diff --git a/sdk/resources/azure-mgmt-resource/_meta.json b/sdk/resources/azure-mgmt-resource/_meta.json index e721723ca4cc8..916a9502b9151 100644 --- a/sdk/resources/azure-mgmt-resource/_meta.json +++ b/sdk/resources/azure-mgmt-resource/_meta.json @@ -1,11 +1,11 @@ { - "autorest": "3.7.2", + "autorest": "3.9.2", "use": [ - "@autorest/python@5.13.0", - "@autorest/modelerfour@4.19.3" + "@autorest/python@6.1.6", + "@autorest/modelerfour@4.24.3" ], - "commit": "8db7df38fe5fca1fc4d2634f5c89e8acfeb1f4ce", + "commit": "8f55d0430fb62a9a5b6f607a6552f73afa3e0c8f", "repository_url": "https://github.com/Azure/azure-rest-api-specs", - "autorest_command": "autorest specification/resources/resource-manager/readme.md --multiapi --python --python-sdks-folder=/home/vsts/work/1/azure-sdk-for-python/sdk --python3-only --use=@autorest/python@5.13.0 --use=@autorest/modelerfour@4.19.3 --version=3.7.2", + "autorest_command": "autorest specification/resources/resource-manager/readme.md --python --python-sdks-folder=/mnt/vss/_work/1/s/azure-sdk-for-python/sdk --use=@autorest/python@6.1.6 --use=@autorest/modelerfour@4.24.3 --version=3.9.2 --version-tolerant=False", "readme": "specification/resources/resource-manager/readme.md" } \ No newline at end of file diff --git a/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/changes/__init__.py b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/changes/__init__.py index 2ffc61590dbd5..c86af52dcdb60 100644 --- a/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/changes/__init__.py +++ b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/changes/__init__.py @@ -14,3 +14,7 @@ patch_sdk() except ImportError: pass + +from ._version import VERSION + +__version__ = VERSION diff --git a/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/changes/_changes_client.py b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/changes/_changes_client.py index 8cb533c5539b7..c77fbc8187da2 100644 --- a/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/changes/_changes_client.py +++ b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/changes/_changes_client.py @@ -9,20 +9,17 @@ # regenerated. # -------------------------------------------------------------------------- -from typing import TYPE_CHECKING - -from msrest import Deserializer, Serializer +from typing import Any, Optional, TYPE_CHECKING from azure.mgmt.core import ARMPipelineClient from azure.profiles import KnownProfiles, ProfileDefinition from azure.profiles.multiapiclient import MultiApiClientMixin from ._configuration import ChangesClientConfiguration +from ._serialization import Deserializer, Serializer if TYPE_CHECKING: # pylint: disable=unused-import,ungrouped-imports - from typing import Any, Optional - from azure.core.credentials import TokenCredential class _SDKClient(object): @@ -43,9 +40,9 @@ class ChangesClient(MultiApiClientMixin, _SDKClient): The api-version parameter sets the default API version if the operation group is not described in the profile. - :param credential: Credential needed for the client to connect to Azure. + :param credential: Credential needed for the client to connect to Azure. Required. :type credential: ~azure.core.credentials.TokenCredential - :param subscription_id: The Azure subscription ID. This is a GUID-formatted string (e.g. 00000000-0000-0000-0000-000000000000). + :param subscription_id: The Azure subscription ID. This is a GUID-formatted string (e.g. 00000000-0000-0000-0000-000000000000). Required. :type subscription_id: str :param api_version: API version to use if no profile is provided, or if missing in profile. :type api_version: str @@ -66,10 +63,10 @@ class ChangesClient(MultiApiClientMixin, _SDKClient): def __init__( self, - credential, # type: "TokenCredential" - subscription_id, # type: str + credential: "TokenCredential", + subscription_id: str, api_version=None, # type: Optional[str] - base_url="https://management.azure.com", # type: str + base_url: str = "https://management.azure.com", profile=KnownProfiles.default, # type: KnownProfiles **kwargs # type: Any ): diff --git a/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/changes/_configuration.py b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/changes/_configuration.py index 68f69c07d0e8f..4060683cb4bdf 100644 --- a/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/changes/_configuration.py +++ b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/changes/_configuration.py @@ -8,7 +8,7 @@ # Changes may cause incorrect behavior and will be lost if the code is # regenerated. # -------------------------------------------------------------------------- -from typing import TYPE_CHECKING +from typing import Any, TYPE_CHECKING from azure.core.configuration import Configuration from azure.core.pipeline import policies @@ -18,8 +18,6 @@ if TYPE_CHECKING: # pylint: disable=unused-import,ungrouped-imports - from typing import Any - from azure.core.credentials import TokenCredential class ChangesClientConfiguration(Configuration): @@ -28,16 +26,16 @@ class ChangesClientConfiguration(Configuration): Note that all parameters used to create this instance are saved as instance attributes. - :param credential: Credential needed for the client to connect to Azure. + :param credential: Credential needed for the client to connect to Azure. Required. :type credential: ~azure.core.credentials.TokenCredential - :param subscription_id: The Azure subscription ID. This is a GUID-formatted string (e.g. 00000000-0000-0000-0000-000000000000). + :param subscription_id: The Azure subscription ID. This is a GUID-formatted string (e.g. 00000000-0000-0000-0000-000000000000). Required. :type subscription_id: str """ def __init__( self, - credential, # type: "TokenCredential" - subscription_id, # type: str + credential: "TokenCredential", + subscription_id: str, **kwargs # type: Any ): # type: (...) -> None diff --git a/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/changes/_serialization.py b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/changes/_serialization.py new file mode 100644 index 0000000000000..240df16c57f3c --- /dev/null +++ b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/changes/_serialization.py @@ -0,0 +1,2006 @@ +# -------------------------------------------------------------------------- +# +# Copyright (c) Microsoft Corporation. All rights reserved. +# +# The MIT License (MIT) +# +# Permission is hereby granted, free of charge, to any person obtaining a copy +# of this software and associated documentation files (the ""Software""), to +# deal in the Software without restriction, including without limitation the +# rights to use, copy, modify, merge, publish, distribute, sublicense, and/or +# sell copies of the Software, and to permit persons to whom the Software is +# furnished to do so, subject to the following conditions: +# +# The above copyright notice and this permission notice shall be included in +# all copies or substantial portions of the Software. +# +# THE SOFTWARE IS PROVIDED *AS IS*, WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING +# FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS +# IN THE SOFTWARE. +# +# -------------------------------------------------------------------------- + +# pylint: skip-file + +from base64 import b64decode, b64encode +import calendar +import datetime +import decimal +import email +from enum import Enum +import json +import logging +import re +import sys +import codecs +try: + from urllib import quote # type: ignore +except ImportError: + from urllib.parse import quote # type: ignore +import xml.etree.ElementTree as ET + +import isodate + +from typing import Dict, Any, cast, TYPE_CHECKING + +from azure.core.exceptions import DeserializationError, SerializationError, raise_with_traceback + +_BOM = codecs.BOM_UTF8.decode(encoding='utf-8') + +if TYPE_CHECKING: + from typing import Optional, Union, AnyStr, IO, Mapping + +class RawDeserializer: + + # Accept "text" because we're open minded people... + JSON_REGEXP = re.compile(r'^(application|text)/([a-z+.]+\+)?json$') + + # Name used in context + CONTEXT_NAME = "deserialized_data" + + @classmethod + def deserialize_from_text(cls, data, content_type=None): + # type: (Optional[Union[AnyStr, IO]], Optional[str]) -> Any + """Decode data according to content-type. + + Accept a stream of data as well, but will be load at once in memory for now. + + If no content-type, will return the string version (not bytes, not stream) + + :param data: Input, could be bytes or stream (will be decoded with UTF8) or text + :type data: str or bytes or IO + :param str content_type: The content type. + """ + if hasattr(data, 'read'): + # Assume a stream + data = cast(IO, data).read() + + if isinstance(data, bytes): + data_as_str = data.decode(encoding='utf-8-sig') + else: + # Explain to mypy the correct type. + data_as_str = cast(str, data) + + # Remove Byte Order Mark if present in string + data_as_str = data_as_str.lstrip(_BOM) + + if content_type is None: + return data + + if cls.JSON_REGEXP.match(content_type): + try: + return json.loads(data_as_str) + except ValueError as err: + raise DeserializationError("JSON is invalid: {}".format(err), err) + elif "xml" in (content_type or []): + try: + + try: + if isinstance(data, unicode): # type: ignore + # If I'm Python 2.7 and unicode XML will scream if I try a "fromstring" on unicode string + data_as_str = data_as_str.encode(encoding="utf-8") # type: ignore + except NameError: + pass + + return ET.fromstring(data_as_str) # nosec + except ET.ParseError: + # It might be because the server has an issue, and returned JSON with + # content-type XML.... + # So let's try a JSON load, and if it's still broken + # let's flow the initial exception + def _json_attemp(data): + try: + return True, json.loads(data) + except ValueError: + return False, None # Don't care about this one + success, json_result = _json_attemp(data) + if success: + return json_result + # If i'm here, it's not JSON, it's not XML, let's scream + # and raise the last context in this block (the XML exception) + # The function hack is because Py2.7 messes up with exception + # context otherwise. + _LOGGER.critical("Wasn't XML not JSON, failing") + raise_with_traceback(DeserializationError, "XML is invalid") + 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 + """Deserialize from HTTP response. + + Use bytes and headers to NOT use any requests/aiohttp or whatever + specific implementation. + Headers will tested for "content-type" + """ + # Try to use content-type from headers if available + content_type = None + if 'content-type' in headers: + content_type = headers['content-type'].split(";")[0].strip().lower() + # Ouch, this server did not declare what it sent... + # Let's guess it's JSON... + # Also, since Autorest was considering that an empty body was a valid JSON, + # need that test as well.... + else: + content_type = "application/json" + + if body_bytes: + return cls.deserialize_from_text(body_bytes, content_type) + return None + +try: + basestring # type: ignore + unicode_str = unicode # type: ignore +except NameError: + basestring = str # type: ignore + unicode_str = str # type: ignore + +_LOGGER = logging.getLogger(__name__) + +try: + _long_type = long # type: ignore +except NameError: + _long_type = int + +class UTC(datetime.tzinfo): + """Time Zone info for handling UTC""" + + def utcoffset(self, dt): + """UTF offset for UTC is 0.""" + return datetime.timedelta(0) + + def tzname(self, dt): + """Timestamp representation.""" + return "Z" + + def dst(self, dt): + """No daylight saving for UTC.""" + return datetime.timedelta(hours=1) + +try: + from datetime import timezone as _FixedOffset +except ImportError: # Python 2.7 + class _FixedOffset(datetime.tzinfo): # type: ignore + """Fixed offset in minutes east from UTC. + Copy/pasted from Python doc + :param datetime.timedelta offset: offset in timedelta format + """ + + def __init__(self, offset): + self.__offset = offset + + def utcoffset(self, dt): + return self.__offset + + def tzname(self, dt): + return str(self.__offset.total_seconds()/3600) + + def __repr__(self): + return "".format(self.tzname(None)) + + def dst(self, dt): + return datetime.timedelta(0) + + def __getinitargs__(self): + return (self.__offset,) + +try: + from datetime import timezone + TZ_UTC = timezone.utc # type: ignore +except ImportError: + TZ_UTC = UTC() # type: ignore + +_FLATTEN = re.compile(r"(? y, + "minimum": lambda x, y: x < y, + "maximum": lambda x, y: x > y, + "minimum_ex": lambda x, y: x <= y, + "maximum_ex": lambda x, y: x >= y, + "min_items": lambda x, y: len(x) < y, + "max_items": lambda x, y: len(x) > y, + "pattern": lambda x, y: not re.match(y, x, re.UNICODE), + "unique": lambda x, y: len(x) != len(set(x)), + "multiple": lambda x, y: x % y != 0 + } + + def __init__(self, classes=None): + self.serialize_type = { + 'iso-8601': Serializer.serialize_iso, + 'rfc-1123': Serializer.serialize_rfc, + 'unix-time': Serializer.serialize_unix, + 'duration': Serializer.serialize_duration, + 'date': Serializer.serialize_date, + 'time': Serializer.serialize_time, + 'decimal': Serializer.serialize_decimal, + 'long': Serializer.serialize_long, + 'bytearray': Serializer.serialize_bytearray, + 'base64': Serializer.serialize_base64, + 'object': self.serialize_object, + '[]': self.serialize_iter, + '{}': self.serialize_dict + } + self.dependencies = dict(classes) if classes else {} + self.key_transformer = full_restapi_key_transformer + self.client_side_validation = True + + def _serialize(self, target_obj, data_type=None, **kwargs): + """Serialize data into a string according to type. + + :param target_obj: The data to be serialized. + :param str data_type: The type to be serialized from. + :rtype: str, dict + :raises: SerializationError if serialization fails. + """ + key_transformer = kwargs.get("key_transformer", self.key_transformer) + keep_readonly = kwargs.get("keep_readonly", False) + if target_obj is None: + return None + + attr_name = None + class_name = target_obj.__class__.__name__ + + if data_type: + return self.serialize_data( + target_obj, data_type, **kwargs) + + if not hasattr(target_obj, "_attribute_map"): + data_type = type(target_obj).__name__ + if data_type in self.basic_types.values(): + return self.serialize_data( + target_obj, data_type, **kwargs) + + # Force "is_xml" kwargs if we detect a XML model + try: + is_xml_model_serialization = kwargs["is_xml"] + except KeyError: + is_xml_model_serialization = kwargs.setdefault("is_xml", target_obj.is_xml_model()) + + serialized = {} + if is_xml_model_serialization: + serialized = target_obj._create_xml_node() + try: + attributes = target_obj._attribute_map + for attr, attr_desc in attributes.items(): + attr_name = attr + if not keep_readonly and target_obj._validation.get(attr_name, {}).get('readonly', False): + continue + + if attr_name == "additional_properties" and attr_desc["key"] == '': + if target_obj.additional_properties is not None: + serialized.update(target_obj.additional_properties) + continue + try: + + orig_attr = getattr(target_obj, attr) + if is_xml_model_serialization: + pass # Don't provide "transformer" for XML for now. Keep "orig_attr" + else: # JSON + keys, orig_attr = key_transformer(attr, attr_desc.copy(), orig_attr) + keys = keys if isinstance(keys, list) else [keys] + + + kwargs["serialization_ctxt"] = attr_desc + new_attr = self.serialize_data(orig_attr, attr_desc['type'], **kwargs) + + + if is_xml_model_serialization: + xml_desc = attr_desc.get('xml', {}) + xml_name = xml_desc.get('name', attr_desc['key']) + xml_prefix = xml_desc.get('prefix', None) + xml_ns = xml_desc.get('ns', None) + 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) + continue + if xml_desc.get("text", False): + serialized.text = new_attr + continue + if isinstance(new_attr, list): + serialized.extend(new_attr) + 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', {}): + splitted_tag = new_attr.tag.split("}") + if len(splitted_tag) == 2: # Namespace + new_attr.tag = "}".join([splitted_tag[0], xml_name]) + else: + new_attr.tag = xml_name + serialized.append(new_attr) + 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) + else: # JSON + for k in reversed(keys): + unflattened = {k: new_attr} + new_attr = unflattened + + _new_attr = new_attr + _serialized = serialized + for k in keys: + if k not in _serialized: + _serialized.update(_new_attr) + _new_attr = _new_attr[k] + _serialized = _serialized[k] + except ValueError: + continue + + except (AttributeError, KeyError, TypeError) as err: + msg = "Attribute {} in object {} cannot be serialized.\n{}".format( + attr_name, class_name, str(target_obj)) + raise_with_traceback(SerializationError, msg, err) + else: + return serialized + + def body(self, data, data_type, **kwargs): + """Serialize data intended for a request body. + + :param data: The data to be serialized. + :param str data_type: The type to be serialized from. + :rtype: dict + :raises: SerializationError if serialization fails. + :raises: ValueError if data is None + """ + + # Just in case this is a dict + internal_data_type = data_type.strip('[]{}') + internal_data_type = self.dependencies.get(internal_data_type, None) + try: + is_xml_model_serialization = kwargs["is_xml"] + except KeyError: + if internal_data_type and issubclass(internal_data_type, Model): + is_xml_model_serialization = kwargs.setdefault("is_xml", internal_data_type.is_xml_model()) + else: + is_xml_model_serialization = False + if internal_data_type and not isinstance(internal_data_type, Enum): + try: + deserializer = Deserializer(self.dependencies) + # Since it's on serialization, it's almost sure that format is not JSON REST + # We're not able to deal with additional properties for now. + deserializer.additional_properties_detection = False + if is_xml_model_serialization: + deserializer.key_extractors = [ + attribute_key_case_insensitive_extractor, + ] + else: + deserializer.key_extractors = [ + rest_key_case_insensitive_extractor, + attribute_key_case_insensitive_extractor, + last_rest_key_case_insensitive_extractor + ] + data = deserializer._deserialize(data_type, data) + except DeserializationError as err: + raise_with_traceback( + SerializationError, "Unable to build a model: "+str(err), err) + + return self._serialize(data, data_type, **kwargs) + + def url(self, name, data, data_type, **kwargs): + """Serialize data intended for a URL path. + + :param data: The data to be serialized. + :param str data_type: The type to be serialized from. + :rtype: str + :raises: TypeError if serialization fails. + :raises: ValueError if data is None + """ + try: + output = self.serialize_data(data, data_type, **kwargs) + if data_type == 'bool': + output = json.dumps(output) + + if kwargs.get('skip_quote') is True: + output = str(output) + else: + output = quote(str(output), safe='') + except SerializationError: + raise TypeError("{} must be type {}.".format(name, data_type)) + else: + return output + + def query(self, name, data, data_type, **kwargs): + """Serialize data intended for a URL query. + + :param data: The data to be serialized. + :param str data_type: The type to be serialized from. + :rtype: str + :raises: TypeError if serialization fails. + :raises: ValueError if data is None + """ + try: + # 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)) + + # Not a list, regular serialization + output = self.serialize_data(data, data_type, **kwargs) + if data_type == 'bool': + output = json.dumps(output) + if kwargs.get('skip_quote') is True: + output = str(output) + else: + output = quote(str(output), safe='') + except SerializationError: + raise TypeError("{} must be type {}.".format(name, data_type)) + else: + return str(output) + + def header(self, name, data, data_type, **kwargs): + """Serialize data intended for a request header. + + :param data: The data to be serialized. + :param str data_type: The type to be serialized from. + :rtype: str + :raises: TypeError if serialization fails. + :raises: ValueError if data is None + """ + try: + if data_type in ['[str]']: + data = ["" if d is None else d for d in data] + + output = self.serialize_data(data, data_type, **kwargs) + if data_type == 'bool': + output = json.dumps(output) + except SerializationError: + raise TypeError("{} must be type {}.".format(name, data_type)) + else: + return str(output) + + def serialize_data(self, data, data_type, **kwargs): + """Serialize generic data according to supplied data type. + + :param data: The data to be serialized. + :param str data_type: The type to be serialized from. + :param bool required: Whether it's essential that the data not be + empty or None + :raises: AttributeError if required data is None. + :raises: ValueError if data is None + :raises: SerializationError if serialization fails. + """ + if data is None: + raise ValueError("No value for given attribute") + + try: + if data_type in self.basic_types.values(): + return self.serialize_basic(data, data_type, **kwargs) + + elif data_type in self.serialize_type: + return self.serialize_type[data_type](data, **kwargs) + + # If dependencies is empty, try with current data class + # It has to be a subclass of Enum anyway + enum_type = self.dependencies.get(data_type, data.__class__) + if issubclass(enum_type, Enum): + return Serializer.serialize_enum(data, enum_obj=enum_type) + + iter_type = data_type[0] + data_type[-1] + if iter_type in self.serialize_type: + return self.serialize_type[iter_type]( + data, data_type[1:-1], **kwargs) + + except (ValueError, TypeError) as err: + msg = "Unable to serialize value: {!r} as type: {!r}." + raise_with_traceback( + SerializationError, msg.format(data, data_type), err) + else: + return self._serialize(data, **kwargs) + + @classmethod + def _get_custom_serializers(cls, data_type, **kwargs): + custom_serializer = kwargs.get("basic_types_serializers", {}).get(data_type) + if custom_serializer: + return custom_serializer + if kwargs.get("is_xml", False): + return cls._xml_basic_types_serializers.get(data_type) + + @classmethod + def serialize_basic(cls, data, data_type, **kwargs): + """Serialize basic builting data type. + Serializes objects to str, int, float or bool. + + Possible kwargs: + - basic_types_serializers dict[str, callable] : If set, use the callable as serializer + - is_xml bool : If set, use xml_basic_types_serializers + + :param data: Object to be serialized. + :param str data_type: Type of object in the iterable. + """ + custom_serializer = cls._get_custom_serializers(data_type, **kwargs) + if custom_serializer: + return custom_serializer(data) + if data_type == 'str': + return cls.serialize_unicode(data) + return eval(data_type)(data) # nosec + + @classmethod + def serialize_unicode(cls, data): + """Special handling for serializing unicode strings in Py2. + Encode to UTF-8 if unicode, otherwise handle as a str. + + :param data: Object to be serialized. + :rtype: str + """ + try: # If I received an enum, return its value + return data.value + except AttributeError: + pass + + try: + if isinstance(data, unicode): + # Don't change it, JSON and XML ElementTree are totally able + # to serialize correctly u'' strings + return data + except NameError: + return str(data) + else: + return str(data) + + def serialize_iter(self, data, iter_type, div=None, **kwargs): + """Serialize iterable. + + Supported kwargs: + - serialization_ctxt dict : The current entry of _attribute_map, or same format. + serialization_ctxt['type'] should be same as data_type. + - is_xml bool : If set, serialize as XML + + :param list attr: Object to be serialized. + :param str iter_type: Type of object in the iterable. + :param bool required: Whether the objects in the iterable must + not be None or empty. + :param str div: If set, this str will be used to combine the elements + in the iterable into a combined string. Default is 'None'. + :rtype: list, str + """ + if isinstance(data, str): + raise SerializationError("Refuse str type as a valid iter type.") + + serialization_ctxt = kwargs.get("serialization_ctxt", {}) + is_xml = kwargs.get("is_xml", False) + + serialized = [] + for d in data: + try: + serialized.append(self.serialize_data(d, iter_type, **kwargs)) + except ValueError: + serialized.append(None) + + if div: + serialized = ['' if s is None else str(s) for s in serialized] + serialized = div.join(serialized) + + if 'xml' in serialization_ctxt or is_xml: + # XML serialization is more complicated + xml_desc = serialization_ctxt.get('xml', {}) + xml_name = xml_desc.get('name') + if not xml_name: + xml_name = serialization_ctxt['key'] + + # Create a wrap node if necessary (use the fact that Element and list have "append") + is_wrapped = xml_desc.get("wrapped", False) + node_name = xml_desc.get("itemsName", xml_name) + if is_wrapped: + final_result = _create_xml_node( + xml_name, + xml_desc.get('prefix', None), + xml_desc.get('ns', None) + ) + else: + final_result = [] + # All list elements to "local_node" + for el in serialized: + if isinstance(el, ET.Element): + el_node = el + else: + el_node = _create_xml_node( + node_name, + xml_desc.get('prefix', None), + xml_desc.get('ns', None) + ) + if el is not None: # Otherwise it writes "None" :-p + el_node.text = str(el) + final_result.append(el_node) + return final_result + return serialized + + def serialize_dict(self, attr, dict_type, **kwargs): + """Serialize a dictionary of objects. + + :param dict attr: Object to be serialized. + :param str dict_type: Type of object in the dictionary. + :param bool required: Whether the objects in the dictionary must + not be None or empty. + :rtype: dict + """ + serialization_ctxt = kwargs.get("serialization_ctxt", {}) + serialized = {} + for key, value in attr.items(): + try: + serialized[self.serialize_unicode(key)] = self.serialize_data( + value, dict_type, **kwargs) + except ValueError: + serialized[self.serialize_unicode(key)] = None + + if 'xml' in serialization_ctxt: + # XML serialization is more complicated + xml_desc = serialization_ctxt['xml'] + xml_name = xml_desc['name'] + + final_result = _create_xml_node( + xml_name, + xml_desc.get('prefix', None), + xml_desc.get('ns', None) + ) + for key, value in serialized.items(): + ET.SubElement(final_result, key).text = value + return final_result + + return serialized + + def serialize_object(self, attr, **kwargs): + """Serialize a generic object. + This will be handled as a dictionary. If object passed in is not + a basic type (str, int, float, dict, list) it will simply be + cast to str. + + :param dict attr: Object to be serialized. + :rtype: dict or str + """ + if attr is None: + return None + if isinstance(attr, ET.Element): + return attr + obj_type = type(attr) + if obj_type in self.basic_types: + return self.serialize_basic(attr, self.basic_types[obj_type], **kwargs) + if obj_type is _long_type: + return self.serialize_long(attr) + if obj_type is unicode_str: + return self.serialize_unicode(attr) + if obj_type is datetime.datetime: + return self.serialize_iso(attr) + if obj_type is datetime.date: + return self.serialize_date(attr) + if obj_type is datetime.time: + return self.serialize_time(attr) + if obj_type is datetime.timedelta: + return self.serialize_duration(attr) + if obj_type is decimal.Decimal: + return self.serialize_decimal(attr) + + # If it's a model or I know this dependency, serialize as a Model + elif obj_type in self.dependencies.values() or isinstance(attr, Model): + return self._serialize(attr) + + if obj_type == dict: + serialized = {} + for key, value in attr.items(): + try: + serialized[self.serialize_unicode(key)] = self.serialize_object( + value, **kwargs) + except ValueError: + serialized[self.serialize_unicode(key)] = None + return serialized + + if obj_type == list: + serialized = [] + for obj in attr: + try: + serialized.append(self.serialize_object( + obj, **kwargs)) + except ValueError: + pass + return serialized + return str(attr) + + @staticmethod + def serialize_enum(attr, enum_obj=None): + try: + result = attr.value + except AttributeError: + result = attr + try: + enum_obj(result) + return result + except ValueError: + for enum_value in enum_obj: + if enum_value.value.lower() == str(attr).lower(): + return enum_value.value + error = "{!r} is not valid value for enum {!r}" + raise SerializationError(error.format(attr, enum_obj)) + + @staticmethod + def serialize_bytearray(attr, **kwargs): + """Serialize bytearray into base-64 string. + + :param attr: Object to be serialized. + :rtype: str + """ + return b64encode(attr).decode() + + @staticmethod + def serialize_base64(attr, **kwargs): + """Serialize str into base-64 string. + + :param attr: Object to be serialized. + :rtype: str + """ + encoded = b64encode(attr).decode('ascii') + return encoded.strip('=').replace('+', '-').replace('/', '_') + + @staticmethod + def serialize_decimal(attr, **kwargs): + """Serialize Decimal object to float. + + :param attr: Object to be serialized. + :rtype: float + """ + return float(attr) + + @staticmethod + def serialize_long(attr, **kwargs): + """Serialize long (Py2) or int (Py3). + + :param attr: Object to be serialized. + :rtype: int/long + """ + return _long_type(attr) + + @staticmethod + def serialize_date(attr, **kwargs): + """Serialize Date object into ISO-8601 formatted string. + + :param Date attr: Object to be serialized. + :rtype: str + """ + if isinstance(attr, str): + attr = isodate.parse_date(attr) + t = "{:04}-{:02}-{:02}".format(attr.year, attr.month, attr.day) + return t + + @staticmethod + def serialize_time(attr, **kwargs): + """Serialize Time object into ISO-8601 formatted string. + + :param datetime.time attr: Object to be serialized. + :rtype: str + """ + if isinstance(attr, str): + attr = isodate.parse_time(attr) + t = "{:02}:{:02}:{:02}".format(attr.hour, attr.minute, attr.second) + if attr.microsecond: + t += ".{:02}".format(attr.microsecond) + return t + + @staticmethod + def serialize_duration(attr, **kwargs): + """Serialize TimeDelta object into ISO-8601 formatted string. + + :param TimeDelta attr: Object to be serialized. + :rtype: str + """ + if isinstance(attr, str): + attr = isodate.parse_duration(attr) + return isodate.duration_isoformat(attr) + + @staticmethod + def serialize_rfc(attr, **kwargs): + """Serialize Datetime object into RFC-1123 formatted string. + + :param Datetime attr: Object to be serialized. + :rtype: str + :raises: TypeError if format invalid. + """ + try: + if not attr.tzinfo: + _LOGGER.warning( + "Datetime with no tzinfo will be considered UTC.") + utc = attr.utctimetuple() + except AttributeError: + raise TypeError("RFC1123 object must be valid Datetime object.") + + return "{}, {:02} {} {:04} {:02}:{:02}:{:02} GMT".format( + Serializer.days[utc.tm_wday], utc.tm_mday, + Serializer.months[utc.tm_mon], utc.tm_year, + utc.tm_hour, utc.tm_min, utc.tm_sec) + + @staticmethod + def serialize_iso(attr, **kwargs): + """Serialize Datetime object into ISO-8601 formatted string. + + :param Datetime attr: Object to be serialized. + :rtype: str + :raises: SerializationError if format invalid. + """ + if isinstance(attr, str): + attr = isodate.parse_datetime(attr) + try: + if not attr.tzinfo: + _LOGGER.warning( + "Datetime with no tzinfo will be considered UTC.") + utc = attr.utctimetuple() + if utc.tm_year > 9999 or utc.tm_year < 1: + raise OverflowError("Hit max or min date") + + microseconds = str(attr.microsecond).rjust(6,'0').rstrip('0').ljust(3, '0') + if microseconds: + microseconds = '.'+microseconds + date = "{:04}-{:02}-{:02}T{:02}:{:02}:{:02}".format( + utc.tm_year, utc.tm_mon, utc.tm_mday, + utc.tm_hour, utc.tm_min, utc.tm_sec) + return date + microseconds + 'Z' + except (ValueError, OverflowError) as err: + msg = "Unable to serialize datetime object." + raise_with_traceback(SerializationError, msg, err) + except AttributeError as err: + msg = "ISO-8601 object must be valid Datetime object." + raise_with_traceback(TypeError, msg, err) + + @staticmethod + def serialize_unix(attr, **kwargs): + """Serialize Datetime object into IntTime format. + This is represented as seconds. + + :param Datetime attr: Object to be serialized. + :rtype: int + :raises: SerializationError if format invalid + """ + if isinstance(attr, int): + return attr + try: + if not attr.tzinfo: + _LOGGER.warning( + "Datetime with no tzinfo will be considered UTC.") + return int(calendar.timegm(attr.utctimetuple())) + except AttributeError: + raise TypeError("Unix time object must be valid Datetime object.") + +def rest_key_extractor(attr, attr_desc, data): + key = attr_desc['key'] + working_data = data + + while '.' in key: + dict_keys = _FLATTEN.split(key) + if len(dict_keys) == 1: + key = _decode_attribute_map_key(dict_keys[0]) + break + working_key = _decode_attribute_map_key(dict_keys[0]) + working_data = working_data.get(working_key, data) + if working_data is None: + # If at any point while following flatten JSON path see None, it means + # that all properties under are None as well + # https://github.com/Azure/msrest-for-python/issues/197 + return None + key = '.'.join(dict_keys[1:]) + + return working_data.get(key) + +def rest_key_case_insensitive_extractor(attr, attr_desc, data): + key = attr_desc['key'] + working_data = data + + while '.' in key: + dict_keys = _FLATTEN.split(key) + if len(dict_keys) == 1: + key = _decode_attribute_map_key(dict_keys[0]) + break + working_key = _decode_attribute_map_key(dict_keys[0]) + working_data = attribute_key_case_insensitive_extractor(working_key, None, working_data) + if working_data is None: + # If at any point while following flatten JSON path see None, it means + # that all properties under are None as well + # https://github.com/Azure/msrest-for-python/issues/197 + return None + key = '.'.join(dict_keys[1:]) + + if working_data: + return attribute_key_case_insensitive_extractor(key, None, working_data) + +def last_rest_key_extractor(attr, attr_desc, data): + """Extract the attribute in "data" based on the last part of the JSON path key. + """ + key = attr_desc['key'] + dict_keys = _FLATTEN.split(key) + return attribute_key_extractor(dict_keys[-1], None, data) + +def last_rest_key_case_insensitive_extractor(attr, attr_desc, data): + """Extract the attribute in "data" based on the last part of the JSON path key. + + This is the case insensitive version of "last_rest_key_extractor" + """ + key = attr_desc['key'] + dict_keys = _FLATTEN.split(key) + return attribute_key_case_insensitive_extractor(dict_keys[-1], None, data) + +def attribute_key_extractor(attr, _, data): + return data.get(attr) + +def attribute_key_case_insensitive_extractor(attr, _, data): + found_key = None + lower_attr = attr.lower() + for key in data: + if lower_attr == key.lower(): + found_key = key + break + + return data.get(found_key) + +def _extract_name_from_internal_type(internal_type): + """Given an internal type XML description, extract correct XML name with namespace. + + :param dict internal_type: An model type + :rtype: tuple + :returns: A tuple XML name + namespace dict + """ + internal_type_xml_map = getattr(internal_type, "_xml_map", {}) + 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) + return xml_name + + +def xml_key_extractor(attr, attr_desc, data): + if isinstance(data, dict): + return None + + # Test if this model is XML ready first + if not isinstance(data, ET.Element): + return None + + xml_desc = attr_desc.get('xml', {}) + xml_name = xml_desc.get('name', attr_desc['key']) + + # Look for a children + is_iter_type = attr_desc['type'].startswith("[") + is_wrapped = xml_desc.get("wrapped", False) + internal_type = attr_desc.get("internalType", None) + internal_type_xml_map = getattr(internal_type, "_xml_map", {}) + + # 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) + + # If it's an attribute, that's simple + if xml_desc.get("attr", False): + return data.get(xml_name) + + # If it's x-ms-text, that's simple too + if xml_desc.get("text", False): + return data.text + + # Scenario where I take the local name: + # - Wrapped node + # - Internal type is an enum (considered basic types) + # - Internal type has no XML/Name node + if is_wrapped or (internal_type and (issubclass(internal_type, Enum) or 'name' not in internal_type_xml_map)): + children = data.findall(xml_name) + # If internal type has a local name and it's not a list, I use that name + elif not is_iter_type and internal_type and 'name' in internal_type_xml_map: + xml_name = _extract_name_from_internal_type(internal_type) + children = data.findall(xml_name) + # That's an array + else: + if internal_type: # Complex type, ignore itemsName and use the complex type name + items_name = _extract_name_from_internal_type(internal_type) + else: + items_name = xml_desc.get("itemsName", xml_name) + children = data.findall(items_name) + + if len(children) == 0: + if is_iter_type: + if is_wrapped: + return None # is_wrapped no node, we want None + else: + return [] # not wrapped, assume empty list + return None # Assume it's not there, maybe an optional node. + + # If is_iter_type and not wrapped, return all found children + if is_iter_type: + if not is_wrapped: + return children + else: # Iter and wrapped, should have found one node only (the wrap one) + if len(children) != 1: + raise DeserializationError( + "Tried to deserialize an array not wrapped, and found several nodes '{}'. Maybe you should declare this array as wrapped?".format( + xml_name + )) + return list(children[0]) # Might be empty list and that's ok. + + # Here it's not a itertype, we should have found one element only or empty + if len(children) > 1: + raise DeserializationError("Find several XML '{}' where it was not expected".format(xml_name)) + return children[0] + +class Deserializer(object): + """Response object model deserializer. + + :param dict classes: Class type dictionary for deserializing complex types. + :ivar list key_extractors: Ordered list of extractors to be used by this deserializer. + """ + + basic_types = {str: 'str', int: 'int', bool: 'bool', float: 'float'} + + valid_date = re.compile( + r'\d{4}[-]\d{2}[-]\d{2}T\d{2}:\d{2}:\d{2}' + r'\.?\d*Z?[-+]?[\d{2}]?:?[\d{2}]?') + + def __init__(self, classes=None): + self.deserialize_type = { + 'iso-8601': Deserializer.deserialize_iso, + 'rfc-1123': Deserializer.deserialize_rfc, + 'unix-time': Deserializer.deserialize_unix, + 'duration': Deserializer.deserialize_duration, + 'date': Deserializer.deserialize_date, + 'time': Deserializer.deserialize_time, + 'decimal': Deserializer.deserialize_decimal, + 'long': Deserializer.deserialize_long, + 'bytearray': Deserializer.deserialize_bytearray, + 'base64': Deserializer.deserialize_base64, + 'object': self.deserialize_object, + '[]': self.deserialize_iter, + '{}': self.deserialize_dict + } + self.deserialize_expected_types = { + 'duration': (isodate.Duration, datetime.timedelta), + 'iso-8601': (datetime.datetime) + } + self.dependencies = 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 + # complicated, with no real scenario for now. + # So adding a flag to disable additional properties detection. This flag should be + # used if your expect the deserialization to NOT come from a JSON REST syntax. + # Otherwise, result are unexpected + self.additional_properties_detection = True + + def __call__(self, target_obj, response_data, content_type=None): + """Call the deserializer to process a REST response. + + :param str target_obj: Target data type to deserialize to. + :param requests.Response response_data: REST response object. + :param str content_type: Swagger "produces" if available. + :raises: DeserializationError if deserialization fails. + :return: Deserialized object. + """ + data = self._unpack_content(response_data, content_type) + return self._deserialize(target_obj, data) + + def _deserialize(self, target_obj, data): + """Call the deserializer on a model. + + Data needs to be already deserialized as JSON or XML ElementTree + + :param str target_obj: Target data type to deserialize to. + :param object data: Object to deserialize. + :raises: DeserializationError if deserialization fails. + :return: Deserialized object. + """ + # This is already a model, go recursive just in case + if hasattr(data, "_attribute_map"): + constants = [name for name, config in getattr(data, '_validation', {}).items() + if config.get('constant')] + try: + for attr, mapconfig in data._attribute_map.items(): + if attr in constants: + continue + value = getattr(data, attr) + if value is None: + continue + local_type = mapconfig['type'] + internal_data_type = local_type.strip('[]{}') + if internal_data_type not in self.dependencies or isinstance(internal_data_type, Enum): + continue + setattr( + data, + attr, + self._deserialize(local_type, value) + ) + return data + except AttributeError: + return + + response, class_name = self._classify_target(target_obj, data) + + if isinstance(response, basestring): + return self.deserialize_data(data, response) + elif isinstance(response, type) and issubclass(response, Enum): + return self.deserialize_enum(data, response) + + if data is None: + return data + try: + attributes = response._attribute_map + d_attrs = {} + for attr, attr_desc in attributes.items(): + # Check empty string. If it's not empty, someone has a real "additionalProperties"... + if attr == "additional_properties" and attr_desc["key"] == '': + continue + raw_value = None + # Enhance attr_desc with some dynamic data + attr_desc = attr_desc.copy() # Do a copy, do not change the real one + internal_data_type = attr_desc["type"].strip('[]{}') + if internal_data_type in self.dependencies: + attr_desc["internalType"] = self.dependencies[internal_data_type] + + for key_extractor in self.key_extractors: + found_value = key_extractor(attr, attr_desc, data) + if found_value is not None: + if raw_value is not None and raw_value != found_value: + msg = ("Ignoring extracted value '%s' from %s for key '%s'" + " (duplicate extraction, follow extractors order)" ) + _LOGGER.warning( + msg, + found_value, + key_extractor, + attr + ) + continue + raw_value = found_value + + 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 + raise_with_traceback(DeserializationError, msg, err) + else: + additional_properties = self._build_additional_properties(attributes, data) + return self._instantiate_model(response, d_attrs, additional_properties) + + def _build_additional_properties(self, attribute_map, data): + if not self.additional_properties_detection: + return None + if "additional_properties" in attribute_map and attribute_map.get("additional_properties", {}).get("key") != '': + # Check empty string. If it's not empty, someone has a real "additionalProperties" + return None + if isinstance(data, ET.Element): + data = {el.tag: el.text for el in data} + + known_keys = {_decode_attribute_map_key(_FLATTEN.split(desc['key'])[0]) + for desc in attribute_map.values() if desc['key'] != ''} + present_keys = set(data.keys()) + missing_keys = present_keys - known_keys + return {key: data[key] for key in missing_keys} + + def _classify_target(self, target, data): + """Check to see whether the deserialization target object can + be classified into a subclass. + 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. + """ + if target is None: + return None, None + + if isinstance(target, basestring): + try: + target = self.dependencies[target] + except KeyError: + return target, target + + try: + target = target._classify(data, self.dependencies) + except AttributeError: + pass # Target is not a Model, no classify + return target, target.__class__.__name__ + + def failsafe_deserialize(self, target_obj, data, content_type=None): + """Ignores any errors encountered in deserialization, + and falls back to not deserializing the object. Recommended + for use in error deserialization, as we want to return the + HttpResponseError to users, and not have them deal with + 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 content_type: Swagger "produces" if available. + """ + try: + return self(target_obj, data, content_type=content_type) + except: + _LOGGER.debug( + "Ran into a deserialization error. Ignoring since this is failsafe deserialization", + exc_info=True + ) + return None + + @staticmethod + def _unpack_content(raw_data, content_type=None): + """Extract the correct structure for deserialization. + + If raw_data is a PipelineResponse, try to extract the result of RawDeserializer. + if we can't, raise. Your Pipeline should have a RawDeserializer. + + If not a pipeline response and raw_data is bytes or string, use content-type + to decode it. If no content-type, try JSON. + + If raw_data is something else, bypass all logic and return it directly. + + :param raw_data: Data to be processed. + :param content_type: How to parse if raw_data is a string/bytes. + :raises JSONDecodeError: If JSON is requested and parsing is impossible. + :raises UnicodeDecodeError: If bytes is not UTF8 + """ + # Assume this is enough to detect a Pipeline Response without importing it + context = getattr(raw_data, "context", {}) + if context: + if RawDeserializer.CONTEXT_NAME in context: + return context[RawDeserializer.CONTEXT_NAME] + raise ValueError("This pipeline didn't have the RawDeserializer policy; can't deserialize") + + #Assume this is enough to recognize universal_http.ClientResponse without importing it + if hasattr(raw_data, "body"): + return RawDeserializer.deserialize_from_http_generics( + raw_data.text(), + raw_data.headers + ) + + # Assume this enough to recognize requests.Response without importing it. + if hasattr(raw_data, '_content_consumed'): + 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 raw_data + + def _instantiate_model(self, response, attrs, additional_properties=None): + """Instantiate a response model passing in deserialized args. + + :param response: The response model class. + :param d_attrs: The deserialized response attributes. + """ + if callable(response): + subtype = getattr(response, '_subtype_map', {}) + try: + readonly = [k for k, v in response._validation.items() + if v.get('readonly')] + const = [k for k, v in response._validation.items() + if v.get('constant')] + kwargs = {k: v for k, v in attrs.items() + if k not in subtype and k not in readonly + const} + response_obj = response(**kwargs) + for attr in readonly: + setattr(response_obj, attr, attrs.get(attr)) + if additional_properties: + response_obj.additional_properties = additional_properties + return response_obj + except TypeError as err: + msg = "Unable to deserialize {} into model {}. ".format( + kwargs, response) + raise DeserializationError(msg + str(err)) + else: + try: + for attr, value in attrs.items(): + setattr(response, attr, value) + return response + except Exception as exp: + msg = "Unable to populate response model. " + msg += "Type: {}, Error: {}".format(type(response), exp) + raise DeserializationError(msg) + + def deserialize_data(self, data, data_type): + """Process data for deserialization according to data type. + + :param str data: The response string to be deserialized. + :param str data_type: The type to deserialize to. + :raises: DeserializationError if deserialization fails. + :return: Deserialized object. + """ + if data is None: + return data + + try: + if not data_type: + return data + if data_type in self.basic_types.values(): + return self.deserialize_basic(data, data_type) + if data_type in self.deserialize_type: + if isinstance(data, self.deserialize_expected_types.get(data_type, tuple())): + return data + + is_a_text_parsing_type = lambda x: x not in ["object", "[]", r"{}"] + if isinstance(data, ET.Element) and is_a_text_parsing_type(data_type) and not data.text: + return None + data_val = self.deserialize_type[data_type](data) + return data_val + + iter_type = data_type[0] + data_type[-1] + if iter_type in self.deserialize_type: + return self.deserialize_type[iter_type](data, data_type[1:-1]) + + obj_type = self.dependencies[data_type] + if issubclass(obj_type, Enum): + if isinstance(data, ET.Element): + data = data.text + return self.deserialize_enum(data, obj_type) + + except (ValueError, TypeError, AttributeError) as err: + msg = "Unable to deserialize response data." + msg += " Data: {}, {}".format(data, data_type) + raise_with_traceback(DeserializationError, msg, err) + else: + return self._deserialize(obj_type, data) + + def deserialize_iter(self, attr, iter_type): + """Deserialize an iterable. + + :param list attr: Iterable to be deserialized. + :param str iter_type: The type of object in the iterable. + :rtype: list + """ + if attr is None: + return None + if isinstance(attr, ET.Element): # If I receive an element here, get the children + attr = list(attr) + if not isinstance(attr, (list, set)): + raise DeserializationError("Cannot deserialize as [{}] an object of type {}".format( + iter_type, + type(attr) + )) + return [self.deserialize_data(a, iter_type) for a in attr] + + def deserialize_dict(self, attr, dict_type): + """Deserialize a dictionary. + + :param dict/list attr: Dictionary to be deserialized. Also accepts + a list of key, value pairs. + :param str dict_type: The object type of the items in the dictionary. + :rtype: dict + """ + if isinstance(attr, list): + return {x['key']: self.deserialize_data(x['value'], dict_type) for x in attr} + + if isinstance(attr, ET.Element): + # Transform value into {"Key": "value"} + attr = {el.tag: el.text for el in attr} + return {k: self.deserialize_data(v, dict_type) for k, v in attr.items()} + + def deserialize_object(self, attr, **kwargs): + """Deserialize a generic object. + This will be handled as a dictionary. + + :param dict attr: Dictionary to be deserialized. + :rtype: dict + :raises: TypeError if non-builtin datatype encountered. + """ + if attr is None: + return None + if isinstance(attr, ET.Element): + # Do no recurse on XML, just return the tree as-is + return attr + if isinstance(attr, basestring): + return self.deserialize_basic(attr, 'str') + obj_type = type(attr) + if obj_type in self.basic_types: + return self.deserialize_basic(attr, self.basic_types[obj_type]) + if obj_type is _long_type: + return self.deserialize_long(attr) + + if obj_type == dict: + deserialized = {} + for key, value in attr.items(): + try: + deserialized[key] = self.deserialize_object( + value, **kwargs) + except ValueError: + deserialized[key] = None + return deserialized + + if obj_type == list: + deserialized = [] + for obj in attr: + try: + deserialized.append(self.deserialize_object( + obj, **kwargs)) + except ValueError: + pass + return deserialized + + else: + error = "Cannot deserialize generic object with type: " + raise TypeError(error + str(obj_type)) + + def deserialize_basic(self, attr, data_type): + """Deserialize basic builtin data type from string. + Will attempt to convert to str, int, float and bool. + This function will also accept '1', '0', 'true' and 'false' as + valid bool values. + + :param str attr: response string to be deserialized. + :param str data_type: deserialization data type. + :rtype: str, int, float or bool + :raises: TypeError if string format is not valid. + """ + # If we're here, data is supposed to be a basic type. + # If it's still an XML node, take the text + if isinstance(attr, ET.Element): + attr = attr.text + if not attr: + if data_type == "str": + # None or '', node is empty string. + return '' + else: + # None or '', node with a strong type is None. + # Don't try to model "empty bool" or "empty int" + return None + + if data_type == 'bool': + if attr in [True, False, 1, 0]: + return bool(attr) + elif isinstance(attr, basestring): + if attr.lower() in ['true', '1']: + return True + elif attr.lower() in ['false', '0']: + return False + raise TypeError("Invalid boolean value: {}".format(attr)) + + if data_type == 'str': + return self.deserialize_unicode(attr) + return eval(data_type)(attr) # nosec + + @staticmethod + def deserialize_unicode(data): + """Preserve unicode objects in Python 2, otherwise return data + as a string. + + :param str data: response string to be deserialized. + :rtype: str or unicode + """ + # We might be here because we have an enum modeled as string, + # and we try to deserialize a partial dict with enum inside + if isinstance(data, Enum): + return data + + # Consider this is real string + try: + if isinstance(data, unicode): + return data + except NameError: + return str(data) + else: + return str(data) + + @staticmethod + def deserialize_enum(data, enum_obj): + """Deserialize string into enum object. + + If the string is not a valid enum value it will be returned as-is + and a warning will be logged. + + :param str data: Response string to be deserialized. If this value is + None or invalid it will be returned as-is. + :param Enum enum_obj: Enum object to deserialize to. + :rtype: Enum + """ + if isinstance(data, enum_obj) or data is None: + return data + if isinstance(data, Enum): + data = data.value + if isinstance(data, int): + # Workaround. We might consider remove it in the future. + # https://github.com/Azure/azure-rest-api-specs/issues/141 + try: + return list(enum_obj.__members__.values())[data] + except IndexError: + error = "{!r} is not a valid index for enum {!r}" + raise DeserializationError(error.format(data, enum_obj)) + try: + return enum_obj(str(data)) + except ValueError: + for enum_value in enum_obj: + if enum_value.value.lower() == str(data).lower(): + return enum_value + # We don't fail anymore for unknown value, we deserialize as a string + _LOGGER.warning("Deserializer is not able to find %s as valid enum in %s", data, enum_obj) + return Deserializer.deserialize_unicode(data) + + @staticmethod + def deserialize_bytearray(attr): + """Deserialize string into bytearray. + + :param str attr: response string to be deserialized. + :rtype: bytearray + :raises: TypeError if string format invalid. + """ + if isinstance(attr, ET.Element): + attr = attr.text + return bytearray(b64decode(attr)) + + @staticmethod + def deserialize_base64(attr): + """Deserialize base64 encoded string into string. + + :param str attr: response string to be deserialized. + :rtype: bytearray + :raises: TypeError if string format invalid. + """ + if isinstance(attr, ET.Element): + attr = attr.text + padding = '=' * (3 - (len(attr) + 3) % 4) + attr = attr + padding + encoded = attr.replace('-', '+').replace('_', '/') + return b64decode(encoded) + + @staticmethod + def deserialize_decimal(attr): + """Deserialize string into Decimal object. + + :param str attr: response string to be deserialized. + :rtype: Decimal + :raises: DeserializationError if string format invalid. + """ + if isinstance(attr, ET.Element): + attr = attr.text + try: + return decimal.Decimal(attr) + except decimal.DecimalException as err: + msg = "Invalid decimal {}".format(attr) + raise_with_traceback(DeserializationError, msg, err) + + @staticmethod + def deserialize_long(attr): + """Deserialize string into long (Py2) or int (Py3). + + :param str attr: response string to be deserialized. + :rtype: long or int + :raises: ValueError if string format invalid. + """ + if isinstance(attr, ET.Element): + attr = attr.text + return _long_type(attr) + + @staticmethod + def deserialize_duration(attr): + """Deserialize ISO-8601 formatted string into TimeDelta object. + + :param str attr: response string to be deserialized. + :rtype: TimeDelta + :raises: DeserializationError if string format invalid. + """ + if isinstance(attr, ET.Element): + attr = attr.text + try: + duration = isodate.parse_duration(attr) + except(ValueError, OverflowError, AttributeError) as err: + msg = "Cannot deserialize duration object." + raise_with_traceback(DeserializationError, msg, err) + else: + return duration + + @staticmethod + def deserialize_date(attr): + """Deserialize ISO-8601 formatted string into Date object. + + :param str attr: response string to be deserialized. + :rtype: Date + :raises: DeserializationError if string format invalid. + """ + if isinstance(attr, ET.Element): + attr = attr.text + if re.search(r"[^\W\d_]", attr, re.I + re.U): + 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) + + @staticmethod + def deserialize_time(attr): + """Deserialize ISO-8601 formatted string into time object. + + :param str attr: response string to be deserialized. + :rtype: datetime.time + :raises: DeserializationError if string format invalid. + """ + if isinstance(attr, ET.Element): + attr = attr.text + if re.search(r"[^\W\d_]", attr, re.I + re.U): + raise DeserializationError("Date must have only digits and -. Received: %s" % attr) + return isodate.parse_time(attr) + + @staticmethod + def deserialize_rfc(attr): + """Deserialize RFC-1123 formatted string into Datetime object. + + :param str attr: response string to be deserialized. + :rtype: Datetime + :raises: DeserializationError if string format invalid. + """ + if isinstance(attr, ET.Element): + attr = attr.text + try: + parsed_date = email.utils.parsedate_tz(attr) + date_obj = datetime.datetime( + *parsed_date[:6], + tzinfo=_FixedOffset(datetime.timedelta(minutes=(parsed_date[9] or 0)/60)) + ) + if not date_obj.tzinfo: + date_obj = date_obj.astimezone(tz=TZ_UTC) + except ValueError as err: + msg = "Cannot deserialize to rfc datetime object." + raise_with_traceback(DeserializationError, msg, err) + else: + return date_obj + + @staticmethod + def deserialize_iso(attr): + """Deserialize ISO-8601 formatted string into Datetime object. + + :param str attr: response string to be deserialized. + :rtype: Datetime + :raises: DeserializationError if string format invalid. + """ + if isinstance(attr, ET.Element): + attr = attr.text + try: + attr = attr.upper() + match = Deserializer.valid_date.match(attr) + if not match: + raise ValueError("Invalid datetime string: " + attr) + + check_decimal = attr.split('.') + if len(check_decimal) > 1: + decimal_str = "" + for digit in check_decimal[1]: + if digit.isdigit(): + decimal_str += digit + else: + break + if len(decimal_str) > 6: + attr = attr.replace(decimal_str, decimal_str[0:6]) + + date_obj = isodate.parse_datetime(attr) + test_utc = date_obj.utctimetuple() + if test_utc.tm_year > 9999 or test_utc.tm_year < 1: + raise OverflowError("Hit max or min date") + except(ValueError, OverflowError, AttributeError) as err: + msg = "Cannot deserialize datetime object." + raise_with_traceback(DeserializationError, msg, err) + else: + return date_obj + + @staticmethod + def deserialize_unix(attr): + """Serialize Datetime object into IntTime format. + This is represented as seconds. + + :param int attr: Object to be serialized. + :rtype: Datetime + :raises: DeserializationError if format invalid + """ + if isinstance(attr, ET.Element): + attr = int(attr.text) + try: + date_obj = datetime.datetime.fromtimestamp(attr, TZ_UTC) + except ValueError as err: + msg = "Cannot deserialize to unix datetime object." + raise_with_traceback(DeserializationError, msg, err) + else: + return date_obj diff --git a/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/changes/aio/_changes_client.py b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/changes/aio/_changes_client.py index 379b385160b0a..73d7583683e4e 100644 --- a/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/changes/aio/_changes_client.py +++ b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/changes/aio/_changes_client.py @@ -11,17 +11,15 @@ from typing import Any, Optional, TYPE_CHECKING -from msrest import Deserializer, Serializer - from azure.mgmt.core import AsyncARMPipelineClient from azure.profiles import KnownProfiles, ProfileDefinition from azure.profiles.multiapiclient import MultiApiClientMixin +from .._serialization import Deserializer, Serializer from ._configuration import ChangesClientConfiguration if TYPE_CHECKING: # pylint: disable=unused-import,ungrouped-imports - from azure.core.credentials import TokenCredential from azure.core.credentials_async import AsyncTokenCredential class _SDKClient(object): @@ -42,9 +40,9 @@ class ChangesClient(MultiApiClientMixin, _SDKClient): The api-version parameter sets the default API version if the operation group is not described in the profile. - :param credential: Credential needed for the client to connect to Azure. + :param credential: Credential needed for the client to connect to Azure. Required. :type credential: ~azure.core.credentials_async.AsyncTokenCredential - :param subscription_id: The Azure subscription ID. This is a GUID-formatted string (e.g. 00000000-0000-0000-0000-000000000000). + :param subscription_id: The Azure subscription ID. This is a GUID-formatted string (e.g. 00000000-0000-0000-0000-000000000000). Required. :type subscription_id: str :param api_version: API version to use if no profile is provided, or if missing in profile. :type api_version: str diff --git a/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/changes/aio/_configuration.py b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/changes/aio/_configuration.py index a97983b63a8e3..4c81a91e15953 100644 --- a/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/changes/aio/_configuration.py +++ b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/changes/aio/_configuration.py @@ -26,9 +26,9 @@ class ChangesClientConfiguration(Configuration): Note that all parameters used to create this instance are saved as instance attributes. - :param credential: Credential needed for the client to connect to Azure. + :param credential: Credential needed for the client to connect to Azure. Required. :type credential: ~azure.core.credentials_async.AsyncTokenCredential - :param subscription_id: The Azure subscription ID. This is a GUID-formatted string (e.g. 00000000-0000-0000-0000-000000000000). + :param subscription_id: The Azure subscription ID. This is a GUID-formatted string (e.g. 00000000-0000-0000-0000-000000000000). Required. :type subscription_id: str """ diff --git a/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/changes/v2022_05_01/__init__.py b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/changes/v2022_05_01/__init__.py index d87b0e5726427..59ecbe34fde97 100644 --- a/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/changes/v2022_05_01/__init__.py +++ b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/changes/v2022_05_01/__init__.py @@ -10,9 +10,15 @@ from ._version import VERSION __version__ = VERSION -__all__ = ['ChangesClient'] -# `._patch.py` is used for handwritten extensions to the generated code -# Example: https://github.com/Azure/azure-sdk-for-python/blob/main/doc/dev/customize_code/how-to-patch-sdk-code.md -from ._patch import patch_sdk -patch_sdk() +try: + from ._patch import __all__ as _patch_all + from ._patch import * # type: ignore # pylint: disable=unused-wildcard-import +except ImportError: + _patch_all = [] +from ._patch import patch_sdk as _patch_sdk + +__all__ = ["ChangesClient"] +__all__.extend([p for p in _patch_all if p not in __all__]) + +_patch_sdk() diff --git a/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/changes/v2022_05_01/_changes_client.py b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/changes/v2022_05_01/_changes_client.py index 068ccced1ae0b..a61550e41dd43 100644 --- a/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/changes/v2022_05_01/_changes_client.py +++ b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/changes/v2022_05_01/_changes_client.py @@ -9,12 +9,11 @@ from copy import deepcopy from typing import Any, TYPE_CHECKING -from msrest import Deserializer, Serializer - from azure.core.rest import HttpRequest, HttpResponse from azure.mgmt.core import ARMPipelineClient from . import models +from .._serialization import Deserializer, Serializer from ._configuration import ChangesClientConfiguration from .operations import ChangesOperations @@ -22,15 +21,16 @@ # pylint: disable=unused-import,ungrouped-imports from azure.core.credentials import TokenCredential -class ChangesClient: + +class ChangesClient: # pylint: disable=client-accepts-api-version-keyword """The Resource Changes Client. :ivar changes: ChangesOperations operations :vartype changes: azure.mgmt.resource.changes.v2022_05_01.operations.ChangesOperations - :param credential: Credential needed for the client to connect to Azure. + :param credential: Credential needed for the client to connect to Azure. Required. :type credential: ~azure.core.credentials.TokenCredential :param subscription_id: The Azure subscription ID. This is a GUID-formatted string (e.g. - 00000000-0000-0000-0000-000000000000). + 00000000-0000-0000-0000-000000000000). Required. :type subscription_id: str :param base_url: Service URL. Default value is "https://management.azure.com". :type base_url: str @@ -55,12 +55,7 @@ def __init__( self._serialize.client_side_validation = False self.changes = ChangesOperations(self._client, self._config, self._serialize, self._deserialize) - - def _send_request( - self, - request: HttpRequest, - **kwargs: Any - ) -> HttpResponse: + def _send_request(self, request: HttpRequest, **kwargs: Any) -> HttpResponse: """Runs the network request through the client's chained policies. >>> from azure.core.rest import HttpRequest @@ -69,7 +64,7 @@ def _send_request( >>> response = client._send_request(request) - For more information on this code flow, see https://aka.ms/azsdk/python/protocol/quickstart + For more information on this code flow, see https://aka.ms/azsdk/dpcodegen/python/send_request :param request: The network request you want to make. Required. :type request: ~azure.core.rest.HttpRequest diff --git a/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/changes/v2022_05_01/_configuration.py b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/changes/v2022_05_01/_configuration.py index 15c61999b8f7e..a56f4c33705c3 100644 --- a/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/changes/v2022_05_01/_configuration.py +++ b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/changes/v2022_05_01/_configuration.py @@ -25,24 +25,19 @@ class ChangesClientConfiguration(Configuration): # pylint: disable=too-many-ins Note that all parameters used to create this instance are saved as instance attributes. - :param credential: Credential needed for the client to connect to Azure. + :param credential: Credential needed for the client to connect to Azure. Required. :type credential: ~azure.core.credentials.TokenCredential :param subscription_id: The Azure subscription ID. This is a GUID-formatted string (e.g. - 00000000-0000-0000-0000-000000000000). + 00000000-0000-0000-0000-000000000000). Required. :type subscription_id: str :keyword api_version: Api Version. Default value is "2022-05-01". Note that overriding this default value may result in unsupported behavior. :paramtype api_version: str """ - def __init__( - self, - credential: "TokenCredential", - subscription_id: str, - **kwargs: Any - ) -> None: + def __init__(self, credential: "TokenCredential", subscription_id: str, **kwargs: Any) -> None: super(ChangesClientConfiguration, self).__init__(**kwargs) - api_version = kwargs.pop('api_version', "2022-05-01") # type: str + api_version = kwargs.pop("api_version", "2022-05-01") # type: str if credential is None: raise ValueError("Parameter 'credential' must not be None.") @@ -52,23 +47,24 @@ def __init__( self.credential = credential self.subscription_id = subscription_id self.api_version = api_version - self.credential_scopes = kwargs.pop('credential_scopes', ['https://management.azure.com/.default']) - kwargs.setdefault('sdk_moniker', 'mgmt-resource/{}'.format(VERSION)) + self.credential_scopes = kwargs.pop("credential_scopes", ["https://management.azure.com/.default"]) + kwargs.setdefault("sdk_moniker", "mgmt-resource/{}".format(VERSION)) self._configure(**kwargs) def _configure( - self, - **kwargs # type: Any + self, **kwargs # type: Any ): # type: (...) -> 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) - self.logging_policy = kwargs.get('logging_policy') or policies.NetworkTraceLoggingPolicy(**kwargs) - self.http_logging_policy = kwargs.get('http_logging_policy') or ARMHttpLoggingPolicy(**kwargs) - self.retry_policy = kwargs.get('retry_policy') or policies.RetryPolicy(**kwargs) - self.custom_hook_policy = kwargs.get('custom_hook_policy') or policies.CustomHookPolicy(**kwargs) - self.redirect_policy = kwargs.get('redirect_policy') or policies.RedirectPolicy(**kwargs) - self.authentication_policy = kwargs.get('authentication_policy') + 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) + self.logging_policy = kwargs.get("logging_policy") or policies.NetworkTraceLoggingPolicy(**kwargs) + self.http_logging_policy = kwargs.get("http_logging_policy") or ARMHttpLoggingPolicy(**kwargs) + self.retry_policy = kwargs.get("retry_policy") or policies.RetryPolicy(**kwargs) + self.custom_hook_policy = kwargs.get("custom_hook_policy") or policies.CustomHookPolicy(**kwargs) + self.redirect_policy = kwargs.get("redirect_policy") or policies.RedirectPolicy(**kwargs) + self.authentication_policy = kwargs.get("authentication_policy") if self.credential and not self.authentication_policy: - self.authentication_policy = ARMChallengeAuthenticationPolicy(self.credential, *self.credential_scopes, **kwargs) + self.authentication_policy = ARMChallengeAuthenticationPolicy( + self.credential, *self.credential_scopes, **kwargs + ) diff --git a/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/changes/v2022_05_01/_metadata.json b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/changes/v2022_05_01/_metadata.json index d4486655f8207..e1a1ce4c9d21e 100644 --- a/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/changes/v2022_05_01/_metadata.json +++ b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/changes/v2022_05_01/_metadata.json @@ -10,20 +10,20 @@ "azure_arm": true, "has_lro_operations": false, "client_side_validation": false, - "sync_imports": "{\"typing\": {\"azurecore\": {\"azure.core.credentials\": [\"TokenCredential\"]}}, \"regular\": {\"azurecore\": {\"azure.profiles\": [\"KnownProfiles\", \"ProfileDefinition\"], \"azure.profiles.multiapiclient\": [\"MultiApiClientMixin\"], \"azure.mgmt.core\": [\"ARMPipelineClient\"]}, \"local\": {\"._configuration\": [\"ChangesClientConfiguration\"]}, \"thirdparty\": {\"msrest\": [\"Deserializer\", \"Serializer\"]}}, \"conditional\": {\"stdlib\": {\"typing\": [\"Any\", \"Optional\"]}}}", - "async_imports": "{\"typing\": {\"azurecore\": {\"azure.core.credentials_async\": [\"AsyncTokenCredential\"], \"azure.core.credentials\": [\"TokenCredential\"]}}, \"regular\": {\"azurecore\": {\"azure.profiles\": [\"KnownProfiles\", \"ProfileDefinition\"], \"azure.profiles.multiapiclient\": [\"MultiApiClientMixin\"], \"azure.mgmt.core\": [\"AsyncARMPipelineClient\"]}, \"local\": {\"._configuration\": [\"ChangesClientConfiguration\"]}, \"thirdparty\": {\"msrest\": [\"Deserializer\", \"Serializer\"]}}, \"conditional\": {\"stdlib\": {\"typing\": [\"Any\", \"Optional\"]}}}" + "sync_imports": "{\"conditional\": {\"stdlib\": {\"typing\": [\"Any\", \"Optional\"]}}, \"regular\": {\"azurecore\": {\"azure.mgmt.core\": [\"ARMPipelineClient\"], \"azure.profiles\": [\"KnownProfiles\", \"ProfileDefinition\"], \"azure.profiles.multiapiclient\": [\"MultiApiClientMixin\"]}, \"local\": {\"._configuration\": [\"ChangesClientConfiguration\"], \".._serialization\": [\"Deserializer\", \"Serializer\"]}}, \"typing\": {\"azurecore\": {\"azure.core.credentials\": [\"TokenCredential\"]}}}", + "async_imports": "{\"conditional\": {\"stdlib\": {\"typing\": [\"Any\", \"Optional\"]}}, \"regular\": {\"azurecore\": {\"azure.mgmt.core\": [\"AsyncARMPipelineClient\"], \"azure.profiles\": [\"KnownProfiles\", \"ProfileDefinition\"], \"azure.profiles.multiapiclient\": [\"MultiApiClientMixin\"]}, \"local\": {\"._configuration\": [\"ChangesClientConfiguration\"], \"..._serialization\": [\"Deserializer\", \"Serializer\"]}}, \"typing\": {\"azurecore\": {\"azure.core.credentials_async\": [\"AsyncTokenCredential\"]}}}" }, "global_parameters": { "sync": { "credential": { - "signature": "credential, # type: \"TokenCredential\"", - "description": "Credential needed for the client to connect to Azure.", + "signature": "credential: \"TokenCredential\",", + "description": "Credential needed for the client to connect to Azure. Required.", "docstring_type": "~azure.core.credentials.TokenCredential", "required": true }, "subscription_id": { - "signature": "subscription_id, # type: str", - "description": "The Azure subscription ID. This is a GUID-formatted string (e.g. 00000000-0000-0000-0000-000000000000).", + "signature": "subscription_id: str,", + "description": "The Azure subscription ID. This is a GUID-formatted string (e.g. 00000000-0000-0000-0000-000000000000). Required.", "docstring_type": "str", "required": true } @@ -31,13 +31,13 @@ "async": { "credential": { "signature": "credential: \"AsyncTokenCredential\",", - "description": "Credential needed for the client to connect to Azure.", + "description": "Credential needed for the client to connect to Azure. Required.", "docstring_type": "~azure.core.credentials_async.AsyncTokenCredential", "required": true }, "subscription_id": { "signature": "subscription_id: str,", - "description": "The Azure subscription ID. This is a GUID-formatted string (e.g. 00000000-0000-0000-0000-000000000000).", + "description": "The Azure subscription ID. This is a GUID-formatted string (e.g. 00000000-0000-0000-0000-000000000000). Required.", "docstring_type": "str", "required": true } @@ -54,7 +54,7 @@ "required": false }, "base_url": { - "signature": "base_url=\"https://management.azure.com\", # type: str", + "signature": "base_url: str = \"https://management.azure.com\",", "description": "Service URL", "docstring_type": "str", "required": false diff --git a/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/changes/v2022_05_01/_patch.py b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/changes/v2022_05_01/_patch.py index 74e48ecd07cf3..f99e77fef9861 100644 --- a/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/changes/v2022_05_01/_patch.py +++ b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/changes/v2022_05_01/_patch.py @@ -28,4 +28,4 @@ # This file is used for handwritten extensions to the generated code. Example: # https://github.com/Azure/azure-sdk-for-python/blob/main/doc/dev/customize_code/how-to-patch-sdk-code.md def patch_sdk(): - pass \ No newline at end of file + pass diff --git a/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/changes/v2022_05_01/_vendor.py b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/changes/v2022_05_01/_vendor.py index 138f663c53a4e..9aad73fc743e7 100644 --- a/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/changes/v2022_05_01/_vendor.py +++ b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/changes/v2022_05_01/_vendor.py @@ -7,6 +7,7 @@ from azure.core.pipeline.transport import HttpRequest + def _convert_request(request, files=None): data = request.content if not files else None request = HttpRequest(method=request.method, url=request.url, headers=request.headers, data=data) @@ -14,6 +15,7 @@ def _convert_request(request, files=None): request.set_formdata_body(files) return request + def _format_url_section(template, **kwargs): components = template.split("/") while components: @@ -21,7 +23,5 @@ def _format_url_section(template, **kwargs): 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 - ] + components = [c for c in formatted_components if "{}".format(key.args[0]) not in c] template = "/".join(components) diff --git a/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/changes/v2022_05_01/_version.py b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/changes/v2022_05_01/_version.py index a012ac01c480c..e5754a47ce68f 100644 --- a/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/changes/v2022_05_01/_version.py +++ b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/changes/v2022_05_01/_version.py @@ -6,4 +6,4 @@ # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -VERSION = "21.1.0" +VERSION = "1.0.0b1" diff --git a/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/changes/v2022_05_01/aio/__init__.py b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/changes/v2022_05_01/aio/__init__.py index ec4b693a71efd..b0a96f96f4afb 100644 --- a/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/changes/v2022_05_01/aio/__init__.py +++ b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/changes/v2022_05_01/aio/__init__.py @@ -7,9 +7,15 @@ # -------------------------------------------------------------------------- from ._changes_client import ChangesClient -__all__ = ['ChangesClient'] -# `._patch.py` is used for handwritten extensions to the generated code -# Example: https://github.com/Azure/azure-sdk-for-python/blob/main/doc/dev/customize_code/how-to-patch-sdk-code.md -from ._patch import patch_sdk -patch_sdk() +try: + from ._patch import __all__ as _patch_all + from ._patch import * # type: ignore # pylint: disable=unused-wildcard-import +except ImportError: + _patch_all = [] +from ._patch import patch_sdk as _patch_sdk + +__all__ = ["ChangesClient"] +__all__.extend([p for p in _patch_all if p not in __all__]) + +_patch_sdk() diff --git a/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/changes/v2022_05_01/aio/_changes_client.py b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/changes/v2022_05_01/aio/_changes_client.py index f0045c7f3b672..940af694ab65f 100644 --- a/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/changes/v2022_05_01/aio/_changes_client.py +++ b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/changes/v2022_05_01/aio/_changes_client.py @@ -9,12 +9,11 @@ from copy import deepcopy from typing import Any, Awaitable, TYPE_CHECKING -from msrest import Deserializer, Serializer - from azure.core.rest import AsyncHttpResponse, HttpRequest from azure.mgmt.core import AsyncARMPipelineClient from .. import models +from ..._serialization import Deserializer, Serializer from ._configuration import ChangesClientConfiguration from .operations import ChangesOperations @@ -22,15 +21,16 @@ # pylint: disable=unused-import,ungrouped-imports from azure.core.credentials_async import AsyncTokenCredential -class ChangesClient: + +class ChangesClient: # pylint: disable=client-accepts-api-version-keyword """The Resource Changes Client. :ivar changes: ChangesOperations operations :vartype changes: azure.mgmt.resource.changes.v2022_05_01.aio.operations.ChangesOperations - :param credential: Credential needed for the client to connect to Azure. + :param credential: Credential needed for the client to connect to Azure. Required. :type credential: ~azure.core.credentials_async.AsyncTokenCredential :param subscription_id: The Azure subscription ID. This is a GUID-formatted string (e.g. - 00000000-0000-0000-0000-000000000000). + 00000000-0000-0000-0000-000000000000). Required. :type subscription_id: str :param base_url: Service URL. Default value is "https://management.azure.com". :type base_url: str @@ -55,12 +55,7 @@ def __init__( self._serialize.client_side_validation = False self.changes = ChangesOperations(self._client, self._config, self._serialize, self._deserialize) - - def _send_request( - self, - request: HttpRequest, - **kwargs: Any - ) -> Awaitable[AsyncHttpResponse]: + def _send_request(self, request: HttpRequest, **kwargs: Any) -> Awaitable[AsyncHttpResponse]: """Runs the network request through the client's chained policies. >>> from azure.core.rest import HttpRequest @@ -69,7 +64,7 @@ def _send_request( >>> response = await client._send_request(request) - For more information on this code flow, see https://aka.ms/azsdk/python/protocol/quickstart + For more information on this code flow, see https://aka.ms/azsdk/dpcodegen/python/send_request :param request: The network request you want to make. Required. :type request: ~azure.core.rest.HttpRequest diff --git a/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/changes/v2022_05_01/aio/_configuration.py b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/changes/v2022_05_01/aio/_configuration.py index 0926eea41a364..6739ccb3bc5cf 100644 --- a/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/changes/v2022_05_01/aio/_configuration.py +++ b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/changes/v2022_05_01/aio/_configuration.py @@ -25,24 +25,19 @@ class ChangesClientConfiguration(Configuration): # pylint: disable=too-many-ins Note that all parameters used to create this instance are saved as instance attributes. - :param credential: Credential needed for the client to connect to Azure. + :param credential: Credential needed for the client to connect to Azure. Required. :type credential: ~azure.core.credentials_async.AsyncTokenCredential :param subscription_id: The Azure subscription ID. This is a GUID-formatted string (e.g. - 00000000-0000-0000-0000-000000000000). + 00000000-0000-0000-0000-000000000000). Required. :type subscription_id: str :keyword api_version: Api Version. Default value is "2022-05-01". Note that overriding this default value may result in unsupported behavior. :paramtype api_version: str """ - def __init__( - self, - credential: "AsyncTokenCredential", - subscription_id: str, - **kwargs: Any - ) -> None: + def __init__(self, credential: "AsyncTokenCredential", subscription_id: str, **kwargs: Any) -> None: super(ChangesClientConfiguration, self).__init__(**kwargs) - api_version = kwargs.pop('api_version', "2022-05-01") # type: str + api_version = kwargs.pop("api_version", "2022-05-01") # type: str if credential is None: raise ValueError("Parameter 'credential' must not be None.") @@ -52,22 +47,21 @@ def __init__( self.credential = credential self.subscription_id = subscription_id self.api_version = api_version - self.credential_scopes = kwargs.pop('credential_scopes', ['https://management.azure.com/.default']) - kwargs.setdefault('sdk_moniker', 'mgmt-resource/{}'.format(VERSION)) + self.credential_scopes = kwargs.pop("credential_scopes", ["https://management.azure.com/.default"]) + kwargs.setdefault("sdk_moniker", "mgmt-resource/{}".format(VERSION)) self._configure(**kwargs) - 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) - self.logging_policy = kwargs.get('logging_policy') or policies.NetworkTraceLoggingPolicy(**kwargs) - self.http_logging_policy = kwargs.get('http_logging_policy') or ARMHttpLoggingPolicy(**kwargs) - self.retry_policy = kwargs.get('retry_policy') or policies.AsyncRetryPolicy(**kwargs) - self.custom_hook_policy = kwargs.get('custom_hook_policy') or policies.CustomHookPolicy(**kwargs) - self.redirect_policy = kwargs.get('redirect_policy') or policies.AsyncRedirectPolicy(**kwargs) - self.authentication_policy = kwargs.get('authentication_policy') + 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) + self.logging_policy = kwargs.get("logging_policy") or policies.NetworkTraceLoggingPolicy(**kwargs) + self.http_logging_policy = kwargs.get("http_logging_policy") or ARMHttpLoggingPolicy(**kwargs) + self.retry_policy = kwargs.get("retry_policy") or policies.AsyncRetryPolicy(**kwargs) + self.custom_hook_policy = kwargs.get("custom_hook_policy") or policies.CustomHookPolicy(**kwargs) + self.redirect_policy = kwargs.get("redirect_policy") or policies.AsyncRedirectPolicy(**kwargs) + self.authentication_policy = kwargs.get("authentication_policy") if self.credential and not self.authentication_policy: - self.authentication_policy = AsyncARMChallengeAuthenticationPolicy(self.credential, *self.credential_scopes, **kwargs) + self.authentication_policy = AsyncARMChallengeAuthenticationPolicy( + self.credential, *self.credential_scopes, **kwargs + ) diff --git a/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/changes/v2022_05_01/aio/_patch.py b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/changes/v2022_05_01/aio/_patch.py index 74e48ecd07cf3..f99e77fef9861 100644 --- a/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/changes/v2022_05_01/aio/_patch.py +++ b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/changes/v2022_05_01/aio/_patch.py @@ -28,4 +28,4 @@ # This file is used for handwritten extensions to the generated code. Example: # https://github.com/Azure/azure-sdk-for-python/blob/main/doc/dev/customize_code/how-to-patch-sdk-code.md def patch_sdk(): - pass \ No newline at end of file + pass diff --git a/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/changes/v2022_05_01/aio/operations/__init__.py b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/changes/v2022_05_01/aio/operations/__init__.py index f3c0a138bab4a..80c317f699652 100644 --- a/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/changes/v2022_05_01/aio/operations/__init__.py +++ b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/changes/v2022_05_01/aio/operations/__init__.py @@ -8,6 +8,12 @@ from ._operations import ChangesOperations +from ._patch import __all__ as _patch_all +from ._patch import * # type: ignore # pylint: disable=unused-wildcard-import +from ._patch import patch_sdk as _patch_sdk + __all__ = [ - 'ChangesOperations', + "ChangesOperations", ] +__all__.extend([p for p in _patch_all if p not in __all__]) +_patch_sdk() diff --git a/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/changes/v2022_05_01/aio/operations/_operations.py b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/changes/v2022_05_01/aio/operations/_operations.py index fbabbb806c459..622d605331a21 100644 --- a/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/changes/v2022_05_01/aio/operations/_operations.py +++ b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/changes/v2022_05_01/aio/operations/_operations.py @@ -7,43 +7,51 @@ # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- from typing import Any, AsyncIterable, Callable, Dict, Optional, TypeVar +from urllib.parse import parse_qs, urljoin, urlparse from azure.core.async_paging import AsyncItemPaged, AsyncList -from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error +from azure.core.exceptions import ( + ClientAuthenticationError, + HttpResponseError, + ResourceExistsError, + ResourceNotFoundError, + ResourceNotModifiedError, + map_error, +) from azure.core.pipeline import PipelineResponse from azure.core.pipeline.transport import AsyncHttpResponse from azure.core.rest import HttpRequest from azure.core.tracing.decorator import distributed_trace from azure.core.tracing.decorator_async import distributed_trace_async +from azure.core.utils import case_insensitive_dict from azure.mgmt.core.exceptions import ARMErrorFormat from ... import models as _models from ..._vendor import _convert_request from ...operations._operations import build_changes_get_request, build_changes_list_request -T = TypeVar('T') + +T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] -class ChangesOperations: - """ChangesOperations async operations. - You should not instantiate this class directly. Instead, you should create a Client instance that - instantiates it for you and attaches it as an attribute. +class ChangesOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. - :ivar models: Alias to model classes used in this operation group. - :type models: ~azure.mgmt.resource.changes.v2022_05_01.models - :param client: Client for service requests. - :param config: Configuration of service client. - :param serializer: An object model serializer. - :param deserializer: An object model deserializer. + Instead, you should access the following operations through + :class:`~azure.mgmt.resource.changes.v2022_05_01.aio.ChangesClient`'s + :attr:`changes` attribute. """ models = _models - def __init__(self, client, config, serializer, deserializer) -> None: - self._client = client - self._serialize = serializer - self._deserialize = deserializer - self._config = config + def __init__(self, *args, **kwargs) -> None: + input_args = list(args) + self._client = input_args.pop(0) if input_args else kwargs.pop("client") + self._config = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") @distributed_trace def list( @@ -52,67 +60,72 @@ def list( resource_provider_namespace: str, resource_type: str, resource_name: str, - top: Optional[int] = 100, + top: int = 100, skip_token: Optional[str] = None, **kwargs: Any - ) -> AsyncIterable["_models.ChangeResourceListResult"]: + ) -> AsyncIterable["_models.ChangeResourceResult"]: """Obtains a list of change resources from the past 14 days for the target resource. - :param resource_group_name: The name of the resource group. + :param resource_group_name: The name of the resource group. Required. :type resource_group_name: str - :param resource_provider_namespace: The name of the resource provider namespace. + :param resource_provider_namespace: The name of the resource provider namespace. Required. :type resource_provider_namespace: str - :param resource_type: The name of the resource type. + :param resource_type: The name of the resource type. Required. :type resource_type: str - :param resource_name: The name of the resource. + :param resource_name: The name of the resource. Required. :type resource_name: str :param top: (Optional) Set the maximum number of results per response. Default value is 100. - :type top: long + :type top: int :param skip_token: (Optional) The page-continuation token. Default value is None. :type skip_token: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either ChangeResourceListResult or the result of + :return: An iterator like instance of either ChangeResourceResult or the result of cls(response) :rtype: - ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.resource.changes.v2022_05_01.models.ChangeResourceListResult] - :raises: ~azure.core.exceptions.HttpResponseError + ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.resource.changes.v2022_05_01.models.ChangeResourceResult] + :raises ~azure.core.exceptions.HttpResponseError: """ - api_version = kwargs.pop('api_version', "2022-05-01") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2022-05-01")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[_models.ChangeResourceListResult] - cls = kwargs.pop('cls', None) # type: ClsType["_models.ChangeResourceListResult"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) + def prepare_request(next_link=None): if not next_link: - + request = build_changes_list_request( - subscription_id=self._config.subscription_id, resource_group_name=resource_group_name, resource_provider_namespace=resource_provider_namespace, resource_type=resource_type, resource_name=resource_name, - api_version=api_version, + subscription_id=self._config.subscription_id, top=top, skip_token=skip_token, - template_url=self.list.metadata['url'], + 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.url = self._client.format_url(request.url) # type: ignore else: - - request = build_changes_list_request( - subscription_id=self._config.subscription_id, - resource_group_name=resource_group_name, - resource_provider_namespace=resource_provider_namespace, - resource_type=resource_type, - resource_name=resource_name, - template_url=next_link, - ) + # make call to next link with the client's api-version + _parsed_next_link = urlparse(next_link) + _next_request_params = case_insensitive_dict(parse_qs(_parsed_next_link.query)) + _next_request_params["api-version"] = self._config.api_version + request = HttpRequest("GET", urljoin(next_link, _parsed_next_link.path), params=_next_request_params) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore request.method = "GET" return request @@ -126,10 +139,8 @@ async def extract_data(pipeline_response): async def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) response = pipeline_response.http_response @@ -140,11 +151,9 @@ async def get_next(next_link=None): return pipeline_response + return AsyncItemPaged(get_next, extract_data) - return AsyncItemPaged( - get_next, extract_data - ) - list.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{resourceType}/{resourceName}/providers/Microsoft.Resources/changes"} # type: ignore + list.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{resourceType}/{resourceName}/providers/Microsoft.Resources/changes"} # type: ignore @distributed_trace_async async def get( @@ -155,51 +164,57 @@ async def get( resource_name: str, change_resource_id: str, **kwargs: Any - ) -> "_models.ChangeResourceResult": + ) -> _models.ChangeResourceResult: """Obtains the specified change resource for the target resource. - :param resource_group_name: The name of the resource group. + :param resource_group_name: The name of the resource group. Required. :type resource_group_name: str - :param resource_provider_namespace: The name of the resource provider namespace. + :param resource_provider_namespace: The name of the resource provider namespace. Required. :type resource_provider_namespace: str - :param resource_type: The name of the resource type. + :param resource_type: The name of the resource type. Required. :type resource_type: str - :param resource_name: The name of the resource. + :param resource_name: The name of the resource. Required. :type resource_name: str - :param change_resource_id: The ID of the change resource. + :param change_resource_id: The ID of the change resource. Required. :type change_resource_id: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: ChangeResourceResult, or the result of cls(response) + :return: ChangeResourceResult or the result of cls(response) :rtype: ~azure.mgmt.resource.changes.v2022_05_01.models.ChangeResourceResult - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.ChangeResourceResult"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + 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', "2022-05-01") # type: str + api_version = kwargs.pop("api_version", _params.pop("api-version", "2022-05-01")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[_models.ChangeResourceResult] - request = build_changes_get_request( - subscription_id=self._config.subscription_id, resource_group_name=resource_group_name, resource_provider_namespace=resource_provider_namespace, resource_type=resource_type, resource_name=resource_name, change_resource_id=change_resource_id, + subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.get.metadata['url'], + template_url=self.get.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200]: @@ -207,12 +222,11 @@ async def get( error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - deserialized = self._deserialize('ChangeResourceResult', pipeline_response) + deserialized = self._deserialize("ChangeResourceResult", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - get.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{resourceType}/{resourceName}/providers/Microsoft.Resources/changes/{changeResourceId}"} # type: ignore - + get.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{resourceType}/{resourceName}/providers/Microsoft.Resources/changes/{changeResourceId}"} # type: ignore diff --git a/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/changes/v2022_05_01/aio/operations/_patch.py b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/changes/v2022_05_01/aio/operations/_patch.py new file mode 100644 index 0000000000000..f7dd32510333d --- /dev/null +++ b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/changes/v2022_05_01/aio/operations/_patch.py @@ -0,0 +1,20 @@ +# ------------------------------------ +# Copyright (c) Microsoft Corporation. +# Licensed under the MIT License. +# ------------------------------------ +"""Customize generated code here. + +Follow our quickstart for examples: https://aka.ms/azsdk/python/dpcodegen/python/customize +""" +from typing import List + +__all__: List[str] = [] # Add all objects you want publicly available to users at this package level + + +def patch_sdk(): + """Do not remove from this file. + + `patch_sdk` is a last resort escape hatch that allows you to do customizations + you can't accomplish using the techniques described in + https://aka.ms/azsdk/python/dpcodegen/python/customize + """ diff --git a/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/changes/v2022_05_01/models/__init__.py b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/changes/v2022_05_01/models/__init__.py index 5de10a0e9fe0d..034e882ff2039 100644 --- a/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/changes/v2022_05_01/models/__init__.py +++ b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/changes/v2022_05_01/models/__init__.py @@ -16,24 +16,26 @@ from ._models_py3 import ErrorResponse from ._models_py3 import Resource - -from ._changes_client_enums import ( - ChangeCategory, - ChangeType, - PropertyChangeType, -) +from ._changes_client_enums import ChangeCategory +from ._changes_client_enums import ChangeType +from ._changes_client_enums import PropertyChangeType +from ._patch import __all__ as _patch_all +from ._patch import * # type: ignore # pylint: disable=unused-wildcard-import +from ._patch import patch_sdk as _patch_sdk __all__ = [ - 'ChangeAttributes', - 'ChangeBase', - 'ChangeProperties', - 'ChangeResourceListResult', - 'ChangeResourceResult', - 'ErrorAdditionalInfo', - 'ErrorDetail', - 'ErrorResponse', - 'Resource', - 'ChangeCategory', - 'ChangeType', - 'PropertyChangeType', + "ChangeAttributes", + "ChangeBase", + "ChangeProperties", + "ChangeResourceListResult", + "ChangeResourceResult", + "ErrorAdditionalInfo", + "ErrorDetail", + "ErrorResponse", + "Resource", + "ChangeCategory", + "ChangeType", + "PropertyChangeType", ] +__all__.extend([p for p in _patch_all if p not in __all__]) +_patch_sdk() diff --git a/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/changes/v2022_05_01/models/_changes_client_enums.py b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/changes/v2022_05_01/models/_changes_client_enums.py index 3ddb85e1f0d49..1a70f25342eae 100644 --- a/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/changes/v2022_05_01/models/_changes_client_enums.py +++ b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/changes/v2022_05_01/models/_changes_client_enums.py @@ -7,37 +7,35 @@ # -------------------------------------------------------------------------- from enum import Enum -from six import with_metaclass from azure.core import CaseInsensitiveEnumMeta -class ChangeCategory(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): - """The entity that made the change - """ +class ChangeCategory(str, Enum, metaclass=CaseInsensitiveEnumMeta): + """The entity that made the change.""" - #: User initiated change. + #: User initiated change USER = "User" - #: System initiated change. + #: System initiated change SYSTEM = "System" -class ChangeType(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): - """The type of change that was captured in the resource - """ - #: An existing resource underwent a change. +class ChangeType(str, Enum, metaclass=CaseInsensitiveEnumMeta): + """The type of change that was captured in the resource.""" + + #: An existing resource underwent a change UPDATE = "Update" - #: An existing resource was deleted. + #: An existing resource was deleted DELETE = "Delete" - #: A newly created resource. + #: A newly created resource CREATE = "Create" -class PropertyChangeType(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): - """The type of change that occurred - """ - #: An existing property underwent a change. +class PropertyChangeType(str, Enum, metaclass=CaseInsensitiveEnumMeta): + """The type of change that occurred.""" + + #: An existing property underwent a change UPDATE = "Update" - #: A property was newly created. + #: A property was newly created INSERT = "Insert" - #: An existing property was deleted. + #: An existing property was deleted REMOVE = "Remove" diff --git a/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/changes/v2022_05_01/models/_models_py3.py b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/changes/v2022_05_01/models/_models_py3.py index 16854c044ef5b..bff73be0ef85b 100644 --- a/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/changes/v2022_05_01/models/_models_py3.py +++ b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/changes/v2022_05_01/models/_models_py3.py @@ -1,4 +1,5 @@ # coding=utf-8 +# pylint: disable=too-many-lines # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. # Licensed under the MIT License. See License.txt in the project root for license information. @@ -6,13 +7,16 @@ # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -from typing import Dict, List, Optional +from typing import Dict, List, Optional, TYPE_CHECKING -from azure.core.exceptions import HttpResponseError -import msrest.serialization +from ... import _serialization +if TYPE_CHECKING: + # pylint: disable=unused-import,ungrouped-imports + from .. import models as _models -class ChangeAttributes(msrest.serialization.Model): + +class ChangeAttributes(_serialization.Model): """Details about the change resource. Variables are only populated by the server, and will be ignored when sending a request. @@ -22,7 +26,7 @@ class ChangeAttributes(msrest.serialization.Model): :ivar timestamp: The time the change(s) on the target resource ocurred. :vartype timestamp: str :ivar changes_count: The number of changes this resource captures. - :vartype changes_count: long + :vartype changes_count: int :ivar previous_resource_snapshot_id: The GUID of the previous snapshot. :vartype previous_resource_snapshot_id: str :ivar new_resource_snapshot_id: The GUID of the new snapshot. @@ -30,28 +34,24 @@ class ChangeAttributes(msrest.serialization.Model): """ _validation = { - 'correlation_id': {'readonly': True}, - 'timestamp': {'readonly': True}, - 'changes_count': {'readonly': True}, - 'previous_resource_snapshot_id': {'readonly': True}, - 'new_resource_snapshot_id': {'readonly': True}, + "correlation_id": {"readonly": True}, + "timestamp": {"readonly": True}, + "changes_count": {"readonly": True}, + "previous_resource_snapshot_id": {"readonly": True}, + "new_resource_snapshot_id": {"readonly": True}, } _attribute_map = { - 'correlation_id': {'key': 'correlationId', 'type': 'str'}, - 'timestamp': {'key': 'timestamp', 'type': 'str'}, - 'changes_count': {'key': 'changesCount', 'type': 'long'}, - 'previous_resource_snapshot_id': {'key': 'previousResourceSnapshotId', 'type': 'str'}, - 'new_resource_snapshot_id': {'key': 'newResourceSnapshotId', 'type': 'str'}, + "correlation_id": {"key": "correlationId", "type": "str"}, + "timestamp": {"key": "timestamp", "type": "str"}, + "changes_count": {"key": "changesCount", "type": "int"}, + "previous_resource_snapshot_id": {"key": "previousResourceSnapshotId", "type": "str"}, + "new_resource_snapshot_id": {"key": "newResourceSnapshotId", "type": "str"}, } - def __init__( - self, - **kwargs - ): - """ - """ - super(ChangeAttributes, self).__init__(**kwargs) + def __init__(self, **kwargs): + """ """ + super().__init__(**kwargs) self.correlation_id = None self.timestamp = None self.changes_count = None @@ -59,17 +59,16 @@ def __init__( self.new_resource_snapshot_id = None -class ChangeBase(msrest.serialization.Model): +class ChangeBase(_serialization.Model): """An individual change on the target resource. Variables are only populated by the server, and will be ignored when sending a request. - :ivar property_change_type: The type of change that occurred. Possible values include: - "Update", "Insert", "Remove". + :ivar property_change_type: The type of change that occurred. Known values are: "Update", + "Insert", and "Remove". :vartype property_change_type: str or ~azure.mgmt.resource.changes.v2022_05_01.models.PropertyChangeType - :ivar change_category: The entity that made the change. Possible values include: "User", - "System". + :ivar change_category: The entity that made the change. Known values are: "User" and "System". :vartype change_category: str or ~azure.mgmt.resource.changes.v2022_05_01.models.ChangeCategory :ivar previous_value: The target resource property value before the change. :vartype previous_value: str @@ -78,33 +77,29 @@ class ChangeBase(msrest.serialization.Model): """ _validation = { - 'property_change_type': {'readonly': True}, - 'change_category': {'readonly': True}, - 'previous_value': {'readonly': True}, - 'new_value': {'readonly': True}, + "property_change_type": {"readonly": True}, + "change_category": {"readonly": True}, + "previous_value": {"readonly": True}, + "new_value": {"readonly": True}, } _attribute_map = { - 'property_change_type': {'key': 'propertyChangeType', 'type': 'str'}, - 'change_category': {'key': 'changeCategory', 'type': 'str'}, - 'previous_value': {'key': 'previousValue', 'type': 'str'}, - 'new_value': {'key': 'newValue', 'type': 'str'}, + "property_change_type": {"key": "propertyChangeType", "type": "str"}, + "change_category": {"key": "changeCategory", "type": "str"}, + "previous_value": {"key": "previousValue", "type": "str"}, + "new_value": {"key": "newValue", "type": "str"}, } - def __init__( - self, - **kwargs - ): - """ - """ - super(ChangeBase, self).__init__(**kwargs) + def __init__(self, **kwargs): + """ """ + super().__init__(**kwargs) self.property_change_type = None self.change_category = None self.previous_value = None self.new_value = None -class ChangeProperties(msrest.serialization.Model): +class ChangeProperties(_serialization.Model): """The properties of a change. Variables are only populated by the server, and will be ignored when sending a request. @@ -113,8 +108,8 @@ class ChangeProperties(msrest.serialization.Model): :vartype target_resource_id: str :ivar target_resource_type: The namespace and type of the resource. :vartype target_resource_type: str - :ivar change_type: The type of change that was captured in the resource. Possible values - include: "Update", "Delete", "Create". + :ivar change_type: The type of change that was captured in the resource. Known values are: + "Update", "Delete", and "Create". :vartype change_type: str or ~azure.mgmt.resource.changes.v2022_05_01.models.ChangeType :ivar change_attributes: Details about the change resource. :vartype change_attributes: ~azure.mgmt.resource.changes.v2022_05_01.models.ChangeAttributes @@ -124,24 +119,24 @@ class ChangeProperties(msrest.serialization.Model): """ _validation = { - 'target_resource_id': {'readonly': True}, - 'target_resource_type': {'readonly': True}, - 'change_type': {'readonly': True}, + "target_resource_id": {"readonly": True}, + "target_resource_type": {"readonly": True}, + "change_type": {"readonly": True}, } _attribute_map = { - 'target_resource_id': {'key': 'targetResourceId', 'type': 'str'}, - 'target_resource_type': {'key': 'targetResourceType', 'type': 'str'}, - 'change_type': {'key': 'changeType', 'type': 'str'}, - 'change_attributes': {'key': 'changeAttributes', 'type': 'ChangeAttributes'}, - 'changes': {'key': 'changes', 'type': '{ChangeBase}'}, + "target_resource_id": {"key": "targetResourceId", "type": "str"}, + "target_resource_type": {"key": "targetResourceType", "type": "str"}, + "change_type": {"key": "changeType", "type": "str"}, + "change_attributes": {"key": "changeAttributes", "type": "ChangeAttributes"}, + "changes": {"key": "changes", "type": "{ChangeBase}"}, } def __init__( self, *, - change_attributes: Optional["ChangeAttributes"] = None, - changes: Optional[Dict[str, "ChangeBase"]] = None, + change_attributes: Optional["_models.ChangeAttributes"] = None, + changes: Optional[Dict[str, "_models.ChangeBase"]] = None, **kwargs ): """ @@ -151,7 +146,7 @@ def __init__( the value. :paramtype changes: dict[str, ~azure.mgmt.resource.changes.v2022_05_01.models.ChangeBase] """ - super(ChangeProperties, self).__init__(**kwargs) + super().__init__(**kwargs) self.target_resource_id = None self.target_resource_type = None self.change_type = None @@ -159,7 +154,7 @@ def __init__( self.changes = changes -class ChangeResourceListResult(msrest.serialization.Model): +class ChangeResourceListResult(_serialization.Model): """The list of resources. :ivar next_link: The link used to get the next page of Change Resources. @@ -169,16 +164,12 @@ class ChangeResourceListResult(msrest.serialization.Model): """ _attribute_map = { - 'next_link': {'key': 'nextLink', 'type': 'str'}, - 'value': {'key': 'value', 'type': '[ChangeResourceResult]'}, + "next_link": {"key": "nextLink", "type": "str"}, + "value": {"key": "value", "type": "[ChangeResourceResult]"}, } def __init__( - self, - *, - next_link: Optional[str] = None, - value: Optional[List["ChangeResourceResult"]] = None, - **kwargs + self, *, next_link: Optional[str] = None, value: Optional[List["_models.ChangeResourceResult"]] = None, **kwargs ): """ :keyword next_link: The link used to get the next page of Change Resources. @@ -186,12 +177,12 @@ def __init__( :keyword value: The list of resources. :paramtype value: list[~azure.mgmt.resource.changes.v2022_05_01.models.ChangeResourceResult] """ - super(ChangeResourceListResult, self).__init__(**kwargs) + super().__init__(**kwargs) self.next_link = next_link self.value = value -class Resource(msrest.serialization.Model): +class Resource(_serialization.Model): """Common fields that are returned in the response for all Azure Resource Manager resources. Variables are only populated by the server, and will be ignored when sending a request. @@ -207,24 +198,20 @@ class Resource(msrest.serialization.Model): """ _validation = { - 'id': {'readonly': True}, - 'name': {'readonly': True}, - 'type': {'readonly': True}, + "id": {"readonly": True}, + "name": {"readonly": True}, + "type": {"readonly": True}, } _attribute_map = { - 'id': {'key': 'id', 'type': 'str'}, - 'name': {'key': 'name', 'type': 'str'}, - 'type': {'key': 'type', 'type': 'str'}, + "id": {"key": "id", "type": "str"}, + "name": {"key": "name", "type": "str"}, + "type": {"key": "type", "type": "str"}, } - def __init__( - self, - **kwargs - ): - """ - """ - super(Resource, self).__init__(**kwargs) + def __init__(self, **kwargs): + """ """ + super().__init__(**kwargs) self.id = None self.name = None self.type = None @@ -248,33 +235,28 @@ class ChangeResourceResult(Resource): """ _validation = { - 'id': {'readonly': True}, - 'name': {'readonly': True}, - 'type': {'readonly': True}, + "id": {"readonly": True}, + "name": {"readonly": True}, + "type": {"readonly": True}, } _attribute_map = { - 'id': {'key': 'id', 'type': 'str'}, - 'name': {'key': 'name', 'type': 'str'}, - 'type': {'key': 'type', 'type': 'str'}, - 'properties': {'key': 'properties', 'type': 'ChangeProperties'}, + "id": {"key": "id", "type": "str"}, + "name": {"key": "name", "type": "str"}, + "type": {"key": "type", "type": "str"}, + "properties": {"key": "properties", "type": "ChangeProperties"}, } - def __init__( - self, - *, - properties: Optional["ChangeProperties"] = None, - **kwargs - ): + def __init__(self, *, properties: Optional["_models.ChangeProperties"] = None, **kwargs): """ :keyword properties: The properties of a change. :paramtype properties: ~azure.mgmt.resource.changes.v2022_05_01.models.ChangeProperties """ - super(ChangeResourceResult, self).__init__(**kwargs) + super().__init__(**kwargs) self.properties = properties -class ErrorAdditionalInfo(msrest.serialization.Model): +class ErrorAdditionalInfo(_serialization.Model): """The resource management error additional info. Variables are only populated by the server, and will be ignored when sending a request. @@ -282,31 +264,27 @@ class ErrorAdditionalInfo(msrest.serialization.Model): :ivar type: The additional info type. :vartype type: str :ivar info: The additional info. - :vartype info: any + :vartype info: JSON """ _validation = { - 'type': {'readonly': True}, - 'info': {'readonly': True}, + "type": {"readonly": True}, + "info": {"readonly": True}, } _attribute_map = { - 'type': {'key': 'type', 'type': 'str'}, - 'info': {'key': 'info', 'type': 'object'}, + "type": {"key": "type", "type": "str"}, + "info": {"key": "info", "type": "object"}, } - def __init__( - self, - **kwargs - ): - """ - """ - super(ErrorAdditionalInfo, self).__init__(**kwargs) + def __init__(self, **kwargs): + """ """ + super().__init__(**kwargs) self.type = None self.info = None -class ErrorDetail(msrest.serialization.Model): +class ErrorDetail(_serialization.Model): """The error detail. Variables are only populated by the server, and will be ignored when sending a request. @@ -325,28 +303,24 @@ class ErrorDetail(msrest.serialization.Model): """ _validation = { - 'code': {'readonly': True}, - 'message': {'readonly': True}, - 'target': {'readonly': True}, - 'details': {'readonly': True}, - 'additional_info': {'readonly': True}, + "code": {"readonly": True}, + "message": {"readonly": True}, + "target": {"readonly": True}, + "details": {"readonly": True}, + "additional_info": {"readonly": True}, } _attribute_map = { - 'code': {'key': 'code', 'type': 'str'}, - 'message': {'key': 'message', 'type': 'str'}, - 'target': {'key': 'target', 'type': 'str'}, - 'details': {'key': 'details', 'type': '[ErrorDetail]'}, - 'additional_info': {'key': 'additionalInfo', 'type': '[ErrorAdditionalInfo]'}, + "code": {"key": "code", "type": "str"}, + "message": {"key": "message", "type": "str"}, + "target": {"key": "target", "type": "str"}, + "details": {"key": "details", "type": "[ErrorDetail]"}, + "additional_info": {"key": "additionalInfo", "type": "[ErrorAdditionalInfo]"}, } - def __init__( - self, - **kwargs - ): - """ - """ - super(ErrorDetail, self).__init__(**kwargs) + def __init__(self, **kwargs): + """ """ + super().__init__(**kwargs) self.code = None self.message = None self.target = None @@ -354,7 +328,7 @@ def __init__( self.additional_info = None -class ErrorResponse(msrest.serialization.Model): +class ErrorResponse(_serialization.Model): """Common error response for all Azure Resource Manager APIs to return error details for failed operations. (This also follows the OData error response format.). :ivar error: The error object. @@ -362,18 +336,13 @@ class ErrorResponse(msrest.serialization.Model): """ _attribute_map = { - 'error': {'key': 'error', 'type': 'ErrorDetail'}, + "error": {"key": "error", "type": "ErrorDetail"}, } - def __init__( - self, - *, - error: Optional["ErrorDetail"] = None, - **kwargs - ): + def __init__(self, *, error: Optional["_models.ErrorDetail"] = None, **kwargs): """ :keyword error: The error object. :paramtype error: ~azure.mgmt.resource.changes.v2022_05_01.models.ErrorDetail """ - super(ErrorResponse, self).__init__(**kwargs) + super().__init__(**kwargs) self.error = error diff --git a/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/changes/v2022_05_01/models/_patch.py b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/changes/v2022_05_01/models/_patch.py new file mode 100644 index 0000000000000..f7dd32510333d --- /dev/null +++ b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/changes/v2022_05_01/models/_patch.py @@ -0,0 +1,20 @@ +# ------------------------------------ +# Copyright (c) Microsoft Corporation. +# Licensed under the MIT License. +# ------------------------------------ +"""Customize generated code here. + +Follow our quickstart for examples: https://aka.ms/azsdk/python/dpcodegen/python/customize +""" +from typing import List + +__all__: List[str] = [] # Add all objects you want publicly available to users at this package level + + +def patch_sdk(): + """Do not remove from this file. + + `patch_sdk` is a last resort escape hatch that allows you to do customizations + you can't accomplish using the techniques described in + https://aka.ms/azsdk/python/dpcodegen/python/customize + """ diff --git a/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/changes/v2022_05_01/operations/__init__.py b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/changes/v2022_05_01/operations/__init__.py index f3c0a138bab4a..80c317f699652 100644 --- a/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/changes/v2022_05_01/operations/__init__.py +++ b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/changes/v2022_05_01/operations/__init__.py @@ -8,6 +8,12 @@ from ._operations import ChangesOperations +from ._patch import __all__ as _patch_all +from ._patch import * # type: ignore # pylint: disable=unused-wildcard-import +from ._patch import patch_sdk as _patch_sdk + __all__ = [ - 'ChangesOperations', + "ChangesOperations", ] +__all__.extend([p for p in _patch_all if p not in __all__]) +_patch_sdk() diff --git a/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/changes/v2022_05_01/operations/_operations.py b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/changes/v2022_05_01/operations/_operations.py index 62eadea5a8324..df05a5159b064 100644 --- a/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/changes/v2022_05_01/operations/_operations.py +++ b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/changes/v2022_05_01/operations/_operations.py @@ -7,134 +7,138 @@ # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- from typing import Any, Callable, Dict, Iterable, Optional, TypeVar - -from msrest import Serializer - -from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error +from urllib.parse import parse_qs, urljoin, urlparse + +from azure.core.exceptions import ( + ClientAuthenticationError, + HttpResponseError, + ResourceExistsError, + ResourceNotFoundError, + ResourceNotModifiedError, + map_error, +) from azure.core.paging import ItemPaged from azure.core.pipeline import PipelineResponse from azure.core.pipeline.transport import HttpResponse from azure.core.rest import HttpRequest from azure.core.tracing.decorator import distributed_trace +from azure.core.utils import case_insensitive_dict from azure.mgmt.core.exceptions import ARMErrorFormat from .. import models as _models +from ..._serialization import Serializer from .._vendor import _convert_request, _format_url_section -T = TypeVar('T') + +T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] _SERIALIZER = Serializer() _SERIALIZER.client_side_validation = False + def build_changes_list_request( - subscription_id: str, resource_group_name: str, resource_provider_namespace: str, resource_type: str, resource_name: str, + subscription_id: str, *, - top: Optional[int] = 100, + top: int = 100, skip_token: Optional[str] = None, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2022-05-01") # type: 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", "2022-05-01")) # type: str + accept = _headers.pop("Accept", "application/json") - accept = "application/json" # Construct URL - _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{resourceType}/{resourceName}/providers/Microsoft.Resources/changes") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{resourceType}/{resourceName}/providers/Microsoft.Resources/changes", + ) # pylint: disable=line-too-long path_format_arguments = { - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str'), - "resourceProviderNamespace": _SERIALIZER.url("resource_provider_namespace", resource_provider_namespace, 'str'), - "resourceType": _SERIALIZER.url("resource_type", resource_type, 'str'), - "resourceName": _SERIALIZER.url("resource_name", resource_name, 'str'), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), + "resourceProviderNamespace": _SERIALIZER.url("resource_provider_namespace", resource_provider_namespace, "str"), + "resourceType": _SERIALIZER.url("resource_type", resource_type, "str"), + "resourceName": _SERIALIZER.url("resource_name", resource_name, "str"), } _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") if top is not None: - _query_parameters['$top'] = _SERIALIZER.query("top", top, 'long', maximum=100, minimum=1) + _params["$top"] = _SERIALIZER.query("top", top, "int", maximum=100, minimum=1) if skip_token is not None: - _query_parameters['$skipToken'] = _SERIALIZER.query("skip_token", skip_token, 'str') + _params["$skipToken"] = _SERIALIZER.query("skip_token", skip_token, "str") # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - return HttpRequest( - method="GET", - url=_url, - params=_query_parameters, - headers=_header_parameters, - **kwargs - ) + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) def build_changes_get_request( - subscription_id: str, resource_group_name: str, resource_provider_namespace: str, resource_type: str, resource_name: str, change_resource_id: str, + subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2022-05-01") # type: 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", "2022-05-01")) # type: str + accept = _headers.pop("Accept", "application/json") - accept = "application/json" # Construct URL - _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{resourceType}/{resourceName}/providers/Microsoft.Resources/changes/{changeResourceId}") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{resourceType}/{resourceName}/providers/Microsoft.Resources/changes/{changeResourceId}", + ) # pylint: disable=line-too-long path_format_arguments = { - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str'), - "resourceProviderNamespace": _SERIALIZER.url("resource_provider_namespace", resource_provider_namespace, 'str'), - "resourceType": _SERIALIZER.url("resource_type", resource_type, 'str'), - "resourceName": _SERIALIZER.url("resource_name", resource_name, 'str'), - "changeResourceId": _SERIALIZER.url("change_resource_id", change_resource_id, 'str'), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), + "resourceProviderNamespace": _SERIALIZER.url("resource_provider_namespace", resource_provider_namespace, "str"), + "resourceType": _SERIALIZER.url("resource_type", resource_type, "str"), + "resourceName": _SERIALIZER.url("resource_name", resource_name, "str"), + "changeResourceId": _SERIALIZER.url("change_resource_id", change_resource_id, "str"), } _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') - - return HttpRequest( - method="GET", - url=_url, - params=_query_parameters, - headers=_header_parameters, - **kwargs - ) - -class ChangesOperations(object): - """ChangesOperations operations. - - You should not instantiate this class directly. Instead, you should create a Client instance that - instantiates it for you and attaches it as an attribute. - - :ivar models: Alias to model classes used in this operation group. - :type models: ~azure.mgmt.resource.changes.v2022_05_01.models - :param client: Client for service requests. - :param config: Configuration of service client. - :param serializer: An object model serializer. - :param deserializer: An object model deserializer. + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) + + +class ChangesOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. + + Instead, you should access the following operations through + :class:`~azure.mgmt.resource.changes.v2022_05_01.ChangesClient`'s + :attr:`changes` attribute. """ models = _models - def __init__(self, client, config, serializer, deserializer): - self._client = client - self._serialize = serializer - self._deserialize = deserializer - self._config = config + def __init__(self, *args, **kwargs): + input_args = list(args) + self._client = input_args.pop(0) if input_args else kwargs.pop("client") + self._config = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") @distributed_trace def list( @@ -143,67 +147,72 @@ def list( resource_provider_namespace: str, resource_type: str, resource_name: str, - top: Optional[int] = 100, + top: int = 100, skip_token: Optional[str] = None, **kwargs: Any - ) -> Iterable["_models.ChangeResourceListResult"]: + ) -> Iterable["_models.ChangeResourceResult"]: """Obtains a list of change resources from the past 14 days for the target resource. - :param resource_group_name: The name of the resource group. + :param resource_group_name: The name of the resource group. Required. :type resource_group_name: str - :param resource_provider_namespace: The name of the resource provider namespace. + :param resource_provider_namespace: The name of the resource provider namespace. Required. :type resource_provider_namespace: str - :param resource_type: The name of the resource type. + :param resource_type: The name of the resource type. Required. :type resource_type: str - :param resource_name: The name of the resource. + :param resource_name: The name of the resource. Required. :type resource_name: str :param top: (Optional) Set the maximum number of results per response. Default value is 100. - :type top: long + :type top: int :param skip_token: (Optional) The page-continuation token. Default value is None. :type skip_token: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either ChangeResourceListResult or the result of + :return: An iterator like instance of either ChangeResourceResult or the result of cls(response) :rtype: - ~azure.core.paging.ItemPaged[~azure.mgmt.resource.changes.v2022_05_01.models.ChangeResourceListResult] - :raises: ~azure.core.exceptions.HttpResponseError + ~azure.core.paging.ItemPaged[~azure.mgmt.resource.changes.v2022_05_01.models.ChangeResourceResult] + :raises ~azure.core.exceptions.HttpResponseError: """ - api_version = kwargs.pop('api_version', "2022-05-01") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2022-05-01")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[_models.ChangeResourceListResult] - cls = kwargs.pop('cls', None) # type: ClsType["_models.ChangeResourceListResult"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) + def prepare_request(next_link=None): if not next_link: - + request = build_changes_list_request( - subscription_id=self._config.subscription_id, resource_group_name=resource_group_name, resource_provider_namespace=resource_provider_namespace, resource_type=resource_type, resource_name=resource_name, - api_version=api_version, + subscription_id=self._config.subscription_id, top=top, skip_token=skip_token, - template_url=self.list.metadata['url'], + 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.url = self._client.format_url(request.url) # type: ignore else: - - request = build_changes_list_request( - subscription_id=self._config.subscription_id, - resource_group_name=resource_group_name, - resource_provider_namespace=resource_provider_namespace, - resource_type=resource_type, - resource_name=resource_name, - template_url=next_link, - ) + # make call to next link with the client's api-version + _parsed_next_link = urlparse(next_link) + _next_request_params = case_insensitive_dict(parse_qs(_parsed_next_link.query)) + _next_request_params["api-version"] = self._config.api_version + request = HttpRequest("GET", urljoin(next_link, _parsed_next_link.path), params=_next_request_params) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore request.method = "GET" return request @@ -217,10 +226,8 @@ def extract_data(pipeline_response): def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) response = pipeline_response.http_response @@ -231,11 +238,9 @@ def get_next(next_link=None): return pipeline_response + return ItemPaged(get_next, extract_data) - return ItemPaged( - get_next, extract_data - ) - list.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{resourceType}/{resourceName}/providers/Microsoft.Resources/changes"} # type: ignore + list.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{resourceType}/{resourceName}/providers/Microsoft.Resources/changes"} # type: ignore @distributed_trace def get( @@ -246,51 +251,57 @@ def get( resource_name: str, change_resource_id: str, **kwargs: Any - ) -> "_models.ChangeResourceResult": + ) -> _models.ChangeResourceResult: """Obtains the specified change resource for the target resource. - :param resource_group_name: The name of the resource group. + :param resource_group_name: The name of the resource group. Required. :type resource_group_name: str - :param resource_provider_namespace: The name of the resource provider namespace. + :param resource_provider_namespace: The name of the resource provider namespace. Required. :type resource_provider_namespace: str - :param resource_type: The name of the resource type. + :param resource_type: The name of the resource type. Required. :type resource_type: str - :param resource_name: The name of the resource. + :param resource_name: The name of the resource. Required. :type resource_name: str - :param change_resource_id: The ID of the change resource. + :param change_resource_id: The ID of the change resource. Required. :type change_resource_id: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: ChangeResourceResult, or the result of cls(response) + :return: ChangeResourceResult or the result of cls(response) :rtype: ~azure.mgmt.resource.changes.v2022_05_01.models.ChangeResourceResult - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.ChangeResourceResult"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + 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', "2022-05-01") # type: str + api_version = kwargs.pop("api_version", _params.pop("api-version", "2022-05-01")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[_models.ChangeResourceResult] - request = build_changes_get_request( - subscription_id=self._config.subscription_id, resource_group_name=resource_group_name, resource_provider_namespace=resource_provider_namespace, resource_type=resource_type, resource_name=resource_name, change_resource_id=change_resource_id, + subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.get.metadata['url'], + template_url=self.get.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200]: @@ -298,12 +309,11 @@ def get( error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - deserialized = self._deserialize('ChangeResourceResult', pipeline_response) + deserialized = self._deserialize("ChangeResourceResult", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - get.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{resourceType}/{resourceName}/providers/Microsoft.Resources/changes/{changeResourceId}"} # type: ignore - + get.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{resourceType}/{resourceName}/providers/Microsoft.Resources/changes/{changeResourceId}"} # type: ignore diff --git a/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/changes/v2022_05_01/operations/_patch.py b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/changes/v2022_05_01/operations/_patch.py new file mode 100644 index 0000000000000..f7dd32510333d --- /dev/null +++ b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/changes/v2022_05_01/operations/_patch.py @@ -0,0 +1,20 @@ +# ------------------------------------ +# Copyright (c) Microsoft Corporation. +# Licensed under the MIT License. +# ------------------------------------ +"""Customize generated code here. + +Follow our quickstart for examples: https://aka.ms/azsdk/python/dpcodegen/python/customize +""" +from typing import List + +__all__: List[str] = [] # Add all objects you want publicly available to users at this package level + + +def patch_sdk(): + """Do not remove from this file. + + `patch_sdk` is a last resort escape hatch that allows you to do customizations + you can't accomplish using the techniques described in + https://aka.ms/azsdk/python/dpcodegen/python/customize + """ diff --git a/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/deploymentscripts/__init__.py b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/deploymentscripts/__init__.py index 1f514fcd17c48..f6fb8859512b2 100644 --- a/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/deploymentscripts/__init__.py +++ b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/deploymentscripts/__init__.py @@ -14,3 +14,7 @@ patch_sdk() except ImportError: pass + +from ._version import VERSION + +__version__ = VERSION diff --git a/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/deploymentscripts/_configuration.py b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/deploymentscripts/_configuration.py index d78176a792d96..92f3a64035361 100644 --- a/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/deploymentscripts/_configuration.py +++ b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/deploymentscripts/_configuration.py @@ -8,7 +8,7 @@ # Changes may cause incorrect behavior and will be lost if the code is # regenerated. # -------------------------------------------------------------------------- -from typing import TYPE_CHECKING +from typing import Any, TYPE_CHECKING from azure.core.configuration import Configuration from azure.core.pipeline import policies @@ -18,8 +18,6 @@ if TYPE_CHECKING: # pylint: disable=unused-import,ungrouped-imports - from typing import Any - from azure.core.credentials import TokenCredential class DeploymentScriptsClientConfiguration(Configuration): @@ -28,16 +26,16 @@ class DeploymentScriptsClientConfiguration(Configuration): Note that all parameters used to create this instance are saved as instance attributes. - :param credential: Credential needed for the client to connect to Azure. + :param credential: Credential needed for the client to connect to Azure. Required. :type credential: ~azure.core.credentials.TokenCredential - :param subscription_id: Subscription Id which forms part of the URI for every service call. + :param subscription_id: Subscription Id which forms part of the URI for every service call. Required. :type subscription_id: str """ def __init__( self, - credential, # type: "TokenCredential" - subscription_id, # type: str + credential: "TokenCredential", + subscription_id: str, **kwargs # type: Any ): # type: (...) -> None diff --git a/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/deploymentscripts/_deployment_scripts_client.py b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/deploymentscripts/_deployment_scripts_client.py index 18325aa2297d9..7da2988b104e8 100644 --- a/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/deploymentscripts/_deployment_scripts_client.py +++ b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/deploymentscripts/_deployment_scripts_client.py @@ -9,20 +9,17 @@ # regenerated. # -------------------------------------------------------------------------- -from typing import TYPE_CHECKING - -from msrest import Deserializer, Serializer +from typing import Any, Optional, TYPE_CHECKING from azure.mgmt.core import ARMPipelineClient from azure.profiles import KnownProfiles, ProfileDefinition from azure.profiles.multiapiclient import MultiApiClientMixin from ._configuration import DeploymentScriptsClientConfiguration +from ._serialization import Deserializer, Serializer if TYPE_CHECKING: # pylint: disable=unused-import,ungrouped-imports - from typing import Any, Optional - from azure.core.credentials import TokenCredential class _SDKClient(object): @@ -43,9 +40,9 @@ class DeploymentScriptsClient(MultiApiClientMixin, _SDKClient): The api-version parameter sets the default API version if the operation group is not described in the profile. - :param credential: Credential needed for the client to connect to Azure. + :param credential: Credential needed for the client to connect to Azure. Required. :type credential: ~azure.core.credentials.TokenCredential - :param subscription_id: Subscription Id which forms part of the URI for every service call. + :param subscription_id: Subscription Id which forms part of the URI for every service call. Required. :type subscription_id: str :param api_version: API version to use if no profile is provided, or if missing in profile. :type api_version: str @@ -67,10 +64,10 @@ class DeploymentScriptsClient(MultiApiClientMixin, _SDKClient): def __init__( self, - credential, # type: "TokenCredential" - subscription_id, # type: str + credential: "TokenCredential", + subscription_id: str, api_version=None, # type: Optional[str] - base_url="https://management.azure.com", # type: str + base_url: str = "https://management.azure.com", profile=KnownProfiles.default, # type: KnownProfiles **kwargs # type: Any ): diff --git a/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/deploymentscripts/_serialization.py b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/deploymentscripts/_serialization.py new file mode 100644 index 0000000000000..240df16c57f3c --- /dev/null +++ b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/deploymentscripts/_serialization.py @@ -0,0 +1,2006 @@ +# -------------------------------------------------------------------------- +# +# Copyright (c) Microsoft Corporation. All rights reserved. +# +# The MIT License (MIT) +# +# Permission is hereby granted, free of charge, to any person obtaining a copy +# of this software and associated documentation files (the ""Software""), to +# deal in the Software without restriction, including without limitation the +# rights to use, copy, modify, merge, publish, distribute, sublicense, and/or +# sell copies of the Software, and to permit persons to whom the Software is +# furnished to do so, subject to the following conditions: +# +# The above copyright notice and this permission notice shall be included in +# all copies or substantial portions of the Software. +# +# THE SOFTWARE IS PROVIDED *AS IS*, WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING +# FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS +# IN THE SOFTWARE. +# +# -------------------------------------------------------------------------- + +# pylint: skip-file + +from base64 import b64decode, b64encode +import calendar +import datetime +import decimal +import email +from enum import Enum +import json +import logging +import re +import sys +import codecs +try: + from urllib import quote # type: ignore +except ImportError: + from urllib.parse import quote # type: ignore +import xml.etree.ElementTree as ET + +import isodate + +from typing import Dict, Any, cast, TYPE_CHECKING + +from azure.core.exceptions import DeserializationError, SerializationError, raise_with_traceback + +_BOM = codecs.BOM_UTF8.decode(encoding='utf-8') + +if TYPE_CHECKING: + from typing import Optional, Union, AnyStr, IO, Mapping + +class RawDeserializer: + + # Accept "text" because we're open minded people... + JSON_REGEXP = re.compile(r'^(application|text)/([a-z+.]+\+)?json$') + + # Name used in context + CONTEXT_NAME = "deserialized_data" + + @classmethod + def deserialize_from_text(cls, data, content_type=None): + # type: (Optional[Union[AnyStr, IO]], Optional[str]) -> Any + """Decode data according to content-type. + + Accept a stream of data as well, but will be load at once in memory for now. + + If no content-type, will return the string version (not bytes, not stream) + + :param data: Input, could be bytes or stream (will be decoded with UTF8) or text + :type data: str or bytes or IO + :param str content_type: The content type. + """ + if hasattr(data, 'read'): + # Assume a stream + data = cast(IO, data).read() + + if isinstance(data, bytes): + data_as_str = data.decode(encoding='utf-8-sig') + else: + # Explain to mypy the correct type. + data_as_str = cast(str, data) + + # Remove Byte Order Mark if present in string + data_as_str = data_as_str.lstrip(_BOM) + + if content_type is None: + return data + + if cls.JSON_REGEXP.match(content_type): + try: + return json.loads(data_as_str) + except ValueError as err: + raise DeserializationError("JSON is invalid: {}".format(err), err) + elif "xml" in (content_type or []): + try: + + try: + if isinstance(data, unicode): # type: ignore + # If I'm Python 2.7 and unicode XML will scream if I try a "fromstring" on unicode string + data_as_str = data_as_str.encode(encoding="utf-8") # type: ignore + except NameError: + pass + + return ET.fromstring(data_as_str) # nosec + except ET.ParseError: + # It might be because the server has an issue, and returned JSON with + # content-type XML.... + # So let's try a JSON load, and if it's still broken + # let's flow the initial exception + def _json_attemp(data): + try: + return True, json.loads(data) + except ValueError: + return False, None # Don't care about this one + success, json_result = _json_attemp(data) + if success: + return json_result + # If i'm here, it's not JSON, it's not XML, let's scream + # and raise the last context in this block (the XML exception) + # The function hack is because Py2.7 messes up with exception + # context otherwise. + _LOGGER.critical("Wasn't XML not JSON, failing") + raise_with_traceback(DeserializationError, "XML is invalid") + 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 + """Deserialize from HTTP response. + + Use bytes and headers to NOT use any requests/aiohttp or whatever + specific implementation. + Headers will tested for "content-type" + """ + # Try to use content-type from headers if available + content_type = None + if 'content-type' in headers: + content_type = headers['content-type'].split(";")[0].strip().lower() + # Ouch, this server did not declare what it sent... + # Let's guess it's JSON... + # Also, since Autorest was considering that an empty body was a valid JSON, + # need that test as well.... + else: + content_type = "application/json" + + if body_bytes: + return cls.deserialize_from_text(body_bytes, content_type) + return None + +try: + basestring # type: ignore + unicode_str = unicode # type: ignore +except NameError: + basestring = str # type: ignore + unicode_str = str # type: ignore + +_LOGGER = logging.getLogger(__name__) + +try: + _long_type = long # type: ignore +except NameError: + _long_type = int + +class UTC(datetime.tzinfo): + """Time Zone info for handling UTC""" + + def utcoffset(self, dt): + """UTF offset for UTC is 0.""" + return datetime.timedelta(0) + + def tzname(self, dt): + """Timestamp representation.""" + return "Z" + + def dst(self, dt): + """No daylight saving for UTC.""" + return datetime.timedelta(hours=1) + +try: + from datetime import timezone as _FixedOffset +except ImportError: # Python 2.7 + class _FixedOffset(datetime.tzinfo): # type: ignore + """Fixed offset in minutes east from UTC. + Copy/pasted from Python doc + :param datetime.timedelta offset: offset in timedelta format + """ + + def __init__(self, offset): + self.__offset = offset + + def utcoffset(self, dt): + return self.__offset + + def tzname(self, dt): + return str(self.__offset.total_seconds()/3600) + + def __repr__(self): + return "".format(self.tzname(None)) + + def dst(self, dt): + return datetime.timedelta(0) + + def __getinitargs__(self): + return (self.__offset,) + +try: + from datetime import timezone + TZ_UTC = timezone.utc # type: ignore +except ImportError: + TZ_UTC = UTC() # type: ignore + +_FLATTEN = re.compile(r"(? y, + "minimum": lambda x, y: x < y, + "maximum": lambda x, y: x > y, + "minimum_ex": lambda x, y: x <= y, + "maximum_ex": lambda x, y: x >= y, + "min_items": lambda x, y: len(x) < y, + "max_items": lambda x, y: len(x) > y, + "pattern": lambda x, y: not re.match(y, x, re.UNICODE), + "unique": lambda x, y: len(x) != len(set(x)), + "multiple": lambda x, y: x % y != 0 + } + + def __init__(self, classes=None): + self.serialize_type = { + 'iso-8601': Serializer.serialize_iso, + 'rfc-1123': Serializer.serialize_rfc, + 'unix-time': Serializer.serialize_unix, + 'duration': Serializer.serialize_duration, + 'date': Serializer.serialize_date, + 'time': Serializer.serialize_time, + 'decimal': Serializer.serialize_decimal, + 'long': Serializer.serialize_long, + 'bytearray': Serializer.serialize_bytearray, + 'base64': Serializer.serialize_base64, + 'object': self.serialize_object, + '[]': self.serialize_iter, + '{}': self.serialize_dict + } + self.dependencies = dict(classes) if classes else {} + self.key_transformer = full_restapi_key_transformer + self.client_side_validation = True + + def _serialize(self, target_obj, data_type=None, **kwargs): + """Serialize data into a string according to type. + + :param target_obj: The data to be serialized. + :param str data_type: The type to be serialized from. + :rtype: str, dict + :raises: SerializationError if serialization fails. + """ + key_transformer = kwargs.get("key_transformer", self.key_transformer) + keep_readonly = kwargs.get("keep_readonly", False) + if target_obj is None: + return None + + attr_name = None + class_name = target_obj.__class__.__name__ + + if data_type: + return self.serialize_data( + target_obj, data_type, **kwargs) + + if not hasattr(target_obj, "_attribute_map"): + data_type = type(target_obj).__name__ + if data_type in self.basic_types.values(): + return self.serialize_data( + target_obj, data_type, **kwargs) + + # Force "is_xml" kwargs if we detect a XML model + try: + is_xml_model_serialization = kwargs["is_xml"] + except KeyError: + is_xml_model_serialization = kwargs.setdefault("is_xml", target_obj.is_xml_model()) + + serialized = {} + if is_xml_model_serialization: + serialized = target_obj._create_xml_node() + try: + attributes = target_obj._attribute_map + for attr, attr_desc in attributes.items(): + attr_name = attr + if not keep_readonly and target_obj._validation.get(attr_name, {}).get('readonly', False): + continue + + if attr_name == "additional_properties" and attr_desc["key"] == '': + if target_obj.additional_properties is not None: + serialized.update(target_obj.additional_properties) + continue + try: + + orig_attr = getattr(target_obj, attr) + if is_xml_model_serialization: + pass # Don't provide "transformer" for XML for now. Keep "orig_attr" + else: # JSON + keys, orig_attr = key_transformer(attr, attr_desc.copy(), orig_attr) + keys = keys if isinstance(keys, list) else [keys] + + + kwargs["serialization_ctxt"] = attr_desc + new_attr = self.serialize_data(orig_attr, attr_desc['type'], **kwargs) + + + if is_xml_model_serialization: + xml_desc = attr_desc.get('xml', {}) + xml_name = xml_desc.get('name', attr_desc['key']) + xml_prefix = xml_desc.get('prefix', None) + xml_ns = xml_desc.get('ns', None) + 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) + continue + if xml_desc.get("text", False): + serialized.text = new_attr + continue + if isinstance(new_attr, list): + serialized.extend(new_attr) + 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', {}): + splitted_tag = new_attr.tag.split("}") + if len(splitted_tag) == 2: # Namespace + new_attr.tag = "}".join([splitted_tag[0], xml_name]) + else: + new_attr.tag = xml_name + serialized.append(new_attr) + 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) + else: # JSON + for k in reversed(keys): + unflattened = {k: new_attr} + new_attr = unflattened + + _new_attr = new_attr + _serialized = serialized + for k in keys: + if k not in _serialized: + _serialized.update(_new_attr) + _new_attr = _new_attr[k] + _serialized = _serialized[k] + except ValueError: + continue + + except (AttributeError, KeyError, TypeError) as err: + msg = "Attribute {} in object {} cannot be serialized.\n{}".format( + attr_name, class_name, str(target_obj)) + raise_with_traceback(SerializationError, msg, err) + else: + return serialized + + def body(self, data, data_type, **kwargs): + """Serialize data intended for a request body. + + :param data: The data to be serialized. + :param str data_type: The type to be serialized from. + :rtype: dict + :raises: SerializationError if serialization fails. + :raises: ValueError if data is None + """ + + # Just in case this is a dict + internal_data_type = data_type.strip('[]{}') + internal_data_type = self.dependencies.get(internal_data_type, None) + try: + is_xml_model_serialization = kwargs["is_xml"] + except KeyError: + if internal_data_type and issubclass(internal_data_type, Model): + is_xml_model_serialization = kwargs.setdefault("is_xml", internal_data_type.is_xml_model()) + else: + is_xml_model_serialization = False + if internal_data_type and not isinstance(internal_data_type, Enum): + try: + deserializer = Deserializer(self.dependencies) + # Since it's on serialization, it's almost sure that format is not JSON REST + # We're not able to deal with additional properties for now. + deserializer.additional_properties_detection = False + if is_xml_model_serialization: + deserializer.key_extractors = [ + attribute_key_case_insensitive_extractor, + ] + else: + deserializer.key_extractors = [ + rest_key_case_insensitive_extractor, + attribute_key_case_insensitive_extractor, + last_rest_key_case_insensitive_extractor + ] + data = deserializer._deserialize(data_type, data) + except DeserializationError as err: + raise_with_traceback( + SerializationError, "Unable to build a model: "+str(err), err) + + return self._serialize(data, data_type, **kwargs) + + def url(self, name, data, data_type, **kwargs): + """Serialize data intended for a URL path. + + :param data: The data to be serialized. + :param str data_type: The type to be serialized from. + :rtype: str + :raises: TypeError if serialization fails. + :raises: ValueError if data is None + """ + try: + output = self.serialize_data(data, data_type, **kwargs) + if data_type == 'bool': + output = json.dumps(output) + + if kwargs.get('skip_quote') is True: + output = str(output) + else: + output = quote(str(output), safe='') + except SerializationError: + raise TypeError("{} must be type {}.".format(name, data_type)) + else: + return output + + def query(self, name, data, data_type, **kwargs): + """Serialize data intended for a URL query. + + :param data: The data to be serialized. + :param str data_type: The type to be serialized from. + :rtype: str + :raises: TypeError if serialization fails. + :raises: ValueError if data is None + """ + try: + # 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)) + + # Not a list, regular serialization + output = self.serialize_data(data, data_type, **kwargs) + if data_type == 'bool': + output = json.dumps(output) + if kwargs.get('skip_quote') is True: + output = str(output) + else: + output = quote(str(output), safe='') + except SerializationError: + raise TypeError("{} must be type {}.".format(name, data_type)) + else: + return str(output) + + def header(self, name, data, data_type, **kwargs): + """Serialize data intended for a request header. + + :param data: The data to be serialized. + :param str data_type: The type to be serialized from. + :rtype: str + :raises: TypeError if serialization fails. + :raises: ValueError if data is None + """ + try: + if data_type in ['[str]']: + data = ["" if d is None else d for d in data] + + output = self.serialize_data(data, data_type, **kwargs) + if data_type == 'bool': + output = json.dumps(output) + except SerializationError: + raise TypeError("{} must be type {}.".format(name, data_type)) + else: + return str(output) + + def serialize_data(self, data, data_type, **kwargs): + """Serialize generic data according to supplied data type. + + :param data: The data to be serialized. + :param str data_type: The type to be serialized from. + :param bool required: Whether it's essential that the data not be + empty or None + :raises: AttributeError if required data is None. + :raises: ValueError if data is None + :raises: SerializationError if serialization fails. + """ + if data is None: + raise ValueError("No value for given attribute") + + try: + if data_type in self.basic_types.values(): + return self.serialize_basic(data, data_type, **kwargs) + + elif data_type in self.serialize_type: + return self.serialize_type[data_type](data, **kwargs) + + # If dependencies is empty, try with current data class + # It has to be a subclass of Enum anyway + enum_type = self.dependencies.get(data_type, data.__class__) + if issubclass(enum_type, Enum): + return Serializer.serialize_enum(data, enum_obj=enum_type) + + iter_type = data_type[0] + data_type[-1] + if iter_type in self.serialize_type: + return self.serialize_type[iter_type]( + data, data_type[1:-1], **kwargs) + + except (ValueError, TypeError) as err: + msg = "Unable to serialize value: {!r} as type: {!r}." + raise_with_traceback( + SerializationError, msg.format(data, data_type), err) + else: + return self._serialize(data, **kwargs) + + @classmethod + def _get_custom_serializers(cls, data_type, **kwargs): + custom_serializer = kwargs.get("basic_types_serializers", {}).get(data_type) + if custom_serializer: + return custom_serializer + if kwargs.get("is_xml", False): + return cls._xml_basic_types_serializers.get(data_type) + + @classmethod + def serialize_basic(cls, data, data_type, **kwargs): + """Serialize basic builting data type. + Serializes objects to str, int, float or bool. + + Possible kwargs: + - basic_types_serializers dict[str, callable] : If set, use the callable as serializer + - is_xml bool : If set, use xml_basic_types_serializers + + :param data: Object to be serialized. + :param str data_type: Type of object in the iterable. + """ + custom_serializer = cls._get_custom_serializers(data_type, **kwargs) + if custom_serializer: + return custom_serializer(data) + if data_type == 'str': + return cls.serialize_unicode(data) + return eval(data_type)(data) # nosec + + @classmethod + def serialize_unicode(cls, data): + """Special handling for serializing unicode strings in Py2. + Encode to UTF-8 if unicode, otherwise handle as a str. + + :param data: Object to be serialized. + :rtype: str + """ + try: # If I received an enum, return its value + return data.value + except AttributeError: + pass + + try: + if isinstance(data, unicode): + # Don't change it, JSON and XML ElementTree are totally able + # to serialize correctly u'' strings + return data + except NameError: + return str(data) + else: + return str(data) + + def serialize_iter(self, data, iter_type, div=None, **kwargs): + """Serialize iterable. + + Supported kwargs: + - serialization_ctxt dict : The current entry of _attribute_map, or same format. + serialization_ctxt['type'] should be same as data_type. + - is_xml bool : If set, serialize as XML + + :param list attr: Object to be serialized. + :param str iter_type: Type of object in the iterable. + :param bool required: Whether the objects in the iterable must + not be None or empty. + :param str div: If set, this str will be used to combine the elements + in the iterable into a combined string. Default is 'None'. + :rtype: list, str + """ + if isinstance(data, str): + raise SerializationError("Refuse str type as a valid iter type.") + + serialization_ctxt = kwargs.get("serialization_ctxt", {}) + is_xml = kwargs.get("is_xml", False) + + serialized = [] + for d in data: + try: + serialized.append(self.serialize_data(d, iter_type, **kwargs)) + except ValueError: + serialized.append(None) + + if div: + serialized = ['' if s is None else str(s) for s in serialized] + serialized = div.join(serialized) + + if 'xml' in serialization_ctxt or is_xml: + # XML serialization is more complicated + xml_desc = serialization_ctxt.get('xml', {}) + xml_name = xml_desc.get('name') + if not xml_name: + xml_name = serialization_ctxt['key'] + + # Create a wrap node if necessary (use the fact that Element and list have "append") + is_wrapped = xml_desc.get("wrapped", False) + node_name = xml_desc.get("itemsName", xml_name) + if is_wrapped: + final_result = _create_xml_node( + xml_name, + xml_desc.get('prefix', None), + xml_desc.get('ns', None) + ) + else: + final_result = [] + # All list elements to "local_node" + for el in serialized: + if isinstance(el, ET.Element): + el_node = el + else: + el_node = _create_xml_node( + node_name, + xml_desc.get('prefix', None), + xml_desc.get('ns', None) + ) + if el is not None: # Otherwise it writes "None" :-p + el_node.text = str(el) + final_result.append(el_node) + return final_result + return serialized + + def serialize_dict(self, attr, dict_type, **kwargs): + """Serialize a dictionary of objects. + + :param dict attr: Object to be serialized. + :param str dict_type: Type of object in the dictionary. + :param bool required: Whether the objects in the dictionary must + not be None or empty. + :rtype: dict + """ + serialization_ctxt = kwargs.get("serialization_ctxt", {}) + serialized = {} + for key, value in attr.items(): + try: + serialized[self.serialize_unicode(key)] = self.serialize_data( + value, dict_type, **kwargs) + except ValueError: + serialized[self.serialize_unicode(key)] = None + + if 'xml' in serialization_ctxt: + # XML serialization is more complicated + xml_desc = serialization_ctxt['xml'] + xml_name = xml_desc['name'] + + final_result = _create_xml_node( + xml_name, + xml_desc.get('prefix', None), + xml_desc.get('ns', None) + ) + for key, value in serialized.items(): + ET.SubElement(final_result, key).text = value + return final_result + + return serialized + + def serialize_object(self, attr, **kwargs): + """Serialize a generic object. + This will be handled as a dictionary. If object passed in is not + a basic type (str, int, float, dict, list) it will simply be + cast to str. + + :param dict attr: Object to be serialized. + :rtype: dict or str + """ + if attr is None: + return None + if isinstance(attr, ET.Element): + return attr + obj_type = type(attr) + if obj_type in self.basic_types: + return self.serialize_basic(attr, self.basic_types[obj_type], **kwargs) + if obj_type is _long_type: + return self.serialize_long(attr) + if obj_type is unicode_str: + return self.serialize_unicode(attr) + if obj_type is datetime.datetime: + return self.serialize_iso(attr) + if obj_type is datetime.date: + return self.serialize_date(attr) + if obj_type is datetime.time: + return self.serialize_time(attr) + if obj_type is datetime.timedelta: + return self.serialize_duration(attr) + if obj_type is decimal.Decimal: + return self.serialize_decimal(attr) + + # If it's a model or I know this dependency, serialize as a Model + elif obj_type in self.dependencies.values() or isinstance(attr, Model): + return self._serialize(attr) + + if obj_type == dict: + serialized = {} + for key, value in attr.items(): + try: + serialized[self.serialize_unicode(key)] = self.serialize_object( + value, **kwargs) + except ValueError: + serialized[self.serialize_unicode(key)] = None + return serialized + + if obj_type == list: + serialized = [] + for obj in attr: + try: + serialized.append(self.serialize_object( + obj, **kwargs)) + except ValueError: + pass + return serialized + return str(attr) + + @staticmethod + def serialize_enum(attr, enum_obj=None): + try: + result = attr.value + except AttributeError: + result = attr + try: + enum_obj(result) + return result + except ValueError: + for enum_value in enum_obj: + if enum_value.value.lower() == str(attr).lower(): + return enum_value.value + error = "{!r} is not valid value for enum {!r}" + raise SerializationError(error.format(attr, enum_obj)) + + @staticmethod + def serialize_bytearray(attr, **kwargs): + """Serialize bytearray into base-64 string. + + :param attr: Object to be serialized. + :rtype: str + """ + return b64encode(attr).decode() + + @staticmethod + def serialize_base64(attr, **kwargs): + """Serialize str into base-64 string. + + :param attr: Object to be serialized. + :rtype: str + """ + encoded = b64encode(attr).decode('ascii') + return encoded.strip('=').replace('+', '-').replace('/', '_') + + @staticmethod + def serialize_decimal(attr, **kwargs): + """Serialize Decimal object to float. + + :param attr: Object to be serialized. + :rtype: float + """ + return float(attr) + + @staticmethod + def serialize_long(attr, **kwargs): + """Serialize long (Py2) or int (Py3). + + :param attr: Object to be serialized. + :rtype: int/long + """ + return _long_type(attr) + + @staticmethod + def serialize_date(attr, **kwargs): + """Serialize Date object into ISO-8601 formatted string. + + :param Date attr: Object to be serialized. + :rtype: str + """ + if isinstance(attr, str): + attr = isodate.parse_date(attr) + t = "{:04}-{:02}-{:02}".format(attr.year, attr.month, attr.day) + return t + + @staticmethod + def serialize_time(attr, **kwargs): + """Serialize Time object into ISO-8601 formatted string. + + :param datetime.time attr: Object to be serialized. + :rtype: str + """ + if isinstance(attr, str): + attr = isodate.parse_time(attr) + t = "{:02}:{:02}:{:02}".format(attr.hour, attr.minute, attr.second) + if attr.microsecond: + t += ".{:02}".format(attr.microsecond) + return t + + @staticmethod + def serialize_duration(attr, **kwargs): + """Serialize TimeDelta object into ISO-8601 formatted string. + + :param TimeDelta attr: Object to be serialized. + :rtype: str + """ + if isinstance(attr, str): + attr = isodate.parse_duration(attr) + return isodate.duration_isoformat(attr) + + @staticmethod + def serialize_rfc(attr, **kwargs): + """Serialize Datetime object into RFC-1123 formatted string. + + :param Datetime attr: Object to be serialized. + :rtype: str + :raises: TypeError if format invalid. + """ + try: + if not attr.tzinfo: + _LOGGER.warning( + "Datetime with no tzinfo will be considered UTC.") + utc = attr.utctimetuple() + except AttributeError: + raise TypeError("RFC1123 object must be valid Datetime object.") + + return "{}, {:02} {} {:04} {:02}:{:02}:{:02} GMT".format( + Serializer.days[utc.tm_wday], utc.tm_mday, + Serializer.months[utc.tm_mon], utc.tm_year, + utc.tm_hour, utc.tm_min, utc.tm_sec) + + @staticmethod + def serialize_iso(attr, **kwargs): + """Serialize Datetime object into ISO-8601 formatted string. + + :param Datetime attr: Object to be serialized. + :rtype: str + :raises: SerializationError if format invalid. + """ + if isinstance(attr, str): + attr = isodate.parse_datetime(attr) + try: + if not attr.tzinfo: + _LOGGER.warning( + "Datetime with no tzinfo will be considered UTC.") + utc = attr.utctimetuple() + if utc.tm_year > 9999 or utc.tm_year < 1: + raise OverflowError("Hit max or min date") + + microseconds = str(attr.microsecond).rjust(6,'0').rstrip('0').ljust(3, '0') + if microseconds: + microseconds = '.'+microseconds + date = "{:04}-{:02}-{:02}T{:02}:{:02}:{:02}".format( + utc.tm_year, utc.tm_mon, utc.tm_mday, + utc.tm_hour, utc.tm_min, utc.tm_sec) + return date + microseconds + 'Z' + except (ValueError, OverflowError) as err: + msg = "Unable to serialize datetime object." + raise_with_traceback(SerializationError, msg, err) + except AttributeError as err: + msg = "ISO-8601 object must be valid Datetime object." + raise_with_traceback(TypeError, msg, err) + + @staticmethod + def serialize_unix(attr, **kwargs): + """Serialize Datetime object into IntTime format. + This is represented as seconds. + + :param Datetime attr: Object to be serialized. + :rtype: int + :raises: SerializationError if format invalid + """ + if isinstance(attr, int): + return attr + try: + if not attr.tzinfo: + _LOGGER.warning( + "Datetime with no tzinfo will be considered UTC.") + return int(calendar.timegm(attr.utctimetuple())) + except AttributeError: + raise TypeError("Unix time object must be valid Datetime object.") + +def rest_key_extractor(attr, attr_desc, data): + key = attr_desc['key'] + working_data = data + + while '.' in key: + dict_keys = _FLATTEN.split(key) + if len(dict_keys) == 1: + key = _decode_attribute_map_key(dict_keys[0]) + break + working_key = _decode_attribute_map_key(dict_keys[0]) + working_data = working_data.get(working_key, data) + if working_data is None: + # If at any point while following flatten JSON path see None, it means + # that all properties under are None as well + # https://github.com/Azure/msrest-for-python/issues/197 + return None + key = '.'.join(dict_keys[1:]) + + return working_data.get(key) + +def rest_key_case_insensitive_extractor(attr, attr_desc, data): + key = attr_desc['key'] + working_data = data + + while '.' in key: + dict_keys = _FLATTEN.split(key) + if len(dict_keys) == 1: + key = _decode_attribute_map_key(dict_keys[0]) + break + working_key = _decode_attribute_map_key(dict_keys[0]) + working_data = attribute_key_case_insensitive_extractor(working_key, None, working_data) + if working_data is None: + # If at any point while following flatten JSON path see None, it means + # that all properties under are None as well + # https://github.com/Azure/msrest-for-python/issues/197 + return None + key = '.'.join(dict_keys[1:]) + + if working_data: + return attribute_key_case_insensitive_extractor(key, None, working_data) + +def last_rest_key_extractor(attr, attr_desc, data): + """Extract the attribute in "data" based on the last part of the JSON path key. + """ + key = attr_desc['key'] + dict_keys = _FLATTEN.split(key) + return attribute_key_extractor(dict_keys[-1], None, data) + +def last_rest_key_case_insensitive_extractor(attr, attr_desc, data): + """Extract the attribute in "data" based on the last part of the JSON path key. + + This is the case insensitive version of "last_rest_key_extractor" + """ + key = attr_desc['key'] + dict_keys = _FLATTEN.split(key) + return attribute_key_case_insensitive_extractor(dict_keys[-1], None, data) + +def attribute_key_extractor(attr, _, data): + return data.get(attr) + +def attribute_key_case_insensitive_extractor(attr, _, data): + found_key = None + lower_attr = attr.lower() + for key in data: + if lower_attr == key.lower(): + found_key = key + break + + return data.get(found_key) + +def _extract_name_from_internal_type(internal_type): + """Given an internal type XML description, extract correct XML name with namespace. + + :param dict internal_type: An model type + :rtype: tuple + :returns: A tuple XML name + namespace dict + """ + internal_type_xml_map = getattr(internal_type, "_xml_map", {}) + 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) + return xml_name + + +def xml_key_extractor(attr, attr_desc, data): + if isinstance(data, dict): + return None + + # Test if this model is XML ready first + if not isinstance(data, ET.Element): + return None + + xml_desc = attr_desc.get('xml', {}) + xml_name = xml_desc.get('name', attr_desc['key']) + + # Look for a children + is_iter_type = attr_desc['type'].startswith("[") + is_wrapped = xml_desc.get("wrapped", False) + internal_type = attr_desc.get("internalType", None) + internal_type_xml_map = getattr(internal_type, "_xml_map", {}) + + # 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) + + # If it's an attribute, that's simple + if xml_desc.get("attr", False): + return data.get(xml_name) + + # If it's x-ms-text, that's simple too + if xml_desc.get("text", False): + return data.text + + # Scenario where I take the local name: + # - Wrapped node + # - Internal type is an enum (considered basic types) + # - Internal type has no XML/Name node + if is_wrapped or (internal_type and (issubclass(internal_type, Enum) or 'name' not in internal_type_xml_map)): + children = data.findall(xml_name) + # If internal type has a local name and it's not a list, I use that name + elif not is_iter_type and internal_type and 'name' in internal_type_xml_map: + xml_name = _extract_name_from_internal_type(internal_type) + children = data.findall(xml_name) + # That's an array + else: + if internal_type: # Complex type, ignore itemsName and use the complex type name + items_name = _extract_name_from_internal_type(internal_type) + else: + items_name = xml_desc.get("itemsName", xml_name) + children = data.findall(items_name) + + if len(children) == 0: + if is_iter_type: + if is_wrapped: + return None # is_wrapped no node, we want None + else: + return [] # not wrapped, assume empty list + return None # Assume it's not there, maybe an optional node. + + # If is_iter_type and not wrapped, return all found children + if is_iter_type: + if not is_wrapped: + return children + else: # Iter and wrapped, should have found one node only (the wrap one) + if len(children) != 1: + raise DeserializationError( + "Tried to deserialize an array not wrapped, and found several nodes '{}'. Maybe you should declare this array as wrapped?".format( + xml_name + )) + return list(children[0]) # Might be empty list and that's ok. + + # Here it's not a itertype, we should have found one element only or empty + if len(children) > 1: + raise DeserializationError("Find several XML '{}' where it was not expected".format(xml_name)) + return children[0] + +class Deserializer(object): + """Response object model deserializer. + + :param dict classes: Class type dictionary for deserializing complex types. + :ivar list key_extractors: Ordered list of extractors to be used by this deserializer. + """ + + basic_types = {str: 'str', int: 'int', bool: 'bool', float: 'float'} + + valid_date = re.compile( + r'\d{4}[-]\d{2}[-]\d{2}T\d{2}:\d{2}:\d{2}' + r'\.?\d*Z?[-+]?[\d{2}]?:?[\d{2}]?') + + def __init__(self, classes=None): + self.deserialize_type = { + 'iso-8601': Deserializer.deserialize_iso, + 'rfc-1123': Deserializer.deserialize_rfc, + 'unix-time': Deserializer.deserialize_unix, + 'duration': Deserializer.deserialize_duration, + 'date': Deserializer.deserialize_date, + 'time': Deserializer.deserialize_time, + 'decimal': Deserializer.deserialize_decimal, + 'long': Deserializer.deserialize_long, + 'bytearray': Deserializer.deserialize_bytearray, + 'base64': Deserializer.deserialize_base64, + 'object': self.deserialize_object, + '[]': self.deserialize_iter, + '{}': self.deserialize_dict + } + self.deserialize_expected_types = { + 'duration': (isodate.Duration, datetime.timedelta), + 'iso-8601': (datetime.datetime) + } + self.dependencies = 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 + # complicated, with no real scenario for now. + # So adding a flag to disable additional properties detection. This flag should be + # used if your expect the deserialization to NOT come from a JSON REST syntax. + # Otherwise, result are unexpected + self.additional_properties_detection = True + + def __call__(self, target_obj, response_data, content_type=None): + """Call the deserializer to process a REST response. + + :param str target_obj: Target data type to deserialize to. + :param requests.Response response_data: REST response object. + :param str content_type: Swagger "produces" if available. + :raises: DeserializationError if deserialization fails. + :return: Deserialized object. + """ + data = self._unpack_content(response_data, content_type) + return self._deserialize(target_obj, data) + + def _deserialize(self, target_obj, data): + """Call the deserializer on a model. + + Data needs to be already deserialized as JSON or XML ElementTree + + :param str target_obj: Target data type to deserialize to. + :param object data: Object to deserialize. + :raises: DeserializationError if deserialization fails. + :return: Deserialized object. + """ + # This is already a model, go recursive just in case + if hasattr(data, "_attribute_map"): + constants = [name for name, config in getattr(data, '_validation', {}).items() + if config.get('constant')] + try: + for attr, mapconfig in data._attribute_map.items(): + if attr in constants: + continue + value = getattr(data, attr) + if value is None: + continue + local_type = mapconfig['type'] + internal_data_type = local_type.strip('[]{}') + if internal_data_type not in self.dependencies or isinstance(internal_data_type, Enum): + continue + setattr( + data, + attr, + self._deserialize(local_type, value) + ) + return data + except AttributeError: + return + + response, class_name = self._classify_target(target_obj, data) + + if isinstance(response, basestring): + return self.deserialize_data(data, response) + elif isinstance(response, type) and issubclass(response, Enum): + return self.deserialize_enum(data, response) + + if data is None: + return data + try: + attributes = response._attribute_map + d_attrs = {} + for attr, attr_desc in attributes.items(): + # Check empty string. If it's not empty, someone has a real "additionalProperties"... + if attr == "additional_properties" and attr_desc["key"] == '': + continue + raw_value = None + # Enhance attr_desc with some dynamic data + attr_desc = attr_desc.copy() # Do a copy, do not change the real one + internal_data_type = attr_desc["type"].strip('[]{}') + if internal_data_type in self.dependencies: + attr_desc["internalType"] = self.dependencies[internal_data_type] + + for key_extractor in self.key_extractors: + found_value = key_extractor(attr, attr_desc, data) + if found_value is not None: + if raw_value is not None and raw_value != found_value: + msg = ("Ignoring extracted value '%s' from %s for key '%s'" + " (duplicate extraction, follow extractors order)" ) + _LOGGER.warning( + msg, + found_value, + key_extractor, + attr + ) + continue + raw_value = found_value + + 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 + raise_with_traceback(DeserializationError, msg, err) + else: + additional_properties = self._build_additional_properties(attributes, data) + return self._instantiate_model(response, d_attrs, additional_properties) + + def _build_additional_properties(self, attribute_map, data): + if not self.additional_properties_detection: + return None + if "additional_properties" in attribute_map and attribute_map.get("additional_properties", {}).get("key") != '': + # Check empty string. If it's not empty, someone has a real "additionalProperties" + return None + if isinstance(data, ET.Element): + data = {el.tag: el.text for el in data} + + known_keys = {_decode_attribute_map_key(_FLATTEN.split(desc['key'])[0]) + for desc in attribute_map.values() if desc['key'] != ''} + present_keys = set(data.keys()) + missing_keys = present_keys - known_keys + return {key: data[key] for key in missing_keys} + + def _classify_target(self, target, data): + """Check to see whether the deserialization target object can + be classified into a subclass. + 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. + """ + if target is None: + return None, None + + if isinstance(target, basestring): + try: + target = self.dependencies[target] + except KeyError: + return target, target + + try: + target = target._classify(data, self.dependencies) + except AttributeError: + pass # Target is not a Model, no classify + return target, target.__class__.__name__ + + def failsafe_deserialize(self, target_obj, data, content_type=None): + """Ignores any errors encountered in deserialization, + and falls back to not deserializing the object. Recommended + for use in error deserialization, as we want to return the + HttpResponseError to users, and not have them deal with + 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 content_type: Swagger "produces" if available. + """ + try: + return self(target_obj, data, content_type=content_type) + except: + _LOGGER.debug( + "Ran into a deserialization error. Ignoring since this is failsafe deserialization", + exc_info=True + ) + return None + + @staticmethod + def _unpack_content(raw_data, content_type=None): + """Extract the correct structure for deserialization. + + If raw_data is a PipelineResponse, try to extract the result of RawDeserializer. + if we can't, raise. Your Pipeline should have a RawDeserializer. + + If not a pipeline response and raw_data is bytes or string, use content-type + to decode it. If no content-type, try JSON. + + If raw_data is something else, bypass all logic and return it directly. + + :param raw_data: Data to be processed. + :param content_type: How to parse if raw_data is a string/bytes. + :raises JSONDecodeError: If JSON is requested and parsing is impossible. + :raises UnicodeDecodeError: If bytes is not UTF8 + """ + # Assume this is enough to detect a Pipeline Response without importing it + context = getattr(raw_data, "context", {}) + if context: + if RawDeserializer.CONTEXT_NAME in context: + return context[RawDeserializer.CONTEXT_NAME] + raise ValueError("This pipeline didn't have the RawDeserializer policy; can't deserialize") + + #Assume this is enough to recognize universal_http.ClientResponse without importing it + if hasattr(raw_data, "body"): + return RawDeserializer.deserialize_from_http_generics( + raw_data.text(), + raw_data.headers + ) + + # Assume this enough to recognize requests.Response without importing it. + if hasattr(raw_data, '_content_consumed'): + 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 raw_data + + def _instantiate_model(self, response, attrs, additional_properties=None): + """Instantiate a response model passing in deserialized args. + + :param response: The response model class. + :param d_attrs: The deserialized response attributes. + """ + if callable(response): + subtype = getattr(response, '_subtype_map', {}) + try: + readonly = [k for k, v in response._validation.items() + if v.get('readonly')] + const = [k for k, v in response._validation.items() + if v.get('constant')] + kwargs = {k: v for k, v in attrs.items() + if k not in subtype and k not in readonly + const} + response_obj = response(**kwargs) + for attr in readonly: + setattr(response_obj, attr, attrs.get(attr)) + if additional_properties: + response_obj.additional_properties = additional_properties + return response_obj + except TypeError as err: + msg = "Unable to deserialize {} into model {}. ".format( + kwargs, response) + raise DeserializationError(msg + str(err)) + else: + try: + for attr, value in attrs.items(): + setattr(response, attr, value) + return response + except Exception as exp: + msg = "Unable to populate response model. " + msg += "Type: {}, Error: {}".format(type(response), exp) + raise DeserializationError(msg) + + def deserialize_data(self, data, data_type): + """Process data for deserialization according to data type. + + :param str data: The response string to be deserialized. + :param str data_type: The type to deserialize to. + :raises: DeserializationError if deserialization fails. + :return: Deserialized object. + """ + if data is None: + return data + + try: + if not data_type: + return data + if data_type in self.basic_types.values(): + return self.deserialize_basic(data, data_type) + if data_type in self.deserialize_type: + if isinstance(data, self.deserialize_expected_types.get(data_type, tuple())): + return data + + is_a_text_parsing_type = lambda x: x not in ["object", "[]", r"{}"] + if isinstance(data, ET.Element) and is_a_text_parsing_type(data_type) and not data.text: + return None + data_val = self.deserialize_type[data_type](data) + return data_val + + iter_type = data_type[0] + data_type[-1] + if iter_type in self.deserialize_type: + return self.deserialize_type[iter_type](data, data_type[1:-1]) + + obj_type = self.dependencies[data_type] + if issubclass(obj_type, Enum): + if isinstance(data, ET.Element): + data = data.text + return self.deserialize_enum(data, obj_type) + + except (ValueError, TypeError, AttributeError) as err: + msg = "Unable to deserialize response data." + msg += " Data: {}, {}".format(data, data_type) + raise_with_traceback(DeserializationError, msg, err) + else: + return self._deserialize(obj_type, data) + + def deserialize_iter(self, attr, iter_type): + """Deserialize an iterable. + + :param list attr: Iterable to be deserialized. + :param str iter_type: The type of object in the iterable. + :rtype: list + """ + if attr is None: + return None + if isinstance(attr, ET.Element): # If I receive an element here, get the children + attr = list(attr) + if not isinstance(attr, (list, set)): + raise DeserializationError("Cannot deserialize as [{}] an object of type {}".format( + iter_type, + type(attr) + )) + return [self.deserialize_data(a, iter_type) for a in attr] + + def deserialize_dict(self, attr, dict_type): + """Deserialize a dictionary. + + :param dict/list attr: Dictionary to be deserialized. Also accepts + a list of key, value pairs. + :param str dict_type: The object type of the items in the dictionary. + :rtype: dict + """ + if isinstance(attr, list): + return {x['key']: self.deserialize_data(x['value'], dict_type) for x in attr} + + if isinstance(attr, ET.Element): + # Transform value into {"Key": "value"} + attr = {el.tag: el.text for el in attr} + return {k: self.deserialize_data(v, dict_type) for k, v in attr.items()} + + def deserialize_object(self, attr, **kwargs): + """Deserialize a generic object. + This will be handled as a dictionary. + + :param dict attr: Dictionary to be deserialized. + :rtype: dict + :raises: TypeError if non-builtin datatype encountered. + """ + if attr is None: + return None + if isinstance(attr, ET.Element): + # Do no recurse on XML, just return the tree as-is + return attr + if isinstance(attr, basestring): + return self.deserialize_basic(attr, 'str') + obj_type = type(attr) + if obj_type in self.basic_types: + return self.deserialize_basic(attr, self.basic_types[obj_type]) + if obj_type is _long_type: + return self.deserialize_long(attr) + + if obj_type == dict: + deserialized = {} + for key, value in attr.items(): + try: + deserialized[key] = self.deserialize_object( + value, **kwargs) + except ValueError: + deserialized[key] = None + return deserialized + + if obj_type == list: + deserialized = [] + for obj in attr: + try: + deserialized.append(self.deserialize_object( + obj, **kwargs)) + except ValueError: + pass + return deserialized + + else: + error = "Cannot deserialize generic object with type: " + raise TypeError(error + str(obj_type)) + + def deserialize_basic(self, attr, data_type): + """Deserialize basic builtin data type from string. + Will attempt to convert to str, int, float and bool. + This function will also accept '1', '0', 'true' and 'false' as + valid bool values. + + :param str attr: response string to be deserialized. + :param str data_type: deserialization data type. + :rtype: str, int, float or bool + :raises: TypeError if string format is not valid. + """ + # If we're here, data is supposed to be a basic type. + # If it's still an XML node, take the text + if isinstance(attr, ET.Element): + attr = attr.text + if not attr: + if data_type == "str": + # None or '', node is empty string. + return '' + else: + # None or '', node with a strong type is None. + # Don't try to model "empty bool" or "empty int" + return None + + if data_type == 'bool': + if attr in [True, False, 1, 0]: + return bool(attr) + elif isinstance(attr, basestring): + if attr.lower() in ['true', '1']: + return True + elif attr.lower() in ['false', '0']: + return False + raise TypeError("Invalid boolean value: {}".format(attr)) + + if data_type == 'str': + return self.deserialize_unicode(attr) + return eval(data_type)(attr) # nosec + + @staticmethod + def deserialize_unicode(data): + """Preserve unicode objects in Python 2, otherwise return data + as a string. + + :param str data: response string to be deserialized. + :rtype: str or unicode + """ + # We might be here because we have an enum modeled as string, + # and we try to deserialize a partial dict with enum inside + if isinstance(data, Enum): + return data + + # Consider this is real string + try: + if isinstance(data, unicode): + return data + except NameError: + return str(data) + else: + return str(data) + + @staticmethod + def deserialize_enum(data, enum_obj): + """Deserialize string into enum object. + + If the string is not a valid enum value it will be returned as-is + and a warning will be logged. + + :param str data: Response string to be deserialized. If this value is + None or invalid it will be returned as-is. + :param Enum enum_obj: Enum object to deserialize to. + :rtype: Enum + """ + if isinstance(data, enum_obj) or data is None: + return data + if isinstance(data, Enum): + data = data.value + if isinstance(data, int): + # Workaround. We might consider remove it in the future. + # https://github.com/Azure/azure-rest-api-specs/issues/141 + try: + return list(enum_obj.__members__.values())[data] + except IndexError: + error = "{!r} is not a valid index for enum {!r}" + raise DeserializationError(error.format(data, enum_obj)) + try: + return enum_obj(str(data)) + except ValueError: + for enum_value in enum_obj: + if enum_value.value.lower() == str(data).lower(): + return enum_value + # We don't fail anymore for unknown value, we deserialize as a string + _LOGGER.warning("Deserializer is not able to find %s as valid enum in %s", data, enum_obj) + return Deserializer.deserialize_unicode(data) + + @staticmethod + def deserialize_bytearray(attr): + """Deserialize string into bytearray. + + :param str attr: response string to be deserialized. + :rtype: bytearray + :raises: TypeError if string format invalid. + """ + if isinstance(attr, ET.Element): + attr = attr.text + return bytearray(b64decode(attr)) + + @staticmethod + def deserialize_base64(attr): + """Deserialize base64 encoded string into string. + + :param str attr: response string to be deserialized. + :rtype: bytearray + :raises: TypeError if string format invalid. + """ + if isinstance(attr, ET.Element): + attr = attr.text + padding = '=' * (3 - (len(attr) + 3) % 4) + attr = attr + padding + encoded = attr.replace('-', '+').replace('_', '/') + return b64decode(encoded) + + @staticmethod + def deserialize_decimal(attr): + """Deserialize string into Decimal object. + + :param str attr: response string to be deserialized. + :rtype: Decimal + :raises: DeserializationError if string format invalid. + """ + if isinstance(attr, ET.Element): + attr = attr.text + try: + return decimal.Decimal(attr) + except decimal.DecimalException as err: + msg = "Invalid decimal {}".format(attr) + raise_with_traceback(DeserializationError, msg, err) + + @staticmethod + def deserialize_long(attr): + """Deserialize string into long (Py2) or int (Py3). + + :param str attr: response string to be deserialized. + :rtype: long or int + :raises: ValueError if string format invalid. + """ + if isinstance(attr, ET.Element): + attr = attr.text + return _long_type(attr) + + @staticmethod + def deserialize_duration(attr): + """Deserialize ISO-8601 formatted string into TimeDelta object. + + :param str attr: response string to be deserialized. + :rtype: TimeDelta + :raises: DeserializationError if string format invalid. + """ + if isinstance(attr, ET.Element): + attr = attr.text + try: + duration = isodate.parse_duration(attr) + except(ValueError, OverflowError, AttributeError) as err: + msg = "Cannot deserialize duration object." + raise_with_traceback(DeserializationError, msg, err) + else: + return duration + + @staticmethod + def deserialize_date(attr): + """Deserialize ISO-8601 formatted string into Date object. + + :param str attr: response string to be deserialized. + :rtype: Date + :raises: DeserializationError if string format invalid. + """ + if isinstance(attr, ET.Element): + attr = attr.text + if re.search(r"[^\W\d_]", attr, re.I + re.U): + 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) + + @staticmethod + def deserialize_time(attr): + """Deserialize ISO-8601 formatted string into time object. + + :param str attr: response string to be deserialized. + :rtype: datetime.time + :raises: DeserializationError if string format invalid. + """ + if isinstance(attr, ET.Element): + attr = attr.text + if re.search(r"[^\W\d_]", attr, re.I + re.U): + raise DeserializationError("Date must have only digits and -. Received: %s" % attr) + return isodate.parse_time(attr) + + @staticmethod + def deserialize_rfc(attr): + """Deserialize RFC-1123 formatted string into Datetime object. + + :param str attr: response string to be deserialized. + :rtype: Datetime + :raises: DeserializationError if string format invalid. + """ + if isinstance(attr, ET.Element): + attr = attr.text + try: + parsed_date = email.utils.parsedate_tz(attr) + date_obj = datetime.datetime( + *parsed_date[:6], + tzinfo=_FixedOffset(datetime.timedelta(minutes=(parsed_date[9] or 0)/60)) + ) + if not date_obj.tzinfo: + date_obj = date_obj.astimezone(tz=TZ_UTC) + except ValueError as err: + msg = "Cannot deserialize to rfc datetime object." + raise_with_traceback(DeserializationError, msg, err) + else: + return date_obj + + @staticmethod + def deserialize_iso(attr): + """Deserialize ISO-8601 formatted string into Datetime object. + + :param str attr: response string to be deserialized. + :rtype: Datetime + :raises: DeserializationError if string format invalid. + """ + if isinstance(attr, ET.Element): + attr = attr.text + try: + attr = attr.upper() + match = Deserializer.valid_date.match(attr) + if not match: + raise ValueError("Invalid datetime string: " + attr) + + check_decimal = attr.split('.') + if len(check_decimal) > 1: + decimal_str = "" + for digit in check_decimal[1]: + if digit.isdigit(): + decimal_str += digit + else: + break + if len(decimal_str) > 6: + attr = attr.replace(decimal_str, decimal_str[0:6]) + + date_obj = isodate.parse_datetime(attr) + test_utc = date_obj.utctimetuple() + if test_utc.tm_year > 9999 or test_utc.tm_year < 1: + raise OverflowError("Hit max or min date") + except(ValueError, OverflowError, AttributeError) as err: + msg = "Cannot deserialize datetime object." + raise_with_traceback(DeserializationError, msg, err) + else: + return date_obj + + @staticmethod + def deserialize_unix(attr): + """Serialize Datetime object into IntTime format. + This is represented as seconds. + + :param int attr: Object to be serialized. + :rtype: Datetime + :raises: DeserializationError if format invalid + """ + if isinstance(attr, ET.Element): + attr = int(attr.text) + try: + date_obj = datetime.datetime.fromtimestamp(attr, TZ_UTC) + except ValueError as err: + msg = "Cannot deserialize to unix datetime object." + raise_with_traceback(DeserializationError, msg, err) + else: + return date_obj diff --git a/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/deploymentscripts/aio/_configuration.py b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/deploymentscripts/aio/_configuration.py index 435c43bb56045..52febcaf0037d 100644 --- a/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/deploymentscripts/aio/_configuration.py +++ b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/deploymentscripts/aio/_configuration.py @@ -26,9 +26,9 @@ class DeploymentScriptsClientConfiguration(Configuration): Note that all parameters used to create this instance are saved as instance attributes. - :param credential: Credential needed for the client to connect to Azure. + :param credential: Credential needed for the client to connect to Azure. Required. :type credential: ~azure.core.credentials_async.AsyncTokenCredential - :param subscription_id: Subscription Id which forms part of the URI for every service call. + :param subscription_id: Subscription Id which forms part of the URI for every service call. Required. :type subscription_id: str """ diff --git a/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/deploymentscripts/aio/_deployment_scripts_client.py b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/deploymentscripts/aio/_deployment_scripts_client.py index 3b6e4cbf14fe5..81b4430afd667 100644 --- a/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/deploymentscripts/aio/_deployment_scripts_client.py +++ b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/deploymentscripts/aio/_deployment_scripts_client.py @@ -11,17 +11,15 @@ from typing import Any, Optional, TYPE_CHECKING -from msrest import Deserializer, Serializer - from azure.mgmt.core import AsyncARMPipelineClient from azure.profiles import KnownProfiles, ProfileDefinition from azure.profiles.multiapiclient import MultiApiClientMixin +from .._serialization import Deserializer, Serializer from ._configuration import DeploymentScriptsClientConfiguration if TYPE_CHECKING: # pylint: disable=unused-import,ungrouped-imports - from azure.core.credentials import TokenCredential from azure.core.credentials_async import AsyncTokenCredential class _SDKClient(object): @@ -42,9 +40,9 @@ class DeploymentScriptsClient(MultiApiClientMixin, _SDKClient): The api-version parameter sets the default API version if the operation group is not described in the profile. - :param credential: Credential needed for the client to connect to Azure. + :param credential: Credential needed for the client to connect to Azure. Required. :type credential: ~azure.core.credentials_async.AsyncTokenCredential - :param subscription_id: Subscription Id which forms part of the URI for every service call. + :param subscription_id: Subscription Id which forms part of the URI for every service call. Required. :type subscription_id: str :param api_version: API version to use if no profile is provided, or if missing in profile. :type api_version: str diff --git a/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/deploymentscripts/v2019_10_01_preview/__init__.py b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/deploymentscripts/v2019_10_01_preview/__init__.py index d4d4c09823149..6fbd53dc300b6 100644 --- a/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/deploymentscripts/v2019_10_01_preview/__init__.py +++ b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/deploymentscripts/v2019_10_01_preview/__init__.py @@ -10,9 +10,15 @@ from ._version import VERSION __version__ = VERSION -__all__ = ['DeploymentScriptsClient'] -# `._patch.py` is used for handwritten extensions to the generated code -# Example: https://github.com/Azure/azure-sdk-for-python/blob/main/doc/dev/customize_code/how-to-patch-sdk-code.md -from ._patch import patch_sdk -patch_sdk() +try: + from ._patch import __all__ as _patch_all + from ._patch import * # type: ignore # pylint: disable=unused-wildcard-import +except ImportError: + _patch_all = [] +from ._patch import patch_sdk as _patch_sdk + +__all__ = ["DeploymentScriptsClient"] +__all__.extend([p for p in _patch_all if p not in __all__]) + +_patch_sdk() diff --git a/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/deploymentscripts/v2019_10_01_preview/_configuration.py b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/deploymentscripts/v2019_10_01_preview/_configuration.py index 947e08b9031ed..6a2c203d57fa8 100644 --- a/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/deploymentscripts/v2019_10_01_preview/_configuration.py +++ b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/deploymentscripts/v2019_10_01_preview/_configuration.py @@ -25,23 +25,19 @@ class DeploymentScriptsClientConfiguration(Configuration): # pylint: disable=to Note that all parameters used to create this instance are saved as instance attributes. - :param credential: Credential needed for the client to connect to Azure. + :param credential: Credential needed for the client to connect to Azure. Required. :type credential: ~azure.core.credentials.TokenCredential :param subscription_id: Subscription Id which forms part of the URI for every service call. + Required. :type subscription_id: str :keyword api_version: Api Version. Default value is "2019-10-01-preview". Note that overriding this default value may result in unsupported behavior. :paramtype api_version: str """ - def __init__( - self, - credential: "TokenCredential", - subscription_id: str, - **kwargs: Any - ) -> None: + def __init__(self, credential: "TokenCredential", subscription_id: str, **kwargs: Any) -> None: super(DeploymentScriptsClientConfiguration, self).__init__(**kwargs) - api_version = kwargs.pop('api_version', "2019-10-01-preview") # type: str + api_version = kwargs.pop("api_version", "2019-10-01-preview") # type: str if credential is None: raise ValueError("Parameter 'credential' must not be None.") @@ -51,23 +47,24 @@ def __init__( self.credential = credential self.subscription_id = subscription_id self.api_version = api_version - self.credential_scopes = kwargs.pop('credential_scopes', ['https://management.azure.com/.default']) - kwargs.setdefault('sdk_moniker', 'mgmt-resource/{}'.format(VERSION)) + self.credential_scopes = kwargs.pop("credential_scopes", ["https://management.azure.com/.default"]) + kwargs.setdefault("sdk_moniker", "mgmt-resource/{}".format(VERSION)) self._configure(**kwargs) def _configure( - self, - **kwargs # type: Any + self, **kwargs # type: Any ): # type: (...) -> 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) - self.logging_policy = kwargs.get('logging_policy') or policies.NetworkTraceLoggingPolicy(**kwargs) - self.http_logging_policy = kwargs.get('http_logging_policy') or ARMHttpLoggingPolicy(**kwargs) - self.retry_policy = kwargs.get('retry_policy') or policies.RetryPolicy(**kwargs) - self.custom_hook_policy = kwargs.get('custom_hook_policy') or policies.CustomHookPolicy(**kwargs) - self.redirect_policy = kwargs.get('redirect_policy') or policies.RedirectPolicy(**kwargs) - self.authentication_policy = kwargs.get('authentication_policy') + 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) + self.logging_policy = kwargs.get("logging_policy") or policies.NetworkTraceLoggingPolicy(**kwargs) + self.http_logging_policy = kwargs.get("http_logging_policy") or ARMHttpLoggingPolicy(**kwargs) + self.retry_policy = kwargs.get("retry_policy") or policies.RetryPolicy(**kwargs) + self.custom_hook_policy = kwargs.get("custom_hook_policy") or policies.CustomHookPolicy(**kwargs) + self.redirect_policy = kwargs.get("redirect_policy") or policies.RedirectPolicy(**kwargs) + self.authentication_policy = kwargs.get("authentication_policy") if self.credential and not self.authentication_policy: - self.authentication_policy = ARMChallengeAuthenticationPolicy(self.credential, *self.credential_scopes, **kwargs) + self.authentication_policy = ARMChallengeAuthenticationPolicy( + self.credential, *self.credential_scopes, **kwargs + ) diff --git a/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/deploymentscripts/v2019_10_01_preview/_deployment_scripts_client.py b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/deploymentscripts/v2019_10_01_preview/_deployment_scripts_client.py index 1ea87d554ce4b..6feb0f1ff6d32 100644 --- a/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/deploymentscripts/v2019_10_01_preview/_deployment_scripts_client.py +++ b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/deploymentscripts/v2019_10_01_preview/_deployment_scripts_client.py @@ -9,12 +9,11 @@ from copy import deepcopy from typing import Any, TYPE_CHECKING -from msrest import Deserializer, Serializer - from azure.core.rest import HttpRequest, HttpResponse from azure.mgmt.core import ARMPipelineClient from . import models +from .._serialization import Deserializer, Serializer from ._configuration import DeploymentScriptsClientConfiguration from .operations import DeploymentScriptsOperations @@ -22,16 +21,18 @@ # pylint: disable=unused-import,ungrouped-imports from azure.core.credentials import TokenCredential -class DeploymentScriptsClient: + +class DeploymentScriptsClient: # pylint: disable=client-accepts-api-version-keyword """The APIs listed in this specification can be used to manage Deployment Scripts resource through the Azure Resource Manager. :ivar deployment_scripts: DeploymentScriptsOperations operations :vartype deployment_scripts: azure.mgmt.resource.deploymentscripts.v2019_10_01_preview.operations.DeploymentScriptsOperations - :param credential: Credential needed for the client to connect to Azure. + :param credential: Credential needed for the client to connect to Azure. Required. :type credential: ~azure.core.credentials.TokenCredential :param subscription_id: Subscription Id which forms part of the URI for every service call. + Required. :type subscription_id: str :param base_url: Service URL. Default value is "https://management.azure.com". :type base_url: str @@ -49,21 +50,20 @@ def __init__( base_url: str = "https://management.azure.com", **kwargs: Any ) -> None: - self._config = DeploymentScriptsClientConfiguration(credential=credential, subscription_id=subscription_id, **kwargs) + self._config = DeploymentScriptsClientConfiguration( + credential=credential, subscription_id=subscription_id, **kwargs + ) self._client = ARMPipelineClient(base_url=base_url, config=self._config, **kwargs) client_models = {k: v for k, v in models.__dict__.items() if isinstance(v, type)} self._serialize = Serializer(client_models) self._deserialize = Deserializer(client_models) self._serialize.client_side_validation = False - self.deployment_scripts = DeploymentScriptsOperations(self._client, self._config, self._serialize, self._deserialize) - + self.deployment_scripts = DeploymentScriptsOperations( + self._client, self._config, self._serialize, self._deserialize + ) - def _send_request( - self, - request: HttpRequest, - **kwargs: Any - ) -> HttpResponse: + def _send_request(self, request: HttpRequest, **kwargs: Any) -> HttpResponse: """Runs the network request through the client's chained policies. >>> from azure.core.rest import HttpRequest @@ -72,7 +72,7 @@ def _send_request( >>> response = client._send_request(request) - For more information on this code flow, see https://aka.ms/azsdk/python/protocol/quickstart + For more information on this code flow, see https://aka.ms/azsdk/dpcodegen/python/send_request :param request: The network request you want to make. Required. :type request: ~azure.core.rest.HttpRequest diff --git a/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/deploymentscripts/v2019_10_01_preview/_metadata.json b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/deploymentscripts/v2019_10_01_preview/_metadata.json index 1074263e89350..1fcab04e363e6 100644 --- a/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/deploymentscripts/v2019_10_01_preview/_metadata.json +++ b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/deploymentscripts/v2019_10_01_preview/_metadata.json @@ -10,20 +10,20 @@ "azure_arm": true, "has_lro_operations": true, "client_side_validation": false, - "sync_imports": "{\"typing\": {\"azurecore\": {\"azure.core.credentials\": [\"TokenCredential\"]}}, \"regular\": {\"azurecore\": {\"azure.profiles\": [\"KnownProfiles\", \"ProfileDefinition\"], \"azure.profiles.multiapiclient\": [\"MultiApiClientMixin\"], \"azure.mgmt.core\": [\"ARMPipelineClient\"]}, \"local\": {\"._configuration\": [\"DeploymentScriptsClientConfiguration\"]}, \"thirdparty\": {\"msrest\": [\"Deserializer\", \"Serializer\"]}}, \"conditional\": {\"stdlib\": {\"typing\": [\"Any\", \"Optional\"]}}}", - "async_imports": "{\"typing\": {\"azurecore\": {\"azure.core.credentials_async\": [\"AsyncTokenCredential\"], \"azure.core.credentials\": [\"TokenCredential\"]}}, \"regular\": {\"azurecore\": {\"azure.profiles\": [\"KnownProfiles\", \"ProfileDefinition\"], \"azure.profiles.multiapiclient\": [\"MultiApiClientMixin\"], \"azure.mgmt.core\": [\"AsyncARMPipelineClient\"]}, \"local\": {\"._configuration\": [\"DeploymentScriptsClientConfiguration\"]}, \"thirdparty\": {\"msrest\": [\"Deserializer\", \"Serializer\"]}}, \"conditional\": {\"stdlib\": {\"typing\": [\"Any\", \"Optional\"]}}}" + "sync_imports": "{\"conditional\": {\"stdlib\": {\"typing\": [\"Any\", \"Optional\"]}}, \"regular\": {\"azurecore\": {\"azure.mgmt.core\": [\"ARMPipelineClient\"], \"azure.profiles\": [\"KnownProfiles\", \"ProfileDefinition\"], \"azure.profiles.multiapiclient\": [\"MultiApiClientMixin\"]}, \"local\": {\"._configuration\": [\"DeploymentScriptsClientConfiguration\"], \".._serialization\": [\"Deserializer\", \"Serializer\"]}}, \"typing\": {\"azurecore\": {\"azure.core.credentials\": [\"TokenCredential\"]}}}", + "async_imports": "{\"conditional\": {\"stdlib\": {\"typing\": [\"Any\", \"Optional\"]}}, \"regular\": {\"azurecore\": {\"azure.mgmt.core\": [\"AsyncARMPipelineClient\"], \"azure.profiles\": [\"KnownProfiles\", \"ProfileDefinition\"], \"azure.profiles.multiapiclient\": [\"MultiApiClientMixin\"]}, \"local\": {\"._configuration\": [\"DeploymentScriptsClientConfiguration\"], \"..._serialization\": [\"Deserializer\", \"Serializer\"]}}, \"typing\": {\"azurecore\": {\"azure.core.credentials_async\": [\"AsyncTokenCredential\"]}}}" }, "global_parameters": { "sync": { "credential": { - "signature": "credential, # type: \"TokenCredential\"", - "description": "Credential needed for the client to connect to Azure.", + "signature": "credential: \"TokenCredential\",", + "description": "Credential needed for the client to connect to Azure. Required.", "docstring_type": "~azure.core.credentials.TokenCredential", "required": true }, "subscription_id": { - "signature": "subscription_id, # type: str", - "description": "Subscription Id which forms part of the URI for every service call.", + "signature": "subscription_id: str,", + "description": "Subscription Id which forms part of the URI for every service call. Required.", "docstring_type": "str", "required": true } @@ -31,13 +31,13 @@ "async": { "credential": { "signature": "credential: \"AsyncTokenCredential\",", - "description": "Credential needed for the client to connect to Azure.", + "description": "Credential needed for the client to connect to Azure. Required.", "docstring_type": "~azure.core.credentials_async.AsyncTokenCredential", "required": true }, "subscription_id": { "signature": "subscription_id: str,", - "description": "Subscription Id which forms part of the URI for every service call.", + "description": "Subscription Id which forms part of the URI for every service call. Required.", "docstring_type": "str", "required": true } @@ -54,7 +54,7 @@ "required": false }, "base_url": { - "signature": "base_url=\"https://management.azure.com\", # type: str", + "signature": "base_url: str = \"https://management.azure.com\",", "description": "Service URL", "docstring_type": "str", "required": false diff --git a/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/deploymentscripts/v2019_10_01_preview/_patch.py b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/deploymentscripts/v2019_10_01_preview/_patch.py index 74e48ecd07cf3..f99e77fef9861 100644 --- a/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/deploymentscripts/v2019_10_01_preview/_patch.py +++ b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/deploymentscripts/v2019_10_01_preview/_patch.py @@ -28,4 +28,4 @@ # This file is used for handwritten extensions to the generated code. Example: # https://github.com/Azure/azure-sdk-for-python/blob/main/doc/dev/customize_code/how-to-patch-sdk-code.md def patch_sdk(): - pass \ No newline at end of file + pass diff --git a/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/deploymentscripts/v2019_10_01_preview/_vendor.py b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/deploymentscripts/v2019_10_01_preview/_vendor.py index 138f663c53a4e..9aad73fc743e7 100644 --- a/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/deploymentscripts/v2019_10_01_preview/_vendor.py +++ b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/deploymentscripts/v2019_10_01_preview/_vendor.py @@ -7,6 +7,7 @@ from azure.core.pipeline.transport import HttpRequest + def _convert_request(request, files=None): data = request.content if not files else None request = HttpRequest(method=request.method, url=request.url, headers=request.headers, data=data) @@ -14,6 +15,7 @@ def _convert_request(request, files=None): request.set_formdata_body(files) return request + def _format_url_section(template, **kwargs): components = template.split("/") while components: @@ -21,7 +23,5 @@ def _format_url_section(template, **kwargs): 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 - ] + components = [c for c in formatted_components if "{}".format(key.args[0]) not in c] template = "/".join(components) diff --git a/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/deploymentscripts/v2019_10_01_preview/_version.py b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/deploymentscripts/v2019_10_01_preview/_version.py index a012ac01c480c..e5754a47ce68f 100644 --- a/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/deploymentscripts/v2019_10_01_preview/_version.py +++ b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/deploymentscripts/v2019_10_01_preview/_version.py @@ -6,4 +6,4 @@ # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -VERSION = "21.1.0" +VERSION = "1.0.0b1" diff --git a/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/deploymentscripts/v2019_10_01_preview/aio/__init__.py b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/deploymentscripts/v2019_10_01_preview/aio/__init__.py index 815170897d35d..101e9dc5372bd 100644 --- a/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/deploymentscripts/v2019_10_01_preview/aio/__init__.py +++ b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/deploymentscripts/v2019_10_01_preview/aio/__init__.py @@ -7,9 +7,15 @@ # -------------------------------------------------------------------------- from ._deployment_scripts_client import DeploymentScriptsClient -__all__ = ['DeploymentScriptsClient'] -# `._patch.py` is used for handwritten extensions to the generated code -# Example: https://github.com/Azure/azure-sdk-for-python/blob/main/doc/dev/customize_code/how-to-patch-sdk-code.md -from ._patch import patch_sdk -patch_sdk() +try: + from ._patch import __all__ as _patch_all + from ._patch import * # type: ignore # pylint: disable=unused-wildcard-import +except ImportError: + _patch_all = [] +from ._patch import patch_sdk as _patch_sdk + +__all__ = ["DeploymentScriptsClient"] +__all__.extend([p for p in _patch_all if p not in __all__]) + +_patch_sdk() diff --git a/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/deploymentscripts/v2019_10_01_preview/aio/_configuration.py b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/deploymentscripts/v2019_10_01_preview/aio/_configuration.py index f70ddadd8c534..3844dc325b983 100644 --- a/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/deploymentscripts/v2019_10_01_preview/aio/_configuration.py +++ b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/deploymentscripts/v2019_10_01_preview/aio/_configuration.py @@ -25,23 +25,19 @@ class DeploymentScriptsClientConfiguration(Configuration): # pylint: disable=to Note that all parameters used to create this instance are saved as instance attributes. - :param credential: Credential needed for the client to connect to Azure. + :param credential: Credential needed for the client to connect to Azure. Required. :type credential: ~azure.core.credentials_async.AsyncTokenCredential :param subscription_id: Subscription Id which forms part of the URI for every service call. + Required. :type subscription_id: str :keyword api_version: Api Version. Default value is "2019-10-01-preview". Note that overriding this default value may result in unsupported behavior. :paramtype api_version: str """ - def __init__( - self, - credential: "AsyncTokenCredential", - subscription_id: str, - **kwargs: Any - ) -> None: + def __init__(self, credential: "AsyncTokenCredential", subscription_id: str, **kwargs: Any) -> None: super(DeploymentScriptsClientConfiguration, self).__init__(**kwargs) - api_version = kwargs.pop('api_version', "2019-10-01-preview") # type: str + api_version = kwargs.pop("api_version", "2019-10-01-preview") # type: str if credential is None: raise ValueError("Parameter 'credential' must not be None.") @@ -51,22 +47,21 @@ def __init__( self.credential = credential self.subscription_id = subscription_id self.api_version = api_version - self.credential_scopes = kwargs.pop('credential_scopes', ['https://management.azure.com/.default']) - kwargs.setdefault('sdk_moniker', 'mgmt-resource/{}'.format(VERSION)) + self.credential_scopes = kwargs.pop("credential_scopes", ["https://management.azure.com/.default"]) + kwargs.setdefault("sdk_moniker", "mgmt-resource/{}".format(VERSION)) self._configure(**kwargs) - 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) - self.logging_policy = kwargs.get('logging_policy') or policies.NetworkTraceLoggingPolicy(**kwargs) - self.http_logging_policy = kwargs.get('http_logging_policy') or ARMHttpLoggingPolicy(**kwargs) - self.retry_policy = kwargs.get('retry_policy') or policies.AsyncRetryPolicy(**kwargs) - self.custom_hook_policy = kwargs.get('custom_hook_policy') or policies.CustomHookPolicy(**kwargs) - self.redirect_policy = kwargs.get('redirect_policy') or policies.AsyncRedirectPolicy(**kwargs) - self.authentication_policy = kwargs.get('authentication_policy') + 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) + self.logging_policy = kwargs.get("logging_policy") or policies.NetworkTraceLoggingPolicy(**kwargs) + self.http_logging_policy = kwargs.get("http_logging_policy") or ARMHttpLoggingPolicy(**kwargs) + self.retry_policy = kwargs.get("retry_policy") or policies.AsyncRetryPolicy(**kwargs) + self.custom_hook_policy = kwargs.get("custom_hook_policy") or policies.CustomHookPolicy(**kwargs) + self.redirect_policy = kwargs.get("redirect_policy") or policies.AsyncRedirectPolicy(**kwargs) + self.authentication_policy = kwargs.get("authentication_policy") if self.credential and not self.authentication_policy: - self.authentication_policy = AsyncARMChallengeAuthenticationPolicy(self.credential, *self.credential_scopes, **kwargs) + self.authentication_policy = AsyncARMChallengeAuthenticationPolicy( + self.credential, *self.credential_scopes, **kwargs + ) diff --git a/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/deploymentscripts/v2019_10_01_preview/aio/_deployment_scripts_client.py b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/deploymentscripts/v2019_10_01_preview/aio/_deployment_scripts_client.py index fa397e2724eb9..2a7f25f7438f7 100644 --- a/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/deploymentscripts/v2019_10_01_preview/aio/_deployment_scripts_client.py +++ b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/deploymentscripts/v2019_10_01_preview/aio/_deployment_scripts_client.py @@ -9,12 +9,11 @@ from copy import deepcopy from typing import Any, Awaitable, TYPE_CHECKING -from msrest import Deserializer, Serializer - from azure.core.rest import AsyncHttpResponse, HttpRequest from azure.mgmt.core import AsyncARMPipelineClient from .. import models +from ..._serialization import Deserializer, Serializer from ._configuration import DeploymentScriptsClientConfiguration from .operations import DeploymentScriptsOperations @@ -22,16 +21,18 @@ # pylint: disable=unused-import,ungrouped-imports from azure.core.credentials_async import AsyncTokenCredential -class DeploymentScriptsClient: + +class DeploymentScriptsClient: # pylint: disable=client-accepts-api-version-keyword """The APIs listed in this specification can be used to manage Deployment Scripts resource through the Azure Resource Manager. :ivar deployment_scripts: DeploymentScriptsOperations operations :vartype deployment_scripts: azure.mgmt.resource.deploymentscripts.v2019_10_01_preview.aio.operations.DeploymentScriptsOperations - :param credential: Credential needed for the client to connect to Azure. + :param credential: Credential needed for the client to connect to Azure. Required. :type credential: ~azure.core.credentials_async.AsyncTokenCredential :param subscription_id: Subscription Id which forms part of the URI for every service call. + Required. :type subscription_id: str :param base_url: Service URL. Default value is "https://management.azure.com". :type base_url: str @@ -49,21 +50,20 @@ def __init__( base_url: str = "https://management.azure.com", **kwargs: Any ) -> None: - self._config = DeploymentScriptsClientConfiguration(credential=credential, subscription_id=subscription_id, **kwargs) + self._config = DeploymentScriptsClientConfiguration( + credential=credential, subscription_id=subscription_id, **kwargs + ) self._client = AsyncARMPipelineClient(base_url=base_url, config=self._config, **kwargs) client_models = {k: v for k, v in models.__dict__.items() if isinstance(v, type)} self._serialize = Serializer(client_models) self._deserialize = Deserializer(client_models) self._serialize.client_side_validation = False - self.deployment_scripts = DeploymentScriptsOperations(self._client, self._config, self._serialize, self._deserialize) - + self.deployment_scripts = DeploymentScriptsOperations( + self._client, self._config, self._serialize, self._deserialize + ) - def _send_request( - self, - request: HttpRequest, - **kwargs: Any - ) -> Awaitable[AsyncHttpResponse]: + def _send_request(self, request: HttpRequest, **kwargs: Any) -> Awaitable[AsyncHttpResponse]: """Runs the network request through the client's chained policies. >>> from azure.core.rest import HttpRequest @@ -72,7 +72,7 @@ def _send_request( >>> response = await client._send_request(request) - For more information on this code flow, see https://aka.ms/azsdk/python/protocol/quickstart + For more information on this code flow, see https://aka.ms/azsdk/dpcodegen/python/send_request :param request: The network request you want to make. Required. :type request: ~azure.core.rest.HttpRequest diff --git a/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/deploymentscripts/v2019_10_01_preview/aio/_patch.py b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/deploymentscripts/v2019_10_01_preview/aio/_patch.py index 74e48ecd07cf3..f99e77fef9861 100644 --- a/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/deploymentscripts/v2019_10_01_preview/aio/_patch.py +++ b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/deploymentscripts/v2019_10_01_preview/aio/_patch.py @@ -28,4 +28,4 @@ # This file is used for handwritten extensions to the generated code. Example: # https://github.com/Azure/azure-sdk-for-python/blob/main/doc/dev/customize_code/how-to-patch-sdk-code.md def patch_sdk(): - pass \ No newline at end of file + pass diff --git a/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/deploymentscripts/v2019_10_01_preview/aio/operations/__init__.py b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/deploymentscripts/v2019_10_01_preview/aio/operations/__init__.py index 2a9499c638ccc..15dd692e91d23 100644 --- a/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/deploymentscripts/v2019_10_01_preview/aio/operations/__init__.py +++ b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/deploymentscripts/v2019_10_01_preview/aio/operations/__init__.py @@ -8,6 +8,12 @@ from ._operations import DeploymentScriptsOperations +from ._patch import __all__ as _patch_all +from ._patch import * # type: ignore # pylint: disable=unused-wildcard-import +from ._patch import patch_sdk as _patch_sdk + __all__ = [ - 'DeploymentScriptsOperations', + "DeploymentScriptsOperations", ] +__all__.extend([p for p in _patch_all if p not in __all__]) +_patch_sdk() diff --git a/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/deploymentscripts/v2019_10_01_preview/aio/operations/_operations.py b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/deploymentscripts/v2019_10_01_preview/aio/operations/_operations.py index 882e67be37152..7c50f53d6d673 100644 --- a/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/deploymentscripts/v2019_10_01_preview/aio/operations/_operations.py +++ b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/deploymentscripts/v2019_10_01_preview/aio/operations/_operations.py @@ -6,119 +6,230 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -from typing import Any, AsyncIterable, Callable, Dict, Optional, TypeVar, Union +from typing import Any, AsyncIterable, Callable, Dict, IO, Optional, TypeVar, Union, cast, overload +from urllib.parse import parse_qs, urljoin, urlparse from azure.core.async_paging import AsyncItemPaged, AsyncList -from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error +from azure.core.exceptions import ( + ClientAuthenticationError, + HttpResponseError, + ResourceExistsError, + ResourceNotFoundError, + ResourceNotModifiedError, + map_error, +) from azure.core.pipeline import PipelineResponse from azure.core.pipeline.transport import AsyncHttpResponse from azure.core.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 from azure.mgmt.core.polling.async_arm_polling import AsyncARMPolling from ... import models as _models from ..._vendor import _convert_request -from ...operations._operations import build_deployment_scripts_create_request_initial, build_deployment_scripts_delete_request, build_deployment_scripts_get_logs_default_request, build_deployment_scripts_get_logs_request, build_deployment_scripts_get_request, build_deployment_scripts_list_by_resource_group_request, build_deployment_scripts_list_by_subscription_request, build_deployment_scripts_update_request -T = TypeVar('T') +from ...operations._operations import ( + build_deployment_scripts_create_request, + build_deployment_scripts_delete_request, + build_deployment_scripts_get_logs_default_request, + build_deployment_scripts_get_logs_request, + build_deployment_scripts_get_request, + build_deployment_scripts_list_by_resource_group_request, + build_deployment_scripts_list_by_subscription_request, + build_deployment_scripts_update_request, +) + +T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] -class DeploymentScriptsOperations: - """DeploymentScriptsOperations async operations. - You should not instantiate this class directly. Instead, you should create a Client instance that - instantiates it for you and attaches it as an attribute. +class DeploymentScriptsOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. - :ivar models: Alias to model classes used in this operation group. - :type models: ~azure.mgmt.resource.deploymentscripts.v2019_10_01_preview.models - :param client: Client for service requests. - :param config: Configuration of service client. - :param serializer: An object model serializer. - :param deserializer: An object model deserializer. + Instead, you should access the following operations through + :class:`~azure.mgmt.resource.deploymentscripts.v2019_10_01_preview.aio.DeploymentScriptsClient`'s + :attr:`deployment_scripts` attribute. """ models = _models - def __init__(self, client, config, serializer, deserializer) -> None: - self._client = client - self._serialize = serializer - self._deserialize = deserializer - self._config = config + def __init__(self, *args, **kwargs) -> None: + input_args = list(args) + self._client = input_args.pop(0) if input_args else kwargs.pop("client") + self._config = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") async def _create_initial( self, resource_group_name: str, script_name: str, - deployment_script: "_models.DeploymentScript", + deployment_script: Union[_models.DeploymentScript, IO], **kwargs: Any - ) -> "_models.DeploymentScript": - cls = kwargs.pop('cls', None) # type: ClsType["_models.DeploymentScript"] + ) -> _models.DeploymentScript: error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) - api_version = kwargs.pop('api_version', "2019-10-01-preview") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - _json = self._serialize.body(deployment_script, 'DeploymentScript') + api_version = kwargs.pop("api_version", _params.pop("api-version", "2019-10-01-preview")) # type: str + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.DeploymentScript] - request = build_deployment_scripts_create_request_initial( - subscription_id=self._config.subscription_id, + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(deployment_script, (IO, bytes)): + _content = deployment_script + else: + _json = self._serialize.body(deployment_script, "DeploymentScript") + + request = build_deployment_scripts_create_request( resource_group_name=resource_group_name, script_name=script_name, + subscription_id=self._config.subscription_id, api_version=api_version, content_type=content_type, json=_json, - template_url=self._create_initial.metadata['url'], + content=_content, + template_url=self._create_initial.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200, 201]: map_error(status_code=response.status_code, response=response, error_map=error_map) - raise HttpResponseError(response=response, error_format=ARMErrorFormat) + error = self._deserialize.failsafe_deserialize(_models.DeploymentScriptsError, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) if response.status_code == 200: - deserialized = self._deserialize('DeploymentScript', pipeline_response) + deserialized = self._deserialize("DeploymentScript", pipeline_response) if response.status_code == 201: - deserialized = self._deserialize('DeploymentScript', pipeline_response) + deserialized = self._deserialize("DeploymentScript", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - _create_initial.metadata = {'url': "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/Microsoft.Resources/deploymentScripts/{scriptName}"} # type: ignore + _create_initial.metadata = {"url": "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/Microsoft.Resources/deploymentScripts/{scriptName}"} # type: ignore + + @overload + async def begin_create( + self, + resource_group_name: str, + script_name: str, + deployment_script: _models.DeploymentScript, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> AsyncLROPoller[_models.DeploymentScript]: + """Creates a deployment script. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param script_name: Name of the deployment script. Required. + :type script_name: str + :param deployment_script: Deployment script supplied to the operation. Required. + :type deployment_script: + ~azure.mgmt.resource.deploymentscripts.v2019_10_01_preview.models.DeploymentScript + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be AsyncARMPolling. Pass in False for + this operation to not poll, or pass in your own initialized polling object for a personal + polling strategy. + :paramtype polling: bool or ~azure.core.polling.AsyncPollingMethod + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of AsyncLROPoller that returns either DeploymentScript or the result of + cls(response) + :rtype: + ~azure.core.polling.AsyncLROPoller[~azure.mgmt.resource.deploymentscripts.v2019_10_01_preview.models.DeploymentScript] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + async def begin_create( + self, + resource_group_name: str, + script_name: str, + deployment_script: IO, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> AsyncLROPoller[_models.DeploymentScript]: + """Creates a deployment script. + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param script_name: Name of the deployment script. Required. + :type script_name: str + :param deployment_script: Deployment script supplied to the operation. Required. + :type deployment_script: IO + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be AsyncARMPolling. Pass in False for + this operation to not poll, or pass in your own initialized polling object for a personal + polling strategy. + :paramtype polling: bool or ~azure.core.polling.AsyncPollingMethod + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of AsyncLROPoller that returns either DeploymentScript or the result of + cls(response) + :rtype: + ~azure.core.polling.AsyncLROPoller[~azure.mgmt.resource.deploymentscripts.v2019_10_01_preview.models.DeploymentScript] + :raises ~azure.core.exceptions.HttpResponseError: + """ @distributed_trace_async async def begin_create( self, resource_group_name: str, script_name: str, - deployment_script: "_models.DeploymentScript", + deployment_script: Union[_models.DeploymentScript, IO], **kwargs: Any - ) -> AsyncLROPoller["_models.DeploymentScript"]: + ) -> AsyncLROPoller[_models.DeploymentScript]: """Creates a deployment script. :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. :type resource_group_name: str - :param script_name: Name of the deployment script. + :param script_name: Name of the deployment script. Required. :type script_name: str - :param deployment_script: Deployment script supplied to the operation. + :param deployment_script: Deployment script supplied to the operation. Is either a model type + or a IO type. Required. :type deployment_script: - ~azure.mgmt.resource.deploymentscripts.v2019_10_01_preview.models.DeploymentScript + ~azure.mgmt.resource.deploymentscripts.v2019_10_01_preview.models.DeploymentScript or IO + :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. + Default value is None. + :paramtype content_type: str :keyword callable cls: A custom type or function that will be passed the direct response :keyword str continuation_token: A continuation token to restart a poller from a saved state. :keyword polling: By default, your polling method will be AsyncARMPolling. Pass in False for @@ -131,105 +242,186 @@ async def begin_create( cls(response) :rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.resource.deploymentscripts.v2019_10_01_preview.models.DeploymentScript] - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - api_version = kwargs.pop('api_version', "2019-10-01-preview") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] - polling = kwargs.pop('polling', True) # type: Union[bool, AsyncPollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType["_models.DeploymentScript"] - lro_delay = kwargs.pop( - 'polling_interval', - self._config.polling_interval - ) - cont_token = kwargs.pop('continuation_token', None) # type: Optional[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", "2019-10-01-preview")) # type: str + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.DeploymentScript] + polling = kwargs.pop("polling", True) # type: Union[bool, AsyncPollingMethod] + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token = kwargs.pop("continuation_token", None) # type: Optional[str] if cont_token is None: - raw_result = await self._create_initial( + raw_result = await self._create_initial( # type: ignore resource_group_name=resource_group_name, script_name=script_name, deployment_script=deployment_script, api_version=api_version, content_type=content_type, - cls=lambda x,y,z: x, + cls=lambda x, y, z: x, + headers=_headers, + params=_params, **kwargs ) - kwargs.pop('error_map', None) + kwargs.pop("error_map", None) def get_long_running_output(pipeline_response): - response = pipeline_response.http_response - deserialized = self._deserialize('DeploymentScript', pipeline_response) + deserialized = self._deserialize("DeploymentScript", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - - if polling is True: polling_method = AsyncARMPolling(lro_delay, **kwargs) - elif polling is False: polling_method = AsyncNoPolling() - else: polling_method = polling + if polling is True: + polling_method = cast(AsyncPollingMethod, AsyncARMPolling(lro_delay, **kwargs)) # type: AsyncPollingMethod + elif polling is False: + polling_method = cast(AsyncPollingMethod, AsyncNoPolling()) + else: + polling_method = polling if cont_token: return AsyncLROPoller.from_continuation_token( polling_method=polling_method, continuation_token=cont_token, client=self._client, - deserialization_callback=get_long_running_output + deserialization_callback=get_long_running_output, ) return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) - begin_create.metadata = {'url': "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/Microsoft.Resources/deploymentScripts/{scriptName}"} # type: ignore + begin_create.metadata = {"url": "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/Microsoft.Resources/deploymentScripts/{scriptName}"} # type: ignore - @distributed_trace_async + @overload async def update( self, resource_group_name: str, script_name: str, - deployment_script: Optional["_models.DeploymentScriptUpdateParameter"] = None, + deployment_script: Optional[_models.DeploymentScriptUpdateParameter] = None, + *, + content_type: str = "application/json", **kwargs: Any - ) -> "_models.DeploymentScript": + ) -> _models.DeploymentScript: """Updates deployment script tags with specified values. :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. :type resource_group_name: str - :param script_name: Name of the deployment script. + :param script_name: Name of the deployment script. Required. :type script_name: str :param deployment_script: Deployment script resource with the tags to be updated. Default value is None. :type deployment_script: ~azure.mgmt.resource.deploymentscripts.v2019_10_01_preview.models.DeploymentScriptUpdateParameter + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: DeploymentScript or the result of cls(response) + :rtype: ~azure.mgmt.resource.deploymentscripts.v2019_10_01_preview.models.DeploymentScript + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + async def update( + self, + resource_group_name: str, + script_name: str, + deployment_script: Optional[IO] = None, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.DeploymentScript: + """Updates deployment script tags with specified values. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param script_name: Name of the deployment script. Required. + :type script_name: str + :param deployment_script: Deployment script resource with the tags to be updated. Default value + is None. + :type deployment_script: IO + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: DeploymentScript or the result of cls(response) + :rtype: ~azure.mgmt.resource.deploymentscripts.v2019_10_01_preview.models.DeploymentScript + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace_async + async def update( + self, + resource_group_name: str, + script_name: str, + deployment_script: Optional[Union[_models.DeploymentScriptUpdateParameter, IO]] = None, + **kwargs: Any + ) -> _models.DeploymentScript: + """Updates deployment script tags with specified values. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param script_name: Name of the deployment script. Required. + :type script_name: str + :param deployment_script: Deployment script resource with the tags to be updated. Is either a + model type or a IO type. Default value is None. + :type deployment_script: + ~azure.mgmt.resource.deploymentscripts.v2019_10_01_preview.models.DeploymentScriptUpdateParameter + or IO + :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. + Default value is None. + :paramtype content_type: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: DeploymentScript, or the result of cls(response) + :return: DeploymentScript or the result of cls(response) :rtype: ~azure.mgmt.resource.deploymentscripts.v2019_10_01_preview.models.DeploymentScript - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.DeploymentScript"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) - api_version = kwargs.pop('api_version', "2019-10-01-preview") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - if deployment_script is not None: - _json = self._serialize.body(deployment_script, 'DeploymentScriptUpdateParameter') + api_version = kwargs.pop("api_version", _params.pop("api-version", "2019-10-01-preview")) # type: str + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.DeploymentScript] + + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(deployment_script, (IO, bytes)): + _content = deployment_script else: - _json = None + if deployment_script is not None: + _json = self._serialize.body(deployment_script, "DeploymentScriptUpdateParameter") + else: + _json = None request = build_deployment_scripts_update_request( - subscription_id=self._config.subscription_id, resource_group_name=resource_group_name, script_name=script_name, + subscription_id=self._config.subscription_id, api_version=api_version, content_type=content_type, json=_json, - template_url=self.update.metadata['url'], + content=_content, + template_url=self.update.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200]: @@ -237,58 +429,59 @@ async def update( error = self._deserialize.failsafe_deserialize(_models.DeploymentScriptsError, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - deserialized = self._deserialize('DeploymentScript', pipeline_response) + deserialized = self._deserialize("DeploymentScript", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - update.metadata = {'url': "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/Microsoft.Resources/deploymentScripts/{scriptName}"} # type: ignore - + update.metadata = {"url": "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/Microsoft.Resources/deploymentScripts/{scriptName}"} # type: ignore @distributed_trace_async - async def get( - self, - resource_group_name: str, - script_name: str, - **kwargs: Any - ) -> "_models.DeploymentScript": + async def get(self, resource_group_name: str, script_name: str, **kwargs: Any) -> _models.DeploymentScript: """Gets a deployment script with a given name. :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. :type resource_group_name: str - :param script_name: Name of the deployment script. + :param script_name: Name of the deployment script. Required. :type script_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: DeploymentScript, or the result of cls(response) + :return: DeploymentScript or the result of cls(response) :rtype: ~azure.mgmt.resource.deploymentscripts.v2019_10_01_preview.models.DeploymentScript - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.DeploymentScript"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) - api_version = kwargs.pop('api_version', "2019-10-01-preview") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2019-10-01-preview")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[_models.DeploymentScript] - request = build_deployment_scripts_get_request( - subscription_id=self._config.subscription_id, resource_group_name=resource_group_name, script_name=script_name, + subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.get.metadata['url'], + template_url=self.get.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200]: @@ -296,59 +489,62 @@ async def get( error = self._deserialize.failsafe_deserialize(_models.DeploymentScriptsError, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - deserialized = self._deserialize('DeploymentScript', pipeline_response) + deserialized = self._deserialize("DeploymentScript", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - get.metadata = {'url': "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/Microsoft.Resources/deploymentScripts/{scriptName}"} # type: ignore - + get.metadata = {"url": "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/Microsoft.Resources/deploymentScripts/{scriptName}"} # type: ignore @distributed_trace_async async def delete( # pylint: disable=inconsistent-return-statements - self, - resource_group_name: str, - script_name: str, - **kwargs: Any + self, resource_group_name: str, script_name: str, **kwargs: Any ) -> None: """Deletes a deployment script. When operation completes, status code 200 returned without content. :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. :type resource_group_name: str - :param script_name: Name of the deployment script. + :param script_name: Name of the deployment script. Required. :type script_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: None, or the result of cls(response) + :return: None or the result of cls(response) :rtype: None - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType[None] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + 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', "2019-10-01-preview") # type: str + api_version = kwargs.pop("api_version", _params.pop("api-version", "2019-10-01-preview")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[None] - request = build_deployment_scripts_delete_request( - subscription_id=self._config.subscription_id, resource_group_name=resource_group_name, script_name=script_name, + subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.delete.metadata['url'], + template_url=self.delete.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200, 204]: @@ -359,49 +555,53 @@ async def delete( # pylint: disable=inconsistent-return-statements if cls: return cls(pipeline_response, None, {}) - delete.metadata = {'url': "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/Microsoft.Resources/deploymentScripts/{scriptName}"} # type: ignore - + delete.metadata = {"url": "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/Microsoft.Resources/deploymentScripts/{scriptName}"} # type: ignore @distributed_trace - def list_by_subscription( - self, - **kwargs: Any - ) -> AsyncIterable["_models.DeploymentScriptListResult"]: + def list_by_subscription(self, **kwargs: Any) -> AsyncIterable["_models.DeploymentScript"]: """Lists all deployment scripts for a given subscription. :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either DeploymentScriptListResult or the result of - cls(response) + :return: An iterator like instance of either DeploymentScript or the result of cls(response) :rtype: - ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.resource.deploymentscripts.v2019_10_01_preview.models.DeploymentScriptListResult] - :raises: ~azure.core.exceptions.HttpResponseError + ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.resource.deploymentscripts.v2019_10_01_preview.models.DeploymentScript] + :raises ~azure.core.exceptions.HttpResponseError: """ - api_version = kwargs.pop('api_version', "2019-10-01-preview") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2019-10-01-preview")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[_models.DeploymentScriptListResult] - cls = kwargs.pop('cls', None) # type: ClsType["_models.DeploymentScriptListResult"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) + def prepare_request(next_link=None): if not next_link: - + request = build_deployment_scripts_list_by_subscription_request( subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.list_by_subscription.metadata['url'], + template_url=self.list_by_subscription.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore else: - - request = build_deployment_scripts_list_by_subscription_request( - subscription_id=self._config.subscription_id, - template_url=next_link, - ) + # make call to next link with the client's api-version + _parsed_next_link = urlparse(next_link) + _next_request_params = case_insensitive_dict(parse_qs(_parsed_next_link.query)) + _next_request_params["api-version"] = self._config.api_version + request = HttpRequest("GET", urljoin(next_link, _parsed_next_link.path), params=_next_request_params) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore request.method = "GET" return request @@ -415,10 +615,8 @@ async def extract_data(pipeline_response): async def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) response = pipeline_response.http_response @@ -429,54 +627,54 @@ async def get_next(next_link=None): return pipeline_response + return AsyncItemPaged(get_next, extract_data) - return AsyncItemPaged( - get_next, extract_data - ) - list_by_subscription.metadata = {'url': "/subscriptions/{subscriptionId}/providers/Microsoft.Resources/deploymentScripts"} # type: ignore + list_by_subscription.metadata = {"url": "/subscriptions/{subscriptionId}/providers/Microsoft.Resources/deploymentScripts"} # type: ignore @distributed_trace_async - async def get_logs( - self, - resource_group_name: str, - script_name: str, - **kwargs: Any - ) -> "_models.ScriptLogsList": + async def get_logs(self, resource_group_name: str, script_name: str, **kwargs: Any) -> _models.ScriptLogsList: """Gets deployment script logs for a given deployment script name. :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. :type resource_group_name: str - :param script_name: Name of the deployment script. + :param script_name: Name of the deployment script. Required. :type script_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: ScriptLogsList, or the result of cls(response) + :return: ScriptLogsList or the result of cls(response) :rtype: ~azure.mgmt.resource.deploymentscripts.v2019_10_01_preview.models.ScriptLogsList - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.ScriptLogsList"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) - api_version = kwargs.pop('api_version', "2019-10-01-preview") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2019-10-01-preview")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[_models.ScriptLogsList] - request = build_deployment_scripts_get_logs_request( - subscription_id=self._config.subscription_id, resource_group_name=resource_group_name, script_name=script_name, + subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.get_logs.metadata['url'], + template_url=self.get_logs.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200]: @@ -484,64 +682,66 @@ async def get_logs( error = self._deserialize.failsafe_deserialize(_models.DeploymentScriptsError, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - deserialized = self._deserialize('ScriptLogsList', pipeline_response) + deserialized = self._deserialize("ScriptLogsList", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - get_logs.metadata = {'url': "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/Microsoft.Resources/deploymentScripts/{scriptName}/logs"} # type: ignore - + get_logs.metadata = {"url": "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/Microsoft.Resources/deploymentScripts/{scriptName}/logs"} # type: ignore @distributed_trace_async async def get_logs_default( - self, - resource_group_name: str, - script_name: str, - tail: Optional[int] = None, - **kwargs: Any - ) -> "_models.ScriptLog": + self, resource_group_name: str, script_name: str, tail: Optional[int] = None, **kwargs: Any + ) -> _models.ScriptLog: """Gets deployment script logs for a given deployment script name. :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. :type resource_group_name: str - :param script_name: Name of the deployment script. + :param script_name: Name of the deployment script. Required. :type script_name: str :param tail: The number of lines to show from the tail of the deployment script log. Valid value is a positive number up to 1000. If 'tail' is not provided, all available logs are shown up to container instance log capacity of 4mb. Default value is None. :type tail: int :keyword callable cls: A custom type or function that will be passed the direct response - :return: ScriptLog, or the result of cls(response) + :return: ScriptLog or the result of cls(response) :rtype: ~azure.mgmt.resource.deploymentscripts.v2019_10_01_preview.models.ScriptLog - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.ScriptLog"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + 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', "2019-10-01-preview") # type: str + api_version = kwargs.pop("api_version", _params.pop("api-version", "2019-10-01-preview")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[_models.ScriptLog] - request = build_deployment_scripts_get_logs_default_request( - subscription_id=self._config.subscription_id, resource_group_name=resource_group_name, script_name=script_name, - api_version=api_version, + subscription_id=self._config.subscription_id, tail=tail, - template_url=self.get_logs_default.metadata['url'], + api_version=api_version, + template_url=self.get_logs_default.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200]: @@ -549,61 +749,66 @@ async def get_logs_default( error = self._deserialize.failsafe_deserialize(_models.DeploymentScriptsError, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - deserialized = self._deserialize('ScriptLog', pipeline_response) + deserialized = self._deserialize("ScriptLog", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - get_logs_default.metadata = {'url': "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/Microsoft.Resources/deploymentScripts/{scriptName}/logs/default"} # type: ignore - + get_logs_default.metadata = {"url": "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/Microsoft.Resources/deploymentScripts/{scriptName}/logs/default"} # type: ignore @distributed_trace def list_by_resource_group( - self, - resource_group_name: str, - **kwargs: Any - ) -> AsyncIterable["_models.DeploymentScriptListResult"]: + self, resource_group_name: str, **kwargs: Any + ) -> AsyncIterable["_models.DeploymentScript"]: """Lists deployments scripts. :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. :type resource_group_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either DeploymentScriptListResult or the result of - cls(response) + :return: An iterator like instance of either DeploymentScript or the result of cls(response) :rtype: - ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.resource.deploymentscripts.v2019_10_01_preview.models.DeploymentScriptListResult] - :raises: ~azure.core.exceptions.HttpResponseError + ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.resource.deploymentscripts.v2019_10_01_preview.models.DeploymentScript] + :raises ~azure.core.exceptions.HttpResponseError: """ - api_version = kwargs.pop('api_version', "2019-10-01-preview") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2019-10-01-preview")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[_models.DeploymentScriptListResult] - cls = kwargs.pop('cls', None) # type: ClsType["_models.DeploymentScriptListResult"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) + def prepare_request(next_link=None): if not next_link: - + request = build_deployment_scripts_list_by_resource_group_request( - subscription_id=self._config.subscription_id, 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'], + 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.url = self._client.format_url(request.url) # type: ignore else: - - request = build_deployment_scripts_list_by_resource_group_request( - subscription_id=self._config.subscription_id, - resource_group_name=resource_group_name, - template_url=next_link, - ) + # make call to next link with the client's api-version + _parsed_next_link = urlparse(next_link) + _next_request_params = case_insensitive_dict(parse_qs(_parsed_next_link.query)) + _next_request_params["api-version"] = self._config.api_version + request = HttpRequest("GET", urljoin(next_link, _parsed_next_link.path), params=_next_request_params) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore request.method = "GET" return request @@ -617,10 +822,8 @@ async def extract_data(pipeline_response): async def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) response = pipeline_response.http_response @@ -631,8 +834,6 @@ async def get_next(next_link=None): return pipeline_response + return AsyncItemPaged(get_next, extract_data) - return AsyncItemPaged( - get_next, extract_data - ) - list_by_resource_group.metadata = {'url': "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/Microsoft.Resources/deploymentScripts"} # type: ignore + list_by_resource_group.metadata = {"url": "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/Microsoft.Resources/deploymentScripts"} # type: ignore diff --git a/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/deploymentscripts/v2019_10_01_preview/aio/operations/_patch.py b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/deploymentscripts/v2019_10_01_preview/aio/operations/_patch.py new file mode 100644 index 0000000000000..f7dd32510333d --- /dev/null +++ b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/deploymentscripts/v2019_10_01_preview/aio/operations/_patch.py @@ -0,0 +1,20 @@ +# ------------------------------------ +# Copyright (c) Microsoft Corporation. +# Licensed under the MIT License. +# ------------------------------------ +"""Customize generated code here. + +Follow our quickstart for examples: https://aka.ms/azsdk/python/dpcodegen/python/customize +""" +from typing import List + +__all__: List[str] = [] # Add all objects you want publicly available to users at this package level + + +def patch_sdk(): + """Do not remove from this file. + + `patch_sdk` is a last resort escape hatch that allows you to do customizations + you can't accomplish using the techniques described in + https://aka.ms/azsdk/python/dpcodegen/python/customize + """ diff --git a/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/deploymentscripts/v2019_10_01_preview/models/__init__.py b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/deploymentscripts/v2019_10_01_preview/models/__init__.py index 41f495e69961f..eea076a09b970 100644 --- a/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/deploymentscripts/v2019_10_01_preview/models/__init__.py +++ b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/deploymentscripts/v2019_10_01_preview/models/__init__.py @@ -29,41 +29,43 @@ from ._models_py3 import SystemData from ._models_py3 import UserAssignedIdentity - -from ._deployment_scripts_client_enums import ( - CleanupOptions, - CreatedByType, - ManagedServiceIdentityType, - ScriptProvisioningState, - ScriptType, -) +from ._deployment_scripts_client_enums import CleanupOptions +from ._deployment_scripts_client_enums import CreatedByType +from ._deployment_scripts_client_enums import ManagedServiceIdentityType +from ._deployment_scripts_client_enums import ScriptProvisioningState +from ._deployment_scripts_client_enums import ScriptType +from ._patch import __all__ as _patch_all +from ._patch import * # type: ignore # pylint: disable=unused-wildcard-import +from ._patch import patch_sdk as _patch_sdk __all__ = [ - 'AzureCliScript', - 'AzureCliScriptProperties', - 'AzurePowerShellScript', - 'AzurePowerShellScriptProperties', - 'AzureResourceBase', - 'ContainerConfiguration', - 'DeploymentScript', - 'DeploymentScriptListResult', - 'DeploymentScriptPropertiesBase', - 'DeploymentScriptUpdateParameter', - 'DeploymentScriptsError', - 'EnvironmentVariable', - 'ErrorAdditionalInfo', - 'ErrorResponse', - 'ManagedServiceIdentity', - 'ScriptConfigurationBase', - 'ScriptLog', - 'ScriptLogsList', - 'ScriptStatus', - 'StorageAccountConfiguration', - 'SystemData', - 'UserAssignedIdentity', - 'CleanupOptions', - 'CreatedByType', - 'ManagedServiceIdentityType', - 'ScriptProvisioningState', - 'ScriptType', + "AzureCliScript", + "AzureCliScriptProperties", + "AzurePowerShellScript", + "AzurePowerShellScriptProperties", + "AzureResourceBase", + "ContainerConfiguration", + "DeploymentScript", + "DeploymentScriptListResult", + "DeploymentScriptPropertiesBase", + "DeploymentScriptUpdateParameter", + "DeploymentScriptsError", + "EnvironmentVariable", + "ErrorAdditionalInfo", + "ErrorResponse", + "ManagedServiceIdentity", + "ScriptConfigurationBase", + "ScriptLog", + "ScriptLogsList", + "ScriptStatus", + "StorageAccountConfiguration", + "SystemData", + "UserAssignedIdentity", + "CleanupOptions", + "CreatedByType", + "ManagedServiceIdentityType", + "ScriptProvisioningState", + "ScriptType", ] +__all__.extend([p for p in _patch_all if p not in __all__]) +_patch_sdk() diff --git a/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/deploymentscripts/v2019_10_01_preview/models/_deployment_scripts_client_enums.py b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/deploymentscripts/v2019_10_01_preview/models/_deployment_scripts_client_enums.py index 278dc1e6bf8e4..41451353e2f9b 100644 --- a/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/deploymentscripts/v2019_10_01_preview/models/_deployment_scripts_client_enums.py +++ b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/deploymentscripts/v2019_10_01_preview/models/_deployment_scripts_client_enums.py @@ -7,11 +7,10 @@ # -------------------------------------------------------------------------- from enum import Enum -from six import with_metaclass from azure.core import CaseInsensitiveEnumMeta -class CleanupOptions(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): +class CleanupOptions(str, Enum, metaclass=CaseInsensitiveEnumMeta): """The clean up preference when the script execution gets in a terminal state. Default setting is 'Always'. """ @@ -20,24 +19,24 @@ class CleanupOptions(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): ON_SUCCESS = "OnSuccess" ON_EXPIRATION = "OnExpiration" -class CreatedByType(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): - """The type of identity that created the resource. - """ + +class CreatedByType(str, Enum, metaclass=CaseInsensitiveEnumMeta): + """The type of identity that created the resource.""" USER = "User" APPLICATION = "Application" MANAGED_IDENTITY = "ManagedIdentity" KEY = "Key" -class ManagedServiceIdentityType(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): - """Type of the managed identity. - """ + +class ManagedServiceIdentityType(str, Enum, metaclass=CaseInsensitiveEnumMeta): + """Type of the managed identity.""" USER_ASSIGNED = "UserAssigned" -class ScriptProvisioningState(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): - """State of the script execution. This only appears in the response. - """ + +class ScriptProvisioningState(str, Enum, metaclass=CaseInsensitiveEnumMeta): + """State of the script execution. This only appears in the response.""" CREATING = "Creating" PROVISIONING_RESOURCES = "ProvisioningResources" @@ -46,9 +45,9 @@ class ScriptProvisioningState(with_metaclass(CaseInsensitiveEnumMeta, str, Enum) FAILED = "Failed" CANCELED = "Canceled" -class ScriptType(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): - """Type of the script. - """ + +class ScriptType(str, Enum, metaclass=CaseInsensitiveEnumMeta): + """Type of the script.""" AZURE_POWER_SHELL = "AzurePowerShell" AZURE_CLI = "AzureCLI" diff --git a/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/deploymentscripts/v2019_10_01_preview/models/_models_py3.py b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/deploymentscripts/v2019_10_01_preview/models/_models_py3.py index a505bfcf344dd..af2c022449f0c 100644 --- a/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/deploymentscripts/v2019_10_01_preview/models/_models_py3.py +++ b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/deploymentscripts/v2019_10_01_preview/models/_models_py3.py @@ -1,4 +1,5 @@ # coding=utf-8 +# pylint: disable=too-many-lines # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. # Licensed under the MIT License. See License.txt in the project root for license information. @@ -7,15 +8,16 @@ # -------------------------------------------------------------------------- import datetime -from typing import Dict, List, Optional, Union +from typing import Dict, List, Optional, TYPE_CHECKING, Union -from azure.core.exceptions import HttpResponseError -import msrest.serialization +from ... import _serialization -from ._deployment_scripts_client_enums import * +if TYPE_CHECKING: + # pylint: disable=unused-import,ungrouped-imports + from .. import models as _models -class AzureResourceBase(msrest.serialization.Model): +class AzureResourceBase(_serialization.Model): """Common properties for all Azure resources. Variables are only populated by the server, and will be ignored when sending a request. @@ -29,24 +31,20 @@ class AzureResourceBase(msrest.serialization.Model): """ _validation = { - 'id': {'readonly': True}, - 'name': {'readonly': True}, - 'type': {'readonly': True}, + "id": {"readonly": True}, + "name": {"readonly": True}, + "type": {"readonly": True}, } _attribute_map = { - 'id': {'key': 'id', 'type': 'str'}, - 'name': {'key': 'name', 'type': 'str'}, - 'type': {'key': 'type', 'type': 'str'}, + "id": {"key": "id", "type": "str"}, + "name": {"key": "name", "type": "str"}, + "type": {"key": "type", "type": "str"}, } - def __init__( - self, - **kwargs - ): - """ - """ - super(AzureResourceBase, self).__init__(**kwargs) + def __init__(self, **kwargs): + """ """ + super().__init__(**kwargs) self.id = None self.name = None self.type = None @@ -55,8 +53,8 @@ def __init__( class DeploymentScript(AzureResourceBase): """Deployment script object. - You probably want to use the sub-classes and not this class directly. Known - sub-classes are: AzureCliScript, AzurePowerShellScript. + You probably want to use the sub-classes and not this class directly. Known sub-classes are: + AzureCliScript, AzurePowerShellScript Variables are only populated by the server, and will be ignored when sending a request. @@ -68,17 +66,16 @@ class DeploymentScript(AzureResourceBase): :vartype name: str :ivar type: Type of this resource. :vartype type: str - :ivar identity: Required. Managed identity to be used for this deployment script. Currently, - only user-assigned MSI is supported. + :ivar identity: Managed identity to be used for this deployment script. Currently, only + user-assigned MSI is supported. Required. :vartype identity: ~azure.mgmt.resource.deploymentscripts.v2019_10_01_preview.models.ManagedServiceIdentity - :ivar location: Required. The location of the ACI and the storage account for the deployment - script. + :ivar location: The location of the ACI and the storage account for the deployment script. + Required. :vartype location: str - :ivar tags: A set of tags. Resource tags. + :ivar tags: Resource tags. :vartype tags: dict[str, str] - :ivar kind: Required. Type of the script.Constant filled by server. Possible values include: - "AzurePowerShell", "AzureCLI". + :ivar kind: Type of the script. Required. Known values are: "AzurePowerShell" and "AzureCLI". :vartype kind: str or ~azure.mgmt.resource.deploymentscripts.v2019_10_01_preview.models.ScriptType :ivar system_data: The system metadata related to this resource. @@ -87,58 +84,56 @@ class DeploymentScript(AzureResourceBase): """ _validation = { - 'id': {'readonly': True}, - 'name': {'readonly': True}, - 'type': {'readonly': True}, - 'identity': {'required': True}, - 'location': {'required': True}, - 'kind': {'required': True}, - 'system_data': {'readonly': True}, + "id": {"readonly": True}, + "name": {"readonly": True}, + "type": {"readonly": True}, + "identity": {"required": True}, + "location": {"required": True}, + "kind": {"required": True}, + "system_data": {"readonly": True}, } _attribute_map = { - 'id': {'key': 'id', 'type': 'str'}, - 'name': {'key': 'name', 'type': 'str'}, - 'type': {'key': 'type', 'type': 'str'}, - 'identity': {'key': 'identity', 'type': 'ManagedServiceIdentity'}, - 'location': {'key': 'location', 'type': 'str'}, - 'tags': {'key': 'tags', 'type': '{str}'}, - 'kind': {'key': 'kind', 'type': 'str'}, - 'system_data': {'key': 'systemData', 'type': 'SystemData'}, + "id": {"key": "id", "type": "str"}, + "name": {"key": "name", "type": "str"}, + "type": {"key": "type", "type": "str"}, + "identity": {"key": "identity", "type": "ManagedServiceIdentity"}, + "location": {"key": "location", "type": "str"}, + "tags": {"key": "tags", "type": "{str}"}, + "kind": {"key": "kind", "type": "str"}, + "system_data": {"key": "systemData", "type": "SystemData"}, } - _subtype_map = { - 'kind': {'AzureCLI': 'AzureCliScript', 'AzurePowerShell': 'AzurePowerShellScript'} - } + _subtype_map = {"kind": {"AzureCLI": "AzureCliScript", "AzurePowerShell": "AzurePowerShellScript"}} def __init__( self, *, - identity: "ManagedServiceIdentity", + identity: "_models.ManagedServiceIdentity", location: str, tags: Optional[Dict[str, str]] = None, **kwargs ): """ - :keyword identity: Required. Managed identity to be used for this deployment script. Currently, - only user-assigned MSI is supported. + :keyword identity: Managed identity to be used for this deployment script. Currently, only + user-assigned MSI is supported. Required. :paramtype identity: ~azure.mgmt.resource.deploymentscripts.v2019_10_01_preview.models.ManagedServiceIdentity - :keyword location: Required. The location of the ACI and the storage account for the deployment - script. + :keyword location: The location of the ACI and the storage account for the deployment script. + Required. :paramtype location: str - :keyword tags: A set of tags. Resource tags. + :keyword tags: Resource tags. :paramtype tags: dict[str, str] """ - super(DeploymentScript, self).__init__(**kwargs) + super().__init__(**kwargs) self.identity = identity self.location = location self.tags = tags - self.kind = 'DeploymentScript' # type: str + self.kind = None # type: Optional[str] self.system_data = None -class AzureCliScript(DeploymentScript): +class AzureCliScript(DeploymentScript): # pylint: disable=too-many-instance-attributes """Object model for the Azure CLI script. Variables are only populated by the server, and will be ignored when sending a request. @@ -151,17 +146,16 @@ class AzureCliScript(DeploymentScript): :vartype name: str :ivar type: Type of this resource. :vartype type: str - :ivar identity: Required. Managed identity to be used for this deployment script. Currently, - only user-assigned MSI is supported. + :ivar identity: Managed identity to be used for this deployment script. Currently, only + user-assigned MSI is supported. Required. :vartype identity: ~azure.mgmt.resource.deploymentscripts.v2019_10_01_preview.models.ManagedServiceIdentity - :ivar location: Required. The location of the ACI and the storage account for the deployment - script. + :ivar location: The location of the ACI and the storage account for the deployment script. + Required. :vartype location: str - :ivar tags: A set of tags. Resource tags. + :ivar tags: Resource tags. :vartype tags: dict[str, str] - :ivar kind: Required. Type of the script.Constant filled by server. Possible values include: - "AzurePowerShell", "AzureCLI". + :ivar kind: Type of the script. Required. Known values are: "AzurePowerShell" and "AzureCLI". :vartype kind: str or ~azure.mgmt.resource.deploymentscripts.v2019_10_01_preview.models.ScriptType :ivar system_data: The system metadata related to this resource. @@ -174,19 +168,19 @@ class AzureCliScript(DeploymentScript): :vartype storage_account_settings: ~azure.mgmt.resource.deploymentscripts.v2019_10_01_preview.models.StorageAccountConfiguration :ivar cleanup_preference: The clean up preference when the script execution gets in a terminal - state. Default setting is 'Always'. Possible values include: "Always", "OnSuccess", - "OnExpiration". Default value: "Always". + state. Default setting is 'Always'. Known values are: "Always", "OnSuccess", and + "OnExpiration". :vartype cleanup_preference: str or ~azure.mgmt.resource.deploymentscripts.v2019_10_01_preview.models.CleanupOptions :ivar provisioning_state: State of the script execution. This only appears in the response. - Possible values include: "Creating", "ProvisioningResources", "Running", "Succeeded", "Failed", + Known values are: "Creating", "ProvisioningResources", "Running", "Succeeded", "Failed", and "Canceled". :vartype provisioning_state: str or ~azure.mgmt.resource.deploymentscripts.v2019_10_01_preview.models.ScriptProvisioningState :ivar status: Contains the results of script execution. :vartype status: ~azure.mgmt.resource.deploymentscripts.v2019_10_01_preview.models.ScriptStatus :ivar outputs: List of script outputs. - :vartype outputs: dict[str, any] + :vartype outputs: dict[str, JSON] :ivar primary_script_uri: Uri for the script. This is the entry point for the external script. :vartype primary_script_uri: str :ivar supporting_script_uris: Supporting files for the external script. @@ -202,88 +196,88 @@ class AzureCliScript(DeploymentScript): :ivar force_update_tag: Gets or sets how the deployment script should be forced to execute even if the script resource has not changed. Can be current time stamp or a GUID. :vartype force_update_tag: str - :ivar retention_interval: Required. Interval for which the service retains the script resource - after it reaches a terminal state. Resource will be deleted when this duration expires. - Duration is based on ISO 8601 pattern (for example P1D means one day). + :ivar retention_interval: Interval for which the service retains the script resource after it + reaches a terminal state. Resource will be deleted when this duration expires. Duration is + based on ISO 8601 pattern (for example P1D means one day). Required. :vartype retention_interval: ~datetime.timedelta :ivar timeout: Maximum allowed script execution time specified in ISO 8601 format. Default value is P1D. :vartype timeout: ~datetime.timedelta - :ivar az_cli_version: Required. Azure CLI module version to be used. + :ivar az_cli_version: Azure CLI module version to be used. Required. :vartype az_cli_version: str """ _validation = { - 'id': {'readonly': True}, - 'name': {'readonly': True}, - 'type': {'readonly': True}, - 'identity': {'required': True}, - 'location': {'required': True}, - 'kind': {'required': True}, - 'system_data': {'readonly': True}, - 'provisioning_state': {'readonly': True}, - 'status': {'readonly': True}, - 'outputs': {'readonly': True}, - 'script_content': {'max_length': 32000, 'min_length': 0}, - 'retention_interval': {'required': True}, - 'az_cli_version': {'required': True}, + "id": {"readonly": True}, + "name": {"readonly": True}, + "type": {"readonly": True}, + "identity": {"required": True}, + "location": {"required": True}, + "kind": {"required": True}, + "system_data": {"readonly": True}, + "provisioning_state": {"readonly": True}, + "status": {"readonly": True}, + "outputs": {"readonly": True}, + "script_content": {"max_length": 32000}, + "retention_interval": {"required": True}, + "az_cli_version": {"required": True}, } _attribute_map = { - 'id': {'key': 'id', 'type': 'str'}, - 'name': {'key': 'name', 'type': 'str'}, - 'type': {'key': 'type', 'type': 'str'}, - 'identity': {'key': 'identity', 'type': 'ManagedServiceIdentity'}, - 'location': {'key': 'location', 'type': 'str'}, - 'tags': {'key': 'tags', 'type': '{str}'}, - 'kind': {'key': 'kind', 'type': 'str'}, - 'system_data': {'key': 'systemData', 'type': 'SystemData'}, - 'container_settings': {'key': 'properties.containerSettings', 'type': 'ContainerConfiguration'}, - 'storage_account_settings': {'key': 'properties.storageAccountSettings', 'type': 'StorageAccountConfiguration'}, - 'cleanup_preference': {'key': 'properties.cleanupPreference', 'type': 'str'}, - 'provisioning_state': {'key': 'properties.provisioningState', 'type': 'str'}, - 'status': {'key': 'properties.status', 'type': 'ScriptStatus'}, - 'outputs': {'key': 'properties.outputs', 'type': '{object}'}, - 'primary_script_uri': {'key': 'properties.primaryScriptUri', 'type': 'str'}, - 'supporting_script_uris': {'key': 'properties.supportingScriptUris', 'type': '[str]'}, - 'script_content': {'key': 'properties.scriptContent', 'type': 'str'}, - 'arguments': {'key': 'properties.arguments', 'type': 'str'}, - 'environment_variables': {'key': 'properties.environmentVariables', 'type': '[EnvironmentVariable]'}, - 'force_update_tag': {'key': 'properties.forceUpdateTag', 'type': 'str'}, - 'retention_interval': {'key': 'properties.retentionInterval', 'type': 'duration'}, - 'timeout': {'key': 'properties.timeout', 'type': 'duration'}, - 'az_cli_version': {'key': 'properties.azCliVersion', 'type': 'str'}, + "id": {"key": "id", "type": "str"}, + "name": {"key": "name", "type": "str"}, + "type": {"key": "type", "type": "str"}, + "identity": {"key": "identity", "type": "ManagedServiceIdentity"}, + "location": {"key": "location", "type": "str"}, + "tags": {"key": "tags", "type": "{str}"}, + "kind": {"key": "kind", "type": "str"}, + "system_data": {"key": "systemData", "type": "SystemData"}, + "container_settings": {"key": "properties.containerSettings", "type": "ContainerConfiguration"}, + "storage_account_settings": {"key": "properties.storageAccountSettings", "type": "StorageAccountConfiguration"}, + "cleanup_preference": {"key": "properties.cleanupPreference", "type": "str"}, + "provisioning_state": {"key": "properties.provisioningState", "type": "str"}, + "status": {"key": "properties.status", "type": "ScriptStatus"}, + "outputs": {"key": "properties.outputs", "type": "{object}"}, + "primary_script_uri": {"key": "properties.primaryScriptUri", "type": "str"}, + "supporting_script_uris": {"key": "properties.supportingScriptUris", "type": "[str]"}, + "script_content": {"key": "properties.scriptContent", "type": "str"}, + "arguments": {"key": "properties.arguments", "type": "str"}, + "environment_variables": {"key": "properties.environmentVariables", "type": "[EnvironmentVariable]"}, + "force_update_tag": {"key": "properties.forceUpdateTag", "type": "str"}, + "retention_interval": {"key": "properties.retentionInterval", "type": "duration"}, + "timeout": {"key": "properties.timeout", "type": "duration"}, + "az_cli_version": {"key": "properties.azCliVersion", "type": "str"}, } def __init__( self, *, - identity: "ManagedServiceIdentity", + identity: "_models.ManagedServiceIdentity", location: str, retention_interval: datetime.timedelta, az_cli_version: str, tags: Optional[Dict[str, str]] = None, - container_settings: Optional["ContainerConfiguration"] = None, - storage_account_settings: Optional["StorageAccountConfiguration"] = None, - cleanup_preference: Optional[Union[str, "CleanupOptions"]] = "Always", + container_settings: Optional["_models.ContainerConfiguration"] = None, + storage_account_settings: Optional["_models.StorageAccountConfiguration"] = None, + cleanup_preference: Union[str, "_models.CleanupOptions"] = "Always", primary_script_uri: Optional[str] = None, supporting_script_uris: Optional[List[str]] = None, script_content: Optional[str] = None, arguments: Optional[str] = None, - environment_variables: Optional[List["EnvironmentVariable"]] = None, + environment_variables: Optional[List["_models.EnvironmentVariable"]] = None, force_update_tag: Optional[str] = None, - timeout: Optional[datetime.timedelta] = "P1D", + timeout: datetime.timedelta = "P1D", **kwargs ): """ - :keyword identity: Required. Managed identity to be used for this deployment script. Currently, - only user-assigned MSI is supported. + :keyword identity: Managed identity to be used for this deployment script. Currently, only + user-assigned MSI is supported. Required. :paramtype identity: ~azure.mgmt.resource.deploymentscripts.v2019_10_01_preview.models.ManagedServiceIdentity - :keyword location: Required. The location of the ACI and the storage account for the deployment - script. + :keyword location: The location of the ACI and the storage account for the deployment script. + Required. :paramtype location: str - :keyword tags: A set of tags. Resource tags. + :keyword tags: Resource tags. :paramtype tags: dict[str, str] :keyword container_settings: Container settings. :paramtype container_settings: @@ -292,8 +286,8 @@ def __init__( :paramtype storage_account_settings: ~azure.mgmt.resource.deploymentscripts.v2019_10_01_preview.models.StorageAccountConfiguration :keyword cleanup_preference: The clean up preference when the script execution gets in a - terminal state. Default setting is 'Always'. Possible values include: "Always", "OnSuccess", - "OnExpiration". Default value: "Always". + terminal state. Default setting is 'Always'. Known values are: "Always", "OnSuccess", and + "OnExpiration". :paramtype cleanup_preference: str or ~azure.mgmt.resource.deploymentscripts.v2019_10_01_preview.models.CleanupOptions :keyword primary_script_uri: Uri for the script. This is the entry point for the external @@ -312,18 +306,18 @@ def __init__( :keyword force_update_tag: Gets or sets how the deployment script should be forced to execute even if the script resource has not changed. Can be current time stamp or a GUID. :paramtype force_update_tag: str - :keyword retention_interval: Required. Interval for which the service retains the script - resource after it reaches a terminal state. Resource will be deleted when this duration - expires. Duration is based on ISO 8601 pattern (for example P1D means one day). + :keyword retention_interval: Interval for which the service retains the script resource after + it reaches a terminal state. Resource will be deleted when this duration expires. Duration is + based on ISO 8601 pattern (for example P1D means one day). Required. :paramtype retention_interval: ~datetime.timedelta :keyword timeout: Maximum allowed script execution time specified in ISO 8601 format. Default value is P1D. :paramtype timeout: ~datetime.timedelta - :keyword az_cli_version: Required. Azure CLI module version to be used. + :keyword az_cli_version: Azure CLI module version to be used. Required. :paramtype az_cli_version: str """ - super(AzureCliScript, self).__init__(identity=identity, location=location, tags=tags, **kwargs) - self.kind = 'AzureCLI' # type: str + super().__init__(identity=identity, location=location, tags=tags, **kwargs) + self.kind = "AzureCLI" # type: str self.container_settings = container_settings self.storage_account_settings = storage_account_settings self.cleanup_preference = cleanup_preference @@ -341,7 +335,7 @@ def __init__( self.az_cli_version = az_cli_version -class ScriptConfigurationBase(msrest.serialization.Model): +class ScriptConfigurationBase(_serialization.Model): """Common configuration settings for both Azure PowerShell and Azure CLI scripts. All required parameters must be populated in order to send to Azure. @@ -361,9 +355,9 @@ class ScriptConfigurationBase(msrest.serialization.Model): :ivar force_update_tag: Gets or sets how the deployment script should be forced to execute even if the script resource has not changed. Can be current time stamp or a GUID. :vartype force_update_tag: str - :ivar retention_interval: Required. Interval for which the service retains the script resource - after it reaches a terminal state. Resource will be deleted when this duration expires. - Duration is based on ISO 8601 pattern (for example P1D means one day). + :ivar retention_interval: Interval for which the service retains the script resource after it + reaches a terminal state. Resource will be deleted when this duration expires. Duration is + based on ISO 8601 pattern (for example P1D means one day). Required. :vartype retention_interval: ~datetime.timedelta :ivar timeout: Maximum allowed script execution time specified in ISO 8601 format. Default value is P1D. @@ -371,19 +365,19 @@ class ScriptConfigurationBase(msrest.serialization.Model): """ _validation = { - 'script_content': {'max_length': 32000, 'min_length': 0}, - 'retention_interval': {'required': True}, + "script_content": {"max_length": 32000}, + "retention_interval": {"required": True}, } _attribute_map = { - 'primary_script_uri': {'key': 'primaryScriptUri', 'type': 'str'}, - 'supporting_script_uris': {'key': 'supportingScriptUris', 'type': '[str]'}, - 'script_content': {'key': 'scriptContent', 'type': 'str'}, - 'arguments': {'key': 'arguments', 'type': 'str'}, - 'environment_variables': {'key': 'environmentVariables', 'type': '[EnvironmentVariable]'}, - 'force_update_tag': {'key': 'forceUpdateTag', 'type': 'str'}, - 'retention_interval': {'key': 'retentionInterval', 'type': 'duration'}, - 'timeout': {'key': 'timeout', 'type': 'duration'}, + "primary_script_uri": {"key": "primaryScriptUri", "type": "str"}, + "supporting_script_uris": {"key": "supportingScriptUris", "type": "[str]"}, + "script_content": {"key": "scriptContent", "type": "str"}, + "arguments": {"key": "arguments", "type": "str"}, + "environment_variables": {"key": "environmentVariables", "type": "[EnvironmentVariable]"}, + "force_update_tag": {"key": "forceUpdateTag", "type": "str"}, + "retention_interval": {"key": "retentionInterval", "type": "duration"}, + "timeout": {"key": "timeout", "type": "duration"}, } def __init__( @@ -394,9 +388,9 @@ def __init__( supporting_script_uris: Optional[List[str]] = None, script_content: Optional[str] = None, arguments: Optional[str] = None, - environment_variables: Optional[List["EnvironmentVariable"]] = None, + environment_variables: Optional[List["_models.EnvironmentVariable"]] = None, force_update_tag: Optional[str] = None, - timeout: Optional[datetime.timedelta] = "P1D", + timeout: datetime.timedelta = "P1D", **kwargs ): """ @@ -416,15 +410,15 @@ def __init__( :keyword force_update_tag: Gets or sets how the deployment script should be forced to execute even if the script resource has not changed. Can be current time stamp or a GUID. :paramtype force_update_tag: str - :keyword retention_interval: Required. Interval for which the service retains the script - resource after it reaches a terminal state. Resource will be deleted when this duration - expires. Duration is based on ISO 8601 pattern (for example P1D means one day). + :keyword retention_interval: Interval for which the service retains the script resource after + it reaches a terminal state. Resource will be deleted when this duration expires. Duration is + based on ISO 8601 pattern (for example P1D means one day). Required. :paramtype retention_interval: ~datetime.timedelta :keyword timeout: Maximum allowed script execution time specified in ISO 8601 format. Default value is P1D. :paramtype timeout: ~datetime.timedelta """ - super(ScriptConfigurationBase, self).__init__(**kwargs) + super().__init__(**kwargs) self.primary_script_uri = primary_script_uri self.supporting_script_uris = supporting_script_uris self.script_content = script_content @@ -435,7 +429,7 @@ def __init__( self.timeout = timeout -class DeploymentScriptPropertiesBase(msrest.serialization.Model): +class DeploymentScriptPropertiesBase(_serialization.Model): """Common properties for the deployment script. Variables are only populated by the server, and will be ignored when sending a request. @@ -447,42 +441,42 @@ class DeploymentScriptPropertiesBase(msrest.serialization.Model): :vartype storage_account_settings: ~azure.mgmt.resource.deploymentscripts.v2019_10_01_preview.models.StorageAccountConfiguration :ivar cleanup_preference: The clean up preference when the script execution gets in a terminal - state. Default setting is 'Always'. Possible values include: "Always", "OnSuccess", - "OnExpiration". Default value: "Always". + state. Default setting is 'Always'. Known values are: "Always", "OnSuccess", and + "OnExpiration". :vartype cleanup_preference: str or ~azure.mgmt.resource.deploymentscripts.v2019_10_01_preview.models.CleanupOptions :ivar provisioning_state: State of the script execution. This only appears in the response. - Possible values include: "Creating", "ProvisioningResources", "Running", "Succeeded", "Failed", + Known values are: "Creating", "ProvisioningResources", "Running", "Succeeded", "Failed", and "Canceled". :vartype provisioning_state: str or ~azure.mgmt.resource.deploymentscripts.v2019_10_01_preview.models.ScriptProvisioningState :ivar status: Contains the results of script execution. :vartype status: ~azure.mgmt.resource.deploymentscripts.v2019_10_01_preview.models.ScriptStatus :ivar outputs: List of script outputs. - :vartype outputs: dict[str, any] + :vartype outputs: dict[str, JSON] """ _validation = { - 'provisioning_state': {'readonly': True}, - 'status': {'readonly': True}, - 'outputs': {'readonly': True}, + "provisioning_state": {"readonly": True}, + "status": {"readonly": True}, + "outputs": {"readonly": True}, } _attribute_map = { - 'container_settings': {'key': 'containerSettings', 'type': 'ContainerConfiguration'}, - 'storage_account_settings': {'key': 'storageAccountSettings', 'type': 'StorageAccountConfiguration'}, - 'cleanup_preference': {'key': 'cleanupPreference', 'type': 'str'}, - 'provisioning_state': {'key': 'provisioningState', 'type': 'str'}, - 'status': {'key': 'status', 'type': 'ScriptStatus'}, - 'outputs': {'key': 'outputs', 'type': '{object}'}, + "container_settings": {"key": "containerSettings", "type": "ContainerConfiguration"}, + "storage_account_settings": {"key": "storageAccountSettings", "type": "StorageAccountConfiguration"}, + "cleanup_preference": {"key": "cleanupPreference", "type": "str"}, + "provisioning_state": {"key": "provisioningState", "type": "str"}, + "status": {"key": "status", "type": "ScriptStatus"}, + "outputs": {"key": "outputs", "type": "{object}"}, } def __init__( self, *, - container_settings: Optional["ContainerConfiguration"] = None, - storage_account_settings: Optional["StorageAccountConfiguration"] = None, - cleanup_preference: Optional[Union[str, "CleanupOptions"]] = "Always", + container_settings: Optional["_models.ContainerConfiguration"] = None, + storage_account_settings: Optional["_models.StorageAccountConfiguration"] = None, + cleanup_preference: Union[str, "_models.CleanupOptions"] = "Always", **kwargs ): """ @@ -493,12 +487,12 @@ def __init__( :paramtype storage_account_settings: ~azure.mgmt.resource.deploymentscripts.v2019_10_01_preview.models.StorageAccountConfiguration :keyword cleanup_preference: The clean up preference when the script execution gets in a - terminal state. Default setting is 'Always'. Possible values include: "Always", "OnSuccess", - "OnExpiration". Default value: "Always". + terminal state. Default setting is 'Always'. Known values are: "Always", "OnSuccess", and + "OnExpiration". :paramtype cleanup_preference: str or ~azure.mgmt.resource.deploymentscripts.v2019_10_01_preview.models.CleanupOptions """ - super(DeploymentScriptPropertiesBase, self).__init__(**kwargs) + super().__init__(**kwargs) self.container_settings = container_settings self.storage_account_settings = storage_account_settings self.cleanup_preference = cleanup_preference @@ -507,7 +501,9 @@ def __init__( self.outputs = None -class AzureCliScriptProperties(DeploymentScriptPropertiesBase, ScriptConfigurationBase): +class AzureCliScriptProperties( + DeploymentScriptPropertiesBase, ScriptConfigurationBase +): # pylint: disable=too-many-instance-attributes """Properties of the Azure CLI script object. Variables are only populated by the server, and will be ignored when sending a request. @@ -529,9 +525,9 @@ class AzureCliScriptProperties(DeploymentScriptPropertiesBase, ScriptConfigurati :ivar force_update_tag: Gets or sets how the deployment script should be forced to execute even if the script resource has not changed. Can be current time stamp or a GUID. :vartype force_update_tag: str - :ivar retention_interval: Required. Interval for which the service retains the script resource - after it reaches a terminal state. Resource will be deleted when this duration expires. - Duration is based on ISO 8601 pattern (for example P1D means one day). + :ivar retention_interval: Interval for which the service retains the script resource after it + reaches a terminal state. Resource will be deleted when this duration expires. Duration is + based on ISO 8601 pattern (for example P1D means one day). Required. :vartype retention_interval: ~datetime.timedelta :ivar timeout: Maximum allowed script execution time specified in ISO 8601 format. Default value is P1D. @@ -543,48 +539,48 @@ class AzureCliScriptProperties(DeploymentScriptPropertiesBase, ScriptConfigurati :vartype storage_account_settings: ~azure.mgmt.resource.deploymentscripts.v2019_10_01_preview.models.StorageAccountConfiguration :ivar cleanup_preference: The clean up preference when the script execution gets in a terminal - state. Default setting is 'Always'. Possible values include: "Always", "OnSuccess", - "OnExpiration". Default value: "Always". + state. Default setting is 'Always'. Known values are: "Always", "OnSuccess", and + "OnExpiration". :vartype cleanup_preference: str or ~azure.mgmt.resource.deploymentscripts.v2019_10_01_preview.models.CleanupOptions :ivar provisioning_state: State of the script execution. This only appears in the response. - Possible values include: "Creating", "ProvisioningResources", "Running", "Succeeded", "Failed", + Known values are: "Creating", "ProvisioningResources", "Running", "Succeeded", "Failed", and "Canceled". :vartype provisioning_state: str or ~azure.mgmt.resource.deploymentscripts.v2019_10_01_preview.models.ScriptProvisioningState :ivar status: Contains the results of script execution. :vartype status: ~azure.mgmt.resource.deploymentscripts.v2019_10_01_preview.models.ScriptStatus :ivar outputs: List of script outputs. - :vartype outputs: dict[str, any] - :ivar az_cli_version: Required. Azure CLI module version to be used. + :vartype outputs: dict[str, JSON] + :ivar az_cli_version: Azure CLI module version to be used. Required. :vartype az_cli_version: str """ _validation = { - 'script_content': {'max_length': 32000, 'min_length': 0}, - 'retention_interval': {'required': True}, - 'provisioning_state': {'readonly': True}, - 'status': {'readonly': True}, - 'outputs': {'readonly': True}, - 'az_cli_version': {'required': True}, + "script_content": {"max_length": 32000}, + "retention_interval": {"required": True}, + "provisioning_state": {"readonly": True}, + "status": {"readonly": True}, + "outputs": {"readonly": True}, + "az_cli_version": {"required": True}, } _attribute_map = { - 'primary_script_uri': {'key': 'primaryScriptUri', 'type': 'str'}, - 'supporting_script_uris': {'key': 'supportingScriptUris', 'type': '[str]'}, - 'script_content': {'key': 'scriptContent', 'type': 'str'}, - 'arguments': {'key': 'arguments', 'type': 'str'}, - 'environment_variables': {'key': 'environmentVariables', 'type': '[EnvironmentVariable]'}, - 'force_update_tag': {'key': 'forceUpdateTag', 'type': 'str'}, - 'retention_interval': {'key': 'retentionInterval', 'type': 'duration'}, - 'timeout': {'key': 'timeout', 'type': 'duration'}, - 'container_settings': {'key': 'containerSettings', 'type': 'ContainerConfiguration'}, - 'storage_account_settings': {'key': 'storageAccountSettings', 'type': 'StorageAccountConfiguration'}, - 'cleanup_preference': {'key': 'cleanupPreference', 'type': 'str'}, - 'provisioning_state': {'key': 'provisioningState', 'type': 'str'}, - 'status': {'key': 'status', 'type': 'ScriptStatus'}, - 'outputs': {'key': 'outputs', 'type': '{object}'}, - 'az_cli_version': {'key': 'azCliVersion', 'type': 'str'}, + "primary_script_uri": {"key": "primaryScriptUri", "type": "str"}, + "supporting_script_uris": {"key": "supportingScriptUris", "type": "[str]"}, + "script_content": {"key": "scriptContent", "type": "str"}, + "arguments": {"key": "arguments", "type": "str"}, + "environment_variables": {"key": "environmentVariables", "type": "[EnvironmentVariable]"}, + "force_update_tag": {"key": "forceUpdateTag", "type": "str"}, + "retention_interval": {"key": "retentionInterval", "type": "duration"}, + "timeout": {"key": "timeout", "type": "duration"}, + "container_settings": {"key": "containerSettings", "type": "ContainerConfiguration"}, + "storage_account_settings": {"key": "storageAccountSettings", "type": "StorageAccountConfiguration"}, + "cleanup_preference": {"key": "cleanupPreference", "type": "str"}, + "provisioning_state": {"key": "provisioningState", "type": "str"}, + "status": {"key": "status", "type": "ScriptStatus"}, + "outputs": {"key": "outputs", "type": "{object}"}, + "az_cli_version": {"key": "azCliVersion", "type": "str"}, } def __init__( @@ -596,12 +592,12 @@ def __init__( supporting_script_uris: Optional[List[str]] = None, script_content: Optional[str] = None, arguments: Optional[str] = None, - environment_variables: Optional[List["EnvironmentVariable"]] = None, + environment_variables: Optional[List["_models.EnvironmentVariable"]] = None, force_update_tag: Optional[str] = None, - timeout: Optional[datetime.timedelta] = "P1D", - container_settings: Optional["ContainerConfiguration"] = None, - storage_account_settings: Optional["StorageAccountConfiguration"] = None, - cleanup_preference: Optional[Union[str, "CleanupOptions"]] = "Always", + timeout: datetime.timedelta = "P1D", + container_settings: Optional["_models.ContainerConfiguration"] = None, + storage_account_settings: Optional["_models.StorageAccountConfiguration"] = None, + cleanup_preference: Union[str, "_models.CleanupOptions"] = "Always", **kwargs ): """ @@ -621,9 +617,9 @@ def __init__( :keyword force_update_tag: Gets or sets how the deployment script should be forced to execute even if the script resource has not changed. Can be current time stamp or a GUID. :paramtype force_update_tag: str - :keyword retention_interval: Required. Interval for which the service retains the script - resource after it reaches a terminal state. Resource will be deleted when this duration - expires. Duration is based on ISO 8601 pattern (for example P1D means one day). + :keyword retention_interval: Interval for which the service retains the script resource after + it reaches a terminal state. Resource will be deleted when this duration expires. Duration is + based on ISO 8601 pattern (for example P1D means one day). Required. :paramtype retention_interval: ~datetime.timedelta :keyword timeout: Maximum allowed script execution time specified in ISO 8601 format. Default value is P1D. @@ -635,14 +631,27 @@ def __init__( :paramtype storage_account_settings: ~azure.mgmt.resource.deploymentscripts.v2019_10_01_preview.models.StorageAccountConfiguration :keyword cleanup_preference: The clean up preference when the script execution gets in a - terminal state. Default setting is 'Always'. Possible values include: "Always", "OnSuccess", - "OnExpiration". Default value: "Always". + terminal state. Default setting is 'Always'. Known values are: "Always", "OnSuccess", and + "OnExpiration". :paramtype cleanup_preference: str or ~azure.mgmt.resource.deploymentscripts.v2019_10_01_preview.models.CleanupOptions - :keyword az_cli_version: Required. Azure CLI module version to be used. + :keyword az_cli_version: Azure CLI module version to be used. Required. :paramtype az_cli_version: str """ - super(AzureCliScriptProperties, self).__init__(container_settings=container_settings, storage_account_settings=storage_account_settings, cleanup_preference=cleanup_preference, primary_script_uri=primary_script_uri, supporting_script_uris=supporting_script_uris, script_content=script_content, arguments=arguments, environment_variables=environment_variables, force_update_tag=force_update_tag, retention_interval=retention_interval, timeout=timeout, **kwargs) + super().__init__( + container_settings=container_settings, + storage_account_settings=storage_account_settings, + cleanup_preference=cleanup_preference, + primary_script_uri=primary_script_uri, + supporting_script_uris=supporting_script_uris, + script_content=script_content, + arguments=arguments, + environment_variables=environment_variables, + force_update_tag=force_update_tag, + retention_interval=retention_interval, + timeout=timeout, + **kwargs + ) self.primary_script_uri = primary_script_uri self.supporting_script_uris = supporting_script_uris self.script_content = script_content @@ -660,7 +669,7 @@ def __init__( self.outputs = None -class AzurePowerShellScript(DeploymentScript): +class AzurePowerShellScript(DeploymentScript): # pylint: disable=too-many-instance-attributes """Object model for the Azure PowerShell script. Variables are only populated by the server, and will be ignored when sending a request. @@ -673,17 +682,16 @@ class AzurePowerShellScript(DeploymentScript): :vartype name: str :ivar type: Type of this resource. :vartype type: str - :ivar identity: Required. Managed identity to be used for this deployment script. Currently, - only user-assigned MSI is supported. + :ivar identity: Managed identity to be used for this deployment script. Currently, only + user-assigned MSI is supported. Required. :vartype identity: ~azure.mgmt.resource.deploymentscripts.v2019_10_01_preview.models.ManagedServiceIdentity - :ivar location: Required. The location of the ACI and the storage account for the deployment - script. + :ivar location: The location of the ACI and the storage account for the deployment script. + Required. :vartype location: str - :ivar tags: A set of tags. Resource tags. + :ivar tags: Resource tags. :vartype tags: dict[str, str] - :ivar kind: Required. Type of the script.Constant filled by server. Possible values include: - "AzurePowerShell", "AzureCLI". + :ivar kind: Type of the script. Required. Known values are: "AzurePowerShell" and "AzureCLI". :vartype kind: str or ~azure.mgmt.resource.deploymentscripts.v2019_10_01_preview.models.ScriptType :ivar system_data: The system metadata related to this resource. @@ -696,19 +704,19 @@ class AzurePowerShellScript(DeploymentScript): :vartype storage_account_settings: ~azure.mgmt.resource.deploymentscripts.v2019_10_01_preview.models.StorageAccountConfiguration :ivar cleanup_preference: The clean up preference when the script execution gets in a terminal - state. Default setting is 'Always'. Possible values include: "Always", "OnSuccess", - "OnExpiration". Default value: "Always". + state. Default setting is 'Always'. Known values are: "Always", "OnSuccess", and + "OnExpiration". :vartype cleanup_preference: str or ~azure.mgmt.resource.deploymentscripts.v2019_10_01_preview.models.CleanupOptions :ivar provisioning_state: State of the script execution. This only appears in the response. - Possible values include: "Creating", "ProvisioningResources", "Running", "Succeeded", "Failed", + Known values are: "Creating", "ProvisioningResources", "Running", "Succeeded", "Failed", and "Canceled". :vartype provisioning_state: str or ~azure.mgmt.resource.deploymentscripts.v2019_10_01_preview.models.ScriptProvisioningState :ivar status: Contains the results of script execution. :vartype status: ~azure.mgmt.resource.deploymentscripts.v2019_10_01_preview.models.ScriptStatus :ivar outputs: List of script outputs. - :vartype outputs: dict[str, any] + :vartype outputs: dict[str, JSON] :ivar primary_script_uri: Uri for the script. This is the entry point for the external script. :vartype primary_script_uri: str :ivar supporting_script_uris: Supporting files for the external script. @@ -724,88 +732,88 @@ class AzurePowerShellScript(DeploymentScript): :ivar force_update_tag: Gets or sets how the deployment script should be forced to execute even if the script resource has not changed. Can be current time stamp or a GUID. :vartype force_update_tag: str - :ivar retention_interval: Required. Interval for which the service retains the script resource - after it reaches a terminal state. Resource will be deleted when this duration expires. - Duration is based on ISO 8601 pattern (for example P1D means one day). + :ivar retention_interval: Interval for which the service retains the script resource after it + reaches a terminal state. Resource will be deleted when this duration expires. Duration is + based on ISO 8601 pattern (for example P1D means one day). Required. :vartype retention_interval: ~datetime.timedelta :ivar timeout: Maximum allowed script execution time specified in ISO 8601 format. Default value is P1D. :vartype timeout: ~datetime.timedelta - :ivar az_power_shell_version: Required. Azure PowerShell module version to be used. + :ivar az_power_shell_version: Azure PowerShell module version to be used. Required. :vartype az_power_shell_version: str """ _validation = { - 'id': {'readonly': True}, - 'name': {'readonly': True}, - 'type': {'readonly': True}, - 'identity': {'required': True}, - 'location': {'required': True}, - 'kind': {'required': True}, - 'system_data': {'readonly': True}, - 'provisioning_state': {'readonly': True}, - 'status': {'readonly': True}, - 'outputs': {'readonly': True}, - 'script_content': {'max_length': 32000, 'min_length': 0}, - 'retention_interval': {'required': True}, - 'az_power_shell_version': {'required': True}, + "id": {"readonly": True}, + "name": {"readonly": True}, + "type": {"readonly": True}, + "identity": {"required": True}, + "location": {"required": True}, + "kind": {"required": True}, + "system_data": {"readonly": True}, + "provisioning_state": {"readonly": True}, + "status": {"readonly": True}, + "outputs": {"readonly": True}, + "script_content": {"max_length": 32000}, + "retention_interval": {"required": True}, + "az_power_shell_version": {"required": True}, } _attribute_map = { - 'id': {'key': 'id', 'type': 'str'}, - 'name': {'key': 'name', 'type': 'str'}, - 'type': {'key': 'type', 'type': 'str'}, - 'identity': {'key': 'identity', 'type': 'ManagedServiceIdentity'}, - 'location': {'key': 'location', 'type': 'str'}, - 'tags': {'key': 'tags', 'type': '{str}'}, - 'kind': {'key': 'kind', 'type': 'str'}, - 'system_data': {'key': 'systemData', 'type': 'SystemData'}, - 'container_settings': {'key': 'properties.containerSettings', 'type': 'ContainerConfiguration'}, - 'storage_account_settings': {'key': 'properties.storageAccountSettings', 'type': 'StorageAccountConfiguration'}, - 'cleanup_preference': {'key': 'properties.cleanupPreference', 'type': 'str'}, - 'provisioning_state': {'key': 'properties.provisioningState', 'type': 'str'}, - 'status': {'key': 'properties.status', 'type': 'ScriptStatus'}, - 'outputs': {'key': 'properties.outputs', 'type': '{object}'}, - 'primary_script_uri': {'key': 'properties.primaryScriptUri', 'type': 'str'}, - 'supporting_script_uris': {'key': 'properties.supportingScriptUris', 'type': '[str]'}, - 'script_content': {'key': 'properties.scriptContent', 'type': 'str'}, - 'arguments': {'key': 'properties.arguments', 'type': 'str'}, - 'environment_variables': {'key': 'properties.environmentVariables', 'type': '[EnvironmentVariable]'}, - 'force_update_tag': {'key': 'properties.forceUpdateTag', 'type': 'str'}, - 'retention_interval': {'key': 'properties.retentionInterval', 'type': 'duration'}, - 'timeout': {'key': 'properties.timeout', 'type': 'duration'}, - 'az_power_shell_version': {'key': 'properties.azPowerShellVersion', 'type': 'str'}, + "id": {"key": "id", "type": "str"}, + "name": {"key": "name", "type": "str"}, + "type": {"key": "type", "type": "str"}, + "identity": {"key": "identity", "type": "ManagedServiceIdentity"}, + "location": {"key": "location", "type": "str"}, + "tags": {"key": "tags", "type": "{str}"}, + "kind": {"key": "kind", "type": "str"}, + "system_data": {"key": "systemData", "type": "SystemData"}, + "container_settings": {"key": "properties.containerSettings", "type": "ContainerConfiguration"}, + "storage_account_settings": {"key": "properties.storageAccountSettings", "type": "StorageAccountConfiguration"}, + "cleanup_preference": {"key": "properties.cleanupPreference", "type": "str"}, + "provisioning_state": {"key": "properties.provisioningState", "type": "str"}, + "status": {"key": "properties.status", "type": "ScriptStatus"}, + "outputs": {"key": "properties.outputs", "type": "{object}"}, + "primary_script_uri": {"key": "properties.primaryScriptUri", "type": "str"}, + "supporting_script_uris": {"key": "properties.supportingScriptUris", "type": "[str]"}, + "script_content": {"key": "properties.scriptContent", "type": "str"}, + "arguments": {"key": "properties.arguments", "type": "str"}, + "environment_variables": {"key": "properties.environmentVariables", "type": "[EnvironmentVariable]"}, + "force_update_tag": {"key": "properties.forceUpdateTag", "type": "str"}, + "retention_interval": {"key": "properties.retentionInterval", "type": "duration"}, + "timeout": {"key": "properties.timeout", "type": "duration"}, + "az_power_shell_version": {"key": "properties.azPowerShellVersion", "type": "str"}, } def __init__( self, *, - identity: "ManagedServiceIdentity", + identity: "_models.ManagedServiceIdentity", location: str, retention_interval: datetime.timedelta, az_power_shell_version: str, tags: Optional[Dict[str, str]] = None, - container_settings: Optional["ContainerConfiguration"] = None, - storage_account_settings: Optional["StorageAccountConfiguration"] = None, - cleanup_preference: Optional[Union[str, "CleanupOptions"]] = "Always", + container_settings: Optional["_models.ContainerConfiguration"] = None, + storage_account_settings: Optional["_models.StorageAccountConfiguration"] = None, + cleanup_preference: Union[str, "_models.CleanupOptions"] = "Always", primary_script_uri: Optional[str] = None, supporting_script_uris: Optional[List[str]] = None, script_content: Optional[str] = None, arguments: Optional[str] = None, - environment_variables: Optional[List["EnvironmentVariable"]] = None, + environment_variables: Optional[List["_models.EnvironmentVariable"]] = None, force_update_tag: Optional[str] = None, - timeout: Optional[datetime.timedelta] = "P1D", + timeout: datetime.timedelta = "P1D", **kwargs ): """ - :keyword identity: Required. Managed identity to be used for this deployment script. Currently, - only user-assigned MSI is supported. + :keyword identity: Managed identity to be used for this deployment script. Currently, only + user-assigned MSI is supported. Required. :paramtype identity: ~azure.mgmt.resource.deploymentscripts.v2019_10_01_preview.models.ManagedServiceIdentity - :keyword location: Required. The location of the ACI and the storage account for the deployment - script. + :keyword location: The location of the ACI and the storage account for the deployment script. + Required. :paramtype location: str - :keyword tags: A set of tags. Resource tags. + :keyword tags: Resource tags. :paramtype tags: dict[str, str] :keyword container_settings: Container settings. :paramtype container_settings: @@ -814,8 +822,8 @@ def __init__( :paramtype storage_account_settings: ~azure.mgmt.resource.deploymentscripts.v2019_10_01_preview.models.StorageAccountConfiguration :keyword cleanup_preference: The clean up preference when the script execution gets in a - terminal state. Default setting is 'Always'. Possible values include: "Always", "OnSuccess", - "OnExpiration". Default value: "Always". + terminal state. Default setting is 'Always'. Known values are: "Always", "OnSuccess", and + "OnExpiration". :paramtype cleanup_preference: str or ~azure.mgmt.resource.deploymentscripts.v2019_10_01_preview.models.CleanupOptions :keyword primary_script_uri: Uri for the script. This is the entry point for the external @@ -834,18 +842,18 @@ def __init__( :keyword force_update_tag: Gets or sets how the deployment script should be forced to execute even if the script resource has not changed. Can be current time stamp or a GUID. :paramtype force_update_tag: str - :keyword retention_interval: Required. Interval for which the service retains the script - resource after it reaches a terminal state. Resource will be deleted when this duration - expires. Duration is based on ISO 8601 pattern (for example P1D means one day). + :keyword retention_interval: Interval for which the service retains the script resource after + it reaches a terminal state. Resource will be deleted when this duration expires. Duration is + based on ISO 8601 pattern (for example P1D means one day). Required. :paramtype retention_interval: ~datetime.timedelta :keyword timeout: Maximum allowed script execution time specified in ISO 8601 format. Default value is P1D. :paramtype timeout: ~datetime.timedelta - :keyword az_power_shell_version: Required. Azure PowerShell module version to be used. + :keyword az_power_shell_version: Azure PowerShell module version to be used. Required. :paramtype az_power_shell_version: str """ - super(AzurePowerShellScript, self).__init__(identity=identity, location=location, tags=tags, **kwargs) - self.kind = 'AzurePowerShell' # type: str + super().__init__(identity=identity, location=location, tags=tags, **kwargs) + self.kind = "AzurePowerShell" # type: str self.container_settings = container_settings self.storage_account_settings = storage_account_settings self.cleanup_preference = cleanup_preference @@ -863,7 +871,9 @@ def __init__( self.az_power_shell_version = az_power_shell_version -class AzurePowerShellScriptProperties(DeploymentScriptPropertiesBase, ScriptConfigurationBase): +class AzurePowerShellScriptProperties( + DeploymentScriptPropertiesBase, ScriptConfigurationBase +): # pylint: disable=too-many-instance-attributes """Properties of the Azure PowerShell script object. Variables are only populated by the server, and will be ignored when sending a request. @@ -885,9 +895,9 @@ class AzurePowerShellScriptProperties(DeploymentScriptPropertiesBase, ScriptConf :ivar force_update_tag: Gets or sets how the deployment script should be forced to execute even if the script resource has not changed. Can be current time stamp or a GUID. :vartype force_update_tag: str - :ivar retention_interval: Required. Interval for which the service retains the script resource - after it reaches a terminal state. Resource will be deleted when this duration expires. - Duration is based on ISO 8601 pattern (for example P1D means one day). + :ivar retention_interval: Interval for which the service retains the script resource after it + reaches a terminal state. Resource will be deleted when this duration expires. Duration is + based on ISO 8601 pattern (for example P1D means one day). Required. :vartype retention_interval: ~datetime.timedelta :ivar timeout: Maximum allowed script execution time specified in ISO 8601 format. Default value is P1D. @@ -899,48 +909,48 @@ class AzurePowerShellScriptProperties(DeploymentScriptPropertiesBase, ScriptConf :vartype storage_account_settings: ~azure.mgmt.resource.deploymentscripts.v2019_10_01_preview.models.StorageAccountConfiguration :ivar cleanup_preference: The clean up preference when the script execution gets in a terminal - state. Default setting is 'Always'. Possible values include: "Always", "OnSuccess", - "OnExpiration". Default value: "Always". + state. Default setting is 'Always'. Known values are: "Always", "OnSuccess", and + "OnExpiration". :vartype cleanup_preference: str or ~azure.mgmt.resource.deploymentscripts.v2019_10_01_preview.models.CleanupOptions :ivar provisioning_state: State of the script execution. This only appears in the response. - Possible values include: "Creating", "ProvisioningResources", "Running", "Succeeded", "Failed", + Known values are: "Creating", "ProvisioningResources", "Running", "Succeeded", "Failed", and "Canceled". :vartype provisioning_state: str or ~azure.mgmt.resource.deploymentscripts.v2019_10_01_preview.models.ScriptProvisioningState :ivar status: Contains the results of script execution. :vartype status: ~azure.mgmt.resource.deploymentscripts.v2019_10_01_preview.models.ScriptStatus :ivar outputs: List of script outputs. - :vartype outputs: dict[str, any] - :ivar az_power_shell_version: Required. Azure PowerShell module version to be used. + :vartype outputs: dict[str, JSON] + :ivar az_power_shell_version: Azure PowerShell module version to be used. Required. :vartype az_power_shell_version: str """ _validation = { - 'script_content': {'max_length': 32000, 'min_length': 0}, - 'retention_interval': {'required': True}, - 'provisioning_state': {'readonly': True}, - 'status': {'readonly': True}, - 'outputs': {'readonly': True}, - 'az_power_shell_version': {'required': True}, + "script_content": {"max_length": 32000}, + "retention_interval": {"required": True}, + "provisioning_state": {"readonly": True}, + "status": {"readonly": True}, + "outputs": {"readonly": True}, + "az_power_shell_version": {"required": True}, } _attribute_map = { - 'primary_script_uri': {'key': 'primaryScriptUri', 'type': 'str'}, - 'supporting_script_uris': {'key': 'supportingScriptUris', 'type': '[str]'}, - 'script_content': {'key': 'scriptContent', 'type': 'str'}, - 'arguments': {'key': 'arguments', 'type': 'str'}, - 'environment_variables': {'key': 'environmentVariables', 'type': '[EnvironmentVariable]'}, - 'force_update_tag': {'key': 'forceUpdateTag', 'type': 'str'}, - 'retention_interval': {'key': 'retentionInterval', 'type': 'duration'}, - 'timeout': {'key': 'timeout', 'type': 'duration'}, - 'container_settings': {'key': 'containerSettings', 'type': 'ContainerConfiguration'}, - 'storage_account_settings': {'key': 'storageAccountSettings', 'type': 'StorageAccountConfiguration'}, - 'cleanup_preference': {'key': 'cleanupPreference', 'type': 'str'}, - 'provisioning_state': {'key': 'provisioningState', 'type': 'str'}, - 'status': {'key': 'status', 'type': 'ScriptStatus'}, - 'outputs': {'key': 'outputs', 'type': '{object}'}, - 'az_power_shell_version': {'key': 'azPowerShellVersion', 'type': 'str'}, + "primary_script_uri": {"key": "primaryScriptUri", "type": "str"}, + "supporting_script_uris": {"key": "supportingScriptUris", "type": "[str]"}, + "script_content": {"key": "scriptContent", "type": "str"}, + "arguments": {"key": "arguments", "type": "str"}, + "environment_variables": {"key": "environmentVariables", "type": "[EnvironmentVariable]"}, + "force_update_tag": {"key": "forceUpdateTag", "type": "str"}, + "retention_interval": {"key": "retentionInterval", "type": "duration"}, + "timeout": {"key": "timeout", "type": "duration"}, + "container_settings": {"key": "containerSettings", "type": "ContainerConfiguration"}, + "storage_account_settings": {"key": "storageAccountSettings", "type": "StorageAccountConfiguration"}, + "cleanup_preference": {"key": "cleanupPreference", "type": "str"}, + "provisioning_state": {"key": "provisioningState", "type": "str"}, + "status": {"key": "status", "type": "ScriptStatus"}, + "outputs": {"key": "outputs", "type": "{object}"}, + "az_power_shell_version": {"key": "azPowerShellVersion", "type": "str"}, } def __init__( @@ -952,12 +962,12 @@ def __init__( supporting_script_uris: Optional[List[str]] = None, script_content: Optional[str] = None, arguments: Optional[str] = None, - environment_variables: Optional[List["EnvironmentVariable"]] = None, + environment_variables: Optional[List["_models.EnvironmentVariable"]] = None, force_update_tag: Optional[str] = None, - timeout: Optional[datetime.timedelta] = "P1D", - container_settings: Optional["ContainerConfiguration"] = None, - storage_account_settings: Optional["StorageAccountConfiguration"] = None, - cleanup_preference: Optional[Union[str, "CleanupOptions"]] = "Always", + timeout: datetime.timedelta = "P1D", + container_settings: Optional["_models.ContainerConfiguration"] = None, + storage_account_settings: Optional["_models.StorageAccountConfiguration"] = None, + cleanup_preference: Union[str, "_models.CleanupOptions"] = "Always", **kwargs ): """ @@ -977,9 +987,9 @@ def __init__( :keyword force_update_tag: Gets or sets how the deployment script should be forced to execute even if the script resource has not changed. Can be current time stamp or a GUID. :paramtype force_update_tag: str - :keyword retention_interval: Required. Interval for which the service retains the script - resource after it reaches a terminal state. Resource will be deleted when this duration - expires. Duration is based on ISO 8601 pattern (for example P1D means one day). + :keyword retention_interval: Interval for which the service retains the script resource after + it reaches a terminal state. Resource will be deleted when this duration expires. Duration is + based on ISO 8601 pattern (for example P1D means one day). Required. :paramtype retention_interval: ~datetime.timedelta :keyword timeout: Maximum allowed script execution time specified in ISO 8601 format. Default value is P1D. @@ -991,14 +1001,27 @@ def __init__( :paramtype storage_account_settings: ~azure.mgmt.resource.deploymentscripts.v2019_10_01_preview.models.StorageAccountConfiguration :keyword cleanup_preference: The clean up preference when the script execution gets in a - terminal state. Default setting is 'Always'. Possible values include: "Always", "OnSuccess", - "OnExpiration". Default value: "Always". + terminal state. Default setting is 'Always'. Known values are: "Always", "OnSuccess", and + "OnExpiration". :paramtype cleanup_preference: str or ~azure.mgmt.resource.deploymentscripts.v2019_10_01_preview.models.CleanupOptions - :keyword az_power_shell_version: Required. Azure PowerShell module version to be used. + :keyword az_power_shell_version: Azure PowerShell module version to be used. Required. :paramtype az_power_shell_version: str """ - super(AzurePowerShellScriptProperties, self).__init__(container_settings=container_settings, storage_account_settings=storage_account_settings, cleanup_preference=cleanup_preference, primary_script_uri=primary_script_uri, supporting_script_uris=supporting_script_uris, script_content=script_content, arguments=arguments, environment_variables=environment_variables, force_update_tag=force_update_tag, retention_interval=retention_interval, timeout=timeout, **kwargs) + super().__init__( + container_settings=container_settings, + storage_account_settings=storage_account_settings, + cleanup_preference=cleanup_preference, + primary_script_uri=primary_script_uri, + supporting_script_uris=supporting_script_uris, + script_content=script_content, + arguments=arguments, + environment_variables=environment_variables, + force_update_tag=force_update_tag, + retention_interval=retention_interval, + timeout=timeout, + **kwargs + ) self.primary_script_uri = primary_script_uri self.supporting_script_uris = supporting_script_uris self.script_content = script_content @@ -1016,7 +1039,7 @@ def __init__( self.outputs = None -class ContainerConfiguration(msrest.serialization.Model): +class ContainerConfiguration(_serialization.Model): """Settings to customize ACI container instance. :ivar container_group_name: Container group name, if not specified then the name will get @@ -1033,19 +1056,14 @@ class ContainerConfiguration(msrest.serialization.Model): """ _validation = { - 'container_group_name': {'max_length': 63, 'min_length': 1}, + "container_group_name": {"max_length": 63, "min_length": 1}, } _attribute_map = { - 'container_group_name': {'key': 'containerGroupName', 'type': 'str'}, + "container_group_name": {"key": "containerGroupName", "type": "str"}, } - def __init__( - self, - *, - container_group_name: Optional[str] = None, - **kwargs - ): + def __init__(self, *, container_group_name: Optional[str] = None, **kwargs): """ :keyword container_group_name: Container group name, if not specified then the name will get auto-generated. Not specifying a 'containerGroupName' indicates the system to generate a unique @@ -1059,11 +1077,11 @@ def __init__( property. :paramtype container_group_name: str """ - super(ContainerConfiguration, self).__init__(**kwargs) + super().__init__(**kwargs) self.container_group_name = container_group_name -class DeploymentScriptListResult(msrest.serialization.Model): +class DeploymentScriptListResult(_serialization.Model): """List of deployment scripts. Variables are only populated by the server, and will be ignored when sending a request. @@ -1076,31 +1094,26 @@ class DeploymentScriptListResult(msrest.serialization.Model): """ _validation = { - 'next_link': {'readonly': True}, + "next_link": {"readonly": True}, } _attribute_map = { - 'value': {'key': 'value', 'type': '[DeploymentScript]'}, - 'next_link': {'key': 'nextLink', 'type': 'str'}, + "value": {"key": "value", "type": "[DeploymentScript]"}, + "next_link": {"key": "nextLink", "type": "str"}, } - def __init__( - self, - *, - value: Optional[List["DeploymentScript"]] = None, - **kwargs - ): + def __init__(self, *, value: Optional[List["_models.DeploymentScript"]] = None, **kwargs): """ :keyword value: An array of deployment scripts. :paramtype value: list[~azure.mgmt.resource.deploymentscripts.v2019_10_01_preview.models.DeploymentScript] """ - super(DeploymentScriptListResult, self).__init__(**kwargs) + super().__init__(**kwargs) self.value = value self.next_link = None -class DeploymentScriptsError(msrest.serialization.Model): +class DeploymentScriptsError(_serialization.Model): """Deployment scripts error response. :ivar error: Common error response for all Azure Resource Manager APIs to return error details @@ -1109,22 +1122,17 @@ class DeploymentScriptsError(msrest.serialization.Model): """ _attribute_map = { - 'error': {'key': 'error', 'type': 'ErrorResponse'}, + "error": {"key": "error", "type": "ErrorResponse"}, } - def __init__( - self, - *, - error: Optional["ErrorResponse"] = None, - **kwargs - ): + def __init__(self, *, error: Optional["_models.ErrorResponse"] = None, **kwargs): """ :keyword error: Common error response for all Azure Resource Manager APIs to return error details for failed operations. (This also follows the OData error response format.). :paramtype error: ~azure.mgmt.resource.deploymentscripts.v2019_10_01_preview.models.ErrorResponse """ - super(DeploymentScriptsError, self).__init__(**kwargs) + super().__init__(**kwargs) self.error = error @@ -1139,43 +1147,38 @@ class DeploymentScriptUpdateParameter(AzureResourceBase): :vartype name: str :ivar type: Type of this resource. :vartype type: str - :ivar tags: A set of tags. Resource tags to be updated. + :ivar tags: Resource tags to be updated. :vartype tags: dict[str, str] """ _validation = { - 'id': {'readonly': True}, - 'name': {'readonly': True}, - 'type': {'readonly': True}, + "id": {"readonly": True}, + "name": {"readonly": True}, + "type": {"readonly": True}, } _attribute_map = { - 'id': {'key': 'id', 'type': 'str'}, - 'name': {'key': 'name', 'type': 'str'}, - 'type': {'key': 'type', 'type': 'str'}, - 'tags': {'key': 'tags', 'type': '{str}'}, + "id": {"key": "id", "type": "str"}, + "name": {"key": "name", "type": "str"}, + "type": {"key": "type", "type": "str"}, + "tags": {"key": "tags", "type": "{str}"}, } - def __init__( - self, - *, - tags: Optional[Dict[str, str]] = None, - **kwargs - ): + def __init__(self, *, tags: Optional[Dict[str, str]] = None, **kwargs): """ - :keyword tags: A set of tags. Resource tags to be updated. + :keyword tags: Resource tags to be updated. :paramtype tags: dict[str, str] """ - super(DeploymentScriptUpdateParameter, self).__init__(**kwargs) + super().__init__(**kwargs) self.tags = tags -class EnvironmentVariable(msrest.serialization.Model): +class EnvironmentVariable(_serialization.Model): """The environment variable to pass to the script in the container instance. All required parameters must be populated in order to send to Azure. - :ivar name: Required. The name of the environment variable. + :ivar name: The name of the environment variable. Required. :vartype name: str :ivar value: The value of the environment variable. :vartype value: str @@ -1184,38 +1187,31 @@ class EnvironmentVariable(msrest.serialization.Model): """ _validation = { - 'name': {'required': True}, + "name": {"required": True}, } _attribute_map = { - 'name': {'key': 'name', 'type': 'str'}, - 'value': {'key': 'value', 'type': 'str'}, - 'secure_value': {'key': 'secureValue', 'type': 'str'}, + "name": {"key": "name", "type": "str"}, + "value": {"key": "value", "type": "str"}, + "secure_value": {"key": "secureValue", "type": "str"}, } - def __init__( - self, - *, - name: str, - value: Optional[str] = None, - secure_value: Optional[str] = None, - **kwargs - ): + def __init__(self, *, name: str, value: Optional[str] = None, secure_value: Optional[str] = None, **kwargs): """ - :keyword name: Required. The name of the environment variable. + :keyword name: The name of the environment variable. Required. :paramtype name: str :keyword value: The value of the environment variable. :paramtype value: str :keyword secure_value: The value of the secure environment variable. :paramtype secure_value: str """ - super(EnvironmentVariable, self).__init__(**kwargs) + super().__init__(**kwargs) self.name = name self.value = value self.secure_value = secure_value -class ErrorAdditionalInfo(msrest.serialization.Model): +class ErrorAdditionalInfo(_serialization.Model): """The resource management error additional info. Variables are only populated by the server, and will be ignored when sending a request. @@ -1223,31 +1219,27 @@ class ErrorAdditionalInfo(msrest.serialization.Model): :ivar type: The additional info type. :vartype type: str :ivar info: The additional info. - :vartype info: any + :vartype info: JSON """ _validation = { - 'type': {'readonly': True}, - 'info': {'readonly': True}, + "type": {"readonly": True}, + "info": {"readonly": True}, } _attribute_map = { - 'type': {'key': 'type', 'type': 'str'}, - 'info': {'key': 'info', 'type': 'object'}, + "type": {"key": "type", "type": "str"}, + "info": {"key": "info", "type": "object"}, } - def __init__( - self, - **kwargs - ): - """ - """ - super(ErrorAdditionalInfo, self).__init__(**kwargs) + def __init__(self, **kwargs): + """ """ + super().__init__(**kwargs) self.type = None self.info = None -class ErrorResponse(msrest.serialization.Model): +class ErrorResponse(_serialization.Model): """Common error response for all Azure Resource Manager APIs to return error details for failed operations. (This also follows the OData error response format.). Variables are only populated by the server, and will be ignored when sending a request. @@ -1267,28 +1259,24 @@ class ErrorResponse(msrest.serialization.Model): """ _validation = { - 'code': {'readonly': True}, - 'message': {'readonly': True}, - 'target': {'readonly': True}, - 'details': {'readonly': True}, - 'additional_info': {'readonly': True}, + "code": {"readonly": True}, + "message": {"readonly": True}, + "target": {"readonly": True}, + "details": {"readonly": True}, + "additional_info": {"readonly": True}, } _attribute_map = { - 'code': {'key': 'code', 'type': 'str'}, - 'message': {'key': 'message', 'type': 'str'}, - 'target': {'key': 'target', 'type': 'str'}, - 'details': {'key': 'details', 'type': '[ErrorResponse]'}, - 'additional_info': {'key': 'additionalInfo', 'type': '[ErrorAdditionalInfo]'}, + "code": {"key": "code", "type": "str"}, + "message": {"key": "message", "type": "str"}, + "target": {"key": "target", "type": "str"}, + "details": {"key": "details", "type": "[ErrorResponse]"}, + "additional_info": {"key": "additionalInfo", "type": "[ErrorAdditionalInfo]"}, } - def __init__( - self, - **kwargs - ): - """ - """ - super(ErrorResponse, self).__init__(**kwargs) + def __init__(self, **kwargs): + """ """ + super().__init__(**kwargs) self.code = None self.message = None self.target = None @@ -1296,12 +1284,12 @@ def __init__( self.additional_info = None -class ManagedServiceIdentity(msrest.serialization.Model): +class ManagedServiceIdentity(_serialization.Model): """Managed identity generic object. Variables are only populated by the server, and will be ignored when sending a request. - :ivar type: Type of the managed identity. Possible values include: "UserAssigned". + :ivar type: Type of the managed identity. "UserAssigned" :vartype type: str or ~azure.mgmt.resource.deploymentscripts.v2019_10_01_preview.models.ManagedServiceIdentityType :ivar tenant_id: ID of the Azure Active Directory. @@ -1313,24 +1301,24 @@ class ManagedServiceIdentity(msrest.serialization.Model): """ _validation = { - 'tenant_id': {'readonly': True}, + "tenant_id": {"readonly": True}, } _attribute_map = { - 'type': {'key': 'type', 'type': 'str'}, - 'tenant_id': {'key': 'tenantId', 'type': 'str'}, - 'user_assigned_identities': {'key': 'userAssignedIdentities', 'type': '{UserAssignedIdentity}'}, + "type": {"key": "type", "type": "str"}, + "tenant_id": {"key": "tenantId", "type": "str"}, + "user_assigned_identities": {"key": "userAssignedIdentities", "type": "{UserAssignedIdentity}"}, } def __init__( self, *, - type: Optional[Union[str, "ManagedServiceIdentityType"]] = None, - user_assigned_identities: Optional[Dict[str, "UserAssignedIdentity"]] = None, + type: Optional[Union[str, "_models.ManagedServiceIdentityType"]] = None, + user_assigned_identities: Optional[Dict[str, "_models.UserAssignedIdentity"]] = None, **kwargs ): """ - :keyword type: Type of the managed identity. Possible values include: "UserAssigned". + :keyword type: Type of the managed identity. "UserAssigned" :paramtype type: str or ~azure.mgmt.resource.deploymentscripts.v2019_10_01_preview.models.ManagedServiceIdentityType :keyword user_assigned_identities: The list of user-assigned managed identities associated with @@ -1338,7 +1326,7 @@ def __init__( :paramtype user_assigned_identities: dict[str, ~azure.mgmt.resource.deploymentscripts.v2019_10_01_preview.models.UserAssignedIdentity] """ - super(ManagedServiceIdentity, self).__init__(**kwargs) + super().__init__(**kwargs) self.type = type self.tenant_id = None self.user_assigned_identities = user_assigned_identities @@ -1360,30 +1348,26 @@ class ScriptLog(AzureResourceBase): """ _validation = { - 'id': {'readonly': True}, - 'name': {'readonly': True}, - 'type': {'readonly': True}, - 'log': {'readonly': True}, + "id": {"readonly": True}, + "name": {"readonly": True}, + "type": {"readonly": True}, + "log": {"readonly": True}, } _attribute_map = { - 'id': {'key': 'id', 'type': 'str'}, - 'name': {'key': 'name', 'type': 'str'}, - 'type': {'key': 'type', 'type': 'str'}, - 'log': {'key': 'properties.log', 'type': 'str'}, + "id": {"key": "id", "type": "str"}, + "name": {"key": "name", "type": "str"}, + "type": {"key": "type", "type": "str"}, + "log": {"key": "properties.log", "type": "str"}, } - def __init__( - self, - **kwargs - ): - """ - """ - super(ScriptLog, self).__init__(**kwargs) + def __init__(self, **kwargs): + """ """ + super().__init__(**kwargs) self.log = None -class ScriptLogsList(msrest.serialization.Model): +class ScriptLogsList(_serialization.Model): """Deployment script execution logs. :ivar value: Deployment scripts logs. @@ -1392,25 +1376,20 @@ class ScriptLogsList(msrest.serialization.Model): """ _attribute_map = { - 'value': {'key': 'value', 'type': '[ScriptLog]'}, + "value": {"key": "value", "type": "[ScriptLog]"}, } - def __init__( - self, - *, - value: Optional[List["ScriptLog"]] = None, - **kwargs - ): + def __init__(self, *, value: Optional[List["_models.ScriptLog"]] = None, **kwargs): """ :keyword value: Deployment scripts logs. :paramtype value: list[~azure.mgmt.resource.deploymentscripts.v2019_10_01_preview.models.ScriptLog] """ - super(ScriptLogsList, self).__init__(**kwargs) + super().__init__(**kwargs) self.value = value -class ScriptStatus(msrest.serialization.Model): +class ScriptStatus(_serialization.Model): """Generic object modeling results of script execution. Variables are only populated by the server, and will be ignored when sending a request. @@ -1430,34 +1409,29 @@ class ScriptStatus(msrest.serialization.Model): """ _validation = { - 'container_instance_id': {'readonly': True}, - 'storage_account_id': {'readonly': True}, - 'start_time': {'readonly': True}, - 'end_time': {'readonly': True}, - 'expiration_time': {'readonly': True}, + "container_instance_id": {"readonly": True}, + "storage_account_id": {"readonly": True}, + "start_time": {"readonly": True}, + "end_time": {"readonly": True}, + "expiration_time": {"readonly": True}, } _attribute_map = { - 'container_instance_id': {'key': 'containerInstanceId', 'type': 'str'}, - 'storage_account_id': {'key': 'storageAccountId', 'type': 'str'}, - 'start_time': {'key': 'startTime', 'type': 'iso-8601'}, - 'end_time': {'key': 'endTime', 'type': 'iso-8601'}, - 'expiration_time': {'key': 'expirationTime', 'type': 'iso-8601'}, - 'error': {'key': 'error', 'type': 'ErrorResponse'}, + "container_instance_id": {"key": "containerInstanceId", "type": "str"}, + "storage_account_id": {"key": "storageAccountId", "type": "str"}, + "start_time": {"key": "startTime", "type": "iso-8601"}, + "end_time": {"key": "endTime", "type": "iso-8601"}, + "expiration_time": {"key": "expirationTime", "type": "iso-8601"}, + "error": {"key": "error", "type": "ErrorResponse"}, } - def __init__( - self, - *, - error: Optional["ErrorResponse"] = None, - **kwargs - ): + def __init__(self, *, error: Optional["_models.ErrorResponse"] = None, **kwargs): """ :keyword error: Error that is relayed from the script execution. :paramtype error: ~azure.mgmt.resource.deploymentscripts.v2019_10_01_preview.models.ErrorResponse """ - super(ScriptStatus, self).__init__(**kwargs) + super().__init__(**kwargs) self.container_instance_id = None self.storage_account_id = None self.start_time = None @@ -1466,7 +1440,7 @@ def __init__( self.error = error -class StorageAccountConfiguration(msrest.serialization.Model): +class StorageAccountConfiguration(_serialization.Model): """Settings to use an existing storage account. Valid storage account kinds are: Storage, StorageV2 and FileStorage. :ivar storage_account_name: The storage account name. @@ -1476,16 +1450,12 @@ class StorageAccountConfiguration(msrest.serialization.Model): """ _attribute_map = { - 'storage_account_name': {'key': 'storageAccountName', 'type': 'str'}, - 'storage_account_key': {'key': 'storageAccountKey', 'type': 'str'}, + "storage_account_name": {"key": "storageAccountName", "type": "str"}, + "storage_account_key": {"key": "storageAccountKey", "type": "str"}, } def __init__( - self, - *, - storage_account_name: Optional[str] = None, - storage_account_key: Optional[str] = None, - **kwargs + self, *, storage_account_name: Optional[str] = None, storage_account_key: Optional[str] = None, **kwargs ): """ :keyword storage_account_name: The storage account name. @@ -1493,26 +1463,26 @@ def __init__( :keyword storage_account_key: The storage account access key. :paramtype storage_account_key: str """ - super(StorageAccountConfiguration, self).__init__(**kwargs) + super().__init__(**kwargs) self.storage_account_name = storage_account_name self.storage_account_key = storage_account_key -class SystemData(msrest.serialization.Model): +class SystemData(_serialization.Model): """Metadata pertaining to creation and last modification of the resource. :ivar created_by: The identity that created the resource. :vartype created_by: str - :ivar created_by_type: The type of identity that created the resource. Possible values include: - "User", "Application", "ManagedIdentity", "Key". + :ivar created_by_type: The type of identity that created the resource. Known values are: + "User", "Application", "ManagedIdentity", and "Key". :vartype created_by_type: str or ~azure.mgmt.resource.deploymentscripts.v2019_10_01_preview.models.CreatedByType :ivar created_at: The timestamp of resource creation (UTC). :vartype created_at: ~datetime.datetime :ivar last_modified_by: The identity that last modified the resource. :vartype last_modified_by: str - :ivar last_modified_by_type: The type of identity that last modified the resource. Possible - values include: "User", "Application", "ManagedIdentity", "Key". + :ivar last_modified_by_type: The type of identity that last modified the resource. Known values + are: "User", "Application", "ManagedIdentity", and "Key". :vartype last_modified_by_type: str or ~azure.mgmt.resource.deploymentscripts.v2019_10_01_preview.models.CreatedByType :ivar last_modified_at: The timestamp of resource last modification (UTC). @@ -1520,44 +1490,44 @@ class SystemData(msrest.serialization.Model): """ _attribute_map = { - 'created_by': {'key': 'createdBy', 'type': 'str'}, - 'created_by_type': {'key': 'createdByType', 'type': 'str'}, - 'created_at': {'key': 'createdAt', 'type': 'iso-8601'}, - 'last_modified_by': {'key': 'lastModifiedBy', 'type': 'str'}, - 'last_modified_by_type': {'key': 'lastModifiedByType', 'type': 'str'}, - 'last_modified_at': {'key': 'lastModifiedAt', 'type': 'iso-8601'}, + "created_by": {"key": "createdBy", "type": "str"}, + "created_by_type": {"key": "createdByType", "type": "str"}, + "created_at": {"key": "createdAt", "type": "iso-8601"}, + "last_modified_by": {"key": "lastModifiedBy", "type": "str"}, + "last_modified_by_type": {"key": "lastModifiedByType", "type": "str"}, + "last_modified_at": {"key": "lastModifiedAt", "type": "iso-8601"}, } def __init__( self, *, created_by: Optional[str] = None, - created_by_type: Optional[Union[str, "CreatedByType"]] = None, + created_by_type: Optional[Union[str, "_models.CreatedByType"]] = None, created_at: Optional[datetime.datetime] = None, last_modified_by: Optional[str] = None, - last_modified_by_type: Optional[Union[str, "CreatedByType"]] = None, + last_modified_by_type: Optional[Union[str, "_models.CreatedByType"]] = None, last_modified_at: Optional[datetime.datetime] = None, **kwargs ): """ :keyword created_by: The identity that created the resource. :paramtype created_by: str - :keyword created_by_type: The type of identity that created the resource. Possible values - include: "User", "Application", "ManagedIdentity", "Key". + :keyword created_by_type: The type of identity that created the resource. Known values are: + "User", "Application", "ManagedIdentity", and "Key". :paramtype created_by_type: str or ~azure.mgmt.resource.deploymentscripts.v2019_10_01_preview.models.CreatedByType :keyword created_at: The timestamp of resource creation (UTC). :paramtype created_at: ~datetime.datetime :keyword last_modified_by: The identity that last modified the resource. :paramtype last_modified_by: str - :keyword last_modified_by_type: The type of identity that last modified the resource. Possible - values include: "User", "Application", "ManagedIdentity", "Key". + :keyword last_modified_by_type: The type of identity that last modified the resource. Known + values are: "User", "Application", "ManagedIdentity", and "Key". :paramtype last_modified_by_type: str or ~azure.mgmt.resource.deploymentscripts.v2019_10_01_preview.models.CreatedByType :keyword last_modified_at: The timestamp of resource last modification (UTC). :paramtype last_modified_at: ~datetime.datetime """ - super(SystemData, self).__init__(**kwargs) + super().__init__(**kwargs) self.created_by = created_by self.created_by_type = created_by_type self.created_at = created_at @@ -1566,7 +1536,7 @@ def __init__( self.last_modified_at = last_modified_at -class UserAssignedIdentity(msrest.serialization.Model): +class UserAssignedIdentity(_serialization.Model): """User-assigned managed identity. Variables are only populated by the server, and will be ignored when sending a request. @@ -1578,21 +1548,17 @@ class UserAssignedIdentity(msrest.serialization.Model): """ _validation = { - 'principal_id': {'readonly': True}, - 'client_id': {'readonly': True}, + "principal_id": {"readonly": True}, + "client_id": {"readonly": True}, } _attribute_map = { - 'principal_id': {'key': 'principalId', 'type': 'str'}, - 'client_id': {'key': 'clientId', 'type': 'str'}, + "principal_id": {"key": "principalId", "type": "str"}, + "client_id": {"key": "clientId", "type": "str"}, } - def __init__( - self, - **kwargs - ): - """ - """ - super(UserAssignedIdentity, self).__init__(**kwargs) + def __init__(self, **kwargs): + """ """ + super().__init__(**kwargs) self.principal_id = None self.client_id = None diff --git a/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/deploymentscripts/v2019_10_01_preview/models/_patch.py b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/deploymentscripts/v2019_10_01_preview/models/_patch.py new file mode 100644 index 0000000000000..f7dd32510333d --- /dev/null +++ b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/deploymentscripts/v2019_10_01_preview/models/_patch.py @@ -0,0 +1,20 @@ +# ------------------------------------ +# Copyright (c) Microsoft Corporation. +# Licensed under the MIT License. +# ------------------------------------ +"""Customize generated code here. + +Follow our quickstart for examples: https://aka.ms/azsdk/python/dpcodegen/python/customize +""" +from typing import List + +__all__: List[str] = [] # Add all objects you want publicly available to users at this package level + + +def patch_sdk(): + """Do not remove from this file. + + `patch_sdk` is a last resort escape hatch that allows you to do customizations + you can't accomplish using the techniques described in + https://aka.ms/azsdk/python/dpcodegen/python/customize + """ diff --git a/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/deploymentscripts/v2019_10_01_preview/operations/__init__.py b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/deploymentscripts/v2019_10_01_preview/operations/__init__.py index 2a9499c638ccc..15dd692e91d23 100644 --- a/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/deploymentscripts/v2019_10_01_preview/operations/__init__.py +++ b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/deploymentscripts/v2019_10_01_preview/operations/__init__.py @@ -8,6 +8,12 @@ from ._operations import DeploymentScriptsOperations +from ._patch import __all__ as _patch_all +from ._patch import * # type: ignore # pylint: disable=unused-wildcard-import +from ._patch import patch_sdk as _patch_sdk + __all__ = [ - 'DeploymentScriptsOperations', + "DeploymentScriptsOperations", ] +__all__.extend([p for p in _patch_all if p not in __all__]) +_patch_sdk() diff --git a/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/deploymentscripts/v2019_10_01_preview/operations/_operations.py b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/deploymentscripts/v2019_10_01_preview/operations/_operations.py index a6d5199373a26..3291db8a7fafa 100644 --- a/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/deploymentscripts/v2019_10_01_preview/operations/_operations.py +++ b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/deploymentscripts/v2019_10_01_preview/operations/_operations.py @@ -6,424 +6,485 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -from typing import Any, Callable, Dict, Iterable, Optional, TypeVar, Union - -from msrest import Serializer - -from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error +from typing import Any, Callable, Dict, IO, Iterable, Optional, TypeVar, Union, cast, overload +from urllib.parse import parse_qs, urljoin, urlparse + +from azure.core.exceptions import ( + ClientAuthenticationError, + HttpResponseError, + ResourceExistsError, + ResourceNotFoundError, + ResourceNotModifiedError, + map_error, +) from azure.core.paging import ItemPaged from azure.core.pipeline import PipelineResponse from azure.core.pipeline.transport import HttpResponse from azure.core.polling import LROPoller, NoPolling, PollingMethod from azure.core.rest import HttpRequest from azure.core.tracing.decorator import distributed_trace +from azure.core.utils import case_insensitive_dict from azure.mgmt.core.exceptions import ARMErrorFormat from azure.mgmt.core.polling.arm_polling import ARMPolling from .. import models as _models +from ..._serialization import Serializer from .._vendor import _convert_request, _format_url_section -T = TypeVar('T') -JSONType = Any + +T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] _SERIALIZER = Serializer() _SERIALIZER.client_side_validation = False -def build_deployment_scripts_create_request_initial( - subscription_id: str, - resource_group_name: str, - script_name: str, - *, - json: JSONType = None, - content: Any = None, - **kwargs: Any + +def build_deployment_scripts_create_request( + resource_group_name: str, script_name: str, subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2019-10-01-preview") # type: str - content_type = kwargs.pop('content_type', None) # type: Optional[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", "2019-10-01-preview")) # type: str + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + accept = _headers.pop("Accept", "application/json") - accept = "application/json" # Construct URL - _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/Microsoft.Resources/deploymentScripts/{scriptName}") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/Microsoft.Resources/deploymentScripts/{scriptName}", + ) # pylint: disable=line-too-long path_format_arguments = { - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._\(\)]+$'), - "scriptName": _SERIALIZER.url("script_name", script_name, 'str', max_length=90, min_length=1), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url( + "resource_group_name", resource_group_name, "str", max_length=90, min_length=1, pattern=r"^[-\w\._\(\)]+$" + ), + "scriptName": _SERIALIZER.url("script_name", script_name, "str", max_length=90, min_length=1), } _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] if content_type is not None: - _header_parameters['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') - _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers["Content-Type"] = _SERIALIZER.header("content_type", content_type, "str") + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - return HttpRequest( - method="PUT", - url=_url, - params=_query_parameters, - headers=_header_parameters, - json=json, - content=content, - **kwargs - ) + return HttpRequest(method="PUT", url=_url, params=_params, headers=_headers, **kwargs) def build_deployment_scripts_update_request( - subscription_id: str, - resource_group_name: str, - script_name: str, - *, - json: JSONType = None, - content: Any = None, - **kwargs: Any + resource_group_name: str, script_name: str, subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2019-10-01-preview") # type: str - content_type = kwargs.pop('content_type', None) # type: Optional[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", "2019-10-01-preview")) # type: str + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + accept = _headers.pop("Accept", "application/json") - accept = "application/json" # Construct URL - _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/Microsoft.Resources/deploymentScripts/{scriptName}") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/Microsoft.Resources/deploymentScripts/{scriptName}", + ) # pylint: disable=line-too-long path_format_arguments = { - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._\(\)]+$'), - "scriptName": _SERIALIZER.url("script_name", script_name, 'str', max_length=90, min_length=1), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url( + "resource_group_name", resource_group_name, "str", max_length=90, min_length=1, pattern=r"^[-\w\._\(\)]+$" + ), + "scriptName": _SERIALIZER.url("script_name", script_name, "str", max_length=90, min_length=1), } _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] if content_type is not None: - _header_parameters['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') - _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers["Content-Type"] = _SERIALIZER.header("content_type", content_type, "str") + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - return HttpRequest( - method="PATCH", - url=_url, - params=_query_parameters, - headers=_header_parameters, - json=json, - content=content, - **kwargs - ) + return HttpRequest(method="PATCH", url=_url, params=_params, headers=_headers, **kwargs) def build_deployment_scripts_get_request( - subscription_id: str, - resource_group_name: str, - script_name: str, - **kwargs: Any + resource_group_name: str, script_name: str, subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2019-10-01-preview") # type: 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", "2019-10-01-preview")) # type: str + accept = _headers.pop("Accept", "application/json") - accept = "application/json" # Construct URL - _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/Microsoft.Resources/deploymentScripts/{scriptName}") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/Microsoft.Resources/deploymentScripts/{scriptName}", + ) # pylint: disable=line-too-long path_format_arguments = { - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._\(\)]+$'), - "scriptName": _SERIALIZER.url("script_name", script_name, 'str', max_length=90, min_length=1), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url( + "resource_group_name", resource_group_name, "str", max_length=90, min_length=1, pattern=r"^[-\w\._\(\)]+$" + ), + "scriptName": _SERIALIZER.url("script_name", script_name, "str", max_length=90, min_length=1), } _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - return HttpRequest( - method="GET", - url=_url, - params=_query_parameters, - headers=_header_parameters, - **kwargs - ) + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) def build_deployment_scripts_delete_request( - subscription_id: str, - resource_group_name: str, - script_name: str, - **kwargs: Any + resource_group_name: str, script_name: str, subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2019-10-01-preview") # type: 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", "2019-10-01-preview")) # type: str + accept = _headers.pop("Accept", "application/json") - accept = "application/json" # Construct URL - _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/Microsoft.Resources/deploymentScripts/{scriptName}") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/Microsoft.Resources/deploymentScripts/{scriptName}", + ) # pylint: disable=line-too-long path_format_arguments = { - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._\(\)]+$'), - "scriptName": _SERIALIZER.url("script_name", script_name, 'str', max_length=90, min_length=1), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url( + "resource_group_name", resource_group_name, "str", max_length=90, min_length=1, pattern=r"^[-\w\._\(\)]+$" + ), + "scriptName": _SERIALIZER.url("script_name", script_name, "str", max_length=90, min_length=1), } _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - return HttpRequest( - method="DELETE", - url=_url, - params=_query_parameters, - headers=_header_parameters, - **kwargs - ) + return HttpRequest(method="DELETE", url=_url, params=_params, headers=_headers, **kwargs) -def build_deployment_scripts_list_by_subscription_request( - subscription_id: str, - **kwargs: Any -) -> HttpRequest: - api_version = kwargs.pop('api_version', "2019-10-01-preview") # type: str +def build_deployment_scripts_list_by_subscription_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", "2019-10-01-preview")) # type: str + accept = _headers.pop("Accept", "application/json") - accept = "application/json" # Construct URL _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/providers/Microsoft.Resources/deploymentScripts") path_format_arguments = { - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), } _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - return HttpRequest( - method="GET", - url=_url, - params=_query_parameters, - headers=_header_parameters, - **kwargs - ) + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) def build_deployment_scripts_get_logs_request( - subscription_id: str, - resource_group_name: str, - script_name: str, - **kwargs: Any + resource_group_name: str, script_name: str, subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2019-10-01-preview") # type: 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", "2019-10-01-preview")) # type: str + accept = _headers.pop("Accept", "application/json") - accept = "application/json" # Construct URL - _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/Microsoft.Resources/deploymentScripts/{scriptName}/logs") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/Microsoft.Resources/deploymentScripts/{scriptName}/logs", + ) # pylint: disable=line-too-long path_format_arguments = { - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._\(\)]+$'), - "scriptName": _SERIALIZER.url("script_name", script_name, 'str', max_length=90, min_length=1), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url( + "resource_group_name", resource_group_name, "str", max_length=90, min_length=1, pattern=r"^[-\w\._\(\)]+$" + ), + "scriptName": _SERIALIZER.url("script_name", script_name, "str", max_length=90, min_length=1), } _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - return HttpRequest( - method="GET", - url=_url, - params=_query_parameters, - headers=_header_parameters, - **kwargs - ) + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) def build_deployment_scripts_get_logs_default_request( - subscription_id: str, - resource_group_name: str, - script_name: str, - *, - tail: Optional[int] = None, - **kwargs: Any + resource_group_name: str, script_name: str, subscription_id: str, *, tail: Optional[int] = None, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2019-10-01-preview") # type: 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", "2019-10-01-preview")) # type: str + accept = _headers.pop("Accept", "application/json") - accept = "application/json" # Construct URL - _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/Microsoft.Resources/deploymentScripts/{scriptName}/logs/default") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/Microsoft.Resources/deploymentScripts/{scriptName}/logs/default", + ) # pylint: disable=line-too-long path_format_arguments = { - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._\(\)]+$'), - "scriptName": _SERIALIZER.url("script_name", script_name, 'str', max_length=90, min_length=1), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url( + "resource_group_name", resource_group_name, "str", max_length=90, min_length=1, pattern=r"^[-\w\._\(\)]+$" + ), + "scriptName": _SERIALIZER.url("script_name", script_name, "str", max_length=90, min_length=1), } _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") if tail is not None: - _query_parameters['tail'] = _SERIALIZER.query("tail", tail, 'int') + _params["tail"] = _SERIALIZER.query("tail", tail, "int") # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - return HttpRequest( - method="GET", - url=_url, - params=_query_parameters, - headers=_header_parameters, - **kwargs - ) + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) def build_deployment_scripts_list_by_resource_group_request( - subscription_id: str, - resource_group_name: str, - **kwargs: Any + resource_group_name: str, subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2019-10-01-preview") # type: 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", "2019-10-01-preview")) # type: str + accept = _headers.pop("Accept", "application/json") - accept = "application/json" # Construct URL - _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/Microsoft.Resources/deploymentScripts") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/Microsoft.Resources/deploymentScripts", + ) # pylint: disable=line-too-long path_format_arguments = { - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._\(\)]+$'), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url( + "resource_group_name", resource_group_name, "str", max_length=90, min_length=1, pattern=r"^[-\w\._\(\)]+$" + ), } _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') - - return HttpRequest( - method="GET", - url=_url, - params=_query_parameters, - headers=_header_parameters, - **kwargs - ) - -class DeploymentScriptsOperations(object): - """DeploymentScriptsOperations operations. - - You should not instantiate this class directly. Instead, you should create a Client instance that - instantiates it for you and attaches it as an attribute. - - :ivar models: Alias to model classes used in this operation group. - :type models: ~azure.mgmt.resource.deploymentscripts.v2019_10_01_preview.models - :param client: Client for service requests. - :param config: Configuration of service client. - :param serializer: An object model serializer. - :param deserializer: An object model deserializer. + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) + + +class DeploymentScriptsOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. + + Instead, you should access the following operations through + :class:`~azure.mgmt.resource.deploymentscripts.v2019_10_01_preview.DeploymentScriptsClient`'s + :attr:`deployment_scripts` attribute. """ models = _models - def __init__(self, client, config, serializer, deserializer): - self._client = client - self._serialize = serializer - self._deserialize = deserializer - self._config = config + def __init__(self, *args, **kwargs): + input_args = list(args) + self._client = input_args.pop(0) if input_args else kwargs.pop("client") + self._config = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") def _create_initial( self, resource_group_name: str, script_name: str, - deployment_script: "_models.DeploymentScript", + deployment_script: Union[_models.DeploymentScript, IO], **kwargs: Any - ) -> "_models.DeploymentScript": - cls = kwargs.pop('cls', None) # type: ClsType["_models.DeploymentScript"] + ) -> _models.DeploymentScript: error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) - api_version = kwargs.pop('api_version', "2019-10-01-preview") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - _json = self._serialize.body(deployment_script, 'DeploymentScript') + api_version = kwargs.pop("api_version", _params.pop("api-version", "2019-10-01-preview")) # type: str + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.DeploymentScript] - request = build_deployment_scripts_create_request_initial( - subscription_id=self._config.subscription_id, + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(deployment_script, (IO, bytes)): + _content = deployment_script + else: + _json = self._serialize.body(deployment_script, "DeploymentScript") + + request = build_deployment_scripts_create_request( resource_group_name=resource_group_name, script_name=script_name, + subscription_id=self._config.subscription_id, api_version=api_version, content_type=content_type, json=_json, - template_url=self._create_initial.metadata['url'], + content=_content, + template_url=self._create_initial.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200, 201]: map_error(status_code=response.status_code, response=response, error_map=error_map) - raise HttpResponseError(response=response, error_format=ARMErrorFormat) + error = self._deserialize.failsafe_deserialize(_models.DeploymentScriptsError, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) if response.status_code == 200: - deserialized = self._deserialize('DeploymentScript', pipeline_response) + deserialized = self._deserialize("DeploymentScript", pipeline_response) if response.status_code == 201: - deserialized = self._deserialize('DeploymentScript', pipeline_response) + deserialized = self._deserialize("DeploymentScript", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - _create_initial.metadata = {'url': "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/Microsoft.Resources/deploymentScripts/{scriptName}"} # type: ignore + _create_initial.metadata = {"url": "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/Microsoft.Resources/deploymentScripts/{scriptName}"} # type: ignore + + @overload + def begin_create( + self, + resource_group_name: str, + script_name: str, + deployment_script: _models.DeploymentScript, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> LROPoller[_models.DeploymentScript]: + """Creates a deployment script. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param script_name: Name of the deployment script. Required. + :type script_name: str + :param deployment_script: Deployment script supplied to the operation. Required. + :type deployment_script: + ~azure.mgmt.resource.deploymentscripts.v2019_10_01_preview.models.DeploymentScript + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be ARMPolling. Pass in False for this + operation to not poll, or pass in your own initialized polling object for a personal polling + strategy. + :paramtype polling: bool or ~azure.core.polling.PollingMethod + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of LROPoller that returns either DeploymentScript or the result of + cls(response) + :rtype: + ~azure.core.polling.LROPoller[~azure.mgmt.resource.deploymentscripts.v2019_10_01_preview.models.DeploymentScript] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + def begin_create( + self, + resource_group_name: str, + script_name: str, + deployment_script: IO, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> LROPoller[_models.DeploymentScript]: + """Creates a deployment script. + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param script_name: Name of the deployment script. Required. + :type script_name: str + :param deployment_script: Deployment script supplied to the operation. Required. + :type deployment_script: IO + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be ARMPolling. Pass in False for this + operation to not poll, or pass in your own initialized polling object for a personal polling + strategy. + :paramtype polling: bool or ~azure.core.polling.PollingMethod + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of LROPoller that returns either DeploymentScript or the result of + cls(response) + :rtype: + ~azure.core.polling.LROPoller[~azure.mgmt.resource.deploymentscripts.v2019_10_01_preview.models.DeploymentScript] + :raises ~azure.core.exceptions.HttpResponseError: + """ @distributed_trace def begin_create( self, resource_group_name: str, script_name: str, - deployment_script: "_models.DeploymentScript", + deployment_script: Union[_models.DeploymentScript, IO], **kwargs: Any - ) -> LROPoller["_models.DeploymentScript"]: + ) -> LROPoller[_models.DeploymentScript]: """Creates a deployment script. :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. :type resource_group_name: str - :param script_name: Name of the deployment script. + :param script_name: Name of the deployment script. Required. :type script_name: str - :param deployment_script: Deployment script supplied to the operation. + :param deployment_script: Deployment script supplied to the operation. Is either a model type + or a IO type. Required. :type deployment_script: - ~azure.mgmt.resource.deploymentscripts.v2019_10_01_preview.models.DeploymentScript + ~azure.mgmt.resource.deploymentscripts.v2019_10_01_preview.models.DeploymentScript or IO + :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. + Default value is None. + :paramtype content_type: str :keyword callable cls: A custom type or function that will be passed the direct response :keyword str continuation_token: A continuation token to restart a poller from a saved state. :keyword polling: By default, your polling method will be ARMPolling. Pass in False for this @@ -436,105 +497,186 @@ def begin_create( cls(response) :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.resource.deploymentscripts.v2019_10_01_preview.models.DeploymentScript] - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - api_version = kwargs.pop('api_version', "2019-10-01-preview") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] - polling = kwargs.pop('polling', True) # type: Union[bool, PollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType["_models.DeploymentScript"] - lro_delay = kwargs.pop( - 'polling_interval', - self._config.polling_interval - ) - cont_token = kwargs.pop('continuation_token', None) # type: Optional[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", "2019-10-01-preview")) # type: str + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.DeploymentScript] + polling = kwargs.pop("polling", True) # type: Union[bool, PollingMethod] + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token = kwargs.pop("continuation_token", None) # type: Optional[str] if cont_token is None: - raw_result = self._create_initial( + raw_result = self._create_initial( # type: ignore resource_group_name=resource_group_name, script_name=script_name, deployment_script=deployment_script, api_version=api_version, content_type=content_type, - cls=lambda x,y,z: x, + cls=lambda x, y, z: x, + headers=_headers, + params=_params, **kwargs ) - kwargs.pop('error_map', None) + kwargs.pop("error_map", None) def get_long_running_output(pipeline_response): - response = pipeline_response.http_response - deserialized = self._deserialize('DeploymentScript', pipeline_response) + deserialized = self._deserialize("DeploymentScript", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - - if polling is True: polling_method = ARMPolling(lro_delay, **kwargs) - elif polling is False: polling_method = NoPolling() - else: polling_method = polling + if polling is True: + polling_method = cast(PollingMethod, ARMPolling(lro_delay, **kwargs)) # type: PollingMethod + elif polling is False: + polling_method = cast(PollingMethod, NoPolling()) + else: + polling_method = polling if cont_token: return LROPoller.from_continuation_token( polling_method=polling_method, continuation_token=cont_token, client=self._client, - deserialization_callback=get_long_running_output + deserialization_callback=get_long_running_output, ) return LROPoller(self._client, raw_result, get_long_running_output, polling_method) - begin_create.metadata = {'url': "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/Microsoft.Resources/deploymentScripts/{scriptName}"} # type: ignore + begin_create.metadata = {"url": "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/Microsoft.Resources/deploymentScripts/{scriptName}"} # type: ignore - @distributed_trace + @overload def update( self, resource_group_name: str, script_name: str, - deployment_script: Optional["_models.DeploymentScriptUpdateParameter"] = None, + deployment_script: Optional[_models.DeploymentScriptUpdateParameter] = None, + *, + content_type: str = "application/json", **kwargs: Any - ) -> "_models.DeploymentScript": + ) -> _models.DeploymentScript: """Updates deployment script tags with specified values. :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. :type resource_group_name: str - :param script_name: Name of the deployment script. + :param script_name: Name of the deployment script. Required. :type script_name: str :param deployment_script: Deployment script resource with the tags to be updated. Default value is None. :type deployment_script: ~azure.mgmt.resource.deploymentscripts.v2019_10_01_preview.models.DeploymentScriptUpdateParameter + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: DeploymentScript, or the result of cls(response) + :return: DeploymentScript or the result of cls(response) :rtype: ~azure.mgmt.resource.deploymentscripts.v2019_10_01_preview.models.DeploymentScript - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + def update( + self, + resource_group_name: str, + script_name: str, + deployment_script: Optional[IO] = None, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.DeploymentScript: + """Updates deployment script tags with specified values. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param script_name: Name of the deployment script. Required. + :type script_name: str + :param deployment_script: Deployment script resource with the tags to be updated. Default value + is None. + :type deployment_script: IO + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: DeploymentScript or the result of cls(response) + :rtype: ~azure.mgmt.resource.deploymentscripts.v2019_10_01_preview.models.DeploymentScript + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace + def update( + self, + resource_group_name: str, + script_name: str, + deployment_script: Optional[Union[_models.DeploymentScriptUpdateParameter, IO]] = None, + **kwargs: Any + ) -> _models.DeploymentScript: + """Updates deployment script tags with specified values. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param script_name: Name of the deployment script. Required. + :type script_name: str + :param deployment_script: Deployment script resource with the tags to be updated. Is either a + model type or a IO type. Default value is None. + :type deployment_script: + ~azure.mgmt.resource.deploymentscripts.v2019_10_01_preview.models.DeploymentScriptUpdateParameter + or IO + :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. + Default value is None. + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: DeploymentScript or the result of cls(response) + :rtype: ~azure.mgmt.resource.deploymentscripts.v2019_10_01_preview.models.DeploymentScript + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.DeploymentScript"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) - api_version = kwargs.pop('api_version', "2019-10-01-preview") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - if deployment_script is not None: - _json = self._serialize.body(deployment_script, 'DeploymentScriptUpdateParameter') + api_version = kwargs.pop("api_version", _params.pop("api-version", "2019-10-01-preview")) # type: str + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.DeploymentScript] + + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(deployment_script, (IO, bytes)): + _content = deployment_script else: - _json = None + if deployment_script is not None: + _json = self._serialize.body(deployment_script, "DeploymentScriptUpdateParameter") + else: + _json = None request = build_deployment_scripts_update_request( - subscription_id=self._config.subscription_id, resource_group_name=resource_group_name, script_name=script_name, + subscription_id=self._config.subscription_id, api_version=api_version, content_type=content_type, json=_json, - template_url=self.update.metadata['url'], + content=_content, + template_url=self.update.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200]: @@ -542,58 +684,59 @@ def update( error = self._deserialize.failsafe_deserialize(_models.DeploymentScriptsError, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - deserialized = self._deserialize('DeploymentScript', pipeline_response) + deserialized = self._deserialize("DeploymentScript", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - update.metadata = {'url': "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/Microsoft.Resources/deploymentScripts/{scriptName}"} # type: ignore - + update.metadata = {"url": "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/Microsoft.Resources/deploymentScripts/{scriptName}"} # type: ignore @distributed_trace - def get( - self, - resource_group_name: str, - script_name: str, - **kwargs: Any - ) -> "_models.DeploymentScript": + def get(self, resource_group_name: str, script_name: str, **kwargs: Any) -> _models.DeploymentScript: """Gets a deployment script with a given name. :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. :type resource_group_name: str - :param script_name: Name of the deployment script. + :param script_name: Name of the deployment script. Required. :type script_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: DeploymentScript, or the result of cls(response) + :return: DeploymentScript or the result of cls(response) :rtype: ~azure.mgmt.resource.deploymentscripts.v2019_10_01_preview.models.DeploymentScript - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.DeploymentScript"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + 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', "2019-10-01-preview") # type: str + api_version = kwargs.pop("api_version", _params.pop("api-version", "2019-10-01-preview")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[_models.DeploymentScript] - request = build_deployment_scripts_get_request( - subscription_id=self._config.subscription_id, resource_group_name=resource_group_name, script_name=script_name, + subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.get.metadata['url'], + template_url=self.get.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200]: @@ -601,59 +744,62 @@ def get( error = self._deserialize.failsafe_deserialize(_models.DeploymentScriptsError, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - deserialized = self._deserialize('DeploymentScript', pipeline_response) + deserialized = self._deserialize("DeploymentScript", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - get.metadata = {'url': "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/Microsoft.Resources/deploymentScripts/{scriptName}"} # type: ignore - + get.metadata = {"url": "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/Microsoft.Resources/deploymentScripts/{scriptName}"} # type: ignore @distributed_trace def delete( # pylint: disable=inconsistent-return-statements - self, - resource_group_name: str, - script_name: str, - **kwargs: Any + self, resource_group_name: str, script_name: str, **kwargs: Any ) -> None: """Deletes a deployment script. When operation completes, status code 200 returned without content. :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. :type resource_group_name: str - :param script_name: Name of the deployment script. + :param script_name: Name of the deployment script. Required. :type script_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: None, or the result of cls(response) + :return: None or the result of cls(response) :rtype: None - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType[None] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + 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', "2019-10-01-preview") # type: str + api_version = kwargs.pop("api_version", _params.pop("api-version", "2019-10-01-preview")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[None] - request = build_deployment_scripts_delete_request( - subscription_id=self._config.subscription_id, resource_group_name=resource_group_name, script_name=script_name, + subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.delete.metadata['url'], + template_url=self.delete.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200, 204]: @@ -664,49 +810,53 @@ def delete( # pylint: disable=inconsistent-return-statements if cls: return cls(pipeline_response, None, {}) - delete.metadata = {'url': "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/Microsoft.Resources/deploymentScripts/{scriptName}"} # type: ignore - + delete.metadata = {"url": "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/Microsoft.Resources/deploymentScripts/{scriptName}"} # type: ignore @distributed_trace - def list_by_subscription( - self, - **kwargs: Any - ) -> Iterable["_models.DeploymentScriptListResult"]: + def list_by_subscription(self, **kwargs: Any) -> Iterable["_models.DeploymentScript"]: """Lists all deployment scripts for a given subscription. :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either DeploymentScriptListResult or the result of - cls(response) + :return: An iterator like instance of either DeploymentScript or the result of cls(response) :rtype: - ~azure.core.paging.ItemPaged[~azure.mgmt.resource.deploymentscripts.v2019_10_01_preview.models.DeploymentScriptListResult] - :raises: ~azure.core.exceptions.HttpResponseError + ~azure.core.paging.ItemPaged[~azure.mgmt.resource.deploymentscripts.v2019_10_01_preview.models.DeploymentScript] + :raises ~azure.core.exceptions.HttpResponseError: """ - api_version = kwargs.pop('api_version', "2019-10-01-preview") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2019-10-01-preview")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[_models.DeploymentScriptListResult] - cls = kwargs.pop('cls', None) # type: ClsType["_models.DeploymentScriptListResult"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) + def prepare_request(next_link=None): if not next_link: - + request = build_deployment_scripts_list_by_subscription_request( subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.list_by_subscription.metadata['url'], + template_url=self.list_by_subscription.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore else: - - request = build_deployment_scripts_list_by_subscription_request( - subscription_id=self._config.subscription_id, - template_url=next_link, - ) + # make call to next link with the client's api-version + _parsed_next_link = urlparse(next_link) + _next_request_params = case_insensitive_dict(parse_qs(_parsed_next_link.query)) + _next_request_params["api-version"] = self._config.api_version + request = HttpRequest("GET", urljoin(next_link, _parsed_next_link.path), params=_next_request_params) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore request.method = "GET" return request @@ -720,10 +870,8 @@ def extract_data(pipeline_response): def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) response = pipeline_response.http_response @@ -734,54 +882,54 @@ def get_next(next_link=None): return pipeline_response + return ItemPaged(get_next, extract_data) - return ItemPaged( - get_next, extract_data - ) - list_by_subscription.metadata = {'url': "/subscriptions/{subscriptionId}/providers/Microsoft.Resources/deploymentScripts"} # type: ignore + list_by_subscription.metadata = {"url": "/subscriptions/{subscriptionId}/providers/Microsoft.Resources/deploymentScripts"} # type: ignore @distributed_trace - def get_logs( - self, - resource_group_name: str, - script_name: str, - **kwargs: Any - ) -> "_models.ScriptLogsList": + def get_logs(self, resource_group_name: str, script_name: str, **kwargs: Any) -> _models.ScriptLogsList: """Gets deployment script logs for a given deployment script name. :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. :type resource_group_name: str - :param script_name: Name of the deployment script. + :param script_name: Name of the deployment script. Required. :type script_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: ScriptLogsList, or the result of cls(response) + :return: ScriptLogsList or the result of cls(response) :rtype: ~azure.mgmt.resource.deploymentscripts.v2019_10_01_preview.models.ScriptLogsList - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.ScriptLogsList"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + 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', "2019-10-01-preview") # type: str + api_version = kwargs.pop("api_version", _params.pop("api-version", "2019-10-01-preview")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[_models.ScriptLogsList] - request = build_deployment_scripts_get_logs_request( - subscription_id=self._config.subscription_id, resource_group_name=resource_group_name, script_name=script_name, + subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.get_logs.metadata['url'], + template_url=self.get_logs.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200]: @@ -789,64 +937,66 @@ def get_logs( error = self._deserialize.failsafe_deserialize(_models.DeploymentScriptsError, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - deserialized = self._deserialize('ScriptLogsList', pipeline_response) + deserialized = self._deserialize("ScriptLogsList", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - get_logs.metadata = {'url': "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/Microsoft.Resources/deploymentScripts/{scriptName}/logs"} # type: ignore - + get_logs.metadata = {"url": "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/Microsoft.Resources/deploymentScripts/{scriptName}/logs"} # type: ignore @distributed_trace def get_logs_default( - self, - resource_group_name: str, - script_name: str, - tail: Optional[int] = None, - **kwargs: Any - ) -> "_models.ScriptLog": + self, resource_group_name: str, script_name: str, tail: Optional[int] = None, **kwargs: Any + ) -> _models.ScriptLog: """Gets deployment script logs for a given deployment script name. :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. :type resource_group_name: str - :param script_name: Name of the deployment script. + :param script_name: Name of the deployment script. Required. :type script_name: str :param tail: The number of lines to show from the tail of the deployment script log. Valid value is a positive number up to 1000. If 'tail' is not provided, all available logs are shown up to container instance log capacity of 4mb. Default value is None. :type tail: int :keyword callable cls: A custom type or function that will be passed the direct response - :return: ScriptLog, or the result of cls(response) + :return: ScriptLog or the result of cls(response) :rtype: ~azure.mgmt.resource.deploymentscripts.v2019_10_01_preview.models.ScriptLog - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.ScriptLog"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) - api_version = kwargs.pop('api_version', "2019-10-01-preview") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2019-10-01-preview")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[_models.ScriptLog] - request = build_deployment_scripts_get_logs_default_request( - subscription_id=self._config.subscription_id, resource_group_name=resource_group_name, script_name=script_name, - api_version=api_version, + subscription_id=self._config.subscription_id, tail=tail, - template_url=self.get_logs_default.metadata['url'], + api_version=api_version, + template_url=self.get_logs_default.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200]: @@ -854,61 +1004,64 @@ def get_logs_default( error = self._deserialize.failsafe_deserialize(_models.DeploymentScriptsError, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - deserialized = self._deserialize('ScriptLog', pipeline_response) + deserialized = self._deserialize("ScriptLog", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - get_logs_default.metadata = {'url': "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/Microsoft.Resources/deploymentScripts/{scriptName}/logs/default"} # type: ignore - + get_logs_default.metadata = {"url": "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/Microsoft.Resources/deploymentScripts/{scriptName}/logs/default"} # type: ignore @distributed_trace - def list_by_resource_group( - self, - resource_group_name: str, - **kwargs: Any - ) -> Iterable["_models.DeploymentScriptListResult"]: + def list_by_resource_group(self, resource_group_name: str, **kwargs: Any) -> Iterable["_models.DeploymentScript"]: """Lists deployments scripts. :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. :type resource_group_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either DeploymentScriptListResult or the result of - cls(response) + :return: An iterator like instance of either DeploymentScript or the result of cls(response) :rtype: - ~azure.core.paging.ItemPaged[~azure.mgmt.resource.deploymentscripts.v2019_10_01_preview.models.DeploymentScriptListResult] - :raises: ~azure.core.exceptions.HttpResponseError + ~azure.core.paging.ItemPaged[~azure.mgmt.resource.deploymentscripts.v2019_10_01_preview.models.DeploymentScript] + :raises ~azure.core.exceptions.HttpResponseError: """ - api_version = kwargs.pop('api_version', "2019-10-01-preview") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2019-10-01-preview")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[_models.DeploymentScriptListResult] - cls = kwargs.pop('cls', None) # type: ClsType["_models.DeploymentScriptListResult"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) + def prepare_request(next_link=None): if not next_link: - + request = build_deployment_scripts_list_by_resource_group_request( - subscription_id=self._config.subscription_id, 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'], + 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.url = self._client.format_url(request.url) # type: ignore else: - - request = build_deployment_scripts_list_by_resource_group_request( - subscription_id=self._config.subscription_id, - resource_group_name=resource_group_name, - template_url=next_link, - ) + # make call to next link with the client's api-version + _parsed_next_link = urlparse(next_link) + _next_request_params = case_insensitive_dict(parse_qs(_parsed_next_link.query)) + _next_request_params["api-version"] = self._config.api_version + request = HttpRequest("GET", urljoin(next_link, _parsed_next_link.path), params=_next_request_params) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore request.method = "GET" return request @@ -922,10 +1075,8 @@ def extract_data(pipeline_response): def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) response = pipeline_response.http_response @@ -936,8 +1087,6 @@ def get_next(next_link=None): return pipeline_response + return ItemPaged(get_next, extract_data) - return ItemPaged( - get_next, extract_data - ) - list_by_resource_group.metadata = {'url': "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/Microsoft.Resources/deploymentScripts"} # type: ignore + list_by_resource_group.metadata = {"url": "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/Microsoft.Resources/deploymentScripts"} # type: ignore diff --git a/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/deploymentscripts/v2019_10_01_preview/operations/_patch.py b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/deploymentscripts/v2019_10_01_preview/operations/_patch.py new file mode 100644 index 0000000000000..f7dd32510333d --- /dev/null +++ b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/deploymentscripts/v2019_10_01_preview/operations/_patch.py @@ -0,0 +1,20 @@ +# ------------------------------------ +# Copyright (c) Microsoft Corporation. +# Licensed under the MIT License. +# ------------------------------------ +"""Customize generated code here. + +Follow our quickstart for examples: https://aka.ms/azsdk/python/dpcodegen/python/customize +""" +from typing import List + +__all__: List[str] = [] # Add all objects you want publicly available to users at this package level + + +def patch_sdk(): + """Do not remove from this file. + + `patch_sdk` is a last resort escape hatch that allows you to do customizations + you can't accomplish using the techniques described in + https://aka.ms/azsdk/python/dpcodegen/python/customize + """ diff --git a/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/deploymentscripts/v2020_10_01/__init__.py b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/deploymentscripts/v2020_10_01/__init__.py index d4d4c09823149..6fbd53dc300b6 100644 --- a/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/deploymentscripts/v2020_10_01/__init__.py +++ b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/deploymentscripts/v2020_10_01/__init__.py @@ -10,9 +10,15 @@ from ._version import VERSION __version__ = VERSION -__all__ = ['DeploymentScriptsClient'] -# `._patch.py` is used for handwritten extensions to the generated code -# Example: https://github.com/Azure/azure-sdk-for-python/blob/main/doc/dev/customize_code/how-to-patch-sdk-code.md -from ._patch import patch_sdk -patch_sdk() +try: + from ._patch import __all__ as _patch_all + from ._patch import * # type: ignore # pylint: disable=unused-wildcard-import +except ImportError: + _patch_all = [] +from ._patch import patch_sdk as _patch_sdk + +__all__ = ["DeploymentScriptsClient"] +__all__.extend([p for p in _patch_all if p not in __all__]) + +_patch_sdk() diff --git a/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/deploymentscripts/v2020_10_01/_configuration.py b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/deploymentscripts/v2020_10_01/_configuration.py index cf5f91ecadcd3..c2d8f826b22a5 100644 --- a/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/deploymentscripts/v2020_10_01/_configuration.py +++ b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/deploymentscripts/v2020_10_01/_configuration.py @@ -25,23 +25,19 @@ class DeploymentScriptsClientConfiguration(Configuration): # pylint: disable=to Note that all parameters used to create this instance are saved as instance attributes. - :param credential: Credential needed for the client to connect to Azure. + :param credential: Credential needed for the client to connect to Azure. Required. :type credential: ~azure.core.credentials.TokenCredential :param subscription_id: Subscription Id which forms part of the URI for every service call. + Required. :type subscription_id: str :keyword api_version: Api Version. Default value is "2020-10-01". Note that overriding this default value may result in unsupported behavior. :paramtype api_version: str """ - def __init__( - self, - credential: "TokenCredential", - subscription_id: str, - **kwargs: Any - ) -> None: + def __init__(self, credential: "TokenCredential", subscription_id: str, **kwargs: Any) -> None: super(DeploymentScriptsClientConfiguration, self).__init__(**kwargs) - api_version = kwargs.pop('api_version', "2020-10-01") # type: str + api_version = kwargs.pop("api_version", "2020-10-01") # type: str if credential is None: raise ValueError("Parameter 'credential' must not be None.") @@ -51,23 +47,24 @@ def __init__( self.credential = credential self.subscription_id = subscription_id self.api_version = api_version - self.credential_scopes = kwargs.pop('credential_scopes', ['https://management.azure.com/.default']) - kwargs.setdefault('sdk_moniker', 'mgmt-resource/{}'.format(VERSION)) + self.credential_scopes = kwargs.pop("credential_scopes", ["https://management.azure.com/.default"]) + kwargs.setdefault("sdk_moniker", "mgmt-resource/{}".format(VERSION)) self._configure(**kwargs) def _configure( - self, - **kwargs # type: Any + self, **kwargs # type: Any ): # type: (...) -> 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) - self.logging_policy = kwargs.get('logging_policy') or policies.NetworkTraceLoggingPolicy(**kwargs) - self.http_logging_policy = kwargs.get('http_logging_policy') or ARMHttpLoggingPolicy(**kwargs) - self.retry_policy = kwargs.get('retry_policy') or policies.RetryPolicy(**kwargs) - self.custom_hook_policy = kwargs.get('custom_hook_policy') or policies.CustomHookPolicy(**kwargs) - self.redirect_policy = kwargs.get('redirect_policy') or policies.RedirectPolicy(**kwargs) - self.authentication_policy = kwargs.get('authentication_policy') + 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) + self.logging_policy = kwargs.get("logging_policy") or policies.NetworkTraceLoggingPolicy(**kwargs) + self.http_logging_policy = kwargs.get("http_logging_policy") or ARMHttpLoggingPolicy(**kwargs) + self.retry_policy = kwargs.get("retry_policy") or policies.RetryPolicy(**kwargs) + self.custom_hook_policy = kwargs.get("custom_hook_policy") or policies.CustomHookPolicy(**kwargs) + self.redirect_policy = kwargs.get("redirect_policy") or policies.RedirectPolicy(**kwargs) + self.authentication_policy = kwargs.get("authentication_policy") if self.credential and not self.authentication_policy: - self.authentication_policy = ARMChallengeAuthenticationPolicy(self.credential, *self.credential_scopes, **kwargs) + self.authentication_policy = ARMChallengeAuthenticationPolicy( + self.credential, *self.credential_scopes, **kwargs + ) diff --git a/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/deploymentscripts/v2020_10_01/_deployment_scripts_client.py b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/deploymentscripts/v2020_10_01/_deployment_scripts_client.py index e24d50e76d7bf..4be23d47a4fdd 100644 --- a/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/deploymentscripts/v2020_10_01/_deployment_scripts_client.py +++ b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/deploymentscripts/v2020_10_01/_deployment_scripts_client.py @@ -9,12 +9,11 @@ from copy import deepcopy from typing import Any, TYPE_CHECKING -from msrest import Deserializer, Serializer - from azure.core.rest import HttpRequest, HttpResponse from azure.mgmt.core import ARMPipelineClient from . import models +from .._serialization import Deserializer, Serializer from ._configuration import DeploymentScriptsClientConfiguration from .operations import DeploymentScriptsOperations @@ -22,16 +21,18 @@ # pylint: disable=unused-import,ungrouped-imports from azure.core.credentials import TokenCredential -class DeploymentScriptsClient: + +class DeploymentScriptsClient: # pylint: disable=client-accepts-api-version-keyword """The APIs listed in this specification can be used to manage Deployment Scripts resource through the Azure Resource Manager. :ivar deployment_scripts: DeploymentScriptsOperations operations :vartype deployment_scripts: azure.mgmt.resource.deploymentscripts.v2020_10_01.operations.DeploymentScriptsOperations - :param credential: Credential needed for the client to connect to Azure. + :param credential: Credential needed for the client to connect to Azure. Required. :type credential: ~azure.core.credentials.TokenCredential :param subscription_id: Subscription Id which forms part of the URI for every service call. + Required. :type subscription_id: str :param base_url: Service URL. Default value is "https://management.azure.com". :type base_url: str @@ -49,21 +50,20 @@ def __init__( base_url: str = "https://management.azure.com", **kwargs: Any ) -> None: - self._config = DeploymentScriptsClientConfiguration(credential=credential, subscription_id=subscription_id, **kwargs) + self._config = DeploymentScriptsClientConfiguration( + credential=credential, subscription_id=subscription_id, **kwargs + ) self._client = ARMPipelineClient(base_url=base_url, config=self._config, **kwargs) client_models = {k: v for k, v in models.__dict__.items() if isinstance(v, type)} self._serialize = Serializer(client_models) self._deserialize = Deserializer(client_models) self._serialize.client_side_validation = False - self.deployment_scripts = DeploymentScriptsOperations(self._client, self._config, self._serialize, self._deserialize) - + self.deployment_scripts = DeploymentScriptsOperations( + self._client, self._config, self._serialize, self._deserialize + ) - def _send_request( - self, - request: HttpRequest, - **kwargs: Any - ) -> HttpResponse: + def _send_request(self, request: HttpRequest, **kwargs: Any) -> HttpResponse: """Runs the network request through the client's chained policies. >>> from azure.core.rest import HttpRequest @@ -72,7 +72,7 @@ def _send_request( >>> response = client._send_request(request) - For more information on this code flow, see https://aka.ms/azsdk/python/protocol/quickstart + For more information on this code flow, see https://aka.ms/azsdk/dpcodegen/python/send_request :param request: The network request you want to make. Required. :type request: ~azure.core.rest.HttpRequest diff --git a/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/deploymentscripts/v2020_10_01/_metadata.json b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/deploymentscripts/v2020_10_01/_metadata.json index 03b3230b3bff0..fb20192760feb 100644 --- a/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/deploymentscripts/v2020_10_01/_metadata.json +++ b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/deploymentscripts/v2020_10_01/_metadata.json @@ -10,20 +10,20 @@ "azure_arm": true, "has_lro_operations": true, "client_side_validation": false, - "sync_imports": "{\"typing\": {\"azurecore\": {\"azure.core.credentials\": [\"TokenCredential\"]}}, \"regular\": {\"azurecore\": {\"azure.profiles\": [\"KnownProfiles\", \"ProfileDefinition\"], \"azure.profiles.multiapiclient\": [\"MultiApiClientMixin\"], \"azure.mgmt.core\": [\"ARMPipelineClient\"]}, \"local\": {\"._configuration\": [\"DeploymentScriptsClientConfiguration\"]}, \"thirdparty\": {\"msrest\": [\"Deserializer\", \"Serializer\"]}}, \"conditional\": {\"stdlib\": {\"typing\": [\"Any\", \"Optional\"]}}}", - "async_imports": "{\"typing\": {\"azurecore\": {\"azure.core.credentials_async\": [\"AsyncTokenCredential\"], \"azure.core.credentials\": [\"TokenCredential\"]}}, \"regular\": {\"azurecore\": {\"azure.profiles\": [\"KnownProfiles\", \"ProfileDefinition\"], \"azure.profiles.multiapiclient\": [\"MultiApiClientMixin\"], \"azure.mgmt.core\": [\"AsyncARMPipelineClient\"]}, \"local\": {\"._configuration\": [\"DeploymentScriptsClientConfiguration\"]}, \"thirdparty\": {\"msrest\": [\"Deserializer\", \"Serializer\"]}}, \"conditional\": {\"stdlib\": {\"typing\": [\"Any\", \"Optional\"]}}}" + "sync_imports": "{\"conditional\": {\"stdlib\": {\"typing\": [\"Any\", \"Optional\"]}}, \"regular\": {\"azurecore\": {\"azure.mgmt.core\": [\"ARMPipelineClient\"], \"azure.profiles\": [\"KnownProfiles\", \"ProfileDefinition\"], \"azure.profiles.multiapiclient\": [\"MultiApiClientMixin\"]}, \"local\": {\"._configuration\": [\"DeploymentScriptsClientConfiguration\"], \".._serialization\": [\"Deserializer\", \"Serializer\"]}}, \"typing\": {\"azurecore\": {\"azure.core.credentials\": [\"TokenCredential\"]}}}", + "async_imports": "{\"conditional\": {\"stdlib\": {\"typing\": [\"Any\", \"Optional\"]}}, \"regular\": {\"azurecore\": {\"azure.mgmt.core\": [\"AsyncARMPipelineClient\"], \"azure.profiles\": [\"KnownProfiles\", \"ProfileDefinition\"], \"azure.profiles.multiapiclient\": [\"MultiApiClientMixin\"]}, \"local\": {\"._configuration\": [\"DeploymentScriptsClientConfiguration\"], \"..._serialization\": [\"Deserializer\", \"Serializer\"]}}, \"typing\": {\"azurecore\": {\"azure.core.credentials_async\": [\"AsyncTokenCredential\"]}}}" }, "global_parameters": { "sync": { "credential": { - "signature": "credential, # type: \"TokenCredential\"", - "description": "Credential needed for the client to connect to Azure.", + "signature": "credential: \"TokenCredential\",", + "description": "Credential needed for the client to connect to Azure. Required.", "docstring_type": "~azure.core.credentials.TokenCredential", "required": true }, "subscription_id": { - "signature": "subscription_id, # type: str", - "description": "Subscription Id which forms part of the URI for every service call.", + "signature": "subscription_id: str,", + "description": "Subscription Id which forms part of the URI for every service call. Required.", "docstring_type": "str", "required": true } @@ -31,13 +31,13 @@ "async": { "credential": { "signature": "credential: \"AsyncTokenCredential\",", - "description": "Credential needed for the client to connect to Azure.", + "description": "Credential needed for the client to connect to Azure. Required.", "docstring_type": "~azure.core.credentials_async.AsyncTokenCredential", "required": true }, "subscription_id": { "signature": "subscription_id: str,", - "description": "Subscription Id which forms part of the URI for every service call.", + "description": "Subscription Id which forms part of the URI for every service call. Required.", "docstring_type": "str", "required": true } @@ -54,7 +54,7 @@ "required": false }, "base_url": { - "signature": "base_url=\"https://management.azure.com\", # type: str", + "signature": "base_url: str = \"https://management.azure.com\",", "description": "Service URL", "docstring_type": "str", "required": false diff --git a/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/deploymentscripts/v2020_10_01/_patch.py b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/deploymentscripts/v2020_10_01/_patch.py index 74e48ecd07cf3..f99e77fef9861 100644 --- a/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/deploymentscripts/v2020_10_01/_patch.py +++ b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/deploymentscripts/v2020_10_01/_patch.py @@ -28,4 +28,4 @@ # This file is used for handwritten extensions to the generated code. Example: # https://github.com/Azure/azure-sdk-for-python/blob/main/doc/dev/customize_code/how-to-patch-sdk-code.md def patch_sdk(): - pass \ No newline at end of file + pass diff --git a/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/deploymentscripts/v2020_10_01/_vendor.py b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/deploymentscripts/v2020_10_01/_vendor.py index 138f663c53a4e..9aad73fc743e7 100644 --- a/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/deploymentscripts/v2020_10_01/_vendor.py +++ b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/deploymentscripts/v2020_10_01/_vendor.py @@ -7,6 +7,7 @@ from azure.core.pipeline.transport import HttpRequest + def _convert_request(request, files=None): data = request.content if not files else None request = HttpRequest(method=request.method, url=request.url, headers=request.headers, data=data) @@ -14,6 +15,7 @@ def _convert_request(request, files=None): request.set_formdata_body(files) return request + def _format_url_section(template, **kwargs): components = template.split("/") while components: @@ -21,7 +23,5 @@ def _format_url_section(template, **kwargs): 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 - ] + components = [c for c in formatted_components if "{}".format(key.args[0]) not in c] template = "/".join(components) diff --git a/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/deploymentscripts/v2020_10_01/_version.py b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/deploymentscripts/v2020_10_01/_version.py index a012ac01c480c..e5754a47ce68f 100644 --- a/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/deploymentscripts/v2020_10_01/_version.py +++ b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/deploymentscripts/v2020_10_01/_version.py @@ -6,4 +6,4 @@ # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -VERSION = "21.1.0" +VERSION = "1.0.0b1" diff --git a/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/deploymentscripts/v2020_10_01/aio/__init__.py b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/deploymentscripts/v2020_10_01/aio/__init__.py index 815170897d35d..101e9dc5372bd 100644 --- a/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/deploymentscripts/v2020_10_01/aio/__init__.py +++ b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/deploymentscripts/v2020_10_01/aio/__init__.py @@ -7,9 +7,15 @@ # -------------------------------------------------------------------------- from ._deployment_scripts_client import DeploymentScriptsClient -__all__ = ['DeploymentScriptsClient'] -# `._patch.py` is used for handwritten extensions to the generated code -# Example: https://github.com/Azure/azure-sdk-for-python/blob/main/doc/dev/customize_code/how-to-patch-sdk-code.md -from ._patch import patch_sdk -patch_sdk() +try: + from ._patch import __all__ as _patch_all + from ._patch import * # type: ignore # pylint: disable=unused-wildcard-import +except ImportError: + _patch_all = [] +from ._patch import patch_sdk as _patch_sdk + +__all__ = ["DeploymentScriptsClient"] +__all__.extend([p for p in _patch_all if p not in __all__]) + +_patch_sdk() diff --git a/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/deploymentscripts/v2020_10_01/aio/_configuration.py b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/deploymentscripts/v2020_10_01/aio/_configuration.py index 67fd158fe212a..c488d131c365f 100644 --- a/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/deploymentscripts/v2020_10_01/aio/_configuration.py +++ b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/deploymentscripts/v2020_10_01/aio/_configuration.py @@ -25,23 +25,19 @@ class DeploymentScriptsClientConfiguration(Configuration): # pylint: disable=to Note that all parameters used to create this instance are saved as instance attributes. - :param credential: Credential needed for the client to connect to Azure. + :param credential: Credential needed for the client to connect to Azure. Required. :type credential: ~azure.core.credentials_async.AsyncTokenCredential :param subscription_id: Subscription Id which forms part of the URI for every service call. + Required. :type subscription_id: str :keyword api_version: Api Version. Default value is "2020-10-01". Note that overriding this default value may result in unsupported behavior. :paramtype api_version: str """ - def __init__( - self, - credential: "AsyncTokenCredential", - subscription_id: str, - **kwargs: Any - ) -> None: + def __init__(self, credential: "AsyncTokenCredential", subscription_id: str, **kwargs: Any) -> None: super(DeploymentScriptsClientConfiguration, self).__init__(**kwargs) - api_version = kwargs.pop('api_version', "2020-10-01") # type: str + api_version = kwargs.pop("api_version", "2020-10-01") # type: str if credential is None: raise ValueError("Parameter 'credential' must not be None.") @@ -51,22 +47,21 @@ def __init__( self.credential = credential self.subscription_id = subscription_id self.api_version = api_version - self.credential_scopes = kwargs.pop('credential_scopes', ['https://management.azure.com/.default']) - kwargs.setdefault('sdk_moniker', 'mgmt-resource/{}'.format(VERSION)) + self.credential_scopes = kwargs.pop("credential_scopes", ["https://management.azure.com/.default"]) + kwargs.setdefault("sdk_moniker", "mgmt-resource/{}".format(VERSION)) self._configure(**kwargs) - 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) - self.logging_policy = kwargs.get('logging_policy') or policies.NetworkTraceLoggingPolicy(**kwargs) - self.http_logging_policy = kwargs.get('http_logging_policy') or ARMHttpLoggingPolicy(**kwargs) - self.retry_policy = kwargs.get('retry_policy') or policies.AsyncRetryPolicy(**kwargs) - self.custom_hook_policy = kwargs.get('custom_hook_policy') or policies.CustomHookPolicy(**kwargs) - self.redirect_policy = kwargs.get('redirect_policy') or policies.AsyncRedirectPolicy(**kwargs) - self.authentication_policy = kwargs.get('authentication_policy') + 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) + self.logging_policy = kwargs.get("logging_policy") or policies.NetworkTraceLoggingPolicy(**kwargs) + self.http_logging_policy = kwargs.get("http_logging_policy") or ARMHttpLoggingPolicy(**kwargs) + self.retry_policy = kwargs.get("retry_policy") or policies.AsyncRetryPolicy(**kwargs) + self.custom_hook_policy = kwargs.get("custom_hook_policy") or policies.CustomHookPolicy(**kwargs) + self.redirect_policy = kwargs.get("redirect_policy") or policies.AsyncRedirectPolicy(**kwargs) + self.authentication_policy = kwargs.get("authentication_policy") if self.credential and not self.authentication_policy: - self.authentication_policy = AsyncARMChallengeAuthenticationPolicy(self.credential, *self.credential_scopes, **kwargs) + self.authentication_policy = AsyncARMChallengeAuthenticationPolicy( + self.credential, *self.credential_scopes, **kwargs + ) diff --git a/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/deploymentscripts/v2020_10_01/aio/_deployment_scripts_client.py b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/deploymentscripts/v2020_10_01/aio/_deployment_scripts_client.py index c857456635907..1fffd4b514f5b 100644 --- a/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/deploymentscripts/v2020_10_01/aio/_deployment_scripts_client.py +++ b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/deploymentscripts/v2020_10_01/aio/_deployment_scripts_client.py @@ -9,12 +9,11 @@ from copy import deepcopy from typing import Any, Awaitable, TYPE_CHECKING -from msrest import Deserializer, Serializer - from azure.core.rest import AsyncHttpResponse, HttpRequest from azure.mgmt.core import AsyncARMPipelineClient from .. import models +from ..._serialization import Deserializer, Serializer from ._configuration import DeploymentScriptsClientConfiguration from .operations import DeploymentScriptsOperations @@ -22,16 +21,18 @@ # pylint: disable=unused-import,ungrouped-imports from azure.core.credentials_async import AsyncTokenCredential -class DeploymentScriptsClient: + +class DeploymentScriptsClient: # pylint: disable=client-accepts-api-version-keyword """The APIs listed in this specification can be used to manage Deployment Scripts resource through the Azure Resource Manager. :ivar deployment_scripts: DeploymentScriptsOperations operations :vartype deployment_scripts: azure.mgmt.resource.deploymentscripts.v2020_10_01.aio.operations.DeploymentScriptsOperations - :param credential: Credential needed for the client to connect to Azure. + :param credential: Credential needed for the client to connect to Azure. Required. :type credential: ~azure.core.credentials_async.AsyncTokenCredential :param subscription_id: Subscription Id which forms part of the URI for every service call. + Required. :type subscription_id: str :param base_url: Service URL. Default value is "https://management.azure.com". :type base_url: str @@ -49,21 +50,20 @@ def __init__( base_url: str = "https://management.azure.com", **kwargs: Any ) -> None: - self._config = DeploymentScriptsClientConfiguration(credential=credential, subscription_id=subscription_id, **kwargs) + self._config = DeploymentScriptsClientConfiguration( + credential=credential, subscription_id=subscription_id, **kwargs + ) self._client = AsyncARMPipelineClient(base_url=base_url, config=self._config, **kwargs) client_models = {k: v for k, v in models.__dict__.items() if isinstance(v, type)} self._serialize = Serializer(client_models) self._deserialize = Deserializer(client_models) self._serialize.client_side_validation = False - self.deployment_scripts = DeploymentScriptsOperations(self._client, self._config, self._serialize, self._deserialize) - + self.deployment_scripts = DeploymentScriptsOperations( + self._client, self._config, self._serialize, self._deserialize + ) - def _send_request( - self, - request: HttpRequest, - **kwargs: Any - ) -> Awaitable[AsyncHttpResponse]: + def _send_request(self, request: HttpRequest, **kwargs: Any) -> Awaitable[AsyncHttpResponse]: """Runs the network request through the client's chained policies. >>> from azure.core.rest import HttpRequest @@ -72,7 +72,7 @@ def _send_request( >>> response = await client._send_request(request) - For more information on this code flow, see https://aka.ms/azsdk/python/protocol/quickstart + For more information on this code flow, see https://aka.ms/azsdk/dpcodegen/python/send_request :param request: The network request you want to make. Required. :type request: ~azure.core.rest.HttpRequest diff --git a/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/deploymentscripts/v2020_10_01/aio/_patch.py b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/deploymentscripts/v2020_10_01/aio/_patch.py index 74e48ecd07cf3..f99e77fef9861 100644 --- a/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/deploymentscripts/v2020_10_01/aio/_patch.py +++ b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/deploymentscripts/v2020_10_01/aio/_patch.py @@ -28,4 +28,4 @@ # This file is used for handwritten extensions to the generated code. Example: # https://github.com/Azure/azure-sdk-for-python/blob/main/doc/dev/customize_code/how-to-patch-sdk-code.md def patch_sdk(): - pass \ No newline at end of file + pass diff --git a/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/deploymentscripts/v2020_10_01/aio/operations/__init__.py b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/deploymentscripts/v2020_10_01/aio/operations/__init__.py index 2a9499c638ccc..15dd692e91d23 100644 --- a/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/deploymentscripts/v2020_10_01/aio/operations/__init__.py +++ b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/deploymentscripts/v2020_10_01/aio/operations/__init__.py @@ -8,6 +8,12 @@ from ._operations import DeploymentScriptsOperations +from ._patch import __all__ as _patch_all +from ._patch import * # type: ignore # pylint: disable=unused-wildcard-import +from ._patch import patch_sdk as _patch_sdk + __all__ = [ - 'DeploymentScriptsOperations', + "DeploymentScriptsOperations", ] +__all__.extend([p for p in _patch_all if p not in __all__]) +_patch_sdk() diff --git a/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/deploymentscripts/v2020_10_01/aio/operations/_operations.py b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/deploymentscripts/v2020_10_01/aio/operations/_operations.py index fb705c6b66858..2cd4eaf154c4d 100644 --- a/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/deploymentscripts/v2020_10_01/aio/operations/_operations.py +++ b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/deploymentscripts/v2020_10_01/aio/operations/_operations.py @@ -6,119 +6,230 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -from typing import Any, AsyncIterable, Callable, Dict, Optional, TypeVar, Union +from typing import Any, AsyncIterable, Callable, Dict, IO, Optional, TypeVar, Union, cast, overload +from urllib.parse import parse_qs, urljoin, urlparse from azure.core.async_paging import AsyncItemPaged, AsyncList -from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error +from azure.core.exceptions import ( + ClientAuthenticationError, + HttpResponseError, + ResourceExistsError, + ResourceNotFoundError, + ResourceNotModifiedError, + map_error, +) from azure.core.pipeline import PipelineResponse from azure.core.pipeline.transport import AsyncHttpResponse from azure.core.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 from azure.mgmt.core.polling.async_arm_polling import AsyncARMPolling from ... import models as _models from ..._vendor import _convert_request -from ...operations._operations import build_deployment_scripts_create_request_initial, build_deployment_scripts_delete_request, build_deployment_scripts_get_logs_default_request, build_deployment_scripts_get_logs_request, build_deployment_scripts_get_request, build_deployment_scripts_list_by_resource_group_request, build_deployment_scripts_list_by_subscription_request, build_deployment_scripts_update_request -T = TypeVar('T') +from ...operations._operations import ( + build_deployment_scripts_create_request, + build_deployment_scripts_delete_request, + build_deployment_scripts_get_logs_default_request, + build_deployment_scripts_get_logs_request, + build_deployment_scripts_get_request, + build_deployment_scripts_list_by_resource_group_request, + build_deployment_scripts_list_by_subscription_request, + build_deployment_scripts_update_request, +) + +T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] -class DeploymentScriptsOperations: - """DeploymentScriptsOperations async operations. - You should not instantiate this class directly. Instead, you should create a Client instance that - instantiates it for you and attaches it as an attribute. +class DeploymentScriptsOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. - :ivar models: Alias to model classes used in this operation group. - :type models: ~azure.mgmt.resource.deploymentscripts.v2020_10_01.models - :param client: Client for service requests. - :param config: Configuration of service client. - :param serializer: An object model serializer. - :param deserializer: An object model deserializer. + Instead, you should access the following operations through + :class:`~azure.mgmt.resource.deploymentscripts.v2020_10_01.aio.DeploymentScriptsClient`'s + :attr:`deployment_scripts` attribute. """ models = _models - def __init__(self, client, config, serializer, deserializer) -> None: - self._client = client - self._serialize = serializer - self._deserialize = deserializer - self._config = config + def __init__(self, *args, **kwargs) -> None: + input_args = list(args) + self._client = input_args.pop(0) if input_args else kwargs.pop("client") + self._config = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") async def _create_initial( self, resource_group_name: str, script_name: str, - deployment_script: "_models.DeploymentScript", + deployment_script: Union[_models.DeploymentScript, IO], **kwargs: Any - ) -> "_models.DeploymentScript": - cls = kwargs.pop('cls', None) # type: ClsType["_models.DeploymentScript"] + ) -> _models.DeploymentScript: error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) - api_version = kwargs.pop('api_version', "2020-10-01") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - _json = self._serialize.body(deployment_script, 'DeploymentScript') + api_version = kwargs.pop("api_version", _params.pop("api-version", "2020-10-01")) # type: str + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.DeploymentScript] - request = build_deployment_scripts_create_request_initial( - subscription_id=self._config.subscription_id, + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(deployment_script, (IO, bytes)): + _content = deployment_script + else: + _json = self._serialize.body(deployment_script, "DeploymentScript") + + request = build_deployment_scripts_create_request( resource_group_name=resource_group_name, script_name=script_name, + subscription_id=self._config.subscription_id, api_version=api_version, content_type=content_type, json=_json, - template_url=self._create_initial.metadata['url'], + content=_content, + template_url=self._create_initial.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200, 201]: map_error(status_code=response.status_code, response=response, error_map=error_map) - raise HttpResponseError(response=response, error_format=ARMErrorFormat) + error = self._deserialize.failsafe_deserialize(_models.DeploymentScriptsError, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) if response.status_code == 200: - deserialized = self._deserialize('DeploymentScript', pipeline_response) + deserialized = self._deserialize("DeploymentScript", pipeline_response) if response.status_code == 201: - deserialized = self._deserialize('DeploymentScript', pipeline_response) + deserialized = self._deserialize("DeploymentScript", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - _create_initial.metadata = {'url': "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/Microsoft.Resources/deploymentScripts/{scriptName}"} # type: ignore + _create_initial.metadata = {"url": "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/Microsoft.Resources/deploymentScripts/{scriptName}"} # type: ignore + + @overload + async def begin_create( + self, + resource_group_name: str, + script_name: str, + deployment_script: _models.DeploymentScript, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> AsyncLROPoller[_models.DeploymentScript]: + """Creates a deployment script. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param script_name: Name of the deployment script. Required. + :type script_name: str + :param deployment_script: Deployment script supplied to the operation. Required. + :type deployment_script: + ~azure.mgmt.resource.deploymentscripts.v2020_10_01.models.DeploymentScript + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be AsyncARMPolling. Pass in False for + this operation to not poll, or pass in your own initialized polling object for a personal + polling strategy. + :paramtype polling: bool or ~azure.core.polling.AsyncPollingMethod + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of AsyncLROPoller that returns either DeploymentScript or the result of + cls(response) + :rtype: + ~azure.core.polling.AsyncLROPoller[~azure.mgmt.resource.deploymentscripts.v2020_10_01.models.DeploymentScript] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + async def begin_create( + self, + resource_group_name: str, + script_name: str, + deployment_script: IO, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> AsyncLROPoller[_models.DeploymentScript]: + """Creates a deployment script. + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param script_name: Name of the deployment script. Required. + :type script_name: str + :param deployment_script: Deployment script supplied to the operation. Required. + :type deployment_script: IO + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be AsyncARMPolling. Pass in False for + this operation to not poll, or pass in your own initialized polling object for a personal + polling strategy. + :paramtype polling: bool or ~azure.core.polling.AsyncPollingMethod + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of AsyncLROPoller that returns either DeploymentScript or the result of + cls(response) + :rtype: + ~azure.core.polling.AsyncLROPoller[~azure.mgmt.resource.deploymentscripts.v2020_10_01.models.DeploymentScript] + :raises ~azure.core.exceptions.HttpResponseError: + """ @distributed_trace_async async def begin_create( self, resource_group_name: str, script_name: str, - deployment_script: "_models.DeploymentScript", + deployment_script: Union[_models.DeploymentScript, IO], **kwargs: Any - ) -> AsyncLROPoller["_models.DeploymentScript"]: + ) -> AsyncLROPoller[_models.DeploymentScript]: """Creates a deployment script. :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. :type resource_group_name: str - :param script_name: Name of the deployment script. + :param script_name: Name of the deployment script. Required. :type script_name: str - :param deployment_script: Deployment script supplied to the operation. + :param deployment_script: Deployment script supplied to the operation. Is either a model type + or a IO type. Required. :type deployment_script: - ~azure.mgmt.resource.deploymentscripts.v2020_10_01.models.DeploymentScript + ~azure.mgmt.resource.deploymentscripts.v2020_10_01.models.DeploymentScript or IO + :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. + Default value is None. + :paramtype content_type: str :keyword callable cls: A custom type or function that will be passed the direct response :keyword str continuation_token: A continuation token to restart a poller from a saved state. :keyword polling: By default, your polling method will be AsyncARMPolling. Pass in False for @@ -131,105 +242,185 @@ async def begin_create( cls(response) :rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.resource.deploymentscripts.v2020_10_01.models.DeploymentScript] - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - api_version = kwargs.pop('api_version', "2020-10-01") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] - polling = kwargs.pop('polling', True) # type: Union[bool, AsyncPollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType["_models.DeploymentScript"] - lro_delay = kwargs.pop( - 'polling_interval', - self._config.polling_interval - ) - cont_token = kwargs.pop('continuation_token', None) # type: Optional[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", "2020-10-01")) # type: str + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.DeploymentScript] + polling = kwargs.pop("polling", True) # type: Union[bool, AsyncPollingMethod] + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token = kwargs.pop("continuation_token", None) # type: Optional[str] if cont_token is None: - raw_result = await self._create_initial( + raw_result = await self._create_initial( # type: ignore resource_group_name=resource_group_name, script_name=script_name, deployment_script=deployment_script, api_version=api_version, content_type=content_type, - cls=lambda x,y,z: x, + cls=lambda x, y, z: x, + headers=_headers, + params=_params, **kwargs ) - kwargs.pop('error_map', None) + kwargs.pop("error_map", None) def get_long_running_output(pipeline_response): - response = pipeline_response.http_response - deserialized = self._deserialize('DeploymentScript', pipeline_response) + deserialized = self._deserialize("DeploymentScript", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - - if polling is True: polling_method = AsyncARMPolling(lro_delay, **kwargs) - elif polling is False: polling_method = AsyncNoPolling() - else: polling_method = polling + if polling is True: + polling_method = cast(AsyncPollingMethod, AsyncARMPolling(lro_delay, **kwargs)) # type: AsyncPollingMethod + elif polling is False: + polling_method = cast(AsyncPollingMethod, AsyncNoPolling()) + else: + polling_method = polling if cont_token: return AsyncLROPoller.from_continuation_token( polling_method=polling_method, continuation_token=cont_token, client=self._client, - deserialization_callback=get_long_running_output + deserialization_callback=get_long_running_output, ) return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) - begin_create.metadata = {'url': "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/Microsoft.Resources/deploymentScripts/{scriptName}"} # type: ignore + begin_create.metadata = {"url": "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/Microsoft.Resources/deploymentScripts/{scriptName}"} # type: ignore - @distributed_trace_async + @overload async def update( self, resource_group_name: str, script_name: str, - deployment_script: Optional["_models.DeploymentScriptUpdateParameter"] = None, + deployment_script: Optional[_models.DeploymentScriptUpdateParameter] = None, + *, + content_type: str = "application/json", **kwargs: Any - ) -> "_models.DeploymentScript": + ) -> _models.DeploymentScript: """Updates deployment script tags with specified values. :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. :type resource_group_name: str - :param script_name: Name of the deployment script. + :param script_name: Name of the deployment script. Required. :type script_name: str :param deployment_script: Deployment script resource with the tags to be updated. Default value is None. :type deployment_script: ~azure.mgmt.resource.deploymentscripts.v2020_10_01.models.DeploymentScriptUpdateParameter + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: DeploymentScript, or the result of cls(response) + :return: DeploymentScript or the result of cls(response) :rtype: ~azure.mgmt.resource.deploymentscripts.v2020_10_01.models.DeploymentScript - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + async def update( + self, + resource_group_name: str, + script_name: str, + deployment_script: Optional[IO] = None, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.DeploymentScript: + """Updates deployment script tags with specified values. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param script_name: Name of the deployment script. Required. + :type script_name: str + :param deployment_script: Deployment script resource with the tags to be updated. Default value + is None. + :type deployment_script: IO + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: DeploymentScript or the result of cls(response) + :rtype: ~azure.mgmt.resource.deploymentscripts.v2020_10_01.models.DeploymentScript + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace_async + async def update( + self, + resource_group_name: str, + script_name: str, + deployment_script: Optional[Union[_models.DeploymentScriptUpdateParameter, IO]] = None, + **kwargs: Any + ) -> _models.DeploymentScript: + """Updates deployment script tags with specified values. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param script_name: Name of the deployment script. Required. + :type script_name: str + :param deployment_script: Deployment script resource with the tags to be updated. Is either a + model type or a IO type. Default value is None. + :type deployment_script: + ~azure.mgmt.resource.deploymentscripts.v2020_10_01.models.DeploymentScriptUpdateParameter or IO + :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. + Default value is None. + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: DeploymentScript or the result of cls(response) + :rtype: ~azure.mgmt.resource.deploymentscripts.v2020_10_01.models.DeploymentScript + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.DeploymentScript"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', "2020-10-01") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + api_version = kwargs.pop("api_version", _params.pop("api-version", "2020-10-01")) # type: str + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.DeploymentScript] - if deployment_script is not None: - _json = self._serialize.body(deployment_script, 'DeploymentScriptUpdateParameter') + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(deployment_script, (IO, bytes)): + _content = deployment_script else: - _json = None + if deployment_script is not None: + _json = self._serialize.body(deployment_script, "DeploymentScriptUpdateParameter") + else: + _json = None request = build_deployment_scripts_update_request( - subscription_id=self._config.subscription_id, resource_group_name=resource_group_name, script_name=script_name, + subscription_id=self._config.subscription_id, api_version=api_version, content_type=content_type, json=_json, - template_url=self.update.metadata['url'], + content=_content, + template_url=self.update.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200]: @@ -237,58 +428,59 @@ async def update( error = self._deserialize.failsafe_deserialize(_models.DeploymentScriptsError, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - deserialized = self._deserialize('DeploymentScript', pipeline_response) + deserialized = self._deserialize("DeploymentScript", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - update.metadata = {'url': "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/Microsoft.Resources/deploymentScripts/{scriptName}"} # type: ignore - + update.metadata = {"url": "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/Microsoft.Resources/deploymentScripts/{scriptName}"} # type: ignore @distributed_trace_async - async def get( - self, - resource_group_name: str, - script_name: str, - **kwargs: Any - ) -> "_models.DeploymentScript": + async def get(self, resource_group_name: str, script_name: str, **kwargs: Any) -> _models.DeploymentScript: """Gets a deployment script with a given name. :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. :type resource_group_name: str - :param script_name: Name of the deployment script. + :param script_name: Name of the deployment script. Required. :type script_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: DeploymentScript, or the result of cls(response) + :return: DeploymentScript or the result of cls(response) :rtype: ~azure.mgmt.resource.deploymentscripts.v2020_10_01.models.DeploymentScript - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.DeploymentScript"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + 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', "2020-10-01") # type: str + api_version = kwargs.pop("api_version", _params.pop("api-version", "2020-10-01")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[_models.DeploymentScript] - request = build_deployment_scripts_get_request( - subscription_id=self._config.subscription_id, resource_group_name=resource_group_name, script_name=script_name, + subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.get.metadata['url'], + template_url=self.get.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200]: @@ -296,59 +488,62 @@ async def get( error = self._deserialize.failsafe_deserialize(_models.DeploymentScriptsError, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - deserialized = self._deserialize('DeploymentScript', pipeline_response) + deserialized = self._deserialize("DeploymentScript", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - get.metadata = {'url': "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/Microsoft.Resources/deploymentScripts/{scriptName}"} # type: ignore - + get.metadata = {"url": "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/Microsoft.Resources/deploymentScripts/{scriptName}"} # type: ignore @distributed_trace_async async def delete( # pylint: disable=inconsistent-return-statements - self, - resource_group_name: str, - script_name: str, - **kwargs: Any + self, resource_group_name: str, script_name: str, **kwargs: Any ) -> None: """Deletes a deployment script. When operation completes, status code 200 returned without content. :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. :type resource_group_name: str - :param script_name: Name of the deployment script. + :param script_name: Name of the deployment script. Required. :type script_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: None, or the result of cls(response) + :return: None or the result of cls(response) :rtype: None - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType[None] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) - api_version = kwargs.pop('api_version', "2020-10-01") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2020-10-01")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[None] - request = build_deployment_scripts_delete_request( - subscription_id=self._config.subscription_id, resource_group_name=resource_group_name, script_name=script_name, + subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.delete.metadata['url'], + template_url=self.delete.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200, 204]: @@ -359,49 +554,53 @@ async def delete( # pylint: disable=inconsistent-return-statements if cls: return cls(pipeline_response, None, {}) - delete.metadata = {'url': "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/Microsoft.Resources/deploymentScripts/{scriptName}"} # type: ignore - + delete.metadata = {"url": "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/Microsoft.Resources/deploymentScripts/{scriptName}"} # type: ignore @distributed_trace - def list_by_subscription( - self, - **kwargs: Any - ) -> AsyncIterable["_models.DeploymentScriptListResult"]: + def list_by_subscription(self, **kwargs: Any) -> AsyncIterable["_models.DeploymentScript"]: """Lists all deployment scripts for a given subscription. :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either DeploymentScriptListResult or the result of - cls(response) + :return: An iterator like instance of either DeploymentScript or the result of cls(response) :rtype: - ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.resource.deploymentscripts.v2020_10_01.models.DeploymentScriptListResult] - :raises: ~azure.core.exceptions.HttpResponseError + ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.resource.deploymentscripts.v2020_10_01.models.DeploymentScript] + :raises ~azure.core.exceptions.HttpResponseError: """ - api_version = kwargs.pop('api_version', "2020-10-01") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2020-10-01")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[_models.DeploymentScriptListResult] - cls = kwargs.pop('cls', None) # type: ClsType["_models.DeploymentScriptListResult"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) + def prepare_request(next_link=None): if not next_link: - + request = build_deployment_scripts_list_by_subscription_request( subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.list_by_subscription.metadata['url'], + template_url=self.list_by_subscription.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore else: - - request = build_deployment_scripts_list_by_subscription_request( - subscription_id=self._config.subscription_id, - template_url=next_link, - ) + # make call to next link with the client's api-version + _parsed_next_link = urlparse(next_link) + _next_request_params = case_insensitive_dict(parse_qs(_parsed_next_link.query)) + _next_request_params["api-version"] = self._config.api_version + request = HttpRequest("GET", urljoin(next_link, _parsed_next_link.path), params=_next_request_params) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore request.method = "GET" return request @@ -415,10 +614,8 @@ async def extract_data(pipeline_response): async def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) response = pipeline_response.http_response @@ -429,54 +626,54 @@ async def get_next(next_link=None): return pipeline_response + return AsyncItemPaged(get_next, extract_data) - return AsyncItemPaged( - get_next, extract_data - ) - list_by_subscription.metadata = {'url': "/subscriptions/{subscriptionId}/providers/Microsoft.Resources/deploymentScripts"} # type: ignore + list_by_subscription.metadata = {"url": "/subscriptions/{subscriptionId}/providers/Microsoft.Resources/deploymentScripts"} # type: ignore @distributed_trace_async - async def get_logs( - self, - resource_group_name: str, - script_name: str, - **kwargs: Any - ) -> "_models.ScriptLogsList": + async def get_logs(self, resource_group_name: str, script_name: str, **kwargs: Any) -> _models.ScriptLogsList: """Gets deployment script logs for a given deployment script name. :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. :type resource_group_name: str - :param script_name: Name of the deployment script. + :param script_name: Name of the deployment script. Required. :type script_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: ScriptLogsList, or the result of cls(response) + :return: ScriptLogsList or the result of cls(response) :rtype: ~azure.mgmt.resource.deploymentscripts.v2020_10_01.models.ScriptLogsList - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.ScriptLogsList"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + 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', "2020-10-01") # type: str + api_version = kwargs.pop("api_version", _params.pop("api-version", "2020-10-01")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[_models.ScriptLogsList] - request = build_deployment_scripts_get_logs_request( - subscription_id=self._config.subscription_id, resource_group_name=resource_group_name, script_name=script_name, + subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.get_logs.metadata['url'], + template_url=self.get_logs.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200]: @@ -484,64 +681,66 @@ async def get_logs( error = self._deserialize.failsafe_deserialize(_models.DeploymentScriptsError, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - deserialized = self._deserialize('ScriptLogsList', pipeline_response) + deserialized = self._deserialize("ScriptLogsList", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - get_logs.metadata = {'url': "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/Microsoft.Resources/deploymentScripts/{scriptName}/logs"} # type: ignore - + get_logs.metadata = {"url": "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/Microsoft.Resources/deploymentScripts/{scriptName}/logs"} # type: ignore @distributed_trace_async async def get_logs_default( - self, - resource_group_name: str, - script_name: str, - tail: Optional[int] = None, - **kwargs: Any - ) -> "_models.ScriptLog": + self, resource_group_name: str, script_name: str, tail: Optional[int] = None, **kwargs: Any + ) -> _models.ScriptLog: """Gets deployment script logs for a given deployment script name. :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. :type resource_group_name: str - :param script_name: Name of the deployment script. + :param script_name: Name of the deployment script. Required. :type script_name: str :param tail: The number of lines to show from the tail of the deployment script log. Valid value is a positive number up to 1000. If 'tail' is not provided, all available logs are shown up to container instance log capacity of 4mb. Default value is None. :type tail: int :keyword callable cls: A custom type or function that will be passed the direct response - :return: ScriptLog, or the result of cls(response) + :return: ScriptLog or the result of cls(response) :rtype: ~azure.mgmt.resource.deploymentscripts.v2020_10_01.models.ScriptLog - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.ScriptLog"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) - api_version = kwargs.pop('api_version', "2020-10-01") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2020-10-01")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[_models.ScriptLog] - request = build_deployment_scripts_get_logs_default_request( - subscription_id=self._config.subscription_id, resource_group_name=resource_group_name, script_name=script_name, - api_version=api_version, + subscription_id=self._config.subscription_id, tail=tail, - template_url=self.get_logs_default.metadata['url'], + api_version=api_version, + template_url=self.get_logs_default.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200]: @@ -549,61 +748,66 @@ async def get_logs_default( error = self._deserialize.failsafe_deserialize(_models.DeploymentScriptsError, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - deserialized = self._deserialize('ScriptLog', pipeline_response) + deserialized = self._deserialize("ScriptLog", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - get_logs_default.metadata = {'url': "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/Microsoft.Resources/deploymentScripts/{scriptName}/logs/default"} # type: ignore - + get_logs_default.metadata = {"url": "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/Microsoft.Resources/deploymentScripts/{scriptName}/logs/default"} # type: ignore @distributed_trace def list_by_resource_group( - self, - resource_group_name: str, - **kwargs: Any - ) -> AsyncIterable["_models.DeploymentScriptListResult"]: + self, resource_group_name: str, **kwargs: Any + ) -> AsyncIterable["_models.DeploymentScript"]: """Lists deployments scripts. :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. :type resource_group_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either DeploymentScriptListResult or the result of - cls(response) + :return: An iterator like instance of either DeploymentScript or the result of cls(response) :rtype: - ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.resource.deploymentscripts.v2020_10_01.models.DeploymentScriptListResult] - :raises: ~azure.core.exceptions.HttpResponseError + ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.resource.deploymentscripts.v2020_10_01.models.DeploymentScript] + :raises ~azure.core.exceptions.HttpResponseError: """ - api_version = kwargs.pop('api_version', "2020-10-01") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2020-10-01")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[_models.DeploymentScriptListResult] - cls = kwargs.pop('cls', None) # type: ClsType["_models.DeploymentScriptListResult"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) + def prepare_request(next_link=None): if not next_link: - + request = build_deployment_scripts_list_by_resource_group_request( - subscription_id=self._config.subscription_id, 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'], + 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.url = self._client.format_url(request.url) # type: ignore else: - - request = build_deployment_scripts_list_by_resource_group_request( - subscription_id=self._config.subscription_id, - resource_group_name=resource_group_name, - template_url=next_link, - ) + # make call to next link with the client's api-version + _parsed_next_link = urlparse(next_link) + _next_request_params = case_insensitive_dict(parse_qs(_parsed_next_link.query)) + _next_request_params["api-version"] = self._config.api_version + request = HttpRequest("GET", urljoin(next_link, _parsed_next_link.path), params=_next_request_params) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore request.method = "GET" return request @@ -617,10 +821,8 @@ async def extract_data(pipeline_response): async def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) response = pipeline_response.http_response @@ -631,8 +833,6 @@ async def get_next(next_link=None): return pipeline_response + return AsyncItemPaged(get_next, extract_data) - return AsyncItemPaged( - get_next, extract_data - ) - list_by_resource_group.metadata = {'url': "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/Microsoft.Resources/deploymentScripts"} # type: ignore + list_by_resource_group.metadata = {"url": "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/Microsoft.Resources/deploymentScripts"} # type: ignore diff --git a/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/deploymentscripts/v2020_10_01/aio/operations/_patch.py b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/deploymentscripts/v2020_10_01/aio/operations/_patch.py new file mode 100644 index 0000000000000..f7dd32510333d --- /dev/null +++ b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/deploymentscripts/v2020_10_01/aio/operations/_patch.py @@ -0,0 +1,20 @@ +# ------------------------------------ +# Copyright (c) Microsoft Corporation. +# Licensed under the MIT License. +# ------------------------------------ +"""Customize generated code here. + +Follow our quickstart for examples: https://aka.ms/azsdk/python/dpcodegen/python/customize +""" +from typing import List + +__all__: List[str] = [] # Add all objects you want publicly available to users at this package level + + +def patch_sdk(): + """Do not remove from this file. + + `patch_sdk` is a last resort escape hatch that allows you to do customizations + you can't accomplish using the techniques described in + https://aka.ms/azsdk/python/dpcodegen/python/customize + """ diff --git a/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/deploymentscripts/v2020_10_01/models/__init__.py b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/deploymentscripts/v2020_10_01/models/__init__.py index 41f495e69961f..eea076a09b970 100644 --- a/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/deploymentscripts/v2020_10_01/models/__init__.py +++ b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/deploymentscripts/v2020_10_01/models/__init__.py @@ -29,41 +29,43 @@ from ._models_py3 import SystemData from ._models_py3 import UserAssignedIdentity - -from ._deployment_scripts_client_enums import ( - CleanupOptions, - CreatedByType, - ManagedServiceIdentityType, - ScriptProvisioningState, - ScriptType, -) +from ._deployment_scripts_client_enums import CleanupOptions +from ._deployment_scripts_client_enums import CreatedByType +from ._deployment_scripts_client_enums import ManagedServiceIdentityType +from ._deployment_scripts_client_enums import ScriptProvisioningState +from ._deployment_scripts_client_enums import ScriptType +from ._patch import __all__ as _patch_all +from ._patch import * # type: ignore # pylint: disable=unused-wildcard-import +from ._patch import patch_sdk as _patch_sdk __all__ = [ - 'AzureCliScript', - 'AzureCliScriptProperties', - 'AzurePowerShellScript', - 'AzurePowerShellScriptProperties', - 'AzureResourceBase', - 'ContainerConfiguration', - 'DeploymentScript', - 'DeploymentScriptListResult', - 'DeploymentScriptPropertiesBase', - 'DeploymentScriptUpdateParameter', - 'DeploymentScriptsError', - 'EnvironmentVariable', - 'ErrorAdditionalInfo', - 'ErrorResponse', - 'ManagedServiceIdentity', - 'ScriptConfigurationBase', - 'ScriptLog', - 'ScriptLogsList', - 'ScriptStatus', - 'StorageAccountConfiguration', - 'SystemData', - 'UserAssignedIdentity', - 'CleanupOptions', - 'CreatedByType', - 'ManagedServiceIdentityType', - 'ScriptProvisioningState', - 'ScriptType', + "AzureCliScript", + "AzureCliScriptProperties", + "AzurePowerShellScript", + "AzurePowerShellScriptProperties", + "AzureResourceBase", + "ContainerConfiguration", + "DeploymentScript", + "DeploymentScriptListResult", + "DeploymentScriptPropertiesBase", + "DeploymentScriptUpdateParameter", + "DeploymentScriptsError", + "EnvironmentVariable", + "ErrorAdditionalInfo", + "ErrorResponse", + "ManagedServiceIdentity", + "ScriptConfigurationBase", + "ScriptLog", + "ScriptLogsList", + "ScriptStatus", + "StorageAccountConfiguration", + "SystemData", + "UserAssignedIdentity", + "CleanupOptions", + "CreatedByType", + "ManagedServiceIdentityType", + "ScriptProvisioningState", + "ScriptType", ] +__all__.extend([p for p in _patch_all if p not in __all__]) +_patch_sdk() diff --git a/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/deploymentscripts/v2020_10_01/models/_deployment_scripts_client_enums.py b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/deploymentscripts/v2020_10_01/models/_deployment_scripts_client_enums.py index 278dc1e6bf8e4..41451353e2f9b 100644 --- a/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/deploymentscripts/v2020_10_01/models/_deployment_scripts_client_enums.py +++ b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/deploymentscripts/v2020_10_01/models/_deployment_scripts_client_enums.py @@ -7,11 +7,10 @@ # -------------------------------------------------------------------------- from enum import Enum -from six import with_metaclass from azure.core import CaseInsensitiveEnumMeta -class CleanupOptions(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): +class CleanupOptions(str, Enum, metaclass=CaseInsensitiveEnumMeta): """The clean up preference when the script execution gets in a terminal state. Default setting is 'Always'. """ @@ -20,24 +19,24 @@ class CleanupOptions(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): ON_SUCCESS = "OnSuccess" ON_EXPIRATION = "OnExpiration" -class CreatedByType(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): - """The type of identity that created the resource. - """ + +class CreatedByType(str, Enum, metaclass=CaseInsensitiveEnumMeta): + """The type of identity that created the resource.""" USER = "User" APPLICATION = "Application" MANAGED_IDENTITY = "ManagedIdentity" KEY = "Key" -class ManagedServiceIdentityType(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): - """Type of the managed identity. - """ + +class ManagedServiceIdentityType(str, Enum, metaclass=CaseInsensitiveEnumMeta): + """Type of the managed identity.""" USER_ASSIGNED = "UserAssigned" -class ScriptProvisioningState(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): - """State of the script execution. This only appears in the response. - """ + +class ScriptProvisioningState(str, Enum, metaclass=CaseInsensitiveEnumMeta): + """State of the script execution. This only appears in the response.""" CREATING = "Creating" PROVISIONING_RESOURCES = "ProvisioningResources" @@ -46,9 +45,9 @@ class ScriptProvisioningState(with_metaclass(CaseInsensitiveEnumMeta, str, Enum) FAILED = "Failed" CANCELED = "Canceled" -class ScriptType(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): - """Type of the script. - """ + +class ScriptType(str, Enum, metaclass=CaseInsensitiveEnumMeta): + """Type of the script.""" AZURE_POWER_SHELL = "AzurePowerShell" AZURE_CLI = "AzureCLI" diff --git a/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/deploymentscripts/v2020_10_01/models/_models_py3.py b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/deploymentscripts/v2020_10_01/models/_models_py3.py index c1ca559fcca8d..2de9537d18763 100644 --- a/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/deploymentscripts/v2020_10_01/models/_models_py3.py +++ b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/deploymentscripts/v2020_10_01/models/_models_py3.py @@ -1,4 +1,5 @@ # coding=utf-8 +# pylint: disable=too-many-lines # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. # Licensed under the MIT License. See License.txt in the project root for license information. @@ -7,15 +8,16 @@ # -------------------------------------------------------------------------- import datetime -from typing import Dict, List, Optional, Union +from typing import Dict, List, Optional, TYPE_CHECKING, Union -from azure.core.exceptions import HttpResponseError -import msrest.serialization +from ... import _serialization -from ._deployment_scripts_client_enums import * +if TYPE_CHECKING: + # pylint: disable=unused-import,ungrouped-imports + from .. import models as _models -class AzureResourceBase(msrest.serialization.Model): +class AzureResourceBase(_serialization.Model): """Common properties for all Azure resources. Variables are only populated by the server, and will be ignored when sending a request. @@ -29,24 +31,20 @@ class AzureResourceBase(msrest.serialization.Model): """ _validation = { - 'id': {'readonly': True}, - 'name': {'readonly': True}, - 'type': {'readonly': True}, + "id": {"readonly": True}, + "name": {"readonly": True}, + "type": {"readonly": True}, } _attribute_map = { - 'id': {'key': 'id', 'type': 'str'}, - 'name': {'key': 'name', 'type': 'str'}, - 'type': {'key': 'type', 'type': 'str'}, + "id": {"key": "id", "type": "str"}, + "name": {"key": "name", "type": "str"}, + "type": {"key": "type", "type": "str"}, } - def __init__( - self, - **kwargs - ): - """ - """ - super(AzureResourceBase, self).__init__(**kwargs) + def __init__(self, **kwargs): + """ """ + super().__init__(**kwargs) self.id = None self.name = None self.type = None @@ -55,8 +53,8 @@ def __init__( class DeploymentScript(AzureResourceBase): """Deployment script object. - You probably want to use the sub-classes and not this class directly. Known - sub-classes are: AzureCliScript, AzurePowerShellScript. + You probably want to use the sub-classes and not this class directly. Known sub-classes are: + AzureCliScript, AzurePowerShellScript Variables are only populated by the server, and will be ignored when sending a request. @@ -72,47 +70,44 @@ class DeploymentScript(AzureResourceBase): Currently, only user-assigned MSI is supported. :vartype identity: ~azure.mgmt.resource.deploymentscripts.v2020_10_01.models.ManagedServiceIdentity - :ivar location: Required. The location of the ACI and the storage account for the deployment - script. + :ivar location: The location of the ACI and the storage account for the deployment script. + Required. :vartype location: str - :ivar tags: A set of tags. Resource tags. + :ivar tags: Resource tags. :vartype tags: dict[str, str] - :ivar kind: Required. Type of the script.Constant filled by server. Possible values include: - "AzurePowerShell", "AzureCLI". + :ivar kind: Type of the script. Required. Known values are: "AzurePowerShell" and "AzureCLI". :vartype kind: str or ~azure.mgmt.resource.deploymentscripts.v2020_10_01.models.ScriptType :ivar system_data: The system metadata related to this resource. :vartype system_data: ~azure.mgmt.resource.deploymentscripts.v2020_10_01.models.SystemData """ _validation = { - 'id': {'readonly': True}, - 'name': {'readonly': True}, - 'type': {'readonly': True}, - 'location': {'required': True}, - 'kind': {'required': True}, - 'system_data': {'readonly': True}, + "id": {"readonly": True}, + "name": {"readonly": True}, + "type": {"readonly": True}, + "location": {"required": True}, + "kind": {"required": True}, + "system_data": {"readonly": True}, } _attribute_map = { - 'id': {'key': 'id', 'type': 'str'}, - 'name': {'key': 'name', 'type': 'str'}, - 'type': {'key': 'type', 'type': 'str'}, - 'identity': {'key': 'identity', 'type': 'ManagedServiceIdentity'}, - 'location': {'key': 'location', 'type': 'str'}, - 'tags': {'key': 'tags', 'type': '{str}'}, - 'kind': {'key': 'kind', 'type': 'str'}, - 'system_data': {'key': 'systemData', 'type': 'SystemData'}, + "id": {"key": "id", "type": "str"}, + "name": {"key": "name", "type": "str"}, + "type": {"key": "type", "type": "str"}, + "identity": {"key": "identity", "type": "ManagedServiceIdentity"}, + "location": {"key": "location", "type": "str"}, + "tags": {"key": "tags", "type": "{str}"}, + "kind": {"key": "kind", "type": "str"}, + "system_data": {"key": "systemData", "type": "SystemData"}, } - _subtype_map = { - 'kind': {'AzureCLI': 'AzureCliScript', 'AzurePowerShell': 'AzurePowerShellScript'} - } + _subtype_map = {"kind": {"AzureCLI": "AzureCliScript", "AzurePowerShell": "AzurePowerShellScript"}} def __init__( self, *, location: str, - identity: Optional["ManagedServiceIdentity"] = None, + identity: Optional["_models.ManagedServiceIdentity"] = None, tags: Optional[Dict[str, str]] = None, **kwargs ): @@ -121,21 +116,21 @@ def __init__( Currently, only user-assigned MSI is supported. :paramtype identity: ~azure.mgmt.resource.deploymentscripts.v2020_10_01.models.ManagedServiceIdentity - :keyword location: Required. The location of the ACI and the storage account for the deployment - script. + :keyword location: The location of the ACI and the storage account for the deployment script. + Required. :paramtype location: str - :keyword tags: A set of tags. Resource tags. + :keyword tags: Resource tags. :paramtype tags: dict[str, str] """ - super(DeploymentScript, self).__init__(**kwargs) + super().__init__(**kwargs) self.identity = identity self.location = location self.tags = tags - self.kind = 'DeploymentScript' # type: str + self.kind = None # type: Optional[str] self.system_data = None -class AzureCliScript(DeploymentScript): +class AzureCliScript(DeploymentScript): # pylint: disable=too-many-instance-attributes """Object model for the Azure CLI script. Variables are only populated by the server, and will be ignored when sending a request. @@ -152,13 +147,12 @@ class AzureCliScript(DeploymentScript): Currently, only user-assigned MSI is supported. :vartype identity: ~azure.mgmt.resource.deploymentscripts.v2020_10_01.models.ManagedServiceIdentity - :ivar location: Required. The location of the ACI and the storage account for the deployment - script. + :ivar location: The location of the ACI and the storage account for the deployment script. + Required. :vartype location: str - :ivar tags: A set of tags. Resource tags. + :ivar tags: Resource tags. :vartype tags: dict[str, str] - :ivar kind: Required. Type of the script.Constant filled by server. Possible values include: - "AzurePowerShell", "AzureCLI". + :ivar kind: Type of the script. Required. Known values are: "AzurePowerShell" and "AzureCLI". :vartype kind: str or ~azure.mgmt.resource.deploymentscripts.v2020_10_01.models.ScriptType :ivar system_data: The system metadata related to this resource. :vartype system_data: ~azure.mgmt.resource.deploymentscripts.v2020_10_01.models.SystemData @@ -169,19 +163,19 @@ class AzureCliScript(DeploymentScript): :vartype storage_account_settings: ~azure.mgmt.resource.deploymentscripts.v2020_10_01.models.StorageAccountConfiguration :ivar cleanup_preference: The clean up preference when the script execution gets in a terminal - state. Default setting is 'Always'. Possible values include: "Always", "OnSuccess", - "OnExpiration". Default value: "Always". + state. Default setting is 'Always'. Known values are: "Always", "OnSuccess", and + "OnExpiration". :vartype cleanup_preference: str or ~azure.mgmt.resource.deploymentscripts.v2020_10_01.models.CleanupOptions :ivar provisioning_state: State of the script execution. This only appears in the response. - Possible values include: "Creating", "ProvisioningResources", "Running", "Succeeded", "Failed", + Known values are: "Creating", "ProvisioningResources", "Running", "Succeeded", "Failed", and "Canceled". :vartype provisioning_state: str or ~azure.mgmt.resource.deploymentscripts.v2020_10_01.models.ScriptProvisioningState :ivar status: Contains the results of script execution. :vartype status: ~azure.mgmt.resource.deploymentscripts.v2020_10_01.models.ScriptStatus :ivar outputs: List of script outputs. - :vartype outputs: dict[str, any] + :vartype outputs: dict[str, JSON] :ivar primary_script_uri: Uri for the script. This is the entry point for the external script. :vartype primary_script_uri: str :ivar supporting_script_uris: Supporting files for the external script. @@ -197,55 +191,55 @@ class AzureCliScript(DeploymentScript): :ivar force_update_tag: Gets or sets how the deployment script should be forced to execute even if the script resource has not changed. Can be current time stamp or a GUID. :vartype force_update_tag: str - :ivar retention_interval: Required. Interval for which the service retains the script resource - after it reaches a terminal state. Resource will be deleted when this duration expires. - Duration is based on ISO 8601 pattern (for example P1D means one day). + :ivar retention_interval: Interval for which the service retains the script resource after it + reaches a terminal state. Resource will be deleted when this duration expires. Duration is + based on ISO 8601 pattern (for example P1D means one day). Required. :vartype retention_interval: ~datetime.timedelta :ivar timeout: Maximum allowed script execution time specified in ISO 8601 format. Default value is P1D. :vartype timeout: ~datetime.timedelta - :ivar az_cli_version: Required. Azure CLI module version to be used. + :ivar az_cli_version: Azure CLI module version to be used. Required. :vartype az_cli_version: str """ _validation = { - 'id': {'readonly': True}, - 'name': {'readonly': True}, - 'type': {'readonly': True}, - 'location': {'required': True}, - 'kind': {'required': True}, - 'system_data': {'readonly': True}, - 'provisioning_state': {'readonly': True}, - 'status': {'readonly': True}, - 'outputs': {'readonly': True}, - 'retention_interval': {'required': True}, - 'az_cli_version': {'required': True}, + "id": {"readonly": True}, + "name": {"readonly": True}, + "type": {"readonly": True}, + "location": {"required": True}, + "kind": {"required": True}, + "system_data": {"readonly": True}, + "provisioning_state": {"readonly": True}, + "status": {"readonly": True}, + "outputs": {"readonly": True}, + "retention_interval": {"required": True}, + "az_cli_version": {"required": True}, } _attribute_map = { - 'id': {'key': 'id', 'type': 'str'}, - 'name': {'key': 'name', 'type': 'str'}, - 'type': {'key': 'type', 'type': 'str'}, - 'identity': {'key': 'identity', 'type': 'ManagedServiceIdentity'}, - 'location': {'key': 'location', 'type': 'str'}, - 'tags': {'key': 'tags', 'type': '{str}'}, - 'kind': {'key': 'kind', 'type': 'str'}, - 'system_data': {'key': 'systemData', 'type': 'SystemData'}, - 'container_settings': {'key': 'properties.containerSettings', 'type': 'ContainerConfiguration'}, - 'storage_account_settings': {'key': 'properties.storageAccountSettings', 'type': 'StorageAccountConfiguration'}, - 'cleanup_preference': {'key': 'properties.cleanupPreference', 'type': 'str'}, - 'provisioning_state': {'key': 'properties.provisioningState', 'type': 'str'}, - 'status': {'key': 'properties.status', 'type': 'ScriptStatus'}, - 'outputs': {'key': 'properties.outputs', 'type': '{object}'}, - 'primary_script_uri': {'key': 'properties.primaryScriptUri', 'type': 'str'}, - 'supporting_script_uris': {'key': 'properties.supportingScriptUris', 'type': '[str]'}, - 'script_content': {'key': 'properties.scriptContent', 'type': 'str'}, - 'arguments': {'key': 'properties.arguments', 'type': 'str'}, - 'environment_variables': {'key': 'properties.environmentVariables', 'type': '[EnvironmentVariable]'}, - 'force_update_tag': {'key': 'properties.forceUpdateTag', 'type': 'str'}, - 'retention_interval': {'key': 'properties.retentionInterval', 'type': 'duration'}, - 'timeout': {'key': 'properties.timeout', 'type': 'duration'}, - 'az_cli_version': {'key': 'properties.azCliVersion', 'type': 'str'}, + "id": {"key": "id", "type": "str"}, + "name": {"key": "name", "type": "str"}, + "type": {"key": "type", "type": "str"}, + "identity": {"key": "identity", "type": "ManagedServiceIdentity"}, + "location": {"key": "location", "type": "str"}, + "tags": {"key": "tags", "type": "{str}"}, + "kind": {"key": "kind", "type": "str"}, + "system_data": {"key": "systemData", "type": "SystemData"}, + "container_settings": {"key": "properties.containerSettings", "type": "ContainerConfiguration"}, + "storage_account_settings": {"key": "properties.storageAccountSettings", "type": "StorageAccountConfiguration"}, + "cleanup_preference": {"key": "properties.cleanupPreference", "type": "str"}, + "provisioning_state": {"key": "properties.provisioningState", "type": "str"}, + "status": {"key": "properties.status", "type": "ScriptStatus"}, + "outputs": {"key": "properties.outputs", "type": "{object}"}, + "primary_script_uri": {"key": "properties.primaryScriptUri", "type": "str"}, + "supporting_script_uris": {"key": "properties.supportingScriptUris", "type": "[str]"}, + "script_content": {"key": "properties.scriptContent", "type": "str"}, + "arguments": {"key": "properties.arguments", "type": "str"}, + "environment_variables": {"key": "properties.environmentVariables", "type": "[EnvironmentVariable]"}, + "force_update_tag": {"key": "properties.forceUpdateTag", "type": "str"}, + "retention_interval": {"key": "properties.retentionInterval", "type": "duration"}, + "timeout": {"key": "properties.timeout", "type": "duration"}, + "az_cli_version": {"key": "properties.azCliVersion", "type": "str"}, } def __init__( @@ -254,18 +248,18 @@ def __init__( location: str, retention_interval: datetime.timedelta, az_cli_version: str, - identity: Optional["ManagedServiceIdentity"] = None, + identity: Optional["_models.ManagedServiceIdentity"] = None, tags: Optional[Dict[str, str]] = None, - container_settings: Optional["ContainerConfiguration"] = None, - storage_account_settings: Optional["StorageAccountConfiguration"] = None, - cleanup_preference: Optional[Union[str, "CleanupOptions"]] = "Always", + container_settings: Optional["_models.ContainerConfiguration"] = None, + storage_account_settings: Optional["_models.StorageAccountConfiguration"] = None, + cleanup_preference: Union[str, "_models.CleanupOptions"] = "Always", primary_script_uri: Optional[str] = None, supporting_script_uris: Optional[List[str]] = None, script_content: Optional[str] = None, arguments: Optional[str] = None, - environment_variables: Optional[List["EnvironmentVariable"]] = None, + environment_variables: Optional[List["_models.EnvironmentVariable"]] = None, force_update_tag: Optional[str] = None, - timeout: Optional[datetime.timedelta] = "P1D", + timeout: datetime.timedelta = "P1D", **kwargs ): """ @@ -273,10 +267,10 @@ def __init__( Currently, only user-assigned MSI is supported. :paramtype identity: ~azure.mgmt.resource.deploymentscripts.v2020_10_01.models.ManagedServiceIdentity - :keyword location: Required. The location of the ACI and the storage account for the deployment - script. + :keyword location: The location of the ACI and the storage account for the deployment script. + Required. :paramtype location: str - :keyword tags: A set of tags. Resource tags. + :keyword tags: Resource tags. :paramtype tags: dict[str, str] :keyword container_settings: Container settings. :paramtype container_settings: @@ -285,8 +279,8 @@ def __init__( :paramtype storage_account_settings: ~azure.mgmt.resource.deploymentscripts.v2020_10_01.models.StorageAccountConfiguration :keyword cleanup_preference: The clean up preference when the script execution gets in a - terminal state. Default setting is 'Always'. Possible values include: "Always", "OnSuccess", - "OnExpiration". Default value: "Always". + terminal state. Default setting is 'Always'. Known values are: "Always", "OnSuccess", and + "OnExpiration". :paramtype cleanup_preference: str or ~azure.mgmt.resource.deploymentscripts.v2020_10_01.models.CleanupOptions :keyword primary_script_uri: Uri for the script. This is the entry point for the external @@ -305,18 +299,18 @@ def __init__( :keyword force_update_tag: Gets or sets how the deployment script should be forced to execute even if the script resource has not changed. Can be current time stamp or a GUID. :paramtype force_update_tag: str - :keyword retention_interval: Required. Interval for which the service retains the script - resource after it reaches a terminal state. Resource will be deleted when this duration - expires. Duration is based on ISO 8601 pattern (for example P1D means one day). + :keyword retention_interval: Interval for which the service retains the script resource after + it reaches a terminal state. Resource will be deleted when this duration expires. Duration is + based on ISO 8601 pattern (for example P1D means one day). Required. :paramtype retention_interval: ~datetime.timedelta :keyword timeout: Maximum allowed script execution time specified in ISO 8601 format. Default value is P1D. :paramtype timeout: ~datetime.timedelta - :keyword az_cli_version: Required. Azure CLI module version to be used. + :keyword az_cli_version: Azure CLI module version to be used. Required. :paramtype az_cli_version: str """ - super(AzureCliScript, self).__init__(identity=identity, location=location, tags=tags, **kwargs) - self.kind = 'AzureCLI' # type: str + super().__init__(identity=identity, location=location, tags=tags, **kwargs) + self.kind = "AzureCLI" # type: str self.container_settings = container_settings self.storage_account_settings = storage_account_settings self.cleanup_preference = cleanup_preference @@ -334,7 +328,7 @@ def __init__( self.az_cli_version = az_cli_version -class ScriptConfigurationBase(msrest.serialization.Model): +class ScriptConfigurationBase(_serialization.Model): """Common configuration settings for both Azure PowerShell and Azure CLI scripts. All required parameters must be populated in order to send to Azure. @@ -354,9 +348,9 @@ class ScriptConfigurationBase(msrest.serialization.Model): :ivar force_update_tag: Gets or sets how the deployment script should be forced to execute even if the script resource has not changed. Can be current time stamp or a GUID. :vartype force_update_tag: str - :ivar retention_interval: Required. Interval for which the service retains the script resource - after it reaches a terminal state. Resource will be deleted when this duration expires. - Duration is based on ISO 8601 pattern (for example P1D means one day). + :ivar retention_interval: Interval for which the service retains the script resource after it + reaches a terminal state. Resource will be deleted when this duration expires. Duration is + based on ISO 8601 pattern (for example P1D means one day). Required. :vartype retention_interval: ~datetime.timedelta :ivar timeout: Maximum allowed script execution time specified in ISO 8601 format. Default value is P1D. @@ -364,18 +358,18 @@ class ScriptConfigurationBase(msrest.serialization.Model): """ _validation = { - 'retention_interval': {'required': True}, + "retention_interval": {"required": True}, } _attribute_map = { - 'primary_script_uri': {'key': 'primaryScriptUri', 'type': 'str'}, - 'supporting_script_uris': {'key': 'supportingScriptUris', 'type': '[str]'}, - 'script_content': {'key': 'scriptContent', 'type': 'str'}, - 'arguments': {'key': 'arguments', 'type': 'str'}, - 'environment_variables': {'key': 'environmentVariables', 'type': '[EnvironmentVariable]'}, - 'force_update_tag': {'key': 'forceUpdateTag', 'type': 'str'}, - 'retention_interval': {'key': 'retentionInterval', 'type': 'duration'}, - 'timeout': {'key': 'timeout', 'type': 'duration'}, + "primary_script_uri": {"key": "primaryScriptUri", "type": "str"}, + "supporting_script_uris": {"key": "supportingScriptUris", "type": "[str]"}, + "script_content": {"key": "scriptContent", "type": "str"}, + "arguments": {"key": "arguments", "type": "str"}, + "environment_variables": {"key": "environmentVariables", "type": "[EnvironmentVariable]"}, + "force_update_tag": {"key": "forceUpdateTag", "type": "str"}, + "retention_interval": {"key": "retentionInterval", "type": "duration"}, + "timeout": {"key": "timeout", "type": "duration"}, } def __init__( @@ -386,9 +380,9 @@ def __init__( supporting_script_uris: Optional[List[str]] = None, script_content: Optional[str] = None, arguments: Optional[str] = None, - environment_variables: Optional[List["EnvironmentVariable"]] = None, + environment_variables: Optional[List["_models.EnvironmentVariable"]] = None, force_update_tag: Optional[str] = None, - timeout: Optional[datetime.timedelta] = "P1D", + timeout: datetime.timedelta = "P1D", **kwargs ): """ @@ -408,15 +402,15 @@ def __init__( :keyword force_update_tag: Gets or sets how the deployment script should be forced to execute even if the script resource has not changed. Can be current time stamp or a GUID. :paramtype force_update_tag: str - :keyword retention_interval: Required. Interval for which the service retains the script - resource after it reaches a terminal state. Resource will be deleted when this duration - expires. Duration is based on ISO 8601 pattern (for example P1D means one day). + :keyword retention_interval: Interval for which the service retains the script resource after + it reaches a terminal state. Resource will be deleted when this duration expires. Duration is + based on ISO 8601 pattern (for example P1D means one day). Required. :paramtype retention_interval: ~datetime.timedelta :keyword timeout: Maximum allowed script execution time specified in ISO 8601 format. Default value is P1D. :paramtype timeout: ~datetime.timedelta """ - super(ScriptConfigurationBase, self).__init__(**kwargs) + super().__init__(**kwargs) self.primary_script_uri = primary_script_uri self.supporting_script_uris = supporting_script_uris self.script_content = script_content @@ -427,7 +421,7 @@ def __init__( self.timeout = timeout -class DeploymentScriptPropertiesBase(msrest.serialization.Model): +class DeploymentScriptPropertiesBase(_serialization.Model): """Common properties for the deployment script. Variables are only populated by the server, and will be ignored when sending a request. @@ -439,42 +433,42 @@ class DeploymentScriptPropertiesBase(msrest.serialization.Model): :vartype storage_account_settings: ~azure.mgmt.resource.deploymentscripts.v2020_10_01.models.StorageAccountConfiguration :ivar cleanup_preference: The clean up preference when the script execution gets in a terminal - state. Default setting is 'Always'. Possible values include: "Always", "OnSuccess", - "OnExpiration". Default value: "Always". + state. Default setting is 'Always'. Known values are: "Always", "OnSuccess", and + "OnExpiration". :vartype cleanup_preference: str or ~azure.mgmt.resource.deploymentscripts.v2020_10_01.models.CleanupOptions :ivar provisioning_state: State of the script execution. This only appears in the response. - Possible values include: "Creating", "ProvisioningResources", "Running", "Succeeded", "Failed", + Known values are: "Creating", "ProvisioningResources", "Running", "Succeeded", "Failed", and "Canceled". :vartype provisioning_state: str or ~azure.mgmt.resource.deploymentscripts.v2020_10_01.models.ScriptProvisioningState :ivar status: Contains the results of script execution. :vartype status: ~azure.mgmt.resource.deploymentscripts.v2020_10_01.models.ScriptStatus :ivar outputs: List of script outputs. - :vartype outputs: dict[str, any] + :vartype outputs: dict[str, JSON] """ _validation = { - 'provisioning_state': {'readonly': True}, - 'status': {'readonly': True}, - 'outputs': {'readonly': True}, + "provisioning_state": {"readonly": True}, + "status": {"readonly": True}, + "outputs": {"readonly": True}, } _attribute_map = { - 'container_settings': {'key': 'containerSettings', 'type': 'ContainerConfiguration'}, - 'storage_account_settings': {'key': 'storageAccountSettings', 'type': 'StorageAccountConfiguration'}, - 'cleanup_preference': {'key': 'cleanupPreference', 'type': 'str'}, - 'provisioning_state': {'key': 'provisioningState', 'type': 'str'}, - 'status': {'key': 'status', 'type': 'ScriptStatus'}, - 'outputs': {'key': 'outputs', 'type': '{object}'}, + "container_settings": {"key": "containerSettings", "type": "ContainerConfiguration"}, + "storage_account_settings": {"key": "storageAccountSettings", "type": "StorageAccountConfiguration"}, + "cleanup_preference": {"key": "cleanupPreference", "type": "str"}, + "provisioning_state": {"key": "provisioningState", "type": "str"}, + "status": {"key": "status", "type": "ScriptStatus"}, + "outputs": {"key": "outputs", "type": "{object}"}, } def __init__( self, *, - container_settings: Optional["ContainerConfiguration"] = None, - storage_account_settings: Optional["StorageAccountConfiguration"] = None, - cleanup_preference: Optional[Union[str, "CleanupOptions"]] = "Always", + container_settings: Optional["_models.ContainerConfiguration"] = None, + storage_account_settings: Optional["_models.StorageAccountConfiguration"] = None, + cleanup_preference: Union[str, "_models.CleanupOptions"] = "Always", **kwargs ): """ @@ -485,12 +479,12 @@ def __init__( :paramtype storage_account_settings: ~azure.mgmt.resource.deploymentscripts.v2020_10_01.models.StorageAccountConfiguration :keyword cleanup_preference: The clean up preference when the script execution gets in a - terminal state. Default setting is 'Always'. Possible values include: "Always", "OnSuccess", - "OnExpiration". Default value: "Always". + terminal state. Default setting is 'Always'. Known values are: "Always", "OnSuccess", and + "OnExpiration". :paramtype cleanup_preference: str or ~azure.mgmt.resource.deploymentscripts.v2020_10_01.models.CleanupOptions """ - super(DeploymentScriptPropertiesBase, self).__init__(**kwargs) + super().__init__(**kwargs) self.container_settings = container_settings self.storage_account_settings = storage_account_settings self.cleanup_preference = cleanup_preference @@ -499,7 +493,9 @@ def __init__( self.outputs = None -class AzureCliScriptProperties(DeploymentScriptPropertiesBase, ScriptConfigurationBase): +class AzureCliScriptProperties( + DeploymentScriptPropertiesBase, ScriptConfigurationBase +): # pylint: disable=too-many-instance-attributes """Properties of the Azure CLI script object. Variables are only populated by the server, and will be ignored when sending a request. @@ -521,9 +517,9 @@ class AzureCliScriptProperties(DeploymentScriptPropertiesBase, ScriptConfigurati :ivar force_update_tag: Gets or sets how the deployment script should be forced to execute even if the script resource has not changed. Can be current time stamp or a GUID. :vartype force_update_tag: str - :ivar retention_interval: Required. Interval for which the service retains the script resource - after it reaches a terminal state. Resource will be deleted when this duration expires. - Duration is based on ISO 8601 pattern (for example P1D means one day). + :ivar retention_interval: Interval for which the service retains the script resource after it + reaches a terminal state. Resource will be deleted when this duration expires. Duration is + based on ISO 8601 pattern (for example P1D means one day). Required. :vartype retention_interval: ~datetime.timedelta :ivar timeout: Maximum allowed script execution time specified in ISO 8601 format. Default value is P1D. @@ -535,47 +531,47 @@ class AzureCliScriptProperties(DeploymentScriptPropertiesBase, ScriptConfigurati :vartype storage_account_settings: ~azure.mgmt.resource.deploymentscripts.v2020_10_01.models.StorageAccountConfiguration :ivar cleanup_preference: The clean up preference when the script execution gets in a terminal - state. Default setting is 'Always'. Possible values include: "Always", "OnSuccess", - "OnExpiration". Default value: "Always". + state. Default setting is 'Always'. Known values are: "Always", "OnSuccess", and + "OnExpiration". :vartype cleanup_preference: str or ~azure.mgmt.resource.deploymentscripts.v2020_10_01.models.CleanupOptions :ivar provisioning_state: State of the script execution. This only appears in the response. - Possible values include: "Creating", "ProvisioningResources", "Running", "Succeeded", "Failed", + Known values are: "Creating", "ProvisioningResources", "Running", "Succeeded", "Failed", and "Canceled". :vartype provisioning_state: str or ~azure.mgmt.resource.deploymentscripts.v2020_10_01.models.ScriptProvisioningState :ivar status: Contains the results of script execution. :vartype status: ~azure.mgmt.resource.deploymentscripts.v2020_10_01.models.ScriptStatus :ivar outputs: List of script outputs. - :vartype outputs: dict[str, any] - :ivar az_cli_version: Required. Azure CLI module version to be used. + :vartype outputs: dict[str, JSON] + :ivar az_cli_version: Azure CLI module version to be used. Required. :vartype az_cli_version: str """ _validation = { - 'retention_interval': {'required': True}, - 'provisioning_state': {'readonly': True}, - 'status': {'readonly': True}, - 'outputs': {'readonly': True}, - 'az_cli_version': {'required': True}, + "retention_interval": {"required": True}, + "provisioning_state": {"readonly": True}, + "status": {"readonly": True}, + "outputs": {"readonly": True}, + "az_cli_version": {"required": True}, } _attribute_map = { - 'primary_script_uri': {'key': 'primaryScriptUri', 'type': 'str'}, - 'supporting_script_uris': {'key': 'supportingScriptUris', 'type': '[str]'}, - 'script_content': {'key': 'scriptContent', 'type': 'str'}, - 'arguments': {'key': 'arguments', 'type': 'str'}, - 'environment_variables': {'key': 'environmentVariables', 'type': '[EnvironmentVariable]'}, - 'force_update_tag': {'key': 'forceUpdateTag', 'type': 'str'}, - 'retention_interval': {'key': 'retentionInterval', 'type': 'duration'}, - 'timeout': {'key': 'timeout', 'type': 'duration'}, - 'container_settings': {'key': 'containerSettings', 'type': 'ContainerConfiguration'}, - 'storage_account_settings': {'key': 'storageAccountSettings', 'type': 'StorageAccountConfiguration'}, - 'cleanup_preference': {'key': 'cleanupPreference', 'type': 'str'}, - 'provisioning_state': {'key': 'provisioningState', 'type': 'str'}, - 'status': {'key': 'status', 'type': 'ScriptStatus'}, - 'outputs': {'key': 'outputs', 'type': '{object}'}, - 'az_cli_version': {'key': 'azCliVersion', 'type': 'str'}, + "primary_script_uri": {"key": "primaryScriptUri", "type": "str"}, + "supporting_script_uris": {"key": "supportingScriptUris", "type": "[str]"}, + "script_content": {"key": "scriptContent", "type": "str"}, + "arguments": {"key": "arguments", "type": "str"}, + "environment_variables": {"key": "environmentVariables", "type": "[EnvironmentVariable]"}, + "force_update_tag": {"key": "forceUpdateTag", "type": "str"}, + "retention_interval": {"key": "retentionInterval", "type": "duration"}, + "timeout": {"key": "timeout", "type": "duration"}, + "container_settings": {"key": "containerSettings", "type": "ContainerConfiguration"}, + "storage_account_settings": {"key": "storageAccountSettings", "type": "StorageAccountConfiguration"}, + "cleanup_preference": {"key": "cleanupPreference", "type": "str"}, + "provisioning_state": {"key": "provisioningState", "type": "str"}, + "status": {"key": "status", "type": "ScriptStatus"}, + "outputs": {"key": "outputs", "type": "{object}"}, + "az_cli_version": {"key": "azCliVersion", "type": "str"}, } def __init__( @@ -587,12 +583,12 @@ def __init__( supporting_script_uris: Optional[List[str]] = None, script_content: Optional[str] = None, arguments: Optional[str] = None, - environment_variables: Optional[List["EnvironmentVariable"]] = None, + environment_variables: Optional[List["_models.EnvironmentVariable"]] = None, force_update_tag: Optional[str] = None, - timeout: Optional[datetime.timedelta] = "P1D", - container_settings: Optional["ContainerConfiguration"] = None, - storage_account_settings: Optional["StorageAccountConfiguration"] = None, - cleanup_preference: Optional[Union[str, "CleanupOptions"]] = "Always", + timeout: datetime.timedelta = "P1D", + container_settings: Optional["_models.ContainerConfiguration"] = None, + storage_account_settings: Optional["_models.StorageAccountConfiguration"] = None, + cleanup_preference: Union[str, "_models.CleanupOptions"] = "Always", **kwargs ): """ @@ -612,9 +608,9 @@ def __init__( :keyword force_update_tag: Gets or sets how the deployment script should be forced to execute even if the script resource has not changed. Can be current time stamp or a GUID. :paramtype force_update_tag: str - :keyword retention_interval: Required. Interval for which the service retains the script - resource after it reaches a terminal state. Resource will be deleted when this duration - expires. Duration is based on ISO 8601 pattern (for example P1D means one day). + :keyword retention_interval: Interval for which the service retains the script resource after + it reaches a terminal state. Resource will be deleted when this duration expires. Duration is + based on ISO 8601 pattern (for example P1D means one day). Required. :paramtype retention_interval: ~datetime.timedelta :keyword timeout: Maximum allowed script execution time specified in ISO 8601 format. Default value is P1D. @@ -626,14 +622,27 @@ def __init__( :paramtype storage_account_settings: ~azure.mgmt.resource.deploymentscripts.v2020_10_01.models.StorageAccountConfiguration :keyword cleanup_preference: The clean up preference when the script execution gets in a - terminal state. Default setting is 'Always'. Possible values include: "Always", "OnSuccess", - "OnExpiration". Default value: "Always". + terminal state. Default setting is 'Always'. Known values are: "Always", "OnSuccess", and + "OnExpiration". :paramtype cleanup_preference: str or ~azure.mgmt.resource.deploymentscripts.v2020_10_01.models.CleanupOptions - :keyword az_cli_version: Required. Azure CLI module version to be used. + :keyword az_cli_version: Azure CLI module version to be used. Required. :paramtype az_cli_version: str """ - super(AzureCliScriptProperties, self).__init__(container_settings=container_settings, storage_account_settings=storage_account_settings, cleanup_preference=cleanup_preference, primary_script_uri=primary_script_uri, supporting_script_uris=supporting_script_uris, script_content=script_content, arguments=arguments, environment_variables=environment_variables, force_update_tag=force_update_tag, retention_interval=retention_interval, timeout=timeout, **kwargs) + super().__init__( + container_settings=container_settings, + storage_account_settings=storage_account_settings, + cleanup_preference=cleanup_preference, + primary_script_uri=primary_script_uri, + supporting_script_uris=supporting_script_uris, + script_content=script_content, + arguments=arguments, + environment_variables=environment_variables, + force_update_tag=force_update_tag, + retention_interval=retention_interval, + timeout=timeout, + **kwargs + ) self.primary_script_uri = primary_script_uri self.supporting_script_uris = supporting_script_uris self.script_content = script_content @@ -651,7 +660,7 @@ def __init__( self.outputs = None -class AzurePowerShellScript(DeploymentScript): +class AzurePowerShellScript(DeploymentScript): # pylint: disable=too-many-instance-attributes """Object model for the Azure PowerShell script. Variables are only populated by the server, and will be ignored when sending a request. @@ -668,13 +677,12 @@ class AzurePowerShellScript(DeploymentScript): Currently, only user-assigned MSI is supported. :vartype identity: ~azure.mgmt.resource.deploymentscripts.v2020_10_01.models.ManagedServiceIdentity - :ivar location: Required. The location of the ACI and the storage account for the deployment - script. + :ivar location: The location of the ACI and the storage account for the deployment script. + Required. :vartype location: str - :ivar tags: A set of tags. Resource tags. + :ivar tags: Resource tags. :vartype tags: dict[str, str] - :ivar kind: Required. Type of the script.Constant filled by server. Possible values include: - "AzurePowerShell", "AzureCLI". + :ivar kind: Type of the script. Required. Known values are: "AzurePowerShell" and "AzureCLI". :vartype kind: str or ~azure.mgmt.resource.deploymentscripts.v2020_10_01.models.ScriptType :ivar system_data: The system metadata related to this resource. :vartype system_data: ~azure.mgmt.resource.deploymentscripts.v2020_10_01.models.SystemData @@ -685,19 +693,19 @@ class AzurePowerShellScript(DeploymentScript): :vartype storage_account_settings: ~azure.mgmt.resource.deploymentscripts.v2020_10_01.models.StorageAccountConfiguration :ivar cleanup_preference: The clean up preference when the script execution gets in a terminal - state. Default setting is 'Always'. Possible values include: "Always", "OnSuccess", - "OnExpiration". Default value: "Always". + state. Default setting is 'Always'. Known values are: "Always", "OnSuccess", and + "OnExpiration". :vartype cleanup_preference: str or ~azure.mgmt.resource.deploymentscripts.v2020_10_01.models.CleanupOptions :ivar provisioning_state: State of the script execution. This only appears in the response. - Possible values include: "Creating", "ProvisioningResources", "Running", "Succeeded", "Failed", + Known values are: "Creating", "ProvisioningResources", "Running", "Succeeded", "Failed", and "Canceled". :vartype provisioning_state: str or ~azure.mgmt.resource.deploymentscripts.v2020_10_01.models.ScriptProvisioningState :ivar status: Contains the results of script execution. :vartype status: ~azure.mgmt.resource.deploymentscripts.v2020_10_01.models.ScriptStatus :ivar outputs: List of script outputs. - :vartype outputs: dict[str, any] + :vartype outputs: dict[str, JSON] :ivar primary_script_uri: Uri for the script. This is the entry point for the external script. :vartype primary_script_uri: str :ivar supporting_script_uris: Supporting files for the external script. @@ -713,55 +721,55 @@ class AzurePowerShellScript(DeploymentScript): :ivar force_update_tag: Gets or sets how the deployment script should be forced to execute even if the script resource has not changed. Can be current time stamp or a GUID. :vartype force_update_tag: str - :ivar retention_interval: Required. Interval for which the service retains the script resource - after it reaches a terminal state. Resource will be deleted when this duration expires. - Duration is based on ISO 8601 pattern (for example P1D means one day). + :ivar retention_interval: Interval for which the service retains the script resource after it + reaches a terminal state. Resource will be deleted when this duration expires. Duration is + based on ISO 8601 pattern (for example P1D means one day). Required. :vartype retention_interval: ~datetime.timedelta :ivar timeout: Maximum allowed script execution time specified in ISO 8601 format. Default value is P1D. :vartype timeout: ~datetime.timedelta - :ivar az_power_shell_version: Required. Azure PowerShell module version to be used. + :ivar az_power_shell_version: Azure PowerShell module version to be used. Required. :vartype az_power_shell_version: str """ _validation = { - 'id': {'readonly': True}, - 'name': {'readonly': True}, - 'type': {'readonly': True}, - 'location': {'required': True}, - 'kind': {'required': True}, - 'system_data': {'readonly': True}, - 'provisioning_state': {'readonly': True}, - 'status': {'readonly': True}, - 'outputs': {'readonly': True}, - 'retention_interval': {'required': True}, - 'az_power_shell_version': {'required': True}, + "id": {"readonly": True}, + "name": {"readonly": True}, + "type": {"readonly": True}, + "location": {"required": True}, + "kind": {"required": True}, + "system_data": {"readonly": True}, + "provisioning_state": {"readonly": True}, + "status": {"readonly": True}, + "outputs": {"readonly": True}, + "retention_interval": {"required": True}, + "az_power_shell_version": {"required": True}, } _attribute_map = { - 'id': {'key': 'id', 'type': 'str'}, - 'name': {'key': 'name', 'type': 'str'}, - 'type': {'key': 'type', 'type': 'str'}, - 'identity': {'key': 'identity', 'type': 'ManagedServiceIdentity'}, - 'location': {'key': 'location', 'type': 'str'}, - 'tags': {'key': 'tags', 'type': '{str}'}, - 'kind': {'key': 'kind', 'type': 'str'}, - 'system_data': {'key': 'systemData', 'type': 'SystemData'}, - 'container_settings': {'key': 'properties.containerSettings', 'type': 'ContainerConfiguration'}, - 'storage_account_settings': {'key': 'properties.storageAccountSettings', 'type': 'StorageAccountConfiguration'}, - 'cleanup_preference': {'key': 'properties.cleanupPreference', 'type': 'str'}, - 'provisioning_state': {'key': 'properties.provisioningState', 'type': 'str'}, - 'status': {'key': 'properties.status', 'type': 'ScriptStatus'}, - 'outputs': {'key': 'properties.outputs', 'type': '{object}'}, - 'primary_script_uri': {'key': 'properties.primaryScriptUri', 'type': 'str'}, - 'supporting_script_uris': {'key': 'properties.supportingScriptUris', 'type': '[str]'}, - 'script_content': {'key': 'properties.scriptContent', 'type': 'str'}, - 'arguments': {'key': 'properties.arguments', 'type': 'str'}, - 'environment_variables': {'key': 'properties.environmentVariables', 'type': '[EnvironmentVariable]'}, - 'force_update_tag': {'key': 'properties.forceUpdateTag', 'type': 'str'}, - 'retention_interval': {'key': 'properties.retentionInterval', 'type': 'duration'}, - 'timeout': {'key': 'properties.timeout', 'type': 'duration'}, - 'az_power_shell_version': {'key': 'properties.azPowerShellVersion', 'type': 'str'}, + "id": {"key": "id", "type": "str"}, + "name": {"key": "name", "type": "str"}, + "type": {"key": "type", "type": "str"}, + "identity": {"key": "identity", "type": "ManagedServiceIdentity"}, + "location": {"key": "location", "type": "str"}, + "tags": {"key": "tags", "type": "{str}"}, + "kind": {"key": "kind", "type": "str"}, + "system_data": {"key": "systemData", "type": "SystemData"}, + "container_settings": {"key": "properties.containerSettings", "type": "ContainerConfiguration"}, + "storage_account_settings": {"key": "properties.storageAccountSettings", "type": "StorageAccountConfiguration"}, + "cleanup_preference": {"key": "properties.cleanupPreference", "type": "str"}, + "provisioning_state": {"key": "properties.provisioningState", "type": "str"}, + "status": {"key": "properties.status", "type": "ScriptStatus"}, + "outputs": {"key": "properties.outputs", "type": "{object}"}, + "primary_script_uri": {"key": "properties.primaryScriptUri", "type": "str"}, + "supporting_script_uris": {"key": "properties.supportingScriptUris", "type": "[str]"}, + "script_content": {"key": "properties.scriptContent", "type": "str"}, + "arguments": {"key": "properties.arguments", "type": "str"}, + "environment_variables": {"key": "properties.environmentVariables", "type": "[EnvironmentVariable]"}, + "force_update_tag": {"key": "properties.forceUpdateTag", "type": "str"}, + "retention_interval": {"key": "properties.retentionInterval", "type": "duration"}, + "timeout": {"key": "properties.timeout", "type": "duration"}, + "az_power_shell_version": {"key": "properties.azPowerShellVersion", "type": "str"}, } def __init__( @@ -770,18 +778,18 @@ def __init__( location: str, retention_interval: datetime.timedelta, az_power_shell_version: str, - identity: Optional["ManagedServiceIdentity"] = None, + identity: Optional["_models.ManagedServiceIdentity"] = None, tags: Optional[Dict[str, str]] = None, - container_settings: Optional["ContainerConfiguration"] = None, - storage_account_settings: Optional["StorageAccountConfiguration"] = None, - cleanup_preference: Optional[Union[str, "CleanupOptions"]] = "Always", + container_settings: Optional["_models.ContainerConfiguration"] = None, + storage_account_settings: Optional["_models.StorageAccountConfiguration"] = None, + cleanup_preference: Union[str, "_models.CleanupOptions"] = "Always", primary_script_uri: Optional[str] = None, supporting_script_uris: Optional[List[str]] = None, script_content: Optional[str] = None, arguments: Optional[str] = None, - environment_variables: Optional[List["EnvironmentVariable"]] = None, + environment_variables: Optional[List["_models.EnvironmentVariable"]] = None, force_update_tag: Optional[str] = None, - timeout: Optional[datetime.timedelta] = "P1D", + timeout: datetime.timedelta = "P1D", **kwargs ): """ @@ -789,10 +797,10 @@ def __init__( Currently, only user-assigned MSI is supported. :paramtype identity: ~azure.mgmt.resource.deploymentscripts.v2020_10_01.models.ManagedServiceIdentity - :keyword location: Required. The location of the ACI and the storage account for the deployment - script. + :keyword location: The location of the ACI and the storage account for the deployment script. + Required. :paramtype location: str - :keyword tags: A set of tags. Resource tags. + :keyword tags: Resource tags. :paramtype tags: dict[str, str] :keyword container_settings: Container settings. :paramtype container_settings: @@ -801,8 +809,8 @@ def __init__( :paramtype storage_account_settings: ~azure.mgmt.resource.deploymentscripts.v2020_10_01.models.StorageAccountConfiguration :keyword cleanup_preference: The clean up preference when the script execution gets in a - terminal state. Default setting is 'Always'. Possible values include: "Always", "OnSuccess", - "OnExpiration". Default value: "Always". + terminal state. Default setting is 'Always'. Known values are: "Always", "OnSuccess", and + "OnExpiration". :paramtype cleanup_preference: str or ~azure.mgmt.resource.deploymentscripts.v2020_10_01.models.CleanupOptions :keyword primary_script_uri: Uri for the script. This is the entry point for the external @@ -821,18 +829,18 @@ def __init__( :keyword force_update_tag: Gets or sets how the deployment script should be forced to execute even if the script resource has not changed. Can be current time stamp or a GUID. :paramtype force_update_tag: str - :keyword retention_interval: Required. Interval for which the service retains the script - resource after it reaches a terminal state. Resource will be deleted when this duration - expires. Duration is based on ISO 8601 pattern (for example P1D means one day). + :keyword retention_interval: Interval for which the service retains the script resource after + it reaches a terminal state. Resource will be deleted when this duration expires. Duration is + based on ISO 8601 pattern (for example P1D means one day). Required. :paramtype retention_interval: ~datetime.timedelta :keyword timeout: Maximum allowed script execution time specified in ISO 8601 format. Default value is P1D. :paramtype timeout: ~datetime.timedelta - :keyword az_power_shell_version: Required. Azure PowerShell module version to be used. + :keyword az_power_shell_version: Azure PowerShell module version to be used. Required. :paramtype az_power_shell_version: str """ - super(AzurePowerShellScript, self).__init__(identity=identity, location=location, tags=tags, **kwargs) - self.kind = 'AzurePowerShell' # type: str + super().__init__(identity=identity, location=location, tags=tags, **kwargs) + self.kind = "AzurePowerShell" # type: str self.container_settings = container_settings self.storage_account_settings = storage_account_settings self.cleanup_preference = cleanup_preference @@ -850,7 +858,9 @@ def __init__( self.az_power_shell_version = az_power_shell_version -class AzurePowerShellScriptProperties(DeploymentScriptPropertiesBase, ScriptConfigurationBase): +class AzurePowerShellScriptProperties( + DeploymentScriptPropertiesBase, ScriptConfigurationBase +): # pylint: disable=too-many-instance-attributes """Properties of the Azure PowerShell script object. Variables are only populated by the server, and will be ignored when sending a request. @@ -872,9 +882,9 @@ class AzurePowerShellScriptProperties(DeploymentScriptPropertiesBase, ScriptConf :ivar force_update_tag: Gets or sets how the deployment script should be forced to execute even if the script resource has not changed. Can be current time stamp or a GUID. :vartype force_update_tag: str - :ivar retention_interval: Required. Interval for which the service retains the script resource - after it reaches a terminal state. Resource will be deleted when this duration expires. - Duration is based on ISO 8601 pattern (for example P1D means one day). + :ivar retention_interval: Interval for which the service retains the script resource after it + reaches a terminal state. Resource will be deleted when this duration expires. Duration is + based on ISO 8601 pattern (for example P1D means one day). Required. :vartype retention_interval: ~datetime.timedelta :ivar timeout: Maximum allowed script execution time specified in ISO 8601 format. Default value is P1D. @@ -886,47 +896,47 @@ class AzurePowerShellScriptProperties(DeploymentScriptPropertiesBase, ScriptConf :vartype storage_account_settings: ~azure.mgmt.resource.deploymentscripts.v2020_10_01.models.StorageAccountConfiguration :ivar cleanup_preference: The clean up preference when the script execution gets in a terminal - state. Default setting is 'Always'. Possible values include: "Always", "OnSuccess", - "OnExpiration". Default value: "Always". + state. Default setting is 'Always'. Known values are: "Always", "OnSuccess", and + "OnExpiration". :vartype cleanup_preference: str or ~azure.mgmt.resource.deploymentscripts.v2020_10_01.models.CleanupOptions :ivar provisioning_state: State of the script execution. This only appears in the response. - Possible values include: "Creating", "ProvisioningResources", "Running", "Succeeded", "Failed", + Known values are: "Creating", "ProvisioningResources", "Running", "Succeeded", "Failed", and "Canceled". :vartype provisioning_state: str or ~azure.mgmt.resource.deploymentscripts.v2020_10_01.models.ScriptProvisioningState :ivar status: Contains the results of script execution. :vartype status: ~azure.mgmt.resource.deploymentscripts.v2020_10_01.models.ScriptStatus :ivar outputs: List of script outputs. - :vartype outputs: dict[str, any] - :ivar az_power_shell_version: Required. Azure PowerShell module version to be used. + :vartype outputs: dict[str, JSON] + :ivar az_power_shell_version: Azure PowerShell module version to be used. Required. :vartype az_power_shell_version: str """ _validation = { - 'retention_interval': {'required': True}, - 'provisioning_state': {'readonly': True}, - 'status': {'readonly': True}, - 'outputs': {'readonly': True}, - 'az_power_shell_version': {'required': True}, + "retention_interval": {"required": True}, + "provisioning_state": {"readonly": True}, + "status": {"readonly": True}, + "outputs": {"readonly": True}, + "az_power_shell_version": {"required": True}, } _attribute_map = { - 'primary_script_uri': {'key': 'primaryScriptUri', 'type': 'str'}, - 'supporting_script_uris': {'key': 'supportingScriptUris', 'type': '[str]'}, - 'script_content': {'key': 'scriptContent', 'type': 'str'}, - 'arguments': {'key': 'arguments', 'type': 'str'}, - 'environment_variables': {'key': 'environmentVariables', 'type': '[EnvironmentVariable]'}, - 'force_update_tag': {'key': 'forceUpdateTag', 'type': 'str'}, - 'retention_interval': {'key': 'retentionInterval', 'type': 'duration'}, - 'timeout': {'key': 'timeout', 'type': 'duration'}, - 'container_settings': {'key': 'containerSettings', 'type': 'ContainerConfiguration'}, - 'storage_account_settings': {'key': 'storageAccountSettings', 'type': 'StorageAccountConfiguration'}, - 'cleanup_preference': {'key': 'cleanupPreference', 'type': 'str'}, - 'provisioning_state': {'key': 'provisioningState', 'type': 'str'}, - 'status': {'key': 'status', 'type': 'ScriptStatus'}, - 'outputs': {'key': 'outputs', 'type': '{object}'}, - 'az_power_shell_version': {'key': 'azPowerShellVersion', 'type': 'str'}, + "primary_script_uri": {"key": "primaryScriptUri", "type": "str"}, + "supporting_script_uris": {"key": "supportingScriptUris", "type": "[str]"}, + "script_content": {"key": "scriptContent", "type": "str"}, + "arguments": {"key": "arguments", "type": "str"}, + "environment_variables": {"key": "environmentVariables", "type": "[EnvironmentVariable]"}, + "force_update_tag": {"key": "forceUpdateTag", "type": "str"}, + "retention_interval": {"key": "retentionInterval", "type": "duration"}, + "timeout": {"key": "timeout", "type": "duration"}, + "container_settings": {"key": "containerSettings", "type": "ContainerConfiguration"}, + "storage_account_settings": {"key": "storageAccountSettings", "type": "StorageAccountConfiguration"}, + "cleanup_preference": {"key": "cleanupPreference", "type": "str"}, + "provisioning_state": {"key": "provisioningState", "type": "str"}, + "status": {"key": "status", "type": "ScriptStatus"}, + "outputs": {"key": "outputs", "type": "{object}"}, + "az_power_shell_version": {"key": "azPowerShellVersion", "type": "str"}, } def __init__( @@ -938,12 +948,12 @@ def __init__( supporting_script_uris: Optional[List[str]] = None, script_content: Optional[str] = None, arguments: Optional[str] = None, - environment_variables: Optional[List["EnvironmentVariable"]] = None, + environment_variables: Optional[List["_models.EnvironmentVariable"]] = None, force_update_tag: Optional[str] = None, - timeout: Optional[datetime.timedelta] = "P1D", - container_settings: Optional["ContainerConfiguration"] = None, - storage_account_settings: Optional["StorageAccountConfiguration"] = None, - cleanup_preference: Optional[Union[str, "CleanupOptions"]] = "Always", + timeout: datetime.timedelta = "P1D", + container_settings: Optional["_models.ContainerConfiguration"] = None, + storage_account_settings: Optional["_models.StorageAccountConfiguration"] = None, + cleanup_preference: Union[str, "_models.CleanupOptions"] = "Always", **kwargs ): """ @@ -963,9 +973,9 @@ def __init__( :keyword force_update_tag: Gets or sets how the deployment script should be forced to execute even if the script resource has not changed. Can be current time stamp or a GUID. :paramtype force_update_tag: str - :keyword retention_interval: Required. Interval for which the service retains the script - resource after it reaches a terminal state. Resource will be deleted when this duration - expires. Duration is based on ISO 8601 pattern (for example P1D means one day). + :keyword retention_interval: Interval for which the service retains the script resource after + it reaches a terminal state. Resource will be deleted when this duration expires. Duration is + based on ISO 8601 pattern (for example P1D means one day). Required. :paramtype retention_interval: ~datetime.timedelta :keyword timeout: Maximum allowed script execution time specified in ISO 8601 format. Default value is P1D. @@ -977,14 +987,27 @@ def __init__( :paramtype storage_account_settings: ~azure.mgmt.resource.deploymentscripts.v2020_10_01.models.StorageAccountConfiguration :keyword cleanup_preference: The clean up preference when the script execution gets in a - terminal state. Default setting is 'Always'. Possible values include: "Always", "OnSuccess", - "OnExpiration". Default value: "Always". + terminal state. Default setting is 'Always'. Known values are: "Always", "OnSuccess", and + "OnExpiration". :paramtype cleanup_preference: str or ~azure.mgmt.resource.deploymentscripts.v2020_10_01.models.CleanupOptions - :keyword az_power_shell_version: Required. Azure PowerShell module version to be used. + :keyword az_power_shell_version: Azure PowerShell module version to be used. Required. :paramtype az_power_shell_version: str """ - super(AzurePowerShellScriptProperties, self).__init__(container_settings=container_settings, storage_account_settings=storage_account_settings, cleanup_preference=cleanup_preference, primary_script_uri=primary_script_uri, supporting_script_uris=supporting_script_uris, script_content=script_content, arguments=arguments, environment_variables=environment_variables, force_update_tag=force_update_tag, retention_interval=retention_interval, timeout=timeout, **kwargs) + super().__init__( + container_settings=container_settings, + storage_account_settings=storage_account_settings, + cleanup_preference=cleanup_preference, + primary_script_uri=primary_script_uri, + supporting_script_uris=supporting_script_uris, + script_content=script_content, + arguments=arguments, + environment_variables=environment_variables, + force_update_tag=force_update_tag, + retention_interval=retention_interval, + timeout=timeout, + **kwargs + ) self.primary_script_uri = primary_script_uri self.supporting_script_uris = supporting_script_uris self.script_content = script_content @@ -1002,7 +1025,7 @@ def __init__( self.outputs = None -class ContainerConfiguration(msrest.serialization.Model): +class ContainerConfiguration(_serialization.Model): """Settings to customize ACI container instance. :ivar container_group_name: Container group name, if not specified then the name will get @@ -1019,19 +1042,14 @@ class ContainerConfiguration(msrest.serialization.Model): """ _validation = { - 'container_group_name': {'max_length': 63, 'min_length': 1}, + "container_group_name": {"max_length": 63, "min_length": 1}, } _attribute_map = { - 'container_group_name': {'key': 'containerGroupName', 'type': 'str'}, + "container_group_name": {"key": "containerGroupName", "type": "str"}, } - def __init__( - self, - *, - container_group_name: Optional[str] = None, - **kwargs - ): + def __init__(self, *, container_group_name: Optional[str] = None, **kwargs): """ :keyword container_group_name: Container group name, if not specified then the name will get auto-generated. Not specifying a 'containerGroupName' indicates the system to generate a unique @@ -1045,11 +1063,11 @@ def __init__( property. :paramtype container_group_name: str """ - super(ContainerConfiguration, self).__init__(**kwargs) + super().__init__(**kwargs) self.container_group_name = container_group_name -class DeploymentScriptListResult(msrest.serialization.Model): +class DeploymentScriptListResult(_serialization.Model): """List of deployment scripts. Variables are only populated by the server, and will be ignored when sending a request. @@ -1062,31 +1080,26 @@ class DeploymentScriptListResult(msrest.serialization.Model): """ _validation = { - 'next_link': {'readonly': True}, + "next_link": {"readonly": True}, } _attribute_map = { - 'value': {'key': 'value', 'type': '[DeploymentScript]'}, - 'next_link': {'key': 'nextLink', 'type': 'str'}, + "value": {"key": "value", "type": "[DeploymentScript]"}, + "next_link": {"key": "nextLink", "type": "str"}, } - def __init__( - self, - *, - value: Optional[List["DeploymentScript"]] = None, - **kwargs - ): + def __init__(self, *, value: Optional[List["_models.DeploymentScript"]] = None, **kwargs): """ :keyword value: An array of deployment scripts. :paramtype value: list[~azure.mgmt.resource.deploymentscripts.v2020_10_01.models.DeploymentScript] """ - super(DeploymentScriptListResult, self).__init__(**kwargs) + super().__init__(**kwargs) self.value = value self.next_link = None -class DeploymentScriptsError(msrest.serialization.Model): +class DeploymentScriptsError(_serialization.Model): """Deployment scripts error response. :ivar error: Common error response for all Azure Resource Manager APIs to return error details @@ -1095,21 +1108,16 @@ class DeploymentScriptsError(msrest.serialization.Model): """ _attribute_map = { - 'error': {'key': 'error', 'type': 'ErrorResponse'}, + "error": {"key": "error", "type": "ErrorResponse"}, } - def __init__( - self, - *, - error: Optional["ErrorResponse"] = None, - **kwargs - ): + def __init__(self, *, error: Optional["_models.ErrorResponse"] = None, **kwargs): """ :keyword error: Common error response for all Azure Resource Manager APIs to return error details for failed operations. (This also follows the OData error response format.). :paramtype error: ~azure.mgmt.resource.deploymentscripts.v2020_10_01.models.ErrorResponse """ - super(DeploymentScriptsError, self).__init__(**kwargs) + super().__init__(**kwargs) self.error = error @@ -1124,43 +1132,38 @@ class DeploymentScriptUpdateParameter(AzureResourceBase): :vartype name: str :ivar type: Type of this resource. :vartype type: str - :ivar tags: A set of tags. Resource tags to be updated. + :ivar tags: Resource tags to be updated. :vartype tags: dict[str, str] """ _validation = { - 'id': {'readonly': True}, - 'name': {'readonly': True}, - 'type': {'readonly': True}, + "id": {"readonly": True}, + "name": {"readonly": True}, + "type": {"readonly": True}, } _attribute_map = { - 'id': {'key': 'id', 'type': 'str'}, - 'name': {'key': 'name', 'type': 'str'}, - 'type': {'key': 'type', 'type': 'str'}, - 'tags': {'key': 'tags', 'type': '{str}'}, + "id": {"key": "id", "type": "str"}, + "name": {"key": "name", "type": "str"}, + "type": {"key": "type", "type": "str"}, + "tags": {"key": "tags", "type": "{str}"}, } - def __init__( - self, - *, - tags: Optional[Dict[str, str]] = None, - **kwargs - ): + def __init__(self, *, tags: Optional[Dict[str, str]] = None, **kwargs): """ - :keyword tags: A set of tags. Resource tags to be updated. + :keyword tags: Resource tags to be updated. :paramtype tags: dict[str, str] """ - super(DeploymentScriptUpdateParameter, self).__init__(**kwargs) + super().__init__(**kwargs) self.tags = tags -class EnvironmentVariable(msrest.serialization.Model): +class EnvironmentVariable(_serialization.Model): """The environment variable to pass to the script in the container instance. All required parameters must be populated in order to send to Azure. - :ivar name: Required. The name of the environment variable. + :ivar name: The name of the environment variable. Required. :vartype name: str :ivar value: The value of the environment variable. :vartype value: str @@ -1169,38 +1172,31 @@ class EnvironmentVariable(msrest.serialization.Model): """ _validation = { - 'name': {'required': True}, + "name": {"required": True}, } _attribute_map = { - 'name': {'key': 'name', 'type': 'str'}, - 'value': {'key': 'value', 'type': 'str'}, - 'secure_value': {'key': 'secureValue', 'type': 'str'}, + "name": {"key": "name", "type": "str"}, + "value": {"key": "value", "type": "str"}, + "secure_value": {"key": "secureValue", "type": "str"}, } - def __init__( - self, - *, - name: str, - value: Optional[str] = None, - secure_value: Optional[str] = None, - **kwargs - ): + def __init__(self, *, name: str, value: Optional[str] = None, secure_value: Optional[str] = None, **kwargs): """ - :keyword name: Required. The name of the environment variable. + :keyword name: The name of the environment variable. Required. :paramtype name: str :keyword value: The value of the environment variable. :paramtype value: str :keyword secure_value: The value of the secure environment variable. :paramtype secure_value: str """ - super(EnvironmentVariable, self).__init__(**kwargs) + super().__init__(**kwargs) self.name = name self.value = value self.secure_value = secure_value -class ErrorAdditionalInfo(msrest.serialization.Model): +class ErrorAdditionalInfo(_serialization.Model): """The resource management error additional info. Variables are only populated by the server, and will be ignored when sending a request. @@ -1208,31 +1204,27 @@ class ErrorAdditionalInfo(msrest.serialization.Model): :ivar type: The additional info type. :vartype type: str :ivar info: The additional info. - :vartype info: any + :vartype info: JSON """ _validation = { - 'type': {'readonly': True}, - 'info': {'readonly': True}, + "type": {"readonly": True}, + "info": {"readonly": True}, } _attribute_map = { - 'type': {'key': 'type', 'type': 'str'}, - 'info': {'key': 'info', 'type': 'object'}, + "type": {"key": "type", "type": "str"}, + "info": {"key": "info", "type": "object"}, } - def __init__( - self, - **kwargs - ): - """ - """ - super(ErrorAdditionalInfo, self).__init__(**kwargs) + def __init__(self, **kwargs): + """ """ + super().__init__(**kwargs) self.type = None self.info = None -class ErrorResponse(msrest.serialization.Model): +class ErrorResponse(_serialization.Model): """Common error response for all Azure Resource Manager APIs to return error details for failed operations. (This also follows the OData error response format.). Variables are only populated by the server, and will be ignored when sending a request. @@ -1251,28 +1243,24 @@ class ErrorResponse(msrest.serialization.Model): """ _validation = { - 'code': {'readonly': True}, - 'message': {'readonly': True}, - 'target': {'readonly': True}, - 'details': {'readonly': True}, - 'additional_info': {'readonly': True}, + "code": {"readonly": True}, + "message": {"readonly": True}, + "target": {"readonly": True}, + "details": {"readonly": True}, + "additional_info": {"readonly": True}, } _attribute_map = { - 'code': {'key': 'code', 'type': 'str'}, - 'message': {'key': 'message', 'type': 'str'}, - 'target': {'key': 'target', 'type': 'str'}, - 'details': {'key': 'details', 'type': '[ErrorResponse]'}, - 'additional_info': {'key': 'additionalInfo', 'type': '[ErrorAdditionalInfo]'}, + "code": {"key": "code", "type": "str"}, + "message": {"key": "message", "type": "str"}, + "target": {"key": "target", "type": "str"}, + "details": {"key": "details", "type": "[ErrorResponse]"}, + "additional_info": {"key": "additionalInfo", "type": "[ErrorAdditionalInfo]"}, } - def __init__( - self, - **kwargs - ): - """ - """ - super(ErrorResponse, self).__init__(**kwargs) + def __init__(self, **kwargs): + """ """ + super().__init__(**kwargs) self.code = None self.message = None self.target = None @@ -1280,12 +1268,12 @@ def __init__( self.additional_info = None -class ManagedServiceIdentity(msrest.serialization.Model): +class ManagedServiceIdentity(_serialization.Model): """Managed identity generic object. Variables are only populated by the server, and will be ignored when sending a request. - :ivar type: Type of the managed identity. Possible values include: "UserAssigned". + :ivar type: Type of the managed identity. "UserAssigned" :vartype type: str or ~azure.mgmt.resource.deploymentscripts.v2020_10_01.models.ManagedServiceIdentityType :ivar tenant_id: ID of the Azure Active Directory. @@ -1297,24 +1285,24 @@ class ManagedServiceIdentity(msrest.serialization.Model): """ _validation = { - 'tenant_id': {'readonly': True}, + "tenant_id": {"readonly": True}, } _attribute_map = { - 'type': {'key': 'type', 'type': 'str'}, - 'tenant_id': {'key': 'tenantId', 'type': 'str'}, - 'user_assigned_identities': {'key': 'userAssignedIdentities', 'type': '{UserAssignedIdentity}'}, + "type": {"key": "type", "type": "str"}, + "tenant_id": {"key": "tenantId", "type": "str"}, + "user_assigned_identities": {"key": "userAssignedIdentities", "type": "{UserAssignedIdentity}"}, } def __init__( self, *, - type: Optional[Union[str, "ManagedServiceIdentityType"]] = None, - user_assigned_identities: Optional[Dict[str, "UserAssignedIdentity"]] = None, + type: Optional[Union[str, "_models.ManagedServiceIdentityType"]] = None, + user_assigned_identities: Optional[Dict[str, "_models.UserAssignedIdentity"]] = None, **kwargs ): """ - :keyword type: Type of the managed identity. Possible values include: "UserAssigned". + :keyword type: Type of the managed identity. "UserAssigned" :paramtype type: str or ~azure.mgmt.resource.deploymentscripts.v2020_10_01.models.ManagedServiceIdentityType :keyword user_assigned_identities: The list of user-assigned managed identities associated with @@ -1322,7 +1310,7 @@ def __init__( :paramtype user_assigned_identities: dict[str, ~azure.mgmt.resource.deploymentscripts.v2020_10_01.models.UserAssignedIdentity] """ - super(ManagedServiceIdentity, self).__init__(**kwargs) + super().__init__(**kwargs) self.type = type self.tenant_id = None self.user_assigned_identities = user_assigned_identities @@ -1344,30 +1332,26 @@ class ScriptLog(AzureResourceBase): """ _validation = { - 'id': {'readonly': True}, - 'name': {'readonly': True}, - 'type': {'readonly': True}, - 'log': {'readonly': True}, + "id": {"readonly": True}, + "name": {"readonly": True}, + "type": {"readonly": True}, + "log": {"readonly": True}, } _attribute_map = { - 'id': {'key': 'id', 'type': 'str'}, - 'name': {'key': 'name', 'type': 'str'}, - 'type': {'key': 'type', 'type': 'str'}, - 'log': {'key': 'properties.log', 'type': 'str'}, + "id": {"key": "id", "type": "str"}, + "name": {"key": "name", "type": "str"}, + "type": {"key": "type", "type": "str"}, + "log": {"key": "properties.log", "type": "str"}, } - def __init__( - self, - **kwargs - ): - """ - """ - super(ScriptLog, self).__init__(**kwargs) + def __init__(self, **kwargs): + """ """ + super().__init__(**kwargs) self.log = None -class ScriptLogsList(msrest.serialization.Model): +class ScriptLogsList(_serialization.Model): """Deployment script execution logs. :ivar value: Deployment scripts logs. @@ -1375,24 +1359,19 @@ class ScriptLogsList(msrest.serialization.Model): """ _attribute_map = { - 'value': {'key': 'value', 'type': '[ScriptLog]'}, + "value": {"key": "value", "type": "[ScriptLog]"}, } - def __init__( - self, - *, - value: Optional[List["ScriptLog"]] = None, - **kwargs - ): + def __init__(self, *, value: Optional[List["_models.ScriptLog"]] = None, **kwargs): """ :keyword value: Deployment scripts logs. :paramtype value: list[~azure.mgmt.resource.deploymentscripts.v2020_10_01.models.ScriptLog] """ - super(ScriptLogsList, self).__init__(**kwargs) + super().__init__(**kwargs) self.value = value -class ScriptStatus(msrest.serialization.Model): +class ScriptStatus(_serialization.Model): """Generic object modeling results of script execution. Variables are only populated by the server, and will be ignored when sending a request. @@ -1412,33 +1391,28 @@ class ScriptStatus(msrest.serialization.Model): """ _validation = { - 'container_instance_id': {'readonly': True}, - 'storage_account_id': {'readonly': True}, - 'start_time': {'readonly': True}, - 'end_time': {'readonly': True}, - 'expiration_time': {'readonly': True}, + "container_instance_id": {"readonly": True}, + "storage_account_id": {"readonly": True}, + "start_time": {"readonly": True}, + "end_time": {"readonly": True}, + "expiration_time": {"readonly": True}, } _attribute_map = { - 'container_instance_id': {'key': 'containerInstanceId', 'type': 'str'}, - 'storage_account_id': {'key': 'storageAccountId', 'type': 'str'}, - 'start_time': {'key': 'startTime', 'type': 'iso-8601'}, - 'end_time': {'key': 'endTime', 'type': 'iso-8601'}, - 'expiration_time': {'key': 'expirationTime', 'type': 'iso-8601'}, - 'error': {'key': 'error', 'type': 'ErrorResponse'}, + "container_instance_id": {"key": "containerInstanceId", "type": "str"}, + "storage_account_id": {"key": "storageAccountId", "type": "str"}, + "start_time": {"key": "startTime", "type": "iso-8601"}, + "end_time": {"key": "endTime", "type": "iso-8601"}, + "expiration_time": {"key": "expirationTime", "type": "iso-8601"}, + "error": {"key": "error", "type": "ErrorResponse"}, } - def __init__( - self, - *, - error: Optional["ErrorResponse"] = None, - **kwargs - ): + def __init__(self, *, error: Optional["_models.ErrorResponse"] = None, **kwargs): """ :keyword error: Error that is relayed from the script execution. :paramtype error: ~azure.mgmt.resource.deploymentscripts.v2020_10_01.models.ErrorResponse """ - super(ScriptStatus, self).__init__(**kwargs) + super().__init__(**kwargs) self.container_instance_id = None self.storage_account_id = None self.start_time = None @@ -1447,7 +1421,7 @@ def __init__( self.error = error -class StorageAccountConfiguration(msrest.serialization.Model): +class StorageAccountConfiguration(_serialization.Model): """Settings to use an existing storage account. Valid storage account kinds are: Storage, StorageV2 and FileStorage. :ivar storage_account_name: The storage account name. @@ -1457,16 +1431,12 @@ class StorageAccountConfiguration(msrest.serialization.Model): """ _attribute_map = { - 'storage_account_name': {'key': 'storageAccountName', 'type': 'str'}, - 'storage_account_key': {'key': 'storageAccountKey', 'type': 'str'}, + "storage_account_name": {"key": "storageAccountName", "type": "str"}, + "storage_account_key": {"key": "storageAccountKey", "type": "str"}, } def __init__( - self, - *, - storage_account_name: Optional[str] = None, - storage_account_key: Optional[str] = None, - **kwargs + self, *, storage_account_name: Optional[str] = None, storage_account_key: Optional[str] = None, **kwargs ): """ :keyword storage_account_name: The storage account name. @@ -1474,26 +1444,26 @@ def __init__( :keyword storage_account_key: The storage account access key. :paramtype storage_account_key: str """ - super(StorageAccountConfiguration, self).__init__(**kwargs) + super().__init__(**kwargs) self.storage_account_name = storage_account_name self.storage_account_key = storage_account_key -class SystemData(msrest.serialization.Model): +class SystemData(_serialization.Model): """Metadata pertaining to creation and last modification of the resource. :ivar created_by: The identity that created the resource. :vartype created_by: str - :ivar created_by_type: The type of identity that created the resource. Possible values include: - "User", "Application", "ManagedIdentity", "Key". + :ivar created_by_type: The type of identity that created the resource. Known values are: + "User", "Application", "ManagedIdentity", and "Key". :vartype created_by_type: str or ~azure.mgmt.resource.deploymentscripts.v2020_10_01.models.CreatedByType :ivar created_at: The timestamp of resource creation (UTC). :vartype created_at: ~datetime.datetime :ivar last_modified_by: The identity that last modified the resource. :vartype last_modified_by: str - :ivar last_modified_by_type: The type of identity that last modified the resource. Possible - values include: "User", "Application", "ManagedIdentity", "Key". + :ivar last_modified_by_type: The type of identity that last modified the resource. Known values + are: "User", "Application", "ManagedIdentity", and "Key". :vartype last_modified_by_type: str or ~azure.mgmt.resource.deploymentscripts.v2020_10_01.models.CreatedByType :ivar last_modified_at: The timestamp of resource last modification (UTC). @@ -1501,44 +1471,44 @@ class SystemData(msrest.serialization.Model): """ _attribute_map = { - 'created_by': {'key': 'createdBy', 'type': 'str'}, - 'created_by_type': {'key': 'createdByType', 'type': 'str'}, - 'created_at': {'key': 'createdAt', 'type': 'iso-8601'}, - 'last_modified_by': {'key': 'lastModifiedBy', 'type': 'str'}, - 'last_modified_by_type': {'key': 'lastModifiedByType', 'type': 'str'}, - 'last_modified_at': {'key': 'lastModifiedAt', 'type': 'iso-8601'}, + "created_by": {"key": "createdBy", "type": "str"}, + "created_by_type": {"key": "createdByType", "type": "str"}, + "created_at": {"key": "createdAt", "type": "iso-8601"}, + "last_modified_by": {"key": "lastModifiedBy", "type": "str"}, + "last_modified_by_type": {"key": "lastModifiedByType", "type": "str"}, + "last_modified_at": {"key": "lastModifiedAt", "type": "iso-8601"}, } def __init__( self, *, created_by: Optional[str] = None, - created_by_type: Optional[Union[str, "CreatedByType"]] = None, + created_by_type: Optional[Union[str, "_models.CreatedByType"]] = None, created_at: Optional[datetime.datetime] = None, last_modified_by: Optional[str] = None, - last_modified_by_type: Optional[Union[str, "CreatedByType"]] = None, + last_modified_by_type: Optional[Union[str, "_models.CreatedByType"]] = None, last_modified_at: Optional[datetime.datetime] = None, **kwargs ): """ :keyword created_by: The identity that created the resource. :paramtype created_by: str - :keyword created_by_type: The type of identity that created the resource. Possible values - include: "User", "Application", "ManagedIdentity", "Key". + :keyword created_by_type: The type of identity that created the resource. Known values are: + "User", "Application", "ManagedIdentity", and "Key". :paramtype created_by_type: str or ~azure.mgmt.resource.deploymentscripts.v2020_10_01.models.CreatedByType :keyword created_at: The timestamp of resource creation (UTC). :paramtype created_at: ~datetime.datetime :keyword last_modified_by: The identity that last modified the resource. :paramtype last_modified_by: str - :keyword last_modified_by_type: The type of identity that last modified the resource. Possible - values include: "User", "Application", "ManagedIdentity", "Key". + :keyword last_modified_by_type: The type of identity that last modified the resource. Known + values are: "User", "Application", "ManagedIdentity", and "Key". :paramtype last_modified_by_type: str or ~azure.mgmt.resource.deploymentscripts.v2020_10_01.models.CreatedByType :keyword last_modified_at: The timestamp of resource last modification (UTC). :paramtype last_modified_at: ~datetime.datetime """ - super(SystemData, self).__init__(**kwargs) + super().__init__(**kwargs) self.created_by = created_by self.created_by_type = created_by_type self.created_at = created_at @@ -1547,7 +1517,7 @@ def __init__( self.last_modified_at = last_modified_at -class UserAssignedIdentity(msrest.serialization.Model): +class UserAssignedIdentity(_serialization.Model): """User-assigned managed identity. Variables are only populated by the server, and will be ignored when sending a request. @@ -1559,21 +1529,17 @@ class UserAssignedIdentity(msrest.serialization.Model): """ _validation = { - 'principal_id': {'readonly': True}, - 'client_id': {'readonly': True}, + "principal_id": {"readonly": True}, + "client_id": {"readonly": True}, } _attribute_map = { - 'principal_id': {'key': 'principalId', 'type': 'str'}, - 'client_id': {'key': 'clientId', 'type': 'str'}, + "principal_id": {"key": "principalId", "type": "str"}, + "client_id": {"key": "clientId", "type": "str"}, } - def __init__( - self, - **kwargs - ): - """ - """ - super(UserAssignedIdentity, self).__init__(**kwargs) + def __init__(self, **kwargs): + """ """ + super().__init__(**kwargs) self.principal_id = None self.client_id = None diff --git a/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/deploymentscripts/v2020_10_01/models/_patch.py b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/deploymentscripts/v2020_10_01/models/_patch.py new file mode 100644 index 0000000000000..f7dd32510333d --- /dev/null +++ b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/deploymentscripts/v2020_10_01/models/_patch.py @@ -0,0 +1,20 @@ +# ------------------------------------ +# Copyright (c) Microsoft Corporation. +# Licensed under the MIT License. +# ------------------------------------ +"""Customize generated code here. + +Follow our quickstart for examples: https://aka.ms/azsdk/python/dpcodegen/python/customize +""" +from typing import List + +__all__: List[str] = [] # Add all objects you want publicly available to users at this package level + + +def patch_sdk(): + """Do not remove from this file. + + `patch_sdk` is a last resort escape hatch that allows you to do customizations + you can't accomplish using the techniques described in + https://aka.ms/azsdk/python/dpcodegen/python/customize + """ diff --git a/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/deploymentscripts/v2020_10_01/operations/__init__.py b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/deploymentscripts/v2020_10_01/operations/__init__.py index 2a9499c638ccc..15dd692e91d23 100644 --- a/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/deploymentscripts/v2020_10_01/operations/__init__.py +++ b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/deploymentscripts/v2020_10_01/operations/__init__.py @@ -8,6 +8,12 @@ from ._operations import DeploymentScriptsOperations +from ._patch import __all__ as _patch_all +from ._patch import * # type: ignore # pylint: disable=unused-wildcard-import +from ._patch import patch_sdk as _patch_sdk + __all__ = [ - 'DeploymentScriptsOperations', + "DeploymentScriptsOperations", ] +__all__.extend([p for p in _patch_all if p not in __all__]) +_patch_sdk() diff --git a/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/deploymentscripts/v2020_10_01/operations/_operations.py b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/deploymentscripts/v2020_10_01/operations/_operations.py index 94cf59ff89686..a9287b108ee53 100644 --- a/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/deploymentscripts/v2020_10_01/operations/_operations.py +++ b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/deploymentscripts/v2020_10_01/operations/_operations.py @@ -6,424 +6,485 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -from typing import Any, Callable, Dict, Iterable, Optional, TypeVar, Union - -from msrest import Serializer - -from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error +from typing import Any, Callable, Dict, IO, Iterable, Optional, TypeVar, Union, cast, overload +from urllib.parse import parse_qs, urljoin, urlparse + +from azure.core.exceptions import ( + ClientAuthenticationError, + HttpResponseError, + ResourceExistsError, + ResourceNotFoundError, + ResourceNotModifiedError, + map_error, +) from azure.core.paging import ItemPaged from azure.core.pipeline import PipelineResponse from azure.core.pipeline.transport import HttpResponse from azure.core.polling import LROPoller, NoPolling, PollingMethod from azure.core.rest import HttpRequest from azure.core.tracing.decorator import distributed_trace +from azure.core.utils import case_insensitive_dict from azure.mgmt.core.exceptions import ARMErrorFormat from azure.mgmt.core.polling.arm_polling import ARMPolling from .. import models as _models +from ..._serialization import Serializer from .._vendor import _convert_request, _format_url_section -T = TypeVar('T') -JSONType = Any + +T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] _SERIALIZER = Serializer() _SERIALIZER.client_side_validation = False -def build_deployment_scripts_create_request_initial( - subscription_id: str, - resource_group_name: str, - script_name: str, - *, - json: JSONType = None, - content: Any = None, - **kwargs: Any + +def build_deployment_scripts_create_request( + resource_group_name: str, script_name: str, subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2020-10-01") # type: str - content_type = kwargs.pop('content_type', None) # type: Optional[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", "2020-10-01")) # type: str + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + accept = _headers.pop("Accept", "application/json") - accept = "application/json" # Construct URL - _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/Microsoft.Resources/deploymentScripts/{scriptName}") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/Microsoft.Resources/deploymentScripts/{scriptName}", + ) # pylint: disable=line-too-long path_format_arguments = { - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1), - "scriptName": _SERIALIZER.url("script_name", script_name, 'str', max_length=90, min_length=1), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url( + "resource_group_name", resource_group_name, "str", max_length=90, min_length=1 + ), + "scriptName": _SERIALIZER.url("script_name", script_name, "str", max_length=90, min_length=1), } _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] if content_type is not None: - _header_parameters['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') - _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers["Content-Type"] = _SERIALIZER.header("content_type", content_type, "str") + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - return HttpRequest( - method="PUT", - url=_url, - params=_query_parameters, - headers=_header_parameters, - json=json, - content=content, - **kwargs - ) + return HttpRequest(method="PUT", url=_url, params=_params, headers=_headers, **kwargs) def build_deployment_scripts_update_request( - subscription_id: str, - resource_group_name: str, - script_name: str, - *, - json: JSONType = None, - content: Any = None, - **kwargs: Any + resource_group_name: str, script_name: str, subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2020-10-01") # type: str - content_type = kwargs.pop('content_type', None) # type: Optional[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", "2020-10-01")) # type: str + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + accept = _headers.pop("Accept", "application/json") - accept = "application/json" # Construct URL - _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/Microsoft.Resources/deploymentScripts/{scriptName}") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/Microsoft.Resources/deploymentScripts/{scriptName}", + ) # pylint: disable=line-too-long path_format_arguments = { - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1), - "scriptName": _SERIALIZER.url("script_name", script_name, 'str', max_length=90, min_length=1), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url( + "resource_group_name", resource_group_name, "str", max_length=90, min_length=1 + ), + "scriptName": _SERIALIZER.url("script_name", script_name, "str", max_length=90, min_length=1), } _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] if content_type is not None: - _header_parameters['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') - _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers["Content-Type"] = _SERIALIZER.header("content_type", content_type, "str") + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - return HttpRequest( - method="PATCH", - url=_url, - params=_query_parameters, - headers=_header_parameters, - json=json, - content=content, - **kwargs - ) + return HttpRequest(method="PATCH", url=_url, params=_params, headers=_headers, **kwargs) def build_deployment_scripts_get_request( - subscription_id: str, - resource_group_name: str, - script_name: str, - **kwargs: Any + resource_group_name: str, script_name: str, subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2020-10-01") # type: 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", "2020-10-01")) # type: str + accept = _headers.pop("Accept", "application/json") - accept = "application/json" # Construct URL - _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/Microsoft.Resources/deploymentScripts/{scriptName}") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/Microsoft.Resources/deploymentScripts/{scriptName}", + ) # pylint: disable=line-too-long path_format_arguments = { - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1), - "scriptName": _SERIALIZER.url("script_name", script_name, 'str', max_length=90, min_length=1), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url( + "resource_group_name", resource_group_name, "str", max_length=90, min_length=1 + ), + "scriptName": _SERIALIZER.url("script_name", script_name, "str", max_length=90, min_length=1), } _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - return HttpRequest( - method="GET", - url=_url, - params=_query_parameters, - headers=_header_parameters, - **kwargs - ) + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) def build_deployment_scripts_delete_request( - subscription_id: str, - resource_group_name: str, - script_name: str, - **kwargs: Any + resource_group_name: str, script_name: str, subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2020-10-01") # type: 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", "2020-10-01")) # type: str + accept = _headers.pop("Accept", "application/json") - accept = "application/json" # Construct URL - _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/Microsoft.Resources/deploymentScripts/{scriptName}") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/Microsoft.Resources/deploymentScripts/{scriptName}", + ) # pylint: disable=line-too-long path_format_arguments = { - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1), - "scriptName": _SERIALIZER.url("script_name", script_name, 'str', max_length=90, min_length=1), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url( + "resource_group_name", resource_group_name, "str", max_length=90, min_length=1 + ), + "scriptName": _SERIALIZER.url("script_name", script_name, "str", max_length=90, min_length=1), } _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - return HttpRequest( - method="DELETE", - url=_url, - params=_query_parameters, - headers=_header_parameters, - **kwargs - ) + return HttpRequest(method="DELETE", url=_url, params=_params, headers=_headers, **kwargs) -def build_deployment_scripts_list_by_subscription_request( - subscription_id: str, - **kwargs: Any -) -> HttpRequest: - api_version = kwargs.pop('api_version', "2020-10-01") # type: str +def build_deployment_scripts_list_by_subscription_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", "2020-10-01")) # type: str + accept = _headers.pop("Accept", "application/json") - accept = "application/json" # Construct URL _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/providers/Microsoft.Resources/deploymentScripts") path_format_arguments = { - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), } _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - return HttpRequest( - method="GET", - url=_url, - params=_query_parameters, - headers=_header_parameters, - **kwargs - ) + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) def build_deployment_scripts_get_logs_request( - subscription_id: str, - resource_group_name: str, - script_name: str, - **kwargs: Any + resource_group_name: str, script_name: str, subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2020-10-01") # type: 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", "2020-10-01")) # type: str + accept = _headers.pop("Accept", "application/json") - accept = "application/json" # Construct URL - _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/Microsoft.Resources/deploymentScripts/{scriptName}/logs") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/Microsoft.Resources/deploymentScripts/{scriptName}/logs", + ) # pylint: disable=line-too-long path_format_arguments = { - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1), - "scriptName": _SERIALIZER.url("script_name", script_name, 'str', max_length=90, min_length=1), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url( + "resource_group_name", resource_group_name, "str", max_length=90, min_length=1 + ), + "scriptName": _SERIALIZER.url("script_name", script_name, "str", max_length=90, min_length=1), } _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - return HttpRequest( - method="GET", - url=_url, - params=_query_parameters, - headers=_header_parameters, - **kwargs - ) + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) def build_deployment_scripts_get_logs_default_request( - subscription_id: str, - resource_group_name: str, - script_name: str, - *, - tail: Optional[int] = None, - **kwargs: Any + resource_group_name: str, script_name: str, subscription_id: str, *, tail: Optional[int] = None, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2020-10-01") # type: 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", "2020-10-01")) # type: str + accept = _headers.pop("Accept", "application/json") - accept = "application/json" # Construct URL - _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/Microsoft.Resources/deploymentScripts/{scriptName}/logs/default") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/Microsoft.Resources/deploymentScripts/{scriptName}/logs/default", + ) # pylint: disable=line-too-long path_format_arguments = { - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1), - "scriptName": _SERIALIZER.url("script_name", script_name, 'str', max_length=90, min_length=1), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url( + "resource_group_name", resource_group_name, "str", max_length=90, min_length=1 + ), + "scriptName": _SERIALIZER.url("script_name", script_name, "str", max_length=90, min_length=1), } _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") if tail is not None: - _query_parameters['tail'] = _SERIALIZER.query("tail", tail, 'int') + _params["tail"] = _SERIALIZER.query("tail", tail, "int") # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - return HttpRequest( - method="GET", - url=_url, - params=_query_parameters, - headers=_header_parameters, - **kwargs - ) + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) def build_deployment_scripts_list_by_resource_group_request( - subscription_id: str, - resource_group_name: str, - **kwargs: Any + resource_group_name: str, subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2020-10-01") # type: 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", "2020-10-01")) # type: str + accept = _headers.pop("Accept", "application/json") - accept = "application/json" # Construct URL - _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/Microsoft.Resources/deploymentScripts") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/Microsoft.Resources/deploymentScripts", + ) # pylint: disable=line-too-long path_format_arguments = { - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url( + "resource_group_name", resource_group_name, "str", max_length=90, min_length=1 + ), } _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') - - return HttpRequest( - method="GET", - url=_url, - params=_query_parameters, - headers=_header_parameters, - **kwargs - ) - -class DeploymentScriptsOperations(object): - """DeploymentScriptsOperations operations. - - You should not instantiate this class directly. Instead, you should create a Client instance that - instantiates it for you and attaches it as an attribute. - - :ivar models: Alias to model classes used in this operation group. - :type models: ~azure.mgmt.resource.deploymentscripts.v2020_10_01.models - :param client: Client for service requests. - :param config: Configuration of service client. - :param serializer: An object model serializer. - :param deserializer: An object model deserializer. + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) + + +class DeploymentScriptsOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. + + Instead, you should access the following operations through + :class:`~azure.mgmt.resource.deploymentscripts.v2020_10_01.DeploymentScriptsClient`'s + :attr:`deployment_scripts` attribute. """ models = _models - def __init__(self, client, config, serializer, deserializer): - self._client = client - self._serialize = serializer - self._deserialize = deserializer - self._config = config + def __init__(self, *args, **kwargs): + input_args = list(args) + self._client = input_args.pop(0) if input_args else kwargs.pop("client") + self._config = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") def _create_initial( self, resource_group_name: str, script_name: str, - deployment_script: "_models.DeploymentScript", + deployment_script: Union[_models.DeploymentScript, IO], **kwargs: Any - ) -> "_models.DeploymentScript": - cls = kwargs.pop('cls', None) # type: ClsType["_models.DeploymentScript"] + ) -> _models.DeploymentScript: error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) - api_version = kwargs.pop('api_version', "2020-10-01") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - _json = self._serialize.body(deployment_script, 'DeploymentScript') + api_version = kwargs.pop("api_version", _params.pop("api-version", "2020-10-01")) # type: str + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.DeploymentScript] - request = build_deployment_scripts_create_request_initial( - subscription_id=self._config.subscription_id, + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(deployment_script, (IO, bytes)): + _content = deployment_script + else: + _json = self._serialize.body(deployment_script, "DeploymentScript") + + request = build_deployment_scripts_create_request( resource_group_name=resource_group_name, script_name=script_name, + subscription_id=self._config.subscription_id, api_version=api_version, content_type=content_type, json=_json, - template_url=self._create_initial.metadata['url'], + content=_content, + template_url=self._create_initial.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200, 201]: map_error(status_code=response.status_code, response=response, error_map=error_map) - raise HttpResponseError(response=response, error_format=ARMErrorFormat) + error = self._deserialize.failsafe_deserialize(_models.DeploymentScriptsError, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) if response.status_code == 200: - deserialized = self._deserialize('DeploymentScript', pipeline_response) + deserialized = self._deserialize("DeploymentScript", pipeline_response) if response.status_code == 201: - deserialized = self._deserialize('DeploymentScript', pipeline_response) + deserialized = self._deserialize("DeploymentScript", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - _create_initial.metadata = {'url': "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/Microsoft.Resources/deploymentScripts/{scriptName}"} # type: ignore + _create_initial.metadata = {"url": "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/Microsoft.Resources/deploymentScripts/{scriptName}"} # type: ignore + @overload + def begin_create( + self, + resource_group_name: str, + script_name: str, + deployment_script: _models.DeploymentScript, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> LROPoller[_models.DeploymentScript]: + """Creates a deployment script. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param script_name: Name of the deployment script. Required. + :type script_name: str + :param deployment_script: Deployment script supplied to the operation. Required. + :type deployment_script: + ~azure.mgmt.resource.deploymentscripts.v2020_10_01.models.DeploymentScript + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be ARMPolling. Pass in False for this + operation to not poll, or pass in your own initialized polling object for a personal polling + strategy. + :paramtype polling: bool or ~azure.core.polling.PollingMethod + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of LROPoller that returns either DeploymentScript or the result of + cls(response) + :rtype: + ~azure.core.polling.LROPoller[~azure.mgmt.resource.deploymentscripts.v2020_10_01.models.DeploymentScript] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + def begin_create( + self, + resource_group_name: str, + script_name: str, + deployment_script: IO, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> LROPoller[_models.DeploymentScript]: + """Creates a deployment script. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param script_name: Name of the deployment script. Required. + :type script_name: str + :param deployment_script: Deployment script supplied to the operation. Required. + :type deployment_script: IO + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be ARMPolling. Pass in False for this + operation to not poll, or pass in your own initialized polling object for a personal polling + strategy. + :paramtype polling: bool or ~azure.core.polling.PollingMethod + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of LROPoller that returns either DeploymentScript or the result of + cls(response) + :rtype: + ~azure.core.polling.LROPoller[~azure.mgmt.resource.deploymentscripts.v2020_10_01.models.DeploymentScript] + :raises ~azure.core.exceptions.HttpResponseError: + """ @distributed_trace def begin_create( self, resource_group_name: str, script_name: str, - deployment_script: "_models.DeploymentScript", + deployment_script: Union[_models.DeploymentScript, IO], **kwargs: Any - ) -> LROPoller["_models.DeploymentScript"]: + ) -> LROPoller[_models.DeploymentScript]: """Creates a deployment script. :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. :type resource_group_name: str - :param script_name: Name of the deployment script. + :param script_name: Name of the deployment script. Required. :type script_name: str - :param deployment_script: Deployment script supplied to the operation. + :param deployment_script: Deployment script supplied to the operation. Is either a model type + or a IO type. Required. :type deployment_script: - ~azure.mgmt.resource.deploymentscripts.v2020_10_01.models.DeploymentScript + ~azure.mgmt.resource.deploymentscripts.v2020_10_01.models.DeploymentScript or IO + :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. + Default value is None. + :paramtype content_type: str :keyword callable cls: A custom type or function that will be passed the direct response :keyword str continuation_token: A continuation token to restart a poller from a saved state. :keyword polling: By default, your polling method will be ARMPolling. Pass in False for this @@ -436,105 +497,185 @@ def begin_create( cls(response) :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.resource.deploymentscripts.v2020_10_01.models.DeploymentScript] - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - api_version = kwargs.pop('api_version', "2020-10-01") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] - polling = kwargs.pop('polling', True) # type: Union[bool, PollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType["_models.DeploymentScript"] - lro_delay = kwargs.pop( - 'polling_interval', - self._config.polling_interval - ) - cont_token = kwargs.pop('continuation_token', None) # type: Optional[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", "2020-10-01")) # type: str + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.DeploymentScript] + polling = kwargs.pop("polling", True) # type: Union[bool, PollingMethod] + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token = kwargs.pop("continuation_token", None) # type: Optional[str] if cont_token is None: - raw_result = self._create_initial( + raw_result = self._create_initial( # type: ignore resource_group_name=resource_group_name, script_name=script_name, deployment_script=deployment_script, api_version=api_version, content_type=content_type, - cls=lambda x,y,z: x, + cls=lambda x, y, z: x, + headers=_headers, + params=_params, **kwargs ) - kwargs.pop('error_map', None) + kwargs.pop("error_map", None) def get_long_running_output(pipeline_response): - response = pipeline_response.http_response - deserialized = self._deserialize('DeploymentScript', pipeline_response) + deserialized = self._deserialize("DeploymentScript", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - - if polling is True: polling_method = ARMPolling(lro_delay, **kwargs) - elif polling is False: polling_method = NoPolling() - else: polling_method = polling + if polling is True: + polling_method = cast(PollingMethod, ARMPolling(lro_delay, **kwargs)) # type: PollingMethod + elif polling is False: + polling_method = cast(PollingMethod, NoPolling()) + else: + polling_method = polling if cont_token: return LROPoller.from_continuation_token( polling_method=polling_method, continuation_token=cont_token, client=self._client, - deserialization_callback=get_long_running_output + deserialization_callback=get_long_running_output, ) return LROPoller(self._client, raw_result, get_long_running_output, polling_method) - begin_create.metadata = {'url': "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/Microsoft.Resources/deploymentScripts/{scriptName}"} # type: ignore + begin_create.metadata = {"url": "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/Microsoft.Resources/deploymentScripts/{scriptName}"} # type: ignore - @distributed_trace + @overload def update( self, resource_group_name: str, script_name: str, - deployment_script: Optional["_models.DeploymentScriptUpdateParameter"] = None, + deployment_script: Optional[_models.DeploymentScriptUpdateParameter] = None, + *, + content_type: str = "application/json", **kwargs: Any - ) -> "_models.DeploymentScript": + ) -> _models.DeploymentScript: """Updates deployment script tags with specified values. :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. :type resource_group_name: str - :param script_name: Name of the deployment script. + :param script_name: Name of the deployment script. Required. :type script_name: str :param deployment_script: Deployment script resource with the tags to be updated. Default value is None. :type deployment_script: ~azure.mgmt.resource.deploymentscripts.v2020_10_01.models.DeploymentScriptUpdateParameter + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: DeploymentScript or the result of cls(response) + :rtype: ~azure.mgmt.resource.deploymentscripts.v2020_10_01.models.DeploymentScript + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + def update( + self, + resource_group_name: str, + script_name: str, + deployment_script: Optional[IO] = None, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.DeploymentScript: + """Updates deployment script tags with specified values. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param script_name: Name of the deployment script. Required. + :type script_name: str + :param deployment_script: Deployment script resource with the tags to be updated. Default value + is None. + :type deployment_script: IO + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: DeploymentScript, or the result of cls(response) + :return: DeploymentScript or the result of cls(response) :rtype: ~azure.mgmt.resource.deploymentscripts.v2020_10_01.models.DeploymentScript - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace + def update( + self, + resource_group_name: str, + script_name: str, + deployment_script: Optional[Union[_models.DeploymentScriptUpdateParameter, IO]] = None, + **kwargs: Any + ) -> _models.DeploymentScript: + """Updates deployment script tags with specified values. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param script_name: Name of the deployment script. Required. + :type script_name: str + :param deployment_script: Deployment script resource with the tags to be updated. Is either a + model type or a IO type. Default value is None. + :type deployment_script: + ~azure.mgmt.resource.deploymentscripts.v2020_10_01.models.DeploymentScriptUpdateParameter or IO + :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. + Default value is None. + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: DeploymentScript or the result of cls(response) + :rtype: ~azure.mgmt.resource.deploymentscripts.v2020_10_01.models.DeploymentScript + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.DeploymentScript"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) - api_version = kwargs.pop('api_version', "2020-10-01") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - if deployment_script is not None: - _json = self._serialize.body(deployment_script, 'DeploymentScriptUpdateParameter') + api_version = kwargs.pop("api_version", _params.pop("api-version", "2020-10-01")) # type: str + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.DeploymentScript] + + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(deployment_script, (IO, bytes)): + _content = deployment_script else: - _json = None + if deployment_script is not None: + _json = self._serialize.body(deployment_script, "DeploymentScriptUpdateParameter") + else: + _json = None request = build_deployment_scripts_update_request( - subscription_id=self._config.subscription_id, resource_group_name=resource_group_name, script_name=script_name, + subscription_id=self._config.subscription_id, api_version=api_version, content_type=content_type, json=_json, - template_url=self.update.metadata['url'], + content=_content, + template_url=self.update.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200]: @@ -542,58 +683,59 @@ def update( error = self._deserialize.failsafe_deserialize(_models.DeploymentScriptsError, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - deserialized = self._deserialize('DeploymentScript', pipeline_response) + deserialized = self._deserialize("DeploymentScript", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - update.metadata = {'url': "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/Microsoft.Resources/deploymentScripts/{scriptName}"} # type: ignore - + update.metadata = {"url": "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/Microsoft.Resources/deploymentScripts/{scriptName}"} # type: ignore @distributed_trace - def get( - self, - resource_group_name: str, - script_name: str, - **kwargs: Any - ) -> "_models.DeploymentScript": + def get(self, resource_group_name: str, script_name: str, **kwargs: Any) -> _models.DeploymentScript: """Gets a deployment script with a given name. :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. :type resource_group_name: str - :param script_name: Name of the deployment script. + :param script_name: Name of the deployment script. Required. :type script_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: DeploymentScript, or the result of cls(response) + :return: DeploymentScript or the result of cls(response) :rtype: ~azure.mgmt.resource.deploymentscripts.v2020_10_01.models.DeploymentScript - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.DeploymentScript"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + 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', "2020-10-01") # type: str + api_version = kwargs.pop("api_version", _params.pop("api-version", "2020-10-01")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[_models.DeploymentScript] - request = build_deployment_scripts_get_request( - subscription_id=self._config.subscription_id, resource_group_name=resource_group_name, script_name=script_name, + subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.get.metadata['url'], + template_url=self.get.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200]: @@ -601,59 +743,62 @@ def get( error = self._deserialize.failsafe_deserialize(_models.DeploymentScriptsError, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - deserialized = self._deserialize('DeploymentScript', pipeline_response) + deserialized = self._deserialize("DeploymentScript", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - get.metadata = {'url': "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/Microsoft.Resources/deploymentScripts/{scriptName}"} # type: ignore - + get.metadata = {"url": "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/Microsoft.Resources/deploymentScripts/{scriptName}"} # type: ignore @distributed_trace def delete( # pylint: disable=inconsistent-return-statements - self, - resource_group_name: str, - script_name: str, - **kwargs: Any + self, resource_group_name: str, script_name: str, **kwargs: Any ) -> None: """Deletes a deployment script. When operation completes, status code 200 returned without content. :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. :type resource_group_name: str - :param script_name: Name of the deployment script. + :param script_name: Name of the deployment script. Required. :type script_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: None, or the result of cls(response) + :return: None or the result of cls(response) :rtype: None - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType[None] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + 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', "2020-10-01") # type: str + api_version = kwargs.pop("api_version", _params.pop("api-version", "2020-10-01")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[None] - request = build_deployment_scripts_delete_request( - subscription_id=self._config.subscription_id, resource_group_name=resource_group_name, script_name=script_name, + subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.delete.metadata['url'], + template_url=self.delete.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200, 204]: @@ -664,49 +809,53 @@ def delete( # pylint: disable=inconsistent-return-statements if cls: return cls(pipeline_response, None, {}) - delete.metadata = {'url': "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/Microsoft.Resources/deploymentScripts/{scriptName}"} # type: ignore - + delete.metadata = {"url": "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/Microsoft.Resources/deploymentScripts/{scriptName}"} # type: ignore @distributed_trace - def list_by_subscription( - self, - **kwargs: Any - ) -> Iterable["_models.DeploymentScriptListResult"]: + def list_by_subscription(self, **kwargs: Any) -> Iterable["_models.DeploymentScript"]: """Lists all deployment scripts for a given subscription. :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either DeploymentScriptListResult or the result of - cls(response) + :return: An iterator like instance of either DeploymentScript or the result of cls(response) :rtype: - ~azure.core.paging.ItemPaged[~azure.mgmt.resource.deploymentscripts.v2020_10_01.models.DeploymentScriptListResult] - :raises: ~azure.core.exceptions.HttpResponseError + ~azure.core.paging.ItemPaged[~azure.mgmt.resource.deploymentscripts.v2020_10_01.models.DeploymentScript] + :raises ~azure.core.exceptions.HttpResponseError: """ - api_version = kwargs.pop('api_version', "2020-10-01") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2020-10-01")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[_models.DeploymentScriptListResult] - cls = kwargs.pop('cls', None) # type: ClsType["_models.DeploymentScriptListResult"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) + def prepare_request(next_link=None): if not next_link: - + request = build_deployment_scripts_list_by_subscription_request( subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.list_by_subscription.metadata['url'], + template_url=self.list_by_subscription.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore else: - - request = build_deployment_scripts_list_by_subscription_request( - subscription_id=self._config.subscription_id, - template_url=next_link, - ) + # make call to next link with the client's api-version + _parsed_next_link = urlparse(next_link) + _next_request_params = case_insensitive_dict(parse_qs(_parsed_next_link.query)) + _next_request_params["api-version"] = self._config.api_version + request = HttpRequest("GET", urljoin(next_link, _parsed_next_link.path), params=_next_request_params) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore request.method = "GET" return request @@ -720,10 +869,8 @@ def extract_data(pipeline_response): def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) response = pipeline_response.http_response @@ -734,54 +881,54 @@ def get_next(next_link=None): return pipeline_response + return ItemPaged(get_next, extract_data) - return ItemPaged( - get_next, extract_data - ) - list_by_subscription.metadata = {'url': "/subscriptions/{subscriptionId}/providers/Microsoft.Resources/deploymentScripts"} # type: ignore + list_by_subscription.metadata = {"url": "/subscriptions/{subscriptionId}/providers/Microsoft.Resources/deploymentScripts"} # type: ignore @distributed_trace - def get_logs( - self, - resource_group_name: str, - script_name: str, - **kwargs: Any - ) -> "_models.ScriptLogsList": + def get_logs(self, resource_group_name: str, script_name: str, **kwargs: Any) -> _models.ScriptLogsList: """Gets deployment script logs for a given deployment script name. :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. :type resource_group_name: str - :param script_name: Name of the deployment script. + :param script_name: Name of the deployment script. Required. :type script_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: ScriptLogsList, or the result of cls(response) + :return: ScriptLogsList or the result of cls(response) :rtype: ~azure.mgmt.resource.deploymentscripts.v2020_10_01.models.ScriptLogsList - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.ScriptLogsList"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + 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', "2020-10-01") # type: str + api_version = kwargs.pop("api_version", _params.pop("api-version", "2020-10-01")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[_models.ScriptLogsList] - request = build_deployment_scripts_get_logs_request( - subscription_id=self._config.subscription_id, resource_group_name=resource_group_name, script_name=script_name, + subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.get_logs.metadata['url'], + template_url=self.get_logs.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200]: @@ -789,64 +936,66 @@ def get_logs( error = self._deserialize.failsafe_deserialize(_models.DeploymentScriptsError, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - deserialized = self._deserialize('ScriptLogsList', pipeline_response) + deserialized = self._deserialize("ScriptLogsList", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - get_logs.metadata = {'url': "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/Microsoft.Resources/deploymentScripts/{scriptName}/logs"} # type: ignore - + get_logs.metadata = {"url": "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/Microsoft.Resources/deploymentScripts/{scriptName}/logs"} # type: ignore @distributed_trace def get_logs_default( - self, - resource_group_name: str, - script_name: str, - tail: Optional[int] = None, - **kwargs: Any - ) -> "_models.ScriptLog": + self, resource_group_name: str, script_name: str, tail: Optional[int] = None, **kwargs: Any + ) -> _models.ScriptLog: """Gets deployment script logs for a given deployment script name. :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. :type resource_group_name: str - :param script_name: Name of the deployment script. + :param script_name: Name of the deployment script. Required. :type script_name: str :param tail: The number of lines to show from the tail of the deployment script log. Valid value is a positive number up to 1000. If 'tail' is not provided, all available logs are shown up to container instance log capacity of 4mb. Default value is None. :type tail: int :keyword callable cls: A custom type or function that will be passed the direct response - :return: ScriptLog, or the result of cls(response) + :return: ScriptLog or the result of cls(response) :rtype: ~azure.mgmt.resource.deploymentscripts.v2020_10_01.models.ScriptLog - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.ScriptLog"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) - api_version = kwargs.pop('api_version', "2020-10-01") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2020-10-01")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[_models.ScriptLog] - request = build_deployment_scripts_get_logs_default_request( - subscription_id=self._config.subscription_id, resource_group_name=resource_group_name, script_name=script_name, - api_version=api_version, + subscription_id=self._config.subscription_id, tail=tail, - template_url=self.get_logs_default.metadata['url'], + api_version=api_version, + template_url=self.get_logs_default.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200]: @@ -854,61 +1003,64 @@ def get_logs_default( error = self._deserialize.failsafe_deserialize(_models.DeploymentScriptsError, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - deserialized = self._deserialize('ScriptLog', pipeline_response) + deserialized = self._deserialize("ScriptLog", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - get_logs_default.metadata = {'url': "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/Microsoft.Resources/deploymentScripts/{scriptName}/logs/default"} # type: ignore - + get_logs_default.metadata = {"url": "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/Microsoft.Resources/deploymentScripts/{scriptName}/logs/default"} # type: ignore @distributed_trace - def list_by_resource_group( - self, - resource_group_name: str, - **kwargs: Any - ) -> Iterable["_models.DeploymentScriptListResult"]: + def list_by_resource_group(self, resource_group_name: str, **kwargs: Any) -> Iterable["_models.DeploymentScript"]: """Lists deployments scripts. :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. :type resource_group_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either DeploymentScriptListResult or the result of - cls(response) + :return: An iterator like instance of either DeploymentScript or the result of cls(response) :rtype: - ~azure.core.paging.ItemPaged[~azure.mgmt.resource.deploymentscripts.v2020_10_01.models.DeploymentScriptListResult] - :raises: ~azure.core.exceptions.HttpResponseError + ~azure.core.paging.ItemPaged[~azure.mgmt.resource.deploymentscripts.v2020_10_01.models.DeploymentScript] + :raises ~azure.core.exceptions.HttpResponseError: """ - api_version = kwargs.pop('api_version', "2020-10-01") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2020-10-01")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[_models.DeploymentScriptListResult] - cls = kwargs.pop('cls', None) # type: ClsType["_models.DeploymentScriptListResult"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) + def prepare_request(next_link=None): if not next_link: - + request = build_deployment_scripts_list_by_resource_group_request( - subscription_id=self._config.subscription_id, 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'], + 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.url = self._client.format_url(request.url) # type: ignore else: - - request = build_deployment_scripts_list_by_resource_group_request( - subscription_id=self._config.subscription_id, - resource_group_name=resource_group_name, - template_url=next_link, - ) + # make call to next link with the client's api-version + _parsed_next_link = urlparse(next_link) + _next_request_params = case_insensitive_dict(parse_qs(_parsed_next_link.query)) + _next_request_params["api-version"] = self._config.api_version + request = HttpRequest("GET", urljoin(next_link, _parsed_next_link.path), params=_next_request_params) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore request.method = "GET" return request @@ -922,10 +1074,8 @@ def extract_data(pipeline_response): def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) response = pipeline_response.http_response @@ -936,8 +1086,6 @@ def get_next(next_link=None): return pipeline_response + return ItemPaged(get_next, extract_data) - return ItemPaged( - get_next, extract_data - ) - list_by_resource_group.metadata = {'url': "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/Microsoft.Resources/deploymentScripts"} # type: ignore + list_by_resource_group.metadata = {"url": "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/Microsoft.Resources/deploymentScripts"} # type: ignore diff --git a/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/deploymentscripts/v2020_10_01/operations/_patch.py b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/deploymentscripts/v2020_10_01/operations/_patch.py new file mode 100644 index 0000000000000..f7dd32510333d --- /dev/null +++ b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/deploymentscripts/v2020_10_01/operations/_patch.py @@ -0,0 +1,20 @@ +# ------------------------------------ +# Copyright (c) Microsoft Corporation. +# Licensed under the MIT License. +# ------------------------------------ +"""Customize generated code here. + +Follow our quickstart for examples: https://aka.ms/azsdk/python/dpcodegen/python/customize +""" +from typing import List + +__all__: List[str] = [] # Add all objects you want publicly available to users at this package level + + +def patch_sdk(): + """Do not remove from this file. + + `patch_sdk` is a last resort escape hatch that allows you to do customizations + you can't accomplish using the techniques described in + https://aka.ms/azsdk/python/dpcodegen/python/customize + """ diff --git a/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/features/__init__.py b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/features/__init__.py index 516b87957f1d2..add40d97624e9 100644 --- a/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/features/__init__.py +++ b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/features/__init__.py @@ -14,3 +14,7 @@ patch_sdk() except ImportError: pass + +from ._version import VERSION + +__version__ = VERSION diff --git a/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/features/_configuration.py b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/features/_configuration.py index 969dd1968a096..cdacae0fdc397 100644 --- a/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/features/_configuration.py +++ b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/features/_configuration.py @@ -8,7 +8,7 @@ # Changes may cause incorrect behavior and will be lost if the code is # regenerated. # -------------------------------------------------------------------------- -from typing import TYPE_CHECKING +from typing import Any, TYPE_CHECKING from azure.core.configuration import Configuration from azure.core.pipeline import policies @@ -18,8 +18,6 @@ if TYPE_CHECKING: # pylint: disable=unused-import,ungrouped-imports - from typing import Any - from azure.core.credentials import TokenCredential class FeatureClientConfiguration(Configuration): @@ -28,16 +26,16 @@ class FeatureClientConfiguration(Configuration): Note that all parameters used to create this instance are saved as instance attributes. - :param credential: Credential needed for the client to connect to Azure. + :param credential: Credential needed for the client to connect to Azure. Required. :type credential: ~azure.core.credentials.TokenCredential - :param subscription_id: The Azure subscription ID. + :param subscription_id: The Azure subscription ID. Required. :type subscription_id: str """ def __init__( self, - credential, # type: "TokenCredential" - subscription_id, # type: str + credential: "TokenCredential", + subscription_id: str, **kwargs # type: Any ): # type: (...) -> None diff --git a/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/features/_feature_client.py b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/features/_feature_client.py index 92f00b88e7376..1540657aab3e9 100644 --- a/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/features/_feature_client.py +++ b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/features/_feature_client.py @@ -9,9 +9,7 @@ # regenerated. # -------------------------------------------------------------------------- -from typing import TYPE_CHECKING - -from msrest import Deserializer, Serializer +from typing import Any, Optional, TYPE_CHECKING from azure.mgmt.core import ARMPipelineClient from azure.profiles import KnownProfiles, ProfileDefinition @@ -19,11 +17,10 @@ from ._configuration import FeatureClientConfiguration from ._operations_mixin import FeatureClientOperationsMixin +from ._serialization import Deserializer, Serializer if TYPE_CHECKING: # pylint: disable=unused-import,ungrouped-imports - from typing import Any, Optional - from azure.core.credentials import TokenCredential class _SDKClient(object): @@ -44,9 +41,9 @@ class FeatureClient(FeatureClientOperationsMixin, MultiApiClientMixin, _SDKClien The api-version parameter sets the default API version if the operation group is not described in the profile. - :param credential: Credential needed for the client to connect to Azure. + :param credential: Credential needed for the client to connect to Azure. Required. :type credential: ~azure.core.credentials.TokenCredential - :param subscription_id: The Azure subscription ID. + :param subscription_id: The Azure subscription ID. Required. :type subscription_id: str :param api_version: API version to use if no profile is provided, or if missing in profile. :type api_version: str @@ -67,10 +64,10 @@ class FeatureClient(FeatureClientOperationsMixin, MultiApiClientMixin, _SDKClien def __init__( self, - credential, # type: "TokenCredential" - subscription_id, # type: str + credential: "TokenCredential", + subscription_id: str, api_version=None, # type: Optional[str] - base_url="https://management.azure.com", # type: str + base_url: str = "https://management.azure.com", profile=KnownProfiles.default, # type: KnownProfiles **kwargs # type: Any ): diff --git a/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/features/_operations_mixin.py b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/features/_operations_mixin.py index aaebaf1b44af8..0f15ae9268635 100644 --- a/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/features/_operations_mixin.py +++ b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/features/_operations_mixin.py @@ -8,30 +8,27 @@ # Changes may cause incorrect behavior and will be lost if the code is # regenerated. # -------------------------------------------------------------------------- -from msrest import Serializer, Deserializer -from typing import TYPE_CHECKING +from ._serialization import Serializer, Deserializer +from typing import Any, Iterable -if TYPE_CHECKING: - # pylint: disable=unused-import,ungrouped-imports - from typing import Any, Iterable +from azure.core.paging import ItemPaged - from azure.core.paging import ItemPaged +from . import models as _models class FeatureClientOperationsMixin(object): def list_operations( self, - **kwargs # type: Any - ): - # type: (...) -> Iterable["_models.OperationListResult"] + **kwargs: Any + ) -> Iterable["_models.Operation"]: """Lists all of the available Microsoft.Features REST API operations. :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either OperationListResult or the result of cls(response) + :return: An iterator like instance of either Operation or the result of cls(response) :rtype: - ~azure.core.paging.ItemPaged[~azure.mgmt.resource.features.v2021_07_01.models.OperationListResult] - :raises: ~azure.core.exceptions.HttpResponseError + ~azure.core.paging.ItemPaged[~azure.mgmt.resource.features.v2021_07_01.models.Operation] + :raises ~azure.core.exceptions.HttpResponseError: """ api_version = self._get_api_version('list_operations') if api_version == '2015-12-01': diff --git a/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/features/_serialization.py b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/features/_serialization.py new file mode 100644 index 0000000000000..240df16c57f3c --- /dev/null +++ b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/features/_serialization.py @@ -0,0 +1,2006 @@ +# -------------------------------------------------------------------------- +# +# Copyright (c) Microsoft Corporation. All rights reserved. +# +# The MIT License (MIT) +# +# Permission is hereby granted, free of charge, to any person obtaining a copy +# of this software and associated documentation files (the ""Software""), to +# deal in the Software without restriction, including without limitation the +# rights to use, copy, modify, merge, publish, distribute, sublicense, and/or +# sell copies of the Software, and to permit persons to whom the Software is +# furnished to do so, subject to the following conditions: +# +# The above copyright notice and this permission notice shall be included in +# all copies or substantial portions of the Software. +# +# THE SOFTWARE IS PROVIDED *AS IS*, WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING +# FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS +# IN THE SOFTWARE. +# +# -------------------------------------------------------------------------- + +# pylint: skip-file + +from base64 import b64decode, b64encode +import calendar +import datetime +import decimal +import email +from enum import Enum +import json +import logging +import re +import sys +import codecs +try: + from urllib import quote # type: ignore +except ImportError: + from urllib.parse import quote # type: ignore +import xml.etree.ElementTree as ET + +import isodate + +from typing import Dict, Any, cast, TYPE_CHECKING + +from azure.core.exceptions import DeserializationError, SerializationError, raise_with_traceback + +_BOM = codecs.BOM_UTF8.decode(encoding='utf-8') + +if TYPE_CHECKING: + from typing import Optional, Union, AnyStr, IO, Mapping + +class RawDeserializer: + + # Accept "text" because we're open minded people... + JSON_REGEXP = re.compile(r'^(application|text)/([a-z+.]+\+)?json$') + + # Name used in context + CONTEXT_NAME = "deserialized_data" + + @classmethod + def deserialize_from_text(cls, data, content_type=None): + # type: (Optional[Union[AnyStr, IO]], Optional[str]) -> Any + """Decode data according to content-type. + + Accept a stream of data as well, but will be load at once in memory for now. + + If no content-type, will return the string version (not bytes, not stream) + + :param data: Input, could be bytes or stream (will be decoded with UTF8) or text + :type data: str or bytes or IO + :param str content_type: The content type. + """ + if hasattr(data, 'read'): + # Assume a stream + data = cast(IO, data).read() + + if isinstance(data, bytes): + data_as_str = data.decode(encoding='utf-8-sig') + else: + # Explain to mypy the correct type. + data_as_str = cast(str, data) + + # Remove Byte Order Mark if present in string + data_as_str = data_as_str.lstrip(_BOM) + + if content_type is None: + return data + + if cls.JSON_REGEXP.match(content_type): + try: + return json.loads(data_as_str) + except ValueError as err: + raise DeserializationError("JSON is invalid: {}".format(err), err) + elif "xml" in (content_type or []): + try: + + try: + if isinstance(data, unicode): # type: ignore + # If I'm Python 2.7 and unicode XML will scream if I try a "fromstring" on unicode string + data_as_str = data_as_str.encode(encoding="utf-8") # type: ignore + except NameError: + pass + + return ET.fromstring(data_as_str) # nosec + except ET.ParseError: + # It might be because the server has an issue, and returned JSON with + # content-type XML.... + # So let's try a JSON load, and if it's still broken + # let's flow the initial exception + def _json_attemp(data): + try: + return True, json.loads(data) + except ValueError: + return False, None # Don't care about this one + success, json_result = _json_attemp(data) + if success: + return json_result + # If i'm here, it's not JSON, it's not XML, let's scream + # and raise the last context in this block (the XML exception) + # The function hack is because Py2.7 messes up with exception + # context otherwise. + _LOGGER.critical("Wasn't XML not JSON, failing") + raise_with_traceback(DeserializationError, "XML is invalid") + 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 + """Deserialize from HTTP response. + + Use bytes and headers to NOT use any requests/aiohttp or whatever + specific implementation. + Headers will tested for "content-type" + """ + # Try to use content-type from headers if available + content_type = None + if 'content-type' in headers: + content_type = headers['content-type'].split(";")[0].strip().lower() + # Ouch, this server did not declare what it sent... + # Let's guess it's JSON... + # Also, since Autorest was considering that an empty body was a valid JSON, + # need that test as well.... + else: + content_type = "application/json" + + if body_bytes: + return cls.deserialize_from_text(body_bytes, content_type) + return None + +try: + basestring # type: ignore + unicode_str = unicode # type: ignore +except NameError: + basestring = str # type: ignore + unicode_str = str # type: ignore + +_LOGGER = logging.getLogger(__name__) + +try: + _long_type = long # type: ignore +except NameError: + _long_type = int + +class UTC(datetime.tzinfo): + """Time Zone info for handling UTC""" + + def utcoffset(self, dt): + """UTF offset for UTC is 0.""" + return datetime.timedelta(0) + + def tzname(self, dt): + """Timestamp representation.""" + return "Z" + + def dst(self, dt): + """No daylight saving for UTC.""" + return datetime.timedelta(hours=1) + +try: + from datetime import timezone as _FixedOffset +except ImportError: # Python 2.7 + class _FixedOffset(datetime.tzinfo): # type: ignore + """Fixed offset in minutes east from UTC. + Copy/pasted from Python doc + :param datetime.timedelta offset: offset in timedelta format + """ + + def __init__(self, offset): + self.__offset = offset + + def utcoffset(self, dt): + return self.__offset + + def tzname(self, dt): + return str(self.__offset.total_seconds()/3600) + + def __repr__(self): + return "".format(self.tzname(None)) + + def dst(self, dt): + return datetime.timedelta(0) + + def __getinitargs__(self): + return (self.__offset,) + +try: + from datetime import timezone + TZ_UTC = timezone.utc # type: ignore +except ImportError: + TZ_UTC = UTC() # type: ignore + +_FLATTEN = re.compile(r"(? y, + "minimum": lambda x, y: x < y, + "maximum": lambda x, y: x > y, + "minimum_ex": lambda x, y: x <= y, + "maximum_ex": lambda x, y: x >= y, + "min_items": lambda x, y: len(x) < y, + "max_items": lambda x, y: len(x) > y, + "pattern": lambda x, y: not re.match(y, x, re.UNICODE), + "unique": lambda x, y: len(x) != len(set(x)), + "multiple": lambda x, y: x % y != 0 + } + + def __init__(self, classes=None): + self.serialize_type = { + 'iso-8601': Serializer.serialize_iso, + 'rfc-1123': Serializer.serialize_rfc, + 'unix-time': Serializer.serialize_unix, + 'duration': Serializer.serialize_duration, + 'date': Serializer.serialize_date, + 'time': Serializer.serialize_time, + 'decimal': Serializer.serialize_decimal, + 'long': Serializer.serialize_long, + 'bytearray': Serializer.serialize_bytearray, + 'base64': Serializer.serialize_base64, + 'object': self.serialize_object, + '[]': self.serialize_iter, + '{}': self.serialize_dict + } + self.dependencies = dict(classes) if classes else {} + self.key_transformer = full_restapi_key_transformer + self.client_side_validation = True + + def _serialize(self, target_obj, data_type=None, **kwargs): + """Serialize data into a string according to type. + + :param target_obj: The data to be serialized. + :param str data_type: The type to be serialized from. + :rtype: str, dict + :raises: SerializationError if serialization fails. + """ + key_transformer = kwargs.get("key_transformer", self.key_transformer) + keep_readonly = kwargs.get("keep_readonly", False) + if target_obj is None: + return None + + attr_name = None + class_name = target_obj.__class__.__name__ + + if data_type: + return self.serialize_data( + target_obj, data_type, **kwargs) + + if not hasattr(target_obj, "_attribute_map"): + data_type = type(target_obj).__name__ + if data_type in self.basic_types.values(): + return self.serialize_data( + target_obj, data_type, **kwargs) + + # Force "is_xml" kwargs if we detect a XML model + try: + is_xml_model_serialization = kwargs["is_xml"] + except KeyError: + is_xml_model_serialization = kwargs.setdefault("is_xml", target_obj.is_xml_model()) + + serialized = {} + if is_xml_model_serialization: + serialized = target_obj._create_xml_node() + try: + attributes = target_obj._attribute_map + for attr, attr_desc in attributes.items(): + attr_name = attr + if not keep_readonly and target_obj._validation.get(attr_name, {}).get('readonly', False): + continue + + if attr_name == "additional_properties" and attr_desc["key"] == '': + if target_obj.additional_properties is not None: + serialized.update(target_obj.additional_properties) + continue + try: + + orig_attr = getattr(target_obj, attr) + if is_xml_model_serialization: + pass # Don't provide "transformer" for XML for now. Keep "orig_attr" + else: # JSON + keys, orig_attr = key_transformer(attr, attr_desc.copy(), orig_attr) + keys = keys if isinstance(keys, list) else [keys] + + + kwargs["serialization_ctxt"] = attr_desc + new_attr = self.serialize_data(orig_attr, attr_desc['type'], **kwargs) + + + if is_xml_model_serialization: + xml_desc = attr_desc.get('xml', {}) + xml_name = xml_desc.get('name', attr_desc['key']) + xml_prefix = xml_desc.get('prefix', None) + xml_ns = xml_desc.get('ns', None) + 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) + continue + if xml_desc.get("text", False): + serialized.text = new_attr + continue + if isinstance(new_attr, list): + serialized.extend(new_attr) + 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', {}): + splitted_tag = new_attr.tag.split("}") + if len(splitted_tag) == 2: # Namespace + new_attr.tag = "}".join([splitted_tag[0], xml_name]) + else: + new_attr.tag = xml_name + serialized.append(new_attr) + 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) + else: # JSON + for k in reversed(keys): + unflattened = {k: new_attr} + new_attr = unflattened + + _new_attr = new_attr + _serialized = serialized + for k in keys: + if k not in _serialized: + _serialized.update(_new_attr) + _new_attr = _new_attr[k] + _serialized = _serialized[k] + except ValueError: + continue + + except (AttributeError, KeyError, TypeError) as err: + msg = "Attribute {} in object {} cannot be serialized.\n{}".format( + attr_name, class_name, str(target_obj)) + raise_with_traceback(SerializationError, msg, err) + else: + return serialized + + def body(self, data, data_type, **kwargs): + """Serialize data intended for a request body. + + :param data: The data to be serialized. + :param str data_type: The type to be serialized from. + :rtype: dict + :raises: SerializationError if serialization fails. + :raises: ValueError if data is None + """ + + # Just in case this is a dict + internal_data_type = data_type.strip('[]{}') + internal_data_type = self.dependencies.get(internal_data_type, None) + try: + is_xml_model_serialization = kwargs["is_xml"] + except KeyError: + if internal_data_type and issubclass(internal_data_type, Model): + is_xml_model_serialization = kwargs.setdefault("is_xml", internal_data_type.is_xml_model()) + else: + is_xml_model_serialization = False + if internal_data_type and not isinstance(internal_data_type, Enum): + try: + deserializer = Deserializer(self.dependencies) + # Since it's on serialization, it's almost sure that format is not JSON REST + # We're not able to deal with additional properties for now. + deserializer.additional_properties_detection = False + if is_xml_model_serialization: + deserializer.key_extractors = [ + attribute_key_case_insensitive_extractor, + ] + else: + deserializer.key_extractors = [ + rest_key_case_insensitive_extractor, + attribute_key_case_insensitive_extractor, + last_rest_key_case_insensitive_extractor + ] + data = deserializer._deserialize(data_type, data) + except DeserializationError as err: + raise_with_traceback( + SerializationError, "Unable to build a model: "+str(err), err) + + return self._serialize(data, data_type, **kwargs) + + def url(self, name, data, data_type, **kwargs): + """Serialize data intended for a URL path. + + :param data: The data to be serialized. + :param str data_type: The type to be serialized from. + :rtype: str + :raises: TypeError if serialization fails. + :raises: ValueError if data is None + """ + try: + output = self.serialize_data(data, data_type, **kwargs) + if data_type == 'bool': + output = json.dumps(output) + + if kwargs.get('skip_quote') is True: + output = str(output) + else: + output = quote(str(output), safe='') + except SerializationError: + raise TypeError("{} must be type {}.".format(name, data_type)) + else: + return output + + def query(self, name, data, data_type, **kwargs): + """Serialize data intended for a URL query. + + :param data: The data to be serialized. + :param str data_type: The type to be serialized from. + :rtype: str + :raises: TypeError if serialization fails. + :raises: ValueError if data is None + """ + try: + # 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)) + + # Not a list, regular serialization + output = self.serialize_data(data, data_type, **kwargs) + if data_type == 'bool': + output = json.dumps(output) + if kwargs.get('skip_quote') is True: + output = str(output) + else: + output = quote(str(output), safe='') + except SerializationError: + raise TypeError("{} must be type {}.".format(name, data_type)) + else: + return str(output) + + def header(self, name, data, data_type, **kwargs): + """Serialize data intended for a request header. + + :param data: The data to be serialized. + :param str data_type: The type to be serialized from. + :rtype: str + :raises: TypeError if serialization fails. + :raises: ValueError if data is None + """ + try: + if data_type in ['[str]']: + data = ["" if d is None else d for d in data] + + output = self.serialize_data(data, data_type, **kwargs) + if data_type == 'bool': + output = json.dumps(output) + except SerializationError: + raise TypeError("{} must be type {}.".format(name, data_type)) + else: + return str(output) + + def serialize_data(self, data, data_type, **kwargs): + """Serialize generic data according to supplied data type. + + :param data: The data to be serialized. + :param str data_type: The type to be serialized from. + :param bool required: Whether it's essential that the data not be + empty or None + :raises: AttributeError if required data is None. + :raises: ValueError if data is None + :raises: SerializationError if serialization fails. + """ + if data is None: + raise ValueError("No value for given attribute") + + try: + if data_type in self.basic_types.values(): + return self.serialize_basic(data, data_type, **kwargs) + + elif data_type in self.serialize_type: + return self.serialize_type[data_type](data, **kwargs) + + # If dependencies is empty, try with current data class + # It has to be a subclass of Enum anyway + enum_type = self.dependencies.get(data_type, data.__class__) + if issubclass(enum_type, Enum): + return Serializer.serialize_enum(data, enum_obj=enum_type) + + iter_type = data_type[0] + data_type[-1] + if iter_type in self.serialize_type: + return self.serialize_type[iter_type]( + data, data_type[1:-1], **kwargs) + + except (ValueError, TypeError) as err: + msg = "Unable to serialize value: {!r} as type: {!r}." + raise_with_traceback( + SerializationError, msg.format(data, data_type), err) + else: + return self._serialize(data, **kwargs) + + @classmethod + def _get_custom_serializers(cls, data_type, **kwargs): + custom_serializer = kwargs.get("basic_types_serializers", {}).get(data_type) + if custom_serializer: + return custom_serializer + if kwargs.get("is_xml", False): + return cls._xml_basic_types_serializers.get(data_type) + + @classmethod + def serialize_basic(cls, data, data_type, **kwargs): + """Serialize basic builting data type. + Serializes objects to str, int, float or bool. + + Possible kwargs: + - basic_types_serializers dict[str, callable] : If set, use the callable as serializer + - is_xml bool : If set, use xml_basic_types_serializers + + :param data: Object to be serialized. + :param str data_type: Type of object in the iterable. + """ + custom_serializer = cls._get_custom_serializers(data_type, **kwargs) + if custom_serializer: + return custom_serializer(data) + if data_type == 'str': + return cls.serialize_unicode(data) + return eval(data_type)(data) # nosec + + @classmethod + def serialize_unicode(cls, data): + """Special handling for serializing unicode strings in Py2. + Encode to UTF-8 if unicode, otherwise handle as a str. + + :param data: Object to be serialized. + :rtype: str + """ + try: # If I received an enum, return its value + return data.value + except AttributeError: + pass + + try: + if isinstance(data, unicode): + # Don't change it, JSON and XML ElementTree are totally able + # to serialize correctly u'' strings + return data + except NameError: + return str(data) + else: + return str(data) + + def serialize_iter(self, data, iter_type, div=None, **kwargs): + """Serialize iterable. + + Supported kwargs: + - serialization_ctxt dict : The current entry of _attribute_map, or same format. + serialization_ctxt['type'] should be same as data_type. + - is_xml bool : If set, serialize as XML + + :param list attr: Object to be serialized. + :param str iter_type: Type of object in the iterable. + :param bool required: Whether the objects in the iterable must + not be None or empty. + :param str div: If set, this str will be used to combine the elements + in the iterable into a combined string. Default is 'None'. + :rtype: list, str + """ + if isinstance(data, str): + raise SerializationError("Refuse str type as a valid iter type.") + + serialization_ctxt = kwargs.get("serialization_ctxt", {}) + is_xml = kwargs.get("is_xml", False) + + serialized = [] + for d in data: + try: + serialized.append(self.serialize_data(d, iter_type, **kwargs)) + except ValueError: + serialized.append(None) + + if div: + serialized = ['' if s is None else str(s) for s in serialized] + serialized = div.join(serialized) + + if 'xml' in serialization_ctxt or is_xml: + # XML serialization is more complicated + xml_desc = serialization_ctxt.get('xml', {}) + xml_name = xml_desc.get('name') + if not xml_name: + xml_name = serialization_ctxt['key'] + + # Create a wrap node if necessary (use the fact that Element and list have "append") + is_wrapped = xml_desc.get("wrapped", False) + node_name = xml_desc.get("itemsName", xml_name) + if is_wrapped: + final_result = _create_xml_node( + xml_name, + xml_desc.get('prefix', None), + xml_desc.get('ns', None) + ) + else: + final_result = [] + # All list elements to "local_node" + for el in serialized: + if isinstance(el, ET.Element): + el_node = el + else: + el_node = _create_xml_node( + node_name, + xml_desc.get('prefix', None), + xml_desc.get('ns', None) + ) + if el is not None: # Otherwise it writes "None" :-p + el_node.text = str(el) + final_result.append(el_node) + return final_result + return serialized + + def serialize_dict(self, attr, dict_type, **kwargs): + """Serialize a dictionary of objects. + + :param dict attr: Object to be serialized. + :param str dict_type: Type of object in the dictionary. + :param bool required: Whether the objects in the dictionary must + not be None or empty. + :rtype: dict + """ + serialization_ctxt = kwargs.get("serialization_ctxt", {}) + serialized = {} + for key, value in attr.items(): + try: + serialized[self.serialize_unicode(key)] = self.serialize_data( + value, dict_type, **kwargs) + except ValueError: + serialized[self.serialize_unicode(key)] = None + + if 'xml' in serialization_ctxt: + # XML serialization is more complicated + xml_desc = serialization_ctxt['xml'] + xml_name = xml_desc['name'] + + final_result = _create_xml_node( + xml_name, + xml_desc.get('prefix', None), + xml_desc.get('ns', None) + ) + for key, value in serialized.items(): + ET.SubElement(final_result, key).text = value + return final_result + + return serialized + + def serialize_object(self, attr, **kwargs): + """Serialize a generic object. + This will be handled as a dictionary. If object passed in is not + a basic type (str, int, float, dict, list) it will simply be + cast to str. + + :param dict attr: Object to be serialized. + :rtype: dict or str + """ + if attr is None: + return None + if isinstance(attr, ET.Element): + return attr + obj_type = type(attr) + if obj_type in self.basic_types: + return self.serialize_basic(attr, self.basic_types[obj_type], **kwargs) + if obj_type is _long_type: + return self.serialize_long(attr) + if obj_type is unicode_str: + return self.serialize_unicode(attr) + if obj_type is datetime.datetime: + return self.serialize_iso(attr) + if obj_type is datetime.date: + return self.serialize_date(attr) + if obj_type is datetime.time: + return self.serialize_time(attr) + if obj_type is datetime.timedelta: + return self.serialize_duration(attr) + if obj_type is decimal.Decimal: + return self.serialize_decimal(attr) + + # If it's a model or I know this dependency, serialize as a Model + elif obj_type in self.dependencies.values() or isinstance(attr, Model): + return self._serialize(attr) + + if obj_type == dict: + serialized = {} + for key, value in attr.items(): + try: + serialized[self.serialize_unicode(key)] = self.serialize_object( + value, **kwargs) + except ValueError: + serialized[self.serialize_unicode(key)] = None + return serialized + + if obj_type == list: + serialized = [] + for obj in attr: + try: + serialized.append(self.serialize_object( + obj, **kwargs)) + except ValueError: + pass + return serialized + return str(attr) + + @staticmethod + def serialize_enum(attr, enum_obj=None): + try: + result = attr.value + except AttributeError: + result = attr + try: + enum_obj(result) + return result + except ValueError: + for enum_value in enum_obj: + if enum_value.value.lower() == str(attr).lower(): + return enum_value.value + error = "{!r} is not valid value for enum {!r}" + raise SerializationError(error.format(attr, enum_obj)) + + @staticmethod + def serialize_bytearray(attr, **kwargs): + """Serialize bytearray into base-64 string. + + :param attr: Object to be serialized. + :rtype: str + """ + return b64encode(attr).decode() + + @staticmethod + def serialize_base64(attr, **kwargs): + """Serialize str into base-64 string. + + :param attr: Object to be serialized. + :rtype: str + """ + encoded = b64encode(attr).decode('ascii') + return encoded.strip('=').replace('+', '-').replace('/', '_') + + @staticmethod + def serialize_decimal(attr, **kwargs): + """Serialize Decimal object to float. + + :param attr: Object to be serialized. + :rtype: float + """ + return float(attr) + + @staticmethod + def serialize_long(attr, **kwargs): + """Serialize long (Py2) or int (Py3). + + :param attr: Object to be serialized. + :rtype: int/long + """ + return _long_type(attr) + + @staticmethod + def serialize_date(attr, **kwargs): + """Serialize Date object into ISO-8601 formatted string. + + :param Date attr: Object to be serialized. + :rtype: str + """ + if isinstance(attr, str): + attr = isodate.parse_date(attr) + t = "{:04}-{:02}-{:02}".format(attr.year, attr.month, attr.day) + return t + + @staticmethod + def serialize_time(attr, **kwargs): + """Serialize Time object into ISO-8601 formatted string. + + :param datetime.time attr: Object to be serialized. + :rtype: str + """ + if isinstance(attr, str): + attr = isodate.parse_time(attr) + t = "{:02}:{:02}:{:02}".format(attr.hour, attr.minute, attr.second) + if attr.microsecond: + t += ".{:02}".format(attr.microsecond) + return t + + @staticmethod + def serialize_duration(attr, **kwargs): + """Serialize TimeDelta object into ISO-8601 formatted string. + + :param TimeDelta attr: Object to be serialized. + :rtype: str + """ + if isinstance(attr, str): + attr = isodate.parse_duration(attr) + return isodate.duration_isoformat(attr) + + @staticmethod + def serialize_rfc(attr, **kwargs): + """Serialize Datetime object into RFC-1123 formatted string. + + :param Datetime attr: Object to be serialized. + :rtype: str + :raises: TypeError if format invalid. + """ + try: + if not attr.tzinfo: + _LOGGER.warning( + "Datetime with no tzinfo will be considered UTC.") + utc = attr.utctimetuple() + except AttributeError: + raise TypeError("RFC1123 object must be valid Datetime object.") + + return "{}, {:02} {} {:04} {:02}:{:02}:{:02} GMT".format( + Serializer.days[utc.tm_wday], utc.tm_mday, + Serializer.months[utc.tm_mon], utc.tm_year, + utc.tm_hour, utc.tm_min, utc.tm_sec) + + @staticmethod + def serialize_iso(attr, **kwargs): + """Serialize Datetime object into ISO-8601 formatted string. + + :param Datetime attr: Object to be serialized. + :rtype: str + :raises: SerializationError if format invalid. + """ + if isinstance(attr, str): + attr = isodate.parse_datetime(attr) + try: + if not attr.tzinfo: + _LOGGER.warning( + "Datetime with no tzinfo will be considered UTC.") + utc = attr.utctimetuple() + if utc.tm_year > 9999 or utc.tm_year < 1: + raise OverflowError("Hit max or min date") + + microseconds = str(attr.microsecond).rjust(6,'0').rstrip('0').ljust(3, '0') + if microseconds: + microseconds = '.'+microseconds + date = "{:04}-{:02}-{:02}T{:02}:{:02}:{:02}".format( + utc.tm_year, utc.tm_mon, utc.tm_mday, + utc.tm_hour, utc.tm_min, utc.tm_sec) + return date + microseconds + 'Z' + except (ValueError, OverflowError) as err: + msg = "Unable to serialize datetime object." + raise_with_traceback(SerializationError, msg, err) + except AttributeError as err: + msg = "ISO-8601 object must be valid Datetime object." + raise_with_traceback(TypeError, msg, err) + + @staticmethod + def serialize_unix(attr, **kwargs): + """Serialize Datetime object into IntTime format. + This is represented as seconds. + + :param Datetime attr: Object to be serialized. + :rtype: int + :raises: SerializationError if format invalid + """ + if isinstance(attr, int): + return attr + try: + if not attr.tzinfo: + _LOGGER.warning( + "Datetime with no tzinfo will be considered UTC.") + return int(calendar.timegm(attr.utctimetuple())) + except AttributeError: + raise TypeError("Unix time object must be valid Datetime object.") + +def rest_key_extractor(attr, attr_desc, data): + key = attr_desc['key'] + working_data = data + + while '.' in key: + dict_keys = _FLATTEN.split(key) + if len(dict_keys) == 1: + key = _decode_attribute_map_key(dict_keys[0]) + break + working_key = _decode_attribute_map_key(dict_keys[0]) + working_data = working_data.get(working_key, data) + if working_data is None: + # If at any point while following flatten JSON path see None, it means + # that all properties under are None as well + # https://github.com/Azure/msrest-for-python/issues/197 + return None + key = '.'.join(dict_keys[1:]) + + return working_data.get(key) + +def rest_key_case_insensitive_extractor(attr, attr_desc, data): + key = attr_desc['key'] + working_data = data + + while '.' in key: + dict_keys = _FLATTEN.split(key) + if len(dict_keys) == 1: + key = _decode_attribute_map_key(dict_keys[0]) + break + working_key = _decode_attribute_map_key(dict_keys[0]) + working_data = attribute_key_case_insensitive_extractor(working_key, None, working_data) + if working_data is None: + # If at any point while following flatten JSON path see None, it means + # that all properties under are None as well + # https://github.com/Azure/msrest-for-python/issues/197 + return None + key = '.'.join(dict_keys[1:]) + + if working_data: + return attribute_key_case_insensitive_extractor(key, None, working_data) + +def last_rest_key_extractor(attr, attr_desc, data): + """Extract the attribute in "data" based on the last part of the JSON path key. + """ + key = attr_desc['key'] + dict_keys = _FLATTEN.split(key) + return attribute_key_extractor(dict_keys[-1], None, data) + +def last_rest_key_case_insensitive_extractor(attr, attr_desc, data): + """Extract the attribute in "data" based on the last part of the JSON path key. + + This is the case insensitive version of "last_rest_key_extractor" + """ + key = attr_desc['key'] + dict_keys = _FLATTEN.split(key) + return attribute_key_case_insensitive_extractor(dict_keys[-1], None, data) + +def attribute_key_extractor(attr, _, data): + return data.get(attr) + +def attribute_key_case_insensitive_extractor(attr, _, data): + found_key = None + lower_attr = attr.lower() + for key in data: + if lower_attr == key.lower(): + found_key = key + break + + return data.get(found_key) + +def _extract_name_from_internal_type(internal_type): + """Given an internal type XML description, extract correct XML name with namespace. + + :param dict internal_type: An model type + :rtype: tuple + :returns: A tuple XML name + namespace dict + """ + internal_type_xml_map = getattr(internal_type, "_xml_map", {}) + 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) + return xml_name + + +def xml_key_extractor(attr, attr_desc, data): + if isinstance(data, dict): + return None + + # Test if this model is XML ready first + if not isinstance(data, ET.Element): + return None + + xml_desc = attr_desc.get('xml', {}) + xml_name = xml_desc.get('name', attr_desc['key']) + + # Look for a children + is_iter_type = attr_desc['type'].startswith("[") + is_wrapped = xml_desc.get("wrapped", False) + internal_type = attr_desc.get("internalType", None) + internal_type_xml_map = getattr(internal_type, "_xml_map", {}) + + # 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) + + # If it's an attribute, that's simple + if xml_desc.get("attr", False): + return data.get(xml_name) + + # If it's x-ms-text, that's simple too + if xml_desc.get("text", False): + return data.text + + # Scenario where I take the local name: + # - Wrapped node + # - Internal type is an enum (considered basic types) + # - Internal type has no XML/Name node + if is_wrapped or (internal_type and (issubclass(internal_type, Enum) or 'name' not in internal_type_xml_map)): + children = data.findall(xml_name) + # If internal type has a local name and it's not a list, I use that name + elif not is_iter_type and internal_type and 'name' in internal_type_xml_map: + xml_name = _extract_name_from_internal_type(internal_type) + children = data.findall(xml_name) + # That's an array + else: + if internal_type: # Complex type, ignore itemsName and use the complex type name + items_name = _extract_name_from_internal_type(internal_type) + else: + items_name = xml_desc.get("itemsName", xml_name) + children = data.findall(items_name) + + if len(children) == 0: + if is_iter_type: + if is_wrapped: + return None # is_wrapped no node, we want None + else: + return [] # not wrapped, assume empty list + return None # Assume it's not there, maybe an optional node. + + # If is_iter_type and not wrapped, return all found children + if is_iter_type: + if not is_wrapped: + return children + else: # Iter and wrapped, should have found one node only (the wrap one) + if len(children) != 1: + raise DeserializationError( + "Tried to deserialize an array not wrapped, and found several nodes '{}'. Maybe you should declare this array as wrapped?".format( + xml_name + )) + return list(children[0]) # Might be empty list and that's ok. + + # Here it's not a itertype, we should have found one element only or empty + if len(children) > 1: + raise DeserializationError("Find several XML '{}' where it was not expected".format(xml_name)) + return children[0] + +class Deserializer(object): + """Response object model deserializer. + + :param dict classes: Class type dictionary for deserializing complex types. + :ivar list key_extractors: Ordered list of extractors to be used by this deserializer. + """ + + basic_types = {str: 'str', int: 'int', bool: 'bool', float: 'float'} + + valid_date = re.compile( + r'\d{4}[-]\d{2}[-]\d{2}T\d{2}:\d{2}:\d{2}' + r'\.?\d*Z?[-+]?[\d{2}]?:?[\d{2}]?') + + def __init__(self, classes=None): + self.deserialize_type = { + 'iso-8601': Deserializer.deserialize_iso, + 'rfc-1123': Deserializer.deserialize_rfc, + 'unix-time': Deserializer.deserialize_unix, + 'duration': Deserializer.deserialize_duration, + 'date': Deserializer.deserialize_date, + 'time': Deserializer.deserialize_time, + 'decimal': Deserializer.deserialize_decimal, + 'long': Deserializer.deserialize_long, + 'bytearray': Deserializer.deserialize_bytearray, + 'base64': Deserializer.deserialize_base64, + 'object': self.deserialize_object, + '[]': self.deserialize_iter, + '{}': self.deserialize_dict + } + self.deserialize_expected_types = { + 'duration': (isodate.Duration, datetime.timedelta), + 'iso-8601': (datetime.datetime) + } + self.dependencies = 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 + # complicated, with no real scenario for now. + # So adding a flag to disable additional properties detection. This flag should be + # used if your expect the deserialization to NOT come from a JSON REST syntax. + # Otherwise, result are unexpected + self.additional_properties_detection = True + + def __call__(self, target_obj, response_data, content_type=None): + """Call the deserializer to process a REST response. + + :param str target_obj: Target data type to deserialize to. + :param requests.Response response_data: REST response object. + :param str content_type: Swagger "produces" if available. + :raises: DeserializationError if deserialization fails. + :return: Deserialized object. + """ + data = self._unpack_content(response_data, content_type) + return self._deserialize(target_obj, data) + + def _deserialize(self, target_obj, data): + """Call the deserializer on a model. + + Data needs to be already deserialized as JSON or XML ElementTree + + :param str target_obj: Target data type to deserialize to. + :param object data: Object to deserialize. + :raises: DeserializationError if deserialization fails. + :return: Deserialized object. + """ + # This is already a model, go recursive just in case + if hasattr(data, "_attribute_map"): + constants = [name for name, config in getattr(data, '_validation', {}).items() + if config.get('constant')] + try: + for attr, mapconfig in data._attribute_map.items(): + if attr in constants: + continue + value = getattr(data, attr) + if value is None: + continue + local_type = mapconfig['type'] + internal_data_type = local_type.strip('[]{}') + if internal_data_type not in self.dependencies or isinstance(internal_data_type, Enum): + continue + setattr( + data, + attr, + self._deserialize(local_type, value) + ) + return data + except AttributeError: + return + + response, class_name = self._classify_target(target_obj, data) + + if isinstance(response, basestring): + return self.deserialize_data(data, response) + elif isinstance(response, type) and issubclass(response, Enum): + return self.deserialize_enum(data, response) + + if data is None: + return data + try: + attributes = response._attribute_map + d_attrs = {} + for attr, attr_desc in attributes.items(): + # Check empty string. If it's not empty, someone has a real "additionalProperties"... + if attr == "additional_properties" and attr_desc["key"] == '': + continue + raw_value = None + # Enhance attr_desc with some dynamic data + attr_desc = attr_desc.copy() # Do a copy, do not change the real one + internal_data_type = attr_desc["type"].strip('[]{}') + if internal_data_type in self.dependencies: + attr_desc["internalType"] = self.dependencies[internal_data_type] + + for key_extractor in self.key_extractors: + found_value = key_extractor(attr, attr_desc, data) + if found_value is not None: + if raw_value is not None and raw_value != found_value: + msg = ("Ignoring extracted value '%s' from %s for key '%s'" + " (duplicate extraction, follow extractors order)" ) + _LOGGER.warning( + msg, + found_value, + key_extractor, + attr + ) + continue + raw_value = found_value + + 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 + raise_with_traceback(DeserializationError, msg, err) + else: + additional_properties = self._build_additional_properties(attributes, data) + return self._instantiate_model(response, d_attrs, additional_properties) + + def _build_additional_properties(self, attribute_map, data): + if not self.additional_properties_detection: + return None + if "additional_properties" in attribute_map and attribute_map.get("additional_properties", {}).get("key") != '': + # Check empty string. If it's not empty, someone has a real "additionalProperties" + return None + if isinstance(data, ET.Element): + data = {el.tag: el.text for el in data} + + known_keys = {_decode_attribute_map_key(_FLATTEN.split(desc['key'])[0]) + for desc in attribute_map.values() if desc['key'] != ''} + present_keys = set(data.keys()) + missing_keys = present_keys - known_keys + return {key: data[key] for key in missing_keys} + + def _classify_target(self, target, data): + """Check to see whether the deserialization target object can + be classified into a subclass. + 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. + """ + if target is None: + return None, None + + if isinstance(target, basestring): + try: + target = self.dependencies[target] + except KeyError: + return target, target + + try: + target = target._classify(data, self.dependencies) + except AttributeError: + pass # Target is not a Model, no classify + return target, target.__class__.__name__ + + def failsafe_deserialize(self, target_obj, data, content_type=None): + """Ignores any errors encountered in deserialization, + and falls back to not deserializing the object. Recommended + for use in error deserialization, as we want to return the + HttpResponseError to users, and not have them deal with + 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 content_type: Swagger "produces" if available. + """ + try: + return self(target_obj, data, content_type=content_type) + except: + _LOGGER.debug( + "Ran into a deserialization error. Ignoring since this is failsafe deserialization", + exc_info=True + ) + return None + + @staticmethod + def _unpack_content(raw_data, content_type=None): + """Extract the correct structure for deserialization. + + If raw_data is a PipelineResponse, try to extract the result of RawDeserializer. + if we can't, raise. Your Pipeline should have a RawDeserializer. + + If not a pipeline response and raw_data is bytes or string, use content-type + to decode it. If no content-type, try JSON. + + If raw_data is something else, bypass all logic and return it directly. + + :param raw_data: Data to be processed. + :param content_type: How to parse if raw_data is a string/bytes. + :raises JSONDecodeError: If JSON is requested and parsing is impossible. + :raises UnicodeDecodeError: If bytes is not UTF8 + """ + # Assume this is enough to detect a Pipeline Response without importing it + context = getattr(raw_data, "context", {}) + if context: + if RawDeserializer.CONTEXT_NAME in context: + return context[RawDeserializer.CONTEXT_NAME] + raise ValueError("This pipeline didn't have the RawDeserializer policy; can't deserialize") + + #Assume this is enough to recognize universal_http.ClientResponse without importing it + if hasattr(raw_data, "body"): + return RawDeserializer.deserialize_from_http_generics( + raw_data.text(), + raw_data.headers + ) + + # Assume this enough to recognize requests.Response without importing it. + if hasattr(raw_data, '_content_consumed'): + 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 raw_data + + def _instantiate_model(self, response, attrs, additional_properties=None): + """Instantiate a response model passing in deserialized args. + + :param response: The response model class. + :param d_attrs: The deserialized response attributes. + """ + if callable(response): + subtype = getattr(response, '_subtype_map', {}) + try: + readonly = [k for k, v in response._validation.items() + if v.get('readonly')] + const = [k for k, v in response._validation.items() + if v.get('constant')] + kwargs = {k: v for k, v in attrs.items() + if k not in subtype and k not in readonly + const} + response_obj = response(**kwargs) + for attr in readonly: + setattr(response_obj, attr, attrs.get(attr)) + if additional_properties: + response_obj.additional_properties = additional_properties + return response_obj + except TypeError as err: + msg = "Unable to deserialize {} into model {}. ".format( + kwargs, response) + raise DeserializationError(msg + str(err)) + else: + try: + for attr, value in attrs.items(): + setattr(response, attr, value) + return response + except Exception as exp: + msg = "Unable to populate response model. " + msg += "Type: {}, Error: {}".format(type(response), exp) + raise DeserializationError(msg) + + def deserialize_data(self, data, data_type): + """Process data for deserialization according to data type. + + :param str data: The response string to be deserialized. + :param str data_type: The type to deserialize to. + :raises: DeserializationError if deserialization fails. + :return: Deserialized object. + """ + if data is None: + return data + + try: + if not data_type: + return data + if data_type in self.basic_types.values(): + return self.deserialize_basic(data, data_type) + if data_type in self.deserialize_type: + if isinstance(data, self.deserialize_expected_types.get(data_type, tuple())): + return data + + is_a_text_parsing_type = lambda x: x not in ["object", "[]", r"{}"] + if isinstance(data, ET.Element) and is_a_text_parsing_type(data_type) and not data.text: + return None + data_val = self.deserialize_type[data_type](data) + return data_val + + iter_type = data_type[0] + data_type[-1] + if iter_type in self.deserialize_type: + return self.deserialize_type[iter_type](data, data_type[1:-1]) + + obj_type = self.dependencies[data_type] + if issubclass(obj_type, Enum): + if isinstance(data, ET.Element): + data = data.text + return self.deserialize_enum(data, obj_type) + + except (ValueError, TypeError, AttributeError) as err: + msg = "Unable to deserialize response data." + msg += " Data: {}, {}".format(data, data_type) + raise_with_traceback(DeserializationError, msg, err) + else: + return self._deserialize(obj_type, data) + + def deserialize_iter(self, attr, iter_type): + """Deserialize an iterable. + + :param list attr: Iterable to be deserialized. + :param str iter_type: The type of object in the iterable. + :rtype: list + """ + if attr is None: + return None + if isinstance(attr, ET.Element): # If I receive an element here, get the children + attr = list(attr) + if not isinstance(attr, (list, set)): + raise DeserializationError("Cannot deserialize as [{}] an object of type {}".format( + iter_type, + type(attr) + )) + return [self.deserialize_data(a, iter_type) for a in attr] + + def deserialize_dict(self, attr, dict_type): + """Deserialize a dictionary. + + :param dict/list attr: Dictionary to be deserialized. Also accepts + a list of key, value pairs. + :param str dict_type: The object type of the items in the dictionary. + :rtype: dict + """ + if isinstance(attr, list): + return {x['key']: self.deserialize_data(x['value'], dict_type) for x in attr} + + if isinstance(attr, ET.Element): + # Transform value into {"Key": "value"} + attr = {el.tag: el.text for el in attr} + return {k: self.deserialize_data(v, dict_type) for k, v in attr.items()} + + def deserialize_object(self, attr, **kwargs): + """Deserialize a generic object. + This will be handled as a dictionary. + + :param dict attr: Dictionary to be deserialized. + :rtype: dict + :raises: TypeError if non-builtin datatype encountered. + """ + if attr is None: + return None + if isinstance(attr, ET.Element): + # Do no recurse on XML, just return the tree as-is + return attr + if isinstance(attr, basestring): + return self.deserialize_basic(attr, 'str') + obj_type = type(attr) + if obj_type in self.basic_types: + return self.deserialize_basic(attr, self.basic_types[obj_type]) + if obj_type is _long_type: + return self.deserialize_long(attr) + + if obj_type == dict: + deserialized = {} + for key, value in attr.items(): + try: + deserialized[key] = self.deserialize_object( + value, **kwargs) + except ValueError: + deserialized[key] = None + return deserialized + + if obj_type == list: + deserialized = [] + for obj in attr: + try: + deserialized.append(self.deserialize_object( + obj, **kwargs)) + except ValueError: + pass + return deserialized + + else: + error = "Cannot deserialize generic object with type: " + raise TypeError(error + str(obj_type)) + + def deserialize_basic(self, attr, data_type): + """Deserialize basic builtin data type from string. + Will attempt to convert to str, int, float and bool. + This function will also accept '1', '0', 'true' and 'false' as + valid bool values. + + :param str attr: response string to be deserialized. + :param str data_type: deserialization data type. + :rtype: str, int, float or bool + :raises: TypeError if string format is not valid. + """ + # If we're here, data is supposed to be a basic type. + # If it's still an XML node, take the text + if isinstance(attr, ET.Element): + attr = attr.text + if not attr: + if data_type == "str": + # None or '', node is empty string. + return '' + else: + # None or '', node with a strong type is None. + # Don't try to model "empty bool" or "empty int" + return None + + if data_type == 'bool': + if attr in [True, False, 1, 0]: + return bool(attr) + elif isinstance(attr, basestring): + if attr.lower() in ['true', '1']: + return True + elif attr.lower() in ['false', '0']: + return False + raise TypeError("Invalid boolean value: {}".format(attr)) + + if data_type == 'str': + return self.deserialize_unicode(attr) + return eval(data_type)(attr) # nosec + + @staticmethod + def deserialize_unicode(data): + """Preserve unicode objects in Python 2, otherwise return data + as a string. + + :param str data: response string to be deserialized. + :rtype: str or unicode + """ + # We might be here because we have an enum modeled as string, + # and we try to deserialize a partial dict with enum inside + if isinstance(data, Enum): + return data + + # Consider this is real string + try: + if isinstance(data, unicode): + return data + except NameError: + return str(data) + else: + return str(data) + + @staticmethod + def deserialize_enum(data, enum_obj): + """Deserialize string into enum object. + + If the string is not a valid enum value it will be returned as-is + and a warning will be logged. + + :param str data: Response string to be deserialized. If this value is + None or invalid it will be returned as-is. + :param Enum enum_obj: Enum object to deserialize to. + :rtype: Enum + """ + if isinstance(data, enum_obj) or data is None: + return data + if isinstance(data, Enum): + data = data.value + if isinstance(data, int): + # Workaround. We might consider remove it in the future. + # https://github.com/Azure/azure-rest-api-specs/issues/141 + try: + return list(enum_obj.__members__.values())[data] + except IndexError: + error = "{!r} is not a valid index for enum {!r}" + raise DeserializationError(error.format(data, enum_obj)) + try: + return enum_obj(str(data)) + except ValueError: + for enum_value in enum_obj: + if enum_value.value.lower() == str(data).lower(): + return enum_value + # We don't fail anymore for unknown value, we deserialize as a string + _LOGGER.warning("Deserializer is not able to find %s as valid enum in %s", data, enum_obj) + return Deserializer.deserialize_unicode(data) + + @staticmethod + def deserialize_bytearray(attr): + """Deserialize string into bytearray. + + :param str attr: response string to be deserialized. + :rtype: bytearray + :raises: TypeError if string format invalid. + """ + if isinstance(attr, ET.Element): + attr = attr.text + return bytearray(b64decode(attr)) + + @staticmethod + def deserialize_base64(attr): + """Deserialize base64 encoded string into string. + + :param str attr: response string to be deserialized. + :rtype: bytearray + :raises: TypeError if string format invalid. + """ + if isinstance(attr, ET.Element): + attr = attr.text + padding = '=' * (3 - (len(attr) + 3) % 4) + attr = attr + padding + encoded = attr.replace('-', '+').replace('_', '/') + return b64decode(encoded) + + @staticmethod + def deserialize_decimal(attr): + """Deserialize string into Decimal object. + + :param str attr: response string to be deserialized. + :rtype: Decimal + :raises: DeserializationError if string format invalid. + """ + if isinstance(attr, ET.Element): + attr = attr.text + try: + return decimal.Decimal(attr) + except decimal.DecimalException as err: + msg = "Invalid decimal {}".format(attr) + raise_with_traceback(DeserializationError, msg, err) + + @staticmethod + def deserialize_long(attr): + """Deserialize string into long (Py2) or int (Py3). + + :param str attr: response string to be deserialized. + :rtype: long or int + :raises: ValueError if string format invalid. + """ + if isinstance(attr, ET.Element): + attr = attr.text + return _long_type(attr) + + @staticmethod + def deserialize_duration(attr): + """Deserialize ISO-8601 formatted string into TimeDelta object. + + :param str attr: response string to be deserialized. + :rtype: TimeDelta + :raises: DeserializationError if string format invalid. + """ + if isinstance(attr, ET.Element): + attr = attr.text + try: + duration = isodate.parse_duration(attr) + except(ValueError, OverflowError, AttributeError) as err: + msg = "Cannot deserialize duration object." + raise_with_traceback(DeserializationError, msg, err) + else: + return duration + + @staticmethod + def deserialize_date(attr): + """Deserialize ISO-8601 formatted string into Date object. + + :param str attr: response string to be deserialized. + :rtype: Date + :raises: DeserializationError if string format invalid. + """ + if isinstance(attr, ET.Element): + attr = attr.text + if re.search(r"[^\W\d_]", attr, re.I + re.U): + 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) + + @staticmethod + def deserialize_time(attr): + """Deserialize ISO-8601 formatted string into time object. + + :param str attr: response string to be deserialized. + :rtype: datetime.time + :raises: DeserializationError if string format invalid. + """ + if isinstance(attr, ET.Element): + attr = attr.text + if re.search(r"[^\W\d_]", attr, re.I + re.U): + raise DeserializationError("Date must have only digits and -. Received: %s" % attr) + return isodate.parse_time(attr) + + @staticmethod + def deserialize_rfc(attr): + """Deserialize RFC-1123 formatted string into Datetime object. + + :param str attr: response string to be deserialized. + :rtype: Datetime + :raises: DeserializationError if string format invalid. + """ + if isinstance(attr, ET.Element): + attr = attr.text + try: + parsed_date = email.utils.parsedate_tz(attr) + date_obj = datetime.datetime( + *parsed_date[:6], + tzinfo=_FixedOffset(datetime.timedelta(minutes=(parsed_date[9] or 0)/60)) + ) + if not date_obj.tzinfo: + date_obj = date_obj.astimezone(tz=TZ_UTC) + except ValueError as err: + msg = "Cannot deserialize to rfc datetime object." + raise_with_traceback(DeserializationError, msg, err) + else: + return date_obj + + @staticmethod + def deserialize_iso(attr): + """Deserialize ISO-8601 formatted string into Datetime object. + + :param str attr: response string to be deserialized. + :rtype: Datetime + :raises: DeserializationError if string format invalid. + """ + if isinstance(attr, ET.Element): + attr = attr.text + try: + attr = attr.upper() + match = Deserializer.valid_date.match(attr) + if not match: + raise ValueError("Invalid datetime string: " + attr) + + check_decimal = attr.split('.') + if len(check_decimal) > 1: + decimal_str = "" + for digit in check_decimal[1]: + if digit.isdigit(): + decimal_str += digit + else: + break + if len(decimal_str) > 6: + attr = attr.replace(decimal_str, decimal_str[0:6]) + + date_obj = isodate.parse_datetime(attr) + test_utc = date_obj.utctimetuple() + if test_utc.tm_year > 9999 or test_utc.tm_year < 1: + raise OverflowError("Hit max or min date") + except(ValueError, OverflowError, AttributeError) as err: + msg = "Cannot deserialize datetime object." + raise_with_traceback(DeserializationError, msg, err) + else: + return date_obj + + @staticmethod + def deserialize_unix(attr): + """Serialize Datetime object into IntTime format. + This is represented as seconds. + + :param int attr: Object to be serialized. + :rtype: Datetime + :raises: DeserializationError if format invalid + """ + if isinstance(attr, ET.Element): + attr = int(attr.text) + try: + date_obj = datetime.datetime.fromtimestamp(attr, TZ_UTC) + except ValueError as err: + msg = "Cannot deserialize to unix datetime object." + raise_with_traceback(DeserializationError, msg, err) + else: + return date_obj diff --git a/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/features/aio/_configuration.py b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/features/aio/_configuration.py index c5904ebd7c9a6..6058e43679000 100644 --- a/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/features/aio/_configuration.py +++ b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/features/aio/_configuration.py @@ -26,9 +26,9 @@ class FeatureClientConfiguration(Configuration): Note that all parameters used to create this instance are saved as instance attributes. - :param credential: Credential needed for the client to connect to Azure. + :param credential: Credential needed for the client to connect to Azure. Required. :type credential: ~azure.core.credentials_async.AsyncTokenCredential - :param subscription_id: The Azure subscription ID. + :param subscription_id: The Azure subscription ID. Required. :type subscription_id: str """ diff --git a/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/features/aio/_feature_client.py b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/features/aio/_feature_client.py index 465d5c6277dd0..ea25d1a5eb64a 100644 --- a/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/features/aio/_feature_client.py +++ b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/features/aio/_feature_client.py @@ -11,18 +11,16 @@ from typing import Any, Optional, TYPE_CHECKING -from msrest import Deserializer, Serializer - from azure.mgmt.core import AsyncARMPipelineClient from azure.profiles import KnownProfiles, ProfileDefinition from azure.profiles.multiapiclient import MultiApiClientMixin +from .._serialization import Deserializer, Serializer from ._configuration import FeatureClientConfiguration from ._operations_mixin import FeatureClientOperationsMixin if TYPE_CHECKING: # pylint: disable=unused-import,ungrouped-imports - from azure.core.credentials import TokenCredential from azure.core.credentials_async import AsyncTokenCredential class _SDKClient(object): @@ -43,9 +41,9 @@ class FeatureClient(FeatureClientOperationsMixin, MultiApiClientMixin, _SDKClien The api-version parameter sets the default API version if the operation group is not described in the profile. - :param credential: Credential needed for the client to connect to Azure. + :param credential: Credential needed for the client to connect to Azure. Required. :type credential: ~azure.core.credentials_async.AsyncTokenCredential - :param subscription_id: The Azure subscription ID. + :param subscription_id: The Azure subscription ID. Required. :type subscription_id: str :param api_version: API version to use if no profile is provided, or if missing in profile. :type api_version: str diff --git a/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/features/aio/_operations_mixin.py b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/features/aio/_operations_mixin.py index 8aff8a1d29bf9..da2fded858878 100644 --- a/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/features/aio/_operations_mixin.py +++ b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/features/aio/_operations_mixin.py @@ -8,25 +8,27 @@ # Changes may cause incorrect behavior and will be lost if the code is # regenerated. # -------------------------------------------------------------------------- -from msrest import Serializer, Deserializer +from .._serialization import Serializer, Deserializer from typing import Any, AsyncIterable from azure.core.async_paging import AsyncItemPaged +from .. import models as _models + class FeatureClientOperationsMixin(object): def list_operations( self, **kwargs: Any - ) -> AsyncIterable["_models.OperationListResult"]: + ) -> AsyncIterable["_models.Operation"]: """Lists all of the available Microsoft.Features REST API operations. :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either OperationListResult or the result of cls(response) + :return: An iterator like instance of either Operation or the result of cls(response) :rtype: - ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.resource.features.v2021_07_01.models.OperationListResult] - :raises: ~azure.core.exceptions.HttpResponseError + ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.resource.features.v2021_07_01.models.Operation] + :raises ~azure.core.exceptions.HttpResponseError: """ api_version = self._get_api_version('list_operations') if api_version == '2015-12-01': diff --git a/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/features/v2015_12_01/__init__.py b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/features/v2015_12_01/__init__.py index ad53d4ac63340..babff32b0dc94 100644 --- a/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/features/v2015_12_01/__init__.py +++ b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/features/v2015_12_01/__init__.py @@ -10,9 +10,15 @@ from ._version import VERSION __version__ = VERSION -__all__ = ['FeatureClient'] -# `._patch.py` is used for handwritten extensions to the generated code -# Example: https://github.com/Azure/azure-sdk-for-python/blob/main/doc/dev/customize_code/how-to-patch-sdk-code.md -from ._patch import patch_sdk -patch_sdk() +try: + from ._patch import __all__ as _patch_all + from ._patch import * # type: ignore # pylint: disable=unused-wildcard-import +except ImportError: + _patch_all = [] +from ._patch import patch_sdk as _patch_sdk + +__all__ = ["FeatureClient"] +__all__.extend([p for p in _patch_all if p not in __all__]) + +_patch_sdk() diff --git a/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/features/v2015_12_01/_configuration.py b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/features/v2015_12_01/_configuration.py index 84e58f63119d6..96f7958d0fc2c 100644 --- a/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/features/v2015_12_01/_configuration.py +++ b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/features/v2015_12_01/_configuration.py @@ -25,23 +25,18 @@ class FeatureClientConfiguration(Configuration): # pylint: disable=too-many-ins Note that all parameters used to create this instance are saved as instance attributes. - :param credential: Credential needed for the client to connect to Azure. + :param credential: Credential needed for the client to connect to Azure. Required. :type credential: ~azure.core.credentials.TokenCredential - :param subscription_id: The ID of the target subscription. + :param subscription_id: The ID of the target subscription. Required. :type subscription_id: str :keyword api_version: Api Version. Default value is "2015-12-01". Note that overriding this default value may result in unsupported behavior. :paramtype api_version: str """ - def __init__( - self, - credential: "TokenCredential", - subscription_id: str, - **kwargs: Any - ) -> None: + def __init__(self, credential: "TokenCredential", subscription_id: str, **kwargs: Any) -> None: super(FeatureClientConfiguration, self).__init__(**kwargs) - api_version = kwargs.pop('api_version', "2015-12-01") # type: str + api_version = kwargs.pop("api_version", "2015-12-01") # type: str if credential is None: raise ValueError("Parameter 'credential' must not be None.") @@ -51,23 +46,24 @@ def __init__( self.credential = credential self.subscription_id = subscription_id self.api_version = api_version - self.credential_scopes = kwargs.pop('credential_scopes', ['https://management.azure.com/.default']) - kwargs.setdefault('sdk_moniker', 'mgmt-resource/{}'.format(VERSION)) + self.credential_scopes = kwargs.pop("credential_scopes", ["https://management.azure.com/.default"]) + kwargs.setdefault("sdk_moniker", "mgmt-resource/{}".format(VERSION)) self._configure(**kwargs) def _configure( - self, - **kwargs # type: Any + self, **kwargs # type: Any ): # type: (...) -> 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) - self.logging_policy = kwargs.get('logging_policy') or policies.NetworkTraceLoggingPolicy(**kwargs) - self.http_logging_policy = kwargs.get('http_logging_policy') or ARMHttpLoggingPolicy(**kwargs) - self.retry_policy = kwargs.get('retry_policy') or policies.RetryPolicy(**kwargs) - self.custom_hook_policy = kwargs.get('custom_hook_policy') or policies.CustomHookPolicy(**kwargs) - self.redirect_policy = kwargs.get('redirect_policy') or policies.RedirectPolicy(**kwargs) - self.authentication_policy = kwargs.get('authentication_policy') + 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) + self.logging_policy = kwargs.get("logging_policy") or policies.NetworkTraceLoggingPolicy(**kwargs) + self.http_logging_policy = kwargs.get("http_logging_policy") or ARMHttpLoggingPolicy(**kwargs) + self.retry_policy = kwargs.get("retry_policy") or policies.RetryPolicy(**kwargs) + self.custom_hook_policy = kwargs.get("custom_hook_policy") or policies.CustomHookPolicy(**kwargs) + self.redirect_policy = kwargs.get("redirect_policy") or policies.RedirectPolicy(**kwargs) + self.authentication_policy = kwargs.get("authentication_policy") if self.credential and not self.authentication_policy: - self.authentication_policy = ARMChallengeAuthenticationPolicy(self.credential, *self.credential_scopes, **kwargs) + self.authentication_policy = ARMChallengeAuthenticationPolicy( + self.credential, *self.credential_scopes, **kwargs + ) diff --git a/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/features/v2015_12_01/_feature_client.py b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/features/v2015_12_01/_feature_client.py index 05f2976c9a4ad..df508b37e156d 100644 --- a/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/features/v2015_12_01/_feature_client.py +++ b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/features/v2015_12_01/_feature_client.py @@ -9,12 +9,11 @@ from copy import deepcopy from typing import Any, TYPE_CHECKING -from msrest import Deserializer, Serializer - from azure.core.rest import HttpRequest, HttpResponse from azure.mgmt.core import ARMPipelineClient from . import models +from .._serialization import Deserializer, Serializer from ._configuration import FeatureClientConfiguration from .operations import FeatureClientOperationsMixin, FeaturesOperations @@ -22,7 +21,8 @@ # pylint: disable=unused-import,ungrouped-imports from azure.core.credentials import TokenCredential -class FeatureClient(FeatureClientOperationsMixin): + +class FeatureClient(FeatureClientOperationsMixin): # pylint: disable=client-accepts-api-version-keyword """Azure Feature Exposure Control (AFEC) provides a mechanism for the resource providers to control feature exposure to users. Resource providers typically use this mechanism to provide public/private preview for new features prior to making them generally available. Users need to @@ -30,9 +30,9 @@ class FeatureClient(FeatureClientOperationsMixin): :ivar features: FeaturesOperations operations :vartype features: azure.mgmt.resource.features.v2015_12_01.operations.FeaturesOperations - :param credential: Credential needed for the client to connect to Azure. + :param credential: Credential needed for the client to connect to Azure. Required. :type credential: ~azure.core.credentials.TokenCredential - :param subscription_id: The ID of the target subscription. + :param subscription_id: The ID of the target subscription. Required. :type subscription_id: str :param base_url: Service URL. Default value is "https://management.azure.com". :type base_url: str @@ -57,12 +57,7 @@ def __init__( self._serialize.client_side_validation = False self.features = FeaturesOperations(self._client, self._config, self._serialize, self._deserialize) - - def _send_request( - self, - request: HttpRequest, - **kwargs: Any - ) -> HttpResponse: + def _send_request(self, request: HttpRequest, **kwargs: Any) -> HttpResponse: """Runs the network request through the client's chained policies. >>> from azure.core.rest import HttpRequest @@ -71,7 +66,7 @@ def _send_request( >>> response = client._send_request(request) - For more information on this code flow, see https://aka.ms/azsdk/python/protocol/quickstart + For more information on this code flow, see https://aka.ms/azsdk/dpcodegen/python/send_request :param request: The network request you want to make. Required. :type request: ~azure.core.rest.HttpRequest diff --git a/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/features/v2015_12_01/_metadata.json b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/features/v2015_12_01/_metadata.json index 4a90ed96e977a..5d2819b85e1e1 100644 --- a/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/features/v2015_12_01/_metadata.json +++ b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/features/v2015_12_01/_metadata.json @@ -10,20 +10,20 @@ "azure_arm": true, "has_lro_operations": false, "client_side_validation": false, - "sync_imports": "{\"typing\": {\"azurecore\": {\"azure.core.credentials\": [\"TokenCredential\"]}}, \"regular\": {\"azurecore\": {\"azure.profiles\": [\"KnownProfiles\", \"ProfileDefinition\"], \"azure.profiles.multiapiclient\": [\"MultiApiClientMixin\"], \"azure.mgmt.core\": [\"ARMPipelineClient\"]}, \"local\": {\"._configuration\": [\"FeatureClientConfiguration\"], \"._operations_mixin\": [\"FeatureClientOperationsMixin\"]}, \"thirdparty\": {\"msrest\": [\"Deserializer\", \"Serializer\"]}}, \"conditional\": {\"stdlib\": {\"typing\": [\"Any\", \"Optional\"]}}}", - "async_imports": "{\"typing\": {\"azurecore\": {\"azure.core.credentials_async\": [\"AsyncTokenCredential\"], \"azure.core.credentials\": [\"TokenCredential\"]}}, \"regular\": {\"azurecore\": {\"azure.profiles\": [\"KnownProfiles\", \"ProfileDefinition\"], \"azure.profiles.multiapiclient\": [\"MultiApiClientMixin\"], \"azure.mgmt.core\": [\"AsyncARMPipelineClient\"]}, \"local\": {\"._configuration\": [\"FeatureClientConfiguration\"], \"._operations_mixin\": [\"FeatureClientOperationsMixin\"]}, \"thirdparty\": {\"msrest\": [\"Deserializer\", \"Serializer\"]}}, \"conditional\": {\"stdlib\": {\"typing\": [\"Any\", \"Optional\"]}}}" + "sync_imports": "{\"conditional\": {\"stdlib\": {\"typing\": [\"Any\", \"Optional\"]}}, \"regular\": {\"azurecore\": {\"azure.mgmt.core\": [\"ARMPipelineClient\"], \"azure.profiles\": [\"KnownProfiles\", \"ProfileDefinition\"], \"azure.profiles.multiapiclient\": [\"MultiApiClientMixin\"]}, \"local\": {\"._configuration\": [\"FeatureClientConfiguration\"], \".._serialization\": [\"Deserializer\", \"Serializer\"], \"._operations_mixin\": [\"FeatureClientOperationsMixin\"]}}, \"typing\": {\"azurecore\": {\"azure.core.credentials\": [\"TokenCredential\"]}}}", + "async_imports": "{\"conditional\": {\"stdlib\": {\"typing\": [\"Any\", \"Optional\"]}}, \"regular\": {\"azurecore\": {\"azure.mgmt.core\": [\"AsyncARMPipelineClient\"], \"azure.profiles\": [\"KnownProfiles\", \"ProfileDefinition\"], \"azure.profiles.multiapiclient\": [\"MultiApiClientMixin\"]}, \"local\": {\"._configuration\": [\"FeatureClientConfiguration\"], \"..._serialization\": [\"Deserializer\", \"Serializer\"], \"._operations_mixin\": [\"FeatureClientOperationsMixin\"]}}, \"typing\": {\"azurecore\": {\"azure.core.credentials_async\": [\"AsyncTokenCredential\"]}}}" }, "global_parameters": { "sync": { "credential": { - "signature": "credential, # type: \"TokenCredential\"", - "description": "Credential needed for the client to connect to Azure.", + "signature": "credential: \"TokenCredential\",", + "description": "Credential needed for the client to connect to Azure. Required.", "docstring_type": "~azure.core.credentials.TokenCredential", "required": true }, "subscription_id": { - "signature": "subscription_id, # type: str", - "description": "The ID of the target subscription.", + "signature": "subscription_id: str,", + "description": "The ID of the target subscription. Required.", "docstring_type": "str", "required": true } @@ -31,13 +31,13 @@ "async": { "credential": { "signature": "credential: \"AsyncTokenCredential\",", - "description": "Credential needed for the client to connect to Azure.", + "description": "Credential needed for the client to connect to Azure. Required.", "docstring_type": "~azure.core.credentials_async.AsyncTokenCredential", "required": true }, "subscription_id": { "signature": "subscription_id: str,", - "description": "The ID of the target subscription.", + "description": "The ID of the target subscription. Required.", "docstring_type": "str", "required": true } @@ -54,7 +54,7 @@ "required": false }, "base_url": { - "signature": "base_url=\"https://management.azure.com\", # type: str", + "signature": "base_url: str = \"https://management.azure.com\",", "description": "Service URL", "docstring_type": "str", "required": false @@ -100,20 +100,21 @@ "features": "FeaturesOperations" }, "operation_mixins": { - "sync_imports": "{\"conditional\": {\"stdlib\": {\"typing\": [\"Any\", \"Iterable\"]}, \"azurecore\": {\"azure.core.paging\": [\"ItemPaged\"]}}}", - "async_imports": "{\"conditional\": {\"stdlib\": {\"typing\": [\"Any\", \"AsyncIterable\"]}, \"azurecore\": {\"azure.core.async_paging\": [\"AsyncItemPaged\"]}}}", + "sync_imports": "{\"conditional\": {\"stdlib\": {\"typing\": [\"Any\", \"Iterable\"]}}, \"regular\": {\"local\": {\".\": [[\"models\", \"_models\"]]}, \"azurecore\": {\"azure.core.paging\": [\"ItemPaged\"]}}}", + "async_imports": "{\"conditional\": {\"stdlib\": {\"typing\": [\"Any\", \"AsyncIterable\"]}}, \"regular\": {\"local\": {\"..\": [[\"models\", \"_models\"]]}, \"azurecore\": {\"azure.core.async_paging\": [\"AsyncItemPaged\"]}}}", "operations": { "list_operations" : { "sync": { - "signature": "def list_operations(\n self,\n **kwargs # type: Any\n):\n # type: (...) -\u003e Iterable[\"_models.OperationListResult\"]\n", - "doc": "\"\"\"Lists all of the available Microsoft.Features REST API operations.\n\n:keyword callable cls: A custom type or function that will be passed the direct response\n:return: An iterator like instance of either OperationListResult or the result of cls(response)\n:rtype:\n ~azure.core.paging.ItemPaged[~azure.mgmt.resource.features.v2015_12_01.models.OperationListResult]\n:raises: ~azure.core.exceptions.HttpResponseError\n\"\"\"" + "signature": "def list_operations(\n self,\n **kwargs: Any\n) -\u003e Iterable[\"_models.Operation\"]:\n", + "doc": "\"\"\"Lists all of the available Microsoft.Features REST API operations.\n\n:keyword callable cls: A custom type or function that will be passed the direct response\n:return: An iterator like instance of either Operation or the result of cls(response)\n:rtype:\n ~azure.core.paging.ItemPaged[~azure.mgmt.resource.features.v2015_12_01.models.Operation]\n:raises ~azure.core.exceptions.HttpResponseError:\n\"\"\"", + "call": "**kwargs" }, "async": { "coroutine": false, - "signature": "def list_operations(\n self,\n **kwargs: Any\n) -\u003e AsyncIterable[\"_models.OperationListResult\"]:\n", - "doc": "\"\"\"Lists all of the available Microsoft.Features REST API operations.\n\n:keyword callable cls: A custom type or function that will be passed the direct response\n:return: An iterator like instance of either OperationListResult or the result of cls(response)\n:rtype:\n ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.resource.features.v2015_12_01.models.OperationListResult]\n:raises: ~azure.core.exceptions.HttpResponseError\n\"\"\"" - }, - "call": "" + "signature": "def list_operations(\n self,\n **kwargs: Any\n) -\u003e AsyncIterable[\"_models.Operation\"]:\n", + "doc": "\"\"\"Lists all of the available Microsoft.Features REST API operations.\n\n:keyword callable cls: A custom type or function that will be passed the direct response\n:return: An iterator like instance of either Operation or the result of cls(response)\n:rtype:\n ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.resource.features.v2015_12_01.models.Operation]\n:raises ~azure.core.exceptions.HttpResponseError:\n\"\"\"", + "call": "**kwargs" + } } } } diff --git a/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/features/v2015_12_01/_patch.py b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/features/v2015_12_01/_patch.py index 74e48ecd07cf3..f99e77fef9861 100644 --- a/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/features/v2015_12_01/_patch.py +++ b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/features/v2015_12_01/_patch.py @@ -28,4 +28,4 @@ # This file is used for handwritten extensions to the generated code. Example: # https://github.com/Azure/azure-sdk-for-python/blob/main/doc/dev/customize_code/how-to-patch-sdk-code.md def patch_sdk(): - pass \ No newline at end of file + pass diff --git a/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/features/v2015_12_01/_vendor.py b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/features/v2015_12_01/_vendor.py index 138f663c53a4e..496652fe7d437 100644 --- a/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/features/v2015_12_01/_vendor.py +++ b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/features/v2015_12_01/_vendor.py @@ -5,8 +5,20 @@ # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- +from abc import ABC +from typing import TYPE_CHECKING + from azure.core.pipeline.transport import HttpRequest +from ._configuration import FeatureClientConfiguration + +if TYPE_CHECKING: + # pylint: disable=unused-import,ungrouped-imports + from azure.core import PipelineClient + + from .._serialization import Deserializer, Serializer + + def _convert_request(request, files=None): data = request.content if not files else None request = HttpRequest(method=request.method, url=request.url, headers=request.headers, data=data) @@ -14,6 +26,7 @@ def _convert_request(request, files=None): request.set_formdata_body(files) return request + def _format_url_section(template, **kwargs): components = template.split("/") while components: @@ -21,7 +34,14 @@ def _format_url_section(template, **kwargs): 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 - ] + components = [c for c in formatted_components if "{}".format(key.args[0]) not in c] template = "/".join(components) + + +class MixinABC(ABC): + """DO NOT use this class. It is for internal typing use only.""" + + _client: "PipelineClient" + _config: FeatureClientConfiguration + _serialize: "Serializer" + _deserialize: "Deserializer" diff --git a/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/features/v2015_12_01/_version.py b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/features/v2015_12_01/_version.py index a012ac01c480c..e5754a47ce68f 100644 --- a/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/features/v2015_12_01/_version.py +++ b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/features/v2015_12_01/_version.py @@ -6,4 +6,4 @@ # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -VERSION = "21.1.0" +VERSION = "1.0.0b1" diff --git a/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/features/v2015_12_01/aio/__init__.py b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/features/v2015_12_01/aio/__init__.py index 8a08a800d1a0a..1b49aa3332539 100644 --- a/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/features/v2015_12_01/aio/__init__.py +++ b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/features/v2015_12_01/aio/__init__.py @@ -7,9 +7,15 @@ # -------------------------------------------------------------------------- from ._feature_client import FeatureClient -__all__ = ['FeatureClient'] -# `._patch.py` is used for handwritten extensions to the generated code -# Example: https://github.com/Azure/azure-sdk-for-python/blob/main/doc/dev/customize_code/how-to-patch-sdk-code.md -from ._patch import patch_sdk -patch_sdk() +try: + from ._patch import __all__ as _patch_all + from ._patch import * # type: ignore # pylint: disable=unused-wildcard-import +except ImportError: + _patch_all = [] +from ._patch import patch_sdk as _patch_sdk + +__all__ = ["FeatureClient"] +__all__.extend([p for p in _patch_all if p not in __all__]) + +_patch_sdk() diff --git a/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/features/v2015_12_01/aio/_configuration.py b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/features/v2015_12_01/aio/_configuration.py index 1f61e43b0911a..eb4b49815ad1e 100644 --- a/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/features/v2015_12_01/aio/_configuration.py +++ b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/features/v2015_12_01/aio/_configuration.py @@ -25,23 +25,18 @@ class FeatureClientConfiguration(Configuration): # pylint: disable=too-many-ins Note that all parameters used to create this instance are saved as instance attributes. - :param credential: Credential needed for the client to connect to Azure. + :param credential: Credential needed for the client to connect to Azure. Required. :type credential: ~azure.core.credentials_async.AsyncTokenCredential - :param subscription_id: The ID of the target subscription. + :param subscription_id: The ID of the target subscription. Required. :type subscription_id: str :keyword api_version: Api Version. Default value is "2015-12-01". Note that overriding this default value may result in unsupported behavior. :paramtype api_version: str """ - def __init__( - self, - credential: "AsyncTokenCredential", - subscription_id: str, - **kwargs: Any - ) -> None: + def __init__(self, credential: "AsyncTokenCredential", subscription_id: str, **kwargs: Any) -> None: super(FeatureClientConfiguration, self).__init__(**kwargs) - api_version = kwargs.pop('api_version', "2015-12-01") # type: str + api_version = kwargs.pop("api_version", "2015-12-01") # type: str if credential is None: raise ValueError("Parameter 'credential' must not be None.") @@ -51,22 +46,21 @@ def __init__( self.credential = credential self.subscription_id = subscription_id self.api_version = api_version - self.credential_scopes = kwargs.pop('credential_scopes', ['https://management.azure.com/.default']) - kwargs.setdefault('sdk_moniker', 'mgmt-resource/{}'.format(VERSION)) + self.credential_scopes = kwargs.pop("credential_scopes", ["https://management.azure.com/.default"]) + kwargs.setdefault("sdk_moniker", "mgmt-resource/{}".format(VERSION)) self._configure(**kwargs) - 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) - self.logging_policy = kwargs.get('logging_policy') or policies.NetworkTraceLoggingPolicy(**kwargs) - self.http_logging_policy = kwargs.get('http_logging_policy') or ARMHttpLoggingPolicy(**kwargs) - self.retry_policy = kwargs.get('retry_policy') or policies.AsyncRetryPolicy(**kwargs) - self.custom_hook_policy = kwargs.get('custom_hook_policy') or policies.CustomHookPolicy(**kwargs) - self.redirect_policy = kwargs.get('redirect_policy') or policies.AsyncRedirectPolicy(**kwargs) - self.authentication_policy = kwargs.get('authentication_policy') + 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) + self.logging_policy = kwargs.get("logging_policy") or policies.NetworkTraceLoggingPolicy(**kwargs) + self.http_logging_policy = kwargs.get("http_logging_policy") or ARMHttpLoggingPolicy(**kwargs) + self.retry_policy = kwargs.get("retry_policy") or policies.AsyncRetryPolicy(**kwargs) + self.custom_hook_policy = kwargs.get("custom_hook_policy") or policies.CustomHookPolicy(**kwargs) + self.redirect_policy = kwargs.get("redirect_policy") or policies.AsyncRedirectPolicy(**kwargs) + self.authentication_policy = kwargs.get("authentication_policy") if self.credential and not self.authentication_policy: - self.authentication_policy = AsyncARMChallengeAuthenticationPolicy(self.credential, *self.credential_scopes, **kwargs) + self.authentication_policy = AsyncARMChallengeAuthenticationPolicy( + self.credential, *self.credential_scopes, **kwargs + ) diff --git a/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/features/v2015_12_01/aio/_feature_client.py b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/features/v2015_12_01/aio/_feature_client.py index d4c51f23f9817..2cdff9c0f92a9 100644 --- a/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/features/v2015_12_01/aio/_feature_client.py +++ b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/features/v2015_12_01/aio/_feature_client.py @@ -9,12 +9,11 @@ from copy import deepcopy from typing import Any, Awaitable, TYPE_CHECKING -from msrest import Deserializer, Serializer - from azure.core.rest import AsyncHttpResponse, HttpRequest from azure.mgmt.core import AsyncARMPipelineClient from .. import models +from ..._serialization import Deserializer, Serializer from ._configuration import FeatureClientConfiguration from .operations import FeatureClientOperationsMixin, FeaturesOperations @@ -22,7 +21,8 @@ # pylint: disable=unused-import,ungrouped-imports from azure.core.credentials_async import AsyncTokenCredential -class FeatureClient(FeatureClientOperationsMixin): + +class FeatureClient(FeatureClientOperationsMixin): # pylint: disable=client-accepts-api-version-keyword """Azure Feature Exposure Control (AFEC) provides a mechanism for the resource providers to control feature exposure to users. Resource providers typically use this mechanism to provide public/private preview for new features prior to making them generally available. Users need to @@ -30,9 +30,9 @@ class FeatureClient(FeatureClientOperationsMixin): :ivar features: FeaturesOperations operations :vartype features: azure.mgmt.resource.features.v2015_12_01.aio.operations.FeaturesOperations - :param credential: Credential needed for the client to connect to Azure. + :param credential: Credential needed for the client to connect to Azure. Required. :type credential: ~azure.core.credentials_async.AsyncTokenCredential - :param subscription_id: The ID of the target subscription. + :param subscription_id: The ID of the target subscription. Required. :type subscription_id: str :param base_url: Service URL. Default value is "https://management.azure.com". :type base_url: str @@ -57,12 +57,7 @@ def __init__( self._serialize.client_side_validation = False self.features = FeaturesOperations(self._client, self._config, self._serialize, self._deserialize) - - def _send_request( - self, - request: HttpRequest, - **kwargs: Any - ) -> Awaitable[AsyncHttpResponse]: + def _send_request(self, request: HttpRequest, **kwargs: Any) -> Awaitable[AsyncHttpResponse]: """Runs the network request through the client's chained policies. >>> from azure.core.rest import HttpRequest @@ -71,7 +66,7 @@ def _send_request( >>> response = await client._send_request(request) - For more information on this code flow, see https://aka.ms/azsdk/python/protocol/quickstart + For more information on this code flow, see https://aka.ms/azsdk/dpcodegen/python/send_request :param request: The network request you want to make. Required. :type request: ~azure.core.rest.HttpRequest diff --git a/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/features/v2015_12_01/aio/_patch.py b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/features/v2015_12_01/aio/_patch.py index 74e48ecd07cf3..f99e77fef9861 100644 --- a/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/features/v2015_12_01/aio/_patch.py +++ b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/features/v2015_12_01/aio/_patch.py @@ -28,4 +28,4 @@ # This file is used for handwritten extensions to the generated code. Example: # https://github.com/Azure/azure-sdk-for-python/blob/main/doc/dev/customize_code/how-to-patch-sdk-code.md def patch_sdk(): - pass \ No newline at end of file + pass diff --git a/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/features/v2015_12_01/aio/_vendor.py b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/features/v2015_12_01/aio/_vendor.py new file mode 100644 index 0000000000000..3601f1022c123 --- /dev/null +++ b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/features/v2015_12_01/aio/_vendor.py @@ -0,0 +1,28 @@ +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- + +from abc import ABC +from typing import TYPE_CHECKING + +from azure.core.pipeline.transport import HttpRequest + +from ._configuration import FeatureClientConfiguration + +if TYPE_CHECKING: + # pylint: disable=unused-import,ungrouped-imports + from azure.core import AsyncPipelineClient + + from ..._serialization import Deserializer, Serializer + + +class MixinABC(ABC): + """DO NOT use this class. It is for internal typing use only.""" + + _client: "AsyncPipelineClient" + _config: FeatureClientConfiguration + _serialize: "Serializer" + _deserialize: "Deserializer" diff --git a/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/features/v2015_12_01/aio/operations/__init__.py b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/features/v2015_12_01/aio/operations/__init__.py index 2b3386c42c8fb..0aa97023d4db0 100644 --- a/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/features/v2015_12_01/aio/operations/__init__.py +++ b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/features/v2015_12_01/aio/operations/__init__.py @@ -9,7 +9,13 @@ from ._operations import FeatureClientOperationsMixin from ._operations import FeaturesOperations +from ._patch import __all__ as _patch_all +from ._patch import * # type: ignore # pylint: disable=unused-wildcard-import +from ._patch import patch_sdk as _patch_sdk + __all__ = [ - 'FeatureClientOperationsMixin', - 'FeaturesOperations', + "FeatureClientOperationsMixin", + "FeaturesOperations", ] +__all__.extend([p for p in _patch_all if p not in __all__]) +_patch_sdk() diff --git a/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/features/v2015_12_01/aio/operations/_operations.py b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/features/v2015_12_01/aio/operations/_operations.py index 6ff2563d55c83..3e95c55aaeec4 100644 --- a/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/features/v2015_12_01/aio/operations/_operations.py +++ b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/features/v2015_12_01/aio/operations/_operations.py @@ -7,61 +7,86 @@ # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- from typing import Any, AsyncIterable, Callable, Dict, Optional, TypeVar +from urllib.parse import parse_qs, urljoin, urlparse from azure.core.async_paging import AsyncItemPaged, AsyncList -from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error +from azure.core.exceptions import ( + ClientAuthenticationError, + HttpResponseError, + ResourceExistsError, + ResourceNotFoundError, + ResourceNotModifiedError, + map_error, +) from azure.core.pipeline import PipelineResponse from azure.core.pipeline.transport import AsyncHttpResponse from azure.core.rest import HttpRequest from azure.core.tracing.decorator import distributed_trace from azure.core.tracing.decorator_async import distributed_trace_async +from azure.core.utils import case_insensitive_dict from azure.mgmt.core.exceptions import ARMErrorFormat from ... import models as _models from ..._vendor import _convert_request -from ...operations._operations import build_features_get_request, build_features_list_all_request, build_features_list_request, build_features_register_request, build_features_unregister_request, build_list_operations_request -T = TypeVar('T') +from ...operations._operations import ( + build_features_get_request, + build_features_list_all_request, + build_features_list_request, + build_features_register_request, + build_features_unregister_request, + build_list_operations_request, +) +from .._vendor import MixinABC + +T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] -class FeatureClientOperationsMixin: +class FeatureClientOperationsMixin(MixinABC): @distributed_trace - def list_operations( - self, - **kwargs: Any - ) -> AsyncIterable["_models.OperationListResult"]: + def list_operations(self, **kwargs: Any) -> AsyncIterable["_models.Operation"]: """Lists all of the available Microsoft.Features REST API operations. :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either OperationListResult or the result of cls(response) + :return: An iterator like instance of either Operation or the result of cls(response) :rtype: - ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.resource.features.v2015_12_01.models.OperationListResult] - :raises: ~azure.core.exceptions.HttpResponseError + ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.resource.features.v2015_12_01.models.Operation] + :raises ~azure.core.exceptions.HttpResponseError: """ - api_version = kwargs.pop('api_version', "2015-12-01") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2015-12-01")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[_models.OperationListResult] - cls = kwargs.pop('cls', None) # type: ClsType["_models.OperationListResult"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) + def prepare_request(next_link=None): if not next_link: - + request = build_list_operations_request( api_version=api_version, - template_url=self.list_operations.metadata['url'], + template_url=self.list_operations.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore else: - - request = build_list_operations_request( - template_url=next_link, - ) + # make call to next link with the client's api-version + _parsed_next_link = urlparse(next_link) + _next_request_params = case_insensitive_dict(parse_qs(_parsed_next_link.query)) + _next_request_params["api-version"] = self._config.api_version + request = HttpRequest("GET", urljoin(next_link, _parsed_next_link.path), params=_next_request_params) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore request.method = "GET" return request @@ -75,10 +100,8 @@ async def extract_data(pipeline_response): async def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) response = pipeline_response.http_response @@ -88,73 +111,75 @@ async def get_next(next_link=None): return pipeline_response + return AsyncItemPaged(get_next, extract_data) - return AsyncItemPaged( - get_next, extract_data - ) - list_operations.metadata = {'url': "/providers/Microsoft.Features/operations"} # type: ignore -class FeaturesOperations: - """FeaturesOperations async operations. + list_operations.metadata = {"url": "/providers/Microsoft.Features/operations"} # type: ignore - You should not instantiate this class directly. Instead, you should create a Client instance that - instantiates it for you and attaches it as an attribute. - :ivar models: Alias to model classes used in this operation group. - :type models: ~azure.mgmt.resource.features.v2015_12_01.models - :param client: Client for service requests. - :param config: Configuration of service client. - :param serializer: An object model serializer. - :param deserializer: An object model deserializer. +class FeaturesOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. + + Instead, you should access the following operations through + :class:`~azure.mgmt.resource.features.v2015_12_01.aio.FeatureClient`'s + :attr:`features` attribute. """ models = _models - def __init__(self, client, config, serializer, deserializer) -> None: - self._client = client - self._serialize = serializer - self._deserialize = deserializer - self._config = config + def __init__(self, *args, **kwargs) -> None: + input_args = list(args) + self._client = input_args.pop(0) if input_args else kwargs.pop("client") + self._config = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") @distributed_trace - def list_all( - self, - **kwargs: Any - ) -> AsyncIterable["_models.FeatureOperationsListResult"]: + def list_all(self, **kwargs: Any) -> AsyncIterable["_models.FeatureResult"]: """Gets all the preview features that are available through AFEC for the subscription. :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either FeatureOperationsListResult or the result of - cls(response) + :return: An iterator like instance of either FeatureResult or the result of cls(response) :rtype: - ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.resource.features.v2015_12_01.models.FeatureOperationsListResult] - :raises: ~azure.core.exceptions.HttpResponseError + ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.resource.features.v2015_12_01.models.FeatureResult] + :raises ~azure.core.exceptions.HttpResponseError: """ - api_version = kwargs.pop('api_version', "2015-12-01") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2015-12-01")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[_models.FeatureOperationsListResult] - cls = kwargs.pop('cls', None) # type: ClsType["_models.FeatureOperationsListResult"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) + def prepare_request(next_link=None): if not next_link: - + request = build_features_list_all_request( subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.list_all.metadata['url'], + template_url=self.list_all.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore else: - - request = build_features_list_all_request( - subscription_id=self._config.subscription_id, - template_url=next_link, - ) + # make call to next link with the client's api-version + _parsed_next_link = urlparse(next_link) + _next_request_params = case_insensitive_dict(parse_qs(_parsed_next_link.query)) + _next_request_params["api-version"] = self._config.api_version + request = HttpRequest("GET", urljoin(next_link, _parsed_next_link.path), params=_next_request_params) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore request.method = "GET" return request @@ -168,10 +193,8 @@ async def extract_data(pipeline_response): async def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) response = pipeline_response.http_response @@ -181,59 +204,60 @@ async def get_next(next_link=None): return pipeline_response + return AsyncItemPaged(get_next, extract_data) - return AsyncItemPaged( - get_next, extract_data - ) - list_all.metadata = {'url': "/subscriptions/{subscriptionId}/providers/Microsoft.Features/features"} # type: ignore + list_all.metadata = {"url": "/subscriptions/{subscriptionId}/providers/Microsoft.Features/features"} # type: ignore @distributed_trace - def list( - self, - resource_provider_namespace: str, - **kwargs: Any - ) -> AsyncIterable["_models.FeatureOperationsListResult"]: + def list(self, resource_provider_namespace: str, **kwargs: Any) -> AsyncIterable["_models.FeatureResult"]: """Gets all the preview features in a provider namespace that are available through AFEC for the subscription. :param resource_provider_namespace: The namespace of the resource provider for getting - features. + features. Required. :type resource_provider_namespace: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either FeatureOperationsListResult or the result of - cls(response) + :return: An iterator like instance of either FeatureResult or the result of cls(response) :rtype: - ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.resource.features.v2015_12_01.models.FeatureOperationsListResult] - :raises: ~azure.core.exceptions.HttpResponseError + ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.resource.features.v2015_12_01.models.FeatureResult] + :raises ~azure.core.exceptions.HttpResponseError: """ - api_version = kwargs.pop('api_version', "2015-12-01") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2015-12-01")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[_models.FeatureOperationsListResult] - cls = kwargs.pop('cls', None) # type: ClsType["_models.FeatureOperationsListResult"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) + def prepare_request(next_link=None): if not next_link: - + request = build_features_list_request( resource_provider_namespace=resource_provider_namespace, subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.list.metadata['url'], + template_url=self.list.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore else: - - request = build_features_list_request( - resource_provider_namespace=resource_provider_namespace, - subscription_id=self._config.subscription_id, - template_url=next_link, - ) + # make call to next link with the client's api-version + _parsed_next_link = urlparse(next_link) + _next_request_params = case_insensitive_dict(parse_qs(_parsed_next_link.query)) + _next_request_params["api-version"] = self._config.api_version + request = HttpRequest("GET", urljoin(next_link, _parsed_next_link.path), params=_next_request_params) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore request.method = "GET" return request @@ -247,10 +271,8 @@ async def extract_data(pipeline_response): async def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) response = pipeline_response.http_response @@ -260,182 +282,184 @@ async def get_next(next_link=None): return pipeline_response + return AsyncItemPaged(get_next, extract_data) - return AsyncItemPaged( - get_next, extract_data - ) - list.metadata = {'url': "/subscriptions/{subscriptionId}/providers/Microsoft.Features/providers/{resourceProviderNamespace}/features"} # type: ignore + list.metadata = {"url": "/subscriptions/{subscriptionId}/providers/Microsoft.Features/providers/{resourceProviderNamespace}/features"} # type: ignore @distributed_trace_async - async def get( - self, - resource_provider_namespace: str, - feature_name: str, - **kwargs: Any - ) -> "_models.FeatureResult": + async def get(self, resource_provider_namespace: str, feature_name: str, **kwargs: Any) -> _models.FeatureResult: """Gets the preview feature with the specified name. - :param resource_provider_namespace: The resource provider namespace for the feature. + :param resource_provider_namespace: The resource provider namespace for the feature. Required. :type resource_provider_namespace: str - :param feature_name: The name of the feature to get. + :param feature_name: The name of the feature to get. Required. :type feature_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: FeatureResult, or the result of cls(response) + :return: FeatureResult or the result of cls(response) :rtype: ~azure.mgmt.resource.features.v2015_12_01.models.FeatureResult - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.FeatureResult"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + 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', "2015-12-01") # type: str + api_version = kwargs.pop("api_version", _params.pop("api-version", "2015-12-01")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[_models.FeatureResult] - request = build_features_get_request( resource_provider_namespace=resource_provider_namespace, feature_name=feature_name, subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.get.metadata['url'], + template_url=self.get.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) - deserialized = self._deserialize('FeatureResult', pipeline_response) + deserialized = self._deserialize("FeatureResult", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - get.metadata = {'url': "/subscriptions/{subscriptionId}/providers/Microsoft.Features/providers/{resourceProviderNamespace}/features/{featureName}"} # type: ignore - + get.metadata = {"url": "/subscriptions/{subscriptionId}/providers/Microsoft.Features/providers/{resourceProviderNamespace}/features/{featureName}"} # type: ignore @distributed_trace_async async def register( - self, - resource_provider_namespace: str, - feature_name: str, - **kwargs: Any - ) -> "_models.FeatureResult": + self, resource_provider_namespace: str, feature_name: str, **kwargs: Any + ) -> _models.FeatureResult: """Registers the preview feature for the subscription. - :param resource_provider_namespace: The namespace of the resource provider. + :param resource_provider_namespace: The namespace of the resource provider. Required. :type resource_provider_namespace: str - :param feature_name: The name of the feature to register. + :param feature_name: The name of the feature to register. Required. :type feature_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: FeatureResult, or the result of cls(response) + :return: FeatureResult or the result of cls(response) :rtype: ~azure.mgmt.resource.features.v2015_12_01.models.FeatureResult - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.FeatureResult"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) - api_version = kwargs.pop('api_version', "2015-12-01") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2015-12-01")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[_models.FeatureResult] - request = build_features_register_request( resource_provider_namespace=resource_provider_namespace, feature_name=feature_name, subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.register.metadata['url'], + template_url=self.register.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) - deserialized = self._deserialize('FeatureResult', pipeline_response) + deserialized = self._deserialize("FeatureResult", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - register.metadata = {'url': "/subscriptions/{subscriptionId}/providers/Microsoft.Features/providers/{resourceProviderNamespace}/features/{featureName}/register"} # type: ignore - + register.metadata = {"url": "/subscriptions/{subscriptionId}/providers/Microsoft.Features/providers/{resourceProviderNamespace}/features/{featureName}/register"} # type: ignore @distributed_trace_async async def unregister( - self, - resource_provider_namespace: str, - feature_name: str, - **kwargs: Any - ) -> "_models.FeatureResult": + self, resource_provider_namespace: str, feature_name: str, **kwargs: Any + ) -> _models.FeatureResult: """Unregisters the preview feature for the subscription. - :param resource_provider_namespace: The namespace of the resource provider. + :param resource_provider_namespace: The namespace of the resource provider. Required. :type resource_provider_namespace: str - :param feature_name: The name of the feature to unregister. + :param feature_name: The name of the feature to unregister. Required. :type feature_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: FeatureResult, or the result of cls(response) + :return: FeatureResult or the result of cls(response) :rtype: ~azure.mgmt.resource.features.v2015_12_01.models.FeatureResult - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.FeatureResult"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + 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', "2015-12-01") # type: str + api_version = kwargs.pop("api_version", _params.pop("api-version", "2015-12-01")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[_models.FeatureResult] - request = build_features_unregister_request( resource_provider_namespace=resource_provider_namespace, feature_name=feature_name, subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.unregister.metadata['url'], + template_url=self.unregister.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) - deserialized = self._deserialize('FeatureResult', pipeline_response) + deserialized = self._deserialize("FeatureResult", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - unregister.metadata = {'url': "/subscriptions/{subscriptionId}/providers/Microsoft.Features/providers/{resourceProviderNamespace}/features/{featureName}/unregister"} # type: ignore - + unregister.metadata = {"url": "/subscriptions/{subscriptionId}/providers/Microsoft.Features/providers/{resourceProviderNamespace}/features/{featureName}/unregister"} # type: ignore diff --git a/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/features/v2015_12_01/aio/operations/_patch.py b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/features/v2015_12_01/aio/operations/_patch.py new file mode 100644 index 0000000000000..f7dd32510333d --- /dev/null +++ b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/features/v2015_12_01/aio/operations/_patch.py @@ -0,0 +1,20 @@ +# ------------------------------------ +# Copyright (c) Microsoft Corporation. +# Licensed under the MIT License. +# ------------------------------------ +"""Customize generated code here. + +Follow our quickstart for examples: https://aka.ms/azsdk/python/dpcodegen/python/customize +""" +from typing import List + +__all__: List[str] = [] # Add all objects you want publicly available to users at this package level + + +def patch_sdk(): + """Do not remove from this file. + + `patch_sdk` is a last resort escape hatch that allows you to do customizations + you can't accomplish using the techniques described in + https://aka.ms/azsdk/python/dpcodegen/python/customize + """ diff --git a/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/features/v2015_12_01/models/__init__.py b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/features/v2015_12_01/models/__init__.py index 7d03867e8e98f..5219fb58af9db 100644 --- a/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/features/v2015_12_01/models/__init__.py +++ b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/features/v2015_12_01/models/__init__.py @@ -12,13 +12,17 @@ from ._models_py3 import Operation from ._models_py3 import OperationDisplay from ._models_py3 import OperationListResult - +from ._patch import __all__ as _patch_all +from ._patch import * # type: ignore # pylint: disable=unused-wildcard-import +from ._patch import patch_sdk as _patch_sdk __all__ = [ - 'FeatureOperationsListResult', - 'FeatureProperties', - 'FeatureResult', - 'Operation', - 'OperationDisplay', - 'OperationListResult', + "FeatureOperationsListResult", + "FeatureProperties", + "FeatureResult", + "Operation", + "OperationDisplay", + "OperationListResult", ] +__all__.extend([p for p in _patch_all if p not in __all__]) +_patch_sdk() diff --git a/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/features/v2015_12_01/models/_models_py3.py b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/features/v2015_12_01/models/_models_py3.py index e91f7152715c1..5b03032f59f88 100644 --- a/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/features/v2015_12_01/models/_models_py3.py +++ b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/features/v2015_12_01/models/_models_py3.py @@ -1,4 +1,5 @@ # coding=utf-8 +# pylint: disable=too-many-lines # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. # Licensed under the MIT License. See License.txt in the project root for license information. @@ -6,12 +7,16 @@ # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -from typing import List, Optional +from typing import List, Optional, TYPE_CHECKING -import msrest.serialization +from ... import _serialization +if TYPE_CHECKING: + # pylint: disable=unused-import,ungrouped-imports + from .. import models as _models -class FeatureOperationsListResult(msrest.serialization.Model): + +class FeatureOperationsListResult(_serialization.Model): """List of previewed features. :ivar value: The array of features. @@ -21,16 +26,12 @@ class FeatureOperationsListResult(msrest.serialization.Model): """ _attribute_map = { - 'value': {'key': 'value', 'type': '[FeatureResult]'}, - 'next_link': {'key': 'nextLink', 'type': 'str'}, + "value": {"key": "value", "type": "[FeatureResult]"}, + "next_link": {"key": "nextLink", "type": "str"}, } def __init__( - self, - *, - value: Optional[List["FeatureResult"]] = None, - next_link: Optional[str] = None, - **kwargs + self, *, value: Optional[List["_models.FeatureResult"]] = None, next_link: Optional[str] = None, **kwargs ): """ :keyword value: The array of features. @@ -38,12 +39,12 @@ def __init__( :keyword next_link: The URL to use for getting the next set of results. :paramtype next_link: str """ - super(FeatureOperationsListResult, self).__init__(**kwargs) + super().__init__(**kwargs) self.value = value self.next_link = next_link -class FeatureProperties(msrest.serialization.Model): +class FeatureProperties(_serialization.Model): """Information about feature. :ivar state: The registration state of the feature for the subscription. @@ -51,24 +52,19 @@ class FeatureProperties(msrest.serialization.Model): """ _attribute_map = { - 'state': {'key': 'state', 'type': 'str'}, + "state": {"key": "state", "type": "str"}, } - def __init__( - self, - *, - state: Optional[str] = None, - **kwargs - ): + def __init__(self, *, state: Optional[str] = None, **kwargs): """ :keyword state: The registration state of the feature for the subscription. :paramtype state: str """ - super(FeatureProperties, self).__init__(**kwargs) + super().__init__(**kwargs) self.state = state -class FeatureResult(msrest.serialization.Model): +class FeatureResult(_serialization.Model): """Previewed feature information. :ivar name: The name of the feature. @@ -82,18 +78,18 @@ class FeatureResult(msrest.serialization.Model): """ _attribute_map = { - 'name': {'key': 'name', 'type': 'str'}, - 'properties': {'key': 'properties', 'type': 'FeatureProperties'}, - 'id': {'key': 'id', 'type': 'str'}, - 'type': {'key': 'type', 'type': 'str'}, + "name": {"key": "name", "type": "str"}, + "properties": {"key": "properties", "type": "FeatureProperties"}, + "id": {"key": "id", "type": "str"}, + "type": {"key": "type", "type": "str"}, } def __init__( self, *, name: Optional[str] = None, - properties: Optional["FeatureProperties"] = None, - id: Optional[str] = None, + properties: Optional["_models.FeatureProperties"] = None, + id: Optional[str] = None, # pylint: disable=redefined-builtin type: Optional[str] = None, **kwargs ): @@ -107,14 +103,14 @@ def __init__( :keyword type: The resource type of the feature. :paramtype type: str """ - super(FeatureResult, self).__init__(**kwargs) + super().__init__(**kwargs) self.name = name self.properties = properties self.id = id self.type = type -class Operation(msrest.serialization.Model): +class Operation(_serialization.Model): """Microsoft.Features operation. :ivar name: Operation name: {provider}/{resource}/{operation}. @@ -124,29 +120,23 @@ class Operation(msrest.serialization.Model): """ _attribute_map = { - 'name': {'key': 'name', 'type': 'str'}, - 'display': {'key': 'display', 'type': 'OperationDisplay'}, + "name": {"key": "name", "type": "str"}, + "display": {"key": "display", "type": "OperationDisplay"}, } - def __init__( - self, - *, - name: Optional[str] = None, - display: Optional["OperationDisplay"] = None, - **kwargs - ): + def __init__(self, *, name: Optional[str] = None, display: Optional["_models.OperationDisplay"] = None, **kwargs): """ :keyword name: Operation name: {provider}/{resource}/{operation}. :paramtype name: str :keyword display: The object that represents the operation. :paramtype display: ~azure.mgmt.resource.features.v2015_12_01.models.OperationDisplay """ - super(Operation, self).__init__(**kwargs) + super().__init__(**kwargs) self.name = name self.display = display -class OperationDisplay(msrest.serialization.Model): +class OperationDisplay(_serialization.Model): """The object that represents the operation. :ivar provider: Service provider: Microsoft.Features. @@ -158,9 +148,9 @@ class OperationDisplay(msrest.serialization.Model): """ _attribute_map = { - 'provider': {'key': 'provider', 'type': 'str'}, - 'resource': {'key': 'resource', 'type': 'str'}, - 'operation': {'key': 'operation', 'type': 'str'}, + "provider": {"key": "provider", "type": "str"}, + "resource": {"key": "resource", "type": "str"}, + "operation": {"key": "operation", "type": "str"}, } def __init__( @@ -179,13 +169,13 @@ def __init__( :keyword operation: Operation type: Read, write, delete, etc. :paramtype operation: str """ - super(OperationDisplay, self).__init__(**kwargs) + super().__init__(**kwargs) self.provider = provider self.resource = resource self.operation = operation -class OperationListResult(msrest.serialization.Model): +class OperationListResult(_serialization.Model): """Result of the request to list Microsoft.Features operations. It contains a list of operations and a URL link to get the next set of results. :ivar value: List of Microsoft.Features operations. @@ -195,23 +185,17 @@ class OperationListResult(msrest.serialization.Model): """ _attribute_map = { - 'value': {'key': 'value', 'type': '[Operation]'}, - 'next_link': {'key': 'nextLink', 'type': 'str'}, + "value": {"key": "value", "type": "[Operation]"}, + "next_link": {"key": "nextLink", "type": "str"}, } - def __init__( - self, - *, - value: Optional[List["Operation"]] = None, - next_link: Optional[str] = None, - **kwargs - ): + def __init__(self, *, value: Optional[List["_models.Operation"]] = None, next_link: Optional[str] = None, **kwargs): """ :keyword value: List of Microsoft.Features operations. :paramtype value: list[~azure.mgmt.resource.features.v2015_12_01.models.Operation] :keyword next_link: URL to get the next set of operation list results if there are any. :paramtype next_link: str """ - super(OperationListResult, self).__init__(**kwargs) + super().__init__(**kwargs) self.value = value self.next_link = next_link diff --git a/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/features/v2015_12_01/models/_patch.py b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/features/v2015_12_01/models/_patch.py new file mode 100644 index 0000000000000..f7dd32510333d --- /dev/null +++ b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/features/v2015_12_01/models/_patch.py @@ -0,0 +1,20 @@ +# ------------------------------------ +# Copyright (c) Microsoft Corporation. +# Licensed under the MIT License. +# ------------------------------------ +"""Customize generated code here. + +Follow our quickstart for examples: https://aka.ms/azsdk/python/dpcodegen/python/customize +""" +from typing import List + +__all__: List[str] = [] # Add all objects you want publicly available to users at this package level + + +def patch_sdk(): + """Do not remove from this file. + + `patch_sdk` is a last resort escape hatch that allows you to do customizations + you can't accomplish using the techniques described in + https://aka.ms/azsdk/python/dpcodegen/python/customize + """ diff --git a/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/features/v2015_12_01/operations/__init__.py b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/features/v2015_12_01/operations/__init__.py index 2b3386c42c8fb..0aa97023d4db0 100644 --- a/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/features/v2015_12_01/operations/__init__.py +++ b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/features/v2015_12_01/operations/__init__.py @@ -9,7 +9,13 @@ from ._operations import FeatureClientOperationsMixin from ._operations import FeaturesOperations +from ._patch import __all__ as _patch_all +from ._patch import * # type: ignore # pylint: disable=unused-wildcard-import +from ._patch import patch_sdk as _patch_sdk + __all__ = [ - 'FeatureClientOperationsMixin', - 'FeaturesOperations', + "FeatureClientOperationsMixin", + "FeaturesOperations", ] +__all__.extend([p for p in _patch_all if p not in __all__]) +_patch_sdk() diff --git a/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/features/v2015_12_01/operations/_operations.py b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/features/v2015_12_01/operations/_operations.py index d333a6b97a2f1..74778f75812ea 100644 --- a/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/features/v2015_12_01/operations/_operations.py +++ b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/features/v2015_12_01/operations/_operations.py @@ -7,263 +7,244 @@ # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- from typing import Any, Callable, Dict, Iterable, Optional, TypeVar - -from msrest import Serializer - -from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error +from urllib.parse import parse_qs, urljoin, urlparse + +from azure.core.exceptions import ( + ClientAuthenticationError, + HttpResponseError, + ResourceExistsError, + ResourceNotFoundError, + ResourceNotModifiedError, + map_error, +) from azure.core.paging import ItemPaged from azure.core.pipeline import PipelineResponse from azure.core.pipeline.transport import HttpResponse from azure.core.rest import HttpRequest from azure.core.tracing.decorator import distributed_trace +from azure.core.utils import case_insensitive_dict from azure.mgmt.core.exceptions import ARMErrorFormat from .. import models as _models -from .._vendor import _convert_request, _format_url_section -T = TypeVar('T') +from ..._serialization import Serializer +from .._vendor import MixinABC, _convert_request, _format_url_section + +T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] _SERIALIZER = Serializer() _SERIALIZER.client_side_validation = False -def build_list_operations_request( - **kwargs: Any -) -> HttpRequest: - api_version = kwargs.pop('api_version', "2015-12-01") # type: str - accept = "application/json, text/json" +def build_list_operations_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", "2015-12-01")) # type: str + accept = _headers.pop("Accept", "application/json, text/json") + # Construct URL _url = kwargs.pop("template_url", "/providers/Microsoft.Features/operations") # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - return HttpRequest( - method="GET", - url=_url, - params=_query_parameters, - headers=_header_parameters, - **kwargs - ) + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) -def build_features_list_all_request( - subscription_id: str, - **kwargs: Any -) -> HttpRequest: - api_version = kwargs.pop('api_version', "2015-12-01") # type: str +def build_features_list_all_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", "2015-12-01")) # type: str + accept = _headers.pop("Accept", "application/json, text/json") - accept = "application/json, text/json" # Construct URL _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/providers/Microsoft.Features/features") path_format_arguments = { - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), } _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') - - return HttpRequest( - method="GET", - url=_url, - params=_query_parameters, - headers=_header_parameters, - **kwargs - ) - - -def build_features_list_request( - resource_provider_namespace: str, - subscription_id: str, - **kwargs: Any -) -> HttpRequest: - api_version = kwargs.pop('api_version', "2015-12-01") # type: str + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) + + +def build_features_list_request(resource_provider_namespace: str, subscription_id: str, **kwargs: Any) -> HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2015-12-01")) # type: str + accept = _headers.pop("Accept", "application/json, text/json") - accept = "application/json, text/json" # Construct URL - _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/providers/Microsoft.Features/providers/{resourceProviderNamespace}/features") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/providers/Microsoft.Features/providers/{resourceProviderNamespace}/features", + ) # pylint: disable=line-too-long path_format_arguments = { - "resourceProviderNamespace": _SERIALIZER.url("resource_provider_namespace", resource_provider_namespace, 'str'), - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), + "resourceProviderNamespace": _SERIALIZER.url("resource_provider_namespace", resource_provider_namespace, "str"), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), } _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - return HttpRequest( - method="GET", - url=_url, - params=_query_parameters, - headers=_header_parameters, - **kwargs - ) + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) def build_features_get_request( - resource_provider_namespace: str, - feature_name: str, - subscription_id: str, - **kwargs: Any + resource_provider_namespace: str, feature_name: str, subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2015-12-01") # type: 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", "2015-12-01")) # type: str + accept = _headers.pop("Accept", "application/json, text/json") - accept = "application/json, text/json" # Construct URL - _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/providers/Microsoft.Features/providers/{resourceProviderNamespace}/features/{featureName}") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/providers/Microsoft.Features/providers/{resourceProviderNamespace}/features/{featureName}", + ) # pylint: disable=line-too-long path_format_arguments = { - "resourceProviderNamespace": _SERIALIZER.url("resource_provider_namespace", resource_provider_namespace, 'str'), - "featureName": _SERIALIZER.url("feature_name", feature_name, 'str'), - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), + "resourceProviderNamespace": _SERIALIZER.url("resource_provider_namespace", resource_provider_namespace, "str"), + "featureName": _SERIALIZER.url("feature_name", feature_name, "str"), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), } _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - return HttpRequest( - method="GET", - url=_url, - params=_query_parameters, - headers=_header_parameters, - **kwargs - ) + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) def build_features_register_request( - resource_provider_namespace: str, - feature_name: str, - subscription_id: str, - **kwargs: Any + resource_provider_namespace: str, feature_name: str, subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2015-12-01") # type: 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", "2015-12-01")) # type: str + accept = _headers.pop("Accept", "application/json, text/json") - accept = "application/json, text/json" # Construct URL - _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/providers/Microsoft.Features/providers/{resourceProviderNamespace}/features/{featureName}/register") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/providers/Microsoft.Features/providers/{resourceProviderNamespace}/features/{featureName}/register", + ) # pylint: disable=line-too-long path_format_arguments = { - "resourceProviderNamespace": _SERIALIZER.url("resource_provider_namespace", resource_provider_namespace, 'str'), - "featureName": _SERIALIZER.url("feature_name", feature_name, 'str'), - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), + "resourceProviderNamespace": _SERIALIZER.url("resource_provider_namespace", resource_provider_namespace, "str"), + "featureName": _SERIALIZER.url("feature_name", feature_name, "str"), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), } _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - return HttpRequest( - method="POST", - url=_url, - params=_query_parameters, - headers=_header_parameters, - **kwargs - ) + return HttpRequest(method="POST", url=_url, params=_params, headers=_headers, **kwargs) def build_features_unregister_request( - resource_provider_namespace: str, - feature_name: str, - subscription_id: str, - **kwargs: Any + resource_provider_namespace: str, feature_name: str, subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2015-12-01") # type: 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", "2015-12-01")) # type: str + accept = _headers.pop("Accept", "application/json, text/json") - accept = "application/json, text/json" # Construct URL - _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/providers/Microsoft.Features/providers/{resourceProviderNamespace}/features/{featureName}/unregister") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/providers/Microsoft.Features/providers/{resourceProviderNamespace}/features/{featureName}/unregister", + ) # pylint: disable=line-too-long path_format_arguments = { - "resourceProviderNamespace": _SERIALIZER.url("resource_provider_namespace", resource_provider_namespace, 'str'), - "featureName": _SERIALIZER.url("feature_name", feature_name, 'str'), - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), + "resourceProviderNamespace": _SERIALIZER.url("resource_provider_namespace", resource_provider_namespace, "str"), + "featureName": _SERIALIZER.url("feature_name", feature_name, "str"), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), } _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - return HttpRequest( - method="POST", - url=_url, - params=_query_parameters, - headers=_header_parameters, - **kwargs - ) + return HttpRequest(method="POST", url=_url, params=_params, headers=_headers, **kwargs) -class FeatureClientOperationsMixin(object): +class FeatureClientOperationsMixin(MixinABC): @distributed_trace - def list_operations( - self, - **kwargs: Any - ) -> Iterable["_models.OperationListResult"]: + def list_operations(self, **kwargs: Any) -> Iterable["_models.Operation"]: """Lists all of the available Microsoft.Features REST API operations. :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either OperationListResult or the result of cls(response) + :return: An iterator like instance of either Operation or the result of cls(response) :rtype: - ~azure.core.paging.ItemPaged[~azure.mgmt.resource.features.v2015_12_01.models.OperationListResult] - :raises: ~azure.core.exceptions.HttpResponseError + ~azure.core.paging.ItemPaged[~azure.mgmt.resource.features.v2015_12_01.models.Operation] + :raises ~azure.core.exceptions.HttpResponseError: """ - api_version = kwargs.pop('api_version', "2015-12-01") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2015-12-01")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[_models.OperationListResult] - cls = kwargs.pop('cls', None) # type: ClsType["_models.OperationListResult"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) + def prepare_request(next_link=None): if not next_link: - + request = build_list_operations_request( api_version=api_version, - template_url=self.list_operations.metadata['url'], + template_url=self.list_operations.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore else: - - request = build_list_operations_request( - template_url=next_link, - ) + # make call to next link with the client's api-version + _parsed_next_link = urlparse(next_link) + _next_request_params = case_insensitive_dict(parse_qs(_parsed_next_link.query)) + _next_request_params["api-version"] = self._config.api_version + request = HttpRequest("GET", urljoin(next_link, _parsed_next_link.path), params=_next_request_params) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore request.method = "GET" return request @@ -277,10 +258,8 @@ def extract_data(pipeline_response): def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) response = pipeline_response.http_response @@ -290,73 +269,75 @@ def get_next(next_link=None): return pipeline_response + return ItemPaged(get_next, extract_data) - return ItemPaged( - get_next, extract_data - ) - list_operations.metadata = {'url': "/providers/Microsoft.Features/operations"} # type: ignore -class FeaturesOperations(object): - """FeaturesOperations operations. - - You should not instantiate this class directly. Instead, you should create a Client instance that - instantiates it for you and attaches it as an attribute. - - :ivar models: Alias to model classes used in this operation group. - :type models: ~azure.mgmt.resource.features.v2015_12_01.models - :param client: Client for service requests. - :param config: Configuration of service client. - :param serializer: An object model serializer. - :param deserializer: An object model deserializer. + list_operations.metadata = {"url": "/providers/Microsoft.Features/operations"} # type: ignore + + +class FeaturesOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. + + Instead, you should access the following operations through + :class:`~azure.mgmt.resource.features.v2015_12_01.FeatureClient`'s + :attr:`features` attribute. """ models = _models - def __init__(self, client, config, serializer, deserializer): - self._client = client - self._serialize = serializer - self._deserialize = deserializer - self._config = config + def __init__(self, *args, **kwargs): + input_args = list(args) + self._client = input_args.pop(0) if input_args else kwargs.pop("client") + self._config = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") @distributed_trace - def list_all( - self, - **kwargs: Any - ) -> Iterable["_models.FeatureOperationsListResult"]: + def list_all(self, **kwargs: Any) -> Iterable["_models.FeatureResult"]: """Gets all the preview features that are available through AFEC for the subscription. :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either FeatureOperationsListResult or the result of - cls(response) + :return: An iterator like instance of either FeatureResult or the result of cls(response) :rtype: - ~azure.core.paging.ItemPaged[~azure.mgmt.resource.features.v2015_12_01.models.FeatureOperationsListResult] - :raises: ~azure.core.exceptions.HttpResponseError + ~azure.core.paging.ItemPaged[~azure.mgmt.resource.features.v2015_12_01.models.FeatureResult] + :raises ~azure.core.exceptions.HttpResponseError: """ - api_version = kwargs.pop('api_version', "2015-12-01") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2015-12-01")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[_models.FeatureOperationsListResult] - cls = kwargs.pop('cls', None) # type: ClsType["_models.FeatureOperationsListResult"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) + def prepare_request(next_link=None): if not next_link: - + request = build_features_list_all_request( subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.list_all.metadata['url'], + template_url=self.list_all.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore else: - - request = build_features_list_all_request( - subscription_id=self._config.subscription_id, - template_url=next_link, - ) + # make call to next link with the client's api-version + _parsed_next_link = urlparse(next_link) + _next_request_params = case_insensitive_dict(parse_qs(_parsed_next_link.query)) + _next_request_params["api-version"] = self._config.api_version + request = HttpRequest("GET", urljoin(next_link, _parsed_next_link.path), params=_next_request_params) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore request.method = "GET" return request @@ -370,10 +351,8 @@ def extract_data(pipeline_response): def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) response = pipeline_response.http_response @@ -383,59 +362,60 @@ def get_next(next_link=None): return pipeline_response + return ItemPaged(get_next, extract_data) - return ItemPaged( - get_next, extract_data - ) - list_all.metadata = {'url': "/subscriptions/{subscriptionId}/providers/Microsoft.Features/features"} # type: ignore + list_all.metadata = {"url": "/subscriptions/{subscriptionId}/providers/Microsoft.Features/features"} # type: ignore @distributed_trace - def list( - self, - resource_provider_namespace: str, - **kwargs: Any - ) -> Iterable["_models.FeatureOperationsListResult"]: + def list(self, resource_provider_namespace: str, **kwargs: Any) -> Iterable["_models.FeatureResult"]: """Gets all the preview features in a provider namespace that are available through AFEC for the subscription. :param resource_provider_namespace: The namespace of the resource provider for getting - features. + features. Required. :type resource_provider_namespace: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either FeatureOperationsListResult or the result of - cls(response) + :return: An iterator like instance of either FeatureResult or the result of cls(response) :rtype: - ~azure.core.paging.ItemPaged[~azure.mgmt.resource.features.v2015_12_01.models.FeatureOperationsListResult] - :raises: ~azure.core.exceptions.HttpResponseError + ~azure.core.paging.ItemPaged[~azure.mgmt.resource.features.v2015_12_01.models.FeatureResult] + :raises ~azure.core.exceptions.HttpResponseError: """ - api_version = kwargs.pop('api_version', "2015-12-01") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2015-12-01")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[_models.FeatureOperationsListResult] - cls = kwargs.pop('cls', None) # type: ClsType["_models.FeatureOperationsListResult"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) + def prepare_request(next_link=None): if not next_link: - + request = build_features_list_request( resource_provider_namespace=resource_provider_namespace, subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.list.metadata['url'], + template_url=self.list.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore else: - - request = build_features_list_request( - resource_provider_namespace=resource_provider_namespace, - subscription_id=self._config.subscription_id, - template_url=next_link, - ) + # make call to next link with the client's api-version + _parsed_next_link = urlparse(next_link) + _next_request_params = case_insensitive_dict(parse_qs(_parsed_next_link.query)) + _next_request_params["api-version"] = self._config.api_version + request = HttpRequest("GET", urljoin(next_link, _parsed_next_link.path), params=_next_request_params) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore request.method = "GET" return request @@ -449,10 +429,8 @@ def extract_data(pipeline_response): def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) response = pipeline_response.http_response @@ -462,182 +440,180 @@ def get_next(next_link=None): return pipeline_response + return ItemPaged(get_next, extract_data) - return ItemPaged( - get_next, extract_data - ) - list.metadata = {'url': "/subscriptions/{subscriptionId}/providers/Microsoft.Features/providers/{resourceProviderNamespace}/features"} # type: ignore + list.metadata = {"url": "/subscriptions/{subscriptionId}/providers/Microsoft.Features/providers/{resourceProviderNamespace}/features"} # type: ignore @distributed_trace - def get( - self, - resource_provider_namespace: str, - feature_name: str, - **kwargs: Any - ) -> "_models.FeatureResult": + def get(self, resource_provider_namespace: str, feature_name: str, **kwargs: Any) -> _models.FeatureResult: """Gets the preview feature with the specified name. - :param resource_provider_namespace: The resource provider namespace for the feature. + :param resource_provider_namespace: The resource provider namespace for the feature. Required. :type resource_provider_namespace: str - :param feature_name: The name of the feature to get. + :param feature_name: The name of the feature to get. Required. :type feature_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: FeatureResult, or the result of cls(response) + :return: FeatureResult or the result of cls(response) :rtype: ~azure.mgmt.resource.features.v2015_12_01.models.FeatureResult - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.FeatureResult"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) - api_version = kwargs.pop('api_version', "2015-12-01") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2015-12-01")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[_models.FeatureResult] - request = build_features_get_request( resource_provider_namespace=resource_provider_namespace, feature_name=feature_name, subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.get.metadata['url'], + template_url=self.get.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) - deserialized = self._deserialize('FeatureResult', pipeline_response) + deserialized = self._deserialize("FeatureResult", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - get.metadata = {'url': "/subscriptions/{subscriptionId}/providers/Microsoft.Features/providers/{resourceProviderNamespace}/features/{featureName}"} # type: ignore - + get.metadata = {"url": "/subscriptions/{subscriptionId}/providers/Microsoft.Features/providers/{resourceProviderNamespace}/features/{featureName}"} # type: ignore @distributed_trace - def register( - self, - resource_provider_namespace: str, - feature_name: str, - **kwargs: Any - ) -> "_models.FeatureResult": + def register(self, resource_provider_namespace: str, feature_name: str, **kwargs: Any) -> _models.FeatureResult: """Registers the preview feature for the subscription. - :param resource_provider_namespace: The namespace of the resource provider. + :param resource_provider_namespace: The namespace of the resource provider. Required. :type resource_provider_namespace: str - :param feature_name: The name of the feature to register. + :param feature_name: The name of the feature to register. Required. :type feature_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: FeatureResult, or the result of cls(response) + :return: FeatureResult or the result of cls(response) :rtype: ~azure.mgmt.resource.features.v2015_12_01.models.FeatureResult - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.FeatureResult"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) - api_version = kwargs.pop('api_version', "2015-12-01") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2015-12-01")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[_models.FeatureResult] - request = build_features_register_request( resource_provider_namespace=resource_provider_namespace, feature_name=feature_name, subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.register.metadata['url'], + template_url=self.register.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) - deserialized = self._deserialize('FeatureResult', pipeline_response) + deserialized = self._deserialize("FeatureResult", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - register.metadata = {'url': "/subscriptions/{subscriptionId}/providers/Microsoft.Features/providers/{resourceProviderNamespace}/features/{featureName}/register"} # type: ignore - + register.metadata = {"url": "/subscriptions/{subscriptionId}/providers/Microsoft.Features/providers/{resourceProviderNamespace}/features/{featureName}/register"} # type: ignore @distributed_trace - def unregister( - self, - resource_provider_namespace: str, - feature_name: str, - **kwargs: Any - ) -> "_models.FeatureResult": + def unregister(self, resource_provider_namespace: str, feature_name: str, **kwargs: Any) -> _models.FeatureResult: """Unregisters the preview feature for the subscription. - :param resource_provider_namespace: The namespace of the resource provider. + :param resource_provider_namespace: The namespace of the resource provider. Required. :type resource_provider_namespace: str - :param feature_name: The name of the feature to unregister. + :param feature_name: The name of the feature to unregister. Required. :type feature_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: FeatureResult, or the result of cls(response) + :return: FeatureResult or the result of cls(response) :rtype: ~azure.mgmt.resource.features.v2015_12_01.models.FeatureResult - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.FeatureResult"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) - api_version = kwargs.pop('api_version', "2015-12-01") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2015-12-01")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[_models.FeatureResult] - request = build_features_unregister_request( resource_provider_namespace=resource_provider_namespace, feature_name=feature_name, subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.unregister.metadata['url'], + template_url=self.unregister.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) - deserialized = self._deserialize('FeatureResult', pipeline_response) + deserialized = self._deserialize("FeatureResult", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - unregister.metadata = {'url': "/subscriptions/{subscriptionId}/providers/Microsoft.Features/providers/{resourceProviderNamespace}/features/{featureName}/unregister"} # type: ignore - + unregister.metadata = {"url": "/subscriptions/{subscriptionId}/providers/Microsoft.Features/providers/{resourceProviderNamespace}/features/{featureName}/unregister"} # type: ignore diff --git a/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/features/v2015_12_01/operations/_patch.py b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/features/v2015_12_01/operations/_patch.py new file mode 100644 index 0000000000000..f7dd32510333d --- /dev/null +++ b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/features/v2015_12_01/operations/_patch.py @@ -0,0 +1,20 @@ +# ------------------------------------ +# Copyright (c) Microsoft Corporation. +# Licensed under the MIT License. +# ------------------------------------ +"""Customize generated code here. + +Follow our quickstart for examples: https://aka.ms/azsdk/python/dpcodegen/python/customize +""" +from typing import List + +__all__: List[str] = [] # Add all objects you want publicly available to users at this package level + + +def patch_sdk(): + """Do not remove from this file. + + `patch_sdk` is a last resort escape hatch that allows you to do customizations + you can't accomplish using the techniques described in + https://aka.ms/azsdk/python/dpcodegen/python/customize + """ diff --git a/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/features/v2021_07_01/__init__.py b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/features/v2021_07_01/__init__.py index ad53d4ac63340..babff32b0dc94 100644 --- a/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/features/v2021_07_01/__init__.py +++ b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/features/v2021_07_01/__init__.py @@ -10,9 +10,15 @@ from ._version import VERSION __version__ = VERSION -__all__ = ['FeatureClient'] -# `._patch.py` is used for handwritten extensions to the generated code -# Example: https://github.com/Azure/azure-sdk-for-python/blob/main/doc/dev/customize_code/how-to-patch-sdk-code.md -from ._patch import patch_sdk -patch_sdk() +try: + from ._patch import __all__ as _patch_all + from ._patch import * # type: ignore # pylint: disable=unused-wildcard-import +except ImportError: + _patch_all = [] +from ._patch import patch_sdk as _patch_sdk + +__all__ = ["FeatureClient"] +__all__.extend([p for p in _patch_all if p not in __all__]) + +_patch_sdk() diff --git a/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/features/v2021_07_01/_configuration.py b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/features/v2021_07_01/_configuration.py index f713c43c0962d..c8074e26881bc 100644 --- a/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/features/v2021_07_01/_configuration.py +++ b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/features/v2021_07_01/_configuration.py @@ -25,23 +25,18 @@ class FeatureClientConfiguration(Configuration): # pylint: disable=too-many-ins Note that all parameters used to create this instance are saved as instance attributes. - :param credential: Credential needed for the client to connect to Azure. + :param credential: Credential needed for the client to connect to Azure. Required. :type credential: ~azure.core.credentials.TokenCredential - :param subscription_id: The Azure subscription ID. + :param subscription_id: The Azure subscription ID. Required. :type subscription_id: str :keyword api_version: Api Version. Default value is "2021-07-01". Note that overriding this default value may result in unsupported behavior. :paramtype api_version: str """ - def __init__( - self, - credential: "TokenCredential", - subscription_id: str, - **kwargs: Any - ) -> None: + def __init__(self, credential: "TokenCredential", subscription_id: str, **kwargs: Any) -> None: super(FeatureClientConfiguration, self).__init__(**kwargs) - api_version = kwargs.pop('api_version', "2021-07-01") # type: str + api_version = kwargs.pop("api_version", "2021-07-01") # type: str if credential is None: raise ValueError("Parameter 'credential' must not be None.") @@ -51,23 +46,24 @@ def __init__( self.credential = credential self.subscription_id = subscription_id self.api_version = api_version - self.credential_scopes = kwargs.pop('credential_scopes', ['https://management.azure.com/.default']) - kwargs.setdefault('sdk_moniker', 'mgmt-resource/{}'.format(VERSION)) + self.credential_scopes = kwargs.pop("credential_scopes", ["https://management.azure.com/.default"]) + kwargs.setdefault("sdk_moniker", "mgmt-resource/{}".format(VERSION)) self._configure(**kwargs) def _configure( - self, - **kwargs # type: Any + self, **kwargs # type: Any ): # type: (...) -> 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) - self.logging_policy = kwargs.get('logging_policy') or policies.NetworkTraceLoggingPolicy(**kwargs) - self.http_logging_policy = kwargs.get('http_logging_policy') or ARMHttpLoggingPolicy(**kwargs) - self.retry_policy = kwargs.get('retry_policy') or policies.RetryPolicy(**kwargs) - self.custom_hook_policy = kwargs.get('custom_hook_policy') or policies.CustomHookPolicy(**kwargs) - self.redirect_policy = kwargs.get('redirect_policy') or policies.RedirectPolicy(**kwargs) - self.authentication_policy = kwargs.get('authentication_policy') + 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) + self.logging_policy = kwargs.get("logging_policy") or policies.NetworkTraceLoggingPolicy(**kwargs) + self.http_logging_policy = kwargs.get("http_logging_policy") or ARMHttpLoggingPolicy(**kwargs) + self.retry_policy = kwargs.get("retry_policy") or policies.RetryPolicy(**kwargs) + self.custom_hook_policy = kwargs.get("custom_hook_policy") or policies.CustomHookPolicy(**kwargs) + self.redirect_policy = kwargs.get("redirect_policy") or policies.RedirectPolicy(**kwargs) + self.authentication_policy = kwargs.get("authentication_policy") if self.credential and not self.authentication_policy: - self.authentication_policy = ARMChallengeAuthenticationPolicy(self.credential, *self.credential_scopes, **kwargs) + self.authentication_policy = ARMChallengeAuthenticationPolicy( + self.credential, *self.credential_scopes, **kwargs + ) diff --git a/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/features/v2021_07_01/_feature_client.py b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/features/v2021_07_01/_feature_client.py index 3677ef24375d6..da1ab6013cd01 100644 --- a/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/features/v2021_07_01/_feature_client.py +++ b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/features/v2021_07_01/_feature_client.py @@ -9,12 +9,11 @@ from copy import deepcopy from typing import Any, TYPE_CHECKING -from msrest import Deserializer, Serializer - from azure.core.rest import HttpRequest, HttpResponse from azure.mgmt.core import ARMPipelineClient from . import models +from .._serialization import Deserializer, Serializer from ._configuration import FeatureClientConfiguration from .operations import FeatureClientOperationsMixin, FeaturesOperations, SubscriptionFeatureRegistrationsOperations @@ -22,7 +21,8 @@ # pylint: disable=unused-import,ungrouped-imports from azure.core.credentials import TokenCredential -class FeatureClient(FeatureClientOperationsMixin): + +class FeatureClient(FeatureClientOperationsMixin): # pylint: disable=client-accepts-api-version-keyword """Azure Feature Exposure Control (AFEC) provides a mechanism for the resource providers to control feature exposure to users. Resource providers typically use this mechanism to provide public/private preview for new features prior to making them generally available. Users need to @@ -33,9 +33,9 @@ class FeatureClient(FeatureClientOperationsMixin): :ivar subscription_feature_registrations: SubscriptionFeatureRegistrationsOperations operations :vartype subscription_feature_registrations: azure.mgmt.resource.features.v2021_07_01.operations.SubscriptionFeatureRegistrationsOperations - :param credential: Credential needed for the client to connect to Azure. + :param credential: Credential needed for the client to connect to Azure. Required. :type credential: ~azure.core.credentials.TokenCredential - :param subscription_id: The Azure subscription ID. + :param subscription_id: The Azure subscription ID. Required. :type subscription_id: str :param base_url: Service URL. Default value is "https://management.azure.com". :type base_url: str @@ -59,14 +59,11 @@ def __init__( self._deserialize = Deserializer(client_models) self._serialize.client_side_validation = False self.features = FeaturesOperations(self._client, self._config, self._serialize, self._deserialize) - self.subscription_feature_registrations = SubscriptionFeatureRegistrationsOperations(self._client, self._config, self._serialize, self._deserialize) - + self.subscription_feature_registrations = SubscriptionFeatureRegistrationsOperations( + self._client, self._config, self._serialize, self._deserialize + ) - def _send_request( - self, - request: HttpRequest, - **kwargs: Any - ) -> HttpResponse: + def _send_request(self, request: HttpRequest, **kwargs: Any) -> HttpResponse: """Runs the network request through the client's chained policies. >>> from azure.core.rest import HttpRequest @@ -75,7 +72,7 @@ def _send_request( >>> response = client._send_request(request) - For more information on this code flow, see https://aka.ms/azsdk/python/protocol/quickstart + For more information on this code flow, see https://aka.ms/azsdk/dpcodegen/python/send_request :param request: The network request you want to make. Required. :type request: ~azure.core.rest.HttpRequest diff --git a/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/features/v2021_07_01/_metadata.json b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/features/v2021_07_01/_metadata.json index d5fb464648b9e..79ccf220a107a 100644 --- a/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/features/v2021_07_01/_metadata.json +++ b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/features/v2021_07_01/_metadata.json @@ -10,20 +10,20 @@ "azure_arm": true, "has_lro_operations": false, "client_side_validation": false, - "sync_imports": "{\"typing\": {\"azurecore\": {\"azure.core.credentials\": [\"TokenCredential\"]}}, \"regular\": {\"azurecore\": {\"azure.profiles\": [\"KnownProfiles\", \"ProfileDefinition\"], \"azure.profiles.multiapiclient\": [\"MultiApiClientMixin\"], \"azure.mgmt.core\": [\"ARMPipelineClient\"]}, \"local\": {\"._configuration\": [\"FeatureClientConfiguration\"], \"._operations_mixin\": [\"FeatureClientOperationsMixin\"]}, \"thirdparty\": {\"msrest\": [\"Deserializer\", \"Serializer\"]}}, \"conditional\": {\"stdlib\": {\"typing\": [\"Any\", \"Optional\"]}}}", - "async_imports": "{\"typing\": {\"azurecore\": {\"azure.core.credentials_async\": [\"AsyncTokenCredential\"], \"azure.core.credentials\": [\"TokenCredential\"]}}, \"regular\": {\"azurecore\": {\"azure.profiles\": [\"KnownProfiles\", \"ProfileDefinition\"], \"azure.profiles.multiapiclient\": [\"MultiApiClientMixin\"], \"azure.mgmt.core\": [\"AsyncARMPipelineClient\"]}, \"local\": {\"._configuration\": [\"FeatureClientConfiguration\"], \"._operations_mixin\": [\"FeatureClientOperationsMixin\"]}, \"thirdparty\": {\"msrest\": [\"Deserializer\", \"Serializer\"]}}, \"conditional\": {\"stdlib\": {\"typing\": [\"Any\", \"Optional\"]}}}" + "sync_imports": "{\"conditional\": {\"stdlib\": {\"typing\": [\"Any\", \"Optional\"]}}, \"regular\": {\"azurecore\": {\"azure.mgmt.core\": [\"ARMPipelineClient\"], \"azure.profiles\": [\"KnownProfiles\", \"ProfileDefinition\"], \"azure.profiles.multiapiclient\": [\"MultiApiClientMixin\"]}, \"local\": {\"._configuration\": [\"FeatureClientConfiguration\"], \".._serialization\": [\"Deserializer\", \"Serializer\"], \"._operations_mixin\": [\"FeatureClientOperationsMixin\"]}}, \"typing\": {\"azurecore\": {\"azure.core.credentials\": [\"TokenCredential\"]}}}", + "async_imports": "{\"conditional\": {\"stdlib\": {\"typing\": [\"Any\", \"Optional\"]}}, \"regular\": {\"azurecore\": {\"azure.mgmt.core\": [\"AsyncARMPipelineClient\"], \"azure.profiles\": [\"KnownProfiles\", \"ProfileDefinition\"], \"azure.profiles.multiapiclient\": [\"MultiApiClientMixin\"]}, \"local\": {\"._configuration\": [\"FeatureClientConfiguration\"], \"..._serialization\": [\"Deserializer\", \"Serializer\"], \"._operations_mixin\": [\"FeatureClientOperationsMixin\"]}}, \"typing\": {\"azurecore\": {\"azure.core.credentials_async\": [\"AsyncTokenCredential\"]}}}" }, "global_parameters": { "sync": { "credential": { - "signature": "credential, # type: \"TokenCredential\"", - "description": "Credential needed for the client to connect to Azure.", + "signature": "credential: \"TokenCredential\",", + "description": "Credential needed for the client to connect to Azure. Required.", "docstring_type": "~azure.core.credentials.TokenCredential", "required": true }, "subscription_id": { - "signature": "subscription_id, # type: str", - "description": "The Azure subscription ID.", + "signature": "subscription_id: str,", + "description": "The Azure subscription ID. Required.", "docstring_type": "str", "required": true } @@ -31,13 +31,13 @@ "async": { "credential": { "signature": "credential: \"AsyncTokenCredential\",", - "description": "Credential needed for the client to connect to Azure.", + "description": "Credential needed for the client to connect to Azure. Required.", "docstring_type": "~azure.core.credentials_async.AsyncTokenCredential", "required": true }, "subscription_id": { "signature": "subscription_id: str,", - "description": "The Azure subscription ID.", + "description": "The Azure subscription ID. Required.", "docstring_type": "str", "required": true } @@ -54,7 +54,7 @@ "required": false }, "base_url": { - "signature": "base_url=\"https://management.azure.com\", # type: str", + "signature": "base_url: str = \"https://management.azure.com\",", "description": "Service URL", "docstring_type": "str", "required": false @@ -101,20 +101,21 @@ "subscription_feature_registrations": "SubscriptionFeatureRegistrationsOperations" }, "operation_mixins": { - "sync_imports": "{\"conditional\": {\"stdlib\": {\"typing\": [\"Any\", \"Iterable\"]}, \"azurecore\": {\"azure.core.paging\": [\"ItemPaged\"]}}}", - "async_imports": "{\"conditional\": {\"stdlib\": {\"typing\": [\"Any\", \"AsyncIterable\"]}, \"azurecore\": {\"azure.core.async_paging\": [\"AsyncItemPaged\"]}}}", + "sync_imports": "{\"conditional\": {\"stdlib\": {\"typing\": [\"Any\", \"Iterable\"]}}, \"regular\": {\"local\": {\".\": [[\"models\", \"_models\"]]}, \"azurecore\": {\"azure.core.paging\": [\"ItemPaged\"]}}}", + "async_imports": "{\"conditional\": {\"stdlib\": {\"typing\": [\"Any\", \"AsyncIterable\"]}}, \"regular\": {\"local\": {\"..\": [[\"models\", \"_models\"]]}, \"azurecore\": {\"azure.core.async_paging\": [\"AsyncItemPaged\"]}}}", "operations": { "list_operations" : { "sync": { - "signature": "def list_operations(\n self,\n **kwargs # type: Any\n):\n # type: (...) -\u003e Iterable[\"_models.OperationListResult\"]\n", - "doc": "\"\"\"Lists all of the available Microsoft.Features REST API operations.\n\n:keyword callable cls: A custom type or function that will be passed the direct response\n:return: An iterator like instance of either OperationListResult or the result of cls(response)\n:rtype:\n ~azure.core.paging.ItemPaged[~azure.mgmt.resource.features.v2021_07_01.models.OperationListResult]\n:raises: ~azure.core.exceptions.HttpResponseError\n\"\"\"" + "signature": "def list_operations(\n self,\n **kwargs: Any\n) -\u003e Iterable[\"_models.Operation\"]:\n", + "doc": "\"\"\"Lists all of the available Microsoft.Features REST API operations.\n\n:keyword callable cls: A custom type or function that will be passed the direct response\n:return: An iterator like instance of either Operation or the result of cls(response)\n:rtype:\n ~azure.core.paging.ItemPaged[~azure.mgmt.resource.features.v2021_07_01.models.Operation]\n:raises ~azure.core.exceptions.HttpResponseError:\n\"\"\"", + "call": "**kwargs" }, "async": { "coroutine": false, - "signature": "def list_operations(\n self,\n **kwargs: Any\n) -\u003e AsyncIterable[\"_models.OperationListResult\"]:\n", - "doc": "\"\"\"Lists all of the available Microsoft.Features REST API operations.\n\n:keyword callable cls: A custom type or function that will be passed the direct response\n:return: An iterator like instance of either OperationListResult or the result of cls(response)\n:rtype:\n ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.resource.features.v2021_07_01.models.OperationListResult]\n:raises: ~azure.core.exceptions.HttpResponseError\n\"\"\"" - }, - "call": "" + "signature": "def list_operations(\n self,\n **kwargs: Any\n) -\u003e AsyncIterable[\"_models.Operation\"]:\n", + "doc": "\"\"\"Lists all of the available Microsoft.Features REST API operations.\n\n:keyword callable cls: A custom type or function that will be passed the direct response\n:return: An iterator like instance of either Operation or the result of cls(response)\n:rtype:\n ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.resource.features.v2021_07_01.models.Operation]\n:raises ~azure.core.exceptions.HttpResponseError:\n\"\"\"", + "call": "**kwargs" + } } } } diff --git a/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/features/v2021_07_01/_patch.py b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/features/v2021_07_01/_patch.py index 74e48ecd07cf3..f99e77fef9861 100644 --- a/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/features/v2021_07_01/_patch.py +++ b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/features/v2021_07_01/_patch.py @@ -28,4 +28,4 @@ # This file is used for handwritten extensions to the generated code. Example: # https://github.com/Azure/azure-sdk-for-python/blob/main/doc/dev/customize_code/how-to-patch-sdk-code.md def patch_sdk(): - pass \ No newline at end of file + pass diff --git a/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/features/v2021_07_01/_vendor.py b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/features/v2021_07_01/_vendor.py index 138f663c53a4e..496652fe7d437 100644 --- a/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/features/v2021_07_01/_vendor.py +++ b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/features/v2021_07_01/_vendor.py @@ -5,8 +5,20 @@ # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- +from abc import ABC +from typing import TYPE_CHECKING + from azure.core.pipeline.transport import HttpRequest +from ._configuration import FeatureClientConfiguration + +if TYPE_CHECKING: + # pylint: disable=unused-import,ungrouped-imports + from azure.core import PipelineClient + + from .._serialization import Deserializer, Serializer + + def _convert_request(request, files=None): data = request.content if not files else None request = HttpRequest(method=request.method, url=request.url, headers=request.headers, data=data) @@ -14,6 +26,7 @@ def _convert_request(request, files=None): request.set_formdata_body(files) return request + def _format_url_section(template, **kwargs): components = template.split("/") while components: @@ -21,7 +34,14 @@ def _format_url_section(template, **kwargs): 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 - ] + components = [c for c in formatted_components if "{}".format(key.args[0]) not in c] template = "/".join(components) + + +class MixinABC(ABC): + """DO NOT use this class. It is for internal typing use only.""" + + _client: "PipelineClient" + _config: FeatureClientConfiguration + _serialize: "Serializer" + _deserialize: "Deserializer" diff --git a/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/features/v2021_07_01/_version.py b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/features/v2021_07_01/_version.py index a012ac01c480c..e5754a47ce68f 100644 --- a/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/features/v2021_07_01/_version.py +++ b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/features/v2021_07_01/_version.py @@ -6,4 +6,4 @@ # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -VERSION = "21.1.0" +VERSION = "1.0.0b1" diff --git a/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/features/v2021_07_01/aio/__init__.py b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/features/v2021_07_01/aio/__init__.py index 8a08a800d1a0a..1b49aa3332539 100644 --- a/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/features/v2021_07_01/aio/__init__.py +++ b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/features/v2021_07_01/aio/__init__.py @@ -7,9 +7,15 @@ # -------------------------------------------------------------------------- from ._feature_client import FeatureClient -__all__ = ['FeatureClient'] -# `._patch.py` is used for handwritten extensions to the generated code -# Example: https://github.com/Azure/azure-sdk-for-python/blob/main/doc/dev/customize_code/how-to-patch-sdk-code.md -from ._patch import patch_sdk -patch_sdk() +try: + from ._patch import __all__ as _patch_all + from ._patch import * # type: ignore # pylint: disable=unused-wildcard-import +except ImportError: + _patch_all = [] +from ._patch import patch_sdk as _patch_sdk + +__all__ = ["FeatureClient"] +__all__.extend([p for p in _patch_all if p not in __all__]) + +_patch_sdk() diff --git a/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/features/v2021_07_01/aio/_configuration.py b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/features/v2021_07_01/aio/_configuration.py index d5c6045fc499c..2904259f6207e 100644 --- a/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/features/v2021_07_01/aio/_configuration.py +++ b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/features/v2021_07_01/aio/_configuration.py @@ -25,23 +25,18 @@ class FeatureClientConfiguration(Configuration): # pylint: disable=too-many-ins Note that all parameters used to create this instance are saved as instance attributes. - :param credential: Credential needed for the client to connect to Azure. + :param credential: Credential needed for the client to connect to Azure. Required. :type credential: ~azure.core.credentials_async.AsyncTokenCredential - :param subscription_id: The Azure subscription ID. + :param subscription_id: The Azure subscription ID. Required. :type subscription_id: str :keyword api_version: Api Version. Default value is "2021-07-01". Note that overriding this default value may result in unsupported behavior. :paramtype api_version: str """ - def __init__( - self, - credential: "AsyncTokenCredential", - subscription_id: str, - **kwargs: Any - ) -> None: + def __init__(self, credential: "AsyncTokenCredential", subscription_id: str, **kwargs: Any) -> None: super(FeatureClientConfiguration, self).__init__(**kwargs) - api_version = kwargs.pop('api_version', "2021-07-01") # type: str + api_version = kwargs.pop("api_version", "2021-07-01") # type: str if credential is None: raise ValueError("Parameter 'credential' must not be None.") @@ -51,22 +46,21 @@ def __init__( self.credential = credential self.subscription_id = subscription_id self.api_version = api_version - self.credential_scopes = kwargs.pop('credential_scopes', ['https://management.azure.com/.default']) - kwargs.setdefault('sdk_moniker', 'mgmt-resource/{}'.format(VERSION)) + self.credential_scopes = kwargs.pop("credential_scopes", ["https://management.azure.com/.default"]) + kwargs.setdefault("sdk_moniker", "mgmt-resource/{}".format(VERSION)) self._configure(**kwargs) - 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) - self.logging_policy = kwargs.get('logging_policy') or policies.NetworkTraceLoggingPolicy(**kwargs) - self.http_logging_policy = kwargs.get('http_logging_policy') or ARMHttpLoggingPolicy(**kwargs) - self.retry_policy = kwargs.get('retry_policy') or policies.AsyncRetryPolicy(**kwargs) - self.custom_hook_policy = kwargs.get('custom_hook_policy') or policies.CustomHookPolicy(**kwargs) - self.redirect_policy = kwargs.get('redirect_policy') or policies.AsyncRedirectPolicy(**kwargs) - self.authentication_policy = kwargs.get('authentication_policy') + 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) + self.logging_policy = kwargs.get("logging_policy") or policies.NetworkTraceLoggingPolicy(**kwargs) + self.http_logging_policy = kwargs.get("http_logging_policy") or ARMHttpLoggingPolicy(**kwargs) + self.retry_policy = kwargs.get("retry_policy") or policies.AsyncRetryPolicy(**kwargs) + self.custom_hook_policy = kwargs.get("custom_hook_policy") or policies.CustomHookPolicy(**kwargs) + self.redirect_policy = kwargs.get("redirect_policy") or policies.AsyncRedirectPolicy(**kwargs) + self.authentication_policy = kwargs.get("authentication_policy") if self.credential and not self.authentication_policy: - self.authentication_policy = AsyncARMChallengeAuthenticationPolicy(self.credential, *self.credential_scopes, **kwargs) + self.authentication_policy = AsyncARMChallengeAuthenticationPolicy( + self.credential, *self.credential_scopes, **kwargs + ) diff --git a/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/features/v2021_07_01/aio/_feature_client.py b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/features/v2021_07_01/aio/_feature_client.py index df261c14ac49a..88594009b9923 100644 --- a/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/features/v2021_07_01/aio/_feature_client.py +++ b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/features/v2021_07_01/aio/_feature_client.py @@ -9,12 +9,11 @@ from copy import deepcopy from typing import Any, Awaitable, TYPE_CHECKING -from msrest import Deserializer, Serializer - from azure.core.rest import AsyncHttpResponse, HttpRequest from azure.mgmt.core import AsyncARMPipelineClient from .. import models +from ..._serialization import Deserializer, Serializer from ._configuration import FeatureClientConfiguration from .operations import FeatureClientOperationsMixin, FeaturesOperations, SubscriptionFeatureRegistrationsOperations @@ -22,7 +21,8 @@ # pylint: disable=unused-import,ungrouped-imports from azure.core.credentials_async import AsyncTokenCredential -class FeatureClient(FeatureClientOperationsMixin): + +class FeatureClient(FeatureClientOperationsMixin): # pylint: disable=client-accepts-api-version-keyword """Azure Feature Exposure Control (AFEC) provides a mechanism for the resource providers to control feature exposure to users. Resource providers typically use this mechanism to provide public/private preview for new features prior to making them generally available. Users need to @@ -33,9 +33,9 @@ class FeatureClient(FeatureClientOperationsMixin): :ivar subscription_feature_registrations: SubscriptionFeatureRegistrationsOperations operations :vartype subscription_feature_registrations: azure.mgmt.resource.features.v2021_07_01.aio.operations.SubscriptionFeatureRegistrationsOperations - :param credential: Credential needed for the client to connect to Azure. + :param credential: Credential needed for the client to connect to Azure. Required. :type credential: ~azure.core.credentials_async.AsyncTokenCredential - :param subscription_id: The Azure subscription ID. + :param subscription_id: The Azure subscription ID. Required. :type subscription_id: str :param base_url: Service URL. Default value is "https://management.azure.com". :type base_url: str @@ -59,14 +59,11 @@ def __init__( self._deserialize = Deserializer(client_models) self._serialize.client_side_validation = False self.features = FeaturesOperations(self._client, self._config, self._serialize, self._deserialize) - self.subscription_feature_registrations = SubscriptionFeatureRegistrationsOperations(self._client, self._config, self._serialize, self._deserialize) - + self.subscription_feature_registrations = SubscriptionFeatureRegistrationsOperations( + self._client, self._config, self._serialize, self._deserialize + ) - def _send_request( - self, - request: HttpRequest, - **kwargs: Any - ) -> Awaitable[AsyncHttpResponse]: + def _send_request(self, request: HttpRequest, **kwargs: Any) -> Awaitable[AsyncHttpResponse]: """Runs the network request through the client's chained policies. >>> from azure.core.rest import HttpRequest @@ -75,7 +72,7 @@ def _send_request( >>> response = await client._send_request(request) - For more information on this code flow, see https://aka.ms/azsdk/python/protocol/quickstart + For more information on this code flow, see https://aka.ms/azsdk/dpcodegen/python/send_request :param request: The network request you want to make. Required. :type request: ~azure.core.rest.HttpRequest diff --git a/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/features/v2021_07_01/aio/_patch.py b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/features/v2021_07_01/aio/_patch.py index 74e48ecd07cf3..f99e77fef9861 100644 --- a/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/features/v2021_07_01/aio/_patch.py +++ b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/features/v2021_07_01/aio/_patch.py @@ -28,4 +28,4 @@ # This file is used for handwritten extensions to the generated code. Example: # https://github.com/Azure/azure-sdk-for-python/blob/main/doc/dev/customize_code/how-to-patch-sdk-code.md def patch_sdk(): - pass \ No newline at end of file + pass diff --git a/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/features/v2021_07_01/aio/_vendor.py b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/features/v2021_07_01/aio/_vendor.py new file mode 100644 index 0000000000000..3601f1022c123 --- /dev/null +++ b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/features/v2021_07_01/aio/_vendor.py @@ -0,0 +1,28 @@ +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- + +from abc import ABC +from typing import TYPE_CHECKING + +from azure.core.pipeline.transport import HttpRequest + +from ._configuration import FeatureClientConfiguration + +if TYPE_CHECKING: + # pylint: disable=unused-import,ungrouped-imports + from azure.core import AsyncPipelineClient + + from ..._serialization import Deserializer, Serializer + + +class MixinABC(ABC): + """DO NOT use this class. It is for internal typing use only.""" + + _client: "AsyncPipelineClient" + _config: FeatureClientConfiguration + _serialize: "Serializer" + _deserialize: "Deserializer" diff --git a/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/features/v2021_07_01/aio/operations/__init__.py b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/features/v2021_07_01/aio/operations/__init__.py index bfda220abc66d..7a3fdf7ac696e 100644 --- a/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/features/v2021_07_01/aio/operations/__init__.py +++ b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/features/v2021_07_01/aio/operations/__init__.py @@ -10,8 +10,14 @@ from ._operations import FeaturesOperations from ._operations import SubscriptionFeatureRegistrationsOperations +from ._patch import __all__ as _patch_all +from ._patch import * # type: ignore # pylint: disable=unused-wildcard-import +from ._patch import patch_sdk as _patch_sdk + __all__ = [ - 'FeatureClientOperationsMixin', - 'FeaturesOperations', - 'SubscriptionFeatureRegistrationsOperations', + "FeatureClientOperationsMixin", + "FeaturesOperations", + "SubscriptionFeatureRegistrationsOperations", ] +__all__.extend([p for p in _patch_all if p not in __all__]) +_patch_sdk() diff --git a/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/features/v2021_07_01/aio/operations/_operations.py b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/features/v2021_07_01/aio/operations/_operations.py index 65b0a149e5137..f82ea28c2cc80 100644 --- a/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/features/v2021_07_01/aio/operations/_operations.py +++ b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/features/v2021_07_01/aio/operations/_operations.py @@ -6,62 +6,92 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -from typing import Any, AsyncIterable, Callable, Dict, Optional, TypeVar +from typing import Any, AsyncIterable, Callable, Dict, IO, Optional, TypeVar, Union, overload +from urllib.parse import parse_qs, urljoin, urlparse from azure.core.async_paging import AsyncItemPaged, AsyncList -from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error +from azure.core.exceptions import ( + ClientAuthenticationError, + HttpResponseError, + ResourceExistsError, + ResourceNotFoundError, + ResourceNotModifiedError, + map_error, +) from azure.core.pipeline import PipelineResponse from azure.core.pipeline.transport import AsyncHttpResponse from azure.core.rest import HttpRequest from azure.core.tracing.decorator import distributed_trace from azure.core.tracing.decorator_async import distributed_trace_async +from azure.core.utils import case_insensitive_dict from azure.mgmt.core.exceptions import ARMErrorFormat from ... import models as _models from ..._vendor import _convert_request -from ...operations._operations import build_features_get_request, build_features_list_all_request, build_features_list_request, build_features_register_request, build_features_unregister_request, build_list_operations_request, build_subscription_feature_registrations_create_or_update_request, build_subscription_feature_registrations_delete_request, build_subscription_feature_registrations_get_request, build_subscription_feature_registrations_list_all_by_subscription_request, build_subscription_feature_registrations_list_by_subscription_request -T = TypeVar('T') +from ...operations._operations import ( + build_features_get_request, + build_features_list_all_request, + build_features_list_request, + build_features_register_request, + build_features_unregister_request, + build_list_operations_request, + build_subscription_feature_registrations_create_or_update_request, + build_subscription_feature_registrations_delete_request, + build_subscription_feature_registrations_get_request, + build_subscription_feature_registrations_list_all_by_subscription_request, + build_subscription_feature_registrations_list_by_subscription_request, +) +from .._vendor import MixinABC + +T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] -class FeatureClientOperationsMixin: +class FeatureClientOperationsMixin(MixinABC): @distributed_trace - def list_operations( - self, - **kwargs: Any - ) -> AsyncIterable["_models.OperationListResult"]: + def list_operations(self, **kwargs: Any) -> AsyncIterable["_models.Operation"]: """Lists all of the available Microsoft.Features REST API operations. :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either OperationListResult or the result of cls(response) + :return: An iterator like instance of either Operation or the result of cls(response) :rtype: - ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.resource.features.v2021_07_01.models.OperationListResult] - :raises: ~azure.core.exceptions.HttpResponseError + ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.resource.features.v2021_07_01.models.Operation] + :raises ~azure.core.exceptions.HttpResponseError: """ - api_version = kwargs.pop('api_version', "2021-07-01") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-07-01")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[_models.OperationListResult] - cls = kwargs.pop('cls', None) # type: ClsType["_models.OperationListResult"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) + def prepare_request(next_link=None): if not next_link: - + request = build_list_operations_request( api_version=api_version, - template_url=self.list_operations.metadata['url'], + template_url=self.list_operations.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore else: - - request = build_list_operations_request( - template_url=next_link, - ) + # make call to next link with the client's api-version + _parsed_next_link = urlparse(next_link) + _next_request_params = case_insensitive_dict(parse_qs(_parsed_next_link.query)) + _next_request_params["api-version"] = self._config.api_version + request = HttpRequest("GET", urljoin(next_link, _parsed_next_link.path), params=_next_request_params) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore request.method = "GET" return request @@ -75,10 +105,8 @@ async def extract_data(pipeline_response): async def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) response = pipeline_response.http_response @@ -89,73 +117,75 @@ async def get_next(next_link=None): return pipeline_response + return AsyncItemPaged(get_next, extract_data) - return AsyncItemPaged( - get_next, extract_data - ) - list_operations.metadata = {'url': "/providers/Microsoft.Features/operations"} # type: ignore -class FeaturesOperations: - """FeaturesOperations async operations. + list_operations.metadata = {"url": "/providers/Microsoft.Features/operations"} # type: ignore - You should not instantiate this class directly. Instead, you should create a Client instance that - instantiates it for you and attaches it as an attribute. - :ivar models: Alias to model classes used in this operation group. - :type models: ~azure.mgmt.resource.features.v2021_07_01.models - :param client: Client for service requests. - :param config: Configuration of service client. - :param serializer: An object model serializer. - :param deserializer: An object model deserializer. +class FeaturesOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. + + Instead, you should access the following operations through + :class:`~azure.mgmt.resource.features.v2021_07_01.aio.FeatureClient`'s + :attr:`features` attribute. """ models = _models - def __init__(self, client, config, serializer, deserializer) -> None: - self._client = client - self._serialize = serializer - self._deserialize = deserializer - self._config = config + def __init__(self, *args, **kwargs) -> None: + input_args = list(args) + self._client = input_args.pop(0) if input_args else kwargs.pop("client") + self._config = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") @distributed_trace - def list_all( - self, - **kwargs: Any - ) -> AsyncIterable["_models.FeatureOperationsListResult"]: + def list_all(self, **kwargs: Any) -> AsyncIterable["_models.FeatureResult"]: """Gets all the preview features that are available through AFEC for the subscription. :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either FeatureOperationsListResult or the result of - cls(response) + :return: An iterator like instance of either FeatureResult or the result of cls(response) :rtype: - ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.resource.features.v2021_07_01.models.FeatureOperationsListResult] - :raises: ~azure.core.exceptions.HttpResponseError + ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.resource.features.v2021_07_01.models.FeatureResult] + :raises ~azure.core.exceptions.HttpResponseError: """ - api_version = kwargs.pop('api_version', "2021-07-01") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-07-01")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[_models.FeatureOperationsListResult] - cls = kwargs.pop('cls', None) # type: ClsType["_models.FeatureOperationsListResult"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) + def prepare_request(next_link=None): if not next_link: - + request = build_features_list_all_request( subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.list_all.metadata['url'], + template_url=self.list_all.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore else: - - request = build_features_list_all_request( - subscription_id=self._config.subscription_id, - template_url=next_link, - ) + # make call to next link with the client's api-version + _parsed_next_link = urlparse(next_link) + _next_request_params = case_insensitive_dict(parse_qs(_parsed_next_link.query)) + _next_request_params["api-version"] = self._config.api_version + request = HttpRequest("GET", urljoin(next_link, _parsed_next_link.path), params=_next_request_params) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore request.method = "GET" return request @@ -169,10 +199,8 @@ async def extract_data(pipeline_response): async def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) response = pipeline_response.http_response @@ -183,59 +211,60 @@ async def get_next(next_link=None): return pipeline_response + return AsyncItemPaged(get_next, extract_data) - return AsyncItemPaged( - get_next, extract_data - ) - list_all.metadata = {'url': "/subscriptions/{subscriptionId}/providers/Microsoft.Features/features"} # type: ignore + list_all.metadata = {"url": "/subscriptions/{subscriptionId}/providers/Microsoft.Features/features"} # type: ignore @distributed_trace - def list( - self, - resource_provider_namespace: str, - **kwargs: Any - ) -> AsyncIterable["_models.FeatureOperationsListResult"]: + def list(self, resource_provider_namespace: str, **kwargs: Any) -> AsyncIterable["_models.FeatureResult"]: """Gets all the preview features in a provider namespace that are available through AFEC for the subscription. :param resource_provider_namespace: The namespace of the resource provider for getting - features. + features. Required. :type resource_provider_namespace: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either FeatureOperationsListResult or the result of - cls(response) + :return: An iterator like instance of either FeatureResult or the result of cls(response) :rtype: - ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.resource.features.v2021_07_01.models.FeatureOperationsListResult] - :raises: ~azure.core.exceptions.HttpResponseError + ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.resource.features.v2021_07_01.models.FeatureResult] + :raises ~azure.core.exceptions.HttpResponseError: """ - api_version = kwargs.pop('api_version', "2021-07-01") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-07-01")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[_models.FeatureOperationsListResult] - cls = kwargs.pop('cls', None) # type: ClsType["_models.FeatureOperationsListResult"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) + def prepare_request(next_link=None): if not next_link: - + request = build_features_list_request( resource_provider_namespace=resource_provider_namespace, subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.list.metadata['url'], + template_url=self.list.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore else: - - request = build_features_list_request( - resource_provider_namespace=resource_provider_namespace, - subscription_id=self._config.subscription_id, - template_url=next_link, - ) + # make call to next link with the client's api-version + _parsed_next_link = urlparse(next_link) + _next_request_params = case_insensitive_dict(parse_qs(_parsed_next_link.query)) + _next_request_params["api-version"] = self._config.api_version + request = HttpRequest("GET", urljoin(next_link, _parsed_next_link.path), params=_next_request_params) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore request.method = "GET" return request @@ -249,10 +278,8 @@ async def extract_data(pipeline_response): async def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) response = pipeline_response.http_response @@ -263,54 +290,53 @@ async def get_next(next_link=None): return pipeline_response + return AsyncItemPaged(get_next, extract_data) - return AsyncItemPaged( - get_next, extract_data - ) - list.metadata = {'url': "/subscriptions/{subscriptionId}/providers/Microsoft.Features/providers/{resourceProviderNamespace}/features"} # type: ignore + list.metadata = {"url": "/subscriptions/{subscriptionId}/providers/Microsoft.Features/providers/{resourceProviderNamespace}/features"} # type: ignore @distributed_trace_async - async def get( - self, - resource_provider_namespace: str, - feature_name: str, - **kwargs: Any - ) -> "_models.FeatureResult": + async def get(self, resource_provider_namespace: str, feature_name: str, **kwargs: Any) -> _models.FeatureResult: """Gets the preview feature with the specified name. - :param resource_provider_namespace: The resource provider namespace for the feature. + :param resource_provider_namespace: The resource provider namespace for the feature. Required. :type resource_provider_namespace: str - :param feature_name: The name of the feature to get. + :param feature_name: The name of the feature to get. Required. :type feature_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: FeatureResult, or the result of cls(response) + :return: FeatureResult or the result of cls(response) :rtype: ~azure.mgmt.resource.features.v2021_07_01.models.FeatureResult - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.FeatureResult"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) - api_version = kwargs.pop('api_version', "2021-07-01") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-07-01")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[_models.FeatureResult] - request = build_features_get_request( resource_provider_namespace=resource_provider_namespace, feature_name=feature_name, subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.get.metadata['url'], + template_url=self.get.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200]: @@ -318,58 +344,60 @@ async def get( error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - deserialized = self._deserialize('FeatureResult', pipeline_response) + deserialized = self._deserialize("FeatureResult", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - get.metadata = {'url': "/subscriptions/{subscriptionId}/providers/Microsoft.Features/providers/{resourceProviderNamespace}/features/{featureName}"} # type: ignore - + get.metadata = {"url": "/subscriptions/{subscriptionId}/providers/Microsoft.Features/providers/{resourceProviderNamespace}/features/{featureName}"} # type: ignore @distributed_trace_async async def register( - self, - resource_provider_namespace: str, - feature_name: str, - **kwargs: Any - ) -> "_models.FeatureResult": + self, resource_provider_namespace: str, feature_name: str, **kwargs: Any + ) -> _models.FeatureResult: """Registers the preview feature for the subscription. - :param resource_provider_namespace: The namespace of the resource provider. + :param resource_provider_namespace: The namespace of the resource provider. Required. :type resource_provider_namespace: str - :param feature_name: The name of the feature to register. + :param feature_name: The name of the feature to register. Required. :type feature_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: FeatureResult, or the result of cls(response) + :return: FeatureResult or the result of cls(response) :rtype: ~azure.mgmt.resource.features.v2021_07_01.models.FeatureResult - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.FeatureResult"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) - api_version = kwargs.pop('api_version', "2021-07-01") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-07-01")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[_models.FeatureResult] - request = build_features_register_request( resource_provider_namespace=resource_provider_namespace, feature_name=feature_name, subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.register.metadata['url'], + template_url=self.register.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200]: @@ -377,58 +405,60 @@ async def register( error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - deserialized = self._deserialize('FeatureResult', pipeline_response) + deserialized = self._deserialize("FeatureResult", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - register.metadata = {'url': "/subscriptions/{subscriptionId}/providers/Microsoft.Features/providers/{resourceProviderNamespace}/features/{featureName}/register"} # type: ignore - + register.metadata = {"url": "/subscriptions/{subscriptionId}/providers/Microsoft.Features/providers/{resourceProviderNamespace}/features/{featureName}/register"} # type: ignore @distributed_trace_async async def unregister( - self, - resource_provider_namespace: str, - feature_name: str, - **kwargs: Any - ) -> "_models.FeatureResult": + self, resource_provider_namespace: str, feature_name: str, **kwargs: Any + ) -> _models.FeatureResult: """Unregisters the preview feature for the subscription. - :param resource_provider_namespace: The namespace of the resource provider. + :param resource_provider_namespace: The namespace of the resource provider. Required. :type resource_provider_namespace: str - :param feature_name: The name of the feature to unregister. + :param feature_name: The name of the feature to unregister. Required. :type feature_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: FeatureResult, or the result of cls(response) + :return: FeatureResult or the result of cls(response) :rtype: ~azure.mgmt.resource.features.v2021_07_01.models.FeatureResult - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.FeatureResult"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) - api_version = kwargs.pop('api_version', "2021-07-01") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-07-01")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[_models.FeatureResult] - request = build_features_unregister_request( resource_provider_namespace=resource_provider_namespace, feature_name=feature_name, subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.unregister.metadata['url'], + template_url=self.unregister.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200]: @@ -436,79 +466,80 @@ async def unregister( error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - deserialized = self._deserialize('FeatureResult', pipeline_response) + deserialized = self._deserialize("FeatureResult", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - unregister.metadata = {'url': "/subscriptions/{subscriptionId}/providers/Microsoft.Features/providers/{resourceProviderNamespace}/features/{featureName}/unregister"} # type: ignore + unregister.metadata = {"url": "/subscriptions/{subscriptionId}/providers/Microsoft.Features/providers/{resourceProviderNamespace}/features/{featureName}/unregister"} # type: ignore -class SubscriptionFeatureRegistrationsOperations: - """SubscriptionFeatureRegistrationsOperations async operations. - You should not instantiate this class directly. Instead, you should create a Client instance that - instantiates it for you and attaches it as an attribute. +class SubscriptionFeatureRegistrationsOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. - :ivar models: Alias to model classes used in this operation group. - :type models: ~azure.mgmt.resource.features.v2021_07_01.models - :param client: Client for service requests. - :param config: Configuration of service client. - :param serializer: An object model serializer. - :param deserializer: An object model deserializer. + Instead, you should access the following operations through + :class:`~azure.mgmt.resource.features.v2021_07_01.aio.FeatureClient`'s + :attr:`subscription_feature_registrations` attribute. """ models = _models - def __init__(self, client, config, serializer, deserializer) -> None: - self._client = client - self._serialize = serializer - self._deserialize = deserializer - self._config = config + def __init__(self, *args, **kwargs) -> None: + input_args = list(args) + self._client = input_args.pop(0) if input_args else kwargs.pop("client") + self._config = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") @distributed_trace_async async def get( - self, - provider_namespace: str, - feature_name: str, - **kwargs: Any - ) -> "_models.SubscriptionFeatureRegistration": + self, provider_namespace: str, feature_name: str, **kwargs: Any + ) -> _models.SubscriptionFeatureRegistration: """Returns a feature registration. - :param provider_namespace: The provider namespace. + :param provider_namespace: The provider namespace. Required. :type provider_namespace: str - :param feature_name: The feature name. + :param feature_name: The feature name. Required. :type feature_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: SubscriptionFeatureRegistration, or the result of cls(response) + :return: SubscriptionFeatureRegistration or the result of cls(response) :rtype: ~azure.mgmt.resource.features.v2021_07_01.models.SubscriptionFeatureRegistration - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.SubscriptionFeatureRegistration"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) - api_version = kwargs.pop('api_version', "2021-07-01") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-07-01")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[_models.SubscriptionFeatureRegistration] - request = build_subscription_feature_registrations_get_request( - subscription_id=self._config.subscription_id, provider_namespace=provider_namespace, feature_name=feature_name, + subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.get.metadata['url'], + template_url=self.get.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200]: @@ -516,70 +547,143 @@ async def get( error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - deserialized = self._deserialize('SubscriptionFeatureRegistration', pipeline_response) + deserialized = self._deserialize("SubscriptionFeatureRegistration", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - get.metadata = {'url': "/subscriptions/{subscriptionId}/providers/Microsoft.Features/featureProviders/{providerNamespace}/subscriptionFeatureRegistrations/{featureName}"} # type: ignore + get.metadata = {"url": "/subscriptions/{subscriptionId}/providers/Microsoft.Features/featureProviders/{providerNamespace}/subscriptionFeatureRegistrations/{featureName}"} # type: ignore - - @distributed_trace_async + @overload async def create_or_update( self, provider_namespace: str, feature_name: str, - subscription_feature_registration_type: Optional["_models.SubscriptionFeatureRegistration"] = None, + subscription_feature_registration_type: Optional[_models.SubscriptionFeatureRegistration] = None, + *, + content_type: str = "application/json", **kwargs: Any - ) -> "_models.SubscriptionFeatureRegistration": + ) -> _models.SubscriptionFeatureRegistration: """Create or update a feature registration. - :param provider_namespace: The provider namespace. + :param provider_namespace: The provider namespace. Required. :type provider_namespace: str - :param feature_name: The feature name. + :param feature_name: The feature name. Required. :type feature_name: str :param subscription_feature_registration_type: Subscription Feature Registration Type details. Default value is None. :type subscription_feature_registration_type: ~azure.mgmt.resource.features.v2021_07_01.models.SubscriptionFeatureRegistration + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: SubscriptionFeatureRegistration, or the result of cls(response) + :return: SubscriptionFeatureRegistration or the result of cls(response) :rtype: ~azure.mgmt.resource.features.v2021_07_01.models.SubscriptionFeatureRegistration - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + async def create_or_update( + self, + provider_namespace: str, + feature_name: str, + subscription_feature_registration_type: Optional[IO] = None, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.SubscriptionFeatureRegistration: + """Create or update a feature registration. + + :param provider_namespace: The provider namespace. Required. + :type provider_namespace: str + :param feature_name: The feature name. Required. + :type feature_name: str + :param subscription_feature_registration_type: Subscription Feature Registration Type details. + Default value is None. + :type subscription_feature_registration_type: IO + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: SubscriptionFeatureRegistration or the result of cls(response) + :rtype: ~azure.mgmt.resource.features.v2021_07_01.models.SubscriptionFeatureRegistration + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace_async + async def create_or_update( + self, + provider_namespace: str, + feature_name: str, + subscription_feature_registration_type: Optional[Union[_models.SubscriptionFeatureRegistration, IO]] = None, + **kwargs: Any + ) -> _models.SubscriptionFeatureRegistration: + """Create or update a feature registration. + + :param provider_namespace: The provider namespace. Required. + :type provider_namespace: str + :param feature_name: The feature name. Required. + :type feature_name: str + :param subscription_feature_registration_type: Subscription Feature Registration Type details. + Is either a model type or a IO type. Default value is None. + :type subscription_feature_registration_type: + ~azure.mgmt.resource.features.v2021_07_01.models.SubscriptionFeatureRegistration or IO + :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. + Default value is None. + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: SubscriptionFeatureRegistration or the result of cls(response) + :rtype: ~azure.mgmt.resource.features.v2021_07_01.models.SubscriptionFeatureRegistration + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.SubscriptionFeatureRegistration"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) - api_version = kwargs.pop('api_version', "2021-07-01") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - if subscription_feature_registration_type is not None: - _json = self._serialize.body(subscription_feature_registration_type, 'SubscriptionFeatureRegistration') + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-07-01")) # type: str + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.SubscriptionFeatureRegistration] + + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(subscription_feature_registration_type, (IO, bytes)): + _content = subscription_feature_registration_type else: - _json = None + if subscription_feature_registration_type is not None: + _json = self._serialize.body(subscription_feature_registration_type, "SubscriptionFeatureRegistration") + else: + _json = None request = build_subscription_feature_registrations_create_or_update_request( - subscription_id=self._config.subscription_id, provider_namespace=provider_namespace, feature_name=feature_name, + subscription_id=self._config.subscription_id, api_version=api_version, content_type=content_type, json=_json, - template_url=self.create_or_update.metadata['url'], + content=_content, + template_url=self.create_or_update.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200]: @@ -587,58 +691,60 @@ async def create_or_update( error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - deserialized = self._deserialize('SubscriptionFeatureRegistration', pipeline_response) + deserialized = self._deserialize("SubscriptionFeatureRegistration", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - create_or_update.metadata = {'url': "/subscriptions/{subscriptionId}/providers/Microsoft.Features/featureProviders/{providerNamespace}/subscriptionFeatureRegistrations/{featureName}"} # type: ignore - + create_or_update.metadata = {"url": "/subscriptions/{subscriptionId}/providers/Microsoft.Features/featureProviders/{providerNamespace}/subscriptionFeatureRegistrations/{featureName}"} # type: ignore @distributed_trace_async async def delete( # pylint: disable=inconsistent-return-statements - self, - provider_namespace: str, - feature_name: str, - **kwargs: Any + self, provider_namespace: str, feature_name: str, **kwargs: Any ) -> None: """Deletes a feature registration. - :param provider_namespace: The provider namespace. + :param provider_namespace: The provider namespace. Required. :type provider_namespace: str - :param feature_name: The feature name. + :param feature_name: The feature name. Required. :type feature_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: None, or the result of cls(response) + :return: None or the result of cls(response) :rtype: None - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType[None] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + 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', "2021-07-01") # type: str + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-07-01")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[None] - request = build_subscription_feature_registrations_delete_request( - subscription_id=self._config.subscription_id, provider_namespace=provider_namespace, feature_name=feature_name, + subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.delete.metadata['url'], + template_url=self.delete.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200, 204]: @@ -649,54 +755,59 @@ async def delete( # pylint: disable=inconsistent-return-statements if cls: return cls(pipeline_response, None, {}) - delete.metadata = {'url': "/subscriptions/{subscriptionId}/providers/Microsoft.Features/featureProviders/{providerNamespace}/subscriptionFeatureRegistrations/{featureName}"} # type: ignore - + delete.metadata = {"url": "/subscriptions/{subscriptionId}/providers/Microsoft.Features/featureProviders/{providerNamespace}/subscriptionFeatureRegistrations/{featureName}"} # type: ignore @distributed_trace def list_by_subscription( - self, - provider_namespace: str, - **kwargs: Any - ) -> AsyncIterable["_models.SubscriptionFeatureRegistrationList"]: + self, provider_namespace: str, **kwargs: Any + ) -> AsyncIterable["_models.SubscriptionFeatureRegistration"]: """Returns subscription feature registrations for given subscription and provider namespace. - :param provider_namespace: The provider namespace. + :param provider_namespace: The provider namespace. Required. :type provider_namespace: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either SubscriptionFeatureRegistrationList or the result - of cls(response) + :return: An iterator like instance of either SubscriptionFeatureRegistration or the result of + cls(response) :rtype: - ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.resource.features.v2021_07_01.models.SubscriptionFeatureRegistrationList] - :raises: ~azure.core.exceptions.HttpResponseError + ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.resource.features.v2021_07_01.models.SubscriptionFeatureRegistration] + :raises ~azure.core.exceptions.HttpResponseError: """ - api_version = kwargs.pop('api_version', "2021-07-01") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-07-01")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[_models.SubscriptionFeatureRegistrationList] - cls = kwargs.pop('cls', None) # type: ClsType["_models.SubscriptionFeatureRegistrationList"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) + def prepare_request(next_link=None): if not next_link: - + request = build_subscription_feature_registrations_list_by_subscription_request( - subscription_id=self._config.subscription_id, provider_namespace=provider_namespace, + subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.list_by_subscription.metadata['url'], + template_url=self.list_by_subscription.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore else: - - request = build_subscription_feature_registrations_list_by_subscription_request( - subscription_id=self._config.subscription_id, - provider_namespace=provider_namespace, - template_url=next_link, - ) + # make call to next link with the client's api-version + _parsed_next_link = urlparse(next_link) + _next_request_params = case_insensitive_dict(parse_qs(_parsed_next_link.query)) + _next_request_params["api-version"] = self._config.api_version + request = HttpRequest("GET", urljoin(next_link, _parsed_next_link.path), params=_next_request_params) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore request.method = "GET" return request @@ -710,10 +821,8 @@ async def extract_data(pipeline_response): async def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) response = pipeline_response.http_response @@ -724,52 +833,56 @@ async def get_next(next_link=None): return pipeline_response + return AsyncItemPaged(get_next, extract_data) - return AsyncItemPaged( - get_next, extract_data - ) - list_by_subscription.metadata = {'url': "/subscriptions/{subscriptionId}/providers/Microsoft.Features/featureProviders/{providerNamespace}/subscriptionFeatureRegistrations"} # type: ignore + list_by_subscription.metadata = {"url": "/subscriptions/{subscriptionId}/providers/Microsoft.Features/featureProviders/{providerNamespace}/subscriptionFeatureRegistrations"} # type: ignore @distributed_trace - def list_all_by_subscription( - self, - **kwargs: Any - ) -> AsyncIterable["_models.SubscriptionFeatureRegistrationList"]: + def list_all_by_subscription(self, **kwargs: Any) -> AsyncIterable["_models.SubscriptionFeatureRegistration"]: """Returns subscription feature registrations for given subscription. :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either SubscriptionFeatureRegistrationList or the result - of cls(response) + :return: An iterator like instance of either SubscriptionFeatureRegistration or the result of + cls(response) :rtype: - ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.resource.features.v2021_07_01.models.SubscriptionFeatureRegistrationList] - :raises: ~azure.core.exceptions.HttpResponseError + ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.resource.features.v2021_07_01.models.SubscriptionFeatureRegistration] + :raises ~azure.core.exceptions.HttpResponseError: """ - api_version = kwargs.pop('api_version', "2021-07-01") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-07-01")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[_models.SubscriptionFeatureRegistrationList] - cls = kwargs.pop('cls', None) # type: ClsType["_models.SubscriptionFeatureRegistrationList"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) + def prepare_request(next_link=None): if not next_link: - + request = build_subscription_feature_registrations_list_all_by_subscription_request( subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.list_all_by_subscription.metadata['url'], + template_url=self.list_all_by_subscription.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore else: - - request = build_subscription_feature_registrations_list_all_by_subscription_request( - subscription_id=self._config.subscription_id, - template_url=next_link, - ) + # make call to next link with the client's api-version + _parsed_next_link = urlparse(next_link) + _next_request_params = case_insensitive_dict(parse_qs(_parsed_next_link.query)) + _next_request_params["api-version"] = self._config.api_version + request = HttpRequest("GET", urljoin(next_link, _parsed_next_link.path), params=_next_request_params) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore request.method = "GET" return request @@ -783,10 +896,8 @@ async def extract_data(pipeline_response): async def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) response = pipeline_response.http_response @@ -797,8 +908,6 @@ async def get_next(next_link=None): return pipeline_response + return AsyncItemPaged(get_next, extract_data) - return AsyncItemPaged( - get_next, extract_data - ) - list_all_by_subscription.metadata = {'url': "/subscriptions/{subscriptionId}/providers/Microsoft.Features/subscriptionFeatureRegistrations"} # type: ignore + list_all_by_subscription.metadata = {"url": "/subscriptions/{subscriptionId}/providers/Microsoft.Features/subscriptionFeatureRegistrations"} # type: ignore diff --git a/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/features/v2021_07_01/aio/operations/_patch.py b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/features/v2021_07_01/aio/operations/_patch.py new file mode 100644 index 0000000000000..f7dd32510333d --- /dev/null +++ b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/features/v2021_07_01/aio/operations/_patch.py @@ -0,0 +1,20 @@ +# ------------------------------------ +# Copyright (c) Microsoft Corporation. +# Licensed under the MIT License. +# ------------------------------------ +"""Customize generated code here. + +Follow our quickstart for examples: https://aka.ms/azsdk/python/dpcodegen/python/customize +""" +from typing import List + +__all__: List[str] = [] # Add all objects you want publicly available to users at this package level + + +def patch_sdk(): + """Do not remove from this file. + + `patch_sdk` is a last resort escape hatch that allows you to do customizations + you can't accomplish using the techniques described in + https://aka.ms/azsdk/python/dpcodegen/python/customize + """ diff --git a/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/features/v2021_07_01/models/__init__.py b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/features/v2021_07_01/models/__init__.py index 52972ef9d0508..f52db8a099650 100644 --- a/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/features/v2021_07_01/models/__init__.py +++ b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/features/v2021_07_01/models/__init__.py @@ -20,26 +20,28 @@ from ._models_py3 import SubscriptionFeatureRegistrationList from ._models_py3 import SubscriptionFeatureRegistrationProperties - -from ._feature_client_enums import ( - SubscriptionFeatureRegistrationApprovalType, - SubscriptionFeatureRegistrationState, -) +from ._feature_client_enums import SubscriptionFeatureRegistrationApprovalType +from ._feature_client_enums import SubscriptionFeatureRegistrationState +from ._patch import __all__ as _patch_all +from ._patch import * # type: ignore # pylint: disable=unused-wildcard-import +from ._patch import patch_sdk as _patch_sdk __all__ = [ - 'AuthorizationProfile', - 'ErrorDefinition', - 'ErrorResponse', - 'FeatureOperationsListResult', - 'FeatureProperties', - 'FeatureResult', - 'Operation', - 'OperationDisplay', - 'OperationListResult', - 'ProxyResource', - 'SubscriptionFeatureRegistration', - 'SubscriptionFeatureRegistrationList', - 'SubscriptionFeatureRegistrationProperties', - 'SubscriptionFeatureRegistrationApprovalType', - 'SubscriptionFeatureRegistrationState', + "AuthorizationProfile", + "ErrorDefinition", + "ErrorResponse", + "FeatureOperationsListResult", + "FeatureProperties", + "FeatureResult", + "Operation", + "OperationDisplay", + "OperationListResult", + "ProxyResource", + "SubscriptionFeatureRegistration", + "SubscriptionFeatureRegistrationList", + "SubscriptionFeatureRegistrationProperties", + "SubscriptionFeatureRegistrationApprovalType", + "SubscriptionFeatureRegistrationState", ] +__all__.extend([p for p in _patch_all if p not in __all__]) +_patch_sdk() diff --git a/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/features/v2021_07_01/models/_feature_client_enums.py b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/features/v2021_07_01/models/_feature_client_enums.py index c98149643ac4c..6fc564d148377 100644 --- a/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/features/v2021_07_01/models/_feature_client_enums.py +++ b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/features/v2021_07_01/models/_feature_client_enums.py @@ -7,21 +7,19 @@ # -------------------------------------------------------------------------- from enum import Enum -from six import with_metaclass from azure.core import CaseInsensitiveEnumMeta -class SubscriptionFeatureRegistrationApprovalType(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): - """The feature approval type. - """ +class SubscriptionFeatureRegistrationApprovalType(str, Enum, metaclass=CaseInsensitiveEnumMeta): + """The feature approval type.""" NOT_SPECIFIED = "NotSpecified" APPROVAL_REQUIRED = "ApprovalRequired" AUTO_APPROVAL = "AutoApproval" -class SubscriptionFeatureRegistrationState(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): - """The state. - """ + +class SubscriptionFeatureRegistrationState(str, Enum, metaclass=CaseInsensitiveEnumMeta): + """The state.""" NOT_SPECIFIED = "NotSpecified" NOT_REGISTERED = "NotRegistered" diff --git a/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/features/v2021_07_01/models/_models_py3.py b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/features/v2021_07_01/models/_models_py3.py index 6530648cef2b1..fc56a0763af9c 100644 --- a/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/features/v2021_07_01/models/_models_py3.py +++ b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/features/v2021_07_01/models/_models_py3.py @@ -1,4 +1,5 @@ # coding=utf-8 +# pylint: disable=too-many-lines # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. # Licensed under the MIT License. See License.txt in the project root for license information. @@ -6,15 +7,16 @@ # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -from typing import Dict, List, Optional, Union +from typing import Dict, List, Optional, TYPE_CHECKING, Union -from azure.core.exceptions import HttpResponseError -import msrest.serialization +from ... import _serialization -from ._feature_client_enums import * +if TYPE_CHECKING: + # pylint: disable=unused-import,ungrouped-imports + from .. import models as _models -class AuthorizationProfile(msrest.serialization.Model): +class AuthorizationProfile(_serialization.Model): """Authorization Profile. Variables are only populated by the server, and will be ignored when sending a request. @@ -32,28 +34,24 @@ class AuthorizationProfile(msrest.serialization.Model): """ _validation = { - 'requested_time': {'readonly': True}, - 'requester': {'readonly': True}, - 'requester_object_id': {'readonly': True}, - 'approved_time': {'readonly': True}, - 'approver': {'readonly': True}, + "requested_time": {"readonly": True}, + "requester": {"readonly": True}, + "requester_object_id": {"readonly": True}, + "approved_time": {"readonly": True}, + "approver": {"readonly": True}, } _attribute_map = { - 'requested_time': {'key': 'requestedTime', 'type': 'iso-8601'}, - 'requester': {'key': 'requester', 'type': 'str'}, - 'requester_object_id': {'key': 'requesterObjectId', 'type': 'str'}, - 'approved_time': {'key': 'approvedTime', 'type': 'iso-8601'}, - 'approver': {'key': 'approver', 'type': 'str'}, + "requested_time": {"key": "requestedTime", "type": "iso-8601"}, + "requester": {"key": "requester", "type": "str"}, + "requester_object_id": {"key": "requesterObjectId", "type": "str"}, + "approved_time": {"key": "approvedTime", "type": "iso-8601"}, + "approver": {"key": "approver", "type": "str"}, } - def __init__( - self, - **kwargs - ): - """ - """ - super(AuthorizationProfile, self).__init__(**kwargs) + def __init__(self, **kwargs): + """ """ + super().__init__(**kwargs) self.requested_time = None self.requester = None self.requester_object_id = None @@ -61,7 +59,7 @@ def __init__( self.approver = None -class ErrorDefinition(msrest.serialization.Model): +class ErrorDefinition(_serialization.Model): """Error definition. Variables are only populated by the server, and will be ignored when sending a request. @@ -75,33 +73,28 @@ class ErrorDefinition(msrest.serialization.Model): """ _validation = { - 'code': {'readonly': True}, - 'message': {'readonly': True}, + "code": {"readonly": True}, + "message": {"readonly": True}, } _attribute_map = { - 'code': {'key': 'code', 'type': 'str'}, - 'message': {'key': 'message', 'type': 'str'}, - 'details': {'key': 'details', 'type': '[ErrorDefinition]'}, + "code": {"key": "code", "type": "str"}, + "message": {"key": "message", "type": "str"}, + "details": {"key": "details", "type": "[ErrorDefinition]"}, } - def __init__( - self, - *, - details: Optional[List["ErrorDefinition"]] = None, - **kwargs - ): + def __init__(self, *, details: Optional[List["_models.ErrorDefinition"]] = None, **kwargs): """ :keyword details: Internal error details. :paramtype details: list[~azure.mgmt.resource.features.v2021_07_01.models.ErrorDefinition] """ - super(ErrorDefinition, self).__init__(**kwargs) + super().__init__(**kwargs) self.code = None self.message = None self.details = details -class ErrorResponse(msrest.serialization.Model): +class ErrorResponse(_serialization.Model): """Error response indicates that the service is not able to process the incoming request. :ivar error: The error details. @@ -109,24 +102,19 @@ class ErrorResponse(msrest.serialization.Model): """ _attribute_map = { - 'error': {'key': 'error', 'type': 'ErrorDefinition'}, + "error": {"key": "error", "type": "ErrorDefinition"}, } - def __init__( - self, - *, - error: Optional["ErrorDefinition"] = None, - **kwargs - ): + def __init__(self, *, error: Optional["_models.ErrorDefinition"] = None, **kwargs): """ :keyword error: The error details. :paramtype error: ~azure.mgmt.resource.features.v2021_07_01.models.ErrorDefinition """ - super(ErrorResponse, self).__init__(**kwargs) + super().__init__(**kwargs) self.error = error -class FeatureOperationsListResult(msrest.serialization.Model): +class FeatureOperationsListResult(_serialization.Model): """List of previewed features. :ivar value: The array of features. @@ -136,16 +124,12 @@ class FeatureOperationsListResult(msrest.serialization.Model): """ _attribute_map = { - 'value': {'key': 'value', 'type': '[FeatureResult]'}, - 'next_link': {'key': 'nextLink', 'type': 'str'}, + "value": {"key": "value", "type": "[FeatureResult]"}, + "next_link": {"key": "nextLink", "type": "str"}, } def __init__( - self, - *, - value: Optional[List["FeatureResult"]] = None, - next_link: Optional[str] = None, - **kwargs + self, *, value: Optional[List["_models.FeatureResult"]] = None, next_link: Optional[str] = None, **kwargs ): """ :keyword value: The array of features. @@ -153,12 +137,12 @@ def __init__( :keyword next_link: The URL to use for getting the next set of results. :paramtype next_link: str """ - super(FeatureOperationsListResult, self).__init__(**kwargs) + super().__init__(**kwargs) self.value = value self.next_link = next_link -class FeatureProperties(msrest.serialization.Model): +class FeatureProperties(_serialization.Model): """Information about feature. :ivar state: The registration state of the feature for the subscription. @@ -166,24 +150,19 @@ class FeatureProperties(msrest.serialization.Model): """ _attribute_map = { - 'state': {'key': 'state', 'type': 'str'}, + "state": {"key": "state", "type": "str"}, } - def __init__( - self, - *, - state: Optional[str] = None, - **kwargs - ): + def __init__(self, *, state: Optional[str] = None, **kwargs): """ :keyword state: The registration state of the feature for the subscription. :paramtype state: str """ - super(FeatureProperties, self).__init__(**kwargs) + super().__init__(**kwargs) self.state = state -class FeatureResult(msrest.serialization.Model): +class FeatureResult(_serialization.Model): """Previewed feature information. :ivar name: The name of the feature. @@ -197,18 +176,18 @@ class FeatureResult(msrest.serialization.Model): """ _attribute_map = { - 'name': {'key': 'name', 'type': 'str'}, - 'properties': {'key': 'properties', 'type': 'FeatureProperties'}, - 'id': {'key': 'id', 'type': 'str'}, - 'type': {'key': 'type', 'type': 'str'}, + "name": {"key": "name", "type": "str"}, + "properties": {"key": "properties", "type": "FeatureProperties"}, + "id": {"key": "id", "type": "str"}, + "type": {"key": "type", "type": "str"}, } def __init__( self, *, name: Optional[str] = None, - properties: Optional["FeatureProperties"] = None, - id: Optional[str] = None, + properties: Optional["_models.FeatureProperties"] = None, + id: Optional[str] = None, # pylint: disable=redefined-builtin type: Optional[str] = None, **kwargs ): @@ -222,14 +201,14 @@ def __init__( :keyword type: The resource type of the feature. :paramtype type: str """ - super(FeatureResult, self).__init__(**kwargs) + super().__init__(**kwargs) self.name = name self.properties = properties self.id = id self.type = type -class Operation(msrest.serialization.Model): +class Operation(_serialization.Model): """Microsoft.Features operation. :ivar name: Operation name: {provider}/{resource}/{operation}. @@ -239,29 +218,23 @@ class Operation(msrest.serialization.Model): """ _attribute_map = { - 'name': {'key': 'name', 'type': 'str'}, - 'display': {'key': 'display', 'type': 'OperationDisplay'}, + "name": {"key": "name", "type": "str"}, + "display": {"key": "display", "type": "OperationDisplay"}, } - def __init__( - self, - *, - name: Optional[str] = None, - display: Optional["OperationDisplay"] = None, - **kwargs - ): + def __init__(self, *, name: Optional[str] = None, display: Optional["_models.OperationDisplay"] = None, **kwargs): """ :keyword name: Operation name: {provider}/{resource}/{operation}. :paramtype name: str :keyword display: The object that represents the operation. :paramtype display: ~azure.mgmt.resource.features.v2021_07_01.models.OperationDisplay """ - super(Operation, self).__init__(**kwargs) + super().__init__(**kwargs) self.name = name self.display = display -class OperationDisplay(msrest.serialization.Model): +class OperationDisplay(_serialization.Model): """The object that represents the operation. :ivar provider: Service provider: Microsoft.Features. @@ -273,9 +246,9 @@ class OperationDisplay(msrest.serialization.Model): """ _attribute_map = { - 'provider': {'key': 'provider', 'type': 'str'}, - 'resource': {'key': 'resource', 'type': 'str'}, - 'operation': {'key': 'operation', 'type': 'str'}, + "provider": {"key": "provider", "type": "str"}, + "resource": {"key": "resource", "type": "str"}, + "operation": {"key": "operation", "type": "str"}, } def __init__( @@ -294,13 +267,13 @@ def __init__( :keyword operation: Operation type: Read, write, delete, etc. :paramtype operation: str """ - super(OperationDisplay, self).__init__(**kwargs) + super().__init__(**kwargs) self.provider = provider self.resource = resource self.operation = operation -class OperationListResult(msrest.serialization.Model): +class OperationListResult(_serialization.Model): """Result of the request to list Microsoft.Features operations. It contains a list of operations and a URL link to get the next set of results. :ivar value: List of Microsoft.Features operations. @@ -310,29 +283,23 @@ class OperationListResult(msrest.serialization.Model): """ _attribute_map = { - 'value': {'key': 'value', 'type': '[Operation]'}, - 'next_link': {'key': 'nextLink', 'type': 'str'}, + "value": {"key": "value", "type": "[Operation]"}, + "next_link": {"key": "nextLink", "type": "str"}, } - def __init__( - self, - *, - value: Optional[List["Operation"]] = None, - next_link: Optional[str] = None, - **kwargs - ): + def __init__(self, *, value: Optional[List["_models.Operation"]] = None, next_link: Optional[str] = None, **kwargs): """ :keyword value: List of Microsoft.Features operations. :paramtype value: list[~azure.mgmt.resource.features.v2021_07_01.models.Operation] :keyword next_link: URL to get the next set of operation list results if there are any. :paramtype next_link: str """ - super(OperationListResult, self).__init__(**kwargs) + super().__init__(**kwargs) self.value = value self.next_link = next_link -class ProxyResource(msrest.serialization.Model): +class ProxyResource(_serialization.Model): """An Azure proxy resource. Variables are only populated by the server, and will be ignored when sending a request. @@ -346,24 +313,20 @@ class ProxyResource(msrest.serialization.Model): """ _validation = { - 'id': {'readonly': True}, - 'name': {'readonly': True}, - 'type': {'readonly': True}, + "id": {"readonly": True}, + "name": {"readonly": True}, + "type": {"readonly": True}, } _attribute_map = { - 'id': {'key': 'id', 'type': 'str'}, - 'name': {'key': 'name', 'type': 'str'}, - 'type': {'key': 'type', 'type': 'str'}, + "id": {"key": "id", "type": "str"}, + "name": {"key": "name", "type": "str"}, + "type": {"key": "type", "type": "str"}, } - def __init__( - self, - **kwargs - ): - """ - """ - super(ProxyResource, self).__init__(**kwargs) + def __init__(self, **kwargs): + """ """ + super().__init__(**kwargs) self.id = None self.name = None self.type = None @@ -386,34 +349,29 @@ class SubscriptionFeatureRegistration(ProxyResource): """ _validation = { - 'id': {'readonly': True}, - 'name': {'readonly': True}, - 'type': {'readonly': True}, + "id": {"readonly": True}, + "name": {"readonly": True}, + "type": {"readonly": True}, } _attribute_map = { - 'id': {'key': 'id', 'type': 'str'}, - 'name': {'key': 'name', 'type': 'str'}, - 'type': {'key': 'type', 'type': 'str'}, - 'properties': {'key': 'properties', 'type': 'SubscriptionFeatureRegistrationProperties'}, + "id": {"key": "id", "type": "str"}, + "name": {"key": "name", "type": "str"}, + "type": {"key": "type", "type": "str"}, + "properties": {"key": "properties", "type": "SubscriptionFeatureRegistrationProperties"}, } - def __init__( - self, - *, - properties: Optional["SubscriptionFeatureRegistrationProperties"] = None, - **kwargs - ): + def __init__(self, *, properties: Optional["_models.SubscriptionFeatureRegistrationProperties"] = None, **kwargs): """ :keyword properties: :paramtype properties: ~azure.mgmt.resource.features.v2021_07_01.models.SubscriptionFeatureRegistrationProperties """ - super(SubscriptionFeatureRegistration, self).__init__(**kwargs) + super().__init__(**kwargs) self.properties = properties -class SubscriptionFeatureRegistrationList(msrest.serialization.Model): +class SubscriptionFeatureRegistrationList(_serialization.Model): """The list of subscription feature registrations. :ivar next_link: The link used to get the next page of subscription feature registrations list. @@ -424,15 +382,15 @@ class SubscriptionFeatureRegistrationList(msrest.serialization.Model): """ _attribute_map = { - 'next_link': {'key': 'nextLink', 'type': 'str'}, - 'value': {'key': 'value', 'type': '[SubscriptionFeatureRegistration]'}, + "next_link": {"key": "nextLink", "type": "str"}, + "value": {"key": "value", "type": "[SubscriptionFeatureRegistration]"}, } def __init__( self, *, next_link: Optional[str] = None, - value: Optional[List["SubscriptionFeatureRegistration"]] = None, + value: Optional[List["_models.SubscriptionFeatureRegistration"]] = None, **kwargs ): """ @@ -443,12 +401,12 @@ def __init__( :paramtype value: list[~azure.mgmt.resource.features.v2021_07_01.models.SubscriptionFeatureRegistration] """ - super(SubscriptionFeatureRegistrationList, self).__init__(**kwargs) + super().__init__(**kwargs) self.next_link = next_link self.value = value -class SubscriptionFeatureRegistrationProperties(msrest.serialization.Model): +class SubscriptionFeatureRegistrationProperties(_serialization.Model): # pylint: disable=too-many-instance-attributes """SubscriptionFeatureRegistrationProperties. Variables are only populated by the server, and will be ignored when sending a request. @@ -463,8 +421,8 @@ class SubscriptionFeatureRegistrationProperties(msrest.serialization.Model): :vartype display_name: str :ivar provider_namespace: The providerNamespace. :vartype provider_namespace: str - :ivar state: The state. Possible values include: "NotSpecified", "NotRegistered", "Pending", - "Registering", "Registered", "Unregistering", "Unregistered". + :ivar state: The state. Known values are: "NotSpecified", "NotRegistered", "Pending", + "Registering", "Registered", "Unregistering", and "Unregistered". :vartype state: str or ~azure.mgmt.resource.features.v2021_07_01.models.SubscriptionFeatureRegistrationState :ivar authorization_profile: Authorization Profile. @@ -478,8 +436,8 @@ class SubscriptionFeatureRegistrationProperties(msrest.serialization.Model): :vartype registration_date: ~datetime.datetime :ivar documentation_link: The feature documentation link. :vartype documentation_link: str - :ivar approval_type: The feature approval type. Possible values include: "NotSpecified", - "ApprovalRequired", "AutoApproval". + :ivar approval_type: The feature approval type. Known values are: "NotSpecified", + "ApprovalRequired", and "AutoApproval". :vartype approval_type: str or ~azure.mgmt.resource.features.v2021_07_01.models.SubscriptionFeatureRegistrationApprovalType :ivar should_feature_display_in_portal: Indicates whether feature should be displayed in @@ -490,48 +448,48 @@ class SubscriptionFeatureRegistrationProperties(msrest.serialization.Model): """ _validation = { - 'tenant_id': {'readonly': True}, - 'subscription_id': {'readonly': True}, - 'feature_name': {'readonly': True}, - 'display_name': {'readonly': True}, - 'provider_namespace': {'readonly': True}, - 'release_date': {'readonly': True}, - 'registration_date': {'readonly': True}, - 'documentation_link': {'readonly': True, 'max_length': 1000, 'min_length': 0}, - 'approval_type': {'readonly': True}, - 'description': {'max_length': 1000, 'min_length': 0}, + "tenant_id": {"readonly": True}, + "subscription_id": {"readonly": True}, + "feature_name": {"readonly": True}, + "display_name": {"readonly": True}, + "provider_namespace": {"readonly": True}, + "release_date": {"readonly": True}, + "registration_date": {"readonly": True}, + "documentation_link": {"readonly": True, "max_length": 1000}, + "approval_type": {"readonly": True}, + "description": {"max_length": 1000}, } _attribute_map = { - 'tenant_id': {'key': 'tenantId', 'type': 'str'}, - 'subscription_id': {'key': 'subscriptionId', 'type': 'str'}, - 'feature_name': {'key': 'featureName', 'type': 'str'}, - 'display_name': {'key': 'displayName', 'type': 'str'}, - 'provider_namespace': {'key': 'providerNamespace', 'type': 'str'}, - 'state': {'key': 'state', 'type': 'str'}, - 'authorization_profile': {'key': 'authorizationProfile', 'type': 'AuthorizationProfile'}, - 'metadata': {'key': 'metadata', 'type': '{str}'}, - 'release_date': {'key': 'releaseDate', 'type': 'iso-8601'}, - 'registration_date': {'key': 'registrationDate', 'type': 'iso-8601'}, - 'documentation_link': {'key': 'documentationLink', 'type': 'str'}, - 'approval_type': {'key': 'approvalType', 'type': 'str'}, - 'should_feature_display_in_portal': {'key': 'shouldFeatureDisplayInPortal', 'type': 'bool'}, - 'description': {'key': 'description', 'type': 'str'}, + "tenant_id": {"key": "tenantId", "type": "str"}, + "subscription_id": {"key": "subscriptionId", "type": "str"}, + "feature_name": {"key": "featureName", "type": "str"}, + "display_name": {"key": "displayName", "type": "str"}, + "provider_namespace": {"key": "providerNamespace", "type": "str"}, + "state": {"key": "state", "type": "str"}, + "authorization_profile": {"key": "authorizationProfile", "type": "AuthorizationProfile"}, + "metadata": {"key": "metadata", "type": "{str}"}, + "release_date": {"key": "releaseDate", "type": "iso-8601"}, + "registration_date": {"key": "registrationDate", "type": "iso-8601"}, + "documentation_link": {"key": "documentationLink", "type": "str"}, + "approval_type": {"key": "approvalType", "type": "str"}, + "should_feature_display_in_portal": {"key": "shouldFeatureDisplayInPortal", "type": "bool"}, + "description": {"key": "description", "type": "str"}, } def __init__( self, *, - state: Optional[Union[str, "SubscriptionFeatureRegistrationState"]] = None, - authorization_profile: Optional["AuthorizationProfile"] = None, + state: Optional[Union[str, "_models.SubscriptionFeatureRegistrationState"]] = None, + authorization_profile: Optional["_models.AuthorizationProfile"] = None, metadata: Optional[Dict[str, str]] = None, - should_feature_display_in_portal: Optional[bool] = False, + should_feature_display_in_portal: bool = False, description: Optional[str] = None, **kwargs ): """ - :keyword state: The state. Possible values include: "NotSpecified", "NotRegistered", "Pending", - "Registering", "Registered", "Unregistering", "Unregistered". + :keyword state: The state. Known values are: "NotSpecified", "NotRegistered", "Pending", + "Registering", "Registered", "Unregistering", and "Unregistered". :paramtype state: str or ~azure.mgmt.resource.features.v2021_07_01.models.SubscriptionFeatureRegistrationState :keyword authorization_profile: Authorization Profile. @@ -545,7 +503,7 @@ def __init__( :keyword description: The feature description. :paramtype description: str """ - super(SubscriptionFeatureRegistrationProperties, self).__init__(**kwargs) + super().__init__(**kwargs) self.tenant_id = None self.subscription_id = None self.feature_name = None diff --git a/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/features/v2021_07_01/models/_patch.py b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/features/v2021_07_01/models/_patch.py new file mode 100644 index 0000000000000..f7dd32510333d --- /dev/null +++ b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/features/v2021_07_01/models/_patch.py @@ -0,0 +1,20 @@ +# ------------------------------------ +# Copyright (c) Microsoft Corporation. +# Licensed under the MIT License. +# ------------------------------------ +"""Customize generated code here. + +Follow our quickstart for examples: https://aka.ms/azsdk/python/dpcodegen/python/customize +""" +from typing import List + +__all__: List[str] = [] # Add all objects you want publicly available to users at this package level + + +def patch_sdk(): + """Do not remove from this file. + + `patch_sdk` is a last resort escape hatch that allows you to do customizations + you can't accomplish using the techniques described in + https://aka.ms/azsdk/python/dpcodegen/python/customize + """ diff --git a/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/features/v2021_07_01/operations/__init__.py b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/features/v2021_07_01/operations/__init__.py index bfda220abc66d..7a3fdf7ac696e 100644 --- a/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/features/v2021_07_01/operations/__init__.py +++ b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/features/v2021_07_01/operations/__init__.py @@ -10,8 +10,14 @@ from ._operations import FeaturesOperations from ._operations import SubscriptionFeatureRegistrationsOperations +from ._patch import __all__ as _patch_all +from ._patch import * # type: ignore # pylint: disable=unused-wildcard-import +from ._patch import patch_sdk as _patch_sdk + __all__ = [ - 'FeatureClientOperationsMixin', - 'FeaturesOperations', - 'SubscriptionFeatureRegistrationsOperations', + "FeatureClientOperationsMixin", + "FeaturesOperations", + "SubscriptionFeatureRegistrationsOperations", ] +__all__.extend([p for p in _patch_all if p not in __all__]) +_patch_sdk() diff --git a/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/features/v2021_07_01/operations/_operations.py b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/features/v2021_07_01/operations/_operations.py index bd9190787ed6e..0cbb8ad642386 100644 --- a/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/features/v2021_07_01/operations/_operations.py +++ b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/features/v2021_07_01/operations/_operations.py @@ -6,447 +6,399 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -from typing import Any, Callable, Dict, Iterable, Optional, TypeVar - -from msrest import Serializer - -from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error +from typing import Any, Callable, Dict, IO, Iterable, Optional, TypeVar, Union, overload +from urllib.parse import parse_qs, urljoin, urlparse + +from azure.core.exceptions import ( + ClientAuthenticationError, + HttpResponseError, + ResourceExistsError, + ResourceNotFoundError, + ResourceNotModifiedError, + map_error, +) from azure.core.paging import ItemPaged from azure.core.pipeline import PipelineResponse from azure.core.pipeline.transport import HttpResponse from azure.core.rest import HttpRequest from azure.core.tracing.decorator import distributed_trace +from azure.core.utils import case_insensitive_dict from azure.mgmt.core.exceptions import ARMErrorFormat from .. import models as _models -from .._vendor import _convert_request, _format_url_section -T = TypeVar('T') +from ..._serialization import Serializer +from .._vendor import MixinABC, _convert_request, _format_url_section + +T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] -JSONType = Any _SERIALIZER = Serializer() _SERIALIZER.client_side_validation = False -def build_list_operations_request( - **kwargs: Any -) -> HttpRequest: - api_version = kwargs.pop('api_version', "2021-07-01") # type: str - accept = "application/json, text/json" +def build_list_operations_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-07-01")) # type: str + accept = _headers.pop("Accept", "application/json, text/json") + # Construct URL _url = kwargs.pop("template_url", "/providers/Microsoft.Features/operations") # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - return HttpRequest( - method="GET", - url=_url, - params=_query_parameters, - headers=_header_parameters, - **kwargs - ) + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) -def build_features_list_all_request( - subscription_id: str, - **kwargs: Any -) -> HttpRequest: - api_version = kwargs.pop('api_version', "2021-07-01") # type: str +def build_features_list_all_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-07-01")) # type: str + accept = _headers.pop("Accept", "application/json, text/json") - accept = "application/json, text/json" # Construct URL _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/providers/Microsoft.Features/features") path_format_arguments = { - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), } _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') - - return HttpRequest( - method="GET", - url=_url, - params=_query_parameters, - headers=_header_parameters, - **kwargs - ) - - -def build_features_list_request( - resource_provider_namespace: str, - subscription_id: str, - **kwargs: Any -) -> HttpRequest: - api_version = kwargs.pop('api_version', "2021-07-01") # type: str + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) + + +def build_features_list_request(resource_provider_namespace: str, subscription_id: str, **kwargs: Any) -> HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-07-01")) # type: str + accept = _headers.pop("Accept", "application/json, text/json") - accept = "application/json, text/json" # Construct URL - _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/providers/Microsoft.Features/providers/{resourceProviderNamespace}/features") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/providers/Microsoft.Features/providers/{resourceProviderNamespace}/features", + ) # pylint: disable=line-too-long path_format_arguments = { - "resourceProviderNamespace": _SERIALIZER.url("resource_provider_namespace", resource_provider_namespace, 'str'), - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), + "resourceProviderNamespace": _SERIALIZER.url("resource_provider_namespace", resource_provider_namespace, "str"), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), } _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - return HttpRequest( - method="GET", - url=_url, - params=_query_parameters, - headers=_header_parameters, - **kwargs - ) + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) def build_features_get_request( - resource_provider_namespace: str, - feature_name: str, - subscription_id: str, - **kwargs: Any + resource_provider_namespace: str, feature_name: str, subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2021-07-01") # type: 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-07-01")) # type: str + accept = _headers.pop("Accept", "application/json, text/json") - accept = "application/json, text/json" # Construct URL - _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/providers/Microsoft.Features/providers/{resourceProviderNamespace}/features/{featureName}") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/providers/Microsoft.Features/providers/{resourceProviderNamespace}/features/{featureName}", + ) # pylint: disable=line-too-long path_format_arguments = { - "resourceProviderNamespace": _SERIALIZER.url("resource_provider_namespace", resource_provider_namespace, 'str'), - "featureName": _SERIALIZER.url("feature_name", feature_name, 'str'), - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), + "resourceProviderNamespace": _SERIALIZER.url("resource_provider_namespace", resource_provider_namespace, "str"), + "featureName": _SERIALIZER.url("feature_name", feature_name, "str"), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), } _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - return HttpRequest( - method="GET", - url=_url, - params=_query_parameters, - headers=_header_parameters, - **kwargs - ) + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) def build_features_register_request( - resource_provider_namespace: str, - feature_name: str, - subscription_id: str, - **kwargs: Any + resource_provider_namespace: str, feature_name: str, subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2021-07-01") # type: 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-07-01")) # type: str + accept = _headers.pop("Accept", "application/json, text/json") - accept = "application/json, text/json" # Construct URL - _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/providers/Microsoft.Features/providers/{resourceProviderNamespace}/features/{featureName}/register") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/providers/Microsoft.Features/providers/{resourceProviderNamespace}/features/{featureName}/register", + ) # pylint: disable=line-too-long path_format_arguments = { - "resourceProviderNamespace": _SERIALIZER.url("resource_provider_namespace", resource_provider_namespace, 'str'), - "featureName": _SERIALIZER.url("feature_name", feature_name, 'str'), - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), + "resourceProviderNamespace": _SERIALIZER.url("resource_provider_namespace", resource_provider_namespace, "str"), + "featureName": _SERIALIZER.url("feature_name", feature_name, "str"), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), } _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - return HttpRequest( - method="POST", - url=_url, - params=_query_parameters, - headers=_header_parameters, - **kwargs - ) + return HttpRequest(method="POST", url=_url, params=_params, headers=_headers, **kwargs) def build_features_unregister_request( - resource_provider_namespace: str, - feature_name: str, - subscription_id: str, - **kwargs: Any + resource_provider_namespace: str, feature_name: str, subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2021-07-01") # type: 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-07-01")) # type: str + accept = _headers.pop("Accept", "application/json, text/json") - accept = "application/json, text/json" # Construct URL - _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/providers/Microsoft.Features/providers/{resourceProviderNamespace}/features/{featureName}/unregister") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/providers/Microsoft.Features/providers/{resourceProviderNamespace}/features/{featureName}/unregister", + ) # pylint: disable=line-too-long path_format_arguments = { - "resourceProviderNamespace": _SERIALIZER.url("resource_provider_namespace", resource_provider_namespace, 'str'), - "featureName": _SERIALIZER.url("feature_name", feature_name, 'str'), - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), + "resourceProviderNamespace": _SERIALIZER.url("resource_provider_namespace", resource_provider_namespace, "str"), + "featureName": _SERIALIZER.url("feature_name", feature_name, "str"), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), } _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - return HttpRequest( - method="POST", - url=_url, - params=_query_parameters, - headers=_header_parameters, - **kwargs - ) + return HttpRequest(method="POST", url=_url, params=_params, headers=_headers, **kwargs) def build_subscription_feature_registrations_get_request( - subscription_id: str, - provider_namespace: str, - feature_name: str, - **kwargs: Any + provider_namespace: str, feature_name: str, subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2021-07-01") # type: 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-07-01")) # type: str + accept = _headers.pop("Accept", "application/json") - accept = "application/json" # Construct URL - _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/providers/Microsoft.Features/featureProviders/{providerNamespace}/subscriptionFeatureRegistrations/{featureName}") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/providers/Microsoft.Features/featureProviders/{providerNamespace}/subscriptionFeatureRegistrations/{featureName}", + ) # pylint: disable=line-too-long path_format_arguments = { - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), - "providerNamespace": _SERIALIZER.url("provider_namespace", provider_namespace, 'str'), - "featureName": _SERIALIZER.url("feature_name", feature_name, 'str'), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "providerNamespace": _SERIALIZER.url("provider_namespace", provider_namespace, "str"), + "featureName": _SERIALIZER.url("feature_name", feature_name, "str"), } _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - return HttpRequest( - method="GET", - url=_url, - params=_query_parameters, - headers=_header_parameters, - **kwargs - ) + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) def build_subscription_feature_registrations_create_or_update_request( - subscription_id: str, - provider_namespace: str, - feature_name: str, - *, - json: JSONType = None, - content: Any = None, - **kwargs: Any + provider_namespace: str, feature_name: str, subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2021-07-01") # type: str - content_type = kwargs.pop('content_type', None) # type: Optional[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-07-01")) # type: str + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + accept = _headers.pop("Accept", "application/json") - accept = "application/json" # Construct URL - _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/providers/Microsoft.Features/featureProviders/{providerNamespace}/subscriptionFeatureRegistrations/{featureName}") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/providers/Microsoft.Features/featureProviders/{providerNamespace}/subscriptionFeatureRegistrations/{featureName}", + ) # pylint: disable=line-too-long path_format_arguments = { - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), - "providerNamespace": _SERIALIZER.url("provider_namespace", provider_namespace, 'str'), - "featureName": _SERIALIZER.url("feature_name", feature_name, 'str'), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "providerNamespace": _SERIALIZER.url("provider_namespace", provider_namespace, "str"), + "featureName": _SERIALIZER.url("feature_name", feature_name, "str"), } _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] if content_type is not None: - _header_parameters['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') - _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers["Content-Type"] = _SERIALIZER.header("content_type", content_type, "str") + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - return HttpRequest( - method="PUT", - url=_url, - params=_query_parameters, - headers=_header_parameters, - json=json, - content=content, - **kwargs - ) + return HttpRequest(method="PUT", url=_url, params=_params, headers=_headers, **kwargs) def build_subscription_feature_registrations_delete_request( - subscription_id: str, - provider_namespace: str, - feature_name: str, - **kwargs: Any + provider_namespace: str, feature_name: str, subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2021-07-01") # type: 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-07-01")) # type: str + accept = _headers.pop("Accept", "application/json") - accept = "application/json" # Construct URL - _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/providers/Microsoft.Features/featureProviders/{providerNamespace}/subscriptionFeatureRegistrations/{featureName}") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/providers/Microsoft.Features/featureProviders/{providerNamespace}/subscriptionFeatureRegistrations/{featureName}", + ) # pylint: disable=line-too-long path_format_arguments = { - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), - "providerNamespace": _SERIALIZER.url("provider_namespace", provider_namespace, 'str'), - "featureName": _SERIALIZER.url("feature_name", feature_name, 'str'), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "providerNamespace": _SERIALIZER.url("provider_namespace", provider_namespace, "str"), + "featureName": _SERIALIZER.url("feature_name", feature_name, "str"), } _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - return HttpRequest( - method="DELETE", - url=_url, - params=_query_parameters, - headers=_header_parameters, - **kwargs - ) + return HttpRequest(method="DELETE", url=_url, params=_params, headers=_headers, **kwargs) def build_subscription_feature_registrations_list_by_subscription_request( - subscription_id: str, - provider_namespace: str, - **kwargs: Any + provider_namespace: str, subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2021-07-01") # type: 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-07-01")) # type: str + accept = _headers.pop("Accept", "application/json") - accept = "application/json" # Construct URL - _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/providers/Microsoft.Features/featureProviders/{providerNamespace}/subscriptionFeatureRegistrations") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/providers/Microsoft.Features/featureProviders/{providerNamespace}/subscriptionFeatureRegistrations", + ) # pylint: disable=line-too-long path_format_arguments = { - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), - "providerNamespace": _SERIALIZER.url("provider_namespace", provider_namespace, 'str'), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "providerNamespace": _SERIALIZER.url("provider_namespace", provider_namespace, "str"), } _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - return HttpRequest( - method="GET", - url=_url, - params=_query_parameters, - headers=_header_parameters, - **kwargs - ) + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) def build_subscription_feature_registrations_list_all_by_subscription_request( - subscription_id: str, - **kwargs: Any + subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2021-07-01") # type: 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-07-01")) # type: str + accept = _headers.pop("Accept", "application/json") - accept = "application/json" # Construct URL - _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/providers/Microsoft.Features/subscriptionFeatureRegistrations") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", "/subscriptions/{subscriptionId}/providers/Microsoft.Features/subscriptionFeatureRegistrations" + ) # pylint: disable=line-too-long path_format_arguments = { - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), } _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - return HttpRequest( - method="GET", - url=_url, - params=_query_parameters, - headers=_header_parameters, - **kwargs - ) + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) -class FeatureClientOperationsMixin(object): +class FeatureClientOperationsMixin(MixinABC): @distributed_trace - def list_operations( - self, - **kwargs: Any - ) -> Iterable["_models.OperationListResult"]: + def list_operations(self, **kwargs: Any) -> Iterable["_models.Operation"]: """Lists all of the available Microsoft.Features REST API operations. :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either OperationListResult or the result of cls(response) + :return: An iterator like instance of either Operation or the result of cls(response) :rtype: - ~azure.core.paging.ItemPaged[~azure.mgmt.resource.features.v2021_07_01.models.OperationListResult] - :raises: ~azure.core.exceptions.HttpResponseError + ~azure.core.paging.ItemPaged[~azure.mgmt.resource.features.v2021_07_01.models.Operation] + :raises ~azure.core.exceptions.HttpResponseError: """ - api_version = kwargs.pop('api_version', "2021-07-01") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-07-01")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[_models.OperationListResult] - cls = kwargs.pop('cls', None) # type: ClsType["_models.OperationListResult"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) + def prepare_request(next_link=None): if not next_link: - + request = build_list_operations_request( api_version=api_version, - template_url=self.list_operations.metadata['url'], + template_url=self.list_operations.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore else: - - request = build_list_operations_request( - template_url=next_link, - ) + # make call to next link with the client's api-version + _parsed_next_link = urlparse(next_link) + _next_request_params = case_insensitive_dict(parse_qs(_parsed_next_link.query)) + _next_request_params["api-version"] = self._config.api_version + request = HttpRequest("GET", urljoin(next_link, _parsed_next_link.path), params=_next_request_params) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore request.method = "GET" return request @@ -460,10 +412,8 @@ def extract_data(pipeline_response): def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) response = pipeline_response.http_response @@ -474,73 +424,75 @@ def get_next(next_link=None): return pipeline_response + return ItemPaged(get_next, extract_data) - return ItemPaged( - get_next, extract_data - ) - list_operations.metadata = {'url': "/providers/Microsoft.Features/operations"} # type: ignore -class FeaturesOperations(object): - """FeaturesOperations operations. - - You should not instantiate this class directly. Instead, you should create a Client instance that - instantiates it for you and attaches it as an attribute. - - :ivar models: Alias to model classes used in this operation group. - :type models: ~azure.mgmt.resource.features.v2021_07_01.models - :param client: Client for service requests. - :param config: Configuration of service client. - :param serializer: An object model serializer. - :param deserializer: An object model deserializer. + list_operations.metadata = {"url": "/providers/Microsoft.Features/operations"} # type: ignore + + +class FeaturesOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. + + Instead, you should access the following operations through + :class:`~azure.mgmt.resource.features.v2021_07_01.FeatureClient`'s + :attr:`features` attribute. """ models = _models - def __init__(self, client, config, serializer, deserializer): - self._client = client - self._serialize = serializer - self._deserialize = deserializer - self._config = config + def __init__(self, *args, **kwargs): + input_args = list(args) + self._client = input_args.pop(0) if input_args else kwargs.pop("client") + self._config = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") @distributed_trace - def list_all( - self, - **kwargs: Any - ) -> Iterable["_models.FeatureOperationsListResult"]: + def list_all(self, **kwargs: Any) -> Iterable["_models.FeatureResult"]: """Gets all the preview features that are available through AFEC for the subscription. :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either FeatureOperationsListResult or the result of - cls(response) + :return: An iterator like instance of either FeatureResult or the result of cls(response) :rtype: - ~azure.core.paging.ItemPaged[~azure.mgmt.resource.features.v2021_07_01.models.FeatureOperationsListResult] - :raises: ~azure.core.exceptions.HttpResponseError + ~azure.core.paging.ItemPaged[~azure.mgmt.resource.features.v2021_07_01.models.FeatureResult] + :raises ~azure.core.exceptions.HttpResponseError: """ - api_version = kwargs.pop('api_version', "2021-07-01") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-07-01")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[_models.FeatureOperationsListResult] - cls = kwargs.pop('cls', None) # type: ClsType["_models.FeatureOperationsListResult"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) + def prepare_request(next_link=None): if not next_link: - + request = build_features_list_all_request( subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.list_all.metadata['url'], + template_url=self.list_all.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore else: - - request = build_features_list_all_request( - subscription_id=self._config.subscription_id, - template_url=next_link, - ) + # make call to next link with the client's api-version + _parsed_next_link = urlparse(next_link) + _next_request_params = case_insensitive_dict(parse_qs(_parsed_next_link.query)) + _next_request_params["api-version"] = self._config.api_version + request = HttpRequest("GET", urljoin(next_link, _parsed_next_link.path), params=_next_request_params) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore request.method = "GET" return request @@ -554,10 +506,8 @@ def extract_data(pipeline_response): def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) response = pipeline_response.http_response @@ -568,59 +518,60 @@ def get_next(next_link=None): return pipeline_response + return ItemPaged(get_next, extract_data) - return ItemPaged( - get_next, extract_data - ) - list_all.metadata = {'url': "/subscriptions/{subscriptionId}/providers/Microsoft.Features/features"} # type: ignore + list_all.metadata = {"url": "/subscriptions/{subscriptionId}/providers/Microsoft.Features/features"} # type: ignore @distributed_trace - def list( - self, - resource_provider_namespace: str, - **kwargs: Any - ) -> Iterable["_models.FeatureOperationsListResult"]: + def list(self, resource_provider_namespace: str, **kwargs: Any) -> Iterable["_models.FeatureResult"]: """Gets all the preview features in a provider namespace that are available through AFEC for the subscription. :param resource_provider_namespace: The namespace of the resource provider for getting - features. + features. Required. :type resource_provider_namespace: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either FeatureOperationsListResult or the result of - cls(response) + :return: An iterator like instance of either FeatureResult or the result of cls(response) :rtype: - ~azure.core.paging.ItemPaged[~azure.mgmt.resource.features.v2021_07_01.models.FeatureOperationsListResult] - :raises: ~azure.core.exceptions.HttpResponseError + ~azure.core.paging.ItemPaged[~azure.mgmt.resource.features.v2021_07_01.models.FeatureResult] + :raises ~azure.core.exceptions.HttpResponseError: """ - api_version = kwargs.pop('api_version', "2021-07-01") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-07-01")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[_models.FeatureOperationsListResult] - cls = kwargs.pop('cls', None) # type: ClsType["_models.FeatureOperationsListResult"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) + def prepare_request(next_link=None): if not next_link: - + request = build_features_list_request( resource_provider_namespace=resource_provider_namespace, subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.list.metadata['url'], + template_url=self.list.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore else: - - request = build_features_list_request( - resource_provider_namespace=resource_provider_namespace, - subscription_id=self._config.subscription_id, - template_url=next_link, - ) + # make call to next link with the client's api-version + _parsed_next_link = urlparse(next_link) + _next_request_params = case_insensitive_dict(parse_qs(_parsed_next_link.query)) + _next_request_params["api-version"] = self._config.api_version + request = HttpRequest("GET", urljoin(next_link, _parsed_next_link.path), params=_next_request_params) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore request.method = "GET" return request @@ -634,10 +585,8 @@ def extract_data(pipeline_response): def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) response = pipeline_response.http_response @@ -648,54 +597,53 @@ def get_next(next_link=None): return pipeline_response + return ItemPaged(get_next, extract_data) - return ItemPaged( - get_next, extract_data - ) - list.metadata = {'url': "/subscriptions/{subscriptionId}/providers/Microsoft.Features/providers/{resourceProviderNamespace}/features"} # type: ignore + list.metadata = {"url": "/subscriptions/{subscriptionId}/providers/Microsoft.Features/providers/{resourceProviderNamespace}/features"} # type: ignore @distributed_trace - def get( - self, - resource_provider_namespace: str, - feature_name: str, - **kwargs: Any - ) -> "_models.FeatureResult": + def get(self, resource_provider_namespace: str, feature_name: str, **kwargs: Any) -> _models.FeatureResult: """Gets the preview feature with the specified name. - :param resource_provider_namespace: The resource provider namespace for the feature. + :param resource_provider_namespace: The resource provider namespace for the feature. Required. :type resource_provider_namespace: str - :param feature_name: The name of the feature to get. + :param feature_name: The name of the feature to get. Required. :type feature_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: FeatureResult, or the result of cls(response) + :return: FeatureResult or the result of cls(response) :rtype: ~azure.mgmt.resource.features.v2021_07_01.models.FeatureResult - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.FeatureResult"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + 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', "2021-07-01") # type: str + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-07-01")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[_models.FeatureResult] - request = build_features_get_request( resource_provider_namespace=resource_provider_namespace, feature_name=feature_name, subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.get.metadata['url'], + template_url=self.get.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200]: @@ -703,58 +651,58 @@ def get( error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - deserialized = self._deserialize('FeatureResult', pipeline_response) + deserialized = self._deserialize("FeatureResult", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - get.metadata = {'url': "/subscriptions/{subscriptionId}/providers/Microsoft.Features/providers/{resourceProviderNamespace}/features/{featureName}"} # type: ignore - + get.metadata = {"url": "/subscriptions/{subscriptionId}/providers/Microsoft.Features/providers/{resourceProviderNamespace}/features/{featureName}"} # type: ignore @distributed_trace - def register( - self, - resource_provider_namespace: str, - feature_name: str, - **kwargs: Any - ) -> "_models.FeatureResult": + def register(self, resource_provider_namespace: str, feature_name: str, **kwargs: Any) -> _models.FeatureResult: """Registers the preview feature for the subscription. - :param resource_provider_namespace: The namespace of the resource provider. + :param resource_provider_namespace: The namespace of the resource provider. Required. :type resource_provider_namespace: str - :param feature_name: The name of the feature to register. + :param feature_name: The name of the feature to register. Required. :type feature_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: FeatureResult, or the result of cls(response) + :return: FeatureResult or the result of cls(response) :rtype: ~azure.mgmt.resource.features.v2021_07_01.models.FeatureResult - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.FeatureResult"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) - api_version = kwargs.pop('api_version', "2021-07-01") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-07-01")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[_models.FeatureResult] - request = build_features_register_request( resource_provider_namespace=resource_provider_namespace, feature_name=feature_name, subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.register.metadata['url'], + template_url=self.register.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200]: @@ -762,58 +710,58 @@ def register( error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - deserialized = self._deserialize('FeatureResult', pipeline_response) + deserialized = self._deserialize("FeatureResult", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - register.metadata = {'url': "/subscriptions/{subscriptionId}/providers/Microsoft.Features/providers/{resourceProviderNamespace}/features/{featureName}/register"} # type: ignore - + register.metadata = {"url": "/subscriptions/{subscriptionId}/providers/Microsoft.Features/providers/{resourceProviderNamespace}/features/{featureName}/register"} # type: ignore @distributed_trace - def unregister( - self, - resource_provider_namespace: str, - feature_name: str, - **kwargs: Any - ) -> "_models.FeatureResult": + def unregister(self, resource_provider_namespace: str, feature_name: str, **kwargs: Any) -> _models.FeatureResult: """Unregisters the preview feature for the subscription. - :param resource_provider_namespace: The namespace of the resource provider. + :param resource_provider_namespace: The namespace of the resource provider. Required. :type resource_provider_namespace: str - :param feature_name: The name of the feature to unregister. + :param feature_name: The name of the feature to unregister. Required. :type feature_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: FeatureResult, or the result of cls(response) + :return: FeatureResult or the result of cls(response) :rtype: ~azure.mgmt.resource.features.v2021_07_01.models.FeatureResult - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.FeatureResult"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + 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', "2021-07-01") # type: str + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-07-01")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[_models.FeatureResult] - request = build_features_unregister_request( resource_provider_namespace=resource_provider_namespace, feature_name=feature_name, subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.unregister.metadata['url'], + template_url=self.unregister.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200]: @@ -821,79 +769,78 @@ def unregister( error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - deserialized = self._deserialize('FeatureResult', pipeline_response) + deserialized = self._deserialize("FeatureResult", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - unregister.metadata = {'url': "/subscriptions/{subscriptionId}/providers/Microsoft.Features/providers/{resourceProviderNamespace}/features/{featureName}/unregister"} # type: ignore + unregister.metadata = {"url": "/subscriptions/{subscriptionId}/providers/Microsoft.Features/providers/{resourceProviderNamespace}/features/{featureName}/unregister"} # type: ignore -class SubscriptionFeatureRegistrationsOperations(object): - """SubscriptionFeatureRegistrationsOperations operations. - You should not instantiate this class directly. Instead, you should create a Client instance that - instantiates it for you and attaches it as an attribute. +class SubscriptionFeatureRegistrationsOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. - :ivar models: Alias to model classes used in this operation group. - :type models: ~azure.mgmt.resource.features.v2021_07_01.models - :param client: Client for service requests. - :param config: Configuration of service client. - :param serializer: An object model serializer. - :param deserializer: An object model deserializer. + Instead, you should access the following operations through + :class:`~azure.mgmt.resource.features.v2021_07_01.FeatureClient`'s + :attr:`subscription_feature_registrations` attribute. """ models = _models - def __init__(self, client, config, serializer, deserializer): - self._client = client - self._serialize = serializer - self._deserialize = deserializer - self._config = config + def __init__(self, *args, **kwargs): + input_args = list(args) + self._client = input_args.pop(0) if input_args else kwargs.pop("client") + self._config = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") @distributed_trace - def get( - self, - provider_namespace: str, - feature_name: str, - **kwargs: Any - ) -> "_models.SubscriptionFeatureRegistration": + def get(self, provider_namespace: str, feature_name: str, **kwargs: Any) -> _models.SubscriptionFeatureRegistration: """Returns a feature registration. - :param provider_namespace: The provider namespace. + :param provider_namespace: The provider namespace. Required. :type provider_namespace: str - :param feature_name: The feature name. + :param feature_name: The feature name. Required. :type feature_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: SubscriptionFeatureRegistration, or the result of cls(response) + :return: SubscriptionFeatureRegistration or the result of cls(response) :rtype: ~azure.mgmt.resource.features.v2021_07_01.models.SubscriptionFeatureRegistration - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.SubscriptionFeatureRegistration"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + 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', "2021-07-01") # type: str + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-07-01")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[_models.SubscriptionFeatureRegistration] - request = build_subscription_feature_registrations_get_request( - subscription_id=self._config.subscription_id, provider_namespace=provider_namespace, feature_name=feature_name, + subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.get.metadata['url'], + template_url=self.get.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200]: @@ -901,70 +848,143 @@ def get( error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - deserialized = self._deserialize('SubscriptionFeatureRegistration', pipeline_response) + deserialized = self._deserialize("SubscriptionFeatureRegistration", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - get.metadata = {'url': "/subscriptions/{subscriptionId}/providers/Microsoft.Features/featureProviders/{providerNamespace}/subscriptionFeatureRegistrations/{featureName}"} # type: ignore + get.metadata = {"url": "/subscriptions/{subscriptionId}/providers/Microsoft.Features/featureProviders/{providerNamespace}/subscriptionFeatureRegistrations/{featureName}"} # type: ignore - - @distributed_trace + @overload def create_or_update( self, provider_namespace: str, feature_name: str, - subscription_feature_registration_type: Optional["_models.SubscriptionFeatureRegistration"] = None, + subscription_feature_registration_type: Optional[_models.SubscriptionFeatureRegistration] = None, + *, + content_type: str = "application/json", **kwargs: Any - ) -> "_models.SubscriptionFeatureRegistration": + ) -> _models.SubscriptionFeatureRegistration: """Create or update a feature registration. - :param provider_namespace: The provider namespace. + :param provider_namespace: The provider namespace. Required. :type provider_namespace: str - :param feature_name: The feature name. + :param feature_name: The feature name. Required. :type feature_name: str :param subscription_feature_registration_type: Subscription Feature Registration Type details. Default value is None. :type subscription_feature_registration_type: ~azure.mgmt.resource.features.v2021_07_01.models.SubscriptionFeatureRegistration + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: SubscriptionFeatureRegistration or the result of cls(response) + :rtype: ~azure.mgmt.resource.features.v2021_07_01.models.SubscriptionFeatureRegistration + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + def create_or_update( + self, + provider_namespace: str, + feature_name: str, + subscription_feature_registration_type: Optional[IO] = None, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.SubscriptionFeatureRegistration: + """Create or update a feature registration. + + :param provider_namespace: The provider namespace. Required. + :type provider_namespace: str + :param feature_name: The feature name. Required. + :type feature_name: str + :param subscription_feature_registration_type: Subscription Feature Registration Type details. + Default value is None. + :type subscription_feature_registration_type: IO + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: SubscriptionFeatureRegistration, or the result of cls(response) + :return: SubscriptionFeatureRegistration or the result of cls(response) :rtype: ~azure.mgmt.resource.features.v2021_07_01.models.SubscriptionFeatureRegistration - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace + def create_or_update( + self, + provider_namespace: str, + feature_name: str, + subscription_feature_registration_type: Optional[Union[_models.SubscriptionFeatureRegistration, IO]] = None, + **kwargs: Any + ) -> _models.SubscriptionFeatureRegistration: + """Create or update a feature registration. + + :param provider_namespace: The provider namespace. Required. + :type provider_namespace: str + :param feature_name: The feature name. Required. + :type feature_name: str + :param subscription_feature_registration_type: Subscription Feature Registration Type details. + Is either a model type or a IO type. Default value is None. + :type subscription_feature_registration_type: + ~azure.mgmt.resource.features.v2021_07_01.models.SubscriptionFeatureRegistration or IO + :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. + Default value is None. + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: SubscriptionFeatureRegistration or the result of cls(response) + :rtype: ~azure.mgmt.resource.features.v2021_07_01.models.SubscriptionFeatureRegistration + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.SubscriptionFeatureRegistration"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', "2021-07-01") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-07-01")) # type: str + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.SubscriptionFeatureRegistration] - if subscription_feature_registration_type is not None: - _json = self._serialize.body(subscription_feature_registration_type, 'SubscriptionFeatureRegistration') + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(subscription_feature_registration_type, (IO, bytes)): + _content = subscription_feature_registration_type else: - _json = None + if subscription_feature_registration_type is not None: + _json = self._serialize.body(subscription_feature_registration_type, "SubscriptionFeatureRegistration") + else: + _json = None request = build_subscription_feature_registrations_create_or_update_request( - subscription_id=self._config.subscription_id, provider_namespace=provider_namespace, feature_name=feature_name, + subscription_id=self._config.subscription_id, api_version=api_version, content_type=content_type, json=_json, - template_url=self.create_or_update.metadata['url'], + content=_content, + template_url=self.create_or_update.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200]: @@ -972,58 +992,60 @@ def create_or_update( error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - deserialized = self._deserialize('SubscriptionFeatureRegistration', pipeline_response) + deserialized = self._deserialize("SubscriptionFeatureRegistration", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - create_or_update.metadata = {'url': "/subscriptions/{subscriptionId}/providers/Microsoft.Features/featureProviders/{providerNamespace}/subscriptionFeatureRegistrations/{featureName}"} # type: ignore - + create_or_update.metadata = {"url": "/subscriptions/{subscriptionId}/providers/Microsoft.Features/featureProviders/{providerNamespace}/subscriptionFeatureRegistrations/{featureName}"} # type: ignore @distributed_trace def delete( # pylint: disable=inconsistent-return-statements - self, - provider_namespace: str, - feature_name: str, - **kwargs: Any + self, provider_namespace: str, feature_name: str, **kwargs: Any ) -> None: """Deletes a feature registration. - :param provider_namespace: The provider namespace. + :param provider_namespace: The provider namespace. Required. :type provider_namespace: str - :param feature_name: The feature name. + :param feature_name: The feature name. Required. :type feature_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: None, or the result of cls(response) + :return: None or the result of cls(response) :rtype: None - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType[None] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + 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', "2021-07-01") # type: str + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-07-01")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[None] - request = build_subscription_feature_registrations_delete_request( - subscription_id=self._config.subscription_id, provider_namespace=provider_namespace, feature_name=feature_name, + subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.delete.metadata['url'], + template_url=self.delete.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200, 204]: @@ -1034,54 +1056,59 @@ def delete( # pylint: disable=inconsistent-return-statements if cls: return cls(pipeline_response, None, {}) - delete.metadata = {'url': "/subscriptions/{subscriptionId}/providers/Microsoft.Features/featureProviders/{providerNamespace}/subscriptionFeatureRegistrations/{featureName}"} # type: ignore - + delete.metadata = {"url": "/subscriptions/{subscriptionId}/providers/Microsoft.Features/featureProviders/{providerNamespace}/subscriptionFeatureRegistrations/{featureName}"} # type: ignore @distributed_trace def list_by_subscription( - self, - provider_namespace: str, - **kwargs: Any - ) -> Iterable["_models.SubscriptionFeatureRegistrationList"]: + self, provider_namespace: str, **kwargs: Any + ) -> Iterable["_models.SubscriptionFeatureRegistration"]: """Returns subscription feature registrations for given subscription and provider namespace. - :param provider_namespace: The provider namespace. + :param provider_namespace: The provider namespace. Required. :type provider_namespace: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either SubscriptionFeatureRegistrationList or the result - of cls(response) + :return: An iterator like instance of either SubscriptionFeatureRegistration or the result of + cls(response) :rtype: - ~azure.core.paging.ItemPaged[~azure.mgmt.resource.features.v2021_07_01.models.SubscriptionFeatureRegistrationList] - :raises: ~azure.core.exceptions.HttpResponseError + ~azure.core.paging.ItemPaged[~azure.mgmt.resource.features.v2021_07_01.models.SubscriptionFeatureRegistration] + :raises ~azure.core.exceptions.HttpResponseError: """ - api_version = kwargs.pop('api_version', "2021-07-01") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-07-01")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[_models.SubscriptionFeatureRegistrationList] - cls = kwargs.pop('cls', None) # type: ClsType["_models.SubscriptionFeatureRegistrationList"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) + def prepare_request(next_link=None): if not next_link: - + request = build_subscription_feature_registrations_list_by_subscription_request( - subscription_id=self._config.subscription_id, provider_namespace=provider_namespace, + subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.list_by_subscription.metadata['url'], + template_url=self.list_by_subscription.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore else: - - request = build_subscription_feature_registrations_list_by_subscription_request( - subscription_id=self._config.subscription_id, - provider_namespace=provider_namespace, - template_url=next_link, - ) + # make call to next link with the client's api-version + _parsed_next_link = urlparse(next_link) + _next_request_params = case_insensitive_dict(parse_qs(_parsed_next_link.query)) + _next_request_params["api-version"] = self._config.api_version + request = HttpRequest("GET", urljoin(next_link, _parsed_next_link.path), params=_next_request_params) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore request.method = "GET" return request @@ -1095,10 +1122,8 @@ def extract_data(pipeline_response): def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) response = pipeline_response.http_response @@ -1109,52 +1134,56 @@ def get_next(next_link=None): return pipeline_response + return ItemPaged(get_next, extract_data) - return ItemPaged( - get_next, extract_data - ) - list_by_subscription.metadata = {'url': "/subscriptions/{subscriptionId}/providers/Microsoft.Features/featureProviders/{providerNamespace}/subscriptionFeatureRegistrations"} # type: ignore + list_by_subscription.metadata = {"url": "/subscriptions/{subscriptionId}/providers/Microsoft.Features/featureProviders/{providerNamespace}/subscriptionFeatureRegistrations"} # type: ignore @distributed_trace - def list_all_by_subscription( - self, - **kwargs: Any - ) -> Iterable["_models.SubscriptionFeatureRegistrationList"]: + def list_all_by_subscription(self, **kwargs: Any) -> Iterable["_models.SubscriptionFeatureRegistration"]: """Returns subscription feature registrations for given subscription. :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either SubscriptionFeatureRegistrationList or the result - of cls(response) + :return: An iterator like instance of either SubscriptionFeatureRegistration or the result of + cls(response) :rtype: - ~azure.core.paging.ItemPaged[~azure.mgmt.resource.features.v2021_07_01.models.SubscriptionFeatureRegistrationList] - :raises: ~azure.core.exceptions.HttpResponseError + ~azure.core.paging.ItemPaged[~azure.mgmt.resource.features.v2021_07_01.models.SubscriptionFeatureRegistration] + :raises ~azure.core.exceptions.HttpResponseError: """ - api_version = kwargs.pop('api_version', "2021-07-01") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-07-01")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[_models.SubscriptionFeatureRegistrationList] - cls = kwargs.pop('cls', None) # type: ClsType["_models.SubscriptionFeatureRegistrationList"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) + def prepare_request(next_link=None): if not next_link: - + request = build_subscription_feature_registrations_list_all_by_subscription_request( subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.list_all_by_subscription.metadata['url'], + template_url=self.list_all_by_subscription.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore else: - - request = build_subscription_feature_registrations_list_all_by_subscription_request( - subscription_id=self._config.subscription_id, - template_url=next_link, - ) + # make call to next link with the client's api-version + _parsed_next_link = urlparse(next_link) + _next_request_params = case_insensitive_dict(parse_qs(_parsed_next_link.query)) + _next_request_params["api-version"] = self._config.api_version + request = HttpRequest("GET", urljoin(next_link, _parsed_next_link.path), params=_next_request_params) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore request.method = "GET" return request @@ -1168,10 +1197,8 @@ def extract_data(pipeline_response): def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) response = pipeline_response.http_response @@ -1182,8 +1209,6 @@ def get_next(next_link=None): return pipeline_response + return ItemPaged(get_next, extract_data) - return ItemPaged( - get_next, extract_data - ) - list_all_by_subscription.metadata = {'url': "/subscriptions/{subscriptionId}/providers/Microsoft.Features/subscriptionFeatureRegistrations"} # type: ignore + list_all_by_subscription.metadata = {"url": "/subscriptions/{subscriptionId}/providers/Microsoft.Features/subscriptionFeatureRegistrations"} # type: ignore diff --git a/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/features/v2021_07_01/operations/_patch.py b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/features/v2021_07_01/operations/_patch.py new file mode 100644 index 0000000000000..f7dd32510333d --- /dev/null +++ b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/features/v2021_07_01/operations/_patch.py @@ -0,0 +1,20 @@ +# ------------------------------------ +# Copyright (c) Microsoft Corporation. +# Licensed under the MIT License. +# ------------------------------------ +"""Customize generated code here. + +Follow our quickstart for examples: https://aka.ms/azsdk/python/dpcodegen/python/customize +""" +from typing import List + +__all__: List[str] = [] # Add all objects you want publicly available to users at this package level + + +def patch_sdk(): + """Do not remove from this file. + + `patch_sdk` is a last resort escape hatch that allows you to do customizations + you can't accomplish using the techniques described in + https://aka.ms/azsdk/python/dpcodegen/python/customize + """ diff --git a/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/links/__init__.py b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/links/__init__.py index e91de7900ee78..4449746f13f4d 100644 --- a/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/links/__init__.py +++ b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/links/__init__.py @@ -14,3 +14,7 @@ patch_sdk() except ImportError: pass + +from ._version import VERSION + +__version__ = VERSION diff --git a/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/links/_configuration.py b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/links/_configuration.py index 8ee473bb1ccf8..8cd1c84fa7cbf 100644 --- a/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/links/_configuration.py +++ b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/links/_configuration.py @@ -8,7 +8,7 @@ # Changes may cause incorrect behavior and will be lost if the code is # regenerated. # -------------------------------------------------------------------------- -from typing import TYPE_CHECKING +from typing import Any, TYPE_CHECKING from azure.core.configuration import Configuration from azure.core.pipeline import policies @@ -18,8 +18,6 @@ if TYPE_CHECKING: # pylint: disable=unused-import,ungrouped-imports - from typing import Any - from azure.core.credentials import TokenCredential class ManagementLinkClientConfiguration(Configuration): @@ -28,16 +26,16 @@ class ManagementLinkClientConfiguration(Configuration): Note that all parameters used to create this instance are saved as instance attributes. - :param credential: Credential needed for the client to connect to Azure. + :param credential: Credential needed for the client to connect to Azure. Required. :type credential: ~azure.core.credentials.TokenCredential - :param subscription_id: The ID of the target subscription. + :param subscription_id: The ID of the target subscription. Required. :type subscription_id: str """ def __init__( self, - credential, # type: "TokenCredential" - subscription_id, # type: str + credential: "TokenCredential", + subscription_id: str, **kwargs # type: Any ): # type: (...) -> None diff --git a/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/links/_management_link_client.py b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/links/_management_link_client.py index 1023dd7dbdc04..11a376f974b57 100644 --- a/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/links/_management_link_client.py +++ b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/links/_management_link_client.py @@ -9,20 +9,17 @@ # regenerated. # -------------------------------------------------------------------------- -from typing import TYPE_CHECKING - -from msrest import Deserializer, Serializer +from typing import Any, Optional, TYPE_CHECKING from azure.mgmt.core import ARMPipelineClient from azure.profiles import KnownProfiles, ProfileDefinition from azure.profiles.multiapiclient import MultiApiClientMixin from ._configuration import ManagementLinkClientConfiguration +from ._serialization import Deserializer, Serializer if TYPE_CHECKING: # pylint: disable=unused-import,ungrouped-imports - from typing import Any, Optional - from azure.core.credentials import TokenCredential class _SDKClient(object): @@ -43,9 +40,9 @@ class ManagementLinkClient(MultiApiClientMixin, _SDKClient): The api-version parameter sets the default API version if the operation group is not described in the profile. - :param credential: Credential needed for the client to connect to Azure. + :param credential: Credential needed for the client to connect to Azure. Required. :type credential: ~azure.core.credentials.TokenCredential - :param subscription_id: The ID of the target subscription. + :param subscription_id: The ID of the target subscription. Required. :type subscription_id: str :param api_version: API version to use if no profile is provided, or if missing in profile. :type api_version: str @@ -66,10 +63,10 @@ class ManagementLinkClient(MultiApiClientMixin, _SDKClient): def __init__( self, - credential, # type: "TokenCredential" - subscription_id, # type: str + credential: "TokenCredential", + subscription_id: str, api_version=None, # type: Optional[str] - base_url="https://management.azure.com", # type: str + base_url: str = "https://management.azure.com", profile=KnownProfiles.default, # type: KnownProfiles **kwargs # type: Any ): diff --git a/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/links/_serialization.py b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/links/_serialization.py new file mode 100644 index 0000000000000..240df16c57f3c --- /dev/null +++ b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/links/_serialization.py @@ -0,0 +1,2006 @@ +# -------------------------------------------------------------------------- +# +# Copyright (c) Microsoft Corporation. All rights reserved. +# +# The MIT License (MIT) +# +# Permission is hereby granted, free of charge, to any person obtaining a copy +# of this software and associated documentation files (the ""Software""), to +# deal in the Software without restriction, including without limitation the +# rights to use, copy, modify, merge, publish, distribute, sublicense, and/or +# sell copies of the Software, and to permit persons to whom the Software is +# furnished to do so, subject to the following conditions: +# +# The above copyright notice and this permission notice shall be included in +# all copies or substantial portions of the Software. +# +# THE SOFTWARE IS PROVIDED *AS IS*, WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING +# FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS +# IN THE SOFTWARE. +# +# -------------------------------------------------------------------------- + +# pylint: skip-file + +from base64 import b64decode, b64encode +import calendar +import datetime +import decimal +import email +from enum import Enum +import json +import logging +import re +import sys +import codecs +try: + from urllib import quote # type: ignore +except ImportError: + from urllib.parse import quote # type: ignore +import xml.etree.ElementTree as ET + +import isodate + +from typing import Dict, Any, cast, TYPE_CHECKING + +from azure.core.exceptions import DeserializationError, SerializationError, raise_with_traceback + +_BOM = codecs.BOM_UTF8.decode(encoding='utf-8') + +if TYPE_CHECKING: + from typing import Optional, Union, AnyStr, IO, Mapping + +class RawDeserializer: + + # Accept "text" because we're open minded people... + JSON_REGEXP = re.compile(r'^(application|text)/([a-z+.]+\+)?json$') + + # Name used in context + CONTEXT_NAME = "deserialized_data" + + @classmethod + def deserialize_from_text(cls, data, content_type=None): + # type: (Optional[Union[AnyStr, IO]], Optional[str]) -> Any + """Decode data according to content-type. + + Accept a stream of data as well, but will be load at once in memory for now. + + If no content-type, will return the string version (not bytes, not stream) + + :param data: Input, could be bytes or stream (will be decoded with UTF8) or text + :type data: str or bytes or IO + :param str content_type: The content type. + """ + if hasattr(data, 'read'): + # Assume a stream + data = cast(IO, data).read() + + if isinstance(data, bytes): + data_as_str = data.decode(encoding='utf-8-sig') + else: + # Explain to mypy the correct type. + data_as_str = cast(str, data) + + # Remove Byte Order Mark if present in string + data_as_str = data_as_str.lstrip(_BOM) + + if content_type is None: + return data + + if cls.JSON_REGEXP.match(content_type): + try: + return json.loads(data_as_str) + except ValueError as err: + raise DeserializationError("JSON is invalid: {}".format(err), err) + elif "xml" in (content_type or []): + try: + + try: + if isinstance(data, unicode): # type: ignore + # If I'm Python 2.7 and unicode XML will scream if I try a "fromstring" on unicode string + data_as_str = data_as_str.encode(encoding="utf-8") # type: ignore + except NameError: + pass + + return ET.fromstring(data_as_str) # nosec + except ET.ParseError: + # It might be because the server has an issue, and returned JSON with + # content-type XML.... + # So let's try a JSON load, and if it's still broken + # let's flow the initial exception + def _json_attemp(data): + try: + return True, json.loads(data) + except ValueError: + return False, None # Don't care about this one + success, json_result = _json_attemp(data) + if success: + return json_result + # If i'm here, it's not JSON, it's not XML, let's scream + # and raise the last context in this block (the XML exception) + # The function hack is because Py2.7 messes up with exception + # context otherwise. + _LOGGER.critical("Wasn't XML not JSON, failing") + raise_with_traceback(DeserializationError, "XML is invalid") + 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 + """Deserialize from HTTP response. + + Use bytes and headers to NOT use any requests/aiohttp or whatever + specific implementation. + Headers will tested for "content-type" + """ + # Try to use content-type from headers if available + content_type = None + if 'content-type' in headers: + content_type = headers['content-type'].split(";")[0].strip().lower() + # Ouch, this server did not declare what it sent... + # Let's guess it's JSON... + # Also, since Autorest was considering that an empty body was a valid JSON, + # need that test as well.... + else: + content_type = "application/json" + + if body_bytes: + return cls.deserialize_from_text(body_bytes, content_type) + return None + +try: + basestring # type: ignore + unicode_str = unicode # type: ignore +except NameError: + basestring = str # type: ignore + unicode_str = str # type: ignore + +_LOGGER = logging.getLogger(__name__) + +try: + _long_type = long # type: ignore +except NameError: + _long_type = int + +class UTC(datetime.tzinfo): + """Time Zone info for handling UTC""" + + def utcoffset(self, dt): + """UTF offset for UTC is 0.""" + return datetime.timedelta(0) + + def tzname(self, dt): + """Timestamp representation.""" + return "Z" + + def dst(self, dt): + """No daylight saving for UTC.""" + return datetime.timedelta(hours=1) + +try: + from datetime import timezone as _FixedOffset +except ImportError: # Python 2.7 + class _FixedOffset(datetime.tzinfo): # type: ignore + """Fixed offset in minutes east from UTC. + Copy/pasted from Python doc + :param datetime.timedelta offset: offset in timedelta format + """ + + def __init__(self, offset): + self.__offset = offset + + def utcoffset(self, dt): + return self.__offset + + def tzname(self, dt): + return str(self.__offset.total_seconds()/3600) + + def __repr__(self): + return "".format(self.tzname(None)) + + def dst(self, dt): + return datetime.timedelta(0) + + def __getinitargs__(self): + return (self.__offset,) + +try: + from datetime import timezone + TZ_UTC = timezone.utc # type: ignore +except ImportError: + TZ_UTC = UTC() # type: ignore + +_FLATTEN = re.compile(r"(? y, + "minimum": lambda x, y: x < y, + "maximum": lambda x, y: x > y, + "minimum_ex": lambda x, y: x <= y, + "maximum_ex": lambda x, y: x >= y, + "min_items": lambda x, y: len(x) < y, + "max_items": lambda x, y: len(x) > y, + "pattern": lambda x, y: not re.match(y, x, re.UNICODE), + "unique": lambda x, y: len(x) != len(set(x)), + "multiple": lambda x, y: x % y != 0 + } + + def __init__(self, classes=None): + self.serialize_type = { + 'iso-8601': Serializer.serialize_iso, + 'rfc-1123': Serializer.serialize_rfc, + 'unix-time': Serializer.serialize_unix, + 'duration': Serializer.serialize_duration, + 'date': Serializer.serialize_date, + 'time': Serializer.serialize_time, + 'decimal': Serializer.serialize_decimal, + 'long': Serializer.serialize_long, + 'bytearray': Serializer.serialize_bytearray, + 'base64': Serializer.serialize_base64, + 'object': self.serialize_object, + '[]': self.serialize_iter, + '{}': self.serialize_dict + } + self.dependencies = dict(classes) if classes else {} + self.key_transformer = full_restapi_key_transformer + self.client_side_validation = True + + def _serialize(self, target_obj, data_type=None, **kwargs): + """Serialize data into a string according to type. + + :param target_obj: The data to be serialized. + :param str data_type: The type to be serialized from. + :rtype: str, dict + :raises: SerializationError if serialization fails. + """ + key_transformer = kwargs.get("key_transformer", self.key_transformer) + keep_readonly = kwargs.get("keep_readonly", False) + if target_obj is None: + return None + + attr_name = None + class_name = target_obj.__class__.__name__ + + if data_type: + return self.serialize_data( + target_obj, data_type, **kwargs) + + if not hasattr(target_obj, "_attribute_map"): + data_type = type(target_obj).__name__ + if data_type in self.basic_types.values(): + return self.serialize_data( + target_obj, data_type, **kwargs) + + # Force "is_xml" kwargs if we detect a XML model + try: + is_xml_model_serialization = kwargs["is_xml"] + except KeyError: + is_xml_model_serialization = kwargs.setdefault("is_xml", target_obj.is_xml_model()) + + serialized = {} + if is_xml_model_serialization: + serialized = target_obj._create_xml_node() + try: + attributes = target_obj._attribute_map + for attr, attr_desc in attributes.items(): + attr_name = attr + if not keep_readonly and target_obj._validation.get(attr_name, {}).get('readonly', False): + continue + + if attr_name == "additional_properties" and attr_desc["key"] == '': + if target_obj.additional_properties is not None: + serialized.update(target_obj.additional_properties) + continue + try: + + orig_attr = getattr(target_obj, attr) + if is_xml_model_serialization: + pass # Don't provide "transformer" for XML for now. Keep "orig_attr" + else: # JSON + keys, orig_attr = key_transformer(attr, attr_desc.copy(), orig_attr) + keys = keys if isinstance(keys, list) else [keys] + + + kwargs["serialization_ctxt"] = attr_desc + new_attr = self.serialize_data(orig_attr, attr_desc['type'], **kwargs) + + + if is_xml_model_serialization: + xml_desc = attr_desc.get('xml', {}) + xml_name = xml_desc.get('name', attr_desc['key']) + xml_prefix = xml_desc.get('prefix', None) + xml_ns = xml_desc.get('ns', None) + 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) + continue + if xml_desc.get("text", False): + serialized.text = new_attr + continue + if isinstance(new_attr, list): + serialized.extend(new_attr) + 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', {}): + splitted_tag = new_attr.tag.split("}") + if len(splitted_tag) == 2: # Namespace + new_attr.tag = "}".join([splitted_tag[0], xml_name]) + else: + new_attr.tag = xml_name + serialized.append(new_attr) + 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) + else: # JSON + for k in reversed(keys): + unflattened = {k: new_attr} + new_attr = unflattened + + _new_attr = new_attr + _serialized = serialized + for k in keys: + if k not in _serialized: + _serialized.update(_new_attr) + _new_attr = _new_attr[k] + _serialized = _serialized[k] + except ValueError: + continue + + except (AttributeError, KeyError, TypeError) as err: + msg = "Attribute {} in object {} cannot be serialized.\n{}".format( + attr_name, class_name, str(target_obj)) + raise_with_traceback(SerializationError, msg, err) + else: + return serialized + + def body(self, data, data_type, **kwargs): + """Serialize data intended for a request body. + + :param data: The data to be serialized. + :param str data_type: The type to be serialized from. + :rtype: dict + :raises: SerializationError if serialization fails. + :raises: ValueError if data is None + """ + + # Just in case this is a dict + internal_data_type = data_type.strip('[]{}') + internal_data_type = self.dependencies.get(internal_data_type, None) + try: + is_xml_model_serialization = kwargs["is_xml"] + except KeyError: + if internal_data_type and issubclass(internal_data_type, Model): + is_xml_model_serialization = kwargs.setdefault("is_xml", internal_data_type.is_xml_model()) + else: + is_xml_model_serialization = False + if internal_data_type and not isinstance(internal_data_type, Enum): + try: + deserializer = Deserializer(self.dependencies) + # Since it's on serialization, it's almost sure that format is not JSON REST + # We're not able to deal with additional properties for now. + deserializer.additional_properties_detection = False + if is_xml_model_serialization: + deserializer.key_extractors = [ + attribute_key_case_insensitive_extractor, + ] + else: + deserializer.key_extractors = [ + rest_key_case_insensitive_extractor, + attribute_key_case_insensitive_extractor, + last_rest_key_case_insensitive_extractor + ] + data = deserializer._deserialize(data_type, data) + except DeserializationError as err: + raise_with_traceback( + SerializationError, "Unable to build a model: "+str(err), err) + + return self._serialize(data, data_type, **kwargs) + + def url(self, name, data, data_type, **kwargs): + """Serialize data intended for a URL path. + + :param data: The data to be serialized. + :param str data_type: The type to be serialized from. + :rtype: str + :raises: TypeError if serialization fails. + :raises: ValueError if data is None + """ + try: + output = self.serialize_data(data, data_type, **kwargs) + if data_type == 'bool': + output = json.dumps(output) + + if kwargs.get('skip_quote') is True: + output = str(output) + else: + output = quote(str(output), safe='') + except SerializationError: + raise TypeError("{} must be type {}.".format(name, data_type)) + else: + return output + + def query(self, name, data, data_type, **kwargs): + """Serialize data intended for a URL query. + + :param data: The data to be serialized. + :param str data_type: The type to be serialized from. + :rtype: str + :raises: TypeError if serialization fails. + :raises: ValueError if data is None + """ + try: + # 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)) + + # Not a list, regular serialization + output = self.serialize_data(data, data_type, **kwargs) + if data_type == 'bool': + output = json.dumps(output) + if kwargs.get('skip_quote') is True: + output = str(output) + else: + output = quote(str(output), safe='') + except SerializationError: + raise TypeError("{} must be type {}.".format(name, data_type)) + else: + return str(output) + + def header(self, name, data, data_type, **kwargs): + """Serialize data intended for a request header. + + :param data: The data to be serialized. + :param str data_type: The type to be serialized from. + :rtype: str + :raises: TypeError if serialization fails. + :raises: ValueError if data is None + """ + try: + if data_type in ['[str]']: + data = ["" if d is None else d for d in data] + + output = self.serialize_data(data, data_type, **kwargs) + if data_type == 'bool': + output = json.dumps(output) + except SerializationError: + raise TypeError("{} must be type {}.".format(name, data_type)) + else: + return str(output) + + def serialize_data(self, data, data_type, **kwargs): + """Serialize generic data according to supplied data type. + + :param data: The data to be serialized. + :param str data_type: The type to be serialized from. + :param bool required: Whether it's essential that the data not be + empty or None + :raises: AttributeError if required data is None. + :raises: ValueError if data is None + :raises: SerializationError if serialization fails. + """ + if data is None: + raise ValueError("No value for given attribute") + + try: + if data_type in self.basic_types.values(): + return self.serialize_basic(data, data_type, **kwargs) + + elif data_type in self.serialize_type: + return self.serialize_type[data_type](data, **kwargs) + + # If dependencies is empty, try with current data class + # It has to be a subclass of Enum anyway + enum_type = self.dependencies.get(data_type, data.__class__) + if issubclass(enum_type, Enum): + return Serializer.serialize_enum(data, enum_obj=enum_type) + + iter_type = data_type[0] + data_type[-1] + if iter_type in self.serialize_type: + return self.serialize_type[iter_type]( + data, data_type[1:-1], **kwargs) + + except (ValueError, TypeError) as err: + msg = "Unable to serialize value: {!r} as type: {!r}." + raise_with_traceback( + SerializationError, msg.format(data, data_type), err) + else: + return self._serialize(data, **kwargs) + + @classmethod + def _get_custom_serializers(cls, data_type, **kwargs): + custom_serializer = kwargs.get("basic_types_serializers", {}).get(data_type) + if custom_serializer: + return custom_serializer + if kwargs.get("is_xml", False): + return cls._xml_basic_types_serializers.get(data_type) + + @classmethod + def serialize_basic(cls, data, data_type, **kwargs): + """Serialize basic builting data type. + Serializes objects to str, int, float or bool. + + Possible kwargs: + - basic_types_serializers dict[str, callable] : If set, use the callable as serializer + - is_xml bool : If set, use xml_basic_types_serializers + + :param data: Object to be serialized. + :param str data_type: Type of object in the iterable. + """ + custom_serializer = cls._get_custom_serializers(data_type, **kwargs) + if custom_serializer: + return custom_serializer(data) + if data_type == 'str': + return cls.serialize_unicode(data) + return eval(data_type)(data) # nosec + + @classmethod + def serialize_unicode(cls, data): + """Special handling for serializing unicode strings in Py2. + Encode to UTF-8 if unicode, otherwise handle as a str. + + :param data: Object to be serialized. + :rtype: str + """ + try: # If I received an enum, return its value + return data.value + except AttributeError: + pass + + try: + if isinstance(data, unicode): + # Don't change it, JSON and XML ElementTree are totally able + # to serialize correctly u'' strings + return data + except NameError: + return str(data) + else: + return str(data) + + def serialize_iter(self, data, iter_type, div=None, **kwargs): + """Serialize iterable. + + Supported kwargs: + - serialization_ctxt dict : The current entry of _attribute_map, or same format. + serialization_ctxt['type'] should be same as data_type. + - is_xml bool : If set, serialize as XML + + :param list attr: Object to be serialized. + :param str iter_type: Type of object in the iterable. + :param bool required: Whether the objects in the iterable must + not be None or empty. + :param str div: If set, this str will be used to combine the elements + in the iterable into a combined string. Default is 'None'. + :rtype: list, str + """ + if isinstance(data, str): + raise SerializationError("Refuse str type as a valid iter type.") + + serialization_ctxt = kwargs.get("serialization_ctxt", {}) + is_xml = kwargs.get("is_xml", False) + + serialized = [] + for d in data: + try: + serialized.append(self.serialize_data(d, iter_type, **kwargs)) + except ValueError: + serialized.append(None) + + if div: + serialized = ['' if s is None else str(s) for s in serialized] + serialized = div.join(serialized) + + if 'xml' in serialization_ctxt or is_xml: + # XML serialization is more complicated + xml_desc = serialization_ctxt.get('xml', {}) + xml_name = xml_desc.get('name') + if not xml_name: + xml_name = serialization_ctxt['key'] + + # Create a wrap node if necessary (use the fact that Element and list have "append") + is_wrapped = xml_desc.get("wrapped", False) + node_name = xml_desc.get("itemsName", xml_name) + if is_wrapped: + final_result = _create_xml_node( + xml_name, + xml_desc.get('prefix', None), + xml_desc.get('ns', None) + ) + else: + final_result = [] + # All list elements to "local_node" + for el in serialized: + if isinstance(el, ET.Element): + el_node = el + else: + el_node = _create_xml_node( + node_name, + xml_desc.get('prefix', None), + xml_desc.get('ns', None) + ) + if el is not None: # Otherwise it writes "None" :-p + el_node.text = str(el) + final_result.append(el_node) + return final_result + return serialized + + def serialize_dict(self, attr, dict_type, **kwargs): + """Serialize a dictionary of objects. + + :param dict attr: Object to be serialized. + :param str dict_type: Type of object in the dictionary. + :param bool required: Whether the objects in the dictionary must + not be None or empty. + :rtype: dict + """ + serialization_ctxt = kwargs.get("serialization_ctxt", {}) + serialized = {} + for key, value in attr.items(): + try: + serialized[self.serialize_unicode(key)] = self.serialize_data( + value, dict_type, **kwargs) + except ValueError: + serialized[self.serialize_unicode(key)] = None + + if 'xml' in serialization_ctxt: + # XML serialization is more complicated + xml_desc = serialization_ctxt['xml'] + xml_name = xml_desc['name'] + + final_result = _create_xml_node( + xml_name, + xml_desc.get('prefix', None), + xml_desc.get('ns', None) + ) + for key, value in serialized.items(): + ET.SubElement(final_result, key).text = value + return final_result + + return serialized + + def serialize_object(self, attr, **kwargs): + """Serialize a generic object. + This will be handled as a dictionary. If object passed in is not + a basic type (str, int, float, dict, list) it will simply be + cast to str. + + :param dict attr: Object to be serialized. + :rtype: dict or str + """ + if attr is None: + return None + if isinstance(attr, ET.Element): + return attr + obj_type = type(attr) + if obj_type in self.basic_types: + return self.serialize_basic(attr, self.basic_types[obj_type], **kwargs) + if obj_type is _long_type: + return self.serialize_long(attr) + if obj_type is unicode_str: + return self.serialize_unicode(attr) + if obj_type is datetime.datetime: + return self.serialize_iso(attr) + if obj_type is datetime.date: + return self.serialize_date(attr) + if obj_type is datetime.time: + return self.serialize_time(attr) + if obj_type is datetime.timedelta: + return self.serialize_duration(attr) + if obj_type is decimal.Decimal: + return self.serialize_decimal(attr) + + # If it's a model or I know this dependency, serialize as a Model + elif obj_type in self.dependencies.values() or isinstance(attr, Model): + return self._serialize(attr) + + if obj_type == dict: + serialized = {} + for key, value in attr.items(): + try: + serialized[self.serialize_unicode(key)] = self.serialize_object( + value, **kwargs) + except ValueError: + serialized[self.serialize_unicode(key)] = None + return serialized + + if obj_type == list: + serialized = [] + for obj in attr: + try: + serialized.append(self.serialize_object( + obj, **kwargs)) + except ValueError: + pass + return serialized + return str(attr) + + @staticmethod + def serialize_enum(attr, enum_obj=None): + try: + result = attr.value + except AttributeError: + result = attr + try: + enum_obj(result) + return result + except ValueError: + for enum_value in enum_obj: + if enum_value.value.lower() == str(attr).lower(): + return enum_value.value + error = "{!r} is not valid value for enum {!r}" + raise SerializationError(error.format(attr, enum_obj)) + + @staticmethod + def serialize_bytearray(attr, **kwargs): + """Serialize bytearray into base-64 string. + + :param attr: Object to be serialized. + :rtype: str + """ + return b64encode(attr).decode() + + @staticmethod + def serialize_base64(attr, **kwargs): + """Serialize str into base-64 string. + + :param attr: Object to be serialized. + :rtype: str + """ + encoded = b64encode(attr).decode('ascii') + return encoded.strip('=').replace('+', '-').replace('/', '_') + + @staticmethod + def serialize_decimal(attr, **kwargs): + """Serialize Decimal object to float. + + :param attr: Object to be serialized. + :rtype: float + """ + return float(attr) + + @staticmethod + def serialize_long(attr, **kwargs): + """Serialize long (Py2) or int (Py3). + + :param attr: Object to be serialized. + :rtype: int/long + """ + return _long_type(attr) + + @staticmethod + def serialize_date(attr, **kwargs): + """Serialize Date object into ISO-8601 formatted string. + + :param Date attr: Object to be serialized. + :rtype: str + """ + if isinstance(attr, str): + attr = isodate.parse_date(attr) + t = "{:04}-{:02}-{:02}".format(attr.year, attr.month, attr.day) + return t + + @staticmethod + def serialize_time(attr, **kwargs): + """Serialize Time object into ISO-8601 formatted string. + + :param datetime.time attr: Object to be serialized. + :rtype: str + """ + if isinstance(attr, str): + attr = isodate.parse_time(attr) + t = "{:02}:{:02}:{:02}".format(attr.hour, attr.minute, attr.second) + if attr.microsecond: + t += ".{:02}".format(attr.microsecond) + return t + + @staticmethod + def serialize_duration(attr, **kwargs): + """Serialize TimeDelta object into ISO-8601 formatted string. + + :param TimeDelta attr: Object to be serialized. + :rtype: str + """ + if isinstance(attr, str): + attr = isodate.parse_duration(attr) + return isodate.duration_isoformat(attr) + + @staticmethod + def serialize_rfc(attr, **kwargs): + """Serialize Datetime object into RFC-1123 formatted string. + + :param Datetime attr: Object to be serialized. + :rtype: str + :raises: TypeError if format invalid. + """ + try: + if not attr.tzinfo: + _LOGGER.warning( + "Datetime with no tzinfo will be considered UTC.") + utc = attr.utctimetuple() + except AttributeError: + raise TypeError("RFC1123 object must be valid Datetime object.") + + return "{}, {:02} {} {:04} {:02}:{:02}:{:02} GMT".format( + Serializer.days[utc.tm_wday], utc.tm_mday, + Serializer.months[utc.tm_mon], utc.tm_year, + utc.tm_hour, utc.tm_min, utc.tm_sec) + + @staticmethod + def serialize_iso(attr, **kwargs): + """Serialize Datetime object into ISO-8601 formatted string. + + :param Datetime attr: Object to be serialized. + :rtype: str + :raises: SerializationError if format invalid. + """ + if isinstance(attr, str): + attr = isodate.parse_datetime(attr) + try: + if not attr.tzinfo: + _LOGGER.warning( + "Datetime with no tzinfo will be considered UTC.") + utc = attr.utctimetuple() + if utc.tm_year > 9999 or utc.tm_year < 1: + raise OverflowError("Hit max or min date") + + microseconds = str(attr.microsecond).rjust(6,'0').rstrip('0').ljust(3, '0') + if microseconds: + microseconds = '.'+microseconds + date = "{:04}-{:02}-{:02}T{:02}:{:02}:{:02}".format( + utc.tm_year, utc.tm_mon, utc.tm_mday, + utc.tm_hour, utc.tm_min, utc.tm_sec) + return date + microseconds + 'Z' + except (ValueError, OverflowError) as err: + msg = "Unable to serialize datetime object." + raise_with_traceback(SerializationError, msg, err) + except AttributeError as err: + msg = "ISO-8601 object must be valid Datetime object." + raise_with_traceback(TypeError, msg, err) + + @staticmethod + def serialize_unix(attr, **kwargs): + """Serialize Datetime object into IntTime format. + This is represented as seconds. + + :param Datetime attr: Object to be serialized. + :rtype: int + :raises: SerializationError if format invalid + """ + if isinstance(attr, int): + return attr + try: + if not attr.tzinfo: + _LOGGER.warning( + "Datetime with no tzinfo will be considered UTC.") + return int(calendar.timegm(attr.utctimetuple())) + except AttributeError: + raise TypeError("Unix time object must be valid Datetime object.") + +def rest_key_extractor(attr, attr_desc, data): + key = attr_desc['key'] + working_data = data + + while '.' in key: + dict_keys = _FLATTEN.split(key) + if len(dict_keys) == 1: + key = _decode_attribute_map_key(dict_keys[0]) + break + working_key = _decode_attribute_map_key(dict_keys[0]) + working_data = working_data.get(working_key, data) + if working_data is None: + # If at any point while following flatten JSON path see None, it means + # that all properties under are None as well + # https://github.com/Azure/msrest-for-python/issues/197 + return None + key = '.'.join(dict_keys[1:]) + + return working_data.get(key) + +def rest_key_case_insensitive_extractor(attr, attr_desc, data): + key = attr_desc['key'] + working_data = data + + while '.' in key: + dict_keys = _FLATTEN.split(key) + if len(dict_keys) == 1: + key = _decode_attribute_map_key(dict_keys[0]) + break + working_key = _decode_attribute_map_key(dict_keys[0]) + working_data = attribute_key_case_insensitive_extractor(working_key, None, working_data) + if working_data is None: + # If at any point while following flatten JSON path see None, it means + # that all properties under are None as well + # https://github.com/Azure/msrest-for-python/issues/197 + return None + key = '.'.join(dict_keys[1:]) + + if working_data: + return attribute_key_case_insensitive_extractor(key, None, working_data) + +def last_rest_key_extractor(attr, attr_desc, data): + """Extract the attribute in "data" based on the last part of the JSON path key. + """ + key = attr_desc['key'] + dict_keys = _FLATTEN.split(key) + return attribute_key_extractor(dict_keys[-1], None, data) + +def last_rest_key_case_insensitive_extractor(attr, attr_desc, data): + """Extract the attribute in "data" based on the last part of the JSON path key. + + This is the case insensitive version of "last_rest_key_extractor" + """ + key = attr_desc['key'] + dict_keys = _FLATTEN.split(key) + return attribute_key_case_insensitive_extractor(dict_keys[-1], None, data) + +def attribute_key_extractor(attr, _, data): + return data.get(attr) + +def attribute_key_case_insensitive_extractor(attr, _, data): + found_key = None + lower_attr = attr.lower() + for key in data: + if lower_attr == key.lower(): + found_key = key + break + + return data.get(found_key) + +def _extract_name_from_internal_type(internal_type): + """Given an internal type XML description, extract correct XML name with namespace. + + :param dict internal_type: An model type + :rtype: tuple + :returns: A tuple XML name + namespace dict + """ + internal_type_xml_map = getattr(internal_type, "_xml_map", {}) + 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) + return xml_name + + +def xml_key_extractor(attr, attr_desc, data): + if isinstance(data, dict): + return None + + # Test if this model is XML ready first + if not isinstance(data, ET.Element): + return None + + xml_desc = attr_desc.get('xml', {}) + xml_name = xml_desc.get('name', attr_desc['key']) + + # Look for a children + is_iter_type = attr_desc['type'].startswith("[") + is_wrapped = xml_desc.get("wrapped", False) + internal_type = attr_desc.get("internalType", None) + internal_type_xml_map = getattr(internal_type, "_xml_map", {}) + + # 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) + + # If it's an attribute, that's simple + if xml_desc.get("attr", False): + return data.get(xml_name) + + # If it's x-ms-text, that's simple too + if xml_desc.get("text", False): + return data.text + + # Scenario where I take the local name: + # - Wrapped node + # - Internal type is an enum (considered basic types) + # - Internal type has no XML/Name node + if is_wrapped or (internal_type and (issubclass(internal_type, Enum) or 'name' not in internal_type_xml_map)): + children = data.findall(xml_name) + # If internal type has a local name and it's not a list, I use that name + elif not is_iter_type and internal_type and 'name' in internal_type_xml_map: + xml_name = _extract_name_from_internal_type(internal_type) + children = data.findall(xml_name) + # That's an array + else: + if internal_type: # Complex type, ignore itemsName and use the complex type name + items_name = _extract_name_from_internal_type(internal_type) + else: + items_name = xml_desc.get("itemsName", xml_name) + children = data.findall(items_name) + + if len(children) == 0: + if is_iter_type: + if is_wrapped: + return None # is_wrapped no node, we want None + else: + return [] # not wrapped, assume empty list + return None # Assume it's not there, maybe an optional node. + + # If is_iter_type and not wrapped, return all found children + if is_iter_type: + if not is_wrapped: + return children + else: # Iter and wrapped, should have found one node only (the wrap one) + if len(children) != 1: + raise DeserializationError( + "Tried to deserialize an array not wrapped, and found several nodes '{}'. Maybe you should declare this array as wrapped?".format( + xml_name + )) + return list(children[0]) # Might be empty list and that's ok. + + # Here it's not a itertype, we should have found one element only or empty + if len(children) > 1: + raise DeserializationError("Find several XML '{}' where it was not expected".format(xml_name)) + return children[0] + +class Deserializer(object): + """Response object model deserializer. + + :param dict classes: Class type dictionary for deserializing complex types. + :ivar list key_extractors: Ordered list of extractors to be used by this deserializer. + """ + + basic_types = {str: 'str', int: 'int', bool: 'bool', float: 'float'} + + valid_date = re.compile( + r'\d{4}[-]\d{2}[-]\d{2}T\d{2}:\d{2}:\d{2}' + r'\.?\d*Z?[-+]?[\d{2}]?:?[\d{2}]?') + + def __init__(self, classes=None): + self.deserialize_type = { + 'iso-8601': Deserializer.deserialize_iso, + 'rfc-1123': Deserializer.deserialize_rfc, + 'unix-time': Deserializer.deserialize_unix, + 'duration': Deserializer.deserialize_duration, + 'date': Deserializer.deserialize_date, + 'time': Deserializer.deserialize_time, + 'decimal': Deserializer.deserialize_decimal, + 'long': Deserializer.deserialize_long, + 'bytearray': Deserializer.deserialize_bytearray, + 'base64': Deserializer.deserialize_base64, + 'object': self.deserialize_object, + '[]': self.deserialize_iter, + '{}': self.deserialize_dict + } + self.deserialize_expected_types = { + 'duration': (isodate.Duration, datetime.timedelta), + 'iso-8601': (datetime.datetime) + } + self.dependencies = 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 + # complicated, with no real scenario for now. + # So adding a flag to disable additional properties detection. This flag should be + # used if your expect the deserialization to NOT come from a JSON REST syntax. + # Otherwise, result are unexpected + self.additional_properties_detection = True + + def __call__(self, target_obj, response_data, content_type=None): + """Call the deserializer to process a REST response. + + :param str target_obj: Target data type to deserialize to. + :param requests.Response response_data: REST response object. + :param str content_type: Swagger "produces" if available. + :raises: DeserializationError if deserialization fails. + :return: Deserialized object. + """ + data = self._unpack_content(response_data, content_type) + return self._deserialize(target_obj, data) + + def _deserialize(self, target_obj, data): + """Call the deserializer on a model. + + Data needs to be already deserialized as JSON or XML ElementTree + + :param str target_obj: Target data type to deserialize to. + :param object data: Object to deserialize. + :raises: DeserializationError if deserialization fails. + :return: Deserialized object. + """ + # This is already a model, go recursive just in case + if hasattr(data, "_attribute_map"): + constants = [name for name, config in getattr(data, '_validation', {}).items() + if config.get('constant')] + try: + for attr, mapconfig in data._attribute_map.items(): + if attr in constants: + continue + value = getattr(data, attr) + if value is None: + continue + local_type = mapconfig['type'] + internal_data_type = local_type.strip('[]{}') + if internal_data_type not in self.dependencies or isinstance(internal_data_type, Enum): + continue + setattr( + data, + attr, + self._deserialize(local_type, value) + ) + return data + except AttributeError: + return + + response, class_name = self._classify_target(target_obj, data) + + if isinstance(response, basestring): + return self.deserialize_data(data, response) + elif isinstance(response, type) and issubclass(response, Enum): + return self.deserialize_enum(data, response) + + if data is None: + return data + try: + attributes = response._attribute_map + d_attrs = {} + for attr, attr_desc in attributes.items(): + # Check empty string. If it's not empty, someone has a real "additionalProperties"... + if attr == "additional_properties" and attr_desc["key"] == '': + continue + raw_value = None + # Enhance attr_desc with some dynamic data + attr_desc = attr_desc.copy() # Do a copy, do not change the real one + internal_data_type = attr_desc["type"].strip('[]{}') + if internal_data_type in self.dependencies: + attr_desc["internalType"] = self.dependencies[internal_data_type] + + for key_extractor in self.key_extractors: + found_value = key_extractor(attr, attr_desc, data) + if found_value is not None: + if raw_value is not None and raw_value != found_value: + msg = ("Ignoring extracted value '%s' from %s for key '%s'" + " (duplicate extraction, follow extractors order)" ) + _LOGGER.warning( + msg, + found_value, + key_extractor, + attr + ) + continue + raw_value = found_value + + 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 + raise_with_traceback(DeserializationError, msg, err) + else: + additional_properties = self._build_additional_properties(attributes, data) + return self._instantiate_model(response, d_attrs, additional_properties) + + def _build_additional_properties(self, attribute_map, data): + if not self.additional_properties_detection: + return None + if "additional_properties" in attribute_map and attribute_map.get("additional_properties", {}).get("key") != '': + # Check empty string. If it's not empty, someone has a real "additionalProperties" + return None + if isinstance(data, ET.Element): + data = {el.tag: el.text for el in data} + + known_keys = {_decode_attribute_map_key(_FLATTEN.split(desc['key'])[0]) + for desc in attribute_map.values() if desc['key'] != ''} + present_keys = set(data.keys()) + missing_keys = present_keys - known_keys + return {key: data[key] for key in missing_keys} + + def _classify_target(self, target, data): + """Check to see whether the deserialization target object can + be classified into a subclass. + 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. + """ + if target is None: + return None, None + + if isinstance(target, basestring): + try: + target = self.dependencies[target] + except KeyError: + return target, target + + try: + target = target._classify(data, self.dependencies) + except AttributeError: + pass # Target is not a Model, no classify + return target, target.__class__.__name__ + + def failsafe_deserialize(self, target_obj, data, content_type=None): + """Ignores any errors encountered in deserialization, + and falls back to not deserializing the object. Recommended + for use in error deserialization, as we want to return the + HttpResponseError to users, and not have them deal with + 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 content_type: Swagger "produces" if available. + """ + try: + return self(target_obj, data, content_type=content_type) + except: + _LOGGER.debug( + "Ran into a deserialization error. Ignoring since this is failsafe deserialization", + exc_info=True + ) + return None + + @staticmethod + def _unpack_content(raw_data, content_type=None): + """Extract the correct structure for deserialization. + + If raw_data is a PipelineResponse, try to extract the result of RawDeserializer. + if we can't, raise. Your Pipeline should have a RawDeserializer. + + If not a pipeline response and raw_data is bytes or string, use content-type + to decode it. If no content-type, try JSON. + + If raw_data is something else, bypass all logic and return it directly. + + :param raw_data: Data to be processed. + :param content_type: How to parse if raw_data is a string/bytes. + :raises JSONDecodeError: If JSON is requested and parsing is impossible. + :raises UnicodeDecodeError: If bytes is not UTF8 + """ + # Assume this is enough to detect a Pipeline Response without importing it + context = getattr(raw_data, "context", {}) + if context: + if RawDeserializer.CONTEXT_NAME in context: + return context[RawDeserializer.CONTEXT_NAME] + raise ValueError("This pipeline didn't have the RawDeserializer policy; can't deserialize") + + #Assume this is enough to recognize universal_http.ClientResponse without importing it + if hasattr(raw_data, "body"): + return RawDeserializer.deserialize_from_http_generics( + raw_data.text(), + raw_data.headers + ) + + # Assume this enough to recognize requests.Response without importing it. + if hasattr(raw_data, '_content_consumed'): + 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 raw_data + + def _instantiate_model(self, response, attrs, additional_properties=None): + """Instantiate a response model passing in deserialized args. + + :param response: The response model class. + :param d_attrs: The deserialized response attributes. + """ + if callable(response): + subtype = getattr(response, '_subtype_map', {}) + try: + readonly = [k for k, v in response._validation.items() + if v.get('readonly')] + const = [k for k, v in response._validation.items() + if v.get('constant')] + kwargs = {k: v for k, v in attrs.items() + if k not in subtype and k not in readonly + const} + response_obj = response(**kwargs) + for attr in readonly: + setattr(response_obj, attr, attrs.get(attr)) + if additional_properties: + response_obj.additional_properties = additional_properties + return response_obj + except TypeError as err: + msg = "Unable to deserialize {} into model {}. ".format( + kwargs, response) + raise DeserializationError(msg + str(err)) + else: + try: + for attr, value in attrs.items(): + setattr(response, attr, value) + return response + except Exception as exp: + msg = "Unable to populate response model. " + msg += "Type: {}, Error: {}".format(type(response), exp) + raise DeserializationError(msg) + + def deserialize_data(self, data, data_type): + """Process data for deserialization according to data type. + + :param str data: The response string to be deserialized. + :param str data_type: The type to deserialize to. + :raises: DeserializationError if deserialization fails. + :return: Deserialized object. + """ + if data is None: + return data + + try: + if not data_type: + return data + if data_type in self.basic_types.values(): + return self.deserialize_basic(data, data_type) + if data_type in self.deserialize_type: + if isinstance(data, self.deserialize_expected_types.get(data_type, tuple())): + return data + + is_a_text_parsing_type = lambda x: x not in ["object", "[]", r"{}"] + if isinstance(data, ET.Element) and is_a_text_parsing_type(data_type) and not data.text: + return None + data_val = self.deserialize_type[data_type](data) + return data_val + + iter_type = data_type[0] + data_type[-1] + if iter_type in self.deserialize_type: + return self.deserialize_type[iter_type](data, data_type[1:-1]) + + obj_type = self.dependencies[data_type] + if issubclass(obj_type, Enum): + if isinstance(data, ET.Element): + data = data.text + return self.deserialize_enum(data, obj_type) + + except (ValueError, TypeError, AttributeError) as err: + msg = "Unable to deserialize response data." + msg += " Data: {}, {}".format(data, data_type) + raise_with_traceback(DeserializationError, msg, err) + else: + return self._deserialize(obj_type, data) + + def deserialize_iter(self, attr, iter_type): + """Deserialize an iterable. + + :param list attr: Iterable to be deserialized. + :param str iter_type: The type of object in the iterable. + :rtype: list + """ + if attr is None: + return None + if isinstance(attr, ET.Element): # If I receive an element here, get the children + attr = list(attr) + if not isinstance(attr, (list, set)): + raise DeserializationError("Cannot deserialize as [{}] an object of type {}".format( + iter_type, + type(attr) + )) + return [self.deserialize_data(a, iter_type) for a in attr] + + def deserialize_dict(self, attr, dict_type): + """Deserialize a dictionary. + + :param dict/list attr: Dictionary to be deserialized. Also accepts + a list of key, value pairs. + :param str dict_type: The object type of the items in the dictionary. + :rtype: dict + """ + if isinstance(attr, list): + return {x['key']: self.deserialize_data(x['value'], dict_type) for x in attr} + + if isinstance(attr, ET.Element): + # Transform value into {"Key": "value"} + attr = {el.tag: el.text for el in attr} + return {k: self.deserialize_data(v, dict_type) for k, v in attr.items()} + + def deserialize_object(self, attr, **kwargs): + """Deserialize a generic object. + This will be handled as a dictionary. + + :param dict attr: Dictionary to be deserialized. + :rtype: dict + :raises: TypeError if non-builtin datatype encountered. + """ + if attr is None: + return None + if isinstance(attr, ET.Element): + # Do no recurse on XML, just return the tree as-is + return attr + if isinstance(attr, basestring): + return self.deserialize_basic(attr, 'str') + obj_type = type(attr) + if obj_type in self.basic_types: + return self.deserialize_basic(attr, self.basic_types[obj_type]) + if obj_type is _long_type: + return self.deserialize_long(attr) + + if obj_type == dict: + deserialized = {} + for key, value in attr.items(): + try: + deserialized[key] = self.deserialize_object( + value, **kwargs) + except ValueError: + deserialized[key] = None + return deserialized + + if obj_type == list: + deserialized = [] + for obj in attr: + try: + deserialized.append(self.deserialize_object( + obj, **kwargs)) + except ValueError: + pass + return deserialized + + else: + error = "Cannot deserialize generic object with type: " + raise TypeError(error + str(obj_type)) + + def deserialize_basic(self, attr, data_type): + """Deserialize basic builtin data type from string. + Will attempt to convert to str, int, float and bool. + This function will also accept '1', '0', 'true' and 'false' as + valid bool values. + + :param str attr: response string to be deserialized. + :param str data_type: deserialization data type. + :rtype: str, int, float or bool + :raises: TypeError if string format is not valid. + """ + # If we're here, data is supposed to be a basic type. + # If it's still an XML node, take the text + if isinstance(attr, ET.Element): + attr = attr.text + if not attr: + if data_type == "str": + # None or '', node is empty string. + return '' + else: + # None or '', node with a strong type is None. + # Don't try to model "empty bool" or "empty int" + return None + + if data_type == 'bool': + if attr in [True, False, 1, 0]: + return bool(attr) + elif isinstance(attr, basestring): + if attr.lower() in ['true', '1']: + return True + elif attr.lower() in ['false', '0']: + return False + raise TypeError("Invalid boolean value: {}".format(attr)) + + if data_type == 'str': + return self.deserialize_unicode(attr) + return eval(data_type)(attr) # nosec + + @staticmethod + def deserialize_unicode(data): + """Preserve unicode objects in Python 2, otherwise return data + as a string. + + :param str data: response string to be deserialized. + :rtype: str or unicode + """ + # We might be here because we have an enum modeled as string, + # and we try to deserialize a partial dict with enum inside + if isinstance(data, Enum): + return data + + # Consider this is real string + try: + if isinstance(data, unicode): + return data + except NameError: + return str(data) + else: + return str(data) + + @staticmethod + def deserialize_enum(data, enum_obj): + """Deserialize string into enum object. + + If the string is not a valid enum value it will be returned as-is + and a warning will be logged. + + :param str data: Response string to be deserialized. If this value is + None or invalid it will be returned as-is. + :param Enum enum_obj: Enum object to deserialize to. + :rtype: Enum + """ + if isinstance(data, enum_obj) or data is None: + return data + if isinstance(data, Enum): + data = data.value + if isinstance(data, int): + # Workaround. We might consider remove it in the future. + # https://github.com/Azure/azure-rest-api-specs/issues/141 + try: + return list(enum_obj.__members__.values())[data] + except IndexError: + error = "{!r} is not a valid index for enum {!r}" + raise DeserializationError(error.format(data, enum_obj)) + try: + return enum_obj(str(data)) + except ValueError: + for enum_value in enum_obj: + if enum_value.value.lower() == str(data).lower(): + return enum_value + # We don't fail anymore for unknown value, we deserialize as a string + _LOGGER.warning("Deserializer is not able to find %s as valid enum in %s", data, enum_obj) + return Deserializer.deserialize_unicode(data) + + @staticmethod + def deserialize_bytearray(attr): + """Deserialize string into bytearray. + + :param str attr: response string to be deserialized. + :rtype: bytearray + :raises: TypeError if string format invalid. + """ + if isinstance(attr, ET.Element): + attr = attr.text + return bytearray(b64decode(attr)) + + @staticmethod + def deserialize_base64(attr): + """Deserialize base64 encoded string into string. + + :param str attr: response string to be deserialized. + :rtype: bytearray + :raises: TypeError if string format invalid. + """ + if isinstance(attr, ET.Element): + attr = attr.text + padding = '=' * (3 - (len(attr) + 3) % 4) + attr = attr + padding + encoded = attr.replace('-', '+').replace('_', '/') + return b64decode(encoded) + + @staticmethod + def deserialize_decimal(attr): + """Deserialize string into Decimal object. + + :param str attr: response string to be deserialized. + :rtype: Decimal + :raises: DeserializationError if string format invalid. + """ + if isinstance(attr, ET.Element): + attr = attr.text + try: + return decimal.Decimal(attr) + except decimal.DecimalException as err: + msg = "Invalid decimal {}".format(attr) + raise_with_traceback(DeserializationError, msg, err) + + @staticmethod + def deserialize_long(attr): + """Deserialize string into long (Py2) or int (Py3). + + :param str attr: response string to be deserialized. + :rtype: long or int + :raises: ValueError if string format invalid. + """ + if isinstance(attr, ET.Element): + attr = attr.text + return _long_type(attr) + + @staticmethod + def deserialize_duration(attr): + """Deserialize ISO-8601 formatted string into TimeDelta object. + + :param str attr: response string to be deserialized. + :rtype: TimeDelta + :raises: DeserializationError if string format invalid. + """ + if isinstance(attr, ET.Element): + attr = attr.text + try: + duration = isodate.parse_duration(attr) + except(ValueError, OverflowError, AttributeError) as err: + msg = "Cannot deserialize duration object." + raise_with_traceback(DeserializationError, msg, err) + else: + return duration + + @staticmethod + def deserialize_date(attr): + """Deserialize ISO-8601 formatted string into Date object. + + :param str attr: response string to be deserialized. + :rtype: Date + :raises: DeserializationError if string format invalid. + """ + if isinstance(attr, ET.Element): + attr = attr.text + if re.search(r"[^\W\d_]", attr, re.I + re.U): + 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) + + @staticmethod + def deserialize_time(attr): + """Deserialize ISO-8601 formatted string into time object. + + :param str attr: response string to be deserialized. + :rtype: datetime.time + :raises: DeserializationError if string format invalid. + """ + if isinstance(attr, ET.Element): + attr = attr.text + if re.search(r"[^\W\d_]", attr, re.I + re.U): + raise DeserializationError("Date must have only digits and -. Received: %s" % attr) + return isodate.parse_time(attr) + + @staticmethod + def deserialize_rfc(attr): + """Deserialize RFC-1123 formatted string into Datetime object. + + :param str attr: response string to be deserialized. + :rtype: Datetime + :raises: DeserializationError if string format invalid. + """ + if isinstance(attr, ET.Element): + attr = attr.text + try: + parsed_date = email.utils.parsedate_tz(attr) + date_obj = datetime.datetime( + *parsed_date[:6], + tzinfo=_FixedOffset(datetime.timedelta(minutes=(parsed_date[9] or 0)/60)) + ) + if not date_obj.tzinfo: + date_obj = date_obj.astimezone(tz=TZ_UTC) + except ValueError as err: + msg = "Cannot deserialize to rfc datetime object." + raise_with_traceback(DeserializationError, msg, err) + else: + return date_obj + + @staticmethod + def deserialize_iso(attr): + """Deserialize ISO-8601 formatted string into Datetime object. + + :param str attr: response string to be deserialized. + :rtype: Datetime + :raises: DeserializationError if string format invalid. + """ + if isinstance(attr, ET.Element): + attr = attr.text + try: + attr = attr.upper() + match = Deserializer.valid_date.match(attr) + if not match: + raise ValueError("Invalid datetime string: " + attr) + + check_decimal = attr.split('.') + if len(check_decimal) > 1: + decimal_str = "" + for digit in check_decimal[1]: + if digit.isdigit(): + decimal_str += digit + else: + break + if len(decimal_str) > 6: + attr = attr.replace(decimal_str, decimal_str[0:6]) + + date_obj = isodate.parse_datetime(attr) + test_utc = date_obj.utctimetuple() + if test_utc.tm_year > 9999 or test_utc.tm_year < 1: + raise OverflowError("Hit max or min date") + except(ValueError, OverflowError, AttributeError) as err: + msg = "Cannot deserialize datetime object." + raise_with_traceback(DeserializationError, msg, err) + else: + return date_obj + + @staticmethod + def deserialize_unix(attr): + """Serialize Datetime object into IntTime format. + This is represented as seconds. + + :param int attr: Object to be serialized. + :rtype: Datetime + :raises: DeserializationError if format invalid + """ + if isinstance(attr, ET.Element): + attr = int(attr.text) + try: + date_obj = datetime.datetime.fromtimestamp(attr, TZ_UTC) + except ValueError as err: + msg = "Cannot deserialize to unix datetime object." + raise_with_traceback(DeserializationError, msg, err) + else: + return date_obj diff --git a/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/links/aio/_configuration.py b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/links/aio/_configuration.py index 3edb5cf1cc609..1acdc945ce8fd 100644 --- a/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/links/aio/_configuration.py +++ b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/links/aio/_configuration.py @@ -26,9 +26,9 @@ class ManagementLinkClientConfiguration(Configuration): Note that all parameters used to create this instance are saved as instance attributes. - :param credential: Credential needed for the client to connect to Azure. + :param credential: Credential needed for the client to connect to Azure. Required. :type credential: ~azure.core.credentials_async.AsyncTokenCredential - :param subscription_id: The ID of the target subscription. + :param subscription_id: The ID of the target subscription. Required. :type subscription_id: str """ diff --git a/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/links/aio/_management_link_client.py b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/links/aio/_management_link_client.py index 90ff19a937c45..2e48802ea8f93 100644 --- a/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/links/aio/_management_link_client.py +++ b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/links/aio/_management_link_client.py @@ -11,17 +11,15 @@ from typing import Any, Optional, TYPE_CHECKING -from msrest import Deserializer, Serializer - from azure.mgmt.core import AsyncARMPipelineClient from azure.profiles import KnownProfiles, ProfileDefinition from azure.profiles.multiapiclient import MultiApiClientMixin +from .._serialization import Deserializer, Serializer from ._configuration import ManagementLinkClientConfiguration if TYPE_CHECKING: # pylint: disable=unused-import,ungrouped-imports - from azure.core.credentials import TokenCredential from azure.core.credentials_async import AsyncTokenCredential class _SDKClient(object): @@ -42,9 +40,9 @@ class ManagementLinkClient(MultiApiClientMixin, _SDKClient): The api-version parameter sets the default API version if the operation group is not described in the profile. - :param credential: Credential needed for the client to connect to Azure. + :param credential: Credential needed for the client to connect to Azure. Required. :type credential: ~azure.core.credentials_async.AsyncTokenCredential - :param subscription_id: The ID of the target subscription. + :param subscription_id: The ID of the target subscription. Required. :type subscription_id: str :param api_version: API version to use if no profile is provided, or if missing in profile. :type api_version: str diff --git a/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/links/v2016_09_01/__init__.py b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/links/v2016_09_01/__init__.py index 70d7514c712f9..4b32da823ed86 100644 --- a/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/links/v2016_09_01/__init__.py +++ b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/links/v2016_09_01/__init__.py @@ -10,9 +10,15 @@ from ._version import VERSION __version__ = VERSION -__all__ = ['ManagementLinkClient'] -# `._patch.py` is used for handwritten extensions to the generated code -# Example: https://github.com/Azure/azure-sdk-for-python/blob/main/doc/dev/customize_code/how-to-patch-sdk-code.md -from ._patch import patch_sdk -patch_sdk() +try: + from ._patch import __all__ as _patch_all + from ._patch import * # type: ignore # pylint: disable=unused-wildcard-import +except ImportError: + _patch_all = [] +from ._patch import patch_sdk as _patch_sdk + +__all__ = ["ManagementLinkClient"] +__all__.extend([p for p in _patch_all if p not in __all__]) + +_patch_sdk() diff --git a/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/links/v2016_09_01/_configuration.py b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/links/v2016_09_01/_configuration.py index c425a02a8d05a..a0e58ec22702c 100644 --- a/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/links/v2016_09_01/_configuration.py +++ b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/links/v2016_09_01/_configuration.py @@ -25,23 +25,18 @@ class ManagementLinkClientConfiguration(Configuration): # pylint: disable=too-m Note that all parameters used to create this instance are saved as instance attributes. - :param credential: Credential needed for the client to connect to Azure. + :param credential: Credential needed for the client to connect to Azure. Required. :type credential: ~azure.core.credentials.TokenCredential - :param subscription_id: The ID of the target subscription. + :param subscription_id: The ID of the target subscription. Required. :type subscription_id: str :keyword api_version: Api Version. Default value is "2016-09-01". Note that overriding this default value may result in unsupported behavior. :paramtype api_version: str """ - def __init__( - self, - credential: "TokenCredential", - subscription_id: str, - **kwargs: Any - ) -> None: + def __init__(self, credential: "TokenCredential", subscription_id: str, **kwargs: Any) -> None: super(ManagementLinkClientConfiguration, self).__init__(**kwargs) - api_version = kwargs.pop('api_version', "2016-09-01") # type: str + api_version = kwargs.pop("api_version", "2016-09-01") # type: str if credential is None: raise ValueError("Parameter 'credential' must not be None.") @@ -51,23 +46,24 @@ def __init__( self.credential = credential self.subscription_id = subscription_id self.api_version = api_version - self.credential_scopes = kwargs.pop('credential_scopes', ['https://management.azure.com/.default']) - kwargs.setdefault('sdk_moniker', 'mgmt-resource/{}'.format(VERSION)) + self.credential_scopes = kwargs.pop("credential_scopes", ["https://management.azure.com/.default"]) + kwargs.setdefault("sdk_moniker", "mgmt-resource/{}".format(VERSION)) self._configure(**kwargs) def _configure( - self, - **kwargs # type: Any + self, **kwargs # type: Any ): # type: (...) -> 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) - self.logging_policy = kwargs.get('logging_policy') or policies.NetworkTraceLoggingPolicy(**kwargs) - self.http_logging_policy = kwargs.get('http_logging_policy') or ARMHttpLoggingPolicy(**kwargs) - self.retry_policy = kwargs.get('retry_policy') or policies.RetryPolicy(**kwargs) - self.custom_hook_policy = kwargs.get('custom_hook_policy') or policies.CustomHookPolicy(**kwargs) - self.redirect_policy = kwargs.get('redirect_policy') or policies.RedirectPolicy(**kwargs) - self.authentication_policy = kwargs.get('authentication_policy') + 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) + self.logging_policy = kwargs.get("logging_policy") or policies.NetworkTraceLoggingPolicy(**kwargs) + self.http_logging_policy = kwargs.get("http_logging_policy") or ARMHttpLoggingPolicy(**kwargs) + self.retry_policy = kwargs.get("retry_policy") or policies.RetryPolicy(**kwargs) + self.custom_hook_policy = kwargs.get("custom_hook_policy") or policies.CustomHookPolicy(**kwargs) + self.redirect_policy = kwargs.get("redirect_policy") or policies.RedirectPolicy(**kwargs) + self.authentication_policy = kwargs.get("authentication_policy") if self.credential and not self.authentication_policy: - self.authentication_policy = ARMChallengeAuthenticationPolicy(self.credential, *self.credential_scopes, **kwargs) + self.authentication_policy = ARMChallengeAuthenticationPolicy( + self.credential, *self.credential_scopes, **kwargs + ) diff --git a/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/links/v2016_09_01/_management_link_client.py b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/links/v2016_09_01/_management_link_client.py index 36a3ad09b6b2c..597b8a10ffac6 100644 --- a/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/links/v2016_09_01/_management_link_client.py +++ b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/links/v2016_09_01/_management_link_client.py @@ -9,12 +9,11 @@ from copy import deepcopy from typing import Any, TYPE_CHECKING -from msrest import Deserializer, Serializer - from azure.core.rest import HttpRequest, HttpResponse from azure.mgmt.core import ARMPipelineClient from . import models +from .._serialization import Deserializer, Serializer from ._configuration import ManagementLinkClientConfiguration from .operations import Operations, ResourceLinksOperations @@ -22,7 +21,8 @@ # pylint: disable=unused-import,ungrouped-imports from azure.core.credentials import TokenCredential -class ManagementLinkClient: + +class ManagementLinkClient: # pylint: disable=client-accepts-api-version-keyword """Azure resources can be linked together to form logical relationships. You can establish links between resources belonging to different resource groups. However, all the linked resources must belong to the same subscription. Each resource can be linked to 50 other resources. If any @@ -33,9 +33,9 @@ class ManagementLinkClient: :ivar resource_links: ResourceLinksOperations operations :vartype resource_links: azure.mgmt.resource.links.v2016_09_01.operations.ResourceLinksOperations - :param credential: Credential needed for the client to connect to Azure. + :param credential: Credential needed for the client to connect to Azure. Required. :type credential: ~azure.core.credentials.TokenCredential - :param subscription_id: The ID of the target subscription. + :param subscription_id: The ID of the target subscription. Required. :type subscription_id: str :param base_url: Service URL. Default value is "https://management.azure.com". :type base_url: str @@ -51,7 +51,9 @@ def __init__( base_url: str = "https://management.azure.com", **kwargs: Any ) -> None: - self._config = ManagementLinkClientConfiguration(credential=credential, subscription_id=subscription_id, **kwargs) + self._config = ManagementLinkClientConfiguration( + credential=credential, subscription_id=subscription_id, **kwargs + ) self._client = ARMPipelineClient(base_url=base_url, config=self._config, **kwargs) client_models = {k: v for k, v in models.__dict__.items() if isinstance(v, type)} @@ -61,12 +63,7 @@ def __init__( self.operations = Operations(self._client, self._config, self._serialize, self._deserialize) self.resource_links = ResourceLinksOperations(self._client, self._config, self._serialize, self._deserialize) - - def _send_request( - self, - request: HttpRequest, - **kwargs: Any - ) -> HttpResponse: + def _send_request(self, request: HttpRequest, **kwargs: Any) -> HttpResponse: """Runs the network request through the client's chained policies. >>> from azure.core.rest import HttpRequest @@ -75,7 +72,7 @@ def _send_request( >>> response = client._send_request(request) - For more information on this code flow, see https://aka.ms/azsdk/python/protocol/quickstart + For more information on this code flow, see https://aka.ms/azsdk/dpcodegen/python/send_request :param request: The network request you want to make. Required. :type request: ~azure.core.rest.HttpRequest diff --git a/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/links/v2016_09_01/_metadata.json b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/links/v2016_09_01/_metadata.json index 6e087ada8a02c..f717f43986058 100644 --- a/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/links/v2016_09_01/_metadata.json +++ b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/links/v2016_09_01/_metadata.json @@ -10,20 +10,20 @@ "azure_arm": true, "has_lro_operations": false, "client_side_validation": false, - "sync_imports": "{\"typing\": {\"azurecore\": {\"azure.core.credentials\": [\"TokenCredential\"]}}, \"regular\": {\"azurecore\": {\"azure.profiles\": [\"KnownProfiles\", \"ProfileDefinition\"], \"azure.profiles.multiapiclient\": [\"MultiApiClientMixin\"], \"azure.mgmt.core\": [\"ARMPipelineClient\"]}, \"local\": {\"._configuration\": [\"ManagementLinkClientConfiguration\"]}, \"thirdparty\": {\"msrest\": [\"Deserializer\", \"Serializer\"]}}, \"conditional\": {\"stdlib\": {\"typing\": [\"Any\", \"Optional\"]}}}", - "async_imports": "{\"typing\": {\"azurecore\": {\"azure.core.credentials_async\": [\"AsyncTokenCredential\"], \"azure.core.credentials\": [\"TokenCredential\"]}}, \"regular\": {\"azurecore\": {\"azure.profiles\": [\"KnownProfiles\", \"ProfileDefinition\"], \"azure.profiles.multiapiclient\": [\"MultiApiClientMixin\"], \"azure.mgmt.core\": [\"AsyncARMPipelineClient\"]}, \"local\": {\"._configuration\": [\"ManagementLinkClientConfiguration\"]}, \"thirdparty\": {\"msrest\": [\"Deserializer\", \"Serializer\"]}}, \"conditional\": {\"stdlib\": {\"typing\": [\"Any\", \"Optional\"]}}}" + "sync_imports": "{\"conditional\": {\"stdlib\": {\"typing\": [\"Any\", \"Optional\"]}}, \"regular\": {\"azurecore\": {\"azure.mgmt.core\": [\"ARMPipelineClient\"], \"azure.profiles\": [\"KnownProfiles\", \"ProfileDefinition\"], \"azure.profiles.multiapiclient\": [\"MultiApiClientMixin\"]}, \"local\": {\"._configuration\": [\"ManagementLinkClientConfiguration\"], \".._serialization\": [\"Deserializer\", \"Serializer\"]}}, \"typing\": {\"azurecore\": {\"azure.core.credentials\": [\"TokenCredential\"]}}}", + "async_imports": "{\"conditional\": {\"stdlib\": {\"typing\": [\"Any\", \"Optional\"]}}, \"regular\": {\"azurecore\": {\"azure.mgmt.core\": [\"AsyncARMPipelineClient\"], \"azure.profiles\": [\"KnownProfiles\", \"ProfileDefinition\"], \"azure.profiles.multiapiclient\": [\"MultiApiClientMixin\"]}, \"local\": {\"._configuration\": [\"ManagementLinkClientConfiguration\"], \"..._serialization\": [\"Deserializer\", \"Serializer\"]}}, \"typing\": {\"azurecore\": {\"azure.core.credentials_async\": [\"AsyncTokenCredential\"]}}}" }, "global_parameters": { "sync": { "credential": { - "signature": "credential, # type: \"TokenCredential\"", - "description": "Credential needed for the client to connect to Azure.", + "signature": "credential: \"TokenCredential\",", + "description": "Credential needed for the client to connect to Azure. Required.", "docstring_type": "~azure.core.credentials.TokenCredential", "required": true }, "subscription_id": { - "signature": "subscription_id, # type: str", - "description": "The ID of the target subscription.", + "signature": "subscription_id: str,", + "description": "The ID of the target subscription. Required.", "docstring_type": "str", "required": true } @@ -31,13 +31,13 @@ "async": { "credential": { "signature": "credential: \"AsyncTokenCredential\",", - "description": "Credential needed for the client to connect to Azure.", + "description": "Credential needed for the client to connect to Azure. Required.", "docstring_type": "~azure.core.credentials_async.AsyncTokenCredential", "required": true }, "subscription_id": { "signature": "subscription_id: str,", - "description": "The ID of the target subscription.", + "description": "The ID of the target subscription. Required.", "docstring_type": "str", "required": true } @@ -54,7 +54,7 @@ "required": false }, "base_url": { - "signature": "base_url=\"https://management.azure.com\", # type: str", + "signature": "base_url: str = \"https://management.azure.com\",", "description": "Service URL", "docstring_type": "str", "required": false diff --git a/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/links/v2016_09_01/_patch.py b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/links/v2016_09_01/_patch.py index 74e48ecd07cf3..f99e77fef9861 100644 --- a/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/links/v2016_09_01/_patch.py +++ b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/links/v2016_09_01/_patch.py @@ -28,4 +28,4 @@ # This file is used for handwritten extensions to the generated code. Example: # https://github.com/Azure/azure-sdk-for-python/blob/main/doc/dev/customize_code/how-to-patch-sdk-code.md def patch_sdk(): - pass \ No newline at end of file + pass diff --git a/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/links/v2016_09_01/_vendor.py b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/links/v2016_09_01/_vendor.py index 138f663c53a4e..9aad73fc743e7 100644 --- a/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/links/v2016_09_01/_vendor.py +++ b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/links/v2016_09_01/_vendor.py @@ -7,6 +7,7 @@ from azure.core.pipeline.transport import HttpRequest + def _convert_request(request, files=None): data = request.content if not files else None request = HttpRequest(method=request.method, url=request.url, headers=request.headers, data=data) @@ -14,6 +15,7 @@ def _convert_request(request, files=None): request.set_formdata_body(files) return request + def _format_url_section(template, **kwargs): components = template.split("/") while components: @@ -21,7 +23,5 @@ def _format_url_section(template, **kwargs): 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 - ] + components = [c for c in formatted_components if "{}".format(key.args[0]) not in c] template = "/".join(components) diff --git a/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/links/v2016_09_01/_version.py b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/links/v2016_09_01/_version.py index a012ac01c480c..e5754a47ce68f 100644 --- a/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/links/v2016_09_01/_version.py +++ b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/links/v2016_09_01/_version.py @@ -6,4 +6,4 @@ # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -VERSION = "21.1.0" +VERSION = "1.0.0b1" diff --git a/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/links/v2016_09_01/aio/__init__.py b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/links/v2016_09_01/aio/__init__.py index ea7512a1012fe..8779306581c31 100644 --- a/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/links/v2016_09_01/aio/__init__.py +++ b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/links/v2016_09_01/aio/__init__.py @@ -7,9 +7,15 @@ # -------------------------------------------------------------------------- from ._management_link_client import ManagementLinkClient -__all__ = ['ManagementLinkClient'] -# `._patch.py` is used for handwritten extensions to the generated code -# Example: https://github.com/Azure/azure-sdk-for-python/blob/main/doc/dev/customize_code/how-to-patch-sdk-code.md -from ._patch import patch_sdk -patch_sdk() +try: + from ._patch import __all__ as _patch_all + from ._patch import * # type: ignore # pylint: disable=unused-wildcard-import +except ImportError: + _patch_all = [] +from ._patch import patch_sdk as _patch_sdk + +__all__ = ["ManagementLinkClient"] +__all__.extend([p for p in _patch_all if p not in __all__]) + +_patch_sdk() diff --git a/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/links/v2016_09_01/aio/_configuration.py b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/links/v2016_09_01/aio/_configuration.py index d0201a05858c7..85d04a013adae 100644 --- a/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/links/v2016_09_01/aio/_configuration.py +++ b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/links/v2016_09_01/aio/_configuration.py @@ -25,23 +25,18 @@ class ManagementLinkClientConfiguration(Configuration): # pylint: disable=too-m Note that all parameters used to create this instance are saved as instance attributes. - :param credential: Credential needed for the client to connect to Azure. + :param credential: Credential needed for the client to connect to Azure. Required. :type credential: ~azure.core.credentials_async.AsyncTokenCredential - :param subscription_id: The ID of the target subscription. + :param subscription_id: The ID of the target subscription. Required. :type subscription_id: str :keyword api_version: Api Version. Default value is "2016-09-01". Note that overriding this default value may result in unsupported behavior. :paramtype api_version: str """ - def __init__( - self, - credential: "AsyncTokenCredential", - subscription_id: str, - **kwargs: Any - ) -> None: + def __init__(self, credential: "AsyncTokenCredential", subscription_id: str, **kwargs: Any) -> None: super(ManagementLinkClientConfiguration, self).__init__(**kwargs) - api_version = kwargs.pop('api_version', "2016-09-01") # type: str + api_version = kwargs.pop("api_version", "2016-09-01") # type: str if credential is None: raise ValueError("Parameter 'credential' must not be None.") @@ -51,22 +46,21 @@ def __init__( self.credential = credential self.subscription_id = subscription_id self.api_version = api_version - self.credential_scopes = kwargs.pop('credential_scopes', ['https://management.azure.com/.default']) - kwargs.setdefault('sdk_moniker', 'mgmt-resource/{}'.format(VERSION)) + self.credential_scopes = kwargs.pop("credential_scopes", ["https://management.azure.com/.default"]) + kwargs.setdefault("sdk_moniker", "mgmt-resource/{}".format(VERSION)) self._configure(**kwargs) - 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) - self.logging_policy = kwargs.get('logging_policy') or policies.NetworkTraceLoggingPolicy(**kwargs) - self.http_logging_policy = kwargs.get('http_logging_policy') or ARMHttpLoggingPolicy(**kwargs) - self.retry_policy = kwargs.get('retry_policy') or policies.AsyncRetryPolicy(**kwargs) - self.custom_hook_policy = kwargs.get('custom_hook_policy') or policies.CustomHookPolicy(**kwargs) - self.redirect_policy = kwargs.get('redirect_policy') or policies.AsyncRedirectPolicy(**kwargs) - self.authentication_policy = kwargs.get('authentication_policy') + 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) + self.logging_policy = kwargs.get("logging_policy") or policies.NetworkTraceLoggingPolicy(**kwargs) + self.http_logging_policy = kwargs.get("http_logging_policy") or ARMHttpLoggingPolicy(**kwargs) + self.retry_policy = kwargs.get("retry_policy") or policies.AsyncRetryPolicy(**kwargs) + self.custom_hook_policy = kwargs.get("custom_hook_policy") or policies.CustomHookPolicy(**kwargs) + self.redirect_policy = kwargs.get("redirect_policy") or policies.AsyncRedirectPolicy(**kwargs) + self.authentication_policy = kwargs.get("authentication_policy") if self.credential and not self.authentication_policy: - self.authentication_policy = AsyncARMChallengeAuthenticationPolicy(self.credential, *self.credential_scopes, **kwargs) + self.authentication_policy = AsyncARMChallengeAuthenticationPolicy( + self.credential, *self.credential_scopes, **kwargs + ) diff --git a/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/links/v2016_09_01/aio/_management_link_client.py b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/links/v2016_09_01/aio/_management_link_client.py index 30431d68ac859..ba9c8130be263 100644 --- a/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/links/v2016_09_01/aio/_management_link_client.py +++ b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/links/v2016_09_01/aio/_management_link_client.py @@ -9,12 +9,11 @@ from copy import deepcopy from typing import Any, Awaitable, TYPE_CHECKING -from msrest import Deserializer, Serializer - from azure.core.rest import AsyncHttpResponse, HttpRequest from azure.mgmt.core import AsyncARMPipelineClient from .. import models +from ..._serialization import Deserializer, Serializer from ._configuration import ManagementLinkClientConfiguration from .operations import Operations, ResourceLinksOperations @@ -22,7 +21,8 @@ # pylint: disable=unused-import,ungrouped-imports from azure.core.credentials_async import AsyncTokenCredential -class ManagementLinkClient: + +class ManagementLinkClient: # pylint: disable=client-accepts-api-version-keyword """Azure resources can be linked together to form logical relationships. You can establish links between resources belonging to different resource groups. However, all the linked resources must belong to the same subscription. Each resource can be linked to 50 other resources. If any @@ -33,9 +33,9 @@ class ManagementLinkClient: :ivar resource_links: ResourceLinksOperations operations :vartype resource_links: azure.mgmt.resource.links.v2016_09_01.aio.operations.ResourceLinksOperations - :param credential: Credential needed for the client to connect to Azure. + :param credential: Credential needed for the client to connect to Azure. Required. :type credential: ~azure.core.credentials_async.AsyncTokenCredential - :param subscription_id: The ID of the target subscription. + :param subscription_id: The ID of the target subscription. Required. :type subscription_id: str :param base_url: Service URL. Default value is "https://management.azure.com". :type base_url: str @@ -51,7 +51,9 @@ def __init__( base_url: str = "https://management.azure.com", **kwargs: Any ) -> None: - self._config = ManagementLinkClientConfiguration(credential=credential, subscription_id=subscription_id, **kwargs) + self._config = ManagementLinkClientConfiguration( + credential=credential, subscription_id=subscription_id, **kwargs + ) self._client = AsyncARMPipelineClient(base_url=base_url, config=self._config, **kwargs) client_models = {k: v for k, v in models.__dict__.items() if isinstance(v, type)} @@ -61,12 +63,7 @@ def __init__( self.operations = Operations(self._client, self._config, self._serialize, self._deserialize) self.resource_links = ResourceLinksOperations(self._client, self._config, self._serialize, self._deserialize) - - def _send_request( - self, - request: HttpRequest, - **kwargs: Any - ) -> Awaitable[AsyncHttpResponse]: + def _send_request(self, request: HttpRequest, **kwargs: Any) -> Awaitable[AsyncHttpResponse]: """Runs the network request through the client's chained policies. >>> from azure.core.rest import HttpRequest @@ -75,7 +72,7 @@ def _send_request( >>> response = await client._send_request(request) - For more information on this code flow, see https://aka.ms/azsdk/python/protocol/quickstart + For more information on this code flow, see https://aka.ms/azsdk/dpcodegen/python/send_request :param request: The network request you want to make. Required. :type request: ~azure.core.rest.HttpRequest diff --git a/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/links/v2016_09_01/aio/_patch.py b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/links/v2016_09_01/aio/_patch.py index 74e48ecd07cf3..f99e77fef9861 100644 --- a/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/links/v2016_09_01/aio/_patch.py +++ b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/links/v2016_09_01/aio/_patch.py @@ -28,4 +28,4 @@ # This file is used for handwritten extensions to the generated code. Example: # https://github.com/Azure/azure-sdk-for-python/blob/main/doc/dev/customize_code/how-to-patch-sdk-code.md def patch_sdk(): - pass \ No newline at end of file + pass diff --git a/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/links/v2016_09_01/aio/operations/__init__.py b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/links/v2016_09_01/aio/operations/__init__.py index 77eaeb37af2b9..89ee702795da8 100644 --- a/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/links/v2016_09_01/aio/operations/__init__.py +++ b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/links/v2016_09_01/aio/operations/__init__.py @@ -9,7 +9,13 @@ from ._operations import Operations from ._operations import ResourceLinksOperations +from ._patch import __all__ as _patch_all +from ._patch import * # type: ignore # pylint: disable=unused-wildcard-import +from ._patch import patch_sdk as _patch_sdk + __all__ = [ - 'Operations', - 'ResourceLinksOperations', + "Operations", + "ResourceLinksOperations", ] +__all__.extend([p for p in _patch_all if p not in __all__]) +_patch_sdk() diff --git a/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/links/v2016_09_01/aio/operations/_operations.py b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/links/v2016_09_01/aio/operations/_operations.py index f7606830ca6c8..e391482618444 100644 --- a/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/links/v2016_09_01/aio/operations/_operations.py +++ b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/links/v2016_09_01/aio/operations/_operations.py @@ -6,82 +6,104 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -from typing import Any, AsyncIterable, Callable, Dict, Optional, TypeVar +from typing import Any, AsyncIterable, Callable, Dict, IO, Optional, TypeVar, Union, overload +from urllib.parse import parse_qs, urljoin, urlparse from azure.core.async_paging import AsyncItemPaged, AsyncList -from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error +from azure.core.exceptions import ( + ClientAuthenticationError, + HttpResponseError, + ResourceExistsError, + ResourceNotFoundError, + ResourceNotModifiedError, + map_error, +) from azure.core.pipeline import PipelineResponse from azure.core.pipeline.transport import AsyncHttpResponse from azure.core.rest import HttpRequest from azure.core.tracing.decorator import distributed_trace from azure.core.tracing.decorator_async import distributed_trace_async +from azure.core.utils import case_insensitive_dict from azure.mgmt.core.exceptions import ARMErrorFormat from ... import models as _models from ..._vendor import _convert_request -from ...operations._operations import build_operations_list_request, build_resource_links_create_or_update_request, build_resource_links_delete_request, build_resource_links_get_request, build_resource_links_list_at_source_scope_request, build_resource_links_list_at_subscription_request -T = TypeVar('T') +from ...operations._operations import ( + build_operations_list_request, + build_resource_links_create_or_update_request, + build_resource_links_delete_request, + build_resource_links_get_request, + build_resource_links_list_at_source_scope_request, + build_resource_links_list_at_subscription_request, +) + +T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] -class Operations: - """Operations async operations. - You should not instantiate this class directly. Instead, you should create a Client instance that - instantiates it for you and attaches it as an attribute. +class Operations: + """ + .. warning:: + **DO NOT** instantiate this class directly. - :ivar models: Alias to model classes used in this operation group. - :type models: ~azure.mgmt.resource.links.v2016_09_01.models - :param client: Client for service requests. - :param config: Configuration of service client. - :param serializer: An object model serializer. - :param deserializer: An object model deserializer. + Instead, you should access the following operations through + :class:`~azure.mgmt.resource.links.v2016_09_01.aio.ManagementLinkClient`'s + :attr:`operations` attribute. """ models = _models - def __init__(self, client, config, serializer, deserializer) -> None: - self._client = client - self._serialize = serializer - self._deserialize = deserializer - self._config = config + def __init__(self, *args, **kwargs) -> None: + input_args = list(args) + self._client = input_args.pop(0) if input_args else kwargs.pop("client") + self._config = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") @distributed_trace - def list( - self, - **kwargs: Any - ) -> AsyncIterable["_models.OperationListResult"]: + def list(self, **kwargs: Any) -> AsyncIterable["_models.Operation"]: """Lists all of the available Microsoft.Resources REST API operations. :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either OperationListResult or the result of cls(response) + :return: An iterator like instance of either Operation or the result of cls(response) :rtype: - ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.resource.links.v2016_09_01.models.OperationListResult] - :raises: ~azure.core.exceptions.HttpResponseError + ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.resource.links.v2016_09_01.models.Operation] + :raises ~azure.core.exceptions.HttpResponseError: """ - api_version = kwargs.pop('api_version', "2016-09-01") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2016-09-01")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[_models.OperationListResult] - cls = kwargs.pop('cls', None) # type: ClsType["_models.OperationListResult"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) + def prepare_request(next_link=None): if not next_link: - + request = build_operations_list_request( api_version=api_version, - template_url=self.list.metadata['url'], + template_url=self.list.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore else: - - request = build_operations_list_request( - template_url=next_link, - ) + # make call to next link with the client's api-version + _parsed_next_link = urlparse(next_link) + _next_request_params = case_insensitive_dict(parse_qs(_parsed_next_link.query)) + _next_request_params["api-version"] = self._config.api_version + request = HttpRequest("GET", urljoin(next_link, _parsed_next_link.path), params=_next_request_params) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore request.method = "GET" return request @@ -95,10 +117,8 @@ async def extract_data(pipeline_response): async def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) response = pipeline_response.http_response @@ -108,73 +128,73 @@ async def get_next(next_link=None): return pipeline_response + return AsyncItemPaged(get_next, extract_data) - return AsyncItemPaged( - get_next, extract_data - ) - list.metadata = {'url': "/providers/Microsoft.Resources/operations"} # type: ignore -class ResourceLinksOperations: - """ResourceLinksOperations async operations. + list.metadata = {"url": "/providers/Microsoft.Resources/operations"} # type: ignore - You should not instantiate this class directly. Instead, you should create a Client instance that - instantiates it for you and attaches it as an attribute. - :ivar models: Alias to model classes used in this operation group. - :type models: ~azure.mgmt.resource.links.v2016_09_01.models - :param client: Client for service requests. - :param config: Configuration of service client. - :param serializer: An object model serializer. - :param deserializer: An object model deserializer. +class ResourceLinksOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. + + Instead, you should access the following operations through + :class:`~azure.mgmt.resource.links.v2016_09_01.aio.ManagementLinkClient`'s + :attr:`resource_links` attribute. """ models = _models - def __init__(self, client, config, serializer, deserializer) -> None: - self._client = client - self._serialize = serializer - self._deserialize = deserializer - self._config = config + def __init__(self, *args, **kwargs) -> None: + input_args = list(args) + self._client = input_args.pop(0) if input_args else kwargs.pop("client") + self._config = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") @distributed_trace_async - async def delete( # pylint: disable=inconsistent-return-statements - self, - link_id: str, - **kwargs: Any - ) -> None: + async def delete(self, link_id: str, **kwargs: Any) -> None: # pylint: disable=inconsistent-return-statements """Deletes a resource link with the specified ID. :param link_id: The fully qualified ID of the resource link. Use the format, /subscriptions/{subscription-id}/resourceGroups/{resource-group-name}/{provider-namespace}/{resource-type}/{resource-name}/Microsoft.Resources/links/{link-name}. For example, /subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/myGroup/Microsoft.Web/sites/mySite/Microsoft.Resources/links/myLink. + Required. :type link_id: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: None, or the result of cls(response) + :return: None or the result of cls(response) :rtype: None - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType[None] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + 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', "2016-09-01") # type: str + api_version = kwargs.pop("api_version", _params.pop("api-version", "2016-09-01")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[None] - request = build_resource_links_delete_request( link_id=link_id, api_version=api_version, - template_url=self.delete.metadata['url'], + template_url=self.delete.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200, 204]: @@ -184,56 +204,117 @@ async def delete( # pylint: disable=inconsistent-return-statements if cls: return cls(pipeline_response, None, {}) - delete.metadata = {'url': "/{linkId}"} # type: ignore + delete.metadata = {"url": "/{linkId}"} # type: ignore + + @overload + async def create_or_update( + self, link_id: str, parameters: _models.ResourceLink, *, content_type: str = "application/json", **kwargs: Any + ) -> _models.ResourceLink: + """Creates or updates a resource link between the specified resources. + + :param link_id: The fully qualified ID of the resource link. Use the format, + /subscriptions/{subscription-id}/resourceGroups/{resource-group-name}/{provider-namespace}/{resource-type}/{resource-name}/Microsoft.Resources/links/{link-name}. + For example, + /subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/myGroup/Microsoft.Web/sites/mySite/Microsoft.Resources/links/myLink. + Required. + :type link_id: str + :param parameters: Parameters for creating or updating a resource link. Required. + :type parameters: ~azure.mgmt.resource.links.v2016_09_01.models.ResourceLink + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: ResourceLink or the result of cls(response) + :rtype: ~azure.mgmt.resource.links.v2016_09_01.models.ResourceLink + :raises ~azure.core.exceptions.HttpResponseError: + """ + @overload + async def create_or_update( + self, link_id: str, parameters: IO, *, content_type: str = "application/json", **kwargs: Any + ) -> _models.ResourceLink: + """Creates or updates a resource link between the specified resources. + + :param link_id: The fully qualified ID of the resource link. Use the format, + /subscriptions/{subscription-id}/resourceGroups/{resource-group-name}/{provider-namespace}/{resource-type}/{resource-name}/Microsoft.Resources/links/{link-name}. + For example, + /subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/myGroup/Microsoft.Web/sites/mySite/Microsoft.Resources/links/myLink. + Required. + :type link_id: str + :param parameters: Parameters for creating or updating a resource link. Required. + :type parameters: IO + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: ResourceLink or the result of cls(response) + :rtype: ~azure.mgmt.resource.links.v2016_09_01.models.ResourceLink + :raises ~azure.core.exceptions.HttpResponseError: + """ @distributed_trace_async async def create_or_update( - self, - link_id: str, - parameters: "_models.ResourceLink", - **kwargs: Any - ) -> "_models.ResourceLink": + self, link_id: str, parameters: Union[_models.ResourceLink, IO], **kwargs: Any + ) -> _models.ResourceLink: """Creates or updates a resource link between the specified resources. :param link_id: The fully qualified ID of the resource link. Use the format, /subscriptions/{subscription-id}/resourceGroups/{resource-group-name}/{provider-namespace}/{resource-type}/{resource-name}/Microsoft.Resources/links/{link-name}. For example, /subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/myGroup/Microsoft.Web/sites/mySite/Microsoft.Resources/links/myLink. + Required. :type link_id: str - :param parameters: Parameters for creating or updating a resource link. - :type parameters: ~azure.mgmt.resource.links.v2016_09_01.models.ResourceLink + :param parameters: Parameters for creating or updating a resource link. Is either a model type + or a IO type. Required. + :type parameters: ~azure.mgmt.resource.links.v2016_09_01.models.ResourceLink or IO + :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. + Default value is None. + :paramtype content_type: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: ResourceLink, or the result of cls(response) + :return: ResourceLink or the result of cls(response) :rtype: ~azure.mgmt.resource.links.v2016_09_01.models.ResourceLink - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.ResourceLink"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) - api_version = kwargs.pop('api_version', "2016-09-01") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - _json = self._serialize.body(parameters, 'ResourceLink') + api_version = kwargs.pop("api_version", _params.pop("api-version", "2016-09-01")) # type: str + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.ResourceLink] + + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(parameters, (IO, bytes)): + _content = parameters + else: + _json = self._serialize.body(parameters, "ResourceLink") request = build_resource_links_create_or_update_request( link_id=link_id, api_version=api_version, content_type=content_type, json=_json, - template_url=self.create_or_update.metadata['url'], + content=_content, + template_url=self.create_or_update.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200, 201]: @@ -241,79 +322,78 @@ async def create_or_update( raise HttpResponseError(response=response, error_format=ARMErrorFormat) if response.status_code == 200: - deserialized = self._deserialize('ResourceLink', pipeline_response) + deserialized = self._deserialize("ResourceLink", pipeline_response) if response.status_code == 201: - deserialized = self._deserialize('ResourceLink', pipeline_response) + deserialized = self._deserialize("ResourceLink", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - create_or_update.metadata = {'url': "/{linkId}"} # type: ignore - + create_or_update.metadata = {"url": "/{linkId}"} # type: ignore @distributed_trace_async - async def get( - self, - link_id: str, - **kwargs: Any - ) -> "_models.ResourceLink": + async def get(self, link_id: str, **kwargs: Any) -> _models.ResourceLink: """Gets a resource link with the specified ID. :param link_id: The fully qualified Id of the resource link. For example, /subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/myGroup/Microsoft.Web/sites/mySite/Microsoft.Resources/links/myLink. + Required. :type link_id: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: ResourceLink, or the result of cls(response) + :return: ResourceLink or the result of cls(response) :rtype: ~azure.mgmt.resource.links.v2016_09_01.models.ResourceLink - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.ResourceLink"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + 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', "2016-09-01") # type: str + api_version = kwargs.pop("api_version", _params.pop("api-version", "2016-09-01")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[_models.ResourceLink] - request = build_resource_links_get_request( link_id=link_id, api_version=api_version, - template_url=self.get.metadata['url'], + template_url=self.get.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) - deserialized = self._deserialize('ResourceLink', pipeline_response) + deserialized = self._deserialize("ResourceLink", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - get.metadata = {'url': "/{linkId}"} # type: ignore - + get.metadata = {"url": "/{linkId}"} # type: ignore @distributed_trace def list_at_subscription( - self, - filter: Optional[str] = None, - **kwargs: Any - ) -> AsyncIterable["_models.ResourceLinkResult"]: + self, filter: Optional[str] = None, **kwargs: Any + ) -> AsyncIterable["_models.ResourceLink"]: """Gets all the linked resources for the subscription. :param filter: The filter to apply on the list resource links operation. The supported filter @@ -321,38 +401,47 @@ def list_at_subscription( None. :type filter: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either ResourceLinkResult or the result of cls(response) + :return: An iterator like instance of either ResourceLink or the result of cls(response) :rtype: - ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.resource.links.v2016_09_01.models.ResourceLinkResult] - :raises: ~azure.core.exceptions.HttpResponseError + ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.resource.links.v2016_09_01.models.ResourceLink] + :raises ~azure.core.exceptions.HttpResponseError: """ - api_version = kwargs.pop('api_version', "2016-09-01") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2016-09-01")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[_models.ResourceLinkResult] - cls = kwargs.pop('cls', None) # type: ClsType["_models.ResourceLinkResult"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) + def prepare_request(next_link=None): if not next_link: - + request = build_resource_links_list_at_subscription_request( subscription_id=self._config.subscription_id, - api_version=api_version, filter=filter, - template_url=self.list_at_subscription.metadata['url'], + api_version=api_version, + template_url=self.list_at_subscription.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore else: - - request = build_resource_links_list_at_subscription_request( - subscription_id=self._config.subscription_id, - template_url=next_link, - ) + # make call to next link with the client's api-version + _parsed_next_link = urlparse(next_link) + _next_request_params = case_insensitive_dict(parse_qs(_parsed_next_link.query)) + _next_request_params["api-version"] = self._config.api_version + request = HttpRequest("GET", urljoin(next_link, _parsed_next_link.path), params=_next_request_params) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore request.method = "GET" return request @@ -366,10 +455,8 @@ async def extract_data(pipeline_response): async def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) response = pipeline_response.http_response @@ -379,62 +466,66 @@ async def get_next(next_link=None): return pipeline_response + return AsyncItemPaged(get_next, extract_data) - return AsyncItemPaged( - get_next, extract_data - ) - list_at_subscription.metadata = {'url': "/subscriptions/{subscriptionId}/providers/Microsoft.Resources/links"} # type: ignore + list_at_subscription.metadata = {"url": "/subscriptions/{subscriptionId}/providers/Microsoft.Resources/links"} # type: ignore @distributed_trace def list_at_source_scope( - self, - scope: str, - filter: Optional[str] = "atScope()", - **kwargs: Any - ) -> AsyncIterable["_models.ResourceLinkResult"]: + self, scope: str, filter: str = "atScope()", **kwargs: Any + ) -> AsyncIterable["_models.ResourceLink"]: """Gets a list of resource links at and below the specified source scope. :param scope: The fully qualified ID of the scope for getting the resource links. For example, to list resource links at and under a resource group, set the scope to - /subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/myGroup. + /subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/myGroup. Required. :type scope: str :param filter: The filter to apply when getting resource links. To get links only at the - specified scope (not below the scope), use Filter.atScope(). Possible values are "atScope()" or + specified scope (not below the scope), use Filter.atScope(). Known values are "atScope()" and None. Default value is "atScope()". :type filter: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either ResourceLinkResult or the result of cls(response) + :return: An iterator like instance of either ResourceLink or the result of cls(response) :rtype: - ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.resource.links.v2016_09_01.models.ResourceLinkResult] - :raises: ~azure.core.exceptions.HttpResponseError + ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.resource.links.v2016_09_01.models.ResourceLink] + :raises ~azure.core.exceptions.HttpResponseError: """ - api_version = kwargs.pop('api_version', "2016-09-01") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2016-09-01")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[_models.ResourceLinkResult] - cls = kwargs.pop('cls', None) # type: ClsType["_models.ResourceLinkResult"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) + def prepare_request(next_link=None): if not next_link: - + request = build_resource_links_list_at_source_scope_request( scope=scope, - api_version=api_version, filter=filter, - template_url=self.list_at_source_scope.metadata['url'], + api_version=api_version, + template_url=self.list_at_source_scope.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore else: - - request = build_resource_links_list_at_source_scope_request( - scope=scope, - template_url=next_link, - ) + # make call to next link with the client's api-version + _parsed_next_link = urlparse(next_link) + _next_request_params = case_insensitive_dict(parse_qs(_parsed_next_link.query)) + _next_request_params["api-version"] = self._config.api_version + request = HttpRequest("GET", urljoin(next_link, _parsed_next_link.path), params=_next_request_params) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore request.method = "GET" return request @@ -448,10 +539,8 @@ async def extract_data(pipeline_response): async def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) response = pipeline_response.http_response @@ -461,8 +550,6 @@ async def get_next(next_link=None): return pipeline_response + return AsyncItemPaged(get_next, extract_data) - return AsyncItemPaged( - get_next, extract_data - ) - list_at_source_scope.metadata = {'url': "/{scope}/providers/Microsoft.Resources/links"} # type: ignore + list_at_source_scope.metadata = {"url": "/{scope}/providers/Microsoft.Resources/links"} # type: ignore diff --git a/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/links/v2016_09_01/aio/operations/_patch.py b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/links/v2016_09_01/aio/operations/_patch.py new file mode 100644 index 0000000000000..f7dd32510333d --- /dev/null +++ b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/links/v2016_09_01/aio/operations/_patch.py @@ -0,0 +1,20 @@ +# ------------------------------------ +# Copyright (c) Microsoft Corporation. +# Licensed under the MIT License. +# ------------------------------------ +"""Customize generated code here. + +Follow our quickstart for examples: https://aka.ms/azsdk/python/dpcodegen/python/customize +""" +from typing import List + +__all__: List[str] = [] # Add all objects you want publicly available to users at this package level + + +def patch_sdk(): + """Do not remove from this file. + + `patch_sdk` is a last resort escape hatch that allows you to do customizations + you can't accomplish using the techniques described in + https://aka.ms/azsdk/python/dpcodegen/python/customize + """ diff --git a/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/links/v2016_09_01/models/__init__.py b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/links/v2016_09_01/models/__init__.py index 2fdfa31c60e67..07cdd79d75c79 100644 --- a/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/links/v2016_09_01/models/__init__.py +++ b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/links/v2016_09_01/models/__init__.py @@ -13,14 +13,18 @@ from ._models_py3 import ResourceLinkFilter from ._models_py3 import ResourceLinkProperties from ._models_py3 import ResourceLinkResult - +from ._patch import __all__ as _patch_all +from ._patch import * # type: ignore # pylint: disable=unused-wildcard-import +from ._patch import patch_sdk as _patch_sdk __all__ = [ - 'Operation', - 'OperationDisplay', - 'OperationListResult', - 'ResourceLink', - 'ResourceLinkFilter', - 'ResourceLinkProperties', - 'ResourceLinkResult', + "Operation", + "OperationDisplay", + "OperationListResult", + "ResourceLink", + "ResourceLinkFilter", + "ResourceLinkProperties", + "ResourceLinkResult", ] +__all__.extend([p for p in _patch_all if p not in __all__]) +_patch_sdk() diff --git a/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/links/v2016_09_01/models/_models_py3.py b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/links/v2016_09_01/models/_models_py3.py index ffc3cac3e583f..485292ca58502 100644 --- a/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/links/v2016_09_01/models/_models_py3.py +++ b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/links/v2016_09_01/models/_models_py3.py @@ -1,4 +1,5 @@ # coding=utf-8 +# pylint: disable=too-many-lines # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. # Licensed under the MIT License. See License.txt in the project root for license information. @@ -6,12 +7,16 @@ # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -from typing import List, Optional +from typing import List, Optional, TYPE_CHECKING -import msrest.serialization +from ... import _serialization +if TYPE_CHECKING: + # pylint: disable=unused-import,ungrouped-imports + from .. import models as _models -class Operation(msrest.serialization.Model): + +class Operation(_serialization.Model): """Microsoft.Resources operation. :ivar name: Operation name: {provider}/{resource}/{operation}. @@ -21,29 +26,23 @@ class Operation(msrest.serialization.Model): """ _attribute_map = { - 'name': {'key': 'name', 'type': 'str'}, - 'display': {'key': 'display', 'type': 'OperationDisplay'}, + "name": {"key": "name", "type": "str"}, + "display": {"key": "display", "type": "OperationDisplay"}, } - def __init__( - self, - *, - name: Optional[str] = None, - display: Optional["OperationDisplay"] = None, - **kwargs - ): + def __init__(self, *, name: Optional[str] = None, display: Optional["_models.OperationDisplay"] = None, **kwargs): """ :keyword name: Operation name: {provider}/{resource}/{operation}. :paramtype name: str :keyword display: The object that represents the operation. :paramtype display: ~azure.mgmt.resource.links.v2016_09_01.models.OperationDisplay """ - super(Operation, self).__init__(**kwargs) + super().__init__(**kwargs) self.name = name self.display = display -class OperationDisplay(msrest.serialization.Model): +class OperationDisplay(_serialization.Model): """The object that represents the operation. :ivar provider: Service provider: Microsoft.Resources. @@ -57,10 +56,10 @@ class OperationDisplay(msrest.serialization.Model): """ _attribute_map = { - 'provider': {'key': 'provider', 'type': 'str'}, - 'resource': {'key': 'resource', 'type': 'str'}, - 'operation': {'key': 'operation', 'type': 'str'}, - 'description': {'key': 'description', 'type': 'str'}, + "provider": {"key": "provider", "type": "str"}, + "resource": {"key": "resource", "type": "str"}, + "operation": {"key": "operation", "type": "str"}, + "description": {"key": "description", "type": "str"}, } def __init__( @@ -82,14 +81,14 @@ def __init__( :keyword description: Description of the operation. :paramtype description: str """ - super(OperationDisplay, self).__init__(**kwargs) + super().__init__(**kwargs) self.provider = provider self.resource = resource self.operation = operation self.description = description -class OperationListResult(msrest.serialization.Model): +class OperationListResult(_serialization.Model): """Result of the request to list Microsoft.Resources operations. It contains a list of operations and a URL link to get the next set of results. :ivar value: List of Microsoft.Resources operations. @@ -99,29 +98,23 @@ class OperationListResult(msrest.serialization.Model): """ _attribute_map = { - 'value': {'key': 'value', 'type': '[Operation]'}, - 'next_link': {'key': 'nextLink', 'type': 'str'}, + "value": {"key": "value", "type": "[Operation]"}, + "next_link": {"key": "nextLink", "type": "str"}, } - def __init__( - self, - *, - value: Optional[List["Operation"]] = None, - next_link: Optional[str] = None, - **kwargs - ): + def __init__(self, *, value: Optional[List["_models.Operation"]] = None, next_link: Optional[str] = None, **kwargs): """ :keyword value: List of Microsoft.Resources operations. :paramtype value: list[~azure.mgmt.resource.links.v2016_09_01.models.Operation] :keyword next_link: URL to get the next set of operation list results if there are any. :paramtype next_link: str """ - super(OperationListResult, self).__init__(**kwargs) + super().__init__(**kwargs) self.value = value self.next_link = next_link -class ResourceLink(msrest.serialization.Model): +class ResourceLink(_serialization.Model): """The resource link. Variables are only populated by the server, and will be ignored when sending a request. @@ -131,73 +124,63 @@ class ResourceLink(msrest.serialization.Model): :ivar name: The name of the resource link. :vartype name: str :ivar type: The resource link object. - :vartype type: any + :vartype type: JSON :ivar properties: Properties for resource link. :vartype properties: ~azure.mgmt.resource.links.v2016_09_01.models.ResourceLinkProperties """ _validation = { - 'id': {'readonly': True}, - 'name': {'readonly': True}, - 'type': {'readonly': True}, + "id": {"readonly": True}, + "name": {"readonly": True}, + "type": {"readonly": True}, } _attribute_map = { - 'id': {'key': 'id', 'type': 'str'}, - 'name': {'key': 'name', 'type': 'str'}, - 'type': {'key': 'type', 'type': 'object'}, - 'properties': {'key': 'properties', 'type': 'ResourceLinkProperties'}, + "id": {"key": "id", "type": "str"}, + "name": {"key": "name", "type": "str"}, + "type": {"key": "type", "type": "object"}, + "properties": {"key": "properties", "type": "ResourceLinkProperties"}, } - def __init__( - self, - *, - properties: Optional["ResourceLinkProperties"] = None, - **kwargs - ): + def __init__(self, *, properties: Optional["_models.ResourceLinkProperties"] = None, **kwargs): """ :keyword properties: Properties for resource link. :paramtype properties: ~azure.mgmt.resource.links.v2016_09_01.models.ResourceLinkProperties """ - super(ResourceLink, self).__init__(**kwargs) + super().__init__(**kwargs) self.id = None self.name = None self.type = None self.properties = properties -class ResourceLinkFilter(msrest.serialization.Model): +class ResourceLinkFilter(_serialization.Model): """Resource link filter. All required parameters must be populated in order to send to Azure. - :ivar target_id: Required. The ID of the target resource. + :ivar target_id: The ID of the target resource. Required. :vartype target_id: str """ _validation = { - 'target_id': {'required': True}, + "target_id": {"required": True}, } _attribute_map = { - 'target_id': {'key': 'targetId', 'type': 'str'}, + "target_id": {"key": "targetId", "type": "str"}, } - def __init__( - self, - *, - target_id: str, - **kwargs - ): + def __init__(self, *, target_id: str, **kwargs): """ - :keyword target_id: Required. The ID of the target resource. + :keyword target_id: The ID of the target resource. Required. :paramtype target_id: str """ - super(ResourceLinkFilter, self).__init__(**kwargs) + super().__init__(**kwargs) self.target_id = target_id -class ResourceLinkProperties(msrest.serialization.Model): +class ResourceLinkProperties(_serialization.Model): """The resource link properties. Variables are only populated by the server, and will be ignored when sending a request. @@ -206,75 +189,64 @@ class ResourceLinkProperties(msrest.serialization.Model): :ivar source_id: The fully qualified ID of the source resource in the link. :vartype source_id: str - :ivar target_id: Required. The fully qualified ID of the target resource in the link. + :ivar target_id: The fully qualified ID of the target resource in the link. Required. :vartype target_id: str :ivar notes: Notes about the resource link. :vartype notes: str """ _validation = { - 'source_id': {'readonly': True}, - 'target_id': {'required': True}, + "source_id": {"readonly": True}, + "target_id": {"required": True}, } _attribute_map = { - 'source_id': {'key': 'sourceId', 'type': 'str'}, - 'target_id': {'key': 'targetId', 'type': 'str'}, - 'notes': {'key': 'notes', 'type': 'str'}, + "source_id": {"key": "sourceId", "type": "str"}, + "target_id": {"key": "targetId", "type": "str"}, + "notes": {"key": "notes", "type": "str"}, } - def __init__( - self, - *, - target_id: str, - notes: Optional[str] = None, - **kwargs - ): + def __init__(self, *, target_id: str, notes: Optional[str] = None, **kwargs): """ - :keyword target_id: Required. The fully qualified ID of the target resource in the link. + :keyword target_id: The fully qualified ID of the target resource in the link. Required. :paramtype target_id: str :keyword notes: Notes about the resource link. :paramtype notes: str """ - super(ResourceLinkProperties, self).__init__(**kwargs) + super().__init__(**kwargs) self.source_id = None self.target_id = target_id self.notes = notes -class ResourceLinkResult(msrest.serialization.Model): +class ResourceLinkResult(_serialization.Model): """List of resource links. Variables are only populated by the server, and will be ignored when sending a request. All required parameters must be populated in order to send to Azure. - :ivar value: Required. An array of resource links. + :ivar value: An array of resource links. Required. :vartype value: list[~azure.mgmt.resource.links.v2016_09_01.models.ResourceLink] :ivar next_link: The URL to use for getting the next set of results. :vartype next_link: str """ _validation = { - 'value': {'required': True}, - 'next_link': {'readonly': True}, + "value": {"required": True}, + "next_link": {"readonly": True}, } _attribute_map = { - 'value': {'key': 'value', 'type': '[ResourceLink]'}, - 'next_link': {'key': 'nextLink', 'type': 'str'}, + "value": {"key": "value", "type": "[ResourceLink]"}, + "next_link": {"key": "nextLink", "type": "str"}, } - def __init__( - self, - *, - value: List["ResourceLink"], - **kwargs - ): + def __init__(self, *, value: List["_models.ResourceLink"], **kwargs): """ - :keyword value: Required. An array of resource links. + :keyword value: An array of resource links. Required. :paramtype value: list[~azure.mgmt.resource.links.v2016_09_01.models.ResourceLink] """ - super(ResourceLinkResult, self).__init__(**kwargs) + super().__init__(**kwargs) self.value = value self.next_link = None diff --git a/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/links/v2016_09_01/models/_patch.py b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/links/v2016_09_01/models/_patch.py new file mode 100644 index 0000000000000..f7dd32510333d --- /dev/null +++ b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/links/v2016_09_01/models/_patch.py @@ -0,0 +1,20 @@ +# ------------------------------------ +# Copyright (c) Microsoft Corporation. +# Licensed under the MIT License. +# ------------------------------------ +"""Customize generated code here. + +Follow our quickstart for examples: https://aka.ms/azsdk/python/dpcodegen/python/customize +""" +from typing import List + +__all__: List[str] = [] # Add all objects you want publicly available to users at this package level + + +def patch_sdk(): + """Do not remove from this file. + + `patch_sdk` is a last resort escape hatch that allows you to do customizations + you can't accomplish using the techniques described in + https://aka.ms/azsdk/python/dpcodegen/python/customize + """ diff --git a/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/links/v2016_09_01/operations/__init__.py b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/links/v2016_09_01/operations/__init__.py index 77eaeb37af2b9..89ee702795da8 100644 --- a/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/links/v2016_09_01/operations/__init__.py +++ b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/links/v2016_09_01/operations/__init__.py @@ -9,7 +9,13 @@ from ._operations import Operations from ._operations import ResourceLinksOperations +from ._patch import __all__ as _patch_all +from ._patch import * # type: ignore # pylint: disable=unused-wildcard-import +from ._patch import patch_sdk as _patch_sdk + __all__ = [ - 'Operations', - 'ResourceLinksOperations', + "Operations", + "ResourceLinksOperations", ] +__all__.extend([p for p in _patch_all if p not in __all__]) +_patch_sdk() diff --git a/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/links/v2016_09_01/operations/_operations.py b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/links/v2016_09_01/operations/_operations.py index d036f3dcb89f4..461a3b838aae1 100644 --- a/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/links/v2016_09_01/operations/_operations.py +++ b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/links/v2016_09_01/operations/_operations.py @@ -6,281 +6,242 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -from typing import Any, Callable, Dict, Iterable, Optional, TypeVar - -from msrest import Serializer - -from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error +from typing import Any, Callable, Dict, IO, Iterable, Optional, TypeVar, Union, overload +from urllib.parse import parse_qs, urljoin, urlparse + +from azure.core.exceptions import ( + ClientAuthenticationError, + HttpResponseError, + ResourceExistsError, + ResourceNotFoundError, + ResourceNotModifiedError, + map_error, +) from azure.core.paging import ItemPaged from azure.core.pipeline import PipelineResponse from azure.core.pipeline.transport import HttpResponse from azure.core.rest import HttpRequest from azure.core.tracing.decorator import distributed_trace +from azure.core.utils import case_insensitive_dict from azure.mgmt.core.exceptions import ARMErrorFormat from .. import models as _models +from ..._serialization import Serializer from .._vendor import _convert_request, _format_url_section -T = TypeVar('T') + +T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] -JSONType = Any _SERIALIZER = Serializer() _SERIALIZER.client_side_validation = False -def build_operations_list_request( - **kwargs: Any -) -> HttpRequest: - api_version = kwargs.pop('api_version', "2016-09-01") # type: str - accept = "application/json" +def build_operations_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", "2016-09-01")) # type: str + accept = _headers.pop("Accept", "application/json") + # Construct URL _url = kwargs.pop("template_url", "/providers/Microsoft.Resources/operations") # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - return HttpRequest( - method="GET", - url=_url, - params=_query_parameters, - headers=_header_parameters, - **kwargs - ) + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) -def build_resource_links_delete_request( - link_id: str, - **kwargs: Any -) -> HttpRequest: - api_version = kwargs.pop('api_version', "2016-09-01") # type: str +def build_resource_links_delete_request(link_id: str, **kwargs: Any) -> HttpRequest: + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + api_version = kwargs.pop("api_version", _params.pop("api-version", "2016-09-01")) # type: str # Construct URL _url = kwargs.pop("template_url", "/{linkId}") path_format_arguments = { - "linkId": _SERIALIZER.url("link_id", link_id, 'str', skip_quote=True), + "linkId": _SERIALIZER.url("link_id", link_id, "str", skip_quote=True), } _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') - - return HttpRequest( - method="DELETE", - url=_url, - params=_query_parameters, - **kwargs - ) - - -def build_resource_links_create_or_update_request( - link_id: str, - *, - json: JSONType = None, - content: Any = None, - **kwargs: Any -) -> HttpRequest: - api_version = kwargs.pop('api_version', "2016-09-01") # type: str - content_type = kwargs.pop('content_type', None) # type: Optional[str] + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") + + return HttpRequest(method="DELETE", url=_url, params=_params, **kwargs) + + +def build_resource_links_create_or_update_request(link_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", "2016-09-01")) # type: str + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + accept = _headers.pop("Accept", "application/json") - accept = "application/json" # Construct URL _url = kwargs.pop("template_url", "/{linkId}") path_format_arguments = { - "linkId": _SERIALIZER.url("link_id", link_id, 'str', skip_quote=True), + "linkId": _SERIALIZER.url("link_id", link_id, "str", skip_quote=True), } _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] if content_type is not None: - _header_parameters['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') - _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') - - return HttpRequest( - method="PUT", - url=_url, - params=_query_parameters, - headers=_header_parameters, - json=json, - content=content, - **kwargs - ) - - -def build_resource_links_get_request( - link_id: str, - **kwargs: Any -) -> HttpRequest: - api_version = kwargs.pop('api_version', "2016-09-01") # type: str + _headers["Content-Type"] = _SERIALIZER.header("content_type", content_type, "str") + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="PUT", url=_url, params=_params, headers=_headers, **kwargs) + + +def build_resource_links_get_request(link_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", "2016-09-01")) # type: str + accept = _headers.pop("Accept", "application/json") - accept = "application/json" # Construct URL _url = kwargs.pop("template_url", "/{linkId}") path_format_arguments = { - "linkId": _SERIALIZER.url("link_id", link_id, 'str', skip_quote=True), + "linkId": _SERIALIZER.url("link_id", link_id, "str", skip_quote=True), } _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - return HttpRequest( - method="GET", - url=_url, - params=_query_parameters, - headers=_header_parameters, - **kwargs - ) + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) def build_resource_links_list_at_subscription_request( - subscription_id: str, - *, - filter: Optional[str] = None, - **kwargs: Any + subscription_id: str, *, filter: Optional[str] = None, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2016-09-01") # type: 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", "2016-09-01")) # type: str + accept = _headers.pop("Accept", "application/json") - accept = "application/json" # Construct URL _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/providers/Microsoft.Resources/links") path_format_arguments = { - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), } _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] if filter is not None: - _query_parameters['$filter'] = _SERIALIZER.query("filter", filter, 'str') - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["$filter"] = _SERIALIZER.query("filter", filter, "str") + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - return HttpRequest( - method="GET", - url=_url, - params=_query_parameters, - headers=_header_parameters, - **kwargs - ) + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) def build_resource_links_list_at_source_scope_request( - scope: str, - *, - filter: Optional[str] = "atScope()", - **kwargs: Any + scope: str, *, filter: str = "atScope()", **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2016-09-01") # type: 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", "2016-09-01")) # type: str + accept = _headers.pop("Accept", "application/json") - accept = "application/json" # Construct URL _url = kwargs.pop("template_url", "/{scope}/providers/Microsoft.Resources/links") path_format_arguments = { - "scope": _SERIALIZER.url("scope", scope, 'str', skip_quote=True), + "scope": _SERIALIZER.url("scope", scope, "str", skip_quote=True), } _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] if filter is not None: - _query_parameters['$filter'] = _SERIALIZER.query("filter", filter, 'str') - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["$filter"] = _SERIALIZER.query("filter", filter, "str") + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') - - return HttpRequest( - method="GET", - url=_url, - params=_query_parameters, - headers=_header_parameters, - **kwargs - ) - -class Operations(object): - """Operations operations. - - You should not instantiate this class directly. Instead, you should create a Client instance that - instantiates it for you and attaches it as an attribute. - - :ivar models: Alias to model classes used in this operation group. - :type models: ~azure.mgmt.resource.links.v2016_09_01.models - :param client: Client for service requests. - :param config: Configuration of service client. - :param serializer: An object model serializer. - :param deserializer: An object model deserializer. + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) + + +class Operations: + """ + .. warning:: + **DO NOT** instantiate this class directly. + + Instead, you should access the following operations through + :class:`~azure.mgmt.resource.links.v2016_09_01.ManagementLinkClient`'s + :attr:`operations` attribute. """ models = _models - def __init__(self, client, config, serializer, deserializer): - self._client = client - self._serialize = serializer - self._deserialize = deserializer - self._config = config + def __init__(self, *args, **kwargs): + input_args = list(args) + self._client = input_args.pop(0) if input_args else kwargs.pop("client") + self._config = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") @distributed_trace - def list( - self, - **kwargs: Any - ) -> Iterable["_models.OperationListResult"]: + def list(self, **kwargs: Any) -> Iterable["_models.Operation"]: """Lists all of the available Microsoft.Resources REST API operations. :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either OperationListResult or the result of cls(response) - :rtype: - ~azure.core.paging.ItemPaged[~azure.mgmt.resource.links.v2016_09_01.models.OperationListResult] - :raises: ~azure.core.exceptions.HttpResponseError + :return: An iterator like instance of either Operation or the result of cls(response) + :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.resource.links.v2016_09_01.models.Operation] + :raises ~azure.core.exceptions.HttpResponseError: """ - api_version = kwargs.pop('api_version', "2016-09-01") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2016-09-01")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[_models.OperationListResult] - cls = kwargs.pop('cls', None) # type: ClsType["_models.OperationListResult"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) + def prepare_request(next_link=None): if not next_link: - + request = build_operations_list_request( api_version=api_version, - template_url=self.list.metadata['url'], + template_url=self.list.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore else: - - request = build_operations_list_request( - template_url=next_link, - ) + # make call to next link with the client's api-version + _parsed_next_link = urlparse(next_link) + _next_request_params = case_insensitive_dict(parse_qs(_parsed_next_link.query)) + _next_request_params["api-version"] = self._config.api_version + request = HttpRequest("GET", urljoin(next_link, _parsed_next_link.path), params=_next_request_params) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore request.method = "GET" return request @@ -294,10 +255,8 @@ def extract_data(pipeline_response): def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) response = pipeline_response.http_response @@ -307,73 +266,73 @@ def get_next(next_link=None): return pipeline_response + return ItemPaged(get_next, extract_data) - return ItemPaged( - get_next, extract_data - ) - list.metadata = {'url': "/providers/Microsoft.Resources/operations"} # type: ignore -class ResourceLinksOperations(object): - """ResourceLinksOperations operations. - - You should not instantiate this class directly. Instead, you should create a Client instance that - instantiates it for you and attaches it as an attribute. - - :ivar models: Alias to model classes used in this operation group. - :type models: ~azure.mgmt.resource.links.v2016_09_01.models - :param client: Client for service requests. - :param config: Configuration of service client. - :param serializer: An object model serializer. - :param deserializer: An object model deserializer. + list.metadata = {"url": "/providers/Microsoft.Resources/operations"} # type: ignore + + +class ResourceLinksOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. + + Instead, you should access the following operations through + :class:`~azure.mgmt.resource.links.v2016_09_01.ManagementLinkClient`'s + :attr:`resource_links` attribute. """ models = _models - def __init__(self, client, config, serializer, deserializer): - self._client = client - self._serialize = serializer - self._deserialize = deserializer - self._config = config + def __init__(self, *args, **kwargs): + input_args = list(args) + self._client = input_args.pop(0) if input_args else kwargs.pop("client") + self._config = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") @distributed_trace - def delete( # pylint: disable=inconsistent-return-statements - self, - link_id: str, - **kwargs: Any - ) -> None: + def delete(self, link_id: str, **kwargs: Any) -> None: # pylint: disable=inconsistent-return-statements """Deletes a resource link with the specified ID. :param link_id: The fully qualified ID of the resource link. Use the format, /subscriptions/{subscription-id}/resourceGroups/{resource-group-name}/{provider-namespace}/{resource-type}/{resource-name}/Microsoft.Resources/links/{link-name}. For example, /subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/myGroup/Microsoft.Web/sites/mySite/Microsoft.Resources/links/myLink. + Required. :type link_id: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: None, or the result of cls(response) + :return: None or the result of cls(response) :rtype: None - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType[None] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + 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', "2016-09-01") # type: str + api_version = kwargs.pop("api_version", _params.pop("api-version", "2016-09-01")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[None] - request = build_resource_links_delete_request( link_id=link_id, api_version=api_version, - template_url=self.delete.metadata['url'], + template_url=self.delete.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200, 204]: @@ -383,56 +342,117 @@ def delete( # pylint: disable=inconsistent-return-statements if cls: return cls(pipeline_response, None, {}) - delete.metadata = {'url': "/{linkId}"} # type: ignore + delete.metadata = {"url": "/{linkId}"} # type: ignore + + @overload + def create_or_update( + self, link_id: str, parameters: _models.ResourceLink, *, content_type: str = "application/json", **kwargs: Any + ) -> _models.ResourceLink: + """Creates or updates a resource link between the specified resources. + + :param link_id: The fully qualified ID of the resource link. Use the format, + /subscriptions/{subscription-id}/resourceGroups/{resource-group-name}/{provider-namespace}/{resource-type}/{resource-name}/Microsoft.Resources/links/{link-name}. + For example, + /subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/myGroup/Microsoft.Web/sites/mySite/Microsoft.Resources/links/myLink. + Required. + :type link_id: str + :param parameters: Parameters for creating or updating a resource link. Required. + :type parameters: ~azure.mgmt.resource.links.v2016_09_01.models.ResourceLink + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: ResourceLink or the result of cls(response) + :rtype: ~azure.mgmt.resource.links.v2016_09_01.models.ResourceLink + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + def create_or_update( + self, link_id: str, parameters: IO, *, content_type: str = "application/json", **kwargs: Any + ) -> _models.ResourceLink: + """Creates or updates a resource link between the specified resources. + :param link_id: The fully qualified ID of the resource link. Use the format, + /subscriptions/{subscription-id}/resourceGroups/{resource-group-name}/{provider-namespace}/{resource-type}/{resource-name}/Microsoft.Resources/links/{link-name}. + For example, + /subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/myGroup/Microsoft.Web/sites/mySite/Microsoft.Resources/links/myLink. + Required. + :type link_id: str + :param parameters: Parameters for creating or updating a resource link. Required. + :type parameters: IO + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: ResourceLink or the result of cls(response) + :rtype: ~azure.mgmt.resource.links.v2016_09_01.models.ResourceLink + :raises ~azure.core.exceptions.HttpResponseError: + """ @distributed_trace def create_or_update( - self, - link_id: str, - parameters: "_models.ResourceLink", - **kwargs: Any - ) -> "_models.ResourceLink": + self, link_id: str, parameters: Union[_models.ResourceLink, IO], **kwargs: Any + ) -> _models.ResourceLink: """Creates or updates a resource link between the specified resources. :param link_id: The fully qualified ID of the resource link. Use the format, /subscriptions/{subscription-id}/resourceGroups/{resource-group-name}/{provider-namespace}/{resource-type}/{resource-name}/Microsoft.Resources/links/{link-name}. For example, /subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/myGroup/Microsoft.Web/sites/mySite/Microsoft.Resources/links/myLink. + Required. :type link_id: str - :param parameters: Parameters for creating or updating a resource link. - :type parameters: ~azure.mgmt.resource.links.v2016_09_01.models.ResourceLink + :param parameters: Parameters for creating or updating a resource link. Is either a model type + or a IO type. Required. + :type parameters: ~azure.mgmt.resource.links.v2016_09_01.models.ResourceLink or IO + :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. + Default value is None. + :paramtype content_type: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: ResourceLink, or the result of cls(response) + :return: ResourceLink or the result of cls(response) :rtype: ~azure.mgmt.resource.links.v2016_09_01.models.ResourceLink - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.ResourceLink"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', "2016-09-01") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + api_version = kwargs.pop("api_version", _params.pop("api-version", "2016-09-01")) # type: str + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.ResourceLink] - _json = self._serialize.body(parameters, 'ResourceLink') + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(parameters, (IO, bytes)): + _content = parameters + else: + _json = self._serialize.body(parameters, "ResourceLink") request = build_resource_links_create_or_update_request( link_id=link_id, api_version=api_version, content_type=content_type, json=_json, - template_url=self.create_or_update.metadata['url'], + content=_content, + template_url=self.create_or_update.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200, 201]: @@ -440,79 +460,76 @@ def create_or_update( raise HttpResponseError(response=response, error_format=ARMErrorFormat) if response.status_code == 200: - deserialized = self._deserialize('ResourceLink', pipeline_response) + deserialized = self._deserialize("ResourceLink", pipeline_response) if response.status_code == 201: - deserialized = self._deserialize('ResourceLink', pipeline_response) + deserialized = self._deserialize("ResourceLink", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - create_or_update.metadata = {'url': "/{linkId}"} # type: ignore - + create_or_update.metadata = {"url": "/{linkId}"} # type: ignore @distributed_trace - def get( - self, - link_id: str, - **kwargs: Any - ) -> "_models.ResourceLink": + def get(self, link_id: str, **kwargs: Any) -> _models.ResourceLink: """Gets a resource link with the specified ID. :param link_id: The fully qualified Id of the resource link. For example, /subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/myGroup/Microsoft.Web/sites/mySite/Microsoft.Resources/links/myLink. + Required. :type link_id: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: ResourceLink, or the result of cls(response) + :return: ResourceLink or the result of cls(response) :rtype: ~azure.mgmt.resource.links.v2016_09_01.models.ResourceLink - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.ResourceLink"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) - api_version = kwargs.pop('api_version', "2016-09-01") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2016-09-01")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[_models.ResourceLink] - request = build_resource_links_get_request( link_id=link_id, api_version=api_version, - template_url=self.get.metadata['url'], + template_url=self.get.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) - deserialized = self._deserialize('ResourceLink', pipeline_response) + deserialized = self._deserialize("ResourceLink", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - get.metadata = {'url': "/{linkId}"} # type: ignore - + get.metadata = {"url": "/{linkId}"} # type: ignore @distributed_trace - def list_at_subscription( - self, - filter: Optional[str] = None, - **kwargs: Any - ) -> Iterable["_models.ResourceLinkResult"]: + def list_at_subscription(self, filter: Optional[str] = None, **kwargs: Any) -> Iterable["_models.ResourceLink"]: """Gets all the linked resources for the subscription. :param filter: The filter to apply on the list resource links operation. The supported filter @@ -520,38 +537,47 @@ def list_at_subscription( None. :type filter: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either ResourceLinkResult or the result of cls(response) + :return: An iterator like instance of either ResourceLink or the result of cls(response) :rtype: - ~azure.core.paging.ItemPaged[~azure.mgmt.resource.links.v2016_09_01.models.ResourceLinkResult] - :raises: ~azure.core.exceptions.HttpResponseError + ~azure.core.paging.ItemPaged[~azure.mgmt.resource.links.v2016_09_01.models.ResourceLink] + :raises ~azure.core.exceptions.HttpResponseError: """ - api_version = kwargs.pop('api_version', "2016-09-01") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2016-09-01")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[_models.ResourceLinkResult] - cls = kwargs.pop('cls', None) # type: ClsType["_models.ResourceLinkResult"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) + def prepare_request(next_link=None): if not next_link: - + request = build_resource_links_list_at_subscription_request( subscription_id=self._config.subscription_id, - api_version=api_version, filter=filter, - template_url=self.list_at_subscription.metadata['url'], + api_version=api_version, + template_url=self.list_at_subscription.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore else: - - request = build_resource_links_list_at_subscription_request( - subscription_id=self._config.subscription_id, - template_url=next_link, - ) + # make call to next link with the client's api-version + _parsed_next_link = urlparse(next_link) + _next_request_params = case_insensitive_dict(parse_qs(_parsed_next_link.query)) + _next_request_params["api-version"] = self._config.api_version + request = HttpRequest("GET", urljoin(next_link, _parsed_next_link.path), params=_next_request_params) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore request.method = "GET" return request @@ -565,10 +591,8 @@ def extract_data(pipeline_response): def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) response = pipeline_response.http_response @@ -578,62 +602,66 @@ def get_next(next_link=None): return pipeline_response + return ItemPaged(get_next, extract_data) - return ItemPaged( - get_next, extract_data - ) - list_at_subscription.metadata = {'url': "/subscriptions/{subscriptionId}/providers/Microsoft.Resources/links"} # type: ignore + list_at_subscription.metadata = {"url": "/subscriptions/{subscriptionId}/providers/Microsoft.Resources/links"} # type: ignore @distributed_trace def list_at_source_scope( - self, - scope: str, - filter: Optional[str] = "atScope()", - **kwargs: Any - ) -> Iterable["_models.ResourceLinkResult"]: + self, scope: str, filter: str = "atScope()", **kwargs: Any + ) -> Iterable["_models.ResourceLink"]: """Gets a list of resource links at and below the specified source scope. :param scope: The fully qualified ID of the scope for getting the resource links. For example, to list resource links at and under a resource group, set the scope to - /subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/myGroup. + /subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/myGroup. Required. :type scope: str :param filter: The filter to apply when getting resource links. To get links only at the - specified scope (not below the scope), use Filter.atScope(). Possible values are "atScope()" or + specified scope (not below the scope), use Filter.atScope(). Known values are "atScope()" and None. Default value is "atScope()". :type filter: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either ResourceLinkResult or the result of cls(response) + :return: An iterator like instance of either ResourceLink or the result of cls(response) :rtype: - ~azure.core.paging.ItemPaged[~azure.mgmt.resource.links.v2016_09_01.models.ResourceLinkResult] - :raises: ~azure.core.exceptions.HttpResponseError + ~azure.core.paging.ItemPaged[~azure.mgmt.resource.links.v2016_09_01.models.ResourceLink] + :raises ~azure.core.exceptions.HttpResponseError: """ - api_version = kwargs.pop('api_version', "2016-09-01") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2016-09-01")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[_models.ResourceLinkResult] - cls = kwargs.pop('cls', None) # type: ClsType["_models.ResourceLinkResult"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) + def prepare_request(next_link=None): if not next_link: - + request = build_resource_links_list_at_source_scope_request( scope=scope, - api_version=api_version, filter=filter, - template_url=self.list_at_source_scope.metadata['url'], + api_version=api_version, + template_url=self.list_at_source_scope.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore else: - - request = build_resource_links_list_at_source_scope_request( - scope=scope, - template_url=next_link, - ) + # make call to next link with the client's api-version + _parsed_next_link = urlparse(next_link) + _next_request_params = case_insensitive_dict(parse_qs(_parsed_next_link.query)) + _next_request_params["api-version"] = self._config.api_version + request = HttpRequest("GET", urljoin(next_link, _parsed_next_link.path), params=_next_request_params) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore request.method = "GET" return request @@ -647,10 +675,8 @@ def extract_data(pipeline_response): def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) response = pipeline_response.http_response @@ -660,8 +686,6 @@ def get_next(next_link=None): return pipeline_response + return ItemPaged(get_next, extract_data) - return ItemPaged( - get_next, extract_data - ) - list_at_source_scope.metadata = {'url': "/{scope}/providers/Microsoft.Resources/links"} # type: ignore + list_at_source_scope.metadata = {"url": "/{scope}/providers/Microsoft.Resources/links"} # type: ignore diff --git a/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/links/v2016_09_01/operations/_patch.py b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/links/v2016_09_01/operations/_patch.py new file mode 100644 index 0000000000000..f7dd32510333d --- /dev/null +++ b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/links/v2016_09_01/operations/_patch.py @@ -0,0 +1,20 @@ +# ------------------------------------ +# Copyright (c) Microsoft Corporation. +# Licensed under the MIT License. +# ------------------------------------ +"""Customize generated code here. + +Follow our quickstart for examples: https://aka.ms/azsdk/python/dpcodegen/python/customize +""" +from typing import List + +__all__: List[str] = [] # Add all objects you want publicly available to users at this package level + + +def patch_sdk(): + """Do not remove from this file. + + `patch_sdk` is a last resort escape hatch that allows you to do customizations + you can't accomplish using the techniques described in + https://aka.ms/azsdk/python/dpcodegen/python/customize + """ diff --git a/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/locks/__init__.py b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/locks/__init__.py index 2daa8df98bf2e..3141c047a5d55 100644 --- a/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/locks/__init__.py +++ b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/locks/__init__.py @@ -14,3 +14,7 @@ patch_sdk() except ImportError: pass + +from ._version import VERSION + +__version__ = VERSION diff --git a/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/locks/_configuration.py b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/locks/_configuration.py index 39cfe1f7a778d..8274a606e18ce 100644 --- a/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/locks/_configuration.py +++ b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/locks/_configuration.py @@ -8,7 +8,7 @@ # Changes may cause incorrect behavior and will be lost if the code is # regenerated. # -------------------------------------------------------------------------- -from typing import TYPE_CHECKING +from typing import Any, TYPE_CHECKING from azure.core.configuration import Configuration from azure.core.pipeline import policies @@ -18,8 +18,6 @@ if TYPE_CHECKING: # pylint: disable=unused-import,ungrouped-imports - from typing import Any - from azure.core.credentials import TokenCredential class ManagementLockClientConfiguration(Configuration): @@ -28,16 +26,16 @@ class ManagementLockClientConfiguration(Configuration): Note that all parameters used to create this instance are saved as instance attributes. - :param credential: Credential needed for the client to connect to Azure. + :param credential: Credential needed for the client to connect to Azure. Required. :type credential: ~azure.core.credentials.TokenCredential - :param subscription_id: The ID of the target subscription. + :param subscription_id: The ID of the target subscription. Required. :type subscription_id: str """ def __init__( self, - credential, # type: "TokenCredential" - subscription_id, # type: str + credential: "TokenCredential", + subscription_id: str, **kwargs # type: Any ): # type: (...) -> None diff --git a/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/locks/_management_lock_client.py b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/locks/_management_lock_client.py index 07a8ca5b576c2..bb4693c56603b 100644 --- a/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/locks/_management_lock_client.py +++ b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/locks/_management_lock_client.py @@ -9,20 +9,17 @@ # regenerated. # -------------------------------------------------------------------------- -from typing import TYPE_CHECKING - -from msrest import Deserializer, Serializer +from typing import Any, Optional, TYPE_CHECKING from azure.mgmt.core import ARMPipelineClient from azure.profiles import KnownProfiles, ProfileDefinition from azure.profiles.multiapiclient import MultiApiClientMixin from ._configuration import ManagementLockClientConfiguration +from ._serialization import Deserializer, Serializer if TYPE_CHECKING: # pylint: disable=unused-import,ungrouped-imports - from typing import Any, Optional - from azure.core.credentials import TokenCredential class _SDKClient(object): @@ -43,9 +40,9 @@ class ManagementLockClient(MultiApiClientMixin, _SDKClient): The api-version parameter sets the default API version if the operation group is not described in the profile. - :param credential: Credential needed for the client to connect to Azure. + :param credential: Credential needed for the client to connect to Azure. Required. :type credential: ~azure.core.credentials.TokenCredential - :param subscription_id: The ID of the target subscription. + :param subscription_id: The ID of the target subscription. Required. :type subscription_id: str :param api_version: API version to use if no profile is provided, or if missing in profile. :type api_version: str @@ -66,10 +63,10 @@ class ManagementLockClient(MultiApiClientMixin, _SDKClient): def __init__( self, - credential, # type: "TokenCredential" - subscription_id, # type: str + credential: "TokenCredential", + subscription_id: str, api_version=None, # type: Optional[str] - base_url="https://management.azure.com", # type: str + base_url: str = "https://management.azure.com", profile=KnownProfiles.default, # type: KnownProfiles **kwargs # type: Any ): diff --git a/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/locks/_serialization.py b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/locks/_serialization.py new file mode 100644 index 0000000000000..240df16c57f3c --- /dev/null +++ b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/locks/_serialization.py @@ -0,0 +1,2006 @@ +# -------------------------------------------------------------------------- +# +# Copyright (c) Microsoft Corporation. All rights reserved. +# +# The MIT License (MIT) +# +# Permission is hereby granted, free of charge, to any person obtaining a copy +# of this software and associated documentation files (the ""Software""), to +# deal in the Software without restriction, including without limitation the +# rights to use, copy, modify, merge, publish, distribute, sublicense, and/or +# sell copies of the Software, and to permit persons to whom the Software is +# furnished to do so, subject to the following conditions: +# +# The above copyright notice and this permission notice shall be included in +# all copies or substantial portions of the Software. +# +# THE SOFTWARE IS PROVIDED *AS IS*, WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING +# FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS +# IN THE SOFTWARE. +# +# -------------------------------------------------------------------------- + +# pylint: skip-file + +from base64 import b64decode, b64encode +import calendar +import datetime +import decimal +import email +from enum import Enum +import json +import logging +import re +import sys +import codecs +try: + from urllib import quote # type: ignore +except ImportError: + from urllib.parse import quote # type: ignore +import xml.etree.ElementTree as ET + +import isodate + +from typing import Dict, Any, cast, TYPE_CHECKING + +from azure.core.exceptions import DeserializationError, SerializationError, raise_with_traceback + +_BOM = codecs.BOM_UTF8.decode(encoding='utf-8') + +if TYPE_CHECKING: + from typing import Optional, Union, AnyStr, IO, Mapping + +class RawDeserializer: + + # Accept "text" because we're open minded people... + JSON_REGEXP = re.compile(r'^(application|text)/([a-z+.]+\+)?json$') + + # Name used in context + CONTEXT_NAME = "deserialized_data" + + @classmethod + def deserialize_from_text(cls, data, content_type=None): + # type: (Optional[Union[AnyStr, IO]], Optional[str]) -> Any + """Decode data according to content-type. + + Accept a stream of data as well, but will be load at once in memory for now. + + If no content-type, will return the string version (not bytes, not stream) + + :param data: Input, could be bytes or stream (will be decoded with UTF8) or text + :type data: str or bytes or IO + :param str content_type: The content type. + """ + if hasattr(data, 'read'): + # Assume a stream + data = cast(IO, data).read() + + if isinstance(data, bytes): + data_as_str = data.decode(encoding='utf-8-sig') + else: + # Explain to mypy the correct type. + data_as_str = cast(str, data) + + # Remove Byte Order Mark if present in string + data_as_str = data_as_str.lstrip(_BOM) + + if content_type is None: + return data + + if cls.JSON_REGEXP.match(content_type): + try: + return json.loads(data_as_str) + except ValueError as err: + raise DeserializationError("JSON is invalid: {}".format(err), err) + elif "xml" in (content_type or []): + try: + + try: + if isinstance(data, unicode): # type: ignore + # If I'm Python 2.7 and unicode XML will scream if I try a "fromstring" on unicode string + data_as_str = data_as_str.encode(encoding="utf-8") # type: ignore + except NameError: + pass + + return ET.fromstring(data_as_str) # nosec + except ET.ParseError: + # It might be because the server has an issue, and returned JSON with + # content-type XML.... + # So let's try a JSON load, and if it's still broken + # let's flow the initial exception + def _json_attemp(data): + try: + return True, json.loads(data) + except ValueError: + return False, None # Don't care about this one + success, json_result = _json_attemp(data) + if success: + return json_result + # If i'm here, it's not JSON, it's not XML, let's scream + # and raise the last context in this block (the XML exception) + # The function hack is because Py2.7 messes up with exception + # context otherwise. + _LOGGER.critical("Wasn't XML not JSON, failing") + raise_with_traceback(DeserializationError, "XML is invalid") + 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 + """Deserialize from HTTP response. + + Use bytes and headers to NOT use any requests/aiohttp or whatever + specific implementation. + Headers will tested for "content-type" + """ + # Try to use content-type from headers if available + content_type = None + if 'content-type' in headers: + content_type = headers['content-type'].split(";")[0].strip().lower() + # Ouch, this server did not declare what it sent... + # Let's guess it's JSON... + # Also, since Autorest was considering that an empty body was a valid JSON, + # need that test as well.... + else: + content_type = "application/json" + + if body_bytes: + return cls.deserialize_from_text(body_bytes, content_type) + return None + +try: + basestring # type: ignore + unicode_str = unicode # type: ignore +except NameError: + basestring = str # type: ignore + unicode_str = str # type: ignore + +_LOGGER = logging.getLogger(__name__) + +try: + _long_type = long # type: ignore +except NameError: + _long_type = int + +class UTC(datetime.tzinfo): + """Time Zone info for handling UTC""" + + def utcoffset(self, dt): + """UTF offset for UTC is 0.""" + return datetime.timedelta(0) + + def tzname(self, dt): + """Timestamp representation.""" + return "Z" + + def dst(self, dt): + """No daylight saving for UTC.""" + return datetime.timedelta(hours=1) + +try: + from datetime import timezone as _FixedOffset +except ImportError: # Python 2.7 + class _FixedOffset(datetime.tzinfo): # type: ignore + """Fixed offset in minutes east from UTC. + Copy/pasted from Python doc + :param datetime.timedelta offset: offset in timedelta format + """ + + def __init__(self, offset): + self.__offset = offset + + def utcoffset(self, dt): + return self.__offset + + def tzname(self, dt): + return str(self.__offset.total_seconds()/3600) + + def __repr__(self): + return "".format(self.tzname(None)) + + def dst(self, dt): + return datetime.timedelta(0) + + def __getinitargs__(self): + return (self.__offset,) + +try: + from datetime import timezone + TZ_UTC = timezone.utc # type: ignore +except ImportError: + TZ_UTC = UTC() # type: ignore + +_FLATTEN = re.compile(r"(? y, + "minimum": lambda x, y: x < y, + "maximum": lambda x, y: x > y, + "minimum_ex": lambda x, y: x <= y, + "maximum_ex": lambda x, y: x >= y, + "min_items": lambda x, y: len(x) < y, + "max_items": lambda x, y: len(x) > y, + "pattern": lambda x, y: not re.match(y, x, re.UNICODE), + "unique": lambda x, y: len(x) != len(set(x)), + "multiple": lambda x, y: x % y != 0 + } + + def __init__(self, classes=None): + self.serialize_type = { + 'iso-8601': Serializer.serialize_iso, + 'rfc-1123': Serializer.serialize_rfc, + 'unix-time': Serializer.serialize_unix, + 'duration': Serializer.serialize_duration, + 'date': Serializer.serialize_date, + 'time': Serializer.serialize_time, + 'decimal': Serializer.serialize_decimal, + 'long': Serializer.serialize_long, + 'bytearray': Serializer.serialize_bytearray, + 'base64': Serializer.serialize_base64, + 'object': self.serialize_object, + '[]': self.serialize_iter, + '{}': self.serialize_dict + } + self.dependencies = dict(classes) if classes else {} + self.key_transformer = full_restapi_key_transformer + self.client_side_validation = True + + def _serialize(self, target_obj, data_type=None, **kwargs): + """Serialize data into a string according to type. + + :param target_obj: The data to be serialized. + :param str data_type: The type to be serialized from. + :rtype: str, dict + :raises: SerializationError if serialization fails. + """ + key_transformer = kwargs.get("key_transformer", self.key_transformer) + keep_readonly = kwargs.get("keep_readonly", False) + if target_obj is None: + return None + + attr_name = None + class_name = target_obj.__class__.__name__ + + if data_type: + return self.serialize_data( + target_obj, data_type, **kwargs) + + if not hasattr(target_obj, "_attribute_map"): + data_type = type(target_obj).__name__ + if data_type in self.basic_types.values(): + return self.serialize_data( + target_obj, data_type, **kwargs) + + # Force "is_xml" kwargs if we detect a XML model + try: + is_xml_model_serialization = kwargs["is_xml"] + except KeyError: + is_xml_model_serialization = kwargs.setdefault("is_xml", target_obj.is_xml_model()) + + serialized = {} + if is_xml_model_serialization: + serialized = target_obj._create_xml_node() + try: + attributes = target_obj._attribute_map + for attr, attr_desc in attributes.items(): + attr_name = attr + if not keep_readonly and target_obj._validation.get(attr_name, {}).get('readonly', False): + continue + + if attr_name == "additional_properties" and attr_desc["key"] == '': + if target_obj.additional_properties is not None: + serialized.update(target_obj.additional_properties) + continue + try: + + orig_attr = getattr(target_obj, attr) + if is_xml_model_serialization: + pass # Don't provide "transformer" for XML for now. Keep "orig_attr" + else: # JSON + keys, orig_attr = key_transformer(attr, attr_desc.copy(), orig_attr) + keys = keys if isinstance(keys, list) else [keys] + + + kwargs["serialization_ctxt"] = attr_desc + new_attr = self.serialize_data(orig_attr, attr_desc['type'], **kwargs) + + + if is_xml_model_serialization: + xml_desc = attr_desc.get('xml', {}) + xml_name = xml_desc.get('name', attr_desc['key']) + xml_prefix = xml_desc.get('prefix', None) + xml_ns = xml_desc.get('ns', None) + 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) + continue + if xml_desc.get("text", False): + serialized.text = new_attr + continue + if isinstance(new_attr, list): + serialized.extend(new_attr) + 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', {}): + splitted_tag = new_attr.tag.split("}") + if len(splitted_tag) == 2: # Namespace + new_attr.tag = "}".join([splitted_tag[0], xml_name]) + else: + new_attr.tag = xml_name + serialized.append(new_attr) + 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) + else: # JSON + for k in reversed(keys): + unflattened = {k: new_attr} + new_attr = unflattened + + _new_attr = new_attr + _serialized = serialized + for k in keys: + if k not in _serialized: + _serialized.update(_new_attr) + _new_attr = _new_attr[k] + _serialized = _serialized[k] + except ValueError: + continue + + except (AttributeError, KeyError, TypeError) as err: + msg = "Attribute {} in object {} cannot be serialized.\n{}".format( + attr_name, class_name, str(target_obj)) + raise_with_traceback(SerializationError, msg, err) + else: + return serialized + + def body(self, data, data_type, **kwargs): + """Serialize data intended for a request body. + + :param data: The data to be serialized. + :param str data_type: The type to be serialized from. + :rtype: dict + :raises: SerializationError if serialization fails. + :raises: ValueError if data is None + """ + + # Just in case this is a dict + internal_data_type = data_type.strip('[]{}') + internal_data_type = self.dependencies.get(internal_data_type, None) + try: + is_xml_model_serialization = kwargs["is_xml"] + except KeyError: + if internal_data_type and issubclass(internal_data_type, Model): + is_xml_model_serialization = kwargs.setdefault("is_xml", internal_data_type.is_xml_model()) + else: + is_xml_model_serialization = False + if internal_data_type and not isinstance(internal_data_type, Enum): + try: + deserializer = Deserializer(self.dependencies) + # Since it's on serialization, it's almost sure that format is not JSON REST + # We're not able to deal with additional properties for now. + deserializer.additional_properties_detection = False + if is_xml_model_serialization: + deserializer.key_extractors = [ + attribute_key_case_insensitive_extractor, + ] + else: + deserializer.key_extractors = [ + rest_key_case_insensitive_extractor, + attribute_key_case_insensitive_extractor, + last_rest_key_case_insensitive_extractor + ] + data = deserializer._deserialize(data_type, data) + except DeserializationError as err: + raise_with_traceback( + SerializationError, "Unable to build a model: "+str(err), err) + + return self._serialize(data, data_type, **kwargs) + + def url(self, name, data, data_type, **kwargs): + """Serialize data intended for a URL path. + + :param data: The data to be serialized. + :param str data_type: The type to be serialized from. + :rtype: str + :raises: TypeError if serialization fails. + :raises: ValueError if data is None + """ + try: + output = self.serialize_data(data, data_type, **kwargs) + if data_type == 'bool': + output = json.dumps(output) + + if kwargs.get('skip_quote') is True: + output = str(output) + else: + output = quote(str(output), safe='') + except SerializationError: + raise TypeError("{} must be type {}.".format(name, data_type)) + else: + return output + + def query(self, name, data, data_type, **kwargs): + """Serialize data intended for a URL query. + + :param data: The data to be serialized. + :param str data_type: The type to be serialized from. + :rtype: str + :raises: TypeError if serialization fails. + :raises: ValueError if data is None + """ + try: + # 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)) + + # Not a list, regular serialization + output = self.serialize_data(data, data_type, **kwargs) + if data_type == 'bool': + output = json.dumps(output) + if kwargs.get('skip_quote') is True: + output = str(output) + else: + output = quote(str(output), safe='') + except SerializationError: + raise TypeError("{} must be type {}.".format(name, data_type)) + else: + return str(output) + + def header(self, name, data, data_type, **kwargs): + """Serialize data intended for a request header. + + :param data: The data to be serialized. + :param str data_type: The type to be serialized from. + :rtype: str + :raises: TypeError if serialization fails. + :raises: ValueError if data is None + """ + try: + if data_type in ['[str]']: + data = ["" if d is None else d for d in data] + + output = self.serialize_data(data, data_type, **kwargs) + if data_type == 'bool': + output = json.dumps(output) + except SerializationError: + raise TypeError("{} must be type {}.".format(name, data_type)) + else: + return str(output) + + def serialize_data(self, data, data_type, **kwargs): + """Serialize generic data according to supplied data type. + + :param data: The data to be serialized. + :param str data_type: The type to be serialized from. + :param bool required: Whether it's essential that the data not be + empty or None + :raises: AttributeError if required data is None. + :raises: ValueError if data is None + :raises: SerializationError if serialization fails. + """ + if data is None: + raise ValueError("No value for given attribute") + + try: + if data_type in self.basic_types.values(): + return self.serialize_basic(data, data_type, **kwargs) + + elif data_type in self.serialize_type: + return self.serialize_type[data_type](data, **kwargs) + + # If dependencies is empty, try with current data class + # It has to be a subclass of Enum anyway + enum_type = self.dependencies.get(data_type, data.__class__) + if issubclass(enum_type, Enum): + return Serializer.serialize_enum(data, enum_obj=enum_type) + + iter_type = data_type[0] + data_type[-1] + if iter_type in self.serialize_type: + return self.serialize_type[iter_type]( + data, data_type[1:-1], **kwargs) + + except (ValueError, TypeError) as err: + msg = "Unable to serialize value: {!r} as type: {!r}." + raise_with_traceback( + SerializationError, msg.format(data, data_type), err) + else: + return self._serialize(data, **kwargs) + + @classmethod + def _get_custom_serializers(cls, data_type, **kwargs): + custom_serializer = kwargs.get("basic_types_serializers", {}).get(data_type) + if custom_serializer: + return custom_serializer + if kwargs.get("is_xml", False): + return cls._xml_basic_types_serializers.get(data_type) + + @classmethod + def serialize_basic(cls, data, data_type, **kwargs): + """Serialize basic builting data type. + Serializes objects to str, int, float or bool. + + Possible kwargs: + - basic_types_serializers dict[str, callable] : If set, use the callable as serializer + - is_xml bool : If set, use xml_basic_types_serializers + + :param data: Object to be serialized. + :param str data_type: Type of object in the iterable. + """ + custom_serializer = cls._get_custom_serializers(data_type, **kwargs) + if custom_serializer: + return custom_serializer(data) + if data_type == 'str': + return cls.serialize_unicode(data) + return eval(data_type)(data) # nosec + + @classmethod + def serialize_unicode(cls, data): + """Special handling for serializing unicode strings in Py2. + Encode to UTF-8 if unicode, otherwise handle as a str. + + :param data: Object to be serialized. + :rtype: str + """ + try: # If I received an enum, return its value + return data.value + except AttributeError: + pass + + try: + if isinstance(data, unicode): + # Don't change it, JSON and XML ElementTree are totally able + # to serialize correctly u'' strings + return data + except NameError: + return str(data) + else: + return str(data) + + def serialize_iter(self, data, iter_type, div=None, **kwargs): + """Serialize iterable. + + Supported kwargs: + - serialization_ctxt dict : The current entry of _attribute_map, or same format. + serialization_ctxt['type'] should be same as data_type. + - is_xml bool : If set, serialize as XML + + :param list attr: Object to be serialized. + :param str iter_type: Type of object in the iterable. + :param bool required: Whether the objects in the iterable must + not be None or empty. + :param str div: If set, this str will be used to combine the elements + in the iterable into a combined string. Default is 'None'. + :rtype: list, str + """ + if isinstance(data, str): + raise SerializationError("Refuse str type as a valid iter type.") + + serialization_ctxt = kwargs.get("serialization_ctxt", {}) + is_xml = kwargs.get("is_xml", False) + + serialized = [] + for d in data: + try: + serialized.append(self.serialize_data(d, iter_type, **kwargs)) + except ValueError: + serialized.append(None) + + if div: + serialized = ['' if s is None else str(s) for s in serialized] + serialized = div.join(serialized) + + if 'xml' in serialization_ctxt or is_xml: + # XML serialization is more complicated + xml_desc = serialization_ctxt.get('xml', {}) + xml_name = xml_desc.get('name') + if not xml_name: + xml_name = serialization_ctxt['key'] + + # Create a wrap node if necessary (use the fact that Element and list have "append") + is_wrapped = xml_desc.get("wrapped", False) + node_name = xml_desc.get("itemsName", xml_name) + if is_wrapped: + final_result = _create_xml_node( + xml_name, + xml_desc.get('prefix', None), + xml_desc.get('ns', None) + ) + else: + final_result = [] + # All list elements to "local_node" + for el in serialized: + if isinstance(el, ET.Element): + el_node = el + else: + el_node = _create_xml_node( + node_name, + xml_desc.get('prefix', None), + xml_desc.get('ns', None) + ) + if el is not None: # Otherwise it writes "None" :-p + el_node.text = str(el) + final_result.append(el_node) + return final_result + return serialized + + def serialize_dict(self, attr, dict_type, **kwargs): + """Serialize a dictionary of objects. + + :param dict attr: Object to be serialized. + :param str dict_type: Type of object in the dictionary. + :param bool required: Whether the objects in the dictionary must + not be None or empty. + :rtype: dict + """ + serialization_ctxt = kwargs.get("serialization_ctxt", {}) + serialized = {} + for key, value in attr.items(): + try: + serialized[self.serialize_unicode(key)] = self.serialize_data( + value, dict_type, **kwargs) + except ValueError: + serialized[self.serialize_unicode(key)] = None + + if 'xml' in serialization_ctxt: + # XML serialization is more complicated + xml_desc = serialization_ctxt['xml'] + xml_name = xml_desc['name'] + + final_result = _create_xml_node( + xml_name, + xml_desc.get('prefix', None), + xml_desc.get('ns', None) + ) + for key, value in serialized.items(): + ET.SubElement(final_result, key).text = value + return final_result + + return serialized + + def serialize_object(self, attr, **kwargs): + """Serialize a generic object. + This will be handled as a dictionary. If object passed in is not + a basic type (str, int, float, dict, list) it will simply be + cast to str. + + :param dict attr: Object to be serialized. + :rtype: dict or str + """ + if attr is None: + return None + if isinstance(attr, ET.Element): + return attr + obj_type = type(attr) + if obj_type in self.basic_types: + return self.serialize_basic(attr, self.basic_types[obj_type], **kwargs) + if obj_type is _long_type: + return self.serialize_long(attr) + if obj_type is unicode_str: + return self.serialize_unicode(attr) + if obj_type is datetime.datetime: + return self.serialize_iso(attr) + if obj_type is datetime.date: + return self.serialize_date(attr) + if obj_type is datetime.time: + return self.serialize_time(attr) + if obj_type is datetime.timedelta: + return self.serialize_duration(attr) + if obj_type is decimal.Decimal: + return self.serialize_decimal(attr) + + # If it's a model or I know this dependency, serialize as a Model + elif obj_type in self.dependencies.values() or isinstance(attr, Model): + return self._serialize(attr) + + if obj_type == dict: + serialized = {} + for key, value in attr.items(): + try: + serialized[self.serialize_unicode(key)] = self.serialize_object( + value, **kwargs) + except ValueError: + serialized[self.serialize_unicode(key)] = None + return serialized + + if obj_type == list: + serialized = [] + for obj in attr: + try: + serialized.append(self.serialize_object( + obj, **kwargs)) + except ValueError: + pass + return serialized + return str(attr) + + @staticmethod + def serialize_enum(attr, enum_obj=None): + try: + result = attr.value + except AttributeError: + result = attr + try: + enum_obj(result) + return result + except ValueError: + for enum_value in enum_obj: + if enum_value.value.lower() == str(attr).lower(): + return enum_value.value + error = "{!r} is not valid value for enum {!r}" + raise SerializationError(error.format(attr, enum_obj)) + + @staticmethod + def serialize_bytearray(attr, **kwargs): + """Serialize bytearray into base-64 string. + + :param attr: Object to be serialized. + :rtype: str + """ + return b64encode(attr).decode() + + @staticmethod + def serialize_base64(attr, **kwargs): + """Serialize str into base-64 string. + + :param attr: Object to be serialized. + :rtype: str + """ + encoded = b64encode(attr).decode('ascii') + return encoded.strip('=').replace('+', '-').replace('/', '_') + + @staticmethod + def serialize_decimal(attr, **kwargs): + """Serialize Decimal object to float. + + :param attr: Object to be serialized. + :rtype: float + """ + return float(attr) + + @staticmethod + def serialize_long(attr, **kwargs): + """Serialize long (Py2) or int (Py3). + + :param attr: Object to be serialized. + :rtype: int/long + """ + return _long_type(attr) + + @staticmethod + def serialize_date(attr, **kwargs): + """Serialize Date object into ISO-8601 formatted string. + + :param Date attr: Object to be serialized. + :rtype: str + """ + if isinstance(attr, str): + attr = isodate.parse_date(attr) + t = "{:04}-{:02}-{:02}".format(attr.year, attr.month, attr.day) + return t + + @staticmethod + def serialize_time(attr, **kwargs): + """Serialize Time object into ISO-8601 formatted string. + + :param datetime.time attr: Object to be serialized. + :rtype: str + """ + if isinstance(attr, str): + attr = isodate.parse_time(attr) + t = "{:02}:{:02}:{:02}".format(attr.hour, attr.minute, attr.second) + if attr.microsecond: + t += ".{:02}".format(attr.microsecond) + return t + + @staticmethod + def serialize_duration(attr, **kwargs): + """Serialize TimeDelta object into ISO-8601 formatted string. + + :param TimeDelta attr: Object to be serialized. + :rtype: str + """ + if isinstance(attr, str): + attr = isodate.parse_duration(attr) + return isodate.duration_isoformat(attr) + + @staticmethod + def serialize_rfc(attr, **kwargs): + """Serialize Datetime object into RFC-1123 formatted string. + + :param Datetime attr: Object to be serialized. + :rtype: str + :raises: TypeError if format invalid. + """ + try: + if not attr.tzinfo: + _LOGGER.warning( + "Datetime with no tzinfo will be considered UTC.") + utc = attr.utctimetuple() + except AttributeError: + raise TypeError("RFC1123 object must be valid Datetime object.") + + return "{}, {:02} {} {:04} {:02}:{:02}:{:02} GMT".format( + Serializer.days[utc.tm_wday], utc.tm_mday, + Serializer.months[utc.tm_mon], utc.tm_year, + utc.tm_hour, utc.tm_min, utc.tm_sec) + + @staticmethod + def serialize_iso(attr, **kwargs): + """Serialize Datetime object into ISO-8601 formatted string. + + :param Datetime attr: Object to be serialized. + :rtype: str + :raises: SerializationError if format invalid. + """ + if isinstance(attr, str): + attr = isodate.parse_datetime(attr) + try: + if not attr.tzinfo: + _LOGGER.warning( + "Datetime with no tzinfo will be considered UTC.") + utc = attr.utctimetuple() + if utc.tm_year > 9999 or utc.tm_year < 1: + raise OverflowError("Hit max or min date") + + microseconds = str(attr.microsecond).rjust(6,'0').rstrip('0').ljust(3, '0') + if microseconds: + microseconds = '.'+microseconds + date = "{:04}-{:02}-{:02}T{:02}:{:02}:{:02}".format( + utc.tm_year, utc.tm_mon, utc.tm_mday, + utc.tm_hour, utc.tm_min, utc.tm_sec) + return date + microseconds + 'Z' + except (ValueError, OverflowError) as err: + msg = "Unable to serialize datetime object." + raise_with_traceback(SerializationError, msg, err) + except AttributeError as err: + msg = "ISO-8601 object must be valid Datetime object." + raise_with_traceback(TypeError, msg, err) + + @staticmethod + def serialize_unix(attr, **kwargs): + """Serialize Datetime object into IntTime format. + This is represented as seconds. + + :param Datetime attr: Object to be serialized. + :rtype: int + :raises: SerializationError if format invalid + """ + if isinstance(attr, int): + return attr + try: + if not attr.tzinfo: + _LOGGER.warning( + "Datetime with no tzinfo will be considered UTC.") + return int(calendar.timegm(attr.utctimetuple())) + except AttributeError: + raise TypeError("Unix time object must be valid Datetime object.") + +def rest_key_extractor(attr, attr_desc, data): + key = attr_desc['key'] + working_data = data + + while '.' in key: + dict_keys = _FLATTEN.split(key) + if len(dict_keys) == 1: + key = _decode_attribute_map_key(dict_keys[0]) + break + working_key = _decode_attribute_map_key(dict_keys[0]) + working_data = working_data.get(working_key, data) + if working_data is None: + # If at any point while following flatten JSON path see None, it means + # that all properties under are None as well + # https://github.com/Azure/msrest-for-python/issues/197 + return None + key = '.'.join(dict_keys[1:]) + + return working_data.get(key) + +def rest_key_case_insensitive_extractor(attr, attr_desc, data): + key = attr_desc['key'] + working_data = data + + while '.' in key: + dict_keys = _FLATTEN.split(key) + if len(dict_keys) == 1: + key = _decode_attribute_map_key(dict_keys[0]) + break + working_key = _decode_attribute_map_key(dict_keys[0]) + working_data = attribute_key_case_insensitive_extractor(working_key, None, working_data) + if working_data is None: + # If at any point while following flatten JSON path see None, it means + # that all properties under are None as well + # https://github.com/Azure/msrest-for-python/issues/197 + return None + key = '.'.join(dict_keys[1:]) + + if working_data: + return attribute_key_case_insensitive_extractor(key, None, working_data) + +def last_rest_key_extractor(attr, attr_desc, data): + """Extract the attribute in "data" based on the last part of the JSON path key. + """ + key = attr_desc['key'] + dict_keys = _FLATTEN.split(key) + return attribute_key_extractor(dict_keys[-1], None, data) + +def last_rest_key_case_insensitive_extractor(attr, attr_desc, data): + """Extract the attribute in "data" based on the last part of the JSON path key. + + This is the case insensitive version of "last_rest_key_extractor" + """ + key = attr_desc['key'] + dict_keys = _FLATTEN.split(key) + return attribute_key_case_insensitive_extractor(dict_keys[-1], None, data) + +def attribute_key_extractor(attr, _, data): + return data.get(attr) + +def attribute_key_case_insensitive_extractor(attr, _, data): + found_key = None + lower_attr = attr.lower() + for key in data: + if lower_attr == key.lower(): + found_key = key + break + + return data.get(found_key) + +def _extract_name_from_internal_type(internal_type): + """Given an internal type XML description, extract correct XML name with namespace. + + :param dict internal_type: An model type + :rtype: tuple + :returns: A tuple XML name + namespace dict + """ + internal_type_xml_map = getattr(internal_type, "_xml_map", {}) + 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) + return xml_name + + +def xml_key_extractor(attr, attr_desc, data): + if isinstance(data, dict): + return None + + # Test if this model is XML ready first + if not isinstance(data, ET.Element): + return None + + xml_desc = attr_desc.get('xml', {}) + xml_name = xml_desc.get('name', attr_desc['key']) + + # Look for a children + is_iter_type = attr_desc['type'].startswith("[") + is_wrapped = xml_desc.get("wrapped", False) + internal_type = attr_desc.get("internalType", None) + internal_type_xml_map = getattr(internal_type, "_xml_map", {}) + + # 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) + + # If it's an attribute, that's simple + if xml_desc.get("attr", False): + return data.get(xml_name) + + # If it's x-ms-text, that's simple too + if xml_desc.get("text", False): + return data.text + + # Scenario where I take the local name: + # - Wrapped node + # - Internal type is an enum (considered basic types) + # - Internal type has no XML/Name node + if is_wrapped or (internal_type and (issubclass(internal_type, Enum) or 'name' not in internal_type_xml_map)): + children = data.findall(xml_name) + # If internal type has a local name and it's not a list, I use that name + elif not is_iter_type and internal_type and 'name' in internal_type_xml_map: + xml_name = _extract_name_from_internal_type(internal_type) + children = data.findall(xml_name) + # That's an array + else: + if internal_type: # Complex type, ignore itemsName and use the complex type name + items_name = _extract_name_from_internal_type(internal_type) + else: + items_name = xml_desc.get("itemsName", xml_name) + children = data.findall(items_name) + + if len(children) == 0: + if is_iter_type: + if is_wrapped: + return None # is_wrapped no node, we want None + else: + return [] # not wrapped, assume empty list + return None # Assume it's not there, maybe an optional node. + + # If is_iter_type and not wrapped, return all found children + if is_iter_type: + if not is_wrapped: + return children + else: # Iter and wrapped, should have found one node only (the wrap one) + if len(children) != 1: + raise DeserializationError( + "Tried to deserialize an array not wrapped, and found several nodes '{}'. Maybe you should declare this array as wrapped?".format( + xml_name + )) + return list(children[0]) # Might be empty list and that's ok. + + # Here it's not a itertype, we should have found one element only or empty + if len(children) > 1: + raise DeserializationError("Find several XML '{}' where it was not expected".format(xml_name)) + return children[0] + +class Deserializer(object): + """Response object model deserializer. + + :param dict classes: Class type dictionary for deserializing complex types. + :ivar list key_extractors: Ordered list of extractors to be used by this deserializer. + """ + + basic_types = {str: 'str', int: 'int', bool: 'bool', float: 'float'} + + valid_date = re.compile( + r'\d{4}[-]\d{2}[-]\d{2}T\d{2}:\d{2}:\d{2}' + r'\.?\d*Z?[-+]?[\d{2}]?:?[\d{2}]?') + + def __init__(self, classes=None): + self.deserialize_type = { + 'iso-8601': Deserializer.deserialize_iso, + 'rfc-1123': Deserializer.deserialize_rfc, + 'unix-time': Deserializer.deserialize_unix, + 'duration': Deserializer.deserialize_duration, + 'date': Deserializer.deserialize_date, + 'time': Deserializer.deserialize_time, + 'decimal': Deserializer.deserialize_decimal, + 'long': Deserializer.deserialize_long, + 'bytearray': Deserializer.deserialize_bytearray, + 'base64': Deserializer.deserialize_base64, + 'object': self.deserialize_object, + '[]': self.deserialize_iter, + '{}': self.deserialize_dict + } + self.deserialize_expected_types = { + 'duration': (isodate.Duration, datetime.timedelta), + 'iso-8601': (datetime.datetime) + } + self.dependencies = 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 + # complicated, with no real scenario for now. + # So adding a flag to disable additional properties detection. This flag should be + # used if your expect the deserialization to NOT come from a JSON REST syntax. + # Otherwise, result are unexpected + self.additional_properties_detection = True + + def __call__(self, target_obj, response_data, content_type=None): + """Call the deserializer to process a REST response. + + :param str target_obj: Target data type to deserialize to. + :param requests.Response response_data: REST response object. + :param str content_type: Swagger "produces" if available. + :raises: DeserializationError if deserialization fails. + :return: Deserialized object. + """ + data = self._unpack_content(response_data, content_type) + return self._deserialize(target_obj, data) + + def _deserialize(self, target_obj, data): + """Call the deserializer on a model. + + Data needs to be already deserialized as JSON or XML ElementTree + + :param str target_obj: Target data type to deserialize to. + :param object data: Object to deserialize. + :raises: DeserializationError if deserialization fails. + :return: Deserialized object. + """ + # This is already a model, go recursive just in case + if hasattr(data, "_attribute_map"): + constants = [name for name, config in getattr(data, '_validation', {}).items() + if config.get('constant')] + try: + for attr, mapconfig in data._attribute_map.items(): + if attr in constants: + continue + value = getattr(data, attr) + if value is None: + continue + local_type = mapconfig['type'] + internal_data_type = local_type.strip('[]{}') + if internal_data_type not in self.dependencies or isinstance(internal_data_type, Enum): + continue + setattr( + data, + attr, + self._deserialize(local_type, value) + ) + return data + except AttributeError: + return + + response, class_name = self._classify_target(target_obj, data) + + if isinstance(response, basestring): + return self.deserialize_data(data, response) + elif isinstance(response, type) and issubclass(response, Enum): + return self.deserialize_enum(data, response) + + if data is None: + return data + try: + attributes = response._attribute_map + d_attrs = {} + for attr, attr_desc in attributes.items(): + # Check empty string. If it's not empty, someone has a real "additionalProperties"... + if attr == "additional_properties" and attr_desc["key"] == '': + continue + raw_value = None + # Enhance attr_desc with some dynamic data + attr_desc = attr_desc.copy() # Do a copy, do not change the real one + internal_data_type = attr_desc["type"].strip('[]{}') + if internal_data_type in self.dependencies: + attr_desc["internalType"] = self.dependencies[internal_data_type] + + for key_extractor in self.key_extractors: + found_value = key_extractor(attr, attr_desc, data) + if found_value is not None: + if raw_value is not None and raw_value != found_value: + msg = ("Ignoring extracted value '%s' from %s for key '%s'" + " (duplicate extraction, follow extractors order)" ) + _LOGGER.warning( + msg, + found_value, + key_extractor, + attr + ) + continue + raw_value = found_value + + 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 + raise_with_traceback(DeserializationError, msg, err) + else: + additional_properties = self._build_additional_properties(attributes, data) + return self._instantiate_model(response, d_attrs, additional_properties) + + def _build_additional_properties(self, attribute_map, data): + if not self.additional_properties_detection: + return None + if "additional_properties" in attribute_map and attribute_map.get("additional_properties", {}).get("key") != '': + # Check empty string. If it's not empty, someone has a real "additionalProperties" + return None + if isinstance(data, ET.Element): + data = {el.tag: el.text for el in data} + + known_keys = {_decode_attribute_map_key(_FLATTEN.split(desc['key'])[0]) + for desc in attribute_map.values() if desc['key'] != ''} + present_keys = set(data.keys()) + missing_keys = present_keys - known_keys + return {key: data[key] for key in missing_keys} + + def _classify_target(self, target, data): + """Check to see whether the deserialization target object can + be classified into a subclass. + 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. + """ + if target is None: + return None, None + + if isinstance(target, basestring): + try: + target = self.dependencies[target] + except KeyError: + return target, target + + try: + target = target._classify(data, self.dependencies) + except AttributeError: + pass # Target is not a Model, no classify + return target, target.__class__.__name__ + + def failsafe_deserialize(self, target_obj, data, content_type=None): + """Ignores any errors encountered in deserialization, + and falls back to not deserializing the object. Recommended + for use in error deserialization, as we want to return the + HttpResponseError to users, and not have them deal with + 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 content_type: Swagger "produces" if available. + """ + try: + return self(target_obj, data, content_type=content_type) + except: + _LOGGER.debug( + "Ran into a deserialization error. Ignoring since this is failsafe deserialization", + exc_info=True + ) + return None + + @staticmethod + def _unpack_content(raw_data, content_type=None): + """Extract the correct structure for deserialization. + + If raw_data is a PipelineResponse, try to extract the result of RawDeserializer. + if we can't, raise. Your Pipeline should have a RawDeserializer. + + If not a pipeline response and raw_data is bytes or string, use content-type + to decode it. If no content-type, try JSON. + + If raw_data is something else, bypass all logic and return it directly. + + :param raw_data: Data to be processed. + :param content_type: How to parse if raw_data is a string/bytes. + :raises JSONDecodeError: If JSON is requested and parsing is impossible. + :raises UnicodeDecodeError: If bytes is not UTF8 + """ + # Assume this is enough to detect a Pipeline Response without importing it + context = getattr(raw_data, "context", {}) + if context: + if RawDeserializer.CONTEXT_NAME in context: + return context[RawDeserializer.CONTEXT_NAME] + raise ValueError("This pipeline didn't have the RawDeserializer policy; can't deserialize") + + #Assume this is enough to recognize universal_http.ClientResponse without importing it + if hasattr(raw_data, "body"): + return RawDeserializer.deserialize_from_http_generics( + raw_data.text(), + raw_data.headers + ) + + # Assume this enough to recognize requests.Response without importing it. + if hasattr(raw_data, '_content_consumed'): + 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 raw_data + + def _instantiate_model(self, response, attrs, additional_properties=None): + """Instantiate a response model passing in deserialized args. + + :param response: The response model class. + :param d_attrs: The deserialized response attributes. + """ + if callable(response): + subtype = getattr(response, '_subtype_map', {}) + try: + readonly = [k for k, v in response._validation.items() + if v.get('readonly')] + const = [k for k, v in response._validation.items() + if v.get('constant')] + kwargs = {k: v for k, v in attrs.items() + if k not in subtype and k not in readonly + const} + response_obj = response(**kwargs) + for attr in readonly: + setattr(response_obj, attr, attrs.get(attr)) + if additional_properties: + response_obj.additional_properties = additional_properties + return response_obj + except TypeError as err: + msg = "Unable to deserialize {} into model {}. ".format( + kwargs, response) + raise DeserializationError(msg + str(err)) + else: + try: + for attr, value in attrs.items(): + setattr(response, attr, value) + return response + except Exception as exp: + msg = "Unable to populate response model. " + msg += "Type: {}, Error: {}".format(type(response), exp) + raise DeserializationError(msg) + + def deserialize_data(self, data, data_type): + """Process data for deserialization according to data type. + + :param str data: The response string to be deserialized. + :param str data_type: The type to deserialize to. + :raises: DeserializationError if deserialization fails. + :return: Deserialized object. + """ + if data is None: + return data + + try: + if not data_type: + return data + if data_type in self.basic_types.values(): + return self.deserialize_basic(data, data_type) + if data_type in self.deserialize_type: + if isinstance(data, self.deserialize_expected_types.get(data_type, tuple())): + return data + + is_a_text_parsing_type = lambda x: x not in ["object", "[]", r"{}"] + if isinstance(data, ET.Element) and is_a_text_parsing_type(data_type) and not data.text: + return None + data_val = self.deserialize_type[data_type](data) + return data_val + + iter_type = data_type[0] + data_type[-1] + if iter_type in self.deserialize_type: + return self.deserialize_type[iter_type](data, data_type[1:-1]) + + obj_type = self.dependencies[data_type] + if issubclass(obj_type, Enum): + if isinstance(data, ET.Element): + data = data.text + return self.deserialize_enum(data, obj_type) + + except (ValueError, TypeError, AttributeError) as err: + msg = "Unable to deserialize response data." + msg += " Data: {}, {}".format(data, data_type) + raise_with_traceback(DeserializationError, msg, err) + else: + return self._deserialize(obj_type, data) + + def deserialize_iter(self, attr, iter_type): + """Deserialize an iterable. + + :param list attr: Iterable to be deserialized. + :param str iter_type: The type of object in the iterable. + :rtype: list + """ + if attr is None: + return None + if isinstance(attr, ET.Element): # If I receive an element here, get the children + attr = list(attr) + if not isinstance(attr, (list, set)): + raise DeserializationError("Cannot deserialize as [{}] an object of type {}".format( + iter_type, + type(attr) + )) + return [self.deserialize_data(a, iter_type) for a in attr] + + def deserialize_dict(self, attr, dict_type): + """Deserialize a dictionary. + + :param dict/list attr: Dictionary to be deserialized. Also accepts + a list of key, value pairs. + :param str dict_type: The object type of the items in the dictionary. + :rtype: dict + """ + if isinstance(attr, list): + return {x['key']: self.deserialize_data(x['value'], dict_type) for x in attr} + + if isinstance(attr, ET.Element): + # Transform value into {"Key": "value"} + attr = {el.tag: el.text for el in attr} + return {k: self.deserialize_data(v, dict_type) for k, v in attr.items()} + + def deserialize_object(self, attr, **kwargs): + """Deserialize a generic object. + This will be handled as a dictionary. + + :param dict attr: Dictionary to be deserialized. + :rtype: dict + :raises: TypeError if non-builtin datatype encountered. + """ + if attr is None: + return None + if isinstance(attr, ET.Element): + # Do no recurse on XML, just return the tree as-is + return attr + if isinstance(attr, basestring): + return self.deserialize_basic(attr, 'str') + obj_type = type(attr) + if obj_type in self.basic_types: + return self.deserialize_basic(attr, self.basic_types[obj_type]) + if obj_type is _long_type: + return self.deserialize_long(attr) + + if obj_type == dict: + deserialized = {} + for key, value in attr.items(): + try: + deserialized[key] = self.deserialize_object( + value, **kwargs) + except ValueError: + deserialized[key] = None + return deserialized + + if obj_type == list: + deserialized = [] + for obj in attr: + try: + deserialized.append(self.deserialize_object( + obj, **kwargs)) + except ValueError: + pass + return deserialized + + else: + error = "Cannot deserialize generic object with type: " + raise TypeError(error + str(obj_type)) + + def deserialize_basic(self, attr, data_type): + """Deserialize basic builtin data type from string. + Will attempt to convert to str, int, float and bool. + This function will also accept '1', '0', 'true' and 'false' as + valid bool values. + + :param str attr: response string to be deserialized. + :param str data_type: deserialization data type. + :rtype: str, int, float or bool + :raises: TypeError if string format is not valid. + """ + # If we're here, data is supposed to be a basic type. + # If it's still an XML node, take the text + if isinstance(attr, ET.Element): + attr = attr.text + if not attr: + if data_type == "str": + # None or '', node is empty string. + return '' + else: + # None or '', node with a strong type is None. + # Don't try to model "empty bool" or "empty int" + return None + + if data_type == 'bool': + if attr in [True, False, 1, 0]: + return bool(attr) + elif isinstance(attr, basestring): + if attr.lower() in ['true', '1']: + return True + elif attr.lower() in ['false', '0']: + return False + raise TypeError("Invalid boolean value: {}".format(attr)) + + if data_type == 'str': + return self.deserialize_unicode(attr) + return eval(data_type)(attr) # nosec + + @staticmethod + def deserialize_unicode(data): + """Preserve unicode objects in Python 2, otherwise return data + as a string. + + :param str data: response string to be deserialized. + :rtype: str or unicode + """ + # We might be here because we have an enum modeled as string, + # and we try to deserialize a partial dict with enum inside + if isinstance(data, Enum): + return data + + # Consider this is real string + try: + if isinstance(data, unicode): + return data + except NameError: + return str(data) + else: + return str(data) + + @staticmethod + def deserialize_enum(data, enum_obj): + """Deserialize string into enum object. + + If the string is not a valid enum value it will be returned as-is + and a warning will be logged. + + :param str data: Response string to be deserialized. If this value is + None or invalid it will be returned as-is. + :param Enum enum_obj: Enum object to deserialize to. + :rtype: Enum + """ + if isinstance(data, enum_obj) or data is None: + return data + if isinstance(data, Enum): + data = data.value + if isinstance(data, int): + # Workaround. We might consider remove it in the future. + # https://github.com/Azure/azure-rest-api-specs/issues/141 + try: + return list(enum_obj.__members__.values())[data] + except IndexError: + error = "{!r} is not a valid index for enum {!r}" + raise DeserializationError(error.format(data, enum_obj)) + try: + return enum_obj(str(data)) + except ValueError: + for enum_value in enum_obj: + if enum_value.value.lower() == str(data).lower(): + return enum_value + # We don't fail anymore for unknown value, we deserialize as a string + _LOGGER.warning("Deserializer is not able to find %s as valid enum in %s", data, enum_obj) + return Deserializer.deserialize_unicode(data) + + @staticmethod + def deserialize_bytearray(attr): + """Deserialize string into bytearray. + + :param str attr: response string to be deserialized. + :rtype: bytearray + :raises: TypeError if string format invalid. + """ + if isinstance(attr, ET.Element): + attr = attr.text + return bytearray(b64decode(attr)) + + @staticmethod + def deserialize_base64(attr): + """Deserialize base64 encoded string into string. + + :param str attr: response string to be deserialized. + :rtype: bytearray + :raises: TypeError if string format invalid. + """ + if isinstance(attr, ET.Element): + attr = attr.text + padding = '=' * (3 - (len(attr) + 3) % 4) + attr = attr + padding + encoded = attr.replace('-', '+').replace('_', '/') + return b64decode(encoded) + + @staticmethod + def deserialize_decimal(attr): + """Deserialize string into Decimal object. + + :param str attr: response string to be deserialized. + :rtype: Decimal + :raises: DeserializationError if string format invalid. + """ + if isinstance(attr, ET.Element): + attr = attr.text + try: + return decimal.Decimal(attr) + except decimal.DecimalException as err: + msg = "Invalid decimal {}".format(attr) + raise_with_traceback(DeserializationError, msg, err) + + @staticmethod + def deserialize_long(attr): + """Deserialize string into long (Py2) or int (Py3). + + :param str attr: response string to be deserialized. + :rtype: long or int + :raises: ValueError if string format invalid. + """ + if isinstance(attr, ET.Element): + attr = attr.text + return _long_type(attr) + + @staticmethod + def deserialize_duration(attr): + """Deserialize ISO-8601 formatted string into TimeDelta object. + + :param str attr: response string to be deserialized. + :rtype: TimeDelta + :raises: DeserializationError if string format invalid. + """ + if isinstance(attr, ET.Element): + attr = attr.text + try: + duration = isodate.parse_duration(attr) + except(ValueError, OverflowError, AttributeError) as err: + msg = "Cannot deserialize duration object." + raise_with_traceback(DeserializationError, msg, err) + else: + return duration + + @staticmethod + def deserialize_date(attr): + """Deserialize ISO-8601 formatted string into Date object. + + :param str attr: response string to be deserialized. + :rtype: Date + :raises: DeserializationError if string format invalid. + """ + if isinstance(attr, ET.Element): + attr = attr.text + if re.search(r"[^\W\d_]", attr, re.I + re.U): + 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) + + @staticmethod + def deserialize_time(attr): + """Deserialize ISO-8601 formatted string into time object. + + :param str attr: response string to be deserialized. + :rtype: datetime.time + :raises: DeserializationError if string format invalid. + """ + if isinstance(attr, ET.Element): + attr = attr.text + if re.search(r"[^\W\d_]", attr, re.I + re.U): + raise DeserializationError("Date must have only digits and -. Received: %s" % attr) + return isodate.parse_time(attr) + + @staticmethod + def deserialize_rfc(attr): + """Deserialize RFC-1123 formatted string into Datetime object. + + :param str attr: response string to be deserialized. + :rtype: Datetime + :raises: DeserializationError if string format invalid. + """ + if isinstance(attr, ET.Element): + attr = attr.text + try: + parsed_date = email.utils.parsedate_tz(attr) + date_obj = datetime.datetime( + *parsed_date[:6], + tzinfo=_FixedOffset(datetime.timedelta(minutes=(parsed_date[9] or 0)/60)) + ) + if not date_obj.tzinfo: + date_obj = date_obj.astimezone(tz=TZ_UTC) + except ValueError as err: + msg = "Cannot deserialize to rfc datetime object." + raise_with_traceback(DeserializationError, msg, err) + else: + return date_obj + + @staticmethod + def deserialize_iso(attr): + """Deserialize ISO-8601 formatted string into Datetime object. + + :param str attr: response string to be deserialized. + :rtype: Datetime + :raises: DeserializationError if string format invalid. + """ + if isinstance(attr, ET.Element): + attr = attr.text + try: + attr = attr.upper() + match = Deserializer.valid_date.match(attr) + if not match: + raise ValueError("Invalid datetime string: " + attr) + + check_decimal = attr.split('.') + if len(check_decimal) > 1: + decimal_str = "" + for digit in check_decimal[1]: + if digit.isdigit(): + decimal_str += digit + else: + break + if len(decimal_str) > 6: + attr = attr.replace(decimal_str, decimal_str[0:6]) + + date_obj = isodate.parse_datetime(attr) + test_utc = date_obj.utctimetuple() + if test_utc.tm_year > 9999 or test_utc.tm_year < 1: + raise OverflowError("Hit max or min date") + except(ValueError, OverflowError, AttributeError) as err: + msg = "Cannot deserialize datetime object." + raise_with_traceback(DeserializationError, msg, err) + else: + return date_obj + + @staticmethod + def deserialize_unix(attr): + """Serialize Datetime object into IntTime format. + This is represented as seconds. + + :param int attr: Object to be serialized. + :rtype: Datetime + :raises: DeserializationError if format invalid + """ + if isinstance(attr, ET.Element): + attr = int(attr.text) + try: + date_obj = datetime.datetime.fromtimestamp(attr, TZ_UTC) + except ValueError as err: + msg = "Cannot deserialize to unix datetime object." + raise_with_traceback(DeserializationError, msg, err) + else: + return date_obj diff --git a/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/locks/aio/_configuration.py b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/locks/aio/_configuration.py index f1668af3249a5..e036a19dabe3e 100644 --- a/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/locks/aio/_configuration.py +++ b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/locks/aio/_configuration.py @@ -26,9 +26,9 @@ class ManagementLockClientConfiguration(Configuration): Note that all parameters used to create this instance are saved as instance attributes. - :param credential: Credential needed for the client to connect to Azure. + :param credential: Credential needed for the client to connect to Azure. Required. :type credential: ~azure.core.credentials_async.AsyncTokenCredential - :param subscription_id: The ID of the target subscription. + :param subscription_id: The ID of the target subscription. Required. :type subscription_id: str """ diff --git a/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/locks/aio/_management_lock_client.py b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/locks/aio/_management_lock_client.py index 5700444702759..99c70ae94c93b 100644 --- a/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/locks/aio/_management_lock_client.py +++ b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/locks/aio/_management_lock_client.py @@ -11,17 +11,15 @@ from typing import Any, Optional, TYPE_CHECKING -from msrest import Deserializer, Serializer - from azure.mgmt.core import AsyncARMPipelineClient from azure.profiles import KnownProfiles, ProfileDefinition from azure.profiles.multiapiclient import MultiApiClientMixin +from .._serialization import Deserializer, Serializer from ._configuration import ManagementLockClientConfiguration if TYPE_CHECKING: # pylint: disable=unused-import,ungrouped-imports - from azure.core.credentials import TokenCredential from azure.core.credentials_async import AsyncTokenCredential class _SDKClient(object): @@ -42,9 +40,9 @@ class ManagementLockClient(MultiApiClientMixin, _SDKClient): The api-version parameter sets the default API version if the operation group is not described in the profile. - :param credential: Credential needed for the client to connect to Azure. + :param credential: Credential needed for the client to connect to Azure. Required. :type credential: ~azure.core.credentials_async.AsyncTokenCredential - :param subscription_id: The ID of the target subscription. + :param subscription_id: The ID of the target subscription. Required. :type subscription_id: str :param api_version: API version to use if no profile is provided, or if missing in profile. :type api_version: str diff --git a/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/locks/v2015_01_01/__init__.py b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/locks/v2015_01_01/__init__.py index 94979e384920d..bb035608c3c38 100644 --- a/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/locks/v2015_01_01/__init__.py +++ b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/locks/v2015_01_01/__init__.py @@ -10,9 +10,15 @@ from ._version import VERSION __version__ = VERSION -__all__ = ['ManagementLockClient'] -# `._patch.py` is used for handwritten extensions to the generated code -# Example: https://github.com/Azure/azure-sdk-for-python/blob/main/doc/dev/customize_code/how-to-patch-sdk-code.md -from ._patch import patch_sdk -patch_sdk() +try: + from ._patch import __all__ as _patch_all + from ._patch import * # type: ignore # pylint: disable=unused-wildcard-import +except ImportError: + _patch_all = [] +from ._patch import patch_sdk as _patch_sdk + +__all__ = ["ManagementLockClient"] +__all__.extend([p for p in _patch_all if p not in __all__]) + +_patch_sdk() diff --git a/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/locks/v2015_01_01/_configuration.py b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/locks/v2015_01_01/_configuration.py index 6f3f15abbc744..974ebfc773d84 100644 --- a/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/locks/v2015_01_01/_configuration.py +++ b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/locks/v2015_01_01/_configuration.py @@ -25,23 +25,18 @@ class ManagementLockClientConfiguration(Configuration): # pylint: disable=too-m Note that all parameters used to create this instance are saved as instance attributes. - :param credential: Credential needed for the client to connect to Azure. + :param credential: Credential needed for the client to connect to Azure. Required. :type credential: ~azure.core.credentials.TokenCredential - :param subscription_id: The ID of the target subscription. + :param subscription_id: The ID of the target subscription. Required. :type subscription_id: str :keyword api_version: Api Version. Default value is "2015-01-01". Note that overriding this default value may result in unsupported behavior. :paramtype api_version: str """ - def __init__( - self, - credential: "TokenCredential", - subscription_id: str, - **kwargs: Any - ) -> None: + def __init__(self, credential: "TokenCredential", subscription_id: str, **kwargs: Any) -> None: super(ManagementLockClientConfiguration, self).__init__(**kwargs) - api_version = kwargs.pop('api_version', "2015-01-01") # type: str + api_version = kwargs.pop("api_version", "2015-01-01") # type: str if credential is None: raise ValueError("Parameter 'credential' must not be None.") @@ -51,23 +46,24 @@ def __init__( self.credential = credential self.subscription_id = subscription_id self.api_version = api_version - self.credential_scopes = kwargs.pop('credential_scopes', ['https://management.azure.com/.default']) - kwargs.setdefault('sdk_moniker', 'mgmt-resource/{}'.format(VERSION)) + self.credential_scopes = kwargs.pop("credential_scopes", ["https://management.azure.com/.default"]) + kwargs.setdefault("sdk_moniker", "mgmt-resource/{}".format(VERSION)) self._configure(**kwargs) def _configure( - self, - **kwargs # type: Any + self, **kwargs # type: Any ): # type: (...) -> 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) - self.logging_policy = kwargs.get('logging_policy') or policies.NetworkTraceLoggingPolicy(**kwargs) - self.http_logging_policy = kwargs.get('http_logging_policy') or ARMHttpLoggingPolicy(**kwargs) - self.retry_policy = kwargs.get('retry_policy') or policies.RetryPolicy(**kwargs) - self.custom_hook_policy = kwargs.get('custom_hook_policy') or policies.CustomHookPolicy(**kwargs) - self.redirect_policy = kwargs.get('redirect_policy') or policies.RedirectPolicy(**kwargs) - self.authentication_policy = kwargs.get('authentication_policy') + 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) + self.logging_policy = kwargs.get("logging_policy") or policies.NetworkTraceLoggingPolicy(**kwargs) + self.http_logging_policy = kwargs.get("http_logging_policy") or ARMHttpLoggingPolicy(**kwargs) + self.retry_policy = kwargs.get("retry_policy") or policies.RetryPolicy(**kwargs) + self.custom_hook_policy = kwargs.get("custom_hook_policy") or policies.CustomHookPolicy(**kwargs) + self.redirect_policy = kwargs.get("redirect_policy") or policies.RedirectPolicy(**kwargs) + self.authentication_policy = kwargs.get("authentication_policy") if self.credential and not self.authentication_policy: - self.authentication_policy = ARMChallengeAuthenticationPolicy(self.credential, *self.credential_scopes, **kwargs) + self.authentication_policy = ARMChallengeAuthenticationPolicy( + self.credential, *self.credential_scopes, **kwargs + ) diff --git a/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/locks/v2015_01_01/_management_lock_client.py b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/locks/v2015_01_01/_management_lock_client.py index 740e78df93aca..2bb89d877669b 100644 --- a/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/locks/v2015_01_01/_management_lock_client.py +++ b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/locks/v2015_01_01/_management_lock_client.py @@ -9,12 +9,11 @@ from copy import deepcopy from typing import Any, TYPE_CHECKING -from msrest import Deserializer, Serializer - from azure.core.rest import HttpRequest, HttpResponse from azure.mgmt.core import ARMPipelineClient from . import models +from .._serialization import Deserializer, Serializer from ._configuration import ManagementLockClientConfiguration from .operations import ManagementLocksOperations @@ -22,15 +21,16 @@ # pylint: disable=unused-import,ungrouped-imports from azure.core.credentials import TokenCredential -class ManagementLockClient: + +class ManagementLockClient: # pylint: disable=client-accepts-api-version-keyword """ManagementLockClient. :ivar management_locks: ManagementLocksOperations operations :vartype management_locks: azure.mgmt.resource.locks.v2015_01_01.operations.ManagementLocksOperations - :param credential: Credential needed for the client to connect to Azure. + :param credential: Credential needed for the client to connect to Azure. Required. :type credential: ~azure.core.credentials.TokenCredential - :param subscription_id: The ID of the target subscription. + :param subscription_id: The ID of the target subscription. Required. :type subscription_id: str :param base_url: Service URL. Default value is "https://management.azure.com". :type base_url: str @@ -46,21 +46,20 @@ def __init__( base_url: str = "https://management.azure.com", **kwargs: Any ) -> None: - self._config = ManagementLockClientConfiguration(credential=credential, subscription_id=subscription_id, **kwargs) + self._config = ManagementLockClientConfiguration( + credential=credential, subscription_id=subscription_id, **kwargs + ) self._client = ARMPipelineClient(base_url=base_url, config=self._config, **kwargs) client_models = {k: v for k, v in models.__dict__.items() if isinstance(v, type)} self._serialize = Serializer(client_models) self._deserialize = Deserializer(client_models) self._serialize.client_side_validation = False - self.management_locks = ManagementLocksOperations(self._client, self._config, self._serialize, self._deserialize) - + self.management_locks = ManagementLocksOperations( + self._client, self._config, self._serialize, self._deserialize + ) - def _send_request( - self, - request: HttpRequest, - **kwargs: Any - ) -> HttpResponse: + def _send_request(self, request: HttpRequest, **kwargs: Any) -> HttpResponse: """Runs the network request through the client's chained policies. >>> from azure.core.rest import HttpRequest @@ -69,7 +68,7 @@ def _send_request( >>> response = client._send_request(request) - For more information on this code flow, see https://aka.ms/azsdk/python/protocol/quickstart + For more information on this code flow, see https://aka.ms/azsdk/dpcodegen/python/send_request :param request: The network request you want to make. Required. :type request: ~azure.core.rest.HttpRequest diff --git a/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/locks/v2015_01_01/_metadata.json b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/locks/v2015_01_01/_metadata.json index 0c0ad9f826906..05c7902fef21e 100644 --- a/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/locks/v2015_01_01/_metadata.json +++ b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/locks/v2015_01_01/_metadata.json @@ -10,20 +10,20 @@ "azure_arm": true, "has_lro_operations": false, "client_side_validation": false, - "sync_imports": "{\"typing\": {\"azurecore\": {\"azure.core.credentials\": [\"TokenCredential\"]}}, \"regular\": {\"azurecore\": {\"azure.profiles\": [\"KnownProfiles\", \"ProfileDefinition\"], \"azure.profiles.multiapiclient\": [\"MultiApiClientMixin\"], \"azure.mgmt.core\": [\"ARMPipelineClient\"]}, \"local\": {\"._configuration\": [\"ManagementLockClientConfiguration\"]}, \"thirdparty\": {\"msrest\": [\"Deserializer\", \"Serializer\"]}}, \"conditional\": {\"stdlib\": {\"typing\": [\"Any\", \"Optional\"]}}}", - "async_imports": "{\"typing\": {\"azurecore\": {\"azure.core.credentials_async\": [\"AsyncTokenCredential\"], \"azure.core.credentials\": [\"TokenCredential\"]}}, \"regular\": {\"azurecore\": {\"azure.profiles\": [\"KnownProfiles\", \"ProfileDefinition\"], \"azure.profiles.multiapiclient\": [\"MultiApiClientMixin\"], \"azure.mgmt.core\": [\"AsyncARMPipelineClient\"]}, \"local\": {\"._configuration\": [\"ManagementLockClientConfiguration\"]}, \"thirdparty\": {\"msrest\": [\"Deserializer\", \"Serializer\"]}}, \"conditional\": {\"stdlib\": {\"typing\": [\"Any\", \"Optional\"]}}}" + "sync_imports": "{\"conditional\": {\"stdlib\": {\"typing\": [\"Any\", \"Optional\"]}}, \"regular\": {\"azurecore\": {\"azure.mgmt.core\": [\"ARMPipelineClient\"], \"azure.profiles\": [\"KnownProfiles\", \"ProfileDefinition\"], \"azure.profiles.multiapiclient\": [\"MultiApiClientMixin\"]}, \"local\": {\"._configuration\": [\"ManagementLockClientConfiguration\"], \".._serialization\": [\"Deserializer\", \"Serializer\"]}}, \"typing\": {\"azurecore\": {\"azure.core.credentials\": [\"TokenCredential\"]}}}", + "async_imports": "{\"conditional\": {\"stdlib\": {\"typing\": [\"Any\", \"Optional\"]}}, \"regular\": {\"azurecore\": {\"azure.mgmt.core\": [\"AsyncARMPipelineClient\"], \"azure.profiles\": [\"KnownProfiles\", \"ProfileDefinition\"], \"azure.profiles.multiapiclient\": [\"MultiApiClientMixin\"]}, \"local\": {\"._configuration\": [\"ManagementLockClientConfiguration\"], \"..._serialization\": [\"Deserializer\", \"Serializer\"]}}, \"typing\": {\"azurecore\": {\"azure.core.credentials_async\": [\"AsyncTokenCredential\"]}}}" }, "global_parameters": { "sync": { "credential": { - "signature": "credential, # type: \"TokenCredential\"", - "description": "Credential needed for the client to connect to Azure.", + "signature": "credential: \"TokenCredential\",", + "description": "Credential needed for the client to connect to Azure. Required.", "docstring_type": "~azure.core.credentials.TokenCredential", "required": true }, "subscription_id": { - "signature": "subscription_id, # type: str", - "description": "The ID of the target subscription.", + "signature": "subscription_id: str,", + "description": "The ID of the target subscription. Required.", "docstring_type": "str", "required": true } @@ -31,13 +31,13 @@ "async": { "credential": { "signature": "credential: \"AsyncTokenCredential\",", - "description": "Credential needed for the client to connect to Azure.", + "description": "Credential needed for the client to connect to Azure. Required.", "docstring_type": "~azure.core.credentials_async.AsyncTokenCredential", "required": true }, "subscription_id": { "signature": "subscription_id: str,", - "description": "The ID of the target subscription.", + "description": "The ID of the target subscription. Required.", "docstring_type": "str", "required": true } @@ -54,7 +54,7 @@ "required": false }, "base_url": { - "signature": "base_url=\"https://management.azure.com\", # type: str", + "signature": "base_url: str = \"https://management.azure.com\",", "description": "Service URL", "docstring_type": "str", "required": false diff --git a/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/locks/v2015_01_01/_patch.py b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/locks/v2015_01_01/_patch.py index 74e48ecd07cf3..f99e77fef9861 100644 --- a/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/locks/v2015_01_01/_patch.py +++ b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/locks/v2015_01_01/_patch.py @@ -28,4 +28,4 @@ # This file is used for handwritten extensions to the generated code. Example: # https://github.com/Azure/azure-sdk-for-python/blob/main/doc/dev/customize_code/how-to-patch-sdk-code.md def patch_sdk(): - pass \ No newline at end of file + pass diff --git a/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/locks/v2015_01_01/_vendor.py b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/locks/v2015_01_01/_vendor.py index 138f663c53a4e..9aad73fc743e7 100644 --- a/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/locks/v2015_01_01/_vendor.py +++ b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/locks/v2015_01_01/_vendor.py @@ -7,6 +7,7 @@ from azure.core.pipeline.transport import HttpRequest + def _convert_request(request, files=None): data = request.content if not files else None request = HttpRequest(method=request.method, url=request.url, headers=request.headers, data=data) @@ -14,6 +15,7 @@ def _convert_request(request, files=None): request.set_formdata_body(files) return request + def _format_url_section(template, **kwargs): components = template.split("/") while components: @@ -21,7 +23,5 @@ def _format_url_section(template, **kwargs): 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 - ] + components = [c for c in formatted_components if "{}".format(key.args[0]) not in c] template = "/".join(components) diff --git a/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/locks/v2015_01_01/_version.py b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/locks/v2015_01_01/_version.py index a012ac01c480c..e5754a47ce68f 100644 --- a/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/locks/v2015_01_01/_version.py +++ b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/locks/v2015_01_01/_version.py @@ -6,4 +6,4 @@ # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -VERSION = "21.1.0" +VERSION = "1.0.0b1" diff --git a/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/locks/v2015_01_01/aio/__init__.py b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/locks/v2015_01_01/aio/__init__.py index b16e12de5ea7f..cc4a3cfffe5d9 100644 --- a/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/locks/v2015_01_01/aio/__init__.py +++ b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/locks/v2015_01_01/aio/__init__.py @@ -7,9 +7,15 @@ # -------------------------------------------------------------------------- from ._management_lock_client import ManagementLockClient -__all__ = ['ManagementLockClient'] -# `._patch.py` is used for handwritten extensions to the generated code -# Example: https://github.com/Azure/azure-sdk-for-python/blob/main/doc/dev/customize_code/how-to-patch-sdk-code.md -from ._patch import patch_sdk -patch_sdk() +try: + from ._patch import __all__ as _patch_all + from ._patch import * # type: ignore # pylint: disable=unused-wildcard-import +except ImportError: + _patch_all = [] +from ._patch import patch_sdk as _patch_sdk + +__all__ = ["ManagementLockClient"] +__all__.extend([p for p in _patch_all if p not in __all__]) + +_patch_sdk() diff --git a/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/locks/v2015_01_01/aio/_configuration.py b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/locks/v2015_01_01/aio/_configuration.py index cf175a3f4c423..24de78218efcf 100644 --- a/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/locks/v2015_01_01/aio/_configuration.py +++ b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/locks/v2015_01_01/aio/_configuration.py @@ -25,23 +25,18 @@ class ManagementLockClientConfiguration(Configuration): # pylint: disable=too-m Note that all parameters used to create this instance are saved as instance attributes. - :param credential: Credential needed for the client to connect to Azure. + :param credential: Credential needed for the client to connect to Azure. Required. :type credential: ~azure.core.credentials_async.AsyncTokenCredential - :param subscription_id: The ID of the target subscription. + :param subscription_id: The ID of the target subscription. Required. :type subscription_id: str :keyword api_version: Api Version. Default value is "2015-01-01". Note that overriding this default value may result in unsupported behavior. :paramtype api_version: str """ - def __init__( - self, - credential: "AsyncTokenCredential", - subscription_id: str, - **kwargs: Any - ) -> None: + def __init__(self, credential: "AsyncTokenCredential", subscription_id: str, **kwargs: Any) -> None: super(ManagementLockClientConfiguration, self).__init__(**kwargs) - api_version = kwargs.pop('api_version', "2015-01-01") # type: str + api_version = kwargs.pop("api_version", "2015-01-01") # type: str if credential is None: raise ValueError("Parameter 'credential' must not be None.") @@ -51,22 +46,21 @@ def __init__( self.credential = credential self.subscription_id = subscription_id self.api_version = api_version - self.credential_scopes = kwargs.pop('credential_scopes', ['https://management.azure.com/.default']) - kwargs.setdefault('sdk_moniker', 'mgmt-resource/{}'.format(VERSION)) + self.credential_scopes = kwargs.pop("credential_scopes", ["https://management.azure.com/.default"]) + kwargs.setdefault("sdk_moniker", "mgmt-resource/{}".format(VERSION)) self._configure(**kwargs) - 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) - self.logging_policy = kwargs.get('logging_policy') or policies.NetworkTraceLoggingPolicy(**kwargs) - self.http_logging_policy = kwargs.get('http_logging_policy') or ARMHttpLoggingPolicy(**kwargs) - self.retry_policy = kwargs.get('retry_policy') or policies.AsyncRetryPolicy(**kwargs) - self.custom_hook_policy = kwargs.get('custom_hook_policy') or policies.CustomHookPolicy(**kwargs) - self.redirect_policy = kwargs.get('redirect_policy') or policies.AsyncRedirectPolicy(**kwargs) - self.authentication_policy = kwargs.get('authentication_policy') + 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) + self.logging_policy = kwargs.get("logging_policy") or policies.NetworkTraceLoggingPolicy(**kwargs) + self.http_logging_policy = kwargs.get("http_logging_policy") or ARMHttpLoggingPolicy(**kwargs) + self.retry_policy = kwargs.get("retry_policy") or policies.AsyncRetryPolicy(**kwargs) + self.custom_hook_policy = kwargs.get("custom_hook_policy") or policies.CustomHookPolicy(**kwargs) + self.redirect_policy = kwargs.get("redirect_policy") or policies.AsyncRedirectPolicy(**kwargs) + self.authentication_policy = kwargs.get("authentication_policy") if self.credential and not self.authentication_policy: - self.authentication_policy = AsyncARMChallengeAuthenticationPolicy(self.credential, *self.credential_scopes, **kwargs) + self.authentication_policy = AsyncARMChallengeAuthenticationPolicy( + self.credential, *self.credential_scopes, **kwargs + ) diff --git a/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/locks/v2015_01_01/aio/_management_lock_client.py b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/locks/v2015_01_01/aio/_management_lock_client.py index 6a7b0c84b87e7..535df62304c4c 100644 --- a/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/locks/v2015_01_01/aio/_management_lock_client.py +++ b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/locks/v2015_01_01/aio/_management_lock_client.py @@ -9,12 +9,11 @@ from copy import deepcopy from typing import Any, Awaitable, TYPE_CHECKING -from msrest import Deserializer, Serializer - from azure.core.rest import AsyncHttpResponse, HttpRequest from azure.mgmt.core import AsyncARMPipelineClient from .. import models +from ..._serialization import Deserializer, Serializer from ._configuration import ManagementLockClientConfiguration from .operations import ManagementLocksOperations @@ -22,15 +21,16 @@ # pylint: disable=unused-import,ungrouped-imports from azure.core.credentials_async import AsyncTokenCredential -class ManagementLockClient: + +class ManagementLockClient: # pylint: disable=client-accepts-api-version-keyword """ManagementLockClient. :ivar management_locks: ManagementLocksOperations operations :vartype management_locks: azure.mgmt.resource.locks.v2015_01_01.aio.operations.ManagementLocksOperations - :param credential: Credential needed for the client to connect to Azure. + :param credential: Credential needed for the client to connect to Azure. Required. :type credential: ~azure.core.credentials_async.AsyncTokenCredential - :param subscription_id: The ID of the target subscription. + :param subscription_id: The ID of the target subscription. Required. :type subscription_id: str :param base_url: Service URL. Default value is "https://management.azure.com". :type base_url: str @@ -46,21 +46,20 @@ def __init__( base_url: str = "https://management.azure.com", **kwargs: Any ) -> None: - self._config = ManagementLockClientConfiguration(credential=credential, subscription_id=subscription_id, **kwargs) + self._config = ManagementLockClientConfiguration( + credential=credential, subscription_id=subscription_id, **kwargs + ) self._client = AsyncARMPipelineClient(base_url=base_url, config=self._config, **kwargs) client_models = {k: v for k, v in models.__dict__.items() if isinstance(v, type)} self._serialize = Serializer(client_models) self._deserialize = Deserializer(client_models) self._serialize.client_side_validation = False - self.management_locks = ManagementLocksOperations(self._client, self._config, self._serialize, self._deserialize) - + self.management_locks = ManagementLocksOperations( + self._client, self._config, self._serialize, self._deserialize + ) - def _send_request( - self, - request: HttpRequest, - **kwargs: Any - ) -> Awaitable[AsyncHttpResponse]: + def _send_request(self, request: HttpRequest, **kwargs: Any) -> Awaitable[AsyncHttpResponse]: """Runs the network request through the client's chained policies. >>> from azure.core.rest import HttpRequest @@ -69,7 +68,7 @@ def _send_request( >>> response = await client._send_request(request) - For more information on this code flow, see https://aka.ms/azsdk/python/protocol/quickstart + For more information on this code flow, see https://aka.ms/azsdk/dpcodegen/python/send_request :param request: The network request you want to make. Required. :type request: ~azure.core.rest.HttpRequest diff --git a/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/locks/v2015_01_01/aio/_patch.py b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/locks/v2015_01_01/aio/_patch.py index 74e48ecd07cf3..f99e77fef9861 100644 --- a/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/locks/v2015_01_01/aio/_patch.py +++ b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/locks/v2015_01_01/aio/_patch.py @@ -28,4 +28,4 @@ # This file is used for handwritten extensions to the generated code. Example: # https://github.com/Azure/azure-sdk-for-python/blob/main/doc/dev/customize_code/how-to-patch-sdk-code.md def patch_sdk(): - pass \ No newline at end of file + pass diff --git a/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/locks/v2015_01_01/aio/operations/__init__.py b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/locks/v2015_01_01/aio/operations/__init__.py index 74a4171599d51..b49dd4f3d5cdd 100644 --- a/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/locks/v2015_01_01/aio/operations/__init__.py +++ b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/locks/v2015_01_01/aio/operations/__init__.py @@ -8,6 +8,12 @@ from ._operations import ManagementLocksOperations +from ._patch import __all__ as _patch_all +from ._patch import * # type: ignore # pylint: disable=unused-wildcard-import +from ._patch import patch_sdk as _patch_sdk + __all__ = [ - 'ManagementLocksOperations', + "ManagementLocksOperations", ] +__all__.extend([p for p in _patch_all if p not in __all__]) +_patch_sdk() diff --git a/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/locks/v2015_01_01/aio/operations/_operations.py b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/locks/v2015_01_01/aio/operations/_operations.py index 2803942b7e077..69c88b1510503 100644 --- a/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/locks/v2015_01_01/aio/operations/_operations.py +++ b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/locks/v2015_01_01/aio/operations/_operations.py @@ -6,76 +6,166 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -from typing import Any, AsyncIterable, Callable, Dict, Optional, TypeVar +from typing import Any, AsyncIterable, Callable, Dict, IO, Optional, TypeVar, Union, overload +from urllib.parse import parse_qs, urljoin, urlparse from azure.core.async_paging import AsyncItemPaged, AsyncList -from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error +from azure.core.exceptions import ( + ClientAuthenticationError, + HttpResponseError, + ResourceExistsError, + ResourceNotFoundError, + ResourceNotModifiedError, + map_error, +) from azure.core.pipeline import PipelineResponse from azure.core.pipeline.transport import AsyncHttpResponse from azure.core.rest import HttpRequest from azure.core.tracing.decorator import distributed_trace from azure.core.tracing.decorator_async import distributed_trace_async +from azure.core.utils import case_insensitive_dict from azure.mgmt.core.exceptions import ARMErrorFormat from ... import models as _models from ..._vendor import _convert_request -from ...operations._operations import build_management_locks_create_or_update_at_resource_group_level_request, build_management_locks_create_or_update_at_resource_level_request, build_management_locks_create_or_update_at_subscription_level_request, build_management_locks_delete_at_resource_group_level_request, build_management_locks_delete_at_resource_level_request, build_management_locks_delete_at_subscription_level_request, build_management_locks_get_at_resource_group_level_request, build_management_locks_get_request, build_management_locks_list_at_resource_group_level_request, build_management_locks_list_at_resource_level_request, build_management_locks_list_at_subscription_level_request -T = TypeVar('T') +from ...operations._operations import ( + build_management_locks_create_or_update_at_resource_group_level_request, + build_management_locks_create_or_update_at_resource_level_request, + build_management_locks_create_or_update_at_subscription_level_request, + build_management_locks_delete_at_resource_group_level_request, + build_management_locks_delete_at_resource_level_request, + build_management_locks_delete_at_subscription_level_request, + build_management_locks_get_at_resource_group_level_request, + build_management_locks_get_request, + build_management_locks_list_at_resource_group_level_request, + build_management_locks_list_at_resource_level_request, + build_management_locks_list_at_subscription_level_request, +) + +T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] -class ManagementLocksOperations: - """ManagementLocksOperations async operations. - You should not instantiate this class directly. Instead, you should create a Client instance that - instantiates it for you and attaches it as an attribute. +class ManagementLocksOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. - :ivar models: Alias to model classes used in this operation group. - :type models: ~azure.mgmt.resource.locks.v2015_01_01.models - :param client: Client for service requests. - :param config: Configuration of service client. - :param serializer: An object model serializer. - :param deserializer: An object model deserializer. + Instead, you should access the following operations through + :class:`~azure.mgmt.resource.locks.v2015_01_01.aio.ManagementLockClient`'s + :attr:`management_locks` attribute. """ models = _models - def __init__(self, client, config, serializer, deserializer) -> None: - self._client = client - self._serialize = serializer - self._deserialize = deserializer - self._config = config + def __init__(self, *args, **kwargs) -> None: + input_args = list(args) + self._client = input_args.pop(0) if input_args else kwargs.pop("client") + self._config = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") - @distributed_trace_async + @overload async def create_or_update_at_resource_group_level( self, resource_group_name: str, lock_name: str, - parameters: "_models.ManagementLockObject", + parameters: _models.ManagementLockObject, + *, + content_type: str = "application/json", **kwargs: Any - ) -> "_models.ManagementLockObject": + ) -> _models.ManagementLockObject: """Create or update a management lock at the resource group level. - :param resource_group_name: The resource group name. + :param resource_group_name: The resource group name. Required. :type resource_group_name: str - :param lock_name: The lock name. + :param lock_name: The lock name. Required. :type lock_name: str - :param parameters: The management lock parameters. + :param parameters: The management lock parameters. Required. :type parameters: ~azure.mgmt.resource.locks.v2015_01_01.models.ManagementLockObject + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: ManagementLockObject or the result of cls(response) + :rtype: ~azure.mgmt.resource.locks.v2015_01_01.models.ManagementLockObject + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + async def create_or_update_at_resource_group_level( + self, + resource_group_name: str, + lock_name: str, + parameters: IO, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.ManagementLockObject: + """Create or update a management lock at the resource group level. + + :param resource_group_name: The resource group name. Required. + :type resource_group_name: str + :param lock_name: The lock name. Required. + :type lock_name: str + :param parameters: The management lock parameters. Required. + :type parameters: IO + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: ManagementLockObject, or the result of cls(response) + :return: ManagementLockObject or the result of cls(response) :rtype: ~azure.mgmt.resource.locks.v2015_01_01.models.ManagementLockObject - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace_async + async def create_or_update_at_resource_group_level( + self, + resource_group_name: str, + lock_name: str, + parameters: Union[_models.ManagementLockObject, IO], + **kwargs: Any + ) -> _models.ManagementLockObject: + """Create or update a management lock at the resource group level. + + :param resource_group_name: The resource group name. Required. + :type resource_group_name: str + :param lock_name: The lock name. Required. + :type lock_name: str + :param parameters: The management lock parameters. Is either a model type or a IO type. + Required. + :type parameters: ~azure.mgmt.resource.locks.v2015_01_01.models.ManagementLockObject or IO + :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. + Default value is None. + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: ManagementLockObject or the result of cls(response) + :rtype: ~azure.mgmt.resource.locks.v2015_01_01.models.ManagementLockObject + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.ManagementLockObject"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) - api_version = kwargs.pop('api_version', "2015-01-01") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - _json = self._serialize.body(parameters, 'ManagementLockObject') + api_version = kwargs.pop("api_version", _params.pop("api-version", "2015-01-01")) # type: str + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.ManagementLockObject] + + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(parameters, (IO, bytes)): + _content = parameters + else: + _json = self._serialize.body(parameters, "ManagementLockObject") request = build_management_locks_create_or_update_at_resource_group_level_request( resource_group_name=resource_group_name, @@ -84,16 +174,18 @@ async def create_or_update_at_resource_group_level( api_version=api_version, content_type=content_type, json=_json, - template_url=self.create_or_update_at_resource_group_level.metadata['url'], + content=_content, + template_url=self.create_or_update_at_resource_group_level.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200, 201]: @@ -101,61 +193,63 @@ async def create_or_update_at_resource_group_level( raise HttpResponseError(response=response, error_format=ARMErrorFormat) if response.status_code == 200: - deserialized = self._deserialize('ManagementLockObject', pipeline_response) + deserialized = self._deserialize("ManagementLockObject", pipeline_response) if response.status_code == 201: - deserialized = self._deserialize('ManagementLockObject', pipeline_response) + deserialized = self._deserialize("ManagementLockObject", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - create_or_update_at_resource_group_level.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Authorization/locks/{lockName}"} # type: ignore - + create_or_update_at_resource_group_level.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Authorization/locks/{lockName}"} # type: ignore @distributed_trace_async async def delete_at_resource_group_level( # pylint: disable=inconsistent-return-statements - self, - resource_group_name: str, - lock_name: str, - **kwargs: Any + self, resource_group_name: str, lock_name: str, **kwargs: Any ) -> None: """Deletes the management lock of a resource group. - :param resource_group_name: The resource group name. + :param resource_group_name: The resource group name. Required. :type resource_group_name: str - :param lock_name: The name of lock. + :param lock_name: The name of lock. Required. :type lock_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: None, or the result of cls(response) + :return: None or the result of cls(response) :rtype: None - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType[None] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) - api_version = kwargs.pop('api_version', "2015-01-01") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2015-01-01")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[None] - request = build_management_locks_delete_at_resource_group_level_request( resource_group_name=resource_group_name, lock_name=lock_name, subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.delete_at_resource_group_level.metadata['url'], + template_url=self.delete_at_resource_group_level.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200, 204]: @@ -165,66 +259,145 @@ async def delete_at_resource_group_level( # pylint: disable=inconsistent-return if cls: return cls(pipeline_response, None, {}) - delete_at_resource_group_level.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Authorization/locks/{lockName}"} # type: ignore - + delete_at_resource_group_level.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Authorization/locks/{lockName}"} # type: ignore @distributed_trace_async async def get_at_resource_group_level( - self, - resource_group_name: str, - lock_name: str, - **kwargs: Any - ) -> "_models.ManagementLockObject": + self, resource_group_name: str, lock_name: str, **kwargs: Any + ) -> _models.ManagementLockObject: """Gets a management lock at the resource group level. - :param resource_group_name: The resource group name. + :param resource_group_name: The resource group name. Required. :type resource_group_name: str - :param lock_name: The lock name. + :param lock_name: The lock name. Required. :type lock_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: ManagementLockObject, or the result of cls(response) + :return: ManagementLockObject or the result of cls(response) :rtype: ~azure.mgmt.resource.locks.v2015_01_01.models.ManagementLockObject - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.ManagementLockObject"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + 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', "2015-01-01") # type: str + api_version = kwargs.pop("api_version", _params.pop("api-version", "2015-01-01")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[_models.ManagementLockObject] - request = build_management_locks_get_at_resource_group_level_request( resource_group_name=resource_group_name, lock_name=lock_name, subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.get_at_resource_group_level.metadata['url'], + template_url=self.get_at_resource_group_level.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) - deserialized = self._deserialize('ManagementLockObject', pipeline_response) + deserialized = self._deserialize("ManagementLockObject", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - get_at_resource_group_level.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Authorization/locks/{lockName}"} # type: ignore + get_at_resource_group_level.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Authorization/locks/{lockName}"} # type: ignore + + @overload + async def create_or_update_at_resource_level( + self, + resource_group_name: str, + resource_provider_namespace: str, + parent_resource_path: str, + resource_type: str, + resource_name: str, + lock_name: str, + parameters: _models.ManagementLockObject, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.ManagementLockObject: + """Create or update a management lock at the resource level or any level below resource. + + :param resource_group_name: The name of the resource group. Required. + :type resource_group_name: str + :param resource_provider_namespace: Resource identity. Required. + :type resource_provider_namespace: str + :param parent_resource_path: Resource identity. Required. + :type parent_resource_path: str + :param resource_type: Resource identity. Required. + :type resource_type: str + :param resource_name: Resource identity. Required. + :type resource_name: str + :param lock_name: The name of lock. Required. + :type lock_name: str + :param parameters: Create or update management lock parameters. Required. + :type parameters: ~azure.mgmt.resource.locks.v2015_01_01.models.ManagementLockObject + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: ManagementLockObject or the result of cls(response) + :rtype: ~azure.mgmt.resource.locks.v2015_01_01.models.ManagementLockObject + :raises ~azure.core.exceptions.HttpResponseError: + """ + @overload + async def create_or_update_at_resource_level( + self, + resource_group_name: str, + resource_provider_namespace: str, + parent_resource_path: str, + resource_type: str, + resource_name: str, + lock_name: str, + parameters: IO, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.ManagementLockObject: + """Create or update a management lock at the resource level or any level below resource. + + :param resource_group_name: The name of the resource group. Required. + :type resource_group_name: str + :param resource_provider_namespace: Resource identity. Required. + :type resource_provider_namespace: str + :param parent_resource_path: Resource identity. Required. + :type parent_resource_path: str + :param resource_type: Resource identity. Required. + :type resource_type: str + :param resource_name: Resource identity. Required. + :type resource_name: str + :param lock_name: The name of lock. Required. + :type lock_name: str + :param parameters: Create or update management lock parameters. Required. + :type parameters: IO + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: ManagementLockObject or the result of cls(response) + :rtype: ~azure.mgmt.resource.locks.v2015_01_01.models.ManagementLockObject + :raises ~azure.core.exceptions.HttpResponseError: + """ @distributed_trace_async async def create_or_update_at_resource_level( @@ -235,40 +408,56 @@ async def create_or_update_at_resource_level( resource_type: str, resource_name: str, lock_name: str, - parameters: "_models.ManagementLockObject", + parameters: Union[_models.ManagementLockObject, IO], **kwargs: Any - ) -> "_models.ManagementLockObject": + ) -> _models.ManagementLockObject: """Create or update a management lock at the resource level or any level below resource. - :param resource_group_name: The name of the resource group. + :param resource_group_name: The name of the resource group. Required. :type resource_group_name: str - :param resource_provider_namespace: Resource identity. + :param resource_provider_namespace: Resource identity. Required. :type resource_provider_namespace: str - :param parent_resource_path: Resource identity. + :param parent_resource_path: Resource identity. Required. :type parent_resource_path: str - :param resource_type: Resource identity. + :param resource_type: Resource identity. Required. :type resource_type: str - :param resource_name: Resource identity. + :param resource_name: Resource identity. Required. :type resource_name: str - :param lock_name: The name of lock. + :param lock_name: The name of lock. Required. :type lock_name: str - :param parameters: Create or update management lock parameters. - :type parameters: ~azure.mgmt.resource.locks.v2015_01_01.models.ManagementLockObject + :param parameters: Create or update management lock parameters. Is either a model type or a IO + type. Required. + :type parameters: ~azure.mgmt.resource.locks.v2015_01_01.models.ManagementLockObject or IO + :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. + Default value is None. + :paramtype content_type: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: ManagementLockObject, or the result of cls(response) + :return: ManagementLockObject or the result of cls(response) :rtype: ~azure.mgmt.resource.locks.v2015_01_01.models.ManagementLockObject - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.ManagementLockObject"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', "2015-01-01") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + api_version = kwargs.pop("api_version", _params.pop("api-version", "2015-01-01")) # type: str + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.ManagementLockObject] - _json = self._serialize.body(parameters, 'ManagementLockObject') + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(parameters, (IO, bytes)): + _content = parameters + else: + _json = self._serialize.body(parameters, "ManagementLockObject") request = build_management_locks_create_or_update_at_resource_level_request( resource_group_name=resource_group_name, @@ -281,16 +470,18 @@ async def create_or_update_at_resource_level( api_version=api_version, content_type=content_type, json=_json, - template_url=self.create_or_update_at_resource_level.metadata['url'], + content=_content, + template_url=self.create_or_update_at_resource_level.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200, 201]: @@ -298,18 +489,17 @@ async def create_or_update_at_resource_level( raise HttpResponseError(response=response, error_format=ARMErrorFormat) if response.status_code == 200: - deserialized = self._deserialize('ManagementLockObject', pipeline_response) + deserialized = self._deserialize("ManagementLockObject", pipeline_response) if response.status_code == 201: - deserialized = self._deserialize('ManagementLockObject', pipeline_response) + deserialized = self._deserialize("ManagementLockObject", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - create_or_update_at_resource_level.metadata = {'url': "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{parentResourcePath}/{resourceType}/{resourceName}/providers/Microsoft.Authorization/locks/{lockName}"} # type: ignore - + create_or_update_at_resource_level.metadata = {"url": "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{parentResourcePath}/{resourceType}/{resourceName}/providers/Microsoft.Authorization/locks/{lockName}"} # type: ignore @distributed_trace_async async def delete_at_resource_level( # pylint: disable=inconsistent-return-statements @@ -324,32 +514,37 @@ async def delete_at_resource_level( # pylint: disable=inconsistent-return-state ) -> None: """Deletes the management lock of a resource or any level below resource. - :param resource_group_name: The name of the resource group. + :param resource_group_name: The name of the resource group. Required. :type resource_group_name: str - :param resource_provider_namespace: Resource identity. + :param resource_provider_namespace: Resource identity. Required. :type resource_provider_namespace: str - :param parent_resource_path: Resource identity. + :param parent_resource_path: Resource identity. Required. :type parent_resource_path: str - :param resource_type: Resource identity. + :param resource_type: Resource identity. Required. :type resource_type: str - :param resource_name: Resource identity. + :param resource_name: Resource identity. Required. :type resource_name: str - :param lock_name: The name of lock. + :param lock_name: The name of lock. Required. :type lock_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: None, or the result of cls(response) + :return: None or the result of cls(response) :rtype: None - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType[None] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + 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', "2015-01-01") # type: str + api_version = kwargs.pop("api_version", _params.pop("api-version", "2015-01-01")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[None] - request = build_management_locks_delete_at_resource_level_request( resource_group_name=resource_group_name, resource_provider_namespace=resource_provider_namespace, @@ -359,16 +554,17 @@ async def delete_at_resource_level( # pylint: disable=inconsistent-return-state lock_name=lock_name, subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.delete_at_resource_level.metadata['url'], + template_url=self.delete_at_resource_level.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200, 204]: @@ -378,37 +574,92 @@ async def delete_at_resource_level( # pylint: disable=inconsistent-return-state if cls: return cls(pipeline_response, None, {}) - delete_at_resource_level.metadata = {'url': "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{parentResourcePath}/{resourceType}/{resourceName}/providers/Microsoft.Authorization/locks/{lockName}"} # type: ignore - + delete_at_resource_level.metadata = {"url": "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{parentResourcePath}/{resourceType}/{resourceName}/providers/Microsoft.Authorization/locks/{lockName}"} # type: ignore - @distributed_trace_async + @overload async def create_or_update_at_subscription_level( self, lock_name: str, - parameters: "_models.ManagementLockObject", + parameters: _models.ManagementLockObject, + *, + content_type: str = "application/json", **kwargs: Any - ) -> "_models.ManagementLockObject": + ) -> _models.ManagementLockObject: """Create or update a management lock at the subscription level. - :param lock_name: The name of lock. + :param lock_name: The name of lock. Required. :type lock_name: str - :param parameters: The management lock parameters. + :param parameters: The management lock parameters. Required. :type parameters: ~azure.mgmt.resource.locks.v2015_01_01.models.ManagementLockObject + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: ManagementLockObject or the result of cls(response) + :rtype: ~azure.mgmt.resource.locks.v2015_01_01.models.ManagementLockObject + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + async def create_or_update_at_subscription_level( + self, lock_name: str, parameters: IO, *, content_type: str = "application/json", **kwargs: Any + ) -> _models.ManagementLockObject: + """Create or update a management lock at the subscription level. + + :param lock_name: The name of lock. Required. + :type lock_name: str + :param parameters: The management lock parameters. Required. + :type parameters: IO + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: ManagementLockObject or the result of cls(response) + :rtype: ~azure.mgmt.resource.locks.v2015_01_01.models.ManagementLockObject + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace_async + async def create_or_update_at_subscription_level( + self, lock_name: str, parameters: Union[_models.ManagementLockObject, IO], **kwargs: Any + ) -> _models.ManagementLockObject: + """Create or update a management lock at the subscription level. + + :param lock_name: The name of lock. Required. + :type lock_name: str + :param parameters: The management lock parameters. Is either a model type or a IO type. + Required. + :type parameters: ~azure.mgmt.resource.locks.v2015_01_01.models.ManagementLockObject or IO + :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. + Default value is None. + :paramtype content_type: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: ManagementLockObject, or the result of cls(response) + :return: ManagementLockObject or the result of cls(response) :rtype: ~azure.mgmt.resource.locks.v2015_01_01.models.ManagementLockObject - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.ManagementLockObject"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', "2015-01-01") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + api_version = kwargs.pop("api_version", _params.pop("api-version", "2015-01-01")) # type: str + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.ManagementLockObject] - _json = self._serialize.body(parameters, 'ManagementLockObject') + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(parameters, (IO, bytes)): + _content = parameters + else: + _json = self._serialize.body(parameters, "ManagementLockObject") request = build_management_locks_create_or_update_at_subscription_level_request( lock_name=lock_name, @@ -416,16 +667,18 @@ async def create_or_update_at_subscription_level( api_version=api_version, content_type=content_type, json=_json, - template_url=self.create_or_update_at_subscription_level.metadata['url'], + content=_content, + template_url=self.create_or_update_at_subscription_level.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200, 201]: @@ -433,57 +686,60 @@ async def create_or_update_at_subscription_level( raise HttpResponseError(response=response, error_format=ARMErrorFormat) if response.status_code == 200: - deserialized = self._deserialize('ManagementLockObject', pipeline_response) + deserialized = self._deserialize("ManagementLockObject", pipeline_response) if response.status_code == 201: - deserialized = self._deserialize('ManagementLockObject', pipeline_response) + deserialized = self._deserialize("ManagementLockObject", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - create_or_update_at_subscription_level.metadata = {'url': "/subscriptions/{subscriptionId}/providers/Microsoft.Authorization/locks/{lockName}"} # type: ignore - + create_or_update_at_subscription_level.metadata = {"url": "/subscriptions/{subscriptionId}/providers/Microsoft.Authorization/locks/{lockName}"} # type: ignore @distributed_trace_async async def delete_at_subscription_level( # pylint: disable=inconsistent-return-statements - self, - lock_name: str, - **kwargs: Any + self, lock_name: str, **kwargs: Any ) -> None: """Deletes the management lock of a subscription. - :param lock_name: The name of lock. + :param lock_name: The name of lock. Required. :type lock_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: None, or the result of cls(response) + :return: None or the result of cls(response) :rtype: None - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType[None] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) - api_version = kwargs.pop('api_version', "2015-01-01") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2015-01-01")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[None] - request = build_management_locks_delete_at_subscription_level_request( lock_name=lock_name, subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.delete_at_subscription_level.metadata['url'], + template_url=self.delete_at_subscription_level.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200, 204]: @@ -493,112 +749,117 @@ async def delete_at_subscription_level( # pylint: disable=inconsistent-return-s if cls: return cls(pipeline_response, None, {}) - delete_at_subscription_level.metadata = {'url': "/subscriptions/{subscriptionId}/providers/Microsoft.Authorization/locks/{lockName}"} # type: ignore - + delete_at_subscription_level.metadata = {"url": "/subscriptions/{subscriptionId}/providers/Microsoft.Authorization/locks/{lockName}"} # type: ignore @distributed_trace_async - async def get( - self, - lock_name: str, - **kwargs: Any - ) -> "_models.ManagementLockObject": + async def get(self, lock_name: str, **kwargs: Any) -> _models.ManagementLockObject: """Gets the management lock of a scope. - :param lock_name: Name of the management lock. + :param lock_name: Name of the management lock. Required. :type lock_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: ManagementLockObject, or the result of cls(response) + :return: ManagementLockObject or the result of cls(response) :rtype: ~azure.mgmt.resource.locks.v2015_01_01.models.ManagementLockObject - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.ManagementLockObject"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + 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', "2015-01-01") # type: str + api_version = kwargs.pop("api_version", _params.pop("api-version", "2015-01-01")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[_models.ManagementLockObject] - request = build_management_locks_get_request( lock_name=lock_name, subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.get.metadata['url'], + template_url=self.get.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) - deserialized = self._deserialize('ManagementLockObject', pipeline_response) + deserialized = self._deserialize("ManagementLockObject", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - get.metadata = {'url': "/subscriptions/{subscriptionId}/providers/Microsoft.Authorization/locks/{lockName}"} # type: ignore - + get.metadata = {"url": "/subscriptions/{subscriptionId}/providers/Microsoft.Authorization/locks/{lockName}"} # type: ignore @distributed_trace def list_at_resource_group_level( - self, - resource_group_name: str, - filter: Optional[str] = None, - **kwargs: Any - ) -> AsyncIterable["_models.ManagementLockListResult"]: + self, resource_group_name: str, filter: Optional[str] = None, **kwargs: Any + ) -> AsyncIterable["_models.ManagementLockObject"]: """Gets all the management locks of a resource group. - :param resource_group_name: Resource group name. + :param resource_group_name: Resource group name. Required. :type resource_group_name: str :param filter: The filter to apply on the operation. Default value is None. :type filter: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either ManagementLockListResult or the result of + :return: An iterator like instance of either ManagementLockObject or the result of cls(response) :rtype: - ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.resource.locks.v2015_01_01.models.ManagementLockListResult] - :raises: ~azure.core.exceptions.HttpResponseError + ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.resource.locks.v2015_01_01.models.ManagementLockObject] + :raises ~azure.core.exceptions.HttpResponseError: """ - api_version = kwargs.pop('api_version', "2015-01-01") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2015-01-01")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[_models.ManagementLockListResult] - cls = kwargs.pop('cls', None) # type: ClsType["_models.ManagementLockListResult"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) + def prepare_request(next_link=None): if not next_link: - + request = build_management_locks_list_at_resource_group_level_request( resource_group_name=resource_group_name, subscription_id=self._config.subscription_id, - api_version=api_version, filter=filter, - template_url=self.list_at_resource_group_level.metadata['url'], + api_version=api_version, + template_url=self.list_at_resource_group_level.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore else: - - request = build_management_locks_list_at_resource_group_level_request( - resource_group_name=resource_group_name, - subscription_id=self._config.subscription_id, - template_url=next_link, - ) + # make call to next link with the client's api-version + _parsed_next_link = urlparse(next_link) + _next_request_params = case_insensitive_dict(parse_qs(_parsed_next_link.query)) + _next_request_params["api-version"] = self._config.api_version + request = HttpRequest("GET", urljoin(next_link, _parsed_next_link.path), params=_next_request_params) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore request.method = "GET" return request @@ -612,10 +873,8 @@ async def extract_data(pipeline_response): async def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) response = pipeline_response.http_response @@ -625,11 +884,9 @@ async def get_next(next_link=None): return pipeline_response + return AsyncItemPaged(get_next, extract_data) - return AsyncItemPaged( - get_next, extract_data - ) - list_at_resource_group_level.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Authorization/locks"} # type: ignore + list_at_resource_group_level.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Authorization/locks"} # type: ignore @distributed_trace def list_at_resource_level( @@ -641,38 +898,46 @@ def list_at_resource_level( resource_name: str, filter: Optional[str] = None, **kwargs: Any - ) -> AsyncIterable["_models.ManagementLockListResult"]: + ) -> AsyncIterable["_models.ManagementLockObject"]: """Gets all the management locks of a resource or any level below resource. :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. :type resource_group_name: str - :param resource_provider_namespace: Resource identity. + :param resource_provider_namespace: Resource identity. Required. :type resource_provider_namespace: str - :param parent_resource_path: Resource identity. + :param parent_resource_path: Resource identity. Required. :type parent_resource_path: str - :param resource_type: Resource identity. + :param resource_type: Resource identity. Required. :type resource_type: str - :param resource_name: Resource identity. + :param resource_name: Resource identity. Required. :type resource_name: str :param filter: The filter to apply on the operation. Default value is None. :type filter: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either ManagementLockListResult or the result of + :return: An iterator like instance of either ManagementLockObject or the result of cls(response) :rtype: - ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.resource.locks.v2015_01_01.models.ManagementLockListResult] - :raises: ~azure.core.exceptions.HttpResponseError + ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.resource.locks.v2015_01_01.models.ManagementLockObject] + :raises ~azure.core.exceptions.HttpResponseError: """ - api_version = kwargs.pop('api_version', "2015-01-01") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2015-01-01")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[_models.ManagementLockListResult] - cls = kwargs.pop('cls', None) # type: ClsType["_models.ManagementLockListResult"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) + def prepare_request(next_link=None): if not next_link: - + request = build_management_locks_list_at_resource_level_request( resource_group_name=resource_group_name, resource_provider_namespace=resource_provider_namespace, @@ -680,26 +945,23 @@ def prepare_request(next_link=None): resource_type=resource_type, resource_name=resource_name, subscription_id=self._config.subscription_id, - api_version=api_version, filter=filter, - template_url=self.list_at_resource_level.metadata['url'], + api_version=api_version, + template_url=self.list_at_resource_level.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore else: - - request = build_management_locks_list_at_resource_level_request( - resource_group_name=resource_group_name, - resource_provider_namespace=resource_provider_namespace, - parent_resource_path=parent_resource_path, - resource_type=resource_type, - resource_name=resource_name, - subscription_id=self._config.subscription_id, - template_url=next_link, - ) + # make call to next link with the client's api-version + _parsed_next_link = urlparse(next_link) + _next_request_params = case_insensitive_dict(parse_qs(_parsed_next_link.query)) + _next_request_params["api-version"] = self._config.api_version + request = HttpRequest("GET", urljoin(next_link, _parsed_next_link.path), params=_next_request_params) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore request.method = "GET" return request @@ -713,10 +975,8 @@ async def extract_data(pipeline_response): async def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) response = pipeline_response.http_response @@ -726,56 +986,61 @@ async def get_next(next_link=None): return pipeline_response + return AsyncItemPaged(get_next, extract_data) - return AsyncItemPaged( - get_next, extract_data - ) - list_at_resource_level.metadata = {'url': "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{parentResourcePath}/{resourceType}/{resourceName}/providers/Microsoft.Authorization/locks"} # type: ignore + list_at_resource_level.metadata = {"url": "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{parentResourcePath}/{resourceType}/{resourceName}/providers/Microsoft.Authorization/locks"} # type: ignore @distributed_trace def list_at_subscription_level( - self, - filter: Optional[str] = None, - **kwargs: Any - ) -> AsyncIterable["_models.ManagementLockListResult"]: + self, filter: Optional[str] = None, **kwargs: Any + ) -> AsyncIterable["_models.ManagementLockObject"]: """Gets all the management locks of a subscription. :param filter: The filter to apply on the operation. Default value is None. :type filter: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either ManagementLockListResult or the result of + :return: An iterator like instance of either ManagementLockObject or the result of cls(response) :rtype: - ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.resource.locks.v2015_01_01.models.ManagementLockListResult] - :raises: ~azure.core.exceptions.HttpResponseError + ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.resource.locks.v2015_01_01.models.ManagementLockObject] + :raises ~azure.core.exceptions.HttpResponseError: """ - api_version = kwargs.pop('api_version', "2015-01-01") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2015-01-01")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[_models.ManagementLockListResult] - cls = kwargs.pop('cls', None) # type: ClsType["_models.ManagementLockListResult"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) + def prepare_request(next_link=None): if not next_link: - + request = build_management_locks_list_at_subscription_level_request( subscription_id=self._config.subscription_id, - api_version=api_version, filter=filter, - template_url=self.list_at_subscription_level.metadata['url'], + api_version=api_version, + template_url=self.list_at_subscription_level.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore else: - - request = build_management_locks_list_at_subscription_level_request( - subscription_id=self._config.subscription_id, - template_url=next_link, - ) + # make call to next link with the client's api-version + _parsed_next_link = urlparse(next_link) + _next_request_params = case_insensitive_dict(parse_qs(_parsed_next_link.query)) + _next_request_params["api-version"] = self._config.api_version + request = HttpRequest("GET", urljoin(next_link, _parsed_next_link.path), params=_next_request_params) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore request.method = "GET" return request @@ -789,10 +1054,8 @@ async def extract_data(pipeline_response): async def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) response = pipeline_response.http_response @@ -802,8 +1065,6 @@ async def get_next(next_link=None): return pipeline_response + return AsyncItemPaged(get_next, extract_data) - return AsyncItemPaged( - get_next, extract_data - ) - list_at_subscription_level.metadata = {'url': "/subscriptions/{subscriptionId}/providers/Microsoft.Authorization/locks"} # type: ignore + list_at_subscription_level.metadata = {"url": "/subscriptions/{subscriptionId}/providers/Microsoft.Authorization/locks"} # type: ignore diff --git a/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/locks/v2015_01_01/aio/operations/_patch.py b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/locks/v2015_01_01/aio/operations/_patch.py new file mode 100644 index 0000000000000..f7dd32510333d --- /dev/null +++ b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/locks/v2015_01_01/aio/operations/_patch.py @@ -0,0 +1,20 @@ +# ------------------------------------ +# Copyright (c) Microsoft Corporation. +# Licensed under the MIT License. +# ------------------------------------ +"""Customize generated code here. + +Follow our quickstart for examples: https://aka.ms/azsdk/python/dpcodegen/python/customize +""" +from typing import List + +__all__: List[str] = [] # Add all objects you want publicly available to users at this package level + + +def patch_sdk(): + """Do not remove from this file. + + `patch_sdk` is a last resort escape hatch that allows you to do customizations + you can't accomplish using the techniques described in + https://aka.ms/azsdk/python/dpcodegen/python/customize + """ diff --git a/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/locks/v2015_01_01/models/__init__.py b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/locks/v2015_01_01/models/__init__.py index 0c16e764de97f..cb9c8273c8a45 100644 --- a/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/locks/v2015_01_01/models/__init__.py +++ b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/locks/v2015_01_01/models/__init__.py @@ -9,13 +9,15 @@ from ._models_py3 import ManagementLockListResult from ._models_py3 import ManagementLockObject - -from ._management_lock_client_enums import ( - LockLevel, -) +from ._management_lock_client_enums import LockLevel +from ._patch import __all__ as _patch_all +from ._patch import * # type: ignore # pylint: disable=unused-wildcard-import +from ._patch import patch_sdk as _patch_sdk __all__ = [ - 'ManagementLockListResult', - 'ManagementLockObject', - 'LockLevel', + "ManagementLockListResult", + "ManagementLockObject", + "LockLevel", ] +__all__.extend([p for p in _patch_all if p not in __all__]) +_patch_sdk() diff --git a/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/locks/v2015_01_01/models/_management_lock_client_enums.py b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/locks/v2015_01_01/models/_management_lock_client_enums.py index b9f3d543402ab..ef20a9304ed6e 100644 --- a/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/locks/v2015_01_01/models/_management_lock_client_enums.py +++ b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/locks/v2015_01_01/models/_management_lock_client_enums.py @@ -7,13 +7,11 @@ # -------------------------------------------------------------------------- from enum import Enum -from six import with_metaclass from azure.core import CaseInsensitiveEnumMeta -class LockLevel(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): - """The lock level of the management lock. - """ +class LockLevel(str, Enum, metaclass=CaseInsensitiveEnumMeta): + """The lock level of the management lock.""" NOT_SPECIFIED = "NotSpecified" CAN_NOT_DELETE = "CanNotDelete" diff --git a/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/locks/v2015_01_01/models/_models_py3.py b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/locks/v2015_01_01/models/_models_py3.py index 8c1bf60deab95..c38cc9cb216a5 100644 --- a/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/locks/v2015_01_01/models/_models_py3.py +++ b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/locks/v2015_01_01/models/_models_py3.py @@ -1,4 +1,5 @@ # coding=utf-8 +# pylint: disable=too-many-lines # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. # Licensed under the MIT License. See License.txt in the project root for license information. @@ -6,14 +7,16 @@ # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -from typing import List, Optional, Union +from typing import List, Optional, TYPE_CHECKING, Union -import msrest.serialization +from ... import _serialization -from ._management_lock_client_enums import * +if TYPE_CHECKING: + # pylint: disable=unused-import,ungrouped-imports + from .. import models as _models -class ManagementLockListResult(msrest.serialization.Model): +class ManagementLockListResult(_serialization.Model): """List of management locks. :ivar value: The list of locks. @@ -23,16 +26,12 @@ class ManagementLockListResult(msrest.serialization.Model): """ _attribute_map = { - 'value': {'key': 'value', 'type': '[ManagementLockObject]'}, - 'next_link': {'key': 'nextLink', 'type': 'str'}, + "value": {"key": "value", "type": "[ManagementLockObject]"}, + "next_link": {"key": "nextLink", "type": "str"}, } def __init__( - self, - *, - value: Optional[List["ManagementLockObject"]] = None, - next_link: Optional[str] = None, - **kwargs + self, *, value: Optional[List["_models.ManagementLockObject"]] = None, next_link: Optional[str] = None, **kwargs ): """ :keyword value: The list of locks. @@ -40,12 +39,12 @@ def __init__( :keyword next_link: The URL to get the next set of results. :paramtype next_link: str """ - super(ManagementLockListResult, self).__init__(**kwargs) + super().__init__(**kwargs) self.value = value self.next_link = next_link -class ManagementLockObject(msrest.serialization.Model): +class ManagementLockObject(_serialization.Model): """Management lock information. Variables are only populated by the server, and will be ignored when sending a request. @@ -56,44 +55,44 @@ class ManagementLockObject(msrest.serialization.Model): :vartype type: str :ivar name: The name of the lock. :vartype name: str - :ivar level: The lock level of the management lock. Possible values include: "NotSpecified", - "CanNotDelete", "ReadOnly". + :ivar level: The lock level of the management lock. Known values are: "NotSpecified", + "CanNotDelete", and "ReadOnly". :vartype level: str or ~azure.mgmt.resource.locks.v2015_01_01.models.LockLevel :ivar notes: The notes of the management lock. :vartype notes: str """ _validation = { - 'id': {'readonly': True}, - 'type': {'readonly': True}, + "id": {"readonly": True}, + "type": {"readonly": True}, } _attribute_map = { - 'id': {'key': 'id', 'type': 'str'}, - 'type': {'key': 'type', 'type': 'str'}, - 'name': {'key': 'name', 'type': 'str'}, - 'level': {'key': 'properties.level', 'type': 'str'}, - 'notes': {'key': 'properties.notes', 'type': 'str'}, + "id": {"key": "id", "type": "str"}, + "type": {"key": "type", "type": "str"}, + "name": {"key": "name", "type": "str"}, + "level": {"key": "properties.level", "type": "str"}, + "notes": {"key": "properties.notes", "type": "str"}, } def __init__( self, *, name: Optional[str] = None, - level: Optional[Union[str, "LockLevel"]] = None, + level: Optional[Union[str, "_models.LockLevel"]] = None, notes: Optional[str] = None, **kwargs ): """ :keyword name: The name of the lock. :paramtype name: str - :keyword level: The lock level of the management lock. Possible values include: "NotSpecified", - "CanNotDelete", "ReadOnly". + :keyword level: The lock level of the management lock. Known values are: "NotSpecified", + "CanNotDelete", and "ReadOnly". :paramtype level: str or ~azure.mgmt.resource.locks.v2015_01_01.models.LockLevel :keyword notes: The notes of the management lock. :paramtype notes: str """ - super(ManagementLockObject, self).__init__(**kwargs) + super().__init__(**kwargs) self.id = None self.type = None self.name = name diff --git a/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/locks/v2015_01_01/models/_patch.py b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/locks/v2015_01_01/models/_patch.py new file mode 100644 index 0000000000000..f7dd32510333d --- /dev/null +++ b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/locks/v2015_01_01/models/_patch.py @@ -0,0 +1,20 @@ +# ------------------------------------ +# Copyright (c) Microsoft Corporation. +# Licensed under the MIT License. +# ------------------------------------ +"""Customize generated code here. + +Follow our quickstart for examples: https://aka.ms/azsdk/python/dpcodegen/python/customize +""" +from typing import List + +__all__: List[str] = [] # Add all objects you want publicly available to users at this package level + + +def patch_sdk(): + """Do not remove from this file. + + `patch_sdk` is a last resort escape hatch that allows you to do customizations + you can't accomplish using the techniques described in + https://aka.ms/azsdk/python/dpcodegen/python/customize + """ diff --git a/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/locks/v2015_01_01/operations/__init__.py b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/locks/v2015_01_01/operations/__init__.py index 74a4171599d51..b49dd4f3d5cdd 100644 --- a/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/locks/v2015_01_01/operations/__init__.py +++ b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/locks/v2015_01_01/operations/__init__.py @@ -8,6 +8,12 @@ from ._operations import ManagementLocksOperations +from ._patch import __all__ as _patch_all +from ._patch import * # type: ignore # pylint: disable=unused-wildcard-import +from ._patch import patch_sdk as _patch_sdk + __all__ = [ - 'ManagementLocksOperations', + "ManagementLocksOperations", ] +__all__.extend([p for p in _patch_all if p not in __all__]) +_patch_sdk() diff --git a/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/locks/v2015_01_01/operations/_operations.py b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/locks/v2015_01_01/operations/_operations.py index c659f0dbb1ff8..ff257a040a438 100644 --- a/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/locks/v2015_01_01/operations/_operations.py +++ b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/locks/v2015_01_01/operations/_operations.py @@ -6,135 +6,130 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -from typing import Any, Callable, Dict, Iterable, Optional, TypeVar - -from msrest import Serializer - -from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error +from typing import Any, Callable, Dict, IO, Iterable, Optional, TypeVar, Union, overload +from urllib.parse import parse_qs, urljoin, urlparse + +from azure.core.exceptions import ( + ClientAuthenticationError, + HttpResponseError, + ResourceExistsError, + ResourceNotFoundError, + ResourceNotModifiedError, + map_error, +) from azure.core.paging import ItemPaged from azure.core.pipeline import PipelineResponse from azure.core.pipeline.transport import HttpResponse from azure.core.rest import HttpRequest from azure.core.tracing.decorator import distributed_trace +from azure.core.utils import case_insensitive_dict from azure.mgmt.core.exceptions import ARMErrorFormat from .. import models as _models +from ..._serialization import Serializer from .._vendor import _convert_request, _format_url_section -T = TypeVar('T') -JSONType = Any + +T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] _SERIALIZER = Serializer() _SERIALIZER.client_side_validation = False + def build_management_locks_create_or_update_at_resource_group_level_request( - resource_group_name: str, - lock_name: str, - subscription_id: str, - *, - json: JSONType = None, - content: Any = None, - **kwargs: Any + resource_group_name: str, lock_name: str, subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2015-01-01") # type: str - content_type = kwargs.pop('content_type', None) # type: Optional[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", "2015-01-01")) # type: str + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + accept = _headers.pop("Accept", "application/json") - accept = "application/json" # Construct URL - _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Authorization/locks/{lockName}") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Authorization/locks/{lockName}", + ) # pylint: disable=line-too-long path_format_arguments = { - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._\(\)]+$'), - "lockName": _SERIALIZER.url("lock_name", lock_name, 'str'), - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), + "resourceGroupName": _SERIALIZER.url( + "resource_group_name", resource_group_name, "str", max_length=90, min_length=1, pattern=r"^[-\w\._\(\)]+$" + ), + "lockName": _SERIALIZER.url("lock_name", lock_name, "str"), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), } _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] if content_type is not None: - _header_parameters['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') - _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') - - return HttpRequest( - method="PUT", - url=_url, - params=_query_parameters, - headers=_header_parameters, - json=json, - content=content, - **kwargs - ) + _headers["Content-Type"] = _SERIALIZER.header("content_type", content_type, "str") + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="PUT", url=_url, params=_params, headers=_headers, **kwargs) def build_management_locks_delete_at_resource_group_level_request( - resource_group_name: str, - lock_name: str, - subscription_id: str, - **kwargs: Any + resource_group_name: str, lock_name: str, subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2015-01-01") # type: str + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + api_version = kwargs.pop("api_version", _params.pop("api-version", "2015-01-01")) # type: str # Construct URL - _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Authorization/locks/{lockName}") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Authorization/locks/{lockName}", + ) # pylint: disable=line-too-long path_format_arguments = { - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._\(\)]+$'), - "lockName": _SERIALIZER.url("lock_name", lock_name, 'str'), - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), + "resourceGroupName": _SERIALIZER.url( + "resource_group_name", resource_group_name, "str", max_length=90, min_length=1, pattern=r"^[-\w\._\(\)]+$" + ), + "lockName": _SERIALIZER.url("lock_name", lock_name, "str"), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), } _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') - - return HttpRequest( - method="DELETE", - url=_url, - params=_query_parameters, - **kwargs - ) + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") + + return HttpRequest(method="DELETE", url=_url, params=_params, **kwargs) def build_management_locks_get_at_resource_group_level_request( - resource_group_name: str, - lock_name: str, - subscription_id: str, - **kwargs: Any + resource_group_name: str, lock_name: str, subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2015-01-01") # type: 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", "2015-01-01")) # type: str + accept = _headers.pop("Accept", "application/json") - accept = "application/json" # Construct URL - _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Authorization/locks/{lockName}") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Authorization/locks/{lockName}", + ) # pylint: disable=line-too-long path_format_arguments = { - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._\(\)]+$'), - "lockName": _SERIALIZER.url("lock_name", lock_name, 'str'), - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), + "resourceGroupName": _SERIALIZER.url( + "resource_group_name", resource_group_name, "str", max_length=90, min_length=1, pattern=r"^[-\w\._\(\)]+$" + ), + "lockName": _SERIALIZER.url("lock_name", lock_name, "str"), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), } _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') - - return HttpRequest( - method="GET", - url=_url, - params=_query_parameters, - headers=_header_parameters, - **kwargs - ) + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) def build_management_locks_create_or_update_at_resource_level_request( @@ -145,48 +140,43 @@ def build_management_locks_create_or_update_at_resource_level_request( resource_name: str, lock_name: str, subscription_id: str, - *, - json: JSONType = None, - content: Any = None, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2015-01-01") # type: str - content_type = kwargs.pop('content_type', None) # type: Optional[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", "2015-01-01")) # type: str + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + accept = _headers.pop("Accept", "application/json") - accept = "application/json" # Construct URL - _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{parentResourcePath}/{resourceType}/{resourceName}/providers/Microsoft.Authorization/locks/{lockName}") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{parentResourcePath}/{resourceType}/{resourceName}/providers/Microsoft.Authorization/locks/{lockName}", + ) # pylint: disable=line-too-long path_format_arguments = { - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._\(\)]+$'), - "resourceProviderNamespace": _SERIALIZER.url("resource_provider_namespace", resource_provider_namespace, 'str'), - "parentResourcePath": _SERIALIZER.url("parent_resource_path", parent_resource_path, 'str', skip_quote=True), - "resourceType": _SERIALIZER.url("resource_type", resource_type, 'str', skip_quote=True), - "resourceName": _SERIALIZER.url("resource_name", resource_name, 'str'), - "lockName": _SERIALIZER.url("lock_name", lock_name, 'str'), - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), + "resourceGroupName": _SERIALIZER.url( + "resource_group_name", resource_group_name, "str", max_length=90, min_length=1, pattern=r"^[-\w\._\(\)]+$" + ), + "resourceProviderNamespace": _SERIALIZER.url("resource_provider_namespace", resource_provider_namespace, "str"), + "parentResourcePath": _SERIALIZER.url("parent_resource_path", parent_resource_path, "str", skip_quote=True), + "resourceType": _SERIALIZER.url("resource_type", resource_type, "str", skip_quote=True), + "resourceName": _SERIALIZER.url("resource_name", resource_name, "str"), + "lockName": _SERIALIZER.url("lock_name", lock_name, "str"), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), } _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] if content_type is not None: - _header_parameters['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') - _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') - - return HttpRequest( - method="PUT", - url=_url, - params=_query_parameters, - headers=_header_parameters, - json=json, - content=content, - **kwargs - ) + _headers["Content-Type"] = _SERIALIZER.header("content_type", content_type, "str") + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="PUT", url=_url, params=_params, headers=_headers, **kwargs) def build_management_locks_delete_at_resource_level_request( @@ -199,174 +189,148 @@ def build_management_locks_delete_at_resource_level_request( subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2015-01-01") # type: str + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + api_version = kwargs.pop("api_version", _params.pop("api-version", "2015-01-01")) # type: str # Construct URL - _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{parentResourcePath}/{resourceType}/{resourceName}/providers/Microsoft.Authorization/locks/{lockName}") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{parentResourcePath}/{resourceType}/{resourceName}/providers/Microsoft.Authorization/locks/{lockName}", + ) # pylint: disable=line-too-long path_format_arguments = { - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._\(\)]+$'), - "resourceProviderNamespace": _SERIALIZER.url("resource_provider_namespace", resource_provider_namespace, 'str'), - "parentResourcePath": _SERIALIZER.url("parent_resource_path", parent_resource_path, 'str', skip_quote=True), - "resourceType": _SERIALIZER.url("resource_type", resource_type, 'str', skip_quote=True), - "resourceName": _SERIALIZER.url("resource_name", resource_name, 'str'), - "lockName": _SERIALIZER.url("lock_name", lock_name, 'str'), - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), + "resourceGroupName": _SERIALIZER.url( + "resource_group_name", resource_group_name, "str", max_length=90, min_length=1, pattern=r"^[-\w\._\(\)]+$" + ), + "resourceProviderNamespace": _SERIALIZER.url("resource_provider_namespace", resource_provider_namespace, "str"), + "parentResourcePath": _SERIALIZER.url("parent_resource_path", parent_resource_path, "str", skip_quote=True), + "resourceType": _SERIALIZER.url("resource_type", resource_type, "str", skip_quote=True), + "resourceName": _SERIALIZER.url("resource_name", resource_name, "str"), + "lockName": _SERIALIZER.url("lock_name", lock_name, "str"), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), } _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') - - return HttpRequest( - method="DELETE", - url=_url, - params=_query_parameters, - **kwargs - ) + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") + + return HttpRequest(method="DELETE", url=_url, params=_params, **kwargs) def build_management_locks_create_or_update_at_subscription_level_request( - lock_name: str, - subscription_id: str, - *, - json: JSONType = None, - content: Any = None, - **kwargs: Any + lock_name: str, subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2015-01-01") # type: str - content_type = kwargs.pop('content_type', None) # type: Optional[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", "2015-01-01")) # type: str + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + accept = _headers.pop("Accept", "application/json") - accept = "application/json" # Construct URL - _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/providers/Microsoft.Authorization/locks/{lockName}") + _url = kwargs.pop( + "template_url", "/subscriptions/{subscriptionId}/providers/Microsoft.Authorization/locks/{lockName}" + ) path_format_arguments = { - "lockName": _SERIALIZER.url("lock_name", lock_name, 'str'), - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), + "lockName": _SERIALIZER.url("lock_name", lock_name, "str"), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), } _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] if content_type is not None: - _header_parameters['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') - _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') - - return HttpRequest( - method="PUT", - url=_url, - params=_query_parameters, - headers=_header_parameters, - json=json, - content=content, - **kwargs - ) + _headers["Content-Type"] = _SERIALIZER.header("content_type", content_type, "str") + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="PUT", url=_url, params=_params, headers=_headers, **kwargs) def build_management_locks_delete_at_subscription_level_request( - lock_name: str, - subscription_id: str, - **kwargs: Any + lock_name: str, subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2015-01-01") # type: str + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + api_version = kwargs.pop("api_version", _params.pop("api-version", "2015-01-01")) # type: str # Construct URL - _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/providers/Microsoft.Authorization/locks/{lockName}") + _url = kwargs.pop( + "template_url", "/subscriptions/{subscriptionId}/providers/Microsoft.Authorization/locks/{lockName}" + ) path_format_arguments = { - "lockName": _SERIALIZER.url("lock_name", lock_name, 'str'), - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), + "lockName": _SERIALIZER.url("lock_name", lock_name, "str"), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), } _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') - - return HttpRequest( - method="DELETE", - url=_url, - params=_query_parameters, - **kwargs - ) + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") + return HttpRequest(method="DELETE", url=_url, params=_params, **kwargs) -def build_management_locks_get_request( - lock_name: str, - subscription_id: str, - **kwargs: Any -) -> HttpRequest: - api_version = kwargs.pop('api_version', "2015-01-01") # type: str - accept = "application/json" +def build_management_locks_get_request(lock_name: str, subscription_id: str, **kwargs: Any) -> HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2015-01-01")) # type: str + accept = _headers.pop("Accept", "application/json") + # Construct URL - _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/providers/Microsoft.Authorization/locks/{lockName}") + _url = kwargs.pop( + "template_url", "/subscriptions/{subscriptionId}/providers/Microsoft.Authorization/locks/{lockName}" + ) path_format_arguments = { - "lockName": _SERIALIZER.url("lock_name", lock_name, 'str'), - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), + "lockName": _SERIALIZER.url("lock_name", lock_name, "str"), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), } _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') - - return HttpRequest( - method="GET", - url=_url, - params=_query_parameters, - headers=_header_parameters, - **kwargs - ) + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) def build_management_locks_list_at_resource_group_level_request( - resource_group_name: str, - subscription_id: str, - *, - filter: Optional[str] = None, - **kwargs: Any + resource_group_name: str, subscription_id: str, *, filter: Optional[str] = None, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2015-01-01") # type: 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", "2015-01-01")) # type: str + accept = _headers.pop("Accept", "application/json") - accept = "application/json" # Construct URL - _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Authorization/locks") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Authorization/locks", + ) # pylint: disable=line-too-long path_format_arguments = { - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._\(\)]+$'), - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), + "resourceGroupName": _SERIALIZER.url( + "resource_group_name", resource_group_name, "str", max_length=90, min_length=1, pattern=r"^[-\w\._\(\)]+$" + ), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), } _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] if filter is not None: - _query_parameters['$filter'] = _SERIALIZER.query("filter", filter, 'str') - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["$filter"] = _SERIALIZER.query("filter", filter, "str") + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') - - return HttpRequest( - method="GET", - url=_url, - params=_query_parameters, - headers=_header_parameters, - **kwargs - ) + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) def build_management_locks_list_at_resource_level_request( @@ -380,129 +344,189 @@ def build_management_locks_list_at_resource_level_request( filter: Optional[str] = None, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2015-01-01") # type: 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", "2015-01-01")) # type: str + accept = _headers.pop("Accept", "application/json") - accept = "application/json" # Construct URL - _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{parentResourcePath}/{resourceType}/{resourceName}/providers/Microsoft.Authorization/locks") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{parentResourcePath}/{resourceType}/{resourceName}/providers/Microsoft.Authorization/locks", + ) # pylint: disable=line-too-long path_format_arguments = { - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._\(\)]+$'), - "resourceProviderNamespace": _SERIALIZER.url("resource_provider_namespace", resource_provider_namespace, 'str'), - "parentResourcePath": _SERIALIZER.url("parent_resource_path", parent_resource_path, 'str', skip_quote=True), - "resourceType": _SERIALIZER.url("resource_type", resource_type, 'str', skip_quote=True), - "resourceName": _SERIALIZER.url("resource_name", resource_name, 'str'), - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), + "resourceGroupName": _SERIALIZER.url( + "resource_group_name", resource_group_name, "str", max_length=90, min_length=1, pattern=r"^[-\w\._\(\)]+$" + ), + "resourceProviderNamespace": _SERIALIZER.url("resource_provider_namespace", resource_provider_namespace, "str"), + "parentResourcePath": _SERIALIZER.url("parent_resource_path", parent_resource_path, "str", skip_quote=True), + "resourceType": _SERIALIZER.url("resource_type", resource_type, "str", skip_quote=True), + "resourceName": _SERIALIZER.url("resource_name", resource_name, "str"), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), } _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] if filter is not None: - _query_parameters['$filter'] = _SERIALIZER.query("filter", filter, 'str') - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["$filter"] = _SERIALIZER.query("filter", filter, "str") + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') - - return HttpRequest( - method="GET", - url=_url, - params=_query_parameters, - headers=_header_parameters, - **kwargs - ) + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) def build_management_locks_list_at_subscription_level_request( - subscription_id: str, - *, - filter: Optional[str] = None, - **kwargs: Any + subscription_id: str, *, filter: Optional[str] = None, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2015-01-01") # type: 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", "2015-01-01")) # type: str + accept = _headers.pop("Accept", "application/json") - accept = "application/json" # Construct URL _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/providers/Microsoft.Authorization/locks") path_format_arguments = { - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), } _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] if filter is not None: - _query_parameters['$filter'] = _SERIALIZER.query("filter", filter, 'str') - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["$filter"] = _SERIALIZER.query("filter", filter, "str") + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') - - return HttpRequest( - method="GET", - url=_url, - params=_query_parameters, - headers=_header_parameters, - **kwargs - ) + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") -class ManagementLocksOperations(object): - """ManagementLocksOperations operations. + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) - You should not instantiate this class directly. Instead, you should create a Client instance that - instantiates it for you and attaches it as an attribute. - :ivar models: Alias to model classes used in this operation group. - :type models: ~azure.mgmt.resource.locks.v2015_01_01.models - :param client: Client for service requests. - :param config: Configuration of service client. - :param serializer: An object model serializer. - :param deserializer: An object model deserializer. +class ManagementLocksOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. + + Instead, you should access the following operations through + :class:`~azure.mgmt.resource.locks.v2015_01_01.ManagementLockClient`'s + :attr:`management_locks` attribute. """ models = _models - def __init__(self, client, config, serializer, deserializer): - self._client = client - self._serialize = serializer - self._deserialize = deserializer - self._config = config + def __init__(self, *args, **kwargs): + input_args = list(args) + self._client = input_args.pop(0) if input_args else kwargs.pop("client") + self._config = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") - @distributed_trace + @overload def create_or_update_at_resource_group_level( self, resource_group_name: str, lock_name: str, - parameters: "_models.ManagementLockObject", + parameters: _models.ManagementLockObject, + *, + content_type: str = "application/json", **kwargs: Any - ) -> "_models.ManagementLockObject": + ) -> _models.ManagementLockObject: """Create or update a management lock at the resource group level. - :param resource_group_name: The resource group name. + :param resource_group_name: The resource group name. Required. :type resource_group_name: str - :param lock_name: The lock name. + :param lock_name: The lock name. Required. :type lock_name: str - :param parameters: The management lock parameters. + :param parameters: The management lock parameters. Required. :type parameters: ~azure.mgmt.resource.locks.v2015_01_01.models.ManagementLockObject + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: ManagementLockObject or the result of cls(response) + :rtype: ~azure.mgmt.resource.locks.v2015_01_01.models.ManagementLockObject + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + def create_or_update_at_resource_group_level( + self, + resource_group_name: str, + lock_name: str, + parameters: IO, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.ManagementLockObject: + """Create or update a management lock at the resource group level. + + :param resource_group_name: The resource group name. Required. + :type resource_group_name: str + :param lock_name: The lock name. Required. + :type lock_name: str + :param parameters: The management lock parameters. Required. + :type parameters: IO + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: ManagementLockObject, or the result of cls(response) + :return: ManagementLockObject or the result of cls(response) :rtype: ~azure.mgmt.resource.locks.v2015_01_01.models.ManagementLockObject - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace + def create_or_update_at_resource_group_level( + self, + resource_group_name: str, + lock_name: str, + parameters: Union[_models.ManagementLockObject, IO], + **kwargs: Any + ) -> _models.ManagementLockObject: + """Create or update a management lock at the resource group level. + + :param resource_group_name: The resource group name. Required. + :type resource_group_name: str + :param lock_name: The lock name. Required. + :type lock_name: str + :param parameters: The management lock parameters. Is either a model type or a IO type. + Required. + :type parameters: ~azure.mgmt.resource.locks.v2015_01_01.models.ManagementLockObject or IO + :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. + Default value is None. + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: ManagementLockObject or the result of cls(response) + :rtype: ~azure.mgmt.resource.locks.v2015_01_01.models.ManagementLockObject + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.ManagementLockObject"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) - api_version = kwargs.pop('api_version', "2015-01-01") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - _json = self._serialize.body(parameters, 'ManagementLockObject') + api_version = kwargs.pop("api_version", _params.pop("api-version", "2015-01-01")) # type: str + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.ManagementLockObject] + + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(parameters, (IO, bytes)): + _content = parameters + else: + _json = self._serialize.body(parameters, "ManagementLockObject") request = build_management_locks_create_or_update_at_resource_group_level_request( resource_group_name=resource_group_name, @@ -511,16 +535,18 @@ def create_or_update_at_resource_group_level( api_version=api_version, content_type=content_type, json=_json, - template_url=self.create_or_update_at_resource_group_level.metadata['url'], + content=_content, + template_url=self.create_or_update_at_resource_group_level.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200, 201]: @@ -528,61 +554,63 @@ def create_or_update_at_resource_group_level( raise HttpResponseError(response=response, error_format=ARMErrorFormat) if response.status_code == 200: - deserialized = self._deserialize('ManagementLockObject', pipeline_response) + deserialized = self._deserialize("ManagementLockObject", pipeline_response) if response.status_code == 201: - deserialized = self._deserialize('ManagementLockObject', pipeline_response) + deserialized = self._deserialize("ManagementLockObject", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - create_or_update_at_resource_group_level.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Authorization/locks/{lockName}"} # type: ignore - + create_or_update_at_resource_group_level.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Authorization/locks/{lockName}"} # type: ignore @distributed_trace def delete_at_resource_group_level( # pylint: disable=inconsistent-return-statements - self, - resource_group_name: str, - lock_name: str, - **kwargs: Any + self, resource_group_name: str, lock_name: str, **kwargs: Any ) -> None: """Deletes the management lock of a resource group. - :param resource_group_name: The resource group name. + :param resource_group_name: The resource group name. Required. :type resource_group_name: str - :param lock_name: The name of lock. + :param lock_name: The name of lock. Required. :type lock_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: None, or the result of cls(response) + :return: None or the result of cls(response) :rtype: None - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType[None] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) - api_version = kwargs.pop('api_version', "2015-01-01") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2015-01-01")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[None] - request = build_management_locks_delete_at_resource_group_level_request( resource_group_name=resource_group_name, lock_name=lock_name, subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.delete_at_resource_group_level.metadata['url'], + template_url=self.delete_at_resource_group_level.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200, 204]: @@ -592,66 +620,145 @@ def delete_at_resource_group_level( # pylint: disable=inconsistent-return-state if cls: return cls(pipeline_response, None, {}) - delete_at_resource_group_level.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Authorization/locks/{lockName}"} # type: ignore - + delete_at_resource_group_level.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Authorization/locks/{lockName}"} # type: ignore @distributed_trace def get_at_resource_group_level( - self, - resource_group_name: str, - lock_name: str, - **kwargs: Any - ) -> "_models.ManagementLockObject": + self, resource_group_name: str, lock_name: str, **kwargs: Any + ) -> _models.ManagementLockObject: """Gets a management lock at the resource group level. - :param resource_group_name: The resource group name. + :param resource_group_name: The resource group name. Required. :type resource_group_name: str - :param lock_name: The lock name. + :param lock_name: The lock name. Required. :type lock_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: ManagementLockObject, or the result of cls(response) + :return: ManagementLockObject or the result of cls(response) :rtype: ~azure.mgmt.resource.locks.v2015_01_01.models.ManagementLockObject - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.ManagementLockObject"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) - api_version = kwargs.pop('api_version', "2015-01-01") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2015-01-01")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[_models.ManagementLockObject] - request = build_management_locks_get_at_resource_group_level_request( resource_group_name=resource_group_name, lock_name=lock_name, subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.get_at_resource_group_level.metadata['url'], + template_url=self.get_at_resource_group_level.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) - deserialized = self._deserialize('ManagementLockObject', pipeline_response) + deserialized = self._deserialize("ManagementLockObject", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - get_at_resource_group_level.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Authorization/locks/{lockName}"} # type: ignore + get_at_resource_group_level.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Authorization/locks/{lockName}"} # type: ignore + + @overload + def create_or_update_at_resource_level( + self, + resource_group_name: str, + resource_provider_namespace: str, + parent_resource_path: str, + resource_type: str, + resource_name: str, + lock_name: str, + parameters: _models.ManagementLockObject, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.ManagementLockObject: + """Create or update a management lock at the resource level or any level below resource. + + :param resource_group_name: The name of the resource group. Required. + :type resource_group_name: str + :param resource_provider_namespace: Resource identity. Required. + :type resource_provider_namespace: str + :param parent_resource_path: Resource identity. Required. + :type parent_resource_path: str + :param resource_type: Resource identity. Required. + :type resource_type: str + :param resource_name: Resource identity. Required. + :type resource_name: str + :param lock_name: The name of lock. Required. + :type lock_name: str + :param parameters: Create or update management lock parameters. Required. + :type parameters: ~azure.mgmt.resource.locks.v2015_01_01.models.ManagementLockObject + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: ManagementLockObject or the result of cls(response) + :rtype: ~azure.mgmt.resource.locks.v2015_01_01.models.ManagementLockObject + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + def create_or_update_at_resource_level( + self, + resource_group_name: str, + resource_provider_namespace: str, + parent_resource_path: str, + resource_type: str, + resource_name: str, + lock_name: str, + parameters: IO, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.ManagementLockObject: + """Create or update a management lock at the resource level or any level below resource. + :param resource_group_name: The name of the resource group. Required. + :type resource_group_name: str + :param resource_provider_namespace: Resource identity. Required. + :type resource_provider_namespace: str + :param parent_resource_path: Resource identity. Required. + :type parent_resource_path: str + :param resource_type: Resource identity. Required. + :type resource_type: str + :param resource_name: Resource identity. Required. + :type resource_name: str + :param lock_name: The name of lock. Required. + :type lock_name: str + :param parameters: Create or update management lock parameters. Required. + :type parameters: IO + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: ManagementLockObject or the result of cls(response) + :rtype: ~azure.mgmt.resource.locks.v2015_01_01.models.ManagementLockObject + :raises ~azure.core.exceptions.HttpResponseError: + """ @distributed_trace def create_or_update_at_resource_level( @@ -662,40 +769,56 @@ def create_or_update_at_resource_level( resource_type: str, resource_name: str, lock_name: str, - parameters: "_models.ManagementLockObject", + parameters: Union[_models.ManagementLockObject, IO], **kwargs: Any - ) -> "_models.ManagementLockObject": + ) -> _models.ManagementLockObject: """Create or update a management lock at the resource level or any level below resource. - :param resource_group_name: The name of the resource group. + :param resource_group_name: The name of the resource group. Required. :type resource_group_name: str - :param resource_provider_namespace: Resource identity. + :param resource_provider_namespace: Resource identity. Required. :type resource_provider_namespace: str - :param parent_resource_path: Resource identity. + :param parent_resource_path: Resource identity. Required. :type parent_resource_path: str - :param resource_type: Resource identity. + :param resource_type: Resource identity. Required. :type resource_type: str - :param resource_name: Resource identity. + :param resource_name: Resource identity. Required. :type resource_name: str - :param lock_name: The name of lock. + :param lock_name: The name of lock. Required. :type lock_name: str - :param parameters: Create or update management lock parameters. - :type parameters: ~azure.mgmt.resource.locks.v2015_01_01.models.ManagementLockObject + :param parameters: Create or update management lock parameters. Is either a model type or a IO + type. Required. + :type parameters: ~azure.mgmt.resource.locks.v2015_01_01.models.ManagementLockObject or IO + :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. + Default value is None. + :paramtype content_type: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: ManagementLockObject, or the result of cls(response) + :return: ManagementLockObject or the result of cls(response) :rtype: ~azure.mgmt.resource.locks.v2015_01_01.models.ManagementLockObject - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.ManagementLockObject"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) - api_version = kwargs.pop('api_version', "2015-01-01") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - _json = self._serialize.body(parameters, 'ManagementLockObject') + api_version = kwargs.pop("api_version", _params.pop("api-version", "2015-01-01")) # type: str + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.ManagementLockObject] + + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(parameters, (IO, bytes)): + _content = parameters + else: + _json = self._serialize.body(parameters, "ManagementLockObject") request = build_management_locks_create_or_update_at_resource_level_request( resource_group_name=resource_group_name, @@ -708,16 +831,18 @@ def create_or_update_at_resource_level( api_version=api_version, content_type=content_type, json=_json, - template_url=self.create_or_update_at_resource_level.metadata['url'], + content=_content, + template_url=self.create_or_update_at_resource_level.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200, 201]: @@ -725,18 +850,17 @@ def create_or_update_at_resource_level( raise HttpResponseError(response=response, error_format=ARMErrorFormat) if response.status_code == 200: - deserialized = self._deserialize('ManagementLockObject', pipeline_response) + deserialized = self._deserialize("ManagementLockObject", pipeline_response) if response.status_code == 201: - deserialized = self._deserialize('ManagementLockObject', pipeline_response) + deserialized = self._deserialize("ManagementLockObject", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - create_or_update_at_resource_level.metadata = {'url': "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{parentResourcePath}/{resourceType}/{resourceName}/providers/Microsoft.Authorization/locks/{lockName}"} # type: ignore - + create_or_update_at_resource_level.metadata = {"url": "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{parentResourcePath}/{resourceType}/{resourceName}/providers/Microsoft.Authorization/locks/{lockName}"} # type: ignore @distributed_trace def delete_at_resource_level( # pylint: disable=inconsistent-return-statements @@ -751,32 +875,37 @@ def delete_at_resource_level( # pylint: disable=inconsistent-return-statements ) -> None: """Deletes the management lock of a resource or any level below resource. - :param resource_group_name: The name of the resource group. + :param resource_group_name: The name of the resource group. Required. :type resource_group_name: str - :param resource_provider_namespace: Resource identity. + :param resource_provider_namespace: Resource identity. Required. :type resource_provider_namespace: str - :param parent_resource_path: Resource identity. + :param parent_resource_path: Resource identity. Required. :type parent_resource_path: str - :param resource_type: Resource identity. + :param resource_type: Resource identity. Required. :type resource_type: str - :param resource_name: Resource identity. + :param resource_name: Resource identity. Required. :type resource_name: str - :param lock_name: The name of lock. + :param lock_name: The name of lock. Required. :type lock_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: None, or the result of cls(response) + :return: None or the result of cls(response) :rtype: None - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType[None] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + 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', "2015-01-01") # type: str + api_version = kwargs.pop("api_version", _params.pop("api-version", "2015-01-01")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[None] - request = build_management_locks_delete_at_resource_level_request( resource_group_name=resource_group_name, resource_provider_namespace=resource_provider_namespace, @@ -786,16 +915,17 @@ def delete_at_resource_level( # pylint: disable=inconsistent-return-statements lock_name=lock_name, subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.delete_at_resource_level.metadata['url'], + template_url=self.delete_at_resource_level.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200, 204]: @@ -805,37 +935,92 @@ def delete_at_resource_level( # pylint: disable=inconsistent-return-statements if cls: return cls(pipeline_response, None, {}) - delete_at_resource_level.metadata = {'url': "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{parentResourcePath}/{resourceType}/{resourceName}/providers/Microsoft.Authorization/locks/{lockName}"} # type: ignore + delete_at_resource_level.metadata = {"url": "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{parentResourcePath}/{resourceType}/{resourceName}/providers/Microsoft.Authorization/locks/{lockName}"} # type: ignore - - @distributed_trace + @overload def create_or_update_at_subscription_level( self, lock_name: str, - parameters: "_models.ManagementLockObject", + parameters: _models.ManagementLockObject, + *, + content_type: str = "application/json", **kwargs: Any - ) -> "_models.ManagementLockObject": + ) -> _models.ManagementLockObject: """Create or update a management lock at the subscription level. - :param lock_name: The name of lock. + :param lock_name: The name of lock. Required. :type lock_name: str - :param parameters: The management lock parameters. + :param parameters: The management lock parameters. Required. :type parameters: ~azure.mgmt.resource.locks.v2015_01_01.models.ManagementLockObject + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: ManagementLockObject, or the result of cls(response) + :return: ManagementLockObject or the result of cls(response) :rtype: ~azure.mgmt.resource.locks.v2015_01_01.models.ManagementLockObject - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + def create_or_update_at_subscription_level( + self, lock_name: str, parameters: IO, *, content_type: str = "application/json", **kwargs: Any + ) -> _models.ManagementLockObject: + """Create or update a management lock at the subscription level. + + :param lock_name: The name of lock. Required. + :type lock_name: str + :param parameters: The management lock parameters. Required. + :type parameters: IO + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: ManagementLockObject or the result of cls(response) + :rtype: ~azure.mgmt.resource.locks.v2015_01_01.models.ManagementLockObject + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace + def create_or_update_at_subscription_level( + self, lock_name: str, parameters: Union[_models.ManagementLockObject, IO], **kwargs: Any + ) -> _models.ManagementLockObject: + """Create or update a management lock at the subscription level. + + :param lock_name: The name of lock. Required. + :type lock_name: str + :param parameters: The management lock parameters. Is either a model type or a IO type. + Required. + :type parameters: ~azure.mgmt.resource.locks.v2015_01_01.models.ManagementLockObject or IO + :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. + Default value is None. + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: ManagementLockObject or the result of cls(response) + :rtype: ~azure.mgmt.resource.locks.v2015_01_01.models.ManagementLockObject + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.ManagementLockObject"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) - api_version = kwargs.pop('api_version', "2015-01-01") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - _json = self._serialize.body(parameters, 'ManagementLockObject') + api_version = kwargs.pop("api_version", _params.pop("api-version", "2015-01-01")) # type: str + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.ManagementLockObject] + + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(parameters, (IO, bytes)): + _content = parameters + else: + _json = self._serialize.body(parameters, "ManagementLockObject") request = build_management_locks_create_or_update_at_subscription_level_request( lock_name=lock_name, @@ -843,16 +1028,18 @@ def create_or_update_at_subscription_level( api_version=api_version, content_type=content_type, json=_json, - template_url=self.create_or_update_at_subscription_level.metadata['url'], + content=_content, + template_url=self.create_or_update_at_subscription_level.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200, 201]: @@ -860,57 +1047,60 @@ def create_or_update_at_subscription_level( raise HttpResponseError(response=response, error_format=ARMErrorFormat) if response.status_code == 200: - deserialized = self._deserialize('ManagementLockObject', pipeline_response) + deserialized = self._deserialize("ManagementLockObject", pipeline_response) if response.status_code == 201: - deserialized = self._deserialize('ManagementLockObject', pipeline_response) + deserialized = self._deserialize("ManagementLockObject", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - create_or_update_at_subscription_level.metadata = {'url': "/subscriptions/{subscriptionId}/providers/Microsoft.Authorization/locks/{lockName}"} # type: ignore - + create_or_update_at_subscription_level.metadata = {"url": "/subscriptions/{subscriptionId}/providers/Microsoft.Authorization/locks/{lockName}"} # type: ignore @distributed_trace def delete_at_subscription_level( # pylint: disable=inconsistent-return-statements - self, - lock_name: str, - **kwargs: Any + self, lock_name: str, **kwargs: Any ) -> None: """Deletes the management lock of a subscription. - :param lock_name: The name of lock. + :param lock_name: The name of lock. Required. :type lock_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: None, or the result of cls(response) + :return: None or the result of cls(response) :rtype: None - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType[None] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) - api_version = kwargs.pop('api_version', "2015-01-01") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2015-01-01")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[None] - request = build_management_locks_delete_at_subscription_level_request( lock_name=lock_name, subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.delete_at_subscription_level.metadata['url'], + template_url=self.delete_at_subscription_level.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200, 204]: @@ -920,112 +1110,117 @@ def delete_at_subscription_level( # pylint: disable=inconsistent-return-stateme if cls: return cls(pipeline_response, None, {}) - delete_at_subscription_level.metadata = {'url': "/subscriptions/{subscriptionId}/providers/Microsoft.Authorization/locks/{lockName}"} # type: ignore - + delete_at_subscription_level.metadata = {"url": "/subscriptions/{subscriptionId}/providers/Microsoft.Authorization/locks/{lockName}"} # type: ignore @distributed_trace - def get( - self, - lock_name: str, - **kwargs: Any - ) -> "_models.ManagementLockObject": + def get(self, lock_name: str, **kwargs: Any) -> _models.ManagementLockObject: """Gets the management lock of a scope. - :param lock_name: Name of the management lock. + :param lock_name: Name of the management lock. Required. :type lock_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: ManagementLockObject, or the result of cls(response) + :return: ManagementLockObject or the result of cls(response) :rtype: ~azure.mgmt.resource.locks.v2015_01_01.models.ManagementLockObject - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.ManagementLockObject"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + 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', "2015-01-01") # type: str + api_version = kwargs.pop("api_version", _params.pop("api-version", "2015-01-01")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[_models.ManagementLockObject] - request = build_management_locks_get_request( lock_name=lock_name, subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.get.metadata['url'], + template_url=self.get.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) - deserialized = self._deserialize('ManagementLockObject', pipeline_response) + deserialized = self._deserialize("ManagementLockObject", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - get.metadata = {'url': "/subscriptions/{subscriptionId}/providers/Microsoft.Authorization/locks/{lockName}"} # type: ignore - + get.metadata = {"url": "/subscriptions/{subscriptionId}/providers/Microsoft.Authorization/locks/{lockName}"} # type: ignore @distributed_trace def list_at_resource_group_level( - self, - resource_group_name: str, - filter: Optional[str] = None, - **kwargs: Any - ) -> Iterable["_models.ManagementLockListResult"]: + self, resource_group_name: str, filter: Optional[str] = None, **kwargs: Any + ) -> Iterable["_models.ManagementLockObject"]: """Gets all the management locks of a resource group. - :param resource_group_name: Resource group name. + :param resource_group_name: Resource group name. Required. :type resource_group_name: str :param filter: The filter to apply on the operation. Default value is None. :type filter: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either ManagementLockListResult or the result of + :return: An iterator like instance of either ManagementLockObject or the result of cls(response) :rtype: - ~azure.core.paging.ItemPaged[~azure.mgmt.resource.locks.v2015_01_01.models.ManagementLockListResult] - :raises: ~azure.core.exceptions.HttpResponseError + ~azure.core.paging.ItemPaged[~azure.mgmt.resource.locks.v2015_01_01.models.ManagementLockObject] + :raises ~azure.core.exceptions.HttpResponseError: """ - api_version = kwargs.pop('api_version', "2015-01-01") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2015-01-01")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[_models.ManagementLockListResult] - cls = kwargs.pop('cls', None) # type: ClsType["_models.ManagementLockListResult"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) + def prepare_request(next_link=None): if not next_link: - + request = build_management_locks_list_at_resource_group_level_request( resource_group_name=resource_group_name, subscription_id=self._config.subscription_id, - api_version=api_version, filter=filter, - template_url=self.list_at_resource_group_level.metadata['url'], + api_version=api_version, + template_url=self.list_at_resource_group_level.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore else: - - request = build_management_locks_list_at_resource_group_level_request( - resource_group_name=resource_group_name, - subscription_id=self._config.subscription_id, - template_url=next_link, - ) + # make call to next link with the client's api-version + _parsed_next_link = urlparse(next_link) + _next_request_params = case_insensitive_dict(parse_qs(_parsed_next_link.query)) + _next_request_params["api-version"] = self._config.api_version + request = HttpRequest("GET", urljoin(next_link, _parsed_next_link.path), params=_next_request_params) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore request.method = "GET" return request @@ -1039,10 +1234,8 @@ def extract_data(pipeline_response): def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) response = pipeline_response.http_response @@ -1052,11 +1245,9 @@ def get_next(next_link=None): return pipeline_response + return ItemPaged(get_next, extract_data) - return ItemPaged( - get_next, extract_data - ) - list_at_resource_group_level.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Authorization/locks"} # type: ignore + list_at_resource_group_level.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Authorization/locks"} # type: ignore @distributed_trace def list_at_resource_level( @@ -1068,38 +1259,46 @@ def list_at_resource_level( resource_name: str, filter: Optional[str] = None, **kwargs: Any - ) -> Iterable["_models.ManagementLockListResult"]: + ) -> Iterable["_models.ManagementLockObject"]: """Gets all the management locks of a resource or any level below resource. :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. :type resource_group_name: str - :param resource_provider_namespace: Resource identity. + :param resource_provider_namespace: Resource identity. Required. :type resource_provider_namespace: str - :param parent_resource_path: Resource identity. + :param parent_resource_path: Resource identity. Required. :type parent_resource_path: str - :param resource_type: Resource identity. + :param resource_type: Resource identity. Required. :type resource_type: str - :param resource_name: Resource identity. + :param resource_name: Resource identity. Required. :type resource_name: str :param filter: The filter to apply on the operation. Default value is None. :type filter: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either ManagementLockListResult or the result of + :return: An iterator like instance of either ManagementLockObject or the result of cls(response) :rtype: - ~azure.core.paging.ItemPaged[~azure.mgmt.resource.locks.v2015_01_01.models.ManagementLockListResult] - :raises: ~azure.core.exceptions.HttpResponseError + ~azure.core.paging.ItemPaged[~azure.mgmt.resource.locks.v2015_01_01.models.ManagementLockObject] + :raises ~azure.core.exceptions.HttpResponseError: """ - api_version = kwargs.pop('api_version', "2015-01-01") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2015-01-01")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[_models.ManagementLockListResult] - cls = kwargs.pop('cls', None) # type: ClsType["_models.ManagementLockListResult"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) + def prepare_request(next_link=None): if not next_link: - + request = build_management_locks_list_at_resource_level_request( resource_group_name=resource_group_name, resource_provider_namespace=resource_provider_namespace, @@ -1107,26 +1306,23 @@ def prepare_request(next_link=None): resource_type=resource_type, resource_name=resource_name, subscription_id=self._config.subscription_id, - api_version=api_version, filter=filter, - template_url=self.list_at_resource_level.metadata['url'], + api_version=api_version, + template_url=self.list_at_resource_level.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore else: - - request = build_management_locks_list_at_resource_level_request( - resource_group_name=resource_group_name, - resource_provider_namespace=resource_provider_namespace, - parent_resource_path=parent_resource_path, - resource_type=resource_type, - resource_name=resource_name, - subscription_id=self._config.subscription_id, - template_url=next_link, - ) + # make call to next link with the client's api-version + _parsed_next_link = urlparse(next_link) + _next_request_params = case_insensitive_dict(parse_qs(_parsed_next_link.query)) + _next_request_params["api-version"] = self._config.api_version + request = HttpRequest("GET", urljoin(next_link, _parsed_next_link.path), params=_next_request_params) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore request.method = "GET" return request @@ -1140,10 +1336,8 @@ def extract_data(pipeline_response): def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) response = pipeline_response.http_response @@ -1153,56 +1347,61 @@ def get_next(next_link=None): return pipeline_response + return ItemPaged(get_next, extract_data) - return ItemPaged( - get_next, extract_data - ) - list_at_resource_level.metadata = {'url': "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{parentResourcePath}/{resourceType}/{resourceName}/providers/Microsoft.Authorization/locks"} # type: ignore + list_at_resource_level.metadata = {"url": "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{parentResourcePath}/{resourceType}/{resourceName}/providers/Microsoft.Authorization/locks"} # type: ignore @distributed_trace def list_at_subscription_level( - self, - filter: Optional[str] = None, - **kwargs: Any - ) -> Iterable["_models.ManagementLockListResult"]: + self, filter: Optional[str] = None, **kwargs: Any + ) -> Iterable["_models.ManagementLockObject"]: """Gets all the management locks of a subscription. :param filter: The filter to apply on the operation. Default value is None. :type filter: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either ManagementLockListResult or the result of + :return: An iterator like instance of either ManagementLockObject or the result of cls(response) :rtype: - ~azure.core.paging.ItemPaged[~azure.mgmt.resource.locks.v2015_01_01.models.ManagementLockListResult] - :raises: ~azure.core.exceptions.HttpResponseError + ~azure.core.paging.ItemPaged[~azure.mgmt.resource.locks.v2015_01_01.models.ManagementLockObject] + :raises ~azure.core.exceptions.HttpResponseError: """ - api_version = kwargs.pop('api_version', "2015-01-01") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2015-01-01")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[_models.ManagementLockListResult] - cls = kwargs.pop('cls', None) # type: ClsType["_models.ManagementLockListResult"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) + def prepare_request(next_link=None): if not next_link: - + request = build_management_locks_list_at_subscription_level_request( subscription_id=self._config.subscription_id, - api_version=api_version, filter=filter, - template_url=self.list_at_subscription_level.metadata['url'], + api_version=api_version, + template_url=self.list_at_subscription_level.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore else: - - request = build_management_locks_list_at_subscription_level_request( - subscription_id=self._config.subscription_id, - template_url=next_link, - ) + # make call to next link with the client's api-version + _parsed_next_link = urlparse(next_link) + _next_request_params = case_insensitive_dict(parse_qs(_parsed_next_link.query)) + _next_request_params["api-version"] = self._config.api_version + request = HttpRequest("GET", urljoin(next_link, _parsed_next_link.path), params=_next_request_params) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore request.method = "GET" return request @@ -1216,10 +1415,8 @@ def extract_data(pipeline_response): def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) response = pipeline_response.http_response @@ -1229,8 +1426,6 @@ def get_next(next_link=None): return pipeline_response + return ItemPaged(get_next, extract_data) - return ItemPaged( - get_next, extract_data - ) - list_at_subscription_level.metadata = {'url': "/subscriptions/{subscriptionId}/providers/Microsoft.Authorization/locks"} # type: ignore + list_at_subscription_level.metadata = {"url": "/subscriptions/{subscriptionId}/providers/Microsoft.Authorization/locks"} # type: ignore diff --git a/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/locks/v2015_01_01/operations/_patch.py b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/locks/v2015_01_01/operations/_patch.py new file mode 100644 index 0000000000000..f7dd32510333d --- /dev/null +++ b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/locks/v2015_01_01/operations/_patch.py @@ -0,0 +1,20 @@ +# ------------------------------------ +# Copyright (c) Microsoft Corporation. +# Licensed under the MIT License. +# ------------------------------------ +"""Customize generated code here. + +Follow our quickstart for examples: https://aka.ms/azsdk/python/dpcodegen/python/customize +""" +from typing import List + +__all__: List[str] = [] # Add all objects you want publicly available to users at this package level + + +def patch_sdk(): + """Do not remove from this file. + + `patch_sdk` is a last resort escape hatch that allows you to do customizations + you can't accomplish using the techniques described in + https://aka.ms/azsdk/python/dpcodegen/python/customize + """ diff --git a/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/locks/v2016_09_01/__init__.py b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/locks/v2016_09_01/__init__.py index 94979e384920d..bb035608c3c38 100644 --- a/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/locks/v2016_09_01/__init__.py +++ b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/locks/v2016_09_01/__init__.py @@ -10,9 +10,15 @@ from ._version import VERSION __version__ = VERSION -__all__ = ['ManagementLockClient'] -# `._patch.py` is used for handwritten extensions to the generated code -# Example: https://github.com/Azure/azure-sdk-for-python/blob/main/doc/dev/customize_code/how-to-patch-sdk-code.md -from ._patch import patch_sdk -patch_sdk() +try: + from ._patch import __all__ as _patch_all + from ._patch import * # type: ignore # pylint: disable=unused-wildcard-import +except ImportError: + _patch_all = [] +from ._patch import patch_sdk as _patch_sdk + +__all__ = ["ManagementLockClient"] +__all__.extend([p for p in _patch_all if p not in __all__]) + +_patch_sdk() diff --git a/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/locks/v2016_09_01/_configuration.py b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/locks/v2016_09_01/_configuration.py index b4b0fcb4677fa..879f7e4ca8ef4 100644 --- a/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/locks/v2016_09_01/_configuration.py +++ b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/locks/v2016_09_01/_configuration.py @@ -25,23 +25,18 @@ class ManagementLockClientConfiguration(Configuration): # pylint: disable=too-m Note that all parameters used to create this instance are saved as instance attributes. - :param credential: Credential needed for the client to connect to Azure. + :param credential: Credential needed for the client to connect to Azure. Required. :type credential: ~azure.core.credentials.TokenCredential - :param subscription_id: The ID of the target subscription. + :param subscription_id: The ID of the target subscription. Required. :type subscription_id: str :keyword api_version: Api Version. Default value is "2016-09-01". Note that overriding this default value may result in unsupported behavior. :paramtype api_version: str """ - def __init__( - self, - credential: "TokenCredential", - subscription_id: str, - **kwargs: Any - ) -> None: + def __init__(self, credential: "TokenCredential", subscription_id: str, **kwargs: Any) -> None: super(ManagementLockClientConfiguration, self).__init__(**kwargs) - api_version = kwargs.pop('api_version', "2016-09-01") # type: str + api_version = kwargs.pop("api_version", "2016-09-01") # type: str if credential is None: raise ValueError("Parameter 'credential' must not be None.") @@ -51,23 +46,24 @@ def __init__( self.credential = credential self.subscription_id = subscription_id self.api_version = api_version - self.credential_scopes = kwargs.pop('credential_scopes', ['https://management.azure.com/.default']) - kwargs.setdefault('sdk_moniker', 'mgmt-resource/{}'.format(VERSION)) + self.credential_scopes = kwargs.pop("credential_scopes", ["https://management.azure.com/.default"]) + kwargs.setdefault("sdk_moniker", "mgmt-resource/{}".format(VERSION)) self._configure(**kwargs) def _configure( - self, - **kwargs # type: Any + self, **kwargs # type: Any ): # type: (...) -> 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) - self.logging_policy = kwargs.get('logging_policy') or policies.NetworkTraceLoggingPolicy(**kwargs) - self.http_logging_policy = kwargs.get('http_logging_policy') or ARMHttpLoggingPolicy(**kwargs) - self.retry_policy = kwargs.get('retry_policy') or policies.RetryPolicy(**kwargs) - self.custom_hook_policy = kwargs.get('custom_hook_policy') or policies.CustomHookPolicy(**kwargs) - self.redirect_policy = kwargs.get('redirect_policy') or policies.RedirectPolicy(**kwargs) - self.authentication_policy = kwargs.get('authentication_policy') + 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) + self.logging_policy = kwargs.get("logging_policy") or policies.NetworkTraceLoggingPolicy(**kwargs) + self.http_logging_policy = kwargs.get("http_logging_policy") or ARMHttpLoggingPolicy(**kwargs) + self.retry_policy = kwargs.get("retry_policy") or policies.RetryPolicy(**kwargs) + self.custom_hook_policy = kwargs.get("custom_hook_policy") or policies.CustomHookPolicy(**kwargs) + self.redirect_policy = kwargs.get("redirect_policy") or policies.RedirectPolicy(**kwargs) + self.authentication_policy = kwargs.get("authentication_policy") if self.credential and not self.authentication_policy: - self.authentication_policy = ARMChallengeAuthenticationPolicy(self.credential, *self.credential_scopes, **kwargs) + self.authentication_policy = ARMChallengeAuthenticationPolicy( + self.credential, *self.credential_scopes, **kwargs + ) diff --git a/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/locks/v2016_09_01/_management_lock_client.py b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/locks/v2016_09_01/_management_lock_client.py index eaf2636404414..082d420d10c33 100644 --- a/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/locks/v2016_09_01/_management_lock_client.py +++ b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/locks/v2016_09_01/_management_lock_client.py @@ -9,12 +9,11 @@ from copy import deepcopy from typing import Any, TYPE_CHECKING -from msrest import Deserializer, Serializer - from azure.core.rest import HttpRequest, HttpResponse from azure.mgmt.core import ARMPipelineClient from . import models +from .._serialization import Deserializer, Serializer from ._configuration import ManagementLockClientConfiguration from .operations import AuthorizationOperationsOperations, ManagementLocksOperations @@ -22,7 +21,8 @@ # pylint: disable=unused-import,ungrouped-imports from azure.core.credentials import TokenCredential -class ManagementLockClient: + +class ManagementLockClient: # pylint: disable=client-accepts-api-version-keyword """Azure resources can be locked to prevent other users in your organization from deleting or modifying resources. @@ -32,9 +32,9 @@ class ManagementLockClient: :ivar management_locks: ManagementLocksOperations operations :vartype management_locks: azure.mgmt.resource.locks.v2016_09_01.operations.ManagementLocksOperations - :param credential: Credential needed for the client to connect to Azure. + :param credential: Credential needed for the client to connect to Azure. Required. :type credential: ~azure.core.credentials.TokenCredential - :param subscription_id: The ID of the target subscription. + :param subscription_id: The ID of the target subscription. Required. :type subscription_id: str :param base_url: Service URL. Default value is "https://management.azure.com". :type base_url: str @@ -50,22 +50,23 @@ def __init__( base_url: str = "https://management.azure.com", **kwargs: Any ) -> None: - self._config = ManagementLockClientConfiguration(credential=credential, subscription_id=subscription_id, **kwargs) + self._config = ManagementLockClientConfiguration( + credential=credential, subscription_id=subscription_id, **kwargs + ) self._client = ARMPipelineClient(base_url=base_url, config=self._config, **kwargs) client_models = {k: v for k, v in models.__dict__.items() if isinstance(v, type)} self._serialize = Serializer(client_models) self._deserialize = Deserializer(client_models) self._serialize.client_side_validation = False - self.authorization_operations = AuthorizationOperationsOperations(self._client, self._config, self._serialize, self._deserialize) - self.management_locks = ManagementLocksOperations(self._client, self._config, self._serialize, self._deserialize) - - - def _send_request( - self, - request: HttpRequest, - **kwargs: Any - ) -> HttpResponse: + self.authorization_operations = AuthorizationOperationsOperations( + self._client, self._config, self._serialize, self._deserialize + ) + self.management_locks = ManagementLocksOperations( + self._client, self._config, self._serialize, self._deserialize + ) + + def _send_request(self, request: HttpRequest, **kwargs: Any) -> HttpResponse: """Runs the network request through the client's chained policies. >>> from azure.core.rest import HttpRequest @@ -74,7 +75,7 @@ def _send_request( >>> response = client._send_request(request) - For more information on this code flow, see https://aka.ms/azsdk/python/protocol/quickstart + For more information on this code flow, see https://aka.ms/azsdk/dpcodegen/python/send_request :param request: The network request you want to make. Required. :type request: ~azure.core.rest.HttpRequest diff --git a/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/locks/v2016_09_01/_metadata.json b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/locks/v2016_09_01/_metadata.json index b9d6d010dba57..30a3799166e92 100644 --- a/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/locks/v2016_09_01/_metadata.json +++ b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/locks/v2016_09_01/_metadata.json @@ -10,20 +10,20 @@ "azure_arm": true, "has_lro_operations": false, "client_side_validation": false, - "sync_imports": "{\"typing\": {\"azurecore\": {\"azure.core.credentials\": [\"TokenCredential\"]}}, \"regular\": {\"azurecore\": {\"azure.profiles\": [\"KnownProfiles\", \"ProfileDefinition\"], \"azure.profiles.multiapiclient\": [\"MultiApiClientMixin\"], \"azure.mgmt.core\": [\"ARMPipelineClient\"]}, \"local\": {\"._configuration\": [\"ManagementLockClientConfiguration\"]}, \"thirdparty\": {\"msrest\": [\"Deserializer\", \"Serializer\"]}}, \"conditional\": {\"stdlib\": {\"typing\": [\"Any\", \"Optional\"]}}}", - "async_imports": "{\"typing\": {\"azurecore\": {\"azure.core.credentials_async\": [\"AsyncTokenCredential\"], \"azure.core.credentials\": [\"TokenCredential\"]}}, \"regular\": {\"azurecore\": {\"azure.profiles\": [\"KnownProfiles\", \"ProfileDefinition\"], \"azure.profiles.multiapiclient\": [\"MultiApiClientMixin\"], \"azure.mgmt.core\": [\"AsyncARMPipelineClient\"]}, \"local\": {\"._configuration\": [\"ManagementLockClientConfiguration\"]}, \"thirdparty\": {\"msrest\": [\"Deserializer\", \"Serializer\"]}}, \"conditional\": {\"stdlib\": {\"typing\": [\"Any\", \"Optional\"]}}}" + "sync_imports": "{\"conditional\": {\"stdlib\": {\"typing\": [\"Any\", \"Optional\"]}}, \"regular\": {\"azurecore\": {\"azure.mgmt.core\": [\"ARMPipelineClient\"], \"azure.profiles\": [\"KnownProfiles\", \"ProfileDefinition\"], \"azure.profiles.multiapiclient\": [\"MultiApiClientMixin\"]}, \"local\": {\"._configuration\": [\"ManagementLockClientConfiguration\"], \".._serialization\": [\"Deserializer\", \"Serializer\"]}}, \"typing\": {\"azurecore\": {\"azure.core.credentials\": [\"TokenCredential\"]}}}", + "async_imports": "{\"conditional\": {\"stdlib\": {\"typing\": [\"Any\", \"Optional\"]}}, \"regular\": {\"azurecore\": {\"azure.mgmt.core\": [\"AsyncARMPipelineClient\"], \"azure.profiles\": [\"KnownProfiles\", \"ProfileDefinition\"], \"azure.profiles.multiapiclient\": [\"MultiApiClientMixin\"]}, \"local\": {\"._configuration\": [\"ManagementLockClientConfiguration\"], \"..._serialization\": [\"Deserializer\", \"Serializer\"]}}, \"typing\": {\"azurecore\": {\"azure.core.credentials_async\": [\"AsyncTokenCredential\"]}}}" }, "global_parameters": { "sync": { "credential": { - "signature": "credential, # type: \"TokenCredential\"", - "description": "Credential needed for the client to connect to Azure.", + "signature": "credential: \"TokenCredential\",", + "description": "Credential needed for the client to connect to Azure. Required.", "docstring_type": "~azure.core.credentials.TokenCredential", "required": true }, "subscription_id": { - "signature": "subscription_id, # type: str", - "description": "The ID of the target subscription.", + "signature": "subscription_id: str,", + "description": "The ID of the target subscription. Required.", "docstring_type": "str", "required": true } @@ -31,13 +31,13 @@ "async": { "credential": { "signature": "credential: \"AsyncTokenCredential\",", - "description": "Credential needed for the client to connect to Azure.", + "description": "Credential needed for the client to connect to Azure. Required.", "docstring_type": "~azure.core.credentials_async.AsyncTokenCredential", "required": true }, "subscription_id": { "signature": "subscription_id: str,", - "description": "The ID of the target subscription.", + "description": "The ID of the target subscription. Required.", "docstring_type": "str", "required": true } @@ -54,7 +54,7 @@ "required": false }, "base_url": { - "signature": "base_url=\"https://management.azure.com\", # type: str", + "signature": "base_url: str = \"https://management.azure.com\",", "description": "Service URL", "docstring_type": "str", "required": false diff --git a/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/locks/v2016_09_01/_patch.py b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/locks/v2016_09_01/_patch.py index 74e48ecd07cf3..f99e77fef9861 100644 --- a/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/locks/v2016_09_01/_patch.py +++ b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/locks/v2016_09_01/_patch.py @@ -28,4 +28,4 @@ # This file is used for handwritten extensions to the generated code. Example: # https://github.com/Azure/azure-sdk-for-python/blob/main/doc/dev/customize_code/how-to-patch-sdk-code.md def patch_sdk(): - pass \ No newline at end of file + pass diff --git a/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/locks/v2016_09_01/_vendor.py b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/locks/v2016_09_01/_vendor.py index 138f663c53a4e..9aad73fc743e7 100644 --- a/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/locks/v2016_09_01/_vendor.py +++ b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/locks/v2016_09_01/_vendor.py @@ -7,6 +7,7 @@ from azure.core.pipeline.transport import HttpRequest + def _convert_request(request, files=None): data = request.content if not files else None request = HttpRequest(method=request.method, url=request.url, headers=request.headers, data=data) @@ -14,6 +15,7 @@ def _convert_request(request, files=None): request.set_formdata_body(files) return request + def _format_url_section(template, **kwargs): components = template.split("/") while components: @@ -21,7 +23,5 @@ def _format_url_section(template, **kwargs): 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 - ] + components = [c for c in formatted_components if "{}".format(key.args[0]) not in c] template = "/".join(components) diff --git a/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/locks/v2016_09_01/_version.py b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/locks/v2016_09_01/_version.py index a012ac01c480c..e5754a47ce68f 100644 --- a/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/locks/v2016_09_01/_version.py +++ b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/locks/v2016_09_01/_version.py @@ -6,4 +6,4 @@ # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -VERSION = "21.1.0" +VERSION = "1.0.0b1" diff --git a/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/locks/v2016_09_01/aio/__init__.py b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/locks/v2016_09_01/aio/__init__.py index b16e12de5ea7f..cc4a3cfffe5d9 100644 --- a/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/locks/v2016_09_01/aio/__init__.py +++ b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/locks/v2016_09_01/aio/__init__.py @@ -7,9 +7,15 @@ # -------------------------------------------------------------------------- from ._management_lock_client import ManagementLockClient -__all__ = ['ManagementLockClient'] -# `._patch.py` is used for handwritten extensions to the generated code -# Example: https://github.com/Azure/azure-sdk-for-python/blob/main/doc/dev/customize_code/how-to-patch-sdk-code.md -from ._patch import patch_sdk -patch_sdk() +try: + from ._patch import __all__ as _patch_all + from ._patch import * # type: ignore # pylint: disable=unused-wildcard-import +except ImportError: + _patch_all = [] +from ._patch import patch_sdk as _patch_sdk + +__all__ = ["ManagementLockClient"] +__all__.extend([p for p in _patch_all if p not in __all__]) + +_patch_sdk() diff --git a/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/locks/v2016_09_01/aio/_configuration.py b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/locks/v2016_09_01/aio/_configuration.py index d683c289ca691..b42aa06f73c54 100644 --- a/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/locks/v2016_09_01/aio/_configuration.py +++ b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/locks/v2016_09_01/aio/_configuration.py @@ -25,23 +25,18 @@ class ManagementLockClientConfiguration(Configuration): # pylint: disable=too-m Note that all parameters used to create this instance are saved as instance attributes. - :param credential: Credential needed for the client to connect to Azure. + :param credential: Credential needed for the client to connect to Azure. Required. :type credential: ~azure.core.credentials_async.AsyncTokenCredential - :param subscription_id: The ID of the target subscription. + :param subscription_id: The ID of the target subscription. Required. :type subscription_id: str :keyword api_version: Api Version. Default value is "2016-09-01". Note that overriding this default value may result in unsupported behavior. :paramtype api_version: str """ - def __init__( - self, - credential: "AsyncTokenCredential", - subscription_id: str, - **kwargs: Any - ) -> None: + def __init__(self, credential: "AsyncTokenCredential", subscription_id: str, **kwargs: Any) -> None: super(ManagementLockClientConfiguration, self).__init__(**kwargs) - api_version = kwargs.pop('api_version', "2016-09-01") # type: str + api_version = kwargs.pop("api_version", "2016-09-01") # type: str if credential is None: raise ValueError("Parameter 'credential' must not be None.") @@ -51,22 +46,21 @@ def __init__( self.credential = credential self.subscription_id = subscription_id self.api_version = api_version - self.credential_scopes = kwargs.pop('credential_scopes', ['https://management.azure.com/.default']) - kwargs.setdefault('sdk_moniker', 'mgmt-resource/{}'.format(VERSION)) + self.credential_scopes = kwargs.pop("credential_scopes", ["https://management.azure.com/.default"]) + kwargs.setdefault("sdk_moniker", "mgmt-resource/{}".format(VERSION)) self._configure(**kwargs) - 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) - self.logging_policy = kwargs.get('logging_policy') or policies.NetworkTraceLoggingPolicy(**kwargs) - self.http_logging_policy = kwargs.get('http_logging_policy') or ARMHttpLoggingPolicy(**kwargs) - self.retry_policy = kwargs.get('retry_policy') or policies.AsyncRetryPolicy(**kwargs) - self.custom_hook_policy = kwargs.get('custom_hook_policy') or policies.CustomHookPolicy(**kwargs) - self.redirect_policy = kwargs.get('redirect_policy') or policies.AsyncRedirectPolicy(**kwargs) - self.authentication_policy = kwargs.get('authentication_policy') + 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) + self.logging_policy = kwargs.get("logging_policy") or policies.NetworkTraceLoggingPolicy(**kwargs) + self.http_logging_policy = kwargs.get("http_logging_policy") or ARMHttpLoggingPolicy(**kwargs) + self.retry_policy = kwargs.get("retry_policy") or policies.AsyncRetryPolicy(**kwargs) + self.custom_hook_policy = kwargs.get("custom_hook_policy") or policies.CustomHookPolicy(**kwargs) + self.redirect_policy = kwargs.get("redirect_policy") or policies.AsyncRedirectPolicy(**kwargs) + self.authentication_policy = kwargs.get("authentication_policy") if self.credential and not self.authentication_policy: - self.authentication_policy = AsyncARMChallengeAuthenticationPolicy(self.credential, *self.credential_scopes, **kwargs) + self.authentication_policy = AsyncARMChallengeAuthenticationPolicy( + self.credential, *self.credential_scopes, **kwargs + ) diff --git a/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/locks/v2016_09_01/aio/_management_lock_client.py b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/locks/v2016_09_01/aio/_management_lock_client.py index 0cd9acd5347d4..e604e60883a80 100644 --- a/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/locks/v2016_09_01/aio/_management_lock_client.py +++ b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/locks/v2016_09_01/aio/_management_lock_client.py @@ -9,12 +9,11 @@ from copy import deepcopy from typing import Any, Awaitable, TYPE_CHECKING -from msrest import Deserializer, Serializer - from azure.core.rest import AsyncHttpResponse, HttpRequest from azure.mgmt.core import AsyncARMPipelineClient from .. import models +from ..._serialization import Deserializer, Serializer from ._configuration import ManagementLockClientConfiguration from .operations import AuthorizationOperationsOperations, ManagementLocksOperations @@ -22,7 +21,8 @@ # pylint: disable=unused-import,ungrouped-imports from azure.core.credentials_async import AsyncTokenCredential -class ManagementLockClient: + +class ManagementLockClient: # pylint: disable=client-accepts-api-version-keyword """Azure resources can be locked to prevent other users in your organization from deleting or modifying resources. @@ -32,9 +32,9 @@ class ManagementLockClient: :ivar management_locks: ManagementLocksOperations operations :vartype management_locks: azure.mgmt.resource.locks.v2016_09_01.aio.operations.ManagementLocksOperations - :param credential: Credential needed for the client to connect to Azure. + :param credential: Credential needed for the client to connect to Azure. Required. :type credential: ~azure.core.credentials_async.AsyncTokenCredential - :param subscription_id: The ID of the target subscription. + :param subscription_id: The ID of the target subscription. Required. :type subscription_id: str :param base_url: Service URL. Default value is "https://management.azure.com". :type base_url: str @@ -50,22 +50,23 @@ def __init__( base_url: str = "https://management.azure.com", **kwargs: Any ) -> None: - self._config = ManagementLockClientConfiguration(credential=credential, subscription_id=subscription_id, **kwargs) + self._config = ManagementLockClientConfiguration( + credential=credential, subscription_id=subscription_id, **kwargs + ) self._client = AsyncARMPipelineClient(base_url=base_url, config=self._config, **kwargs) client_models = {k: v for k, v in models.__dict__.items() if isinstance(v, type)} self._serialize = Serializer(client_models) self._deserialize = Deserializer(client_models) self._serialize.client_side_validation = False - self.authorization_operations = AuthorizationOperationsOperations(self._client, self._config, self._serialize, self._deserialize) - self.management_locks = ManagementLocksOperations(self._client, self._config, self._serialize, self._deserialize) - - - def _send_request( - self, - request: HttpRequest, - **kwargs: Any - ) -> Awaitable[AsyncHttpResponse]: + self.authorization_operations = AuthorizationOperationsOperations( + self._client, self._config, self._serialize, self._deserialize + ) + self.management_locks = ManagementLocksOperations( + self._client, self._config, self._serialize, self._deserialize + ) + + def _send_request(self, request: HttpRequest, **kwargs: Any) -> Awaitable[AsyncHttpResponse]: """Runs the network request through the client's chained policies. >>> from azure.core.rest import HttpRequest @@ -74,7 +75,7 @@ def _send_request( >>> response = await client._send_request(request) - For more information on this code flow, see https://aka.ms/azsdk/python/protocol/quickstart + For more information on this code flow, see https://aka.ms/azsdk/dpcodegen/python/send_request :param request: The network request you want to make. Required. :type request: ~azure.core.rest.HttpRequest diff --git a/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/locks/v2016_09_01/aio/_patch.py b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/locks/v2016_09_01/aio/_patch.py index 74e48ecd07cf3..f99e77fef9861 100644 --- a/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/locks/v2016_09_01/aio/_patch.py +++ b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/locks/v2016_09_01/aio/_patch.py @@ -28,4 +28,4 @@ # This file is used for handwritten extensions to the generated code. Example: # https://github.com/Azure/azure-sdk-for-python/blob/main/doc/dev/customize_code/how-to-patch-sdk-code.md def patch_sdk(): - pass \ No newline at end of file + pass diff --git a/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/locks/v2016_09_01/aio/operations/__init__.py b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/locks/v2016_09_01/aio/operations/__init__.py index 13807383c19c0..51c9a203449d1 100644 --- a/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/locks/v2016_09_01/aio/operations/__init__.py +++ b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/locks/v2016_09_01/aio/operations/__init__.py @@ -9,7 +9,13 @@ from ._operations import AuthorizationOperationsOperations from ._operations import ManagementLocksOperations +from ._patch import __all__ as _patch_all +from ._patch import * # type: ignore # pylint: disable=unused-wildcard-import +from ._patch import patch_sdk as _patch_sdk + __all__ = [ - 'AuthorizationOperationsOperations', - 'ManagementLocksOperations', + "AuthorizationOperationsOperations", + "ManagementLocksOperations", ] +__all__.extend([p for p in _patch_all if p not in __all__]) +_patch_sdk() diff --git a/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/locks/v2016_09_01/aio/operations/_operations.py b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/locks/v2016_09_01/aio/operations/_operations.py index e88f000fc055e..3e46664431468 100644 --- a/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/locks/v2016_09_01/aio/operations/_operations.py +++ b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/locks/v2016_09_01/aio/operations/_operations.py @@ -6,82 +6,115 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -from typing import Any, AsyncIterable, Callable, Dict, Optional, TypeVar +from typing import Any, AsyncIterable, Callable, Dict, IO, Optional, TypeVar, Union, overload +from urllib.parse import parse_qs, urljoin, urlparse from azure.core.async_paging import AsyncItemPaged, AsyncList -from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error +from azure.core.exceptions import ( + ClientAuthenticationError, + HttpResponseError, + ResourceExistsError, + ResourceNotFoundError, + ResourceNotModifiedError, + map_error, +) from azure.core.pipeline import PipelineResponse from azure.core.pipeline.transport import AsyncHttpResponse from azure.core.rest import HttpRequest from azure.core.tracing.decorator import distributed_trace from azure.core.tracing.decorator_async import distributed_trace_async +from azure.core.utils import case_insensitive_dict from azure.mgmt.core.exceptions import ARMErrorFormat from ... import models as _models from ..._vendor import _convert_request -from ...operations._operations import build_authorization_operations_list_request, build_management_locks_create_or_update_at_resource_group_level_request, build_management_locks_create_or_update_at_resource_level_request, build_management_locks_create_or_update_at_subscription_level_request, build_management_locks_create_or_update_by_scope_request, build_management_locks_delete_at_resource_group_level_request, build_management_locks_delete_at_resource_level_request, build_management_locks_delete_at_subscription_level_request, build_management_locks_delete_by_scope_request, build_management_locks_get_at_resource_group_level_request, build_management_locks_get_at_resource_level_request, build_management_locks_get_at_subscription_level_request, build_management_locks_get_by_scope_request, build_management_locks_list_at_resource_group_level_request, build_management_locks_list_at_resource_level_request, build_management_locks_list_at_subscription_level_request, build_management_locks_list_by_scope_request -T = TypeVar('T') +from ...operations._operations import ( + build_authorization_operations_list_request, + build_management_locks_create_or_update_at_resource_group_level_request, + build_management_locks_create_or_update_at_resource_level_request, + build_management_locks_create_or_update_at_subscription_level_request, + build_management_locks_create_or_update_by_scope_request, + build_management_locks_delete_at_resource_group_level_request, + build_management_locks_delete_at_resource_level_request, + build_management_locks_delete_at_subscription_level_request, + build_management_locks_delete_by_scope_request, + build_management_locks_get_at_resource_group_level_request, + build_management_locks_get_at_resource_level_request, + build_management_locks_get_at_subscription_level_request, + build_management_locks_get_by_scope_request, + build_management_locks_list_at_resource_group_level_request, + build_management_locks_list_at_resource_level_request, + build_management_locks_list_at_subscription_level_request, + build_management_locks_list_by_scope_request, +) + +T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] -class AuthorizationOperationsOperations: - """AuthorizationOperationsOperations async operations. - You should not instantiate this class directly. Instead, you should create a Client instance that - instantiates it for you and attaches it as an attribute. +class AuthorizationOperationsOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. - :ivar models: Alias to model classes used in this operation group. - :type models: ~azure.mgmt.resource.locks.v2016_09_01.models - :param client: Client for service requests. - :param config: Configuration of service client. - :param serializer: An object model serializer. - :param deserializer: An object model deserializer. + Instead, you should access the following operations through + :class:`~azure.mgmt.resource.locks.v2016_09_01.aio.ManagementLockClient`'s + :attr:`authorization_operations` attribute. """ models = _models - def __init__(self, client, config, serializer, deserializer) -> None: - self._client = client - self._serialize = serializer - self._deserialize = deserializer - self._config = config + def __init__(self, *args, **kwargs) -> None: + input_args = list(args) + self._client = input_args.pop(0) if input_args else kwargs.pop("client") + self._config = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") @distributed_trace - def list( - self, - **kwargs: Any - ) -> AsyncIterable["_models.OperationListResult"]: + def list(self, **kwargs: Any) -> AsyncIterable["_models.Operation"]: """Lists all of the available Microsoft.Authorization REST API operations. :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either OperationListResult or the result of cls(response) + :return: An iterator like instance of either Operation or the result of cls(response) :rtype: - ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.resource.locks.v2016_09_01.models.OperationListResult] - :raises: ~azure.core.exceptions.HttpResponseError + ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.resource.locks.v2016_09_01.models.Operation] + :raises ~azure.core.exceptions.HttpResponseError: """ - api_version = kwargs.pop('api_version', "2016-09-01") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2016-09-01")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[_models.OperationListResult] - cls = kwargs.pop('cls', None) # type: ClsType["_models.OperationListResult"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) + def prepare_request(next_link=None): if not next_link: - + request = build_authorization_operations_list_request( api_version=api_version, - template_url=self.list.metadata['url'], + template_url=self.list.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore else: - - request = build_authorization_operations_list_request( - template_url=next_link, - ) + # make call to next link with the client's api-version + _parsed_next_link = urlparse(next_link) + _next_request_params = case_insensitive_dict(parse_qs(_parsed_next_link.query)) + _next_request_params["api-version"] = self._config.api_version + request = HttpRequest("GET", urljoin(next_link, _parsed_next_link.path), params=_next_request_params) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore request.method = "GET" return request @@ -95,10 +128,8 @@ async def extract_data(pipeline_response): async def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) response = pipeline_response.http_response @@ -108,41 +139,40 @@ async def get_next(next_link=None): return pipeline_response + return AsyncItemPaged(get_next, extract_data) - return AsyncItemPaged( - get_next, extract_data - ) - list.metadata = {'url': "/providers/Microsoft.Authorization/operations"} # type: ignore -class ManagementLocksOperations: - """ManagementLocksOperations async operations. + list.metadata = {"url": "/providers/Microsoft.Authorization/operations"} # type: ignore - You should not instantiate this class directly. Instead, you should create a Client instance that - instantiates it for you and attaches it as an attribute. - :ivar models: Alias to model classes used in this operation group. - :type models: ~azure.mgmt.resource.locks.v2016_09_01.models - :param client: Client for service requests. - :param config: Configuration of service client. - :param serializer: An object model serializer. - :param deserializer: An object model deserializer. +class ManagementLocksOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. + + Instead, you should access the following operations through + :class:`~azure.mgmt.resource.locks.v2016_09_01.aio.ManagementLockClient`'s + :attr:`management_locks` attribute. """ models = _models - def __init__(self, client, config, serializer, deserializer) -> None: - self._client = client - self._serialize = serializer - self._deserialize = deserializer - self._config = config + def __init__(self, *args, **kwargs) -> None: + input_args = list(args) + self._client = input_args.pop(0) if input_args else kwargs.pop("client") + self._config = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") - @distributed_trace_async + @overload async def create_or_update_at_resource_group_level( self, resource_group_name: str, lock_name: str, - parameters: "_models.ManagementLockObject", + parameters: _models.ManagementLockObject, + *, + content_type: str = "application/json", **kwargs: Any - ) -> "_models.ManagementLockObject": + ) -> _models.ManagementLockObject: """Creates or updates a management lock at the resource group level. When you apply a lock at a parent scope, all child resources inherit the same lock. To create @@ -150,28 +180,108 @@ async def create_or_update_at_resource_group_level( Microsoft.Authorization/locks/* actions. Of the built-in roles, only Owner and User Access Administrator are granted those actions. - :param resource_group_name: The name of the resource group to lock. + :param resource_group_name: The name of the resource group to lock. Required. :type resource_group_name: str :param lock_name: The lock name. The lock name can be a maximum of 260 characters. It cannot - contain <, > %, &, :, \, ?, /, or any control characters. + contain <, > %, &, :, \, ?, /, or any control characters. Required. :type lock_name: str - :param parameters: The management lock parameters. + :param parameters: The management lock parameters. Required. :type parameters: ~azure.mgmt.resource.locks.v2016_09_01.models.ManagementLockObject + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: ManagementLockObject or the result of cls(response) + :rtype: ~azure.mgmt.resource.locks.v2016_09_01.models.ManagementLockObject + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + async def create_or_update_at_resource_group_level( + self, + resource_group_name: str, + lock_name: str, + parameters: IO, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.ManagementLockObject: + """Creates or updates a management lock at the resource group level. + + When you apply a lock at a parent scope, all child resources inherit the same lock. To create + management locks, you must have access to Microsoft.Authorization/\ * or + Microsoft.Authorization/locks/* actions. Of the built-in roles, only Owner and User Access + Administrator are granted those actions. + + :param resource_group_name: The name of the resource group to lock. Required. + :type resource_group_name: str + :param lock_name: The lock name. The lock name can be a maximum of 260 characters. It cannot + contain <, > %, &, :, \, ?, /, or any control characters. Required. + :type lock_name: str + :param parameters: The management lock parameters. Required. + :type parameters: IO + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: ManagementLockObject, or the result of cls(response) + :return: ManagementLockObject or the result of cls(response) :rtype: ~azure.mgmt.resource.locks.v2016_09_01.models.ManagementLockObject - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace_async + async def create_or_update_at_resource_group_level( + self, + resource_group_name: str, + lock_name: str, + parameters: Union[_models.ManagementLockObject, IO], + **kwargs: Any + ) -> _models.ManagementLockObject: + """Creates or updates a management lock at the resource group level. + + When you apply a lock at a parent scope, all child resources inherit the same lock. To create + management locks, you must have access to Microsoft.Authorization/\ * or + Microsoft.Authorization/locks/* actions. Of the built-in roles, only Owner and User Access + Administrator are granted those actions. + + :param resource_group_name: The name of the resource group to lock. Required. + :type resource_group_name: str + :param lock_name: The lock name. The lock name can be a maximum of 260 characters. It cannot + contain <, > %, &, :, \, ?, /, or any control characters. Required. + :type lock_name: str + :param parameters: The management lock parameters. Is either a model type or a IO type. + Required. + :type parameters: ~azure.mgmt.resource.locks.v2016_09_01.models.ManagementLockObject or IO + :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. + Default value is None. + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: ManagementLockObject or the result of cls(response) + :rtype: ~azure.mgmt.resource.locks.v2016_09_01.models.ManagementLockObject + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.ManagementLockObject"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', "2016-09-01") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + api_version = kwargs.pop("api_version", _params.pop("api-version", "2016-09-01")) # type: str + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.ManagementLockObject] - _json = self._serialize.body(parameters, 'ManagementLockObject') + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(parameters, (IO, bytes)): + _content = parameters + else: + _json = self._serialize.body(parameters, "ManagementLockObject") request = build_management_locks_create_or_update_at_resource_group_level_request( resource_group_name=resource_group_name, @@ -180,16 +290,18 @@ async def create_or_update_at_resource_group_level( api_version=api_version, content_type=content_type, json=_json, - template_url=self.create_or_update_at_resource_group_level.metadata['url'], + content=_content, + template_url=self.create_or_update_at_resource_group_level.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200, 201]: @@ -197,25 +309,21 @@ async def create_or_update_at_resource_group_level( raise HttpResponseError(response=response, error_format=ARMErrorFormat) if response.status_code == 200: - deserialized = self._deserialize('ManagementLockObject', pipeline_response) + deserialized = self._deserialize("ManagementLockObject", pipeline_response) if response.status_code == 201: - deserialized = self._deserialize('ManagementLockObject', pipeline_response) + deserialized = self._deserialize("ManagementLockObject", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - create_or_update_at_resource_group_level.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Authorization/locks/{lockName}"} # type: ignore - + create_or_update_at_resource_group_level.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Authorization/locks/{lockName}"} # type: ignore @distributed_trace_async async def delete_at_resource_group_level( # pylint: disable=inconsistent-return-statements - self, - resource_group_name: str, - lock_name: str, - **kwargs: Any + self, resource_group_name: str, lock_name: str, **kwargs: Any ) -> None: """Deletes a management lock at the resource group level. @@ -223,39 +331,45 @@ async def delete_at_resource_group_level( # pylint: disable=inconsistent-return Microsoft.Authorization/locks/* actions. Of the built-in roles, only Owner and User Access Administrator are granted those actions. - :param resource_group_name: The name of the resource group containing the lock. + :param resource_group_name: The name of the resource group containing the lock. Required. :type resource_group_name: str - :param lock_name: The name of lock to delete. + :param lock_name: The name of lock to delete. Required. :type lock_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: None, or the result of cls(response) + :return: None or the result of cls(response) :rtype: None - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType[None] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + 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', "2016-09-01") # type: str + api_version = kwargs.pop("api_version", _params.pop("api-version", "2016-09-01")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[None] - request = build_management_locks_delete_at_resource_group_level_request( resource_group_name=resource_group_name, lock_name=lock_name, subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.delete_at_resource_group_level.metadata['url'], + template_url=self.delete_at_resource_group_level.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200, 204]: @@ -265,102 +379,171 @@ async def delete_at_resource_group_level( # pylint: disable=inconsistent-return if cls: return cls(pipeline_response, None, {}) - delete_at_resource_group_level.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Authorization/locks/{lockName}"} # type: ignore - + delete_at_resource_group_level.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Authorization/locks/{lockName}"} # type: ignore @distributed_trace_async async def get_at_resource_group_level( - self, - resource_group_name: str, - lock_name: str, - **kwargs: Any - ) -> "_models.ManagementLockObject": + self, resource_group_name: str, lock_name: str, **kwargs: Any + ) -> _models.ManagementLockObject: """Gets a management lock at the resource group level. - :param resource_group_name: The name of the locked resource group. + :param resource_group_name: The name of the locked resource group. Required. :type resource_group_name: str - :param lock_name: The name of the lock to get. + :param lock_name: The name of the lock to get. Required. :type lock_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: ManagementLockObject, or the result of cls(response) + :return: ManagementLockObject or the result of cls(response) :rtype: ~azure.mgmt.resource.locks.v2016_09_01.models.ManagementLockObject - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.ManagementLockObject"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) - api_version = kwargs.pop('api_version', "2016-09-01") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2016-09-01")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[_models.ManagementLockObject] - request = build_management_locks_get_at_resource_group_level_request( resource_group_name=resource_group_name, lock_name=lock_name, subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.get_at_resource_group_level.metadata['url'], + template_url=self.get_at_resource_group_level.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) - deserialized = self._deserialize('ManagementLockObject', pipeline_response) + deserialized = self._deserialize("ManagementLockObject", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - get_at_resource_group_level.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Authorization/locks/{lockName}"} # type: ignore + get_at_resource_group_level.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Authorization/locks/{lockName}"} # type: ignore - - @distributed_trace_async + @overload async def create_or_update_by_scope( self, scope: str, lock_name: str, - parameters: "_models.ManagementLockObject", + parameters: _models.ManagementLockObject, + *, + content_type: str = "application/json", **kwargs: Any - ) -> "_models.ManagementLockObject": + ) -> _models.ManagementLockObject: """Create or update a management lock by scope. :param scope: The scope for the lock. When providing a scope for the assignment, use '/subscriptions/{subscriptionId}' for subscriptions, '/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}' for resource groups, and '/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{parentResourcePathIfPresent}/{resourceType}/{resourceName}' - for resources. + for resources. Required. :type scope: str - :param lock_name: The name of lock. + :param lock_name: The name of lock. Required. :type lock_name: str - :param parameters: Create or update management lock parameters. + :param parameters: Create or update management lock parameters. Required. :type parameters: ~azure.mgmt.resource.locks.v2016_09_01.models.ManagementLockObject + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: ManagementLockObject or the result of cls(response) + :rtype: ~azure.mgmt.resource.locks.v2016_09_01.models.ManagementLockObject + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + async def create_or_update_by_scope( + self, scope: str, lock_name: str, parameters: IO, *, content_type: str = "application/json", **kwargs: Any + ) -> _models.ManagementLockObject: + """Create or update a management lock by scope. + + :param scope: The scope for the lock. When providing a scope for the assignment, use + '/subscriptions/{subscriptionId}' for subscriptions, + '/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}' for resource groups, and + '/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{parentResourcePathIfPresent}/{resourceType}/{resourceName}' + for resources. Required. + :type scope: str + :param lock_name: The name of lock. Required. + :type lock_name: str + :param parameters: Create or update management lock parameters. Required. + :type parameters: IO + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: ManagementLockObject, or the result of cls(response) + :return: ManagementLockObject or the result of cls(response) :rtype: ~azure.mgmt.resource.locks.v2016_09_01.models.ManagementLockObject - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace_async + async def create_or_update_by_scope( + self, scope: str, lock_name: str, parameters: Union[_models.ManagementLockObject, IO], **kwargs: Any + ) -> _models.ManagementLockObject: + """Create or update a management lock by scope. + + :param scope: The scope for the lock. When providing a scope for the assignment, use + '/subscriptions/{subscriptionId}' for subscriptions, + '/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}' for resource groups, and + '/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{parentResourcePathIfPresent}/{resourceType}/{resourceName}' + for resources. Required. + :type scope: str + :param lock_name: The name of lock. Required. + :type lock_name: str + :param parameters: Create or update management lock parameters. Is either a model type or a IO + type. Required. + :type parameters: ~azure.mgmt.resource.locks.v2016_09_01.models.ManagementLockObject or IO + :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. + Default value is None. + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: ManagementLockObject or the result of cls(response) + :rtype: ~azure.mgmt.resource.locks.v2016_09_01.models.ManagementLockObject + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.ManagementLockObject"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) - api_version = kwargs.pop('api_version', "2016-09-01") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - _json = self._serialize.body(parameters, 'ManagementLockObject') + api_version = kwargs.pop("api_version", _params.pop("api-version", "2016-09-01")) # type: str + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.ManagementLockObject] + + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(parameters, (IO, bytes)): + _content = parameters + else: + _json = self._serialize.body(parameters, "ManagementLockObject") request = build_management_locks_create_or_update_by_scope_request( scope=scope, @@ -368,16 +551,18 @@ async def create_or_update_by_scope( api_version=api_version, content_type=content_type, json=_json, - template_url=self.create_or_update_by_scope.metadata['url'], + content=_content, + template_url=self.create_or_update_by_scope.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200, 201]: @@ -385,60 +570,62 @@ async def create_or_update_by_scope( raise HttpResponseError(response=response, error_format=ARMErrorFormat) if response.status_code == 200: - deserialized = self._deserialize('ManagementLockObject', pipeline_response) + deserialized = self._deserialize("ManagementLockObject", pipeline_response) if response.status_code == 201: - deserialized = self._deserialize('ManagementLockObject', pipeline_response) + deserialized = self._deserialize("ManagementLockObject", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - create_or_update_by_scope.metadata = {'url': "/{scope}/providers/Microsoft.Authorization/locks/{lockName}"} # type: ignore - + create_or_update_by_scope.metadata = {"url": "/{scope}/providers/Microsoft.Authorization/locks/{lockName}"} # type: ignore @distributed_trace_async async def delete_by_scope( # pylint: disable=inconsistent-return-statements - self, - scope: str, - lock_name: str, - **kwargs: Any + self, scope: str, lock_name: str, **kwargs: Any ) -> None: """Delete a management lock by scope. - :param scope: The scope for the lock. + :param scope: The scope for the lock. Required. :type scope: str - :param lock_name: The name of lock. + :param lock_name: The name of lock. Required. :type lock_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: None, or the result of cls(response) + :return: None or the result of cls(response) :rtype: None - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType[None] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + 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', "2016-09-01") # type: str + api_version = kwargs.pop("api_version", _params.pop("api-version", "2016-09-01")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[None] - request = build_management_locks_delete_by_scope_request( scope=scope, lock_name=lock_name, api_version=api_version, - template_url=self.delete_by_scope.metadata['url'], + template_url=self.delete_by_scope.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200, 204]: @@ -448,65 +635,158 @@ async def delete_by_scope( # pylint: disable=inconsistent-return-statements if cls: return cls(pipeline_response, None, {}) - delete_by_scope.metadata = {'url': "/{scope}/providers/Microsoft.Authorization/locks/{lockName}"} # type: ignore - + delete_by_scope.metadata = {"url": "/{scope}/providers/Microsoft.Authorization/locks/{lockName}"} # type: ignore @distributed_trace_async - async def get_by_scope( - self, - scope: str, - lock_name: str, - **kwargs: Any - ) -> "_models.ManagementLockObject": + async def get_by_scope(self, scope: str, lock_name: str, **kwargs: Any) -> _models.ManagementLockObject: """Get a management lock by scope. - :param scope: The scope for the lock. + :param scope: The scope for the lock. Required. :type scope: str - :param lock_name: The name of lock. + :param lock_name: The name of lock. Required. :type lock_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: ManagementLockObject, or the result of cls(response) + :return: ManagementLockObject or the result of cls(response) :rtype: ~azure.mgmt.resource.locks.v2016_09_01.models.ManagementLockObject - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.ManagementLockObject"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + 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', "2016-09-01") # type: str + api_version = kwargs.pop("api_version", _params.pop("api-version", "2016-09-01")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[_models.ManagementLockObject] - request = build_management_locks_get_by_scope_request( scope=scope, lock_name=lock_name, api_version=api_version, - template_url=self.get_by_scope.metadata['url'], + template_url=self.get_by_scope.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) - deserialized = self._deserialize('ManagementLockObject', pipeline_response) + deserialized = self._deserialize("ManagementLockObject", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - get_by_scope.metadata = {'url': "/{scope}/providers/Microsoft.Authorization/locks/{lockName}"} # type: ignore + get_by_scope.metadata = {"url": "/{scope}/providers/Microsoft.Authorization/locks/{lockName}"} # type: ignore + + @overload + async def create_or_update_at_resource_level( + self, + resource_group_name: str, + resource_provider_namespace: str, + parent_resource_path: str, + resource_type: str, + resource_name: str, + lock_name: str, + parameters: _models.ManagementLockObject, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.ManagementLockObject: + """Creates or updates a management lock at the resource level or any level below the resource. + + When you apply a lock at a parent scope, all child resources inherit the same lock. To create + management locks, you must have access to Microsoft.Authorization/\ * or + Microsoft.Authorization/locks/* actions. Of the built-in roles, only Owner and User Access + Administrator are granted those actions. + + :param resource_group_name: The name of the resource group containing the resource to lock. + Required. + :type resource_group_name: str + :param resource_provider_namespace: The resource provider namespace of the resource to lock. + Required. + :type resource_provider_namespace: str + :param parent_resource_path: The parent resource identity. Required. + :type parent_resource_path: str + :param resource_type: The resource type of the resource to lock. Required. + :type resource_type: str + :param resource_name: The name of the resource to lock. Required. + :type resource_name: str + :param lock_name: The name of lock. The lock name can be a maximum of 260 characters. It cannot + contain <, > %, &, :, \, ?, /, or any control characters. Required. + :type lock_name: str + :param parameters: Parameters for creating or updating a management lock. Required. + :type parameters: ~azure.mgmt.resource.locks.v2016_09_01.models.ManagementLockObject + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: ManagementLockObject or the result of cls(response) + :rtype: ~azure.mgmt.resource.locks.v2016_09_01.models.ManagementLockObject + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + async def create_or_update_at_resource_level( + self, + resource_group_name: str, + resource_provider_namespace: str, + parent_resource_path: str, + resource_type: str, + resource_name: str, + lock_name: str, + parameters: IO, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.ManagementLockObject: + """Creates or updates a management lock at the resource level or any level below the resource. + + When you apply a lock at a parent scope, all child resources inherit the same lock. To create + management locks, you must have access to Microsoft.Authorization/\ * or + Microsoft.Authorization/locks/* actions. Of the built-in roles, only Owner and User Access + Administrator are granted those actions. + :param resource_group_name: The name of the resource group containing the resource to lock. + Required. + :type resource_group_name: str + :param resource_provider_namespace: The resource provider namespace of the resource to lock. + Required. + :type resource_provider_namespace: str + :param parent_resource_path: The parent resource identity. Required. + :type parent_resource_path: str + :param resource_type: The resource type of the resource to lock. Required. + :type resource_type: str + :param resource_name: The name of the resource to lock. Required. + :type resource_name: str + :param lock_name: The name of lock. The lock name can be a maximum of 260 characters. It cannot + contain <, > %, &, :, \, ?, /, or any control characters. Required. + :type lock_name: str + :param parameters: Parameters for creating or updating a management lock. Required. + :type parameters: IO + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: ManagementLockObject or the result of cls(response) + :rtype: ~azure.mgmt.resource.locks.v2016_09_01.models.ManagementLockObject + :raises ~azure.core.exceptions.HttpResponseError: + """ @distributed_trace_async async def create_or_update_at_resource_level( @@ -517,9 +797,9 @@ async def create_or_update_at_resource_level( resource_type: str, resource_name: str, lock_name: str, - parameters: "_models.ManagementLockObject", + parameters: Union[_models.ManagementLockObject, IO], **kwargs: Any - ) -> "_models.ManagementLockObject": + ) -> _models.ManagementLockObject: """Creates or updates a management lock at the resource level or any level below the resource. When you apply a lock at a parent scope, all child resources inherit the same lock. To create @@ -528,35 +808,53 @@ async def create_or_update_at_resource_level( Administrator are granted those actions. :param resource_group_name: The name of the resource group containing the resource to lock. + Required. :type resource_group_name: str :param resource_provider_namespace: The resource provider namespace of the resource to lock. + Required. :type resource_provider_namespace: str - :param parent_resource_path: The parent resource identity. + :param parent_resource_path: The parent resource identity. Required. :type parent_resource_path: str - :param resource_type: The resource type of the resource to lock. + :param resource_type: The resource type of the resource to lock. Required. :type resource_type: str - :param resource_name: The name of the resource to lock. + :param resource_name: The name of the resource to lock. Required. :type resource_name: str :param lock_name: The name of lock. The lock name can be a maximum of 260 characters. It cannot - contain <, > %, &, :, \, ?, /, or any control characters. + contain <, > %, &, :, \, ?, /, or any control characters. Required. :type lock_name: str - :param parameters: Parameters for creating or updating a management lock. - :type parameters: ~azure.mgmt.resource.locks.v2016_09_01.models.ManagementLockObject + :param parameters: Parameters for creating or updating a management lock. Is either a model + type or a IO type. Required. + :type parameters: ~azure.mgmt.resource.locks.v2016_09_01.models.ManagementLockObject or IO + :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. + Default value is None. + :paramtype content_type: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: ManagementLockObject, or the result of cls(response) + :return: ManagementLockObject or the result of cls(response) :rtype: ~azure.mgmt.resource.locks.v2016_09_01.models.ManagementLockObject - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.ManagementLockObject"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) - api_version = kwargs.pop('api_version', "2016-09-01") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - _json = self._serialize.body(parameters, 'ManagementLockObject') + api_version = kwargs.pop("api_version", _params.pop("api-version", "2016-09-01")) # type: str + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.ManagementLockObject] + + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(parameters, (IO, bytes)): + _content = parameters + else: + _json = self._serialize.body(parameters, "ManagementLockObject") request = build_management_locks_create_or_update_at_resource_level_request( resource_group_name=resource_group_name, @@ -569,16 +867,18 @@ async def create_or_update_at_resource_level( api_version=api_version, content_type=content_type, json=_json, - template_url=self.create_or_update_at_resource_level.metadata['url'], + content=_content, + template_url=self.create_or_update_at_resource_level.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200, 201]: @@ -586,18 +886,17 @@ async def create_or_update_at_resource_level( raise HttpResponseError(response=response, error_format=ARMErrorFormat) if response.status_code == 200: - deserialized = self._deserialize('ManagementLockObject', pipeline_response) + deserialized = self._deserialize("ManagementLockObject", pipeline_response) if response.status_code == 201: - deserialized = self._deserialize('ManagementLockObject', pipeline_response) + deserialized = self._deserialize("ManagementLockObject", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - create_or_update_at_resource_level.metadata = {'url': "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{parentResourcePath}/{resourceType}/{resourceName}/providers/Microsoft.Authorization/locks/{lockName}"} # type: ignore - + create_or_update_at_resource_level.metadata = {"url": "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{parentResourcePath}/{resourceType}/{resourceName}/providers/Microsoft.Authorization/locks/{lockName}"} # type: ignore @distributed_trace_async async def delete_at_resource_level( # pylint: disable=inconsistent-return-statements @@ -617,33 +916,38 @@ async def delete_at_resource_level( # pylint: disable=inconsistent-return-state Administrator are granted those actions. :param resource_group_name: The name of the resource group containing the resource with the - lock to delete. + lock to delete. Required. :type resource_group_name: str :param resource_provider_namespace: The resource provider namespace of the resource with the - lock to delete. + lock to delete. Required. :type resource_provider_namespace: str - :param parent_resource_path: The parent resource identity. + :param parent_resource_path: The parent resource identity. Required. :type parent_resource_path: str - :param resource_type: The resource type of the resource with the lock to delete. + :param resource_type: The resource type of the resource with the lock to delete. Required. :type resource_type: str - :param resource_name: The name of the resource with the lock to delete. + :param resource_name: The name of the resource with the lock to delete. Required. :type resource_name: str - :param lock_name: The name of the lock to delete. + :param lock_name: The name of the lock to delete. Required. :type lock_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: None, or the result of cls(response) + :return: None or the result of cls(response) :rtype: None - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType[None] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + 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', "2016-09-01") # type: str + api_version = kwargs.pop("api_version", _params.pop("api-version", "2016-09-01")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[None] - request = build_management_locks_delete_at_resource_level_request( resource_group_name=resource_group_name, resource_provider_namespace=resource_provider_namespace, @@ -653,16 +957,17 @@ async def delete_at_resource_level( # pylint: disable=inconsistent-return-state lock_name=lock_name, subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.delete_at_resource_level.metadata['url'], + template_url=self.delete_at_resource_level.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200, 204]: @@ -672,8 +977,7 @@ async def delete_at_resource_level( # pylint: disable=inconsistent-return-state if cls: return cls(pipeline_response, None, {}) - delete_at_resource_level.metadata = {'url': "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{parentResourcePath}/{resourceType}/{resourceName}/providers/Microsoft.Authorization/locks/{lockName}"} # type: ignore - + delete_at_resource_level.metadata = {"url": "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{parentResourcePath}/{resourceType}/{resourceName}/providers/Microsoft.Authorization/locks/{lockName}"} # type: ignore @distributed_trace_async async def get_at_resource_level( @@ -685,36 +989,41 @@ async def get_at_resource_level( resource_name: str, lock_name: str, **kwargs: Any - ) -> "_models.ManagementLockObject": + ) -> _models.ManagementLockObject: """Get the management lock of a resource or any level below resource. - :param resource_group_name: The name of the resource group. + :param resource_group_name: The name of the resource group. Required. :type resource_group_name: str - :param resource_provider_namespace: The namespace of the resource provider. + :param resource_provider_namespace: The namespace of the resource provider. Required. :type resource_provider_namespace: str :param parent_resource_path: An extra path parameter needed in some services, like SQL - Databases. + Databases. Required. :type parent_resource_path: str - :param resource_type: The type of the resource. + :param resource_type: The type of the resource. Required. :type resource_type: str - :param resource_name: The name of the resource. + :param resource_name: The name of the resource. Required. :type resource_name: str - :param lock_name: The name of lock. + :param lock_name: The name of lock. Required. :type lock_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: ManagementLockObject, or the result of cls(response) + :return: ManagementLockObject or the result of cls(response) :rtype: ~azure.mgmt.resource.locks.v2016_09_01.models.ManagementLockObject - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.ManagementLockObject"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + 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', "2016-09-01") # type: str + api_version = kwargs.pop("api_version", _params.pop("api-version", "2016-09-01")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[_models.ManagementLockObject] - request = build_management_locks_get_at_resource_level_request( resource_group_name=resource_group_name, resource_provider_namespace=resource_provider_namespace, @@ -724,39 +1033,41 @@ async def get_at_resource_level( lock_name=lock_name, subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.get_at_resource_level.metadata['url'], + template_url=self.get_at_resource_level.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) - deserialized = self._deserialize('ManagementLockObject', pipeline_response) + deserialized = self._deserialize("ManagementLockObject", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - get_at_resource_level.metadata = {'url': "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{parentResourcePath}/{resourceType}/{resourceName}/providers/Microsoft.Authorization/locks/{lockName}"} # type: ignore - + get_at_resource_level.metadata = {"url": "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{parentResourcePath}/{resourceType}/{resourceName}/providers/Microsoft.Authorization/locks/{lockName}"} # type: ignore - @distributed_trace_async + @overload async def create_or_update_at_subscription_level( self, lock_name: str, - parameters: "_models.ManagementLockObject", + parameters: _models.ManagementLockObject, + *, + content_type: str = "application/json", **kwargs: Any - ) -> "_models.ManagementLockObject": + ) -> _models.ManagementLockObject: """Creates or updates a management lock at the subscription level. When you apply a lock at a parent scope, all child resources inherit the same lock. To create @@ -765,25 +1076,91 @@ async def create_or_update_at_subscription_level( Administrator are granted those actions. :param lock_name: The name of lock. The lock name can be a maximum of 260 characters. It cannot - contain <, > %, &, :, \, ?, /, or any control characters. + contain <, > %, &, :, \, ?, /, or any control characters. Required. :type lock_name: str - :param parameters: The management lock parameters. + :param parameters: The management lock parameters. Required. :type parameters: ~azure.mgmt.resource.locks.v2016_09_01.models.ManagementLockObject + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: ManagementLockObject, or the result of cls(response) + :return: ManagementLockObject or the result of cls(response) :rtype: ~azure.mgmt.resource.locks.v2016_09_01.models.ManagementLockObject - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + async def create_or_update_at_subscription_level( + self, lock_name: str, parameters: IO, *, content_type: str = "application/json", **kwargs: Any + ) -> _models.ManagementLockObject: + """Creates or updates a management lock at the subscription level. + + When you apply a lock at a parent scope, all child resources inherit the same lock. To create + management locks, you must have access to Microsoft.Authorization/\ * or + Microsoft.Authorization/locks/* actions. Of the built-in roles, only Owner and User Access + Administrator are granted those actions. + + :param lock_name: The name of lock. The lock name can be a maximum of 260 characters. It cannot + contain <, > %, &, :, \, ?, /, or any control characters. Required. + :type lock_name: str + :param parameters: The management lock parameters. Required. + :type parameters: IO + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: ManagementLockObject or the result of cls(response) + :rtype: ~azure.mgmt.resource.locks.v2016_09_01.models.ManagementLockObject + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace_async + async def create_or_update_at_subscription_level( + self, lock_name: str, parameters: Union[_models.ManagementLockObject, IO], **kwargs: Any + ) -> _models.ManagementLockObject: + """Creates or updates a management lock at the subscription level. + + When you apply a lock at a parent scope, all child resources inherit the same lock. To create + management locks, you must have access to Microsoft.Authorization/\ * or + Microsoft.Authorization/locks/* actions. Of the built-in roles, only Owner and User Access + Administrator are granted those actions. + + :param lock_name: The name of lock. The lock name can be a maximum of 260 characters. It cannot + contain <, > %, &, :, \, ?, /, or any control characters. Required. + :type lock_name: str + :param parameters: The management lock parameters. Is either a model type or a IO type. + Required. + :type parameters: ~azure.mgmt.resource.locks.v2016_09_01.models.ManagementLockObject or IO + :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. + Default value is None. + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: ManagementLockObject or the result of cls(response) + :rtype: ~azure.mgmt.resource.locks.v2016_09_01.models.ManagementLockObject + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.ManagementLockObject"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', "2016-09-01") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + api_version = kwargs.pop("api_version", _params.pop("api-version", "2016-09-01")) # type: str + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.ManagementLockObject] - _json = self._serialize.body(parameters, 'ManagementLockObject') + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(parameters, (IO, bytes)): + _content = parameters + else: + _json = self._serialize.body(parameters, "ManagementLockObject") request = build_management_locks_create_or_update_at_subscription_level_request( lock_name=lock_name, @@ -791,16 +1168,18 @@ async def create_or_update_at_subscription_level( api_version=api_version, content_type=content_type, json=_json, - template_url=self.create_or_update_at_subscription_level.metadata['url'], + content=_content, + template_url=self.create_or_update_at_subscription_level.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200, 201]: @@ -808,24 +1187,21 @@ async def create_or_update_at_subscription_level( raise HttpResponseError(response=response, error_format=ARMErrorFormat) if response.status_code == 200: - deserialized = self._deserialize('ManagementLockObject', pipeline_response) + deserialized = self._deserialize("ManagementLockObject", pipeline_response) if response.status_code == 201: - deserialized = self._deserialize('ManagementLockObject', pipeline_response) + deserialized = self._deserialize("ManagementLockObject", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - create_or_update_at_subscription_level.metadata = {'url': "/subscriptions/{subscriptionId}/providers/Microsoft.Authorization/locks/{lockName}"} # type: ignore - + create_or_update_at_subscription_level.metadata = {"url": "/subscriptions/{subscriptionId}/providers/Microsoft.Authorization/locks/{lockName}"} # type: ignore @distributed_trace_async async def delete_at_subscription_level( # pylint: disable=inconsistent-return-statements - self, - lock_name: str, - **kwargs: Any + self, lock_name: str, **kwargs: Any ) -> None: """Deletes the management lock at the subscription level. @@ -833,36 +1209,42 @@ async def delete_at_subscription_level( # pylint: disable=inconsistent-return-s Microsoft.Authorization/locks/* actions. Of the built-in roles, only Owner and User Access Administrator are granted those actions. - :param lock_name: The name of lock to delete. + :param lock_name: The name of lock to delete. Required. :type lock_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: None, or the result of cls(response) + :return: None or the result of cls(response) :rtype: None - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType[None] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + 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', "2016-09-01") # type: str + api_version = kwargs.pop("api_version", _params.pop("api-version", "2016-09-01")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[None] - request = build_management_locks_delete_at_subscription_level_request( lock_name=lock_name, subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.delete_at_subscription_level.metadata['url'], + template_url=self.delete_at_subscription_level.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200, 204]: @@ -872,112 +1254,118 @@ async def delete_at_subscription_level( # pylint: disable=inconsistent-return-s if cls: return cls(pipeline_response, None, {}) - delete_at_subscription_level.metadata = {'url': "/subscriptions/{subscriptionId}/providers/Microsoft.Authorization/locks/{lockName}"} # type: ignore - + delete_at_subscription_level.metadata = {"url": "/subscriptions/{subscriptionId}/providers/Microsoft.Authorization/locks/{lockName}"} # type: ignore @distributed_trace_async - async def get_at_subscription_level( - self, - lock_name: str, - **kwargs: Any - ) -> "_models.ManagementLockObject": + async def get_at_subscription_level(self, lock_name: str, **kwargs: Any) -> _models.ManagementLockObject: """Gets a management lock at the subscription level. - :param lock_name: The name of the lock to get. + :param lock_name: The name of the lock to get. Required. :type lock_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: ManagementLockObject, or the result of cls(response) + :return: ManagementLockObject or the result of cls(response) :rtype: ~azure.mgmt.resource.locks.v2016_09_01.models.ManagementLockObject - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.ManagementLockObject"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) - api_version = kwargs.pop('api_version', "2016-09-01") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2016-09-01")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[_models.ManagementLockObject] - request = build_management_locks_get_at_subscription_level_request( lock_name=lock_name, subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.get_at_subscription_level.metadata['url'], + template_url=self.get_at_subscription_level.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) - deserialized = self._deserialize('ManagementLockObject', pipeline_response) + deserialized = self._deserialize("ManagementLockObject", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - get_at_subscription_level.metadata = {'url': "/subscriptions/{subscriptionId}/providers/Microsoft.Authorization/locks/{lockName}"} # type: ignore - + get_at_subscription_level.metadata = {"url": "/subscriptions/{subscriptionId}/providers/Microsoft.Authorization/locks/{lockName}"} # type: ignore @distributed_trace def list_at_resource_group_level( - self, - resource_group_name: str, - filter: Optional[str] = None, - **kwargs: Any - ) -> AsyncIterable["_models.ManagementLockListResult"]: + self, resource_group_name: str, filter: Optional[str] = None, **kwargs: Any + ) -> AsyncIterable["_models.ManagementLockObject"]: """Gets all the management locks for a resource group. :param resource_group_name: The name of the resource group containing the locks to get. + Required. :type resource_group_name: str :param filter: The filter to apply on the operation. Default value is None. :type filter: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either ManagementLockListResult or the result of + :return: An iterator like instance of either ManagementLockObject or the result of cls(response) :rtype: - ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.resource.locks.v2016_09_01.models.ManagementLockListResult] - :raises: ~azure.core.exceptions.HttpResponseError + ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.resource.locks.v2016_09_01.models.ManagementLockObject] + :raises ~azure.core.exceptions.HttpResponseError: """ - api_version = kwargs.pop('api_version', "2016-09-01") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2016-09-01")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[_models.ManagementLockListResult] - cls = kwargs.pop('cls', None) # type: ClsType["_models.ManagementLockListResult"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) + def prepare_request(next_link=None): if not next_link: - + request = build_management_locks_list_at_resource_group_level_request( resource_group_name=resource_group_name, subscription_id=self._config.subscription_id, - api_version=api_version, filter=filter, - template_url=self.list_at_resource_group_level.metadata['url'], + api_version=api_version, + template_url=self.list_at_resource_group_level.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore else: - - request = build_management_locks_list_at_resource_group_level_request( - resource_group_name=resource_group_name, - subscription_id=self._config.subscription_id, - template_url=next_link, - ) + # make call to next link with the client's api-version + _parsed_next_link = urlparse(next_link) + _next_request_params = case_insensitive_dict(parse_qs(_parsed_next_link.query)) + _next_request_params["api-version"] = self._config.api_version + request = HttpRequest("GET", urljoin(next_link, _parsed_next_link.path), params=_next_request_params) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore request.method = "GET" return request @@ -991,10 +1379,8 @@ async def extract_data(pipeline_response): async def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) response = pipeline_response.http_response @@ -1004,11 +1390,9 @@ async def get_next(next_link=None): return pipeline_response + return AsyncItemPaged(get_next, extract_data) - return AsyncItemPaged( - get_next, extract_data - ) - list_at_resource_group_level.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Authorization/locks"} # type: ignore + list_at_resource_group_level.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Authorization/locks"} # type: ignore @distributed_trace def list_at_resource_level( @@ -1020,39 +1404,46 @@ def list_at_resource_level( resource_name: str, filter: Optional[str] = None, **kwargs: Any - ) -> AsyncIterable["_models.ManagementLockListResult"]: + ) -> AsyncIterable["_models.ManagementLockObject"]: """Gets all the management locks for a resource or any level below resource. :param resource_group_name: The name of the resource group containing the locked resource. The - name is case insensitive. + name is case insensitive. Required. :type resource_group_name: str - :param resource_provider_namespace: The namespace of the resource provider. + :param resource_provider_namespace: The namespace of the resource provider. Required. :type resource_provider_namespace: str - :param parent_resource_path: The parent resource identity. + :param parent_resource_path: The parent resource identity. Required. :type parent_resource_path: str - :param resource_type: The resource type of the locked resource. + :param resource_type: The resource type of the locked resource. Required. :type resource_type: str - :param resource_name: The name of the locked resource. + :param resource_name: The name of the locked resource. Required. :type resource_name: str :param filter: The filter to apply on the operation. Default value is None. :type filter: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either ManagementLockListResult or the result of + :return: An iterator like instance of either ManagementLockObject or the result of cls(response) :rtype: - ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.resource.locks.v2016_09_01.models.ManagementLockListResult] - :raises: ~azure.core.exceptions.HttpResponseError + ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.resource.locks.v2016_09_01.models.ManagementLockObject] + :raises ~azure.core.exceptions.HttpResponseError: """ - api_version = kwargs.pop('api_version', "2016-09-01") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2016-09-01")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[_models.ManagementLockListResult] - cls = kwargs.pop('cls', None) # type: ClsType["_models.ManagementLockListResult"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) + def prepare_request(next_link=None): if not next_link: - + request = build_management_locks_list_at_resource_level_request( resource_group_name=resource_group_name, resource_provider_namespace=resource_provider_namespace, @@ -1060,26 +1451,23 @@ def prepare_request(next_link=None): resource_type=resource_type, resource_name=resource_name, subscription_id=self._config.subscription_id, - api_version=api_version, filter=filter, - template_url=self.list_at_resource_level.metadata['url'], + api_version=api_version, + template_url=self.list_at_resource_level.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore else: - - request = build_management_locks_list_at_resource_level_request( - resource_group_name=resource_group_name, - resource_provider_namespace=resource_provider_namespace, - parent_resource_path=parent_resource_path, - resource_type=resource_type, - resource_name=resource_name, - subscription_id=self._config.subscription_id, - template_url=next_link, - ) + # make call to next link with the client's api-version + _parsed_next_link = urlparse(next_link) + _next_request_params = case_insensitive_dict(parse_qs(_parsed_next_link.query)) + _next_request_params["api-version"] = self._config.api_version + request = HttpRequest("GET", urljoin(next_link, _parsed_next_link.path), params=_next_request_params) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore request.method = "GET" return request @@ -1093,10 +1481,8 @@ async def extract_data(pipeline_response): async def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) response = pipeline_response.http_response @@ -1106,56 +1492,61 @@ async def get_next(next_link=None): return pipeline_response + return AsyncItemPaged(get_next, extract_data) - return AsyncItemPaged( - get_next, extract_data - ) - list_at_resource_level.metadata = {'url': "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{parentResourcePath}/{resourceType}/{resourceName}/providers/Microsoft.Authorization/locks"} # type: ignore + list_at_resource_level.metadata = {"url": "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{parentResourcePath}/{resourceType}/{resourceName}/providers/Microsoft.Authorization/locks"} # type: ignore @distributed_trace def list_at_subscription_level( - self, - filter: Optional[str] = None, - **kwargs: Any - ) -> AsyncIterable["_models.ManagementLockListResult"]: + self, filter: Optional[str] = None, **kwargs: Any + ) -> AsyncIterable["_models.ManagementLockObject"]: """Gets all the management locks for a subscription. :param filter: The filter to apply on the operation. Default value is None. :type filter: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either ManagementLockListResult or the result of + :return: An iterator like instance of either ManagementLockObject or the result of cls(response) :rtype: - ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.resource.locks.v2016_09_01.models.ManagementLockListResult] - :raises: ~azure.core.exceptions.HttpResponseError + ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.resource.locks.v2016_09_01.models.ManagementLockObject] + :raises ~azure.core.exceptions.HttpResponseError: """ - api_version = kwargs.pop('api_version', "2016-09-01") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2016-09-01")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[_models.ManagementLockListResult] - cls = kwargs.pop('cls', None) # type: ClsType["_models.ManagementLockListResult"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) + def prepare_request(next_link=None): if not next_link: - + request = build_management_locks_list_at_subscription_level_request( subscription_id=self._config.subscription_id, - api_version=api_version, filter=filter, - template_url=self.list_at_subscription_level.metadata['url'], + api_version=api_version, + template_url=self.list_at_subscription_level.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore else: - - request = build_management_locks_list_at_subscription_level_request( - subscription_id=self._config.subscription_id, - template_url=next_link, - ) + # make call to next link with the client's api-version + _parsed_next_link = urlparse(next_link) + _next_request_params = case_insensitive_dict(parse_qs(_parsed_next_link.query)) + _next_request_params["api-version"] = self._config.api_version + request = HttpRequest("GET", urljoin(next_link, _parsed_next_link.path), params=_next_request_params) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore request.method = "GET" return request @@ -1169,10 +1560,8 @@ async def extract_data(pipeline_response): async def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) response = pipeline_response.http_response @@ -1182,63 +1571,67 @@ async def get_next(next_link=None): return pipeline_response + return AsyncItemPaged(get_next, extract_data) - return AsyncItemPaged( - get_next, extract_data - ) - list_at_subscription_level.metadata = {'url': "/subscriptions/{subscriptionId}/providers/Microsoft.Authorization/locks"} # type: ignore + list_at_subscription_level.metadata = {"url": "/subscriptions/{subscriptionId}/providers/Microsoft.Authorization/locks"} # type: ignore @distributed_trace def list_by_scope( - self, - scope: str, - filter: Optional[str] = None, - **kwargs: Any - ) -> AsyncIterable["_models.ManagementLockListResult"]: + self, scope: str, filter: Optional[str] = None, **kwargs: Any + ) -> AsyncIterable["_models.ManagementLockObject"]: """Gets all the management locks for a scope. :param scope: The scope for the lock. When providing a scope for the assignment, use '/subscriptions/{subscriptionId}' for subscriptions, '/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}' for resource groups, and '/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{parentResourcePathIfPresent}/{resourceType}/{resourceName}' - for resources. + for resources. Required. :type scope: str :param filter: The filter to apply on the operation. Default value is None. :type filter: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either ManagementLockListResult or the result of + :return: An iterator like instance of either ManagementLockObject or the result of cls(response) :rtype: - ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.resource.locks.v2016_09_01.models.ManagementLockListResult] - :raises: ~azure.core.exceptions.HttpResponseError + ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.resource.locks.v2016_09_01.models.ManagementLockObject] + :raises ~azure.core.exceptions.HttpResponseError: """ - api_version = kwargs.pop('api_version', "2016-09-01") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2016-09-01")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[_models.ManagementLockListResult] - cls = kwargs.pop('cls', None) # type: ClsType["_models.ManagementLockListResult"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) + def prepare_request(next_link=None): if not next_link: - + request = build_management_locks_list_by_scope_request( scope=scope, - api_version=api_version, filter=filter, - template_url=self.list_by_scope.metadata['url'], + api_version=api_version, + template_url=self.list_by_scope.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore else: - - request = build_management_locks_list_by_scope_request( - scope=scope, - template_url=next_link, - ) + # make call to next link with the client's api-version + _parsed_next_link = urlparse(next_link) + _next_request_params = case_insensitive_dict(parse_qs(_parsed_next_link.query)) + _next_request_params["api-version"] = self._config.api_version + request = HttpRequest("GET", urljoin(next_link, _parsed_next_link.path), params=_next_request_params) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore request.method = "GET" return request @@ -1252,10 +1645,8 @@ async def extract_data(pipeline_response): async def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) response = pipeline_response.http_response @@ -1265,8 +1656,6 @@ async def get_next(next_link=None): return pipeline_response + return AsyncItemPaged(get_next, extract_data) - return AsyncItemPaged( - get_next, extract_data - ) - list_by_scope.metadata = {'url': "/{scope}/providers/Microsoft.Authorization/locks"} # type: ignore + list_by_scope.metadata = {"url": "/{scope}/providers/Microsoft.Authorization/locks"} # type: ignore diff --git a/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/locks/v2016_09_01/aio/operations/_patch.py b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/locks/v2016_09_01/aio/operations/_patch.py new file mode 100644 index 0000000000000..f7dd32510333d --- /dev/null +++ b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/locks/v2016_09_01/aio/operations/_patch.py @@ -0,0 +1,20 @@ +# ------------------------------------ +# Copyright (c) Microsoft Corporation. +# Licensed under the MIT License. +# ------------------------------------ +"""Customize generated code here. + +Follow our quickstart for examples: https://aka.ms/azsdk/python/dpcodegen/python/customize +""" +from typing import List + +__all__: List[str] = [] # Add all objects you want publicly available to users at this package level + + +def patch_sdk(): + """Do not remove from this file. + + `patch_sdk` is a last resort escape hatch that allows you to do customizations + you can't accomplish using the techniques described in + https://aka.ms/azsdk/python/dpcodegen/python/customize + """ diff --git a/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/locks/v2016_09_01/models/__init__.py b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/locks/v2016_09_01/models/__init__.py index edb81e06a8641..f553a610d4cbc 100644 --- a/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/locks/v2016_09_01/models/__init__.py +++ b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/locks/v2016_09_01/models/__init__.py @@ -13,17 +13,19 @@ from ._models_py3 import OperationDisplay from ._models_py3 import OperationListResult - -from ._management_lock_client_enums import ( - LockLevel, -) +from ._management_lock_client_enums import LockLevel +from ._patch import __all__ as _patch_all +from ._patch import * # type: ignore # pylint: disable=unused-wildcard-import +from ._patch import patch_sdk as _patch_sdk __all__ = [ - 'ManagementLockListResult', - 'ManagementLockObject', - 'ManagementLockOwner', - 'Operation', - 'OperationDisplay', - 'OperationListResult', - 'LockLevel', + "ManagementLockListResult", + "ManagementLockObject", + "ManagementLockOwner", + "Operation", + "OperationDisplay", + "OperationListResult", + "LockLevel", ] +__all__.extend([p for p in _patch_all if p not in __all__]) +_patch_sdk() diff --git a/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/locks/v2016_09_01/models/_management_lock_client_enums.py b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/locks/v2016_09_01/models/_management_lock_client_enums.py index 67b85cfc2c301..672293de07fe1 100644 --- a/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/locks/v2016_09_01/models/_management_lock_client_enums.py +++ b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/locks/v2016_09_01/models/_management_lock_client_enums.py @@ -7,11 +7,10 @@ # -------------------------------------------------------------------------- from enum import Enum -from six import with_metaclass from azure.core import CaseInsensitiveEnumMeta -class LockLevel(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): +class LockLevel(str, Enum, metaclass=CaseInsensitiveEnumMeta): """The level of the lock. Possible values are: NotSpecified, CanNotDelete, ReadOnly. CanNotDelete means authorized users are able to read and modify the resources, but not delete. ReadOnly means authorized users can only read from a resource, but they can't modify or delete it. diff --git a/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/locks/v2016_09_01/models/_models_py3.py b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/locks/v2016_09_01/models/_models_py3.py index a011c7f0be503..ca0bf2f263cfe 100644 --- a/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/locks/v2016_09_01/models/_models_py3.py +++ b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/locks/v2016_09_01/models/_models_py3.py @@ -1,4 +1,5 @@ # coding=utf-8 +# pylint: disable=too-many-lines # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. # Licensed under the MIT License. See License.txt in the project root for license information. @@ -6,14 +7,16 @@ # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -from typing import List, Optional, Union +from typing import List, Optional, TYPE_CHECKING, Union -import msrest.serialization +from ... import _serialization -from ._management_lock_client_enums import * +if TYPE_CHECKING: + # pylint: disable=unused-import,ungrouped-imports + from .. import models as _models -class ManagementLockListResult(msrest.serialization.Model): +class ManagementLockListResult(_serialization.Model): """The list of locks. :ivar value: The list of locks. @@ -23,16 +26,12 @@ class ManagementLockListResult(msrest.serialization.Model): """ _attribute_map = { - 'value': {'key': 'value', 'type': '[ManagementLockObject]'}, - 'next_link': {'key': 'nextLink', 'type': 'str'}, + "value": {"key": "value", "type": "[ManagementLockObject]"}, + "next_link": {"key": "nextLink", "type": "str"}, } def __init__( - self, - *, - value: Optional[List["ManagementLockObject"]] = None, - next_link: Optional[str] = None, - **kwargs + self, *, value: Optional[List["_models.ManagementLockObject"]] = None, next_link: Optional[str] = None, **kwargs ): """ :keyword value: The list of locks. @@ -40,12 +39,12 @@ def __init__( :keyword next_link: The URL to use for getting the next set of results. :paramtype next_link: str """ - super(ManagementLockListResult, self).__init__(**kwargs) + super().__init__(**kwargs) self.value = value self.next_link = next_link -class ManagementLockObject(msrest.serialization.Model): +class ManagementLockObject(_serialization.Model): """The lock information. Variables are only populated by the server, and will be ignored when sending a request. @@ -58,10 +57,10 @@ class ManagementLockObject(msrest.serialization.Model): :vartype type: str :ivar name: The name of the lock. :vartype name: str - :ivar level: Required. The level of the lock. Possible values are: NotSpecified, CanNotDelete, - ReadOnly. CanNotDelete means authorized users are able to read and modify the resources, but - not delete. ReadOnly means authorized users can only read from a resource, but they can't - modify or delete it. Possible values include: "NotSpecified", "CanNotDelete", "ReadOnly". + :ivar level: The level of the lock. Possible values are: NotSpecified, CanNotDelete, ReadOnly. + CanNotDelete means authorized users are able to read and modify the resources, but not delete. + ReadOnly means authorized users can only read from a resource, but they can't modify or delete + it. Required. Known values are: "NotSpecified", "CanNotDelete", and "ReadOnly". :vartype level: str or ~azure.mgmt.resource.locks.v2016_09_01.models.LockLevel :ivar notes: Notes about the lock. Maximum of 512 characters. :vartype notes: str @@ -70,34 +69,34 @@ class ManagementLockObject(msrest.serialization.Model): """ _validation = { - 'id': {'readonly': True}, - 'type': {'readonly': True}, - 'name': {'readonly': True}, - 'level': {'required': True}, + "id": {"readonly": True}, + "type": {"readonly": True}, + "name": {"readonly": True}, + "level": {"required": True}, } _attribute_map = { - 'id': {'key': 'id', 'type': 'str'}, - 'type': {'key': 'type', 'type': 'str'}, - 'name': {'key': 'name', 'type': 'str'}, - 'level': {'key': 'properties.level', 'type': 'str'}, - 'notes': {'key': 'properties.notes', 'type': 'str'}, - 'owners': {'key': 'properties.owners', 'type': '[ManagementLockOwner]'}, + "id": {"key": "id", "type": "str"}, + "type": {"key": "type", "type": "str"}, + "name": {"key": "name", "type": "str"}, + "level": {"key": "properties.level", "type": "str"}, + "notes": {"key": "properties.notes", "type": "str"}, + "owners": {"key": "properties.owners", "type": "[ManagementLockOwner]"}, } def __init__( self, *, - level: Union[str, "LockLevel"], + level: Union[str, "_models.LockLevel"], notes: Optional[str] = None, - owners: Optional[List["ManagementLockOwner"]] = None, + owners: Optional[List["_models.ManagementLockOwner"]] = None, **kwargs ): """ - :keyword level: Required. The level of the lock. Possible values are: NotSpecified, - CanNotDelete, ReadOnly. CanNotDelete means authorized users are able to read and modify the - resources, but not delete. ReadOnly means authorized users can only read from a resource, but - they can't modify or delete it. Possible values include: "NotSpecified", "CanNotDelete", + :keyword level: The level of the lock. Possible values are: NotSpecified, CanNotDelete, + ReadOnly. CanNotDelete means authorized users are able to read and modify the resources, but + not delete. ReadOnly means authorized users can only read from a resource, but they can't + modify or delete it. Required. Known values are: "NotSpecified", "CanNotDelete", and "ReadOnly". :paramtype level: str or ~azure.mgmt.resource.locks.v2016_09_01.models.LockLevel :keyword notes: Notes about the lock. Maximum of 512 characters. @@ -105,7 +104,7 @@ def __init__( :keyword owners: The owners of the lock. :paramtype owners: list[~azure.mgmt.resource.locks.v2016_09_01.models.ManagementLockOwner] """ - super(ManagementLockObject, self).__init__(**kwargs) + super().__init__(**kwargs) self.id = None self.type = None self.name = None @@ -114,7 +113,7 @@ def __init__( self.owners = owners -class ManagementLockOwner(msrest.serialization.Model): +class ManagementLockOwner(_serialization.Model): """Lock owner properties. :ivar application_id: The application ID of the lock owner. @@ -122,24 +121,19 @@ class ManagementLockOwner(msrest.serialization.Model): """ _attribute_map = { - 'application_id': {'key': 'applicationId', 'type': 'str'}, + "application_id": {"key": "applicationId", "type": "str"}, } - def __init__( - self, - *, - application_id: Optional[str] = None, - **kwargs - ): + def __init__(self, *, application_id: Optional[str] = None, **kwargs): """ :keyword application_id: The application ID of the lock owner. :paramtype application_id: str """ - super(ManagementLockOwner, self).__init__(**kwargs) + super().__init__(**kwargs) self.application_id = application_id -class Operation(msrest.serialization.Model): +class Operation(_serialization.Model): """Microsoft.Authorization operation. :ivar name: Operation name: {provider}/{resource}/{operation}. @@ -149,29 +143,23 @@ class Operation(msrest.serialization.Model): """ _attribute_map = { - 'name': {'key': 'name', 'type': 'str'}, - 'display': {'key': 'display', 'type': 'OperationDisplay'}, + "name": {"key": "name", "type": "str"}, + "display": {"key": "display", "type": "OperationDisplay"}, } - def __init__( - self, - *, - name: Optional[str] = None, - display: Optional["OperationDisplay"] = None, - **kwargs - ): + def __init__(self, *, name: Optional[str] = None, display: Optional["_models.OperationDisplay"] = None, **kwargs): """ :keyword name: Operation name: {provider}/{resource}/{operation}. :paramtype name: str :keyword display: The object that represents the operation. :paramtype display: ~azure.mgmt.resource.locks.v2016_09_01.models.OperationDisplay """ - super(Operation, self).__init__(**kwargs) + super().__init__(**kwargs) self.name = name self.display = display -class OperationDisplay(msrest.serialization.Model): +class OperationDisplay(_serialization.Model): """The object that represents the operation. :ivar provider: Service provider: Microsoft.Authorization. @@ -183,9 +171,9 @@ class OperationDisplay(msrest.serialization.Model): """ _attribute_map = { - 'provider': {'key': 'provider', 'type': 'str'}, - 'resource': {'key': 'resource', 'type': 'str'}, - 'operation': {'key': 'operation', 'type': 'str'}, + "provider": {"key": "provider", "type": "str"}, + "resource": {"key": "resource", "type": "str"}, + "operation": {"key": "operation", "type": "str"}, } def __init__( @@ -204,13 +192,13 @@ def __init__( :keyword operation: Operation type: Read, write, delete, etc. :paramtype operation: str """ - super(OperationDisplay, self).__init__(**kwargs) + super().__init__(**kwargs) self.provider = provider self.resource = resource self.operation = operation -class OperationListResult(msrest.serialization.Model): +class OperationListResult(_serialization.Model): """Result of the request to list Microsoft.Authorization operations. It contains a list of operations and a URL link to get the next set of results. :ivar value: List of Microsoft.Authorization operations. @@ -220,23 +208,17 @@ class OperationListResult(msrest.serialization.Model): """ _attribute_map = { - 'value': {'key': 'value', 'type': '[Operation]'}, - 'next_link': {'key': 'nextLink', 'type': 'str'}, + "value": {"key": "value", "type": "[Operation]"}, + "next_link": {"key": "nextLink", "type": "str"}, } - def __init__( - self, - *, - value: Optional[List["Operation"]] = None, - next_link: Optional[str] = None, - **kwargs - ): + def __init__(self, *, value: Optional[List["_models.Operation"]] = None, next_link: Optional[str] = None, **kwargs): """ :keyword value: List of Microsoft.Authorization operations. :paramtype value: list[~azure.mgmt.resource.locks.v2016_09_01.models.Operation] :keyword next_link: URL to get the next set of operation list results if there are any. :paramtype next_link: str """ - super(OperationListResult, self).__init__(**kwargs) + super().__init__(**kwargs) self.value = value self.next_link = next_link diff --git a/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/locks/v2016_09_01/models/_patch.py b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/locks/v2016_09_01/models/_patch.py new file mode 100644 index 0000000000000..f7dd32510333d --- /dev/null +++ b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/locks/v2016_09_01/models/_patch.py @@ -0,0 +1,20 @@ +# ------------------------------------ +# Copyright (c) Microsoft Corporation. +# Licensed under the MIT License. +# ------------------------------------ +"""Customize generated code here. + +Follow our quickstart for examples: https://aka.ms/azsdk/python/dpcodegen/python/customize +""" +from typing import List + +__all__: List[str] = [] # Add all objects you want publicly available to users at this package level + + +def patch_sdk(): + """Do not remove from this file. + + `patch_sdk` is a last resort escape hatch that allows you to do customizations + you can't accomplish using the techniques described in + https://aka.ms/azsdk/python/dpcodegen/python/customize + """ diff --git a/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/locks/v2016_09_01/operations/__init__.py b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/locks/v2016_09_01/operations/__init__.py index 13807383c19c0..51c9a203449d1 100644 --- a/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/locks/v2016_09_01/operations/__init__.py +++ b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/locks/v2016_09_01/operations/__init__.py @@ -9,7 +9,13 @@ from ._operations import AuthorizationOperationsOperations from ._operations import ManagementLocksOperations +from ._patch import __all__ as _patch_all +from ._patch import * # type: ignore # pylint: disable=unused-wildcard-import +from ._patch import patch_sdk as _patch_sdk + __all__ = [ - 'AuthorizationOperationsOperations', - 'ManagementLocksOperations', + "AuthorizationOperationsOperations", + "ManagementLocksOperations", ] +__all__.extend([p for p in _patch_all if p not in __all__]) +_patch_sdk() diff --git a/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/locks/v2016_09_01/operations/_operations.py b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/locks/v2016_09_01/operations/_operations.py index 2bbcf3c62633b..2b4a989427401 100644 --- a/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/locks/v2016_09_01/operations/_operations.py +++ b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/locks/v2016_09_01/operations/_operations.py @@ -6,265 +6,221 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -from typing import Any, Callable, Dict, Iterable, Optional, TypeVar - -from msrest import Serializer - -from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error +from typing import Any, Callable, Dict, IO, Iterable, Optional, TypeVar, Union, overload +from urllib.parse import parse_qs, urljoin, urlparse + +from azure.core.exceptions import ( + ClientAuthenticationError, + HttpResponseError, + ResourceExistsError, + ResourceNotFoundError, + ResourceNotModifiedError, + map_error, +) from azure.core.paging import ItemPaged from azure.core.pipeline import PipelineResponse from azure.core.pipeline.transport import HttpResponse from azure.core.rest import HttpRequest from azure.core.tracing.decorator import distributed_trace +from azure.core.utils import case_insensitive_dict from azure.mgmt.core.exceptions import ARMErrorFormat from .. import models as _models +from ..._serialization import Serializer from .._vendor import _convert_request, _format_url_section -T = TypeVar('T') + +T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] -JSONType = Any _SERIALIZER = Serializer() _SERIALIZER.client_side_validation = False -def build_authorization_operations_list_request( - **kwargs: Any -) -> HttpRequest: - api_version = kwargs.pop('api_version', "2016-09-01") # type: str - accept = "application/json" +def build_authorization_operations_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", "2016-09-01")) # type: str + accept = _headers.pop("Accept", "application/json") + # Construct URL _url = kwargs.pop("template_url", "/providers/Microsoft.Authorization/operations") # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') - - return HttpRequest( - method="GET", - url=_url, - params=_query_parameters, - headers=_header_parameters, - **kwargs - ) + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) def build_management_locks_create_or_update_at_resource_group_level_request( - resource_group_name: str, - lock_name: str, - subscription_id: str, - *, - json: JSONType = None, - content: Any = None, - **kwargs: Any + resource_group_name: str, lock_name: str, subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2016-09-01") # type: str - content_type = kwargs.pop('content_type', None) # type: Optional[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", "2016-09-01")) # type: str + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + accept = _headers.pop("Accept", "application/json") - accept = "application/json" # Construct URL - _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Authorization/locks/{lockName}") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Authorization/locks/{lockName}", + ) # pylint: disable=line-too-long path_format_arguments = { - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._\(\)]+$'), - "lockName": _SERIALIZER.url("lock_name", lock_name, 'str'), - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), + "resourceGroupName": _SERIALIZER.url( + "resource_group_name", resource_group_name, "str", max_length=90, min_length=1, pattern=r"^[-\w\._\(\)]+$" + ), + "lockName": _SERIALIZER.url("lock_name", lock_name, "str"), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), } _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] if content_type is not None: - _header_parameters['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') - _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') - - return HttpRequest( - method="PUT", - url=_url, - params=_query_parameters, - headers=_header_parameters, - json=json, - content=content, - **kwargs - ) + _headers["Content-Type"] = _SERIALIZER.header("content_type", content_type, "str") + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="PUT", url=_url, params=_params, headers=_headers, **kwargs) def build_management_locks_delete_at_resource_group_level_request( - resource_group_name: str, - lock_name: str, - subscription_id: str, - **kwargs: Any + resource_group_name: str, lock_name: str, subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2016-09-01") # type: str + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + api_version = kwargs.pop("api_version", _params.pop("api-version", "2016-09-01")) # type: str # Construct URL - _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Authorization/locks/{lockName}") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Authorization/locks/{lockName}", + ) # pylint: disable=line-too-long path_format_arguments = { - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._\(\)]+$'), - "lockName": _SERIALIZER.url("lock_name", lock_name, 'str'), - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), + "resourceGroupName": _SERIALIZER.url( + "resource_group_name", resource_group_name, "str", max_length=90, min_length=1, pattern=r"^[-\w\._\(\)]+$" + ), + "lockName": _SERIALIZER.url("lock_name", lock_name, "str"), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), } _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') - - return HttpRequest( - method="DELETE", - url=_url, - params=_query_parameters, - **kwargs - ) + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") + + return HttpRequest(method="DELETE", url=_url, params=_params, **kwargs) def build_management_locks_get_at_resource_group_level_request( - resource_group_name: str, - lock_name: str, - subscription_id: str, - **kwargs: Any + resource_group_name: str, lock_name: str, subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2016-09-01") # type: 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", "2016-09-01")) # type: str + accept = _headers.pop("Accept", "application/json") - accept = "application/json" # Construct URL - _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Authorization/locks/{lockName}") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Authorization/locks/{lockName}", + ) # pylint: disable=line-too-long path_format_arguments = { - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._\(\)]+$'), - "lockName": _SERIALIZER.url("lock_name", lock_name, 'str'), - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), + "resourceGroupName": _SERIALIZER.url( + "resource_group_name", resource_group_name, "str", max_length=90, min_length=1, pattern=r"^[-\w\._\(\)]+$" + ), + "lockName": _SERIALIZER.url("lock_name", lock_name, "str"), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), } _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') - - return HttpRequest( - method="GET", - url=_url, - params=_query_parameters, - headers=_header_parameters, - **kwargs - ) + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) -def build_management_locks_create_or_update_by_scope_request( - scope: str, - lock_name: str, - *, - json: JSONType = None, - content: Any = None, - **kwargs: Any -) -> HttpRequest: - api_version = kwargs.pop('api_version', "2016-09-01") # type: str - content_type = kwargs.pop('content_type', None) # type: Optional[str] - accept = "application/json" +def build_management_locks_create_or_update_by_scope_request(scope: str, lock_name: 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", "2016-09-01")) # type: str + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + accept = _headers.pop("Accept", "application/json") + # Construct URL _url = kwargs.pop("template_url", "/{scope}/providers/Microsoft.Authorization/locks/{lockName}") path_format_arguments = { - "scope": _SERIALIZER.url("scope", scope, 'str'), - "lockName": _SERIALIZER.url("lock_name", lock_name, 'str'), + "scope": _SERIALIZER.url("scope", scope, "str"), + "lockName": _SERIALIZER.url("lock_name", lock_name, "str"), } _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] if content_type is not None: - _header_parameters['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') - _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') - - return HttpRequest( - method="PUT", - url=_url, - params=_query_parameters, - headers=_header_parameters, - json=json, - content=content, - **kwargs - ) + _headers["Content-Type"] = _SERIALIZER.header("content_type", content_type, "str") + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + return HttpRequest(method="PUT", url=_url, params=_params, headers=_headers, **kwargs) -def build_management_locks_delete_by_scope_request( - scope: str, - lock_name: str, - **kwargs: Any -) -> HttpRequest: - api_version = kwargs.pop('api_version', "2016-09-01") # type: str +def build_management_locks_delete_by_scope_request(scope: str, lock_name: str, **kwargs: Any) -> HttpRequest: + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2016-09-01")) # type: str # Construct URL _url = kwargs.pop("template_url", "/{scope}/providers/Microsoft.Authorization/locks/{lockName}") path_format_arguments = { - "scope": _SERIALIZER.url("scope", scope, 'str'), - "lockName": _SERIALIZER.url("lock_name", lock_name, 'str'), + "scope": _SERIALIZER.url("scope", scope, "str"), + "lockName": _SERIALIZER.url("lock_name", lock_name, "str"), } _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') - - return HttpRequest( - method="DELETE", - url=_url, - params=_query_parameters, - **kwargs - ) + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") + return HttpRequest(method="DELETE", url=_url, params=_params, **kwargs) -def build_management_locks_get_by_scope_request( - scope: str, - lock_name: str, - **kwargs: Any -) -> HttpRequest: - api_version = kwargs.pop('api_version', "2016-09-01") # type: str - accept = "application/json" +def build_management_locks_get_by_scope_request(scope: str, lock_name: 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", "2016-09-01")) # type: str + accept = _headers.pop("Accept", "application/json") + # Construct URL _url = kwargs.pop("template_url", "/{scope}/providers/Microsoft.Authorization/locks/{lockName}") path_format_arguments = { - "scope": _SERIALIZER.url("scope", scope, 'str'), - "lockName": _SERIALIZER.url("lock_name", lock_name, 'str'), + "scope": _SERIALIZER.url("scope", scope, "str"), + "lockName": _SERIALIZER.url("lock_name", lock_name, "str"), } _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') - - return HttpRequest( - method="GET", - url=_url, - params=_query_parameters, - headers=_header_parameters, - **kwargs - ) + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) def build_management_locks_create_or_update_at_resource_level_request( @@ -275,48 +231,43 @@ def build_management_locks_create_or_update_at_resource_level_request( resource_name: str, lock_name: str, subscription_id: str, - *, - json: JSONType = None, - content: Any = None, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2016-09-01") # type: str - content_type = kwargs.pop('content_type', None) # type: Optional[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", "2016-09-01")) # type: str + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + accept = _headers.pop("Accept", "application/json") - accept = "application/json" # Construct URL - _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{parentResourcePath}/{resourceType}/{resourceName}/providers/Microsoft.Authorization/locks/{lockName}") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{parentResourcePath}/{resourceType}/{resourceName}/providers/Microsoft.Authorization/locks/{lockName}", + ) # pylint: disable=line-too-long path_format_arguments = { - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._\(\)]+$'), - "resourceProviderNamespace": _SERIALIZER.url("resource_provider_namespace", resource_provider_namespace, 'str'), - "parentResourcePath": _SERIALIZER.url("parent_resource_path", parent_resource_path, 'str', skip_quote=True), - "resourceType": _SERIALIZER.url("resource_type", resource_type, 'str', skip_quote=True), - "resourceName": _SERIALIZER.url("resource_name", resource_name, 'str'), - "lockName": _SERIALIZER.url("lock_name", lock_name, 'str'), - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), + "resourceGroupName": _SERIALIZER.url( + "resource_group_name", resource_group_name, "str", max_length=90, min_length=1, pattern=r"^[-\w\._\(\)]+$" + ), + "resourceProviderNamespace": _SERIALIZER.url("resource_provider_namespace", resource_provider_namespace, "str"), + "parentResourcePath": _SERIALIZER.url("parent_resource_path", parent_resource_path, "str", skip_quote=True), + "resourceType": _SERIALIZER.url("resource_type", resource_type, "str", skip_quote=True), + "resourceName": _SERIALIZER.url("resource_name", resource_name, "str"), + "lockName": _SERIALIZER.url("lock_name", lock_name, "str"), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), } _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] if content_type is not None: - _header_parameters['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') - _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') - - return HttpRequest( - method="PUT", - url=_url, - params=_query_parameters, - headers=_header_parameters, - json=json, - content=content, - **kwargs - ) + _headers["Content-Type"] = _SERIALIZER.header("content_type", content_type, "str") + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="PUT", url=_url, params=_params, headers=_headers, **kwargs) def build_management_locks_delete_at_resource_level_request( @@ -329,32 +280,32 @@ def build_management_locks_delete_at_resource_level_request( subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2016-09-01") # type: str + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + api_version = kwargs.pop("api_version", _params.pop("api-version", "2016-09-01")) # type: str # Construct URL - _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{parentResourcePath}/{resourceType}/{resourceName}/providers/Microsoft.Authorization/locks/{lockName}") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{parentResourcePath}/{resourceType}/{resourceName}/providers/Microsoft.Authorization/locks/{lockName}", + ) # pylint: disable=line-too-long path_format_arguments = { - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._\(\)]+$'), - "resourceProviderNamespace": _SERIALIZER.url("resource_provider_namespace", resource_provider_namespace, 'str'), - "parentResourcePath": _SERIALIZER.url("parent_resource_path", parent_resource_path, 'str', skip_quote=True), - "resourceType": _SERIALIZER.url("resource_type", resource_type, 'str', skip_quote=True), - "resourceName": _SERIALIZER.url("resource_name", resource_name, 'str'), - "lockName": _SERIALIZER.url("lock_name", lock_name, 'str'), - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), + "resourceGroupName": _SERIALIZER.url( + "resource_group_name", resource_group_name, "str", max_length=90, min_length=1, pattern=r"^[-\w\._\(\)]+$" + ), + "resourceProviderNamespace": _SERIALIZER.url("resource_provider_namespace", resource_provider_namespace, "str"), + "parentResourcePath": _SERIALIZER.url("parent_resource_path", parent_resource_path, "str", skip_quote=True), + "resourceType": _SERIALIZER.url("resource_type", resource_type, "str", skip_quote=True), + "resourceName": _SERIALIZER.url("resource_name", resource_name, "str"), + "lockName": _SERIALIZER.url("lock_name", lock_name, "str"), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), } _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') - - return HttpRequest( - method="DELETE", - url=_url, - params=_query_parameters, - **kwargs - ) + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") + + return HttpRequest(method="DELETE", url=_url, params=_params, **kwargs) def build_management_locks_get_at_resource_level_request( @@ -367,180 +318,156 @@ def build_management_locks_get_at_resource_level_request( subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2016-09-01") # type: 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", "2016-09-01")) # type: str + accept = _headers.pop("Accept", "application/json") - accept = "application/json" # Construct URL - _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{parentResourcePath}/{resourceType}/{resourceName}/providers/Microsoft.Authorization/locks/{lockName}") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{parentResourcePath}/{resourceType}/{resourceName}/providers/Microsoft.Authorization/locks/{lockName}", + ) # pylint: disable=line-too-long path_format_arguments = { - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._\(\)]+$'), - "resourceProviderNamespace": _SERIALIZER.url("resource_provider_namespace", resource_provider_namespace, 'str'), - "parentResourcePath": _SERIALIZER.url("parent_resource_path", parent_resource_path, 'str', skip_quote=True), - "resourceType": _SERIALIZER.url("resource_type", resource_type, 'str', skip_quote=True), - "resourceName": _SERIALIZER.url("resource_name", resource_name, 'str'), - "lockName": _SERIALIZER.url("lock_name", lock_name, 'str'), - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), + "resourceGroupName": _SERIALIZER.url( + "resource_group_name", resource_group_name, "str", max_length=90, min_length=1, pattern=r"^[-\w\._\(\)]+$" + ), + "resourceProviderNamespace": _SERIALIZER.url("resource_provider_namespace", resource_provider_namespace, "str"), + "parentResourcePath": _SERIALIZER.url("parent_resource_path", parent_resource_path, "str", skip_quote=True), + "resourceType": _SERIALIZER.url("resource_type", resource_type, "str", skip_quote=True), + "resourceName": _SERIALIZER.url("resource_name", resource_name, "str"), + "lockName": _SERIALIZER.url("lock_name", lock_name, "str"), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), } _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') - - return HttpRequest( - method="GET", - url=_url, - params=_query_parameters, - headers=_header_parameters, - **kwargs - ) + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) def build_management_locks_create_or_update_at_subscription_level_request( - lock_name: str, - subscription_id: str, - *, - json: JSONType = None, - content: Any = None, - **kwargs: Any + lock_name: str, subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2016-09-01") # type: str - content_type = kwargs.pop('content_type', None) # type: Optional[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", "2016-09-01")) # type: str + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + accept = _headers.pop("Accept", "application/json") - accept = "application/json" # Construct URL - _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/providers/Microsoft.Authorization/locks/{lockName}") + _url = kwargs.pop( + "template_url", "/subscriptions/{subscriptionId}/providers/Microsoft.Authorization/locks/{lockName}" + ) path_format_arguments = { - "lockName": _SERIALIZER.url("lock_name", lock_name, 'str'), - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), + "lockName": _SERIALIZER.url("lock_name", lock_name, "str"), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), } _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] if content_type is not None: - _header_parameters['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') - _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') - - return HttpRequest( - method="PUT", - url=_url, - params=_query_parameters, - headers=_header_parameters, - json=json, - content=content, - **kwargs - ) + _headers["Content-Type"] = _SERIALIZER.header("content_type", content_type, "str") + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="PUT", url=_url, params=_params, headers=_headers, **kwargs) def build_management_locks_delete_at_subscription_level_request( - lock_name: str, - subscription_id: str, - **kwargs: Any + lock_name: str, subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2016-09-01") # type: str + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + api_version = kwargs.pop("api_version", _params.pop("api-version", "2016-09-01")) # type: str # Construct URL - _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/providers/Microsoft.Authorization/locks/{lockName}") + _url = kwargs.pop( + "template_url", "/subscriptions/{subscriptionId}/providers/Microsoft.Authorization/locks/{lockName}" + ) path_format_arguments = { - "lockName": _SERIALIZER.url("lock_name", lock_name, 'str'), - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), + "lockName": _SERIALIZER.url("lock_name", lock_name, "str"), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), } _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') - - return HttpRequest( - method="DELETE", - url=_url, - params=_query_parameters, - **kwargs - ) + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") + + return HttpRequest(method="DELETE", url=_url, params=_params, **kwargs) def build_management_locks_get_at_subscription_level_request( - lock_name: str, - subscription_id: str, - **kwargs: Any + lock_name: str, subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2016-09-01") # type: 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", "2016-09-01")) # type: str + accept = _headers.pop("Accept", "application/json") - accept = "application/json" # Construct URL - _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/providers/Microsoft.Authorization/locks/{lockName}") + _url = kwargs.pop( + "template_url", "/subscriptions/{subscriptionId}/providers/Microsoft.Authorization/locks/{lockName}" + ) path_format_arguments = { - "lockName": _SERIALIZER.url("lock_name", lock_name, 'str'), - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), + "lockName": _SERIALIZER.url("lock_name", lock_name, "str"), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), } _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') - - return HttpRequest( - method="GET", - url=_url, - params=_query_parameters, - headers=_header_parameters, - **kwargs - ) + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) def build_management_locks_list_at_resource_group_level_request( - resource_group_name: str, - subscription_id: str, - *, - filter: Optional[str] = None, - **kwargs: Any + resource_group_name: str, subscription_id: str, *, filter: Optional[str] = None, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2016-09-01") # type: 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", "2016-09-01")) # type: str + accept = _headers.pop("Accept", "application/json") - accept = "application/json" # Construct URL - _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Authorization/locks") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Authorization/locks", + ) # pylint: disable=line-too-long path_format_arguments = { - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._\(\)]+$'), - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), + "resourceGroupName": _SERIALIZER.url( + "resource_group_name", resource_group_name, "str", max_length=90, min_length=1, pattern=r"^[-\w\._\(\)]+$" + ), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), } _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] if filter is not None: - _query_parameters['$filter'] = _SERIALIZER.query("filter", filter, 'str') - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["$filter"] = _SERIALIZER.query("filter", filter, "str") + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') - - return HttpRequest( - method="GET", - url=_url, - params=_query_parameters, - headers=_header_parameters, - **kwargs - ) + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) def build_management_locks_list_at_resource_level_request( @@ -554,171 +481,159 @@ def build_management_locks_list_at_resource_level_request( filter: Optional[str] = None, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2016-09-01") # type: 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", "2016-09-01")) # type: str + accept = _headers.pop("Accept", "application/json") - accept = "application/json" # Construct URL - _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{parentResourcePath}/{resourceType}/{resourceName}/providers/Microsoft.Authorization/locks") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{parentResourcePath}/{resourceType}/{resourceName}/providers/Microsoft.Authorization/locks", + ) # pylint: disable=line-too-long path_format_arguments = { - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._\(\)]+$'), - "resourceProviderNamespace": _SERIALIZER.url("resource_provider_namespace", resource_provider_namespace, 'str'), - "parentResourcePath": _SERIALIZER.url("parent_resource_path", parent_resource_path, 'str', skip_quote=True), - "resourceType": _SERIALIZER.url("resource_type", resource_type, 'str', skip_quote=True), - "resourceName": _SERIALIZER.url("resource_name", resource_name, 'str'), - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), + "resourceGroupName": _SERIALIZER.url( + "resource_group_name", resource_group_name, "str", max_length=90, min_length=1, pattern=r"^[-\w\._\(\)]+$" + ), + "resourceProviderNamespace": _SERIALIZER.url("resource_provider_namespace", resource_provider_namespace, "str"), + "parentResourcePath": _SERIALIZER.url("parent_resource_path", parent_resource_path, "str", skip_quote=True), + "resourceType": _SERIALIZER.url("resource_type", resource_type, "str", skip_quote=True), + "resourceName": _SERIALIZER.url("resource_name", resource_name, "str"), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), } _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] if filter is not None: - _query_parameters['$filter'] = _SERIALIZER.query("filter", filter, 'str') - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["$filter"] = _SERIALIZER.query("filter", filter, "str") + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') - - return HttpRequest( - method="GET", - url=_url, - params=_query_parameters, - headers=_header_parameters, - **kwargs - ) + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) def build_management_locks_list_at_subscription_level_request( - subscription_id: str, - *, - filter: Optional[str] = None, - **kwargs: Any + subscription_id: str, *, filter: Optional[str] = None, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2016-09-01") # type: 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", "2016-09-01")) # type: str + accept = _headers.pop("Accept", "application/json") - accept = "application/json" # Construct URL _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/providers/Microsoft.Authorization/locks") path_format_arguments = { - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), } _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] if filter is not None: - _query_parameters['$filter'] = _SERIALIZER.query("filter", filter, 'str') - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["$filter"] = _SERIALIZER.query("filter", filter, "str") + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') - - return HttpRequest( - method="GET", - url=_url, - params=_query_parameters, - headers=_header_parameters, - **kwargs - ) + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) def build_management_locks_list_by_scope_request( - scope: str, - *, - filter: Optional[str] = None, - **kwargs: Any + scope: str, *, filter: Optional[str] = None, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2016-09-01") # type: 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", "2016-09-01")) # type: str + accept = _headers.pop("Accept", "application/json") - accept = "application/json" # Construct URL _url = kwargs.pop("template_url", "/{scope}/providers/Microsoft.Authorization/locks") path_format_arguments = { - "scope": _SERIALIZER.url("scope", scope, 'str'), + "scope": _SERIALIZER.url("scope", scope, "str"), } _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] if filter is not None: - _query_parameters['$filter'] = _SERIALIZER.query("filter", filter, 'str') - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["$filter"] = _SERIALIZER.query("filter", filter, "str") + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') - - return HttpRequest( - method="GET", - url=_url, - params=_query_parameters, - headers=_header_parameters, - **kwargs - ) + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) -class AuthorizationOperationsOperations(object): - """AuthorizationOperationsOperations operations. - You should not instantiate this class directly. Instead, you should create a Client instance that - instantiates it for you and attaches it as an attribute. +class AuthorizationOperationsOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. - :ivar models: Alias to model classes used in this operation group. - :type models: ~azure.mgmt.resource.locks.v2016_09_01.models - :param client: Client for service requests. - :param config: Configuration of service client. - :param serializer: An object model serializer. - :param deserializer: An object model deserializer. + Instead, you should access the following operations through + :class:`~azure.mgmt.resource.locks.v2016_09_01.ManagementLockClient`'s + :attr:`authorization_operations` attribute. """ models = _models - def __init__(self, client, config, serializer, deserializer): - self._client = client - self._serialize = serializer - self._deserialize = deserializer - self._config = config + def __init__(self, *args, **kwargs): + input_args = list(args) + self._client = input_args.pop(0) if input_args else kwargs.pop("client") + self._config = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") @distributed_trace - def list( - self, - **kwargs: Any - ) -> Iterable["_models.OperationListResult"]: + def list(self, **kwargs: Any) -> Iterable["_models.Operation"]: """Lists all of the available Microsoft.Authorization REST API operations. :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either OperationListResult or the result of cls(response) - :rtype: - ~azure.core.paging.ItemPaged[~azure.mgmt.resource.locks.v2016_09_01.models.OperationListResult] - :raises: ~azure.core.exceptions.HttpResponseError + :return: An iterator like instance of either Operation or the result of cls(response) + :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.resource.locks.v2016_09_01.models.Operation] + :raises ~azure.core.exceptions.HttpResponseError: """ - api_version = kwargs.pop('api_version', "2016-09-01") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2016-09-01")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[_models.OperationListResult] - cls = kwargs.pop('cls', None) # type: ClsType["_models.OperationListResult"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) + def prepare_request(next_link=None): if not next_link: - + request = build_authorization_operations_list_request( api_version=api_version, - template_url=self.list.metadata['url'], + template_url=self.list.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore else: - - request = build_authorization_operations_list_request( - template_url=next_link, - ) + # make call to next link with the client's api-version + _parsed_next_link = urlparse(next_link) + _next_request_params = case_insensitive_dict(parse_qs(_parsed_next_link.query)) + _next_request_params["api-version"] = self._config.api_version + request = HttpRequest("GET", urljoin(next_link, _parsed_next_link.path), params=_next_request_params) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore request.method = "GET" return request @@ -732,10 +647,8 @@ def extract_data(pipeline_response): def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) response = pipeline_response.http_response @@ -745,41 +658,40 @@ def get_next(next_link=None): return pipeline_response + return ItemPaged(get_next, extract_data) - return ItemPaged( - get_next, extract_data - ) - list.metadata = {'url': "/providers/Microsoft.Authorization/operations"} # type: ignore -class ManagementLocksOperations(object): - """ManagementLocksOperations operations. - - You should not instantiate this class directly. Instead, you should create a Client instance that - instantiates it for you and attaches it as an attribute. - - :ivar models: Alias to model classes used in this operation group. - :type models: ~azure.mgmt.resource.locks.v2016_09_01.models - :param client: Client for service requests. - :param config: Configuration of service client. - :param serializer: An object model serializer. - :param deserializer: An object model deserializer. + list.metadata = {"url": "/providers/Microsoft.Authorization/operations"} # type: ignore + + +class ManagementLocksOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. + + Instead, you should access the following operations through + :class:`~azure.mgmt.resource.locks.v2016_09_01.ManagementLockClient`'s + :attr:`management_locks` attribute. """ models = _models - def __init__(self, client, config, serializer, deserializer): - self._client = client - self._serialize = serializer - self._deserialize = deserializer - self._config = config + def __init__(self, *args, **kwargs): + input_args = list(args) + self._client = input_args.pop(0) if input_args else kwargs.pop("client") + self._config = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") - @distributed_trace + @overload def create_or_update_at_resource_group_level( self, resource_group_name: str, lock_name: str, - parameters: "_models.ManagementLockObject", + parameters: _models.ManagementLockObject, + *, + content_type: str = "application/json", **kwargs: Any - ) -> "_models.ManagementLockObject": + ) -> _models.ManagementLockObject: """Creates or updates a management lock at the resource group level. When you apply a lock at a parent scope, all child resources inherit the same lock. To create @@ -787,28 +699,108 @@ def create_or_update_at_resource_group_level( Microsoft.Authorization/locks/* actions. Of the built-in roles, only Owner and User Access Administrator are granted those actions. - :param resource_group_name: The name of the resource group to lock. + :param resource_group_name: The name of the resource group to lock. Required. :type resource_group_name: str :param lock_name: The lock name. The lock name can be a maximum of 260 characters. It cannot - contain <, > %, &, :, \, ?, /, or any control characters. + contain <, > %, &, :, \, ?, /, or any control characters. Required. :type lock_name: str - :param parameters: The management lock parameters. + :param parameters: The management lock parameters. Required. :type parameters: ~azure.mgmt.resource.locks.v2016_09_01.models.ManagementLockObject + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: ManagementLockObject or the result of cls(response) + :rtype: ~azure.mgmt.resource.locks.v2016_09_01.models.ManagementLockObject + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + def create_or_update_at_resource_group_level( + self, + resource_group_name: str, + lock_name: str, + parameters: IO, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.ManagementLockObject: + """Creates or updates a management lock at the resource group level. + + When you apply a lock at a parent scope, all child resources inherit the same lock. To create + management locks, you must have access to Microsoft.Authorization/\ * or + Microsoft.Authorization/locks/* actions. Of the built-in roles, only Owner and User Access + Administrator are granted those actions. + + :param resource_group_name: The name of the resource group to lock. Required. + :type resource_group_name: str + :param lock_name: The lock name. The lock name can be a maximum of 260 characters. It cannot + contain <, > %, &, :, \, ?, /, or any control characters. Required. + :type lock_name: str + :param parameters: The management lock parameters. Required. + :type parameters: IO + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: ManagementLockObject or the result of cls(response) + :rtype: ~azure.mgmt.resource.locks.v2016_09_01.models.ManagementLockObject + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace + def create_or_update_at_resource_group_level( + self, + resource_group_name: str, + lock_name: str, + parameters: Union[_models.ManagementLockObject, IO], + **kwargs: Any + ) -> _models.ManagementLockObject: + """Creates or updates a management lock at the resource group level. + + When you apply a lock at a parent scope, all child resources inherit the same lock. To create + management locks, you must have access to Microsoft.Authorization/\ * or + Microsoft.Authorization/locks/* actions. Of the built-in roles, only Owner and User Access + Administrator are granted those actions. + + :param resource_group_name: The name of the resource group to lock. Required. + :type resource_group_name: str + :param lock_name: The lock name. The lock name can be a maximum of 260 characters. It cannot + contain <, > %, &, :, \, ?, /, or any control characters. Required. + :type lock_name: str + :param parameters: The management lock parameters. Is either a model type or a IO type. + Required. + :type parameters: ~azure.mgmt.resource.locks.v2016_09_01.models.ManagementLockObject or IO + :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. + Default value is None. + :paramtype content_type: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: ManagementLockObject, or the result of cls(response) + :return: ManagementLockObject or the result of cls(response) :rtype: ~azure.mgmt.resource.locks.v2016_09_01.models.ManagementLockObject - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.ManagementLockObject"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) - api_version = kwargs.pop('api_version', "2016-09-01") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - _json = self._serialize.body(parameters, 'ManagementLockObject') + api_version = kwargs.pop("api_version", _params.pop("api-version", "2016-09-01")) # type: str + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.ManagementLockObject] + + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(parameters, (IO, bytes)): + _content = parameters + else: + _json = self._serialize.body(parameters, "ManagementLockObject") request = build_management_locks_create_or_update_at_resource_group_level_request( resource_group_name=resource_group_name, @@ -817,16 +809,18 @@ def create_or_update_at_resource_group_level( api_version=api_version, content_type=content_type, json=_json, - template_url=self.create_or_update_at_resource_group_level.metadata['url'], + content=_content, + template_url=self.create_or_update_at_resource_group_level.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200, 201]: @@ -834,25 +828,21 @@ def create_or_update_at_resource_group_level( raise HttpResponseError(response=response, error_format=ARMErrorFormat) if response.status_code == 200: - deserialized = self._deserialize('ManagementLockObject', pipeline_response) + deserialized = self._deserialize("ManagementLockObject", pipeline_response) if response.status_code == 201: - deserialized = self._deserialize('ManagementLockObject', pipeline_response) + deserialized = self._deserialize("ManagementLockObject", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - create_or_update_at_resource_group_level.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Authorization/locks/{lockName}"} # type: ignore - + create_or_update_at_resource_group_level.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Authorization/locks/{lockName}"} # type: ignore @distributed_trace def delete_at_resource_group_level( # pylint: disable=inconsistent-return-statements - self, - resource_group_name: str, - lock_name: str, - **kwargs: Any + self, resource_group_name: str, lock_name: str, **kwargs: Any ) -> None: """Deletes a management lock at the resource group level. @@ -860,39 +850,45 @@ def delete_at_resource_group_level( # pylint: disable=inconsistent-return-state Microsoft.Authorization/locks/* actions. Of the built-in roles, only Owner and User Access Administrator are granted those actions. - :param resource_group_name: The name of the resource group containing the lock. + :param resource_group_name: The name of the resource group containing the lock. Required. :type resource_group_name: str - :param lock_name: The name of lock to delete. + :param lock_name: The name of lock to delete. Required. :type lock_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: None, or the result of cls(response) + :return: None or the result of cls(response) :rtype: None - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType[None] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + 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', "2016-09-01") # type: str + api_version = kwargs.pop("api_version", _params.pop("api-version", "2016-09-01")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[None] - request = build_management_locks_delete_at_resource_group_level_request( resource_group_name=resource_group_name, lock_name=lock_name, subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.delete_at_resource_group_level.metadata['url'], + template_url=self.delete_at_resource_group_level.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200, 204]: @@ -902,102 +898,171 @@ def delete_at_resource_group_level( # pylint: disable=inconsistent-return-state if cls: return cls(pipeline_response, None, {}) - delete_at_resource_group_level.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Authorization/locks/{lockName}"} # type: ignore - + delete_at_resource_group_level.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Authorization/locks/{lockName}"} # type: ignore @distributed_trace def get_at_resource_group_level( - self, - resource_group_name: str, - lock_name: str, - **kwargs: Any - ) -> "_models.ManagementLockObject": + self, resource_group_name: str, lock_name: str, **kwargs: Any + ) -> _models.ManagementLockObject: """Gets a management lock at the resource group level. - :param resource_group_name: The name of the locked resource group. + :param resource_group_name: The name of the locked resource group. Required. :type resource_group_name: str - :param lock_name: The name of the lock to get. + :param lock_name: The name of the lock to get. Required. :type lock_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: ManagementLockObject, or the result of cls(response) + :return: ManagementLockObject or the result of cls(response) :rtype: ~azure.mgmt.resource.locks.v2016_09_01.models.ManagementLockObject - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.ManagementLockObject"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + 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', "2016-09-01") # type: str + api_version = kwargs.pop("api_version", _params.pop("api-version", "2016-09-01")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[_models.ManagementLockObject] - request = build_management_locks_get_at_resource_group_level_request( resource_group_name=resource_group_name, lock_name=lock_name, subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.get_at_resource_group_level.metadata['url'], + template_url=self.get_at_resource_group_level.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) - deserialized = self._deserialize('ManagementLockObject', pipeline_response) + deserialized = self._deserialize("ManagementLockObject", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - get_at_resource_group_level.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Authorization/locks/{lockName}"} # type: ignore - + get_at_resource_group_level.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Authorization/locks/{lockName}"} # type: ignore - @distributed_trace + @overload def create_or_update_by_scope( self, scope: str, lock_name: str, - parameters: "_models.ManagementLockObject", + parameters: _models.ManagementLockObject, + *, + content_type: str = "application/json", **kwargs: Any - ) -> "_models.ManagementLockObject": + ) -> _models.ManagementLockObject: """Create or update a management lock by scope. :param scope: The scope for the lock. When providing a scope for the assignment, use '/subscriptions/{subscriptionId}' for subscriptions, '/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}' for resource groups, and '/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{parentResourcePathIfPresent}/{resourceType}/{resourceName}' - for resources. + for resources. Required. :type scope: str - :param lock_name: The name of lock. + :param lock_name: The name of lock. Required. :type lock_name: str - :param parameters: Create or update management lock parameters. + :param parameters: Create or update management lock parameters. Required. :type parameters: ~azure.mgmt.resource.locks.v2016_09_01.models.ManagementLockObject + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: ManagementLockObject or the result of cls(response) + :rtype: ~azure.mgmt.resource.locks.v2016_09_01.models.ManagementLockObject + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + def create_or_update_by_scope( + self, scope: str, lock_name: str, parameters: IO, *, content_type: str = "application/json", **kwargs: Any + ) -> _models.ManagementLockObject: + """Create or update a management lock by scope. + + :param scope: The scope for the lock. When providing a scope for the assignment, use + '/subscriptions/{subscriptionId}' for subscriptions, + '/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}' for resource groups, and + '/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{parentResourcePathIfPresent}/{resourceType}/{resourceName}' + for resources. Required. + :type scope: str + :param lock_name: The name of lock. Required. + :type lock_name: str + :param parameters: Create or update management lock parameters. Required. + :type parameters: IO + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: ManagementLockObject, or the result of cls(response) + :return: ManagementLockObject or the result of cls(response) :rtype: ~azure.mgmt.resource.locks.v2016_09_01.models.ManagementLockObject - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace + def create_or_update_by_scope( + self, scope: str, lock_name: str, parameters: Union[_models.ManagementLockObject, IO], **kwargs: Any + ) -> _models.ManagementLockObject: + """Create or update a management lock by scope. + + :param scope: The scope for the lock. When providing a scope for the assignment, use + '/subscriptions/{subscriptionId}' for subscriptions, + '/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}' for resource groups, and + '/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{parentResourcePathIfPresent}/{resourceType}/{resourceName}' + for resources. Required. + :type scope: str + :param lock_name: The name of lock. Required. + :type lock_name: str + :param parameters: Create or update management lock parameters. Is either a model type or a IO + type. Required. + :type parameters: ~azure.mgmt.resource.locks.v2016_09_01.models.ManagementLockObject or IO + :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. + Default value is None. + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: ManagementLockObject or the result of cls(response) + :rtype: ~azure.mgmt.resource.locks.v2016_09_01.models.ManagementLockObject + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.ManagementLockObject"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) - api_version = kwargs.pop('api_version', "2016-09-01") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - _json = self._serialize.body(parameters, 'ManagementLockObject') + api_version = kwargs.pop("api_version", _params.pop("api-version", "2016-09-01")) # type: str + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.ManagementLockObject] + + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(parameters, (IO, bytes)): + _content = parameters + else: + _json = self._serialize.body(parameters, "ManagementLockObject") request = build_management_locks_create_or_update_by_scope_request( scope=scope, @@ -1005,16 +1070,18 @@ def create_or_update_by_scope( api_version=api_version, content_type=content_type, json=_json, - template_url=self.create_or_update_by_scope.metadata['url'], + content=_content, + template_url=self.create_or_update_by_scope.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200, 201]: @@ -1022,60 +1089,62 @@ def create_or_update_by_scope( raise HttpResponseError(response=response, error_format=ARMErrorFormat) if response.status_code == 200: - deserialized = self._deserialize('ManagementLockObject', pipeline_response) + deserialized = self._deserialize("ManagementLockObject", pipeline_response) if response.status_code == 201: - deserialized = self._deserialize('ManagementLockObject', pipeline_response) + deserialized = self._deserialize("ManagementLockObject", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - create_or_update_by_scope.metadata = {'url': "/{scope}/providers/Microsoft.Authorization/locks/{lockName}"} # type: ignore - + create_or_update_by_scope.metadata = {"url": "/{scope}/providers/Microsoft.Authorization/locks/{lockName}"} # type: ignore @distributed_trace def delete_by_scope( # pylint: disable=inconsistent-return-statements - self, - scope: str, - lock_name: str, - **kwargs: Any + self, scope: str, lock_name: str, **kwargs: Any ) -> None: """Delete a management lock by scope. - :param scope: The scope for the lock. + :param scope: The scope for the lock. Required. :type scope: str - :param lock_name: The name of lock. + :param lock_name: The name of lock. Required. :type lock_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: None, or the result of cls(response) + :return: None or the result of cls(response) :rtype: None - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType[None] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + 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', "2016-09-01") # type: str + api_version = kwargs.pop("api_version", _params.pop("api-version", "2016-09-01")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[None] - request = build_management_locks_delete_by_scope_request( scope=scope, lock_name=lock_name, api_version=api_version, - template_url=self.delete_by_scope.metadata['url'], + template_url=self.delete_by_scope.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200, 204]: @@ -1085,65 +1154,158 @@ def delete_by_scope( # pylint: disable=inconsistent-return-statements if cls: return cls(pipeline_response, None, {}) - delete_by_scope.metadata = {'url': "/{scope}/providers/Microsoft.Authorization/locks/{lockName}"} # type: ignore - + delete_by_scope.metadata = {"url": "/{scope}/providers/Microsoft.Authorization/locks/{lockName}"} # type: ignore @distributed_trace - def get_by_scope( - self, - scope: str, - lock_name: str, - **kwargs: Any - ) -> "_models.ManagementLockObject": + def get_by_scope(self, scope: str, lock_name: str, **kwargs: Any) -> _models.ManagementLockObject: """Get a management lock by scope. - :param scope: The scope for the lock. + :param scope: The scope for the lock. Required. :type scope: str - :param lock_name: The name of lock. + :param lock_name: The name of lock. Required. :type lock_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: ManagementLockObject, or the result of cls(response) + :return: ManagementLockObject or the result of cls(response) :rtype: ~azure.mgmt.resource.locks.v2016_09_01.models.ManagementLockObject - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.ManagementLockObject"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + 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', "2016-09-01") # type: str + api_version = kwargs.pop("api_version", _params.pop("api-version", "2016-09-01")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[_models.ManagementLockObject] - request = build_management_locks_get_by_scope_request( scope=scope, lock_name=lock_name, api_version=api_version, - template_url=self.get_by_scope.metadata['url'], + template_url=self.get_by_scope.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) - deserialized = self._deserialize('ManagementLockObject', pipeline_response) + deserialized = self._deserialize("ManagementLockObject", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - get_by_scope.metadata = {'url': "/{scope}/providers/Microsoft.Authorization/locks/{lockName}"} # type: ignore + get_by_scope.metadata = {"url": "/{scope}/providers/Microsoft.Authorization/locks/{lockName}"} # type: ignore + + @overload + def create_or_update_at_resource_level( + self, + resource_group_name: str, + resource_provider_namespace: str, + parent_resource_path: str, + resource_type: str, + resource_name: str, + lock_name: str, + parameters: _models.ManagementLockObject, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.ManagementLockObject: + """Creates or updates a management lock at the resource level or any level below the resource. + + When you apply a lock at a parent scope, all child resources inherit the same lock. To create + management locks, you must have access to Microsoft.Authorization/\ * or + Microsoft.Authorization/locks/* actions. Of the built-in roles, only Owner and User Access + Administrator are granted those actions. + + :param resource_group_name: The name of the resource group containing the resource to lock. + Required. + :type resource_group_name: str + :param resource_provider_namespace: The resource provider namespace of the resource to lock. + Required. + :type resource_provider_namespace: str + :param parent_resource_path: The parent resource identity. Required. + :type parent_resource_path: str + :param resource_type: The resource type of the resource to lock. Required. + :type resource_type: str + :param resource_name: The name of the resource to lock. Required. + :type resource_name: str + :param lock_name: The name of lock. The lock name can be a maximum of 260 characters. It cannot + contain <, > %, &, :, \, ?, /, or any control characters. Required. + :type lock_name: str + :param parameters: Parameters for creating or updating a management lock. Required. + :type parameters: ~azure.mgmt.resource.locks.v2016_09_01.models.ManagementLockObject + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: ManagementLockObject or the result of cls(response) + :rtype: ~azure.mgmt.resource.locks.v2016_09_01.models.ManagementLockObject + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + def create_or_update_at_resource_level( + self, + resource_group_name: str, + resource_provider_namespace: str, + parent_resource_path: str, + resource_type: str, + resource_name: str, + lock_name: str, + parameters: IO, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.ManagementLockObject: + """Creates or updates a management lock at the resource level or any level below the resource. + + When you apply a lock at a parent scope, all child resources inherit the same lock. To create + management locks, you must have access to Microsoft.Authorization/\ * or + Microsoft.Authorization/locks/* actions. Of the built-in roles, only Owner and User Access + Administrator are granted those actions. + :param resource_group_name: The name of the resource group containing the resource to lock. + Required. + :type resource_group_name: str + :param resource_provider_namespace: The resource provider namespace of the resource to lock. + Required. + :type resource_provider_namespace: str + :param parent_resource_path: The parent resource identity. Required. + :type parent_resource_path: str + :param resource_type: The resource type of the resource to lock. Required. + :type resource_type: str + :param resource_name: The name of the resource to lock. Required. + :type resource_name: str + :param lock_name: The name of lock. The lock name can be a maximum of 260 characters. It cannot + contain <, > %, &, :, \, ?, /, or any control characters. Required. + :type lock_name: str + :param parameters: Parameters for creating or updating a management lock. Required. + :type parameters: IO + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: ManagementLockObject or the result of cls(response) + :rtype: ~azure.mgmt.resource.locks.v2016_09_01.models.ManagementLockObject + :raises ~azure.core.exceptions.HttpResponseError: + """ @distributed_trace def create_or_update_at_resource_level( @@ -1154,9 +1316,9 @@ def create_or_update_at_resource_level( resource_type: str, resource_name: str, lock_name: str, - parameters: "_models.ManagementLockObject", + parameters: Union[_models.ManagementLockObject, IO], **kwargs: Any - ) -> "_models.ManagementLockObject": + ) -> _models.ManagementLockObject: """Creates or updates a management lock at the resource level or any level below the resource. When you apply a lock at a parent scope, all child resources inherit the same lock. To create @@ -1165,35 +1327,53 @@ def create_or_update_at_resource_level( Administrator are granted those actions. :param resource_group_name: The name of the resource group containing the resource to lock. + Required. :type resource_group_name: str :param resource_provider_namespace: The resource provider namespace of the resource to lock. + Required. :type resource_provider_namespace: str - :param parent_resource_path: The parent resource identity. + :param parent_resource_path: The parent resource identity. Required. :type parent_resource_path: str - :param resource_type: The resource type of the resource to lock. + :param resource_type: The resource type of the resource to lock. Required. :type resource_type: str - :param resource_name: The name of the resource to lock. + :param resource_name: The name of the resource to lock. Required. :type resource_name: str :param lock_name: The name of lock. The lock name can be a maximum of 260 characters. It cannot - contain <, > %, &, :, \, ?, /, or any control characters. + contain <, > %, &, :, \, ?, /, or any control characters. Required. :type lock_name: str - :param parameters: Parameters for creating or updating a management lock. - :type parameters: ~azure.mgmt.resource.locks.v2016_09_01.models.ManagementLockObject + :param parameters: Parameters for creating or updating a management lock. Is either a model + type or a IO type. Required. + :type parameters: ~azure.mgmt.resource.locks.v2016_09_01.models.ManagementLockObject or IO + :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. + Default value is None. + :paramtype content_type: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: ManagementLockObject, or the result of cls(response) + :return: ManagementLockObject or the result of cls(response) :rtype: ~azure.mgmt.resource.locks.v2016_09_01.models.ManagementLockObject - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.ManagementLockObject"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) - api_version = kwargs.pop('api_version', "2016-09-01") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - _json = self._serialize.body(parameters, 'ManagementLockObject') + api_version = kwargs.pop("api_version", _params.pop("api-version", "2016-09-01")) # type: str + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.ManagementLockObject] + + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(parameters, (IO, bytes)): + _content = parameters + else: + _json = self._serialize.body(parameters, "ManagementLockObject") request = build_management_locks_create_or_update_at_resource_level_request( resource_group_name=resource_group_name, @@ -1206,16 +1386,18 @@ def create_or_update_at_resource_level( api_version=api_version, content_type=content_type, json=_json, - template_url=self.create_or_update_at_resource_level.metadata['url'], + content=_content, + template_url=self.create_or_update_at_resource_level.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200, 201]: @@ -1223,18 +1405,17 @@ def create_or_update_at_resource_level( raise HttpResponseError(response=response, error_format=ARMErrorFormat) if response.status_code == 200: - deserialized = self._deserialize('ManagementLockObject', pipeline_response) + deserialized = self._deserialize("ManagementLockObject", pipeline_response) if response.status_code == 201: - deserialized = self._deserialize('ManagementLockObject', pipeline_response) + deserialized = self._deserialize("ManagementLockObject", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - create_or_update_at_resource_level.metadata = {'url': "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{parentResourcePath}/{resourceType}/{resourceName}/providers/Microsoft.Authorization/locks/{lockName}"} # type: ignore - + create_or_update_at_resource_level.metadata = {"url": "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{parentResourcePath}/{resourceType}/{resourceName}/providers/Microsoft.Authorization/locks/{lockName}"} # type: ignore @distributed_trace def delete_at_resource_level( # pylint: disable=inconsistent-return-statements @@ -1254,33 +1435,38 @@ def delete_at_resource_level( # pylint: disable=inconsistent-return-statements Administrator are granted those actions. :param resource_group_name: The name of the resource group containing the resource with the - lock to delete. + lock to delete. Required. :type resource_group_name: str :param resource_provider_namespace: The resource provider namespace of the resource with the - lock to delete. + lock to delete. Required. :type resource_provider_namespace: str - :param parent_resource_path: The parent resource identity. + :param parent_resource_path: The parent resource identity. Required. :type parent_resource_path: str - :param resource_type: The resource type of the resource with the lock to delete. + :param resource_type: The resource type of the resource with the lock to delete. Required. :type resource_type: str - :param resource_name: The name of the resource with the lock to delete. + :param resource_name: The name of the resource with the lock to delete. Required. :type resource_name: str - :param lock_name: The name of the lock to delete. + :param lock_name: The name of the lock to delete. Required. :type lock_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: None, or the result of cls(response) + :return: None or the result of cls(response) :rtype: None - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType[None] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) - api_version = kwargs.pop('api_version', "2016-09-01") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2016-09-01")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[None] - request = build_management_locks_delete_at_resource_level_request( resource_group_name=resource_group_name, resource_provider_namespace=resource_provider_namespace, @@ -1290,16 +1476,17 @@ def delete_at_resource_level( # pylint: disable=inconsistent-return-statements lock_name=lock_name, subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.delete_at_resource_level.metadata['url'], + template_url=self.delete_at_resource_level.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200, 204]: @@ -1309,8 +1496,7 @@ def delete_at_resource_level( # pylint: disable=inconsistent-return-statements if cls: return cls(pipeline_response, None, {}) - delete_at_resource_level.metadata = {'url': "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{parentResourcePath}/{resourceType}/{resourceName}/providers/Microsoft.Authorization/locks/{lockName}"} # type: ignore - + delete_at_resource_level.metadata = {"url": "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{parentResourcePath}/{resourceType}/{resourceName}/providers/Microsoft.Authorization/locks/{lockName}"} # type: ignore @distributed_trace def get_at_resource_level( @@ -1322,36 +1508,41 @@ def get_at_resource_level( resource_name: str, lock_name: str, **kwargs: Any - ) -> "_models.ManagementLockObject": + ) -> _models.ManagementLockObject: """Get the management lock of a resource or any level below resource. - :param resource_group_name: The name of the resource group. + :param resource_group_name: The name of the resource group. Required. :type resource_group_name: str - :param resource_provider_namespace: The namespace of the resource provider. + :param resource_provider_namespace: The namespace of the resource provider. Required. :type resource_provider_namespace: str :param parent_resource_path: An extra path parameter needed in some services, like SQL - Databases. + Databases. Required. :type parent_resource_path: str - :param resource_type: The type of the resource. + :param resource_type: The type of the resource. Required. :type resource_type: str - :param resource_name: The name of the resource. + :param resource_name: The name of the resource. Required. :type resource_name: str - :param lock_name: The name of lock. + :param lock_name: The name of lock. Required. :type lock_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: ManagementLockObject, or the result of cls(response) + :return: ManagementLockObject or the result of cls(response) :rtype: ~azure.mgmt.resource.locks.v2016_09_01.models.ManagementLockObject - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.ManagementLockObject"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) - api_version = kwargs.pop('api_version', "2016-09-01") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2016-09-01")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[_models.ManagementLockObject] - request = build_management_locks_get_at_resource_level_request( resource_group_name=resource_group_name, resource_provider_namespace=resource_provider_namespace, @@ -1361,39 +1552,41 @@ def get_at_resource_level( lock_name=lock_name, subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.get_at_resource_level.metadata['url'], + template_url=self.get_at_resource_level.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) - deserialized = self._deserialize('ManagementLockObject', pipeline_response) + deserialized = self._deserialize("ManagementLockObject", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - get_at_resource_level.metadata = {'url': "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{parentResourcePath}/{resourceType}/{resourceName}/providers/Microsoft.Authorization/locks/{lockName}"} # type: ignore - + get_at_resource_level.metadata = {"url": "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{parentResourcePath}/{resourceType}/{resourceName}/providers/Microsoft.Authorization/locks/{lockName}"} # type: ignore - @distributed_trace + @overload def create_or_update_at_subscription_level( self, lock_name: str, - parameters: "_models.ManagementLockObject", + parameters: _models.ManagementLockObject, + *, + content_type: str = "application/json", **kwargs: Any - ) -> "_models.ManagementLockObject": + ) -> _models.ManagementLockObject: """Creates or updates a management lock at the subscription level. When you apply a lock at a parent scope, all child resources inherit the same lock. To create @@ -1402,25 +1595,91 @@ def create_or_update_at_subscription_level( Administrator are granted those actions. :param lock_name: The name of lock. The lock name can be a maximum of 260 characters. It cannot - contain <, > %, &, :, \, ?, /, or any control characters. + contain <, > %, &, :, \, ?, /, or any control characters. Required. :type lock_name: str - :param parameters: The management lock parameters. + :param parameters: The management lock parameters. Required. :type parameters: ~azure.mgmt.resource.locks.v2016_09_01.models.ManagementLockObject + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: ManagementLockObject, or the result of cls(response) + :return: ManagementLockObject or the result of cls(response) :rtype: ~azure.mgmt.resource.locks.v2016_09_01.models.ManagementLockObject - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + def create_or_update_at_subscription_level( + self, lock_name: str, parameters: IO, *, content_type: str = "application/json", **kwargs: Any + ) -> _models.ManagementLockObject: + """Creates or updates a management lock at the subscription level. + + When you apply a lock at a parent scope, all child resources inherit the same lock. To create + management locks, you must have access to Microsoft.Authorization/\ * or + Microsoft.Authorization/locks/* actions. Of the built-in roles, only Owner and User Access + Administrator are granted those actions. + + :param lock_name: The name of lock. The lock name can be a maximum of 260 characters. It cannot + contain <, > %, &, :, \, ?, /, or any control characters. Required. + :type lock_name: str + :param parameters: The management lock parameters. Required. + :type parameters: IO + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: ManagementLockObject or the result of cls(response) + :rtype: ~azure.mgmt.resource.locks.v2016_09_01.models.ManagementLockObject + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace + def create_or_update_at_subscription_level( + self, lock_name: str, parameters: Union[_models.ManagementLockObject, IO], **kwargs: Any + ) -> _models.ManagementLockObject: + """Creates or updates a management lock at the subscription level. + + When you apply a lock at a parent scope, all child resources inherit the same lock. To create + management locks, you must have access to Microsoft.Authorization/\ * or + Microsoft.Authorization/locks/* actions. Of the built-in roles, only Owner and User Access + Administrator are granted those actions. + + :param lock_name: The name of lock. The lock name can be a maximum of 260 characters. It cannot + contain <, > %, &, :, \, ?, /, or any control characters. Required. + :type lock_name: str + :param parameters: The management lock parameters. Is either a model type or a IO type. + Required. + :type parameters: ~azure.mgmt.resource.locks.v2016_09_01.models.ManagementLockObject or IO + :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. + Default value is None. + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: ManagementLockObject or the result of cls(response) + :rtype: ~azure.mgmt.resource.locks.v2016_09_01.models.ManagementLockObject + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.ManagementLockObject"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) - api_version = kwargs.pop('api_version', "2016-09-01") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - _json = self._serialize.body(parameters, 'ManagementLockObject') + api_version = kwargs.pop("api_version", _params.pop("api-version", "2016-09-01")) # type: str + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.ManagementLockObject] + + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(parameters, (IO, bytes)): + _content = parameters + else: + _json = self._serialize.body(parameters, "ManagementLockObject") request = build_management_locks_create_or_update_at_subscription_level_request( lock_name=lock_name, @@ -1428,16 +1687,18 @@ def create_or_update_at_subscription_level( api_version=api_version, content_type=content_type, json=_json, - template_url=self.create_or_update_at_subscription_level.metadata['url'], + content=_content, + template_url=self.create_or_update_at_subscription_level.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200, 201]: @@ -1445,24 +1706,21 @@ def create_or_update_at_subscription_level( raise HttpResponseError(response=response, error_format=ARMErrorFormat) if response.status_code == 200: - deserialized = self._deserialize('ManagementLockObject', pipeline_response) + deserialized = self._deserialize("ManagementLockObject", pipeline_response) if response.status_code == 201: - deserialized = self._deserialize('ManagementLockObject', pipeline_response) + deserialized = self._deserialize("ManagementLockObject", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - create_or_update_at_subscription_level.metadata = {'url': "/subscriptions/{subscriptionId}/providers/Microsoft.Authorization/locks/{lockName}"} # type: ignore - + create_or_update_at_subscription_level.metadata = {"url": "/subscriptions/{subscriptionId}/providers/Microsoft.Authorization/locks/{lockName}"} # type: ignore @distributed_trace def delete_at_subscription_level( # pylint: disable=inconsistent-return-statements - self, - lock_name: str, - **kwargs: Any + self, lock_name: str, **kwargs: Any ) -> None: """Deletes the management lock at the subscription level. @@ -1470,36 +1728,42 @@ def delete_at_subscription_level( # pylint: disable=inconsistent-return-stateme Microsoft.Authorization/locks/* actions. Of the built-in roles, only Owner and User Access Administrator are granted those actions. - :param lock_name: The name of lock to delete. + :param lock_name: The name of lock to delete. Required. :type lock_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: None, or the result of cls(response) + :return: None or the result of cls(response) :rtype: None - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType[None] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) - api_version = kwargs.pop('api_version', "2016-09-01") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2016-09-01")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[None] - request = build_management_locks_delete_at_subscription_level_request( lock_name=lock_name, subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.delete_at_subscription_level.metadata['url'], + template_url=self.delete_at_subscription_level.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200, 204]: @@ -1509,112 +1773,118 @@ def delete_at_subscription_level( # pylint: disable=inconsistent-return-stateme if cls: return cls(pipeline_response, None, {}) - delete_at_subscription_level.metadata = {'url': "/subscriptions/{subscriptionId}/providers/Microsoft.Authorization/locks/{lockName}"} # type: ignore - + delete_at_subscription_level.metadata = {"url": "/subscriptions/{subscriptionId}/providers/Microsoft.Authorization/locks/{lockName}"} # type: ignore @distributed_trace - def get_at_subscription_level( - self, - lock_name: str, - **kwargs: Any - ) -> "_models.ManagementLockObject": + def get_at_subscription_level(self, lock_name: str, **kwargs: Any) -> _models.ManagementLockObject: """Gets a management lock at the subscription level. - :param lock_name: The name of the lock to get. + :param lock_name: The name of the lock to get. Required. :type lock_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: ManagementLockObject, or the result of cls(response) + :return: ManagementLockObject or the result of cls(response) :rtype: ~azure.mgmt.resource.locks.v2016_09_01.models.ManagementLockObject - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.ManagementLockObject"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) - api_version = kwargs.pop('api_version', "2016-09-01") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2016-09-01")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[_models.ManagementLockObject] - request = build_management_locks_get_at_subscription_level_request( lock_name=lock_name, subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.get_at_subscription_level.metadata['url'], + template_url=self.get_at_subscription_level.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) - deserialized = self._deserialize('ManagementLockObject', pipeline_response) + deserialized = self._deserialize("ManagementLockObject", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - get_at_subscription_level.metadata = {'url': "/subscriptions/{subscriptionId}/providers/Microsoft.Authorization/locks/{lockName}"} # type: ignore - + get_at_subscription_level.metadata = {"url": "/subscriptions/{subscriptionId}/providers/Microsoft.Authorization/locks/{lockName}"} # type: ignore @distributed_trace def list_at_resource_group_level( - self, - resource_group_name: str, - filter: Optional[str] = None, - **kwargs: Any - ) -> Iterable["_models.ManagementLockListResult"]: + self, resource_group_name: str, filter: Optional[str] = None, **kwargs: Any + ) -> Iterable["_models.ManagementLockObject"]: """Gets all the management locks for a resource group. :param resource_group_name: The name of the resource group containing the locks to get. + Required. :type resource_group_name: str :param filter: The filter to apply on the operation. Default value is None. :type filter: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either ManagementLockListResult or the result of + :return: An iterator like instance of either ManagementLockObject or the result of cls(response) :rtype: - ~azure.core.paging.ItemPaged[~azure.mgmt.resource.locks.v2016_09_01.models.ManagementLockListResult] - :raises: ~azure.core.exceptions.HttpResponseError + ~azure.core.paging.ItemPaged[~azure.mgmt.resource.locks.v2016_09_01.models.ManagementLockObject] + :raises ~azure.core.exceptions.HttpResponseError: """ - api_version = kwargs.pop('api_version', "2016-09-01") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2016-09-01")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[_models.ManagementLockListResult] - cls = kwargs.pop('cls', None) # type: ClsType["_models.ManagementLockListResult"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) + def prepare_request(next_link=None): if not next_link: - + request = build_management_locks_list_at_resource_group_level_request( resource_group_name=resource_group_name, subscription_id=self._config.subscription_id, - api_version=api_version, filter=filter, - template_url=self.list_at_resource_group_level.metadata['url'], + api_version=api_version, + template_url=self.list_at_resource_group_level.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore else: - - request = build_management_locks_list_at_resource_group_level_request( - resource_group_name=resource_group_name, - subscription_id=self._config.subscription_id, - template_url=next_link, - ) + # make call to next link with the client's api-version + _parsed_next_link = urlparse(next_link) + _next_request_params = case_insensitive_dict(parse_qs(_parsed_next_link.query)) + _next_request_params["api-version"] = self._config.api_version + request = HttpRequest("GET", urljoin(next_link, _parsed_next_link.path), params=_next_request_params) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore request.method = "GET" return request @@ -1628,10 +1898,8 @@ def extract_data(pipeline_response): def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) response = pipeline_response.http_response @@ -1641,11 +1909,9 @@ def get_next(next_link=None): return pipeline_response + return ItemPaged(get_next, extract_data) - return ItemPaged( - get_next, extract_data - ) - list_at_resource_group_level.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Authorization/locks"} # type: ignore + list_at_resource_group_level.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Authorization/locks"} # type: ignore @distributed_trace def list_at_resource_level( @@ -1657,39 +1923,46 @@ def list_at_resource_level( resource_name: str, filter: Optional[str] = None, **kwargs: Any - ) -> Iterable["_models.ManagementLockListResult"]: + ) -> Iterable["_models.ManagementLockObject"]: """Gets all the management locks for a resource or any level below resource. :param resource_group_name: The name of the resource group containing the locked resource. The - name is case insensitive. + name is case insensitive. Required. :type resource_group_name: str - :param resource_provider_namespace: The namespace of the resource provider. + :param resource_provider_namespace: The namespace of the resource provider. Required. :type resource_provider_namespace: str - :param parent_resource_path: The parent resource identity. + :param parent_resource_path: The parent resource identity. Required. :type parent_resource_path: str - :param resource_type: The resource type of the locked resource. + :param resource_type: The resource type of the locked resource. Required. :type resource_type: str - :param resource_name: The name of the locked resource. + :param resource_name: The name of the locked resource. Required. :type resource_name: str :param filter: The filter to apply on the operation. Default value is None. :type filter: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either ManagementLockListResult or the result of + :return: An iterator like instance of either ManagementLockObject or the result of cls(response) :rtype: - ~azure.core.paging.ItemPaged[~azure.mgmt.resource.locks.v2016_09_01.models.ManagementLockListResult] - :raises: ~azure.core.exceptions.HttpResponseError + ~azure.core.paging.ItemPaged[~azure.mgmt.resource.locks.v2016_09_01.models.ManagementLockObject] + :raises ~azure.core.exceptions.HttpResponseError: """ - api_version = kwargs.pop('api_version', "2016-09-01") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2016-09-01")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[_models.ManagementLockListResult] - cls = kwargs.pop('cls', None) # type: ClsType["_models.ManagementLockListResult"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) + def prepare_request(next_link=None): if not next_link: - + request = build_management_locks_list_at_resource_level_request( resource_group_name=resource_group_name, resource_provider_namespace=resource_provider_namespace, @@ -1697,26 +1970,23 @@ def prepare_request(next_link=None): resource_type=resource_type, resource_name=resource_name, subscription_id=self._config.subscription_id, - api_version=api_version, filter=filter, - template_url=self.list_at_resource_level.metadata['url'], + api_version=api_version, + template_url=self.list_at_resource_level.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore else: - - request = build_management_locks_list_at_resource_level_request( - resource_group_name=resource_group_name, - resource_provider_namespace=resource_provider_namespace, - parent_resource_path=parent_resource_path, - resource_type=resource_type, - resource_name=resource_name, - subscription_id=self._config.subscription_id, - template_url=next_link, - ) + # make call to next link with the client's api-version + _parsed_next_link = urlparse(next_link) + _next_request_params = case_insensitive_dict(parse_qs(_parsed_next_link.query)) + _next_request_params["api-version"] = self._config.api_version + request = HttpRequest("GET", urljoin(next_link, _parsed_next_link.path), params=_next_request_params) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore request.method = "GET" return request @@ -1730,10 +2000,8 @@ def extract_data(pipeline_response): def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) response = pipeline_response.http_response @@ -1743,56 +2011,61 @@ def get_next(next_link=None): return pipeline_response + return ItemPaged(get_next, extract_data) - return ItemPaged( - get_next, extract_data - ) - list_at_resource_level.metadata = {'url': "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{parentResourcePath}/{resourceType}/{resourceName}/providers/Microsoft.Authorization/locks"} # type: ignore + list_at_resource_level.metadata = {"url": "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{parentResourcePath}/{resourceType}/{resourceName}/providers/Microsoft.Authorization/locks"} # type: ignore @distributed_trace def list_at_subscription_level( - self, - filter: Optional[str] = None, - **kwargs: Any - ) -> Iterable["_models.ManagementLockListResult"]: + self, filter: Optional[str] = None, **kwargs: Any + ) -> Iterable["_models.ManagementLockObject"]: """Gets all the management locks for a subscription. :param filter: The filter to apply on the operation. Default value is None. :type filter: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either ManagementLockListResult or the result of + :return: An iterator like instance of either ManagementLockObject or the result of cls(response) :rtype: - ~azure.core.paging.ItemPaged[~azure.mgmt.resource.locks.v2016_09_01.models.ManagementLockListResult] - :raises: ~azure.core.exceptions.HttpResponseError + ~azure.core.paging.ItemPaged[~azure.mgmt.resource.locks.v2016_09_01.models.ManagementLockObject] + :raises ~azure.core.exceptions.HttpResponseError: """ - api_version = kwargs.pop('api_version', "2016-09-01") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2016-09-01")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[_models.ManagementLockListResult] - cls = kwargs.pop('cls', None) # type: ClsType["_models.ManagementLockListResult"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) + def prepare_request(next_link=None): if not next_link: - + request = build_management_locks_list_at_subscription_level_request( subscription_id=self._config.subscription_id, - api_version=api_version, filter=filter, - template_url=self.list_at_subscription_level.metadata['url'], + api_version=api_version, + template_url=self.list_at_subscription_level.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore else: - - request = build_management_locks_list_at_subscription_level_request( - subscription_id=self._config.subscription_id, - template_url=next_link, - ) + # make call to next link with the client's api-version + _parsed_next_link = urlparse(next_link) + _next_request_params = case_insensitive_dict(parse_qs(_parsed_next_link.query)) + _next_request_params["api-version"] = self._config.api_version + request = HttpRequest("GET", urljoin(next_link, _parsed_next_link.path), params=_next_request_params) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore request.method = "GET" return request @@ -1806,10 +2079,8 @@ def extract_data(pipeline_response): def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) response = pipeline_response.http_response @@ -1819,63 +2090,67 @@ def get_next(next_link=None): return pipeline_response + return ItemPaged(get_next, extract_data) - return ItemPaged( - get_next, extract_data - ) - list_at_subscription_level.metadata = {'url': "/subscriptions/{subscriptionId}/providers/Microsoft.Authorization/locks"} # type: ignore + list_at_subscription_level.metadata = {"url": "/subscriptions/{subscriptionId}/providers/Microsoft.Authorization/locks"} # type: ignore @distributed_trace def list_by_scope( - self, - scope: str, - filter: Optional[str] = None, - **kwargs: Any - ) -> Iterable["_models.ManagementLockListResult"]: + self, scope: str, filter: Optional[str] = None, **kwargs: Any + ) -> Iterable["_models.ManagementLockObject"]: """Gets all the management locks for a scope. :param scope: The scope for the lock. When providing a scope for the assignment, use '/subscriptions/{subscriptionId}' for subscriptions, '/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}' for resource groups, and '/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{parentResourcePathIfPresent}/{resourceType}/{resourceName}' - for resources. + for resources. Required. :type scope: str :param filter: The filter to apply on the operation. Default value is None. :type filter: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either ManagementLockListResult or the result of + :return: An iterator like instance of either ManagementLockObject or the result of cls(response) :rtype: - ~azure.core.paging.ItemPaged[~azure.mgmt.resource.locks.v2016_09_01.models.ManagementLockListResult] - :raises: ~azure.core.exceptions.HttpResponseError + ~azure.core.paging.ItemPaged[~azure.mgmt.resource.locks.v2016_09_01.models.ManagementLockObject] + :raises ~azure.core.exceptions.HttpResponseError: """ - api_version = kwargs.pop('api_version', "2016-09-01") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2016-09-01")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[_models.ManagementLockListResult] - cls = kwargs.pop('cls', None) # type: ClsType["_models.ManagementLockListResult"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) + def prepare_request(next_link=None): if not next_link: - + request = build_management_locks_list_by_scope_request( scope=scope, - api_version=api_version, filter=filter, - template_url=self.list_by_scope.metadata['url'], + api_version=api_version, + template_url=self.list_by_scope.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore else: - - request = build_management_locks_list_by_scope_request( - scope=scope, - template_url=next_link, - ) + # make call to next link with the client's api-version + _parsed_next_link = urlparse(next_link) + _next_request_params = case_insensitive_dict(parse_qs(_parsed_next_link.query)) + _next_request_params["api-version"] = self._config.api_version + request = HttpRequest("GET", urljoin(next_link, _parsed_next_link.path), params=_next_request_params) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore request.method = "GET" return request @@ -1889,10 +2164,8 @@ def extract_data(pipeline_response): def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) response = pipeline_response.http_response @@ -1902,8 +2175,6 @@ def get_next(next_link=None): return pipeline_response + return ItemPaged(get_next, extract_data) - return ItemPaged( - get_next, extract_data - ) - list_by_scope.metadata = {'url': "/{scope}/providers/Microsoft.Authorization/locks"} # type: ignore + list_by_scope.metadata = {"url": "/{scope}/providers/Microsoft.Authorization/locks"} # type: ignore diff --git a/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/locks/v2016_09_01/operations/_patch.py b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/locks/v2016_09_01/operations/_patch.py new file mode 100644 index 0000000000000..f7dd32510333d --- /dev/null +++ b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/locks/v2016_09_01/operations/_patch.py @@ -0,0 +1,20 @@ +# ------------------------------------ +# Copyright (c) Microsoft Corporation. +# Licensed under the MIT License. +# ------------------------------------ +"""Customize generated code here. + +Follow our quickstart for examples: https://aka.ms/azsdk/python/dpcodegen/python/customize +""" +from typing import List + +__all__: List[str] = [] # Add all objects you want publicly available to users at this package level + + +def patch_sdk(): + """Do not remove from this file. + + `patch_sdk` is a last resort escape hatch that allows you to do customizations + you can't accomplish using the techniques described in + https://aka.ms/azsdk/python/dpcodegen/python/customize + """ diff --git a/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/managedapplications/__init__.py b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/managedapplications/__init__.py index 624aa2175b55c..62ec58b505d9a 100644 --- a/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/managedapplications/__init__.py +++ b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/managedapplications/__init__.py @@ -7,12 +7,14 @@ # -------------------------------------------------------------------------- from ._application_client import ApplicationClient +__all__ = ['ApplicationClient'] + +try: + from ._patch import patch_sdk # type: ignore + patch_sdk() +except ImportError: + pass + from ._version import VERSION __version__ = VERSION -__all__ = ['ApplicationClient'] - -# `._patch.py` is used for handwritten extensions to the generated code -# Example: https://github.com/Azure/azure-sdk-for-python/blob/main/doc/dev/customize_code/how-to-patch-sdk-code.md -from ._patch import patch_sdk -patch_sdk() diff --git a/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/managedapplications/_application_client.py b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/managedapplications/_application_client.py index 98adda8e6d29d..55936bd6ab234 100644 --- a/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/managedapplications/_application_client.py +++ b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/managedapplications/_application_client.py @@ -1,102 +1,129 @@ # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. -# Licensed under the MIT License. See License.txt in the project root for license information. +# Licensed under the MIT License. See License.txt in the project root for +# license information. +# # Code generated by Microsoft (R) AutoRest Code Generator. -# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# Changes may cause incorrect behavior and will be lost if the code is +# regenerated. # -------------------------------------------------------------------------- -from copy import deepcopy -from typing import Any, TYPE_CHECKING +from typing import Any, Optional, TYPE_CHECKING -from msrest import Deserializer, Serializer - -from azure.core.rest import HttpRequest, HttpResponse from azure.mgmt.core import ARMPipelineClient +from azure.profiles import KnownProfiles, ProfileDefinition +from azure.profiles.multiapiclient import MultiApiClientMixin -from . import models from ._configuration import ApplicationClientConfiguration -from .operations import ApplicationClientOperationsMixin, ApplicationDefinitionsOperations, ApplicationsOperations +from ._operations_mixin import ApplicationClientOperationsMixin +from ._serialization import Deserializer, Serializer if TYPE_CHECKING: # pylint: disable=unused-import,ungrouped-imports from azure.core.credentials import TokenCredential -class ApplicationClient(ApplicationClientOperationsMixin): +class _SDKClient(object): + def __init__(self, *args, **kwargs): + """This is a fake class to support current implemetation of MultiApiClientMixin." + Will be removed in final version of multiapi azure-core based client + """ + pass + +class ApplicationClient(ApplicationClientOperationsMixin, MultiApiClientMixin, _SDKClient): """ARM applications. - :ivar applications: ApplicationsOperations operations - :vartype applications: - azure.mgmt.resource.managedapplications.operations.ApplicationsOperations - :ivar application_definitions: ApplicationDefinitionsOperations operations - :vartype application_definitions: - azure.mgmt.resource.managedapplications.operations.ApplicationDefinitionsOperations - :param credential: Credential needed for the client to connect to Azure. + This ready contains multiple API versions, to help you deal with all of the Azure clouds + (Azure Stack, Azure Government, Azure China, etc.). + By default, it uses the latest API version available on public Azure. + For production, you should stick to a particular api-version and/or profile. + The profile sets a mapping between an operation group and its API version. + The api-version parameter sets the default API version if the operation + group is not described in the profile. + + :param credential: Credential needed for the client to connect to Azure. Required. :type credential: ~azure.core.credentials.TokenCredential - :param subscription_id: The ID of the target subscription. + :param subscription_id: The ID of the target subscription. Required. :type subscription_id: str - :param base_url: Service URL. Default value is "https://management.azure.com". + :param api_version: API version to use if no profile is provided, or if missing in profile. + :type api_version: str + :param base_url: Service URL :type base_url: str - :keyword api_version: Api Version. Default value is "2018-06-01". Note that overriding this - default value may result in unsupported behavior. - :paramtype api_version: str - :keyword int polling_interval: Default waiting time between two polls for LRO operations if no - Retry-After header is present. + :param profile: A profile definition, from KnownProfiles to dict. + :type profile: azure.profiles.KnownProfiles + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no Retry-After header is present. """ + DEFAULT_API_VERSION = '2018-06-01' + _PROFILE_TAG = "azure.mgmt.resource.managedapplications.ApplicationClient" + LATEST_PROFILE = ProfileDefinition({ + _PROFILE_TAG: { + None: DEFAULT_API_VERSION, + }}, + _PROFILE_TAG + " latest" + ) + def __init__( self, credential: "TokenCredential", subscription_id: str, + api_version=None, # type: Optional[str] base_url: str = "https://management.azure.com", - **kwargs: Any - ) -> None: - self._config = ApplicationClientConfiguration(credential=credential, subscription_id=subscription_id, **kwargs) + profile=KnownProfiles.default, # type: KnownProfiles + **kwargs # type: Any + ): + self._config = ApplicationClientConfiguration(credential, subscription_id, **kwargs) self._client = ARMPipelineClient(base_url=base_url, config=self._config, **kwargs) + super(ApplicationClient, self).__init__( + api_version=api_version, + profile=profile + ) - 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 - self.applications = ApplicationsOperations(self._client, self._config, self._serialize, self._deserialize) - self.application_definitions = ApplicationDefinitionsOperations(self._client, self._config, self._serialize, self._deserialize) + @classmethod + def _models_dict(cls, api_version): + return {k: v for k, v in cls.models(api_version).__dict__.items() if isinstance(v, type)} + @classmethod + def models(cls, api_version=DEFAULT_API_VERSION): + """Module depends on the API version: - def _send_request( - self, - request: HttpRequest, - **kwargs: Any - ) -> HttpResponse: - """Runs the network request through the client's chained policies. - - >>> from azure.core.rest import HttpRequest - >>> request = HttpRequest("GET", "https://www.example.org/") - - >>> response = client._send_request(request) - - - For more information on this code flow, see https://aka.ms/azsdk/python/protocol/quickstart - - :param request: The network request you want to make. Required. - :type request: ~azure.core.rest.HttpRequest - :keyword bool stream: Whether the response payload will be streamed. Defaults to False. - :return: The response of your network call. Does not do error handling on your response. - :rtype: ~azure.core.rest.HttpResponse + * 2018-06-01: :mod:`v2018_06_01.models` """ + if api_version == '2018-06-01': + from .v2018_06_01 import models + return models + raise ValueError("API version {} is not available".format(api_version)) - request_copy = deepcopy(request) - request_copy.url = self._client.format_url(request_copy.url) - return self._client.send_request(request_copy, **kwargs) + @property + def application_definitions(self): + """Instance depends on the API version: + + * 2018-06-01: :class:`ApplicationDefinitionsOperations` + """ + api_version = self._get_api_version('application_definitions') + if api_version == '2018-06-01': + from .v2018_06_01.operations import ApplicationDefinitionsOperations as OperationClass + else: + raise ValueError("API version {} does not have operation group 'application_definitions'".format(api_version)) + return OperationClass(self._client, self._config, Serializer(self._models_dict(api_version)), Deserializer(self._models_dict(api_version))) + + @property + def applications(self): + """Instance depends on the API version: + + * 2018-06-01: :class:`ApplicationsOperations` + """ + api_version = self._get_api_version('applications') + if api_version == '2018-06-01': + from .v2018_06_01.operations import ApplicationsOperations as OperationClass + else: + raise ValueError("API version {} does not have operation group 'applications'".format(api_version)) + return OperationClass(self._client, self._config, Serializer(self._models_dict(api_version)), Deserializer(self._models_dict(api_version))) def close(self): - # type: () -> None self._client.close() - def __enter__(self): - # type: () -> ApplicationClient self._client.__enter__() return self - def __exit__(self, *exc_details): - # type: (Any) -> None self._client.__exit__(*exc_details) diff --git a/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/managedapplications/_configuration.py b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/managedapplications/_configuration.py index be7e047dee3dd..39a01128f8253 100644 --- a/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/managedapplications/_configuration.py +++ b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/managedapplications/_configuration.py @@ -1,11 +1,13 @@ # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. -# Licensed under the MIT License. See License.txt in the project root for license information. +# Licensed under the MIT License. See License.txt in the project root for +# license information. +# # Code generated by Microsoft (R) AutoRest Code Generator. -# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# Changes may cause incorrect behavior and will be lost if the code is +# regenerated. # -------------------------------------------------------------------------- - from typing import Any, TYPE_CHECKING from azure.core.configuration import Configuration @@ -18,41 +20,35 @@ # pylint: disable=unused-import,ungrouped-imports from azure.core.credentials import TokenCredential - -class ApplicationClientConfiguration(Configuration): # pylint: disable=too-many-instance-attributes +class ApplicationClientConfiguration(Configuration): """Configuration for ApplicationClient. Note that all parameters used to create this instance are saved as instance attributes. - :param credential: Credential needed for the client to connect to Azure. + :param credential: Credential needed for the client to connect to Azure. Required. :type credential: ~azure.core.credentials.TokenCredential - :param subscription_id: The ID of the target subscription. + :param subscription_id: The ID of the target subscription. Required. :type subscription_id: str - :keyword api_version: Api Version. Default value is "2018-06-01". Note that overriding this - default value may result in unsupported behavior. - :paramtype api_version: str """ def __init__( self, credential: "TokenCredential", subscription_id: str, - **kwargs: Any - ) -> None: - super(ApplicationClientConfiguration, self).__init__(**kwargs) - api_version = kwargs.pop('api_version', "2018-06-01") # type: str - + **kwargs # type: Any + ): + # type: (...) -> None if credential is None: raise ValueError("Parameter 'credential' must not be None.") if subscription_id is None: raise ValueError("Parameter 'subscription_id' must not be None.") + super(ApplicationClientConfiguration, self).__init__(**kwargs) self.credential = credential self.subscription_id = subscription_id - self.api_version = api_version self.credential_scopes = kwargs.pop('credential_scopes', ['https://management.azure.com/.default']) - kwargs.setdefault('sdk_moniker', 'mgmt-resource/{}'.format(VERSION)) + kwargs.setdefault('sdk_moniker', 'azure-mgmt-resource/{}'.format(VERSION)) self._configure(**kwargs) def _configure( diff --git a/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/managedapplications/_operations_mixin.py b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/managedapplications/_operations_mixin.py new file mode 100644 index 0000000000000..bd38876a6052f --- /dev/null +++ b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/managedapplications/_operations_mixin.py @@ -0,0 +1,44 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for +# license information. +# +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is +# regenerated. +# -------------------------------------------------------------------------- +from ._serialization import Serializer, Deserializer +from typing import Any, Iterable + +from azure.core.paging import ItemPaged + +from . import models as _models + + +class ApplicationClientOperationsMixin(object): + + def list_operations( + self, + **kwargs: Any + ) -> Iterable["_models.Operation"]: + """Lists all of the available Microsoft.Solutions REST API operations. + + :keyword callable cls: A custom type or function that will be passed the direct response + :return: An iterator like instance of either Operation or the result of cls(response) + :rtype: + ~azure.core.paging.ItemPaged[~azure.mgmt.resource.managedapplications.v2018_06_01.models.Operation] + :raises ~azure.core.exceptions.HttpResponseError: + """ + api_version = self._get_api_version('list_operations') + if api_version == '2018-06-01': + from .v2018_06_01.operations import ApplicationClientOperationsMixin as OperationClass + else: + raise ValueError("API version {} does not have operation 'list_operations'".format(api_version)) + mixin_instance = OperationClass() + mixin_instance._client = self._client + mixin_instance._config = self._config + mixin_instance._serialize = Serializer(self._models_dict(api_version)) + mixin_instance._serialize.client_side_validation = False + mixin_instance._deserialize = Deserializer(self._models_dict(api_version)) + return mixin_instance.list_operations(**kwargs) diff --git a/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/managedapplications/_serialization.py b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/managedapplications/_serialization.py new file mode 100644 index 0000000000000..240df16c57f3c --- /dev/null +++ b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/managedapplications/_serialization.py @@ -0,0 +1,2006 @@ +# -------------------------------------------------------------------------- +# +# Copyright (c) Microsoft Corporation. All rights reserved. +# +# The MIT License (MIT) +# +# Permission is hereby granted, free of charge, to any person obtaining a copy +# of this software and associated documentation files (the ""Software""), to +# deal in the Software without restriction, including without limitation the +# rights to use, copy, modify, merge, publish, distribute, sublicense, and/or +# sell copies of the Software, and to permit persons to whom the Software is +# furnished to do so, subject to the following conditions: +# +# The above copyright notice and this permission notice shall be included in +# all copies or substantial portions of the Software. +# +# THE SOFTWARE IS PROVIDED *AS IS*, WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING +# FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS +# IN THE SOFTWARE. +# +# -------------------------------------------------------------------------- + +# pylint: skip-file + +from base64 import b64decode, b64encode +import calendar +import datetime +import decimal +import email +from enum import Enum +import json +import logging +import re +import sys +import codecs +try: + from urllib import quote # type: ignore +except ImportError: + from urllib.parse import quote # type: ignore +import xml.etree.ElementTree as ET + +import isodate + +from typing import Dict, Any, cast, TYPE_CHECKING + +from azure.core.exceptions import DeserializationError, SerializationError, raise_with_traceback + +_BOM = codecs.BOM_UTF8.decode(encoding='utf-8') + +if TYPE_CHECKING: + from typing import Optional, Union, AnyStr, IO, Mapping + +class RawDeserializer: + + # Accept "text" because we're open minded people... + JSON_REGEXP = re.compile(r'^(application|text)/([a-z+.]+\+)?json$') + + # Name used in context + CONTEXT_NAME = "deserialized_data" + + @classmethod + def deserialize_from_text(cls, data, content_type=None): + # type: (Optional[Union[AnyStr, IO]], Optional[str]) -> Any + """Decode data according to content-type. + + Accept a stream of data as well, but will be load at once in memory for now. + + If no content-type, will return the string version (not bytes, not stream) + + :param data: Input, could be bytes or stream (will be decoded with UTF8) or text + :type data: str or bytes or IO + :param str content_type: The content type. + """ + if hasattr(data, 'read'): + # Assume a stream + data = cast(IO, data).read() + + if isinstance(data, bytes): + data_as_str = data.decode(encoding='utf-8-sig') + else: + # Explain to mypy the correct type. + data_as_str = cast(str, data) + + # Remove Byte Order Mark if present in string + data_as_str = data_as_str.lstrip(_BOM) + + if content_type is None: + return data + + if cls.JSON_REGEXP.match(content_type): + try: + return json.loads(data_as_str) + except ValueError as err: + raise DeserializationError("JSON is invalid: {}".format(err), err) + elif "xml" in (content_type or []): + try: + + try: + if isinstance(data, unicode): # type: ignore + # If I'm Python 2.7 and unicode XML will scream if I try a "fromstring" on unicode string + data_as_str = data_as_str.encode(encoding="utf-8") # type: ignore + except NameError: + pass + + return ET.fromstring(data_as_str) # nosec + except ET.ParseError: + # It might be because the server has an issue, and returned JSON with + # content-type XML.... + # So let's try a JSON load, and if it's still broken + # let's flow the initial exception + def _json_attemp(data): + try: + return True, json.loads(data) + except ValueError: + return False, None # Don't care about this one + success, json_result = _json_attemp(data) + if success: + return json_result + # If i'm here, it's not JSON, it's not XML, let's scream + # and raise the last context in this block (the XML exception) + # The function hack is because Py2.7 messes up with exception + # context otherwise. + _LOGGER.critical("Wasn't XML not JSON, failing") + raise_with_traceback(DeserializationError, "XML is invalid") + 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 + """Deserialize from HTTP response. + + Use bytes and headers to NOT use any requests/aiohttp or whatever + specific implementation. + Headers will tested for "content-type" + """ + # Try to use content-type from headers if available + content_type = None + if 'content-type' in headers: + content_type = headers['content-type'].split(";")[0].strip().lower() + # Ouch, this server did not declare what it sent... + # Let's guess it's JSON... + # Also, since Autorest was considering that an empty body was a valid JSON, + # need that test as well.... + else: + content_type = "application/json" + + if body_bytes: + return cls.deserialize_from_text(body_bytes, content_type) + return None + +try: + basestring # type: ignore + unicode_str = unicode # type: ignore +except NameError: + basestring = str # type: ignore + unicode_str = str # type: ignore + +_LOGGER = logging.getLogger(__name__) + +try: + _long_type = long # type: ignore +except NameError: + _long_type = int + +class UTC(datetime.tzinfo): + """Time Zone info for handling UTC""" + + def utcoffset(self, dt): + """UTF offset for UTC is 0.""" + return datetime.timedelta(0) + + def tzname(self, dt): + """Timestamp representation.""" + return "Z" + + def dst(self, dt): + """No daylight saving for UTC.""" + return datetime.timedelta(hours=1) + +try: + from datetime import timezone as _FixedOffset +except ImportError: # Python 2.7 + class _FixedOffset(datetime.tzinfo): # type: ignore + """Fixed offset in minutes east from UTC. + Copy/pasted from Python doc + :param datetime.timedelta offset: offset in timedelta format + """ + + def __init__(self, offset): + self.__offset = offset + + def utcoffset(self, dt): + return self.__offset + + def tzname(self, dt): + return str(self.__offset.total_seconds()/3600) + + def __repr__(self): + return "".format(self.tzname(None)) + + def dst(self, dt): + return datetime.timedelta(0) + + def __getinitargs__(self): + return (self.__offset,) + +try: + from datetime import timezone + TZ_UTC = timezone.utc # type: ignore +except ImportError: + TZ_UTC = UTC() # type: ignore + +_FLATTEN = re.compile(r"(? y, + "minimum": lambda x, y: x < y, + "maximum": lambda x, y: x > y, + "minimum_ex": lambda x, y: x <= y, + "maximum_ex": lambda x, y: x >= y, + "min_items": lambda x, y: len(x) < y, + "max_items": lambda x, y: len(x) > y, + "pattern": lambda x, y: not re.match(y, x, re.UNICODE), + "unique": lambda x, y: len(x) != len(set(x)), + "multiple": lambda x, y: x % y != 0 + } + + def __init__(self, classes=None): + self.serialize_type = { + 'iso-8601': Serializer.serialize_iso, + 'rfc-1123': Serializer.serialize_rfc, + 'unix-time': Serializer.serialize_unix, + 'duration': Serializer.serialize_duration, + 'date': Serializer.serialize_date, + 'time': Serializer.serialize_time, + 'decimal': Serializer.serialize_decimal, + 'long': Serializer.serialize_long, + 'bytearray': Serializer.serialize_bytearray, + 'base64': Serializer.serialize_base64, + 'object': self.serialize_object, + '[]': self.serialize_iter, + '{}': self.serialize_dict + } + self.dependencies = dict(classes) if classes else {} + self.key_transformer = full_restapi_key_transformer + self.client_side_validation = True + + def _serialize(self, target_obj, data_type=None, **kwargs): + """Serialize data into a string according to type. + + :param target_obj: The data to be serialized. + :param str data_type: The type to be serialized from. + :rtype: str, dict + :raises: SerializationError if serialization fails. + """ + key_transformer = kwargs.get("key_transformer", self.key_transformer) + keep_readonly = kwargs.get("keep_readonly", False) + if target_obj is None: + return None + + attr_name = None + class_name = target_obj.__class__.__name__ + + if data_type: + return self.serialize_data( + target_obj, data_type, **kwargs) + + if not hasattr(target_obj, "_attribute_map"): + data_type = type(target_obj).__name__ + if data_type in self.basic_types.values(): + return self.serialize_data( + target_obj, data_type, **kwargs) + + # Force "is_xml" kwargs if we detect a XML model + try: + is_xml_model_serialization = kwargs["is_xml"] + except KeyError: + is_xml_model_serialization = kwargs.setdefault("is_xml", target_obj.is_xml_model()) + + serialized = {} + if is_xml_model_serialization: + serialized = target_obj._create_xml_node() + try: + attributes = target_obj._attribute_map + for attr, attr_desc in attributes.items(): + attr_name = attr + if not keep_readonly and target_obj._validation.get(attr_name, {}).get('readonly', False): + continue + + if attr_name == "additional_properties" and attr_desc["key"] == '': + if target_obj.additional_properties is not None: + serialized.update(target_obj.additional_properties) + continue + try: + + orig_attr = getattr(target_obj, attr) + if is_xml_model_serialization: + pass # Don't provide "transformer" for XML for now. Keep "orig_attr" + else: # JSON + keys, orig_attr = key_transformer(attr, attr_desc.copy(), orig_attr) + keys = keys if isinstance(keys, list) else [keys] + + + kwargs["serialization_ctxt"] = attr_desc + new_attr = self.serialize_data(orig_attr, attr_desc['type'], **kwargs) + + + if is_xml_model_serialization: + xml_desc = attr_desc.get('xml', {}) + xml_name = xml_desc.get('name', attr_desc['key']) + xml_prefix = xml_desc.get('prefix', None) + xml_ns = xml_desc.get('ns', None) + 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) + continue + if xml_desc.get("text", False): + serialized.text = new_attr + continue + if isinstance(new_attr, list): + serialized.extend(new_attr) + 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', {}): + splitted_tag = new_attr.tag.split("}") + if len(splitted_tag) == 2: # Namespace + new_attr.tag = "}".join([splitted_tag[0], xml_name]) + else: + new_attr.tag = xml_name + serialized.append(new_attr) + 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) + else: # JSON + for k in reversed(keys): + unflattened = {k: new_attr} + new_attr = unflattened + + _new_attr = new_attr + _serialized = serialized + for k in keys: + if k not in _serialized: + _serialized.update(_new_attr) + _new_attr = _new_attr[k] + _serialized = _serialized[k] + except ValueError: + continue + + except (AttributeError, KeyError, TypeError) as err: + msg = "Attribute {} in object {} cannot be serialized.\n{}".format( + attr_name, class_name, str(target_obj)) + raise_with_traceback(SerializationError, msg, err) + else: + return serialized + + def body(self, data, data_type, **kwargs): + """Serialize data intended for a request body. + + :param data: The data to be serialized. + :param str data_type: The type to be serialized from. + :rtype: dict + :raises: SerializationError if serialization fails. + :raises: ValueError if data is None + """ + + # Just in case this is a dict + internal_data_type = data_type.strip('[]{}') + internal_data_type = self.dependencies.get(internal_data_type, None) + try: + is_xml_model_serialization = kwargs["is_xml"] + except KeyError: + if internal_data_type and issubclass(internal_data_type, Model): + is_xml_model_serialization = kwargs.setdefault("is_xml", internal_data_type.is_xml_model()) + else: + is_xml_model_serialization = False + if internal_data_type and not isinstance(internal_data_type, Enum): + try: + deserializer = Deserializer(self.dependencies) + # Since it's on serialization, it's almost sure that format is not JSON REST + # We're not able to deal with additional properties for now. + deserializer.additional_properties_detection = False + if is_xml_model_serialization: + deserializer.key_extractors = [ + attribute_key_case_insensitive_extractor, + ] + else: + deserializer.key_extractors = [ + rest_key_case_insensitive_extractor, + attribute_key_case_insensitive_extractor, + last_rest_key_case_insensitive_extractor + ] + data = deserializer._deserialize(data_type, data) + except DeserializationError as err: + raise_with_traceback( + SerializationError, "Unable to build a model: "+str(err), err) + + return self._serialize(data, data_type, **kwargs) + + def url(self, name, data, data_type, **kwargs): + """Serialize data intended for a URL path. + + :param data: The data to be serialized. + :param str data_type: The type to be serialized from. + :rtype: str + :raises: TypeError if serialization fails. + :raises: ValueError if data is None + """ + try: + output = self.serialize_data(data, data_type, **kwargs) + if data_type == 'bool': + output = json.dumps(output) + + if kwargs.get('skip_quote') is True: + output = str(output) + else: + output = quote(str(output), safe='') + except SerializationError: + raise TypeError("{} must be type {}.".format(name, data_type)) + else: + return output + + def query(self, name, data, data_type, **kwargs): + """Serialize data intended for a URL query. + + :param data: The data to be serialized. + :param str data_type: The type to be serialized from. + :rtype: str + :raises: TypeError if serialization fails. + :raises: ValueError if data is None + """ + try: + # 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)) + + # Not a list, regular serialization + output = self.serialize_data(data, data_type, **kwargs) + if data_type == 'bool': + output = json.dumps(output) + if kwargs.get('skip_quote') is True: + output = str(output) + else: + output = quote(str(output), safe='') + except SerializationError: + raise TypeError("{} must be type {}.".format(name, data_type)) + else: + return str(output) + + def header(self, name, data, data_type, **kwargs): + """Serialize data intended for a request header. + + :param data: The data to be serialized. + :param str data_type: The type to be serialized from. + :rtype: str + :raises: TypeError if serialization fails. + :raises: ValueError if data is None + """ + try: + if data_type in ['[str]']: + data = ["" if d is None else d for d in data] + + output = self.serialize_data(data, data_type, **kwargs) + if data_type == 'bool': + output = json.dumps(output) + except SerializationError: + raise TypeError("{} must be type {}.".format(name, data_type)) + else: + return str(output) + + def serialize_data(self, data, data_type, **kwargs): + """Serialize generic data according to supplied data type. + + :param data: The data to be serialized. + :param str data_type: The type to be serialized from. + :param bool required: Whether it's essential that the data not be + empty or None + :raises: AttributeError if required data is None. + :raises: ValueError if data is None + :raises: SerializationError if serialization fails. + """ + if data is None: + raise ValueError("No value for given attribute") + + try: + if data_type in self.basic_types.values(): + return self.serialize_basic(data, data_type, **kwargs) + + elif data_type in self.serialize_type: + return self.serialize_type[data_type](data, **kwargs) + + # If dependencies is empty, try with current data class + # It has to be a subclass of Enum anyway + enum_type = self.dependencies.get(data_type, data.__class__) + if issubclass(enum_type, Enum): + return Serializer.serialize_enum(data, enum_obj=enum_type) + + iter_type = data_type[0] + data_type[-1] + if iter_type in self.serialize_type: + return self.serialize_type[iter_type]( + data, data_type[1:-1], **kwargs) + + except (ValueError, TypeError) as err: + msg = "Unable to serialize value: {!r} as type: {!r}." + raise_with_traceback( + SerializationError, msg.format(data, data_type), err) + else: + return self._serialize(data, **kwargs) + + @classmethod + def _get_custom_serializers(cls, data_type, **kwargs): + custom_serializer = kwargs.get("basic_types_serializers", {}).get(data_type) + if custom_serializer: + return custom_serializer + if kwargs.get("is_xml", False): + return cls._xml_basic_types_serializers.get(data_type) + + @classmethod + def serialize_basic(cls, data, data_type, **kwargs): + """Serialize basic builting data type. + Serializes objects to str, int, float or bool. + + Possible kwargs: + - basic_types_serializers dict[str, callable] : If set, use the callable as serializer + - is_xml bool : If set, use xml_basic_types_serializers + + :param data: Object to be serialized. + :param str data_type: Type of object in the iterable. + """ + custom_serializer = cls._get_custom_serializers(data_type, **kwargs) + if custom_serializer: + return custom_serializer(data) + if data_type == 'str': + return cls.serialize_unicode(data) + return eval(data_type)(data) # nosec + + @classmethod + def serialize_unicode(cls, data): + """Special handling for serializing unicode strings in Py2. + Encode to UTF-8 if unicode, otherwise handle as a str. + + :param data: Object to be serialized. + :rtype: str + """ + try: # If I received an enum, return its value + return data.value + except AttributeError: + pass + + try: + if isinstance(data, unicode): + # Don't change it, JSON and XML ElementTree are totally able + # to serialize correctly u'' strings + return data + except NameError: + return str(data) + else: + return str(data) + + def serialize_iter(self, data, iter_type, div=None, **kwargs): + """Serialize iterable. + + Supported kwargs: + - serialization_ctxt dict : The current entry of _attribute_map, or same format. + serialization_ctxt['type'] should be same as data_type. + - is_xml bool : If set, serialize as XML + + :param list attr: Object to be serialized. + :param str iter_type: Type of object in the iterable. + :param bool required: Whether the objects in the iterable must + not be None or empty. + :param str div: If set, this str will be used to combine the elements + in the iterable into a combined string. Default is 'None'. + :rtype: list, str + """ + if isinstance(data, str): + raise SerializationError("Refuse str type as a valid iter type.") + + serialization_ctxt = kwargs.get("serialization_ctxt", {}) + is_xml = kwargs.get("is_xml", False) + + serialized = [] + for d in data: + try: + serialized.append(self.serialize_data(d, iter_type, **kwargs)) + except ValueError: + serialized.append(None) + + if div: + serialized = ['' if s is None else str(s) for s in serialized] + serialized = div.join(serialized) + + if 'xml' in serialization_ctxt or is_xml: + # XML serialization is more complicated + xml_desc = serialization_ctxt.get('xml', {}) + xml_name = xml_desc.get('name') + if not xml_name: + xml_name = serialization_ctxt['key'] + + # Create a wrap node if necessary (use the fact that Element and list have "append") + is_wrapped = xml_desc.get("wrapped", False) + node_name = xml_desc.get("itemsName", xml_name) + if is_wrapped: + final_result = _create_xml_node( + xml_name, + xml_desc.get('prefix', None), + xml_desc.get('ns', None) + ) + else: + final_result = [] + # All list elements to "local_node" + for el in serialized: + if isinstance(el, ET.Element): + el_node = el + else: + el_node = _create_xml_node( + node_name, + xml_desc.get('prefix', None), + xml_desc.get('ns', None) + ) + if el is not None: # Otherwise it writes "None" :-p + el_node.text = str(el) + final_result.append(el_node) + return final_result + return serialized + + def serialize_dict(self, attr, dict_type, **kwargs): + """Serialize a dictionary of objects. + + :param dict attr: Object to be serialized. + :param str dict_type: Type of object in the dictionary. + :param bool required: Whether the objects in the dictionary must + not be None or empty. + :rtype: dict + """ + serialization_ctxt = kwargs.get("serialization_ctxt", {}) + serialized = {} + for key, value in attr.items(): + try: + serialized[self.serialize_unicode(key)] = self.serialize_data( + value, dict_type, **kwargs) + except ValueError: + serialized[self.serialize_unicode(key)] = None + + if 'xml' in serialization_ctxt: + # XML serialization is more complicated + xml_desc = serialization_ctxt['xml'] + xml_name = xml_desc['name'] + + final_result = _create_xml_node( + xml_name, + xml_desc.get('prefix', None), + xml_desc.get('ns', None) + ) + for key, value in serialized.items(): + ET.SubElement(final_result, key).text = value + return final_result + + return serialized + + def serialize_object(self, attr, **kwargs): + """Serialize a generic object. + This will be handled as a dictionary. If object passed in is not + a basic type (str, int, float, dict, list) it will simply be + cast to str. + + :param dict attr: Object to be serialized. + :rtype: dict or str + """ + if attr is None: + return None + if isinstance(attr, ET.Element): + return attr + obj_type = type(attr) + if obj_type in self.basic_types: + return self.serialize_basic(attr, self.basic_types[obj_type], **kwargs) + if obj_type is _long_type: + return self.serialize_long(attr) + if obj_type is unicode_str: + return self.serialize_unicode(attr) + if obj_type is datetime.datetime: + return self.serialize_iso(attr) + if obj_type is datetime.date: + return self.serialize_date(attr) + if obj_type is datetime.time: + return self.serialize_time(attr) + if obj_type is datetime.timedelta: + return self.serialize_duration(attr) + if obj_type is decimal.Decimal: + return self.serialize_decimal(attr) + + # If it's a model or I know this dependency, serialize as a Model + elif obj_type in self.dependencies.values() or isinstance(attr, Model): + return self._serialize(attr) + + if obj_type == dict: + serialized = {} + for key, value in attr.items(): + try: + serialized[self.serialize_unicode(key)] = self.serialize_object( + value, **kwargs) + except ValueError: + serialized[self.serialize_unicode(key)] = None + return serialized + + if obj_type == list: + serialized = [] + for obj in attr: + try: + serialized.append(self.serialize_object( + obj, **kwargs)) + except ValueError: + pass + return serialized + return str(attr) + + @staticmethod + def serialize_enum(attr, enum_obj=None): + try: + result = attr.value + except AttributeError: + result = attr + try: + enum_obj(result) + return result + except ValueError: + for enum_value in enum_obj: + if enum_value.value.lower() == str(attr).lower(): + return enum_value.value + error = "{!r} is not valid value for enum {!r}" + raise SerializationError(error.format(attr, enum_obj)) + + @staticmethod + def serialize_bytearray(attr, **kwargs): + """Serialize bytearray into base-64 string. + + :param attr: Object to be serialized. + :rtype: str + """ + return b64encode(attr).decode() + + @staticmethod + def serialize_base64(attr, **kwargs): + """Serialize str into base-64 string. + + :param attr: Object to be serialized. + :rtype: str + """ + encoded = b64encode(attr).decode('ascii') + return encoded.strip('=').replace('+', '-').replace('/', '_') + + @staticmethod + def serialize_decimal(attr, **kwargs): + """Serialize Decimal object to float. + + :param attr: Object to be serialized. + :rtype: float + """ + return float(attr) + + @staticmethod + def serialize_long(attr, **kwargs): + """Serialize long (Py2) or int (Py3). + + :param attr: Object to be serialized. + :rtype: int/long + """ + return _long_type(attr) + + @staticmethod + def serialize_date(attr, **kwargs): + """Serialize Date object into ISO-8601 formatted string. + + :param Date attr: Object to be serialized. + :rtype: str + """ + if isinstance(attr, str): + attr = isodate.parse_date(attr) + t = "{:04}-{:02}-{:02}".format(attr.year, attr.month, attr.day) + return t + + @staticmethod + def serialize_time(attr, **kwargs): + """Serialize Time object into ISO-8601 formatted string. + + :param datetime.time attr: Object to be serialized. + :rtype: str + """ + if isinstance(attr, str): + attr = isodate.parse_time(attr) + t = "{:02}:{:02}:{:02}".format(attr.hour, attr.minute, attr.second) + if attr.microsecond: + t += ".{:02}".format(attr.microsecond) + return t + + @staticmethod + def serialize_duration(attr, **kwargs): + """Serialize TimeDelta object into ISO-8601 formatted string. + + :param TimeDelta attr: Object to be serialized. + :rtype: str + """ + if isinstance(attr, str): + attr = isodate.parse_duration(attr) + return isodate.duration_isoformat(attr) + + @staticmethod + def serialize_rfc(attr, **kwargs): + """Serialize Datetime object into RFC-1123 formatted string. + + :param Datetime attr: Object to be serialized. + :rtype: str + :raises: TypeError if format invalid. + """ + try: + if not attr.tzinfo: + _LOGGER.warning( + "Datetime with no tzinfo will be considered UTC.") + utc = attr.utctimetuple() + except AttributeError: + raise TypeError("RFC1123 object must be valid Datetime object.") + + return "{}, {:02} {} {:04} {:02}:{:02}:{:02} GMT".format( + Serializer.days[utc.tm_wday], utc.tm_mday, + Serializer.months[utc.tm_mon], utc.tm_year, + utc.tm_hour, utc.tm_min, utc.tm_sec) + + @staticmethod + def serialize_iso(attr, **kwargs): + """Serialize Datetime object into ISO-8601 formatted string. + + :param Datetime attr: Object to be serialized. + :rtype: str + :raises: SerializationError if format invalid. + """ + if isinstance(attr, str): + attr = isodate.parse_datetime(attr) + try: + if not attr.tzinfo: + _LOGGER.warning( + "Datetime with no tzinfo will be considered UTC.") + utc = attr.utctimetuple() + if utc.tm_year > 9999 or utc.tm_year < 1: + raise OverflowError("Hit max or min date") + + microseconds = str(attr.microsecond).rjust(6,'0').rstrip('0').ljust(3, '0') + if microseconds: + microseconds = '.'+microseconds + date = "{:04}-{:02}-{:02}T{:02}:{:02}:{:02}".format( + utc.tm_year, utc.tm_mon, utc.tm_mday, + utc.tm_hour, utc.tm_min, utc.tm_sec) + return date + microseconds + 'Z' + except (ValueError, OverflowError) as err: + msg = "Unable to serialize datetime object." + raise_with_traceback(SerializationError, msg, err) + except AttributeError as err: + msg = "ISO-8601 object must be valid Datetime object." + raise_with_traceback(TypeError, msg, err) + + @staticmethod + def serialize_unix(attr, **kwargs): + """Serialize Datetime object into IntTime format. + This is represented as seconds. + + :param Datetime attr: Object to be serialized. + :rtype: int + :raises: SerializationError if format invalid + """ + if isinstance(attr, int): + return attr + try: + if not attr.tzinfo: + _LOGGER.warning( + "Datetime with no tzinfo will be considered UTC.") + return int(calendar.timegm(attr.utctimetuple())) + except AttributeError: + raise TypeError("Unix time object must be valid Datetime object.") + +def rest_key_extractor(attr, attr_desc, data): + key = attr_desc['key'] + working_data = data + + while '.' in key: + dict_keys = _FLATTEN.split(key) + if len(dict_keys) == 1: + key = _decode_attribute_map_key(dict_keys[0]) + break + working_key = _decode_attribute_map_key(dict_keys[0]) + working_data = working_data.get(working_key, data) + if working_data is None: + # If at any point while following flatten JSON path see None, it means + # that all properties under are None as well + # https://github.com/Azure/msrest-for-python/issues/197 + return None + key = '.'.join(dict_keys[1:]) + + return working_data.get(key) + +def rest_key_case_insensitive_extractor(attr, attr_desc, data): + key = attr_desc['key'] + working_data = data + + while '.' in key: + dict_keys = _FLATTEN.split(key) + if len(dict_keys) == 1: + key = _decode_attribute_map_key(dict_keys[0]) + break + working_key = _decode_attribute_map_key(dict_keys[0]) + working_data = attribute_key_case_insensitive_extractor(working_key, None, working_data) + if working_data is None: + # If at any point while following flatten JSON path see None, it means + # that all properties under are None as well + # https://github.com/Azure/msrest-for-python/issues/197 + return None + key = '.'.join(dict_keys[1:]) + + if working_data: + return attribute_key_case_insensitive_extractor(key, None, working_data) + +def last_rest_key_extractor(attr, attr_desc, data): + """Extract the attribute in "data" based on the last part of the JSON path key. + """ + key = attr_desc['key'] + dict_keys = _FLATTEN.split(key) + return attribute_key_extractor(dict_keys[-1], None, data) + +def last_rest_key_case_insensitive_extractor(attr, attr_desc, data): + """Extract the attribute in "data" based on the last part of the JSON path key. + + This is the case insensitive version of "last_rest_key_extractor" + """ + key = attr_desc['key'] + dict_keys = _FLATTEN.split(key) + return attribute_key_case_insensitive_extractor(dict_keys[-1], None, data) + +def attribute_key_extractor(attr, _, data): + return data.get(attr) + +def attribute_key_case_insensitive_extractor(attr, _, data): + found_key = None + lower_attr = attr.lower() + for key in data: + if lower_attr == key.lower(): + found_key = key + break + + return data.get(found_key) + +def _extract_name_from_internal_type(internal_type): + """Given an internal type XML description, extract correct XML name with namespace. + + :param dict internal_type: An model type + :rtype: tuple + :returns: A tuple XML name + namespace dict + """ + internal_type_xml_map = getattr(internal_type, "_xml_map", {}) + 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) + return xml_name + + +def xml_key_extractor(attr, attr_desc, data): + if isinstance(data, dict): + return None + + # Test if this model is XML ready first + if not isinstance(data, ET.Element): + return None + + xml_desc = attr_desc.get('xml', {}) + xml_name = xml_desc.get('name', attr_desc['key']) + + # Look for a children + is_iter_type = attr_desc['type'].startswith("[") + is_wrapped = xml_desc.get("wrapped", False) + internal_type = attr_desc.get("internalType", None) + internal_type_xml_map = getattr(internal_type, "_xml_map", {}) + + # 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) + + # If it's an attribute, that's simple + if xml_desc.get("attr", False): + return data.get(xml_name) + + # If it's x-ms-text, that's simple too + if xml_desc.get("text", False): + return data.text + + # Scenario where I take the local name: + # - Wrapped node + # - Internal type is an enum (considered basic types) + # - Internal type has no XML/Name node + if is_wrapped or (internal_type and (issubclass(internal_type, Enum) or 'name' not in internal_type_xml_map)): + children = data.findall(xml_name) + # If internal type has a local name and it's not a list, I use that name + elif not is_iter_type and internal_type and 'name' in internal_type_xml_map: + xml_name = _extract_name_from_internal_type(internal_type) + children = data.findall(xml_name) + # That's an array + else: + if internal_type: # Complex type, ignore itemsName and use the complex type name + items_name = _extract_name_from_internal_type(internal_type) + else: + items_name = xml_desc.get("itemsName", xml_name) + children = data.findall(items_name) + + if len(children) == 0: + if is_iter_type: + if is_wrapped: + return None # is_wrapped no node, we want None + else: + return [] # not wrapped, assume empty list + return None # Assume it's not there, maybe an optional node. + + # If is_iter_type and not wrapped, return all found children + if is_iter_type: + if not is_wrapped: + return children + else: # Iter and wrapped, should have found one node only (the wrap one) + if len(children) != 1: + raise DeserializationError( + "Tried to deserialize an array not wrapped, and found several nodes '{}'. Maybe you should declare this array as wrapped?".format( + xml_name + )) + return list(children[0]) # Might be empty list and that's ok. + + # Here it's not a itertype, we should have found one element only or empty + if len(children) > 1: + raise DeserializationError("Find several XML '{}' where it was not expected".format(xml_name)) + return children[0] + +class Deserializer(object): + """Response object model deserializer. + + :param dict classes: Class type dictionary for deserializing complex types. + :ivar list key_extractors: Ordered list of extractors to be used by this deserializer. + """ + + basic_types = {str: 'str', int: 'int', bool: 'bool', float: 'float'} + + valid_date = re.compile( + r'\d{4}[-]\d{2}[-]\d{2}T\d{2}:\d{2}:\d{2}' + r'\.?\d*Z?[-+]?[\d{2}]?:?[\d{2}]?') + + def __init__(self, classes=None): + self.deserialize_type = { + 'iso-8601': Deserializer.deserialize_iso, + 'rfc-1123': Deserializer.deserialize_rfc, + 'unix-time': Deserializer.deserialize_unix, + 'duration': Deserializer.deserialize_duration, + 'date': Deserializer.deserialize_date, + 'time': Deserializer.deserialize_time, + 'decimal': Deserializer.deserialize_decimal, + 'long': Deserializer.deserialize_long, + 'bytearray': Deserializer.deserialize_bytearray, + 'base64': Deserializer.deserialize_base64, + 'object': self.deserialize_object, + '[]': self.deserialize_iter, + '{}': self.deserialize_dict + } + self.deserialize_expected_types = { + 'duration': (isodate.Duration, datetime.timedelta), + 'iso-8601': (datetime.datetime) + } + self.dependencies = 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 + # complicated, with no real scenario for now. + # So adding a flag to disable additional properties detection. This flag should be + # used if your expect the deserialization to NOT come from a JSON REST syntax. + # Otherwise, result are unexpected + self.additional_properties_detection = True + + def __call__(self, target_obj, response_data, content_type=None): + """Call the deserializer to process a REST response. + + :param str target_obj: Target data type to deserialize to. + :param requests.Response response_data: REST response object. + :param str content_type: Swagger "produces" if available. + :raises: DeserializationError if deserialization fails. + :return: Deserialized object. + """ + data = self._unpack_content(response_data, content_type) + return self._deserialize(target_obj, data) + + def _deserialize(self, target_obj, data): + """Call the deserializer on a model. + + Data needs to be already deserialized as JSON or XML ElementTree + + :param str target_obj: Target data type to deserialize to. + :param object data: Object to deserialize. + :raises: DeserializationError if deserialization fails. + :return: Deserialized object. + """ + # This is already a model, go recursive just in case + if hasattr(data, "_attribute_map"): + constants = [name for name, config in getattr(data, '_validation', {}).items() + if config.get('constant')] + try: + for attr, mapconfig in data._attribute_map.items(): + if attr in constants: + continue + value = getattr(data, attr) + if value is None: + continue + local_type = mapconfig['type'] + internal_data_type = local_type.strip('[]{}') + if internal_data_type not in self.dependencies or isinstance(internal_data_type, Enum): + continue + setattr( + data, + attr, + self._deserialize(local_type, value) + ) + return data + except AttributeError: + return + + response, class_name = self._classify_target(target_obj, data) + + if isinstance(response, basestring): + return self.deserialize_data(data, response) + elif isinstance(response, type) and issubclass(response, Enum): + return self.deserialize_enum(data, response) + + if data is None: + return data + try: + attributes = response._attribute_map + d_attrs = {} + for attr, attr_desc in attributes.items(): + # Check empty string. If it's not empty, someone has a real "additionalProperties"... + if attr == "additional_properties" and attr_desc["key"] == '': + continue + raw_value = None + # Enhance attr_desc with some dynamic data + attr_desc = attr_desc.copy() # Do a copy, do not change the real one + internal_data_type = attr_desc["type"].strip('[]{}') + if internal_data_type in self.dependencies: + attr_desc["internalType"] = self.dependencies[internal_data_type] + + for key_extractor in self.key_extractors: + found_value = key_extractor(attr, attr_desc, data) + if found_value is not None: + if raw_value is not None and raw_value != found_value: + msg = ("Ignoring extracted value '%s' from %s for key '%s'" + " (duplicate extraction, follow extractors order)" ) + _LOGGER.warning( + msg, + found_value, + key_extractor, + attr + ) + continue + raw_value = found_value + + 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 + raise_with_traceback(DeserializationError, msg, err) + else: + additional_properties = self._build_additional_properties(attributes, data) + return self._instantiate_model(response, d_attrs, additional_properties) + + def _build_additional_properties(self, attribute_map, data): + if not self.additional_properties_detection: + return None + if "additional_properties" in attribute_map and attribute_map.get("additional_properties", {}).get("key") != '': + # Check empty string. If it's not empty, someone has a real "additionalProperties" + return None + if isinstance(data, ET.Element): + data = {el.tag: el.text for el in data} + + known_keys = {_decode_attribute_map_key(_FLATTEN.split(desc['key'])[0]) + for desc in attribute_map.values() if desc['key'] != ''} + present_keys = set(data.keys()) + missing_keys = present_keys - known_keys + return {key: data[key] for key in missing_keys} + + def _classify_target(self, target, data): + """Check to see whether the deserialization target object can + be classified into a subclass. + 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. + """ + if target is None: + return None, None + + if isinstance(target, basestring): + try: + target = self.dependencies[target] + except KeyError: + return target, target + + try: + target = target._classify(data, self.dependencies) + except AttributeError: + pass # Target is not a Model, no classify + return target, target.__class__.__name__ + + def failsafe_deserialize(self, target_obj, data, content_type=None): + """Ignores any errors encountered in deserialization, + and falls back to not deserializing the object. Recommended + for use in error deserialization, as we want to return the + HttpResponseError to users, and not have them deal with + 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 content_type: Swagger "produces" if available. + """ + try: + return self(target_obj, data, content_type=content_type) + except: + _LOGGER.debug( + "Ran into a deserialization error. Ignoring since this is failsafe deserialization", + exc_info=True + ) + return None + + @staticmethod + def _unpack_content(raw_data, content_type=None): + """Extract the correct structure for deserialization. + + If raw_data is a PipelineResponse, try to extract the result of RawDeserializer. + if we can't, raise. Your Pipeline should have a RawDeserializer. + + If not a pipeline response and raw_data is bytes or string, use content-type + to decode it. If no content-type, try JSON. + + If raw_data is something else, bypass all logic and return it directly. + + :param raw_data: Data to be processed. + :param content_type: How to parse if raw_data is a string/bytes. + :raises JSONDecodeError: If JSON is requested and parsing is impossible. + :raises UnicodeDecodeError: If bytes is not UTF8 + """ + # Assume this is enough to detect a Pipeline Response without importing it + context = getattr(raw_data, "context", {}) + if context: + if RawDeserializer.CONTEXT_NAME in context: + return context[RawDeserializer.CONTEXT_NAME] + raise ValueError("This pipeline didn't have the RawDeserializer policy; can't deserialize") + + #Assume this is enough to recognize universal_http.ClientResponse without importing it + if hasattr(raw_data, "body"): + return RawDeserializer.deserialize_from_http_generics( + raw_data.text(), + raw_data.headers + ) + + # Assume this enough to recognize requests.Response without importing it. + if hasattr(raw_data, '_content_consumed'): + 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 raw_data + + def _instantiate_model(self, response, attrs, additional_properties=None): + """Instantiate a response model passing in deserialized args. + + :param response: The response model class. + :param d_attrs: The deserialized response attributes. + """ + if callable(response): + subtype = getattr(response, '_subtype_map', {}) + try: + readonly = [k for k, v in response._validation.items() + if v.get('readonly')] + const = [k for k, v in response._validation.items() + if v.get('constant')] + kwargs = {k: v for k, v in attrs.items() + if k not in subtype and k not in readonly + const} + response_obj = response(**kwargs) + for attr in readonly: + setattr(response_obj, attr, attrs.get(attr)) + if additional_properties: + response_obj.additional_properties = additional_properties + return response_obj + except TypeError as err: + msg = "Unable to deserialize {} into model {}. ".format( + kwargs, response) + raise DeserializationError(msg + str(err)) + else: + try: + for attr, value in attrs.items(): + setattr(response, attr, value) + return response + except Exception as exp: + msg = "Unable to populate response model. " + msg += "Type: {}, Error: {}".format(type(response), exp) + raise DeserializationError(msg) + + def deserialize_data(self, data, data_type): + """Process data for deserialization according to data type. + + :param str data: The response string to be deserialized. + :param str data_type: The type to deserialize to. + :raises: DeserializationError if deserialization fails. + :return: Deserialized object. + """ + if data is None: + return data + + try: + if not data_type: + return data + if data_type in self.basic_types.values(): + return self.deserialize_basic(data, data_type) + if data_type in self.deserialize_type: + if isinstance(data, self.deserialize_expected_types.get(data_type, tuple())): + return data + + is_a_text_parsing_type = lambda x: x not in ["object", "[]", r"{}"] + if isinstance(data, ET.Element) and is_a_text_parsing_type(data_type) and not data.text: + return None + data_val = self.deserialize_type[data_type](data) + return data_val + + iter_type = data_type[0] + data_type[-1] + if iter_type in self.deserialize_type: + return self.deserialize_type[iter_type](data, data_type[1:-1]) + + obj_type = self.dependencies[data_type] + if issubclass(obj_type, Enum): + if isinstance(data, ET.Element): + data = data.text + return self.deserialize_enum(data, obj_type) + + except (ValueError, TypeError, AttributeError) as err: + msg = "Unable to deserialize response data." + msg += " Data: {}, {}".format(data, data_type) + raise_with_traceback(DeserializationError, msg, err) + else: + return self._deserialize(obj_type, data) + + def deserialize_iter(self, attr, iter_type): + """Deserialize an iterable. + + :param list attr: Iterable to be deserialized. + :param str iter_type: The type of object in the iterable. + :rtype: list + """ + if attr is None: + return None + if isinstance(attr, ET.Element): # If I receive an element here, get the children + attr = list(attr) + if not isinstance(attr, (list, set)): + raise DeserializationError("Cannot deserialize as [{}] an object of type {}".format( + iter_type, + type(attr) + )) + return [self.deserialize_data(a, iter_type) for a in attr] + + def deserialize_dict(self, attr, dict_type): + """Deserialize a dictionary. + + :param dict/list attr: Dictionary to be deserialized. Also accepts + a list of key, value pairs. + :param str dict_type: The object type of the items in the dictionary. + :rtype: dict + """ + if isinstance(attr, list): + return {x['key']: self.deserialize_data(x['value'], dict_type) for x in attr} + + if isinstance(attr, ET.Element): + # Transform value into {"Key": "value"} + attr = {el.tag: el.text for el in attr} + return {k: self.deserialize_data(v, dict_type) for k, v in attr.items()} + + def deserialize_object(self, attr, **kwargs): + """Deserialize a generic object. + This will be handled as a dictionary. + + :param dict attr: Dictionary to be deserialized. + :rtype: dict + :raises: TypeError if non-builtin datatype encountered. + """ + if attr is None: + return None + if isinstance(attr, ET.Element): + # Do no recurse on XML, just return the tree as-is + return attr + if isinstance(attr, basestring): + return self.deserialize_basic(attr, 'str') + obj_type = type(attr) + if obj_type in self.basic_types: + return self.deserialize_basic(attr, self.basic_types[obj_type]) + if obj_type is _long_type: + return self.deserialize_long(attr) + + if obj_type == dict: + deserialized = {} + for key, value in attr.items(): + try: + deserialized[key] = self.deserialize_object( + value, **kwargs) + except ValueError: + deserialized[key] = None + return deserialized + + if obj_type == list: + deserialized = [] + for obj in attr: + try: + deserialized.append(self.deserialize_object( + obj, **kwargs)) + except ValueError: + pass + return deserialized + + else: + error = "Cannot deserialize generic object with type: " + raise TypeError(error + str(obj_type)) + + def deserialize_basic(self, attr, data_type): + """Deserialize basic builtin data type from string. + Will attempt to convert to str, int, float and bool. + This function will also accept '1', '0', 'true' and 'false' as + valid bool values. + + :param str attr: response string to be deserialized. + :param str data_type: deserialization data type. + :rtype: str, int, float or bool + :raises: TypeError if string format is not valid. + """ + # If we're here, data is supposed to be a basic type. + # If it's still an XML node, take the text + if isinstance(attr, ET.Element): + attr = attr.text + if not attr: + if data_type == "str": + # None or '', node is empty string. + return '' + else: + # None or '', node with a strong type is None. + # Don't try to model "empty bool" or "empty int" + return None + + if data_type == 'bool': + if attr in [True, False, 1, 0]: + return bool(attr) + elif isinstance(attr, basestring): + if attr.lower() in ['true', '1']: + return True + elif attr.lower() in ['false', '0']: + return False + raise TypeError("Invalid boolean value: {}".format(attr)) + + if data_type == 'str': + return self.deserialize_unicode(attr) + return eval(data_type)(attr) # nosec + + @staticmethod + def deserialize_unicode(data): + """Preserve unicode objects in Python 2, otherwise return data + as a string. + + :param str data: response string to be deserialized. + :rtype: str or unicode + """ + # We might be here because we have an enum modeled as string, + # and we try to deserialize a partial dict with enum inside + if isinstance(data, Enum): + return data + + # Consider this is real string + try: + if isinstance(data, unicode): + return data + except NameError: + return str(data) + else: + return str(data) + + @staticmethod + def deserialize_enum(data, enum_obj): + """Deserialize string into enum object. + + If the string is not a valid enum value it will be returned as-is + and a warning will be logged. + + :param str data: Response string to be deserialized. If this value is + None or invalid it will be returned as-is. + :param Enum enum_obj: Enum object to deserialize to. + :rtype: Enum + """ + if isinstance(data, enum_obj) or data is None: + return data + if isinstance(data, Enum): + data = data.value + if isinstance(data, int): + # Workaround. We might consider remove it in the future. + # https://github.com/Azure/azure-rest-api-specs/issues/141 + try: + return list(enum_obj.__members__.values())[data] + except IndexError: + error = "{!r} is not a valid index for enum {!r}" + raise DeserializationError(error.format(data, enum_obj)) + try: + return enum_obj(str(data)) + except ValueError: + for enum_value in enum_obj: + if enum_value.value.lower() == str(data).lower(): + return enum_value + # We don't fail anymore for unknown value, we deserialize as a string + _LOGGER.warning("Deserializer is not able to find %s as valid enum in %s", data, enum_obj) + return Deserializer.deserialize_unicode(data) + + @staticmethod + def deserialize_bytearray(attr): + """Deserialize string into bytearray. + + :param str attr: response string to be deserialized. + :rtype: bytearray + :raises: TypeError if string format invalid. + """ + if isinstance(attr, ET.Element): + attr = attr.text + return bytearray(b64decode(attr)) + + @staticmethod + def deserialize_base64(attr): + """Deserialize base64 encoded string into string. + + :param str attr: response string to be deserialized. + :rtype: bytearray + :raises: TypeError if string format invalid. + """ + if isinstance(attr, ET.Element): + attr = attr.text + padding = '=' * (3 - (len(attr) + 3) % 4) + attr = attr + padding + encoded = attr.replace('-', '+').replace('_', '/') + return b64decode(encoded) + + @staticmethod + def deserialize_decimal(attr): + """Deserialize string into Decimal object. + + :param str attr: response string to be deserialized. + :rtype: Decimal + :raises: DeserializationError if string format invalid. + """ + if isinstance(attr, ET.Element): + attr = attr.text + try: + return decimal.Decimal(attr) + except decimal.DecimalException as err: + msg = "Invalid decimal {}".format(attr) + raise_with_traceback(DeserializationError, msg, err) + + @staticmethod + def deserialize_long(attr): + """Deserialize string into long (Py2) or int (Py3). + + :param str attr: response string to be deserialized. + :rtype: long or int + :raises: ValueError if string format invalid. + """ + if isinstance(attr, ET.Element): + attr = attr.text + return _long_type(attr) + + @staticmethod + def deserialize_duration(attr): + """Deserialize ISO-8601 formatted string into TimeDelta object. + + :param str attr: response string to be deserialized. + :rtype: TimeDelta + :raises: DeserializationError if string format invalid. + """ + if isinstance(attr, ET.Element): + attr = attr.text + try: + duration = isodate.parse_duration(attr) + except(ValueError, OverflowError, AttributeError) as err: + msg = "Cannot deserialize duration object." + raise_with_traceback(DeserializationError, msg, err) + else: + return duration + + @staticmethod + def deserialize_date(attr): + """Deserialize ISO-8601 formatted string into Date object. + + :param str attr: response string to be deserialized. + :rtype: Date + :raises: DeserializationError if string format invalid. + """ + if isinstance(attr, ET.Element): + attr = attr.text + if re.search(r"[^\W\d_]", attr, re.I + re.U): + 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) + + @staticmethod + def deserialize_time(attr): + """Deserialize ISO-8601 formatted string into time object. + + :param str attr: response string to be deserialized. + :rtype: datetime.time + :raises: DeserializationError if string format invalid. + """ + if isinstance(attr, ET.Element): + attr = attr.text + if re.search(r"[^\W\d_]", attr, re.I + re.U): + raise DeserializationError("Date must have only digits and -. Received: %s" % attr) + return isodate.parse_time(attr) + + @staticmethod + def deserialize_rfc(attr): + """Deserialize RFC-1123 formatted string into Datetime object. + + :param str attr: response string to be deserialized. + :rtype: Datetime + :raises: DeserializationError if string format invalid. + """ + if isinstance(attr, ET.Element): + attr = attr.text + try: + parsed_date = email.utils.parsedate_tz(attr) + date_obj = datetime.datetime( + *parsed_date[:6], + tzinfo=_FixedOffset(datetime.timedelta(minutes=(parsed_date[9] or 0)/60)) + ) + if not date_obj.tzinfo: + date_obj = date_obj.astimezone(tz=TZ_UTC) + except ValueError as err: + msg = "Cannot deserialize to rfc datetime object." + raise_with_traceback(DeserializationError, msg, err) + else: + return date_obj + + @staticmethod + def deserialize_iso(attr): + """Deserialize ISO-8601 formatted string into Datetime object. + + :param str attr: response string to be deserialized. + :rtype: Datetime + :raises: DeserializationError if string format invalid. + """ + if isinstance(attr, ET.Element): + attr = attr.text + try: + attr = attr.upper() + match = Deserializer.valid_date.match(attr) + if not match: + raise ValueError("Invalid datetime string: " + attr) + + check_decimal = attr.split('.') + if len(check_decimal) > 1: + decimal_str = "" + for digit in check_decimal[1]: + if digit.isdigit(): + decimal_str += digit + else: + break + if len(decimal_str) > 6: + attr = attr.replace(decimal_str, decimal_str[0:6]) + + date_obj = isodate.parse_datetime(attr) + test_utc = date_obj.utctimetuple() + if test_utc.tm_year > 9999 or test_utc.tm_year < 1: + raise OverflowError("Hit max or min date") + except(ValueError, OverflowError, AttributeError) as err: + msg = "Cannot deserialize datetime object." + raise_with_traceback(DeserializationError, msg, err) + else: + return date_obj + + @staticmethod + def deserialize_unix(attr): + """Serialize Datetime object into IntTime format. + This is represented as seconds. + + :param int attr: Object to be serialized. + :rtype: Datetime + :raises: DeserializationError if format invalid + """ + if isinstance(attr, ET.Element): + attr = int(attr.text) + try: + date_obj = datetime.datetime.fromtimestamp(attr, TZ_UTC) + except ValueError as err: + msg = "Cannot deserialize to unix datetime object." + raise_with_traceback(DeserializationError, msg, err) + else: + return date_obj diff --git a/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/managedapplications/aio/__init__.py b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/managedapplications/aio/__init__.py index 45c4790ba3ab1..42ac8700d5dff 100644 --- a/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/managedapplications/aio/__init__.py +++ b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/managedapplications/aio/__init__.py @@ -8,8 +8,3 @@ from ._application_client import ApplicationClient __all__ = ['ApplicationClient'] - -# `._patch.py` is used for handwritten extensions to the generated code -# Example: https://github.com/Azure/azure-sdk-for-python/blob/main/doc/dev/customize_code/how-to-patch-sdk-code.md -from ._patch import patch_sdk -patch_sdk() diff --git a/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/managedapplications/aio/_application_client.py b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/managedapplications/aio/_application_client.py index e808560f6374c..1d5efaf31f9bd 100644 --- a/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/managedapplications/aio/_application_client.py +++ b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/managedapplications/aio/_application_client.py @@ -1,99 +1,129 @@ # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. -# Licensed under the MIT License. See License.txt in the project root for license information. +# Licensed under the MIT License. See License.txt in the project root for +# license information. +# # Code generated by Microsoft (R) AutoRest Code Generator. -# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# Changes may cause incorrect behavior and will be lost if the code is +# regenerated. # -------------------------------------------------------------------------- -from copy import deepcopy -from typing import Any, Awaitable, TYPE_CHECKING +from typing import Any, Optional, TYPE_CHECKING -from msrest import Deserializer, Serializer - -from azure.core.rest import AsyncHttpResponse, HttpRequest from azure.mgmt.core import AsyncARMPipelineClient +from azure.profiles import KnownProfiles, ProfileDefinition +from azure.profiles.multiapiclient import MultiApiClientMixin -from .. import models +from .._serialization import Deserializer, Serializer from ._configuration import ApplicationClientConfiguration -from .operations import ApplicationClientOperationsMixin, ApplicationDefinitionsOperations, ApplicationsOperations +from ._operations_mixin import ApplicationClientOperationsMixin if TYPE_CHECKING: # pylint: disable=unused-import,ungrouped-imports from azure.core.credentials_async import AsyncTokenCredential -class ApplicationClient(ApplicationClientOperationsMixin): +class _SDKClient(object): + def __init__(self, *args, **kwargs): + """This is a fake class to support current implemetation of MultiApiClientMixin." + Will be removed in final version of multiapi azure-core based client + """ + pass + +class ApplicationClient(ApplicationClientOperationsMixin, MultiApiClientMixin, _SDKClient): """ARM applications. - :ivar applications: ApplicationsOperations operations - :vartype applications: - azure.mgmt.resource.managedapplications.aio.operations.ApplicationsOperations - :ivar application_definitions: ApplicationDefinitionsOperations operations - :vartype application_definitions: - azure.mgmt.resource.managedapplications.aio.operations.ApplicationDefinitionsOperations - :param credential: Credential needed for the client to connect to Azure. + This ready contains multiple API versions, to help you deal with all of the Azure clouds + (Azure Stack, Azure Government, Azure China, etc.). + By default, it uses the latest API version available on public Azure. + For production, you should stick to a particular api-version and/or profile. + The profile sets a mapping between an operation group and its API version. + The api-version parameter sets the default API version if the operation + group is not described in the profile. + + :param credential: Credential needed for the client to connect to Azure. Required. :type credential: ~azure.core.credentials_async.AsyncTokenCredential - :param subscription_id: The ID of the target subscription. + :param subscription_id: The ID of the target subscription. Required. :type subscription_id: str - :param base_url: Service URL. Default value is "https://management.azure.com". + :param api_version: API version to use if no profile is provided, or if missing in profile. + :type api_version: str + :param base_url: Service URL :type base_url: str - :keyword api_version: Api Version. Default value is "2018-06-01". Note that overriding this - default value may result in unsupported behavior. - :paramtype api_version: str - :keyword int polling_interval: Default waiting time between two polls for LRO operations if no - Retry-After header is present. + :param profile: A profile definition, from KnownProfiles to dict. + :type profile: azure.profiles.KnownProfiles + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no Retry-After header is present. """ + DEFAULT_API_VERSION = '2018-06-01' + _PROFILE_TAG = "azure.mgmt.resource.managedapplications.ApplicationClient" + LATEST_PROFILE = ProfileDefinition({ + _PROFILE_TAG: { + None: DEFAULT_API_VERSION, + }}, + _PROFILE_TAG + " latest" + ) + def __init__( self, credential: "AsyncTokenCredential", subscription_id: str, + api_version: Optional[str] = None, base_url: str = "https://management.azure.com", - **kwargs: Any + profile: KnownProfiles = KnownProfiles.default, + **kwargs # type: Any ) -> None: - self._config = ApplicationClientConfiguration(credential=credential, subscription_id=subscription_id, **kwargs) + self._config = ApplicationClientConfiguration(credential, subscription_id, **kwargs) self._client = AsyncARMPipelineClient(base_url=base_url, config=self._config, **kwargs) + super(ApplicationClient, self).__init__( + api_version=api_version, + profile=profile + ) - 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 - self.applications = ApplicationsOperations(self._client, self._config, self._serialize, self._deserialize) - self.application_definitions = ApplicationDefinitionsOperations(self._client, self._config, self._serialize, self._deserialize) + @classmethod + def _models_dict(cls, api_version): + return {k: v for k, v in cls.models(api_version).__dict__.items() if isinstance(v, type)} + @classmethod + def models(cls, api_version=DEFAULT_API_VERSION): + """Module depends on the API version: - def _send_request( - self, - request: HttpRequest, - **kwargs: Any - ) -> Awaitable[AsyncHttpResponse]: - """Runs the network request through the client's chained policies. - - >>> from azure.core.rest import HttpRequest - >>> request = HttpRequest("GET", "https://www.example.org/") - - >>> response = await client._send_request(request) - - - For more information on this code flow, see https://aka.ms/azsdk/python/protocol/quickstart - - :param request: The network request you want to make. Required. - :type request: ~azure.core.rest.HttpRequest - :keyword bool stream: Whether the response payload will be streamed. Defaults to False. - :return: The response of your network call. Does not do error handling on your response. - :rtype: ~azure.core.rest.AsyncHttpResponse + * 2018-06-01: :mod:`v2018_06_01.models` """ + if api_version == '2018-06-01': + from ..v2018_06_01 import models + return models + raise ValueError("API version {} is not available".format(api_version)) - request_copy = deepcopy(request) - request_copy.url = self._client.format_url(request_copy.url) - return self._client.send_request(request_copy, **kwargs) + @property + def application_definitions(self): + """Instance depends on the API version: - async def close(self) -> None: + * 2018-06-01: :class:`ApplicationDefinitionsOperations` + """ + api_version = self._get_api_version('application_definitions') + if api_version == '2018-06-01': + from ..v2018_06_01.aio.operations import ApplicationDefinitionsOperations as OperationClass + else: + raise ValueError("API version {} does not have operation group 'application_definitions'".format(api_version)) + return OperationClass(self._client, self._config, Serializer(self._models_dict(api_version)), Deserializer(self._models_dict(api_version))) + + @property + def applications(self): + """Instance depends on the API version: + + * 2018-06-01: :class:`ApplicationsOperations` + """ + api_version = self._get_api_version('applications') + if api_version == '2018-06-01': + from ..v2018_06_01.aio.operations import ApplicationsOperations as OperationClass + else: + raise ValueError("API version {} does not have operation group 'applications'".format(api_version)) + return OperationClass(self._client, self._config, Serializer(self._models_dict(api_version)), Deserializer(self._models_dict(api_version))) + + async def close(self): await self._client.close() - - async def __aenter__(self) -> "ApplicationClient": + async def __aenter__(self): await self._client.__aenter__() return self - - async def __aexit__(self, *exc_details) -> None: + async def __aexit__(self, *exc_details): await self._client.__aexit__(*exc_details) diff --git a/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/managedapplications/aio/_configuration.py b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/managedapplications/aio/_configuration.py index ba545312e9167..989ae032af090 100644 --- a/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/managedapplications/aio/_configuration.py +++ b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/managedapplications/aio/_configuration.py @@ -1,11 +1,13 @@ # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. -# Licensed under the MIT License. See License.txt in the project root for license information. +# Licensed under the MIT License. See License.txt in the project root for +# license information. +# # Code generated by Microsoft (R) AutoRest Code Generator. -# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# Changes may cause incorrect behavior and will be lost if the code is +# regenerated. # -------------------------------------------------------------------------- - from typing import Any, TYPE_CHECKING from azure.core.configuration import Configuration @@ -18,41 +20,34 @@ # pylint: disable=unused-import,ungrouped-imports from azure.core.credentials_async import AsyncTokenCredential - -class ApplicationClientConfiguration(Configuration): # pylint: disable=too-many-instance-attributes +class ApplicationClientConfiguration(Configuration): """Configuration for ApplicationClient. Note that all parameters used to create this instance are saved as instance attributes. - :param credential: Credential needed for the client to connect to Azure. + :param credential: Credential needed for the client to connect to Azure. Required. :type credential: ~azure.core.credentials_async.AsyncTokenCredential - :param subscription_id: The ID of the target subscription. + :param subscription_id: The ID of the target subscription. Required. :type subscription_id: str - :keyword api_version: Api Version. Default value is "2018-06-01". Note that overriding this - default value may result in unsupported behavior. - :paramtype api_version: str """ def __init__( self, credential: "AsyncTokenCredential", subscription_id: str, - **kwargs: Any + **kwargs # type: Any ) -> None: - super(ApplicationClientConfiguration, self).__init__(**kwargs) - api_version = kwargs.pop('api_version', "2018-06-01") # type: str - if credential is None: raise ValueError("Parameter 'credential' must not be None.") if subscription_id is None: raise ValueError("Parameter 'subscription_id' must not be None.") + super(ApplicationClientConfiguration, self).__init__(**kwargs) self.credential = credential self.subscription_id = subscription_id - self.api_version = api_version self.credential_scopes = kwargs.pop('credential_scopes', ['https://management.azure.com/.default']) - kwargs.setdefault('sdk_moniker', 'mgmt-resource/{}'.format(VERSION)) + kwargs.setdefault('sdk_moniker', 'azure-mgmt-resource/{}'.format(VERSION)) self._configure(**kwargs) def _configure( diff --git a/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/managedapplications/aio/_operations_mixin.py b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/managedapplications/aio/_operations_mixin.py new file mode 100644 index 0000000000000..dc6a2e8292442 --- /dev/null +++ b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/managedapplications/aio/_operations_mixin.py @@ -0,0 +1,44 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for +# license information. +# +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is +# regenerated. +# -------------------------------------------------------------------------- +from .._serialization import Serializer, Deserializer +from typing import Any, AsyncIterable + +from azure.core.async_paging import AsyncItemPaged + +from .. import models as _models + + +class ApplicationClientOperationsMixin(object): + + def list_operations( + self, + **kwargs: Any + ) -> AsyncIterable["_models.Operation"]: + """Lists all of the available Microsoft.Solutions REST API operations. + + :keyword callable cls: A custom type or function that will be passed the direct response + :return: An iterator like instance of either Operation or the result of cls(response) + :rtype: + ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.resource.managedapplications.v2018_06_01.models.Operation] + :raises ~azure.core.exceptions.HttpResponseError: + """ + api_version = self._get_api_version('list_operations') + if api_version == '2018-06-01': + from ..v2018_06_01.aio.operations import ApplicationClientOperationsMixin as OperationClass + else: + raise ValueError("API version {} does not have operation 'list_operations'".format(api_version)) + mixin_instance = OperationClass() + mixin_instance._client = self._client + mixin_instance._config = self._config + mixin_instance._serialize = Serializer(self._models_dict(api_version)) + mixin_instance._serialize.client_side_validation = False + mixin_instance._deserialize = Deserializer(self._models_dict(api_version)) + return mixin_instance.list_operations(**kwargs) diff --git a/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/managedapplications/aio/_patch.py b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/managedapplications/aio/_patch.py deleted file mode 100644 index 74e48ecd07cf3..0000000000000 --- a/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/managedapplications/aio/_patch.py +++ /dev/null @@ -1,31 +0,0 @@ -# coding=utf-8 -# -------------------------------------------------------------------------- -# -# Copyright (c) Microsoft Corporation. All rights reserved. -# -# The MIT License (MIT) -# -# Permission is hereby granted, free of charge, to any person obtaining a copy -# of this software and associated documentation files (the ""Software""), to -# deal in the Software without restriction, including without limitation the -# rights to use, copy, modify, merge, publish, distribute, sublicense, and/or -# sell copies of the Software, and to permit persons to whom the Software is -# furnished to do so, subject to the following conditions: -# -# The above copyright notice and this permission notice shall be included in -# all copies or substantial portions of the Software. -# -# THE SOFTWARE IS PROVIDED *AS IS*, WITHOUT WARRANTY OF ANY KIND, EXPRESS OR -# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, -# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE -# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER -# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING -# FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS -# IN THE SOFTWARE. -# -# -------------------------------------------------------------------------- - -# This file is used for handwritten extensions to the generated code. Example: -# https://github.com/Azure/azure-sdk-for-python/blob/main/doc/dev/customize_code/how-to-patch-sdk-code.md -def patch_sdk(): - pass \ No newline at end of file diff --git a/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/managedapplications/aio/operations/_operations.py b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/managedapplications/aio/operations/_operations.py deleted file mode 100644 index 16cd9d4021b98..0000000000000 --- a/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/managedapplications/aio/operations/_operations.py +++ /dev/null @@ -1,1668 +0,0 @@ -# pylint: disable=too-many-lines -# coding=utf-8 -# -------------------------------------------------------------------------- -# Copyright (c) Microsoft Corporation. All rights reserved. -# Licensed under the MIT License. See License.txt in the project root for license information. -# Code generated by Microsoft (R) AutoRest Code Generator. -# Changes may cause incorrect behavior and will be lost if the code is regenerated. -# -------------------------------------------------------------------------- -from typing import Any, AsyncIterable, Callable, Dict, Optional, TypeVar, Union - -from azure.core.async_paging import AsyncItemPaged, AsyncList -from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error -from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import AsyncHttpResponse -from azure.core.polling import AsyncLROPoller, AsyncNoPolling, AsyncPollingMethod -from azure.core.rest import HttpRequest -from azure.core.tracing.decorator import distributed_trace -from azure.core.tracing.decorator_async import distributed_trace_async -from azure.mgmt.core.exceptions import ARMErrorFormat -from azure.mgmt.core.polling.async_arm_polling import AsyncARMPolling - -from ... import models as _models -from ..._vendor import _convert_request -from ...operations._operations import build_application_definitions_create_or_update_by_id_request_initial, build_application_definitions_create_or_update_request_initial, build_application_definitions_delete_by_id_request_initial, build_application_definitions_delete_request_initial, build_application_definitions_get_by_id_request, build_application_definitions_get_request, build_application_definitions_list_by_resource_group_request, build_applications_create_or_update_by_id_request_initial, build_applications_create_or_update_request_initial, build_applications_delete_by_id_request_initial, build_applications_delete_request_initial, build_applications_get_by_id_request, build_applications_get_request, build_applications_list_by_resource_group_request, build_applications_list_by_subscription_request, build_applications_update_by_id_request, build_applications_update_request, build_list_operations_request -T = TypeVar('T') -ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] - -class ApplicationClientOperationsMixin: - - @distributed_trace - def list_operations( - self, - **kwargs: Any - ) -> AsyncIterable["_models.OperationListResult"]: - """Lists all of the available Microsoft.Solutions REST API operations. - - :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either OperationListResult or the result of cls(response) - :rtype: - ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.resource.managedapplications.models.OperationListResult] - :raises: ~azure.core.exceptions.HttpResponseError - """ - api_version = kwargs.pop('api_version', "2018-06-01") # type: str - - cls = kwargs.pop('cls', None) # type: ClsType["_models.OperationListResult"] - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {})) - def prepare_request(next_link=None): - if not next_link: - - request = build_list_operations_request( - api_version=api_version, - template_url=self.list_operations.metadata['url'], - ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) - - else: - - request = build_list_operations_request( - template_url=next_link, - ) - 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("OperationListResult", pipeline_response) - list_of_elem = deserialized.value - if cls: - list_of_elem = cls(list_of_elem) - 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( # pylint: disable=protected-access - request, - stream=False, - **kwargs - ) - response = pipeline_response.http_response - - if response.status_code not in [200]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - raise HttpResponseError(response=response, error_format=ARMErrorFormat) - - return pipeline_response - - - return AsyncItemPaged( - get_next, extract_data - ) - list_operations.metadata = {'url': "/providers/Microsoft.Solutions/operations"} # type: ignore -class ApplicationsOperations: - """ApplicationsOperations async operations. - - You should not instantiate this class directly. Instead, you should create a Client instance that - instantiates it for you and attaches it as an attribute. - - :ivar models: Alias to model classes used in this operation group. - :type models: ~azure.mgmt.resource.managedapplications.models - :param client: Client for service requests. - :param config: Configuration of service client. - :param serializer: An object model serializer. - :param deserializer: An object model deserializer. - """ - - models = _models - - def __init__(self, client, config, serializer, deserializer) -> None: - self._client = client - self._serialize = serializer - self._deserialize = deserializer - self._config = config - - @distributed_trace_async - async def get( - self, - resource_group_name: str, - application_name: str, - **kwargs: Any - ) -> Optional["_models.Application"]: - """Gets the managed application. - - :param resource_group_name: The name of the resource group. The name is case insensitive. - :type resource_group_name: str - :param application_name: The name of the managed application. - :type application_name: str - :keyword callable cls: A custom type or function that will be passed the direct response - :return: Application, or the result of cls(response) - :rtype: ~azure.mgmt.resource.managedapplications.models.Application or None - :raises: ~azure.core.exceptions.HttpResponseError - """ - cls = kwargs.pop('cls', None) # type: ClsType[Optional["_models.Application"]] - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {})) - - api_version = kwargs.pop('api_version', "2018-06-01") # type: str - - - request = build_applications_get_request( - resource_group_name=resource_group_name, - application_name=application_name, - subscription_id=self._config.subscription_id, - api_version=api_version, - template_url=self.get.metadata['url'], - ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) - - pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs - ) - response = pipeline_response.http_response - - if response.status_code not in [200, 404]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) - raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - - deserialized = None - if response.status_code == 200: - deserialized = self._deserialize('Application', pipeline_response) - - if cls: - return cls(pipeline_response, deserialized, {}) - - return deserialized - - get.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Solutions/applications/{applicationName}"} # type: ignore - - - async def _delete_initial( # pylint: disable=inconsistent-return-statements - self, - resource_group_name: str, - application_name: str, - **kwargs: Any - ) -> None: - cls = kwargs.pop('cls', None) # type: ClsType[None] - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {})) - - api_version = kwargs.pop('api_version', "2018-06-01") # type: str - - - request = build_applications_delete_request_initial( - resource_group_name=resource_group_name, - application_name=application_name, - subscription_id=self._config.subscription_id, - api_version=api_version, - template_url=self._delete_initial.metadata['url'], - ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) - - pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs - ) - response = pipeline_response.http_response - - if response.status_code not in [202, 204]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - raise HttpResponseError(response=response, error_format=ARMErrorFormat) - - if cls: - return cls(pipeline_response, None, {}) - - _delete_initial.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Solutions/applications/{applicationName}"} # type: ignore - - - @distributed_trace_async - async def begin_delete( # pylint: disable=inconsistent-return-statements - self, - resource_group_name: str, - application_name: str, - **kwargs: Any - ) -> AsyncLROPoller[None]: - """Deletes the managed application. - - :param resource_group_name: The name of the resource group. The name is case insensitive. - :type resource_group_name: str - :param application_name: The name of the managed application. - :type application_name: str - :keyword callable cls: A custom type or function that will be passed the direct response - :keyword str continuation_token: A continuation token to restart a poller from a saved state. - :keyword polling: By default, your polling method will be AsyncARMPolling. Pass in False for - this operation to not poll, or pass in your own initialized polling object for a personal - polling strategy. - :paramtype polling: bool or ~azure.core.polling.AsyncPollingMethod - :keyword int polling_interval: Default waiting time between two polls for LRO operations if no - Retry-After header is present. - :return: An instance of AsyncLROPoller that returns either None or the result of cls(response) - :rtype: ~azure.core.polling.AsyncLROPoller[None] - :raises: ~azure.core.exceptions.HttpResponseError - """ - api_version = kwargs.pop('api_version', "2018-06-01") # type: str - polling = kwargs.pop('polling', True) # type: Union[bool, AsyncPollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType[None] - lro_delay = kwargs.pop( - 'polling_interval', - self._config.polling_interval - ) - cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] - if cont_token is None: - raw_result = await self._delete_initial( - resource_group_name=resource_group_name, - application_name=application_name, - api_version=api_version, - cls=lambda x,y,z: x, - **kwargs - ) - kwargs.pop('error_map', None) - - def get_long_running_output(pipeline_response): - if cls: - return cls(pipeline_response, None, {}) - - - if polling is True: polling_method = AsyncARMPolling(lro_delay, **kwargs) - elif polling is False: polling_method = AsyncNoPolling() - else: polling_method = polling - if cont_token: - return AsyncLROPoller.from_continuation_token( - polling_method=polling_method, - continuation_token=cont_token, - client=self._client, - deserialization_callback=get_long_running_output - ) - return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) - - begin_delete.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Solutions/applications/{applicationName}"} # type: ignore - - async def _create_or_update_initial( - self, - resource_group_name: str, - application_name: str, - parameters: "_models.Application", - **kwargs: Any - ) -> "_models.Application": - cls = kwargs.pop('cls', None) # type: ClsType["_models.Application"] - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {})) - - api_version = kwargs.pop('api_version', "2018-06-01") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] - - _json = self._serialize.body(parameters, 'Application') - - request = build_applications_create_or_update_request_initial( - resource_group_name=resource_group_name, - application_name=application_name, - subscription_id=self._config.subscription_id, - api_version=api_version, - content_type=content_type, - json=_json, - template_url=self._create_or_update_initial.metadata['url'], - ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) - - pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs - ) - response = pipeline_response.http_response - - if response.status_code not in [200, 201]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - raise HttpResponseError(response=response, error_format=ARMErrorFormat) - - if response.status_code == 200: - deserialized = self._deserialize('Application', pipeline_response) - - if response.status_code == 201: - deserialized = self._deserialize('Application', pipeline_response) - - if cls: - return cls(pipeline_response, deserialized, {}) - - return deserialized - - _create_or_update_initial.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Solutions/applications/{applicationName}"} # type: ignore - - - @distributed_trace_async - async def begin_create_or_update( - self, - resource_group_name: str, - application_name: str, - parameters: "_models.Application", - **kwargs: Any - ) -> AsyncLROPoller["_models.Application"]: - """Creates a new managed application. - - :param resource_group_name: The name of the resource group. The name is case insensitive. - :type resource_group_name: str - :param application_name: The name of the managed application. - :type application_name: str - :param parameters: Parameters supplied to the create or update a managed application. - :type parameters: ~azure.mgmt.resource.managedapplications.models.Application - :keyword callable cls: A custom type or function that will be passed the direct response - :keyword str continuation_token: A continuation token to restart a poller from a saved state. - :keyword polling: By default, your polling method will be AsyncARMPolling. Pass in False for - this operation to not poll, or pass in your own initialized polling object for a personal - polling strategy. - :paramtype polling: bool or ~azure.core.polling.AsyncPollingMethod - :keyword int polling_interval: Default waiting time between two polls for LRO operations if no - Retry-After header is present. - :return: An instance of AsyncLROPoller that returns either Application or the result of - cls(response) - :rtype: - ~azure.core.polling.AsyncLROPoller[~azure.mgmt.resource.managedapplications.models.Application] - :raises: ~azure.core.exceptions.HttpResponseError - """ - api_version = kwargs.pop('api_version', "2018-06-01") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] - polling = kwargs.pop('polling', True) # type: Union[bool, AsyncPollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType["_models.Application"] - lro_delay = kwargs.pop( - 'polling_interval', - self._config.polling_interval - ) - cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] - if cont_token is None: - raw_result = await self._create_or_update_initial( - resource_group_name=resource_group_name, - application_name=application_name, - parameters=parameters, - api_version=api_version, - content_type=content_type, - cls=lambda x,y,z: x, - **kwargs - ) - kwargs.pop('error_map', None) - - def get_long_running_output(pipeline_response): - response = pipeline_response.http_response - deserialized = self._deserialize('Application', pipeline_response) - if cls: - return cls(pipeline_response, deserialized, {}) - return deserialized - - - if polling is True: polling_method = AsyncARMPolling(lro_delay, **kwargs) - elif polling is False: polling_method = AsyncNoPolling() - else: polling_method = polling - if cont_token: - return AsyncLROPoller.from_continuation_token( - polling_method=polling_method, - continuation_token=cont_token, - client=self._client, - deserialization_callback=get_long_running_output - ) - return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) - - begin_create_or_update.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Solutions/applications/{applicationName}"} # type: ignore - - @distributed_trace_async - async def update( - self, - resource_group_name: str, - application_name: str, - parameters: Optional["_models.ApplicationPatchable"] = None, - **kwargs: Any - ) -> "_models.Application": - """Updates an existing managed application. The only value that can be updated via PATCH currently - is the tags. - - :param resource_group_name: The name of the resource group. The name is case insensitive. - :type resource_group_name: str - :param application_name: The name of the managed application. - :type application_name: str - :param parameters: Parameters supplied to update an existing managed application. Default value - is None. - :type parameters: ~azure.mgmt.resource.managedapplications.models.ApplicationPatchable - :keyword callable cls: A custom type or function that will be passed the direct response - :return: Application, or the result of cls(response) - :rtype: ~azure.mgmt.resource.managedapplications.models.Application - :raises: ~azure.core.exceptions.HttpResponseError - """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.Application"] - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {})) - - api_version = kwargs.pop('api_version', "2018-06-01") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] - - if parameters is not None: - _json = self._serialize.body(parameters, 'ApplicationPatchable') - else: - _json = None - - request = build_applications_update_request( - resource_group_name=resource_group_name, - application_name=application_name, - subscription_id=self._config.subscription_id, - api_version=api_version, - content_type=content_type, - json=_json, - template_url=self.update.metadata['url'], - ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) - - pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **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.ErrorResponse, pipeline_response) - raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - - deserialized = self._deserialize('Application', pipeline_response) - - if cls: - return cls(pipeline_response, deserialized, {}) - - return deserialized - - update.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Solutions/applications/{applicationName}"} # type: ignore - - - @distributed_trace - def list_by_resource_group( - self, - resource_group_name: str, - **kwargs: Any - ) -> AsyncIterable["_models.ApplicationListResult"]: - """Gets all the applications within a resource group. - - :param resource_group_name: The name of the resource group. The name is case insensitive. - :type resource_group_name: str - :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either ApplicationListResult or the result of - cls(response) - :rtype: - ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.resource.managedapplications.models.ApplicationListResult] - :raises: ~azure.core.exceptions.HttpResponseError - """ - api_version = kwargs.pop('api_version', "2018-06-01") # type: str - - cls = kwargs.pop('cls', None) # type: ClsType["_models.ApplicationListResult"] - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {})) - def prepare_request(next_link=None): - if not next_link: - - request = build_applications_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'], - ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) - - else: - - request = build_applications_list_by_resource_group_request( - resource_group_name=resource_group_name, - subscription_id=self._config.subscription_id, - template_url=next_link, - ) - 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("ApplicationListResult", pipeline_response) - list_of_elem = deserialized.value - if cls: - list_of_elem = cls(list_of_elem) - 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( # pylint: disable=protected-access - request, - stream=False, - **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.ErrorResponse, pipeline_response) - raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - - return pipeline_response - - - return AsyncItemPaged( - get_next, extract_data - ) - list_by_resource_group.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Solutions/applications"} # type: ignore - - @distributed_trace - def list_by_subscription( - self, - **kwargs: Any - ) -> AsyncIterable["_models.ApplicationListResult"]: - """Gets all the applications within a subscription. - - :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either ApplicationListResult or the result of - cls(response) - :rtype: - ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.resource.managedapplications.models.ApplicationListResult] - :raises: ~azure.core.exceptions.HttpResponseError - """ - api_version = kwargs.pop('api_version', "2018-06-01") # type: str - - cls = kwargs.pop('cls', None) # type: ClsType["_models.ApplicationListResult"] - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {})) - def prepare_request(next_link=None): - if not next_link: - - request = build_applications_list_by_subscription_request( - subscription_id=self._config.subscription_id, - api_version=api_version, - template_url=self.list_by_subscription.metadata['url'], - ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) - - else: - - request = build_applications_list_by_subscription_request( - subscription_id=self._config.subscription_id, - template_url=next_link, - ) - 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("ApplicationListResult", pipeline_response) - list_of_elem = deserialized.value - if cls: - list_of_elem = cls(list_of_elem) - 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( # pylint: disable=protected-access - request, - stream=False, - **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.ErrorResponse, pipeline_response) - raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - - return pipeline_response - - - return AsyncItemPaged( - get_next, extract_data - ) - list_by_subscription.metadata = {'url': "/subscriptions/{subscriptionId}/providers/Microsoft.Solutions/applications"} # type: ignore - - @distributed_trace_async - async def get_by_id( - self, - application_id: str, - **kwargs: Any - ) -> Optional["_models.Application"]: - """Gets the managed application. - - :param application_id: The fully qualified ID of the managed application, including the managed - application name and the managed application resource type. Use the format, - /subscriptions/{guid}/resourceGroups/{resource-group-name}/Microsoft.Solutions/applications/{application-name}. - :type application_id: str - :keyword callable cls: A custom type or function that will be passed the direct response - :return: Application, or the result of cls(response) - :rtype: ~azure.mgmt.resource.managedapplications.models.Application or None - :raises: ~azure.core.exceptions.HttpResponseError - """ - cls = kwargs.pop('cls', None) # type: ClsType[Optional["_models.Application"]] - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {})) - - api_version = kwargs.pop('api_version', "2018-06-01") # type: str - - - request = build_applications_get_by_id_request( - application_id=application_id, - api_version=api_version, - template_url=self.get_by_id.metadata['url'], - ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) - - pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs - ) - response = pipeline_response.http_response - - if response.status_code not in [200, 404]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) - raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - - deserialized = None - if response.status_code == 200: - deserialized = self._deserialize('Application', pipeline_response) - - if cls: - return cls(pipeline_response, deserialized, {}) - - return deserialized - - get_by_id.metadata = {'url': "/{applicationId}"} # type: ignore - - - async def _delete_by_id_initial( # pylint: disable=inconsistent-return-statements - self, - application_id: str, - **kwargs: Any - ) -> None: - cls = kwargs.pop('cls', None) # type: ClsType[None] - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {})) - - api_version = kwargs.pop('api_version', "2018-06-01") # type: str - - - request = build_applications_delete_by_id_request_initial( - application_id=application_id, - api_version=api_version, - template_url=self._delete_by_id_initial.metadata['url'], - ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) - - pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs - ) - response = pipeline_response.http_response - - if response.status_code not in [202, 204]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - raise HttpResponseError(response=response, error_format=ARMErrorFormat) - - if cls: - return cls(pipeline_response, None, {}) - - _delete_by_id_initial.metadata = {'url': "/{applicationId}"} # type: ignore - - - @distributed_trace_async - async def begin_delete_by_id( # pylint: disable=inconsistent-return-statements - self, - application_id: str, - **kwargs: Any - ) -> AsyncLROPoller[None]: - """Deletes the managed application. - - :param application_id: The fully qualified ID of the managed application, including the managed - application name and the managed application resource type. Use the format, - /subscriptions/{guid}/resourceGroups/{resource-group-name}/Microsoft.Solutions/applications/{application-name}. - :type application_id: str - :keyword callable cls: A custom type or function that will be passed the direct response - :keyword str continuation_token: A continuation token to restart a poller from a saved state. - :keyword polling: By default, your polling method will be AsyncARMPolling. Pass in False for - this operation to not poll, or pass in your own initialized polling object for a personal - polling strategy. - :paramtype polling: bool or ~azure.core.polling.AsyncPollingMethod - :keyword int polling_interval: Default waiting time between two polls for LRO operations if no - Retry-After header is present. - :return: An instance of AsyncLROPoller that returns either None or the result of cls(response) - :rtype: ~azure.core.polling.AsyncLROPoller[None] - :raises: ~azure.core.exceptions.HttpResponseError - """ - api_version = kwargs.pop('api_version', "2018-06-01") # type: str - polling = kwargs.pop('polling', True) # type: Union[bool, AsyncPollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType[None] - lro_delay = kwargs.pop( - 'polling_interval', - self._config.polling_interval - ) - cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] - if cont_token is None: - raw_result = await self._delete_by_id_initial( - application_id=application_id, - api_version=api_version, - cls=lambda x,y,z: x, - **kwargs - ) - kwargs.pop('error_map', None) - - def get_long_running_output(pipeline_response): - if cls: - return cls(pipeline_response, None, {}) - - - if polling is True: polling_method = AsyncARMPolling(lro_delay, **kwargs) - elif polling is False: polling_method = AsyncNoPolling() - else: polling_method = polling - if cont_token: - return AsyncLROPoller.from_continuation_token( - polling_method=polling_method, - continuation_token=cont_token, - client=self._client, - deserialization_callback=get_long_running_output - ) - return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) - - begin_delete_by_id.metadata = {'url': "/{applicationId}"} # type: ignore - - async def _create_or_update_by_id_initial( - self, - application_id: str, - parameters: "_models.Application", - **kwargs: Any - ) -> "_models.Application": - cls = kwargs.pop('cls', None) # type: ClsType["_models.Application"] - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {})) - - api_version = kwargs.pop('api_version', "2018-06-01") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] - - _json = self._serialize.body(parameters, 'Application') - - request = build_applications_create_or_update_by_id_request_initial( - application_id=application_id, - api_version=api_version, - content_type=content_type, - json=_json, - template_url=self._create_or_update_by_id_initial.metadata['url'], - ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) - - pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs - ) - response = pipeline_response.http_response - - if response.status_code not in [200, 201]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - raise HttpResponseError(response=response, error_format=ARMErrorFormat) - - if response.status_code == 200: - deserialized = self._deserialize('Application', pipeline_response) - - if response.status_code == 201: - deserialized = self._deserialize('Application', pipeline_response) - - if cls: - return cls(pipeline_response, deserialized, {}) - - return deserialized - - _create_or_update_by_id_initial.metadata = {'url': "/{applicationId}"} # type: ignore - - - @distributed_trace_async - async def begin_create_or_update_by_id( - self, - application_id: str, - parameters: "_models.Application", - **kwargs: Any - ) -> AsyncLROPoller["_models.Application"]: - """Creates a new managed application. - - :param application_id: The fully qualified ID of the managed application, including the managed - application name and the managed application resource type. Use the format, - /subscriptions/{guid}/resourceGroups/{resource-group-name}/Microsoft.Solutions/applications/{application-name}. - :type application_id: str - :param parameters: Parameters supplied to the create or update a managed application. - :type parameters: ~azure.mgmt.resource.managedapplications.models.Application - :keyword callable cls: A custom type or function that will be passed the direct response - :keyword str continuation_token: A continuation token to restart a poller from a saved state. - :keyword polling: By default, your polling method will be AsyncARMPolling. Pass in False for - this operation to not poll, or pass in your own initialized polling object for a personal - polling strategy. - :paramtype polling: bool or ~azure.core.polling.AsyncPollingMethod - :keyword int polling_interval: Default waiting time between two polls for LRO operations if no - Retry-After header is present. - :return: An instance of AsyncLROPoller that returns either Application or the result of - cls(response) - :rtype: - ~azure.core.polling.AsyncLROPoller[~azure.mgmt.resource.managedapplications.models.Application] - :raises: ~azure.core.exceptions.HttpResponseError - """ - api_version = kwargs.pop('api_version', "2018-06-01") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] - polling = kwargs.pop('polling', True) # type: Union[bool, AsyncPollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType["_models.Application"] - lro_delay = kwargs.pop( - 'polling_interval', - self._config.polling_interval - ) - cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] - if cont_token is None: - raw_result = await self._create_or_update_by_id_initial( - application_id=application_id, - parameters=parameters, - api_version=api_version, - content_type=content_type, - cls=lambda x,y,z: x, - **kwargs - ) - kwargs.pop('error_map', None) - - def get_long_running_output(pipeline_response): - response = pipeline_response.http_response - deserialized = self._deserialize('Application', pipeline_response) - if cls: - return cls(pipeline_response, deserialized, {}) - return deserialized - - - if polling is True: polling_method = AsyncARMPolling(lro_delay, **kwargs) - elif polling is False: polling_method = AsyncNoPolling() - else: polling_method = polling - if cont_token: - return AsyncLROPoller.from_continuation_token( - polling_method=polling_method, - continuation_token=cont_token, - client=self._client, - deserialization_callback=get_long_running_output - ) - return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) - - begin_create_or_update_by_id.metadata = {'url': "/{applicationId}"} # type: ignore - - @distributed_trace_async - async def update_by_id( - self, - application_id: str, - parameters: Optional["_models.Application"] = None, - **kwargs: Any - ) -> "_models.Application": - """Updates an existing managed application. The only value that can be updated via PATCH currently - is the tags. - - :param application_id: The fully qualified ID of the managed application, including the managed - application name and the managed application resource type. Use the format, - /subscriptions/{guid}/resourceGroups/{resource-group-name}/Microsoft.Solutions/applications/{application-name}. - :type application_id: str - :param parameters: Parameters supplied to update an existing managed application. Default value - is None. - :type parameters: ~azure.mgmt.resource.managedapplications.models.Application - :keyword callable cls: A custom type or function that will be passed the direct response - :return: Application, or the result of cls(response) - :rtype: ~azure.mgmt.resource.managedapplications.models.Application - :raises: ~azure.core.exceptions.HttpResponseError - """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.Application"] - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {})) - - api_version = kwargs.pop('api_version', "2018-06-01") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] - - if parameters is not None: - _json = self._serialize.body(parameters, 'Application') - else: - _json = None - - request = build_applications_update_by_id_request( - application_id=application_id, - api_version=api_version, - content_type=content_type, - json=_json, - template_url=self.update_by_id.metadata['url'], - ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) - - pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **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.ErrorResponse, pipeline_response) - raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - - deserialized = self._deserialize('Application', pipeline_response) - - if cls: - return cls(pipeline_response, deserialized, {}) - - return deserialized - - update_by_id.metadata = {'url': "/{applicationId}"} # type: ignore - -class ApplicationDefinitionsOperations: - """ApplicationDefinitionsOperations async operations. - - You should not instantiate this class directly. Instead, you should create a Client instance that - instantiates it for you and attaches it as an attribute. - - :ivar models: Alias to model classes used in this operation group. - :type models: ~azure.mgmt.resource.managedapplications.models - :param client: Client for service requests. - :param config: Configuration of service client. - :param serializer: An object model serializer. - :param deserializer: An object model deserializer. - """ - - models = _models - - def __init__(self, client, config, serializer, deserializer) -> None: - self._client = client - self._serialize = serializer - self._deserialize = deserializer - self._config = config - - @distributed_trace_async - async def get( - self, - resource_group_name: str, - application_definition_name: str, - **kwargs: Any - ) -> Optional["_models.ApplicationDefinition"]: - """Gets the managed application definition. - - :param resource_group_name: The name of the resource group. The name is case insensitive. - :type resource_group_name: str - :param application_definition_name: The name of the managed application definition. - :type application_definition_name: str - :keyword callable cls: A custom type or function that will be passed the direct response - :return: ApplicationDefinition, or the result of cls(response) - :rtype: ~azure.mgmt.resource.managedapplications.models.ApplicationDefinition or None - :raises: ~azure.core.exceptions.HttpResponseError - """ - cls = kwargs.pop('cls', None) # type: ClsType[Optional["_models.ApplicationDefinition"]] - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {})) - - api_version = kwargs.pop('api_version', "2018-06-01") # type: str - - - request = build_application_definitions_get_request( - resource_group_name=resource_group_name, - application_definition_name=application_definition_name, - subscription_id=self._config.subscription_id, - api_version=api_version, - template_url=self.get.metadata['url'], - ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) - - pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs - ) - response = pipeline_response.http_response - - if response.status_code not in [200, 404]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) - raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - - deserialized = None - if response.status_code == 200: - deserialized = self._deserialize('ApplicationDefinition', pipeline_response) - - if cls: - return cls(pipeline_response, deserialized, {}) - - return deserialized - - get.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Solutions/applicationDefinitions/{applicationDefinitionName}"} # type: ignore - - - async def _delete_initial( # pylint: disable=inconsistent-return-statements - self, - resource_group_name: str, - application_definition_name: str, - **kwargs: Any - ) -> None: - cls = kwargs.pop('cls', None) # type: ClsType[None] - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {})) - - api_version = kwargs.pop('api_version', "2018-06-01") # type: str - - - request = build_application_definitions_delete_request_initial( - resource_group_name=resource_group_name, - application_definition_name=application_definition_name, - subscription_id=self._config.subscription_id, - api_version=api_version, - template_url=self._delete_initial.metadata['url'], - ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) - - pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs - ) - response = pipeline_response.http_response - - if response.status_code not in [200, 202, 204]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - raise HttpResponseError(response=response, error_format=ARMErrorFormat) - - if cls: - return cls(pipeline_response, None, {}) - - _delete_initial.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Solutions/applicationDefinitions/{applicationDefinitionName}"} # type: ignore - - - @distributed_trace_async - async def begin_delete( # pylint: disable=inconsistent-return-statements - self, - resource_group_name: str, - application_definition_name: str, - **kwargs: Any - ) -> AsyncLROPoller[None]: - """Deletes the managed application definition. - - :param resource_group_name: The name of the resource group. The name is case insensitive. - :type resource_group_name: str - :param application_definition_name: The name of the managed application definition to delete. - :type application_definition_name: str - :keyword callable cls: A custom type or function that will be passed the direct response - :keyword str continuation_token: A continuation token to restart a poller from a saved state. - :keyword polling: By default, your polling method will be AsyncARMPolling. Pass in False for - this operation to not poll, or pass in your own initialized polling object for a personal - polling strategy. - :paramtype polling: bool or ~azure.core.polling.AsyncPollingMethod - :keyword int polling_interval: Default waiting time between two polls for LRO operations if no - Retry-After header is present. - :return: An instance of AsyncLROPoller that returns either None or the result of cls(response) - :rtype: ~azure.core.polling.AsyncLROPoller[None] - :raises: ~azure.core.exceptions.HttpResponseError - """ - api_version = kwargs.pop('api_version', "2018-06-01") # type: str - polling = kwargs.pop('polling', True) # type: Union[bool, AsyncPollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType[None] - lro_delay = kwargs.pop( - 'polling_interval', - self._config.polling_interval - ) - cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] - if cont_token is None: - raw_result = await self._delete_initial( - resource_group_name=resource_group_name, - application_definition_name=application_definition_name, - api_version=api_version, - cls=lambda x,y,z: x, - **kwargs - ) - kwargs.pop('error_map', None) - - def get_long_running_output(pipeline_response): - if cls: - return cls(pipeline_response, None, {}) - - - if polling is True: polling_method = AsyncARMPolling(lro_delay, **kwargs) - elif polling is False: polling_method = AsyncNoPolling() - else: polling_method = polling - if cont_token: - return AsyncLROPoller.from_continuation_token( - polling_method=polling_method, - continuation_token=cont_token, - client=self._client, - deserialization_callback=get_long_running_output - ) - return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) - - begin_delete.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Solutions/applicationDefinitions/{applicationDefinitionName}"} # type: ignore - - async def _create_or_update_initial( - self, - resource_group_name: str, - application_definition_name: str, - parameters: "_models.ApplicationDefinition", - **kwargs: Any - ) -> "_models.ApplicationDefinition": - cls = kwargs.pop('cls', None) # type: ClsType["_models.ApplicationDefinition"] - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {})) - - api_version = kwargs.pop('api_version', "2018-06-01") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] - - _json = self._serialize.body(parameters, 'ApplicationDefinition') - - request = build_application_definitions_create_or_update_request_initial( - resource_group_name=resource_group_name, - application_definition_name=application_definition_name, - subscription_id=self._config.subscription_id, - api_version=api_version, - content_type=content_type, - json=_json, - template_url=self._create_or_update_initial.metadata['url'], - ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) - - pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs - ) - response = pipeline_response.http_response - - if response.status_code not in [200, 201]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - raise HttpResponseError(response=response, error_format=ARMErrorFormat) - - if response.status_code == 200: - deserialized = self._deserialize('ApplicationDefinition', pipeline_response) - - if response.status_code == 201: - deserialized = self._deserialize('ApplicationDefinition', pipeline_response) - - if cls: - return cls(pipeline_response, deserialized, {}) - - return deserialized - - _create_or_update_initial.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Solutions/applicationDefinitions/{applicationDefinitionName}"} # type: ignore - - - @distributed_trace_async - async def begin_create_or_update( - self, - resource_group_name: str, - application_definition_name: str, - parameters: "_models.ApplicationDefinition", - **kwargs: Any - ) -> AsyncLROPoller["_models.ApplicationDefinition"]: - """Creates a new managed application definition. - - :param resource_group_name: The name of the resource group. The name is case insensitive. - :type resource_group_name: str - :param application_definition_name: The name of the managed application definition. - :type application_definition_name: str - :param parameters: Parameters supplied to the create or update an managed application - definition. - :type parameters: ~azure.mgmt.resource.managedapplications.models.ApplicationDefinition - :keyword callable cls: A custom type or function that will be passed the direct response - :keyword str continuation_token: A continuation token to restart a poller from a saved state. - :keyword polling: By default, your polling method will be AsyncARMPolling. Pass in False for - this operation to not poll, or pass in your own initialized polling object for a personal - polling strategy. - :paramtype polling: bool or ~azure.core.polling.AsyncPollingMethod - :keyword int polling_interval: Default waiting time between two polls for LRO operations if no - Retry-After header is present. - :return: An instance of AsyncLROPoller that returns either ApplicationDefinition or the result - of cls(response) - :rtype: - ~azure.core.polling.AsyncLROPoller[~azure.mgmt.resource.managedapplications.models.ApplicationDefinition] - :raises: ~azure.core.exceptions.HttpResponseError - """ - api_version = kwargs.pop('api_version', "2018-06-01") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] - polling = kwargs.pop('polling', True) # type: Union[bool, AsyncPollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType["_models.ApplicationDefinition"] - lro_delay = kwargs.pop( - 'polling_interval', - self._config.polling_interval - ) - cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] - if cont_token is None: - raw_result = await self._create_or_update_initial( - resource_group_name=resource_group_name, - application_definition_name=application_definition_name, - parameters=parameters, - api_version=api_version, - content_type=content_type, - cls=lambda x,y,z: x, - **kwargs - ) - kwargs.pop('error_map', None) - - def get_long_running_output(pipeline_response): - response = pipeline_response.http_response - deserialized = self._deserialize('ApplicationDefinition', pipeline_response) - if cls: - return cls(pipeline_response, deserialized, {}) - return deserialized - - - if polling is True: polling_method = AsyncARMPolling(lro_delay, **kwargs) - elif polling is False: polling_method = AsyncNoPolling() - else: polling_method = polling - if cont_token: - return AsyncLROPoller.from_continuation_token( - polling_method=polling_method, - continuation_token=cont_token, - client=self._client, - deserialization_callback=get_long_running_output - ) - return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) - - begin_create_or_update.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Solutions/applicationDefinitions/{applicationDefinitionName}"} # type: ignore - - @distributed_trace - def list_by_resource_group( - self, - resource_group_name: str, - **kwargs: Any - ) -> AsyncIterable["_models.ApplicationDefinitionListResult"]: - """Lists the managed application definitions in a resource group. - - :param resource_group_name: The name of the resource group. The name is case insensitive. - :type resource_group_name: str - :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either ApplicationDefinitionListResult or the result of - cls(response) - :rtype: - ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.resource.managedapplications.models.ApplicationDefinitionListResult] - :raises: ~azure.core.exceptions.HttpResponseError - """ - api_version = kwargs.pop('api_version', "2018-06-01") # type: str - - cls = kwargs.pop('cls', None) # type: ClsType["_models.ApplicationDefinitionListResult"] - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {})) - def prepare_request(next_link=None): - if not next_link: - - request = build_application_definitions_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'], - ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) - - else: - - request = build_application_definitions_list_by_resource_group_request( - resource_group_name=resource_group_name, - subscription_id=self._config.subscription_id, - template_url=next_link, - ) - 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("ApplicationDefinitionListResult", pipeline_response) - list_of_elem = deserialized.value - if cls: - list_of_elem = cls(list_of_elem) - 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( # pylint: disable=protected-access - request, - stream=False, - **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.ErrorResponse, pipeline_response) - raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - - return pipeline_response - - - return AsyncItemPaged( - get_next, extract_data - ) - list_by_resource_group.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Solutions/applicationDefinitions"} # type: ignore - - @distributed_trace_async - async def get_by_id( - self, - resource_group_name: str, - application_definition_name: str, - **kwargs: Any - ) -> Optional["_models.ApplicationDefinition"]: - """Gets the managed application definition. - - :param resource_group_name: The name of the resource group. The name is case insensitive. - :type resource_group_name: str - :param application_definition_name: The name of the managed application definition. - :type application_definition_name: str - :keyword callable cls: A custom type or function that will be passed the direct response - :return: ApplicationDefinition, or the result of cls(response) - :rtype: ~azure.mgmt.resource.managedapplications.models.ApplicationDefinition or None - :raises: ~azure.core.exceptions.HttpResponseError - """ - cls = kwargs.pop('cls', None) # type: ClsType[Optional["_models.ApplicationDefinition"]] - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {})) - - api_version = kwargs.pop('api_version', "2018-06-01") # type: str - - - request = build_application_definitions_get_by_id_request( - resource_group_name=resource_group_name, - application_definition_name=application_definition_name, - subscription_id=self._config.subscription_id, - api_version=api_version, - template_url=self.get_by_id.metadata['url'], - ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) - - pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs - ) - response = pipeline_response.http_response - - if response.status_code not in [200, 404]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) - raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - - deserialized = None - if response.status_code == 200: - deserialized = self._deserialize('ApplicationDefinition', pipeline_response) - - if cls: - return cls(pipeline_response, deserialized, {}) - - return deserialized - - get_by_id.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Solutions/applicationDefinitions/{applicationDefinitionName}"} # type: ignore - - - async def _delete_by_id_initial( # pylint: disable=inconsistent-return-statements - self, - resource_group_name: str, - application_definition_name: str, - **kwargs: Any - ) -> None: - cls = kwargs.pop('cls', None) # type: ClsType[None] - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {})) - - api_version = kwargs.pop('api_version', "2018-06-01") # type: str - - - request = build_application_definitions_delete_by_id_request_initial( - resource_group_name=resource_group_name, - application_definition_name=application_definition_name, - subscription_id=self._config.subscription_id, - api_version=api_version, - template_url=self._delete_by_id_initial.metadata['url'], - ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) - - pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs - ) - response = pipeline_response.http_response - - if response.status_code not in [200, 202, 204]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - raise HttpResponseError(response=response, error_format=ARMErrorFormat) - - if cls: - return cls(pipeline_response, None, {}) - - _delete_by_id_initial.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Solutions/applicationDefinitions/{applicationDefinitionName}"} # type: ignore - - - @distributed_trace_async - async def begin_delete_by_id( # pylint: disable=inconsistent-return-statements - self, - resource_group_name: str, - application_definition_name: str, - **kwargs: Any - ) -> AsyncLROPoller[None]: - """Deletes the managed application definition. - - :param resource_group_name: The name of the resource group. The name is case insensitive. - :type resource_group_name: str - :param application_definition_name: The name of the managed application definition. - :type application_definition_name: str - :keyword callable cls: A custom type or function that will be passed the direct response - :keyword str continuation_token: A continuation token to restart a poller from a saved state. - :keyword polling: By default, your polling method will be AsyncARMPolling. Pass in False for - this operation to not poll, or pass in your own initialized polling object for a personal - polling strategy. - :paramtype polling: bool or ~azure.core.polling.AsyncPollingMethod - :keyword int polling_interval: Default waiting time between two polls for LRO operations if no - Retry-After header is present. - :return: An instance of AsyncLROPoller that returns either None or the result of cls(response) - :rtype: ~azure.core.polling.AsyncLROPoller[None] - :raises: ~azure.core.exceptions.HttpResponseError - """ - api_version = kwargs.pop('api_version', "2018-06-01") # type: str - polling = kwargs.pop('polling', True) # type: Union[bool, AsyncPollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType[None] - lro_delay = kwargs.pop( - 'polling_interval', - self._config.polling_interval - ) - cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] - if cont_token is None: - raw_result = await self._delete_by_id_initial( - resource_group_name=resource_group_name, - application_definition_name=application_definition_name, - api_version=api_version, - cls=lambda x,y,z: x, - **kwargs - ) - kwargs.pop('error_map', None) - - def get_long_running_output(pipeline_response): - if cls: - return cls(pipeline_response, None, {}) - - - if polling is True: polling_method = AsyncARMPolling(lro_delay, **kwargs) - elif polling is False: polling_method = AsyncNoPolling() - else: polling_method = polling - if cont_token: - return AsyncLROPoller.from_continuation_token( - polling_method=polling_method, - continuation_token=cont_token, - client=self._client, - deserialization_callback=get_long_running_output - ) - return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) - - begin_delete_by_id.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Solutions/applicationDefinitions/{applicationDefinitionName}"} # type: ignore - - async def _create_or_update_by_id_initial( - self, - resource_group_name: str, - application_definition_name: str, - parameters: "_models.ApplicationDefinition", - **kwargs: Any - ) -> "_models.ApplicationDefinition": - cls = kwargs.pop('cls', None) # type: ClsType["_models.ApplicationDefinition"] - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {})) - - api_version = kwargs.pop('api_version', "2018-06-01") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] - - _json = self._serialize.body(parameters, 'ApplicationDefinition') - - request = build_application_definitions_create_or_update_by_id_request_initial( - resource_group_name=resource_group_name, - application_definition_name=application_definition_name, - subscription_id=self._config.subscription_id, - api_version=api_version, - content_type=content_type, - json=_json, - template_url=self._create_or_update_by_id_initial.metadata['url'], - ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) - - pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs - ) - response = pipeline_response.http_response - - if response.status_code not in [200, 201]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - raise HttpResponseError(response=response, error_format=ARMErrorFormat) - - if response.status_code == 200: - deserialized = self._deserialize('ApplicationDefinition', pipeline_response) - - if response.status_code == 201: - deserialized = self._deserialize('ApplicationDefinition', pipeline_response) - - if cls: - return cls(pipeline_response, deserialized, {}) - - return deserialized - - _create_or_update_by_id_initial.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Solutions/applicationDefinitions/{applicationDefinitionName}"} # type: ignore - - - @distributed_trace_async - async def begin_create_or_update_by_id( - self, - resource_group_name: str, - application_definition_name: str, - parameters: "_models.ApplicationDefinition", - **kwargs: Any - ) -> AsyncLROPoller["_models.ApplicationDefinition"]: - """Creates a new managed application definition. - - :param resource_group_name: The name of the resource group. The name is case insensitive. - :type resource_group_name: str - :param application_definition_name: The name of the managed application definition. - :type application_definition_name: str - :param parameters: Parameters supplied to the create or update a managed application - definition. - :type parameters: ~azure.mgmt.resource.managedapplications.models.ApplicationDefinition - :keyword callable cls: A custom type or function that will be passed the direct response - :keyword str continuation_token: A continuation token to restart a poller from a saved state. - :keyword polling: By default, your polling method will be AsyncARMPolling. Pass in False for - this operation to not poll, or pass in your own initialized polling object for a personal - polling strategy. - :paramtype polling: bool or ~azure.core.polling.AsyncPollingMethod - :keyword int polling_interval: Default waiting time between two polls for LRO operations if no - Retry-After header is present. - :return: An instance of AsyncLROPoller that returns either ApplicationDefinition or the result - of cls(response) - :rtype: - ~azure.core.polling.AsyncLROPoller[~azure.mgmt.resource.managedapplications.models.ApplicationDefinition] - :raises: ~azure.core.exceptions.HttpResponseError - """ - api_version = kwargs.pop('api_version', "2018-06-01") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] - polling = kwargs.pop('polling', True) # type: Union[bool, AsyncPollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType["_models.ApplicationDefinition"] - lro_delay = kwargs.pop( - 'polling_interval', - self._config.polling_interval - ) - cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] - if cont_token is None: - raw_result = await self._create_or_update_by_id_initial( - resource_group_name=resource_group_name, - application_definition_name=application_definition_name, - parameters=parameters, - api_version=api_version, - content_type=content_type, - cls=lambda x,y,z: x, - **kwargs - ) - kwargs.pop('error_map', None) - - def get_long_running_output(pipeline_response): - response = pipeline_response.http_response - deserialized = self._deserialize('ApplicationDefinition', pipeline_response) - if cls: - return cls(pipeline_response, deserialized, {}) - return deserialized - - - if polling is True: polling_method = AsyncARMPolling(lro_delay, **kwargs) - elif polling is False: polling_method = AsyncNoPolling() - else: polling_method = polling - if cont_token: - return AsyncLROPoller.from_continuation_token( - polling_method=polling_method, - continuation_token=cont_token, - client=self._client, - deserialization_callback=get_long_running_output - ) - return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) - - begin_create_or_update_by_id.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Solutions/applicationDefinitions/{applicationDefinitionName}"} # type: ignore diff --git a/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/managedapplications/models.py b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/managedapplications/models.py new file mode 100644 index 0000000000000..1c47d132a6791 --- /dev/null +++ b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/managedapplications/models.py @@ -0,0 +1,7 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for +# license information. +# -------------------------------------------------------------------------- +from .v2018_06_01.models import * diff --git a/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/managedapplications/operations/_operations.py b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/managedapplications/operations/_operations.py deleted file mode 100644 index 02943c18e6720..0000000000000 --- a/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/managedapplications/operations/_operations.py +++ /dev/null @@ -1,2333 +0,0 @@ -# pylint: disable=too-many-lines -# coding=utf-8 -# -------------------------------------------------------------------------- -# Copyright (c) Microsoft Corporation. All rights reserved. -# Licensed under the MIT License. See License.txt in the project root for license information. -# Code generated by Microsoft (R) AutoRest Code Generator. -# Changes may cause incorrect behavior and will be lost if the code is regenerated. -# -------------------------------------------------------------------------- -from typing import Any, Callable, Dict, Iterable, Optional, TypeVar, Union - -from msrest import Serializer - -from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error -from azure.core.paging import ItemPaged -from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import HttpResponse -from azure.core.polling import LROPoller, NoPolling, PollingMethod -from azure.core.rest import HttpRequest -from azure.core.tracing.decorator import distributed_trace -from azure.mgmt.core.exceptions import ARMErrorFormat -from azure.mgmt.core.polling.arm_polling import ARMPolling - -from .. import models as _models -from .._vendor import _convert_request, _format_url_section -T = TypeVar('T') -ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] -JSONType = Any - -_SERIALIZER = Serializer() -_SERIALIZER.client_side_validation = False - -def build_list_operations_request( - **kwargs: Any -) -> HttpRequest: - api_version = kwargs.pop('api_version', "2018-06-01") # type: str - - accept = "application/json" - # Construct URL - _url = kwargs.pop("template_url", "/providers/Microsoft.Solutions/operations") - - # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') - - # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') - - return HttpRequest( - method="GET", - url=_url, - params=_query_parameters, - headers=_header_parameters, - **kwargs - ) - - -def build_applications_get_request( - resource_group_name: str, - application_name: str, - subscription_id: str, - **kwargs: Any -) -> HttpRequest: - api_version = kwargs.pop('api_version', "2018-06-01") # type: str - - accept = "application/json" - # Construct URL - _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Solutions/applications/{applicationName}") # pylint: disable=line-too-long - path_format_arguments = { - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._\(\)]+$'), - "applicationName": _SERIALIZER.url("application_name", application_name, 'str', max_length=64, min_length=3), - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), - } - - _url = _format_url_section(_url, **path_format_arguments) - - # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') - - # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') - - return HttpRequest( - method="GET", - url=_url, - params=_query_parameters, - headers=_header_parameters, - **kwargs - ) - - -def build_applications_delete_request_initial( - resource_group_name: str, - application_name: str, - subscription_id: str, - **kwargs: Any -) -> HttpRequest: - api_version = kwargs.pop('api_version', "2018-06-01") # type: str - - accept = "application/json" - # Construct URL - _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Solutions/applications/{applicationName}") # pylint: disable=line-too-long - path_format_arguments = { - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._\(\)]+$'), - "applicationName": _SERIALIZER.url("application_name", application_name, 'str', max_length=64, min_length=3), - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), - } - - _url = _format_url_section(_url, **path_format_arguments) - - # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') - - # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') - - return HttpRequest( - method="DELETE", - url=_url, - params=_query_parameters, - headers=_header_parameters, - **kwargs - ) - - -def build_applications_create_or_update_request_initial( - resource_group_name: str, - application_name: str, - subscription_id: str, - *, - json: JSONType = None, - content: Any = None, - **kwargs: Any -) -> HttpRequest: - api_version = kwargs.pop('api_version', "2018-06-01") # type: str - content_type = kwargs.pop('content_type', None) # type: Optional[str] - - accept = "application/json" - # Construct URL - _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Solutions/applications/{applicationName}") # pylint: disable=line-too-long - path_format_arguments = { - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._\(\)]+$'), - "applicationName": _SERIALIZER.url("application_name", application_name, 'str', max_length=64, min_length=3), - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), - } - - _url = _format_url_section(_url, **path_format_arguments) - - # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') - - # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - if content_type is not None: - _header_parameters['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') - _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') - - return HttpRequest( - method="PUT", - url=_url, - params=_query_parameters, - headers=_header_parameters, - json=json, - content=content, - **kwargs - ) - - -def build_applications_update_request( - resource_group_name: str, - application_name: str, - subscription_id: str, - *, - json: JSONType = None, - content: Any = None, - **kwargs: Any -) -> HttpRequest: - api_version = kwargs.pop('api_version', "2018-06-01") # type: str - content_type = kwargs.pop('content_type', None) # type: Optional[str] - - accept = "application/json" - # Construct URL - _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Solutions/applications/{applicationName}") # pylint: disable=line-too-long - path_format_arguments = { - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._\(\)]+$'), - "applicationName": _SERIALIZER.url("application_name", application_name, 'str', max_length=64, min_length=3), - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), - } - - _url = _format_url_section(_url, **path_format_arguments) - - # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') - - # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - if content_type is not None: - _header_parameters['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') - _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') - - return HttpRequest( - method="PATCH", - url=_url, - params=_query_parameters, - headers=_header_parameters, - json=json, - content=content, - **kwargs - ) - - -def build_applications_list_by_resource_group_request( - resource_group_name: str, - subscription_id: str, - **kwargs: Any -) -> HttpRequest: - api_version = kwargs.pop('api_version', "2018-06-01") # type: str - - accept = "application/json" - # Construct URL - _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Solutions/applications") # pylint: disable=line-too-long - path_format_arguments = { - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._\(\)]+$'), - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), - } - - _url = _format_url_section(_url, **path_format_arguments) - - # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') - - # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') - - return HttpRequest( - method="GET", - url=_url, - params=_query_parameters, - headers=_header_parameters, - **kwargs - ) - - -def build_applications_list_by_subscription_request( - subscription_id: str, - **kwargs: Any -) -> HttpRequest: - api_version = kwargs.pop('api_version', "2018-06-01") # type: str - - accept = "application/json" - # Construct URL - _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/providers/Microsoft.Solutions/applications") - path_format_arguments = { - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), - } - - _url = _format_url_section(_url, **path_format_arguments) - - # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') - - # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') - - return HttpRequest( - method="GET", - url=_url, - params=_query_parameters, - headers=_header_parameters, - **kwargs - ) - - -def build_applications_get_by_id_request( - application_id: str, - **kwargs: Any -) -> HttpRequest: - api_version = kwargs.pop('api_version', "2018-06-01") # type: str - - accept = "application/json" - # Construct URL - _url = kwargs.pop("template_url", "/{applicationId}") - path_format_arguments = { - "applicationId": _SERIALIZER.url("application_id", application_id, 'str', skip_quote=True), - } - - _url = _format_url_section(_url, **path_format_arguments) - - # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') - - # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') - - return HttpRequest( - method="GET", - url=_url, - params=_query_parameters, - headers=_header_parameters, - **kwargs - ) - - -def build_applications_delete_by_id_request_initial( - application_id: str, - **kwargs: Any -) -> HttpRequest: - api_version = kwargs.pop('api_version', "2018-06-01") # type: str - - accept = "application/json" - # Construct URL - _url = kwargs.pop("template_url", "/{applicationId}") - path_format_arguments = { - "applicationId": _SERIALIZER.url("application_id", application_id, 'str', skip_quote=True), - } - - _url = _format_url_section(_url, **path_format_arguments) - - # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') - - # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') - - return HttpRequest( - method="DELETE", - url=_url, - params=_query_parameters, - headers=_header_parameters, - **kwargs - ) - - -def build_applications_create_or_update_by_id_request_initial( - application_id: str, - *, - json: JSONType = None, - content: Any = None, - **kwargs: Any -) -> HttpRequest: - api_version = kwargs.pop('api_version', "2018-06-01") # type: str - content_type = kwargs.pop('content_type', None) # type: Optional[str] - - accept = "application/json" - # Construct URL - _url = kwargs.pop("template_url", "/{applicationId}") - path_format_arguments = { - "applicationId": _SERIALIZER.url("application_id", application_id, 'str', skip_quote=True), - } - - _url = _format_url_section(_url, **path_format_arguments) - - # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') - - # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - if content_type is not None: - _header_parameters['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') - _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') - - return HttpRequest( - method="PUT", - url=_url, - params=_query_parameters, - headers=_header_parameters, - json=json, - content=content, - **kwargs - ) - - -def build_applications_update_by_id_request( - application_id: str, - *, - json: JSONType = None, - content: Any = None, - **kwargs: Any -) -> HttpRequest: - api_version = kwargs.pop('api_version', "2018-06-01") # type: str - content_type = kwargs.pop('content_type', None) # type: Optional[str] - - accept = "application/json" - # Construct URL - _url = kwargs.pop("template_url", "/{applicationId}") - path_format_arguments = { - "applicationId": _SERIALIZER.url("application_id", application_id, 'str', skip_quote=True), - } - - _url = _format_url_section(_url, **path_format_arguments) - - # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') - - # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - if content_type is not None: - _header_parameters['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') - _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') - - return HttpRequest( - method="PATCH", - url=_url, - params=_query_parameters, - headers=_header_parameters, - json=json, - content=content, - **kwargs - ) - - -def build_application_definitions_get_request( - resource_group_name: str, - application_definition_name: str, - subscription_id: str, - **kwargs: Any -) -> HttpRequest: - api_version = kwargs.pop('api_version', "2018-06-01") # type: str - - accept = "application/json" - # Construct URL - _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Solutions/applicationDefinitions/{applicationDefinitionName}") # pylint: disable=line-too-long - path_format_arguments = { - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._\(\)]+$'), - "applicationDefinitionName": _SERIALIZER.url("application_definition_name", application_definition_name, 'str', max_length=64, min_length=3), - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), - } - - _url = _format_url_section(_url, **path_format_arguments) - - # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') - - # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') - - return HttpRequest( - method="GET", - url=_url, - params=_query_parameters, - headers=_header_parameters, - **kwargs - ) - - -def build_application_definitions_delete_request_initial( - resource_group_name: str, - application_definition_name: str, - subscription_id: str, - **kwargs: Any -) -> HttpRequest: - api_version = kwargs.pop('api_version', "2018-06-01") # type: str - - accept = "application/json" - # Construct URL - _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Solutions/applicationDefinitions/{applicationDefinitionName}") # pylint: disable=line-too-long - path_format_arguments = { - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._\(\)]+$'), - "applicationDefinitionName": _SERIALIZER.url("application_definition_name", application_definition_name, 'str', max_length=64, min_length=3), - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), - } - - _url = _format_url_section(_url, **path_format_arguments) - - # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') - - # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') - - return HttpRequest( - method="DELETE", - url=_url, - params=_query_parameters, - headers=_header_parameters, - **kwargs - ) - - -def build_application_definitions_create_or_update_request_initial( - resource_group_name: str, - application_definition_name: str, - subscription_id: str, - *, - json: JSONType = None, - content: Any = None, - **kwargs: Any -) -> HttpRequest: - api_version = kwargs.pop('api_version', "2018-06-01") # type: str - content_type = kwargs.pop('content_type', None) # type: Optional[str] - - accept = "application/json" - # Construct URL - _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Solutions/applicationDefinitions/{applicationDefinitionName}") # pylint: disable=line-too-long - path_format_arguments = { - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._\(\)]+$'), - "applicationDefinitionName": _SERIALIZER.url("application_definition_name", application_definition_name, 'str', max_length=64, min_length=3), - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), - } - - _url = _format_url_section(_url, **path_format_arguments) - - # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') - - # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - if content_type is not None: - _header_parameters['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') - _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') - - return HttpRequest( - method="PUT", - url=_url, - params=_query_parameters, - headers=_header_parameters, - json=json, - content=content, - **kwargs - ) - - -def build_application_definitions_list_by_resource_group_request( - resource_group_name: str, - subscription_id: str, - **kwargs: Any -) -> HttpRequest: - api_version = kwargs.pop('api_version', "2018-06-01") # type: str - - accept = "application/json" - # Construct URL - _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Solutions/applicationDefinitions") # pylint: disable=line-too-long - path_format_arguments = { - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._\(\)]+$'), - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), - } - - _url = _format_url_section(_url, **path_format_arguments) - - # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') - - # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') - - return HttpRequest( - method="GET", - url=_url, - params=_query_parameters, - headers=_header_parameters, - **kwargs - ) - - -def build_application_definitions_get_by_id_request( - resource_group_name: str, - application_definition_name: str, - subscription_id: str, - **kwargs: Any -) -> HttpRequest: - api_version = kwargs.pop('api_version', "2018-06-01") # type: str - - accept = "application/json" - # Construct URL - _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Solutions/applicationDefinitions/{applicationDefinitionName}") # pylint: disable=line-too-long - path_format_arguments = { - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._\(\)]+$'), - "applicationDefinitionName": _SERIALIZER.url("application_definition_name", application_definition_name, 'str', max_length=64, min_length=3), - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), - } - - _url = _format_url_section(_url, **path_format_arguments) - - # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') - - # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') - - return HttpRequest( - method="GET", - url=_url, - params=_query_parameters, - headers=_header_parameters, - **kwargs - ) - - -def build_application_definitions_delete_by_id_request_initial( - resource_group_name: str, - application_definition_name: str, - subscription_id: str, - **kwargs: Any -) -> HttpRequest: - api_version = kwargs.pop('api_version', "2018-06-01") # type: str - - accept = "application/json" - # Construct URL - _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Solutions/applicationDefinitions/{applicationDefinitionName}") # pylint: disable=line-too-long - path_format_arguments = { - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._\(\)]+$'), - "applicationDefinitionName": _SERIALIZER.url("application_definition_name", application_definition_name, 'str', max_length=64, min_length=3), - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), - } - - _url = _format_url_section(_url, **path_format_arguments) - - # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') - - # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') - - return HttpRequest( - method="DELETE", - url=_url, - params=_query_parameters, - headers=_header_parameters, - **kwargs - ) - - -def build_application_definitions_create_or_update_by_id_request_initial( - resource_group_name: str, - application_definition_name: str, - subscription_id: str, - *, - json: JSONType = None, - content: Any = None, - **kwargs: Any -) -> HttpRequest: - api_version = kwargs.pop('api_version', "2018-06-01") # type: str - content_type = kwargs.pop('content_type', None) # type: Optional[str] - - accept = "application/json" - # Construct URL - _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Solutions/applicationDefinitions/{applicationDefinitionName}") # pylint: disable=line-too-long - path_format_arguments = { - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._\(\)]+$'), - "applicationDefinitionName": _SERIALIZER.url("application_definition_name", application_definition_name, 'str', max_length=64, min_length=3), - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), - } - - _url = _format_url_section(_url, **path_format_arguments) - - # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') - - # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - if content_type is not None: - _header_parameters['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') - _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') - - return HttpRequest( - method="PUT", - url=_url, - params=_query_parameters, - headers=_header_parameters, - json=json, - content=content, - **kwargs - ) - -class ApplicationClientOperationsMixin(object): - - @distributed_trace - def list_operations( - self, - **kwargs: Any - ) -> Iterable["_models.OperationListResult"]: - """Lists all of the available Microsoft.Solutions REST API operations. - - :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either OperationListResult or the result of cls(response) - :rtype: - ~azure.core.paging.ItemPaged[~azure.mgmt.resource.managedapplications.models.OperationListResult] - :raises: ~azure.core.exceptions.HttpResponseError - """ - api_version = kwargs.pop('api_version', "2018-06-01") # type: str - - cls = kwargs.pop('cls', None) # type: ClsType["_models.OperationListResult"] - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {})) - def prepare_request(next_link=None): - if not next_link: - - request = build_list_operations_request( - api_version=api_version, - template_url=self.list_operations.metadata['url'], - ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) - - else: - - request = build_list_operations_request( - template_url=next_link, - ) - 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("OperationListResult", pipeline_response) - list_of_elem = deserialized.value - if cls: - list_of_elem = cls(list_of_elem) - 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( # pylint: disable=protected-access - request, - stream=False, - **kwargs - ) - response = pipeline_response.http_response - - if response.status_code not in [200]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - raise HttpResponseError(response=response, error_format=ARMErrorFormat) - - return pipeline_response - - - return ItemPaged( - get_next, extract_data - ) - list_operations.metadata = {'url': "/providers/Microsoft.Solutions/operations"} # type: ignore -class ApplicationsOperations(object): - """ApplicationsOperations operations. - - You should not instantiate this class directly. Instead, you should create a Client instance that - instantiates it for you and attaches it as an attribute. - - :ivar models: Alias to model classes used in this operation group. - :type models: ~azure.mgmt.resource.managedapplications.models - :param client: Client for service requests. - :param config: Configuration of service client. - :param serializer: An object model serializer. - :param deserializer: An object model deserializer. - """ - - models = _models - - def __init__(self, client, config, serializer, deserializer): - self._client = client - self._serialize = serializer - self._deserialize = deserializer - self._config = config - - @distributed_trace - def get( - self, - resource_group_name: str, - application_name: str, - **kwargs: Any - ) -> Optional["_models.Application"]: - """Gets the managed application. - - :param resource_group_name: The name of the resource group. The name is case insensitive. - :type resource_group_name: str - :param application_name: The name of the managed application. - :type application_name: str - :keyword callable cls: A custom type or function that will be passed the direct response - :return: Application, or the result of cls(response) - :rtype: ~azure.mgmt.resource.managedapplications.models.Application or None - :raises: ~azure.core.exceptions.HttpResponseError - """ - cls = kwargs.pop('cls', None) # type: ClsType[Optional["_models.Application"]] - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {})) - - api_version = kwargs.pop('api_version', "2018-06-01") # type: str - - - request = build_applications_get_request( - resource_group_name=resource_group_name, - application_name=application_name, - subscription_id=self._config.subscription_id, - api_version=api_version, - template_url=self.get.metadata['url'], - ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) - - pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs - ) - response = pipeline_response.http_response - - if response.status_code not in [200, 404]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) - raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - - deserialized = None - if response.status_code == 200: - deserialized = self._deserialize('Application', pipeline_response) - - if cls: - return cls(pipeline_response, deserialized, {}) - - return deserialized - - get.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Solutions/applications/{applicationName}"} # type: ignore - - - def _delete_initial( # pylint: disable=inconsistent-return-statements - self, - resource_group_name: str, - application_name: str, - **kwargs: Any - ) -> None: - cls = kwargs.pop('cls', None) # type: ClsType[None] - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {})) - - api_version = kwargs.pop('api_version', "2018-06-01") # type: str - - - request = build_applications_delete_request_initial( - resource_group_name=resource_group_name, - application_name=application_name, - subscription_id=self._config.subscription_id, - api_version=api_version, - template_url=self._delete_initial.metadata['url'], - ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) - - pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs - ) - response = pipeline_response.http_response - - if response.status_code not in [202, 204]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - raise HttpResponseError(response=response, error_format=ARMErrorFormat) - - if cls: - return cls(pipeline_response, None, {}) - - _delete_initial.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Solutions/applications/{applicationName}"} # type: ignore - - - @distributed_trace - def begin_delete( # pylint: disable=inconsistent-return-statements - self, - resource_group_name: str, - application_name: str, - **kwargs: Any - ) -> LROPoller[None]: - """Deletes the managed application. - - :param resource_group_name: The name of the resource group. The name is case insensitive. - :type resource_group_name: str - :param application_name: The name of the managed application. - :type application_name: str - :keyword callable cls: A custom type or function that will be passed the direct response - :keyword str continuation_token: A continuation token to restart a poller from a saved state. - :keyword polling: By default, your polling method will be ARMPolling. Pass in False for this - operation to not poll, or pass in your own initialized polling object for a personal polling - strategy. - :paramtype polling: bool or ~azure.core.polling.PollingMethod - :keyword int polling_interval: Default waiting time between two polls for LRO operations if no - Retry-After header is present. - :return: An instance of LROPoller that returns either None or the result of cls(response) - :rtype: ~azure.core.polling.LROPoller[None] - :raises: ~azure.core.exceptions.HttpResponseError - """ - api_version = kwargs.pop('api_version', "2018-06-01") # type: str - polling = kwargs.pop('polling', True) # type: Union[bool, PollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType[None] - lro_delay = kwargs.pop( - 'polling_interval', - self._config.polling_interval - ) - cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] - if cont_token is None: - raw_result = self._delete_initial( - resource_group_name=resource_group_name, - application_name=application_name, - api_version=api_version, - cls=lambda x,y,z: x, - **kwargs - ) - kwargs.pop('error_map', None) - - def get_long_running_output(pipeline_response): - if cls: - return cls(pipeline_response, None, {}) - - - if polling is True: polling_method = ARMPolling(lro_delay, **kwargs) - elif polling is False: polling_method = NoPolling() - else: polling_method = polling - if cont_token: - return LROPoller.from_continuation_token( - polling_method=polling_method, - continuation_token=cont_token, - client=self._client, - deserialization_callback=get_long_running_output - ) - return LROPoller(self._client, raw_result, get_long_running_output, polling_method) - - begin_delete.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Solutions/applications/{applicationName}"} # type: ignore - - def _create_or_update_initial( - self, - resource_group_name: str, - application_name: str, - parameters: "_models.Application", - **kwargs: Any - ) -> "_models.Application": - cls = kwargs.pop('cls', None) # type: ClsType["_models.Application"] - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {})) - - api_version = kwargs.pop('api_version', "2018-06-01") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] - - _json = self._serialize.body(parameters, 'Application') - - request = build_applications_create_or_update_request_initial( - resource_group_name=resource_group_name, - application_name=application_name, - subscription_id=self._config.subscription_id, - api_version=api_version, - content_type=content_type, - json=_json, - template_url=self._create_or_update_initial.metadata['url'], - ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) - - pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs - ) - response = pipeline_response.http_response - - if response.status_code not in [200, 201]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - raise HttpResponseError(response=response, error_format=ARMErrorFormat) - - if response.status_code == 200: - deserialized = self._deserialize('Application', pipeline_response) - - if response.status_code == 201: - deserialized = self._deserialize('Application', pipeline_response) - - if cls: - return cls(pipeline_response, deserialized, {}) - - return deserialized - - _create_or_update_initial.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Solutions/applications/{applicationName}"} # type: ignore - - - @distributed_trace - def begin_create_or_update( - self, - resource_group_name: str, - application_name: str, - parameters: "_models.Application", - **kwargs: Any - ) -> LROPoller["_models.Application"]: - """Creates a new managed application. - - :param resource_group_name: The name of the resource group. The name is case insensitive. - :type resource_group_name: str - :param application_name: The name of the managed application. - :type application_name: str - :param parameters: Parameters supplied to the create or update a managed application. - :type parameters: ~azure.mgmt.resource.managedapplications.models.Application - :keyword callable cls: A custom type or function that will be passed the direct response - :keyword str continuation_token: A continuation token to restart a poller from a saved state. - :keyword polling: By default, your polling method will be ARMPolling. Pass in False for this - operation to not poll, or pass in your own initialized polling object for a personal polling - strategy. - :paramtype polling: bool or ~azure.core.polling.PollingMethod - :keyword int polling_interval: Default waiting time between two polls for LRO operations if no - Retry-After header is present. - :return: An instance of LROPoller that returns either Application or the result of - cls(response) - :rtype: - ~azure.core.polling.LROPoller[~azure.mgmt.resource.managedapplications.models.Application] - :raises: ~azure.core.exceptions.HttpResponseError - """ - api_version = kwargs.pop('api_version', "2018-06-01") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] - polling = kwargs.pop('polling', True) # type: Union[bool, PollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType["_models.Application"] - lro_delay = kwargs.pop( - 'polling_interval', - self._config.polling_interval - ) - cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] - if cont_token is None: - raw_result = self._create_or_update_initial( - resource_group_name=resource_group_name, - application_name=application_name, - parameters=parameters, - api_version=api_version, - content_type=content_type, - cls=lambda x,y,z: x, - **kwargs - ) - kwargs.pop('error_map', None) - - def get_long_running_output(pipeline_response): - response = pipeline_response.http_response - deserialized = self._deserialize('Application', pipeline_response) - if cls: - return cls(pipeline_response, deserialized, {}) - return deserialized - - - if polling is True: polling_method = ARMPolling(lro_delay, **kwargs) - elif polling is False: polling_method = NoPolling() - else: polling_method = polling - if cont_token: - return LROPoller.from_continuation_token( - polling_method=polling_method, - continuation_token=cont_token, - client=self._client, - deserialization_callback=get_long_running_output - ) - return LROPoller(self._client, raw_result, get_long_running_output, polling_method) - - begin_create_or_update.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Solutions/applications/{applicationName}"} # type: ignore - - @distributed_trace - def update( - self, - resource_group_name: str, - application_name: str, - parameters: Optional["_models.ApplicationPatchable"] = None, - **kwargs: Any - ) -> "_models.Application": - """Updates an existing managed application. The only value that can be updated via PATCH currently - is the tags. - - :param resource_group_name: The name of the resource group. The name is case insensitive. - :type resource_group_name: str - :param application_name: The name of the managed application. - :type application_name: str - :param parameters: Parameters supplied to update an existing managed application. Default value - is None. - :type parameters: ~azure.mgmt.resource.managedapplications.models.ApplicationPatchable - :keyword callable cls: A custom type or function that will be passed the direct response - :return: Application, or the result of cls(response) - :rtype: ~azure.mgmt.resource.managedapplications.models.Application - :raises: ~azure.core.exceptions.HttpResponseError - """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.Application"] - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {})) - - api_version = kwargs.pop('api_version', "2018-06-01") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] - - if parameters is not None: - _json = self._serialize.body(parameters, 'ApplicationPatchable') - else: - _json = None - - request = build_applications_update_request( - resource_group_name=resource_group_name, - application_name=application_name, - subscription_id=self._config.subscription_id, - api_version=api_version, - content_type=content_type, - json=_json, - template_url=self.update.metadata['url'], - ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) - - pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **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.ErrorResponse, pipeline_response) - raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - - deserialized = self._deserialize('Application', pipeline_response) - - if cls: - return cls(pipeline_response, deserialized, {}) - - return deserialized - - update.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Solutions/applications/{applicationName}"} # type: ignore - - - @distributed_trace - def list_by_resource_group( - self, - resource_group_name: str, - **kwargs: Any - ) -> Iterable["_models.ApplicationListResult"]: - """Gets all the applications within a resource group. - - :param resource_group_name: The name of the resource group. The name is case insensitive. - :type resource_group_name: str - :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either ApplicationListResult or the result of - cls(response) - :rtype: - ~azure.core.paging.ItemPaged[~azure.mgmt.resource.managedapplications.models.ApplicationListResult] - :raises: ~azure.core.exceptions.HttpResponseError - """ - api_version = kwargs.pop('api_version', "2018-06-01") # type: str - - cls = kwargs.pop('cls', None) # type: ClsType["_models.ApplicationListResult"] - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {})) - def prepare_request(next_link=None): - if not next_link: - - request = build_applications_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'], - ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) - - else: - - request = build_applications_list_by_resource_group_request( - resource_group_name=resource_group_name, - subscription_id=self._config.subscription_id, - template_url=next_link, - ) - 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("ApplicationListResult", pipeline_response) - list_of_elem = deserialized.value - if cls: - list_of_elem = cls(list_of_elem) - 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( # pylint: disable=protected-access - request, - stream=False, - **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.ErrorResponse, pipeline_response) - raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - - return pipeline_response - - - return ItemPaged( - get_next, extract_data - ) - list_by_resource_group.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Solutions/applications"} # type: ignore - - @distributed_trace - def list_by_subscription( - self, - **kwargs: Any - ) -> Iterable["_models.ApplicationListResult"]: - """Gets all the applications within a subscription. - - :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either ApplicationListResult or the result of - cls(response) - :rtype: - ~azure.core.paging.ItemPaged[~azure.mgmt.resource.managedapplications.models.ApplicationListResult] - :raises: ~azure.core.exceptions.HttpResponseError - """ - api_version = kwargs.pop('api_version', "2018-06-01") # type: str - - cls = kwargs.pop('cls', None) # type: ClsType["_models.ApplicationListResult"] - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {})) - def prepare_request(next_link=None): - if not next_link: - - request = build_applications_list_by_subscription_request( - subscription_id=self._config.subscription_id, - api_version=api_version, - template_url=self.list_by_subscription.metadata['url'], - ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) - - else: - - request = build_applications_list_by_subscription_request( - subscription_id=self._config.subscription_id, - template_url=next_link, - ) - 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("ApplicationListResult", pipeline_response) - list_of_elem = deserialized.value - if cls: - list_of_elem = cls(list_of_elem) - 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( # pylint: disable=protected-access - request, - stream=False, - **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.ErrorResponse, pipeline_response) - raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - - return pipeline_response - - - return ItemPaged( - get_next, extract_data - ) - list_by_subscription.metadata = {'url': "/subscriptions/{subscriptionId}/providers/Microsoft.Solutions/applications"} # type: ignore - - @distributed_trace - def get_by_id( - self, - application_id: str, - **kwargs: Any - ) -> Optional["_models.Application"]: - """Gets the managed application. - - :param application_id: The fully qualified ID of the managed application, including the managed - application name and the managed application resource type. Use the format, - /subscriptions/{guid}/resourceGroups/{resource-group-name}/Microsoft.Solutions/applications/{application-name}. - :type application_id: str - :keyword callable cls: A custom type or function that will be passed the direct response - :return: Application, or the result of cls(response) - :rtype: ~azure.mgmt.resource.managedapplications.models.Application or None - :raises: ~azure.core.exceptions.HttpResponseError - """ - cls = kwargs.pop('cls', None) # type: ClsType[Optional["_models.Application"]] - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {})) - - api_version = kwargs.pop('api_version', "2018-06-01") # type: str - - - request = build_applications_get_by_id_request( - application_id=application_id, - api_version=api_version, - template_url=self.get_by_id.metadata['url'], - ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) - - pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs - ) - response = pipeline_response.http_response - - if response.status_code not in [200, 404]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) - raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - - deserialized = None - if response.status_code == 200: - deserialized = self._deserialize('Application', pipeline_response) - - if cls: - return cls(pipeline_response, deserialized, {}) - - return deserialized - - get_by_id.metadata = {'url': "/{applicationId}"} # type: ignore - - - def _delete_by_id_initial( # pylint: disable=inconsistent-return-statements - self, - application_id: str, - **kwargs: Any - ) -> None: - cls = kwargs.pop('cls', None) # type: ClsType[None] - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {})) - - api_version = kwargs.pop('api_version', "2018-06-01") # type: str - - - request = build_applications_delete_by_id_request_initial( - application_id=application_id, - api_version=api_version, - template_url=self._delete_by_id_initial.metadata['url'], - ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) - - pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs - ) - response = pipeline_response.http_response - - if response.status_code not in [202, 204]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - raise HttpResponseError(response=response, error_format=ARMErrorFormat) - - if cls: - return cls(pipeline_response, None, {}) - - _delete_by_id_initial.metadata = {'url': "/{applicationId}"} # type: ignore - - - @distributed_trace - def begin_delete_by_id( # pylint: disable=inconsistent-return-statements - self, - application_id: str, - **kwargs: Any - ) -> LROPoller[None]: - """Deletes the managed application. - - :param application_id: The fully qualified ID of the managed application, including the managed - application name and the managed application resource type. Use the format, - /subscriptions/{guid}/resourceGroups/{resource-group-name}/Microsoft.Solutions/applications/{application-name}. - :type application_id: str - :keyword callable cls: A custom type or function that will be passed the direct response - :keyword str continuation_token: A continuation token to restart a poller from a saved state. - :keyword polling: By default, your polling method will be ARMPolling. Pass in False for this - operation to not poll, or pass in your own initialized polling object for a personal polling - strategy. - :paramtype polling: bool or ~azure.core.polling.PollingMethod - :keyword int polling_interval: Default waiting time between two polls for LRO operations if no - Retry-After header is present. - :return: An instance of LROPoller that returns either None or the result of cls(response) - :rtype: ~azure.core.polling.LROPoller[None] - :raises: ~azure.core.exceptions.HttpResponseError - """ - api_version = kwargs.pop('api_version', "2018-06-01") # type: str - polling = kwargs.pop('polling', True) # type: Union[bool, PollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType[None] - lro_delay = kwargs.pop( - 'polling_interval', - self._config.polling_interval - ) - cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] - if cont_token is None: - raw_result = self._delete_by_id_initial( - application_id=application_id, - api_version=api_version, - cls=lambda x,y,z: x, - **kwargs - ) - kwargs.pop('error_map', None) - - def get_long_running_output(pipeline_response): - if cls: - return cls(pipeline_response, None, {}) - - - if polling is True: polling_method = ARMPolling(lro_delay, **kwargs) - elif polling is False: polling_method = NoPolling() - else: polling_method = polling - if cont_token: - return LROPoller.from_continuation_token( - polling_method=polling_method, - continuation_token=cont_token, - client=self._client, - deserialization_callback=get_long_running_output - ) - return LROPoller(self._client, raw_result, get_long_running_output, polling_method) - - begin_delete_by_id.metadata = {'url': "/{applicationId}"} # type: ignore - - def _create_or_update_by_id_initial( - self, - application_id: str, - parameters: "_models.Application", - **kwargs: Any - ) -> "_models.Application": - cls = kwargs.pop('cls', None) # type: ClsType["_models.Application"] - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {})) - - api_version = kwargs.pop('api_version', "2018-06-01") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] - - _json = self._serialize.body(parameters, 'Application') - - request = build_applications_create_or_update_by_id_request_initial( - application_id=application_id, - api_version=api_version, - content_type=content_type, - json=_json, - template_url=self._create_or_update_by_id_initial.metadata['url'], - ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) - - pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs - ) - response = pipeline_response.http_response - - if response.status_code not in [200, 201]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - raise HttpResponseError(response=response, error_format=ARMErrorFormat) - - if response.status_code == 200: - deserialized = self._deserialize('Application', pipeline_response) - - if response.status_code == 201: - deserialized = self._deserialize('Application', pipeline_response) - - if cls: - return cls(pipeline_response, deserialized, {}) - - return deserialized - - _create_or_update_by_id_initial.metadata = {'url': "/{applicationId}"} # type: ignore - - - @distributed_trace - def begin_create_or_update_by_id( - self, - application_id: str, - parameters: "_models.Application", - **kwargs: Any - ) -> LROPoller["_models.Application"]: - """Creates a new managed application. - - :param application_id: The fully qualified ID of the managed application, including the managed - application name and the managed application resource type. Use the format, - /subscriptions/{guid}/resourceGroups/{resource-group-name}/Microsoft.Solutions/applications/{application-name}. - :type application_id: str - :param parameters: Parameters supplied to the create or update a managed application. - :type parameters: ~azure.mgmt.resource.managedapplications.models.Application - :keyword callable cls: A custom type or function that will be passed the direct response - :keyword str continuation_token: A continuation token to restart a poller from a saved state. - :keyword polling: By default, your polling method will be ARMPolling. Pass in False for this - operation to not poll, or pass in your own initialized polling object for a personal polling - strategy. - :paramtype polling: bool or ~azure.core.polling.PollingMethod - :keyword int polling_interval: Default waiting time between two polls for LRO operations if no - Retry-After header is present. - :return: An instance of LROPoller that returns either Application or the result of - cls(response) - :rtype: - ~azure.core.polling.LROPoller[~azure.mgmt.resource.managedapplications.models.Application] - :raises: ~azure.core.exceptions.HttpResponseError - """ - api_version = kwargs.pop('api_version', "2018-06-01") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] - polling = kwargs.pop('polling', True) # type: Union[bool, PollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType["_models.Application"] - lro_delay = kwargs.pop( - 'polling_interval', - self._config.polling_interval - ) - cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] - if cont_token is None: - raw_result = self._create_or_update_by_id_initial( - application_id=application_id, - parameters=parameters, - api_version=api_version, - content_type=content_type, - cls=lambda x,y,z: x, - **kwargs - ) - kwargs.pop('error_map', None) - - def get_long_running_output(pipeline_response): - response = pipeline_response.http_response - deserialized = self._deserialize('Application', pipeline_response) - if cls: - return cls(pipeline_response, deserialized, {}) - return deserialized - - - if polling is True: polling_method = ARMPolling(lro_delay, **kwargs) - elif polling is False: polling_method = NoPolling() - else: polling_method = polling - if cont_token: - return LROPoller.from_continuation_token( - polling_method=polling_method, - continuation_token=cont_token, - client=self._client, - deserialization_callback=get_long_running_output - ) - return LROPoller(self._client, raw_result, get_long_running_output, polling_method) - - begin_create_or_update_by_id.metadata = {'url': "/{applicationId}"} # type: ignore - - @distributed_trace - def update_by_id( - self, - application_id: str, - parameters: Optional["_models.Application"] = None, - **kwargs: Any - ) -> "_models.Application": - """Updates an existing managed application. The only value that can be updated via PATCH currently - is the tags. - - :param application_id: The fully qualified ID of the managed application, including the managed - application name and the managed application resource type. Use the format, - /subscriptions/{guid}/resourceGroups/{resource-group-name}/Microsoft.Solutions/applications/{application-name}. - :type application_id: str - :param parameters: Parameters supplied to update an existing managed application. Default value - is None. - :type parameters: ~azure.mgmt.resource.managedapplications.models.Application - :keyword callable cls: A custom type or function that will be passed the direct response - :return: Application, or the result of cls(response) - :rtype: ~azure.mgmt.resource.managedapplications.models.Application - :raises: ~azure.core.exceptions.HttpResponseError - """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.Application"] - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {})) - - api_version = kwargs.pop('api_version', "2018-06-01") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] - - if parameters is not None: - _json = self._serialize.body(parameters, 'Application') - else: - _json = None - - request = build_applications_update_by_id_request( - application_id=application_id, - api_version=api_version, - content_type=content_type, - json=_json, - template_url=self.update_by_id.metadata['url'], - ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) - - pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **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.ErrorResponse, pipeline_response) - raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - - deserialized = self._deserialize('Application', pipeline_response) - - if cls: - return cls(pipeline_response, deserialized, {}) - - return deserialized - - update_by_id.metadata = {'url': "/{applicationId}"} # type: ignore - -class ApplicationDefinitionsOperations(object): - """ApplicationDefinitionsOperations operations. - - You should not instantiate this class directly. Instead, you should create a Client instance that - instantiates it for you and attaches it as an attribute. - - :ivar models: Alias to model classes used in this operation group. - :type models: ~azure.mgmt.resource.managedapplications.models - :param client: Client for service requests. - :param config: Configuration of service client. - :param serializer: An object model serializer. - :param deserializer: An object model deserializer. - """ - - models = _models - - def __init__(self, client, config, serializer, deserializer): - self._client = client - self._serialize = serializer - self._deserialize = deserializer - self._config = config - - @distributed_trace - def get( - self, - resource_group_name: str, - application_definition_name: str, - **kwargs: Any - ) -> Optional["_models.ApplicationDefinition"]: - """Gets the managed application definition. - - :param resource_group_name: The name of the resource group. The name is case insensitive. - :type resource_group_name: str - :param application_definition_name: The name of the managed application definition. - :type application_definition_name: str - :keyword callable cls: A custom type or function that will be passed the direct response - :return: ApplicationDefinition, or the result of cls(response) - :rtype: ~azure.mgmt.resource.managedapplications.models.ApplicationDefinition or None - :raises: ~azure.core.exceptions.HttpResponseError - """ - cls = kwargs.pop('cls', None) # type: ClsType[Optional["_models.ApplicationDefinition"]] - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {})) - - api_version = kwargs.pop('api_version', "2018-06-01") # type: str - - - request = build_application_definitions_get_request( - resource_group_name=resource_group_name, - application_definition_name=application_definition_name, - subscription_id=self._config.subscription_id, - api_version=api_version, - template_url=self.get.metadata['url'], - ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) - - pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs - ) - response = pipeline_response.http_response - - if response.status_code not in [200, 404]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) - raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - - deserialized = None - if response.status_code == 200: - deserialized = self._deserialize('ApplicationDefinition', pipeline_response) - - if cls: - return cls(pipeline_response, deserialized, {}) - - return deserialized - - get.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Solutions/applicationDefinitions/{applicationDefinitionName}"} # type: ignore - - - def _delete_initial( # pylint: disable=inconsistent-return-statements - self, - resource_group_name: str, - application_definition_name: str, - **kwargs: Any - ) -> None: - cls = kwargs.pop('cls', None) # type: ClsType[None] - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {})) - - api_version = kwargs.pop('api_version', "2018-06-01") # type: str - - - request = build_application_definitions_delete_request_initial( - resource_group_name=resource_group_name, - application_definition_name=application_definition_name, - subscription_id=self._config.subscription_id, - api_version=api_version, - template_url=self._delete_initial.metadata['url'], - ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) - - pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs - ) - response = pipeline_response.http_response - - if response.status_code not in [200, 202, 204]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - raise HttpResponseError(response=response, error_format=ARMErrorFormat) - - if cls: - return cls(pipeline_response, None, {}) - - _delete_initial.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Solutions/applicationDefinitions/{applicationDefinitionName}"} # type: ignore - - - @distributed_trace - def begin_delete( # pylint: disable=inconsistent-return-statements - self, - resource_group_name: str, - application_definition_name: str, - **kwargs: Any - ) -> LROPoller[None]: - """Deletes the managed application definition. - - :param resource_group_name: The name of the resource group. The name is case insensitive. - :type resource_group_name: str - :param application_definition_name: The name of the managed application definition to delete. - :type application_definition_name: str - :keyword callable cls: A custom type or function that will be passed the direct response - :keyword str continuation_token: A continuation token to restart a poller from a saved state. - :keyword polling: By default, your polling method will be ARMPolling. Pass in False for this - operation to not poll, or pass in your own initialized polling object for a personal polling - strategy. - :paramtype polling: bool or ~azure.core.polling.PollingMethod - :keyword int polling_interval: Default waiting time between two polls for LRO operations if no - Retry-After header is present. - :return: An instance of LROPoller that returns either None or the result of cls(response) - :rtype: ~azure.core.polling.LROPoller[None] - :raises: ~azure.core.exceptions.HttpResponseError - """ - api_version = kwargs.pop('api_version', "2018-06-01") # type: str - polling = kwargs.pop('polling', True) # type: Union[bool, PollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType[None] - lro_delay = kwargs.pop( - 'polling_interval', - self._config.polling_interval - ) - cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] - if cont_token is None: - raw_result = self._delete_initial( - resource_group_name=resource_group_name, - application_definition_name=application_definition_name, - api_version=api_version, - cls=lambda x,y,z: x, - **kwargs - ) - kwargs.pop('error_map', None) - - def get_long_running_output(pipeline_response): - if cls: - return cls(pipeline_response, None, {}) - - - if polling is True: polling_method = ARMPolling(lro_delay, **kwargs) - elif polling is False: polling_method = NoPolling() - else: polling_method = polling - if cont_token: - return LROPoller.from_continuation_token( - polling_method=polling_method, - continuation_token=cont_token, - client=self._client, - deserialization_callback=get_long_running_output - ) - return LROPoller(self._client, raw_result, get_long_running_output, polling_method) - - begin_delete.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Solutions/applicationDefinitions/{applicationDefinitionName}"} # type: ignore - - def _create_or_update_initial( - self, - resource_group_name: str, - application_definition_name: str, - parameters: "_models.ApplicationDefinition", - **kwargs: Any - ) -> "_models.ApplicationDefinition": - cls = kwargs.pop('cls', None) # type: ClsType["_models.ApplicationDefinition"] - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {})) - - api_version = kwargs.pop('api_version', "2018-06-01") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] - - _json = self._serialize.body(parameters, 'ApplicationDefinition') - - request = build_application_definitions_create_or_update_request_initial( - resource_group_name=resource_group_name, - application_definition_name=application_definition_name, - subscription_id=self._config.subscription_id, - api_version=api_version, - content_type=content_type, - json=_json, - template_url=self._create_or_update_initial.metadata['url'], - ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) - - pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs - ) - response = pipeline_response.http_response - - if response.status_code not in [200, 201]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - raise HttpResponseError(response=response, error_format=ARMErrorFormat) - - if response.status_code == 200: - deserialized = self._deserialize('ApplicationDefinition', pipeline_response) - - if response.status_code == 201: - deserialized = self._deserialize('ApplicationDefinition', pipeline_response) - - if cls: - return cls(pipeline_response, deserialized, {}) - - return deserialized - - _create_or_update_initial.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Solutions/applicationDefinitions/{applicationDefinitionName}"} # type: ignore - - - @distributed_trace - def begin_create_or_update( - self, - resource_group_name: str, - application_definition_name: str, - parameters: "_models.ApplicationDefinition", - **kwargs: Any - ) -> LROPoller["_models.ApplicationDefinition"]: - """Creates a new managed application definition. - - :param resource_group_name: The name of the resource group. The name is case insensitive. - :type resource_group_name: str - :param application_definition_name: The name of the managed application definition. - :type application_definition_name: str - :param parameters: Parameters supplied to the create or update an managed application - definition. - :type parameters: ~azure.mgmt.resource.managedapplications.models.ApplicationDefinition - :keyword callable cls: A custom type or function that will be passed the direct response - :keyword str continuation_token: A continuation token to restart a poller from a saved state. - :keyword polling: By default, your polling method will be ARMPolling. Pass in False for this - operation to not poll, or pass in your own initialized polling object for a personal polling - strategy. - :paramtype polling: bool or ~azure.core.polling.PollingMethod - :keyword int polling_interval: Default waiting time between two polls for LRO operations if no - Retry-After header is present. - :return: An instance of LROPoller that returns either ApplicationDefinition or the result of - cls(response) - :rtype: - ~azure.core.polling.LROPoller[~azure.mgmt.resource.managedapplications.models.ApplicationDefinition] - :raises: ~azure.core.exceptions.HttpResponseError - """ - api_version = kwargs.pop('api_version', "2018-06-01") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] - polling = kwargs.pop('polling', True) # type: Union[bool, PollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType["_models.ApplicationDefinition"] - lro_delay = kwargs.pop( - 'polling_interval', - self._config.polling_interval - ) - cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] - if cont_token is None: - raw_result = self._create_or_update_initial( - resource_group_name=resource_group_name, - application_definition_name=application_definition_name, - parameters=parameters, - api_version=api_version, - content_type=content_type, - cls=lambda x,y,z: x, - **kwargs - ) - kwargs.pop('error_map', None) - - def get_long_running_output(pipeline_response): - response = pipeline_response.http_response - deserialized = self._deserialize('ApplicationDefinition', pipeline_response) - if cls: - return cls(pipeline_response, deserialized, {}) - return deserialized - - - if polling is True: polling_method = ARMPolling(lro_delay, **kwargs) - elif polling is False: polling_method = NoPolling() - else: polling_method = polling - if cont_token: - return LROPoller.from_continuation_token( - polling_method=polling_method, - continuation_token=cont_token, - client=self._client, - deserialization_callback=get_long_running_output - ) - return LROPoller(self._client, raw_result, get_long_running_output, polling_method) - - begin_create_or_update.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Solutions/applicationDefinitions/{applicationDefinitionName}"} # type: ignore - - @distributed_trace - def list_by_resource_group( - self, - resource_group_name: str, - **kwargs: Any - ) -> Iterable["_models.ApplicationDefinitionListResult"]: - """Lists the managed application definitions in a resource group. - - :param resource_group_name: The name of the resource group. The name is case insensitive. - :type resource_group_name: str - :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either ApplicationDefinitionListResult or the result of - cls(response) - :rtype: - ~azure.core.paging.ItemPaged[~azure.mgmt.resource.managedapplications.models.ApplicationDefinitionListResult] - :raises: ~azure.core.exceptions.HttpResponseError - """ - api_version = kwargs.pop('api_version', "2018-06-01") # type: str - - cls = kwargs.pop('cls', None) # type: ClsType["_models.ApplicationDefinitionListResult"] - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {})) - def prepare_request(next_link=None): - if not next_link: - - request = build_application_definitions_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'], - ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) - - else: - - request = build_application_definitions_list_by_resource_group_request( - resource_group_name=resource_group_name, - subscription_id=self._config.subscription_id, - template_url=next_link, - ) - 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("ApplicationDefinitionListResult", pipeline_response) - list_of_elem = deserialized.value - if cls: - list_of_elem = cls(list_of_elem) - 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( # pylint: disable=protected-access - request, - stream=False, - **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.ErrorResponse, pipeline_response) - raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - - return pipeline_response - - - return ItemPaged( - get_next, extract_data - ) - list_by_resource_group.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Solutions/applicationDefinitions"} # type: ignore - - @distributed_trace - def get_by_id( - self, - resource_group_name: str, - application_definition_name: str, - **kwargs: Any - ) -> Optional["_models.ApplicationDefinition"]: - """Gets the managed application definition. - - :param resource_group_name: The name of the resource group. The name is case insensitive. - :type resource_group_name: str - :param application_definition_name: The name of the managed application definition. - :type application_definition_name: str - :keyword callable cls: A custom type or function that will be passed the direct response - :return: ApplicationDefinition, or the result of cls(response) - :rtype: ~azure.mgmt.resource.managedapplications.models.ApplicationDefinition or None - :raises: ~azure.core.exceptions.HttpResponseError - """ - cls = kwargs.pop('cls', None) # type: ClsType[Optional["_models.ApplicationDefinition"]] - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {})) - - api_version = kwargs.pop('api_version', "2018-06-01") # type: str - - - request = build_application_definitions_get_by_id_request( - resource_group_name=resource_group_name, - application_definition_name=application_definition_name, - subscription_id=self._config.subscription_id, - api_version=api_version, - template_url=self.get_by_id.metadata['url'], - ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) - - pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs - ) - response = pipeline_response.http_response - - if response.status_code not in [200, 404]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) - raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - - deserialized = None - if response.status_code == 200: - deserialized = self._deserialize('ApplicationDefinition', pipeline_response) - - if cls: - return cls(pipeline_response, deserialized, {}) - - return deserialized - - get_by_id.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Solutions/applicationDefinitions/{applicationDefinitionName}"} # type: ignore - - - def _delete_by_id_initial( # pylint: disable=inconsistent-return-statements - self, - resource_group_name: str, - application_definition_name: str, - **kwargs: Any - ) -> None: - cls = kwargs.pop('cls', None) # type: ClsType[None] - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {})) - - api_version = kwargs.pop('api_version', "2018-06-01") # type: str - - - request = build_application_definitions_delete_by_id_request_initial( - resource_group_name=resource_group_name, - application_definition_name=application_definition_name, - subscription_id=self._config.subscription_id, - api_version=api_version, - template_url=self._delete_by_id_initial.metadata['url'], - ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) - - pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs - ) - response = pipeline_response.http_response - - if response.status_code not in [200, 202, 204]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - raise HttpResponseError(response=response, error_format=ARMErrorFormat) - - if cls: - return cls(pipeline_response, None, {}) - - _delete_by_id_initial.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Solutions/applicationDefinitions/{applicationDefinitionName}"} # type: ignore - - - @distributed_trace - def begin_delete_by_id( # pylint: disable=inconsistent-return-statements - self, - resource_group_name: str, - application_definition_name: str, - **kwargs: Any - ) -> LROPoller[None]: - """Deletes the managed application definition. - - :param resource_group_name: The name of the resource group. The name is case insensitive. - :type resource_group_name: str - :param application_definition_name: The name of the managed application definition. - :type application_definition_name: str - :keyword callable cls: A custom type or function that will be passed the direct response - :keyword str continuation_token: A continuation token to restart a poller from a saved state. - :keyword polling: By default, your polling method will be ARMPolling. Pass in False for this - operation to not poll, or pass in your own initialized polling object for a personal polling - strategy. - :paramtype polling: bool or ~azure.core.polling.PollingMethod - :keyword int polling_interval: Default waiting time between two polls for LRO operations if no - Retry-After header is present. - :return: An instance of LROPoller that returns either None or the result of cls(response) - :rtype: ~azure.core.polling.LROPoller[None] - :raises: ~azure.core.exceptions.HttpResponseError - """ - api_version = kwargs.pop('api_version', "2018-06-01") # type: str - polling = kwargs.pop('polling', True) # type: Union[bool, PollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType[None] - lro_delay = kwargs.pop( - 'polling_interval', - self._config.polling_interval - ) - cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] - if cont_token is None: - raw_result = self._delete_by_id_initial( - resource_group_name=resource_group_name, - application_definition_name=application_definition_name, - api_version=api_version, - cls=lambda x,y,z: x, - **kwargs - ) - kwargs.pop('error_map', None) - - def get_long_running_output(pipeline_response): - if cls: - return cls(pipeline_response, None, {}) - - - if polling is True: polling_method = ARMPolling(lro_delay, **kwargs) - elif polling is False: polling_method = NoPolling() - else: polling_method = polling - if cont_token: - return LROPoller.from_continuation_token( - polling_method=polling_method, - continuation_token=cont_token, - client=self._client, - deserialization_callback=get_long_running_output - ) - return LROPoller(self._client, raw_result, get_long_running_output, polling_method) - - begin_delete_by_id.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Solutions/applicationDefinitions/{applicationDefinitionName}"} # type: ignore - - def _create_or_update_by_id_initial( - self, - resource_group_name: str, - application_definition_name: str, - parameters: "_models.ApplicationDefinition", - **kwargs: Any - ) -> "_models.ApplicationDefinition": - cls = kwargs.pop('cls', None) # type: ClsType["_models.ApplicationDefinition"] - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {})) - - api_version = kwargs.pop('api_version', "2018-06-01") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] - - _json = self._serialize.body(parameters, 'ApplicationDefinition') - - request = build_application_definitions_create_or_update_by_id_request_initial( - resource_group_name=resource_group_name, - application_definition_name=application_definition_name, - subscription_id=self._config.subscription_id, - api_version=api_version, - content_type=content_type, - json=_json, - template_url=self._create_or_update_by_id_initial.metadata['url'], - ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) - - pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs - ) - response = pipeline_response.http_response - - if response.status_code not in [200, 201]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - raise HttpResponseError(response=response, error_format=ARMErrorFormat) - - if response.status_code == 200: - deserialized = self._deserialize('ApplicationDefinition', pipeline_response) - - if response.status_code == 201: - deserialized = self._deserialize('ApplicationDefinition', pipeline_response) - - if cls: - return cls(pipeline_response, deserialized, {}) - - return deserialized - - _create_or_update_by_id_initial.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Solutions/applicationDefinitions/{applicationDefinitionName}"} # type: ignore - - - @distributed_trace - def begin_create_or_update_by_id( - self, - resource_group_name: str, - application_definition_name: str, - parameters: "_models.ApplicationDefinition", - **kwargs: Any - ) -> LROPoller["_models.ApplicationDefinition"]: - """Creates a new managed application definition. - - :param resource_group_name: The name of the resource group. The name is case insensitive. - :type resource_group_name: str - :param application_definition_name: The name of the managed application definition. - :type application_definition_name: str - :param parameters: Parameters supplied to the create or update a managed application - definition. - :type parameters: ~azure.mgmt.resource.managedapplications.models.ApplicationDefinition - :keyword callable cls: A custom type or function that will be passed the direct response - :keyword str continuation_token: A continuation token to restart a poller from a saved state. - :keyword polling: By default, your polling method will be ARMPolling. Pass in False for this - operation to not poll, or pass in your own initialized polling object for a personal polling - strategy. - :paramtype polling: bool or ~azure.core.polling.PollingMethod - :keyword int polling_interval: Default waiting time between two polls for LRO operations if no - Retry-After header is present. - :return: An instance of LROPoller that returns either ApplicationDefinition or the result of - cls(response) - :rtype: - ~azure.core.polling.LROPoller[~azure.mgmt.resource.managedapplications.models.ApplicationDefinition] - :raises: ~azure.core.exceptions.HttpResponseError - """ - api_version = kwargs.pop('api_version', "2018-06-01") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] - polling = kwargs.pop('polling', True) # type: Union[bool, PollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType["_models.ApplicationDefinition"] - lro_delay = kwargs.pop( - 'polling_interval', - self._config.polling_interval - ) - cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] - if cont_token is None: - raw_result = self._create_or_update_by_id_initial( - resource_group_name=resource_group_name, - application_definition_name=application_definition_name, - parameters=parameters, - api_version=api_version, - content_type=content_type, - cls=lambda x,y,z: x, - **kwargs - ) - kwargs.pop('error_map', None) - - def get_long_running_output(pipeline_response): - response = pipeline_response.http_response - deserialized = self._deserialize('ApplicationDefinition', pipeline_response) - if cls: - return cls(pipeline_response, deserialized, {}) - return deserialized - - - if polling is True: polling_method = ARMPolling(lro_delay, **kwargs) - elif polling is False: polling_method = NoPolling() - else: polling_method = polling - if cont_token: - return LROPoller.from_continuation_token( - polling_method=polling_method, - continuation_token=cont_token, - client=self._client, - deserialization_callback=get_long_running_output - ) - return LROPoller(self._client, raw_result, get_long_running_output, polling_method) - - begin_create_or_update_by_id.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Solutions/applicationDefinitions/{applicationDefinitionName}"} # type: ignore diff --git a/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/managedapplications/v2018_06_01/__init__.py b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/managedapplications/v2018_06_01/__init__.py new file mode 100644 index 0000000000000..f4ca5c50120f5 --- /dev/null +++ b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/managedapplications/v2018_06_01/__init__.py @@ -0,0 +1,24 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- + +from ._application_client import ApplicationClient +from ._version import VERSION + +__version__ = VERSION + +try: + from ._patch import __all__ as _patch_all + from ._patch import * # type: ignore # pylint: disable=unused-wildcard-import +except ImportError: + _patch_all = [] +from ._patch import patch_sdk as _patch_sdk + +__all__ = ["ApplicationClient"] +__all__.extend([p for p in _patch_all if p not in __all__]) + +_patch_sdk() diff --git a/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/managedapplications/v2018_06_01/_application_client.py b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/managedapplications/v2018_06_01/_application_client.py new file mode 100644 index 0000000000000..4c2e3aa392175 --- /dev/null +++ b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/managedapplications/v2018_06_01/_application_client.py @@ -0,0 +1,99 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- + +from copy import deepcopy +from typing import Any, TYPE_CHECKING + +from azure.core.rest import HttpRequest, HttpResponse +from azure.mgmt.core import ARMPipelineClient + +from . import models +from .._serialization import Deserializer, Serializer +from ._configuration import ApplicationClientConfiguration +from .operations import ApplicationClientOperationsMixin, ApplicationDefinitionsOperations, ApplicationsOperations + +if TYPE_CHECKING: + # pylint: disable=unused-import,ungrouped-imports + from azure.core.credentials import TokenCredential + + +class ApplicationClient(ApplicationClientOperationsMixin): # pylint: disable=client-accepts-api-version-keyword + """ARM applications. + + :ivar applications: ApplicationsOperations operations + :vartype applications: + azure.mgmt.resource.managedapplications.v2018_06_01.operations.ApplicationsOperations + :ivar application_definitions: ApplicationDefinitionsOperations operations + :vartype application_definitions: + azure.mgmt.resource.managedapplications.v2018_06_01.operations.ApplicationDefinitionsOperations + :param credential: Credential needed for the client to connect to Azure. Required. + :type credential: ~azure.core.credentials.TokenCredential + :param subscription_id: The ID of the target subscription. Required. + :type subscription_id: str + :param base_url: Service URL. Default value is "https://management.azure.com". + :type base_url: str + :keyword api_version: Api Version. Default value is "2018-06-01". Note that overriding this + default value may result in unsupported behavior. + :paramtype api_version: str + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + """ + + def __init__( + self, + credential: "TokenCredential", + subscription_id: str, + base_url: str = "https://management.azure.com", + **kwargs: Any + ) -> None: + self._config = ApplicationClientConfiguration(credential=credential, subscription_id=subscription_id, **kwargs) + self._client = ARMPipelineClient(base_url=base_url, config=self._config, **kwargs) + + client_models = {k: v for k, v in models.__dict__.items() if isinstance(v, type)} + self._serialize = Serializer(client_models) + self._deserialize = Deserializer(client_models) + self._serialize.client_side_validation = False + self.applications = ApplicationsOperations(self._client, self._config, self._serialize, self._deserialize) + self.application_definitions = ApplicationDefinitionsOperations( + self._client, self._config, self._serialize, self._deserialize + ) + + def _send_request(self, request: HttpRequest, **kwargs: Any) -> HttpResponse: + """Runs the network request through the client's chained policies. + + >>> from azure.core.rest import HttpRequest + >>> request = HttpRequest("GET", "https://www.example.org/") + + >>> response = client._send_request(request) + + + For more information on this code flow, see https://aka.ms/azsdk/dpcodegen/python/send_request + + :param request: The network request you want to make. Required. + :type request: ~azure.core.rest.HttpRequest + :keyword bool stream: Whether the response payload will be streamed. Defaults to False. + :return: The response of your network call. Does not do error handling on your response. + :rtype: ~azure.core.rest.HttpResponse + """ + + request_copy = deepcopy(request) + request_copy.url = self._client.format_url(request_copy.url) + return self._client.send_request(request_copy, **kwargs) + + def close(self): + # type: () -> None + self._client.close() + + def __enter__(self): + # type: () -> ApplicationClient + self._client.__enter__() + return self + + def __exit__(self, *exc_details): + # type: (Any) -> None + self._client.__exit__(*exc_details) diff --git a/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/managedapplications/v2018_06_01/_configuration.py b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/managedapplications/v2018_06_01/_configuration.py new file mode 100644 index 0000000000000..0e68fc0a79844 --- /dev/null +++ b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/managedapplications/v2018_06_01/_configuration.py @@ -0,0 +1,69 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- + +from typing import Any, TYPE_CHECKING + +from azure.core.configuration import Configuration +from azure.core.pipeline import policies +from azure.mgmt.core.policies import ARMChallengeAuthenticationPolicy, ARMHttpLoggingPolicy + +from ._version import VERSION + +if TYPE_CHECKING: + # pylint: disable=unused-import,ungrouped-imports + from azure.core.credentials import TokenCredential + + +class ApplicationClientConfiguration(Configuration): # pylint: disable=too-many-instance-attributes + """Configuration for ApplicationClient. + + Note that all parameters used to create this instance are saved as instance + attributes. + + :param credential: Credential needed for the client to connect to Azure. Required. + :type credential: ~azure.core.credentials.TokenCredential + :param subscription_id: The ID of the target subscription. Required. + :type subscription_id: str + :keyword api_version: Api Version. Default value is "2018-06-01". Note that overriding this + default value may result in unsupported behavior. + :paramtype api_version: str + """ + + def __init__(self, credential: "TokenCredential", subscription_id: str, **kwargs: Any) -> None: + super(ApplicationClientConfiguration, self).__init__(**kwargs) + api_version = kwargs.pop("api_version", "2018-06-01") # type: str + + if credential is None: + raise ValueError("Parameter 'credential' must not be None.") + if subscription_id is None: + raise ValueError("Parameter 'subscription_id' must not be None.") + + self.credential = credential + self.subscription_id = subscription_id + self.api_version = api_version + self.credential_scopes = kwargs.pop("credential_scopes", ["https://management.azure.com/.default"]) + kwargs.setdefault("sdk_moniker", "mgmt-resource/{}".format(VERSION)) + self._configure(**kwargs) + + def _configure( + self, **kwargs # type: Any + ): + # type: (...) -> 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) + self.logging_policy = kwargs.get("logging_policy") or policies.NetworkTraceLoggingPolicy(**kwargs) + self.http_logging_policy = kwargs.get("http_logging_policy") or ARMHttpLoggingPolicy(**kwargs) + self.retry_policy = kwargs.get("retry_policy") or policies.RetryPolicy(**kwargs) + self.custom_hook_policy = kwargs.get("custom_hook_policy") or policies.CustomHookPolicy(**kwargs) + self.redirect_policy = kwargs.get("redirect_policy") or policies.RedirectPolicy(**kwargs) + self.authentication_policy = kwargs.get("authentication_policy") + if self.credential and not self.authentication_policy: + self.authentication_policy = ARMChallengeAuthenticationPolicy( + self.credential, *self.credential_scopes, **kwargs + ) diff --git a/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/managedapplications/_metadata.json b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/managedapplications/v2018_06_01/_metadata.json similarity index 69% rename from sdk/resources/azure-mgmt-resource/azure/mgmt/resource/managedapplications/_metadata.json rename to sdk/resources/azure-mgmt-resource/azure/mgmt/resource/managedapplications/v2018_06_01/_metadata.json index 31d15a4efd26d..b7101fa94b792 100644 --- a/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/managedapplications/_metadata.json +++ b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/managedapplications/v2018_06_01/_metadata.json @@ -10,20 +10,20 @@ "azure_arm": true, "has_lro_operations": true, "client_side_validation": false, - "sync_imports": "{\"typing\": {\"azurecore\": {\"azure.core.credentials\": [\"TokenCredential\"]}}, \"regular\": {\"azurecore\": {\"azure.profiles\": [\"KnownProfiles\", \"ProfileDefinition\"], \"azure.profiles.multiapiclient\": [\"MultiApiClientMixin\"], \"azure.mgmt.core\": [\"ARMPipelineClient\"]}, \"local\": {\"._configuration\": [\"ApplicationClientConfiguration\"], \"._operations_mixin\": [\"ApplicationClientOperationsMixin\"]}, \"thirdparty\": {\"msrest\": [\"Deserializer\", \"Serializer\"]}}, \"conditional\": {\"stdlib\": {\"typing\": [\"Any\", \"Optional\"]}}}", - "async_imports": "{\"typing\": {\"azurecore\": {\"azure.core.credentials_async\": [\"AsyncTokenCredential\"], \"azure.core.credentials\": [\"TokenCredential\"]}}, \"regular\": {\"azurecore\": {\"azure.profiles\": [\"KnownProfiles\", \"ProfileDefinition\"], \"azure.profiles.multiapiclient\": [\"MultiApiClientMixin\"], \"azure.mgmt.core\": [\"AsyncARMPipelineClient\"]}, \"local\": {\"._configuration\": [\"ApplicationClientConfiguration\"], \"._operations_mixin\": [\"ApplicationClientOperationsMixin\"]}, \"thirdparty\": {\"msrest\": [\"Deserializer\", \"Serializer\"]}}, \"conditional\": {\"stdlib\": {\"typing\": [\"Any\", \"Optional\"]}}}" + "sync_imports": "{\"conditional\": {\"stdlib\": {\"typing\": [\"Any\", \"Optional\"]}}, \"regular\": {\"azurecore\": {\"azure.mgmt.core\": [\"ARMPipelineClient\"], \"azure.profiles\": [\"KnownProfiles\", \"ProfileDefinition\"], \"azure.profiles.multiapiclient\": [\"MultiApiClientMixin\"]}, \"local\": {\"._configuration\": [\"ApplicationClientConfiguration\"], \".._serialization\": [\"Deserializer\", \"Serializer\"], \"._operations_mixin\": [\"ApplicationClientOperationsMixin\"]}}, \"typing\": {\"azurecore\": {\"azure.core.credentials\": [\"TokenCredential\"]}}}", + "async_imports": "{\"conditional\": {\"stdlib\": {\"typing\": [\"Any\", \"Optional\"]}}, \"regular\": {\"azurecore\": {\"azure.mgmt.core\": [\"AsyncARMPipelineClient\"], \"azure.profiles\": [\"KnownProfiles\", \"ProfileDefinition\"], \"azure.profiles.multiapiclient\": [\"MultiApiClientMixin\"]}, \"local\": {\"._configuration\": [\"ApplicationClientConfiguration\"], \"..._serialization\": [\"Deserializer\", \"Serializer\"], \"._operations_mixin\": [\"ApplicationClientOperationsMixin\"]}}, \"typing\": {\"azurecore\": {\"azure.core.credentials_async\": [\"AsyncTokenCredential\"]}}}" }, "global_parameters": { "sync": { "credential": { - "signature": "credential, # type: \"TokenCredential\"", - "description": "Credential needed for the client to connect to Azure.", + "signature": "credential: \"TokenCredential\",", + "description": "Credential needed for the client to connect to Azure. Required.", "docstring_type": "~azure.core.credentials.TokenCredential", "required": true }, "subscription_id": { - "signature": "subscription_id, # type: str", - "description": "The ID of the target subscription.", + "signature": "subscription_id: str,", + "description": "The ID of the target subscription. Required.", "docstring_type": "str", "required": true } @@ -31,13 +31,13 @@ "async": { "credential": { "signature": "credential: \"AsyncTokenCredential\",", - "description": "Credential needed for the client to connect to Azure.", + "description": "Credential needed for the client to connect to Azure. Required.", "docstring_type": "~azure.core.credentials_async.AsyncTokenCredential", "required": true }, "subscription_id": { "signature": "subscription_id: str,", - "description": "The ID of the target subscription.", + "description": "The ID of the target subscription. Required.", "docstring_type": "str", "required": true } @@ -54,7 +54,7 @@ "required": false }, "base_url": { - "signature": "base_url=\"https://management.azure.com\", # type: str", + "signature": "base_url: str = \"https://management.azure.com\",", "description": "Service URL", "docstring_type": "str", "required": false @@ -101,20 +101,21 @@ "application_definitions": "ApplicationDefinitionsOperations" }, "operation_mixins": { - "sync_imports": "{\"conditional\": {\"stdlib\": {\"typing\": [\"Any\", \"Iterable\"]}, \"azurecore\": {\"azure.core.paging\": [\"ItemPaged\"]}}}", - "async_imports": "{\"conditional\": {\"stdlib\": {\"typing\": [\"Any\", \"AsyncIterable\"]}, \"azurecore\": {\"azure.core.async_paging\": [\"AsyncItemPaged\"]}}}", + "sync_imports": "{\"conditional\": {\"stdlib\": {\"typing\": [\"Any\", \"Iterable\"]}}, \"regular\": {\"local\": {\".\": [[\"models\", \"_models\"]]}, \"azurecore\": {\"azure.core.paging\": [\"ItemPaged\"]}}}", + "async_imports": "{\"conditional\": {\"stdlib\": {\"typing\": [\"Any\", \"AsyncIterable\"]}}, \"regular\": {\"local\": {\"..\": [[\"models\", \"_models\"]]}, \"azurecore\": {\"azure.core.async_paging\": [\"AsyncItemPaged\"]}}}", "operations": { "list_operations" : { "sync": { - "signature": "def list_operations(\n self,\n **kwargs # type: Any\n):\n # type: (...) -\u003e Iterable[\"_models.OperationListResult\"]\n", - "doc": "\"\"\"Lists all of the available Microsoft.Solutions REST API operations.\n\n:keyword callable cls: A custom type or function that will be passed the direct response\n:return: An iterator like instance of either OperationListResult or the result of cls(response)\n:rtype:\n ~azure.core.paging.ItemPaged[~azure.mgmt.resource.managedapplications.models.OperationListResult]\n:raises: ~azure.core.exceptions.HttpResponseError\n\"\"\"" + "signature": "def list_operations(\n self,\n **kwargs: Any\n) -\u003e Iterable[\"_models.Operation\"]:\n", + "doc": "\"\"\"Lists all of the available Microsoft.Solutions REST API operations.\n\n:keyword callable cls: A custom type or function that will be passed the direct response\n:return: An iterator like instance of either Operation or the result of cls(response)\n:rtype:\n ~azure.core.paging.ItemPaged[~azure.mgmt.resource.managedapplications.v2018_06_01.models.Operation]\n:raises ~azure.core.exceptions.HttpResponseError:\n\"\"\"", + "call": "**kwargs" }, "async": { "coroutine": false, - "signature": "def list_operations(\n self,\n **kwargs: Any\n) -\u003e AsyncIterable[\"_models.OperationListResult\"]:\n", - "doc": "\"\"\"Lists all of the available Microsoft.Solutions REST API operations.\n\n:keyword callable cls: A custom type or function that will be passed the direct response\n:return: An iterator like instance of either OperationListResult or the result of cls(response)\n:rtype:\n ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.resource.managedapplications.models.OperationListResult]\n:raises: ~azure.core.exceptions.HttpResponseError\n\"\"\"" - }, - "call": "" + "signature": "def list_operations(\n self,\n **kwargs: Any\n) -\u003e AsyncIterable[\"_models.Operation\"]:\n", + "doc": "\"\"\"Lists all of the available Microsoft.Solutions REST API operations.\n\n:keyword callable cls: A custom type or function that will be passed the direct response\n:return: An iterator like instance of either Operation or the result of cls(response)\n:rtype:\n ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.resource.managedapplications.v2018_06_01.models.Operation]\n:raises ~azure.core.exceptions.HttpResponseError:\n\"\"\"", + "call": "**kwargs" + } } } } diff --git a/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/managedapplications/v2018_06_01/_patch.py b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/managedapplications/v2018_06_01/_patch.py new file mode 100644 index 0000000000000..f7dd32510333d --- /dev/null +++ b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/managedapplications/v2018_06_01/_patch.py @@ -0,0 +1,20 @@ +# ------------------------------------ +# Copyright (c) Microsoft Corporation. +# Licensed under the MIT License. +# ------------------------------------ +"""Customize generated code here. + +Follow our quickstart for examples: https://aka.ms/azsdk/python/dpcodegen/python/customize +""" +from typing import List + +__all__: List[str] = [] # Add all objects you want publicly available to users at this package level + + +def patch_sdk(): + """Do not remove from this file. + + `patch_sdk` is a last resort escape hatch that allows you to do customizations + you can't accomplish using the techniques described in + https://aka.ms/azsdk/python/dpcodegen/python/customize + """ diff --git a/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/managedapplications/_vendor.py b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/managedapplications/v2018_06_01/_vendor.py similarity index 63% rename from sdk/resources/azure-mgmt-resource/azure/mgmt/resource/managedapplications/_vendor.py rename to sdk/resources/azure-mgmt-resource/azure/mgmt/resource/managedapplications/v2018_06_01/_vendor.py index 138f663c53a4e..38abc3c34c9ca 100644 --- a/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/managedapplications/_vendor.py +++ b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/managedapplications/v2018_06_01/_vendor.py @@ -5,8 +5,20 @@ # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- +from abc import ABC +from typing import TYPE_CHECKING + from azure.core.pipeline.transport import HttpRequest +from ._configuration import ApplicationClientConfiguration + +if TYPE_CHECKING: + # pylint: disable=unused-import,ungrouped-imports + from azure.core import PipelineClient + + from .._serialization import Deserializer, Serializer + + def _convert_request(request, files=None): data = request.content if not files else None request = HttpRequest(method=request.method, url=request.url, headers=request.headers, data=data) @@ -14,6 +26,7 @@ def _convert_request(request, files=None): request.set_formdata_body(files) return request + def _format_url_section(template, **kwargs): components = template.split("/") while components: @@ -21,7 +34,14 @@ def _format_url_section(template, **kwargs): 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 - ] + components = [c for c in formatted_components if "{}".format(key.args[0]) not in c] template = "/".join(components) + + +class MixinABC(ABC): + """DO NOT use this class. It is for internal typing use only.""" + + _client: "PipelineClient" + _config: ApplicationClientConfiguration + _serialize: "Serializer" + _deserialize: "Deserializer" diff --git a/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/managedapplications/v2018_06_01/_version.py b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/managedapplications/v2018_06_01/_version.py new file mode 100644 index 0000000000000..e5754a47ce68f --- /dev/null +++ b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/managedapplications/v2018_06_01/_version.py @@ -0,0 +1,9 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- + +VERSION = "1.0.0b1" diff --git a/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/managedapplications/v2018_06_01/aio/__init__.py b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/managedapplications/v2018_06_01/aio/__init__.py new file mode 100644 index 0000000000000..ada6f36bad048 --- /dev/null +++ b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/managedapplications/v2018_06_01/aio/__init__.py @@ -0,0 +1,21 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- + +from ._application_client import ApplicationClient + +try: + from ._patch import __all__ as _patch_all + from ._patch import * # type: ignore # pylint: disable=unused-wildcard-import +except ImportError: + _patch_all = [] +from ._patch import patch_sdk as _patch_sdk + +__all__ = ["ApplicationClient"] +__all__.extend([p for p in _patch_all if p not in __all__]) + +_patch_sdk() diff --git a/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/managedapplications/v2018_06_01/aio/_application_client.py b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/managedapplications/v2018_06_01/aio/_application_client.py new file mode 100644 index 0000000000000..c21c0c58b007d --- /dev/null +++ b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/managedapplications/v2018_06_01/aio/_application_client.py @@ -0,0 +1,96 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- + +from copy import deepcopy +from typing import Any, Awaitable, TYPE_CHECKING + +from azure.core.rest import AsyncHttpResponse, HttpRequest +from azure.mgmt.core import AsyncARMPipelineClient + +from .. import models +from ..._serialization import Deserializer, Serializer +from ._configuration import ApplicationClientConfiguration +from .operations import ApplicationClientOperationsMixin, ApplicationDefinitionsOperations, ApplicationsOperations + +if TYPE_CHECKING: + # pylint: disable=unused-import,ungrouped-imports + from azure.core.credentials_async import AsyncTokenCredential + + +class ApplicationClient(ApplicationClientOperationsMixin): # pylint: disable=client-accepts-api-version-keyword + """ARM applications. + + :ivar applications: ApplicationsOperations operations + :vartype applications: + azure.mgmt.resource.managedapplications.v2018_06_01.aio.operations.ApplicationsOperations + :ivar application_definitions: ApplicationDefinitionsOperations operations + :vartype application_definitions: + azure.mgmt.resource.managedapplications.v2018_06_01.aio.operations.ApplicationDefinitionsOperations + :param credential: Credential needed for the client to connect to Azure. Required. + :type credential: ~azure.core.credentials_async.AsyncTokenCredential + :param subscription_id: The ID of the target subscription. Required. + :type subscription_id: str + :param base_url: Service URL. Default value is "https://management.azure.com". + :type base_url: str + :keyword api_version: Api Version. Default value is "2018-06-01". Note that overriding this + default value may result in unsupported behavior. + :paramtype api_version: str + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + """ + + def __init__( + self, + credential: "AsyncTokenCredential", + subscription_id: str, + base_url: str = "https://management.azure.com", + **kwargs: Any + ) -> None: + self._config = ApplicationClientConfiguration(credential=credential, subscription_id=subscription_id, **kwargs) + self._client = AsyncARMPipelineClient(base_url=base_url, config=self._config, **kwargs) + + client_models = {k: v for k, v in models.__dict__.items() if isinstance(v, type)} + self._serialize = Serializer(client_models) + self._deserialize = Deserializer(client_models) + self._serialize.client_side_validation = False + self.applications = ApplicationsOperations(self._client, self._config, self._serialize, self._deserialize) + self.application_definitions = ApplicationDefinitionsOperations( + self._client, self._config, self._serialize, self._deserialize + ) + + def _send_request(self, request: HttpRequest, **kwargs: Any) -> Awaitable[AsyncHttpResponse]: + """Runs the network request through the client's chained policies. + + >>> from azure.core.rest import HttpRequest + >>> request = HttpRequest("GET", "https://www.example.org/") + + >>> response = await client._send_request(request) + + + For more information on this code flow, see https://aka.ms/azsdk/dpcodegen/python/send_request + + :param request: The network request you want to make. Required. + :type request: ~azure.core.rest.HttpRequest + :keyword bool stream: Whether the response payload will be streamed. Defaults to False. + :return: The response of your network call. Does not do error handling on your response. + :rtype: ~azure.core.rest.AsyncHttpResponse + """ + + request_copy = deepcopy(request) + request_copy.url = self._client.format_url(request_copy.url) + return self._client.send_request(request_copy, **kwargs) + + async def close(self) -> None: + await self._client.close() + + async def __aenter__(self) -> "ApplicationClient": + await self._client.__aenter__() + return self + + async def __aexit__(self, *exc_details) -> None: + await self._client.__aexit__(*exc_details) diff --git a/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/managedapplications/v2018_06_01/aio/_configuration.py b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/managedapplications/v2018_06_01/aio/_configuration.py new file mode 100644 index 0000000000000..70672d30f4140 --- /dev/null +++ b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/managedapplications/v2018_06_01/aio/_configuration.py @@ -0,0 +1,66 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- + +from typing import Any, TYPE_CHECKING + +from azure.core.configuration import Configuration +from azure.core.pipeline import policies +from azure.mgmt.core.policies import ARMHttpLoggingPolicy, AsyncARMChallengeAuthenticationPolicy + +from .._version import VERSION + +if TYPE_CHECKING: + # pylint: disable=unused-import,ungrouped-imports + from azure.core.credentials_async import AsyncTokenCredential + + +class ApplicationClientConfiguration(Configuration): # pylint: disable=too-many-instance-attributes + """Configuration for ApplicationClient. + + Note that all parameters used to create this instance are saved as instance + attributes. + + :param credential: Credential needed for the client to connect to Azure. Required. + :type credential: ~azure.core.credentials_async.AsyncTokenCredential + :param subscription_id: The ID of the target subscription. Required. + :type subscription_id: str + :keyword api_version: Api Version. Default value is "2018-06-01". Note that overriding this + default value may result in unsupported behavior. + :paramtype api_version: str + """ + + def __init__(self, credential: "AsyncTokenCredential", subscription_id: str, **kwargs: Any) -> None: + super(ApplicationClientConfiguration, self).__init__(**kwargs) + api_version = kwargs.pop("api_version", "2018-06-01") # type: str + + if credential is None: + raise ValueError("Parameter 'credential' must not be None.") + if subscription_id is None: + raise ValueError("Parameter 'subscription_id' must not be None.") + + self.credential = credential + self.subscription_id = subscription_id + self.api_version = api_version + self.credential_scopes = kwargs.pop("credential_scopes", ["https://management.azure.com/.default"]) + kwargs.setdefault("sdk_moniker", "mgmt-resource/{}".format(VERSION)) + self._configure(**kwargs) + + 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) + self.logging_policy = kwargs.get("logging_policy") or policies.NetworkTraceLoggingPolicy(**kwargs) + self.http_logging_policy = kwargs.get("http_logging_policy") or ARMHttpLoggingPolicy(**kwargs) + self.retry_policy = kwargs.get("retry_policy") or policies.AsyncRetryPolicy(**kwargs) + self.custom_hook_policy = kwargs.get("custom_hook_policy") or policies.CustomHookPolicy(**kwargs) + self.redirect_policy = kwargs.get("redirect_policy") or policies.AsyncRedirectPolicy(**kwargs) + self.authentication_policy = kwargs.get("authentication_policy") + if self.credential and not self.authentication_policy: + self.authentication_policy = AsyncARMChallengeAuthenticationPolicy( + self.credential, *self.credential_scopes, **kwargs + ) diff --git a/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/managedapplications/v2018_06_01/aio/_patch.py b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/managedapplications/v2018_06_01/aio/_patch.py new file mode 100644 index 0000000000000..f7dd32510333d --- /dev/null +++ b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/managedapplications/v2018_06_01/aio/_patch.py @@ -0,0 +1,20 @@ +# ------------------------------------ +# Copyright (c) Microsoft Corporation. +# Licensed under the MIT License. +# ------------------------------------ +"""Customize generated code here. + +Follow our quickstart for examples: https://aka.ms/azsdk/python/dpcodegen/python/customize +""" +from typing import List + +__all__: List[str] = [] # Add all objects you want publicly available to users at this package level + + +def patch_sdk(): + """Do not remove from this file. + + `patch_sdk` is a last resort escape hatch that allows you to do customizations + you can't accomplish using the techniques described in + https://aka.ms/azsdk/python/dpcodegen/python/customize + """ diff --git a/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/managedapplications/v2018_06_01/aio/_vendor.py b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/managedapplications/v2018_06_01/aio/_vendor.py new file mode 100644 index 0000000000000..f22ed665dfb77 --- /dev/null +++ b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/managedapplications/v2018_06_01/aio/_vendor.py @@ -0,0 +1,28 @@ +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- + +from abc import ABC +from typing import TYPE_CHECKING + +from azure.core.pipeline.transport import HttpRequest + +from ._configuration import ApplicationClientConfiguration + +if TYPE_CHECKING: + # pylint: disable=unused-import,ungrouped-imports + from azure.core import AsyncPipelineClient + + from ..._serialization import Deserializer, Serializer + + +class MixinABC(ABC): + """DO NOT use this class. It is for internal typing use only.""" + + _client: "AsyncPipelineClient" + _config: ApplicationClientConfiguration + _serialize: "Serializer" + _deserialize: "Deserializer" diff --git a/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/managedapplications/operations/__init__.py b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/managedapplications/v2018_06_01/aio/operations/__init__.py similarity index 64% rename from sdk/resources/azure-mgmt-resource/azure/mgmt/resource/managedapplications/operations/__init__.py rename to sdk/resources/azure-mgmt-resource/azure/mgmt/resource/managedapplications/v2018_06_01/aio/operations/__init__.py index c37a7d15fb768..fb2a5ff1b798d 100644 --- a/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/managedapplications/operations/__init__.py +++ b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/managedapplications/v2018_06_01/aio/operations/__init__.py @@ -10,8 +10,14 @@ from ._operations import ApplicationsOperations from ._operations import ApplicationDefinitionsOperations +from ._patch import __all__ as _patch_all +from ._patch import * # type: ignore # pylint: disable=unused-wildcard-import +from ._patch import patch_sdk as _patch_sdk + __all__ = [ - 'ApplicationClientOperationsMixin', - 'ApplicationsOperations', - 'ApplicationDefinitionsOperations', + "ApplicationClientOperationsMixin", + "ApplicationsOperations", + "ApplicationDefinitionsOperations", ] +__all__.extend([p for p in _patch_all if p not in __all__]) +_patch_sdk() diff --git a/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/managedapplications/v2018_06_01/aio/operations/_operations.py b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/managedapplications/v2018_06_01/aio/operations/_operations.py new file mode 100644 index 0000000000000..565ed549ce16e --- /dev/null +++ b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/managedapplications/v2018_06_01/aio/operations/_operations.py @@ -0,0 +1,2257 @@ +# pylint: disable=too-many-lines +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- +from typing import Any, AsyncIterable, Callable, Dict, IO, Optional, TypeVar, Union, cast, overload +from urllib.parse import parse_qs, urljoin, urlparse + +from azure.core.async_paging import AsyncItemPaged, AsyncList +from azure.core.exceptions import ( + ClientAuthenticationError, + HttpResponseError, + ResourceExistsError, + ResourceNotFoundError, + ResourceNotModifiedError, + map_error, +) +from azure.core.pipeline import PipelineResponse +from azure.core.pipeline.transport import AsyncHttpResponse +from azure.core.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 +from azure.mgmt.core.polling.async_arm_polling import AsyncARMPolling + +from ... import models as _models +from ..._vendor import _convert_request +from ...operations._operations import ( + build_application_definitions_create_or_update_by_id_request, + build_application_definitions_create_or_update_request, + build_application_definitions_delete_by_id_request, + build_application_definitions_delete_request, + build_application_definitions_get_by_id_request, + build_application_definitions_get_request, + build_application_definitions_list_by_resource_group_request, + build_applications_create_or_update_by_id_request, + build_applications_create_or_update_request, + build_applications_delete_by_id_request, + build_applications_delete_request, + build_applications_get_by_id_request, + build_applications_get_request, + build_applications_list_by_resource_group_request, + build_applications_list_by_subscription_request, + build_applications_update_by_id_request, + build_applications_update_request, + build_list_operations_request, +) +from .._vendor import MixinABC + +T = TypeVar("T") +ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] + + +class ApplicationClientOperationsMixin(MixinABC): + @distributed_trace + def list_operations(self, **kwargs: Any) -> AsyncIterable["_models.Operation"]: + """Lists all of the available Microsoft.Solutions REST API operations. + + :keyword callable cls: A custom type or function that will be passed the direct response + :return: An iterator like instance of either Operation or the result of cls(response) + :rtype: + ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.resource.managedapplications.v2018_06_01.models.Operation] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2018-06-01")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[_models.OperationListResult] + + error_map = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + def prepare_request(next_link=None): + if not next_link: + + request = build_list_operations_request( + api_version=api_version, + template_url=self.list_operations.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 = urlparse(next_link) + _next_request_params = case_insensitive_dict(parse_qs(_parsed_next_link.query)) + _next_request_params["api-version"] = self._config.api_version + request = HttpRequest("GET", 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.method = "GET" + return request + + 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) + 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 + ) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + return pipeline_response + + return AsyncItemPaged(get_next, extract_data) + + list_operations.metadata = {"url": "/providers/Microsoft.Solutions/operations"} # type: ignore + + +class ApplicationsOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. + + Instead, you should access the following operations through + :class:`~azure.mgmt.resource.managedapplications.v2018_06_01.aio.ApplicationClient`'s + :attr:`applications` attribute. + """ + + models = _models + + def __init__(self, *args, **kwargs) -> None: + input_args = list(args) + self._client = input_args.pop(0) if input_args else kwargs.pop("client") + self._config = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") + + @distributed_trace_async + async def get( + self, resource_group_name: str, application_name: str, **kwargs: Any + ) -> Optional[_models.Application]: + """Gets the managed application. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param application_name: The name of the managed application. Required. + :type application_name: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: Application or None or the result of cls(response) + :rtype: ~azure.mgmt.resource.managedapplications.v2018_06_01.models.Application or None + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2018-06-01")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[Optional[_models.Application]] + + request = build_applications_get_request( + resource_group_name=resource_group_name, + application_name=application_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + template_url=self.get.metadata["url"], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore + + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [200, 404]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + deserialized = None + if response.status_code == 200: + deserialized = self._deserialize("Application", pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + + get.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Solutions/applications/{applicationName}"} # type: ignore + + async def _delete_initial( # pylint: disable=inconsistent-return-statements + self, resource_group_name: str, application_name: str, **kwargs: Any + ) -> None: + error_map = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2018-06-01")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[None] + + request = build_applications_delete_request( + resource_group_name=resource_group_name, + application_name=application_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + template_url=self._delete_initial.metadata["url"], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore + + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [202, 204]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + if cls: + return cls(pipeline_response, None, {}) + + _delete_initial.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Solutions/applications/{applicationName}"} # type: ignore + + @distributed_trace_async + async def begin_delete( + self, resource_group_name: str, application_name: str, **kwargs: Any + ) -> AsyncLROPoller[None]: + """Deletes the managed application. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param application_name: The name of the managed application. Required. + :type application_name: str + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be AsyncARMPolling. Pass in False for + this operation to not poll, or pass in your own initialized polling object for a personal + polling strategy. + :paramtype polling: bool or ~azure.core.polling.AsyncPollingMethod + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of AsyncLROPoller that returns either None or the result of cls(response) + :rtype: ~azure.core.polling.AsyncLROPoller[None] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2018-06-01")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[None] + polling = kwargs.pop("polling", True) # type: Union[bool, AsyncPollingMethod] + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token = kwargs.pop("continuation_token", None) # type: Optional[str] + if cont_token is None: + raw_result = await self._delete_initial( # type: ignore + resource_group_name=resource_group_name, + application_name=application_name, + api_version=api_version, + cls=lambda x, y, z: x, + headers=_headers, + params=_params, + **kwargs + ) + kwargs.pop("error_map", None) + + def get_long_running_output(pipeline_response): # pylint: disable=inconsistent-return-statements + if cls: + return cls(pipeline_response, None, {}) + + if polling is True: + polling_method = cast(AsyncPollingMethod, AsyncARMPolling(lro_delay, **kwargs)) # type: AsyncPollingMethod + elif polling is False: + polling_method = cast(AsyncPollingMethod, AsyncNoPolling()) + else: + polling_method = polling + if cont_token: + return AsyncLROPoller.from_continuation_token( + polling_method=polling_method, + continuation_token=cont_token, + client=self._client, + deserialization_callback=get_long_running_output, + ) + return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) + + begin_delete.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Solutions/applications/{applicationName}"} # type: ignore + + async def _create_or_update_initial( + self, resource_group_name: str, application_name: str, parameters: Union[_models.Application, IO], **kwargs: Any + ) -> _models.Application: + error_map = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2018-06-01")) # type: str + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.Application] + + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(parameters, (IO, bytes)): + _content = parameters + else: + _json = self._serialize.body(parameters, "Application") + + request = build_applications_create_or_update_request( + resource_group_name=resource_group_name, + application_name=application_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + content_type=content_type, + json=_json, + content=_content, + template_url=self._create_or_update_initial.metadata["url"], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore + + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [200, 201]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + if response.status_code == 200: + deserialized = self._deserialize("Application", pipeline_response) + + if response.status_code == 201: + deserialized = self._deserialize("Application", pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + + _create_or_update_initial.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Solutions/applications/{applicationName}"} # type: ignore + + @overload + async def begin_create_or_update( + self, + resource_group_name: str, + application_name: str, + parameters: _models.Application, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> AsyncLROPoller[_models.Application]: + """Creates a new managed application. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param application_name: The name of the managed application. Required. + :type application_name: str + :param parameters: Parameters supplied to the create or update a managed application. Required. + :type parameters: ~azure.mgmt.resource.managedapplications.v2018_06_01.models.Application + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be AsyncARMPolling. Pass in False for + this operation to not poll, or pass in your own initialized polling object for a personal + polling strategy. + :paramtype polling: bool or ~azure.core.polling.AsyncPollingMethod + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of AsyncLROPoller that returns either Application or the result of + cls(response) + :rtype: + ~azure.core.polling.AsyncLROPoller[~azure.mgmt.resource.managedapplications.v2018_06_01.models.Application] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + async def begin_create_or_update( + self, + resource_group_name: str, + application_name: str, + parameters: IO, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> AsyncLROPoller[_models.Application]: + """Creates a new managed application. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param application_name: The name of the managed application. Required. + :type application_name: str + :param parameters: Parameters supplied to the create or update a managed application. Required. + :type parameters: IO + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be AsyncARMPolling. Pass in False for + this operation to not poll, or pass in your own initialized polling object for a personal + polling strategy. + :paramtype polling: bool or ~azure.core.polling.AsyncPollingMethod + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of AsyncLROPoller that returns either Application or the result of + cls(response) + :rtype: + ~azure.core.polling.AsyncLROPoller[~azure.mgmt.resource.managedapplications.v2018_06_01.models.Application] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace_async + async def begin_create_or_update( + self, resource_group_name: str, application_name: str, parameters: Union[_models.Application, IO], **kwargs: Any + ) -> AsyncLROPoller[_models.Application]: + """Creates a new managed application. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param application_name: The name of the managed application. Required. + :type application_name: str + :param parameters: Parameters supplied to the create or update a managed application. Is either + a model type or a IO type. Required. + :type parameters: ~azure.mgmt.resource.managedapplications.v2018_06_01.models.Application or IO + :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. + Default value is None. + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be AsyncARMPolling. Pass in False for + this operation to not poll, or pass in your own initialized polling object for a personal + polling strategy. + :paramtype polling: bool or ~azure.core.polling.AsyncPollingMethod + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of AsyncLROPoller that returns either Application or the result of + cls(response) + :rtype: + ~azure.core.polling.AsyncLROPoller[~azure.mgmt.resource.managedapplications.v2018_06_01.models.Application] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _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", "2018-06-01")) # type: str + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.Application] + polling = kwargs.pop("polling", True) # type: Union[bool, AsyncPollingMethod] + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token = kwargs.pop("continuation_token", None) # type: Optional[str] + if cont_token is None: + raw_result = await self._create_or_update_initial( # type: ignore + resource_group_name=resource_group_name, + application_name=application_name, + parameters=parameters, + api_version=api_version, + content_type=content_type, + cls=lambda x, y, z: x, + headers=_headers, + params=_params, + **kwargs + ) + kwargs.pop("error_map", None) + + def get_long_running_output(pipeline_response): + deserialized = self._deserialize("Application", pipeline_response) + if cls: + return cls(pipeline_response, deserialized, {}) + return deserialized + + if polling is True: + polling_method = cast(AsyncPollingMethod, AsyncARMPolling(lro_delay, **kwargs)) # type: AsyncPollingMethod + elif polling is False: + polling_method = cast(AsyncPollingMethod, AsyncNoPolling()) + else: + polling_method = polling + if cont_token: + return AsyncLROPoller.from_continuation_token( + polling_method=polling_method, + continuation_token=cont_token, + client=self._client, + deserialization_callback=get_long_running_output, + ) + return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) + + begin_create_or_update.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Solutions/applications/{applicationName}"} # type: ignore + + @overload + async def update( + self, + resource_group_name: str, + application_name: str, + parameters: Optional[_models.ApplicationPatchable] = None, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.Application: + """Updates an existing managed application. The only value that can be updated via PATCH currently + is the tags. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param application_name: The name of the managed application. Required. + :type application_name: str + :param parameters: Parameters supplied to update an existing managed application. Default value + is None. + :type parameters: + ~azure.mgmt.resource.managedapplications.v2018_06_01.models.ApplicationPatchable + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: Application or the result of cls(response) + :rtype: ~azure.mgmt.resource.managedapplications.v2018_06_01.models.Application + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + async def update( + self, + resource_group_name: str, + application_name: str, + parameters: Optional[IO] = None, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.Application: + """Updates an existing managed application. The only value that can be updated via PATCH currently + is the tags. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param application_name: The name of the managed application. Required. + :type application_name: str + :param parameters: Parameters supplied to update an existing managed application. Default value + is None. + :type parameters: IO + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: Application or the result of cls(response) + :rtype: ~azure.mgmt.resource.managedapplications.v2018_06_01.models.Application + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace_async + async def update( + self, + resource_group_name: str, + application_name: str, + parameters: Optional[Union[_models.ApplicationPatchable, IO]] = None, + **kwargs: Any + ) -> _models.Application: + """Updates an existing managed application. The only value that can be updated via PATCH currently + is the tags. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param application_name: The name of the managed application. Required. + :type application_name: str + :param parameters: Parameters supplied to update an existing managed application. Is either a + model type or a IO type. Default value is None. + :type parameters: + ~azure.mgmt.resource.managedapplications.v2018_06_01.models.ApplicationPatchable or IO + :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. + Default value is None. + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: Application or the result of cls(response) + :rtype: ~azure.mgmt.resource.managedapplications.v2018_06_01.models.Application + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2018-06-01")) # type: str + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.Application] + + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(parameters, (IO, bytes)): + _content = parameters + else: + if parameters is not None: + _json = self._serialize.body(parameters, "ApplicationPatchable") + else: + _json = None + + request = build_applications_update_request( + resource_group_name=resource_group_name, + application_name=application_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + content_type=content_type, + json=_json, + content=_content, + template_url=self.update.metadata["url"], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore + + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + deserialized = self._deserialize("Application", pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + + update.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Solutions/applications/{applicationName}"} # type: ignore + + @distributed_trace + def list_by_resource_group(self, resource_group_name: str, **kwargs: Any) -> AsyncIterable["_models.Application"]: + """Gets all the applications within a resource group. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: An iterator like instance of either Application or the result of cls(response) + :rtype: + ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.resource.managedapplications.v2018_06_01.models.Application] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2018-06-01")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[_models.ApplicationListResult] + + error_map = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + def prepare_request(next_link=None): + if not next_link: + + request = build_applications_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 = urlparse(next_link) + _next_request_params = case_insensitive_dict(parse_qs(_parsed_next_link.query)) + _next_request_params["api-version"] = self._config.api_version + request = HttpRequest("GET", 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.method = "GET" + return request + + async def extract_data(pipeline_response): + deserialized = self._deserialize("ApplicationListResult", pipeline_response) + list_of_elem = deserialized.value + if cls: + list_of_elem = cls(list_of_elem) + 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 + ) + 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.ErrorResponse, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + return pipeline_response + + return AsyncItemPaged(get_next, extract_data) + + list_by_resource_group.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Solutions/applications"} # type: ignore + + @distributed_trace + def list_by_subscription(self, **kwargs: Any) -> AsyncIterable["_models.Application"]: + """Gets all the applications within a subscription. + + :keyword callable cls: A custom type or function that will be passed the direct response + :return: An iterator like instance of either Application or the result of cls(response) + :rtype: + ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.resource.managedapplications.v2018_06_01.models.Application] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2018-06-01")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[_models.ApplicationListResult] + + error_map = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + def prepare_request(next_link=None): + if not next_link: + + request = build_applications_list_by_subscription_request( + subscription_id=self._config.subscription_id, + api_version=api_version, + template_url=self.list_by_subscription.metadata["url"], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore + + else: + # make call to next link with the client's api-version + _parsed_next_link = urlparse(next_link) + _next_request_params = case_insensitive_dict(parse_qs(_parsed_next_link.query)) + _next_request_params["api-version"] = self._config.api_version + request = HttpRequest("GET", 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.method = "GET" + return request + + async def extract_data(pipeline_response): + deserialized = self._deserialize("ApplicationListResult", pipeline_response) + list_of_elem = deserialized.value + if cls: + list_of_elem = cls(list_of_elem) + 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 + ) + 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.ErrorResponse, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + return pipeline_response + + return AsyncItemPaged(get_next, extract_data) + + list_by_subscription.metadata = {"url": "/subscriptions/{subscriptionId}/providers/Microsoft.Solutions/applications"} # type: ignore + + @distributed_trace_async + async def get_by_id(self, application_id: str, **kwargs: Any) -> Optional[_models.Application]: + """Gets the managed application. + + :param application_id: The fully qualified ID of the managed application, including the managed + application name and the managed application resource type. Use the format, + /subscriptions/{guid}/resourceGroups/{resource-group-name}/Microsoft.Solutions/applications/{application-name}. + Required. + :type application_id: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: Application or None or the result of cls(response) + :rtype: ~azure.mgmt.resource.managedapplications.v2018_06_01.models.Application or None + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2018-06-01")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[Optional[_models.Application]] + + request = build_applications_get_by_id_request( + application_id=application_id, + api_version=api_version, + template_url=self.get_by_id.metadata["url"], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore + + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [200, 404]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + deserialized = None + if response.status_code == 200: + deserialized = self._deserialize("Application", pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + + get_by_id.metadata = {"url": "/{applicationId}"} # type: ignore + + async def _delete_by_id_initial( # pylint: disable=inconsistent-return-statements + self, application_id: str, **kwargs: Any + ) -> None: + error_map = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2018-06-01")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[None] + + request = build_applications_delete_by_id_request( + application_id=application_id, + api_version=api_version, + template_url=self._delete_by_id_initial.metadata["url"], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore + + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [202, 204]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + if cls: + return cls(pipeline_response, None, {}) + + _delete_by_id_initial.metadata = {"url": "/{applicationId}"} # type: ignore + + @distributed_trace_async + async def begin_delete_by_id(self, application_id: str, **kwargs: Any) -> AsyncLROPoller[None]: + """Deletes the managed application. + + :param application_id: The fully qualified ID of the managed application, including the managed + application name and the managed application resource type. Use the format, + /subscriptions/{guid}/resourceGroups/{resource-group-name}/Microsoft.Solutions/applications/{application-name}. + Required. + :type application_id: str + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be AsyncARMPolling. Pass in False for + this operation to not poll, or pass in your own initialized polling object for a personal + polling strategy. + :paramtype polling: bool or ~azure.core.polling.AsyncPollingMethod + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of AsyncLROPoller that returns either None or the result of cls(response) + :rtype: ~azure.core.polling.AsyncLROPoller[None] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2018-06-01")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[None] + polling = kwargs.pop("polling", True) # type: Union[bool, AsyncPollingMethod] + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token = kwargs.pop("continuation_token", None) # type: Optional[str] + if cont_token is None: + raw_result = await self._delete_by_id_initial( # type: ignore + application_id=application_id, + api_version=api_version, + cls=lambda x, y, z: x, + headers=_headers, + params=_params, + **kwargs + ) + kwargs.pop("error_map", None) + + def get_long_running_output(pipeline_response): # pylint: disable=inconsistent-return-statements + if cls: + return cls(pipeline_response, None, {}) + + if polling is True: + polling_method = cast(AsyncPollingMethod, AsyncARMPolling(lro_delay, **kwargs)) # type: AsyncPollingMethod + elif polling is False: + polling_method = cast(AsyncPollingMethod, AsyncNoPolling()) + else: + polling_method = polling + if cont_token: + return AsyncLROPoller.from_continuation_token( + polling_method=polling_method, + continuation_token=cont_token, + client=self._client, + deserialization_callback=get_long_running_output, + ) + return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) + + begin_delete_by_id.metadata = {"url": "/{applicationId}"} # type: ignore + + async def _create_or_update_by_id_initial( + self, application_id: str, parameters: Union[_models.Application, IO], **kwargs: Any + ) -> _models.Application: + error_map = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2018-06-01")) # type: str + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.Application] + + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(parameters, (IO, bytes)): + _content = parameters + else: + _json = self._serialize.body(parameters, "Application") + + request = build_applications_create_or_update_by_id_request( + application_id=application_id, + api_version=api_version, + content_type=content_type, + json=_json, + content=_content, + template_url=self._create_or_update_by_id_initial.metadata["url"], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore + + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [200, 201]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + if response.status_code == 200: + deserialized = self._deserialize("Application", pipeline_response) + + if response.status_code == 201: + deserialized = self._deserialize("Application", pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + + _create_or_update_by_id_initial.metadata = {"url": "/{applicationId}"} # type: ignore + + @overload + async def begin_create_or_update_by_id( + self, + application_id: str, + parameters: _models.Application, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> AsyncLROPoller[_models.Application]: + """Creates a new managed application. + + :param application_id: The fully qualified ID of the managed application, including the managed + application name and the managed application resource type. Use the format, + /subscriptions/{guid}/resourceGroups/{resource-group-name}/Microsoft.Solutions/applications/{application-name}. + Required. + :type application_id: str + :param parameters: Parameters supplied to the create or update a managed application. Required. + :type parameters: ~azure.mgmt.resource.managedapplications.v2018_06_01.models.Application + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be AsyncARMPolling. Pass in False for + this operation to not poll, or pass in your own initialized polling object for a personal + polling strategy. + :paramtype polling: bool or ~azure.core.polling.AsyncPollingMethod + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of AsyncLROPoller that returns either Application or the result of + cls(response) + :rtype: + ~azure.core.polling.AsyncLROPoller[~azure.mgmt.resource.managedapplications.v2018_06_01.models.Application] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + async def begin_create_or_update_by_id( + self, application_id: str, parameters: IO, *, content_type: str = "application/json", **kwargs: Any + ) -> AsyncLROPoller[_models.Application]: + """Creates a new managed application. + + :param application_id: The fully qualified ID of the managed application, including the managed + application name and the managed application resource type. Use the format, + /subscriptions/{guid}/resourceGroups/{resource-group-name}/Microsoft.Solutions/applications/{application-name}. + Required. + :type application_id: str + :param parameters: Parameters supplied to the create or update a managed application. Required. + :type parameters: IO + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be AsyncARMPolling. Pass in False for + this operation to not poll, or pass in your own initialized polling object for a personal + polling strategy. + :paramtype polling: bool or ~azure.core.polling.AsyncPollingMethod + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of AsyncLROPoller that returns either Application or the result of + cls(response) + :rtype: + ~azure.core.polling.AsyncLROPoller[~azure.mgmt.resource.managedapplications.v2018_06_01.models.Application] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace_async + async def begin_create_or_update_by_id( + self, application_id: str, parameters: Union[_models.Application, IO], **kwargs: Any + ) -> AsyncLROPoller[_models.Application]: + """Creates a new managed application. + + :param application_id: The fully qualified ID of the managed application, including the managed + application name and the managed application resource type. Use the format, + /subscriptions/{guid}/resourceGroups/{resource-group-name}/Microsoft.Solutions/applications/{application-name}. + Required. + :type application_id: str + :param parameters: Parameters supplied to the create or update a managed application. Is either + a model type or a IO type. Required. + :type parameters: ~azure.mgmt.resource.managedapplications.v2018_06_01.models.Application or IO + :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. + Default value is None. + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be AsyncARMPolling. Pass in False for + this operation to not poll, or pass in your own initialized polling object for a personal + polling strategy. + :paramtype polling: bool or ~azure.core.polling.AsyncPollingMethod + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of AsyncLROPoller that returns either Application or the result of + cls(response) + :rtype: + ~azure.core.polling.AsyncLROPoller[~azure.mgmt.resource.managedapplications.v2018_06_01.models.Application] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _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", "2018-06-01")) # type: str + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.Application] + polling = kwargs.pop("polling", True) # type: Union[bool, AsyncPollingMethod] + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token = kwargs.pop("continuation_token", None) # type: Optional[str] + if cont_token is None: + raw_result = await self._create_or_update_by_id_initial( # type: ignore + application_id=application_id, + parameters=parameters, + api_version=api_version, + content_type=content_type, + cls=lambda x, y, z: x, + headers=_headers, + params=_params, + **kwargs + ) + kwargs.pop("error_map", None) + + def get_long_running_output(pipeline_response): + deserialized = self._deserialize("Application", pipeline_response) + if cls: + return cls(pipeline_response, deserialized, {}) + return deserialized + + if polling is True: + polling_method = cast(AsyncPollingMethod, AsyncARMPolling(lro_delay, **kwargs)) # type: AsyncPollingMethod + elif polling is False: + polling_method = cast(AsyncPollingMethod, AsyncNoPolling()) + else: + polling_method = polling + if cont_token: + return AsyncLROPoller.from_continuation_token( + polling_method=polling_method, + continuation_token=cont_token, + client=self._client, + deserialization_callback=get_long_running_output, + ) + return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) + + begin_create_or_update_by_id.metadata = {"url": "/{applicationId}"} # type: ignore + + @overload + async def update_by_id( + self, + application_id: str, + parameters: Optional[_models.Application] = None, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.Application: + """Updates an existing managed application. The only value that can be updated via PATCH currently + is the tags. + + :param application_id: The fully qualified ID of the managed application, including the managed + application name and the managed application resource type. Use the format, + /subscriptions/{guid}/resourceGroups/{resource-group-name}/Microsoft.Solutions/applications/{application-name}. + Required. + :type application_id: str + :param parameters: Parameters supplied to update an existing managed application. Default value + is None. + :type parameters: ~azure.mgmt.resource.managedapplications.v2018_06_01.models.Application + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: Application or the result of cls(response) + :rtype: ~azure.mgmt.resource.managedapplications.v2018_06_01.models.Application + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + async def update_by_id( + self, + application_id: str, + parameters: Optional[IO] = None, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.Application: + """Updates an existing managed application. The only value that can be updated via PATCH currently + is the tags. + + :param application_id: The fully qualified ID of the managed application, including the managed + application name and the managed application resource type. Use the format, + /subscriptions/{guid}/resourceGroups/{resource-group-name}/Microsoft.Solutions/applications/{application-name}. + Required. + :type application_id: str + :param parameters: Parameters supplied to update an existing managed application. Default value + is None. + :type parameters: IO + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: Application or the result of cls(response) + :rtype: ~azure.mgmt.resource.managedapplications.v2018_06_01.models.Application + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace_async + async def update_by_id( + self, application_id: str, parameters: Optional[Union[_models.Application, IO]] = None, **kwargs: Any + ) -> _models.Application: + """Updates an existing managed application. The only value that can be updated via PATCH currently + is the tags. + + :param application_id: The fully qualified ID of the managed application, including the managed + application name and the managed application resource type. Use the format, + /subscriptions/{guid}/resourceGroups/{resource-group-name}/Microsoft.Solutions/applications/{application-name}. + Required. + :type application_id: str + :param parameters: Parameters supplied to update an existing managed application. Is either a + model type or a IO type. Default value is None. + :type parameters: ~azure.mgmt.resource.managedapplications.v2018_06_01.models.Application or IO + :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. + Default value is None. + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: Application or the result of cls(response) + :rtype: ~azure.mgmt.resource.managedapplications.v2018_06_01.models.Application + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2018-06-01")) # type: str + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.Application] + + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(parameters, (IO, bytes)): + _content = parameters + else: + if parameters is not None: + _json = self._serialize.body(parameters, "Application") + else: + _json = None + + request = build_applications_update_by_id_request( + application_id=application_id, + api_version=api_version, + content_type=content_type, + json=_json, + content=_content, + template_url=self.update_by_id.metadata["url"], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore + + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + deserialized = self._deserialize("Application", pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + + update_by_id.metadata = {"url": "/{applicationId}"} # type: ignore + + +class ApplicationDefinitionsOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. + + Instead, you should access the following operations through + :class:`~azure.mgmt.resource.managedapplications.v2018_06_01.aio.ApplicationClient`'s + :attr:`application_definitions` attribute. + """ + + models = _models + + def __init__(self, *args, **kwargs) -> None: + input_args = list(args) + self._client = input_args.pop(0) if input_args else kwargs.pop("client") + self._config = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") + + @distributed_trace_async + async def get( + self, resource_group_name: str, application_definition_name: str, **kwargs: Any + ) -> Optional[_models.ApplicationDefinition]: + """Gets the managed application definition. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param application_definition_name: The name of the managed application definition. Required. + :type application_definition_name: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: ApplicationDefinition or None or the result of cls(response) + :rtype: ~azure.mgmt.resource.managedapplications.v2018_06_01.models.ApplicationDefinition or + None + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2018-06-01")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[Optional[_models.ApplicationDefinition]] + + request = build_application_definitions_get_request( + resource_group_name=resource_group_name, + application_definition_name=application_definition_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + template_url=self.get.metadata["url"], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore + + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [200, 404]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + deserialized = None + if response.status_code == 200: + deserialized = self._deserialize("ApplicationDefinition", pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + + get.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Solutions/applicationDefinitions/{applicationDefinitionName}"} # type: ignore + + async def _delete_initial( # pylint: disable=inconsistent-return-statements + self, resource_group_name: str, application_definition_name: str, **kwargs: Any + ) -> None: + error_map = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2018-06-01")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[None] + + request = build_application_definitions_delete_request( + resource_group_name=resource_group_name, + application_definition_name=application_definition_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + template_url=self._delete_initial.metadata["url"], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore + + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [200, 202, 204]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + if cls: + return cls(pipeline_response, None, {}) + + _delete_initial.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Solutions/applicationDefinitions/{applicationDefinitionName}"} # type: ignore + + @distributed_trace_async + async def begin_delete( + self, resource_group_name: str, application_definition_name: str, **kwargs: Any + ) -> AsyncLROPoller[None]: + """Deletes the managed application definition. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param application_definition_name: The name of the managed application definition to delete. + Required. + :type application_definition_name: str + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be AsyncARMPolling. Pass in False for + this operation to not poll, or pass in your own initialized polling object for a personal + polling strategy. + :paramtype polling: bool or ~azure.core.polling.AsyncPollingMethod + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of AsyncLROPoller that returns either None or the result of cls(response) + :rtype: ~azure.core.polling.AsyncLROPoller[None] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2018-06-01")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[None] + polling = kwargs.pop("polling", True) # type: Union[bool, AsyncPollingMethod] + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token = kwargs.pop("continuation_token", None) # type: Optional[str] + if cont_token is None: + raw_result = await self._delete_initial( # type: ignore + resource_group_name=resource_group_name, + application_definition_name=application_definition_name, + api_version=api_version, + cls=lambda x, y, z: x, + headers=_headers, + params=_params, + **kwargs + ) + kwargs.pop("error_map", None) + + def get_long_running_output(pipeline_response): # pylint: disable=inconsistent-return-statements + if cls: + return cls(pipeline_response, None, {}) + + if polling is True: + polling_method = cast(AsyncPollingMethod, AsyncARMPolling(lro_delay, **kwargs)) # type: AsyncPollingMethod + elif polling is False: + polling_method = cast(AsyncPollingMethod, AsyncNoPolling()) + else: + polling_method = polling + if cont_token: + return AsyncLROPoller.from_continuation_token( + polling_method=polling_method, + continuation_token=cont_token, + client=self._client, + deserialization_callback=get_long_running_output, + ) + return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) + + begin_delete.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Solutions/applicationDefinitions/{applicationDefinitionName}"} # type: ignore + + async def _create_or_update_initial( + self, + resource_group_name: str, + application_definition_name: str, + parameters: Union[_models.ApplicationDefinition, IO], + **kwargs: Any + ) -> _models.ApplicationDefinition: + error_map = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2018-06-01")) # type: str + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.ApplicationDefinition] + + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(parameters, (IO, bytes)): + _content = parameters + else: + _json = self._serialize.body(parameters, "ApplicationDefinition") + + request = build_application_definitions_create_or_update_request( + resource_group_name=resource_group_name, + application_definition_name=application_definition_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + content_type=content_type, + json=_json, + content=_content, + template_url=self._create_or_update_initial.metadata["url"], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore + + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [200, 201]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + if response.status_code == 200: + deserialized = self._deserialize("ApplicationDefinition", pipeline_response) + + if response.status_code == 201: + deserialized = self._deserialize("ApplicationDefinition", pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + + _create_or_update_initial.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Solutions/applicationDefinitions/{applicationDefinitionName}"} # type: ignore + + @overload + async def begin_create_or_update( + self, + resource_group_name: str, + application_definition_name: str, + parameters: _models.ApplicationDefinition, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> AsyncLROPoller[_models.ApplicationDefinition]: + """Creates a new managed application definition. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param application_definition_name: The name of the managed application definition. Required. + :type application_definition_name: str + :param parameters: Parameters supplied to the create or update an managed application + definition. Required. + :type parameters: + ~azure.mgmt.resource.managedapplications.v2018_06_01.models.ApplicationDefinition + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be AsyncARMPolling. Pass in False for + this operation to not poll, or pass in your own initialized polling object for a personal + polling strategy. + :paramtype polling: bool or ~azure.core.polling.AsyncPollingMethod + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of AsyncLROPoller that returns either ApplicationDefinition or the result + of cls(response) + :rtype: + ~azure.core.polling.AsyncLROPoller[~azure.mgmt.resource.managedapplications.v2018_06_01.models.ApplicationDefinition] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + async def begin_create_or_update( + self, + resource_group_name: str, + application_definition_name: str, + parameters: IO, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> AsyncLROPoller[_models.ApplicationDefinition]: + """Creates a new managed application definition. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param application_definition_name: The name of the managed application definition. Required. + :type application_definition_name: str + :param parameters: Parameters supplied to the create or update an managed application + definition. Required. + :type parameters: IO + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be AsyncARMPolling. Pass in False for + this operation to not poll, or pass in your own initialized polling object for a personal + polling strategy. + :paramtype polling: bool or ~azure.core.polling.AsyncPollingMethod + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of AsyncLROPoller that returns either ApplicationDefinition or the result + of cls(response) + :rtype: + ~azure.core.polling.AsyncLROPoller[~azure.mgmt.resource.managedapplications.v2018_06_01.models.ApplicationDefinition] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace_async + async def begin_create_or_update( + self, + resource_group_name: str, + application_definition_name: str, + parameters: Union[_models.ApplicationDefinition, IO], + **kwargs: Any + ) -> AsyncLROPoller[_models.ApplicationDefinition]: + """Creates a new managed application definition. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param application_definition_name: The name of the managed application definition. Required. + :type application_definition_name: str + :param parameters: Parameters supplied to the create or update an managed application + definition. Is either a model type or a IO type. Required. + :type parameters: + ~azure.mgmt.resource.managedapplications.v2018_06_01.models.ApplicationDefinition or IO + :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. + Default value is None. + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be AsyncARMPolling. Pass in False for + this operation to not poll, or pass in your own initialized polling object for a personal + polling strategy. + :paramtype polling: bool or ~azure.core.polling.AsyncPollingMethod + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of AsyncLROPoller that returns either ApplicationDefinition or the result + of cls(response) + :rtype: + ~azure.core.polling.AsyncLROPoller[~azure.mgmt.resource.managedapplications.v2018_06_01.models.ApplicationDefinition] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _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", "2018-06-01")) # type: str + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.ApplicationDefinition] + polling = kwargs.pop("polling", True) # type: Union[bool, AsyncPollingMethod] + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token = kwargs.pop("continuation_token", None) # type: Optional[str] + if cont_token is None: + raw_result = await self._create_or_update_initial( # type: ignore + resource_group_name=resource_group_name, + application_definition_name=application_definition_name, + parameters=parameters, + api_version=api_version, + content_type=content_type, + cls=lambda x, y, z: x, + headers=_headers, + params=_params, + **kwargs + ) + kwargs.pop("error_map", None) + + def get_long_running_output(pipeline_response): + deserialized = self._deserialize("ApplicationDefinition", pipeline_response) + if cls: + return cls(pipeline_response, deserialized, {}) + return deserialized + + if polling is True: + polling_method = cast(AsyncPollingMethod, AsyncARMPolling(lro_delay, **kwargs)) # type: AsyncPollingMethod + elif polling is False: + polling_method = cast(AsyncPollingMethod, AsyncNoPolling()) + else: + polling_method = polling + if cont_token: + return AsyncLROPoller.from_continuation_token( + polling_method=polling_method, + continuation_token=cont_token, + client=self._client, + deserialization_callback=get_long_running_output, + ) + return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) + + begin_create_or_update.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Solutions/applicationDefinitions/{applicationDefinitionName}"} # type: ignore + + @distributed_trace + def list_by_resource_group( + self, resource_group_name: str, **kwargs: Any + ) -> AsyncIterable["_models.ApplicationDefinition"]: + """Lists the managed application definitions in a resource group. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: An iterator like instance of either ApplicationDefinition or the result of + cls(response) + :rtype: + ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.resource.managedapplications.v2018_06_01.models.ApplicationDefinition] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2018-06-01")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[_models.ApplicationDefinitionListResult] + + error_map = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + def prepare_request(next_link=None): + if not next_link: + + request = build_application_definitions_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 = urlparse(next_link) + _next_request_params = case_insensitive_dict(parse_qs(_parsed_next_link.query)) + _next_request_params["api-version"] = self._config.api_version + request = HttpRequest("GET", 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.method = "GET" + return request + + async def extract_data(pipeline_response): + deserialized = self._deserialize("ApplicationDefinitionListResult", pipeline_response) + list_of_elem = deserialized.value + if cls: + list_of_elem = cls(list_of_elem) + 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 + ) + 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.ErrorResponse, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + return pipeline_response + + return AsyncItemPaged(get_next, extract_data) + + list_by_resource_group.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Solutions/applicationDefinitions"} # type: ignore + + @distributed_trace_async + async def get_by_id( + self, resource_group_name: str, application_definition_name: str, **kwargs: Any + ) -> Optional[_models.ApplicationDefinition]: + """Gets the managed application definition. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param application_definition_name: The name of the managed application definition. Required. + :type application_definition_name: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: ApplicationDefinition or None or the result of cls(response) + :rtype: ~azure.mgmt.resource.managedapplications.v2018_06_01.models.ApplicationDefinition or + None + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2018-06-01")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[Optional[_models.ApplicationDefinition]] + + request = build_application_definitions_get_by_id_request( + resource_group_name=resource_group_name, + application_definition_name=application_definition_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + template_url=self.get_by_id.metadata["url"], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore + + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [200, 404]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + deserialized = None + if response.status_code == 200: + deserialized = self._deserialize("ApplicationDefinition", pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + + get_by_id.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Solutions/applicationDefinitions/{applicationDefinitionName}"} # type: ignore + + async def _delete_by_id_initial( # pylint: disable=inconsistent-return-statements + self, resource_group_name: str, application_definition_name: str, **kwargs: Any + ) -> None: + error_map = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2018-06-01")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[None] + + request = build_application_definitions_delete_by_id_request( + resource_group_name=resource_group_name, + application_definition_name=application_definition_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + template_url=self._delete_by_id_initial.metadata["url"], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore + + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [200, 202, 204]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + if cls: + return cls(pipeline_response, None, {}) + + _delete_by_id_initial.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Solutions/applicationDefinitions/{applicationDefinitionName}"} # type: ignore + + @distributed_trace_async + async def begin_delete_by_id( + self, resource_group_name: str, application_definition_name: str, **kwargs: Any + ) -> AsyncLROPoller[None]: + """Deletes the managed application definition. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param application_definition_name: The name of the managed application definition. Required. + :type application_definition_name: str + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be AsyncARMPolling. Pass in False for + this operation to not poll, or pass in your own initialized polling object for a personal + polling strategy. + :paramtype polling: bool or ~azure.core.polling.AsyncPollingMethod + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of AsyncLROPoller that returns either None or the result of cls(response) + :rtype: ~azure.core.polling.AsyncLROPoller[None] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2018-06-01")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[None] + polling = kwargs.pop("polling", True) # type: Union[bool, AsyncPollingMethod] + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token = kwargs.pop("continuation_token", None) # type: Optional[str] + if cont_token is None: + raw_result = await self._delete_by_id_initial( # type: ignore + resource_group_name=resource_group_name, + application_definition_name=application_definition_name, + api_version=api_version, + cls=lambda x, y, z: x, + headers=_headers, + params=_params, + **kwargs + ) + kwargs.pop("error_map", None) + + def get_long_running_output(pipeline_response): # pylint: disable=inconsistent-return-statements + if cls: + return cls(pipeline_response, None, {}) + + if polling is True: + polling_method = cast(AsyncPollingMethod, AsyncARMPolling(lro_delay, **kwargs)) # type: AsyncPollingMethod + elif polling is False: + polling_method = cast(AsyncPollingMethod, AsyncNoPolling()) + else: + polling_method = polling + if cont_token: + return AsyncLROPoller.from_continuation_token( + polling_method=polling_method, + continuation_token=cont_token, + client=self._client, + deserialization_callback=get_long_running_output, + ) + return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) + + begin_delete_by_id.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Solutions/applicationDefinitions/{applicationDefinitionName}"} # type: ignore + + async def _create_or_update_by_id_initial( + self, + resource_group_name: str, + application_definition_name: str, + parameters: Union[_models.ApplicationDefinition, IO], + **kwargs: Any + ) -> _models.ApplicationDefinition: + error_map = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2018-06-01")) # type: str + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.ApplicationDefinition] + + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(parameters, (IO, bytes)): + _content = parameters + else: + _json = self._serialize.body(parameters, "ApplicationDefinition") + + request = build_application_definitions_create_or_update_by_id_request( + resource_group_name=resource_group_name, + application_definition_name=application_definition_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + content_type=content_type, + json=_json, + content=_content, + template_url=self._create_or_update_by_id_initial.metadata["url"], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore + + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [200, 201]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + if response.status_code == 200: + deserialized = self._deserialize("ApplicationDefinition", pipeline_response) + + if response.status_code == 201: + deserialized = self._deserialize("ApplicationDefinition", pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + + _create_or_update_by_id_initial.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Solutions/applicationDefinitions/{applicationDefinitionName}"} # type: ignore + + @overload + async def begin_create_or_update_by_id( + self, + resource_group_name: str, + application_definition_name: str, + parameters: _models.ApplicationDefinition, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> AsyncLROPoller[_models.ApplicationDefinition]: + """Creates a new managed application definition. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param application_definition_name: The name of the managed application definition. Required. + :type application_definition_name: str + :param parameters: Parameters supplied to the create or update a managed application + definition. Required. + :type parameters: + ~azure.mgmt.resource.managedapplications.v2018_06_01.models.ApplicationDefinition + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be AsyncARMPolling. Pass in False for + this operation to not poll, or pass in your own initialized polling object for a personal + polling strategy. + :paramtype polling: bool or ~azure.core.polling.AsyncPollingMethod + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of AsyncLROPoller that returns either ApplicationDefinition or the result + of cls(response) + :rtype: + ~azure.core.polling.AsyncLROPoller[~azure.mgmt.resource.managedapplications.v2018_06_01.models.ApplicationDefinition] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + async def begin_create_or_update_by_id( + self, + resource_group_name: str, + application_definition_name: str, + parameters: IO, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> AsyncLROPoller[_models.ApplicationDefinition]: + """Creates a new managed application definition. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param application_definition_name: The name of the managed application definition. Required. + :type application_definition_name: str + :param parameters: Parameters supplied to the create or update a managed application + definition. Required. + :type parameters: IO + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be AsyncARMPolling. Pass in False for + this operation to not poll, or pass in your own initialized polling object for a personal + polling strategy. + :paramtype polling: bool or ~azure.core.polling.AsyncPollingMethod + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of AsyncLROPoller that returns either ApplicationDefinition or the result + of cls(response) + :rtype: + ~azure.core.polling.AsyncLROPoller[~azure.mgmt.resource.managedapplications.v2018_06_01.models.ApplicationDefinition] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace_async + async def begin_create_or_update_by_id( + self, + resource_group_name: str, + application_definition_name: str, + parameters: Union[_models.ApplicationDefinition, IO], + **kwargs: Any + ) -> AsyncLROPoller[_models.ApplicationDefinition]: + """Creates a new managed application definition. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param application_definition_name: The name of the managed application definition. Required. + :type application_definition_name: str + :param parameters: Parameters supplied to the create or update a managed application + definition. Is either a model type or a IO type. Required. + :type parameters: + ~azure.mgmt.resource.managedapplications.v2018_06_01.models.ApplicationDefinition or IO + :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. + Default value is None. + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be AsyncARMPolling. Pass in False for + this operation to not poll, or pass in your own initialized polling object for a personal + polling strategy. + :paramtype polling: bool or ~azure.core.polling.AsyncPollingMethod + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of AsyncLROPoller that returns either ApplicationDefinition or the result + of cls(response) + :rtype: + ~azure.core.polling.AsyncLROPoller[~azure.mgmt.resource.managedapplications.v2018_06_01.models.ApplicationDefinition] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _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", "2018-06-01")) # type: str + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.ApplicationDefinition] + polling = kwargs.pop("polling", True) # type: Union[bool, AsyncPollingMethod] + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token = kwargs.pop("continuation_token", None) # type: Optional[str] + if cont_token is None: + raw_result = await self._create_or_update_by_id_initial( # type: ignore + resource_group_name=resource_group_name, + application_definition_name=application_definition_name, + parameters=parameters, + api_version=api_version, + content_type=content_type, + cls=lambda x, y, z: x, + headers=_headers, + params=_params, + **kwargs + ) + kwargs.pop("error_map", None) + + def get_long_running_output(pipeline_response): + deserialized = self._deserialize("ApplicationDefinition", pipeline_response) + if cls: + return cls(pipeline_response, deserialized, {}) + return deserialized + + if polling is True: + polling_method = cast(AsyncPollingMethod, AsyncARMPolling(lro_delay, **kwargs)) # type: AsyncPollingMethod + elif polling is False: + polling_method = cast(AsyncPollingMethod, AsyncNoPolling()) + else: + polling_method = polling + if cont_token: + return AsyncLROPoller.from_continuation_token( + polling_method=polling_method, + continuation_token=cont_token, + client=self._client, + deserialization_callback=get_long_running_output, + ) + return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) + + begin_create_or_update_by_id.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Solutions/applicationDefinitions/{applicationDefinitionName}"} # type: ignore diff --git a/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/managedapplications/v2018_06_01/aio/operations/_patch.py b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/managedapplications/v2018_06_01/aio/operations/_patch.py new file mode 100644 index 0000000000000..f7dd32510333d --- /dev/null +++ b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/managedapplications/v2018_06_01/aio/operations/_patch.py @@ -0,0 +1,20 @@ +# ------------------------------------ +# Copyright (c) Microsoft Corporation. +# Licensed under the MIT License. +# ------------------------------------ +"""Customize generated code here. + +Follow our quickstart for examples: https://aka.ms/azsdk/python/dpcodegen/python/customize +""" +from typing import List + +__all__: List[str] = [] # Add all objects you want publicly available to users at this package level + + +def patch_sdk(): + """Do not remove from this file. + + `patch_sdk` is a last resort escape hatch that allows you to do customizations + you can't accomplish using the techniques described in + https://aka.ms/azsdk/python/dpcodegen/python/customize + """ diff --git a/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/managedapplications/models/__init__.py b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/managedapplications/v2018_06_01/models/__init__.py similarity index 56% rename from sdk/resources/azure-mgmt-resource/azure/mgmt/resource/managedapplications/models/__init__.py rename to sdk/resources/azure-mgmt-resource/azure/mgmt/resource/managedapplications/v2018_06_01/models/__init__.py index 6f5ecd91307e9..176940b33c0dd 100644 --- a/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/managedapplications/models/__init__.py +++ b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/managedapplications/v2018_06_01/models/__init__.py @@ -24,32 +24,34 @@ from ._models_py3 import Resource from ._models_py3 import Sku - -from ._application_client_enums import ( - ApplicationArtifactType, - ApplicationLockLevel, - ProvisioningState, -) +from ._application_client_enums import ApplicationArtifactType +from ._application_client_enums import ApplicationLockLevel +from ._application_client_enums import ProvisioningState +from ._patch import __all__ as _patch_all +from ._patch import * # type: ignore # pylint: disable=unused-wildcard-import +from ._patch import patch_sdk as _patch_sdk __all__ = [ - 'Application', - 'ApplicationArtifact', - 'ApplicationDefinition', - 'ApplicationDefinitionListResult', - 'ApplicationListResult', - 'ApplicationPatchable', - 'ApplicationProviderAuthorization', - 'ErrorResponse', - 'GenericResource', - 'Identity', - 'Operation', - 'OperationDisplay', - 'OperationListResult', - 'Plan', - 'PlanPatchable', - 'Resource', - 'Sku', - 'ApplicationArtifactType', - 'ApplicationLockLevel', - 'ProvisioningState', + "Application", + "ApplicationArtifact", + "ApplicationDefinition", + "ApplicationDefinitionListResult", + "ApplicationListResult", + "ApplicationPatchable", + "ApplicationProviderAuthorization", + "ErrorResponse", + "GenericResource", + "Identity", + "Operation", + "OperationDisplay", + "OperationListResult", + "Plan", + "PlanPatchable", + "Resource", + "Sku", + "ApplicationArtifactType", + "ApplicationLockLevel", + "ProvisioningState", ] +__all__.extend([p for p in _patch_all if p not in __all__]) +_patch_sdk() diff --git a/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/managedapplications/models/_application_client_enums.py b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/managedapplications/v2018_06_01/models/_application_client_enums.py similarity index 68% rename from sdk/resources/azure-mgmt-resource/azure/mgmt/resource/managedapplications/models/_application_client_enums.py rename to sdk/resources/azure-mgmt-resource/azure/mgmt/resource/managedapplications/v2018_06_01/models/_application_client_enums.py index c7b8d511ee5cb..9f13cbccd9a5a 100644 --- a/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/managedapplications/models/_application_client_enums.py +++ b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/managedapplications/v2018_06_01/models/_application_client_enums.py @@ -7,28 +7,26 @@ # -------------------------------------------------------------------------- from enum import Enum -from six import with_metaclass from azure.core import CaseInsensitiveEnumMeta -class ApplicationArtifactType(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): - """The managed application artifact type. - """ +class ApplicationArtifactType(str, Enum, metaclass=CaseInsensitiveEnumMeta): + """The managed application artifact type.""" TEMPLATE = "Template" CUSTOM = "Custom" -class ApplicationLockLevel(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): - """The managed application lock level. - """ + +class ApplicationLockLevel(str, Enum, metaclass=CaseInsensitiveEnumMeta): + """The managed application lock level.""" CAN_NOT_DELETE = "CanNotDelete" READ_ONLY = "ReadOnly" NONE = "None" -class ProvisioningState(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): - """Provisioning status of the managed application. - """ + +class ProvisioningState(str, Enum, metaclass=CaseInsensitiveEnumMeta): + """Provisioning status of the managed application.""" ACCEPTED = "Accepted" RUNNING = "Running" diff --git a/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/managedapplications/models/_models_py3.py b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/managedapplications/v2018_06_01/models/_models_py3.py similarity index 57% rename from sdk/resources/azure-mgmt-resource/azure/mgmt/resource/managedapplications/models/_models_py3.py rename to sdk/resources/azure-mgmt-resource/azure/mgmt/resource/managedapplications/v2018_06_01/models/_models_py3.py index 61738cf790e89..44677bb58a5ac 100644 --- a/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/managedapplications/models/_models_py3.py +++ b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/managedapplications/v2018_06_01/models/_models_py3.py @@ -1,4 +1,5 @@ # coding=utf-8 +# pylint: disable=too-many-lines # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. # Licensed under the MIT License. See License.txt in the project root for license information. @@ -6,15 +7,22 @@ # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -from typing import Any, Dict, List, Optional, Union +import sys +from typing import Any, Dict, List, Optional, TYPE_CHECKING, Union -from azure.core.exceptions import HttpResponseError -import msrest.serialization +from ... import _serialization -from ._application_client_enums import * +if TYPE_CHECKING: + # pylint: disable=unused-import,ungrouped-imports + from .. import models as _models +if sys.version_info >= (3, 9): + from collections.abc import MutableMapping +else: + from typing import MutableMapping # type: ignore # pylint: disable=ungrouped-imports +JSON = MutableMapping[str, Any] # pylint: disable=unsubscriptable-object -class Resource(msrest.serialization.Model): +class Resource(_serialization.Model): """Resource information. Variables are only populated by the server, and will be ignored when sending a request. @@ -27,38 +35,32 @@ class Resource(msrest.serialization.Model): :vartype type: str :ivar location: Resource location. :vartype location: str - :ivar tags: A set of tags. Resource tags. + :ivar tags: Resource tags. :vartype tags: dict[str, str] """ _validation = { - 'id': {'readonly': True}, - 'name': {'readonly': True}, - 'type': {'readonly': True}, + "id": {"readonly": True}, + "name": {"readonly": True}, + "type": {"readonly": True}, } _attribute_map = { - 'id': {'key': 'id', 'type': 'str'}, - 'name': {'key': 'name', 'type': 'str'}, - 'type': {'key': 'type', 'type': 'str'}, - 'location': {'key': 'location', 'type': 'str'}, - 'tags': {'key': 'tags', 'type': '{str}'}, + "id": {"key": "id", "type": "str"}, + "name": {"key": "name", "type": "str"}, + "type": {"key": "type", "type": "str"}, + "location": {"key": "location", "type": "str"}, + "tags": {"key": "tags", "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): """ :keyword location: Resource location. :paramtype location: str - :keyword tags: A set of tags. Resource tags. + :keyword tags: Resource tags. :paramtype tags: dict[str, str] """ - super(Resource, self).__init__(**kwargs) + super().__init__(**kwargs) self.id = None self.name = None self.type = None @@ -79,31 +81,31 @@ class GenericResource(Resource): :vartype type: str :ivar location: Resource location. :vartype location: str - :ivar tags: A set of tags. Resource tags. + :ivar tags: Resource tags. :vartype tags: dict[str, str] :ivar managed_by: ID of the resource that manages this resource. :vartype managed_by: str :ivar sku: The SKU of the resource. - :vartype sku: ~azure.mgmt.resource.managedapplications.models.Sku + :vartype sku: ~azure.mgmt.resource.managedapplications.v2018_06_01.models.Sku :ivar identity: The identity of the resource. - :vartype identity: ~azure.mgmt.resource.managedapplications.models.Identity + :vartype identity: ~azure.mgmt.resource.managedapplications.v2018_06_01.models.Identity """ _validation = { - 'id': {'readonly': True}, - 'name': {'readonly': True}, - 'type': {'readonly': True}, + "id": {"readonly": True}, + "name": {"readonly": True}, + "type": {"readonly": True}, } _attribute_map = { - 'id': {'key': 'id', 'type': 'str'}, - 'name': {'key': 'name', 'type': 'str'}, - 'type': {'key': 'type', 'type': 'str'}, - 'location': {'key': 'location', 'type': 'str'}, - 'tags': {'key': 'tags', 'type': '{str}'}, - 'managed_by': {'key': 'managedBy', 'type': 'str'}, - 'sku': {'key': 'sku', 'type': 'Sku'}, - 'identity': {'key': 'identity', 'type': 'Identity'}, + "id": {"key": "id", "type": "str"}, + "name": {"key": "name", "type": "str"}, + "type": {"key": "type", "type": "str"}, + "location": {"key": "location", "type": "str"}, + "tags": {"key": "tags", "type": "{str}"}, + "managed_by": {"key": "managedBy", "type": "str"}, + "sku": {"key": "sku", "type": "Sku"}, + "identity": {"key": "identity", "type": "Identity"}, } def __init__( @@ -112,29 +114,29 @@ def __init__( location: Optional[str] = None, tags: Optional[Dict[str, str]] = None, managed_by: Optional[str] = None, - sku: Optional["Sku"] = None, - identity: Optional["Identity"] = None, + sku: Optional["_models.Sku"] = None, + identity: Optional["_models.Identity"] = None, **kwargs ): """ :keyword location: Resource location. :paramtype location: str - :keyword tags: A set of tags. Resource tags. + :keyword tags: Resource tags. :paramtype tags: dict[str, str] :keyword managed_by: ID of the resource that manages this resource. :paramtype managed_by: str :keyword sku: The SKU of the resource. - :paramtype sku: ~azure.mgmt.resource.managedapplications.models.Sku + :paramtype sku: ~azure.mgmt.resource.managedapplications.v2018_06_01.models.Sku :keyword identity: The identity of the resource. - :paramtype identity: ~azure.mgmt.resource.managedapplications.models.Identity + :paramtype identity: ~azure.mgmt.resource.managedapplications.v2018_06_01.models.Identity """ - super(GenericResource, self).__init__(location=location, tags=tags, **kwargs) + super().__init__(location=location, tags=tags, **kwargs) self.managed_by = managed_by self.sku = sku self.identity = identity -class Application(GenericResource): +class Application(GenericResource): # pylint: disable=too-many-instance-attributes """Information about managed application. Variables are only populated by the server, and will be ignored when sending a request. @@ -149,61 +151,61 @@ class Application(GenericResource): :vartype type: str :ivar location: Resource location. :vartype location: str - :ivar tags: A set of tags. Resource tags. + :ivar tags: Resource tags. :vartype tags: dict[str, str] :ivar managed_by: ID of the resource that manages this resource. :vartype managed_by: str :ivar sku: The SKU of the resource. - :vartype sku: ~azure.mgmt.resource.managedapplications.models.Sku + :vartype sku: ~azure.mgmt.resource.managedapplications.v2018_06_01.models.Sku :ivar identity: The identity of the resource. - :vartype identity: ~azure.mgmt.resource.managedapplications.models.Identity + :vartype identity: ~azure.mgmt.resource.managedapplications.v2018_06_01.models.Identity :ivar plan: The plan information. - :vartype plan: ~azure.mgmt.resource.managedapplications.models.Plan - :ivar kind: Required. The kind of the managed application. Allowed values are MarketPlace and - ServiceCatalog. + :vartype plan: ~azure.mgmt.resource.managedapplications.v2018_06_01.models.Plan + :ivar kind: The kind of the managed application. Allowed values are MarketPlace and + ServiceCatalog. Required. :vartype kind: str - :ivar managed_resource_group_id: Required. The managed resource group Id. + :ivar managed_resource_group_id: The managed resource group Id. Required. :vartype managed_resource_group_id: str :ivar application_definition_id: The fully qualified path of managed application definition Id. :vartype application_definition_id: str :ivar parameters: Name and value pairs that define the managed application parameters. It can be a JObject or a well formed JSON string. - :vartype parameters: any + :vartype parameters: JSON :ivar outputs: Name and value pairs that define the managed application outputs. - :vartype outputs: any - :ivar provisioning_state: The managed application provisioning state. Possible values include: + :vartype outputs: JSON + :ivar provisioning_state: The managed application provisioning state. Known values are: "Accepted", "Running", "Ready", "Creating", "Created", "Deleting", "Deleted", "Canceled", - "Failed", "Succeeded", "Updating". + "Failed", "Succeeded", and "Updating". :vartype provisioning_state: str or - ~azure.mgmt.resource.managedapplications.models.ProvisioningState + ~azure.mgmt.resource.managedapplications.v2018_06_01.models.ProvisioningState """ _validation = { - 'id': {'readonly': True}, - 'name': {'readonly': True}, - 'type': {'readonly': True}, - 'kind': {'required': True, 'pattern': r'^[-\w\._,\(\)]+$'}, - 'managed_resource_group_id': {'required': True}, - 'outputs': {'readonly': True}, - 'provisioning_state': {'readonly': True}, + "id": {"readonly": True}, + "name": {"readonly": True}, + "type": {"readonly": True}, + "kind": {"required": True, "pattern": r"^[-\w\._,\(\)]+$"}, + "managed_resource_group_id": {"required": True}, + "outputs": {"readonly": True}, + "provisioning_state": {"readonly": True}, } _attribute_map = { - 'id': {'key': 'id', 'type': 'str'}, - 'name': {'key': 'name', 'type': 'str'}, - 'type': {'key': 'type', 'type': 'str'}, - 'location': {'key': 'location', 'type': 'str'}, - 'tags': {'key': 'tags', 'type': '{str}'}, - 'managed_by': {'key': 'managedBy', 'type': 'str'}, - 'sku': {'key': 'sku', 'type': 'Sku'}, - 'identity': {'key': 'identity', 'type': 'Identity'}, - 'plan': {'key': 'plan', 'type': 'Plan'}, - 'kind': {'key': 'kind', 'type': 'str'}, - 'managed_resource_group_id': {'key': 'properties.managedResourceGroupId', 'type': 'str'}, - 'application_definition_id': {'key': 'properties.applicationDefinitionId', 'type': 'str'}, - 'parameters': {'key': 'properties.parameters', 'type': 'object'}, - 'outputs': {'key': 'properties.outputs', 'type': 'object'}, - 'provisioning_state': {'key': 'properties.provisioningState', 'type': 'str'}, + "id": {"key": "id", "type": "str"}, + "name": {"key": "name", "type": "str"}, + "type": {"key": "type", "type": "str"}, + "location": {"key": "location", "type": "str"}, + "tags": {"key": "tags", "type": "{str}"}, + "managed_by": {"key": "managedBy", "type": "str"}, + "sku": {"key": "sku", "type": "Sku"}, + "identity": {"key": "identity", "type": "Identity"}, + "plan": {"key": "plan", "type": "Plan"}, + "kind": {"key": "kind", "type": "str"}, + "managed_resource_group_id": {"key": "properties.managedResourceGroupId", "type": "str"}, + "application_definition_id": {"key": "properties.applicationDefinitionId", "type": "str"}, + "parameters": {"key": "properties.parameters", "type": "object"}, + "outputs": {"key": "properties.outputs", "type": "object"}, + "provisioning_state": {"key": "properties.provisioningState", "type": "str"}, } def __init__( @@ -214,39 +216,39 @@ def __init__( location: Optional[str] = None, tags: Optional[Dict[str, str]] = None, managed_by: Optional[str] = None, - sku: Optional["Sku"] = None, - identity: Optional["Identity"] = None, - plan: Optional["Plan"] = None, + sku: Optional["_models.Sku"] = None, + identity: Optional["_models.Identity"] = None, + plan: Optional["_models.Plan"] = None, application_definition_id: Optional[str] = None, - parameters: Optional[Any] = None, + parameters: Optional[JSON] = None, **kwargs ): """ :keyword location: Resource location. :paramtype location: str - :keyword tags: A set of tags. Resource tags. + :keyword tags: Resource tags. :paramtype tags: dict[str, str] :keyword managed_by: ID of the resource that manages this resource. :paramtype managed_by: str :keyword sku: The SKU of the resource. - :paramtype sku: ~azure.mgmt.resource.managedapplications.models.Sku + :paramtype sku: ~azure.mgmt.resource.managedapplications.v2018_06_01.models.Sku :keyword identity: The identity of the resource. - :paramtype identity: ~azure.mgmt.resource.managedapplications.models.Identity + :paramtype identity: ~azure.mgmt.resource.managedapplications.v2018_06_01.models.Identity :keyword plan: The plan information. - :paramtype plan: ~azure.mgmt.resource.managedapplications.models.Plan - :keyword kind: Required. The kind of the managed application. Allowed values are MarketPlace - and ServiceCatalog. + :paramtype plan: ~azure.mgmt.resource.managedapplications.v2018_06_01.models.Plan + :keyword kind: The kind of the managed application. Allowed values are MarketPlace and + ServiceCatalog. Required. :paramtype kind: str - :keyword managed_resource_group_id: Required. The managed resource group Id. + :keyword managed_resource_group_id: The managed resource group Id. Required. :paramtype managed_resource_group_id: str :keyword application_definition_id: The fully qualified path of managed application definition Id. :paramtype application_definition_id: str :keyword parameters: Name and value pairs that define the managed application parameters. It can be a JObject or a well formed JSON string. - :paramtype parameters: any + :paramtype parameters: JSON """ - super(Application, self).__init__(location=location, tags=tags, managed_by=managed_by, sku=sku, identity=identity, **kwargs) + super().__init__(location=location, tags=tags, managed_by=managed_by, sku=sku, identity=identity, **kwargs) self.plan = plan self.kind = kind self.managed_resource_group_id = managed_resource_group_id @@ -256,22 +258,22 @@ def __init__( self.provisioning_state = None -class ApplicationArtifact(msrest.serialization.Model): +class ApplicationArtifact(_serialization.Model): """Managed application artifact. :ivar name: The managed application artifact name. :vartype name: str :ivar uri: The managed application artifact blob uri. :vartype uri: str - :ivar type: The managed application artifact type. Possible values include: "Template", - "Custom". - :vartype type: str or ~azure.mgmt.resource.managedapplications.models.ApplicationArtifactType + :ivar type: The managed application artifact type. Known values are: "Template" and "Custom". + :vartype type: str or + ~azure.mgmt.resource.managedapplications.v2018_06_01.models.ApplicationArtifactType """ _attribute_map = { - 'name': {'key': 'name', 'type': 'str'}, - 'uri': {'key': 'uri', 'type': 'str'}, - 'type': {'key': 'type', 'type': 'str'}, + "name": {"key": "name", "type": "str"}, + "uri": {"key": "uri", "type": "str"}, + "type": {"key": "type", "type": "str"}, } def __init__( @@ -279,7 +281,7 @@ def __init__( *, name: Optional[str] = None, uri: Optional[str] = None, - type: Optional[Union[str, "ApplicationArtifactType"]] = None, + type: Optional[Union[str, "_models.ApplicationArtifactType"]] = None, **kwargs ): """ @@ -287,17 +289,18 @@ def __init__( :paramtype name: str :keyword uri: The managed application artifact blob uri. :paramtype uri: str - :keyword type: The managed application artifact type. Possible values include: "Template", + :keyword type: The managed application artifact type. Known values are: "Template" and "Custom". - :paramtype type: str or ~azure.mgmt.resource.managedapplications.models.ApplicationArtifactType + :paramtype type: str or + ~azure.mgmt.resource.managedapplications.v2018_06_01.models.ApplicationArtifactType """ - super(ApplicationArtifact, self).__init__(**kwargs) + super().__init__(**kwargs) self.name = name self.uri = uri self.type = type -class ApplicationDefinition(GenericResource): +class ApplicationDefinition(GenericResource): # pylint: disable=too-many-instance-attributes """Information about managed application definition. Variables are only populated by the server, and will be ignored when sending a request. @@ -312,114 +315,116 @@ class ApplicationDefinition(GenericResource): :vartype type: str :ivar location: Resource location. :vartype location: str - :ivar tags: A set of tags. Resource tags. + :ivar tags: Resource tags. :vartype tags: dict[str, str] :ivar managed_by: ID of the resource that manages this resource. :vartype managed_by: str :ivar sku: The SKU of the resource. - :vartype sku: ~azure.mgmt.resource.managedapplications.models.Sku + :vartype sku: ~azure.mgmt.resource.managedapplications.v2018_06_01.models.Sku :ivar identity: The identity of the resource. - :vartype identity: ~azure.mgmt.resource.managedapplications.models.Identity - :ivar lock_level: Required. The managed application lock level. Possible values include: - "CanNotDelete", "ReadOnly", "None". + :vartype identity: ~azure.mgmt.resource.managedapplications.v2018_06_01.models.Identity + :ivar lock_level: The managed application lock level. Required. Known values are: + "CanNotDelete", "ReadOnly", and "None". :vartype lock_level: str or - ~azure.mgmt.resource.managedapplications.models.ApplicationLockLevel + ~azure.mgmt.resource.managedapplications.v2018_06_01.models.ApplicationLockLevel :ivar display_name: The managed application definition display name. :vartype display_name: str :ivar is_enabled: A value indicating whether the package is enabled or not. :vartype is_enabled: str - :ivar authorizations: Required. The managed application provider authorizations. + :ivar authorizations: The managed application provider authorizations. Required. :vartype authorizations: - list[~azure.mgmt.resource.managedapplications.models.ApplicationProviderAuthorization] + list[~azure.mgmt.resource.managedapplications.v2018_06_01.models.ApplicationProviderAuthorization] :ivar artifacts: The collection of managed application artifacts. The portal will use the files specified as artifacts to construct the user experience of creating a managed application from a managed application definition. - :vartype artifacts: list[~azure.mgmt.resource.managedapplications.models.ApplicationArtifact] + :vartype artifacts: + list[~azure.mgmt.resource.managedapplications.v2018_06_01.models.ApplicationArtifact] :ivar description: The managed application definition description. :vartype description: str :ivar package_file_uri: The managed application definition package file Uri. Use this element. :vartype package_file_uri: str :ivar main_template: The inline main template json which has resources to be provisioned. It can be a JObject or well-formed JSON string. - :vartype main_template: any + :vartype main_template: JSON :ivar create_ui_definition: The createUiDefinition json for the backing template with Microsoft.Solutions/applications resource. It can be a JObject or well-formed JSON string. - :vartype create_ui_definition: any + :vartype create_ui_definition: JSON """ _validation = { - 'id': {'readonly': True}, - 'name': {'readonly': True}, - 'type': {'readonly': True}, - 'lock_level': {'required': True}, - 'authorizations': {'required': True}, + "id": {"readonly": True}, + "name": {"readonly": True}, + "type": {"readonly": True}, + "lock_level": {"required": True}, + "authorizations": {"required": True}, } _attribute_map = { - 'id': {'key': 'id', 'type': 'str'}, - 'name': {'key': 'name', 'type': 'str'}, - 'type': {'key': 'type', 'type': 'str'}, - 'location': {'key': 'location', 'type': 'str'}, - 'tags': {'key': 'tags', 'type': '{str}'}, - 'managed_by': {'key': 'managedBy', 'type': 'str'}, - 'sku': {'key': 'sku', 'type': 'Sku'}, - 'identity': {'key': 'identity', 'type': 'Identity'}, - 'lock_level': {'key': 'properties.lockLevel', 'type': 'str'}, - 'display_name': {'key': 'properties.displayName', 'type': 'str'}, - 'is_enabled': {'key': 'properties.isEnabled', 'type': 'str'}, - 'authorizations': {'key': 'properties.authorizations', 'type': '[ApplicationProviderAuthorization]'}, - 'artifacts': {'key': 'properties.artifacts', 'type': '[ApplicationArtifact]'}, - 'description': {'key': 'properties.description', 'type': 'str'}, - 'package_file_uri': {'key': 'properties.packageFileUri', 'type': 'str'}, - 'main_template': {'key': 'properties.mainTemplate', 'type': 'object'}, - 'create_ui_definition': {'key': 'properties.createUiDefinition', 'type': 'object'}, + "id": {"key": "id", "type": "str"}, + "name": {"key": "name", "type": "str"}, + "type": {"key": "type", "type": "str"}, + "location": {"key": "location", "type": "str"}, + "tags": {"key": "tags", "type": "{str}"}, + "managed_by": {"key": "managedBy", "type": "str"}, + "sku": {"key": "sku", "type": "Sku"}, + "identity": {"key": "identity", "type": "Identity"}, + "lock_level": {"key": "properties.lockLevel", "type": "str"}, + "display_name": {"key": "properties.displayName", "type": "str"}, + "is_enabled": {"key": "properties.isEnabled", "type": "str"}, + "authorizations": {"key": "properties.authorizations", "type": "[ApplicationProviderAuthorization]"}, + "artifacts": {"key": "properties.artifacts", "type": "[ApplicationArtifact]"}, + "description": {"key": "properties.description", "type": "str"}, + "package_file_uri": {"key": "properties.packageFileUri", "type": "str"}, + "main_template": {"key": "properties.mainTemplate", "type": "object"}, + "create_ui_definition": {"key": "properties.createUiDefinition", "type": "object"}, } def __init__( self, *, - lock_level: Union[str, "ApplicationLockLevel"], - authorizations: List["ApplicationProviderAuthorization"], + lock_level: Union[str, "_models.ApplicationLockLevel"], + authorizations: List["_models.ApplicationProviderAuthorization"], location: Optional[str] = None, tags: Optional[Dict[str, str]] = None, managed_by: Optional[str] = None, - sku: Optional["Sku"] = None, - identity: Optional["Identity"] = None, + sku: Optional["_models.Sku"] = None, + identity: Optional["_models.Identity"] = None, display_name: Optional[str] = None, is_enabled: Optional[str] = None, - artifacts: Optional[List["ApplicationArtifact"]] = None, + artifacts: Optional[List["_models.ApplicationArtifact"]] = None, description: Optional[str] = None, package_file_uri: Optional[str] = None, - main_template: Optional[Any] = None, - create_ui_definition: Optional[Any] = None, + main_template: Optional[JSON] = None, + create_ui_definition: Optional[JSON] = None, **kwargs ): """ :keyword location: Resource location. :paramtype location: str - :keyword tags: A set of tags. Resource tags. + :keyword tags: Resource tags. :paramtype tags: dict[str, str] :keyword managed_by: ID of the resource that manages this resource. :paramtype managed_by: str :keyword sku: The SKU of the resource. - :paramtype sku: ~azure.mgmt.resource.managedapplications.models.Sku + :paramtype sku: ~azure.mgmt.resource.managedapplications.v2018_06_01.models.Sku :keyword identity: The identity of the resource. - :paramtype identity: ~azure.mgmt.resource.managedapplications.models.Identity - :keyword lock_level: Required. The managed application lock level. Possible values include: - "CanNotDelete", "ReadOnly", "None". + :paramtype identity: ~azure.mgmt.resource.managedapplications.v2018_06_01.models.Identity + :keyword lock_level: The managed application lock level. Required. Known values are: + "CanNotDelete", "ReadOnly", and "None". :paramtype lock_level: str or - ~azure.mgmt.resource.managedapplications.models.ApplicationLockLevel + ~azure.mgmt.resource.managedapplications.v2018_06_01.models.ApplicationLockLevel :keyword display_name: The managed application definition display name. :paramtype display_name: str :keyword is_enabled: A value indicating whether the package is enabled or not. :paramtype is_enabled: str - :keyword authorizations: Required. The managed application provider authorizations. + :keyword authorizations: The managed application provider authorizations. Required. :paramtype authorizations: - list[~azure.mgmt.resource.managedapplications.models.ApplicationProviderAuthorization] + list[~azure.mgmt.resource.managedapplications.v2018_06_01.models.ApplicationProviderAuthorization] :keyword artifacts: The collection of managed application artifacts. The portal will use the files specified as artifacts to construct the user experience of creating a managed application from a managed application definition. - :paramtype artifacts: list[~azure.mgmt.resource.managedapplications.models.ApplicationArtifact] + :paramtype artifacts: + list[~azure.mgmt.resource.managedapplications.v2018_06_01.models.ApplicationArtifact] :keyword description: The managed application definition description. :paramtype description: str :keyword package_file_uri: The managed application definition package file Uri. Use this @@ -427,12 +432,12 @@ def __init__( :paramtype package_file_uri: str :keyword main_template: The inline main template json which has resources to be provisioned. It can be a JObject or well-formed JSON string. - :paramtype main_template: any + :paramtype main_template: JSON :keyword create_ui_definition: The createUiDefinition json for the backing template with Microsoft.Solutions/applications resource. It can be a JObject or well-formed JSON string. - :paramtype create_ui_definition: any + :paramtype create_ui_definition: JSON """ - super(ApplicationDefinition, self).__init__(location=location, tags=tags, managed_by=managed_by, sku=sku, identity=identity, **kwargs) + super().__init__(location=location, tags=tags, managed_by=managed_by, sku=sku, identity=identity, **kwargs) self.lock_level = lock_level self.display_name = display_name self.is_enabled = is_enabled @@ -444,71 +449,69 @@ def __init__( self.create_ui_definition = create_ui_definition -class ApplicationDefinitionListResult(msrest.serialization.Model): +class ApplicationDefinitionListResult(_serialization.Model): """List of managed application definitions. :ivar value: The array of managed application definitions. - :vartype value: list[~azure.mgmt.resource.managedapplications.models.ApplicationDefinition] + :vartype value: + list[~azure.mgmt.resource.managedapplications.v2018_06_01.models.ApplicationDefinition] :ivar next_link: The URL to use for getting the next set of results. :vartype next_link: str """ _attribute_map = { - 'value': {'key': 'value', 'type': '[ApplicationDefinition]'}, - 'next_link': {'key': 'nextLink', 'type': 'str'}, + "value": {"key": "value", "type": "[ApplicationDefinition]"}, + "next_link": {"key": "nextLink", "type": "str"}, } def __init__( self, *, - value: Optional[List["ApplicationDefinition"]] = None, + value: Optional[List["_models.ApplicationDefinition"]] = None, next_link: Optional[str] = None, **kwargs ): """ :keyword value: The array of managed application definitions. - :paramtype value: list[~azure.mgmt.resource.managedapplications.models.ApplicationDefinition] + :paramtype value: + list[~azure.mgmt.resource.managedapplications.v2018_06_01.models.ApplicationDefinition] :keyword next_link: The URL to use for getting the next set of results. :paramtype next_link: str """ - super(ApplicationDefinitionListResult, self).__init__(**kwargs) + super().__init__(**kwargs) self.value = value self.next_link = next_link -class ApplicationListResult(msrest.serialization.Model): +class ApplicationListResult(_serialization.Model): """List of managed applications. :ivar value: The array of managed applications. - :vartype value: list[~azure.mgmt.resource.managedapplications.models.Application] + :vartype value: list[~azure.mgmt.resource.managedapplications.v2018_06_01.models.Application] :ivar next_link: The URL to use for getting the next set of results. :vartype next_link: str """ _attribute_map = { - 'value': {'key': 'value', 'type': '[Application]'}, - 'next_link': {'key': 'nextLink', 'type': 'str'}, + "value": {"key": "value", "type": "[Application]"}, + "next_link": {"key": "nextLink", "type": "str"}, } def __init__( - self, - *, - value: Optional[List["Application"]] = None, - next_link: Optional[str] = None, - **kwargs + self, *, value: Optional[List["_models.Application"]] = None, next_link: Optional[str] = None, **kwargs ): """ :keyword value: The array of managed applications. - :paramtype value: list[~azure.mgmt.resource.managedapplications.models.Application] + :paramtype value: list[~azure.mgmt.resource.managedapplications.v2018_06_01.models.Application] :keyword next_link: The URL to use for getting the next set of results. :paramtype next_link: str """ - super(ApplicationListResult, self).__init__(**kwargs) + super().__init__(**kwargs) self.value = value self.next_link = next_link -class ApplicationPatchable(GenericResource): +class ApplicationPatchable(GenericResource): # pylint: disable=too-many-instance-attributes """Information about managed application. Variables are only populated by the server, and will be ignored when sending a request. @@ -521,16 +524,16 @@ class ApplicationPatchable(GenericResource): :vartype type: str :ivar location: Resource location. :vartype location: str - :ivar tags: A set of tags. Resource tags. + :ivar tags: Resource tags. :vartype tags: dict[str, str] :ivar managed_by: ID of the resource that manages this resource. :vartype managed_by: str :ivar sku: The SKU of the resource. - :vartype sku: ~azure.mgmt.resource.managedapplications.models.Sku + :vartype sku: ~azure.mgmt.resource.managedapplications.v2018_06_01.models.Sku :ivar identity: The identity of the resource. - :vartype identity: ~azure.mgmt.resource.managedapplications.models.Identity + :vartype identity: ~azure.mgmt.resource.managedapplications.v2018_06_01.models.Identity :ivar plan: The plan information. - :vartype plan: ~azure.mgmt.resource.managedapplications.models.PlanPatchable + :vartype plan: ~azure.mgmt.resource.managedapplications.v2018_06_01.models.PlanPatchable :ivar kind: The kind of the managed application. Allowed values are MarketPlace and ServiceCatalog. :vartype kind: str @@ -540,41 +543,41 @@ class ApplicationPatchable(GenericResource): :vartype application_definition_id: str :ivar parameters: Name and value pairs that define the managed application parameters. It can be a JObject or a well formed JSON string. - :vartype parameters: any + :vartype parameters: JSON :ivar outputs: Name and value pairs that define the managed application outputs. - :vartype outputs: any - :ivar provisioning_state: The managed application provisioning state. Possible values include: + :vartype outputs: JSON + :ivar provisioning_state: The managed application provisioning state. Known values are: "Accepted", "Running", "Ready", "Creating", "Created", "Deleting", "Deleted", "Canceled", - "Failed", "Succeeded", "Updating". + "Failed", "Succeeded", and "Updating". :vartype provisioning_state: str or - ~azure.mgmt.resource.managedapplications.models.ProvisioningState + ~azure.mgmt.resource.managedapplications.v2018_06_01.models.ProvisioningState """ _validation = { - 'id': {'readonly': True}, - 'name': {'readonly': True}, - 'type': {'readonly': True}, - 'kind': {'pattern': r'^[-\w\._,\(\)]+$'}, - 'outputs': {'readonly': True}, - 'provisioning_state': {'readonly': True}, + "id": {"readonly": True}, + "name": {"readonly": True}, + "type": {"readonly": True}, + "kind": {"pattern": r"^[-\w\._,\(\)]+$"}, + "outputs": {"readonly": True}, + "provisioning_state": {"readonly": True}, } _attribute_map = { - 'id': {'key': 'id', 'type': 'str'}, - 'name': {'key': 'name', 'type': 'str'}, - 'type': {'key': 'type', 'type': 'str'}, - 'location': {'key': 'location', 'type': 'str'}, - 'tags': {'key': 'tags', 'type': '{str}'}, - 'managed_by': {'key': 'managedBy', 'type': 'str'}, - 'sku': {'key': 'sku', 'type': 'Sku'}, - 'identity': {'key': 'identity', 'type': 'Identity'}, - 'plan': {'key': 'plan', 'type': 'PlanPatchable'}, - 'kind': {'key': 'kind', 'type': 'str'}, - 'managed_resource_group_id': {'key': 'properties.managedResourceGroupId', 'type': 'str'}, - 'application_definition_id': {'key': 'properties.applicationDefinitionId', 'type': 'str'}, - 'parameters': {'key': 'properties.parameters', 'type': 'object'}, - 'outputs': {'key': 'properties.outputs', 'type': 'object'}, - 'provisioning_state': {'key': 'properties.provisioningState', 'type': 'str'}, + "id": {"key": "id", "type": "str"}, + "name": {"key": "name", "type": "str"}, + "type": {"key": "type", "type": "str"}, + "location": {"key": "location", "type": "str"}, + "tags": {"key": "tags", "type": "{str}"}, + "managed_by": {"key": "managedBy", "type": "str"}, + "sku": {"key": "sku", "type": "Sku"}, + "identity": {"key": "identity", "type": "Identity"}, + "plan": {"key": "plan", "type": "PlanPatchable"}, + "kind": {"key": "kind", "type": "str"}, + "managed_resource_group_id": {"key": "properties.managedResourceGroupId", "type": "str"}, + "application_definition_id": {"key": "properties.applicationDefinitionId", "type": "str"}, + "parameters": {"key": "properties.parameters", "type": "object"}, + "outputs": {"key": "properties.outputs", "type": "object"}, + "provisioning_state": {"key": "properties.provisioningState", "type": "str"}, } def __init__( @@ -583,28 +586,28 @@ def __init__( location: Optional[str] = None, tags: Optional[Dict[str, str]] = None, managed_by: Optional[str] = None, - sku: Optional["Sku"] = None, - identity: Optional["Identity"] = None, - plan: Optional["PlanPatchable"] = None, + sku: Optional["_models.Sku"] = None, + identity: Optional["_models.Identity"] = None, + plan: Optional["_models.PlanPatchable"] = None, kind: Optional[str] = None, managed_resource_group_id: Optional[str] = None, application_definition_id: Optional[str] = None, - parameters: Optional[Any] = None, + parameters: Optional[JSON] = None, **kwargs ): """ :keyword location: Resource location. :paramtype location: str - :keyword tags: A set of tags. Resource tags. + :keyword tags: Resource tags. :paramtype tags: dict[str, str] :keyword managed_by: ID of the resource that manages this resource. :paramtype managed_by: str :keyword sku: The SKU of the resource. - :paramtype sku: ~azure.mgmt.resource.managedapplications.models.Sku + :paramtype sku: ~azure.mgmt.resource.managedapplications.v2018_06_01.models.Sku :keyword identity: The identity of the resource. - :paramtype identity: ~azure.mgmt.resource.managedapplications.models.Identity + :paramtype identity: ~azure.mgmt.resource.managedapplications.v2018_06_01.models.Identity :keyword plan: The plan information. - :paramtype plan: ~azure.mgmt.resource.managedapplications.models.PlanPatchable + :paramtype plan: ~azure.mgmt.resource.managedapplications.v2018_06_01.models.PlanPatchable :keyword kind: The kind of the managed application. Allowed values are MarketPlace and ServiceCatalog. :paramtype kind: str @@ -615,9 +618,9 @@ def __init__( :paramtype application_definition_id: str :keyword parameters: Name and value pairs that define the managed application parameters. It can be a JObject or a well formed JSON string. - :paramtype parameters: any + :paramtype parameters: JSON """ - super(ApplicationPatchable, self).__init__(location=location, tags=tags, managed_by=managed_by, sku=sku, identity=identity, **kwargs) + super().__init__(location=location, tags=tags, managed_by=managed_by, sku=sku, identity=identity, **kwargs) self.plan = plan self.kind = kind self.managed_resource_group_id = managed_resource_group_id @@ -627,53 +630,46 @@ def __init__( self.provisioning_state = None -class ApplicationProviderAuthorization(msrest.serialization.Model): +class ApplicationProviderAuthorization(_serialization.Model): """The managed application provider authorization. All required parameters must be populated in order to send to Azure. - :ivar principal_id: Required. The provider's principal identifier. This is the identity that - the provider will use to call ARM to manage the managed application resources. + :ivar principal_id: The provider's principal identifier. This is the identity that the provider + will use to call ARM to manage the managed application resources. Required. :vartype principal_id: str - :ivar role_definition_id: Required. The provider's role definition identifier. This role will - define all the permissions that the provider must have on the managed application's container - resource group. This role definition cannot have permission to delete the resource group. + :ivar role_definition_id: The provider's role definition identifier. This role will define all + the permissions that the provider must have on the managed application's container resource + group. This role definition cannot have permission to delete the resource group. Required. :vartype role_definition_id: str """ _validation = { - 'principal_id': {'required': True}, - 'role_definition_id': {'required': True}, + "principal_id": {"required": True}, + "role_definition_id": {"required": True}, } _attribute_map = { - 'principal_id': {'key': 'principalId', 'type': 'str'}, - 'role_definition_id': {'key': 'roleDefinitionId', 'type': 'str'}, + "principal_id": {"key": "principalId", "type": "str"}, + "role_definition_id": {"key": "roleDefinitionId", "type": "str"}, } - def __init__( - self, - *, - principal_id: str, - role_definition_id: str, - **kwargs - ): + def __init__(self, *, principal_id: str, role_definition_id: str, **kwargs): """ - :keyword principal_id: Required. The provider's principal identifier. This is the identity that - the provider will use to call ARM to manage the managed application resources. + :keyword principal_id: The provider's principal identifier. This is the identity that the + provider will use to call ARM to manage the managed application resources. Required. :paramtype principal_id: str - :keyword role_definition_id: Required. The provider's role definition identifier. This role - will define all the permissions that the provider must have on the managed application's - container resource group. This role definition cannot have permission to delete the resource - group. + :keyword role_definition_id: The provider's role definition identifier. This role will define + all the permissions that the provider must have on the managed application's container resource + group. This role definition cannot have permission to delete the resource group. Required. :paramtype role_definition_id: str """ - super(ApplicationProviderAuthorization, self).__init__(**kwargs) + super().__init__(**kwargs) self.principal_id = principal_id self.role_definition_id = role_definition_id -class ErrorResponse(msrest.serialization.Model): +class ErrorResponse(_serialization.Model): """Error response indicates managed application is not able to process the incoming request. The reason is provided in the error message. :ivar http_status: Http status code. @@ -685,9 +681,9 @@ class ErrorResponse(msrest.serialization.Model): """ _attribute_map = { - 'http_status': {'key': 'httpStatus', 'type': 'str'}, - 'error_code': {'key': 'errorCode', 'type': 'str'}, - 'error_message': {'key': 'errorMessage', 'type': 'str'}, + "http_status": {"key": "httpStatus", "type": "str"}, + "error_code": {"key": "errorCode", "type": "str"}, + "error_message": {"key": "errorMessage", "type": "str"}, } def __init__( @@ -706,13 +702,13 @@ def __init__( :keyword error_message: Error message indicating why the operation failed. :paramtype error_message: str """ - super(ErrorResponse, self).__init__(**kwargs) + super().__init__(**kwargs) self.http_status = http_status self.error_code = error_code self.error_message = error_message -class Identity(msrest.serialization.Model): +class Identity(_serialization.Model): """Identity for the resource. Variables are only populated by the server, and will be ignored when sending a request. @@ -721,72 +717,60 @@ class Identity(msrest.serialization.Model): :vartype principal_id: str :ivar tenant_id: The tenant ID of resource. :vartype tenant_id: str - :ivar type: The identity type. The only acceptable values to pass in are None and - "SystemAssigned". The default value is None. + :ivar type: The identity type. Default value is "SystemAssigned". :vartype type: str """ _validation = { - 'principal_id': {'readonly': True}, - 'tenant_id': {'readonly': True}, + "principal_id": {"readonly": True}, + "tenant_id": {"readonly": True}, } _attribute_map = { - 'principal_id': {'key': 'principalId', 'type': 'str'}, - 'tenant_id': {'key': 'tenantId', 'type': 'str'}, - 'type': {'key': 'type', 'type': 'str'}, + "principal_id": {"key": "principalId", "type": "str"}, + "tenant_id": {"key": "tenantId", "type": "str"}, + "type": {"key": "type", "type": "str"}, } - def __init__( - self, - *, - type: Optional[str] = None, - **kwargs - ): + def __init__(self, *, type: Optional[str] = None, **kwargs): """ - :keyword type: The identity type. The only acceptable values to pass in are None and - "SystemAssigned". The default value is None. + :keyword type: The identity type. Default value is "SystemAssigned". :paramtype type: str """ - super(Identity, self).__init__(**kwargs) + super().__init__(**kwargs) self.principal_id = None self.tenant_id = None self.type = type -class Operation(msrest.serialization.Model): +class Operation(_serialization.Model): """Microsoft.Solutions operation. :ivar name: Operation name: {provider}/{resource}/{operation}. :vartype name: str :ivar display: The object that represents the operation. - :vartype display: ~azure.mgmt.resource.managedapplications.models.OperationDisplay + :vartype display: ~azure.mgmt.resource.managedapplications.v2018_06_01.models.OperationDisplay """ _attribute_map = { - 'name': {'key': 'name', 'type': 'str'}, - 'display': {'key': 'display', 'type': 'OperationDisplay'}, + "name": {"key": "name", "type": "str"}, + "display": {"key": "display", "type": "OperationDisplay"}, } - def __init__( - self, - *, - name: Optional[str] = None, - display: Optional["OperationDisplay"] = None, - **kwargs - ): + def __init__(self, *, name: Optional[str] = None, display: Optional["_models.OperationDisplay"] = None, **kwargs): """ :keyword name: Operation name: {provider}/{resource}/{operation}. :paramtype name: str :keyword display: The object that represents the operation. - :paramtype display: ~azure.mgmt.resource.managedapplications.models.OperationDisplay + :paramtype display: + ~azure.mgmt.resource.managedapplications.v2018_06_01.models.OperationDisplay """ - super(Operation, self).__init__(**kwargs) + super().__init__(**kwargs) self.name = name self.display = display -class OperationDisplay(msrest.serialization.Model): +class OperationDisplay(_serialization.Model): """The object that represents the operation. :ivar provider: Service provider: Microsoft.Solutions. @@ -798,9 +782,9 @@ class OperationDisplay(msrest.serialization.Model): """ _attribute_map = { - 'provider': {'key': 'provider', 'type': 'str'}, - 'resource': {'key': 'resource', 'type': 'str'}, - 'operation': {'key': 'operation', 'type': 'str'}, + "provider": {"key": "provider", "type": "str"}, + "resource": {"key": "resource", "type": "str"}, + "operation": {"key": "operation", "type": "str"}, } def __init__( @@ -819,99 +803,86 @@ def __init__( :keyword operation: Operation type: Read, write, delete, etc. :paramtype operation: str """ - super(OperationDisplay, self).__init__(**kwargs) + super().__init__(**kwargs) self.provider = provider self.resource = resource self.operation = operation -class OperationListResult(msrest.serialization.Model): +class OperationListResult(_serialization.Model): """Result of the request to list Microsoft.Solutions operations. It contains a list of operations and a URL link to get the next set of results. :ivar value: List of Microsoft.Solutions operations. - :vartype value: list[~azure.mgmt.resource.managedapplications.models.Operation] + :vartype value: list[~azure.mgmt.resource.managedapplications.v2018_06_01.models.Operation] :ivar next_link: URL to get the next set of operation list results if there are any. :vartype next_link: str """ _attribute_map = { - 'value': {'key': 'value', 'type': '[Operation]'}, - 'next_link': {'key': 'nextLink', 'type': 'str'}, + "value": {"key": "value", "type": "[Operation]"}, + "next_link": {"key": "nextLink", "type": "str"}, } - def __init__( - self, - *, - value: Optional[List["Operation"]] = None, - next_link: Optional[str] = None, - **kwargs - ): + def __init__(self, *, value: Optional[List["_models.Operation"]] = None, next_link: Optional[str] = None, **kwargs): """ :keyword value: List of Microsoft.Solutions operations. - :paramtype value: list[~azure.mgmt.resource.managedapplications.models.Operation] + :paramtype value: list[~azure.mgmt.resource.managedapplications.v2018_06_01.models.Operation] :keyword next_link: URL to get the next set of operation list results if there are any. :paramtype next_link: str """ - super(OperationListResult, self).__init__(**kwargs) + super().__init__(**kwargs) self.value = value self.next_link = next_link -class Plan(msrest.serialization.Model): +class Plan(_serialization.Model): """Plan for the managed application. All required parameters must be populated in order to send to Azure. - :ivar name: Required. The plan name. + :ivar name: The plan name. Required. :vartype name: str - :ivar publisher: Required. The publisher ID. + :ivar publisher: The publisher ID. Required. :vartype publisher: str - :ivar product: Required. The product code. + :ivar product: The product code. Required. :vartype product: str :ivar promotion_code: The promotion code. :vartype promotion_code: str - :ivar version: Required. The plan's version. + :ivar version: The plan's version. Required. :vartype version: str """ _validation = { - 'name': {'required': True}, - 'publisher': {'required': True}, - 'product': {'required': True}, - 'version': {'required': True}, + "name": {"required": True}, + "publisher": {"required": True}, + "product": {"required": True}, + "version": {"required": True}, } _attribute_map = { - 'name': {'key': 'name', 'type': 'str'}, - 'publisher': {'key': 'publisher', 'type': 'str'}, - 'product': {'key': 'product', 'type': 'str'}, - 'promotion_code': {'key': 'promotionCode', 'type': 'str'}, - 'version': {'key': 'version', 'type': 'str'}, + "name": {"key": "name", "type": "str"}, + "publisher": {"key": "publisher", "type": "str"}, + "product": {"key": "product", "type": "str"}, + "promotion_code": {"key": "promotionCode", "type": "str"}, + "version": {"key": "version", "type": "str"}, } def __init__( - self, - *, - name: str, - publisher: str, - product: str, - version: str, - promotion_code: Optional[str] = None, - **kwargs + self, *, name: str, publisher: str, product: str, version: str, promotion_code: Optional[str] = None, **kwargs ): """ - :keyword name: Required. The plan name. + :keyword name: The plan name. Required. :paramtype name: str - :keyword publisher: Required. The publisher ID. + :keyword publisher: The publisher ID. Required. :paramtype publisher: str - :keyword product: Required. The product code. + :keyword product: The product code. Required. :paramtype product: str :keyword promotion_code: The promotion code. :paramtype promotion_code: str - :keyword version: Required. The plan's version. + :keyword version: The plan's version. Required. :paramtype version: str """ - super(Plan, self).__init__(**kwargs) + super().__init__(**kwargs) self.name = name self.publisher = publisher self.product = product @@ -919,7 +890,7 @@ def __init__( self.version = version -class PlanPatchable(msrest.serialization.Model): +class PlanPatchable(_serialization.Model): """Plan for the managed application. :ivar name: The plan name. @@ -935,11 +906,11 @@ class PlanPatchable(msrest.serialization.Model): """ _attribute_map = { - 'name': {'key': 'name', 'type': 'str'}, - 'publisher': {'key': 'publisher', 'type': 'str'}, - 'product': {'key': 'product', 'type': 'str'}, - 'promotion_code': {'key': 'promotionCode', 'type': 'str'}, - 'version': {'key': 'version', 'type': 'str'}, + "name": {"key": "name", "type": "str"}, + "publisher": {"key": "publisher", "type": "str"}, + "product": {"key": "product", "type": "str"}, + "promotion_code": {"key": "promotionCode", "type": "str"}, + "version": {"key": "version", "type": "str"}, } def __init__( @@ -964,7 +935,7 @@ def __init__( :keyword version: The plan's version. :paramtype version: str """ - super(PlanPatchable, self).__init__(**kwargs) + super().__init__(**kwargs) self.name = name self.publisher = publisher self.product = product @@ -972,12 +943,12 @@ def __init__( self.version = version -class Sku(msrest.serialization.Model): +class Sku(_serialization.Model): """SKU for the resource. All required parameters must be populated in order to send to Azure. - :ivar name: Required. The SKU name. + :ivar name: The SKU name. Required. :vartype name: str :ivar tier: The SKU tier. :vartype tier: str @@ -992,16 +963,16 @@ class Sku(msrest.serialization.Model): """ _validation = { - 'name': {'required': True}, + "name": {"required": True}, } _attribute_map = { - 'name': {'key': 'name', 'type': 'str'}, - 'tier': {'key': 'tier', 'type': 'str'}, - 'size': {'key': 'size', 'type': 'str'}, - 'family': {'key': 'family', 'type': 'str'}, - 'model': {'key': 'model', 'type': 'str'}, - 'capacity': {'key': 'capacity', 'type': 'int'}, + "name": {"key": "name", "type": "str"}, + "tier": {"key": "tier", "type": "str"}, + "size": {"key": "size", "type": "str"}, + "family": {"key": "family", "type": "str"}, + "model": {"key": "model", "type": "str"}, + "capacity": {"key": "capacity", "type": "int"}, } def __init__( @@ -1016,7 +987,7 @@ def __init__( **kwargs ): """ - :keyword name: Required. The SKU name. + :keyword name: The SKU name. Required. :paramtype name: str :keyword tier: The SKU tier. :paramtype tier: str @@ -1029,7 +1000,7 @@ def __init__( :keyword capacity: The SKU capacity. :paramtype capacity: int """ - super(Sku, self).__init__(**kwargs) + super().__init__(**kwargs) self.name = name self.tier = tier self.size = size diff --git a/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/managedapplications/v2018_06_01/models/_patch.py b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/managedapplications/v2018_06_01/models/_patch.py new file mode 100644 index 0000000000000..f7dd32510333d --- /dev/null +++ b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/managedapplications/v2018_06_01/models/_patch.py @@ -0,0 +1,20 @@ +# ------------------------------------ +# Copyright (c) Microsoft Corporation. +# Licensed under the MIT License. +# ------------------------------------ +"""Customize generated code here. + +Follow our quickstart for examples: https://aka.ms/azsdk/python/dpcodegen/python/customize +""" +from typing import List + +__all__: List[str] = [] # Add all objects you want publicly available to users at this package level + + +def patch_sdk(): + """Do not remove from this file. + + `patch_sdk` is a last resort escape hatch that allows you to do customizations + you can't accomplish using the techniques described in + https://aka.ms/azsdk/python/dpcodegen/python/customize + """ diff --git a/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/managedapplications/aio/operations/__init__.py b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/managedapplications/v2018_06_01/operations/__init__.py similarity index 64% rename from sdk/resources/azure-mgmt-resource/azure/mgmt/resource/managedapplications/aio/operations/__init__.py rename to sdk/resources/azure-mgmt-resource/azure/mgmt/resource/managedapplications/v2018_06_01/operations/__init__.py index c37a7d15fb768..fb2a5ff1b798d 100644 --- a/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/managedapplications/aio/operations/__init__.py +++ b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/managedapplications/v2018_06_01/operations/__init__.py @@ -10,8 +10,14 @@ from ._operations import ApplicationsOperations from ._operations import ApplicationDefinitionsOperations +from ._patch import __all__ as _patch_all +from ._patch import * # type: ignore # pylint: disable=unused-wildcard-import +from ._patch import patch_sdk as _patch_sdk + __all__ = [ - 'ApplicationClientOperationsMixin', - 'ApplicationsOperations', - 'ApplicationDefinitionsOperations', + "ApplicationClientOperationsMixin", + "ApplicationsOperations", + "ApplicationDefinitionsOperations", ] +__all__.extend([p for p in _patch_all if p not in __all__]) +_patch_sdk() diff --git a/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/managedapplications/v2018_06_01/operations/_operations.py b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/managedapplications/v2018_06_01/operations/_operations.py new file mode 100644 index 0000000000000..574cbc65e6384 --- /dev/null +++ b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/managedapplications/v2018_06_01/operations/_operations.py @@ -0,0 +1,2798 @@ +# pylint: disable=too-many-lines +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- +from typing import Any, Callable, Dict, IO, Iterable, Optional, TypeVar, Union, cast, overload +from urllib.parse import parse_qs, urljoin, urlparse + +from azure.core.exceptions import ( + ClientAuthenticationError, + HttpResponseError, + ResourceExistsError, + ResourceNotFoundError, + ResourceNotModifiedError, + map_error, +) +from azure.core.paging import ItemPaged +from azure.core.pipeline import PipelineResponse +from azure.core.pipeline.transport import HttpResponse +from azure.core.polling import LROPoller, NoPolling, PollingMethod +from azure.core.rest import HttpRequest +from azure.core.tracing.decorator import distributed_trace +from azure.core.utils import case_insensitive_dict +from azure.mgmt.core.exceptions import ARMErrorFormat +from azure.mgmt.core.polling.arm_polling import ARMPolling + +from .. import models as _models +from ..._serialization import Serializer +from .._vendor import MixinABC, _convert_request, _format_url_section + +T = TypeVar("T") +ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] + +_SERIALIZER = Serializer() +_SERIALIZER.client_side_validation = False + + +def build_list_operations_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", "2018-06-01")) # type: str + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = kwargs.pop("template_url", "/providers/Microsoft.Solutions/operations") + + # Construct parameters + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") + + # Construct headers + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) + + +def build_applications_get_request( + resource_group_name: str, application_name: str, subscription_id: str, **kwargs: Any +) -> HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2018-06-01")) # type: str + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Solutions/applications/{applicationName}", + ) # pylint: disable=line-too-long + path_format_arguments = { + "resourceGroupName": _SERIALIZER.url( + "resource_group_name", resource_group_name, "str", max_length=90, min_length=1, pattern=r"^[-\w\._\(\)]+$" + ), + "applicationName": _SERIALIZER.url("application_name", application_name, "str", max_length=64, min_length=3), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + } + + _url = _format_url_section(_url, **path_format_arguments) + + # Construct parameters + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") + + # Construct headers + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) + + +def build_applications_delete_request( + resource_group_name: str, application_name: str, subscription_id: str, **kwargs: Any +) -> HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2018-06-01")) # type: str + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Solutions/applications/{applicationName}", + ) # pylint: disable=line-too-long + path_format_arguments = { + "resourceGroupName": _SERIALIZER.url( + "resource_group_name", resource_group_name, "str", max_length=90, min_length=1, pattern=r"^[-\w\._\(\)]+$" + ), + "applicationName": _SERIALIZER.url("application_name", application_name, "str", max_length=64, min_length=3), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + } + + _url = _format_url_section(_url, **path_format_arguments) + + # Construct parameters + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") + + # Construct headers + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="DELETE", url=_url, params=_params, headers=_headers, **kwargs) + + +def build_applications_create_or_update_request( + resource_group_name: str, application_name: str, subscription_id: str, **kwargs: Any +) -> HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2018-06-01")) # type: str + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Solutions/applications/{applicationName}", + ) # pylint: disable=line-too-long + path_format_arguments = { + "resourceGroupName": _SERIALIZER.url( + "resource_group_name", resource_group_name, "str", max_length=90, min_length=1, pattern=r"^[-\w\._\(\)]+$" + ), + "applicationName": _SERIALIZER.url("application_name", application_name, "str", max_length=64, min_length=3), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + } + + _url = _format_url_section(_url, **path_format_arguments) + + # Construct parameters + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") + + # Construct headers + if content_type is not None: + _headers["Content-Type"] = _SERIALIZER.header("content_type", content_type, "str") + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="PUT", url=_url, params=_params, headers=_headers, **kwargs) + + +def build_applications_update_request( + resource_group_name: str, application_name: str, subscription_id: str, **kwargs: Any +) -> HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2018-06-01")) # type: str + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Solutions/applications/{applicationName}", + ) # pylint: disable=line-too-long + path_format_arguments = { + "resourceGroupName": _SERIALIZER.url( + "resource_group_name", resource_group_name, "str", max_length=90, min_length=1, pattern=r"^[-\w\._\(\)]+$" + ), + "applicationName": _SERIALIZER.url("application_name", application_name, "str", max_length=64, min_length=3), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + } + + _url = _format_url_section(_url, **path_format_arguments) + + # Construct parameters + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") + + # Construct headers + if content_type is not None: + _headers["Content-Type"] = _SERIALIZER.header("content_type", content_type, "str") + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="PATCH", url=_url, params=_params, headers=_headers, **kwargs) + + +def build_applications_list_by_resource_group_request( + resource_group_name: str, subscription_id: str, **kwargs: Any +) -> HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2018-06-01")) # type: str + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Solutions/applications", + ) # pylint: disable=line-too-long + path_format_arguments = { + "resourceGroupName": _SERIALIZER.url( + "resource_group_name", resource_group_name, "str", max_length=90, min_length=1, pattern=r"^[-\w\._\(\)]+$" + ), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + } + + _url = _format_url_section(_url, **path_format_arguments) + + # Construct parameters + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") + + # Construct headers + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) + + +def build_applications_list_by_subscription_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", "2018-06-01")) # type: str + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/providers/Microsoft.Solutions/applications") + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + } + + _url = _format_url_section(_url, **path_format_arguments) + + # Construct parameters + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") + + # Construct headers + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) + + +def build_applications_get_by_id_request(application_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", "2018-06-01")) # type: str + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = kwargs.pop("template_url", "/{applicationId}") + path_format_arguments = { + "applicationId": _SERIALIZER.url("application_id", application_id, "str", skip_quote=True), + } + + _url = _format_url_section(_url, **path_format_arguments) + + # Construct parameters + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") + + # Construct headers + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) + + +def build_applications_delete_by_id_request(application_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", "2018-06-01")) # type: str + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = kwargs.pop("template_url", "/{applicationId}") + path_format_arguments = { + "applicationId": _SERIALIZER.url("application_id", application_id, "str", skip_quote=True), + } + + _url = _format_url_section(_url, **path_format_arguments) + + # Construct parameters + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") + + # Construct headers + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="DELETE", url=_url, params=_params, headers=_headers, **kwargs) + + +def build_applications_create_or_update_by_id_request(application_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", "2018-06-01")) # type: str + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = kwargs.pop("template_url", "/{applicationId}") + path_format_arguments = { + "applicationId": _SERIALIZER.url("application_id", application_id, "str", skip_quote=True), + } + + _url = _format_url_section(_url, **path_format_arguments) + + # Construct parameters + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") + + # Construct headers + if content_type is not None: + _headers["Content-Type"] = _SERIALIZER.header("content_type", content_type, "str") + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="PUT", url=_url, params=_params, headers=_headers, **kwargs) + + +def build_applications_update_by_id_request(application_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", "2018-06-01")) # type: str + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = kwargs.pop("template_url", "/{applicationId}") + path_format_arguments = { + "applicationId": _SERIALIZER.url("application_id", application_id, "str", skip_quote=True), + } + + _url = _format_url_section(_url, **path_format_arguments) + + # Construct parameters + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") + + # Construct headers + if content_type is not None: + _headers["Content-Type"] = _SERIALIZER.header("content_type", content_type, "str") + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="PATCH", url=_url, params=_params, headers=_headers, **kwargs) + + +def build_application_definitions_get_request( + resource_group_name: str, application_definition_name: str, subscription_id: str, **kwargs: Any +) -> HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2018-06-01")) # type: str + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Solutions/applicationDefinitions/{applicationDefinitionName}", + ) # pylint: disable=line-too-long + path_format_arguments = { + "resourceGroupName": _SERIALIZER.url( + "resource_group_name", resource_group_name, "str", max_length=90, min_length=1, pattern=r"^[-\w\._\(\)]+$" + ), + "applicationDefinitionName": _SERIALIZER.url( + "application_definition_name", application_definition_name, "str", max_length=64, min_length=3 + ), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + } + + _url = _format_url_section(_url, **path_format_arguments) + + # Construct parameters + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") + + # Construct headers + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) + + +def build_application_definitions_delete_request( + resource_group_name: str, application_definition_name: str, subscription_id: str, **kwargs: Any +) -> HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2018-06-01")) # type: str + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Solutions/applicationDefinitions/{applicationDefinitionName}", + ) # pylint: disable=line-too-long + path_format_arguments = { + "resourceGroupName": _SERIALIZER.url( + "resource_group_name", resource_group_name, "str", max_length=90, min_length=1, pattern=r"^[-\w\._\(\)]+$" + ), + "applicationDefinitionName": _SERIALIZER.url( + "application_definition_name", application_definition_name, "str", max_length=64, min_length=3 + ), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + } + + _url = _format_url_section(_url, **path_format_arguments) + + # Construct parameters + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") + + # Construct headers + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="DELETE", url=_url, params=_params, headers=_headers, **kwargs) + + +def build_application_definitions_create_or_update_request( + resource_group_name: str, application_definition_name: str, subscription_id: str, **kwargs: Any +) -> HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2018-06-01")) # type: str + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Solutions/applicationDefinitions/{applicationDefinitionName}", + ) # pylint: disable=line-too-long + path_format_arguments = { + "resourceGroupName": _SERIALIZER.url( + "resource_group_name", resource_group_name, "str", max_length=90, min_length=1, pattern=r"^[-\w\._\(\)]+$" + ), + "applicationDefinitionName": _SERIALIZER.url( + "application_definition_name", application_definition_name, "str", max_length=64, min_length=3 + ), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + } + + _url = _format_url_section(_url, **path_format_arguments) + + # Construct parameters + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") + + # Construct headers + if content_type is not None: + _headers["Content-Type"] = _SERIALIZER.header("content_type", content_type, "str") + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="PUT", url=_url, params=_params, headers=_headers, **kwargs) + + +def build_application_definitions_list_by_resource_group_request( + resource_group_name: str, subscription_id: str, **kwargs: Any +) -> HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2018-06-01")) # type: str + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Solutions/applicationDefinitions", + ) # pylint: disable=line-too-long + path_format_arguments = { + "resourceGroupName": _SERIALIZER.url( + "resource_group_name", resource_group_name, "str", max_length=90, min_length=1, pattern=r"^[-\w\._\(\)]+$" + ), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + } + + _url = _format_url_section(_url, **path_format_arguments) + + # Construct parameters + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") + + # Construct headers + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) + + +def build_application_definitions_get_by_id_request( + resource_group_name: str, application_definition_name: str, subscription_id: str, **kwargs: Any +) -> HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2018-06-01")) # type: str + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Solutions/applicationDefinitions/{applicationDefinitionName}", + ) # pylint: disable=line-too-long + path_format_arguments = { + "resourceGroupName": _SERIALIZER.url( + "resource_group_name", resource_group_name, "str", max_length=90, min_length=1, pattern=r"^[-\w\._\(\)]+$" + ), + "applicationDefinitionName": _SERIALIZER.url( + "application_definition_name", application_definition_name, "str", max_length=64, min_length=3 + ), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + } + + _url = _format_url_section(_url, **path_format_arguments) + + # Construct parameters + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") + + # Construct headers + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) + + +def build_application_definitions_delete_by_id_request( + resource_group_name: str, application_definition_name: str, subscription_id: str, **kwargs: Any +) -> HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2018-06-01")) # type: str + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Solutions/applicationDefinitions/{applicationDefinitionName}", + ) # pylint: disable=line-too-long + path_format_arguments = { + "resourceGroupName": _SERIALIZER.url( + "resource_group_name", resource_group_name, "str", max_length=90, min_length=1, pattern=r"^[-\w\._\(\)]+$" + ), + "applicationDefinitionName": _SERIALIZER.url( + "application_definition_name", application_definition_name, "str", max_length=64, min_length=3 + ), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + } + + _url = _format_url_section(_url, **path_format_arguments) + + # Construct parameters + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") + + # Construct headers + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="DELETE", url=_url, params=_params, headers=_headers, **kwargs) + + +def build_application_definitions_create_or_update_by_id_request( + resource_group_name: str, application_definition_name: str, subscription_id: str, **kwargs: Any +) -> HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2018-06-01")) # type: str + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Solutions/applicationDefinitions/{applicationDefinitionName}", + ) # pylint: disable=line-too-long + path_format_arguments = { + "resourceGroupName": _SERIALIZER.url( + "resource_group_name", resource_group_name, "str", max_length=90, min_length=1, pattern=r"^[-\w\._\(\)]+$" + ), + "applicationDefinitionName": _SERIALIZER.url( + "application_definition_name", application_definition_name, "str", max_length=64, min_length=3 + ), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + } + + _url = _format_url_section(_url, **path_format_arguments) + + # Construct parameters + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") + + # Construct headers + if content_type is not None: + _headers["Content-Type"] = _SERIALIZER.header("content_type", content_type, "str") + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="PUT", url=_url, params=_params, headers=_headers, **kwargs) + + +class ApplicationClientOperationsMixin(MixinABC): + @distributed_trace + def list_operations(self, **kwargs: Any) -> Iterable["_models.Operation"]: + """Lists all of the available Microsoft.Solutions REST API operations. + + :keyword callable cls: A custom type or function that will be passed the direct response + :return: An iterator like instance of either Operation or the result of cls(response) + :rtype: + ~azure.core.paging.ItemPaged[~azure.mgmt.resource.managedapplications.v2018_06_01.models.Operation] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2018-06-01")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[_models.OperationListResult] + + error_map = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + def prepare_request(next_link=None): + if not next_link: + + request = build_list_operations_request( + api_version=api_version, + template_url=self.list_operations.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 = urlparse(next_link) + _next_request_params = case_insensitive_dict(parse_qs(_parsed_next_link.query)) + _next_request_params["api-version"] = self._config.api_version + request = HttpRequest("GET", 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.method = "GET" + return request + + 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) + 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 + ) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + return pipeline_response + + return ItemPaged(get_next, extract_data) + + list_operations.metadata = {"url": "/providers/Microsoft.Solutions/operations"} # type: ignore + + +class ApplicationsOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. + + Instead, you should access the following operations through + :class:`~azure.mgmt.resource.managedapplications.v2018_06_01.ApplicationClient`'s + :attr:`applications` attribute. + """ + + models = _models + + def __init__(self, *args, **kwargs): + input_args = list(args) + self._client = input_args.pop(0) if input_args else kwargs.pop("client") + self._config = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") + + @distributed_trace + def get(self, resource_group_name: str, application_name: str, **kwargs: Any) -> Optional[_models.Application]: + """Gets the managed application. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param application_name: The name of the managed application. Required. + :type application_name: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: Application or None or the result of cls(response) + :rtype: ~azure.mgmt.resource.managedapplications.v2018_06_01.models.Application or None + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2018-06-01")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[Optional[_models.Application]] + + request = build_applications_get_request( + resource_group_name=resource_group_name, + application_name=application_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + template_url=self.get.metadata["url"], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore + + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [200, 404]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + deserialized = None + if response.status_code == 200: + deserialized = self._deserialize("Application", pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + + get.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Solutions/applications/{applicationName}"} # type: ignore + + def _delete_initial( # pylint: disable=inconsistent-return-statements + self, resource_group_name: str, application_name: str, **kwargs: Any + ) -> None: + error_map = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2018-06-01")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[None] + + request = build_applications_delete_request( + resource_group_name=resource_group_name, + application_name=application_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + template_url=self._delete_initial.metadata["url"], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore + + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [202, 204]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + if cls: + return cls(pipeline_response, None, {}) + + _delete_initial.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Solutions/applications/{applicationName}"} # type: ignore + + @distributed_trace + def begin_delete(self, resource_group_name: str, application_name: str, **kwargs: Any) -> LROPoller[None]: + """Deletes the managed application. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param application_name: The name of the managed application. Required. + :type application_name: str + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be ARMPolling. Pass in False for this + operation to not poll, or pass in your own initialized polling object for a personal polling + strategy. + :paramtype polling: bool or ~azure.core.polling.PollingMethod + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of LROPoller that returns either None or the result of cls(response) + :rtype: ~azure.core.polling.LROPoller[None] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2018-06-01")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[None] + polling = kwargs.pop("polling", True) # type: Union[bool, PollingMethod] + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token = kwargs.pop("continuation_token", None) # type: Optional[str] + if cont_token is None: + raw_result = self._delete_initial( # type: ignore + resource_group_name=resource_group_name, + application_name=application_name, + api_version=api_version, + cls=lambda x, y, z: x, + headers=_headers, + params=_params, + **kwargs + ) + kwargs.pop("error_map", None) + + def get_long_running_output(pipeline_response): # pylint: disable=inconsistent-return-statements + if cls: + return cls(pipeline_response, None, {}) + + if polling is True: + polling_method = cast(PollingMethod, ARMPolling(lro_delay, **kwargs)) # type: PollingMethod + elif polling is False: + polling_method = cast(PollingMethod, NoPolling()) + else: + polling_method = polling + if cont_token: + return LROPoller.from_continuation_token( + polling_method=polling_method, + continuation_token=cont_token, + client=self._client, + deserialization_callback=get_long_running_output, + ) + return LROPoller(self._client, raw_result, get_long_running_output, polling_method) + + begin_delete.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Solutions/applications/{applicationName}"} # type: ignore + + def _create_or_update_initial( + self, resource_group_name: str, application_name: str, parameters: Union[_models.Application, IO], **kwargs: Any + ) -> _models.Application: + error_map = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2018-06-01")) # type: str + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.Application] + + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(parameters, (IO, bytes)): + _content = parameters + else: + _json = self._serialize.body(parameters, "Application") + + request = build_applications_create_or_update_request( + resource_group_name=resource_group_name, + application_name=application_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + content_type=content_type, + json=_json, + content=_content, + template_url=self._create_or_update_initial.metadata["url"], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore + + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [200, 201]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + if response.status_code == 200: + deserialized = self._deserialize("Application", pipeline_response) + + if response.status_code == 201: + deserialized = self._deserialize("Application", pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + + _create_or_update_initial.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Solutions/applications/{applicationName}"} # type: ignore + + @overload + def begin_create_or_update( + self, + resource_group_name: str, + application_name: str, + parameters: _models.Application, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> LROPoller[_models.Application]: + """Creates a new managed application. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param application_name: The name of the managed application. Required. + :type application_name: str + :param parameters: Parameters supplied to the create or update a managed application. Required. + :type parameters: ~azure.mgmt.resource.managedapplications.v2018_06_01.models.Application + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be ARMPolling. Pass in False for this + operation to not poll, or pass in your own initialized polling object for a personal polling + strategy. + :paramtype polling: bool or ~azure.core.polling.PollingMethod + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of LROPoller that returns either Application or the result of + cls(response) + :rtype: + ~azure.core.polling.LROPoller[~azure.mgmt.resource.managedapplications.v2018_06_01.models.Application] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + def begin_create_or_update( + self, + resource_group_name: str, + application_name: str, + parameters: IO, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> LROPoller[_models.Application]: + """Creates a new managed application. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param application_name: The name of the managed application. Required. + :type application_name: str + :param parameters: Parameters supplied to the create or update a managed application. Required. + :type parameters: IO + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be ARMPolling. Pass in False for this + operation to not poll, or pass in your own initialized polling object for a personal polling + strategy. + :paramtype polling: bool or ~azure.core.polling.PollingMethod + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of LROPoller that returns either Application or the result of + cls(response) + :rtype: + ~azure.core.polling.LROPoller[~azure.mgmt.resource.managedapplications.v2018_06_01.models.Application] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace + def begin_create_or_update( + self, resource_group_name: str, application_name: str, parameters: Union[_models.Application, IO], **kwargs: Any + ) -> LROPoller[_models.Application]: + """Creates a new managed application. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param application_name: The name of the managed application. Required. + :type application_name: str + :param parameters: Parameters supplied to the create or update a managed application. Is either + a model type or a IO type. Required. + :type parameters: ~azure.mgmt.resource.managedapplications.v2018_06_01.models.Application or IO + :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. + Default value is None. + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be ARMPolling. Pass in False for this + operation to not poll, or pass in your own initialized polling object for a personal polling + strategy. + :paramtype polling: bool or ~azure.core.polling.PollingMethod + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of LROPoller that returns either Application or the result of + cls(response) + :rtype: + ~azure.core.polling.LROPoller[~azure.mgmt.resource.managedapplications.v2018_06_01.models.Application] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _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", "2018-06-01")) # type: str + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.Application] + polling = kwargs.pop("polling", True) # type: Union[bool, PollingMethod] + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token = kwargs.pop("continuation_token", None) # type: Optional[str] + if cont_token is None: + raw_result = self._create_or_update_initial( # type: ignore + resource_group_name=resource_group_name, + application_name=application_name, + parameters=parameters, + api_version=api_version, + content_type=content_type, + cls=lambda x, y, z: x, + headers=_headers, + params=_params, + **kwargs + ) + kwargs.pop("error_map", None) + + def get_long_running_output(pipeline_response): + deserialized = self._deserialize("Application", pipeline_response) + if cls: + return cls(pipeline_response, deserialized, {}) + return deserialized + + if polling is True: + polling_method = cast(PollingMethod, ARMPolling(lro_delay, **kwargs)) # type: PollingMethod + elif polling is False: + polling_method = cast(PollingMethod, NoPolling()) + else: + polling_method = polling + if cont_token: + return LROPoller.from_continuation_token( + polling_method=polling_method, + continuation_token=cont_token, + client=self._client, + deserialization_callback=get_long_running_output, + ) + return LROPoller(self._client, raw_result, get_long_running_output, polling_method) + + begin_create_or_update.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Solutions/applications/{applicationName}"} # type: ignore + + @overload + def update( + self, + resource_group_name: str, + application_name: str, + parameters: Optional[_models.ApplicationPatchable] = None, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.Application: + """Updates an existing managed application. The only value that can be updated via PATCH currently + is the tags. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param application_name: The name of the managed application. Required. + :type application_name: str + :param parameters: Parameters supplied to update an existing managed application. Default value + is None. + :type parameters: + ~azure.mgmt.resource.managedapplications.v2018_06_01.models.ApplicationPatchable + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: Application or the result of cls(response) + :rtype: ~azure.mgmt.resource.managedapplications.v2018_06_01.models.Application + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + def update( + self, + resource_group_name: str, + application_name: str, + parameters: Optional[IO] = None, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.Application: + """Updates an existing managed application. The only value that can be updated via PATCH currently + is the tags. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param application_name: The name of the managed application. Required. + :type application_name: str + :param parameters: Parameters supplied to update an existing managed application. Default value + is None. + :type parameters: IO + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: Application or the result of cls(response) + :rtype: ~azure.mgmt.resource.managedapplications.v2018_06_01.models.Application + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace + def update( + self, + resource_group_name: str, + application_name: str, + parameters: Optional[Union[_models.ApplicationPatchable, IO]] = None, + **kwargs: Any + ) -> _models.Application: + """Updates an existing managed application. The only value that can be updated via PATCH currently + is the tags. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param application_name: The name of the managed application. Required. + :type application_name: str + :param parameters: Parameters supplied to update an existing managed application. Is either a + model type or a IO type. Default value is None. + :type parameters: + ~azure.mgmt.resource.managedapplications.v2018_06_01.models.ApplicationPatchable or IO + :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. + Default value is None. + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: Application or the result of cls(response) + :rtype: ~azure.mgmt.resource.managedapplications.v2018_06_01.models.Application + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2018-06-01")) # type: str + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.Application] + + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(parameters, (IO, bytes)): + _content = parameters + else: + if parameters is not None: + _json = self._serialize.body(parameters, "ApplicationPatchable") + else: + _json = None + + request = build_applications_update_request( + resource_group_name=resource_group_name, + application_name=application_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + content_type=content_type, + json=_json, + content=_content, + template_url=self.update.metadata["url"], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore + + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + deserialized = self._deserialize("Application", pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + + update.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Solutions/applications/{applicationName}"} # type: ignore + + @distributed_trace + def list_by_resource_group(self, resource_group_name: str, **kwargs: Any) -> Iterable["_models.Application"]: + """Gets all the applications within a resource group. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: An iterator like instance of either Application or the result of cls(response) + :rtype: + ~azure.core.paging.ItemPaged[~azure.mgmt.resource.managedapplications.v2018_06_01.models.Application] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2018-06-01")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[_models.ApplicationListResult] + + error_map = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + def prepare_request(next_link=None): + if not next_link: + + request = build_applications_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 = urlparse(next_link) + _next_request_params = case_insensitive_dict(parse_qs(_parsed_next_link.query)) + _next_request_params["api-version"] = self._config.api_version + request = HttpRequest("GET", 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.method = "GET" + return request + + def extract_data(pipeline_response): + deserialized = self._deserialize("ApplicationListResult", pipeline_response) + list_of_elem = deserialized.value + if cls: + list_of_elem = cls(list_of_elem) + 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 + ) + 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.ErrorResponse, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + return pipeline_response + + return ItemPaged(get_next, extract_data) + + list_by_resource_group.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Solutions/applications"} # type: ignore + + @distributed_trace + def list_by_subscription(self, **kwargs: Any) -> Iterable["_models.Application"]: + """Gets all the applications within a subscription. + + :keyword callable cls: A custom type or function that will be passed the direct response + :return: An iterator like instance of either Application or the result of cls(response) + :rtype: + ~azure.core.paging.ItemPaged[~azure.mgmt.resource.managedapplications.v2018_06_01.models.Application] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2018-06-01")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[_models.ApplicationListResult] + + error_map = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + def prepare_request(next_link=None): + if not next_link: + + request = build_applications_list_by_subscription_request( + subscription_id=self._config.subscription_id, + api_version=api_version, + template_url=self.list_by_subscription.metadata["url"], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore + + else: + # make call to next link with the client's api-version + _parsed_next_link = urlparse(next_link) + _next_request_params = case_insensitive_dict(parse_qs(_parsed_next_link.query)) + _next_request_params["api-version"] = self._config.api_version + request = HttpRequest("GET", 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.method = "GET" + return request + + def extract_data(pipeline_response): + deserialized = self._deserialize("ApplicationListResult", pipeline_response) + list_of_elem = deserialized.value + if cls: + list_of_elem = cls(list_of_elem) + 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 + ) + 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.ErrorResponse, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + return pipeline_response + + return ItemPaged(get_next, extract_data) + + list_by_subscription.metadata = {"url": "/subscriptions/{subscriptionId}/providers/Microsoft.Solutions/applications"} # type: ignore + + @distributed_trace + def get_by_id(self, application_id: str, **kwargs: Any) -> Optional[_models.Application]: + """Gets the managed application. + + :param application_id: The fully qualified ID of the managed application, including the managed + application name and the managed application resource type. Use the format, + /subscriptions/{guid}/resourceGroups/{resource-group-name}/Microsoft.Solutions/applications/{application-name}. + Required. + :type application_id: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: Application or None or the result of cls(response) + :rtype: ~azure.mgmt.resource.managedapplications.v2018_06_01.models.Application or None + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2018-06-01")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[Optional[_models.Application]] + + request = build_applications_get_by_id_request( + application_id=application_id, + api_version=api_version, + template_url=self.get_by_id.metadata["url"], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore + + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [200, 404]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + deserialized = None + if response.status_code == 200: + deserialized = self._deserialize("Application", pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + + get_by_id.metadata = {"url": "/{applicationId}"} # type: ignore + + def _delete_by_id_initial( # pylint: disable=inconsistent-return-statements + self, application_id: str, **kwargs: Any + ) -> None: + error_map = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2018-06-01")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[None] + + request = build_applications_delete_by_id_request( + application_id=application_id, + api_version=api_version, + template_url=self._delete_by_id_initial.metadata["url"], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore + + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [202, 204]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + if cls: + return cls(pipeline_response, None, {}) + + _delete_by_id_initial.metadata = {"url": "/{applicationId}"} # type: ignore + + @distributed_trace + def begin_delete_by_id(self, application_id: str, **kwargs: Any) -> LROPoller[None]: + """Deletes the managed application. + + :param application_id: The fully qualified ID of the managed application, including the managed + application name and the managed application resource type. Use the format, + /subscriptions/{guid}/resourceGroups/{resource-group-name}/Microsoft.Solutions/applications/{application-name}. + Required. + :type application_id: str + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be ARMPolling. Pass in False for this + operation to not poll, or pass in your own initialized polling object for a personal polling + strategy. + :paramtype polling: bool or ~azure.core.polling.PollingMethod + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of LROPoller that returns either None or the result of cls(response) + :rtype: ~azure.core.polling.LROPoller[None] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2018-06-01")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[None] + polling = kwargs.pop("polling", True) # type: Union[bool, PollingMethod] + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token = kwargs.pop("continuation_token", None) # type: Optional[str] + if cont_token is None: + raw_result = self._delete_by_id_initial( # type: ignore + application_id=application_id, + api_version=api_version, + cls=lambda x, y, z: x, + headers=_headers, + params=_params, + **kwargs + ) + kwargs.pop("error_map", None) + + def get_long_running_output(pipeline_response): # pylint: disable=inconsistent-return-statements + if cls: + return cls(pipeline_response, None, {}) + + if polling is True: + polling_method = cast(PollingMethod, ARMPolling(lro_delay, **kwargs)) # type: PollingMethod + elif polling is False: + polling_method = cast(PollingMethod, NoPolling()) + else: + polling_method = polling + if cont_token: + return LROPoller.from_continuation_token( + polling_method=polling_method, + continuation_token=cont_token, + client=self._client, + deserialization_callback=get_long_running_output, + ) + return LROPoller(self._client, raw_result, get_long_running_output, polling_method) + + begin_delete_by_id.metadata = {"url": "/{applicationId}"} # type: ignore + + def _create_or_update_by_id_initial( + self, application_id: str, parameters: Union[_models.Application, IO], **kwargs: Any + ) -> _models.Application: + error_map = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2018-06-01")) # type: str + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.Application] + + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(parameters, (IO, bytes)): + _content = parameters + else: + _json = self._serialize.body(parameters, "Application") + + request = build_applications_create_or_update_by_id_request( + application_id=application_id, + api_version=api_version, + content_type=content_type, + json=_json, + content=_content, + template_url=self._create_or_update_by_id_initial.metadata["url"], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore + + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [200, 201]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + if response.status_code == 200: + deserialized = self._deserialize("Application", pipeline_response) + + if response.status_code == 201: + deserialized = self._deserialize("Application", pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + + _create_or_update_by_id_initial.metadata = {"url": "/{applicationId}"} # type: ignore + + @overload + def begin_create_or_update_by_id( + self, + application_id: str, + parameters: _models.Application, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> LROPoller[_models.Application]: + """Creates a new managed application. + + :param application_id: The fully qualified ID of the managed application, including the managed + application name and the managed application resource type. Use the format, + /subscriptions/{guid}/resourceGroups/{resource-group-name}/Microsoft.Solutions/applications/{application-name}. + Required. + :type application_id: str + :param parameters: Parameters supplied to the create or update a managed application. Required. + :type parameters: ~azure.mgmt.resource.managedapplications.v2018_06_01.models.Application + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be ARMPolling. Pass in False for this + operation to not poll, or pass in your own initialized polling object for a personal polling + strategy. + :paramtype polling: bool or ~azure.core.polling.PollingMethod + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of LROPoller that returns either Application or the result of + cls(response) + :rtype: + ~azure.core.polling.LROPoller[~azure.mgmt.resource.managedapplications.v2018_06_01.models.Application] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + def begin_create_or_update_by_id( + self, application_id: str, parameters: IO, *, content_type: str = "application/json", **kwargs: Any + ) -> LROPoller[_models.Application]: + """Creates a new managed application. + + :param application_id: The fully qualified ID of the managed application, including the managed + application name and the managed application resource type. Use the format, + /subscriptions/{guid}/resourceGroups/{resource-group-name}/Microsoft.Solutions/applications/{application-name}. + Required. + :type application_id: str + :param parameters: Parameters supplied to the create or update a managed application. Required. + :type parameters: IO + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be ARMPolling. Pass in False for this + operation to not poll, or pass in your own initialized polling object for a personal polling + strategy. + :paramtype polling: bool or ~azure.core.polling.PollingMethod + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of LROPoller that returns either Application or the result of + cls(response) + :rtype: + ~azure.core.polling.LROPoller[~azure.mgmt.resource.managedapplications.v2018_06_01.models.Application] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace + def begin_create_or_update_by_id( + self, application_id: str, parameters: Union[_models.Application, IO], **kwargs: Any + ) -> LROPoller[_models.Application]: + """Creates a new managed application. + + :param application_id: The fully qualified ID of the managed application, including the managed + application name and the managed application resource type. Use the format, + /subscriptions/{guid}/resourceGroups/{resource-group-name}/Microsoft.Solutions/applications/{application-name}. + Required. + :type application_id: str + :param parameters: Parameters supplied to the create or update a managed application. Is either + a model type or a IO type. Required. + :type parameters: ~azure.mgmt.resource.managedapplications.v2018_06_01.models.Application or IO + :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. + Default value is None. + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be ARMPolling. Pass in False for this + operation to not poll, or pass in your own initialized polling object for a personal polling + strategy. + :paramtype polling: bool or ~azure.core.polling.PollingMethod + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of LROPoller that returns either Application or the result of + cls(response) + :rtype: + ~azure.core.polling.LROPoller[~azure.mgmt.resource.managedapplications.v2018_06_01.models.Application] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _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", "2018-06-01")) # type: str + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.Application] + polling = kwargs.pop("polling", True) # type: Union[bool, PollingMethod] + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token = kwargs.pop("continuation_token", None) # type: Optional[str] + if cont_token is None: + raw_result = self._create_or_update_by_id_initial( # type: ignore + application_id=application_id, + parameters=parameters, + api_version=api_version, + content_type=content_type, + cls=lambda x, y, z: x, + headers=_headers, + params=_params, + **kwargs + ) + kwargs.pop("error_map", None) + + def get_long_running_output(pipeline_response): + deserialized = self._deserialize("Application", pipeline_response) + if cls: + return cls(pipeline_response, deserialized, {}) + return deserialized + + if polling is True: + polling_method = cast(PollingMethod, ARMPolling(lro_delay, **kwargs)) # type: PollingMethod + elif polling is False: + polling_method = cast(PollingMethod, NoPolling()) + else: + polling_method = polling + if cont_token: + return LROPoller.from_continuation_token( + polling_method=polling_method, + continuation_token=cont_token, + client=self._client, + deserialization_callback=get_long_running_output, + ) + return LROPoller(self._client, raw_result, get_long_running_output, polling_method) + + begin_create_or_update_by_id.metadata = {"url": "/{applicationId}"} # type: ignore + + @overload + def update_by_id( + self, + application_id: str, + parameters: Optional[_models.Application] = None, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.Application: + """Updates an existing managed application. The only value that can be updated via PATCH currently + is the tags. + + :param application_id: The fully qualified ID of the managed application, including the managed + application name and the managed application resource type. Use the format, + /subscriptions/{guid}/resourceGroups/{resource-group-name}/Microsoft.Solutions/applications/{application-name}. + Required. + :type application_id: str + :param parameters: Parameters supplied to update an existing managed application. Default value + is None. + :type parameters: ~azure.mgmt.resource.managedapplications.v2018_06_01.models.Application + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: Application or the result of cls(response) + :rtype: ~azure.mgmt.resource.managedapplications.v2018_06_01.models.Application + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + def update_by_id( + self, + application_id: str, + parameters: Optional[IO] = None, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.Application: + """Updates an existing managed application. The only value that can be updated via PATCH currently + is the tags. + + :param application_id: The fully qualified ID of the managed application, including the managed + application name and the managed application resource type. Use the format, + /subscriptions/{guid}/resourceGroups/{resource-group-name}/Microsoft.Solutions/applications/{application-name}. + Required. + :type application_id: str + :param parameters: Parameters supplied to update an existing managed application. Default value + is None. + :type parameters: IO + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: Application or the result of cls(response) + :rtype: ~azure.mgmt.resource.managedapplications.v2018_06_01.models.Application + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace + def update_by_id( + self, application_id: str, parameters: Optional[Union[_models.Application, IO]] = None, **kwargs: Any + ) -> _models.Application: + """Updates an existing managed application. The only value that can be updated via PATCH currently + is the tags. + + :param application_id: The fully qualified ID of the managed application, including the managed + application name and the managed application resource type. Use the format, + /subscriptions/{guid}/resourceGroups/{resource-group-name}/Microsoft.Solutions/applications/{application-name}. + Required. + :type application_id: str + :param parameters: Parameters supplied to update an existing managed application. Is either a + model type or a IO type. Default value is None. + :type parameters: ~azure.mgmt.resource.managedapplications.v2018_06_01.models.Application or IO + :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. + Default value is None. + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: Application or the result of cls(response) + :rtype: ~azure.mgmt.resource.managedapplications.v2018_06_01.models.Application + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2018-06-01")) # type: str + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.Application] + + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(parameters, (IO, bytes)): + _content = parameters + else: + if parameters is not None: + _json = self._serialize.body(parameters, "Application") + else: + _json = None + + request = build_applications_update_by_id_request( + application_id=application_id, + api_version=api_version, + content_type=content_type, + json=_json, + content=_content, + template_url=self.update_by_id.metadata["url"], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore + + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + deserialized = self._deserialize("Application", pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + + update_by_id.metadata = {"url": "/{applicationId}"} # type: ignore + + +class ApplicationDefinitionsOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. + + Instead, you should access the following operations through + :class:`~azure.mgmt.resource.managedapplications.v2018_06_01.ApplicationClient`'s + :attr:`application_definitions` attribute. + """ + + models = _models + + def __init__(self, *args, **kwargs): + input_args = list(args) + self._client = input_args.pop(0) if input_args else kwargs.pop("client") + self._config = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") + + @distributed_trace + def get( + self, resource_group_name: str, application_definition_name: str, **kwargs: Any + ) -> Optional[_models.ApplicationDefinition]: + """Gets the managed application definition. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param application_definition_name: The name of the managed application definition. Required. + :type application_definition_name: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: ApplicationDefinition or None or the result of cls(response) + :rtype: ~azure.mgmt.resource.managedapplications.v2018_06_01.models.ApplicationDefinition or + None + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2018-06-01")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[Optional[_models.ApplicationDefinition]] + + request = build_application_definitions_get_request( + resource_group_name=resource_group_name, + application_definition_name=application_definition_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + template_url=self.get.metadata["url"], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore + + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [200, 404]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + deserialized = None + if response.status_code == 200: + deserialized = self._deserialize("ApplicationDefinition", pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + + get.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Solutions/applicationDefinitions/{applicationDefinitionName}"} # type: ignore + + def _delete_initial( # pylint: disable=inconsistent-return-statements + self, resource_group_name: str, application_definition_name: str, **kwargs: Any + ) -> None: + error_map = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2018-06-01")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[None] + + request = build_application_definitions_delete_request( + resource_group_name=resource_group_name, + application_definition_name=application_definition_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + template_url=self._delete_initial.metadata["url"], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore + + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [200, 202, 204]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + if cls: + return cls(pipeline_response, None, {}) + + _delete_initial.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Solutions/applicationDefinitions/{applicationDefinitionName}"} # type: ignore + + @distributed_trace + def begin_delete( + self, resource_group_name: str, application_definition_name: str, **kwargs: Any + ) -> LROPoller[None]: + """Deletes the managed application definition. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param application_definition_name: The name of the managed application definition to delete. + Required. + :type application_definition_name: str + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be ARMPolling. Pass in False for this + operation to not poll, or pass in your own initialized polling object for a personal polling + strategy. + :paramtype polling: bool or ~azure.core.polling.PollingMethod + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of LROPoller that returns either None or the result of cls(response) + :rtype: ~azure.core.polling.LROPoller[None] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2018-06-01")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[None] + polling = kwargs.pop("polling", True) # type: Union[bool, PollingMethod] + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token = kwargs.pop("continuation_token", None) # type: Optional[str] + if cont_token is None: + raw_result = self._delete_initial( # type: ignore + resource_group_name=resource_group_name, + application_definition_name=application_definition_name, + api_version=api_version, + cls=lambda x, y, z: x, + headers=_headers, + params=_params, + **kwargs + ) + kwargs.pop("error_map", None) + + def get_long_running_output(pipeline_response): # pylint: disable=inconsistent-return-statements + if cls: + return cls(pipeline_response, None, {}) + + if polling is True: + polling_method = cast(PollingMethod, ARMPolling(lro_delay, **kwargs)) # type: PollingMethod + elif polling is False: + polling_method = cast(PollingMethod, NoPolling()) + else: + polling_method = polling + if cont_token: + return LROPoller.from_continuation_token( + polling_method=polling_method, + continuation_token=cont_token, + client=self._client, + deserialization_callback=get_long_running_output, + ) + return LROPoller(self._client, raw_result, get_long_running_output, polling_method) + + begin_delete.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Solutions/applicationDefinitions/{applicationDefinitionName}"} # type: ignore + + def _create_or_update_initial( + self, + resource_group_name: str, + application_definition_name: str, + parameters: Union[_models.ApplicationDefinition, IO], + **kwargs: Any + ) -> _models.ApplicationDefinition: + error_map = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2018-06-01")) # type: str + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.ApplicationDefinition] + + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(parameters, (IO, bytes)): + _content = parameters + else: + _json = self._serialize.body(parameters, "ApplicationDefinition") + + request = build_application_definitions_create_or_update_request( + resource_group_name=resource_group_name, + application_definition_name=application_definition_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + content_type=content_type, + json=_json, + content=_content, + template_url=self._create_or_update_initial.metadata["url"], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore + + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [200, 201]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + if response.status_code == 200: + deserialized = self._deserialize("ApplicationDefinition", pipeline_response) + + if response.status_code == 201: + deserialized = self._deserialize("ApplicationDefinition", pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + + _create_or_update_initial.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Solutions/applicationDefinitions/{applicationDefinitionName}"} # type: ignore + + @overload + def begin_create_or_update( + self, + resource_group_name: str, + application_definition_name: str, + parameters: _models.ApplicationDefinition, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> LROPoller[_models.ApplicationDefinition]: + """Creates a new managed application definition. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param application_definition_name: The name of the managed application definition. Required. + :type application_definition_name: str + :param parameters: Parameters supplied to the create or update an managed application + definition. Required. + :type parameters: + ~azure.mgmt.resource.managedapplications.v2018_06_01.models.ApplicationDefinition + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be ARMPolling. Pass in False for this + operation to not poll, or pass in your own initialized polling object for a personal polling + strategy. + :paramtype polling: bool or ~azure.core.polling.PollingMethod + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of LROPoller that returns either ApplicationDefinition or the result of + cls(response) + :rtype: + ~azure.core.polling.LROPoller[~azure.mgmt.resource.managedapplications.v2018_06_01.models.ApplicationDefinition] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + def begin_create_or_update( + self, + resource_group_name: str, + application_definition_name: str, + parameters: IO, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> LROPoller[_models.ApplicationDefinition]: + """Creates a new managed application definition. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param application_definition_name: The name of the managed application definition. Required. + :type application_definition_name: str + :param parameters: Parameters supplied to the create or update an managed application + definition. Required. + :type parameters: IO + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be ARMPolling. Pass in False for this + operation to not poll, or pass in your own initialized polling object for a personal polling + strategy. + :paramtype polling: bool or ~azure.core.polling.PollingMethod + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of LROPoller that returns either ApplicationDefinition or the result of + cls(response) + :rtype: + ~azure.core.polling.LROPoller[~azure.mgmt.resource.managedapplications.v2018_06_01.models.ApplicationDefinition] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace + def begin_create_or_update( + self, + resource_group_name: str, + application_definition_name: str, + parameters: Union[_models.ApplicationDefinition, IO], + **kwargs: Any + ) -> LROPoller[_models.ApplicationDefinition]: + """Creates a new managed application definition. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param application_definition_name: The name of the managed application definition. Required. + :type application_definition_name: str + :param parameters: Parameters supplied to the create or update an managed application + definition. Is either a model type or a IO type. Required. + :type parameters: + ~azure.mgmt.resource.managedapplications.v2018_06_01.models.ApplicationDefinition or IO + :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. + Default value is None. + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be ARMPolling. Pass in False for this + operation to not poll, or pass in your own initialized polling object for a personal polling + strategy. + :paramtype polling: bool or ~azure.core.polling.PollingMethod + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of LROPoller that returns either ApplicationDefinition or the result of + cls(response) + :rtype: + ~azure.core.polling.LROPoller[~azure.mgmt.resource.managedapplications.v2018_06_01.models.ApplicationDefinition] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _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", "2018-06-01")) # type: str + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.ApplicationDefinition] + polling = kwargs.pop("polling", True) # type: Union[bool, PollingMethod] + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token = kwargs.pop("continuation_token", None) # type: Optional[str] + if cont_token is None: + raw_result = self._create_or_update_initial( # type: ignore + resource_group_name=resource_group_name, + application_definition_name=application_definition_name, + parameters=parameters, + api_version=api_version, + content_type=content_type, + cls=lambda x, y, z: x, + headers=_headers, + params=_params, + **kwargs + ) + kwargs.pop("error_map", None) + + def get_long_running_output(pipeline_response): + deserialized = self._deserialize("ApplicationDefinition", pipeline_response) + if cls: + return cls(pipeline_response, deserialized, {}) + return deserialized + + if polling is True: + polling_method = cast(PollingMethod, ARMPolling(lro_delay, **kwargs)) # type: PollingMethod + elif polling is False: + polling_method = cast(PollingMethod, NoPolling()) + else: + polling_method = polling + if cont_token: + return LROPoller.from_continuation_token( + polling_method=polling_method, + continuation_token=cont_token, + client=self._client, + deserialization_callback=get_long_running_output, + ) + return LROPoller(self._client, raw_result, get_long_running_output, polling_method) + + begin_create_or_update.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Solutions/applicationDefinitions/{applicationDefinitionName}"} # type: ignore + + @distributed_trace + def list_by_resource_group( + self, resource_group_name: str, **kwargs: Any + ) -> Iterable["_models.ApplicationDefinition"]: + """Lists the managed application definitions in a resource group. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: An iterator like instance of either ApplicationDefinition or the result of + cls(response) + :rtype: + ~azure.core.paging.ItemPaged[~azure.mgmt.resource.managedapplications.v2018_06_01.models.ApplicationDefinition] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2018-06-01")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[_models.ApplicationDefinitionListResult] + + error_map = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + def prepare_request(next_link=None): + if not next_link: + + request = build_application_definitions_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 = urlparse(next_link) + _next_request_params = case_insensitive_dict(parse_qs(_parsed_next_link.query)) + _next_request_params["api-version"] = self._config.api_version + request = HttpRequest("GET", 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.method = "GET" + return request + + def extract_data(pipeline_response): + deserialized = self._deserialize("ApplicationDefinitionListResult", pipeline_response) + list_of_elem = deserialized.value + if cls: + list_of_elem = cls(list_of_elem) + 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 + ) + 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.ErrorResponse, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + return pipeline_response + + return ItemPaged(get_next, extract_data) + + list_by_resource_group.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Solutions/applicationDefinitions"} # type: ignore + + @distributed_trace + def get_by_id( + self, resource_group_name: str, application_definition_name: str, **kwargs: Any + ) -> Optional[_models.ApplicationDefinition]: + """Gets the managed application definition. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param application_definition_name: The name of the managed application definition. Required. + :type application_definition_name: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: ApplicationDefinition or None or the result of cls(response) + :rtype: ~azure.mgmt.resource.managedapplications.v2018_06_01.models.ApplicationDefinition or + None + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2018-06-01")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[Optional[_models.ApplicationDefinition]] + + request = build_application_definitions_get_by_id_request( + resource_group_name=resource_group_name, + application_definition_name=application_definition_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + template_url=self.get_by_id.metadata["url"], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore + + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [200, 404]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + deserialized = None + if response.status_code == 200: + deserialized = self._deserialize("ApplicationDefinition", pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + + get_by_id.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Solutions/applicationDefinitions/{applicationDefinitionName}"} # type: ignore + + def _delete_by_id_initial( # pylint: disable=inconsistent-return-statements + self, resource_group_name: str, application_definition_name: str, **kwargs: Any + ) -> None: + error_map = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2018-06-01")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[None] + + request = build_application_definitions_delete_by_id_request( + resource_group_name=resource_group_name, + application_definition_name=application_definition_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + template_url=self._delete_by_id_initial.metadata["url"], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore + + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [200, 202, 204]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + if cls: + return cls(pipeline_response, None, {}) + + _delete_by_id_initial.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Solutions/applicationDefinitions/{applicationDefinitionName}"} # type: ignore + + @distributed_trace + def begin_delete_by_id( + self, resource_group_name: str, application_definition_name: str, **kwargs: Any + ) -> LROPoller[None]: + """Deletes the managed application definition. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param application_definition_name: The name of the managed application definition. Required. + :type application_definition_name: str + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be ARMPolling. Pass in False for this + operation to not poll, or pass in your own initialized polling object for a personal polling + strategy. + :paramtype polling: bool or ~azure.core.polling.PollingMethod + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of LROPoller that returns either None or the result of cls(response) + :rtype: ~azure.core.polling.LROPoller[None] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2018-06-01")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[None] + polling = kwargs.pop("polling", True) # type: Union[bool, PollingMethod] + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token = kwargs.pop("continuation_token", None) # type: Optional[str] + if cont_token is None: + raw_result = self._delete_by_id_initial( # type: ignore + resource_group_name=resource_group_name, + application_definition_name=application_definition_name, + api_version=api_version, + cls=lambda x, y, z: x, + headers=_headers, + params=_params, + **kwargs + ) + kwargs.pop("error_map", None) + + def get_long_running_output(pipeline_response): # pylint: disable=inconsistent-return-statements + if cls: + return cls(pipeline_response, None, {}) + + if polling is True: + polling_method = cast(PollingMethod, ARMPolling(lro_delay, **kwargs)) # type: PollingMethod + elif polling is False: + polling_method = cast(PollingMethod, NoPolling()) + else: + polling_method = polling + if cont_token: + return LROPoller.from_continuation_token( + polling_method=polling_method, + continuation_token=cont_token, + client=self._client, + deserialization_callback=get_long_running_output, + ) + return LROPoller(self._client, raw_result, get_long_running_output, polling_method) + + begin_delete_by_id.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Solutions/applicationDefinitions/{applicationDefinitionName}"} # type: ignore + + def _create_or_update_by_id_initial( + self, + resource_group_name: str, + application_definition_name: str, + parameters: Union[_models.ApplicationDefinition, IO], + **kwargs: Any + ) -> _models.ApplicationDefinition: + error_map = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2018-06-01")) # type: str + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.ApplicationDefinition] + + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(parameters, (IO, bytes)): + _content = parameters + else: + _json = self._serialize.body(parameters, "ApplicationDefinition") + + request = build_application_definitions_create_or_update_by_id_request( + resource_group_name=resource_group_name, + application_definition_name=application_definition_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + content_type=content_type, + json=_json, + content=_content, + template_url=self._create_or_update_by_id_initial.metadata["url"], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore + + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [200, 201]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + if response.status_code == 200: + deserialized = self._deserialize("ApplicationDefinition", pipeline_response) + + if response.status_code == 201: + deserialized = self._deserialize("ApplicationDefinition", pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + + _create_or_update_by_id_initial.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Solutions/applicationDefinitions/{applicationDefinitionName}"} # type: ignore + + @overload + def begin_create_or_update_by_id( + self, + resource_group_name: str, + application_definition_name: str, + parameters: _models.ApplicationDefinition, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> LROPoller[_models.ApplicationDefinition]: + """Creates a new managed application definition. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param application_definition_name: The name of the managed application definition. Required. + :type application_definition_name: str + :param parameters: Parameters supplied to the create or update a managed application + definition. Required. + :type parameters: + ~azure.mgmt.resource.managedapplications.v2018_06_01.models.ApplicationDefinition + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be ARMPolling. Pass in False for this + operation to not poll, or pass in your own initialized polling object for a personal polling + strategy. + :paramtype polling: bool or ~azure.core.polling.PollingMethod + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of LROPoller that returns either ApplicationDefinition or the result of + cls(response) + :rtype: + ~azure.core.polling.LROPoller[~azure.mgmt.resource.managedapplications.v2018_06_01.models.ApplicationDefinition] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + def begin_create_or_update_by_id( + self, + resource_group_name: str, + application_definition_name: str, + parameters: IO, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> LROPoller[_models.ApplicationDefinition]: + """Creates a new managed application definition. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param application_definition_name: The name of the managed application definition. Required. + :type application_definition_name: str + :param parameters: Parameters supplied to the create or update a managed application + definition. Required. + :type parameters: IO + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be ARMPolling. Pass in False for this + operation to not poll, or pass in your own initialized polling object for a personal polling + strategy. + :paramtype polling: bool or ~azure.core.polling.PollingMethod + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of LROPoller that returns either ApplicationDefinition or the result of + cls(response) + :rtype: + ~azure.core.polling.LROPoller[~azure.mgmt.resource.managedapplications.v2018_06_01.models.ApplicationDefinition] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace + def begin_create_or_update_by_id( + self, + resource_group_name: str, + application_definition_name: str, + parameters: Union[_models.ApplicationDefinition, IO], + **kwargs: Any + ) -> LROPoller[_models.ApplicationDefinition]: + """Creates a new managed application definition. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param application_definition_name: The name of the managed application definition. Required. + :type application_definition_name: str + :param parameters: Parameters supplied to the create or update a managed application + definition. Is either a model type or a IO type. Required. + :type parameters: + ~azure.mgmt.resource.managedapplications.v2018_06_01.models.ApplicationDefinition or IO + :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. + Default value is None. + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be ARMPolling. Pass in False for this + operation to not poll, or pass in your own initialized polling object for a personal polling + strategy. + :paramtype polling: bool or ~azure.core.polling.PollingMethod + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of LROPoller that returns either ApplicationDefinition or the result of + cls(response) + :rtype: + ~azure.core.polling.LROPoller[~azure.mgmt.resource.managedapplications.v2018_06_01.models.ApplicationDefinition] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _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", "2018-06-01")) # type: str + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.ApplicationDefinition] + polling = kwargs.pop("polling", True) # type: Union[bool, PollingMethod] + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token = kwargs.pop("continuation_token", None) # type: Optional[str] + if cont_token is None: + raw_result = self._create_or_update_by_id_initial( # type: ignore + resource_group_name=resource_group_name, + application_definition_name=application_definition_name, + parameters=parameters, + api_version=api_version, + content_type=content_type, + cls=lambda x, y, z: x, + headers=_headers, + params=_params, + **kwargs + ) + kwargs.pop("error_map", None) + + def get_long_running_output(pipeline_response): + deserialized = self._deserialize("ApplicationDefinition", pipeline_response) + if cls: + return cls(pipeline_response, deserialized, {}) + return deserialized + + if polling is True: + polling_method = cast(PollingMethod, ARMPolling(lro_delay, **kwargs)) # type: PollingMethod + elif polling is False: + polling_method = cast(PollingMethod, NoPolling()) + else: + polling_method = polling + if cont_token: + return LROPoller.from_continuation_token( + polling_method=polling_method, + continuation_token=cont_token, + client=self._client, + deserialization_callback=get_long_running_output, + ) + return LROPoller(self._client, raw_result, get_long_running_output, polling_method) + + begin_create_or_update_by_id.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Solutions/applicationDefinitions/{applicationDefinitionName}"} # type: ignore diff --git a/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/managedapplications/v2018_06_01/operations/_patch.py b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/managedapplications/v2018_06_01/operations/_patch.py new file mode 100644 index 0000000000000..f7dd32510333d --- /dev/null +++ b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/managedapplications/v2018_06_01/operations/_patch.py @@ -0,0 +1,20 @@ +# ------------------------------------ +# Copyright (c) Microsoft Corporation. +# Licensed under the MIT License. +# ------------------------------------ +"""Customize generated code here. + +Follow our quickstart for examples: https://aka.ms/azsdk/python/dpcodegen/python/customize +""" +from typing import List + +__all__: List[str] = [] # Add all objects you want publicly available to users at this package level + + +def patch_sdk(): + """Do not remove from this file. + + `patch_sdk` is a last resort escape hatch that allows you to do customizations + you can't accomplish using the techniques described in + https://aka.ms/azsdk/python/dpcodegen/python/customize + """ diff --git a/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/managedapplications/v2018_06_01/py.typed b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/managedapplications/v2018_06_01/py.typed new file mode 100644 index 0000000000000..e5aff4f83af86 --- /dev/null +++ b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/managedapplications/v2018_06_01/py.typed @@ -0,0 +1 @@ +# Marker file for PEP 561. \ No newline at end of file diff --git a/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/policy/__init__.py b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/policy/__init__.py index ce44eb7e8b4e2..30a146f473fb8 100644 --- a/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/policy/__init__.py +++ b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/policy/__init__.py @@ -14,3 +14,7 @@ patch_sdk() except ImportError: pass + +from ._version import VERSION + +__version__ = VERSION diff --git a/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/policy/_configuration.py b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/policy/_configuration.py index a042a5e21fb67..a06a8859c8e22 100644 --- a/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/policy/_configuration.py +++ b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/policy/_configuration.py @@ -8,7 +8,7 @@ # Changes may cause incorrect behavior and will be lost if the code is # regenerated. # -------------------------------------------------------------------------- -from typing import TYPE_CHECKING +from typing import Any, TYPE_CHECKING from azure.core.configuration import Configuration from azure.core.pipeline import policies @@ -18,8 +18,6 @@ if TYPE_CHECKING: # pylint: disable=unused-import,ungrouped-imports - from typing import Any - from azure.core.credentials import TokenCredential class PolicyClientConfiguration(Configuration): @@ -28,16 +26,16 @@ class PolicyClientConfiguration(Configuration): Note that all parameters used to create this instance are saved as instance attributes. - :param credential: Credential needed for the client to connect to Azure. + :param credential: Credential needed for the client to connect to Azure. Required. :type credential: ~azure.core.credentials.TokenCredential - :param subscription_id: The ID of the target subscription. + :param subscription_id: The ID of the target subscription. Required. :type subscription_id: str """ def __init__( self, - credential, # type: "TokenCredential" - subscription_id, # type: str + credential: "TokenCredential", + subscription_id: str, **kwargs # type: Any ): # type: (...) -> None diff --git a/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/policy/_policy_client.py b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/policy/_policy_client.py index 7114cb1c8e9b0..12014107f7a4e 100644 --- a/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/policy/_policy_client.py +++ b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/policy/_policy_client.py @@ -9,20 +9,17 @@ # regenerated. # -------------------------------------------------------------------------- -from typing import TYPE_CHECKING - -from msrest import Deserializer, Serializer +from typing import Any, Optional, TYPE_CHECKING from azure.mgmt.core import ARMPipelineClient from azure.profiles import KnownProfiles, ProfileDefinition from azure.profiles.multiapiclient import MultiApiClientMixin from ._configuration import PolicyClientConfiguration +from ._serialization import Deserializer, Serializer if TYPE_CHECKING: # pylint: disable=unused-import,ungrouped-imports - from typing import Any, Optional - from azure.core.credentials import TokenCredential class _SDKClient(object): @@ -43,9 +40,9 @@ class PolicyClient(MultiApiClientMixin, _SDKClient): The api-version parameter sets the default API version if the operation group is not described in the profile. - :param credential: Credential needed for the client to connect to Azure. + :param credential: Credential needed for the client to connect to Azure. Required. :type credential: ~azure.core.credentials.TokenCredential - :param subscription_id: The ID of the target subscription. + :param subscription_id: The ID of the target subscription. Required. :type subscription_id: str :param api_version: API version to use if no profile is provided, or if missing in profile. :type api_version: str @@ -66,10 +63,10 @@ class PolicyClient(MultiApiClientMixin, _SDKClient): def __init__( self, - credential, # type: "TokenCredential" - subscription_id, # type: str + credential: "TokenCredential", + subscription_id: str, api_version=None, # type: Optional[str] - base_url="https://management.azure.com", # type: str + base_url: str = "https://management.azure.com", profile=KnownProfiles.default, # type: KnownProfiles **kwargs # type: Any ): @@ -287,6 +284,32 @@ def policy_set_definitions(self): raise ValueError("API version {} does not have operation group 'policy_set_definitions'".format(api_version)) return OperationClass(self._client, self._config, Serializer(self._models_dict(api_version)), Deserializer(self._models_dict(api_version))) + @property + def variable_values(self): + """Instance depends on the API version: + + * 2021-06-01: :class:`VariableValuesOperations` + """ + api_version = self._get_api_version('variable_values') + if api_version == '2021-06-01': + from .v2021_06_01.operations import VariableValuesOperations as OperationClass + else: + raise ValueError("API version {} does not have operation group 'variable_values'".format(api_version)) + return OperationClass(self._client, self._config, Serializer(self._models_dict(api_version)), Deserializer(self._models_dict(api_version))) + + @property + def variables(self): + """Instance depends on the API version: + + * 2021-06-01: :class:`VariablesOperations` + """ + api_version = self._get_api_version('variables') + if api_version == '2021-06-01': + from .v2021_06_01.operations import VariablesOperations as OperationClass + else: + raise ValueError("API version {} does not have operation group 'variables'".format(api_version)) + return OperationClass(self._client, self._config, Serializer(self._models_dict(api_version)), Deserializer(self._models_dict(api_version))) + def close(self): self._client.close() def __enter__(self): diff --git a/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/policy/_serialization.py b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/policy/_serialization.py new file mode 100644 index 0000000000000..240df16c57f3c --- /dev/null +++ b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/policy/_serialization.py @@ -0,0 +1,2006 @@ +# -------------------------------------------------------------------------- +# +# Copyright (c) Microsoft Corporation. All rights reserved. +# +# The MIT License (MIT) +# +# Permission is hereby granted, free of charge, to any person obtaining a copy +# of this software and associated documentation files (the ""Software""), to +# deal in the Software without restriction, including without limitation the +# rights to use, copy, modify, merge, publish, distribute, sublicense, and/or +# sell copies of the Software, and to permit persons to whom the Software is +# furnished to do so, subject to the following conditions: +# +# The above copyright notice and this permission notice shall be included in +# all copies or substantial portions of the Software. +# +# THE SOFTWARE IS PROVIDED *AS IS*, WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING +# FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS +# IN THE SOFTWARE. +# +# -------------------------------------------------------------------------- + +# pylint: skip-file + +from base64 import b64decode, b64encode +import calendar +import datetime +import decimal +import email +from enum import Enum +import json +import logging +import re +import sys +import codecs +try: + from urllib import quote # type: ignore +except ImportError: + from urllib.parse import quote # type: ignore +import xml.etree.ElementTree as ET + +import isodate + +from typing import Dict, Any, cast, TYPE_CHECKING + +from azure.core.exceptions import DeserializationError, SerializationError, raise_with_traceback + +_BOM = codecs.BOM_UTF8.decode(encoding='utf-8') + +if TYPE_CHECKING: + from typing import Optional, Union, AnyStr, IO, Mapping + +class RawDeserializer: + + # Accept "text" because we're open minded people... + JSON_REGEXP = re.compile(r'^(application|text)/([a-z+.]+\+)?json$') + + # Name used in context + CONTEXT_NAME = "deserialized_data" + + @classmethod + def deserialize_from_text(cls, data, content_type=None): + # type: (Optional[Union[AnyStr, IO]], Optional[str]) -> Any + """Decode data according to content-type. + + Accept a stream of data as well, but will be load at once in memory for now. + + If no content-type, will return the string version (not bytes, not stream) + + :param data: Input, could be bytes or stream (will be decoded with UTF8) or text + :type data: str or bytes or IO + :param str content_type: The content type. + """ + if hasattr(data, 'read'): + # Assume a stream + data = cast(IO, data).read() + + if isinstance(data, bytes): + data_as_str = data.decode(encoding='utf-8-sig') + else: + # Explain to mypy the correct type. + data_as_str = cast(str, data) + + # Remove Byte Order Mark if present in string + data_as_str = data_as_str.lstrip(_BOM) + + if content_type is None: + return data + + if cls.JSON_REGEXP.match(content_type): + try: + return json.loads(data_as_str) + except ValueError as err: + raise DeserializationError("JSON is invalid: {}".format(err), err) + elif "xml" in (content_type or []): + try: + + try: + if isinstance(data, unicode): # type: ignore + # If I'm Python 2.7 and unicode XML will scream if I try a "fromstring" on unicode string + data_as_str = data_as_str.encode(encoding="utf-8") # type: ignore + except NameError: + pass + + return ET.fromstring(data_as_str) # nosec + except ET.ParseError: + # It might be because the server has an issue, and returned JSON with + # content-type XML.... + # So let's try a JSON load, and if it's still broken + # let's flow the initial exception + def _json_attemp(data): + try: + return True, json.loads(data) + except ValueError: + return False, None # Don't care about this one + success, json_result = _json_attemp(data) + if success: + return json_result + # If i'm here, it's not JSON, it's not XML, let's scream + # and raise the last context in this block (the XML exception) + # The function hack is because Py2.7 messes up with exception + # context otherwise. + _LOGGER.critical("Wasn't XML not JSON, failing") + raise_with_traceback(DeserializationError, "XML is invalid") + 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 + """Deserialize from HTTP response. + + Use bytes and headers to NOT use any requests/aiohttp or whatever + specific implementation. + Headers will tested for "content-type" + """ + # Try to use content-type from headers if available + content_type = None + if 'content-type' in headers: + content_type = headers['content-type'].split(";")[0].strip().lower() + # Ouch, this server did not declare what it sent... + # Let's guess it's JSON... + # Also, since Autorest was considering that an empty body was a valid JSON, + # need that test as well.... + else: + content_type = "application/json" + + if body_bytes: + return cls.deserialize_from_text(body_bytes, content_type) + return None + +try: + basestring # type: ignore + unicode_str = unicode # type: ignore +except NameError: + basestring = str # type: ignore + unicode_str = str # type: ignore + +_LOGGER = logging.getLogger(__name__) + +try: + _long_type = long # type: ignore +except NameError: + _long_type = int + +class UTC(datetime.tzinfo): + """Time Zone info for handling UTC""" + + def utcoffset(self, dt): + """UTF offset for UTC is 0.""" + return datetime.timedelta(0) + + def tzname(self, dt): + """Timestamp representation.""" + return "Z" + + def dst(self, dt): + """No daylight saving for UTC.""" + return datetime.timedelta(hours=1) + +try: + from datetime import timezone as _FixedOffset +except ImportError: # Python 2.7 + class _FixedOffset(datetime.tzinfo): # type: ignore + """Fixed offset in minutes east from UTC. + Copy/pasted from Python doc + :param datetime.timedelta offset: offset in timedelta format + """ + + def __init__(self, offset): + self.__offset = offset + + def utcoffset(self, dt): + return self.__offset + + def tzname(self, dt): + return str(self.__offset.total_seconds()/3600) + + def __repr__(self): + return "".format(self.tzname(None)) + + def dst(self, dt): + return datetime.timedelta(0) + + def __getinitargs__(self): + return (self.__offset,) + +try: + from datetime import timezone + TZ_UTC = timezone.utc # type: ignore +except ImportError: + TZ_UTC = UTC() # type: ignore + +_FLATTEN = re.compile(r"(? y, + "minimum": lambda x, y: x < y, + "maximum": lambda x, y: x > y, + "minimum_ex": lambda x, y: x <= y, + "maximum_ex": lambda x, y: x >= y, + "min_items": lambda x, y: len(x) < y, + "max_items": lambda x, y: len(x) > y, + "pattern": lambda x, y: not re.match(y, x, re.UNICODE), + "unique": lambda x, y: len(x) != len(set(x)), + "multiple": lambda x, y: x % y != 0 + } + + def __init__(self, classes=None): + self.serialize_type = { + 'iso-8601': Serializer.serialize_iso, + 'rfc-1123': Serializer.serialize_rfc, + 'unix-time': Serializer.serialize_unix, + 'duration': Serializer.serialize_duration, + 'date': Serializer.serialize_date, + 'time': Serializer.serialize_time, + 'decimal': Serializer.serialize_decimal, + 'long': Serializer.serialize_long, + 'bytearray': Serializer.serialize_bytearray, + 'base64': Serializer.serialize_base64, + 'object': self.serialize_object, + '[]': self.serialize_iter, + '{}': self.serialize_dict + } + self.dependencies = dict(classes) if classes else {} + self.key_transformer = full_restapi_key_transformer + self.client_side_validation = True + + def _serialize(self, target_obj, data_type=None, **kwargs): + """Serialize data into a string according to type. + + :param target_obj: The data to be serialized. + :param str data_type: The type to be serialized from. + :rtype: str, dict + :raises: SerializationError if serialization fails. + """ + key_transformer = kwargs.get("key_transformer", self.key_transformer) + keep_readonly = kwargs.get("keep_readonly", False) + if target_obj is None: + return None + + attr_name = None + class_name = target_obj.__class__.__name__ + + if data_type: + return self.serialize_data( + target_obj, data_type, **kwargs) + + if not hasattr(target_obj, "_attribute_map"): + data_type = type(target_obj).__name__ + if data_type in self.basic_types.values(): + return self.serialize_data( + target_obj, data_type, **kwargs) + + # Force "is_xml" kwargs if we detect a XML model + try: + is_xml_model_serialization = kwargs["is_xml"] + except KeyError: + is_xml_model_serialization = kwargs.setdefault("is_xml", target_obj.is_xml_model()) + + serialized = {} + if is_xml_model_serialization: + serialized = target_obj._create_xml_node() + try: + attributes = target_obj._attribute_map + for attr, attr_desc in attributes.items(): + attr_name = attr + if not keep_readonly and target_obj._validation.get(attr_name, {}).get('readonly', False): + continue + + if attr_name == "additional_properties" and attr_desc["key"] == '': + if target_obj.additional_properties is not None: + serialized.update(target_obj.additional_properties) + continue + try: + + orig_attr = getattr(target_obj, attr) + if is_xml_model_serialization: + pass # Don't provide "transformer" for XML for now. Keep "orig_attr" + else: # JSON + keys, orig_attr = key_transformer(attr, attr_desc.copy(), orig_attr) + keys = keys if isinstance(keys, list) else [keys] + + + kwargs["serialization_ctxt"] = attr_desc + new_attr = self.serialize_data(orig_attr, attr_desc['type'], **kwargs) + + + if is_xml_model_serialization: + xml_desc = attr_desc.get('xml', {}) + xml_name = xml_desc.get('name', attr_desc['key']) + xml_prefix = xml_desc.get('prefix', None) + xml_ns = xml_desc.get('ns', None) + 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) + continue + if xml_desc.get("text", False): + serialized.text = new_attr + continue + if isinstance(new_attr, list): + serialized.extend(new_attr) + 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', {}): + splitted_tag = new_attr.tag.split("}") + if len(splitted_tag) == 2: # Namespace + new_attr.tag = "}".join([splitted_tag[0], xml_name]) + else: + new_attr.tag = xml_name + serialized.append(new_attr) + 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) + else: # JSON + for k in reversed(keys): + unflattened = {k: new_attr} + new_attr = unflattened + + _new_attr = new_attr + _serialized = serialized + for k in keys: + if k not in _serialized: + _serialized.update(_new_attr) + _new_attr = _new_attr[k] + _serialized = _serialized[k] + except ValueError: + continue + + except (AttributeError, KeyError, TypeError) as err: + msg = "Attribute {} in object {} cannot be serialized.\n{}".format( + attr_name, class_name, str(target_obj)) + raise_with_traceback(SerializationError, msg, err) + else: + return serialized + + def body(self, data, data_type, **kwargs): + """Serialize data intended for a request body. + + :param data: The data to be serialized. + :param str data_type: The type to be serialized from. + :rtype: dict + :raises: SerializationError if serialization fails. + :raises: ValueError if data is None + """ + + # Just in case this is a dict + internal_data_type = data_type.strip('[]{}') + internal_data_type = self.dependencies.get(internal_data_type, None) + try: + is_xml_model_serialization = kwargs["is_xml"] + except KeyError: + if internal_data_type and issubclass(internal_data_type, Model): + is_xml_model_serialization = kwargs.setdefault("is_xml", internal_data_type.is_xml_model()) + else: + is_xml_model_serialization = False + if internal_data_type and not isinstance(internal_data_type, Enum): + try: + deserializer = Deserializer(self.dependencies) + # Since it's on serialization, it's almost sure that format is not JSON REST + # We're not able to deal with additional properties for now. + deserializer.additional_properties_detection = False + if is_xml_model_serialization: + deserializer.key_extractors = [ + attribute_key_case_insensitive_extractor, + ] + else: + deserializer.key_extractors = [ + rest_key_case_insensitive_extractor, + attribute_key_case_insensitive_extractor, + last_rest_key_case_insensitive_extractor + ] + data = deserializer._deserialize(data_type, data) + except DeserializationError as err: + raise_with_traceback( + SerializationError, "Unable to build a model: "+str(err), err) + + return self._serialize(data, data_type, **kwargs) + + def url(self, name, data, data_type, **kwargs): + """Serialize data intended for a URL path. + + :param data: The data to be serialized. + :param str data_type: The type to be serialized from. + :rtype: str + :raises: TypeError if serialization fails. + :raises: ValueError if data is None + """ + try: + output = self.serialize_data(data, data_type, **kwargs) + if data_type == 'bool': + output = json.dumps(output) + + if kwargs.get('skip_quote') is True: + output = str(output) + else: + output = quote(str(output), safe='') + except SerializationError: + raise TypeError("{} must be type {}.".format(name, data_type)) + else: + return output + + def query(self, name, data, data_type, **kwargs): + """Serialize data intended for a URL query. + + :param data: The data to be serialized. + :param str data_type: The type to be serialized from. + :rtype: str + :raises: TypeError if serialization fails. + :raises: ValueError if data is None + """ + try: + # 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)) + + # Not a list, regular serialization + output = self.serialize_data(data, data_type, **kwargs) + if data_type == 'bool': + output = json.dumps(output) + if kwargs.get('skip_quote') is True: + output = str(output) + else: + output = quote(str(output), safe='') + except SerializationError: + raise TypeError("{} must be type {}.".format(name, data_type)) + else: + return str(output) + + def header(self, name, data, data_type, **kwargs): + """Serialize data intended for a request header. + + :param data: The data to be serialized. + :param str data_type: The type to be serialized from. + :rtype: str + :raises: TypeError if serialization fails. + :raises: ValueError if data is None + """ + try: + if data_type in ['[str]']: + data = ["" if d is None else d for d in data] + + output = self.serialize_data(data, data_type, **kwargs) + if data_type == 'bool': + output = json.dumps(output) + except SerializationError: + raise TypeError("{} must be type {}.".format(name, data_type)) + else: + return str(output) + + def serialize_data(self, data, data_type, **kwargs): + """Serialize generic data according to supplied data type. + + :param data: The data to be serialized. + :param str data_type: The type to be serialized from. + :param bool required: Whether it's essential that the data not be + empty or None + :raises: AttributeError if required data is None. + :raises: ValueError if data is None + :raises: SerializationError if serialization fails. + """ + if data is None: + raise ValueError("No value for given attribute") + + try: + if data_type in self.basic_types.values(): + return self.serialize_basic(data, data_type, **kwargs) + + elif data_type in self.serialize_type: + return self.serialize_type[data_type](data, **kwargs) + + # If dependencies is empty, try with current data class + # It has to be a subclass of Enum anyway + enum_type = self.dependencies.get(data_type, data.__class__) + if issubclass(enum_type, Enum): + return Serializer.serialize_enum(data, enum_obj=enum_type) + + iter_type = data_type[0] + data_type[-1] + if iter_type in self.serialize_type: + return self.serialize_type[iter_type]( + data, data_type[1:-1], **kwargs) + + except (ValueError, TypeError) as err: + msg = "Unable to serialize value: {!r} as type: {!r}." + raise_with_traceback( + SerializationError, msg.format(data, data_type), err) + else: + return self._serialize(data, **kwargs) + + @classmethod + def _get_custom_serializers(cls, data_type, **kwargs): + custom_serializer = kwargs.get("basic_types_serializers", {}).get(data_type) + if custom_serializer: + return custom_serializer + if kwargs.get("is_xml", False): + return cls._xml_basic_types_serializers.get(data_type) + + @classmethod + def serialize_basic(cls, data, data_type, **kwargs): + """Serialize basic builting data type. + Serializes objects to str, int, float or bool. + + Possible kwargs: + - basic_types_serializers dict[str, callable] : If set, use the callable as serializer + - is_xml bool : If set, use xml_basic_types_serializers + + :param data: Object to be serialized. + :param str data_type: Type of object in the iterable. + """ + custom_serializer = cls._get_custom_serializers(data_type, **kwargs) + if custom_serializer: + return custom_serializer(data) + if data_type == 'str': + return cls.serialize_unicode(data) + return eval(data_type)(data) # nosec + + @classmethod + def serialize_unicode(cls, data): + """Special handling for serializing unicode strings in Py2. + Encode to UTF-8 if unicode, otherwise handle as a str. + + :param data: Object to be serialized. + :rtype: str + """ + try: # If I received an enum, return its value + return data.value + except AttributeError: + pass + + try: + if isinstance(data, unicode): + # Don't change it, JSON and XML ElementTree are totally able + # to serialize correctly u'' strings + return data + except NameError: + return str(data) + else: + return str(data) + + def serialize_iter(self, data, iter_type, div=None, **kwargs): + """Serialize iterable. + + Supported kwargs: + - serialization_ctxt dict : The current entry of _attribute_map, or same format. + serialization_ctxt['type'] should be same as data_type. + - is_xml bool : If set, serialize as XML + + :param list attr: Object to be serialized. + :param str iter_type: Type of object in the iterable. + :param bool required: Whether the objects in the iterable must + not be None or empty. + :param str div: If set, this str will be used to combine the elements + in the iterable into a combined string. Default is 'None'. + :rtype: list, str + """ + if isinstance(data, str): + raise SerializationError("Refuse str type as a valid iter type.") + + serialization_ctxt = kwargs.get("serialization_ctxt", {}) + is_xml = kwargs.get("is_xml", False) + + serialized = [] + for d in data: + try: + serialized.append(self.serialize_data(d, iter_type, **kwargs)) + except ValueError: + serialized.append(None) + + if div: + serialized = ['' if s is None else str(s) for s in serialized] + serialized = div.join(serialized) + + if 'xml' in serialization_ctxt or is_xml: + # XML serialization is more complicated + xml_desc = serialization_ctxt.get('xml', {}) + xml_name = xml_desc.get('name') + if not xml_name: + xml_name = serialization_ctxt['key'] + + # Create a wrap node if necessary (use the fact that Element and list have "append") + is_wrapped = xml_desc.get("wrapped", False) + node_name = xml_desc.get("itemsName", xml_name) + if is_wrapped: + final_result = _create_xml_node( + xml_name, + xml_desc.get('prefix', None), + xml_desc.get('ns', None) + ) + else: + final_result = [] + # All list elements to "local_node" + for el in serialized: + if isinstance(el, ET.Element): + el_node = el + else: + el_node = _create_xml_node( + node_name, + xml_desc.get('prefix', None), + xml_desc.get('ns', None) + ) + if el is not None: # Otherwise it writes "None" :-p + el_node.text = str(el) + final_result.append(el_node) + return final_result + return serialized + + def serialize_dict(self, attr, dict_type, **kwargs): + """Serialize a dictionary of objects. + + :param dict attr: Object to be serialized. + :param str dict_type: Type of object in the dictionary. + :param bool required: Whether the objects in the dictionary must + not be None or empty. + :rtype: dict + """ + serialization_ctxt = kwargs.get("serialization_ctxt", {}) + serialized = {} + for key, value in attr.items(): + try: + serialized[self.serialize_unicode(key)] = self.serialize_data( + value, dict_type, **kwargs) + except ValueError: + serialized[self.serialize_unicode(key)] = None + + if 'xml' in serialization_ctxt: + # XML serialization is more complicated + xml_desc = serialization_ctxt['xml'] + xml_name = xml_desc['name'] + + final_result = _create_xml_node( + xml_name, + xml_desc.get('prefix', None), + xml_desc.get('ns', None) + ) + for key, value in serialized.items(): + ET.SubElement(final_result, key).text = value + return final_result + + return serialized + + def serialize_object(self, attr, **kwargs): + """Serialize a generic object. + This will be handled as a dictionary. If object passed in is not + a basic type (str, int, float, dict, list) it will simply be + cast to str. + + :param dict attr: Object to be serialized. + :rtype: dict or str + """ + if attr is None: + return None + if isinstance(attr, ET.Element): + return attr + obj_type = type(attr) + if obj_type in self.basic_types: + return self.serialize_basic(attr, self.basic_types[obj_type], **kwargs) + if obj_type is _long_type: + return self.serialize_long(attr) + if obj_type is unicode_str: + return self.serialize_unicode(attr) + if obj_type is datetime.datetime: + return self.serialize_iso(attr) + if obj_type is datetime.date: + return self.serialize_date(attr) + if obj_type is datetime.time: + return self.serialize_time(attr) + if obj_type is datetime.timedelta: + return self.serialize_duration(attr) + if obj_type is decimal.Decimal: + return self.serialize_decimal(attr) + + # If it's a model or I know this dependency, serialize as a Model + elif obj_type in self.dependencies.values() or isinstance(attr, Model): + return self._serialize(attr) + + if obj_type == dict: + serialized = {} + for key, value in attr.items(): + try: + serialized[self.serialize_unicode(key)] = self.serialize_object( + value, **kwargs) + except ValueError: + serialized[self.serialize_unicode(key)] = None + return serialized + + if obj_type == list: + serialized = [] + for obj in attr: + try: + serialized.append(self.serialize_object( + obj, **kwargs)) + except ValueError: + pass + return serialized + return str(attr) + + @staticmethod + def serialize_enum(attr, enum_obj=None): + try: + result = attr.value + except AttributeError: + result = attr + try: + enum_obj(result) + return result + except ValueError: + for enum_value in enum_obj: + if enum_value.value.lower() == str(attr).lower(): + return enum_value.value + error = "{!r} is not valid value for enum {!r}" + raise SerializationError(error.format(attr, enum_obj)) + + @staticmethod + def serialize_bytearray(attr, **kwargs): + """Serialize bytearray into base-64 string. + + :param attr: Object to be serialized. + :rtype: str + """ + return b64encode(attr).decode() + + @staticmethod + def serialize_base64(attr, **kwargs): + """Serialize str into base-64 string. + + :param attr: Object to be serialized. + :rtype: str + """ + encoded = b64encode(attr).decode('ascii') + return encoded.strip('=').replace('+', '-').replace('/', '_') + + @staticmethod + def serialize_decimal(attr, **kwargs): + """Serialize Decimal object to float. + + :param attr: Object to be serialized. + :rtype: float + """ + return float(attr) + + @staticmethod + def serialize_long(attr, **kwargs): + """Serialize long (Py2) or int (Py3). + + :param attr: Object to be serialized. + :rtype: int/long + """ + return _long_type(attr) + + @staticmethod + def serialize_date(attr, **kwargs): + """Serialize Date object into ISO-8601 formatted string. + + :param Date attr: Object to be serialized. + :rtype: str + """ + if isinstance(attr, str): + attr = isodate.parse_date(attr) + t = "{:04}-{:02}-{:02}".format(attr.year, attr.month, attr.day) + return t + + @staticmethod + def serialize_time(attr, **kwargs): + """Serialize Time object into ISO-8601 formatted string. + + :param datetime.time attr: Object to be serialized. + :rtype: str + """ + if isinstance(attr, str): + attr = isodate.parse_time(attr) + t = "{:02}:{:02}:{:02}".format(attr.hour, attr.minute, attr.second) + if attr.microsecond: + t += ".{:02}".format(attr.microsecond) + return t + + @staticmethod + def serialize_duration(attr, **kwargs): + """Serialize TimeDelta object into ISO-8601 formatted string. + + :param TimeDelta attr: Object to be serialized. + :rtype: str + """ + if isinstance(attr, str): + attr = isodate.parse_duration(attr) + return isodate.duration_isoformat(attr) + + @staticmethod + def serialize_rfc(attr, **kwargs): + """Serialize Datetime object into RFC-1123 formatted string. + + :param Datetime attr: Object to be serialized. + :rtype: str + :raises: TypeError if format invalid. + """ + try: + if not attr.tzinfo: + _LOGGER.warning( + "Datetime with no tzinfo will be considered UTC.") + utc = attr.utctimetuple() + except AttributeError: + raise TypeError("RFC1123 object must be valid Datetime object.") + + return "{}, {:02} {} {:04} {:02}:{:02}:{:02} GMT".format( + Serializer.days[utc.tm_wday], utc.tm_mday, + Serializer.months[utc.tm_mon], utc.tm_year, + utc.tm_hour, utc.tm_min, utc.tm_sec) + + @staticmethod + def serialize_iso(attr, **kwargs): + """Serialize Datetime object into ISO-8601 formatted string. + + :param Datetime attr: Object to be serialized. + :rtype: str + :raises: SerializationError if format invalid. + """ + if isinstance(attr, str): + attr = isodate.parse_datetime(attr) + try: + if not attr.tzinfo: + _LOGGER.warning( + "Datetime with no tzinfo will be considered UTC.") + utc = attr.utctimetuple() + if utc.tm_year > 9999 or utc.tm_year < 1: + raise OverflowError("Hit max or min date") + + microseconds = str(attr.microsecond).rjust(6,'0').rstrip('0').ljust(3, '0') + if microseconds: + microseconds = '.'+microseconds + date = "{:04}-{:02}-{:02}T{:02}:{:02}:{:02}".format( + utc.tm_year, utc.tm_mon, utc.tm_mday, + utc.tm_hour, utc.tm_min, utc.tm_sec) + return date + microseconds + 'Z' + except (ValueError, OverflowError) as err: + msg = "Unable to serialize datetime object." + raise_with_traceback(SerializationError, msg, err) + except AttributeError as err: + msg = "ISO-8601 object must be valid Datetime object." + raise_with_traceback(TypeError, msg, err) + + @staticmethod + def serialize_unix(attr, **kwargs): + """Serialize Datetime object into IntTime format. + This is represented as seconds. + + :param Datetime attr: Object to be serialized. + :rtype: int + :raises: SerializationError if format invalid + """ + if isinstance(attr, int): + return attr + try: + if not attr.tzinfo: + _LOGGER.warning( + "Datetime with no tzinfo will be considered UTC.") + return int(calendar.timegm(attr.utctimetuple())) + except AttributeError: + raise TypeError("Unix time object must be valid Datetime object.") + +def rest_key_extractor(attr, attr_desc, data): + key = attr_desc['key'] + working_data = data + + while '.' in key: + dict_keys = _FLATTEN.split(key) + if len(dict_keys) == 1: + key = _decode_attribute_map_key(dict_keys[0]) + break + working_key = _decode_attribute_map_key(dict_keys[0]) + working_data = working_data.get(working_key, data) + if working_data is None: + # If at any point while following flatten JSON path see None, it means + # that all properties under are None as well + # https://github.com/Azure/msrest-for-python/issues/197 + return None + key = '.'.join(dict_keys[1:]) + + return working_data.get(key) + +def rest_key_case_insensitive_extractor(attr, attr_desc, data): + key = attr_desc['key'] + working_data = data + + while '.' in key: + dict_keys = _FLATTEN.split(key) + if len(dict_keys) == 1: + key = _decode_attribute_map_key(dict_keys[0]) + break + working_key = _decode_attribute_map_key(dict_keys[0]) + working_data = attribute_key_case_insensitive_extractor(working_key, None, working_data) + if working_data is None: + # If at any point while following flatten JSON path see None, it means + # that all properties under are None as well + # https://github.com/Azure/msrest-for-python/issues/197 + return None + key = '.'.join(dict_keys[1:]) + + if working_data: + return attribute_key_case_insensitive_extractor(key, None, working_data) + +def last_rest_key_extractor(attr, attr_desc, data): + """Extract the attribute in "data" based on the last part of the JSON path key. + """ + key = attr_desc['key'] + dict_keys = _FLATTEN.split(key) + return attribute_key_extractor(dict_keys[-1], None, data) + +def last_rest_key_case_insensitive_extractor(attr, attr_desc, data): + """Extract the attribute in "data" based on the last part of the JSON path key. + + This is the case insensitive version of "last_rest_key_extractor" + """ + key = attr_desc['key'] + dict_keys = _FLATTEN.split(key) + return attribute_key_case_insensitive_extractor(dict_keys[-1], None, data) + +def attribute_key_extractor(attr, _, data): + return data.get(attr) + +def attribute_key_case_insensitive_extractor(attr, _, data): + found_key = None + lower_attr = attr.lower() + for key in data: + if lower_attr == key.lower(): + found_key = key + break + + return data.get(found_key) + +def _extract_name_from_internal_type(internal_type): + """Given an internal type XML description, extract correct XML name with namespace. + + :param dict internal_type: An model type + :rtype: tuple + :returns: A tuple XML name + namespace dict + """ + internal_type_xml_map = getattr(internal_type, "_xml_map", {}) + 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) + return xml_name + + +def xml_key_extractor(attr, attr_desc, data): + if isinstance(data, dict): + return None + + # Test if this model is XML ready first + if not isinstance(data, ET.Element): + return None + + xml_desc = attr_desc.get('xml', {}) + xml_name = xml_desc.get('name', attr_desc['key']) + + # Look for a children + is_iter_type = attr_desc['type'].startswith("[") + is_wrapped = xml_desc.get("wrapped", False) + internal_type = attr_desc.get("internalType", None) + internal_type_xml_map = getattr(internal_type, "_xml_map", {}) + + # 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) + + # If it's an attribute, that's simple + if xml_desc.get("attr", False): + return data.get(xml_name) + + # If it's x-ms-text, that's simple too + if xml_desc.get("text", False): + return data.text + + # Scenario where I take the local name: + # - Wrapped node + # - Internal type is an enum (considered basic types) + # - Internal type has no XML/Name node + if is_wrapped or (internal_type and (issubclass(internal_type, Enum) or 'name' not in internal_type_xml_map)): + children = data.findall(xml_name) + # If internal type has a local name and it's not a list, I use that name + elif not is_iter_type and internal_type and 'name' in internal_type_xml_map: + xml_name = _extract_name_from_internal_type(internal_type) + children = data.findall(xml_name) + # That's an array + else: + if internal_type: # Complex type, ignore itemsName and use the complex type name + items_name = _extract_name_from_internal_type(internal_type) + else: + items_name = xml_desc.get("itemsName", xml_name) + children = data.findall(items_name) + + if len(children) == 0: + if is_iter_type: + if is_wrapped: + return None # is_wrapped no node, we want None + else: + return [] # not wrapped, assume empty list + return None # Assume it's not there, maybe an optional node. + + # If is_iter_type and not wrapped, return all found children + if is_iter_type: + if not is_wrapped: + return children + else: # Iter and wrapped, should have found one node only (the wrap one) + if len(children) != 1: + raise DeserializationError( + "Tried to deserialize an array not wrapped, and found several nodes '{}'. Maybe you should declare this array as wrapped?".format( + xml_name + )) + return list(children[0]) # Might be empty list and that's ok. + + # Here it's not a itertype, we should have found one element only or empty + if len(children) > 1: + raise DeserializationError("Find several XML '{}' where it was not expected".format(xml_name)) + return children[0] + +class Deserializer(object): + """Response object model deserializer. + + :param dict classes: Class type dictionary for deserializing complex types. + :ivar list key_extractors: Ordered list of extractors to be used by this deserializer. + """ + + basic_types = {str: 'str', int: 'int', bool: 'bool', float: 'float'} + + valid_date = re.compile( + r'\d{4}[-]\d{2}[-]\d{2}T\d{2}:\d{2}:\d{2}' + r'\.?\d*Z?[-+]?[\d{2}]?:?[\d{2}]?') + + def __init__(self, classes=None): + self.deserialize_type = { + 'iso-8601': Deserializer.deserialize_iso, + 'rfc-1123': Deserializer.deserialize_rfc, + 'unix-time': Deserializer.deserialize_unix, + 'duration': Deserializer.deserialize_duration, + 'date': Deserializer.deserialize_date, + 'time': Deserializer.deserialize_time, + 'decimal': Deserializer.deserialize_decimal, + 'long': Deserializer.deserialize_long, + 'bytearray': Deserializer.deserialize_bytearray, + 'base64': Deserializer.deserialize_base64, + 'object': self.deserialize_object, + '[]': self.deserialize_iter, + '{}': self.deserialize_dict + } + self.deserialize_expected_types = { + 'duration': (isodate.Duration, datetime.timedelta), + 'iso-8601': (datetime.datetime) + } + self.dependencies = 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 + # complicated, with no real scenario for now. + # So adding a flag to disable additional properties detection. This flag should be + # used if your expect the deserialization to NOT come from a JSON REST syntax. + # Otherwise, result are unexpected + self.additional_properties_detection = True + + def __call__(self, target_obj, response_data, content_type=None): + """Call the deserializer to process a REST response. + + :param str target_obj: Target data type to deserialize to. + :param requests.Response response_data: REST response object. + :param str content_type: Swagger "produces" if available. + :raises: DeserializationError if deserialization fails. + :return: Deserialized object. + """ + data = self._unpack_content(response_data, content_type) + return self._deserialize(target_obj, data) + + def _deserialize(self, target_obj, data): + """Call the deserializer on a model. + + Data needs to be already deserialized as JSON or XML ElementTree + + :param str target_obj: Target data type to deserialize to. + :param object data: Object to deserialize. + :raises: DeserializationError if deserialization fails. + :return: Deserialized object. + """ + # This is already a model, go recursive just in case + if hasattr(data, "_attribute_map"): + constants = [name for name, config in getattr(data, '_validation', {}).items() + if config.get('constant')] + try: + for attr, mapconfig in data._attribute_map.items(): + if attr in constants: + continue + value = getattr(data, attr) + if value is None: + continue + local_type = mapconfig['type'] + internal_data_type = local_type.strip('[]{}') + if internal_data_type not in self.dependencies or isinstance(internal_data_type, Enum): + continue + setattr( + data, + attr, + self._deserialize(local_type, value) + ) + return data + except AttributeError: + return + + response, class_name = self._classify_target(target_obj, data) + + if isinstance(response, basestring): + return self.deserialize_data(data, response) + elif isinstance(response, type) and issubclass(response, Enum): + return self.deserialize_enum(data, response) + + if data is None: + return data + try: + attributes = response._attribute_map + d_attrs = {} + for attr, attr_desc in attributes.items(): + # Check empty string. If it's not empty, someone has a real "additionalProperties"... + if attr == "additional_properties" and attr_desc["key"] == '': + continue + raw_value = None + # Enhance attr_desc with some dynamic data + attr_desc = attr_desc.copy() # Do a copy, do not change the real one + internal_data_type = attr_desc["type"].strip('[]{}') + if internal_data_type in self.dependencies: + attr_desc["internalType"] = self.dependencies[internal_data_type] + + for key_extractor in self.key_extractors: + found_value = key_extractor(attr, attr_desc, data) + if found_value is not None: + if raw_value is not None and raw_value != found_value: + msg = ("Ignoring extracted value '%s' from %s for key '%s'" + " (duplicate extraction, follow extractors order)" ) + _LOGGER.warning( + msg, + found_value, + key_extractor, + attr + ) + continue + raw_value = found_value + + 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 + raise_with_traceback(DeserializationError, msg, err) + else: + additional_properties = self._build_additional_properties(attributes, data) + return self._instantiate_model(response, d_attrs, additional_properties) + + def _build_additional_properties(self, attribute_map, data): + if not self.additional_properties_detection: + return None + if "additional_properties" in attribute_map and attribute_map.get("additional_properties", {}).get("key") != '': + # Check empty string. If it's not empty, someone has a real "additionalProperties" + return None + if isinstance(data, ET.Element): + data = {el.tag: el.text for el in data} + + known_keys = {_decode_attribute_map_key(_FLATTEN.split(desc['key'])[0]) + for desc in attribute_map.values() if desc['key'] != ''} + present_keys = set(data.keys()) + missing_keys = present_keys - known_keys + return {key: data[key] for key in missing_keys} + + def _classify_target(self, target, data): + """Check to see whether the deserialization target object can + be classified into a subclass. + 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. + """ + if target is None: + return None, None + + if isinstance(target, basestring): + try: + target = self.dependencies[target] + except KeyError: + return target, target + + try: + target = target._classify(data, self.dependencies) + except AttributeError: + pass # Target is not a Model, no classify + return target, target.__class__.__name__ + + def failsafe_deserialize(self, target_obj, data, content_type=None): + """Ignores any errors encountered in deserialization, + and falls back to not deserializing the object. Recommended + for use in error deserialization, as we want to return the + HttpResponseError to users, and not have them deal with + 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 content_type: Swagger "produces" if available. + """ + try: + return self(target_obj, data, content_type=content_type) + except: + _LOGGER.debug( + "Ran into a deserialization error. Ignoring since this is failsafe deserialization", + exc_info=True + ) + return None + + @staticmethod + def _unpack_content(raw_data, content_type=None): + """Extract the correct structure for deserialization. + + If raw_data is a PipelineResponse, try to extract the result of RawDeserializer. + if we can't, raise. Your Pipeline should have a RawDeserializer. + + If not a pipeline response and raw_data is bytes or string, use content-type + to decode it. If no content-type, try JSON. + + If raw_data is something else, bypass all logic and return it directly. + + :param raw_data: Data to be processed. + :param content_type: How to parse if raw_data is a string/bytes. + :raises JSONDecodeError: If JSON is requested and parsing is impossible. + :raises UnicodeDecodeError: If bytes is not UTF8 + """ + # Assume this is enough to detect a Pipeline Response without importing it + context = getattr(raw_data, "context", {}) + if context: + if RawDeserializer.CONTEXT_NAME in context: + return context[RawDeserializer.CONTEXT_NAME] + raise ValueError("This pipeline didn't have the RawDeserializer policy; can't deserialize") + + #Assume this is enough to recognize universal_http.ClientResponse without importing it + if hasattr(raw_data, "body"): + return RawDeserializer.deserialize_from_http_generics( + raw_data.text(), + raw_data.headers + ) + + # Assume this enough to recognize requests.Response without importing it. + if hasattr(raw_data, '_content_consumed'): + 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 raw_data + + def _instantiate_model(self, response, attrs, additional_properties=None): + """Instantiate a response model passing in deserialized args. + + :param response: The response model class. + :param d_attrs: The deserialized response attributes. + """ + if callable(response): + subtype = getattr(response, '_subtype_map', {}) + try: + readonly = [k for k, v in response._validation.items() + if v.get('readonly')] + const = [k for k, v in response._validation.items() + if v.get('constant')] + kwargs = {k: v for k, v in attrs.items() + if k not in subtype and k not in readonly + const} + response_obj = response(**kwargs) + for attr in readonly: + setattr(response_obj, attr, attrs.get(attr)) + if additional_properties: + response_obj.additional_properties = additional_properties + return response_obj + except TypeError as err: + msg = "Unable to deserialize {} into model {}. ".format( + kwargs, response) + raise DeserializationError(msg + str(err)) + else: + try: + for attr, value in attrs.items(): + setattr(response, attr, value) + return response + except Exception as exp: + msg = "Unable to populate response model. " + msg += "Type: {}, Error: {}".format(type(response), exp) + raise DeserializationError(msg) + + def deserialize_data(self, data, data_type): + """Process data for deserialization according to data type. + + :param str data: The response string to be deserialized. + :param str data_type: The type to deserialize to. + :raises: DeserializationError if deserialization fails. + :return: Deserialized object. + """ + if data is None: + return data + + try: + if not data_type: + return data + if data_type in self.basic_types.values(): + return self.deserialize_basic(data, data_type) + if data_type in self.deserialize_type: + if isinstance(data, self.deserialize_expected_types.get(data_type, tuple())): + return data + + is_a_text_parsing_type = lambda x: x not in ["object", "[]", r"{}"] + if isinstance(data, ET.Element) and is_a_text_parsing_type(data_type) and not data.text: + return None + data_val = self.deserialize_type[data_type](data) + return data_val + + iter_type = data_type[0] + data_type[-1] + if iter_type in self.deserialize_type: + return self.deserialize_type[iter_type](data, data_type[1:-1]) + + obj_type = self.dependencies[data_type] + if issubclass(obj_type, Enum): + if isinstance(data, ET.Element): + data = data.text + return self.deserialize_enum(data, obj_type) + + except (ValueError, TypeError, AttributeError) as err: + msg = "Unable to deserialize response data." + msg += " Data: {}, {}".format(data, data_type) + raise_with_traceback(DeserializationError, msg, err) + else: + return self._deserialize(obj_type, data) + + def deserialize_iter(self, attr, iter_type): + """Deserialize an iterable. + + :param list attr: Iterable to be deserialized. + :param str iter_type: The type of object in the iterable. + :rtype: list + """ + if attr is None: + return None + if isinstance(attr, ET.Element): # If I receive an element here, get the children + attr = list(attr) + if not isinstance(attr, (list, set)): + raise DeserializationError("Cannot deserialize as [{}] an object of type {}".format( + iter_type, + type(attr) + )) + return [self.deserialize_data(a, iter_type) for a in attr] + + def deserialize_dict(self, attr, dict_type): + """Deserialize a dictionary. + + :param dict/list attr: Dictionary to be deserialized. Also accepts + a list of key, value pairs. + :param str dict_type: The object type of the items in the dictionary. + :rtype: dict + """ + if isinstance(attr, list): + return {x['key']: self.deserialize_data(x['value'], dict_type) for x in attr} + + if isinstance(attr, ET.Element): + # Transform value into {"Key": "value"} + attr = {el.tag: el.text for el in attr} + return {k: self.deserialize_data(v, dict_type) for k, v in attr.items()} + + def deserialize_object(self, attr, **kwargs): + """Deserialize a generic object. + This will be handled as a dictionary. + + :param dict attr: Dictionary to be deserialized. + :rtype: dict + :raises: TypeError if non-builtin datatype encountered. + """ + if attr is None: + return None + if isinstance(attr, ET.Element): + # Do no recurse on XML, just return the tree as-is + return attr + if isinstance(attr, basestring): + return self.deserialize_basic(attr, 'str') + obj_type = type(attr) + if obj_type in self.basic_types: + return self.deserialize_basic(attr, self.basic_types[obj_type]) + if obj_type is _long_type: + return self.deserialize_long(attr) + + if obj_type == dict: + deserialized = {} + for key, value in attr.items(): + try: + deserialized[key] = self.deserialize_object( + value, **kwargs) + except ValueError: + deserialized[key] = None + return deserialized + + if obj_type == list: + deserialized = [] + for obj in attr: + try: + deserialized.append(self.deserialize_object( + obj, **kwargs)) + except ValueError: + pass + return deserialized + + else: + error = "Cannot deserialize generic object with type: " + raise TypeError(error + str(obj_type)) + + def deserialize_basic(self, attr, data_type): + """Deserialize basic builtin data type from string. + Will attempt to convert to str, int, float and bool. + This function will also accept '1', '0', 'true' and 'false' as + valid bool values. + + :param str attr: response string to be deserialized. + :param str data_type: deserialization data type. + :rtype: str, int, float or bool + :raises: TypeError if string format is not valid. + """ + # If we're here, data is supposed to be a basic type. + # If it's still an XML node, take the text + if isinstance(attr, ET.Element): + attr = attr.text + if not attr: + if data_type == "str": + # None or '', node is empty string. + return '' + else: + # None or '', node with a strong type is None. + # Don't try to model "empty bool" or "empty int" + return None + + if data_type == 'bool': + if attr in [True, False, 1, 0]: + return bool(attr) + elif isinstance(attr, basestring): + if attr.lower() in ['true', '1']: + return True + elif attr.lower() in ['false', '0']: + return False + raise TypeError("Invalid boolean value: {}".format(attr)) + + if data_type == 'str': + return self.deserialize_unicode(attr) + return eval(data_type)(attr) # nosec + + @staticmethod + def deserialize_unicode(data): + """Preserve unicode objects in Python 2, otherwise return data + as a string. + + :param str data: response string to be deserialized. + :rtype: str or unicode + """ + # We might be here because we have an enum modeled as string, + # and we try to deserialize a partial dict with enum inside + if isinstance(data, Enum): + return data + + # Consider this is real string + try: + if isinstance(data, unicode): + return data + except NameError: + return str(data) + else: + return str(data) + + @staticmethod + def deserialize_enum(data, enum_obj): + """Deserialize string into enum object. + + If the string is not a valid enum value it will be returned as-is + and a warning will be logged. + + :param str data: Response string to be deserialized. If this value is + None or invalid it will be returned as-is. + :param Enum enum_obj: Enum object to deserialize to. + :rtype: Enum + """ + if isinstance(data, enum_obj) or data is None: + return data + if isinstance(data, Enum): + data = data.value + if isinstance(data, int): + # Workaround. We might consider remove it in the future. + # https://github.com/Azure/azure-rest-api-specs/issues/141 + try: + return list(enum_obj.__members__.values())[data] + except IndexError: + error = "{!r} is not a valid index for enum {!r}" + raise DeserializationError(error.format(data, enum_obj)) + try: + return enum_obj(str(data)) + except ValueError: + for enum_value in enum_obj: + if enum_value.value.lower() == str(data).lower(): + return enum_value + # We don't fail anymore for unknown value, we deserialize as a string + _LOGGER.warning("Deserializer is not able to find %s as valid enum in %s", data, enum_obj) + return Deserializer.deserialize_unicode(data) + + @staticmethod + def deserialize_bytearray(attr): + """Deserialize string into bytearray. + + :param str attr: response string to be deserialized. + :rtype: bytearray + :raises: TypeError if string format invalid. + """ + if isinstance(attr, ET.Element): + attr = attr.text + return bytearray(b64decode(attr)) + + @staticmethod + def deserialize_base64(attr): + """Deserialize base64 encoded string into string. + + :param str attr: response string to be deserialized. + :rtype: bytearray + :raises: TypeError if string format invalid. + """ + if isinstance(attr, ET.Element): + attr = attr.text + padding = '=' * (3 - (len(attr) + 3) % 4) + attr = attr + padding + encoded = attr.replace('-', '+').replace('_', '/') + return b64decode(encoded) + + @staticmethod + def deserialize_decimal(attr): + """Deserialize string into Decimal object. + + :param str attr: response string to be deserialized. + :rtype: Decimal + :raises: DeserializationError if string format invalid. + """ + if isinstance(attr, ET.Element): + attr = attr.text + try: + return decimal.Decimal(attr) + except decimal.DecimalException as err: + msg = "Invalid decimal {}".format(attr) + raise_with_traceback(DeserializationError, msg, err) + + @staticmethod + def deserialize_long(attr): + """Deserialize string into long (Py2) or int (Py3). + + :param str attr: response string to be deserialized. + :rtype: long or int + :raises: ValueError if string format invalid. + """ + if isinstance(attr, ET.Element): + attr = attr.text + return _long_type(attr) + + @staticmethod + def deserialize_duration(attr): + """Deserialize ISO-8601 formatted string into TimeDelta object. + + :param str attr: response string to be deserialized. + :rtype: TimeDelta + :raises: DeserializationError if string format invalid. + """ + if isinstance(attr, ET.Element): + attr = attr.text + try: + duration = isodate.parse_duration(attr) + except(ValueError, OverflowError, AttributeError) as err: + msg = "Cannot deserialize duration object." + raise_with_traceback(DeserializationError, msg, err) + else: + return duration + + @staticmethod + def deserialize_date(attr): + """Deserialize ISO-8601 formatted string into Date object. + + :param str attr: response string to be deserialized. + :rtype: Date + :raises: DeserializationError if string format invalid. + """ + if isinstance(attr, ET.Element): + attr = attr.text + if re.search(r"[^\W\d_]", attr, re.I + re.U): + 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) + + @staticmethod + def deserialize_time(attr): + """Deserialize ISO-8601 formatted string into time object. + + :param str attr: response string to be deserialized. + :rtype: datetime.time + :raises: DeserializationError if string format invalid. + """ + if isinstance(attr, ET.Element): + attr = attr.text + if re.search(r"[^\W\d_]", attr, re.I + re.U): + raise DeserializationError("Date must have only digits and -. Received: %s" % attr) + return isodate.parse_time(attr) + + @staticmethod + def deserialize_rfc(attr): + """Deserialize RFC-1123 formatted string into Datetime object. + + :param str attr: response string to be deserialized. + :rtype: Datetime + :raises: DeserializationError if string format invalid. + """ + if isinstance(attr, ET.Element): + attr = attr.text + try: + parsed_date = email.utils.parsedate_tz(attr) + date_obj = datetime.datetime( + *parsed_date[:6], + tzinfo=_FixedOffset(datetime.timedelta(minutes=(parsed_date[9] or 0)/60)) + ) + if not date_obj.tzinfo: + date_obj = date_obj.astimezone(tz=TZ_UTC) + except ValueError as err: + msg = "Cannot deserialize to rfc datetime object." + raise_with_traceback(DeserializationError, msg, err) + else: + return date_obj + + @staticmethod + def deserialize_iso(attr): + """Deserialize ISO-8601 formatted string into Datetime object. + + :param str attr: response string to be deserialized. + :rtype: Datetime + :raises: DeserializationError if string format invalid. + """ + if isinstance(attr, ET.Element): + attr = attr.text + try: + attr = attr.upper() + match = Deserializer.valid_date.match(attr) + if not match: + raise ValueError("Invalid datetime string: " + attr) + + check_decimal = attr.split('.') + if len(check_decimal) > 1: + decimal_str = "" + for digit in check_decimal[1]: + if digit.isdigit(): + decimal_str += digit + else: + break + if len(decimal_str) > 6: + attr = attr.replace(decimal_str, decimal_str[0:6]) + + date_obj = isodate.parse_datetime(attr) + test_utc = date_obj.utctimetuple() + if test_utc.tm_year > 9999 or test_utc.tm_year < 1: + raise OverflowError("Hit max or min date") + except(ValueError, OverflowError, AttributeError) as err: + msg = "Cannot deserialize datetime object." + raise_with_traceback(DeserializationError, msg, err) + else: + return date_obj + + @staticmethod + def deserialize_unix(attr): + """Serialize Datetime object into IntTime format. + This is represented as seconds. + + :param int attr: Object to be serialized. + :rtype: Datetime + :raises: DeserializationError if format invalid + """ + if isinstance(attr, ET.Element): + attr = int(attr.text) + try: + date_obj = datetime.datetime.fromtimestamp(attr, TZ_UTC) + except ValueError as err: + msg = "Cannot deserialize to unix datetime object." + raise_with_traceback(DeserializationError, msg, err) + else: + return date_obj diff --git a/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/policy/aio/_configuration.py b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/policy/aio/_configuration.py index be542e6ae80e0..62c46beab7791 100644 --- a/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/policy/aio/_configuration.py +++ b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/policy/aio/_configuration.py @@ -26,9 +26,9 @@ class PolicyClientConfiguration(Configuration): Note that all parameters used to create this instance are saved as instance attributes. - :param credential: Credential needed for the client to connect to Azure. + :param credential: Credential needed for the client to connect to Azure. Required. :type credential: ~azure.core.credentials_async.AsyncTokenCredential - :param subscription_id: The ID of the target subscription. + :param subscription_id: The ID of the target subscription. Required. :type subscription_id: str """ diff --git a/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/policy/aio/_policy_client.py b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/policy/aio/_policy_client.py index d91a9b98d9f2a..2cf11515e6004 100644 --- a/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/policy/aio/_policy_client.py +++ b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/policy/aio/_policy_client.py @@ -11,17 +11,15 @@ from typing import Any, Optional, TYPE_CHECKING -from msrest import Deserializer, Serializer - from azure.mgmt.core import AsyncARMPipelineClient from azure.profiles import KnownProfiles, ProfileDefinition from azure.profiles.multiapiclient import MultiApiClientMixin +from .._serialization import Deserializer, Serializer from ._configuration import PolicyClientConfiguration if TYPE_CHECKING: # pylint: disable=unused-import,ungrouped-imports - from azure.core.credentials import TokenCredential from azure.core.credentials_async import AsyncTokenCredential class _SDKClient(object): @@ -42,9 +40,9 @@ class PolicyClient(MultiApiClientMixin, _SDKClient): The api-version parameter sets the default API version if the operation group is not described in the profile. - :param credential: Credential needed for the client to connect to Azure. + :param credential: Credential needed for the client to connect to Azure. Required. :type credential: ~azure.core.credentials_async.AsyncTokenCredential - :param subscription_id: The ID of the target subscription. + :param subscription_id: The ID of the target subscription. Required. :type subscription_id: str :param api_version: API version to use if no profile is provided, or if missing in profile. :type api_version: str @@ -286,6 +284,32 @@ def policy_set_definitions(self): raise ValueError("API version {} does not have operation group 'policy_set_definitions'".format(api_version)) return OperationClass(self._client, self._config, Serializer(self._models_dict(api_version)), Deserializer(self._models_dict(api_version))) + @property + def variable_values(self): + """Instance depends on the API version: + + * 2021-06-01: :class:`VariableValuesOperations` + """ + api_version = self._get_api_version('variable_values') + if api_version == '2021-06-01': + from ..v2021_06_01.aio.operations import VariableValuesOperations as OperationClass + else: + raise ValueError("API version {} does not have operation group 'variable_values'".format(api_version)) + return OperationClass(self._client, self._config, Serializer(self._models_dict(api_version)), Deserializer(self._models_dict(api_version))) + + @property + def variables(self): + """Instance depends on the API version: + + * 2021-06-01: :class:`VariablesOperations` + """ + api_version = self._get_api_version('variables') + if api_version == '2021-06-01': + from ..v2021_06_01.aio.operations import VariablesOperations as OperationClass + else: + raise ValueError("API version {} does not have operation group 'variables'".format(api_version)) + return OperationClass(self._client, self._config, Serializer(self._models_dict(api_version)), Deserializer(self._models_dict(api_version))) + async def close(self): await self._client.close() async def __aenter__(self): diff --git a/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/policy/v2015_10_01_preview/__init__.py b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/policy/v2015_10_01_preview/__init__.py index 89180ab440872..bb1ffe59afae7 100644 --- a/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/policy/v2015_10_01_preview/__init__.py +++ b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/policy/v2015_10_01_preview/__init__.py @@ -10,9 +10,15 @@ from ._version import VERSION __version__ = VERSION -__all__ = ['PolicyClient'] -# `._patch.py` is used for handwritten extensions to the generated code -# Example: https://github.com/Azure/azure-sdk-for-python/blob/main/doc/dev/customize_code/how-to-patch-sdk-code.md -from ._patch import patch_sdk -patch_sdk() +try: + from ._patch import __all__ as _patch_all + from ._patch import * # type: ignore # pylint: disable=unused-wildcard-import +except ImportError: + _patch_all = [] +from ._patch import patch_sdk as _patch_sdk + +__all__ = ["PolicyClient"] +__all__.extend([p for p in _patch_all if p not in __all__]) + +_patch_sdk() diff --git a/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/policy/v2015_10_01_preview/_configuration.py b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/policy/v2015_10_01_preview/_configuration.py index dfa2709ba16a1..0645ce3fdd35d 100644 --- a/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/policy/v2015_10_01_preview/_configuration.py +++ b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/policy/v2015_10_01_preview/_configuration.py @@ -25,23 +25,18 @@ class PolicyClientConfiguration(Configuration): # pylint: disable=too-many-inst Note that all parameters used to create this instance are saved as instance attributes. - :param credential: Credential needed for the client to connect to Azure. + :param credential: Credential needed for the client to connect to Azure. Required. :type credential: ~azure.core.credentials.TokenCredential - :param subscription_id: The ID of the target subscription. + :param subscription_id: The ID of the target subscription. Required. :type subscription_id: str :keyword api_version: Api Version. Default value is "2015-10-01-preview". Note that overriding this default value may result in unsupported behavior. :paramtype api_version: str """ - def __init__( - self, - credential: "TokenCredential", - subscription_id: str, - **kwargs: Any - ) -> None: + def __init__(self, credential: "TokenCredential", subscription_id: str, **kwargs: Any) -> None: super(PolicyClientConfiguration, self).__init__(**kwargs) - api_version = kwargs.pop('api_version', "2015-10-01-preview") # type: str + api_version = kwargs.pop("api_version", "2015-10-01-preview") # type: str if credential is None: raise ValueError("Parameter 'credential' must not be None.") @@ -51,23 +46,24 @@ def __init__( self.credential = credential self.subscription_id = subscription_id self.api_version = api_version - self.credential_scopes = kwargs.pop('credential_scopes', ['https://management.azure.com/.default']) - kwargs.setdefault('sdk_moniker', 'mgmt-resource/{}'.format(VERSION)) + self.credential_scopes = kwargs.pop("credential_scopes", ["https://management.azure.com/.default"]) + kwargs.setdefault("sdk_moniker", "mgmt-resource/{}".format(VERSION)) self._configure(**kwargs) def _configure( - self, - **kwargs # type: Any + self, **kwargs # type: Any ): # type: (...) -> 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) - self.logging_policy = kwargs.get('logging_policy') or policies.NetworkTraceLoggingPolicy(**kwargs) - self.http_logging_policy = kwargs.get('http_logging_policy') or ARMHttpLoggingPolicy(**kwargs) - self.retry_policy = kwargs.get('retry_policy') or policies.RetryPolicy(**kwargs) - self.custom_hook_policy = kwargs.get('custom_hook_policy') or policies.CustomHookPolicy(**kwargs) - self.redirect_policy = kwargs.get('redirect_policy') or policies.RedirectPolicy(**kwargs) - self.authentication_policy = kwargs.get('authentication_policy') + 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) + self.logging_policy = kwargs.get("logging_policy") or policies.NetworkTraceLoggingPolicy(**kwargs) + self.http_logging_policy = kwargs.get("http_logging_policy") or ARMHttpLoggingPolicy(**kwargs) + self.retry_policy = kwargs.get("retry_policy") or policies.RetryPolicy(**kwargs) + self.custom_hook_policy = kwargs.get("custom_hook_policy") or policies.CustomHookPolicy(**kwargs) + self.redirect_policy = kwargs.get("redirect_policy") or policies.RedirectPolicy(**kwargs) + self.authentication_policy = kwargs.get("authentication_policy") if self.credential and not self.authentication_policy: - self.authentication_policy = ARMChallengeAuthenticationPolicy(self.credential, *self.credential_scopes, **kwargs) + self.authentication_policy = ARMChallengeAuthenticationPolicy( + self.credential, *self.credential_scopes, **kwargs + ) diff --git a/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/policy/v2015_10_01_preview/_metadata.json b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/policy/v2015_10_01_preview/_metadata.json index 952df1c779571..cf77d74d98c8b 100644 --- a/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/policy/v2015_10_01_preview/_metadata.json +++ b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/policy/v2015_10_01_preview/_metadata.json @@ -10,20 +10,20 @@ "azure_arm": true, "has_lro_operations": false, "client_side_validation": false, - "sync_imports": "{\"typing\": {\"azurecore\": {\"azure.core.credentials\": [\"TokenCredential\"]}}, \"regular\": {\"azurecore\": {\"azure.profiles\": [\"KnownProfiles\", \"ProfileDefinition\"], \"azure.profiles.multiapiclient\": [\"MultiApiClientMixin\"], \"azure.mgmt.core\": [\"ARMPipelineClient\"]}, \"local\": {\"._configuration\": [\"PolicyClientConfiguration\"]}, \"thirdparty\": {\"msrest\": [\"Deserializer\", \"Serializer\"]}}, \"conditional\": {\"stdlib\": {\"typing\": [\"Any\", \"Optional\"]}}}", - "async_imports": "{\"typing\": {\"azurecore\": {\"azure.core.credentials_async\": [\"AsyncTokenCredential\"], \"azure.core.credentials\": [\"TokenCredential\"]}}, \"regular\": {\"azurecore\": {\"azure.profiles\": [\"KnownProfiles\", \"ProfileDefinition\"], \"azure.profiles.multiapiclient\": [\"MultiApiClientMixin\"], \"azure.mgmt.core\": [\"AsyncARMPipelineClient\"]}, \"local\": {\"._configuration\": [\"PolicyClientConfiguration\"]}, \"thirdparty\": {\"msrest\": [\"Deserializer\", \"Serializer\"]}}, \"conditional\": {\"stdlib\": {\"typing\": [\"Any\", \"Optional\"]}}}" + "sync_imports": "{\"conditional\": {\"stdlib\": {\"typing\": [\"Any\", \"Optional\"]}}, \"regular\": {\"azurecore\": {\"azure.mgmt.core\": [\"ARMPipelineClient\"], \"azure.profiles\": [\"KnownProfiles\", \"ProfileDefinition\"], \"azure.profiles.multiapiclient\": [\"MultiApiClientMixin\"]}, \"local\": {\"._configuration\": [\"PolicyClientConfiguration\"], \".._serialization\": [\"Deserializer\", \"Serializer\"]}}, \"typing\": {\"azurecore\": {\"azure.core.credentials\": [\"TokenCredential\"]}}}", + "async_imports": "{\"conditional\": {\"stdlib\": {\"typing\": [\"Any\", \"Optional\"]}}, \"regular\": {\"azurecore\": {\"azure.mgmt.core\": [\"AsyncARMPipelineClient\"], \"azure.profiles\": [\"KnownProfiles\", \"ProfileDefinition\"], \"azure.profiles.multiapiclient\": [\"MultiApiClientMixin\"]}, \"local\": {\"._configuration\": [\"PolicyClientConfiguration\"], \"..._serialization\": [\"Deserializer\", \"Serializer\"]}}, \"typing\": {\"azurecore\": {\"azure.core.credentials_async\": [\"AsyncTokenCredential\"]}}}" }, "global_parameters": { "sync": { "credential": { - "signature": "credential, # type: \"TokenCredential\"", - "description": "Credential needed for the client to connect to Azure.", + "signature": "credential: \"TokenCredential\",", + "description": "Credential needed for the client to connect to Azure. Required.", "docstring_type": "~azure.core.credentials.TokenCredential", "required": true }, "subscription_id": { - "signature": "subscription_id, # type: str", - "description": "The ID of the target subscription.", + "signature": "subscription_id: str,", + "description": "The ID of the target subscription. Required.", "docstring_type": "str", "required": true } @@ -31,13 +31,13 @@ "async": { "credential": { "signature": "credential: \"AsyncTokenCredential\",", - "description": "Credential needed for the client to connect to Azure.", + "description": "Credential needed for the client to connect to Azure. Required.", "docstring_type": "~azure.core.credentials_async.AsyncTokenCredential", "required": true }, "subscription_id": { "signature": "subscription_id: str,", - "description": "The ID of the target subscription.", + "description": "The ID of the target subscription. Required.", "docstring_type": "str", "required": true } @@ -54,7 +54,7 @@ "required": false }, "base_url": { - "signature": "base_url=\"https://management.azure.com\", # type: str", + "signature": "base_url: str = \"https://management.azure.com\",", "description": "Service URL", "docstring_type": "str", "required": false diff --git a/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/policy/v2015_10_01_preview/_patch.py b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/policy/v2015_10_01_preview/_patch.py index 74e48ecd07cf3..f99e77fef9861 100644 --- a/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/policy/v2015_10_01_preview/_patch.py +++ b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/policy/v2015_10_01_preview/_patch.py @@ -28,4 +28,4 @@ # This file is used for handwritten extensions to the generated code. Example: # https://github.com/Azure/azure-sdk-for-python/blob/main/doc/dev/customize_code/how-to-patch-sdk-code.md def patch_sdk(): - pass \ No newline at end of file + pass diff --git a/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/policy/v2015_10_01_preview/_policy_client.py b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/policy/v2015_10_01_preview/_policy_client.py index 5e9b06ffa8fa9..ac60e402ee52e 100644 --- a/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/policy/v2015_10_01_preview/_policy_client.py +++ b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/policy/v2015_10_01_preview/_policy_client.py @@ -9,12 +9,11 @@ from copy import deepcopy from typing import Any, TYPE_CHECKING -from msrest import Deserializer, Serializer - from azure.core.rest import HttpRequest, HttpResponse from azure.mgmt.core import ARMPipelineClient from . import models +from .._serialization import Deserializer, Serializer from ._configuration import PolicyClientConfiguration from .operations import PolicyAssignmentsOperations, PolicyDefinitionsOperations @@ -22,7 +21,8 @@ # pylint: disable=unused-import,ungrouped-imports from azure.core.credentials import TokenCredential -class PolicyClient: + +class PolicyClient: # pylint: disable=client-accepts-api-version-keyword """To manage and control access to your resources, you can define customized policies and assign them at a scope. @@ -32,9 +32,9 @@ class PolicyClient: :ivar policy_definitions: PolicyDefinitionsOperations operations :vartype policy_definitions: azure.mgmt.resource.policy.v2015_10_01_preview.operations.PolicyDefinitionsOperations - :param credential: Credential needed for the client to connect to Azure. + :param credential: Credential needed for the client to connect to Azure. Required. :type credential: ~azure.core.credentials.TokenCredential - :param subscription_id: The ID of the target subscription. + :param subscription_id: The ID of the target subscription. Required. :type subscription_id: str :param base_url: Service URL. Default value is "https://management.azure.com". :type base_url: str @@ -57,15 +57,14 @@ def __init__( self._serialize = Serializer(client_models) self._deserialize = Deserializer(client_models) self._serialize.client_side_validation = False - self.policy_assignments = PolicyAssignmentsOperations(self._client, self._config, self._serialize, self._deserialize) - self.policy_definitions = PolicyDefinitionsOperations(self._client, self._config, self._serialize, self._deserialize) - - - def _send_request( - self, - request: HttpRequest, - **kwargs: Any - ) -> HttpResponse: + self.policy_assignments = PolicyAssignmentsOperations( + self._client, self._config, self._serialize, self._deserialize + ) + self.policy_definitions = PolicyDefinitionsOperations( + self._client, self._config, self._serialize, self._deserialize + ) + + def _send_request(self, request: HttpRequest, **kwargs: Any) -> HttpResponse: """Runs the network request through the client's chained policies. >>> from azure.core.rest import HttpRequest @@ -74,7 +73,7 @@ def _send_request( >>> response = client._send_request(request) - For more information on this code flow, see https://aka.ms/azsdk/python/protocol/quickstart + For more information on this code flow, see https://aka.ms/azsdk/dpcodegen/python/send_request :param request: The network request you want to make. Required. :type request: ~azure.core.rest.HttpRequest diff --git a/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/policy/v2015_10_01_preview/_vendor.py b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/policy/v2015_10_01_preview/_vendor.py index 138f663c53a4e..9aad73fc743e7 100644 --- a/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/policy/v2015_10_01_preview/_vendor.py +++ b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/policy/v2015_10_01_preview/_vendor.py @@ -7,6 +7,7 @@ from azure.core.pipeline.transport import HttpRequest + def _convert_request(request, files=None): data = request.content if not files else None request = HttpRequest(method=request.method, url=request.url, headers=request.headers, data=data) @@ -14,6 +15,7 @@ def _convert_request(request, files=None): request.set_formdata_body(files) return request + def _format_url_section(template, **kwargs): components = template.split("/") while components: @@ -21,7 +23,5 @@ def _format_url_section(template, **kwargs): 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 - ] + components = [c for c in formatted_components if "{}".format(key.args[0]) not in c] template = "/".join(components) diff --git a/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/policy/v2015_10_01_preview/_version.py b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/policy/v2015_10_01_preview/_version.py index a012ac01c480c..e5754a47ce68f 100644 --- a/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/policy/v2015_10_01_preview/_version.py +++ b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/policy/v2015_10_01_preview/_version.py @@ -6,4 +6,4 @@ # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -VERSION = "21.1.0" +VERSION = "1.0.0b1" diff --git a/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/policy/v2015_10_01_preview/aio/__init__.py b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/policy/v2015_10_01_preview/aio/__init__.py index 2784ce3f14bf5..4622bf1f396a7 100644 --- a/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/policy/v2015_10_01_preview/aio/__init__.py +++ b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/policy/v2015_10_01_preview/aio/__init__.py @@ -7,9 +7,15 @@ # -------------------------------------------------------------------------- from ._policy_client import PolicyClient -__all__ = ['PolicyClient'] -# `._patch.py` is used for handwritten extensions to the generated code -# Example: https://github.com/Azure/azure-sdk-for-python/blob/main/doc/dev/customize_code/how-to-patch-sdk-code.md -from ._patch import patch_sdk -patch_sdk() +try: + from ._patch import __all__ as _patch_all + from ._patch import * # type: ignore # pylint: disable=unused-wildcard-import +except ImportError: + _patch_all = [] +from ._patch import patch_sdk as _patch_sdk + +__all__ = ["PolicyClient"] +__all__.extend([p for p in _patch_all if p not in __all__]) + +_patch_sdk() diff --git a/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/policy/v2015_10_01_preview/aio/_configuration.py b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/policy/v2015_10_01_preview/aio/_configuration.py index 268dd1ef5c14d..418d621007352 100644 --- a/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/policy/v2015_10_01_preview/aio/_configuration.py +++ b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/policy/v2015_10_01_preview/aio/_configuration.py @@ -25,23 +25,18 @@ class PolicyClientConfiguration(Configuration): # pylint: disable=too-many-inst Note that all parameters used to create this instance are saved as instance attributes. - :param credential: Credential needed for the client to connect to Azure. + :param credential: Credential needed for the client to connect to Azure. Required. :type credential: ~azure.core.credentials_async.AsyncTokenCredential - :param subscription_id: The ID of the target subscription. + :param subscription_id: The ID of the target subscription. Required. :type subscription_id: str :keyword api_version: Api Version. Default value is "2015-10-01-preview". Note that overriding this default value may result in unsupported behavior. :paramtype api_version: str """ - def __init__( - self, - credential: "AsyncTokenCredential", - subscription_id: str, - **kwargs: Any - ) -> None: + def __init__(self, credential: "AsyncTokenCredential", subscription_id: str, **kwargs: Any) -> None: super(PolicyClientConfiguration, self).__init__(**kwargs) - api_version = kwargs.pop('api_version', "2015-10-01-preview") # type: str + api_version = kwargs.pop("api_version", "2015-10-01-preview") # type: str if credential is None: raise ValueError("Parameter 'credential' must not be None.") @@ -51,22 +46,21 @@ def __init__( self.credential = credential self.subscription_id = subscription_id self.api_version = api_version - self.credential_scopes = kwargs.pop('credential_scopes', ['https://management.azure.com/.default']) - kwargs.setdefault('sdk_moniker', 'mgmt-resource/{}'.format(VERSION)) + self.credential_scopes = kwargs.pop("credential_scopes", ["https://management.azure.com/.default"]) + kwargs.setdefault("sdk_moniker", "mgmt-resource/{}".format(VERSION)) self._configure(**kwargs) - 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) - self.logging_policy = kwargs.get('logging_policy') or policies.NetworkTraceLoggingPolicy(**kwargs) - self.http_logging_policy = kwargs.get('http_logging_policy') or ARMHttpLoggingPolicy(**kwargs) - self.retry_policy = kwargs.get('retry_policy') or policies.AsyncRetryPolicy(**kwargs) - self.custom_hook_policy = kwargs.get('custom_hook_policy') or policies.CustomHookPolicy(**kwargs) - self.redirect_policy = kwargs.get('redirect_policy') or policies.AsyncRedirectPolicy(**kwargs) - self.authentication_policy = kwargs.get('authentication_policy') + 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) + self.logging_policy = kwargs.get("logging_policy") or policies.NetworkTraceLoggingPolicy(**kwargs) + self.http_logging_policy = kwargs.get("http_logging_policy") or ARMHttpLoggingPolicy(**kwargs) + self.retry_policy = kwargs.get("retry_policy") or policies.AsyncRetryPolicy(**kwargs) + self.custom_hook_policy = kwargs.get("custom_hook_policy") or policies.CustomHookPolicy(**kwargs) + self.redirect_policy = kwargs.get("redirect_policy") or policies.AsyncRedirectPolicy(**kwargs) + self.authentication_policy = kwargs.get("authentication_policy") if self.credential and not self.authentication_policy: - self.authentication_policy = AsyncARMChallengeAuthenticationPolicy(self.credential, *self.credential_scopes, **kwargs) + self.authentication_policy = AsyncARMChallengeAuthenticationPolicy( + self.credential, *self.credential_scopes, **kwargs + ) diff --git a/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/policy/v2015_10_01_preview/aio/_patch.py b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/policy/v2015_10_01_preview/aio/_patch.py index 74e48ecd07cf3..f99e77fef9861 100644 --- a/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/policy/v2015_10_01_preview/aio/_patch.py +++ b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/policy/v2015_10_01_preview/aio/_patch.py @@ -28,4 +28,4 @@ # This file is used for handwritten extensions to the generated code. Example: # https://github.com/Azure/azure-sdk-for-python/blob/main/doc/dev/customize_code/how-to-patch-sdk-code.md def patch_sdk(): - pass \ No newline at end of file + pass diff --git a/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/policy/v2015_10_01_preview/aio/_policy_client.py b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/policy/v2015_10_01_preview/aio/_policy_client.py index 306b32dfdbe49..a646bb1e89203 100644 --- a/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/policy/v2015_10_01_preview/aio/_policy_client.py +++ b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/policy/v2015_10_01_preview/aio/_policy_client.py @@ -9,12 +9,11 @@ from copy import deepcopy from typing import Any, Awaitable, TYPE_CHECKING -from msrest import Deserializer, Serializer - from azure.core.rest import AsyncHttpResponse, HttpRequest from azure.mgmt.core import AsyncARMPipelineClient from .. import models +from ..._serialization import Deserializer, Serializer from ._configuration import PolicyClientConfiguration from .operations import PolicyAssignmentsOperations, PolicyDefinitionsOperations @@ -22,7 +21,8 @@ # pylint: disable=unused-import,ungrouped-imports from azure.core.credentials_async import AsyncTokenCredential -class PolicyClient: + +class PolicyClient: # pylint: disable=client-accepts-api-version-keyword """To manage and control access to your resources, you can define customized policies and assign them at a scope. @@ -32,9 +32,9 @@ class PolicyClient: :ivar policy_definitions: PolicyDefinitionsOperations operations :vartype policy_definitions: azure.mgmt.resource.policy.v2015_10_01_preview.aio.operations.PolicyDefinitionsOperations - :param credential: Credential needed for the client to connect to Azure. + :param credential: Credential needed for the client to connect to Azure. Required. :type credential: ~azure.core.credentials_async.AsyncTokenCredential - :param subscription_id: The ID of the target subscription. + :param subscription_id: The ID of the target subscription. Required. :type subscription_id: str :param base_url: Service URL. Default value is "https://management.azure.com". :type base_url: str @@ -57,15 +57,14 @@ def __init__( self._serialize = Serializer(client_models) self._deserialize = Deserializer(client_models) self._serialize.client_side_validation = False - self.policy_assignments = PolicyAssignmentsOperations(self._client, self._config, self._serialize, self._deserialize) - self.policy_definitions = PolicyDefinitionsOperations(self._client, self._config, self._serialize, self._deserialize) - - - def _send_request( - self, - request: HttpRequest, - **kwargs: Any - ) -> Awaitable[AsyncHttpResponse]: + self.policy_assignments = PolicyAssignmentsOperations( + self._client, self._config, self._serialize, self._deserialize + ) + self.policy_definitions = PolicyDefinitionsOperations( + self._client, self._config, self._serialize, self._deserialize + ) + + def _send_request(self, request: HttpRequest, **kwargs: Any) -> Awaitable[AsyncHttpResponse]: """Runs the network request through the client's chained policies. >>> from azure.core.rest import HttpRequest @@ -74,7 +73,7 @@ def _send_request( >>> response = await client._send_request(request) - For more information on this code flow, see https://aka.ms/azsdk/python/protocol/quickstart + For more information on this code flow, see https://aka.ms/azsdk/dpcodegen/python/send_request :param request: The network request you want to make. Required. :type request: ~azure.core.rest.HttpRequest diff --git a/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/policy/v2015_10_01_preview/aio/operations/__init__.py b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/policy/v2015_10_01_preview/aio/operations/__init__.py index 33ee2baf02338..1feb25bc4bdb2 100644 --- a/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/policy/v2015_10_01_preview/aio/operations/__init__.py +++ b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/policy/v2015_10_01_preview/aio/operations/__init__.py @@ -9,7 +9,13 @@ from ._operations import PolicyAssignmentsOperations from ._operations import PolicyDefinitionsOperations +from ._patch import __all__ as _patch_all +from ._patch import * # type: ignore # pylint: disable=unused-wildcard-import +from ._patch import patch_sdk as _patch_sdk + __all__ = [ - 'PolicyAssignmentsOperations', - 'PolicyDefinitionsOperations', + "PolicyAssignmentsOperations", + "PolicyDefinitionsOperations", ] +__all__.extend([p for p in _patch_all if p not in __all__]) +_patch_sdk() diff --git a/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/policy/v2015_10_01_preview/aio/operations/_operations.py b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/policy/v2015_10_01_preview/aio/operations/_operations.py index 5d803aa245ce0..925d32aa6129b 100644 --- a/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/policy/v2015_10_01_preview/aio/operations/_operations.py +++ b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/policy/v2015_10_01_preview/aio/operations/_operations.py @@ -6,140 +6,230 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -from typing import Any, AsyncIterable, Callable, Dict, Optional, TypeVar +from typing import Any, AsyncIterable, Callable, Dict, IO, Optional, TypeVar, Union, overload +from urllib.parse import parse_qs, urljoin, urlparse from azure.core.async_paging import AsyncItemPaged, AsyncList -from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error +from azure.core.exceptions import ( + ClientAuthenticationError, + HttpResponseError, + ResourceExistsError, + ResourceNotFoundError, + ResourceNotModifiedError, + map_error, +) from azure.core.pipeline import PipelineResponse from azure.core.pipeline.transport import AsyncHttpResponse from azure.core.rest import HttpRequest from azure.core.tracing.decorator import distributed_trace from azure.core.tracing.decorator_async import distributed_trace_async +from azure.core.utils import case_insensitive_dict from azure.mgmt.core.exceptions import ARMErrorFormat from ... import models as _models from ..._vendor import _convert_request -from ...operations._operations import build_policy_assignments_create_by_id_request, build_policy_assignments_create_request, build_policy_assignments_delete_by_id_request, build_policy_assignments_delete_request, build_policy_assignments_get_by_id_request, build_policy_assignments_get_request, build_policy_assignments_list_for_resource_group_request, build_policy_assignments_list_for_resource_request, build_policy_assignments_list_request, build_policy_definitions_create_or_update_request, build_policy_definitions_delete_request, build_policy_definitions_get_request, build_policy_definitions_list_request -T = TypeVar('T') +from ...operations._operations import ( + build_policy_assignments_create_by_id_request, + build_policy_assignments_create_request, + build_policy_assignments_delete_by_id_request, + build_policy_assignments_delete_request, + build_policy_assignments_get_by_id_request, + build_policy_assignments_get_request, + build_policy_assignments_list_for_resource_group_request, + build_policy_assignments_list_for_resource_request, + build_policy_assignments_list_request, + build_policy_definitions_create_or_update_request, + build_policy_definitions_delete_request, + build_policy_definitions_get_request, + build_policy_definitions_list_request, +) + +T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] -class PolicyAssignmentsOperations: - """PolicyAssignmentsOperations async operations. - You should not instantiate this class directly. Instead, you should create a Client instance that - instantiates it for you and attaches it as an attribute. +class PolicyAssignmentsOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. - :ivar models: Alias to model classes used in this operation group. - :type models: ~azure.mgmt.resource.policy.v2015_10_01_preview.models - :param client: Client for service requests. - :param config: Configuration of service client. - :param serializer: An object model serializer. - :param deserializer: An object model deserializer. + Instead, you should access the following operations through + :class:`~azure.mgmt.resource.policy.v2015_10_01_preview.aio.PolicyClient`'s + :attr:`policy_assignments` attribute. """ models = _models - def __init__(self, client, config, serializer, deserializer) -> None: - self._client = client - self._serialize = serializer - self._deserialize = deserializer - self._config = config + def __init__(self, *args, **kwargs) -> None: + input_args = list(args) + self._client = input_args.pop(0) if input_args else kwargs.pop("client") + self._config = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") @distributed_trace_async - async def delete( - self, - scope: str, - policy_assignment_name: str, - **kwargs: Any - ) -> "_models.PolicyAssignment": + async def delete(self, scope: str, policy_assignment_name: str, **kwargs: Any) -> _models.PolicyAssignment: """Deletes a policy assignment. - :param scope: The scope of the policy assignment. + :param scope: The scope of the policy assignment. Required. :type scope: str - :param policy_assignment_name: The name of the policy assignment to delete. + :param policy_assignment_name: The name of the policy assignment to delete. Required. :type policy_assignment_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: PolicyAssignment, or the result of cls(response) + :return: PolicyAssignment or the result of cls(response) :rtype: ~azure.mgmt.resource.policy.v2015_10_01_preview.models.PolicyAssignment - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.PolicyAssignment"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) - api_version = kwargs.pop('api_version', "2015-10-01-preview") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2015-10-01-preview")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[_models.PolicyAssignment] - request = build_policy_assignments_delete_request( scope=scope, policy_assignment_name=policy_assignment_name, api_version=api_version, - template_url=self.delete.metadata['url'], + template_url=self.delete.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) - deserialized = self._deserialize('PolicyAssignment', pipeline_response) + deserialized = self._deserialize("PolicyAssignment", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - delete.metadata = {'url': "/{scope}/providers/Microsoft.Authorization/policyassignments/{policyAssignmentName}"} # type: ignore - + delete.metadata = {"url": "/{scope}/providers/Microsoft.Authorization/policyassignments/{policyAssignmentName}"} # type: ignore - @distributed_trace_async + @overload async def create( self, scope: str, policy_assignment_name: str, - parameters: "_models.PolicyAssignment", + parameters: _models.PolicyAssignment, *, - content_type: Optional[str] = "application/json", + content_type: str = "application/json", **kwargs: Any - ) -> "_models.PolicyAssignment": + ) -> _models.PolicyAssignment: """Creates a policy assignment. Policy assignments are inherited by child resources. For example, when you apply a policy to a resource group that policy is assigned to all resources in the group. - :param scope: The scope of the policy assignment. + :param scope: The scope of the policy assignment. Required. :type scope: str - :param policy_assignment_name: The name of the policy assignment. + :param policy_assignment_name: The name of the policy assignment. Required. :type policy_assignment_name: str - :param parameters: Parameters for the policy assignment. + :param parameters: Parameters for the policy assignment. Required. :type parameters: ~azure.mgmt.resource.policy.v2015_10_01_preview.models.PolicyAssignment - :keyword content_type: Media type of the body sent to the API. Possible values are: - "application/json" or "text/json". Default value is "application/json". + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: PolicyAssignment or the result of cls(response) + :rtype: ~azure.mgmt.resource.policy.v2015_10_01_preview.models.PolicyAssignment + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + async def create( + self, + scope: str, + policy_assignment_name: str, + parameters: IO, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.PolicyAssignment: + """Creates a policy assignment. + + Policy assignments are inherited by child resources. For example, when you apply a policy to a + resource group that policy is assigned to all resources in the group. + + :param scope: The scope of the policy assignment. Required. + :type scope: str + :param policy_assignment_name: The name of the policy assignment. Required. + :type policy_assignment_name: str + :param parameters: Parameters for the policy assignment. Required. + :type parameters: IO + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Known values are: 'application/json', 'text/json'. Default value is "application/json". :paramtype content_type: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: PolicyAssignment, or the result of cls(response) + :return: PolicyAssignment or the result of cls(response) :rtype: ~azure.mgmt.resource.policy.v2015_10_01_preview.models.PolicyAssignment - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace_async + async def create( + self, scope: str, policy_assignment_name: str, parameters: Union[_models.PolicyAssignment, IO], **kwargs: Any + ) -> _models.PolicyAssignment: + """Creates a policy assignment. + + Policy assignments are inherited by child resources. For example, when you apply a policy to a + resource group that policy is assigned to all resources in the group. + + :param scope: The scope of the policy assignment. Required. + :type scope: str + :param policy_assignment_name: The name of the policy assignment. Required. + :type policy_assignment_name: str + :param parameters: Parameters for the policy assignment. Is either a model type or a IO type. + Required. + :type parameters: ~azure.mgmt.resource.policy.v2015_10_01_preview.models.PolicyAssignment or IO + :keyword content_type: Body Parameter content-type. Known values are: 'application/json', + 'text/json'. Default value is None. + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: PolicyAssignment or the result of cls(response) + :rtype: ~azure.mgmt.resource.policy.v2015_10_01_preview.models.PolicyAssignment + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.PolicyAssignment"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', "2015-10-01-preview") # type: str + api_version = kwargs.pop("api_version", _params.pop("api-version", "2015-10-01-preview")) # type: str + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.PolicyAssignment] - _json = self._serialize.body(parameters, 'PolicyAssignment') + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(parameters, (IO, bytes)): + _content = parameters + else: + _json = self._serialize.body(parameters, "PolicyAssignment") request = build_policy_assignments_create_request( scope=scope, @@ -147,138 +237,144 @@ async def create( api_version=api_version, content_type=content_type, json=_json, - template_url=self.create.metadata['url'], + content=_content, + template_url=self.create.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [201]: map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) - deserialized = self._deserialize('PolicyAssignment', pipeline_response) + deserialized = self._deserialize("PolicyAssignment", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - create.metadata = {'url': "/{scope}/providers/Microsoft.Authorization/policyassignments/{policyAssignmentName}"} # type: ignore - + create.metadata = {"url": "/{scope}/providers/Microsoft.Authorization/policyassignments/{policyAssignmentName}"} # type: ignore @distributed_trace_async - async def get( - self, - scope: str, - policy_assignment_name: str, - **kwargs: Any - ) -> "_models.PolicyAssignment": + async def get(self, scope: str, policy_assignment_name: str, **kwargs: Any) -> _models.PolicyAssignment: """Gets a policy assignment. - :param scope: The scope of the policy assignment. + :param scope: The scope of the policy assignment. Required. :type scope: str - :param policy_assignment_name: The name of the policy assignment to get. + :param policy_assignment_name: The name of the policy assignment to get. Required. :type policy_assignment_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: PolicyAssignment, or the result of cls(response) + :return: PolicyAssignment or the result of cls(response) :rtype: ~azure.mgmt.resource.policy.v2015_10_01_preview.models.PolicyAssignment - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.PolicyAssignment"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) - api_version = kwargs.pop('api_version', "2015-10-01-preview") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2015-10-01-preview")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[_models.PolicyAssignment] - request = build_policy_assignments_get_request( scope=scope, policy_assignment_name=policy_assignment_name, api_version=api_version, - template_url=self.get.metadata['url'], + template_url=self.get.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) - deserialized = self._deserialize('PolicyAssignment', pipeline_response) + deserialized = self._deserialize("PolicyAssignment", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - get.metadata = {'url': "/{scope}/providers/Microsoft.Authorization/policyassignments/{policyAssignmentName}"} # type: ignore - + get.metadata = {"url": "/{scope}/providers/Microsoft.Authorization/policyassignments/{policyAssignmentName}"} # type: ignore @distributed_trace def list_for_resource_group( - self, - resource_group_name: str, - filter: Optional[str] = None, - **kwargs: Any - ) -> AsyncIterable["_models.PolicyAssignmentListResult"]: + self, resource_group_name: str, filter: Optional[str] = None, **kwargs: Any + ) -> AsyncIterable["_models.PolicyAssignment"]: """Gets policy assignments for the resource group. :param resource_group_name: The name of the resource group that contains policy assignments. + Required. :type resource_group_name: str :param filter: The filter to apply on the operation. Default value is None. :type filter: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either PolicyAssignmentListResult or the result of - cls(response) + :return: An iterator like instance of either PolicyAssignment or the result of cls(response) :rtype: - ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.resource.policy.v2015_10_01_preview.models.PolicyAssignmentListResult] - :raises: ~azure.core.exceptions.HttpResponseError + ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.resource.policy.v2015_10_01_preview.models.PolicyAssignment] + :raises ~azure.core.exceptions.HttpResponseError: """ - api_version = kwargs.pop('api_version', "2015-10-01-preview") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2015-10-01-preview")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[_models.PolicyAssignmentListResult] - cls = kwargs.pop('cls', None) # type: ClsType["_models.PolicyAssignmentListResult"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) + def prepare_request(next_link=None): if not next_link: - + request = build_policy_assignments_list_for_resource_group_request( resource_group_name=resource_group_name, subscription_id=self._config.subscription_id, - api_version=api_version, filter=filter, - template_url=self.list_for_resource_group.metadata['url'], + api_version=api_version, + template_url=self.list_for_resource_group.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore else: - - request = build_policy_assignments_list_for_resource_group_request( - resource_group_name=resource_group_name, - subscription_id=self._config.subscription_id, - template_url=next_link, - ) + # make call to next link with the client's api-version + _parsed_next_link = urlparse(next_link) + _next_request_params = case_insensitive_dict(parse_qs(_parsed_next_link.query)) + _next_request_params["api-version"] = self._config.api_version + request = HttpRequest("GET", urljoin(next_link, _parsed_next_link.path), params=_next_request_params) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore request.method = "GET" return request @@ -292,10 +388,8 @@ async def extract_data(pipeline_response): async def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) response = pipeline_response.http_response @@ -305,11 +399,9 @@ async def get_next(next_link=None): return pipeline_response + return AsyncItemPaged(get_next, extract_data) - return AsyncItemPaged( - get_next, extract_data - ) - list_for_resource_group.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Authorization/policyAssignments"} # type: ignore + list_for_resource_group.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Authorization/policyAssignments"} # type: ignore @distributed_trace def list_for_resource( @@ -321,39 +413,45 @@ def list_for_resource( resource_name: str, filter: Optional[str] = None, **kwargs: Any - ) -> AsyncIterable["_models.PolicyAssignmentListResult"]: + ) -> AsyncIterable["_models.PolicyAssignment"]: """Gets policy assignments for a resource. :param resource_group_name: The name of the resource group containing the resource. The name is - case insensitive. + case insensitive. Required. :type resource_group_name: str - :param resource_provider_namespace: The namespace of the resource provider. + :param resource_provider_namespace: The namespace of the resource provider. Required. :type resource_provider_namespace: str - :param parent_resource_path: The parent resource path. + :param parent_resource_path: The parent resource path. Required. :type parent_resource_path: str - :param resource_type: The resource type. + :param resource_type: The resource type. Required. :type resource_type: str - :param resource_name: The name of the resource with policy assignments. + :param resource_name: The name of the resource with policy assignments. Required. :type resource_name: str :param filter: The filter to apply on the operation. Default value is None. :type filter: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either PolicyAssignmentListResult or the result of - cls(response) + :return: An iterator like instance of either PolicyAssignment or the result of cls(response) :rtype: - ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.resource.policy.v2015_10_01_preview.models.PolicyAssignmentListResult] - :raises: ~azure.core.exceptions.HttpResponseError + ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.resource.policy.v2015_10_01_preview.models.PolicyAssignment] + :raises ~azure.core.exceptions.HttpResponseError: """ - api_version = kwargs.pop('api_version', "2015-10-01-preview") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2015-10-01-preview")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[_models.PolicyAssignmentListResult] - cls = kwargs.pop('cls', None) # type: ClsType["_models.PolicyAssignmentListResult"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) + def prepare_request(next_link=None): if not next_link: - + request = build_policy_assignments_list_for_resource_request( resource_group_name=resource_group_name, resource_provider_namespace=resource_provider_namespace, @@ -361,26 +459,23 @@ def prepare_request(next_link=None): resource_type=resource_type, resource_name=resource_name, subscription_id=self._config.subscription_id, - api_version=api_version, filter=filter, - template_url=self.list_for_resource.metadata['url'], + api_version=api_version, + template_url=self.list_for_resource.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore else: - - request = build_policy_assignments_list_for_resource_request( - resource_group_name=resource_group_name, - resource_provider_namespace=resource_provider_namespace, - parent_resource_path=parent_resource_path, - resource_type=resource_type, - resource_name=resource_name, - subscription_id=self._config.subscription_id, - template_url=next_link, - ) + # make call to next link with the client's api-version + _parsed_next_link = urlparse(next_link) + _next_request_params = case_insensitive_dict(parse_qs(_parsed_next_link.query)) + _next_request_params["api-version"] = self._config.api_version + request = HttpRequest("GET", urljoin(next_link, _parsed_next_link.path), params=_next_request_params) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore request.method = "GET" return request @@ -394,10 +489,8 @@ async def extract_data(pipeline_response): async def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) response = pipeline_response.http_response @@ -407,56 +500,58 @@ async def get_next(next_link=None): return pipeline_response + return AsyncItemPaged(get_next, extract_data) - return AsyncItemPaged( - get_next, extract_data - ) - list_for_resource.metadata = {'url': "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{parentResourcePath}/{resourceType}/{resourceName}/providers/Microsoft.Authorization/policyassignments"} # type: ignore + list_for_resource.metadata = {"url": "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{parentResourcePath}/{resourceType}/{resourceName}/providers/Microsoft.Authorization/policyassignments"} # type: ignore @distributed_trace - def list( - self, - filter: Optional[str] = None, - **kwargs: Any - ) -> AsyncIterable["_models.PolicyAssignmentListResult"]: + def list(self, filter: Optional[str] = None, **kwargs: Any) -> AsyncIterable["_models.PolicyAssignment"]: """Gets all the policy assignments for a subscription. :param filter: The filter to apply on the operation. Default value is None. :type filter: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either PolicyAssignmentListResult or the result of - cls(response) + :return: An iterator like instance of either PolicyAssignment or the result of cls(response) :rtype: - ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.resource.policy.v2015_10_01_preview.models.PolicyAssignmentListResult] - :raises: ~azure.core.exceptions.HttpResponseError + ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.resource.policy.v2015_10_01_preview.models.PolicyAssignment] + :raises ~azure.core.exceptions.HttpResponseError: """ - api_version = kwargs.pop('api_version', "2015-10-01-preview") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2015-10-01-preview")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[_models.PolicyAssignmentListResult] - cls = kwargs.pop('cls', None) # type: ClsType["_models.PolicyAssignmentListResult"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) + def prepare_request(next_link=None): if not next_link: - + request = build_policy_assignments_list_request( subscription_id=self._config.subscription_id, - api_version=api_version, filter=filter, - template_url=self.list.metadata['url'], + 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.url = self._client.format_url(request.url) # type: ignore else: - - request = build_policy_assignments_list_request( - subscription_id=self._config.subscription_id, - template_url=next_link, - ) + # make call to next link with the client's api-version + _parsed_next_link = urlparse(next_link) + _next_request_params = case_insensitive_dict(parse_qs(_parsed_next_link.query)) + _next_request_params["api-version"] = self._config.api_version + request = HttpRequest("GET", urljoin(next_link, _parsed_next_link.path), params=_next_request_params) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore request.method = "GET" return request @@ -470,10 +565,8 @@ async def extract_data(pipeline_response): async def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) response = pipeline_response.http_response @@ -483,18 +576,12 @@ async def get_next(next_link=None): return pipeline_response + return AsyncItemPaged(get_next, extract_data) - return AsyncItemPaged( - get_next, extract_data - ) - list.metadata = {'url': "/subscriptions/{subscriptionId}/providers/Microsoft.Authorization/policyassignments"} # type: ignore + list.metadata = {"url": "/subscriptions/{subscriptionId}/providers/Microsoft.Authorization/policyassignments"} # type: ignore @distributed_trace_async - async def delete_by_id( - self, - policy_assignment_id: str, - **kwargs: Any - ) -> "_models.PolicyAssignment": + async def delete_by_id(self, policy_assignment_id: str, **kwargs: Any) -> _models.PolicyAssignment: """Deletes a policy assignment by ID. When providing a scope for the assignment, use '/subscriptions/{subscription-id}/' for @@ -505,59 +592,65 @@ async def delete_by_id( :param policy_assignment_id: The ID of the policy assignment to delete. Use the format '/{scope}/providers/Microsoft.Authorization/policyAssignments/{policy-assignment-name}'. + Required. :type policy_assignment_id: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: PolicyAssignment, or the result of cls(response) + :return: PolicyAssignment or the result of cls(response) :rtype: ~azure.mgmt.resource.policy.v2015_10_01_preview.models.PolicyAssignment - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.PolicyAssignment"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) - api_version = kwargs.pop('api_version', "2015-10-01-preview") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2015-10-01-preview")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[_models.PolicyAssignment] - request = build_policy_assignments_delete_by_id_request( policy_assignment_id=policy_assignment_id, api_version=api_version, - template_url=self.delete_by_id.metadata['url'], + template_url=self.delete_by_id.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) - deserialized = self._deserialize('PolicyAssignment', pipeline_response) + deserialized = self._deserialize("PolicyAssignment", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - delete_by_id.metadata = {'url': "/{policyAssignmentId}"} # type: ignore - + delete_by_id.metadata = {"url": "/{policyAssignmentId}"} # type: ignore - @distributed_trace_async + @overload async def create_by_id( self, policy_assignment_id: str, - parameters: "_models.PolicyAssignment", + parameters: _models.PolicyAssignment, *, - content_type: Optional[str] = "application/json", + content_type: str = "application/json", **kwargs: Any - ) -> "_models.PolicyAssignment": + ) -> _models.PolicyAssignment: """Creates a policy assignment by ID. Policy assignments are inherited by child resources. For example, when you apply a policy to a @@ -570,64 +663,134 @@ async def create_by_id( :param policy_assignment_id: The ID of the policy assignment to create. Use the format '/{scope}/providers/Microsoft.Authorization/policyAssignments/{policy-assignment-name}'. + Required. :type policy_assignment_id: str - :param parameters: Parameters for policy assignment. + :param parameters: Parameters for policy assignment. Required. :type parameters: ~azure.mgmt.resource.policy.v2015_10_01_preview.models.PolicyAssignment - :keyword content_type: Media type of the body sent to the API. Possible values are: - "application/json" or "text/json". Default value is "application/json". + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". :paramtype content_type: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: PolicyAssignment, or the result of cls(response) + :return: PolicyAssignment or the result of cls(response) :rtype: ~azure.mgmt.resource.policy.v2015_10_01_preview.models.PolicyAssignment - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + async def create_by_id( + self, policy_assignment_id: str, parameters: IO, *, content_type: str = "application/json", **kwargs: Any + ) -> _models.PolicyAssignment: + """Creates a policy assignment by ID. + + Policy assignments are inherited by child resources. For example, when you apply a policy to a + resource group that policy is assigned to all resources in the group. When providing a scope + for the assignment, use '/subscriptions/{subscription-id}/' for subscriptions, + '/subscriptions/{subscription-id}/resourceGroups/{resource-group-name}' for resource groups, + and + '/subscriptions/{subscription-id}/resourceGroups/{resource-group-name}/providers/{resource-provider-namespace}/{resource-type}/{resource-name}' + for resources. + + :param policy_assignment_id: The ID of the policy assignment to create. Use the format + '/{scope}/providers/Microsoft.Authorization/policyAssignments/{policy-assignment-name}'. + Required. + :type policy_assignment_id: str + :param parameters: Parameters for policy assignment. Required. + :type parameters: IO + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Known values are: 'application/json', 'text/json'. Default value is "application/json". + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: PolicyAssignment or the result of cls(response) + :rtype: ~azure.mgmt.resource.policy.v2015_10_01_preview.models.PolicyAssignment + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace_async + async def create_by_id( + self, policy_assignment_id: str, parameters: Union[_models.PolicyAssignment, IO], **kwargs: Any + ) -> _models.PolicyAssignment: + """Creates a policy assignment by ID. + + Policy assignments are inherited by child resources. For example, when you apply a policy to a + resource group that policy is assigned to all resources in the group. When providing a scope + for the assignment, use '/subscriptions/{subscription-id}/' for subscriptions, + '/subscriptions/{subscription-id}/resourceGroups/{resource-group-name}' for resource groups, + and + '/subscriptions/{subscription-id}/resourceGroups/{resource-group-name}/providers/{resource-provider-namespace}/{resource-type}/{resource-name}' + for resources. + + :param policy_assignment_id: The ID of the policy assignment to create. Use the format + '/{scope}/providers/Microsoft.Authorization/policyAssignments/{policy-assignment-name}'. + Required. + :type policy_assignment_id: str + :param parameters: Parameters for policy assignment. Is either a model type or a IO type. + Required. + :type parameters: ~azure.mgmt.resource.policy.v2015_10_01_preview.models.PolicyAssignment or IO + :keyword content_type: Body Parameter content-type. Known values are: 'application/json', + 'text/json'. Default value is None. + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: PolicyAssignment or the result of cls(response) + :rtype: ~azure.mgmt.resource.policy.v2015_10_01_preview.models.PolicyAssignment + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.PolicyAssignment"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) - api_version = kwargs.pop('api_version', "2015-10-01-preview") # type: str + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - _json = self._serialize.body(parameters, 'PolicyAssignment') + api_version = kwargs.pop("api_version", _params.pop("api-version", "2015-10-01-preview")) # type: str + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.PolicyAssignment] + + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(parameters, (IO, bytes)): + _content = parameters + else: + _json = self._serialize.body(parameters, "PolicyAssignment") request = build_policy_assignments_create_by_id_request( policy_assignment_id=policy_assignment_id, api_version=api_version, content_type=content_type, json=_json, - template_url=self.create_by_id.metadata['url'], + content=_content, + template_url=self.create_by_id.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [201]: map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) - deserialized = self._deserialize('PolicyAssignment', pipeline_response) + deserialized = self._deserialize("PolicyAssignment", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - create_by_id.metadata = {'url': "/{policyAssignmentId}"} # type: ignore - + create_by_id.metadata = {"url": "/{policyAssignmentId}"} # type: ignore @distributed_trace_async - async def get_by_id( - self, - policy_assignment_id: str, - **kwargs: Any - ) -> "_models.PolicyAssignment": + async def get_by_id(self, policy_assignment_id: str, **kwargs: Any) -> _models.PolicyAssignment: """Gets a policy assignment by ID. When providing a scope for the assignment, use '/subscriptions/{subscription-id}/' for @@ -638,103 +801,160 @@ async def get_by_id( :param policy_assignment_id: The ID of the policy assignment to get. Use the format '/{scope}/providers/Microsoft.Authorization/policyAssignments/{policy-assignment-name}'. + Required. :type policy_assignment_id: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: PolicyAssignment, or the result of cls(response) + :return: PolicyAssignment or the result of cls(response) :rtype: ~azure.mgmt.resource.policy.v2015_10_01_preview.models.PolicyAssignment - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.PolicyAssignment"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) - api_version = kwargs.pop('api_version', "2015-10-01-preview") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2015-10-01-preview")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[_models.PolicyAssignment] - request = build_policy_assignments_get_by_id_request( policy_assignment_id=policy_assignment_id, api_version=api_version, - template_url=self.get_by_id.metadata['url'], + template_url=self.get_by_id.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) - deserialized = self._deserialize('PolicyAssignment', pipeline_response) + deserialized = self._deserialize("PolicyAssignment", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - get_by_id.metadata = {'url': "/{policyAssignmentId}"} # type: ignore + get_by_id.metadata = {"url": "/{policyAssignmentId}"} # type: ignore -class PolicyDefinitionsOperations: - """PolicyDefinitionsOperations async operations. - You should not instantiate this class directly. Instead, you should create a Client instance that - instantiates it for you and attaches it as an attribute. +class PolicyDefinitionsOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. - :ivar models: Alias to model classes used in this operation group. - :type models: ~azure.mgmt.resource.policy.v2015_10_01_preview.models - :param client: Client for service requests. - :param config: Configuration of service client. - :param serializer: An object model serializer. - :param deserializer: An object model deserializer. + Instead, you should access the following operations through + :class:`~azure.mgmt.resource.policy.v2015_10_01_preview.aio.PolicyClient`'s + :attr:`policy_definitions` attribute. """ models = _models - def __init__(self, client, config, serializer, deserializer) -> None: - self._client = client - self._serialize = serializer - self._deserialize = deserializer - self._config = config + def __init__(self, *args, **kwargs) -> None: + input_args = list(args) + self._client = input_args.pop(0) if input_args else kwargs.pop("client") + self._config = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") - @distributed_trace_async + @overload async def create_or_update( self, policy_definition_name: str, - parameters: "_models.PolicyDefinition", + parameters: _models.PolicyDefinition, *, - content_type: Optional[str] = "application/json", + content_type: str = "application/json", **kwargs: Any - ) -> "_models.PolicyDefinition": + ) -> _models.PolicyDefinition: """Creates or updates a policy definition. - :param policy_definition_name: The name of the policy definition to create. + :param policy_definition_name: The name of the policy definition to create. Required. :type policy_definition_name: str - :param parameters: The policy definition properties. + :param parameters: The policy definition properties. Required. :type parameters: ~azure.mgmt.resource.policy.v2015_10_01_preview.models.PolicyDefinition - :keyword content_type: Media type of the body sent to the API. Possible values are: - "application/json" or "text/json". Default value is "application/json". + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". :paramtype content_type: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: PolicyDefinition, or the result of cls(response) + :return: PolicyDefinition or the result of cls(response) :rtype: ~azure.mgmt.resource.policy.v2015_10_01_preview.models.PolicyDefinition - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + async def create_or_update( + self, policy_definition_name: str, parameters: IO, *, content_type: str = "application/json", **kwargs: Any + ) -> _models.PolicyDefinition: + """Creates or updates a policy definition. + + :param policy_definition_name: The name of the policy definition to create. Required. + :type policy_definition_name: str + :param parameters: The policy definition properties. Required. + :type parameters: IO + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Known values are: 'application/json', 'text/json'. Default value is "application/json". + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: PolicyDefinition or the result of cls(response) + :rtype: ~azure.mgmt.resource.policy.v2015_10_01_preview.models.PolicyDefinition + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace_async + async def create_or_update( + self, policy_definition_name: str, parameters: Union[_models.PolicyDefinition, IO], **kwargs: Any + ) -> _models.PolicyDefinition: + """Creates or updates a policy definition. + + :param policy_definition_name: The name of the policy definition to create. Required. + :type policy_definition_name: str + :param parameters: The policy definition properties. Is either a model type or a IO type. + Required. + :type parameters: ~azure.mgmt.resource.policy.v2015_10_01_preview.models.PolicyDefinition or IO + :keyword content_type: Body Parameter content-type. Known values are: 'application/json', + 'text/json'. Default value is None. + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: PolicyDefinition or the result of cls(response) + :rtype: ~azure.mgmt.resource.policy.v2015_10_01_preview.models.PolicyDefinition + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.PolicyDefinition"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) - api_version = kwargs.pop('api_version', "2015-10-01-preview") # type: str + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - _json = self._serialize.body(parameters, 'PolicyDefinition') + api_version = kwargs.pop("api_version", _params.pop("api-version", "2015-10-01-preview")) # type: str + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.PolicyDefinition] + + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(parameters, (IO, bytes)): + _content = parameters + else: + _json = self._serialize.body(parameters, "PolicyDefinition") request = build_policy_definitions_create_or_update_request( policy_definition_name=policy_definition_name, @@ -742,70 +962,75 @@ async def create_or_update( api_version=api_version, content_type=content_type, json=_json, - template_url=self.create_or_update.metadata['url'], + content=_content, + template_url=self.create_or_update.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [201]: map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) - deserialized = self._deserialize('PolicyDefinition', pipeline_response) + deserialized = self._deserialize("PolicyDefinition", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - create_or_update.metadata = {'url': "/subscriptions/{subscriptionId}/providers/Microsoft.Authorization/policydefinitions/{policyDefinitionName}"} # type: ignore - + create_or_update.metadata = {"url": "/subscriptions/{subscriptionId}/providers/Microsoft.Authorization/policydefinitions/{policyDefinitionName}"} # type: ignore @distributed_trace_async async def delete( # pylint: disable=inconsistent-return-statements - self, - policy_definition_name: str, - **kwargs: Any + self, policy_definition_name: str, **kwargs: Any ) -> None: """Deletes a policy definition. - :param policy_definition_name: The name of the policy definition to delete. + :param policy_definition_name: The name of the policy definition to delete. Required. :type policy_definition_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: None, or the result of cls(response) + :return: None or the result of cls(response) :rtype: None - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType[None] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) - api_version = kwargs.pop('api_version', "2015-10-01-preview") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2015-10-01-preview")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[None] - request = build_policy_definitions_delete_request( policy_definition_name=policy_definition_name, subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.delete.metadata['url'], + template_url=self.delete.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200, 204]: @@ -815,107 +1040,111 @@ async def delete( # pylint: disable=inconsistent-return-statements if cls: return cls(pipeline_response, None, {}) - delete.metadata = {'url': "/subscriptions/{subscriptionId}/providers/Microsoft.Authorization/policydefinitions/{policyDefinitionName}"} # type: ignore - + delete.metadata = {"url": "/subscriptions/{subscriptionId}/providers/Microsoft.Authorization/policydefinitions/{policyDefinitionName}"} # type: ignore @distributed_trace_async - async def get( - self, - policy_definition_name: str, - **kwargs: Any - ) -> "_models.PolicyDefinition": + async def get(self, policy_definition_name: str, **kwargs: Any) -> _models.PolicyDefinition: """Gets the policy definition. - :param policy_definition_name: The name of the policy definition to get. + :param policy_definition_name: The name of the policy definition to get. Required. :type policy_definition_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: PolicyDefinition, or the result of cls(response) + :return: PolicyDefinition or the result of cls(response) :rtype: ~azure.mgmt.resource.policy.v2015_10_01_preview.models.PolicyDefinition - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.PolicyDefinition"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) - api_version = kwargs.pop('api_version', "2015-10-01-preview") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2015-10-01-preview")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[_models.PolicyDefinition] - request = build_policy_definitions_get_request( policy_definition_name=policy_definition_name, subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.get.metadata['url'], + template_url=self.get.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) - deserialized = self._deserialize('PolicyDefinition', pipeline_response) + deserialized = self._deserialize("PolicyDefinition", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - get.metadata = {'url': "/subscriptions/{subscriptionId}/providers/Microsoft.Authorization/policydefinitions/{policyDefinitionName}"} # type: ignore - + get.metadata = {"url": "/subscriptions/{subscriptionId}/providers/Microsoft.Authorization/policydefinitions/{policyDefinitionName}"} # type: ignore @distributed_trace - def list( - self, - filter: Optional[str] = None, - **kwargs: Any - ) -> AsyncIterable["_models.PolicyDefinitionListResult"]: + def list(self, filter: Optional[str] = None, **kwargs: Any) -> AsyncIterable["_models.PolicyDefinition"]: """Gets all the policy definitions for a subscription. :param filter: The filter to apply on the operation. Default value is None. :type filter: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either PolicyDefinitionListResult or the result of - cls(response) + :return: An iterator like instance of either PolicyDefinition or the result of cls(response) :rtype: - ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.resource.policy.v2015_10_01_preview.models.PolicyDefinitionListResult] - :raises: ~azure.core.exceptions.HttpResponseError + ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.resource.policy.v2015_10_01_preview.models.PolicyDefinition] + :raises ~azure.core.exceptions.HttpResponseError: """ - api_version = kwargs.pop('api_version', "2015-10-01-preview") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2015-10-01-preview")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[_models.PolicyDefinitionListResult] - cls = kwargs.pop('cls', None) # type: ClsType["_models.PolicyDefinitionListResult"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) + def prepare_request(next_link=None): if not next_link: - + request = build_policy_definitions_list_request( subscription_id=self._config.subscription_id, - api_version=api_version, filter=filter, - template_url=self.list.metadata['url'], + 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.url = self._client.format_url(request.url) # type: ignore else: - - request = build_policy_definitions_list_request( - subscription_id=self._config.subscription_id, - template_url=next_link, - ) + # make call to next link with the client's api-version + _parsed_next_link = urlparse(next_link) + _next_request_params = case_insensitive_dict(parse_qs(_parsed_next_link.query)) + _next_request_params["api-version"] = self._config.api_version + request = HttpRequest("GET", urljoin(next_link, _parsed_next_link.path), params=_next_request_params) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore request.method = "GET" return request @@ -929,10 +1158,8 @@ async def extract_data(pipeline_response): async def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) response = pipeline_response.http_response @@ -942,8 +1169,6 @@ async def get_next(next_link=None): return pipeline_response + return AsyncItemPaged(get_next, extract_data) - return AsyncItemPaged( - get_next, extract_data - ) - list.metadata = {'url': "/subscriptions/{subscriptionId}/providers/Microsoft.Authorization/policydefinitions"} # type: ignore + list.metadata = {"url": "/subscriptions/{subscriptionId}/providers/Microsoft.Authorization/policydefinitions"} # type: ignore diff --git a/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/policy/v2015_10_01_preview/aio/operations/_patch.py b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/policy/v2015_10_01_preview/aio/operations/_patch.py new file mode 100644 index 0000000000000..f7dd32510333d --- /dev/null +++ b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/policy/v2015_10_01_preview/aio/operations/_patch.py @@ -0,0 +1,20 @@ +# ------------------------------------ +# Copyright (c) Microsoft Corporation. +# Licensed under the MIT License. +# ------------------------------------ +"""Customize generated code here. + +Follow our quickstart for examples: https://aka.ms/azsdk/python/dpcodegen/python/customize +""" +from typing import List + +__all__: List[str] = [] # Add all objects you want publicly available to users at this package level + + +def patch_sdk(): + """Do not remove from this file. + + `patch_sdk` is a last resort escape hatch that allows you to do customizations + you can't accomplish using the techniques described in + https://aka.ms/azsdk/python/dpcodegen/python/customize + """ diff --git a/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/policy/v2015_10_01_preview/models/__init__.py b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/policy/v2015_10_01_preview/models/__init__.py index f43cdc9ba8b0d..4303a55b1742d 100644 --- a/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/policy/v2015_10_01_preview/models/__init__.py +++ b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/policy/v2015_10_01_preview/models/__init__.py @@ -11,15 +11,17 @@ from ._models_py3 import PolicyDefinition from ._models_py3 import PolicyDefinitionListResult - -from ._policy_client_enums import ( - PolicyType, -) +from ._policy_client_enums import PolicyType +from ._patch import __all__ as _patch_all +from ._patch import * # type: ignore # pylint: disable=unused-wildcard-import +from ._patch import patch_sdk as _patch_sdk __all__ = [ - 'PolicyAssignment', - 'PolicyAssignmentListResult', - 'PolicyDefinition', - 'PolicyDefinitionListResult', - 'PolicyType', + "PolicyAssignment", + "PolicyAssignmentListResult", + "PolicyDefinition", + "PolicyDefinitionListResult", + "PolicyType", ] +__all__.extend([p for p in _patch_all if p not in __all__]) +_patch_sdk() diff --git a/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/policy/v2015_10_01_preview/models/_models_py3.py b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/policy/v2015_10_01_preview/models/_models_py3.py index bbbad547ee0a8..336f7dd43a109 100644 --- a/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/policy/v2015_10_01_preview/models/_models_py3.py +++ b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/policy/v2015_10_01_preview/models/_models_py3.py @@ -1,4 +1,5 @@ # coding=utf-8 +# pylint: disable=too-many-lines # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. # Licensed under the MIT License. See License.txt in the project root for license information. @@ -6,14 +7,22 @@ # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -from typing import Any, List, Optional, Union +import sys +from typing import Any, List, Optional, TYPE_CHECKING, Union -import msrest.serialization +from ... import _serialization -from ._policy_client_enums import * +if TYPE_CHECKING: + # pylint: disable=unused-import,ungrouped-imports + from .. import models as _models +if sys.version_info >= (3, 9): + from collections.abc import MutableMapping +else: + from typing import MutableMapping # type: ignore # pylint: disable=ungrouped-imports +JSON = MutableMapping[str, Any] # pylint: disable=unsubscriptable-object -class PolicyAssignment(msrest.serialization.Model): +class PolicyAssignment(_serialization.Model): """The policy assignment. :ivar id: The ID of the policy assignment. @@ -31,18 +40,18 @@ class PolicyAssignment(msrest.serialization.Model): """ _attribute_map = { - 'id': {'key': 'id', 'type': 'str'}, - 'type': {'key': 'type', 'type': 'str'}, - 'name': {'key': 'name', 'type': 'str'}, - 'display_name': {'key': 'properties.displayName', 'type': 'str'}, - 'policy_definition_id': {'key': 'properties.policyDefinitionId', 'type': 'str'}, - 'scope': {'key': 'properties.scope', 'type': 'str'}, + "id": {"key": "id", "type": "str"}, + "type": {"key": "type", "type": "str"}, + "name": {"key": "name", "type": "str"}, + "display_name": {"key": "properties.displayName", "type": "str"}, + "policy_definition_id": {"key": "properties.policyDefinitionId", "type": "str"}, + "scope": {"key": "properties.scope", "type": "str"}, } def __init__( self, *, - id: Optional[str] = None, + id: Optional[str] = None, # pylint: disable=redefined-builtin type: Optional[str] = None, name: Optional[str] = None, display_name: Optional[str] = None, @@ -64,7 +73,7 @@ def __init__( :keyword scope: The scope for the policy assignment. :paramtype scope: str """ - super(PolicyAssignment, self).__init__(**kwargs) + super().__init__(**kwargs) self.id = id self.type = type self.name = name @@ -73,7 +82,7 @@ def __init__( self.scope = scope -class PolicyAssignmentListResult(msrest.serialization.Model): +class PolicyAssignmentListResult(_serialization.Model): """List of policy assignments. :ivar value: An array of policy assignments. @@ -83,16 +92,12 @@ class PolicyAssignmentListResult(msrest.serialization.Model): """ _attribute_map = { - 'value': {'key': 'value', 'type': '[PolicyAssignment]'}, - 'next_link': {'key': 'nextLink', 'type': 'str'}, + "value": {"key": "value", "type": "[PolicyAssignment]"}, + "next_link": {"key": "nextLink", "type": "str"}, } def __init__( - self, - *, - value: Optional[List["PolicyAssignment"]] = None, - next_link: Optional[str] = None, - **kwargs + self, *, value: Optional[List["_models.PolicyAssignment"]] = None, next_link: Optional[str] = None, **kwargs ): """ :keyword value: An array of policy assignments. @@ -100,12 +105,12 @@ def __init__( :keyword next_link: The URL to use for getting the next set of results. :paramtype next_link: str """ - super(PolicyAssignmentListResult, self).__init__(**kwargs) + super().__init__(**kwargs) self.value = value self.next_link = next_link -class PolicyDefinition(msrest.serialization.Model): +class PolicyDefinition(_serialization.Model): """The policy definition. Variables are only populated by the server, and will be ignored when sending a request. @@ -116,37 +121,37 @@ class PolicyDefinition(msrest.serialization.Model): value is inferred from the name value in the request URI. :vartype name: str :ivar policy_type: The type of policy definition. Possible values are NotSpecified, BuiltIn, - and Custom. Possible values include: "NotSpecified", "BuiltIn", "Custom". + and Custom. Known values are: "NotSpecified", "BuiltIn", and "Custom". :vartype policy_type: str or ~azure.mgmt.resource.policy.v2015_10_01_preview.models.PolicyType :ivar display_name: The display name of the policy definition. :vartype display_name: str :ivar description: The policy definition description. :vartype description: str :ivar policy_rule: The policy rule. - :vartype policy_rule: any + :vartype policy_rule: JSON """ _validation = { - 'id': {'readonly': True}, + "id": {"readonly": True}, } _attribute_map = { - 'id': {'key': 'id', 'type': 'str'}, - 'name': {'key': 'name', 'type': 'str'}, - 'policy_type': {'key': 'properties.policyType', 'type': 'str'}, - 'display_name': {'key': 'properties.displayName', 'type': 'str'}, - 'description': {'key': 'properties.description', 'type': 'str'}, - 'policy_rule': {'key': 'properties.policyRule', 'type': 'object'}, + "id": {"key": "id", "type": "str"}, + "name": {"key": "name", "type": "str"}, + "policy_type": {"key": "properties.policyType", "type": "str"}, + "display_name": {"key": "properties.displayName", "type": "str"}, + "description": {"key": "properties.description", "type": "str"}, + "policy_rule": {"key": "properties.policyRule", "type": "object"}, } def __init__( self, *, name: Optional[str] = None, - policy_type: Optional[Union[str, "PolicyType"]] = None, + policy_type: Optional[Union[str, "_models.PolicyType"]] = None, display_name: Optional[str] = None, description: Optional[str] = None, - policy_rule: Optional[Any] = None, + policy_rule: Optional[JSON] = None, **kwargs ): """ @@ -154,7 +159,7 @@ def __init__( value is inferred from the name value in the request URI. :paramtype name: str :keyword policy_type: The type of policy definition. Possible values are NotSpecified, BuiltIn, - and Custom. Possible values include: "NotSpecified", "BuiltIn", "Custom". + and Custom. Known values are: "NotSpecified", "BuiltIn", and "Custom". :paramtype policy_type: str or ~azure.mgmt.resource.policy.v2015_10_01_preview.models.PolicyType :keyword display_name: The display name of the policy definition. @@ -162,9 +167,9 @@ def __init__( :keyword description: The policy definition description. :paramtype description: str :keyword policy_rule: The policy rule. - :paramtype policy_rule: any + :paramtype policy_rule: JSON """ - super(PolicyDefinition, self).__init__(**kwargs) + super().__init__(**kwargs) self.id = None self.name = name self.policy_type = policy_type @@ -173,7 +178,7 @@ def __init__( self.policy_rule = policy_rule -class PolicyDefinitionListResult(msrest.serialization.Model): +class PolicyDefinitionListResult(_serialization.Model): """List of policy definitions. :ivar value: An array of policy definitions. @@ -183,16 +188,12 @@ class PolicyDefinitionListResult(msrest.serialization.Model): """ _attribute_map = { - 'value': {'key': 'value', 'type': '[PolicyDefinition]'}, - 'next_link': {'key': 'nextLink', 'type': 'str'}, + "value": {"key": "value", "type": "[PolicyDefinition]"}, + "next_link": {"key": "nextLink", "type": "str"}, } def __init__( - self, - *, - value: Optional[List["PolicyDefinition"]] = None, - next_link: Optional[str] = None, - **kwargs + self, *, value: Optional[List["_models.PolicyDefinition"]] = None, next_link: Optional[str] = None, **kwargs ): """ :keyword value: An array of policy definitions. @@ -200,6 +201,6 @@ def __init__( :keyword next_link: The URL to use for getting the next set of results. :paramtype next_link: str """ - super(PolicyDefinitionListResult, self).__init__(**kwargs) + super().__init__(**kwargs) self.value = value self.next_link = next_link diff --git a/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/policy/v2015_10_01_preview/models/_patch.py b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/policy/v2015_10_01_preview/models/_patch.py new file mode 100644 index 0000000000000..f7dd32510333d --- /dev/null +++ b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/policy/v2015_10_01_preview/models/_patch.py @@ -0,0 +1,20 @@ +# ------------------------------------ +# Copyright (c) Microsoft Corporation. +# Licensed under the MIT License. +# ------------------------------------ +"""Customize generated code here. + +Follow our quickstart for examples: https://aka.ms/azsdk/python/dpcodegen/python/customize +""" +from typing import List + +__all__: List[str] = [] # Add all objects you want publicly available to users at this package level + + +def patch_sdk(): + """Do not remove from this file. + + `patch_sdk` is a last resort escape hatch that allows you to do customizations + you can't accomplish using the techniques described in + https://aka.ms/azsdk/python/dpcodegen/python/customize + """ diff --git a/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/policy/v2015_10_01_preview/models/_policy_client_enums.py b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/policy/v2015_10_01_preview/models/_policy_client_enums.py index b6d41257fadba..91c08bdc295c3 100644 --- a/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/policy/v2015_10_01_preview/models/_policy_client_enums.py +++ b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/policy/v2015_10_01_preview/models/_policy_client_enums.py @@ -7,13 +7,11 @@ # -------------------------------------------------------------------------- from enum import Enum -from six import with_metaclass from azure.core import CaseInsensitiveEnumMeta -class PolicyType(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): - """The type of policy definition. Possible values are NotSpecified, BuiltIn, and Custom. - """ +class PolicyType(str, Enum, metaclass=CaseInsensitiveEnumMeta): + """The type of policy definition. Possible values are NotSpecified, BuiltIn, and Custom.""" NOT_SPECIFIED = "NotSpecified" BUILT_IN = "BuiltIn" diff --git a/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/policy/v2015_10_01_preview/operations/__init__.py b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/policy/v2015_10_01_preview/operations/__init__.py index 33ee2baf02338..1feb25bc4bdb2 100644 --- a/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/policy/v2015_10_01_preview/operations/__init__.py +++ b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/policy/v2015_10_01_preview/operations/__init__.py @@ -9,7 +9,13 @@ from ._operations import PolicyAssignmentsOperations from ._operations import PolicyDefinitionsOperations +from ._patch import __all__ as _patch_all +from ._patch import * # type: ignore # pylint: disable=unused-wildcard-import +from ._patch import patch_sdk as _patch_sdk + __all__ = [ - 'PolicyAssignmentsOperations', - 'PolicyDefinitionsOperations', + "PolicyAssignmentsOperations", + "PolicyDefinitionsOperations", ] +__all__.extend([p for p in _patch_all if p not in __all__]) +_patch_sdk() diff --git a/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/policy/v2015_10_01_preview/operations/_operations.py b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/policy/v2015_10_01_preview/operations/_operations.py index d5efdf3c9e569..847be88b91e79 100644 --- a/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/policy/v2015_10_01_preview/operations/_operations.py +++ b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/policy/v2015_10_01_preview/operations/_operations.py @@ -6,173 +6,152 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -from typing import Any, Callable, Dict, Iterable, Optional, TypeVar - -from msrest import Serializer - -from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error +from typing import Any, Callable, Dict, IO, Iterable, Optional, TypeVar, Union, overload +from urllib.parse import parse_qs, urljoin, urlparse + +from azure.core.exceptions import ( + ClientAuthenticationError, + HttpResponseError, + ResourceExistsError, + ResourceNotFoundError, + ResourceNotModifiedError, + map_error, +) from azure.core.paging import ItemPaged from azure.core.pipeline import PipelineResponse from azure.core.pipeline.transport import HttpResponse from azure.core.rest import HttpRequest from azure.core.tracing.decorator import distributed_trace +from azure.core.utils import case_insensitive_dict from azure.mgmt.core.exceptions import ARMErrorFormat from .. import models as _models +from ..._serialization import Serializer from .._vendor import _convert_request, _format_url_section -T = TypeVar('T') -JSONType = Any + +T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] _SERIALIZER = Serializer() _SERIALIZER.client_side_validation = False -def build_policy_assignments_delete_request( - scope: str, - policy_assignment_name: str, - **kwargs: Any -) -> HttpRequest: - api_version = kwargs.pop('api_version', "2015-10-01-preview") # type: str - accept = "application/json, text/json" +def build_policy_assignments_delete_request(scope: str, policy_assignment_name: 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", "2015-10-01-preview")) # type: str + accept = _headers.pop("Accept", "application/json, text/json") + # Construct URL - _url = kwargs.pop("template_url", "/{scope}/providers/Microsoft.Authorization/policyassignments/{policyAssignmentName}") + _url = kwargs.pop( + "template_url", "/{scope}/providers/Microsoft.Authorization/policyassignments/{policyAssignmentName}" + ) path_format_arguments = { - "scope": _SERIALIZER.url("scope", scope, 'str', skip_quote=True), - "policyAssignmentName": _SERIALIZER.url("policy_assignment_name", policy_assignment_name, 'str'), + "scope": _SERIALIZER.url("scope", scope, "str", skip_quote=True), + "policyAssignmentName": _SERIALIZER.url("policy_assignment_name", policy_assignment_name, "str"), } _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') - - return HttpRequest( - method="DELETE", - url=_url, - params=_query_parameters, - headers=_header_parameters, - **kwargs - ) + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + return HttpRequest(method="DELETE", url=_url, params=_params, headers=_headers, **kwargs) -def build_policy_assignments_create_request( - scope: str, - policy_assignment_name: str, - *, - json: JSONType = None, - content: Any = None, - **kwargs: Any -) -> HttpRequest: - api_version = kwargs.pop('api_version', "2015-10-01-preview") # type: str - content_type = kwargs.pop('content_type', None) # type: Optional[str] - accept = "application/json, text/json" +def build_policy_assignments_create_request(scope: str, policy_assignment_name: 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", "2015-10-01-preview")) # type: str + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + accept = _headers.pop("Accept", "application/json, text/json") + # Construct URL - _url = kwargs.pop("template_url", "/{scope}/providers/Microsoft.Authorization/policyassignments/{policyAssignmentName}") + _url = kwargs.pop( + "template_url", "/{scope}/providers/Microsoft.Authorization/policyassignments/{policyAssignmentName}" + ) path_format_arguments = { - "scope": _SERIALIZER.url("scope", scope, 'str', skip_quote=True), - "policyAssignmentName": _SERIALIZER.url("policy_assignment_name", policy_assignment_name, 'str'), + "scope": _SERIALIZER.url("scope", scope, "str", skip_quote=True), + "policyAssignmentName": _SERIALIZER.url("policy_assignment_name", policy_assignment_name, "str"), } _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] if content_type is not None: - _header_parameters['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') - _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') - - return HttpRequest( - method="PUT", - url=_url, - params=_query_parameters, - headers=_header_parameters, - json=json, - content=content, - **kwargs - ) + _headers["Content-Type"] = _SERIALIZER.header("content_type", content_type, "str") + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + return HttpRequest(method="PUT", url=_url, params=_params, headers=_headers, **kwargs) -def build_policy_assignments_get_request( - scope: str, - policy_assignment_name: str, - **kwargs: Any -) -> HttpRequest: - api_version = kwargs.pop('api_version', "2015-10-01-preview") # type: str - accept = "application/json, text/json" +def build_policy_assignments_get_request(scope: str, policy_assignment_name: 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", "2015-10-01-preview")) # type: str + accept = _headers.pop("Accept", "application/json, text/json") + # Construct URL - _url = kwargs.pop("template_url", "/{scope}/providers/Microsoft.Authorization/policyassignments/{policyAssignmentName}") + _url = kwargs.pop( + "template_url", "/{scope}/providers/Microsoft.Authorization/policyassignments/{policyAssignmentName}" + ) path_format_arguments = { - "scope": _SERIALIZER.url("scope", scope, 'str', skip_quote=True), - "policyAssignmentName": _SERIALIZER.url("policy_assignment_name", policy_assignment_name, 'str'), + "scope": _SERIALIZER.url("scope", scope, "str", skip_quote=True), + "policyAssignmentName": _SERIALIZER.url("policy_assignment_name", policy_assignment_name, "str"), } _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') - - return HttpRequest( - method="GET", - url=_url, - params=_query_parameters, - headers=_header_parameters, - **kwargs - ) + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) def build_policy_assignments_list_for_resource_group_request( - resource_group_name: str, - subscription_id: str, - *, - filter: Optional[str] = None, - **kwargs: Any + resource_group_name: str, subscription_id: str, *, filter: Optional[str] = None, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2015-10-01-preview") # type: 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", "2015-10-01-preview")) # type: str + accept = _headers.pop("Accept", "application/json, text/json") - accept = "application/json, text/json" # Construct URL - _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Authorization/policyAssignments") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Authorization/policyAssignments", + ) # pylint: disable=line-too-long path_format_arguments = { - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._\(\)]+$'), - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), + "resourceGroupName": _SERIALIZER.url( + "resource_group_name", resource_group_name, "str", max_length=90, min_length=1, pattern=r"^[-\w\._\(\)]+$" + ), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), } _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] if filter is not None: - _query_parameters['$filter'] = _SERIALIZER.query("filter", filter, 'str', skip_quote=True) - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["$filter"] = _SERIALIZER.query("filter", filter, "str", skip_quote=True) + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') - - return HttpRequest( - method="GET", - url=_url, - params=_query_parameters, - headers=_header_parameters, - **kwargs - ) + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) def build_policy_assignments_list_for_resource_request( @@ -186,437 +165,445 @@ def build_policy_assignments_list_for_resource_request( filter: Optional[str] = None, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2015-10-01-preview") # type: 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", "2015-10-01-preview")) # type: str + accept = _headers.pop("Accept", "application/json, text/json") - accept = "application/json, text/json" # Construct URL - _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{parentResourcePath}/{resourceType}/{resourceName}/providers/Microsoft.Authorization/policyassignments") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{parentResourcePath}/{resourceType}/{resourceName}/providers/Microsoft.Authorization/policyassignments", + ) # pylint: disable=line-too-long path_format_arguments = { - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._\(\)]+$'), - "resourceProviderNamespace": _SERIALIZER.url("resource_provider_namespace", resource_provider_namespace, 'str'), - "parentResourcePath": _SERIALIZER.url("parent_resource_path", parent_resource_path, 'str', skip_quote=True), - "resourceType": _SERIALIZER.url("resource_type", resource_type, 'str', skip_quote=True), - "resourceName": _SERIALIZER.url("resource_name", resource_name, 'str'), - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), + "resourceGroupName": _SERIALIZER.url( + "resource_group_name", resource_group_name, "str", max_length=90, min_length=1, pattern=r"^[-\w\._\(\)]+$" + ), + "resourceProviderNamespace": _SERIALIZER.url("resource_provider_namespace", resource_provider_namespace, "str"), + "parentResourcePath": _SERIALIZER.url("parent_resource_path", parent_resource_path, "str", skip_quote=True), + "resourceType": _SERIALIZER.url("resource_type", resource_type, "str", skip_quote=True), + "resourceName": _SERIALIZER.url("resource_name", resource_name, "str"), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), } _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] if filter is not None: - _query_parameters['$filter'] = _SERIALIZER.query("filter", filter, 'str') - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["$filter"] = _SERIALIZER.query("filter", filter, "str") + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') - - return HttpRequest( - method="GET", - url=_url, - params=_query_parameters, - headers=_header_parameters, - **kwargs - ) + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) def build_policy_assignments_list_request( - subscription_id: str, - *, - filter: Optional[str] = None, - **kwargs: Any + subscription_id: str, *, filter: Optional[str] = None, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2015-10-01-preview") # type: 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", "2015-10-01-preview")) # type: str + accept = _headers.pop("Accept", "application/json, text/json") - accept = "application/json, text/json" # Construct URL - _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/providers/Microsoft.Authorization/policyassignments") + _url = kwargs.pop( + "template_url", "/subscriptions/{subscriptionId}/providers/Microsoft.Authorization/policyassignments" + ) path_format_arguments = { - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), } _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] if filter is not None: - _query_parameters['$filter'] = _SERIALIZER.query("filter", filter, 'str') - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["$filter"] = _SERIALIZER.query("filter", filter, "str") + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') - - return HttpRequest( - method="GET", - url=_url, - params=_query_parameters, - headers=_header_parameters, - **kwargs - ) + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) -def build_policy_assignments_delete_by_id_request( - policy_assignment_id: str, - **kwargs: Any -) -> HttpRequest: - api_version = kwargs.pop('api_version', "2015-10-01-preview") # type: str - accept = "application/json, text/json" +def build_policy_assignments_delete_by_id_request(policy_assignment_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", "2015-10-01-preview")) # type: str + accept = _headers.pop("Accept", "application/json, text/json") + # Construct URL _url = kwargs.pop("template_url", "/{policyAssignmentId}") path_format_arguments = { - "policyAssignmentId": _SERIALIZER.url("policy_assignment_id", policy_assignment_id, 'str', skip_quote=True), + "policyAssignmentId": _SERIALIZER.url("policy_assignment_id", policy_assignment_id, "str", skip_quote=True), } _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') - - return HttpRequest( - method="DELETE", - url=_url, - params=_query_parameters, - headers=_header_parameters, - **kwargs - ) + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + return HttpRequest(method="DELETE", url=_url, params=_params, headers=_headers, **kwargs) -def build_policy_assignments_create_by_id_request( - policy_assignment_id: str, - *, - json: JSONType = None, - content: Any = None, - **kwargs: Any -) -> HttpRequest: - api_version = kwargs.pop('api_version', "2015-10-01-preview") # type: str - content_type = kwargs.pop('content_type', None) # type: Optional[str] - accept = "application/json, text/json" +def build_policy_assignments_create_by_id_request(policy_assignment_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", "2015-10-01-preview")) # type: str + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + accept = _headers.pop("Accept", "application/json, text/json") + # Construct URL _url = kwargs.pop("template_url", "/{policyAssignmentId}") path_format_arguments = { - "policyAssignmentId": _SERIALIZER.url("policy_assignment_id", policy_assignment_id, 'str', skip_quote=True), + "policyAssignmentId": _SERIALIZER.url("policy_assignment_id", policy_assignment_id, "str", skip_quote=True), } _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] if content_type is not None: - _header_parameters['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') - _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') - - return HttpRequest( - method="PUT", - url=_url, - params=_query_parameters, - headers=_header_parameters, - json=json, - content=content, - **kwargs - ) + _headers["Content-Type"] = _SERIALIZER.header("content_type", content_type, "str") + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + return HttpRequest(method="PUT", url=_url, params=_params, headers=_headers, **kwargs) -def build_policy_assignments_get_by_id_request( - policy_assignment_id: str, - **kwargs: Any -) -> HttpRequest: - api_version = kwargs.pop('api_version', "2015-10-01-preview") # type: str - accept = "application/json, text/json" +def build_policy_assignments_get_by_id_request(policy_assignment_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", "2015-10-01-preview")) # type: str + accept = _headers.pop("Accept", "application/json, text/json") + # Construct URL _url = kwargs.pop("template_url", "/{policyAssignmentId}") path_format_arguments = { - "policyAssignmentId": _SERIALIZER.url("policy_assignment_id", policy_assignment_id, 'str', skip_quote=True), + "policyAssignmentId": _SERIALIZER.url("policy_assignment_id", policy_assignment_id, "str", skip_quote=True), } _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') - - return HttpRequest( - method="GET", - url=_url, - params=_query_parameters, - headers=_header_parameters, - **kwargs - ) + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) def build_policy_definitions_create_or_update_request( - policy_definition_name: str, - subscription_id: str, - *, - json: JSONType = None, - content: Any = None, - **kwargs: Any + policy_definition_name: str, subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2015-10-01-preview") # type: str - content_type = kwargs.pop('content_type', None) # type: Optional[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", "2015-10-01-preview")) # type: str + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + accept = _headers.pop("Accept", "application/json, text/json") - accept = "application/json, text/json" # Construct URL - _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/providers/Microsoft.Authorization/policydefinitions/{policyDefinitionName}") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/providers/Microsoft.Authorization/policydefinitions/{policyDefinitionName}", + ) # pylint: disable=line-too-long path_format_arguments = { - "policyDefinitionName": _SERIALIZER.url("policy_definition_name", policy_definition_name, 'str'), - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), + "policyDefinitionName": _SERIALIZER.url("policy_definition_name", policy_definition_name, "str"), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), } _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] if content_type is not None: - _header_parameters['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') - _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') - - return HttpRequest( - method="PUT", - url=_url, - params=_query_parameters, - headers=_header_parameters, - json=json, - content=content, - **kwargs - ) + _headers["Content-Type"] = _SERIALIZER.header("content_type", content_type, "str") + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="PUT", url=_url, params=_params, headers=_headers, **kwargs) def build_policy_definitions_delete_request( - policy_definition_name: str, - subscription_id: str, - **kwargs: Any + policy_definition_name: str, subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2015-10-01-preview") # type: str + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + api_version = kwargs.pop("api_version", _params.pop("api-version", "2015-10-01-preview")) # type: str # Construct URL - _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/providers/Microsoft.Authorization/policydefinitions/{policyDefinitionName}") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/providers/Microsoft.Authorization/policydefinitions/{policyDefinitionName}", + ) # pylint: disable=line-too-long path_format_arguments = { - "policyDefinitionName": _SERIALIZER.url("policy_definition_name", policy_definition_name, 'str'), - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), + "policyDefinitionName": _SERIALIZER.url("policy_definition_name", policy_definition_name, "str"), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), } _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') - - return HttpRequest( - method="DELETE", - url=_url, - params=_query_parameters, - **kwargs - ) + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") + + return HttpRequest(method="DELETE", url=_url, params=_params, **kwargs) def build_policy_definitions_get_request( - policy_definition_name: str, - subscription_id: str, - **kwargs: Any + policy_definition_name: str, subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2015-10-01-preview") # type: 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", "2015-10-01-preview")) # type: str + accept = _headers.pop("Accept", "application/json, text/json") - accept = "application/json, text/json" # Construct URL - _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/providers/Microsoft.Authorization/policydefinitions/{policyDefinitionName}") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/providers/Microsoft.Authorization/policydefinitions/{policyDefinitionName}", + ) # pylint: disable=line-too-long path_format_arguments = { - "policyDefinitionName": _SERIALIZER.url("policy_definition_name", policy_definition_name, 'str'), - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), + "policyDefinitionName": _SERIALIZER.url("policy_definition_name", policy_definition_name, "str"), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), } _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') - - return HttpRequest( - method="GET", - url=_url, - params=_query_parameters, - headers=_header_parameters, - **kwargs - ) + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) def build_policy_definitions_list_request( - subscription_id: str, - *, - filter: Optional[str] = None, - **kwargs: Any + subscription_id: str, *, filter: Optional[str] = None, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2015-10-01-preview") # type: 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", "2015-10-01-preview")) # type: str + accept = _headers.pop("Accept", "application/json, text/json") - accept = "application/json, text/json" # Construct URL - _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/providers/Microsoft.Authorization/policydefinitions") + _url = kwargs.pop( + "template_url", "/subscriptions/{subscriptionId}/providers/Microsoft.Authorization/policydefinitions" + ) path_format_arguments = { - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), } _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] if filter is not None: - _query_parameters['$filter'] = _SERIALIZER.query("filter", filter, 'str') - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["$filter"] = _SERIALIZER.query("filter", filter, "str") + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') - - return HttpRequest( - method="GET", - url=_url, - params=_query_parameters, - headers=_header_parameters, - **kwargs - ) + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") -class PolicyAssignmentsOperations(object): - """PolicyAssignmentsOperations operations. + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) - You should not instantiate this class directly. Instead, you should create a Client instance that - instantiates it for you and attaches it as an attribute. - :ivar models: Alias to model classes used in this operation group. - :type models: ~azure.mgmt.resource.policy.v2015_10_01_preview.models - :param client: Client for service requests. - :param config: Configuration of service client. - :param serializer: An object model serializer. - :param deserializer: An object model deserializer. +class PolicyAssignmentsOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. + + Instead, you should access the following operations through + :class:`~azure.mgmt.resource.policy.v2015_10_01_preview.PolicyClient`'s + :attr:`policy_assignments` attribute. """ models = _models - def __init__(self, client, config, serializer, deserializer): - self._client = client - self._serialize = serializer - self._deserialize = deserializer - self._config = config + def __init__(self, *args, **kwargs): + input_args = list(args) + self._client = input_args.pop(0) if input_args else kwargs.pop("client") + self._config = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") @distributed_trace - def delete( - self, - scope: str, - policy_assignment_name: str, - **kwargs: Any - ) -> "_models.PolicyAssignment": + def delete(self, scope: str, policy_assignment_name: str, **kwargs: Any) -> _models.PolicyAssignment: """Deletes a policy assignment. - :param scope: The scope of the policy assignment. + :param scope: The scope of the policy assignment. Required. :type scope: str - :param policy_assignment_name: The name of the policy assignment to delete. + :param policy_assignment_name: The name of the policy assignment to delete. Required. :type policy_assignment_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: PolicyAssignment, or the result of cls(response) + :return: PolicyAssignment or the result of cls(response) :rtype: ~azure.mgmt.resource.policy.v2015_10_01_preview.models.PolicyAssignment - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.PolicyAssignment"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) - api_version = kwargs.pop('api_version', "2015-10-01-preview") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2015-10-01-preview")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[_models.PolicyAssignment] - request = build_policy_assignments_delete_request( scope=scope, policy_assignment_name=policy_assignment_name, api_version=api_version, - template_url=self.delete.metadata['url'], + template_url=self.delete.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) - deserialized = self._deserialize('PolicyAssignment', pipeline_response) + deserialized = self._deserialize("PolicyAssignment", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - delete.metadata = {'url': "/{scope}/providers/Microsoft.Authorization/policyassignments/{policyAssignmentName}"} # type: ignore - + delete.metadata = {"url": "/{scope}/providers/Microsoft.Authorization/policyassignments/{policyAssignmentName}"} # type: ignore - @distributed_trace + @overload def create( self, scope: str, policy_assignment_name: str, - parameters: "_models.PolicyAssignment", + parameters: _models.PolicyAssignment, *, - content_type: Optional[str] = "application/json", + content_type: str = "application/json", **kwargs: Any - ) -> "_models.PolicyAssignment": + ) -> _models.PolicyAssignment: """Creates a policy assignment. Policy assignments are inherited by child resources. For example, when you apply a policy to a resource group that policy is assigned to all resources in the group. - :param scope: The scope of the policy assignment. + :param scope: The scope of the policy assignment. Required. :type scope: str - :param policy_assignment_name: The name of the policy assignment. + :param policy_assignment_name: The name of the policy assignment. Required. :type policy_assignment_name: str - :param parameters: Parameters for the policy assignment. + :param parameters: Parameters for the policy assignment. Required. :type parameters: ~azure.mgmt.resource.policy.v2015_10_01_preview.models.PolicyAssignment - :keyword content_type: Media type of the body sent to the API. Possible values are: - "application/json" or "text/json". Default value is "application/json". + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: PolicyAssignment or the result of cls(response) + :rtype: ~azure.mgmt.resource.policy.v2015_10_01_preview.models.PolicyAssignment + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + def create( + self, + scope: str, + policy_assignment_name: str, + parameters: IO, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.PolicyAssignment: + """Creates a policy assignment. + + Policy assignments are inherited by child resources. For example, when you apply a policy to a + resource group that policy is assigned to all resources in the group. + + :param scope: The scope of the policy assignment. Required. + :type scope: str + :param policy_assignment_name: The name of the policy assignment. Required. + :type policy_assignment_name: str + :param parameters: Parameters for the policy assignment. Required. + :type parameters: IO + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Known values are: 'application/json', 'text/json'. Default value is "application/json". + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: PolicyAssignment or the result of cls(response) + :rtype: ~azure.mgmt.resource.policy.v2015_10_01_preview.models.PolicyAssignment + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace + def create( + self, scope: str, policy_assignment_name: str, parameters: Union[_models.PolicyAssignment, IO], **kwargs: Any + ) -> _models.PolicyAssignment: + """Creates a policy assignment. + + Policy assignments are inherited by child resources. For example, when you apply a policy to a + resource group that policy is assigned to all resources in the group. + + :param scope: The scope of the policy assignment. Required. + :type scope: str + :param policy_assignment_name: The name of the policy assignment. Required. + :type policy_assignment_name: str + :param parameters: Parameters for the policy assignment. Is either a model type or a IO type. + Required. + :type parameters: ~azure.mgmt.resource.policy.v2015_10_01_preview.models.PolicyAssignment or IO + :keyword content_type: Body Parameter content-type. Known values are: 'application/json', + 'text/json'. Default value is None. :paramtype content_type: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: PolicyAssignment, or the result of cls(response) + :return: PolicyAssignment or the result of cls(response) :rtype: ~azure.mgmt.resource.policy.v2015_10_01_preview.models.PolicyAssignment - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.PolicyAssignment"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', "2015-10-01-preview") # type: str + api_version = kwargs.pop("api_version", _params.pop("api-version", "2015-10-01-preview")) # type: str + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.PolicyAssignment] - _json = self._serialize.body(parameters, 'PolicyAssignment') + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(parameters, (IO, bytes)): + _content = parameters + else: + _json = self._serialize.body(parameters, "PolicyAssignment") request = build_policy_assignments_create_request( scope=scope, @@ -624,138 +611,144 @@ def create( api_version=api_version, content_type=content_type, json=_json, - template_url=self.create.metadata['url'], + content=_content, + template_url=self.create.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [201]: map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) - deserialized = self._deserialize('PolicyAssignment', pipeline_response) + deserialized = self._deserialize("PolicyAssignment", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - create.metadata = {'url': "/{scope}/providers/Microsoft.Authorization/policyassignments/{policyAssignmentName}"} # type: ignore - + create.metadata = {"url": "/{scope}/providers/Microsoft.Authorization/policyassignments/{policyAssignmentName}"} # type: ignore @distributed_trace - def get( - self, - scope: str, - policy_assignment_name: str, - **kwargs: Any - ) -> "_models.PolicyAssignment": + def get(self, scope: str, policy_assignment_name: str, **kwargs: Any) -> _models.PolicyAssignment: """Gets a policy assignment. - :param scope: The scope of the policy assignment. + :param scope: The scope of the policy assignment. Required. :type scope: str - :param policy_assignment_name: The name of the policy assignment to get. + :param policy_assignment_name: The name of the policy assignment to get. Required. :type policy_assignment_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: PolicyAssignment, or the result of cls(response) + :return: PolicyAssignment or the result of cls(response) :rtype: ~azure.mgmt.resource.policy.v2015_10_01_preview.models.PolicyAssignment - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.PolicyAssignment"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) - api_version = kwargs.pop('api_version', "2015-10-01-preview") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2015-10-01-preview")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[_models.PolicyAssignment] - request = build_policy_assignments_get_request( scope=scope, policy_assignment_name=policy_assignment_name, api_version=api_version, - template_url=self.get.metadata['url'], + template_url=self.get.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) - deserialized = self._deserialize('PolicyAssignment', pipeline_response) + deserialized = self._deserialize("PolicyAssignment", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - get.metadata = {'url': "/{scope}/providers/Microsoft.Authorization/policyassignments/{policyAssignmentName}"} # type: ignore - + get.metadata = {"url": "/{scope}/providers/Microsoft.Authorization/policyassignments/{policyAssignmentName}"} # type: ignore @distributed_trace def list_for_resource_group( - self, - resource_group_name: str, - filter: Optional[str] = None, - **kwargs: Any - ) -> Iterable["_models.PolicyAssignmentListResult"]: + self, resource_group_name: str, filter: Optional[str] = None, **kwargs: Any + ) -> Iterable["_models.PolicyAssignment"]: """Gets policy assignments for the resource group. :param resource_group_name: The name of the resource group that contains policy assignments. + Required. :type resource_group_name: str :param filter: The filter to apply on the operation. Default value is None. :type filter: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either PolicyAssignmentListResult or the result of - cls(response) + :return: An iterator like instance of either PolicyAssignment or the result of cls(response) :rtype: - ~azure.core.paging.ItemPaged[~azure.mgmt.resource.policy.v2015_10_01_preview.models.PolicyAssignmentListResult] - :raises: ~azure.core.exceptions.HttpResponseError + ~azure.core.paging.ItemPaged[~azure.mgmt.resource.policy.v2015_10_01_preview.models.PolicyAssignment] + :raises ~azure.core.exceptions.HttpResponseError: """ - api_version = kwargs.pop('api_version', "2015-10-01-preview") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2015-10-01-preview")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[_models.PolicyAssignmentListResult] - cls = kwargs.pop('cls', None) # type: ClsType["_models.PolicyAssignmentListResult"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) + def prepare_request(next_link=None): if not next_link: - + request = build_policy_assignments_list_for_resource_group_request( resource_group_name=resource_group_name, subscription_id=self._config.subscription_id, - api_version=api_version, filter=filter, - template_url=self.list_for_resource_group.metadata['url'], + api_version=api_version, + template_url=self.list_for_resource_group.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore else: - - request = build_policy_assignments_list_for_resource_group_request( - resource_group_name=resource_group_name, - subscription_id=self._config.subscription_id, - template_url=next_link, - ) + # make call to next link with the client's api-version + _parsed_next_link = urlparse(next_link) + _next_request_params = case_insensitive_dict(parse_qs(_parsed_next_link.query)) + _next_request_params["api-version"] = self._config.api_version + request = HttpRequest("GET", urljoin(next_link, _parsed_next_link.path), params=_next_request_params) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore request.method = "GET" return request @@ -769,10 +762,8 @@ def extract_data(pipeline_response): def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) response = pipeline_response.http_response @@ -782,11 +773,9 @@ def get_next(next_link=None): return pipeline_response + return ItemPaged(get_next, extract_data) - return ItemPaged( - get_next, extract_data - ) - list_for_resource_group.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Authorization/policyAssignments"} # type: ignore + list_for_resource_group.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Authorization/policyAssignments"} # type: ignore @distributed_trace def list_for_resource( @@ -798,39 +787,45 @@ def list_for_resource( resource_name: str, filter: Optional[str] = None, **kwargs: Any - ) -> Iterable["_models.PolicyAssignmentListResult"]: + ) -> Iterable["_models.PolicyAssignment"]: """Gets policy assignments for a resource. :param resource_group_name: The name of the resource group containing the resource. The name is - case insensitive. + case insensitive. Required. :type resource_group_name: str - :param resource_provider_namespace: The namespace of the resource provider. + :param resource_provider_namespace: The namespace of the resource provider. Required. :type resource_provider_namespace: str - :param parent_resource_path: The parent resource path. + :param parent_resource_path: The parent resource path. Required. :type parent_resource_path: str - :param resource_type: The resource type. + :param resource_type: The resource type. Required. :type resource_type: str - :param resource_name: The name of the resource with policy assignments. + :param resource_name: The name of the resource with policy assignments. Required. :type resource_name: str :param filter: The filter to apply on the operation. Default value is None. :type filter: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either PolicyAssignmentListResult or the result of - cls(response) + :return: An iterator like instance of either PolicyAssignment or the result of cls(response) :rtype: - ~azure.core.paging.ItemPaged[~azure.mgmt.resource.policy.v2015_10_01_preview.models.PolicyAssignmentListResult] - :raises: ~azure.core.exceptions.HttpResponseError + ~azure.core.paging.ItemPaged[~azure.mgmt.resource.policy.v2015_10_01_preview.models.PolicyAssignment] + :raises ~azure.core.exceptions.HttpResponseError: """ - api_version = kwargs.pop('api_version', "2015-10-01-preview") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2015-10-01-preview")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[_models.PolicyAssignmentListResult] - cls = kwargs.pop('cls', None) # type: ClsType["_models.PolicyAssignmentListResult"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) + def prepare_request(next_link=None): if not next_link: - + request = build_policy_assignments_list_for_resource_request( resource_group_name=resource_group_name, resource_provider_namespace=resource_provider_namespace, @@ -838,26 +833,23 @@ def prepare_request(next_link=None): resource_type=resource_type, resource_name=resource_name, subscription_id=self._config.subscription_id, - api_version=api_version, filter=filter, - template_url=self.list_for_resource.metadata['url'], + api_version=api_version, + template_url=self.list_for_resource.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore else: - - request = build_policy_assignments_list_for_resource_request( - resource_group_name=resource_group_name, - resource_provider_namespace=resource_provider_namespace, - parent_resource_path=parent_resource_path, - resource_type=resource_type, - resource_name=resource_name, - subscription_id=self._config.subscription_id, - template_url=next_link, - ) + # make call to next link with the client's api-version + _parsed_next_link = urlparse(next_link) + _next_request_params = case_insensitive_dict(parse_qs(_parsed_next_link.query)) + _next_request_params["api-version"] = self._config.api_version + request = HttpRequest("GET", urljoin(next_link, _parsed_next_link.path), params=_next_request_params) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore request.method = "GET" return request @@ -871,10 +863,8 @@ def extract_data(pipeline_response): def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) response = pipeline_response.http_response @@ -884,56 +874,58 @@ def get_next(next_link=None): return pipeline_response + return ItemPaged(get_next, extract_data) - return ItemPaged( - get_next, extract_data - ) - list_for_resource.metadata = {'url': "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{parentResourcePath}/{resourceType}/{resourceName}/providers/Microsoft.Authorization/policyassignments"} # type: ignore + list_for_resource.metadata = {"url": "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{parentResourcePath}/{resourceType}/{resourceName}/providers/Microsoft.Authorization/policyassignments"} # type: ignore @distributed_trace - def list( - self, - filter: Optional[str] = None, - **kwargs: Any - ) -> Iterable["_models.PolicyAssignmentListResult"]: + def list(self, filter: Optional[str] = None, **kwargs: Any) -> Iterable["_models.PolicyAssignment"]: """Gets all the policy assignments for a subscription. :param filter: The filter to apply on the operation. Default value is None. :type filter: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either PolicyAssignmentListResult or the result of - cls(response) + :return: An iterator like instance of either PolicyAssignment or the result of cls(response) :rtype: - ~azure.core.paging.ItemPaged[~azure.mgmt.resource.policy.v2015_10_01_preview.models.PolicyAssignmentListResult] - :raises: ~azure.core.exceptions.HttpResponseError + ~azure.core.paging.ItemPaged[~azure.mgmt.resource.policy.v2015_10_01_preview.models.PolicyAssignment] + :raises ~azure.core.exceptions.HttpResponseError: """ - api_version = kwargs.pop('api_version', "2015-10-01-preview") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2015-10-01-preview")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[_models.PolicyAssignmentListResult] - cls = kwargs.pop('cls', None) # type: ClsType["_models.PolicyAssignmentListResult"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) + def prepare_request(next_link=None): if not next_link: - + request = build_policy_assignments_list_request( subscription_id=self._config.subscription_id, - api_version=api_version, filter=filter, - template_url=self.list.metadata['url'], + 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.url = self._client.format_url(request.url) # type: ignore else: - - request = build_policy_assignments_list_request( - subscription_id=self._config.subscription_id, - template_url=next_link, - ) + # make call to next link with the client's api-version + _parsed_next_link = urlparse(next_link) + _next_request_params = case_insensitive_dict(parse_qs(_parsed_next_link.query)) + _next_request_params["api-version"] = self._config.api_version + request = HttpRequest("GET", urljoin(next_link, _parsed_next_link.path), params=_next_request_params) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore request.method = "GET" return request @@ -947,10 +939,8 @@ def extract_data(pipeline_response): def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) response = pipeline_response.http_response @@ -960,18 +950,12 @@ def get_next(next_link=None): return pipeline_response + return ItemPaged(get_next, extract_data) - return ItemPaged( - get_next, extract_data - ) - list.metadata = {'url': "/subscriptions/{subscriptionId}/providers/Microsoft.Authorization/policyassignments"} # type: ignore + list.metadata = {"url": "/subscriptions/{subscriptionId}/providers/Microsoft.Authorization/policyassignments"} # type: ignore @distributed_trace - def delete_by_id( - self, - policy_assignment_id: str, - **kwargs: Any - ) -> "_models.PolicyAssignment": + def delete_by_id(self, policy_assignment_id: str, **kwargs: Any) -> _models.PolicyAssignment: """Deletes a policy assignment by ID. When providing a scope for the assignment, use '/subscriptions/{subscription-id}/' for @@ -982,59 +966,65 @@ def delete_by_id( :param policy_assignment_id: The ID of the policy assignment to delete. Use the format '/{scope}/providers/Microsoft.Authorization/policyAssignments/{policy-assignment-name}'. + Required. :type policy_assignment_id: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: PolicyAssignment, or the result of cls(response) + :return: PolicyAssignment or the result of cls(response) :rtype: ~azure.mgmt.resource.policy.v2015_10_01_preview.models.PolicyAssignment - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.PolicyAssignment"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) - api_version = kwargs.pop('api_version', "2015-10-01-preview") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2015-10-01-preview")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[_models.PolicyAssignment] - request = build_policy_assignments_delete_by_id_request( policy_assignment_id=policy_assignment_id, api_version=api_version, - template_url=self.delete_by_id.metadata['url'], + template_url=self.delete_by_id.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) - deserialized = self._deserialize('PolicyAssignment', pipeline_response) + deserialized = self._deserialize("PolicyAssignment", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - delete_by_id.metadata = {'url': "/{policyAssignmentId}"} # type: ignore + delete_by_id.metadata = {"url": "/{policyAssignmentId}"} # type: ignore - - @distributed_trace + @overload def create_by_id( self, policy_assignment_id: str, - parameters: "_models.PolicyAssignment", + parameters: _models.PolicyAssignment, *, - content_type: Optional[str] = "application/json", + content_type: str = "application/json", **kwargs: Any - ) -> "_models.PolicyAssignment": + ) -> _models.PolicyAssignment: """Creates a policy assignment by ID. Policy assignments are inherited by child resources. For example, when you apply a policy to a @@ -1047,64 +1037,134 @@ def create_by_id( :param policy_assignment_id: The ID of the policy assignment to create. Use the format '/{scope}/providers/Microsoft.Authorization/policyAssignments/{policy-assignment-name}'. + Required. :type policy_assignment_id: str - :param parameters: Parameters for policy assignment. + :param parameters: Parameters for policy assignment. Required. :type parameters: ~azure.mgmt.resource.policy.v2015_10_01_preview.models.PolicyAssignment - :keyword content_type: Media type of the body sent to the API. Possible values are: - "application/json" or "text/json". Default value is "application/json". + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: PolicyAssignment or the result of cls(response) + :rtype: ~azure.mgmt.resource.policy.v2015_10_01_preview.models.PolicyAssignment + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + def create_by_id( + self, policy_assignment_id: str, parameters: IO, *, content_type: str = "application/json", **kwargs: Any + ) -> _models.PolicyAssignment: + """Creates a policy assignment by ID. + + Policy assignments are inherited by child resources. For example, when you apply a policy to a + resource group that policy is assigned to all resources in the group. When providing a scope + for the assignment, use '/subscriptions/{subscription-id}/' for subscriptions, + '/subscriptions/{subscription-id}/resourceGroups/{resource-group-name}' for resource groups, + and + '/subscriptions/{subscription-id}/resourceGroups/{resource-group-name}/providers/{resource-provider-namespace}/{resource-type}/{resource-name}' + for resources. + + :param policy_assignment_id: The ID of the policy assignment to create. Use the format + '/{scope}/providers/Microsoft.Authorization/policyAssignments/{policy-assignment-name}'. + Required. + :type policy_assignment_id: str + :param parameters: Parameters for policy assignment. Required. + :type parameters: IO + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Known values are: 'application/json', 'text/json'. Default value is "application/json". :paramtype content_type: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: PolicyAssignment, or the result of cls(response) + :return: PolicyAssignment or the result of cls(response) :rtype: ~azure.mgmt.resource.policy.v2015_10_01_preview.models.PolicyAssignment - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace + def create_by_id( + self, policy_assignment_id: str, parameters: Union[_models.PolicyAssignment, IO], **kwargs: Any + ) -> _models.PolicyAssignment: + """Creates a policy assignment by ID. + + Policy assignments are inherited by child resources. For example, when you apply a policy to a + resource group that policy is assigned to all resources in the group. When providing a scope + for the assignment, use '/subscriptions/{subscription-id}/' for subscriptions, + '/subscriptions/{subscription-id}/resourceGroups/{resource-group-name}' for resource groups, + and + '/subscriptions/{subscription-id}/resourceGroups/{resource-group-name}/providers/{resource-provider-namespace}/{resource-type}/{resource-name}' + for resources. + + :param policy_assignment_id: The ID of the policy assignment to create. Use the format + '/{scope}/providers/Microsoft.Authorization/policyAssignments/{policy-assignment-name}'. + Required. + :type policy_assignment_id: str + :param parameters: Parameters for policy assignment. Is either a model type or a IO type. + Required. + :type parameters: ~azure.mgmt.resource.policy.v2015_10_01_preview.models.PolicyAssignment or IO + :keyword content_type: Body Parameter content-type. Known values are: 'application/json', + 'text/json'. Default value is None. + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: PolicyAssignment or the result of cls(response) + :rtype: ~azure.mgmt.resource.policy.v2015_10_01_preview.models.PolicyAssignment + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.PolicyAssignment"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', "2015-10-01-preview") # type: str + api_version = kwargs.pop("api_version", _params.pop("api-version", "2015-10-01-preview")) # type: str + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.PolicyAssignment] - _json = self._serialize.body(parameters, 'PolicyAssignment') + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(parameters, (IO, bytes)): + _content = parameters + else: + _json = self._serialize.body(parameters, "PolicyAssignment") request = build_policy_assignments_create_by_id_request( policy_assignment_id=policy_assignment_id, api_version=api_version, content_type=content_type, json=_json, - template_url=self.create_by_id.metadata['url'], + content=_content, + template_url=self.create_by_id.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [201]: map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) - deserialized = self._deserialize('PolicyAssignment', pipeline_response) + deserialized = self._deserialize("PolicyAssignment", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - create_by_id.metadata = {'url': "/{policyAssignmentId}"} # type: ignore - + create_by_id.metadata = {"url": "/{policyAssignmentId}"} # type: ignore @distributed_trace - def get_by_id( - self, - policy_assignment_id: str, - **kwargs: Any - ) -> "_models.PolicyAssignment": + def get_by_id(self, policy_assignment_id: str, **kwargs: Any) -> _models.PolicyAssignment: """Gets a policy assignment by ID. When providing a scope for the assignment, use '/subscriptions/{subscription-id}/' for @@ -1115,103 +1175,160 @@ def get_by_id( :param policy_assignment_id: The ID of the policy assignment to get. Use the format '/{scope}/providers/Microsoft.Authorization/policyAssignments/{policy-assignment-name}'. + Required. :type policy_assignment_id: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: PolicyAssignment, or the result of cls(response) + :return: PolicyAssignment or the result of cls(response) :rtype: ~azure.mgmt.resource.policy.v2015_10_01_preview.models.PolicyAssignment - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.PolicyAssignment"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + 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', "2015-10-01-preview") # type: str + api_version = kwargs.pop("api_version", _params.pop("api-version", "2015-10-01-preview")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[_models.PolicyAssignment] - request = build_policy_assignments_get_by_id_request( policy_assignment_id=policy_assignment_id, api_version=api_version, - template_url=self.get_by_id.metadata['url'], + template_url=self.get_by_id.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) - deserialized = self._deserialize('PolicyAssignment', pipeline_response) + deserialized = self._deserialize("PolicyAssignment", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - get_by_id.metadata = {'url': "/{policyAssignmentId}"} # type: ignore + get_by_id.metadata = {"url": "/{policyAssignmentId}"} # type: ignore -class PolicyDefinitionsOperations(object): - """PolicyDefinitionsOperations operations. - You should not instantiate this class directly. Instead, you should create a Client instance that - instantiates it for you and attaches it as an attribute. +class PolicyDefinitionsOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. - :ivar models: Alias to model classes used in this operation group. - :type models: ~azure.mgmt.resource.policy.v2015_10_01_preview.models - :param client: Client for service requests. - :param config: Configuration of service client. - :param serializer: An object model serializer. - :param deserializer: An object model deserializer. + Instead, you should access the following operations through + :class:`~azure.mgmt.resource.policy.v2015_10_01_preview.PolicyClient`'s + :attr:`policy_definitions` attribute. """ models = _models - def __init__(self, client, config, serializer, deserializer): - self._client = client - self._serialize = serializer - self._deserialize = deserializer - self._config = config + def __init__(self, *args, **kwargs): + input_args = list(args) + self._client = input_args.pop(0) if input_args else kwargs.pop("client") + self._config = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") - @distributed_trace + @overload def create_or_update( self, policy_definition_name: str, - parameters: "_models.PolicyDefinition", + parameters: _models.PolicyDefinition, *, - content_type: Optional[str] = "application/json", + content_type: str = "application/json", **kwargs: Any - ) -> "_models.PolicyDefinition": + ) -> _models.PolicyDefinition: """Creates or updates a policy definition. - :param policy_definition_name: The name of the policy definition to create. + :param policy_definition_name: The name of the policy definition to create. Required. :type policy_definition_name: str - :param parameters: The policy definition properties. + :param parameters: The policy definition properties. Required. :type parameters: ~azure.mgmt.resource.policy.v2015_10_01_preview.models.PolicyDefinition - :keyword content_type: Media type of the body sent to the API. Possible values are: - "application/json" or "text/json". Default value is "application/json". + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: PolicyDefinition or the result of cls(response) + :rtype: ~azure.mgmt.resource.policy.v2015_10_01_preview.models.PolicyDefinition + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + def create_or_update( + self, policy_definition_name: str, parameters: IO, *, content_type: str = "application/json", **kwargs: Any + ) -> _models.PolicyDefinition: + """Creates or updates a policy definition. + + :param policy_definition_name: The name of the policy definition to create. Required. + :type policy_definition_name: str + :param parameters: The policy definition properties. Required. + :type parameters: IO + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Known values are: 'application/json', 'text/json'. Default value is "application/json". + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: PolicyDefinition or the result of cls(response) + :rtype: ~azure.mgmt.resource.policy.v2015_10_01_preview.models.PolicyDefinition + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace + def create_or_update( + self, policy_definition_name: str, parameters: Union[_models.PolicyDefinition, IO], **kwargs: Any + ) -> _models.PolicyDefinition: + """Creates or updates a policy definition. + + :param policy_definition_name: The name of the policy definition to create. Required. + :type policy_definition_name: str + :param parameters: The policy definition properties. Is either a model type or a IO type. + Required. + :type parameters: ~azure.mgmt.resource.policy.v2015_10_01_preview.models.PolicyDefinition or IO + :keyword content_type: Body Parameter content-type. Known values are: 'application/json', + 'text/json'. Default value is None. :paramtype content_type: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: PolicyDefinition, or the result of cls(response) + :return: PolicyDefinition or the result of cls(response) :rtype: ~azure.mgmt.resource.policy.v2015_10_01_preview.models.PolicyDefinition - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.PolicyDefinition"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) - api_version = kwargs.pop('api_version', "2015-10-01-preview") # type: str + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - _json = self._serialize.body(parameters, 'PolicyDefinition') + api_version = kwargs.pop("api_version", _params.pop("api-version", "2015-10-01-preview")) # type: str + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.PolicyDefinition] + + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(parameters, (IO, bytes)): + _content = parameters + else: + _json = self._serialize.body(parameters, "PolicyDefinition") request = build_policy_definitions_create_or_update_request( policy_definition_name=policy_definition_name, @@ -1219,70 +1336,75 @@ def create_or_update( api_version=api_version, content_type=content_type, json=_json, - template_url=self.create_or_update.metadata['url'], + content=_content, + template_url=self.create_or_update.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [201]: map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) - deserialized = self._deserialize('PolicyDefinition', pipeline_response) + deserialized = self._deserialize("PolicyDefinition", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - create_or_update.metadata = {'url': "/subscriptions/{subscriptionId}/providers/Microsoft.Authorization/policydefinitions/{policyDefinitionName}"} # type: ignore - + create_or_update.metadata = {"url": "/subscriptions/{subscriptionId}/providers/Microsoft.Authorization/policydefinitions/{policyDefinitionName}"} # type: ignore @distributed_trace def delete( # pylint: disable=inconsistent-return-statements - self, - policy_definition_name: str, - **kwargs: Any + self, policy_definition_name: str, **kwargs: Any ) -> None: """Deletes a policy definition. - :param policy_definition_name: The name of the policy definition to delete. + :param policy_definition_name: The name of the policy definition to delete. Required. :type policy_definition_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: None, or the result of cls(response) + :return: None or the result of cls(response) :rtype: None - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType[None] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) - api_version = kwargs.pop('api_version', "2015-10-01-preview") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2015-10-01-preview")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[None] - request = build_policy_definitions_delete_request( policy_definition_name=policy_definition_name, subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.delete.metadata['url'], + template_url=self.delete.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200, 204]: @@ -1292,107 +1414,111 @@ def delete( # pylint: disable=inconsistent-return-statements if cls: return cls(pipeline_response, None, {}) - delete.metadata = {'url': "/subscriptions/{subscriptionId}/providers/Microsoft.Authorization/policydefinitions/{policyDefinitionName}"} # type: ignore - + delete.metadata = {"url": "/subscriptions/{subscriptionId}/providers/Microsoft.Authorization/policydefinitions/{policyDefinitionName}"} # type: ignore @distributed_trace - def get( - self, - policy_definition_name: str, - **kwargs: Any - ) -> "_models.PolicyDefinition": + def get(self, policy_definition_name: str, **kwargs: Any) -> _models.PolicyDefinition: """Gets the policy definition. - :param policy_definition_name: The name of the policy definition to get. + :param policy_definition_name: The name of the policy definition to get. Required. :type policy_definition_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: PolicyDefinition, or the result of cls(response) + :return: PolicyDefinition or the result of cls(response) :rtype: ~azure.mgmt.resource.policy.v2015_10_01_preview.models.PolicyDefinition - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.PolicyDefinition"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + 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', "2015-10-01-preview") # type: str + api_version = kwargs.pop("api_version", _params.pop("api-version", "2015-10-01-preview")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[_models.PolicyDefinition] - request = build_policy_definitions_get_request( policy_definition_name=policy_definition_name, subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.get.metadata['url'], + template_url=self.get.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) - deserialized = self._deserialize('PolicyDefinition', pipeline_response) + deserialized = self._deserialize("PolicyDefinition", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - get.metadata = {'url': "/subscriptions/{subscriptionId}/providers/Microsoft.Authorization/policydefinitions/{policyDefinitionName}"} # type: ignore - + get.metadata = {"url": "/subscriptions/{subscriptionId}/providers/Microsoft.Authorization/policydefinitions/{policyDefinitionName}"} # type: ignore @distributed_trace - def list( - self, - filter: Optional[str] = None, - **kwargs: Any - ) -> Iterable["_models.PolicyDefinitionListResult"]: + def list(self, filter: Optional[str] = None, **kwargs: Any) -> Iterable["_models.PolicyDefinition"]: """Gets all the policy definitions for a subscription. :param filter: The filter to apply on the operation. Default value is None. :type filter: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either PolicyDefinitionListResult or the result of - cls(response) + :return: An iterator like instance of either PolicyDefinition or the result of cls(response) :rtype: - ~azure.core.paging.ItemPaged[~azure.mgmt.resource.policy.v2015_10_01_preview.models.PolicyDefinitionListResult] - :raises: ~azure.core.exceptions.HttpResponseError + ~azure.core.paging.ItemPaged[~azure.mgmt.resource.policy.v2015_10_01_preview.models.PolicyDefinition] + :raises ~azure.core.exceptions.HttpResponseError: """ - api_version = kwargs.pop('api_version', "2015-10-01-preview") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2015-10-01-preview")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[_models.PolicyDefinitionListResult] - cls = kwargs.pop('cls', None) # type: ClsType["_models.PolicyDefinitionListResult"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) + def prepare_request(next_link=None): if not next_link: - + request = build_policy_definitions_list_request( subscription_id=self._config.subscription_id, - api_version=api_version, filter=filter, - template_url=self.list.metadata['url'], + 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.url = self._client.format_url(request.url) # type: ignore else: - - request = build_policy_definitions_list_request( - subscription_id=self._config.subscription_id, - template_url=next_link, - ) + # make call to next link with the client's api-version + _parsed_next_link = urlparse(next_link) + _next_request_params = case_insensitive_dict(parse_qs(_parsed_next_link.query)) + _next_request_params["api-version"] = self._config.api_version + request = HttpRequest("GET", urljoin(next_link, _parsed_next_link.path), params=_next_request_params) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore request.method = "GET" return request @@ -1406,10 +1532,8 @@ def extract_data(pipeline_response): def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) response = pipeline_response.http_response @@ -1419,8 +1543,6 @@ def get_next(next_link=None): return pipeline_response + return ItemPaged(get_next, extract_data) - return ItemPaged( - get_next, extract_data - ) - list.metadata = {'url': "/subscriptions/{subscriptionId}/providers/Microsoft.Authorization/policydefinitions"} # type: ignore + list.metadata = {"url": "/subscriptions/{subscriptionId}/providers/Microsoft.Authorization/policydefinitions"} # type: ignore diff --git a/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/policy/v2015_10_01_preview/operations/_patch.py b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/policy/v2015_10_01_preview/operations/_patch.py new file mode 100644 index 0000000000000..f7dd32510333d --- /dev/null +++ b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/policy/v2015_10_01_preview/operations/_patch.py @@ -0,0 +1,20 @@ +# ------------------------------------ +# Copyright (c) Microsoft Corporation. +# Licensed under the MIT License. +# ------------------------------------ +"""Customize generated code here. + +Follow our quickstart for examples: https://aka.ms/azsdk/python/dpcodegen/python/customize +""" +from typing import List + +__all__: List[str] = [] # Add all objects you want publicly available to users at this package level + + +def patch_sdk(): + """Do not remove from this file. + + `patch_sdk` is a last resort escape hatch that allows you to do customizations + you can't accomplish using the techniques described in + https://aka.ms/azsdk/python/dpcodegen/python/customize + """ diff --git a/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/policy/v2016_04_01/__init__.py b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/policy/v2016_04_01/__init__.py index 89180ab440872..bb1ffe59afae7 100644 --- a/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/policy/v2016_04_01/__init__.py +++ b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/policy/v2016_04_01/__init__.py @@ -10,9 +10,15 @@ from ._version import VERSION __version__ = VERSION -__all__ = ['PolicyClient'] -# `._patch.py` is used for handwritten extensions to the generated code -# Example: https://github.com/Azure/azure-sdk-for-python/blob/main/doc/dev/customize_code/how-to-patch-sdk-code.md -from ._patch import patch_sdk -patch_sdk() +try: + from ._patch import __all__ as _patch_all + from ._patch import * # type: ignore # pylint: disable=unused-wildcard-import +except ImportError: + _patch_all = [] +from ._patch import patch_sdk as _patch_sdk + +__all__ = ["PolicyClient"] +__all__.extend([p for p in _patch_all if p not in __all__]) + +_patch_sdk() diff --git a/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/policy/v2016_04_01/_configuration.py b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/policy/v2016_04_01/_configuration.py index e5b2cffae60a7..dee7eeb85e5f4 100644 --- a/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/policy/v2016_04_01/_configuration.py +++ b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/policy/v2016_04_01/_configuration.py @@ -25,23 +25,18 @@ class PolicyClientConfiguration(Configuration): # pylint: disable=too-many-inst Note that all parameters used to create this instance are saved as instance attributes. - :param credential: Credential needed for the client to connect to Azure. + :param credential: Credential needed for the client to connect to Azure. Required. :type credential: ~azure.core.credentials.TokenCredential - :param subscription_id: The ID of the target subscription. + :param subscription_id: The ID of the target subscription. Required. :type subscription_id: str :keyword api_version: Api Version. Default value is "2016-04-01". Note that overriding this default value may result in unsupported behavior. :paramtype api_version: str """ - def __init__( - self, - credential: "TokenCredential", - subscription_id: str, - **kwargs: Any - ) -> None: + def __init__(self, credential: "TokenCredential", subscription_id: str, **kwargs: Any) -> None: super(PolicyClientConfiguration, self).__init__(**kwargs) - api_version = kwargs.pop('api_version', "2016-04-01") # type: str + api_version = kwargs.pop("api_version", "2016-04-01") # type: str if credential is None: raise ValueError("Parameter 'credential' must not be None.") @@ -51,23 +46,24 @@ def __init__( self.credential = credential self.subscription_id = subscription_id self.api_version = api_version - self.credential_scopes = kwargs.pop('credential_scopes', ['https://management.azure.com/.default']) - kwargs.setdefault('sdk_moniker', 'mgmt-resource/{}'.format(VERSION)) + self.credential_scopes = kwargs.pop("credential_scopes", ["https://management.azure.com/.default"]) + kwargs.setdefault("sdk_moniker", "mgmt-resource/{}".format(VERSION)) self._configure(**kwargs) def _configure( - self, - **kwargs # type: Any + self, **kwargs # type: Any ): # type: (...) -> 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) - self.logging_policy = kwargs.get('logging_policy') or policies.NetworkTraceLoggingPolicy(**kwargs) - self.http_logging_policy = kwargs.get('http_logging_policy') or ARMHttpLoggingPolicy(**kwargs) - self.retry_policy = kwargs.get('retry_policy') or policies.RetryPolicy(**kwargs) - self.custom_hook_policy = kwargs.get('custom_hook_policy') or policies.CustomHookPolicy(**kwargs) - self.redirect_policy = kwargs.get('redirect_policy') or policies.RedirectPolicy(**kwargs) - self.authentication_policy = kwargs.get('authentication_policy') + 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) + self.logging_policy = kwargs.get("logging_policy") or policies.NetworkTraceLoggingPolicy(**kwargs) + self.http_logging_policy = kwargs.get("http_logging_policy") or ARMHttpLoggingPolicy(**kwargs) + self.retry_policy = kwargs.get("retry_policy") or policies.RetryPolicy(**kwargs) + self.custom_hook_policy = kwargs.get("custom_hook_policy") or policies.CustomHookPolicy(**kwargs) + self.redirect_policy = kwargs.get("redirect_policy") or policies.RedirectPolicy(**kwargs) + self.authentication_policy = kwargs.get("authentication_policy") if self.credential and not self.authentication_policy: - self.authentication_policy = ARMChallengeAuthenticationPolicy(self.credential, *self.credential_scopes, **kwargs) + self.authentication_policy = ARMChallengeAuthenticationPolicy( + self.credential, *self.credential_scopes, **kwargs + ) diff --git a/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/policy/v2016_04_01/_metadata.json b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/policy/v2016_04_01/_metadata.json index ed59cad8bc420..b97ea9680e44d 100644 --- a/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/policy/v2016_04_01/_metadata.json +++ b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/policy/v2016_04_01/_metadata.json @@ -10,20 +10,20 @@ "azure_arm": true, "has_lro_operations": false, "client_side_validation": false, - "sync_imports": "{\"typing\": {\"azurecore\": {\"azure.core.credentials\": [\"TokenCredential\"]}}, \"regular\": {\"azurecore\": {\"azure.profiles\": [\"KnownProfiles\", \"ProfileDefinition\"], \"azure.profiles.multiapiclient\": [\"MultiApiClientMixin\"], \"azure.mgmt.core\": [\"ARMPipelineClient\"]}, \"local\": {\"._configuration\": [\"PolicyClientConfiguration\"]}, \"thirdparty\": {\"msrest\": [\"Deserializer\", \"Serializer\"]}}, \"conditional\": {\"stdlib\": {\"typing\": [\"Any\", \"Optional\"]}}}", - "async_imports": "{\"typing\": {\"azurecore\": {\"azure.core.credentials_async\": [\"AsyncTokenCredential\"], \"azure.core.credentials\": [\"TokenCredential\"]}}, \"regular\": {\"azurecore\": {\"azure.profiles\": [\"KnownProfiles\", \"ProfileDefinition\"], \"azure.profiles.multiapiclient\": [\"MultiApiClientMixin\"], \"azure.mgmt.core\": [\"AsyncARMPipelineClient\"]}, \"local\": {\"._configuration\": [\"PolicyClientConfiguration\"]}, \"thirdparty\": {\"msrest\": [\"Deserializer\", \"Serializer\"]}}, \"conditional\": {\"stdlib\": {\"typing\": [\"Any\", \"Optional\"]}}}" + "sync_imports": "{\"conditional\": {\"stdlib\": {\"typing\": [\"Any\", \"Optional\"]}}, \"regular\": {\"azurecore\": {\"azure.mgmt.core\": [\"ARMPipelineClient\"], \"azure.profiles\": [\"KnownProfiles\", \"ProfileDefinition\"], \"azure.profiles.multiapiclient\": [\"MultiApiClientMixin\"]}, \"local\": {\"._configuration\": [\"PolicyClientConfiguration\"], \".._serialization\": [\"Deserializer\", \"Serializer\"]}}, \"typing\": {\"azurecore\": {\"azure.core.credentials\": [\"TokenCredential\"]}}}", + "async_imports": "{\"conditional\": {\"stdlib\": {\"typing\": [\"Any\", \"Optional\"]}}, \"regular\": {\"azurecore\": {\"azure.mgmt.core\": [\"AsyncARMPipelineClient\"], \"azure.profiles\": [\"KnownProfiles\", \"ProfileDefinition\"], \"azure.profiles.multiapiclient\": [\"MultiApiClientMixin\"]}, \"local\": {\"._configuration\": [\"PolicyClientConfiguration\"], \"..._serialization\": [\"Deserializer\", \"Serializer\"]}}, \"typing\": {\"azurecore\": {\"azure.core.credentials_async\": [\"AsyncTokenCredential\"]}}}" }, "global_parameters": { "sync": { "credential": { - "signature": "credential, # type: \"TokenCredential\"", - "description": "Credential needed for the client to connect to Azure.", + "signature": "credential: \"TokenCredential\",", + "description": "Credential needed for the client to connect to Azure. Required.", "docstring_type": "~azure.core.credentials.TokenCredential", "required": true }, "subscription_id": { - "signature": "subscription_id, # type: str", - "description": "The ID of the target subscription.", + "signature": "subscription_id: str,", + "description": "The ID of the target subscription. Required.", "docstring_type": "str", "required": true } @@ -31,13 +31,13 @@ "async": { "credential": { "signature": "credential: \"AsyncTokenCredential\",", - "description": "Credential needed for the client to connect to Azure.", + "description": "Credential needed for the client to connect to Azure. Required.", "docstring_type": "~azure.core.credentials_async.AsyncTokenCredential", "required": true }, "subscription_id": { "signature": "subscription_id: str,", - "description": "The ID of the target subscription.", + "description": "The ID of the target subscription. Required.", "docstring_type": "str", "required": true } @@ -54,7 +54,7 @@ "required": false }, "base_url": { - "signature": "base_url=\"https://management.azure.com\", # type: str", + "signature": "base_url: str = \"https://management.azure.com\",", "description": "Service URL", "docstring_type": "str", "required": false diff --git a/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/policy/v2016_04_01/_patch.py b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/policy/v2016_04_01/_patch.py index 74e48ecd07cf3..f99e77fef9861 100644 --- a/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/policy/v2016_04_01/_patch.py +++ b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/policy/v2016_04_01/_patch.py @@ -28,4 +28,4 @@ # This file is used for handwritten extensions to the generated code. Example: # https://github.com/Azure/azure-sdk-for-python/blob/main/doc/dev/customize_code/how-to-patch-sdk-code.md def patch_sdk(): - pass \ No newline at end of file + pass diff --git a/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/policy/v2016_04_01/_policy_client.py b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/policy/v2016_04_01/_policy_client.py index 202ae9de5a93b..a634d2271ebc4 100644 --- a/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/policy/v2016_04_01/_policy_client.py +++ b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/policy/v2016_04_01/_policy_client.py @@ -9,12 +9,11 @@ from copy import deepcopy from typing import Any, TYPE_CHECKING -from msrest import Deserializer, Serializer - from azure.core.rest import HttpRequest, HttpResponse from azure.mgmt.core import ARMPipelineClient from . import models +from .._serialization import Deserializer, Serializer from ._configuration import PolicyClientConfiguration from .operations import PolicyAssignmentsOperations, PolicyDefinitionsOperations @@ -22,7 +21,8 @@ # pylint: disable=unused-import,ungrouped-imports from azure.core.credentials import TokenCredential -class PolicyClient: + +class PolicyClient: # pylint: disable=client-accepts-api-version-keyword """To manage and control access to your resources, you can define customized policies and assign them at a scope. @@ -32,9 +32,9 @@ class PolicyClient: :ivar policy_definitions: PolicyDefinitionsOperations operations :vartype policy_definitions: azure.mgmt.resource.policy.v2016_04_01.operations.PolicyDefinitionsOperations - :param credential: Credential needed for the client to connect to Azure. + :param credential: Credential needed for the client to connect to Azure. Required. :type credential: ~azure.core.credentials.TokenCredential - :param subscription_id: The ID of the target subscription. + :param subscription_id: The ID of the target subscription. Required. :type subscription_id: str :param base_url: Service URL. Default value is "https://management.azure.com". :type base_url: str @@ -57,15 +57,14 @@ def __init__( self._serialize = Serializer(client_models) self._deserialize = Deserializer(client_models) self._serialize.client_side_validation = False - self.policy_assignments = PolicyAssignmentsOperations(self._client, self._config, self._serialize, self._deserialize) - self.policy_definitions = PolicyDefinitionsOperations(self._client, self._config, self._serialize, self._deserialize) - - - def _send_request( - self, - request: HttpRequest, - **kwargs: Any - ) -> HttpResponse: + self.policy_assignments = PolicyAssignmentsOperations( + self._client, self._config, self._serialize, self._deserialize + ) + self.policy_definitions = PolicyDefinitionsOperations( + self._client, self._config, self._serialize, self._deserialize + ) + + def _send_request(self, request: HttpRequest, **kwargs: Any) -> HttpResponse: """Runs the network request through the client's chained policies. >>> from azure.core.rest import HttpRequest @@ -74,7 +73,7 @@ def _send_request( >>> response = client._send_request(request) - For more information on this code flow, see https://aka.ms/azsdk/python/protocol/quickstart + For more information on this code flow, see https://aka.ms/azsdk/dpcodegen/python/send_request :param request: The network request you want to make. Required. :type request: ~azure.core.rest.HttpRequest diff --git a/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/policy/v2016_04_01/_vendor.py b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/policy/v2016_04_01/_vendor.py index 138f663c53a4e..9aad73fc743e7 100644 --- a/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/policy/v2016_04_01/_vendor.py +++ b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/policy/v2016_04_01/_vendor.py @@ -7,6 +7,7 @@ from azure.core.pipeline.transport import HttpRequest + def _convert_request(request, files=None): data = request.content if not files else None request = HttpRequest(method=request.method, url=request.url, headers=request.headers, data=data) @@ -14,6 +15,7 @@ def _convert_request(request, files=None): request.set_formdata_body(files) return request + def _format_url_section(template, **kwargs): components = template.split("/") while components: @@ -21,7 +23,5 @@ def _format_url_section(template, **kwargs): 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 - ] + components = [c for c in formatted_components if "{}".format(key.args[0]) not in c] template = "/".join(components) diff --git a/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/policy/v2016_04_01/_version.py b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/policy/v2016_04_01/_version.py index a012ac01c480c..e5754a47ce68f 100644 --- a/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/policy/v2016_04_01/_version.py +++ b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/policy/v2016_04_01/_version.py @@ -6,4 +6,4 @@ # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -VERSION = "21.1.0" +VERSION = "1.0.0b1" diff --git a/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/policy/v2016_04_01/aio/__init__.py b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/policy/v2016_04_01/aio/__init__.py index 2784ce3f14bf5..4622bf1f396a7 100644 --- a/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/policy/v2016_04_01/aio/__init__.py +++ b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/policy/v2016_04_01/aio/__init__.py @@ -7,9 +7,15 @@ # -------------------------------------------------------------------------- from ._policy_client import PolicyClient -__all__ = ['PolicyClient'] -# `._patch.py` is used for handwritten extensions to the generated code -# Example: https://github.com/Azure/azure-sdk-for-python/blob/main/doc/dev/customize_code/how-to-patch-sdk-code.md -from ._patch import patch_sdk -patch_sdk() +try: + from ._patch import __all__ as _patch_all + from ._patch import * # type: ignore # pylint: disable=unused-wildcard-import +except ImportError: + _patch_all = [] +from ._patch import patch_sdk as _patch_sdk + +__all__ = ["PolicyClient"] +__all__.extend([p for p in _patch_all if p not in __all__]) + +_patch_sdk() diff --git a/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/policy/v2016_04_01/aio/_configuration.py b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/policy/v2016_04_01/aio/_configuration.py index 12cc81e7803c5..b058a2bc72132 100644 --- a/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/policy/v2016_04_01/aio/_configuration.py +++ b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/policy/v2016_04_01/aio/_configuration.py @@ -25,23 +25,18 @@ class PolicyClientConfiguration(Configuration): # pylint: disable=too-many-inst Note that all parameters used to create this instance are saved as instance attributes. - :param credential: Credential needed for the client to connect to Azure. + :param credential: Credential needed for the client to connect to Azure. Required. :type credential: ~azure.core.credentials_async.AsyncTokenCredential - :param subscription_id: The ID of the target subscription. + :param subscription_id: The ID of the target subscription. Required. :type subscription_id: str :keyword api_version: Api Version. Default value is "2016-04-01". Note that overriding this default value may result in unsupported behavior. :paramtype api_version: str """ - def __init__( - self, - credential: "AsyncTokenCredential", - subscription_id: str, - **kwargs: Any - ) -> None: + def __init__(self, credential: "AsyncTokenCredential", subscription_id: str, **kwargs: Any) -> None: super(PolicyClientConfiguration, self).__init__(**kwargs) - api_version = kwargs.pop('api_version', "2016-04-01") # type: str + api_version = kwargs.pop("api_version", "2016-04-01") # type: str if credential is None: raise ValueError("Parameter 'credential' must not be None.") @@ -51,22 +46,21 @@ def __init__( self.credential = credential self.subscription_id = subscription_id self.api_version = api_version - self.credential_scopes = kwargs.pop('credential_scopes', ['https://management.azure.com/.default']) - kwargs.setdefault('sdk_moniker', 'mgmt-resource/{}'.format(VERSION)) + self.credential_scopes = kwargs.pop("credential_scopes", ["https://management.azure.com/.default"]) + kwargs.setdefault("sdk_moniker", "mgmt-resource/{}".format(VERSION)) self._configure(**kwargs) - 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) - self.logging_policy = kwargs.get('logging_policy') or policies.NetworkTraceLoggingPolicy(**kwargs) - self.http_logging_policy = kwargs.get('http_logging_policy') or ARMHttpLoggingPolicy(**kwargs) - self.retry_policy = kwargs.get('retry_policy') or policies.AsyncRetryPolicy(**kwargs) - self.custom_hook_policy = kwargs.get('custom_hook_policy') or policies.CustomHookPolicy(**kwargs) - self.redirect_policy = kwargs.get('redirect_policy') or policies.AsyncRedirectPolicy(**kwargs) - self.authentication_policy = kwargs.get('authentication_policy') + 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) + self.logging_policy = kwargs.get("logging_policy") or policies.NetworkTraceLoggingPolicy(**kwargs) + self.http_logging_policy = kwargs.get("http_logging_policy") or ARMHttpLoggingPolicy(**kwargs) + self.retry_policy = kwargs.get("retry_policy") or policies.AsyncRetryPolicy(**kwargs) + self.custom_hook_policy = kwargs.get("custom_hook_policy") or policies.CustomHookPolicy(**kwargs) + self.redirect_policy = kwargs.get("redirect_policy") or policies.AsyncRedirectPolicy(**kwargs) + self.authentication_policy = kwargs.get("authentication_policy") if self.credential and not self.authentication_policy: - self.authentication_policy = AsyncARMChallengeAuthenticationPolicy(self.credential, *self.credential_scopes, **kwargs) + self.authentication_policy = AsyncARMChallengeAuthenticationPolicy( + self.credential, *self.credential_scopes, **kwargs + ) diff --git a/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/policy/v2016_04_01/aio/_patch.py b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/policy/v2016_04_01/aio/_patch.py index 74e48ecd07cf3..f99e77fef9861 100644 --- a/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/policy/v2016_04_01/aio/_patch.py +++ b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/policy/v2016_04_01/aio/_patch.py @@ -28,4 +28,4 @@ # This file is used for handwritten extensions to the generated code. Example: # https://github.com/Azure/azure-sdk-for-python/blob/main/doc/dev/customize_code/how-to-patch-sdk-code.md def patch_sdk(): - pass \ No newline at end of file + pass diff --git a/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/policy/v2016_04_01/aio/_policy_client.py b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/policy/v2016_04_01/aio/_policy_client.py index 791437348d4a4..384607c7c45b1 100644 --- a/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/policy/v2016_04_01/aio/_policy_client.py +++ b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/policy/v2016_04_01/aio/_policy_client.py @@ -9,12 +9,11 @@ from copy import deepcopy from typing import Any, Awaitable, TYPE_CHECKING -from msrest import Deserializer, Serializer - from azure.core.rest import AsyncHttpResponse, HttpRequest from azure.mgmt.core import AsyncARMPipelineClient from .. import models +from ..._serialization import Deserializer, Serializer from ._configuration import PolicyClientConfiguration from .operations import PolicyAssignmentsOperations, PolicyDefinitionsOperations @@ -22,7 +21,8 @@ # pylint: disable=unused-import,ungrouped-imports from azure.core.credentials_async import AsyncTokenCredential -class PolicyClient: + +class PolicyClient: # pylint: disable=client-accepts-api-version-keyword """To manage and control access to your resources, you can define customized policies and assign them at a scope. @@ -32,9 +32,9 @@ class PolicyClient: :ivar policy_definitions: PolicyDefinitionsOperations operations :vartype policy_definitions: azure.mgmt.resource.policy.v2016_04_01.aio.operations.PolicyDefinitionsOperations - :param credential: Credential needed for the client to connect to Azure. + :param credential: Credential needed for the client to connect to Azure. Required. :type credential: ~azure.core.credentials_async.AsyncTokenCredential - :param subscription_id: The ID of the target subscription. + :param subscription_id: The ID of the target subscription. Required. :type subscription_id: str :param base_url: Service URL. Default value is "https://management.azure.com". :type base_url: str @@ -57,15 +57,14 @@ def __init__( self._serialize = Serializer(client_models) self._deserialize = Deserializer(client_models) self._serialize.client_side_validation = False - self.policy_assignments = PolicyAssignmentsOperations(self._client, self._config, self._serialize, self._deserialize) - self.policy_definitions = PolicyDefinitionsOperations(self._client, self._config, self._serialize, self._deserialize) - - - def _send_request( - self, - request: HttpRequest, - **kwargs: Any - ) -> Awaitable[AsyncHttpResponse]: + self.policy_assignments = PolicyAssignmentsOperations( + self._client, self._config, self._serialize, self._deserialize + ) + self.policy_definitions = PolicyDefinitionsOperations( + self._client, self._config, self._serialize, self._deserialize + ) + + def _send_request(self, request: HttpRequest, **kwargs: Any) -> Awaitable[AsyncHttpResponse]: """Runs the network request through the client's chained policies. >>> from azure.core.rest import HttpRequest @@ -74,7 +73,7 @@ def _send_request( >>> response = await client._send_request(request) - For more information on this code flow, see https://aka.ms/azsdk/python/protocol/quickstart + For more information on this code flow, see https://aka.ms/azsdk/dpcodegen/python/send_request :param request: The network request you want to make. Required. :type request: ~azure.core.rest.HttpRequest diff --git a/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/policy/v2016_04_01/aio/operations/__init__.py b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/policy/v2016_04_01/aio/operations/__init__.py index 33ee2baf02338..1feb25bc4bdb2 100644 --- a/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/policy/v2016_04_01/aio/operations/__init__.py +++ b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/policy/v2016_04_01/aio/operations/__init__.py @@ -9,7 +9,13 @@ from ._operations import PolicyAssignmentsOperations from ._operations import PolicyDefinitionsOperations +from ._patch import __all__ as _patch_all +from ._patch import * # type: ignore # pylint: disable=unused-wildcard-import +from ._patch import patch_sdk as _patch_sdk + __all__ = [ - 'PolicyAssignmentsOperations', - 'PolicyDefinitionsOperations', + "PolicyAssignmentsOperations", + "PolicyDefinitionsOperations", ] +__all__.extend([p for p in _patch_all if p not in __all__]) +_patch_sdk() diff --git a/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/policy/v2016_04_01/aio/operations/_operations.py b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/policy/v2016_04_01/aio/operations/_operations.py index 1bab248e2b76f..3bb427c03d0d5 100644 --- a/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/policy/v2016_04_01/aio/operations/_operations.py +++ b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/policy/v2016_04_01/aio/operations/_operations.py @@ -6,140 +6,230 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -from typing import Any, AsyncIterable, Callable, Dict, Optional, TypeVar +from typing import Any, AsyncIterable, Callable, Dict, IO, Optional, TypeVar, Union, overload +from urllib.parse import parse_qs, urljoin, urlparse from azure.core.async_paging import AsyncItemPaged, AsyncList -from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error +from azure.core.exceptions import ( + ClientAuthenticationError, + HttpResponseError, + ResourceExistsError, + ResourceNotFoundError, + ResourceNotModifiedError, + map_error, +) from azure.core.pipeline import PipelineResponse from azure.core.pipeline.transport import AsyncHttpResponse from azure.core.rest import HttpRequest from azure.core.tracing.decorator import distributed_trace from azure.core.tracing.decorator_async import distributed_trace_async +from azure.core.utils import case_insensitive_dict from azure.mgmt.core.exceptions import ARMErrorFormat from ... import models as _models from ..._vendor import _convert_request -from ...operations._operations import build_policy_assignments_create_by_id_request, build_policy_assignments_create_request, build_policy_assignments_delete_by_id_request, build_policy_assignments_delete_request, build_policy_assignments_get_by_id_request, build_policy_assignments_get_request, build_policy_assignments_list_for_resource_group_request, build_policy_assignments_list_for_resource_request, build_policy_assignments_list_request, build_policy_definitions_create_or_update_request, build_policy_definitions_delete_request, build_policy_definitions_get_request, build_policy_definitions_list_request -T = TypeVar('T') +from ...operations._operations import ( + build_policy_assignments_create_by_id_request, + build_policy_assignments_create_request, + build_policy_assignments_delete_by_id_request, + build_policy_assignments_delete_request, + build_policy_assignments_get_by_id_request, + build_policy_assignments_get_request, + build_policy_assignments_list_for_resource_group_request, + build_policy_assignments_list_for_resource_request, + build_policy_assignments_list_request, + build_policy_definitions_create_or_update_request, + build_policy_definitions_delete_request, + build_policy_definitions_get_request, + build_policy_definitions_list_request, +) + +T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] -class PolicyAssignmentsOperations: - """PolicyAssignmentsOperations async operations. - You should not instantiate this class directly. Instead, you should create a Client instance that - instantiates it for you and attaches it as an attribute. +class PolicyAssignmentsOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. - :ivar models: Alias to model classes used in this operation group. - :type models: ~azure.mgmt.resource.policy.v2016_04_01.models - :param client: Client for service requests. - :param config: Configuration of service client. - :param serializer: An object model serializer. - :param deserializer: An object model deserializer. + Instead, you should access the following operations through + :class:`~azure.mgmt.resource.policy.v2016_04_01.aio.PolicyClient`'s + :attr:`policy_assignments` attribute. """ models = _models - def __init__(self, client, config, serializer, deserializer) -> None: - self._client = client - self._serialize = serializer - self._deserialize = deserializer - self._config = config + def __init__(self, *args, **kwargs) -> None: + input_args = list(args) + self._client = input_args.pop(0) if input_args else kwargs.pop("client") + self._config = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") @distributed_trace_async - async def delete( - self, - scope: str, - policy_assignment_name: str, - **kwargs: Any - ) -> "_models.PolicyAssignment": + async def delete(self, scope: str, policy_assignment_name: str, **kwargs: Any) -> _models.PolicyAssignment: """Deletes a policy assignment. - :param scope: The scope of the policy assignment. + :param scope: The scope of the policy assignment. Required. :type scope: str - :param policy_assignment_name: The name of the policy assignment to delete. + :param policy_assignment_name: The name of the policy assignment to delete. Required. :type policy_assignment_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: PolicyAssignment, or the result of cls(response) + :return: PolicyAssignment or the result of cls(response) :rtype: ~azure.mgmt.resource.policy.v2016_04_01.models.PolicyAssignment - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.PolicyAssignment"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) - api_version = kwargs.pop('api_version', "2016-04-01") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2016-04-01")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[_models.PolicyAssignment] - request = build_policy_assignments_delete_request( scope=scope, policy_assignment_name=policy_assignment_name, api_version=api_version, - template_url=self.delete.metadata['url'], + template_url=self.delete.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) - deserialized = self._deserialize('PolicyAssignment', pipeline_response) + deserialized = self._deserialize("PolicyAssignment", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - delete.metadata = {'url': "/{scope}/providers/Microsoft.Authorization/policyassignments/{policyAssignmentName}"} # type: ignore - + delete.metadata = {"url": "/{scope}/providers/Microsoft.Authorization/policyassignments/{policyAssignmentName}"} # type: ignore - @distributed_trace_async + @overload async def create( self, scope: str, policy_assignment_name: str, - parameters: "_models.PolicyAssignment", + parameters: _models.PolicyAssignment, *, - content_type: Optional[str] = "application/json", + content_type: str = "application/json", **kwargs: Any - ) -> "_models.PolicyAssignment": + ) -> _models.PolicyAssignment: """Creates a policy assignment. Policy assignments are inherited by child resources. For example, when you apply a policy to a resource group that policy is assigned to all resources in the group. - :param scope: The scope of the policy assignment. + :param scope: The scope of the policy assignment. Required. :type scope: str - :param policy_assignment_name: The name of the policy assignment. + :param policy_assignment_name: The name of the policy assignment. Required. :type policy_assignment_name: str - :param parameters: Parameters for the policy assignment. + :param parameters: Parameters for the policy assignment. Required. :type parameters: ~azure.mgmt.resource.policy.v2016_04_01.models.PolicyAssignment - :keyword content_type: Media type of the body sent to the API. Possible values are: - "application/json" or "text/json". Default value is "application/json". + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: PolicyAssignment or the result of cls(response) + :rtype: ~azure.mgmt.resource.policy.v2016_04_01.models.PolicyAssignment + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + async def create( + self, + scope: str, + policy_assignment_name: str, + parameters: IO, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.PolicyAssignment: + """Creates a policy assignment. + + Policy assignments are inherited by child resources. For example, when you apply a policy to a + resource group that policy is assigned to all resources in the group. + + :param scope: The scope of the policy assignment. Required. + :type scope: str + :param policy_assignment_name: The name of the policy assignment. Required. + :type policy_assignment_name: str + :param parameters: Parameters for the policy assignment. Required. + :type parameters: IO + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Known values are: 'application/json', 'text/json'. Default value is "application/json". :paramtype content_type: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: PolicyAssignment, or the result of cls(response) + :return: PolicyAssignment or the result of cls(response) :rtype: ~azure.mgmt.resource.policy.v2016_04_01.models.PolicyAssignment - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace_async + async def create( + self, scope: str, policy_assignment_name: str, parameters: Union[_models.PolicyAssignment, IO], **kwargs: Any + ) -> _models.PolicyAssignment: + """Creates a policy assignment. + + Policy assignments are inherited by child resources. For example, when you apply a policy to a + resource group that policy is assigned to all resources in the group. + + :param scope: The scope of the policy assignment. Required. + :type scope: str + :param policy_assignment_name: The name of the policy assignment. Required. + :type policy_assignment_name: str + :param parameters: Parameters for the policy assignment. Is either a model type or a IO type. + Required. + :type parameters: ~azure.mgmt.resource.policy.v2016_04_01.models.PolicyAssignment or IO + :keyword content_type: Body Parameter content-type. Known values are: 'application/json', + 'text/json'. Default value is None. + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: PolicyAssignment or the result of cls(response) + :rtype: ~azure.mgmt.resource.policy.v2016_04_01.models.PolicyAssignment + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.PolicyAssignment"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', "2016-04-01") # type: str + api_version = kwargs.pop("api_version", _params.pop("api-version", "2016-04-01")) # type: str + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.PolicyAssignment] - _json = self._serialize.body(parameters, 'PolicyAssignment') + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(parameters, (IO, bytes)): + _content = parameters + else: + _json = self._serialize.body(parameters, "PolicyAssignment") request = build_policy_assignments_create_request( scope=scope, @@ -147,138 +237,144 @@ async def create( api_version=api_version, content_type=content_type, json=_json, - template_url=self.create.metadata['url'], + content=_content, + template_url=self.create.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [201]: map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) - deserialized = self._deserialize('PolicyAssignment', pipeline_response) + deserialized = self._deserialize("PolicyAssignment", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - create.metadata = {'url': "/{scope}/providers/Microsoft.Authorization/policyassignments/{policyAssignmentName}"} # type: ignore - + create.metadata = {"url": "/{scope}/providers/Microsoft.Authorization/policyassignments/{policyAssignmentName}"} # type: ignore @distributed_trace_async - async def get( - self, - scope: str, - policy_assignment_name: str, - **kwargs: Any - ) -> "_models.PolicyAssignment": + async def get(self, scope: str, policy_assignment_name: str, **kwargs: Any) -> _models.PolicyAssignment: """Gets a policy assignment. - :param scope: The scope of the policy assignment. + :param scope: The scope of the policy assignment. Required. :type scope: str - :param policy_assignment_name: The name of the policy assignment to get. + :param policy_assignment_name: The name of the policy assignment to get. Required. :type policy_assignment_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: PolicyAssignment, or the result of cls(response) + :return: PolicyAssignment or the result of cls(response) :rtype: ~azure.mgmt.resource.policy.v2016_04_01.models.PolicyAssignment - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.PolicyAssignment"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) - api_version = kwargs.pop('api_version', "2016-04-01") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2016-04-01")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[_models.PolicyAssignment] - request = build_policy_assignments_get_request( scope=scope, policy_assignment_name=policy_assignment_name, api_version=api_version, - template_url=self.get.metadata['url'], + template_url=self.get.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) - deserialized = self._deserialize('PolicyAssignment', pipeline_response) + deserialized = self._deserialize("PolicyAssignment", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - get.metadata = {'url': "/{scope}/providers/Microsoft.Authorization/policyassignments/{policyAssignmentName}"} # type: ignore - + get.metadata = {"url": "/{scope}/providers/Microsoft.Authorization/policyassignments/{policyAssignmentName}"} # type: ignore @distributed_trace def list_for_resource_group( - self, - resource_group_name: str, - filter: Optional[str] = None, - **kwargs: Any - ) -> AsyncIterable["_models.PolicyAssignmentListResult"]: + self, resource_group_name: str, filter: Optional[str] = None, **kwargs: Any + ) -> AsyncIterable["_models.PolicyAssignment"]: """Gets policy assignments for the resource group. :param resource_group_name: The name of the resource group that contains policy assignments. + Required. :type resource_group_name: str :param filter: The filter to apply on the operation. Default value is None. :type filter: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either PolicyAssignmentListResult or the result of - cls(response) + :return: An iterator like instance of either PolicyAssignment or the result of cls(response) :rtype: - ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.resource.policy.v2016_04_01.models.PolicyAssignmentListResult] - :raises: ~azure.core.exceptions.HttpResponseError + ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.resource.policy.v2016_04_01.models.PolicyAssignment] + :raises ~azure.core.exceptions.HttpResponseError: """ - api_version = kwargs.pop('api_version', "2016-04-01") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2016-04-01")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[_models.PolicyAssignmentListResult] - cls = kwargs.pop('cls', None) # type: ClsType["_models.PolicyAssignmentListResult"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) + def prepare_request(next_link=None): if not next_link: - + request = build_policy_assignments_list_for_resource_group_request( resource_group_name=resource_group_name, subscription_id=self._config.subscription_id, - api_version=api_version, filter=filter, - template_url=self.list_for_resource_group.metadata['url'], + api_version=api_version, + template_url=self.list_for_resource_group.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore else: - - request = build_policy_assignments_list_for_resource_group_request( - resource_group_name=resource_group_name, - subscription_id=self._config.subscription_id, - template_url=next_link, - ) + # make call to next link with the client's api-version + _parsed_next_link = urlparse(next_link) + _next_request_params = case_insensitive_dict(parse_qs(_parsed_next_link.query)) + _next_request_params["api-version"] = self._config.api_version + request = HttpRequest("GET", urljoin(next_link, _parsed_next_link.path), params=_next_request_params) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore request.method = "GET" return request @@ -292,10 +388,8 @@ async def extract_data(pipeline_response): async def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) response = pipeline_response.http_response @@ -305,11 +399,9 @@ async def get_next(next_link=None): return pipeline_response + return AsyncItemPaged(get_next, extract_data) - return AsyncItemPaged( - get_next, extract_data - ) - list_for_resource_group.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Authorization/policyAssignments"} # type: ignore + list_for_resource_group.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Authorization/policyAssignments"} # type: ignore @distributed_trace def list_for_resource( @@ -321,39 +413,45 @@ def list_for_resource( resource_name: str, filter: Optional[str] = None, **kwargs: Any - ) -> AsyncIterable["_models.PolicyAssignmentListResult"]: + ) -> AsyncIterable["_models.PolicyAssignment"]: """Gets policy assignments for a resource. :param resource_group_name: The name of the resource group containing the resource. The name is - case insensitive. + case insensitive. Required. :type resource_group_name: str - :param resource_provider_namespace: The namespace of the resource provider. + :param resource_provider_namespace: The namespace of the resource provider. Required. :type resource_provider_namespace: str - :param parent_resource_path: The parent resource path. + :param parent_resource_path: The parent resource path. Required. :type parent_resource_path: str - :param resource_type: The resource type. + :param resource_type: The resource type. Required. :type resource_type: str - :param resource_name: The name of the resource with policy assignments. + :param resource_name: The name of the resource with policy assignments. Required. :type resource_name: str :param filter: The filter to apply on the operation. Default value is None. :type filter: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either PolicyAssignmentListResult or the result of - cls(response) + :return: An iterator like instance of either PolicyAssignment or the result of cls(response) :rtype: - ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.resource.policy.v2016_04_01.models.PolicyAssignmentListResult] - :raises: ~azure.core.exceptions.HttpResponseError + ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.resource.policy.v2016_04_01.models.PolicyAssignment] + :raises ~azure.core.exceptions.HttpResponseError: """ - api_version = kwargs.pop('api_version', "2016-04-01") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2016-04-01")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[_models.PolicyAssignmentListResult] - cls = kwargs.pop('cls', None) # type: ClsType["_models.PolicyAssignmentListResult"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) + def prepare_request(next_link=None): if not next_link: - + request = build_policy_assignments_list_for_resource_request( resource_group_name=resource_group_name, resource_provider_namespace=resource_provider_namespace, @@ -361,26 +459,23 @@ def prepare_request(next_link=None): resource_type=resource_type, resource_name=resource_name, subscription_id=self._config.subscription_id, - api_version=api_version, filter=filter, - template_url=self.list_for_resource.metadata['url'], + api_version=api_version, + template_url=self.list_for_resource.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore else: - - request = build_policy_assignments_list_for_resource_request( - resource_group_name=resource_group_name, - resource_provider_namespace=resource_provider_namespace, - parent_resource_path=parent_resource_path, - resource_type=resource_type, - resource_name=resource_name, - subscription_id=self._config.subscription_id, - template_url=next_link, - ) + # make call to next link with the client's api-version + _parsed_next_link = urlparse(next_link) + _next_request_params = case_insensitive_dict(parse_qs(_parsed_next_link.query)) + _next_request_params["api-version"] = self._config.api_version + request = HttpRequest("GET", urljoin(next_link, _parsed_next_link.path), params=_next_request_params) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore request.method = "GET" return request @@ -394,10 +489,8 @@ async def extract_data(pipeline_response): async def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) response = pipeline_response.http_response @@ -407,56 +500,58 @@ async def get_next(next_link=None): return pipeline_response + return AsyncItemPaged(get_next, extract_data) - return AsyncItemPaged( - get_next, extract_data - ) - list_for_resource.metadata = {'url': "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{parentResourcePath}/{resourceType}/{resourceName}/providers/Microsoft.Authorization/policyassignments"} # type: ignore + list_for_resource.metadata = {"url": "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{parentResourcePath}/{resourceType}/{resourceName}/providers/Microsoft.Authorization/policyassignments"} # type: ignore @distributed_trace - def list( - self, - filter: Optional[str] = None, - **kwargs: Any - ) -> AsyncIterable["_models.PolicyAssignmentListResult"]: + def list(self, filter: Optional[str] = None, **kwargs: Any) -> AsyncIterable["_models.PolicyAssignment"]: """Gets all the policy assignments for a subscription. :param filter: The filter to apply on the operation. Default value is None. :type filter: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either PolicyAssignmentListResult or the result of - cls(response) + :return: An iterator like instance of either PolicyAssignment or the result of cls(response) :rtype: - ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.resource.policy.v2016_04_01.models.PolicyAssignmentListResult] - :raises: ~azure.core.exceptions.HttpResponseError + ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.resource.policy.v2016_04_01.models.PolicyAssignment] + :raises ~azure.core.exceptions.HttpResponseError: """ - api_version = kwargs.pop('api_version', "2016-04-01") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2016-04-01")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[_models.PolicyAssignmentListResult] - cls = kwargs.pop('cls', None) # type: ClsType["_models.PolicyAssignmentListResult"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) + def prepare_request(next_link=None): if not next_link: - + request = build_policy_assignments_list_request( subscription_id=self._config.subscription_id, - api_version=api_version, filter=filter, - template_url=self.list.metadata['url'], + 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.url = self._client.format_url(request.url) # type: ignore else: - - request = build_policy_assignments_list_request( - subscription_id=self._config.subscription_id, - template_url=next_link, - ) + # make call to next link with the client's api-version + _parsed_next_link = urlparse(next_link) + _next_request_params = case_insensitive_dict(parse_qs(_parsed_next_link.query)) + _next_request_params["api-version"] = self._config.api_version + request = HttpRequest("GET", urljoin(next_link, _parsed_next_link.path), params=_next_request_params) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore request.method = "GET" return request @@ -470,10 +565,8 @@ async def extract_data(pipeline_response): async def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) response = pipeline_response.http_response @@ -483,18 +576,12 @@ async def get_next(next_link=None): return pipeline_response + return AsyncItemPaged(get_next, extract_data) - return AsyncItemPaged( - get_next, extract_data - ) - list.metadata = {'url': "/subscriptions/{subscriptionId}/providers/Microsoft.Authorization/policyassignments"} # type: ignore + list.metadata = {"url": "/subscriptions/{subscriptionId}/providers/Microsoft.Authorization/policyassignments"} # type: ignore @distributed_trace_async - async def delete_by_id( - self, - policy_assignment_id: str, - **kwargs: Any - ) -> "_models.PolicyAssignment": + async def delete_by_id(self, policy_assignment_id: str, **kwargs: Any) -> _models.PolicyAssignment: """Deletes a policy assignment by ID. When providing a scope for the assignment, use '/subscriptions/{subscription-id}/' for @@ -505,59 +592,65 @@ async def delete_by_id( :param policy_assignment_id: The ID of the policy assignment to delete. Use the format '/{scope}/providers/Microsoft.Authorization/policyAssignments/{policy-assignment-name}'. + Required. :type policy_assignment_id: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: PolicyAssignment, or the result of cls(response) + :return: PolicyAssignment or the result of cls(response) :rtype: ~azure.mgmt.resource.policy.v2016_04_01.models.PolicyAssignment - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.PolicyAssignment"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) - api_version = kwargs.pop('api_version', "2016-04-01") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2016-04-01")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[_models.PolicyAssignment] - request = build_policy_assignments_delete_by_id_request( policy_assignment_id=policy_assignment_id, api_version=api_version, - template_url=self.delete_by_id.metadata['url'], + template_url=self.delete_by_id.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) - deserialized = self._deserialize('PolicyAssignment', pipeline_response) + deserialized = self._deserialize("PolicyAssignment", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - delete_by_id.metadata = {'url': "/{policyAssignmentId}"} # type: ignore - + delete_by_id.metadata = {"url": "/{policyAssignmentId}"} # type: ignore - @distributed_trace_async + @overload async def create_by_id( self, policy_assignment_id: str, - parameters: "_models.PolicyAssignment", + parameters: _models.PolicyAssignment, *, - content_type: Optional[str] = "application/json", + content_type: str = "application/json", **kwargs: Any - ) -> "_models.PolicyAssignment": + ) -> _models.PolicyAssignment: """Creates a policy assignment by ID. Policy assignments are inherited by child resources. For example, when you apply a policy to a @@ -570,64 +663,134 @@ async def create_by_id( :param policy_assignment_id: The ID of the policy assignment to create. Use the format '/{scope}/providers/Microsoft.Authorization/policyAssignments/{policy-assignment-name}'. + Required. :type policy_assignment_id: str - :param parameters: Parameters for policy assignment. + :param parameters: Parameters for policy assignment. Required. :type parameters: ~azure.mgmt.resource.policy.v2016_04_01.models.PolicyAssignment - :keyword content_type: Media type of the body sent to the API. Possible values are: - "application/json" or "text/json". Default value is "application/json". + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". :paramtype content_type: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: PolicyAssignment, or the result of cls(response) + :return: PolicyAssignment or the result of cls(response) :rtype: ~azure.mgmt.resource.policy.v2016_04_01.models.PolicyAssignment - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + async def create_by_id( + self, policy_assignment_id: str, parameters: IO, *, content_type: str = "application/json", **kwargs: Any + ) -> _models.PolicyAssignment: + """Creates a policy assignment by ID. + + Policy assignments are inherited by child resources. For example, when you apply a policy to a + resource group that policy is assigned to all resources in the group. When providing a scope + for the assignment, use '/subscriptions/{subscription-id}/' for subscriptions, + '/subscriptions/{subscription-id}/resourceGroups/{resource-group-name}' for resource groups, + and + '/subscriptions/{subscription-id}/resourceGroups/{resource-group-name}/providers/{resource-provider-namespace}/{resource-type}/{resource-name}' + for resources. + + :param policy_assignment_id: The ID of the policy assignment to create. Use the format + '/{scope}/providers/Microsoft.Authorization/policyAssignments/{policy-assignment-name}'. + Required. + :type policy_assignment_id: str + :param parameters: Parameters for policy assignment. Required. + :type parameters: IO + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Known values are: 'application/json', 'text/json'. Default value is "application/json". + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: PolicyAssignment or the result of cls(response) + :rtype: ~azure.mgmt.resource.policy.v2016_04_01.models.PolicyAssignment + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace_async + async def create_by_id( + self, policy_assignment_id: str, parameters: Union[_models.PolicyAssignment, IO], **kwargs: Any + ) -> _models.PolicyAssignment: + """Creates a policy assignment by ID. + + Policy assignments are inherited by child resources. For example, when you apply a policy to a + resource group that policy is assigned to all resources in the group. When providing a scope + for the assignment, use '/subscriptions/{subscription-id}/' for subscriptions, + '/subscriptions/{subscription-id}/resourceGroups/{resource-group-name}' for resource groups, + and + '/subscriptions/{subscription-id}/resourceGroups/{resource-group-name}/providers/{resource-provider-namespace}/{resource-type}/{resource-name}' + for resources. + + :param policy_assignment_id: The ID of the policy assignment to create. Use the format + '/{scope}/providers/Microsoft.Authorization/policyAssignments/{policy-assignment-name}'. + Required. + :type policy_assignment_id: str + :param parameters: Parameters for policy assignment. Is either a model type or a IO type. + Required. + :type parameters: ~azure.mgmt.resource.policy.v2016_04_01.models.PolicyAssignment or IO + :keyword content_type: Body Parameter content-type. Known values are: 'application/json', + 'text/json'. Default value is None. + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: PolicyAssignment or the result of cls(response) + :rtype: ~azure.mgmt.resource.policy.v2016_04_01.models.PolicyAssignment + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.PolicyAssignment"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) - api_version = kwargs.pop('api_version', "2016-04-01") # type: str + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - _json = self._serialize.body(parameters, 'PolicyAssignment') + api_version = kwargs.pop("api_version", _params.pop("api-version", "2016-04-01")) # type: str + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.PolicyAssignment] + + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(parameters, (IO, bytes)): + _content = parameters + else: + _json = self._serialize.body(parameters, "PolicyAssignment") request = build_policy_assignments_create_by_id_request( policy_assignment_id=policy_assignment_id, api_version=api_version, content_type=content_type, json=_json, - template_url=self.create_by_id.metadata['url'], + content=_content, + template_url=self.create_by_id.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [201]: map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) - deserialized = self._deserialize('PolicyAssignment', pipeline_response) + deserialized = self._deserialize("PolicyAssignment", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - create_by_id.metadata = {'url': "/{policyAssignmentId}"} # type: ignore - + create_by_id.metadata = {"url": "/{policyAssignmentId}"} # type: ignore @distributed_trace_async - async def get_by_id( - self, - policy_assignment_id: str, - **kwargs: Any - ) -> "_models.PolicyAssignment": + async def get_by_id(self, policy_assignment_id: str, **kwargs: Any) -> _models.PolicyAssignment: """Gets a policy assignment by ID. When providing a scope for the assignment, use '/subscriptions/{subscription-id}/' for @@ -638,103 +801,160 @@ async def get_by_id( :param policy_assignment_id: The ID of the policy assignment to get. Use the format '/{scope}/providers/Microsoft.Authorization/policyAssignments/{policy-assignment-name}'. + Required. :type policy_assignment_id: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: PolicyAssignment, or the result of cls(response) + :return: PolicyAssignment or the result of cls(response) :rtype: ~azure.mgmt.resource.policy.v2016_04_01.models.PolicyAssignment - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.PolicyAssignment"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) - api_version = kwargs.pop('api_version', "2016-04-01") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2016-04-01")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[_models.PolicyAssignment] - request = build_policy_assignments_get_by_id_request( policy_assignment_id=policy_assignment_id, api_version=api_version, - template_url=self.get_by_id.metadata['url'], + template_url=self.get_by_id.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) - deserialized = self._deserialize('PolicyAssignment', pipeline_response) + deserialized = self._deserialize("PolicyAssignment", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - get_by_id.metadata = {'url': "/{policyAssignmentId}"} # type: ignore + get_by_id.metadata = {"url": "/{policyAssignmentId}"} # type: ignore -class PolicyDefinitionsOperations: - """PolicyDefinitionsOperations async operations. - You should not instantiate this class directly. Instead, you should create a Client instance that - instantiates it for you and attaches it as an attribute. +class PolicyDefinitionsOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. - :ivar models: Alias to model classes used in this operation group. - :type models: ~azure.mgmt.resource.policy.v2016_04_01.models - :param client: Client for service requests. - :param config: Configuration of service client. - :param serializer: An object model serializer. - :param deserializer: An object model deserializer. + Instead, you should access the following operations through + :class:`~azure.mgmt.resource.policy.v2016_04_01.aio.PolicyClient`'s + :attr:`policy_definitions` attribute. """ models = _models - def __init__(self, client, config, serializer, deserializer) -> None: - self._client = client - self._serialize = serializer - self._deserialize = deserializer - self._config = config + def __init__(self, *args, **kwargs) -> None: + input_args = list(args) + self._client = input_args.pop(0) if input_args else kwargs.pop("client") + self._config = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") - @distributed_trace_async + @overload async def create_or_update( self, policy_definition_name: str, - parameters: "_models.PolicyDefinition", + parameters: _models.PolicyDefinition, *, - content_type: Optional[str] = "application/json", + content_type: str = "application/json", **kwargs: Any - ) -> "_models.PolicyDefinition": + ) -> _models.PolicyDefinition: """Creates or updates a policy definition. - :param policy_definition_name: The name of the policy definition to create. + :param policy_definition_name: The name of the policy definition to create. Required. :type policy_definition_name: str - :param parameters: The policy definition properties. + :param parameters: The policy definition properties. Required. :type parameters: ~azure.mgmt.resource.policy.v2016_04_01.models.PolicyDefinition - :keyword content_type: Media type of the body sent to the API. Possible values are: - "application/json" or "text/json". Default value is "application/json". + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". :paramtype content_type: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: PolicyDefinition, or the result of cls(response) + :return: PolicyDefinition or the result of cls(response) :rtype: ~azure.mgmt.resource.policy.v2016_04_01.models.PolicyDefinition - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + async def create_or_update( + self, policy_definition_name: str, parameters: IO, *, content_type: str = "application/json", **kwargs: Any + ) -> _models.PolicyDefinition: + """Creates or updates a policy definition. + + :param policy_definition_name: The name of the policy definition to create. Required. + :type policy_definition_name: str + :param parameters: The policy definition properties. Required. + :type parameters: IO + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Known values are: 'application/json', 'text/json'. Default value is "application/json". + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: PolicyDefinition or the result of cls(response) + :rtype: ~azure.mgmt.resource.policy.v2016_04_01.models.PolicyDefinition + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace_async + async def create_or_update( + self, policy_definition_name: str, parameters: Union[_models.PolicyDefinition, IO], **kwargs: Any + ) -> _models.PolicyDefinition: + """Creates or updates a policy definition. + + :param policy_definition_name: The name of the policy definition to create. Required. + :type policy_definition_name: str + :param parameters: The policy definition properties. Is either a model type or a IO type. + Required. + :type parameters: ~azure.mgmt.resource.policy.v2016_04_01.models.PolicyDefinition or IO + :keyword content_type: Body Parameter content-type. Known values are: 'application/json', + 'text/json'. Default value is None. + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: PolicyDefinition or the result of cls(response) + :rtype: ~azure.mgmt.resource.policy.v2016_04_01.models.PolicyDefinition + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.PolicyDefinition"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) - api_version = kwargs.pop('api_version', "2016-04-01") # type: str + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - _json = self._serialize.body(parameters, 'PolicyDefinition') + api_version = kwargs.pop("api_version", _params.pop("api-version", "2016-04-01")) # type: str + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.PolicyDefinition] + + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(parameters, (IO, bytes)): + _content = parameters + else: + _json = self._serialize.body(parameters, "PolicyDefinition") request = build_policy_definitions_create_or_update_request( policy_definition_name=policy_definition_name, @@ -742,70 +962,75 @@ async def create_or_update( api_version=api_version, content_type=content_type, json=_json, - template_url=self.create_or_update.metadata['url'], + content=_content, + template_url=self.create_or_update.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [201]: map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) - deserialized = self._deserialize('PolicyDefinition', pipeline_response) + deserialized = self._deserialize("PolicyDefinition", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - create_or_update.metadata = {'url': "/subscriptions/{subscriptionId}/providers/Microsoft.Authorization/policydefinitions/{policyDefinitionName}"} # type: ignore - + create_or_update.metadata = {"url": "/subscriptions/{subscriptionId}/providers/Microsoft.Authorization/policydefinitions/{policyDefinitionName}"} # type: ignore @distributed_trace_async async def delete( # pylint: disable=inconsistent-return-statements - self, - policy_definition_name: str, - **kwargs: Any + self, policy_definition_name: str, **kwargs: Any ) -> None: """Deletes a policy definition. - :param policy_definition_name: The name of the policy definition to delete. + :param policy_definition_name: The name of the policy definition to delete. Required. :type policy_definition_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: None, or the result of cls(response) + :return: None or the result of cls(response) :rtype: None - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType[None] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) - api_version = kwargs.pop('api_version', "2016-04-01") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2016-04-01")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[None] - request = build_policy_definitions_delete_request( policy_definition_name=policy_definition_name, subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.delete.metadata['url'], + template_url=self.delete.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200, 204]: @@ -815,107 +1040,111 @@ async def delete( # pylint: disable=inconsistent-return-statements if cls: return cls(pipeline_response, None, {}) - delete.metadata = {'url': "/subscriptions/{subscriptionId}/providers/Microsoft.Authorization/policydefinitions/{policyDefinitionName}"} # type: ignore - + delete.metadata = {"url": "/subscriptions/{subscriptionId}/providers/Microsoft.Authorization/policydefinitions/{policyDefinitionName}"} # type: ignore @distributed_trace_async - async def get( - self, - policy_definition_name: str, - **kwargs: Any - ) -> "_models.PolicyDefinition": + async def get(self, policy_definition_name: str, **kwargs: Any) -> _models.PolicyDefinition: """Gets the policy definition. - :param policy_definition_name: The name of the policy definition to get. + :param policy_definition_name: The name of the policy definition to get. Required. :type policy_definition_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: PolicyDefinition, or the result of cls(response) + :return: PolicyDefinition or the result of cls(response) :rtype: ~azure.mgmt.resource.policy.v2016_04_01.models.PolicyDefinition - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.PolicyDefinition"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) - api_version = kwargs.pop('api_version', "2016-04-01") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2016-04-01")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[_models.PolicyDefinition] - request = build_policy_definitions_get_request( policy_definition_name=policy_definition_name, subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.get.metadata['url'], + template_url=self.get.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) - deserialized = self._deserialize('PolicyDefinition', pipeline_response) + deserialized = self._deserialize("PolicyDefinition", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - get.metadata = {'url': "/subscriptions/{subscriptionId}/providers/Microsoft.Authorization/policydefinitions/{policyDefinitionName}"} # type: ignore - + get.metadata = {"url": "/subscriptions/{subscriptionId}/providers/Microsoft.Authorization/policydefinitions/{policyDefinitionName}"} # type: ignore @distributed_trace - def list( - self, - filter: Optional[str] = None, - **kwargs: Any - ) -> AsyncIterable["_models.PolicyDefinitionListResult"]: + def list(self, filter: Optional[str] = None, **kwargs: Any) -> AsyncIterable["_models.PolicyDefinition"]: """Gets all the policy definitions for a subscription. :param filter: The filter to apply on the operation. Default value is None. :type filter: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either PolicyDefinitionListResult or the result of - cls(response) + :return: An iterator like instance of either PolicyDefinition or the result of cls(response) :rtype: - ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.resource.policy.v2016_04_01.models.PolicyDefinitionListResult] - :raises: ~azure.core.exceptions.HttpResponseError + ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.resource.policy.v2016_04_01.models.PolicyDefinition] + :raises ~azure.core.exceptions.HttpResponseError: """ - api_version = kwargs.pop('api_version', "2016-04-01") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2016-04-01")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[_models.PolicyDefinitionListResult] - cls = kwargs.pop('cls', None) # type: ClsType["_models.PolicyDefinitionListResult"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) + def prepare_request(next_link=None): if not next_link: - + request = build_policy_definitions_list_request( subscription_id=self._config.subscription_id, - api_version=api_version, filter=filter, - template_url=self.list.metadata['url'], + 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.url = self._client.format_url(request.url) # type: ignore else: - - request = build_policy_definitions_list_request( - subscription_id=self._config.subscription_id, - template_url=next_link, - ) + # make call to next link with the client's api-version + _parsed_next_link = urlparse(next_link) + _next_request_params = case_insensitive_dict(parse_qs(_parsed_next_link.query)) + _next_request_params["api-version"] = self._config.api_version + request = HttpRequest("GET", urljoin(next_link, _parsed_next_link.path), params=_next_request_params) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore request.method = "GET" return request @@ -929,10 +1158,8 @@ async def extract_data(pipeline_response): async def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) response = pipeline_response.http_response @@ -942,8 +1169,6 @@ async def get_next(next_link=None): return pipeline_response + return AsyncItemPaged(get_next, extract_data) - return AsyncItemPaged( - get_next, extract_data - ) - list.metadata = {'url': "/subscriptions/{subscriptionId}/providers/Microsoft.Authorization/policydefinitions"} # type: ignore + list.metadata = {"url": "/subscriptions/{subscriptionId}/providers/Microsoft.Authorization/policydefinitions"} # type: ignore diff --git a/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/policy/v2016_04_01/aio/operations/_patch.py b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/policy/v2016_04_01/aio/operations/_patch.py new file mode 100644 index 0000000000000..f7dd32510333d --- /dev/null +++ b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/policy/v2016_04_01/aio/operations/_patch.py @@ -0,0 +1,20 @@ +# ------------------------------------ +# Copyright (c) Microsoft Corporation. +# Licensed under the MIT License. +# ------------------------------------ +"""Customize generated code here. + +Follow our quickstart for examples: https://aka.ms/azsdk/python/dpcodegen/python/customize +""" +from typing import List + +__all__: List[str] = [] # Add all objects you want publicly available to users at this package level + + +def patch_sdk(): + """Do not remove from this file. + + `patch_sdk` is a last resort escape hatch that allows you to do customizations + you can't accomplish using the techniques described in + https://aka.ms/azsdk/python/dpcodegen/python/customize + """ diff --git a/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/policy/v2016_04_01/models/__init__.py b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/policy/v2016_04_01/models/__init__.py index f43cdc9ba8b0d..4303a55b1742d 100644 --- a/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/policy/v2016_04_01/models/__init__.py +++ b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/policy/v2016_04_01/models/__init__.py @@ -11,15 +11,17 @@ from ._models_py3 import PolicyDefinition from ._models_py3 import PolicyDefinitionListResult - -from ._policy_client_enums import ( - PolicyType, -) +from ._policy_client_enums import PolicyType +from ._patch import __all__ as _patch_all +from ._patch import * # type: ignore # pylint: disable=unused-wildcard-import +from ._patch import patch_sdk as _patch_sdk __all__ = [ - 'PolicyAssignment', - 'PolicyAssignmentListResult', - 'PolicyDefinition', - 'PolicyDefinitionListResult', - 'PolicyType', + "PolicyAssignment", + "PolicyAssignmentListResult", + "PolicyDefinition", + "PolicyDefinitionListResult", + "PolicyType", ] +__all__.extend([p for p in _patch_all if p not in __all__]) +_patch_sdk() diff --git a/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/policy/v2016_04_01/models/_models_py3.py b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/policy/v2016_04_01/models/_models_py3.py index 346e1c1fd5ec8..a2b91ed75494c 100644 --- a/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/policy/v2016_04_01/models/_models_py3.py +++ b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/policy/v2016_04_01/models/_models_py3.py @@ -1,4 +1,5 @@ # coding=utf-8 +# pylint: disable=too-many-lines # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. # Licensed under the MIT License. See License.txt in the project root for license information. @@ -6,14 +7,22 @@ # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -from typing import Any, List, Optional, Union +import sys +from typing import Any, List, Optional, TYPE_CHECKING, Union -import msrest.serialization +from ... import _serialization -from ._policy_client_enums import * +if TYPE_CHECKING: + # pylint: disable=unused-import,ungrouped-imports + from .. import models as _models +if sys.version_info >= (3, 9): + from collections.abc import MutableMapping +else: + from typing import MutableMapping # type: ignore # pylint: disable=ungrouped-imports +JSON = MutableMapping[str, Any] # pylint: disable=unsubscriptable-object -class PolicyAssignment(msrest.serialization.Model): +class PolicyAssignment(_serialization.Model): """The policy assignment. :ivar id: The ID of the policy assignment. @@ -31,18 +40,18 @@ class PolicyAssignment(msrest.serialization.Model): """ _attribute_map = { - 'id': {'key': 'id', 'type': 'str'}, - 'type': {'key': 'type', 'type': 'str'}, - 'name': {'key': 'name', 'type': 'str'}, - 'display_name': {'key': 'properties.displayName', 'type': 'str'}, - 'policy_definition_id': {'key': 'properties.policyDefinitionId', 'type': 'str'}, - 'scope': {'key': 'properties.scope', 'type': 'str'}, + "id": {"key": "id", "type": "str"}, + "type": {"key": "type", "type": "str"}, + "name": {"key": "name", "type": "str"}, + "display_name": {"key": "properties.displayName", "type": "str"}, + "policy_definition_id": {"key": "properties.policyDefinitionId", "type": "str"}, + "scope": {"key": "properties.scope", "type": "str"}, } def __init__( self, *, - id: Optional[str] = None, + id: Optional[str] = None, # pylint: disable=redefined-builtin type: Optional[str] = None, name: Optional[str] = None, display_name: Optional[str] = None, @@ -64,7 +73,7 @@ def __init__( :keyword scope: The scope for the policy assignment. :paramtype scope: str """ - super(PolicyAssignment, self).__init__(**kwargs) + super().__init__(**kwargs) self.id = id self.type = type self.name = name @@ -73,7 +82,7 @@ def __init__( self.scope = scope -class PolicyAssignmentListResult(msrest.serialization.Model): +class PolicyAssignmentListResult(_serialization.Model): """List of policy assignments. :ivar value: An array of policy assignments. @@ -83,16 +92,12 @@ class PolicyAssignmentListResult(msrest.serialization.Model): """ _attribute_map = { - 'value': {'key': 'value', 'type': '[PolicyAssignment]'}, - 'next_link': {'key': 'nextLink', 'type': 'str'}, + "value": {"key": "value", "type": "[PolicyAssignment]"}, + "next_link": {"key": "nextLink", "type": "str"}, } def __init__( - self, - *, - value: Optional[List["PolicyAssignment"]] = None, - next_link: Optional[str] = None, - **kwargs + self, *, value: Optional[List["_models.PolicyAssignment"]] = None, next_link: Optional[str] = None, **kwargs ): """ :keyword value: An array of policy assignments. @@ -100,12 +105,12 @@ def __init__( :keyword next_link: The URL to use for getting the next set of results. :paramtype next_link: str """ - super(PolicyAssignmentListResult, self).__init__(**kwargs) + super().__init__(**kwargs) self.value = value self.next_link = next_link -class PolicyDefinition(msrest.serialization.Model): +class PolicyDefinition(_serialization.Model): """The policy definition. Variables are only populated by the server, and will be ignored when sending a request. @@ -116,37 +121,37 @@ class PolicyDefinition(msrest.serialization.Model): value is inferred from the name value in the request URI. :vartype name: str :ivar policy_type: The type of policy definition. Possible values are NotSpecified, BuiltIn, - and Custom. Possible values include: "NotSpecified", "BuiltIn", "Custom". + and Custom. Known values are: "NotSpecified", "BuiltIn", and "Custom". :vartype policy_type: str or ~azure.mgmt.resource.policy.v2016_04_01.models.PolicyType :ivar display_name: The display name of the policy definition. :vartype display_name: str :ivar description: The policy definition description. :vartype description: str :ivar policy_rule: The policy rule. - :vartype policy_rule: any + :vartype policy_rule: JSON """ _validation = { - 'id': {'readonly': True}, + "id": {"readonly": True}, } _attribute_map = { - 'id': {'key': 'id', 'type': 'str'}, - 'name': {'key': 'name', 'type': 'str'}, - 'policy_type': {'key': 'properties.policyType', 'type': 'str'}, - 'display_name': {'key': 'properties.displayName', 'type': 'str'}, - 'description': {'key': 'properties.description', 'type': 'str'}, - 'policy_rule': {'key': 'properties.policyRule', 'type': 'object'}, + "id": {"key": "id", "type": "str"}, + "name": {"key": "name", "type": "str"}, + "policy_type": {"key": "properties.policyType", "type": "str"}, + "display_name": {"key": "properties.displayName", "type": "str"}, + "description": {"key": "properties.description", "type": "str"}, + "policy_rule": {"key": "properties.policyRule", "type": "object"}, } def __init__( self, *, name: Optional[str] = None, - policy_type: Optional[Union[str, "PolicyType"]] = None, + policy_type: Optional[Union[str, "_models.PolicyType"]] = None, display_name: Optional[str] = None, description: Optional[str] = None, - policy_rule: Optional[Any] = None, + policy_rule: Optional[JSON] = None, **kwargs ): """ @@ -154,16 +159,16 @@ def __init__( value is inferred from the name value in the request URI. :paramtype name: str :keyword policy_type: The type of policy definition. Possible values are NotSpecified, BuiltIn, - and Custom. Possible values include: "NotSpecified", "BuiltIn", "Custom". + and Custom. Known values are: "NotSpecified", "BuiltIn", and "Custom". :paramtype policy_type: str or ~azure.mgmt.resource.policy.v2016_04_01.models.PolicyType :keyword display_name: The display name of the policy definition. :paramtype display_name: str :keyword description: The policy definition description. :paramtype description: str :keyword policy_rule: The policy rule. - :paramtype policy_rule: any + :paramtype policy_rule: JSON """ - super(PolicyDefinition, self).__init__(**kwargs) + super().__init__(**kwargs) self.id = None self.name = name self.policy_type = policy_type @@ -172,7 +177,7 @@ def __init__( self.policy_rule = policy_rule -class PolicyDefinitionListResult(msrest.serialization.Model): +class PolicyDefinitionListResult(_serialization.Model): """List of policy definitions. :ivar value: An array of policy definitions. @@ -182,16 +187,12 @@ class PolicyDefinitionListResult(msrest.serialization.Model): """ _attribute_map = { - 'value': {'key': 'value', 'type': '[PolicyDefinition]'}, - 'next_link': {'key': 'nextLink', 'type': 'str'}, + "value": {"key": "value", "type": "[PolicyDefinition]"}, + "next_link": {"key": "nextLink", "type": "str"}, } def __init__( - self, - *, - value: Optional[List["PolicyDefinition"]] = None, - next_link: Optional[str] = None, - **kwargs + self, *, value: Optional[List["_models.PolicyDefinition"]] = None, next_link: Optional[str] = None, **kwargs ): """ :keyword value: An array of policy definitions. @@ -199,6 +200,6 @@ def __init__( :keyword next_link: The URL to use for getting the next set of results. :paramtype next_link: str """ - super(PolicyDefinitionListResult, self).__init__(**kwargs) + super().__init__(**kwargs) self.value = value self.next_link = next_link diff --git a/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/policy/v2016_04_01/models/_patch.py b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/policy/v2016_04_01/models/_patch.py new file mode 100644 index 0000000000000..f7dd32510333d --- /dev/null +++ b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/policy/v2016_04_01/models/_patch.py @@ -0,0 +1,20 @@ +# ------------------------------------ +# Copyright (c) Microsoft Corporation. +# Licensed under the MIT License. +# ------------------------------------ +"""Customize generated code here. + +Follow our quickstart for examples: https://aka.ms/azsdk/python/dpcodegen/python/customize +""" +from typing import List + +__all__: List[str] = [] # Add all objects you want publicly available to users at this package level + + +def patch_sdk(): + """Do not remove from this file. + + `patch_sdk` is a last resort escape hatch that allows you to do customizations + you can't accomplish using the techniques described in + https://aka.ms/azsdk/python/dpcodegen/python/customize + """ diff --git a/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/policy/v2016_04_01/models/_policy_client_enums.py b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/policy/v2016_04_01/models/_policy_client_enums.py index b6d41257fadba..91c08bdc295c3 100644 --- a/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/policy/v2016_04_01/models/_policy_client_enums.py +++ b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/policy/v2016_04_01/models/_policy_client_enums.py @@ -7,13 +7,11 @@ # -------------------------------------------------------------------------- from enum import Enum -from six import with_metaclass from azure.core import CaseInsensitiveEnumMeta -class PolicyType(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): - """The type of policy definition. Possible values are NotSpecified, BuiltIn, and Custom. - """ +class PolicyType(str, Enum, metaclass=CaseInsensitiveEnumMeta): + """The type of policy definition. Possible values are NotSpecified, BuiltIn, and Custom.""" NOT_SPECIFIED = "NotSpecified" BUILT_IN = "BuiltIn" diff --git a/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/policy/v2016_04_01/operations/__init__.py b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/policy/v2016_04_01/operations/__init__.py index 33ee2baf02338..1feb25bc4bdb2 100644 --- a/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/policy/v2016_04_01/operations/__init__.py +++ b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/policy/v2016_04_01/operations/__init__.py @@ -9,7 +9,13 @@ from ._operations import PolicyAssignmentsOperations from ._operations import PolicyDefinitionsOperations +from ._patch import __all__ as _patch_all +from ._patch import * # type: ignore # pylint: disable=unused-wildcard-import +from ._patch import patch_sdk as _patch_sdk + __all__ = [ - 'PolicyAssignmentsOperations', - 'PolicyDefinitionsOperations', + "PolicyAssignmentsOperations", + "PolicyDefinitionsOperations", ] +__all__.extend([p for p in _patch_all if p not in __all__]) +_patch_sdk() diff --git a/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/policy/v2016_04_01/operations/_operations.py b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/policy/v2016_04_01/operations/_operations.py index f462239e64ea2..26656bcf62a4f 100644 --- a/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/policy/v2016_04_01/operations/_operations.py +++ b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/policy/v2016_04_01/operations/_operations.py @@ -6,173 +6,152 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -from typing import Any, Callable, Dict, Iterable, Optional, TypeVar - -from msrest import Serializer - -from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error +from typing import Any, Callable, Dict, IO, Iterable, Optional, TypeVar, Union, overload +from urllib.parse import parse_qs, urljoin, urlparse + +from azure.core.exceptions import ( + ClientAuthenticationError, + HttpResponseError, + ResourceExistsError, + ResourceNotFoundError, + ResourceNotModifiedError, + map_error, +) from azure.core.paging import ItemPaged from azure.core.pipeline import PipelineResponse from azure.core.pipeline.transport import HttpResponse from azure.core.rest import HttpRequest from azure.core.tracing.decorator import distributed_trace +from azure.core.utils import case_insensitive_dict from azure.mgmt.core.exceptions import ARMErrorFormat from .. import models as _models +from ..._serialization import Serializer from .._vendor import _convert_request, _format_url_section -T = TypeVar('T') -JSONType = Any + +T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] _SERIALIZER = Serializer() _SERIALIZER.client_side_validation = False -def build_policy_assignments_delete_request( - scope: str, - policy_assignment_name: str, - **kwargs: Any -) -> HttpRequest: - api_version = kwargs.pop('api_version', "2016-04-01") # type: str - accept = "application/json, text/json" +def build_policy_assignments_delete_request(scope: str, policy_assignment_name: 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", "2016-04-01")) # type: str + accept = _headers.pop("Accept", "application/json, text/json") + # Construct URL - _url = kwargs.pop("template_url", "/{scope}/providers/Microsoft.Authorization/policyassignments/{policyAssignmentName}") + _url = kwargs.pop( + "template_url", "/{scope}/providers/Microsoft.Authorization/policyassignments/{policyAssignmentName}" + ) path_format_arguments = { - "scope": _SERIALIZER.url("scope", scope, 'str', skip_quote=True), - "policyAssignmentName": _SERIALIZER.url("policy_assignment_name", policy_assignment_name, 'str'), + "scope": _SERIALIZER.url("scope", scope, "str", skip_quote=True), + "policyAssignmentName": _SERIALIZER.url("policy_assignment_name", policy_assignment_name, "str"), } _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') - - return HttpRequest( - method="DELETE", - url=_url, - params=_query_parameters, - headers=_header_parameters, - **kwargs - ) + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + return HttpRequest(method="DELETE", url=_url, params=_params, headers=_headers, **kwargs) -def build_policy_assignments_create_request( - scope: str, - policy_assignment_name: str, - *, - json: JSONType = None, - content: Any = None, - **kwargs: Any -) -> HttpRequest: - api_version = kwargs.pop('api_version', "2016-04-01") # type: str - content_type = kwargs.pop('content_type', None) # type: Optional[str] - accept = "application/json, text/json" +def build_policy_assignments_create_request(scope: str, policy_assignment_name: 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", "2016-04-01")) # type: str + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + accept = _headers.pop("Accept", "application/json, text/json") + # Construct URL - _url = kwargs.pop("template_url", "/{scope}/providers/Microsoft.Authorization/policyassignments/{policyAssignmentName}") + _url = kwargs.pop( + "template_url", "/{scope}/providers/Microsoft.Authorization/policyassignments/{policyAssignmentName}" + ) path_format_arguments = { - "scope": _SERIALIZER.url("scope", scope, 'str', skip_quote=True), - "policyAssignmentName": _SERIALIZER.url("policy_assignment_name", policy_assignment_name, 'str'), + "scope": _SERIALIZER.url("scope", scope, "str", skip_quote=True), + "policyAssignmentName": _SERIALIZER.url("policy_assignment_name", policy_assignment_name, "str"), } _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] if content_type is not None: - _header_parameters['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') - _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') - - return HttpRequest( - method="PUT", - url=_url, - params=_query_parameters, - headers=_header_parameters, - json=json, - content=content, - **kwargs - ) + _headers["Content-Type"] = _SERIALIZER.header("content_type", content_type, "str") + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + return HttpRequest(method="PUT", url=_url, params=_params, headers=_headers, **kwargs) -def build_policy_assignments_get_request( - scope: str, - policy_assignment_name: str, - **kwargs: Any -) -> HttpRequest: - api_version = kwargs.pop('api_version', "2016-04-01") # type: str - accept = "application/json, text/json" +def build_policy_assignments_get_request(scope: str, policy_assignment_name: 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", "2016-04-01")) # type: str + accept = _headers.pop("Accept", "application/json, text/json") + # Construct URL - _url = kwargs.pop("template_url", "/{scope}/providers/Microsoft.Authorization/policyassignments/{policyAssignmentName}") + _url = kwargs.pop( + "template_url", "/{scope}/providers/Microsoft.Authorization/policyassignments/{policyAssignmentName}" + ) path_format_arguments = { - "scope": _SERIALIZER.url("scope", scope, 'str', skip_quote=True), - "policyAssignmentName": _SERIALIZER.url("policy_assignment_name", policy_assignment_name, 'str'), + "scope": _SERIALIZER.url("scope", scope, "str", skip_quote=True), + "policyAssignmentName": _SERIALIZER.url("policy_assignment_name", policy_assignment_name, "str"), } _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') - - return HttpRequest( - method="GET", - url=_url, - params=_query_parameters, - headers=_header_parameters, - **kwargs - ) + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) def build_policy_assignments_list_for_resource_group_request( - resource_group_name: str, - subscription_id: str, - *, - filter: Optional[str] = None, - **kwargs: Any + resource_group_name: str, subscription_id: str, *, filter: Optional[str] = None, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2016-04-01") # type: 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", "2016-04-01")) # type: str + accept = _headers.pop("Accept", "application/json, text/json") - accept = "application/json, text/json" # Construct URL - _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Authorization/policyAssignments") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Authorization/policyAssignments", + ) # pylint: disable=line-too-long path_format_arguments = { - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._\(\)]+$'), - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), + "resourceGroupName": _SERIALIZER.url( + "resource_group_name", resource_group_name, "str", max_length=90, min_length=1, pattern=r"^[-\w\._\(\)]+$" + ), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), } _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] if filter is not None: - _query_parameters['$filter'] = _SERIALIZER.query("filter", filter, 'str', skip_quote=True) - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["$filter"] = _SERIALIZER.query("filter", filter, "str", skip_quote=True) + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') - - return HttpRequest( - method="GET", - url=_url, - params=_query_parameters, - headers=_header_parameters, - **kwargs - ) + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) def build_policy_assignments_list_for_resource_request( @@ -186,437 +165,445 @@ def build_policy_assignments_list_for_resource_request( filter: Optional[str] = None, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2016-04-01") # type: 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", "2016-04-01")) # type: str + accept = _headers.pop("Accept", "application/json, text/json") - accept = "application/json, text/json" # Construct URL - _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{parentResourcePath}/{resourceType}/{resourceName}/providers/Microsoft.Authorization/policyassignments") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{parentResourcePath}/{resourceType}/{resourceName}/providers/Microsoft.Authorization/policyassignments", + ) # pylint: disable=line-too-long path_format_arguments = { - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._\(\)]+$'), - "resourceProviderNamespace": _SERIALIZER.url("resource_provider_namespace", resource_provider_namespace, 'str'), - "parentResourcePath": _SERIALIZER.url("parent_resource_path", parent_resource_path, 'str', skip_quote=True), - "resourceType": _SERIALIZER.url("resource_type", resource_type, 'str', skip_quote=True), - "resourceName": _SERIALIZER.url("resource_name", resource_name, 'str'), - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), + "resourceGroupName": _SERIALIZER.url( + "resource_group_name", resource_group_name, "str", max_length=90, min_length=1, pattern=r"^[-\w\._\(\)]+$" + ), + "resourceProviderNamespace": _SERIALIZER.url("resource_provider_namespace", resource_provider_namespace, "str"), + "parentResourcePath": _SERIALIZER.url("parent_resource_path", parent_resource_path, "str", skip_quote=True), + "resourceType": _SERIALIZER.url("resource_type", resource_type, "str", skip_quote=True), + "resourceName": _SERIALIZER.url("resource_name", resource_name, "str"), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), } _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] if filter is not None: - _query_parameters['$filter'] = _SERIALIZER.query("filter", filter, 'str') - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["$filter"] = _SERIALIZER.query("filter", filter, "str") + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') - - return HttpRequest( - method="GET", - url=_url, - params=_query_parameters, - headers=_header_parameters, - **kwargs - ) + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) def build_policy_assignments_list_request( - subscription_id: str, - *, - filter: Optional[str] = None, - **kwargs: Any + subscription_id: str, *, filter: Optional[str] = None, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2016-04-01") # type: 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", "2016-04-01")) # type: str + accept = _headers.pop("Accept", "application/json, text/json") - accept = "application/json, text/json" # Construct URL - _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/providers/Microsoft.Authorization/policyassignments") + _url = kwargs.pop( + "template_url", "/subscriptions/{subscriptionId}/providers/Microsoft.Authorization/policyassignments" + ) path_format_arguments = { - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), } _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] if filter is not None: - _query_parameters['$filter'] = _SERIALIZER.query("filter", filter, 'str') - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["$filter"] = _SERIALIZER.query("filter", filter, "str") + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') - - return HttpRequest( - method="GET", - url=_url, - params=_query_parameters, - headers=_header_parameters, - **kwargs - ) + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) -def build_policy_assignments_delete_by_id_request( - policy_assignment_id: str, - **kwargs: Any -) -> HttpRequest: - api_version = kwargs.pop('api_version', "2016-04-01") # type: str - accept = "application/json, text/json" +def build_policy_assignments_delete_by_id_request(policy_assignment_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", "2016-04-01")) # type: str + accept = _headers.pop("Accept", "application/json, text/json") + # Construct URL _url = kwargs.pop("template_url", "/{policyAssignmentId}") path_format_arguments = { - "policyAssignmentId": _SERIALIZER.url("policy_assignment_id", policy_assignment_id, 'str', skip_quote=True), + "policyAssignmentId": _SERIALIZER.url("policy_assignment_id", policy_assignment_id, "str", skip_quote=True), } _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') - - return HttpRequest( - method="DELETE", - url=_url, - params=_query_parameters, - headers=_header_parameters, - **kwargs - ) + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + return HttpRequest(method="DELETE", url=_url, params=_params, headers=_headers, **kwargs) -def build_policy_assignments_create_by_id_request( - policy_assignment_id: str, - *, - json: JSONType = None, - content: Any = None, - **kwargs: Any -) -> HttpRequest: - api_version = kwargs.pop('api_version', "2016-04-01") # type: str - content_type = kwargs.pop('content_type', None) # type: Optional[str] - accept = "application/json, text/json" +def build_policy_assignments_create_by_id_request(policy_assignment_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", "2016-04-01")) # type: str + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + accept = _headers.pop("Accept", "application/json, text/json") + # Construct URL _url = kwargs.pop("template_url", "/{policyAssignmentId}") path_format_arguments = { - "policyAssignmentId": _SERIALIZER.url("policy_assignment_id", policy_assignment_id, 'str', skip_quote=True), + "policyAssignmentId": _SERIALIZER.url("policy_assignment_id", policy_assignment_id, "str", skip_quote=True), } _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] if content_type is not None: - _header_parameters['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') - _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') - - return HttpRequest( - method="PUT", - url=_url, - params=_query_parameters, - headers=_header_parameters, - json=json, - content=content, - **kwargs - ) + _headers["Content-Type"] = _SERIALIZER.header("content_type", content_type, "str") + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + return HttpRequest(method="PUT", url=_url, params=_params, headers=_headers, **kwargs) -def build_policy_assignments_get_by_id_request( - policy_assignment_id: str, - **kwargs: Any -) -> HttpRequest: - api_version = kwargs.pop('api_version', "2016-04-01") # type: str - accept = "application/json, text/json" +def build_policy_assignments_get_by_id_request(policy_assignment_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", "2016-04-01")) # type: str + accept = _headers.pop("Accept", "application/json, text/json") + # Construct URL _url = kwargs.pop("template_url", "/{policyAssignmentId}") path_format_arguments = { - "policyAssignmentId": _SERIALIZER.url("policy_assignment_id", policy_assignment_id, 'str', skip_quote=True), + "policyAssignmentId": _SERIALIZER.url("policy_assignment_id", policy_assignment_id, "str", skip_quote=True), } _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') - - return HttpRequest( - method="GET", - url=_url, - params=_query_parameters, - headers=_header_parameters, - **kwargs - ) + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) def build_policy_definitions_create_or_update_request( - policy_definition_name: str, - subscription_id: str, - *, - json: JSONType = None, - content: Any = None, - **kwargs: Any + policy_definition_name: str, subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2016-04-01") # type: str - content_type = kwargs.pop('content_type', None) # type: Optional[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", "2016-04-01")) # type: str + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + accept = _headers.pop("Accept", "application/json, text/json") - accept = "application/json, text/json" # Construct URL - _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/providers/Microsoft.Authorization/policydefinitions/{policyDefinitionName}") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/providers/Microsoft.Authorization/policydefinitions/{policyDefinitionName}", + ) # pylint: disable=line-too-long path_format_arguments = { - "policyDefinitionName": _SERIALIZER.url("policy_definition_name", policy_definition_name, 'str'), - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), + "policyDefinitionName": _SERIALIZER.url("policy_definition_name", policy_definition_name, "str"), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), } _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] if content_type is not None: - _header_parameters['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') - _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') - - return HttpRequest( - method="PUT", - url=_url, - params=_query_parameters, - headers=_header_parameters, - json=json, - content=content, - **kwargs - ) + _headers["Content-Type"] = _SERIALIZER.header("content_type", content_type, "str") + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="PUT", url=_url, params=_params, headers=_headers, **kwargs) def build_policy_definitions_delete_request( - policy_definition_name: str, - subscription_id: str, - **kwargs: Any + policy_definition_name: str, subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2016-04-01") # type: str + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + api_version = kwargs.pop("api_version", _params.pop("api-version", "2016-04-01")) # type: str # Construct URL - _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/providers/Microsoft.Authorization/policydefinitions/{policyDefinitionName}") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/providers/Microsoft.Authorization/policydefinitions/{policyDefinitionName}", + ) # pylint: disable=line-too-long path_format_arguments = { - "policyDefinitionName": _SERIALIZER.url("policy_definition_name", policy_definition_name, 'str'), - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), + "policyDefinitionName": _SERIALIZER.url("policy_definition_name", policy_definition_name, "str"), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), } _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') - - return HttpRequest( - method="DELETE", - url=_url, - params=_query_parameters, - **kwargs - ) + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") + + return HttpRequest(method="DELETE", url=_url, params=_params, **kwargs) def build_policy_definitions_get_request( - policy_definition_name: str, - subscription_id: str, - **kwargs: Any + policy_definition_name: str, subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2016-04-01") # type: 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", "2016-04-01")) # type: str + accept = _headers.pop("Accept", "application/json, text/json") - accept = "application/json, text/json" # Construct URL - _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/providers/Microsoft.Authorization/policydefinitions/{policyDefinitionName}") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/providers/Microsoft.Authorization/policydefinitions/{policyDefinitionName}", + ) # pylint: disable=line-too-long path_format_arguments = { - "policyDefinitionName": _SERIALIZER.url("policy_definition_name", policy_definition_name, 'str'), - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), + "policyDefinitionName": _SERIALIZER.url("policy_definition_name", policy_definition_name, "str"), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), } _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') - - return HttpRequest( - method="GET", - url=_url, - params=_query_parameters, - headers=_header_parameters, - **kwargs - ) + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) def build_policy_definitions_list_request( - subscription_id: str, - *, - filter: Optional[str] = None, - **kwargs: Any + subscription_id: str, *, filter: Optional[str] = None, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2016-04-01") # type: 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", "2016-04-01")) # type: str + accept = _headers.pop("Accept", "application/json, text/json") - accept = "application/json, text/json" # Construct URL - _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/providers/Microsoft.Authorization/policydefinitions") + _url = kwargs.pop( + "template_url", "/subscriptions/{subscriptionId}/providers/Microsoft.Authorization/policydefinitions" + ) path_format_arguments = { - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), } _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] if filter is not None: - _query_parameters['$filter'] = _SERIALIZER.query("filter", filter, 'str') - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["$filter"] = _SERIALIZER.query("filter", filter, "str") + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') - - return HttpRequest( - method="GET", - url=_url, - params=_query_parameters, - headers=_header_parameters, - **kwargs - ) + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") -class PolicyAssignmentsOperations(object): - """PolicyAssignmentsOperations operations. + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) - You should not instantiate this class directly. Instead, you should create a Client instance that - instantiates it for you and attaches it as an attribute. - :ivar models: Alias to model classes used in this operation group. - :type models: ~azure.mgmt.resource.policy.v2016_04_01.models - :param client: Client for service requests. - :param config: Configuration of service client. - :param serializer: An object model serializer. - :param deserializer: An object model deserializer. +class PolicyAssignmentsOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. + + Instead, you should access the following operations through + :class:`~azure.mgmt.resource.policy.v2016_04_01.PolicyClient`'s + :attr:`policy_assignments` attribute. """ models = _models - def __init__(self, client, config, serializer, deserializer): - self._client = client - self._serialize = serializer - self._deserialize = deserializer - self._config = config + def __init__(self, *args, **kwargs): + input_args = list(args) + self._client = input_args.pop(0) if input_args else kwargs.pop("client") + self._config = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") @distributed_trace - def delete( - self, - scope: str, - policy_assignment_name: str, - **kwargs: Any - ) -> "_models.PolicyAssignment": + def delete(self, scope: str, policy_assignment_name: str, **kwargs: Any) -> _models.PolicyAssignment: """Deletes a policy assignment. - :param scope: The scope of the policy assignment. + :param scope: The scope of the policy assignment. Required. :type scope: str - :param policy_assignment_name: The name of the policy assignment to delete. + :param policy_assignment_name: The name of the policy assignment to delete. Required. :type policy_assignment_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: PolicyAssignment, or the result of cls(response) + :return: PolicyAssignment or the result of cls(response) :rtype: ~azure.mgmt.resource.policy.v2016_04_01.models.PolicyAssignment - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.PolicyAssignment"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) - api_version = kwargs.pop('api_version', "2016-04-01") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2016-04-01")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[_models.PolicyAssignment] - request = build_policy_assignments_delete_request( scope=scope, policy_assignment_name=policy_assignment_name, api_version=api_version, - template_url=self.delete.metadata['url'], + template_url=self.delete.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) - deserialized = self._deserialize('PolicyAssignment', pipeline_response) + deserialized = self._deserialize("PolicyAssignment", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - delete.metadata = {'url': "/{scope}/providers/Microsoft.Authorization/policyassignments/{policyAssignmentName}"} # type: ignore - + delete.metadata = {"url": "/{scope}/providers/Microsoft.Authorization/policyassignments/{policyAssignmentName}"} # type: ignore - @distributed_trace + @overload def create( self, scope: str, policy_assignment_name: str, - parameters: "_models.PolicyAssignment", + parameters: _models.PolicyAssignment, *, - content_type: Optional[str] = "application/json", + content_type: str = "application/json", **kwargs: Any - ) -> "_models.PolicyAssignment": + ) -> _models.PolicyAssignment: """Creates a policy assignment. Policy assignments are inherited by child resources. For example, when you apply a policy to a resource group that policy is assigned to all resources in the group. - :param scope: The scope of the policy assignment. + :param scope: The scope of the policy assignment. Required. :type scope: str - :param policy_assignment_name: The name of the policy assignment. + :param policy_assignment_name: The name of the policy assignment. Required. :type policy_assignment_name: str - :param parameters: Parameters for the policy assignment. + :param parameters: Parameters for the policy assignment. Required. :type parameters: ~azure.mgmt.resource.policy.v2016_04_01.models.PolicyAssignment - :keyword content_type: Media type of the body sent to the API. Possible values are: - "application/json" or "text/json". Default value is "application/json". + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: PolicyAssignment or the result of cls(response) + :rtype: ~azure.mgmt.resource.policy.v2016_04_01.models.PolicyAssignment + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + def create( + self, + scope: str, + policy_assignment_name: str, + parameters: IO, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.PolicyAssignment: + """Creates a policy assignment. + + Policy assignments are inherited by child resources. For example, when you apply a policy to a + resource group that policy is assigned to all resources in the group. + + :param scope: The scope of the policy assignment. Required. + :type scope: str + :param policy_assignment_name: The name of the policy assignment. Required. + :type policy_assignment_name: str + :param parameters: Parameters for the policy assignment. Required. + :type parameters: IO + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Known values are: 'application/json', 'text/json'. Default value is "application/json". + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: PolicyAssignment or the result of cls(response) + :rtype: ~azure.mgmt.resource.policy.v2016_04_01.models.PolicyAssignment + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace + def create( + self, scope: str, policy_assignment_name: str, parameters: Union[_models.PolicyAssignment, IO], **kwargs: Any + ) -> _models.PolicyAssignment: + """Creates a policy assignment. + + Policy assignments are inherited by child resources. For example, when you apply a policy to a + resource group that policy is assigned to all resources in the group. + + :param scope: The scope of the policy assignment. Required. + :type scope: str + :param policy_assignment_name: The name of the policy assignment. Required. + :type policy_assignment_name: str + :param parameters: Parameters for the policy assignment. Is either a model type or a IO type. + Required. + :type parameters: ~azure.mgmt.resource.policy.v2016_04_01.models.PolicyAssignment or IO + :keyword content_type: Body Parameter content-type. Known values are: 'application/json', + 'text/json'. Default value is None. :paramtype content_type: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: PolicyAssignment, or the result of cls(response) + :return: PolicyAssignment or the result of cls(response) :rtype: ~azure.mgmt.resource.policy.v2016_04_01.models.PolicyAssignment - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.PolicyAssignment"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', "2016-04-01") # type: str + api_version = kwargs.pop("api_version", _params.pop("api-version", "2016-04-01")) # type: str + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.PolicyAssignment] - _json = self._serialize.body(parameters, 'PolicyAssignment') + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(parameters, (IO, bytes)): + _content = parameters + else: + _json = self._serialize.body(parameters, "PolicyAssignment") request = build_policy_assignments_create_request( scope=scope, @@ -624,138 +611,144 @@ def create( api_version=api_version, content_type=content_type, json=_json, - template_url=self.create.metadata['url'], + content=_content, + template_url=self.create.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [201]: map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) - deserialized = self._deserialize('PolicyAssignment', pipeline_response) + deserialized = self._deserialize("PolicyAssignment", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - create.metadata = {'url': "/{scope}/providers/Microsoft.Authorization/policyassignments/{policyAssignmentName}"} # type: ignore - + create.metadata = {"url": "/{scope}/providers/Microsoft.Authorization/policyassignments/{policyAssignmentName}"} # type: ignore @distributed_trace - def get( - self, - scope: str, - policy_assignment_name: str, - **kwargs: Any - ) -> "_models.PolicyAssignment": + def get(self, scope: str, policy_assignment_name: str, **kwargs: Any) -> _models.PolicyAssignment: """Gets a policy assignment. - :param scope: The scope of the policy assignment. + :param scope: The scope of the policy assignment. Required. :type scope: str - :param policy_assignment_name: The name of the policy assignment to get. + :param policy_assignment_name: The name of the policy assignment to get. Required. :type policy_assignment_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: PolicyAssignment, or the result of cls(response) + :return: PolicyAssignment or the result of cls(response) :rtype: ~azure.mgmt.resource.policy.v2016_04_01.models.PolicyAssignment - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.PolicyAssignment"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) - api_version = kwargs.pop('api_version', "2016-04-01") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2016-04-01")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[_models.PolicyAssignment] - request = build_policy_assignments_get_request( scope=scope, policy_assignment_name=policy_assignment_name, api_version=api_version, - template_url=self.get.metadata['url'], + template_url=self.get.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) - deserialized = self._deserialize('PolicyAssignment', pipeline_response) + deserialized = self._deserialize("PolicyAssignment", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - get.metadata = {'url': "/{scope}/providers/Microsoft.Authorization/policyassignments/{policyAssignmentName}"} # type: ignore - + get.metadata = {"url": "/{scope}/providers/Microsoft.Authorization/policyassignments/{policyAssignmentName}"} # type: ignore @distributed_trace def list_for_resource_group( - self, - resource_group_name: str, - filter: Optional[str] = None, - **kwargs: Any - ) -> Iterable["_models.PolicyAssignmentListResult"]: + self, resource_group_name: str, filter: Optional[str] = None, **kwargs: Any + ) -> Iterable["_models.PolicyAssignment"]: """Gets policy assignments for the resource group. :param resource_group_name: The name of the resource group that contains policy assignments. + Required. :type resource_group_name: str :param filter: The filter to apply on the operation. Default value is None. :type filter: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either PolicyAssignmentListResult or the result of - cls(response) + :return: An iterator like instance of either PolicyAssignment or the result of cls(response) :rtype: - ~azure.core.paging.ItemPaged[~azure.mgmt.resource.policy.v2016_04_01.models.PolicyAssignmentListResult] - :raises: ~azure.core.exceptions.HttpResponseError + ~azure.core.paging.ItemPaged[~azure.mgmt.resource.policy.v2016_04_01.models.PolicyAssignment] + :raises ~azure.core.exceptions.HttpResponseError: """ - api_version = kwargs.pop('api_version', "2016-04-01") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2016-04-01")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[_models.PolicyAssignmentListResult] - cls = kwargs.pop('cls', None) # type: ClsType["_models.PolicyAssignmentListResult"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) + def prepare_request(next_link=None): if not next_link: - + request = build_policy_assignments_list_for_resource_group_request( resource_group_name=resource_group_name, subscription_id=self._config.subscription_id, - api_version=api_version, filter=filter, - template_url=self.list_for_resource_group.metadata['url'], + api_version=api_version, + template_url=self.list_for_resource_group.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore else: - - request = build_policy_assignments_list_for_resource_group_request( - resource_group_name=resource_group_name, - subscription_id=self._config.subscription_id, - template_url=next_link, - ) + # make call to next link with the client's api-version + _parsed_next_link = urlparse(next_link) + _next_request_params = case_insensitive_dict(parse_qs(_parsed_next_link.query)) + _next_request_params["api-version"] = self._config.api_version + request = HttpRequest("GET", urljoin(next_link, _parsed_next_link.path), params=_next_request_params) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore request.method = "GET" return request @@ -769,10 +762,8 @@ def extract_data(pipeline_response): def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) response = pipeline_response.http_response @@ -782,11 +773,9 @@ def get_next(next_link=None): return pipeline_response + return ItemPaged(get_next, extract_data) - return ItemPaged( - get_next, extract_data - ) - list_for_resource_group.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Authorization/policyAssignments"} # type: ignore + list_for_resource_group.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Authorization/policyAssignments"} # type: ignore @distributed_trace def list_for_resource( @@ -798,39 +787,45 @@ def list_for_resource( resource_name: str, filter: Optional[str] = None, **kwargs: Any - ) -> Iterable["_models.PolicyAssignmentListResult"]: + ) -> Iterable["_models.PolicyAssignment"]: """Gets policy assignments for a resource. :param resource_group_name: The name of the resource group containing the resource. The name is - case insensitive. + case insensitive. Required. :type resource_group_name: str - :param resource_provider_namespace: The namespace of the resource provider. + :param resource_provider_namespace: The namespace of the resource provider. Required. :type resource_provider_namespace: str - :param parent_resource_path: The parent resource path. + :param parent_resource_path: The parent resource path. Required. :type parent_resource_path: str - :param resource_type: The resource type. + :param resource_type: The resource type. Required. :type resource_type: str - :param resource_name: The name of the resource with policy assignments. + :param resource_name: The name of the resource with policy assignments. Required. :type resource_name: str :param filter: The filter to apply on the operation. Default value is None. :type filter: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either PolicyAssignmentListResult or the result of - cls(response) + :return: An iterator like instance of either PolicyAssignment or the result of cls(response) :rtype: - ~azure.core.paging.ItemPaged[~azure.mgmt.resource.policy.v2016_04_01.models.PolicyAssignmentListResult] - :raises: ~azure.core.exceptions.HttpResponseError + ~azure.core.paging.ItemPaged[~azure.mgmt.resource.policy.v2016_04_01.models.PolicyAssignment] + :raises ~azure.core.exceptions.HttpResponseError: """ - api_version = kwargs.pop('api_version', "2016-04-01") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2016-04-01")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[_models.PolicyAssignmentListResult] - cls = kwargs.pop('cls', None) # type: ClsType["_models.PolicyAssignmentListResult"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) + def prepare_request(next_link=None): if not next_link: - + request = build_policy_assignments_list_for_resource_request( resource_group_name=resource_group_name, resource_provider_namespace=resource_provider_namespace, @@ -838,26 +833,23 @@ def prepare_request(next_link=None): resource_type=resource_type, resource_name=resource_name, subscription_id=self._config.subscription_id, - api_version=api_version, filter=filter, - template_url=self.list_for_resource.metadata['url'], + api_version=api_version, + template_url=self.list_for_resource.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore else: - - request = build_policy_assignments_list_for_resource_request( - resource_group_name=resource_group_name, - resource_provider_namespace=resource_provider_namespace, - parent_resource_path=parent_resource_path, - resource_type=resource_type, - resource_name=resource_name, - subscription_id=self._config.subscription_id, - template_url=next_link, - ) + # make call to next link with the client's api-version + _parsed_next_link = urlparse(next_link) + _next_request_params = case_insensitive_dict(parse_qs(_parsed_next_link.query)) + _next_request_params["api-version"] = self._config.api_version + request = HttpRequest("GET", urljoin(next_link, _parsed_next_link.path), params=_next_request_params) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore request.method = "GET" return request @@ -871,10 +863,8 @@ def extract_data(pipeline_response): def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) response = pipeline_response.http_response @@ -884,56 +874,58 @@ def get_next(next_link=None): return pipeline_response + return ItemPaged(get_next, extract_data) - return ItemPaged( - get_next, extract_data - ) - list_for_resource.metadata = {'url': "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{parentResourcePath}/{resourceType}/{resourceName}/providers/Microsoft.Authorization/policyassignments"} # type: ignore + list_for_resource.metadata = {"url": "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{parentResourcePath}/{resourceType}/{resourceName}/providers/Microsoft.Authorization/policyassignments"} # type: ignore @distributed_trace - def list( - self, - filter: Optional[str] = None, - **kwargs: Any - ) -> Iterable["_models.PolicyAssignmentListResult"]: + def list(self, filter: Optional[str] = None, **kwargs: Any) -> Iterable["_models.PolicyAssignment"]: """Gets all the policy assignments for a subscription. :param filter: The filter to apply on the operation. Default value is None. :type filter: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either PolicyAssignmentListResult or the result of - cls(response) + :return: An iterator like instance of either PolicyAssignment or the result of cls(response) :rtype: - ~azure.core.paging.ItemPaged[~azure.mgmt.resource.policy.v2016_04_01.models.PolicyAssignmentListResult] - :raises: ~azure.core.exceptions.HttpResponseError + ~azure.core.paging.ItemPaged[~azure.mgmt.resource.policy.v2016_04_01.models.PolicyAssignment] + :raises ~azure.core.exceptions.HttpResponseError: """ - api_version = kwargs.pop('api_version', "2016-04-01") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2016-04-01")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[_models.PolicyAssignmentListResult] - cls = kwargs.pop('cls', None) # type: ClsType["_models.PolicyAssignmentListResult"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) + def prepare_request(next_link=None): if not next_link: - + request = build_policy_assignments_list_request( subscription_id=self._config.subscription_id, - api_version=api_version, filter=filter, - template_url=self.list.metadata['url'], + 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.url = self._client.format_url(request.url) # type: ignore else: - - request = build_policy_assignments_list_request( - subscription_id=self._config.subscription_id, - template_url=next_link, - ) + # make call to next link with the client's api-version + _parsed_next_link = urlparse(next_link) + _next_request_params = case_insensitive_dict(parse_qs(_parsed_next_link.query)) + _next_request_params["api-version"] = self._config.api_version + request = HttpRequest("GET", urljoin(next_link, _parsed_next_link.path), params=_next_request_params) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore request.method = "GET" return request @@ -947,10 +939,8 @@ def extract_data(pipeline_response): def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) response = pipeline_response.http_response @@ -960,18 +950,12 @@ def get_next(next_link=None): return pipeline_response + return ItemPaged(get_next, extract_data) - return ItemPaged( - get_next, extract_data - ) - list.metadata = {'url': "/subscriptions/{subscriptionId}/providers/Microsoft.Authorization/policyassignments"} # type: ignore + list.metadata = {"url": "/subscriptions/{subscriptionId}/providers/Microsoft.Authorization/policyassignments"} # type: ignore @distributed_trace - def delete_by_id( - self, - policy_assignment_id: str, - **kwargs: Any - ) -> "_models.PolicyAssignment": + def delete_by_id(self, policy_assignment_id: str, **kwargs: Any) -> _models.PolicyAssignment: """Deletes a policy assignment by ID. When providing a scope for the assignment, use '/subscriptions/{subscription-id}/' for @@ -982,59 +966,65 @@ def delete_by_id( :param policy_assignment_id: The ID of the policy assignment to delete. Use the format '/{scope}/providers/Microsoft.Authorization/policyAssignments/{policy-assignment-name}'. + Required. :type policy_assignment_id: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: PolicyAssignment, or the result of cls(response) + :return: PolicyAssignment or the result of cls(response) :rtype: ~azure.mgmt.resource.policy.v2016_04_01.models.PolicyAssignment - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.PolicyAssignment"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) - api_version = kwargs.pop('api_version', "2016-04-01") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2016-04-01")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[_models.PolicyAssignment] - request = build_policy_assignments_delete_by_id_request( policy_assignment_id=policy_assignment_id, api_version=api_version, - template_url=self.delete_by_id.metadata['url'], + template_url=self.delete_by_id.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) - deserialized = self._deserialize('PolicyAssignment', pipeline_response) + deserialized = self._deserialize("PolicyAssignment", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - delete_by_id.metadata = {'url': "/{policyAssignmentId}"} # type: ignore + delete_by_id.metadata = {"url": "/{policyAssignmentId}"} # type: ignore - - @distributed_trace + @overload def create_by_id( self, policy_assignment_id: str, - parameters: "_models.PolicyAssignment", + parameters: _models.PolicyAssignment, *, - content_type: Optional[str] = "application/json", + content_type: str = "application/json", **kwargs: Any - ) -> "_models.PolicyAssignment": + ) -> _models.PolicyAssignment: """Creates a policy assignment by ID. Policy assignments are inherited by child resources. For example, when you apply a policy to a @@ -1047,64 +1037,134 @@ def create_by_id( :param policy_assignment_id: The ID of the policy assignment to create. Use the format '/{scope}/providers/Microsoft.Authorization/policyAssignments/{policy-assignment-name}'. + Required. :type policy_assignment_id: str - :param parameters: Parameters for policy assignment. + :param parameters: Parameters for policy assignment. Required. :type parameters: ~azure.mgmt.resource.policy.v2016_04_01.models.PolicyAssignment - :keyword content_type: Media type of the body sent to the API. Possible values are: - "application/json" or "text/json". Default value is "application/json". + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: PolicyAssignment or the result of cls(response) + :rtype: ~azure.mgmt.resource.policy.v2016_04_01.models.PolicyAssignment + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + def create_by_id( + self, policy_assignment_id: str, parameters: IO, *, content_type: str = "application/json", **kwargs: Any + ) -> _models.PolicyAssignment: + """Creates a policy assignment by ID. + + Policy assignments are inherited by child resources. For example, when you apply a policy to a + resource group that policy is assigned to all resources in the group. When providing a scope + for the assignment, use '/subscriptions/{subscription-id}/' for subscriptions, + '/subscriptions/{subscription-id}/resourceGroups/{resource-group-name}' for resource groups, + and + '/subscriptions/{subscription-id}/resourceGroups/{resource-group-name}/providers/{resource-provider-namespace}/{resource-type}/{resource-name}' + for resources. + + :param policy_assignment_id: The ID of the policy assignment to create. Use the format + '/{scope}/providers/Microsoft.Authorization/policyAssignments/{policy-assignment-name}'. + Required. + :type policy_assignment_id: str + :param parameters: Parameters for policy assignment. Required. + :type parameters: IO + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Known values are: 'application/json', 'text/json'. Default value is "application/json". :paramtype content_type: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: PolicyAssignment, or the result of cls(response) + :return: PolicyAssignment or the result of cls(response) :rtype: ~azure.mgmt.resource.policy.v2016_04_01.models.PolicyAssignment - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace + def create_by_id( + self, policy_assignment_id: str, parameters: Union[_models.PolicyAssignment, IO], **kwargs: Any + ) -> _models.PolicyAssignment: + """Creates a policy assignment by ID. + + Policy assignments are inherited by child resources. For example, when you apply a policy to a + resource group that policy is assigned to all resources in the group. When providing a scope + for the assignment, use '/subscriptions/{subscription-id}/' for subscriptions, + '/subscriptions/{subscription-id}/resourceGroups/{resource-group-name}' for resource groups, + and + '/subscriptions/{subscription-id}/resourceGroups/{resource-group-name}/providers/{resource-provider-namespace}/{resource-type}/{resource-name}' + for resources. + + :param policy_assignment_id: The ID of the policy assignment to create. Use the format + '/{scope}/providers/Microsoft.Authorization/policyAssignments/{policy-assignment-name}'. + Required. + :type policy_assignment_id: str + :param parameters: Parameters for policy assignment. Is either a model type or a IO type. + Required. + :type parameters: ~azure.mgmt.resource.policy.v2016_04_01.models.PolicyAssignment or IO + :keyword content_type: Body Parameter content-type. Known values are: 'application/json', + 'text/json'. Default value is None. + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: PolicyAssignment or the result of cls(response) + :rtype: ~azure.mgmt.resource.policy.v2016_04_01.models.PolicyAssignment + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.PolicyAssignment"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', "2016-04-01") # type: str + api_version = kwargs.pop("api_version", _params.pop("api-version", "2016-04-01")) # type: str + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.PolicyAssignment] - _json = self._serialize.body(parameters, 'PolicyAssignment') + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(parameters, (IO, bytes)): + _content = parameters + else: + _json = self._serialize.body(parameters, "PolicyAssignment") request = build_policy_assignments_create_by_id_request( policy_assignment_id=policy_assignment_id, api_version=api_version, content_type=content_type, json=_json, - template_url=self.create_by_id.metadata['url'], + content=_content, + template_url=self.create_by_id.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [201]: map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) - deserialized = self._deserialize('PolicyAssignment', pipeline_response) + deserialized = self._deserialize("PolicyAssignment", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - create_by_id.metadata = {'url': "/{policyAssignmentId}"} # type: ignore - + create_by_id.metadata = {"url": "/{policyAssignmentId}"} # type: ignore @distributed_trace - def get_by_id( - self, - policy_assignment_id: str, - **kwargs: Any - ) -> "_models.PolicyAssignment": + def get_by_id(self, policy_assignment_id: str, **kwargs: Any) -> _models.PolicyAssignment: """Gets a policy assignment by ID. When providing a scope for the assignment, use '/subscriptions/{subscription-id}/' for @@ -1115,103 +1175,160 @@ def get_by_id( :param policy_assignment_id: The ID of the policy assignment to get. Use the format '/{scope}/providers/Microsoft.Authorization/policyAssignments/{policy-assignment-name}'. + Required. :type policy_assignment_id: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: PolicyAssignment, or the result of cls(response) + :return: PolicyAssignment or the result of cls(response) :rtype: ~azure.mgmt.resource.policy.v2016_04_01.models.PolicyAssignment - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.PolicyAssignment"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + 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', "2016-04-01") # type: str + api_version = kwargs.pop("api_version", _params.pop("api-version", "2016-04-01")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[_models.PolicyAssignment] - request = build_policy_assignments_get_by_id_request( policy_assignment_id=policy_assignment_id, api_version=api_version, - template_url=self.get_by_id.metadata['url'], + template_url=self.get_by_id.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) - deserialized = self._deserialize('PolicyAssignment', pipeline_response) + deserialized = self._deserialize("PolicyAssignment", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - get_by_id.metadata = {'url': "/{policyAssignmentId}"} # type: ignore + get_by_id.metadata = {"url": "/{policyAssignmentId}"} # type: ignore -class PolicyDefinitionsOperations(object): - """PolicyDefinitionsOperations operations. - You should not instantiate this class directly. Instead, you should create a Client instance that - instantiates it for you and attaches it as an attribute. +class PolicyDefinitionsOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. - :ivar models: Alias to model classes used in this operation group. - :type models: ~azure.mgmt.resource.policy.v2016_04_01.models - :param client: Client for service requests. - :param config: Configuration of service client. - :param serializer: An object model serializer. - :param deserializer: An object model deserializer. + Instead, you should access the following operations through + :class:`~azure.mgmt.resource.policy.v2016_04_01.PolicyClient`'s + :attr:`policy_definitions` attribute. """ models = _models - def __init__(self, client, config, serializer, deserializer): - self._client = client - self._serialize = serializer - self._deserialize = deserializer - self._config = config + def __init__(self, *args, **kwargs): + input_args = list(args) + self._client = input_args.pop(0) if input_args else kwargs.pop("client") + self._config = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") - @distributed_trace + @overload def create_or_update( self, policy_definition_name: str, - parameters: "_models.PolicyDefinition", + parameters: _models.PolicyDefinition, *, - content_type: Optional[str] = "application/json", + content_type: str = "application/json", **kwargs: Any - ) -> "_models.PolicyDefinition": + ) -> _models.PolicyDefinition: """Creates or updates a policy definition. - :param policy_definition_name: The name of the policy definition to create. + :param policy_definition_name: The name of the policy definition to create. Required. :type policy_definition_name: str - :param parameters: The policy definition properties. + :param parameters: The policy definition properties. Required. :type parameters: ~azure.mgmt.resource.policy.v2016_04_01.models.PolicyDefinition - :keyword content_type: Media type of the body sent to the API. Possible values are: - "application/json" or "text/json". Default value is "application/json". + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: PolicyDefinition or the result of cls(response) + :rtype: ~azure.mgmt.resource.policy.v2016_04_01.models.PolicyDefinition + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + def create_or_update( + self, policy_definition_name: str, parameters: IO, *, content_type: str = "application/json", **kwargs: Any + ) -> _models.PolicyDefinition: + """Creates or updates a policy definition. + + :param policy_definition_name: The name of the policy definition to create. Required. + :type policy_definition_name: str + :param parameters: The policy definition properties. Required. + :type parameters: IO + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Known values are: 'application/json', 'text/json'. Default value is "application/json". + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: PolicyDefinition or the result of cls(response) + :rtype: ~azure.mgmt.resource.policy.v2016_04_01.models.PolicyDefinition + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace + def create_or_update( + self, policy_definition_name: str, parameters: Union[_models.PolicyDefinition, IO], **kwargs: Any + ) -> _models.PolicyDefinition: + """Creates or updates a policy definition. + + :param policy_definition_name: The name of the policy definition to create. Required. + :type policy_definition_name: str + :param parameters: The policy definition properties. Is either a model type or a IO type. + Required. + :type parameters: ~azure.mgmt.resource.policy.v2016_04_01.models.PolicyDefinition or IO + :keyword content_type: Body Parameter content-type. Known values are: 'application/json', + 'text/json'. Default value is None. :paramtype content_type: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: PolicyDefinition, or the result of cls(response) + :return: PolicyDefinition or the result of cls(response) :rtype: ~azure.mgmt.resource.policy.v2016_04_01.models.PolicyDefinition - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.PolicyDefinition"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) - api_version = kwargs.pop('api_version', "2016-04-01") # type: str + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - _json = self._serialize.body(parameters, 'PolicyDefinition') + api_version = kwargs.pop("api_version", _params.pop("api-version", "2016-04-01")) # type: str + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.PolicyDefinition] + + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(parameters, (IO, bytes)): + _content = parameters + else: + _json = self._serialize.body(parameters, "PolicyDefinition") request = build_policy_definitions_create_or_update_request( policy_definition_name=policy_definition_name, @@ -1219,70 +1336,75 @@ def create_or_update( api_version=api_version, content_type=content_type, json=_json, - template_url=self.create_or_update.metadata['url'], + content=_content, + template_url=self.create_or_update.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [201]: map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) - deserialized = self._deserialize('PolicyDefinition', pipeline_response) + deserialized = self._deserialize("PolicyDefinition", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - create_or_update.metadata = {'url': "/subscriptions/{subscriptionId}/providers/Microsoft.Authorization/policydefinitions/{policyDefinitionName}"} # type: ignore - + create_or_update.metadata = {"url": "/subscriptions/{subscriptionId}/providers/Microsoft.Authorization/policydefinitions/{policyDefinitionName}"} # type: ignore @distributed_trace def delete( # pylint: disable=inconsistent-return-statements - self, - policy_definition_name: str, - **kwargs: Any + self, policy_definition_name: str, **kwargs: Any ) -> None: """Deletes a policy definition. - :param policy_definition_name: The name of the policy definition to delete. + :param policy_definition_name: The name of the policy definition to delete. Required. :type policy_definition_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: None, or the result of cls(response) + :return: None or the result of cls(response) :rtype: None - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType[None] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) - api_version = kwargs.pop('api_version', "2016-04-01") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2016-04-01")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[None] - request = build_policy_definitions_delete_request( policy_definition_name=policy_definition_name, subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.delete.metadata['url'], + template_url=self.delete.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200, 204]: @@ -1292,107 +1414,111 @@ def delete( # pylint: disable=inconsistent-return-statements if cls: return cls(pipeline_response, None, {}) - delete.metadata = {'url': "/subscriptions/{subscriptionId}/providers/Microsoft.Authorization/policydefinitions/{policyDefinitionName}"} # type: ignore - + delete.metadata = {"url": "/subscriptions/{subscriptionId}/providers/Microsoft.Authorization/policydefinitions/{policyDefinitionName}"} # type: ignore @distributed_trace - def get( - self, - policy_definition_name: str, - **kwargs: Any - ) -> "_models.PolicyDefinition": + def get(self, policy_definition_name: str, **kwargs: Any) -> _models.PolicyDefinition: """Gets the policy definition. - :param policy_definition_name: The name of the policy definition to get. + :param policy_definition_name: The name of the policy definition to get. Required. :type policy_definition_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: PolicyDefinition, or the result of cls(response) + :return: PolicyDefinition or the result of cls(response) :rtype: ~azure.mgmt.resource.policy.v2016_04_01.models.PolicyDefinition - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.PolicyDefinition"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + 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', "2016-04-01") # type: str + api_version = kwargs.pop("api_version", _params.pop("api-version", "2016-04-01")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[_models.PolicyDefinition] - request = build_policy_definitions_get_request( policy_definition_name=policy_definition_name, subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.get.metadata['url'], + template_url=self.get.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) - deserialized = self._deserialize('PolicyDefinition', pipeline_response) + deserialized = self._deserialize("PolicyDefinition", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - get.metadata = {'url': "/subscriptions/{subscriptionId}/providers/Microsoft.Authorization/policydefinitions/{policyDefinitionName}"} # type: ignore - + get.metadata = {"url": "/subscriptions/{subscriptionId}/providers/Microsoft.Authorization/policydefinitions/{policyDefinitionName}"} # type: ignore @distributed_trace - def list( - self, - filter: Optional[str] = None, - **kwargs: Any - ) -> Iterable["_models.PolicyDefinitionListResult"]: + def list(self, filter: Optional[str] = None, **kwargs: Any) -> Iterable["_models.PolicyDefinition"]: """Gets all the policy definitions for a subscription. :param filter: The filter to apply on the operation. Default value is None. :type filter: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either PolicyDefinitionListResult or the result of - cls(response) + :return: An iterator like instance of either PolicyDefinition or the result of cls(response) :rtype: - ~azure.core.paging.ItemPaged[~azure.mgmt.resource.policy.v2016_04_01.models.PolicyDefinitionListResult] - :raises: ~azure.core.exceptions.HttpResponseError + ~azure.core.paging.ItemPaged[~azure.mgmt.resource.policy.v2016_04_01.models.PolicyDefinition] + :raises ~azure.core.exceptions.HttpResponseError: """ - api_version = kwargs.pop('api_version', "2016-04-01") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2016-04-01")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[_models.PolicyDefinitionListResult] - cls = kwargs.pop('cls', None) # type: ClsType["_models.PolicyDefinitionListResult"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) + def prepare_request(next_link=None): if not next_link: - + request = build_policy_definitions_list_request( subscription_id=self._config.subscription_id, - api_version=api_version, filter=filter, - template_url=self.list.metadata['url'], + 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.url = self._client.format_url(request.url) # type: ignore else: - - request = build_policy_definitions_list_request( - subscription_id=self._config.subscription_id, - template_url=next_link, - ) + # make call to next link with the client's api-version + _parsed_next_link = urlparse(next_link) + _next_request_params = case_insensitive_dict(parse_qs(_parsed_next_link.query)) + _next_request_params["api-version"] = self._config.api_version + request = HttpRequest("GET", urljoin(next_link, _parsed_next_link.path), params=_next_request_params) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore request.method = "GET" return request @@ -1406,10 +1532,8 @@ def extract_data(pipeline_response): def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) response = pipeline_response.http_response @@ -1419,8 +1543,6 @@ def get_next(next_link=None): return pipeline_response + return ItemPaged(get_next, extract_data) - return ItemPaged( - get_next, extract_data - ) - list.metadata = {'url': "/subscriptions/{subscriptionId}/providers/Microsoft.Authorization/policydefinitions"} # type: ignore + list.metadata = {"url": "/subscriptions/{subscriptionId}/providers/Microsoft.Authorization/policydefinitions"} # type: ignore diff --git a/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/policy/v2016_04_01/operations/_patch.py b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/policy/v2016_04_01/operations/_patch.py new file mode 100644 index 0000000000000..f7dd32510333d --- /dev/null +++ b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/policy/v2016_04_01/operations/_patch.py @@ -0,0 +1,20 @@ +# ------------------------------------ +# Copyright (c) Microsoft Corporation. +# Licensed under the MIT License. +# ------------------------------------ +"""Customize generated code here. + +Follow our quickstart for examples: https://aka.ms/azsdk/python/dpcodegen/python/customize +""" +from typing import List + +__all__: List[str] = [] # Add all objects you want publicly available to users at this package level + + +def patch_sdk(): + """Do not remove from this file. + + `patch_sdk` is a last resort escape hatch that allows you to do customizations + you can't accomplish using the techniques described in + https://aka.ms/azsdk/python/dpcodegen/python/customize + """ diff --git a/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/policy/v2016_12_01/__init__.py b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/policy/v2016_12_01/__init__.py index 89180ab440872..bb1ffe59afae7 100644 --- a/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/policy/v2016_12_01/__init__.py +++ b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/policy/v2016_12_01/__init__.py @@ -10,9 +10,15 @@ from ._version import VERSION __version__ = VERSION -__all__ = ['PolicyClient'] -# `._patch.py` is used for handwritten extensions to the generated code -# Example: https://github.com/Azure/azure-sdk-for-python/blob/main/doc/dev/customize_code/how-to-patch-sdk-code.md -from ._patch import patch_sdk -patch_sdk() +try: + from ._patch import __all__ as _patch_all + from ._patch import * # type: ignore # pylint: disable=unused-wildcard-import +except ImportError: + _patch_all = [] +from ._patch import patch_sdk as _patch_sdk + +__all__ = ["PolicyClient"] +__all__.extend([p for p in _patch_all if p not in __all__]) + +_patch_sdk() diff --git a/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/policy/v2016_12_01/_configuration.py b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/policy/v2016_12_01/_configuration.py index 28447986defff..f8ec8bf8cff10 100644 --- a/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/policy/v2016_12_01/_configuration.py +++ b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/policy/v2016_12_01/_configuration.py @@ -25,23 +25,18 @@ class PolicyClientConfiguration(Configuration): # pylint: disable=too-many-inst Note that all parameters used to create this instance are saved as instance attributes. - :param credential: Credential needed for the client to connect to Azure. + :param credential: Credential needed for the client to connect to Azure. Required. :type credential: ~azure.core.credentials.TokenCredential - :param subscription_id: The ID of the target subscription. + :param subscription_id: The ID of the target subscription. Required. :type subscription_id: str :keyword api_version: Api Version. Default value is "2016-12-01". Note that overriding this default value may result in unsupported behavior. :paramtype api_version: str """ - def __init__( - self, - credential: "TokenCredential", - subscription_id: str, - **kwargs: Any - ) -> None: + def __init__(self, credential: "TokenCredential", subscription_id: str, **kwargs: Any) -> None: super(PolicyClientConfiguration, self).__init__(**kwargs) - api_version = kwargs.pop('api_version', "2016-12-01") # type: str + api_version = kwargs.pop("api_version", "2016-12-01") # type: str if credential is None: raise ValueError("Parameter 'credential' must not be None.") @@ -51,23 +46,24 @@ def __init__( self.credential = credential self.subscription_id = subscription_id self.api_version = api_version - self.credential_scopes = kwargs.pop('credential_scopes', ['https://management.azure.com/.default']) - kwargs.setdefault('sdk_moniker', 'mgmt-resource/{}'.format(VERSION)) + self.credential_scopes = kwargs.pop("credential_scopes", ["https://management.azure.com/.default"]) + kwargs.setdefault("sdk_moniker", "mgmt-resource/{}".format(VERSION)) self._configure(**kwargs) def _configure( - self, - **kwargs # type: Any + self, **kwargs # type: Any ): # type: (...) -> 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) - self.logging_policy = kwargs.get('logging_policy') or policies.NetworkTraceLoggingPolicy(**kwargs) - self.http_logging_policy = kwargs.get('http_logging_policy') or ARMHttpLoggingPolicy(**kwargs) - self.retry_policy = kwargs.get('retry_policy') or policies.RetryPolicy(**kwargs) - self.custom_hook_policy = kwargs.get('custom_hook_policy') or policies.CustomHookPolicy(**kwargs) - self.redirect_policy = kwargs.get('redirect_policy') or policies.RedirectPolicy(**kwargs) - self.authentication_policy = kwargs.get('authentication_policy') + 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) + self.logging_policy = kwargs.get("logging_policy") or policies.NetworkTraceLoggingPolicy(**kwargs) + self.http_logging_policy = kwargs.get("http_logging_policy") or ARMHttpLoggingPolicy(**kwargs) + self.retry_policy = kwargs.get("retry_policy") or policies.RetryPolicy(**kwargs) + self.custom_hook_policy = kwargs.get("custom_hook_policy") or policies.CustomHookPolicy(**kwargs) + self.redirect_policy = kwargs.get("redirect_policy") or policies.RedirectPolicy(**kwargs) + self.authentication_policy = kwargs.get("authentication_policy") if self.credential and not self.authentication_policy: - self.authentication_policy = ARMChallengeAuthenticationPolicy(self.credential, *self.credential_scopes, **kwargs) + self.authentication_policy = ARMChallengeAuthenticationPolicy( + self.credential, *self.credential_scopes, **kwargs + ) diff --git a/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/policy/v2016_12_01/_metadata.json b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/policy/v2016_12_01/_metadata.json index 40f19d9b24c44..4a4ef60e12868 100644 --- a/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/policy/v2016_12_01/_metadata.json +++ b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/policy/v2016_12_01/_metadata.json @@ -10,20 +10,20 @@ "azure_arm": true, "has_lro_operations": false, "client_side_validation": false, - "sync_imports": "{\"typing\": {\"azurecore\": {\"azure.core.credentials\": [\"TokenCredential\"]}}, \"regular\": {\"azurecore\": {\"azure.profiles\": [\"KnownProfiles\", \"ProfileDefinition\"], \"azure.profiles.multiapiclient\": [\"MultiApiClientMixin\"], \"azure.mgmt.core\": [\"ARMPipelineClient\"]}, \"local\": {\"._configuration\": [\"PolicyClientConfiguration\"]}, \"thirdparty\": {\"msrest\": [\"Deserializer\", \"Serializer\"]}}, \"conditional\": {\"stdlib\": {\"typing\": [\"Any\", \"Optional\"]}}}", - "async_imports": "{\"typing\": {\"azurecore\": {\"azure.core.credentials_async\": [\"AsyncTokenCredential\"], \"azure.core.credentials\": [\"TokenCredential\"]}}, \"regular\": {\"azurecore\": {\"azure.profiles\": [\"KnownProfiles\", \"ProfileDefinition\"], \"azure.profiles.multiapiclient\": [\"MultiApiClientMixin\"], \"azure.mgmt.core\": [\"AsyncARMPipelineClient\"]}, \"local\": {\"._configuration\": [\"PolicyClientConfiguration\"]}, \"thirdparty\": {\"msrest\": [\"Deserializer\", \"Serializer\"]}}, \"conditional\": {\"stdlib\": {\"typing\": [\"Any\", \"Optional\"]}}}" + "sync_imports": "{\"conditional\": {\"stdlib\": {\"typing\": [\"Any\", \"Optional\"]}}, \"regular\": {\"azurecore\": {\"azure.mgmt.core\": [\"ARMPipelineClient\"], \"azure.profiles\": [\"KnownProfiles\", \"ProfileDefinition\"], \"azure.profiles.multiapiclient\": [\"MultiApiClientMixin\"]}, \"local\": {\"._configuration\": [\"PolicyClientConfiguration\"], \".._serialization\": [\"Deserializer\", \"Serializer\"]}}, \"typing\": {\"azurecore\": {\"azure.core.credentials\": [\"TokenCredential\"]}}}", + "async_imports": "{\"conditional\": {\"stdlib\": {\"typing\": [\"Any\", \"Optional\"]}}, \"regular\": {\"azurecore\": {\"azure.mgmt.core\": [\"AsyncARMPipelineClient\"], \"azure.profiles\": [\"KnownProfiles\", \"ProfileDefinition\"], \"azure.profiles.multiapiclient\": [\"MultiApiClientMixin\"]}, \"local\": {\"._configuration\": [\"PolicyClientConfiguration\"], \"..._serialization\": [\"Deserializer\", \"Serializer\"]}}, \"typing\": {\"azurecore\": {\"azure.core.credentials_async\": [\"AsyncTokenCredential\"]}}}" }, "global_parameters": { "sync": { "credential": { - "signature": "credential, # type: \"TokenCredential\"", - "description": "Credential needed for the client to connect to Azure.", + "signature": "credential: \"TokenCredential\",", + "description": "Credential needed for the client to connect to Azure. Required.", "docstring_type": "~azure.core.credentials.TokenCredential", "required": true }, "subscription_id": { - "signature": "subscription_id, # type: str", - "description": "The ID of the target subscription.", + "signature": "subscription_id: str,", + "description": "The ID of the target subscription. Required.", "docstring_type": "str", "required": true } @@ -31,13 +31,13 @@ "async": { "credential": { "signature": "credential: \"AsyncTokenCredential\",", - "description": "Credential needed for the client to connect to Azure.", + "description": "Credential needed for the client to connect to Azure. Required.", "docstring_type": "~azure.core.credentials_async.AsyncTokenCredential", "required": true }, "subscription_id": { "signature": "subscription_id: str,", - "description": "The ID of the target subscription.", + "description": "The ID of the target subscription. Required.", "docstring_type": "str", "required": true } @@ -54,7 +54,7 @@ "required": false }, "base_url": { - "signature": "base_url=\"https://management.azure.com\", # type: str", + "signature": "base_url: str = \"https://management.azure.com\",", "description": "Service URL", "docstring_type": "str", "required": false diff --git a/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/policy/v2016_12_01/_patch.py b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/policy/v2016_12_01/_patch.py index 74e48ecd07cf3..f99e77fef9861 100644 --- a/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/policy/v2016_12_01/_patch.py +++ b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/policy/v2016_12_01/_patch.py @@ -28,4 +28,4 @@ # This file is used for handwritten extensions to the generated code. Example: # https://github.com/Azure/azure-sdk-for-python/blob/main/doc/dev/customize_code/how-to-patch-sdk-code.md def patch_sdk(): - pass \ No newline at end of file + pass diff --git a/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/policy/v2016_12_01/_policy_client.py b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/policy/v2016_12_01/_policy_client.py index c6440fb52a8cc..8c3f485de87c9 100644 --- a/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/policy/v2016_12_01/_policy_client.py +++ b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/policy/v2016_12_01/_policy_client.py @@ -9,12 +9,11 @@ from copy import deepcopy from typing import Any, TYPE_CHECKING -from msrest import Deserializer, Serializer - from azure.core.rest import HttpRequest, HttpResponse from azure.mgmt.core import ARMPipelineClient from . import models +from .._serialization import Deserializer, Serializer from ._configuration import PolicyClientConfiguration from .operations import PolicyAssignmentsOperations, PolicyDefinitionsOperations @@ -22,7 +21,8 @@ # pylint: disable=unused-import,ungrouped-imports from azure.core.credentials import TokenCredential -class PolicyClient: + +class PolicyClient: # pylint: disable=client-accepts-api-version-keyword """To manage and control access to your resources, you can define customized policies and assign them at a scope. @@ -32,9 +32,9 @@ class PolicyClient: :ivar policy_assignments: PolicyAssignmentsOperations operations :vartype policy_assignments: azure.mgmt.resource.policy.v2016_12_01.operations.PolicyAssignmentsOperations - :param credential: Credential needed for the client to connect to Azure. + :param credential: Credential needed for the client to connect to Azure. Required. :type credential: ~azure.core.credentials.TokenCredential - :param subscription_id: The ID of the target subscription. + :param subscription_id: The ID of the target subscription. Required. :type subscription_id: str :param base_url: Service URL. Default value is "https://management.azure.com". :type base_url: str @@ -57,15 +57,14 @@ def __init__( self._serialize = Serializer(client_models) self._deserialize = Deserializer(client_models) self._serialize.client_side_validation = False - self.policy_definitions = PolicyDefinitionsOperations(self._client, self._config, self._serialize, self._deserialize) - self.policy_assignments = PolicyAssignmentsOperations(self._client, self._config, self._serialize, self._deserialize) - - - def _send_request( - self, - request: HttpRequest, - **kwargs: Any - ) -> HttpResponse: + self.policy_definitions = PolicyDefinitionsOperations( + self._client, self._config, self._serialize, self._deserialize + ) + self.policy_assignments = PolicyAssignmentsOperations( + self._client, self._config, self._serialize, self._deserialize + ) + + def _send_request(self, request: HttpRequest, **kwargs: Any) -> HttpResponse: """Runs the network request through the client's chained policies. >>> from azure.core.rest import HttpRequest @@ -74,7 +73,7 @@ def _send_request( >>> response = client._send_request(request) - For more information on this code flow, see https://aka.ms/azsdk/python/protocol/quickstart + For more information on this code flow, see https://aka.ms/azsdk/dpcodegen/python/send_request :param request: The network request you want to make. Required. :type request: ~azure.core.rest.HttpRequest diff --git a/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/policy/v2016_12_01/_vendor.py b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/policy/v2016_12_01/_vendor.py index 138f663c53a4e..9aad73fc743e7 100644 --- a/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/policy/v2016_12_01/_vendor.py +++ b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/policy/v2016_12_01/_vendor.py @@ -7,6 +7,7 @@ from azure.core.pipeline.transport import HttpRequest + def _convert_request(request, files=None): data = request.content if not files else None request = HttpRequest(method=request.method, url=request.url, headers=request.headers, data=data) @@ -14,6 +15,7 @@ def _convert_request(request, files=None): request.set_formdata_body(files) return request + def _format_url_section(template, **kwargs): components = template.split("/") while components: @@ -21,7 +23,5 @@ def _format_url_section(template, **kwargs): 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 - ] + components = [c for c in formatted_components if "{}".format(key.args[0]) not in c] template = "/".join(components) diff --git a/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/policy/v2016_12_01/_version.py b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/policy/v2016_12_01/_version.py index a012ac01c480c..e5754a47ce68f 100644 --- a/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/policy/v2016_12_01/_version.py +++ b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/policy/v2016_12_01/_version.py @@ -6,4 +6,4 @@ # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -VERSION = "21.1.0" +VERSION = "1.0.0b1" diff --git a/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/policy/v2016_12_01/aio/__init__.py b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/policy/v2016_12_01/aio/__init__.py index 2784ce3f14bf5..4622bf1f396a7 100644 --- a/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/policy/v2016_12_01/aio/__init__.py +++ b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/policy/v2016_12_01/aio/__init__.py @@ -7,9 +7,15 @@ # -------------------------------------------------------------------------- from ._policy_client import PolicyClient -__all__ = ['PolicyClient'] -# `._patch.py` is used for handwritten extensions to the generated code -# Example: https://github.com/Azure/azure-sdk-for-python/blob/main/doc/dev/customize_code/how-to-patch-sdk-code.md -from ._patch import patch_sdk -patch_sdk() +try: + from ._patch import __all__ as _patch_all + from ._patch import * # type: ignore # pylint: disable=unused-wildcard-import +except ImportError: + _patch_all = [] +from ._patch import patch_sdk as _patch_sdk + +__all__ = ["PolicyClient"] +__all__.extend([p for p in _patch_all if p not in __all__]) + +_patch_sdk() diff --git a/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/policy/v2016_12_01/aio/_configuration.py b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/policy/v2016_12_01/aio/_configuration.py index e95176d4b3348..1d988e57b156b 100644 --- a/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/policy/v2016_12_01/aio/_configuration.py +++ b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/policy/v2016_12_01/aio/_configuration.py @@ -25,23 +25,18 @@ class PolicyClientConfiguration(Configuration): # pylint: disable=too-many-inst Note that all parameters used to create this instance are saved as instance attributes. - :param credential: Credential needed for the client to connect to Azure. + :param credential: Credential needed for the client to connect to Azure. Required. :type credential: ~azure.core.credentials_async.AsyncTokenCredential - :param subscription_id: The ID of the target subscription. + :param subscription_id: The ID of the target subscription. Required. :type subscription_id: str :keyword api_version: Api Version. Default value is "2016-12-01". Note that overriding this default value may result in unsupported behavior. :paramtype api_version: str """ - def __init__( - self, - credential: "AsyncTokenCredential", - subscription_id: str, - **kwargs: Any - ) -> None: + def __init__(self, credential: "AsyncTokenCredential", subscription_id: str, **kwargs: Any) -> None: super(PolicyClientConfiguration, self).__init__(**kwargs) - api_version = kwargs.pop('api_version', "2016-12-01") # type: str + api_version = kwargs.pop("api_version", "2016-12-01") # type: str if credential is None: raise ValueError("Parameter 'credential' must not be None.") @@ -51,22 +46,21 @@ def __init__( self.credential = credential self.subscription_id = subscription_id self.api_version = api_version - self.credential_scopes = kwargs.pop('credential_scopes', ['https://management.azure.com/.default']) - kwargs.setdefault('sdk_moniker', 'mgmt-resource/{}'.format(VERSION)) + self.credential_scopes = kwargs.pop("credential_scopes", ["https://management.azure.com/.default"]) + kwargs.setdefault("sdk_moniker", "mgmt-resource/{}".format(VERSION)) self._configure(**kwargs) - 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) - self.logging_policy = kwargs.get('logging_policy') or policies.NetworkTraceLoggingPolicy(**kwargs) - self.http_logging_policy = kwargs.get('http_logging_policy') or ARMHttpLoggingPolicy(**kwargs) - self.retry_policy = kwargs.get('retry_policy') or policies.AsyncRetryPolicy(**kwargs) - self.custom_hook_policy = kwargs.get('custom_hook_policy') or policies.CustomHookPolicy(**kwargs) - self.redirect_policy = kwargs.get('redirect_policy') or policies.AsyncRedirectPolicy(**kwargs) - self.authentication_policy = kwargs.get('authentication_policy') + 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) + self.logging_policy = kwargs.get("logging_policy") or policies.NetworkTraceLoggingPolicy(**kwargs) + self.http_logging_policy = kwargs.get("http_logging_policy") or ARMHttpLoggingPolicy(**kwargs) + self.retry_policy = kwargs.get("retry_policy") or policies.AsyncRetryPolicy(**kwargs) + self.custom_hook_policy = kwargs.get("custom_hook_policy") or policies.CustomHookPolicy(**kwargs) + self.redirect_policy = kwargs.get("redirect_policy") or policies.AsyncRedirectPolicy(**kwargs) + self.authentication_policy = kwargs.get("authentication_policy") if self.credential and not self.authentication_policy: - self.authentication_policy = AsyncARMChallengeAuthenticationPolicy(self.credential, *self.credential_scopes, **kwargs) + self.authentication_policy = AsyncARMChallengeAuthenticationPolicy( + self.credential, *self.credential_scopes, **kwargs + ) diff --git a/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/policy/v2016_12_01/aio/_patch.py b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/policy/v2016_12_01/aio/_patch.py index 74e48ecd07cf3..f99e77fef9861 100644 --- a/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/policy/v2016_12_01/aio/_patch.py +++ b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/policy/v2016_12_01/aio/_patch.py @@ -28,4 +28,4 @@ # This file is used for handwritten extensions to the generated code. Example: # https://github.com/Azure/azure-sdk-for-python/blob/main/doc/dev/customize_code/how-to-patch-sdk-code.md def patch_sdk(): - pass \ No newline at end of file + pass diff --git a/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/policy/v2016_12_01/aio/_policy_client.py b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/policy/v2016_12_01/aio/_policy_client.py index 6f1ae234ff797..36796c16d87d3 100644 --- a/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/policy/v2016_12_01/aio/_policy_client.py +++ b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/policy/v2016_12_01/aio/_policy_client.py @@ -9,12 +9,11 @@ from copy import deepcopy from typing import Any, Awaitable, TYPE_CHECKING -from msrest import Deserializer, Serializer - from azure.core.rest import AsyncHttpResponse, HttpRequest from azure.mgmt.core import AsyncARMPipelineClient from .. import models +from ..._serialization import Deserializer, Serializer from ._configuration import PolicyClientConfiguration from .operations import PolicyAssignmentsOperations, PolicyDefinitionsOperations @@ -22,7 +21,8 @@ # pylint: disable=unused-import,ungrouped-imports from azure.core.credentials_async import AsyncTokenCredential -class PolicyClient: + +class PolicyClient: # pylint: disable=client-accepts-api-version-keyword """To manage and control access to your resources, you can define customized policies and assign them at a scope. @@ -32,9 +32,9 @@ class PolicyClient: :ivar policy_assignments: PolicyAssignmentsOperations operations :vartype policy_assignments: azure.mgmt.resource.policy.v2016_12_01.aio.operations.PolicyAssignmentsOperations - :param credential: Credential needed for the client to connect to Azure. + :param credential: Credential needed for the client to connect to Azure. Required. :type credential: ~azure.core.credentials_async.AsyncTokenCredential - :param subscription_id: The ID of the target subscription. + :param subscription_id: The ID of the target subscription. Required. :type subscription_id: str :param base_url: Service URL. Default value is "https://management.azure.com". :type base_url: str @@ -57,15 +57,14 @@ def __init__( self._serialize = Serializer(client_models) self._deserialize = Deserializer(client_models) self._serialize.client_side_validation = False - self.policy_definitions = PolicyDefinitionsOperations(self._client, self._config, self._serialize, self._deserialize) - self.policy_assignments = PolicyAssignmentsOperations(self._client, self._config, self._serialize, self._deserialize) - - - def _send_request( - self, - request: HttpRequest, - **kwargs: Any - ) -> Awaitable[AsyncHttpResponse]: + self.policy_definitions = PolicyDefinitionsOperations( + self._client, self._config, self._serialize, self._deserialize + ) + self.policy_assignments = PolicyAssignmentsOperations( + self._client, self._config, self._serialize, self._deserialize + ) + + def _send_request(self, request: HttpRequest, **kwargs: Any) -> Awaitable[AsyncHttpResponse]: """Runs the network request through the client's chained policies. >>> from azure.core.rest import HttpRequest @@ -74,7 +73,7 @@ def _send_request( >>> response = await client._send_request(request) - For more information on this code flow, see https://aka.ms/azsdk/python/protocol/quickstart + For more information on this code flow, see https://aka.ms/azsdk/dpcodegen/python/send_request :param request: The network request you want to make. Required. :type request: ~azure.core.rest.HttpRequest diff --git a/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/policy/v2016_12_01/aio/operations/__init__.py b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/policy/v2016_12_01/aio/operations/__init__.py index 7636edce1e12a..ced86dae62e6f 100644 --- a/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/policy/v2016_12_01/aio/operations/__init__.py +++ b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/policy/v2016_12_01/aio/operations/__init__.py @@ -9,7 +9,13 @@ from ._operations import PolicyDefinitionsOperations from ._operations import PolicyAssignmentsOperations +from ._patch import __all__ as _patch_all +from ._patch import * # type: ignore # pylint: disable=unused-wildcard-import +from ._patch import patch_sdk as _patch_sdk + __all__ = [ - 'PolicyDefinitionsOperations', - 'PolicyAssignmentsOperations', + "PolicyDefinitionsOperations", + "PolicyAssignmentsOperations", ] +__all__.extend([p for p in _patch_all if p not in __all__]) +_patch_sdk() diff --git a/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/policy/v2016_12_01/aio/operations/_operations.py b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/policy/v2016_12_01/aio/operations/_operations.py index 1034abcef50d0..de9afa58b4a44 100644 --- a/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/policy/v2016_12_01/aio/operations/_operations.py +++ b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/policy/v2016_12_01/aio/operations/_operations.py @@ -6,77 +6,157 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -from typing import Any, AsyncIterable, Callable, Dict, Optional, TypeVar +from typing import Any, AsyncIterable, Callable, Dict, IO, Optional, TypeVar, Union, overload +from urllib.parse import parse_qs, urljoin, urlparse from azure.core.async_paging import AsyncItemPaged, AsyncList -from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error +from azure.core.exceptions import ( + ClientAuthenticationError, + HttpResponseError, + ResourceExistsError, + ResourceNotFoundError, + ResourceNotModifiedError, + map_error, +) from azure.core.pipeline import PipelineResponse from azure.core.pipeline.transport import AsyncHttpResponse from azure.core.rest import HttpRequest from azure.core.tracing.decorator import distributed_trace from azure.core.tracing.decorator_async import distributed_trace_async +from azure.core.utils import case_insensitive_dict from azure.mgmt.core.exceptions import ARMErrorFormat from ... import models as _models from ..._vendor import _convert_request -from ...operations._operations import build_policy_assignments_create_by_id_request, build_policy_assignments_create_request, build_policy_assignments_delete_by_id_request, build_policy_assignments_delete_request, build_policy_assignments_get_by_id_request, build_policy_assignments_get_request, build_policy_assignments_list_for_resource_group_request, build_policy_assignments_list_for_resource_request, build_policy_assignments_list_request, build_policy_definitions_create_or_update_at_management_group_request, build_policy_definitions_create_or_update_request, build_policy_definitions_delete_at_management_group_request, build_policy_definitions_delete_request, build_policy_definitions_get_at_management_group_request, build_policy_definitions_get_built_in_request, build_policy_definitions_get_request, build_policy_definitions_list_built_in_request, build_policy_definitions_list_by_management_group_request, build_policy_definitions_list_request -T = TypeVar('T') +from ...operations._operations import ( + build_policy_assignments_create_by_id_request, + build_policy_assignments_create_request, + build_policy_assignments_delete_by_id_request, + build_policy_assignments_delete_request, + build_policy_assignments_get_by_id_request, + build_policy_assignments_get_request, + build_policy_assignments_list_for_resource_group_request, + build_policy_assignments_list_for_resource_request, + build_policy_assignments_list_request, + build_policy_definitions_create_or_update_at_management_group_request, + build_policy_definitions_create_or_update_request, + build_policy_definitions_delete_at_management_group_request, + build_policy_definitions_delete_request, + build_policy_definitions_get_at_management_group_request, + build_policy_definitions_get_built_in_request, + build_policy_definitions_get_request, + build_policy_definitions_list_built_in_request, + build_policy_definitions_list_by_management_group_request, + build_policy_definitions_list_request, +) + +T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] -class PolicyDefinitionsOperations: - """PolicyDefinitionsOperations async operations. - You should not instantiate this class directly. Instead, you should create a Client instance that - instantiates it for you and attaches it as an attribute. +class PolicyDefinitionsOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. - :ivar models: Alias to model classes used in this operation group. - :type models: ~azure.mgmt.resource.policy.v2016_12_01.models - :param client: Client for service requests. - :param config: Configuration of service client. - :param serializer: An object model serializer. - :param deserializer: An object model deserializer. + Instead, you should access the following operations through + :class:`~azure.mgmt.resource.policy.v2016_12_01.aio.PolicyClient`'s + :attr:`policy_definitions` attribute. """ models = _models - def __init__(self, client, config, serializer, deserializer) -> None: - self._client = client - self._serialize = serializer - self._deserialize = deserializer - self._config = config + def __init__(self, *args, **kwargs) -> None: + input_args = list(args) + self._client = input_args.pop(0) if input_args else kwargs.pop("client") + self._config = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") - @distributed_trace_async + @overload async def create_or_update( self, policy_definition_name: str, - parameters: "_models.PolicyDefinition", + parameters: _models.PolicyDefinition, *, - content_type: Optional[str] = "application/json", + content_type: str = "application/json", **kwargs: Any - ) -> "_models.PolicyDefinition": + ) -> _models.PolicyDefinition: """Creates or updates a policy definition. - :param policy_definition_name: The name of the policy definition to create. + :param policy_definition_name: The name of the policy definition to create. Required. :type policy_definition_name: str - :param parameters: The policy definition properties. + :param parameters: The policy definition properties. Required. :type parameters: ~azure.mgmt.resource.policy.v2016_12_01.models.PolicyDefinition - :keyword content_type: Media type of the body sent to the API. Possible values are: - "application/json" or "text/json". Default value is "application/json". + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: PolicyDefinition or the result of cls(response) + :rtype: ~azure.mgmt.resource.policy.v2016_12_01.models.PolicyDefinition + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + async def create_or_update( + self, policy_definition_name: str, parameters: IO, *, content_type: str = "application/json", **kwargs: Any + ) -> _models.PolicyDefinition: + """Creates or updates a policy definition. + + :param policy_definition_name: The name of the policy definition to create. Required. + :type policy_definition_name: str + :param parameters: The policy definition properties. Required. + :type parameters: IO + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Known values are: 'application/json', 'text/json'. Default value is "application/json". + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: PolicyDefinition or the result of cls(response) + :rtype: ~azure.mgmt.resource.policy.v2016_12_01.models.PolicyDefinition + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace_async + async def create_or_update( + self, policy_definition_name: str, parameters: Union[_models.PolicyDefinition, IO], **kwargs: Any + ) -> _models.PolicyDefinition: + """Creates or updates a policy definition. + + :param policy_definition_name: The name of the policy definition to create. Required. + :type policy_definition_name: str + :param parameters: The policy definition properties. Is either a model type or a IO type. + Required. + :type parameters: ~azure.mgmt.resource.policy.v2016_12_01.models.PolicyDefinition or IO + :keyword content_type: Body Parameter content-type. Known values are: 'application/json', + 'text/json'. Default value is None. :paramtype content_type: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: PolicyDefinition, or the result of cls(response) + :return: PolicyDefinition or the result of cls(response) :rtype: ~azure.mgmt.resource.policy.v2016_12_01.models.PolicyDefinition - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.PolicyDefinition"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', "2016-12-01") # type: str + api_version = kwargs.pop("api_version", _params.pop("api-version", "2016-12-01")) # type: str + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.PolicyDefinition] - _json = self._serialize.body(parameters, 'PolicyDefinition') + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(parameters, (IO, bytes)): + _content = parameters + else: + _json = self._serialize.body(parameters, "PolicyDefinition") request = build_policy_definitions_create_or_update_request( policy_definition_name=policy_definition_name, @@ -84,70 +164,75 @@ async def create_or_update( api_version=api_version, content_type=content_type, json=_json, - template_url=self.create_or_update.metadata['url'], + content=_content, + template_url=self.create_or_update.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [201]: map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) - deserialized = self._deserialize('PolicyDefinition', pipeline_response) + deserialized = self._deserialize("PolicyDefinition", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - create_or_update.metadata = {'url': "/subscriptions/{subscriptionId}/providers/Microsoft.Authorization/policyDefinitions/{policyDefinitionName}"} # type: ignore - + create_or_update.metadata = {"url": "/subscriptions/{subscriptionId}/providers/Microsoft.Authorization/policyDefinitions/{policyDefinitionName}"} # type: ignore @distributed_trace_async async def delete( # pylint: disable=inconsistent-return-statements - self, - policy_definition_name: str, - **kwargs: Any + self, policy_definition_name: str, **kwargs: Any ) -> None: """Deletes a policy definition. - :param policy_definition_name: The name of the policy definition to delete. + :param policy_definition_name: The name of the policy definition to delete. Required. :type policy_definition_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: None, or the result of cls(response) + :return: None or the result of cls(response) :rtype: None - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType[None] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + 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', "2016-12-01") # type: str + api_version = kwargs.pop("api_version", _params.pop("api-version", "2016-12-01")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[None] - request = build_policy_definitions_delete_request( policy_definition_name=policy_definition_name, subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.delete.metadata['url'], + template_url=self.delete.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200, 204]: @@ -157,151 +242,218 @@ async def delete( # pylint: disable=inconsistent-return-statements if cls: return cls(pipeline_response, None, {}) - delete.metadata = {'url': "/subscriptions/{subscriptionId}/providers/Microsoft.Authorization/policyDefinitions/{policyDefinitionName}"} # type: ignore - + delete.metadata = {"url": "/subscriptions/{subscriptionId}/providers/Microsoft.Authorization/policyDefinitions/{policyDefinitionName}"} # type: ignore @distributed_trace_async - async def get( - self, - policy_definition_name: str, - **kwargs: Any - ) -> "_models.PolicyDefinition": + async def get(self, policy_definition_name: str, **kwargs: Any) -> _models.PolicyDefinition: """Gets the policy definition. - :param policy_definition_name: The name of the policy definition to get. + :param policy_definition_name: The name of the policy definition to get. Required. :type policy_definition_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: PolicyDefinition, or the result of cls(response) + :return: PolicyDefinition or the result of cls(response) :rtype: ~azure.mgmt.resource.policy.v2016_12_01.models.PolicyDefinition - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.PolicyDefinition"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + 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', "2016-12-01") # type: str + api_version = kwargs.pop("api_version", _params.pop("api-version", "2016-12-01")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[_models.PolicyDefinition] - request = build_policy_definitions_get_request( policy_definition_name=policy_definition_name, subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.get.metadata['url'], + template_url=self.get.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) - deserialized = self._deserialize('PolicyDefinition', pipeline_response) + deserialized = self._deserialize("PolicyDefinition", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - get.metadata = {'url': "/subscriptions/{subscriptionId}/providers/Microsoft.Authorization/policyDefinitions/{policyDefinitionName}"} # type: ignore - + get.metadata = {"url": "/subscriptions/{subscriptionId}/providers/Microsoft.Authorization/policyDefinitions/{policyDefinitionName}"} # type: ignore @distributed_trace_async - async def get_built_in( - self, - policy_definition_name: str, - **kwargs: Any - ) -> "_models.PolicyDefinition": + async def get_built_in(self, policy_definition_name: str, **kwargs: Any) -> _models.PolicyDefinition: """Gets the built in policy definition. - :param policy_definition_name: The name of the built in policy definition to get. + :param policy_definition_name: The name of the built in policy definition to get. Required. :type policy_definition_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: PolicyDefinition, or the result of cls(response) + :return: PolicyDefinition or the result of cls(response) :rtype: ~azure.mgmt.resource.policy.v2016_12_01.models.PolicyDefinition - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.PolicyDefinition"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) - api_version = kwargs.pop('api_version', "2016-12-01") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2016-12-01")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[_models.PolicyDefinition] - request = build_policy_definitions_get_built_in_request( policy_definition_name=policy_definition_name, api_version=api_version, - template_url=self.get_built_in.metadata['url'], + template_url=self.get_built_in.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) - deserialized = self._deserialize('PolicyDefinition', pipeline_response) + deserialized = self._deserialize("PolicyDefinition", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - get_built_in.metadata = {'url': "/providers/Microsoft.Authorization/policyDefinitions/{policyDefinitionName}"} # type: ignore + get_built_in.metadata = {"url": "/providers/Microsoft.Authorization/policyDefinitions/{policyDefinitionName}"} # type: ignore - - @distributed_trace_async + @overload async def create_or_update_at_management_group( self, policy_definition_name: str, management_group_id: str, - parameters: "_models.PolicyDefinition", + parameters: _models.PolicyDefinition, *, - content_type: Optional[str] = "application/json", + content_type: str = "application/json", **kwargs: Any - ) -> "_models.PolicyDefinition": + ) -> _models.PolicyDefinition: """Creates or updates a policy definition at management group level. - :param policy_definition_name: The name of the policy definition to create. + :param policy_definition_name: The name of the policy definition to create. Required. :type policy_definition_name: str - :param management_group_id: The ID of the management group. + :param management_group_id: The ID of the management group. Required. :type management_group_id: str - :param parameters: The policy definition properties. + :param parameters: The policy definition properties. Required. :type parameters: ~azure.mgmt.resource.policy.v2016_12_01.models.PolicyDefinition - :keyword content_type: Media type of the body sent to the API. Possible values are: - "application/json" or "text/json". Default value is "application/json". + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: PolicyDefinition or the result of cls(response) + :rtype: ~azure.mgmt.resource.policy.v2016_12_01.models.PolicyDefinition + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + async def create_or_update_at_management_group( + self, + policy_definition_name: str, + management_group_id: str, + parameters: IO, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.PolicyDefinition: + """Creates or updates a policy definition at management group level. + + :param policy_definition_name: The name of the policy definition to create. Required. + :type policy_definition_name: str + :param management_group_id: The ID of the management group. Required. + :type management_group_id: str + :param parameters: The policy definition properties. Required. + :type parameters: IO + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Known values are: 'application/json', 'text/json'. Default value is "application/json". + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: PolicyDefinition or the result of cls(response) + :rtype: ~azure.mgmt.resource.policy.v2016_12_01.models.PolicyDefinition + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace_async + async def create_or_update_at_management_group( + self, + policy_definition_name: str, + management_group_id: str, + parameters: Union[_models.PolicyDefinition, IO], + **kwargs: Any + ) -> _models.PolicyDefinition: + """Creates or updates a policy definition at management group level. + + :param policy_definition_name: The name of the policy definition to create. Required. + :type policy_definition_name: str + :param management_group_id: The ID of the management group. Required. + :type management_group_id: str + :param parameters: The policy definition properties. Is either a model type or a IO type. + Required. + :type parameters: ~azure.mgmt.resource.policy.v2016_12_01.models.PolicyDefinition or IO + :keyword content_type: Body Parameter content-type. Known values are: 'application/json', + 'text/json'. Default value is None. :paramtype content_type: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: PolicyDefinition, or the result of cls(response) + :return: PolicyDefinition or the result of cls(response) :rtype: ~azure.mgmt.resource.policy.v2016_12_01.models.PolicyDefinition - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.PolicyDefinition"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', "2016-12-01") # type: str + api_version = kwargs.pop("api_version", _params.pop("api-version", "2016-12-01")) # type: str + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.PolicyDefinition] - _json = self._serialize.body(parameters, 'PolicyDefinition') + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(parameters, (IO, bytes)): + _content = parameters + else: + _json = self._serialize.body(parameters, "PolicyDefinition") request = build_policy_definitions_create_or_update_at_management_group_request( policy_definition_name=policy_definition_name, @@ -309,73 +461,77 @@ async def create_or_update_at_management_group( api_version=api_version, content_type=content_type, json=_json, - template_url=self.create_or_update_at_management_group.metadata['url'], + content=_content, + template_url=self.create_or_update_at_management_group.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [201]: map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) - deserialized = self._deserialize('PolicyDefinition', pipeline_response) + deserialized = self._deserialize("PolicyDefinition", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - create_or_update_at_management_group.metadata = {'url': "/providers/Microsoft.Management/managementgroups/{managementGroupId}/providers/Microsoft.Authorization/policyDefinitions/{policyDefinitionName}"} # type: ignore - + create_or_update_at_management_group.metadata = {"url": "/providers/Microsoft.Management/managementgroups/{managementGroupId}/providers/Microsoft.Authorization/policyDefinitions/{policyDefinitionName}"} # type: ignore @distributed_trace_async async def delete_at_management_group( # pylint: disable=inconsistent-return-statements - self, - policy_definition_name: str, - management_group_id: str, - **kwargs: Any + self, policy_definition_name: str, management_group_id: str, **kwargs: Any ) -> None: """Deletes a policy definition at management group level. - :param policy_definition_name: The name of the policy definition to delete. + :param policy_definition_name: The name of the policy definition to delete. Required. :type policy_definition_name: str - :param management_group_id: The ID of the management group. + :param management_group_id: The ID of the management group. Required. :type management_group_id: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: None, or the result of cls(response) + :return: None or the result of cls(response) :rtype: None - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType[None] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) - api_version = kwargs.pop('api_version', "2016-12-01") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2016-12-01")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[None] - request = build_policy_definitions_delete_at_management_group_request( policy_definition_name=policy_definition_name, management_group_id=management_group_id, api_version=api_version, - template_url=self.delete_at_management_group.metadata['url'], + template_url=self.delete_at_management_group.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200, 204]: @@ -385,106 +541,112 @@ async def delete_at_management_group( # pylint: disable=inconsistent-return-sta if cls: return cls(pipeline_response, None, {}) - delete_at_management_group.metadata = {'url': "/providers/Microsoft.Management/managementgroups/{managementGroupId}/providers/Microsoft.Authorization/policyDefinitions/{policyDefinitionName}"} # type: ignore - + delete_at_management_group.metadata = {"url": "/providers/Microsoft.Management/managementgroups/{managementGroupId}/providers/Microsoft.Authorization/policyDefinitions/{policyDefinitionName}"} # type: ignore @distributed_trace_async async def get_at_management_group( - self, - policy_definition_name: str, - management_group_id: str, - **kwargs: Any - ) -> "_models.PolicyDefinition": + self, policy_definition_name: str, management_group_id: str, **kwargs: Any + ) -> _models.PolicyDefinition: """Gets the policy definition at management group level. - :param policy_definition_name: The name of the policy definition to get. + :param policy_definition_name: The name of the policy definition to get. Required. :type policy_definition_name: str - :param management_group_id: The ID of the management group. + :param management_group_id: The ID of the management group. Required. :type management_group_id: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: PolicyDefinition, or the result of cls(response) + :return: PolicyDefinition or the result of cls(response) :rtype: ~azure.mgmt.resource.policy.v2016_12_01.models.PolicyDefinition - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.PolicyDefinition"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) - api_version = kwargs.pop('api_version', "2016-12-01") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2016-12-01")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[_models.PolicyDefinition] - request = build_policy_definitions_get_at_management_group_request( policy_definition_name=policy_definition_name, management_group_id=management_group_id, api_version=api_version, - template_url=self.get_at_management_group.metadata['url'], + template_url=self.get_at_management_group.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) - deserialized = self._deserialize('PolicyDefinition', pipeline_response) + deserialized = self._deserialize("PolicyDefinition", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - get_at_management_group.metadata = {'url': "/providers/Microsoft.Management/managementgroups/{managementGroupId}/providers/Microsoft.Authorization/policyDefinitions/{policyDefinitionName}"} # type: ignore - + get_at_management_group.metadata = {"url": "/providers/Microsoft.Management/managementgroups/{managementGroupId}/providers/Microsoft.Authorization/policyDefinitions/{policyDefinitionName}"} # type: ignore @distributed_trace - def list( - self, - **kwargs: Any - ) -> AsyncIterable["_models.PolicyDefinitionListResult"]: + def list(self, **kwargs: Any) -> AsyncIterable["_models.PolicyDefinition"]: """Gets all the policy definitions for a subscription. :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either PolicyDefinitionListResult or the result of - cls(response) + :return: An iterator like instance of either PolicyDefinition or the result of cls(response) :rtype: - ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.resource.policy.v2016_12_01.models.PolicyDefinitionListResult] - :raises: ~azure.core.exceptions.HttpResponseError + ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.resource.policy.v2016_12_01.models.PolicyDefinition] + :raises ~azure.core.exceptions.HttpResponseError: """ - api_version = kwargs.pop('api_version', "2016-12-01") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2016-12-01")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[_models.PolicyDefinitionListResult] - cls = kwargs.pop('cls', None) # type: ClsType["_models.PolicyDefinitionListResult"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) + def prepare_request(next_link=None): if not next_link: - + request = build_policy_definitions_list_request( subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.list.metadata['url'], + template_url=self.list.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore else: - - request = build_policy_definitions_list_request( - subscription_id=self._config.subscription_id, - template_url=next_link, - ) + # make call to next link with the client's api-version + _parsed_next_link = urlparse(next_link) + _next_request_params = case_insensitive_dict(parse_qs(_parsed_next_link.query)) + _next_request_params["api-version"] = self._config.api_version + request = HttpRequest("GET", urljoin(next_link, _parsed_next_link.path), params=_next_request_params) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore request.method = "GET" return request @@ -498,10 +660,8 @@ async def extract_data(pipeline_response): async def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) response = pipeline_response.http_response @@ -511,50 +671,54 @@ async def get_next(next_link=None): return pipeline_response + return AsyncItemPaged(get_next, extract_data) - return AsyncItemPaged( - get_next, extract_data - ) - list.metadata = {'url': "/subscriptions/{subscriptionId}/providers/Microsoft.Authorization/policyDefinitions"} # type: ignore + list.metadata = {"url": "/subscriptions/{subscriptionId}/providers/Microsoft.Authorization/policyDefinitions"} # type: ignore @distributed_trace - def list_built_in( - self, - **kwargs: Any - ) -> AsyncIterable["_models.PolicyDefinitionListResult"]: + def list_built_in(self, **kwargs: Any) -> AsyncIterable["_models.PolicyDefinition"]: """Gets all the built in policy definitions. :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either PolicyDefinitionListResult or the result of - cls(response) + :return: An iterator like instance of either PolicyDefinition or the result of cls(response) :rtype: - ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.resource.policy.v2016_12_01.models.PolicyDefinitionListResult] - :raises: ~azure.core.exceptions.HttpResponseError + ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.resource.policy.v2016_12_01.models.PolicyDefinition] + :raises ~azure.core.exceptions.HttpResponseError: """ - api_version = kwargs.pop('api_version', "2016-12-01") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2016-12-01")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[_models.PolicyDefinitionListResult] - cls = kwargs.pop('cls', None) # type: ClsType["_models.PolicyDefinitionListResult"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) + def prepare_request(next_link=None): if not next_link: - + request = build_policy_definitions_list_built_in_request( api_version=api_version, - template_url=self.list_built_in.metadata['url'], + template_url=self.list_built_in.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore else: - - request = build_policy_definitions_list_built_in_request( - template_url=next_link, - ) + # make call to next link with the client's api-version + _parsed_next_link = urlparse(next_link) + _next_request_params = case_insensitive_dict(parse_qs(_parsed_next_link.query)) + _next_request_params["api-version"] = self._config.api_version + request = HttpRequest("GET", urljoin(next_link, _parsed_next_link.path), params=_next_request_params) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore request.method = "GET" return request @@ -568,10 +732,8 @@ async def extract_data(pipeline_response): async def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) response = pipeline_response.http_response @@ -581,55 +743,59 @@ async def get_next(next_link=None): return pipeline_response + return AsyncItemPaged(get_next, extract_data) - return AsyncItemPaged( - get_next, extract_data - ) - list_built_in.metadata = {'url': "/providers/Microsoft.Authorization/policyDefinitions"} # type: ignore + list_built_in.metadata = {"url": "/providers/Microsoft.Authorization/policyDefinitions"} # type: ignore @distributed_trace def list_by_management_group( - self, - management_group_id: str, - **kwargs: Any - ) -> AsyncIterable["_models.PolicyDefinitionListResult"]: + self, management_group_id: str, **kwargs: Any + ) -> AsyncIterable["_models.PolicyDefinition"]: """Gets all the policy definitions for a subscription at management group level. - :param management_group_id: The ID of the management group. + :param management_group_id: The ID of the management group. Required. :type management_group_id: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either PolicyDefinitionListResult or the result of - cls(response) + :return: An iterator like instance of either PolicyDefinition or the result of cls(response) :rtype: - ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.resource.policy.v2016_12_01.models.PolicyDefinitionListResult] - :raises: ~azure.core.exceptions.HttpResponseError + ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.resource.policy.v2016_12_01.models.PolicyDefinition] + :raises ~azure.core.exceptions.HttpResponseError: """ - api_version = kwargs.pop('api_version', "2016-12-01") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2016-12-01")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[_models.PolicyDefinitionListResult] - cls = kwargs.pop('cls', None) # type: ClsType["_models.PolicyDefinitionListResult"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) + def prepare_request(next_link=None): if not next_link: - + request = build_policy_definitions_list_by_management_group_request( management_group_id=management_group_id, api_version=api_version, - template_url=self.list_by_management_group.metadata['url'], + template_url=self.list_by_management_group.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore else: - - request = build_policy_definitions_list_by_management_group_request( - management_group_id=management_group_id, - template_url=next_link, - ) + # make call to next link with the client's api-version + _parsed_next_link = urlparse(next_link) + _next_request_params = case_insensitive_dict(parse_qs(_parsed_next_link.query)) + _next_request_params["api-version"] = self._config.api_version + request = HttpRequest("GET", urljoin(next_link, _parsed_next_link.path), params=_next_request_params) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore request.method = "GET" return request @@ -643,10 +809,8 @@ async def extract_data(pipeline_response): async def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) response = pipeline_response.http_response @@ -656,74 +820,74 @@ async def get_next(next_link=None): return pipeline_response + return AsyncItemPaged(get_next, extract_data) - return AsyncItemPaged( - get_next, extract_data - ) - list_by_management_group.metadata = {'url': "/providers/Microsoft.Management/managementgroups/{managementGroupId}/providers/Microsoft.Authorization/policyDefinitions"} # type: ignore -class PolicyAssignmentsOperations: - """PolicyAssignmentsOperations async operations. + list_by_management_group.metadata = {"url": "/providers/Microsoft.Management/managementgroups/{managementGroupId}/providers/Microsoft.Authorization/policyDefinitions"} # type: ignore - You should not instantiate this class directly. Instead, you should create a Client instance that - instantiates it for you and attaches it as an attribute. - :ivar models: Alias to model classes used in this operation group. - :type models: ~azure.mgmt.resource.policy.v2016_12_01.models - :param client: Client for service requests. - :param config: Configuration of service client. - :param serializer: An object model serializer. - :param deserializer: An object model deserializer. +class PolicyAssignmentsOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. + + Instead, you should access the following operations through + :class:`~azure.mgmt.resource.policy.v2016_12_01.aio.PolicyClient`'s + :attr:`policy_assignments` attribute. """ models = _models - def __init__(self, client, config, serializer, deserializer) -> None: - self._client = client - self._serialize = serializer - self._deserialize = deserializer - self._config = config + def __init__(self, *args, **kwargs) -> None: + input_args = list(args) + self._client = input_args.pop(0) if input_args else kwargs.pop("client") + self._config = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") @distributed_trace_async async def delete( - self, - scope: str, - policy_assignment_name: str, - **kwargs: Any - ) -> Optional["_models.PolicyAssignment"]: + self, scope: str, policy_assignment_name: str, **kwargs: Any + ) -> Optional[_models.PolicyAssignment]: """Deletes a policy assignment. - :param scope: The scope of the policy assignment. + :param scope: The scope of the policy assignment. Required. :type scope: str - :param policy_assignment_name: The name of the policy assignment to delete. + :param policy_assignment_name: The name of the policy assignment to delete. Required. :type policy_assignment_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: PolicyAssignment, or the result of cls(response) + :return: PolicyAssignment or None or the result of cls(response) :rtype: ~azure.mgmt.resource.policy.v2016_12_01.models.PolicyAssignment or None - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType[Optional["_models.PolicyAssignment"]] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + 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', "2016-12-01") # type: str + api_version = kwargs.pop("api_version", _params.pop("api-version", "2016-12-01")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[Optional[_models.PolicyAssignment]] - request = build_policy_assignments_delete_request( scope=scope, policy_assignment_name=policy_assignment_name, api_version=api_version, - template_url=self.delete.metadata['url'], + template_url=self.delete.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200, 204]: @@ -732,54 +896,121 @@ async def delete( deserialized = None if response.status_code == 200: - deserialized = self._deserialize('PolicyAssignment', pipeline_response) + deserialized = self._deserialize("PolicyAssignment", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - delete.metadata = {'url': "/{scope}/providers/Microsoft.Authorization/policyAssignments/{policyAssignmentName}"} # type: ignore - + delete.metadata = {"url": "/{scope}/providers/Microsoft.Authorization/policyAssignments/{policyAssignmentName}"} # type: ignore - @distributed_trace_async + @overload async def create( self, scope: str, policy_assignment_name: str, - parameters: "_models.PolicyAssignment", + parameters: _models.PolicyAssignment, *, - content_type: Optional[str] = "application/json", + content_type: str = "application/json", **kwargs: Any - ) -> "_models.PolicyAssignment": + ) -> _models.PolicyAssignment: """Creates a policy assignment. Policy assignments are inherited by child resources. For example, when you apply a policy to a resource group that policy is assigned to all resources in the group. - :param scope: The scope of the policy assignment. + :param scope: The scope of the policy assignment. Required. :type scope: str - :param policy_assignment_name: The name of the policy assignment. + :param policy_assignment_name: The name of the policy assignment. Required. :type policy_assignment_name: str - :param parameters: Parameters for the policy assignment. + :param parameters: Parameters for the policy assignment. Required. :type parameters: ~azure.mgmt.resource.policy.v2016_12_01.models.PolicyAssignment - :keyword content_type: Media type of the body sent to the API. Possible values are: - "application/json" or "text/json". Default value is "application/json". + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: PolicyAssignment or the result of cls(response) + :rtype: ~azure.mgmt.resource.policy.v2016_12_01.models.PolicyAssignment + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + async def create( + self, + scope: str, + policy_assignment_name: str, + parameters: IO, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.PolicyAssignment: + """Creates a policy assignment. + + Policy assignments are inherited by child resources. For example, when you apply a policy to a + resource group that policy is assigned to all resources in the group. + + :param scope: The scope of the policy assignment. Required. + :type scope: str + :param policy_assignment_name: The name of the policy assignment. Required. + :type policy_assignment_name: str + :param parameters: Parameters for the policy assignment. Required. + :type parameters: IO + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Known values are: 'application/json', 'text/json'. Default value is "application/json". + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: PolicyAssignment or the result of cls(response) + :rtype: ~azure.mgmt.resource.policy.v2016_12_01.models.PolicyAssignment + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace_async + async def create( + self, scope: str, policy_assignment_name: str, parameters: Union[_models.PolicyAssignment, IO], **kwargs: Any + ) -> _models.PolicyAssignment: + """Creates a policy assignment. + + Policy assignments are inherited by child resources. For example, when you apply a policy to a + resource group that policy is assigned to all resources in the group. + + :param scope: The scope of the policy assignment. Required. + :type scope: str + :param policy_assignment_name: The name of the policy assignment. Required. + :type policy_assignment_name: str + :param parameters: Parameters for the policy assignment. Is either a model type or a IO type. + Required. + :type parameters: ~azure.mgmt.resource.policy.v2016_12_01.models.PolicyAssignment or IO + :keyword content_type: Body Parameter content-type. Known values are: 'application/json', + 'text/json'. Default value is None. :paramtype content_type: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: PolicyAssignment, or the result of cls(response) + :return: PolicyAssignment or the result of cls(response) :rtype: ~azure.mgmt.resource.policy.v2016_12_01.models.PolicyAssignment - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.PolicyAssignment"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', "2016-12-01") # type: str + api_version = kwargs.pop("api_version", _params.pop("api-version", "2016-12-01")) # type: str + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.PolicyAssignment] - _json = self._serialize.body(parameters, 'PolicyAssignment') + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(parameters, (IO, bytes)): + _content = parameters + else: + _json = self._serialize.body(parameters, "PolicyAssignment") request = build_policy_assignments_create_request( scope=scope, @@ -787,138 +1018,144 @@ async def create( api_version=api_version, content_type=content_type, json=_json, - template_url=self.create.metadata['url'], + content=_content, + template_url=self.create.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [201]: map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) - deserialized = self._deserialize('PolicyAssignment', pipeline_response) + deserialized = self._deserialize("PolicyAssignment", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - create.metadata = {'url': "/{scope}/providers/Microsoft.Authorization/policyAssignments/{policyAssignmentName}"} # type: ignore - + create.metadata = {"url": "/{scope}/providers/Microsoft.Authorization/policyAssignments/{policyAssignmentName}"} # type: ignore @distributed_trace_async - async def get( - self, - scope: str, - policy_assignment_name: str, - **kwargs: Any - ) -> "_models.PolicyAssignment": + async def get(self, scope: str, policy_assignment_name: str, **kwargs: Any) -> _models.PolicyAssignment: """Gets a policy assignment. - :param scope: The scope of the policy assignment. + :param scope: The scope of the policy assignment. Required. :type scope: str - :param policy_assignment_name: The name of the policy assignment to get. + :param policy_assignment_name: The name of the policy assignment to get. Required. :type policy_assignment_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: PolicyAssignment, or the result of cls(response) + :return: PolicyAssignment or the result of cls(response) :rtype: ~azure.mgmt.resource.policy.v2016_12_01.models.PolicyAssignment - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.PolicyAssignment"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + 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', "2016-12-01") # type: str + api_version = kwargs.pop("api_version", _params.pop("api-version", "2016-12-01")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[_models.PolicyAssignment] - request = build_policy_assignments_get_request( scope=scope, policy_assignment_name=policy_assignment_name, api_version=api_version, - template_url=self.get.metadata['url'], + template_url=self.get.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) - deserialized = self._deserialize('PolicyAssignment', pipeline_response) + deserialized = self._deserialize("PolicyAssignment", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - get.metadata = {'url': "/{scope}/providers/Microsoft.Authorization/policyAssignments/{policyAssignmentName}"} # type: ignore - + get.metadata = {"url": "/{scope}/providers/Microsoft.Authorization/policyAssignments/{policyAssignmentName}"} # type: ignore @distributed_trace def list_for_resource_group( - self, - resource_group_name: str, - filter: Optional[str] = None, - **kwargs: Any - ) -> AsyncIterable["_models.PolicyAssignmentListResult"]: + self, resource_group_name: str, filter: Optional[str] = None, **kwargs: Any + ) -> AsyncIterable["_models.PolicyAssignment"]: """Gets policy assignments for the resource group. :param resource_group_name: The name of the resource group that contains policy assignments. + Required. :type resource_group_name: str :param filter: The filter to apply on the operation. Default value is None. :type filter: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either PolicyAssignmentListResult or the result of - cls(response) + :return: An iterator like instance of either PolicyAssignment or the result of cls(response) :rtype: - ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.resource.policy.v2016_12_01.models.PolicyAssignmentListResult] - :raises: ~azure.core.exceptions.HttpResponseError + ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.resource.policy.v2016_12_01.models.PolicyAssignment] + :raises ~azure.core.exceptions.HttpResponseError: """ - api_version = kwargs.pop('api_version', "2016-12-01") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2016-12-01")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[_models.PolicyAssignmentListResult] - cls = kwargs.pop('cls', None) # type: ClsType["_models.PolicyAssignmentListResult"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) + def prepare_request(next_link=None): if not next_link: - + request = build_policy_assignments_list_for_resource_group_request( resource_group_name=resource_group_name, subscription_id=self._config.subscription_id, - api_version=api_version, filter=filter, - template_url=self.list_for_resource_group.metadata['url'], + api_version=api_version, + template_url=self.list_for_resource_group.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore else: - - request = build_policy_assignments_list_for_resource_group_request( - resource_group_name=resource_group_name, - subscription_id=self._config.subscription_id, - template_url=next_link, - ) + # make call to next link with the client's api-version + _parsed_next_link = urlparse(next_link) + _next_request_params = case_insensitive_dict(parse_qs(_parsed_next_link.query)) + _next_request_params["api-version"] = self._config.api_version + request = HttpRequest("GET", urljoin(next_link, _parsed_next_link.path), params=_next_request_params) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore request.method = "GET" return request @@ -932,10 +1169,8 @@ async def extract_data(pipeline_response): async def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) response = pipeline_response.http_response @@ -945,11 +1180,9 @@ async def get_next(next_link=None): return pipeline_response + return AsyncItemPaged(get_next, extract_data) - return AsyncItemPaged( - get_next, extract_data - ) - list_for_resource_group.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Authorization/policyAssignments"} # type: ignore + list_for_resource_group.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Authorization/policyAssignments"} # type: ignore @distributed_trace def list_for_resource( @@ -961,39 +1194,45 @@ def list_for_resource( resource_name: str, filter: Optional[str] = None, **kwargs: Any - ) -> AsyncIterable["_models.PolicyAssignmentListResult"]: + ) -> AsyncIterable["_models.PolicyAssignment"]: """Gets policy assignments for a resource. :param resource_group_name: The name of the resource group containing the resource. The name is - case insensitive. + case insensitive. Required. :type resource_group_name: str - :param resource_provider_namespace: The namespace of the resource provider. + :param resource_provider_namespace: The namespace of the resource provider. Required. :type resource_provider_namespace: str - :param parent_resource_path: The parent resource path. + :param parent_resource_path: The parent resource path. Required. :type parent_resource_path: str - :param resource_type: The resource type. + :param resource_type: The resource type. Required. :type resource_type: str - :param resource_name: The name of the resource with policy assignments. + :param resource_name: The name of the resource with policy assignments. Required. :type resource_name: str :param filter: The filter to apply on the operation. Default value is None. :type filter: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either PolicyAssignmentListResult or the result of - cls(response) + :return: An iterator like instance of either PolicyAssignment or the result of cls(response) :rtype: - ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.resource.policy.v2016_12_01.models.PolicyAssignmentListResult] - :raises: ~azure.core.exceptions.HttpResponseError + ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.resource.policy.v2016_12_01.models.PolicyAssignment] + :raises ~azure.core.exceptions.HttpResponseError: """ - api_version = kwargs.pop('api_version', "2016-12-01") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2016-12-01")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[_models.PolicyAssignmentListResult] - cls = kwargs.pop('cls', None) # type: ClsType["_models.PolicyAssignmentListResult"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) + def prepare_request(next_link=None): if not next_link: - + request = build_policy_assignments_list_for_resource_request( resource_group_name=resource_group_name, resource_provider_namespace=resource_provider_namespace, @@ -1001,26 +1240,23 @@ def prepare_request(next_link=None): resource_type=resource_type, resource_name=resource_name, subscription_id=self._config.subscription_id, - api_version=api_version, filter=filter, - template_url=self.list_for_resource.metadata['url'], + api_version=api_version, + template_url=self.list_for_resource.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore else: - - request = build_policy_assignments_list_for_resource_request( - resource_group_name=resource_group_name, - resource_provider_namespace=resource_provider_namespace, - parent_resource_path=parent_resource_path, - resource_type=resource_type, - resource_name=resource_name, - subscription_id=self._config.subscription_id, - template_url=next_link, - ) + # make call to next link with the client's api-version + _parsed_next_link = urlparse(next_link) + _next_request_params = case_insensitive_dict(parse_qs(_parsed_next_link.query)) + _next_request_params["api-version"] = self._config.api_version + request = HttpRequest("GET", urljoin(next_link, _parsed_next_link.path), params=_next_request_params) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore request.method = "GET" return request @@ -1034,10 +1270,8 @@ async def extract_data(pipeline_response): async def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) response = pipeline_response.http_response @@ -1047,56 +1281,58 @@ async def get_next(next_link=None): return pipeline_response + return AsyncItemPaged(get_next, extract_data) - return AsyncItemPaged( - get_next, extract_data - ) - list_for_resource.metadata = {'url': "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{parentResourcePath}/{resourceType}/{resourceName}/providers/Microsoft.Authorization/policyAssignments"} # type: ignore + list_for_resource.metadata = {"url": "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{parentResourcePath}/{resourceType}/{resourceName}/providers/Microsoft.Authorization/policyAssignments"} # type: ignore @distributed_trace - def list( - self, - filter: Optional[str] = None, - **kwargs: Any - ) -> AsyncIterable["_models.PolicyAssignmentListResult"]: + def list(self, filter: Optional[str] = None, **kwargs: Any) -> AsyncIterable["_models.PolicyAssignment"]: """Gets all the policy assignments for a subscription. :param filter: The filter to apply on the operation. Default value is None. :type filter: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either PolicyAssignmentListResult or the result of - cls(response) + :return: An iterator like instance of either PolicyAssignment or the result of cls(response) :rtype: - ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.resource.policy.v2016_12_01.models.PolicyAssignmentListResult] - :raises: ~azure.core.exceptions.HttpResponseError + ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.resource.policy.v2016_12_01.models.PolicyAssignment] + :raises ~azure.core.exceptions.HttpResponseError: """ - api_version = kwargs.pop('api_version', "2016-12-01") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2016-12-01")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[_models.PolicyAssignmentListResult] - cls = kwargs.pop('cls', None) # type: ClsType["_models.PolicyAssignmentListResult"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) + def prepare_request(next_link=None): if not next_link: - + request = build_policy_assignments_list_request( subscription_id=self._config.subscription_id, - api_version=api_version, filter=filter, - template_url=self.list.metadata['url'], + 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.url = self._client.format_url(request.url) # type: ignore else: - - request = build_policy_assignments_list_request( - subscription_id=self._config.subscription_id, - template_url=next_link, - ) + # make call to next link with the client's api-version + _parsed_next_link = urlparse(next_link) + _next_request_params = case_insensitive_dict(parse_qs(_parsed_next_link.query)) + _next_request_params["api-version"] = self._config.api_version + request = HttpRequest("GET", urljoin(next_link, _parsed_next_link.path), params=_next_request_params) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore request.method = "GET" return request @@ -1110,10 +1346,8 @@ async def extract_data(pipeline_response): async def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) response = pipeline_response.http_response @@ -1123,18 +1357,12 @@ async def get_next(next_link=None): return pipeline_response + return AsyncItemPaged(get_next, extract_data) - return AsyncItemPaged( - get_next, extract_data - ) - list.metadata = {'url': "/subscriptions/{subscriptionId}/providers/Microsoft.Authorization/policyAssignments"} # type: ignore + list.metadata = {"url": "/subscriptions/{subscriptionId}/providers/Microsoft.Authorization/policyAssignments"} # type: ignore @distributed_trace_async - async def delete_by_id( - self, - policy_assignment_id: str, - **kwargs: Any - ) -> "_models.PolicyAssignment": + async def delete_by_id(self, policy_assignment_id: str, **kwargs: Any) -> _models.PolicyAssignment: """Deletes a policy assignment by ID. When providing a scope for the assignment, use '/subscriptions/{subscription-id}/' for @@ -1145,59 +1373,65 @@ async def delete_by_id( :param policy_assignment_id: The ID of the policy assignment to delete. Use the format '/{scope}/providers/Microsoft.Authorization/policyAssignments/{policy-assignment-name}'. + Required. :type policy_assignment_id: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: PolicyAssignment, or the result of cls(response) + :return: PolicyAssignment or the result of cls(response) :rtype: ~azure.mgmt.resource.policy.v2016_12_01.models.PolicyAssignment - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.PolicyAssignment"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) - api_version = kwargs.pop('api_version', "2016-12-01") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2016-12-01")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[_models.PolicyAssignment] - request = build_policy_assignments_delete_by_id_request( policy_assignment_id=policy_assignment_id, api_version=api_version, - template_url=self.delete_by_id.metadata['url'], + template_url=self.delete_by_id.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) - deserialized = self._deserialize('PolicyAssignment', pipeline_response) + deserialized = self._deserialize("PolicyAssignment", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - delete_by_id.metadata = {'url': "/{policyAssignmentId}"} # type: ignore + delete_by_id.metadata = {"url": "/{policyAssignmentId}"} # type: ignore - - @distributed_trace_async + @overload async def create_by_id( self, policy_assignment_id: str, - parameters: "_models.PolicyAssignment", + parameters: _models.PolicyAssignment, *, - content_type: Optional[str] = "application/json", + content_type: str = "application/json", **kwargs: Any - ) -> "_models.PolicyAssignment": + ) -> _models.PolicyAssignment: """Creates a policy assignment by ID. Policy assignments are inherited by child resources. For example, when you apply a policy to a @@ -1210,64 +1444,134 @@ async def create_by_id( :param policy_assignment_id: The ID of the policy assignment to create. Use the format '/{scope}/providers/Microsoft.Authorization/policyAssignments/{policy-assignment-name}'. + Required. :type policy_assignment_id: str - :param parameters: Parameters for policy assignment. + :param parameters: Parameters for policy assignment. Required. :type parameters: ~azure.mgmt.resource.policy.v2016_12_01.models.PolicyAssignment - :keyword content_type: Media type of the body sent to the API. Possible values are: - "application/json" or "text/json". Default value is "application/json". + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". :paramtype content_type: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: PolicyAssignment, or the result of cls(response) + :return: PolicyAssignment or the result of cls(response) :rtype: ~azure.mgmt.resource.policy.v2016_12_01.models.PolicyAssignment - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + async def create_by_id( + self, policy_assignment_id: str, parameters: IO, *, content_type: str = "application/json", **kwargs: Any + ) -> _models.PolicyAssignment: + """Creates a policy assignment by ID. + + Policy assignments are inherited by child resources. For example, when you apply a policy to a + resource group that policy is assigned to all resources in the group. When providing a scope + for the assignment, use '/subscriptions/{subscription-id}/' for subscriptions, + '/subscriptions/{subscription-id}/resourceGroups/{resource-group-name}' for resource groups, + and + '/subscriptions/{subscription-id}/resourceGroups/{resource-group-name}/providers/{resource-provider-namespace}/{resource-type}/{resource-name}' + for resources. + + :param policy_assignment_id: The ID of the policy assignment to create. Use the format + '/{scope}/providers/Microsoft.Authorization/policyAssignments/{policy-assignment-name}'. + Required. + :type policy_assignment_id: str + :param parameters: Parameters for policy assignment. Required. + :type parameters: IO + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Known values are: 'application/json', 'text/json'. Default value is "application/json". + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: PolicyAssignment or the result of cls(response) + :rtype: ~azure.mgmt.resource.policy.v2016_12_01.models.PolicyAssignment + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace_async + async def create_by_id( + self, policy_assignment_id: str, parameters: Union[_models.PolicyAssignment, IO], **kwargs: Any + ) -> _models.PolicyAssignment: + """Creates a policy assignment by ID. + + Policy assignments are inherited by child resources. For example, when you apply a policy to a + resource group that policy is assigned to all resources in the group. When providing a scope + for the assignment, use '/subscriptions/{subscription-id}/' for subscriptions, + '/subscriptions/{subscription-id}/resourceGroups/{resource-group-name}' for resource groups, + and + '/subscriptions/{subscription-id}/resourceGroups/{resource-group-name}/providers/{resource-provider-namespace}/{resource-type}/{resource-name}' + for resources. + + :param policy_assignment_id: The ID of the policy assignment to create. Use the format + '/{scope}/providers/Microsoft.Authorization/policyAssignments/{policy-assignment-name}'. + Required. + :type policy_assignment_id: str + :param parameters: Parameters for policy assignment. Is either a model type or a IO type. + Required. + :type parameters: ~azure.mgmt.resource.policy.v2016_12_01.models.PolicyAssignment or IO + :keyword content_type: Body Parameter content-type. Known values are: 'application/json', + 'text/json'. Default value is None. + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: PolicyAssignment or the result of cls(response) + :rtype: ~azure.mgmt.resource.policy.v2016_12_01.models.PolicyAssignment + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.PolicyAssignment"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', "2016-12-01") # type: str + api_version = kwargs.pop("api_version", _params.pop("api-version", "2016-12-01")) # type: str + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.PolicyAssignment] - _json = self._serialize.body(parameters, 'PolicyAssignment') + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(parameters, (IO, bytes)): + _content = parameters + else: + _json = self._serialize.body(parameters, "PolicyAssignment") request = build_policy_assignments_create_by_id_request( policy_assignment_id=policy_assignment_id, api_version=api_version, content_type=content_type, json=_json, - template_url=self.create_by_id.metadata['url'], + content=_content, + template_url=self.create_by_id.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [201]: map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) - deserialized = self._deserialize('PolicyAssignment', pipeline_response) + deserialized = self._deserialize("PolicyAssignment", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - create_by_id.metadata = {'url': "/{policyAssignmentId}"} # type: ignore - + create_by_id.metadata = {"url": "/{policyAssignmentId}"} # type: ignore @distributed_trace_async - async def get_by_id( - self, - policy_assignment_id: str, - **kwargs: Any - ) -> "_models.PolicyAssignment": + async def get_by_id(self, policy_assignment_id: str, **kwargs: Any) -> _models.PolicyAssignment: """Gets a policy assignment by ID. When providing a scope for the assignment, use '/subscriptions/{subscription-id}/' for @@ -1278,46 +1582,52 @@ async def get_by_id( :param policy_assignment_id: The ID of the policy assignment to get. Use the format '/{scope}/providers/Microsoft.Authorization/policyAssignments/{policy-assignment-name}'. + Required. :type policy_assignment_id: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: PolicyAssignment, or the result of cls(response) + :return: PolicyAssignment or the result of cls(response) :rtype: ~azure.mgmt.resource.policy.v2016_12_01.models.PolicyAssignment - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.PolicyAssignment"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + 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', "2016-12-01") # type: str + api_version = kwargs.pop("api_version", _params.pop("api-version", "2016-12-01")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[_models.PolicyAssignment] - request = build_policy_assignments_get_by_id_request( policy_assignment_id=policy_assignment_id, api_version=api_version, - template_url=self.get_by_id.metadata['url'], + template_url=self.get_by_id.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) - deserialized = self._deserialize('PolicyAssignment', pipeline_response) + deserialized = self._deserialize("PolicyAssignment", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - get_by_id.metadata = {'url': "/{policyAssignmentId}"} # type: ignore - + get_by_id.metadata = {"url": "/{policyAssignmentId}"} # type: ignore diff --git a/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/policy/v2016_12_01/aio/operations/_patch.py b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/policy/v2016_12_01/aio/operations/_patch.py new file mode 100644 index 0000000000000..f7dd32510333d --- /dev/null +++ b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/policy/v2016_12_01/aio/operations/_patch.py @@ -0,0 +1,20 @@ +# ------------------------------------ +# Copyright (c) Microsoft Corporation. +# Licensed under the MIT License. +# ------------------------------------ +"""Customize generated code here. + +Follow our quickstart for examples: https://aka.ms/azsdk/python/dpcodegen/python/customize +""" +from typing import List + +__all__: List[str] = [] # Add all objects you want publicly available to users at this package level + + +def patch_sdk(): + """Do not remove from this file. + + `patch_sdk` is a last resort escape hatch that allows you to do customizations + you can't accomplish using the techniques described in + https://aka.ms/azsdk/python/dpcodegen/python/customize + """ diff --git a/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/policy/v2016_12_01/models/__init__.py b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/policy/v2016_12_01/models/__init__.py index f9d9a126cdbcd..21de57ff27f1e 100644 --- a/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/policy/v2016_12_01/models/__init__.py +++ b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/policy/v2016_12_01/models/__init__.py @@ -11,17 +11,19 @@ from ._models_py3 import PolicyDefinition from ._models_py3 import PolicyDefinitionListResult - -from ._policy_client_enums import ( - PolicyMode, - PolicyType, -) +from ._policy_client_enums import PolicyMode +from ._policy_client_enums import PolicyType +from ._patch import __all__ as _patch_all +from ._patch import * # type: ignore # pylint: disable=unused-wildcard-import +from ._patch import patch_sdk as _patch_sdk __all__ = [ - 'PolicyAssignment', - 'PolicyAssignmentListResult', - 'PolicyDefinition', - 'PolicyDefinitionListResult', - 'PolicyMode', - 'PolicyType', + "PolicyAssignment", + "PolicyAssignmentListResult", + "PolicyDefinition", + "PolicyDefinitionListResult", + "PolicyMode", + "PolicyType", ] +__all__.extend([p for p in _patch_all if p not in __all__]) +_patch_sdk() diff --git a/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/policy/v2016_12_01/models/_models_py3.py b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/policy/v2016_12_01/models/_models_py3.py index 2341f447eb8b6..ed3200d87e285 100644 --- a/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/policy/v2016_12_01/models/_models_py3.py +++ b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/policy/v2016_12_01/models/_models_py3.py @@ -1,4 +1,5 @@ # coding=utf-8 +# pylint: disable=too-many-lines # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. # Licensed under the MIT License. See License.txt in the project root for license information. @@ -6,14 +7,22 @@ # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -from typing import Any, List, Optional, Union +import sys +from typing import Any, List, Optional, TYPE_CHECKING, Union -import msrest.serialization +from ... import _serialization -from ._policy_client_enums import * +if TYPE_CHECKING: + # pylint: disable=unused-import,ungrouped-imports + from .. import models as _models +if sys.version_info >= (3, 9): + from collections.abc import MutableMapping +else: + from typing import MutableMapping # type: ignore # pylint: disable=ungrouped-imports +JSON = MutableMapping[str, Any] # pylint: disable=unsubscriptable-object -class PolicyAssignment(msrest.serialization.Model): +class PolicyAssignment(_serialization.Model): """The policy assignment. Variables are only populated by the server, and will be ignored when sending a request. @@ -31,24 +40,24 @@ class PolicyAssignment(msrest.serialization.Model): :ivar scope: The scope for the policy assignment. :vartype scope: str :ivar parameters: Required if a parameter is used in policy rule. - :vartype parameters: any + :vartype parameters: JSON :ivar description: This message will be part of response in case of policy violation. :vartype description: str """ _validation = { - 'id': {'readonly': True}, + "id": {"readonly": True}, } _attribute_map = { - 'id': {'key': 'id', 'type': 'str'}, - 'type': {'key': 'type', 'type': 'str'}, - 'name': {'key': 'name', 'type': 'str'}, - 'display_name': {'key': 'properties.displayName', 'type': 'str'}, - 'policy_definition_id': {'key': 'properties.policyDefinitionId', 'type': 'str'}, - 'scope': {'key': 'properties.scope', 'type': 'str'}, - 'parameters': {'key': 'properties.parameters', 'type': 'object'}, - 'description': {'key': 'properties.description', 'type': 'str'}, + "id": {"key": "id", "type": "str"}, + "type": {"key": "type", "type": "str"}, + "name": {"key": "name", "type": "str"}, + "display_name": {"key": "properties.displayName", "type": "str"}, + "policy_definition_id": {"key": "properties.policyDefinitionId", "type": "str"}, + "scope": {"key": "properties.scope", "type": "str"}, + "parameters": {"key": "properties.parameters", "type": "object"}, + "description": {"key": "properties.description", "type": "str"}, } def __init__( @@ -59,7 +68,7 @@ def __init__( display_name: Optional[str] = None, policy_definition_id: Optional[str] = None, scope: Optional[str] = None, - parameters: Optional[Any] = None, + parameters: Optional[JSON] = None, description: Optional[str] = None, **kwargs ): @@ -75,11 +84,11 @@ def __init__( :keyword scope: The scope for the policy assignment. :paramtype scope: str :keyword parameters: Required if a parameter is used in policy rule. - :paramtype parameters: any + :paramtype parameters: JSON :keyword description: This message will be part of response in case of policy violation. :paramtype description: str """ - super(PolicyAssignment, self).__init__(**kwargs) + super().__init__(**kwargs) self.id = None self.type = type self.name = name @@ -90,7 +99,7 @@ def __init__( self.description = description -class PolicyAssignmentListResult(msrest.serialization.Model): +class PolicyAssignmentListResult(_serialization.Model): """List of policy assignments. :ivar value: An array of policy assignments. @@ -100,16 +109,12 @@ class PolicyAssignmentListResult(msrest.serialization.Model): """ _attribute_map = { - 'value': {'key': 'value', 'type': '[PolicyAssignment]'}, - 'next_link': {'key': 'nextLink', 'type': 'str'}, + "value": {"key": "value", "type": "[PolicyAssignment]"}, + "next_link": {"key": "nextLink", "type": "str"}, } def __init__( - self, - *, - value: Optional[List["PolicyAssignment"]] = None, - next_link: Optional[str] = None, - **kwargs + self, *, value: Optional[List["_models.PolicyAssignment"]] = None, next_link: Optional[str] = None, **kwargs ): """ :keyword value: An array of policy assignments. @@ -117,12 +122,12 @@ def __init__( :keyword next_link: The URL to use for getting the next set of results. :paramtype next_link: str """ - super(PolicyAssignmentListResult, self).__init__(**kwargs) + super().__init__(**kwargs) self.value = value self.next_link = next_link -class PolicyDefinition(msrest.serialization.Model): +class PolicyDefinition(_serialization.Model): """The policy definition. Variables are only populated by the server, and will be ignored when sending a request. @@ -132,71 +137,71 @@ class PolicyDefinition(msrest.serialization.Model): :ivar name: The name of the policy definition. :vartype name: str :ivar policy_type: The type of policy definition. Possible values are NotSpecified, BuiltIn, - and Custom. Possible values include: "NotSpecified", "BuiltIn", "Custom". + and Custom. Known values are: "NotSpecified", "BuiltIn", and "Custom". :vartype policy_type: str or ~azure.mgmt.resource.policy.v2016_12_01.models.PolicyType :ivar mode: The policy definition mode. Possible values are NotSpecified, Indexed, and All. - Possible values include: "NotSpecified", "Indexed", "All". + Known values are: "NotSpecified", "Indexed", and "All". :vartype mode: str or ~azure.mgmt.resource.policy.v2016_12_01.models.PolicyMode :ivar display_name: The display name of the policy definition. :vartype display_name: str :ivar description: The policy definition description. :vartype description: str :ivar policy_rule: The policy rule. - :vartype policy_rule: any + :vartype policy_rule: JSON :ivar metadata: The policy definition metadata. - :vartype metadata: any + :vartype metadata: JSON :ivar parameters: Required if a parameter is used in policy rule. - :vartype parameters: any + :vartype parameters: JSON """ _validation = { - 'id': {'readonly': True}, - 'name': {'readonly': True}, + "id": {"readonly": True}, + "name": {"readonly": True}, } _attribute_map = { - 'id': {'key': 'id', 'type': 'str'}, - 'name': {'key': 'name', 'type': 'str'}, - 'policy_type': {'key': 'properties.policyType', 'type': 'str'}, - 'mode': {'key': 'properties.mode', 'type': 'str'}, - 'display_name': {'key': 'properties.displayName', 'type': 'str'}, - 'description': {'key': 'properties.description', 'type': 'str'}, - 'policy_rule': {'key': 'properties.policyRule', 'type': 'object'}, - 'metadata': {'key': 'properties.metadata', 'type': 'object'}, - 'parameters': {'key': 'properties.parameters', 'type': 'object'}, + "id": {"key": "id", "type": "str"}, + "name": {"key": "name", "type": "str"}, + "policy_type": {"key": "properties.policyType", "type": "str"}, + "mode": {"key": "properties.mode", "type": "str"}, + "display_name": {"key": "properties.displayName", "type": "str"}, + "description": {"key": "properties.description", "type": "str"}, + "policy_rule": {"key": "properties.policyRule", "type": "object"}, + "metadata": {"key": "properties.metadata", "type": "object"}, + "parameters": {"key": "properties.parameters", "type": "object"}, } def __init__( self, *, - policy_type: Optional[Union[str, "PolicyType"]] = None, - mode: Optional[Union[str, "PolicyMode"]] = None, + policy_type: Optional[Union[str, "_models.PolicyType"]] = None, + mode: Optional[Union[str, "_models.PolicyMode"]] = None, display_name: Optional[str] = None, description: Optional[str] = None, - policy_rule: Optional[Any] = None, - metadata: Optional[Any] = None, - parameters: Optional[Any] = None, + policy_rule: Optional[JSON] = None, + metadata: Optional[JSON] = None, + parameters: Optional[JSON] = None, **kwargs ): """ :keyword policy_type: The type of policy definition. Possible values are NotSpecified, BuiltIn, - and Custom. Possible values include: "NotSpecified", "BuiltIn", "Custom". + and Custom. Known values are: "NotSpecified", "BuiltIn", and "Custom". :paramtype policy_type: str or ~azure.mgmt.resource.policy.v2016_12_01.models.PolicyType :keyword mode: The policy definition mode. Possible values are NotSpecified, Indexed, and All. - Possible values include: "NotSpecified", "Indexed", "All". + Known values are: "NotSpecified", "Indexed", and "All". :paramtype mode: str or ~azure.mgmt.resource.policy.v2016_12_01.models.PolicyMode :keyword display_name: The display name of the policy definition. :paramtype display_name: str :keyword description: The policy definition description. :paramtype description: str :keyword policy_rule: The policy rule. - :paramtype policy_rule: any + :paramtype policy_rule: JSON :keyword metadata: The policy definition metadata. - :paramtype metadata: any + :paramtype metadata: JSON :keyword parameters: Required if a parameter is used in policy rule. - :paramtype parameters: any + :paramtype parameters: JSON """ - super(PolicyDefinition, self).__init__(**kwargs) + super().__init__(**kwargs) self.id = None self.name = None self.policy_type = policy_type @@ -208,7 +213,7 @@ def __init__( self.parameters = parameters -class PolicyDefinitionListResult(msrest.serialization.Model): +class PolicyDefinitionListResult(_serialization.Model): """List of policy definitions. :ivar value: An array of policy definitions. @@ -218,16 +223,12 @@ class PolicyDefinitionListResult(msrest.serialization.Model): """ _attribute_map = { - 'value': {'key': 'value', 'type': '[PolicyDefinition]'}, - 'next_link': {'key': 'nextLink', 'type': 'str'}, + "value": {"key": "value", "type": "[PolicyDefinition]"}, + "next_link": {"key": "nextLink", "type": "str"}, } def __init__( - self, - *, - value: Optional[List["PolicyDefinition"]] = None, - next_link: Optional[str] = None, - **kwargs + self, *, value: Optional[List["_models.PolicyDefinition"]] = None, next_link: Optional[str] = None, **kwargs ): """ :keyword value: An array of policy definitions. @@ -235,6 +236,6 @@ def __init__( :keyword next_link: The URL to use for getting the next set of results. :paramtype next_link: str """ - super(PolicyDefinitionListResult, self).__init__(**kwargs) + super().__init__(**kwargs) self.value = value self.next_link = next_link diff --git a/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/policy/v2016_12_01/models/_patch.py b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/policy/v2016_12_01/models/_patch.py new file mode 100644 index 0000000000000..f7dd32510333d --- /dev/null +++ b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/policy/v2016_12_01/models/_patch.py @@ -0,0 +1,20 @@ +# ------------------------------------ +# Copyright (c) Microsoft Corporation. +# Licensed under the MIT License. +# ------------------------------------ +"""Customize generated code here. + +Follow our quickstart for examples: https://aka.ms/azsdk/python/dpcodegen/python/customize +""" +from typing import List + +__all__: List[str] = [] # Add all objects you want publicly available to users at this package level + + +def patch_sdk(): + """Do not remove from this file. + + `patch_sdk` is a last resort escape hatch that allows you to do customizations + you can't accomplish using the techniques described in + https://aka.ms/azsdk/python/dpcodegen/python/customize + """ diff --git a/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/policy/v2016_12_01/models/_policy_client_enums.py b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/policy/v2016_12_01/models/_policy_client_enums.py index 2acd4055af049..5a5cb27e9884c 100644 --- a/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/policy/v2016_12_01/models/_policy_client_enums.py +++ b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/policy/v2016_12_01/models/_policy_client_enums.py @@ -7,21 +7,19 @@ # -------------------------------------------------------------------------- from enum import Enum -from six import with_metaclass from azure.core import CaseInsensitiveEnumMeta -class PolicyMode(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): - """The policy definition mode. Possible values are NotSpecified, Indexed, and All. - """ +class PolicyMode(str, Enum, metaclass=CaseInsensitiveEnumMeta): + """The policy definition mode. Possible values are NotSpecified, Indexed, and All.""" NOT_SPECIFIED = "NotSpecified" INDEXED = "Indexed" ALL = "All" -class PolicyType(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): - """The type of policy definition. Possible values are NotSpecified, BuiltIn, and Custom. - """ + +class PolicyType(str, Enum, metaclass=CaseInsensitiveEnumMeta): + """The type of policy definition. Possible values are NotSpecified, BuiltIn, and Custom.""" NOT_SPECIFIED = "NotSpecified" BUILT_IN = "BuiltIn" diff --git a/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/policy/v2016_12_01/operations/__init__.py b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/policy/v2016_12_01/operations/__init__.py index 7636edce1e12a..ced86dae62e6f 100644 --- a/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/policy/v2016_12_01/operations/__init__.py +++ b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/policy/v2016_12_01/operations/__init__.py @@ -9,7 +9,13 @@ from ._operations import PolicyDefinitionsOperations from ._operations import PolicyAssignmentsOperations +from ._patch import __all__ as _patch_all +from ._patch import * # type: ignore # pylint: disable=unused-wildcard-import +from ._patch import patch_sdk as _patch_sdk + __all__ = [ - 'PolicyDefinitionsOperations', - 'PolicyAssignmentsOperations', + "PolicyDefinitionsOperations", + "PolicyAssignmentsOperations", ] +__all__.extend([p for p in _patch_all if p not in __all__]) +_patch_sdk() diff --git a/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/policy/v2016_12_01/operations/_operations.py b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/policy/v2016_12_01/operations/_operations.py index 6802b41e079cc..1b11221ed389e 100644 --- a/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/policy/v2016_12_01/operations/_operations.py +++ b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/policy/v2016_12_01/operations/_operations.py @@ -6,503 +6,422 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -from typing import Any, Callable, Dict, Iterable, Optional, TypeVar - -from msrest import Serializer - -from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error +from typing import Any, Callable, Dict, IO, Iterable, Optional, TypeVar, Union, overload +from urllib.parse import parse_qs, urljoin, urlparse + +from azure.core.exceptions import ( + ClientAuthenticationError, + HttpResponseError, + ResourceExistsError, + ResourceNotFoundError, + ResourceNotModifiedError, + map_error, +) from azure.core.paging import ItemPaged from azure.core.pipeline import PipelineResponse from azure.core.pipeline.transport import HttpResponse from azure.core.rest import HttpRequest from azure.core.tracing.decorator import distributed_trace +from azure.core.utils import case_insensitive_dict from azure.mgmt.core.exceptions import ARMErrorFormat from .. import models as _models +from ..._serialization import Serializer from .._vendor import _convert_request, _format_url_section -T = TypeVar('T') -JSONType = Any + +T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] _SERIALIZER = Serializer() _SERIALIZER.client_side_validation = False + def build_policy_definitions_create_or_update_request( - policy_definition_name: str, - subscription_id: str, - *, - json: JSONType = None, - content: Any = None, - **kwargs: Any + policy_definition_name: str, subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2016-12-01") # type: str - content_type = kwargs.pop('content_type', None) # type: Optional[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", "2016-12-01")) # type: str + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + accept = _headers.pop("Accept", "application/json, text/json") - accept = "application/json, text/json" # Construct URL - _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/providers/Microsoft.Authorization/policyDefinitions/{policyDefinitionName}") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/providers/Microsoft.Authorization/policyDefinitions/{policyDefinitionName}", + ) # pylint: disable=line-too-long path_format_arguments = { - "policyDefinitionName": _SERIALIZER.url("policy_definition_name", policy_definition_name, 'str'), - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), + "policyDefinitionName": _SERIALIZER.url("policy_definition_name", policy_definition_name, "str"), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), } _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] if content_type is not None: - _header_parameters['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') - _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') - - return HttpRequest( - method="PUT", - url=_url, - params=_query_parameters, - headers=_header_parameters, - json=json, - content=content, - **kwargs - ) + _headers["Content-Type"] = _SERIALIZER.header("content_type", content_type, "str") + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="PUT", url=_url, params=_params, headers=_headers, **kwargs) def build_policy_definitions_delete_request( - policy_definition_name: str, - subscription_id: str, - **kwargs: Any + policy_definition_name: str, subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2016-12-01") # type: str + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + api_version = kwargs.pop("api_version", _params.pop("api-version", "2016-12-01")) # type: str # Construct URL - _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/providers/Microsoft.Authorization/policyDefinitions/{policyDefinitionName}") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/providers/Microsoft.Authorization/policyDefinitions/{policyDefinitionName}", + ) # pylint: disable=line-too-long path_format_arguments = { - "policyDefinitionName": _SERIALIZER.url("policy_definition_name", policy_definition_name, 'str'), - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), + "policyDefinitionName": _SERIALIZER.url("policy_definition_name", policy_definition_name, "str"), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), } _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') - - return HttpRequest( - method="DELETE", - url=_url, - params=_query_parameters, - **kwargs - ) + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") + + return HttpRequest(method="DELETE", url=_url, params=_params, **kwargs) def build_policy_definitions_get_request( - policy_definition_name: str, - subscription_id: str, - **kwargs: Any + policy_definition_name: str, subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2016-12-01") # type: 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", "2016-12-01")) # type: str + accept = _headers.pop("Accept", "application/json, text/json") - accept = "application/json, text/json" # Construct URL - _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/providers/Microsoft.Authorization/policyDefinitions/{policyDefinitionName}") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/providers/Microsoft.Authorization/policyDefinitions/{policyDefinitionName}", + ) # pylint: disable=line-too-long path_format_arguments = { - "policyDefinitionName": _SERIALIZER.url("policy_definition_name", policy_definition_name, 'str'), - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), + "policyDefinitionName": _SERIALIZER.url("policy_definition_name", policy_definition_name, "str"), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), } _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') - - return HttpRequest( - method="GET", - url=_url, - params=_query_parameters, - headers=_header_parameters, - **kwargs - ) + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) -def build_policy_definitions_get_built_in_request( - policy_definition_name: str, - **kwargs: Any -) -> HttpRequest: - api_version = kwargs.pop('api_version', "2016-12-01") # type: str - accept = "application/json, text/json" +def build_policy_definitions_get_built_in_request(policy_definition_name: 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", "2016-12-01")) # type: str + accept = _headers.pop("Accept", "application/json, text/json") + # Construct URL _url = kwargs.pop("template_url", "/providers/Microsoft.Authorization/policyDefinitions/{policyDefinitionName}") path_format_arguments = { - "policyDefinitionName": _SERIALIZER.url("policy_definition_name", policy_definition_name, 'str'), + "policyDefinitionName": _SERIALIZER.url("policy_definition_name", policy_definition_name, "str"), } _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') - - return HttpRequest( - method="GET", - url=_url, - params=_query_parameters, - headers=_header_parameters, - **kwargs - ) + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) def build_policy_definitions_create_or_update_at_management_group_request( - policy_definition_name: str, - management_group_id: str, - *, - json: JSONType = None, - content: Any = None, - **kwargs: Any + policy_definition_name: str, management_group_id: str, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2016-12-01") # type: str - content_type = kwargs.pop('content_type', None) # type: Optional[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", "2016-12-01")) # type: str + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + accept = _headers.pop("Accept", "application/json, text/json") - accept = "application/json, text/json" # Construct URL - _url = kwargs.pop("template_url", "/providers/Microsoft.Management/managementgroups/{managementGroupId}/providers/Microsoft.Authorization/policyDefinitions/{policyDefinitionName}") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", + "/providers/Microsoft.Management/managementgroups/{managementGroupId}/providers/Microsoft.Authorization/policyDefinitions/{policyDefinitionName}", + ) # pylint: disable=line-too-long path_format_arguments = { - "policyDefinitionName": _SERIALIZER.url("policy_definition_name", policy_definition_name, 'str'), - "managementGroupId": _SERIALIZER.url("management_group_id", management_group_id, 'str'), + "policyDefinitionName": _SERIALIZER.url("policy_definition_name", policy_definition_name, "str"), + "managementGroupId": _SERIALIZER.url("management_group_id", management_group_id, "str"), } _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] if content_type is not None: - _header_parameters['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') - _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') - - return HttpRequest( - method="PUT", - url=_url, - params=_query_parameters, - headers=_header_parameters, - json=json, - content=content, - **kwargs - ) + _headers["Content-Type"] = _SERIALIZER.header("content_type", content_type, "str") + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="PUT", url=_url, params=_params, headers=_headers, **kwargs) def build_policy_definitions_delete_at_management_group_request( - policy_definition_name: str, - management_group_id: str, - **kwargs: Any + policy_definition_name: str, management_group_id: str, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2016-12-01") # type: str + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + api_version = kwargs.pop("api_version", _params.pop("api-version", "2016-12-01")) # type: str # Construct URL - _url = kwargs.pop("template_url", "/providers/Microsoft.Management/managementgroups/{managementGroupId}/providers/Microsoft.Authorization/policyDefinitions/{policyDefinitionName}") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", + "/providers/Microsoft.Management/managementgroups/{managementGroupId}/providers/Microsoft.Authorization/policyDefinitions/{policyDefinitionName}", + ) # pylint: disable=line-too-long path_format_arguments = { - "policyDefinitionName": _SERIALIZER.url("policy_definition_name", policy_definition_name, 'str'), - "managementGroupId": _SERIALIZER.url("management_group_id", management_group_id, 'str'), + "policyDefinitionName": _SERIALIZER.url("policy_definition_name", policy_definition_name, "str"), + "managementGroupId": _SERIALIZER.url("management_group_id", management_group_id, "str"), } _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') - - return HttpRequest( - method="DELETE", - url=_url, - params=_query_parameters, - **kwargs - ) + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") + + return HttpRequest(method="DELETE", url=_url, params=_params, **kwargs) def build_policy_definitions_get_at_management_group_request( - policy_definition_name: str, - management_group_id: str, - **kwargs: Any + policy_definition_name: str, management_group_id: str, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2016-12-01") # type: 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", "2016-12-01")) # type: str + accept = _headers.pop("Accept", "application/json, text/json") - accept = "application/json, text/json" # Construct URL - _url = kwargs.pop("template_url", "/providers/Microsoft.Management/managementgroups/{managementGroupId}/providers/Microsoft.Authorization/policyDefinitions/{policyDefinitionName}") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", + "/providers/Microsoft.Management/managementgroups/{managementGroupId}/providers/Microsoft.Authorization/policyDefinitions/{policyDefinitionName}", + ) # pylint: disable=line-too-long path_format_arguments = { - "policyDefinitionName": _SERIALIZER.url("policy_definition_name", policy_definition_name, 'str'), - "managementGroupId": _SERIALIZER.url("management_group_id", management_group_id, 'str'), + "policyDefinitionName": _SERIALIZER.url("policy_definition_name", policy_definition_name, "str"), + "managementGroupId": _SERIALIZER.url("management_group_id", management_group_id, "str"), } _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') - - return HttpRequest( - method="GET", - url=_url, - params=_query_parameters, - headers=_header_parameters, - **kwargs - ) + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) -def build_policy_definitions_list_request( - subscription_id: str, - **kwargs: Any -) -> HttpRequest: - api_version = kwargs.pop('api_version', "2016-12-01") # type: str - accept = "application/json, text/json" +def build_policy_definitions_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", "2016-12-01")) # type: str + accept = _headers.pop("Accept", "application/json, text/json") + # Construct URL - _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/providers/Microsoft.Authorization/policyDefinitions") + _url = kwargs.pop( + "template_url", "/subscriptions/{subscriptionId}/providers/Microsoft.Authorization/policyDefinitions" + ) path_format_arguments = { - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), } _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') - - return HttpRequest( - method="GET", - url=_url, - params=_query_parameters, - headers=_header_parameters, - **kwargs - ) + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) -def build_policy_definitions_list_built_in_request( - **kwargs: Any -) -> HttpRequest: - api_version = kwargs.pop('api_version', "2016-12-01") # type: str - accept = "application/json, text/json" +def build_policy_definitions_list_built_in_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", "2016-12-01")) # type: str + accept = _headers.pop("Accept", "application/json, text/json") + # Construct URL _url = kwargs.pop("template_url", "/providers/Microsoft.Authorization/policyDefinitions") # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') - - return HttpRequest( - method="GET", - url=_url, - params=_query_parameters, - headers=_header_parameters, - **kwargs - ) + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) -def build_policy_definitions_list_by_management_group_request( - management_group_id: str, - **kwargs: Any -) -> HttpRequest: - api_version = kwargs.pop('api_version', "2016-12-01") # type: str - accept = "application/json, text/json" +def build_policy_definitions_list_by_management_group_request(management_group_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", "2016-12-01")) # type: str + accept = _headers.pop("Accept", "application/json, text/json") + # Construct URL - _url = kwargs.pop("template_url", "/providers/Microsoft.Management/managementgroups/{managementGroupId}/providers/Microsoft.Authorization/policyDefinitions") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", + "/providers/Microsoft.Management/managementgroups/{managementGroupId}/providers/Microsoft.Authorization/policyDefinitions", + ) # pylint: disable=line-too-long path_format_arguments = { - "managementGroupId": _SERIALIZER.url("management_group_id", management_group_id, 'str'), + "managementGroupId": _SERIALIZER.url("management_group_id", management_group_id, "str"), } _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') - - return HttpRequest( - method="GET", - url=_url, - params=_query_parameters, - headers=_header_parameters, - **kwargs - ) + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) -def build_policy_assignments_delete_request( - scope: str, - policy_assignment_name: str, - **kwargs: Any -) -> HttpRequest: - api_version = kwargs.pop('api_version', "2016-12-01") # type: str - accept = "application/json, text/json" +def build_policy_assignments_delete_request(scope: str, policy_assignment_name: 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", "2016-12-01")) # type: str + accept = _headers.pop("Accept", "application/json, text/json") + # Construct URL - _url = kwargs.pop("template_url", "/{scope}/providers/Microsoft.Authorization/policyAssignments/{policyAssignmentName}") + _url = kwargs.pop( + "template_url", "/{scope}/providers/Microsoft.Authorization/policyAssignments/{policyAssignmentName}" + ) path_format_arguments = { - "scope": _SERIALIZER.url("scope", scope, 'str', skip_quote=True), - "policyAssignmentName": _SERIALIZER.url("policy_assignment_name", policy_assignment_name, 'str'), + "scope": _SERIALIZER.url("scope", scope, "str", skip_quote=True), + "policyAssignmentName": _SERIALIZER.url("policy_assignment_name", policy_assignment_name, "str"), } _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') - - return HttpRequest( - method="DELETE", - url=_url, - params=_query_parameters, - headers=_header_parameters, - **kwargs - ) + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + return HttpRequest(method="DELETE", url=_url, params=_params, headers=_headers, **kwargs) -def build_policy_assignments_create_request( - scope: str, - policy_assignment_name: str, - *, - json: JSONType = None, - content: Any = None, - **kwargs: Any -) -> HttpRequest: - api_version = kwargs.pop('api_version', "2016-12-01") # type: str - content_type = kwargs.pop('content_type', None) # type: Optional[str] - accept = "application/json, text/json" +def build_policy_assignments_create_request(scope: str, policy_assignment_name: 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", "2016-12-01")) # type: str + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + accept = _headers.pop("Accept", "application/json, text/json") + # Construct URL - _url = kwargs.pop("template_url", "/{scope}/providers/Microsoft.Authorization/policyAssignments/{policyAssignmentName}") + _url = kwargs.pop( + "template_url", "/{scope}/providers/Microsoft.Authorization/policyAssignments/{policyAssignmentName}" + ) path_format_arguments = { - "scope": _SERIALIZER.url("scope", scope, 'str', skip_quote=True), - "policyAssignmentName": _SERIALIZER.url("policy_assignment_name", policy_assignment_name, 'str'), + "scope": _SERIALIZER.url("scope", scope, "str", skip_quote=True), + "policyAssignmentName": _SERIALIZER.url("policy_assignment_name", policy_assignment_name, "str"), } _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] if content_type is not None: - _header_parameters['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') - _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') - - return HttpRequest( - method="PUT", - url=_url, - params=_query_parameters, - headers=_header_parameters, - json=json, - content=content, - **kwargs - ) + _headers["Content-Type"] = _SERIALIZER.header("content_type", content_type, "str") + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + return HttpRequest(method="PUT", url=_url, params=_params, headers=_headers, **kwargs) -def build_policy_assignments_get_request( - scope: str, - policy_assignment_name: str, - **kwargs: Any -) -> HttpRequest: - api_version = kwargs.pop('api_version', "2016-12-01") # type: str - accept = "application/json, text/json" +def build_policy_assignments_get_request(scope: str, policy_assignment_name: 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", "2016-12-01")) # type: str + accept = _headers.pop("Accept", "application/json, text/json") + # Construct URL - _url = kwargs.pop("template_url", "/{scope}/providers/Microsoft.Authorization/policyAssignments/{policyAssignmentName}") + _url = kwargs.pop( + "template_url", "/{scope}/providers/Microsoft.Authorization/policyAssignments/{policyAssignmentName}" + ) path_format_arguments = { - "scope": _SERIALIZER.url("scope", scope, 'str', skip_quote=True), - "policyAssignmentName": _SERIALIZER.url("policy_assignment_name", policy_assignment_name, 'str'), + "scope": _SERIALIZER.url("scope", scope, "str", skip_quote=True), + "policyAssignmentName": _SERIALIZER.url("policy_assignment_name", policy_assignment_name, "str"), } _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') - - return HttpRequest( - method="GET", - url=_url, - params=_query_parameters, - headers=_header_parameters, - **kwargs - ) + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) def build_policy_assignments_list_for_resource_group_request( - resource_group_name: str, - subscription_id: str, - *, - filter: Optional[str] = None, - **kwargs: Any + resource_group_name: str, subscription_id: str, *, filter: Optional[str] = None, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2016-12-01") # type: 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", "2016-12-01")) # type: str + accept = _headers.pop("Accept", "application/json, text/json") - accept = "application/json, text/json" # Construct URL - _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Authorization/policyAssignments") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Authorization/policyAssignments", + ) # pylint: disable=line-too-long path_format_arguments = { - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._\(\)]+$'), - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), + "resourceGroupName": _SERIALIZER.url( + "resource_group_name", resource_group_name, "str", max_length=90, min_length=1, pattern=r"^[-\w\._\(\)]+$" + ), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), } _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] if filter is not None: - _query_parameters['$filter'] = _SERIALIZER.query("filter", filter, 'str', skip_quote=True) - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["$filter"] = _SERIALIZER.query("filter", filter, "str", skip_quote=True) + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') - - return HttpRequest( - method="GET", - url=_url, - params=_query_parameters, - headers=_header_parameters, - **kwargs - ) + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) def build_policy_assignments_list_for_resource_request( @@ -516,234 +435,249 @@ def build_policy_assignments_list_for_resource_request( filter: Optional[str] = None, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2016-12-01") # type: 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", "2016-12-01")) # type: str + accept = _headers.pop("Accept", "application/json, text/json") - accept = "application/json, text/json" # Construct URL - _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{parentResourcePath}/{resourceType}/{resourceName}/providers/Microsoft.Authorization/policyAssignments") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{parentResourcePath}/{resourceType}/{resourceName}/providers/Microsoft.Authorization/policyAssignments", + ) # pylint: disable=line-too-long path_format_arguments = { - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._\(\)]+$'), - "resourceProviderNamespace": _SERIALIZER.url("resource_provider_namespace", resource_provider_namespace, 'str'), - "parentResourcePath": _SERIALIZER.url("parent_resource_path", parent_resource_path, 'str', skip_quote=True), - "resourceType": _SERIALIZER.url("resource_type", resource_type, 'str', skip_quote=True), - "resourceName": _SERIALIZER.url("resource_name", resource_name, 'str'), - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), + "resourceGroupName": _SERIALIZER.url( + "resource_group_name", resource_group_name, "str", max_length=90, min_length=1, pattern=r"^[-\w\._\(\)]+$" + ), + "resourceProviderNamespace": _SERIALIZER.url("resource_provider_namespace", resource_provider_namespace, "str"), + "parentResourcePath": _SERIALIZER.url("parent_resource_path", parent_resource_path, "str", skip_quote=True), + "resourceType": _SERIALIZER.url("resource_type", resource_type, "str", skip_quote=True), + "resourceName": _SERIALIZER.url("resource_name", resource_name, "str"), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), } _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] if filter is not None: - _query_parameters['$filter'] = _SERIALIZER.query("filter", filter, 'str') - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["$filter"] = _SERIALIZER.query("filter", filter, "str") + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') - - return HttpRequest( - method="GET", - url=_url, - params=_query_parameters, - headers=_header_parameters, - **kwargs - ) + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) def build_policy_assignments_list_request( - subscription_id: str, - *, - filter: Optional[str] = None, - **kwargs: Any + subscription_id: str, *, filter: Optional[str] = None, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2016-12-01") # type: 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", "2016-12-01")) # type: str + accept = _headers.pop("Accept", "application/json, text/json") - accept = "application/json, text/json" # Construct URL - _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/providers/Microsoft.Authorization/policyAssignments") + _url = kwargs.pop( + "template_url", "/subscriptions/{subscriptionId}/providers/Microsoft.Authorization/policyAssignments" + ) path_format_arguments = { - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), } _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] if filter is not None: - _query_parameters['$filter'] = _SERIALIZER.query("filter", filter, 'str') - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["$filter"] = _SERIALIZER.query("filter", filter, "str") + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') - - return HttpRequest( - method="GET", - url=_url, - params=_query_parameters, - headers=_header_parameters, - **kwargs - ) + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) -def build_policy_assignments_delete_by_id_request( - policy_assignment_id: str, - **kwargs: Any -) -> HttpRequest: - api_version = kwargs.pop('api_version', "2016-12-01") # type: str - accept = "application/json, text/json" +def build_policy_assignments_delete_by_id_request(policy_assignment_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", "2016-12-01")) # type: str + accept = _headers.pop("Accept", "application/json, text/json") + # Construct URL _url = kwargs.pop("template_url", "/{policyAssignmentId}") path_format_arguments = { - "policyAssignmentId": _SERIALIZER.url("policy_assignment_id", policy_assignment_id, 'str', skip_quote=True), + "policyAssignmentId": _SERIALIZER.url("policy_assignment_id", policy_assignment_id, "str", skip_quote=True), } _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') - - return HttpRequest( - method="DELETE", - url=_url, - params=_query_parameters, - headers=_header_parameters, - **kwargs - ) + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + return HttpRequest(method="DELETE", url=_url, params=_params, headers=_headers, **kwargs) -def build_policy_assignments_create_by_id_request( - policy_assignment_id: str, - *, - json: JSONType = None, - content: Any = None, - **kwargs: Any -) -> HttpRequest: - api_version = kwargs.pop('api_version', "2016-12-01") # type: str - content_type = kwargs.pop('content_type', None) # type: Optional[str] - accept = "application/json, text/json" +def build_policy_assignments_create_by_id_request(policy_assignment_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", "2016-12-01")) # type: str + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + accept = _headers.pop("Accept", "application/json, text/json") + # Construct URL _url = kwargs.pop("template_url", "/{policyAssignmentId}") path_format_arguments = { - "policyAssignmentId": _SERIALIZER.url("policy_assignment_id", policy_assignment_id, 'str', skip_quote=True), + "policyAssignmentId": _SERIALIZER.url("policy_assignment_id", policy_assignment_id, "str", skip_quote=True), } _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] if content_type is not None: - _header_parameters['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') - _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') - - return HttpRequest( - method="PUT", - url=_url, - params=_query_parameters, - headers=_header_parameters, - json=json, - content=content, - **kwargs - ) + _headers["Content-Type"] = _SERIALIZER.header("content_type", content_type, "str") + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + return HttpRequest(method="PUT", url=_url, params=_params, headers=_headers, **kwargs) -def build_policy_assignments_get_by_id_request( - policy_assignment_id: str, - **kwargs: Any -) -> HttpRequest: - api_version = kwargs.pop('api_version', "2016-12-01") # type: str - accept = "application/json, text/json" +def build_policy_assignments_get_by_id_request(policy_assignment_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", "2016-12-01")) # type: str + accept = _headers.pop("Accept", "application/json, text/json") + # Construct URL _url = kwargs.pop("template_url", "/{policyAssignmentId}") path_format_arguments = { - "policyAssignmentId": _SERIALIZER.url("policy_assignment_id", policy_assignment_id, 'str', skip_quote=True), + "policyAssignmentId": _SERIALIZER.url("policy_assignment_id", policy_assignment_id, "str", skip_quote=True), } _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') - - return HttpRequest( - method="GET", - url=_url, - params=_query_parameters, - headers=_header_parameters, - **kwargs - ) + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") -class PolicyDefinitionsOperations(object): - """PolicyDefinitionsOperations operations. + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) - You should not instantiate this class directly. Instead, you should create a Client instance that - instantiates it for you and attaches it as an attribute. - :ivar models: Alias to model classes used in this operation group. - :type models: ~azure.mgmt.resource.policy.v2016_12_01.models - :param client: Client for service requests. - :param config: Configuration of service client. - :param serializer: An object model serializer. - :param deserializer: An object model deserializer. +class PolicyDefinitionsOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. + + Instead, you should access the following operations through + :class:`~azure.mgmt.resource.policy.v2016_12_01.PolicyClient`'s + :attr:`policy_definitions` attribute. """ models = _models - def __init__(self, client, config, serializer, deserializer): - self._client = client - self._serialize = serializer - self._deserialize = deserializer - self._config = config + def __init__(self, *args, **kwargs): + input_args = list(args) + self._client = input_args.pop(0) if input_args else kwargs.pop("client") + self._config = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") - @distributed_trace + @overload def create_or_update( self, policy_definition_name: str, - parameters: "_models.PolicyDefinition", + parameters: _models.PolicyDefinition, *, - content_type: Optional[str] = "application/json", + content_type: str = "application/json", **kwargs: Any - ) -> "_models.PolicyDefinition": + ) -> _models.PolicyDefinition: """Creates or updates a policy definition. - :param policy_definition_name: The name of the policy definition to create. + :param policy_definition_name: The name of the policy definition to create. Required. :type policy_definition_name: str - :param parameters: The policy definition properties. + :param parameters: The policy definition properties. Required. :type parameters: ~azure.mgmt.resource.policy.v2016_12_01.models.PolicyDefinition - :keyword content_type: Media type of the body sent to the API. Possible values are: - "application/json" or "text/json". Default value is "application/json". + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: PolicyDefinition or the result of cls(response) + :rtype: ~azure.mgmt.resource.policy.v2016_12_01.models.PolicyDefinition + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + def create_or_update( + self, policy_definition_name: str, parameters: IO, *, content_type: str = "application/json", **kwargs: Any + ) -> _models.PolicyDefinition: + """Creates or updates a policy definition. + + :param policy_definition_name: The name of the policy definition to create. Required. + :type policy_definition_name: str + :param parameters: The policy definition properties. Required. + :type parameters: IO + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Known values are: 'application/json', 'text/json'. Default value is "application/json". :paramtype content_type: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: PolicyDefinition, or the result of cls(response) + :return: PolicyDefinition or the result of cls(response) :rtype: ~azure.mgmt.resource.policy.v2016_12_01.models.PolicyDefinition - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace + def create_or_update( + self, policy_definition_name: str, parameters: Union[_models.PolicyDefinition, IO], **kwargs: Any + ) -> _models.PolicyDefinition: + """Creates or updates a policy definition. + + :param policy_definition_name: The name of the policy definition to create. Required. + :type policy_definition_name: str + :param parameters: The policy definition properties. Is either a model type or a IO type. + Required. + :type parameters: ~azure.mgmt.resource.policy.v2016_12_01.models.PolicyDefinition or IO + :keyword content_type: Body Parameter content-type. Known values are: 'application/json', + 'text/json'. Default value is None. + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: PolicyDefinition or the result of cls(response) + :rtype: ~azure.mgmt.resource.policy.v2016_12_01.models.PolicyDefinition + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.PolicyDefinition"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', "2016-12-01") # type: str + api_version = kwargs.pop("api_version", _params.pop("api-version", "2016-12-01")) # type: str + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.PolicyDefinition] - _json = self._serialize.body(parameters, 'PolicyDefinition') + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(parameters, (IO, bytes)): + _content = parameters + else: + _json = self._serialize.body(parameters, "PolicyDefinition") request = build_policy_definitions_create_or_update_request( policy_definition_name=policy_definition_name, @@ -751,70 +685,75 @@ def create_or_update( api_version=api_version, content_type=content_type, json=_json, - template_url=self.create_or_update.metadata['url'], + content=_content, + template_url=self.create_or_update.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [201]: map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) - deserialized = self._deserialize('PolicyDefinition', pipeline_response) + deserialized = self._deserialize("PolicyDefinition", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - create_or_update.metadata = {'url': "/subscriptions/{subscriptionId}/providers/Microsoft.Authorization/policyDefinitions/{policyDefinitionName}"} # type: ignore - + create_or_update.metadata = {"url": "/subscriptions/{subscriptionId}/providers/Microsoft.Authorization/policyDefinitions/{policyDefinitionName}"} # type: ignore @distributed_trace def delete( # pylint: disable=inconsistent-return-statements - self, - policy_definition_name: str, - **kwargs: Any + self, policy_definition_name: str, **kwargs: Any ) -> None: """Deletes a policy definition. - :param policy_definition_name: The name of the policy definition to delete. + :param policy_definition_name: The name of the policy definition to delete. Required. :type policy_definition_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: None, or the result of cls(response) + :return: None or the result of cls(response) :rtype: None - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType[None] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + 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', "2016-12-01") # type: str + api_version = kwargs.pop("api_version", _params.pop("api-version", "2016-12-01")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[None] - request = build_policy_definitions_delete_request( policy_definition_name=policy_definition_name, subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.delete.metadata['url'], + template_url=self.delete.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200, 204]: @@ -824,151 +763,218 @@ def delete( # pylint: disable=inconsistent-return-statements if cls: return cls(pipeline_response, None, {}) - delete.metadata = {'url': "/subscriptions/{subscriptionId}/providers/Microsoft.Authorization/policyDefinitions/{policyDefinitionName}"} # type: ignore - + delete.metadata = {"url": "/subscriptions/{subscriptionId}/providers/Microsoft.Authorization/policyDefinitions/{policyDefinitionName}"} # type: ignore @distributed_trace - def get( - self, - policy_definition_name: str, - **kwargs: Any - ) -> "_models.PolicyDefinition": + def get(self, policy_definition_name: str, **kwargs: Any) -> _models.PolicyDefinition: """Gets the policy definition. - :param policy_definition_name: The name of the policy definition to get. + :param policy_definition_name: The name of the policy definition to get. Required. :type policy_definition_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: PolicyDefinition, or the result of cls(response) + :return: PolicyDefinition or the result of cls(response) :rtype: ~azure.mgmt.resource.policy.v2016_12_01.models.PolicyDefinition - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.PolicyDefinition"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + 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', "2016-12-01") # type: str + api_version = kwargs.pop("api_version", _params.pop("api-version", "2016-12-01")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[_models.PolicyDefinition] - request = build_policy_definitions_get_request( policy_definition_name=policy_definition_name, subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.get.metadata['url'], + template_url=self.get.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) - deserialized = self._deserialize('PolicyDefinition', pipeline_response) + deserialized = self._deserialize("PolicyDefinition", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - get.metadata = {'url': "/subscriptions/{subscriptionId}/providers/Microsoft.Authorization/policyDefinitions/{policyDefinitionName}"} # type: ignore - + get.metadata = {"url": "/subscriptions/{subscriptionId}/providers/Microsoft.Authorization/policyDefinitions/{policyDefinitionName}"} # type: ignore @distributed_trace - def get_built_in( - self, - policy_definition_name: str, - **kwargs: Any - ) -> "_models.PolicyDefinition": + def get_built_in(self, policy_definition_name: str, **kwargs: Any) -> _models.PolicyDefinition: """Gets the built in policy definition. - :param policy_definition_name: The name of the built in policy definition to get. + :param policy_definition_name: The name of the built in policy definition to get. Required. :type policy_definition_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: PolicyDefinition, or the result of cls(response) + :return: PolicyDefinition or the result of cls(response) :rtype: ~azure.mgmt.resource.policy.v2016_12_01.models.PolicyDefinition - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.PolicyDefinition"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + 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', "2016-12-01") # type: str + api_version = kwargs.pop("api_version", _params.pop("api-version", "2016-12-01")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[_models.PolicyDefinition] - request = build_policy_definitions_get_built_in_request( policy_definition_name=policy_definition_name, api_version=api_version, - template_url=self.get_built_in.metadata['url'], + template_url=self.get_built_in.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) - deserialized = self._deserialize('PolicyDefinition', pipeline_response) + deserialized = self._deserialize("PolicyDefinition", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - get_built_in.metadata = {'url': "/providers/Microsoft.Authorization/policyDefinitions/{policyDefinitionName}"} # type: ignore - + get_built_in.metadata = {"url": "/providers/Microsoft.Authorization/policyDefinitions/{policyDefinitionName}"} # type: ignore - @distributed_trace + @overload def create_or_update_at_management_group( self, policy_definition_name: str, management_group_id: str, - parameters: "_models.PolicyDefinition", + parameters: _models.PolicyDefinition, *, - content_type: Optional[str] = "application/json", + content_type: str = "application/json", **kwargs: Any - ) -> "_models.PolicyDefinition": + ) -> _models.PolicyDefinition: """Creates or updates a policy definition at management group level. - :param policy_definition_name: The name of the policy definition to create. + :param policy_definition_name: The name of the policy definition to create. Required. :type policy_definition_name: str - :param management_group_id: The ID of the management group. + :param management_group_id: The ID of the management group. Required. :type management_group_id: str - :param parameters: The policy definition properties. + :param parameters: The policy definition properties. Required. :type parameters: ~azure.mgmt.resource.policy.v2016_12_01.models.PolicyDefinition - :keyword content_type: Media type of the body sent to the API. Possible values are: - "application/json" or "text/json". Default value is "application/json". + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: PolicyDefinition or the result of cls(response) + :rtype: ~azure.mgmt.resource.policy.v2016_12_01.models.PolicyDefinition + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + def create_or_update_at_management_group( + self, + policy_definition_name: str, + management_group_id: str, + parameters: IO, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.PolicyDefinition: + """Creates or updates a policy definition at management group level. + + :param policy_definition_name: The name of the policy definition to create. Required. + :type policy_definition_name: str + :param management_group_id: The ID of the management group. Required. + :type management_group_id: str + :param parameters: The policy definition properties. Required. + :type parameters: IO + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Known values are: 'application/json', 'text/json'. Default value is "application/json". :paramtype content_type: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: PolicyDefinition, or the result of cls(response) + :return: PolicyDefinition or the result of cls(response) :rtype: ~azure.mgmt.resource.policy.v2016_12_01.models.PolicyDefinition - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace + def create_or_update_at_management_group( + self, + policy_definition_name: str, + management_group_id: str, + parameters: Union[_models.PolicyDefinition, IO], + **kwargs: Any + ) -> _models.PolicyDefinition: + """Creates or updates a policy definition at management group level. + + :param policy_definition_name: The name of the policy definition to create. Required. + :type policy_definition_name: str + :param management_group_id: The ID of the management group. Required. + :type management_group_id: str + :param parameters: The policy definition properties. Is either a model type or a IO type. + Required. + :type parameters: ~azure.mgmt.resource.policy.v2016_12_01.models.PolicyDefinition or IO + :keyword content_type: Body Parameter content-type. Known values are: 'application/json', + 'text/json'. Default value is None. + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: PolicyDefinition or the result of cls(response) + :rtype: ~azure.mgmt.resource.policy.v2016_12_01.models.PolicyDefinition + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.PolicyDefinition"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', "2016-12-01") # type: str + api_version = kwargs.pop("api_version", _params.pop("api-version", "2016-12-01")) # type: str + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.PolicyDefinition] - _json = self._serialize.body(parameters, 'PolicyDefinition') + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(parameters, (IO, bytes)): + _content = parameters + else: + _json = self._serialize.body(parameters, "PolicyDefinition") request = build_policy_definitions_create_or_update_at_management_group_request( policy_definition_name=policy_definition_name, @@ -976,73 +982,77 @@ def create_or_update_at_management_group( api_version=api_version, content_type=content_type, json=_json, - template_url=self.create_or_update_at_management_group.metadata['url'], + content=_content, + template_url=self.create_or_update_at_management_group.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [201]: map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) - deserialized = self._deserialize('PolicyDefinition', pipeline_response) + deserialized = self._deserialize("PolicyDefinition", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - create_or_update_at_management_group.metadata = {'url': "/providers/Microsoft.Management/managementgroups/{managementGroupId}/providers/Microsoft.Authorization/policyDefinitions/{policyDefinitionName}"} # type: ignore - + create_or_update_at_management_group.metadata = {"url": "/providers/Microsoft.Management/managementgroups/{managementGroupId}/providers/Microsoft.Authorization/policyDefinitions/{policyDefinitionName}"} # type: ignore @distributed_trace def delete_at_management_group( # pylint: disable=inconsistent-return-statements - self, - policy_definition_name: str, - management_group_id: str, - **kwargs: Any + self, policy_definition_name: str, management_group_id: str, **kwargs: Any ) -> None: """Deletes a policy definition at management group level. - :param policy_definition_name: The name of the policy definition to delete. + :param policy_definition_name: The name of the policy definition to delete. Required. :type policy_definition_name: str - :param management_group_id: The ID of the management group. + :param management_group_id: The ID of the management group. Required. :type management_group_id: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: None, or the result of cls(response) + :return: None or the result of cls(response) :rtype: None - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType[None] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) - api_version = kwargs.pop('api_version', "2016-12-01") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2016-12-01")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[None] - request = build_policy_definitions_delete_at_management_group_request( policy_definition_name=policy_definition_name, management_group_id=management_group_id, api_version=api_version, - template_url=self.delete_at_management_group.metadata['url'], + template_url=self.delete_at_management_group.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200, 204]: @@ -1052,106 +1062,112 @@ def delete_at_management_group( # pylint: disable=inconsistent-return-statement if cls: return cls(pipeline_response, None, {}) - delete_at_management_group.metadata = {'url': "/providers/Microsoft.Management/managementgroups/{managementGroupId}/providers/Microsoft.Authorization/policyDefinitions/{policyDefinitionName}"} # type: ignore - + delete_at_management_group.metadata = {"url": "/providers/Microsoft.Management/managementgroups/{managementGroupId}/providers/Microsoft.Authorization/policyDefinitions/{policyDefinitionName}"} # type: ignore @distributed_trace def get_at_management_group( - self, - policy_definition_name: str, - management_group_id: str, - **kwargs: Any - ) -> "_models.PolicyDefinition": + self, policy_definition_name: str, management_group_id: str, **kwargs: Any + ) -> _models.PolicyDefinition: """Gets the policy definition at management group level. - :param policy_definition_name: The name of the policy definition to get. + :param policy_definition_name: The name of the policy definition to get. Required. :type policy_definition_name: str - :param management_group_id: The ID of the management group. + :param management_group_id: The ID of the management group. Required. :type management_group_id: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: PolicyDefinition, or the result of cls(response) + :return: PolicyDefinition or the result of cls(response) :rtype: ~azure.mgmt.resource.policy.v2016_12_01.models.PolicyDefinition - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.PolicyDefinition"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + 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', "2016-12-01") # type: str + api_version = kwargs.pop("api_version", _params.pop("api-version", "2016-12-01")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[_models.PolicyDefinition] - request = build_policy_definitions_get_at_management_group_request( policy_definition_name=policy_definition_name, management_group_id=management_group_id, api_version=api_version, - template_url=self.get_at_management_group.metadata['url'], + template_url=self.get_at_management_group.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) - deserialized = self._deserialize('PolicyDefinition', pipeline_response) + deserialized = self._deserialize("PolicyDefinition", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - get_at_management_group.metadata = {'url': "/providers/Microsoft.Management/managementgroups/{managementGroupId}/providers/Microsoft.Authorization/policyDefinitions/{policyDefinitionName}"} # type: ignore - + get_at_management_group.metadata = {"url": "/providers/Microsoft.Management/managementgroups/{managementGroupId}/providers/Microsoft.Authorization/policyDefinitions/{policyDefinitionName}"} # type: ignore @distributed_trace - def list( - self, - **kwargs: Any - ) -> Iterable["_models.PolicyDefinitionListResult"]: + def list(self, **kwargs: Any) -> Iterable["_models.PolicyDefinition"]: """Gets all the policy definitions for a subscription. :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either PolicyDefinitionListResult or the result of - cls(response) + :return: An iterator like instance of either PolicyDefinition or the result of cls(response) :rtype: - ~azure.core.paging.ItemPaged[~azure.mgmt.resource.policy.v2016_12_01.models.PolicyDefinitionListResult] - :raises: ~azure.core.exceptions.HttpResponseError + ~azure.core.paging.ItemPaged[~azure.mgmt.resource.policy.v2016_12_01.models.PolicyDefinition] + :raises ~azure.core.exceptions.HttpResponseError: """ - api_version = kwargs.pop('api_version', "2016-12-01") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2016-12-01")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[_models.PolicyDefinitionListResult] - cls = kwargs.pop('cls', None) # type: ClsType["_models.PolicyDefinitionListResult"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) + def prepare_request(next_link=None): if not next_link: - + request = build_policy_definitions_list_request( subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.list.metadata['url'], + template_url=self.list.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore else: - - request = build_policy_definitions_list_request( - subscription_id=self._config.subscription_id, - template_url=next_link, - ) + # make call to next link with the client's api-version + _parsed_next_link = urlparse(next_link) + _next_request_params = case_insensitive_dict(parse_qs(_parsed_next_link.query)) + _next_request_params["api-version"] = self._config.api_version + request = HttpRequest("GET", urljoin(next_link, _parsed_next_link.path), params=_next_request_params) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore request.method = "GET" return request @@ -1165,10 +1181,8 @@ def extract_data(pipeline_response): def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) response = pipeline_response.http_response @@ -1178,50 +1192,54 @@ def get_next(next_link=None): return pipeline_response + return ItemPaged(get_next, extract_data) - return ItemPaged( - get_next, extract_data - ) - list.metadata = {'url': "/subscriptions/{subscriptionId}/providers/Microsoft.Authorization/policyDefinitions"} # type: ignore + list.metadata = {"url": "/subscriptions/{subscriptionId}/providers/Microsoft.Authorization/policyDefinitions"} # type: ignore @distributed_trace - def list_built_in( - self, - **kwargs: Any - ) -> Iterable["_models.PolicyDefinitionListResult"]: + def list_built_in(self, **kwargs: Any) -> Iterable["_models.PolicyDefinition"]: """Gets all the built in policy definitions. :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either PolicyDefinitionListResult or the result of - cls(response) + :return: An iterator like instance of either PolicyDefinition or the result of cls(response) :rtype: - ~azure.core.paging.ItemPaged[~azure.mgmt.resource.policy.v2016_12_01.models.PolicyDefinitionListResult] - :raises: ~azure.core.exceptions.HttpResponseError + ~azure.core.paging.ItemPaged[~azure.mgmt.resource.policy.v2016_12_01.models.PolicyDefinition] + :raises ~azure.core.exceptions.HttpResponseError: """ - api_version = kwargs.pop('api_version', "2016-12-01") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2016-12-01")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[_models.PolicyDefinitionListResult] - cls = kwargs.pop('cls', None) # type: ClsType["_models.PolicyDefinitionListResult"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) + def prepare_request(next_link=None): if not next_link: - + request = build_policy_definitions_list_built_in_request( api_version=api_version, - template_url=self.list_built_in.metadata['url'], + template_url=self.list_built_in.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore else: - - request = build_policy_definitions_list_built_in_request( - template_url=next_link, - ) + # make call to next link with the client's api-version + _parsed_next_link = urlparse(next_link) + _next_request_params = case_insensitive_dict(parse_qs(_parsed_next_link.query)) + _next_request_params["api-version"] = self._config.api_version + request = HttpRequest("GET", urljoin(next_link, _parsed_next_link.path), params=_next_request_params) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore request.method = "GET" return request @@ -1235,10 +1253,8 @@ def extract_data(pipeline_response): def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) response = pipeline_response.http_response @@ -1248,55 +1264,57 @@ def get_next(next_link=None): return pipeline_response + return ItemPaged(get_next, extract_data) - return ItemPaged( - get_next, extract_data - ) - list_built_in.metadata = {'url': "/providers/Microsoft.Authorization/policyDefinitions"} # type: ignore + list_built_in.metadata = {"url": "/providers/Microsoft.Authorization/policyDefinitions"} # type: ignore @distributed_trace - def list_by_management_group( - self, - management_group_id: str, - **kwargs: Any - ) -> Iterable["_models.PolicyDefinitionListResult"]: + def list_by_management_group(self, management_group_id: str, **kwargs: Any) -> Iterable["_models.PolicyDefinition"]: """Gets all the policy definitions for a subscription at management group level. - :param management_group_id: The ID of the management group. + :param management_group_id: The ID of the management group. Required. :type management_group_id: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either PolicyDefinitionListResult or the result of - cls(response) + :return: An iterator like instance of either PolicyDefinition or the result of cls(response) :rtype: - ~azure.core.paging.ItemPaged[~azure.mgmt.resource.policy.v2016_12_01.models.PolicyDefinitionListResult] - :raises: ~azure.core.exceptions.HttpResponseError + ~azure.core.paging.ItemPaged[~azure.mgmt.resource.policy.v2016_12_01.models.PolicyDefinition] + :raises ~azure.core.exceptions.HttpResponseError: """ - api_version = kwargs.pop('api_version', "2016-12-01") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2016-12-01")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[_models.PolicyDefinitionListResult] - cls = kwargs.pop('cls', None) # type: ClsType["_models.PolicyDefinitionListResult"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) + def prepare_request(next_link=None): if not next_link: - + request = build_policy_definitions_list_by_management_group_request( management_group_id=management_group_id, api_version=api_version, - template_url=self.list_by_management_group.metadata['url'], + template_url=self.list_by_management_group.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore else: - - request = build_policy_definitions_list_by_management_group_request( - management_group_id=management_group_id, - template_url=next_link, - ) + # make call to next link with the client's api-version + _parsed_next_link = urlparse(next_link) + _next_request_params = case_insensitive_dict(parse_qs(_parsed_next_link.query)) + _next_request_params["api-version"] = self._config.api_version + request = HttpRequest("GET", urljoin(next_link, _parsed_next_link.path), params=_next_request_params) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore request.method = "GET" return request @@ -1310,10 +1328,8 @@ def extract_data(pipeline_response): def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) response = pipeline_response.http_response @@ -1323,74 +1339,72 @@ def get_next(next_link=None): return pipeline_response + return ItemPaged(get_next, extract_data) - return ItemPaged( - get_next, extract_data - ) - list_by_management_group.metadata = {'url': "/providers/Microsoft.Management/managementgroups/{managementGroupId}/providers/Microsoft.Authorization/policyDefinitions"} # type: ignore -class PolicyAssignmentsOperations(object): - """PolicyAssignmentsOperations operations. - - You should not instantiate this class directly. Instead, you should create a Client instance that - instantiates it for you and attaches it as an attribute. - - :ivar models: Alias to model classes used in this operation group. - :type models: ~azure.mgmt.resource.policy.v2016_12_01.models - :param client: Client for service requests. - :param config: Configuration of service client. - :param serializer: An object model serializer. - :param deserializer: An object model deserializer. + list_by_management_group.metadata = {"url": "/providers/Microsoft.Management/managementgroups/{managementGroupId}/providers/Microsoft.Authorization/policyDefinitions"} # type: ignore + + +class PolicyAssignmentsOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. + + Instead, you should access the following operations through + :class:`~azure.mgmt.resource.policy.v2016_12_01.PolicyClient`'s + :attr:`policy_assignments` attribute. """ models = _models - def __init__(self, client, config, serializer, deserializer): - self._client = client - self._serialize = serializer - self._deserialize = deserializer - self._config = config + def __init__(self, *args, **kwargs): + input_args = list(args) + self._client = input_args.pop(0) if input_args else kwargs.pop("client") + self._config = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") @distributed_trace - def delete( - self, - scope: str, - policy_assignment_name: str, - **kwargs: Any - ) -> Optional["_models.PolicyAssignment"]: + def delete(self, scope: str, policy_assignment_name: str, **kwargs: Any) -> Optional[_models.PolicyAssignment]: """Deletes a policy assignment. - :param scope: The scope of the policy assignment. + :param scope: The scope of the policy assignment. Required. :type scope: str - :param policy_assignment_name: The name of the policy assignment to delete. + :param policy_assignment_name: The name of the policy assignment to delete. Required. :type policy_assignment_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: PolicyAssignment, or the result of cls(response) + :return: PolicyAssignment or None or the result of cls(response) :rtype: ~azure.mgmt.resource.policy.v2016_12_01.models.PolicyAssignment or None - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType[Optional["_models.PolicyAssignment"]] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) - api_version = kwargs.pop('api_version', "2016-12-01") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2016-12-01")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[Optional[_models.PolicyAssignment]] - request = build_policy_assignments_delete_request( scope=scope, policy_assignment_name=policy_assignment_name, api_version=api_version, - template_url=self.delete.metadata['url'], + template_url=self.delete.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200, 204]: @@ -1399,54 +1413,121 @@ def delete( deserialized = None if response.status_code == 200: - deserialized = self._deserialize('PolicyAssignment', pipeline_response) + deserialized = self._deserialize("PolicyAssignment", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - delete.metadata = {'url': "/{scope}/providers/Microsoft.Authorization/policyAssignments/{policyAssignmentName}"} # type: ignore + delete.metadata = {"url": "/{scope}/providers/Microsoft.Authorization/policyAssignments/{policyAssignmentName}"} # type: ignore - - @distributed_trace + @overload def create( self, scope: str, policy_assignment_name: str, - parameters: "_models.PolicyAssignment", + parameters: _models.PolicyAssignment, *, - content_type: Optional[str] = "application/json", + content_type: str = "application/json", **kwargs: Any - ) -> "_models.PolicyAssignment": + ) -> _models.PolicyAssignment: """Creates a policy assignment. Policy assignments are inherited by child resources. For example, when you apply a policy to a resource group that policy is assigned to all resources in the group. - :param scope: The scope of the policy assignment. + :param scope: The scope of the policy assignment. Required. :type scope: str - :param policy_assignment_name: The name of the policy assignment. + :param policy_assignment_name: The name of the policy assignment. Required. :type policy_assignment_name: str - :param parameters: Parameters for the policy assignment. + :param parameters: Parameters for the policy assignment. Required. :type parameters: ~azure.mgmt.resource.policy.v2016_12_01.models.PolicyAssignment - :keyword content_type: Media type of the body sent to the API. Possible values are: - "application/json" or "text/json". Default value is "application/json". + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: PolicyAssignment or the result of cls(response) + :rtype: ~azure.mgmt.resource.policy.v2016_12_01.models.PolicyAssignment + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + def create( + self, + scope: str, + policy_assignment_name: str, + parameters: IO, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.PolicyAssignment: + """Creates a policy assignment. + + Policy assignments are inherited by child resources. For example, when you apply a policy to a + resource group that policy is assigned to all resources in the group. + + :param scope: The scope of the policy assignment. Required. + :type scope: str + :param policy_assignment_name: The name of the policy assignment. Required. + :type policy_assignment_name: str + :param parameters: Parameters for the policy assignment. Required. + :type parameters: IO + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Known values are: 'application/json', 'text/json'. Default value is "application/json". + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: PolicyAssignment or the result of cls(response) + :rtype: ~azure.mgmt.resource.policy.v2016_12_01.models.PolicyAssignment + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace + def create( + self, scope: str, policy_assignment_name: str, parameters: Union[_models.PolicyAssignment, IO], **kwargs: Any + ) -> _models.PolicyAssignment: + """Creates a policy assignment. + + Policy assignments are inherited by child resources. For example, when you apply a policy to a + resource group that policy is assigned to all resources in the group. + + :param scope: The scope of the policy assignment. Required. + :type scope: str + :param policy_assignment_name: The name of the policy assignment. Required. + :type policy_assignment_name: str + :param parameters: Parameters for the policy assignment. Is either a model type or a IO type. + Required. + :type parameters: ~azure.mgmt.resource.policy.v2016_12_01.models.PolicyAssignment or IO + :keyword content_type: Body Parameter content-type. Known values are: 'application/json', + 'text/json'. Default value is None. :paramtype content_type: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: PolicyAssignment, or the result of cls(response) + :return: PolicyAssignment or the result of cls(response) :rtype: ~azure.mgmt.resource.policy.v2016_12_01.models.PolicyAssignment - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.PolicyAssignment"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', "2016-12-01") # type: str + api_version = kwargs.pop("api_version", _params.pop("api-version", "2016-12-01")) # type: str + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.PolicyAssignment] - _json = self._serialize.body(parameters, 'PolicyAssignment') + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(parameters, (IO, bytes)): + _content = parameters + else: + _json = self._serialize.body(parameters, "PolicyAssignment") request = build_policy_assignments_create_request( scope=scope, @@ -1454,138 +1535,144 @@ def create( api_version=api_version, content_type=content_type, json=_json, - template_url=self.create.metadata['url'], + content=_content, + template_url=self.create.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [201]: map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) - deserialized = self._deserialize('PolicyAssignment', pipeline_response) + deserialized = self._deserialize("PolicyAssignment", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - create.metadata = {'url': "/{scope}/providers/Microsoft.Authorization/policyAssignments/{policyAssignmentName}"} # type: ignore - + create.metadata = {"url": "/{scope}/providers/Microsoft.Authorization/policyAssignments/{policyAssignmentName}"} # type: ignore @distributed_trace - def get( - self, - scope: str, - policy_assignment_name: str, - **kwargs: Any - ) -> "_models.PolicyAssignment": + def get(self, scope: str, policy_assignment_name: str, **kwargs: Any) -> _models.PolicyAssignment: """Gets a policy assignment. - :param scope: The scope of the policy assignment. + :param scope: The scope of the policy assignment. Required. :type scope: str - :param policy_assignment_name: The name of the policy assignment to get. + :param policy_assignment_name: The name of the policy assignment to get. Required. :type policy_assignment_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: PolicyAssignment, or the result of cls(response) + :return: PolicyAssignment or the result of cls(response) :rtype: ~azure.mgmt.resource.policy.v2016_12_01.models.PolicyAssignment - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.PolicyAssignment"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) - api_version = kwargs.pop('api_version', "2016-12-01") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2016-12-01")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[_models.PolicyAssignment] - request = build_policy_assignments_get_request( scope=scope, policy_assignment_name=policy_assignment_name, api_version=api_version, - template_url=self.get.metadata['url'], + template_url=self.get.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) - deserialized = self._deserialize('PolicyAssignment', pipeline_response) + deserialized = self._deserialize("PolicyAssignment", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - get.metadata = {'url': "/{scope}/providers/Microsoft.Authorization/policyAssignments/{policyAssignmentName}"} # type: ignore - + get.metadata = {"url": "/{scope}/providers/Microsoft.Authorization/policyAssignments/{policyAssignmentName}"} # type: ignore @distributed_trace def list_for_resource_group( - self, - resource_group_name: str, - filter: Optional[str] = None, - **kwargs: Any - ) -> Iterable["_models.PolicyAssignmentListResult"]: + self, resource_group_name: str, filter: Optional[str] = None, **kwargs: Any + ) -> Iterable["_models.PolicyAssignment"]: """Gets policy assignments for the resource group. :param resource_group_name: The name of the resource group that contains policy assignments. + Required. :type resource_group_name: str :param filter: The filter to apply on the operation. Default value is None. :type filter: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either PolicyAssignmentListResult or the result of - cls(response) + :return: An iterator like instance of either PolicyAssignment or the result of cls(response) :rtype: - ~azure.core.paging.ItemPaged[~azure.mgmt.resource.policy.v2016_12_01.models.PolicyAssignmentListResult] - :raises: ~azure.core.exceptions.HttpResponseError + ~azure.core.paging.ItemPaged[~azure.mgmt.resource.policy.v2016_12_01.models.PolicyAssignment] + :raises ~azure.core.exceptions.HttpResponseError: """ - api_version = kwargs.pop('api_version', "2016-12-01") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2016-12-01")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[_models.PolicyAssignmentListResult] - cls = kwargs.pop('cls', None) # type: ClsType["_models.PolicyAssignmentListResult"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) + def prepare_request(next_link=None): if not next_link: - + request = build_policy_assignments_list_for_resource_group_request( resource_group_name=resource_group_name, subscription_id=self._config.subscription_id, - api_version=api_version, filter=filter, - template_url=self.list_for_resource_group.metadata['url'], + api_version=api_version, + template_url=self.list_for_resource_group.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore else: - - request = build_policy_assignments_list_for_resource_group_request( - resource_group_name=resource_group_name, - subscription_id=self._config.subscription_id, - template_url=next_link, - ) + # make call to next link with the client's api-version + _parsed_next_link = urlparse(next_link) + _next_request_params = case_insensitive_dict(parse_qs(_parsed_next_link.query)) + _next_request_params["api-version"] = self._config.api_version + request = HttpRequest("GET", urljoin(next_link, _parsed_next_link.path), params=_next_request_params) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore request.method = "GET" return request @@ -1599,10 +1686,8 @@ def extract_data(pipeline_response): def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) response = pipeline_response.http_response @@ -1612,11 +1697,9 @@ def get_next(next_link=None): return pipeline_response + return ItemPaged(get_next, extract_data) - return ItemPaged( - get_next, extract_data - ) - list_for_resource_group.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Authorization/policyAssignments"} # type: ignore + list_for_resource_group.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Authorization/policyAssignments"} # type: ignore @distributed_trace def list_for_resource( @@ -1628,39 +1711,45 @@ def list_for_resource( resource_name: str, filter: Optional[str] = None, **kwargs: Any - ) -> Iterable["_models.PolicyAssignmentListResult"]: + ) -> Iterable["_models.PolicyAssignment"]: """Gets policy assignments for a resource. :param resource_group_name: The name of the resource group containing the resource. The name is - case insensitive. + case insensitive. Required. :type resource_group_name: str - :param resource_provider_namespace: The namespace of the resource provider. + :param resource_provider_namespace: The namespace of the resource provider. Required. :type resource_provider_namespace: str - :param parent_resource_path: The parent resource path. + :param parent_resource_path: The parent resource path. Required. :type parent_resource_path: str - :param resource_type: The resource type. + :param resource_type: The resource type. Required. :type resource_type: str - :param resource_name: The name of the resource with policy assignments. + :param resource_name: The name of the resource with policy assignments. Required. :type resource_name: str :param filter: The filter to apply on the operation. Default value is None. :type filter: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either PolicyAssignmentListResult or the result of - cls(response) + :return: An iterator like instance of either PolicyAssignment or the result of cls(response) :rtype: - ~azure.core.paging.ItemPaged[~azure.mgmt.resource.policy.v2016_12_01.models.PolicyAssignmentListResult] - :raises: ~azure.core.exceptions.HttpResponseError + ~azure.core.paging.ItemPaged[~azure.mgmt.resource.policy.v2016_12_01.models.PolicyAssignment] + :raises ~azure.core.exceptions.HttpResponseError: """ - api_version = kwargs.pop('api_version', "2016-12-01") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2016-12-01")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[_models.PolicyAssignmentListResult] - cls = kwargs.pop('cls', None) # type: ClsType["_models.PolicyAssignmentListResult"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) + def prepare_request(next_link=None): if not next_link: - + request = build_policy_assignments_list_for_resource_request( resource_group_name=resource_group_name, resource_provider_namespace=resource_provider_namespace, @@ -1668,26 +1757,23 @@ def prepare_request(next_link=None): resource_type=resource_type, resource_name=resource_name, subscription_id=self._config.subscription_id, - api_version=api_version, filter=filter, - template_url=self.list_for_resource.metadata['url'], + api_version=api_version, + template_url=self.list_for_resource.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore else: - - request = build_policy_assignments_list_for_resource_request( - resource_group_name=resource_group_name, - resource_provider_namespace=resource_provider_namespace, - parent_resource_path=parent_resource_path, - resource_type=resource_type, - resource_name=resource_name, - subscription_id=self._config.subscription_id, - template_url=next_link, - ) + # make call to next link with the client's api-version + _parsed_next_link = urlparse(next_link) + _next_request_params = case_insensitive_dict(parse_qs(_parsed_next_link.query)) + _next_request_params["api-version"] = self._config.api_version + request = HttpRequest("GET", urljoin(next_link, _parsed_next_link.path), params=_next_request_params) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore request.method = "GET" return request @@ -1701,10 +1787,8 @@ def extract_data(pipeline_response): def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) response = pipeline_response.http_response @@ -1714,56 +1798,58 @@ def get_next(next_link=None): return pipeline_response + return ItemPaged(get_next, extract_data) - return ItemPaged( - get_next, extract_data - ) - list_for_resource.metadata = {'url': "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{parentResourcePath}/{resourceType}/{resourceName}/providers/Microsoft.Authorization/policyAssignments"} # type: ignore + list_for_resource.metadata = {"url": "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{parentResourcePath}/{resourceType}/{resourceName}/providers/Microsoft.Authorization/policyAssignments"} # type: ignore @distributed_trace - def list( - self, - filter: Optional[str] = None, - **kwargs: Any - ) -> Iterable["_models.PolicyAssignmentListResult"]: + def list(self, filter: Optional[str] = None, **kwargs: Any) -> Iterable["_models.PolicyAssignment"]: """Gets all the policy assignments for a subscription. :param filter: The filter to apply on the operation. Default value is None. :type filter: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either PolicyAssignmentListResult or the result of - cls(response) + :return: An iterator like instance of either PolicyAssignment or the result of cls(response) :rtype: - ~azure.core.paging.ItemPaged[~azure.mgmt.resource.policy.v2016_12_01.models.PolicyAssignmentListResult] - :raises: ~azure.core.exceptions.HttpResponseError + ~azure.core.paging.ItemPaged[~azure.mgmt.resource.policy.v2016_12_01.models.PolicyAssignment] + :raises ~azure.core.exceptions.HttpResponseError: """ - api_version = kwargs.pop('api_version', "2016-12-01") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2016-12-01")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[_models.PolicyAssignmentListResult] - cls = kwargs.pop('cls', None) # type: ClsType["_models.PolicyAssignmentListResult"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) + def prepare_request(next_link=None): if not next_link: - + request = build_policy_assignments_list_request( subscription_id=self._config.subscription_id, - api_version=api_version, filter=filter, - template_url=self.list.metadata['url'], + 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.url = self._client.format_url(request.url) # type: ignore else: - - request = build_policy_assignments_list_request( - subscription_id=self._config.subscription_id, - template_url=next_link, - ) + # make call to next link with the client's api-version + _parsed_next_link = urlparse(next_link) + _next_request_params = case_insensitive_dict(parse_qs(_parsed_next_link.query)) + _next_request_params["api-version"] = self._config.api_version + request = HttpRequest("GET", urljoin(next_link, _parsed_next_link.path), params=_next_request_params) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore request.method = "GET" return request @@ -1777,10 +1863,8 @@ def extract_data(pipeline_response): def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) response = pipeline_response.http_response @@ -1790,18 +1874,12 @@ def get_next(next_link=None): return pipeline_response + return ItemPaged(get_next, extract_data) - return ItemPaged( - get_next, extract_data - ) - list.metadata = {'url': "/subscriptions/{subscriptionId}/providers/Microsoft.Authorization/policyAssignments"} # type: ignore + list.metadata = {"url": "/subscriptions/{subscriptionId}/providers/Microsoft.Authorization/policyAssignments"} # type: ignore @distributed_trace - def delete_by_id( - self, - policy_assignment_id: str, - **kwargs: Any - ) -> "_models.PolicyAssignment": + def delete_by_id(self, policy_assignment_id: str, **kwargs: Any) -> _models.PolicyAssignment: """Deletes a policy assignment by ID. When providing a scope for the assignment, use '/subscriptions/{subscription-id}/' for @@ -1812,59 +1890,65 @@ def delete_by_id( :param policy_assignment_id: The ID of the policy assignment to delete. Use the format '/{scope}/providers/Microsoft.Authorization/policyAssignments/{policy-assignment-name}'. + Required. :type policy_assignment_id: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: PolicyAssignment, or the result of cls(response) + :return: PolicyAssignment or the result of cls(response) :rtype: ~azure.mgmt.resource.policy.v2016_12_01.models.PolicyAssignment - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.PolicyAssignment"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + 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', "2016-12-01") # type: str + api_version = kwargs.pop("api_version", _params.pop("api-version", "2016-12-01")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[_models.PolicyAssignment] - request = build_policy_assignments_delete_by_id_request( policy_assignment_id=policy_assignment_id, api_version=api_version, - template_url=self.delete_by_id.metadata['url'], + template_url=self.delete_by_id.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) - deserialized = self._deserialize('PolicyAssignment', pipeline_response) + deserialized = self._deserialize("PolicyAssignment", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - delete_by_id.metadata = {'url': "/{policyAssignmentId}"} # type: ignore - + delete_by_id.metadata = {"url": "/{policyAssignmentId}"} # type: ignore - @distributed_trace + @overload def create_by_id( self, policy_assignment_id: str, - parameters: "_models.PolicyAssignment", + parameters: _models.PolicyAssignment, *, - content_type: Optional[str] = "application/json", + content_type: str = "application/json", **kwargs: Any - ) -> "_models.PolicyAssignment": + ) -> _models.PolicyAssignment: """Creates a policy assignment by ID. Policy assignments are inherited by child resources. For example, when you apply a policy to a @@ -1877,64 +1961,134 @@ def create_by_id( :param policy_assignment_id: The ID of the policy assignment to create. Use the format '/{scope}/providers/Microsoft.Authorization/policyAssignments/{policy-assignment-name}'. + Required. :type policy_assignment_id: str - :param parameters: Parameters for policy assignment. + :param parameters: Parameters for policy assignment. Required. :type parameters: ~azure.mgmt.resource.policy.v2016_12_01.models.PolicyAssignment - :keyword content_type: Media type of the body sent to the API. Possible values are: - "application/json" or "text/json". Default value is "application/json". + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". :paramtype content_type: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: PolicyAssignment, or the result of cls(response) + :return: PolicyAssignment or the result of cls(response) :rtype: ~azure.mgmt.resource.policy.v2016_12_01.models.PolicyAssignment - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + def create_by_id( + self, policy_assignment_id: str, parameters: IO, *, content_type: str = "application/json", **kwargs: Any + ) -> _models.PolicyAssignment: + """Creates a policy assignment by ID. + + Policy assignments are inherited by child resources. For example, when you apply a policy to a + resource group that policy is assigned to all resources in the group. When providing a scope + for the assignment, use '/subscriptions/{subscription-id}/' for subscriptions, + '/subscriptions/{subscription-id}/resourceGroups/{resource-group-name}' for resource groups, + and + '/subscriptions/{subscription-id}/resourceGroups/{resource-group-name}/providers/{resource-provider-namespace}/{resource-type}/{resource-name}' + for resources. + + :param policy_assignment_id: The ID of the policy assignment to create. Use the format + '/{scope}/providers/Microsoft.Authorization/policyAssignments/{policy-assignment-name}'. + Required. + :type policy_assignment_id: str + :param parameters: Parameters for policy assignment. Required. + :type parameters: IO + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Known values are: 'application/json', 'text/json'. Default value is "application/json". + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: PolicyAssignment or the result of cls(response) + :rtype: ~azure.mgmt.resource.policy.v2016_12_01.models.PolicyAssignment + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace + def create_by_id( + self, policy_assignment_id: str, parameters: Union[_models.PolicyAssignment, IO], **kwargs: Any + ) -> _models.PolicyAssignment: + """Creates a policy assignment by ID. + + Policy assignments are inherited by child resources. For example, when you apply a policy to a + resource group that policy is assigned to all resources in the group. When providing a scope + for the assignment, use '/subscriptions/{subscription-id}/' for subscriptions, + '/subscriptions/{subscription-id}/resourceGroups/{resource-group-name}' for resource groups, + and + '/subscriptions/{subscription-id}/resourceGroups/{resource-group-name}/providers/{resource-provider-namespace}/{resource-type}/{resource-name}' + for resources. + + :param policy_assignment_id: The ID of the policy assignment to create. Use the format + '/{scope}/providers/Microsoft.Authorization/policyAssignments/{policy-assignment-name}'. + Required. + :type policy_assignment_id: str + :param parameters: Parameters for policy assignment. Is either a model type or a IO type. + Required. + :type parameters: ~azure.mgmt.resource.policy.v2016_12_01.models.PolicyAssignment or IO + :keyword content_type: Body Parameter content-type. Known values are: 'application/json', + 'text/json'. Default value is None. + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: PolicyAssignment or the result of cls(response) + :rtype: ~azure.mgmt.resource.policy.v2016_12_01.models.PolicyAssignment + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.PolicyAssignment"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', "2016-12-01") # type: str + api_version = kwargs.pop("api_version", _params.pop("api-version", "2016-12-01")) # type: str + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.PolicyAssignment] - _json = self._serialize.body(parameters, 'PolicyAssignment') + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(parameters, (IO, bytes)): + _content = parameters + else: + _json = self._serialize.body(parameters, "PolicyAssignment") request = build_policy_assignments_create_by_id_request( policy_assignment_id=policy_assignment_id, api_version=api_version, content_type=content_type, json=_json, - template_url=self.create_by_id.metadata['url'], + content=_content, + template_url=self.create_by_id.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [201]: map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) - deserialized = self._deserialize('PolicyAssignment', pipeline_response) + deserialized = self._deserialize("PolicyAssignment", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - create_by_id.metadata = {'url': "/{policyAssignmentId}"} # type: ignore - + create_by_id.metadata = {"url": "/{policyAssignmentId}"} # type: ignore @distributed_trace - def get_by_id( - self, - policy_assignment_id: str, - **kwargs: Any - ) -> "_models.PolicyAssignment": + def get_by_id(self, policy_assignment_id: str, **kwargs: Any) -> _models.PolicyAssignment: """Gets a policy assignment by ID. When providing a scope for the assignment, use '/subscriptions/{subscription-id}/' for @@ -1945,46 +2099,52 @@ def get_by_id( :param policy_assignment_id: The ID of the policy assignment to get. Use the format '/{scope}/providers/Microsoft.Authorization/policyAssignments/{policy-assignment-name}'. + Required. :type policy_assignment_id: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: PolicyAssignment, or the result of cls(response) + :return: PolicyAssignment or the result of cls(response) :rtype: ~azure.mgmt.resource.policy.v2016_12_01.models.PolicyAssignment - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.PolicyAssignment"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + 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', "2016-12-01") # type: str + api_version = kwargs.pop("api_version", _params.pop("api-version", "2016-12-01")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[_models.PolicyAssignment] - request = build_policy_assignments_get_by_id_request( policy_assignment_id=policy_assignment_id, api_version=api_version, - template_url=self.get_by_id.metadata['url'], + template_url=self.get_by_id.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) - deserialized = self._deserialize('PolicyAssignment', pipeline_response) + deserialized = self._deserialize("PolicyAssignment", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - get_by_id.metadata = {'url': "/{policyAssignmentId}"} # type: ignore - + get_by_id.metadata = {"url": "/{policyAssignmentId}"} # type: ignore diff --git a/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/policy/v2016_12_01/operations/_patch.py b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/policy/v2016_12_01/operations/_patch.py new file mode 100644 index 0000000000000..f7dd32510333d --- /dev/null +++ b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/policy/v2016_12_01/operations/_patch.py @@ -0,0 +1,20 @@ +# ------------------------------------ +# Copyright (c) Microsoft Corporation. +# Licensed under the MIT License. +# ------------------------------------ +"""Customize generated code here. + +Follow our quickstart for examples: https://aka.ms/azsdk/python/dpcodegen/python/customize +""" +from typing import List + +__all__: List[str] = [] # Add all objects you want publicly available to users at this package level + + +def patch_sdk(): + """Do not remove from this file. + + `patch_sdk` is a last resort escape hatch that allows you to do customizations + you can't accomplish using the techniques described in + https://aka.ms/azsdk/python/dpcodegen/python/customize + """ diff --git a/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/policy/v2017_06_01_preview/__init__.py b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/policy/v2017_06_01_preview/__init__.py index 89180ab440872..bb1ffe59afae7 100644 --- a/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/policy/v2017_06_01_preview/__init__.py +++ b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/policy/v2017_06_01_preview/__init__.py @@ -10,9 +10,15 @@ from ._version import VERSION __version__ = VERSION -__all__ = ['PolicyClient'] -# `._patch.py` is used for handwritten extensions to the generated code -# Example: https://github.com/Azure/azure-sdk-for-python/blob/main/doc/dev/customize_code/how-to-patch-sdk-code.md -from ._patch import patch_sdk -patch_sdk() +try: + from ._patch import __all__ as _patch_all + from ._patch import * # type: ignore # pylint: disable=unused-wildcard-import +except ImportError: + _patch_all = [] +from ._patch import patch_sdk as _patch_sdk + +__all__ = ["PolicyClient"] +__all__.extend([p for p in _patch_all if p not in __all__]) + +_patch_sdk() diff --git a/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/policy/v2017_06_01_preview/_configuration.py b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/policy/v2017_06_01_preview/_configuration.py index 4c2ba31e56c60..c6a430f1f8bdc 100644 --- a/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/policy/v2017_06_01_preview/_configuration.py +++ b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/policy/v2017_06_01_preview/_configuration.py @@ -25,18 +25,13 @@ class PolicyClientConfiguration(Configuration): # pylint: disable=too-many-inst Note that all parameters used to create this instance are saved as instance attributes. - :param credential: Credential needed for the client to connect to Azure. + :param credential: Credential needed for the client to connect to Azure. Required. :type credential: ~azure.core.credentials.TokenCredential - :param subscription_id: The ID of the target subscription. + :param subscription_id: The ID of the target subscription. Required. :type subscription_id: str """ - def __init__( - self, - credential: "TokenCredential", - subscription_id: str, - **kwargs: Any - ) -> None: + def __init__(self, credential: "TokenCredential", subscription_id: str, **kwargs: Any) -> None: super(PolicyClientConfiguration, self).__init__(**kwargs) if credential is None: raise ValueError("Parameter 'credential' must not be None.") @@ -45,23 +40,24 @@ def __init__( self.credential = credential self.subscription_id = subscription_id - self.credential_scopes = kwargs.pop('credential_scopes', ['https://management.azure.com/.default']) - kwargs.setdefault('sdk_moniker', 'mgmt-resource/{}'.format(VERSION)) + self.credential_scopes = kwargs.pop("credential_scopes", ["https://management.azure.com/.default"]) + kwargs.setdefault("sdk_moniker", "mgmt-resource/{}".format(VERSION)) self._configure(**kwargs) def _configure( - self, - **kwargs # type: Any + self, **kwargs # type: Any ): # type: (...) -> 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) - self.logging_policy = kwargs.get('logging_policy') or policies.NetworkTraceLoggingPolicy(**kwargs) - self.http_logging_policy = kwargs.get('http_logging_policy') or ARMHttpLoggingPolicy(**kwargs) - self.retry_policy = kwargs.get('retry_policy') or policies.RetryPolicy(**kwargs) - self.custom_hook_policy = kwargs.get('custom_hook_policy') or policies.CustomHookPolicy(**kwargs) - self.redirect_policy = kwargs.get('redirect_policy') or policies.RedirectPolicy(**kwargs) - self.authentication_policy = kwargs.get('authentication_policy') + 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) + self.logging_policy = kwargs.get("logging_policy") or policies.NetworkTraceLoggingPolicy(**kwargs) + self.http_logging_policy = kwargs.get("http_logging_policy") or ARMHttpLoggingPolicy(**kwargs) + self.retry_policy = kwargs.get("retry_policy") or policies.RetryPolicy(**kwargs) + self.custom_hook_policy = kwargs.get("custom_hook_policy") or policies.CustomHookPolicy(**kwargs) + self.redirect_policy = kwargs.get("redirect_policy") or policies.RedirectPolicy(**kwargs) + self.authentication_policy = kwargs.get("authentication_policy") if self.credential and not self.authentication_policy: - self.authentication_policy = ARMChallengeAuthenticationPolicy(self.credential, *self.credential_scopes, **kwargs) + self.authentication_policy = ARMChallengeAuthenticationPolicy( + self.credential, *self.credential_scopes, **kwargs + ) diff --git a/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/policy/v2017_06_01_preview/_metadata.json b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/policy/v2017_06_01_preview/_metadata.json index abaea8b895a74..094a2b363f514 100644 --- a/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/policy/v2017_06_01_preview/_metadata.json +++ b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/policy/v2017_06_01_preview/_metadata.json @@ -10,20 +10,20 @@ "azure_arm": true, "has_lro_operations": false, "client_side_validation": false, - "sync_imports": "{\"typing\": {\"azurecore\": {\"azure.core.credentials\": [\"TokenCredential\"]}}, \"regular\": {\"azurecore\": {\"azure.profiles\": [\"KnownProfiles\", \"ProfileDefinition\"], \"azure.profiles.multiapiclient\": [\"MultiApiClientMixin\"], \"azure.mgmt.core\": [\"ARMPipelineClient\"]}, \"local\": {\"._configuration\": [\"PolicyClientConfiguration\"]}, \"thirdparty\": {\"msrest\": [\"Deserializer\", \"Serializer\"]}}, \"conditional\": {\"stdlib\": {\"typing\": [\"Any\", \"Optional\"]}}}", - "async_imports": "{\"typing\": {\"azurecore\": {\"azure.core.credentials_async\": [\"AsyncTokenCredential\"], \"azure.core.credentials\": [\"TokenCredential\"]}}, \"regular\": {\"azurecore\": {\"azure.profiles\": [\"KnownProfiles\", \"ProfileDefinition\"], \"azure.profiles.multiapiclient\": [\"MultiApiClientMixin\"], \"azure.mgmt.core\": [\"AsyncARMPipelineClient\"]}, \"local\": {\"._configuration\": [\"PolicyClientConfiguration\"]}, \"thirdparty\": {\"msrest\": [\"Deserializer\", \"Serializer\"]}}, \"conditional\": {\"stdlib\": {\"typing\": [\"Any\", \"Optional\"]}}}" + "sync_imports": "{\"conditional\": {\"stdlib\": {\"typing\": [\"Any\", \"Optional\"]}}, \"regular\": {\"azurecore\": {\"azure.mgmt.core\": [\"ARMPipelineClient\"], \"azure.profiles\": [\"KnownProfiles\", \"ProfileDefinition\"], \"azure.profiles.multiapiclient\": [\"MultiApiClientMixin\"]}, \"local\": {\"._configuration\": [\"PolicyClientConfiguration\"], \".._serialization\": [\"Deserializer\", \"Serializer\"]}}, \"typing\": {\"azurecore\": {\"azure.core.credentials\": [\"TokenCredential\"]}}}", + "async_imports": "{\"conditional\": {\"stdlib\": {\"typing\": [\"Any\", \"Optional\"]}}, \"regular\": {\"azurecore\": {\"azure.mgmt.core\": [\"AsyncARMPipelineClient\"], \"azure.profiles\": [\"KnownProfiles\", \"ProfileDefinition\"], \"azure.profiles.multiapiclient\": [\"MultiApiClientMixin\"]}, \"local\": {\"._configuration\": [\"PolicyClientConfiguration\"], \"..._serialization\": [\"Deserializer\", \"Serializer\"]}}, \"typing\": {\"azurecore\": {\"azure.core.credentials_async\": [\"AsyncTokenCredential\"]}}}" }, "global_parameters": { "sync": { "credential": { - "signature": "credential, # type: \"TokenCredential\"", - "description": "Credential needed for the client to connect to Azure.", + "signature": "credential: \"TokenCredential\",", + "description": "Credential needed for the client to connect to Azure. Required.", "docstring_type": "~azure.core.credentials.TokenCredential", "required": true }, "subscription_id": { - "signature": "subscription_id, # type: str", - "description": "The ID of the target subscription.", + "signature": "subscription_id: str,", + "description": "The ID of the target subscription. Required.", "docstring_type": "str", "required": true } @@ -31,13 +31,13 @@ "async": { "credential": { "signature": "credential: \"AsyncTokenCredential\",", - "description": "Credential needed for the client to connect to Azure.", + "description": "Credential needed for the client to connect to Azure. Required.", "docstring_type": "~azure.core.credentials_async.AsyncTokenCredential", "required": true }, "subscription_id": { "signature": "subscription_id: str,", - "description": "The ID of the target subscription.", + "description": "The ID of the target subscription. Required.", "docstring_type": "str", "required": true } @@ -54,7 +54,7 @@ "required": false }, "base_url": { - "signature": "base_url=\"https://management.azure.com\", # type: str", + "signature": "base_url: str = \"https://management.azure.com\",", "description": "Service URL", "docstring_type": "str", "required": false diff --git a/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/policy/v2017_06_01_preview/_patch.py b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/policy/v2017_06_01_preview/_patch.py index 74e48ecd07cf3..f99e77fef9861 100644 --- a/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/policy/v2017_06_01_preview/_patch.py +++ b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/policy/v2017_06_01_preview/_patch.py @@ -28,4 +28,4 @@ # This file is used for handwritten extensions to the generated code. Example: # https://github.com/Azure/azure-sdk-for-python/blob/main/doc/dev/customize_code/how-to-patch-sdk-code.md def patch_sdk(): - pass \ No newline at end of file + pass diff --git a/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/policy/v2017_06_01_preview/_policy_client.py b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/policy/v2017_06_01_preview/_policy_client.py index 947d7c447af0f..7b4e9520ae47a 100644 --- a/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/policy/v2017_06_01_preview/_policy_client.py +++ b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/policy/v2017_06_01_preview/_policy_client.py @@ -9,12 +9,11 @@ from copy import deepcopy from typing import Any, TYPE_CHECKING -from msrest import Deserializer, Serializer - from azure.core.rest import HttpRequest, HttpResponse from azure.mgmt.core import ARMPipelineClient from . import models +from .._serialization import Deserializer, Serializer from ._configuration import PolicyClientConfiguration from .operations import PolicyAssignmentsOperations, PolicyDefinitionsOperations, PolicySetDefinitionsOperations @@ -22,7 +21,8 @@ # pylint: disable=unused-import,ungrouped-imports from azure.core.credentials import TokenCredential -class PolicyClient: + +class PolicyClient: # pylint: disable=client-accepts-api-version-keyword """To manage and control access to your resources, you can define customized policies and assign them at a scope. @@ -35,9 +35,9 @@ class PolicyClient: :ivar policy_definitions: PolicyDefinitionsOperations operations :vartype policy_definitions: azure.mgmt.resource.policy.v2017_06_01_preview.operations.PolicyDefinitionsOperations - :param credential: Credential needed for the client to connect to Azure. + :param credential: Credential needed for the client to connect to Azure. Required. :type credential: ~azure.core.credentials.TokenCredential - :param subscription_id: The ID of the target subscription. + :param subscription_id: The ID of the target subscription. Required. :type subscription_id: str :param base_url: Service URL. Default value is "https://management.azure.com". :type base_url: str @@ -57,16 +57,17 @@ def __init__( self._serialize = Serializer(client_models) self._deserialize = Deserializer(client_models) self._serialize.client_side_validation = False - self.policy_assignments = PolicyAssignmentsOperations(self._client, self._config, self._serialize, self._deserialize) - self.policy_set_definitions = PolicySetDefinitionsOperations(self._client, self._config, self._serialize, self._deserialize) - self.policy_definitions = PolicyDefinitionsOperations(self._client, self._config, self._serialize, self._deserialize) - - - def _send_request( - self, - request: HttpRequest, - **kwargs: Any - ) -> HttpResponse: + self.policy_assignments = PolicyAssignmentsOperations( + self._client, self._config, self._serialize, self._deserialize + ) + self.policy_set_definitions = PolicySetDefinitionsOperations( + self._client, self._config, self._serialize, self._deserialize + ) + self.policy_definitions = PolicyDefinitionsOperations( + self._client, self._config, self._serialize, self._deserialize + ) + + def _send_request(self, request: HttpRequest, **kwargs: Any) -> HttpResponse: """Runs the network request through the client's chained policies. >>> from azure.core.rest import HttpRequest @@ -75,7 +76,7 @@ def _send_request( >>> response = client._send_request(request) - For more information on this code flow, see https://aka.ms/azsdk/python/protocol/quickstart + For more information on this code flow, see https://aka.ms/azsdk/dpcodegen/python/send_request :param request: The network request you want to make. Required. :type request: ~azure.core.rest.HttpRequest diff --git a/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/policy/v2017_06_01_preview/_vendor.py b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/policy/v2017_06_01_preview/_vendor.py index 138f663c53a4e..9aad73fc743e7 100644 --- a/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/policy/v2017_06_01_preview/_vendor.py +++ b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/policy/v2017_06_01_preview/_vendor.py @@ -7,6 +7,7 @@ from azure.core.pipeline.transport import HttpRequest + def _convert_request(request, files=None): data = request.content if not files else None request = HttpRequest(method=request.method, url=request.url, headers=request.headers, data=data) @@ -14,6 +15,7 @@ def _convert_request(request, files=None): request.set_formdata_body(files) return request + def _format_url_section(template, **kwargs): components = template.split("/") while components: @@ -21,7 +23,5 @@ def _format_url_section(template, **kwargs): 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 - ] + components = [c for c in formatted_components if "{}".format(key.args[0]) not in c] template = "/".join(components) diff --git a/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/policy/v2017_06_01_preview/_version.py b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/policy/v2017_06_01_preview/_version.py index a012ac01c480c..e5754a47ce68f 100644 --- a/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/policy/v2017_06_01_preview/_version.py +++ b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/policy/v2017_06_01_preview/_version.py @@ -6,4 +6,4 @@ # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -VERSION = "21.1.0" +VERSION = "1.0.0b1" diff --git a/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/policy/v2017_06_01_preview/aio/__init__.py b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/policy/v2017_06_01_preview/aio/__init__.py index 2784ce3f14bf5..4622bf1f396a7 100644 --- a/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/policy/v2017_06_01_preview/aio/__init__.py +++ b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/policy/v2017_06_01_preview/aio/__init__.py @@ -7,9 +7,15 @@ # -------------------------------------------------------------------------- from ._policy_client import PolicyClient -__all__ = ['PolicyClient'] -# `._patch.py` is used for handwritten extensions to the generated code -# Example: https://github.com/Azure/azure-sdk-for-python/blob/main/doc/dev/customize_code/how-to-patch-sdk-code.md -from ._patch import patch_sdk -patch_sdk() +try: + from ._patch import __all__ as _patch_all + from ._patch import * # type: ignore # pylint: disable=unused-wildcard-import +except ImportError: + _patch_all = [] +from ._patch import patch_sdk as _patch_sdk + +__all__ = ["PolicyClient"] +__all__.extend([p for p in _patch_all if p not in __all__]) + +_patch_sdk() diff --git a/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/policy/v2017_06_01_preview/aio/_configuration.py b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/policy/v2017_06_01_preview/aio/_configuration.py index 21e375a7dd621..c52b0ba98ee82 100644 --- a/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/policy/v2017_06_01_preview/aio/_configuration.py +++ b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/policy/v2017_06_01_preview/aio/_configuration.py @@ -25,18 +25,13 @@ class PolicyClientConfiguration(Configuration): # pylint: disable=too-many-inst Note that all parameters used to create this instance are saved as instance attributes. - :param credential: Credential needed for the client to connect to Azure. + :param credential: Credential needed for the client to connect to Azure. Required. :type credential: ~azure.core.credentials_async.AsyncTokenCredential - :param subscription_id: The ID of the target subscription. + :param subscription_id: The ID of the target subscription. Required. :type subscription_id: str """ - def __init__( - self, - credential: "AsyncTokenCredential", - subscription_id: str, - **kwargs: Any - ) -> None: + def __init__(self, credential: "AsyncTokenCredential", subscription_id: str, **kwargs: Any) -> None: super(PolicyClientConfiguration, self).__init__(**kwargs) if credential is None: raise ValueError("Parameter 'credential' must not be None.") @@ -45,22 +40,21 @@ def __init__( self.credential = credential self.subscription_id = subscription_id - self.credential_scopes = kwargs.pop('credential_scopes', ['https://management.azure.com/.default']) - kwargs.setdefault('sdk_moniker', 'mgmt-resource/{}'.format(VERSION)) + self.credential_scopes = kwargs.pop("credential_scopes", ["https://management.azure.com/.default"]) + kwargs.setdefault("sdk_moniker", "mgmt-resource/{}".format(VERSION)) self._configure(**kwargs) - 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) - self.logging_policy = kwargs.get('logging_policy') or policies.NetworkTraceLoggingPolicy(**kwargs) - self.http_logging_policy = kwargs.get('http_logging_policy') or ARMHttpLoggingPolicy(**kwargs) - self.retry_policy = kwargs.get('retry_policy') or policies.AsyncRetryPolicy(**kwargs) - self.custom_hook_policy = kwargs.get('custom_hook_policy') or policies.CustomHookPolicy(**kwargs) - self.redirect_policy = kwargs.get('redirect_policy') or policies.AsyncRedirectPolicy(**kwargs) - self.authentication_policy = kwargs.get('authentication_policy') + 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) + self.logging_policy = kwargs.get("logging_policy") or policies.NetworkTraceLoggingPolicy(**kwargs) + self.http_logging_policy = kwargs.get("http_logging_policy") or ARMHttpLoggingPolicy(**kwargs) + self.retry_policy = kwargs.get("retry_policy") or policies.AsyncRetryPolicy(**kwargs) + self.custom_hook_policy = kwargs.get("custom_hook_policy") or policies.CustomHookPolicy(**kwargs) + self.redirect_policy = kwargs.get("redirect_policy") or policies.AsyncRedirectPolicy(**kwargs) + self.authentication_policy = kwargs.get("authentication_policy") if self.credential and not self.authentication_policy: - self.authentication_policy = AsyncARMChallengeAuthenticationPolicy(self.credential, *self.credential_scopes, **kwargs) + self.authentication_policy = AsyncARMChallengeAuthenticationPolicy( + self.credential, *self.credential_scopes, **kwargs + ) diff --git a/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/policy/v2017_06_01_preview/aio/_patch.py b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/policy/v2017_06_01_preview/aio/_patch.py index 74e48ecd07cf3..f99e77fef9861 100644 --- a/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/policy/v2017_06_01_preview/aio/_patch.py +++ b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/policy/v2017_06_01_preview/aio/_patch.py @@ -28,4 +28,4 @@ # This file is used for handwritten extensions to the generated code. Example: # https://github.com/Azure/azure-sdk-for-python/blob/main/doc/dev/customize_code/how-to-patch-sdk-code.md def patch_sdk(): - pass \ No newline at end of file + pass diff --git a/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/policy/v2017_06_01_preview/aio/_policy_client.py b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/policy/v2017_06_01_preview/aio/_policy_client.py index b03f346a523e4..4a28ada0f7984 100644 --- a/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/policy/v2017_06_01_preview/aio/_policy_client.py +++ b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/policy/v2017_06_01_preview/aio/_policy_client.py @@ -9,12 +9,11 @@ from copy import deepcopy from typing import Any, Awaitable, TYPE_CHECKING -from msrest import Deserializer, Serializer - from azure.core.rest import AsyncHttpResponse, HttpRequest from azure.mgmt.core import AsyncARMPipelineClient from .. import models +from ..._serialization import Deserializer, Serializer from ._configuration import PolicyClientConfiguration from .operations import PolicyAssignmentsOperations, PolicyDefinitionsOperations, PolicySetDefinitionsOperations @@ -22,7 +21,8 @@ # pylint: disable=unused-import,ungrouped-imports from azure.core.credentials_async import AsyncTokenCredential -class PolicyClient: + +class PolicyClient: # pylint: disable=client-accepts-api-version-keyword """To manage and control access to your resources, you can define customized policies and assign them at a scope. @@ -35,9 +35,9 @@ class PolicyClient: :ivar policy_definitions: PolicyDefinitionsOperations operations :vartype policy_definitions: azure.mgmt.resource.policy.v2017_06_01_preview.aio.operations.PolicyDefinitionsOperations - :param credential: Credential needed for the client to connect to Azure. + :param credential: Credential needed for the client to connect to Azure. Required. :type credential: ~azure.core.credentials_async.AsyncTokenCredential - :param subscription_id: The ID of the target subscription. + :param subscription_id: The ID of the target subscription. Required. :type subscription_id: str :param base_url: Service URL. Default value is "https://management.azure.com". :type base_url: str @@ -57,16 +57,17 @@ def __init__( self._serialize = Serializer(client_models) self._deserialize = Deserializer(client_models) self._serialize.client_side_validation = False - self.policy_assignments = PolicyAssignmentsOperations(self._client, self._config, self._serialize, self._deserialize) - self.policy_set_definitions = PolicySetDefinitionsOperations(self._client, self._config, self._serialize, self._deserialize) - self.policy_definitions = PolicyDefinitionsOperations(self._client, self._config, self._serialize, self._deserialize) - - - def _send_request( - self, - request: HttpRequest, - **kwargs: Any - ) -> Awaitable[AsyncHttpResponse]: + self.policy_assignments = PolicyAssignmentsOperations( + self._client, self._config, self._serialize, self._deserialize + ) + self.policy_set_definitions = PolicySetDefinitionsOperations( + self._client, self._config, self._serialize, self._deserialize + ) + self.policy_definitions = PolicyDefinitionsOperations( + self._client, self._config, self._serialize, self._deserialize + ) + + def _send_request(self, request: HttpRequest, **kwargs: Any) -> Awaitable[AsyncHttpResponse]: """Runs the network request through the client's chained policies. >>> from azure.core.rest import HttpRequest @@ -75,7 +76,7 @@ def _send_request( >>> response = await client._send_request(request) - For more information on this code flow, see https://aka.ms/azsdk/python/protocol/quickstart + For more information on this code flow, see https://aka.ms/azsdk/dpcodegen/python/send_request :param request: The network request you want to make. Required. :type request: ~azure.core.rest.HttpRequest diff --git a/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/policy/v2017_06_01_preview/aio/operations/__init__.py b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/policy/v2017_06_01_preview/aio/operations/__init__.py index e7579dcbdfe86..5b62ee07afa98 100644 --- a/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/policy/v2017_06_01_preview/aio/operations/__init__.py +++ b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/policy/v2017_06_01_preview/aio/operations/__init__.py @@ -10,8 +10,14 @@ from ._operations import PolicySetDefinitionsOperations from ._operations import PolicyDefinitionsOperations +from ._patch import __all__ as _patch_all +from ._patch import * # type: ignore # pylint: disable=unused-wildcard-import +from ._patch import patch_sdk as _patch_sdk + __all__ = [ - 'PolicyAssignmentsOperations', - 'PolicySetDefinitionsOperations', - 'PolicyDefinitionsOperations', + "PolicyAssignmentsOperations", + "PolicySetDefinitionsOperations", + "PolicyDefinitionsOperations", ] +__all__.extend([p for p in _patch_all if p not in __all__]) +_patch_sdk() diff --git a/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/policy/v2017_06_01_preview/aio/operations/_operations.py b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/policy/v2017_06_01_preview/aio/operations/_operations.py index eb8a96014266c..9ebf48e25a82a 100644 --- a/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/policy/v2017_06_01_preview/aio/operations/_operations.py +++ b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/policy/v2017_06_01_preview/aio/operations/_operations.py @@ -6,89 +6,126 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -from typing import Any, AsyncIterable, Callable, Dict, Optional, TypeVar +from typing import Any, AsyncIterable, Callable, Dict, IO, Optional, TypeVar, Union, overload from azure.core.async_paging import AsyncItemPaged, AsyncList -from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error +from azure.core.exceptions import ( + ClientAuthenticationError, + HttpResponseError, + ResourceExistsError, + ResourceNotFoundError, + ResourceNotModifiedError, + map_error, +) from azure.core.pipeline import PipelineResponse from azure.core.pipeline.transport import AsyncHttpResponse from azure.core.rest import HttpRequest from azure.core.tracing.decorator import distributed_trace from azure.core.tracing.decorator_async import distributed_trace_async +from azure.core.utils import case_insensitive_dict from azure.mgmt.core.exceptions import ARMErrorFormat from ... import models as _models from ..._vendor import _convert_request -from ...operations._operations import build_policy_assignments_create_by_id_request, build_policy_assignments_create_request, build_policy_assignments_delete_by_id_request, build_policy_assignments_delete_request, build_policy_assignments_get_by_id_request, build_policy_assignments_get_request, build_policy_assignments_list_for_resource_group_request, build_policy_assignments_list_for_resource_request, build_policy_assignments_list_request, build_policy_definitions_create_or_update_at_management_group_request, build_policy_definitions_create_or_update_request, build_policy_definitions_delete_at_management_group_request, build_policy_definitions_delete_request, build_policy_definitions_get_at_management_group_request, build_policy_definitions_get_built_in_request, build_policy_definitions_get_request, build_policy_definitions_list_built_in_request, build_policy_definitions_list_by_management_group_request, build_policy_definitions_list_request, build_policy_set_definitions_create_or_update_at_management_group_request, build_policy_set_definitions_create_or_update_request, build_policy_set_definitions_delete_at_management_group_request, build_policy_set_definitions_delete_request, build_policy_set_definitions_get_at_management_group_request, build_policy_set_definitions_get_built_in_request, build_policy_set_definitions_get_request, build_policy_set_definitions_list_built_in_request, build_policy_set_definitions_list_by_management_group_request, build_policy_set_definitions_list_request -T = TypeVar('T') +from ...operations._operations import ( + build_policy_assignments_create_by_id_request, + build_policy_assignments_create_request, + build_policy_assignments_delete_by_id_request, + build_policy_assignments_delete_request, + build_policy_assignments_get_by_id_request, + build_policy_assignments_get_request, + build_policy_assignments_list_for_resource_group_request, + build_policy_assignments_list_for_resource_request, + build_policy_assignments_list_request, + build_policy_definitions_create_or_update_at_management_group_request, + build_policy_definitions_create_or_update_request, + build_policy_definitions_delete_at_management_group_request, + build_policy_definitions_delete_request, + build_policy_definitions_get_at_management_group_request, + build_policy_definitions_get_built_in_request, + build_policy_definitions_get_request, + build_policy_definitions_list_built_in_request, + build_policy_definitions_list_by_management_group_request, + build_policy_definitions_list_request, + build_policy_set_definitions_create_or_update_at_management_group_request, + build_policy_set_definitions_create_or_update_request, + build_policy_set_definitions_delete_at_management_group_request, + build_policy_set_definitions_delete_request, + build_policy_set_definitions_get_at_management_group_request, + build_policy_set_definitions_get_built_in_request, + build_policy_set_definitions_get_request, + build_policy_set_definitions_list_built_in_request, + build_policy_set_definitions_list_by_management_group_request, + build_policy_set_definitions_list_request, +) + +T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] -class PolicyAssignmentsOperations: - """PolicyAssignmentsOperations async operations. - You should not instantiate this class directly. Instead, you should create a Client instance that - instantiates it for you and attaches it as an attribute. +class PolicyAssignmentsOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. - :ivar models: Alias to model classes used in this operation group. - :type models: ~azure.mgmt.resource.policy.v2017_06_01_preview.models - :param client: Client for service requests. - :param config: Configuration of service client. - :param serializer: An object model serializer. - :param deserializer: An object model deserializer. + Instead, you should access the following operations through + :class:`~azure.mgmt.resource.policy.v2017_06_01_preview.aio.PolicyClient`'s + :attr:`policy_assignments` attribute. """ models = _models - def __init__(self, client, config, serializer, deserializer) -> None: - self._client = client - self._serialize = serializer - self._deserialize = deserializer - self._config = config + def __init__(self, *args, **kwargs) -> None: + input_args = list(args) + self._client = input_args.pop(0) if input_args else kwargs.pop("client") + self._config = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") @distributed_trace_async async def delete( - self, - scope: str, - policy_assignment_name: str, - **kwargs: Any - ) -> Optional["_models.PolicyAssignment"]: + self, scope: str, policy_assignment_name: str, **kwargs: Any + ) -> Optional[_models.PolicyAssignment]: """Deletes a policy assignment. - :param scope: The scope of the policy assignment. + :param scope: The scope of the policy assignment. Required. :type scope: str - :param policy_assignment_name: The name of the policy assignment to delete. + :param policy_assignment_name: The name of the policy assignment to delete. Required. :type policy_assignment_name: str - :keyword api_version: Api Version. Default value is "2017-06-01-preview". Note that overriding - this default value may result in unsupported behavior. - :paramtype api_version: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: PolicyAssignment, or the result of cls(response) + :return: PolicyAssignment or None or the result of cls(response) :rtype: ~azure.mgmt.resource.policy.v2017_06_01_preview.models.PolicyAssignment or None - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType[Optional["_models.PolicyAssignment"]] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) - api_version = kwargs.pop('api_version', "2017-06-01-preview") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2017-06-01-preview")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[Optional[_models.PolicyAssignment]] - request = build_policy_assignments_delete_request( scope=scope, policy_assignment_name=policy_assignment_name, api_version=api_version, - template_url=self.delete.metadata['url'], + template_url=self.delete.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200, 204]: @@ -98,57 +135,121 @@ async def delete( deserialized = None if response.status_code == 200: - deserialized = self._deserialize('PolicyAssignment', pipeline_response) + deserialized = self._deserialize("PolicyAssignment", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - delete.metadata = {'url': "/{scope}/providers/Microsoft.Authorization/policyAssignments/{policyAssignmentName}"} # type: ignore - + delete.metadata = {"url": "/{scope}/providers/Microsoft.Authorization/policyAssignments/{policyAssignmentName}"} # type: ignore - @distributed_trace_async + @overload async def create( self, scope: str, policy_assignment_name: str, - parameters: "_models.PolicyAssignment", + parameters: _models.PolicyAssignment, *, - content_type: Optional[str] = "application/json", + content_type: str = "application/json", **kwargs: Any - ) -> "_models.PolicyAssignment": + ) -> _models.PolicyAssignment: """Creates a policy assignment. Policy assignments are inherited by child resources. For example, when you apply a policy to a resource group that policy is assigned to all resources in the group. - :param scope: The scope of the policy assignment. + :param scope: The scope of the policy assignment. Required. :type scope: str - :param policy_assignment_name: The name of the policy assignment. + :param policy_assignment_name: The name of the policy assignment. Required. :type policy_assignment_name: str - :param parameters: Parameters for the policy assignment. + :param parameters: Parameters for the policy assignment. Required. :type parameters: ~azure.mgmt.resource.policy.v2017_06_01_preview.models.PolicyAssignment - :keyword content_type: Media type of the body sent to the API. Possible values are: - "application/json" or "text/json". Default value is "application/json". + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". :paramtype content_type: str - :keyword api_version: Api Version. Default value is "2017-06-01-preview". Note that overriding - this default value may result in unsupported behavior. - :paramtype api_version: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: PolicyAssignment, or the result of cls(response) + :return: PolicyAssignment or the result of cls(response) :rtype: ~azure.mgmt.resource.policy.v2017_06_01_preview.models.PolicyAssignment - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + async def create( + self, + scope: str, + policy_assignment_name: str, + parameters: IO, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.PolicyAssignment: + """Creates a policy assignment. + + Policy assignments are inherited by child resources. For example, when you apply a policy to a + resource group that policy is assigned to all resources in the group. + + :param scope: The scope of the policy assignment. Required. + :type scope: str + :param policy_assignment_name: The name of the policy assignment. Required. + :type policy_assignment_name: str + :param parameters: Parameters for the policy assignment. Required. + :type parameters: IO + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Known values are: 'application/json', 'text/json'. Default value is "application/json". + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: PolicyAssignment or the result of cls(response) + :rtype: ~azure.mgmt.resource.policy.v2017_06_01_preview.models.PolicyAssignment + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace_async + async def create( + self, scope: str, policy_assignment_name: str, parameters: Union[_models.PolicyAssignment, IO], **kwargs: Any + ) -> _models.PolicyAssignment: + """Creates a policy assignment. + + Policy assignments are inherited by child resources. For example, when you apply a policy to a + resource group that policy is assigned to all resources in the group. + + :param scope: The scope of the policy assignment. Required. + :type scope: str + :param policy_assignment_name: The name of the policy assignment. Required. + :type policy_assignment_name: str + :param parameters: Parameters for the policy assignment. Is either a model type or a IO type. + Required. + :type parameters: ~azure.mgmt.resource.policy.v2017_06_01_preview.models.PolicyAssignment or IO + :keyword content_type: Body Parameter content-type. Known values are: 'application/json', + 'text/json'. Default value is None. + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: PolicyAssignment or the result of cls(response) + :rtype: ~azure.mgmt.resource.policy.v2017_06_01_preview.models.PolicyAssignment + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.PolicyAssignment"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) - api_version = kwargs.pop('api_version', "2017-06-01-preview") # type: str + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - _json = self._serialize.body(parameters, 'PolicyAssignment') + api_version = kwargs.pop("api_version", _params.pop("api-version", "2017-06-01-preview")) # type: str + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.PolicyAssignment] + + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(parameters, (IO, bytes)): + _content = parameters + else: + _json = self._serialize.body(parameters, "PolicyAssignment") request = build_policy_assignments_create_request( scope=scope, @@ -156,16 +257,18 @@ async def create( api_version=api_version, content_type=content_type, json=_json, - template_url=self.create.metadata['url'], + content=_content, + template_url=self.create.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [201]: @@ -173,60 +276,57 @@ async def create( error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - deserialized = self._deserialize('PolicyAssignment', pipeline_response) + deserialized = self._deserialize("PolicyAssignment", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - create.metadata = {'url': "/{scope}/providers/Microsoft.Authorization/policyAssignments/{policyAssignmentName}"} # type: ignore - + create.metadata = {"url": "/{scope}/providers/Microsoft.Authorization/policyAssignments/{policyAssignmentName}"} # type: ignore @distributed_trace_async - async def get( - self, - scope: str, - policy_assignment_name: str, - **kwargs: Any - ) -> "_models.PolicyAssignment": + async def get(self, scope: str, policy_assignment_name: str, **kwargs: Any) -> _models.PolicyAssignment: """Gets a policy assignment. - :param scope: The scope of the policy assignment. + :param scope: The scope of the policy assignment. Required. :type scope: str - :param policy_assignment_name: The name of the policy assignment to get. + :param policy_assignment_name: The name of the policy assignment to get. Required. :type policy_assignment_name: str - :keyword api_version: Api Version. Default value is "2017-06-01-preview". Note that overriding - this default value may result in unsupported behavior. - :paramtype api_version: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: PolicyAssignment, or the result of cls(response) + :return: PolicyAssignment or the result of cls(response) :rtype: ~azure.mgmt.resource.policy.v2017_06_01_preview.models.PolicyAssignment - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.PolicyAssignment"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + 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', "2017-06-01-preview") # type: str + api_version = kwargs.pop("api_version", _params.pop("api-version", "2017-06-01-preview")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[_models.PolicyAssignment] - request = build_policy_assignments_get_request( scope=scope, policy_assignment_name=policy_assignment_name, api_version=api_version, - template_url=self.get.metadata['url'], + template_url=self.get.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200]: @@ -234,68 +334,65 @@ async def get( error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - deserialized = self._deserialize('PolicyAssignment', pipeline_response) + deserialized = self._deserialize("PolicyAssignment", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - get.metadata = {'url': "/{scope}/providers/Microsoft.Authorization/policyAssignments/{policyAssignmentName}"} # type: ignore - + get.metadata = {"url": "/{scope}/providers/Microsoft.Authorization/policyAssignments/{policyAssignmentName}"} # type: ignore @distributed_trace def list_for_resource_group( - self, - resource_group_name: str, - filter: Optional[str] = None, - **kwargs: Any - ) -> AsyncIterable["_models.PolicyAssignmentListResult"]: + self, resource_group_name: str, filter: Optional[str] = None, **kwargs: Any + ) -> AsyncIterable["_models.PolicyAssignment"]: """Gets policy assignments for the resource group. :param resource_group_name: The name of the resource group that contains policy assignments. + Required. :type resource_group_name: str :param filter: The filter to apply on the operation. Default value is None. :type filter: str - :keyword api_version: Api Version. Default value is "2017-06-01-preview". Note that overriding - this default value may result in unsupported behavior. - :paramtype api_version: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either PolicyAssignmentListResult or the result of - cls(response) + :return: An iterator like instance of either PolicyAssignment or the result of cls(response) :rtype: - ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.resource.policy.v2017_06_01_preview.models.PolicyAssignmentListResult] - :raises: ~azure.core.exceptions.HttpResponseError + ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.resource.policy.v2017_06_01_preview.models.PolicyAssignment] + :raises ~azure.core.exceptions.HttpResponseError: """ - api_version = kwargs.pop('api_version', "2017-06-01-preview") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2017-06-01-preview")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[_models.PolicyAssignmentListResult] - cls = kwargs.pop('cls', None) # type: ClsType["_models.PolicyAssignmentListResult"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) + def prepare_request(next_link=None): if not next_link: - + request = build_policy_assignments_list_for_resource_group_request( resource_group_name=resource_group_name, subscription_id=self._config.subscription_id, - api_version=api_version, filter=filter, - template_url=self.list_for_resource_group.metadata['url'], + api_version=api_version, + template_url=self.list_for_resource_group.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore else: - - request = build_policy_assignments_list_for_resource_group_request( - resource_group_name=resource_group_name, - subscription_id=self._config.subscription_id, - template_url=next_link, - ) + request = HttpRequest("GET", next_link) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore request.method = "GET" return request @@ -309,10 +406,8 @@ async def extract_data(pipeline_response): async def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) response = pipeline_response.http_response @@ -323,11 +418,9 @@ async def get_next(next_link=None): return pipeline_response + return AsyncItemPaged(get_next, extract_data) - return AsyncItemPaged( - get_next, extract_data - ) - list_for_resource_group.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Authorization/policyAssignments"} # type: ignore + list_for_resource_group.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Authorization/policyAssignments"} # type: ignore @distributed_trace def list_for_resource( @@ -339,42 +432,45 @@ def list_for_resource( resource_name: str, filter: Optional[str] = None, **kwargs: Any - ) -> AsyncIterable["_models.PolicyAssignmentListResult"]: + ) -> AsyncIterable["_models.PolicyAssignment"]: """Gets policy assignments for a resource. :param resource_group_name: The name of the resource group containing the resource. The name is - case insensitive. + case insensitive. Required. :type resource_group_name: str - :param resource_provider_namespace: The namespace of the resource provider. + :param resource_provider_namespace: The namespace of the resource provider. Required. :type resource_provider_namespace: str - :param parent_resource_path: The parent resource path. + :param parent_resource_path: The parent resource path. Required. :type parent_resource_path: str - :param resource_type: The resource type. + :param resource_type: The resource type. Required. :type resource_type: str - :param resource_name: The name of the resource with policy assignments. + :param resource_name: The name of the resource with policy assignments. Required. :type resource_name: str :param filter: The filter to apply on the operation. Default value is None. :type filter: str - :keyword api_version: Api Version. Default value is "2017-06-01-preview". Note that overriding - this default value may result in unsupported behavior. - :paramtype api_version: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either PolicyAssignmentListResult or the result of - cls(response) + :return: An iterator like instance of either PolicyAssignment or the result of cls(response) :rtype: - ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.resource.policy.v2017_06_01_preview.models.PolicyAssignmentListResult] - :raises: ~azure.core.exceptions.HttpResponseError + ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.resource.policy.v2017_06_01_preview.models.PolicyAssignment] + :raises ~azure.core.exceptions.HttpResponseError: """ - api_version = kwargs.pop('api_version', "2017-06-01-preview") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2017-06-01-preview")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[_models.PolicyAssignmentListResult] - cls = kwargs.pop('cls', None) # type: ClsType["_models.PolicyAssignmentListResult"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) + def prepare_request(next_link=None): if not next_link: - + request = build_policy_assignments_list_for_resource_request( resource_group_name=resource_group_name, resource_provider_namespace=resource_provider_namespace, @@ -382,26 +478,19 @@ def prepare_request(next_link=None): resource_type=resource_type, resource_name=resource_name, subscription_id=self._config.subscription_id, - api_version=api_version, filter=filter, - template_url=self.list_for_resource.metadata['url'], + api_version=api_version, + template_url=self.list_for_resource.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore else: - - request = build_policy_assignments_list_for_resource_request( - resource_group_name=resource_group_name, - resource_provider_namespace=resource_provider_namespace, - parent_resource_path=parent_resource_path, - resource_type=resource_type, - resource_name=resource_name, - subscription_id=self._config.subscription_id, - template_url=next_link, - ) + request = HttpRequest("GET", next_link) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore request.method = "GET" return request @@ -415,10 +504,8 @@ async def extract_data(pipeline_response): async def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) response = pipeline_response.http_response @@ -429,59 +516,54 @@ async def get_next(next_link=None): return pipeline_response + return AsyncItemPaged(get_next, extract_data) - return AsyncItemPaged( - get_next, extract_data - ) - list_for_resource.metadata = {'url': "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{parentResourcePath}/{resourceType}/{resourceName}/providers/Microsoft.Authorization/policyAssignments"} # type: ignore + list_for_resource.metadata = {"url": "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{parentResourcePath}/{resourceType}/{resourceName}/providers/Microsoft.Authorization/policyAssignments"} # type: ignore @distributed_trace - def list( - self, - filter: Optional[str] = None, - **kwargs: Any - ) -> AsyncIterable["_models.PolicyAssignmentListResult"]: + def list(self, filter: Optional[str] = None, **kwargs: Any) -> AsyncIterable["_models.PolicyAssignment"]: """Gets all the policy assignments for a subscription. :param filter: The filter to apply on the operation. Default value is None. :type filter: str - :keyword api_version: Api Version. Default value is "2017-06-01-preview". Note that overriding - this default value may result in unsupported behavior. - :paramtype api_version: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either PolicyAssignmentListResult or the result of - cls(response) + :return: An iterator like instance of either PolicyAssignment or the result of cls(response) :rtype: - ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.resource.policy.v2017_06_01_preview.models.PolicyAssignmentListResult] - :raises: ~azure.core.exceptions.HttpResponseError + ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.resource.policy.v2017_06_01_preview.models.PolicyAssignment] + :raises ~azure.core.exceptions.HttpResponseError: """ - api_version = kwargs.pop('api_version', "2017-06-01-preview") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2017-06-01-preview")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[_models.PolicyAssignmentListResult] - cls = kwargs.pop('cls', None) # type: ClsType["_models.PolicyAssignmentListResult"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) + def prepare_request(next_link=None): if not next_link: - + request = build_policy_assignments_list_request( subscription_id=self._config.subscription_id, - api_version=api_version, filter=filter, - template_url=self.list.metadata['url'], + 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.url = self._client.format_url(request.url) # type: ignore else: - - request = build_policy_assignments_list_request( - subscription_id=self._config.subscription_id, - template_url=next_link, - ) + request = HttpRequest("GET", next_link) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore request.method = "GET" return request @@ -495,10 +577,8 @@ async def extract_data(pipeline_response): async def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) response = pipeline_response.http_response @@ -509,18 +589,12 @@ async def get_next(next_link=None): return pipeline_response + return AsyncItemPaged(get_next, extract_data) - return AsyncItemPaged( - get_next, extract_data - ) - list.metadata = {'url': "/subscriptions/{subscriptionId}/providers/Microsoft.Authorization/policyAssignments"} # type: ignore + list.metadata = {"url": "/subscriptions/{subscriptionId}/providers/Microsoft.Authorization/policyAssignments"} # type: ignore @distributed_trace_async - async def delete_by_id( - self, - policy_assignment_id: str, - **kwargs: Any - ) -> "_models.PolicyAssignment": + async def delete_by_id(self, policy_assignment_id: str, **kwargs: Any) -> _models.PolicyAssignment: """Deletes a policy assignment by ID. When providing a scope for the assignment, use '/subscriptions/{subscription-id}/' for @@ -531,37 +605,41 @@ async def delete_by_id( :param policy_assignment_id: The ID of the policy assignment to delete. Use the format '/{scope}/providers/Microsoft.Authorization/policyAssignments/{policy-assignment-name}'. + Required. :type policy_assignment_id: str - :keyword api_version: Api Version. Default value is "2017-06-01-preview". Note that overriding - this default value may result in unsupported behavior. - :paramtype api_version: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: PolicyAssignment, or the result of cls(response) + :return: PolicyAssignment or the result of cls(response) :rtype: ~azure.mgmt.resource.policy.v2017_06_01_preview.models.PolicyAssignment - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.PolicyAssignment"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + 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', "2017-06-01-preview") # type: str + api_version = kwargs.pop("api_version", _params.pop("api-version", "2017-06-01-preview")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[_models.PolicyAssignment] - request = build_policy_assignments_delete_by_id_request( policy_assignment_id=policy_assignment_id, api_version=api_version, - template_url=self.delete_by_id.metadata['url'], + template_url=self.delete_by_id.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200]: @@ -569,25 +647,24 @@ async def delete_by_id( error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - deserialized = self._deserialize('PolicyAssignment', pipeline_response) + deserialized = self._deserialize("PolicyAssignment", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - delete_by_id.metadata = {'url': "/{policyAssignmentId}"} # type: ignore - + delete_by_id.metadata = {"url": "/{policyAssignmentId}"} # type: ignore - @distributed_trace_async + @overload async def create_by_id( self, policy_assignment_id: str, - parameters: "_models.PolicyAssignment", + parameters: _models.PolicyAssignment, *, - content_type: Optional[str] = "application/json", + content_type: str = "application/json", **kwargs: Any - ) -> "_models.PolicyAssignment": + ) -> _models.PolicyAssignment: """Creates a policy assignment by ID. Policy assignments are inherited by child resources. For example, when you apply a policy to a @@ -600,45 +677,117 @@ async def create_by_id( :param policy_assignment_id: The ID of the policy assignment to create. Use the format '/{scope}/providers/Microsoft.Authorization/policyAssignments/{policy-assignment-name}'. + Required. :type policy_assignment_id: str - :param parameters: Parameters for policy assignment. + :param parameters: Parameters for policy assignment. Required. :type parameters: ~azure.mgmt.resource.policy.v2017_06_01_preview.models.PolicyAssignment - :keyword content_type: Media type of the body sent to the API. Possible values are: - "application/json" or "text/json". Default value is "application/json". + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: PolicyAssignment or the result of cls(response) + :rtype: ~azure.mgmt.resource.policy.v2017_06_01_preview.models.PolicyAssignment + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + async def create_by_id( + self, policy_assignment_id: str, parameters: IO, *, content_type: str = "application/json", **kwargs: Any + ) -> _models.PolicyAssignment: + """Creates a policy assignment by ID. + + Policy assignments are inherited by child resources. For example, when you apply a policy to a + resource group that policy is assigned to all resources in the group. When providing a scope + for the assignment, use '/subscriptions/{subscription-id}/' for subscriptions, + '/subscriptions/{subscription-id}/resourceGroups/{resource-group-name}' for resource groups, + and + '/subscriptions/{subscription-id}/resourceGroups/{resource-group-name}/providers/{resource-provider-namespace}/{resource-type}/{resource-name}' + for resources. + + :param policy_assignment_id: The ID of the policy assignment to create. Use the format + '/{scope}/providers/Microsoft.Authorization/policyAssignments/{policy-assignment-name}'. + Required. + :type policy_assignment_id: str + :param parameters: Parameters for policy assignment. Required. + :type parameters: IO + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Known values are: 'application/json', 'text/json'. Default value is "application/json". + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: PolicyAssignment or the result of cls(response) + :rtype: ~azure.mgmt.resource.policy.v2017_06_01_preview.models.PolicyAssignment + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace_async + async def create_by_id( + self, policy_assignment_id: str, parameters: Union[_models.PolicyAssignment, IO], **kwargs: Any + ) -> _models.PolicyAssignment: + """Creates a policy assignment by ID. + + Policy assignments are inherited by child resources. For example, when you apply a policy to a + resource group that policy is assigned to all resources in the group. When providing a scope + for the assignment, use '/subscriptions/{subscription-id}/' for subscriptions, + '/subscriptions/{subscription-id}/resourceGroups/{resource-group-name}' for resource groups, + and + '/subscriptions/{subscription-id}/resourceGroups/{resource-group-name}/providers/{resource-provider-namespace}/{resource-type}/{resource-name}' + for resources. + + :param policy_assignment_id: The ID of the policy assignment to create. Use the format + '/{scope}/providers/Microsoft.Authorization/policyAssignments/{policy-assignment-name}'. + Required. + :type policy_assignment_id: str + :param parameters: Parameters for policy assignment. Is either a model type or a IO type. + Required. + :type parameters: ~azure.mgmt.resource.policy.v2017_06_01_preview.models.PolicyAssignment or IO + :keyword content_type: Body Parameter content-type. Known values are: 'application/json', + 'text/json'. Default value is None. :paramtype content_type: str - :keyword api_version: Api Version. Default value is "2017-06-01-preview". Note that overriding - this default value may result in unsupported behavior. - :paramtype api_version: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: PolicyAssignment, or the result of cls(response) + :return: PolicyAssignment or the result of cls(response) :rtype: ~azure.mgmt.resource.policy.v2017_06_01_preview.models.PolicyAssignment - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.PolicyAssignment"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) - api_version = kwargs.pop('api_version', "2017-06-01-preview") # type: str + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - _json = self._serialize.body(parameters, 'PolicyAssignment') + api_version = kwargs.pop("api_version", _params.pop("api-version", "2017-06-01-preview")) # type: str + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.PolicyAssignment] + + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(parameters, (IO, bytes)): + _content = parameters + else: + _json = self._serialize.body(parameters, "PolicyAssignment") request = build_policy_assignments_create_by_id_request( policy_assignment_id=policy_assignment_id, api_version=api_version, content_type=content_type, json=_json, - template_url=self.create_by_id.metadata['url'], + content=_content, + template_url=self.create_by_id.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [201]: @@ -646,22 +795,17 @@ async def create_by_id( error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - deserialized = self._deserialize('PolicyAssignment', pipeline_response) + deserialized = self._deserialize("PolicyAssignment", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - create_by_id.metadata = {'url': "/{policyAssignmentId}"} # type: ignore - + create_by_id.metadata = {"url": "/{policyAssignmentId}"} # type: ignore @distributed_trace_async - async def get_by_id( - self, - policy_assignment_id: str, - **kwargs: Any - ) -> "_models.PolicyAssignment": + async def get_by_id(self, policy_assignment_id: str, **kwargs: Any) -> _models.PolicyAssignment: """Gets a policy assignment by ID. When providing a scope for the assignment, use '/subscriptions/{subscription-id}/' for @@ -672,37 +816,41 @@ async def get_by_id( :param policy_assignment_id: The ID of the policy assignment to get. Use the format '/{scope}/providers/Microsoft.Authorization/policyAssignments/{policy-assignment-name}'. + Required. :type policy_assignment_id: str - :keyword api_version: Api Version. Default value is "2017-06-01-preview". Note that overriding - this default value may result in unsupported behavior. - :paramtype api_version: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: PolicyAssignment, or the result of cls(response) + :return: PolicyAssignment or the result of cls(response) :rtype: ~azure.mgmt.resource.policy.v2017_06_01_preview.models.PolicyAssignment - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.PolicyAssignment"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) - api_version = kwargs.pop('api_version', "2017-06-01-preview") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2017-06-01-preview")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[_models.PolicyAssignment] - request = build_policy_assignments_get_by_id_request( policy_assignment_id=policy_assignment_id, api_version=api_version, - template_url=self.get_by_id.metadata['url'], + template_url=self.get_by_id.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200]: @@ -710,72 +858,120 @@ async def get_by_id( error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - deserialized = self._deserialize('PolicyAssignment', pipeline_response) + deserialized = self._deserialize("PolicyAssignment", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - get_by_id.metadata = {'url': "/{policyAssignmentId}"} # type: ignore + get_by_id.metadata = {"url": "/{policyAssignmentId}"} # type: ignore -class PolicySetDefinitionsOperations: - """PolicySetDefinitionsOperations async operations. - You should not instantiate this class directly. Instead, you should create a Client instance that - instantiates it for you and attaches it as an attribute. +class PolicySetDefinitionsOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. - :ivar models: Alias to model classes used in this operation group. - :type models: ~azure.mgmt.resource.policy.v2017_06_01_preview.models - :param client: Client for service requests. - :param config: Configuration of service client. - :param serializer: An object model serializer. - :param deserializer: An object model deserializer. + Instead, you should access the following operations through + :class:`~azure.mgmt.resource.policy.v2017_06_01_preview.aio.PolicyClient`'s + :attr:`policy_set_definitions` attribute. """ models = _models - def __init__(self, client, config, serializer, deserializer) -> None: - self._client = client - self._serialize = serializer - self._deserialize = deserializer - self._config = config + def __init__(self, *args, **kwargs) -> None: + input_args = list(args) + self._client = input_args.pop(0) if input_args else kwargs.pop("client") + self._config = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") - @distributed_trace_async + @overload async def create_or_update( self, policy_set_definition_name: str, - parameters: "_models.PolicySetDefinition", + parameters: _models.PolicySetDefinition, *, - content_type: Optional[str] = "application/json", + content_type: str = "application/json", **kwargs: Any - ) -> "_models.PolicySetDefinition": + ) -> _models.PolicySetDefinition: """Creates or updates a policy set definition. - :param policy_set_definition_name: The name of the policy set definition to create. + :param policy_set_definition_name: The name of the policy set definition to create. Required. :type policy_set_definition_name: str - :param parameters: The policy set definition properties. + :param parameters: The policy set definition properties. Required. :type parameters: ~azure.mgmt.resource.policy.v2017_06_01_preview.models.PolicySetDefinition - :keyword content_type: Media type of the body sent to the API. Possible values are: - "application/json" or "text/json". Default value is "application/json". + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: PolicySetDefinition or the result of cls(response) + :rtype: ~azure.mgmt.resource.policy.v2017_06_01_preview.models.PolicySetDefinition + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + async def create_or_update( + self, policy_set_definition_name: str, parameters: IO, *, content_type: str = "application/json", **kwargs: Any + ) -> _models.PolicySetDefinition: + """Creates or updates a policy set definition. + + :param policy_set_definition_name: The name of the policy set definition to create. Required. + :type policy_set_definition_name: str + :param parameters: The policy set definition properties. Required. + :type parameters: IO + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Known values are: 'application/json', 'text/json'. Default value is "application/json". + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: PolicySetDefinition or the result of cls(response) + :rtype: ~azure.mgmt.resource.policy.v2017_06_01_preview.models.PolicySetDefinition + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace_async + async def create_or_update( + self, policy_set_definition_name: str, parameters: Union[_models.PolicySetDefinition, IO], **kwargs: Any + ) -> _models.PolicySetDefinition: + """Creates or updates a policy set definition. + + :param policy_set_definition_name: The name of the policy set definition to create. Required. + :type policy_set_definition_name: str + :param parameters: The policy set definition properties. Is either a model type or a IO type. + Required. + :type parameters: ~azure.mgmt.resource.policy.v2017_06_01_preview.models.PolicySetDefinition or + IO + :keyword content_type: Body Parameter content-type. Known values are: 'application/json', + 'text/json'. Default value is None. :paramtype content_type: str - :keyword api_version: Api Version. Default value is "2017-06-01-preview". Note that overriding - this default value may result in unsupported behavior. - :paramtype api_version: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: PolicySetDefinition, or the result of cls(response) + :return: PolicySetDefinition or the result of cls(response) :rtype: ~azure.mgmt.resource.policy.v2017_06_01_preview.models.PolicySetDefinition - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.PolicySetDefinition"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', "2017-06-01-preview") # type: str + api_version = kwargs.pop("api_version", _params.pop("api-version", "2017-06-01-preview")) # type: str + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.PolicySetDefinition] - _json = self._serialize.body(parameters, 'PolicySetDefinition') + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(parameters, (IO, bytes)): + _content = parameters + else: + _json = self._serialize.body(parameters, "PolicySetDefinition") request = build_policy_set_definitions_create_or_update_request( policy_set_definition_name=policy_set_definition_name, @@ -783,16 +979,18 @@ async def create_or_update( api_version=api_version, content_type=content_type, json=_json, - template_url=self.create_or_update.metadata['url'], + content=_content, + template_url=self.create_or_update.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200, 201]: @@ -801,60 +999,60 @@ async def create_or_update( raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) if response.status_code == 200: - deserialized = self._deserialize('PolicySetDefinition', pipeline_response) + deserialized = self._deserialize("PolicySetDefinition", pipeline_response) if response.status_code == 201: - deserialized = self._deserialize('PolicySetDefinition', pipeline_response) + deserialized = self._deserialize("PolicySetDefinition", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - create_or_update.metadata = {'url': "/subscriptions/{subscriptionId}/providers/Microsoft.Authorization/policySetDefinitions/{policySetDefinitionName}"} # type: ignore - + create_or_update.metadata = {"url": "/subscriptions/{subscriptionId}/providers/Microsoft.Authorization/policySetDefinitions/{policySetDefinitionName}"} # type: ignore @distributed_trace_async async def delete( # pylint: disable=inconsistent-return-statements - self, - policy_set_definition_name: str, - **kwargs: Any + self, policy_set_definition_name: str, **kwargs: Any ) -> None: """Deletes a policy set definition. - :param policy_set_definition_name: The name of the policy set definition to delete. + :param policy_set_definition_name: The name of the policy set definition to delete. Required. :type policy_set_definition_name: str - :keyword api_version: Api Version. Default value is "2017-06-01-preview". Note that overriding - this default value may result in unsupported behavior. - :paramtype api_version: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: None, or the result of cls(response) + :return: None or the result of cls(response) :rtype: None - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType[None] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + 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', "2017-06-01-preview") # type: str + api_version = kwargs.pop("api_version", _params.pop("api-version", "2017-06-01-preview")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[None] - request = build_policy_set_definitions_delete_request( policy_set_definition_name=policy_set_definition_name, subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.delete.metadata['url'], + template_url=self.delete.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200, 204]: @@ -865,50 +1063,48 @@ async def delete( # pylint: disable=inconsistent-return-statements if cls: return cls(pipeline_response, None, {}) - delete.metadata = {'url': "/subscriptions/{subscriptionId}/providers/Microsoft.Authorization/policySetDefinitions/{policySetDefinitionName}"} # type: ignore - + delete.metadata = {"url": "/subscriptions/{subscriptionId}/providers/Microsoft.Authorization/policySetDefinitions/{policySetDefinitionName}"} # type: ignore @distributed_trace_async - async def get( - self, - policy_set_definition_name: str, - **kwargs: Any - ) -> "_models.PolicySetDefinition": + async def get(self, policy_set_definition_name: str, **kwargs: Any) -> _models.PolicySetDefinition: """Gets the policy set definition. - :param policy_set_definition_name: The name of the policy set definition to get. + :param policy_set_definition_name: The name of the policy set definition to get. Required. :type policy_set_definition_name: str - :keyword api_version: Api Version. Default value is "2017-06-01-preview". Note that overriding - this default value may result in unsupported behavior. - :paramtype api_version: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: PolicySetDefinition, or the result of cls(response) + :return: PolicySetDefinition or the result of cls(response) :rtype: ~azure.mgmt.resource.policy.v2017_06_01_preview.models.PolicySetDefinition - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.PolicySetDefinition"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + 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', "2017-06-01-preview") # type: str + api_version = kwargs.pop("api_version", _params.pop("api-version", "2017-06-01-preview")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[_models.PolicySetDefinition] - request = build_policy_set_definitions_get_request( policy_set_definition_name=policy_set_definition_name, subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.get.metadata['url'], + template_url=self.get.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200]: @@ -916,56 +1112,54 @@ async def get( error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - deserialized = self._deserialize('PolicySetDefinition', pipeline_response) + deserialized = self._deserialize("PolicySetDefinition", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - get.metadata = {'url': "/subscriptions/{subscriptionId}/providers/Microsoft.Authorization/policySetDefinitions/{policySetDefinitionName}"} # type: ignore - + get.metadata = {"url": "/subscriptions/{subscriptionId}/providers/Microsoft.Authorization/policySetDefinitions/{policySetDefinitionName}"} # type: ignore @distributed_trace_async - async def get_built_in( - self, - policy_set_definition_name: str, - **kwargs: Any - ) -> "_models.PolicySetDefinition": + async def get_built_in(self, policy_set_definition_name: str, **kwargs: Any) -> _models.PolicySetDefinition: """Gets the built in policy set definition. - :param policy_set_definition_name: The name of the policy set definition to get. + :param policy_set_definition_name: The name of the policy set definition to get. Required. :type policy_set_definition_name: str - :keyword api_version: Api Version. Default value is "2017-06-01-preview". Note that overriding - this default value may result in unsupported behavior. - :paramtype api_version: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: PolicySetDefinition, or the result of cls(response) + :return: PolicySetDefinition or the result of cls(response) :rtype: ~azure.mgmt.resource.policy.v2017_06_01_preview.models.PolicySetDefinition - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.PolicySetDefinition"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + 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', "2017-06-01-preview") # type: str + api_version = kwargs.pop("api_version", _params.pop("api-version", "2017-06-01-preview")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[_models.PolicySetDefinition] - request = build_policy_set_definitions_get_built_in_request( policy_set_definition_name=policy_set_definition_name, api_version=api_version, - template_url=self.get_built_in.metadata['url'], + template_url=self.get_built_in.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200]: @@ -973,59 +1167,56 @@ async def get_built_in( error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - deserialized = self._deserialize('PolicySetDefinition', pipeline_response) + deserialized = self._deserialize("PolicySetDefinition", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - get_built_in.metadata = {'url': "/providers/Microsoft.Authorization/policySetDefinitions/{policySetDefinitionName}"} # type: ignore - + get_built_in.metadata = {"url": "/providers/Microsoft.Authorization/policySetDefinitions/{policySetDefinitionName}"} # type: ignore @distributed_trace - def list( - self, - **kwargs: Any - ) -> AsyncIterable["_models.PolicySetDefinitionListResult"]: + def list(self, **kwargs: Any) -> AsyncIterable["_models.PolicySetDefinition"]: """Gets all the policy set definitions for a subscription. - :keyword api_version: Api Version. Default value is "2017-06-01-preview". Note that overriding - this default value may result in unsupported behavior. - :paramtype api_version: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either PolicySetDefinitionListResult or the result of - cls(response) + :return: An iterator like instance of either PolicySetDefinition or the result of cls(response) :rtype: - ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.resource.policy.v2017_06_01_preview.models.PolicySetDefinitionListResult] - :raises: ~azure.core.exceptions.HttpResponseError + ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.resource.policy.v2017_06_01_preview.models.PolicySetDefinition] + :raises ~azure.core.exceptions.HttpResponseError: """ - api_version = kwargs.pop('api_version', "2017-06-01-preview") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2017-06-01-preview")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[_models.PolicySetDefinitionListResult] - cls = kwargs.pop('cls', None) # type: ClsType["_models.PolicySetDefinitionListResult"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) + def prepare_request(next_link=None): if not next_link: - + request = build_policy_set_definitions_list_request( subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.list.metadata['url'], + template_url=self.list.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore else: - - request = build_policy_set_definitions_list_request( - subscription_id=self._config.subscription_id, - template_url=next_link, - ) + request = HttpRequest("GET", next_link) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore request.method = "GET" return request @@ -1039,10 +1230,8 @@ async def extract_data(pipeline_response): async def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) response = pipeline_response.http_response @@ -1053,53 +1242,50 @@ async def get_next(next_link=None): return pipeline_response + return AsyncItemPaged(get_next, extract_data) - return AsyncItemPaged( - get_next, extract_data - ) - list.metadata = {'url': "/subscriptions/{subscriptionId}/providers/Microsoft.Authorization/policySetDefinitions"} # type: ignore + list.metadata = {"url": "/subscriptions/{subscriptionId}/providers/Microsoft.Authorization/policySetDefinitions"} # type: ignore @distributed_trace - def list_built_in( - self, - **kwargs: Any - ) -> AsyncIterable["_models.PolicySetDefinitionListResult"]: + def list_built_in(self, **kwargs: Any) -> AsyncIterable["_models.PolicySetDefinition"]: """Gets all the built in policy set definitions. - :keyword api_version: Api Version. Default value is "2017-06-01-preview". Note that overriding - this default value may result in unsupported behavior. - :paramtype api_version: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either PolicySetDefinitionListResult or the result of - cls(response) + :return: An iterator like instance of either PolicySetDefinition or the result of cls(response) :rtype: - ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.resource.policy.v2017_06_01_preview.models.PolicySetDefinitionListResult] - :raises: ~azure.core.exceptions.HttpResponseError + ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.resource.policy.v2017_06_01_preview.models.PolicySetDefinition] + :raises ~azure.core.exceptions.HttpResponseError: """ - api_version = kwargs.pop('api_version', "2017-06-01-preview") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2017-06-01-preview")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[_models.PolicySetDefinitionListResult] - cls = kwargs.pop('cls', None) # type: ClsType["_models.PolicySetDefinitionListResult"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) + def prepare_request(next_link=None): if not next_link: - + request = build_policy_set_definitions_list_built_in_request( api_version=api_version, - template_url=self.list_built_in.metadata['url'], + template_url=self.list_built_in.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore else: - - request = build_policy_set_definitions_list_built_in_request( - template_url=next_link, - ) + request = HttpRequest("GET", next_link) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore request.method = "GET" return request @@ -1113,10 +1299,8 @@ async def extract_data(pipeline_response): async def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) response = pipeline_response.http_response @@ -1127,50 +1311,112 @@ async def get_next(next_link=None): return pipeline_response + return AsyncItemPaged(get_next, extract_data) - return AsyncItemPaged( - get_next, extract_data - ) - list_built_in.metadata = {'url': "/providers/Microsoft.Authorization/policySetDefinitions"} # type: ignore + list_built_in.metadata = {"url": "/providers/Microsoft.Authorization/policySetDefinitions"} # type: ignore - @distributed_trace_async + @overload async def create_or_update_at_management_group( self, policy_set_definition_name: str, management_group_id: str, - parameters: "_models.PolicySetDefinition", + parameters: _models.PolicySetDefinition, *, - content_type: Optional[str] = "application/json", + content_type: str = "application/json", **kwargs: Any - ) -> "_models.PolicySetDefinition": + ) -> _models.PolicySetDefinition: """Creates or updates a policy set definition at management group level. - :param policy_set_definition_name: The name of the policy set definition to create. + :param policy_set_definition_name: The name of the policy set definition to create. Required. :type policy_set_definition_name: str - :param management_group_id: The ID of the management group. + :param management_group_id: The ID of the management group. Required. :type management_group_id: str - :param parameters: The policy set definition properties. + :param parameters: The policy set definition properties. Required. :type parameters: ~azure.mgmt.resource.policy.v2017_06_01_preview.models.PolicySetDefinition - :keyword content_type: Media type of the body sent to the API. Possible values are: - "application/json" or "text/json". Default value is "application/json". + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". :paramtype content_type: str - :keyword api_version: Api Version. Default value is "2017-06-01-preview". Note that overriding - this default value may result in unsupported behavior. - :paramtype api_version: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: PolicySetDefinition, or the result of cls(response) + :return: PolicySetDefinition or the result of cls(response) :rtype: ~azure.mgmt.resource.policy.v2017_06_01_preview.models.PolicySetDefinition - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + async def create_or_update_at_management_group( + self, + policy_set_definition_name: str, + management_group_id: str, + parameters: IO, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.PolicySetDefinition: + """Creates or updates a policy set definition at management group level. + + :param policy_set_definition_name: The name of the policy set definition to create. Required. + :type policy_set_definition_name: str + :param management_group_id: The ID of the management group. Required. + :type management_group_id: str + :param parameters: The policy set definition properties. Required. + :type parameters: IO + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Known values are: 'application/json', 'text/json'. Default value is "application/json". + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: PolicySetDefinition or the result of cls(response) + :rtype: ~azure.mgmt.resource.policy.v2017_06_01_preview.models.PolicySetDefinition + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace_async + async def create_or_update_at_management_group( + self, + policy_set_definition_name: str, + management_group_id: str, + parameters: Union[_models.PolicySetDefinition, IO], + **kwargs: Any + ) -> _models.PolicySetDefinition: + """Creates or updates a policy set definition at management group level. + + :param policy_set_definition_name: The name of the policy set definition to create. Required. + :type policy_set_definition_name: str + :param management_group_id: The ID of the management group. Required. + :type management_group_id: str + :param parameters: The policy set definition properties. Is either a model type or a IO type. + Required. + :type parameters: ~azure.mgmt.resource.policy.v2017_06_01_preview.models.PolicySetDefinition or + IO + :keyword content_type: Body Parameter content-type. Known values are: 'application/json', + 'text/json'. Default value is None. + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: PolicySetDefinition or the result of cls(response) + :rtype: ~azure.mgmt.resource.policy.v2017_06_01_preview.models.PolicySetDefinition + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.PolicySetDefinition"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) - api_version = kwargs.pop('api_version', "2017-06-01-preview") # type: str + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - _json = self._serialize.body(parameters, 'PolicySetDefinition') + api_version = kwargs.pop("api_version", _params.pop("api-version", "2017-06-01-preview")) # type: str + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.PolicySetDefinition] + + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(parameters, (IO, bytes)): + _content = parameters + else: + _json = self._serialize.body(parameters, "PolicySetDefinition") request = build_policy_set_definitions_create_or_update_at_management_group_request( policy_set_definition_name=policy_set_definition_name, @@ -1178,16 +1424,18 @@ async def create_or_update_at_management_group( api_version=api_version, content_type=content_type, json=_json, - template_url=self.create_or_update_at_management_group.metadata['url'], + content=_content, + template_url=self.create_or_update_at_management_group.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200, 201]: @@ -1196,63 +1444,62 @@ async def create_or_update_at_management_group( raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) if response.status_code == 200: - deserialized = self._deserialize('PolicySetDefinition', pipeline_response) + deserialized = self._deserialize("PolicySetDefinition", pipeline_response) if response.status_code == 201: - deserialized = self._deserialize('PolicySetDefinition', pipeline_response) + deserialized = self._deserialize("PolicySetDefinition", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - create_or_update_at_management_group.metadata = {'url': "/providers/Microsoft.Management/managementgroups/{managementGroupId}/providers/Microsoft.Authorization/policySetDefinitions/{policySetDefinitionName}"} # type: ignore - + create_or_update_at_management_group.metadata = {"url": "/providers/Microsoft.Management/managementgroups/{managementGroupId}/providers/Microsoft.Authorization/policySetDefinitions/{policySetDefinitionName}"} # type: ignore @distributed_trace_async async def delete_at_management_group( # pylint: disable=inconsistent-return-statements - self, - policy_set_definition_name: str, - management_group_id: str, - **kwargs: Any + self, policy_set_definition_name: str, management_group_id: str, **kwargs: Any ) -> None: """Deletes a policy set definition at management group level. - :param policy_set_definition_name: The name of the policy set definition to delete. + :param policy_set_definition_name: The name of the policy set definition to delete. Required. :type policy_set_definition_name: str - :param management_group_id: The ID of the management group. + :param management_group_id: The ID of the management group. Required. :type management_group_id: str - :keyword api_version: Api Version. Default value is "2017-06-01-preview". Note that overriding - this default value may result in unsupported behavior. - :paramtype api_version: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: None, or the result of cls(response) + :return: None or the result of cls(response) :rtype: None - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType[None] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + 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', "2017-06-01-preview") # type: str + api_version = kwargs.pop("api_version", _params.pop("api-version", "2017-06-01-preview")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[None] - request = build_policy_set_definitions_delete_at_management_group_request( policy_set_definition_name=policy_set_definition_name, management_group_id=management_group_id, api_version=api_version, - template_url=self.delete_at_management_group.metadata['url'], + template_url=self.delete_at_management_group.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200, 204]: @@ -1263,53 +1510,52 @@ async def delete_at_management_group( # pylint: disable=inconsistent-return-sta if cls: return cls(pipeline_response, None, {}) - delete_at_management_group.metadata = {'url': "/providers/Microsoft.Management/managementgroups/{managementGroupId}/providers/Microsoft.Authorization/policySetDefinitions/{policySetDefinitionName}"} # type: ignore - + delete_at_management_group.metadata = {"url": "/providers/Microsoft.Management/managementgroups/{managementGroupId}/providers/Microsoft.Authorization/policySetDefinitions/{policySetDefinitionName}"} # type: ignore @distributed_trace_async async def get_at_management_group( - self, - policy_set_definition_name: str, - management_group_id: str, - **kwargs: Any - ) -> "_models.PolicySetDefinition": + self, policy_set_definition_name: str, management_group_id: str, **kwargs: Any + ) -> _models.PolicySetDefinition: """Gets the policy set definition at management group level. - :param policy_set_definition_name: The name of the policy set definition to get. + :param policy_set_definition_name: The name of the policy set definition to get. Required. :type policy_set_definition_name: str - :param management_group_id: The ID of the management group. + :param management_group_id: The ID of the management group. Required. :type management_group_id: str - :keyword api_version: Api Version. Default value is "2017-06-01-preview". Note that overriding - this default value may result in unsupported behavior. - :paramtype api_version: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: PolicySetDefinition, or the result of cls(response) + :return: PolicySetDefinition or the result of cls(response) :rtype: ~azure.mgmt.resource.policy.v2017_06_01_preview.models.PolicySetDefinition - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.PolicySetDefinition"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + 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', "2017-06-01-preview") # type: str + api_version = kwargs.pop("api_version", _params.pop("api-version", "2017-06-01-preview")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[_models.PolicySetDefinition] - request = build_policy_set_definitions_get_at_management_group_request( policy_set_definition_name=policy_set_definition_name, management_group_id=management_group_id, api_version=api_version, - template_url=self.get_at_management_group.metadata['url'], + template_url=self.get_at_management_group.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200]: @@ -1317,62 +1563,60 @@ async def get_at_management_group( error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - deserialized = self._deserialize('PolicySetDefinition', pipeline_response) + deserialized = self._deserialize("PolicySetDefinition", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - get_at_management_group.metadata = {'url': "/providers/Microsoft.Management/managementgroups/{managementGroupId}/providers/Microsoft.Authorization/policySetDefinitions/{policySetDefinitionName}"} # type: ignore - + get_at_management_group.metadata = {"url": "/providers/Microsoft.Management/managementgroups/{managementGroupId}/providers/Microsoft.Authorization/policySetDefinitions/{policySetDefinitionName}"} # type: ignore @distributed_trace def list_by_management_group( - self, - management_group_id: str, - **kwargs: Any - ) -> AsyncIterable["_models.PolicySetDefinitionListResult"]: + self, management_group_id: str, **kwargs: Any + ) -> AsyncIterable["_models.PolicySetDefinition"]: """Gets all the policy set definitions for a subscription at management group. - :param management_group_id: The ID of the management group. + :param management_group_id: The ID of the management group. Required. :type management_group_id: str - :keyword api_version: Api Version. Default value is "2017-06-01-preview". Note that overriding - this default value may result in unsupported behavior. - :paramtype api_version: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either PolicySetDefinitionListResult or the result of - cls(response) + :return: An iterator like instance of either PolicySetDefinition or the result of cls(response) :rtype: - ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.resource.policy.v2017_06_01_preview.models.PolicySetDefinitionListResult] - :raises: ~azure.core.exceptions.HttpResponseError + ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.resource.policy.v2017_06_01_preview.models.PolicySetDefinition] + :raises ~azure.core.exceptions.HttpResponseError: """ - api_version = kwargs.pop('api_version', "2017-06-01-preview") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2017-06-01-preview")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[_models.PolicySetDefinitionListResult] - cls = kwargs.pop('cls', None) # type: ClsType["_models.PolicySetDefinitionListResult"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) + def prepare_request(next_link=None): if not next_link: - + request = build_policy_set_definitions_list_by_management_group_request( management_group_id=management_group_id, api_version=api_version, - template_url=self.list_by_management_group.metadata['url'], + template_url=self.list_by_management_group.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore else: - - request = build_policy_set_definitions_list_by_management_group_request( - management_group_id=management_group_id, - template_url=next_link, - ) + request = HttpRequest("GET", next_link) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore request.method = "GET" return request @@ -1386,10 +1630,8 @@ async def extract_data(pipeline_response): async def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) response = pipeline_response.http_response @@ -1400,68 +1642,114 @@ async def get_next(next_link=None): return pipeline_response + return AsyncItemPaged(get_next, extract_data) + + list_by_management_group.metadata = {"url": "/providers/Microsoft.Management/managementgroups/{managementGroupId}/providers/Microsoft.Authorization/policySetDefinitions"} # type: ignore - return AsyncItemPaged( - get_next, extract_data - ) - list_by_management_group.metadata = {'url': "/providers/Microsoft.Management/managementgroups/{managementGroupId}/providers/Microsoft.Authorization/policySetDefinitions"} # type: ignore -class PolicyDefinitionsOperations: - """PolicyDefinitionsOperations async operations. - You should not instantiate this class directly. Instead, you should create a Client instance that - instantiates it for you and attaches it as an attribute. +class PolicyDefinitionsOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. - :ivar models: Alias to model classes used in this operation group. - :type models: ~azure.mgmt.resource.policy.v2017_06_01_preview.models - :param client: Client for service requests. - :param config: Configuration of service client. - :param serializer: An object model serializer. - :param deserializer: An object model deserializer. + Instead, you should access the following operations through + :class:`~azure.mgmt.resource.policy.v2017_06_01_preview.aio.PolicyClient`'s + :attr:`policy_definitions` attribute. """ models = _models - def __init__(self, client, config, serializer, deserializer) -> None: - self._client = client - self._serialize = serializer - self._deserialize = deserializer - self._config = config + def __init__(self, *args, **kwargs) -> None: + input_args = list(args) + self._client = input_args.pop(0) if input_args else kwargs.pop("client") + self._config = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") - @distributed_trace_async + @overload async def create_or_update( self, policy_definition_name: str, - parameters: "_models.PolicyDefinition", + parameters: _models.PolicyDefinition, *, - content_type: Optional[str] = "application/json", + content_type: str = "application/json", **kwargs: Any - ) -> "_models.PolicyDefinition": + ) -> _models.PolicyDefinition: """Creates or updates a policy definition. - :param policy_definition_name: The name of the policy definition to create. + :param policy_definition_name: The name of the policy definition to create. Required. :type policy_definition_name: str - :param parameters: The policy definition properties. + :param parameters: The policy definition properties. Required. :type parameters: ~azure.mgmt.resource.policy.v2017_06_01_preview.models.PolicyDefinition - :keyword content_type: Media type of the body sent to the API. Possible values are: - "application/json" or "text/json". Default value is "application/json". + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: PolicyDefinition or the result of cls(response) + :rtype: ~azure.mgmt.resource.policy.v2017_06_01_preview.models.PolicyDefinition + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + async def create_or_update( + self, policy_definition_name: str, parameters: IO, *, content_type: str = "application/json", **kwargs: Any + ) -> _models.PolicyDefinition: + """Creates or updates a policy definition. + + :param policy_definition_name: The name of the policy definition to create. Required. + :type policy_definition_name: str + :param parameters: The policy definition properties. Required. + :type parameters: IO + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Known values are: 'application/json', 'text/json'. Default value is "application/json". + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: PolicyDefinition or the result of cls(response) + :rtype: ~azure.mgmt.resource.policy.v2017_06_01_preview.models.PolicyDefinition + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace_async + async def create_or_update( + self, policy_definition_name: str, parameters: Union[_models.PolicyDefinition, IO], **kwargs: Any + ) -> _models.PolicyDefinition: + """Creates or updates a policy definition. + + :param policy_definition_name: The name of the policy definition to create. Required. + :type policy_definition_name: str + :param parameters: The policy definition properties. Is either a model type or a IO type. + Required. + :type parameters: ~azure.mgmt.resource.policy.v2017_06_01_preview.models.PolicyDefinition or IO + :keyword content_type: Body Parameter content-type. Known values are: 'application/json', + 'text/json'. Default value is None. :paramtype content_type: str - :keyword api_version: Api Version. Default value is "2016-12-01". Note that overriding this - default value may result in unsupported behavior. - :paramtype api_version: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: PolicyDefinition, or the result of cls(response) + :return: PolicyDefinition or the result of cls(response) :rtype: ~azure.mgmt.resource.policy.v2017_06_01_preview.models.PolicyDefinition - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.PolicyDefinition"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) - api_version = kwargs.pop('api_version', "2016-12-01") # type: str + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - _json = self._serialize.body(parameters, 'PolicyDefinition') + api_version = kwargs.pop("api_version", _params.pop("api-version", "2016-12-01")) # type: str + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.PolicyDefinition] + + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(parameters, (IO, bytes)): + _content = parameters + else: + _json = self._serialize.body(parameters, "PolicyDefinition") request = build_policy_definitions_create_or_update_request( policy_definition_name=policy_definition_name, @@ -1469,73 +1757,75 @@ async def create_or_update( api_version=api_version, content_type=content_type, json=_json, - template_url=self.create_or_update.metadata['url'], + content=_content, + template_url=self.create_or_update.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [201]: map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) - deserialized = self._deserialize('PolicyDefinition', pipeline_response) + deserialized = self._deserialize("PolicyDefinition", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - create_or_update.metadata = {'url': "/subscriptions/{subscriptionId}/providers/Microsoft.Authorization/policyDefinitions/{policyDefinitionName}"} # type: ignore - + create_or_update.metadata = {"url": "/subscriptions/{subscriptionId}/providers/Microsoft.Authorization/policyDefinitions/{policyDefinitionName}"} # type: ignore @distributed_trace_async async def delete( # pylint: disable=inconsistent-return-statements - self, - policy_definition_name: str, - **kwargs: Any + self, policy_definition_name: str, **kwargs: Any ) -> None: """Deletes a policy definition. - :param policy_definition_name: The name of the policy definition to delete. + :param policy_definition_name: The name of the policy definition to delete. Required. :type policy_definition_name: str - :keyword api_version: Api Version. Default value is "2016-12-01". Note that overriding this - default value may result in unsupported behavior. - :paramtype api_version: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: None, or the result of cls(response) + :return: None or the result of cls(response) :rtype: None - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType[None] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) - api_version = kwargs.pop('api_version', "2016-12-01") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2016-12-01")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[None] - request = build_policy_definitions_delete_request( policy_definition_name=policy_definition_name, subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.delete.metadata['url'], + template_url=self.delete.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200, 204]: @@ -1545,160 +1835,218 @@ async def delete( # pylint: disable=inconsistent-return-statements if cls: return cls(pipeline_response, None, {}) - delete.metadata = {'url': "/subscriptions/{subscriptionId}/providers/Microsoft.Authorization/policyDefinitions/{policyDefinitionName}"} # type: ignore - + delete.metadata = {"url": "/subscriptions/{subscriptionId}/providers/Microsoft.Authorization/policyDefinitions/{policyDefinitionName}"} # type: ignore @distributed_trace_async - async def get( - self, - policy_definition_name: str, - **kwargs: Any - ) -> "_models.PolicyDefinition": + async def get(self, policy_definition_name: str, **kwargs: Any) -> _models.PolicyDefinition: """Gets the policy definition. - :param policy_definition_name: The name of the policy definition to get. + :param policy_definition_name: The name of the policy definition to get. Required. :type policy_definition_name: str - :keyword api_version: Api Version. Default value is "2016-12-01". Note that overriding this - default value may result in unsupported behavior. - :paramtype api_version: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: PolicyDefinition, or the result of cls(response) + :return: PolicyDefinition or the result of cls(response) :rtype: ~azure.mgmt.resource.policy.v2017_06_01_preview.models.PolicyDefinition - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.PolicyDefinition"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) - api_version = kwargs.pop('api_version', "2016-12-01") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2016-12-01")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[_models.PolicyDefinition] - request = build_policy_definitions_get_request( policy_definition_name=policy_definition_name, subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.get.metadata['url'], + template_url=self.get.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) - deserialized = self._deserialize('PolicyDefinition', pipeline_response) + deserialized = self._deserialize("PolicyDefinition", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - get.metadata = {'url': "/subscriptions/{subscriptionId}/providers/Microsoft.Authorization/policyDefinitions/{policyDefinitionName}"} # type: ignore - + get.metadata = {"url": "/subscriptions/{subscriptionId}/providers/Microsoft.Authorization/policyDefinitions/{policyDefinitionName}"} # type: ignore @distributed_trace_async - async def get_built_in( - self, - policy_definition_name: str, - **kwargs: Any - ) -> "_models.PolicyDefinition": + async def get_built_in(self, policy_definition_name: str, **kwargs: Any) -> _models.PolicyDefinition: """Gets the built in policy definition. - :param policy_definition_name: The name of the built in policy definition to get. + :param policy_definition_name: The name of the built in policy definition to get. Required. :type policy_definition_name: str - :keyword api_version: Api Version. Default value is "2016-12-01". Note that overriding this - default value may result in unsupported behavior. - :paramtype api_version: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: PolicyDefinition, or the result of cls(response) + :return: PolicyDefinition or the result of cls(response) :rtype: ~azure.mgmt.resource.policy.v2017_06_01_preview.models.PolicyDefinition - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.PolicyDefinition"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) - api_version = kwargs.pop('api_version', "2016-12-01") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2016-12-01")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[_models.PolicyDefinition] - request = build_policy_definitions_get_built_in_request( policy_definition_name=policy_definition_name, api_version=api_version, - template_url=self.get_built_in.metadata['url'], + template_url=self.get_built_in.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) - deserialized = self._deserialize('PolicyDefinition', pipeline_response) + deserialized = self._deserialize("PolicyDefinition", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - get_built_in.metadata = {'url': "/providers/Microsoft.Authorization/policyDefinitions/{policyDefinitionName}"} # type: ignore - + get_built_in.metadata = {"url": "/providers/Microsoft.Authorization/policyDefinitions/{policyDefinitionName}"} # type: ignore - @distributed_trace_async + @overload async def create_or_update_at_management_group( self, policy_definition_name: str, management_group_id: str, - parameters: "_models.PolicyDefinition", + parameters: _models.PolicyDefinition, *, - content_type: Optional[str] = "application/json", + content_type: str = "application/json", **kwargs: Any - ) -> "_models.PolicyDefinition": + ) -> _models.PolicyDefinition: """Creates or updates a policy definition at management group level. - :param policy_definition_name: The name of the policy definition to create. + :param policy_definition_name: The name of the policy definition to create. Required. :type policy_definition_name: str - :param management_group_id: The ID of the management group. + :param management_group_id: The ID of the management group. Required. :type management_group_id: str - :param parameters: The policy definition properties. + :param parameters: The policy definition properties. Required. :type parameters: ~azure.mgmt.resource.policy.v2017_06_01_preview.models.PolicyDefinition - :keyword content_type: Media type of the body sent to the API. Possible values are: - "application/json" or "text/json". Default value is "application/json". + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: PolicyDefinition or the result of cls(response) + :rtype: ~azure.mgmt.resource.policy.v2017_06_01_preview.models.PolicyDefinition + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + async def create_or_update_at_management_group( + self, + policy_definition_name: str, + management_group_id: str, + parameters: IO, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.PolicyDefinition: + """Creates or updates a policy definition at management group level. + + :param policy_definition_name: The name of the policy definition to create. Required. + :type policy_definition_name: str + :param management_group_id: The ID of the management group. Required. + :type management_group_id: str + :param parameters: The policy definition properties. Required. + :type parameters: IO + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Known values are: 'application/json', 'text/json'. Default value is "application/json". + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: PolicyDefinition or the result of cls(response) + :rtype: ~azure.mgmt.resource.policy.v2017_06_01_preview.models.PolicyDefinition + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace_async + async def create_or_update_at_management_group( + self, + policy_definition_name: str, + management_group_id: str, + parameters: Union[_models.PolicyDefinition, IO], + **kwargs: Any + ) -> _models.PolicyDefinition: + """Creates or updates a policy definition at management group level. + + :param policy_definition_name: The name of the policy definition to create. Required. + :type policy_definition_name: str + :param management_group_id: The ID of the management group. Required. + :type management_group_id: str + :param parameters: The policy definition properties. Is either a model type or a IO type. + Required. + :type parameters: ~azure.mgmt.resource.policy.v2017_06_01_preview.models.PolicyDefinition or IO + :keyword content_type: Body Parameter content-type. Known values are: 'application/json', + 'text/json'. Default value is None. :paramtype content_type: str - :keyword api_version: Api Version. Default value is "2016-12-01". Note that overriding this - default value may result in unsupported behavior. - :paramtype api_version: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: PolicyDefinition, or the result of cls(response) + :return: PolicyDefinition or the result of cls(response) :rtype: ~azure.mgmt.resource.policy.v2017_06_01_preview.models.PolicyDefinition - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.PolicyDefinition"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', "2016-12-01") # type: str + api_version = kwargs.pop("api_version", _params.pop("api-version", "2016-12-01")) # type: str + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.PolicyDefinition] - _json = self._serialize.body(parameters, 'PolicyDefinition') + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(parameters, (IO, bytes)): + _content = parameters + else: + _json = self._serialize.body(parameters, "PolicyDefinition") request = build_policy_definitions_create_or_update_at_management_group_request( policy_definition_name=policy_definition_name, @@ -1706,76 +2054,77 @@ async def create_or_update_at_management_group( api_version=api_version, content_type=content_type, json=_json, - template_url=self.create_or_update_at_management_group.metadata['url'], + content=_content, + template_url=self.create_or_update_at_management_group.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [201]: map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) - deserialized = self._deserialize('PolicyDefinition', pipeline_response) + deserialized = self._deserialize("PolicyDefinition", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - create_or_update_at_management_group.metadata = {'url': "/providers/Microsoft.Management/managementgroups/{managementGroupId}/providers/Microsoft.Authorization/policyDefinitions/{policyDefinitionName}"} # type: ignore - + create_or_update_at_management_group.metadata = {"url": "/providers/Microsoft.Management/managementgroups/{managementGroupId}/providers/Microsoft.Authorization/policyDefinitions/{policyDefinitionName}"} # type: ignore @distributed_trace_async async def delete_at_management_group( # pylint: disable=inconsistent-return-statements - self, - policy_definition_name: str, - management_group_id: str, - **kwargs: Any + self, policy_definition_name: str, management_group_id: str, **kwargs: Any ) -> None: """Deletes a policy definition at management group level. - :param policy_definition_name: The name of the policy definition to delete. + :param policy_definition_name: The name of the policy definition to delete. Required. :type policy_definition_name: str - :param management_group_id: The ID of the management group. + :param management_group_id: The ID of the management group. Required. :type management_group_id: str - :keyword api_version: Api Version. Default value is "2016-12-01". Note that overriding this - default value may result in unsupported behavior. - :paramtype api_version: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: None, or the result of cls(response) + :return: None or the result of cls(response) :rtype: None - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType[None] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + 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', "2016-12-01") # type: str + api_version = kwargs.pop("api_version", _params.pop("api-version", "2016-12-01")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[None] - request = build_policy_definitions_delete_at_management_group_request( policy_definition_name=policy_definition_name, management_group_id=management_group_id, api_version=api_version, - template_url=self.delete_at_management_group.metadata['url'], + template_url=self.delete_at_management_group.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200, 204]: @@ -1785,112 +2134,108 @@ async def delete_at_management_group( # pylint: disable=inconsistent-return-sta if cls: return cls(pipeline_response, None, {}) - delete_at_management_group.metadata = {'url': "/providers/Microsoft.Management/managementgroups/{managementGroupId}/providers/Microsoft.Authorization/policyDefinitions/{policyDefinitionName}"} # type: ignore - + delete_at_management_group.metadata = {"url": "/providers/Microsoft.Management/managementgroups/{managementGroupId}/providers/Microsoft.Authorization/policyDefinitions/{policyDefinitionName}"} # type: ignore @distributed_trace_async async def get_at_management_group( - self, - policy_definition_name: str, - management_group_id: str, - **kwargs: Any - ) -> "_models.PolicyDefinition": + self, policy_definition_name: str, management_group_id: str, **kwargs: Any + ) -> _models.PolicyDefinition: """Gets the policy definition at management group level. - :param policy_definition_name: The name of the policy definition to get. + :param policy_definition_name: The name of the policy definition to get. Required. :type policy_definition_name: str - :param management_group_id: The ID of the management group. + :param management_group_id: The ID of the management group. Required. :type management_group_id: str - :keyword api_version: Api Version. Default value is "2016-12-01". Note that overriding this - default value may result in unsupported behavior. - :paramtype api_version: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: PolicyDefinition, or the result of cls(response) + :return: PolicyDefinition or the result of cls(response) :rtype: ~azure.mgmt.resource.policy.v2017_06_01_preview.models.PolicyDefinition - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.PolicyDefinition"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) - api_version = kwargs.pop('api_version', "2016-12-01") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2016-12-01")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[_models.PolicyDefinition] - request = build_policy_definitions_get_at_management_group_request( policy_definition_name=policy_definition_name, management_group_id=management_group_id, api_version=api_version, - template_url=self.get_at_management_group.metadata['url'], + template_url=self.get_at_management_group.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) - deserialized = self._deserialize('PolicyDefinition', pipeline_response) + deserialized = self._deserialize("PolicyDefinition", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - get_at_management_group.metadata = {'url': "/providers/Microsoft.Management/managementgroups/{managementGroupId}/providers/Microsoft.Authorization/policyDefinitions/{policyDefinitionName}"} # type: ignore - + get_at_management_group.metadata = {"url": "/providers/Microsoft.Management/managementgroups/{managementGroupId}/providers/Microsoft.Authorization/policyDefinitions/{policyDefinitionName}"} # type: ignore @distributed_trace - def list( - self, - **kwargs: Any - ) -> AsyncIterable["_models.PolicyDefinitionListResult"]: + def list(self, **kwargs: Any) -> AsyncIterable["_models.PolicyDefinition"]: """Gets all the policy definitions for a subscription. - :keyword api_version: Api Version. Default value is "2016-12-01". Note that overriding this - default value may result in unsupported behavior. - :paramtype api_version: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either PolicyDefinitionListResult or the result of - cls(response) + :return: An iterator like instance of either PolicyDefinition or the result of cls(response) :rtype: - ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.resource.policy.v2017_06_01_preview.models.PolicyDefinitionListResult] - :raises: ~azure.core.exceptions.HttpResponseError + ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.resource.policy.v2017_06_01_preview.models.PolicyDefinition] + :raises ~azure.core.exceptions.HttpResponseError: """ - api_version = kwargs.pop('api_version', "2016-12-01") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2016-12-01")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[_models.PolicyDefinitionListResult] - cls = kwargs.pop('cls', None) # type: ClsType["_models.PolicyDefinitionListResult"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) + def prepare_request(next_link=None): if not next_link: - + request = build_policy_definitions_list_request( subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.list.metadata['url'], + template_url=self.list.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore else: - - request = build_policy_definitions_list_request( - subscription_id=self._config.subscription_id, - template_url=next_link, - ) + request = HttpRequest("GET", next_link) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore request.method = "GET" return request @@ -1904,10 +2249,8 @@ async def extract_data(pipeline_response): async def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) response = pipeline_response.http_response @@ -1917,53 +2260,50 @@ async def get_next(next_link=None): return pipeline_response + return AsyncItemPaged(get_next, extract_data) - return AsyncItemPaged( - get_next, extract_data - ) - list.metadata = {'url': "/subscriptions/{subscriptionId}/providers/Microsoft.Authorization/policyDefinitions"} # type: ignore + list.metadata = {"url": "/subscriptions/{subscriptionId}/providers/Microsoft.Authorization/policyDefinitions"} # type: ignore @distributed_trace - def list_built_in( - self, - **kwargs: Any - ) -> AsyncIterable["_models.PolicyDefinitionListResult"]: + def list_built_in(self, **kwargs: Any) -> AsyncIterable["_models.PolicyDefinition"]: """Gets all the built in policy definitions. - :keyword api_version: Api Version. Default value is "2016-12-01". Note that overriding this - default value may result in unsupported behavior. - :paramtype api_version: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either PolicyDefinitionListResult or the result of - cls(response) + :return: An iterator like instance of either PolicyDefinition or the result of cls(response) :rtype: - ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.resource.policy.v2017_06_01_preview.models.PolicyDefinitionListResult] - :raises: ~azure.core.exceptions.HttpResponseError + ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.resource.policy.v2017_06_01_preview.models.PolicyDefinition] + :raises ~azure.core.exceptions.HttpResponseError: """ - api_version = kwargs.pop('api_version', "2016-12-01") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2016-12-01")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[_models.PolicyDefinitionListResult] - cls = kwargs.pop('cls', None) # type: ClsType["_models.PolicyDefinitionListResult"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) + def prepare_request(next_link=None): if not next_link: - + request = build_policy_definitions_list_built_in_request( api_version=api_version, - template_url=self.list_built_in.metadata['url'], + template_url=self.list_built_in.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore else: - - request = build_policy_definitions_list_built_in_request( - template_url=next_link, - ) + request = HttpRequest("GET", next_link) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore request.method = "GET" return request @@ -1977,10 +2317,8 @@ async def extract_data(pipeline_response): async def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) response = pipeline_response.http_response @@ -1990,58 +2328,55 @@ async def get_next(next_link=None): return pipeline_response + return AsyncItemPaged(get_next, extract_data) - return AsyncItemPaged( - get_next, extract_data - ) - list_built_in.metadata = {'url': "/providers/Microsoft.Authorization/policyDefinitions"} # type: ignore + list_built_in.metadata = {"url": "/providers/Microsoft.Authorization/policyDefinitions"} # type: ignore @distributed_trace def list_by_management_group( - self, - management_group_id: str, - **kwargs: Any - ) -> AsyncIterable["_models.PolicyDefinitionListResult"]: + self, management_group_id: str, **kwargs: Any + ) -> AsyncIterable["_models.PolicyDefinition"]: """Gets all the policy definitions for a subscription at management group level. - :param management_group_id: The ID of the management group. + :param management_group_id: The ID of the management group. Required. :type management_group_id: str - :keyword api_version: Api Version. Default value is "2016-12-01". Note that overriding this - default value may result in unsupported behavior. - :paramtype api_version: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either PolicyDefinitionListResult or the result of - cls(response) + :return: An iterator like instance of either PolicyDefinition or the result of cls(response) :rtype: - ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.resource.policy.v2017_06_01_preview.models.PolicyDefinitionListResult] - :raises: ~azure.core.exceptions.HttpResponseError + ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.resource.policy.v2017_06_01_preview.models.PolicyDefinition] + :raises ~azure.core.exceptions.HttpResponseError: """ - api_version = kwargs.pop('api_version', "2016-12-01") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2016-12-01")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[_models.PolicyDefinitionListResult] - cls = kwargs.pop('cls', None) # type: ClsType["_models.PolicyDefinitionListResult"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) + def prepare_request(next_link=None): if not next_link: - + request = build_policy_definitions_list_by_management_group_request( management_group_id=management_group_id, api_version=api_version, - template_url=self.list_by_management_group.metadata['url'], + template_url=self.list_by_management_group.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore else: - - request = build_policy_definitions_list_by_management_group_request( - management_group_id=management_group_id, - template_url=next_link, - ) + request = HttpRequest("GET", next_link) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore request.method = "GET" return request @@ -2055,10 +2390,8 @@ async def extract_data(pipeline_response): async def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) response = pipeline_response.http_response @@ -2068,8 +2401,6 @@ async def get_next(next_link=None): return pipeline_response + return AsyncItemPaged(get_next, extract_data) - return AsyncItemPaged( - get_next, extract_data - ) - list_by_management_group.metadata = {'url': "/providers/Microsoft.Management/managementgroups/{managementGroupId}/providers/Microsoft.Authorization/policyDefinitions"} # type: ignore + list_by_management_group.metadata = {"url": "/providers/Microsoft.Management/managementgroups/{managementGroupId}/providers/Microsoft.Authorization/policyDefinitions"} # type: ignore diff --git a/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/policy/v2017_06_01_preview/aio/operations/_patch.py b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/policy/v2017_06_01_preview/aio/operations/_patch.py new file mode 100644 index 0000000000000..f7dd32510333d --- /dev/null +++ b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/policy/v2017_06_01_preview/aio/operations/_patch.py @@ -0,0 +1,20 @@ +# ------------------------------------ +# Copyright (c) Microsoft Corporation. +# Licensed under the MIT License. +# ------------------------------------ +"""Customize generated code here. + +Follow our quickstart for examples: https://aka.ms/azsdk/python/dpcodegen/python/customize +""" +from typing import List + +__all__: List[str] = [] # Add all objects you want publicly available to users at this package level + + +def patch_sdk(): + """Do not remove from this file. + + `patch_sdk` is a last resort escape hatch that allows you to do customizations + you can't accomplish using the techniques described in + https://aka.ms/azsdk/python/dpcodegen/python/customize + """ diff --git a/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/policy/v2017_06_01_preview/models/__init__.py b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/policy/v2017_06_01_preview/models/__init__.py index 79ebbf2e7efdc..1b8c682c598ba 100644 --- a/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/policy/v2017_06_01_preview/models/__init__.py +++ b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/policy/v2017_06_01_preview/models/__init__.py @@ -16,22 +16,24 @@ from ._models_py3 import PolicySetDefinitionListResult from ._models_py3 import PolicySku - -from ._policy_client_enums import ( - PolicyMode, - PolicyType, -) +from ._policy_client_enums import PolicyMode +from ._policy_client_enums import PolicyType +from ._patch import __all__ as _patch_all +from ._patch import * # type: ignore # pylint: disable=unused-wildcard-import +from ._patch import patch_sdk as _patch_sdk __all__ = [ - 'ErrorResponse', - 'PolicyAssignment', - 'PolicyAssignmentListResult', - 'PolicyDefinition', - 'PolicyDefinitionListResult', - 'PolicyDefinitionReference', - 'PolicySetDefinition', - 'PolicySetDefinitionListResult', - 'PolicySku', - 'PolicyMode', - 'PolicyType', + "ErrorResponse", + "PolicyAssignment", + "PolicyAssignmentListResult", + "PolicyDefinition", + "PolicyDefinitionListResult", + "PolicyDefinitionReference", + "PolicySetDefinition", + "PolicySetDefinitionListResult", + "PolicySku", + "PolicyMode", + "PolicyType", ] +__all__.extend([p for p in _patch_all if p not in __all__]) +_patch_sdk() diff --git a/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/policy/v2017_06_01_preview/models/_models_py3.py b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/policy/v2017_06_01_preview/models/_models_py3.py index 010494fc5a6b9..525da4aa3700d 100644 --- a/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/policy/v2017_06_01_preview/models/_models_py3.py +++ b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/policy/v2017_06_01_preview/models/_models_py3.py @@ -1,4 +1,5 @@ # coding=utf-8 +# pylint: disable=too-many-lines # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. # Licensed under the MIT License. See License.txt in the project root for license information. @@ -6,15 +7,22 @@ # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -from typing import Any, List, Optional, Union +import sys +from typing import Any, List, Optional, TYPE_CHECKING, Union -from azure.core.exceptions import HttpResponseError -import msrest.serialization +from ... import _serialization -from ._policy_client_enums import * +if TYPE_CHECKING: + # pylint: disable=unused-import,ungrouped-imports + from .. import models as _models +if sys.version_info >= (3, 9): + from collections.abc import MutableMapping +else: + from typing import MutableMapping # type: ignore # pylint: disable=ungrouped-imports +JSON = MutableMapping[str, Any] # pylint: disable=unsubscriptable-object -class ErrorResponse(msrest.serialization.Model): +class ErrorResponse(_serialization.Model): """Error response indicates ARM is not able to process the incoming request. The reason is provided in the error message. :ivar http_status: Http status code. @@ -26,9 +34,9 @@ class ErrorResponse(msrest.serialization.Model): """ _attribute_map = { - 'http_status': {'key': 'httpStatus', 'type': 'str'}, - 'error_code': {'key': 'errorCode', 'type': 'str'}, - 'error_message': {'key': 'errorMessage', 'type': 'str'}, + "http_status": {"key": "httpStatus", "type": "str"}, + "error_code": {"key": "errorCode", "type": "str"}, + "error_message": {"key": "errorMessage", "type": "str"}, } def __init__( @@ -47,13 +55,13 @@ def __init__( :keyword error_message: Error message indicating why the operation failed. :paramtype error_message: str """ - super(ErrorResponse, self).__init__(**kwargs) + super().__init__(**kwargs) self.http_status = http_status self.error_code = error_code self.error_message = error_message -class PolicyAssignment(msrest.serialization.Model): +class PolicyAssignment(_serialization.Model): # pylint: disable=too-many-instance-attributes """The policy assignment. Variables are only populated by the server, and will be ignored when sending a request. @@ -75,44 +83,44 @@ class PolicyAssignment(msrest.serialization.Model): :ivar not_scopes: The policy's excluded scopes. :vartype not_scopes: list[str] :ivar parameters: Required if a parameter is used in policy rule. - :vartype parameters: any + :vartype parameters: JSON :ivar description: This message will be part of response in case of policy violation. :vartype description: str :ivar metadata: The policy assignment metadata. - :vartype metadata: any + :vartype metadata: JSON """ _validation = { - 'id': {'readonly': True}, - 'type': {'readonly': True}, - 'name': {'readonly': True}, + "id": {"readonly": True}, + "type": {"readonly": True}, + "name": {"readonly": True}, } _attribute_map = { - 'id': {'key': 'id', 'type': 'str'}, - 'type': {'key': 'type', 'type': 'str'}, - 'name': {'key': 'name', 'type': 'str'}, - 'sku': {'key': 'sku', 'type': 'PolicySku'}, - 'display_name': {'key': 'properties.displayName', 'type': 'str'}, - 'policy_definition_id': {'key': 'properties.policyDefinitionId', 'type': 'str'}, - 'scope': {'key': 'properties.scope', 'type': 'str'}, - 'not_scopes': {'key': 'properties.notScopes', 'type': '[str]'}, - 'parameters': {'key': 'properties.parameters', 'type': 'object'}, - 'description': {'key': 'properties.description', 'type': 'str'}, - 'metadata': {'key': 'properties.metadata', 'type': 'object'}, + "id": {"key": "id", "type": "str"}, + "type": {"key": "type", "type": "str"}, + "name": {"key": "name", "type": "str"}, + "sku": {"key": "sku", "type": "PolicySku"}, + "display_name": {"key": "properties.displayName", "type": "str"}, + "policy_definition_id": {"key": "properties.policyDefinitionId", "type": "str"}, + "scope": {"key": "properties.scope", "type": "str"}, + "not_scopes": {"key": "properties.notScopes", "type": "[str]"}, + "parameters": {"key": "properties.parameters", "type": "object"}, + "description": {"key": "properties.description", "type": "str"}, + "metadata": {"key": "properties.metadata", "type": "object"}, } def __init__( self, *, - sku: Optional["PolicySku"] = None, + sku: Optional["_models.PolicySku"] = None, display_name: Optional[str] = None, policy_definition_id: Optional[str] = None, scope: Optional[str] = None, not_scopes: Optional[List[str]] = None, - parameters: Optional[Any] = None, + parameters: Optional[JSON] = None, description: Optional[str] = None, - metadata: Optional[Any] = None, + metadata: Optional[JSON] = None, **kwargs ): """ @@ -127,13 +135,13 @@ def __init__( :keyword not_scopes: The policy's excluded scopes. :paramtype not_scopes: list[str] :keyword parameters: Required if a parameter is used in policy rule. - :paramtype parameters: any + :paramtype parameters: JSON :keyword description: This message will be part of response in case of policy violation. :paramtype description: str :keyword metadata: The policy assignment metadata. - :paramtype metadata: any + :paramtype metadata: JSON """ - super(PolicyAssignment, self).__init__(**kwargs) + super().__init__(**kwargs) self.id = None self.type = None self.name = None @@ -147,7 +155,7 @@ def __init__( self.metadata = metadata -class PolicyAssignmentListResult(msrest.serialization.Model): +class PolicyAssignmentListResult(_serialization.Model): """List of policy assignments. :ivar value: An array of policy assignments. @@ -157,16 +165,12 @@ class PolicyAssignmentListResult(msrest.serialization.Model): """ _attribute_map = { - 'value': {'key': 'value', 'type': '[PolicyAssignment]'}, - 'next_link': {'key': 'nextLink', 'type': 'str'}, + "value": {"key": "value", "type": "[PolicyAssignment]"}, + "next_link": {"key": "nextLink", "type": "str"}, } def __init__( - self, - *, - value: Optional[List["PolicyAssignment"]] = None, - next_link: Optional[str] = None, - **kwargs + self, *, value: Optional[List["_models.PolicyAssignment"]] = None, next_link: Optional[str] = None, **kwargs ): """ :keyword value: An array of policy assignments. @@ -174,12 +178,12 @@ def __init__( :keyword next_link: The URL to use for getting the next set of results. :paramtype next_link: str """ - super(PolicyAssignmentListResult, self).__init__(**kwargs) + super().__init__(**kwargs) self.value = value self.next_link = next_link -class PolicyDefinition(msrest.serialization.Model): +class PolicyDefinition(_serialization.Model): """The policy definition. Variables are only populated by the server, and will be ignored when sending a request. @@ -189,72 +193,72 @@ class PolicyDefinition(msrest.serialization.Model): :ivar name: The name of the policy definition. :vartype name: str :ivar policy_type: The type of policy definition. Possible values are NotSpecified, BuiltIn, - and Custom. Possible values include: "NotSpecified", "BuiltIn", "Custom". + and Custom. Known values are: "NotSpecified", "BuiltIn", and "Custom". :vartype policy_type: str or ~azure.mgmt.resource.policy.v2017_06_01_preview.models.PolicyType :ivar mode: The policy definition mode. Possible values are NotSpecified, Indexed, and All. - Possible values include: "NotSpecified", "Indexed", "All". + Known values are: "NotSpecified", "Indexed", and "All". :vartype mode: str or ~azure.mgmt.resource.policy.v2017_06_01_preview.models.PolicyMode :ivar display_name: The display name of the policy definition. :vartype display_name: str :ivar description: The policy definition description. :vartype description: str :ivar policy_rule: The policy rule. - :vartype policy_rule: any + :vartype policy_rule: JSON :ivar metadata: The policy definition metadata. - :vartype metadata: any + :vartype metadata: JSON :ivar parameters: Required if a parameter is used in policy rule. - :vartype parameters: any + :vartype parameters: JSON """ _validation = { - 'id': {'readonly': True}, - 'name': {'readonly': True}, + "id": {"readonly": True}, + "name": {"readonly": True}, } _attribute_map = { - 'id': {'key': 'id', 'type': 'str'}, - 'name': {'key': 'name', 'type': 'str'}, - 'policy_type': {'key': 'properties.policyType', 'type': 'str'}, - 'mode': {'key': 'properties.mode', 'type': 'str'}, - 'display_name': {'key': 'properties.displayName', 'type': 'str'}, - 'description': {'key': 'properties.description', 'type': 'str'}, - 'policy_rule': {'key': 'properties.policyRule', 'type': 'object'}, - 'metadata': {'key': 'properties.metadata', 'type': 'object'}, - 'parameters': {'key': 'properties.parameters', 'type': 'object'}, + "id": {"key": "id", "type": "str"}, + "name": {"key": "name", "type": "str"}, + "policy_type": {"key": "properties.policyType", "type": "str"}, + "mode": {"key": "properties.mode", "type": "str"}, + "display_name": {"key": "properties.displayName", "type": "str"}, + "description": {"key": "properties.description", "type": "str"}, + "policy_rule": {"key": "properties.policyRule", "type": "object"}, + "metadata": {"key": "properties.metadata", "type": "object"}, + "parameters": {"key": "properties.parameters", "type": "object"}, } def __init__( self, *, - policy_type: Optional[Union[str, "PolicyType"]] = None, - mode: Optional[Union[str, "PolicyMode"]] = None, + policy_type: Optional[Union[str, "_models.PolicyType"]] = None, + mode: Optional[Union[str, "_models.PolicyMode"]] = None, display_name: Optional[str] = None, description: Optional[str] = None, - policy_rule: Optional[Any] = None, - metadata: Optional[Any] = None, - parameters: Optional[Any] = None, + policy_rule: Optional[JSON] = None, + metadata: Optional[JSON] = None, + parameters: Optional[JSON] = None, **kwargs ): """ :keyword policy_type: The type of policy definition. Possible values are NotSpecified, BuiltIn, - and Custom. Possible values include: "NotSpecified", "BuiltIn", "Custom". + and Custom. Known values are: "NotSpecified", "BuiltIn", and "Custom". :paramtype policy_type: str or ~azure.mgmt.resource.policy.v2017_06_01_preview.models.PolicyType :keyword mode: The policy definition mode. Possible values are NotSpecified, Indexed, and All. - Possible values include: "NotSpecified", "Indexed", "All". + Known values are: "NotSpecified", "Indexed", and "All". :paramtype mode: str or ~azure.mgmt.resource.policy.v2017_06_01_preview.models.PolicyMode :keyword display_name: The display name of the policy definition. :paramtype display_name: str :keyword description: The policy definition description. :paramtype description: str :keyword policy_rule: The policy rule. - :paramtype policy_rule: any + :paramtype policy_rule: JSON :keyword metadata: The policy definition metadata. - :paramtype metadata: any + :paramtype metadata: JSON :keyword parameters: Required if a parameter is used in policy rule. - :paramtype parameters: any + :paramtype parameters: JSON """ - super(PolicyDefinition, self).__init__(**kwargs) + super().__init__(**kwargs) self.id = None self.name = None self.policy_type = policy_type @@ -266,7 +270,7 @@ def __init__( self.parameters = parameters -class PolicyDefinitionListResult(msrest.serialization.Model): +class PolicyDefinitionListResult(_serialization.Model): """List of policy definitions. :ivar value: An array of policy definitions. @@ -276,16 +280,12 @@ class PolicyDefinitionListResult(msrest.serialization.Model): """ _attribute_map = { - 'value': {'key': 'value', 'type': '[PolicyDefinition]'}, - 'next_link': {'key': 'nextLink', 'type': 'str'}, + "value": {"key": "value", "type": "[PolicyDefinition]"}, + "next_link": {"key": "nextLink", "type": "str"}, } def __init__( - self, - *, - value: Optional[List["PolicyDefinition"]] = None, - next_link: Optional[str] = None, - **kwargs + self, *, value: Optional[List["_models.PolicyDefinition"]] = None, next_link: Optional[str] = None, **kwargs ): """ :keyword value: An array of policy definitions. @@ -293,44 +293,38 @@ def __init__( :keyword next_link: The URL to use for getting the next set of results. :paramtype next_link: str """ - super(PolicyDefinitionListResult, self).__init__(**kwargs) + super().__init__(**kwargs) self.value = value self.next_link = next_link -class PolicyDefinitionReference(msrest.serialization.Model): +class PolicyDefinitionReference(_serialization.Model): """The policy definition reference. :ivar policy_definition_id: The ID of the policy definition or policy set definition. :vartype policy_definition_id: str :ivar parameters: Required if a parameter is used in policy rule. - :vartype parameters: any + :vartype parameters: JSON """ _attribute_map = { - 'policy_definition_id': {'key': 'policyDefinitionId', 'type': 'str'}, - 'parameters': {'key': 'parameters', 'type': 'object'}, + "policy_definition_id": {"key": "policyDefinitionId", "type": "str"}, + "parameters": {"key": "parameters", "type": "object"}, } - def __init__( - self, - *, - policy_definition_id: Optional[str] = None, - parameters: Optional[Any] = None, - **kwargs - ): + def __init__(self, *, policy_definition_id: Optional[str] = None, parameters: Optional[JSON] = None, **kwargs): """ :keyword policy_definition_id: The ID of the policy definition or policy set definition. :paramtype policy_definition_id: str :keyword parameters: Required if a parameter is used in policy rule. - :paramtype parameters: any + :paramtype parameters: JSON """ - super(PolicyDefinitionReference, self).__init__(**kwargs) + super().__init__(**kwargs) self.policy_definition_id = policy_definition_id self.parameters = parameters -class PolicySetDefinition(msrest.serialization.Model): +class PolicySetDefinition(_serialization.Model): """The policy set definition. Variables are only populated by the server, and will be ignored when sending a request. @@ -342,54 +336,54 @@ class PolicySetDefinition(msrest.serialization.Model): :ivar type: The type of the resource (Microsoft.Authorization/policySetDefinitions). :vartype type: str :ivar policy_type: The type of policy definition. Possible values are NotSpecified, BuiltIn, - and Custom. Possible values include: "NotSpecified", "BuiltIn", "Custom". + and Custom. Known values are: "NotSpecified", "BuiltIn", and "Custom". :vartype policy_type: str or ~azure.mgmt.resource.policy.v2017_06_01_preview.models.PolicyType :ivar display_name: The display name of the policy set definition. :vartype display_name: str :ivar description: The policy set definition description. :vartype description: str :ivar metadata: The policy set definition metadata. - :vartype metadata: any + :vartype metadata: JSON :ivar parameters: The policy set definition parameters that can be used in policy definition references. - :vartype parameters: any + :vartype parameters: JSON :ivar policy_definitions: An array of policy definition references. :vartype policy_definitions: list[~azure.mgmt.resource.policy.v2017_06_01_preview.models.PolicyDefinitionReference] """ _validation = { - 'id': {'readonly': True}, - 'name': {'readonly': True}, - 'type': {'readonly': True}, + "id": {"readonly": True}, + "name": {"readonly": True}, + "type": {"readonly": True}, } _attribute_map = { - 'id': {'key': 'id', 'type': 'str'}, - 'name': {'key': 'name', 'type': 'str'}, - 'type': {'key': 'type', 'type': 'str'}, - 'policy_type': {'key': 'properties.policyType', 'type': 'str'}, - 'display_name': {'key': 'properties.displayName', 'type': 'str'}, - 'description': {'key': 'properties.description', 'type': 'str'}, - 'metadata': {'key': 'properties.metadata', 'type': 'object'}, - 'parameters': {'key': 'properties.parameters', 'type': 'object'}, - 'policy_definitions': {'key': 'properties.policyDefinitions', 'type': '[PolicyDefinitionReference]'}, + "id": {"key": "id", "type": "str"}, + "name": {"key": "name", "type": "str"}, + "type": {"key": "type", "type": "str"}, + "policy_type": {"key": "properties.policyType", "type": "str"}, + "display_name": {"key": "properties.displayName", "type": "str"}, + "description": {"key": "properties.description", "type": "str"}, + "metadata": {"key": "properties.metadata", "type": "object"}, + "parameters": {"key": "properties.parameters", "type": "object"}, + "policy_definitions": {"key": "properties.policyDefinitions", "type": "[PolicyDefinitionReference]"}, } def __init__( self, *, - policy_type: Optional[Union[str, "PolicyType"]] = None, + policy_type: Optional[Union[str, "_models.PolicyType"]] = None, display_name: Optional[str] = None, description: Optional[str] = None, - metadata: Optional[Any] = None, - parameters: Optional[Any] = None, - policy_definitions: Optional[List["PolicyDefinitionReference"]] = None, + metadata: Optional[JSON] = None, + parameters: Optional[JSON] = None, + policy_definitions: Optional[List["_models.PolicyDefinitionReference"]] = None, **kwargs ): """ :keyword policy_type: The type of policy definition. Possible values are NotSpecified, BuiltIn, - and Custom. Possible values include: "NotSpecified", "BuiltIn", "Custom". + and Custom. Known values are: "NotSpecified", "BuiltIn", and "Custom". :paramtype policy_type: str or ~azure.mgmt.resource.policy.v2017_06_01_preview.models.PolicyType :keyword display_name: The display name of the policy set definition. @@ -397,15 +391,15 @@ def __init__( :keyword description: The policy set definition description. :paramtype description: str :keyword metadata: The policy set definition metadata. - :paramtype metadata: any + :paramtype metadata: JSON :keyword parameters: The policy set definition parameters that can be used in policy definition references. - :paramtype parameters: any + :paramtype parameters: JSON :keyword policy_definitions: An array of policy definition references. :paramtype policy_definitions: list[~azure.mgmt.resource.policy.v2017_06_01_preview.models.PolicyDefinitionReference] """ - super(PolicySetDefinition, self).__init__(**kwargs) + super().__init__(**kwargs) self.id = None self.name = None self.type = None @@ -417,7 +411,7 @@ def __init__( self.policy_definitions = policy_definitions -class PolicySetDefinitionListResult(msrest.serialization.Model): +class PolicySetDefinitionListResult(_serialization.Model): """List of policy set definitions. :ivar value: An array of policy set definitions. @@ -428,16 +422,12 @@ class PolicySetDefinitionListResult(msrest.serialization.Model): """ _attribute_map = { - 'value': {'key': 'value', 'type': '[PolicySetDefinition]'}, - 'next_link': {'key': 'nextLink', 'type': 'str'}, + "value": {"key": "value", "type": "[PolicySetDefinition]"}, + "next_link": {"key": "nextLink", "type": "str"}, } def __init__( - self, - *, - value: Optional[List["PolicySetDefinition"]] = None, - next_link: Optional[str] = None, - **kwargs + self, *, value: Optional[List["_models.PolicySetDefinition"]] = None, next_link: Optional[str] = None, **kwargs ): """ :keyword value: An array of policy set definitions. @@ -446,44 +436,38 @@ def __init__( :keyword next_link: The URL to use for getting the next set of results. :paramtype next_link: str """ - super(PolicySetDefinitionListResult, self).__init__(**kwargs) + super().__init__(**kwargs) self.value = value self.next_link = next_link -class PolicySku(msrest.serialization.Model): +class PolicySku(_serialization.Model): """The policy sku. All required parameters must be populated in order to send to Azure. - :ivar name: Required. The name of the policy sku. Possible values are A0 and A1. + :ivar name: The name of the policy sku. Possible values are A0 and A1. Required. :vartype name: str :ivar tier: The policy sku tier. Possible values are Free and Standard. :vartype tier: str """ _validation = { - 'name': {'required': True}, + "name": {"required": True}, } _attribute_map = { - 'name': {'key': 'name', 'type': 'str'}, - 'tier': {'key': 'tier', 'type': 'str'}, + "name": {"key": "name", "type": "str"}, + "tier": {"key": "tier", "type": "str"}, } - def __init__( - self, - *, - name: str, - tier: Optional[str] = None, - **kwargs - ): + def __init__(self, *, name: str, tier: Optional[str] = None, **kwargs): """ - :keyword name: Required. The name of the policy sku. Possible values are A0 and A1. + :keyword name: The name of the policy sku. Possible values are A0 and A1. Required. :paramtype name: str :keyword tier: The policy sku tier. Possible values are Free and Standard. :paramtype tier: str """ - super(PolicySku, self).__init__(**kwargs) + super().__init__(**kwargs) self.name = name self.tier = tier diff --git a/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/policy/v2017_06_01_preview/models/_patch.py b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/policy/v2017_06_01_preview/models/_patch.py new file mode 100644 index 0000000000000..f7dd32510333d --- /dev/null +++ b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/policy/v2017_06_01_preview/models/_patch.py @@ -0,0 +1,20 @@ +# ------------------------------------ +# Copyright (c) Microsoft Corporation. +# Licensed under the MIT License. +# ------------------------------------ +"""Customize generated code here. + +Follow our quickstart for examples: https://aka.ms/azsdk/python/dpcodegen/python/customize +""" +from typing import List + +__all__: List[str] = [] # Add all objects you want publicly available to users at this package level + + +def patch_sdk(): + """Do not remove from this file. + + `patch_sdk` is a last resort escape hatch that allows you to do customizations + you can't accomplish using the techniques described in + https://aka.ms/azsdk/python/dpcodegen/python/customize + """ diff --git a/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/policy/v2017_06_01_preview/models/_policy_client_enums.py b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/policy/v2017_06_01_preview/models/_policy_client_enums.py index 2acd4055af049..5a5cb27e9884c 100644 --- a/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/policy/v2017_06_01_preview/models/_policy_client_enums.py +++ b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/policy/v2017_06_01_preview/models/_policy_client_enums.py @@ -7,21 +7,19 @@ # -------------------------------------------------------------------------- from enum import Enum -from six import with_metaclass from azure.core import CaseInsensitiveEnumMeta -class PolicyMode(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): - """The policy definition mode. Possible values are NotSpecified, Indexed, and All. - """ +class PolicyMode(str, Enum, metaclass=CaseInsensitiveEnumMeta): + """The policy definition mode. Possible values are NotSpecified, Indexed, and All.""" NOT_SPECIFIED = "NotSpecified" INDEXED = "Indexed" ALL = "All" -class PolicyType(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): - """The type of policy definition. Possible values are NotSpecified, BuiltIn, and Custom. - """ + +class PolicyType(str, Enum, metaclass=CaseInsensitiveEnumMeta): + """The type of policy definition. Possible values are NotSpecified, BuiltIn, and Custom.""" NOT_SPECIFIED = "NotSpecified" BUILT_IN = "BuiltIn" diff --git a/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/policy/v2017_06_01_preview/operations/__init__.py b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/policy/v2017_06_01_preview/operations/__init__.py index e7579dcbdfe86..5b62ee07afa98 100644 --- a/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/policy/v2017_06_01_preview/operations/__init__.py +++ b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/policy/v2017_06_01_preview/operations/__init__.py @@ -10,8 +10,14 @@ from ._operations import PolicySetDefinitionsOperations from ._operations import PolicyDefinitionsOperations +from ._patch import __all__ as _patch_all +from ._patch import * # type: ignore # pylint: disable=unused-wildcard-import +from ._patch import patch_sdk as _patch_sdk + __all__ = [ - 'PolicyAssignmentsOperations', - 'PolicySetDefinitionsOperations', - 'PolicyDefinitionsOperations', + "PolicyAssignmentsOperations", + "PolicySetDefinitionsOperations", + "PolicyDefinitionsOperations", ] +__all__.extend([p for p in _patch_all if p not in __all__]) +_patch_sdk() diff --git a/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/policy/v2017_06_01_preview/operations/_operations.py b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/policy/v2017_06_01_preview/operations/_operations.py index 49361bc7d743b..d36c06e1074bf 100644 --- a/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/policy/v2017_06_01_preview/operations/_operations.py +++ b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/policy/v2017_06_01_preview/operations/_operations.py @@ -6,173 +6,151 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -from typing import Any, Callable, Dict, Iterable, Optional, TypeVar - -from msrest import Serializer - -from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error +from typing import Any, Callable, Dict, IO, Iterable, Optional, TypeVar, Union, overload + +from azure.core.exceptions import ( + ClientAuthenticationError, + HttpResponseError, + ResourceExistsError, + ResourceNotFoundError, + ResourceNotModifiedError, + map_error, +) from azure.core.paging import ItemPaged from azure.core.pipeline import PipelineResponse from azure.core.pipeline.transport import HttpResponse from azure.core.rest import HttpRequest from azure.core.tracing.decorator import distributed_trace +from azure.core.utils import case_insensitive_dict from azure.mgmt.core.exceptions import ARMErrorFormat from .. import models as _models +from ..._serialization import Serializer from .._vendor import _convert_request, _format_url_section -T = TypeVar('T') -JSONType = Any + +T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] _SERIALIZER = Serializer() _SERIALIZER.client_side_validation = False -def build_policy_assignments_delete_request( - scope: str, - policy_assignment_name: str, - **kwargs: Any -) -> HttpRequest: - api_version = kwargs.pop('api_version', "2017-06-01-preview") # type: str - accept = "application/json, text/json" +def build_policy_assignments_delete_request(scope: str, policy_assignment_name: 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", "2017-06-01-preview")) # type: str + accept = _headers.pop("Accept", "application/json, text/json") + # Construct URL - _url = kwargs.pop("template_url", "/{scope}/providers/Microsoft.Authorization/policyAssignments/{policyAssignmentName}") + _url = kwargs.pop( + "template_url", "/{scope}/providers/Microsoft.Authorization/policyAssignments/{policyAssignmentName}" + ) path_format_arguments = { - "scope": _SERIALIZER.url("scope", scope, 'str', skip_quote=True), - "policyAssignmentName": _SERIALIZER.url("policy_assignment_name", policy_assignment_name, 'str'), + "scope": _SERIALIZER.url("scope", scope, "str", skip_quote=True), + "policyAssignmentName": _SERIALIZER.url("policy_assignment_name", policy_assignment_name, "str"), } _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') - - return HttpRequest( - method="DELETE", - url=_url, - params=_query_parameters, - headers=_header_parameters, - **kwargs - ) + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + return HttpRequest(method="DELETE", url=_url, params=_params, headers=_headers, **kwargs) -def build_policy_assignments_create_request( - scope: str, - policy_assignment_name: str, - *, - json: JSONType = None, - content: Any = None, - **kwargs: Any -) -> HttpRequest: - api_version = kwargs.pop('api_version', "2017-06-01-preview") # type: str - content_type = kwargs.pop('content_type', None) # type: Optional[str] - accept = "application/json, text/json" +def build_policy_assignments_create_request(scope: str, policy_assignment_name: 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", "2017-06-01-preview")) # type: str + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + accept = _headers.pop("Accept", "application/json, text/json") + # Construct URL - _url = kwargs.pop("template_url", "/{scope}/providers/Microsoft.Authorization/policyAssignments/{policyAssignmentName}") + _url = kwargs.pop( + "template_url", "/{scope}/providers/Microsoft.Authorization/policyAssignments/{policyAssignmentName}" + ) path_format_arguments = { - "scope": _SERIALIZER.url("scope", scope, 'str', skip_quote=True), - "policyAssignmentName": _SERIALIZER.url("policy_assignment_name", policy_assignment_name, 'str'), + "scope": _SERIALIZER.url("scope", scope, "str", skip_quote=True), + "policyAssignmentName": _SERIALIZER.url("policy_assignment_name", policy_assignment_name, "str"), } _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] if content_type is not None: - _header_parameters['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') - _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') - - return HttpRequest( - method="PUT", - url=_url, - params=_query_parameters, - headers=_header_parameters, - json=json, - content=content, - **kwargs - ) + _headers["Content-Type"] = _SERIALIZER.header("content_type", content_type, "str") + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + return HttpRequest(method="PUT", url=_url, params=_params, headers=_headers, **kwargs) -def build_policy_assignments_get_request( - scope: str, - policy_assignment_name: str, - **kwargs: Any -) -> HttpRequest: - api_version = kwargs.pop('api_version', "2017-06-01-preview") # type: str - accept = "application/json, text/json" +def build_policy_assignments_get_request(scope: str, policy_assignment_name: 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", "2017-06-01-preview")) # type: str + accept = _headers.pop("Accept", "application/json, text/json") + # Construct URL - _url = kwargs.pop("template_url", "/{scope}/providers/Microsoft.Authorization/policyAssignments/{policyAssignmentName}") + _url = kwargs.pop( + "template_url", "/{scope}/providers/Microsoft.Authorization/policyAssignments/{policyAssignmentName}" + ) path_format_arguments = { - "scope": _SERIALIZER.url("scope", scope, 'str', skip_quote=True), - "policyAssignmentName": _SERIALIZER.url("policy_assignment_name", policy_assignment_name, 'str'), + "scope": _SERIALIZER.url("scope", scope, "str", skip_quote=True), + "policyAssignmentName": _SERIALIZER.url("policy_assignment_name", policy_assignment_name, "str"), } _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') - - return HttpRequest( - method="GET", - url=_url, - params=_query_parameters, - headers=_header_parameters, - **kwargs - ) + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) def build_policy_assignments_list_for_resource_group_request( - resource_group_name: str, - subscription_id: str, - *, - filter: Optional[str] = None, - **kwargs: Any + resource_group_name: str, subscription_id: str, *, filter: Optional[str] = None, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2017-06-01-preview") # type: 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", "2017-06-01-preview")) # type: str + accept = _headers.pop("Accept", "application/json, text/json") - accept = "application/json, text/json" # Construct URL - _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Authorization/policyAssignments") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Authorization/policyAssignments", + ) # pylint: disable=line-too-long path_format_arguments = { - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._\(\)]+$'), - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), + "resourceGroupName": _SERIALIZER.url( + "resource_group_name", resource_group_name, "str", max_length=90, min_length=1, pattern=r"^[-\w\._\(\)]+$" + ), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), } _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] if filter is not None: - _query_parameters['$filter'] = _SERIALIZER.query("filter", filter, 'str', skip_quote=True) - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["$filter"] = _SERIALIZER.query("filter", filter, "str", skip_quote=True) + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') - - return HttpRequest( - method="GET", - url=_url, - params=_query_parameters, - headers=_header_parameters, - **kwargs - ) + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) def build_policy_assignments_list_for_resource_request( @@ -186,918 +164,763 @@ def build_policy_assignments_list_for_resource_request( filter: Optional[str] = None, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2017-06-01-preview") # type: 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", "2017-06-01-preview")) # type: str + accept = _headers.pop("Accept", "application/json, text/json") - accept = "application/json, text/json" # Construct URL - _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{parentResourcePath}/{resourceType}/{resourceName}/providers/Microsoft.Authorization/policyAssignments") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{parentResourcePath}/{resourceType}/{resourceName}/providers/Microsoft.Authorization/policyAssignments", + ) # pylint: disable=line-too-long path_format_arguments = { - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._\(\)]+$'), - "resourceProviderNamespace": _SERIALIZER.url("resource_provider_namespace", resource_provider_namespace, 'str'), - "parentResourcePath": _SERIALIZER.url("parent_resource_path", parent_resource_path, 'str', skip_quote=True), - "resourceType": _SERIALIZER.url("resource_type", resource_type, 'str', skip_quote=True), - "resourceName": _SERIALIZER.url("resource_name", resource_name, 'str'), - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), + "resourceGroupName": _SERIALIZER.url( + "resource_group_name", resource_group_name, "str", max_length=90, min_length=1, pattern=r"^[-\w\._\(\)]+$" + ), + "resourceProviderNamespace": _SERIALIZER.url("resource_provider_namespace", resource_provider_namespace, "str"), + "parentResourcePath": _SERIALIZER.url("parent_resource_path", parent_resource_path, "str", skip_quote=True), + "resourceType": _SERIALIZER.url("resource_type", resource_type, "str", skip_quote=True), + "resourceName": _SERIALIZER.url("resource_name", resource_name, "str"), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), } _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] if filter is not None: - _query_parameters['$filter'] = _SERIALIZER.query("filter", filter, 'str') - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["$filter"] = _SERIALIZER.query("filter", filter, "str") + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') - - return HttpRequest( - method="GET", - url=_url, - params=_query_parameters, - headers=_header_parameters, - **kwargs - ) + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) def build_policy_assignments_list_request( - subscription_id: str, - *, - filter: Optional[str] = None, - **kwargs: Any + subscription_id: str, *, filter: Optional[str] = None, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2017-06-01-preview") # type: 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", "2017-06-01-preview")) # type: str + accept = _headers.pop("Accept", "application/json, text/json") - accept = "application/json, text/json" # Construct URL - _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/providers/Microsoft.Authorization/policyAssignments") + _url = kwargs.pop( + "template_url", "/subscriptions/{subscriptionId}/providers/Microsoft.Authorization/policyAssignments" + ) path_format_arguments = { - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), } _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] if filter is not None: - _query_parameters['$filter'] = _SERIALIZER.query("filter", filter, 'str') - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["$filter"] = _SERIALIZER.query("filter", filter, "str") + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') - - return HttpRequest( - method="GET", - url=_url, - params=_query_parameters, - headers=_header_parameters, - **kwargs - ) + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) -def build_policy_assignments_delete_by_id_request( - policy_assignment_id: str, - **kwargs: Any -) -> HttpRequest: - api_version = kwargs.pop('api_version', "2017-06-01-preview") # type: str - accept = "application/json, text/json" +def build_policy_assignments_delete_by_id_request(policy_assignment_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", "2017-06-01-preview")) # type: str + accept = _headers.pop("Accept", "application/json, text/json") + # Construct URL _url = kwargs.pop("template_url", "/{policyAssignmentId}") path_format_arguments = { - "policyAssignmentId": _SERIALIZER.url("policy_assignment_id", policy_assignment_id, 'str', skip_quote=True), + "policyAssignmentId": _SERIALIZER.url("policy_assignment_id", policy_assignment_id, "str", skip_quote=True), } _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') - - return HttpRequest( - method="DELETE", - url=_url, - params=_query_parameters, - headers=_header_parameters, - **kwargs - ) + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + return HttpRequest(method="DELETE", url=_url, params=_params, headers=_headers, **kwargs) -def build_policy_assignments_create_by_id_request( - policy_assignment_id: str, - *, - json: JSONType = None, - content: Any = None, - **kwargs: Any -) -> HttpRequest: - api_version = kwargs.pop('api_version', "2017-06-01-preview") # type: str - content_type = kwargs.pop('content_type', None) # type: Optional[str] - accept = "application/json, text/json" +def build_policy_assignments_create_by_id_request(policy_assignment_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", "2017-06-01-preview")) # type: str + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + accept = _headers.pop("Accept", "application/json, text/json") + # Construct URL _url = kwargs.pop("template_url", "/{policyAssignmentId}") path_format_arguments = { - "policyAssignmentId": _SERIALIZER.url("policy_assignment_id", policy_assignment_id, 'str', skip_quote=True), + "policyAssignmentId": _SERIALIZER.url("policy_assignment_id", policy_assignment_id, "str", skip_quote=True), } _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] if content_type is not None: - _header_parameters['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') - _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') - - return HttpRequest( - method="PUT", - url=_url, - params=_query_parameters, - headers=_header_parameters, - json=json, - content=content, - **kwargs - ) + _headers["Content-Type"] = _SERIALIZER.header("content_type", content_type, "str") + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + return HttpRequest(method="PUT", url=_url, params=_params, headers=_headers, **kwargs) -def build_policy_assignments_get_by_id_request( - policy_assignment_id: str, - **kwargs: Any -) -> HttpRequest: - api_version = kwargs.pop('api_version', "2017-06-01-preview") # type: str - accept = "application/json, text/json" +def build_policy_assignments_get_by_id_request(policy_assignment_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", "2017-06-01-preview")) # type: str + accept = _headers.pop("Accept", "application/json, text/json") + # Construct URL _url = kwargs.pop("template_url", "/{policyAssignmentId}") path_format_arguments = { - "policyAssignmentId": _SERIALIZER.url("policy_assignment_id", policy_assignment_id, 'str', skip_quote=True), + "policyAssignmentId": _SERIALIZER.url("policy_assignment_id", policy_assignment_id, "str", skip_quote=True), } _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') - - return HttpRequest( - method="GET", - url=_url, - params=_query_parameters, - headers=_header_parameters, - **kwargs - ) + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) def build_policy_set_definitions_create_or_update_request( - policy_set_definition_name: str, - subscription_id: str, - *, - json: JSONType = None, - content: Any = None, - **kwargs: Any + policy_set_definition_name: str, subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2017-06-01-preview") # type: str - content_type = kwargs.pop('content_type', None) # type: Optional[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", "2017-06-01-preview")) # type: str + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + accept = _headers.pop("Accept", "application/json, text/json") - accept = "application/json, text/json" # Construct URL - _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/providers/Microsoft.Authorization/policySetDefinitions/{policySetDefinitionName}") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/providers/Microsoft.Authorization/policySetDefinitions/{policySetDefinitionName}", + ) # pylint: disable=line-too-long path_format_arguments = { - "policySetDefinitionName": _SERIALIZER.url("policy_set_definition_name", policy_set_definition_name, 'str'), - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), + "policySetDefinitionName": _SERIALIZER.url("policy_set_definition_name", policy_set_definition_name, "str"), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), } _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] if content_type is not None: - _header_parameters['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') - _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') - - return HttpRequest( - method="PUT", - url=_url, - params=_query_parameters, - headers=_header_parameters, - json=json, - content=content, - **kwargs - ) + _headers["Content-Type"] = _SERIALIZER.header("content_type", content_type, "str") + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="PUT", url=_url, params=_params, headers=_headers, **kwargs) def build_policy_set_definitions_delete_request( - policy_set_definition_name: str, - subscription_id: str, - **kwargs: Any + policy_set_definition_name: str, subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2017-06-01-preview") # type: 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", "2017-06-01-preview")) # type: str + accept = _headers.pop("Accept", "application/json, text/json") - accept = "application/json, text/json" # Construct URL - _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/providers/Microsoft.Authorization/policySetDefinitions/{policySetDefinitionName}") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/providers/Microsoft.Authorization/policySetDefinitions/{policySetDefinitionName}", + ) # pylint: disable=line-too-long path_format_arguments = { - "policySetDefinitionName": _SERIALIZER.url("policy_set_definition_name", policy_set_definition_name, 'str'), - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), + "policySetDefinitionName": _SERIALIZER.url("policy_set_definition_name", policy_set_definition_name, "str"), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), } _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') - - return HttpRequest( - method="DELETE", - url=_url, - params=_query_parameters, - headers=_header_parameters, - **kwargs - ) + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="DELETE", url=_url, params=_params, headers=_headers, **kwargs) def build_policy_set_definitions_get_request( - policy_set_definition_name: str, - subscription_id: str, - **kwargs: Any + policy_set_definition_name: str, subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2017-06-01-preview") # type: 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", "2017-06-01-preview")) # type: str + accept = _headers.pop("Accept", "application/json, text/json") - accept = "application/json, text/json" # Construct URL - _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/providers/Microsoft.Authorization/policySetDefinitions/{policySetDefinitionName}") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/providers/Microsoft.Authorization/policySetDefinitions/{policySetDefinitionName}", + ) # pylint: disable=line-too-long path_format_arguments = { - "policySetDefinitionName": _SERIALIZER.url("policy_set_definition_name", policy_set_definition_name, 'str'), - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), + "policySetDefinitionName": _SERIALIZER.url("policy_set_definition_name", policy_set_definition_name, "str"), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), } _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') - - return HttpRequest( - method="GET", - url=_url, - params=_query_parameters, - headers=_header_parameters, - **kwargs - ) + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) -def build_policy_set_definitions_get_built_in_request( - policy_set_definition_name: str, - **kwargs: Any -) -> HttpRequest: - api_version = kwargs.pop('api_version', "2017-06-01-preview") # type: str - accept = "application/json, text/json" +def build_policy_set_definitions_get_built_in_request(policy_set_definition_name: 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", "2017-06-01-preview")) # type: str + accept = _headers.pop("Accept", "application/json, text/json") + # Construct URL - _url = kwargs.pop("template_url", "/providers/Microsoft.Authorization/policySetDefinitions/{policySetDefinitionName}") + _url = kwargs.pop( + "template_url", "/providers/Microsoft.Authorization/policySetDefinitions/{policySetDefinitionName}" + ) path_format_arguments = { - "policySetDefinitionName": _SERIALIZER.url("policy_set_definition_name", policy_set_definition_name, 'str'), + "policySetDefinitionName": _SERIALIZER.url("policy_set_definition_name", policy_set_definition_name, "str"), } _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') - - return HttpRequest( - method="GET", - url=_url, - params=_query_parameters, - headers=_header_parameters, - **kwargs - ) + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) -def build_policy_set_definitions_list_request( - subscription_id: str, - **kwargs: Any -) -> HttpRequest: - api_version = kwargs.pop('api_version', "2017-06-01-preview") # type: str - accept = "application/json, text/json" +def build_policy_set_definitions_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", "2017-06-01-preview")) # type: str + accept = _headers.pop("Accept", "application/json, text/json") + # Construct URL - _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/providers/Microsoft.Authorization/policySetDefinitions") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", "/subscriptions/{subscriptionId}/providers/Microsoft.Authorization/policySetDefinitions" + ) # pylint: disable=line-too-long path_format_arguments = { - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), } _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') - - return HttpRequest( - method="GET", - url=_url, - params=_query_parameters, - headers=_header_parameters, - **kwargs - ) + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) -def build_policy_set_definitions_list_built_in_request( - **kwargs: Any -) -> HttpRequest: - api_version = kwargs.pop('api_version', "2017-06-01-preview") # type: str - accept = "application/json, text/json" +def build_policy_set_definitions_list_built_in_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", "2017-06-01-preview")) # type: str + accept = _headers.pop("Accept", "application/json, text/json") + # Construct URL _url = kwargs.pop("template_url", "/providers/Microsoft.Authorization/policySetDefinitions") # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') - - return HttpRequest( - method="GET", - url=_url, - params=_query_parameters, - headers=_header_parameters, - **kwargs - ) + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) def build_policy_set_definitions_create_or_update_at_management_group_request( - policy_set_definition_name: str, - management_group_id: str, - *, - json: JSONType = None, - content: Any = None, - **kwargs: Any + policy_set_definition_name: str, management_group_id: str, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2017-06-01-preview") # type: str - content_type = kwargs.pop('content_type', None) # type: Optional[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", "2017-06-01-preview")) # type: str + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + accept = _headers.pop("Accept", "application/json, text/json") - accept = "application/json, text/json" # Construct URL - _url = kwargs.pop("template_url", "/providers/Microsoft.Management/managementgroups/{managementGroupId}/providers/Microsoft.Authorization/policySetDefinitions/{policySetDefinitionName}") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", + "/providers/Microsoft.Management/managementgroups/{managementGroupId}/providers/Microsoft.Authorization/policySetDefinitions/{policySetDefinitionName}", + ) # pylint: disable=line-too-long path_format_arguments = { - "policySetDefinitionName": _SERIALIZER.url("policy_set_definition_name", policy_set_definition_name, 'str'), - "managementGroupId": _SERIALIZER.url("management_group_id", management_group_id, 'str'), + "policySetDefinitionName": _SERIALIZER.url("policy_set_definition_name", policy_set_definition_name, "str"), + "managementGroupId": _SERIALIZER.url("management_group_id", management_group_id, "str"), } _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] if content_type is not None: - _header_parameters['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') - _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') - - return HttpRequest( - method="PUT", - url=_url, - params=_query_parameters, - headers=_header_parameters, - json=json, - content=content, - **kwargs - ) + _headers["Content-Type"] = _SERIALIZER.header("content_type", content_type, "str") + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="PUT", url=_url, params=_params, headers=_headers, **kwargs) def build_policy_set_definitions_delete_at_management_group_request( - policy_set_definition_name: str, - management_group_id: str, - **kwargs: Any + policy_set_definition_name: str, management_group_id: str, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2017-06-01-preview") # type: 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", "2017-06-01-preview")) # type: str + accept = _headers.pop("Accept", "application/json, text/json") - accept = "application/json, text/json" # Construct URL - _url = kwargs.pop("template_url", "/providers/Microsoft.Management/managementgroups/{managementGroupId}/providers/Microsoft.Authorization/policySetDefinitions/{policySetDefinitionName}") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", + "/providers/Microsoft.Management/managementgroups/{managementGroupId}/providers/Microsoft.Authorization/policySetDefinitions/{policySetDefinitionName}", + ) # pylint: disable=line-too-long path_format_arguments = { - "policySetDefinitionName": _SERIALIZER.url("policy_set_definition_name", policy_set_definition_name, 'str'), - "managementGroupId": _SERIALIZER.url("management_group_id", management_group_id, 'str'), + "policySetDefinitionName": _SERIALIZER.url("policy_set_definition_name", policy_set_definition_name, "str"), + "managementGroupId": _SERIALIZER.url("management_group_id", management_group_id, "str"), } _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') - - return HttpRequest( - method="DELETE", - url=_url, - params=_query_parameters, - headers=_header_parameters, - **kwargs - ) + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="DELETE", url=_url, params=_params, headers=_headers, **kwargs) def build_policy_set_definitions_get_at_management_group_request( - policy_set_definition_name: str, - management_group_id: str, - **kwargs: Any + policy_set_definition_name: str, management_group_id: str, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2017-06-01-preview") # type: 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", "2017-06-01-preview")) # type: str + accept = _headers.pop("Accept", "application/json, text/json") - accept = "application/json, text/json" # Construct URL - _url = kwargs.pop("template_url", "/providers/Microsoft.Management/managementgroups/{managementGroupId}/providers/Microsoft.Authorization/policySetDefinitions/{policySetDefinitionName}") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", + "/providers/Microsoft.Management/managementgroups/{managementGroupId}/providers/Microsoft.Authorization/policySetDefinitions/{policySetDefinitionName}", + ) # pylint: disable=line-too-long path_format_arguments = { - "policySetDefinitionName": _SERIALIZER.url("policy_set_definition_name", policy_set_definition_name, 'str'), - "managementGroupId": _SERIALIZER.url("management_group_id", management_group_id, 'str'), + "policySetDefinitionName": _SERIALIZER.url("policy_set_definition_name", policy_set_definition_name, "str"), + "managementGroupId": _SERIALIZER.url("management_group_id", management_group_id, "str"), } _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') - - return HttpRequest( - method="GET", - url=_url, - params=_query_parameters, - headers=_header_parameters, - **kwargs - ) + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) def build_policy_set_definitions_list_by_management_group_request( - management_group_id: str, - **kwargs: Any + management_group_id: str, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2017-06-01-preview") # type: 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", "2017-06-01-preview")) # type: str + accept = _headers.pop("Accept", "application/json, text/json") - accept = "application/json, text/json" # Construct URL - _url = kwargs.pop("template_url", "/providers/Microsoft.Management/managementgroups/{managementGroupId}/providers/Microsoft.Authorization/policySetDefinitions") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", + "/providers/Microsoft.Management/managementgroups/{managementGroupId}/providers/Microsoft.Authorization/policySetDefinitions", + ) # pylint: disable=line-too-long path_format_arguments = { - "managementGroupId": _SERIALIZER.url("management_group_id", management_group_id, 'str'), + "managementGroupId": _SERIALIZER.url("management_group_id", management_group_id, "str"), } _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') - - return HttpRequest( - method="GET", - url=_url, - params=_query_parameters, - headers=_header_parameters, - **kwargs - ) + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) def build_policy_definitions_create_or_update_request( - policy_definition_name: str, - subscription_id: str, - *, - json: JSONType = None, - content: Any = None, - **kwargs: Any + policy_definition_name: str, subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2016-12-01") # type: str - content_type = kwargs.pop('content_type', None) # type: Optional[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", "2016-12-01")) # type: str + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + accept = _headers.pop("Accept", "application/json, text/json") - accept = "application/json, text/json" # Construct URL - _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/providers/Microsoft.Authorization/policyDefinitions/{policyDefinitionName}") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/providers/Microsoft.Authorization/policyDefinitions/{policyDefinitionName}", + ) # pylint: disable=line-too-long path_format_arguments = { - "policyDefinitionName": _SERIALIZER.url("policy_definition_name", policy_definition_name, 'str'), - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), + "policyDefinitionName": _SERIALIZER.url("policy_definition_name", policy_definition_name, "str"), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), } _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] if content_type is not None: - _header_parameters['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') - _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') - - return HttpRequest( - method="PUT", - url=_url, - params=_query_parameters, - headers=_header_parameters, - json=json, - content=content, - **kwargs - ) + _headers["Content-Type"] = _SERIALIZER.header("content_type", content_type, "str") + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="PUT", url=_url, params=_params, headers=_headers, **kwargs) def build_policy_definitions_delete_request( - policy_definition_name: str, - subscription_id: str, - **kwargs: Any + policy_definition_name: str, subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2016-12-01") # type: str + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + api_version = kwargs.pop("api_version", _params.pop("api-version", "2016-12-01")) # type: str # Construct URL - _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/providers/Microsoft.Authorization/policyDefinitions/{policyDefinitionName}") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/providers/Microsoft.Authorization/policyDefinitions/{policyDefinitionName}", + ) # pylint: disable=line-too-long path_format_arguments = { - "policyDefinitionName": _SERIALIZER.url("policy_definition_name", policy_definition_name, 'str'), - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), + "policyDefinitionName": _SERIALIZER.url("policy_definition_name", policy_definition_name, "str"), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), } _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') - - return HttpRequest( - method="DELETE", - url=_url, - params=_query_parameters, - **kwargs - ) + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") + + return HttpRequest(method="DELETE", url=_url, params=_params, **kwargs) def build_policy_definitions_get_request( - policy_definition_name: str, - subscription_id: str, - **kwargs: Any + policy_definition_name: str, subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2016-12-01") # type: 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", "2016-12-01")) # type: str + accept = _headers.pop("Accept", "application/json, text/json") - accept = "application/json, text/json" # Construct URL - _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/providers/Microsoft.Authorization/policyDefinitions/{policyDefinitionName}") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/providers/Microsoft.Authorization/policyDefinitions/{policyDefinitionName}", + ) # pylint: disable=line-too-long path_format_arguments = { - "policyDefinitionName": _SERIALIZER.url("policy_definition_name", policy_definition_name, 'str'), - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), + "policyDefinitionName": _SERIALIZER.url("policy_definition_name", policy_definition_name, "str"), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), } _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') - - return HttpRequest( - method="GET", - url=_url, - params=_query_parameters, - headers=_header_parameters, - **kwargs - ) + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) -def build_policy_definitions_get_built_in_request( - policy_definition_name: str, - **kwargs: Any -) -> HttpRequest: - api_version = kwargs.pop('api_version', "2016-12-01") # type: str - accept = "application/json, text/json" +def build_policy_definitions_get_built_in_request(policy_definition_name: 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", "2016-12-01")) # type: str + accept = _headers.pop("Accept", "application/json, text/json") + # Construct URL _url = kwargs.pop("template_url", "/providers/Microsoft.Authorization/policyDefinitions/{policyDefinitionName}") path_format_arguments = { - "policyDefinitionName": _SERIALIZER.url("policy_definition_name", policy_definition_name, 'str'), + "policyDefinitionName": _SERIALIZER.url("policy_definition_name", policy_definition_name, "str"), } _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') - - return HttpRequest( - method="GET", - url=_url, - params=_query_parameters, - headers=_header_parameters, - **kwargs - ) + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) def build_policy_definitions_create_or_update_at_management_group_request( - policy_definition_name: str, - management_group_id: str, - *, - json: JSONType = None, - content: Any = None, - **kwargs: Any + policy_definition_name: str, management_group_id: str, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2016-12-01") # type: str - content_type = kwargs.pop('content_type', None) # type: Optional[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", "2016-12-01")) # type: str + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + accept = _headers.pop("Accept", "application/json, text/json") - accept = "application/json, text/json" # Construct URL - _url = kwargs.pop("template_url", "/providers/Microsoft.Management/managementgroups/{managementGroupId}/providers/Microsoft.Authorization/policyDefinitions/{policyDefinitionName}") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", + "/providers/Microsoft.Management/managementgroups/{managementGroupId}/providers/Microsoft.Authorization/policyDefinitions/{policyDefinitionName}", + ) # pylint: disable=line-too-long path_format_arguments = { - "policyDefinitionName": _SERIALIZER.url("policy_definition_name", policy_definition_name, 'str'), - "managementGroupId": _SERIALIZER.url("management_group_id", management_group_id, 'str'), + "policyDefinitionName": _SERIALIZER.url("policy_definition_name", policy_definition_name, "str"), + "managementGroupId": _SERIALIZER.url("management_group_id", management_group_id, "str"), } _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] if content_type is not None: - _header_parameters['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') - _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') - - return HttpRequest( - method="PUT", - url=_url, - params=_query_parameters, - headers=_header_parameters, - json=json, - content=content, - **kwargs - ) + _headers["Content-Type"] = _SERIALIZER.header("content_type", content_type, "str") + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="PUT", url=_url, params=_params, headers=_headers, **kwargs) def build_policy_definitions_delete_at_management_group_request( - policy_definition_name: str, - management_group_id: str, - **kwargs: Any + policy_definition_name: str, management_group_id: str, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2016-12-01") # type: str + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + api_version = kwargs.pop("api_version", _params.pop("api-version", "2016-12-01")) # type: str # Construct URL - _url = kwargs.pop("template_url", "/providers/Microsoft.Management/managementgroups/{managementGroupId}/providers/Microsoft.Authorization/policyDefinitions/{policyDefinitionName}") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", + "/providers/Microsoft.Management/managementgroups/{managementGroupId}/providers/Microsoft.Authorization/policyDefinitions/{policyDefinitionName}", + ) # pylint: disable=line-too-long path_format_arguments = { - "policyDefinitionName": _SERIALIZER.url("policy_definition_name", policy_definition_name, 'str'), - "managementGroupId": _SERIALIZER.url("management_group_id", management_group_id, 'str'), + "policyDefinitionName": _SERIALIZER.url("policy_definition_name", policy_definition_name, "str"), + "managementGroupId": _SERIALIZER.url("management_group_id", management_group_id, "str"), } _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') - - return HttpRequest( - method="DELETE", - url=_url, - params=_query_parameters, - **kwargs - ) + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") + + return HttpRequest(method="DELETE", url=_url, params=_params, **kwargs) def build_policy_definitions_get_at_management_group_request( - policy_definition_name: str, - management_group_id: str, - **kwargs: Any + policy_definition_name: str, management_group_id: str, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2016-12-01") # type: 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", "2016-12-01")) # type: str + accept = _headers.pop("Accept", "application/json, text/json") - accept = "application/json, text/json" # Construct URL - _url = kwargs.pop("template_url", "/providers/Microsoft.Management/managementgroups/{managementGroupId}/providers/Microsoft.Authorization/policyDefinitions/{policyDefinitionName}") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", + "/providers/Microsoft.Management/managementgroups/{managementGroupId}/providers/Microsoft.Authorization/policyDefinitions/{policyDefinitionName}", + ) # pylint: disable=line-too-long path_format_arguments = { - "policyDefinitionName": _SERIALIZER.url("policy_definition_name", policy_definition_name, 'str'), - "managementGroupId": _SERIALIZER.url("management_group_id", management_group_id, 'str'), + "policyDefinitionName": _SERIALIZER.url("policy_definition_name", policy_definition_name, "str"), + "managementGroupId": _SERIALIZER.url("management_group_id", management_group_id, "str"), } _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') - - return HttpRequest( - method="GET", - url=_url, - params=_query_parameters, - headers=_header_parameters, - **kwargs - ) + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) -def build_policy_definitions_list_request( - subscription_id: str, - **kwargs: Any -) -> HttpRequest: - api_version = kwargs.pop('api_version', "2016-12-01") # type: str - accept = "application/json, text/json" +def build_policy_definitions_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", "2016-12-01")) # type: str + accept = _headers.pop("Accept", "application/json, text/json") + # Construct URL - _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/providers/Microsoft.Authorization/policyDefinitions") + _url = kwargs.pop( + "template_url", "/subscriptions/{subscriptionId}/providers/Microsoft.Authorization/policyDefinitions" + ) path_format_arguments = { - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), } _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') - - return HttpRequest( - method="GET", - url=_url, - params=_query_parameters, - headers=_header_parameters, - **kwargs - ) + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) -def build_policy_definitions_list_built_in_request( - **kwargs: Any -) -> HttpRequest: - api_version = kwargs.pop('api_version', "2016-12-01") # type: str - accept = "application/json, text/json" +def build_policy_definitions_list_built_in_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", "2016-12-01")) # type: str + accept = _headers.pop("Accept", "application/json, text/json") + # Construct URL _url = kwargs.pop("template_url", "/providers/Microsoft.Authorization/policyDefinitions") # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') - - return HttpRequest( - method="GET", - url=_url, - params=_query_parameters, - headers=_header_parameters, - **kwargs - ) + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) -def build_policy_definitions_list_by_management_group_request( - management_group_id: str, - **kwargs: Any -) -> HttpRequest: - api_version = kwargs.pop('api_version', "2016-12-01") # type: str - accept = "application/json, text/json" +def build_policy_definitions_list_by_management_group_request(management_group_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", "2016-12-01")) # type: str + accept = _headers.pop("Accept", "application/json, text/json") + # Construct URL - _url = kwargs.pop("template_url", "/providers/Microsoft.Management/managementgroups/{managementGroupId}/providers/Microsoft.Authorization/policyDefinitions") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", + "/providers/Microsoft.Management/managementgroups/{managementGroupId}/providers/Microsoft.Authorization/policyDefinitions", + ) # pylint: disable=line-too-long path_format_arguments = { - "managementGroupId": _SERIALIZER.url("management_group_id", management_group_id, 'str'), + "managementGroupId": _SERIALIZER.url("management_group_id", management_group_id, "str"), } _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') - - return HttpRequest( - method="GET", - url=_url, - params=_query_parameters, - headers=_header_parameters, - **kwargs - ) + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) -class PolicyAssignmentsOperations(object): - """PolicyAssignmentsOperations operations. - You should not instantiate this class directly. Instead, you should create a Client instance that - instantiates it for you and attaches it as an attribute. +class PolicyAssignmentsOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. - :ivar models: Alias to model classes used in this operation group. - :type models: ~azure.mgmt.resource.policy.v2017_06_01_preview.models - :param client: Client for service requests. - :param config: Configuration of service client. - :param serializer: An object model serializer. - :param deserializer: An object model deserializer. + Instead, you should access the following operations through + :class:`~azure.mgmt.resource.policy.v2017_06_01_preview.PolicyClient`'s + :attr:`policy_assignments` attribute. """ models = _models - def __init__(self, client, config, serializer, deserializer): - self._client = client - self._serialize = serializer - self._deserialize = deserializer - self._config = config + def __init__(self, *args, **kwargs): + input_args = list(args) + self._client = input_args.pop(0) if input_args else kwargs.pop("client") + self._config = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") @distributed_trace - def delete( - self, - scope: str, - policy_assignment_name: str, - **kwargs: Any - ) -> Optional["_models.PolicyAssignment"]: + def delete(self, scope: str, policy_assignment_name: str, **kwargs: Any) -> Optional[_models.PolicyAssignment]: """Deletes a policy assignment. - :param scope: The scope of the policy assignment. + :param scope: The scope of the policy assignment. Required. :type scope: str - :param policy_assignment_name: The name of the policy assignment to delete. + :param policy_assignment_name: The name of the policy assignment to delete. Required. :type policy_assignment_name: str - :keyword api_version: Api Version. Default value is "2017-06-01-preview". Note that overriding - this default value may result in unsupported behavior. - :paramtype api_version: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: PolicyAssignment, or the result of cls(response) + :return: PolicyAssignment or None or the result of cls(response) :rtype: ~azure.mgmt.resource.policy.v2017_06_01_preview.models.PolicyAssignment or None - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType[Optional["_models.PolicyAssignment"]] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) - api_version = kwargs.pop('api_version', "2017-06-01-preview") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2017-06-01-preview")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[Optional[_models.PolicyAssignment]] - request = build_policy_assignments_delete_request( scope=scope, policy_assignment_name=policy_assignment_name, api_version=api_version, - template_url=self.delete.metadata['url'], + template_url=self.delete.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200, 204]: @@ -1107,57 +930,121 @@ def delete( deserialized = None if response.status_code == 200: - deserialized = self._deserialize('PolicyAssignment', pipeline_response) + deserialized = self._deserialize("PolicyAssignment", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - delete.metadata = {'url': "/{scope}/providers/Microsoft.Authorization/policyAssignments/{policyAssignmentName}"} # type: ignore + delete.metadata = {"url": "/{scope}/providers/Microsoft.Authorization/policyAssignments/{policyAssignmentName}"} # type: ignore - - @distributed_trace + @overload def create( self, scope: str, policy_assignment_name: str, - parameters: "_models.PolicyAssignment", + parameters: _models.PolicyAssignment, *, - content_type: Optional[str] = "application/json", + content_type: str = "application/json", **kwargs: Any - ) -> "_models.PolicyAssignment": + ) -> _models.PolicyAssignment: """Creates a policy assignment. Policy assignments are inherited by child resources. For example, when you apply a policy to a resource group that policy is assigned to all resources in the group. - :param scope: The scope of the policy assignment. + :param scope: The scope of the policy assignment. Required. :type scope: str - :param policy_assignment_name: The name of the policy assignment. + :param policy_assignment_name: The name of the policy assignment. Required. :type policy_assignment_name: str - :param parameters: Parameters for the policy assignment. + :param parameters: Parameters for the policy assignment. Required. :type parameters: ~azure.mgmt.resource.policy.v2017_06_01_preview.models.PolicyAssignment - :keyword content_type: Media type of the body sent to the API. Possible values are: - "application/json" or "text/json". Default value is "application/json". + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". :paramtype content_type: str - :keyword api_version: Api Version. Default value is "2017-06-01-preview". Note that overriding - this default value may result in unsupported behavior. - :paramtype api_version: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: PolicyAssignment, or the result of cls(response) + :return: PolicyAssignment or the result of cls(response) :rtype: ~azure.mgmt.resource.policy.v2017_06_01_preview.models.PolicyAssignment - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + def create( + self, + scope: str, + policy_assignment_name: str, + parameters: IO, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.PolicyAssignment: + """Creates a policy assignment. + + Policy assignments are inherited by child resources. For example, when you apply a policy to a + resource group that policy is assigned to all resources in the group. + + :param scope: The scope of the policy assignment. Required. + :type scope: str + :param policy_assignment_name: The name of the policy assignment. Required. + :type policy_assignment_name: str + :param parameters: Parameters for the policy assignment. Required. + :type parameters: IO + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Known values are: 'application/json', 'text/json'. Default value is "application/json". + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: PolicyAssignment or the result of cls(response) + :rtype: ~azure.mgmt.resource.policy.v2017_06_01_preview.models.PolicyAssignment + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace + def create( + self, scope: str, policy_assignment_name: str, parameters: Union[_models.PolicyAssignment, IO], **kwargs: Any + ) -> _models.PolicyAssignment: + """Creates a policy assignment. + + Policy assignments are inherited by child resources. For example, when you apply a policy to a + resource group that policy is assigned to all resources in the group. + + :param scope: The scope of the policy assignment. Required. + :type scope: str + :param policy_assignment_name: The name of the policy assignment. Required. + :type policy_assignment_name: str + :param parameters: Parameters for the policy assignment. Is either a model type or a IO type. + Required. + :type parameters: ~azure.mgmt.resource.policy.v2017_06_01_preview.models.PolicyAssignment or IO + :keyword content_type: Body Parameter content-type. Known values are: 'application/json', + 'text/json'. Default value is None. + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: PolicyAssignment or the result of cls(response) + :rtype: ~azure.mgmt.resource.policy.v2017_06_01_preview.models.PolicyAssignment + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.PolicyAssignment"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) - api_version = kwargs.pop('api_version', "2017-06-01-preview") # type: str + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - _json = self._serialize.body(parameters, 'PolicyAssignment') + api_version = kwargs.pop("api_version", _params.pop("api-version", "2017-06-01-preview")) # type: str + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.PolicyAssignment] + + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(parameters, (IO, bytes)): + _content = parameters + else: + _json = self._serialize.body(parameters, "PolicyAssignment") request = build_policy_assignments_create_request( scope=scope, @@ -1165,16 +1052,18 @@ def create( api_version=api_version, content_type=content_type, json=_json, - template_url=self.create.metadata['url'], + content=_content, + template_url=self.create.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [201]: @@ -1182,60 +1071,57 @@ def create( error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - deserialized = self._deserialize('PolicyAssignment', pipeline_response) + deserialized = self._deserialize("PolicyAssignment", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - create.metadata = {'url': "/{scope}/providers/Microsoft.Authorization/policyAssignments/{policyAssignmentName}"} # type: ignore - + create.metadata = {"url": "/{scope}/providers/Microsoft.Authorization/policyAssignments/{policyAssignmentName}"} # type: ignore @distributed_trace - def get( - self, - scope: str, - policy_assignment_name: str, - **kwargs: Any - ) -> "_models.PolicyAssignment": + def get(self, scope: str, policy_assignment_name: str, **kwargs: Any) -> _models.PolicyAssignment: """Gets a policy assignment. - :param scope: The scope of the policy assignment. + :param scope: The scope of the policy assignment. Required. :type scope: str - :param policy_assignment_name: The name of the policy assignment to get. + :param policy_assignment_name: The name of the policy assignment to get. Required. :type policy_assignment_name: str - :keyword api_version: Api Version. Default value is "2017-06-01-preview". Note that overriding - this default value may result in unsupported behavior. - :paramtype api_version: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: PolicyAssignment, or the result of cls(response) + :return: PolicyAssignment or the result of cls(response) :rtype: ~azure.mgmt.resource.policy.v2017_06_01_preview.models.PolicyAssignment - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.PolicyAssignment"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) - api_version = kwargs.pop('api_version', "2017-06-01-preview") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2017-06-01-preview")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[_models.PolicyAssignment] - request = build_policy_assignments_get_request( scope=scope, policy_assignment_name=policy_assignment_name, api_version=api_version, - template_url=self.get.metadata['url'], + template_url=self.get.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200]: @@ -1243,68 +1129,65 @@ def get( error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - deserialized = self._deserialize('PolicyAssignment', pipeline_response) + deserialized = self._deserialize("PolicyAssignment", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - get.metadata = {'url': "/{scope}/providers/Microsoft.Authorization/policyAssignments/{policyAssignmentName}"} # type: ignore - + get.metadata = {"url": "/{scope}/providers/Microsoft.Authorization/policyAssignments/{policyAssignmentName}"} # type: ignore @distributed_trace def list_for_resource_group( - self, - resource_group_name: str, - filter: Optional[str] = None, - **kwargs: Any - ) -> Iterable["_models.PolicyAssignmentListResult"]: + self, resource_group_name: str, filter: Optional[str] = None, **kwargs: Any + ) -> Iterable["_models.PolicyAssignment"]: """Gets policy assignments for the resource group. :param resource_group_name: The name of the resource group that contains policy assignments. + Required. :type resource_group_name: str :param filter: The filter to apply on the operation. Default value is None. :type filter: str - :keyword api_version: Api Version. Default value is "2017-06-01-preview". Note that overriding - this default value may result in unsupported behavior. - :paramtype api_version: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either PolicyAssignmentListResult or the result of - cls(response) + :return: An iterator like instance of either PolicyAssignment or the result of cls(response) :rtype: - ~azure.core.paging.ItemPaged[~azure.mgmt.resource.policy.v2017_06_01_preview.models.PolicyAssignmentListResult] - :raises: ~azure.core.exceptions.HttpResponseError + ~azure.core.paging.ItemPaged[~azure.mgmt.resource.policy.v2017_06_01_preview.models.PolicyAssignment] + :raises ~azure.core.exceptions.HttpResponseError: """ - api_version = kwargs.pop('api_version', "2017-06-01-preview") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2017-06-01-preview")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[_models.PolicyAssignmentListResult] - cls = kwargs.pop('cls', None) # type: ClsType["_models.PolicyAssignmentListResult"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) + def prepare_request(next_link=None): if not next_link: - + request = build_policy_assignments_list_for_resource_group_request( resource_group_name=resource_group_name, subscription_id=self._config.subscription_id, - api_version=api_version, filter=filter, - template_url=self.list_for_resource_group.metadata['url'], + api_version=api_version, + template_url=self.list_for_resource_group.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore else: - - request = build_policy_assignments_list_for_resource_group_request( - resource_group_name=resource_group_name, - subscription_id=self._config.subscription_id, - template_url=next_link, - ) + request = HttpRequest("GET", next_link) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore request.method = "GET" return request @@ -1318,10 +1201,8 @@ def extract_data(pipeline_response): def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) response = pipeline_response.http_response @@ -1332,11 +1213,9 @@ def get_next(next_link=None): return pipeline_response + return ItemPaged(get_next, extract_data) - return ItemPaged( - get_next, extract_data - ) - list_for_resource_group.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Authorization/policyAssignments"} # type: ignore + list_for_resource_group.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Authorization/policyAssignments"} # type: ignore @distributed_trace def list_for_resource( @@ -1348,42 +1227,45 @@ def list_for_resource( resource_name: str, filter: Optional[str] = None, **kwargs: Any - ) -> Iterable["_models.PolicyAssignmentListResult"]: + ) -> Iterable["_models.PolicyAssignment"]: """Gets policy assignments for a resource. :param resource_group_name: The name of the resource group containing the resource. The name is - case insensitive. + case insensitive. Required. :type resource_group_name: str - :param resource_provider_namespace: The namespace of the resource provider. + :param resource_provider_namespace: The namespace of the resource provider. Required. :type resource_provider_namespace: str - :param parent_resource_path: The parent resource path. + :param parent_resource_path: The parent resource path. Required. :type parent_resource_path: str - :param resource_type: The resource type. + :param resource_type: The resource type. Required. :type resource_type: str - :param resource_name: The name of the resource with policy assignments. + :param resource_name: The name of the resource with policy assignments. Required. :type resource_name: str :param filter: The filter to apply on the operation. Default value is None. :type filter: str - :keyword api_version: Api Version. Default value is "2017-06-01-preview". Note that overriding - this default value may result in unsupported behavior. - :paramtype api_version: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either PolicyAssignmentListResult or the result of - cls(response) + :return: An iterator like instance of either PolicyAssignment or the result of cls(response) :rtype: - ~azure.core.paging.ItemPaged[~azure.mgmt.resource.policy.v2017_06_01_preview.models.PolicyAssignmentListResult] - :raises: ~azure.core.exceptions.HttpResponseError + ~azure.core.paging.ItemPaged[~azure.mgmt.resource.policy.v2017_06_01_preview.models.PolicyAssignment] + :raises ~azure.core.exceptions.HttpResponseError: """ - api_version = kwargs.pop('api_version', "2017-06-01-preview") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2017-06-01-preview")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[_models.PolicyAssignmentListResult] - cls = kwargs.pop('cls', None) # type: ClsType["_models.PolicyAssignmentListResult"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) + def prepare_request(next_link=None): if not next_link: - + request = build_policy_assignments_list_for_resource_request( resource_group_name=resource_group_name, resource_provider_namespace=resource_provider_namespace, @@ -1391,26 +1273,19 @@ def prepare_request(next_link=None): resource_type=resource_type, resource_name=resource_name, subscription_id=self._config.subscription_id, - api_version=api_version, filter=filter, - template_url=self.list_for_resource.metadata['url'], + api_version=api_version, + template_url=self.list_for_resource.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore else: - - request = build_policy_assignments_list_for_resource_request( - resource_group_name=resource_group_name, - resource_provider_namespace=resource_provider_namespace, - parent_resource_path=parent_resource_path, - resource_type=resource_type, - resource_name=resource_name, - subscription_id=self._config.subscription_id, - template_url=next_link, - ) + request = HttpRequest("GET", next_link) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore request.method = "GET" return request @@ -1424,10 +1299,8 @@ def extract_data(pipeline_response): def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) response = pipeline_response.http_response @@ -1438,59 +1311,54 @@ def get_next(next_link=None): return pipeline_response + return ItemPaged(get_next, extract_data) - return ItemPaged( - get_next, extract_data - ) - list_for_resource.metadata = {'url': "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{parentResourcePath}/{resourceType}/{resourceName}/providers/Microsoft.Authorization/policyAssignments"} # type: ignore + list_for_resource.metadata = {"url": "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{parentResourcePath}/{resourceType}/{resourceName}/providers/Microsoft.Authorization/policyAssignments"} # type: ignore @distributed_trace - def list( - self, - filter: Optional[str] = None, - **kwargs: Any - ) -> Iterable["_models.PolicyAssignmentListResult"]: + def list(self, filter: Optional[str] = None, **kwargs: Any) -> Iterable["_models.PolicyAssignment"]: """Gets all the policy assignments for a subscription. :param filter: The filter to apply on the operation. Default value is None. :type filter: str - :keyword api_version: Api Version. Default value is "2017-06-01-preview". Note that overriding - this default value may result in unsupported behavior. - :paramtype api_version: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either PolicyAssignmentListResult or the result of - cls(response) + :return: An iterator like instance of either PolicyAssignment or the result of cls(response) :rtype: - ~azure.core.paging.ItemPaged[~azure.mgmt.resource.policy.v2017_06_01_preview.models.PolicyAssignmentListResult] - :raises: ~azure.core.exceptions.HttpResponseError + ~azure.core.paging.ItemPaged[~azure.mgmt.resource.policy.v2017_06_01_preview.models.PolicyAssignment] + :raises ~azure.core.exceptions.HttpResponseError: """ - api_version = kwargs.pop('api_version', "2017-06-01-preview") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2017-06-01-preview")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[_models.PolicyAssignmentListResult] - cls = kwargs.pop('cls', None) # type: ClsType["_models.PolicyAssignmentListResult"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) + def prepare_request(next_link=None): if not next_link: - + request = build_policy_assignments_list_request( subscription_id=self._config.subscription_id, - api_version=api_version, filter=filter, - template_url=self.list.metadata['url'], + 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.url = self._client.format_url(request.url) # type: ignore else: - - request = build_policy_assignments_list_request( - subscription_id=self._config.subscription_id, - template_url=next_link, - ) + request = HttpRequest("GET", next_link) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore request.method = "GET" return request @@ -1504,10 +1372,8 @@ def extract_data(pipeline_response): def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) response = pipeline_response.http_response @@ -1518,18 +1384,12 @@ def get_next(next_link=None): return pipeline_response + return ItemPaged(get_next, extract_data) - return ItemPaged( - get_next, extract_data - ) - list.metadata = {'url': "/subscriptions/{subscriptionId}/providers/Microsoft.Authorization/policyAssignments"} # type: ignore + list.metadata = {"url": "/subscriptions/{subscriptionId}/providers/Microsoft.Authorization/policyAssignments"} # type: ignore @distributed_trace - def delete_by_id( - self, - policy_assignment_id: str, - **kwargs: Any - ) -> "_models.PolicyAssignment": + def delete_by_id(self, policy_assignment_id: str, **kwargs: Any) -> _models.PolicyAssignment: """Deletes a policy assignment by ID. When providing a scope for the assignment, use '/subscriptions/{subscription-id}/' for @@ -1540,37 +1400,41 @@ def delete_by_id( :param policy_assignment_id: The ID of the policy assignment to delete. Use the format '/{scope}/providers/Microsoft.Authorization/policyAssignments/{policy-assignment-name}'. + Required. :type policy_assignment_id: str - :keyword api_version: Api Version. Default value is "2017-06-01-preview". Note that overriding - this default value may result in unsupported behavior. - :paramtype api_version: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: PolicyAssignment, or the result of cls(response) + :return: PolicyAssignment or the result of cls(response) :rtype: ~azure.mgmt.resource.policy.v2017_06_01_preview.models.PolicyAssignment - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.PolicyAssignment"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + 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', "2017-06-01-preview") # type: str + api_version = kwargs.pop("api_version", _params.pop("api-version", "2017-06-01-preview")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[_models.PolicyAssignment] - request = build_policy_assignments_delete_by_id_request( policy_assignment_id=policy_assignment_id, api_version=api_version, - template_url=self.delete_by_id.metadata['url'], + template_url=self.delete_by_id.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200]: @@ -1578,25 +1442,82 @@ def delete_by_id( error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - deserialized = self._deserialize('PolicyAssignment', pipeline_response) + deserialized = self._deserialize("PolicyAssignment", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - delete_by_id.metadata = {'url': "/{policyAssignmentId}"} # type: ignore + delete_by_id.metadata = {"url": "/{policyAssignmentId}"} # type: ignore + + @overload + def create_by_id( + self, + policy_assignment_id: str, + parameters: _models.PolicyAssignment, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.PolicyAssignment: + """Creates a policy assignment by ID. + + Policy assignments are inherited by child resources. For example, when you apply a policy to a + resource group that policy is assigned to all resources in the group. When providing a scope + for the assignment, use '/subscriptions/{subscription-id}/' for subscriptions, + '/subscriptions/{subscription-id}/resourceGroups/{resource-group-name}' for resource groups, + and + '/subscriptions/{subscription-id}/resourceGroups/{resource-group-name}/providers/{resource-provider-namespace}/{resource-type}/{resource-name}' + for resources. + + :param policy_assignment_id: The ID of the policy assignment to create. Use the format + '/{scope}/providers/Microsoft.Authorization/policyAssignments/{policy-assignment-name}'. + Required. + :type policy_assignment_id: str + :param parameters: Parameters for policy assignment. Required. + :type parameters: ~azure.mgmt.resource.policy.v2017_06_01_preview.models.PolicyAssignment + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: PolicyAssignment or the result of cls(response) + :rtype: ~azure.mgmt.resource.policy.v2017_06_01_preview.models.PolicyAssignment + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + def create_by_id( + self, policy_assignment_id: str, parameters: IO, *, content_type: str = "application/json", **kwargs: Any + ) -> _models.PolicyAssignment: + """Creates a policy assignment by ID. + + Policy assignments are inherited by child resources. For example, when you apply a policy to a + resource group that policy is assigned to all resources in the group. When providing a scope + for the assignment, use '/subscriptions/{subscription-id}/' for subscriptions, + '/subscriptions/{subscription-id}/resourceGroups/{resource-group-name}' for resource groups, + and + '/subscriptions/{subscription-id}/resourceGroups/{resource-group-name}/providers/{resource-provider-namespace}/{resource-type}/{resource-name}' + for resources. + :param policy_assignment_id: The ID of the policy assignment to create. Use the format + '/{scope}/providers/Microsoft.Authorization/policyAssignments/{policy-assignment-name}'. + Required. + :type policy_assignment_id: str + :param parameters: Parameters for policy assignment. Required. + :type parameters: IO + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Known values are: 'application/json', 'text/json'. Default value is "application/json". + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: PolicyAssignment or the result of cls(response) + :rtype: ~azure.mgmt.resource.policy.v2017_06_01_preview.models.PolicyAssignment + :raises ~azure.core.exceptions.HttpResponseError: + """ @distributed_trace def create_by_id( - self, - policy_assignment_id: str, - parameters: "_models.PolicyAssignment", - *, - content_type: Optional[str] = "application/json", - **kwargs: Any - ) -> "_models.PolicyAssignment": + self, policy_assignment_id: str, parameters: Union[_models.PolicyAssignment, IO], **kwargs: Any + ) -> _models.PolicyAssignment: """Creates a policy assignment by ID. Policy assignments are inherited by child resources. For example, when you apply a policy to a @@ -1609,45 +1530,59 @@ def create_by_id( :param policy_assignment_id: The ID of the policy assignment to create. Use the format '/{scope}/providers/Microsoft.Authorization/policyAssignments/{policy-assignment-name}'. + Required. :type policy_assignment_id: str - :param parameters: Parameters for policy assignment. - :type parameters: ~azure.mgmt.resource.policy.v2017_06_01_preview.models.PolicyAssignment - :keyword content_type: Media type of the body sent to the API. Possible values are: - "application/json" or "text/json". Default value is "application/json". + :param parameters: Parameters for policy assignment. Is either a model type or a IO type. + Required. + :type parameters: ~azure.mgmt.resource.policy.v2017_06_01_preview.models.PolicyAssignment or IO + :keyword content_type: Body Parameter content-type. Known values are: 'application/json', + 'text/json'. Default value is None. :paramtype content_type: str - :keyword api_version: Api Version. Default value is "2017-06-01-preview". Note that overriding - this default value may result in unsupported behavior. - :paramtype api_version: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: PolicyAssignment, or the result of cls(response) + :return: PolicyAssignment or the result of cls(response) :rtype: ~azure.mgmt.resource.policy.v2017_06_01_preview.models.PolicyAssignment - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.PolicyAssignment"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) - api_version = kwargs.pop('api_version', "2017-06-01-preview") # type: str + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - _json = self._serialize.body(parameters, 'PolicyAssignment') + api_version = kwargs.pop("api_version", _params.pop("api-version", "2017-06-01-preview")) # type: str + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.PolicyAssignment] + + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(parameters, (IO, bytes)): + _content = parameters + else: + _json = self._serialize.body(parameters, "PolicyAssignment") request = build_policy_assignments_create_by_id_request( policy_assignment_id=policy_assignment_id, api_version=api_version, content_type=content_type, json=_json, - template_url=self.create_by_id.metadata['url'], + content=_content, + template_url=self.create_by_id.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [201]: @@ -1655,22 +1590,17 @@ def create_by_id( error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - deserialized = self._deserialize('PolicyAssignment', pipeline_response) + deserialized = self._deserialize("PolicyAssignment", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - create_by_id.metadata = {'url': "/{policyAssignmentId}"} # type: ignore - + create_by_id.metadata = {"url": "/{policyAssignmentId}"} # type: ignore @distributed_trace - def get_by_id( - self, - policy_assignment_id: str, - **kwargs: Any - ) -> "_models.PolicyAssignment": + def get_by_id(self, policy_assignment_id: str, **kwargs: Any) -> _models.PolicyAssignment: """Gets a policy assignment by ID. When providing a scope for the assignment, use '/subscriptions/{subscription-id}/' for @@ -1681,37 +1611,41 @@ def get_by_id( :param policy_assignment_id: The ID of the policy assignment to get. Use the format '/{scope}/providers/Microsoft.Authorization/policyAssignments/{policy-assignment-name}'. + Required. :type policy_assignment_id: str - :keyword api_version: Api Version. Default value is "2017-06-01-preview". Note that overriding - this default value may result in unsupported behavior. - :paramtype api_version: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: PolicyAssignment, or the result of cls(response) + :return: PolicyAssignment or the result of cls(response) :rtype: ~azure.mgmt.resource.policy.v2017_06_01_preview.models.PolicyAssignment - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.PolicyAssignment"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) - api_version = kwargs.pop('api_version', "2017-06-01-preview") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2017-06-01-preview")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[_models.PolicyAssignment] - request = build_policy_assignments_get_by_id_request( policy_assignment_id=policy_assignment_id, api_version=api_version, - template_url=self.get_by_id.metadata['url'], + template_url=self.get_by_id.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200]: @@ -1719,72 +1653,120 @@ def get_by_id( error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - deserialized = self._deserialize('PolicyAssignment', pipeline_response) + deserialized = self._deserialize("PolicyAssignment", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - get_by_id.metadata = {'url': "/{policyAssignmentId}"} # type: ignore + get_by_id.metadata = {"url": "/{policyAssignmentId}"} # type: ignore -class PolicySetDefinitionsOperations(object): - """PolicySetDefinitionsOperations operations. - You should not instantiate this class directly. Instead, you should create a Client instance that - instantiates it for you and attaches it as an attribute. +class PolicySetDefinitionsOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. - :ivar models: Alias to model classes used in this operation group. - :type models: ~azure.mgmt.resource.policy.v2017_06_01_preview.models - :param client: Client for service requests. - :param config: Configuration of service client. - :param serializer: An object model serializer. - :param deserializer: An object model deserializer. + Instead, you should access the following operations through + :class:`~azure.mgmt.resource.policy.v2017_06_01_preview.PolicyClient`'s + :attr:`policy_set_definitions` attribute. """ models = _models - def __init__(self, client, config, serializer, deserializer): - self._client = client - self._serialize = serializer - self._deserialize = deserializer - self._config = config + def __init__(self, *args, **kwargs): + input_args = list(args) + self._client = input_args.pop(0) if input_args else kwargs.pop("client") + self._config = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") - @distributed_trace + @overload def create_or_update( self, policy_set_definition_name: str, - parameters: "_models.PolicySetDefinition", + parameters: _models.PolicySetDefinition, *, - content_type: Optional[str] = "application/json", + content_type: str = "application/json", **kwargs: Any - ) -> "_models.PolicySetDefinition": + ) -> _models.PolicySetDefinition: """Creates or updates a policy set definition. - :param policy_set_definition_name: The name of the policy set definition to create. + :param policy_set_definition_name: The name of the policy set definition to create. Required. :type policy_set_definition_name: str - :param parameters: The policy set definition properties. + :param parameters: The policy set definition properties. Required. :type parameters: ~azure.mgmt.resource.policy.v2017_06_01_preview.models.PolicySetDefinition - :keyword content_type: Media type of the body sent to the API. Possible values are: - "application/json" or "text/json". Default value is "application/json". + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: PolicySetDefinition or the result of cls(response) + :rtype: ~azure.mgmt.resource.policy.v2017_06_01_preview.models.PolicySetDefinition + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + def create_or_update( + self, policy_set_definition_name: str, parameters: IO, *, content_type: str = "application/json", **kwargs: Any + ) -> _models.PolicySetDefinition: + """Creates or updates a policy set definition. + + :param policy_set_definition_name: The name of the policy set definition to create. Required. + :type policy_set_definition_name: str + :param parameters: The policy set definition properties. Required. + :type parameters: IO + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Known values are: 'application/json', 'text/json'. Default value is "application/json". + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: PolicySetDefinition or the result of cls(response) + :rtype: ~azure.mgmt.resource.policy.v2017_06_01_preview.models.PolicySetDefinition + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace + def create_or_update( + self, policy_set_definition_name: str, parameters: Union[_models.PolicySetDefinition, IO], **kwargs: Any + ) -> _models.PolicySetDefinition: + """Creates or updates a policy set definition. + + :param policy_set_definition_name: The name of the policy set definition to create. Required. + :type policy_set_definition_name: str + :param parameters: The policy set definition properties. Is either a model type or a IO type. + Required. + :type parameters: ~azure.mgmt.resource.policy.v2017_06_01_preview.models.PolicySetDefinition or + IO + :keyword content_type: Body Parameter content-type. Known values are: 'application/json', + 'text/json'. Default value is None. :paramtype content_type: str - :keyword api_version: Api Version. Default value is "2017-06-01-preview". Note that overriding - this default value may result in unsupported behavior. - :paramtype api_version: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: PolicySetDefinition, or the result of cls(response) + :return: PolicySetDefinition or the result of cls(response) :rtype: ~azure.mgmt.resource.policy.v2017_06_01_preview.models.PolicySetDefinition - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.PolicySetDefinition"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', "2017-06-01-preview") # type: str + api_version = kwargs.pop("api_version", _params.pop("api-version", "2017-06-01-preview")) # type: str + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.PolicySetDefinition] - _json = self._serialize.body(parameters, 'PolicySetDefinition') + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(parameters, (IO, bytes)): + _content = parameters + else: + _json = self._serialize.body(parameters, "PolicySetDefinition") request = build_policy_set_definitions_create_or_update_request( policy_set_definition_name=policy_set_definition_name, @@ -1792,16 +1774,18 @@ def create_or_update( api_version=api_version, content_type=content_type, json=_json, - template_url=self.create_or_update.metadata['url'], + content=_content, + template_url=self.create_or_update.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200, 201]: @@ -1810,60 +1794,60 @@ def create_or_update( raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) if response.status_code == 200: - deserialized = self._deserialize('PolicySetDefinition', pipeline_response) + deserialized = self._deserialize("PolicySetDefinition", pipeline_response) if response.status_code == 201: - deserialized = self._deserialize('PolicySetDefinition', pipeline_response) + deserialized = self._deserialize("PolicySetDefinition", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - create_or_update.metadata = {'url': "/subscriptions/{subscriptionId}/providers/Microsoft.Authorization/policySetDefinitions/{policySetDefinitionName}"} # type: ignore - + create_or_update.metadata = {"url": "/subscriptions/{subscriptionId}/providers/Microsoft.Authorization/policySetDefinitions/{policySetDefinitionName}"} # type: ignore @distributed_trace def delete( # pylint: disable=inconsistent-return-statements - self, - policy_set_definition_name: str, - **kwargs: Any + self, policy_set_definition_name: str, **kwargs: Any ) -> None: """Deletes a policy set definition. - :param policy_set_definition_name: The name of the policy set definition to delete. + :param policy_set_definition_name: The name of the policy set definition to delete. Required. :type policy_set_definition_name: str - :keyword api_version: Api Version. Default value is "2017-06-01-preview". Note that overriding - this default value may result in unsupported behavior. - :paramtype api_version: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: None, or the result of cls(response) + :return: None or the result of cls(response) :rtype: None - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType[None] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + 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', "2017-06-01-preview") # type: str + api_version = kwargs.pop("api_version", _params.pop("api-version", "2017-06-01-preview")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[None] - request = build_policy_set_definitions_delete_request( policy_set_definition_name=policy_set_definition_name, subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.delete.metadata['url'], + template_url=self.delete.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200, 204]: @@ -1874,50 +1858,48 @@ def delete( # pylint: disable=inconsistent-return-statements if cls: return cls(pipeline_response, None, {}) - delete.metadata = {'url': "/subscriptions/{subscriptionId}/providers/Microsoft.Authorization/policySetDefinitions/{policySetDefinitionName}"} # type: ignore - + delete.metadata = {"url": "/subscriptions/{subscriptionId}/providers/Microsoft.Authorization/policySetDefinitions/{policySetDefinitionName}"} # type: ignore @distributed_trace - def get( - self, - policy_set_definition_name: str, - **kwargs: Any - ) -> "_models.PolicySetDefinition": + def get(self, policy_set_definition_name: str, **kwargs: Any) -> _models.PolicySetDefinition: """Gets the policy set definition. - :param policy_set_definition_name: The name of the policy set definition to get. + :param policy_set_definition_name: The name of the policy set definition to get. Required. :type policy_set_definition_name: str - :keyword api_version: Api Version. Default value is "2017-06-01-preview". Note that overriding - this default value may result in unsupported behavior. - :paramtype api_version: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: PolicySetDefinition, or the result of cls(response) + :return: PolicySetDefinition or the result of cls(response) :rtype: ~azure.mgmt.resource.policy.v2017_06_01_preview.models.PolicySetDefinition - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.PolicySetDefinition"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + 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', "2017-06-01-preview") # type: str + api_version = kwargs.pop("api_version", _params.pop("api-version", "2017-06-01-preview")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[_models.PolicySetDefinition] - request = build_policy_set_definitions_get_request( policy_set_definition_name=policy_set_definition_name, subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.get.metadata['url'], + template_url=self.get.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200]: @@ -1925,56 +1907,54 @@ def get( error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - deserialized = self._deserialize('PolicySetDefinition', pipeline_response) + deserialized = self._deserialize("PolicySetDefinition", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - get.metadata = {'url': "/subscriptions/{subscriptionId}/providers/Microsoft.Authorization/policySetDefinitions/{policySetDefinitionName}"} # type: ignore - + get.metadata = {"url": "/subscriptions/{subscriptionId}/providers/Microsoft.Authorization/policySetDefinitions/{policySetDefinitionName}"} # type: ignore @distributed_trace - def get_built_in( - self, - policy_set_definition_name: str, - **kwargs: Any - ) -> "_models.PolicySetDefinition": + def get_built_in(self, policy_set_definition_name: str, **kwargs: Any) -> _models.PolicySetDefinition: """Gets the built in policy set definition. - :param policy_set_definition_name: The name of the policy set definition to get. + :param policy_set_definition_name: The name of the policy set definition to get. Required. :type policy_set_definition_name: str - :keyword api_version: Api Version. Default value is "2017-06-01-preview". Note that overriding - this default value may result in unsupported behavior. - :paramtype api_version: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: PolicySetDefinition, or the result of cls(response) + :return: PolicySetDefinition or the result of cls(response) :rtype: ~azure.mgmt.resource.policy.v2017_06_01_preview.models.PolicySetDefinition - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.PolicySetDefinition"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + 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', "2017-06-01-preview") # type: str + api_version = kwargs.pop("api_version", _params.pop("api-version", "2017-06-01-preview")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[_models.PolicySetDefinition] - request = build_policy_set_definitions_get_built_in_request( policy_set_definition_name=policy_set_definition_name, api_version=api_version, - template_url=self.get_built_in.metadata['url'], + template_url=self.get_built_in.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200]: @@ -1982,59 +1962,56 @@ def get_built_in( error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - deserialized = self._deserialize('PolicySetDefinition', pipeline_response) + deserialized = self._deserialize("PolicySetDefinition", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - get_built_in.metadata = {'url': "/providers/Microsoft.Authorization/policySetDefinitions/{policySetDefinitionName}"} # type: ignore - + get_built_in.metadata = {"url": "/providers/Microsoft.Authorization/policySetDefinitions/{policySetDefinitionName}"} # type: ignore @distributed_trace - def list( - self, - **kwargs: Any - ) -> Iterable["_models.PolicySetDefinitionListResult"]: + def list(self, **kwargs: Any) -> Iterable["_models.PolicySetDefinition"]: """Gets all the policy set definitions for a subscription. - :keyword api_version: Api Version. Default value is "2017-06-01-preview". Note that overriding - this default value may result in unsupported behavior. - :paramtype api_version: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either PolicySetDefinitionListResult or the result of - cls(response) + :return: An iterator like instance of either PolicySetDefinition or the result of cls(response) :rtype: - ~azure.core.paging.ItemPaged[~azure.mgmt.resource.policy.v2017_06_01_preview.models.PolicySetDefinitionListResult] - :raises: ~azure.core.exceptions.HttpResponseError + ~azure.core.paging.ItemPaged[~azure.mgmt.resource.policy.v2017_06_01_preview.models.PolicySetDefinition] + :raises ~azure.core.exceptions.HttpResponseError: """ - api_version = kwargs.pop('api_version', "2017-06-01-preview") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2017-06-01-preview")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[_models.PolicySetDefinitionListResult] - cls = kwargs.pop('cls', None) # type: ClsType["_models.PolicySetDefinitionListResult"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) + def prepare_request(next_link=None): if not next_link: - + request = build_policy_set_definitions_list_request( subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.list.metadata['url'], + template_url=self.list.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore else: - - request = build_policy_set_definitions_list_request( - subscription_id=self._config.subscription_id, - template_url=next_link, - ) + request = HttpRequest("GET", next_link) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore request.method = "GET" return request @@ -2048,10 +2025,8 @@ def extract_data(pipeline_response): def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) response = pipeline_response.http_response @@ -2062,53 +2037,50 @@ def get_next(next_link=None): return pipeline_response + return ItemPaged(get_next, extract_data) - return ItemPaged( - get_next, extract_data - ) - list.metadata = {'url': "/subscriptions/{subscriptionId}/providers/Microsoft.Authorization/policySetDefinitions"} # type: ignore + list.metadata = {"url": "/subscriptions/{subscriptionId}/providers/Microsoft.Authorization/policySetDefinitions"} # type: ignore @distributed_trace - def list_built_in( - self, - **kwargs: Any - ) -> Iterable["_models.PolicySetDefinitionListResult"]: + def list_built_in(self, **kwargs: Any) -> Iterable["_models.PolicySetDefinition"]: """Gets all the built in policy set definitions. - :keyword api_version: Api Version. Default value is "2017-06-01-preview". Note that overriding - this default value may result in unsupported behavior. - :paramtype api_version: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either PolicySetDefinitionListResult or the result of - cls(response) + :return: An iterator like instance of either PolicySetDefinition or the result of cls(response) :rtype: - ~azure.core.paging.ItemPaged[~azure.mgmt.resource.policy.v2017_06_01_preview.models.PolicySetDefinitionListResult] - :raises: ~azure.core.exceptions.HttpResponseError + ~azure.core.paging.ItemPaged[~azure.mgmt.resource.policy.v2017_06_01_preview.models.PolicySetDefinition] + :raises ~azure.core.exceptions.HttpResponseError: """ - api_version = kwargs.pop('api_version', "2017-06-01-preview") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2017-06-01-preview")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[_models.PolicySetDefinitionListResult] - cls = kwargs.pop('cls', None) # type: ClsType["_models.PolicySetDefinitionListResult"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) + def prepare_request(next_link=None): if not next_link: - + request = build_policy_set_definitions_list_built_in_request( api_version=api_version, - template_url=self.list_built_in.metadata['url'], + template_url=self.list_built_in.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore else: - - request = build_policy_set_definitions_list_built_in_request( - template_url=next_link, - ) + request = HttpRequest("GET", next_link) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore request.method = "GET" return request @@ -2122,10 +2094,8 @@ def extract_data(pipeline_response): def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) response = pipeline_response.http_response @@ -2136,50 +2106,112 @@ def get_next(next_link=None): return pipeline_response + return ItemPaged(get_next, extract_data) - return ItemPaged( - get_next, extract_data - ) - list_built_in.metadata = {'url': "/providers/Microsoft.Authorization/policySetDefinitions"} # type: ignore + list_built_in.metadata = {"url": "/providers/Microsoft.Authorization/policySetDefinitions"} # type: ignore - @distributed_trace + @overload def create_or_update_at_management_group( self, policy_set_definition_name: str, management_group_id: str, - parameters: "_models.PolicySetDefinition", + parameters: _models.PolicySetDefinition, *, - content_type: Optional[str] = "application/json", + content_type: str = "application/json", **kwargs: Any - ) -> "_models.PolicySetDefinition": + ) -> _models.PolicySetDefinition: """Creates or updates a policy set definition at management group level. - :param policy_set_definition_name: The name of the policy set definition to create. + :param policy_set_definition_name: The name of the policy set definition to create. Required. :type policy_set_definition_name: str - :param management_group_id: The ID of the management group. + :param management_group_id: The ID of the management group. Required. :type management_group_id: str - :param parameters: The policy set definition properties. + :param parameters: The policy set definition properties. Required. :type parameters: ~azure.mgmt.resource.policy.v2017_06_01_preview.models.PolicySetDefinition - :keyword content_type: Media type of the body sent to the API. Possible values are: - "application/json" or "text/json". Default value is "application/json". + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: PolicySetDefinition or the result of cls(response) + :rtype: ~azure.mgmt.resource.policy.v2017_06_01_preview.models.PolicySetDefinition + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + def create_or_update_at_management_group( + self, + policy_set_definition_name: str, + management_group_id: str, + parameters: IO, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.PolicySetDefinition: + """Creates or updates a policy set definition at management group level. + + :param policy_set_definition_name: The name of the policy set definition to create. Required. + :type policy_set_definition_name: str + :param management_group_id: The ID of the management group. Required. + :type management_group_id: str + :param parameters: The policy set definition properties. Required. + :type parameters: IO + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Known values are: 'application/json', 'text/json'. Default value is "application/json". + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: PolicySetDefinition or the result of cls(response) + :rtype: ~azure.mgmt.resource.policy.v2017_06_01_preview.models.PolicySetDefinition + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace + def create_or_update_at_management_group( + self, + policy_set_definition_name: str, + management_group_id: str, + parameters: Union[_models.PolicySetDefinition, IO], + **kwargs: Any + ) -> _models.PolicySetDefinition: + """Creates or updates a policy set definition at management group level. + + :param policy_set_definition_name: The name of the policy set definition to create. Required. + :type policy_set_definition_name: str + :param management_group_id: The ID of the management group. Required. + :type management_group_id: str + :param parameters: The policy set definition properties. Is either a model type or a IO type. + Required. + :type parameters: ~azure.mgmt.resource.policy.v2017_06_01_preview.models.PolicySetDefinition or + IO + :keyword content_type: Body Parameter content-type. Known values are: 'application/json', + 'text/json'. Default value is None. :paramtype content_type: str - :keyword api_version: Api Version. Default value is "2017-06-01-preview". Note that overriding - this default value may result in unsupported behavior. - :paramtype api_version: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: PolicySetDefinition, or the result of cls(response) + :return: PolicySetDefinition or the result of cls(response) :rtype: ~azure.mgmt.resource.policy.v2017_06_01_preview.models.PolicySetDefinition - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.PolicySetDefinition"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) - api_version = kwargs.pop('api_version', "2017-06-01-preview") # type: str + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - _json = self._serialize.body(parameters, 'PolicySetDefinition') + api_version = kwargs.pop("api_version", _params.pop("api-version", "2017-06-01-preview")) # type: str + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.PolicySetDefinition] + + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(parameters, (IO, bytes)): + _content = parameters + else: + _json = self._serialize.body(parameters, "PolicySetDefinition") request = build_policy_set_definitions_create_or_update_at_management_group_request( policy_set_definition_name=policy_set_definition_name, @@ -2187,16 +2219,18 @@ def create_or_update_at_management_group( api_version=api_version, content_type=content_type, json=_json, - template_url=self.create_or_update_at_management_group.metadata['url'], + content=_content, + template_url=self.create_or_update_at_management_group.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200, 201]: @@ -2205,63 +2239,62 @@ def create_or_update_at_management_group( raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) if response.status_code == 200: - deserialized = self._deserialize('PolicySetDefinition', pipeline_response) + deserialized = self._deserialize("PolicySetDefinition", pipeline_response) if response.status_code == 201: - deserialized = self._deserialize('PolicySetDefinition', pipeline_response) + deserialized = self._deserialize("PolicySetDefinition", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - create_or_update_at_management_group.metadata = {'url': "/providers/Microsoft.Management/managementgroups/{managementGroupId}/providers/Microsoft.Authorization/policySetDefinitions/{policySetDefinitionName}"} # type: ignore - + create_or_update_at_management_group.metadata = {"url": "/providers/Microsoft.Management/managementgroups/{managementGroupId}/providers/Microsoft.Authorization/policySetDefinitions/{policySetDefinitionName}"} # type: ignore @distributed_trace def delete_at_management_group( # pylint: disable=inconsistent-return-statements - self, - policy_set_definition_name: str, - management_group_id: str, - **kwargs: Any + self, policy_set_definition_name: str, management_group_id: str, **kwargs: Any ) -> None: """Deletes a policy set definition at management group level. - :param policy_set_definition_name: The name of the policy set definition to delete. + :param policy_set_definition_name: The name of the policy set definition to delete. Required. :type policy_set_definition_name: str - :param management_group_id: The ID of the management group. + :param management_group_id: The ID of the management group. Required. :type management_group_id: str - :keyword api_version: Api Version. Default value is "2017-06-01-preview". Note that overriding - this default value may result in unsupported behavior. - :paramtype api_version: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: None, or the result of cls(response) + :return: None or the result of cls(response) :rtype: None - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType[None] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + 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', "2017-06-01-preview") # type: str + api_version = kwargs.pop("api_version", _params.pop("api-version", "2017-06-01-preview")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[None] - request = build_policy_set_definitions_delete_at_management_group_request( policy_set_definition_name=policy_set_definition_name, management_group_id=management_group_id, api_version=api_version, - template_url=self.delete_at_management_group.metadata['url'], + template_url=self.delete_at_management_group.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200, 204]: @@ -2272,53 +2305,52 @@ def delete_at_management_group( # pylint: disable=inconsistent-return-statement if cls: return cls(pipeline_response, None, {}) - delete_at_management_group.metadata = {'url': "/providers/Microsoft.Management/managementgroups/{managementGroupId}/providers/Microsoft.Authorization/policySetDefinitions/{policySetDefinitionName}"} # type: ignore - + delete_at_management_group.metadata = {"url": "/providers/Microsoft.Management/managementgroups/{managementGroupId}/providers/Microsoft.Authorization/policySetDefinitions/{policySetDefinitionName}"} # type: ignore @distributed_trace def get_at_management_group( - self, - policy_set_definition_name: str, - management_group_id: str, - **kwargs: Any - ) -> "_models.PolicySetDefinition": + self, policy_set_definition_name: str, management_group_id: str, **kwargs: Any + ) -> _models.PolicySetDefinition: """Gets the policy set definition at management group level. - :param policy_set_definition_name: The name of the policy set definition to get. + :param policy_set_definition_name: The name of the policy set definition to get. Required. :type policy_set_definition_name: str - :param management_group_id: The ID of the management group. + :param management_group_id: The ID of the management group. Required. :type management_group_id: str - :keyword api_version: Api Version. Default value is "2017-06-01-preview". Note that overriding - this default value may result in unsupported behavior. - :paramtype api_version: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: PolicySetDefinition, or the result of cls(response) + :return: PolicySetDefinition or the result of cls(response) :rtype: ~azure.mgmt.resource.policy.v2017_06_01_preview.models.PolicySetDefinition - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.PolicySetDefinition"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) - api_version = kwargs.pop('api_version', "2017-06-01-preview") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2017-06-01-preview")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[_models.PolicySetDefinition] - request = build_policy_set_definitions_get_at_management_group_request( policy_set_definition_name=policy_set_definition_name, management_group_id=management_group_id, api_version=api_version, - template_url=self.get_at_management_group.metadata['url'], + template_url=self.get_at_management_group.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200]: @@ -2326,62 +2358,60 @@ def get_at_management_group( error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - deserialized = self._deserialize('PolicySetDefinition', pipeline_response) + deserialized = self._deserialize("PolicySetDefinition", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - get_at_management_group.metadata = {'url': "/providers/Microsoft.Management/managementgroups/{managementGroupId}/providers/Microsoft.Authorization/policySetDefinitions/{policySetDefinitionName}"} # type: ignore - + get_at_management_group.metadata = {"url": "/providers/Microsoft.Management/managementgroups/{managementGroupId}/providers/Microsoft.Authorization/policySetDefinitions/{policySetDefinitionName}"} # type: ignore @distributed_trace def list_by_management_group( - self, - management_group_id: str, - **kwargs: Any - ) -> Iterable["_models.PolicySetDefinitionListResult"]: + self, management_group_id: str, **kwargs: Any + ) -> Iterable["_models.PolicySetDefinition"]: """Gets all the policy set definitions for a subscription at management group. - :param management_group_id: The ID of the management group. + :param management_group_id: The ID of the management group. Required. :type management_group_id: str - :keyword api_version: Api Version. Default value is "2017-06-01-preview". Note that overriding - this default value may result in unsupported behavior. - :paramtype api_version: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either PolicySetDefinitionListResult or the result of - cls(response) + :return: An iterator like instance of either PolicySetDefinition or the result of cls(response) :rtype: - ~azure.core.paging.ItemPaged[~azure.mgmt.resource.policy.v2017_06_01_preview.models.PolicySetDefinitionListResult] - :raises: ~azure.core.exceptions.HttpResponseError + ~azure.core.paging.ItemPaged[~azure.mgmt.resource.policy.v2017_06_01_preview.models.PolicySetDefinition] + :raises ~azure.core.exceptions.HttpResponseError: """ - api_version = kwargs.pop('api_version', "2017-06-01-preview") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2017-06-01-preview")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[_models.PolicySetDefinitionListResult] - cls = kwargs.pop('cls', None) # type: ClsType["_models.PolicySetDefinitionListResult"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) + def prepare_request(next_link=None): if not next_link: - + request = build_policy_set_definitions_list_by_management_group_request( management_group_id=management_group_id, api_version=api_version, - template_url=self.list_by_management_group.metadata['url'], + template_url=self.list_by_management_group.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore else: - - request = build_policy_set_definitions_list_by_management_group_request( - management_group_id=management_group_id, - template_url=next_link, - ) + request = HttpRequest("GET", next_link) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore request.method = "GET" return request @@ -2395,10 +2425,8 @@ def extract_data(pipeline_response): def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) response = pipeline_response.http_response @@ -2409,68 +2437,114 @@ def get_next(next_link=None): return pipeline_response + return ItemPaged(get_next, extract_data) - return ItemPaged( - get_next, extract_data - ) - list_by_management_group.metadata = {'url': "/providers/Microsoft.Management/managementgroups/{managementGroupId}/providers/Microsoft.Authorization/policySetDefinitions"} # type: ignore -class PolicyDefinitionsOperations(object): - """PolicyDefinitionsOperations operations. - - You should not instantiate this class directly. Instead, you should create a Client instance that - instantiates it for you and attaches it as an attribute. - - :ivar models: Alias to model classes used in this operation group. - :type models: ~azure.mgmt.resource.policy.v2017_06_01_preview.models - :param client: Client for service requests. - :param config: Configuration of service client. - :param serializer: An object model serializer. - :param deserializer: An object model deserializer. + list_by_management_group.metadata = {"url": "/providers/Microsoft.Management/managementgroups/{managementGroupId}/providers/Microsoft.Authorization/policySetDefinitions"} # type: ignore + + +class PolicyDefinitionsOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. + + Instead, you should access the following operations through + :class:`~azure.mgmt.resource.policy.v2017_06_01_preview.PolicyClient`'s + :attr:`policy_definitions` attribute. """ models = _models - def __init__(self, client, config, serializer, deserializer): - self._client = client - self._serialize = serializer - self._deserialize = deserializer - self._config = config + def __init__(self, *args, **kwargs): + input_args = list(args) + self._client = input_args.pop(0) if input_args else kwargs.pop("client") + self._config = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") - @distributed_trace + @overload def create_or_update( self, policy_definition_name: str, - parameters: "_models.PolicyDefinition", + parameters: _models.PolicyDefinition, *, - content_type: Optional[str] = "application/json", + content_type: str = "application/json", **kwargs: Any - ) -> "_models.PolicyDefinition": + ) -> _models.PolicyDefinition: """Creates or updates a policy definition. - :param policy_definition_name: The name of the policy definition to create. + :param policy_definition_name: The name of the policy definition to create. Required. :type policy_definition_name: str - :param parameters: The policy definition properties. + :param parameters: The policy definition properties. Required. :type parameters: ~azure.mgmt.resource.policy.v2017_06_01_preview.models.PolicyDefinition - :keyword content_type: Media type of the body sent to the API. Possible values are: - "application/json" or "text/json". Default value is "application/json". + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: PolicyDefinition or the result of cls(response) + :rtype: ~azure.mgmt.resource.policy.v2017_06_01_preview.models.PolicyDefinition + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + def create_or_update( + self, policy_definition_name: str, parameters: IO, *, content_type: str = "application/json", **kwargs: Any + ) -> _models.PolicyDefinition: + """Creates or updates a policy definition. + + :param policy_definition_name: The name of the policy definition to create. Required. + :type policy_definition_name: str + :param parameters: The policy definition properties. Required. + :type parameters: IO + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Known values are: 'application/json', 'text/json'. Default value is "application/json". + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: PolicyDefinition or the result of cls(response) + :rtype: ~azure.mgmt.resource.policy.v2017_06_01_preview.models.PolicyDefinition + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace + def create_or_update( + self, policy_definition_name: str, parameters: Union[_models.PolicyDefinition, IO], **kwargs: Any + ) -> _models.PolicyDefinition: + """Creates or updates a policy definition. + + :param policy_definition_name: The name of the policy definition to create. Required. + :type policy_definition_name: str + :param parameters: The policy definition properties. Is either a model type or a IO type. + Required. + :type parameters: ~azure.mgmt.resource.policy.v2017_06_01_preview.models.PolicyDefinition or IO + :keyword content_type: Body Parameter content-type. Known values are: 'application/json', + 'text/json'. Default value is None. :paramtype content_type: str - :keyword api_version: Api Version. Default value is "2016-12-01". Note that overriding this - default value may result in unsupported behavior. - :paramtype api_version: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: PolicyDefinition, or the result of cls(response) + :return: PolicyDefinition or the result of cls(response) :rtype: ~azure.mgmt.resource.policy.v2017_06_01_preview.models.PolicyDefinition - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.PolicyDefinition"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', "2016-12-01") # type: str + api_version = kwargs.pop("api_version", _params.pop("api-version", "2016-12-01")) # type: str + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.PolicyDefinition] - _json = self._serialize.body(parameters, 'PolicyDefinition') + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(parameters, (IO, bytes)): + _content = parameters + else: + _json = self._serialize.body(parameters, "PolicyDefinition") request = build_policy_definitions_create_or_update_request( policy_definition_name=policy_definition_name, @@ -2478,73 +2552,75 @@ def create_or_update( api_version=api_version, content_type=content_type, json=_json, - template_url=self.create_or_update.metadata['url'], + content=_content, + template_url=self.create_or_update.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [201]: map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) - deserialized = self._deserialize('PolicyDefinition', pipeline_response) + deserialized = self._deserialize("PolicyDefinition", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - create_or_update.metadata = {'url': "/subscriptions/{subscriptionId}/providers/Microsoft.Authorization/policyDefinitions/{policyDefinitionName}"} # type: ignore - + create_or_update.metadata = {"url": "/subscriptions/{subscriptionId}/providers/Microsoft.Authorization/policyDefinitions/{policyDefinitionName}"} # type: ignore @distributed_trace def delete( # pylint: disable=inconsistent-return-statements - self, - policy_definition_name: str, - **kwargs: Any + self, policy_definition_name: str, **kwargs: Any ) -> None: """Deletes a policy definition. - :param policy_definition_name: The name of the policy definition to delete. + :param policy_definition_name: The name of the policy definition to delete. Required. :type policy_definition_name: str - :keyword api_version: Api Version. Default value is "2016-12-01". Note that overriding this - default value may result in unsupported behavior. - :paramtype api_version: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: None, or the result of cls(response) + :return: None or the result of cls(response) :rtype: None - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType[None] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + 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', "2016-12-01") # type: str + api_version = kwargs.pop("api_version", _params.pop("api-version", "2016-12-01")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[None] - request = build_policy_definitions_delete_request( policy_definition_name=policy_definition_name, subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.delete.metadata['url'], + template_url=self.delete.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200, 204]: @@ -2554,160 +2630,218 @@ def delete( # pylint: disable=inconsistent-return-statements if cls: return cls(pipeline_response, None, {}) - delete.metadata = {'url': "/subscriptions/{subscriptionId}/providers/Microsoft.Authorization/policyDefinitions/{policyDefinitionName}"} # type: ignore - + delete.metadata = {"url": "/subscriptions/{subscriptionId}/providers/Microsoft.Authorization/policyDefinitions/{policyDefinitionName}"} # type: ignore @distributed_trace - def get( - self, - policy_definition_name: str, - **kwargs: Any - ) -> "_models.PolicyDefinition": + def get(self, policy_definition_name: str, **kwargs: Any) -> _models.PolicyDefinition: """Gets the policy definition. - :param policy_definition_name: The name of the policy definition to get. + :param policy_definition_name: The name of the policy definition to get. Required. :type policy_definition_name: str - :keyword api_version: Api Version. Default value is "2016-12-01". Note that overriding this - default value may result in unsupported behavior. - :paramtype api_version: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: PolicyDefinition, or the result of cls(response) + :return: PolicyDefinition or the result of cls(response) :rtype: ~azure.mgmt.resource.policy.v2017_06_01_preview.models.PolicyDefinition - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.PolicyDefinition"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + 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', "2016-12-01") # type: str + api_version = kwargs.pop("api_version", _params.pop("api-version", "2016-12-01")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[_models.PolicyDefinition] - request = build_policy_definitions_get_request( policy_definition_name=policy_definition_name, subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.get.metadata['url'], + template_url=self.get.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) - deserialized = self._deserialize('PolicyDefinition', pipeline_response) + deserialized = self._deserialize("PolicyDefinition", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - get.metadata = {'url': "/subscriptions/{subscriptionId}/providers/Microsoft.Authorization/policyDefinitions/{policyDefinitionName}"} # type: ignore - + get.metadata = {"url": "/subscriptions/{subscriptionId}/providers/Microsoft.Authorization/policyDefinitions/{policyDefinitionName}"} # type: ignore @distributed_trace - def get_built_in( - self, - policy_definition_name: str, - **kwargs: Any - ) -> "_models.PolicyDefinition": + def get_built_in(self, policy_definition_name: str, **kwargs: Any) -> _models.PolicyDefinition: """Gets the built in policy definition. - :param policy_definition_name: The name of the built in policy definition to get. + :param policy_definition_name: The name of the built in policy definition to get. Required. :type policy_definition_name: str - :keyword api_version: Api Version. Default value is "2016-12-01". Note that overriding this - default value may result in unsupported behavior. - :paramtype api_version: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: PolicyDefinition, or the result of cls(response) + :return: PolicyDefinition or the result of cls(response) :rtype: ~azure.mgmt.resource.policy.v2017_06_01_preview.models.PolicyDefinition - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.PolicyDefinition"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + 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', "2016-12-01") # type: str + api_version = kwargs.pop("api_version", _params.pop("api-version", "2016-12-01")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[_models.PolicyDefinition] - request = build_policy_definitions_get_built_in_request( policy_definition_name=policy_definition_name, api_version=api_version, - template_url=self.get_built_in.metadata['url'], + template_url=self.get_built_in.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) - deserialized = self._deserialize('PolicyDefinition', pipeline_response) + deserialized = self._deserialize("PolicyDefinition", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - get_built_in.metadata = {'url': "/providers/Microsoft.Authorization/policyDefinitions/{policyDefinitionName}"} # type: ignore - + get_built_in.metadata = {"url": "/providers/Microsoft.Authorization/policyDefinitions/{policyDefinitionName}"} # type: ignore - @distributed_trace + @overload def create_or_update_at_management_group( self, policy_definition_name: str, management_group_id: str, - parameters: "_models.PolicyDefinition", + parameters: _models.PolicyDefinition, *, - content_type: Optional[str] = "application/json", + content_type: str = "application/json", **kwargs: Any - ) -> "_models.PolicyDefinition": + ) -> _models.PolicyDefinition: """Creates or updates a policy definition at management group level. - :param policy_definition_name: The name of the policy definition to create. + :param policy_definition_name: The name of the policy definition to create. Required. :type policy_definition_name: str - :param management_group_id: The ID of the management group. + :param management_group_id: The ID of the management group. Required. :type management_group_id: str - :param parameters: The policy definition properties. + :param parameters: The policy definition properties. Required. :type parameters: ~azure.mgmt.resource.policy.v2017_06_01_preview.models.PolicyDefinition - :keyword content_type: Media type of the body sent to the API. Possible values are: - "application/json" or "text/json". Default value is "application/json". + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: PolicyDefinition or the result of cls(response) + :rtype: ~azure.mgmt.resource.policy.v2017_06_01_preview.models.PolicyDefinition + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + def create_or_update_at_management_group( + self, + policy_definition_name: str, + management_group_id: str, + parameters: IO, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.PolicyDefinition: + """Creates or updates a policy definition at management group level. + + :param policy_definition_name: The name of the policy definition to create. Required. + :type policy_definition_name: str + :param management_group_id: The ID of the management group. Required. + :type management_group_id: str + :param parameters: The policy definition properties. Required. + :type parameters: IO + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Known values are: 'application/json', 'text/json'. Default value is "application/json". + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: PolicyDefinition or the result of cls(response) + :rtype: ~azure.mgmt.resource.policy.v2017_06_01_preview.models.PolicyDefinition + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace + def create_or_update_at_management_group( + self, + policy_definition_name: str, + management_group_id: str, + parameters: Union[_models.PolicyDefinition, IO], + **kwargs: Any + ) -> _models.PolicyDefinition: + """Creates or updates a policy definition at management group level. + + :param policy_definition_name: The name of the policy definition to create. Required. + :type policy_definition_name: str + :param management_group_id: The ID of the management group. Required. + :type management_group_id: str + :param parameters: The policy definition properties. Is either a model type or a IO type. + Required. + :type parameters: ~azure.mgmt.resource.policy.v2017_06_01_preview.models.PolicyDefinition or IO + :keyword content_type: Body Parameter content-type. Known values are: 'application/json', + 'text/json'. Default value is None. :paramtype content_type: str - :keyword api_version: Api Version. Default value is "2016-12-01". Note that overriding this - default value may result in unsupported behavior. - :paramtype api_version: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: PolicyDefinition, or the result of cls(response) + :return: PolicyDefinition or the result of cls(response) :rtype: ~azure.mgmt.resource.policy.v2017_06_01_preview.models.PolicyDefinition - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.PolicyDefinition"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', "2016-12-01") # type: str + api_version = kwargs.pop("api_version", _params.pop("api-version", "2016-12-01")) # type: str + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.PolicyDefinition] - _json = self._serialize.body(parameters, 'PolicyDefinition') + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(parameters, (IO, bytes)): + _content = parameters + else: + _json = self._serialize.body(parameters, "PolicyDefinition") request = build_policy_definitions_create_or_update_at_management_group_request( policy_definition_name=policy_definition_name, @@ -2715,76 +2849,77 @@ def create_or_update_at_management_group( api_version=api_version, content_type=content_type, json=_json, - template_url=self.create_or_update_at_management_group.metadata['url'], + content=_content, + template_url=self.create_or_update_at_management_group.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [201]: map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) - deserialized = self._deserialize('PolicyDefinition', pipeline_response) + deserialized = self._deserialize("PolicyDefinition", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - create_or_update_at_management_group.metadata = {'url': "/providers/Microsoft.Management/managementgroups/{managementGroupId}/providers/Microsoft.Authorization/policyDefinitions/{policyDefinitionName}"} # type: ignore - + create_or_update_at_management_group.metadata = {"url": "/providers/Microsoft.Management/managementgroups/{managementGroupId}/providers/Microsoft.Authorization/policyDefinitions/{policyDefinitionName}"} # type: ignore @distributed_trace def delete_at_management_group( # pylint: disable=inconsistent-return-statements - self, - policy_definition_name: str, - management_group_id: str, - **kwargs: Any + self, policy_definition_name: str, management_group_id: str, **kwargs: Any ) -> None: """Deletes a policy definition at management group level. - :param policy_definition_name: The name of the policy definition to delete. + :param policy_definition_name: The name of the policy definition to delete. Required. :type policy_definition_name: str - :param management_group_id: The ID of the management group. + :param management_group_id: The ID of the management group. Required. :type management_group_id: str - :keyword api_version: Api Version. Default value is "2016-12-01". Note that overriding this - default value may result in unsupported behavior. - :paramtype api_version: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: None, or the result of cls(response) + :return: None or the result of cls(response) :rtype: None - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType[None] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) - api_version = kwargs.pop('api_version', "2016-12-01") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2016-12-01")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[None] - request = build_policy_definitions_delete_at_management_group_request( policy_definition_name=policy_definition_name, management_group_id=management_group_id, api_version=api_version, - template_url=self.delete_at_management_group.metadata['url'], + template_url=self.delete_at_management_group.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200, 204]: @@ -2794,112 +2929,108 @@ def delete_at_management_group( # pylint: disable=inconsistent-return-statement if cls: return cls(pipeline_response, None, {}) - delete_at_management_group.metadata = {'url': "/providers/Microsoft.Management/managementgroups/{managementGroupId}/providers/Microsoft.Authorization/policyDefinitions/{policyDefinitionName}"} # type: ignore - + delete_at_management_group.metadata = {"url": "/providers/Microsoft.Management/managementgroups/{managementGroupId}/providers/Microsoft.Authorization/policyDefinitions/{policyDefinitionName}"} # type: ignore @distributed_trace def get_at_management_group( - self, - policy_definition_name: str, - management_group_id: str, - **kwargs: Any - ) -> "_models.PolicyDefinition": + self, policy_definition_name: str, management_group_id: str, **kwargs: Any + ) -> _models.PolicyDefinition: """Gets the policy definition at management group level. - :param policy_definition_name: The name of the policy definition to get. + :param policy_definition_name: The name of the policy definition to get. Required. :type policy_definition_name: str - :param management_group_id: The ID of the management group. + :param management_group_id: The ID of the management group. Required. :type management_group_id: str - :keyword api_version: Api Version. Default value is "2016-12-01". Note that overriding this - default value may result in unsupported behavior. - :paramtype api_version: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: PolicyDefinition, or the result of cls(response) + :return: PolicyDefinition or the result of cls(response) :rtype: ~azure.mgmt.resource.policy.v2017_06_01_preview.models.PolicyDefinition - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.PolicyDefinition"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + 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', "2016-12-01") # type: str + api_version = kwargs.pop("api_version", _params.pop("api-version", "2016-12-01")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[_models.PolicyDefinition] - request = build_policy_definitions_get_at_management_group_request( policy_definition_name=policy_definition_name, management_group_id=management_group_id, api_version=api_version, - template_url=self.get_at_management_group.metadata['url'], + template_url=self.get_at_management_group.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) - deserialized = self._deserialize('PolicyDefinition', pipeline_response) + deserialized = self._deserialize("PolicyDefinition", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - get_at_management_group.metadata = {'url': "/providers/Microsoft.Management/managementgroups/{managementGroupId}/providers/Microsoft.Authorization/policyDefinitions/{policyDefinitionName}"} # type: ignore - + get_at_management_group.metadata = {"url": "/providers/Microsoft.Management/managementgroups/{managementGroupId}/providers/Microsoft.Authorization/policyDefinitions/{policyDefinitionName}"} # type: ignore @distributed_trace - def list( - self, - **kwargs: Any - ) -> Iterable["_models.PolicyDefinitionListResult"]: + def list(self, **kwargs: Any) -> Iterable["_models.PolicyDefinition"]: """Gets all the policy definitions for a subscription. - :keyword api_version: Api Version. Default value is "2016-12-01". Note that overriding this - default value may result in unsupported behavior. - :paramtype api_version: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either PolicyDefinitionListResult or the result of - cls(response) + :return: An iterator like instance of either PolicyDefinition or the result of cls(response) :rtype: - ~azure.core.paging.ItemPaged[~azure.mgmt.resource.policy.v2017_06_01_preview.models.PolicyDefinitionListResult] - :raises: ~azure.core.exceptions.HttpResponseError + ~azure.core.paging.ItemPaged[~azure.mgmt.resource.policy.v2017_06_01_preview.models.PolicyDefinition] + :raises ~azure.core.exceptions.HttpResponseError: """ - api_version = kwargs.pop('api_version', "2016-12-01") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2016-12-01")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[_models.PolicyDefinitionListResult] - cls = kwargs.pop('cls', None) # type: ClsType["_models.PolicyDefinitionListResult"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) + def prepare_request(next_link=None): if not next_link: - + request = build_policy_definitions_list_request( subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.list.metadata['url'], + template_url=self.list.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore else: - - request = build_policy_definitions_list_request( - subscription_id=self._config.subscription_id, - template_url=next_link, - ) + request = HttpRequest("GET", next_link) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore request.method = "GET" return request @@ -2913,10 +3044,8 @@ def extract_data(pipeline_response): def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) response = pipeline_response.http_response @@ -2926,53 +3055,50 @@ def get_next(next_link=None): return pipeline_response + return ItemPaged(get_next, extract_data) - return ItemPaged( - get_next, extract_data - ) - list.metadata = {'url': "/subscriptions/{subscriptionId}/providers/Microsoft.Authorization/policyDefinitions"} # type: ignore + list.metadata = {"url": "/subscriptions/{subscriptionId}/providers/Microsoft.Authorization/policyDefinitions"} # type: ignore @distributed_trace - def list_built_in( - self, - **kwargs: Any - ) -> Iterable["_models.PolicyDefinitionListResult"]: + def list_built_in(self, **kwargs: Any) -> Iterable["_models.PolicyDefinition"]: """Gets all the built in policy definitions. - :keyword api_version: Api Version. Default value is "2016-12-01". Note that overriding this - default value may result in unsupported behavior. - :paramtype api_version: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either PolicyDefinitionListResult or the result of - cls(response) + :return: An iterator like instance of either PolicyDefinition or the result of cls(response) :rtype: - ~azure.core.paging.ItemPaged[~azure.mgmt.resource.policy.v2017_06_01_preview.models.PolicyDefinitionListResult] - :raises: ~azure.core.exceptions.HttpResponseError + ~azure.core.paging.ItemPaged[~azure.mgmt.resource.policy.v2017_06_01_preview.models.PolicyDefinition] + :raises ~azure.core.exceptions.HttpResponseError: """ - api_version = kwargs.pop('api_version', "2016-12-01") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2016-12-01")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[_models.PolicyDefinitionListResult] - cls = kwargs.pop('cls', None) # type: ClsType["_models.PolicyDefinitionListResult"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) + def prepare_request(next_link=None): if not next_link: - + request = build_policy_definitions_list_built_in_request( api_version=api_version, - template_url=self.list_built_in.metadata['url'], + template_url=self.list_built_in.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore else: - - request = build_policy_definitions_list_built_in_request( - template_url=next_link, - ) + request = HttpRequest("GET", next_link) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore request.method = "GET" return request @@ -2986,10 +3112,8 @@ def extract_data(pipeline_response): def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) response = pipeline_response.http_response @@ -2999,58 +3123,53 @@ def get_next(next_link=None): return pipeline_response + return ItemPaged(get_next, extract_data) - return ItemPaged( - get_next, extract_data - ) - list_built_in.metadata = {'url': "/providers/Microsoft.Authorization/policyDefinitions"} # type: ignore + list_built_in.metadata = {"url": "/providers/Microsoft.Authorization/policyDefinitions"} # type: ignore @distributed_trace - def list_by_management_group( - self, - management_group_id: str, - **kwargs: Any - ) -> Iterable["_models.PolicyDefinitionListResult"]: + def list_by_management_group(self, management_group_id: str, **kwargs: Any) -> Iterable["_models.PolicyDefinition"]: """Gets all the policy definitions for a subscription at management group level. - :param management_group_id: The ID of the management group. + :param management_group_id: The ID of the management group. Required. :type management_group_id: str - :keyword api_version: Api Version. Default value is "2016-12-01". Note that overriding this - default value may result in unsupported behavior. - :paramtype api_version: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either PolicyDefinitionListResult or the result of - cls(response) + :return: An iterator like instance of either PolicyDefinition or the result of cls(response) :rtype: - ~azure.core.paging.ItemPaged[~azure.mgmt.resource.policy.v2017_06_01_preview.models.PolicyDefinitionListResult] - :raises: ~azure.core.exceptions.HttpResponseError + ~azure.core.paging.ItemPaged[~azure.mgmt.resource.policy.v2017_06_01_preview.models.PolicyDefinition] + :raises ~azure.core.exceptions.HttpResponseError: """ - api_version = kwargs.pop('api_version', "2016-12-01") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2016-12-01")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[_models.PolicyDefinitionListResult] - cls = kwargs.pop('cls', None) # type: ClsType["_models.PolicyDefinitionListResult"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) + def prepare_request(next_link=None): if not next_link: - + request = build_policy_definitions_list_by_management_group_request( management_group_id=management_group_id, api_version=api_version, - template_url=self.list_by_management_group.metadata['url'], + template_url=self.list_by_management_group.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore else: - - request = build_policy_definitions_list_by_management_group_request( - management_group_id=management_group_id, - template_url=next_link, - ) + request = HttpRequest("GET", next_link) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore request.method = "GET" return request @@ -3064,10 +3183,8 @@ def extract_data(pipeline_response): def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) response = pipeline_response.http_response @@ -3077,8 +3194,6 @@ def get_next(next_link=None): return pipeline_response + return ItemPaged(get_next, extract_data) - return ItemPaged( - get_next, extract_data - ) - list_by_management_group.metadata = {'url': "/providers/Microsoft.Management/managementgroups/{managementGroupId}/providers/Microsoft.Authorization/policyDefinitions"} # type: ignore + list_by_management_group.metadata = {"url": "/providers/Microsoft.Management/managementgroups/{managementGroupId}/providers/Microsoft.Authorization/policyDefinitions"} # type: ignore diff --git a/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/policy/v2017_06_01_preview/operations/_patch.py b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/policy/v2017_06_01_preview/operations/_patch.py new file mode 100644 index 0000000000000..f7dd32510333d --- /dev/null +++ b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/policy/v2017_06_01_preview/operations/_patch.py @@ -0,0 +1,20 @@ +# ------------------------------------ +# Copyright (c) Microsoft Corporation. +# Licensed under the MIT License. +# ------------------------------------ +"""Customize generated code here. + +Follow our quickstart for examples: https://aka.ms/azsdk/python/dpcodegen/python/customize +""" +from typing import List + +__all__: List[str] = [] # Add all objects you want publicly available to users at this package level + + +def patch_sdk(): + """Do not remove from this file. + + `patch_sdk` is a last resort escape hatch that allows you to do customizations + you can't accomplish using the techniques described in + https://aka.ms/azsdk/python/dpcodegen/python/customize + """ diff --git a/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/policy/v2018_03_01/__init__.py b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/policy/v2018_03_01/__init__.py index 89180ab440872..bb1ffe59afae7 100644 --- a/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/policy/v2018_03_01/__init__.py +++ b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/policy/v2018_03_01/__init__.py @@ -10,9 +10,15 @@ from ._version import VERSION __version__ = VERSION -__all__ = ['PolicyClient'] -# `._patch.py` is used for handwritten extensions to the generated code -# Example: https://github.com/Azure/azure-sdk-for-python/blob/main/doc/dev/customize_code/how-to-patch-sdk-code.md -from ._patch import patch_sdk -patch_sdk() +try: + from ._patch import __all__ as _patch_all + from ._patch import * # type: ignore # pylint: disable=unused-wildcard-import +except ImportError: + _patch_all = [] +from ._patch import patch_sdk as _patch_sdk + +__all__ = ["PolicyClient"] +__all__.extend([p for p in _patch_all if p not in __all__]) + +_patch_sdk() diff --git a/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/policy/v2018_03_01/_configuration.py b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/policy/v2018_03_01/_configuration.py index cee127e78689c..dec4723a408c9 100644 --- a/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/policy/v2018_03_01/_configuration.py +++ b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/policy/v2018_03_01/_configuration.py @@ -25,23 +25,18 @@ class PolicyClientConfiguration(Configuration): # pylint: disable=too-many-inst Note that all parameters used to create this instance are saved as instance attributes. - :param credential: Credential needed for the client to connect to Azure. + :param credential: Credential needed for the client to connect to Azure. Required. :type credential: ~azure.core.credentials.TokenCredential - :param subscription_id: The ID of the target subscription. + :param subscription_id: The ID of the target subscription. Required. :type subscription_id: str :keyword api_version: Api Version. Default value is "2018-03-01". Note that overriding this default value may result in unsupported behavior. :paramtype api_version: str """ - def __init__( - self, - credential: "TokenCredential", - subscription_id: str, - **kwargs: Any - ) -> None: + def __init__(self, credential: "TokenCredential", subscription_id: str, **kwargs: Any) -> None: super(PolicyClientConfiguration, self).__init__(**kwargs) - api_version = kwargs.pop('api_version', "2018-03-01") # type: str + api_version = kwargs.pop("api_version", "2018-03-01") # type: str if credential is None: raise ValueError("Parameter 'credential' must not be None.") @@ -51,23 +46,24 @@ def __init__( self.credential = credential self.subscription_id = subscription_id self.api_version = api_version - self.credential_scopes = kwargs.pop('credential_scopes', ['https://management.azure.com/.default']) - kwargs.setdefault('sdk_moniker', 'mgmt-resource/{}'.format(VERSION)) + self.credential_scopes = kwargs.pop("credential_scopes", ["https://management.azure.com/.default"]) + kwargs.setdefault("sdk_moniker", "mgmt-resource/{}".format(VERSION)) self._configure(**kwargs) def _configure( - self, - **kwargs # type: Any + self, **kwargs # type: Any ): # type: (...) -> 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) - self.logging_policy = kwargs.get('logging_policy') or policies.NetworkTraceLoggingPolicy(**kwargs) - self.http_logging_policy = kwargs.get('http_logging_policy') or ARMHttpLoggingPolicy(**kwargs) - self.retry_policy = kwargs.get('retry_policy') or policies.RetryPolicy(**kwargs) - self.custom_hook_policy = kwargs.get('custom_hook_policy') or policies.CustomHookPolicy(**kwargs) - self.redirect_policy = kwargs.get('redirect_policy') or policies.RedirectPolicy(**kwargs) - self.authentication_policy = kwargs.get('authentication_policy') + 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) + self.logging_policy = kwargs.get("logging_policy") or policies.NetworkTraceLoggingPolicy(**kwargs) + self.http_logging_policy = kwargs.get("http_logging_policy") or ARMHttpLoggingPolicy(**kwargs) + self.retry_policy = kwargs.get("retry_policy") or policies.RetryPolicy(**kwargs) + self.custom_hook_policy = kwargs.get("custom_hook_policy") or policies.CustomHookPolicy(**kwargs) + self.redirect_policy = kwargs.get("redirect_policy") or policies.RedirectPolicy(**kwargs) + self.authentication_policy = kwargs.get("authentication_policy") if self.credential and not self.authentication_policy: - self.authentication_policy = ARMChallengeAuthenticationPolicy(self.credential, *self.credential_scopes, **kwargs) + self.authentication_policy = ARMChallengeAuthenticationPolicy( + self.credential, *self.credential_scopes, **kwargs + ) diff --git a/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/policy/v2018_03_01/_metadata.json b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/policy/v2018_03_01/_metadata.json index 35393f7f3f613..e3505c212b139 100644 --- a/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/policy/v2018_03_01/_metadata.json +++ b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/policy/v2018_03_01/_metadata.json @@ -10,20 +10,20 @@ "azure_arm": true, "has_lro_operations": false, "client_side_validation": false, - "sync_imports": "{\"typing\": {\"azurecore\": {\"azure.core.credentials\": [\"TokenCredential\"]}}, \"regular\": {\"azurecore\": {\"azure.profiles\": [\"KnownProfiles\", \"ProfileDefinition\"], \"azure.profiles.multiapiclient\": [\"MultiApiClientMixin\"], \"azure.mgmt.core\": [\"ARMPipelineClient\"]}, \"local\": {\"._configuration\": [\"PolicyClientConfiguration\"]}, \"thirdparty\": {\"msrest\": [\"Deserializer\", \"Serializer\"]}}, \"conditional\": {\"stdlib\": {\"typing\": [\"Any\", \"Optional\"]}}}", - "async_imports": "{\"typing\": {\"azurecore\": {\"azure.core.credentials_async\": [\"AsyncTokenCredential\"], \"azure.core.credentials\": [\"TokenCredential\"]}}, \"regular\": {\"azurecore\": {\"azure.profiles\": [\"KnownProfiles\", \"ProfileDefinition\"], \"azure.profiles.multiapiclient\": [\"MultiApiClientMixin\"], \"azure.mgmt.core\": [\"AsyncARMPipelineClient\"]}, \"local\": {\"._configuration\": [\"PolicyClientConfiguration\"]}, \"thirdparty\": {\"msrest\": [\"Deserializer\", \"Serializer\"]}}, \"conditional\": {\"stdlib\": {\"typing\": [\"Any\", \"Optional\"]}}}" + "sync_imports": "{\"conditional\": {\"stdlib\": {\"typing\": [\"Any\", \"Optional\"]}}, \"regular\": {\"azurecore\": {\"azure.mgmt.core\": [\"ARMPipelineClient\"], \"azure.profiles\": [\"KnownProfiles\", \"ProfileDefinition\"], \"azure.profiles.multiapiclient\": [\"MultiApiClientMixin\"]}, \"local\": {\"._configuration\": [\"PolicyClientConfiguration\"], \".._serialization\": [\"Deserializer\", \"Serializer\"]}}, \"typing\": {\"azurecore\": {\"azure.core.credentials\": [\"TokenCredential\"]}}}", + "async_imports": "{\"conditional\": {\"stdlib\": {\"typing\": [\"Any\", \"Optional\"]}}, \"regular\": {\"azurecore\": {\"azure.mgmt.core\": [\"AsyncARMPipelineClient\"], \"azure.profiles\": [\"KnownProfiles\", \"ProfileDefinition\"], \"azure.profiles.multiapiclient\": [\"MultiApiClientMixin\"]}, \"local\": {\"._configuration\": [\"PolicyClientConfiguration\"], \"..._serialization\": [\"Deserializer\", \"Serializer\"]}}, \"typing\": {\"azurecore\": {\"azure.core.credentials_async\": [\"AsyncTokenCredential\"]}}}" }, "global_parameters": { "sync": { "credential": { - "signature": "credential, # type: \"TokenCredential\"", - "description": "Credential needed for the client to connect to Azure.", + "signature": "credential: \"TokenCredential\",", + "description": "Credential needed for the client to connect to Azure. Required.", "docstring_type": "~azure.core.credentials.TokenCredential", "required": true }, "subscription_id": { - "signature": "subscription_id, # type: str", - "description": "The ID of the target subscription.", + "signature": "subscription_id: str,", + "description": "The ID of the target subscription. Required.", "docstring_type": "str", "required": true } @@ -31,13 +31,13 @@ "async": { "credential": { "signature": "credential: \"AsyncTokenCredential\",", - "description": "Credential needed for the client to connect to Azure.", + "description": "Credential needed for the client to connect to Azure. Required.", "docstring_type": "~azure.core.credentials_async.AsyncTokenCredential", "required": true }, "subscription_id": { "signature": "subscription_id: str,", - "description": "The ID of the target subscription.", + "description": "The ID of the target subscription. Required.", "docstring_type": "str", "required": true } @@ -54,7 +54,7 @@ "required": false }, "base_url": { - "signature": "base_url=\"https://management.azure.com\", # type: str", + "signature": "base_url: str = \"https://management.azure.com\",", "description": "Service URL", "docstring_type": "str", "required": false diff --git a/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/policy/v2018_03_01/_patch.py b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/policy/v2018_03_01/_patch.py index 74e48ecd07cf3..f99e77fef9861 100644 --- a/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/policy/v2018_03_01/_patch.py +++ b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/policy/v2018_03_01/_patch.py @@ -28,4 +28,4 @@ # This file is used for handwritten extensions to the generated code. Example: # https://github.com/Azure/azure-sdk-for-python/blob/main/doc/dev/customize_code/how-to-patch-sdk-code.md def patch_sdk(): - pass \ No newline at end of file + pass diff --git a/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/policy/v2018_03_01/_policy_client.py b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/policy/v2018_03_01/_policy_client.py index 7945f795d1cfa..4177c936d6934 100644 --- a/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/policy/v2018_03_01/_policy_client.py +++ b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/policy/v2018_03_01/_policy_client.py @@ -9,12 +9,11 @@ from copy import deepcopy from typing import Any, TYPE_CHECKING -from msrest import Deserializer, Serializer - from azure.core.rest import HttpRequest, HttpResponse from azure.mgmt.core import ARMPipelineClient from . import models +from .._serialization import Deserializer, Serializer from ._configuration import PolicyClientConfiguration from .operations import PolicyAssignmentsOperations, PolicyDefinitionsOperations, PolicySetDefinitionsOperations @@ -22,7 +21,8 @@ # pylint: disable=unused-import,ungrouped-imports from azure.core.credentials import TokenCredential -class PolicyClient: + +class PolicyClient: # pylint: disable=client-accepts-api-version-keyword """To manage and control access to your resources, you can define customized policies and assign them at a scope. @@ -35,9 +35,9 @@ class PolicyClient: :ivar policy_set_definitions: PolicySetDefinitionsOperations operations :vartype policy_set_definitions: azure.mgmt.resource.policy.v2018_03_01.operations.PolicySetDefinitionsOperations - :param credential: Credential needed for the client to connect to Azure. + :param credential: Credential needed for the client to connect to Azure. Required. :type credential: ~azure.core.credentials.TokenCredential - :param subscription_id: The ID of the target subscription. + :param subscription_id: The ID of the target subscription. Required. :type subscription_id: str :param base_url: Service URL. Default value is "https://management.azure.com". :type base_url: str @@ -60,16 +60,17 @@ def __init__( self._serialize = Serializer(client_models) self._deserialize = Deserializer(client_models) self._serialize.client_side_validation = False - self.policy_assignments = PolicyAssignmentsOperations(self._client, self._config, self._serialize, self._deserialize) - self.policy_definitions = PolicyDefinitionsOperations(self._client, self._config, self._serialize, self._deserialize) - self.policy_set_definitions = PolicySetDefinitionsOperations(self._client, self._config, self._serialize, self._deserialize) - - - def _send_request( - self, - request: HttpRequest, - **kwargs: Any - ) -> HttpResponse: + self.policy_assignments = PolicyAssignmentsOperations( + self._client, self._config, self._serialize, self._deserialize + ) + self.policy_definitions = PolicyDefinitionsOperations( + self._client, self._config, self._serialize, self._deserialize + ) + self.policy_set_definitions = PolicySetDefinitionsOperations( + self._client, self._config, self._serialize, self._deserialize + ) + + def _send_request(self, request: HttpRequest, **kwargs: Any) -> HttpResponse: """Runs the network request through the client's chained policies. >>> from azure.core.rest import HttpRequest @@ -78,7 +79,7 @@ def _send_request( >>> response = client._send_request(request) - For more information on this code flow, see https://aka.ms/azsdk/python/protocol/quickstart + For more information on this code flow, see https://aka.ms/azsdk/dpcodegen/python/send_request :param request: The network request you want to make. Required. :type request: ~azure.core.rest.HttpRequest diff --git a/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/policy/v2018_03_01/_vendor.py b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/policy/v2018_03_01/_vendor.py index 138f663c53a4e..9aad73fc743e7 100644 --- a/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/policy/v2018_03_01/_vendor.py +++ b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/policy/v2018_03_01/_vendor.py @@ -7,6 +7,7 @@ from azure.core.pipeline.transport import HttpRequest + def _convert_request(request, files=None): data = request.content if not files else None request = HttpRequest(method=request.method, url=request.url, headers=request.headers, data=data) @@ -14,6 +15,7 @@ def _convert_request(request, files=None): request.set_formdata_body(files) return request + def _format_url_section(template, **kwargs): components = template.split("/") while components: @@ -21,7 +23,5 @@ def _format_url_section(template, **kwargs): 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 - ] + components = [c for c in formatted_components if "{}".format(key.args[0]) not in c] template = "/".join(components) diff --git a/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/policy/v2018_03_01/_version.py b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/policy/v2018_03_01/_version.py index a012ac01c480c..e5754a47ce68f 100644 --- a/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/policy/v2018_03_01/_version.py +++ b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/policy/v2018_03_01/_version.py @@ -6,4 +6,4 @@ # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -VERSION = "21.1.0" +VERSION = "1.0.0b1" diff --git a/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/policy/v2018_03_01/aio/__init__.py b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/policy/v2018_03_01/aio/__init__.py index 2784ce3f14bf5..4622bf1f396a7 100644 --- a/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/policy/v2018_03_01/aio/__init__.py +++ b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/policy/v2018_03_01/aio/__init__.py @@ -7,9 +7,15 @@ # -------------------------------------------------------------------------- from ._policy_client import PolicyClient -__all__ = ['PolicyClient'] -# `._patch.py` is used for handwritten extensions to the generated code -# Example: https://github.com/Azure/azure-sdk-for-python/blob/main/doc/dev/customize_code/how-to-patch-sdk-code.md -from ._patch import patch_sdk -patch_sdk() +try: + from ._patch import __all__ as _patch_all + from ._patch import * # type: ignore # pylint: disable=unused-wildcard-import +except ImportError: + _patch_all = [] +from ._patch import patch_sdk as _patch_sdk + +__all__ = ["PolicyClient"] +__all__.extend([p for p in _patch_all if p not in __all__]) + +_patch_sdk() diff --git a/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/policy/v2018_03_01/aio/_configuration.py b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/policy/v2018_03_01/aio/_configuration.py index 4e485746dae61..8c25300f12c5d 100644 --- a/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/policy/v2018_03_01/aio/_configuration.py +++ b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/policy/v2018_03_01/aio/_configuration.py @@ -25,23 +25,18 @@ class PolicyClientConfiguration(Configuration): # pylint: disable=too-many-inst Note that all parameters used to create this instance are saved as instance attributes. - :param credential: Credential needed for the client to connect to Azure. + :param credential: Credential needed for the client to connect to Azure. Required. :type credential: ~azure.core.credentials_async.AsyncTokenCredential - :param subscription_id: The ID of the target subscription. + :param subscription_id: The ID of the target subscription. Required. :type subscription_id: str :keyword api_version: Api Version. Default value is "2018-03-01". Note that overriding this default value may result in unsupported behavior. :paramtype api_version: str """ - def __init__( - self, - credential: "AsyncTokenCredential", - subscription_id: str, - **kwargs: Any - ) -> None: + def __init__(self, credential: "AsyncTokenCredential", subscription_id: str, **kwargs: Any) -> None: super(PolicyClientConfiguration, self).__init__(**kwargs) - api_version = kwargs.pop('api_version', "2018-03-01") # type: str + api_version = kwargs.pop("api_version", "2018-03-01") # type: str if credential is None: raise ValueError("Parameter 'credential' must not be None.") @@ -51,22 +46,21 @@ def __init__( self.credential = credential self.subscription_id = subscription_id self.api_version = api_version - self.credential_scopes = kwargs.pop('credential_scopes', ['https://management.azure.com/.default']) - kwargs.setdefault('sdk_moniker', 'mgmt-resource/{}'.format(VERSION)) + self.credential_scopes = kwargs.pop("credential_scopes", ["https://management.azure.com/.default"]) + kwargs.setdefault("sdk_moniker", "mgmt-resource/{}".format(VERSION)) self._configure(**kwargs) - 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) - self.logging_policy = kwargs.get('logging_policy') or policies.NetworkTraceLoggingPolicy(**kwargs) - self.http_logging_policy = kwargs.get('http_logging_policy') or ARMHttpLoggingPolicy(**kwargs) - self.retry_policy = kwargs.get('retry_policy') or policies.AsyncRetryPolicy(**kwargs) - self.custom_hook_policy = kwargs.get('custom_hook_policy') or policies.CustomHookPolicy(**kwargs) - self.redirect_policy = kwargs.get('redirect_policy') or policies.AsyncRedirectPolicy(**kwargs) - self.authentication_policy = kwargs.get('authentication_policy') + 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) + self.logging_policy = kwargs.get("logging_policy") or policies.NetworkTraceLoggingPolicy(**kwargs) + self.http_logging_policy = kwargs.get("http_logging_policy") or ARMHttpLoggingPolicy(**kwargs) + self.retry_policy = kwargs.get("retry_policy") or policies.AsyncRetryPolicy(**kwargs) + self.custom_hook_policy = kwargs.get("custom_hook_policy") or policies.CustomHookPolicy(**kwargs) + self.redirect_policy = kwargs.get("redirect_policy") or policies.AsyncRedirectPolicy(**kwargs) + self.authentication_policy = kwargs.get("authentication_policy") if self.credential and not self.authentication_policy: - self.authentication_policy = AsyncARMChallengeAuthenticationPolicy(self.credential, *self.credential_scopes, **kwargs) + self.authentication_policy = AsyncARMChallengeAuthenticationPolicy( + self.credential, *self.credential_scopes, **kwargs + ) diff --git a/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/policy/v2018_03_01/aio/_patch.py b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/policy/v2018_03_01/aio/_patch.py index 74e48ecd07cf3..f99e77fef9861 100644 --- a/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/policy/v2018_03_01/aio/_patch.py +++ b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/policy/v2018_03_01/aio/_patch.py @@ -28,4 +28,4 @@ # This file is used for handwritten extensions to the generated code. Example: # https://github.com/Azure/azure-sdk-for-python/blob/main/doc/dev/customize_code/how-to-patch-sdk-code.md def patch_sdk(): - pass \ No newline at end of file + pass diff --git a/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/policy/v2018_03_01/aio/_policy_client.py b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/policy/v2018_03_01/aio/_policy_client.py index 0287fc997a2fb..0be3c11707fc0 100644 --- a/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/policy/v2018_03_01/aio/_policy_client.py +++ b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/policy/v2018_03_01/aio/_policy_client.py @@ -9,12 +9,11 @@ from copy import deepcopy from typing import Any, Awaitable, TYPE_CHECKING -from msrest import Deserializer, Serializer - from azure.core.rest import AsyncHttpResponse, HttpRequest from azure.mgmt.core import AsyncARMPipelineClient from .. import models +from ..._serialization import Deserializer, Serializer from ._configuration import PolicyClientConfiguration from .operations import PolicyAssignmentsOperations, PolicyDefinitionsOperations, PolicySetDefinitionsOperations @@ -22,7 +21,8 @@ # pylint: disable=unused-import,ungrouped-imports from azure.core.credentials_async import AsyncTokenCredential -class PolicyClient: + +class PolicyClient: # pylint: disable=client-accepts-api-version-keyword """To manage and control access to your resources, you can define customized policies and assign them at a scope. @@ -35,9 +35,9 @@ class PolicyClient: :ivar policy_set_definitions: PolicySetDefinitionsOperations operations :vartype policy_set_definitions: azure.mgmt.resource.policy.v2018_03_01.aio.operations.PolicySetDefinitionsOperations - :param credential: Credential needed for the client to connect to Azure. + :param credential: Credential needed for the client to connect to Azure. Required. :type credential: ~azure.core.credentials_async.AsyncTokenCredential - :param subscription_id: The ID of the target subscription. + :param subscription_id: The ID of the target subscription. Required. :type subscription_id: str :param base_url: Service URL. Default value is "https://management.azure.com". :type base_url: str @@ -60,16 +60,17 @@ def __init__( self._serialize = Serializer(client_models) self._deserialize = Deserializer(client_models) self._serialize.client_side_validation = False - self.policy_assignments = PolicyAssignmentsOperations(self._client, self._config, self._serialize, self._deserialize) - self.policy_definitions = PolicyDefinitionsOperations(self._client, self._config, self._serialize, self._deserialize) - self.policy_set_definitions = PolicySetDefinitionsOperations(self._client, self._config, self._serialize, self._deserialize) - - - def _send_request( - self, - request: HttpRequest, - **kwargs: Any - ) -> Awaitable[AsyncHttpResponse]: + self.policy_assignments = PolicyAssignmentsOperations( + self._client, self._config, self._serialize, self._deserialize + ) + self.policy_definitions = PolicyDefinitionsOperations( + self._client, self._config, self._serialize, self._deserialize + ) + self.policy_set_definitions = PolicySetDefinitionsOperations( + self._client, self._config, self._serialize, self._deserialize + ) + + def _send_request(self, request: HttpRequest, **kwargs: Any) -> Awaitable[AsyncHttpResponse]: """Runs the network request through the client's chained policies. >>> from azure.core.rest import HttpRequest @@ -78,7 +79,7 @@ def _send_request( >>> response = await client._send_request(request) - For more information on this code flow, see https://aka.ms/azsdk/python/protocol/quickstart + For more information on this code flow, see https://aka.ms/azsdk/dpcodegen/python/send_request :param request: The network request you want to make. Required. :type request: ~azure.core.rest.HttpRequest diff --git a/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/policy/v2018_03_01/aio/operations/__init__.py b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/policy/v2018_03_01/aio/operations/__init__.py index b2ae6190b03fb..4e1971e3e3247 100644 --- a/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/policy/v2018_03_01/aio/operations/__init__.py +++ b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/policy/v2018_03_01/aio/operations/__init__.py @@ -10,8 +10,14 @@ from ._operations import PolicyDefinitionsOperations from ._operations import PolicySetDefinitionsOperations +from ._patch import __all__ as _patch_all +from ._patch import * # type: ignore # pylint: disable=unused-wildcard-import +from ._patch import patch_sdk as _patch_sdk + __all__ = [ - 'PolicyAssignmentsOperations', - 'PolicyDefinitionsOperations', - 'PolicySetDefinitionsOperations', + "PolicyAssignmentsOperations", + "PolicyDefinitionsOperations", + "PolicySetDefinitionsOperations", ] +__all__.extend([p for p in _patch_all if p not in __all__]) +_patch_sdk() diff --git a/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/policy/v2018_03_01/aio/operations/_operations.py b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/policy/v2018_03_01/aio/operations/_operations.py index d987f1a85e8e7..0404de56cebda 100644 --- a/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/policy/v2018_03_01/aio/operations/_operations.py +++ b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/policy/v2018_03_01/aio/operations/_operations.py @@ -6,52 +6,87 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -from typing import Any, AsyncIterable, Callable, Dict, Optional, TypeVar +from typing import Any, AsyncIterable, Callable, Dict, IO, Optional, TypeVar, Union, overload +from urllib.parse import parse_qs, urljoin, urlparse from azure.core.async_paging import AsyncItemPaged, AsyncList -from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error +from azure.core.exceptions import ( + ClientAuthenticationError, + HttpResponseError, + ResourceExistsError, + ResourceNotFoundError, + ResourceNotModifiedError, + map_error, +) from azure.core.pipeline import PipelineResponse from azure.core.pipeline.transport import AsyncHttpResponse from azure.core.rest import HttpRequest from azure.core.tracing.decorator import distributed_trace from azure.core.tracing.decorator_async import distributed_trace_async +from azure.core.utils import case_insensitive_dict from azure.mgmt.core.exceptions import ARMErrorFormat from ... import models as _models from ..._vendor import _convert_request -from ...operations._operations import build_policy_assignments_create_by_id_request, build_policy_assignments_create_request, build_policy_assignments_delete_by_id_request, build_policy_assignments_delete_request, build_policy_assignments_get_by_id_request, build_policy_assignments_get_request, build_policy_assignments_list_for_resource_group_request, build_policy_assignments_list_for_resource_request, build_policy_assignments_list_request, build_policy_definitions_create_or_update_at_management_group_request, build_policy_definitions_create_or_update_request, build_policy_definitions_delete_at_management_group_request, build_policy_definitions_delete_request, build_policy_definitions_get_at_management_group_request, build_policy_definitions_get_built_in_request, build_policy_definitions_get_request, build_policy_definitions_list_built_in_request, build_policy_definitions_list_by_management_group_request, build_policy_definitions_list_request, build_policy_set_definitions_create_or_update_at_management_group_request, build_policy_set_definitions_create_or_update_request, build_policy_set_definitions_delete_at_management_group_request, build_policy_set_definitions_delete_request, build_policy_set_definitions_get_at_management_group_request, build_policy_set_definitions_get_built_in_request, build_policy_set_definitions_get_request, build_policy_set_definitions_list_built_in_request, build_policy_set_definitions_list_by_management_group_request, build_policy_set_definitions_list_request -T = TypeVar('T') +from ...operations._operations import ( + build_policy_assignments_create_by_id_request, + build_policy_assignments_create_request, + build_policy_assignments_delete_by_id_request, + build_policy_assignments_delete_request, + build_policy_assignments_get_by_id_request, + build_policy_assignments_get_request, + build_policy_assignments_list_for_resource_group_request, + build_policy_assignments_list_for_resource_request, + build_policy_assignments_list_request, + build_policy_definitions_create_or_update_at_management_group_request, + build_policy_definitions_create_or_update_request, + build_policy_definitions_delete_at_management_group_request, + build_policy_definitions_delete_request, + build_policy_definitions_get_at_management_group_request, + build_policy_definitions_get_built_in_request, + build_policy_definitions_get_request, + build_policy_definitions_list_built_in_request, + build_policy_definitions_list_by_management_group_request, + build_policy_definitions_list_request, + build_policy_set_definitions_create_or_update_at_management_group_request, + build_policy_set_definitions_create_or_update_request, + build_policy_set_definitions_delete_at_management_group_request, + build_policy_set_definitions_delete_request, + build_policy_set_definitions_get_at_management_group_request, + build_policy_set_definitions_get_built_in_request, + build_policy_set_definitions_get_request, + build_policy_set_definitions_list_built_in_request, + build_policy_set_definitions_list_by_management_group_request, + build_policy_set_definitions_list_request, +) + +T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] -class PolicyAssignmentsOperations: - """PolicyAssignmentsOperations async operations. - You should not instantiate this class directly. Instead, you should create a Client instance that - instantiates it for you and attaches it as an attribute. +class PolicyAssignmentsOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. - :ivar models: Alias to model classes used in this operation group. - :type models: ~azure.mgmt.resource.policy.v2018_03_01.models - :param client: Client for service requests. - :param config: Configuration of service client. - :param serializer: An object model serializer. - :param deserializer: An object model deserializer. + Instead, you should access the following operations through + :class:`~azure.mgmt.resource.policy.v2018_03_01.aio.PolicyClient`'s + :attr:`policy_assignments` attribute. """ models = _models - def __init__(self, client, config, serializer, deserializer) -> None: - self._client = client - self._serialize = serializer - self._deserialize = deserializer - self._config = config + def __init__(self, *args, **kwargs) -> None: + input_args = list(args) + self._client = input_args.pop(0) if input_args else kwargs.pop("client") + self._config = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") @distributed_trace_async async def delete( - self, - scope: str, - policy_assignment_name: str, - **kwargs: Any - ) -> Optional["_models.PolicyAssignment"]: + self, scope: str, policy_assignment_name: str, **kwargs: Any + ) -> Optional[_models.PolicyAssignment]: """Deletes a policy assignment. This operation deletes a policy assignment, given its name and the scope it was created in. The @@ -63,37 +98,44 @@ async def delete( '/subscriptions/{subscriptionId}'), resource group (format: '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}', or resource (format: '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{resourceProviderNamespace}/[{parentResourcePath}/]{resourceType}/{resourceName}'. + Required. :type scope: str - :param policy_assignment_name: The name of the policy assignment to delete. + :param policy_assignment_name: The name of the policy assignment to delete. Required. :type policy_assignment_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: PolicyAssignment, or the result of cls(response) + :return: PolicyAssignment or None or the result of cls(response) :rtype: ~azure.mgmt.resource.policy.v2018_03_01.models.PolicyAssignment or None - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType[Optional["_models.PolicyAssignment"]] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) - api_version = kwargs.pop('api_version', "2018-03-01") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2018-03-01")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[Optional[_models.PolicyAssignment]] - request = build_policy_assignments_delete_request( scope=scope, policy_assignment_name=policy_assignment_name, api_version=api_version, - template_url=self.delete.metadata['url'], + template_url=self.delete.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200, 204]: @@ -103,24 +145,25 @@ async def delete( deserialized = None if response.status_code == 200: - deserialized = self._deserialize('PolicyAssignment', pipeline_response) + deserialized = self._deserialize("PolicyAssignment", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - delete.metadata = {'url': "/{scope}/providers/Microsoft.Authorization/policyAssignments/{policyAssignmentName}"} # type: ignore - + delete.metadata = {"url": "/{scope}/providers/Microsoft.Authorization/policyAssignments/{policyAssignmentName}"} # type: ignore - @distributed_trace_async + @overload async def create( self, scope: str, policy_assignment_name: str, - parameters: "_models.PolicyAssignment", + parameters: _models.PolicyAssignment, + *, + content_type: str = "application/json", **kwargs: Any - ) -> "_models.PolicyAssignment": + ) -> _models.PolicyAssignment: """Creates or updates a policy assignment. This operation creates or updates a policy assignment with the given scope and name. Policy @@ -132,26 +175,109 @@ async def create( '/subscriptions/{subscriptionId}'), resource group (format: '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}', or resource (format: '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{resourceProviderNamespace}/[{parentResourcePath}/]{resourceType}/{resourceName}'. + Required. :type scope: str - :param policy_assignment_name: The name of the policy assignment. + :param policy_assignment_name: The name of the policy assignment. Required. :type policy_assignment_name: str - :param parameters: Parameters for the policy assignment. + :param parameters: Parameters for the policy assignment. Required. :type parameters: ~azure.mgmt.resource.policy.v2018_03_01.models.PolicyAssignment + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: PolicyAssignment or the result of cls(response) + :rtype: ~azure.mgmt.resource.policy.v2018_03_01.models.PolicyAssignment + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + async def create( + self, + scope: str, + policy_assignment_name: str, + parameters: IO, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.PolicyAssignment: + """Creates or updates a policy assignment. + + This operation creates or updates a policy assignment with the given scope and name. Policy + assignments apply to all resources contained within their scope. For example, when you assign a + policy at resource group scope, that policy applies to all resources in the group. + + :param scope: The scope of the policy assignment. Valid scopes are: management group (format: + '/providers/Microsoft.Management/managementGroups/{managementGroup}'), subscription (format: + '/subscriptions/{subscriptionId}'), resource group (format: + '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}', or resource (format: + '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{resourceProviderNamespace}/[{parentResourcePath}/]{resourceType}/{resourceName}'. + Required. + :type scope: str + :param policy_assignment_name: The name of the policy assignment. Required. + :type policy_assignment_name: str + :param parameters: Parameters for the policy assignment. Required. + :type parameters: IO + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: PolicyAssignment or the result of cls(response) + :rtype: ~azure.mgmt.resource.policy.v2018_03_01.models.PolicyAssignment + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace_async + async def create( + self, scope: str, policy_assignment_name: str, parameters: Union[_models.PolicyAssignment, IO], **kwargs: Any + ) -> _models.PolicyAssignment: + """Creates or updates a policy assignment. + + This operation creates or updates a policy assignment with the given scope and name. Policy + assignments apply to all resources contained within their scope. For example, when you assign a + policy at resource group scope, that policy applies to all resources in the group. + + :param scope: The scope of the policy assignment. Valid scopes are: management group (format: + '/providers/Microsoft.Management/managementGroups/{managementGroup}'), subscription (format: + '/subscriptions/{subscriptionId}'), resource group (format: + '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}', or resource (format: + '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{resourceProviderNamespace}/[{parentResourcePath}/]{resourceType}/{resourceName}'. + Required. + :type scope: str + :param policy_assignment_name: The name of the policy assignment. Required. + :type policy_assignment_name: str + :param parameters: Parameters for the policy assignment. Is either a model type or a IO type. + Required. + :type parameters: ~azure.mgmt.resource.policy.v2018_03_01.models.PolicyAssignment or IO + :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. + Default value is None. + :paramtype content_type: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: PolicyAssignment, or the result of cls(response) + :return: PolicyAssignment or the result of cls(response) :rtype: ~azure.mgmt.resource.policy.v2018_03_01.models.PolicyAssignment - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.PolicyAssignment"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', "2018-03-01") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + api_version = kwargs.pop("api_version", _params.pop("api-version", "2018-03-01")) # type: str + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.PolicyAssignment] - _json = self._serialize.body(parameters, 'PolicyAssignment') + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(parameters, (IO, bytes)): + _content = parameters + else: + _json = self._serialize.body(parameters, "PolicyAssignment") request = build_policy_assignments_create_request( scope=scope, @@ -159,16 +285,18 @@ async def create( api_version=api_version, content_type=content_type, json=_json, - template_url=self.create.metadata['url'], + content=_content, + template_url=self.create.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [201]: @@ -176,23 +304,17 @@ async def create( error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - deserialized = self._deserialize('PolicyAssignment', pipeline_response) + deserialized = self._deserialize("PolicyAssignment", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - create.metadata = {'url': "/{scope}/providers/Microsoft.Authorization/policyAssignments/{policyAssignmentName}"} # type: ignore - + create.metadata = {"url": "/{scope}/providers/Microsoft.Authorization/policyAssignments/{policyAssignmentName}"} # type: ignore @distributed_trace_async - async def get( - self, - scope: str, - policy_assignment_name: str, - **kwargs: Any - ) -> "_models.PolicyAssignment": + async def get(self, scope: str, policy_assignment_name: str, **kwargs: Any) -> _models.PolicyAssignment: """Retrieves a policy assignment. This operation retrieves a single policy assignment, given its name and the scope it was @@ -203,37 +325,44 @@ async def get( '/subscriptions/{subscriptionId}'), resource group (format: '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}', or resource (format: '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{resourceProviderNamespace}/[{parentResourcePath}/]{resourceType}/{resourceName}'. + Required. :type scope: str - :param policy_assignment_name: The name of the policy assignment to get. + :param policy_assignment_name: The name of the policy assignment to get. Required. :type policy_assignment_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: PolicyAssignment, or the result of cls(response) + :return: PolicyAssignment or the result of cls(response) :rtype: ~azure.mgmt.resource.policy.v2018_03_01.models.PolicyAssignment - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.PolicyAssignment"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + 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', "2018-03-01") # type: str + api_version = kwargs.pop("api_version", _params.pop("api-version", "2018-03-01")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[_models.PolicyAssignment] - request = build_policy_assignments_get_request( scope=scope, policy_assignment_name=policy_assignment_name, api_version=api_version, - template_url=self.get.metadata['url'], + template_url=self.get.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200]: @@ -241,23 +370,19 @@ async def get( error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - deserialized = self._deserialize('PolicyAssignment', pipeline_response) + deserialized = self._deserialize("PolicyAssignment", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - get.metadata = {'url': "/{scope}/providers/Microsoft.Authorization/policyAssignments/{policyAssignmentName}"} # type: ignore - + get.metadata = {"url": "/{scope}/providers/Microsoft.Authorization/policyAssignments/{policyAssignmentName}"} # type: ignore @distributed_trace def list_for_resource_group( - self, - resource_group_name: str, - filter: Optional[str] = None, - **kwargs: Any - ) -> AsyncIterable["_models.PolicyAssignmentListResult"]: + self, resource_group_name: str, filter: Optional[str] = None, **kwargs: Any + ) -> AsyncIterable["_models.PolicyAssignment"]: """Retrieves all policy assignments that apply to a resource group. This operation retrieves the list of all policy assignments associated with the given resource @@ -272,47 +397,55 @@ def list_for_resource_group( assignments of the policy definition whose id is {value} that apply to the resource group. :param resource_group_name: The name of the resource group that contains policy assignments. + Required. :type resource_group_name: str :param filter: The filter to apply on the operation. Valid values for $filter are: 'atScope()' or 'policyDefinitionId eq '{value}''. If $filter is not provided, no filtering is performed. Default value is None. :type filter: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either PolicyAssignmentListResult or the result of - cls(response) + :return: An iterator like instance of either PolicyAssignment or the result of cls(response) :rtype: - ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.resource.policy.v2018_03_01.models.PolicyAssignmentListResult] - :raises: ~azure.core.exceptions.HttpResponseError + ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.resource.policy.v2018_03_01.models.PolicyAssignment] + :raises ~azure.core.exceptions.HttpResponseError: """ - api_version = kwargs.pop('api_version', "2018-03-01") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2018-03-01")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[_models.PolicyAssignmentListResult] - cls = kwargs.pop('cls', None) # type: ClsType["_models.PolicyAssignmentListResult"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) + def prepare_request(next_link=None): if not next_link: - + request = build_policy_assignments_list_for_resource_group_request( resource_group_name=resource_group_name, subscription_id=self._config.subscription_id, - api_version=api_version, filter=filter, - template_url=self.list_for_resource_group.metadata['url'], + api_version=api_version, + template_url=self.list_for_resource_group.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore else: - - request = build_policy_assignments_list_for_resource_group_request( - resource_group_name=resource_group_name, - subscription_id=self._config.subscription_id, - template_url=next_link, - ) + # make call to next link with the client's api-version + _parsed_next_link = urlparse(next_link) + _next_request_params = case_insensitive_dict(parse_qs(_parsed_next_link.query)) + _next_request_params["api-version"] = self._config.api_version + request = HttpRequest("GET", urljoin(next_link, _parsed_next_link.path), params=_next_request_params) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore request.method = "GET" return request @@ -326,10 +459,8 @@ async def extract_data(pipeline_response): async def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) response = pipeline_response.http_response @@ -340,11 +471,9 @@ async def get_next(next_link=None): return pipeline_response + return AsyncItemPaged(get_next, extract_data) - return AsyncItemPaged( - get_next, extract_data - ) - list_for_resource_group.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Authorization/policyAssignments"} # type: ignore + list_for_resource_group.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Authorization/policyAssignments"} # type: ignore @distributed_trace def list_for_resource( @@ -356,7 +485,7 @@ def list_for_resource( resource_name: str, filter: Optional[str] = None, **kwargs: Any - ) -> AsyncIterable["_models.PolicyAssignmentListResult"]: + ) -> AsyncIterable["_models.PolicyAssignment"]: """Retrieves all policy assignments that apply to a resource. This operation retrieves the list of all policy assignments associated with the specified @@ -382,39 +511,47 @@ def list_for_resource( {parentResourcePath} == '', {resourceType} == 'Microsoft.Web/sites', {resourceName} == 'MyWebApp'). - :param resource_group_name: The name of the resource group containing the resource. + :param resource_group_name: The name of the resource group containing the resource. Required. :type resource_group_name: str :param resource_provider_namespace: The namespace of the resource provider. For example, the namespace of a virtual machine is Microsoft.Compute (from Microsoft.Compute/virtualMachines). + Required. :type resource_provider_namespace: str :param parent_resource_path: The parent resource path. Use empty string if there is none. + Required. :type parent_resource_path: str :param resource_type: The resource type name. For example the type name of a web app is 'sites' - (from Microsoft.Web/sites). + (from Microsoft.Web/sites). Required. :type resource_type: str - :param resource_name: The name of the resource. + :param resource_name: The name of the resource. Required. :type resource_name: str :param filter: The filter to apply on the operation. Valid values for $filter are: 'atScope()' or 'policyDefinitionId eq '{value}''. If $filter is not provided, no filtering is performed. Default value is None. :type filter: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either PolicyAssignmentListResult or the result of - cls(response) + :return: An iterator like instance of either PolicyAssignment or the result of cls(response) :rtype: - ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.resource.policy.v2018_03_01.models.PolicyAssignmentListResult] - :raises: ~azure.core.exceptions.HttpResponseError + ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.resource.policy.v2018_03_01.models.PolicyAssignment] + :raises ~azure.core.exceptions.HttpResponseError: """ - api_version = kwargs.pop('api_version', "2018-03-01") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2018-03-01")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[_models.PolicyAssignmentListResult] - cls = kwargs.pop('cls', None) # type: ClsType["_models.PolicyAssignmentListResult"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) + def prepare_request(next_link=None): if not next_link: - + request = build_policy_assignments_list_for_resource_request( resource_group_name=resource_group_name, resource_provider_namespace=resource_provider_namespace, @@ -422,26 +559,23 @@ def prepare_request(next_link=None): resource_type=resource_type, resource_name=resource_name, subscription_id=self._config.subscription_id, - api_version=api_version, filter=filter, - template_url=self.list_for_resource.metadata['url'], + api_version=api_version, + template_url=self.list_for_resource.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore else: - - request = build_policy_assignments_list_for_resource_request( - resource_group_name=resource_group_name, - resource_provider_namespace=resource_provider_namespace, - parent_resource_path=parent_resource_path, - resource_type=resource_type, - resource_name=resource_name, - subscription_id=self._config.subscription_id, - template_url=next_link, - ) + # make call to next link with the client's api-version + _parsed_next_link = urlparse(next_link) + _next_request_params = case_insensitive_dict(parse_qs(_parsed_next_link.query)) + _next_request_params["api-version"] = self._config.api_version + request = HttpRequest("GET", urljoin(next_link, _parsed_next_link.path), params=_next_request_params) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore request.method = "GET" return request @@ -455,10 +589,8 @@ async def extract_data(pipeline_response): async def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) response = pipeline_response.http_response @@ -469,18 +601,12 @@ async def get_next(next_link=None): return pipeline_response + return AsyncItemPaged(get_next, extract_data) - return AsyncItemPaged( - get_next, extract_data - ) - list_for_resource.metadata = {'url': "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{parentResourcePath}/{resourceType}/{resourceName}/providers/Microsoft.Authorization/policyAssignments"} # type: ignore + list_for_resource.metadata = {"url": "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{parentResourcePath}/{resourceType}/{resourceName}/providers/Microsoft.Authorization/policyAssignments"} # type: ignore @distributed_trace - def list( - self, - filter: Optional[str] = None, - **kwargs: Any - ) -> AsyncIterable["_models.PolicyAssignmentListResult"]: + def list(self, filter: Optional[str] = None, **kwargs: Any) -> AsyncIterable["_models.PolicyAssignment"]: """Retrieves all policy assignments that apply to a subscription. This operation retrieves the list of all policy assignments associated with the given @@ -499,39 +625,47 @@ def list( Default value is None. :type filter: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either PolicyAssignmentListResult or the result of - cls(response) + :return: An iterator like instance of either PolicyAssignment or the result of cls(response) :rtype: - ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.resource.policy.v2018_03_01.models.PolicyAssignmentListResult] - :raises: ~azure.core.exceptions.HttpResponseError + ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.resource.policy.v2018_03_01.models.PolicyAssignment] + :raises ~azure.core.exceptions.HttpResponseError: """ - api_version = kwargs.pop('api_version', "2018-03-01") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2018-03-01")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[_models.PolicyAssignmentListResult] - cls = kwargs.pop('cls', None) # type: ClsType["_models.PolicyAssignmentListResult"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) + def prepare_request(next_link=None): if not next_link: - + request = build_policy_assignments_list_request( subscription_id=self._config.subscription_id, - api_version=api_version, filter=filter, - template_url=self.list.metadata['url'], + 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.url = self._client.format_url(request.url) # type: ignore else: - - request = build_policy_assignments_list_request( - subscription_id=self._config.subscription_id, - template_url=next_link, - ) + # make call to next link with the client's api-version + _parsed_next_link = urlparse(next_link) + _next_request_params = case_insensitive_dict(parse_qs(_parsed_next_link.query)) + _next_request_params["api-version"] = self._config.api_version + request = HttpRequest("GET", urljoin(next_link, _parsed_next_link.path), params=_next_request_params) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore request.method = "GET" return request @@ -545,10 +679,8 @@ async def extract_data(pipeline_response): async def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) response = pipeline_response.http_response @@ -559,18 +691,12 @@ async def get_next(next_link=None): return pipeline_response + return AsyncItemPaged(get_next, extract_data) - return AsyncItemPaged( - get_next, extract_data - ) - list.metadata = {'url': "/subscriptions/{subscriptionId}/providers/Microsoft.Authorization/policyAssignments"} # type: ignore + list.metadata = {"url": "/subscriptions/{subscriptionId}/providers/Microsoft.Authorization/policyAssignments"} # type: ignore @distributed_trace_async - async def delete_by_id( - self, - policy_assignment_id: str, - **kwargs: Any - ) -> Optional["_models.PolicyAssignment"]: + async def delete_by_id(self, policy_assignment_id: str, **kwargs: Any) -> Optional[_models.PolicyAssignment]: """Deletes a policy assignment. This operation deletes the policy with the given ID. Policy assignment IDs have this format: @@ -582,35 +708,41 @@ async def delete_by_id( (resource). :param policy_assignment_id: The ID of the policy assignment to delete. Use the format - '{scope}/providers/Microsoft.Authorization/policyAssignments/{policyAssignmentName}'. + '{scope}/providers/Microsoft.Authorization/policyAssignments/{policyAssignmentName}'. Required. :type policy_assignment_id: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: PolicyAssignment, or the result of cls(response) + :return: PolicyAssignment or None or the result of cls(response) :rtype: ~azure.mgmt.resource.policy.v2018_03_01.models.PolicyAssignment or None - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType[Optional["_models.PolicyAssignment"]] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) - api_version = kwargs.pop('api_version', "2018-03-01") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2018-03-01")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[Optional[_models.PolicyAssignment]] - request = build_policy_assignments_delete_by_id_request( policy_assignment_id=policy_assignment_id, api_version=api_version, - template_url=self.delete_by_id.metadata['url'], + template_url=self.delete_by_id.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200, 204]: @@ -620,23 +752,24 @@ async def delete_by_id( deserialized = None if response.status_code == 200: - deserialized = self._deserialize('PolicyAssignment', pipeline_response) + deserialized = self._deserialize("PolicyAssignment", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - delete_by_id.metadata = {'url': "/{policyAssignmentId}"} # type: ignore + delete_by_id.metadata = {"url": "/{policyAssignmentId}"} # type: ignore - - @distributed_trace_async + @overload async def create_by_id( self, policy_assignment_id: str, - parameters: "_models.PolicyAssignment", + parameters: _models.PolicyAssignment, + *, + content_type: str = "application/json", **kwargs: Any - ) -> "_models.PolicyAssignment": + ) -> _models.PolicyAssignment: """Creates or updates a policy assignment. This operation creates or updates the policy assignment with the given ID. Policy assignments @@ -651,41 +784,121 @@ async def create_by_id( '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{resourceProviderNamespace}/[{parentResourcePath}/]{resourceType}/{resourceName}'. :param policy_assignment_id: The ID of the policy assignment to create. Use the format - '{scope}/providers/Microsoft.Authorization/policyAssignments/{policyAssignmentName}'. + '{scope}/providers/Microsoft.Authorization/policyAssignments/{policyAssignmentName}'. Required. :type policy_assignment_id: str - :param parameters: Parameters for policy assignment. + :param parameters: Parameters for policy assignment. Required. :type parameters: ~azure.mgmt.resource.policy.v2018_03_01.models.PolicyAssignment + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: PolicyAssignment or the result of cls(response) + :rtype: ~azure.mgmt.resource.policy.v2018_03_01.models.PolicyAssignment + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + async def create_by_id( + self, policy_assignment_id: str, parameters: IO, *, content_type: str = "application/json", **kwargs: Any + ) -> _models.PolicyAssignment: + """Creates or updates a policy assignment. + + This operation creates or updates the policy assignment with the given ID. Policy assignments + made on a scope apply to all resources contained in that scope. For example, when you assign a + policy to a resource group that policy applies to all resources in the group. Policy assignment + IDs have this format: + '{scope}/providers/Microsoft.Authorization/policyAssignments/{policyAssignmentName}'. Valid + scopes are: management group (format: + '/providers/Microsoft.Management/managementGroups/{managementGroup}'), subscription (format: + '/subscriptions/{subscriptionId}'), resource group (format: + '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}', or resource (format: + '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{resourceProviderNamespace}/[{parentResourcePath}/]{resourceType}/{resourceName}'. + + :param policy_assignment_id: The ID of the policy assignment to create. Use the format + '{scope}/providers/Microsoft.Authorization/policyAssignments/{policyAssignmentName}'. Required. + :type policy_assignment_id: str + :param parameters: Parameters for policy assignment. Required. + :type parameters: IO + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: PolicyAssignment, or the result of cls(response) + :return: PolicyAssignment or the result of cls(response) :rtype: ~azure.mgmt.resource.policy.v2018_03_01.models.PolicyAssignment - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace_async + async def create_by_id( + self, policy_assignment_id: str, parameters: Union[_models.PolicyAssignment, IO], **kwargs: Any + ) -> _models.PolicyAssignment: + """Creates or updates a policy assignment. + + This operation creates or updates the policy assignment with the given ID. Policy assignments + made on a scope apply to all resources contained in that scope. For example, when you assign a + policy to a resource group that policy applies to all resources in the group. Policy assignment + IDs have this format: + '{scope}/providers/Microsoft.Authorization/policyAssignments/{policyAssignmentName}'. Valid + scopes are: management group (format: + '/providers/Microsoft.Management/managementGroups/{managementGroup}'), subscription (format: + '/subscriptions/{subscriptionId}'), resource group (format: + '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}', or resource (format: + '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{resourceProviderNamespace}/[{parentResourcePath}/]{resourceType}/{resourceName}'. + + :param policy_assignment_id: The ID of the policy assignment to create. Use the format + '{scope}/providers/Microsoft.Authorization/policyAssignments/{policyAssignmentName}'. Required. + :type policy_assignment_id: str + :param parameters: Parameters for policy assignment. Is either a model type or a IO type. + Required. + :type parameters: ~azure.mgmt.resource.policy.v2018_03_01.models.PolicyAssignment or IO + :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. + Default value is None. + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: PolicyAssignment or the result of cls(response) + :rtype: ~azure.mgmt.resource.policy.v2018_03_01.models.PolicyAssignment + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.PolicyAssignment"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', "2018-03-01") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + api_version = kwargs.pop("api_version", _params.pop("api-version", "2018-03-01")) # type: str + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.PolicyAssignment] - _json = self._serialize.body(parameters, 'PolicyAssignment') + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(parameters, (IO, bytes)): + _content = parameters + else: + _json = self._serialize.body(parameters, "PolicyAssignment") request = build_policy_assignments_create_by_id_request( policy_assignment_id=policy_assignment_id, api_version=api_version, content_type=content_type, json=_json, - template_url=self.create_by_id.metadata['url'], + content=_content, + template_url=self.create_by_id.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [201]: @@ -693,22 +906,17 @@ async def create_by_id( error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - deserialized = self._deserialize('PolicyAssignment', pipeline_response) + deserialized = self._deserialize("PolicyAssignment", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - create_by_id.metadata = {'url': "/{policyAssignmentId}"} # type: ignore - + create_by_id.metadata = {"url": "/{policyAssignmentId}"} # type: ignore @distributed_trace_async - async def get_by_id( - self, - policy_assignment_id: str, - **kwargs: Any - ) -> "_models.PolicyAssignment": + async def get_by_id(self, policy_assignment_id: str, **kwargs: Any) -> _models.PolicyAssignment: """Retrieves the policy assignment with the given ID. The operation retrieves the policy assignment with the given ID. Policy assignment IDs have @@ -721,35 +929,41 @@ async def get_by_id( '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{resourceProviderNamespace}/[{parentResourcePath}/]{resourceType}/{resourceName}'. :param policy_assignment_id: The ID of the policy assignment to get. Use the format - '{scope}/providers/Microsoft.Authorization/policyAssignments/{policyAssignmentName}'. + '{scope}/providers/Microsoft.Authorization/policyAssignments/{policyAssignmentName}'. Required. :type policy_assignment_id: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: PolicyAssignment, or the result of cls(response) + :return: PolicyAssignment or the result of cls(response) :rtype: ~azure.mgmt.resource.policy.v2018_03_01.models.PolicyAssignment - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.PolicyAssignment"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) - api_version = kwargs.pop('api_version', "2018-03-01") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2018-03-01")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[_models.PolicyAssignment] - request = build_policy_assignments_get_by_id_request( policy_assignment_id=policy_assignment_id, api_version=api_version, - template_url=self.get_by_id.metadata['url'], + template_url=self.get_by_id.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200]: @@ -757,68 +971,128 @@ async def get_by_id( error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - deserialized = self._deserialize('PolicyAssignment', pipeline_response) + deserialized = self._deserialize("PolicyAssignment", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - get_by_id.metadata = {'url': "/{policyAssignmentId}"} # type: ignore + get_by_id.metadata = {"url": "/{policyAssignmentId}"} # type: ignore -class PolicyDefinitionsOperations: - """PolicyDefinitionsOperations async operations. - You should not instantiate this class directly. Instead, you should create a Client instance that - instantiates it for you and attaches it as an attribute. +class PolicyDefinitionsOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. - :ivar models: Alias to model classes used in this operation group. - :type models: ~azure.mgmt.resource.policy.v2018_03_01.models - :param client: Client for service requests. - :param config: Configuration of service client. - :param serializer: An object model serializer. - :param deserializer: An object model deserializer. + Instead, you should access the following operations through + :class:`~azure.mgmt.resource.policy.v2018_03_01.aio.PolicyClient`'s + :attr:`policy_definitions` attribute. """ models = _models - def __init__(self, client, config, serializer, deserializer) -> None: - self._client = client - self._serialize = serializer - self._deserialize = deserializer - self._config = config + def __init__(self, *args, **kwargs) -> None: + input_args = list(args) + self._client = input_args.pop(0) if input_args else kwargs.pop("client") + self._config = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") - @distributed_trace_async + @overload async def create_or_update( self, policy_definition_name: str, - parameters: "_models.PolicyDefinition", + parameters: _models.PolicyDefinition, + *, + content_type: str = "application/json", **kwargs: Any - ) -> "_models.PolicyDefinition": + ) -> _models.PolicyDefinition: """Creates or updates a policy definition in a subscription. This operation creates or updates a policy definition in the given subscription with the given name. - :param policy_definition_name: The name of the policy definition to create. + :param policy_definition_name: The name of the policy definition to create. Required. :type policy_definition_name: str - :param parameters: The policy definition properties. + :param parameters: The policy definition properties. Required. :type parameters: ~azure.mgmt.resource.policy.v2018_03_01.models.PolicyDefinition + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: PolicyDefinition or the result of cls(response) + :rtype: ~azure.mgmt.resource.policy.v2018_03_01.models.PolicyDefinition + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + async def create_or_update( + self, policy_definition_name: str, parameters: IO, *, content_type: str = "application/json", **kwargs: Any + ) -> _models.PolicyDefinition: + """Creates or updates a policy definition in a subscription. + + This operation creates or updates a policy definition in the given subscription with the given + name. + + :param policy_definition_name: The name of the policy definition to create. Required. + :type policy_definition_name: str + :param parameters: The policy definition properties. Required. + :type parameters: IO + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: PolicyDefinition or the result of cls(response) + :rtype: ~azure.mgmt.resource.policy.v2018_03_01.models.PolicyDefinition + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace_async + async def create_or_update( + self, policy_definition_name: str, parameters: Union[_models.PolicyDefinition, IO], **kwargs: Any + ) -> _models.PolicyDefinition: + """Creates or updates a policy definition in a subscription. + + This operation creates or updates a policy definition in the given subscription with the given + name. + + :param policy_definition_name: The name of the policy definition to create. Required. + :type policy_definition_name: str + :param parameters: The policy definition properties. Is either a model type or a IO type. + Required. + :type parameters: ~azure.mgmt.resource.policy.v2018_03_01.models.PolicyDefinition or IO + :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. + Default value is None. + :paramtype content_type: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: PolicyDefinition, or the result of cls(response) + :return: PolicyDefinition or the result of cls(response) :rtype: ~azure.mgmt.resource.policy.v2018_03_01.models.PolicyDefinition - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.PolicyDefinition"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', "2018-03-01") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + api_version = kwargs.pop("api_version", _params.pop("api-version", "2018-03-01")) # type: str + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.PolicyDefinition] - _json = self._serialize.body(parameters, 'PolicyDefinition') + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(parameters, (IO, bytes)): + _content = parameters + else: + _json = self._serialize.body(parameters, "PolicyDefinition") request = build_policy_definitions_create_or_update_request( policy_definition_name=policy_definition_name, @@ -826,72 +1100,77 @@ async def create_or_update( api_version=api_version, content_type=content_type, json=_json, - template_url=self.create_or_update.metadata['url'], + content=_content, + template_url=self.create_or_update.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [201]: map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) - deserialized = self._deserialize('PolicyDefinition', pipeline_response) + deserialized = self._deserialize("PolicyDefinition", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - create_or_update.metadata = {'url': "/subscriptions/{subscriptionId}/providers/Microsoft.Authorization/policyDefinitions/{policyDefinitionName}"} # type: ignore - + create_or_update.metadata = {"url": "/subscriptions/{subscriptionId}/providers/Microsoft.Authorization/policyDefinitions/{policyDefinitionName}"} # type: ignore @distributed_trace_async async def delete( # pylint: disable=inconsistent-return-statements - self, - policy_definition_name: str, - **kwargs: Any + self, policy_definition_name: str, **kwargs: Any ) -> None: """Deletes a policy definition in a subscription. This operation deletes the policy definition in the given subscription with the given name. - :param policy_definition_name: The name of the policy definition to delete. + :param policy_definition_name: The name of the policy definition to delete. Required. :type policy_definition_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: None, or the result of cls(response) + :return: None or the result of cls(response) :rtype: None - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType[None] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + 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', "2018-03-01") # type: str + api_version = kwargs.pop("api_version", _params.pop("api-version", "2018-03-01")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[None] - request = build_policy_definitions_delete_request( policy_definition_name=policy_definition_name, subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.delete.metadata['url'], + template_url=self.delete.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200, 204]: @@ -901,154 +1180,231 @@ async def delete( # pylint: disable=inconsistent-return-statements if cls: return cls(pipeline_response, None, {}) - delete.metadata = {'url': "/subscriptions/{subscriptionId}/providers/Microsoft.Authorization/policyDefinitions/{policyDefinitionName}"} # type: ignore - + delete.metadata = {"url": "/subscriptions/{subscriptionId}/providers/Microsoft.Authorization/policyDefinitions/{policyDefinitionName}"} # type: ignore @distributed_trace_async - async def get( - self, - policy_definition_name: str, - **kwargs: Any - ) -> "_models.PolicyDefinition": + async def get(self, policy_definition_name: str, **kwargs: Any) -> _models.PolicyDefinition: """Retrieves a policy definition in a subscription. This operation retrieves the policy definition in the given subscription with the given name. - :param policy_definition_name: The name of the policy definition to get. + :param policy_definition_name: The name of the policy definition to get. Required. :type policy_definition_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: PolicyDefinition, or the result of cls(response) + :return: PolicyDefinition or the result of cls(response) :rtype: ~azure.mgmt.resource.policy.v2018_03_01.models.PolicyDefinition - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.PolicyDefinition"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + 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', "2018-03-01") # type: str + api_version = kwargs.pop("api_version", _params.pop("api-version", "2018-03-01")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[_models.PolicyDefinition] - request = build_policy_definitions_get_request( policy_definition_name=policy_definition_name, subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.get.metadata['url'], + template_url=self.get.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) - deserialized = self._deserialize('PolicyDefinition', pipeline_response) + deserialized = self._deserialize("PolicyDefinition", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - get.metadata = {'url': "/subscriptions/{subscriptionId}/providers/Microsoft.Authorization/policyDefinitions/{policyDefinitionName}"} # type: ignore - + get.metadata = {"url": "/subscriptions/{subscriptionId}/providers/Microsoft.Authorization/policyDefinitions/{policyDefinitionName}"} # type: ignore @distributed_trace_async - async def get_built_in( - self, - policy_definition_name: str, - **kwargs: Any - ) -> "_models.PolicyDefinition": + async def get_built_in(self, policy_definition_name: str, **kwargs: Any) -> _models.PolicyDefinition: """Retrieves a built-in policy definition. This operation retrieves the built-in policy definition with the given name. - :param policy_definition_name: The name of the built-in policy definition to get. + :param policy_definition_name: The name of the built-in policy definition to get. Required. :type policy_definition_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: PolicyDefinition, or the result of cls(response) + :return: PolicyDefinition or the result of cls(response) :rtype: ~azure.mgmt.resource.policy.v2018_03_01.models.PolicyDefinition - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.PolicyDefinition"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + 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', "2018-03-01") # type: str + api_version = kwargs.pop("api_version", _params.pop("api-version", "2018-03-01")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[_models.PolicyDefinition] - request = build_policy_definitions_get_built_in_request( policy_definition_name=policy_definition_name, api_version=api_version, - template_url=self.get_built_in.metadata['url'], + template_url=self.get_built_in.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) - deserialized = self._deserialize('PolicyDefinition', pipeline_response) + deserialized = self._deserialize("PolicyDefinition", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - get_built_in.metadata = {'url': "/providers/Microsoft.Authorization/policyDefinitions/{policyDefinitionName}"} # type: ignore + get_built_in.metadata = {"url": "/providers/Microsoft.Authorization/policyDefinitions/{policyDefinitionName}"} # type: ignore + @overload + async def create_or_update_at_management_group( + self, + policy_definition_name: str, + management_group_id: str, + parameters: _models.PolicyDefinition, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.PolicyDefinition: + """Creates or updates a policy definition in a management group. + + This operation creates or updates a policy definition in the given management group with the + given name. + + :param policy_definition_name: The name of the policy definition to create. Required. + :type policy_definition_name: str + :param management_group_id: The ID of the management group. Required. + :type management_group_id: str + :param parameters: The policy definition properties. Required. + :type parameters: ~azure.mgmt.resource.policy.v2018_03_01.models.PolicyDefinition + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: PolicyDefinition or the result of cls(response) + :rtype: ~azure.mgmt.resource.policy.v2018_03_01.models.PolicyDefinition + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + async def create_or_update_at_management_group( + self, + policy_definition_name: str, + management_group_id: str, + parameters: IO, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.PolicyDefinition: + """Creates or updates a policy definition in a management group. + + This operation creates or updates a policy definition in the given management group with the + given name. + + :param policy_definition_name: The name of the policy definition to create. Required. + :type policy_definition_name: str + :param management_group_id: The ID of the management group. Required. + :type management_group_id: str + :param parameters: The policy definition properties. Required. + :type parameters: IO + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: PolicyDefinition or the result of cls(response) + :rtype: ~azure.mgmt.resource.policy.v2018_03_01.models.PolicyDefinition + :raises ~azure.core.exceptions.HttpResponseError: + """ @distributed_trace_async async def create_or_update_at_management_group( self, policy_definition_name: str, management_group_id: str, - parameters: "_models.PolicyDefinition", + parameters: Union[_models.PolicyDefinition, IO], **kwargs: Any - ) -> "_models.PolicyDefinition": + ) -> _models.PolicyDefinition: """Creates or updates a policy definition in a management group. This operation creates or updates a policy definition in the given management group with the given name. - :param policy_definition_name: The name of the policy definition to create. + :param policy_definition_name: The name of the policy definition to create. Required. :type policy_definition_name: str - :param management_group_id: The ID of the management group. + :param management_group_id: The ID of the management group. Required. :type management_group_id: str - :param parameters: The policy definition properties. - :type parameters: ~azure.mgmt.resource.policy.v2018_03_01.models.PolicyDefinition + :param parameters: The policy definition properties. Is either a model type or a IO type. + Required. + :type parameters: ~azure.mgmt.resource.policy.v2018_03_01.models.PolicyDefinition or IO + :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. + Default value is None. + :paramtype content_type: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: PolicyDefinition, or the result of cls(response) + :return: PolicyDefinition or the result of cls(response) :rtype: ~azure.mgmt.resource.policy.v2018_03_01.models.PolicyDefinition - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.PolicyDefinition"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', "2018-03-01") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + api_version = kwargs.pop("api_version", _params.pop("api-version", "2018-03-01")) # type: str + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.PolicyDefinition] - _json = self._serialize.body(parameters, 'PolicyDefinition') + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(parameters, (IO, bytes)): + _content = parameters + else: + _json = self._serialize.body(parameters, "PolicyDefinition") request = build_policy_definitions_create_or_update_at_management_group_request( policy_definition_name=policy_definition_name, @@ -1056,75 +1412,79 @@ async def create_or_update_at_management_group( api_version=api_version, content_type=content_type, json=_json, - template_url=self.create_or_update_at_management_group.metadata['url'], + content=_content, + template_url=self.create_or_update_at_management_group.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [201]: map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) - deserialized = self._deserialize('PolicyDefinition', pipeline_response) + deserialized = self._deserialize("PolicyDefinition", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - create_or_update_at_management_group.metadata = {'url': "/providers/Microsoft.Management/managementgroups/{managementGroupId}/providers/Microsoft.Authorization/policyDefinitions/{policyDefinitionName}"} # type: ignore - + create_or_update_at_management_group.metadata = {"url": "/providers/Microsoft.Management/managementgroups/{managementGroupId}/providers/Microsoft.Authorization/policyDefinitions/{policyDefinitionName}"} # type: ignore @distributed_trace_async async def delete_at_management_group( # pylint: disable=inconsistent-return-statements - self, - policy_definition_name: str, - management_group_id: str, - **kwargs: Any + self, policy_definition_name: str, management_group_id: str, **kwargs: Any ) -> None: """Deletes a policy definition in a management group. This operation deletes the policy definition in the given management group with the given name. - :param policy_definition_name: The name of the policy definition to delete. + :param policy_definition_name: The name of the policy definition to delete. Required. :type policy_definition_name: str - :param management_group_id: The ID of the management group. + :param management_group_id: The ID of the management group. Required. :type management_group_id: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: None, or the result of cls(response) + :return: None or the result of cls(response) :rtype: None - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType[None] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) - api_version = kwargs.pop('api_version', "2018-03-01") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2018-03-01")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[None] - request = build_policy_definitions_delete_at_management_group_request( policy_definition_name=policy_definition_name, management_group_id=management_group_id, api_version=api_version, - template_url=self.delete_at_management_group.metadata['url'], + template_url=self.delete_at_management_group.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200, 204]: @@ -1134,111 +1494,117 @@ async def delete_at_management_group( # pylint: disable=inconsistent-return-sta if cls: return cls(pipeline_response, None, {}) - delete_at_management_group.metadata = {'url': "/providers/Microsoft.Management/managementgroups/{managementGroupId}/providers/Microsoft.Authorization/policyDefinitions/{policyDefinitionName}"} # type: ignore - + delete_at_management_group.metadata = {"url": "/providers/Microsoft.Management/managementgroups/{managementGroupId}/providers/Microsoft.Authorization/policyDefinitions/{policyDefinitionName}"} # type: ignore @distributed_trace_async async def get_at_management_group( - self, - policy_definition_name: str, - management_group_id: str, - **kwargs: Any - ) -> "_models.PolicyDefinition": + self, policy_definition_name: str, management_group_id: str, **kwargs: Any + ) -> _models.PolicyDefinition: """Retrieve a policy definition in a management group. This operation retrieves the policy definition in the given management group with the given name. - :param policy_definition_name: The name of the policy definition to get. + :param policy_definition_name: The name of the policy definition to get. Required. :type policy_definition_name: str - :param management_group_id: The ID of the management group. + :param management_group_id: The ID of the management group. Required. :type management_group_id: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: PolicyDefinition, or the result of cls(response) + :return: PolicyDefinition or the result of cls(response) :rtype: ~azure.mgmt.resource.policy.v2018_03_01.models.PolicyDefinition - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.PolicyDefinition"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + 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', "2018-03-01") # type: str + api_version = kwargs.pop("api_version", _params.pop("api-version", "2018-03-01")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[_models.PolicyDefinition] - request = build_policy_definitions_get_at_management_group_request( policy_definition_name=policy_definition_name, management_group_id=management_group_id, api_version=api_version, - template_url=self.get_at_management_group.metadata['url'], + template_url=self.get_at_management_group.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) - deserialized = self._deserialize('PolicyDefinition', pipeline_response) + deserialized = self._deserialize("PolicyDefinition", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - get_at_management_group.metadata = {'url': "/providers/Microsoft.Management/managementgroups/{managementGroupId}/providers/Microsoft.Authorization/policyDefinitions/{policyDefinitionName}"} # type: ignore - + get_at_management_group.metadata = {"url": "/providers/Microsoft.Management/managementgroups/{managementGroupId}/providers/Microsoft.Authorization/policyDefinitions/{policyDefinitionName}"} # type: ignore @distributed_trace - def list( - self, - **kwargs: Any - ) -> AsyncIterable["_models.PolicyDefinitionListResult"]: + def list(self, **kwargs: Any) -> AsyncIterable["_models.PolicyDefinition"]: """Retrieves policy definitions in a subscription. This operation retrieves a list of all the policy definitions in a given subscription. :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either PolicyDefinitionListResult or the result of - cls(response) + :return: An iterator like instance of either PolicyDefinition or the result of cls(response) :rtype: - ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.resource.policy.v2018_03_01.models.PolicyDefinitionListResult] - :raises: ~azure.core.exceptions.HttpResponseError + ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.resource.policy.v2018_03_01.models.PolicyDefinition] + :raises ~azure.core.exceptions.HttpResponseError: """ - api_version = kwargs.pop('api_version', "2018-03-01") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2018-03-01")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[_models.PolicyDefinitionListResult] - cls = kwargs.pop('cls', None) # type: ClsType["_models.PolicyDefinitionListResult"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) + def prepare_request(next_link=None): if not next_link: - + request = build_policy_definitions_list_request( subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.list.metadata['url'], + template_url=self.list.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore else: - - request = build_policy_definitions_list_request( - subscription_id=self._config.subscription_id, - template_url=next_link, - ) + # make call to next link with the client's api-version + _parsed_next_link = urlparse(next_link) + _next_request_params = case_insensitive_dict(parse_qs(_parsed_next_link.query)) + _next_request_params["api-version"] = self._config.api_version + request = HttpRequest("GET", urljoin(next_link, _parsed_next_link.path), params=_next_request_params) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore request.method = "GET" return request @@ -1252,10 +1618,8 @@ async def extract_data(pipeline_response): async def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) response = pipeline_response.http_response @@ -1265,52 +1629,56 @@ async def get_next(next_link=None): return pipeline_response + return AsyncItemPaged(get_next, extract_data) - return AsyncItemPaged( - get_next, extract_data - ) - list.metadata = {'url': "/subscriptions/{subscriptionId}/providers/Microsoft.Authorization/policyDefinitions"} # type: ignore + list.metadata = {"url": "/subscriptions/{subscriptionId}/providers/Microsoft.Authorization/policyDefinitions"} # type: ignore @distributed_trace - def list_built_in( - self, - **kwargs: Any - ) -> AsyncIterable["_models.PolicyDefinitionListResult"]: + def list_built_in(self, **kwargs: Any) -> AsyncIterable["_models.PolicyDefinition"]: """Retrieve built-in policy definitions. This operation retrieves a list of all the built-in policy definitions. :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either PolicyDefinitionListResult or the result of - cls(response) + :return: An iterator like instance of either PolicyDefinition or the result of cls(response) :rtype: - ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.resource.policy.v2018_03_01.models.PolicyDefinitionListResult] - :raises: ~azure.core.exceptions.HttpResponseError + ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.resource.policy.v2018_03_01.models.PolicyDefinition] + :raises ~azure.core.exceptions.HttpResponseError: """ - api_version = kwargs.pop('api_version', "2018-03-01") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2018-03-01")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[_models.PolicyDefinitionListResult] - cls = kwargs.pop('cls', None) # type: ClsType["_models.PolicyDefinitionListResult"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) + def prepare_request(next_link=None): if not next_link: - + request = build_policy_definitions_list_built_in_request( api_version=api_version, - template_url=self.list_built_in.metadata['url'], + template_url=self.list_built_in.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore else: - - request = build_policy_definitions_list_built_in_request( - template_url=next_link, - ) + # make call to next link with the client's api-version + _parsed_next_link = urlparse(next_link) + _next_request_params = case_insensitive_dict(parse_qs(_parsed_next_link.query)) + _next_request_params["api-version"] = self._config.api_version + request = HttpRequest("GET", urljoin(next_link, _parsed_next_link.path), params=_next_request_params) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore request.method = "GET" return request @@ -1324,10 +1692,8 @@ async def extract_data(pipeline_response): async def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) response = pipeline_response.http_response @@ -1337,57 +1703,61 @@ async def get_next(next_link=None): return pipeline_response + return AsyncItemPaged(get_next, extract_data) - return AsyncItemPaged( - get_next, extract_data - ) - list_built_in.metadata = {'url': "/providers/Microsoft.Authorization/policyDefinitions"} # type: ignore + list_built_in.metadata = {"url": "/providers/Microsoft.Authorization/policyDefinitions"} # type: ignore @distributed_trace def list_by_management_group( - self, - management_group_id: str, - **kwargs: Any - ) -> AsyncIterable["_models.PolicyDefinitionListResult"]: + self, management_group_id: str, **kwargs: Any + ) -> AsyncIterable["_models.PolicyDefinition"]: """Retrieve policy definitions in a management group. This operation retrieves a list of all the policy definitions in a given management group. - :param management_group_id: The ID of the management group. + :param management_group_id: The ID of the management group. Required. :type management_group_id: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either PolicyDefinitionListResult or the result of - cls(response) + :return: An iterator like instance of either PolicyDefinition or the result of cls(response) :rtype: - ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.resource.policy.v2018_03_01.models.PolicyDefinitionListResult] - :raises: ~azure.core.exceptions.HttpResponseError + ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.resource.policy.v2018_03_01.models.PolicyDefinition] + :raises ~azure.core.exceptions.HttpResponseError: """ - api_version = kwargs.pop('api_version', "2018-03-01") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2018-03-01")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[_models.PolicyDefinitionListResult] - cls = kwargs.pop('cls', None) # type: ClsType["_models.PolicyDefinitionListResult"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) + def prepare_request(next_link=None): if not next_link: - + request = build_policy_definitions_list_by_management_group_request( management_group_id=management_group_id, api_version=api_version, - template_url=self.list_by_management_group.metadata['url'], + template_url=self.list_by_management_group.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore else: - - request = build_policy_definitions_list_by_management_group_request( - management_group_id=management_group_id, - template_url=next_link, - ) + # make call to next link with the client's api-version + _parsed_next_link = urlparse(next_link) + _next_request_params = case_insensitive_dict(parse_qs(_parsed_next_link.query)) + _next_request_params["api-version"] = self._config.api_version + request = HttpRequest("GET", urljoin(next_link, _parsed_next_link.path), params=_next_request_params) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore request.method = "GET" return request @@ -1401,10 +1771,8 @@ async def extract_data(pipeline_response): async def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) response = pipeline_response.http_response @@ -1414,64 +1782,123 @@ async def get_next(next_link=None): return pipeline_response + return AsyncItemPaged(get_next, extract_data) + + list_by_management_group.metadata = {"url": "/providers/Microsoft.Management/managementgroups/{managementGroupId}/providers/Microsoft.Authorization/policyDefinitions"} # type: ignore - return AsyncItemPaged( - get_next, extract_data - ) - list_by_management_group.metadata = {'url': "/providers/Microsoft.Management/managementgroups/{managementGroupId}/providers/Microsoft.Authorization/policyDefinitions"} # type: ignore -class PolicySetDefinitionsOperations: - """PolicySetDefinitionsOperations async operations. - You should not instantiate this class directly. Instead, you should create a Client instance that - instantiates it for you and attaches it as an attribute. +class PolicySetDefinitionsOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. - :ivar models: Alias to model classes used in this operation group. - :type models: ~azure.mgmt.resource.policy.v2018_03_01.models - :param client: Client for service requests. - :param config: Configuration of service client. - :param serializer: An object model serializer. - :param deserializer: An object model deserializer. + Instead, you should access the following operations through + :class:`~azure.mgmt.resource.policy.v2018_03_01.aio.PolicyClient`'s + :attr:`policy_set_definitions` attribute. """ models = _models - def __init__(self, client, config, serializer, deserializer) -> None: - self._client = client - self._serialize = serializer - self._deserialize = deserializer - self._config = config + def __init__(self, *args, **kwargs) -> None: + input_args = list(args) + self._client = input_args.pop(0) if input_args else kwargs.pop("client") + self._config = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") - @distributed_trace_async + @overload async def create_or_update( self, policy_set_definition_name: str, - parameters: "_models.PolicySetDefinition", + parameters: _models.PolicySetDefinition, + *, + content_type: str = "application/json", **kwargs: Any - ) -> "_models.PolicySetDefinition": + ) -> _models.PolicySetDefinition: """Creates or updates a policy set definition. This operation creates or updates a policy set definition in the given subscription with the given name. - :param policy_set_definition_name: The name of the policy set definition to create. + :param policy_set_definition_name: The name of the policy set definition to create. Required. :type policy_set_definition_name: str - :param parameters: The policy set definition properties. + :param parameters: The policy set definition properties. Required. :type parameters: ~azure.mgmt.resource.policy.v2018_03_01.models.PolicySetDefinition + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: PolicySetDefinition or the result of cls(response) + :rtype: ~azure.mgmt.resource.policy.v2018_03_01.models.PolicySetDefinition + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + async def create_or_update( + self, policy_set_definition_name: str, parameters: IO, *, content_type: str = "application/json", **kwargs: Any + ) -> _models.PolicySetDefinition: + """Creates or updates a policy set definition. + + This operation creates or updates a policy set definition in the given subscription with the + given name. + + :param policy_set_definition_name: The name of the policy set definition to create. Required. + :type policy_set_definition_name: str + :param parameters: The policy set definition properties. Required. + :type parameters: IO + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: PolicySetDefinition, or the result of cls(response) + :return: PolicySetDefinition or the result of cls(response) :rtype: ~azure.mgmt.resource.policy.v2018_03_01.models.PolicySetDefinition - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace_async + async def create_or_update( + self, policy_set_definition_name: str, parameters: Union[_models.PolicySetDefinition, IO], **kwargs: Any + ) -> _models.PolicySetDefinition: + """Creates or updates a policy set definition. + + This operation creates or updates a policy set definition in the given subscription with the + given name. + + :param policy_set_definition_name: The name of the policy set definition to create. Required. + :type policy_set_definition_name: str + :param parameters: The policy set definition properties. Is either a model type or a IO type. + Required. + :type parameters: ~azure.mgmt.resource.policy.v2018_03_01.models.PolicySetDefinition or IO + :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. + Default value is None. + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: PolicySetDefinition or the result of cls(response) + :rtype: ~azure.mgmt.resource.policy.v2018_03_01.models.PolicySetDefinition + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.PolicySetDefinition"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', "2018-03-01") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + api_version = kwargs.pop("api_version", _params.pop("api-version", "2018-03-01")) # type: str + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.PolicySetDefinition] - _json = self._serialize.body(parameters, 'PolicySetDefinition') + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(parameters, (IO, bytes)): + _content = parameters + else: + _json = self._serialize.body(parameters, "PolicySetDefinition") request = build_policy_set_definitions_create_or_update_request( policy_set_definition_name=policy_set_definition_name, @@ -1479,16 +1906,18 @@ async def create_or_update( api_version=api_version, content_type=content_type, json=_json, - template_url=self.create_or_update.metadata['url'], + content=_content, + template_url=self.create_or_update.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200, 201]: @@ -1497,59 +1926,62 @@ async def create_or_update( raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) if response.status_code == 200: - deserialized = self._deserialize('PolicySetDefinition', pipeline_response) + deserialized = self._deserialize("PolicySetDefinition", pipeline_response) if response.status_code == 201: - deserialized = self._deserialize('PolicySetDefinition', pipeline_response) + deserialized = self._deserialize("PolicySetDefinition", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - create_or_update.metadata = {'url': "/subscriptions/{subscriptionId}/providers/Microsoft.Authorization/policySetDefinitions/{policySetDefinitionName}"} # type: ignore - + create_or_update.metadata = {"url": "/subscriptions/{subscriptionId}/providers/Microsoft.Authorization/policySetDefinitions/{policySetDefinitionName}"} # type: ignore @distributed_trace_async async def delete( # pylint: disable=inconsistent-return-statements - self, - policy_set_definition_name: str, - **kwargs: Any + self, policy_set_definition_name: str, **kwargs: Any ) -> None: """Deletes a policy set definition. This operation deletes the policy set definition in the given subscription with the given name. - :param policy_set_definition_name: The name of the policy set definition to delete. + :param policy_set_definition_name: The name of the policy set definition to delete. Required. :type policy_set_definition_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: None, or the result of cls(response) + :return: None or the result of cls(response) :rtype: None - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType[None] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + 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', "2018-03-01") # type: str + api_version = kwargs.pop("api_version", _params.pop("api-version", "2018-03-01")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[None] - request = build_policy_set_definitions_delete_request( policy_set_definition_name=policy_set_definition_name, subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.delete.metadata['url'], + template_url=self.delete.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200, 204]: @@ -1560,50 +1992,51 @@ async def delete( # pylint: disable=inconsistent-return-statements if cls: return cls(pipeline_response, None, {}) - delete.metadata = {'url': "/subscriptions/{subscriptionId}/providers/Microsoft.Authorization/policySetDefinitions/{policySetDefinitionName}"} # type: ignore - + delete.metadata = {"url": "/subscriptions/{subscriptionId}/providers/Microsoft.Authorization/policySetDefinitions/{policySetDefinitionName}"} # type: ignore @distributed_trace_async - async def get( - self, - policy_set_definition_name: str, - **kwargs: Any - ) -> "_models.PolicySetDefinition": + async def get(self, policy_set_definition_name: str, **kwargs: Any) -> _models.PolicySetDefinition: """Retrieves a policy set definition. This operation retrieves the policy set definition in the given subscription with the given name. - :param policy_set_definition_name: The name of the policy set definition to get. + :param policy_set_definition_name: The name of the policy set definition to get. Required. :type policy_set_definition_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: PolicySetDefinition, or the result of cls(response) + :return: PolicySetDefinition or the result of cls(response) :rtype: ~azure.mgmt.resource.policy.v2018_03_01.models.PolicySetDefinition - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.PolicySetDefinition"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) - api_version = kwargs.pop('api_version', "2018-03-01") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2018-03-01")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[_models.PolicySetDefinition] - request = build_policy_set_definitions_get_request( policy_set_definition_name=policy_set_definition_name, subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.get.metadata['url'], + template_url=self.get.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200]: @@ -1611,55 +2044,56 @@ async def get( error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - deserialized = self._deserialize('PolicySetDefinition', pipeline_response) + deserialized = self._deserialize("PolicySetDefinition", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - get.metadata = {'url': "/subscriptions/{subscriptionId}/providers/Microsoft.Authorization/policySetDefinitions/{policySetDefinitionName}"} # type: ignore - + get.metadata = {"url": "/subscriptions/{subscriptionId}/providers/Microsoft.Authorization/policySetDefinitions/{policySetDefinitionName}"} # type: ignore @distributed_trace_async - async def get_built_in( - self, - policy_set_definition_name: str, - **kwargs: Any - ) -> "_models.PolicySetDefinition": + async def get_built_in(self, policy_set_definition_name: str, **kwargs: Any) -> _models.PolicySetDefinition: """Retrieves a built in policy set definition. This operation retrieves the built-in policy set definition with the given name. - :param policy_set_definition_name: The name of the policy set definition to get. + :param policy_set_definition_name: The name of the policy set definition to get. Required. :type policy_set_definition_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: PolicySetDefinition, or the result of cls(response) + :return: PolicySetDefinition or the result of cls(response) :rtype: ~azure.mgmt.resource.policy.v2018_03_01.models.PolicySetDefinition - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.PolicySetDefinition"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + 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', "2018-03-01") # type: str + api_version = kwargs.pop("api_version", _params.pop("api-version", "2018-03-01")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[_models.PolicySetDefinition] - request = build_policy_set_definitions_get_built_in_request( policy_set_definition_name=policy_set_definition_name, api_version=api_version, - template_url=self.get_built_in.metadata['url'], + template_url=self.get_built_in.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200]: @@ -1667,58 +2101,62 @@ async def get_built_in( error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - deserialized = self._deserialize('PolicySetDefinition', pipeline_response) + deserialized = self._deserialize("PolicySetDefinition", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - get_built_in.metadata = {'url': "/providers/Microsoft.Authorization/policySetDefinitions/{policySetDefinitionName}"} # type: ignore - + get_built_in.metadata = {"url": "/providers/Microsoft.Authorization/policySetDefinitions/{policySetDefinitionName}"} # type: ignore @distributed_trace - def list( - self, - **kwargs: Any - ) -> AsyncIterable["_models.PolicySetDefinitionListResult"]: + def list(self, **kwargs: Any) -> AsyncIterable["_models.PolicySetDefinition"]: """Retrieves the policy set definitions for a subscription. This operation retrieves a list of all the policy set definitions in the given subscription. :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either PolicySetDefinitionListResult or the result of - cls(response) + :return: An iterator like instance of either PolicySetDefinition or the result of cls(response) :rtype: - ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.resource.policy.v2018_03_01.models.PolicySetDefinitionListResult] - :raises: ~azure.core.exceptions.HttpResponseError + ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.resource.policy.v2018_03_01.models.PolicySetDefinition] + :raises ~azure.core.exceptions.HttpResponseError: """ - api_version = kwargs.pop('api_version', "2018-03-01") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2018-03-01")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[_models.PolicySetDefinitionListResult] - cls = kwargs.pop('cls', None) # type: ClsType["_models.PolicySetDefinitionListResult"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) + def prepare_request(next_link=None): if not next_link: - + request = build_policy_set_definitions_list_request( subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.list.metadata['url'], + template_url=self.list.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore else: - - request = build_policy_set_definitions_list_request( - subscription_id=self._config.subscription_id, - template_url=next_link, - ) + # make call to next link with the client's api-version + _parsed_next_link = urlparse(next_link) + _next_request_params = case_insensitive_dict(parse_qs(_parsed_next_link.query)) + _next_request_params["api-version"] = self._config.api_version + request = HttpRequest("GET", urljoin(next_link, _parsed_next_link.path), params=_next_request_params) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore request.method = "GET" return request @@ -1732,10 +2170,8 @@ async def extract_data(pipeline_response): async def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) response = pipeline_response.http_response @@ -1746,52 +2182,56 @@ async def get_next(next_link=None): return pipeline_response + return AsyncItemPaged(get_next, extract_data) - return AsyncItemPaged( - get_next, extract_data - ) - list.metadata = {'url': "/subscriptions/{subscriptionId}/providers/Microsoft.Authorization/policySetDefinitions"} # type: ignore + list.metadata = {"url": "/subscriptions/{subscriptionId}/providers/Microsoft.Authorization/policySetDefinitions"} # type: ignore @distributed_trace - def list_built_in( - self, - **kwargs: Any - ) -> AsyncIterable["_models.PolicySetDefinitionListResult"]: + def list_built_in(self, **kwargs: Any) -> AsyncIterable["_models.PolicySetDefinition"]: """Retrieves built-in policy set definitions. This operation retrieves a list of all the built-in policy set definitions. :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either PolicySetDefinitionListResult or the result of - cls(response) + :return: An iterator like instance of either PolicySetDefinition or the result of cls(response) :rtype: - ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.resource.policy.v2018_03_01.models.PolicySetDefinitionListResult] - :raises: ~azure.core.exceptions.HttpResponseError + ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.resource.policy.v2018_03_01.models.PolicySetDefinition] + :raises ~azure.core.exceptions.HttpResponseError: """ - api_version = kwargs.pop('api_version', "2018-03-01") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2018-03-01")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[_models.PolicySetDefinitionListResult] - cls = kwargs.pop('cls', None) # type: ClsType["_models.PolicySetDefinitionListResult"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) + def prepare_request(next_link=None): if not next_link: - + request = build_policy_set_definitions_list_built_in_request( api_version=api_version, - template_url=self.list_built_in.metadata['url'], + template_url=self.list_built_in.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore else: - - request = build_policy_set_definitions_list_built_in_request( - template_url=next_link, - ) + # make call to next link with the client's api-version + _parsed_next_link = urlparse(next_link) + _next_request_params = case_insensitive_dict(parse_qs(_parsed_next_link.query)) + _next_request_params["api-version"] = self._config.api_version + request = HttpRequest("GET", urljoin(next_link, _parsed_next_link.path), params=_next_request_params) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore request.method = "GET" return request @@ -1805,10 +2245,8 @@ async def extract_data(pipeline_response): async def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) response = pipeline_response.http_response @@ -1819,46 +2257,120 @@ async def get_next(next_link=None): return pipeline_response + return AsyncItemPaged(get_next, extract_data) - return AsyncItemPaged( - get_next, extract_data - ) - list_built_in.metadata = {'url': "/providers/Microsoft.Authorization/policySetDefinitions"} # type: ignore + list_built_in.metadata = {"url": "/providers/Microsoft.Authorization/policySetDefinitions"} # type: ignore - @distributed_trace_async + @overload async def create_or_update_at_management_group( self, policy_set_definition_name: str, management_group_id: str, - parameters: "_models.PolicySetDefinition", + parameters: _models.PolicySetDefinition, + *, + content_type: str = "application/json", **kwargs: Any - ) -> "_models.PolicySetDefinition": + ) -> _models.PolicySetDefinition: """Creates or updates a policy set definition. This operation creates or updates a policy set definition in the given management group with the given name. - :param policy_set_definition_name: The name of the policy set definition to create. + :param policy_set_definition_name: The name of the policy set definition to create. Required. :type policy_set_definition_name: str - :param management_group_id: The ID of the management group. + :param management_group_id: The ID of the management group. Required. :type management_group_id: str - :param parameters: The policy set definition properties. + :param parameters: The policy set definition properties. Required. :type parameters: ~azure.mgmt.resource.policy.v2018_03_01.models.PolicySetDefinition + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: PolicySetDefinition, or the result of cls(response) + :return: PolicySetDefinition or the result of cls(response) :rtype: ~azure.mgmt.resource.policy.v2018_03_01.models.PolicySetDefinition - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + async def create_or_update_at_management_group( + self, + policy_set_definition_name: str, + management_group_id: str, + parameters: IO, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.PolicySetDefinition: + """Creates or updates a policy set definition. + + This operation creates or updates a policy set definition in the given management group with + the given name. + + :param policy_set_definition_name: The name of the policy set definition to create. Required. + :type policy_set_definition_name: str + :param management_group_id: The ID of the management group. Required. + :type management_group_id: str + :param parameters: The policy set definition properties. Required. + :type parameters: IO + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: PolicySetDefinition or the result of cls(response) + :rtype: ~azure.mgmt.resource.policy.v2018_03_01.models.PolicySetDefinition + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace_async + async def create_or_update_at_management_group( + self, + policy_set_definition_name: str, + management_group_id: str, + parameters: Union[_models.PolicySetDefinition, IO], + **kwargs: Any + ) -> _models.PolicySetDefinition: + """Creates or updates a policy set definition. + + This operation creates or updates a policy set definition in the given management group with + the given name. + + :param policy_set_definition_name: The name of the policy set definition to create. Required. + :type policy_set_definition_name: str + :param management_group_id: The ID of the management group. Required. + :type management_group_id: str + :param parameters: The policy set definition properties. Is either a model type or a IO type. + Required. + :type parameters: ~azure.mgmt.resource.policy.v2018_03_01.models.PolicySetDefinition or IO + :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. + Default value is None. + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: PolicySetDefinition or the result of cls(response) + :rtype: ~azure.mgmt.resource.policy.v2018_03_01.models.PolicySetDefinition + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.PolicySetDefinition"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', "2018-03-01") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + api_version = kwargs.pop("api_version", _params.pop("api-version", "2018-03-01")) # type: str + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.PolicySetDefinition] - _json = self._serialize.body(parameters, 'PolicySetDefinition') + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(parameters, (IO, bytes)): + _content = parameters + else: + _json = self._serialize.body(parameters, "PolicySetDefinition") request = build_policy_set_definitions_create_or_update_at_management_group_request( policy_set_definition_name=policy_set_definition_name, @@ -1866,16 +2378,18 @@ async def create_or_update_at_management_group( api_version=api_version, content_type=content_type, json=_json, - template_url=self.create_or_update_at_management_group.metadata['url'], + content=_content, + template_url=self.create_or_update_at_management_group.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200, 201]: @@ -1884,63 +2398,65 @@ async def create_or_update_at_management_group( raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) if response.status_code == 200: - deserialized = self._deserialize('PolicySetDefinition', pipeline_response) + deserialized = self._deserialize("PolicySetDefinition", pipeline_response) if response.status_code == 201: - deserialized = self._deserialize('PolicySetDefinition', pipeline_response) + deserialized = self._deserialize("PolicySetDefinition", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - create_or_update_at_management_group.metadata = {'url': "/providers/Microsoft.Management/managementgroups/{managementGroupId}/providers/Microsoft.Authorization/policySetDefinitions/{policySetDefinitionName}"} # type: ignore - + create_or_update_at_management_group.metadata = {"url": "/providers/Microsoft.Management/managementgroups/{managementGroupId}/providers/Microsoft.Authorization/policySetDefinitions/{policySetDefinitionName}"} # type: ignore @distributed_trace_async async def delete_at_management_group( # pylint: disable=inconsistent-return-statements - self, - policy_set_definition_name: str, - management_group_id: str, - **kwargs: Any + self, policy_set_definition_name: str, management_group_id: str, **kwargs: Any ) -> None: """Deletes a policy set definition. This operation deletes the policy set definition in the given management group with the given name. - :param policy_set_definition_name: The name of the policy set definition to delete. + :param policy_set_definition_name: The name of the policy set definition to delete. Required. :type policy_set_definition_name: str - :param management_group_id: The ID of the management group. + :param management_group_id: The ID of the management group. Required. :type management_group_id: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: None, or the result of cls(response) + :return: None or the result of cls(response) :rtype: None - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType[None] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + 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', "2018-03-01") # type: str + api_version = kwargs.pop("api_version", _params.pop("api-version", "2018-03-01")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[None] - request = build_policy_set_definitions_delete_at_management_group_request( policy_set_definition_name=policy_set_definition_name, management_group_id=management_group_id, api_version=api_version, - template_url=self.delete_at_management_group.metadata['url'], + template_url=self.delete_at_management_group.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200, 204]: @@ -1951,53 +2467,55 @@ async def delete_at_management_group( # pylint: disable=inconsistent-return-sta if cls: return cls(pipeline_response, None, {}) - delete_at_management_group.metadata = {'url': "/providers/Microsoft.Management/managementgroups/{managementGroupId}/providers/Microsoft.Authorization/policySetDefinitions/{policySetDefinitionName}"} # type: ignore - + delete_at_management_group.metadata = {"url": "/providers/Microsoft.Management/managementgroups/{managementGroupId}/providers/Microsoft.Authorization/policySetDefinitions/{policySetDefinitionName}"} # type: ignore @distributed_trace_async async def get_at_management_group( - self, - policy_set_definition_name: str, - management_group_id: str, - **kwargs: Any - ) -> "_models.PolicySetDefinition": + self, policy_set_definition_name: str, management_group_id: str, **kwargs: Any + ) -> _models.PolicySetDefinition: """Retrieves a policy set definition. This operation retrieves the policy set definition in the given management group with the given name. - :param policy_set_definition_name: The name of the policy set definition to get. + :param policy_set_definition_name: The name of the policy set definition to get. Required. :type policy_set_definition_name: str - :param management_group_id: The ID of the management group. + :param management_group_id: The ID of the management group. Required. :type management_group_id: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: PolicySetDefinition, or the result of cls(response) + :return: PolicySetDefinition or the result of cls(response) :rtype: ~azure.mgmt.resource.policy.v2018_03_01.models.PolicySetDefinition - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.PolicySetDefinition"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + 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', "2018-03-01") # type: str + api_version = kwargs.pop("api_version", _params.pop("api-version", "2018-03-01")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[_models.PolicySetDefinition] - request = build_policy_set_definitions_get_at_management_group_request( policy_set_definition_name=policy_set_definition_name, management_group_id=management_group_id, api_version=api_version, - template_url=self.get_at_management_group.metadata['url'], + template_url=self.get_at_management_group.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200]: @@ -2005,62 +2523,67 @@ async def get_at_management_group( error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - deserialized = self._deserialize('PolicySetDefinition', pipeline_response) + deserialized = self._deserialize("PolicySetDefinition", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - get_at_management_group.metadata = {'url': "/providers/Microsoft.Management/managementgroups/{managementGroupId}/providers/Microsoft.Authorization/policySetDefinitions/{policySetDefinitionName}"} # type: ignore - + get_at_management_group.metadata = {"url": "/providers/Microsoft.Management/managementgroups/{managementGroupId}/providers/Microsoft.Authorization/policySetDefinitions/{policySetDefinitionName}"} # type: ignore @distributed_trace def list_by_management_group( - self, - management_group_id: str, - **kwargs: Any - ) -> AsyncIterable["_models.PolicySetDefinitionListResult"]: + self, management_group_id: str, **kwargs: Any + ) -> AsyncIterable["_models.PolicySetDefinition"]: """Retrieves all policy set definitions in management group. This operation retrieves a list of all the a policy set definition in the given management group. - :param management_group_id: The ID of the management group. + :param management_group_id: The ID of the management group. Required. :type management_group_id: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either PolicySetDefinitionListResult or the result of - cls(response) + :return: An iterator like instance of either PolicySetDefinition or the result of cls(response) :rtype: - ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.resource.policy.v2018_03_01.models.PolicySetDefinitionListResult] - :raises: ~azure.core.exceptions.HttpResponseError + ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.resource.policy.v2018_03_01.models.PolicySetDefinition] + :raises ~azure.core.exceptions.HttpResponseError: """ - api_version = kwargs.pop('api_version', "2018-03-01") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2018-03-01")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[_models.PolicySetDefinitionListResult] - cls = kwargs.pop('cls', None) # type: ClsType["_models.PolicySetDefinitionListResult"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) + def prepare_request(next_link=None): if not next_link: - + request = build_policy_set_definitions_list_by_management_group_request( management_group_id=management_group_id, api_version=api_version, - template_url=self.list_by_management_group.metadata['url'], + template_url=self.list_by_management_group.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore else: - - request = build_policy_set_definitions_list_by_management_group_request( - management_group_id=management_group_id, - template_url=next_link, - ) + # make call to next link with the client's api-version + _parsed_next_link = urlparse(next_link) + _next_request_params = case_insensitive_dict(parse_qs(_parsed_next_link.query)) + _next_request_params["api-version"] = self._config.api_version + request = HttpRequest("GET", urljoin(next_link, _parsed_next_link.path), params=_next_request_params) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore request.method = "GET" return request @@ -2074,10 +2597,8 @@ async def extract_data(pipeline_response): async def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) response = pipeline_response.http_response @@ -2088,8 +2609,6 @@ async def get_next(next_link=None): return pipeline_response + return AsyncItemPaged(get_next, extract_data) - return AsyncItemPaged( - get_next, extract_data - ) - list_by_management_group.metadata = {'url': "/providers/Microsoft.Management/managementgroups/{managementGroupId}/providers/Microsoft.Authorization/policySetDefinitions"} # type: ignore + list_by_management_group.metadata = {"url": "/providers/Microsoft.Management/managementgroups/{managementGroupId}/providers/Microsoft.Authorization/policySetDefinitions"} # type: ignore diff --git a/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/policy/v2018_03_01/aio/operations/_patch.py b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/policy/v2018_03_01/aio/operations/_patch.py new file mode 100644 index 0000000000000..f7dd32510333d --- /dev/null +++ b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/policy/v2018_03_01/aio/operations/_patch.py @@ -0,0 +1,20 @@ +# ------------------------------------ +# Copyright (c) Microsoft Corporation. +# Licensed under the MIT License. +# ------------------------------------ +"""Customize generated code here. + +Follow our quickstart for examples: https://aka.ms/azsdk/python/dpcodegen/python/customize +""" +from typing import List + +__all__: List[str] = [] # Add all objects you want publicly available to users at this package level + + +def patch_sdk(): + """Do not remove from this file. + + `patch_sdk` is a last resort escape hatch that allows you to do customizations + you can't accomplish using the techniques described in + https://aka.ms/azsdk/python/dpcodegen/python/customize + """ diff --git a/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/policy/v2018_03_01/models/__init__.py b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/policy/v2018_03_01/models/__init__.py index 79ebbf2e7efdc..1b8c682c598ba 100644 --- a/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/policy/v2018_03_01/models/__init__.py +++ b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/policy/v2018_03_01/models/__init__.py @@ -16,22 +16,24 @@ from ._models_py3 import PolicySetDefinitionListResult from ._models_py3 import PolicySku - -from ._policy_client_enums import ( - PolicyMode, - PolicyType, -) +from ._policy_client_enums import PolicyMode +from ._policy_client_enums import PolicyType +from ._patch import __all__ as _patch_all +from ._patch import * # type: ignore # pylint: disable=unused-wildcard-import +from ._patch import patch_sdk as _patch_sdk __all__ = [ - 'ErrorResponse', - 'PolicyAssignment', - 'PolicyAssignmentListResult', - 'PolicyDefinition', - 'PolicyDefinitionListResult', - 'PolicyDefinitionReference', - 'PolicySetDefinition', - 'PolicySetDefinitionListResult', - 'PolicySku', - 'PolicyMode', - 'PolicyType', + "ErrorResponse", + "PolicyAssignment", + "PolicyAssignmentListResult", + "PolicyDefinition", + "PolicyDefinitionListResult", + "PolicyDefinitionReference", + "PolicySetDefinition", + "PolicySetDefinitionListResult", + "PolicySku", + "PolicyMode", + "PolicyType", ] +__all__.extend([p for p in _patch_all if p not in __all__]) +_patch_sdk() diff --git a/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/policy/v2018_03_01/models/_models_py3.py b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/policy/v2018_03_01/models/_models_py3.py index eb94b7b8062b8..6f45eeb86e32d 100644 --- a/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/policy/v2018_03_01/models/_models_py3.py +++ b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/policy/v2018_03_01/models/_models_py3.py @@ -1,4 +1,5 @@ # coding=utf-8 +# pylint: disable=too-many-lines # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. # Licensed under the MIT License. See License.txt in the project root for license information. @@ -6,15 +7,22 @@ # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -from typing import Any, List, Optional, Union +import sys +from typing import Any, List, Optional, TYPE_CHECKING, Union -from azure.core.exceptions import HttpResponseError -import msrest.serialization +from ... import _serialization -from ._policy_client_enums import * +if TYPE_CHECKING: + # pylint: disable=unused-import,ungrouped-imports + from .. import models as _models +if sys.version_info >= (3, 9): + from collections.abc import MutableMapping +else: + from typing import MutableMapping # type: ignore # pylint: disable=ungrouped-imports +JSON = MutableMapping[str, Any] # pylint: disable=unsubscriptable-object -class ErrorResponse(msrest.serialization.Model): +class ErrorResponse(_serialization.Model): """Error response indicates Azure Resource Manager is not able to process the incoming request. The reason is provided in the error message. :ivar http_status: Http status code. @@ -26,9 +34,9 @@ class ErrorResponse(msrest.serialization.Model): """ _attribute_map = { - 'http_status': {'key': 'httpStatus', 'type': 'str'}, - 'error_code': {'key': 'errorCode', 'type': 'str'}, - 'error_message': {'key': 'errorMessage', 'type': 'str'}, + "http_status": {"key": "httpStatus", "type": "str"}, + "error_code": {"key": "errorCode", "type": "str"}, + "error_message": {"key": "errorMessage", "type": "str"}, } def __init__( @@ -47,13 +55,13 @@ def __init__( :keyword error_message: Error message indicating why the operation failed. :paramtype error_message: str """ - super(ErrorResponse, self).__init__(**kwargs) + super().__init__(**kwargs) self.http_status = http_status self.error_code = error_code self.error_message = error_message -class PolicyAssignment(msrest.serialization.Model): +class PolicyAssignment(_serialization.Model): # pylint: disable=too-many-instance-attributes """The policy assignment. Variables are only populated by the server, and will be ignored when sending a request. @@ -76,44 +84,44 @@ class PolicyAssignment(msrest.serialization.Model): :ivar not_scopes: The policy's excluded scopes. :vartype not_scopes: list[str] :ivar parameters: Required if a parameter is used in policy rule. - :vartype parameters: any + :vartype parameters: JSON :ivar description: This message will be part of response in case of policy violation. :vartype description: str :ivar metadata: The policy assignment metadata. - :vartype metadata: any + :vartype metadata: JSON """ _validation = { - 'id': {'readonly': True}, - 'type': {'readonly': True}, - 'name': {'readonly': True}, + "id": {"readonly": True}, + "type": {"readonly": True}, + "name": {"readonly": True}, } _attribute_map = { - 'id': {'key': 'id', 'type': 'str'}, - 'type': {'key': 'type', 'type': 'str'}, - 'name': {'key': 'name', 'type': 'str'}, - 'sku': {'key': 'sku', 'type': 'PolicySku'}, - 'display_name': {'key': 'properties.displayName', 'type': 'str'}, - 'policy_definition_id': {'key': 'properties.policyDefinitionId', 'type': 'str'}, - 'scope': {'key': 'properties.scope', 'type': 'str'}, - 'not_scopes': {'key': 'properties.notScopes', 'type': '[str]'}, - 'parameters': {'key': 'properties.parameters', 'type': 'object'}, - 'description': {'key': 'properties.description', 'type': 'str'}, - 'metadata': {'key': 'properties.metadata', 'type': 'object'}, + "id": {"key": "id", "type": "str"}, + "type": {"key": "type", "type": "str"}, + "name": {"key": "name", "type": "str"}, + "sku": {"key": "sku", "type": "PolicySku"}, + "display_name": {"key": "properties.displayName", "type": "str"}, + "policy_definition_id": {"key": "properties.policyDefinitionId", "type": "str"}, + "scope": {"key": "properties.scope", "type": "str"}, + "not_scopes": {"key": "properties.notScopes", "type": "[str]"}, + "parameters": {"key": "properties.parameters", "type": "object"}, + "description": {"key": "properties.description", "type": "str"}, + "metadata": {"key": "properties.metadata", "type": "object"}, } def __init__( self, *, - sku: Optional["PolicySku"] = None, + sku: Optional["_models.PolicySku"] = None, display_name: Optional[str] = None, policy_definition_id: Optional[str] = None, scope: Optional[str] = None, not_scopes: Optional[List[str]] = None, - parameters: Optional[Any] = None, + parameters: Optional[JSON] = None, description: Optional[str] = None, - metadata: Optional[Any] = None, + metadata: Optional[JSON] = None, **kwargs ): """ @@ -129,13 +137,13 @@ def __init__( :keyword not_scopes: The policy's excluded scopes. :paramtype not_scopes: list[str] :keyword parameters: Required if a parameter is used in policy rule. - :paramtype parameters: any + :paramtype parameters: JSON :keyword description: This message will be part of response in case of policy violation. :paramtype description: str :keyword metadata: The policy assignment metadata. - :paramtype metadata: any + :paramtype metadata: JSON """ - super(PolicyAssignment, self).__init__(**kwargs) + super().__init__(**kwargs) self.id = None self.type = None self.name = None @@ -149,7 +157,7 @@ def __init__( self.metadata = metadata -class PolicyAssignmentListResult(msrest.serialization.Model): +class PolicyAssignmentListResult(_serialization.Model): """List of policy assignments. :ivar value: An array of policy assignments. @@ -159,16 +167,12 @@ class PolicyAssignmentListResult(msrest.serialization.Model): """ _attribute_map = { - 'value': {'key': 'value', 'type': '[PolicyAssignment]'}, - 'next_link': {'key': 'nextLink', 'type': 'str'}, + "value": {"key": "value", "type": "[PolicyAssignment]"}, + "next_link": {"key": "nextLink", "type": "str"}, } def __init__( - self, - *, - value: Optional[List["PolicyAssignment"]] = None, - next_link: Optional[str] = None, - **kwargs + self, *, value: Optional[List["_models.PolicyAssignment"]] = None, next_link: Optional[str] = None, **kwargs ): """ :keyword value: An array of policy assignments. @@ -176,12 +180,12 @@ def __init__( :keyword next_link: The URL to use for getting the next set of results. :paramtype next_link: str """ - super(PolicyAssignmentListResult, self).__init__(**kwargs) + super().__init__(**kwargs) self.value = value self.next_link = next_link -class PolicyDefinition(msrest.serialization.Model): +class PolicyDefinition(_serialization.Model): """The policy definition. Variables are only populated by the server, and will be ignored when sending a request. @@ -193,73 +197,73 @@ class PolicyDefinition(msrest.serialization.Model): :ivar type: The type of the resource (Microsoft.Authorization/policyDefinitions). :vartype type: str :ivar policy_type: The type of policy definition. Possible values are NotSpecified, BuiltIn, - and Custom. Possible values include: "NotSpecified", "BuiltIn", "Custom". + and Custom. Known values are: "NotSpecified", "BuiltIn", and "Custom". :vartype policy_type: str or ~azure.mgmt.resource.policy.v2018_03_01.models.PolicyType :ivar mode: The policy definition mode. Possible values are NotSpecified, Indexed, and All. - Possible values include: "NotSpecified", "Indexed", "All". + Known values are: "NotSpecified", "Indexed", and "All". :vartype mode: str or ~azure.mgmt.resource.policy.v2018_03_01.models.PolicyMode :ivar display_name: The display name of the policy definition. :vartype display_name: str :ivar description: The policy definition description. :vartype description: str :ivar policy_rule: The policy rule. - :vartype policy_rule: any + :vartype policy_rule: JSON :ivar metadata: The policy definition metadata. - :vartype metadata: any + :vartype metadata: JSON :ivar parameters: Required if a parameter is used in policy rule. - :vartype parameters: any + :vartype parameters: JSON """ _validation = { - 'id': {'readonly': True}, - 'name': {'readonly': True}, - 'type': {'readonly': True}, + "id": {"readonly": True}, + "name": {"readonly": True}, + "type": {"readonly": True}, } _attribute_map = { - 'id': {'key': 'id', 'type': 'str'}, - 'name': {'key': 'name', 'type': 'str'}, - 'type': {'key': 'type', 'type': 'str'}, - 'policy_type': {'key': 'properties.policyType', 'type': 'str'}, - 'mode': {'key': 'properties.mode', 'type': 'str'}, - 'display_name': {'key': 'properties.displayName', 'type': 'str'}, - 'description': {'key': 'properties.description', 'type': 'str'}, - 'policy_rule': {'key': 'properties.policyRule', 'type': 'object'}, - 'metadata': {'key': 'properties.metadata', 'type': 'object'}, - 'parameters': {'key': 'properties.parameters', 'type': 'object'}, + "id": {"key": "id", "type": "str"}, + "name": {"key": "name", "type": "str"}, + "type": {"key": "type", "type": "str"}, + "policy_type": {"key": "properties.policyType", "type": "str"}, + "mode": {"key": "properties.mode", "type": "str"}, + "display_name": {"key": "properties.displayName", "type": "str"}, + "description": {"key": "properties.description", "type": "str"}, + "policy_rule": {"key": "properties.policyRule", "type": "object"}, + "metadata": {"key": "properties.metadata", "type": "object"}, + "parameters": {"key": "properties.parameters", "type": "object"}, } def __init__( self, *, - policy_type: Optional[Union[str, "PolicyType"]] = None, - mode: Optional[Union[str, "PolicyMode"]] = None, + policy_type: Optional[Union[str, "_models.PolicyType"]] = None, + mode: Optional[Union[str, "_models.PolicyMode"]] = None, display_name: Optional[str] = None, description: Optional[str] = None, - policy_rule: Optional[Any] = None, - metadata: Optional[Any] = None, - parameters: Optional[Any] = None, + policy_rule: Optional[JSON] = None, + metadata: Optional[JSON] = None, + parameters: Optional[JSON] = None, **kwargs ): """ :keyword policy_type: The type of policy definition. Possible values are NotSpecified, BuiltIn, - and Custom. Possible values include: "NotSpecified", "BuiltIn", "Custom". + and Custom. Known values are: "NotSpecified", "BuiltIn", and "Custom". :paramtype policy_type: str or ~azure.mgmt.resource.policy.v2018_03_01.models.PolicyType :keyword mode: The policy definition mode. Possible values are NotSpecified, Indexed, and All. - Possible values include: "NotSpecified", "Indexed", "All". + Known values are: "NotSpecified", "Indexed", and "All". :paramtype mode: str or ~azure.mgmt.resource.policy.v2018_03_01.models.PolicyMode :keyword display_name: The display name of the policy definition. :paramtype display_name: str :keyword description: The policy definition description. :paramtype description: str :keyword policy_rule: The policy rule. - :paramtype policy_rule: any + :paramtype policy_rule: JSON :keyword metadata: The policy definition metadata. - :paramtype metadata: any + :paramtype metadata: JSON :keyword parameters: Required if a parameter is used in policy rule. - :paramtype parameters: any + :paramtype parameters: JSON """ - super(PolicyDefinition, self).__init__(**kwargs) + super().__init__(**kwargs) self.id = None self.name = None self.type = None @@ -272,7 +276,7 @@ def __init__( self.parameters = parameters -class PolicyDefinitionListResult(msrest.serialization.Model): +class PolicyDefinitionListResult(_serialization.Model): """List of policy definitions. :ivar value: An array of policy definitions. @@ -282,16 +286,12 @@ class PolicyDefinitionListResult(msrest.serialization.Model): """ _attribute_map = { - 'value': {'key': 'value', 'type': '[PolicyDefinition]'}, - 'next_link': {'key': 'nextLink', 'type': 'str'}, + "value": {"key": "value", "type": "[PolicyDefinition]"}, + "next_link": {"key": "nextLink", "type": "str"}, } def __init__( - self, - *, - value: Optional[List["PolicyDefinition"]] = None, - next_link: Optional[str] = None, - **kwargs + self, *, value: Optional[List["_models.PolicyDefinition"]] = None, next_link: Optional[str] = None, **kwargs ): """ :keyword value: An array of policy definitions. @@ -299,44 +299,38 @@ def __init__( :keyword next_link: The URL to use for getting the next set of results. :paramtype next_link: str """ - super(PolicyDefinitionListResult, self).__init__(**kwargs) + super().__init__(**kwargs) self.value = value self.next_link = next_link -class PolicyDefinitionReference(msrest.serialization.Model): +class PolicyDefinitionReference(_serialization.Model): """The policy definition reference. :ivar policy_definition_id: The ID of the policy definition or policy set definition. :vartype policy_definition_id: str :ivar parameters: Required if a parameter is used in policy rule. - :vartype parameters: any + :vartype parameters: JSON """ _attribute_map = { - 'policy_definition_id': {'key': 'policyDefinitionId', 'type': 'str'}, - 'parameters': {'key': 'parameters', 'type': 'object'}, + "policy_definition_id": {"key": "policyDefinitionId", "type": "str"}, + "parameters": {"key": "parameters", "type": "object"}, } - def __init__( - self, - *, - policy_definition_id: Optional[str] = None, - parameters: Optional[Any] = None, - **kwargs - ): + def __init__(self, *, policy_definition_id: Optional[str] = None, parameters: Optional[JSON] = None, **kwargs): """ :keyword policy_definition_id: The ID of the policy definition or policy set definition. :paramtype policy_definition_id: str :keyword parameters: Required if a parameter is used in policy rule. - :paramtype parameters: any + :paramtype parameters: JSON """ - super(PolicyDefinitionReference, self).__init__(**kwargs) + super().__init__(**kwargs) self.policy_definition_id = policy_definition_id self.parameters = parameters -class PolicySetDefinition(msrest.serialization.Model): +class PolicySetDefinition(_serialization.Model): """The policy set definition. Variables are only populated by the server, and will be ignored when sending a request. @@ -348,69 +342,69 @@ class PolicySetDefinition(msrest.serialization.Model): :ivar type: The type of the resource (Microsoft.Authorization/policySetDefinitions). :vartype type: str :ivar policy_type: The type of policy definition. Possible values are NotSpecified, BuiltIn, - and Custom. Possible values include: "NotSpecified", "BuiltIn", "Custom". + and Custom. Known values are: "NotSpecified", "BuiltIn", and "Custom". :vartype policy_type: str or ~azure.mgmt.resource.policy.v2018_03_01.models.PolicyType :ivar display_name: The display name of the policy set definition. :vartype display_name: str :ivar description: The policy set definition description. :vartype description: str :ivar metadata: The policy set definition metadata. - :vartype metadata: any + :vartype metadata: JSON :ivar parameters: The policy set definition parameters that can be used in policy definition references. - :vartype parameters: any + :vartype parameters: JSON :ivar policy_definitions: An array of policy definition references. :vartype policy_definitions: list[~azure.mgmt.resource.policy.v2018_03_01.models.PolicyDefinitionReference] """ _validation = { - 'id': {'readonly': True}, - 'name': {'readonly': True}, - 'type': {'readonly': True}, + "id": {"readonly": True}, + "name": {"readonly": True}, + "type": {"readonly": True}, } _attribute_map = { - 'id': {'key': 'id', 'type': 'str'}, - 'name': {'key': 'name', 'type': 'str'}, - 'type': {'key': 'type', 'type': 'str'}, - 'policy_type': {'key': 'properties.policyType', 'type': 'str'}, - 'display_name': {'key': 'properties.displayName', 'type': 'str'}, - 'description': {'key': 'properties.description', 'type': 'str'}, - 'metadata': {'key': 'properties.metadata', 'type': 'object'}, - 'parameters': {'key': 'properties.parameters', 'type': 'object'}, - 'policy_definitions': {'key': 'properties.policyDefinitions', 'type': '[PolicyDefinitionReference]'}, + "id": {"key": "id", "type": "str"}, + "name": {"key": "name", "type": "str"}, + "type": {"key": "type", "type": "str"}, + "policy_type": {"key": "properties.policyType", "type": "str"}, + "display_name": {"key": "properties.displayName", "type": "str"}, + "description": {"key": "properties.description", "type": "str"}, + "metadata": {"key": "properties.metadata", "type": "object"}, + "parameters": {"key": "properties.parameters", "type": "object"}, + "policy_definitions": {"key": "properties.policyDefinitions", "type": "[PolicyDefinitionReference]"}, } def __init__( self, *, - policy_type: Optional[Union[str, "PolicyType"]] = None, + policy_type: Optional[Union[str, "_models.PolicyType"]] = None, display_name: Optional[str] = None, description: Optional[str] = None, - metadata: Optional[Any] = None, - parameters: Optional[Any] = None, - policy_definitions: Optional[List["PolicyDefinitionReference"]] = None, + metadata: Optional[JSON] = None, + parameters: Optional[JSON] = None, + policy_definitions: Optional[List["_models.PolicyDefinitionReference"]] = None, **kwargs ): """ :keyword policy_type: The type of policy definition. Possible values are NotSpecified, BuiltIn, - and Custom. Possible values include: "NotSpecified", "BuiltIn", "Custom". + and Custom. Known values are: "NotSpecified", "BuiltIn", and "Custom". :paramtype policy_type: str or ~azure.mgmt.resource.policy.v2018_03_01.models.PolicyType :keyword display_name: The display name of the policy set definition. :paramtype display_name: str :keyword description: The policy set definition description. :paramtype description: str :keyword metadata: The policy set definition metadata. - :paramtype metadata: any + :paramtype metadata: JSON :keyword parameters: The policy set definition parameters that can be used in policy definition references. - :paramtype parameters: any + :paramtype parameters: JSON :keyword policy_definitions: An array of policy definition references. :paramtype policy_definitions: list[~azure.mgmt.resource.policy.v2018_03_01.models.PolicyDefinitionReference] """ - super(PolicySetDefinition, self).__init__(**kwargs) + super().__init__(**kwargs) self.id = None self.name = None self.type = None @@ -422,7 +416,7 @@ def __init__( self.policy_definitions = policy_definitions -class PolicySetDefinitionListResult(msrest.serialization.Model): +class PolicySetDefinitionListResult(_serialization.Model): """List of policy set definitions. :ivar value: An array of policy set definitions. @@ -432,16 +426,12 @@ class PolicySetDefinitionListResult(msrest.serialization.Model): """ _attribute_map = { - 'value': {'key': 'value', 'type': '[PolicySetDefinition]'}, - 'next_link': {'key': 'nextLink', 'type': 'str'}, + "value": {"key": "value", "type": "[PolicySetDefinition]"}, + "next_link": {"key": "nextLink", "type": "str"}, } def __init__( - self, - *, - value: Optional[List["PolicySetDefinition"]] = None, - next_link: Optional[str] = None, - **kwargs + self, *, value: Optional[List["_models.PolicySetDefinition"]] = None, next_link: Optional[str] = None, **kwargs ): """ :keyword value: An array of policy set definitions. @@ -449,44 +439,38 @@ def __init__( :keyword next_link: The URL to use for getting the next set of results. :paramtype next_link: str """ - super(PolicySetDefinitionListResult, self).__init__(**kwargs) + super().__init__(**kwargs) self.value = value self.next_link = next_link -class PolicySku(msrest.serialization.Model): +class PolicySku(_serialization.Model): """The policy sku. This property is optional, obsolete, and will be ignored. All required parameters must be populated in order to send to Azure. - :ivar name: Required. The name of the policy sku. Possible values are A0 and A1. + :ivar name: The name of the policy sku. Possible values are A0 and A1. Required. :vartype name: str :ivar tier: The policy sku tier. Possible values are Free and Standard. :vartype tier: str """ _validation = { - 'name': {'required': True}, + "name": {"required": True}, } _attribute_map = { - 'name': {'key': 'name', 'type': 'str'}, - 'tier': {'key': 'tier', 'type': 'str'}, + "name": {"key": "name", "type": "str"}, + "tier": {"key": "tier", "type": "str"}, } - def __init__( - self, - *, - name: str, - tier: Optional[str] = None, - **kwargs - ): + def __init__(self, *, name: str, tier: Optional[str] = None, **kwargs): """ - :keyword name: Required. The name of the policy sku. Possible values are A0 and A1. + :keyword name: The name of the policy sku. Possible values are A0 and A1. Required. :paramtype name: str :keyword tier: The policy sku tier. Possible values are Free and Standard. :paramtype tier: str """ - super(PolicySku, self).__init__(**kwargs) + super().__init__(**kwargs) self.name = name self.tier = tier diff --git a/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/policy/v2018_03_01/models/_patch.py b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/policy/v2018_03_01/models/_patch.py new file mode 100644 index 0000000000000..f7dd32510333d --- /dev/null +++ b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/policy/v2018_03_01/models/_patch.py @@ -0,0 +1,20 @@ +# ------------------------------------ +# Copyright (c) Microsoft Corporation. +# Licensed under the MIT License. +# ------------------------------------ +"""Customize generated code here. + +Follow our quickstart for examples: https://aka.ms/azsdk/python/dpcodegen/python/customize +""" +from typing import List + +__all__: List[str] = [] # Add all objects you want publicly available to users at this package level + + +def patch_sdk(): + """Do not remove from this file. + + `patch_sdk` is a last resort escape hatch that allows you to do customizations + you can't accomplish using the techniques described in + https://aka.ms/azsdk/python/dpcodegen/python/customize + """ diff --git a/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/policy/v2018_03_01/models/_policy_client_enums.py b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/policy/v2018_03_01/models/_policy_client_enums.py index 2acd4055af049..5a5cb27e9884c 100644 --- a/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/policy/v2018_03_01/models/_policy_client_enums.py +++ b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/policy/v2018_03_01/models/_policy_client_enums.py @@ -7,21 +7,19 @@ # -------------------------------------------------------------------------- from enum import Enum -from six import with_metaclass from azure.core import CaseInsensitiveEnumMeta -class PolicyMode(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): - """The policy definition mode. Possible values are NotSpecified, Indexed, and All. - """ +class PolicyMode(str, Enum, metaclass=CaseInsensitiveEnumMeta): + """The policy definition mode. Possible values are NotSpecified, Indexed, and All.""" NOT_SPECIFIED = "NotSpecified" INDEXED = "Indexed" ALL = "All" -class PolicyType(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): - """The type of policy definition. Possible values are NotSpecified, BuiltIn, and Custom. - """ + +class PolicyType(str, Enum, metaclass=CaseInsensitiveEnumMeta): + """The type of policy definition. Possible values are NotSpecified, BuiltIn, and Custom.""" NOT_SPECIFIED = "NotSpecified" BUILT_IN = "BuiltIn" diff --git a/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/policy/v2018_03_01/operations/__init__.py b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/policy/v2018_03_01/operations/__init__.py index b2ae6190b03fb..4e1971e3e3247 100644 --- a/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/policy/v2018_03_01/operations/__init__.py +++ b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/policy/v2018_03_01/operations/__init__.py @@ -10,8 +10,14 @@ from ._operations import PolicyDefinitionsOperations from ._operations import PolicySetDefinitionsOperations +from ._patch import __all__ as _patch_all +from ._patch import * # type: ignore # pylint: disable=unused-wildcard-import +from ._patch import patch_sdk as _patch_sdk + __all__ = [ - 'PolicyAssignmentsOperations', - 'PolicyDefinitionsOperations', - 'PolicySetDefinitionsOperations', + "PolicyAssignmentsOperations", + "PolicyDefinitionsOperations", + "PolicySetDefinitionsOperations", ] +__all__.extend([p for p in _patch_all if p not in __all__]) +_patch_sdk() diff --git a/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/policy/v2018_03_01/operations/_operations.py b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/policy/v2018_03_01/operations/_operations.py index d8b51262207e8..0e8167436d03b 100644 --- a/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/policy/v2018_03_01/operations/_operations.py +++ b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/policy/v2018_03_01/operations/_operations.py @@ -6,173 +6,152 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -from typing import Any, Callable, Dict, Iterable, Optional, TypeVar - -from msrest import Serializer - -from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error +from typing import Any, Callable, Dict, IO, Iterable, Optional, TypeVar, Union, overload +from urllib.parse import parse_qs, urljoin, urlparse + +from azure.core.exceptions import ( + ClientAuthenticationError, + HttpResponseError, + ResourceExistsError, + ResourceNotFoundError, + ResourceNotModifiedError, + map_error, +) from azure.core.paging import ItemPaged from azure.core.pipeline import PipelineResponse from azure.core.pipeline.transport import HttpResponse from azure.core.rest import HttpRequest from azure.core.tracing.decorator import distributed_trace +from azure.core.utils import case_insensitive_dict from azure.mgmt.core.exceptions import ARMErrorFormat from .. import models as _models +from ..._serialization import Serializer from .._vendor import _convert_request, _format_url_section -T = TypeVar('T') -JSONType = Any + +T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] _SERIALIZER = Serializer() _SERIALIZER.client_side_validation = False -def build_policy_assignments_delete_request( - scope: str, - policy_assignment_name: str, - **kwargs: Any -) -> HttpRequest: - api_version = kwargs.pop('api_version', "2018-03-01") # type: str - accept = "application/json" +def build_policy_assignments_delete_request(scope: str, policy_assignment_name: 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", "2018-03-01")) # type: str + accept = _headers.pop("Accept", "application/json") + # Construct URL - _url = kwargs.pop("template_url", "/{scope}/providers/Microsoft.Authorization/policyAssignments/{policyAssignmentName}") + _url = kwargs.pop( + "template_url", "/{scope}/providers/Microsoft.Authorization/policyAssignments/{policyAssignmentName}" + ) path_format_arguments = { - "scope": _SERIALIZER.url("scope", scope, 'str', skip_quote=True), - "policyAssignmentName": _SERIALIZER.url("policy_assignment_name", policy_assignment_name, 'str'), + "scope": _SERIALIZER.url("scope", scope, "str", skip_quote=True), + "policyAssignmentName": _SERIALIZER.url("policy_assignment_name", policy_assignment_name, "str"), } _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') - - return HttpRequest( - method="DELETE", - url=_url, - params=_query_parameters, - headers=_header_parameters, - **kwargs - ) + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + return HttpRequest(method="DELETE", url=_url, params=_params, headers=_headers, **kwargs) -def build_policy_assignments_create_request( - scope: str, - policy_assignment_name: str, - *, - json: JSONType = None, - content: Any = None, - **kwargs: Any -) -> HttpRequest: - api_version = kwargs.pop('api_version', "2018-03-01") # type: str - content_type = kwargs.pop('content_type', None) # type: Optional[str] - accept = "application/json" +def build_policy_assignments_create_request(scope: str, policy_assignment_name: 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", "2018-03-01")) # type: str + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + accept = _headers.pop("Accept", "application/json") + # Construct URL - _url = kwargs.pop("template_url", "/{scope}/providers/Microsoft.Authorization/policyAssignments/{policyAssignmentName}") + _url = kwargs.pop( + "template_url", "/{scope}/providers/Microsoft.Authorization/policyAssignments/{policyAssignmentName}" + ) path_format_arguments = { - "scope": _SERIALIZER.url("scope", scope, 'str', skip_quote=True), - "policyAssignmentName": _SERIALIZER.url("policy_assignment_name", policy_assignment_name, 'str'), + "scope": _SERIALIZER.url("scope", scope, "str", skip_quote=True), + "policyAssignmentName": _SERIALIZER.url("policy_assignment_name", policy_assignment_name, "str"), } _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] if content_type is not None: - _header_parameters['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') - _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') - - return HttpRequest( - method="PUT", - url=_url, - params=_query_parameters, - headers=_header_parameters, - json=json, - content=content, - **kwargs - ) + _headers["Content-Type"] = _SERIALIZER.header("content_type", content_type, "str") + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + return HttpRequest(method="PUT", url=_url, params=_params, headers=_headers, **kwargs) -def build_policy_assignments_get_request( - scope: str, - policy_assignment_name: str, - **kwargs: Any -) -> HttpRequest: - api_version = kwargs.pop('api_version', "2018-03-01") # type: str - accept = "application/json" +def build_policy_assignments_get_request(scope: str, policy_assignment_name: 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", "2018-03-01")) # type: str + accept = _headers.pop("Accept", "application/json") + # Construct URL - _url = kwargs.pop("template_url", "/{scope}/providers/Microsoft.Authorization/policyAssignments/{policyAssignmentName}") + _url = kwargs.pop( + "template_url", "/{scope}/providers/Microsoft.Authorization/policyAssignments/{policyAssignmentName}" + ) path_format_arguments = { - "scope": _SERIALIZER.url("scope", scope, 'str', skip_quote=True), - "policyAssignmentName": _SERIALIZER.url("policy_assignment_name", policy_assignment_name, 'str'), + "scope": _SERIALIZER.url("scope", scope, "str", skip_quote=True), + "policyAssignmentName": _SERIALIZER.url("policy_assignment_name", policy_assignment_name, "str"), } _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') - - return HttpRequest( - method="GET", - url=_url, - params=_query_parameters, - headers=_header_parameters, - **kwargs - ) + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) def build_policy_assignments_list_for_resource_group_request( - resource_group_name: str, - subscription_id: str, - *, - filter: Optional[str] = None, - **kwargs: Any + resource_group_name: str, subscription_id: str, *, filter: Optional[str] = None, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2018-03-01") # type: 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", "2018-03-01")) # type: str + accept = _headers.pop("Accept", "application/json") - accept = "application/json" # Construct URL - _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Authorization/policyAssignments") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Authorization/policyAssignments", + ) # pylint: disable=line-too-long path_format_arguments = { - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._\(\)]+$'), - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), + "resourceGroupName": _SERIALIZER.url( + "resource_group_name", resource_group_name, "str", max_length=90, min_length=1, pattern=r"^[-\w\._\(\)]+$" + ), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), } _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] if filter is not None: - _query_parameters['$filter'] = _SERIALIZER.query("filter", filter, 'str', skip_quote=True) - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["$filter"] = _SERIALIZER.query("filter", filter, "str", skip_quote=True) + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') - - return HttpRequest( - method="GET", - url=_url, - params=_query_parameters, - headers=_header_parameters, - **kwargs - ) + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) def build_policy_assignments_list_for_resource_request( @@ -186,881 +165,723 @@ def build_policy_assignments_list_for_resource_request( filter: Optional[str] = None, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2018-03-01") # type: 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", "2018-03-01")) # type: str + accept = _headers.pop("Accept", "application/json") - accept = "application/json" # Construct URL - _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{parentResourcePath}/{resourceType}/{resourceName}/providers/Microsoft.Authorization/policyAssignments") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{parentResourcePath}/{resourceType}/{resourceName}/providers/Microsoft.Authorization/policyAssignments", + ) # pylint: disable=line-too-long path_format_arguments = { - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._\(\)]+$'), - "resourceProviderNamespace": _SERIALIZER.url("resource_provider_namespace", resource_provider_namespace, 'str'), - "parentResourcePath": _SERIALIZER.url("parent_resource_path", parent_resource_path, 'str', skip_quote=True), - "resourceType": _SERIALIZER.url("resource_type", resource_type, 'str', skip_quote=True), - "resourceName": _SERIALIZER.url("resource_name", resource_name, 'str'), - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), + "resourceGroupName": _SERIALIZER.url( + "resource_group_name", resource_group_name, "str", max_length=90, min_length=1, pattern=r"^[-\w\._\(\)]+$" + ), + "resourceProviderNamespace": _SERIALIZER.url("resource_provider_namespace", resource_provider_namespace, "str"), + "parentResourcePath": _SERIALIZER.url("parent_resource_path", parent_resource_path, "str", skip_quote=True), + "resourceType": _SERIALIZER.url("resource_type", resource_type, "str", skip_quote=True), + "resourceName": _SERIALIZER.url("resource_name", resource_name, "str"), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), } _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] if filter is not None: - _query_parameters['$filter'] = _SERIALIZER.query("filter", filter, 'str') - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["$filter"] = _SERIALIZER.query("filter", filter, "str") + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') - - return HttpRequest( - method="GET", - url=_url, - params=_query_parameters, - headers=_header_parameters, - **kwargs - ) + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) def build_policy_assignments_list_request( - subscription_id: str, - *, - filter: Optional[str] = None, - **kwargs: Any + subscription_id: str, *, filter: Optional[str] = None, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2018-03-01") # type: 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", "2018-03-01")) # type: str + accept = _headers.pop("Accept", "application/json") - accept = "application/json" # Construct URL - _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/providers/Microsoft.Authorization/policyAssignments") + _url = kwargs.pop( + "template_url", "/subscriptions/{subscriptionId}/providers/Microsoft.Authorization/policyAssignments" + ) path_format_arguments = { - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), } _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] if filter is not None: - _query_parameters['$filter'] = _SERIALIZER.query("filter", filter, 'str') - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["$filter"] = _SERIALIZER.query("filter", filter, "str") + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') - - return HttpRequest( - method="GET", - url=_url, - params=_query_parameters, - headers=_header_parameters, - **kwargs - ) + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) -def build_policy_assignments_delete_by_id_request( - policy_assignment_id: str, - **kwargs: Any -) -> HttpRequest: - api_version = kwargs.pop('api_version', "2018-03-01") # type: str - accept = "application/json" +def build_policy_assignments_delete_by_id_request(policy_assignment_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", "2018-03-01")) # type: str + accept = _headers.pop("Accept", "application/json") + # Construct URL _url = kwargs.pop("template_url", "/{policyAssignmentId}") path_format_arguments = { - "policyAssignmentId": _SERIALIZER.url("policy_assignment_id", policy_assignment_id, 'str', skip_quote=True), + "policyAssignmentId": _SERIALIZER.url("policy_assignment_id", policy_assignment_id, "str", skip_quote=True), } _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') - - return HttpRequest( - method="DELETE", - url=_url, - params=_query_parameters, - headers=_header_parameters, - **kwargs - ) + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + return HttpRequest(method="DELETE", url=_url, params=_params, headers=_headers, **kwargs) -def build_policy_assignments_create_by_id_request( - policy_assignment_id: str, - *, - json: JSONType = None, - content: Any = None, - **kwargs: Any -) -> HttpRequest: - api_version = kwargs.pop('api_version', "2018-03-01") # type: str - content_type = kwargs.pop('content_type', None) # type: Optional[str] - accept = "application/json" +def build_policy_assignments_create_by_id_request(policy_assignment_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", "2018-03-01")) # type: str + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + accept = _headers.pop("Accept", "application/json") + # Construct URL _url = kwargs.pop("template_url", "/{policyAssignmentId}") path_format_arguments = { - "policyAssignmentId": _SERIALIZER.url("policy_assignment_id", policy_assignment_id, 'str', skip_quote=True), + "policyAssignmentId": _SERIALIZER.url("policy_assignment_id", policy_assignment_id, "str", skip_quote=True), } _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] if content_type is not None: - _header_parameters['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') - _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') - - return HttpRequest( - method="PUT", - url=_url, - params=_query_parameters, - headers=_header_parameters, - json=json, - content=content, - **kwargs - ) + _headers["Content-Type"] = _SERIALIZER.header("content_type", content_type, "str") + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + return HttpRequest(method="PUT", url=_url, params=_params, headers=_headers, **kwargs) -def build_policy_assignments_get_by_id_request( - policy_assignment_id: str, - **kwargs: Any -) -> HttpRequest: - api_version = kwargs.pop('api_version', "2018-03-01") # type: str - accept = "application/json" +def build_policy_assignments_get_by_id_request(policy_assignment_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", "2018-03-01")) # type: str + accept = _headers.pop("Accept", "application/json") + # Construct URL _url = kwargs.pop("template_url", "/{policyAssignmentId}") path_format_arguments = { - "policyAssignmentId": _SERIALIZER.url("policy_assignment_id", policy_assignment_id, 'str', skip_quote=True), + "policyAssignmentId": _SERIALIZER.url("policy_assignment_id", policy_assignment_id, "str", skip_quote=True), } _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') - - return HttpRequest( - method="GET", - url=_url, - params=_query_parameters, - headers=_header_parameters, - **kwargs - ) + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) def build_policy_definitions_create_or_update_request( - policy_definition_name: str, - subscription_id: str, - *, - json: JSONType = None, - content: Any = None, - **kwargs: Any + policy_definition_name: str, subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2018-03-01") # type: str - content_type = kwargs.pop('content_type', None) # type: Optional[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", "2018-03-01")) # type: str + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + accept = _headers.pop("Accept", "application/json") - accept = "application/json" # Construct URL - _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/providers/Microsoft.Authorization/policyDefinitions/{policyDefinitionName}") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/providers/Microsoft.Authorization/policyDefinitions/{policyDefinitionName}", + ) # pylint: disable=line-too-long path_format_arguments = { - "policyDefinitionName": _SERIALIZER.url("policy_definition_name", policy_definition_name, 'str'), - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), + "policyDefinitionName": _SERIALIZER.url("policy_definition_name", policy_definition_name, "str"), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), } _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] if content_type is not None: - _header_parameters['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') - _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') - - return HttpRequest( - method="PUT", - url=_url, - params=_query_parameters, - headers=_header_parameters, - json=json, - content=content, - **kwargs - ) + _headers["Content-Type"] = _SERIALIZER.header("content_type", content_type, "str") + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="PUT", url=_url, params=_params, headers=_headers, **kwargs) def build_policy_definitions_delete_request( - policy_definition_name: str, - subscription_id: str, - **kwargs: Any + policy_definition_name: str, subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2018-03-01") # type: str + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + api_version = kwargs.pop("api_version", _params.pop("api-version", "2018-03-01")) # type: str # Construct URL - _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/providers/Microsoft.Authorization/policyDefinitions/{policyDefinitionName}") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/providers/Microsoft.Authorization/policyDefinitions/{policyDefinitionName}", + ) # pylint: disable=line-too-long path_format_arguments = { - "policyDefinitionName": _SERIALIZER.url("policy_definition_name", policy_definition_name, 'str'), - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), + "policyDefinitionName": _SERIALIZER.url("policy_definition_name", policy_definition_name, "str"), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), } _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') - - return HttpRequest( - method="DELETE", - url=_url, - params=_query_parameters, - **kwargs - ) + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") + + return HttpRequest(method="DELETE", url=_url, params=_params, **kwargs) def build_policy_definitions_get_request( - policy_definition_name: str, - subscription_id: str, - **kwargs: Any + policy_definition_name: str, subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2018-03-01") # type: 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", "2018-03-01")) # type: str + accept = _headers.pop("Accept", "application/json") - accept = "application/json" # Construct URL - _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/providers/Microsoft.Authorization/policyDefinitions/{policyDefinitionName}") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/providers/Microsoft.Authorization/policyDefinitions/{policyDefinitionName}", + ) # pylint: disable=line-too-long path_format_arguments = { - "policyDefinitionName": _SERIALIZER.url("policy_definition_name", policy_definition_name, 'str'), - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), + "policyDefinitionName": _SERIALIZER.url("policy_definition_name", policy_definition_name, "str"), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), } _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') - - return HttpRequest( - method="GET", - url=_url, - params=_query_parameters, - headers=_header_parameters, - **kwargs - ) + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) -def build_policy_definitions_get_built_in_request( - policy_definition_name: str, - **kwargs: Any -) -> HttpRequest: - api_version = kwargs.pop('api_version', "2018-03-01") # type: str - accept = "application/json" +def build_policy_definitions_get_built_in_request(policy_definition_name: 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", "2018-03-01")) # type: str + accept = _headers.pop("Accept", "application/json") + # Construct URL _url = kwargs.pop("template_url", "/providers/Microsoft.Authorization/policyDefinitions/{policyDefinitionName}") path_format_arguments = { - "policyDefinitionName": _SERIALIZER.url("policy_definition_name", policy_definition_name, 'str'), + "policyDefinitionName": _SERIALIZER.url("policy_definition_name", policy_definition_name, "str"), } _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') - - return HttpRequest( - method="GET", - url=_url, - params=_query_parameters, - headers=_header_parameters, - **kwargs - ) + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) def build_policy_definitions_create_or_update_at_management_group_request( - policy_definition_name: str, - management_group_id: str, - *, - json: JSONType = None, - content: Any = None, - **kwargs: Any + policy_definition_name: str, management_group_id: str, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2018-03-01") # type: str - content_type = kwargs.pop('content_type', None) # type: Optional[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", "2018-03-01")) # type: str + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + accept = _headers.pop("Accept", "application/json") - accept = "application/json" # Construct URL - _url = kwargs.pop("template_url", "/providers/Microsoft.Management/managementgroups/{managementGroupId}/providers/Microsoft.Authorization/policyDefinitions/{policyDefinitionName}") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", + "/providers/Microsoft.Management/managementgroups/{managementGroupId}/providers/Microsoft.Authorization/policyDefinitions/{policyDefinitionName}", + ) # pylint: disable=line-too-long path_format_arguments = { - "policyDefinitionName": _SERIALIZER.url("policy_definition_name", policy_definition_name, 'str'), - "managementGroupId": _SERIALIZER.url("management_group_id", management_group_id, 'str'), + "policyDefinitionName": _SERIALIZER.url("policy_definition_name", policy_definition_name, "str"), + "managementGroupId": _SERIALIZER.url("management_group_id", management_group_id, "str"), } _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] if content_type is not None: - _header_parameters['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') - _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') - - return HttpRequest( - method="PUT", - url=_url, - params=_query_parameters, - headers=_header_parameters, - json=json, - content=content, - **kwargs - ) + _headers["Content-Type"] = _SERIALIZER.header("content_type", content_type, "str") + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="PUT", url=_url, params=_params, headers=_headers, **kwargs) def build_policy_definitions_delete_at_management_group_request( - policy_definition_name: str, - management_group_id: str, - **kwargs: Any + policy_definition_name: str, management_group_id: str, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2018-03-01") # type: str + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + api_version = kwargs.pop("api_version", _params.pop("api-version", "2018-03-01")) # type: str # Construct URL - _url = kwargs.pop("template_url", "/providers/Microsoft.Management/managementgroups/{managementGroupId}/providers/Microsoft.Authorization/policyDefinitions/{policyDefinitionName}") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", + "/providers/Microsoft.Management/managementgroups/{managementGroupId}/providers/Microsoft.Authorization/policyDefinitions/{policyDefinitionName}", + ) # pylint: disable=line-too-long path_format_arguments = { - "policyDefinitionName": _SERIALIZER.url("policy_definition_name", policy_definition_name, 'str'), - "managementGroupId": _SERIALIZER.url("management_group_id", management_group_id, 'str'), + "policyDefinitionName": _SERIALIZER.url("policy_definition_name", policy_definition_name, "str"), + "managementGroupId": _SERIALIZER.url("management_group_id", management_group_id, "str"), } _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') - - return HttpRequest( - method="DELETE", - url=_url, - params=_query_parameters, - **kwargs - ) + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") + + return HttpRequest(method="DELETE", url=_url, params=_params, **kwargs) def build_policy_definitions_get_at_management_group_request( - policy_definition_name: str, - management_group_id: str, - **kwargs: Any + policy_definition_name: str, management_group_id: str, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2018-03-01") # type: 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", "2018-03-01")) # type: str + accept = _headers.pop("Accept", "application/json") - accept = "application/json" # Construct URL - _url = kwargs.pop("template_url", "/providers/Microsoft.Management/managementgroups/{managementGroupId}/providers/Microsoft.Authorization/policyDefinitions/{policyDefinitionName}") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", + "/providers/Microsoft.Management/managementgroups/{managementGroupId}/providers/Microsoft.Authorization/policyDefinitions/{policyDefinitionName}", + ) # pylint: disable=line-too-long path_format_arguments = { - "policyDefinitionName": _SERIALIZER.url("policy_definition_name", policy_definition_name, 'str'), - "managementGroupId": _SERIALIZER.url("management_group_id", management_group_id, 'str'), + "policyDefinitionName": _SERIALIZER.url("policy_definition_name", policy_definition_name, "str"), + "managementGroupId": _SERIALIZER.url("management_group_id", management_group_id, "str"), } _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') - - return HttpRequest( - method="GET", - url=_url, - params=_query_parameters, - headers=_header_parameters, - **kwargs - ) + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) -def build_policy_definitions_list_request( - subscription_id: str, - **kwargs: Any -) -> HttpRequest: - api_version = kwargs.pop('api_version', "2018-03-01") # type: str - accept = "application/json" +def build_policy_definitions_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", "2018-03-01")) # type: str + accept = _headers.pop("Accept", "application/json") + # Construct URL - _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/providers/Microsoft.Authorization/policyDefinitions") + _url = kwargs.pop( + "template_url", "/subscriptions/{subscriptionId}/providers/Microsoft.Authorization/policyDefinitions" + ) path_format_arguments = { - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), } _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') - - return HttpRequest( - method="GET", - url=_url, - params=_query_parameters, - headers=_header_parameters, - **kwargs - ) + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) -def build_policy_definitions_list_built_in_request( - **kwargs: Any -) -> HttpRequest: - api_version = kwargs.pop('api_version', "2018-03-01") # type: str - accept = "application/json" +def build_policy_definitions_list_built_in_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", "2018-03-01")) # type: str + accept = _headers.pop("Accept", "application/json") + # Construct URL _url = kwargs.pop("template_url", "/providers/Microsoft.Authorization/policyDefinitions") # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') - - return HttpRequest( - method="GET", - url=_url, - params=_query_parameters, - headers=_header_parameters, - **kwargs - ) + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) -def build_policy_definitions_list_by_management_group_request( - management_group_id: str, - **kwargs: Any -) -> HttpRequest: - api_version = kwargs.pop('api_version', "2018-03-01") # type: str - accept = "application/json" +def build_policy_definitions_list_by_management_group_request(management_group_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", "2018-03-01")) # type: str + accept = _headers.pop("Accept", "application/json") + # Construct URL - _url = kwargs.pop("template_url", "/providers/Microsoft.Management/managementgroups/{managementGroupId}/providers/Microsoft.Authorization/policyDefinitions") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", + "/providers/Microsoft.Management/managementgroups/{managementGroupId}/providers/Microsoft.Authorization/policyDefinitions", + ) # pylint: disable=line-too-long path_format_arguments = { - "managementGroupId": _SERIALIZER.url("management_group_id", management_group_id, 'str'), + "managementGroupId": _SERIALIZER.url("management_group_id", management_group_id, "str"), } _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') - - return HttpRequest( - method="GET", - url=_url, - params=_query_parameters, - headers=_header_parameters, - **kwargs - ) + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) def build_policy_set_definitions_create_or_update_request( - policy_set_definition_name: str, - subscription_id: str, - *, - json: JSONType = None, - content: Any = None, - **kwargs: Any + policy_set_definition_name: str, subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2018-03-01") # type: str - content_type = kwargs.pop('content_type', None) # type: Optional[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", "2018-03-01")) # type: str + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + accept = _headers.pop("Accept", "application/json") - accept = "application/json" # Construct URL - _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/providers/Microsoft.Authorization/policySetDefinitions/{policySetDefinitionName}") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/providers/Microsoft.Authorization/policySetDefinitions/{policySetDefinitionName}", + ) # pylint: disable=line-too-long path_format_arguments = { - "policySetDefinitionName": _SERIALIZER.url("policy_set_definition_name", policy_set_definition_name, 'str'), - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), + "policySetDefinitionName": _SERIALIZER.url("policy_set_definition_name", policy_set_definition_name, "str"), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), } _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] if content_type is not None: - _header_parameters['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') - _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') - - return HttpRequest( - method="PUT", - url=_url, - params=_query_parameters, - headers=_header_parameters, - json=json, - content=content, - **kwargs - ) + _headers["Content-Type"] = _SERIALIZER.header("content_type", content_type, "str") + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="PUT", url=_url, params=_params, headers=_headers, **kwargs) def build_policy_set_definitions_delete_request( - policy_set_definition_name: str, - subscription_id: str, - **kwargs: Any + policy_set_definition_name: str, subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2018-03-01") # type: 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", "2018-03-01")) # type: str + accept = _headers.pop("Accept", "application/json") - accept = "application/json" # Construct URL - _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/providers/Microsoft.Authorization/policySetDefinitions/{policySetDefinitionName}") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/providers/Microsoft.Authorization/policySetDefinitions/{policySetDefinitionName}", + ) # pylint: disable=line-too-long path_format_arguments = { - "policySetDefinitionName": _SERIALIZER.url("policy_set_definition_name", policy_set_definition_name, 'str'), - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), + "policySetDefinitionName": _SERIALIZER.url("policy_set_definition_name", policy_set_definition_name, "str"), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), } _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') - - return HttpRequest( - method="DELETE", - url=_url, - params=_query_parameters, - headers=_header_parameters, - **kwargs - ) + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="DELETE", url=_url, params=_params, headers=_headers, **kwargs) def build_policy_set_definitions_get_request( - policy_set_definition_name: str, - subscription_id: str, - **kwargs: Any + policy_set_definition_name: str, subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2018-03-01") # type: 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", "2018-03-01")) # type: str + accept = _headers.pop("Accept", "application/json") - accept = "application/json" # Construct URL - _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/providers/Microsoft.Authorization/policySetDefinitions/{policySetDefinitionName}") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/providers/Microsoft.Authorization/policySetDefinitions/{policySetDefinitionName}", + ) # pylint: disable=line-too-long path_format_arguments = { - "policySetDefinitionName": _SERIALIZER.url("policy_set_definition_name", policy_set_definition_name, 'str'), - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), + "policySetDefinitionName": _SERIALIZER.url("policy_set_definition_name", policy_set_definition_name, "str"), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), } _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') - - return HttpRequest( - method="GET", - url=_url, - params=_query_parameters, - headers=_header_parameters, - **kwargs - ) + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) -def build_policy_set_definitions_get_built_in_request( - policy_set_definition_name: str, - **kwargs: Any -) -> HttpRequest: - api_version = kwargs.pop('api_version', "2018-03-01") # type: str - accept = "application/json" +def build_policy_set_definitions_get_built_in_request(policy_set_definition_name: 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", "2018-03-01")) # type: str + accept = _headers.pop("Accept", "application/json") + # Construct URL - _url = kwargs.pop("template_url", "/providers/Microsoft.Authorization/policySetDefinitions/{policySetDefinitionName}") + _url = kwargs.pop( + "template_url", "/providers/Microsoft.Authorization/policySetDefinitions/{policySetDefinitionName}" + ) path_format_arguments = { - "policySetDefinitionName": _SERIALIZER.url("policy_set_definition_name", policy_set_definition_name, 'str'), + "policySetDefinitionName": _SERIALIZER.url("policy_set_definition_name", policy_set_definition_name, "str"), } _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') - - return HttpRequest( - method="GET", - url=_url, - params=_query_parameters, - headers=_header_parameters, - **kwargs - ) + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) -def build_policy_set_definitions_list_request( - subscription_id: str, - **kwargs: Any -) -> HttpRequest: - api_version = kwargs.pop('api_version', "2018-03-01") # type: str - accept = "application/json" +def build_policy_set_definitions_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", "2018-03-01")) # type: str + accept = _headers.pop("Accept", "application/json") + # Construct URL - _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/providers/Microsoft.Authorization/policySetDefinitions") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", "/subscriptions/{subscriptionId}/providers/Microsoft.Authorization/policySetDefinitions" + ) # pylint: disable=line-too-long path_format_arguments = { - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), } _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') - - return HttpRequest( - method="GET", - url=_url, - params=_query_parameters, - headers=_header_parameters, - **kwargs - ) + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) -def build_policy_set_definitions_list_built_in_request( - **kwargs: Any -) -> HttpRequest: - api_version = kwargs.pop('api_version', "2018-03-01") # type: str - accept = "application/json" +def build_policy_set_definitions_list_built_in_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", "2018-03-01")) # type: str + accept = _headers.pop("Accept", "application/json") + # Construct URL _url = kwargs.pop("template_url", "/providers/Microsoft.Authorization/policySetDefinitions") # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') - - return HttpRequest( - method="GET", - url=_url, - params=_query_parameters, - headers=_header_parameters, - **kwargs - ) + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) def build_policy_set_definitions_create_or_update_at_management_group_request( - policy_set_definition_name: str, - management_group_id: str, - *, - json: JSONType = None, - content: Any = None, - **kwargs: Any + policy_set_definition_name: str, management_group_id: str, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2018-03-01") # type: str - content_type = kwargs.pop('content_type', None) # type: Optional[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", "2018-03-01")) # type: str + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + accept = _headers.pop("Accept", "application/json") - accept = "application/json" # Construct URL - _url = kwargs.pop("template_url", "/providers/Microsoft.Management/managementgroups/{managementGroupId}/providers/Microsoft.Authorization/policySetDefinitions/{policySetDefinitionName}") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", + "/providers/Microsoft.Management/managementgroups/{managementGroupId}/providers/Microsoft.Authorization/policySetDefinitions/{policySetDefinitionName}", + ) # pylint: disable=line-too-long path_format_arguments = { - "policySetDefinitionName": _SERIALIZER.url("policy_set_definition_name", policy_set_definition_name, 'str'), - "managementGroupId": _SERIALIZER.url("management_group_id", management_group_id, 'str'), + "policySetDefinitionName": _SERIALIZER.url("policy_set_definition_name", policy_set_definition_name, "str"), + "managementGroupId": _SERIALIZER.url("management_group_id", management_group_id, "str"), } _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] if content_type is not None: - _header_parameters['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') - _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') - - return HttpRequest( - method="PUT", - url=_url, - params=_query_parameters, - headers=_header_parameters, - json=json, - content=content, - **kwargs - ) + _headers["Content-Type"] = _SERIALIZER.header("content_type", content_type, "str") + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="PUT", url=_url, params=_params, headers=_headers, **kwargs) def build_policy_set_definitions_delete_at_management_group_request( - policy_set_definition_name: str, - management_group_id: str, - **kwargs: Any + policy_set_definition_name: str, management_group_id: str, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2018-03-01") # type: 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", "2018-03-01")) # type: str + accept = _headers.pop("Accept", "application/json") - accept = "application/json" # Construct URL - _url = kwargs.pop("template_url", "/providers/Microsoft.Management/managementgroups/{managementGroupId}/providers/Microsoft.Authorization/policySetDefinitions/{policySetDefinitionName}") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", + "/providers/Microsoft.Management/managementgroups/{managementGroupId}/providers/Microsoft.Authorization/policySetDefinitions/{policySetDefinitionName}", + ) # pylint: disable=line-too-long path_format_arguments = { - "policySetDefinitionName": _SERIALIZER.url("policy_set_definition_name", policy_set_definition_name, 'str'), - "managementGroupId": _SERIALIZER.url("management_group_id", management_group_id, 'str'), + "policySetDefinitionName": _SERIALIZER.url("policy_set_definition_name", policy_set_definition_name, "str"), + "managementGroupId": _SERIALIZER.url("management_group_id", management_group_id, "str"), } _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') - - return HttpRequest( - method="DELETE", - url=_url, - params=_query_parameters, - headers=_header_parameters, - **kwargs - ) + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="DELETE", url=_url, params=_params, headers=_headers, **kwargs) def build_policy_set_definitions_get_at_management_group_request( - policy_set_definition_name: str, - management_group_id: str, - **kwargs: Any + policy_set_definition_name: str, management_group_id: str, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2018-03-01") # type: 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", "2018-03-01")) # type: str + accept = _headers.pop("Accept", "application/json") - accept = "application/json" # Construct URL - _url = kwargs.pop("template_url", "/providers/Microsoft.Management/managementgroups/{managementGroupId}/providers/Microsoft.Authorization/policySetDefinitions/{policySetDefinitionName}") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", + "/providers/Microsoft.Management/managementgroups/{managementGroupId}/providers/Microsoft.Authorization/policySetDefinitions/{policySetDefinitionName}", + ) # pylint: disable=line-too-long path_format_arguments = { - "policySetDefinitionName": _SERIALIZER.url("policy_set_definition_name", policy_set_definition_name, 'str'), - "managementGroupId": _SERIALIZER.url("management_group_id", management_group_id, 'str'), + "policySetDefinitionName": _SERIALIZER.url("policy_set_definition_name", policy_set_definition_name, "str"), + "managementGroupId": _SERIALIZER.url("management_group_id", management_group_id, "str"), } _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') - - return HttpRequest( - method="GET", - url=_url, - params=_query_parameters, - headers=_header_parameters, - **kwargs - ) + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) def build_policy_set_definitions_list_by_management_group_request( - management_group_id: str, - **kwargs: Any + management_group_id: str, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2018-03-01") # type: 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", "2018-03-01")) # type: str + accept = _headers.pop("Accept", "application/json") - accept = "application/json" # Construct URL - _url = kwargs.pop("template_url", "/providers/Microsoft.Management/managementgroups/{managementGroupId}/providers/Microsoft.Authorization/policySetDefinitions") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", + "/providers/Microsoft.Management/managementgroups/{managementGroupId}/providers/Microsoft.Authorization/policySetDefinitions", + ) # pylint: disable=line-too-long path_format_arguments = { - "managementGroupId": _SERIALIZER.url("management_group_id", management_group_id, 'str'), + "managementGroupId": _SERIALIZER.url("management_group_id", management_group_id, "str"), } _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') - - return HttpRequest( - method="GET", - url=_url, - params=_query_parameters, - headers=_header_parameters, - **kwargs - ) + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") -class PolicyAssignmentsOperations(object): - """PolicyAssignmentsOperations operations. + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) - You should not instantiate this class directly. Instead, you should create a Client instance that - instantiates it for you and attaches it as an attribute. - :ivar models: Alias to model classes used in this operation group. - :type models: ~azure.mgmt.resource.policy.v2018_03_01.models - :param client: Client for service requests. - :param config: Configuration of service client. - :param serializer: An object model serializer. - :param deserializer: An object model deserializer. +class PolicyAssignmentsOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. + + Instead, you should access the following operations through + :class:`~azure.mgmt.resource.policy.v2018_03_01.PolicyClient`'s + :attr:`policy_assignments` attribute. """ models = _models - def __init__(self, client, config, serializer, deserializer): - self._client = client - self._serialize = serializer - self._deserialize = deserializer - self._config = config + def __init__(self, *args, **kwargs): + input_args = list(args) + self._client = input_args.pop(0) if input_args else kwargs.pop("client") + self._config = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") @distributed_trace - def delete( - self, - scope: str, - policy_assignment_name: str, - **kwargs: Any - ) -> Optional["_models.PolicyAssignment"]: + def delete(self, scope: str, policy_assignment_name: str, **kwargs: Any) -> Optional[_models.PolicyAssignment]: """Deletes a policy assignment. This operation deletes a policy assignment, given its name and the scope it was created in. The @@ -1072,37 +893,44 @@ def delete( '/subscriptions/{subscriptionId}'), resource group (format: '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}', or resource (format: '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{resourceProviderNamespace}/[{parentResourcePath}/]{resourceType}/{resourceName}'. + Required. :type scope: str - :param policy_assignment_name: The name of the policy assignment to delete. + :param policy_assignment_name: The name of the policy assignment to delete. Required. :type policy_assignment_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: PolicyAssignment, or the result of cls(response) + :return: PolicyAssignment or None or the result of cls(response) :rtype: ~azure.mgmt.resource.policy.v2018_03_01.models.PolicyAssignment or None - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType[Optional["_models.PolicyAssignment"]] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) - api_version = kwargs.pop('api_version', "2018-03-01") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2018-03-01")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[Optional[_models.PolicyAssignment]] - request = build_policy_assignments_delete_request( scope=scope, policy_assignment_name=policy_assignment_name, api_version=api_version, - template_url=self.delete.metadata['url'], + template_url=self.delete.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200, 204]: @@ -1112,24 +940,25 @@ def delete( deserialized = None if response.status_code == 200: - deserialized = self._deserialize('PolicyAssignment', pipeline_response) + deserialized = self._deserialize("PolicyAssignment", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - delete.metadata = {'url': "/{scope}/providers/Microsoft.Authorization/policyAssignments/{policyAssignmentName}"} # type: ignore - + delete.metadata = {"url": "/{scope}/providers/Microsoft.Authorization/policyAssignments/{policyAssignmentName}"} # type: ignore - @distributed_trace + @overload def create( self, scope: str, policy_assignment_name: str, - parameters: "_models.PolicyAssignment", + parameters: _models.PolicyAssignment, + *, + content_type: str = "application/json", **kwargs: Any - ) -> "_models.PolicyAssignment": + ) -> _models.PolicyAssignment: """Creates or updates a policy assignment. This operation creates or updates a policy assignment with the given scope and name. Policy @@ -1141,26 +970,109 @@ def create( '/subscriptions/{subscriptionId}'), resource group (format: '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}', or resource (format: '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{resourceProviderNamespace}/[{parentResourcePath}/]{resourceType}/{resourceName}'. + Required. :type scope: str - :param policy_assignment_name: The name of the policy assignment. + :param policy_assignment_name: The name of the policy assignment. Required. :type policy_assignment_name: str - :param parameters: Parameters for the policy assignment. + :param parameters: Parameters for the policy assignment. Required. :type parameters: ~azure.mgmt.resource.policy.v2018_03_01.models.PolicyAssignment + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: PolicyAssignment or the result of cls(response) + :rtype: ~azure.mgmt.resource.policy.v2018_03_01.models.PolicyAssignment + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + def create( + self, + scope: str, + policy_assignment_name: str, + parameters: IO, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.PolicyAssignment: + """Creates or updates a policy assignment. + + This operation creates or updates a policy assignment with the given scope and name. Policy + assignments apply to all resources contained within their scope. For example, when you assign a + policy at resource group scope, that policy applies to all resources in the group. + + :param scope: The scope of the policy assignment. Valid scopes are: management group (format: + '/providers/Microsoft.Management/managementGroups/{managementGroup}'), subscription (format: + '/subscriptions/{subscriptionId}'), resource group (format: + '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}', or resource (format: + '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{resourceProviderNamespace}/[{parentResourcePath}/]{resourceType}/{resourceName}'. + Required. + :type scope: str + :param policy_assignment_name: The name of the policy assignment. Required. + :type policy_assignment_name: str + :param parameters: Parameters for the policy assignment. Required. + :type parameters: IO + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: PolicyAssignment or the result of cls(response) + :rtype: ~azure.mgmt.resource.policy.v2018_03_01.models.PolicyAssignment + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace + def create( + self, scope: str, policy_assignment_name: str, parameters: Union[_models.PolicyAssignment, IO], **kwargs: Any + ) -> _models.PolicyAssignment: + """Creates or updates a policy assignment. + + This operation creates or updates a policy assignment with the given scope and name. Policy + assignments apply to all resources contained within their scope. For example, when you assign a + policy at resource group scope, that policy applies to all resources in the group. + + :param scope: The scope of the policy assignment. Valid scopes are: management group (format: + '/providers/Microsoft.Management/managementGroups/{managementGroup}'), subscription (format: + '/subscriptions/{subscriptionId}'), resource group (format: + '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}', or resource (format: + '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{resourceProviderNamespace}/[{parentResourcePath}/]{resourceType}/{resourceName}'. + Required. + :type scope: str + :param policy_assignment_name: The name of the policy assignment. Required. + :type policy_assignment_name: str + :param parameters: Parameters for the policy assignment. Is either a model type or a IO type. + Required. + :type parameters: ~azure.mgmt.resource.policy.v2018_03_01.models.PolicyAssignment or IO + :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. + Default value is None. + :paramtype content_type: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: PolicyAssignment, or the result of cls(response) + :return: PolicyAssignment or the result of cls(response) :rtype: ~azure.mgmt.resource.policy.v2018_03_01.models.PolicyAssignment - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.PolicyAssignment"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', "2018-03-01") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + api_version = kwargs.pop("api_version", _params.pop("api-version", "2018-03-01")) # type: str + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.PolicyAssignment] - _json = self._serialize.body(parameters, 'PolicyAssignment') + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(parameters, (IO, bytes)): + _content = parameters + else: + _json = self._serialize.body(parameters, "PolicyAssignment") request = build_policy_assignments_create_request( scope=scope, @@ -1168,16 +1080,18 @@ def create( api_version=api_version, content_type=content_type, json=_json, - template_url=self.create.metadata['url'], + content=_content, + template_url=self.create.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [201]: @@ -1185,23 +1099,17 @@ def create( error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - deserialized = self._deserialize('PolicyAssignment', pipeline_response) + deserialized = self._deserialize("PolicyAssignment", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - create.metadata = {'url': "/{scope}/providers/Microsoft.Authorization/policyAssignments/{policyAssignmentName}"} # type: ignore - + create.metadata = {"url": "/{scope}/providers/Microsoft.Authorization/policyAssignments/{policyAssignmentName}"} # type: ignore @distributed_trace - def get( - self, - scope: str, - policy_assignment_name: str, - **kwargs: Any - ) -> "_models.PolicyAssignment": + def get(self, scope: str, policy_assignment_name: str, **kwargs: Any) -> _models.PolicyAssignment: """Retrieves a policy assignment. This operation retrieves a single policy assignment, given its name and the scope it was @@ -1212,37 +1120,44 @@ def get( '/subscriptions/{subscriptionId}'), resource group (format: '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}', or resource (format: '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{resourceProviderNamespace}/[{parentResourcePath}/]{resourceType}/{resourceName}'. + Required. :type scope: str - :param policy_assignment_name: The name of the policy assignment to get. + :param policy_assignment_name: The name of the policy assignment to get. Required. :type policy_assignment_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: PolicyAssignment, or the result of cls(response) + :return: PolicyAssignment or the result of cls(response) :rtype: ~azure.mgmt.resource.policy.v2018_03_01.models.PolicyAssignment - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.PolicyAssignment"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + 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', "2018-03-01") # type: str + api_version = kwargs.pop("api_version", _params.pop("api-version", "2018-03-01")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[_models.PolicyAssignment] - request = build_policy_assignments_get_request( scope=scope, policy_assignment_name=policy_assignment_name, api_version=api_version, - template_url=self.get.metadata['url'], + template_url=self.get.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200]: @@ -1250,23 +1165,19 @@ def get( error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - deserialized = self._deserialize('PolicyAssignment', pipeline_response) + deserialized = self._deserialize("PolicyAssignment", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - get.metadata = {'url': "/{scope}/providers/Microsoft.Authorization/policyAssignments/{policyAssignmentName}"} # type: ignore - + get.metadata = {"url": "/{scope}/providers/Microsoft.Authorization/policyAssignments/{policyAssignmentName}"} # type: ignore @distributed_trace def list_for_resource_group( - self, - resource_group_name: str, - filter: Optional[str] = None, - **kwargs: Any - ) -> Iterable["_models.PolicyAssignmentListResult"]: + self, resource_group_name: str, filter: Optional[str] = None, **kwargs: Any + ) -> Iterable["_models.PolicyAssignment"]: """Retrieves all policy assignments that apply to a resource group. This operation retrieves the list of all policy assignments associated with the given resource @@ -1281,47 +1192,55 @@ def list_for_resource_group( assignments of the policy definition whose id is {value} that apply to the resource group. :param resource_group_name: The name of the resource group that contains policy assignments. + Required. :type resource_group_name: str :param filter: The filter to apply on the operation. Valid values for $filter are: 'atScope()' or 'policyDefinitionId eq '{value}''. If $filter is not provided, no filtering is performed. Default value is None. :type filter: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either PolicyAssignmentListResult or the result of - cls(response) + :return: An iterator like instance of either PolicyAssignment or the result of cls(response) :rtype: - ~azure.core.paging.ItemPaged[~azure.mgmt.resource.policy.v2018_03_01.models.PolicyAssignmentListResult] - :raises: ~azure.core.exceptions.HttpResponseError + ~azure.core.paging.ItemPaged[~azure.mgmt.resource.policy.v2018_03_01.models.PolicyAssignment] + :raises ~azure.core.exceptions.HttpResponseError: """ - api_version = kwargs.pop('api_version', "2018-03-01") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2018-03-01")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[_models.PolicyAssignmentListResult] - cls = kwargs.pop('cls', None) # type: ClsType["_models.PolicyAssignmentListResult"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) + def prepare_request(next_link=None): if not next_link: - + request = build_policy_assignments_list_for_resource_group_request( resource_group_name=resource_group_name, subscription_id=self._config.subscription_id, - api_version=api_version, filter=filter, - template_url=self.list_for_resource_group.metadata['url'], + api_version=api_version, + template_url=self.list_for_resource_group.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore else: - - request = build_policy_assignments_list_for_resource_group_request( - resource_group_name=resource_group_name, - subscription_id=self._config.subscription_id, - template_url=next_link, - ) + # make call to next link with the client's api-version + _parsed_next_link = urlparse(next_link) + _next_request_params = case_insensitive_dict(parse_qs(_parsed_next_link.query)) + _next_request_params["api-version"] = self._config.api_version + request = HttpRequest("GET", urljoin(next_link, _parsed_next_link.path), params=_next_request_params) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore request.method = "GET" return request @@ -1335,10 +1254,8 @@ def extract_data(pipeline_response): def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) response = pipeline_response.http_response @@ -1349,11 +1266,9 @@ def get_next(next_link=None): return pipeline_response + return ItemPaged(get_next, extract_data) - return ItemPaged( - get_next, extract_data - ) - list_for_resource_group.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Authorization/policyAssignments"} # type: ignore + list_for_resource_group.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Authorization/policyAssignments"} # type: ignore @distributed_trace def list_for_resource( @@ -1365,7 +1280,7 @@ def list_for_resource( resource_name: str, filter: Optional[str] = None, **kwargs: Any - ) -> Iterable["_models.PolicyAssignmentListResult"]: + ) -> Iterable["_models.PolicyAssignment"]: """Retrieves all policy assignments that apply to a resource. This operation retrieves the list of all policy assignments associated with the specified @@ -1391,39 +1306,47 @@ def list_for_resource( {parentResourcePath} == '', {resourceType} == 'Microsoft.Web/sites', {resourceName} == 'MyWebApp'). - :param resource_group_name: The name of the resource group containing the resource. + :param resource_group_name: The name of the resource group containing the resource. Required. :type resource_group_name: str :param resource_provider_namespace: The namespace of the resource provider. For example, the namespace of a virtual machine is Microsoft.Compute (from Microsoft.Compute/virtualMachines). + Required. :type resource_provider_namespace: str :param parent_resource_path: The parent resource path. Use empty string if there is none. + Required. :type parent_resource_path: str :param resource_type: The resource type name. For example the type name of a web app is 'sites' - (from Microsoft.Web/sites). + (from Microsoft.Web/sites). Required. :type resource_type: str - :param resource_name: The name of the resource. + :param resource_name: The name of the resource. Required. :type resource_name: str :param filter: The filter to apply on the operation. Valid values for $filter are: 'atScope()' or 'policyDefinitionId eq '{value}''. If $filter is not provided, no filtering is performed. Default value is None. :type filter: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either PolicyAssignmentListResult or the result of - cls(response) + :return: An iterator like instance of either PolicyAssignment or the result of cls(response) :rtype: - ~azure.core.paging.ItemPaged[~azure.mgmt.resource.policy.v2018_03_01.models.PolicyAssignmentListResult] - :raises: ~azure.core.exceptions.HttpResponseError + ~azure.core.paging.ItemPaged[~azure.mgmt.resource.policy.v2018_03_01.models.PolicyAssignment] + :raises ~azure.core.exceptions.HttpResponseError: """ - api_version = kwargs.pop('api_version', "2018-03-01") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2018-03-01")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[_models.PolicyAssignmentListResult] - cls = kwargs.pop('cls', None) # type: ClsType["_models.PolicyAssignmentListResult"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) + def prepare_request(next_link=None): if not next_link: - + request = build_policy_assignments_list_for_resource_request( resource_group_name=resource_group_name, resource_provider_namespace=resource_provider_namespace, @@ -1431,26 +1354,23 @@ def prepare_request(next_link=None): resource_type=resource_type, resource_name=resource_name, subscription_id=self._config.subscription_id, - api_version=api_version, filter=filter, - template_url=self.list_for_resource.metadata['url'], + api_version=api_version, + template_url=self.list_for_resource.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore else: - - request = build_policy_assignments_list_for_resource_request( - resource_group_name=resource_group_name, - resource_provider_namespace=resource_provider_namespace, - parent_resource_path=parent_resource_path, - resource_type=resource_type, - resource_name=resource_name, - subscription_id=self._config.subscription_id, - template_url=next_link, - ) + # make call to next link with the client's api-version + _parsed_next_link = urlparse(next_link) + _next_request_params = case_insensitive_dict(parse_qs(_parsed_next_link.query)) + _next_request_params["api-version"] = self._config.api_version + request = HttpRequest("GET", urljoin(next_link, _parsed_next_link.path), params=_next_request_params) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore request.method = "GET" return request @@ -1464,10 +1384,8 @@ def extract_data(pipeline_response): def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) response = pipeline_response.http_response @@ -1478,18 +1396,12 @@ def get_next(next_link=None): return pipeline_response + return ItemPaged(get_next, extract_data) - return ItemPaged( - get_next, extract_data - ) - list_for_resource.metadata = {'url': "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{parentResourcePath}/{resourceType}/{resourceName}/providers/Microsoft.Authorization/policyAssignments"} # type: ignore + list_for_resource.metadata = {"url": "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{parentResourcePath}/{resourceType}/{resourceName}/providers/Microsoft.Authorization/policyAssignments"} # type: ignore @distributed_trace - def list( - self, - filter: Optional[str] = None, - **kwargs: Any - ) -> Iterable["_models.PolicyAssignmentListResult"]: + def list(self, filter: Optional[str] = None, **kwargs: Any) -> Iterable["_models.PolicyAssignment"]: """Retrieves all policy assignments that apply to a subscription. This operation retrieves the list of all policy assignments associated with the given @@ -1508,39 +1420,47 @@ def list( Default value is None. :type filter: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either PolicyAssignmentListResult or the result of - cls(response) + :return: An iterator like instance of either PolicyAssignment or the result of cls(response) :rtype: - ~azure.core.paging.ItemPaged[~azure.mgmt.resource.policy.v2018_03_01.models.PolicyAssignmentListResult] - :raises: ~azure.core.exceptions.HttpResponseError + ~azure.core.paging.ItemPaged[~azure.mgmt.resource.policy.v2018_03_01.models.PolicyAssignment] + :raises ~azure.core.exceptions.HttpResponseError: """ - api_version = kwargs.pop('api_version', "2018-03-01") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2018-03-01")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[_models.PolicyAssignmentListResult] - cls = kwargs.pop('cls', None) # type: ClsType["_models.PolicyAssignmentListResult"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) + def prepare_request(next_link=None): if not next_link: - + request = build_policy_assignments_list_request( subscription_id=self._config.subscription_id, - api_version=api_version, filter=filter, - template_url=self.list.metadata['url'], + 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.url = self._client.format_url(request.url) # type: ignore else: - - request = build_policy_assignments_list_request( - subscription_id=self._config.subscription_id, - template_url=next_link, - ) + # make call to next link with the client's api-version + _parsed_next_link = urlparse(next_link) + _next_request_params = case_insensitive_dict(parse_qs(_parsed_next_link.query)) + _next_request_params["api-version"] = self._config.api_version + request = HttpRequest("GET", urljoin(next_link, _parsed_next_link.path), params=_next_request_params) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore request.method = "GET" return request @@ -1554,10 +1474,8 @@ def extract_data(pipeline_response): def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) response = pipeline_response.http_response @@ -1568,18 +1486,12 @@ def get_next(next_link=None): return pipeline_response + return ItemPaged(get_next, extract_data) - return ItemPaged( - get_next, extract_data - ) - list.metadata = {'url': "/subscriptions/{subscriptionId}/providers/Microsoft.Authorization/policyAssignments"} # type: ignore + list.metadata = {"url": "/subscriptions/{subscriptionId}/providers/Microsoft.Authorization/policyAssignments"} # type: ignore @distributed_trace - def delete_by_id( - self, - policy_assignment_id: str, - **kwargs: Any - ) -> Optional["_models.PolicyAssignment"]: + def delete_by_id(self, policy_assignment_id: str, **kwargs: Any) -> Optional[_models.PolicyAssignment]: """Deletes a policy assignment. This operation deletes the policy with the given ID. Policy assignment IDs have this format: @@ -1591,35 +1503,41 @@ def delete_by_id( (resource). :param policy_assignment_id: The ID of the policy assignment to delete. Use the format - '{scope}/providers/Microsoft.Authorization/policyAssignments/{policyAssignmentName}'. + '{scope}/providers/Microsoft.Authorization/policyAssignments/{policyAssignmentName}'. Required. :type policy_assignment_id: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: PolicyAssignment, or the result of cls(response) + :return: PolicyAssignment or None or the result of cls(response) :rtype: ~azure.mgmt.resource.policy.v2018_03_01.models.PolicyAssignment or None - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType[Optional["_models.PolicyAssignment"]] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + 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', "2018-03-01") # type: str + api_version = kwargs.pop("api_version", _params.pop("api-version", "2018-03-01")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[Optional[_models.PolicyAssignment]] - request = build_policy_assignments_delete_by_id_request( policy_assignment_id=policy_assignment_id, api_version=api_version, - template_url=self.delete_by_id.metadata['url'], + template_url=self.delete_by_id.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200, 204]: @@ -1629,23 +1547,24 @@ def delete_by_id( deserialized = None if response.status_code == 200: - deserialized = self._deserialize('PolicyAssignment', pipeline_response) + deserialized = self._deserialize("PolicyAssignment", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - delete_by_id.metadata = {'url': "/{policyAssignmentId}"} # type: ignore + delete_by_id.metadata = {"url": "/{policyAssignmentId}"} # type: ignore - - @distributed_trace + @overload def create_by_id( self, policy_assignment_id: str, - parameters: "_models.PolicyAssignment", + parameters: _models.PolicyAssignment, + *, + content_type: str = "application/json", **kwargs: Any - ) -> "_models.PolicyAssignment": + ) -> _models.PolicyAssignment: """Creates or updates a policy assignment. This operation creates or updates the policy assignment with the given ID. Policy assignments @@ -1660,41 +1579,121 @@ def create_by_id( '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{resourceProviderNamespace}/[{parentResourcePath}/]{resourceType}/{resourceName}'. :param policy_assignment_id: The ID of the policy assignment to create. Use the format - '{scope}/providers/Microsoft.Authorization/policyAssignments/{policyAssignmentName}'. + '{scope}/providers/Microsoft.Authorization/policyAssignments/{policyAssignmentName}'. Required. :type policy_assignment_id: str - :param parameters: Parameters for policy assignment. + :param parameters: Parameters for policy assignment. Required. :type parameters: ~azure.mgmt.resource.policy.v2018_03_01.models.PolicyAssignment + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: PolicyAssignment or the result of cls(response) + :rtype: ~azure.mgmt.resource.policy.v2018_03_01.models.PolicyAssignment + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + def create_by_id( + self, policy_assignment_id: str, parameters: IO, *, content_type: str = "application/json", **kwargs: Any + ) -> _models.PolicyAssignment: + """Creates or updates a policy assignment. + + This operation creates or updates the policy assignment with the given ID. Policy assignments + made on a scope apply to all resources contained in that scope. For example, when you assign a + policy to a resource group that policy applies to all resources in the group. Policy assignment + IDs have this format: + '{scope}/providers/Microsoft.Authorization/policyAssignments/{policyAssignmentName}'. Valid + scopes are: management group (format: + '/providers/Microsoft.Management/managementGroups/{managementGroup}'), subscription (format: + '/subscriptions/{subscriptionId}'), resource group (format: + '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}', or resource (format: + '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{resourceProviderNamespace}/[{parentResourcePath}/]{resourceType}/{resourceName}'. + + :param policy_assignment_id: The ID of the policy assignment to create. Use the format + '{scope}/providers/Microsoft.Authorization/policyAssignments/{policyAssignmentName}'. Required. + :type policy_assignment_id: str + :param parameters: Parameters for policy assignment. Required. + :type parameters: IO + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: PolicyAssignment, or the result of cls(response) + :return: PolicyAssignment or the result of cls(response) :rtype: ~azure.mgmt.resource.policy.v2018_03_01.models.PolicyAssignment - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace + def create_by_id( + self, policy_assignment_id: str, parameters: Union[_models.PolicyAssignment, IO], **kwargs: Any + ) -> _models.PolicyAssignment: + """Creates or updates a policy assignment. + + This operation creates or updates the policy assignment with the given ID. Policy assignments + made on a scope apply to all resources contained in that scope. For example, when you assign a + policy to a resource group that policy applies to all resources in the group. Policy assignment + IDs have this format: + '{scope}/providers/Microsoft.Authorization/policyAssignments/{policyAssignmentName}'. Valid + scopes are: management group (format: + '/providers/Microsoft.Management/managementGroups/{managementGroup}'), subscription (format: + '/subscriptions/{subscriptionId}'), resource group (format: + '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}', or resource (format: + '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{resourceProviderNamespace}/[{parentResourcePath}/]{resourceType}/{resourceName}'. + + :param policy_assignment_id: The ID of the policy assignment to create. Use the format + '{scope}/providers/Microsoft.Authorization/policyAssignments/{policyAssignmentName}'. Required. + :type policy_assignment_id: str + :param parameters: Parameters for policy assignment. Is either a model type or a IO type. + Required. + :type parameters: ~azure.mgmt.resource.policy.v2018_03_01.models.PolicyAssignment or IO + :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. + Default value is None. + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: PolicyAssignment or the result of cls(response) + :rtype: ~azure.mgmt.resource.policy.v2018_03_01.models.PolicyAssignment + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.PolicyAssignment"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) - api_version = kwargs.pop('api_version', "2018-03-01") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - _json = self._serialize.body(parameters, 'PolicyAssignment') + api_version = kwargs.pop("api_version", _params.pop("api-version", "2018-03-01")) # type: str + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.PolicyAssignment] + + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(parameters, (IO, bytes)): + _content = parameters + else: + _json = self._serialize.body(parameters, "PolicyAssignment") request = build_policy_assignments_create_by_id_request( policy_assignment_id=policy_assignment_id, api_version=api_version, content_type=content_type, json=_json, - template_url=self.create_by_id.metadata['url'], + content=_content, + template_url=self.create_by_id.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [201]: @@ -1702,22 +1701,17 @@ def create_by_id( error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - deserialized = self._deserialize('PolicyAssignment', pipeline_response) + deserialized = self._deserialize("PolicyAssignment", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - create_by_id.metadata = {'url': "/{policyAssignmentId}"} # type: ignore - + create_by_id.metadata = {"url": "/{policyAssignmentId}"} # type: ignore @distributed_trace - def get_by_id( - self, - policy_assignment_id: str, - **kwargs: Any - ) -> "_models.PolicyAssignment": + def get_by_id(self, policy_assignment_id: str, **kwargs: Any) -> _models.PolicyAssignment: """Retrieves the policy assignment with the given ID. The operation retrieves the policy assignment with the given ID. Policy assignment IDs have @@ -1730,35 +1724,41 @@ def get_by_id( '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{resourceProviderNamespace}/[{parentResourcePath}/]{resourceType}/{resourceName}'. :param policy_assignment_id: The ID of the policy assignment to get. Use the format - '{scope}/providers/Microsoft.Authorization/policyAssignments/{policyAssignmentName}'. + '{scope}/providers/Microsoft.Authorization/policyAssignments/{policyAssignmentName}'. Required. :type policy_assignment_id: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: PolicyAssignment, or the result of cls(response) + :return: PolicyAssignment or the result of cls(response) :rtype: ~azure.mgmt.resource.policy.v2018_03_01.models.PolicyAssignment - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.PolicyAssignment"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) - api_version = kwargs.pop('api_version', "2018-03-01") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2018-03-01")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[_models.PolicyAssignment] - request = build_policy_assignments_get_by_id_request( policy_assignment_id=policy_assignment_id, api_version=api_version, - template_url=self.get_by_id.metadata['url'], + template_url=self.get_by_id.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200]: @@ -1766,68 +1766,128 @@ def get_by_id( error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - deserialized = self._deserialize('PolicyAssignment', pipeline_response) + deserialized = self._deserialize("PolicyAssignment", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - get_by_id.metadata = {'url': "/{policyAssignmentId}"} # type: ignore + get_by_id.metadata = {"url": "/{policyAssignmentId}"} # type: ignore -class PolicyDefinitionsOperations(object): - """PolicyDefinitionsOperations operations. - You should not instantiate this class directly. Instead, you should create a Client instance that - instantiates it for you and attaches it as an attribute. +class PolicyDefinitionsOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. - :ivar models: Alias to model classes used in this operation group. - :type models: ~azure.mgmt.resource.policy.v2018_03_01.models - :param client: Client for service requests. - :param config: Configuration of service client. - :param serializer: An object model serializer. - :param deserializer: An object model deserializer. + Instead, you should access the following operations through + :class:`~azure.mgmt.resource.policy.v2018_03_01.PolicyClient`'s + :attr:`policy_definitions` attribute. """ models = _models - def __init__(self, client, config, serializer, deserializer): - self._client = client - self._serialize = serializer - self._deserialize = deserializer - self._config = config + def __init__(self, *args, **kwargs): + input_args = list(args) + self._client = input_args.pop(0) if input_args else kwargs.pop("client") + self._config = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") - @distributed_trace + @overload def create_or_update( self, policy_definition_name: str, - parameters: "_models.PolicyDefinition", + parameters: _models.PolicyDefinition, + *, + content_type: str = "application/json", **kwargs: Any - ) -> "_models.PolicyDefinition": + ) -> _models.PolicyDefinition: """Creates or updates a policy definition in a subscription. This operation creates or updates a policy definition in the given subscription with the given name. - :param policy_definition_name: The name of the policy definition to create. + :param policy_definition_name: The name of the policy definition to create. Required. :type policy_definition_name: str - :param parameters: The policy definition properties. + :param parameters: The policy definition properties. Required. :type parameters: ~azure.mgmt.resource.policy.v2018_03_01.models.PolicyDefinition + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: PolicyDefinition or the result of cls(response) + :rtype: ~azure.mgmt.resource.policy.v2018_03_01.models.PolicyDefinition + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + def create_or_update( + self, policy_definition_name: str, parameters: IO, *, content_type: str = "application/json", **kwargs: Any + ) -> _models.PolicyDefinition: + """Creates or updates a policy definition in a subscription. + + This operation creates or updates a policy definition in the given subscription with the given + name. + + :param policy_definition_name: The name of the policy definition to create. Required. + :type policy_definition_name: str + :param parameters: The policy definition properties. Required. + :type parameters: IO + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: PolicyDefinition or the result of cls(response) + :rtype: ~azure.mgmt.resource.policy.v2018_03_01.models.PolicyDefinition + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace + def create_or_update( + self, policy_definition_name: str, parameters: Union[_models.PolicyDefinition, IO], **kwargs: Any + ) -> _models.PolicyDefinition: + """Creates or updates a policy definition in a subscription. + + This operation creates or updates a policy definition in the given subscription with the given + name. + + :param policy_definition_name: The name of the policy definition to create. Required. + :type policy_definition_name: str + :param parameters: The policy definition properties. Is either a model type or a IO type. + Required. + :type parameters: ~azure.mgmt.resource.policy.v2018_03_01.models.PolicyDefinition or IO + :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. + Default value is None. + :paramtype content_type: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: PolicyDefinition, or the result of cls(response) + :return: PolicyDefinition or the result of cls(response) :rtype: ~azure.mgmt.resource.policy.v2018_03_01.models.PolicyDefinition - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.PolicyDefinition"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) - api_version = kwargs.pop('api_version', "2018-03-01") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - _json = self._serialize.body(parameters, 'PolicyDefinition') + api_version = kwargs.pop("api_version", _params.pop("api-version", "2018-03-01")) # type: str + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.PolicyDefinition] + + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(parameters, (IO, bytes)): + _content = parameters + else: + _json = self._serialize.body(parameters, "PolicyDefinition") request = build_policy_definitions_create_or_update_request( policy_definition_name=policy_definition_name, @@ -1835,72 +1895,77 @@ def create_or_update( api_version=api_version, content_type=content_type, json=_json, - template_url=self.create_or_update.metadata['url'], + content=_content, + template_url=self.create_or_update.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [201]: map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) - deserialized = self._deserialize('PolicyDefinition', pipeline_response) + deserialized = self._deserialize("PolicyDefinition", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - create_or_update.metadata = {'url': "/subscriptions/{subscriptionId}/providers/Microsoft.Authorization/policyDefinitions/{policyDefinitionName}"} # type: ignore - + create_or_update.metadata = {"url": "/subscriptions/{subscriptionId}/providers/Microsoft.Authorization/policyDefinitions/{policyDefinitionName}"} # type: ignore @distributed_trace def delete( # pylint: disable=inconsistent-return-statements - self, - policy_definition_name: str, - **kwargs: Any + self, policy_definition_name: str, **kwargs: Any ) -> None: """Deletes a policy definition in a subscription. This operation deletes the policy definition in the given subscription with the given name. - :param policy_definition_name: The name of the policy definition to delete. + :param policy_definition_name: The name of the policy definition to delete. Required. :type policy_definition_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: None, or the result of cls(response) + :return: None or the result of cls(response) :rtype: None - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType[None] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) - api_version = kwargs.pop('api_version', "2018-03-01") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2018-03-01")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[None] - request = build_policy_definitions_delete_request( policy_definition_name=policy_definition_name, subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.delete.metadata['url'], + template_url=self.delete.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200, 204]: @@ -1910,154 +1975,231 @@ def delete( # pylint: disable=inconsistent-return-statements if cls: return cls(pipeline_response, None, {}) - delete.metadata = {'url': "/subscriptions/{subscriptionId}/providers/Microsoft.Authorization/policyDefinitions/{policyDefinitionName}"} # type: ignore - + delete.metadata = {"url": "/subscriptions/{subscriptionId}/providers/Microsoft.Authorization/policyDefinitions/{policyDefinitionName}"} # type: ignore @distributed_trace - def get( - self, - policy_definition_name: str, - **kwargs: Any - ) -> "_models.PolicyDefinition": + def get(self, policy_definition_name: str, **kwargs: Any) -> _models.PolicyDefinition: """Retrieves a policy definition in a subscription. This operation retrieves the policy definition in the given subscription with the given name. - :param policy_definition_name: The name of the policy definition to get. + :param policy_definition_name: The name of the policy definition to get. Required. :type policy_definition_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: PolicyDefinition, or the result of cls(response) + :return: PolicyDefinition or the result of cls(response) :rtype: ~azure.mgmt.resource.policy.v2018_03_01.models.PolicyDefinition - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.PolicyDefinition"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) - api_version = kwargs.pop('api_version', "2018-03-01") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2018-03-01")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[_models.PolicyDefinition] - request = build_policy_definitions_get_request( policy_definition_name=policy_definition_name, subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.get.metadata['url'], + template_url=self.get.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) - deserialized = self._deserialize('PolicyDefinition', pipeline_response) + deserialized = self._deserialize("PolicyDefinition", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - get.metadata = {'url': "/subscriptions/{subscriptionId}/providers/Microsoft.Authorization/policyDefinitions/{policyDefinitionName}"} # type: ignore - + get.metadata = {"url": "/subscriptions/{subscriptionId}/providers/Microsoft.Authorization/policyDefinitions/{policyDefinitionName}"} # type: ignore @distributed_trace - def get_built_in( - self, - policy_definition_name: str, - **kwargs: Any - ) -> "_models.PolicyDefinition": + def get_built_in(self, policy_definition_name: str, **kwargs: Any) -> _models.PolicyDefinition: """Retrieves a built-in policy definition. This operation retrieves the built-in policy definition with the given name. - :param policy_definition_name: The name of the built-in policy definition to get. + :param policy_definition_name: The name of the built-in policy definition to get. Required. :type policy_definition_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: PolicyDefinition, or the result of cls(response) + :return: PolicyDefinition or the result of cls(response) :rtype: ~azure.mgmt.resource.policy.v2018_03_01.models.PolicyDefinition - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.PolicyDefinition"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) - api_version = kwargs.pop('api_version', "2018-03-01") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2018-03-01")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[_models.PolicyDefinition] - request = build_policy_definitions_get_built_in_request( policy_definition_name=policy_definition_name, api_version=api_version, - template_url=self.get_built_in.metadata['url'], + template_url=self.get_built_in.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) - deserialized = self._deserialize('PolicyDefinition', pipeline_response) + deserialized = self._deserialize("PolicyDefinition", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - get_built_in.metadata = {'url': "/providers/Microsoft.Authorization/policyDefinitions/{policyDefinitionName}"} # type: ignore + get_built_in.metadata = {"url": "/providers/Microsoft.Authorization/policyDefinitions/{policyDefinitionName}"} # type: ignore + + @overload + def create_or_update_at_management_group( + self, + policy_definition_name: str, + management_group_id: str, + parameters: _models.PolicyDefinition, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.PolicyDefinition: + """Creates or updates a policy definition in a management group. + + This operation creates or updates a policy definition in the given management group with the + given name. + + :param policy_definition_name: The name of the policy definition to create. Required. + :type policy_definition_name: str + :param management_group_id: The ID of the management group. Required. + :type management_group_id: str + :param parameters: The policy definition properties. Required. + :type parameters: ~azure.mgmt.resource.policy.v2018_03_01.models.PolicyDefinition + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: PolicyDefinition or the result of cls(response) + :rtype: ~azure.mgmt.resource.policy.v2018_03_01.models.PolicyDefinition + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + def create_or_update_at_management_group( + self, + policy_definition_name: str, + management_group_id: str, + parameters: IO, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.PolicyDefinition: + """Creates or updates a policy definition in a management group. + + This operation creates or updates a policy definition in the given management group with the + given name. + :param policy_definition_name: The name of the policy definition to create. Required. + :type policy_definition_name: str + :param management_group_id: The ID of the management group. Required. + :type management_group_id: str + :param parameters: The policy definition properties. Required. + :type parameters: IO + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: PolicyDefinition or the result of cls(response) + :rtype: ~azure.mgmt.resource.policy.v2018_03_01.models.PolicyDefinition + :raises ~azure.core.exceptions.HttpResponseError: + """ @distributed_trace def create_or_update_at_management_group( self, policy_definition_name: str, management_group_id: str, - parameters: "_models.PolicyDefinition", + parameters: Union[_models.PolicyDefinition, IO], **kwargs: Any - ) -> "_models.PolicyDefinition": + ) -> _models.PolicyDefinition: """Creates or updates a policy definition in a management group. This operation creates or updates a policy definition in the given management group with the given name. - :param policy_definition_name: The name of the policy definition to create. + :param policy_definition_name: The name of the policy definition to create. Required. :type policy_definition_name: str - :param management_group_id: The ID of the management group. + :param management_group_id: The ID of the management group. Required. :type management_group_id: str - :param parameters: The policy definition properties. - :type parameters: ~azure.mgmt.resource.policy.v2018_03_01.models.PolicyDefinition + :param parameters: The policy definition properties. Is either a model type or a IO type. + Required. + :type parameters: ~azure.mgmt.resource.policy.v2018_03_01.models.PolicyDefinition or IO + :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. + Default value is None. + :paramtype content_type: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: PolicyDefinition, or the result of cls(response) + :return: PolicyDefinition or the result of cls(response) :rtype: ~azure.mgmt.resource.policy.v2018_03_01.models.PolicyDefinition - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.PolicyDefinition"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) - api_version = kwargs.pop('api_version', "2018-03-01") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - _json = self._serialize.body(parameters, 'PolicyDefinition') + api_version = kwargs.pop("api_version", _params.pop("api-version", "2018-03-01")) # type: str + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.PolicyDefinition] + + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(parameters, (IO, bytes)): + _content = parameters + else: + _json = self._serialize.body(parameters, "PolicyDefinition") request = build_policy_definitions_create_or_update_at_management_group_request( policy_definition_name=policy_definition_name, @@ -2065,75 +2207,79 @@ def create_or_update_at_management_group( api_version=api_version, content_type=content_type, json=_json, - template_url=self.create_or_update_at_management_group.metadata['url'], + content=_content, + template_url=self.create_or_update_at_management_group.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [201]: map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) - deserialized = self._deserialize('PolicyDefinition', pipeline_response) + deserialized = self._deserialize("PolicyDefinition", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - create_or_update_at_management_group.metadata = {'url': "/providers/Microsoft.Management/managementgroups/{managementGroupId}/providers/Microsoft.Authorization/policyDefinitions/{policyDefinitionName}"} # type: ignore - + create_or_update_at_management_group.metadata = {"url": "/providers/Microsoft.Management/managementgroups/{managementGroupId}/providers/Microsoft.Authorization/policyDefinitions/{policyDefinitionName}"} # type: ignore @distributed_trace def delete_at_management_group( # pylint: disable=inconsistent-return-statements - self, - policy_definition_name: str, - management_group_id: str, - **kwargs: Any + self, policy_definition_name: str, management_group_id: str, **kwargs: Any ) -> None: """Deletes a policy definition in a management group. This operation deletes the policy definition in the given management group with the given name. - :param policy_definition_name: The name of the policy definition to delete. + :param policy_definition_name: The name of the policy definition to delete. Required. :type policy_definition_name: str - :param management_group_id: The ID of the management group. + :param management_group_id: The ID of the management group. Required. :type management_group_id: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: None, or the result of cls(response) + :return: None or the result of cls(response) :rtype: None - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType[None] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + 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', "2018-03-01") # type: str + api_version = kwargs.pop("api_version", _params.pop("api-version", "2018-03-01")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[None] - request = build_policy_definitions_delete_at_management_group_request( policy_definition_name=policy_definition_name, management_group_id=management_group_id, api_version=api_version, - template_url=self.delete_at_management_group.metadata['url'], + template_url=self.delete_at_management_group.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200, 204]: @@ -2143,111 +2289,117 @@ def delete_at_management_group( # pylint: disable=inconsistent-return-statement if cls: return cls(pipeline_response, None, {}) - delete_at_management_group.metadata = {'url': "/providers/Microsoft.Management/managementgroups/{managementGroupId}/providers/Microsoft.Authorization/policyDefinitions/{policyDefinitionName}"} # type: ignore - + delete_at_management_group.metadata = {"url": "/providers/Microsoft.Management/managementgroups/{managementGroupId}/providers/Microsoft.Authorization/policyDefinitions/{policyDefinitionName}"} # type: ignore @distributed_trace def get_at_management_group( - self, - policy_definition_name: str, - management_group_id: str, - **kwargs: Any - ) -> "_models.PolicyDefinition": + self, policy_definition_name: str, management_group_id: str, **kwargs: Any + ) -> _models.PolicyDefinition: """Retrieve a policy definition in a management group. This operation retrieves the policy definition in the given management group with the given name. - :param policy_definition_name: The name of the policy definition to get. + :param policy_definition_name: The name of the policy definition to get. Required. :type policy_definition_name: str - :param management_group_id: The ID of the management group. + :param management_group_id: The ID of the management group. Required. :type management_group_id: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: PolicyDefinition, or the result of cls(response) + :return: PolicyDefinition or the result of cls(response) :rtype: ~azure.mgmt.resource.policy.v2018_03_01.models.PolicyDefinition - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.PolicyDefinition"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) - api_version = kwargs.pop('api_version', "2018-03-01") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2018-03-01")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[_models.PolicyDefinition] - request = build_policy_definitions_get_at_management_group_request( policy_definition_name=policy_definition_name, management_group_id=management_group_id, api_version=api_version, - template_url=self.get_at_management_group.metadata['url'], + template_url=self.get_at_management_group.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) - deserialized = self._deserialize('PolicyDefinition', pipeline_response) + deserialized = self._deserialize("PolicyDefinition", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - get_at_management_group.metadata = {'url': "/providers/Microsoft.Management/managementgroups/{managementGroupId}/providers/Microsoft.Authorization/policyDefinitions/{policyDefinitionName}"} # type: ignore - + get_at_management_group.metadata = {"url": "/providers/Microsoft.Management/managementgroups/{managementGroupId}/providers/Microsoft.Authorization/policyDefinitions/{policyDefinitionName}"} # type: ignore @distributed_trace - def list( - self, - **kwargs: Any - ) -> Iterable["_models.PolicyDefinitionListResult"]: + def list(self, **kwargs: Any) -> Iterable["_models.PolicyDefinition"]: """Retrieves policy definitions in a subscription. This operation retrieves a list of all the policy definitions in a given subscription. :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either PolicyDefinitionListResult or the result of - cls(response) + :return: An iterator like instance of either PolicyDefinition or the result of cls(response) :rtype: - ~azure.core.paging.ItemPaged[~azure.mgmt.resource.policy.v2018_03_01.models.PolicyDefinitionListResult] - :raises: ~azure.core.exceptions.HttpResponseError + ~azure.core.paging.ItemPaged[~azure.mgmt.resource.policy.v2018_03_01.models.PolicyDefinition] + :raises ~azure.core.exceptions.HttpResponseError: """ - api_version = kwargs.pop('api_version', "2018-03-01") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2018-03-01")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[_models.PolicyDefinitionListResult] - cls = kwargs.pop('cls', None) # type: ClsType["_models.PolicyDefinitionListResult"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) + def prepare_request(next_link=None): if not next_link: - + request = build_policy_definitions_list_request( subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.list.metadata['url'], + template_url=self.list.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore else: - - request = build_policy_definitions_list_request( - subscription_id=self._config.subscription_id, - template_url=next_link, - ) + # make call to next link with the client's api-version + _parsed_next_link = urlparse(next_link) + _next_request_params = case_insensitive_dict(parse_qs(_parsed_next_link.query)) + _next_request_params["api-version"] = self._config.api_version + request = HttpRequest("GET", urljoin(next_link, _parsed_next_link.path), params=_next_request_params) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore request.method = "GET" return request @@ -2261,10 +2413,8 @@ def extract_data(pipeline_response): def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) response = pipeline_response.http_response @@ -2274,52 +2424,56 @@ def get_next(next_link=None): return pipeline_response + return ItemPaged(get_next, extract_data) - return ItemPaged( - get_next, extract_data - ) - list.metadata = {'url': "/subscriptions/{subscriptionId}/providers/Microsoft.Authorization/policyDefinitions"} # type: ignore + list.metadata = {"url": "/subscriptions/{subscriptionId}/providers/Microsoft.Authorization/policyDefinitions"} # type: ignore @distributed_trace - def list_built_in( - self, - **kwargs: Any - ) -> Iterable["_models.PolicyDefinitionListResult"]: + def list_built_in(self, **kwargs: Any) -> Iterable["_models.PolicyDefinition"]: """Retrieve built-in policy definitions. This operation retrieves a list of all the built-in policy definitions. :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either PolicyDefinitionListResult or the result of - cls(response) + :return: An iterator like instance of either PolicyDefinition or the result of cls(response) :rtype: - ~azure.core.paging.ItemPaged[~azure.mgmt.resource.policy.v2018_03_01.models.PolicyDefinitionListResult] - :raises: ~azure.core.exceptions.HttpResponseError + ~azure.core.paging.ItemPaged[~azure.mgmt.resource.policy.v2018_03_01.models.PolicyDefinition] + :raises ~azure.core.exceptions.HttpResponseError: """ - api_version = kwargs.pop('api_version', "2018-03-01") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2018-03-01")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[_models.PolicyDefinitionListResult] - cls = kwargs.pop('cls', None) # type: ClsType["_models.PolicyDefinitionListResult"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) + def prepare_request(next_link=None): if not next_link: - + request = build_policy_definitions_list_built_in_request( api_version=api_version, - template_url=self.list_built_in.metadata['url'], + template_url=self.list_built_in.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore else: - - request = build_policy_definitions_list_built_in_request( - template_url=next_link, - ) + # make call to next link with the client's api-version + _parsed_next_link = urlparse(next_link) + _next_request_params = case_insensitive_dict(parse_qs(_parsed_next_link.query)) + _next_request_params["api-version"] = self._config.api_version + request = HttpRequest("GET", urljoin(next_link, _parsed_next_link.path), params=_next_request_params) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore request.method = "GET" return request @@ -2333,10 +2487,8 @@ def extract_data(pipeline_response): def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) response = pipeline_response.http_response @@ -2346,57 +2498,59 @@ def get_next(next_link=None): return pipeline_response + return ItemPaged(get_next, extract_data) - return ItemPaged( - get_next, extract_data - ) - list_built_in.metadata = {'url': "/providers/Microsoft.Authorization/policyDefinitions"} # type: ignore + list_built_in.metadata = {"url": "/providers/Microsoft.Authorization/policyDefinitions"} # type: ignore @distributed_trace - def list_by_management_group( - self, - management_group_id: str, - **kwargs: Any - ) -> Iterable["_models.PolicyDefinitionListResult"]: + def list_by_management_group(self, management_group_id: str, **kwargs: Any) -> Iterable["_models.PolicyDefinition"]: """Retrieve policy definitions in a management group. This operation retrieves a list of all the policy definitions in a given management group. - :param management_group_id: The ID of the management group. + :param management_group_id: The ID of the management group. Required. :type management_group_id: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either PolicyDefinitionListResult or the result of - cls(response) + :return: An iterator like instance of either PolicyDefinition or the result of cls(response) :rtype: - ~azure.core.paging.ItemPaged[~azure.mgmt.resource.policy.v2018_03_01.models.PolicyDefinitionListResult] - :raises: ~azure.core.exceptions.HttpResponseError + ~azure.core.paging.ItemPaged[~azure.mgmt.resource.policy.v2018_03_01.models.PolicyDefinition] + :raises ~azure.core.exceptions.HttpResponseError: """ - api_version = kwargs.pop('api_version', "2018-03-01") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2018-03-01")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[_models.PolicyDefinitionListResult] - cls = kwargs.pop('cls', None) # type: ClsType["_models.PolicyDefinitionListResult"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) + def prepare_request(next_link=None): if not next_link: - + request = build_policy_definitions_list_by_management_group_request( management_group_id=management_group_id, api_version=api_version, - template_url=self.list_by_management_group.metadata['url'], + template_url=self.list_by_management_group.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore else: - - request = build_policy_definitions_list_by_management_group_request( - management_group_id=management_group_id, - template_url=next_link, - ) + # make call to next link with the client's api-version + _parsed_next_link = urlparse(next_link) + _next_request_params = case_insensitive_dict(parse_qs(_parsed_next_link.query)) + _next_request_params["api-version"] = self._config.api_version + request = HttpRequest("GET", urljoin(next_link, _parsed_next_link.path), params=_next_request_params) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore request.method = "GET" return request @@ -2410,10 +2564,8 @@ def extract_data(pipeline_response): def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) response = pipeline_response.http_response @@ -2423,64 +2575,123 @@ def get_next(next_link=None): return pipeline_response + return ItemPaged(get_next, extract_data) - return ItemPaged( - get_next, extract_data - ) - list_by_management_group.metadata = {'url': "/providers/Microsoft.Management/managementgroups/{managementGroupId}/providers/Microsoft.Authorization/policyDefinitions"} # type: ignore -class PolicySetDefinitionsOperations(object): - """PolicySetDefinitionsOperations operations. - - You should not instantiate this class directly. Instead, you should create a Client instance that - instantiates it for you and attaches it as an attribute. - - :ivar models: Alias to model classes used in this operation group. - :type models: ~azure.mgmt.resource.policy.v2018_03_01.models - :param client: Client for service requests. - :param config: Configuration of service client. - :param serializer: An object model serializer. - :param deserializer: An object model deserializer. + list_by_management_group.metadata = {"url": "/providers/Microsoft.Management/managementgroups/{managementGroupId}/providers/Microsoft.Authorization/policyDefinitions"} # type: ignore + + +class PolicySetDefinitionsOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. + + Instead, you should access the following operations through + :class:`~azure.mgmt.resource.policy.v2018_03_01.PolicyClient`'s + :attr:`policy_set_definitions` attribute. """ models = _models - def __init__(self, client, config, serializer, deserializer): - self._client = client - self._serialize = serializer - self._deserialize = deserializer - self._config = config + def __init__(self, *args, **kwargs): + input_args = list(args) + self._client = input_args.pop(0) if input_args else kwargs.pop("client") + self._config = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") - @distributed_trace + @overload def create_or_update( self, policy_set_definition_name: str, - parameters: "_models.PolicySetDefinition", + parameters: _models.PolicySetDefinition, + *, + content_type: str = "application/json", **kwargs: Any - ) -> "_models.PolicySetDefinition": + ) -> _models.PolicySetDefinition: """Creates or updates a policy set definition. This operation creates or updates a policy set definition in the given subscription with the given name. - :param policy_set_definition_name: The name of the policy set definition to create. + :param policy_set_definition_name: The name of the policy set definition to create. Required. :type policy_set_definition_name: str - :param parameters: The policy set definition properties. + :param parameters: The policy set definition properties. Required. :type parameters: ~azure.mgmt.resource.policy.v2018_03_01.models.PolicySetDefinition + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: PolicySetDefinition or the result of cls(response) + :rtype: ~azure.mgmt.resource.policy.v2018_03_01.models.PolicySetDefinition + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + def create_or_update( + self, policy_set_definition_name: str, parameters: IO, *, content_type: str = "application/json", **kwargs: Any + ) -> _models.PolicySetDefinition: + """Creates or updates a policy set definition. + + This operation creates or updates a policy set definition in the given subscription with the + given name. + + :param policy_set_definition_name: The name of the policy set definition to create. Required. + :type policy_set_definition_name: str + :param parameters: The policy set definition properties. Required. + :type parameters: IO + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: PolicySetDefinition or the result of cls(response) + :rtype: ~azure.mgmt.resource.policy.v2018_03_01.models.PolicySetDefinition + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace + def create_or_update( + self, policy_set_definition_name: str, parameters: Union[_models.PolicySetDefinition, IO], **kwargs: Any + ) -> _models.PolicySetDefinition: + """Creates or updates a policy set definition. + + This operation creates or updates a policy set definition in the given subscription with the + given name. + + :param policy_set_definition_name: The name of the policy set definition to create. Required. + :type policy_set_definition_name: str + :param parameters: The policy set definition properties. Is either a model type or a IO type. + Required. + :type parameters: ~azure.mgmt.resource.policy.v2018_03_01.models.PolicySetDefinition or IO + :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. + Default value is None. + :paramtype content_type: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: PolicySetDefinition, or the result of cls(response) + :return: PolicySetDefinition or the result of cls(response) :rtype: ~azure.mgmt.resource.policy.v2018_03_01.models.PolicySetDefinition - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.PolicySetDefinition"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) - api_version = kwargs.pop('api_version', "2018-03-01") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - _json = self._serialize.body(parameters, 'PolicySetDefinition') + api_version = kwargs.pop("api_version", _params.pop("api-version", "2018-03-01")) # type: str + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.PolicySetDefinition] + + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(parameters, (IO, bytes)): + _content = parameters + else: + _json = self._serialize.body(parameters, "PolicySetDefinition") request = build_policy_set_definitions_create_or_update_request( policy_set_definition_name=policy_set_definition_name, @@ -2488,16 +2699,18 @@ def create_or_update( api_version=api_version, content_type=content_type, json=_json, - template_url=self.create_or_update.metadata['url'], + content=_content, + template_url=self.create_or_update.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200, 201]: @@ -2506,59 +2719,62 @@ def create_or_update( raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) if response.status_code == 200: - deserialized = self._deserialize('PolicySetDefinition', pipeline_response) + deserialized = self._deserialize("PolicySetDefinition", pipeline_response) if response.status_code == 201: - deserialized = self._deserialize('PolicySetDefinition', pipeline_response) + deserialized = self._deserialize("PolicySetDefinition", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - create_or_update.metadata = {'url': "/subscriptions/{subscriptionId}/providers/Microsoft.Authorization/policySetDefinitions/{policySetDefinitionName}"} # type: ignore - + create_or_update.metadata = {"url": "/subscriptions/{subscriptionId}/providers/Microsoft.Authorization/policySetDefinitions/{policySetDefinitionName}"} # type: ignore @distributed_trace def delete( # pylint: disable=inconsistent-return-statements - self, - policy_set_definition_name: str, - **kwargs: Any + self, policy_set_definition_name: str, **kwargs: Any ) -> None: """Deletes a policy set definition. This operation deletes the policy set definition in the given subscription with the given name. - :param policy_set_definition_name: The name of the policy set definition to delete. + :param policy_set_definition_name: The name of the policy set definition to delete. Required. :type policy_set_definition_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: None, or the result of cls(response) + :return: None or the result of cls(response) :rtype: None - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType[None] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) - api_version = kwargs.pop('api_version', "2018-03-01") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2018-03-01")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[None] - request = build_policy_set_definitions_delete_request( policy_set_definition_name=policy_set_definition_name, subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.delete.metadata['url'], + template_url=self.delete.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200, 204]: @@ -2569,50 +2785,51 @@ def delete( # pylint: disable=inconsistent-return-statements if cls: return cls(pipeline_response, None, {}) - delete.metadata = {'url': "/subscriptions/{subscriptionId}/providers/Microsoft.Authorization/policySetDefinitions/{policySetDefinitionName}"} # type: ignore - + delete.metadata = {"url": "/subscriptions/{subscriptionId}/providers/Microsoft.Authorization/policySetDefinitions/{policySetDefinitionName}"} # type: ignore @distributed_trace - def get( - self, - policy_set_definition_name: str, - **kwargs: Any - ) -> "_models.PolicySetDefinition": + def get(self, policy_set_definition_name: str, **kwargs: Any) -> _models.PolicySetDefinition: """Retrieves a policy set definition. This operation retrieves the policy set definition in the given subscription with the given name. - :param policy_set_definition_name: The name of the policy set definition to get. + :param policy_set_definition_name: The name of the policy set definition to get. Required. :type policy_set_definition_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: PolicySetDefinition, or the result of cls(response) + :return: PolicySetDefinition or the result of cls(response) :rtype: ~azure.mgmt.resource.policy.v2018_03_01.models.PolicySetDefinition - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.PolicySetDefinition"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) - api_version = kwargs.pop('api_version', "2018-03-01") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2018-03-01")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[_models.PolicySetDefinition] - request = build_policy_set_definitions_get_request( policy_set_definition_name=policy_set_definition_name, subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.get.metadata['url'], + template_url=self.get.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200]: @@ -2620,55 +2837,56 @@ def get( error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - deserialized = self._deserialize('PolicySetDefinition', pipeline_response) + deserialized = self._deserialize("PolicySetDefinition", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - get.metadata = {'url': "/subscriptions/{subscriptionId}/providers/Microsoft.Authorization/policySetDefinitions/{policySetDefinitionName}"} # type: ignore - + get.metadata = {"url": "/subscriptions/{subscriptionId}/providers/Microsoft.Authorization/policySetDefinitions/{policySetDefinitionName}"} # type: ignore @distributed_trace - def get_built_in( - self, - policy_set_definition_name: str, - **kwargs: Any - ) -> "_models.PolicySetDefinition": + def get_built_in(self, policy_set_definition_name: str, **kwargs: Any) -> _models.PolicySetDefinition: """Retrieves a built in policy set definition. This operation retrieves the built-in policy set definition with the given name. - :param policy_set_definition_name: The name of the policy set definition to get. + :param policy_set_definition_name: The name of the policy set definition to get. Required. :type policy_set_definition_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: PolicySetDefinition, or the result of cls(response) + :return: PolicySetDefinition or the result of cls(response) :rtype: ~azure.mgmt.resource.policy.v2018_03_01.models.PolicySetDefinition - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.PolicySetDefinition"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) - api_version = kwargs.pop('api_version', "2018-03-01") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2018-03-01")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[_models.PolicySetDefinition] - request = build_policy_set_definitions_get_built_in_request( policy_set_definition_name=policy_set_definition_name, api_version=api_version, - template_url=self.get_built_in.metadata['url'], + template_url=self.get_built_in.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200]: @@ -2676,58 +2894,62 @@ def get_built_in( error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - deserialized = self._deserialize('PolicySetDefinition', pipeline_response) + deserialized = self._deserialize("PolicySetDefinition", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - get_built_in.metadata = {'url': "/providers/Microsoft.Authorization/policySetDefinitions/{policySetDefinitionName}"} # type: ignore - + get_built_in.metadata = {"url": "/providers/Microsoft.Authorization/policySetDefinitions/{policySetDefinitionName}"} # type: ignore @distributed_trace - def list( - self, - **kwargs: Any - ) -> Iterable["_models.PolicySetDefinitionListResult"]: + def list(self, **kwargs: Any) -> Iterable["_models.PolicySetDefinition"]: """Retrieves the policy set definitions for a subscription. This operation retrieves a list of all the policy set definitions in the given subscription. :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either PolicySetDefinitionListResult or the result of - cls(response) + :return: An iterator like instance of either PolicySetDefinition or the result of cls(response) :rtype: - ~azure.core.paging.ItemPaged[~azure.mgmt.resource.policy.v2018_03_01.models.PolicySetDefinitionListResult] - :raises: ~azure.core.exceptions.HttpResponseError + ~azure.core.paging.ItemPaged[~azure.mgmt.resource.policy.v2018_03_01.models.PolicySetDefinition] + :raises ~azure.core.exceptions.HttpResponseError: """ - api_version = kwargs.pop('api_version', "2018-03-01") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2018-03-01")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[_models.PolicySetDefinitionListResult] - cls = kwargs.pop('cls', None) # type: ClsType["_models.PolicySetDefinitionListResult"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) + def prepare_request(next_link=None): if not next_link: - + request = build_policy_set_definitions_list_request( subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.list.metadata['url'], + template_url=self.list.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore else: - - request = build_policy_set_definitions_list_request( - subscription_id=self._config.subscription_id, - template_url=next_link, - ) + # make call to next link with the client's api-version + _parsed_next_link = urlparse(next_link) + _next_request_params = case_insensitive_dict(parse_qs(_parsed_next_link.query)) + _next_request_params["api-version"] = self._config.api_version + request = HttpRequest("GET", urljoin(next_link, _parsed_next_link.path), params=_next_request_params) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore request.method = "GET" return request @@ -2741,10 +2963,8 @@ def extract_data(pipeline_response): def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) response = pipeline_response.http_response @@ -2755,52 +2975,56 @@ def get_next(next_link=None): return pipeline_response + return ItemPaged(get_next, extract_data) - return ItemPaged( - get_next, extract_data - ) - list.metadata = {'url': "/subscriptions/{subscriptionId}/providers/Microsoft.Authorization/policySetDefinitions"} # type: ignore + list.metadata = {"url": "/subscriptions/{subscriptionId}/providers/Microsoft.Authorization/policySetDefinitions"} # type: ignore @distributed_trace - def list_built_in( - self, - **kwargs: Any - ) -> Iterable["_models.PolicySetDefinitionListResult"]: + def list_built_in(self, **kwargs: Any) -> Iterable["_models.PolicySetDefinition"]: """Retrieves built-in policy set definitions. This operation retrieves a list of all the built-in policy set definitions. :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either PolicySetDefinitionListResult or the result of - cls(response) + :return: An iterator like instance of either PolicySetDefinition or the result of cls(response) :rtype: - ~azure.core.paging.ItemPaged[~azure.mgmt.resource.policy.v2018_03_01.models.PolicySetDefinitionListResult] - :raises: ~azure.core.exceptions.HttpResponseError + ~azure.core.paging.ItemPaged[~azure.mgmt.resource.policy.v2018_03_01.models.PolicySetDefinition] + :raises ~azure.core.exceptions.HttpResponseError: """ - api_version = kwargs.pop('api_version', "2018-03-01") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2018-03-01")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[_models.PolicySetDefinitionListResult] - cls = kwargs.pop('cls', None) # type: ClsType["_models.PolicySetDefinitionListResult"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) + def prepare_request(next_link=None): if not next_link: - + request = build_policy_set_definitions_list_built_in_request( api_version=api_version, - template_url=self.list_built_in.metadata['url'], + template_url=self.list_built_in.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore else: - - request = build_policy_set_definitions_list_built_in_request( - template_url=next_link, - ) + # make call to next link with the client's api-version + _parsed_next_link = urlparse(next_link) + _next_request_params = case_insensitive_dict(parse_qs(_parsed_next_link.query)) + _next_request_params["api-version"] = self._config.api_version + request = HttpRequest("GET", urljoin(next_link, _parsed_next_link.path), params=_next_request_params) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore request.method = "GET" return request @@ -2814,10 +3038,8 @@ def extract_data(pipeline_response): def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) response = pipeline_response.http_response @@ -2828,46 +3050,120 @@ def get_next(next_link=None): return pipeline_response + return ItemPaged(get_next, extract_data) - return ItemPaged( - get_next, extract_data - ) - list_built_in.metadata = {'url': "/providers/Microsoft.Authorization/policySetDefinitions"} # type: ignore + list_built_in.metadata = {"url": "/providers/Microsoft.Authorization/policySetDefinitions"} # type: ignore - @distributed_trace + @overload def create_or_update_at_management_group( self, policy_set_definition_name: str, management_group_id: str, - parameters: "_models.PolicySetDefinition", + parameters: _models.PolicySetDefinition, + *, + content_type: str = "application/json", **kwargs: Any - ) -> "_models.PolicySetDefinition": + ) -> _models.PolicySetDefinition: """Creates or updates a policy set definition. This operation creates or updates a policy set definition in the given management group with the given name. - :param policy_set_definition_name: The name of the policy set definition to create. + :param policy_set_definition_name: The name of the policy set definition to create. Required. :type policy_set_definition_name: str - :param management_group_id: The ID of the management group. + :param management_group_id: The ID of the management group. Required. :type management_group_id: str - :param parameters: The policy set definition properties. + :param parameters: The policy set definition properties. Required. :type parameters: ~azure.mgmt.resource.policy.v2018_03_01.models.PolicySetDefinition + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: PolicySetDefinition or the result of cls(response) + :rtype: ~azure.mgmt.resource.policy.v2018_03_01.models.PolicySetDefinition + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + def create_or_update_at_management_group( + self, + policy_set_definition_name: str, + management_group_id: str, + parameters: IO, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.PolicySetDefinition: + """Creates or updates a policy set definition. + + This operation creates or updates a policy set definition in the given management group with + the given name. + + :param policy_set_definition_name: The name of the policy set definition to create. Required. + :type policy_set_definition_name: str + :param management_group_id: The ID of the management group. Required. + :type management_group_id: str + :param parameters: The policy set definition properties. Required. + :type parameters: IO + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: PolicySetDefinition or the result of cls(response) + :rtype: ~azure.mgmt.resource.policy.v2018_03_01.models.PolicySetDefinition + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace + def create_or_update_at_management_group( + self, + policy_set_definition_name: str, + management_group_id: str, + parameters: Union[_models.PolicySetDefinition, IO], + **kwargs: Any + ) -> _models.PolicySetDefinition: + """Creates or updates a policy set definition. + + This operation creates or updates a policy set definition in the given management group with + the given name. + + :param policy_set_definition_name: The name of the policy set definition to create. Required. + :type policy_set_definition_name: str + :param management_group_id: The ID of the management group. Required. + :type management_group_id: str + :param parameters: The policy set definition properties. Is either a model type or a IO type. + Required. + :type parameters: ~azure.mgmt.resource.policy.v2018_03_01.models.PolicySetDefinition or IO + :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. + Default value is None. + :paramtype content_type: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: PolicySetDefinition, or the result of cls(response) + :return: PolicySetDefinition or the result of cls(response) :rtype: ~azure.mgmt.resource.policy.v2018_03_01.models.PolicySetDefinition - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.PolicySetDefinition"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', "2018-03-01") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + api_version = kwargs.pop("api_version", _params.pop("api-version", "2018-03-01")) # type: str + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.PolicySetDefinition] - _json = self._serialize.body(parameters, 'PolicySetDefinition') + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(parameters, (IO, bytes)): + _content = parameters + else: + _json = self._serialize.body(parameters, "PolicySetDefinition") request = build_policy_set_definitions_create_or_update_at_management_group_request( policy_set_definition_name=policy_set_definition_name, @@ -2875,16 +3171,18 @@ def create_or_update_at_management_group( api_version=api_version, content_type=content_type, json=_json, - template_url=self.create_or_update_at_management_group.metadata['url'], + content=_content, + template_url=self.create_or_update_at_management_group.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200, 201]: @@ -2893,63 +3191,65 @@ def create_or_update_at_management_group( raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) if response.status_code == 200: - deserialized = self._deserialize('PolicySetDefinition', pipeline_response) + deserialized = self._deserialize("PolicySetDefinition", pipeline_response) if response.status_code == 201: - deserialized = self._deserialize('PolicySetDefinition', pipeline_response) + deserialized = self._deserialize("PolicySetDefinition", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - create_or_update_at_management_group.metadata = {'url': "/providers/Microsoft.Management/managementgroups/{managementGroupId}/providers/Microsoft.Authorization/policySetDefinitions/{policySetDefinitionName}"} # type: ignore - + create_or_update_at_management_group.metadata = {"url": "/providers/Microsoft.Management/managementgroups/{managementGroupId}/providers/Microsoft.Authorization/policySetDefinitions/{policySetDefinitionName}"} # type: ignore @distributed_trace def delete_at_management_group( # pylint: disable=inconsistent-return-statements - self, - policy_set_definition_name: str, - management_group_id: str, - **kwargs: Any + self, policy_set_definition_name: str, management_group_id: str, **kwargs: Any ) -> None: """Deletes a policy set definition. This operation deletes the policy set definition in the given management group with the given name. - :param policy_set_definition_name: The name of the policy set definition to delete. + :param policy_set_definition_name: The name of the policy set definition to delete. Required. :type policy_set_definition_name: str - :param management_group_id: The ID of the management group. + :param management_group_id: The ID of the management group. Required. :type management_group_id: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: None, or the result of cls(response) + :return: None or the result of cls(response) :rtype: None - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType[None] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) - api_version = kwargs.pop('api_version', "2018-03-01") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2018-03-01")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[None] - request = build_policy_set_definitions_delete_at_management_group_request( policy_set_definition_name=policy_set_definition_name, management_group_id=management_group_id, api_version=api_version, - template_url=self.delete_at_management_group.metadata['url'], + template_url=self.delete_at_management_group.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200, 204]: @@ -2960,53 +3260,55 @@ def delete_at_management_group( # pylint: disable=inconsistent-return-statement if cls: return cls(pipeline_response, None, {}) - delete_at_management_group.metadata = {'url': "/providers/Microsoft.Management/managementgroups/{managementGroupId}/providers/Microsoft.Authorization/policySetDefinitions/{policySetDefinitionName}"} # type: ignore - + delete_at_management_group.metadata = {"url": "/providers/Microsoft.Management/managementgroups/{managementGroupId}/providers/Microsoft.Authorization/policySetDefinitions/{policySetDefinitionName}"} # type: ignore @distributed_trace def get_at_management_group( - self, - policy_set_definition_name: str, - management_group_id: str, - **kwargs: Any - ) -> "_models.PolicySetDefinition": + self, policy_set_definition_name: str, management_group_id: str, **kwargs: Any + ) -> _models.PolicySetDefinition: """Retrieves a policy set definition. This operation retrieves the policy set definition in the given management group with the given name. - :param policy_set_definition_name: The name of the policy set definition to get. + :param policy_set_definition_name: The name of the policy set definition to get. Required. :type policy_set_definition_name: str - :param management_group_id: The ID of the management group. + :param management_group_id: The ID of the management group. Required. :type management_group_id: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: PolicySetDefinition, or the result of cls(response) + :return: PolicySetDefinition or the result of cls(response) :rtype: ~azure.mgmt.resource.policy.v2018_03_01.models.PolicySetDefinition - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.PolicySetDefinition"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + 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', "2018-03-01") # type: str + api_version = kwargs.pop("api_version", _params.pop("api-version", "2018-03-01")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[_models.PolicySetDefinition] - request = build_policy_set_definitions_get_at_management_group_request( policy_set_definition_name=policy_set_definition_name, management_group_id=management_group_id, api_version=api_version, - template_url=self.get_at_management_group.metadata['url'], + template_url=self.get_at_management_group.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200]: @@ -3014,62 +3316,67 @@ def get_at_management_group( error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - deserialized = self._deserialize('PolicySetDefinition', pipeline_response) + deserialized = self._deserialize("PolicySetDefinition", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - get_at_management_group.metadata = {'url': "/providers/Microsoft.Management/managementgroups/{managementGroupId}/providers/Microsoft.Authorization/policySetDefinitions/{policySetDefinitionName}"} # type: ignore - + get_at_management_group.metadata = {"url": "/providers/Microsoft.Management/managementgroups/{managementGroupId}/providers/Microsoft.Authorization/policySetDefinitions/{policySetDefinitionName}"} # type: ignore @distributed_trace def list_by_management_group( - self, - management_group_id: str, - **kwargs: Any - ) -> Iterable["_models.PolicySetDefinitionListResult"]: + self, management_group_id: str, **kwargs: Any + ) -> Iterable["_models.PolicySetDefinition"]: """Retrieves all policy set definitions in management group. This operation retrieves a list of all the a policy set definition in the given management group. - :param management_group_id: The ID of the management group. + :param management_group_id: The ID of the management group. Required. :type management_group_id: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either PolicySetDefinitionListResult or the result of - cls(response) + :return: An iterator like instance of either PolicySetDefinition or the result of cls(response) :rtype: - ~azure.core.paging.ItemPaged[~azure.mgmt.resource.policy.v2018_03_01.models.PolicySetDefinitionListResult] - :raises: ~azure.core.exceptions.HttpResponseError + ~azure.core.paging.ItemPaged[~azure.mgmt.resource.policy.v2018_03_01.models.PolicySetDefinition] + :raises ~azure.core.exceptions.HttpResponseError: """ - api_version = kwargs.pop('api_version', "2018-03-01") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2018-03-01")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[_models.PolicySetDefinitionListResult] - cls = kwargs.pop('cls', None) # type: ClsType["_models.PolicySetDefinitionListResult"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) + def prepare_request(next_link=None): if not next_link: - + request = build_policy_set_definitions_list_by_management_group_request( management_group_id=management_group_id, api_version=api_version, - template_url=self.list_by_management_group.metadata['url'], + template_url=self.list_by_management_group.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore else: - - request = build_policy_set_definitions_list_by_management_group_request( - management_group_id=management_group_id, - template_url=next_link, - ) + # make call to next link with the client's api-version + _parsed_next_link = urlparse(next_link) + _next_request_params = case_insensitive_dict(parse_qs(_parsed_next_link.query)) + _next_request_params["api-version"] = self._config.api_version + request = HttpRequest("GET", urljoin(next_link, _parsed_next_link.path), params=_next_request_params) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore request.method = "GET" return request @@ -3083,10 +3390,8 @@ def extract_data(pipeline_response): def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) response = pipeline_response.http_response @@ -3097,8 +3402,6 @@ def get_next(next_link=None): return pipeline_response + return ItemPaged(get_next, extract_data) - return ItemPaged( - get_next, extract_data - ) - list_by_management_group.metadata = {'url': "/providers/Microsoft.Management/managementgroups/{managementGroupId}/providers/Microsoft.Authorization/policySetDefinitions"} # type: ignore + list_by_management_group.metadata = {"url": "/providers/Microsoft.Management/managementgroups/{managementGroupId}/providers/Microsoft.Authorization/policySetDefinitions"} # type: ignore diff --git a/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/policy/v2018_03_01/operations/_patch.py b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/policy/v2018_03_01/operations/_patch.py new file mode 100644 index 0000000000000..f7dd32510333d --- /dev/null +++ b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/policy/v2018_03_01/operations/_patch.py @@ -0,0 +1,20 @@ +# ------------------------------------ +# Copyright (c) Microsoft Corporation. +# Licensed under the MIT License. +# ------------------------------------ +"""Customize generated code here. + +Follow our quickstart for examples: https://aka.ms/azsdk/python/dpcodegen/python/customize +""" +from typing import List + +__all__: List[str] = [] # Add all objects you want publicly available to users at this package level + + +def patch_sdk(): + """Do not remove from this file. + + `patch_sdk` is a last resort escape hatch that allows you to do customizations + you can't accomplish using the techniques described in + https://aka.ms/azsdk/python/dpcodegen/python/customize + """ diff --git a/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/policy/v2018_05_01/__init__.py b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/policy/v2018_05_01/__init__.py index 89180ab440872..bb1ffe59afae7 100644 --- a/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/policy/v2018_05_01/__init__.py +++ b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/policy/v2018_05_01/__init__.py @@ -10,9 +10,15 @@ from ._version import VERSION __version__ = VERSION -__all__ = ['PolicyClient'] -# `._patch.py` is used for handwritten extensions to the generated code -# Example: https://github.com/Azure/azure-sdk-for-python/blob/main/doc/dev/customize_code/how-to-patch-sdk-code.md -from ._patch import patch_sdk -patch_sdk() +try: + from ._patch import __all__ as _patch_all + from ._patch import * # type: ignore # pylint: disable=unused-wildcard-import +except ImportError: + _patch_all = [] +from ._patch import patch_sdk as _patch_sdk + +__all__ = ["PolicyClient"] +__all__.extend([p for p in _patch_all if p not in __all__]) + +_patch_sdk() diff --git a/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/policy/v2018_05_01/_configuration.py b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/policy/v2018_05_01/_configuration.py index 1addedffd3f92..af6a7be6cb582 100644 --- a/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/policy/v2018_05_01/_configuration.py +++ b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/policy/v2018_05_01/_configuration.py @@ -25,23 +25,18 @@ class PolicyClientConfiguration(Configuration): # pylint: disable=too-many-inst Note that all parameters used to create this instance are saved as instance attributes. - :param credential: Credential needed for the client to connect to Azure. + :param credential: Credential needed for the client to connect to Azure. Required. :type credential: ~azure.core.credentials.TokenCredential - :param subscription_id: The ID of the target subscription. + :param subscription_id: The ID of the target subscription. Required. :type subscription_id: str :keyword api_version: Api Version. Default value is "2018-05-01". Note that overriding this default value may result in unsupported behavior. :paramtype api_version: str """ - def __init__( - self, - credential: "TokenCredential", - subscription_id: str, - **kwargs: Any - ) -> None: + def __init__(self, credential: "TokenCredential", subscription_id: str, **kwargs: Any) -> None: super(PolicyClientConfiguration, self).__init__(**kwargs) - api_version = kwargs.pop('api_version', "2018-05-01") # type: str + api_version = kwargs.pop("api_version", "2018-05-01") # type: str if credential is None: raise ValueError("Parameter 'credential' must not be None.") @@ -51,23 +46,24 @@ def __init__( self.credential = credential self.subscription_id = subscription_id self.api_version = api_version - self.credential_scopes = kwargs.pop('credential_scopes', ['https://management.azure.com/.default']) - kwargs.setdefault('sdk_moniker', 'mgmt-resource/{}'.format(VERSION)) + self.credential_scopes = kwargs.pop("credential_scopes", ["https://management.azure.com/.default"]) + kwargs.setdefault("sdk_moniker", "mgmt-resource/{}".format(VERSION)) self._configure(**kwargs) def _configure( - self, - **kwargs # type: Any + self, **kwargs # type: Any ): # type: (...) -> 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) - self.logging_policy = kwargs.get('logging_policy') or policies.NetworkTraceLoggingPolicy(**kwargs) - self.http_logging_policy = kwargs.get('http_logging_policy') or ARMHttpLoggingPolicy(**kwargs) - self.retry_policy = kwargs.get('retry_policy') or policies.RetryPolicy(**kwargs) - self.custom_hook_policy = kwargs.get('custom_hook_policy') or policies.CustomHookPolicy(**kwargs) - self.redirect_policy = kwargs.get('redirect_policy') or policies.RedirectPolicy(**kwargs) - self.authentication_policy = kwargs.get('authentication_policy') + 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) + self.logging_policy = kwargs.get("logging_policy") or policies.NetworkTraceLoggingPolicy(**kwargs) + self.http_logging_policy = kwargs.get("http_logging_policy") or ARMHttpLoggingPolicy(**kwargs) + self.retry_policy = kwargs.get("retry_policy") or policies.RetryPolicy(**kwargs) + self.custom_hook_policy = kwargs.get("custom_hook_policy") or policies.CustomHookPolicy(**kwargs) + self.redirect_policy = kwargs.get("redirect_policy") or policies.RedirectPolicy(**kwargs) + self.authentication_policy = kwargs.get("authentication_policy") if self.credential and not self.authentication_policy: - self.authentication_policy = ARMChallengeAuthenticationPolicy(self.credential, *self.credential_scopes, **kwargs) + self.authentication_policy = ARMChallengeAuthenticationPolicy( + self.credential, *self.credential_scopes, **kwargs + ) diff --git a/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/policy/v2018_05_01/_metadata.json b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/policy/v2018_05_01/_metadata.json index 86b17c81c0f6e..0e6b738e994dd 100644 --- a/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/policy/v2018_05_01/_metadata.json +++ b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/policy/v2018_05_01/_metadata.json @@ -10,20 +10,20 @@ "azure_arm": true, "has_lro_operations": false, "client_side_validation": false, - "sync_imports": "{\"typing\": {\"azurecore\": {\"azure.core.credentials\": [\"TokenCredential\"]}}, \"regular\": {\"azurecore\": {\"azure.profiles\": [\"KnownProfiles\", \"ProfileDefinition\"], \"azure.profiles.multiapiclient\": [\"MultiApiClientMixin\"], \"azure.mgmt.core\": [\"ARMPipelineClient\"]}, \"local\": {\"._configuration\": [\"PolicyClientConfiguration\"]}, \"thirdparty\": {\"msrest\": [\"Deserializer\", \"Serializer\"]}}, \"conditional\": {\"stdlib\": {\"typing\": [\"Any\", \"Optional\"]}}}", - "async_imports": "{\"typing\": {\"azurecore\": {\"azure.core.credentials_async\": [\"AsyncTokenCredential\"], \"azure.core.credentials\": [\"TokenCredential\"]}}, \"regular\": {\"azurecore\": {\"azure.profiles\": [\"KnownProfiles\", \"ProfileDefinition\"], \"azure.profiles.multiapiclient\": [\"MultiApiClientMixin\"], \"azure.mgmt.core\": [\"AsyncARMPipelineClient\"]}, \"local\": {\"._configuration\": [\"PolicyClientConfiguration\"]}, \"thirdparty\": {\"msrest\": [\"Deserializer\", \"Serializer\"]}}, \"conditional\": {\"stdlib\": {\"typing\": [\"Any\", \"Optional\"]}}}" + "sync_imports": "{\"conditional\": {\"stdlib\": {\"typing\": [\"Any\", \"Optional\"]}}, \"regular\": {\"azurecore\": {\"azure.mgmt.core\": [\"ARMPipelineClient\"], \"azure.profiles\": [\"KnownProfiles\", \"ProfileDefinition\"], \"azure.profiles.multiapiclient\": [\"MultiApiClientMixin\"]}, \"local\": {\"._configuration\": [\"PolicyClientConfiguration\"], \".._serialization\": [\"Deserializer\", \"Serializer\"]}}, \"typing\": {\"azurecore\": {\"azure.core.credentials\": [\"TokenCredential\"]}}}", + "async_imports": "{\"conditional\": {\"stdlib\": {\"typing\": [\"Any\", \"Optional\"]}}, \"regular\": {\"azurecore\": {\"azure.mgmt.core\": [\"AsyncARMPipelineClient\"], \"azure.profiles\": [\"KnownProfiles\", \"ProfileDefinition\"], \"azure.profiles.multiapiclient\": [\"MultiApiClientMixin\"]}, \"local\": {\"._configuration\": [\"PolicyClientConfiguration\"], \"..._serialization\": [\"Deserializer\", \"Serializer\"]}}, \"typing\": {\"azurecore\": {\"azure.core.credentials_async\": [\"AsyncTokenCredential\"]}}}" }, "global_parameters": { "sync": { "credential": { - "signature": "credential, # type: \"TokenCredential\"", - "description": "Credential needed for the client to connect to Azure.", + "signature": "credential: \"TokenCredential\",", + "description": "Credential needed for the client to connect to Azure. Required.", "docstring_type": "~azure.core.credentials.TokenCredential", "required": true }, "subscription_id": { - "signature": "subscription_id, # type: str", - "description": "The ID of the target subscription.", + "signature": "subscription_id: str,", + "description": "The ID of the target subscription. Required.", "docstring_type": "str", "required": true } @@ -31,13 +31,13 @@ "async": { "credential": { "signature": "credential: \"AsyncTokenCredential\",", - "description": "Credential needed for the client to connect to Azure.", + "description": "Credential needed for the client to connect to Azure. Required.", "docstring_type": "~azure.core.credentials_async.AsyncTokenCredential", "required": true }, "subscription_id": { "signature": "subscription_id: str,", - "description": "The ID of the target subscription.", + "description": "The ID of the target subscription. Required.", "docstring_type": "str", "required": true } @@ -54,7 +54,7 @@ "required": false }, "base_url": { - "signature": "base_url=\"https://management.azure.com\", # type: str", + "signature": "base_url: str = \"https://management.azure.com\",", "description": "Service URL", "docstring_type": "str", "required": false diff --git a/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/policy/v2018_05_01/_patch.py b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/policy/v2018_05_01/_patch.py index 74e48ecd07cf3..f99e77fef9861 100644 --- a/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/policy/v2018_05_01/_patch.py +++ b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/policy/v2018_05_01/_patch.py @@ -28,4 +28,4 @@ # This file is used for handwritten extensions to the generated code. Example: # https://github.com/Azure/azure-sdk-for-python/blob/main/doc/dev/customize_code/how-to-patch-sdk-code.md def patch_sdk(): - pass \ No newline at end of file + pass diff --git a/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/policy/v2018_05_01/_policy_client.py b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/policy/v2018_05_01/_policy_client.py index 5a49cc3080ca4..badcdad753758 100644 --- a/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/policy/v2018_05_01/_policy_client.py +++ b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/policy/v2018_05_01/_policy_client.py @@ -9,12 +9,11 @@ from copy import deepcopy from typing import Any, TYPE_CHECKING -from msrest import Deserializer, Serializer - from azure.core.rest import HttpRequest, HttpResponse from azure.mgmt.core import ARMPipelineClient from . import models +from .._serialization import Deserializer, Serializer from ._configuration import PolicyClientConfiguration from .operations import PolicyAssignmentsOperations, PolicyDefinitionsOperations, PolicySetDefinitionsOperations @@ -22,7 +21,8 @@ # pylint: disable=unused-import,ungrouped-imports from azure.core.credentials import TokenCredential -class PolicyClient: + +class PolicyClient: # pylint: disable=client-accepts-api-version-keyword """To manage and control access to your resources, you can define customized policies and assign them at a scope. @@ -35,9 +35,9 @@ class PolicyClient: :ivar policy_set_definitions: PolicySetDefinitionsOperations operations :vartype policy_set_definitions: azure.mgmt.resource.policy.v2018_05_01.operations.PolicySetDefinitionsOperations - :param credential: Credential needed for the client to connect to Azure. + :param credential: Credential needed for the client to connect to Azure. Required. :type credential: ~azure.core.credentials.TokenCredential - :param subscription_id: The ID of the target subscription. + :param subscription_id: The ID of the target subscription. Required. :type subscription_id: str :param base_url: Service URL. Default value is "https://management.azure.com". :type base_url: str @@ -60,16 +60,17 @@ def __init__( self._serialize = Serializer(client_models) self._deserialize = Deserializer(client_models) self._serialize.client_side_validation = False - self.policy_assignments = PolicyAssignmentsOperations(self._client, self._config, self._serialize, self._deserialize) - self.policy_definitions = PolicyDefinitionsOperations(self._client, self._config, self._serialize, self._deserialize) - self.policy_set_definitions = PolicySetDefinitionsOperations(self._client, self._config, self._serialize, self._deserialize) - - - def _send_request( - self, - request: HttpRequest, - **kwargs: Any - ) -> HttpResponse: + self.policy_assignments = PolicyAssignmentsOperations( + self._client, self._config, self._serialize, self._deserialize + ) + self.policy_definitions = PolicyDefinitionsOperations( + self._client, self._config, self._serialize, self._deserialize + ) + self.policy_set_definitions = PolicySetDefinitionsOperations( + self._client, self._config, self._serialize, self._deserialize + ) + + def _send_request(self, request: HttpRequest, **kwargs: Any) -> HttpResponse: """Runs the network request through the client's chained policies. >>> from azure.core.rest import HttpRequest @@ -78,7 +79,7 @@ def _send_request( >>> response = client._send_request(request) - For more information on this code flow, see https://aka.ms/azsdk/python/protocol/quickstart + For more information on this code flow, see https://aka.ms/azsdk/dpcodegen/python/send_request :param request: The network request you want to make. Required. :type request: ~azure.core.rest.HttpRequest diff --git a/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/policy/v2018_05_01/_vendor.py b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/policy/v2018_05_01/_vendor.py index 138f663c53a4e..9aad73fc743e7 100644 --- a/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/policy/v2018_05_01/_vendor.py +++ b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/policy/v2018_05_01/_vendor.py @@ -7,6 +7,7 @@ from azure.core.pipeline.transport import HttpRequest + def _convert_request(request, files=None): data = request.content if not files else None request = HttpRequest(method=request.method, url=request.url, headers=request.headers, data=data) @@ -14,6 +15,7 @@ def _convert_request(request, files=None): request.set_formdata_body(files) return request + def _format_url_section(template, **kwargs): components = template.split("/") while components: @@ -21,7 +23,5 @@ def _format_url_section(template, **kwargs): 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 - ] + components = [c for c in formatted_components if "{}".format(key.args[0]) not in c] template = "/".join(components) diff --git a/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/policy/v2018_05_01/_version.py b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/policy/v2018_05_01/_version.py index a012ac01c480c..e5754a47ce68f 100644 --- a/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/policy/v2018_05_01/_version.py +++ b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/policy/v2018_05_01/_version.py @@ -6,4 +6,4 @@ # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -VERSION = "21.1.0" +VERSION = "1.0.0b1" diff --git a/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/policy/v2018_05_01/aio/__init__.py b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/policy/v2018_05_01/aio/__init__.py index 2784ce3f14bf5..4622bf1f396a7 100644 --- a/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/policy/v2018_05_01/aio/__init__.py +++ b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/policy/v2018_05_01/aio/__init__.py @@ -7,9 +7,15 @@ # -------------------------------------------------------------------------- from ._policy_client import PolicyClient -__all__ = ['PolicyClient'] -# `._patch.py` is used for handwritten extensions to the generated code -# Example: https://github.com/Azure/azure-sdk-for-python/blob/main/doc/dev/customize_code/how-to-patch-sdk-code.md -from ._patch import patch_sdk -patch_sdk() +try: + from ._patch import __all__ as _patch_all + from ._patch import * # type: ignore # pylint: disable=unused-wildcard-import +except ImportError: + _patch_all = [] +from ._patch import patch_sdk as _patch_sdk + +__all__ = ["PolicyClient"] +__all__.extend([p for p in _patch_all if p not in __all__]) + +_patch_sdk() diff --git a/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/policy/v2018_05_01/aio/_configuration.py b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/policy/v2018_05_01/aio/_configuration.py index 39d0cee00f8f8..765d8a04d0e0a 100644 --- a/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/policy/v2018_05_01/aio/_configuration.py +++ b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/policy/v2018_05_01/aio/_configuration.py @@ -25,23 +25,18 @@ class PolicyClientConfiguration(Configuration): # pylint: disable=too-many-inst Note that all parameters used to create this instance are saved as instance attributes. - :param credential: Credential needed for the client to connect to Azure. + :param credential: Credential needed for the client to connect to Azure. Required. :type credential: ~azure.core.credentials_async.AsyncTokenCredential - :param subscription_id: The ID of the target subscription. + :param subscription_id: The ID of the target subscription. Required. :type subscription_id: str :keyword api_version: Api Version. Default value is "2018-05-01". Note that overriding this default value may result in unsupported behavior. :paramtype api_version: str """ - def __init__( - self, - credential: "AsyncTokenCredential", - subscription_id: str, - **kwargs: Any - ) -> None: + def __init__(self, credential: "AsyncTokenCredential", subscription_id: str, **kwargs: Any) -> None: super(PolicyClientConfiguration, self).__init__(**kwargs) - api_version = kwargs.pop('api_version', "2018-05-01") # type: str + api_version = kwargs.pop("api_version", "2018-05-01") # type: str if credential is None: raise ValueError("Parameter 'credential' must not be None.") @@ -51,22 +46,21 @@ def __init__( self.credential = credential self.subscription_id = subscription_id self.api_version = api_version - self.credential_scopes = kwargs.pop('credential_scopes', ['https://management.azure.com/.default']) - kwargs.setdefault('sdk_moniker', 'mgmt-resource/{}'.format(VERSION)) + self.credential_scopes = kwargs.pop("credential_scopes", ["https://management.azure.com/.default"]) + kwargs.setdefault("sdk_moniker", "mgmt-resource/{}".format(VERSION)) self._configure(**kwargs) - 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) - self.logging_policy = kwargs.get('logging_policy') or policies.NetworkTraceLoggingPolicy(**kwargs) - self.http_logging_policy = kwargs.get('http_logging_policy') or ARMHttpLoggingPolicy(**kwargs) - self.retry_policy = kwargs.get('retry_policy') or policies.AsyncRetryPolicy(**kwargs) - self.custom_hook_policy = kwargs.get('custom_hook_policy') or policies.CustomHookPolicy(**kwargs) - self.redirect_policy = kwargs.get('redirect_policy') or policies.AsyncRedirectPolicy(**kwargs) - self.authentication_policy = kwargs.get('authentication_policy') + 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) + self.logging_policy = kwargs.get("logging_policy") or policies.NetworkTraceLoggingPolicy(**kwargs) + self.http_logging_policy = kwargs.get("http_logging_policy") or ARMHttpLoggingPolicy(**kwargs) + self.retry_policy = kwargs.get("retry_policy") or policies.AsyncRetryPolicy(**kwargs) + self.custom_hook_policy = kwargs.get("custom_hook_policy") or policies.CustomHookPolicy(**kwargs) + self.redirect_policy = kwargs.get("redirect_policy") or policies.AsyncRedirectPolicy(**kwargs) + self.authentication_policy = kwargs.get("authentication_policy") if self.credential and not self.authentication_policy: - self.authentication_policy = AsyncARMChallengeAuthenticationPolicy(self.credential, *self.credential_scopes, **kwargs) + self.authentication_policy = AsyncARMChallengeAuthenticationPolicy( + self.credential, *self.credential_scopes, **kwargs + ) diff --git a/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/policy/v2018_05_01/aio/_patch.py b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/policy/v2018_05_01/aio/_patch.py index 74e48ecd07cf3..f99e77fef9861 100644 --- a/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/policy/v2018_05_01/aio/_patch.py +++ b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/policy/v2018_05_01/aio/_patch.py @@ -28,4 +28,4 @@ # This file is used for handwritten extensions to the generated code. Example: # https://github.com/Azure/azure-sdk-for-python/blob/main/doc/dev/customize_code/how-to-patch-sdk-code.md def patch_sdk(): - pass \ No newline at end of file + pass diff --git a/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/policy/v2018_05_01/aio/_policy_client.py b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/policy/v2018_05_01/aio/_policy_client.py index 22d899193d94d..5b11f4dc652b0 100644 --- a/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/policy/v2018_05_01/aio/_policy_client.py +++ b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/policy/v2018_05_01/aio/_policy_client.py @@ -9,12 +9,11 @@ from copy import deepcopy from typing import Any, Awaitable, TYPE_CHECKING -from msrest import Deserializer, Serializer - from azure.core.rest import AsyncHttpResponse, HttpRequest from azure.mgmt.core import AsyncARMPipelineClient from .. import models +from ..._serialization import Deserializer, Serializer from ._configuration import PolicyClientConfiguration from .operations import PolicyAssignmentsOperations, PolicyDefinitionsOperations, PolicySetDefinitionsOperations @@ -22,7 +21,8 @@ # pylint: disable=unused-import,ungrouped-imports from azure.core.credentials_async import AsyncTokenCredential -class PolicyClient: + +class PolicyClient: # pylint: disable=client-accepts-api-version-keyword """To manage and control access to your resources, you can define customized policies and assign them at a scope. @@ -35,9 +35,9 @@ class PolicyClient: :ivar policy_set_definitions: PolicySetDefinitionsOperations operations :vartype policy_set_definitions: azure.mgmt.resource.policy.v2018_05_01.aio.operations.PolicySetDefinitionsOperations - :param credential: Credential needed for the client to connect to Azure. + :param credential: Credential needed for the client to connect to Azure. Required. :type credential: ~azure.core.credentials_async.AsyncTokenCredential - :param subscription_id: The ID of the target subscription. + :param subscription_id: The ID of the target subscription. Required. :type subscription_id: str :param base_url: Service URL. Default value is "https://management.azure.com". :type base_url: str @@ -60,16 +60,17 @@ def __init__( self._serialize = Serializer(client_models) self._deserialize = Deserializer(client_models) self._serialize.client_side_validation = False - self.policy_assignments = PolicyAssignmentsOperations(self._client, self._config, self._serialize, self._deserialize) - self.policy_definitions = PolicyDefinitionsOperations(self._client, self._config, self._serialize, self._deserialize) - self.policy_set_definitions = PolicySetDefinitionsOperations(self._client, self._config, self._serialize, self._deserialize) - - - def _send_request( - self, - request: HttpRequest, - **kwargs: Any - ) -> Awaitable[AsyncHttpResponse]: + self.policy_assignments = PolicyAssignmentsOperations( + self._client, self._config, self._serialize, self._deserialize + ) + self.policy_definitions = PolicyDefinitionsOperations( + self._client, self._config, self._serialize, self._deserialize + ) + self.policy_set_definitions = PolicySetDefinitionsOperations( + self._client, self._config, self._serialize, self._deserialize + ) + + def _send_request(self, request: HttpRequest, **kwargs: Any) -> Awaitable[AsyncHttpResponse]: """Runs the network request through the client's chained policies. >>> from azure.core.rest import HttpRequest @@ -78,7 +79,7 @@ def _send_request( >>> response = await client._send_request(request) - For more information on this code flow, see https://aka.ms/azsdk/python/protocol/quickstart + For more information on this code flow, see https://aka.ms/azsdk/dpcodegen/python/send_request :param request: The network request you want to make. Required. :type request: ~azure.core.rest.HttpRequest diff --git a/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/policy/v2018_05_01/aio/operations/__init__.py b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/policy/v2018_05_01/aio/operations/__init__.py index b2ae6190b03fb..4e1971e3e3247 100644 --- a/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/policy/v2018_05_01/aio/operations/__init__.py +++ b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/policy/v2018_05_01/aio/operations/__init__.py @@ -10,8 +10,14 @@ from ._operations import PolicyDefinitionsOperations from ._operations import PolicySetDefinitionsOperations +from ._patch import __all__ as _patch_all +from ._patch import * # type: ignore # pylint: disable=unused-wildcard-import +from ._patch import patch_sdk as _patch_sdk + __all__ = [ - 'PolicyAssignmentsOperations', - 'PolicyDefinitionsOperations', - 'PolicySetDefinitionsOperations', + "PolicyAssignmentsOperations", + "PolicyDefinitionsOperations", + "PolicySetDefinitionsOperations", ] +__all__.extend([p for p in _patch_all if p not in __all__]) +_patch_sdk() diff --git a/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/policy/v2018_05_01/aio/operations/_operations.py b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/policy/v2018_05_01/aio/operations/_operations.py index 7e7c7dc62942f..5cf6e4c78ce16 100644 --- a/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/policy/v2018_05_01/aio/operations/_operations.py +++ b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/policy/v2018_05_01/aio/operations/_operations.py @@ -6,52 +6,87 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -from typing import Any, AsyncIterable, Callable, Dict, Optional, TypeVar +from typing import Any, AsyncIterable, Callable, Dict, IO, Optional, TypeVar, Union, overload +from urllib.parse import parse_qs, urljoin, urlparse from azure.core.async_paging import AsyncItemPaged, AsyncList -from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error +from azure.core.exceptions import ( + ClientAuthenticationError, + HttpResponseError, + ResourceExistsError, + ResourceNotFoundError, + ResourceNotModifiedError, + map_error, +) from azure.core.pipeline import PipelineResponse from azure.core.pipeline.transport import AsyncHttpResponse from azure.core.rest import HttpRequest from azure.core.tracing.decorator import distributed_trace from azure.core.tracing.decorator_async import distributed_trace_async +from azure.core.utils import case_insensitive_dict from azure.mgmt.core.exceptions import ARMErrorFormat from ... import models as _models from ..._vendor import _convert_request -from ...operations._operations import build_policy_assignments_create_by_id_request, build_policy_assignments_create_request, build_policy_assignments_delete_by_id_request, build_policy_assignments_delete_request, build_policy_assignments_get_by_id_request, build_policy_assignments_get_request, build_policy_assignments_list_for_resource_group_request, build_policy_assignments_list_for_resource_request, build_policy_assignments_list_request, build_policy_definitions_create_or_update_at_management_group_request, build_policy_definitions_create_or_update_request, build_policy_definitions_delete_at_management_group_request, build_policy_definitions_delete_request, build_policy_definitions_get_at_management_group_request, build_policy_definitions_get_built_in_request, build_policy_definitions_get_request, build_policy_definitions_list_built_in_request, build_policy_definitions_list_by_management_group_request, build_policy_definitions_list_request, build_policy_set_definitions_create_or_update_at_management_group_request, build_policy_set_definitions_create_or_update_request, build_policy_set_definitions_delete_at_management_group_request, build_policy_set_definitions_delete_request, build_policy_set_definitions_get_at_management_group_request, build_policy_set_definitions_get_built_in_request, build_policy_set_definitions_get_request, build_policy_set_definitions_list_built_in_request, build_policy_set_definitions_list_by_management_group_request, build_policy_set_definitions_list_request -T = TypeVar('T') +from ...operations._operations import ( + build_policy_assignments_create_by_id_request, + build_policy_assignments_create_request, + build_policy_assignments_delete_by_id_request, + build_policy_assignments_delete_request, + build_policy_assignments_get_by_id_request, + build_policy_assignments_get_request, + build_policy_assignments_list_for_resource_group_request, + build_policy_assignments_list_for_resource_request, + build_policy_assignments_list_request, + build_policy_definitions_create_or_update_at_management_group_request, + build_policy_definitions_create_or_update_request, + build_policy_definitions_delete_at_management_group_request, + build_policy_definitions_delete_request, + build_policy_definitions_get_at_management_group_request, + build_policy_definitions_get_built_in_request, + build_policy_definitions_get_request, + build_policy_definitions_list_built_in_request, + build_policy_definitions_list_by_management_group_request, + build_policy_definitions_list_request, + build_policy_set_definitions_create_or_update_at_management_group_request, + build_policy_set_definitions_create_or_update_request, + build_policy_set_definitions_delete_at_management_group_request, + build_policy_set_definitions_delete_request, + build_policy_set_definitions_get_at_management_group_request, + build_policy_set_definitions_get_built_in_request, + build_policy_set_definitions_get_request, + build_policy_set_definitions_list_built_in_request, + build_policy_set_definitions_list_by_management_group_request, + build_policy_set_definitions_list_request, +) + +T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] -class PolicyAssignmentsOperations: - """PolicyAssignmentsOperations async operations. - You should not instantiate this class directly. Instead, you should create a Client instance that - instantiates it for you and attaches it as an attribute. +class PolicyAssignmentsOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. - :ivar models: Alias to model classes used in this operation group. - :type models: ~azure.mgmt.resource.policy.v2018_05_01.models - :param client: Client for service requests. - :param config: Configuration of service client. - :param serializer: An object model serializer. - :param deserializer: An object model deserializer. + Instead, you should access the following operations through + :class:`~azure.mgmt.resource.policy.v2018_05_01.aio.PolicyClient`'s + :attr:`policy_assignments` attribute. """ models = _models - def __init__(self, client, config, serializer, deserializer) -> None: - self._client = client - self._serialize = serializer - self._deserialize = deserializer - self._config = config + def __init__(self, *args, **kwargs) -> None: + input_args = list(args) + self._client = input_args.pop(0) if input_args else kwargs.pop("client") + self._config = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") @distributed_trace_async async def delete( - self, - scope: str, - policy_assignment_name: str, - **kwargs: Any - ) -> Optional["_models.PolicyAssignment"]: + self, scope: str, policy_assignment_name: str, **kwargs: Any + ) -> Optional[_models.PolicyAssignment]: """Deletes a policy assignment. This operation deletes a policy assignment, given its name and the scope it was created in. The @@ -63,37 +98,44 @@ async def delete( '/subscriptions/{subscriptionId}'), resource group (format: '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}', or resource (format: '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{resourceProviderNamespace}/[{parentResourcePath}/]{resourceType}/{resourceName}'. + Required. :type scope: str - :param policy_assignment_name: The name of the policy assignment to delete. + :param policy_assignment_name: The name of the policy assignment to delete. Required. :type policy_assignment_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: PolicyAssignment, or the result of cls(response) + :return: PolicyAssignment or None or the result of cls(response) :rtype: ~azure.mgmt.resource.policy.v2018_05_01.models.PolicyAssignment or None - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType[Optional["_models.PolicyAssignment"]] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) - api_version = kwargs.pop('api_version', "2018-05-01") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2018-05-01")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[Optional[_models.PolicyAssignment]] - request = build_policy_assignments_delete_request( scope=scope, policy_assignment_name=policy_assignment_name, api_version=api_version, - template_url=self.delete.metadata['url'], + template_url=self.delete.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200, 204]: @@ -103,24 +145,25 @@ async def delete( deserialized = None if response.status_code == 200: - deserialized = self._deserialize('PolicyAssignment', pipeline_response) + deserialized = self._deserialize("PolicyAssignment", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - delete.metadata = {'url': "/{scope}/providers/Microsoft.Authorization/policyAssignments/{policyAssignmentName}"} # type: ignore - + delete.metadata = {"url": "/{scope}/providers/Microsoft.Authorization/policyAssignments/{policyAssignmentName}"} # type: ignore - @distributed_trace_async + @overload async def create( self, scope: str, policy_assignment_name: str, - parameters: "_models.PolicyAssignment", + parameters: _models.PolicyAssignment, + *, + content_type: str = "application/json", **kwargs: Any - ) -> "_models.PolicyAssignment": + ) -> _models.PolicyAssignment: """Creates or updates a policy assignment. This operation creates or updates a policy assignment with the given scope and name. Policy @@ -132,26 +175,109 @@ async def create( '/subscriptions/{subscriptionId}'), resource group (format: '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}', or resource (format: '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{resourceProviderNamespace}/[{parentResourcePath}/]{resourceType}/{resourceName}'. + Required. :type scope: str - :param policy_assignment_name: The name of the policy assignment. + :param policy_assignment_name: The name of the policy assignment. Required. :type policy_assignment_name: str - :param parameters: Parameters for the policy assignment. + :param parameters: Parameters for the policy assignment. Required. :type parameters: ~azure.mgmt.resource.policy.v2018_05_01.models.PolicyAssignment + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: PolicyAssignment or the result of cls(response) + :rtype: ~azure.mgmt.resource.policy.v2018_05_01.models.PolicyAssignment + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + async def create( + self, + scope: str, + policy_assignment_name: str, + parameters: IO, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.PolicyAssignment: + """Creates or updates a policy assignment. + + This operation creates or updates a policy assignment with the given scope and name. Policy + assignments apply to all resources contained within their scope. For example, when you assign a + policy at resource group scope, that policy applies to all resources in the group. + + :param scope: The scope of the policy assignment. Valid scopes are: management group (format: + '/providers/Microsoft.Management/managementGroups/{managementGroup}'), subscription (format: + '/subscriptions/{subscriptionId}'), resource group (format: + '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}', or resource (format: + '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{resourceProviderNamespace}/[{parentResourcePath}/]{resourceType}/{resourceName}'. + Required. + :type scope: str + :param policy_assignment_name: The name of the policy assignment. Required. + :type policy_assignment_name: str + :param parameters: Parameters for the policy assignment. Required. + :type parameters: IO + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: PolicyAssignment or the result of cls(response) + :rtype: ~azure.mgmt.resource.policy.v2018_05_01.models.PolicyAssignment + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace_async + async def create( + self, scope: str, policy_assignment_name: str, parameters: Union[_models.PolicyAssignment, IO], **kwargs: Any + ) -> _models.PolicyAssignment: + """Creates or updates a policy assignment. + + This operation creates or updates a policy assignment with the given scope and name. Policy + assignments apply to all resources contained within their scope. For example, when you assign a + policy at resource group scope, that policy applies to all resources in the group. + + :param scope: The scope of the policy assignment. Valid scopes are: management group (format: + '/providers/Microsoft.Management/managementGroups/{managementGroup}'), subscription (format: + '/subscriptions/{subscriptionId}'), resource group (format: + '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}', or resource (format: + '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{resourceProviderNamespace}/[{parentResourcePath}/]{resourceType}/{resourceName}'. + Required. + :type scope: str + :param policy_assignment_name: The name of the policy assignment. Required. + :type policy_assignment_name: str + :param parameters: Parameters for the policy assignment. Is either a model type or a IO type. + Required. + :type parameters: ~azure.mgmt.resource.policy.v2018_05_01.models.PolicyAssignment or IO + :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. + Default value is None. + :paramtype content_type: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: PolicyAssignment, or the result of cls(response) + :return: PolicyAssignment or the result of cls(response) :rtype: ~azure.mgmt.resource.policy.v2018_05_01.models.PolicyAssignment - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.PolicyAssignment"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', "2018-05-01") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + api_version = kwargs.pop("api_version", _params.pop("api-version", "2018-05-01")) # type: str + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.PolicyAssignment] - _json = self._serialize.body(parameters, 'PolicyAssignment') + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(parameters, (IO, bytes)): + _content = parameters + else: + _json = self._serialize.body(parameters, "PolicyAssignment") request = build_policy_assignments_create_request( scope=scope, @@ -159,16 +285,18 @@ async def create( api_version=api_version, content_type=content_type, json=_json, - template_url=self.create.metadata['url'], + content=_content, + template_url=self.create.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [201]: @@ -176,23 +304,17 @@ async def create( error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - deserialized = self._deserialize('PolicyAssignment', pipeline_response) + deserialized = self._deserialize("PolicyAssignment", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - create.metadata = {'url': "/{scope}/providers/Microsoft.Authorization/policyAssignments/{policyAssignmentName}"} # type: ignore - + create.metadata = {"url": "/{scope}/providers/Microsoft.Authorization/policyAssignments/{policyAssignmentName}"} # type: ignore @distributed_trace_async - async def get( - self, - scope: str, - policy_assignment_name: str, - **kwargs: Any - ) -> "_models.PolicyAssignment": + async def get(self, scope: str, policy_assignment_name: str, **kwargs: Any) -> _models.PolicyAssignment: """Retrieves a policy assignment. This operation retrieves a single policy assignment, given its name and the scope it was @@ -203,37 +325,44 @@ async def get( '/subscriptions/{subscriptionId}'), resource group (format: '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}', or resource (format: '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{resourceProviderNamespace}/[{parentResourcePath}/]{resourceType}/{resourceName}'. + Required. :type scope: str - :param policy_assignment_name: The name of the policy assignment to get. + :param policy_assignment_name: The name of the policy assignment to get. Required. :type policy_assignment_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: PolicyAssignment, or the result of cls(response) + :return: PolicyAssignment or the result of cls(response) :rtype: ~azure.mgmt.resource.policy.v2018_05_01.models.PolicyAssignment - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.PolicyAssignment"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + 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', "2018-05-01") # type: str + api_version = kwargs.pop("api_version", _params.pop("api-version", "2018-05-01")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[_models.PolicyAssignment] - request = build_policy_assignments_get_request( scope=scope, policy_assignment_name=policy_assignment_name, api_version=api_version, - template_url=self.get.metadata['url'], + template_url=self.get.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200]: @@ -241,23 +370,19 @@ async def get( error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - deserialized = self._deserialize('PolicyAssignment', pipeline_response) + deserialized = self._deserialize("PolicyAssignment", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - get.metadata = {'url': "/{scope}/providers/Microsoft.Authorization/policyAssignments/{policyAssignmentName}"} # type: ignore - + get.metadata = {"url": "/{scope}/providers/Microsoft.Authorization/policyAssignments/{policyAssignmentName}"} # type: ignore @distributed_trace def list_for_resource_group( - self, - resource_group_name: str, - filter: Optional[str] = None, - **kwargs: Any - ) -> AsyncIterable["_models.PolicyAssignmentListResult"]: + self, resource_group_name: str, filter: Optional[str] = None, **kwargs: Any + ) -> AsyncIterable["_models.PolicyAssignment"]: """Retrieves all policy assignments that apply to a resource group. This operation retrieves the list of all policy assignments associated with the given resource @@ -272,47 +397,55 @@ def list_for_resource_group( assignments of the policy definition whose id is {value} that apply to the resource group. :param resource_group_name: The name of the resource group that contains policy assignments. + Required. :type resource_group_name: str :param filter: The filter to apply on the operation. Valid values for $filter are: 'atScope()' or 'policyDefinitionId eq '{value}''. If $filter is not provided, no filtering is performed. Default value is None. :type filter: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either PolicyAssignmentListResult or the result of - cls(response) + :return: An iterator like instance of either PolicyAssignment or the result of cls(response) :rtype: - ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.resource.policy.v2018_05_01.models.PolicyAssignmentListResult] - :raises: ~azure.core.exceptions.HttpResponseError + ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.resource.policy.v2018_05_01.models.PolicyAssignment] + :raises ~azure.core.exceptions.HttpResponseError: """ - api_version = kwargs.pop('api_version', "2018-05-01") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2018-05-01")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[_models.PolicyAssignmentListResult] - cls = kwargs.pop('cls', None) # type: ClsType["_models.PolicyAssignmentListResult"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) + def prepare_request(next_link=None): if not next_link: - + request = build_policy_assignments_list_for_resource_group_request( resource_group_name=resource_group_name, subscription_id=self._config.subscription_id, - api_version=api_version, filter=filter, - template_url=self.list_for_resource_group.metadata['url'], + api_version=api_version, + template_url=self.list_for_resource_group.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore else: - - request = build_policy_assignments_list_for_resource_group_request( - resource_group_name=resource_group_name, - subscription_id=self._config.subscription_id, - template_url=next_link, - ) + # make call to next link with the client's api-version + _parsed_next_link = urlparse(next_link) + _next_request_params = case_insensitive_dict(parse_qs(_parsed_next_link.query)) + _next_request_params["api-version"] = self._config.api_version + request = HttpRequest("GET", urljoin(next_link, _parsed_next_link.path), params=_next_request_params) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore request.method = "GET" return request @@ -326,10 +459,8 @@ async def extract_data(pipeline_response): async def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) response = pipeline_response.http_response @@ -340,11 +471,9 @@ async def get_next(next_link=None): return pipeline_response + return AsyncItemPaged(get_next, extract_data) - return AsyncItemPaged( - get_next, extract_data - ) - list_for_resource_group.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Authorization/policyAssignments"} # type: ignore + list_for_resource_group.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Authorization/policyAssignments"} # type: ignore @distributed_trace def list_for_resource( @@ -356,7 +485,7 @@ def list_for_resource( resource_name: str, filter: Optional[str] = None, **kwargs: Any - ) -> AsyncIterable["_models.PolicyAssignmentListResult"]: + ) -> AsyncIterable["_models.PolicyAssignment"]: """Retrieves all policy assignments that apply to a resource. This operation retrieves the list of all policy assignments associated with the specified @@ -382,39 +511,47 @@ def list_for_resource( {parentResourcePath} == '', {resourceType} == 'Microsoft.Web/sites', {resourceName} == 'MyWebApp'). - :param resource_group_name: The name of the resource group containing the resource. + :param resource_group_name: The name of the resource group containing the resource. Required. :type resource_group_name: str :param resource_provider_namespace: The namespace of the resource provider. For example, the namespace of a virtual machine is Microsoft.Compute (from Microsoft.Compute/virtualMachines). + Required. :type resource_provider_namespace: str :param parent_resource_path: The parent resource path. Use empty string if there is none. + Required. :type parent_resource_path: str :param resource_type: The resource type name. For example the type name of a web app is 'sites' - (from Microsoft.Web/sites). + (from Microsoft.Web/sites). Required. :type resource_type: str - :param resource_name: The name of the resource. + :param resource_name: The name of the resource. Required. :type resource_name: str :param filter: The filter to apply on the operation. Valid values for $filter are: 'atScope()' or 'policyDefinitionId eq '{value}''. If $filter is not provided, no filtering is performed. Default value is None. :type filter: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either PolicyAssignmentListResult or the result of - cls(response) + :return: An iterator like instance of either PolicyAssignment or the result of cls(response) :rtype: - ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.resource.policy.v2018_05_01.models.PolicyAssignmentListResult] - :raises: ~azure.core.exceptions.HttpResponseError + ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.resource.policy.v2018_05_01.models.PolicyAssignment] + :raises ~azure.core.exceptions.HttpResponseError: """ - api_version = kwargs.pop('api_version', "2018-05-01") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2018-05-01")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[_models.PolicyAssignmentListResult] - cls = kwargs.pop('cls', None) # type: ClsType["_models.PolicyAssignmentListResult"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) + def prepare_request(next_link=None): if not next_link: - + request = build_policy_assignments_list_for_resource_request( resource_group_name=resource_group_name, resource_provider_namespace=resource_provider_namespace, @@ -422,26 +559,23 @@ def prepare_request(next_link=None): resource_type=resource_type, resource_name=resource_name, subscription_id=self._config.subscription_id, - api_version=api_version, filter=filter, - template_url=self.list_for_resource.metadata['url'], + api_version=api_version, + template_url=self.list_for_resource.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore else: - - request = build_policy_assignments_list_for_resource_request( - resource_group_name=resource_group_name, - resource_provider_namespace=resource_provider_namespace, - parent_resource_path=parent_resource_path, - resource_type=resource_type, - resource_name=resource_name, - subscription_id=self._config.subscription_id, - template_url=next_link, - ) + # make call to next link with the client's api-version + _parsed_next_link = urlparse(next_link) + _next_request_params = case_insensitive_dict(parse_qs(_parsed_next_link.query)) + _next_request_params["api-version"] = self._config.api_version + request = HttpRequest("GET", urljoin(next_link, _parsed_next_link.path), params=_next_request_params) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore request.method = "GET" return request @@ -455,10 +589,8 @@ async def extract_data(pipeline_response): async def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) response = pipeline_response.http_response @@ -469,18 +601,12 @@ async def get_next(next_link=None): return pipeline_response + return AsyncItemPaged(get_next, extract_data) - return AsyncItemPaged( - get_next, extract_data - ) - list_for_resource.metadata = {'url': "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{parentResourcePath}/{resourceType}/{resourceName}/providers/Microsoft.Authorization/policyAssignments"} # type: ignore + list_for_resource.metadata = {"url": "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{parentResourcePath}/{resourceType}/{resourceName}/providers/Microsoft.Authorization/policyAssignments"} # type: ignore @distributed_trace - def list( - self, - filter: Optional[str] = None, - **kwargs: Any - ) -> AsyncIterable["_models.PolicyAssignmentListResult"]: + def list(self, filter: Optional[str] = None, **kwargs: Any) -> AsyncIterable["_models.PolicyAssignment"]: """Retrieves all policy assignments that apply to a subscription. This operation retrieves the list of all policy assignments associated with the given @@ -499,39 +625,47 @@ def list( Default value is None. :type filter: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either PolicyAssignmentListResult or the result of - cls(response) + :return: An iterator like instance of either PolicyAssignment or the result of cls(response) :rtype: - ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.resource.policy.v2018_05_01.models.PolicyAssignmentListResult] - :raises: ~azure.core.exceptions.HttpResponseError + ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.resource.policy.v2018_05_01.models.PolicyAssignment] + :raises ~azure.core.exceptions.HttpResponseError: """ - api_version = kwargs.pop('api_version', "2018-05-01") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2018-05-01")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[_models.PolicyAssignmentListResult] - cls = kwargs.pop('cls', None) # type: ClsType["_models.PolicyAssignmentListResult"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) + def prepare_request(next_link=None): if not next_link: - + request = build_policy_assignments_list_request( subscription_id=self._config.subscription_id, - api_version=api_version, filter=filter, - template_url=self.list.metadata['url'], + 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.url = self._client.format_url(request.url) # type: ignore else: - - request = build_policy_assignments_list_request( - subscription_id=self._config.subscription_id, - template_url=next_link, - ) + # make call to next link with the client's api-version + _parsed_next_link = urlparse(next_link) + _next_request_params = case_insensitive_dict(parse_qs(_parsed_next_link.query)) + _next_request_params["api-version"] = self._config.api_version + request = HttpRequest("GET", urljoin(next_link, _parsed_next_link.path), params=_next_request_params) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore request.method = "GET" return request @@ -545,10 +679,8 @@ async def extract_data(pipeline_response): async def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) response = pipeline_response.http_response @@ -559,18 +691,12 @@ async def get_next(next_link=None): return pipeline_response + return AsyncItemPaged(get_next, extract_data) - return AsyncItemPaged( - get_next, extract_data - ) - list.metadata = {'url': "/subscriptions/{subscriptionId}/providers/Microsoft.Authorization/policyAssignments"} # type: ignore + list.metadata = {"url": "/subscriptions/{subscriptionId}/providers/Microsoft.Authorization/policyAssignments"} # type: ignore @distributed_trace_async - async def delete_by_id( - self, - policy_assignment_id: str, - **kwargs: Any - ) -> Optional["_models.PolicyAssignment"]: + async def delete_by_id(self, policy_assignment_id: str, **kwargs: Any) -> Optional[_models.PolicyAssignment]: """Deletes a policy assignment. This operation deletes the policy with the given ID. Policy assignment IDs have this format: @@ -582,35 +708,41 @@ async def delete_by_id( (resource). :param policy_assignment_id: The ID of the policy assignment to delete. Use the format - '{scope}/providers/Microsoft.Authorization/policyAssignments/{policyAssignmentName}'. + '{scope}/providers/Microsoft.Authorization/policyAssignments/{policyAssignmentName}'. Required. :type policy_assignment_id: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: PolicyAssignment, or the result of cls(response) + :return: PolicyAssignment or None or the result of cls(response) :rtype: ~azure.mgmt.resource.policy.v2018_05_01.models.PolicyAssignment or None - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType[Optional["_models.PolicyAssignment"]] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) - api_version = kwargs.pop('api_version', "2018-05-01") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2018-05-01")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[Optional[_models.PolicyAssignment]] - request = build_policy_assignments_delete_by_id_request( policy_assignment_id=policy_assignment_id, api_version=api_version, - template_url=self.delete_by_id.metadata['url'], + template_url=self.delete_by_id.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200, 204]: @@ -620,23 +752,24 @@ async def delete_by_id( deserialized = None if response.status_code == 200: - deserialized = self._deserialize('PolicyAssignment', pipeline_response) + deserialized = self._deserialize("PolicyAssignment", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - delete_by_id.metadata = {'url': "/{policyAssignmentId}"} # type: ignore + delete_by_id.metadata = {"url": "/{policyAssignmentId}"} # type: ignore - - @distributed_trace_async + @overload async def create_by_id( self, policy_assignment_id: str, - parameters: "_models.PolicyAssignment", + parameters: _models.PolicyAssignment, + *, + content_type: str = "application/json", **kwargs: Any - ) -> "_models.PolicyAssignment": + ) -> _models.PolicyAssignment: """Creates or updates a policy assignment. This operation creates or updates the policy assignment with the given ID. Policy assignments @@ -651,41 +784,121 @@ async def create_by_id( '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{resourceProviderNamespace}/[{parentResourcePath}/]{resourceType}/{resourceName}'. :param policy_assignment_id: The ID of the policy assignment to create. Use the format - '{scope}/providers/Microsoft.Authorization/policyAssignments/{policyAssignmentName}'. + '{scope}/providers/Microsoft.Authorization/policyAssignments/{policyAssignmentName}'. Required. :type policy_assignment_id: str - :param parameters: Parameters for policy assignment. + :param parameters: Parameters for policy assignment. Required. :type parameters: ~azure.mgmt.resource.policy.v2018_05_01.models.PolicyAssignment + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: PolicyAssignment or the result of cls(response) + :rtype: ~azure.mgmt.resource.policy.v2018_05_01.models.PolicyAssignment + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + async def create_by_id( + self, policy_assignment_id: str, parameters: IO, *, content_type: str = "application/json", **kwargs: Any + ) -> _models.PolicyAssignment: + """Creates or updates a policy assignment. + + This operation creates or updates the policy assignment with the given ID. Policy assignments + made on a scope apply to all resources contained in that scope. For example, when you assign a + policy to a resource group that policy applies to all resources in the group. Policy assignment + IDs have this format: + '{scope}/providers/Microsoft.Authorization/policyAssignments/{policyAssignmentName}'. Valid + scopes are: management group (format: + '/providers/Microsoft.Management/managementGroups/{managementGroup}'), subscription (format: + '/subscriptions/{subscriptionId}'), resource group (format: + '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}', or resource (format: + '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{resourceProviderNamespace}/[{parentResourcePath}/]{resourceType}/{resourceName}'. + + :param policy_assignment_id: The ID of the policy assignment to create. Use the format + '{scope}/providers/Microsoft.Authorization/policyAssignments/{policyAssignmentName}'. Required. + :type policy_assignment_id: str + :param parameters: Parameters for policy assignment. Required. + :type parameters: IO + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: PolicyAssignment, or the result of cls(response) + :return: PolicyAssignment or the result of cls(response) :rtype: ~azure.mgmt.resource.policy.v2018_05_01.models.PolicyAssignment - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace_async + async def create_by_id( + self, policy_assignment_id: str, parameters: Union[_models.PolicyAssignment, IO], **kwargs: Any + ) -> _models.PolicyAssignment: + """Creates or updates a policy assignment. + + This operation creates or updates the policy assignment with the given ID. Policy assignments + made on a scope apply to all resources contained in that scope. For example, when you assign a + policy to a resource group that policy applies to all resources in the group. Policy assignment + IDs have this format: + '{scope}/providers/Microsoft.Authorization/policyAssignments/{policyAssignmentName}'. Valid + scopes are: management group (format: + '/providers/Microsoft.Management/managementGroups/{managementGroup}'), subscription (format: + '/subscriptions/{subscriptionId}'), resource group (format: + '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}', or resource (format: + '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{resourceProviderNamespace}/[{parentResourcePath}/]{resourceType}/{resourceName}'. + + :param policy_assignment_id: The ID of the policy assignment to create. Use the format + '{scope}/providers/Microsoft.Authorization/policyAssignments/{policyAssignmentName}'. Required. + :type policy_assignment_id: str + :param parameters: Parameters for policy assignment. Is either a model type or a IO type. + Required. + :type parameters: ~azure.mgmt.resource.policy.v2018_05_01.models.PolicyAssignment or IO + :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. + Default value is None. + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: PolicyAssignment or the result of cls(response) + :rtype: ~azure.mgmt.resource.policy.v2018_05_01.models.PolicyAssignment + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.PolicyAssignment"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', "2018-05-01") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + api_version = kwargs.pop("api_version", _params.pop("api-version", "2018-05-01")) # type: str + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.PolicyAssignment] - _json = self._serialize.body(parameters, 'PolicyAssignment') + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(parameters, (IO, bytes)): + _content = parameters + else: + _json = self._serialize.body(parameters, "PolicyAssignment") request = build_policy_assignments_create_by_id_request( policy_assignment_id=policy_assignment_id, api_version=api_version, content_type=content_type, json=_json, - template_url=self.create_by_id.metadata['url'], + content=_content, + template_url=self.create_by_id.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [201]: @@ -693,22 +906,17 @@ async def create_by_id( error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - deserialized = self._deserialize('PolicyAssignment', pipeline_response) + deserialized = self._deserialize("PolicyAssignment", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - create_by_id.metadata = {'url': "/{policyAssignmentId}"} # type: ignore - + create_by_id.metadata = {"url": "/{policyAssignmentId}"} # type: ignore @distributed_trace_async - async def get_by_id( - self, - policy_assignment_id: str, - **kwargs: Any - ) -> "_models.PolicyAssignment": + async def get_by_id(self, policy_assignment_id: str, **kwargs: Any) -> _models.PolicyAssignment: """Retrieves the policy assignment with the given ID. The operation retrieves the policy assignment with the given ID. Policy assignment IDs have @@ -721,35 +929,41 @@ async def get_by_id( '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{resourceProviderNamespace}/[{parentResourcePath}/]{resourceType}/{resourceName}'. :param policy_assignment_id: The ID of the policy assignment to get. Use the format - '{scope}/providers/Microsoft.Authorization/policyAssignments/{policyAssignmentName}'. + '{scope}/providers/Microsoft.Authorization/policyAssignments/{policyAssignmentName}'. Required. :type policy_assignment_id: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: PolicyAssignment, or the result of cls(response) + :return: PolicyAssignment or the result of cls(response) :rtype: ~azure.mgmt.resource.policy.v2018_05_01.models.PolicyAssignment - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.PolicyAssignment"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) - api_version = kwargs.pop('api_version', "2018-05-01") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2018-05-01")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[_models.PolicyAssignment] - request = build_policy_assignments_get_by_id_request( policy_assignment_id=policy_assignment_id, api_version=api_version, - template_url=self.get_by_id.metadata['url'], + template_url=self.get_by_id.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200]: @@ -757,68 +971,128 @@ async def get_by_id( error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - deserialized = self._deserialize('PolicyAssignment', pipeline_response) + deserialized = self._deserialize("PolicyAssignment", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - get_by_id.metadata = {'url': "/{policyAssignmentId}"} # type: ignore + get_by_id.metadata = {"url": "/{policyAssignmentId}"} # type: ignore -class PolicyDefinitionsOperations: - """PolicyDefinitionsOperations async operations. - You should not instantiate this class directly. Instead, you should create a Client instance that - instantiates it for you and attaches it as an attribute. +class PolicyDefinitionsOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. - :ivar models: Alias to model classes used in this operation group. - :type models: ~azure.mgmt.resource.policy.v2018_05_01.models - :param client: Client for service requests. - :param config: Configuration of service client. - :param serializer: An object model serializer. - :param deserializer: An object model deserializer. + Instead, you should access the following operations through + :class:`~azure.mgmt.resource.policy.v2018_05_01.aio.PolicyClient`'s + :attr:`policy_definitions` attribute. """ models = _models - def __init__(self, client, config, serializer, deserializer) -> None: - self._client = client - self._serialize = serializer - self._deserialize = deserializer - self._config = config + def __init__(self, *args, **kwargs) -> None: + input_args = list(args) + self._client = input_args.pop(0) if input_args else kwargs.pop("client") + self._config = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") - @distributed_trace_async + @overload async def create_or_update( self, policy_definition_name: str, - parameters: "_models.PolicyDefinition", + parameters: _models.PolicyDefinition, + *, + content_type: str = "application/json", **kwargs: Any - ) -> "_models.PolicyDefinition": + ) -> _models.PolicyDefinition: """Creates or updates a policy definition in a subscription. This operation creates or updates a policy definition in the given subscription with the given name. - :param policy_definition_name: The name of the policy definition to create. + :param policy_definition_name: The name of the policy definition to create. Required. :type policy_definition_name: str - :param parameters: The policy definition properties. + :param parameters: The policy definition properties. Required. :type parameters: ~azure.mgmt.resource.policy.v2018_05_01.models.PolicyDefinition + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: PolicyDefinition or the result of cls(response) + :rtype: ~azure.mgmt.resource.policy.v2018_05_01.models.PolicyDefinition + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + async def create_or_update( + self, policy_definition_name: str, parameters: IO, *, content_type: str = "application/json", **kwargs: Any + ) -> _models.PolicyDefinition: + """Creates or updates a policy definition in a subscription. + + This operation creates or updates a policy definition in the given subscription with the given + name. + + :param policy_definition_name: The name of the policy definition to create. Required. + :type policy_definition_name: str + :param parameters: The policy definition properties. Required. + :type parameters: IO + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: PolicyDefinition or the result of cls(response) + :rtype: ~azure.mgmt.resource.policy.v2018_05_01.models.PolicyDefinition + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace_async + async def create_or_update( + self, policy_definition_name: str, parameters: Union[_models.PolicyDefinition, IO], **kwargs: Any + ) -> _models.PolicyDefinition: + """Creates or updates a policy definition in a subscription. + + This operation creates or updates a policy definition in the given subscription with the given + name. + + :param policy_definition_name: The name of the policy definition to create. Required. + :type policy_definition_name: str + :param parameters: The policy definition properties. Is either a model type or a IO type. + Required. + :type parameters: ~azure.mgmt.resource.policy.v2018_05_01.models.PolicyDefinition or IO + :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. + Default value is None. + :paramtype content_type: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: PolicyDefinition, or the result of cls(response) + :return: PolicyDefinition or the result of cls(response) :rtype: ~azure.mgmt.resource.policy.v2018_05_01.models.PolicyDefinition - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.PolicyDefinition"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', "2018-05-01") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + api_version = kwargs.pop("api_version", _params.pop("api-version", "2018-05-01")) # type: str + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.PolicyDefinition] - _json = self._serialize.body(parameters, 'PolicyDefinition') + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(parameters, (IO, bytes)): + _content = parameters + else: + _json = self._serialize.body(parameters, "PolicyDefinition") request = build_policy_definitions_create_or_update_request( policy_definition_name=policy_definition_name, @@ -826,72 +1100,77 @@ async def create_or_update( api_version=api_version, content_type=content_type, json=_json, - template_url=self.create_or_update.metadata['url'], + content=_content, + template_url=self.create_or_update.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [201]: map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) - deserialized = self._deserialize('PolicyDefinition', pipeline_response) + deserialized = self._deserialize("PolicyDefinition", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - create_or_update.metadata = {'url': "/subscriptions/{subscriptionId}/providers/Microsoft.Authorization/policyDefinitions/{policyDefinitionName}"} # type: ignore - + create_or_update.metadata = {"url": "/subscriptions/{subscriptionId}/providers/Microsoft.Authorization/policyDefinitions/{policyDefinitionName}"} # type: ignore @distributed_trace_async async def delete( # pylint: disable=inconsistent-return-statements - self, - policy_definition_name: str, - **kwargs: Any + self, policy_definition_name: str, **kwargs: Any ) -> None: """Deletes a policy definition in a subscription. This operation deletes the policy definition in the given subscription with the given name. - :param policy_definition_name: The name of the policy definition to delete. + :param policy_definition_name: The name of the policy definition to delete. Required. :type policy_definition_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: None, or the result of cls(response) + :return: None or the result of cls(response) :rtype: None - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType[None] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + 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', "2018-05-01") # type: str + api_version = kwargs.pop("api_version", _params.pop("api-version", "2018-05-01")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[None] - request = build_policy_definitions_delete_request( policy_definition_name=policy_definition_name, subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.delete.metadata['url'], + template_url=self.delete.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200, 204]: @@ -901,154 +1180,231 @@ async def delete( # pylint: disable=inconsistent-return-statements if cls: return cls(pipeline_response, None, {}) - delete.metadata = {'url': "/subscriptions/{subscriptionId}/providers/Microsoft.Authorization/policyDefinitions/{policyDefinitionName}"} # type: ignore - + delete.metadata = {"url": "/subscriptions/{subscriptionId}/providers/Microsoft.Authorization/policyDefinitions/{policyDefinitionName}"} # type: ignore @distributed_trace_async - async def get( - self, - policy_definition_name: str, - **kwargs: Any - ) -> "_models.PolicyDefinition": + async def get(self, policy_definition_name: str, **kwargs: Any) -> _models.PolicyDefinition: """Retrieves a policy definition in a subscription. This operation retrieves the policy definition in the given subscription with the given name. - :param policy_definition_name: The name of the policy definition to get. + :param policy_definition_name: The name of the policy definition to get. Required. :type policy_definition_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: PolicyDefinition, or the result of cls(response) + :return: PolicyDefinition or the result of cls(response) :rtype: ~azure.mgmt.resource.policy.v2018_05_01.models.PolicyDefinition - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.PolicyDefinition"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + 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', "2018-05-01") # type: str + api_version = kwargs.pop("api_version", _params.pop("api-version", "2018-05-01")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[_models.PolicyDefinition] - request = build_policy_definitions_get_request( policy_definition_name=policy_definition_name, subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.get.metadata['url'], + template_url=self.get.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) - deserialized = self._deserialize('PolicyDefinition', pipeline_response) + deserialized = self._deserialize("PolicyDefinition", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - get.metadata = {'url': "/subscriptions/{subscriptionId}/providers/Microsoft.Authorization/policyDefinitions/{policyDefinitionName}"} # type: ignore - + get.metadata = {"url": "/subscriptions/{subscriptionId}/providers/Microsoft.Authorization/policyDefinitions/{policyDefinitionName}"} # type: ignore @distributed_trace_async - async def get_built_in( - self, - policy_definition_name: str, - **kwargs: Any - ) -> "_models.PolicyDefinition": + async def get_built_in(self, policy_definition_name: str, **kwargs: Any) -> _models.PolicyDefinition: """Retrieves a built-in policy definition. This operation retrieves the built-in policy definition with the given name. - :param policy_definition_name: The name of the built-in policy definition to get. + :param policy_definition_name: The name of the built-in policy definition to get. Required. :type policy_definition_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: PolicyDefinition, or the result of cls(response) + :return: PolicyDefinition or the result of cls(response) :rtype: ~azure.mgmt.resource.policy.v2018_05_01.models.PolicyDefinition - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.PolicyDefinition"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + 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', "2018-05-01") # type: str + api_version = kwargs.pop("api_version", _params.pop("api-version", "2018-05-01")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[_models.PolicyDefinition] - request = build_policy_definitions_get_built_in_request( policy_definition_name=policy_definition_name, api_version=api_version, - template_url=self.get_built_in.metadata['url'], + template_url=self.get_built_in.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) - deserialized = self._deserialize('PolicyDefinition', pipeline_response) + deserialized = self._deserialize("PolicyDefinition", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - get_built_in.metadata = {'url': "/providers/Microsoft.Authorization/policyDefinitions/{policyDefinitionName}"} # type: ignore + get_built_in.metadata = {"url": "/providers/Microsoft.Authorization/policyDefinitions/{policyDefinitionName}"} # type: ignore + @overload + async def create_or_update_at_management_group( + self, + policy_definition_name: str, + management_group_id: str, + parameters: _models.PolicyDefinition, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.PolicyDefinition: + """Creates or updates a policy definition in a management group. + + This operation creates or updates a policy definition in the given management group with the + given name. + + :param policy_definition_name: The name of the policy definition to create. Required. + :type policy_definition_name: str + :param management_group_id: The ID of the management group. Required. + :type management_group_id: str + :param parameters: The policy definition properties. Required. + :type parameters: ~azure.mgmt.resource.policy.v2018_05_01.models.PolicyDefinition + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: PolicyDefinition or the result of cls(response) + :rtype: ~azure.mgmt.resource.policy.v2018_05_01.models.PolicyDefinition + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + async def create_or_update_at_management_group( + self, + policy_definition_name: str, + management_group_id: str, + parameters: IO, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.PolicyDefinition: + """Creates or updates a policy definition in a management group. + + This operation creates or updates a policy definition in the given management group with the + given name. + + :param policy_definition_name: The name of the policy definition to create. Required. + :type policy_definition_name: str + :param management_group_id: The ID of the management group. Required. + :type management_group_id: str + :param parameters: The policy definition properties. Required. + :type parameters: IO + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: PolicyDefinition or the result of cls(response) + :rtype: ~azure.mgmt.resource.policy.v2018_05_01.models.PolicyDefinition + :raises ~azure.core.exceptions.HttpResponseError: + """ @distributed_trace_async async def create_or_update_at_management_group( self, policy_definition_name: str, management_group_id: str, - parameters: "_models.PolicyDefinition", + parameters: Union[_models.PolicyDefinition, IO], **kwargs: Any - ) -> "_models.PolicyDefinition": + ) -> _models.PolicyDefinition: """Creates or updates a policy definition in a management group. This operation creates or updates a policy definition in the given management group with the given name. - :param policy_definition_name: The name of the policy definition to create. + :param policy_definition_name: The name of the policy definition to create. Required. :type policy_definition_name: str - :param management_group_id: The ID of the management group. + :param management_group_id: The ID of the management group. Required. :type management_group_id: str - :param parameters: The policy definition properties. - :type parameters: ~azure.mgmt.resource.policy.v2018_05_01.models.PolicyDefinition + :param parameters: The policy definition properties. Is either a model type or a IO type. + Required. + :type parameters: ~azure.mgmt.resource.policy.v2018_05_01.models.PolicyDefinition or IO + :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. + Default value is None. + :paramtype content_type: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: PolicyDefinition, or the result of cls(response) + :return: PolicyDefinition or the result of cls(response) :rtype: ~azure.mgmt.resource.policy.v2018_05_01.models.PolicyDefinition - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.PolicyDefinition"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', "2018-05-01") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + api_version = kwargs.pop("api_version", _params.pop("api-version", "2018-05-01")) # type: str + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.PolicyDefinition] - _json = self._serialize.body(parameters, 'PolicyDefinition') + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(parameters, (IO, bytes)): + _content = parameters + else: + _json = self._serialize.body(parameters, "PolicyDefinition") request = build_policy_definitions_create_or_update_at_management_group_request( policy_definition_name=policy_definition_name, @@ -1056,75 +1412,79 @@ async def create_or_update_at_management_group( api_version=api_version, content_type=content_type, json=_json, - template_url=self.create_or_update_at_management_group.metadata['url'], + content=_content, + template_url=self.create_or_update_at_management_group.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [201]: map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) - deserialized = self._deserialize('PolicyDefinition', pipeline_response) + deserialized = self._deserialize("PolicyDefinition", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - create_or_update_at_management_group.metadata = {'url': "/providers/Microsoft.Management/managementgroups/{managementGroupId}/providers/Microsoft.Authorization/policyDefinitions/{policyDefinitionName}"} # type: ignore - + create_or_update_at_management_group.metadata = {"url": "/providers/Microsoft.Management/managementgroups/{managementGroupId}/providers/Microsoft.Authorization/policyDefinitions/{policyDefinitionName}"} # type: ignore @distributed_trace_async async def delete_at_management_group( # pylint: disable=inconsistent-return-statements - self, - policy_definition_name: str, - management_group_id: str, - **kwargs: Any + self, policy_definition_name: str, management_group_id: str, **kwargs: Any ) -> None: """Deletes a policy definition in a management group. This operation deletes the policy definition in the given management group with the given name. - :param policy_definition_name: The name of the policy definition to delete. + :param policy_definition_name: The name of the policy definition to delete. Required. :type policy_definition_name: str - :param management_group_id: The ID of the management group. + :param management_group_id: The ID of the management group. Required. :type management_group_id: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: None, or the result of cls(response) + :return: None or the result of cls(response) :rtype: None - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType[None] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) - api_version = kwargs.pop('api_version', "2018-05-01") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2018-05-01")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[None] - request = build_policy_definitions_delete_at_management_group_request( policy_definition_name=policy_definition_name, management_group_id=management_group_id, api_version=api_version, - template_url=self.delete_at_management_group.metadata['url'], + template_url=self.delete_at_management_group.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200, 204]: @@ -1134,111 +1494,117 @@ async def delete_at_management_group( # pylint: disable=inconsistent-return-sta if cls: return cls(pipeline_response, None, {}) - delete_at_management_group.metadata = {'url': "/providers/Microsoft.Management/managementgroups/{managementGroupId}/providers/Microsoft.Authorization/policyDefinitions/{policyDefinitionName}"} # type: ignore - + delete_at_management_group.metadata = {"url": "/providers/Microsoft.Management/managementgroups/{managementGroupId}/providers/Microsoft.Authorization/policyDefinitions/{policyDefinitionName}"} # type: ignore @distributed_trace_async async def get_at_management_group( - self, - policy_definition_name: str, - management_group_id: str, - **kwargs: Any - ) -> "_models.PolicyDefinition": + self, policy_definition_name: str, management_group_id: str, **kwargs: Any + ) -> _models.PolicyDefinition: """Retrieve a policy definition in a management group. This operation retrieves the policy definition in the given management group with the given name. - :param policy_definition_name: The name of the policy definition to get. + :param policy_definition_name: The name of the policy definition to get. Required. :type policy_definition_name: str - :param management_group_id: The ID of the management group. + :param management_group_id: The ID of the management group. Required. :type management_group_id: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: PolicyDefinition, or the result of cls(response) + :return: PolicyDefinition or the result of cls(response) :rtype: ~azure.mgmt.resource.policy.v2018_05_01.models.PolicyDefinition - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.PolicyDefinition"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + 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', "2018-05-01") # type: str + api_version = kwargs.pop("api_version", _params.pop("api-version", "2018-05-01")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[_models.PolicyDefinition] - request = build_policy_definitions_get_at_management_group_request( policy_definition_name=policy_definition_name, management_group_id=management_group_id, api_version=api_version, - template_url=self.get_at_management_group.metadata['url'], + template_url=self.get_at_management_group.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) - deserialized = self._deserialize('PolicyDefinition', pipeline_response) + deserialized = self._deserialize("PolicyDefinition", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - get_at_management_group.metadata = {'url': "/providers/Microsoft.Management/managementgroups/{managementGroupId}/providers/Microsoft.Authorization/policyDefinitions/{policyDefinitionName}"} # type: ignore - + get_at_management_group.metadata = {"url": "/providers/Microsoft.Management/managementgroups/{managementGroupId}/providers/Microsoft.Authorization/policyDefinitions/{policyDefinitionName}"} # type: ignore @distributed_trace - def list( - self, - **kwargs: Any - ) -> AsyncIterable["_models.PolicyDefinitionListResult"]: + def list(self, **kwargs: Any) -> AsyncIterable["_models.PolicyDefinition"]: """Retrieves policy definitions in a subscription. This operation retrieves a list of all the policy definitions in a given subscription. :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either PolicyDefinitionListResult or the result of - cls(response) + :return: An iterator like instance of either PolicyDefinition or the result of cls(response) :rtype: - ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.resource.policy.v2018_05_01.models.PolicyDefinitionListResult] - :raises: ~azure.core.exceptions.HttpResponseError + ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.resource.policy.v2018_05_01.models.PolicyDefinition] + :raises ~azure.core.exceptions.HttpResponseError: """ - api_version = kwargs.pop('api_version', "2018-05-01") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2018-05-01")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[_models.PolicyDefinitionListResult] - cls = kwargs.pop('cls', None) # type: ClsType["_models.PolicyDefinitionListResult"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) + def prepare_request(next_link=None): if not next_link: - + request = build_policy_definitions_list_request( subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.list.metadata['url'], + template_url=self.list.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore else: - - request = build_policy_definitions_list_request( - subscription_id=self._config.subscription_id, - template_url=next_link, - ) + # make call to next link with the client's api-version + _parsed_next_link = urlparse(next_link) + _next_request_params = case_insensitive_dict(parse_qs(_parsed_next_link.query)) + _next_request_params["api-version"] = self._config.api_version + request = HttpRequest("GET", urljoin(next_link, _parsed_next_link.path), params=_next_request_params) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore request.method = "GET" return request @@ -1252,10 +1618,8 @@ async def extract_data(pipeline_response): async def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) response = pipeline_response.http_response @@ -1265,52 +1629,56 @@ async def get_next(next_link=None): return pipeline_response + return AsyncItemPaged(get_next, extract_data) - return AsyncItemPaged( - get_next, extract_data - ) - list.metadata = {'url': "/subscriptions/{subscriptionId}/providers/Microsoft.Authorization/policyDefinitions"} # type: ignore + list.metadata = {"url": "/subscriptions/{subscriptionId}/providers/Microsoft.Authorization/policyDefinitions"} # type: ignore @distributed_trace - def list_built_in( - self, - **kwargs: Any - ) -> AsyncIterable["_models.PolicyDefinitionListResult"]: + def list_built_in(self, **kwargs: Any) -> AsyncIterable["_models.PolicyDefinition"]: """Retrieve built-in policy definitions. This operation retrieves a list of all the built-in policy definitions. :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either PolicyDefinitionListResult or the result of - cls(response) + :return: An iterator like instance of either PolicyDefinition or the result of cls(response) :rtype: - ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.resource.policy.v2018_05_01.models.PolicyDefinitionListResult] - :raises: ~azure.core.exceptions.HttpResponseError + ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.resource.policy.v2018_05_01.models.PolicyDefinition] + :raises ~azure.core.exceptions.HttpResponseError: """ - api_version = kwargs.pop('api_version', "2018-05-01") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2018-05-01")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[_models.PolicyDefinitionListResult] - cls = kwargs.pop('cls', None) # type: ClsType["_models.PolicyDefinitionListResult"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) + def prepare_request(next_link=None): if not next_link: - + request = build_policy_definitions_list_built_in_request( api_version=api_version, - template_url=self.list_built_in.metadata['url'], + template_url=self.list_built_in.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore else: - - request = build_policy_definitions_list_built_in_request( - template_url=next_link, - ) + # make call to next link with the client's api-version + _parsed_next_link = urlparse(next_link) + _next_request_params = case_insensitive_dict(parse_qs(_parsed_next_link.query)) + _next_request_params["api-version"] = self._config.api_version + request = HttpRequest("GET", urljoin(next_link, _parsed_next_link.path), params=_next_request_params) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore request.method = "GET" return request @@ -1324,10 +1692,8 @@ async def extract_data(pipeline_response): async def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) response = pipeline_response.http_response @@ -1337,57 +1703,61 @@ async def get_next(next_link=None): return pipeline_response + return AsyncItemPaged(get_next, extract_data) - return AsyncItemPaged( - get_next, extract_data - ) - list_built_in.metadata = {'url': "/providers/Microsoft.Authorization/policyDefinitions"} # type: ignore + list_built_in.metadata = {"url": "/providers/Microsoft.Authorization/policyDefinitions"} # type: ignore @distributed_trace def list_by_management_group( - self, - management_group_id: str, - **kwargs: Any - ) -> AsyncIterable["_models.PolicyDefinitionListResult"]: + self, management_group_id: str, **kwargs: Any + ) -> AsyncIterable["_models.PolicyDefinition"]: """Retrieve policy definitions in a management group. This operation retrieves a list of all the policy definitions in a given management group. - :param management_group_id: The ID of the management group. + :param management_group_id: The ID of the management group. Required. :type management_group_id: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either PolicyDefinitionListResult or the result of - cls(response) + :return: An iterator like instance of either PolicyDefinition or the result of cls(response) :rtype: - ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.resource.policy.v2018_05_01.models.PolicyDefinitionListResult] - :raises: ~azure.core.exceptions.HttpResponseError + ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.resource.policy.v2018_05_01.models.PolicyDefinition] + :raises ~azure.core.exceptions.HttpResponseError: """ - api_version = kwargs.pop('api_version', "2018-05-01") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2018-05-01")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[_models.PolicyDefinitionListResult] - cls = kwargs.pop('cls', None) # type: ClsType["_models.PolicyDefinitionListResult"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) + def prepare_request(next_link=None): if not next_link: - + request = build_policy_definitions_list_by_management_group_request( management_group_id=management_group_id, api_version=api_version, - template_url=self.list_by_management_group.metadata['url'], + template_url=self.list_by_management_group.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore else: - - request = build_policy_definitions_list_by_management_group_request( - management_group_id=management_group_id, - template_url=next_link, - ) + # make call to next link with the client's api-version + _parsed_next_link = urlparse(next_link) + _next_request_params = case_insensitive_dict(parse_qs(_parsed_next_link.query)) + _next_request_params["api-version"] = self._config.api_version + request = HttpRequest("GET", urljoin(next_link, _parsed_next_link.path), params=_next_request_params) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore request.method = "GET" return request @@ -1401,10 +1771,8 @@ async def extract_data(pipeline_response): async def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) response = pipeline_response.http_response @@ -1414,64 +1782,123 @@ async def get_next(next_link=None): return pipeline_response + return AsyncItemPaged(get_next, extract_data) + + list_by_management_group.metadata = {"url": "/providers/Microsoft.Management/managementgroups/{managementGroupId}/providers/Microsoft.Authorization/policyDefinitions"} # type: ignore - return AsyncItemPaged( - get_next, extract_data - ) - list_by_management_group.metadata = {'url': "/providers/Microsoft.Management/managementgroups/{managementGroupId}/providers/Microsoft.Authorization/policyDefinitions"} # type: ignore -class PolicySetDefinitionsOperations: - """PolicySetDefinitionsOperations async operations. - You should not instantiate this class directly. Instead, you should create a Client instance that - instantiates it for you and attaches it as an attribute. +class PolicySetDefinitionsOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. - :ivar models: Alias to model classes used in this operation group. - :type models: ~azure.mgmt.resource.policy.v2018_05_01.models - :param client: Client for service requests. - :param config: Configuration of service client. - :param serializer: An object model serializer. - :param deserializer: An object model deserializer. + Instead, you should access the following operations through + :class:`~azure.mgmt.resource.policy.v2018_05_01.aio.PolicyClient`'s + :attr:`policy_set_definitions` attribute. """ models = _models - def __init__(self, client, config, serializer, deserializer) -> None: - self._client = client - self._serialize = serializer - self._deserialize = deserializer - self._config = config + def __init__(self, *args, **kwargs) -> None: + input_args = list(args) + self._client = input_args.pop(0) if input_args else kwargs.pop("client") + self._config = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") - @distributed_trace_async + @overload async def create_or_update( self, policy_set_definition_name: str, - parameters: "_models.PolicySetDefinition", + parameters: _models.PolicySetDefinition, + *, + content_type: str = "application/json", **kwargs: Any - ) -> "_models.PolicySetDefinition": + ) -> _models.PolicySetDefinition: """Creates or updates a policy set definition. This operation creates or updates a policy set definition in the given subscription with the given name. - :param policy_set_definition_name: The name of the policy set definition to create. + :param policy_set_definition_name: The name of the policy set definition to create. Required. :type policy_set_definition_name: str - :param parameters: The policy set definition properties. + :param parameters: The policy set definition properties. Required. :type parameters: ~azure.mgmt.resource.policy.v2018_05_01.models.PolicySetDefinition + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: PolicySetDefinition or the result of cls(response) + :rtype: ~azure.mgmt.resource.policy.v2018_05_01.models.PolicySetDefinition + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + async def create_or_update( + self, policy_set_definition_name: str, parameters: IO, *, content_type: str = "application/json", **kwargs: Any + ) -> _models.PolicySetDefinition: + """Creates or updates a policy set definition. + + This operation creates or updates a policy set definition in the given subscription with the + given name. + + :param policy_set_definition_name: The name of the policy set definition to create. Required. + :type policy_set_definition_name: str + :param parameters: The policy set definition properties. Required. + :type parameters: IO + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: PolicySetDefinition, or the result of cls(response) + :return: PolicySetDefinition or the result of cls(response) :rtype: ~azure.mgmt.resource.policy.v2018_05_01.models.PolicySetDefinition - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace_async + async def create_or_update( + self, policy_set_definition_name: str, parameters: Union[_models.PolicySetDefinition, IO], **kwargs: Any + ) -> _models.PolicySetDefinition: + """Creates or updates a policy set definition. + + This operation creates or updates a policy set definition in the given subscription with the + given name. + + :param policy_set_definition_name: The name of the policy set definition to create. Required. + :type policy_set_definition_name: str + :param parameters: The policy set definition properties. Is either a model type or a IO type. + Required. + :type parameters: ~azure.mgmt.resource.policy.v2018_05_01.models.PolicySetDefinition or IO + :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. + Default value is None. + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: PolicySetDefinition or the result of cls(response) + :rtype: ~azure.mgmt.resource.policy.v2018_05_01.models.PolicySetDefinition + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.PolicySetDefinition"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', "2018-05-01") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + api_version = kwargs.pop("api_version", _params.pop("api-version", "2018-05-01")) # type: str + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.PolicySetDefinition] - _json = self._serialize.body(parameters, 'PolicySetDefinition') + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(parameters, (IO, bytes)): + _content = parameters + else: + _json = self._serialize.body(parameters, "PolicySetDefinition") request = build_policy_set_definitions_create_or_update_request( policy_set_definition_name=policy_set_definition_name, @@ -1479,16 +1906,18 @@ async def create_or_update( api_version=api_version, content_type=content_type, json=_json, - template_url=self.create_or_update.metadata['url'], + content=_content, + template_url=self.create_or_update.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200, 201]: @@ -1497,59 +1926,62 @@ async def create_or_update( raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) if response.status_code == 200: - deserialized = self._deserialize('PolicySetDefinition', pipeline_response) + deserialized = self._deserialize("PolicySetDefinition", pipeline_response) if response.status_code == 201: - deserialized = self._deserialize('PolicySetDefinition', pipeline_response) + deserialized = self._deserialize("PolicySetDefinition", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - create_or_update.metadata = {'url': "/subscriptions/{subscriptionId}/providers/Microsoft.Authorization/policySetDefinitions/{policySetDefinitionName}"} # type: ignore - + create_or_update.metadata = {"url": "/subscriptions/{subscriptionId}/providers/Microsoft.Authorization/policySetDefinitions/{policySetDefinitionName}"} # type: ignore @distributed_trace_async async def delete( # pylint: disable=inconsistent-return-statements - self, - policy_set_definition_name: str, - **kwargs: Any + self, policy_set_definition_name: str, **kwargs: Any ) -> None: """Deletes a policy set definition. This operation deletes the policy set definition in the given subscription with the given name. - :param policy_set_definition_name: The name of the policy set definition to delete. + :param policy_set_definition_name: The name of the policy set definition to delete. Required. :type policy_set_definition_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: None, or the result of cls(response) + :return: None or the result of cls(response) :rtype: None - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType[None] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + 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', "2018-05-01") # type: str + api_version = kwargs.pop("api_version", _params.pop("api-version", "2018-05-01")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[None] - request = build_policy_set_definitions_delete_request( policy_set_definition_name=policy_set_definition_name, subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.delete.metadata['url'], + template_url=self.delete.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200, 204]: @@ -1560,50 +1992,51 @@ async def delete( # pylint: disable=inconsistent-return-statements if cls: return cls(pipeline_response, None, {}) - delete.metadata = {'url': "/subscriptions/{subscriptionId}/providers/Microsoft.Authorization/policySetDefinitions/{policySetDefinitionName}"} # type: ignore - + delete.metadata = {"url": "/subscriptions/{subscriptionId}/providers/Microsoft.Authorization/policySetDefinitions/{policySetDefinitionName}"} # type: ignore @distributed_trace_async - async def get( - self, - policy_set_definition_name: str, - **kwargs: Any - ) -> "_models.PolicySetDefinition": + async def get(self, policy_set_definition_name: str, **kwargs: Any) -> _models.PolicySetDefinition: """Retrieves a policy set definition. This operation retrieves the policy set definition in the given subscription with the given name. - :param policy_set_definition_name: The name of the policy set definition to get. + :param policy_set_definition_name: The name of the policy set definition to get. Required. :type policy_set_definition_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: PolicySetDefinition, or the result of cls(response) + :return: PolicySetDefinition or the result of cls(response) :rtype: ~azure.mgmt.resource.policy.v2018_05_01.models.PolicySetDefinition - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.PolicySetDefinition"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) - api_version = kwargs.pop('api_version', "2018-05-01") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2018-05-01")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[_models.PolicySetDefinition] - request = build_policy_set_definitions_get_request( policy_set_definition_name=policy_set_definition_name, subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.get.metadata['url'], + template_url=self.get.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200]: @@ -1611,55 +2044,56 @@ async def get( error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - deserialized = self._deserialize('PolicySetDefinition', pipeline_response) + deserialized = self._deserialize("PolicySetDefinition", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - get.metadata = {'url': "/subscriptions/{subscriptionId}/providers/Microsoft.Authorization/policySetDefinitions/{policySetDefinitionName}"} # type: ignore - + get.metadata = {"url": "/subscriptions/{subscriptionId}/providers/Microsoft.Authorization/policySetDefinitions/{policySetDefinitionName}"} # type: ignore @distributed_trace_async - async def get_built_in( - self, - policy_set_definition_name: str, - **kwargs: Any - ) -> "_models.PolicySetDefinition": + async def get_built_in(self, policy_set_definition_name: str, **kwargs: Any) -> _models.PolicySetDefinition: """Retrieves a built in policy set definition. This operation retrieves the built-in policy set definition with the given name. - :param policy_set_definition_name: The name of the policy set definition to get. + :param policy_set_definition_name: The name of the policy set definition to get. Required. :type policy_set_definition_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: PolicySetDefinition, or the result of cls(response) + :return: PolicySetDefinition or the result of cls(response) :rtype: ~azure.mgmt.resource.policy.v2018_05_01.models.PolicySetDefinition - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.PolicySetDefinition"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + 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', "2018-05-01") # type: str + api_version = kwargs.pop("api_version", _params.pop("api-version", "2018-05-01")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[_models.PolicySetDefinition] - request = build_policy_set_definitions_get_built_in_request( policy_set_definition_name=policy_set_definition_name, api_version=api_version, - template_url=self.get_built_in.metadata['url'], + template_url=self.get_built_in.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200]: @@ -1667,58 +2101,62 @@ async def get_built_in( error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - deserialized = self._deserialize('PolicySetDefinition', pipeline_response) + deserialized = self._deserialize("PolicySetDefinition", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - get_built_in.metadata = {'url': "/providers/Microsoft.Authorization/policySetDefinitions/{policySetDefinitionName}"} # type: ignore - + get_built_in.metadata = {"url": "/providers/Microsoft.Authorization/policySetDefinitions/{policySetDefinitionName}"} # type: ignore @distributed_trace - def list( - self, - **kwargs: Any - ) -> AsyncIterable["_models.PolicySetDefinitionListResult"]: + def list(self, **kwargs: Any) -> AsyncIterable["_models.PolicySetDefinition"]: """Retrieves the policy set definitions for a subscription. This operation retrieves a list of all the policy set definitions in the given subscription. :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either PolicySetDefinitionListResult or the result of - cls(response) + :return: An iterator like instance of either PolicySetDefinition or the result of cls(response) :rtype: - ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.resource.policy.v2018_05_01.models.PolicySetDefinitionListResult] - :raises: ~azure.core.exceptions.HttpResponseError + ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.resource.policy.v2018_05_01.models.PolicySetDefinition] + :raises ~azure.core.exceptions.HttpResponseError: """ - api_version = kwargs.pop('api_version', "2018-05-01") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2018-05-01")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[_models.PolicySetDefinitionListResult] - cls = kwargs.pop('cls', None) # type: ClsType["_models.PolicySetDefinitionListResult"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) + def prepare_request(next_link=None): if not next_link: - + request = build_policy_set_definitions_list_request( subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.list.metadata['url'], + template_url=self.list.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore else: - - request = build_policy_set_definitions_list_request( - subscription_id=self._config.subscription_id, - template_url=next_link, - ) + # make call to next link with the client's api-version + _parsed_next_link = urlparse(next_link) + _next_request_params = case_insensitive_dict(parse_qs(_parsed_next_link.query)) + _next_request_params["api-version"] = self._config.api_version + request = HttpRequest("GET", urljoin(next_link, _parsed_next_link.path), params=_next_request_params) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore request.method = "GET" return request @@ -1732,10 +2170,8 @@ async def extract_data(pipeline_response): async def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) response = pipeline_response.http_response @@ -1746,52 +2182,56 @@ async def get_next(next_link=None): return pipeline_response + return AsyncItemPaged(get_next, extract_data) - return AsyncItemPaged( - get_next, extract_data - ) - list.metadata = {'url': "/subscriptions/{subscriptionId}/providers/Microsoft.Authorization/policySetDefinitions"} # type: ignore + list.metadata = {"url": "/subscriptions/{subscriptionId}/providers/Microsoft.Authorization/policySetDefinitions"} # type: ignore @distributed_trace - def list_built_in( - self, - **kwargs: Any - ) -> AsyncIterable["_models.PolicySetDefinitionListResult"]: + def list_built_in(self, **kwargs: Any) -> AsyncIterable["_models.PolicySetDefinition"]: """Retrieves built-in policy set definitions. This operation retrieves a list of all the built-in policy set definitions. :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either PolicySetDefinitionListResult or the result of - cls(response) + :return: An iterator like instance of either PolicySetDefinition or the result of cls(response) :rtype: - ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.resource.policy.v2018_05_01.models.PolicySetDefinitionListResult] - :raises: ~azure.core.exceptions.HttpResponseError + ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.resource.policy.v2018_05_01.models.PolicySetDefinition] + :raises ~azure.core.exceptions.HttpResponseError: """ - api_version = kwargs.pop('api_version', "2018-05-01") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2018-05-01")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[_models.PolicySetDefinitionListResult] - cls = kwargs.pop('cls', None) # type: ClsType["_models.PolicySetDefinitionListResult"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) + def prepare_request(next_link=None): if not next_link: - + request = build_policy_set_definitions_list_built_in_request( api_version=api_version, - template_url=self.list_built_in.metadata['url'], + template_url=self.list_built_in.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore else: - - request = build_policy_set_definitions_list_built_in_request( - template_url=next_link, - ) + # make call to next link with the client's api-version + _parsed_next_link = urlparse(next_link) + _next_request_params = case_insensitive_dict(parse_qs(_parsed_next_link.query)) + _next_request_params["api-version"] = self._config.api_version + request = HttpRequest("GET", urljoin(next_link, _parsed_next_link.path), params=_next_request_params) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore request.method = "GET" return request @@ -1805,10 +2245,8 @@ async def extract_data(pipeline_response): async def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) response = pipeline_response.http_response @@ -1819,46 +2257,120 @@ async def get_next(next_link=None): return pipeline_response + return AsyncItemPaged(get_next, extract_data) - return AsyncItemPaged( - get_next, extract_data - ) - list_built_in.metadata = {'url': "/providers/Microsoft.Authorization/policySetDefinitions"} # type: ignore + list_built_in.metadata = {"url": "/providers/Microsoft.Authorization/policySetDefinitions"} # type: ignore - @distributed_trace_async + @overload async def create_or_update_at_management_group( self, policy_set_definition_name: str, management_group_id: str, - parameters: "_models.PolicySetDefinition", + parameters: _models.PolicySetDefinition, + *, + content_type: str = "application/json", **kwargs: Any - ) -> "_models.PolicySetDefinition": + ) -> _models.PolicySetDefinition: """Creates or updates a policy set definition. This operation creates or updates a policy set definition in the given management group with the given name. - :param policy_set_definition_name: The name of the policy set definition to create. + :param policy_set_definition_name: The name of the policy set definition to create. Required. :type policy_set_definition_name: str - :param management_group_id: The ID of the management group. + :param management_group_id: The ID of the management group. Required. :type management_group_id: str - :param parameters: The policy set definition properties. + :param parameters: The policy set definition properties. Required. :type parameters: ~azure.mgmt.resource.policy.v2018_05_01.models.PolicySetDefinition + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: PolicySetDefinition, or the result of cls(response) + :return: PolicySetDefinition or the result of cls(response) :rtype: ~azure.mgmt.resource.policy.v2018_05_01.models.PolicySetDefinition - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + async def create_or_update_at_management_group( + self, + policy_set_definition_name: str, + management_group_id: str, + parameters: IO, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.PolicySetDefinition: + """Creates or updates a policy set definition. + + This operation creates or updates a policy set definition in the given management group with + the given name. + + :param policy_set_definition_name: The name of the policy set definition to create. Required. + :type policy_set_definition_name: str + :param management_group_id: The ID of the management group. Required. + :type management_group_id: str + :param parameters: The policy set definition properties. Required. + :type parameters: IO + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: PolicySetDefinition or the result of cls(response) + :rtype: ~azure.mgmt.resource.policy.v2018_05_01.models.PolicySetDefinition + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace_async + async def create_or_update_at_management_group( + self, + policy_set_definition_name: str, + management_group_id: str, + parameters: Union[_models.PolicySetDefinition, IO], + **kwargs: Any + ) -> _models.PolicySetDefinition: + """Creates or updates a policy set definition. + + This operation creates or updates a policy set definition in the given management group with + the given name. + + :param policy_set_definition_name: The name of the policy set definition to create. Required. + :type policy_set_definition_name: str + :param management_group_id: The ID of the management group. Required. + :type management_group_id: str + :param parameters: The policy set definition properties. Is either a model type or a IO type. + Required. + :type parameters: ~azure.mgmt.resource.policy.v2018_05_01.models.PolicySetDefinition or IO + :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. + Default value is None. + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: PolicySetDefinition or the result of cls(response) + :rtype: ~azure.mgmt.resource.policy.v2018_05_01.models.PolicySetDefinition + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.PolicySetDefinition"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', "2018-05-01") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + api_version = kwargs.pop("api_version", _params.pop("api-version", "2018-05-01")) # type: str + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.PolicySetDefinition] - _json = self._serialize.body(parameters, 'PolicySetDefinition') + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(parameters, (IO, bytes)): + _content = parameters + else: + _json = self._serialize.body(parameters, "PolicySetDefinition") request = build_policy_set_definitions_create_or_update_at_management_group_request( policy_set_definition_name=policy_set_definition_name, @@ -1866,16 +2378,18 @@ async def create_or_update_at_management_group( api_version=api_version, content_type=content_type, json=_json, - template_url=self.create_or_update_at_management_group.metadata['url'], + content=_content, + template_url=self.create_or_update_at_management_group.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200, 201]: @@ -1884,63 +2398,65 @@ async def create_or_update_at_management_group( raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) if response.status_code == 200: - deserialized = self._deserialize('PolicySetDefinition', pipeline_response) + deserialized = self._deserialize("PolicySetDefinition", pipeline_response) if response.status_code == 201: - deserialized = self._deserialize('PolicySetDefinition', pipeline_response) + deserialized = self._deserialize("PolicySetDefinition", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - create_or_update_at_management_group.metadata = {'url': "/providers/Microsoft.Management/managementgroups/{managementGroupId}/providers/Microsoft.Authorization/policySetDefinitions/{policySetDefinitionName}"} # type: ignore - + create_or_update_at_management_group.metadata = {"url": "/providers/Microsoft.Management/managementgroups/{managementGroupId}/providers/Microsoft.Authorization/policySetDefinitions/{policySetDefinitionName}"} # type: ignore @distributed_trace_async async def delete_at_management_group( # pylint: disable=inconsistent-return-statements - self, - policy_set_definition_name: str, - management_group_id: str, - **kwargs: Any + self, policy_set_definition_name: str, management_group_id: str, **kwargs: Any ) -> None: """Deletes a policy set definition. This operation deletes the policy set definition in the given management group with the given name. - :param policy_set_definition_name: The name of the policy set definition to delete. + :param policy_set_definition_name: The name of the policy set definition to delete. Required. :type policy_set_definition_name: str - :param management_group_id: The ID of the management group. + :param management_group_id: The ID of the management group. Required. :type management_group_id: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: None, or the result of cls(response) + :return: None or the result of cls(response) :rtype: None - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType[None] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + 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', "2018-05-01") # type: str + api_version = kwargs.pop("api_version", _params.pop("api-version", "2018-05-01")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[None] - request = build_policy_set_definitions_delete_at_management_group_request( policy_set_definition_name=policy_set_definition_name, management_group_id=management_group_id, api_version=api_version, - template_url=self.delete_at_management_group.metadata['url'], + template_url=self.delete_at_management_group.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200, 204]: @@ -1951,53 +2467,55 @@ async def delete_at_management_group( # pylint: disable=inconsistent-return-sta if cls: return cls(pipeline_response, None, {}) - delete_at_management_group.metadata = {'url': "/providers/Microsoft.Management/managementgroups/{managementGroupId}/providers/Microsoft.Authorization/policySetDefinitions/{policySetDefinitionName}"} # type: ignore - + delete_at_management_group.metadata = {"url": "/providers/Microsoft.Management/managementgroups/{managementGroupId}/providers/Microsoft.Authorization/policySetDefinitions/{policySetDefinitionName}"} # type: ignore @distributed_trace_async async def get_at_management_group( - self, - policy_set_definition_name: str, - management_group_id: str, - **kwargs: Any - ) -> "_models.PolicySetDefinition": + self, policy_set_definition_name: str, management_group_id: str, **kwargs: Any + ) -> _models.PolicySetDefinition: """Retrieves a policy set definition. This operation retrieves the policy set definition in the given management group with the given name. - :param policy_set_definition_name: The name of the policy set definition to get. + :param policy_set_definition_name: The name of the policy set definition to get. Required. :type policy_set_definition_name: str - :param management_group_id: The ID of the management group. + :param management_group_id: The ID of the management group. Required. :type management_group_id: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: PolicySetDefinition, or the result of cls(response) + :return: PolicySetDefinition or the result of cls(response) :rtype: ~azure.mgmt.resource.policy.v2018_05_01.models.PolicySetDefinition - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.PolicySetDefinition"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + 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', "2018-05-01") # type: str + api_version = kwargs.pop("api_version", _params.pop("api-version", "2018-05-01")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[_models.PolicySetDefinition] - request = build_policy_set_definitions_get_at_management_group_request( policy_set_definition_name=policy_set_definition_name, management_group_id=management_group_id, api_version=api_version, - template_url=self.get_at_management_group.metadata['url'], + template_url=self.get_at_management_group.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200]: @@ -2005,62 +2523,67 @@ async def get_at_management_group( error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - deserialized = self._deserialize('PolicySetDefinition', pipeline_response) + deserialized = self._deserialize("PolicySetDefinition", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - get_at_management_group.metadata = {'url': "/providers/Microsoft.Management/managementgroups/{managementGroupId}/providers/Microsoft.Authorization/policySetDefinitions/{policySetDefinitionName}"} # type: ignore - + get_at_management_group.metadata = {"url": "/providers/Microsoft.Management/managementgroups/{managementGroupId}/providers/Microsoft.Authorization/policySetDefinitions/{policySetDefinitionName}"} # type: ignore @distributed_trace def list_by_management_group( - self, - management_group_id: str, - **kwargs: Any - ) -> AsyncIterable["_models.PolicySetDefinitionListResult"]: + self, management_group_id: str, **kwargs: Any + ) -> AsyncIterable["_models.PolicySetDefinition"]: """Retrieves all policy set definitions in management group. This operation retrieves a list of all the a policy set definition in the given management group. - :param management_group_id: The ID of the management group. + :param management_group_id: The ID of the management group. Required. :type management_group_id: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either PolicySetDefinitionListResult or the result of - cls(response) + :return: An iterator like instance of either PolicySetDefinition or the result of cls(response) :rtype: - ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.resource.policy.v2018_05_01.models.PolicySetDefinitionListResult] - :raises: ~azure.core.exceptions.HttpResponseError + ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.resource.policy.v2018_05_01.models.PolicySetDefinition] + :raises ~azure.core.exceptions.HttpResponseError: """ - api_version = kwargs.pop('api_version', "2018-05-01") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2018-05-01")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[_models.PolicySetDefinitionListResult] - cls = kwargs.pop('cls', None) # type: ClsType["_models.PolicySetDefinitionListResult"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) + def prepare_request(next_link=None): if not next_link: - + request = build_policy_set_definitions_list_by_management_group_request( management_group_id=management_group_id, api_version=api_version, - template_url=self.list_by_management_group.metadata['url'], + template_url=self.list_by_management_group.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore else: - - request = build_policy_set_definitions_list_by_management_group_request( - management_group_id=management_group_id, - template_url=next_link, - ) + # make call to next link with the client's api-version + _parsed_next_link = urlparse(next_link) + _next_request_params = case_insensitive_dict(parse_qs(_parsed_next_link.query)) + _next_request_params["api-version"] = self._config.api_version + request = HttpRequest("GET", urljoin(next_link, _parsed_next_link.path), params=_next_request_params) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore request.method = "GET" return request @@ -2074,10 +2597,8 @@ async def extract_data(pipeline_response): async def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) response = pipeline_response.http_response @@ -2088,8 +2609,6 @@ async def get_next(next_link=None): return pipeline_response + return AsyncItemPaged(get_next, extract_data) - return AsyncItemPaged( - get_next, extract_data - ) - list_by_management_group.metadata = {'url': "/providers/Microsoft.Management/managementgroups/{managementGroupId}/providers/Microsoft.Authorization/policySetDefinitions"} # type: ignore + list_by_management_group.metadata = {"url": "/providers/Microsoft.Management/managementgroups/{managementGroupId}/providers/Microsoft.Authorization/policySetDefinitions"} # type: ignore diff --git a/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/policy/v2018_05_01/aio/operations/_patch.py b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/policy/v2018_05_01/aio/operations/_patch.py new file mode 100644 index 0000000000000..f7dd32510333d --- /dev/null +++ b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/policy/v2018_05_01/aio/operations/_patch.py @@ -0,0 +1,20 @@ +# ------------------------------------ +# Copyright (c) Microsoft Corporation. +# Licensed under the MIT License. +# ------------------------------------ +"""Customize generated code here. + +Follow our quickstart for examples: https://aka.ms/azsdk/python/dpcodegen/python/customize +""" +from typing import List + +__all__: List[str] = [] # Add all objects you want publicly available to users at this package level + + +def patch_sdk(): + """Do not remove from this file. + + `patch_sdk` is a last resort escape hatch that allows you to do customizations + you can't accomplish using the techniques described in + https://aka.ms/azsdk/python/dpcodegen/python/customize + """ diff --git a/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/policy/v2018_05_01/models/__init__.py b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/policy/v2018_05_01/models/__init__.py index f9bae760a0ce8..fcde4d001ce75 100644 --- a/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/policy/v2018_05_01/models/__init__.py +++ b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/policy/v2018_05_01/models/__init__.py @@ -17,25 +17,27 @@ from ._models_py3 import PolicySetDefinitionListResult from ._models_py3 import PolicySku - -from ._policy_client_enums import ( - PolicyMode, - PolicyType, - ResourceIdentityType, -) +from ._policy_client_enums import PolicyMode +from ._policy_client_enums import PolicyType +from ._policy_client_enums import ResourceIdentityType +from ._patch import __all__ as _patch_all +from ._patch import * # type: ignore # pylint: disable=unused-wildcard-import +from ._patch import patch_sdk as _patch_sdk __all__ = [ - 'ErrorResponse', - 'Identity', - 'PolicyAssignment', - 'PolicyAssignmentListResult', - 'PolicyDefinition', - 'PolicyDefinitionListResult', - 'PolicyDefinitionReference', - 'PolicySetDefinition', - 'PolicySetDefinitionListResult', - 'PolicySku', - 'PolicyMode', - 'PolicyType', - 'ResourceIdentityType', + "ErrorResponse", + "Identity", + "PolicyAssignment", + "PolicyAssignmentListResult", + "PolicyDefinition", + "PolicyDefinitionListResult", + "PolicyDefinitionReference", + "PolicySetDefinition", + "PolicySetDefinitionListResult", + "PolicySku", + "PolicyMode", + "PolicyType", + "ResourceIdentityType", ] +__all__.extend([p for p in _patch_all if p not in __all__]) +_patch_sdk() diff --git a/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/policy/v2018_05_01/models/_models_py3.py b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/policy/v2018_05_01/models/_models_py3.py index a95e2c50c393f..f1323472805ef 100644 --- a/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/policy/v2018_05_01/models/_models_py3.py +++ b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/policy/v2018_05_01/models/_models_py3.py @@ -1,4 +1,5 @@ # coding=utf-8 +# pylint: disable=too-many-lines # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. # Licensed under the MIT License. See License.txt in the project root for license information. @@ -6,15 +7,22 @@ # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -from typing import Any, List, Optional, Union +import sys +from typing import Any, List, Optional, TYPE_CHECKING, Union -from azure.core.exceptions import HttpResponseError -import msrest.serialization +from ... import _serialization -from ._policy_client_enums import * +if TYPE_CHECKING: + # pylint: disable=unused-import,ungrouped-imports + from .. import models as _models +if sys.version_info >= (3, 9): + from collections.abc import MutableMapping +else: + from typing import MutableMapping # type: ignore # pylint: disable=ungrouped-imports +JSON = MutableMapping[str, Any] # pylint: disable=unsubscriptable-object -class ErrorResponse(msrest.serialization.Model): +class ErrorResponse(_serialization.Model): """Error response indicates Azure Resource Manager is not able to process the incoming request. The reason is provided in the error message. :ivar http_status: Http status code. @@ -26,9 +34,9 @@ class ErrorResponse(msrest.serialization.Model): """ _attribute_map = { - 'http_status': {'key': 'httpStatus', 'type': 'str'}, - 'error_code': {'key': 'errorCode', 'type': 'str'}, - 'error_message': {'key': 'errorMessage', 'type': 'str'}, + "http_status": {"key": "httpStatus", "type": "str"}, + "error_code": {"key": "errorCode", "type": "str"}, + "error_message": {"key": "errorMessage", "type": "str"}, } def __init__( @@ -47,13 +55,13 @@ def __init__( :keyword error_message: Error message indicating why the operation failed. :paramtype error_message: str """ - super(ErrorResponse, self).__init__(**kwargs) + super().__init__(**kwargs) self.http_status = http_status self.error_code = error_code self.error_message = error_message -class Identity(msrest.serialization.Model): +class Identity(_serialization.Model): """Identity for the resource. Variables are only populated by the server, and will be ignored when sending a request. @@ -62,38 +70,33 @@ class Identity(msrest.serialization.Model): :vartype principal_id: str :ivar tenant_id: The tenant ID of the resource identity. :vartype tenant_id: str - :ivar type: The identity type. Possible values include: "SystemAssigned", "None". + :ivar type: The identity type. Known values are: "SystemAssigned" and "None". :vartype type: str or ~azure.mgmt.resource.policy.v2018_05_01.models.ResourceIdentityType """ _validation = { - 'principal_id': {'readonly': True}, - 'tenant_id': {'readonly': True}, + "principal_id": {"readonly": True}, + "tenant_id": {"readonly": True}, } _attribute_map = { - 'principal_id': {'key': 'principalId', 'type': 'str'}, - 'tenant_id': {'key': 'tenantId', 'type': 'str'}, - 'type': {'key': 'type', 'type': 'str'}, + "principal_id": {"key": "principalId", "type": "str"}, + "tenant_id": {"key": "tenantId", "type": "str"}, + "type": {"key": "type", "type": "str"}, } - def __init__( - self, - *, - type: Optional[Union[str, "ResourceIdentityType"]] = None, - **kwargs - ): + def __init__(self, *, type: Optional[Union[str, "_models.ResourceIdentityType"]] = None, **kwargs): """ - :keyword type: The identity type. Possible values include: "SystemAssigned", "None". + :keyword type: The identity type. Known values are: "SystemAssigned" and "None". :paramtype type: str or ~azure.mgmt.resource.policy.v2018_05_01.models.ResourceIdentityType """ - super(Identity, self).__init__(**kwargs) + super().__init__(**kwargs) self.principal_id = None self.tenant_id = None self.type = type -class PolicyAssignment(msrest.serialization.Model): +class PolicyAssignment(_serialization.Model): # pylint: disable=too-many-instance-attributes """The policy assignment. Variables are only populated by the server, and will be ignored when sending a request. @@ -121,48 +124,48 @@ class PolicyAssignment(msrest.serialization.Model): :ivar not_scopes: The policy's excluded scopes. :vartype not_scopes: list[str] :ivar parameters: Required if a parameter is used in policy rule. - :vartype parameters: any + :vartype parameters: JSON :ivar description: This message will be part of response in case of policy violation. :vartype description: str :ivar metadata: The policy assignment metadata. - :vartype metadata: any + :vartype metadata: JSON """ _validation = { - 'id': {'readonly': True}, - 'type': {'readonly': True}, - 'name': {'readonly': True}, + "id": {"readonly": True}, + "type": {"readonly": True}, + "name": {"readonly": True}, } _attribute_map = { - 'id': {'key': 'id', 'type': 'str'}, - 'type': {'key': 'type', 'type': 'str'}, - 'name': {'key': 'name', 'type': 'str'}, - 'sku': {'key': 'sku', 'type': 'PolicySku'}, - 'location': {'key': 'location', 'type': 'str'}, - 'identity': {'key': 'identity', 'type': 'Identity'}, - 'display_name': {'key': 'properties.displayName', 'type': 'str'}, - 'policy_definition_id': {'key': 'properties.policyDefinitionId', 'type': 'str'}, - 'scope': {'key': 'properties.scope', 'type': 'str'}, - 'not_scopes': {'key': 'properties.notScopes', 'type': '[str]'}, - 'parameters': {'key': 'properties.parameters', 'type': 'object'}, - 'description': {'key': 'properties.description', 'type': 'str'}, - 'metadata': {'key': 'properties.metadata', 'type': 'object'}, + "id": {"key": "id", "type": "str"}, + "type": {"key": "type", "type": "str"}, + "name": {"key": "name", "type": "str"}, + "sku": {"key": "sku", "type": "PolicySku"}, + "location": {"key": "location", "type": "str"}, + "identity": {"key": "identity", "type": "Identity"}, + "display_name": {"key": "properties.displayName", "type": "str"}, + "policy_definition_id": {"key": "properties.policyDefinitionId", "type": "str"}, + "scope": {"key": "properties.scope", "type": "str"}, + "not_scopes": {"key": "properties.notScopes", "type": "[str]"}, + "parameters": {"key": "properties.parameters", "type": "object"}, + "description": {"key": "properties.description", "type": "str"}, + "metadata": {"key": "properties.metadata", "type": "object"}, } def __init__( self, *, - sku: Optional["PolicySku"] = None, + sku: Optional["_models.PolicySku"] = None, location: Optional[str] = None, - identity: Optional["Identity"] = None, + identity: Optional["_models.Identity"] = None, display_name: Optional[str] = None, policy_definition_id: Optional[str] = None, scope: Optional[str] = None, not_scopes: Optional[List[str]] = None, - parameters: Optional[Any] = None, + parameters: Optional[JSON] = None, description: Optional[str] = None, - metadata: Optional[Any] = None, + metadata: Optional[JSON] = None, **kwargs ): """ @@ -183,13 +186,13 @@ def __init__( :keyword not_scopes: The policy's excluded scopes. :paramtype not_scopes: list[str] :keyword parameters: Required if a parameter is used in policy rule. - :paramtype parameters: any + :paramtype parameters: JSON :keyword description: This message will be part of response in case of policy violation. :paramtype description: str :keyword metadata: The policy assignment metadata. - :paramtype metadata: any + :paramtype metadata: JSON """ - super(PolicyAssignment, self).__init__(**kwargs) + super().__init__(**kwargs) self.id = None self.type = None self.name = None @@ -205,7 +208,7 @@ def __init__( self.metadata = metadata -class PolicyAssignmentListResult(msrest.serialization.Model): +class PolicyAssignmentListResult(_serialization.Model): """List of policy assignments. :ivar value: An array of policy assignments. @@ -215,16 +218,12 @@ class PolicyAssignmentListResult(msrest.serialization.Model): """ _attribute_map = { - 'value': {'key': 'value', 'type': '[PolicyAssignment]'}, - 'next_link': {'key': 'nextLink', 'type': 'str'}, + "value": {"key": "value", "type": "[PolicyAssignment]"}, + "next_link": {"key": "nextLink", "type": "str"}, } def __init__( - self, - *, - value: Optional[List["PolicyAssignment"]] = None, - next_link: Optional[str] = None, - **kwargs + self, *, value: Optional[List["_models.PolicyAssignment"]] = None, next_link: Optional[str] = None, **kwargs ): """ :keyword value: An array of policy assignments. @@ -232,12 +231,12 @@ def __init__( :keyword next_link: The URL to use for getting the next set of results. :paramtype next_link: str """ - super(PolicyAssignmentListResult, self).__init__(**kwargs) + super().__init__(**kwargs) self.value = value self.next_link = next_link -class PolicyDefinition(msrest.serialization.Model): +class PolicyDefinition(_serialization.Model): """The policy definition. Variables are only populated by the server, and will be ignored when sending a request. @@ -249,73 +248,73 @@ class PolicyDefinition(msrest.serialization.Model): :ivar type: The type of the resource (Microsoft.Authorization/policyDefinitions). :vartype type: str :ivar policy_type: The type of policy definition. Possible values are NotSpecified, BuiltIn, - and Custom. Possible values include: "NotSpecified", "BuiltIn", "Custom". + and Custom. Known values are: "NotSpecified", "BuiltIn", and "Custom". :vartype policy_type: str or ~azure.mgmt.resource.policy.v2018_05_01.models.PolicyType :ivar mode: The policy definition mode. Possible values are NotSpecified, Indexed, and All. - Possible values include: "NotSpecified", "Indexed", "All". + Known values are: "NotSpecified", "Indexed", and "All". :vartype mode: str or ~azure.mgmt.resource.policy.v2018_05_01.models.PolicyMode :ivar display_name: The display name of the policy definition. :vartype display_name: str :ivar description: The policy definition description. :vartype description: str :ivar policy_rule: The policy rule. - :vartype policy_rule: any + :vartype policy_rule: JSON :ivar metadata: The policy definition metadata. - :vartype metadata: any + :vartype metadata: JSON :ivar parameters: Required if a parameter is used in policy rule. - :vartype parameters: any + :vartype parameters: JSON """ _validation = { - 'id': {'readonly': True}, - 'name': {'readonly': True}, - 'type': {'readonly': True}, + "id": {"readonly": True}, + "name": {"readonly": True}, + "type": {"readonly": True}, } _attribute_map = { - 'id': {'key': 'id', 'type': 'str'}, - 'name': {'key': 'name', 'type': 'str'}, - 'type': {'key': 'type', 'type': 'str'}, - 'policy_type': {'key': 'properties.policyType', 'type': 'str'}, - 'mode': {'key': 'properties.mode', 'type': 'str'}, - 'display_name': {'key': 'properties.displayName', 'type': 'str'}, - 'description': {'key': 'properties.description', 'type': 'str'}, - 'policy_rule': {'key': 'properties.policyRule', 'type': 'object'}, - 'metadata': {'key': 'properties.metadata', 'type': 'object'}, - 'parameters': {'key': 'properties.parameters', 'type': 'object'}, + "id": {"key": "id", "type": "str"}, + "name": {"key": "name", "type": "str"}, + "type": {"key": "type", "type": "str"}, + "policy_type": {"key": "properties.policyType", "type": "str"}, + "mode": {"key": "properties.mode", "type": "str"}, + "display_name": {"key": "properties.displayName", "type": "str"}, + "description": {"key": "properties.description", "type": "str"}, + "policy_rule": {"key": "properties.policyRule", "type": "object"}, + "metadata": {"key": "properties.metadata", "type": "object"}, + "parameters": {"key": "properties.parameters", "type": "object"}, } def __init__( self, *, - policy_type: Optional[Union[str, "PolicyType"]] = None, - mode: Optional[Union[str, "PolicyMode"]] = None, + policy_type: Optional[Union[str, "_models.PolicyType"]] = None, + mode: Optional[Union[str, "_models.PolicyMode"]] = None, display_name: Optional[str] = None, description: Optional[str] = None, - policy_rule: Optional[Any] = None, - metadata: Optional[Any] = None, - parameters: Optional[Any] = None, + policy_rule: Optional[JSON] = None, + metadata: Optional[JSON] = None, + parameters: Optional[JSON] = None, **kwargs ): """ :keyword policy_type: The type of policy definition. Possible values are NotSpecified, BuiltIn, - and Custom. Possible values include: "NotSpecified", "BuiltIn", "Custom". + and Custom. Known values are: "NotSpecified", "BuiltIn", and "Custom". :paramtype policy_type: str or ~azure.mgmt.resource.policy.v2018_05_01.models.PolicyType :keyword mode: The policy definition mode. Possible values are NotSpecified, Indexed, and All. - Possible values include: "NotSpecified", "Indexed", "All". + Known values are: "NotSpecified", "Indexed", and "All". :paramtype mode: str or ~azure.mgmt.resource.policy.v2018_05_01.models.PolicyMode :keyword display_name: The display name of the policy definition. :paramtype display_name: str :keyword description: The policy definition description. :paramtype description: str :keyword policy_rule: The policy rule. - :paramtype policy_rule: any + :paramtype policy_rule: JSON :keyword metadata: The policy definition metadata. - :paramtype metadata: any + :paramtype metadata: JSON :keyword parameters: Required if a parameter is used in policy rule. - :paramtype parameters: any + :paramtype parameters: JSON """ - super(PolicyDefinition, self).__init__(**kwargs) + super().__init__(**kwargs) self.id = None self.name = None self.type = None @@ -328,7 +327,7 @@ def __init__( self.parameters = parameters -class PolicyDefinitionListResult(msrest.serialization.Model): +class PolicyDefinitionListResult(_serialization.Model): """List of policy definitions. :ivar value: An array of policy definitions. @@ -338,16 +337,12 @@ class PolicyDefinitionListResult(msrest.serialization.Model): """ _attribute_map = { - 'value': {'key': 'value', 'type': '[PolicyDefinition]'}, - 'next_link': {'key': 'nextLink', 'type': 'str'}, + "value": {"key": "value", "type": "[PolicyDefinition]"}, + "next_link": {"key": "nextLink", "type": "str"}, } def __init__( - self, - *, - value: Optional[List["PolicyDefinition"]] = None, - next_link: Optional[str] = None, - **kwargs + self, *, value: Optional[List["_models.PolicyDefinition"]] = None, next_link: Optional[str] = None, **kwargs ): """ :keyword value: An array of policy definitions. @@ -355,44 +350,38 @@ def __init__( :keyword next_link: The URL to use for getting the next set of results. :paramtype next_link: str """ - super(PolicyDefinitionListResult, self).__init__(**kwargs) + super().__init__(**kwargs) self.value = value self.next_link = next_link -class PolicyDefinitionReference(msrest.serialization.Model): +class PolicyDefinitionReference(_serialization.Model): """The policy definition reference. :ivar policy_definition_id: The ID of the policy definition or policy set definition. :vartype policy_definition_id: str :ivar parameters: Required if a parameter is used in policy rule. - :vartype parameters: any + :vartype parameters: JSON """ _attribute_map = { - 'policy_definition_id': {'key': 'policyDefinitionId', 'type': 'str'}, - 'parameters': {'key': 'parameters', 'type': 'object'}, + "policy_definition_id": {"key": "policyDefinitionId", "type": "str"}, + "parameters": {"key": "parameters", "type": "object"}, } - def __init__( - self, - *, - policy_definition_id: Optional[str] = None, - parameters: Optional[Any] = None, - **kwargs - ): + def __init__(self, *, policy_definition_id: Optional[str] = None, parameters: Optional[JSON] = None, **kwargs): """ :keyword policy_definition_id: The ID of the policy definition or policy set definition. :paramtype policy_definition_id: str :keyword parameters: Required if a parameter is used in policy rule. - :paramtype parameters: any + :paramtype parameters: JSON """ - super(PolicyDefinitionReference, self).__init__(**kwargs) + super().__init__(**kwargs) self.policy_definition_id = policy_definition_id self.parameters = parameters -class PolicySetDefinition(msrest.serialization.Model): +class PolicySetDefinition(_serialization.Model): """The policy set definition. Variables are only populated by the server, and will be ignored when sending a request. @@ -404,69 +393,69 @@ class PolicySetDefinition(msrest.serialization.Model): :ivar type: The type of the resource (Microsoft.Authorization/policySetDefinitions). :vartype type: str :ivar policy_type: The type of policy definition. Possible values are NotSpecified, BuiltIn, - and Custom. Possible values include: "NotSpecified", "BuiltIn", "Custom". + and Custom. Known values are: "NotSpecified", "BuiltIn", and "Custom". :vartype policy_type: str or ~azure.mgmt.resource.policy.v2018_05_01.models.PolicyType :ivar display_name: The display name of the policy set definition. :vartype display_name: str :ivar description: The policy set definition description. :vartype description: str :ivar metadata: The policy set definition metadata. - :vartype metadata: any + :vartype metadata: JSON :ivar parameters: The policy set definition parameters that can be used in policy definition references. - :vartype parameters: any + :vartype parameters: JSON :ivar policy_definitions: An array of policy definition references. :vartype policy_definitions: list[~azure.mgmt.resource.policy.v2018_05_01.models.PolicyDefinitionReference] """ _validation = { - 'id': {'readonly': True}, - 'name': {'readonly': True}, - 'type': {'readonly': True}, + "id": {"readonly": True}, + "name": {"readonly": True}, + "type": {"readonly": True}, } _attribute_map = { - 'id': {'key': 'id', 'type': 'str'}, - 'name': {'key': 'name', 'type': 'str'}, - 'type': {'key': 'type', 'type': 'str'}, - 'policy_type': {'key': 'properties.policyType', 'type': 'str'}, - 'display_name': {'key': 'properties.displayName', 'type': 'str'}, - 'description': {'key': 'properties.description', 'type': 'str'}, - 'metadata': {'key': 'properties.metadata', 'type': 'object'}, - 'parameters': {'key': 'properties.parameters', 'type': 'object'}, - 'policy_definitions': {'key': 'properties.policyDefinitions', 'type': '[PolicyDefinitionReference]'}, + "id": {"key": "id", "type": "str"}, + "name": {"key": "name", "type": "str"}, + "type": {"key": "type", "type": "str"}, + "policy_type": {"key": "properties.policyType", "type": "str"}, + "display_name": {"key": "properties.displayName", "type": "str"}, + "description": {"key": "properties.description", "type": "str"}, + "metadata": {"key": "properties.metadata", "type": "object"}, + "parameters": {"key": "properties.parameters", "type": "object"}, + "policy_definitions": {"key": "properties.policyDefinitions", "type": "[PolicyDefinitionReference]"}, } def __init__( self, *, - policy_type: Optional[Union[str, "PolicyType"]] = None, + policy_type: Optional[Union[str, "_models.PolicyType"]] = None, display_name: Optional[str] = None, description: Optional[str] = None, - metadata: Optional[Any] = None, - parameters: Optional[Any] = None, - policy_definitions: Optional[List["PolicyDefinitionReference"]] = None, + metadata: Optional[JSON] = None, + parameters: Optional[JSON] = None, + policy_definitions: Optional[List["_models.PolicyDefinitionReference"]] = None, **kwargs ): """ :keyword policy_type: The type of policy definition. Possible values are NotSpecified, BuiltIn, - and Custom. Possible values include: "NotSpecified", "BuiltIn", "Custom". + and Custom. Known values are: "NotSpecified", "BuiltIn", and "Custom". :paramtype policy_type: str or ~azure.mgmt.resource.policy.v2018_05_01.models.PolicyType :keyword display_name: The display name of the policy set definition. :paramtype display_name: str :keyword description: The policy set definition description. :paramtype description: str :keyword metadata: The policy set definition metadata. - :paramtype metadata: any + :paramtype metadata: JSON :keyword parameters: The policy set definition parameters that can be used in policy definition references. - :paramtype parameters: any + :paramtype parameters: JSON :keyword policy_definitions: An array of policy definition references. :paramtype policy_definitions: list[~azure.mgmt.resource.policy.v2018_05_01.models.PolicyDefinitionReference] """ - super(PolicySetDefinition, self).__init__(**kwargs) + super().__init__(**kwargs) self.id = None self.name = None self.type = None @@ -478,7 +467,7 @@ def __init__( self.policy_definitions = policy_definitions -class PolicySetDefinitionListResult(msrest.serialization.Model): +class PolicySetDefinitionListResult(_serialization.Model): """List of policy set definitions. :ivar value: An array of policy set definitions. @@ -488,16 +477,12 @@ class PolicySetDefinitionListResult(msrest.serialization.Model): """ _attribute_map = { - 'value': {'key': 'value', 'type': '[PolicySetDefinition]'}, - 'next_link': {'key': 'nextLink', 'type': 'str'}, + "value": {"key": "value", "type": "[PolicySetDefinition]"}, + "next_link": {"key": "nextLink", "type": "str"}, } def __init__( - self, - *, - value: Optional[List["PolicySetDefinition"]] = None, - next_link: Optional[str] = None, - **kwargs + self, *, value: Optional[List["_models.PolicySetDefinition"]] = None, next_link: Optional[str] = None, **kwargs ): """ :keyword value: An array of policy set definitions. @@ -505,44 +490,38 @@ def __init__( :keyword next_link: The URL to use for getting the next set of results. :paramtype next_link: str """ - super(PolicySetDefinitionListResult, self).__init__(**kwargs) + super().__init__(**kwargs) self.value = value self.next_link = next_link -class PolicySku(msrest.serialization.Model): +class PolicySku(_serialization.Model): """The policy sku. This property is optional, obsolete, and will be ignored. All required parameters must be populated in order to send to Azure. - :ivar name: Required. The name of the policy sku. Possible values are A0 and A1. + :ivar name: The name of the policy sku. Possible values are A0 and A1. Required. :vartype name: str :ivar tier: The policy sku tier. Possible values are Free and Standard. :vartype tier: str """ _validation = { - 'name': {'required': True}, + "name": {"required": True}, } _attribute_map = { - 'name': {'key': 'name', 'type': 'str'}, - 'tier': {'key': 'tier', 'type': 'str'}, + "name": {"key": "name", "type": "str"}, + "tier": {"key": "tier", "type": "str"}, } - def __init__( - self, - *, - name: str, - tier: Optional[str] = None, - **kwargs - ): + def __init__(self, *, name: str, tier: Optional[str] = None, **kwargs): """ - :keyword name: Required. The name of the policy sku. Possible values are A0 and A1. + :keyword name: The name of the policy sku. Possible values are A0 and A1. Required. :paramtype name: str :keyword tier: The policy sku tier. Possible values are Free and Standard. :paramtype tier: str """ - super(PolicySku, self).__init__(**kwargs) + super().__init__(**kwargs) self.name = name self.tier = tier diff --git a/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/policy/v2018_05_01/models/_patch.py b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/policy/v2018_05_01/models/_patch.py new file mode 100644 index 0000000000000..f7dd32510333d --- /dev/null +++ b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/policy/v2018_05_01/models/_patch.py @@ -0,0 +1,20 @@ +# ------------------------------------ +# Copyright (c) Microsoft Corporation. +# Licensed under the MIT License. +# ------------------------------------ +"""Customize generated code here. + +Follow our quickstart for examples: https://aka.ms/azsdk/python/dpcodegen/python/customize +""" +from typing import List + +__all__: List[str] = [] # Add all objects you want publicly available to users at this package level + + +def patch_sdk(): + """Do not remove from this file. + + `patch_sdk` is a last resort escape hatch that allows you to do customizations + you can't accomplish using the techniques described in + https://aka.ms/azsdk/python/dpcodegen/python/customize + """ diff --git a/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/policy/v2018_05_01/models/_policy_client_enums.py b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/policy/v2018_05_01/models/_policy_client_enums.py index cd821eee59b98..b8dbce1ab7796 100644 --- a/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/policy/v2018_05_01/models/_policy_client_enums.py +++ b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/policy/v2018_05_01/models/_policy_client_enums.py @@ -7,29 +7,27 @@ # -------------------------------------------------------------------------- from enum import Enum -from six import with_metaclass from azure.core import CaseInsensitiveEnumMeta -class PolicyMode(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): - """The policy definition mode. Possible values are NotSpecified, Indexed, and All. - """ +class PolicyMode(str, Enum, metaclass=CaseInsensitiveEnumMeta): + """The policy definition mode. Possible values are NotSpecified, Indexed, and All.""" NOT_SPECIFIED = "NotSpecified" INDEXED = "Indexed" ALL = "All" -class PolicyType(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): - """The type of policy definition. Possible values are NotSpecified, BuiltIn, and Custom. - """ + +class PolicyType(str, Enum, metaclass=CaseInsensitiveEnumMeta): + """The type of policy definition. Possible values are NotSpecified, BuiltIn, and Custom.""" NOT_SPECIFIED = "NotSpecified" BUILT_IN = "BuiltIn" CUSTOM = "Custom" -class ResourceIdentityType(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): - """The identity type. - """ + +class ResourceIdentityType(str, Enum, metaclass=CaseInsensitiveEnumMeta): + """The identity type.""" SYSTEM_ASSIGNED = "SystemAssigned" NONE = "None" diff --git a/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/policy/v2018_05_01/operations/__init__.py b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/policy/v2018_05_01/operations/__init__.py index b2ae6190b03fb..4e1971e3e3247 100644 --- a/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/policy/v2018_05_01/operations/__init__.py +++ b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/policy/v2018_05_01/operations/__init__.py @@ -10,8 +10,14 @@ from ._operations import PolicyDefinitionsOperations from ._operations import PolicySetDefinitionsOperations +from ._patch import __all__ as _patch_all +from ._patch import * # type: ignore # pylint: disable=unused-wildcard-import +from ._patch import patch_sdk as _patch_sdk + __all__ = [ - 'PolicyAssignmentsOperations', - 'PolicyDefinitionsOperations', - 'PolicySetDefinitionsOperations', + "PolicyAssignmentsOperations", + "PolicyDefinitionsOperations", + "PolicySetDefinitionsOperations", ] +__all__.extend([p for p in _patch_all if p not in __all__]) +_patch_sdk() diff --git a/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/policy/v2018_05_01/operations/_operations.py b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/policy/v2018_05_01/operations/_operations.py index b6cf7da6db1d6..4628694fb2120 100644 --- a/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/policy/v2018_05_01/operations/_operations.py +++ b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/policy/v2018_05_01/operations/_operations.py @@ -6,173 +6,152 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -from typing import Any, Callable, Dict, Iterable, Optional, TypeVar - -from msrest import Serializer - -from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error +from typing import Any, Callable, Dict, IO, Iterable, Optional, TypeVar, Union, overload +from urllib.parse import parse_qs, urljoin, urlparse + +from azure.core.exceptions import ( + ClientAuthenticationError, + HttpResponseError, + ResourceExistsError, + ResourceNotFoundError, + ResourceNotModifiedError, + map_error, +) from azure.core.paging import ItemPaged from azure.core.pipeline import PipelineResponse from azure.core.pipeline.transport import HttpResponse from azure.core.rest import HttpRequest from azure.core.tracing.decorator import distributed_trace +from azure.core.utils import case_insensitive_dict from azure.mgmt.core.exceptions import ARMErrorFormat from .. import models as _models +from ..._serialization import Serializer from .._vendor import _convert_request, _format_url_section -T = TypeVar('T') -JSONType = Any + +T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] _SERIALIZER = Serializer() _SERIALIZER.client_side_validation = False -def build_policy_assignments_delete_request( - scope: str, - policy_assignment_name: str, - **kwargs: Any -) -> HttpRequest: - api_version = kwargs.pop('api_version', "2018-05-01") # type: str - accept = "application/json" +def build_policy_assignments_delete_request(scope: str, policy_assignment_name: 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", "2018-05-01")) # type: str + accept = _headers.pop("Accept", "application/json") + # Construct URL - _url = kwargs.pop("template_url", "/{scope}/providers/Microsoft.Authorization/policyAssignments/{policyAssignmentName}") + _url = kwargs.pop( + "template_url", "/{scope}/providers/Microsoft.Authorization/policyAssignments/{policyAssignmentName}" + ) path_format_arguments = { - "scope": _SERIALIZER.url("scope", scope, 'str', skip_quote=True), - "policyAssignmentName": _SERIALIZER.url("policy_assignment_name", policy_assignment_name, 'str'), + "scope": _SERIALIZER.url("scope", scope, "str", skip_quote=True), + "policyAssignmentName": _SERIALIZER.url("policy_assignment_name", policy_assignment_name, "str"), } _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') - - return HttpRequest( - method="DELETE", - url=_url, - params=_query_parameters, - headers=_header_parameters, - **kwargs - ) + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + return HttpRequest(method="DELETE", url=_url, params=_params, headers=_headers, **kwargs) -def build_policy_assignments_create_request( - scope: str, - policy_assignment_name: str, - *, - json: JSONType = None, - content: Any = None, - **kwargs: Any -) -> HttpRequest: - api_version = kwargs.pop('api_version', "2018-05-01") # type: str - content_type = kwargs.pop('content_type', None) # type: Optional[str] - accept = "application/json" +def build_policy_assignments_create_request(scope: str, policy_assignment_name: 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", "2018-05-01")) # type: str + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + accept = _headers.pop("Accept", "application/json") + # Construct URL - _url = kwargs.pop("template_url", "/{scope}/providers/Microsoft.Authorization/policyAssignments/{policyAssignmentName}") + _url = kwargs.pop( + "template_url", "/{scope}/providers/Microsoft.Authorization/policyAssignments/{policyAssignmentName}" + ) path_format_arguments = { - "scope": _SERIALIZER.url("scope", scope, 'str', skip_quote=True), - "policyAssignmentName": _SERIALIZER.url("policy_assignment_name", policy_assignment_name, 'str'), + "scope": _SERIALIZER.url("scope", scope, "str", skip_quote=True), + "policyAssignmentName": _SERIALIZER.url("policy_assignment_name", policy_assignment_name, "str"), } _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] if content_type is not None: - _header_parameters['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') - _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') - - return HttpRequest( - method="PUT", - url=_url, - params=_query_parameters, - headers=_header_parameters, - json=json, - content=content, - **kwargs - ) + _headers["Content-Type"] = _SERIALIZER.header("content_type", content_type, "str") + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + return HttpRequest(method="PUT", url=_url, params=_params, headers=_headers, **kwargs) -def build_policy_assignments_get_request( - scope: str, - policy_assignment_name: str, - **kwargs: Any -) -> HttpRequest: - api_version = kwargs.pop('api_version', "2018-05-01") # type: str - accept = "application/json" +def build_policy_assignments_get_request(scope: str, policy_assignment_name: 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", "2018-05-01")) # type: str + accept = _headers.pop("Accept", "application/json") + # Construct URL - _url = kwargs.pop("template_url", "/{scope}/providers/Microsoft.Authorization/policyAssignments/{policyAssignmentName}") + _url = kwargs.pop( + "template_url", "/{scope}/providers/Microsoft.Authorization/policyAssignments/{policyAssignmentName}" + ) path_format_arguments = { - "scope": _SERIALIZER.url("scope", scope, 'str', skip_quote=True), - "policyAssignmentName": _SERIALIZER.url("policy_assignment_name", policy_assignment_name, 'str'), + "scope": _SERIALIZER.url("scope", scope, "str", skip_quote=True), + "policyAssignmentName": _SERIALIZER.url("policy_assignment_name", policy_assignment_name, "str"), } _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') - - return HttpRequest( - method="GET", - url=_url, - params=_query_parameters, - headers=_header_parameters, - **kwargs - ) + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) def build_policy_assignments_list_for_resource_group_request( - resource_group_name: str, - subscription_id: str, - *, - filter: Optional[str] = None, - **kwargs: Any + resource_group_name: str, subscription_id: str, *, filter: Optional[str] = None, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2018-05-01") # type: 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", "2018-05-01")) # type: str + accept = _headers.pop("Accept", "application/json") - accept = "application/json" # Construct URL - _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Authorization/policyAssignments") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Authorization/policyAssignments", + ) # pylint: disable=line-too-long path_format_arguments = { - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._\(\)]+$'), - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), + "resourceGroupName": _SERIALIZER.url( + "resource_group_name", resource_group_name, "str", max_length=90, min_length=1, pattern=r"^[-\w\._\(\)]+$" + ), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), } _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] if filter is not None: - _query_parameters['$filter'] = _SERIALIZER.query("filter", filter, 'str', skip_quote=True) - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["$filter"] = _SERIALIZER.query("filter", filter, "str", skip_quote=True) + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') - - return HttpRequest( - method="GET", - url=_url, - params=_query_parameters, - headers=_header_parameters, - **kwargs - ) + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) def build_policy_assignments_list_for_resource_request( @@ -186,881 +165,723 @@ def build_policy_assignments_list_for_resource_request( filter: Optional[str] = None, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2018-05-01") # type: 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", "2018-05-01")) # type: str + accept = _headers.pop("Accept", "application/json") - accept = "application/json" # Construct URL - _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{parentResourcePath}/{resourceType}/{resourceName}/providers/Microsoft.Authorization/policyAssignments") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{parentResourcePath}/{resourceType}/{resourceName}/providers/Microsoft.Authorization/policyAssignments", + ) # pylint: disable=line-too-long path_format_arguments = { - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._\(\)]+$'), - "resourceProviderNamespace": _SERIALIZER.url("resource_provider_namespace", resource_provider_namespace, 'str'), - "parentResourcePath": _SERIALIZER.url("parent_resource_path", parent_resource_path, 'str', skip_quote=True), - "resourceType": _SERIALIZER.url("resource_type", resource_type, 'str', skip_quote=True), - "resourceName": _SERIALIZER.url("resource_name", resource_name, 'str'), - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), + "resourceGroupName": _SERIALIZER.url( + "resource_group_name", resource_group_name, "str", max_length=90, min_length=1, pattern=r"^[-\w\._\(\)]+$" + ), + "resourceProviderNamespace": _SERIALIZER.url("resource_provider_namespace", resource_provider_namespace, "str"), + "parentResourcePath": _SERIALIZER.url("parent_resource_path", parent_resource_path, "str", skip_quote=True), + "resourceType": _SERIALIZER.url("resource_type", resource_type, "str", skip_quote=True), + "resourceName": _SERIALIZER.url("resource_name", resource_name, "str"), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), } _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] if filter is not None: - _query_parameters['$filter'] = _SERIALIZER.query("filter", filter, 'str') - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["$filter"] = _SERIALIZER.query("filter", filter, "str") + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') - - return HttpRequest( - method="GET", - url=_url, - params=_query_parameters, - headers=_header_parameters, - **kwargs - ) + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) def build_policy_assignments_list_request( - subscription_id: str, - *, - filter: Optional[str] = None, - **kwargs: Any + subscription_id: str, *, filter: Optional[str] = None, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2018-05-01") # type: 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", "2018-05-01")) # type: str + accept = _headers.pop("Accept", "application/json") - accept = "application/json" # Construct URL - _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/providers/Microsoft.Authorization/policyAssignments") + _url = kwargs.pop( + "template_url", "/subscriptions/{subscriptionId}/providers/Microsoft.Authorization/policyAssignments" + ) path_format_arguments = { - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), } _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] if filter is not None: - _query_parameters['$filter'] = _SERIALIZER.query("filter", filter, 'str') - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["$filter"] = _SERIALIZER.query("filter", filter, "str") + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') - - return HttpRequest( - method="GET", - url=_url, - params=_query_parameters, - headers=_header_parameters, - **kwargs - ) + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) -def build_policy_assignments_delete_by_id_request( - policy_assignment_id: str, - **kwargs: Any -) -> HttpRequest: - api_version = kwargs.pop('api_version', "2018-05-01") # type: str - accept = "application/json" +def build_policy_assignments_delete_by_id_request(policy_assignment_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", "2018-05-01")) # type: str + accept = _headers.pop("Accept", "application/json") + # Construct URL _url = kwargs.pop("template_url", "/{policyAssignmentId}") path_format_arguments = { - "policyAssignmentId": _SERIALIZER.url("policy_assignment_id", policy_assignment_id, 'str', skip_quote=True), + "policyAssignmentId": _SERIALIZER.url("policy_assignment_id", policy_assignment_id, "str", skip_quote=True), } _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') - - return HttpRequest( - method="DELETE", - url=_url, - params=_query_parameters, - headers=_header_parameters, - **kwargs - ) + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + return HttpRequest(method="DELETE", url=_url, params=_params, headers=_headers, **kwargs) -def build_policy_assignments_create_by_id_request( - policy_assignment_id: str, - *, - json: JSONType = None, - content: Any = None, - **kwargs: Any -) -> HttpRequest: - api_version = kwargs.pop('api_version', "2018-05-01") # type: str - content_type = kwargs.pop('content_type', None) # type: Optional[str] - accept = "application/json" +def build_policy_assignments_create_by_id_request(policy_assignment_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", "2018-05-01")) # type: str + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + accept = _headers.pop("Accept", "application/json") + # Construct URL _url = kwargs.pop("template_url", "/{policyAssignmentId}") path_format_arguments = { - "policyAssignmentId": _SERIALIZER.url("policy_assignment_id", policy_assignment_id, 'str', skip_quote=True), + "policyAssignmentId": _SERIALIZER.url("policy_assignment_id", policy_assignment_id, "str", skip_quote=True), } _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] if content_type is not None: - _header_parameters['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') - _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') - - return HttpRequest( - method="PUT", - url=_url, - params=_query_parameters, - headers=_header_parameters, - json=json, - content=content, - **kwargs - ) + _headers["Content-Type"] = _SERIALIZER.header("content_type", content_type, "str") + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + return HttpRequest(method="PUT", url=_url, params=_params, headers=_headers, **kwargs) -def build_policy_assignments_get_by_id_request( - policy_assignment_id: str, - **kwargs: Any -) -> HttpRequest: - api_version = kwargs.pop('api_version', "2018-05-01") # type: str - accept = "application/json" +def build_policy_assignments_get_by_id_request(policy_assignment_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", "2018-05-01")) # type: str + accept = _headers.pop("Accept", "application/json") + # Construct URL _url = kwargs.pop("template_url", "/{policyAssignmentId}") path_format_arguments = { - "policyAssignmentId": _SERIALIZER.url("policy_assignment_id", policy_assignment_id, 'str', skip_quote=True), + "policyAssignmentId": _SERIALIZER.url("policy_assignment_id", policy_assignment_id, "str", skip_quote=True), } _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') - - return HttpRequest( - method="GET", - url=_url, - params=_query_parameters, - headers=_header_parameters, - **kwargs - ) + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) def build_policy_definitions_create_or_update_request( - policy_definition_name: str, - subscription_id: str, - *, - json: JSONType = None, - content: Any = None, - **kwargs: Any + policy_definition_name: str, subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2018-05-01") # type: str - content_type = kwargs.pop('content_type', None) # type: Optional[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", "2018-05-01")) # type: str + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + accept = _headers.pop("Accept", "application/json") - accept = "application/json" # Construct URL - _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/providers/Microsoft.Authorization/policyDefinitions/{policyDefinitionName}") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/providers/Microsoft.Authorization/policyDefinitions/{policyDefinitionName}", + ) # pylint: disable=line-too-long path_format_arguments = { - "policyDefinitionName": _SERIALIZER.url("policy_definition_name", policy_definition_name, 'str'), - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), + "policyDefinitionName": _SERIALIZER.url("policy_definition_name", policy_definition_name, "str"), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), } _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] if content_type is not None: - _header_parameters['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') - _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') - - return HttpRequest( - method="PUT", - url=_url, - params=_query_parameters, - headers=_header_parameters, - json=json, - content=content, - **kwargs - ) + _headers["Content-Type"] = _SERIALIZER.header("content_type", content_type, "str") + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="PUT", url=_url, params=_params, headers=_headers, **kwargs) def build_policy_definitions_delete_request( - policy_definition_name: str, - subscription_id: str, - **kwargs: Any + policy_definition_name: str, subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2018-05-01") # type: str + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + api_version = kwargs.pop("api_version", _params.pop("api-version", "2018-05-01")) # type: str # Construct URL - _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/providers/Microsoft.Authorization/policyDefinitions/{policyDefinitionName}") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/providers/Microsoft.Authorization/policyDefinitions/{policyDefinitionName}", + ) # pylint: disable=line-too-long path_format_arguments = { - "policyDefinitionName": _SERIALIZER.url("policy_definition_name", policy_definition_name, 'str'), - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), + "policyDefinitionName": _SERIALIZER.url("policy_definition_name", policy_definition_name, "str"), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), } _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') - - return HttpRequest( - method="DELETE", - url=_url, - params=_query_parameters, - **kwargs - ) + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") + + return HttpRequest(method="DELETE", url=_url, params=_params, **kwargs) def build_policy_definitions_get_request( - policy_definition_name: str, - subscription_id: str, - **kwargs: Any + policy_definition_name: str, subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2018-05-01") # type: 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", "2018-05-01")) # type: str + accept = _headers.pop("Accept", "application/json") - accept = "application/json" # Construct URL - _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/providers/Microsoft.Authorization/policyDefinitions/{policyDefinitionName}") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/providers/Microsoft.Authorization/policyDefinitions/{policyDefinitionName}", + ) # pylint: disable=line-too-long path_format_arguments = { - "policyDefinitionName": _SERIALIZER.url("policy_definition_name", policy_definition_name, 'str'), - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), + "policyDefinitionName": _SERIALIZER.url("policy_definition_name", policy_definition_name, "str"), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), } _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') - - return HttpRequest( - method="GET", - url=_url, - params=_query_parameters, - headers=_header_parameters, - **kwargs - ) + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) -def build_policy_definitions_get_built_in_request( - policy_definition_name: str, - **kwargs: Any -) -> HttpRequest: - api_version = kwargs.pop('api_version', "2018-05-01") # type: str - accept = "application/json" +def build_policy_definitions_get_built_in_request(policy_definition_name: 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", "2018-05-01")) # type: str + accept = _headers.pop("Accept", "application/json") + # Construct URL _url = kwargs.pop("template_url", "/providers/Microsoft.Authorization/policyDefinitions/{policyDefinitionName}") path_format_arguments = { - "policyDefinitionName": _SERIALIZER.url("policy_definition_name", policy_definition_name, 'str'), + "policyDefinitionName": _SERIALIZER.url("policy_definition_name", policy_definition_name, "str"), } _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') - - return HttpRequest( - method="GET", - url=_url, - params=_query_parameters, - headers=_header_parameters, - **kwargs - ) + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) def build_policy_definitions_create_or_update_at_management_group_request( - policy_definition_name: str, - management_group_id: str, - *, - json: JSONType = None, - content: Any = None, - **kwargs: Any + policy_definition_name: str, management_group_id: str, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2018-05-01") # type: str - content_type = kwargs.pop('content_type', None) # type: Optional[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", "2018-05-01")) # type: str + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + accept = _headers.pop("Accept", "application/json") - accept = "application/json" # Construct URL - _url = kwargs.pop("template_url", "/providers/Microsoft.Management/managementgroups/{managementGroupId}/providers/Microsoft.Authorization/policyDefinitions/{policyDefinitionName}") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", + "/providers/Microsoft.Management/managementgroups/{managementGroupId}/providers/Microsoft.Authorization/policyDefinitions/{policyDefinitionName}", + ) # pylint: disable=line-too-long path_format_arguments = { - "policyDefinitionName": _SERIALIZER.url("policy_definition_name", policy_definition_name, 'str'), - "managementGroupId": _SERIALIZER.url("management_group_id", management_group_id, 'str'), + "policyDefinitionName": _SERIALIZER.url("policy_definition_name", policy_definition_name, "str"), + "managementGroupId": _SERIALIZER.url("management_group_id", management_group_id, "str"), } _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] if content_type is not None: - _header_parameters['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') - _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') - - return HttpRequest( - method="PUT", - url=_url, - params=_query_parameters, - headers=_header_parameters, - json=json, - content=content, - **kwargs - ) + _headers["Content-Type"] = _SERIALIZER.header("content_type", content_type, "str") + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="PUT", url=_url, params=_params, headers=_headers, **kwargs) def build_policy_definitions_delete_at_management_group_request( - policy_definition_name: str, - management_group_id: str, - **kwargs: Any + policy_definition_name: str, management_group_id: str, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2018-05-01") # type: str + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + api_version = kwargs.pop("api_version", _params.pop("api-version", "2018-05-01")) # type: str # Construct URL - _url = kwargs.pop("template_url", "/providers/Microsoft.Management/managementgroups/{managementGroupId}/providers/Microsoft.Authorization/policyDefinitions/{policyDefinitionName}") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", + "/providers/Microsoft.Management/managementgroups/{managementGroupId}/providers/Microsoft.Authorization/policyDefinitions/{policyDefinitionName}", + ) # pylint: disable=line-too-long path_format_arguments = { - "policyDefinitionName": _SERIALIZER.url("policy_definition_name", policy_definition_name, 'str'), - "managementGroupId": _SERIALIZER.url("management_group_id", management_group_id, 'str'), + "policyDefinitionName": _SERIALIZER.url("policy_definition_name", policy_definition_name, "str"), + "managementGroupId": _SERIALIZER.url("management_group_id", management_group_id, "str"), } _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') - - return HttpRequest( - method="DELETE", - url=_url, - params=_query_parameters, - **kwargs - ) + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") + + return HttpRequest(method="DELETE", url=_url, params=_params, **kwargs) def build_policy_definitions_get_at_management_group_request( - policy_definition_name: str, - management_group_id: str, - **kwargs: Any + policy_definition_name: str, management_group_id: str, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2018-05-01") # type: 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", "2018-05-01")) # type: str + accept = _headers.pop("Accept", "application/json") - accept = "application/json" # Construct URL - _url = kwargs.pop("template_url", "/providers/Microsoft.Management/managementgroups/{managementGroupId}/providers/Microsoft.Authorization/policyDefinitions/{policyDefinitionName}") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", + "/providers/Microsoft.Management/managementgroups/{managementGroupId}/providers/Microsoft.Authorization/policyDefinitions/{policyDefinitionName}", + ) # pylint: disable=line-too-long path_format_arguments = { - "policyDefinitionName": _SERIALIZER.url("policy_definition_name", policy_definition_name, 'str'), - "managementGroupId": _SERIALIZER.url("management_group_id", management_group_id, 'str'), + "policyDefinitionName": _SERIALIZER.url("policy_definition_name", policy_definition_name, "str"), + "managementGroupId": _SERIALIZER.url("management_group_id", management_group_id, "str"), } _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') - - return HttpRequest( - method="GET", - url=_url, - params=_query_parameters, - headers=_header_parameters, - **kwargs - ) + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) -def build_policy_definitions_list_request( - subscription_id: str, - **kwargs: Any -) -> HttpRequest: - api_version = kwargs.pop('api_version', "2018-05-01") # type: str - accept = "application/json" +def build_policy_definitions_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", "2018-05-01")) # type: str + accept = _headers.pop("Accept", "application/json") + # Construct URL - _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/providers/Microsoft.Authorization/policyDefinitions") + _url = kwargs.pop( + "template_url", "/subscriptions/{subscriptionId}/providers/Microsoft.Authorization/policyDefinitions" + ) path_format_arguments = { - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), } _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') - - return HttpRequest( - method="GET", - url=_url, - params=_query_parameters, - headers=_header_parameters, - **kwargs - ) + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) -def build_policy_definitions_list_built_in_request( - **kwargs: Any -) -> HttpRequest: - api_version = kwargs.pop('api_version', "2018-05-01") # type: str - accept = "application/json" +def build_policy_definitions_list_built_in_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", "2018-05-01")) # type: str + accept = _headers.pop("Accept", "application/json") + # Construct URL _url = kwargs.pop("template_url", "/providers/Microsoft.Authorization/policyDefinitions") # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') - - return HttpRequest( - method="GET", - url=_url, - params=_query_parameters, - headers=_header_parameters, - **kwargs - ) + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) -def build_policy_definitions_list_by_management_group_request( - management_group_id: str, - **kwargs: Any -) -> HttpRequest: - api_version = kwargs.pop('api_version', "2018-05-01") # type: str - accept = "application/json" +def build_policy_definitions_list_by_management_group_request(management_group_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", "2018-05-01")) # type: str + accept = _headers.pop("Accept", "application/json") + # Construct URL - _url = kwargs.pop("template_url", "/providers/Microsoft.Management/managementgroups/{managementGroupId}/providers/Microsoft.Authorization/policyDefinitions") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", + "/providers/Microsoft.Management/managementgroups/{managementGroupId}/providers/Microsoft.Authorization/policyDefinitions", + ) # pylint: disable=line-too-long path_format_arguments = { - "managementGroupId": _SERIALIZER.url("management_group_id", management_group_id, 'str'), + "managementGroupId": _SERIALIZER.url("management_group_id", management_group_id, "str"), } _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') - - return HttpRequest( - method="GET", - url=_url, - params=_query_parameters, - headers=_header_parameters, - **kwargs - ) + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) def build_policy_set_definitions_create_or_update_request( - policy_set_definition_name: str, - subscription_id: str, - *, - json: JSONType = None, - content: Any = None, - **kwargs: Any + policy_set_definition_name: str, subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2018-05-01") # type: str - content_type = kwargs.pop('content_type', None) # type: Optional[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", "2018-05-01")) # type: str + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + accept = _headers.pop("Accept", "application/json") - accept = "application/json" # Construct URL - _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/providers/Microsoft.Authorization/policySetDefinitions/{policySetDefinitionName}") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/providers/Microsoft.Authorization/policySetDefinitions/{policySetDefinitionName}", + ) # pylint: disable=line-too-long path_format_arguments = { - "policySetDefinitionName": _SERIALIZER.url("policy_set_definition_name", policy_set_definition_name, 'str'), - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), + "policySetDefinitionName": _SERIALIZER.url("policy_set_definition_name", policy_set_definition_name, "str"), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), } _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] if content_type is not None: - _header_parameters['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') - _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') - - return HttpRequest( - method="PUT", - url=_url, - params=_query_parameters, - headers=_header_parameters, - json=json, - content=content, - **kwargs - ) + _headers["Content-Type"] = _SERIALIZER.header("content_type", content_type, "str") + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="PUT", url=_url, params=_params, headers=_headers, **kwargs) def build_policy_set_definitions_delete_request( - policy_set_definition_name: str, - subscription_id: str, - **kwargs: Any + policy_set_definition_name: str, subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2018-05-01") # type: 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", "2018-05-01")) # type: str + accept = _headers.pop("Accept", "application/json") - accept = "application/json" # Construct URL - _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/providers/Microsoft.Authorization/policySetDefinitions/{policySetDefinitionName}") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/providers/Microsoft.Authorization/policySetDefinitions/{policySetDefinitionName}", + ) # pylint: disable=line-too-long path_format_arguments = { - "policySetDefinitionName": _SERIALIZER.url("policy_set_definition_name", policy_set_definition_name, 'str'), - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), + "policySetDefinitionName": _SERIALIZER.url("policy_set_definition_name", policy_set_definition_name, "str"), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), } _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') - - return HttpRequest( - method="DELETE", - url=_url, - params=_query_parameters, - headers=_header_parameters, - **kwargs - ) + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="DELETE", url=_url, params=_params, headers=_headers, **kwargs) def build_policy_set_definitions_get_request( - policy_set_definition_name: str, - subscription_id: str, - **kwargs: Any + policy_set_definition_name: str, subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2018-05-01") # type: 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", "2018-05-01")) # type: str + accept = _headers.pop("Accept", "application/json") - accept = "application/json" # Construct URL - _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/providers/Microsoft.Authorization/policySetDefinitions/{policySetDefinitionName}") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/providers/Microsoft.Authorization/policySetDefinitions/{policySetDefinitionName}", + ) # pylint: disable=line-too-long path_format_arguments = { - "policySetDefinitionName": _SERIALIZER.url("policy_set_definition_name", policy_set_definition_name, 'str'), - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), + "policySetDefinitionName": _SERIALIZER.url("policy_set_definition_name", policy_set_definition_name, "str"), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), } _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') - - return HttpRequest( - method="GET", - url=_url, - params=_query_parameters, - headers=_header_parameters, - **kwargs - ) + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) -def build_policy_set_definitions_get_built_in_request( - policy_set_definition_name: str, - **kwargs: Any -) -> HttpRequest: - api_version = kwargs.pop('api_version', "2018-05-01") # type: str - accept = "application/json" +def build_policy_set_definitions_get_built_in_request(policy_set_definition_name: 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", "2018-05-01")) # type: str + accept = _headers.pop("Accept", "application/json") + # Construct URL - _url = kwargs.pop("template_url", "/providers/Microsoft.Authorization/policySetDefinitions/{policySetDefinitionName}") + _url = kwargs.pop( + "template_url", "/providers/Microsoft.Authorization/policySetDefinitions/{policySetDefinitionName}" + ) path_format_arguments = { - "policySetDefinitionName": _SERIALIZER.url("policy_set_definition_name", policy_set_definition_name, 'str'), + "policySetDefinitionName": _SERIALIZER.url("policy_set_definition_name", policy_set_definition_name, "str"), } _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') - - return HttpRequest( - method="GET", - url=_url, - params=_query_parameters, - headers=_header_parameters, - **kwargs - ) + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) -def build_policy_set_definitions_list_request( - subscription_id: str, - **kwargs: Any -) -> HttpRequest: - api_version = kwargs.pop('api_version', "2018-05-01") # type: str - accept = "application/json" +def build_policy_set_definitions_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", "2018-05-01")) # type: str + accept = _headers.pop("Accept", "application/json") + # Construct URL - _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/providers/Microsoft.Authorization/policySetDefinitions") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", "/subscriptions/{subscriptionId}/providers/Microsoft.Authorization/policySetDefinitions" + ) # pylint: disable=line-too-long path_format_arguments = { - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), } _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') - - return HttpRequest( - method="GET", - url=_url, - params=_query_parameters, - headers=_header_parameters, - **kwargs - ) + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) -def build_policy_set_definitions_list_built_in_request( - **kwargs: Any -) -> HttpRequest: - api_version = kwargs.pop('api_version', "2018-05-01") # type: str - accept = "application/json" +def build_policy_set_definitions_list_built_in_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", "2018-05-01")) # type: str + accept = _headers.pop("Accept", "application/json") + # Construct URL _url = kwargs.pop("template_url", "/providers/Microsoft.Authorization/policySetDefinitions") # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') - - return HttpRequest( - method="GET", - url=_url, - params=_query_parameters, - headers=_header_parameters, - **kwargs - ) + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) def build_policy_set_definitions_create_or_update_at_management_group_request( - policy_set_definition_name: str, - management_group_id: str, - *, - json: JSONType = None, - content: Any = None, - **kwargs: Any + policy_set_definition_name: str, management_group_id: str, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2018-05-01") # type: str - content_type = kwargs.pop('content_type', None) # type: Optional[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", "2018-05-01")) # type: str + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + accept = _headers.pop("Accept", "application/json") - accept = "application/json" # Construct URL - _url = kwargs.pop("template_url", "/providers/Microsoft.Management/managementgroups/{managementGroupId}/providers/Microsoft.Authorization/policySetDefinitions/{policySetDefinitionName}") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", + "/providers/Microsoft.Management/managementgroups/{managementGroupId}/providers/Microsoft.Authorization/policySetDefinitions/{policySetDefinitionName}", + ) # pylint: disable=line-too-long path_format_arguments = { - "policySetDefinitionName": _SERIALIZER.url("policy_set_definition_name", policy_set_definition_name, 'str'), - "managementGroupId": _SERIALIZER.url("management_group_id", management_group_id, 'str'), + "policySetDefinitionName": _SERIALIZER.url("policy_set_definition_name", policy_set_definition_name, "str"), + "managementGroupId": _SERIALIZER.url("management_group_id", management_group_id, "str"), } _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] if content_type is not None: - _header_parameters['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') - _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') - - return HttpRequest( - method="PUT", - url=_url, - params=_query_parameters, - headers=_header_parameters, - json=json, - content=content, - **kwargs - ) + _headers["Content-Type"] = _SERIALIZER.header("content_type", content_type, "str") + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="PUT", url=_url, params=_params, headers=_headers, **kwargs) def build_policy_set_definitions_delete_at_management_group_request( - policy_set_definition_name: str, - management_group_id: str, - **kwargs: Any + policy_set_definition_name: str, management_group_id: str, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2018-05-01") # type: 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", "2018-05-01")) # type: str + accept = _headers.pop("Accept", "application/json") - accept = "application/json" # Construct URL - _url = kwargs.pop("template_url", "/providers/Microsoft.Management/managementgroups/{managementGroupId}/providers/Microsoft.Authorization/policySetDefinitions/{policySetDefinitionName}") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", + "/providers/Microsoft.Management/managementgroups/{managementGroupId}/providers/Microsoft.Authorization/policySetDefinitions/{policySetDefinitionName}", + ) # pylint: disable=line-too-long path_format_arguments = { - "policySetDefinitionName": _SERIALIZER.url("policy_set_definition_name", policy_set_definition_name, 'str'), - "managementGroupId": _SERIALIZER.url("management_group_id", management_group_id, 'str'), + "policySetDefinitionName": _SERIALIZER.url("policy_set_definition_name", policy_set_definition_name, "str"), + "managementGroupId": _SERIALIZER.url("management_group_id", management_group_id, "str"), } _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') - - return HttpRequest( - method="DELETE", - url=_url, - params=_query_parameters, - headers=_header_parameters, - **kwargs - ) + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="DELETE", url=_url, params=_params, headers=_headers, **kwargs) def build_policy_set_definitions_get_at_management_group_request( - policy_set_definition_name: str, - management_group_id: str, - **kwargs: Any + policy_set_definition_name: str, management_group_id: str, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2018-05-01") # type: 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", "2018-05-01")) # type: str + accept = _headers.pop("Accept", "application/json") - accept = "application/json" # Construct URL - _url = kwargs.pop("template_url", "/providers/Microsoft.Management/managementgroups/{managementGroupId}/providers/Microsoft.Authorization/policySetDefinitions/{policySetDefinitionName}") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", + "/providers/Microsoft.Management/managementgroups/{managementGroupId}/providers/Microsoft.Authorization/policySetDefinitions/{policySetDefinitionName}", + ) # pylint: disable=line-too-long path_format_arguments = { - "policySetDefinitionName": _SERIALIZER.url("policy_set_definition_name", policy_set_definition_name, 'str'), - "managementGroupId": _SERIALIZER.url("management_group_id", management_group_id, 'str'), + "policySetDefinitionName": _SERIALIZER.url("policy_set_definition_name", policy_set_definition_name, "str"), + "managementGroupId": _SERIALIZER.url("management_group_id", management_group_id, "str"), } _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') - - return HttpRequest( - method="GET", - url=_url, - params=_query_parameters, - headers=_header_parameters, - **kwargs - ) + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) def build_policy_set_definitions_list_by_management_group_request( - management_group_id: str, - **kwargs: Any + management_group_id: str, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2018-05-01") # type: 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", "2018-05-01")) # type: str + accept = _headers.pop("Accept", "application/json") - accept = "application/json" # Construct URL - _url = kwargs.pop("template_url", "/providers/Microsoft.Management/managementgroups/{managementGroupId}/providers/Microsoft.Authorization/policySetDefinitions") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", + "/providers/Microsoft.Management/managementgroups/{managementGroupId}/providers/Microsoft.Authorization/policySetDefinitions", + ) # pylint: disable=line-too-long path_format_arguments = { - "managementGroupId": _SERIALIZER.url("management_group_id", management_group_id, 'str'), + "managementGroupId": _SERIALIZER.url("management_group_id", management_group_id, "str"), } _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') - - return HttpRequest( - method="GET", - url=_url, - params=_query_parameters, - headers=_header_parameters, - **kwargs - ) + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") -class PolicyAssignmentsOperations(object): - """PolicyAssignmentsOperations operations. + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) - You should not instantiate this class directly. Instead, you should create a Client instance that - instantiates it for you and attaches it as an attribute. - :ivar models: Alias to model classes used in this operation group. - :type models: ~azure.mgmt.resource.policy.v2018_05_01.models - :param client: Client for service requests. - :param config: Configuration of service client. - :param serializer: An object model serializer. - :param deserializer: An object model deserializer. +class PolicyAssignmentsOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. + + Instead, you should access the following operations through + :class:`~azure.mgmt.resource.policy.v2018_05_01.PolicyClient`'s + :attr:`policy_assignments` attribute. """ models = _models - def __init__(self, client, config, serializer, deserializer): - self._client = client - self._serialize = serializer - self._deserialize = deserializer - self._config = config + def __init__(self, *args, **kwargs): + input_args = list(args) + self._client = input_args.pop(0) if input_args else kwargs.pop("client") + self._config = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") @distributed_trace - def delete( - self, - scope: str, - policy_assignment_name: str, - **kwargs: Any - ) -> Optional["_models.PolicyAssignment"]: + def delete(self, scope: str, policy_assignment_name: str, **kwargs: Any) -> Optional[_models.PolicyAssignment]: """Deletes a policy assignment. This operation deletes a policy assignment, given its name and the scope it was created in. The @@ -1072,37 +893,44 @@ def delete( '/subscriptions/{subscriptionId}'), resource group (format: '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}', or resource (format: '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{resourceProviderNamespace}/[{parentResourcePath}/]{resourceType}/{resourceName}'. + Required. :type scope: str - :param policy_assignment_name: The name of the policy assignment to delete. + :param policy_assignment_name: The name of the policy assignment to delete. Required. :type policy_assignment_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: PolicyAssignment, or the result of cls(response) + :return: PolicyAssignment or None or the result of cls(response) :rtype: ~azure.mgmt.resource.policy.v2018_05_01.models.PolicyAssignment or None - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType[Optional["_models.PolicyAssignment"]] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) - api_version = kwargs.pop('api_version', "2018-05-01") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2018-05-01")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[Optional[_models.PolicyAssignment]] - request = build_policy_assignments_delete_request( scope=scope, policy_assignment_name=policy_assignment_name, api_version=api_version, - template_url=self.delete.metadata['url'], + template_url=self.delete.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200, 204]: @@ -1112,24 +940,25 @@ def delete( deserialized = None if response.status_code == 200: - deserialized = self._deserialize('PolicyAssignment', pipeline_response) + deserialized = self._deserialize("PolicyAssignment", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - delete.metadata = {'url': "/{scope}/providers/Microsoft.Authorization/policyAssignments/{policyAssignmentName}"} # type: ignore - + delete.metadata = {"url": "/{scope}/providers/Microsoft.Authorization/policyAssignments/{policyAssignmentName}"} # type: ignore - @distributed_trace + @overload def create( self, scope: str, policy_assignment_name: str, - parameters: "_models.PolicyAssignment", + parameters: _models.PolicyAssignment, + *, + content_type: str = "application/json", **kwargs: Any - ) -> "_models.PolicyAssignment": + ) -> _models.PolicyAssignment: """Creates or updates a policy assignment. This operation creates or updates a policy assignment with the given scope and name. Policy @@ -1141,26 +970,109 @@ def create( '/subscriptions/{subscriptionId}'), resource group (format: '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}', or resource (format: '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{resourceProviderNamespace}/[{parentResourcePath}/]{resourceType}/{resourceName}'. + Required. :type scope: str - :param policy_assignment_name: The name of the policy assignment. + :param policy_assignment_name: The name of the policy assignment. Required. :type policy_assignment_name: str - :param parameters: Parameters for the policy assignment. + :param parameters: Parameters for the policy assignment. Required. :type parameters: ~azure.mgmt.resource.policy.v2018_05_01.models.PolicyAssignment + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: PolicyAssignment or the result of cls(response) + :rtype: ~azure.mgmt.resource.policy.v2018_05_01.models.PolicyAssignment + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + def create( + self, + scope: str, + policy_assignment_name: str, + parameters: IO, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.PolicyAssignment: + """Creates or updates a policy assignment. + + This operation creates or updates a policy assignment with the given scope and name. Policy + assignments apply to all resources contained within their scope. For example, when you assign a + policy at resource group scope, that policy applies to all resources in the group. + + :param scope: The scope of the policy assignment. Valid scopes are: management group (format: + '/providers/Microsoft.Management/managementGroups/{managementGroup}'), subscription (format: + '/subscriptions/{subscriptionId}'), resource group (format: + '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}', or resource (format: + '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{resourceProviderNamespace}/[{parentResourcePath}/]{resourceType}/{resourceName}'. + Required. + :type scope: str + :param policy_assignment_name: The name of the policy assignment. Required. + :type policy_assignment_name: str + :param parameters: Parameters for the policy assignment. Required. + :type parameters: IO + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: PolicyAssignment or the result of cls(response) + :rtype: ~azure.mgmt.resource.policy.v2018_05_01.models.PolicyAssignment + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace + def create( + self, scope: str, policy_assignment_name: str, parameters: Union[_models.PolicyAssignment, IO], **kwargs: Any + ) -> _models.PolicyAssignment: + """Creates or updates a policy assignment. + + This operation creates or updates a policy assignment with the given scope and name. Policy + assignments apply to all resources contained within their scope. For example, when you assign a + policy at resource group scope, that policy applies to all resources in the group. + + :param scope: The scope of the policy assignment. Valid scopes are: management group (format: + '/providers/Microsoft.Management/managementGroups/{managementGroup}'), subscription (format: + '/subscriptions/{subscriptionId}'), resource group (format: + '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}', or resource (format: + '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{resourceProviderNamespace}/[{parentResourcePath}/]{resourceType}/{resourceName}'. + Required. + :type scope: str + :param policy_assignment_name: The name of the policy assignment. Required. + :type policy_assignment_name: str + :param parameters: Parameters for the policy assignment. Is either a model type or a IO type. + Required. + :type parameters: ~azure.mgmt.resource.policy.v2018_05_01.models.PolicyAssignment or IO + :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. + Default value is None. + :paramtype content_type: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: PolicyAssignment, or the result of cls(response) + :return: PolicyAssignment or the result of cls(response) :rtype: ~azure.mgmt.resource.policy.v2018_05_01.models.PolicyAssignment - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.PolicyAssignment"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', "2018-05-01") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + api_version = kwargs.pop("api_version", _params.pop("api-version", "2018-05-01")) # type: str + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.PolicyAssignment] - _json = self._serialize.body(parameters, 'PolicyAssignment') + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(parameters, (IO, bytes)): + _content = parameters + else: + _json = self._serialize.body(parameters, "PolicyAssignment") request = build_policy_assignments_create_request( scope=scope, @@ -1168,16 +1080,18 @@ def create( api_version=api_version, content_type=content_type, json=_json, - template_url=self.create.metadata['url'], + content=_content, + template_url=self.create.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [201]: @@ -1185,23 +1099,17 @@ def create( error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - deserialized = self._deserialize('PolicyAssignment', pipeline_response) + deserialized = self._deserialize("PolicyAssignment", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - create.metadata = {'url': "/{scope}/providers/Microsoft.Authorization/policyAssignments/{policyAssignmentName}"} # type: ignore - + create.metadata = {"url": "/{scope}/providers/Microsoft.Authorization/policyAssignments/{policyAssignmentName}"} # type: ignore @distributed_trace - def get( - self, - scope: str, - policy_assignment_name: str, - **kwargs: Any - ) -> "_models.PolicyAssignment": + def get(self, scope: str, policy_assignment_name: str, **kwargs: Any) -> _models.PolicyAssignment: """Retrieves a policy assignment. This operation retrieves a single policy assignment, given its name and the scope it was @@ -1212,37 +1120,44 @@ def get( '/subscriptions/{subscriptionId}'), resource group (format: '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}', or resource (format: '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{resourceProviderNamespace}/[{parentResourcePath}/]{resourceType}/{resourceName}'. + Required. :type scope: str - :param policy_assignment_name: The name of the policy assignment to get. + :param policy_assignment_name: The name of the policy assignment to get. Required. :type policy_assignment_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: PolicyAssignment, or the result of cls(response) + :return: PolicyAssignment or the result of cls(response) :rtype: ~azure.mgmt.resource.policy.v2018_05_01.models.PolicyAssignment - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.PolicyAssignment"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + 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', "2018-05-01") # type: str + api_version = kwargs.pop("api_version", _params.pop("api-version", "2018-05-01")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[_models.PolicyAssignment] - request = build_policy_assignments_get_request( scope=scope, policy_assignment_name=policy_assignment_name, api_version=api_version, - template_url=self.get.metadata['url'], + template_url=self.get.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200]: @@ -1250,23 +1165,19 @@ def get( error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - deserialized = self._deserialize('PolicyAssignment', pipeline_response) + deserialized = self._deserialize("PolicyAssignment", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - get.metadata = {'url': "/{scope}/providers/Microsoft.Authorization/policyAssignments/{policyAssignmentName}"} # type: ignore - + get.metadata = {"url": "/{scope}/providers/Microsoft.Authorization/policyAssignments/{policyAssignmentName}"} # type: ignore @distributed_trace def list_for_resource_group( - self, - resource_group_name: str, - filter: Optional[str] = None, - **kwargs: Any - ) -> Iterable["_models.PolicyAssignmentListResult"]: + self, resource_group_name: str, filter: Optional[str] = None, **kwargs: Any + ) -> Iterable["_models.PolicyAssignment"]: """Retrieves all policy assignments that apply to a resource group. This operation retrieves the list of all policy assignments associated with the given resource @@ -1281,47 +1192,55 @@ def list_for_resource_group( assignments of the policy definition whose id is {value} that apply to the resource group. :param resource_group_name: The name of the resource group that contains policy assignments. + Required. :type resource_group_name: str :param filter: The filter to apply on the operation. Valid values for $filter are: 'atScope()' or 'policyDefinitionId eq '{value}''. If $filter is not provided, no filtering is performed. Default value is None. :type filter: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either PolicyAssignmentListResult or the result of - cls(response) + :return: An iterator like instance of either PolicyAssignment or the result of cls(response) :rtype: - ~azure.core.paging.ItemPaged[~azure.mgmt.resource.policy.v2018_05_01.models.PolicyAssignmentListResult] - :raises: ~azure.core.exceptions.HttpResponseError + ~azure.core.paging.ItemPaged[~azure.mgmt.resource.policy.v2018_05_01.models.PolicyAssignment] + :raises ~azure.core.exceptions.HttpResponseError: """ - api_version = kwargs.pop('api_version', "2018-05-01") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2018-05-01")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[_models.PolicyAssignmentListResult] - cls = kwargs.pop('cls', None) # type: ClsType["_models.PolicyAssignmentListResult"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) + def prepare_request(next_link=None): if not next_link: - + request = build_policy_assignments_list_for_resource_group_request( resource_group_name=resource_group_name, subscription_id=self._config.subscription_id, - api_version=api_version, filter=filter, - template_url=self.list_for_resource_group.metadata['url'], + api_version=api_version, + template_url=self.list_for_resource_group.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore else: - - request = build_policy_assignments_list_for_resource_group_request( - resource_group_name=resource_group_name, - subscription_id=self._config.subscription_id, - template_url=next_link, - ) + # make call to next link with the client's api-version + _parsed_next_link = urlparse(next_link) + _next_request_params = case_insensitive_dict(parse_qs(_parsed_next_link.query)) + _next_request_params["api-version"] = self._config.api_version + request = HttpRequest("GET", urljoin(next_link, _parsed_next_link.path), params=_next_request_params) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore request.method = "GET" return request @@ -1335,10 +1254,8 @@ def extract_data(pipeline_response): def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) response = pipeline_response.http_response @@ -1349,11 +1266,9 @@ def get_next(next_link=None): return pipeline_response + return ItemPaged(get_next, extract_data) - return ItemPaged( - get_next, extract_data - ) - list_for_resource_group.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Authorization/policyAssignments"} # type: ignore + list_for_resource_group.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Authorization/policyAssignments"} # type: ignore @distributed_trace def list_for_resource( @@ -1365,7 +1280,7 @@ def list_for_resource( resource_name: str, filter: Optional[str] = None, **kwargs: Any - ) -> Iterable["_models.PolicyAssignmentListResult"]: + ) -> Iterable["_models.PolicyAssignment"]: """Retrieves all policy assignments that apply to a resource. This operation retrieves the list of all policy assignments associated with the specified @@ -1391,39 +1306,47 @@ def list_for_resource( {parentResourcePath} == '', {resourceType} == 'Microsoft.Web/sites', {resourceName} == 'MyWebApp'). - :param resource_group_name: The name of the resource group containing the resource. + :param resource_group_name: The name of the resource group containing the resource. Required. :type resource_group_name: str :param resource_provider_namespace: The namespace of the resource provider. For example, the namespace of a virtual machine is Microsoft.Compute (from Microsoft.Compute/virtualMachines). + Required. :type resource_provider_namespace: str :param parent_resource_path: The parent resource path. Use empty string if there is none. + Required. :type parent_resource_path: str :param resource_type: The resource type name. For example the type name of a web app is 'sites' - (from Microsoft.Web/sites). + (from Microsoft.Web/sites). Required. :type resource_type: str - :param resource_name: The name of the resource. + :param resource_name: The name of the resource. Required. :type resource_name: str :param filter: The filter to apply on the operation. Valid values for $filter are: 'atScope()' or 'policyDefinitionId eq '{value}''. If $filter is not provided, no filtering is performed. Default value is None. :type filter: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either PolicyAssignmentListResult or the result of - cls(response) + :return: An iterator like instance of either PolicyAssignment or the result of cls(response) :rtype: - ~azure.core.paging.ItemPaged[~azure.mgmt.resource.policy.v2018_05_01.models.PolicyAssignmentListResult] - :raises: ~azure.core.exceptions.HttpResponseError + ~azure.core.paging.ItemPaged[~azure.mgmt.resource.policy.v2018_05_01.models.PolicyAssignment] + :raises ~azure.core.exceptions.HttpResponseError: """ - api_version = kwargs.pop('api_version', "2018-05-01") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2018-05-01")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[_models.PolicyAssignmentListResult] - cls = kwargs.pop('cls', None) # type: ClsType["_models.PolicyAssignmentListResult"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) + def prepare_request(next_link=None): if not next_link: - + request = build_policy_assignments_list_for_resource_request( resource_group_name=resource_group_name, resource_provider_namespace=resource_provider_namespace, @@ -1431,26 +1354,23 @@ def prepare_request(next_link=None): resource_type=resource_type, resource_name=resource_name, subscription_id=self._config.subscription_id, - api_version=api_version, filter=filter, - template_url=self.list_for_resource.metadata['url'], + api_version=api_version, + template_url=self.list_for_resource.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore else: - - request = build_policy_assignments_list_for_resource_request( - resource_group_name=resource_group_name, - resource_provider_namespace=resource_provider_namespace, - parent_resource_path=parent_resource_path, - resource_type=resource_type, - resource_name=resource_name, - subscription_id=self._config.subscription_id, - template_url=next_link, - ) + # make call to next link with the client's api-version + _parsed_next_link = urlparse(next_link) + _next_request_params = case_insensitive_dict(parse_qs(_parsed_next_link.query)) + _next_request_params["api-version"] = self._config.api_version + request = HttpRequest("GET", urljoin(next_link, _parsed_next_link.path), params=_next_request_params) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore request.method = "GET" return request @@ -1464,10 +1384,8 @@ def extract_data(pipeline_response): def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) response = pipeline_response.http_response @@ -1478,18 +1396,12 @@ def get_next(next_link=None): return pipeline_response + return ItemPaged(get_next, extract_data) - return ItemPaged( - get_next, extract_data - ) - list_for_resource.metadata = {'url': "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{parentResourcePath}/{resourceType}/{resourceName}/providers/Microsoft.Authorization/policyAssignments"} # type: ignore + list_for_resource.metadata = {"url": "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{parentResourcePath}/{resourceType}/{resourceName}/providers/Microsoft.Authorization/policyAssignments"} # type: ignore @distributed_trace - def list( - self, - filter: Optional[str] = None, - **kwargs: Any - ) -> Iterable["_models.PolicyAssignmentListResult"]: + def list(self, filter: Optional[str] = None, **kwargs: Any) -> Iterable["_models.PolicyAssignment"]: """Retrieves all policy assignments that apply to a subscription. This operation retrieves the list of all policy assignments associated with the given @@ -1508,39 +1420,47 @@ def list( Default value is None. :type filter: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either PolicyAssignmentListResult or the result of - cls(response) + :return: An iterator like instance of either PolicyAssignment or the result of cls(response) :rtype: - ~azure.core.paging.ItemPaged[~azure.mgmt.resource.policy.v2018_05_01.models.PolicyAssignmentListResult] - :raises: ~azure.core.exceptions.HttpResponseError + ~azure.core.paging.ItemPaged[~azure.mgmt.resource.policy.v2018_05_01.models.PolicyAssignment] + :raises ~azure.core.exceptions.HttpResponseError: """ - api_version = kwargs.pop('api_version', "2018-05-01") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2018-05-01")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[_models.PolicyAssignmentListResult] - cls = kwargs.pop('cls', None) # type: ClsType["_models.PolicyAssignmentListResult"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) + def prepare_request(next_link=None): if not next_link: - + request = build_policy_assignments_list_request( subscription_id=self._config.subscription_id, - api_version=api_version, filter=filter, - template_url=self.list.metadata['url'], + 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.url = self._client.format_url(request.url) # type: ignore else: - - request = build_policy_assignments_list_request( - subscription_id=self._config.subscription_id, - template_url=next_link, - ) + # make call to next link with the client's api-version + _parsed_next_link = urlparse(next_link) + _next_request_params = case_insensitive_dict(parse_qs(_parsed_next_link.query)) + _next_request_params["api-version"] = self._config.api_version + request = HttpRequest("GET", urljoin(next_link, _parsed_next_link.path), params=_next_request_params) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore request.method = "GET" return request @@ -1554,10 +1474,8 @@ def extract_data(pipeline_response): def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) response = pipeline_response.http_response @@ -1568,18 +1486,12 @@ def get_next(next_link=None): return pipeline_response + return ItemPaged(get_next, extract_data) - return ItemPaged( - get_next, extract_data - ) - list.metadata = {'url': "/subscriptions/{subscriptionId}/providers/Microsoft.Authorization/policyAssignments"} # type: ignore + list.metadata = {"url": "/subscriptions/{subscriptionId}/providers/Microsoft.Authorization/policyAssignments"} # type: ignore @distributed_trace - def delete_by_id( - self, - policy_assignment_id: str, - **kwargs: Any - ) -> Optional["_models.PolicyAssignment"]: + def delete_by_id(self, policy_assignment_id: str, **kwargs: Any) -> Optional[_models.PolicyAssignment]: """Deletes a policy assignment. This operation deletes the policy with the given ID. Policy assignment IDs have this format: @@ -1591,35 +1503,41 @@ def delete_by_id( (resource). :param policy_assignment_id: The ID of the policy assignment to delete. Use the format - '{scope}/providers/Microsoft.Authorization/policyAssignments/{policyAssignmentName}'. + '{scope}/providers/Microsoft.Authorization/policyAssignments/{policyAssignmentName}'. Required. :type policy_assignment_id: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: PolicyAssignment, or the result of cls(response) + :return: PolicyAssignment or None or the result of cls(response) :rtype: ~azure.mgmt.resource.policy.v2018_05_01.models.PolicyAssignment or None - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType[Optional["_models.PolicyAssignment"]] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + 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', "2018-05-01") # type: str + api_version = kwargs.pop("api_version", _params.pop("api-version", "2018-05-01")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[Optional[_models.PolicyAssignment]] - request = build_policy_assignments_delete_by_id_request( policy_assignment_id=policy_assignment_id, api_version=api_version, - template_url=self.delete_by_id.metadata['url'], + template_url=self.delete_by_id.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200, 204]: @@ -1629,23 +1547,24 @@ def delete_by_id( deserialized = None if response.status_code == 200: - deserialized = self._deserialize('PolicyAssignment', pipeline_response) + deserialized = self._deserialize("PolicyAssignment", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - delete_by_id.metadata = {'url': "/{policyAssignmentId}"} # type: ignore + delete_by_id.metadata = {"url": "/{policyAssignmentId}"} # type: ignore - - @distributed_trace + @overload def create_by_id( self, policy_assignment_id: str, - parameters: "_models.PolicyAssignment", + parameters: _models.PolicyAssignment, + *, + content_type: str = "application/json", **kwargs: Any - ) -> "_models.PolicyAssignment": + ) -> _models.PolicyAssignment: """Creates or updates a policy assignment. This operation creates or updates the policy assignment with the given ID. Policy assignments @@ -1660,41 +1579,121 @@ def create_by_id( '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{resourceProviderNamespace}/[{parentResourcePath}/]{resourceType}/{resourceName}'. :param policy_assignment_id: The ID of the policy assignment to create. Use the format - '{scope}/providers/Microsoft.Authorization/policyAssignments/{policyAssignmentName}'. + '{scope}/providers/Microsoft.Authorization/policyAssignments/{policyAssignmentName}'. Required. :type policy_assignment_id: str - :param parameters: Parameters for policy assignment. + :param parameters: Parameters for policy assignment. Required. :type parameters: ~azure.mgmt.resource.policy.v2018_05_01.models.PolicyAssignment + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: PolicyAssignment or the result of cls(response) + :rtype: ~azure.mgmt.resource.policy.v2018_05_01.models.PolicyAssignment + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + def create_by_id( + self, policy_assignment_id: str, parameters: IO, *, content_type: str = "application/json", **kwargs: Any + ) -> _models.PolicyAssignment: + """Creates or updates a policy assignment. + + This operation creates or updates the policy assignment with the given ID. Policy assignments + made on a scope apply to all resources contained in that scope. For example, when you assign a + policy to a resource group that policy applies to all resources in the group. Policy assignment + IDs have this format: + '{scope}/providers/Microsoft.Authorization/policyAssignments/{policyAssignmentName}'. Valid + scopes are: management group (format: + '/providers/Microsoft.Management/managementGroups/{managementGroup}'), subscription (format: + '/subscriptions/{subscriptionId}'), resource group (format: + '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}', or resource (format: + '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{resourceProviderNamespace}/[{parentResourcePath}/]{resourceType}/{resourceName}'. + + :param policy_assignment_id: The ID of the policy assignment to create. Use the format + '{scope}/providers/Microsoft.Authorization/policyAssignments/{policyAssignmentName}'. Required. + :type policy_assignment_id: str + :param parameters: Parameters for policy assignment. Required. + :type parameters: IO + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: PolicyAssignment, or the result of cls(response) + :return: PolicyAssignment or the result of cls(response) :rtype: ~azure.mgmt.resource.policy.v2018_05_01.models.PolicyAssignment - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace + def create_by_id( + self, policy_assignment_id: str, parameters: Union[_models.PolicyAssignment, IO], **kwargs: Any + ) -> _models.PolicyAssignment: + """Creates or updates a policy assignment. + + This operation creates or updates the policy assignment with the given ID. Policy assignments + made on a scope apply to all resources contained in that scope. For example, when you assign a + policy to a resource group that policy applies to all resources in the group. Policy assignment + IDs have this format: + '{scope}/providers/Microsoft.Authorization/policyAssignments/{policyAssignmentName}'. Valid + scopes are: management group (format: + '/providers/Microsoft.Management/managementGroups/{managementGroup}'), subscription (format: + '/subscriptions/{subscriptionId}'), resource group (format: + '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}', or resource (format: + '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{resourceProviderNamespace}/[{parentResourcePath}/]{resourceType}/{resourceName}'. + + :param policy_assignment_id: The ID of the policy assignment to create. Use the format + '{scope}/providers/Microsoft.Authorization/policyAssignments/{policyAssignmentName}'. Required. + :type policy_assignment_id: str + :param parameters: Parameters for policy assignment. Is either a model type or a IO type. + Required. + :type parameters: ~azure.mgmt.resource.policy.v2018_05_01.models.PolicyAssignment or IO + :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. + Default value is None. + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: PolicyAssignment or the result of cls(response) + :rtype: ~azure.mgmt.resource.policy.v2018_05_01.models.PolicyAssignment + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.PolicyAssignment"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) - api_version = kwargs.pop('api_version', "2018-05-01") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - _json = self._serialize.body(parameters, 'PolicyAssignment') + api_version = kwargs.pop("api_version", _params.pop("api-version", "2018-05-01")) # type: str + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.PolicyAssignment] + + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(parameters, (IO, bytes)): + _content = parameters + else: + _json = self._serialize.body(parameters, "PolicyAssignment") request = build_policy_assignments_create_by_id_request( policy_assignment_id=policy_assignment_id, api_version=api_version, content_type=content_type, json=_json, - template_url=self.create_by_id.metadata['url'], + content=_content, + template_url=self.create_by_id.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [201]: @@ -1702,22 +1701,17 @@ def create_by_id( error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - deserialized = self._deserialize('PolicyAssignment', pipeline_response) + deserialized = self._deserialize("PolicyAssignment", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - create_by_id.metadata = {'url': "/{policyAssignmentId}"} # type: ignore - + create_by_id.metadata = {"url": "/{policyAssignmentId}"} # type: ignore @distributed_trace - def get_by_id( - self, - policy_assignment_id: str, - **kwargs: Any - ) -> "_models.PolicyAssignment": + def get_by_id(self, policy_assignment_id: str, **kwargs: Any) -> _models.PolicyAssignment: """Retrieves the policy assignment with the given ID. The operation retrieves the policy assignment with the given ID. Policy assignment IDs have @@ -1730,35 +1724,41 @@ def get_by_id( '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{resourceProviderNamespace}/[{parentResourcePath}/]{resourceType}/{resourceName}'. :param policy_assignment_id: The ID of the policy assignment to get. Use the format - '{scope}/providers/Microsoft.Authorization/policyAssignments/{policyAssignmentName}'. + '{scope}/providers/Microsoft.Authorization/policyAssignments/{policyAssignmentName}'. Required. :type policy_assignment_id: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: PolicyAssignment, or the result of cls(response) + :return: PolicyAssignment or the result of cls(response) :rtype: ~azure.mgmt.resource.policy.v2018_05_01.models.PolicyAssignment - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.PolicyAssignment"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) - api_version = kwargs.pop('api_version', "2018-05-01") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2018-05-01")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[_models.PolicyAssignment] - request = build_policy_assignments_get_by_id_request( policy_assignment_id=policy_assignment_id, api_version=api_version, - template_url=self.get_by_id.metadata['url'], + template_url=self.get_by_id.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200]: @@ -1766,68 +1766,128 @@ def get_by_id( error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - deserialized = self._deserialize('PolicyAssignment', pipeline_response) + deserialized = self._deserialize("PolicyAssignment", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - get_by_id.metadata = {'url': "/{policyAssignmentId}"} # type: ignore + get_by_id.metadata = {"url": "/{policyAssignmentId}"} # type: ignore -class PolicyDefinitionsOperations(object): - """PolicyDefinitionsOperations operations. - You should not instantiate this class directly. Instead, you should create a Client instance that - instantiates it for you and attaches it as an attribute. +class PolicyDefinitionsOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. - :ivar models: Alias to model classes used in this operation group. - :type models: ~azure.mgmt.resource.policy.v2018_05_01.models - :param client: Client for service requests. - :param config: Configuration of service client. - :param serializer: An object model serializer. - :param deserializer: An object model deserializer. + Instead, you should access the following operations through + :class:`~azure.mgmt.resource.policy.v2018_05_01.PolicyClient`'s + :attr:`policy_definitions` attribute. """ models = _models - def __init__(self, client, config, serializer, deserializer): - self._client = client - self._serialize = serializer - self._deserialize = deserializer - self._config = config + def __init__(self, *args, **kwargs): + input_args = list(args) + self._client = input_args.pop(0) if input_args else kwargs.pop("client") + self._config = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") - @distributed_trace + @overload def create_or_update( self, policy_definition_name: str, - parameters: "_models.PolicyDefinition", + parameters: _models.PolicyDefinition, + *, + content_type: str = "application/json", **kwargs: Any - ) -> "_models.PolicyDefinition": + ) -> _models.PolicyDefinition: """Creates or updates a policy definition in a subscription. This operation creates or updates a policy definition in the given subscription with the given name. - :param policy_definition_name: The name of the policy definition to create. + :param policy_definition_name: The name of the policy definition to create. Required. :type policy_definition_name: str - :param parameters: The policy definition properties. + :param parameters: The policy definition properties. Required. :type parameters: ~azure.mgmt.resource.policy.v2018_05_01.models.PolicyDefinition + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: PolicyDefinition or the result of cls(response) + :rtype: ~azure.mgmt.resource.policy.v2018_05_01.models.PolicyDefinition + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + def create_or_update( + self, policy_definition_name: str, parameters: IO, *, content_type: str = "application/json", **kwargs: Any + ) -> _models.PolicyDefinition: + """Creates or updates a policy definition in a subscription. + + This operation creates or updates a policy definition in the given subscription with the given + name. + + :param policy_definition_name: The name of the policy definition to create. Required. + :type policy_definition_name: str + :param parameters: The policy definition properties. Required. + :type parameters: IO + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: PolicyDefinition or the result of cls(response) + :rtype: ~azure.mgmt.resource.policy.v2018_05_01.models.PolicyDefinition + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace + def create_or_update( + self, policy_definition_name: str, parameters: Union[_models.PolicyDefinition, IO], **kwargs: Any + ) -> _models.PolicyDefinition: + """Creates or updates a policy definition in a subscription. + + This operation creates or updates a policy definition in the given subscription with the given + name. + + :param policy_definition_name: The name of the policy definition to create. Required. + :type policy_definition_name: str + :param parameters: The policy definition properties. Is either a model type or a IO type. + Required. + :type parameters: ~azure.mgmt.resource.policy.v2018_05_01.models.PolicyDefinition or IO + :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. + Default value is None. + :paramtype content_type: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: PolicyDefinition, or the result of cls(response) + :return: PolicyDefinition or the result of cls(response) :rtype: ~azure.mgmt.resource.policy.v2018_05_01.models.PolicyDefinition - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.PolicyDefinition"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) - api_version = kwargs.pop('api_version', "2018-05-01") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - _json = self._serialize.body(parameters, 'PolicyDefinition') + api_version = kwargs.pop("api_version", _params.pop("api-version", "2018-05-01")) # type: str + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.PolicyDefinition] + + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(parameters, (IO, bytes)): + _content = parameters + else: + _json = self._serialize.body(parameters, "PolicyDefinition") request = build_policy_definitions_create_or_update_request( policy_definition_name=policy_definition_name, @@ -1835,72 +1895,77 @@ def create_or_update( api_version=api_version, content_type=content_type, json=_json, - template_url=self.create_or_update.metadata['url'], + content=_content, + template_url=self.create_or_update.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [201]: map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) - deserialized = self._deserialize('PolicyDefinition', pipeline_response) + deserialized = self._deserialize("PolicyDefinition", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - create_or_update.metadata = {'url': "/subscriptions/{subscriptionId}/providers/Microsoft.Authorization/policyDefinitions/{policyDefinitionName}"} # type: ignore - + create_or_update.metadata = {"url": "/subscriptions/{subscriptionId}/providers/Microsoft.Authorization/policyDefinitions/{policyDefinitionName}"} # type: ignore @distributed_trace def delete( # pylint: disable=inconsistent-return-statements - self, - policy_definition_name: str, - **kwargs: Any + self, policy_definition_name: str, **kwargs: Any ) -> None: """Deletes a policy definition in a subscription. This operation deletes the policy definition in the given subscription with the given name. - :param policy_definition_name: The name of the policy definition to delete. + :param policy_definition_name: The name of the policy definition to delete. Required. :type policy_definition_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: None, or the result of cls(response) + :return: None or the result of cls(response) :rtype: None - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType[None] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) - api_version = kwargs.pop('api_version', "2018-05-01") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2018-05-01")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[None] - request = build_policy_definitions_delete_request( policy_definition_name=policy_definition_name, subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.delete.metadata['url'], + template_url=self.delete.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200, 204]: @@ -1910,154 +1975,231 @@ def delete( # pylint: disable=inconsistent-return-statements if cls: return cls(pipeline_response, None, {}) - delete.metadata = {'url': "/subscriptions/{subscriptionId}/providers/Microsoft.Authorization/policyDefinitions/{policyDefinitionName}"} # type: ignore - + delete.metadata = {"url": "/subscriptions/{subscriptionId}/providers/Microsoft.Authorization/policyDefinitions/{policyDefinitionName}"} # type: ignore @distributed_trace - def get( - self, - policy_definition_name: str, - **kwargs: Any - ) -> "_models.PolicyDefinition": + def get(self, policy_definition_name: str, **kwargs: Any) -> _models.PolicyDefinition: """Retrieves a policy definition in a subscription. This operation retrieves the policy definition in the given subscription with the given name. - :param policy_definition_name: The name of the policy definition to get. + :param policy_definition_name: The name of the policy definition to get. Required. :type policy_definition_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: PolicyDefinition, or the result of cls(response) + :return: PolicyDefinition or the result of cls(response) :rtype: ~azure.mgmt.resource.policy.v2018_05_01.models.PolicyDefinition - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.PolicyDefinition"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) - api_version = kwargs.pop('api_version', "2018-05-01") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2018-05-01")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[_models.PolicyDefinition] - request = build_policy_definitions_get_request( policy_definition_name=policy_definition_name, subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.get.metadata['url'], + template_url=self.get.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) - deserialized = self._deserialize('PolicyDefinition', pipeline_response) + deserialized = self._deserialize("PolicyDefinition", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - get.metadata = {'url': "/subscriptions/{subscriptionId}/providers/Microsoft.Authorization/policyDefinitions/{policyDefinitionName}"} # type: ignore - + get.metadata = {"url": "/subscriptions/{subscriptionId}/providers/Microsoft.Authorization/policyDefinitions/{policyDefinitionName}"} # type: ignore @distributed_trace - def get_built_in( - self, - policy_definition_name: str, - **kwargs: Any - ) -> "_models.PolicyDefinition": + def get_built_in(self, policy_definition_name: str, **kwargs: Any) -> _models.PolicyDefinition: """Retrieves a built-in policy definition. This operation retrieves the built-in policy definition with the given name. - :param policy_definition_name: The name of the built-in policy definition to get. + :param policy_definition_name: The name of the built-in policy definition to get. Required. :type policy_definition_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: PolicyDefinition, or the result of cls(response) + :return: PolicyDefinition or the result of cls(response) :rtype: ~azure.mgmt.resource.policy.v2018_05_01.models.PolicyDefinition - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.PolicyDefinition"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) - api_version = kwargs.pop('api_version', "2018-05-01") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2018-05-01")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[_models.PolicyDefinition] - request = build_policy_definitions_get_built_in_request( policy_definition_name=policy_definition_name, api_version=api_version, - template_url=self.get_built_in.metadata['url'], + template_url=self.get_built_in.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) - deserialized = self._deserialize('PolicyDefinition', pipeline_response) + deserialized = self._deserialize("PolicyDefinition", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - get_built_in.metadata = {'url': "/providers/Microsoft.Authorization/policyDefinitions/{policyDefinitionName}"} # type: ignore + get_built_in.metadata = {"url": "/providers/Microsoft.Authorization/policyDefinitions/{policyDefinitionName}"} # type: ignore + + @overload + def create_or_update_at_management_group( + self, + policy_definition_name: str, + management_group_id: str, + parameters: _models.PolicyDefinition, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.PolicyDefinition: + """Creates or updates a policy definition in a management group. + + This operation creates or updates a policy definition in the given management group with the + given name. + + :param policy_definition_name: The name of the policy definition to create. Required. + :type policy_definition_name: str + :param management_group_id: The ID of the management group. Required. + :type management_group_id: str + :param parameters: The policy definition properties. Required. + :type parameters: ~azure.mgmt.resource.policy.v2018_05_01.models.PolicyDefinition + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: PolicyDefinition or the result of cls(response) + :rtype: ~azure.mgmt.resource.policy.v2018_05_01.models.PolicyDefinition + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + def create_or_update_at_management_group( + self, + policy_definition_name: str, + management_group_id: str, + parameters: IO, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.PolicyDefinition: + """Creates or updates a policy definition in a management group. + + This operation creates or updates a policy definition in the given management group with the + given name. + :param policy_definition_name: The name of the policy definition to create. Required. + :type policy_definition_name: str + :param management_group_id: The ID of the management group. Required. + :type management_group_id: str + :param parameters: The policy definition properties. Required. + :type parameters: IO + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: PolicyDefinition or the result of cls(response) + :rtype: ~azure.mgmt.resource.policy.v2018_05_01.models.PolicyDefinition + :raises ~azure.core.exceptions.HttpResponseError: + """ @distributed_trace def create_or_update_at_management_group( self, policy_definition_name: str, management_group_id: str, - parameters: "_models.PolicyDefinition", + parameters: Union[_models.PolicyDefinition, IO], **kwargs: Any - ) -> "_models.PolicyDefinition": + ) -> _models.PolicyDefinition: """Creates or updates a policy definition in a management group. This operation creates or updates a policy definition in the given management group with the given name. - :param policy_definition_name: The name of the policy definition to create. + :param policy_definition_name: The name of the policy definition to create. Required. :type policy_definition_name: str - :param management_group_id: The ID of the management group. + :param management_group_id: The ID of the management group. Required. :type management_group_id: str - :param parameters: The policy definition properties. - :type parameters: ~azure.mgmt.resource.policy.v2018_05_01.models.PolicyDefinition + :param parameters: The policy definition properties. Is either a model type or a IO type. + Required. + :type parameters: ~azure.mgmt.resource.policy.v2018_05_01.models.PolicyDefinition or IO + :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. + Default value is None. + :paramtype content_type: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: PolicyDefinition, or the result of cls(response) + :return: PolicyDefinition or the result of cls(response) :rtype: ~azure.mgmt.resource.policy.v2018_05_01.models.PolicyDefinition - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.PolicyDefinition"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) - api_version = kwargs.pop('api_version', "2018-05-01") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - _json = self._serialize.body(parameters, 'PolicyDefinition') + api_version = kwargs.pop("api_version", _params.pop("api-version", "2018-05-01")) # type: str + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.PolicyDefinition] + + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(parameters, (IO, bytes)): + _content = parameters + else: + _json = self._serialize.body(parameters, "PolicyDefinition") request = build_policy_definitions_create_or_update_at_management_group_request( policy_definition_name=policy_definition_name, @@ -2065,75 +2207,79 @@ def create_or_update_at_management_group( api_version=api_version, content_type=content_type, json=_json, - template_url=self.create_or_update_at_management_group.metadata['url'], + content=_content, + template_url=self.create_or_update_at_management_group.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [201]: map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) - deserialized = self._deserialize('PolicyDefinition', pipeline_response) + deserialized = self._deserialize("PolicyDefinition", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - create_or_update_at_management_group.metadata = {'url': "/providers/Microsoft.Management/managementgroups/{managementGroupId}/providers/Microsoft.Authorization/policyDefinitions/{policyDefinitionName}"} # type: ignore - + create_or_update_at_management_group.metadata = {"url": "/providers/Microsoft.Management/managementgroups/{managementGroupId}/providers/Microsoft.Authorization/policyDefinitions/{policyDefinitionName}"} # type: ignore @distributed_trace def delete_at_management_group( # pylint: disable=inconsistent-return-statements - self, - policy_definition_name: str, - management_group_id: str, - **kwargs: Any + self, policy_definition_name: str, management_group_id: str, **kwargs: Any ) -> None: """Deletes a policy definition in a management group. This operation deletes the policy definition in the given management group with the given name. - :param policy_definition_name: The name of the policy definition to delete. + :param policy_definition_name: The name of the policy definition to delete. Required. :type policy_definition_name: str - :param management_group_id: The ID of the management group. + :param management_group_id: The ID of the management group. Required. :type management_group_id: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: None, or the result of cls(response) + :return: None or the result of cls(response) :rtype: None - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType[None] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + 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', "2018-05-01") # type: str + api_version = kwargs.pop("api_version", _params.pop("api-version", "2018-05-01")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[None] - request = build_policy_definitions_delete_at_management_group_request( policy_definition_name=policy_definition_name, management_group_id=management_group_id, api_version=api_version, - template_url=self.delete_at_management_group.metadata['url'], + template_url=self.delete_at_management_group.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200, 204]: @@ -2143,111 +2289,117 @@ def delete_at_management_group( # pylint: disable=inconsistent-return-statement if cls: return cls(pipeline_response, None, {}) - delete_at_management_group.metadata = {'url': "/providers/Microsoft.Management/managementgroups/{managementGroupId}/providers/Microsoft.Authorization/policyDefinitions/{policyDefinitionName}"} # type: ignore - + delete_at_management_group.metadata = {"url": "/providers/Microsoft.Management/managementgroups/{managementGroupId}/providers/Microsoft.Authorization/policyDefinitions/{policyDefinitionName}"} # type: ignore @distributed_trace def get_at_management_group( - self, - policy_definition_name: str, - management_group_id: str, - **kwargs: Any - ) -> "_models.PolicyDefinition": + self, policy_definition_name: str, management_group_id: str, **kwargs: Any + ) -> _models.PolicyDefinition: """Retrieve a policy definition in a management group. This operation retrieves the policy definition in the given management group with the given name. - :param policy_definition_name: The name of the policy definition to get. + :param policy_definition_name: The name of the policy definition to get. Required. :type policy_definition_name: str - :param management_group_id: The ID of the management group. + :param management_group_id: The ID of the management group. Required. :type management_group_id: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: PolicyDefinition, or the result of cls(response) + :return: PolicyDefinition or the result of cls(response) :rtype: ~azure.mgmt.resource.policy.v2018_05_01.models.PolicyDefinition - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.PolicyDefinition"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) - api_version = kwargs.pop('api_version', "2018-05-01") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2018-05-01")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[_models.PolicyDefinition] - request = build_policy_definitions_get_at_management_group_request( policy_definition_name=policy_definition_name, management_group_id=management_group_id, api_version=api_version, - template_url=self.get_at_management_group.metadata['url'], + template_url=self.get_at_management_group.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) - deserialized = self._deserialize('PolicyDefinition', pipeline_response) + deserialized = self._deserialize("PolicyDefinition", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - get_at_management_group.metadata = {'url': "/providers/Microsoft.Management/managementgroups/{managementGroupId}/providers/Microsoft.Authorization/policyDefinitions/{policyDefinitionName}"} # type: ignore - + get_at_management_group.metadata = {"url": "/providers/Microsoft.Management/managementgroups/{managementGroupId}/providers/Microsoft.Authorization/policyDefinitions/{policyDefinitionName}"} # type: ignore @distributed_trace - def list( - self, - **kwargs: Any - ) -> Iterable["_models.PolicyDefinitionListResult"]: + def list(self, **kwargs: Any) -> Iterable["_models.PolicyDefinition"]: """Retrieves policy definitions in a subscription. This operation retrieves a list of all the policy definitions in a given subscription. :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either PolicyDefinitionListResult or the result of - cls(response) + :return: An iterator like instance of either PolicyDefinition or the result of cls(response) :rtype: - ~azure.core.paging.ItemPaged[~azure.mgmt.resource.policy.v2018_05_01.models.PolicyDefinitionListResult] - :raises: ~azure.core.exceptions.HttpResponseError + ~azure.core.paging.ItemPaged[~azure.mgmt.resource.policy.v2018_05_01.models.PolicyDefinition] + :raises ~azure.core.exceptions.HttpResponseError: """ - api_version = kwargs.pop('api_version', "2018-05-01") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2018-05-01")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[_models.PolicyDefinitionListResult] - cls = kwargs.pop('cls', None) # type: ClsType["_models.PolicyDefinitionListResult"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) + def prepare_request(next_link=None): if not next_link: - + request = build_policy_definitions_list_request( subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.list.metadata['url'], + template_url=self.list.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore else: - - request = build_policy_definitions_list_request( - subscription_id=self._config.subscription_id, - template_url=next_link, - ) + # make call to next link with the client's api-version + _parsed_next_link = urlparse(next_link) + _next_request_params = case_insensitive_dict(parse_qs(_parsed_next_link.query)) + _next_request_params["api-version"] = self._config.api_version + request = HttpRequest("GET", urljoin(next_link, _parsed_next_link.path), params=_next_request_params) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore request.method = "GET" return request @@ -2261,10 +2413,8 @@ def extract_data(pipeline_response): def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) response = pipeline_response.http_response @@ -2274,52 +2424,56 @@ def get_next(next_link=None): return pipeline_response + return ItemPaged(get_next, extract_data) - return ItemPaged( - get_next, extract_data - ) - list.metadata = {'url': "/subscriptions/{subscriptionId}/providers/Microsoft.Authorization/policyDefinitions"} # type: ignore + list.metadata = {"url": "/subscriptions/{subscriptionId}/providers/Microsoft.Authorization/policyDefinitions"} # type: ignore @distributed_trace - def list_built_in( - self, - **kwargs: Any - ) -> Iterable["_models.PolicyDefinitionListResult"]: + def list_built_in(self, **kwargs: Any) -> Iterable["_models.PolicyDefinition"]: """Retrieve built-in policy definitions. This operation retrieves a list of all the built-in policy definitions. :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either PolicyDefinitionListResult or the result of - cls(response) + :return: An iterator like instance of either PolicyDefinition or the result of cls(response) :rtype: - ~azure.core.paging.ItemPaged[~azure.mgmt.resource.policy.v2018_05_01.models.PolicyDefinitionListResult] - :raises: ~azure.core.exceptions.HttpResponseError + ~azure.core.paging.ItemPaged[~azure.mgmt.resource.policy.v2018_05_01.models.PolicyDefinition] + :raises ~azure.core.exceptions.HttpResponseError: """ - api_version = kwargs.pop('api_version', "2018-05-01") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2018-05-01")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[_models.PolicyDefinitionListResult] - cls = kwargs.pop('cls', None) # type: ClsType["_models.PolicyDefinitionListResult"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) + def prepare_request(next_link=None): if not next_link: - + request = build_policy_definitions_list_built_in_request( api_version=api_version, - template_url=self.list_built_in.metadata['url'], + template_url=self.list_built_in.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore else: - - request = build_policy_definitions_list_built_in_request( - template_url=next_link, - ) + # make call to next link with the client's api-version + _parsed_next_link = urlparse(next_link) + _next_request_params = case_insensitive_dict(parse_qs(_parsed_next_link.query)) + _next_request_params["api-version"] = self._config.api_version + request = HttpRequest("GET", urljoin(next_link, _parsed_next_link.path), params=_next_request_params) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore request.method = "GET" return request @@ -2333,10 +2487,8 @@ def extract_data(pipeline_response): def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) response = pipeline_response.http_response @@ -2346,57 +2498,59 @@ def get_next(next_link=None): return pipeline_response + return ItemPaged(get_next, extract_data) - return ItemPaged( - get_next, extract_data - ) - list_built_in.metadata = {'url': "/providers/Microsoft.Authorization/policyDefinitions"} # type: ignore + list_built_in.metadata = {"url": "/providers/Microsoft.Authorization/policyDefinitions"} # type: ignore @distributed_trace - def list_by_management_group( - self, - management_group_id: str, - **kwargs: Any - ) -> Iterable["_models.PolicyDefinitionListResult"]: + def list_by_management_group(self, management_group_id: str, **kwargs: Any) -> Iterable["_models.PolicyDefinition"]: """Retrieve policy definitions in a management group. This operation retrieves a list of all the policy definitions in a given management group. - :param management_group_id: The ID of the management group. + :param management_group_id: The ID of the management group. Required. :type management_group_id: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either PolicyDefinitionListResult or the result of - cls(response) + :return: An iterator like instance of either PolicyDefinition or the result of cls(response) :rtype: - ~azure.core.paging.ItemPaged[~azure.mgmt.resource.policy.v2018_05_01.models.PolicyDefinitionListResult] - :raises: ~azure.core.exceptions.HttpResponseError + ~azure.core.paging.ItemPaged[~azure.mgmt.resource.policy.v2018_05_01.models.PolicyDefinition] + :raises ~azure.core.exceptions.HttpResponseError: """ - api_version = kwargs.pop('api_version', "2018-05-01") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2018-05-01")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[_models.PolicyDefinitionListResult] - cls = kwargs.pop('cls', None) # type: ClsType["_models.PolicyDefinitionListResult"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) + def prepare_request(next_link=None): if not next_link: - + request = build_policy_definitions_list_by_management_group_request( management_group_id=management_group_id, api_version=api_version, - template_url=self.list_by_management_group.metadata['url'], + template_url=self.list_by_management_group.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore else: - - request = build_policy_definitions_list_by_management_group_request( - management_group_id=management_group_id, - template_url=next_link, - ) + # make call to next link with the client's api-version + _parsed_next_link = urlparse(next_link) + _next_request_params = case_insensitive_dict(parse_qs(_parsed_next_link.query)) + _next_request_params["api-version"] = self._config.api_version + request = HttpRequest("GET", urljoin(next_link, _parsed_next_link.path), params=_next_request_params) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore request.method = "GET" return request @@ -2410,10 +2564,8 @@ def extract_data(pipeline_response): def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) response = pipeline_response.http_response @@ -2423,64 +2575,123 @@ def get_next(next_link=None): return pipeline_response + return ItemPaged(get_next, extract_data) - return ItemPaged( - get_next, extract_data - ) - list_by_management_group.metadata = {'url': "/providers/Microsoft.Management/managementgroups/{managementGroupId}/providers/Microsoft.Authorization/policyDefinitions"} # type: ignore -class PolicySetDefinitionsOperations(object): - """PolicySetDefinitionsOperations operations. - - You should not instantiate this class directly. Instead, you should create a Client instance that - instantiates it for you and attaches it as an attribute. - - :ivar models: Alias to model classes used in this operation group. - :type models: ~azure.mgmt.resource.policy.v2018_05_01.models - :param client: Client for service requests. - :param config: Configuration of service client. - :param serializer: An object model serializer. - :param deserializer: An object model deserializer. + list_by_management_group.metadata = {"url": "/providers/Microsoft.Management/managementgroups/{managementGroupId}/providers/Microsoft.Authorization/policyDefinitions"} # type: ignore + + +class PolicySetDefinitionsOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. + + Instead, you should access the following operations through + :class:`~azure.mgmt.resource.policy.v2018_05_01.PolicyClient`'s + :attr:`policy_set_definitions` attribute. """ models = _models - def __init__(self, client, config, serializer, deserializer): - self._client = client - self._serialize = serializer - self._deserialize = deserializer - self._config = config + def __init__(self, *args, **kwargs): + input_args = list(args) + self._client = input_args.pop(0) if input_args else kwargs.pop("client") + self._config = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") - @distributed_trace + @overload def create_or_update( self, policy_set_definition_name: str, - parameters: "_models.PolicySetDefinition", + parameters: _models.PolicySetDefinition, + *, + content_type: str = "application/json", **kwargs: Any - ) -> "_models.PolicySetDefinition": + ) -> _models.PolicySetDefinition: """Creates or updates a policy set definition. This operation creates or updates a policy set definition in the given subscription with the given name. - :param policy_set_definition_name: The name of the policy set definition to create. + :param policy_set_definition_name: The name of the policy set definition to create. Required. :type policy_set_definition_name: str - :param parameters: The policy set definition properties. + :param parameters: The policy set definition properties. Required. :type parameters: ~azure.mgmt.resource.policy.v2018_05_01.models.PolicySetDefinition + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: PolicySetDefinition or the result of cls(response) + :rtype: ~azure.mgmt.resource.policy.v2018_05_01.models.PolicySetDefinition + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + def create_or_update( + self, policy_set_definition_name: str, parameters: IO, *, content_type: str = "application/json", **kwargs: Any + ) -> _models.PolicySetDefinition: + """Creates or updates a policy set definition. + + This operation creates or updates a policy set definition in the given subscription with the + given name. + + :param policy_set_definition_name: The name of the policy set definition to create. Required. + :type policy_set_definition_name: str + :param parameters: The policy set definition properties. Required. + :type parameters: IO + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: PolicySetDefinition or the result of cls(response) + :rtype: ~azure.mgmt.resource.policy.v2018_05_01.models.PolicySetDefinition + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace + def create_or_update( + self, policy_set_definition_name: str, parameters: Union[_models.PolicySetDefinition, IO], **kwargs: Any + ) -> _models.PolicySetDefinition: + """Creates or updates a policy set definition. + + This operation creates or updates a policy set definition in the given subscription with the + given name. + + :param policy_set_definition_name: The name of the policy set definition to create. Required. + :type policy_set_definition_name: str + :param parameters: The policy set definition properties. Is either a model type or a IO type. + Required. + :type parameters: ~azure.mgmt.resource.policy.v2018_05_01.models.PolicySetDefinition or IO + :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. + Default value is None. + :paramtype content_type: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: PolicySetDefinition, or the result of cls(response) + :return: PolicySetDefinition or the result of cls(response) :rtype: ~azure.mgmt.resource.policy.v2018_05_01.models.PolicySetDefinition - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.PolicySetDefinition"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) - api_version = kwargs.pop('api_version', "2018-05-01") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - _json = self._serialize.body(parameters, 'PolicySetDefinition') + api_version = kwargs.pop("api_version", _params.pop("api-version", "2018-05-01")) # type: str + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.PolicySetDefinition] + + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(parameters, (IO, bytes)): + _content = parameters + else: + _json = self._serialize.body(parameters, "PolicySetDefinition") request = build_policy_set_definitions_create_or_update_request( policy_set_definition_name=policy_set_definition_name, @@ -2488,16 +2699,18 @@ def create_or_update( api_version=api_version, content_type=content_type, json=_json, - template_url=self.create_or_update.metadata['url'], + content=_content, + template_url=self.create_or_update.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200, 201]: @@ -2506,59 +2719,62 @@ def create_or_update( raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) if response.status_code == 200: - deserialized = self._deserialize('PolicySetDefinition', pipeline_response) + deserialized = self._deserialize("PolicySetDefinition", pipeline_response) if response.status_code == 201: - deserialized = self._deserialize('PolicySetDefinition', pipeline_response) + deserialized = self._deserialize("PolicySetDefinition", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - create_or_update.metadata = {'url': "/subscriptions/{subscriptionId}/providers/Microsoft.Authorization/policySetDefinitions/{policySetDefinitionName}"} # type: ignore - + create_or_update.metadata = {"url": "/subscriptions/{subscriptionId}/providers/Microsoft.Authorization/policySetDefinitions/{policySetDefinitionName}"} # type: ignore @distributed_trace def delete( # pylint: disable=inconsistent-return-statements - self, - policy_set_definition_name: str, - **kwargs: Any + self, policy_set_definition_name: str, **kwargs: Any ) -> None: """Deletes a policy set definition. This operation deletes the policy set definition in the given subscription with the given name. - :param policy_set_definition_name: The name of the policy set definition to delete. + :param policy_set_definition_name: The name of the policy set definition to delete. Required. :type policy_set_definition_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: None, or the result of cls(response) + :return: None or the result of cls(response) :rtype: None - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType[None] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) - api_version = kwargs.pop('api_version', "2018-05-01") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2018-05-01")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[None] - request = build_policy_set_definitions_delete_request( policy_set_definition_name=policy_set_definition_name, subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.delete.metadata['url'], + template_url=self.delete.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200, 204]: @@ -2569,50 +2785,51 @@ def delete( # pylint: disable=inconsistent-return-statements if cls: return cls(pipeline_response, None, {}) - delete.metadata = {'url': "/subscriptions/{subscriptionId}/providers/Microsoft.Authorization/policySetDefinitions/{policySetDefinitionName}"} # type: ignore - + delete.metadata = {"url": "/subscriptions/{subscriptionId}/providers/Microsoft.Authorization/policySetDefinitions/{policySetDefinitionName}"} # type: ignore @distributed_trace - def get( - self, - policy_set_definition_name: str, - **kwargs: Any - ) -> "_models.PolicySetDefinition": + def get(self, policy_set_definition_name: str, **kwargs: Any) -> _models.PolicySetDefinition: """Retrieves a policy set definition. This operation retrieves the policy set definition in the given subscription with the given name. - :param policy_set_definition_name: The name of the policy set definition to get. + :param policy_set_definition_name: The name of the policy set definition to get. Required. :type policy_set_definition_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: PolicySetDefinition, or the result of cls(response) + :return: PolicySetDefinition or the result of cls(response) :rtype: ~azure.mgmt.resource.policy.v2018_05_01.models.PolicySetDefinition - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.PolicySetDefinition"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) - api_version = kwargs.pop('api_version', "2018-05-01") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2018-05-01")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[_models.PolicySetDefinition] - request = build_policy_set_definitions_get_request( policy_set_definition_name=policy_set_definition_name, subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.get.metadata['url'], + template_url=self.get.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200]: @@ -2620,55 +2837,56 @@ def get( error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - deserialized = self._deserialize('PolicySetDefinition', pipeline_response) + deserialized = self._deserialize("PolicySetDefinition", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - get.metadata = {'url': "/subscriptions/{subscriptionId}/providers/Microsoft.Authorization/policySetDefinitions/{policySetDefinitionName}"} # type: ignore - + get.metadata = {"url": "/subscriptions/{subscriptionId}/providers/Microsoft.Authorization/policySetDefinitions/{policySetDefinitionName}"} # type: ignore @distributed_trace - def get_built_in( - self, - policy_set_definition_name: str, - **kwargs: Any - ) -> "_models.PolicySetDefinition": + def get_built_in(self, policy_set_definition_name: str, **kwargs: Any) -> _models.PolicySetDefinition: """Retrieves a built in policy set definition. This operation retrieves the built-in policy set definition with the given name. - :param policy_set_definition_name: The name of the policy set definition to get. + :param policy_set_definition_name: The name of the policy set definition to get. Required. :type policy_set_definition_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: PolicySetDefinition, or the result of cls(response) + :return: PolicySetDefinition or the result of cls(response) :rtype: ~azure.mgmt.resource.policy.v2018_05_01.models.PolicySetDefinition - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.PolicySetDefinition"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) - api_version = kwargs.pop('api_version', "2018-05-01") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2018-05-01")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[_models.PolicySetDefinition] - request = build_policy_set_definitions_get_built_in_request( policy_set_definition_name=policy_set_definition_name, api_version=api_version, - template_url=self.get_built_in.metadata['url'], + template_url=self.get_built_in.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200]: @@ -2676,58 +2894,62 @@ def get_built_in( error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - deserialized = self._deserialize('PolicySetDefinition', pipeline_response) + deserialized = self._deserialize("PolicySetDefinition", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - get_built_in.metadata = {'url': "/providers/Microsoft.Authorization/policySetDefinitions/{policySetDefinitionName}"} # type: ignore - + get_built_in.metadata = {"url": "/providers/Microsoft.Authorization/policySetDefinitions/{policySetDefinitionName}"} # type: ignore @distributed_trace - def list( - self, - **kwargs: Any - ) -> Iterable["_models.PolicySetDefinitionListResult"]: + def list(self, **kwargs: Any) -> Iterable["_models.PolicySetDefinition"]: """Retrieves the policy set definitions for a subscription. This operation retrieves a list of all the policy set definitions in the given subscription. :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either PolicySetDefinitionListResult or the result of - cls(response) + :return: An iterator like instance of either PolicySetDefinition or the result of cls(response) :rtype: - ~azure.core.paging.ItemPaged[~azure.mgmt.resource.policy.v2018_05_01.models.PolicySetDefinitionListResult] - :raises: ~azure.core.exceptions.HttpResponseError + ~azure.core.paging.ItemPaged[~azure.mgmt.resource.policy.v2018_05_01.models.PolicySetDefinition] + :raises ~azure.core.exceptions.HttpResponseError: """ - api_version = kwargs.pop('api_version', "2018-05-01") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2018-05-01")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[_models.PolicySetDefinitionListResult] - cls = kwargs.pop('cls', None) # type: ClsType["_models.PolicySetDefinitionListResult"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) + def prepare_request(next_link=None): if not next_link: - + request = build_policy_set_definitions_list_request( subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.list.metadata['url'], + template_url=self.list.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore else: - - request = build_policy_set_definitions_list_request( - subscription_id=self._config.subscription_id, - template_url=next_link, - ) + # make call to next link with the client's api-version + _parsed_next_link = urlparse(next_link) + _next_request_params = case_insensitive_dict(parse_qs(_parsed_next_link.query)) + _next_request_params["api-version"] = self._config.api_version + request = HttpRequest("GET", urljoin(next_link, _parsed_next_link.path), params=_next_request_params) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore request.method = "GET" return request @@ -2741,10 +2963,8 @@ def extract_data(pipeline_response): def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) response = pipeline_response.http_response @@ -2755,52 +2975,56 @@ def get_next(next_link=None): return pipeline_response + return ItemPaged(get_next, extract_data) - return ItemPaged( - get_next, extract_data - ) - list.metadata = {'url': "/subscriptions/{subscriptionId}/providers/Microsoft.Authorization/policySetDefinitions"} # type: ignore + list.metadata = {"url": "/subscriptions/{subscriptionId}/providers/Microsoft.Authorization/policySetDefinitions"} # type: ignore @distributed_trace - def list_built_in( - self, - **kwargs: Any - ) -> Iterable["_models.PolicySetDefinitionListResult"]: + def list_built_in(self, **kwargs: Any) -> Iterable["_models.PolicySetDefinition"]: """Retrieves built-in policy set definitions. This operation retrieves a list of all the built-in policy set definitions. :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either PolicySetDefinitionListResult or the result of - cls(response) + :return: An iterator like instance of either PolicySetDefinition or the result of cls(response) :rtype: - ~azure.core.paging.ItemPaged[~azure.mgmt.resource.policy.v2018_05_01.models.PolicySetDefinitionListResult] - :raises: ~azure.core.exceptions.HttpResponseError + ~azure.core.paging.ItemPaged[~azure.mgmt.resource.policy.v2018_05_01.models.PolicySetDefinition] + :raises ~azure.core.exceptions.HttpResponseError: """ - api_version = kwargs.pop('api_version', "2018-05-01") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2018-05-01")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[_models.PolicySetDefinitionListResult] - cls = kwargs.pop('cls', None) # type: ClsType["_models.PolicySetDefinitionListResult"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) + def prepare_request(next_link=None): if not next_link: - + request = build_policy_set_definitions_list_built_in_request( api_version=api_version, - template_url=self.list_built_in.metadata['url'], + template_url=self.list_built_in.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore else: - - request = build_policy_set_definitions_list_built_in_request( - template_url=next_link, - ) + # make call to next link with the client's api-version + _parsed_next_link = urlparse(next_link) + _next_request_params = case_insensitive_dict(parse_qs(_parsed_next_link.query)) + _next_request_params["api-version"] = self._config.api_version + request = HttpRequest("GET", urljoin(next_link, _parsed_next_link.path), params=_next_request_params) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore request.method = "GET" return request @@ -2814,10 +3038,8 @@ def extract_data(pipeline_response): def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) response = pipeline_response.http_response @@ -2828,46 +3050,120 @@ def get_next(next_link=None): return pipeline_response + return ItemPaged(get_next, extract_data) - return ItemPaged( - get_next, extract_data - ) - list_built_in.metadata = {'url': "/providers/Microsoft.Authorization/policySetDefinitions"} # type: ignore + list_built_in.metadata = {"url": "/providers/Microsoft.Authorization/policySetDefinitions"} # type: ignore - @distributed_trace + @overload def create_or_update_at_management_group( self, policy_set_definition_name: str, management_group_id: str, - parameters: "_models.PolicySetDefinition", + parameters: _models.PolicySetDefinition, + *, + content_type: str = "application/json", **kwargs: Any - ) -> "_models.PolicySetDefinition": + ) -> _models.PolicySetDefinition: """Creates or updates a policy set definition. This operation creates or updates a policy set definition in the given management group with the given name. - :param policy_set_definition_name: The name of the policy set definition to create. + :param policy_set_definition_name: The name of the policy set definition to create. Required. :type policy_set_definition_name: str - :param management_group_id: The ID of the management group. + :param management_group_id: The ID of the management group. Required. :type management_group_id: str - :param parameters: The policy set definition properties. + :param parameters: The policy set definition properties. Required. :type parameters: ~azure.mgmt.resource.policy.v2018_05_01.models.PolicySetDefinition + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: PolicySetDefinition or the result of cls(response) + :rtype: ~azure.mgmt.resource.policy.v2018_05_01.models.PolicySetDefinition + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + def create_or_update_at_management_group( + self, + policy_set_definition_name: str, + management_group_id: str, + parameters: IO, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.PolicySetDefinition: + """Creates or updates a policy set definition. + + This operation creates or updates a policy set definition in the given management group with + the given name. + + :param policy_set_definition_name: The name of the policy set definition to create. Required. + :type policy_set_definition_name: str + :param management_group_id: The ID of the management group. Required. + :type management_group_id: str + :param parameters: The policy set definition properties. Required. + :type parameters: IO + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: PolicySetDefinition or the result of cls(response) + :rtype: ~azure.mgmt.resource.policy.v2018_05_01.models.PolicySetDefinition + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace + def create_or_update_at_management_group( + self, + policy_set_definition_name: str, + management_group_id: str, + parameters: Union[_models.PolicySetDefinition, IO], + **kwargs: Any + ) -> _models.PolicySetDefinition: + """Creates or updates a policy set definition. + + This operation creates or updates a policy set definition in the given management group with + the given name. + + :param policy_set_definition_name: The name of the policy set definition to create. Required. + :type policy_set_definition_name: str + :param management_group_id: The ID of the management group. Required. + :type management_group_id: str + :param parameters: The policy set definition properties. Is either a model type or a IO type. + Required. + :type parameters: ~azure.mgmt.resource.policy.v2018_05_01.models.PolicySetDefinition or IO + :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. + Default value is None. + :paramtype content_type: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: PolicySetDefinition, or the result of cls(response) + :return: PolicySetDefinition or the result of cls(response) :rtype: ~azure.mgmt.resource.policy.v2018_05_01.models.PolicySetDefinition - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.PolicySetDefinition"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', "2018-05-01") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + api_version = kwargs.pop("api_version", _params.pop("api-version", "2018-05-01")) # type: str + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.PolicySetDefinition] - _json = self._serialize.body(parameters, 'PolicySetDefinition') + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(parameters, (IO, bytes)): + _content = parameters + else: + _json = self._serialize.body(parameters, "PolicySetDefinition") request = build_policy_set_definitions_create_or_update_at_management_group_request( policy_set_definition_name=policy_set_definition_name, @@ -2875,16 +3171,18 @@ def create_or_update_at_management_group( api_version=api_version, content_type=content_type, json=_json, - template_url=self.create_or_update_at_management_group.metadata['url'], + content=_content, + template_url=self.create_or_update_at_management_group.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200, 201]: @@ -2893,63 +3191,65 @@ def create_or_update_at_management_group( raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) if response.status_code == 200: - deserialized = self._deserialize('PolicySetDefinition', pipeline_response) + deserialized = self._deserialize("PolicySetDefinition", pipeline_response) if response.status_code == 201: - deserialized = self._deserialize('PolicySetDefinition', pipeline_response) + deserialized = self._deserialize("PolicySetDefinition", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - create_or_update_at_management_group.metadata = {'url': "/providers/Microsoft.Management/managementgroups/{managementGroupId}/providers/Microsoft.Authorization/policySetDefinitions/{policySetDefinitionName}"} # type: ignore - + create_or_update_at_management_group.metadata = {"url": "/providers/Microsoft.Management/managementgroups/{managementGroupId}/providers/Microsoft.Authorization/policySetDefinitions/{policySetDefinitionName}"} # type: ignore @distributed_trace def delete_at_management_group( # pylint: disable=inconsistent-return-statements - self, - policy_set_definition_name: str, - management_group_id: str, - **kwargs: Any + self, policy_set_definition_name: str, management_group_id: str, **kwargs: Any ) -> None: """Deletes a policy set definition. This operation deletes the policy set definition in the given management group with the given name. - :param policy_set_definition_name: The name of the policy set definition to delete. + :param policy_set_definition_name: The name of the policy set definition to delete. Required. :type policy_set_definition_name: str - :param management_group_id: The ID of the management group. + :param management_group_id: The ID of the management group. Required. :type management_group_id: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: None, or the result of cls(response) + :return: None or the result of cls(response) :rtype: None - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType[None] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) - api_version = kwargs.pop('api_version', "2018-05-01") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2018-05-01")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[None] - request = build_policy_set_definitions_delete_at_management_group_request( policy_set_definition_name=policy_set_definition_name, management_group_id=management_group_id, api_version=api_version, - template_url=self.delete_at_management_group.metadata['url'], + template_url=self.delete_at_management_group.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200, 204]: @@ -2960,53 +3260,55 @@ def delete_at_management_group( # pylint: disable=inconsistent-return-statement if cls: return cls(pipeline_response, None, {}) - delete_at_management_group.metadata = {'url': "/providers/Microsoft.Management/managementgroups/{managementGroupId}/providers/Microsoft.Authorization/policySetDefinitions/{policySetDefinitionName}"} # type: ignore - + delete_at_management_group.metadata = {"url": "/providers/Microsoft.Management/managementgroups/{managementGroupId}/providers/Microsoft.Authorization/policySetDefinitions/{policySetDefinitionName}"} # type: ignore @distributed_trace def get_at_management_group( - self, - policy_set_definition_name: str, - management_group_id: str, - **kwargs: Any - ) -> "_models.PolicySetDefinition": + self, policy_set_definition_name: str, management_group_id: str, **kwargs: Any + ) -> _models.PolicySetDefinition: """Retrieves a policy set definition. This operation retrieves the policy set definition in the given management group with the given name. - :param policy_set_definition_name: The name of the policy set definition to get. + :param policy_set_definition_name: The name of the policy set definition to get. Required. :type policy_set_definition_name: str - :param management_group_id: The ID of the management group. + :param management_group_id: The ID of the management group. Required. :type management_group_id: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: PolicySetDefinition, or the result of cls(response) + :return: PolicySetDefinition or the result of cls(response) :rtype: ~azure.mgmt.resource.policy.v2018_05_01.models.PolicySetDefinition - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.PolicySetDefinition"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + 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', "2018-05-01") # type: str + api_version = kwargs.pop("api_version", _params.pop("api-version", "2018-05-01")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[_models.PolicySetDefinition] - request = build_policy_set_definitions_get_at_management_group_request( policy_set_definition_name=policy_set_definition_name, management_group_id=management_group_id, api_version=api_version, - template_url=self.get_at_management_group.metadata['url'], + template_url=self.get_at_management_group.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200]: @@ -3014,62 +3316,67 @@ def get_at_management_group( error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - deserialized = self._deserialize('PolicySetDefinition', pipeline_response) + deserialized = self._deserialize("PolicySetDefinition", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - get_at_management_group.metadata = {'url': "/providers/Microsoft.Management/managementgroups/{managementGroupId}/providers/Microsoft.Authorization/policySetDefinitions/{policySetDefinitionName}"} # type: ignore - + get_at_management_group.metadata = {"url": "/providers/Microsoft.Management/managementgroups/{managementGroupId}/providers/Microsoft.Authorization/policySetDefinitions/{policySetDefinitionName}"} # type: ignore @distributed_trace def list_by_management_group( - self, - management_group_id: str, - **kwargs: Any - ) -> Iterable["_models.PolicySetDefinitionListResult"]: + self, management_group_id: str, **kwargs: Any + ) -> Iterable["_models.PolicySetDefinition"]: """Retrieves all policy set definitions in management group. This operation retrieves a list of all the a policy set definition in the given management group. - :param management_group_id: The ID of the management group. + :param management_group_id: The ID of the management group. Required. :type management_group_id: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either PolicySetDefinitionListResult or the result of - cls(response) + :return: An iterator like instance of either PolicySetDefinition or the result of cls(response) :rtype: - ~azure.core.paging.ItemPaged[~azure.mgmt.resource.policy.v2018_05_01.models.PolicySetDefinitionListResult] - :raises: ~azure.core.exceptions.HttpResponseError + ~azure.core.paging.ItemPaged[~azure.mgmt.resource.policy.v2018_05_01.models.PolicySetDefinition] + :raises ~azure.core.exceptions.HttpResponseError: """ - api_version = kwargs.pop('api_version', "2018-05-01") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2018-05-01")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[_models.PolicySetDefinitionListResult] - cls = kwargs.pop('cls', None) # type: ClsType["_models.PolicySetDefinitionListResult"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) + def prepare_request(next_link=None): if not next_link: - + request = build_policy_set_definitions_list_by_management_group_request( management_group_id=management_group_id, api_version=api_version, - template_url=self.list_by_management_group.metadata['url'], + template_url=self.list_by_management_group.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore else: - - request = build_policy_set_definitions_list_by_management_group_request( - management_group_id=management_group_id, - template_url=next_link, - ) + # make call to next link with the client's api-version + _parsed_next_link = urlparse(next_link) + _next_request_params = case_insensitive_dict(parse_qs(_parsed_next_link.query)) + _next_request_params["api-version"] = self._config.api_version + request = HttpRequest("GET", urljoin(next_link, _parsed_next_link.path), params=_next_request_params) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore request.method = "GET" return request @@ -3083,10 +3390,8 @@ def extract_data(pipeline_response): def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) response = pipeline_response.http_response @@ -3097,8 +3402,6 @@ def get_next(next_link=None): return pipeline_response + return ItemPaged(get_next, extract_data) - return ItemPaged( - get_next, extract_data - ) - list_by_management_group.metadata = {'url': "/providers/Microsoft.Management/managementgroups/{managementGroupId}/providers/Microsoft.Authorization/policySetDefinitions"} # type: ignore + list_by_management_group.metadata = {"url": "/providers/Microsoft.Management/managementgroups/{managementGroupId}/providers/Microsoft.Authorization/policySetDefinitions"} # type: ignore diff --git a/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/policy/v2018_05_01/operations/_patch.py b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/policy/v2018_05_01/operations/_patch.py new file mode 100644 index 0000000000000..f7dd32510333d --- /dev/null +++ b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/policy/v2018_05_01/operations/_patch.py @@ -0,0 +1,20 @@ +# ------------------------------------ +# Copyright (c) Microsoft Corporation. +# Licensed under the MIT License. +# ------------------------------------ +"""Customize generated code here. + +Follow our quickstart for examples: https://aka.ms/azsdk/python/dpcodegen/python/customize +""" +from typing import List + +__all__: List[str] = [] # Add all objects you want publicly available to users at this package level + + +def patch_sdk(): + """Do not remove from this file. + + `patch_sdk` is a last resort escape hatch that allows you to do customizations + you can't accomplish using the techniques described in + https://aka.ms/azsdk/python/dpcodegen/python/customize + """ diff --git a/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/policy/v2019_01_01/__init__.py b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/policy/v2019_01_01/__init__.py index 89180ab440872..bb1ffe59afae7 100644 --- a/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/policy/v2019_01_01/__init__.py +++ b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/policy/v2019_01_01/__init__.py @@ -10,9 +10,15 @@ from ._version import VERSION __version__ = VERSION -__all__ = ['PolicyClient'] -# `._patch.py` is used for handwritten extensions to the generated code -# Example: https://github.com/Azure/azure-sdk-for-python/blob/main/doc/dev/customize_code/how-to-patch-sdk-code.md -from ._patch import patch_sdk -patch_sdk() +try: + from ._patch import __all__ as _patch_all + from ._patch import * # type: ignore # pylint: disable=unused-wildcard-import +except ImportError: + _patch_all = [] +from ._patch import patch_sdk as _patch_sdk + +__all__ = ["PolicyClient"] +__all__.extend([p for p in _patch_all if p not in __all__]) + +_patch_sdk() diff --git a/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/policy/v2019_01_01/_configuration.py b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/policy/v2019_01_01/_configuration.py index ae359cb86cd3e..c4c7c566ae11c 100644 --- a/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/policy/v2019_01_01/_configuration.py +++ b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/policy/v2019_01_01/_configuration.py @@ -25,23 +25,18 @@ class PolicyClientConfiguration(Configuration): # pylint: disable=too-many-inst Note that all parameters used to create this instance are saved as instance attributes. - :param credential: Credential needed for the client to connect to Azure. + :param credential: Credential needed for the client to connect to Azure. Required. :type credential: ~azure.core.credentials.TokenCredential - :param subscription_id: The ID of the target subscription. + :param subscription_id: The ID of the target subscription. Required. :type subscription_id: str :keyword api_version: Api Version. Default value is "2019-01-01". Note that overriding this default value may result in unsupported behavior. :paramtype api_version: str """ - def __init__( - self, - credential: "TokenCredential", - subscription_id: str, - **kwargs: Any - ) -> None: + def __init__(self, credential: "TokenCredential", subscription_id: str, **kwargs: Any) -> None: super(PolicyClientConfiguration, self).__init__(**kwargs) - api_version = kwargs.pop('api_version', "2019-01-01") # type: str + api_version = kwargs.pop("api_version", "2019-01-01") # type: str if credential is None: raise ValueError("Parameter 'credential' must not be None.") @@ -51,23 +46,24 @@ def __init__( self.credential = credential self.subscription_id = subscription_id self.api_version = api_version - self.credential_scopes = kwargs.pop('credential_scopes', ['https://management.azure.com/.default']) - kwargs.setdefault('sdk_moniker', 'mgmt-resource/{}'.format(VERSION)) + self.credential_scopes = kwargs.pop("credential_scopes", ["https://management.azure.com/.default"]) + kwargs.setdefault("sdk_moniker", "mgmt-resource/{}".format(VERSION)) self._configure(**kwargs) def _configure( - self, - **kwargs # type: Any + self, **kwargs # type: Any ): # type: (...) -> 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) - self.logging_policy = kwargs.get('logging_policy') or policies.NetworkTraceLoggingPolicy(**kwargs) - self.http_logging_policy = kwargs.get('http_logging_policy') or ARMHttpLoggingPolicy(**kwargs) - self.retry_policy = kwargs.get('retry_policy') or policies.RetryPolicy(**kwargs) - self.custom_hook_policy = kwargs.get('custom_hook_policy') or policies.CustomHookPolicy(**kwargs) - self.redirect_policy = kwargs.get('redirect_policy') or policies.RedirectPolicy(**kwargs) - self.authentication_policy = kwargs.get('authentication_policy') + 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) + self.logging_policy = kwargs.get("logging_policy") or policies.NetworkTraceLoggingPolicy(**kwargs) + self.http_logging_policy = kwargs.get("http_logging_policy") or ARMHttpLoggingPolicy(**kwargs) + self.retry_policy = kwargs.get("retry_policy") or policies.RetryPolicy(**kwargs) + self.custom_hook_policy = kwargs.get("custom_hook_policy") or policies.CustomHookPolicy(**kwargs) + self.redirect_policy = kwargs.get("redirect_policy") or policies.RedirectPolicy(**kwargs) + self.authentication_policy = kwargs.get("authentication_policy") if self.credential and not self.authentication_policy: - self.authentication_policy = ARMChallengeAuthenticationPolicy(self.credential, *self.credential_scopes, **kwargs) + self.authentication_policy = ARMChallengeAuthenticationPolicy( + self.credential, *self.credential_scopes, **kwargs + ) diff --git a/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/policy/v2019_01_01/_metadata.json b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/policy/v2019_01_01/_metadata.json index 18fc11059b01b..adf32292ec051 100644 --- a/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/policy/v2019_01_01/_metadata.json +++ b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/policy/v2019_01_01/_metadata.json @@ -10,20 +10,20 @@ "azure_arm": true, "has_lro_operations": false, "client_side_validation": false, - "sync_imports": "{\"typing\": {\"azurecore\": {\"azure.core.credentials\": [\"TokenCredential\"]}}, \"regular\": {\"azurecore\": {\"azure.profiles\": [\"KnownProfiles\", \"ProfileDefinition\"], \"azure.profiles.multiapiclient\": [\"MultiApiClientMixin\"], \"azure.mgmt.core\": [\"ARMPipelineClient\"]}, \"local\": {\"._configuration\": [\"PolicyClientConfiguration\"]}, \"thirdparty\": {\"msrest\": [\"Deserializer\", \"Serializer\"]}}, \"conditional\": {\"stdlib\": {\"typing\": [\"Any\", \"Optional\"]}}}", - "async_imports": "{\"typing\": {\"azurecore\": {\"azure.core.credentials_async\": [\"AsyncTokenCredential\"], \"azure.core.credentials\": [\"TokenCredential\"]}}, \"regular\": {\"azurecore\": {\"azure.profiles\": [\"KnownProfiles\", \"ProfileDefinition\"], \"azure.profiles.multiapiclient\": [\"MultiApiClientMixin\"], \"azure.mgmt.core\": [\"AsyncARMPipelineClient\"]}, \"local\": {\"._configuration\": [\"PolicyClientConfiguration\"]}, \"thirdparty\": {\"msrest\": [\"Deserializer\", \"Serializer\"]}}, \"conditional\": {\"stdlib\": {\"typing\": [\"Any\", \"Optional\"]}}}" + "sync_imports": "{\"conditional\": {\"stdlib\": {\"typing\": [\"Any\", \"Optional\"]}}, \"regular\": {\"azurecore\": {\"azure.mgmt.core\": [\"ARMPipelineClient\"], \"azure.profiles\": [\"KnownProfiles\", \"ProfileDefinition\"], \"azure.profiles.multiapiclient\": [\"MultiApiClientMixin\"]}, \"local\": {\"._configuration\": [\"PolicyClientConfiguration\"], \".._serialization\": [\"Deserializer\", \"Serializer\"]}}, \"typing\": {\"azurecore\": {\"azure.core.credentials\": [\"TokenCredential\"]}}}", + "async_imports": "{\"conditional\": {\"stdlib\": {\"typing\": [\"Any\", \"Optional\"]}}, \"regular\": {\"azurecore\": {\"azure.mgmt.core\": [\"AsyncARMPipelineClient\"], \"azure.profiles\": [\"KnownProfiles\", \"ProfileDefinition\"], \"azure.profiles.multiapiclient\": [\"MultiApiClientMixin\"]}, \"local\": {\"._configuration\": [\"PolicyClientConfiguration\"], \"..._serialization\": [\"Deserializer\", \"Serializer\"]}}, \"typing\": {\"azurecore\": {\"azure.core.credentials_async\": [\"AsyncTokenCredential\"]}}}" }, "global_parameters": { "sync": { "credential": { - "signature": "credential, # type: \"TokenCredential\"", - "description": "Credential needed for the client to connect to Azure.", + "signature": "credential: \"TokenCredential\",", + "description": "Credential needed for the client to connect to Azure. Required.", "docstring_type": "~azure.core.credentials.TokenCredential", "required": true }, "subscription_id": { - "signature": "subscription_id, # type: str", - "description": "The ID of the target subscription.", + "signature": "subscription_id: str,", + "description": "The ID of the target subscription. Required.", "docstring_type": "str", "required": true } @@ -31,13 +31,13 @@ "async": { "credential": { "signature": "credential: \"AsyncTokenCredential\",", - "description": "Credential needed for the client to connect to Azure.", + "description": "Credential needed for the client to connect to Azure. Required.", "docstring_type": "~azure.core.credentials_async.AsyncTokenCredential", "required": true }, "subscription_id": { "signature": "subscription_id: str,", - "description": "The ID of the target subscription.", + "description": "The ID of the target subscription. Required.", "docstring_type": "str", "required": true } @@ -54,7 +54,7 @@ "required": false }, "base_url": { - "signature": "base_url=\"https://management.azure.com\", # type: str", + "signature": "base_url: str = \"https://management.azure.com\",", "description": "Service URL", "docstring_type": "str", "required": false diff --git a/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/policy/v2019_01_01/_patch.py b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/policy/v2019_01_01/_patch.py index 74e48ecd07cf3..f99e77fef9861 100644 --- a/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/policy/v2019_01_01/_patch.py +++ b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/policy/v2019_01_01/_patch.py @@ -28,4 +28,4 @@ # This file is used for handwritten extensions to the generated code. Example: # https://github.com/Azure/azure-sdk-for-python/blob/main/doc/dev/customize_code/how-to-patch-sdk-code.md def patch_sdk(): - pass \ No newline at end of file + pass diff --git a/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/policy/v2019_01_01/_policy_client.py b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/policy/v2019_01_01/_policy_client.py index 6048f644c0f90..92e6dc14bd2d3 100644 --- a/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/policy/v2019_01_01/_policy_client.py +++ b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/policy/v2019_01_01/_policy_client.py @@ -9,12 +9,11 @@ from copy import deepcopy from typing import Any, TYPE_CHECKING -from msrest import Deserializer, Serializer - from azure.core.rest import HttpRequest, HttpResponse from azure.mgmt.core import ARMPipelineClient from . import models +from .._serialization import Deserializer, Serializer from ._configuration import PolicyClientConfiguration from .operations import PolicyAssignmentsOperations, PolicyDefinitionsOperations, PolicySetDefinitionsOperations @@ -22,7 +21,8 @@ # pylint: disable=unused-import,ungrouped-imports from azure.core.credentials import TokenCredential -class PolicyClient: + +class PolicyClient: # pylint: disable=client-accepts-api-version-keyword """To manage and control access to your resources, you can define customized policies and assign them at a scope. @@ -35,9 +35,9 @@ class PolicyClient: :ivar policy_set_definitions: PolicySetDefinitionsOperations operations :vartype policy_set_definitions: azure.mgmt.resource.policy.v2019_01_01.operations.PolicySetDefinitionsOperations - :param credential: Credential needed for the client to connect to Azure. + :param credential: Credential needed for the client to connect to Azure. Required. :type credential: ~azure.core.credentials.TokenCredential - :param subscription_id: The ID of the target subscription. + :param subscription_id: The ID of the target subscription. Required. :type subscription_id: str :param base_url: Service URL. Default value is "https://management.azure.com". :type base_url: str @@ -60,16 +60,17 @@ def __init__( self._serialize = Serializer(client_models) self._deserialize = Deserializer(client_models) self._serialize.client_side_validation = False - self.policy_assignments = PolicyAssignmentsOperations(self._client, self._config, self._serialize, self._deserialize) - self.policy_definitions = PolicyDefinitionsOperations(self._client, self._config, self._serialize, self._deserialize) - self.policy_set_definitions = PolicySetDefinitionsOperations(self._client, self._config, self._serialize, self._deserialize) - - - def _send_request( - self, - request: HttpRequest, - **kwargs: Any - ) -> HttpResponse: + self.policy_assignments = PolicyAssignmentsOperations( + self._client, self._config, self._serialize, self._deserialize + ) + self.policy_definitions = PolicyDefinitionsOperations( + self._client, self._config, self._serialize, self._deserialize + ) + self.policy_set_definitions = PolicySetDefinitionsOperations( + self._client, self._config, self._serialize, self._deserialize + ) + + def _send_request(self, request: HttpRequest, **kwargs: Any) -> HttpResponse: """Runs the network request through the client's chained policies. >>> from azure.core.rest import HttpRequest @@ -78,7 +79,7 @@ def _send_request( >>> response = client._send_request(request) - For more information on this code flow, see https://aka.ms/azsdk/python/protocol/quickstart + For more information on this code flow, see https://aka.ms/azsdk/dpcodegen/python/send_request :param request: The network request you want to make. Required. :type request: ~azure.core.rest.HttpRequest diff --git a/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/policy/v2019_01_01/_vendor.py b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/policy/v2019_01_01/_vendor.py index 138f663c53a4e..9aad73fc743e7 100644 --- a/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/policy/v2019_01_01/_vendor.py +++ b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/policy/v2019_01_01/_vendor.py @@ -7,6 +7,7 @@ from azure.core.pipeline.transport import HttpRequest + def _convert_request(request, files=None): data = request.content if not files else None request = HttpRequest(method=request.method, url=request.url, headers=request.headers, data=data) @@ -14,6 +15,7 @@ def _convert_request(request, files=None): request.set_formdata_body(files) return request + def _format_url_section(template, **kwargs): components = template.split("/") while components: @@ -21,7 +23,5 @@ def _format_url_section(template, **kwargs): 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 - ] + components = [c for c in formatted_components if "{}".format(key.args[0]) not in c] template = "/".join(components) diff --git a/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/policy/v2019_01_01/_version.py b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/policy/v2019_01_01/_version.py index a012ac01c480c..e5754a47ce68f 100644 --- a/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/policy/v2019_01_01/_version.py +++ b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/policy/v2019_01_01/_version.py @@ -6,4 +6,4 @@ # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -VERSION = "21.1.0" +VERSION = "1.0.0b1" diff --git a/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/policy/v2019_01_01/aio/__init__.py b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/policy/v2019_01_01/aio/__init__.py index 2784ce3f14bf5..4622bf1f396a7 100644 --- a/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/policy/v2019_01_01/aio/__init__.py +++ b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/policy/v2019_01_01/aio/__init__.py @@ -7,9 +7,15 @@ # -------------------------------------------------------------------------- from ._policy_client import PolicyClient -__all__ = ['PolicyClient'] -# `._patch.py` is used for handwritten extensions to the generated code -# Example: https://github.com/Azure/azure-sdk-for-python/blob/main/doc/dev/customize_code/how-to-patch-sdk-code.md -from ._patch import patch_sdk -patch_sdk() +try: + from ._patch import __all__ as _patch_all + from ._patch import * # type: ignore # pylint: disable=unused-wildcard-import +except ImportError: + _patch_all = [] +from ._patch import patch_sdk as _patch_sdk + +__all__ = ["PolicyClient"] +__all__.extend([p for p in _patch_all if p not in __all__]) + +_patch_sdk() diff --git a/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/policy/v2019_01_01/aio/_configuration.py b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/policy/v2019_01_01/aio/_configuration.py index faac0b0cb7c83..3206a8df47a52 100644 --- a/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/policy/v2019_01_01/aio/_configuration.py +++ b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/policy/v2019_01_01/aio/_configuration.py @@ -25,23 +25,18 @@ class PolicyClientConfiguration(Configuration): # pylint: disable=too-many-inst Note that all parameters used to create this instance are saved as instance attributes. - :param credential: Credential needed for the client to connect to Azure. + :param credential: Credential needed for the client to connect to Azure. Required. :type credential: ~azure.core.credentials_async.AsyncTokenCredential - :param subscription_id: The ID of the target subscription. + :param subscription_id: The ID of the target subscription. Required. :type subscription_id: str :keyword api_version: Api Version. Default value is "2019-01-01". Note that overriding this default value may result in unsupported behavior. :paramtype api_version: str """ - def __init__( - self, - credential: "AsyncTokenCredential", - subscription_id: str, - **kwargs: Any - ) -> None: + def __init__(self, credential: "AsyncTokenCredential", subscription_id: str, **kwargs: Any) -> None: super(PolicyClientConfiguration, self).__init__(**kwargs) - api_version = kwargs.pop('api_version', "2019-01-01") # type: str + api_version = kwargs.pop("api_version", "2019-01-01") # type: str if credential is None: raise ValueError("Parameter 'credential' must not be None.") @@ -51,22 +46,21 @@ def __init__( self.credential = credential self.subscription_id = subscription_id self.api_version = api_version - self.credential_scopes = kwargs.pop('credential_scopes', ['https://management.azure.com/.default']) - kwargs.setdefault('sdk_moniker', 'mgmt-resource/{}'.format(VERSION)) + self.credential_scopes = kwargs.pop("credential_scopes", ["https://management.azure.com/.default"]) + kwargs.setdefault("sdk_moniker", "mgmt-resource/{}".format(VERSION)) self._configure(**kwargs) - 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) - self.logging_policy = kwargs.get('logging_policy') or policies.NetworkTraceLoggingPolicy(**kwargs) - self.http_logging_policy = kwargs.get('http_logging_policy') or ARMHttpLoggingPolicy(**kwargs) - self.retry_policy = kwargs.get('retry_policy') or policies.AsyncRetryPolicy(**kwargs) - self.custom_hook_policy = kwargs.get('custom_hook_policy') or policies.CustomHookPolicy(**kwargs) - self.redirect_policy = kwargs.get('redirect_policy') or policies.AsyncRedirectPolicy(**kwargs) - self.authentication_policy = kwargs.get('authentication_policy') + 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) + self.logging_policy = kwargs.get("logging_policy") or policies.NetworkTraceLoggingPolicy(**kwargs) + self.http_logging_policy = kwargs.get("http_logging_policy") or ARMHttpLoggingPolicy(**kwargs) + self.retry_policy = kwargs.get("retry_policy") or policies.AsyncRetryPolicy(**kwargs) + self.custom_hook_policy = kwargs.get("custom_hook_policy") or policies.CustomHookPolicy(**kwargs) + self.redirect_policy = kwargs.get("redirect_policy") or policies.AsyncRedirectPolicy(**kwargs) + self.authentication_policy = kwargs.get("authentication_policy") if self.credential and not self.authentication_policy: - self.authentication_policy = AsyncARMChallengeAuthenticationPolicy(self.credential, *self.credential_scopes, **kwargs) + self.authentication_policy = AsyncARMChallengeAuthenticationPolicy( + self.credential, *self.credential_scopes, **kwargs + ) diff --git a/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/policy/v2019_01_01/aio/_patch.py b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/policy/v2019_01_01/aio/_patch.py index 74e48ecd07cf3..f99e77fef9861 100644 --- a/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/policy/v2019_01_01/aio/_patch.py +++ b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/policy/v2019_01_01/aio/_patch.py @@ -28,4 +28,4 @@ # This file is used for handwritten extensions to the generated code. Example: # https://github.com/Azure/azure-sdk-for-python/blob/main/doc/dev/customize_code/how-to-patch-sdk-code.md def patch_sdk(): - pass \ No newline at end of file + pass diff --git a/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/policy/v2019_01_01/aio/_policy_client.py b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/policy/v2019_01_01/aio/_policy_client.py index 5ad860f9b097d..ede0df15224c8 100644 --- a/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/policy/v2019_01_01/aio/_policy_client.py +++ b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/policy/v2019_01_01/aio/_policy_client.py @@ -9,12 +9,11 @@ from copy import deepcopy from typing import Any, Awaitable, TYPE_CHECKING -from msrest import Deserializer, Serializer - from azure.core.rest import AsyncHttpResponse, HttpRequest from azure.mgmt.core import AsyncARMPipelineClient from .. import models +from ..._serialization import Deserializer, Serializer from ._configuration import PolicyClientConfiguration from .operations import PolicyAssignmentsOperations, PolicyDefinitionsOperations, PolicySetDefinitionsOperations @@ -22,7 +21,8 @@ # pylint: disable=unused-import,ungrouped-imports from azure.core.credentials_async import AsyncTokenCredential -class PolicyClient: + +class PolicyClient: # pylint: disable=client-accepts-api-version-keyword """To manage and control access to your resources, you can define customized policies and assign them at a scope. @@ -35,9 +35,9 @@ class PolicyClient: :ivar policy_set_definitions: PolicySetDefinitionsOperations operations :vartype policy_set_definitions: azure.mgmt.resource.policy.v2019_01_01.aio.operations.PolicySetDefinitionsOperations - :param credential: Credential needed for the client to connect to Azure. + :param credential: Credential needed for the client to connect to Azure. Required. :type credential: ~azure.core.credentials_async.AsyncTokenCredential - :param subscription_id: The ID of the target subscription. + :param subscription_id: The ID of the target subscription. Required. :type subscription_id: str :param base_url: Service URL. Default value is "https://management.azure.com". :type base_url: str @@ -60,16 +60,17 @@ def __init__( self._serialize = Serializer(client_models) self._deserialize = Deserializer(client_models) self._serialize.client_side_validation = False - self.policy_assignments = PolicyAssignmentsOperations(self._client, self._config, self._serialize, self._deserialize) - self.policy_definitions = PolicyDefinitionsOperations(self._client, self._config, self._serialize, self._deserialize) - self.policy_set_definitions = PolicySetDefinitionsOperations(self._client, self._config, self._serialize, self._deserialize) - - - def _send_request( - self, - request: HttpRequest, - **kwargs: Any - ) -> Awaitable[AsyncHttpResponse]: + self.policy_assignments = PolicyAssignmentsOperations( + self._client, self._config, self._serialize, self._deserialize + ) + self.policy_definitions = PolicyDefinitionsOperations( + self._client, self._config, self._serialize, self._deserialize + ) + self.policy_set_definitions = PolicySetDefinitionsOperations( + self._client, self._config, self._serialize, self._deserialize + ) + + def _send_request(self, request: HttpRequest, **kwargs: Any) -> Awaitable[AsyncHttpResponse]: """Runs the network request through the client's chained policies. >>> from azure.core.rest import HttpRequest @@ -78,7 +79,7 @@ def _send_request( >>> response = await client._send_request(request) - For more information on this code flow, see https://aka.ms/azsdk/python/protocol/quickstart + For more information on this code flow, see https://aka.ms/azsdk/dpcodegen/python/send_request :param request: The network request you want to make. Required. :type request: ~azure.core.rest.HttpRequest diff --git a/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/policy/v2019_01_01/aio/operations/__init__.py b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/policy/v2019_01_01/aio/operations/__init__.py index b2ae6190b03fb..4e1971e3e3247 100644 --- a/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/policy/v2019_01_01/aio/operations/__init__.py +++ b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/policy/v2019_01_01/aio/operations/__init__.py @@ -10,8 +10,14 @@ from ._operations import PolicyDefinitionsOperations from ._operations import PolicySetDefinitionsOperations +from ._patch import __all__ as _patch_all +from ._patch import * # type: ignore # pylint: disable=unused-wildcard-import +from ._patch import patch_sdk as _patch_sdk + __all__ = [ - 'PolicyAssignmentsOperations', - 'PolicyDefinitionsOperations', - 'PolicySetDefinitionsOperations', + "PolicyAssignmentsOperations", + "PolicyDefinitionsOperations", + "PolicySetDefinitionsOperations", ] +__all__.extend([p for p in _patch_all if p not in __all__]) +_patch_sdk() diff --git a/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/policy/v2019_01_01/aio/operations/_operations.py b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/policy/v2019_01_01/aio/operations/_operations.py index 8fed1f4c7b1b3..5eb2288d78e32 100644 --- a/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/policy/v2019_01_01/aio/operations/_operations.py +++ b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/policy/v2019_01_01/aio/operations/_operations.py @@ -6,52 +6,87 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -from typing import Any, AsyncIterable, Callable, Dict, Optional, TypeVar +from typing import Any, AsyncIterable, Callable, Dict, IO, Optional, TypeVar, Union, overload +from urllib.parse import parse_qs, urljoin, urlparse from azure.core.async_paging import AsyncItemPaged, AsyncList -from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error +from azure.core.exceptions import ( + ClientAuthenticationError, + HttpResponseError, + ResourceExistsError, + ResourceNotFoundError, + ResourceNotModifiedError, + map_error, +) from azure.core.pipeline import PipelineResponse from azure.core.pipeline.transport import AsyncHttpResponse from azure.core.rest import HttpRequest from azure.core.tracing.decorator import distributed_trace from azure.core.tracing.decorator_async import distributed_trace_async +from azure.core.utils import case_insensitive_dict from azure.mgmt.core.exceptions import ARMErrorFormat from ... import models as _models from ..._vendor import _convert_request -from ...operations._operations import build_policy_assignments_create_by_id_request, build_policy_assignments_create_request, build_policy_assignments_delete_by_id_request, build_policy_assignments_delete_request, build_policy_assignments_get_by_id_request, build_policy_assignments_get_request, build_policy_assignments_list_for_resource_group_request, build_policy_assignments_list_for_resource_request, build_policy_assignments_list_request, build_policy_definitions_create_or_update_at_management_group_request, build_policy_definitions_create_or_update_request, build_policy_definitions_delete_at_management_group_request, build_policy_definitions_delete_request, build_policy_definitions_get_at_management_group_request, build_policy_definitions_get_built_in_request, build_policy_definitions_get_request, build_policy_definitions_list_built_in_request, build_policy_definitions_list_by_management_group_request, build_policy_definitions_list_request, build_policy_set_definitions_create_or_update_at_management_group_request, build_policy_set_definitions_create_or_update_request, build_policy_set_definitions_delete_at_management_group_request, build_policy_set_definitions_delete_request, build_policy_set_definitions_get_at_management_group_request, build_policy_set_definitions_get_built_in_request, build_policy_set_definitions_get_request, build_policy_set_definitions_list_built_in_request, build_policy_set_definitions_list_by_management_group_request, build_policy_set_definitions_list_request -T = TypeVar('T') +from ...operations._operations import ( + build_policy_assignments_create_by_id_request, + build_policy_assignments_create_request, + build_policy_assignments_delete_by_id_request, + build_policy_assignments_delete_request, + build_policy_assignments_get_by_id_request, + build_policy_assignments_get_request, + build_policy_assignments_list_for_resource_group_request, + build_policy_assignments_list_for_resource_request, + build_policy_assignments_list_request, + build_policy_definitions_create_or_update_at_management_group_request, + build_policy_definitions_create_or_update_request, + build_policy_definitions_delete_at_management_group_request, + build_policy_definitions_delete_request, + build_policy_definitions_get_at_management_group_request, + build_policy_definitions_get_built_in_request, + build_policy_definitions_get_request, + build_policy_definitions_list_built_in_request, + build_policy_definitions_list_by_management_group_request, + build_policy_definitions_list_request, + build_policy_set_definitions_create_or_update_at_management_group_request, + build_policy_set_definitions_create_or_update_request, + build_policy_set_definitions_delete_at_management_group_request, + build_policy_set_definitions_delete_request, + build_policy_set_definitions_get_at_management_group_request, + build_policy_set_definitions_get_built_in_request, + build_policy_set_definitions_get_request, + build_policy_set_definitions_list_built_in_request, + build_policy_set_definitions_list_by_management_group_request, + build_policy_set_definitions_list_request, +) + +T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] -class PolicyAssignmentsOperations: - """PolicyAssignmentsOperations async operations. - You should not instantiate this class directly. Instead, you should create a Client instance that - instantiates it for you and attaches it as an attribute. +class PolicyAssignmentsOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. - :ivar models: Alias to model classes used in this operation group. - :type models: ~azure.mgmt.resource.policy.v2019_01_01.models - :param client: Client for service requests. - :param config: Configuration of service client. - :param serializer: An object model serializer. - :param deserializer: An object model deserializer. + Instead, you should access the following operations through + :class:`~azure.mgmt.resource.policy.v2019_01_01.aio.PolicyClient`'s + :attr:`policy_assignments` attribute. """ models = _models - def __init__(self, client, config, serializer, deserializer) -> None: - self._client = client - self._serialize = serializer - self._deserialize = deserializer - self._config = config + def __init__(self, *args, **kwargs) -> None: + input_args = list(args) + self._client = input_args.pop(0) if input_args else kwargs.pop("client") + self._config = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") @distributed_trace_async async def delete( - self, - scope: str, - policy_assignment_name: str, - **kwargs: Any - ) -> Optional["_models.PolicyAssignment"]: + self, scope: str, policy_assignment_name: str, **kwargs: Any + ) -> Optional[_models.PolicyAssignment]: """Deletes a policy assignment. This operation deletes a policy assignment, given its name and the scope it was created in. The @@ -63,37 +98,44 @@ async def delete( '/subscriptions/{subscriptionId}'), resource group (format: '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}', or resource (format: '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{resourceProviderNamespace}/[{parentResourcePath}/]{resourceType}/{resourceName}'. + Required. :type scope: str - :param policy_assignment_name: The name of the policy assignment to delete. + :param policy_assignment_name: The name of the policy assignment to delete. Required. :type policy_assignment_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: PolicyAssignment, or the result of cls(response) + :return: PolicyAssignment or None or the result of cls(response) :rtype: ~azure.mgmt.resource.policy.v2019_01_01.models.PolicyAssignment or None - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType[Optional["_models.PolicyAssignment"]] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) - api_version = kwargs.pop('api_version', "2019-01-01") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2019-01-01")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[Optional[_models.PolicyAssignment]] - request = build_policy_assignments_delete_request( scope=scope, policy_assignment_name=policy_assignment_name, api_version=api_version, - template_url=self.delete.metadata['url'], + template_url=self.delete.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200, 204]: @@ -103,24 +145,25 @@ async def delete( deserialized = None if response.status_code == 200: - deserialized = self._deserialize('PolicyAssignment', pipeline_response) + deserialized = self._deserialize("PolicyAssignment", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - delete.metadata = {'url': "/{scope}/providers/Microsoft.Authorization/policyAssignments/{policyAssignmentName}"} # type: ignore - + delete.metadata = {"url": "/{scope}/providers/Microsoft.Authorization/policyAssignments/{policyAssignmentName}"} # type: ignore - @distributed_trace_async + @overload async def create( self, scope: str, policy_assignment_name: str, - parameters: "_models.PolicyAssignment", + parameters: _models.PolicyAssignment, + *, + content_type: str = "application/json", **kwargs: Any - ) -> "_models.PolicyAssignment": + ) -> _models.PolicyAssignment: """Creates or updates a policy assignment. This operation creates or updates a policy assignment with the given scope and name. Policy @@ -132,26 +175,109 @@ async def create( '/subscriptions/{subscriptionId}'), resource group (format: '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}', or resource (format: '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{resourceProviderNamespace}/[{parentResourcePath}/]{resourceType}/{resourceName}'. + Required. :type scope: str - :param policy_assignment_name: The name of the policy assignment. + :param policy_assignment_name: The name of the policy assignment. Required. :type policy_assignment_name: str - :param parameters: Parameters for the policy assignment. + :param parameters: Parameters for the policy assignment. Required. :type parameters: ~azure.mgmt.resource.policy.v2019_01_01.models.PolicyAssignment + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: PolicyAssignment or the result of cls(response) + :rtype: ~azure.mgmt.resource.policy.v2019_01_01.models.PolicyAssignment + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + async def create( + self, + scope: str, + policy_assignment_name: str, + parameters: IO, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.PolicyAssignment: + """Creates or updates a policy assignment. + + This operation creates or updates a policy assignment with the given scope and name. Policy + assignments apply to all resources contained within their scope. For example, when you assign a + policy at resource group scope, that policy applies to all resources in the group. + + :param scope: The scope of the policy assignment. Valid scopes are: management group (format: + '/providers/Microsoft.Management/managementGroups/{managementGroup}'), subscription (format: + '/subscriptions/{subscriptionId}'), resource group (format: + '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}', or resource (format: + '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{resourceProviderNamespace}/[{parentResourcePath}/]{resourceType}/{resourceName}'. + Required. + :type scope: str + :param policy_assignment_name: The name of the policy assignment. Required. + :type policy_assignment_name: str + :param parameters: Parameters for the policy assignment. Required. + :type parameters: IO + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: PolicyAssignment or the result of cls(response) + :rtype: ~azure.mgmt.resource.policy.v2019_01_01.models.PolicyAssignment + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace_async + async def create( + self, scope: str, policy_assignment_name: str, parameters: Union[_models.PolicyAssignment, IO], **kwargs: Any + ) -> _models.PolicyAssignment: + """Creates or updates a policy assignment. + + This operation creates or updates a policy assignment with the given scope and name. Policy + assignments apply to all resources contained within their scope. For example, when you assign a + policy at resource group scope, that policy applies to all resources in the group. + + :param scope: The scope of the policy assignment. Valid scopes are: management group (format: + '/providers/Microsoft.Management/managementGroups/{managementGroup}'), subscription (format: + '/subscriptions/{subscriptionId}'), resource group (format: + '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}', or resource (format: + '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{resourceProviderNamespace}/[{parentResourcePath}/]{resourceType}/{resourceName}'. + Required. + :type scope: str + :param policy_assignment_name: The name of the policy assignment. Required. + :type policy_assignment_name: str + :param parameters: Parameters for the policy assignment. Is either a model type or a IO type. + Required. + :type parameters: ~azure.mgmt.resource.policy.v2019_01_01.models.PolicyAssignment or IO + :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. + Default value is None. + :paramtype content_type: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: PolicyAssignment, or the result of cls(response) + :return: PolicyAssignment or the result of cls(response) :rtype: ~azure.mgmt.resource.policy.v2019_01_01.models.PolicyAssignment - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.PolicyAssignment"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', "2019-01-01") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + api_version = kwargs.pop("api_version", _params.pop("api-version", "2019-01-01")) # type: str + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.PolicyAssignment] - _json = self._serialize.body(parameters, 'PolicyAssignment') + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(parameters, (IO, bytes)): + _content = parameters + else: + _json = self._serialize.body(parameters, "PolicyAssignment") request = build_policy_assignments_create_request( scope=scope, @@ -159,16 +285,18 @@ async def create( api_version=api_version, content_type=content_type, json=_json, - template_url=self.create.metadata['url'], + content=_content, + template_url=self.create.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [201]: @@ -176,23 +304,17 @@ async def create( error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - deserialized = self._deserialize('PolicyAssignment', pipeline_response) + deserialized = self._deserialize("PolicyAssignment", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - create.metadata = {'url': "/{scope}/providers/Microsoft.Authorization/policyAssignments/{policyAssignmentName}"} # type: ignore - + create.metadata = {"url": "/{scope}/providers/Microsoft.Authorization/policyAssignments/{policyAssignmentName}"} # type: ignore @distributed_trace_async - async def get( - self, - scope: str, - policy_assignment_name: str, - **kwargs: Any - ) -> "_models.PolicyAssignment": + async def get(self, scope: str, policy_assignment_name: str, **kwargs: Any) -> _models.PolicyAssignment: """Retrieves a policy assignment. This operation retrieves a single policy assignment, given its name and the scope it was @@ -203,37 +325,44 @@ async def get( '/subscriptions/{subscriptionId}'), resource group (format: '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}', or resource (format: '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{resourceProviderNamespace}/[{parentResourcePath}/]{resourceType}/{resourceName}'. + Required. :type scope: str - :param policy_assignment_name: The name of the policy assignment to get. + :param policy_assignment_name: The name of the policy assignment to get. Required. :type policy_assignment_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: PolicyAssignment, or the result of cls(response) + :return: PolicyAssignment or the result of cls(response) :rtype: ~azure.mgmt.resource.policy.v2019_01_01.models.PolicyAssignment - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.PolicyAssignment"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + 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', "2019-01-01") # type: str + api_version = kwargs.pop("api_version", _params.pop("api-version", "2019-01-01")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[_models.PolicyAssignment] - request = build_policy_assignments_get_request( scope=scope, policy_assignment_name=policy_assignment_name, api_version=api_version, - template_url=self.get.metadata['url'], + template_url=self.get.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200]: @@ -241,23 +370,19 @@ async def get( error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - deserialized = self._deserialize('PolicyAssignment', pipeline_response) + deserialized = self._deserialize("PolicyAssignment", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - get.metadata = {'url': "/{scope}/providers/Microsoft.Authorization/policyAssignments/{policyAssignmentName}"} # type: ignore - + get.metadata = {"url": "/{scope}/providers/Microsoft.Authorization/policyAssignments/{policyAssignmentName}"} # type: ignore @distributed_trace def list_for_resource_group( - self, - resource_group_name: str, - filter: Optional[str] = None, - **kwargs: Any - ) -> AsyncIterable["_models.PolicyAssignmentListResult"]: + self, resource_group_name: str, filter: Optional[str] = None, **kwargs: Any + ) -> AsyncIterable["_models.PolicyAssignment"]: """Retrieves all policy assignments that apply to a resource group. This operation retrieves the list of all policy assignments associated with the given resource @@ -272,47 +397,55 @@ def list_for_resource_group( assignments of the policy definition whose id is {value} that apply to the resource group. :param resource_group_name: The name of the resource group that contains policy assignments. + Required. :type resource_group_name: str :param filter: The filter to apply on the operation. Valid values for $filter are: 'atScope()' or 'policyDefinitionId eq '{value}''. If $filter is not provided, no filtering is performed. Default value is None. :type filter: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either PolicyAssignmentListResult or the result of - cls(response) + :return: An iterator like instance of either PolicyAssignment or the result of cls(response) :rtype: - ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.resource.policy.v2019_01_01.models.PolicyAssignmentListResult] - :raises: ~azure.core.exceptions.HttpResponseError + ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.resource.policy.v2019_01_01.models.PolicyAssignment] + :raises ~azure.core.exceptions.HttpResponseError: """ - api_version = kwargs.pop('api_version', "2019-01-01") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2019-01-01")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[_models.PolicyAssignmentListResult] - cls = kwargs.pop('cls', None) # type: ClsType["_models.PolicyAssignmentListResult"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) + def prepare_request(next_link=None): if not next_link: - + request = build_policy_assignments_list_for_resource_group_request( resource_group_name=resource_group_name, subscription_id=self._config.subscription_id, - api_version=api_version, filter=filter, - template_url=self.list_for_resource_group.metadata['url'], + api_version=api_version, + template_url=self.list_for_resource_group.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore else: - - request = build_policy_assignments_list_for_resource_group_request( - resource_group_name=resource_group_name, - subscription_id=self._config.subscription_id, - template_url=next_link, - ) + # make call to next link with the client's api-version + _parsed_next_link = urlparse(next_link) + _next_request_params = case_insensitive_dict(parse_qs(_parsed_next_link.query)) + _next_request_params["api-version"] = self._config.api_version + request = HttpRequest("GET", urljoin(next_link, _parsed_next_link.path), params=_next_request_params) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore request.method = "GET" return request @@ -326,10 +459,8 @@ async def extract_data(pipeline_response): async def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) response = pipeline_response.http_response @@ -340,11 +471,9 @@ async def get_next(next_link=None): return pipeline_response + return AsyncItemPaged(get_next, extract_data) - return AsyncItemPaged( - get_next, extract_data - ) - list_for_resource_group.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Authorization/policyAssignments"} # type: ignore + list_for_resource_group.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Authorization/policyAssignments"} # type: ignore @distributed_trace def list_for_resource( @@ -356,7 +485,7 @@ def list_for_resource( resource_name: str, filter: Optional[str] = None, **kwargs: Any - ) -> AsyncIterable["_models.PolicyAssignmentListResult"]: + ) -> AsyncIterable["_models.PolicyAssignment"]: """Retrieves all policy assignments that apply to a resource. This operation retrieves the list of all policy assignments associated with the specified @@ -382,39 +511,47 @@ def list_for_resource( {parentResourcePath} == '', {resourceType} == 'Microsoft.Web/sites', {resourceName} == 'MyWebApp'). - :param resource_group_name: The name of the resource group containing the resource. + :param resource_group_name: The name of the resource group containing the resource. Required. :type resource_group_name: str :param resource_provider_namespace: The namespace of the resource provider. For example, the namespace of a virtual machine is Microsoft.Compute (from Microsoft.Compute/virtualMachines). + Required. :type resource_provider_namespace: str :param parent_resource_path: The parent resource path. Use empty string if there is none. + Required. :type parent_resource_path: str :param resource_type: The resource type name. For example the type name of a web app is 'sites' - (from Microsoft.Web/sites). + (from Microsoft.Web/sites). Required. :type resource_type: str - :param resource_name: The name of the resource. + :param resource_name: The name of the resource. Required. :type resource_name: str :param filter: The filter to apply on the operation. Valid values for $filter are: 'atScope()' or 'policyDefinitionId eq '{value}''. If $filter is not provided, no filtering is performed. Default value is None. :type filter: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either PolicyAssignmentListResult or the result of - cls(response) + :return: An iterator like instance of either PolicyAssignment or the result of cls(response) :rtype: - ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.resource.policy.v2019_01_01.models.PolicyAssignmentListResult] - :raises: ~azure.core.exceptions.HttpResponseError + ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.resource.policy.v2019_01_01.models.PolicyAssignment] + :raises ~azure.core.exceptions.HttpResponseError: """ - api_version = kwargs.pop('api_version', "2019-01-01") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2019-01-01")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[_models.PolicyAssignmentListResult] - cls = kwargs.pop('cls', None) # type: ClsType["_models.PolicyAssignmentListResult"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) + def prepare_request(next_link=None): if not next_link: - + request = build_policy_assignments_list_for_resource_request( resource_group_name=resource_group_name, resource_provider_namespace=resource_provider_namespace, @@ -422,26 +559,23 @@ def prepare_request(next_link=None): resource_type=resource_type, resource_name=resource_name, subscription_id=self._config.subscription_id, - api_version=api_version, filter=filter, - template_url=self.list_for_resource.metadata['url'], + api_version=api_version, + template_url=self.list_for_resource.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore else: - - request = build_policy_assignments_list_for_resource_request( - resource_group_name=resource_group_name, - resource_provider_namespace=resource_provider_namespace, - parent_resource_path=parent_resource_path, - resource_type=resource_type, - resource_name=resource_name, - subscription_id=self._config.subscription_id, - template_url=next_link, - ) + # make call to next link with the client's api-version + _parsed_next_link = urlparse(next_link) + _next_request_params = case_insensitive_dict(parse_qs(_parsed_next_link.query)) + _next_request_params["api-version"] = self._config.api_version + request = HttpRequest("GET", urljoin(next_link, _parsed_next_link.path), params=_next_request_params) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore request.method = "GET" return request @@ -455,10 +589,8 @@ async def extract_data(pipeline_response): async def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) response = pipeline_response.http_response @@ -469,18 +601,12 @@ async def get_next(next_link=None): return pipeline_response + return AsyncItemPaged(get_next, extract_data) - return AsyncItemPaged( - get_next, extract_data - ) - list_for_resource.metadata = {'url': "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{parentResourcePath}/{resourceType}/{resourceName}/providers/Microsoft.Authorization/policyAssignments"} # type: ignore + list_for_resource.metadata = {"url": "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{parentResourcePath}/{resourceType}/{resourceName}/providers/Microsoft.Authorization/policyAssignments"} # type: ignore @distributed_trace - def list( - self, - filter: Optional[str] = None, - **kwargs: Any - ) -> AsyncIterable["_models.PolicyAssignmentListResult"]: + def list(self, filter: Optional[str] = None, **kwargs: Any) -> AsyncIterable["_models.PolicyAssignment"]: """Retrieves all policy assignments that apply to a subscription. This operation retrieves the list of all policy assignments associated with the given @@ -499,39 +625,47 @@ def list( Default value is None. :type filter: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either PolicyAssignmentListResult or the result of - cls(response) + :return: An iterator like instance of either PolicyAssignment or the result of cls(response) :rtype: - ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.resource.policy.v2019_01_01.models.PolicyAssignmentListResult] - :raises: ~azure.core.exceptions.HttpResponseError + ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.resource.policy.v2019_01_01.models.PolicyAssignment] + :raises ~azure.core.exceptions.HttpResponseError: """ - api_version = kwargs.pop('api_version', "2019-01-01") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2019-01-01")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[_models.PolicyAssignmentListResult] - cls = kwargs.pop('cls', None) # type: ClsType["_models.PolicyAssignmentListResult"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) + def prepare_request(next_link=None): if not next_link: - + request = build_policy_assignments_list_request( subscription_id=self._config.subscription_id, - api_version=api_version, filter=filter, - template_url=self.list.metadata['url'], + 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.url = self._client.format_url(request.url) # type: ignore else: - - request = build_policy_assignments_list_request( - subscription_id=self._config.subscription_id, - template_url=next_link, - ) + # make call to next link with the client's api-version + _parsed_next_link = urlparse(next_link) + _next_request_params = case_insensitive_dict(parse_qs(_parsed_next_link.query)) + _next_request_params["api-version"] = self._config.api_version + request = HttpRequest("GET", urljoin(next_link, _parsed_next_link.path), params=_next_request_params) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore request.method = "GET" return request @@ -545,10 +679,8 @@ async def extract_data(pipeline_response): async def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) response = pipeline_response.http_response @@ -559,18 +691,12 @@ async def get_next(next_link=None): return pipeline_response + return AsyncItemPaged(get_next, extract_data) - return AsyncItemPaged( - get_next, extract_data - ) - list.metadata = {'url': "/subscriptions/{subscriptionId}/providers/Microsoft.Authorization/policyAssignments"} # type: ignore + list.metadata = {"url": "/subscriptions/{subscriptionId}/providers/Microsoft.Authorization/policyAssignments"} # type: ignore @distributed_trace_async - async def delete_by_id( - self, - policy_assignment_id: str, - **kwargs: Any - ) -> Optional["_models.PolicyAssignment"]: + async def delete_by_id(self, policy_assignment_id: str, **kwargs: Any) -> Optional[_models.PolicyAssignment]: """Deletes a policy assignment. This operation deletes the policy with the given ID. Policy assignment IDs have this format: @@ -582,35 +708,41 @@ async def delete_by_id( (resource). :param policy_assignment_id: The ID of the policy assignment to delete. Use the format - '{scope}/providers/Microsoft.Authorization/policyAssignments/{policyAssignmentName}'. + '{scope}/providers/Microsoft.Authorization/policyAssignments/{policyAssignmentName}'. Required. :type policy_assignment_id: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: PolicyAssignment, or the result of cls(response) + :return: PolicyAssignment or None or the result of cls(response) :rtype: ~azure.mgmt.resource.policy.v2019_01_01.models.PolicyAssignment or None - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType[Optional["_models.PolicyAssignment"]] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) - api_version = kwargs.pop('api_version', "2019-01-01") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2019-01-01")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[Optional[_models.PolicyAssignment]] - request = build_policy_assignments_delete_by_id_request( policy_assignment_id=policy_assignment_id, api_version=api_version, - template_url=self.delete_by_id.metadata['url'], + template_url=self.delete_by_id.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200, 204]: @@ -620,23 +752,24 @@ async def delete_by_id( deserialized = None if response.status_code == 200: - deserialized = self._deserialize('PolicyAssignment', pipeline_response) + deserialized = self._deserialize("PolicyAssignment", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - delete_by_id.metadata = {'url': "/{policyAssignmentId}"} # type: ignore + delete_by_id.metadata = {"url": "/{policyAssignmentId}"} # type: ignore - - @distributed_trace_async + @overload async def create_by_id( self, policy_assignment_id: str, - parameters: "_models.PolicyAssignment", + parameters: _models.PolicyAssignment, + *, + content_type: str = "application/json", **kwargs: Any - ) -> "_models.PolicyAssignment": + ) -> _models.PolicyAssignment: """Creates or updates a policy assignment. This operation creates or updates the policy assignment with the given ID. Policy assignments @@ -651,41 +784,121 @@ async def create_by_id( '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{resourceProviderNamespace}/[{parentResourcePath}/]{resourceType}/{resourceName}'. :param policy_assignment_id: The ID of the policy assignment to create. Use the format - '{scope}/providers/Microsoft.Authorization/policyAssignments/{policyAssignmentName}'. + '{scope}/providers/Microsoft.Authorization/policyAssignments/{policyAssignmentName}'. Required. :type policy_assignment_id: str - :param parameters: Parameters for policy assignment. + :param parameters: Parameters for policy assignment. Required. :type parameters: ~azure.mgmt.resource.policy.v2019_01_01.models.PolicyAssignment + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: PolicyAssignment or the result of cls(response) + :rtype: ~azure.mgmt.resource.policy.v2019_01_01.models.PolicyAssignment + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + async def create_by_id( + self, policy_assignment_id: str, parameters: IO, *, content_type: str = "application/json", **kwargs: Any + ) -> _models.PolicyAssignment: + """Creates or updates a policy assignment. + + This operation creates or updates the policy assignment with the given ID. Policy assignments + made on a scope apply to all resources contained in that scope. For example, when you assign a + policy to a resource group that policy applies to all resources in the group. Policy assignment + IDs have this format: + '{scope}/providers/Microsoft.Authorization/policyAssignments/{policyAssignmentName}'. Valid + scopes are: management group (format: + '/providers/Microsoft.Management/managementGroups/{managementGroup}'), subscription (format: + '/subscriptions/{subscriptionId}'), resource group (format: + '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}', or resource (format: + '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{resourceProviderNamespace}/[{parentResourcePath}/]{resourceType}/{resourceName}'. + + :param policy_assignment_id: The ID of the policy assignment to create. Use the format + '{scope}/providers/Microsoft.Authorization/policyAssignments/{policyAssignmentName}'. Required. + :type policy_assignment_id: str + :param parameters: Parameters for policy assignment. Required. + :type parameters: IO + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: PolicyAssignment, or the result of cls(response) + :return: PolicyAssignment or the result of cls(response) :rtype: ~azure.mgmt.resource.policy.v2019_01_01.models.PolicyAssignment - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace_async + async def create_by_id( + self, policy_assignment_id: str, parameters: Union[_models.PolicyAssignment, IO], **kwargs: Any + ) -> _models.PolicyAssignment: + """Creates or updates a policy assignment. + + This operation creates or updates the policy assignment with the given ID. Policy assignments + made on a scope apply to all resources contained in that scope. For example, when you assign a + policy to a resource group that policy applies to all resources in the group. Policy assignment + IDs have this format: + '{scope}/providers/Microsoft.Authorization/policyAssignments/{policyAssignmentName}'. Valid + scopes are: management group (format: + '/providers/Microsoft.Management/managementGroups/{managementGroup}'), subscription (format: + '/subscriptions/{subscriptionId}'), resource group (format: + '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}', or resource (format: + '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{resourceProviderNamespace}/[{parentResourcePath}/]{resourceType}/{resourceName}'. + + :param policy_assignment_id: The ID of the policy assignment to create. Use the format + '{scope}/providers/Microsoft.Authorization/policyAssignments/{policyAssignmentName}'. Required. + :type policy_assignment_id: str + :param parameters: Parameters for policy assignment. Is either a model type or a IO type. + Required. + :type parameters: ~azure.mgmt.resource.policy.v2019_01_01.models.PolicyAssignment or IO + :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. + Default value is None. + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: PolicyAssignment or the result of cls(response) + :rtype: ~azure.mgmt.resource.policy.v2019_01_01.models.PolicyAssignment + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.PolicyAssignment"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', "2019-01-01") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + api_version = kwargs.pop("api_version", _params.pop("api-version", "2019-01-01")) # type: str + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.PolicyAssignment] - _json = self._serialize.body(parameters, 'PolicyAssignment') + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(parameters, (IO, bytes)): + _content = parameters + else: + _json = self._serialize.body(parameters, "PolicyAssignment") request = build_policy_assignments_create_by_id_request( policy_assignment_id=policy_assignment_id, api_version=api_version, content_type=content_type, json=_json, - template_url=self.create_by_id.metadata['url'], + content=_content, + template_url=self.create_by_id.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [201]: @@ -693,22 +906,17 @@ async def create_by_id( error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - deserialized = self._deserialize('PolicyAssignment', pipeline_response) + deserialized = self._deserialize("PolicyAssignment", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - create_by_id.metadata = {'url': "/{policyAssignmentId}"} # type: ignore - + create_by_id.metadata = {"url": "/{policyAssignmentId}"} # type: ignore @distributed_trace_async - async def get_by_id( - self, - policy_assignment_id: str, - **kwargs: Any - ) -> "_models.PolicyAssignment": + async def get_by_id(self, policy_assignment_id: str, **kwargs: Any) -> _models.PolicyAssignment: """Retrieves the policy assignment with the given ID. The operation retrieves the policy assignment with the given ID. Policy assignment IDs have @@ -721,35 +929,41 @@ async def get_by_id( '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{resourceProviderNamespace}/[{parentResourcePath}/]{resourceType}/{resourceName}'. :param policy_assignment_id: The ID of the policy assignment to get. Use the format - '{scope}/providers/Microsoft.Authorization/policyAssignments/{policyAssignmentName}'. + '{scope}/providers/Microsoft.Authorization/policyAssignments/{policyAssignmentName}'. Required. :type policy_assignment_id: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: PolicyAssignment, or the result of cls(response) + :return: PolicyAssignment or the result of cls(response) :rtype: ~azure.mgmt.resource.policy.v2019_01_01.models.PolicyAssignment - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.PolicyAssignment"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) - api_version = kwargs.pop('api_version', "2019-01-01") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2019-01-01")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[_models.PolicyAssignment] - request = build_policy_assignments_get_by_id_request( policy_assignment_id=policy_assignment_id, api_version=api_version, - template_url=self.get_by_id.metadata['url'], + template_url=self.get_by_id.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200]: @@ -757,68 +971,128 @@ async def get_by_id( error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - deserialized = self._deserialize('PolicyAssignment', pipeline_response) + deserialized = self._deserialize("PolicyAssignment", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - get_by_id.metadata = {'url': "/{policyAssignmentId}"} # type: ignore + get_by_id.metadata = {"url": "/{policyAssignmentId}"} # type: ignore -class PolicyDefinitionsOperations: - """PolicyDefinitionsOperations async operations. - You should not instantiate this class directly. Instead, you should create a Client instance that - instantiates it for you and attaches it as an attribute. +class PolicyDefinitionsOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. - :ivar models: Alias to model classes used in this operation group. - :type models: ~azure.mgmt.resource.policy.v2019_01_01.models - :param client: Client for service requests. - :param config: Configuration of service client. - :param serializer: An object model serializer. - :param deserializer: An object model deserializer. + Instead, you should access the following operations through + :class:`~azure.mgmt.resource.policy.v2019_01_01.aio.PolicyClient`'s + :attr:`policy_definitions` attribute. """ models = _models - def __init__(self, client, config, serializer, deserializer) -> None: - self._client = client - self._serialize = serializer - self._deserialize = deserializer - self._config = config + def __init__(self, *args, **kwargs) -> None: + input_args = list(args) + self._client = input_args.pop(0) if input_args else kwargs.pop("client") + self._config = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") - @distributed_trace_async + @overload async def create_or_update( self, policy_definition_name: str, - parameters: "_models.PolicyDefinition", + parameters: _models.PolicyDefinition, + *, + content_type: str = "application/json", **kwargs: Any - ) -> "_models.PolicyDefinition": + ) -> _models.PolicyDefinition: """Creates or updates a policy definition in a subscription. This operation creates or updates a policy definition in the given subscription with the given name. - :param policy_definition_name: The name of the policy definition to create. + :param policy_definition_name: The name of the policy definition to create. Required. :type policy_definition_name: str - :param parameters: The policy definition properties. + :param parameters: The policy definition properties. Required. :type parameters: ~azure.mgmt.resource.policy.v2019_01_01.models.PolicyDefinition + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: PolicyDefinition or the result of cls(response) + :rtype: ~azure.mgmt.resource.policy.v2019_01_01.models.PolicyDefinition + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + async def create_or_update( + self, policy_definition_name: str, parameters: IO, *, content_type: str = "application/json", **kwargs: Any + ) -> _models.PolicyDefinition: + """Creates or updates a policy definition in a subscription. + + This operation creates or updates a policy definition in the given subscription with the given + name. + + :param policy_definition_name: The name of the policy definition to create. Required. + :type policy_definition_name: str + :param parameters: The policy definition properties. Required. + :type parameters: IO + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: PolicyDefinition or the result of cls(response) + :rtype: ~azure.mgmt.resource.policy.v2019_01_01.models.PolicyDefinition + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace_async + async def create_or_update( + self, policy_definition_name: str, parameters: Union[_models.PolicyDefinition, IO], **kwargs: Any + ) -> _models.PolicyDefinition: + """Creates or updates a policy definition in a subscription. + + This operation creates or updates a policy definition in the given subscription with the given + name. + + :param policy_definition_name: The name of the policy definition to create. Required. + :type policy_definition_name: str + :param parameters: The policy definition properties. Is either a model type or a IO type. + Required. + :type parameters: ~azure.mgmt.resource.policy.v2019_01_01.models.PolicyDefinition or IO + :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. + Default value is None. + :paramtype content_type: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: PolicyDefinition, or the result of cls(response) + :return: PolicyDefinition or the result of cls(response) :rtype: ~azure.mgmt.resource.policy.v2019_01_01.models.PolicyDefinition - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.PolicyDefinition"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', "2019-01-01") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + api_version = kwargs.pop("api_version", _params.pop("api-version", "2019-01-01")) # type: str + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.PolicyDefinition] - _json = self._serialize.body(parameters, 'PolicyDefinition') + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(parameters, (IO, bytes)): + _content = parameters + else: + _json = self._serialize.body(parameters, "PolicyDefinition") request = build_policy_definitions_create_or_update_request( policy_definition_name=policy_definition_name, @@ -826,72 +1100,77 @@ async def create_or_update( api_version=api_version, content_type=content_type, json=_json, - template_url=self.create_or_update.metadata['url'], + content=_content, + template_url=self.create_or_update.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [201]: map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) - deserialized = self._deserialize('PolicyDefinition', pipeline_response) + deserialized = self._deserialize("PolicyDefinition", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - create_or_update.metadata = {'url': "/subscriptions/{subscriptionId}/providers/Microsoft.Authorization/policyDefinitions/{policyDefinitionName}"} # type: ignore - + create_or_update.metadata = {"url": "/subscriptions/{subscriptionId}/providers/Microsoft.Authorization/policyDefinitions/{policyDefinitionName}"} # type: ignore @distributed_trace_async async def delete( # pylint: disable=inconsistent-return-statements - self, - policy_definition_name: str, - **kwargs: Any + self, policy_definition_name: str, **kwargs: Any ) -> None: """Deletes a policy definition in a subscription. This operation deletes the policy definition in the given subscription with the given name. - :param policy_definition_name: The name of the policy definition to delete. + :param policy_definition_name: The name of the policy definition to delete. Required. :type policy_definition_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: None, or the result of cls(response) + :return: None or the result of cls(response) :rtype: None - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType[None] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + 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', "2019-01-01") # type: str + api_version = kwargs.pop("api_version", _params.pop("api-version", "2019-01-01")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[None] - request = build_policy_definitions_delete_request( policy_definition_name=policy_definition_name, subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.delete.metadata['url'], + template_url=self.delete.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200, 204]: @@ -901,154 +1180,231 @@ async def delete( # pylint: disable=inconsistent-return-statements if cls: return cls(pipeline_response, None, {}) - delete.metadata = {'url': "/subscriptions/{subscriptionId}/providers/Microsoft.Authorization/policyDefinitions/{policyDefinitionName}"} # type: ignore - + delete.metadata = {"url": "/subscriptions/{subscriptionId}/providers/Microsoft.Authorization/policyDefinitions/{policyDefinitionName}"} # type: ignore @distributed_trace_async - async def get( - self, - policy_definition_name: str, - **kwargs: Any - ) -> "_models.PolicyDefinition": + async def get(self, policy_definition_name: str, **kwargs: Any) -> _models.PolicyDefinition: """Retrieves a policy definition in a subscription. This operation retrieves the policy definition in the given subscription with the given name. - :param policy_definition_name: The name of the policy definition to get. + :param policy_definition_name: The name of the policy definition to get. Required. :type policy_definition_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: PolicyDefinition, or the result of cls(response) + :return: PolicyDefinition or the result of cls(response) :rtype: ~azure.mgmt.resource.policy.v2019_01_01.models.PolicyDefinition - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.PolicyDefinition"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + 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', "2019-01-01") # type: str + api_version = kwargs.pop("api_version", _params.pop("api-version", "2019-01-01")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[_models.PolicyDefinition] - request = build_policy_definitions_get_request( policy_definition_name=policy_definition_name, subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.get.metadata['url'], + template_url=self.get.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) - deserialized = self._deserialize('PolicyDefinition', pipeline_response) + deserialized = self._deserialize("PolicyDefinition", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - get.metadata = {'url': "/subscriptions/{subscriptionId}/providers/Microsoft.Authorization/policyDefinitions/{policyDefinitionName}"} # type: ignore - + get.metadata = {"url": "/subscriptions/{subscriptionId}/providers/Microsoft.Authorization/policyDefinitions/{policyDefinitionName}"} # type: ignore @distributed_trace_async - async def get_built_in( - self, - policy_definition_name: str, - **kwargs: Any - ) -> "_models.PolicyDefinition": + async def get_built_in(self, policy_definition_name: str, **kwargs: Any) -> _models.PolicyDefinition: """Retrieves a built-in policy definition. This operation retrieves the built-in policy definition with the given name. - :param policy_definition_name: The name of the built-in policy definition to get. + :param policy_definition_name: The name of the built-in policy definition to get. Required. :type policy_definition_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: PolicyDefinition, or the result of cls(response) + :return: PolicyDefinition or the result of cls(response) :rtype: ~azure.mgmt.resource.policy.v2019_01_01.models.PolicyDefinition - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.PolicyDefinition"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + 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', "2019-01-01") # type: str + api_version = kwargs.pop("api_version", _params.pop("api-version", "2019-01-01")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[_models.PolicyDefinition] - request = build_policy_definitions_get_built_in_request( policy_definition_name=policy_definition_name, api_version=api_version, - template_url=self.get_built_in.metadata['url'], + template_url=self.get_built_in.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) - deserialized = self._deserialize('PolicyDefinition', pipeline_response) + deserialized = self._deserialize("PolicyDefinition", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - get_built_in.metadata = {'url': "/providers/Microsoft.Authorization/policyDefinitions/{policyDefinitionName}"} # type: ignore + get_built_in.metadata = {"url": "/providers/Microsoft.Authorization/policyDefinitions/{policyDefinitionName}"} # type: ignore + @overload + async def create_or_update_at_management_group( + self, + policy_definition_name: str, + management_group_id: str, + parameters: _models.PolicyDefinition, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.PolicyDefinition: + """Creates or updates a policy definition in a management group. + + This operation creates or updates a policy definition in the given management group with the + given name. + + :param policy_definition_name: The name of the policy definition to create. Required. + :type policy_definition_name: str + :param management_group_id: The ID of the management group. Required. + :type management_group_id: str + :param parameters: The policy definition properties. Required. + :type parameters: ~azure.mgmt.resource.policy.v2019_01_01.models.PolicyDefinition + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: PolicyDefinition or the result of cls(response) + :rtype: ~azure.mgmt.resource.policy.v2019_01_01.models.PolicyDefinition + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + async def create_or_update_at_management_group( + self, + policy_definition_name: str, + management_group_id: str, + parameters: IO, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.PolicyDefinition: + """Creates or updates a policy definition in a management group. + + This operation creates or updates a policy definition in the given management group with the + given name. + + :param policy_definition_name: The name of the policy definition to create. Required. + :type policy_definition_name: str + :param management_group_id: The ID of the management group. Required. + :type management_group_id: str + :param parameters: The policy definition properties. Required. + :type parameters: IO + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: PolicyDefinition or the result of cls(response) + :rtype: ~azure.mgmt.resource.policy.v2019_01_01.models.PolicyDefinition + :raises ~azure.core.exceptions.HttpResponseError: + """ @distributed_trace_async async def create_or_update_at_management_group( self, policy_definition_name: str, management_group_id: str, - parameters: "_models.PolicyDefinition", + parameters: Union[_models.PolicyDefinition, IO], **kwargs: Any - ) -> "_models.PolicyDefinition": + ) -> _models.PolicyDefinition: """Creates or updates a policy definition in a management group. This operation creates or updates a policy definition in the given management group with the given name. - :param policy_definition_name: The name of the policy definition to create. + :param policy_definition_name: The name of the policy definition to create. Required. :type policy_definition_name: str - :param management_group_id: The ID of the management group. + :param management_group_id: The ID of the management group. Required. :type management_group_id: str - :param parameters: The policy definition properties. - :type parameters: ~azure.mgmt.resource.policy.v2019_01_01.models.PolicyDefinition + :param parameters: The policy definition properties. Is either a model type or a IO type. + Required. + :type parameters: ~azure.mgmt.resource.policy.v2019_01_01.models.PolicyDefinition or IO + :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. + Default value is None. + :paramtype content_type: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: PolicyDefinition, or the result of cls(response) + :return: PolicyDefinition or the result of cls(response) :rtype: ~azure.mgmt.resource.policy.v2019_01_01.models.PolicyDefinition - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.PolicyDefinition"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', "2019-01-01") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + api_version = kwargs.pop("api_version", _params.pop("api-version", "2019-01-01")) # type: str + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.PolicyDefinition] - _json = self._serialize.body(parameters, 'PolicyDefinition') + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(parameters, (IO, bytes)): + _content = parameters + else: + _json = self._serialize.body(parameters, "PolicyDefinition") request = build_policy_definitions_create_or_update_at_management_group_request( policy_definition_name=policy_definition_name, @@ -1056,75 +1412,79 @@ async def create_or_update_at_management_group( api_version=api_version, content_type=content_type, json=_json, - template_url=self.create_or_update_at_management_group.metadata['url'], + content=_content, + template_url=self.create_or_update_at_management_group.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [201]: map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) - deserialized = self._deserialize('PolicyDefinition', pipeline_response) + deserialized = self._deserialize("PolicyDefinition", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - create_or_update_at_management_group.metadata = {'url': "/providers/Microsoft.Management/managementgroups/{managementGroupId}/providers/Microsoft.Authorization/policyDefinitions/{policyDefinitionName}"} # type: ignore - + create_or_update_at_management_group.metadata = {"url": "/providers/Microsoft.Management/managementgroups/{managementGroupId}/providers/Microsoft.Authorization/policyDefinitions/{policyDefinitionName}"} # type: ignore @distributed_trace_async async def delete_at_management_group( # pylint: disable=inconsistent-return-statements - self, - policy_definition_name: str, - management_group_id: str, - **kwargs: Any + self, policy_definition_name: str, management_group_id: str, **kwargs: Any ) -> None: """Deletes a policy definition in a management group. This operation deletes the policy definition in the given management group with the given name. - :param policy_definition_name: The name of the policy definition to delete. + :param policy_definition_name: The name of the policy definition to delete. Required. :type policy_definition_name: str - :param management_group_id: The ID of the management group. + :param management_group_id: The ID of the management group. Required. :type management_group_id: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: None, or the result of cls(response) + :return: None or the result of cls(response) :rtype: None - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType[None] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) - api_version = kwargs.pop('api_version', "2019-01-01") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2019-01-01")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[None] - request = build_policy_definitions_delete_at_management_group_request( policy_definition_name=policy_definition_name, management_group_id=management_group_id, api_version=api_version, - template_url=self.delete_at_management_group.metadata['url'], + template_url=self.delete_at_management_group.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200, 204]: @@ -1134,111 +1494,117 @@ async def delete_at_management_group( # pylint: disable=inconsistent-return-sta if cls: return cls(pipeline_response, None, {}) - delete_at_management_group.metadata = {'url': "/providers/Microsoft.Management/managementgroups/{managementGroupId}/providers/Microsoft.Authorization/policyDefinitions/{policyDefinitionName}"} # type: ignore - + delete_at_management_group.metadata = {"url": "/providers/Microsoft.Management/managementgroups/{managementGroupId}/providers/Microsoft.Authorization/policyDefinitions/{policyDefinitionName}"} # type: ignore @distributed_trace_async async def get_at_management_group( - self, - policy_definition_name: str, - management_group_id: str, - **kwargs: Any - ) -> "_models.PolicyDefinition": + self, policy_definition_name: str, management_group_id: str, **kwargs: Any + ) -> _models.PolicyDefinition: """Retrieve a policy definition in a management group. This operation retrieves the policy definition in the given management group with the given name. - :param policy_definition_name: The name of the policy definition to get. + :param policy_definition_name: The name of the policy definition to get. Required. :type policy_definition_name: str - :param management_group_id: The ID of the management group. + :param management_group_id: The ID of the management group. Required. :type management_group_id: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: PolicyDefinition, or the result of cls(response) + :return: PolicyDefinition or the result of cls(response) :rtype: ~azure.mgmt.resource.policy.v2019_01_01.models.PolicyDefinition - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.PolicyDefinition"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + 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', "2019-01-01") # type: str + api_version = kwargs.pop("api_version", _params.pop("api-version", "2019-01-01")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[_models.PolicyDefinition] - request = build_policy_definitions_get_at_management_group_request( policy_definition_name=policy_definition_name, management_group_id=management_group_id, api_version=api_version, - template_url=self.get_at_management_group.metadata['url'], + template_url=self.get_at_management_group.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) - deserialized = self._deserialize('PolicyDefinition', pipeline_response) + deserialized = self._deserialize("PolicyDefinition", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - get_at_management_group.metadata = {'url': "/providers/Microsoft.Management/managementgroups/{managementGroupId}/providers/Microsoft.Authorization/policyDefinitions/{policyDefinitionName}"} # type: ignore - + get_at_management_group.metadata = {"url": "/providers/Microsoft.Management/managementgroups/{managementGroupId}/providers/Microsoft.Authorization/policyDefinitions/{policyDefinitionName}"} # type: ignore @distributed_trace - def list( - self, - **kwargs: Any - ) -> AsyncIterable["_models.PolicyDefinitionListResult"]: + def list(self, **kwargs: Any) -> AsyncIterable["_models.PolicyDefinition"]: """Retrieves policy definitions in a subscription. This operation retrieves a list of all the policy definitions in a given subscription. :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either PolicyDefinitionListResult or the result of - cls(response) + :return: An iterator like instance of either PolicyDefinition or the result of cls(response) :rtype: - ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.resource.policy.v2019_01_01.models.PolicyDefinitionListResult] - :raises: ~azure.core.exceptions.HttpResponseError + ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.resource.policy.v2019_01_01.models.PolicyDefinition] + :raises ~azure.core.exceptions.HttpResponseError: """ - api_version = kwargs.pop('api_version', "2019-01-01") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2019-01-01")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[_models.PolicyDefinitionListResult] - cls = kwargs.pop('cls', None) # type: ClsType["_models.PolicyDefinitionListResult"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) + def prepare_request(next_link=None): if not next_link: - + request = build_policy_definitions_list_request( subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.list.metadata['url'], + template_url=self.list.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore else: - - request = build_policy_definitions_list_request( - subscription_id=self._config.subscription_id, - template_url=next_link, - ) + # make call to next link with the client's api-version + _parsed_next_link = urlparse(next_link) + _next_request_params = case_insensitive_dict(parse_qs(_parsed_next_link.query)) + _next_request_params["api-version"] = self._config.api_version + request = HttpRequest("GET", urljoin(next_link, _parsed_next_link.path), params=_next_request_params) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore request.method = "GET" return request @@ -1252,10 +1618,8 @@ async def extract_data(pipeline_response): async def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) response = pipeline_response.http_response @@ -1265,52 +1629,56 @@ async def get_next(next_link=None): return pipeline_response + return AsyncItemPaged(get_next, extract_data) - return AsyncItemPaged( - get_next, extract_data - ) - list.metadata = {'url': "/subscriptions/{subscriptionId}/providers/Microsoft.Authorization/policyDefinitions"} # type: ignore + list.metadata = {"url": "/subscriptions/{subscriptionId}/providers/Microsoft.Authorization/policyDefinitions"} # type: ignore @distributed_trace - def list_built_in( - self, - **kwargs: Any - ) -> AsyncIterable["_models.PolicyDefinitionListResult"]: + def list_built_in(self, **kwargs: Any) -> AsyncIterable["_models.PolicyDefinition"]: """Retrieve built-in policy definitions. This operation retrieves a list of all the built-in policy definitions. :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either PolicyDefinitionListResult or the result of - cls(response) + :return: An iterator like instance of either PolicyDefinition or the result of cls(response) :rtype: - ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.resource.policy.v2019_01_01.models.PolicyDefinitionListResult] - :raises: ~azure.core.exceptions.HttpResponseError + ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.resource.policy.v2019_01_01.models.PolicyDefinition] + :raises ~azure.core.exceptions.HttpResponseError: """ - api_version = kwargs.pop('api_version', "2019-01-01") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2019-01-01")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[_models.PolicyDefinitionListResult] - cls = kwargs.pop('cls', None) # type: ClsType["_models.PolicyDefinitionListResult"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) + def prepare_request(next_link=None): if not next_link: - + request = build_policy_definitions_list_built_in_request( api_version=api_version, - template_url=self.list_built_in.metadata['url'], + template_url=self.list_built_in.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore else: - - request = build_policy_definitions_list_built_in_request( - template_url=next_link, - ) + # make call to next link with the client's api-version + _parsed_next_link = urlparse(next_link) + _next_request_params = case_insensitive_dict(parse_qs(_parsed_next_link.query)) + _next_request_params["api-version"] = self._config.api_version + request = HttpRequest("GET", urljoin(next_link, _parsed_next_link.path), params=_next_request_params) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore request.method = "GET" return request @@ -1324,10 +1692,8 @@ async def extract_data(pipeline_response): async def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) response = pipeline_response.http_response @@ -1337,57 +1703,61 @@ async def get_next(next_link=None): return pipeline_response + return AsyncItemPaged(get_next, extract_data) - return AsyncItemPaged( - get_next, extract_data - ) - list_built_in.metadata = {'url': "/providers/Microsoft.Authorization/policyDefinitions"} # type: ignore + list_built_in.metadata = {"url": "/providers/Microsoft.Authorization/policyDefinitions"} # type: ignore @distributed_trace def list_by_management_group( - self, - management_group_id: str, - **kwargs: Any - ) -> AsyncIterable["_models.PolicyDefinitionListResult"]: + self, management_group_id: str, **kwargs: Any + ) -> AsyncIterable["_models.PolicyDefinition"]: """Retrieve policy definitions in a management group. This operation retrieves a list of all the policy definitions in a given management group. - :param management_group_id: The ID of the management group. + :param management_group_id: The ID of the management group. Required. :type management_group_id: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either PolicyDefinitionListResult or the result of - cls(response) + :return: An iterator like instance of either PolicyDefinition or the result of cls(response) :rtype: - ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.resource.policy.v2019_01_01.models.PolicyDefinitionListResult] - :raises: ~azure.core.exceptions.HttpResponseError + ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.resource.policy.v2019_01_01.models.PolicyDefinition] + :raises ~azure.core.exceptions.HttpResponseError: """ - api_version = kwargs.pop('api_version', "2019-01-01") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2019-01-01")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[_models.PolicyDefinitionListResult] - cls = kwargs.pop('cls', None) # type: ClsType["_models.PolicyDefinitionListResult"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) + def prepare_request(next_link=None): if not next_link: - + request = build_policy_definitions_list_by_management_group_request( management_group_id=management_group_id, api_version=api_version, - template_url=self.list_by_management_group.metadata['url'], + template_url=self.list_by_management_group.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore else: - - request = build_policy_definitions_list_by_management_group_request( - management_group_id=management_group_id, - template_url=next_link, - ) + # make call to next link with the client's api-version + _parsed_next_link = urlparse(next_link) + _next_request_params = case_insensitive_dict(parse_qs(_parsed_next_link.query)) + _next_request_params["api-version"] = self._config.api_version + request = HttpRequest("GET", urljoin(next_link, _parsed_next_link.path), params=_next_request_params) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore request.method = "GET" return request @@ -1401,10 +1771,8 @@ async def extract_data(pipeline_response): async def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) response = pipeline_response.http_response @@ -1414,64 +1782,123 @@ async def get_next(next_link=None): return pipeline_response + return AsyncItemPaged(get_next, extract_data) + + list_by_management_group.metadata = {"url": "/providers/Microsoft.Management/managementgroups/{managementGroupId}/providers/Microsoft.Authorization/policyDefinitions"} # type: ignore - return AsyncItemPaged( - get_next, extract_data - ) - list_by_management_group.metadata = {'url': "/providers/Microsoft.Management/managementgroups/{managementGroupId}/providers/Microsoft.Authorization/policyDefinitions"} # type: ignore -class PolicySetDefinitionsOperations: - """PolicySetDefinitionsOperations async operations. - You should not instantiate this class directly. Instead, you should create a Client instance that - instantiates it for you and attaches it as an attribute. +class PolicySetDefinitionsOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. - :ivar models: Alias to model classes used in this operation group. - :type models: ~azure.mgmt.resource.policy.v2019_01_01.models - :param client: Client for service requests. - :param config: Configuration of service client. - :param serializer: An object model serializer. - :param deserializer: An object model deserializer. + Instead, you should access the following operations through + :class:`~azure.mgmt.resource.policy.v2019_01_01.aio.PolicyClient`'s + :attr:`policy_set_definitions` attribute. """ models = _models - def __init__(self, client, config, serializer, deserializer) -> None: - self._client = client - self._serialize = serializer - self._deserialize = deserializer - self._config = config + def __init__(self, *args, **kwargs) -> None: + input_args = list(args) + self._client = input_args.pop(0) if input_args else kwargs.pop("client") + self._config = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") - @distributed_trace_async + @overload async def create_or_update( self, policy_set_definition_name: str, - parameters: "_models.PolicySetDefinition", + parameters: _models.PolicySetDefinition, + *, + content_type: str = "application/json", **kwargs: Any - ) -> "_models.PolicySetDefinition": + ) -> _models.PolicySetDefinition: """Creates or updates a policy set definition. This operation creates or updates a policy set definition in the given subscription with the given name. - :param policy_set_definition_name: The name of the policy set definition to create. + :param policy_set_definition_name: The name of the policy set definition to create. Required. :type policy_set_definition_name: str - :param parameters: The policy set definition properties. + :param parameters: The policy set definition properties. Required. :type parameters: ~azure.mgmt.resource.policy.v2019_01_01.models.PolicySetDefinition + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: PolicySetDefinition or the result of cls(response) + :rtype: ~azure.mgmt.resource.policy.v2019_01_01.models.PolicySetDefinition + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + async def create_or_update( + self, policy_set_definition_name: str, parameters: IO, *, content_type: str = "application/json", **kwargs: Any + ) -> _models.PolicySetDefinition: + """Creates or updates a policy set definition. + + This operation creates or updates a policy set definition in the given subscription with the + given name. + + :param policy_set_definition_name: The name of the policy set definition to create. Required. + :type policy_set_definition_name: str + :param parameters: The policy set definition properties. Required. + :type parameters: IO + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: PolicySetDefinition, or the result of cls(response) + :return: PolicySetDefinition or the result of cls(response) :rtype: ~azure.mgmt.resource.policy.v2019_01_01.models.PolicySetDefinition - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace_async + async def create_or_update( + self, policy_set_definition_name: str, parameters: Union[_models.PolicySetDefinition, IO], **kwargs: Any + ) -> _models.PolicySetDefinition: + """Creates or updates a policy set definition. + + This operation creates or updates a policy set definition in the given subscription with the + given name. + + :param policy_set_definition_name: The name of the policy set definition to create. Required. + :type policy_set_definition_name: str + :param parameters: The policy set definition properties. Is either a model type or a IO type. + Required. + :type parameters: ~azure.mgmt.resource.policy.v2019_01_01.models.PolicySetDefinition or IO + :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. + Default value is None. + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: PolicySetDefinition or the result of cls(response) + :rtype: ~azure.mgmt.resource.policy.v2019_01_01.models.PolicySetDefinition + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.PolicySetDefinition"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', "2019-01-01") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + api_version = kwargs.pop("api_version", _params.pop("api-version", "2019-01-01")) # type: str + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.PolicySetDefinition] - _json = self._serialize.body(parameters, 'PolicySetDefinition') + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(parameters, (IO, bytes)): + _content = parameters + else: + _json = self._serialize.body(parameters, "PolicySetDefinition") request = build_policy_set_definitions_create_or_update_request( policy_set_definition_name=policy_set_definition_name, @@ -1479,16 +1906,18 @@ async def create_or_update( api_version=api_version, content_type=content_type, json=_json, - template_url=self.create_or_update.metadata['url'], + content=_content, + template_url=self.create_or_update.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200, 201]: @@ -1497,59 +1926,62 @@ async def create_or_update( raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) if response.status_code == 200: - deserialized = self._deserialize('PolicySetDefinition', pipeline_response) + deserialized = self._deserialize("PolicySetDefinition", pipeline_response) if response.status_code == 201: - deserialized = self._deserialize('PolicySetDefinition', pipeline_response) + deserialized = self._deserialize("PolicySetDefinition", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - create_or_update.metadata = {'url': "/subscriptions/{subscriptionId}/providers/Microsoft.Authorization/policySetDefinitions/{policySetDefinitionName}"} # type: ignore - + create_or_update.metadata = {"url": "/subscriptions/{subscriptionId}/providers/Microsoft.Authorization/policySetDefinitions/{policySetDefinitionName}"} # type: ignore @distributed_trace_async async def delete( # pylint: disable=inconsistent-return-statements - self, - policy_set_definition_name: str, - **kwargs: Any + self, policy_set_definition_name: str, **kwargs: Any ) -> None: """Deletes a policy set definition. This operation deletes the policy set definition in the given subscription with the given name. - :param policy_set_definition_name: The name of the policy set definition to delete. + :param policy_set_definition_name: The name of the policy set definition to delete. Required. :type policy_set_definition_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: None, or the result of cls(response) + :return: None or the result of cls(response) :rtype: None - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType[None] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + 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', "2019-01-01") # type: str + api_version = kwargs.pop("api_version", _params.pop("api-version", "2019-01-01")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[None] - request = build_policy_set_definitions_delete_request( policy_set_definition_name=policy_set_definition_name, subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.delete.metadata['url'], + template_url=self.delete.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200, 204]: @@ -1560,50 +1992,51 @@ async def delete( # pylint: disable=inconsistent-return-statements if cls: return cls(pipeline_response, None, {}) - delete.metadata = {'url': "/subscriptions/{subscriptionId}/providers/Microsoft.Authorization/policySetDefinitions/{policySetDefinitionName}"} # type: ignore - + delete.metadata = {"url": "/subscriptions/{subscriptionId}/providers/Microsoft.Authorization/policySetDefinitions/{policySetDefinitionName}"} # type: ignore @distributed_trace_async - async def get( - self, - policy_set_definition_name: str, - **kwargs: Any - ) -> "_models.PolicySetDefinition": + async def get(self, policy_set_definition_name: str, **kwargs: Any) -> _models.PolicySetDefinition: """Retrieves a policy set definition. This operation retrieves the policy set definition in the given subscription with the given name. - :param policy_set_definition_name: The name of the policy set definition to get. + :param policy_set_definition_name: The name of the policy set definition to get. Required. :type policy_set_definition_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: PolicySetDefinition, or the result of cls(response) + :return: PolicySetDefinition or the result of cls(response) :rtype: ~azure.mgmt.resource.policy.v2019_01_01.models.PolicySetDefinition - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.PolicySetDefinition"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) - api_version = kwargs.pop('api_version', "2019-01-01") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2019-01-01")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[_models.PolicySetDefinition] - request = build_policy_set_definitions_get_request( policy_set_definition_name=policy_set_definition_name, subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.get.metadata['url'], + template_url=self.get.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200]: @@ -1611,55 +2044,56 @@ async def get( error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - deserialized = self._deserialize('PolicySetDefinition', pipeline_response) + deserialized = self._deserialize("PolicySetDefinition", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - get.metadata = {'url': "/subscriptions/{subscriptionId}/providers/Microsoft.Authorization/policySetDefinitions/{policySetDefinitionName}"} # type: ignore - + get.metadata = {"url": "/subscriptions/{subscriptionId}/providers/Microsoft.Authorization/policySetDefinitions/{policySetDefinitionName}"} # type: ignore @distributed_trace_async - async def get_built_in( - self, - policy_set_definition_name: str, - **kwargs: Any - ) -> "_models.PolicySetDefinition": + async def get_built_in(self, policy_set_definition_name: str, **kwargs: Any) -> _models.PolicySetDefinition: """Retrieves a built in policy set definition. This operation retrieves the built-in policy set definition with the given name. - :param policy_set_definition_name: The name of the policy set definition to get. + :param policy_set_definition_name: The name of the policy set definition to get. Required. :type policy_set_definition_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: PolicySetDefinition, or the result of cls(response) + :return: PolicySetDefinition or the result of cls(response) :rtype: ~azure.mgmt.resource.policy.v2019_01_01.models.PolicySetDefinition - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.PolicySetDefinition"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + 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', "2019-01-01") # type: str + api_version = kwargs.pop("api_version", _params.pop("api-version", "2019-01-01")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[_models.PolicySetDefinition] - request = build_policy_set_definitions_get_built_in_request( policy_set_definition_name=policy_set_definition_name, api_version=api_version, - template_url=self.get_built_in.metadata['url'], + template_url=self.get_built_in.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200]: @@ -1667,58 +2101,62 @@ async def get_built_in( error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - deserialized = self._deserialize('PolicySetDefinition', pipeline_response) + deserialized = self._deserialize("PolicySetDefinition", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - get_built_in.metadata = {'url': "/providers/Microsoft.Authorization/policySetDefinitions/{policySetDefinitionName}"} # type: ignore - + get_built_in.metadata = {"url": "/providers/Microsoft.Authorization/policySetDefinitions/{policySetDefinitionName}"} # type: ignore @distributed_trace - def list( - self, - **kwargs: Any - ) -> AsyncIterable["_models.PolicySetDefinitionListResult"]: + def list(self, **kwargs: Any) -> AsyncIterable["_models.PolicySetDefinition"]: """Retrieves the policy set definitions for a subscription. This operation retrieves a list of all the policy set definitions in the given subscription. :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either PolicySetDefinitionListResult or the result of - cls(response) + :return: An iterator like instance of either PolicySetDefinition or the result of cls(response) :rtype: - ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.resource.policy.v2019_01_01.models.PolicySetDefinitionListResult] - :raises: ~azure.core.exceptions.HttpResponseError + ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.resource.policy.v2019_01_01.models.PolicySetDefinition] + :raises ~azure.core.exceptions.HttpResponseError: """ - api_version = kwargs.pop('api_version', "2019-01-01") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2019-01-01")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[_models.PolicySetDefinitionListResult] - cls = kwargs.pop('cls', None) # type: ClsType["_models.PolicySetDefinitionListResult"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) + def prepare_request(next_link=None): if not next_link: - + request = build_policy_set_definitions_list_request( subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.list.metadata['url'], + template_url=self.list.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore else: - - request = build_policy_set_definitions_list_request( - subscription_id=self._config.subscription_id, - template_url=next_link, - ) + # make call to next link with the client's api-version + _parsed_next_link = urlparse(next_link) + _next_request_params = case_insensitive_dict(parse_qs(_parsed_next_link.query)) + _next_request_params["api-version"] = self._config.api_version + request = HttpRequest("GET", urljoin(next_link, _parsed_next_link.path), params=_next_request_params) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore request.method = "GET" return request @@ -1732,10 +2170,8 @@ async def extract_data(pipeline_response): async def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) response = pipeline_response.http_response @@ -1746,52 +2182,56 @@ async def get_next(next_link=None): return pipeline_response + return AsyncItemPaged(get_next, extract_data) - return AsyncItemPaged( - get_next, extract_data - ) - list.metadata = {'url': "/subscriptions/{subscriptionId}/providers/Microsoft.Authorization/policySetDefinitions"} # type: ignore + list.metadata = {"url": "/subscriptions/{subscriptionId}/providers/Microsoft.Authorization/policySetDefinitions"} # type: ignore @distributed_trace - def list_built_in( - self, - **kwargs: Any - ) -> AsyncIterable["_models.PolicySetDefinitionListResult"]: + def list_built_in(self, **kwargs: Any) -> AsyncIterable["_models.PolicySetDefinition"]: """Retrieves built-in policy set definitions. This operation retrieves a list of all the built-in policy set definitions. :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either PolicySetDefinitionListResult or the result of - cls(response) + :return: An iterator like instance of either PolicySetDefinition or the result of cls(response) :rtype: - ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.resource.policy.v2019_01_01.models.PolicySetDefinitionListResult] - :raises: ~azure.core.exceptions.HttpResponseError + ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.resource.policy.v2019_01_01.models.PolicySetDefinition] + :raises ~azure.core.exceptions.HttpResponseError: """ - api_version = kwargs.pop('api_version', "2019-01-01") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2019-01-01")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[_models.PolicySetDefinitionListResult] - cls = kwargs.pop('cls', None) # type: ClsType["_models.PolicySetDefinitionListResult"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) + def prepare_request(next_link=None): if not next_link: - + request = build_policy_set_definitions_list_built_in_request( api_version=api_version, - template_url=self.list_built_in.metadata['url'], + template_url=self.list_built_in.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore else: - - request = build_policy_set_definitions_list_built_in_request( - template_url=next_link, - ) + # make call to next link with the client's api-version + _parsed_next_link = urlparse(next_link) + _next_request_params = case_insensitive_dict(parse_qs(_parsed_next_link.query)) + _next_request_params["api-version"] = self._config.api_version + request = HttpRequest("GET", urljoin(next_link, _parsed_next_link.path), params=_next_request_params) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore request.method = "GET" return request @@ -1805,10 +2245,8 @@ async def extract_data(pipeline_response): async def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) response = pipeline_response.http_response @@ -1819,46 +2257,120 @@ async def get_next(next_link=None): return pipeline_response + return AsyncItemPaged(get_next, extract_data) - return AsyncItemPaged( - get_next, extract_data - ) - list_built_in.metadata = {'url': "/providers/Microsoft.Authorization/policySetDefinitions"} # type: ignore + list_built_in.metadata = {"url": "/providers/Microsoft.Authorization/policySetDefinitions"} # type: ignore - @distributed_trace_async + @overload async def create_or_update_at_management_group( self, policy_set_definition_name: str, management_group_id: str, - parameters: "_models.PolicySetDefinition", + parameters: _models.PolicySetDefinition, + *, + content_type: str = "application/json", **kwargs: Any - ) -> "_models.PolicySetDefinition": + ) -> _models.PolicySetDefinition: """Creates or updates a policy set definition. This operation creates or updates a policy set definition in the given management group with the given name. - :param policy_set_definition_name: The name of the policy set definition to create. + :param policy_set_definition_name: The name of the policy set definition to create. Required. :type policy_set_definition_name: str - :param management_group_id: The ID of the management group. + :param management_group_id: The ID of the management group. Required. :type management_group_id: str - :param parameters: The policy set definition properties. + :param parameters: The policy set definition properties. Required. :type parameters: ~azure.mgmt.resource.policy.v2019_01_01.models.PolicySetDefinition + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: PolicySetDefinition, or the result of cls(response) + :return: PolicySetDefinition or the result of cls(response) :rtype: ~azure.mgmt.resource.policy.v2019_01_01.models.PolicySetDefinition - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + async def create_or_update_at_management_group( + self, + policy_set_definition_name: str, + management_group_id: str, + parameters: IO, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.PolicySetDefinition: + """Creates or updates a policy set definition. + + This operation creates or updates a policy set definition in the given management group with + the given name. + + :param policy_set_definition_name: The name of the policy set definition to create. Required. + :type policy_set_definition_name: str + :param management_group_id: The ID of the management group. Required. + :type management_group_id: str + :param parameters: The policy set definition properties. Required. + :type parameters: IO + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: PolicySetDefinition or the result of cls(response) + :rtype: ~azure.mgmt.resource.policy.v2019_01_01.models.PolicySetDefinition + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace_async + async def create_or_update_at_management_group( + self, + policy_set_definition_name: str, + management_group_id: str, + parameters: Union[_models.PolicySetDefinition, IO], + **kwargs: Any + ) -> _models.PolicySetDefinition: + """Creates or updates a policy set definition. + + This operation creates or updates a policy set definition in the given management group with + the given name. + + :param policy_set_definition_name: The name of the policy set definition to create. Required. + :type policy_set_definition_name: str + :param management_group_id: The ID of the management group. Required. + :type management_group_id: str + :param parameters: The policy set definition properties. Is either a model type or a IO type. + Required. + :type parameters: ~azure.mgmt.resource.policy.v2019_01_01.models.PolicySetDefinition or IO + :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. + Default value is None. + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: PolicySetDefinition or the result of cls(response) + :rtype: ~azure.mgmt.resource.policy.v2019_01_01.models.PolicySetDefinition + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.PolicySetDefinition"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', "2019-01-01") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + api_version = kwargs.pop("api_version", _params.pop("api-version", "2019-01-01")) # type: str + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.PolicySetDefinition] - _json = self._serialize.body(parameters, 'PolicySetDefinition') + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(parameters, (IO, bytes)): + _content = parameters + else: + _json = self._serialize.body(parameters, "PolicySetDefinition") request = build_policy_set_definitions_create_or_update_at_management_group_request( policy_set_definition_name=policy_set_definition_name, @@ -1866,16 +2378,18 @@ async def create_or_update_at_management_group( api_version=api_version, content_type=content_type, json=_json, - template_url=self.create_or_update_at_management_group.metadata['url'], + content=_content, + template_url=self.create_or_update_at_management_group.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200, 201]: @@ -1884,63 +2398,65 @@ async def create_or_update_at_management_group( raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) if response.status_code == 200: - deserialized = self._deserialize('PolicySetDefinition', pipeline_response) + deserialized = self._deserialize("PolicySetDefinition", pipeline_response) if response.status_code == 201: - deserialized = self._deserialize('PolicySetDefinition', pipeline_response) + deserialized = self._deserialize("PolicySetDefinition", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - create_or_update_at_management_group.metadata = {'url': "/providers/Microsoft.Management/managementgroups/{managementGroupId}/providers/Microsoft.Authorization/policySetDefinitions/{policySetDefinitionName}"} # type: ignore - + create_or_update_at_management_group.metadata = {"url": "/providers/Microsoft.Management/managementgroups/{managementGroupId}/providers/Microsoft.Authorization/policySetDefinitions/{policySetDefinitionName}"} # type: ignore @distributed_trace_async async def delete_at_management_group( # pylint: disable=inconsistent-return-statements - self, - policy_set_definition_name: str, - management_group_id: str, - **kwargs: Any + self, policy_set_definition_name: str, management_group_id: str, **kwargs: Any ) -> None: """Deletes a policy set definition. This operation deletes the policy set definition in the given management group with the given name. - :param policy_set_definition_name: The name of the policy set definition to delete. + :param policy_set_definition_name: The name of the policy set definition to delete. Required. :type policy_set_definition_name: str - :param management_group_id: The ID of the management group. + :param management_group_id: The ID of the management group. Required. :type management_group_id: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: None, or the result of cls(response) + :return: None or the result of cls(response) :rtype: None - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType[None] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + 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', "2019-01-01") # type: str + api_version = kwargs.pop("api_version", _params.pop("api-version", "2019-01-01")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[None] - request = build_policy_set_definitions_delete_at_management_group_request( policy_set_definition_name=policy_set_definition_name, management_group_id=management_group_id, api_version=api_version, - template_url=self.delete_at_management_group.metadata['url'], + template_url=self.delete_at_management_group.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200, 204]: @@ -1951,53 +2467,55 @@ async def delete_at_management_group( # pylint: disable=inconsistent-return-sta if cls: return cls(pipeline_response, None, {}) - delete_at_management_group.metadata = {'url': "/providers/Microsoft.Management/managementgroups/{managementGroupId}/providers/Microsoft.Authorization/policySetDefinitions/{policySetDefinitionName}"} # type: ignore - + delete_at_management_group.metadata = {"url": "/providers/Microsoft.Management/managementgroups/{managementGroupId}/providers/Microsoft.Authorization/policySetDefinitions/{policySetDefinitionName}"} # type: ignore @distributed_trace_async async def get_at_management_group( - self, - policy_set_definition_name: str, - management_group_id: str, - **kwargs: Any - ) -> "_models.PolicySetDefinition": + self, policy_set_definition_name: str, management_group_id: str, **kwargs: Any + ) -> _models.PolicySetDefinition: """Retrieves a policy set definition. This operation retrieves the policy set definition in the given management group with the given name. - :param policy_set_definition_name: The name of the policy set definition to get. + :param policy_set_definition_name: The name of the policy set definition to get. Required. :type policy_set_definition_name: str - :param management_group_id: The ID of the management group. + :param management_group_id: The ID of the management group. Required. :type management_group_id: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: PolicySetDefinition, or the result of cls(response) + :return: PolicySetDefinition or the result of cls(response) :rtype: ~azure.mgmt.resource.policy.v2019_01_01.models.PolicySetDefinition - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.PolicySetDefinition"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + 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', "2019-01-01") # type: str + api_version = kwargs.pop("api_version", _params.pop("api-version", "2019-01-01")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[_models.PolicySetDefinition] - request = build_policy_set_definitions_get_at_management_group_request( policy_set_definition_name=policy_set_definition_name, management_group_id=management_group_id, api_version=api_version, - template_url=self.get_at_management_group.metadata['url'], + template_url=self.get_at_management_group.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200]: @@ -2005,62 +2523,67 @@ async def get_at_management_group( error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - deserialized = self._deserialize('PolicySetDefinition', pipeline_response) + deserialized = self._deserialize("PolicySetDefinition", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - get_at_management_group.metadata = {'url': "/providers/Microsoft.Management/managementgroups/{managementGroupId}/providers/Microsoft.Authorization/policySetDefinitions/{policySetDefinitionName}"} # type: ignore - + get_at_management_group.metadata = {"url": "/providers/Microsoft.Management/managementgroups/{managementGroupId}/providers/Microsoft.Authorization/policySetDefinitions/{policySetDefinitionName}"} # type: ignore @distributed_trace def list_by_management_group( - self, - management_group_id: str, - **kwargs: Any - ) -> AsyncIterable["_models.PolicySetDefinitionListResult"]: + self, management_group_id: str, **kwargs: Any + ) -> AsyncIterable["_models.PolicySetDefinition"]: """Retrieves all policy set definitions in management group. This operation retrieves a list of all the a policy set definition in the given management group. - :param management_group_id: The ID of the management group. + :param management_group_id: The ID of the management group. Required. :type management_group_id: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either PolicySetDefinitionListResult or the result of - cls(response) + :return: An iterator like instance of either PolicySetDefinition or the result of cls(response) :rtype: - ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.resource.policy.v2019_01_01.models.PolicySetDefinitionListResult] - :raises: ~azure.core.exceptions.HttpResponseError + ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.resource.policy.v2019_01_01.models.PolicySetDefinition] + :raises ~azure.core.exceptions.HttpResponseError: """ - api_version = kwargs.pop('api_version', "2019-01-01") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2019-01-01")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[_models.PolicySetDefinitionListResult] - cls = kwargs.pop('cls', None) # type: ClsType["_models.PolicySetDefinitionListResult"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) + def prepare_request(next_link=None): if not next_link: - + request = build_policy_set_definitions_list_by_management_group_request( management_group_id=management_group_id, api_version=api_version, - template_url=self.list_by_management_group.metadata['url'], + template_url=self.list_by_management_group.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore else: - - request = build_policy_set_definitions_list_by_management_group_request( - management_group_id=management_group_id, - template_url=next_link, - ) + # make call to next link with the client's api-version + _parsed_next_link = urlparse(next_link) + _next_request_params = case_insensitive_dict(parse_qs(_parsed_next_link.query)) + _next_request_params["api-version"] = self._config.api_version + request = HttpRequest("GET", urljoin(next_link, _parsed_next_link.path), params=_next_request_params) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore request.method = "GET" return request @@ -2074,10 +2597,8 @@ async def extract_data(pipeline_response): async def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) response = pipeline_response.http_response @@ -2088,8 +2609,6 @@ async def get_next(next_link=None): return pipeline_response + return AsyncItemPaged(get_next, extract_data) - return AsyncItemPaged( - get_next, extract_data - ) - list_by_management_group.metadata = {'url': "/providers/Microsoft.Management/managementgroups/{managementGroupId}/providers/Microsoft.Authorization/policySetDefinitions"} # type: ignore + list_by_management_group.metadata = {"url": "/providers/Microsoft.Management/managementgroups/{managementGroupId}/providers/Microsoft.Authorization/policySetDefinitions"} # type: ignore diff --git a/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/policy/v2019_01_01/aio/operations/_patch.py b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/policy/v2019_01_01/aio/operations/_patch.py new file mode 100644 index 0000000000000..f7dd32510333d --- /dev/null +++ b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/policy/v2019_01_01/aio/operations/_patch.py @@ -0,0 +1,20 @@ +# ------------------------------------ +# Copyright (c) Microsoft Corporation. +# Licensed under the MIT License. +# ------------------------------------ +"""Customize generated code here. + +Follow our quickstart for examples: https://aka.ms/azsdk/python/dpcodegen/python/customize +""" +from typing import List + +__all__: List[str] = [] # Add all objects you want publicly available to users at this package level + + +def patch_sdk(): + """Do not remove from this file. + + `patch_sdk` is a last resort escape hatch that allows you to do customizations + you can't accomplish using the techniques described in + https://aka.ms/azsdk/python/dpcodegen/python/customize + """ diff --git a/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/policy/v2019_01_01/models/__init__.py b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/policy/v2019_01_01/models/__init__.py index f79c6005b1b84..5380b1681926a 100644 --- a/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/policy/v2019_01_01/models/__init__.py +++ b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/policy/v2019_01_01/models/__init__.py @@ -17,23 +17,25 @@ from ._models_py3 import PolicySetDefinitionListResult from ._models_py3 import PolicySku - -from ._policy_client_enums import ( - PolicyType, - ResourceIdentityType, -) +from ._policy_client_enums import PolicyType +from ._policy_client_enums import ResourceIdentityType +from ._patch import __all__ as _patch_all +from ._patch import * # type: ignore # pylint: disable=unused-wildcard-import +from ._patch import patch_sdk as _patch_sdk __all__ = [ - 'ErrorResponse', - 'Identity', - 'PolicyAssignment', - 'PolicyAssignmentListResult', - 'PolicyDefinition', - 'PolicyDefinitionListResult', - 'PolicyDefinitionReference', - 'PolicySetDefinition', - 'PolicySetDefinitionListResult', - 'PolicySku', - 'PolicyType', - 'ResourceIdentityType', + "ErrorResponse", + "Identity", + "PolicyAssignment", + "PolicyAssignmentListResult", + "PolicyDefinition", + "PolicyDefinitionListResult", + "PolicyDefinitionReference", + "PolicySetDefinition", + "PolicySetDefinitionListResult", + "PolicySku", + "PolicyType", + "ResourceIdentityType", ] +__all__.extend([p for p in _patch_all if p not in __all__]) +_patch_sdk() diff --git a/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/policy/v2019_01_01/models/_models_py3.py b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/policy/v2019_01_01/models/_models_py3.py index 0eec5d730d790..c401b59133192 100644 --- a/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/policy/v2019_01_01/models/_models_py3.py +++ b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/policy/v2019_01_01/models/_models_py3.py @@ -1,4 +1,5 @@ # coding=utf-8 +# pylint: disable=too-many-lines # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. # Licensed under the MIT License. See License.txt in the project root for license information. @@ -6,15 +7,22 @@ # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -from typing import Any, List, Optional, Union +import sys +from typing import Any, List, Optional, TYPE_CHECKING, Union -from azure.core.exceptions import HttpResponseError -import msrest.serialization +from ... import _serialization -from ._policy_client_enums import * +if TYPE_CHECKING: + # pylint: disable=unused-import,ungrouped-imports + from .. import models as _models +if sys.version_info >= (3, 9): + from collections.abc import MutableMapping +else: + from typing import MutableMapping # type: ignore # pylint: disable=ungrouped-imports +JSON = MutableMapping[str, Any] # pylint: disable=unsubscriptable-object -class ErrorResponse(msrest.serialization.Model): +class ErrorResponse(_serialization.Model): """Error response indicates Azure Resource Manager is not able to process the incoming request. The reason is provided in the error message. :ivar http_status: Http status code. @@ -26,9 +34,9 @@ class ErrorResponse(msrest.serialization.Model): """ _attribute_map = { - 'http_status': {'key': 'httpStatus', 'type': 'str'}, - 'error_code': {'key': 'errorCode', 'type': 'str'}, - 'error_message': {'key': 'errorMessage', 'type': 'str'}, + "http_status": {"key": "httpStatus", "type": "str"}, + "error_code": {"key": "errorCode", "type": "str"}, + "error_message": {"key": "errorMessage", "type": "str"}, } def __init__( @@ -47,13 +55,13 @@ def __init__( :keyword error_message: Error message indicating why the operation failed. :paramtype error_message: str """ - super(ErrorResponse, self).__init__(**kwargs) + super().__init__(**kwargs) self.http_status = http_status self.error_code = error_code self.error_message = error_message -class Identity(msrest.serialization.Model): +class Identity(_serialization.Model): """Identity for the resource. Variables are only populated by the server, and will be ignored when sending a request. @@ -62,38 +70,33 @@ class Identity(msrest.serialization.Model): :vartype principal_id: str :ivar tenant_id: The tenant ID of the resource identity. :vartype tenant_id: str - :ivar type: The identity type. Possible values include: "SystemAssigned", "None". + :ivar type: The identity type. Known values are: "SystemAssigned" and "None". :vartype type: str or ~azure.mgmt.resource.policy.v2019_01_01.models.ResourceIdentityType """ _validation = { - 'principal_id': {'readonly': True}, - 'tenant_id': {'readonly': True}, + "principal_id": {"readonly": True}, + "tenant_id": {"readonly": True}, } _attribute_map = { - 'principal_id': {'key': 'principalId', 'type': 'str'}, - 'tenant_id': {'key': 'tenantId', 'type': 'str'}, - 'type': {'key': 'type', 'type': 'str'}, + "principal_id": {"key": "principalId", "type": "str"}, + "tenant_id": {"key": "tenantId", "type": "str"}, + "type": {"key": "type", "type": "str"}, } - def __init__( - self, - *, - type: Optional[Union[str, "ResourceIdentityType"]] = None, - **kwargs - ): + def __init__(self, *, type: Optional[Union[str, "_models.ResourceIdentityType"]] = None, **kwargs): """ - :keyword type: The identity type. Possible values include: "SystemAssigned", "None". + :keyword type: The identity type. Known values are: "SystemAssigned" and "None". :paramtype type: str or ~azure.mgmt.resource.policy.v2019_01_01.models.ResourceIdentityType """ - super(Identity, self).__init__(**kwargs) + super().__init__(**kwargs) self.principal_id = None self.tenant_id = None self.type = type -class PolicyAssignment(msrest.serialization.Model): +class PolicyAssignment(_serialization.Model): # pylint: disable=too-many-instance-attributes """The policy assignment. Variables are only populated by the server, and will be ignored when sending a request. @@ -121,48 +124,48 @@ class PolicyAssignment(msrest.serialization.Model): :ivar not_scopes: The policy's excluded scopes. :vartype not_scopes: list[str] :ivar parameters: Required if a parameter is used in policy rule. - :vartype parameters: any + :vartype parameters: JSON :ivar description: This message will be part of response in case of policy violation. :vartype description: str :ivar metadata: The policy assignment metadata. - :vartype metadata: any + :vartype metadata: JSON """ _validation = { - 'id': {'readonly': True}, - 'type': {'readonly': True}, - 'name': {'readonly': True}, + "id": {"readonly": True}, + "type": {"readonly": True}, + "name": {"readonly": True}, } _attribute_map = { - 'id': {'key': 'id', 'type': 'str'}, - 'type': {'key': 'type', 'type': 'str'}, - 'name': {'key': 'name', 'type': 'str'}, - 'sku': {'key': 'sku', 'type': 'PolicySku'}, - 'location': {'key': 'location', 'type': 'str'}, - 'identity': {'key': 'identity', 'type': 'Identity'}, - 'display_name': {'key': 'properties.displayName', 'type': 'str'}, - 'policy_definition_id': {'key': 'properties.policyDefinitionId', 'type': 'str'}, - 'scope': {'key': 'properties.scope', 'type': 'str'}, - 'not_scopes': {'key': 'properties.notScopes', 'type': '[str]'}, - 'parameters': {'key': 'properties.parameters', 'type': 'object'}, - 'description': {'key': 'properties.description', 'type': 'str'}, - 'metadata': {'key': 'properties.metadata', 'type': 'object'}, + "id": {"key": "id", "type": "str"}, + "type": {"key": "type", "type": "str"}, + "name": {"key": "name", "type": "str"}, + "sku": {"key": "sku", "type": "PolicySku"}, + "location": {"key": "location", "type": "str"}, + "identity": {"key": "identity", "type": "Identity"}, + "display_name": {"key": "properties.displayName", "type": "str"}, + "policy_definition_id": {"key": "properties.policyDefinitionId", "type": "str"}, + "scope": {"key": "properties.scope", "type": "str"}, + "not_scopes": {"key": "properties.notScopes", "type": "[str]"}, + "parameters": {"key": "properties.parameters", "type": "object"}, + "description": {"key": "properties.description", "type": "str"}, + "metadata": {"key": "properties.metadata", "type": "object"}, } def __init__( self, *, - sku: Optional["PolicySku"] = None, + sku: Optional["_models.PolicySku"] = None, location: Optional[str] = None, - identity: Optional["Identity"] = None, + identity: Optional["_models.Identity"] = None, display_name: Optional[str] = None, policy_definition_id: Optional[str] = None, scope: Optional[str] = None, not_scopes: Optional[List[str]] = None, - parameters: Optional[Any] = None, + parameters: Optional[JSON] = None, description: Optional[str] = None, - metadata: Optional[Any] = None, + metadata: Optional[JSON] = None, **kwargs ): """ @@ -183,13 +186,13 @@ def __init__( :keyword not_scopes: The policy's excluded scopes. :paramtype not_scopes: list[str] :keyword parameters: Required if a parameter is used in policy rule. - :paramtype parameters: any + :paramtype parameters: JSON :keyword description: This message will be part of response in case of policy violation. :paramtype description: str :keyword metadata: The policy assignment metadata. - :paramtype metadata: any + :paramtype metadata: JSON """ - super(PolicyAssignment, self).__init__(**kwargs) + super().__init__(**kwargs) self.id = None self.type = None self.name = None @@ -205,7 +208,7 @@ def __init__( self.metadata = metadata -class PolicyAssignmentListResult(msrest.serialization.Model): +class PolicyAssignmentListResult(_serialization.Model): """List of policy assignments. :ivar value: An array of policy assignments. @@ -215,16 +218,12 @@ class PolicyAssignmentListResult(msrest.serialization.Model): """ _attribute_map = { - 'value': {'key': 'value', 'type': '[PolicyAssignment]'}, - 'next_link': {'key': 'nextLink', 'type': 'str'}, + "value": {"key": "value", "type": "[PolicyAssignment]"}, + "next_link": {"key": "nextLink", "type": "str"}, } def __init__( - self, - *, - value: Optional[List["PolicyAssignment"]] = None, - next_link: Optional[str] = None, - **kwargs + self, *, value: Optional[List["_models.PolicyAssignment"]] = None, next_link: Optional[str] = None, **kwargs ): """ :keyword value: An array of policy assignments. @@ -232,12 +231,12 @@ def __init__( :keyword next_link: The URL to use for getting the next set of results. :paramtype next_link: str """ - super(PolicyAssignmentListResult, self).__init__(**kwargs) + super().__init__(**kwargs) self.value = value self.next_link = next_link -class PolicyDefinition(msrest.serialization.Model): +class PolicyDefinition(_serialization.Model): """The policy definition. Variables are only populated by the server, and will be ignored when sending a request. @@ -249,7 +248,7 @@ class PolicyDefinition(msrest.serialization.Model): :ivar type: The type of the resource (Microsoft.Authorization/policyDefinitions). :vartype type: str :ivar policy_type: The type of policy definition. Possible values are NotSpecified, BuiltIn, - and Custom. Possible values include: "NotSpecified", "BuiltIn", "Custom". + and Custom. Known values are: "NotSpecified", "BuiltIn", and "Custom". :vartype policy_type: str or ~azure.mgmt.resource.policy.v2019_01_01.models.PolicyType :ivar mode: The policy definition mode. Some examples are All, Indexed, Microsoft.KeyVault.Data. @@ -259,47 +258,47 @@ class PolicyDefinition(msrest.serialization.Model): :ivar description: The policy definition description. :vartype description: str :ivar policy_rule: The policy rule. - :vartype policy_rule: any + :vartype policy_rule: JSON :ivar metadata: The policy definition metadata. - :vartype metadata: any + :vartype metadata: JSON :ivar parameters: Required if a parameter is used in policy rule. - :vartype parameters: any + :vartype parameters: JSON """ _validation = { - 'id': {'readonly': True}, - 'name': {'readonly': True}, - 'type': {'readonly': True}, + "id": {"readonly": True}, + "name": {"readonly": True}, + "type": {"readonly": True}, } _attribute_map = { - 'id': {'key': 'id', 'type': 'str'}, - 'name': {'key': 'name', 'type': 'str'}, - 'type': {'key': 'type', 'type': 'str'}, - 'policy_type': {'key': 'properties.policyType', 'type': 'str'}, - 'mode': {'key': 'properties.mode', 'type': 'str'}, - 'display_name': {'key': 'properties.displayName', 'type': 'str'}, - 'description': {'key': 'properties.description', 'type': 'str'}, - 'policy_rule': {'key': 'properties.policyRule', 'type': 'object'}, - 'metadata': {'key': 'properties.metadata', 'type': 'object'}, - 'parameters': {'key': 'properties.parameters', 'type': 'object'}, + "id": {"key": "id", "type": "str"}, + "name": {"key": "name", "type": "str"}, + "type": {"key": "type", "type": "str"}, + "policy_type": {"key": "properties.policyType", "type": "str"}, + "mode": {"key": "properties.mode", "type": "str"}, + "display_name": {"key": "properties.displayName", "type": "str"}, + "description": {"key": "properties.description", "type": "str"}, + "policy_rule": {"key": "properties.policyRule", "type": "object"}, + "metadata": {"key": "properties.metadata", "type": "object"}, + "parameters": {"key": "properties.parameters", "type": "object"}, } def __init__( self, *, - policy_type: Optional[Union[str, "PolicyType"]] = None, + policy_type: Optional[Union[str, "_models.PolicyType"]] = None, mode: Optional[str] = None, display_name: Optional[str] = None, description: Optional[str] = None, - policy_rule: Optional[Any] = None, - metadata: Optional[Any] = None, - parameters: Optional[Any] = None, + policy_rule: Optional[JSON] = None, + metadata: Optional[JSON] = None, + parameters: Optional[JSON] = None, **kwargs ): """ :keyword policy_type: The type of policy definition. Possible values are NotSpecified, BuiltIn, - and Custom. Possible values include: "NotSpecified", "BuiltIn", "Custom". + and Custom. Known values are: "NotSpecified", "BuiltIn", and "Custom". :paramtype policy_type: str or ~azure.mgmt.resource.policy.v2019_01_01.models.PolicyType :keyword mode: The policy definition mode. Some examples are All, Indexed, Microsoft.KeyVault.Data. @@ -309,13 +308,13 @@ def __init__( :keyword description: The policy definition description. :paramtype description: str :keyword policy_rule: The policy rule. - :paramtype policy_rule: any + :paramtype policy_rule: JSON :keyword metadata: The policy definition metadata. - :paramtype metadata: any + :paramtype metadata: JSON :keyword parameters: Required if a parameter is used in policy rule. - :paramtype parameters: any + :paramtype parameters: JSON """ - super(PolicyDefinition, self).__init__(**kwargs) + super().__init__(**kwargs) self.id = None self.name = None self.type = None @@ -328,7 +327,7 @@ def __init__( self.parameters = parameters -class PolicyDefinitionListResult(msrest.serialization.Model): +class PolicyDefinitionListResult(_serialization.Model): """List of policy definitions. :ivar value: An array of policy definitions. @@ -338,16 +337,12 @@ class PolicyDefinitionListResult(msrest.serialization.Model): """ _attribute_map = { - 'value': {'key': 'value', 'type': '[PolicyDefinition]'}, - 'next_link': {'key': 'nextLink', 'type': 'str'}, + "value": {"key": "value", "type": "[PolicyDefinition]"}, + "next_link": {"key": "nextLink", "type": "str"}, } def __init__( - self, - *, - value: Optional[List["PolicyDefinition"]] = None, - next_link: Optional[str] = None, - **kwargs + self, *, value: Optional[List["_models.PolicyDefinition"]] = None, next_link: Optional[str] = None, **kwargs ): """ :keyword value: An array of policy definitions. @@ -355,44 +350,38 @@ def __init__( :keyword next_link: The URL to use for getting the next set of results. :paramtype next_link: str """ - super(PolicyDefinitionListResult, self).__init__(**kwargs) + super().__init__(**kwargs) self.value = value self.next_link = next_link -class PolicyDefinitionReference(msrest.serialization.Model): +class PolicyDefinitionReference(_serialization.Model): """The policy definition reference. :ivar policy_definition_id: The ID of the policy definition or policy set definition. :vartype policy_definition_id: str :ivar parameters: Required if a parameter is used in policy rule. - :vartype parameters: any + :vartype parameters: JSON """ _attribute_map = { - 'policy_definition_id': {'key': 'policyDefinitionId', 'type': 'str'}, - 'parameters': {'key': 'parameters', 'type': 'object'}, + "policy_definition_id": {"key": "policyDefinitionId", "type": "str"}, + "parameters": {"key": "parameters", "type": "object"}, } - def __init__( - self, - *, - policy_definition_id: Optional[str] = None, - parameters: Optional[Any] = None, - **kwargs - ): + def __init__(self, *, policy_definition_id: Optional[str] = None, parameters: Optional[JSON] = None, **kwargs): """ :keyword policy_definition_id: The ID of the policy definition or policy set definition. :paramtype policy_definition_id: str :keyword parameters: Required if a parameter is used in policy rule. - :paramtype parameters: any + :paramtype parameters: JSON """ - super(PolicyDefinitionReference, self).__init__(**kwargs) + super().__init__(**kwargs) self.policy_definition_id = policy_definition_id self.parameters = parameters -class PolicySetDefinition(msrest.serialization.Model): +class PolicySetDefinition(_serialization.Model): """The policy set definition. Variables are only populated by the server, and will be ignored when sending a request. @@ -404,69 +393,69 @@ class PolicySetDefinition(msrest.serialization.Model): :ivar type: The type of the resource (Microsoft.Authorization/policySetDefinitions). :vartype type: str :ivar policy_type: The type of policy definition. Possible values are NotSpecified, BuiltIn, - and Custom. Possible values include: "NotSpecified", "BuiltIn", "Custom". + and Custom. Known values are: "NotSpecified", "BuiltIn", and "Custom". :vartype policy_type: str or ~azure.mgmt.resource.policy.v2019_01_01.models.PolicyType :ivar display_name: The display name of the policy set definition. :vartype display_name: str :ivar description: The policy set definition description. :vartype description: str :ivar metadata: The policy set definition metadata. - :vartype metadata: any + :vartype metadata: JSON :ivar parameters: The policy set definition parameters that can be used in policy definition references. - :vartype parameters: any + :vartype parameters: JSON :ivar policy_definitions: An array of policy definition references. :vartype policy_definitions: list[~azure.mgmt.resource.policy.v2019_01_01.models.PolicyDefinitionReference] """ _validation = { - 'id': {'readonly': True}, - 'name': {'readonly': True}, - 'type': {'readonly': True}, + "id": {"readonly": True}, + "name": {"readonly": True}, + "type": {"readonly": True}, } _attribute_map = { - 'id': {'key': 'id', 'type': 'str'}, - 'name': {'key': 'name', 'type': 'str'}, - 'type': {'key': 'type', 'type': 'str'}, - 'policy_type': {'key': 'properties.policyType', 'type': 'str'}, - 'display_name': {'key': 'properties.displayName', 'type': 'str'}, - 'description': {'key': 'properties.description', 'type': 'str'}, - 'metadata': {'key': 'properties.metadata', 'type': 'object'}, - 'parameters': {'key': 'properties.parameters', 'type': 'object'}, - 'policy_definitions': {'key': 'properties.policyDefinitions', 'type': '[PolicyDefinitionReference]'}, + "id": {"key": "id", "type": "str"}, + "name": {"key": "name", "type": "str"}, + "type": {"key": "type", "type": "str"}, + "policy_type": {"key": "properties.policyType", "type": "str"}, + "display_name": {"key": "properties.displayName", "type": "str"}, + "description": {"key": "properties.description", "type": "str"}, + "metadata": {"key": "properties.metadata", "type": "object"}, + "parameters": {"key": "properties.parameters", "type": "object"}, + "policy_definitions": {"key": "properties.policyDefinitions", "type": "[PolicyDefinitionReference]"}, } def __init__( self, *, - policy_type: Optional[Union[str, "PolicyType"]] = None, + policy_type: Optional[Union[str, "_models.PolicyType"]] = None, display_name: Optional[str] = None, description: Optional[str] = None, - metadata: Optional[Any] = None, - parameters: Optional[Any] = None, - policy_definitions: Optional[List["PolicyDefinitionReference"]] = None, + metadata: Optional[JSON] = None, + parameters: Optional[JSON] = None, + policy_definitions: Optional[List["_models.PolicyDefinitionReference"]] = None, **kwargs ): """ :keyword policy_type: The type of policy definition. Possible values are NotSpecified, BuiltIn, - and Custom. Possible values include: "NotSpecified", "BuiltIn", "Custom". + and Custom. Known values are: "NotSpecified", "BuiltIn", and "Custom". :paramtype policy_type: str or ~azure.mgmt.resource.policy.v2019_01_01.models.PolicyType :keyword display_name: The display name of the policy set definition. :paramtype display_name: str :keyword description: The policy set definition description. :paramtype description: str :keyword metadata: The policy set definition metadata. - :paramtype metadata: any + :paramtype metadata: JSON :keyword parameters: The policy set definition parameters that can be used in policy definition references. - :paramtype parameters: any + :paramtype parameters: JSON :keyword policy_definitions: An array of policy definition references. :paramtype policy_definitions: list[~azure.mgmt.resource.policy.v2019_01_01.models.PolicyDefinitionReference] """ - super(PolicySetDefinition, self).__init__(**kwargs) + super().__init__(**kwargs) self.id = None self.name = None self.type = None @@ -478,7 +467,7 @@ def __init__( self.policy_definitions = policy_definitions -class PolicySetDefinitionListResult(msrest.serialization.Model): +class PolicySetDefinitionListResult(_serialization.Model): """List of policy set definitions. :ivar value: An array of policy set definitions. @@ -488,16 +477,12 @@ class PolicySetDefinitionListResult(msrest.serialization.Model): """ _attribute_map = { - 'value': {'key': 'value', 'type': '[PolicySetDefinition]'}, - 'next_link': {'key': 'nextLink', 'type': 'str'}, + "value": {"key": "value", "type": "[PolicySetDefinition]"}, + "next_link": {"key": "nextLink", "type": "str"}, } def __init__( - self, - *, - value: Optional[List["PolicySetDefinition"]] = None, - next_link: Optional[str] = None, - **kwargs + self, *, value: Optional[List["_models.PolicySetDefinition"]] = None, next_link: Optional[str] = None, **kwargs ): """ :keyword value: An array of policy set definitions. @@ -505,44 +490,38 @@ def __init__( :keyword next_link: The URL to use for getting the next set of results. :paramtype next_link: str """ - super(PolicySetDefinitionListResult, self).__init__(**kwargs) + super().__init__(**kwargs) self.value = value self.next_link = next_link -class PolicySku(msrest.serialization.Model): +class PolicySku(_serialization.Model): """The policy sku. This property is optional, obsolete, and will be ignored. All required parameters must be populated in order to send to Azure. - :ivar name: Required. The name of the policy sku. Possible values are A0 and A1. + :ivar name: The name of the policy sku. Possible values are A0 and A1. Required. :vartype name: str :ivar tier: The policy sku tier. Possible values are Free and Standard. :vartype tier: str """ _validation = { - 'name': {'required': True}, + "name": {"required": True}, } _attribute_map = { - 'name': {'key': 'name', 'type': 'str'}, - 'tier': {'key': 'tier', 'type': 'str'}, + "name": {"key": "name", "type": "str"}, + "tier": {"key": "tier", "type": "str"}, } - def __init__( - self, - *, - name: str, - tier: Optional[str] = None, - **kwargs - ): + def __init__(self, *, name: str, tier: Optional[str] = None, **kwargs): """ - :keyword name: Required. The name of the policy sku. Possible values are A0 and A1. + :keyword name: The name of the policy sku. Possible values are A0 and A1. Required. :paramtype name: str :keyword tier: The policy sku tier. Possible values are Free and Standard. :paramtype tier: str """ - super(PolicySku, self).__init__(**kwargs) + super().__init__(**kwargs) self.name = name self.tier = tier diff --git a/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/policy/v2019_01_01/models/_patch.py b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/policy/v2019_01_01/models/_patch.py new file mode 100644 index 0000000000000..f7dd32510333d --- /dev/null +++ b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/policy/v2019_01_01/models/_patch.py @@ -0,0 +1,20 @@ +# ------------------------------------ +# Copyright (c) Microsoft Corporation. +# Licensed under the MIT License. +# ------------------------------------ +"""Customize generated code here. + +Follow our quickstart for examples: https://aka.ms/azsdk/python/dpcodegen/python/customize +""" +from typing import List + +__all__: List[str] = [] # Add all objects you want publicly available to users at this package level + + +def patch_sdk(): + """Do not remove from this file. + + `patch_sdk` is a last resort escape hatch that allows you to do customizations + you can't accomplish using the techniques described in + https://aka.ms/azsdk/python/dpcodegen/python/customize + """ diff --git a/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/policy/v2019_01_01/models/_policy_client_enums.py b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/policy/v2019_01_01/models/_policy_client_enums.py index 4650214a26848..133cdf113326c 100644 --- a/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/policy/v2019_01_01/models/_policy_client_enums.py +++ b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/policy/v2019_01_01/models/_policy_client_enums.py @@ -7,21 +7,19 @@ # -------------------------------------------------------------------------- from enum import Enum -from six import with_metaclass from azure.core import CaseInsensitiveEnumMeta -class PolicyType(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): - """The type of policy definition. Possible values are NotSpecified, BuiltIn, and Custom. - """ +class PolicyType(str, Enum, metaclass=CaseInsensitiveEnumMeta): + """The type of policy definition. Possible values are NotSpecified, BuiltIn, and Custom.""" NOT_SPECIFIED = "NotSpecified" BUILT_IN = "BuiltIn" CUSTOM = "Custom" -class ResourceIdentityType(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): - """The identity type. - """ + +class ResourceIdentityType(str, Enum, metaclass=CaseInsensitiveEnumMeta): + """The identity type.""" SYSTEM_ASSIGNED = "SystemAssigned" NONE = "None" diff --git a/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/policy/v2019_01_01/operations/__init__.py b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/policy/v2019_01_01/operations/__init__.py index b2ae6190b03fb..4e1971e3e3247 100644 --- a/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/policy/v2019_01_01/operations/__init__.py +++ b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/policy/v2019_01_01/operations/__init__.py @@ -10,8 +10,14 @@ from ._operations import PolicyDefinitionsOperations from ._operations import PolicySetDefinitionsOperations +from ._patch import __all__ as _patch_all +from ._patch import * # type: ignore # pylint: disable=unused-wildcard-import +from ._patch import patch_sdk as _patch_sdk + __all__ = [ - 'PolicyAssignmentsOperations', - 'PolicyDefinitionsOperations', - 'PolicySetDefinitionsOperations', + "PolicyAssignmentsOperations", + "PolicyDefinitionsOperations", + "PolicySetDefinitionsOperations", ] +__all__.extend([p for p in _patch_all if p not in __all__]) +_patch_sdk() diff --git a/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/policy/v2019_01_01/operations/_operations.py b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/policy/v2019_01_01/operations/_operations.py index 347db613961dd..bf04b3c63943d 100644 --- a/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/policy/v2019_01_01/operations/_operations.py +++ b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/policy/v2019_01_01/operations/_operations.py @@ -6,173 +6,152 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -from typing import Any, Callable, Dict, Iterable, Optional, TypeVar - -from msrest import Serializer - -from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error +from typing import Any, Callable, Dict, IO, Iterable, Optional, TypeVar, Union, overload +from urllib.parse import parse_qs, urljoin, urlparse + +from azure.core.exceptions import ( + ClientAuthenticationError, + HttpResponseError, + ResourceExistsError, + ResourceNotFoundError, + ResourceNotModifiedError, + map_error, +) from azure.core.paging import ItemPaged from azure.core.pipeline import PipelineResponse from azure.core.pipeline.transport import HttpResponse from azure.core.rest import HttpRequest from azure.core.tracing.decorator import distributed_trace +from azure.core.utils import case_insensitive_dict from azure.mgmt.core.exceptions import ARMErrorFormat from .. import models as _models +from ..._serialization import Serializer from .._vendor import _convert_request, _format_url_section -T = TypeVar('T') -JSONType = Any + +T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] _SERIALIZER = Serializer() _SERIALIZER.client_side_validation = False -def build_policy_assignments_delete_request( - scope: str, - policy_assignment_name: str, - **kwargs: Any -) -> HttpRequest: - api_version = kwargs.pop('api_version', "2019-01-01") # type: str - accept = "application/json" +def build_policy_assignments_delete_request(scope: str, policy_assignment_name: 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", "2019-01-01")) # type: str + accept = _headers.pop("Accept", "application/json") + # Construct URL - _url = kwargs.pop("template_url", "/{scope}/providers/Microsoft.Authorization/policyAssignments/{policyAssignmentName}") + _url = kwargs.pop( + "template_url", "/{scope}/providers/Microsoft.Authorization/policyAssignments/{policyAssignmentName}" + ) path_format_arguments = { - "scope": _SERIALIZER.url("scope", scope, 'str', skip_quote=True), - "policyAssignmentName": _SERIALIZER.url("policy_assignment_name", policy_assignment_name, 'str'), + "scope": _SERIALIZER.url("scope", scope, "str", skip_quote=True), + "policyAssignmentName": _SERIALIZER.url("policy_assignment_name", policy_assignment_name, "str"), } _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') - - return HttpRequest( - method="DELETE", - url=_url, - params=_query_parameters, - headers=_header_parameters, - **kwargs - ) + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + return HttpRequest(method="DELETE", url=_url, params=_params, headers=_headers, **kwargs) -def build_policy_assignments_create_request( - scope: str, - policy_assignment_name: str, - *, - json: JSONType = None, - content: Any = None, - **kwargs: Any -) -> HttpRequest: - api_version = kwargs.pop('api_version', "2019-01-01") # type: str - content_type = kwargs.pop('content_type', None) # type: Optional[str] - accept = "application/json" +def build_policy_assignments_create_request(scope: str, policy_assignment_name: 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", "2019-01-01")) # type: str + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + accept = _headers.pop("Accept", "application/json") + # Construct URL - _url = kwargs.pop("template_url", "/{scope}/providers/Microsoft.Authorization/policyAssignments/{policyAssignmentName}") + _url = kwargs.pop( + "template_url", "/{scope}/providers/Microsoft.Authorization/policyAssignments/{policyAssignmentName}" + ) path_format_arguments = { - "scope": _SERIALIZER.url("scope", scope, 'str', skip_quote=True), - "policyAssignmentName": _SERIALIZER.url("policy_assignment_name", policy_assignment_name, 'str'), + "scope": _SERIALIZER.url("scope", scope, "str", skip_quote=True), + "policyAssignmentName": _SERIALIZER.url("policy_assignment_name", policy_assignment_name, "str"), } _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] if content_type is not None: - _header_parameters['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') - _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') - - return HttpRequest( - method="PUT", - url=_url, - params=_query_parameters, - headers=_header_parameters, - json=json, - content=content, - **kwargs - ) + _headers["Content-Type"] = _SERIALIZER.header("content_type", content_type, "str") + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + return HttpRequest(method="PUT", url=_url, params=_params, headers=_headers, **kwargs) -def build_policy_assignments_get_request( - scope: str, - policy_assignment_name: str, - **kwargs: Any -) -> HttpRequest: - api_version = kwargs.pop('api_version', "2019-01-01") # type: str - accept = "application/json" +def build_policy_assignments_get_request(scope: str, policy_assignment_name: 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", "2019-01-01")) # type: str + accept = _headers.pop("Accept", "application/json") + # Construct URL - _url = kwargs.pop("template_url", "/{scope}/providers/Microsoft.Authorization/policyAssignments/{policyAssignmentName}") + _url = kwargs.pop( + "template_url", "/{scope}/providers/Microsoft.Authorization/policyAssignments/{policyAssignmentName}" + ) path_format_arguments = { - "scope": _SERIALIZER.url("scope", scope, 'str', skip_quote=True), - "policyAssignmentName": _SERIALIZER.url("policy_assignment_name", policy_assignment_name, 'str'), + "scope": _SERIALIZER.url("scope", scope, "str", skip_quote=True), + "policyAssignmentName": _SERIALIZER.url("policy_assignment_name", policy_assignment_name, "str"), } _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') - - return HttpRequest( - method="GET", - url=_url, - params=_query_parameters, - headers=_header_parameters, - **kwargs - ) + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) def build_policy_assignments_list_for_resource_group_request( - resource_group_name: str, - subscription_id: str, - *, - filter: Optional[str] = None, - **kwargs: Any + resource_group_name: str, subscription_id: str, *, filter: Optional[str] = None, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2019-01-01") # type: 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", "2019-01-01")) # type: str + accept = _headers.pop("Accept", "application/json") - accept = "application/json" # Construct URL - _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Authorization/policyAssignments") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Authorization/policyAssignments", + ) # pylint: disable=line-too-long path_format_arguments = { - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._\(\)]+$'), - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), + "resourceGroupName": _SERIALIZER.url( + "resource_group_name", resource_group_name, "str", max_length=90, min_length=1, pattern=r"^[-\w\._\(\)]+$" + ), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), } _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] if filter is not None: - _query_parameters['$filter'] = _SERIALIZER.query("filter", filter, 'str', skip_quote=True) - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["$filter"] = _SERIALIZER.query("filter", filter, "str", skip_quote=True) + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') - - return HttpRequest( - method="GET", - url=_url, - params=_query_parameters, - headers=_header_parameters, - **kwargs - ) + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) def build_policy_assignments_list_for_resource_request( @@ -186,881 +165,723 @@ def build_policy_assignments_list_for_resource_request( filter: Optional[str] = None, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2019-01-01") # type: 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", "2019-01-01")) # type: str + accept = _headers.pop("Accept", "application/json") - accept = "application/json" # Construct URL - _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{parentResourcePath}/{resourceType}/{resourceName}/providers/Microsoft.Authorization/policyAssignments") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{parentResourcePath}/{resourceType}/{resourceName}/providers/Microsoft.Authorization/policyAssignments", + ) # pylint: disable=line-too-long path_format_arguments = { - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._\(\)]+$'), - "resourceProviderNamespace": _SERIALIZER.url("resource_provider_namespace", resource_provider_namespace, 'str'), - "parentResourcePath": _SERIALIZER.url("parent_resource_path", parent_resource_path, 'str', skip_quote=True), - "resourceType": _SERIALIZER.url("resource_type", resource_type, 'str', skip_quote=True), - "resourceName": _SERIALIZER.url("resource_name", resource_name, 'str'), - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), + "resourceGroupName": _SERIALIZER.url( + "resource_group_name", resource_group_name, "str", max_length=90, min_length=1, pattern=r"^[-\w\._\(\)]+$" + ), + "resourceProviderNamespace": _SERIALIZER.url("resource_provider_namespace", resource_provider_namespace, "str"), + "parentResourcePath": _SERIALIZER.url("parent_resource_path", parent_resource_path, "str", skip_quote=True), + "resourceType": _SERIALIZER.url("resource_type", resource_type, "str", skip_quote=True), + "resourceName": _SERIALIZER.url("resource_name", resource_name, "str"), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), } _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] if filter is not None: - _query_parameters['$filter'] = _SERIALIZER.query("filter", filter, 'str') - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["$filter"] = _SERIALIZER.query("filter", filter, "str") + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') - - return HttpRequest( - method="GET", - url=_url, - params=_query_parameters, - headers=_header_parameters, - **kwargs - ) + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) def build_policy_assignments_list_request( - subscription_id: str, - *, - filter: Optional[str] = None, - **kwargs: Any + subscription_id: str, *, filter: Optional[str] = None, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2019-01-01") # type: 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", "2019-01-01")) # type: str + accept = _headers.pop("Accept", "application/json") - accept = "application/json" # Construct URL - _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/providers/Microsoft.Authorization/policyAssignments") + _url = kwargs.pop( + "template_url", "/subscriptions/{subscriptionId}/providers/Microsoft.Authorization/policyAssignments" + ) path_format_arguments = { - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), } _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] if filter is not None: - _query_parameters['$filter'] = _SERIALIZER.query("filter", filter, 'str') - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["$filter"] = _SERIALIZER.query("filter", filter, "str") + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') - - return HttpRequest( - method="GET", - url=_url, - params=_query_parameters, - headers=_header_parameters, - **kwargs - ) + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) -def build_policy_assignments_delete_by_id_request( - policy_assignment_id: str, - **kwargs: Any -) -> HttpRequest: - api_version = kwargs.pop('api_version', "2019-01-01") # type: str - accept = "application/json" +def build_policy_assignments_delete_by_id_request(policy_assignment_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", "2019-01-01")) # type: str + accept = _headers.pop("Accept", "application/json") + # Construct URL _url = kwargs.pop("template_url", "/{policyAssignmentId}") path_format_arguments = { - "policyAssignmentId": _SERIALIZER.url("policy_assignment_id", policy_assignment_id, 'str', skip_quote=True), + "policyAssignmentId": _SERIALIZER.url("policy_assignment_id", policy_assignment_id, "str", skip_quote=True), } _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') - - return HttpRequest( - method="DELETE", - url=_url, - params=_query_parameters, - headers=_header_parameters, - **kwargs - ) + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + return HttpRequest(method="DELETE", url=_url, params=_params, headers=_headers, **kwargs) -def build_policy_assignments_create_by_id_request( - policy_assignment_id: str, - *, - json: JSONType = None, - content: Any = None, - **kwargs: Any -) -> HttpRequest: - api_version = kwargs.pop('api_version', "2019-01-01") # type: str - content_type = kwargs.pop('content_type', None) # type: Optional[str] - accept = "application/json" +def build_policy_assignments_create_by_id_request(policy_assignment_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", "2019-01-01")) # type: str + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + accept = _headers.pop("Accept", "application/json") + # Construct URL _url = kwargs.pop("template_url", "/{policyAssignmentId}") path_format_arguments = { - "policyAssignmentId": _SERIALIZER.url("policy_assignment_id", policy_assignment_id, 'str', skip_quote=True), + "policyAssignmentId": _SERIALIZER.url("policy_assignment_id", policy_assignment_id, "str", skip_quote=True), } _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] if content_type is not None: - _header_parameters['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') - _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') - - return HttpRequest( - method="PUT", - url=_url, - params=_query_parameters, - headers=_header_parameters, - json=json, - content=content, - **kwargs - ) + _headers["Content-Type"] = _SERIALIZER.header("content_type", content_type, "str") + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + return HttpRequest(method="PUT", url=_url, params=_params, headers=_headers, **kwargs) -def build_policy_assignments_get_by_id_request( - policy_assignment_id: str, - **kwargs: Any -) -> HttpRequest: - api_version = kwargs.pop('api_version', "2019-01-01") # type: str - accept = "application/json" +def build_policy_assignments_get_by_id_request(policy_assignment_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", "2019-01-01")) # type: str + accept = _headers.pop("Accept", "application/json") + # Construct URL _url = kwargs.pop("template_url", "/{policyAssignmentId}") path_format_arguments = { - "policyAssignmentId": _SERIALIZER.url("policy_assignment_id", policy_assignment_id, 'str', skip_quote=True), + "policyAssignmentId": _SERIALIZER.url("policy_assignment_id", policy_assignment_id, "str", skip_quote=True), } _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') - - return HttpRequest( - method="GET", - url=_url, - params=_query_parameters, - headers=_header_parameters, - **kwargs - ) + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) def build_policy_definitions_create_or_update_request( - policy_definition_name: str, - subscription_id: str, - *, - json: JSONType = None, - content: Any = None, - **kwargs: Any + policy_definition_name: str, subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2019-01-01") # type: str - content_type = kwargs.pop('content_type', None) # type: Optional[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", "2019-01-01")) # type: str + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + accept = _headers.pop("Accept", "application/json") - accept = "application/json" # Construct URL - _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/providers/Microsoft.Authorization/policyDefinitions/{policyDefinitionName}") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/providers/Microsoft.Authorization/policyDefinitions/{policyDefinitionName}", + ) # pylint: disable=line-too-long path_format_arguments = { - "policyDefinitionName": _SERIALIZER.url("policy_definition_name", policy_definition_name, 'str'), - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), + "policyDefinitionName": _SERIALIZER.url("policy_definition_name", policy_definition_name, "str"), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), } _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] if content_type is not None: - _header_parameters['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') - _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') - - return HttpRequest( - method="PUT", - url=_url, - params=_query_parameters, - headers=_header_parameters, - json=json, - content=content, - **kwargs - ) + _headers["Content-Type"] = _SERIALIZER.header("content_type", content_type, "str") + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="PUT", url=_url, params=_params, headers=_headers, **kwargs) def build_policy_definitions_delete_request( - policy_definition_name: str, - subscription_id: str, - **kwargs: Any + policy_definition_name: str, subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2019-01-01") # type: str + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + api_version = kwargs.pop("api_version", _params.pop("api-version", "2019-01-01")) # type: str # Construct URL - _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/providers/Microsoft.Authorization/policyDefinitions/{policyDefinitionName}") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/providers/Microsoft.Authorization/policyDefinitions/{policyDefinitionName}", + ) # pylint: disable=line-too-long path_format_arguments = { - "policyDefinitionName": _SERIALIZER.url("policy_definition_name", policy_definition_name, 'str'), - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), + "policyDefinitionName": _SERIALIZER.url("policy_definition_name", policy_definition_name, "str"), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), } _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') - - return HttpRequest( - method="DELETE", - url=_url, - params=_query_parameters, - **kwargs - ) + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") + + return HttpRequest(method="DELETE", url=_url, params=_params, **kwargs) def build_policy_definitions_get_request( - policy_definition_name: str, - subscription_id: str, - **kwargs: Any + policy_definition_name: str, subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2019-01-01") # type: 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", "2019-01-01")) # type: str + accept = _headers.pop("Accept", "application/json") - accept = "application/json" # Construct URL - _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/providers/Microsoft.Authorization/policyDefinitions/{policyDefinitionName}") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/providers/Microsoft.Authorization/policyDefinitions/{policyDefinitionName}", + ) # pylint: disable=line-too-long path_format_arguments = { - "policyDefinitionName": _SERIALIZER.url("policy_definition_name", policy_definition_name, 'str'), - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), + "policyDefinitionName": _SERIALIZER.url("policy_definition_name", policy_definition_name, "str"), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), } _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') - - return HttpRequest( - method="GET", - url=_url, - params=_query_parameters, - headers=_header_parameters, - **kwargs - ) + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) -def build_policy_definitions_get_built_in_request( - policy_definition_name: str, - **kwargs: Any -) -> HttpRequest: - api_version = kwargs.pop('api_version', "2019-01-01") # type: str - accept = "application/json" +def build_policy_definitions_get_built_in_request(policy_definition_name: 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", "2019-01-01")) # type: str + accept = _headers.pop("Accept", "application/json") + # Construct URL _url = kwargs.pop("template_url", "/providers/Microsoft.Authorization/policyDefinitions/{policyDefinitionName}") path_format_arguments = { - "policyDefinitionName": _SERIALIZER.url("policy_definition_name", policy_definition_name, 'str'), + "policyDefinitionName": _SERIALIZER.url("policy_definition_name", policy_definition_name, "str"), } _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') - - return HttpRequest( - method="GET", - url=_url, - params=_query_parameters, - headers=_header_parameters, - **kwargs - ) + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) def build_policy_definitions_create_or_update_at_management_group_request( - policy_definition_name: str, - management_group_id: str, - *, - json: JSONType = None, - content: Any = None, - **kwargs: Any + policy_definition_name: str, management_group_id: str, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2019-01-01") # type: str - content_type = kwargs.pop('content_type', None) # type: Optional[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", "2019-01-01")) # type: str + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + accept = _headers.pop("Accept", "application/json") - accept = "application/json" # Construct URL - _url = kwargs.pop("template_url", "/providers/Microsoft.Management/managementgroups/{managementGroupId}/providers/Microsoft.Authorization/policyDefinitions/{policyDefinitionName}") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", + "/providers/Microsoft.Management/managementgroups/{managementGroupId}/providers/Microsoft.Authorization/policyDefinitions/{policyDefinitionName}", + ) # pylint: disable=line-too-long path_format_arguments = { - "policyDefinitionName": _SERIALIZER.url("policy_definition_name", policy_definition_name, 'str'), - "managementGroupId": _SERIALIZER.url("management_group_id", management_group_id, 'str'), + "policyDefinitionName": _SERIALIZER.url("policy_definition_name", policy_definition_name, "str"), + "managementGroupId": _SERIALIZER.url("management_group_id", management_group_id, "str"), } _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] if content_type is not None: - _header_parameters['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') - _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') - - return HttpRequest( - method="PUT", - url=_url, - params=_query_parameters, - headers=_header_parameters, - json=json, - content=content, - **kwargs - ) + _headers["Content-Type"] = _SERIALIZER.header("content_type", content_type, "str") + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="PUT", url=_url, params=_params, headers=_headers, **kwargs) def build_policy_definitions_delete_at_management_group_request( - policy_definition_name: str, - management_group_id: str, - **kwargs: Any + policy_definition_name: str, management_group_id: str, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2019-01-01") # type: str + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + api_version = kwargs.pop("api_version", _params.pop("api-version", "2019-01-01")) # type: str # Construct URL - _url = kwargs.pop("template_url", "/providers/Microsoft.Management/managementgroups/{managementGroupId}/providers/Microsoft.Authorization/policyDefinitions/{policyDefinitionName}") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", + "/providers/Microsoft.Management/managementgroups/{managementGroupId}/providers/Microsoft.Authorization/policyDefinitions/{policyDefinitionName}", + ) # pylint: disable=line-too-long path_format_arguments = { - "policyDefinitionName": _SERIALIZER.url("policy_definition_name", policy_definition_name, 'str'), - "managementGroupId": _SERIALIZER.url("management_group_id", management_group_id, 'str'), + "policyDefinitionName": _SERIALIZER.url("policy_definition_name", policy_definition_name, "str"), + "managementGroupId": _SERIALIZER.url("management_group_id", management_group_id, "str"), } _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') - - return HttpRequest( - method="DELETE", - url=_url, - params=_query_parameters, - **kwargs - ) + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") + + return HttpRequest(method="DELETE", url=_url, params=_params, **kwargs) def build_policy_definitions_get_at_management_group_request( - policy_definition_name: str, - management_group_id: str, - **kwargs: Any + policy_definition_name: str, management_group_id: str, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2019-01-01") # type: 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", "2019-01-01")) # type: str + accept = _headers.pop("Accept", "application/json") - accept = "application/json" # Construct URL - _url = kwargs.pop("template_url", "/providers/Microsoft.Management/managementgroups/{managementGroupId}/providers/Microsoft.Authorization/policyDefinitions/{policyDefinitionName}") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", + "/providers/Microsoft.Management/managementgroups/{managementGroupId}/providers/Microsoft.Authorization/policyDefinitions/{policyDefinitionName}", + ) # pylint: disable=line-too-long path_format_arguments = { - "policyDefinitionName": _SERIALIZER.url("policy_definition_name", policy_definition_name, 'str'), - "managementGroupId": _SERIALIZER.url("management_group_id", management_group_id, 'str'), + "policyDefinitionName": _SERIALIZER.url("policy_definition_name", policy_definition_name, "str"), + "managementGroupId": _SERIALIZER.url("management_group_id", management_group_id, "str"), } _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') - - return HttpRequest( - method="GET", - url=_url, - params=_query_parameters, - headers=_header_parameters, - **kwargs - ) + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) -def build_policy_definitions_list_request( - subscription_id: str, - **kwargs: Any -) -> HttpRequest: - api_version = kwargs.pop('api_version', "2019-01-01") # type: str - accept = "application/json" +def build_policy_definitions_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", "2019-01-01")) # type: str + accept = _headers.pop("Accept", "application/json") + # Construct URL - _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/providers/Microsoft.Authorization/policyDefinitions") + _url = kwargs.pop( + "template_url", "/subscriptions/{subscriptionId}/providers/Microsoft.Authorization/policyDefinitions" + ) path_format_arguments = { - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), } _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') - - return HttpRequest( - method="GET", - url=_url, - params=_query_parameters, - headers=_header_parameters, - **kwargs - ) + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) -def build_policy_definitions_list_built_in_request( - **kwargs: Any -) -> HttpRequest: - api_version = kwargs.pop('api_version', "2019-01-01") # type: str - accept = "application/json" +def build_policy_definitions_list_built_in_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", "2019-01-01")) # type: str + accept = _headers.pop("Accept", "application/json") + # Construct URL _url = kwargs.pop("template_url", "/providers/Microsoft.Authorization/policyDefinitions") # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') - - return HttpRequest( - method="GET", - url=_url, - params=_query_parameters, - headers=_header_parameters, - **kwargs - ) + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) -def build_policy_definitions_list_by_management_group_request( - management_group_id: str, - **kwargs: Any -) -> HttpRequest: - api_version = kwargs.pop('api_version', "2019-01-01") # type: str - accept = "application/json" +def build_policy_definitions_list_by_management_group_request(management_group_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", "2019-01-01")) # type: str + accept = _headers.pop("Accept", "application/json") + # Construct URL - _url = kwargs.pop("template_url", "/providers/Microsoft.Management/managementgroups/{managementGroupId}/providers/Microsoft.Authorization/policyDefinitions") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", + "/providers/Microsoft.Management/managementgroups/{managementGroupId}/providers/Microsoft.Authorization/policyDefinitions", + ) # pylint: disable=line-too-long path_format_arguments = { - "managementGroupId": _SERIALIZER.url("management_group_id", management_group_id, 'str'), + "managementGroupId": _SERIALIZER.url("management_group_id", management_group_id, "str"), } _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') - - return HttpRequest( - method="GET", - url=_url, - params=_query_parameters, - headers=_header_parameters, - **kwargs - ) + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) def build_policy_set_definitions_create_or_update_request( - policy_set_definition_name: str, - subscription_id: str, - *, - json: JSONType = None, - content: Any = None, - **kwargs: Any + policy_set_definition_name: str, subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2019-01-01") # type: str - content_type = kwargs.pop('content_type', None) # type: Optional[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", "2019-01-01")) # type: str + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + accept = _headers.pop("Accept", "application/json") - accept = "application/json" # Construct URL - _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/providers/Microsoft.Authorization/policySetDefinitions/{policySetDefinitionName}") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/providers/Microsoft.Authorization/policySetDefinitions/{policySetDefinitionName}", + ) # pylint: disable=line-too-long path_format_arguments = { - "policySetDefinitionName": _SERIALIZER.url("policy_set_definition_name", policy_set_definition_name, 'str'), - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), + "policySetDefinitionName": _SERIALIZER.url("policy_set_definition_name", policy_set_definition_name, "str"), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), } _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] if content_type is not None: - _header_parameters['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') - _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') - - return HttpRequest( - method="PUT", - url=_url, - params=_query_parameters, - headers=_header_parameters, - json=json, - content=content, - **kwargs - ) + _headers["Content-Type"] = _SERIALIZER.header("content_type", content_type, "str") + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="PUT", url=_url, params=_params, headers=_headers, **kwargs) def build_policy_set_definitions_delete_request( - policy_set_definition_name: str, - subscription_id: str, - **kwargs: Any + policy_set_definition_name: str, subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2019-01-01") # type: 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", "2019-01-01")) # type: str + accept = _headers.pop("Accept", "application/json") - accept = "application/json" # Construct URL - _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/providers/Microsoft.Authorization/policySetDefinitions/{policySetDefinitionName}") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/providers/Microsoft.Authorization/policySetDefinitions/{policySetDefinitionName}", + ) # pylint: disable=line-too-long path_format_arguments = { - "policySetDefinitionName": _SERIALIZER.url("policy_set_definition_name", policy_set_definition_name, 'str'), - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), + "policySetDefinitionName": _SERIALIZER.url("policy_set_definition_name", policy_set_definition_name, "str"), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), } _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') - - return HttpRequest( - method="DELETE", - url=_url, - params=_query_parameters, - headers=_header_parameters, - **kwargs - ) + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="DELETE", url=_url, params=_params, headers=_headers, **kwargs) def build_policy_set_definitions_get_request( - policy_set_definition_name: str, - subscription_id: str, - **kwargs: Any + policy_set_definition_name: str, subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2019-01-01") # type: 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", "2019-01-01")) # type: str + accept = _headers.pop("Accept", "application/json") - accept = "application/json" # Construct URL - _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/providers/Microsoft.Authorization/policySetDefinitions/{policySetDefinitionName}") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/providers/Microsoft.Authorization/policySetDefinitions/{policySetDefinitionName}", + ) # pylint: disable=line-too-long path_format_arguments = { - "policySetDefinitionName": _SERIALIZER.url("policy_set_definition_name", policy_set_definition_name, 'str'), - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), + "policySetDefinitionName": _SERIALIZER.url("policy_set_definition_name", policy_set_definition_name, "str"), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), } _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') - - return HttpRequest( - method="GET", - url=_url, - params=_query_parameters, - headers=_header_parameters, - **kwargs - ) + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) -def build_policy_set_definitions_get_built_in_request( - policy_set_definition_name: str, - **kwargs: Any -) -> HttpRequest: - api_version = kwargs.pop('api_version', "2019-01-01") # type: str - accept = "application/json" +def build_policy_set_definitions_get_built_in_request(policy_set_definition_name: 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", "2019-01-01")) # type: str + accept = _headers.pop("Accept", "application/json") + # Construct URL - _url = kwargs.pop("template_url", "/providers/Microsoft.Authorization/policySetDefinitions/{policySetDefinitionName}") + _url = kwargs.pop( + "template_url", "/providers/Microsoft.Authorization/policySetDefinitions/{policySetDefinitionName}" + ) path_format_arguments = { - "policySetDefinitionName": _SERIALIZER.url("policy_set_definition_name", policy_set_definition_name, 'str'), + "policySetDefinitionName": _SERIALIZER.url("policy_set_definition_name", policy_set_definition_name, "str"), } _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') - - return HttpRequest( - method="GET", - url=_url, - params=_query_parameters, - headers=_header_parameters, - **kwargs - ) + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) -def build_policy_set_definitions_list_request( - subscription_id: str, - **kwargs: Any -) -> HttpRequest: - api_version = kwargs.pop('api_version', "2019-01-01") # type: str - accept = "application/json" +def build_policy_set_definitions_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", "2019-01-01")) # type: str + accept = _headers.pop("Accept", "application/json") + # Construct URL - _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/providers/Microsoft.Authorization/policySetDefinitions") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", "/subscriptions/{subscriptionId}/providers/Microsoft.Authorization/policySetDefinitions" + ) # pylint: disable=line-too-long path_format_arguments = { - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), } _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') - - return HttpRequest( - method="GET", - url=_url, - params=_query_parameters, - headers=_header_parameters, - **kwargs - ) + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) -def build_policy_set_definitions_list_built_in_request( - **kwargs: Any -) -> HttpRequest: - api_version = kwargs.pop('api_version', "2019-01-01") # type: str - accept = "application/json" +def build_policy_set_definitions_list_built_in_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", "2019-01-01")) # type: str + accept = _headers.pop("Accept", "application/json") + # Construct URL _url = kwargs.pop("template_url", "/providers/Microsoft.Authorization/policySetDefinitions") # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') - - return HttpRequest( - method="GET", - url=_url, - params=_query_parameters, - headers=_header_parameters, - **kwargs - ) + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) def build_policy_set_definitions_create_or_update_at_management_group_request( - policy_set_definition_name: str, - management_group_id: str, - *, - json: JSONType = None, - content: Any = None, - **kwargs: Any + policy_set_definition_name: str, management_group_id: str, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2019-01-01") # type: str - content_type = kwargs.pop('content_type', None) # type: Optional[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", "2019-01-01")) # type: str + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + accept = _headers.pop("Accept", "application/json") - accept = "application/json" # Construct URL - _url = kwargs.pop("template_url", "/providers/Microsoft.Management/managementgroups/{managementGroupId}/providers/Microsoft.Authorization/policySetDefinitions/{policySetDefinitionName}") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", + "/providers/Microsoft.Management/managementgroups/{managementGroupId}/providers/Microsoft.Authorization/policySetDefinitions/{policySetDefinitionName}", + ) # pylint: disable=line-too-long path_format_arguments = { - "policySetDefinitionName": _SERIALIZER.url("policy_set_definition_name", policy_set_definition_name, 'str'), - "managementGroupId": _SERIALIZER.url("management_group_id", management_group_id, 'str'), + "policySetDefinitionName": _SERIALIZER.url("policy_set_definition_name", policy_set_definition_name, "str"), + "managementGroupId": _SERIALIZER.url("management_group_id", management_group_id, "str"), } _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] if content_type is not None: - _header_parameters['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') - _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') - - return HttpRequest( - method="PUT", - url=_url, - params=_query_parameters, - headers=_header_parameters, - json=json, - content=content, - **kwargs - ) + _headers["Content-Type"] = _SERIALIZER.header("content_type", content_type, "str") + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="PUT", url=_url, params=_params, headers=_headers, **kwargs) def build_policy_set_definitions_delete_at_management_group_request( - policy_set_definition_name: str, - management_group_id: str, - **kwargs: Any + policy_set_definition_name: str, management_group_id: str, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2019-01-01") # type: 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", "2019-01-01")) # type: str + accept = _headers.pop("Accept", "application/json") - accept = "application/json" # Construct URL - _url = kwargs.pop("template_url", "/providers/Microsoft.Management/managementgroups/{managementGroupId}/providers/Microsoft.Authorization/policySetDefinitions/{policySetDefinitionName}") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", + "/providers/Microsoft.Management/managementgroups/{managementGroupId}/providers/Microsoft.Authorization/policySetDefinitions/{policySetDefinitionName}", + ) # pylint: disable=line-too-long path_format_arguments = { - "policySetDefinitionName": _SERIALIZER.url("policy_set_definition_name", policy_set_definition_name, 'str'), - "managementGroupId": _SERIALIZER.url("management_group_id", management_group_id, 'str'), + "policySetDefinitionName": _SERIALIZER.url("policy_set_definition_name", policy_set_definition_name, "str"), + "managementGroupId": _SERIALIZER.url("management_group_id", management_group_id, "str"), } _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') - - return HttpRequest( - method="DELETE", - url=_url, - params=_query_parameters, - headers=_header_parameters, - **kwargs - ) + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="DELETE", url=_url, params=_params, headers=_headers, **kwargs) def build_policy_set_definitions_get_at_management_group_request( - policy_set_definition_name: str, - management_group_id: str, - **kwargs: Any + policy_set_definition_name: str, management_group_id: str, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2019-01-01") # type: 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", "2019-01-01")) # type: str + accept = _headers.pop("Accept", "application/json") - accept = "application/json" # Construct URL - _url = kwargs.pop("template_url", "/providers/Microsoft.Management/managementgroups/{managementGroupId}/providers/Microsoft.Authorization/policySetDefinitions/{policySetDefinitionName}") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", + "/providers/Microsoft.Management/managementgroups/{managementGroupId}/providers/Microsoft.Authorization/policySetDefinitions/{policySetDefinitionName}", + ) # pylint: disable=line-too-long path_format_arguments = { - "policySetDefinitionName": _SERIALIZER.url("policy_set_definition_name", policy_set_definition_name, 'str'), - "managementGroupId": _SERIALIZER.url("management_group_id", management_group_id, 'str'), + "policySetDefinitionName": _SERIALIZER.url("policy_set_definition_name", policy_set_definition_name, "str"), + "managementGroupId": _SERIALIZER.url("management_group_id", management_group_id, "str"), } _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') - - return HttpRequest( - method="GET", - url=_url, - params=_query_parameters, - headers=_header_parameters, - **kwargs - ) + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) def build_policy_set_definitions_list_by_management_group_request( - management_group_id: str, - **kwargs: Any + management_group_id: str, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2019-01-01") # type: 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", "2019-01-01")) # type: str + accept = _headers.pop("Accept", "application/json") - accept = "application/json" # Construct URL - _url = kwargs.pop("template_url", "/providers/Microsoft.Management/managementgroups/{managementGroupId}/providers/Microsoft.Authorization/policySetDefinitions") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", + "/providers/Microsoft.Management/managementgroups/{managementGroupId}/providers/Microsoft.Authorization/policySetDefinitions", + ) # pylint: disable=line-too-long path_format_arguments = { - "managementGroupId": _SERIALIZER.url("management_group_id", management_group_id, 'str'), + "managementGroupId": _SERIALIZER.url("management_group_id", management_group_id, "str"), } _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') - - return HttpRequest( - method="GET", - url=_url, - params=_query_parameters, - headers=_header_parameters, - **kwargs - ) + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") -class PolicyAssignmentsOperations(object): - """PolicyAssignmentsOperations operations. + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) - You should not instantiate this class directly. Instead, you should create a Client instance that - instantiates it for you and attaches it as an attribute. - :ivar models: Alias to model classes used in this operation group. - :type models: ~azure.mgmt.resource.policy.v2019_01_01.models - :param client: Client for service requests. - :param config: Configuration of service client. - :param serializer: An object model serializer. - :param deserializer: An object model deserializer. +class PolicyAssignmentsOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. + + Instead, you should access the following operations through + :class:`~azure.mgmt.resource.policy.v2019_01_01.PolicyClient`'s + :attr:`policy_assignments` attribute. """ models = _models - def __init__(self, client, config, serializer, deserializer): - self._client = client - self._serialize = serializer - self._deserialize = deserializer - self._config = config + def __init__(self, *args, **kwargs): + input_args = list(args) + self._client = input_args.pop(0) if input_args else kwargs.pop("client") + self._config = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") @distributed_trace - def delete( - self, - scope: str, - policy_assignment_name: str, - **kwargs: Any - ) -> Optional["_models.PolicyAssignment"]: + def delete(self, scope: str, policy_assignment_name: str, **kwargs: Any) -> Optional[_models.PolicyAssignment]: """Deletes a policy assignment. This operation deletes a policy assignment, given its name and the scope it was created in. The @@ -1072,37 +893,44 @@ def delete( '/subscriptions/{subscriptionId}'), resource group (format: '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}', or resource (format: '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{resourceProviderNamespace}/[{parentResourcePath}/]{resourceType}/{resourceName}'. + Required. :type scope: str - :param policy_assignment_name: The name of the policy assignment to delete. + :param policy_assignment_name: The name of the policy assignment to delete. Required. :type policy_assignment_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: PolicyAssignment, or the result of cls(response) + :return: PolicyAssignment or None or the result of cls(response) :rtype: ~azure.mgmt.resource.policy.v2019_01_01.models.PolicyAssignment or None - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType[Optional["_models.PolicyAssignment"]] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) - api_version = kwargs.pop('api_version', "2019-01-01") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2019-01-01")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[Optional[_models.PolicyAssignment]] - request = build_policy_assignments_delete_request( scope=scope, policy_assignment_name=policy_assignment_name, api_version=api_version, - template_url=self.delete.metadata['url'], + template_url=self.delete.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200, 204]: @@ -1112,24 +940,25 @@ def delete( deserialized = None if response.status_code == 200: - deserialized = self._deserialize('PolicyAssignment', pipeline_response) + deserialized = self._deserialize("PolicyAssignment", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - delete.metadata = {'url': "/{scope}/providers/Microsoft.Authorization/policyAssignments/{policyAssignmentName}"} # type: ignore - + delete.metadata = {"url": "/{scope}/providers/Microsoft.Authorization/policyAssignments/{policyAssignmentName}"} # type: ignore - @distributed_trace + @overload def create( self, scope: str, policy_assignment_name: str, - parameters: "_models.PolicyAssignment", + parameters: _models.PolicyAssignment, + *, + content_type: str = "application/json", **kwargs: Any - ) -> "_models.PolicyAssignment": + ) -> _models.PolicyAssignment: """Creates or updates a policy assignment. This operation creates or updates a policy assignment with the given scope and name. Policy @@ -1141,26 +970,109 @@ def create( '/subscriptions/{subscriptionId}'), resource group (format: '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}', or resource (format: '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{resourceProviderNamespace}/[{parentResourcePath}/]{resourceType}/{resourceName}'. + Required. :type scope: str - :param policy_assignment_name: The name of the policy assignment. + :param policy_assignment_name: The name of the policy assignment. Required. :type policy_assignment_name: str - :param parameters: Parameters for the policy assignment. + :param parameters: Parameters for the policy assignment. Required. :type parameters: ~azure.mgmt.resource.policy.v2019_01_01.models.PolicyAssignment + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: PolicyAssignment or the result of cls(response) + :rtype: ~azure.mgmt.resource.policy.v2019_01_01.models.PolicyAssignment + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + def create( + self, + scope: str, + policy_assignment_name: str, + parameters: IO, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.PolicyAssignment: + """Creates or updates a policy assignment. + + This operation creates or updates a policy assignment with the given scope and name. Policy + assignments apply to all resources contained within their scope. For example, when you assign a + policy at resource group scope, that policy applies to all resources in the group. + + :param scope: The scope of the policy assignment. Valid scopes are: management group (format: + '/providers/Microsoft.Management/managementGroups/{managementGroup}'), subscription (format: + '/subscriptions/{subscriptionId}'), resource group (format: + '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}', or resource (format: + '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{resourceProviderNamespace}/[{parentResourcePath}/]{resourceType}/{resourceName}'. + Required. + :type scope: str + :param policy_assignment_name: The name of the policy assignment. Required. + :type policy_assignment_name: str + :param parameters: Parameters for the policy assignment. Required. + :type parameters: IO + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: PolicyAssignment or the result of cls(response) + :rtype: ~azure.mgmt.resource.policy.v2019_01_01.models.PolicyAssignment + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace + def create( + self, scope: str, policy_assignment_name: str, parameters: Union[_models.PolicyAssignment, IO], **kwargs: Any + ) -> _models.PolicyAssignment: + """Creates or updates a policy assignment. + + This operation creates or updates a policy assignment with the given scope and name. Policy + assignments apply to all resources contained within their scope. For example, when you assign a + policy at resource group scope, that policy applies to all resources in the group. + + :param scope: The scope of the policy assignment. Valid scopes are: management group (format: + '/providers/Microsoft.Management/managementGroups/{managementGroup}'), subscription (format: + '/subscriptions/{subscriptionId}'), resource group (format: + '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}', or resource (format: + '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{resourceProviderNamespace}/[{parentResourcePath}/]{resourceType}/{resourceName}'. + Required. + :type scope: str + :param policy_assignment_name: The name of the policy assignment. Required. + :type policy_assignment_name: str + :param parameters: Parameters for the policy assignment. Is either a model type or a IO type. + Required. + :type parameters: ~azure.mgmt.resource.policy.v2019_01_01.models.PolicyAssignment or IO + :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. + Default value is None. + :paramtype content_type: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: PolicyAssignment, or the result of cls(response) + :return: PolicyAssignment or the result of cls(response) :rtype: ~azure.mgmt.resource.policy.v2019_01_01.models.PolicyAssignment - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.PolicyAssignment"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', "2019-01-01") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + api_version = kwargs.pop("api_version", _params.pop("api-version", "2019-01-01")) # type: str + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.PolicyAssignment] - _json = self._serialize.body(parameters, 'PolicyAssignment') + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(parameters, (IO, bytes)): + _content = parameters + else: + _json = self._serialize.body(parameters, "PolicyAssignment") request = build_policy_assignments_create_request( scope=scope, @@ -1168,16 +1080,18 @@ def create( api_version=api_version, content_type=content_type, json=_json, - template_url=self.create.metadata['url'], + content=_content, + template_url=self.create.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [201]: @@ -1185,23 +1099,17 @@ def create( error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - deserialized = self._deserialize('PolicyAssignment', pipeline_response) + deserialized = self._deserialize("PolicyAssignment", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - create.metadata = {'url': "/{scope}/providers/Microsoft.Authorization/policyAssignments/{policyAssignmentName}"} # type: ignore - + create.metadata = {"url": "/{scope}/providers/Microsoft.Authorization/policyAssignments/{policyAssignmentName}"} # type: ignore @distributed_trace - def get( - self, - scope: str, - policy_assignment_name: str, - **kwargs: Any - ) -> "_models.PolicyAssignment": + def get(self, scope: str, policy_assignment_name: str, **kwargs: Any) -> _models.PolicyAssignment: """Retrieves a policy assignment. This operation retrieves a single policy assignment, given its name and the scope it was @@ -1212,37 +1120,44 @@ def get( '/subscriptions/{subscriptionId}'), resource group (format: '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}', or resource (format: '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{resourceProviderNamespace}/[{parentResourcePath}/]{resourceType}/{resourceName}'. + Required. :type scope: str - :param policy_assignment_name: The name of the policy assignment to get. + :param policy_assignment_name: The name of the policy assignment to get. Required. :type policy_assignment_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: PolicyAssignment, or the result of cls(response) + :return: PolicyAssignment or the result of cls(response) :rtype: ~azure.mgmt.resource.policy.v2019_01_01.models.PolicyAssignment - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.PolicyAssignment"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + 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', "2019-01-01") # type: str + api_version = kwargs.pop("api_version", _params.pop("api-version", "2019-01-01")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[_models.PolicyAssignment] - request = build_policy_assignments_get_request( scope=scope, policy_assignment_name=policy_assignment_name, api_version=api_version, - template_url=self.get.metadata['url'], + template_url=self.get.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200]: @@ -1250,23 +1165,19 @@ def get( error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - deserialized = self._deserialize('PolicyAssignment', pipeline_response) + deserialized = self._deserialize("PolicyAssignment", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - get.metadata = {'url': "/{scope}/providers/Microsoft.Authorization/policyAssignments/{policyAssignmentName}"} # type: ignore - + get.metadata = {"url": "/{scope}/providers/Microsoft.Authorization/policyAssignments/{policyAssignmentName}"} # type: ignore @distributed_trace def list_for_resource_group( - self, - resource_group_name: str, - filter: Optional[str] = None, - **kwargs: Any - ) -> Iterable["_models.PolicyAssignmentListResult"]: + self, resource_group_name: str, filter: Optional[str] = None, **kwargs: Any + ) -> Iterable["_models.PolicyAssignment"]: """Retrieves all policy assignments that apply to a resource group. This operation retrieves the list of all policy assignments associated with the given resource @@ -1281,47 +1192,55 @@ def list_for_resource_group( assignments of the policy definition whose id is {value} that apply to the resource group. :param resource_group_name: The name of the resource group that contains policy assignments. + Required. :type resource_group_name: str :param filter: The filter to apply on the operation. Valid values for $filter are: 'atScope()' or 'policyDefinitionId eq '{value}''. If $filter is not provided, no filtering is performed. Default value is None. :type filter: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either PolicyAssignmentListResult or the result of - cls(response) + :return: An iterator like instance of either PolicyAssignment or the result of cls(response) :rtype: - ~azure.core.paging.ItemPaged[~azure.mgmt.resource.policy.v2019_01_01.models.PolicyAssignmentListResult] - :raises: ~azure.core.exceptions.HttpResponseError + ~azure.core.paging.ItemPaged[~azure.mgmt.resource.policy.v2019_01_01.models.PolicyAssignment] + :raises ~azure.core.exceptions.HttpResponseError: """ - api_version = kwargs.pop('api_version', "2019-01-01") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2019-01-01")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[_models.PolicyAssignmentListResult] - cls = kwargs.pop('cls', None) # type: ClsType["_models.PolicyAssignmentListResult"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) + def prepare_request(next_link=None): if not next_link: - + request = build_policy_assignments_list_for_resource_group_request( resource_group_name=resource_group_name, subscription_id=self._config.subscription_id, - api_version=api_version, filter=filter, - template_url=self.list_for_resource_group.metadata['url'], + api_version=api_version, + template_url=self.list_for_resource_group.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore else: - - request = build_policy_assignments_list_for_resource_group_request( - resource_group_name=resource_group_name, - subscription_id=self._config.subscription_id, - template_url=next_link, - ) + # make call to next link with the client's api-version + _parsed_next_link = urlparse(next_link) + _next_request_params = case_insensitive_dict(parse_qs(_parsed_next_link.query)) + _next_request_params["api-version"] = self._config.api_version + request = HttpRequest("GET", urljoin(next_link, _parsed_next_link.path), params=_next_request_params) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore request.method = "GET" return request @@ -1335,10 +1254,8 @@ def extract_data(pipeline_response): def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) response = pipeline_response.http_response @@ -1349,11 +1266,9 @@ def get_next(next_link=None): return pipeline_response + return ItemPaged(get_next, extract_data) - return ItemPaged( - get_next, extract_data - ) - list_for_resource_group.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Authorization/policyAssignments"} # type: ignore + list_for_resource_group.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Authorization/policyAssignments"} # type: ignore @distributed_trace def list_for_resource( @@ -1365,7 +1280,7 @@ def list_for_resource( resource_name: str, filter: Optional[str] = None, **kwargs: Any - ) -> Iterable["_models.PolicyAssignmentListResult"]: + ) -> Iterable["_models.PolicyAssignment"]: """Retrieves all policy assignments that apply to a resource. This operation retrieves the list of all policy assignments associated with the specified @@ -1391,39 +1306,47 @@ def list_for_resource( {parentResourcePath} == '', {resourceType} == 'Microsoft.Web/sites', {resourceName} == 'MyWebApp'). - :param resource_group_name: The name of the resource group containing the resource. + :param resource_group_name: The name of the resource group containing the resource. Required. :type resource_group_name: str :param resource_provider_namespace: The namespace of the resource provider. For example, the namespace of a virtual machine is Microsoft.Compute (from Microsoft.Compute/virtualMachines). + Required. :type resource_provider_namespace: str :param parent_resource_path: The parent resource path. Use empty string if there is none. + Required. :type parent_resource_path: str :param resource_type: The resource type name. For example the type name of a web app is 'sites' - (from Microsoft.Web/sites). + (from Microsoft.Web/sites). Required. :type resource_type: str - :param resource_name: The name of the resource. + :param resource_name: The name of the resource. Required. :type resource_name: str :param filter: The filter to apply on the operation. Valid values for $filter are: 'atScope()' or 'policyDefinitionId eq '{value}''. If $filter is not provided, no filtering is performed. Default value is None. :type filter: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either PolicyAssignmentListResult or the result of - cls(response) + :return: An iterator like instance of either PolicyAssignment or the result of cls(response) :rtype: - ~azure.core.paging.ItemPaged[~azure.mgmt.resource.policy.v2019_01_01.models.PolicyAssignmentListResult] - :raises: ~azure.core.exceptions.HttpResponseError + ~azure.core.paging.ItemPaged[~azure.mgmt.resource.policy.v2019_01_01.models.PolicyAssignment] + :raises ~azure.core.exceptions.HttpResponseError: """ - api_version = kwargs.pop('api_version', "2019-01-01") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2019-01-01")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[_models.PolicyAssignmentListResult] - cls = kwargs.pop('cls', None) # type: ClsType["_models.PolicyAssignmentListResult"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) + def prepare_request(next_link=None): if not next_link: - + request = build_policy_assignments_list_for_resource_request( resource_group_name=resource_group_name, resource_provider_namespace=resource_provider_namespace, @@ -1431,26 +1354,23 @@ def prepare_request(next_link=None): resource_type=resource_type, resource_name=resource_name, subscription_id=self._config.subscription_id, - api_version=api_version, filter=filter, - template_url=self.list_for_resource.metadata['url'], + api_version=api_version, + template_url=self.list_for_resource.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore else: - - request = build_policy_assignments_list_for_resource_request( - resource_group_name=resource_group_name, - resource_provider_namespace=resource_provider_namespace, - parent_resource_path=parent_resource_path, - resource_type=resource_type, - resource_name=resource_name, - subscription_id=self._config.subscription_id, - template_url=next_link, - ) + # make call to next link with the client's api-version + _parsed_next_link = urlparse(next_link) + _next_request_params = case_insensitive_dict(parse_qs(_parsed_next_link.query)) + _next_request_params["api-version"] = self._config.api_version + request = HttpRequest("GET", urljoin(next_link, _parsed_next_link.path), params=_next_request_params) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore request.method = "GET" return request @@ -1464,10 +1384,8 @@ def extract_data(pipeline_response): def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) response = pipeline_response.http_response @@ -1478,18 +1396,12 @@ def get_next(next_link=None): return pipeline_response + return ItemPaged(get_next, extract_data) - return ItemPaged( - get_next, extract_data - ) - list_for_resource.metadata = {'url': "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{parentResourcePath}/{resourceType}/{resourceName}/providers/Microsoft.Authorization/policyAssignments"} # type: ignore + list_for_resource.metadata = {"url": "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{parentResourcePath}/{resourceType}/{resourceName}/providers/Microsoft.Authorization/policyAssignments"} # type: ignore @distributed_trace - def list( - self, - filter: Optional[str] = None, - **kwargs: Any - ) -> Iterable["_models.PolicyAssignmentListResult"]: + def list(self, filter: Optional[str] = None, **kwargs: Any) -> Iterable["_models.PolicyAssignment"]: """Retrieves all policy assignments that apply to a subscription. This operation retrieves the list of all policy assignments associated with the given @@ -1508,39 +1420,47 @@ def list( Default value is None. :type filter: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either PolicyAssignmentListResult or the result of - cls(response) + :return: An iterator like instance of either PolicyAssignment or the result of cls(response) :rtype: - ~azure.core.paging.ItemPaged[~azure.mgmt.resource.policy.v2019_01_01.models.PolicyAssignmentListResult] - :raises: ~azure.core.exceptions.HttpResponseError + ~azure.core.paging.ItemPaged[~azure.mgmt.resource.policy.v2019_01_01.models.PolicyAssignment] + :raises ~azure.core.exceptions.HttpResponseError: """ - api_version = kwargs.pop('api_version', "2019-01-01") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2019-01-01")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[_models.PolicyAssignmentListResult] - cls = kwargs.pop('cls', None) # type: ClsType["_models.PolicyAssignmentListResult"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) + def prepare_request(next_link=None): if not next_link: - + request = build_policy_assignments_list_request( subscription_id=self._config.subscription_id, - api_version=api_version, filter=filter, - template_url=self.list.metadata['url'], + 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.url = self._client.format_url(request.url) # type: ignore else: - - request = build_policy_assignments_list_request( - subscription_id=self._config.subscription_id, - template_url=next_link, - ) + # make call to next link with the client's api-version + _parsed_next_link = urlparse(next_link) + _next_request_params = case_insensitive_dict(parse_qs(_parsed_next_link.query)) + _next_request_params["api-version"] = self._config.api_version + request = HttpRequest("GET", urljoin(next_link, _parsed_next_link.path), params=_next_request_params) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore request.method = "GET" return request @@ -1554,10 +1474,8 @@ def extract_data(pipeline_response): def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) response = pipeline_response.http_response @@ -1568,18 +1486,12 @@ def get_next(next_link=None): return pipeline_response + return ItemPaged(get_next, extract_data) - return ItemPaged( - get_next, extract_data - ) - list.metadata = {'url': "/subscriptions/{subscriptionId}/providers/Microsoft.Authorization/policyAssignments"} # type: ignore + list.metadata = {"url": "/subscriptions/{subscriptionId}/providers/Microsoft.Authorization/policyAssignments"} # type: ignore @distributed_trace - def delete_by_id( - self, - policy_assignment_id: str, - **kwargs: Any - ) -> Optional["_models.PolicyAssignment"]: + def delete_by_id(self, policy_assignment_id: str, **kwargs: Any) -> Optional[_models.PolicyAssignment]: """Deletes a policy assignment. This operation deletes the policy with the given ID. Policy assignment IDs have this format: @@ -1591,35 +1503,41 @@ def delete_by_id( (resource). :param policy_assignment_id: The ID of the policy assignment to delete. Use the format - '{scope}/providers/Microsoft.Authorization/policyAssignments/{policyAssignmentName}'. + '{scope}/providers/Microsoft.Authorization/policyAssignments/{policyAssignmentName}'. Required. :type policy_assignment_id: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: PolicyAssignment, or the result of cls(response) + :return: PolicyAssignment or None or the result of cls(response) :rtype: ~azure.mgmt.resource.policy.v2019_01_01.models.PolicyAssignment or None - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType[Optional["_models.PolicyAssignment"]] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + 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', "2019-01-01") # type: str + api_version = kwargs.pop("api_version", _params.pop("api-version", "2019-01-01")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[Optional[_models.PolicyAssignment]] - request = build_policy_assignments_delete_by_id_request( policy_assignment_id=policy_assignment_id, api_version=api_version, - template_url=self.delete_by_id.metadata['url'], + template_url=self.delete_by_id.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200, 204]: @@ -1629,23 +1547,24 @@ def delete_by_id( deserialized = None if response.status_code == 200: - deserialized = self._deserialize('PolicyAssignment', pipeline_response) + deserialized = self._deserialize("PolicyAssignment", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - delete_by_id.metadata = {'url': "/{policyAssignmentId}"} # type: ignore + delete_by_id.metadata = {"url": "/{policyAssignmentId}"} # type: ignore - - @distributed_trace + @overload def create_by_id( self, policy_assignment_id: str, - parameters: "_models.PolicyAssignment", + parameters: _models.PolicyAssignment, + *, + content_type: str = "application/json", **kwargs: Any - ) -> "_models.PolicyAssignment": + ) -> _models.PolicyAssignment: """Creates or updates a policy assignment. This operation creates or updates the policy assignment with the given ID. Policy assignments @@ -1660,41 +1579,121 @@ def create_by_id( '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{resourceProviderNamespace}/[{parentResourcePath}/]{resourceType}/{resourceName}'. :param policy_assignment_id: The ID of the policy assignment to create. Use the format - '{scope}/providers/Microsoft.Authorization/policyAssignments/{policyAssignmentName}'. + '{scope}/providers/Microsoft.Authorization/policyAssignments/{policyAssignmentName}'. Required. :type policy_assignment_id: str - :param parameters: Parameters for policy assignment. + :param parameters: Parameters for policy assignment. Required. :type parameters: ~azure.mgmt.resource.policy.v2019_01_01.models.PolicyAssignment + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: PolicyAssignment or the result of cls(response) + :rtype: ~azure.mgmt.resource.policy.v2019_01_01.models.PolicyAssignment + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + def create_by_id( + self, policy_assignment_id: str, parameters: IO, *, content_type: str = "application/json", **kwargs: Any + ) -> _models.PolicyAssignment: + """Creates or updates a policy assignment. + + This operation creates or updates the policy assignment with the given ID. Policy assignments + made on a scope apply to all resources contained in that scope. For example, when you assign a + policy to a resource group that policy applies to all resources in the group. Policy assignment + IDs have this format: + '{scope}/providers/Microsoft.Authorization/policyAssignments/{policyAssignmentName}'. Valid + scopes are: management group (format: + '/providers/Microsoft.Management/managementGroups/{managementGroup}'), subscription (format: + '/subscriptions/{subscriptionId}'), resource group (format: + '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}', or resource (format: + '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{resourceProviderNamespace}/[{parentResourcePath}/]{resourceType}/{resourceName}'. + + :param policy_assignment_id: The ID of the policy assignment to create. Use the format + '{scope}/providers/Microsoft.Authorization/policyAssignments/{policyAssignmentName}'. Required. + :type policy_assignment_id: str + :param parameters: Parameters for policy assignment. Required. + :type parameters: IO + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: PolicyAssignment, or the result of cls(response) + :return: PolicyAssignment or the result of cls(response) :rtype: ~azure.mgmt.resource.policy.v2019_01_01.models.PolicyAssignment - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace + def create_by_id( + self, policy_assignment_id: str, parameters: Union[_models.PolicyAssignment, IO], **kwargs: Any + ) -> _models.PolicyAssignment: + """Creates or updates a policy assignment. + + This operation creates or updates the policy assignment with the given ID. Policy assignments + made on a scope apply to all resources contained in that scope. For example, when you assign a + policy to a resource group that policy applies to all resources in the group. Policy assignment + IDs have this format: + '{scope}/providers/Microsoft.Authorization/policyAssignments/{policyAssignmentName}'. Valid + scopes are: management group (format: + '/providers/Microsoft.Management/managementGroups/{managementGroup}'), subscription (format: + '/subscriptions/{subscriptionId}'), resource group (format: + '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}', or resource (format: + '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{resourceProviderNamespace}/[{parentResourcePath}/]{resourceType}/{resourceName}'. + + :param policy_assignment_id: The ID of the policy assignment to create. Use the format + '{scope}/providers/Microsoft.Authorization/policyAssignments/{policyAssignmentName}'. Required. + :type policy_assignment_id: str + :param parameters: Parameters for policy assignment. Is either a model type or a IO type. + Required. + :type parameters: ~azure.mgmt.resource.policy.v2019_01_01.models.PolicyAssignment or IO + :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. + Default value is None. + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: PolicyAssignment or the result of cls(response) + :rtype: ~azure.mgmt.resource.policy.v2019_01_01.models.PolicyAssignment + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.PolicyAssignment"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) - api_version = kwargs.pop('api_version', "2019-01-01") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - _json = self._serialize.body(parameters, 'PolicyAssignment') + api_version = kwargs.pop("api_version", _params.pop("api-version", "2019-01-01")) # type: str + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.PolicyAssignment] + + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(parameters, (IO, bytes)): + _content = parameters + else: + _json = self._serialize.body(parameters, "PolicyAssignment") request = build_policy_assignments_create_by_id_request( policy_assignment_id=policy_assignment_id, api_version=api_version, content_type=content_type, json=_json, - template_url=self.create_by_id.metadata['url'], + content=_content, + template_url=self.create_by_id.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [201]: @@ -1702,22 +1701,17 @@ def create_by_id( error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - deserialized = self._deserialize('PolicyAssignment', pipeline_response) + deserialized = self._deserialize("PolicyAssignment", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - create_by_id.metadata = {'url': "/{policyAssignmentId}"} # type: ignore - + create_by_id.metadata = {"url": "/{policyAssignmentId}"} # type: ignore @distributed_trace - def get_by_id( - self, - policy_assignment_id: str, - **kwargs: Any - ) -> "_models.PolicyAssignment": + def get_by_id(self, policy_assignment_id: str, **kwargs: Any) -> _models.PolicyAssignment: """Retrieves the policy assignment with the given ID. The operation retrieves the policy assignment with the given ID. Policy assignment IDs have @@ -1730,35 +1724,41 @@ def get_by_id( '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{resourceProviderNamespace}/[{parentResourcePath}/]{resourceType}/{resourceName}'. :param policy_assignment_id: The ID of the policy assignment to get. Use the format - '{scope}/providers/Microsoft.Authorization/policyAssignments/{policyAssignmentName}'. + '{scope}/providers/Microsoft.Authorization/policyAssignments/{policyAssignmentName}'. Required. :type policy_assignment_id: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: PolicyAssignment, or the result of cls(response) + :return: PolicyAssignment or the result of cls(response) :rtype: ~azure.mgmt.resource.policy.v2019_01_01.models.PolicyAssignment - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.PolicyAssignment"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) - api_version = kwargs.pop('api_version', "2019-01-01") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2019-01-01")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[_models.PolicyAssignment] - request = build_policy_assignments_get_by_id_request( policy_assignment_id=policy_assignment_id, api_version=api_version, - template_url=self.get_by_id.metadata['url'], + template_url=self.get_by_id.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200]: @@ -1766,68 +1766,128 @@ def get_by_id( error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - deserialized = self._deserialize('PolicyAssignment', pipeline_response) + deserialized = self._deserialize("PolicyAssignment", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - get_by_id.metadata = {'url': "/{policyAssignmentId}"} # type: ignore + get_by_id.metadata = {"url": "/{policyAssignmentId}"} # type: ignore -class PolicyDefinitionsOperations(object): - """PolicyDefinitionsOperations operations. - You should not instantiate this class directly. Instead, you should create a Client instance that - instantiates it for you and attaches it as an attribute. +class PolicyDefinitionsOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. - :ivar models: Alias to model classes used in this operation group. - :type models: ~azure.mgmt.resource.policy.v2019_01_01.models - :param client: Client for service requests. - :param config: Configuration of service client. - :param serializer: An object model serializer. - :param deserializer: An object model deserializer. + Instead, you should access the following operations through + :class:`~azure.mgmt.resource.policy.v2019_01_01.PolicyClient`'s + :attr:`policy_definitions` attribute. """ models = _models - def __init__(self, client, config, serializer, deserializer): - self._client = client - self._serialize = serializer - self._deserialize = deserializer - self._config = config + def __init__(self, *args, **kwargs): + input_args = list(args) + self._client = input_args.pop(0) if input_args else kwargs.pop("client") + self._config = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") - @distributed_trace + @overload def create_or_update( self, policy_definition_name: str, - parameters: "_models.PolicyDefinition", + parameters: _models.PolicyDefinition, + *, + content_type: str = "application/json", **kwargs: Any - ) -> "_models.PolicyDefinition": + ) -> _models.PolicyDefinition: """Creates or updates a policy definition in a subscription. This operation creates or updates a policy definition in the given subscription with the given name. - :param policy_definition_name: The name of the policy definition to create. + :param policy_definition_name: The name of the policy definition to create. Required. :type policy_definition_name: str - :param parameters: The policy definition properties. + :param parameters: The policy definition properties. Required. :type parameters: ~azure.mgmt.resource.policy.v2019_01_01.models.PolicyDefinition + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: PolicyDefinition or the result of cls(response) + :rtype: ~azure.mgmt.resource.policy.v2019_01_01.models.PolicyDefinition + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + def create_or_update( + self, policy_definition_name: str, parameters: IO, *, content_type: str = "application/json", **kwargs: Any + ) -> _models.PolicyDefinition: + """Creates or updates a policy definition in a subscription. + + This operation creates or updates a policy definition in the given subscription with the given + name. + + :param policy_definition_name: The name of the policy definition to create. Required. + :type policy_definition_name: str + :param parameters: The policy definition properties. Required. + :type parameters: IO + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: PolicyDefinition or the result of cls(response) + :rtype: ~azure.mgmt.resource.policy.v2019_01_01.models.PolicyDefinition + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace + def create_or_update( + self, policy_definition_name: str, parameters: Union[_models.PolicyDefinition, IO], **kwargs: Any + ) -> _models.PolicyDefinition: + """Creates or updates a policy definition in a subscription. + + This operation creates or updates a policy definition in the given subscription with the given + name. + + :param policy_definition_name: The name of the policy definition to create. Required. + :type policy_definition_name: str + :param parameters: The policy definition properties. Is either a model type or a IO type. + Required. + :type parameters: ~azure.mgmt.resource.policy.v2019_01_01.models.PolicyDefinition or IO + :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. + Default value is None. + :paramtype content_type: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: PolicyDefinition, or the result of cls(response) + :return: PolicyDefinition or the result of cls(response) :rtype: ~azure.mgmt.resource.policy.v2019_01_01.models.PolicyDefinition - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.PolicyDefinition"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) - api_version = kwargs.pop('api_version', "2019-01-01") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - _json = self._serialize.body(parameters, 'PolicyDefinition') + api_version = kwargs.pop("api_version", _params.pop("api-version", "2019-01-01")) # type: str + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.PolicyDefinition] + + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(parameters, (IO, bytes)): + _content = parameters + else: + _json = self._serialize.body(parameters, "PolicyDefinition") request = build_policy_definitions_create_or_update_request( policy_definition_name=policy_definition_name, @@ -1835,72 +1895,77 @@ def create_or_update( api_version=api_version, content_type=content_type, json=_json, - template_url=self.create_or_update.metadata['url'], + content=_content, + template_url=self.create_or_update.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [201]: map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) - deserialized = self._deserialize('PolicyDefinition', pipeline_response) + deserialized = self._deserialize("PolicyDefinition", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - create_or_update.metadata = {'url': "/subscriptions/{subscriptionId}/providers/Microsoft.Authorization/policyDefinitions/{policyDefinitionName}"} # type: ignore - + create_or_update.metadata = {"url": "/subscriptions/{subscriptionId}/providers/Microsoft.Authorization/policyDefinitions/{policyDefinitionName}"} # type: ignore @distributed_trace def delete( # pylint: disable=inconsistent-return-statements - self, - policy_definition_name: str, - **kwargs: Any + self, policy_definition_name: str, **kwargs: Any ) -> None: """Deletes a policy definition in a subscription. This operation deletes the policy definition in the given subscription with the given name. - :param policy_definition_name: The name of the policy definition to delete. + :param policy_definition_name: The name of the policy definition to delete. Required. :type policy_definition_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: None, or the result of cls(response) + :return: None or the result of cls(response) :rtype: None - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType[None] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) - api_version = kwargs.pop('api_version', "2019-01-01") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2019-01-01")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[None] - request = build_policy_definitions_delete_request( policy_definition_name=policy_definition_name, subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.delete.metadata['url'], + template_url=self.delete.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200, 204]: @@ -1910,154 +1975,231 @@ def delete( # pylint: disable=inconsistent-return-statements if cls: return cls(pipeline_response, None, {}) - delete.metadata = {'url': "/subscriptions/{subscriptionId}/providers/Microsoft.Authorization/policyDefinitions/{policyDefinitionName}"} # type: ignore - + delete.metadata = {"url": "/subscriptions/{subscriptionId}/providers/Microsoft.Authorization/policyDefinitions/{policyDefinitionName}"} # type: ignore @distributed_trace - def get( - self, - policy_definition_name: str, - **kwargs: Any - ) -> "_models.PolicyDefinition": + def get(self, policy_definition_name: str, **kwargs: Any) -> _models.PolicyDefinition: """Retrieves a policy definition in a subscription. This operation retrieves the policy definition in the given subscription with the given name. - :param policy_definition_name: The name of the policy definition to get. + :param policy_definition_name: The name of the policy definition to get. Required. :type policy_definition_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: PolicyDefinition, or the result of cls(response) + :return: PolicyDefinition or the result of cls(response) :rtype: ~azure.mgmt.resource.policy.v2019_01_01.models.PolicyDefinition - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.PolicyDefinition"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) - api_version = kwargs.pop('api_version', "2019-01-01") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2019-01-01")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[_models.PolicyDefinition] - request = build_policy_definitions_get_request( policy_definition_name=policy_definition_name, subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.get.metadata['url'], + template_url=self.get.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) - deserialized = self._deserialize('PolicyDefinition', pipeline_response) + deserialized = self._deserialize("PolicyDefinition", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - get.metadata = {'url': "/subscriptions/{subscriptionId}/providers/Microsoft.Authorization/policyDefinitions/{policyDefinitionName}"} # type: ignore - + get.metadata = {"url": "/subscriptions/{subscriptionId}/providers/Microsoft.Authorization/policyDefinitions/{policyDefinitionName}"} # type: ignore @distributed_trace - def get_built_in( - self, - policy_definition_name: str, - **kwargs: Any - ) -> "_models.PolicyDefinition": + def get_built_in(self, policy_definition_name: str, **kwargs: Any) -> _models.PolicyDefinition: """Retrieves a built-in policy definition. This operation retrieves the built-in policy definition with the given name. - :param policy_definition_name: The name of the built-in policy definition to get. + :param policy_definition_name: The name of the built-in policy definition to get. Required. :type policy_definition_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: PolicyDefinition, or the result of cls(response) + :return: PolicyDefinition or the result of cls(response) :rtype: ~azure.mgmt.resource.policy.v2019_01_01.models.PolicyDefinition - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.PolicyDefinition"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) - api_version = kwargs.pop('api_version', "2019-01-01") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2019-01-01")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[_models.PolicyDefinition] - request = build_policy_definitions_get_built_in_request( policy_definition_name=policy_definition_name, api_version=api_version, - template_url=self.get_built_in.metadata['url'], + template_url=self.get_built_in.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) - deserialized = self._deserialize('PolicyDefinition', pipeline_response) + deserialized = self._deserialize("PolicyDefinition", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - get_built_in.metadata = {'url': "/providers/Microsoft.Authorization/policyDefinitions/{policyDefinitionName}"} # type: ignore + get_built_in.metadata = {"url": "/providers/Microsoft.Authorization/policyDefinitions/{policyDefinitionName}"} # type: ignore + + @overload + def create_or_update_at_management_group( + self, + policy_definition_name: str, + management_group_id: str, + parameters: _models.PolicyDefinition, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.PolicyDefinition: + """Creates or updates a policy definition in a management group. + + This operation creates or updates a policy definition in the given management group with the + given name. + + :param policy_definition_name: The name of the policy definition to create. Required. + :type policy_definition_name: str + :param management_group_id: The ID of the management group. Required. + :type management_group_id: str + :param parameters: The policy definition properties. Required. + :type parameters: ~azure.mgmt.resource.policy.v2019_01_01.models.PolicyDefinition + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: PolicyDefinition or the result of cls(response) + :rtype: ~azure.mgmt.resource.policy.v2019_01_01.models.PolicyDefinition + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + def create_or_update_at_management_group( + self, + policy_definition_name: str, + management_group_id: str, + parameters: IO, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.PolicyDefinition: + """Creates or updates a policy definition in a management group. + + This operation creates or updates a policy definition in the given management group with the + given name. + :param policy_definition_name: The name of the policy definition to create. Required. + :type policy_definition_name: str + :param management_group_id: The ID of the management group. Required. + :type management_group_id: str + :param parameters: The policy definition properties. Required. + :type parameters: IO + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: PolicyDefinition or the result of cls(response) + :rtype: ~azure.mgmt.resource.policy.v2019_01_01.models.PolicyDefinition + :raises ~azure.core.exceptions.HttpResponseError: + """ @distributed_trace def create_or_update_at_management_group( self, policy_definition_name: str, management_group_id: str, - parameters: "_models.PolicyDefinition", + parameters: Union[_models.PolicyDefinition, IO], **kwargs: Any - ) -> "_models.PolicyDefinition": + ) -> _models.PolicyDefinition: """Creates or updates a policy definition in a management group. This operation creates or updates a policy definition in the given management group with the given name. - :param policy_definition_name: The name of the policy definition to create. + :param policy_definition_name: The name of the policy definition to create. Required. :type policy_definition_name: str - :param management_group_id: The ID of the management group. + :param management_group_id: The ID of the management group. Required. :type management_group_id: str - :param parameters: The policy definition properties. - :type parameters: ~azure.mgmt.resource.policy.v2019_01_01.models.PolicyDefinition + :param parameters: The policy definition properties. Is either a model type or a IO type. + Required. + :type parameters: ~azure.mgmt.resource.policy.v2019_01_01.models.PolicyDefinition or IO + :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. + Default value is None. + :paramtype content_type: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: PolicyDefinition, or the result of cls(response) + :return: PolicyDefinition or the result of cls(response) :rtype: ~azure.mgmt.resource.policy.v2019_01_01.models.PolicyDefinition - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.PolicyDefinition"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) - api_version = kwargs.pop('api_version', "2019-01-01") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - _json = self._serialize.body(parameters, 'PolicyDefinition') + api_version = kwargs.pop("api_version", _params.pop("api-version", "2019-01-01")) # type: str + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.PolicyDefinition] + + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(parameters, (IO, bytes)): + _content = parameters + else: + _json = self._serialize.body(parameters, "PolicyDefinition") request = build_policy_definitions_create_or_update_at_management_group_request( policy_definition_name=policy_definition_name, @@ -2065,75 +2207,79 @@ def create_or_update_at_management_group( api_version=api_version, content_type=content_type, json=_json, - template_url=self.create_or_update_at_management_group.metadata['url'], + content=_content, + template_url=self.create_or_update_at_management_group.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [201]: map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) - deserialized = self._deserialize('PolicyDefinition', pipeline_response) + deserialized = self._deserialize("PolicyDefinition", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - create_or_update_at_management_group.metadata = {'url': "/providers/Microsoft.Management/managementgroups/{managementGroupId}/providers/Microsoft.Authorization/policyDefinitions/{policyDefinitionName}"} # type: ignore - + create_or_update_at_management_group.metadata = {"url": "/providers/Microsoft.Management/managementgroups/{managementGroupId}/providers/Microsoft.Authorization/policyDefinitions/{policyDefinitionName}"} # type: ignore @distributed_trace def delete_at_management_group( # pylint: disable=inconsistent-return-statements - self, - policy_definition_name: str, - management_group_id: str, - **kwargs: Any + self, policy_definition_name: str, management_group_id: str, **kwargs: Any ) -> None: """Deletes a policy definition in a management group. This operation deletes the policy definition in the given management group with the given name. - :param policy_definition_name: The name of the policy definition to delete. + :param policy_definition_name: The name of the policy definition to delete. Required. :type policy_definition_name: str - :param management_group_id: The ID of the management group. + :param management_group_id: The ID of the management group. Required. :type management_group_id: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: None, or the result of cls(response) + :return: None or the result of cls(response) :rtype: None - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType[None] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + 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', "2019-01-01") # type: str + api_version = kwargs.pop("api_version", _params.pop("api-version", "2019-01-01")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[None] - request = build_policy_definitions_delete_at_management_group_request( policy_definition_name=policy_definition_name, management_group_id=management_group_id, api_version=api_version, - template_url=self.delete_at_management_group.metadata['url'], + template_url=self.delete_at_management_group.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200, 204]: @@ -2143,111 +2289,117 @@ def delete_at_management_group( # pylint: disable=inconsistent-return-statement if cls: return cls(pipeline_response, None, {}) - delete_at_management_group.metadata = {'url': "/providers/Microsoft.Management/managementgroups/{managementGroupId}/providers/Microsoft.Authorization/policyDefinitions/{policyDefinitionName}"} # type: ignore - + delete_at_management_group.metadata = {"url": "/providers/Microsoft.Management/managementgroups/{managementGroupId}/providers/Microsoft.Authorization/policyDefinitions/{policyDefinitionName}"} # type: ignore @distributed_trace def get_at_management_group( - self, - policy_definition_name: str, - management_group_id: str, - **kwargs: Any - ) -> "_models.PolicyDefinition": + self, policy_definition_name: str, management_group_id: str, **kwargs: Any + ) -> _models.PolicyDefinition: """Retrieve a policy definition in a management group. This operation retrieves the policy definition in the given management group with the given name. - :param policy_definition_name: The name of the policy definition to get. + :param policy_definition_name: The name of the policy definition to get. Required. :type policy_definition_name: str - :param management_group_id: The ID of the management group. + :param management_group_id: The ID of the management group. Required. :type management_group_id: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: PolicyDefinition, or the result of cls(response) + :return: PolicyDefinition or the result of cls(response) :rtype: ~azure.mgmt.resource.policy.v2019_01_01.models.PolicyDefinition - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.PolicyDefinition"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) - api_version = kwargs.pop('api_version', "2019-01-01") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2019-01-01")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[_models.PolicyDefinition] - request = build_policy_definitions_get_at_management_group_request( policy_definition_name=policy_definition_name, management_group_id=management_group_id, api_version=api_version, - template_url=self.get_at_management_group.metadata['url'], + template_url=self.get_at_management_group.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) - deserialized = self._deserialize('PolicyDefinition', pipeline_response) + deserialized = self._deserialize("PolicyDefinition", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - get_at_management_group.metadata = {'url': "/providers/Microsoft.Management/managementgroups/{managementGroupId}/providers/Microsoft.Authorization/policyDefinitions/{policyDefinitionName}"} # type: ignore - + get_at_management_group.metadata = {"url": "/providers/Microsoft.Management/managementgroups/{managementGroupId}/providers/Microsoft.Authorization/policyDefinitions/{policyDefinitionName}"} # type: ignore @distributed_trace - def list( - self, - **kwargs: Any - ) -> Iterable["_models.PolicyDefinitionListResult"]: + def list(self, **kwargs: Any) -> Iterable["_models.PolicyDefinition"]: """Retrieves policy definitions in a subscription. This operation retrieves a list of all the policy definitions in a given subscription. :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either PolicyDefinitionListResult or the result of - cls(response) + :return: An iterator like instance of either PolicyDefinition or the result of cls(response) :rtype: - ~azure.core.paging.ItemPaged[~azure.mgmt.resource.policy.v2019_01_01.models.PolicyDefinitionListResult] - :raises: ~azure.core.exceptions.HttpResponseError + ~azure.core.paging.ItemPaged[~azure.mgmt.resource.policy.v2019_01_01.models.PolicyDefinition] + :raises ~azure.core.exceptions.HttpResponseError: """ - api_version = kwargs.pop('api_version', "2019-01-01") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2019-01-01")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[_models.PolicyDefinitionListResult] - cls = kwargs.pop('cls', None) # type: ClsType["_models.PolicyDefinitionListResult"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) + def prepare_request(next_link=None): if not next_link: - + request = build_policy_definitions_list_request( subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.list.metadata['url'], + template_url=self.list.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore else: - - request = build_policy_definitions_list_request( - subscription_id=self._config.subscription_id, - template_url=next_link, - ) + # make call to next link with the client's api-version + _parsed_next_link = urlparse(next_link) + _next_request_params = case_insensitive_dict(parse_qs(_parsed_next_link.query)) + _next_request_params["api-version"] = self._config.api_version + request = HttpRequest("GET", urljoin(next_link, _parsed_next_link.path), params=_next_request_params) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore request.method = "GET" return request @@ -2261,10 +2413,8 @@ def extract_data(pipeline_response): def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) response = pipeline_response.http_response @@ -2274,52 +2424,56 @@ def get_next(next_link=None): return pipeline_response + return ItemPaged(get_next, extract_data) - return ItemPaged( - get_next, extract_data - ) - list.metadata = {'url': "/subscriptions/{subscriptionId}/providers/Microsoft.Authorization/policyDefinitions"} # type: ignore + list.metadata = {"url": "/subscriptions/{subscriptionId}/providers/Microsoft.Authorization/policyDefinitions"} # type: ignore @distributed_trace - def list_built_in( - self, - **kwargs: Any - ) -> Iterable["_models.PolicyDefinitionListResult"]: + def list_built_in(self, **kwargs: Any) -> Iterable["_models.PolicyDefinition"]: """Retrieve built-in policy definitions. This operation retrieves a list of all the built-in policy definitions. :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either PolicyDefinitionListResult or the result of - cls(response) + :return: An iterator like instance of either PolicyDefinition or the result of cls(response) :rtype: - ~azure.core.paging.ItemPaged[~azure.mgmt.resource.policy.v2019_01_01.models.PolicyDefinitionListResult] - :raises: ~azure.core.exceptions.HttpResponseError + ~azure.core.paging.ItemPaged[~azure.mgmt.resource.policy.v2019_01_01.models.PolicyDefinition] + :raises ~azure.core.exceptions.HttpResponseError: """ - api_version = kwargs.pop('api_version', "2019-01-01") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2019-01-01")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[_models.PolicyDefinitionListResult] - cls = kwargs.pop('cls', None) # type: ClsType["_models.PolicyDefinitionListResult"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) + def prepare_request(next_link=None): if not next_link: - + request = build_policy_definitions_list_built_in_request( api_version=api_version, - template_url=self.list_built_in.metadata['url'], + template_url=self.list_built_in.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore else: - - request = build_policy_definitions_list_built_in_request( - template_url=next_link, - ) + # make call to next link with the client's api-version + _parsed_next_link = urlparse(next_link) + _next_request_params = case_insensitive_dict(parse_qs(_parsed_next_link.query)) + _next_request_params["api-version"] = self._config.api_version + request = HttpRequest("GET", urljoin(next_link, _parsed_next_link.path), params=_next_request_params) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore request.method = "GET" return request @@ -2333,10 +2487,8 @@ def extract_data(pipeline_response): def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) response = pipeline_response.http_response @@ -2346,57 +2498,59 @@ def get_next(next_link=None): return pipeline_response + return ItemPaged(get_next, extract_data) - return ItemPaged( - get_next, extract_data - ) - list_built_in.metadata = {'url': "/providers/Microsoft.Authorization/policyDefinitions"} # type: ignore + list_built_in.metadata = {"url": "/providers/Microsoft.Authorization/policyDefinitions"} # type: ignore @distributed_trace - def list_by_management_group( - self, - management_group_id: str, - **kwargs: Any - ) -> Iterable["_models.PolicyDefinitionListResult"]: + def list_by_management_group(self, management_group_id: str, **kwargs: Any) -> Iterable["_models.PolicyDefinition"]: """Retrieve policy definitions in a management group. This operation retrieves a list of all the policy definitions in a given management group. - :param management_group_id: The ID of the management group. + :param management_group_id: The ID of the management group. Required. :type management_group_id: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either PolicyDefinitionListResult or the result of - cls(response) + :return: An iterator like instance of either PolicyDefinition or the result of cls(response) :rtype: - ~azure.core.paging.ItemPaged[~azure.mgmt.resource.policy.v2019_01_01.models.PolicyDefinitionListResult] - :raises: ~azure.core.exceptions.HttpResponseError + ~azure.core.paging.ItemPaged[~azure.mgmt.resource.policy.v2019_01_01.models.PolicyDefinition] + :raises ~azure.core.exceptions.HttpResponseError: """ - api_version = kwargs.pop('api_version', "2019-01-01") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2019-01-01")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[_models.PolicyDefinitionListResult] - cls = kwargs.pop('cls', None) # type: ClsType["_models.PolicyDefinitionListResult"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) + def prepare_request(next_link=None): if not next_link: - + request = build_policy_definitions_list_by_management_group_request( management_group_id=management_group_id, api_version=api_version, - template_url=self.list_by_management_group.metadata['url'], + template_url=self.list_by_management_group.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore else: - - request = build_policy_definitions_list_by_management_group_request( - management_group_id=management_group_id, - template_url=next_link, - ) + # make call to next link with the client's api-version + _parsed_next_link = urlparse(next_link) + _next_request_params = case_insensitive_dict(parse_qs(_parsed_next_link.query)) + _next_request_params["api-version"] = self._config.api_version + request = HttpRequest("GET", urljoin(next_link, _parsed_next_link.path), params=_next_request_params) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore request.method = "GET" return request @@ -2410,10 +2564,8 @@ def extract_data(pipeline_response): def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) response = pipeline_response.http_response @@ -2423,64 +2575,123 @@ def get_next(next_link=None): return pipeline_response + return ItemPaged(get_next, extract_data) - return ItemPaged( - get_next, extract_data - ) - list_by_management_group.metadata = {'url': "/providers/Microsoft.Management/managementgroups/{managementGroupId}/providers/Microsoft.Authorization/policyDefinitions"} # type: ignore -class PolicySetDefinitionsOperations(object): - """PolicySetDefinitionsOperations operations. - - You should not instantiate this class directly. Instead, you should create a Client instance that - instantiates it for you and attaches it as an attribute. - - :ivar models: Alias to model classes used in this operation group. - :type models: ~azure.mgmt.resource.policy.v2019_01_01.models - :param client: Client for service requests. - :param config: Configuration of service client. - :param serializer: An object model serializer. - :param deserializer: An object model deserializer. + list_by_management_group.metadata = {"url": "/providers/Microsoft.Management/managementgroups/{managementGroupId}/providers/Microsoft.Authorization/policyDefinitions"} # type: ignore + + +class PolicySetDefinitionsOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. + + Instead, you should access the following operations through + :class:`~azure.mgmt.resource.policy.v2019_01_01.PolicyClient`'s + :attr:`policy_set_definitions` attribute. """ models = _models - def __init__(self, client, config, serializer, deserializer): - self._client = client - self._serialize = serializer - self._deserialize = deserializer - self._config = config + def __init__(self, *args, **kwargs): + input_args = list(args) + self._client = input_args.pop(0) if input_args else kwargs.pop("client") + self._config = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") - @distributed_trace + @overload def create_or_update( self, policy_set_definition_name: str, - parameters: "_models.PolicySetDefinition", + parameters: _models.PolicySetDefinition, + *, + content_type: str = "application/json", **kwargs: Any - ) -> "_models.PolicySetDefinition": + ) -> _models.PolicySetDefinition: """Creates or updates a policy set definition. This operation creates or updates a policy set definition in the given subscription with the given name. - :param policy_set_definition_name: The name of the policy set definition to create. + :param policy_set_definition_name: The name of the policy set definition to create. Required. :type policy_set_definition_name: str - :param parameters: The policy set definition properties. + :param parameters: The policy set definition properties. Required. :type parameters: ~azure.mgmt.resource.policy.v2019_01_01.models.PolicySetDefinition + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: PolicySetDefinition or the result of cls(response) + :rtype: ~azure.mgmt.resource.policy.v2019_01_01.models.PolicySetDefinition + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + def create_or_update( + self, policy_set_definition_name: str, parameters: IO, *, content_type: str = "application/json", **kwargs: Any + ) -> _models.PolicySetDefinition: + """Creates or updates a policy set definition. + + This operation creates or updates a policy set definition in the given subscription with the + given name. + + :param policy_set_definition_name: The name of the policy set definition to create. Required. + :type policy_set_definition_name: str + :param parameters: The policy set definition properties. Required. + :type parameters: IO + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: PolicySetDefinition or the result of cls(response) + :rtype: ~azure.mgmt.resource.policy.v2019_01_01.models.PolicySetDefinition + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace + def create_or_update( + self, policy_set_definition_name: str, parameters: Union[_models.PolicySetDefinition, IO], **kwargs: Any + ) -> _models.PolicySetDefinition: + """Creates or updates a policy set definition. + + This operation creates or updates a policy set definition in the given subscription with the + given name. + + :param policy_set_definition_name: The name of the policy set definition to create. Required. + :type policy_set_definition_name: str + :param parameters: The policy set definition properties. Is either a model type or a IO type. + Required. + :type parameters: ~azure.mgmt.resource.policy.v2019_01_01.models.PolicySetDefinition or IO + :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. + Default value is None. + :paramtype content_type: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: PolicySetDefinition, or the result of cls(response) + :return: PolicySetDefinition or the result of cls(response) :rtype: ~azure.mgmt.resource.policy.v2019_01_01.models.PolicySetDefinition - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.PolicySetDefinition"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) - api_version = kwargs.pop('api_version', "2019-01-01") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - _json = self._serialize.body(parameters, 'PolicySetDefinition') + api_version = kwargs.pop("api_version", _params.pop("api-version", "2019-01-01")) # type: str + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.PolicySetDefinition] + + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(parameters, (IO, bytes)): + _content = parameters + else: + _json = self._serialize.body(parameters, "PolicySetDefinition") request = build_policy_set_definitions_create_or_update_request( policy_set_definition_name=policy_set_definition_name, @@ -2488,16 +2699,18 @@ def create_or_update( api_version=api_version, content_type=content_type, json=_json, - template_url=self.create_or_update.metadata['url'], + content=_content, + template_url=self.create_or_update.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200, 201]: @@ -2506,59 +2719,62 @@ def create_or_update( raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) if response.status_code == 200: - deserialized = self._deserialize('PolicySetDefinition', pipeline_response) + deserialized = self._deserialize("PolicySetDefinition", pipeline_response) if response.status_code == 201: - deserialized = self._deserialize('PolicySetDefinition', pipeline_response) + deserialized = self._deserialize("PolicySetDefinition", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - create_or_update.metadata = {'url': "/subscriptions/{subscriptionId}/providers/Microsoft.Authorization/policySetDefinitions/{policySetDefinitionName}"} # type: ignore - + create_or_update.metadata = {"url": "/subscriptions/{subscriptionId}/providers/Microsoft.Authorization/policySetDefinitions/{policySetDefinitionName}"} # type: ignore @distributed_trace def delete( # pylint: disable=inconsistent-return-statements - self, - policy_set_definition_name: str, - **kwargs: Any + self, policy_set_definition_name: str, **kwargs: Any ) -> None: """Deletes a policy set definition. This operation deletes the policy set definition in the given subscription with the given name. - :param policy_set_definition_name: The name of the policy set definition to delete. + :param policy_set_definition_name: The name of the policy set definition to delete. Required. :type policy_set_definition_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: None, or the result of cls(response) + :return: None or the result of cls(response) :rtype: None - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType[None] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) - api_version = kwargs.pop('api_version', "2019-01-01") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2019-01-01")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[None] - request = build_policy_set_definitions_delete_request( policy_set_definition_name=policy_set_definition_name, subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.delete.metadata['url'], + template_url=self.delete.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200, 204]: @@ -2569,50 +2785,51 @@ def delete( # pylint: disable=inconsistent-return-statements if cls: return cls(pipeline_response, None, {}) - delete.metadata = {'url': "/subscriptions/{subscriptionId}/providers/Microsoft.Authorization/policySetDefinitions/{policySetDefinitionName}"} # type: ignore - + delete.metadata = {"url": "/subscriptions/{subscriptionId}/providers/Microsoft.Authorization/policySetDefinitions/{policySetDefinitionName}"} # type: ignore @distributed_trace - def get( - self, - policy_set_definition_name: str, - **kwargs: Any - ) -> "_models.PolicySetDefinition": + def get(self, policy_set_definition_name: str, **kwargs: Any) -> _models.PolicySetDefinition: """Retrieves a policy set definition. This operation retrieves the policy set definition in the given subscription with the given name. - :param policy_set_definition_name: The name of the policy set definition to get. + :param policy_set_definition_name: The name of the policy set definition to get. Required. :type policy_set_definition_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: PolicySetDefinition, or the result of cls(response) + :return: PolicySetDefinition or the result of cls(response) :rtype: ~azure.mgmt.resource.policy.v2019_01_01.models.PolicySetDefinition - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.PolicySetDefinition"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) - api_version = kwargs.pop('api_version', "2019-01-01") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2019-01-01")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[_models.PolicySetDefinition] - request = build_policy_set_definitions_get_request( policy_set_definition_name=policy_set_definition_name, subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.get.metadata['url'], + template_url=self.get.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200]: @@ -2620,55 +2837,56 @@ def get( error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - deserialized = self._deserialize('PolicySetDefinition', pipeline_response) + deserialized = self._deserialize("PolicySetDefinition", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - get.metadata = {'url': "/subscriptions/{subscriptionId}/providers/Microsoft.Authorization/policySetDefinitions/{policySetDefinitionName}"} # type: ignore - + get.metadata = {"url": "/subscriptions/{subscriptionId}/providers/Microsoft.Authorization/policySetDefinitions/{policySetDefinitionName}"} # type: ignore @distributed_trace - def get_built_in( - self, - policy_set_definition_name: str, - **kwargs: Any - ) -> "_models.PolicySetDefinition": + def get_built_in(self, policy_set_definition_name: str, **kwargs: Any) -> _models.PolicySetDefinition: """Retrieves a built in policy set definition. This operation retrieves the built-in policy set definition with the given name. - :param policy_set_definition_name: The name of the policy set definition to get. + :param policy_set_definition_name: The name of the policy set definition to get. Required. :type policy_set_definition_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: PolicySetDefinition, or the result of cls(response) + :return: PolicySetDefinition or the result of cls(response) :rtype: ~azure.mgmt.resource.policy.v2019_01_01.models.PolicySetDefinition - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.PolicySetDefinition"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) - api_version = kwargs.pop('api_version', "2019-01-01") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2019-01-01")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[_models.PolicySetDefinition] - request = build_policy_set_definitions_get_built_in_request( policy_set_definition_name=policy_set_definition_name, api_version=api_version, - template_url=self.get_built_in.metadata['url'], + template_url=self.get_built_in.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200]: @@ -2676,58 +2894,62 @@ def get_built_in( error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - deserialized = self._deserialize('PolicySetDefinition', pipeline_response) + deserialized = self._deserialize("PolicySetDefinition", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - get_built_in.metadata = {'url': "/providers/Microsoft.Authorization/policySetDefinitions/{policySetDefinitionName}"} # type: ignore - + get_built_in.metadata = {"url": "/providers/Microsoft.Authorization/policySetDefinitions/{policySetDefinitionName}"} # type: ignore @distributed_trace - def list( - self, - **kwargs: Any - ) -> Iterable["_models.PolicySetDefinitionListResult"]: + def list(self, **kwargs: Any) -> Iterable["_models.PolicySetDefinition"]: """Retrieves the policy set definitions for a subscription. This operation retrieves a list of all the policy set definitions in the given subscription. :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either PolicySetDefinitionListResult or the result of - cls(response) + :return: An iterator like instance of either PolicySetDefinition or the result of cls(response) :rtype: - ~azure.core.paging.ItemPaged[~azure.mgmt.resource.policy.v2019_01_01.models.PolicySetDefinitionListResult] - :raises: ~azure.core.exceptions.HttpResponseError + ~azure.core.paging.ItemPaged[~azure.mgmt.resource.policy.v2019_01_01.models.PolicySetDefinition] + :raises ~azure.core.exceptions.HttpResponseError: """ - api_version = kwargs.pop('api_version', "2019-01-01") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2019-01-01")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[_models.PolicySetDefinitionListResult] - cls = kwargs.pop('cls', None) # type: ClsType["_models.PolicySetDefinitionListResult"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) + def prepare_request(next_link=None): if not next_link: - + request = build_policy_set_definitions_list_request( subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.list.metadata['url'], + template_url=self.list.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore else: - - request = build_policy_set_definitions_list_request( - subscription_id=self._config.subscription_id, - template_url=next_link, - ) + # make call to next link with the client's api-version + _parsed_next_link = urlparse(next_link) + _next_request_params = case_insensitive_dict(parse_qs(_parsed_next_link.query)) + _next_request_params["api-version"] = self._config.api_version + request = HttpRequest("GET", urljoin(next_link, _parsed_next_link.path), params=_next_request_params) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore request.method = "GET" return request @@ -2741,10 +2963,8 @@ def extract_data(pipeline_response): def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) response = pipeline_response.http_response @@ -2755,52 +2975,56 @@ def get_next(next_link=None): return pipeline_response + return ItemPaged(get_next, extract_data) - return ItemPaged( - get_next, extract_data - ) - list.metadata = {'url': "/subscriptions/{subscriptionId}/providers/Microsoft.Authorization/policySetDefinitions"} # type: ignore + list.metadata = {"url": "/subscriptions/{subscriptionId}/providers/Microsoft.Authorization/policySetDefinitions"} # type: ignore @distributed_trace - def list_built_in( - self, - **kwargs: Any - ) -> Iterable["_models.PolicySetDefinitionListResult"]: + def list_built_in(self, **kwargs: Any) -> Iterable["_models.PolicySetDefinition"]: """Retrieves built-in policy set definitions. This operation retrieves a list of all the built-in policy set definitions. :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either PolicySetDefinitionListResult or the result of - cls(response) + :return: An iterator like instance of either PolicySetDefinition or the result of cls(response) :rtype: - ~azure.core.paging.ItemPaged[~azure.mgmt.resource.policy.v2019_01_01.models.PolicySetDefinitionListResult] - :raises: ~azure.core.exceptions.HttpResponseError + ~azure.core.paging.ItemPaged[~azure.mgmt.resource.policy.v2019_01_01.models.PolicySetDefinition] + :raises ~azure.core.exceptions.HttpResponseError: """ - api_version = kwargs.pop('api_version', "2019-01-01") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2019-01-01")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[_models.PolicySetDefinitionListResult] - cls = kwargs.pop('cls', None) # type: ClsType["_models.PolicySetDefinitionListResult"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) + def prepare_request(next_link=None): if not next_link: - + request = build_policy_set_definitions_list_built_in_request( api_version=api_version, - template_url=self.list_built_in.metadata['url'], + template_url=self.list_built_in.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore else: - - request = build_policy_set_definitions_list_built_in_request( - template_url=next_link, - ) + # make call to next link with the client's api-version + _parsed_next_link = urlparse(next_link) + _next_request_params = case_insensitive_dict(parse_qs(_parsed_next_link.query)) + _next_request_params["api-version"] = self._config.api_version + request = HttpRequest("GET", urljoin(next_link, _parsed_next_link.path), params=_next_request_params) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore request.method = "GET" return request @@ -2814,10 +3038,8 @@ def extract_data(pipeline_response): def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) response = pipeline_response.http_response @@ -2828,46 +3050,120 @@ def get_next(next_link=None): return pipeline_response + return ItemPaged(get_next, extract_data) - return ItemPaged( - get_next, extract_data - ) - list_built_in.metadata = {'url': "/providers/Microsoft.Authorization/policySetDefinitions"} # type: ignore + list_built_in.metadata = {"url": "/providers/Microsoft.Authorization/policySetDefinitions"} # type: ignore - @distributed_trace + @overload def create_or_update_at_management_group( self, policy_set_definition_name: str, management_group_id: str, - parameters: "_models.PolicySetDefinition", + parameters: _models.PolicySetDefinition, + *, + content_type: str = "application/json", **kwargs: Any - ) -> "_models.PolicySetDefinition": + ) -> _models.PolicySetDefinition: """Creates or updates a policy set definition. This operation creates or updates a policy set definition in the given management group with the given name. - :param policy_set_definition_name: The name of the policy set definition to create. + :param policy_set_definition_name: The name of the policy set definition to create. Required. :type policy_set_definition_name: str - :param management_group_id: The ID of the management group. + :param management_group_id: The ID of the management group. Required. :type management_group_id: str - :param parameters: The policy set definition properties. + :param parameters: The policy set definition properties. Required. :type parameters: ~azure.mgmt.resource.policy.v2019_01_01.models.PolicySetDefinition + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: PolicySetDefinition or the result of cls(response) + :rtype: ~azure.mgmt.resource.policy.v2019_01_01.models.PolicySetDefinition + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + def create_or_update_at_management_group( + self, + policy_set_definition_name: str, + management_group_id: str, + parameters: IO, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.PolicySetDefinition: + """Creates or updates a policy set definition. + + This operation creates or updates a policy set definition in the given management group with + the given name. + + :param policy_set_definition_name: The name of the policy set definition to create. Required. + :type policy_set_definition_name: str + :param management_group_id: The ID of the management group. Required. + :type management_group_id: str + :param parameters: The policy set definition properties. Required. + :type parameters: IO + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: PolicySetDefinition or the result of cls(response) + :rtype: ~azure.mgmt.resource.policy.v2019_01_01.models.PolicySetDefinition + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace + def create_or_update_at_management_group( + self, + policy_set_definition_name: str, + management_group_id: str, + parameters: Union[_models.PolicySetDefinition, IO], + **kwargs: Any + ) -> _models.PolicySetDefinition: + """Creates or updates a policy set definition. + + This operation creates or updates a policy set definition in the given management group with + the given name. + + :param policy_set_definition_name: The name of the policy set definition to create. Required. + :type policy_set_definition_name: str + :param management_group_id: The ID of the management group. Required. + :type management_group_id: str + :param parameters: The policy set definition properties. Is either a model type or a IO type. + Required. + :type parameters: ~azure.mgmt.resource.policy.v2019_01_01.models.PolicySetDefinition or IO + :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. + Default value is None. + :paramtype content_type: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: PolicySetDefinition, or the result of cls(response) + :return: PolicySetDefinition or the result of cls(response) :rtype: ~azure.mgmt.resource.policy.v2019_01_01.models.PolicySetDefinition - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.PolicySetDefinition"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', "2019-01-01") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + api_version = kwargs.pop("api_version", _params.pop("api-version", "2019-01-01")) # type: str + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.PolicySetDefinition] - _json = self._serialize.body(parameters, 'PolicySetDefinition') + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(parameters, (IO, bytes)): + _content = parameters + else: + _json = self._serialize.body(parameters, "PolicySetDefinition") request = build_policy_set_definitions_create_or_update_at_management_group_request( policy_set_definition_name=policy_set_definition_name, @@ -2875,16 +3171,18 @@ def create_or_update_at_management_group( api_version=api_version, content_type=content_type, json=_json, - template_url=self.create_or_update_at_management_group.metadata['url'], + content=_content, + template_url=self.create_or_update_at_management_group.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200, 201]: @@ -2893,63 +3191,65 @@ def create_or_update_at_management_group( raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) if response.status_code == 200: - deserialized = self._deserialize('PolicySetDefinition', pipeline_response) + deserialized = self._deserialize("PolicySetDefinition", pipeline_response) if response.status_code == 201: - deserialized = self._deserialize('PolicySetDefinition', pipeline_response) + deserialized = self._deserialize("PolicySetDefinition", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - create_or_update_at_management_group.metadata = {'url': "/providers/Microsoft.Management/managementgroups/{managementGroupId}/providers/Microsoft.Authorization/policySetDefinitions/{policySetDefinitionName}"} # type: ignore - + create_or_update_at_management_group.metadata = {"url": "/providers/Microsoft.Management/managementgroups/{managementGroupId}/providers/Microsoft.Authorization/policySetDefinitions/{policySetDefinitionName}"} # type: ignore @distributed_trace def delete_at_management_group( # pylint: disable=inconsistent-return-statements - self, - policy_set_definition_name: str, - management_group_id: str, - **kwargs: Any + self, policy_set_definition_name: str, management_group_id: str, **kwargs: Any ) -> None: """Deletes a policy set definition. This operation deletes the policy set definition in the given management group with the given name. - :param policy_set_definition_name: The name of the policy set definition to delete. + :param policy_set_definition_name: The name of the policy set definition to delete. Required. :type policy_set_definition_name: str - :param management_group_id: The ID of the management group. + :param management_group_id: The ID of the management group. Required. :type management_group_id: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: None, or the result of cls(response) + :return: None or the result of cls(response) :rtype: None - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType[None] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) - api_version = kwargs.pop('api_version', "2019-01-01") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2019-01-01")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[None] - request = build_policy_set_definitions_delete_at_management_group_request( policy_set_definition_name=policy_set_definition_name, management_group_id=management_group_id, api_version=api_version, - template_url=self.delete_at_management_group.metadata['url'], + template_url=self.delete_at_management_group.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200, 204]: @@ -2960,53 +3260,55 @@ def delete_at_management_group( # pylint: disable=inconsistent-return-statement if cls: return cls(pipeline_response, None, {}) - delete_at_management_group.metadata = {'url': "/providers/Microsoft.Management/managementgroups/{managementGroupId}/providers/Microsoft.Authorization/policySetDefinitions/{policySetDefinitionName}"} # type: ignore - + delete_at_management_group.metadata = {"url": "/providers/Microsoft.Management/managementgroups/{managementGroupId}/providers/Microsoft.Authorization/policySetDefinitions/{policySetDefinitionName}"} # type: ignore @distributed_trace def get_at_management_group( - self, - policy_set_definition_name: str, - management_group_id: str, - **kwargs: Any - ) -> "_models.PolicySetDefinition": + self, policy_set_definition_name: str, management_group_id: str, **kwargs: Any + ) -> _models.PolicySetDefinition: """Retrieves a policy set definition. This operation retrieves the policy set definition in the given management group with the given name. - :param policy_set_definition_name: The name of the policy set definition to get. + :param policy_set_definition_name: The name of the policy set definition to get. Required. :type policy_set_definition_name: str - :param management_group_id: The ID of the management group. + :param management_group_id: The ID of the management group. Required. :type management_group_id: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: PolicySetDefinition, or the result of cls(response) + :return: PolicySetDefinition or the result of cls(response) :rtype: ~azure.mgmt.resource.policy.v2019_01_01.models.PolicySetDefinition - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.PolicySetDefinition"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + 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', "2019-01-01") # type: str + api_version = kwargs.pop("api_version", _params.pop("api-version", "2019-01-01")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[_models.PolicySetDefinition] - request = build_policy_set_definitions_get_at_management_group_request( policy_set_definition_name=policy_set_definition_name, management_group_id=management_group_id, api_version=api_version, - template_url=self.get_at_management_group.metadata['url'], + template_url=self.get_at_management_group.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200]: @@ -3014,62 +3316,67 @@ def get_at_management_group( error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - deserialized = self._deserialize('PolicySetDefinition', pipeline_response) + deserialized = self._deserialize("PolicySetDefinition", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - get_at_management_group.metadata = {'url': "/providers/Microsoft.Management/managementgroups/{managementGroupId}/providers/Microsoft.Authorization/policySetDefinitions/{policySetDefinitionName}"} # type: ignore - + get_at_management_group.metadata = {"url": "/providers/Microsoft.Management/managementgroups/{managementGroupId}/providers/Microsoft.Authorization/policySetDefinitions/{policySetDefinitionName}"} # type: ignore @distributed_trace def list_by_management_group( - self, - management_group_id: str, - **kwargs: Any - ) -> Iterable["_models.PolicySetDefinitionListResult"]: + self, management_group_id: str, **kwargs: Any + ) -> Iterable["_models.PolicySetDefinition"]: """Retrieves all policy set definitions in management group. This operation retrieves a list of all the a policy set definition in the given management group. - :param management_group_id: The ID of the management group. + :param management_group_id: The ID of the management group. Required. :type management_group_id: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either PolicySetDefinitionListResult or the result of - cls(response) + :return: An iterator like instance of either PolicySetDefinition or the result of cls(response) :rtype: - ~azure.core.paging.ItemPaged[~azure.mgmt.resource.policy.v2019_01_01.models.PolicySetDefinitionListResult] - :raises: ~azure.core.exceptions.HttpResponseError + ~azure.core.paging.ItemPaged[~azure.mgmt.resource.policy.v2019_01_01.models.PolicySetDefinition] + :raises ~azure.core.exceptions.HttpResponseError: """ - api_version = kwargs.pop('api_version', "2019-01-01") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2019-01-01")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[_models.PolicySetDefinitionListResult] - cls = kwargs.pop('cls', None) # type: ClsType["_models.PolicySetDefinitionListResult"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) + def prepare_request(next_link=None): if not next_link: - + request = build_policy_set_definitions_list_by_management_group_request( management_group_id=management_group_id, api_version=api_version, - template_url=self.list_by_management_group.metadata['url'], + template_url=self.list_by_management_group.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore else: - - request = build_policy_set_definitions_list_by_management_group_request( - management_group_id=management_group_id, - template_url=next_link, - ) + # make call to next link with the client's api-version + _parsed_next_link = urlparse(next_link) + _next_request_params = case_insensitive_dict(parse_qs(_parsed_next_link.query)) + _next_request_params["api-version"] = self._config.api_version + request = HttpRequest("GET", urljoin(next_link, _parsed_next_link.path), params=_next_request_params) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore request.method = "GET" return request @@ -3083,10 +3390,8 @@ def extract_data(pipeline_response): def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) response = pipeline_response.http_response @@ -3097,8 +3402,6 @@ def get_next(next_link=None): return pipeline_response + return ItemPaged(get_next, extract_data) - return ItemPaged( - get_next, extract_data - ) - list_by_management_group.metadata = {'url': "/providers/Microsoft.Management/managementgroups/{managementGroupId}/providers/Microsoft.Authorization/policySetDefinitions"} # type: ignore + list_by_management_group.metadata = {"url": "/providers/Microsoft.Management/managementgroups/{managementGroupId}/providers/Microsoft.Authorization/policySetDefinitions"} # type: ignore diff --git a/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/policy/v2019_01_01/operations/_patch.py b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/policy/v2019_01_01/operations/_patch.py new file mode 100644 index 0000000000000..f7dd32510333d --- /dev/null +++ b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/policy/v2019_01_01/operations/_patch.py @@ -0,0 +1,20 @@ +# ------------------------------------ +# Copyright (c) Microsoft Corporation. +# Licensed under the MIT License. +# ------------------------------------ +"""Customize generated code here. + +Follow our quickstart for examples: https://aka.ms/azsdk/python/dpcodegen/python/customize +""" +from typing import List + +__all__: List[str] = [] # Add all objects you want publicly available to users at this package level + + +def patch_sdk(): + """Do not remove from this file. + + `patch_sdk` is a last resort escape hatch that allows you to do customizations + you can't accomplish using the techniques described in + https://aka.ms/azsdk/python/dpcodegen/python/customize + """ diff --git a/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/policy/v2019_06_01/__init__.py b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/policy/v2019_06_01/__init__.py index 89180ab440872..bb1ffe59afae7 100644 --- a/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/policy/v2019_06_01/__init__.py +++ b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/policy/v2019_06_01/__init__.py @@ -10,9 +10,15 @@ from ._version import VERSION __version__ = VERSION -__all__ = ['PolicyClient'] -# `._patch.py` is used for handwritten extensions to the generated code -# Example: https://github.com/Azure/azure-sdk-for-python/blob/main/doc/dev/customize_code/how-to-patch-sdk-code.md -from ._patch import patch_sdk -patch_sdk() +try: + from ._patch import __all__ as _patch_all + from ._patch import * # type: ignore # pylint: disable=unused-wildcard-import +except ImportError: + _patch_all = [] +from ._patch import patch_sdk as _patch_sdk + +__all__ = ["PolicyClient"] +__all__.extend([p for p in _patch_all if p not in __all__]) + +_patch_sdk() diff --git a/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/policy/v2019_06_01/_configuration.py b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/policy/v2019_06_01/_configuration.py index 8a75054f73c8c..d19957f7dc849 100644 --- a/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/policy/v2019_06_01/_configuration.py +++ b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/policy/v2019_06_01/_configuration.py @@ -25,23 +25,18 @@ class PolicyClientConfiguration(Configuration): # pylint: disable=too-many-inst Note that all parameters used to create this instance are saved as instance attributes. - :param credential: Credential needed for the client to connect to Azure. + :param credential: Credential needed for the client to connect to Azure. Required. :type credential: ~azure.core.credentials.TokenCredential - :param subscription_id: The ID of the target subscription. + :param subscription_id: The ID of the target subscription. Required. :type subscription_id: str :keyword api_version: Api Version. Default value is "2019-06-01". Note that overriding this default value may result in unsupported behavior. :paramtype api_version: str """ - def __init__( - self, - credential: "TokenCredential", - subscription_id: str, - **kwargs: Any - ) -> None: + def __init__(self, credential: "TokenCredential", subscription_id: str, **kwargs: Any) -> None: super(PolicyClientConfiguration, self).__init__(**kwargs) - api_version = kwargs.pop('api_version', "2019-06-01") # type: str + api_version = kwargs.pop("api_version", "2019-06-01") # type: str if credential is None: raise ValueError("Parameter 'credential' must not be None.") @@ -51,23 +46,24 @@ def __init__( self.credential = credential self.subscription_id = subscription_id self.api_version = api_version - self.credential_scopes = kwargs.pop('credential_scopes', ['https://management.azure.com/.default']) - kwargs.setdefault('sdk_moniker', 'mgmt-resource/{}'.format(VERSION)) + self.credential_scopes = kwargs.pop("credential_scopes", ["https://management.azure.com/.default"]) + kwargs.setdefault("sdk_moniker", "mgmt-resource/{}".format(VERSION)) self._configure(**kwargs) def _configure( - self, - **kwargs # type: Any + self, **kwargs # type: Any ): # type: (...) -> 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) - self.logging_policy = kwargs.get('logging_policy') or policies.NetworkTraceLoggingPolicy(**kwargs) - self.http_logging_policy = kwargs.get('http_logging_policy') or ARMHttpLoggingPolicy(**kwargs) - self.retry_policy = kwargs.get('retry_policy') or policies.RetryPolicy(**kwargs) - self.custom_hook_policy = kwargs.get('custom_hook_policy') or policies.CustomHookPolicy(**kwargs) - self.redirect_policy = kwargs.get('redirect_policy') or policies.RedirectPolicy(**kwargs) - self.authentication_policy = kwargs.get('authentication_policy') + 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) + self.logging_policy = kwargs.get("logging_policy") or policies.NetworkTraceLoggingPolicy(**kwargs) + self.http_logging_policy = kwargs.get("http_logging_policy") or ARMHttpLoggingPolicy(**kwargs) + self.retry_policy = kwargs.get("retry_policy") or policies.RetryPolicy(**kwargs) + self.custom_hook_policy = kwargs.get("custom_hook_policy") or policies.CustomHookPolicy(**kwargs) + self.redirect_policy = kwargs.get("redirect_policy") or policies.RedirectPolicy(**kwargs) + self.authentication_policy = kwargs.get("authentication_policy") if self.credential and not self.authentication_policy: - self.authentication_policy = ARMChallengeAuthenticationPolicy(self.credential, *self.credential_scopes, **kwargs) + self.authentication_policy = ARMChallengeAuthenticationPolicy( + self.credential, *self.credential_scopes, **kwargs + ) diff --git a/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/policy/v2019_06_01/_metadata.json b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/policy/v2019_06_01/_metadata.json index 0b1a04839328a..0efada0bd31a4 100644 --- a/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/policy/v2019_06_01/_metadata.json +++ b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/policy/v2019_06_01/_metadata.json @@ -10,20 +10,20 @@ "azure_arm": true, "has_lro_operations": false, "client_side_validation": false, - "sync_imports": "{\"typing\": {\"azurecore\": {\"azure.core.credentials\": [\"TokenCredential\"]}}, \"regular\": {\"azurecore\": {\"azure.profiles\": [\"KnownProfiles\", \"ProfileDefinition\"], \"azure.profiles.multiapiclient\": [\"MultiApiClientMixin\"], \"azure.mgmt.core\": [\"ARMPipelineClient\"]}, \"local\": {\"._configuration\": [\"PolicyClientConfiguration\"]}, \"thirdparty\": {\"msrest\": [\"Deserializer\", \"Serializer\"]}}, \"conditional\": {\"stdlib\": {\"typing\": [\"Any\", \"Optional\"]}}}", - "async_imports": "{\"typing\": {\"azurecore\": {\"azure.core.credentials_async\": [\"AsyncTokenCredential\"], \"azure.core.credentials\": [\"TokenCredential\"]}}, \"regular\": {\"azurecore\": {\"azure.profiles\": [\"KnownProfiles\", \"ProfileDefinition\"], \"azure.profiles.multiapiclient\": [\"MultiApiClientMixin\"], \"azure.mgmt.core\": [\"AsyncARMPipelineClient\"]}, \"local\": {\"._configuration\": [\"PolicyClientConfiguration\"]}, \"thirdparty\": {\"msrest\": [\"Deserializer\", \"Serializer\"]}}, \"conditional\": {\"stdlib\": {\"typing\": [\"Any\", \"Optional\"]}}}" + "sync_imports": "{\"conditional\": {\"stdlib\": {\"typing\": [\"Any\", \"Optional\"]}}, \"regular\": {\"azurecore\": {\"azure.mgmt.core\": [\"ARMPipelineClient\"], \"azure.profiles\": [\"KnownProfiles\", \"ProfileDefinition\"], \"azure.profiles.multiapiclient\": [\"MultiApiClientMixin\"]}, \"local\": {\"._configuration\": [\"PolicyClientConfiguration\"], \".._serialization\": [\"Deserializer\", \"Serializer\"]}}, \"typing\": {\"azurecore\": {\"azure.core.credentials\": [\"TokenCredential\"]}}}", + "async_imports": "{\"conditional\": {\"stdlib\": {\"typing\": [\"Any\", \"Optional\"]}}, \"regular\": {\"azurecore\": {\"azure.mgmt.core\": [\"AsyncARMPipelineClient\"], \"azure.profiles\": [\"KnownProfiles\", \"ProfileDefinition\"], \"azure.profiles.multiapiclient\": [\"MultiApiClientMixin\"]}, \"local\": {\"._configuration\": [\"PolicyClientConfiguration\"], \"..._serialization\": [\"Deserializer\", \"Serializer\"]}}, \"typing\": {\"azurecore\": {\"azure.core.credentials_async\": [\"AsyncTokenCredential\"]}}}" }, "global_parameters": { "sync": { "credential": { - "signature": "credential, # type: \"TokenCredential\"", - "description": "Credential needed for the client to connect to Azure.", + "signature": "credential: \"TokenCredential\",", + "description": "Credential needed for the client to connect to Azure. Required.", "docstring_type": "~azure.core.credentials.TokenCredential", "required": true }, "subscription_id": { - "signature": "subscription_id, # type: str", - "description": "The ID of the target subscription.", + "signature": "subscription_id: str,", + "description": "The ID of the target subscription. Required.", "docstring_type": "str", "required": true } @@ -31,13 +31,13 @@ "async": { "credential": { "signature": "credential: \"AsyncTokenCredential\",", - "description": "Credential needed for the client to connect to Azure.", + "description": "Credential needed for the client to connect to Azure. Required.", "docstring_type": "~azure.core.credentials_async.AsyncTokenCredential", "required": true }, "subscription_id": { "signature": "subscription_id: str,", - "description": "The ID of the target subscription.", + "description": "The ID of the target subscription. Required.", "docstring_type": "str", "required": true } @@ -54,7 +54,7 @@ "required": false }, "base_url": { - "signature": "base_url=\"https://management.azure.com\", # type: str", + "signature": "base_url: str = \"https://management.azure.com\",", "description": "Service URL", "docstring_type": "str", "required": false diff --git a/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/policy/v2019_06_01/_patch.py b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/policy/v2019_06_01/_patch.py index 74e48ecd07cf3..f99e77fef9861 100644 --- a/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/policy/v2019_06_01/_patch.py +++ b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/policy/v2019_06_01/_patch.py @@ -28,4 +28,4 @@ # This file is used for handwritten extensions to the generated code. Example: # https://github.com/Azure/azure-sdk-for-python/blob/main/doc/dev/customize_code/how-to-patch-sdk-code.md def patch_sdk(): - pass \ No newline at end of file + pass diff --git a/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/policy/v2019_06_01/_policy_client.py b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/policy/v2019_06_01/_policy_client.py index 83dbfe1128c15..6a43a4c314965 100644 --- a/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/policy/v2019_06_01/_policy_client.py +++ b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/policy/v2019_06_01/_policy_client.py @@ -9,12 +9,11 @@ from copy import deepcopy from typing import Any, TYPE_CHECKING -from msrest import Deserializer, Serializer - from azure.core.rest import HttpRequest, HttpResponse from azure.mgmt.core import ARMPipelineClient from . import models +from .._serialization import Deserializer, Serializer from ._configuration import PolicyClientConfiguration from .operations import PolicyAssignmentsOperations, PolicyDefinitionsOperations, PolicySetDefinitionsOperations @@ -22,7 +21,8 @@ # pylint: disable=unused-import,ungrouped-imports from azure.core.credentials import TokenCredential -class PolicyClient: + +class PolicyClient: # pylint: disable=client-accepts-api-version-keyword """To manage and control access to your resources, you can define customized policies and assign them at a scope. @@ -35,9 +35,9 @@ class PolicyClient: :ivar policy_set_definitions: PolicySetDefinitionsOperations operations :vartype policy_set_definitions: azure.mgmt.resource.policy.v2019_06_01.operations.PolicySetDefinitionsOperations - :param credential: Credential needed for the client to connect to Azure. + :param credential: Credential needed for the client to connect to Azure. Required. :type credential: ~azure.core.credentials.TokenCredential - :param subscription_id: The ID of the target subscription. + :param subscription_id: The ID of the target subscription. Required. :type subscription_id: str :param base_url: Service URL. Default value is "https://management.azure.com". :type base_url: str @@ -60,16 +60,17 @@ def __init__( self._serialize = Serializer(client_models) self._deserialize = Deserializer(client_models) self._serialize.client_side_validation = False - self.policy_assignments = PolicyAssignmentsOperations(self._client, self._config, self._serialize, self._deserialize) - self.policy_definitions = PolicyDefinitionsOperations(self._client, self._config, self._serialize, self._deserialize) - self.policy_set_definitions = PolicySetDefinitionsOperations(self._client, self._config, self._serialize, self._deserialize) - - - def _send_request( - self, - request: HttpRequest, - **kwargs: Any - ) -> HttpResponse: + self.policy_assignments = PolicyAssignmentsOperations( + self._client, self._config, self._serialize, self._deserialize + ) + self.policy_definitions = PolicyDefinitionsOperations( + self._client, self._config, self._serialize, self._deserialize + ) + self.policy_set_definitions = PolicySetDefinitionsOperations( + self._client, self._config, self._serialize, self._deserialize + ) + + def _send_request(self, request: HttpRequest, **kwargs: Any) -> HttpResponse: """Runs the network request through the client's chained policies. >>> from azure.core.rest import HttpRequest @@ -78,7 +79,7 @@ def _send_request( >>> response = client._send_request(request) - For more information on this code flow, see https://aka.ms/azsdk/python/protocol/quickstart + For more information on this code flow, see https://aka.ms/azsdk/dpcodegen/python/send_request :param request: The network request you want to make. Required. :type request: ~azure.core.rest.HttpRequest diff --git a/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/policy/v2019_06_01/_vendor.py b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/policy/v2019_06_01/_vendor.py index 138f663c53a4e..9aad73fc743e7 100644 --- a/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/policy/v2019_06_01/_vendor.py +++ b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/policy/v2019_06_01/_vendor.py @@ -7,6 +7,7 @@ from azure.core.pipeline.transport import HttpRequest + def _convert_request(request, files=None): data = request.content if not files else None request = HttpRequest(method=request.method, url=request.url, headers=request.headers, data=data) @@ -14,6 +15,7 @@ def _convert_request(request, files=None): request.set_formdata_body(files) return request + def _format_url_section(template, **kwargs): components = template.split("/") while components: @@ -21,7 +23,5 @@ def _format_url_section(template, **kwargs): 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 - ] + components = [c for c in formatted_components if "{}".format(key.args[0]) not in c] template = "/".join(components) diff --git a/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/policy/v2019_06_01/_version.py b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/policy/v2019_06_01/_version.py index a012ac01c480c..e5754a47ce68f 100644 --- a/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/policy/v2019_06_01/_version.py +++ b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/policy/v2019_06_01/_version.py @@ -6,4 +6,4 @@ # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -VERSION = "21.1.0" +VERSION = "1.0.0b1" diff --git a/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/policy/v2019_06_01/aio/__init__.py b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/policy/v2019_06_01/aio/__init__.py index 2784ce3f14bf5..4622bf1f396a7 100644 --- a/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/policy/v2019_06_01/aio/__init__.py +++ b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/policy/v2019_06_01/aio/__init__.py @@ -7,9 +7,15 @@ # -------------------------------------------------------------------------- from ._policy_client import PolicyClient -__all__ = ['PolicyClient'] -# `._patch.py` is used for handwritten extensions to the generated code -# Example: https://github.com/Azure/azure-sdk-for-python/blob/main/doc/dev/customize_code/how-to-patch-sdk-code.md -from ._patch import patch_sdk -patch_sdk() +try: + from ._patch import __all__ as _patch_all + from ._patch import * # type: ignore # pylint: disable=unused-wildcard-import +except ImportError: + _patch_all = [] +from ._patch import patch_sdk as _patch_sdk + +__all__ = ["PolicyClient"] +__all__.extend([p for p in _patch_all if p not in __all__]) + +_patch_sdk() diff --git a/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/policy/v2019_06_01/aio/_configuration.py b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/policy/v2019_06_01/aio/_configuration.py index 2d60b9d91dd8b..5531a0c5e7da5 100644 --- a/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/policy/v2019_06_01/aio/_configuration.py +++ b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/policy/v2019_06_01/aio/_configuration.py @@ -25,23 +25,18 @@ class PolicyClientConfiguration(Configuration): # pylint: disable=too-many-inst Note that all parameters used to create this instance are saved as instance attributes. - :param credential: Credential needed for the client to connect to Azure. + :param credential: Credential needed for the client to connect to Azure. Required. :type credential: ~azure.core.credentials_async.AsyncTokenCredential - :param subscription_id: The ID of the target subscription. + :param subscription_id: The ID of the target subscription. Required. :type subscription_id: str :keyword api_version: Api Version. Default value is "2019-06-01". Note that overriding this default value may result in unsupported behavior. :paramtype api_version: str """ - def __init__( - self, - credential: "AsyncTokenCredential", - subscription_id: str, - **kwargs: Any - ) -> None: + def __init__(self, credential: "AsyncTokenCredential", subscription_id: str, **kwargs: Any) -> None: super(PolicyClientConfiguration, self).__init__(**kwargs) - api_version = kwargs.pop('api_version', "2019-06-01") # type: str + api_version = kwargs.pop("api_version", "2019-06-01") # type: str if credential is None: raise ValueError("Parameter 'credential' must not be None.") @@ -51,22 +46,21 @@ def __init__( self.credential = credential self.subscription_id = subscription_id self.api_version = api_version - self.credential_scopes = kwargs.pop('credential_scopes', ['https://management.azure.com/.default']) - kwargs.setdefault('sdk_moniker', 'mgmt-resource/{}'.format(VERSION)) + self.credential_scopes = kwargs.pop("credential_scopes", ["https://management.azure.com/.default"]) + kwargs.setdefault("sdk_moniker", "mgmt-resource/{}".format(VERSION)) self._configure(**kwargs) - 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) - self.logging_policy = kwargs.get('logging_policy') or policies.NetworkTraceLoggingPolicy(**kwargs) - self.http_logging_policy = kwargs.get('http_logging_policy') or ARMHttpLoggingPolicy(**kwargs) - self.retry_policy = kwargs.get('retry_policy') or policies.AsyncRetryPolicy(**kwargs) - self.custom_hook_policy = kwargs.get('custom_hook_policy') or policies.CustomHookPolicy(**kwargs) - self.redirect_policy = kwargs.get('redirect_policy') or policies.AsyncRedirectPolicy(**kwargs) - self.authentication_policy = kwargs.get('authentication_policy') + 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) + self.logging_policy = kwargs.get("logging_policy") or policies.NetworkTraceLoggingPolicy(**kwargs) + self.http_logging_policy = kwargs.get("http_logging_policy") or ARMHttpLoggingPolicy(**kwargs) + self.retry_policy = kwargs.get("retry_policy") or policies.AsyncRetryPolicy(**kwargs) + self.custom_hook_policy = kwargs.get("custom_hook_policy") or policies.CustomHookPolicy(**kwargs) + self.redirect_policy = kwargs.get("redirect_policy") or policies.AsyncRedirectPolicy(**kwargs) + self.authentication_policy = kwargs.get("authentication_policy") if self.credential and not self.authentication_policy: - self.authentication_policy = AsyncARMChallengeAuthenticationPolicy(self.credential, *self.credential_scopes, **kwargs) + self.authentication_policy = AsyncARMChallengeAuthenticationPolicy( + self.credential, *self.credential_scopes, **kwargs + ) diff --git a/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/policy/v2019_06_01/aio/_patch.py b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/policy/v2019_06_01/aio/_patch.py index 74e48ecd07cf3..f99e77fef9861 100644 --- a/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/policy/v2019_06_01/aio/_patch.py +++ b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/policy/v2019_06_01/aio/_patch.py @@ -28,4 +28,4 @@ # This file is used for handwritten extensions to the generated code. Example: # https://github.com/Azure/azure-sdk-for-python/blob/main/doc/dev/customize_code/how-to-patch-sdk-code.md def patch_sdk(): - pass \ No newline at end of file + pass diff --git a/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/policy/v2019_06_01/aio/_policy_client.py b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/policy/v2019_06_01/aio/_policy_client.py index 4fa661d8cd934..19bf09d2ec03c 100644 --- a/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/policy/v2019_06_01/aio/_policy_client.py +++ b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/policy/v2019_06_01/aio/_policy_client.py @@ -9,12 +9,11 @@ from copy import deepcopy from typing import Any, Awaitable, TYPE_CHECKING -from msrest import Deserializer, Serializer - from azure.core.rest import AsyncHttpResponse, HttpRequest from azure.mgmt.core import AsyncARMPipelineClient from .. import models +from ..._serialization import Deserializer, Serializer from ._configuration import PolicyClientConfiguration from .operations import PolicyAssignmentsOperations, PolicyDefinitionsOperations, PolicySetDefinitionsOperations @@ -22,7 +21,8 @@ # pylint: disable=unused-import,ungrouped-imports from azure.core.credentials_async import AsyncTokenCredential -class PolicyClient: + +class PolicyClient: # pylint: disable=client-accepts-api-version-keyword """To manage and control access to your resources, you can define customized policies and assign them at a scope. @@ -35,9 +35,9 @@ class PolicyClient: :ivar policy_set_definitions: PolicySetDefinitionsOperations operations :vartype policy_set_definitions: azure.mgmt.resource.policy.v2019_06_01.aio.operations.PolicySetDefinitionsOperations - :param credential: Credential needed for the client to connect to Azure. + :param credential: Credential needed for the client to connect to Azure. Required. :type credential: ~azure.core.credentials_async.AsyncTokenCredential - :param subscription_id: The ID of the target subscription. + :param subscription_id: The ID of the target subscription. Required. :type subscription_id: str :param base_url: Service URL. Default value is "https://management.azure.com". :type base_url: str @@ -60,16 +60,17 @@ def __init__( self._serialize = Serializer(client_models) self._deserialize = Deserializer(client_models) self._serialize.client_side_validation = False - self.policy_assignments = PolicyAssignmentsOperations(self._client, self._config, self._serialize, self._deserialize) - self.policy_definitions = PolicyDefinitionsOperations(self._client, self._config, self._serialize, self._deserialize) - self.policy_set_definitions = PolicySetDefinitionsOperations(self._client, self._config, self._serialize, self._deserialize) - - - def _send_request( - self, - request: HttpRequest, - **kwargs: Any - ) -> Awaitable[AsyncHttpResponse]: + self.policy_assignments = PolicyAssignmentsOperations( + self._client, self._config, self._serialize, self._deserialize + ) + self.policy_definitions = PolicyDefinitionsOperations( + self._client, self._config, self._serialize, self._deserialize + ) + self.policy_set_definitions = PolicySetDefinitionsOperations( + self._client, self._config, self._serialize, self._deserialize + ) + + def _send_request(self, request: HttpRequest, **kwargs: Any) -> Awaitable[AsyncHttpResponse]: """Runs the network request through the client's chained policies. >>> from azure.core.rest import HttpRequest @@ -78,7 +79,7 @@ def _send_request( >>> response = await client._send_request(request) - For more information on this code flow, see https://aka.ms/azsdk/python/protocol/quickstart + For more information on this code flow, see https://aka.ms/azsdk/dpcodegen/python/send_request :param request: The network request you want to make. Required. :type request: ~azure.core.rest.HttpRequest diff --git a/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/policy/v2019_06_01/aio/operations/__init__.py b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/policy/v2019_06_01/aio/operations/__init__.py index b2ae6190b03fb..4e1971e3e3247 100644 --- a/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/policy/v2019_06_01/aio/operations/__init__.py +++ b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/policy/v2019_06_01/aio/operations/__init__.py @@ -10,8 +10,14 @@ from ._operations import PolicyDefinitionsOperations from ._operations import PolicySetDefinitionsOperations +from ._patch import __all__ as _patch_all +from ._patch import * # type: ignore # pylint: disable=unused-wildcard-import +from ._patch import patch_sdk as _patch_sdk + __all__ = [ - 'PolicyAssignmentsOperations', - 'PolicyDefinitionsOperations', - 'PolicySetDefinitionsOperations', + "PolicyAssignmentsOperations", + "PolicyDefinitionsOperations", + "PolicySetDefinitionsOperations", ] +__all__.extend([p for p in _patch_all if p not in __all__]) +_patch_sdk() diff --git a/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/policy/v2019_06_01/aio/operations/_operations.py b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/policy/v2019_06_01/aio/operations/_operations.py index 78856eba87cb6..87abed279a76c 100644 --- a/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/policy/v2019_06_01/aio/operations/_operations.py +++ b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/policy/v2019_06_01/aio/operations/_operations.py @@ -6,52 +6,87 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -from typing import Any, AsyncIterable, Callable, Dict, Optional, TypeVar +from typing import Any, AsyncIterable, Callable, Dict, IO, Optional, TypeVar, Union, overload +from urllib.parse import parse_qs, urljoin, urlparse from azure.core.async_paging import AsyncItemPaged, AsyncList -from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error +from azure.core.exceptions import ( + ClientAuthenticationError, + HttpResponseError, + ResourceExistsError, + ResourceNotFoundError, + ResourceNotModifiedError, + map_error, +) from azure.core.pipeline import PipelineResponse from azure.core.pipeline.transport import AsyncHttpResponse from azure.core.rest import HttpRequest from azure.core.tracing.decorator import distributed_trace from azure.core.tracing.decorator_async import distributed_trace_async +from azure.core.utils import case_insensitive_dict from azure.mgmt.core.exceptions import ARMErrorFormat from ... import models as _models from ..._vendor import _convert_request -from ...operations._operations import build_policy_assignments_create_by_id_request, build_policy_assignments_create_request, build_policy_assignments_delete_by_id_request, build_policy_assignments_delete_request, build_policy_assignments_get_by_id_request, build_policy_assignments_get_request, build_policy_assignments_list_for_resource_group_request, build_policy_assignments_list_for_resource_request, build_policy_assignments_list_request, build_policy_definitions_create_or_update_at_management_group_request, build_policy_definitions_create_or_update_request, build_policy_definitions_delete_at_management_group_request, build_policy_definitions_delete_request, build_policy_definitions_get_at_management_group_request, build_policy_definitions_get_built_in_request, build_policy_definitions_get_request, build_policy_definitions_list_built_in_request, build_policy_definitions_list_by_management_group_request, build_policy_definitions_list_request, build_policy_set_definitions_create_or_update_at_management_group_request, build_policy_set_definitions_create_or_update_request, build_policy_set_definitions_delete_at_management_group_request, build_policy_set_definitions_delete_request, build_policy_set_definitions_get_at_management_group_request, build_policy_set_definitions_get_built_in_request, build_policy_set_definitions_get_request, build_policy_set_definitions_list_built_in_request, build_policy_set_definitions_list_by_management_group_request, build_policy_set_definitions_list_request -T = TypeVar('T') +from ...operations._operations import ( + build_policy_assignments_create_by_id_request, + build_policy_assignments_create_request, + build_policy_assignments_delete_by_id_request, + build_policy_assignments_delete_request, + build_policy_assignments_get_by_id_request, + build_policy_assignments_get_request, + build_policy_assignments_list_for_resource_group_request, + build_policy_assignments_list_for_resource_request, + build_policy_assignments_list_request, + build_policy_definitions_create_or_update_at_management_group_request, + build_policy_definitions_create_or_update_request, + build_policy_definitions_delete_at_management_group_request, + build_policy_definitions_delete_request, + build_policy_definitions_get_at_management_group_request, + build_policy_definitions_get_built_in_request, + build_policy_definitions_get_request, + build_policy_definitions_list_built_in_request, + build_policy_definitions_list_by_management_group_request, + build_policy_definitions_list_request, + build_policy_set_definitions_create_or_update_at_management_group_request, + build_policy_set_definitions_create_or_update_request, + build_policy_set_definitions_delete_at_management_group_request, + build_policy_set_definitions_delete_request, + build_policy_set_definitions_get_at_management_group_request, + build_policy_set_definitions_get_built_in_request, + build_policy_set_definitions_get_request, + build_policy_set_definitions_list_built_in_request, + build_policy_set_definitions_list_by_management_group_request, + build_policy_set_definitions_list_request, +) + +T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] -class PolicyAssignmentsOperations: - """PolicyAssignmentsOperations async operations. - You should not instantiate this class directly. Instead, you should create a Client instance that - instantiates it for you and attaches it as an attribute. +class PolicyAssignmentsOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. - :ivar models: Alias to model classes used in this operation group. - :type models: ~azure.mgmt.resource.policy.v2019_06_01.models - :param client: Client for service requests. - :param config: Configuration of service client. - :param serializer: An object model serializer. - :param deserializer: An object model deserializer. + Instead, you should access the following operations through + :class:`~azure.mgmt.resource.policy.v2019_06_01.aio.PolicyClient`'s + :attr:`policy_assignments` attribute. """ models = _models - def __init__(self, client, config, serializer, deserializer) -> None: - self._client = client - self._serialize = serializer - self._deserialize = deserializer - self._config = config + def __init__(self, *args, **kwargs) -> None: + input_args = list(args) + self._client = input_args.pop(0) if input_args else kwargs.pop("client") + self._config = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") @distributed_trace_async async def delete( - self, - scope: str, - policy_assignment_name: str, - **kwargs: Any - ) -> Optional["_models.PolicyAssignment"]: + self, scope: str, policy_assignment_name: str, **kwargs: Any + ) -> Optional[_models.PolicyAssignment]: """Deletes a policy assignment. This operation deletes a policy assignment, given its name and the scope it was created in. The @@ -63,37 +98,44 @@ async def delete( '/subscriptions/{subscriptionId}'), resource group (format: '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}', or resource (format: '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{resourceProviderNamespace}/[{parentResourcePath}/]{resourceType}/{resourceName}'. + Required. :type scope: str - :param policy_assignment_name: The name of the policy assignment to delete. + :param policy_assignment_name: The name of the policy assignment to delete. Required. :type policy_assignment_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: PolicyAssignment, or the result of cls(response) + :return: PolicyAssignment or None or the result of cls(response) :rtype: ~azure.mgmt.resource.policy.v2019_06_01.models.PolicyAssignment or None - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType[Optional["_models.PolicyAssignment"]] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) - api_version = kwargs.pop('api_version', "2019-06-01") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2019-06-01")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[Optional[_models.PolicyAssignment]] - request = build_policy_assignments_delete_request( scope=scope, policy_assignment_name=policy_assignment_name, api_version=api_version, - template_url=self.delete.metadata['url'], + template_url=self.delete.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200, 204]: @@ -103,24 +145,25 @@ async def delete( deserialized = None if response.status_code == 200: - deserialized = self._deserialize('PolicyAssignment', pipeline_response) + deserialized = self._deserialize("PolicyAssignment", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - delete.metadata = {'url': "/{scope}/providers/Microsoft.Authorization/policyAssignments/{policyAssignmentName}"} # type: ignore - + delete.metadata = {"url": "/{scope}/providers/Microsoft.Authorization/policyAssignments/{policyAssignmentName}"} # type: ignore - @distributed_trace_async + @overload async def create( self, scope: str, policy_assignment_name: str, - parameters: "_models.PolicyAssignment", + parameters: _models.PolicyAssignment, + *, + content_type: str = "application/json", **kwargs: Any - ) -> "_models.PolicyAssignment": + ) -> _models.PolicyAssignment: """Creates or updates a policy assignment. This operation creates or updates a policy assignment with the given scope and name. Policy @@ -132,26 +175,109 @@ async def create( '/subscriptions/{subscriptionId}'), resource group (format: '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}', or resource (format: '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{resourceProviderNamespace}/[{parentResourcePath}/]{resourceType}/{resourceName}'. + Required. :type scope: str - :param policy_assignment_name: The name of the policy assignment. + :param policy_assignment_name: The name of the policy assignment. Required. :type policy_assignment_name: str - :param parameters: Parameters for the policy assignment. + :param parameters: Parameters for the policy assignment. Required. :type parameters: ~azure.mgmt.resource.policy.v2019_06_01.models.PolicyAssignment + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: PolicyAssignment or the result of cls(response) + :rtype: ~azure.mgmt.resource.policy.v2019_06_01.models.PolicyAssignment + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + async def create( + self, + scope: str, + policy_assignment_name: str, + parameters: IO, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.PolicyAssignment: + """Creates or updates a policy assignment. + + This operation creates or updates a policy assignment with the given scope and name. Policy + assignments apply to all resources contained within their scope. For example, when you assign a + policy at resource group scope, that policy applies to all resources in the group. + + :param scope: The scope of the policy assignment. Valid scopes are: management group (format: + '/providers/Microsoft.Management/managementGroups/{managementGroup}'), subscription (format: + '/subscriptions/{subscriptionId}'), resource group (format: + '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}', or resource (format: + '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{resourceProviderNamespace}/[{parentResourcePath}/]{resourceType}/{resourceName}'. + Required. + :type scope: str + :param policy_assignment_name: The name of the policy assignment. Required. + :type policy_assignment_name: str + :param parameters: Parameters for the policy assignment. Required. + :type parameters: IO + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: PolicyAssignment or the result of cls(response) + :rtype: ~azure.mgmt.resource.policy.v2019_06_01.models.PolicyAssignment + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace_async + async def create( + self, scope: str, policy_assignment_name: str, parameters: Union[_models.PolicyAssignment, IO], **kwargs: Any + ) -> _models.PolicyAssignment: + """Creates or updates a policy assignment. + + This operation creates or updates a policy assignment with the given scope and name. Policy + assignments apply to all resources contained within their scope. For example, when you assign a + policy at resource group scope, that policy applies to all resources in the group. + + :param scope: The scope of the policy assignment. Valid scopes are: management group (format: + '/providers/Microsoft.Management/managementGroups/{managementGroup}'), subscription (format: + '/subscriptions/{subscriptionId}'), resource group (format: + '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}', or resource (format: + '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{resourceProviderNamespace}/[{parentResourcePath}/]{resourceType}/{resourceName}'. + Required. + :type scope: str + :param policy_assignment_name: The name of the policy assignment. Required. + :type policy_assignment_name: str + :param parameters: Parameters for the policy assignment. Is either a model type or a IO type. + Required. + :type parameters: ~azure.mgmt.resource.policy.v2019_06_01.models.PolicyAssignment or IO + :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. + Default value is None. + :paramtype content_type: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: PolicyAssignment, or the result of cls(response) + :return: PolicyAssignment or the result of cls(response) :rtype: ~azure.mgmt.resource.policy.v2019_06_01.models.PolicyAssignment - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.PolicyAssignment"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', "2019-06-01") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + api_version = kwargs.pop("api_version", _params.pop("api-version", "2019-06-01")) # type: str + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.PolicyAssignment] - _json = self._serialize.body(parameters, 'PolicyAssignment') + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(parameters, (IO, bytes)): + _content = parameters + else: + _json = self._serialize.body(parameters, "PolicyAssignment") request = build_policy_assignments_create_request( scope=scope, @@ -159,16 +285,18 @@ async def create( api_version=api_version, content_type=content_type, json=_json, - template_url=self.create.metadata['url'], + content=_content, + template_url=self.create.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [201]: @@ -176,23 +304,17 @@ async def create( error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - deserialized = self._deserialize('PolicyAssignment', pipeline_response) + deserialized = self._deserialize("PolicyAssignment", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - create.metadata = {'url': "/{scope}/providers/Microsoft.Authorization/policyAssignments/{policyAssignmentName}"} # type: ignore - + create.metadata = {"url": "/{scope}/providers/Microsoft.Authorization/policyAssignments/{policyAssignmentName}"} # type: ignore @distributed_trace_async - async def get( - self, - scope: str, - policy_assignment_name: str, - **kwargs: Any - ) -> "_models.PolicyAssignment": + async def get(self, scope: str, policy_assignment_name: str, **kwargs: Any) -> _models.PolicyAssignment: """Retrieves a policy assignment. This operation retrieves a single policy assignment, given its name and the scope it was @@ -203,37 +325,44 @@ async def get( '/subscriptions/{subscriptionId}'), resource group (format: '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}', or resource (format: '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{resourceProviderNamespace}/[{parentResourcePath}/]{resourceType}/{resourceName}'. + Required. :type scope: str - :param policy_assignment_name: The name of the policy assignment to get. + :param policy_assignment_name: The name of the policy assignment to get. Required. :type policy_assignment_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: PolicyAssignment, or the result of cls(response) + :return: PolicyAssignment or the result of cls(response) :rtype: ~azure.mgmt.resource.policy.v2019_06_01.models.PolicyAssignment - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.PolicyAssignment"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + 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', "2019-06-01") # type: str + api_version = kwargs.pop("api_version", _params.pop("api-version", "2019-06-01")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[_models.PolicyAssignment] - request = build_policy_assignments_get_request( scope=scope, policy_assignment_name=policy_assignment_name, api_version=api_version, - template_url=self.get.metadata['url'], + template_url=self.get.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200]: @@ -241,23 +370,19 @@ async def get( error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - deserialized = self._deserialize('PolicyAssignment', pipeline_response) + deserialized = self._deserialize("PolicyAssignment", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - get.metadata = {'url': "/{scope}/providers/Microsoft.Authorization/policyAssignments/{policyAssignmentName}"} # type: ignore - + get.metadata = {"url": "/{scope}/providers/Microsoft.Authorization/policyAssignments/{policyAssignmentName}"} # type: ignore @distributed_trace def list_for_resource_group( - self, - resource_group_name: str, - filter: Optional[str] = None, - **kwargs: Any - ) -> AsyncIterable["_models.PolicyAssignmentListResult"]: + self, resource_group_name: str, filter: Optional[str] = None, **kwargs: Any + ) -> AsyncIterable["_models.PolicyAssignment"]: """Retrieves all policy assignments that apply to a resource group. This operation retrieves the list of all policy assignments associated with the given resource @@ -272,47 +397,55 @@ def list_for_resource_group( assignments of the policy definition whose id is {value} that apply to the resource group. :param resource_group_name: The name of the resource group that contains policy assignments. + Required. :type resource_group_name: str :param filter: The filter to apply on the operation. Valid values for $filter are: 'atScope()' or 'policyDefinitionId eq '{value}''. If $filter is not provided, no filtering is performed. Default value is None. :type filter: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either PolicyAssignmentListResult or the result of - cls(response) + :return: An iterator like instance of either PolicyAssignment or the result of cls(response) :rtype: - ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.resource.policy.v2019_06_01.models.PolicyAssignmentListResult] - :raises: ~azure.core.exceptions.HttpResponseError + ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.resource.policy.v2019_06_01.models.PolicyAssignment] + :raises ~azure.core.exceptions.HttpResponseError: """ - api_version = kwargs.pop('api_version', "2019-06-01") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2019-06-01")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[_models.PolicyAssignmentListResult] - cls = kwargs.pop('cls', None) # type: ClsType["_models.PolicyAssignmentListResult"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) + def prepare_request(next_link=None): if not next_link: - + request = build_policy_assignments_list_for_resource_group_request( resource_group_name=resource_group_name, subscription_id=self._config.subscription_id, - api_version=api_version, filter=filter, - template_url=self.list_for_resource_group.metadata['url'], + api_version=api_version, + template_url=self.list_for_resource_group.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore else: - - request = build_policy_assignments_list_for_resource_group_request( - resource_group_name=resource_group_name, - subscription_id=self._config.subscription_id, - template_url=next_link, - ) + # make call to next link with the client's api-version + _parsed_next_link = urlparse(next_link) + _next_request_params = case_insensitive_dict(parse_qs(_parsed_next_link.query)) + _next_request_params["api-version"] = self._config.api_version + request = HttpRequest("GET", urljoin(next_link, _parsed_next_link.path), params=_next_request_params) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore request.method = "GET" return request @@ -326,10 +459,8 @@ async def extract_data(pipeline_response): async def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) response = pipeline_response.http_response @@ -340,11 +471,9 @@ async def get_next(next_link=None): return pipeline_response + return AsyncItemPaged(get_next, extract_data) - return AsyncItemPaged( - get_next, extract_data - ) - list_for_resource_group.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Authorization/policyAssignments"} # type: ignore + list_for_resource_group.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Authorization/policyAssignments"} # type: ignore @distributed_trace def list_for_resource( @@ -356,7 +485,7 @@ def list_for_resource( resource_name: str, filter: Optional[str] = None, **kwargs: Any - ) -> AsyncIterable["_models.PolicyAssignmentListResult"]: + ) -> AsyncIterable["_models.PolicyAssignment"]: """Retrieves all policy assignments that apply to a resource. This operation retrieves the list of all policy assignments associated with the specified @@ -382,39 +511,47 @@ def list_for_resource( {parentResourcePath} == '', {resourceType} == 'Microsoft.Web/sites', {resourceName} == 'MyWebApp'). - :param resource_group_name: The name of the resource group containing the resource. + :param resource_group_name: The name of the resource group containing the resource. Required. :type resource_group_name: str :param resource_provider_namespace: The namespace of the resource provider. For example, the namespace of a virtual machine is Microsoft.Compute (from Microsoft.Compute/virtualMachines). + Required. :type resource_provider_namespace: str :param parent_resource_path: The parent resource path. Use empty string if there is none. + Required. :type parent_resource_path: str :param resource_type: The resource type name. For example the type name of a web app is 'sites' - (from Microsoft.Web/sites). + (from Microsoft.Web/sites). Required. :type resource_type: str - :param resource_name: The name of the resource. + :param resource_name: The name of the resource. Required. :type resource_name: str :param filter: The filter to apply on the operation. Valid values for $filter are: 'atScope()' or 'policyDefinitionId eq '{value}''. If $filter is not provided, no filtering is performed. Default value is None. :type filter: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either PolicyAssignmentListResult or the result of - cls(response) + :return: An iterator like instance of either PolicyAssignment or the result of cls(response) :rtype: - ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.resource.policy.v2019_06_01.models.PolicyAssignmentListResult] - :raises: ~azure.core.exceptions.HttpResponseError + ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.resource.policy.v2019_06_01.models.PolicyAssignment] + :raises ~azure.core.exceptions.HttpResponseError: """ - api_version = kwargs.pop('api_version', "2019-06-01") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2019-06-01")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[_models.PolicyAssignmentListResult] - cls = kwargs.pop('cls', None) # type: ClsType["_models.PolicyAssignmentListResult"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) + def prepare_request(next_link=None): if not next_link: - + request = build_policy_assignments_list_for_resource_request( resource_group_name=resource_group_name, resource_provider_namespace=resource_provider_namespace, @@ -422,26 +559,23 @@ def prepare_request(next_link=None): resource_type=resource_type, resource_name=resource_name, subscription_id=self._config.subscription_id, - api_version=api_version, filter=filter, - template_url=self.list_for_resource.metadata['url'], + api_version=api_version, + template_url=self.list_for_resource.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore else: - - request = build_policy_assignments_list_for_resource_request( - resource_group_name=resource_group_name, - resource_provider_namespace=resource_provider_namespace, - parent_resource_path=parent_resource_path, - resource_type=resource_type, - resource_name=resource_name, - subscription_id=self._config.subscription_id, - template_url=next_link, - ) + # make call to next link with the client's api-version + _parsed_next_link = urlparse(next_link) + _next_request_params = case_insensitive_dict(parse_qs(_parsed_next_link.query)) + _next_request_params["api-version"] = self._config.api_version + request = HttpRequest("GET", urljoin(next_link, _parsed_next_link.path), params=_next_request_params) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore request.method = "GET" return request @@ -455,10 +589,8 @@ async def extract_data(pipeline_response): async def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) response = pipeline_response.http_response @@ -469,18 +601,12 @@ async def get_next(next_link=None): return pipeline_response + return AsyncItemPaged(get_next, extract_data) - return AsyncItemPaged( - get_next, extract_data - ) - list_for_resource.metadata = {'url': "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{parentResourcePath}/{resourceType}/{resourceName}/providers/Microsoft.Authorization/policyAssignments"} # type: ignore + list_for_resource.metadata = {"url": "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{parentResourcePath}/{resourceType}/{resourceName}/providers/Microsoft.Authorization/policyAssignments"} # type: ignore @distributed_trace - def list( - self, - filter: Optional[str] = None, - **kwargs: Any - ) -> AsyncIterable["_models.PolicyAssignmentListResult"]: + def list(self, filter: Optional[str] = None, **kwargs: Any) -> AsyncIterable["_models.PolicyAssignment"]: """Retrieves all policy assignments that apply to a subscription. This operation retrieves the list of all policy assignments associated with the given @@ -499,39 +625,47 @@ def list( Default value is None. :type filter: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either PolicyAssignmentListResult or the result of - cls(response) + :return: An iterator like instance of either PolicyAssignment or the result of cls(response) :rtype: - ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.resource.policy.v2019_06_01.models.PolicyAssignmentListResult] - :raises: ~azure.core.exceptions.HttpResponseError + ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.resource.policy.v2019_06_01.models.PolicyAssignment] + :raises ~azure.core.exceptions.HttpResponseError: """ - api_version = kwargs.pop('api_version', "2019-06-01") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2019-06-01")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[_models.PolicyAssignmentListResult] - cls = kwargs.pop('cls', None) # type: ClsType["_models.PolicyAssignmentListResult"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) + def prepare_request(next_link=None): if not next_link: - + request = build_policy_assignments_list_request( subscription_id=self._config.subscription_id, - api_version=api_version, filter=filter, - template_url=self.list.metadata['url'], + 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.url = self._client.format_url(request.url) # type: ignore else: - - request = build_policy_assignments_list_request( - subscription_id=self._config.subscription_id, - template_url=next_link, - ) + # make call to next link with the client's api-version + _parsed_next_link = urlparse(next_link) + _next_request_params = case_insensitive_dict(parse_qs(_parsed_next_link.query)) + _next_request_params["api-version"] = self._config.api_version + request = HttpRequest("GET", urljoin(next_link, _parsed_next_link.path), params=_next_request_params) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore request.method = "GET" return request @@ -545,10 +679,8 @@ async def extract_data(pipeline_response): async def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) response = pipeline_response.http_response @@ -559,18 +691,12 @@ async def get_next(next_link=None): return pipeline_response + return AsyncItemPaged(get_next, extract_data) - return AsyncItemPaged( - get_next, extract_data - ) - list.metadata = {'url': "/subscriptions/{subscriptionId}/providers/Microsoft.Authorization/policyAssignments"} # type: ignore + list.metadata = {"url": "/subscriptions/{subscriptionId}/providers/Microsoft.Authorization/policyAssignments"} # type: ignore @distributed_trace_async - async def delete_by_id( - self, - policy_assignment_id: str, - **kwargs: Any - ) -> Optional["_models.PolicyAssignment"]: + async def delete_by_id(self, policy_assignment_id: str, **kwargs: Any) -> Optional[_models.PolicyAssignment]: """Deletes a policy assignment. This operation deletes the policy with the given ID. Policy assignment IDs have this format: @@ -582,35 +708,41 @@ async def delete_by_id( (resource). :param policy_assignment_id: The ID of the policy assignment to delete. Use the format - '{scope}/providers/Microsoft.Authorization/policyAssignments/{policyAssignmentName}'. + '{scope}/providers/Microsoft.Authorization/policyAssignments/{policyAssignmentName}'. Required. :type policy_assignment_id: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: PolicyAssignment, or the result of cls(response) + :return: PolicyAssignment or None or the result of cls(response) :rtype: ~azure.mgmt.resource.policy.v2019_06_01.models.PolicyAssignment or None - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType[Optional["_models.PolicyAssignment"]] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) - api_version = kwargs.pop('api_version', "2019-06-01") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2019-06-01")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[Optional[_models.PolicyAssignment]] - request = build_policy_assignments_delete_by_id_request( policy_assignment_id=policy_assignment_id, api_version=api_version, - template_url=self.delete_by_id.metadata['url'], + template_url=self.delete_by_id.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200, 204]: @@ -620,23 +752,24 @@ async def delete_by_id( deserialized = None if response.status_code == 200: - deserialized = self._deserialize('PolicyAssignment', pipeline_response) + deserialized = self._deserialize("PolicyAssignment", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - delete_by_id.metadata = {'url': "/{policyAssignmentId}"} # type: ignore + delete_by_id.metadata = {"url": "/{policyAssignmentId}"} # type: ignore - - @distributed_trace_async + @overload async def create_by_id( self, policy_assignment_id: str, - parameters: "_models.PolicyAssignment", + parameters: _models.PolicyAssignment, + *, + content_type: str = "application/json", **kwargs: Any - ) -> "_models.PolicyAssignment": + ) -> _models.PolicyAssignment: """Creates or updates a policy assignment. This operation creates or updates the policy assignment with the given ID. Policy assignments @@ -651,41 +784,121 @@ async def create_by_id( '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{resourceProviderNamespace}/[{parentResourcePath}/]{resourceType}/{resourceName}'. :param policy_assignment_id: The ID of the policy assignment to create. Use the format - '{scope}/providers/Microsoft.Authorization/policyAssignments/{policyAssignmentName}'. + '{scope}/providers/Microsoft.Authorization/policyAssignments/{policyAssignmentName}'. Required. :type policy_assignment_id: str - :param parameters: Parameters for policy assignment. + :param parameters: Parameters for policy assignment. Required. :type parameters: ~azure.mgmt.resource.policy.v2019_06_01.models.PolicyAssignment + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: PolicyAssignment or the result of cls(response) + :rtype: ~azure.mgmt.resource.policy.v2019_06_01.models.PolicyAssignment + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + async def create_by_id( + self, policy_assignment_id: str, parameters: IO, *, content_type: str = "application/json", **kwargs: Any + ) -> _models.PolicyAssignment: + """Creates or updates a policy assignment. + + This operation creates or updates the policy assignment with the given ID. Policy assignments + made on a scope apply to all resources contained in that scope. For example, when you assign a + policy to a resource group that policy applies to all resources in the group. Policy assignment + IDs have this format: + '{scope}/providers/Microsoft.Authorization/policyAssignments/{policyAssignmentName}'. Valid + scopes are: management group (format: + '/providers/Microsoft.Management/managementGroups/{managementGroup}'), subscription (format: + '/subscriptions/{subscriptionId}'), resource group (format: + '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}', or resource (format: + '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{resourceProviderNamespace}/[{parentResourcePath}/]{resourceType}/{resourceName}'. + + :param policy_assignment_id: The ID of the policy assignment to create. Use the format + '{scope}/providers/Microsoft.Authorization/policyAssignments/{policyAssignmentName}'. Required. + :type policy_assignment_id: str + :param parameters: Parameters for policy assignment. Required. + :type parameters: IO + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: PolicyAssignment, or the result of cls(response) + :return: PolicyAssignment or the result of cls(response) :rtype: ~azure.mgmt.resource.policy.v2019_06_01.models.PolicyAssignment - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace_async + async def create_by_id( + self, policy_assignment_id: str, parameters: Union[_models.PolicyAssignment, IO], **kwargs: Any + ) -> _models.PolicyAssignment: + """Creates or updates a policy assignment. + + This operation creates or updates the policy assignment with the given ID. Policy assignments + made on a scope apply to all resources contained in that scope. For example, when you assign a + policy to a resource group that policy applies to all resources in the group. Policy assignment + IDs have this format: + '{scope}/providers/Microsoft.Authorization/policyAssignments/{policyAssignmentName}'. Valid + scopes are: management group (format: + '/providers/Microsoft.Management/managementGroups/{managementGroup}'), subscription (format: + '/subscriptions/{subscriptionId}'), resource group (format: + '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}', or resource (format: + '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{resourceProviderNamespace}/[{parentResourcePath}/]{resourceType}/{resourceName}'. + + :param policy_assignment_id: The ID of the policy assignment to create. Use the format + '{scope}/providers/Microsoft.Authorization/policyAssignments/{policyAssignmentName}'. Required. + :type policy_assignment_id: str + :param parameters: Parameters for policy assignment. Is either a model type or a IO type. + Required. + :type parameters: ~azure.mgmt.resource.policy.v2019_06_01.models.PolicyAssignment or IO + :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. + Default value is None. + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: PolicyAssignment or the result of cls(response) + :rtype: ~azure.mgmt.resource.policy.v2019_06_01.models.PolicyAssignment + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.PolicyAssignment"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', "2019-06-01") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + api_version = kwargs.pop("api_version", _params.pop("api-version", "2019-06-01")) # type: str + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.PolicyAssignment] - _json = self._serialize.body(parameters, 'PolicyAssignment') + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(parameters, (IO, bytes)): + _content = parameters + else: + _json = self._serialize.body(parameters, "PolicyAssignment") request = build_policy_assignments_create_by_id_request( policy_assignment_id=policy_assignment_id, api_version=api_version, content_type=content_type, json=_json, - template_url=self.create_by_id.metadata['url'], + content=_content, + template_url=self.create_by_id.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [201]: @@ -693,22 +906,17 @@ async def create_by_id( error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - deserialized = self._deserialize('PolicyAssignment', pipeline_response) + deserialized = self._deserialize("PolicyAssignment", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - create_by_id.metadata = {'url': "/{policyAssignmentId}"} # type: ignore - + create_by_id.metadata = {"url": "/{policyAssignmentId}"} # type: ignore @distributed_trace_async - async def get_by_id( - self, - policy_assignment_id: str, - **kwargs: Any - ) -> "_models.PolicyAssignment": + async def get_by_id(self, policy_assignment_id: str, **kwargs: Any) -> _models.PolicyAssignment: """Retrieves the policy assignment with the given ID. The operation retrieves the policy assignment with the given ID. Policy assignment IDs have @@ -721,35 +929,41 @@ async def get_by_id( '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{resourceProviderNamespace}/[{parentResourcePath}/]{resourceType}/{resourceName}'. :param policy_assignment_id: The ID of the policy assignment to get. Use the format - '{scope}/providers/Microsoft.Authorization/policyAssignments/{policyAssignmentName}'. + '{scope}/providers/Microsoft.Authorization/policyAssignments/{policyAssignmentName}'. Required. :type policy_assignment_id: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: PolicyAssignment, or the result of cls(response) + :return: PolicyAssignment or the result of cls(response) :rtype: ~azure.mgmt.resource.policy.v2019_06_01.models.PolicyAssignment - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.PolicyAssignment"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) - api_version = kwargs.pop('api_version', "2019-06-01") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2019-06-01")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[_models.PolicyAssignment] - request = build_policy_assignments_get_by_id_request( policy_assignment_id=policy_assignment_id, api_version=api_version, - template_url=self.get_by_id.metadata['url'], + template_url=self.get_by_id.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200]: @@ -757,68 +971,128 @@ async def get_by_id( error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - deserialized = self._deserialize('PolicyAssignment', pipeline_response) + deserialized = self._deserialize("PolicyAssignment", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - get_by_id.metadata = {'url': "/{policyAssignmentId}"} # type: ignore + get_by_id.metadata = {"url": "/{policyAssignmentId}"} # type: ignore -class PolicyDefinitionsOperations: - """PolicyDefinitionsOperations async operations. - You should not instantiate this class directly. Instead, you should create a Client instance that - instantiates it for you and attaches it as an attribute. +class PolicyDefinitionsOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. - :ivar models: Alias to model classes used in this operation group. - :type models: ~azure.mgmt.resource.policy.v2019_06_01.models - :param client: Client for service requests. - :param config: Configuration of service client. - :param serializer: An object model serializer. - :param deserializer: An object model deserializer. + Instead, you should access the following operations through + :class:`~azure.mgmt.resource.policy.v2019_06_01.aio.PolicyClient`'s + :attr:`policy_definitions` attribute. """ models = _models - def __init__(self, client, config, serializer, deserializer) -> None: - self._client = client - self._serialize = serializer - self._deserialize = deserializer - self._config = config + def __init__(self, *args, **kwargs) -> None: + input_args = list(args) + self._client = input_args.pop(0) if input_args else kwargs.pop("client") + self._config = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") - @distributed_trace_async + @overload async def create_or_update( self, policy_definition_name: str, - parameters: "_models.PolicyDefinition", + parameters: _models.PolicyDefinition, + *, + content_type: str = "application/json", **kwargs: Any - ) -> "_models.PolicyDefinition": + ) -> _models.PolicyDefinition: """Creates or updates a policy definition in a subscription. This operation creates or updates a policy definition in the given subscription with the given name. - :param policy_definition_name: The name of the policy definition to create. + :param policy_definition_name: The name of the policy definition to create. Required. :type policy_definition_name: str - :param parameters: The policy definition properties. + :param parameters: The policy definition properties. Required. :type parameters: ~azure.mgmt.resource.policy.v2019_06_01.models.PolicyDefinition + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: PolicyDefinition or the result of cls(response) + :rtype: ~azure.mgmt.resource.policy.v2019_06_01.models.PolicyDefinition + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + async def create_or_update( + self, policy_definition_name: str, parameters: IO, *, content_type: str = "application/json", **kwargs: Any + ) -> _models.PolicyDefinition: + """Creates or updates a policy definition in a subscription. + + This operation creates or updates a policy definition in the given subscription with the given + name. + + :param policy_definition_name: The name of the policy definition to create. Required. + :type policy_definition_name: str + :param parameters: The policy definition properties. Required. + :type parameters: IO + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: PolicyDefinition or the result of cls(response) + :rtype: ~azure.mgmt.resource.policy.v2019_06_01.models.PolicyDefinition + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace_async + async def create_or_update( + self, policy_definition_name: str, parameters: Union[_models.PolicyDefinition, IO], **kwargs: Any + ) -> _models.PolicyDefinition: + """Creates or updates a policy definition in a subscription. + + This operation creates or updates a policy definition in the given subscription with the given + name. + + :param policy_definition_name: The name of the policy definition to create. Required. + :type policy_definition_name: str + :param parameters: The policy definition properties. Is either a model type or a IO type. + Required. + :type parameters: ~azure.mgmt.resource.policy.v2019_06_01.models.PolicyDefinition or IO + :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. + Default value is None. + :paramtype content_type: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: PolicyDefinition, or the result of cls(response) + :return: PolicyDefinition or the result of cls(response) :rtype: ~azure.mgmt.resource.policy.v2019_06_01.models.PolicyDefinition - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.PolicyDefinition"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', "2019-06-01") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + api_version = kwargs.pop("api_version", _params.pop("api-version", "2019-06-01")) # type: str + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.PolicyDefinition] - _json = self._serialize.body(parameters, 'PolicyDefinition') + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(parameters, (IO, bytes)): + _content = parameters + else: + _json = self._serialize.body(parameters, "PolicyDefinition") request = build_policy_definitions_create_or_update_request( policy_definition_name=policy_definition_name, @@ -826,72 +1100,77 @@ async def create_or_update( api_version=api_version, content_type=content_type, json=_json, - template_url=self.create_or_update.metadata['url'], + content=_content, + template_url=self.create_or_update.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [201]: map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) - deserialized = self._deserialize('PolicyDefinition', pipeline_response) + deserialized = self._deserialize("PolicyDefinition", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - create_or_update.metadata = {'url': "/subscriptions/{subscriptionId}/providers/Microsoft.Authorization/policyDefinitions/{policyDefinitionName}"} # type: ignore - + create_or_update.metadata = {"url": "/subscriptions/{subscriptionId}/providers/Microsoft.Authorization/policyDefinitions/{policyDefinitionName}"} # type: ignore @distributed_trace_async async def delete( # pylint: disable=inconsistent-return-statements - self, - policy_definition_name: str, - **kwargs: Any + self, policy_definition_name: str, **kwargs: Any ) -> None: """Deletes a policy definition in a subscription. This operation deletes the policy definition in the given subscription with the given name. - :param policy_definition_name: The name of the policy definition to delete. + :param policy_definition_name: The name of the policy definition to delete. Required. :type policy_definition_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: None, or the result of cls(response) + :return: None or the result of cls(response) :rtype: None - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType[None] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + 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', "2019-06-01") # type: str + api_version = kwargs.pop("api_version", _params.pop("api-version", "2019-06-01")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[None] - request = build_policy_definitions_delete_request( policy_definition_name=policy_definition_name, subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.delete.metadata['url'], + template_url=self.delete.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200, 204]: @@ -901,154 +1180,231 @@ async def delete( # pylint: disable=inconsistent-return-statements if cls: return cls(pipeline_response, None, {}) - delete.metadata = {'url': "/subscriptions/{subscriptionId}/providers/Microsoft.Authorization/policyDefinitions/{policyDefinitionName}"} # type: ignore - + delete.metadata = {"url": "/subscriptions/{subscriptionId}/providers/Microsoft.Authorization/policyDefinitions/{policyDefinitionName}"} # type: ignore @distributed_trace_async - async def get( - self, - policy_definition_name: str, - **kwargs: Any - ) -> "_models.PolicyDefinition": + async def get(self, policy_definition_name: str, **kwargs: Any) -> _models.PolicyDefinition: """Retrieves a policy definition in a subscription. This operation retrieves the policy definition in the given subscription with the given name. - :param policy_definition_name: The name of the policy definition to get. + :param policy_definition_name: The name of the policy definition to get. Required. :type policy_definition_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: PolicyDefinition, or the result of cls(response) + :return: PolicyDefinition or the result of cls(response) :rtype: ~azure.mgmt.resource.policy.v2019_06_01.models.PolicyDefinition - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.PolicyDefinition"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + 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', "2019-06-01") # type: str + api_version = kwargs.pop("api_version", _params.pop("api-version", "2019-06-01")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[_models.PolicyDefinition] - request = build_policy_definitions_get_request( policy_definition_name=policy_definition_name, subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.get.metadata['url'], + template_url=self.get.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) - deserialized = self._deserialize('PolicyDefinition', pipeline_response) + deserialized = self._deserialize("PolicyDefinition", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - get.metadata = {'url': "/subscriptions/{subscriptionId}/providers/Microsoft.Authorization/policyDefinitions/{policyDefinitionName}"} # type: ignore - + get.metadata = {"url": "/subscriptions/{subscriptionId}/providers/Microsoft.Authorization/policyDefinitions/{policyDefinitionName}"} # type: ignore @distributed_trace_async - async def get_built_in( - self, - policy_definition_name: str, - **kwargs: Any - ) -> "_models.PolicyDefinition": + async def get_built_in(self, policy_definition_name: str, **kwargs: Any) -> _models.PolicyDefinition: """Retrieves a built-in policy definition. This operation retrieves the built-in policy definition with the given name. - :param policy_definition_name: The name of the built-in policy definition to get. + :param policy_definition_name: The name of the built-in policy definition to get. Required. :type policy_definition_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: PolicyDefinition, or the result of cls(response) + :return: PolicyDefinition or the result of cls(response) :rtype: ~azure.mgmt.resource.policy.v2019_06_01.models.PolicyDefinition - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.PolicyDefinition"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + 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', "2019-06-01") # type: str + api_version = kwargs.pop("api_version", _params.pop("api-version", "2019-06-01")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[_models.PolicyDefinition] - request = build_policy_definitions_get_built_in_request( policy_definition_name=policy_definition_name, api_version=api_version, - template_url=self.get_built_in.metadata['url'], + template_url=self.get_built_in.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) - deserialized = self._deserialize('PolicyDefinition', pipeline_response) + deserialized = self._deserialize("PolicyDefinition", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - get_built_in.metadata = {'url': "/providers/Microsoft.Authorization/policyDefinitions/{policyDefinitionName}"} # type: ignore + get_built_in.metadata = {"url": "/providers/Microsoft.Authorization/policyDefinitions/{policyDefinitionName}"} # type: ignore + @overload + async def create_or_update_at_management_group( + self, + policy_definition_name: str, + management_group_id: str, + parameters: _models.PolicyDefinition, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.PolicyDefinition: + """Creates or updates a policy definition in a management group. + + This operation creates or updates a policy definition in the given management group with the + given name. + + :param policy_definition_name: The name of the policy definition to create. Required. + :type policy_definition_name: str + :param management_group_id: The ID of the management group. Required. + :type management_group_id: str + :param parameters: The policy definition properties. Required. + :type parameters: ~azure.mgmt.resource.policy.v2019_06_01.models.PolicyDefinition + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: PolicyDefinition or the result of cls(response) + :rtype: ~azure.mgmt.resource.policy.v2019_06_01.models.PolicyDefinition + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + async def create_or_update_at_management_group( + self, + policy_definition_name: str, + management_group_id: str, + parameters: IO, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.PolicyDefinition: + """Creates or updates a policy definition in a management group. + + This operation creates or updates a policy definition in the given management group with the + given name. + + :param policy_definition_name: The name of the policy definition to create. Required. + :type policy_definition_name: str + :param management_group_id: The ID of the management group. Required. + :type management_group_id: str + :param parameters: The policy definition properties. Required. + :type parameters: IO + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: PolicyDefinition or the result of cls(response) + :rtype: ~azure.mgmt.resource.policy.v2019_06_01.models.PolicyDefinition + :raises ~azure.core.exceptions.HttpResponseError: + """ @distributed_trace_async async def create_or_update_at_management_group( self, policy_definition_name: str, management_group_id: str, - parameters: "_models.PolicyDefinition", + parameters: Union[_models.PolicyDefinition, IO], **kwargs: Any - ) -> "_models.PolicyDefinition": + ) -> _models.PolicyDefinition: """Creates or updates a policy definition in a management group. This operation creates or updates a policy definition in the given management group with the given name. - :param policy_definition_name: The name of the policy definition to create. + :param policy_definition_name: The name of the policy definition to create. Required. :type policy_definition_name: str - :param management_group_id: The ID of the management group. + :param management_group_id: The ID of the management group. Required. :type management_group_id: str - :param parameters: The policy definition properties. - :type parameters: ~azure.mgmt.resource.policy.v2019_06_01.models.PolicyDefinition + :param parameters: The policy definition properties. Is either a model type or a IO type. + Required. + :type parameters: ~azure.mgmt.resource.policy.v2019_06_01.models.PolicyDefinition or IO + :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. + Default value is None. + :paramtype content_type: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: PolicyDefinition, or the result of cls(response) + :return: PolicyDefinition or the result of cls(response) :rtype: ~azure.mgmt.resource.policy.v2019_06_01.models.PolicyDefinition - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.PolicyDefinition"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', "2019-06-01") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + api_version = kwargs.pop("api_version", _params.pop("api-version", "2019-06-01")) # type: str + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.PolicyDefinition] - _json = self._serialize.body(parameters, 'PolicyDefinition') + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(parameters, (IO, bytes)): + _content = parameters + else: + _json = self._serialize.body(parameters, "PolicyDefinition") request = build_policy_definitions_create_or_update_at_management_group_request( policy_definition_name=policy_definition_name, @@ -1056,75 +1412,79 @@ async def create_or_update_at_management_group( api_version=api_version, content_type=content_type, json=_json, - template_url=self.create_or_update_at_management_group.metadata['url'], + content=_content, + template_url=self.create_or_update_at_management_group.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [201]: map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) - deserialized = self._deserialize('PolicyDefinition', pipeline_response) + deserialized = self._deserialize("PolicyDefinition", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - create_or_update_at_management_group.metadata = {'url': "/providers/Microsoft.Management/managementgroups/{managementGroupId}/providers/Microsoft.Authorization/policyDefinitions/{policyDefinitionName}"} # type: ignore - + create_or_update_at_management_group.metadata = {"url": "/providers/Microsoft.Management/managementgroups/{managementGroupId}/providers/Microsoft.Authorization/policyDefinitions/{policyDefinitionName}"} # type: ignore @distributed_trace_async async def delete_at_management_group( # pylint: disable=inconsistent-return-statements - self, - policy_definition_name: str, - management_group_id: str, - **kwargs: Any + self, policy_definition_name: str, management_group_id: str, **kwargs: Any ) -> None: """Deletes a policy definition in a management group. This operation deletes the policy definition in the given management group with the given name. - :param policy_definition_name: The name of the policy definition to delete. + :param policy_definition_name: The name of the policy definition to delete. Required. :type policy_definition_name: str - :param management_group_id: The ID of the management group. + :param management_group_id: The ID of the management group. Required. :type management_group_id: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: None, or the result of cls(response) + :return: None or the result of cls(response) :rtype: None - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType[None] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) - api_version = kwargs.pop('api_version', "2019-06-01") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2019-06-01")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[None] - request = build_policy_definitions_delete_at_management_group_request( policy_definition_name=policy_definition_name, management_group_id=management_group_id, api_version=api_version, - template_url=self.delete_at_management_group.metadata['url'], + template_url=self.delete_at_management_group.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200, 204]: @@ -1134,111 +1494,117 @@ async def delete_at_management_group( # pylint: disable=inconsistent-return-sta if cls: return cls(pipeline_response, None, {}) - delete_at_management_group.metadata = {'url': "/providers/Microsoft.Management/managementgroups/{managementGroupId}/providers/Microsoft.Authorization/policyDefinitions/{policyDefinitionName}"} # type: ignore - + delete_at_management_group.metadata = {"url": "/providers/Microsoft.Management/managementgroups/{managementGroupId}/providers/Microsoft.Authorization/policyDefinitions/{policyDefinitionName}"} # type: ignore @distributed_trace_async async def get_at_management_group( - self, - policy_definition_name: str, - management_group_id: str, - **kwargs: Any - ) -> "_models.PolicyDefinition": + self, policy_definition_name: str, management_group_id: str, **kwargs: Any + ) -> _models.PolicyDefinition: """Retrieve a policy definition in a management group. This operation retrieves the policy definition in the given management group with the given name. - :param policy_definition_name: The name of the policy definition to get. + :param policy_definition_name: The name of the policy definition to get. Required. :type policy_definition_name: str - :param management_group_id: The ID of the management group. + :param management_group_id: The ID of the management group. Required. :type management_group_id: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: PolicyDefinition, or the result of cls(response) + :return: PolicyDefinition or the result of cls(response) :rtype: ~azure.mgmt.resource.policy.v2019_06_01.models.PolicyDefinition - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.PolicyDefinition"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + 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', "2019-06-01") # type: str + api_version = kwargs.pop("api_version", _params.pop("api-version", "2019-06-01")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[_models.PolicyDefinition] - request = build_policy_definitions_get_at_management_group_request( policy_definition_name=policy_definition_name, management_group_id=management_group_id, api_version=api_version, - template_url=self.get_at_management_group.metadata['url'], + template_url=self.get_at_management_group.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) - deserialized = self._deserialize('PolicyDefinition', pipeline_response) + deserialized = self._deserialize("PolicyDefinition", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - get_at_management_group.metadata = {'url': "/providers/Microsoft.Management/managementgroups/{managementGroupId}/providers/Microsoft.Authorization/policyDefinitions/{policyDefinitionName}"} # type: ignore - + get_at_management_group.metadata = {"url": "/providers/Microsoft.Management/managementgroups/{managementGroupId}/providers/Microsoft.Authorization/policyDefinitions/{policyDefinitionName}"} # type: ignore @distributed_trace - def list( - self, - **kwargs: Any - ) -> AsyncIterable["_models.PolicyDefinitionListResult"]: + def list(self, **kwargs: Any) -> AsyncIterable["_models.PolicyDefinition"]: """Retrieves policy definitions in a subscription. This operation retrieves a list of all the policy definitions in a given subscription. :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either PolicyDefinitionListResult or the result of - cls(response) + :return: An iterator like instance of either PolicyDefinition or the result of cls(response) :rtype: - ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.resource.policy.v2019_06_01.models.PolicyDefinitionListResult] - :raises: ~azure.core.exceptions.HttpResponseError + ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.resource.policy.v2019_06_01.models.PolicyDefinition] + :raises ~azure.core.exceptions.HttpResponseError: """ - api_version = kwargs.pop('api_version', "2019-06-01") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2019-06-01")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[_models.PolicyDefinitionListResult] - cls = kwargs.pop('cls', None) # type: ClsType["_models.PolicyDefinitionListResult"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) + def prepare_request(next_link=None): if not next_link: - + request = build_policy_definitions_list_request( subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.list.metadata['url'], + template_url=self.list.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore else: - - request = build_policy_definitions_list_request( - subscription_id=self._config.subscription_id, - template_url=next_link, - ) + # make call to next link with the client's api-version + _parsed_next_link = urlparse(next_link) + _next_request_params = case_insensitive_dict(parse_qs(_parsed_next_link.query)) + _next_request_params["api-version"] = self._config.api_version + request = HttpRequest("GET", urljoin(next_link, _parsed_next_link.path), params=_next_request_params) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore request.method = "GET" return request @@ -1252,10 +1618,8 @@ async def extract_data(pipeline_response): async def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) response = pipeline_response.http_response @@ -1265,52 +1629,56 @@ async def get_next(next_link=None): return pipeline_response + return AsyncItemPaged(get_next, extract_data) - return AsyncItemPaged( - get_next, extract_data - ) - list.metadata = {'url': "/subscriptions/{subscriptionId}/providers/Microsoft.Authorization/policyDefinitions"} # type: ignore + list.metadata = {"url": "/subscriptions/{subscriptionId}/providers/Microsoft.Authorization/policyDefinitions"} # type: ignore @distributed_trace - def list_built_in( - self, - **kwargs: Any - ) -> AsyncIterable["_models.PolicyDefinitionListResult"]: + def list_built_in(self, **kwargs: Any) -> AsyncIterable["_models.PolicyDefinition"]: """Retrieve built-in policy definitions. This operation retrieves a list of all the built-in policy definitions. :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either PolicyDefinitionListResult or the result of - cls(response) + :return: An iterator like instance of either PolicyDefinition or the result of cls(response) :rtype: - ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.resource.policy.v2019_06_01.models.PolicyDefinitionListResult] - :raises: ~azure.core.exceptions.HttpResponseError + ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.resource.policy.v2019_06_01.models.PolicyDefinition] + :raises ~azure.core.exceptions.HttpResponseError: """ - api_version = kwargs.pop('api_version', "2019-06-01") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2019-06-01")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[_models.PolicyDefinitionListResult] - cls = kwargs.pop('cls', None) # type: ClsType["_models.PolicyDefinitionListResult"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) + def prepare_request(next_link=None): if not next_link: - + request = build_policy_definitions_list_built_in_request( api_version=api_version, - template_url=self.list_built_in.metadata['url'], + template_url=self.list_built_in.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore else: - - request = build_policy_definitions_list_built_in_request( - template_url=next_link, - ) + # make call to next link with the client's api-version + _parsed_next_link = urlparse(next_link) + _next_request_params = case_insensitive_dict(parse_qs(_parsed_next_link.query)) + _next_request_params["api-version"] = self._config.api_version + request = HttpRequest("GET", urljoin(next_link, _parsed_next_link.path), params=_next_request_params) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore request.method = "GET" return request @@ -1324,10 +1692,8 @@ async def extract_data(pipeline_response): async def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) response = pipeline_response.http_response @@ -1337,57 +1703,61 @@ async def get_next(next_link=None): return pipeline_response + return AsyncItemPaged(get_next, extract_data) - return AsyncItemPaged( - get_next, extract_data - ) - list_built_in.metadata = {'url': "/providers/Microsoft.Authorization/policyDefinitions"} # type: ignore + list_built_in.metadata = {"url": "/providers/Microsoft.Authorization/policyDefinitions"} # type: ignore @distributed_trace def list_by_management_group( - self, - management_group_id: str, - **kwargs: Any - ) -> AsyncIterable["_models.PolicyDefinitionListResult"]: + self, management_group_id: str, **kwargs: Any + ) -> AsyncIterable["_models.PolicyDefinition"]: """Retrieve policy definitions in a management group. This operation retrieves a list of all the policy definitions in a given management group. - :param management_group_id: The ID of the management group. + :param management_group_id: The ID of the management group. Required. :type management_group_id: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either PolicyDefinitionListResult or the result of - cls(response) + :return: An iterator like instance of either PolicyDefinition or the result of cls(response) :rtype: - ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.resource.policy.v2019_06_01.models.PolicyDefinitionListResult] - :raises: ~azure.core.exceptions.HttpResponseError + ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.resource.policy.v2019_06_01.models.PolicyDefinition] + :raises ~azure.core.exceptions.HttpResponseError: """ - api_version = kwargs.pop('api_version', "2019-06-01") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2019-06-01")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[_models.PolicyDefinitionListResult] - cls = kwargs.pop('cls', None) # type: ClsType["_models.PolicyDefinitionListResult"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) + def prepare_request(next_link=None): if not next_link: - + request = build_policy_definitions_list_by_management_group_request( management_group_id=management_group_id, api_version=api_version, - template_url=self.list_by_management_group.metadata['url'], + template_url=self.list_by_management_group.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore else: - - request = build_policy_definitions_list_by_management_group_request( - management_group_id=management_group_id, - template_url=next_link, - ) + # make call to next link with the client's api-version + _parsed_next_link = urlparse(next_link) + _next_request_params = case_insensitive_dict(parse_qs(_parsed_next_link.query)) + _next_request_params["api-version"] = self._config.api_version + request = HttpRequest("GET", urljoin(next_link, _parsed_next_link.path), params=_next_request_params) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore request.method = "GET" return request @@ -1401,10 +1771,8 @@ async def extract_data(pipeline_response): async def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) response = pipeline_response.http_response @@ -1414,64 +1782,123 @@ async def get_next(next_link=None): return pipeline_response + return AsyncItemPaged(get_next, extract_data) + + list_by_management_group.metadata = {"url": "/providers/Microsoft.Management/managementgroups/{managementGroupId}/providers/Microsoft.Authorization/policyDefinitions"} # type: ignore - return AsyncItemPaged( - get_next, extract_data - ) - list_by_management_group.metadata = {'url': "/providers/Microsoft.Management/managementgroups/{managementGroupId}/providers/Microsoft.Authorization/policyDefinitions"} # type: ignore -class PolicySetDefinitionsOperations: - """PolicySetDefinitionsOperations async operations. - You should not instantiate this class directly. Instead, you should create a Client instance that - instantiates it for you and attaches it as an attribute. +class PolicySetDefinitionsOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. - :ivar models: Alias to model classes used in this operation group. - :type models: ~azure.mgmt.resource.policy.v2019_06_01.models - :param client: Client for service requests. - :param config: Configuration of service client. - :param serializer: An object model serializer. - :param deserializer: An object model deserializer. + Instead, you should access the following operations through + :class:`~azure.mgmt.resource.policy.v2019_06_01.aio.PolicyClient`'s + :attr:`policy_set_definitions` attribute. """ models = _models - def __init__(self, client, config, serializer, deserializer) -> None: - self._client = client - self._serialize = serializer - self._deserialize = deserializer - self._config = config + def __init__(self, *args, **kwargs) -> None: + input_args = list(args) + self._client = input_args.pop(0) if input_args else kwargs.pop("client") + self._config = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") - @distributed_trace_async + @overload async def create_or_update( self, policy_set_definition_name: str, - parameters: "_models.PolicySetDefinition", + parameters: _models.PolicySetDefinition, + *, + content_type: str = "application/json", **kwargs: Any - ) -> "_models.PolicySetDefinition": + ) -> _models.PolicySetDefinition: """Creates or updates a policy set definition. This operation creates or updates a policy set definition in the given subscription with the given name. - :param policy_set_definition_name: The name of the policy set definition to create. + :param policy_set_definition_name: The name of the policy set definition to create. Required. :type policy_set_definition_name: str - :param parameters: The policy set definition properties. + :param parameters: The policy set definition properties. Required. :type parameters: ~azure.mgmt.resource.policy.v2019_06_01.models.PolicySetDefinition + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: PolicySetDefinition or the result of cls(response) + :rtype: ~azure.mgmt.resource.policy.v2019_06_01.models.PolicySetDefinition + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + async def create_or_update( + self, policy_set_definition_name: str, parameters: IO, *, content_type: str = "application/json", **kwargs: Any + ) -> _models.PolicySetDefinition: + """Creates or updates a policy set definition. + + This operation creates or updates a policy set definition in the given subscription with the + given name. + + :param policy_set_definition_name: The name of the policy set definition to create. Required. + :type policy_set_definition_name: str + :param parameters: The policy set definition properties. Required. + :type parameters: IO + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: PolicySetDefinition, or the result of cls(response) + :return: PolicySetDefinition or the result of cls(response) :rtype: ~azure.mgmt.resource.policy.v2019_06_01.models.PolicySetDefinition - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace_async + async def create_or_update( + self, policy_set_definition_name: str, parameters: Union[_models.PolicySetDefinition, IO], **kwargs: Any + ) -> _models.PolicySetDefinition: + """Creates or updates a policy set definition. + + This operation creates or updates a policy set definition in the given subscription with the + given name. + + :param policy_set_definition_name: The name of the policy set definition to create. Required. + :type policy_set_definition_name: str + :param parameters: The policy set definition properties. Is either a model type or a IO type. + Required. + :type parameters: ~azure.mgmt.resource.policy.v2019_06_01.models.PolicySetDefinition or IO + :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. + Default value is None. + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: PolicySetDefinition or the result of cls(response) + :rtype: ~azure.mgmt.resource.policy.v2019_06_01.models.PolicySetDefinition + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.PolicySetDefinition"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', "2019-06-01") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + api_version = kwargs.pop("api_version", _params.pop("api-version", "2019-06-01")) # type: str + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.PolicySetDefinition] - _json = self._serialize.body(parameters, 'PolicySetDefinition') + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(parameters, (IO, bytes)): + _content = parameters + else: + _json = self._serialize.body(parameters, "PolicySetDefinition") request = build_policy_set_definitions_create_or_update_request( policy_set_definition_name=policy_set_definition_name, @@ -1479,16 +1906,18 @@ async def create_or_update( api_version=api_version, content_type=content_type, json=_json, - template_url=self.create_or_update.metadata['url'], + content=_content, + template_url=self.create_or_update.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200, 201]: @@ -1497,59 +1926,62 @@ async def create_or_update( raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) if response.status_code == 200: - deserialized = self._deserialize('PolicySetDefinition', pipeline_response) + deserialized = self._deserialize("PolicySetDefinition", pipeline_response) if response.status_code == 201: - deserialized = self._deserialize('PolicySetDefinition', pipeline_response) + deserialized = self._deserialize("PolicySetDefinition", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - create_or_update.metadata = {'url': "/subscriptions/{subscriptionId}/providers/Microsoft.Authorization/policySetDefinitions/{policySetDefinitionName}"} # type: ignore - + create_or_update.metadata = {"url": "/subscriptions/{subscriptionId}/providers/Microsoft.Authorization/policySetDefinitions/{policySetDefinitionName}"} # type: ignore @distributed_trace_async async def delete( # pylint: disable=inconsistent-return-statements - self, - policy_set_definition_name: str, - **kwargs: Any + self, policy_set_definition_name: str, **kwargs: Any ) -> None: """Deletes a policy set definition. This operation deletes the policy set definition in the given subscription with the given name. - :param policy_set_definition_name: The name of the policy set definition to delete. + :param policy_set_definition_name: The name of the policy set definition to delete. Required. :type policy_set_definition_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: None, or the result of cls(response) + :return: None or the result of cls(response) :rtype: None - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType[None] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + 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', "2019-06-01") # type: str + api_version = kwargs.pop("api_version", _params.pop("api-version", "2019-06-01")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[None] - request = build_policy_set_definitions_delete_request( policy_set_definition_name=policy_set_definition_name, subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.delete.metadata['url'], + template_url=self.delete.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200, 204]: @@ -1560,50 +1992,51 @@ async def delete( # pylint: disable=inconsistent-return-statements if cls: return cls(pipeline_response, None, {}) - delete.metadata = {'url': "/subscriptions/{subscriptionId}/providers/Microsoft.Authorization/policySetDefinitions/{policySetDefinitionName}"} # type: ignore - + delete.metadata = {"url": "/subscriptions/{subscriptionId}/providers/Microsoft.Authorization/policySetDefinitions/{policySetDefinitionName}"} # type: ignore @distributed_trace_async - async def get( - self, - policy_set_definition_name: str, - **kwargs: Any - ) -> "_models.PolicySetDefinition": + async def get(self, policy_set_definition_name: str, **kwargs: Any) -> _models.PolicySetDefinition: """Retrieves a policy set definition. This operation retrieves the policy set definition in the given subscription with the given name. - :param policy_set_definition_name: The name of the policy set definition to get. + :param policy_set_definition_name: The name of the policy set definition to get. Required. :type policy_set_definition_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: PolicySetDefinition, or the result of cls(response) + :return: PolicySetDefinition or the result of cls(response) :rtype: ~azure.mgmt.resource.policy.v2019_06_01.models.PolicySetDefinition - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.PolicySetDefinition"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) - api_version = kwargs.pop('api_version', "2019-06-01") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2019-06-01")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[_models.PolicySetDefinition] - request = build_policy_set_definitions_get_request( policy_set_definition_name=policy_set_definition_name, subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.get.metadata['url'], + template_url=self.get.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200]: @@ -1611,55 +2044,56 @@ async def get( error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - deserialized = self._deserialize('PolicySetDefinition', pipeline_response) + deserialized = self._deserialize("PolicySetDefinition", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - get.metadata = {'url': "/subscriptions/{subscriptionId}/providers/Microsoft.Authorization/policySetDefinitions/{policySetDefinitionName}"} # type: ignore - + get.metadata = {"url": "/subscriptions/{subscriptionId}/providers/Microsoft.Authorization/policySetDefinitions/{policySetDefinitionName}"} # type: ignore @distributed_trace_async - async def get_built_in( - self, - policy_set_definition_name: str, - **kwargs: Any - ) -> "_models.PolicySetDefinition": + async def get_built_in(self, policy_set_definition_name: str, **kwargs: Any) -> _models.PolicySetDefinition: """Retrieves a built in policy set definition. This operation retrieves the built-in policy set definition with the given name. - :param policy_set_definition_name: The name of the policy set definition to get. + :param policy_set_definition_name: The name of the policy set definition to get. Required. :type policy_set_definition_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: PolicySetDefinition, or the result of cls(response) + :return: PolicySetDefinition or the result of cls(response) :rtype: ~azure.mgmt.resource.policy.v2019_06_01.models.PolicySetDefinition - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.PolicySetDefinition"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + 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', "2019-06-01") # type: str + api_version = kwargs.pop("api_version", _params.pop("api-version", "2019-06-01")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[_models.PolicySetDefinition] - request = build_policy_set_definitions_get_built_in_request( policy_set_definition_name=policy_set_definition_name, api_version=api_version, - template_url=self.get_built_in.metadata['url'], + template_url=self.get_built_in.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200]: @@ -1667,58 +2101,62 @@ async def get_built_in( error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - deserialized = self._deserialize('PolicySetDefinition', pipeline_response) + deserialized = self._deserialize("PolicySetDefinition", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - get_built_in.metadata = {'url': "/providers/Microsoft.Authorization/policySetDefinitions/{policySetDefinitionName}"} # type: ignore - + get_built_in.metadata = {"url": "/providers/Microsoft.Authorization/policySetDefinitions/{policySetDefinitionName}"} # type: ignore @distributed_trace - def list( - self, - **kwargs: Any - ) -> AsyncIterable["_models.PolicySetDefinitionListResult"]: + def list(self, **kwargs: Any) -> AsyncIterable["_models.PolicySetDefinition"]: """Retrieves the policy set definitions for a subscription. This operation retrieves a list of all the policy set definitions in the given subscription. :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either PolicySetDefinitionListResult or the result of - cls(response) + :return: An iterator like instance of either PolicySetDefinition or the result of cls(response) :rtype: - ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.resource.policy.v2019_06_01.models.PolicySetDefinitionListResult] - :raises: ~azure.core.exceptions.HttpResponseError + ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.resource.policy.v2019_06_01.models.PolicySetDefinition] + :raises ~azure.core.exceptions.HttpResponseError: """ - api_version = kwargs.pop('api_version', "2019-06-01") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2019-06-01")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[_models.PolicySetDefinitionListResult] - cls = kwargs.pop('cls', None) # type: ClsType["_models.PolicySetDefinitionListResult"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) + def prepare_request(next_link=None): if not next_link: - + request = build_policy_set_definitions_list_request( subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.list.metadata['url'], + template_url=self.list.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore else: - - request = build_policy_set_definitions_list_request( - subscription_id=self._config.subscription_id, - template_url=next_link, - ) + # make call to next link with the client's api-version + _parsed_next_link = urlparse(next_link) + _next_request_params = case_insensitive_dict(parse_qs(_parsed_next_link.query)) + _next_request_params["api-version"] = self._config.api_version + request = HttpRequest("GET", urljoin(next_link, _parsed_next_link.path), params=_next_request_params) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore request.method = "GET" return request @@ -1732,10 +2170,8 @@ async def extract_data(pipeline_response): async def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) response = pipeline_response.http_response @@ -1746,52 +2182,56 @@ async def get_next(next_link=None): return pipeline_response + return AsyncItemPaged(get_next, extract_data) - return AsyncItemPaged( - get_next, extract_data - ) - list.metadata = {'url': "/subscriptions/{subscriptionId}/providers/Microsoft.Authorization/policySetDefinitions"} # type: ignore + list.metadata = {"url": "/subscriptions/{subscriptionId}/providers/Microsoft.Authorization/policySetDefinitions"} # type: ignore @distributed_trace - def list_built_in( - self, - **kwargs: Any - ) -> AsyncIterable["_models.PolicySetDefinitionListResult"]: + def list_built_in(self, **kwargs: Any) -> AsyncIterable["_models.PolicySetDefinition"]: """Retrieves built-in policy set definitions. This operation retrieves a list of all the built-in policy set definitions. :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either PolicySetDefinitionListResult or the result of - cls(response) + :return: An iterator like instance of either PolicySetDefinition or the result of cls(response) :rtype: - ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.resource.policy.v2019_06_01.models.PolicySetDefinitionListResult] - :raises: ~azure.core.exceptions.HttpResponseError + ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.resource.policy.v2019_06_01.models.PolicySetDefinition] + :raises ~azure.core.exceptions.HttpResponseError: """ - api_version = kwargs.pop('api_version', "2019-06-01") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2019-06-01")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[_models.PolicySetDefinitionListResult] - cls = kwargs.pop('cls', None) # type: ClsType["_models.PolicySetDefinitionListResult"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) + def prepare_request(next_link=None): if not next_link: - + request = build_policy_set_definitions_list_built_in_request( api_version=api_version, - template_url=self.list_built_in.metadata['url'], + template_url=self.list_built_in.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore else: - - request = build_policy_set_definitions_list_built_in_request( - template_url=next_link, - ) + # make call to next link with the client's api-version + _parsed_next_link = urlparse(next_link) + _next_request_params = case_insensitive_dict(parse_qs(_parsed_next_link.query)) + _next_request_params["api-version"] = self._config.api_version + request = HttpRequest("GET", urljoin(next_link, _parsed_next_link.path), params=_next_request_params) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore request.method = "GET" return request @@ -1805,10 +2245,8 @@ async def extract_data(pipeline_response): async def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) response = pipeline_response.http_response @@ -1819,46 +2257,120 @@ async def get_next(next_link=None): return pipeline_response + return AsyncItemPaged(get_next, extract_data) - return AsyncItemPaged( - get_next, extract_data - ) - list_built_in.metadata = {'url': "/providers/Microsoft.Authorization/policySetDefinitions"} # type: ignore + list_built_in.metadata = {"url": "/providers/Microsoft.Authorization/policySetDefinitions"} # type: ignore - @distributed_trace_async + @overload async def create_or_update_at_management_group( self, policy_set_definition_name: str, management_group_id: str, - parameters: "_models.PolicySetDefinition", + parameters: _models.PolicySetDefinition, + *, + content_type: str = "application/json", **kwargs: Any - ) -> "_models.PolicySetDefinition": + ) -> _models.PolicySetDefinition: """Creates or updates a policy set definition. This operation creates or updates a policy set definition in the given management group with the given name. - :param policy_set_definition_name: The name of the policy set definition to create. + :param policy_set_definition_name: The name of the policy set definition to create. Required. :type policy_set_definition_name: str - :param management_group_id: The ID of the management group. + :param management_group_id: The ID of the management group. Required. :type management_group_id: str - :param parameters: The policy set definition properties. + :param parameters: The policy set definition properties. Required. :type parameters: ~azure.mgmt.resource.policy.v2019_06_01.models.PolicySetDefinition + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: PolicySetDefinition, or the result of cls(response) + :return: PolicySetDefinition or the result of cls(response) :rtype: ~azure.mgmt.resource.policy.v2019_06_01.models.PolicySetDefinition - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + async def create_or_update_at_management_group( + self, + policy_set_definition_name: str, + management_group_id: str, + parameters: IO, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.PolicySetDefinition: + """Creates or updates a policy set definition. + + This operation creates or updates a policy set definition in the given management group with + the given name. + + :param policy_set_definition_name: The name of the policy set definition to create. Required. + :type policy_set_definition_name: str + :param management_group_id: The ID of the management group. Required. + :type management_group_id: str + :param parameters: The policy set definition properties. Required. + :type parameters: IO + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: PolicySetDefinition or the result of cls(response) + :rtype: ~azure.mgmt.resource.policy.v2019_06_01.models.PolicySetDefinition + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace_async + async def create_or_update_at_management_group( + self, + policy_set_definition_name: str, + management_group_id: str, + parameters: Union[_models.PolicySetDefinition, IO], + **kwargs: Any + ) -> _models.PolicySetDefinition: + """Creates or updates a policy set definition. + + This operation creates or updates a policy set definition in the given management group with + the given name. + + :param policy_set_definition_name: The name of the policy set definition to create. Required. + :type policy_set_definition_name: str + :param management_group_id: The ID of the management group. Required. + :type management_group_id: str + :param parameters: The policy set definition properties. Is either a model type or a IO type. + Required. + :type parameters: ~azure.mgmt.resource.policy.v2019_06_01.models.PolicySetDefinition or IO + :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. + Default value is None. + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: PolicySetDefinition or the result of cls(response) + :rtype: ~azure.mgmt.resource.policy.v2019_06_01.models.PolicySetDefinition + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.PolicySetDefinition"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', "2019-06-01") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + api_version = kwargs.pop("api_version", _params.pop("api-version", "2019-06-01")) # type: str + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.PolicySetDefinition] - _json = self._serialize.body(parameters, 'PolicySetDefinition') + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(parameters, (IO, bytes)): + _content = parameters + else: + _json = self._serialize.body(parameters, "PolicySetDefinition") request = build_policy_set_definitions_create_or_update_at_management_group_request( policy_set_definition_name=policy_set_definition_name, @@ -1866,16 +2378,18 @@ async def create_or_update_at_management_group( api_version=api_version, content_type=content_type, json=_json, - template_url=self.create_or_update_at_management_group.metadata['url'], + content=_content, + template_url=self.create_or_update_at_management_group.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200, 201]: @@ -1884,63 +2398,65 @@ async def create_or_update_at_management_group( raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) if response.status_code == 200: - deserialized = self._deserialize('PolicySetDefinition', pipeline_response) + deserialized = self._deserialize("PolicySetDefinition", pipeline_response) if response.status_code == 201: - deserialized = self._deserialize('PolicySetDefinition', pipeline_response) + deserialized = self._deserialize("PolicySetDefinition", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - create_or_update_at_management_group.metadata = {'url': "/providers/Microsoft.Management/managementgroups/{managementGroupId}/providers/Microsoft.Authorization/policySetDefinitions/{policySetDefinitionName}"} # type: ignore - + create_or_update_at_management_group.metadata = {"url": "/providers/Microsoft.Management/managementgroups/{managementGroupId}/providers/Microsoft.Authorization/policySetDefinitions/{policySetDefinitionName}"} # type: ignore @distributed_trace_async async def delete_at_management_group( # pylint: disable=inconsistent-return-statements - self, - policy_set_definition_name: str, - management_group_id: str, - **kwargs: Any + self, policy_set_definition_name: str, management_group_id: str, **kwargs: Any ) -> None: """Deletes a policy set definition. This operation deletes the policy set definition in the given management group with the given name. - :param policy_set_definition_name: The name of the policy set definition to delete. + :param policy_set_definition_name: The name of the policy set definition to delete. Required. :type policy_set_definition_name: str - :param management_group_id: The ID of the management group. + :param management_group_id: The ID of the management group. Required. :type management_group_id: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: None, or the result of cls(response) + :return: None or the result of cls(response) :rtype: None - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType[None] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + 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', "2019-06-01") # type: str + api_version = kwargs.pop("api_version", _params.pop("api-version", "2019-06-01")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[None] - request = build_policy_set_definitions_delete_at_management_group_request( policy_set_definition_name=policy_set_definition_name, management_group_id=management_group_id, api_version=api_version, - template_url=self.delete_at_management_group.metadata['url'], + template_url=self.delete_at_management_group.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200, 204]: @@ -1951,53 +2467,55 @@ async def delete_at_management_group( # pylint: disable=inconsistent-return-sta if cls: return cls(pipeline_response, None, {}) - delete_at_management_group.metadata = {'url': "/providers/Microsoft.Management/managementgroups/{managementGroupId}/providers/Microsoft.Authorization/policySetDefinitions/{policySetDefinitionName}"} # type: ignore - + delete_at_management_group.metadata = {"url": "/providers/Microsoft.Management/managementgroups/{managementGroupId}/providers/Microsoft.Authorization/policySetDefinitions/{policySetDefinitionName}"} # type: ignore @distributed_trace_async async def get_at_management_group( - self, - policy_set_definition_name: str, - management_group_id: str, - **kwargs: Any - ) -> "_models.PolicySetDefinition": + self, policy_set_definition_name: str, management_group_id: str, **kwargs: Any + ) -> _models.PolicySetDefinition: """Retrieves a policy set definition. This operation retrieves the policy set definition in the given management group with the given name. - :param policy_set_definition_name: The name of the policy set definition to get. + :param policy_set_definition_name: The name of the policy set definition to get. Required. :type policy_set_definition_name: str - :param management_group_id: The ID of the management group. + :param management_group_id: The ID of the management group. Required. :type management_group_id: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: PolicySetDefinition, or the result of cls(response) + :return: PolicySetDefinition or the result of cls(response) :rtype: ~azure.mgmt.resource.policy.v2019_06_01.models.PolicySetDefinition - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.PolicySetDefinition"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + 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', "2019-06-01") # type: str + api_version = kwargs.pop("api_version", _params.pop("api-version", "2019-06-01")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[_models.PolicySetDefinition] - request = build_policy_set_definitions_get_at_management_group_request( policy_set_definition_name=policy_set_definition_name, management_group_id=management_group_id, api_version=api_version, - template_url=self.get_at_management_group.metadata['url'], + template_url=self.get_at_management_group.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200]: @@ -2005,62 +2523,67 @@ async def get_at_management_group( error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - deserialized = self._deserialize('PolicySetDefinition', pipeline_response) + deserialized = self._deserialize("PolicySetDefinition", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - get_at_management_group.metadata = {'url': "/providers/Microsoft.Management/managementgroups/{managementGroupId}/providers/Microsoft.Authorization/policySetDefinitions/{policySetDefinitionName}"} # type: ignore - + get_at_management_group.metadata = {"url": "/providers/Microsoft.Management/managementgroups/{managementGroupId}/providers/Microsoft.Authorization/policySetDefinitions/{policySetDefinitionName}"} # type: ignore @distributed_trace def list_by_management_group( - self, - management_group_id: str, - **kwargs: Any - ) -> AsyncIterable["_models.PolicySetDefinitionListResult"]: + self, management_group_id: str, **kwargs: Any + ) -> AsyncIterable["_models.PolicySetDefinition"]: """Retrieves all policy set definitions in management group. This operation retrieves a list of all the a policy set definition in the given management group. - :param management_group_id: The ID of the management group. + :param management_group_id: The ID of the management group. Required. :type management_group_id: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either PolicySetDefinitionListResult or the result of - cls(response) + :return: An iterator like instance of either PolicySetDefinition or the result of cls(response) :rtype: - ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.resource.policy.v2019_06_01.models.PolicySetDefinitionListResult] - :raises: ~azure.core.exceptions.HttpResponseError + ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.resource.policy.v2019_06_01.models.PolicySetDefinition] + :raises ~azure.core.exceptions.HttpResponseError: """ - api_version = kwargs.pop('api_version', "2019-06-01") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2019-06-01")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[_models.PolicySetDefinitionListResult] - cls = kwargs.pop('cls', None) # type: ClsType["_models.PolicySetDefinitionListResult"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) + def prepare_request(next_link=None): if not next_link: - + request = build_policy_set_definitions_list_by_management_group_request( management_group_id=management_group_id, api_version=api_version, - template_url=self.list_by_management_group.metadata['url'], + template_url=self.list_by_management_group.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore else: - - request = build_policy_set_definitions_list_by_management_group_request( - management_group_id=management_group_id, - template_url=next_link, - ) + # make call to next link with the client's api-version + _parsed_next_link = urlparse(next_link) + _next_request_params = case_insensitive_dict(parse_qs(_parsed_next_link.query)) + _next_request_params["api-version"] = self._config.api_version + request = HttpRequest("GET", urljoin(next_link, _parsed_next_link.path), params=_next_request_params) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore request.method = "GET" return request @@ -2074,10 +2597,8 @@ async def extract_data(pipeline_response): async def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) response = pipeline_response.http_response @@ -2088,8 +2609,6 @@ async def get_next(next_link=None): return pipeline_response + return AsyncItemPaged(get_next, extract_data) - return AsyncItemPaged( - get_next, extract_data - ) - list_by_management_group.metadata = {'url': "/providers/Microsoft.Management/managementgroups/{managementGroupId}/providers/Microsoft.Authorization/policySetDefinitions"} # type: ignore + list_by_management_group.metadata = {"url": "/providers/Microsoft.Management/managementgroups/{managementGroupId}/providers/Microsoft.Authorization/policySetDefinitions"} # type: ignore diff --git a/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/policy/v2019_06_01/aio/operations/_patch.py b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/policy/v2019_06_01/aio/operations/_patch.py new file mode 100644 index 0000000000000..f7dd32510333d --- /dev/null +++ b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/policy/v2019_06_01/aio/operations/_patch.py @@ -0,0 +1,20 @@ +# ------------------------------------ +# Copyright (c) Microsoft Corporation. +# Licensed under the MIT License. +# ------------------------------------ +"""Customize generated code here. + +Follow our quickstart for examples: https://aka.ms/azsdk/python/dpcodegen/python/customize +""" +from typing import List + +__all__: List[str] = [] # Add all objects you want publicly available to users at this package level + + +def patch_sdk(): + """Do not remove from this file. + + `patch_sdk` is a last resort escape hatch that allows you to do customizations + you can't accomplish using the techniques described in + https://aka.ms/azsdk/python/dpcodegen/python/customize + """ diff --git a/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/policy/v2019_06_01/models/__init__.py b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/policy/v2019_06_01/models/__init__.py index fa5f5d879ff23..51b841b5c3f4c 100644 --- a/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/policy/v2019_06_01/models/__init__.py +++ b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/policy/v2019_06_01/models/__init__.py @@ -17,25 +17,27 @@ from ._models_py3 import PolicySetDefinitionListResult from ._models_py3 import PolicySku - -from ._policy_client_enums import ( - EnforcementMode, - PolicyType, - ResourceIdentityType, -) +from ._policy_client_enums import EnforcementMode +from ._policy_client_enums import PolicyType +from ._policy_client_enums import ResourceIdentityType +from ._patch import __all__ as _patch_all +from ._patch import * # type: ignore # pylint: disable=unused-wildcard-import +from ._patch import patch_sdk as _patch_sdk __all__ = [ - 'ErrorResponse', - 'Identity', - 'PolicyAssignment', - 'PolicyAssignmentListResult', - 'PolicyDefinition', - 'PolicyDefinitionListResult', - 'PolicyDefinitionReference', - 'PolicySetDefinition', - 'PolicySetDefinitionListResult', - 'PolicySku', - 'EnforcementMode', - 'PolicyType', - 'ResourceIdentityType', + "ErrorResponse", + "Identity", + "PolicyAssignment", + "PolicyAssignmentListResult", + "PolicyDefinition", + "PolicyDefinitionListResult", + "PolicyDefinitionReference", + "PolicySetDefinition", + "PolicySetDefinitionListResult", + "PolicySku", + "EnforcementMode", + "PolicyType", + "ResourceIdentityType", ] +__all__.extend([p for p in _patch_all if p not in __all__]) +_patch_sdk() diff --git a/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/policy/v2019_06_01/models/_models_py3.py b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/policy/v2019_06_01/models/_models_py3.py index f645863400817..7dc3ae2c2bb03 100644 --- a/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/policy/v2019_06_01/models/_models_py3.py +++ b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/policy/v2019_06_01/models/_models_py3.py @@ -1,4 +1,5 @@ # coding=utf-8 +# pylint: disable=too-many-lines # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. # Licensed under the MIT License. See License.txt in the project root for license information. @@ -6,15 +7,22 @@ # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -from typing import Any, List, Optional, Union +import sys +from typing import Any, List, Optional, TYPE_CHECKING, Union -from azure.core.exceptions import HttpResponseError -import msrest.serialization +from ... import _serialization -from ._policy_client_enums import * +if TYPE_CHECKING: + # pylint: disable=unused-import,ungrouped-imports + from .. import models as _models +if sys.version_info >= (3, 9): + from collections.abc import MutableMapping +else: + from typing import MutableMapping # type: ignore # pylint: disable=ungrouped-imports +JSON = MutableMapping[str, Any] # pylint: disable=unsubscriptable-object -class ErrorResponse(msrest.serialization.Model): +class ErrorResponse(_serialization.Model): """Error response indicates Azure Resource Manager is not able to process the incoming request. The reason is provided in the error message. :ivar http_status: Http status code. @@ -26,9 +34,9 @@ class ErrorResponse(msrest.serialization.Model): """ _attribute_map = { - 'http_status': {'key': 'httpStatus', 'type': 'str'}, - 'error_code': {'key': 'errorCode', 'type': 'str'}, - 'error_message': {'key': 'errorMessage', 'type': 'str'}, + "http_status": {"key": "httpStatus", "type": "str"}, + "error_code": {"key": "errorCode", "type": "str"}, + "error_message": {"key": "errorMessage", "type": "str"}, } def __init__( @@ -47,13 +55,13 @@ def __init__( :keyword error_message: Error message indicating why the operation failed. :paramtype error_message: str """ - super(ErrorResponse, self).__init__(**kwargs) + super().__init__(**kwargs) self.http_status = http_status self.error_code = error_code self.error_message = error_message -class Identity(msrest.serialization.Model): +class Identity(_serialization.Model): """Identity for the resource. Variables are only populated by the server, and will be ignored when sending a request. @@ -62,38 +70,33 @@ class Identity(msrest.serialization.Model): :vartype principal_id: str :ivar tenant_id: The tenant ID of the resource identity. :vartype tenant_id: str - :ivar type: The identity type. Possible values include: "SystemAssigned", "None". + :ivar type: The identity type. Known values are: "SystemAssigned" and "None". :vartype type: str or ~azure.mgmt.resource.policy.v2019_06_01.models.ResourceIdentityType """ _validation = { - 'principal_id': {'readonly': True}, - 'tenant_id': {'readonly': True}, + "principal_id": {"readonly": True}, + "tenant_id": {"readonly": True}, } _attribute_map = { - 'principal_id': {'key': 'principalId', 'type': 'str'}, - 'tenant_id': {'key': 'tenantId', 'type': 'str'}, - 'type': {'key': 'type', 'type': 'str'}, + "principal_id": {"key": "principalId", "type": "str"}, + "tenant_id": {"key": "tenantId", "type": "str"}, + "type": {"key": "type", "type": "str"}, } - def __init__( - self, - *, - type: Optional[Union[str, "ResourceIdentityType"]] = None, - **kwargs - ): + def __init__(self, *, type: Optional[Union[str, "_models.ResourceIdentityType"]] = None, **kwargs): """ - :keyword type: The identity type. Possible values include: "SystemAssigned", "None". + :keyword type: The identity type. Known values are: "SystemAssigned" and "None". :paramtype type: str or ~azure.mgmt.resource.policy.v2019_06_01.models.ResourceIdentityType """ - super(Identity, self).__init__(**kwargs) + super().__init__(**kwargs) self.principal_id = None self.tenant_id = None self.type = type -class PolicyAssignment(msrest.serialization.Model): +class PolicyAssignment(_serialization.Model): # pylint: disable=too-many-instance-attributes """The policy assignment. Variables are only populated by the server, and will be ignored when sending a request. @@ -121,54 +124,54 @@ class PolicyAssignment(msrest.serialization.Model): :ivar not_scopes: The policy's excluded scopes. :vartype not_scopes: list[str] :ivar parameters: Required if a parameter is used in policy rule. - :vartype parameters: any + :vartype parameters: JSON :ivar description: This message will be part of response in case of policy violation. :vartype description: str :ivar metadata: The policy assignment metadata. - :vartype metadata: any + :vartype metadata: JSON :ivar enforcement_mode: The policy assignment enforcement mode. Possible values are Default and - DoNotEnforce. Possible values include: "Default", "DoNotEnforce". + DoNotEnforce. Known values are: "Default" and "DoNotEnforce". :vartype enforcement_mode: str or ~azure.mgmt.resource.policy.v2019_06_01.models.EnforcementMode """ _validation = { - 'id': {'readonly': True}, - 'type': {'readonly': True}, - 'name': {'readonly': True}, + "id": {"readonly": True}, + "type": {"readonly": True}, + "name": {"readonly": True}, } _attribute_map = { - 'id': {'key': 'id', 'type': 'str'}, - 'type': {'key': 'type', 'type': 'str'}, - 'name': {'key': 'name', 'type': 'str'}, - 'sku': {'key': 'sku', 'type': 'PolicySku'}, - 'location': {'key': 'location', 'type': 'str'}, - 'identity': {'key': 'identity', 'type': 'Identity'}, - 'display_name': {'key': 'properties.displayName', 'type': 'str'}, - 'policy_definition_id': {'key': 'properties.policyDefinitionId', 'type': 'str'}, - 'scope': {'key': 'properties.scope', 'type': 'str'}, - 'not_scopes': {'key': 'properties.notScopes', 'type': '[str]'}, - 'parameters': {'key': 'properties.parameters', 'type': 'object'}, - 'description': {'key': 'properties.description', 'type': 'str'}, - 'metadata': {'key': 'properties.metadata', 'type': 'object'}, - 'enforcement_mode': {'key': 'properties.enforcementMode', 'type': 'str'}, + "id": {"key": "id", "type": "str"}, + "type": {"key": "type", "type": "str"}, + "name": {"key": "name", "type": "str"}, + "sku": {"key": "sku", "type": "PolicySku"}, + "location": {"key": "location", "type": "str"}, + "identity": {"key": "identity", "type": "Identity"}, + "display_name": {"key": "properties.displayName", "type": "str"}, + "policy_definition_id": {"key": "properties.policyDefinitionId", "type": "str"}, + "scope": {"key": "properties.scope", "type": "str"}, + "not_scopes": {"key": "properties.notScopes", "type": "[str]"}, + "parameters": {"key": "properties.parameters", "type": "object"}, + "description": {"key": "properties.description", "type": "str"}, + "metadata": {"key": "properties.metadata", "type": "object"}, + "enforcement_mode": {"key": "properties.enforcementMode", "type": "str"}, } def __init__( self, *, - sku: Optional["PolicySku"] = None, + sku: Optional["_models.PolicySku"] = None, location: Optional[str] = None, - identity: Optional["Identity"] = None, + identity: Optional["_models.Identity"] = None, display_name: Optional[str] = None, policy_definition_id: Optional[str] = None, scope: Optional[str] = None, not_scopes: Optional[List[str]] = None, - parameters: Optional[Any] = None, + parameters: Optional[JSON] = None, description: Optional[str] = None, - metadata: Optional[Any] = None, - enforcement_mode: Optional[Union[str, "EnforcementMode"]] = None, + metadata: Optional[JSON] = None, + enforcement_mode: Optional[Union[str, "_models.EnforcementMode"]] = None, **kwargs ): """ @@ -189,17 +192,17 @@ def __init__( :keyword not_scopes: The policy's excluded scopes. :paramtype not_scopes: list[str] :keyword parameters: Required if a parameter is used in policy rule. - :paramtype parameters: any + :paramtype parameters: JSON :keyword description: This message will be part of response in case of policy violation. :paramtype description: str :keyword metadata: The policy assignment metadata. - :paramtype metadata: any + :paramtype metadata: JSON :keyword enforcement_mode: The policy assignment enforcement mode. Possible values are Default - and DoNotEnforce. Possible values include: "Default", "DoNotEnforce". + and DoNotEnforce. Known values are: "Default" and "DoNotEnforce". :paramtype enforcement_mode: str or ~azure.mgmt.resource.policy.v2019_06_01.models.EnforcementMode """ - super(PolicyAssignment, self).__init__(**kwargs) + super().__init__(**kwargs) self.id = None self.type = None self.name = None @@ -216,7 +219,7 @@ def __init__( self.enforcement_mode = enforcement_mode -class PolicyAssignmentListResult(msrest.serialization.Model): +class PolicyAssignmentListResult(_serialization.Model): """List of policy assignments. :ivar value: An array of policy assignments. @@ -226,16 +229,12 @@ class PolicyAssignmentListResult(msrest.serialization.Model): """ _attribute_map = { - 'value': {'key': 'value', 'type': '[PolicyAssignment]'}, - 'next_link': {'key': 'nextLink', 'type': 'str'}, + "value": {"key": "value", "type": "[PolicyAssignment]"}, + "next_link": {"key": "nextLink", "type": "str"}, } def __init__( - self, - *, - value: Optional[List["PolicyAssignment"]] = None, - next_link: Optional[str] = None, - **kwargs + self, *, value: Optional[List["_models.PolicyAssignment"]] = None, next_link: Optional[str] = None, **kwargs ): """ :keyword value: An array of policy assignments. @@ -243,12 +242,12 @@ def __init__( :keyword next_link: The URL to use for getting the next set of results. :paramtype next_link: str """ - super(PolicyAssignmentListResult, self).__init__(**kwargs) + super().__init__(**kwargs) self.value = value self.next_link = next_link -class PolicyDefinition(msrest.serialization.Model): +class PolicyDefinition(_serialization.Model): """The policy definition. Variables are only populated by the server, and will be ignored when sending a request. @@ -260,7 +259,7 @@ class PolicyDefinition(msrest.serialization.Model): :ivar type: The type of the resource (Microsoft.Authorization/policyDefinitions). :vartype type: str :ivar policy_type: The type of policy definition. Possible values are NotSpecified, BuiltIn, - and Custom. Possible values include: "NotSpecified", "BuiltIn", "Custom". + and Custom. Known values are: "NotSpecified", "BuiltIn", and "Custom". :vartype policy_type: str or ~azure.mgmt.resource.policy.v2019_06_01.models.PolicyType :ivar mode: The policy definition mode. Some examples are All, Indexed, Microsoft.KeyVault.Data. @@ -270,47 +269,47 @@ class PolicyDefinition(msrest.serialization.Model): :ivar description: The policy definition description. :vartype description: str :ivar policy_rule: The policy rule. - :vartype policy_rule: any + :vartype policy_rule: JSON :ivar metadata: The policy definition metadata. - :vartype metadata: any + :vartype metadata: JSON :ivar parameters: Required if a parameter is used in policy rule. - :vartype parameters: any + :vartype parameters: JSON """ _validation = { - 'id': {'readonly': True}, - 'name': {'readonly': True}, - 'type': {'readonly': True}, + "id": {"readonly": True}, + "name": {"readonly": True}, + "type": {"readonly": True}, } _attribute_map = { - 'id': {'key': 'id', 'type': 'str'}, - 'name': {'key': 'name', 'type': 'str'}, - 'type': {'key': 'type', 'type': 'str'}, - 'policy_type': {'key': 'properties.policyType', 'type': 'str'}, - 'mode': {'key': 'properties.mode', 'type': 'str'}, - 'display_name': {'key': 'properties.displayName', 'type': 'str'}, - 'description': {'key': 'properties.description', 'type': 'str'}, - 'policy_rule': {'key': 'properties.policyRule', 'type': 'object'}, - 'metadata': {'key': 'properties.metadata', 'type': 'object'}, - 'parameters': {'key': 'properties.parameters', 'type': 'object'}, + "id": {"key": "id", "type": "str"}, + "name": {"key": "name", "type": "str"}, + "type": {"key": "type", "type": "str"}, + "policy_type": {"key": "properties.policyType", "type": "str"}, + "mode": {"key": "properties.mode", "type": "str"}, + "display_name": {"key": "properties.displayName", "type": "str"}, + "description": {"key": "properties.description", "type": "str"}, + "policy_rule": {"key": "properties.policyRule", "type": "object"}, + "metadata": {"key": "properties.metadata", "type": "object"}, + "parameters": {"key": "properties.parameters", "type": "object"}, } def __init__( self, *, - policy_type: Optional[Union[str, "PolicyType"]] = None, + policy_type: Optional[Union[str, "_models.PolicyType"]] = None, mode: Optional[str] = None, display_name: Optional[str] = None, description: Optional[str] = None, - policy_rule: Optional[Any] = None, - metadata: Optional[Any] = None, - parameters: Optional[Any] = None, + policy_rule: Optional[JSON] = None, + metadata: Optional[JSON] = None, + parameters: Optional[JSON] = None, **kwargs ): """ :keyword policy_type: The type of policy definition. Possible values are NotSpecified, BuiltIn, - and Custom. Possible values include: "NotSpecified", "BuiltIn", "Custom". + and Custom. Known values are: "NotSpecified", "BuiltIn", and "Custom". :paramtype policy_type: str or ~azure.mgmt.resource.policy.v2019_06_01.models.PolicyType :keyword mode: The policy definition mode. Some examples are All, Indexed, Microsoft.KeyVault.Data. @@ -320,13 +319,13 @@ def __init__( :keyword description: The policy definition description. :paramtype description: str :keyword policy_rule: The policy rule. - :paramtype policy_rule: any + :paramtype policy_rule: JSON :keyword metadata: The policy definition metadata. - :paramtype metadata: any + :paramtype metadata: JSON :keyword parameters: Required if a parameter is used in policy rule. - :paramtype parameters: any + :paramtype parameters: JSON """ - super(PolicyDefinition, self).__init__(**kwargs) + super().__init__(**kwargs) self.id = None self.name = None self.type = None @@ -339,7 +338,7 @@ def __init__( self.parameters = parameters -class PolicyDefinitionListResult(msrest.serialization.Model): +class PolicyDefinitionListResult(_serialization.Model): """List of policy definitions. :ivar value: An array of policy definitions. @@ -349,16 +348,12 @@ class PolicyDefinitionListResult(msrest.serialization.Model): """ _attribute_map = { - 'value': {'key': 'value', 'type': '[PolicyDefinition]'}, - 'next_link': {'key': 'nextLink', 'type': 'str'}, + "value": {"key": "value", "type": "[PolicyDefinition]"}, + "next_link": {"key": "nextLink", "type": "str"}, } def __init__( - self, - *, - value: Optional[List["PolicyDefinition"]] = None, - next_link: Optional[str] = None, - **kwargs + self, *, value: Optional[List["_models.PolicyDefinition"]] = None, next_link: Optional[str] = None, **kwargs ): """ :keyword value: An array of policy definitions. @@ -366,44 +361,38 @@ def __init__( :keyword next_link: The URL to use for getting the next set of results. :paramtype next_link: str """ - super(PolicyDefinitionListResult, self).__init__(**kwargs) + super().__init__(**kwargs) self.value = value self.next_link = next_link -class PolicyDefinitionReference(msrest.serialization.Model): +class PolicyDefinitionReference(_serialization.Model): """The policy definition reference. :ivar policy_definition_id: The ID of the policy definition or policy set definition. :vartype policy_definition_id: str :ivar parameters: Required if a parameter is used in policy rule. - :vartype parameters: any + :vartype parameters: JSON """ _attribute_map = { - 'policy_definition_id': {'key': 'policyDefinitionId', 'type': 'str'}, - 'parameters': {'key': 'parameters', 'type': 'object'}, + "policy_definition_id": {"key": "policyDefinitionId", "type": "str"}, + "parameters": {"key": "parameters", "type": "object"}, } - def __init__( - self, - *, - policy_definition_id: Optional[str] = None, - parameters: Optional[Any] = None, - **kwargs - ): + def __init__(self, *, policy_definition_id: Optional[str] = None, parameters: Optional[JSON] = None, **kwargs): """ :keyword policy_definition_id: The ID of the policy definition or policy set definition. :paramtype policy_definition_id: str :keyword parameters: Required if a parameter is used in policy rule. - :paramtype parameters: any + :paramtype parameters: JSON """ - super(PolicyDefinitionReference, self).__init__(**kwargs) + super().__init__(**kwargs) self.policy_definition_id = policy_definition_id self.parameters = parameters -class PolicySetDefinition(msrest.serialization.Model): +class PolicySetDefinition(_serialization.Model): """The policy set definition. Variables are only populated by the server, and will be ignored when sending a request. @@ -415,69 +404,69 @@ class PolicySetDefinition(msrest.serialization.Model): :ivar type: The type of the resource (Microsoft.Authorization/policySetDefinitions). :vartype type: str :ivar policy_type: The type of policy definition. Possible values are NotSpecified, BuiltIn, - and Custom. Possible values include: "NotSpecified", "BuiltIn", "Custom". + and Custom. Known values are: "NotSpecified", "BuiltIn", and "Custom". :vartype policy_type: str or ~azure.mgmt.resource.policy.v2019_06_01.models.PolicyType :ivar display_name: The display name of the policy set definition. :vartype display_name: str :ivar description: The policy set definition description. :vartype description: str :ivar metadata: The policy set definition metadata. - :vartype metadata: any + :vartype metadata: JSON :ivar parameters: The policy set definition parameters that can be used in policy definition references. - :vartype parameters: any + :vartype parameters: JSON :ivar policy_definitions: An array of policy definition references. :vartype policy_definitions: list[~azure.mgmt.resource.policy.v2019_06_01.models.PolicyDefinitionReference] """ _validation = { - 'id': {'readonly': True}, - 'name': {'readonly': True}, - 'type': {'readonly': True}, + "id": {"readonly": True}, + "name": {"readonly": True}, + "type": {"readonly": True}, } _attribute_map = { - 'id': {'key': 'id', 'type': 'str'}, - 'name': {'key': 'name', 'type': 'str'}, - 'type': {'key': 'type', 'type': 'str'}, - 'policy_type': {'key': 'properties.policyType', 'type': 'str'}, - 'display_name': {'key': 'properties.displayName', 'type': 'str'}, - 'description': {'key': 'properties.description', 'type': 'str'}, - 'metadata': {'key': 'properties.metadata', 'type': 'object'}, - 'parameters': {'key': 'properties.parameters', 'type': 'object'}, - 'policy_definitions': {'key': 'properties.policyDefinitions', 'type': '[PolicyDefinitionReference]'}, + "id": {"key": "id", "type": "str"}, + "name": {"key": "name", "type": "str"}, + "type": {"key": "type", "type": "str"}, + "policy_type": {"key": "properties.policyType", "type": "str"}, + "display_name": {"key": "properties.displayName", "type": "str"}, + "description": {"key": "properties.description", "type": "str"}, + "metadata": {"key": "properties.metadata", "type": "object"}, + "parameters": {"key": "properties.parameters", "type": "object"}, + "policy_definitions": {"key": "properties.policyDefinitions", "type": "[PolicyDefinitionReference]"}, } def __init__( self, *, - policy_type: Optional[Union[str, "PolicyType"]] = None, + policy_type: Optional[Union[str, "_models.PolicyType"]] = None, display_name: Optional[str] = None, description: Optional[str] = None, - metadata: Optional[Any] = None, - parameters: Optional[Any] = None, - policy_definitions: Optional[List["PolicyDefinitionReference"]] = None, + metadata: Optional[JSON] = None, + parameters: Optional[JSON] = None, + policy_definitions: Optional[List["_models.PolicyDefinitionReference"]] = None, **kwargs ): """ :keyword policy_type: The type of policy definition. Possible values are NotSpecified, BuiltIn, - and Custom. Possible values include: "NotSpecified", "BuiltIn", "Custom". + and Custom. Known values are: "NotSpecified", "BuiltIn", and "Custom". :paramtype policy_type: str or ~azure.mgmt.resource.policy.v2019_06_01.models.PolicyType :keyword display_name: The display name of the policy set definition. :paramtype display_name: str :keyword description: The policy set definition description. :paramtype description: str :keyword metadata: The policy set definition metadata. - :paramtype metadata: any + :paramtype metadata: JSON :keyword parameters: The policy set definition parameters that can be used in policy definition references. - :paramtype parameters: any + :paramtype parameters: JSON :keyword policy_definitions: An array of policy definition references. :paramtype policy_definitions: list[~azure.mgmt.resource.policy.v2019_06_01.models.PolicyDefinitionReference] """ - super(PolicySetDefinition, self).__init__(**kwargs) + super().__init__(**kwargs) self.id = None self.name = None self.type = None @@ -489,7 +478,7 @@ def __init__( self.policy_definitions = policy_definitions -class PolicySetDefinitionListResult(msrest.serialization.Model): +class PolicySetDefinitionListResult(_serialization.Model): """List of policy set definitions. :ivar value: An array of policy set definitions. @@ -499,16 +488,12 @@ class PolicySetDefinitionListResult(msrest.serialization.Model): """ _attribute_map = { - 'value': {'key': 'value', 'type': '[PolicySetDefinition]'}, - 'next_link': {'key': 'nextLink', 'type': 'str'}, + "value": {"key": "value", "type": "[PolicySetDefinition]"}, + "next_link": {"key": "nextLink", "type": "str"}, } def __init__( - self, - *, - value: Optional[List["PolicySetDefinition"]] = None, - next_link: Optional[str] = None, - **kwargs + self, *, value: Optional[List["_models.PolicySetDefinition"]] = None, next_link: Optional[str] = None, **kwargs ): """ :keyword value: An array of policy set definitions. @@ -516,44 +501,38 @@ def __init__( :keyword next_link: The URL to use for getting the next set of results. :paramtype next_link: str """ - super(PolicySetDefinitionListResult, self).__init__(**kwargs) + super().__init__(**kwargs) self.value = value self.next_link = next_link -class PolicySku(msrest.serialization.Model): +class PolicySku(_serialization.Model): """The policy sku. This property is optional, obsolete, and will be ignored. All required parameters must be populated in order to send to Azure. - :ivar name: Required. The name of the policy sku. Possible values are A0 and A1. + :ivar name: The name of the policy sku. Possible values are A0 and A1. Required. :vartype name: str :ivar tier: The policy sku tier. Possible values are Free and Standard. :vartype tier: str """ _validation = { - 'name': {'required': True}, + "name": {"required": True}, } _attribute_map = { - 'name': {'key': 'name', 'type': 'str'}, - 'tier': {'key': 'tier', 'type': 'str'}, + "name": {"key": "name", "type": "str"}, + "tier": {"key": "tier", "type": "str"}, } - def __init__( - self, - *, - name: str, - tier: Optional[str] = None, - **kwargs - ): + def __init__(self, *, name: str, tier: Optional[str] = None, **kwargs): """ - :keyword name: Required. The name of the policy sku. Possible values are A0 and A1. + :keyword name: The name of the policy sku. Possible values are A0 and A1. Required. :paramtype name: str :keyword tier: The policy sku tier. Possible values are Free and Standard. :paramtype tier: str """ - super(PolicySku, self).__init__(**kwargs) + super().__init__(**kwargs) self.name = name self.tier = tier diff --git a/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/policy/v2019_06_01/models/_patch.py b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/policy/v2019_06_01/models/_patch.py new file mode 100644 index 0000000000000..f7dd32510333d --- /dev/null +++ b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/policy/v2019_06_01/models/_patch.py @@ -0,0 +1,20 @@ +# ------------------------------------ +# Copyright (c) Microsoft Corporation. +# Licensed under the MIT License. +# ------------------------------------ +"""Customize generated code here. + +Follow our quickstart for examples: https://aka.ms/azsdk/python/dpcodegen/python/customize +""" +from typing import List + +__all__: List[str] = [] # Add all objects you want publicly available to users at this package level + + +def patch_sdk(): + """Do not remove from this file. + + `patch_sdk` is a last resort escape hatch that allows you to do customizations + you can't accomplish using the techniques described in + https://aka.ms/azsdk/python/dpcodegen/python/customize + """ diff --git a/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/policy/v2019_06_01/models/_policy_client_enums.py b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/policy/v2019_06_01/models/_policy_client_enums.py index 6917546afc103..673984bf1adfc 100644 --- a/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/policy/v2019_06_01/models/_policy_client_enums.py +++ b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/policy/v2019_06_01/models/_policy_client_enums.py @@ -7,30 +7,28 @@ # -------------------------------------------------------------------------- from enum import Enum -from six import with_metaclass from azure.core import CaseInsensitiveEnumMeta -class EnforcementMode(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): - """The policy assignment enforcement mode. Possible values are Default and DoNotEnforce. - """ +class EnforcementMode(str, Enum, metaclass=CaseInsensitiveEnumMeta): + """The policy assignment enforcement mode. Possible values are Default and DoNotEnforce.""" #: The policy effect is enforced during resource creation or update. DEFAULT = "Default" #: The policy effect is not enforced during resource creation or update. DO_NOT_ENFORCE = "DoNotEnforce" -class PolicyType(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): - """The type of policy definition. Possible values are NotSpecified, BuiltIn, and Custom. - """ + +class PolicyType(str, Enum, metaclass=CaseInsensitiveEnumMeta): + """The type of policy definition. Possible values are NotSpecified, BuiltIn, and Custom.""" NOT_SPECIFIED = "NotSpecified" BUILT_IN = "BuiltIn" CUSTOM = "Custom" -class ResourceIdentityType(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): - """The identity type. - """ + +class ResourceIdentityType(str, Enum, metaclass=CaseInsensitiveEnumMeta): + """The identity type.""" SYSTEM_ASSIGNED = "SystemAssigned" NONE = "None" diff --git a/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/policy/v2019_06_01/operations/__init__.py b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/policy/v2019_06_01/operations/__init__.py index b2ae6190b03fb..4e1971e3e3247 100644 --- a/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/policy/v2019_06_01/operations/__init__.py +++ b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/policy/v2019_06_01/operations/__init__.py @@ -10,8 +10,14 @@ from ._operations import PolicyDefinitionsOperations from ._operations import PolicySetDefinitionsOperations +from ._patch import __all__ as _patch_all +from ._patch import * # type: ignore # pylint: disable=unused-wildcard-import +from ._patch import patch_sdk as _patch_sdk + __all__ = [ - 'PolicyAssignmentsOperations', - 'PolicyDefinitionsOperations', - 'PolicySetDefinitionsOperations', + "PolicyAssignmentsOperations", + "PolicyDefinitionsOperations", + "PolicySetDefinitionsOperations", ] +__all__.extend([p for p in _patch_all if p not in __all__]) +_patch_sdk() diff --git a/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/policy/v2019_06_01/operations/_operations.py b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/policy/v2019_06_01/operations/_operations.py index 1e5f8d29afc2f..5f6edbe66da31 100644 --- a/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/policy/v2019_06_01/operations/_operations.py +++ b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/policy/v2019_06_01/operations/_operations.py @@ -6,173 +6,152 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -from typing import Any, Callable, Dict, Iterable, Optional, TypeVar - -from msrest import Serializer - -from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error +from typing import Any, Callable, Dict, IO, Iterable, Optional, TypeVar, Union, overload +from urllib.parse import parse_qs, urljoin, urlparse + +from azure.core.exceptions import ( + ClientAuthenticationError, + HttpResponseError, + ResourceExistsError, + ResourceNotFoundError, + ResourceNotModifiedError, + map_error, +) from azure.core.paging import ItemPaged from azure.core.pipeline import PipelineResponse from azure.core.pipeline.transport import HttpResponse from azure.core.rest import HttpRequest from azure.core.tracing.decorator import distributed_trace +from azure.core.utils import case_insensitive_dict from azure.mgmt.core.exceptions import ARMErrorFormat from .. import models as _models +from ..._serialization import Serializer from .._vendor import _convert_request, _format_url_section -T = TypeVar('T') -JSONType = Any + +T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] _SERIALIZER = Serializer() _SERIALIZER.client_side_validation = False -def build_policy_assignments_delete_request( - scope: str, - policy_assignment_name: str, - **kwargs: Any -) -> HttpRequest: - api_version = kwargs.pop('api_version', "2019-06-01") # type: str - accept = "application/json" +def build_policy_assignments_delete_request(scope: str, policy_assignment_name: 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", "2019-06-01")) # type: str + accept = _headers.pop("Accept", "application/json") + # Construct URL - _url = kwargs.pop("template_url", "/{scope}/providers/Microsoft.Authorization/policyAssignments/{policyAssignmentName}") + _url = kwargs.pop( + "template_url", "/{scope}/providers/Microsoft.Authorization/policyAssignments/{policyAssignmentName}" + ) path_format_arguments = { - "scope": _SERIALIZER.url("scope", scope, 'str', skip_quote=True), - "policyAssignmentName": _SERIALIZER.url("policy_assignment_name", policy_assignment_name, 'str'), + "scope": _SERIALIZER.url("scope", scope, "str", skip_quote=True), + "policyAssignmentName": _SERIALIZER.url("policy_assignment_name", policy_assignment_name, "str"), } _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') - - return HttpRequest( - method="DELETE", - url=_url, - params=_query_parameters, - headers=_header_parameters, - **kwargs - ) + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + return HttpRequest(method="DELETE", url=_url, params=_params, headers=_headers, **kwargs) -def build_policy_assignments_create_request( - scope: str, - policy_assignment_name: str, - *, - json: JSONType = None, - content: Any = None, - **kwargs: Any -) -> HttpRequest: - api_version = kwargs.pop('api_version', "2019-06-01") # type: str - content_type = kwargs.pop('content_type', None) # type: Optional[str] - accept = "application/json" +def build_policy_assignments_create_request(scope: str, policy_assignment_name: 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", "2019-06-01")) # type: str + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + accept = _headers.pop("Accept", "application/json") + # Construct URL - _url = kwargs.pop("template_url", "/{scope}/providers/Microsoft.Authorization/policyAssignments/{policyAssignmentName}") + _url = kwargs.pop( + "template_url", "/{scope}/providers/Microsoft.Authorization/policyAssignments/{policyAssignmentName}" + ) path_format_arguments = { - "scope": _SERIALIZER.url("scope", scope, 'str', skip_quote=True), - "policyAssignmentName": _SERIALIZER.url("policy_assignment_name", policy_assignment_name, 'str'), + "scope": _SERIALIZER.url("scope", scope, "str", skip_quote=True), + "policyAssignmentName": _SERIALIZER.url("policy_assignment_name", policy_assignment_name, "str"), } _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] if content_type is not None: - _header_parameters['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') - _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') - - return HttpRequest( - method="PUT", - url=_url, - params=_query_parameters, - headers=_header_parameters, - json=json, - content=content, - **kwargs - ) + _headers["Content-Type"] = _SERIALIZER.header("content_type", content_type, "str") + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + return HttpRequest(method="PUT", url=_url, params=_params, headers=_headers, **kwargs) -def build_policy_assignments_get_request( - scope: str, - policy_assignment_name: str, - **kwargs: Any -) -> HttpRequest: - api_version = kwargs.pop('api_version', "2019-06-01") # type: str - accept = "application/json" +def build_policy_assignments_get_request(scope: str, policy_assignment_name: 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", "2019-06-01")) # type: str + accept = _headers.pop("Accept", "application/json") + # Construct URL - _url = kwargs.pop("template_url", "/{scope}/providers/Microsoft.Authorization/policyAssignments/{policyAssignmentName}") + _url = kwargs.pop( + "template_url", "/{scope}/providers/Microsoft.Authorization/policyAssignments/{policyAssignmentName}" + ) path_format_arguments = { - "scope": _SERIALIZER.url("scope", scope, 'str', skip_quote=True), - "policyAssignmentName": _SERIALIZER.url("policy_assignment_name", policy_assignment_name, 'str'), + "scope": _SERIALIZER.url("scope", scope, "str", skip_quote=True), + "policyAssignmentName": _SERIALIZER.url("policy_assignment_name", policy_assignment_name, "str"), } _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') - - return HttpRequest( - method="GET", - url=_url, - params=_query_parameters, - headers=_header_parameters, - **kwargs - ) + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) def build_policy_assignments_list_for_resource_group_request( - resource_group_name: str, - subscription_id: str, - *, - filter: Optional[str] = None, - **kwargs: Any + resource_group_name: str, subscription_id: str, *, filter: Optional[str] = None, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2019-06-01") # type: 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", "2019-06-01")) # type: str + accept = _headers.pop("Accept", "application/json") - accept = "application/json" # Construct URL - _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Authorization/policyAssignments") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Authorization/policyAssignments", + ) # pylint: disable=line-too-long path_format_arguments = { - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._\(\)]+$'), - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), + "resourceGroupName": _SERIALIZER.url( + "resource_group_name", resource_group_name, "str", max_length=90, min_length=1, pattern=r"^[-\w\._\(\)]+$" + ), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), } _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] if filter is not None: - _query_parameters['$filter'] = _SERIALIZER.query("filter", filter, 'str', skip_quote=True) - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["$filter"] = _SERIALIZER.query("filter", filter, "str", skip_quote=True) + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') - - return HttpRequest( - method="GET", - url=_url, - params=_query_parameters, - headers=_header_parameters, - **kwargs - ) + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) def build_policy_assignments_list_for_resource_request( @@ -186,881 +165,723 @@ def build_policy_assignments_list_for_resource_request( filter: Optional[str] = None, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2019-06-01") # type: 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", "2019-06-01")) # type: str + accept = _headers.pop("Accept", "application/json") - accept = "application/json" # Construct URL - _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{parentResourcePath}/{resourceType}/{resourceName}/providers/Microsoft.Authorization/policyAssignments") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{parentResourcePath}/{resourceType}/{resourceName}/providers/Microsoft.Authorization/policyAssignments", + ) # pylint: disable=line-too-long path_format_arguments = { - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._\(\)]+$'), - "resourceProviderNamespace": _SERIALIZER.url("resource_provider_namespace", resource_provider_namespace, 'str'), - "parentResourcePath": _SERIALIZER.url("parent_resource_path", parent_resource_path, 'str', skip_quote=True), - "resourceType": _SERIALIZER.url("resource_type", resource_type, 'str', skip_quote=True), - "resourceName": _SERIALIZER.url("resource_name", resource_name, 'str'), - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), + "resourceGroupName": _SERIALIZER.url( + "resource_group_name", resource_group_name, "str", max_length=90, min_length=1, pattern=r"^[-\w\._\(\)]+$" + ), + "resourceProviderNamespace": _SERIALIZER.url("resource_provider_namespace", resource_provider_namespace, "str"), + "parentResourcePath": _SERIALIZER.url("parent_resource_path", parent_resource_path, "str", skip_quote=True), + "resourceType": _SERIALIZER.url("resource_type", resource_type, "str", skip_quote=True), + "resourceName": _SERIALIZER.url("resource_name", resource_name, "str"), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), } _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] if filter is not None: - _query_parameters['$filter'] = _SERIALIZER.query("filter", filter, 'str') - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["$filter"] = _SERIALIZER.query("filter", filter, "str") + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') - - return HttpRequest( - method="GET", - url=_url, - params=_query_parameters, - headers=_header_parameters, - **kwargs - ) + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) def build_policy_assignments_list_request( - subscription_id: str, - *, - filter: Optional[str] = None, - **kwargs: Any + subscription_id: str, *, filter: Optional[str] = None, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2019-06-01") # type: 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", "2019-06-01")) # type: str + accept = _headers.pop("Accept", "application/json") - accept = "application/json" # Construct URL - _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/providers/Microsoft.Authorization/policyAssignments") + _url = kwargs.pop( + "template_url", "/subscriptions/{subscriptionId}/providers/Microsoft.Authorization/policyAssignments" + ) path_format_arguments = { - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), } _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] if filter is not None: - _query_parameters['$filter'] = _SERIALIZER.query("filter", filter, 'str') - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["$filter"] = _SERIALIZER.query("filter", filter, "str") + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') - - return HttpRequest( - method="GET", - url=_url, - params=_query_parameters, - headers=_header_parameters, - **kwargs - ) + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) -def build_policy_assignments_delete_by_id_request( - policy_assignment_id: str, - **kwargs: Any -) -> HttpRequest: - api_version = kwargs.pop('api_version', "2019-06-01") # type: str - accept = "application/json" +def build_policy_assignments_delete_by_id_request(policy_assignment_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", "2019-06-01")) # type: str + accept = _headers.pop("Accept", "application/json") + # Construct URL _url = kwargs.pop("template_url", "/{policyAssignmentId}") path_format_arguments = { - "policyAssignmentId": _SERIALIZER.url("policy_assignment_id", policy_assignment_id, 'str', skip_quote=True), + "policyAssignmentId": _SERIALIZER.url("policy_assignment_id", policy_assignment_id, "str", skip_quote=True), } _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') - - return HttpRequest( - method="DELETE", - url=_url, - params=_query_parameters, - headers=_header_parameters, - **kwargs - ) + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + return HttpRequest(method="DELETE", url=_url, params=_params, headers=_headers, **kwargs) -def build_policy_assignments_create_by_id_request( - policy_assignment_id: str, - *, - json: JSONType = None, - content: Any = None, - **kwargs: Any -) -> HttpRequest: - api_version = kwargs.pop('api_version', "2019-06-01") # type: str - content_type = kwargs.pop('content_type', None) # type: Optional[str] - accept = "application/json" +def build_policy_assignments_create_by_id_request(policy_assignment_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", "2019-06-01")) # type: str + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + accept = _headers.pop("Accept", "application/json") + # Construct URL _url = kwargs.pop("template_url", "/{policyAssignmentId}") path_format_arguments = { - "policyAssignmentId": _SERIALIZER.url("policy_assignment_id", policy_assignment_id, 'str', skip_quote=True), + "policyAssignmentId": _SERIALIZER.url("policy_assignment_id", policy_assignment_id, "str", skip_quote=True), } _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] if content_type is not None: - _header_parameters['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') - _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') - - return HttpRequest( - method="PUT", - url=_url, - params=_query_parameters, - headers=_header_parameters, - json=json, - content=content, - **kwargs - ) + _headers["Content-Type"] = _SERIALIZER.header("content_type", content_type, "str") + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + return HttpRequest(method="PUT", url=_url, params=_params, headers=_headers, **kwargs) -def build_policy_assignments_get_by_id_request( - policy_assignment_id: str, - **kwargs: Any -) -> HttpRequest: - api_version = kwargs.pop('api_version', "2019-06-01") # type: str - accept = "application/json" +def build_policy_assignments_get_by_id_request(policy_assignment_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", "2019-06-01")) # type: str + accept = _headers.pop("Accept", "application/json") + # Construct URL _url = kwargs.pop("template_url", "/{policyAssignmentId}") path_format_arguments = { - "policyAssignmentId": _SERIALIZER.url("policy_assignment_id", policy_assignment_id, 'str', skip_quote=True), + "policyAssignmentId": _SERIALIZER.url("policy_assignment_id", policy_assignment_id, "str", skip_quote=True), } _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') - - return HttpRequest( - method="GET", - url=_url, - params=_query_parameters, - headers=_header_parameters, - **kwargs - ) + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) def build_policy_definitions_create_or_update_request( - policy_definition_name: str, - subscription_id: str, - *, - json: JSONType = None, - content: Any = None, - **kwargs: Any + policy_definition_name: str, subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2019-06-01") # type: str - content_type = kwargs.pop('content_type', None) # type: Optional[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", "2019-06-01")) # type: str + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + accept = _headers.pop("Accept", "application/json") - accept = "application/json" # Construct URL - _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/providers/Microsoft.Authorization/policyDefinitions/{policyDefinitionName}") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/providers/Microsoft.Authorization/policyDefinitions/{policyDefinitionName}", + ) # pylint: disable=line-too-long path_format_arguments = { - "policyDefinitionName": _SERIALIZER.url("policy_definition_name", policy_definition_name, 'str'), - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), + "policyDefinitionName": _SERIALIZER.url("policy_definition_name", policy_definition_name, "str"), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), } _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] if content_type is not None: - _header_parameters['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') - _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') - - return HttpRequest( - method="PUT", - url=_url, - params=_query_parameters, - headers=_header_parameters, - json=json, - content=content, - **kwargs - ) + _headers["Content-Type"] = _SERIALIZER.header("content_type", content_type, "str") + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="PUT", url=_url, params=_params, headers=_headers, **kwargs) def build_policy_definitions_delete_request( - policy_definition_name: str, - subscription_id: str, - **kwargs: Any + policy_definition_name: str, subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2019-06-01") # type: str + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + api_version = kwargs.pop("api_version", _params.pop("api-version", "2019-06-01")) # type: str # Construct URL - _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/providers/Microsoft.Authorization/policyDefinitions/{policyDefinitionName}") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/providers/Microsoft.Authorization/policyDefinitions/{policyDefinitionName}", + ) # pylint: disable=line-too-long path_format_arguments = { - "policyDefinitionName": _SERIALIZER.url("policy_definition_name", policy_definition_name, 'str'), - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), + "policyDefinitionName": _SERIALIZER.url("policy_definition_name", policy_definition_name, "str"), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), } _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') - - return HttpRequest( - method="DELETE", - url=_url, - params=_query_parameters, - **kwargs - ) + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") + + return HttpRequest(method="DELETE", url=_url, params=_params, **kwargs) def build_policy_definitions_get_request( - policy_definition_name: str, - subscription_id: str, - **kwargs: Any + policy_definition_name: str, subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2019-06-01") # type: 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", "2019-06-01")) # type: str + accept = _headers.pop("Accept", "application/json") - accept = "application/json" # Construct URL - _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/providers/Microsoft.Authorization/policyDefinitions/{policyDefinitionName}") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/providers/Microsoft.Authorization/policyDefinitions/{policyDefinitionName}", + ) # pylint: disable=line-too-long path_format_arguments = { - "policyDefinitionName": _SERIALIZER.url("policy_definition_name", policy_definition_name, 'str'), - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), + "policyDefinitionName": _SERIALIZER.url("policy_definition_name", policy_definition_name, "str"), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), } _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') - - return HttpRequest( - method="GET", - url=_url, - params=_query_parameters, - headers=_header_parameters, - **kwargs - ) + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) -def build_policy_definitions_get_built_in_request( - policy_definition_name: str, - **kwargs: Any -) -> HttpRequest: - api_version = kwargs.pop('api_version', "2019-06-01") # type: str - accept = "application/json" +def build_policy_definitions_get_built_in_request(policy_definition_name: 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", "2019-06-01")) # type: str + accept = _headers.pop("Accept", "application/json") + # Construct URL _url = kwargs.pop("template_url", "/providers/Microsoft.Authorization/policyDefinitions/{policyDefinitionName}") path_format_arguments = { - "policyDefinitionName": _SERIALIZER.url("policy_definition_name", policy_definition_name, 'str'), + "policyDefinitionName": _SERIALIZER.url("policy_definition_name", policy_definition_name, "str"), } _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') - - return HttpRequest( - method="GET", - url=_url, - params=_query_parameters, - headers=_header_parameters, - **kwargs - ) + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) def build_policy_definitions_create_or_update_at_management_group_request( - policy_definition_name: str, - management_group_id: str, - *, - json: JSONType = None, - content: Any = None, - **kwargs: Any + policy_definition_name: str, management_group_id: str, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2019-06-01") # type: str - content_type = kwargs.pop('content_type', None) # type: Optional[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", "2019-06-01")) # type: str + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + accept = _headers.pop("Accept", "application/json") - accept = "application/json" # Construct URL - _url = kwargs.pop("template_url", "/providers/Microsoft.Management/managementgroups/{managementGroupId}/providers/Microsoft.Authorization/policyDefinitions/{policyDefinitionName}") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", + "/providers/Microsoft.Management/managementgroups/{managementGroupId}/providers/Microsoft.Authorization/policyDefinitions/{policyDefinitionName}", + ) # pylint: disable=line-too-long path_format_arguments = { - "policyDefinitionName": _SERIALIZER.url("policy_definition_name", policy_definition_name, 'str'), - "managementGroupId": _SERIALIZER.url("management_group_id", management_group_id, 'str'), + "policyDefinitionName": _SERIALIZER.url("policy_definition_name", policy_definition_name, "str"), + "managementGroupId": _SERIALIZER.url("management_group_id", management_group_id, "str"), } _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] if content_type is not None: - _header_parameters['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') - _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') - - return HttpRequest( - method="PUT", - url=_url, - params=_query_parameters, - headers=_header_parameters, - json=json, - content=content, - **kwargs - ) + _headers["Content-Type"] = _SERIALIZER.header("content_type", content_type, "str") + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="PUT", url=_url, params=_params, headers=_headers, **kwargs) def build_policy_definitions_delete_at_management_group_request( - policy_definition_name: str, - management_group_id: str, - **kwargs: Any + policy_definition_name: str, management_group_id: str, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2019-06-01") # type: str + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + api_version = kwargs.pop("api_version", _params.pop("api-version", "2019-06-01")) # type: str # Construct URL - _url = kwargs.pop("template_url", "/providers/Microsoft.Management/managementgroups/{managementGroupId}/providers/Microsoft.Authorization/policyDefinitions/{policyDefinitionName}") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", + "/providers/Microsoft.Management/managementgroups/{managementGroupId}/providers/Microsoft.Authorization/policyDefinitions/{policyDefinitionName}", + ) # pylint: disable=line-too-long path_format_arguments = { - "policyDefinitionName": _SERIALIZER.url("policy_definition_name", policy_definition_name, 'str'), - "managementGroupId": _SERIALIZER.url("management_group_id", management_group_id, 'str'), + "policyDefinitionName": _SERIALIZER.url("policy_definition_name", policy_definition_name, "str"), + "managementGroupId": _SERIALIZER.url("management_group_id", management_group_id, "str"), } _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') - - return HttpRequest( - method="DELETE", - url=_url, - params=_query_parameters, - **kwargs - ) + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") + + return HttpRequest(method="DELETE", url=_url, params=_params, **kwargs) def build_policy_definitions_get_at_management_group_request( - policy_definition_name: str, - management_group_id: str, - **kwargs: Any + policy_definition_name: str, management_group_id: str, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2019-06-01") # type: 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", "2019-06-01")) # type: str + accept = _headers.pop("Accept", "application/json") - accept = "application/json" # Construct URL - _url = kwargs.pop("template_url", "/providers/Microsoft.Management/managementgroups/{managementGroupId}/providers/Microsoft.Authorization/policyDefinitions/{policyDefinitionName}") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", + "/providers/Microsoft.Management/managementgroups/{managementGroupId}/providers/Microsoft.Authorization/policyDefinitions/{policyDefinitionName}", + ) # pylint: disable=line-too-long path_format_arguments = { - "policyDefinitionName": _SERIALIZER.url("policy_definition_name", policy_definition_name, 'str'), - "managementGroupId": _SERIALIZER.url("management_group_id", management_group_id, 'str'), + "policyDefinitionName": _SERIALIZER.url("policy_definition_name", policy_definition_name, "str"), + "managementGroupId": _SERIALIZER.url("management_group_id", management_group_id, "str"), } _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') - - return HttpRequest( - method="GET", - url=_url, - params=_query_parameters, - headers=_header_parameters, - **kwargs - ) + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) -def build_policy_definitions_list_request( - subscription_id: str, - **kwargs: Any -) -> HttpRequest: - api_version = kwargs.pop('api_version', "2019-06-01") # type: str - accept = "application/json" +def build_policy_definitions_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", "2019-06-01")) # type: str + accept = _headers.pop("Accept", "application/json") + # Construct URL - _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/providers/Microsoft.Authorization/policyDefinitions") + _url = kwargs.pop( + "template_url", "/subscriptions/{subscriptionId}/providers/Microsoft.Authorization/policyDefinitions" + ) path_format_arguments = { - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), } _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') - - return HttpRequest( - method="GET", - url=_url, - params=_query_parameters, - headers=_header_parameters, - **kwargs - ) + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) -def build_policy_definitions_list_built_in_request( - **kwargs: Any -) -> HttpRequest: - api_version = kwargs.pop('api_version', "2019-06-01") # type: str - accept = "application/json" +def build_policy_definitions_list_built_in_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", "2019-06-01")) # type: str + accept = _headers.pop("Accept", "application/json") + # Construct URL _url = kwargs.pop("template_url", "/providers/Microsoft.Authorization/policyDefinitions") # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') - - return HttpRequest( - method="GET", - url=_url, - params=_query_parameters, - headers=_header_parameters, - **kwargs - ) + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) -def build_policy_definitions_list_by_management_group_request( - management_group_id: str, - **kwargs: Any -) -> HttpRequest: - api_version = kwargs.pop('api_version', "2019-06-01") # type: str - accept = "application/json" +def build_policy_definitions_list_by_management_group_request(management_group_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", "2019-06-01")) # type: str + accept = _headers.pop("Accept", "application/json") + # Construct URL - _url = kwargs.pop("template_url", "/providers/Microsoft.Management/managementgroups/{managementGroupId}/providers/Microsoft.Authorization/policyDefinitions") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", + "/providers/Microsoft.Management/managementgroups/{managementGroupId}/providers/Microsoft.Authorization/policyDefinitions", + ) # pylint: disable=line-too-long path_format_arguments = { - "managementGroupId": _SERIALIZER.url("management_group_id", management_group_id, 'str'), + "managementGroupId": _SERIALIZER.url("management_group_id", management_group_id, "str"), } _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') - - return HttpRequest( - method="GET", - url=_url, - params=_query_parameters, - headers=_header_parameters, - **kwargs - ) + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) def build_policy_set_definitions_create_or_update_request( - policy_set_definition_name: str, - subscription_id: str, - *, - json: JSONType = None, - content: Any = None, - **kwargs: Any + policy_set_definition_name: str, subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2019-06-01") # type: str - content_type = kwargs.pop('content_type', None) # type: Optional[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", "2019-06-01")) # type: str + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + accept = _headers.pop("Accept", "application/json") - accept = "application/json" # Construct URL - _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/providers/Microsoft.Authorization/policySetDefinitions/{policySetDefinitionName}") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/providers/Microsoft.Authorization/policySetDefinitions/{policySetDefinitionName}", + ) # pylint: disable=line-too-long path_format_arguments = { - "policySetDefinitionName": _SERIALIZER.url("policy_set_definition_name", policy_set_definition_name, 'str'), - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), + "policySetDefinitionName": _SERIALIZER.url("policy_set_definition_name", policy_set_definition_name, "str"), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), } _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] if content_type is not None: - _header_parameters['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') - _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') - - return HttpRequest( - method="PUT", - url=_url, - params=_query_parameters, - headers=_header_parameters, - json=json, - content=content, - **kwargs - ) + _headers["Content-Type"] = _SERIALIZER.header("content_type", content_type, "str") + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="PUT", url=_url, params=_params, headers=_headers, **kwargs) def build_policy_set_definitions_delete_request( - policy_set_definition_name: str, - subscription_id: str, - **kwargs: Any + policy_set_definition_name: str, subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2019-06-01") # type: 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", "2019-06-01")) # type: str + accept = _headers.pop("Accept", "application/json") - accept = "application/json" # Construct URL - _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/providers/Microsoft.Authorization/policySetDefinitions/{policySetDefinitionName}") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/providers/Microsoft.Authorization/policySetDefinitions/{policySetDefinitionName}", + ) # pylint: disable=line-too-long path_format_arguments = { - "policySetDefinitionName": _SERIALIZER.url("policy_set_definition_name", policy_set_definition_name, 'str'), - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), + "policySetDefinitionName": _SERIALIZER.url("policy_set_definition_name", policy_set_definition_name, "str"), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), } _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') - - return HttpRequest( - method="DELETE", - url=_url, - params=_query_parameters, - headers=_header_parameters, - **kwargs - ) + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="DELETE", url=_url, params=_params, headers=_headers, **kwargs) def build_policy_set_definitions_get_request( - policy_set_definition_name: str, - subscription_id: str, - **kwargs: Any + policy_set_definition_name: str, subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2019-06-01") # type: 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", "2019-06-01")) # type: str + accept = _headers.pop("Accept", "application/json") - accept = "application/json" # Construct URL - _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/providers/Microsoft.Authorization/policySetDefinitions/{policySetDefinitionName}") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/providers/Microsoft.Authorization/policySetDefinitions/{policySetDefinitionName}", + ) # pylint: disable=line-too-long path_format_arguments = { - "policySetDefinitionName": _SERIALIZER.url("policy_set_definition_name", policy_set_definition_name, 'str'), - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), + "policySetDefinitionName": _SERIALIZER.url("policy_set_definition_name", policy_set_definition_name, "str"), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), } _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') - - return HttpRequest( - method="GET", - url=_url, - params=_query_parameters, - headers=_header_parameters, - **kwargs - ) + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) -def build_policy_set_definitions_get_built_in_request( - policy_set_definition_name: str, - **kwargs: Any -) -> HttpRequest: - api_version = kwargs.pop('api_version', "2019-06-01") # type: str - accept = "application/json" +def build_policy_set_definitions_get_built_in_request(policy_set_definition_name: 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", "2019-06-01")) # type: str + accept = _headers.pop("Accept", "application/json") + # Construct URL - _url = kwargs.pop("template_url", "/providers/Microsoft.Authorization/policySetDefinitions/{policySetDefinitionName}") + _url = kwargs.pop( + "template_url", "/providers/Microsoft.Authorization/policySetDefinitions/{policySetDefinitionName}" + ) path_format_arguments = { - "policySetDefinitionName": _SERIALIZER.url("policy_set_definition_name", policy_set_definition_name, 'str'), + "policySetDefinitionName": _SERIALIZER.url("policy_set_definition_name", policy_set_definition_name, "str"), } _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') - - return HttpRequest( - method="GET", - url=_url, - params=_query_parameters, - headers=_header_parameters, - **kwargs - ) + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) -def build_policy_set_definitions_list_request( - subscription_id: str, - **kwargs: Any -) -> HttpRequest: - api_version = kwargs.pop('api_version', "2019-06-01") # type: str - accept = "application/json" +def build_policy_set_definitions_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", "2019-06-01")) # type: str + accept = _headers.pop("Accept", "application/json") + # Construct URL - _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/providers/Microsoft.Authorization/policySetDefinitions") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", "/subscriptions/{subscriptionId}/providers/Microsoft.Authorization/policySetDefinitions" + ) # pylint: disable=line-too-long path_format_arguments = { - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), } _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') - - return HttpRequest( - method="GET", - url=_url, - params=_query_parameters, - headers=_header_parameters, - **kwargs - ) + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) -def build_policy_set_definitions_list_built_in_request( - **kwargs: Any -) -> HttpRequest: - api_version = kwargs.pop('api_version', "2019-06-01") # type: str - accept = "application/json" +def build_policy_set_definitions_list_built_in_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", "2019-06-01")) # type: str + accept = _headers.pop("Accept", "application/json") + # Construct URL _url = kwargs.pop("template_url", "/providers/Microsoft.Authorization/policySetDefinitions") # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') - - return HttpRequest( - method="GET", - url=_url, - params=_query_parameters, - headers=_header_parameters, - **kwargs - ) + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) def build_policy_set_definitions_create_or_update_at_management_group_request( - policy_set_definition_name: str, - management_group_id: str, - *, - json: JSONType = None, - content: Any = None, - **kwargs: Any + policy_set_definition_name: str, management_group_id: str, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2019-06-01") # type: str - content_type = kwargs.pop('content_type', None) # type: Optional[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", "2019-06-01")) # type: str + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + accept = _headers.pop("Accept", "application/json") - accept = "application/json" # Construct URL - _url = kwargs.pop("template_url", "/providers/Microsoft.Management/managementgroups/{managementGroupId}/providers/Microsoft.Authorization/policySetDefinitions/{policySetDefinitionName}") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", + "/providers/Microsoft.Management/managementgroups/{managementGroupId}/providers/Microsoft.Authorization/policySetDefinitions/{policySetDefinitionName}", + ) # pylint: disable=line-too-long path_format_arguments = { - "policySetDefinitionName": _SERIALIZER.url("policy_set_definition_name", policy_set_definition_name, 'str'), - "managementGroupId": _SERIALIZER.url("management_group_id", management_group_id, 'str'), + "policySetDefinitionName": _SERIALIZER.url("policy_set_definition_name", policy_set_definition_name, "str"), + "managementGroupId": _SERIALIZER.url("management_group_id", management_group_id, "str"), } _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] if content_type is not None: - _header_parameters['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') - _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') - - return HttpRequest( - method="PUT", - url=_url, - params=_query_parameters, - headers=_header_parameters, - json=json, - content=content, - **kwargs - ) + _headers["Content-Type"] = _SERIALIZER.header("content_type", content_type, "str") + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="PUT", url=_url, params=_params, headers=_headers, **kwargs) def build_policy_set_definitions_delete_at_management_group_request( - policy_set_definition_name: str, - management_group_id: str, - **kwargs: Any + policy_set_definition_name: str, management_group_id: str, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2019-06-01") # type: 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", "2019-06-01")) # type: str + accept = _headers.pop("Accept", "application/json") - accept = "application/json" # Construct URL - _url = kwargs.pop("template_url", "/providers/Microsoft.Management/managementgroups/{managementGroupId}/providers/Microsoft.Authorization/policySetDefinitions/{policySetDefinitionName}") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", + "/providers/Microsoft.Management/managementgroups/{managementGroupId}/providers/Microsoft.Authorization/policySetDefinitions/{policySetDefinitionName}", + ) # pylint: disable=line-too-long path_format_arguments = { - "policySetDefinitionName": _SERIALIZER.url("policy_set_definition_name", policy_set_definition_name, 'str'), - "managementGroupId": _SERIALIZER.url("management_group_id", management_group_id, 'str'), + "policySetDefinitionName": _SERIALIZER.url("policy_set_definition_name", policy_set_definition_name, "str"), + "managementGroupId": _SERIALIZER.url("management_group_id", management_group_id, "str"), } _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') - - return HttpRequest( - method="DELETE", - url=_url, - params=_query_parameters, - headers=_header_parameters, - **kwargs - ) + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="DELETE", url=_url, params=_params, headers=_headers, **kwargs) def build_policy_set_definitions_get_at_management_group_request( - policy_set_definition_name: str, - management_group_id: str, - **kwargs: Any + policy_set_definition_name: str, management_group_id: str, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2019-06-01") # type: 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", "2019-06-01")) # type: str + accept = _headers.pop("Accept", "application/json") - accept = "application/json" # Construct URL - _url = kwargs.pop("template_url", "/providers/Microsoft.Management/managementgroups/{managementGroupId}/providers/Microsoft.Authorization/policySetDefinitions/{policySetDefinitionName}") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", + "/providers/Microsoft.Management/managementgroups/{managementGroupId}/providers/Microsoft.Authorization/policySetDefinitions/{policySetDefinitionName}", + ) # pylint: disable=line-too-long path_format_arguments = { - "policySetDefinitionName": _SERIALIZER.url("policy_set_definition_name", policy_set_definition_name, 'str'), - "managementGroupId": _SERIALIZER.url("management_group_id", management_group_id, 'str'), + "policySetDefinitionName": _SERIALIZER.url("policy_set_definition_name", policy_set_definition_name, "str"), + "managementGroupId": _SERIALIZER.url("management_group_id", management_group_id, "str"), } _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') - - return HttpRequest( - method="GET", - url=_url, - params=_query_parameters, - headers=_header_parameters, - **kwargs - ) + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) def build_policy_set_definitions_list_by_management_group_request( - management_group_id: str, - **kwargs: Any + management_group_id: str, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2019-06-01") # type: 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", "2019-06-01")) # type: str + accept = _headers.pop("Accept", "application/json") - accept = "application/json" # Construct URL - _url = kwargs.pop("template_url", "/providers/Microsoft.Management/managementgroups/{managementGroupId}/providers/Microsoft.Authorization/policySetDefinitions") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", + "/providers/Microsoft.Management/managementgroups/{managementGroupId}/providers/Microsoft.Authorization/policySetDefinitions", + ) # pylint: disable=line-too-long path_format_arguments = { - "managementGroupId": _SERIALIZER.url("management_group_id", management_group_id, 'str'), + "managementGroupId": _SERIALIZER.url("management_group_id", management_group_id, "str"), } _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') - - return HttpRequest( - method="GET", - url=_url, - params=_query_parameters, - headers=_header_parameters, - **kwargs - ) + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") -class PolicyAssignmentsOperations(object): - """PolicyAssignmentsOperations operations. + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) - You should not instantiate this class directly. Instead, you should create a Client instance that - instantiates it for you and attaches it as an attribute. - :ivar models: Alias to model classes used in this operation group. - :type models: ~azure.mgmt.resource.policy.v2019_06_01.models - :param client: Client for service requests. - :param config: Configuration of service client. - :param serializer: An object model serializer. - :param deserializer: An object model deserializer. +class PolicyAssignmentsOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. + + Instead, you should access the following operations through + :class:`~azure.mgmt.resource.policy.v2019_06_01.PolicyClient`'s + :attr:`policy_assignments` attribute. """ models = _models - def __init__(self, client, config, serializer, deserializer): - self._client = client - self._serialize = serializer - self._deserialize = deserializer - self._config = config + def __init__(self, *args, **kwargs): + input_args = list(args) + self._client = input_args.pop(0) if input_args else kwargs.pop("client") + self._config = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") @distributed_trace - def delete( - self, - scope: str, - policy_assignment_name: str, - **kwargs: Any - ) -> Optional["_models.PolicyAssignment"]: + def delete(self, scope: str, policy_assignment_name: str, **kwargs: Any) -> Optional[_models.PolicyAssignment]: """Deletes a policy assignment. This operation deletes a policy assignment, given its name and the scope it was created in. The @@ -1072,37 +893,44 @@ def delete( '/subscriptions/{subscriptionId}'), resource group (format: '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}', or resource (format: '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{resourceProviderNamespace}/[{parentResourcePath}/]{resourceType}/{resourceName}'. + Required. :type scope: str - :param policy_assignment_name: The name of the policy assignment to delete. + :param policy_assignment_name: The name of the policy assignment to delete. Required. :type policy_assignment_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: PolicyAssignment, or the result of cls(response) + :return: PolicyAssignment or None or the result of cls(response) :rtype: ~azure.mgmt.resource.policy.v2019_06_01.models.PolicyAssignment or None - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType[Optional["_models.PolicyAssignment"]] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) - api_version = kwargs.pop('api_version', "2019-06-01") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2019-06-01")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[Optional[_models.PolicyAssignment]] - request = build_policy_assignments_delete_request( scope=scope, policy_assignment_name=policy_assignment_name, api_version=api_version, - template_url=self.delete.metadata['url'], + template_url=self.delete.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200, 204]: @@ -1112,24 +940,25 @@ def delete( deserialized = None if response.status_code == 200: - deserialized = self._deserialize('PolicyAssignment', pipeline_response) + deserialized = self._deserialize("PolicyAssignment", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - delete.metadata = {'url': "/{scope}/providers/Microsoft.Authorization/policyAssignments/{policyAssignmentName}"} # type: ignore - + delete.metadata = {"url": "/{scope}/providers/Microsoft.Authorization/policyAssignments/{policyAssignmentName}"} # type: ignore - @distributed_trace + @overload def create( self, scope: str, policy_assignment_name: str, - parameters: "_models.PolicyAssignment", + parameters: _models.PolicyAssignment, + *, + content_type: str = "application/json", **kwargs: Any - ) -> "_models.PolicyAssignment": + ) -> _models.PolicyAssignment: """Creates or updates a policy assignment. This operation creates or updates a policy assignment with the given scope and name. Policy @@ -1141,26 +970,109 @@ def create( '/subscriptions/{subscriptionId}'), resource group (format: '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}', or resource (format: '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{resourceProviderNamespace}/[{parentResourcePath}/]{resourceType}/{resourceName}'. + Required. :type scope: str - :param policy_assignment_name: The name of the policy assignment. + :param policy_assignment_name: The name of the policy assignment. Required. :type policy_assignment_name: str - :param parameters: Parameters for the policy assignment. + :param parameters: Parameters for the policy assignment. Required. :type parameters: ~azure.mgmt.resource.policy.v2019_06_01.models.PolicyAssignment + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: PolicyAssignment or the result of cls(response) + :rtype: ~azure.mgmt.resource.policy.v2019_06_01.models.PolicyAssignment + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + def create( + self, + scope: str, + policy_assignment_name: str, + parameters: IO, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.PolicyAssignment: + """Creates or updates a policy assignment. + + This operation creates or updates a policy assignment with the given scope and name. Policy + assignments apply to all resources contained within their scope. For example, when you assign a + policy at resource group scope, that policy applies to all resources in the group. + + :param scope: The scope of the policy assignment. Valid scopes are: management group (format: + '/providers/Microsoft.Management/managementGroups/{managementGroup}'), subscription (format: + '/subscriptions/{subscriptionId}'), resource group (format: + '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}', or resource (format: + '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{resourceProviderNamespace}/[{parentResourcePath}/]{resourceType}/{resourceName}'. + Required. + :type scope: str + :param policy_assignment_name: The name of the policy assignment. Required. + :type policy_assignment_name: str + :param parameters: Parameters for the policy assignment. Required. + :type parameters: IO + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: PolicyAssignment or the result of cls(response) + :rtype: ~azure.mgmt.resource.policy.v2019_06_01.models.PolicyAssignment + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace + def create( + self, scope: str, policy_assignment_name: str, parameters: Union[_models.PolicyAssignment, IO], **kwargs: Any + ) -> _models.PolicyAssignment: + """Creates or updates a policy assignment. + + This operation creates or updates a policy assignment with the given scope and name. Policy + assignments apply to all resources contained within their scope. For example, when you assign a + policy at resource group scope, that policy applies to all resources in the group. + + :param scope: The scope of the policy assignment. Valid scopes are: management group (format: + '/providers/Microsoft.Management/managementGroups/{managementGroup}'), subscription (format: + '/subscriptions/{subscriptionId}'), resource group (format: + '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}', or resource (format: + '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{resourceProviderNamespace}/[{parentResourcePath}/]{resourceType}/{resourceName}'. + Required. + :type scope: str + :param policy_assignment_name: The name of the policy assignment. Required. + :type policy_assignment_name: str + :param parameters: Parameters for the policy assignment. Is either a model type or a IO type. + Required. + :type parameters: ~azure.mgmt.resource.policy.v2019_06_01.models.PolicyAssignment or IO + :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. + Default value is None. + :paramtype content_type: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: PolicyAssignment, or the result of cls(response) + :return: PolicyAssignment or the result of cls(response) :rtype: ~azure.mgmt.resource.policy.v2019_06_01.models.PolicyAssignment - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.PolicyAssignment"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', "2019-06-01") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + api_version = kwargs.pop("api_version", _params.pop("api-version", "2019-06-01")) # type: str + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.PolicyAssignment] - _json = self._serialize.body(parameters, 'PolicyAssignment') + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(parameters, (IO, bytes)): + _content = parameters + else: + _json = self._serialize.body(parameters, "PolicyAssignment") request = build_policy_assignments_create_request( scope=scope, @@ -1168,16 +1080,18 @@ def create( api_version=api_version, content_type=content_type, json=_json, - template_url=self.create.metadata['url'], + content=_content, + template_url=self.create.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [201]: @@ -1185,23 +1099,17 @@ def create( error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - deserialized = self._deserialize('PolicyAssignment', pipeline_response) + deserialized = self._deserialize("PolicyAssignment", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - create.metadata = {'url': "/{scope}/providers/Microsoft.Authorization/policyAssignments/{policyAssignmentName}"} # type: ignore - + create.metadata = {"url": "/{scope}/providers/Microsoft.Authorization/policyAssignments/{policyAssignmentName}"} # type: ignore @distributed_trace - def get( - self, - scope: str, - policy_assignment_name: str, - **kwargs: Any - ) -> "_models.PolicyAssignment": + def get(self, scope: str, policy_assignment_name: str, **kwargs: Any) -> _models.PolicyAssignment: """Retrieves a policy assignment. This operation retrieves a single policy assignment, given its name and the scope it was @@ -1212,37 +1120,44 @@ def get( '/subscriptions/{subscriptionId}'), resource group (format: '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}', or resource (format: '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{resourceProviderNamespace}/[{parentResourcePath}/]{resourceType}/{resourceName}'. + Required. :type scope: str - :param policy_assignment_name: The name of the policy assignment to get. + :param policy_assignment_name: The name of the policy assignment to get. Required. :type policy_assignment_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: PolicyAssignment, or the result of cls(response) + :return: PolicyAssignment or the result of cls(response) :rtype: ~azure.mgmt.resource.policy.v2019_06_01.models.PolicyAssignment - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.PolicyAssignment"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + 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', "2019-06-01") # type: str + api_version = kwargs.pop("api_version", _params.pop("api-version", "2019-06-01")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[_models.PolicyAssignment] - request = build_policy_assignments_get_request( scope=scope, policy_assignment_name=policy_assignment_name, api_version=api_version, - template_url=self.get.metadata['url'], + template_url=self.get.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200]: @@ -1250,23 +1165,19 @@ def get( error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - deserialized = self._deserialize('PolicyAssignment', pipeline_response) + deserialized = self._deserialize("PolicyAssignment", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - get.metadata = {'url': "/{scope}/providers/Microsoft.Authorization/policyAssignments/{policyAssignmentName}"} # type: ignore - + get.metadata = {"url": "/{scope}/providers/Microsoft.Authorization/policyAssignments/{policyAssignmentName}"} # type: ignore @distributed_trace def list_for_resource_group( - self, - resource_group_name: str, - filter: Optional[str] = None, - **kwargs: Any - ) -> Iterable["_models.PolicyAssignmentListResult"]: + self, resource_group_name: str, filter: Optional[str] = None, **kwargs: Any + ) -> Iterable["_models.PolicyAssignment"]: """Retrieves all policy assignments that apply to a resource group. This operation retrieves the list of all policy assignments associated with the given resource @@ -1281,47 +1192,55 @@ def list_for_resource_group( assignments of the policy definition whose id is {value} that apply to the resource group. :param resource_group_name: The name of the resource group that contains policy assignments. + Required. :type resource_group_name: str :param filter: The filter to apply on the operation. Valid values for $filter are: 'atScope()' or 'policyDefinitionId eq '{value}''. If $filter is not provided, no filtering is performed. Default value is None. :type filter: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either PolicyAssignmentListResult or the result of - cls(response) + :return: An iterator like instance of either PolicyAssignment or the result of cls(response) :rtype: - ~azure.core.paging.ItemPaged[~azure.mgmt.resource.policy.v2019_06_01.models.PolicyAssignmentListResult] - :raises: ~azure.core.exceptions.HttpResponseError + ~azure.core.paging.ItemPaged[~azure.mgmt.resource.policy.v2019_06_01.models.PolicyAssignment] + :raises ~azure.core.exceptions.HttpResponseError: """ - api_version = kwargs.pop('api_version', "2019-06-01") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2019-06-01")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[_models.PolicyAssignmentListResult] - cls = kwargs.pop('cls', None) # type: ClsType["_models.PolicyAssignmentListResult"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) + def prepare_request(next_link=None): if not next_link: - + request = build_policy_assignments_list_for_resource_group_request( resource_group_name=resource_group_name, subscription_id=self._config.subscription_id, - api_version=api_version, filter=filter, - template_url=self.list_for_resource_group.metadata['url'], + api_version=api_version, + template_url=self.list_for_resource_group.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore else: - - request = build_policy_assignments_list_for_resource_group_request( - resource_group_name=resource_group_name, - subscription_id=self._config.subscription_id, - template_url=next_link, - ) + # make call to next link with the client's api-version + _parsed_next_link = urlparse(next_link) + _next_request_params = case_insensitive_dict(parse_qs(_parsed_next_link.query)) + _next_request_params["api-version"] = self._config.api_version + request = HttpRequest("GET", urljoin(next_link, _parsed_next_link.path), params=_next_request_params) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore request.method = "GET" return request @@ -1335,10 +1254,8 @@ def extract_data(pipeline_response): def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) response = pipeline_response.http_response @@ -1349,11 +1266,9 @@ def get_next(next_link=None): return pipeline_response + return ItemPaged(get_next, extract_data) - return ItemPaged( - get_next, extract_data - ) - list_for_resource_group.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Authorization/policyAssignments"} # type: ignore + list_for_resource_group.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Authorization/policyAssignments"} # type: ignore @distributed_trace def list_for_resource( @@ -1365,7 +1280,7 @@ def list_for_resource( resource_name: str, filter: Optional[str] = None, **kwargs: Any - ) -> Iterable["_models.PolicyAssignmentListResult"]: + ) -> Iterable["_models.PolicyAssignment"]: """Retrieves all policy assignments that apply to a resource. This operation retrieves the list of all policy assignments associated with the specified @@ -1391,39 +1306,47 @@ def list_for_resource( {parentResourcePath} == '', {resourceType} == 'Microsoft.Web/sites', {resourceName} == 'MyWebApp'). - :param resource_group_name: The name of the resource group containing the resource. + :param resource_group_name: The name of the resource group containing the resource. Required. :type resource_group_name: str :param resource_provider_namespace: The namespace of the resource provider. For example, the namespace of a virtual machine is Microsoft.Compute (from Microsoft.Compute/virtualMachines). + Required. :type resource_provider_namespace: str :param parent_resource_path: The parent resource path. Use empty string if there is none. + Required. :type parent_resource_path: str :param resource_type: The resource type name. For example the type name of a web app is 'sites' - (from Microsoft.Web/sites). + (from Microsoft.Web/sites). Required. :type resource_type: str - :param resource_name: The name of the resource. + :param resource_name: The name of the resource. Required. :type resource_name: str :param filter: The filter to apply on the operation. Valid values for $filter are: 'atScope()' or 'policyDefinitionId eq '{value}''. If $filter is not provided, no filtering is performed. Default value is None. :type filter: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either PolicyAssignmentListResult or the result of - cls(response) + :return: An iterator like instance of either PolicyAssignment or the result of cls(response) :rtype: - ~azure.core.paging.ItemPaged[~azure.mgmt.resource.policy.v2019_06_01.models.PolicyAssignmentListResult] - :raises: ~azure.core.exceptions.HttpResponseError + ~azure.core.paging.ItemPaged[~azure.mgmt.resource.policy.v2019_06_01.models.PolicyAssignment] + :raises ~azure.core.exceptions.HttpResponseError: """ - api_version = kwargs.pop('api_version', "2019-06-01") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2019-06-01")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[_models.PolicyAssignmentListResult] - cls = kwargs.pop('cls', None) # type: ClsType["_models.PolicyAssignmentListResult"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) + def prepare_request(next_link=None): if not next_link: - + request = build_policy_assignments_list_for_resource_request( resource_group_name=resource_group_name, resource_provider_namespace=resource_provider_namespace, @@ -1431,26 +1354,23 @@ def prepare_request(next_link=None): resource_type=resource_type, resource_name=resource_name, subscription_id=self._config.subscription_id, - api_version=api_version, filter=filter, - template_url=self.list_for_resource.metadata['url'], + api_version=api_version, + template_url=self.list_for_resource.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore else: - - request = build_policy_assignments_list_for_resource_request( - resource_group_name=resource_group_name, - resource_provider_namespace=resource_provider_namespace, - parent_resource_path=parent_resource_path, - resource_type=resource_type, - resource_name=resource_name, - subscription_id=self._config.subscription_id, - template_url=next_link, - ) + # make call to next link with the client's api-version + _parsed_next_link = urlparse(next_link) + _next_request_params = case_insensitive_dict(parse_qs(_parsed_next_link.query)) + _next_request_params["api-version"] = self._config.api_version + request = HttpRequest("GET", urljoin(next_link, _parsed_next_link.path), params=_next_request_params) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore request.method = "GET" return request @@ -1464,10 +1384,8 @@ def extract_data(pipeline_response): def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) response = pipeline_response.http_response @@ -1478,18 +1396,12 @@ def get_next(next_link=None): return pipeline_response + return ItemPaged(get_next, extract_data) - return ItemPaged( - get_next, extract_data - ) - list_for_resource.metadata = {'url': "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{parentResourcePath}/{resourceType}/{resourceName}/providers/Microsoft.Authorization/policyAssignments"} # type: ignore + list_for_resource.metadata = {"url": "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{parentResourcePath}/{resourceType}/{resourceName}/providers/Microsoft.Authorization/policyAssignments"} # type: ignore @distributed_trace - def list( - self, - filter: Optional[str] = None, - **kwargs: Any - ) -> Iterable["_models.PolicyAssignmentListResult"]: + def list(self, filter: Optional[str] = None, **kwargs: Any) -> Iterable["_models.PolicyAssignment"]: """Retrieves all policy assignments that apply to a subscription. This operation retrieves the list of all policy assignments associated with the given @@ -1508,39 +1420,47 @@ def list( Default value is None. :type filter: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either PolicyAssignmentListResult or the result of - cls(response) + :return: An iterator like instance of either PolicyAssignment or the result of cls(response) :rtype: - ~azure.core.paging.ItemPaged[~azure.mgmt.resource.policy.v2019_06_01.models.PolicyAssignmentListResult] - :raises: ~azure.core.exceptions.HttpResponseError + ~azure.core.paging.ItemPaged[~azure.mgmt.resource.policy.v2019_06_01.models.PolicyAssignment] + :raises ~azure.core.exceptions.HttpResponseError: """ - api_version = kwargs.pop('api_version', "2019-06-01") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2019-06-01")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[_models.PolicyAssignmentListResult] - cls = kwargs.pop('cls', None) # type: ClsType["_models.PolicyAssignmentListResult"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) + def prepare_request(next_link=None): if not next_link: - + request = build_policy_assignments_list_request( subscription_id=self._config.subscription_id, - api_version=api_version, filter=filter, - template_url=self.list.metadata['url'], + 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.url = self._client.format_url(request.url) # type: ignore else: - - request = build_policy_assignments_list_request( - subscription_id=self._config.subscription_id, - template_url=next_link, - ) + # make call to next link with the client's api-version + _parsed_next_link = urlparse(next_link) + _next_request_params = case_insensitive_dict(parse_qs(_parsed_next_link.query)) + _next_request_params["api-version"] = self._config.api_version + request = HttpRequest("GET", urljoin(next_link, _parsed_next_link.path), params=_next_request_params) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore request.method = "GET" return request @@ -1554,10 +1474,8 @@ def extract_data(pipeline_response): def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) response = pipeline_response.http_response @@ -1568,18 +1486,12 @@ def get_next(next_link=None): return pipeline_response + return ItemPaged(get_next, extract_data) - return ItemPaged( - get_next, extract_data - ) - list.metadata = {'url': "/subscriptions/{subscriptionId}/providers/Microsoft.Authorization/policyAssignments"} # type: ignore + list.metadata = {"url": "/subscriptions/{subscriptionId}/providers/Microsoft.Authorization/policyAssignments"} # type: ignore @distributed_trace - def delete_by_id( - self, - policy_assignment_id: str, - **kwargs: Any - ) -> Optional["_models.PolicyAssignment"]: + def delete_by_id(self, policy_assignment_id: str, **kwargs: Any) -> Optional[_models.PolicyAssignment]: """Deletes a policy assignment. This operation deletes the policy with the given ID. Policy assignment IDs have this format: @@ -1591,35 +1503,41 @@ def delete_by_id( (resource). :param policy_assignment_id: The ID of the policy assignment to delete. Use the format - '{scope}/providers/Microsoft.Authorization/policyAssignments/{policyAssignmentName}'. + '{scope}/providers/Microsoft.Authorization/policyAssignments/{policyAssignmentName}'. Required. :type policy_assignment_id: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: PolicyAssignment, or the result of cls(response) + :return: PolicyAssignment or None or the result of cls(response) :rtype: ~azure.mgmt.resource.policy.v2019_06_01.models.PolicyAssignment or None - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType[Optional["_models.PolicyAssignment"]] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + 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', "2019-06-01") # type: str + api_version = kwargs.pop("api_version", _params.pop("api-version", "2019-06-01")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[Optional[_models.PolicyAssignment]] - request = build_policy_assignments_delete_by_id_request( policy_assignment_id=policy_assignment_id, api_version=api_version, - template_url=self.delete_by_id.metadata['url'], + template_url=self.delete_by_id.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200, 204]: @@ -1629,23 +1547,24 @@ def delete_by_id( deserialized = None if response.status_code == 200: - deserialized = self._deserialize('PolicyAssignment', pipeline_response) + deserialized = self._deserialize("PolicyAssignment", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - delete_by_id.metadata = {'url': "/{policyAssignmentId}"} # type: ignore + delete_by_id.metadata = {"url": "/{policyAssignmentId}"} # type: ignore - - @distributed_trace + @overload def create_by_id( self, policy_assignment_id: str, - parameters: "_models.PolicyAssignment", + parameters: _models.PolicyAssignment, + *, + content_type: str = "application/json", **kwargs: Any - ) -> "_models.PolicyAssignment": + ) -> _models.PolicyAssignment: """Creates or updates a policy assignment. This operation creates or updates the policy assignment with the given ID. Policy assignments @@ -1660,41 +1579,121 @@ def create_by_id( '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{resourceProviderNamespace}/[{parentResourcePath}/]{resourceType}/{resourceName}'. :param policy_assignment_id: The ID of the policy assignment to create. Use the format - '{scope}/providers/Microsoft.Authorization/policyAssignments/{policyAssignmentName}'. + '{scope}/providers/Microsoft.Authorization/policyAssignments/{policyAssignmentName}'. Required. :type policy_assignment_id: str - :param parameters: Parameters for policy assignment. + :param parameters: Parameters for policy assignment. Required. :type parameters: ~azure.mgmt.resource.policy.v2019_06_01.models.PolicyAssignment + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: PolicyAssignment or the result of cls(response) + :rtype: ~azure.mgmt.resource.policy.v2019_06_01.models.PolicyAssignment + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + def create_by_id( + self, policy_assignment_id: str, parameters: IO, *, content_type: str = "application/json", **kwargs: Any + ) -> _models.PolicyAssignment: + """Creates or updates a policy assignment. + + This operation creates or updates the policy assignment with the given ID. Policy assignments + made on a scope apply to all resources contained in that scope. For example, when you assign a + policy to a resource group that policy applies to all resources in the group. Policy assignment + IDs have this format: + '{scope}/providers/Microsoft.Authorization/policyAssignments/{policyAssignmentName}'. Valid + scopes are: management group (format: + '/providers/Microsoft.Management/managementGroups/{managementGroup}'), subscription (format: + '/subscriptions/{subscriptionId}'), resource group (format: + '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}', or resource (format: + '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{resourceProviderNamespace}/[{parentResourcePath}/]{resourceType}/{resourceName}'. + + :param policy_assignment_id: The ID of the policy assignment to create. Use the format + '{scope}/providers/Microsoft.Authorization/policyAssignments/{policyAssignmentName}'. Required. + :type policy_assignment_id: str + :param parameters: Parameters for policy assignment. Required. + :type parameters: IO + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: PolicyAssignment, or the result of cls(response) + :return: PolicyAssignment or the result of cls(response) :rtype: ~azure.mgmt.resource.policy.v2019_06_01.models.PolicyAssignment - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace + def create_by_id( + self, policy_assignment_id: str, parameters: Union[_models.PolicyAssignment, IO], **kwargs: Any + ) -> _models.PolicyAssignment: + """Creates or updates a policy assignment. + + This operation creates or updates the policy assignment with the given ID. Policy assignments + made on a scope apply to all resources contained in that scope. For example, when you assign a + policy to a resource group that policy applies to all resources in the group. Policy assignment + IDs have this format: + '{scope}/providers/Microsoft.Authorization/policyAssignments/{policyAssignmentName}'. Valid + scopes are: management group (format: + '/providers/Microsoft.Management/managementGroups/{managementGroup}'), subscription (format: + '/subscriptions/{subscriptionId}'), resource group (format: + '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}', or resource (format: + '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{resourceProviderNamespace}/[{parentResourcePath}/]{resourceType}/{resourceName}'. + + :param policy_assignment_id: The ID of the policy assignment to create. Use the format + '{scope}/providers/Microsoft.Authorization/policyAssignments/{policyAssignmentName}'. Required. + :type policy_assignment_id: str + :param parameters: Parameters for policy assignment. Is either a model type or a IO type. + Required. + :type parameters: ~azure.mgmt.resource.policy.v2019_06_01.models.PolicyAssignment or IO + :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. + Default value is None. + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: PolicyAssignment or the result of cls(response) + :rtype: ~azure.mgmt.resource.policy.v2019_06_01.models.PolicyAssignment + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.PolicyAssignment"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) - api_version = kwargs.pop('api_version', "2019-06-01") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - _json = self._serialize.body(parameters, 'PolicyAssignment') + api_version = kwargs.pop("api_version", _params.pop("api-version", "2019-06-01")) # type: str + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.PolicyAssignment] + + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(parameters, (IO, bytes)): + _content = parameters + else: + _json = self._serialize.body(parameters, "PolicyAssignment") request = build_policy_assignments_create_by_id_request( policy_assignment_id=policy_assignment_id, api_version=api_version, content_type=content_type, json=_json, - template_url=self.create_by_id.metadata['url'], + content=_content, + template_url=self.create_by_id.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [201]: @@ -1702,22 +1701,17 @@ def create_by_id( error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - deserialized = self._deserialize('PolicyAssignment', pipeline_response) + deserialized = self._deserialize("PolicyAssignment", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - create_by_id.metadata = {'url': "/{policyAssignmentId}"} # type: ignore - + create_by_id.metadata = {"url": "/{policyAssignmentId}"} # type: ignore @distributed_trace - def get_by_id( - self, - policy_assignment_id: str, - **kwargs: Any - ) -> "_models.PolicyAssignment": + def get_by_id(self, policy_assignment_id: str, **kwargs: Any) -> _models.PolicyAssignment: """Retrieves the policy assignment with the given ID. The operation retrieves the policy assignment with the given ID. Policy assignment IDs have @@ -1730,35 +1724,41 @@ def get_by_id( '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{resourceProviderNamespace}/[{parentResourcePath}/]{resourceType}/{resourceName}'. :param policy_assignment_id: The ID of the policy assignment to get. Use the format - '{scope}/providers/Microsoft.Authorization/policyAssignments/{policyAssignmentName}'. + '{scope}/providers/Microsoft.Authorization/policyAssignments/{policyAssignmentName}'. Required. :type policy_assignment_id: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: PolicyAssignment, or the result of cls(response) + :return: PolicyAssignment or the result of cls(response) :rtype: ~azure.mgmt.resource.policy.v2019_06_01.models.PolicyAssignment - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.PolicyAssignment"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) - api_version = kwargs.pop('api_version', "2019-06-01") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2019-06-01")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[_models.PolicyAssignment] - request = build_policy_assignments_get_by_id_request( policy_assignment_id=policy_assignment_id, api_version=api_version, - template_url=self.get_by_id.metadata['url'], + template_url=self.get_by_id.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200]: @@ -1766,68 +1766,128 @@ def get_by_id( error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - deserialized = self._deserialize('PolicyAssignment', pipeline_response) + deserialized = self._deserialize("PolicyAssignment", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - get_by_id.metadata = {'url': "/{policyAssignmentId}"} # type: ignore + get_by_id.metadata = {"url": "/{policyAssignmentId}"} # type: ignore -class PolicyDefinitionsOperations(object): - """PolicyDefinitionsOperations operations. - You should not instantiate this class directly. Instead, you should create a Client instance that - instantiates it for you and attaches it as an attribute. +class PolicyDefinitionsOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. - :ivar models: Alias to model classes used in this operation group. - :type models: ~azure.mgmt.resource.policy.v2019_06_01.models - :param client: Client for service requests. - :param config: Configuration of service client. - :param serializer: An object model serializer. - :param deserializer: An object model deserializer. + Instead, you should access the following operations through + :class:`~azure.mgmt.resource.policy.v2019_06_01.PolicyClient`'s + :attr:`policy_definitions` attribute. """ models = _models - def __init__(self, client, config, serializer, deserializer): - self._client = client - self._serialize = serializer - self._deserialize = deserializer - self._config = config + def __init__(self, *args, **kwargs): + input_args = list(args) + self._client = input_args.pop(0) if input_args else kwargs.pop("client") + self._config = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") - @distributed_trace + @overload def create_or_update( self, policy_definition_name: str, - parameters: "_models.PolicyDefinition", + parameters: _models.PolicyDefinition, + *, + content_type: str = "application/json", **kwargs: Any - ) -> "_models.PolicyDefinition": + ) -> _models.PolicyDefinition: """Creates or updates a policy definition in a subscription. This operation creates or updates a policy definition in the given subscription with the given name. - :param policy_definition_name: The name of the policy definition to create. + :param policy_definition_name: The name of the policy definition to create. Required. :type policy_definition_name: str - :param parameters: The policy definition properties. + :param parameters: The policy definition properties. Required. :type parameters: ~azure.mgmt.resource.policy.v2019_06_01.models.PolicyDefinition + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: PolicyDefinition or the result of cls(response) + :rtype: ~azure.mgmt.resource.policy.v2019_06_01.models.PolicyDefinition + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + def create_or_update( + self, policy_definition_name: str, parameters: IO, *, content_type: str = "application/json", **kwargs: Any + ) -> _models.PolicyDefinition: + """Creates or updates a policy definition in a subscription. + + This operation creates or updates a policy definition in the given subscription with the given + name. + + :param policy_definition_name: The name of the policy definition to create. Required. + :type policy_definition_name: str + :param parameters: The policy definition properties. Required. + :type parameters: IO + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: PolicyDefinition or the result of cls(response) + :rtype: ~azure.mgmt.resource.policy.v2019_06_01.models.PolicyDefinition + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace + def create_or_update( + self, policy_definition_name: str, parameters: Union[_models.PolicyDefinition, IO], **kwargs: Any + ) -> _models.PolicyDefinition: + """Creates or updates a policy definition in a subscription. + + This operation creates or updates a policy definition in the given subscription with the given + name. + + :param policy_definition_name: The name of the policy definition to create. Required. + :type policy_definition_name: str + :param parameters: The policy definition properties. Is either a model type or a IO type. + Required. + :type parameters: ~azure.mgmt.resource.policy.v2019_06_01.models.PolicyDefinition or IO + :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. + Default value is None. + :paramtype content_type: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: PolicyDefinition, or the result of cls(response) + :return: PolicyDefinition or the result of cls(response) :rtype: ~azure.mgmt.resource.policy.v2019_06_01.models.PolicyDefinition - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.PolicyDefinition"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) - api_version = kwargs.pop('api_version', "2019-06-01") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - _json = self._serialize.body(parameters, 'PolicyDefinition') + api_version = kwargs.pop("api_version", _params.pop("api-version", "2019-06-01")) # type: str + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.PolicyDefinition] + + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(parameters, (IO, bytes)): + _content = parameters + else: + _json = self._serialize.body(parameters, "PolicyDefinition") request = build_policy_definitions_create_or_update_request( policy_definition_name=policy_definition_name, @@ -1835,72 +1895,77 @@ def create_or_update( api_version=api_version, content_type=content_type, json=_json, - template_url=self.create_or_update.metadata['url'], + content=_content, + template_url=self.create_or_update.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [201]: map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) - deserialized = self._deserialize('PolicyDefinition', pipeline_response) + deserialized = self._deserialize("PolicyDefinition", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - create_or_update.metadata = {'url': "/subscriptions/{subscriptionId}/providers/Microsoft.Authorization/policyDefinitions/{policyDefinitionName}"} # type: ignore - + create_or_update.metadata = {"url": "/subscriptions/{subscriptionId}/providers/Microsoft.Authorization/policyDefinitions/{policyDefinitionName}"} # type: ignore @distributed_trace def delete( # pylint: disable=inconsistent-return-statements - self, - policy_definition_name: str, - **kwargs: Any + self, policy_definition_name: str, **kwargs: Any ) -> None: """Deletes a policy definition in a subscription. This operation deletes the policy definition in the given subscription with the given name. - :param policy_definition_name: The name of the policy definition to delete. + :param policy_definition_name: The name of the policy definition to delete. Required. :type policy_definition_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: None, or the result of cls(response) + :return: None or the result of cls(response) :rtype: None - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType[None] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) - api_version = kwargs.pop('api_version', "2019-06-01") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2019-06-01")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[None] - request = build_policy_definitions_delete_request( policy_definition_name=policy_definition_name, subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.delete.metadata['url'], + template_url=self.delete.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200, 204]: @@ -1910,154 +1975,231 @@ def delete( # pylint: disable=inconsistent-return-statements if cls: return cls(pipeline_response, None, {}) - delete.metadata = {'url': "/subscriptions/{subscriptionId}/providers/Microsoft.Authorization/policyDefinitions/{policyDefinitionName}"} # type: ignore - + delete.metadata = {"url": "/subscriptions/{subscriptionId}/providers/Microsoft.Authorization/policyDefinitions/{policyDefinitionName}"} # type: ignore @distributed_trace - def get( - self, - policy_definition_name: str, - **kwargs: Any - ) -> "_models.PolicyDefinition": + def get(self, policy_definition_name: str, **kwargs: Any) -> _models.PolicyDefinition: """Retrieves a policy definition in a subscription. This operation retrieves the policy definition in the given subscription with the given name. - :param policy_definition_name: The name of the policy definition to get. + :param policy_definition_name: The name of the policy definition to get. Required. :type policy_definition_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: PolicyDefinition, or the result of cls(response) + :return: PolicyDefinition or the result of cls(response) :rtype: ~azure.mgmt.resource.policy.v2019_06_01.models.PolicyDefinition - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.PolicyDefinition"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) - api_version = kwargs.pop('api_version', "2019-06-01") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2019-06-01")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[_models.PolicyDefinition] - request = build_policy_definitions_get_request( policy_definition_name=policy_definition_name, subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.get.metadata['url'], + template_url=self.get.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) - deserialized = self._deserialize('PolicyDefinition', pipeline_response) + deserialized = self._deserialize("PolicyDefinition", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - get.metadata = {'url': "/subscriptions/{subscriptionId}/providers/Microsoft.Authorization/policyDefinitions/{policyDefinitionName}"} # type: ignore - + get.metadata = {"url": "/subscriptions/{subscriptionId}/providers/Microsoft.Authorization/policyDefinitions/{policyDefinitionName}"} # type: ignore @distributed_trace - def get_built_in( - self, - policy_definition_name: str, - **kwargs: Any - ) -> "_models.PolicyDefinition": + def get_built_in(self, policy_definition_name: str, **kwargs: Any) -> _models.PolicyDefinition: """Retrieves a built-in policy definition. This operation retrieves the built-in policy definition with the given name. - :param policy_definition_name: The name of the built-in policy definition to get. + :param policy_definition_name: The name of the built-in policy definition to get. Required. :type policy_definition_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: PolicyDefinition, or the result of cls(response) + :return: PolicyDefinition or the result of cls(response) :rtype: ~azure.mgmt.resource.policy.v2019_06_01.models.PolicyDefinition - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.PolicyDefinition"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) - api_version = kwargs.pop('api_version', "2019-06-01") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2019-06-01")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[_models.PolicyDefinition] - request = build_policy_definitions_get_built_in_request( policy_definition_name=policy_definition_name, api_version=api_version, - template_url=self.get_built_in.metadata['url'], + template_url=self.get_built_in.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) - deserialized = self._deserialize('PolicyDefinition', pipeline_response) + deserialized = self._deserialize("PolicyDefinition", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - get_built_in.metadata = {'url': "/providers/Microsoft.Authorization/policyDefinitions/{policyDefinitionName}"} # type: ignore + get_built_in.metadata = {"url": "/providers/Microsoft.Authorization/policyDefinitions/{policyDefinitionName}"} # type: ignore + + @overload + def create_or_update_at_management_group( + self, + policy_definition_name: str, + management_group_id: str, + parameters: _models.PolicyDefinition, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.PolicyDefinition: + """Creates or updates a policy definition in a management group. + + This operation creates or updates a policy definition in the given management group with the + given name. + + :param policy_definition_name: The name of the policy definition to create. Required. + :type policy_definition_name: str + :param management_group_id: The ID of the management group. Required. + :type management_group_id: str + :param parameters: The policy definition properties. Required. + :type parameters: ~azure.mgmt.resource.policy.v2019_06_01.models.PolicyDefinition + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: PolicyDefinition or the result of cls(response) + :rtype: ~azure.mgmt.resource.policy.v2019_06_01.models.PolicyDefinition + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + def create_or_update_at_management_group( + self, + policy_definition_name: str, + management_group_id: str, + parameters: IO, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.PolicyDefinition: + """Creates or updates a policy definition in a management group. + + This operation creates or updates a policy definition in the given management group with the + given name. + :param policy_definition_name: The name of the policy definition to create. Required. + :type policy_definition_name: str + :param management_group_id: The ID of the management group. Required. + :type management_group_id: str + :param parameters: The policy definition properties. Required. + :type parameters: IO + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: PolicyDefinition or the result of cls(response) + :rtype: ~azure.mgmt.resource.policy.v2019_06_01.models.PolicyDefinition + :raises ~azure.core.exceptions.HttpResponseError: + """ @distributed_trace def create_or_update_at_management_group( self, policy_definition_name: str, management_group_id: str, - parameters: "_models.PolicyDefinition", + parameters: Union[_models.PolicyDefinition, IO], **kwargs: Any - ) -> "_models.PolicyDefinition": + ) -> _models.PolicyDefinition: """Creates or updates a policy definition in a management group. This operation creates or updates a policy definition in the given management group with the given name. - :param policy_definition_name: The name of the policy definition to create. + :param policy_definition_name: The name of the policy definition to create. Required. :type policy_definition_name: str - :param management_group_id: The ID of the management group. + :param management_group_id: The ID of the management group. Required. :type management_group_id: str - :param parameters: The policy definition properties. - :type parameters: ~azure.mgmt.resource.policy.v2019_06_01.models.PolicyDefinition + :param parameters: The policy definition properties. Is either a model type or a IO type. + Required. + :type parameters: ~azure.mgmt.resource.policy.v2019_06_01.models.PolicyDefinition or IO + :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. + Default value is None. + :paramtype content_type: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: PolicyDefinition, or the result of cls(response) + :return: PolicyDefinition or the result of cls(response) :rtype: ~azure.mgmt.resource.policy.v2019_06_01.models.PolicyDefinition - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.PolicyDefinition"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) - api_version = kwargs.pop('api_version', "2019-06-01") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - _json = self._serialize.body(parameters, 'PolicyDefinition') + api_version = kwargs.pop("api_version", _params.pop("api-version", "2019-06-01")) # type: str + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.PolicyDefinition] + + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(parameters, (IO, bytes)): + _content = parameters + else: + _json = self._serialize.body(parameters, "PolicyDefinition") request = build_policy_definitions_create_or_update_at_management_group_request( policy_definition_name=policy_definition_name, @@ -2065,75 +2207,79 @@ def create_or_update_at_management_group( api_version=api_version, content_type=content_type, json=_json, - template_url=self.create_or_update_at_management_group.metadata['url'], + content=_content, + template_url=self.create_or_update_at_management_group.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [201]: map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) - deserialized = self._deserialize('PolicyDefinition', pipeline_response) + deserialized = self._deserialize("PolicyDefinition", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - create_or_update_at_management_group.metadata = {'url': "/providers/Microsoft.Management/managementgroups/{managementGroupId}/providers/Microsoft.Authorization/policyDefinitions/{policyDefinitionName}"} # type: ignore - + create_or_update_at_management_group.metadata = {"url": "/providers/Microsoft.Management/managementgroups/{managementGroupId}/providers/Microsoft.Authorization/policyDefinitions/{policyDefinitionName}"} # type: ignore @distributed_trace def delete_at_management_group( # pylint: disable=inconsistent-return-statements - self, - policy_definition_name: str, - management_group_id: str, - **kwargs: Any + self, policy_definition_name: str, management_group_id: str, **kwargs: Any ) -> None: """Deletes a policy definition in a management group. This operation deletes the policy definition in the given management group with the given name. - :param policy_definition_name: The name of the policy definition to delete. + :param policy_definition_name: The name of the policy definition to delete. Required. :type policy_definition_name: str - :param management_group_id: The ID of the management group. + :param management_group_id: The ID of the management group. Required. :type management_group_id: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: None, or the result of cls(response) + :return: None or the result of cls(response) :rtype: None - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType[None] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + 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', "2019-06-01") # type: str + api_version = kwargs.pop("api_version", _params.pop("api-version", "2019-06-01")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[None] - request = build_policy_definitions_delete_at_management_group_request( policy_definition_name=policy_definition_name, management_group_id=management_group_id, api_version=api_version, - template_url=self.delete_at_management_group.metadata['url'], + template_url=self.delete_at_management_group.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200, 204]: @@ -2143,111 +2289,117 @@ def delete_at_management_group( # pylint: disable=inconsistent-return-statement if cls: return cls(pipeline_response, None, {}) - delete_at_management_group.metadata = {'url': "/providers/Microsoft.Management/managementgroups/{managementGroupId}/providers/Microsoft.Authorization/policyDefinitions/{policyDefinitionName}"} # type: ignore - + delete_at_management_group.metadata = {"url": "/providers/Microsoft.Management/managementgroups/{managementGroupId}/providers/Microsoft.Authorization/policyDefinitions/{policyDefinitionName}"} # type: ignore @distributed_trace def get_at_management_group( - self, - policy_definition_name: str, - management_group_id: str, - **kwargs: Any - ) -> "_models.PolicyDefinition": + self, policy_definition_name: str, management_group_id: str, **kwargs: Any + ) -> _models.PolicyDefinition: """Retrieve a policy definition in a management group. This operation retrieves the policy definition in the given management group with the given name. - :param policy_definition_name: The name of the policy definition to get. + :param policy_definition_name: The name of the policy definition to get. Required. :type policy_definition_name: str - :param management_group_id: The ID of the management group. + :param management_group_id: The ID of the management group. Required. :type management_group_id: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: PolicyDefinition, or the result of cls(response) + :return: PolicyDefinition or the result of cls(response) :rtype: ~azure.mgmt.resource.policy.v2019_06_01.models.PolicyDefinition - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.PolicyDefinition"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) - api_version = kwargs.pop('api_version', "2019-06-01") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2019-06-01")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[_models.PolicyDefinition] - request = build_policy_definitions_get_at_management_group_request( policy_definition_name=policy_definition_name, management_group_id=management_group_id, api_version=api_version, - template_url=self.get_at_management_group.metadata['url'], + template_url=self.get_at_management_group.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) - deserialized = self._deserialize('PolicyDefinition', pipeline_response) + deserialized = self._deserialize("PolicyDefinition", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - get_at_management_group.metadata = {'url': "/providers/Microsoft.Management/managementgroups/{managementGroupId}/providers/Microsoft.Authorization/policyDefinitions/{policyDefinitionName}"} # type: ignore - + get_at_management_group.metadata = {"url": "/providers/Microsoft.Management/managementgroups/{managementGroupId}/providers/Microsoft.Authorization/policyDefinitions/{policyDefinitionName}"} # type: ignore @distributed_trace - def list( - self, - **kwargs: Any - ) -> Iterable["_models.PolicyDefinitionListResult"]: + def list(self, **kwargs: Any) -> Iterable["_models.PolicyDefinition"]: """Retrieves policy definitions in a subscription. This operation retrieves a list of all the policy definitions in a given subscription. :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either PolicyDefinitionListResult or the result of - cls(response) + :return: An iterator like instance of either PolicyDefinition or the result of cls(response) :rtype: - ~azure.core.paging.ItemPaged[~azure.mgmt.resource.policy.v2019_06_01.models.PolicyDefinitionListResult] - :raises: ~azure.core.exceptions.HttpResponseError + ~azure.core.paging.ItemPaged[~azure.mgmt.resource.policy.v2019_06_01.models.PolicyDefinition] + :raises ~azure.core.exceptions.HttpResponseError: """ - api_version = kwargs.pop('api_version', "2019-06-01") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2019-06-01")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[_models.PolicyDefinitionListResult] - cls = kwargs.pop('cls', None) # type: ClsType["_models.PolicyDefinitionListResult"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) + def prepare_request(next_link=None): if not next_link: - + request = build_policy_definitions_list_request( subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.list.metadata['url'], + template_url=self.list.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore else: - - request = build_policy_definitions_list_request( - subscription_id=self._config.subscription_id, - template_url=next_link, - ) + # make call to next link with the client's api-version + _parsed_next_link = urlparse(next_link) + _next_request_params = case_insensitive_dict(parse_qs(_parsed_next_link.query)) + _next_request_params["api-version"] = self._config.api_version + request = HttpRequest("GET", urljoin(next_link, _parsed_next_link.path), params=_next_request_params) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore request.method = "GET" return request @@ -2261,10 +2413,8 @@ def extract_data(pipeline_response): def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) response = pipeline_response.http_response @@ -2274,52 +2424,56 @@ def get_next(next_link=None): return pipeline_response + return ItemPaged(get_next, extract_data) - return ItemPaged( - get_next, extract_data - ) - list.metadata = {'url': "/subscriptions/{subscriptionId}/providers/Microsoft.Authorization/policyDefinitions"} # type: ignore + list.metadata = {"url": "/subscriptions/{subscriptionId}/providers/Microsoft.Authorization/policyDefinitions"} # type: ignore @distributed_trace - def list_built_in( - self, - **kwargs: Any - ) -> Iterable["_models.PolicyDefinitionListResult"]: + def list_built_in(self, **kwargs: Any) -> Iterable["_models.PolicyDefinition"]: """Retrieve built-in policy definitions. This operation retrieves a list of all the built-in policy definitions. :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either PolicyDefinitionListResult or the result of - cls(response) + :return: An iterator like instance of either PolicyDefinition or the result of cls(response) :rtype: - ~azure.core.paging.ItemPaged[~azure.mgmt.resource.policy.v2019_06_01.models.PolicyDefinitionListResult] - :raises: ~azure.core.exceptions.HttpResponseError + ~azure.core.paging.ItemPaged[~azure.mgmt.resource.policy.v2019_06_01.models.PolicyDefinition] + :raises ~azure.core.exceptions.HttpResponseError: """ - api_version = kwargs.pop('api_version', "2019-06-01") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2019-06-01")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[_models.PolicyDefinitionListResult] - cls = kwargs.pop('cls', None) # type: ClsType["_models.PolicyDefinitionListResult"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) + def prepare_request(next_link=None): if not next_link: - + request = build_policy_definitions_list_built_in_request( api_version=api_version, - template_url=self.list_built_in.metadata['url'], + template_url=self.list_built_in.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore else: - - request = build_policy_definitions_list_built_in_request( - template_url=next_link, - ) + # make call to next link with the client's api-version + _parsed_next_link = urlparse(next_link) + _next_request_params = case_insensitive_dict(parse_qs(_parsed_next_link.query)) + _next_request_params["api-version"] = self._config.api_version + request = HttpRequest("GET", urljoin(next_link, _parsed_next_link.path), params=_next_request_params) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore request.method = "GET" return request @@ -2333,10 +2487,8 @@ def extract_data(pipeline_response): def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) response = pipeline_response.http_response @@ -2346,57 +2498,59 @@ def get_next(next_link=None): return pipeline_response + return ItemPaged(get_next, extract_data) - return ItemPaged( - get_next, extract_data - ) - list_built_in.metadata = {'url': "/providers/Microsoft.Authorization/policyDefinitions"} # type: ignore + list_built_in.metadata = {"url": "/providers/Microsoft.Authorization/policyDefinitions"} # type: ignore @distributed_trace - def list_by_management_group( - self, - management_group_id: str, - **kwargs: Any - ) -> Iterable["_models.PolicyDefinitionListResult"]: + def list_by_management_group(self, management_group_id: str, **kwargs: Any) -> Iterable["_models.PolicyDefinition"]: """Retrieve policy definitions in a management group. This operation retrieves a list of all the policy definitions in a given management group. - :param management_group_id: The ID of the management group. + :param management_group_id: The ID of the management group. Required. :type management_group_id: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either PolicyDefinitionListResult or the result of - cls(response) + :return: An iterator like instance of either PolicyDefinition or the result of cls(response) :rtype: - ~azure.core.paging.ItemPaged[~azure.mgmt.resource.policy.v2019_06_01.models.PolicyDefinitionListResult] - :raises: ~azure.core.exceptions.HttpResponseError + ~azure.core.paging.ItemPaged[~azure.mgmt.resource.policy.v2019_06_01.models.PolicyDefinition] + :raises ~azure.core.exceptions.HttpResponseError: """ - api_version = kwargs.pop('api_version', "2019-06-01") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2019-06-01")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[_models.PolicyDefinitionListResult] - cls = kwargs.pop('cls', None) # type: ClsType["_models.PolicyDefinitionListResult"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) + def prepare_request(next_link=None): if not next_link: - + request = build_policy_definitions_list_by_management_group_request( management_group_id=management_group_id, api_version=api_version, - template_url=self.list_by_management_group.metadata['url'], + template_url=self.list_by_management_group.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore else: - - request = build_policy_definitions_list_by_management_group_request( - management_group_id=management_group_id, - template_url=next_link, - ) + # make call to next link with the client's api-version + _parsed_next_link = urlparse(next_link) + _next_request_params = case_insensitive_dict(parse_qs(_parsed_next_link.query)) + _next_request_params["api-version"] = self._config.api_version + request = HttpRequest("GET", urljoin(next_link, _parsed_next_link.path), params=_next_request_params) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore request.method = "GET" return request @@ -2410,10 +2564,8 @@ def extract_data(pipeline_response): def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) response = pipeline_response.http_response @@ -2423,64 +2575,123 @@ def get_next(next_link=None): return pipeline_response + return ItemPaged(get_next, extract_data) - return ItemPaged( - get_next, extract_data - ) - list_by_management_group.metadata = {'url': "/providers/Microsoft.Management/managementgroups/{managementGroupId}/providers/Microsoft.Authorization/policyDefinitions"} # type: ignore -class PolicySetDefinitionsOperations(object): - """PolicySetDefinitionsOperations operations. - - You should not instantiate this class directly. Instead, you should create a Client instance that - instantiates it for you and attaches it as an attribute. - - :ivar models: Alias to model classes used in this operation group. - :type models: ~azure.mgmt.resource.policy.v2019_06_01.models - :param client: Client for service requests. - :param config: Configuration of service client. - :param serializer: An object model serializer. - :param deserializer: An object model deserializer. + list_by_management_group.metadata = {"url": "/providers/Microsoft.Management/managementgroups/{managementGroupId}/providers/Microsoft.Authorization/policyDefinitions"} # type: ignore + + +class PolicySetDefinitionsOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. + + Instead, you should access the following operations through + :class:`~azure.mgmt.resource.policy.v2019_06_01.PolicyClient`'s + :attr:`policy_set_definitions` attribute. """ models = _models - def __init__(self, client, config, serializer, deserializer): - self._client = client - self._serialize = serializer - self._deserialize = deserializer - self._config = config + def __init__(self, *args, **kwargs): + input_args = list(args) + self._client = input_args.pop(0) if input_args else kwargs.pop("client") + self._config = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") - @distributed_trace + @overload def create_or_update( self, policy_set_definition_name: str, - parameters: "_models.PolicySetDefinition", + parameters: _models.PolicySetDefinition, + *, + content_type: str = "application/json", **kwargs: Any - ) -> "_models.PolicySetDefinition": + ) -> _models.PolicySetDefinition: """Creates or updates a policy set definition. This operation creates or updates a policy set definition in the given subscription with the given name. - :param policy_set_definition_name: The name of the policy set definition to create. + :param policy_set_definition_name: The name of the policy set definition to create. Required. :type policy_set_definition_name: str - :param parameters: The policy set definition properties. + :param parameters: The policy set definition properties. Required. :type parameters: ~azure.mgmt.resource.policy.v2019_06_01.models.PolicySetDefinition + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: PolicySetDefinition or the result of cls(response) + :rtype: ~azure.mgmt.resource.policy.v2019_06_01.models.PolicySetDefinition + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + def create_or_update( + self, policy_set_definition_name: str, parameters: IO, *, content_type: str = "application/json", **kwargs: Any + ) -> _models.PolicySetDefinition: + """Creates or updates a policy set definition. + + This operation creates or updates a policy set definition in the given subscription with the + given name. + + :param policy_set_definition_name: The name of the policy set definition to create. Required. + :type policy_set_definition_name: str + :param parameters: The policy set definition properties. Required. + :type parameters: IO + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: PolicySetDefinition or the result of cls(response) + :rtype: ~azure.mgmt.resource.policy.v2019_06_01.models.PolicySetDefinition + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace + def create_or_update( + self, policy_set_definition_name: str, parameters: Union[_models.PolicySetDefinition, IO], **kwargs: Any + ) -> _models.PolicySetDefinition: + """Creates or updates a policy set definition. + + This operation creates or updates a policy set definition in the given subscription with the + given name. + + :param policy_set_definition_name: The name of the policy set definition to create. Required. + :type policy_set_definition_name: str + :param parameters: The policy set definition properties. Is either a model type or a IO type. + Required. + :type parameters: ~azure.mgmt.resource.policy.v2019_06_01.models.PolicySetDefinition or IO + :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. + Default value is None. + :paramtype content_type: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: PolicySetDefinition, or the result of cls(response) + :return: PolicySetDefinition or the result of cls(response) :rtype: ~azure.mgmt.resource.policy.v2019_06_01.models.PolicySetDefinition - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.PolicySetDefinition"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) - api_version = kwargs.pop('api_version', "2019-06-01") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - _json = self._serialize.body(parameters, 'PolicySetDefinition') + api_version = kwargs.pop("api_version", _params.pop("api-version", "2019-06-01")) # type: str + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.PolicySetDefinition] + + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(parameters, (IO, bytes)): + _content = parameters + else: + _json = self._serialize.body(parameters, "PolicySetDefinition") request = build_policy_set_definitions_create_or_update_request( policy_set_definition_name=policy_set_definition_name, @@ -2488,16 +2699,18 @@ def create_or_update( api_version=api_version, content_type=content_type, json=_json, - template_url=self.create_or_update.metadata['url'], + content=_content, + template_url=self.create_or_update.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200, 201]: @@ -2506,59 +2719,62 @@ def create_or_update( raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) if response.status_code == 200: - deserialized = self._deserialize('PolicySetDefinition', pipeline_response) + deserialized = self._deserialize("PolicySetDefinition", pipeline_response) if response.status_code == 201: - deserialized = self._deserialize('PolicySetDefinition', pipeline_response) + deserialized = self._deserialize("PolicySetDefinition", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - create_or_update.metadata = {'url': "/subscriptions/{subscriptionId}/providers/Microsoft.Authorization/policySetDefinitions/{policySetDefinitionName}"} # type: ignore - + create_or_update.metadata = {"url": "/subscriptions/{subscriptionId}/providers/Microsoft.Authorization/policySetDefinitions/{policySetDefinitionName}"} # type: ignore @distributed_trace def delete( # pylint: disable=inconsistent-return-statements - self, - policy_set_definition_name: str, - **kwargs: Any + self, policy_set_definition_name: str, **kwargs: Any ) -> None: """Deletes a policy set definition. This operation deletes the policy set definition in the given subscription with the given name. - :param policy_set_definition_name: The name of the policy set definition to delete. + :param policy_set_definition_name: The name of the policy set definition to delete. Required. :type policy_set_definition_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: None, or the result of cls(response) + :return: None or the result of cls(response) :rtype: None - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType[None] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) - api_version = kwargs.pop('api_version', "2019-06-01") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2019-06-01")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[None] - request = build_policy_set_definitions_delete_request( policy_set_definition_name=policy_set_definition_name, subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.delete.metadata['url'], + template_url=self.delete.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200, 204]: @@ -2569,50 +2785,51 @@ def delete( # pylint: disable=inconsistent-return-statements if cls: return cls(pipeline_response, None, {}) - delete.metadata = {'url': "/subscriptions/{subscriptionId}/providers/Microsoft.Authorization/policySetDefinitions/{policySetDefinitionName}"} # type: ignore - + delete.metadata = {"url": "/subscriptions/{subscriptionId}/providers/Microsoft.Authorization/policySetDefinitions/{policySetDefinitionName}"} # type: ignore @distributed_trace - def get( - self, - policy_set_definition_name: str, - **kwargs: Any - ) -> "_models.PolicySetDefinition": + def get(self, policy_set_definition_name: str, **kwargs: Any) -> _models.PolicySetDefinition: """Retrieves a policy set definition. This operation retrieves the policy set definition in the given subscription with the given name. - :param policy_set_definition_name: The name of the policy set definition to get. + :param policy_set_definition_name: The name of the policy set definition to get. Required. :type policy_set_definition_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: PolicySetDefinition, or the result of cls(response) + :return: PolicySetDefinition or the result of cls(response) :rtype: ~azure.mgmt.resource.policy.v2019_06_01.models.PolicySetDefinition - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.PolicySetDefinition"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) - api_version = kwargs.pop('api_version', "2019-06-01") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2019-06-01")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[_models.PolicySetDefinition] - request = build_policy_set_definitions_get_request( policy_set_definition_name=policy_set_definition_name, subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.get.metadata['url'], + template_url=self.get.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200]: @@ -2620,55 +2837,56 @@ def get( error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - deserialized = self._deserialize('PolicySetDefinition', pipeline_response) + deserialized = self._deserialize("PolicySetDefinition", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - get.metadata = {'url': "/subscriptions/{subscriptionId}/providers/Microsoft.Authorization/policySetDefinitions/{policySetDefinitionName}"} # type: ignore - + get.metadata = {"url": "/subscriptions/{subscriptionId}/providers/Microsoft.Authorization/policySetDefinitions/{policySetDefinitionName}"} # type: ignore @distributed_trace - def get_built_in( - self, - policy_set_definition_name: str, - **kwargs: Any - ) -> "_models.PolicySetDefinition": + def get_built_in(self, policy_set_definition_name: str, **kwargs: Any) -> _models.PolicySetDefinition: """Retrieves a built in policy set definition. This operation retrieves the built-in policy set definition with the given name. - :param policy_set_definition_name: The name of the policy set definition to get. + :param policy_set_definition_name: The name of the policy set definition to get. Required. :type policy_set_definition_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: PolicySetDefinition, or the result of cls(response) + :return: PolicySetDefinition or the result of cls(response) :rtype: ~azure.mgmt.resource.policy.v2019_06_01.models.PolicySetDefinition - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.PolicySetDefinition"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) - api_version = kwargs.pop('api_version', "2019-06-01") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2019-06-01")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[_models.PolicySetDefinition] - request = build_policy_set_definitions_get_built_in_request( policy_set_definition_name=policy_set_definition_name, api_version=api_version, - template_url=self.get_built_in.metadata['url'], + template_url=self.get_built_in.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200]: @@ -2676,58 +2894,62 @@ def get_built_in( error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - deserialized = self._deserialize('PolicySetDefinition', pipeline_response) + deserialized = self._deserialize("PolicySetDefinition", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - get_built_in.metadata = {'url': "/providers/Microsoft.Authorization/policySetDefinitions/{policySetDefinitionName}"} # type: ignore - + get_built_in.metadata = {"url": "/providers/Microsoft.Authorization/policySetDefinitions/{policySetDefinitionName}"} # type: ignore @distributed_trace - def list( - self, - **kwargs: Any - ) -> Iterable["_models.PolicySetDefinitionListResult"]: + def list(self, **kwargs: Any) -> Iterable["_models.PolicySetDefinition"]: """Retrieves the policy set definitions for a subscription. This operation retrieves a list of all the policy set definitions in the given subscription. :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either PolicySetDefinitionListResult or the result of - cls(response) + :return: An iterator like instance of either PolicySetDefinition or the result of cls(response) :rtype: - ~azure.core.paging.ItemPaged[~azure.mgmt.resource.policy.v2019_06_01.models.PolicySetDefinitionListResult] - :raises: ~azure.core.exceptions.HttpResponseError + ~azure.core.paging.ItemPaged[~azure.mgmt.resource.policy.v2019_06_01.models.PolicySetDefinition] + :raises ~azure.core.exceptions.HttpResponseError: """ - api_version = kwargs.pop('api_version', "2019-06-01") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2019-06-01")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[_models.PolicySetDefinitionListResult] - cls = kwargs.pop('cls', None) # type: ClsType["_models.PolicySetDefinitionListResult"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) + def prepare_request(next_link=None): if not next_link: - + request = build_policy_set_definitions_list_request( subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.list.metadata['url'], + template_url=self.list.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore else: - - request = build_policy_set_definitions_list_request( - subscription_id=self._config.subscription_id, - template_url=next_link, - ) + # make call to next link with the client's api-version + _parsed_next_link = urlparse(next_link) + _next_request_params = case_insensitive_dict(parse_qs(_parsed_next_link.query)) + _next_request_params["api-version"] = self._config.api_version + request = HttpRequest("GET", urljoin(next_link, _parsed_next_link.path), params=_next_request_params) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore request.method = "GET" return request @@ -2741,10 +2963,8 @@ def extract_data(pipeline_response): def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) response = pipeline_response.http_response @@ -2755,52 +2975,56 @@ def get_next(next_link=None): return pipeline_response + return ItemPaged(get_next, extract_data) - return ItemPaged( - get_next, extract_data - ) - list.metadata = {'url': "/subscriptions/{subscriptionId}/providers/Microsoft.Authorization/policySetDefinitions"} # type: ignore + list.metadata = {"url": "/subscriptions/{subscriptionId}/providers/Microsoft.Authorization/policySetDefinitions"} # type: ignore @distributed_trace - def list_built_in( - self, - **kwargs: Any - ) -> Iterable["_models.PolicySetDefinitionListResult"]: + def list_built_in(self, **kwargs: Any) -> Iterable["_models.PolicySetDefinition"]: """Retrieves built-in policy set definitions. This operation retrieves a list of all the built-in policy set definitions. :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either PolicySetDefinitionListResult or the result of - cls(response) + :return: An iterator like instance of either PolicySetDefinition or the result of cls(response) :rtype: - ~azure.core.paging.ItemPaged[~azure.mgmt.resource.policy.v2019_06_01.models.PolicySetDefinitionListResult] - :raises: ~azure.core.exceptions.HttpResponseError + ~azure.core.paging.ItemPaged[~azure.mgmt.resource.policy.v2019_06_01.models.PolicySetDefinition] + :raises ~azure.core.exceptions.HttpResponseError: """ - api_version = kwargs.pop('api_version', "2019-06-01") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2019-06-01")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[_models.PolicySetDefinitionListResult] - cls = kwargs.pop('cls', None) # type: ClsType["_models.PolicySetDefinitionListResult"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) + def prepare_request(next_link=None): if not next_link: - + request = build_policy_set_definitions_list_built_in_request( api_version=api_version, - template_url=self.list_built_in.metadata['url'], + template_url=self.list_built_in.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore else: - - request = build_policy_set_definitions_list_built_in_request( - template_url=next_link, - ) + # make call to next link with the client's api-version + _parsed_next_link = urlparse(next_link) + _next_request_params = case_insensitive_dict(parse_qs(_parsed_next_link.query)) + _next_request_params["api-version"] = self._config.api_version + request = HttpRequest("GET", urljoin(next_link, _parsed_next_link.path), params=_next_request_params) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore request.method = "GET" return request @@ -2814,10 +3038,8 @@ def extract_data(pipeline_response): def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) response = pipeline_response.http_response @@ -2828,46 +3050,120 @@ def get_next(next_link=None): return pipeline_response + return ItemPaged(get_next, extract_data) - return ItemPaged( - get_next, extract_data - ) - list_built_in.metadata = {'url': "/providers/Microsoft.Authorization/policySetDefinitions"} # type: ignore + list_built_in.metadata = {"url": "/providers/Microsoft.Authorization/policySetDefinitions"} # type: ignore - @distributed_trace + @overload def create_or_update_at_management_group( self, policy_set_definition_name: str, management_group_id: str, - parameters: "_models.PolicySetDefinition", + parameters: _models.PolicySetDefinition, + *, + content_type: str = "application/json", **kwargs: Any - ) -> "_models.PolicySetDefinition": + ) -> _models.PolicySetDefinition: """Creates or updates a policy set definition. This operation creates or updates a policy set definition in the given management group with the given name. - :param policy_set_definition_name: The name of the policy set definition to create. + :param policy_set_definition_name: The name of the policy set definition to create. Required. :type policy_set_definition_name: str - :param management_group_id: The ID of the management group. + :param management_group_id: The ID of the management group. Required. :type management_group_id: str - :param parameters: The policy set definition properties. + :param parameters: The policy set definition properties. Required. :type parameters: ~azure.mgmt.resource.policy.v2019_06_01.models.PolicySetDefinition + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: PolicySetDefinition or the result of cls(response) + :rtype: ~azure.mgmt.resource.policy.v2019_06_01.models.PolicySetDefinition + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + def create_or_update_at_management_group( + self, + policy_set_definition_name: str, + management_group_id: str, + parameters: IO, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.PolicySetDefinition: + """Creates or updates a policy set definition. + + This operation creates or updates a policy set definition in the given management group with + the given name. + + :param policy_set_definition_name: The name of the policy set definition to create. Required. + :type policy_set_definition_name: str + :param management_group_id: The ID of the management group. Required. + :type management_group_id: str + :param parameters: The policy set definition properties. Required. + :type parameters: IO + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: PolicySetDefinition or the result of cls(response) + :rtype: ~azure.mgmt.resource.policy.v2019_06_01.models.PolicySetDefinition + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace + def create_or_update_at_management_group( + self, + policy_set_definition_name: str, + management_group_id: str, + parameters: Union[_models.PolicySetDefinition, IO], + **kwargs: Any + ) -> _models.PolicySetDefinition: + """Creates or updates a policy set definition. + + This operation creates or updates a policy set definition in the given management group with + the given name. + + :param policy_set_definition_name: The name of the policy set definition to create. Required. + :type policy_set_definition_name: str + :param management_group_id: The ID of the management group. Required. + :type management_group_id: str + :param parameters: The policy set definition properties. Is either a model type or a IO type. + Required. + :type parameters: ~azure.mgmt.resource.policy.v2019_06_01.models.PolicySetDefinition or IO + :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. + Default value is None. + :paramtype content_type: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: PolicySetDefinition, or the result of cls(response) + :return: PolicySetDefinition or the result of cls(response) :rtype: ~azure.mgmt.resource.policy.v2019_06_01.models.PolicySetDefinition - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.PolicySetDefinition"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', "2019-06-01") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + api_version = kwargs.pop("api_version", _params.pop("api-version", "2019-06-01")) # type: str + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.PolicySetDefinition] - _json = self._serialize.body(parameters, 'PolicySetDefinition') + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(parameters, (IO, bytes)): + _content = parameters + else: + _json = self._serialize.body(parameters, "PolicySetDefinition") request = build_policy_set_definitions_create_or_update_at_management_group_request( policy_set_definition_name=policy_set_definition_name, @@ -2875,16 +3171,18 @@ def create_or_update_at_management_group( api_version=api_version, content_type=content_type, json=_json, - template_url=self.create_or_update_at_management_group.metadata['url'], + content=_content, + template_url=self.create_or_update_at_management_group.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200, 201]: @@ -2893,63 +3191,65 @@ def create_or_update_at_management_group( raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) if response.status_code == 200: - deserialized = self._deserialize('PolicySetDefinition', pipeline_response) + deserialized = self._deserialize("PolicySetDefinition", pipeline_response) if response.status_code == 201: - deserialized = self._deserialize('PolicySetDefinition', pipeline_response) + deserialized = self._deserialize("PolicySetDefinition", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - create_or_update_at_management_group.metadata = {'url': "/providers/Microsoft.Management/managementgroups/{managementGroupId}/providers/Microsoft.Authorization/policySetDefinitions/{policySetDefinitionName}"} # type: ignore - + create_or_update_at_management_group.metadata = {"url": "/providers/Microsoft.Management/managementgroups/{managementGroupId}/providers/Microsoft.Authorization/policySetDefinitions/{policySetDefinitionName}"} # type: ignore @distributed_trace def delete_at_management_group( # pylint: disable=inconsistent-return-statements - self, - policy_set_definition_name: str, - management_group_id: str, - **kwargs: Any + self, policy_set_definition_name: str, management_group_id: str, **kwargs: Any ) -> None: """Deletes a policy set definition. This operation deletes the policy set definition in the given management group with the given name. - :param policy_set_definition_name: The name of the policy set definition to delete. + :param policy_set_definition_name: The name of the policy set definition to delete. Required. :type policy_set_definition_name: str - :param management_group_id: The ID of the management group. + :param management_group_id: The ID of the management group. Required. :type management_group_id: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: None, or the result of cls(response) + :return: None or the result of cls(response) :rtype: None - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType[None] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) - api_version = kwargs.pop('api_version', "2019-06-01") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2019-06-01")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[None] - request = build_policy_set_definitions_delete_at_management_group_request( policy_set_definition_name=policy_set_definition_name, management_group_id=management_group_id, api_version=api_version, - template_url=self.delete_at_management_group.metadata['url'], + template_url=self.delete_at_management_group.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200, 204]: @@ -2960,53 +3260,55 @@ def delete_at_management_group( # pylint: disable=inconsistent-return-statement if cls: return cls(pipeline_response, None, {}) - delete_at_management_group.metadata = {'url': "/providers/Microsoft.Management/managementgroups/{managementGroupId}/providers/Microsoft.Authorization/policySetDefinitions/{policySetDefinitionName}"} # type: ignore - + delete_at_management_group.metadata = {"url": "/providers/Microsoft.Management/managementgroups/{managementGroupId}/providers/Microsoft.Authorization/policySetDefinitions/{policySetDefinitionName}"} # type: ignore @distributed_trace def get_at_management_group( - self, - policy_set_definition_name: str, - management_group_id: str, - **kwargs: Any - ) -> "_models.PolicySetDefinition": + self, policy_set_definition_name: str, management_group_id: str, **kwargs: Any + ) -> _models.PolicySetDefinition: """Retrieves a policy set definition. This operation retrieves the policy set definition in the given management group with the given name. - :param policy_set_definition_name: The name of the policy set definition to get. + :param policy_set_definition_name: The name of the policy set definition to get. Required. :type policy_set_definition_name: str - :param management_group_id: The ID of the management group. + :param management_group_id: The ID of the management group. Required. :type management_group_id: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: PolicySetDefinition, or the result of cls(response) + :return: PolicySetDefinition or the result of cls(response) :rtype: ~azure.mgmt.resource.policy.v2019_06_01.models.PolicySetDefinition - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.PolicySetDefinition"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + 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', "2019-06-01") # type: str + api_version = kwargs.pop("api_version", _params.pop("api-version", "2019-06-01")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[_models.PolicySetDefinition] - request = build_policy_set_definitions_get_at_management_group_request( policy_set_definition_name=policy_set_definition_name, management_group_id=management_group_id, api_version=api_version, - template_url=self.get_at_management_group.metadata['url'], + template_url=self.get_at_management_group.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200]: @@ -3014,62 +3316,67 @@ def get_at_management_group( error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - deserialized = self._deserialize('PolicySetDefinition', pipeline_response) + deserialized = self._deserialize("PolicySetDefinition", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - get_at_management_group.metadata = {'url': "/providers/Microsoft.Management/managementgroups/{managementGroupId}/providers/Microsoft.Authorization/policySetDefinitions/{policySetDefinitionName}"} # type: ignore - + get_at_management_group.metadata = {"url": "/providers/Microsoft.Management/managementgroups/{managementGroupId}/providers/Microsoft.Authorization/policySetDefinitions/{policySetDefinitionName}"} # type: ignore @distributed_trace def list_by_management_group( - self, - management_group_id: str, - **kwargs: Any - ) -> Iterable["_models.PolicySetDefinitionListResult"]: + self, management_group_id: str, **kwargs: Any + ) -> Iterable["_models.PolicySetDefinition"]: """Retrieves all policy set definitions in management group. This operation retrieves a list of all the a policy set definition in the given management group. - :param management_group_id: The ID of the management group. + :param management_group_id: The ID of the management group. Required. :type management_group_id: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either PolicySetDefinitionListResult or the result of - cls(response) + :return: An iterator like instance of either PolicySetDefinition or the result of cls(response) :rtype: - ~azure.core.paging.ItemPaged[~azure.mgmt.resource.policy.v2019_06_01.models.PolicySetDefinitionListResult] - :raises: ~azure.core.exceptions.HttpResponseError + ~azure.core.paging.ItemPaged[~azure.mgmt.resource.policy.v2019_06_01.models.PolicySetDefinition] + :raises ~azure.core.exceptions.HttpResponseError: """ - api_version = kwargs.pop('api_version', "2019-06-01") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2019-06-01")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[_models.PolicySetDefinitionListResult] - cls = kwargs.pop('cls', None) # type: ClsType["_models.PolicySetDefinitionListResult"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) + def prepare_request(next_link=None): if not next_link: - + request = build_policy_set_definitions_list_by_management_group_request( management_group_id=management_group_id, api_version=api_version, - template_url=self.list_by_management_group.metadata['url'], + template_url=self.list_by_management_group.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore else: - - request = build_policy_set_definitions_list_by_management_group_request( - management_group_id=management_group_id, - template_url=next_link, - ) + # make call to next link with the client's api-version + _parsed_next_link = urlparse(next_link) + _next_request_params = case_insensitive_dict(parse_qs(_parsed_next_link.query)) + _next_request_params["api-version"] = self._config.api_version + request = HttpRequest("GET", urljoin(next_link, _parsed_next_link.path), params=_next_request_params) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore request.method = "GET" return request @@ -3083,10 +3390,8 @@ def extract_data(pipeline_response): def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) response = pipeline_response.http_response @@ -3097,8 +3402,6 @@ def get_next(next_link=None): return pipeline_response + return ItemPaged(get_next, extract_data) - return ItemPaged( - get_next, extract_data - ) - list_by_management_group.metadata = {'url': "/providers/Microsoft.Management/managementgroups/{managementGroupId}/providers/Microsoft.Authorization/policySetDefinitions"} # type: ignore + list_by_management_group.metadata = {"url": "/providers/Microsoft.Management/managementgroups/{managementGroupId}/providers/Microsoft.Authorization/policySetDefinitions"} # type: ignore diff --git a/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/policy/v2019_06_01/operations/_patch.py b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/policy/v2019_06_01/operations/_patch.py new file mode 100644 index 0000000000000..f7dd32510333d --- /dev/null +++ b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/policy/v2019_06_01/operations/_patch.py @@ -0,0 +1,20 @@ +# ------------------------------------ +# Copyright (c) Microsoft Corporation. +# Licensed under the MIT License. +# ------------------------------------ +"""Customize generated code here. + +Follow our quickstart for examples: https://aka.ms/azsdk/python/dpcodegen/python/customize +""" +from typing import List + +__all__: List[str] = [] # Add all objects you want publicly available to users at this package level + + +def patch_sdk(): + """Do not remove from this file. + + `patch_sdk` is a last resort escape hatch that allows you to do customizations + you can't accomplish using the techniques described in + https://aka.ms/azsdk/python/dpcodegen/python/customize + """ diff --git a/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/policy/v2019_09_01/__init__.py b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/policy/v2019_09_01/__init__.py index 89180ab440872..bb1ffe59afae7 100644 --- a/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/policy/v2019_09_01/__init__.py +++ b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/policy/v2019_09_01/__init__.py @@ -10,9 +10,15 @@ from ._version import VERSION __version__ = VERSION -__all__ = ['PolicyClient'] -# `._patch.py` is used for handwritten extensions to the generated code -# Example: https://github.com/Azure/azure-sdk-for-python/blob/main/doc/dev/customize_code/how-to-patch-sdk-code.md -from ._patch import patch_sdk -patch_sdk() +try: + from ._patch import __all__ as _patch_all + from ._patch import * # type: ignore # pylint: disable=unused-wildcard-import +except ImportError: + _patch_all = [] +from ._patch import patch_sdk as _patch_sdk + +__all__ = ["PolicyClient"] +__all__.extend([p for p in _patch_all if p not in __all__]) + +_patch_sdk() diff --git a/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/policy/v2019_09_01/_configuration.py b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/policy/v2019_09_01/_configuration.py index d5915a2ad6d7c..80d7595524e0b 100644 --- a/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/policy/v2019_09_01/_configuration.py +++ b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/policy/v2019_09_01/_configuration.py @@ -25,23 +25,18 @@ class PolicyClientConfiguration(Configuration): # pylint: disable=too-many-inst Note that all parameters used to create this instance are saved as instance attributes. - :param credential: Credential needed for the client to connect to Azure. + :param credential: Credential needed for the client to connect to Azure. Required. :type credential: ~azure.core.credentials.TokenCredential - :param subscription_id: The ID of the target subscription. + :param subscription_id: The ID of the target subscription. Required. :type subscription_id: str :keyword api_version: Api Version. Default value is "2019-09-01". Note that overriding this default value may result in unsupported behavior. :paramtype api_version: str """ - def __init__( - self, - credential: "TokenCredential", - subscription_id: str, - **kwargs: Any - ) -> None: + def __init__(self, credential: "TokenCredential", subscription_id: str, **kwargs: Any) -> None: super(PolicyClientConfiguration, self).__init__(**kwargs) - api_version = kwargs.pop('api_version', "2019-09-01") # type: str + api_version = kwargs.pop("api_version", "2019-09-01") # type: str if credential is None: raise ValueError("Parameter 'credential' must not be None.") @@ -51,23 +46,24 @@ def __init__( self.credential = credential self.subscription_id = subscription_id self.api_version = api_version - self.credential_scopes = kwargs.pop('credential_scopes', ['https://management.azure.com/.default']) - kwargs.setdefault('sdk_moniker', 'mgmt-resource/{}'.format(VERSION)) + self.credential_scopes = kwargs.pop("credential_scopes", ["https://management.azure.com/.default"]) + kwargs.setdefault("sdk_moniker", "mgmt-resource/{}".format(VERSION)) self._configure(**kwargs) def _configure( - self, - **kwargs # type: Any + self, **kwargs # type: Any ): # type: (...) -> 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) - self.logging_policy = kwargs.get('logging_policy') or policies.NetworkTraceLoggingPolicy(**kwargs) - self.http_logging_policy = kwargs.get('http_logging_policy') or ARMHttpLoggingPolicy(**kwargs) - self.retry_policy = kwargs.get('retry_policy') or policies.RetryPolicy(**kwargs) - self.custom_hook_policy = kwargs.get('custom_hook_policy') or policies.CustomHookPolicy(**kwargs) - self.redirect_policy = kwargs.get('redirect_policy') or policies.RedirectPolicy(**kwargs) - self.authentication_policy = kwargs.get('authentication_policy') + 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) + self.logging_policy = kwargs.get("logging_policy") or policies.NetworkTraceLoggingPolicy(**kwargs) + self.http_logging_policy = kwargs.get("http_logging_policy") or ARMHttpLoggingPolicy(**kwargs) + self.retry_policy = kwargs.get("retry_policy") or policies.RetryPolicy(**kwargs) + self.custom_hook_policy = kwargs.get("custom_hook_policy") or policies.CustomHookPolicy(**kwargs) + self.redirect_policy = kwargs.get("redirect_policy") or policies.RedirectPolicy(**kwargs) + self.authentication_policy = kwargs.get("authentication_policy") if self.credential and not self.authentication_policy: - self.authentication_policy = ARMChallengeAuthenticationPolicy(self.credential, *self.credential_scopes, **kwargs) + self.authentication_policy = ARMChallengeAuthenticationPolicy( + self.credential, *self.credential_scopes, **kwargs + ) diff --git a/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/policy/v2019_09_01/_metadata.json b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/policy/v2019_09_01/_metadata.json index d25fe37605faa..5b91b0c3db65a 100644 --- a/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/policy/v2019_09_01/_metadata.json +++ b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/policy/v2019_09_01/_metadata.json @@ -10,20 +10,20 @@ "azure_arm": true, "has_lro_operations": false, "client_side_validation": false, - "sync_imports": "{\"typing\": {\"azurecore\": {\"azure.core.credentials\": [\"TokenCredential\"]}}, \"regular\": {\"azurecore\": {\"azure.profiles\": [\"KnownProfiles\", \"ProfileDefinition\"], \"azure.profiles.multiapiclient\": [\"MultiApiClientMixin\"], \"azure.mgmt.core\": [\"ARMPipelineClient\"]}, \"local\": {\"._configuration\": [\"PolicyClientConfiguration\"]}, \"thirdparty\": {\"msrest\": [\"Deserializer\", \"Serializer\"]}}, \"conditional\": {\"stdlib\": {\"typing\": [\"Any\", \"Optional\"]}}}", - "async_imports": "{\"typing\": {\"azurecore\": {\"azure.core.credentials_async\": [\"AsyncTokenCredential\"], \"azure.core.credentials\": [\"TokenCredential\"]}}, \"regular\": {\"azurecore\": {\"azure.profiles\": [\"KnownProfiles\", \"ProfileDefinition\"], \"azure.profiles.multiapiclient\": [\"MultiApiClientMixin\"], \"azure.mgmt.core\": [\"AsyncARMPipelineClient\"]}, \"local\": {\"._configuration\": [\"PolicyClientConfiguration\"]}, \"thirdparty\": {\"msrest\": [\"Deserializer\", \"Serializer\"]}}, \"conditional\": {\"stdlib\": {\"typing\": [\"Any\", \"Optional\"]}}}" + "sync_imports": "{\"conditional\": {\"stdlib\": {\"typing\": [\"Any\", \"Optional\"]}}, \"regular\": {\"azurecore\": {\"azure.mgmt.core\": [\"ARMPipelineClient\"], \"azure.profiles\": [\"KnownProfiles\", \"ProfileDefinition\"], \"azure.profiles.multiapiclient\": [\"MultiApiClientMixin\"]}, \"local\": {\"._configuration\": [\"PolicyClientConfiguration\"], \".._serialization\": [\"Deserializer\", \"Serializer\"]}}, \"typing\": {\"azurecore\": {\"azure.core.credentials\": [\"TokenCredential\"]}}}", + "async_imports": "{\"conditional\": {\"stdlib\": {\"typing\": [\"Any\", \"Optional\"]}}, \"regular\": {\"azurecore\": {\"azure.mgmt.core\": [\"AsyncARMPipelineClient\"], \"azure.profiles\": [\"KnownProfiles\", \"ProfileDefinition\"], \"azure.profiles.multiapiclient\": [\"MultiApiClientMixin\"]}, \"local\": {\"._configuration\": [\"PolicyClientConfiguration\"], \"..._serialization\": [\"Deserializer\", \"Serializer\"]}}, \"typing\": {\"azurecore\": {\"azure.core.credentials_async\": [\"AsyncTokenCredential\"]}}}" }, "global_parameters": { "sync": { "credential": { - "signature": "credential, # type: \"TokenCredential\"", - "description": "Credential needed for the client to connect to Azure.", + "signature": "credential: \"TokenCredential\",", + "description": "Credential needed for the client to connect to Azure. Required.", "docstring_type": "~azure.core.credentials.TokenCredential", "required": true }, "subscription_id": { - "signature": "subscription_id, # type: str", - "description": "The ID of the target subscription.", + "signature": "subscription_id: str,", + "description": "The ID of the target subscription. Required.", "docstring_type": "str", "required": true } @@ -31,13 +31,13 @@ "async": { "credential": { "signature": "credential: \"AsyncTokenCredential\",", - "description": "Credential needed for the client to connect to Azure.", + "description": "Credential needed for the client to connect to Azure. Required.", "docstring_type": "~azure.core.credentials_async.AsyncTokenCredential", "required": true }, "subscription_id": { "signature": "subscription_id: str,", - "description": "The ID of the target subscription.", + "description": "The ID of the target subscription. Required.", "docstring_type": "str", "required": true } @@ -54,7 +54,7 @@ "required": false }, "base_url": { - "signature": "base_url=\"https://management.azure.com\", # type: str", + "signature": "base_url: str = \"https://management.azure.com\",", "description": "Service URL", "docstring_type": "str", "required": false diff --git a/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/policy/v2019_09_01/_patch.py b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/policy/v2019_09_01/_patch.py index 74e48ecd07cf3..f99e77fef9861 100644 --- a/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/policy/v2019_09_01/_patch.py +++ b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/policy/v2019_09_01/_patch.py @@ -28,4 +28,4 @@ # This file is used for handwritten extensions to the generated code. Example: # https://github.com/Azure/azure-sdk-for-python/blob/main/doc/dev/customize_code/how-to-patch-sdk-code.md def patch_sdk(): - pass \ No newline at end of file + pass diff --git a/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/policy/v2019_09_01/_policy_client.py b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/policy/v2019_09_01/_policy_client.py index 7c22e36397a92..7109bcf2be4d6 100644 --- a/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/policy/v2019_09_01/_policy_client.py +++ b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/policy/v2019_09_01/_policy_client.py @@ -9,12 +9,11 @@ from copy import deepcopy from typing import Any, TYPE_CHECKING -from msrest import Deserializer, Serializer - from azure.core.rest import HttpRequest, HttpResponse from azure.mgmt.core import ARMPipelineClient from . import models +from .._serialization import Deserializer, Serializer from ._configuration import PolicyClientConfiguration from .operations import PolicyAssignmentsOperations, PolicyDefinitionsOperations, PolicySetDefinitionsOperations @@ -22,7 +21,8 @@ # pylint: disable=unused-import,ungrouped-imports from azure.core.credentials import TokenCredential -class PolicyClient: + +class PolicyClient: # pylint: disable=client-accepts-api-version-keyword """To manage and control access to your resources, you can define customized policies and assign them at a scope. @@ -35,9 +35,9 @@ class PolicyClient: :ivar policy_set_definitions: PolicySetDefinitionsOperations operations :vartype policy_set_definitions: azure.mgmt.resource.policy.v2019_09_01.operations.PolicySetDefinitionsOperations - :param credential: Credential needed for the client to connect to Azure. + :param credential: Credential needed for the client to connect to Azure. Required. :type credential: ~azure.core.credentials.TokenCredential - :param subscription_id: The ID of the target subscription. + :param subscription_id: The ID of the target subscription. Required. :type subscription_id: str :param base_url: Service URL. Default value is "https://management.azure.com". :type base_url: str @@ -60,16 +60,17 @@ def __init__( self._serialize = Serializer(client_models) self._deserialize = Deserializer(client_models) self._serialize.client_side_validation = False - self.policy_assignments = PolicyAssignmentsOperations(self._client, self._config, self._serialize, self._deserialize) - self.policy_definitions = PolicyDefinitionsOperations(self._client, self._config, self._serialize, self._deserialize) - self.policy_set_definitions = PolicySetDefinitionsOperations(self._client, self._config, self._serialize, self._deserialize) - - - def _send_request( - self, - request: HttpRequest, - **kwargs: Any - ) -> HttpResponse: + self.policy_assignments = PolicyAssignmentsOperations( + self._client, self._config, self._serialize, self._deserialize + ) + self.policy_definitions = PolicyDefinitionsOperations( + self._client, self._config, self._serialize, self._deserialize + ) + self.policy_set_definitions = PolicySetDefinitionsOperations( + self._client, self._config, self._serialize, self._deserialize + ) + + def _send_request(self, request: HttpRequest, **kwargs: Any) -> HttpResponse: """Runs the network request through the client's chained policies. >>> from azure.core.rest import HttpRequest @@ -78,7 +79,7 @@ def _send_request( >>> response = client._send_request(request) - For more information on this code flow, see https://aka.ms/azsdk/python/protocol/quickstart + For more information on this code flow, see https://aka.ms/azsdk/dpcodegen/python/send_request :param request: The network request you want to make. Required. :type request: ~azure.core.rest.HttpRequest diff --git a/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/policy/v2019_09_01/_vendor.py b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/policy/v2019_09_01/_vendor.py index 138f663c53a4e..9aad73fc743e7 100644 --- a/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/policy/v2019_09_01/_vendor.py +++ b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/policy/v2019_09_01/_vendor.py @@ -7,6 +7,7 @@ from azure.core.pipeline.transport import HttpRequest + def _convert_request(request, files=None): data = request.content if not files else None request = HttpRequest(method=request.method, url=request.url, headers=request.headers, data=data) @@ -14,6 +15,7 @@ def _convert_request(request, files=None): request.set_formdata_body(files) return request + def _format_url_section(template, **kwargs): components = template.split("/") while components: @@ -21,7 +23,5 @@ def _format_url_section(template, **kwargs): 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 - ] + components = [c for c in formatted_components if "{}".format(key.args[0]) not in c] template = "/".join(components) diff --git a/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/policy/v2019_09_01/_version.py b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/policy/v2019_09_01/_version.py index a012ac01c480c..e5754a47ce68f 100644 --- a/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/policy/v2019_09_01/_version.py +++ b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/policy/v2019_09_01/_version.py @@ -6,4 +6,4 @@ # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -VERSION = "21.1.0" +VERSION = "1.0.0b1" diff --git a/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/policy/v2019_09_01/aio/__init__.py b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/policy/v2019_09_01/aio/__init__.py index 2784ce3f14bf5..4622bf1f396a7 100644 --- a/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/policy/v2019_09_01/aio/__init__.py +++ b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/policy/v2019_09_01/aio/__init__.py @@ -7,9 +7,15 @@ # -------------------------------------------------------------------------- from ._policy_client import PolicyClient -__all__ = ['PolicyClient'] -# `._patch.py` is used for handwritten extensions to the generated code -# Example: https://github.com/Azure/azure-sdk-for-python/blob/main/doc/dev/customize_code/how-to-patch-sdk-code.md -from ._patch import patch_sdk -patch_sdk() +try: + from ._patch import __all__ as _patch_all + from ._patch import * # type: ignore # pylint: disable=unused-wildcard-import +except ImportError: + _patch_all = [] +from ._patch import patch_sdk as _patch_sdk + +__all__ = ["PolicyClient"] +__all__.extend([p for p in _patch_all if p not in __all__]) + +_patch_sdk() diff --git a/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/policy/v2019_09_01/aio/_configuration.py b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/policy/v2019_09_01/aio/_configuration.py index 38ab1c393bb97..36e50d37ae45d 100644 --- a/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/policy/v2019_09_01/aio/_configuration.py +++ b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/policy/v2019_09_01/aio/_configuration.py @@ -25,23 +25,18 @@ class PolicyClientConfiguration(Configuration): # pylint: disable=too-many-inst Note that all parameters used to create this instance are saved as instance attributes. - :param credential: Credential needed for the client to connect to Azure. + :param credential: Credential needed for the client to connect to Azure. Required. :type credential: ~azure.core.credentials_async.AsyncTokenCredential - :param subscription_id: The ID of the target subscription. + :param subscription_id: The ID of the target subscription. Required. :type subscription_id: str :keyword api_version: Api Version. Default value is "2019-09-01". Note that overriding this default value may result in unsupported behavior. :paramtype api_version: str """ - def __init__( - self, - credential: "AsyncTokenCredential", - subscription_id: str, - **kwargs: Any - ) -> None: + def __init__(self, credential: "AsyncTokenCredential", subscription_id: str, **kwargs: Any) -> None: super(PolicyClientConfiguration, self).__init__(**kwargs) - api_version = kwargs.pop('api_version', "2019-09-01") # type: str + api_version = kwargs.pop("api_version", "2019-09-01") # type: str if credential is None: raise ValueError("Parameter 'credential' must not be None.") @@ -51,22 +46,21 @@ def __init__( self.credential = credential self.subscription_id = subscription_id self.api_version = api_version - self.credential_scopes = kwargs.pop('credential_scopes', ['https://management.azure.com/.default']) - kwargs.setdefault('sdk_moniker', 'mgmt-resource/{}'.format(VERSION)) + self.credential_scopes = kwargs.pop("credential_scopes", ["https://management.azure.com/.default"]) + kwargs.setdefault("sdk_moniker", "mgmt-resource/{}".format(VERSION)) self._configure(**kwargs) - 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) - self.logging_policy = kwargs.get('logging_policy') or policies.NetworkTraceLoggingPolicy(**kwargs) - self.http_logging_policy = kwargs.get('http_logging_policy') or ARMHttpLoggingPolicy(**kwargs) - self.retry_policy = kwargs.get('retry_policy') or policies.AsyncRetryPolicy(**kwargs) - self.custom_hook_policy = kwargs.get('custom_hook_policy') or policies.CustomHookPolicy(**kwargs) - self.redirect_policy = kwargs.get('redirect_policy') or policies.AsyncRedirectPolicy(**kwargs) - self.authentication_policy = kwargs.get('authentication_policy') + 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) + self.logging_policy = kwargs.get("logging_policy") or policies.NetworkTraceLoggingPolicy(**kwargs) + self.http_logging_policy = kwargs.get("http_logging_policy") or ARMHttpLoggingPolicy(**kwargs) + self.retry_policy = kwargs.get("retry_policy") or policies.AsyncRetryPolicy(**kwargs) + self.custom_hook_policy = kwargs.get("custom_hook_policy") or policies.CustomHookPolicy(**kwargs) + self.redirect_policy = kwargs.get("redirect_policy") or policies.AsyncRedirectPolicy(**kwargs) + self.authentication_policy = kwargs.get("authentication_policy") if self.credential and not self.authentication_policy: - self.authentication_policy = AsyncARMChallengeAuthenticationPolicy(self.credential, *self.credential_scopes, **kwargs) + self.authentication_policy = AsyncARMChallengeAuthenticationPolicy( + self.credential, *self.credential_scopes, **kwargs + ) diff --git a/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/policy/v2019_09_01/aio/_patch.py b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/policy/v2019_09_01/aio/_patch.py index 74e48ecd07cf3..f99e77fef9861 100644 --- a/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/policy/v2019_09_01/aio/_patch.py +++ b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/policy/v2019_09_01/aio/_patch.py @@ -28,4 +28,4 @@ # This file is used for handwritten extensions to the generated code. Example: # https://github.com/Azure/azure-sdk-for-python/blob/main/doc/dev/customize_code/how-to-patch-sdk-code.md def patch_sdk(): - pass \ No newline at end of file + pass diff --git a/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/policy/v2019_09_01/aio/_policy_client.py b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/policy/v2019_09_01/aio/_policy_client.py index e9c1621d75427..46d92a7fe22e4 100644 --- a/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/policy/v2019_09_01/aio/_policy_client.py +++ b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/policy/v2019_09_01/aio/_policy_client.py @@ -9,12 +9,11 @@ from copy import deepcopy from typing import Any, Awaitable, TYPE_CHECKING -from msrest import Deserializer, Serializer - from azure.core.rest import AsyncHttpResponse, HttpRequest from azure.mgmt.core import AsyncARMPipelineClient from .. import models +from ..._serialization import Deserializer, Serializer from ._configuration import PolicyClientConfiguration from .operations import PolicyAssignmentsOperations, PolicyDefinitionsOperations, PolicySetDefinitionsOperations @@ -22,7 +21,8 @@ # pylint: disable=unused-import,ungrouped-imports from azure.core.credentials_async import AsyncTokenCredential -class PolicyClient: + +class PolicyClient: # pylint: disable=client-accepts-api-version-keyword """To manage and control access to your resources, you can define customized policies and assign them at a scope. @@ -35,9 +35,9 @@ class PolicyClient: :ivar policy_set_definitions: PolicySetDefinitionsOperations operations :vartype policy_set_definitions: azure.mgmt.resource.policy.v2019_09_01.aio.operations.PolicySetDefinitionsOperations - :param credential: Credential needed for the client to connect to Azure. + :param credential: Credential needed for the client to connect to Azure. Required. :type credential: ~azure.core.credentials_async.AsyncTokenCredential - :param subscription_id: The ID of the target subscription. + :param subscription_id: The ID of the target subscription. Required. :type subscription_id: str :param base_url: Service URL. Default value is "https://management.azure.com". :type base_url: str @@ -60,16 +60,17 @@ def __init__( self._serialize = Serializer(client_models) self._deserialize = Deserializer(client_models) self._serialize.client_side_validation = False - self.policy_assignments = PolicyAssignmentsOperations(self._client, self._config, self._serialize, self._deserialize) - self.policy_definitions = PolicyDefinitionsOperations(self._client, self._config, self._serialize, self._deserialize) - self.policy_set_definitions = PolicySetDefinitionsOperations(self._client, self._config, self._serialize, self._deserialize) - - - def _send_request( - self, - request: HttpRequest, - **kwargs: Any - ) -> Awaitable[AsyncHttpResponse]: + self.policy_assignments = PolicyAssignmentsOperations( + self._client, self._config, self._serialize, self._deserialize + ) + self.policy_definitions = PolicyDefinitionsOperations( + self._client, self._config, self._serialize, self._deserialize + ) + self.policy_set_definitions = PolicySetDefinitionsOperations( + self._client, self._config, self._serialize, self._deserialize + ) + + def _send_request(self, request: HttpRequest, **kwargs: Any) -> Awaitable[AsyncHttpResponse]: """Runs the network request through the client's chained policies. >>> from azure.core.rest import HttpRequest @@ -78,7 +79,7 @@ def _send_request( >>> response = await client._send_request(request) - For more information on this code flow, see https://aka.ms/azsdk/python/protocol/quickstart + For more information on this code flow, see https://aka.ms/azsdk/dpcodegen/python/send_request :param request: The network request you want to make. Required. :type request: ~azure.core.rest.HttpRequest diff --git a/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/policy/v2019_09_01/aio/operations/__init__.py b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/policy/v2019_09_01/aio/operations/__init__.py index b2ae6190b03fb..4e1971e3e3247 100644 --- a/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/policy/v2019_09_01/aio/operations/__init__.py +++ b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/policy/v2019_09_01/aio/operations/__init__.py @@ -10,8 +10,14 @@ from ._operations import PolicyDefinitionsOperations from ._operations import PolicySetDefinitionsOperations +from ._patch import __all__ as _patch_all +from ._patch import * # type: ignore # pylint: disable=unused-wildcard-import +from ._patch import patch_sdk as _patch_sdk + __all__ = [ - 'PolicyAssignmentsOperations', - 'PolicyDefinitionsOperations', - 'PolicySetDefinitionsOperations', + "PolicyAssignmentsOperations", + "PolicyDefinitionsOperations", + "PolicySetDefinitionsOperations", ] +__all__.extend([p for p in _patch_all if p not in __all__]) +_patch_sdk() diff --git a/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/policy/v2019_09_01/aio/operations/_operations.py b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/policy/v2019_09_01/aio/operations/_operations.py index 53def890ad507..05d81f6183282 100644 --- a/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/policy/v2019_09_01/aio/operations/_operations.py +++ b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/policy/v2019_09_01/aio/operations/_operations.py @@ -6,52 +6,88 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -from typing import Any, AsyncIterable, Callable, Dict, Optional, TypeVar +from typing import Any, AsyncIterable, Callable, Dict, IO, Optional, TypeVar, Union, overload +from urllib.parse import parse_qs, urljoin, urlparse from azure.core.async_paging import AsyncItemPaged, AsyncList -from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error +from azure.core.exceptions import ( + ClientAuthenticationError, + HttpResponseError, + ResourceExistsError, + ResourceNotFoundError, + ResourceNotModifiedError, + map_error, +) from azure.core.pipeline import PipelineResponse from azure.core.pipeline.transport import AsyncHttpResponse from azure.core.rest import HttpRequest from azure.core.tracing.decorator import distributed_trace from azure.core.tracing.decorator_async import distributed_trace_async +from azure.core.utils import case_insensitive_dict from azure.mgmt.core.exceptions import ARMErrorFormat from ... import models as _models from ..._vendor import _convert_request -from ...operations._operations import build_policy_assignments_create_by_id_request, build_policy_assignments_create_request, build_policy_assignments_delete_by_id_request, build_policy_assignments_delete_request, build_policy_assignments_get_by_id_request, build_policy_assignments_get_request, build_policy_assignments_list_for_management_group_request, build_policy_assignments_list_for_resource_group_request, build_policy_assignments_list_for_resource_request, build_policy_assignments_list_request, build_policy_definitions_create_or_update_at_management_group_request, build_policy_definitions_create_or_update_request, build_policy_definitions_delete_at_management_group_request, build_policy_definitions_delete_request, build_policy_definitions_get_at_management_group_request, build_policy_definitions_get_built_in_request, build_policy_definitions_get_request, build_policy_definitions_list_built_in_request, build_policy_definitions_list_by_management_group_request, build_policy_definitions_list_request, build_policy_set_definitions_create_or_update_at_management_group_request, build_policy_set_definitions_create_or_update_request, build_policy_set_definitions_delete_at_management_group_request, build_policy_set_definitions_delete_request, build_policy_set_definitions_get_at_management_group_request, build_policy_set_definitions_get_built_in_request, build_policy_set_definitions_get_request, build_policy_set_definitions_list_built_in_request, build_policy_set_definitions_list_by_management_group_request, build_policy_set_definitions_list_request -T = TypeVar('T') +from ...operations._operations import ( + build_policy_assignments_create_by_id_request, + build_policy_assignments_create_request, + build_policy_assignments_delete_by_id_request, + build_policy_assignments_delete_request, + build_policy_assignments_get_by_id_request, + build_policy_assignments_get_request, + build_policy_assignments_list_for_management_group_request, + build_policy_assignments_list_for_resource_group_request, + build_policy_assignments_list_for_resource_request, + build_policy_assignments_list_request, + build_policy_definitions_create_or_update_at_management_group_request, + build_policy_definitions_create_or_update_request, + build_policy_definitions_delete_at_management_group_request, + build_policy_definitions_delete_request, + build_policy_definitions_get_at_management_group_request, + build_policy_definitions_get_built_in_request, + build_policy_definitions_get_request, + build_policy_definitions_list_built_in_request, + build_policy_definitions_list_by_management_group_request, + build_policy_definitions_list_request, + build_policy_set_definitions_create_or_update_at_management_group_request, + build_policy_set_definitions_create_or_update_request, + build_policy_set_definitions_delete_at_management_group_request, + build_policy_set_definitions_delete_request, + build_policy_set_definitions_get_at_management_group_request, + build_policy_set_definitions_get_built_in_request, + build_policy_set_definitions_get_request, + build_policy_set_definitions_list_built_in_request, + build_policy_set_definitions_list_by_management_group_request, + build_policy_set_definitions_list_request, +) + +T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] -class PolicyAssignmentsOperations: - """PolicyAssignmentsOperations async operations. - You should not instantiate this class directly. Instead, you should create a Client instance that - instantiates it for you and attaches it as an attribute. +class PolicyAssignmentsOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. - :ivar models: Alias to model classes used in this operation group. - :type models: ~azure.mgmt.resource.policy.v2019_09_01.models - :param client: Client for service requests. - :param config: Configuration of service client. - :param serializer: An object model serializer. - :param deserializer: An object model deserializer. + Instead, you should access the following operations through + :class:`~azure.mgmt.resource.policy.v2019_09_01.aio.PolicyClient`'s + :attr:`policy_assignments` attribute. """ models = _models - def __init__(self, client, config, serializer, deserializer) -> None: - self._client = client - self._serialize = serializer - self._deserialize = deserializer - self._config = config + def __init__(self, *args, **kwargs) -> None: + input_args = list(args) + self._client = input_args.pop(0) if input_args else kwargs.pop("client") + self._config = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") @distributed_trace_async async def delete( - self, - scope: str, - policy_assignment_name: str, - **kwargs: Any - ) -> Optional["_models.PolicyAssignment"]: + self, scope: str, policy_assignment_name: str, **kwargs: Any + ) -> Optional[_models.PolicyAssignment]: """Deletes a policy assignment. This operation deletes a policy assignment, given its name and the scope it was created in. The @@ -63,37 +99,44 @@ async def delete( '/subscriptions/{subscriptionId}'), resource group (format: '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}', or resource (format: '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{resourceProviderNamespace}/[{parentResourcePath}/]{resourceType}/{resourceName}'. + Required. :type scope: str - :param policy_assignment_name: The name of the policy assignment to delete. + :param policy_assignment_name: The name of the policy assignment to delete. Required. :type policy_assignment_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: PolicyAssignment, or the result of cls(response) + :return: PolicyAssignment or None or the result of cls(response) :rtype: ~azure.mgmt.resource.policy.v2019_09_01.models.PolicyAssignment or None - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType[Optional["_models.PolicyAssignment"]] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) - api_version = kwargs.pop('api_version', "2019-09-01") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2019-09-01")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[Optional[_models.PolicyAssignment]] - request = build_policy_assignments_delete_request( scope=scope, policy_assignment_name=policy_assignment_name, api_version=api_version, - template_url=self.delete.metadata['url'], + template_url=self.delete.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200, 204]: @@ -102,24 +145,25 @@ async def delete( deserialized = None if response.status_code == 200: - deserialized = self._deserialize('PolicyAssignment', pipeline_response) + deserialized = self._deserialize("PolicyAssignment", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - delete.metadata = {'url': "/{scope}/providers/Microsoft.Authorization/policyAssignments/{policyAssignmentName}"} # type: ignore + delete.metadata = {"url": "/{scope}/providers/Microsoft.Authorization/policyAssignments/{policyAssignmentName}"} # type: ignore - - @distributed_trace_async + @overload async def create( self, scope: str, policy_assignment_name: str, - parameters: "_models.PolicyAssignment", + parameters: _models.PolicyAssignment, + *, + content_type: str = "application/json", **kwargs: Any - ) -> "_models.PolicyAssignment": + ) -> _models.PolicyAssignment: """Creates or updates a policy assignment. This operation creates or updates a policy assignment with the given scope and name. Policy @@ -131,26 +175,109 @@ async def create( '/subscriptions/{subscriptionId}'), resource group (format: '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}', or resource (format: '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{resourceProviderNamespace}/[{parentResourcePath}/]{resourceType}/{resourceName}'. + Required. :type scope: str - :param policy_assignment_name: The name of the policy assignment. + :param policy_assignment_name: The name of the policy assignment. Required. :type policy_assignment_name: str - :param parameters: Parameters for the policy assignment. + :param parameters: Parameters for the policy assignment. Required. :type parameters: ~azure.mgmt.resource.policy.v2019_09_01.models.PolicyAssignment + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: PolicyAssignment or the result of cls(response) + :rtype: ~azure.mgmt.resource.policy.v2019_09_01.models.PolicyAssignment + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + async def create( + self, + scope: str, + policy_assignment_name: str, + parameters: IO, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.PolicyAssignment: + """Creates or updates a policy assignment. + + This operation creates or updates a policy assignment with the given scope and name. Policy + assignments apply to all resources contained within their scope. For example, when you assign a + policy at resource group scope, that policy applies to all resources in the group. + + :param scope: The scope of the policy assignment. Valid scopes are: management group (format: + '/providers/Microsoft.Management/managementGroups/{managementGroup}'), subscription (format: + '/subscriptions/{subscriptionId}'), resource group (format: + '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}', or resource (format: + '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{resourceProviderNamespace}/[{parentResourcePath}/]{resourceType}/{resourceName}'. + Required. + :type scope: str + :param policy_assignment_name: The name of the policy assignment. Required. + :type policy_assignment_name: str + :param parameters: Parameters for the policy assignment. Required. + :type parameters: IO + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: PolicyAssignment, or the result of cls(response) + :return: PolicyAssignment or the result of cls(response) :rtype: ~azure.mgmt.resource.policy.v2019_09_01.models.PolicyAssignment - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace_async + async def create( + self, scope: str, policy_assignment_name: str, parameters: Union[_models.PolicyAssignment, IO], **kwargs: Any + ) -> _models.PolicyAssignment: + """Creates or updates a policy assignment. + + This operation creates or updates a policy assignment with the given scope and name. Policy + assignments apply to all resources contained within their scope. For example, when you assign a + policy at resource group scope, that policy applies to all resources in the group. + + :param scope: The scope of the policy assignment. Valid scopes are: management group (format: + '/providers/Microsoft.Management/managementGroups/{managementGroup}'), subscription (format: + '/subscriptions/{subscriptionId}'), resource group (format: + '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}', or resource (format: + '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{resourceProviderNamespace}/[{parentResourcePath}/]{resourceType}/{resourceName}'. + Required. + :type scope: str + :param policy_assignment_name: The name of the policy assignment. Required. + :type policy_assignment_name: str + :param parameters: Parameters for the policy assignment. Is either a model type or a IO type. + Required. + :type parameters: ~azure.mgmt.resource.policy.v2019_09_01.models.PolicyAssignment or IO + :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. + Default value is None. + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: PolicyAssignment or the result of cls(response) + :rtype: ~azure.mgmt.resource.policy.v2019_09_01.models.PolicyAssignment + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.PolicyAssignment"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', "2019-09-01") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + api_version = kwargs.pop("api_version", _params.pop("api-version", "2019-09-01")) # type: str + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.PolicyAssignment] - _json = self._serialize.body(parameters, 'PolicyAssignment') + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(parameters, (IO, bytes)): + _content = parameters + else: + _json = self._serialize.body(parameters, "PolicyAssignment") request = build_policy_assignments_create_request( scope=scope, @@ -158,39 +285,35 @@ async def create( api_version=api_version, content_type=content_type, json=_json, - template_url=self.create.metadata['url'], + content=_content, + template_url=self.create.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [201]: map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) - deserialized = self._deserialize('PolicyAssignment', pipeline_response) + deserialized = self._deserialize("PolicyAssignment", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - create.metadata = {'url': "/{scope}/providers/Microsoft.Authorization/policyAssignments/{policyAssignmentName}"} # type: ignore - + create.metadata = {"url": "/{scope}/providers/Microsoft.Authorization/policyAssignments/{policyAssignmentName}"} # type: ignore @distributed_trace_async - async def get( - self, - scope: str, - policy_assignment_name: str, - **kwargs: Any - ) -> "_models.PolicyAssignment": + async def get(self, scope: str, policy_assignment_name: str, **kwargs: Any) -> _models.PolicyAssignment: """Retrieves a policy assignment. This operation retrieves a single policy assignment, given its name and the scope it was @@ -201,60 +324,63 @@ async def get( '/subscriptions/{subscriptionId}'), resource group (format: '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}', or resource (format: '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{resourceProviderNamespace}/[{parentResourcePath}/]{resourceType}/{resourceName}'. + Required. :type scope: str - :param policy_assignment_name: The name of the policy assignment to get. + :param policy_assignment_name: The name of the policy assignment to get. Required. :type policy_assignment_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: PolicyAssignment, or the result of cls(response) + :return: PolicyAssignment or the result of cls(response) :rtype: ~azure.mgmt.resource.policy.v2019_09_01.models.PolicyAssignment - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.PolicyAssignment"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + 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', "2019-09-01") # type: str + api_version = kwargs.pop("api_version", _params.pop("api-version", "2019-09-01")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[_models.PolicyAssignment] - request = build_policy_assignments_get_request( scope=scope, policy_assignment_name=policy_assignment_name, api_version=api_version, - template_url=self.get.metadata['url'], + template_url=self.get.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) - deserialized = self._deserialize('PolicyAssignment', pipeline_response) + deserialized = self._deserialize("PolicyAssignment", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - get.metadata = {'url': "/{scope}/providers/Microsoft.Authorization/policyAssignments/{policyAssignmentName}"} # type: ignore - + get.metadata = {"url": "/{scope}/providers/Microsoft.Authorization/policyAssignments/{policyAssignmentName}"} # type: ignore @distributed_trace def list_for_resource_group( - self, - resource_group_name: str, - filter: Optional[str] = None, - **kwargs: Any - ) -> AsyncIterable["_models.PolicyAssignmentListResult"]: + self, resource_group_name: str, filter: Optional[str] = None, **kwargs: Any + ) -> AsyncIterable["_models.PolicyAssignment"]: """Retrieves all policy assignments that apply to a resource group. This operation retrieves the list of all policy assignments associated with the given resource @@ -269,47 +395,55 @@ def list_for_resource_group( assignments of the policy definition whose id is {value} that apply to the resource group. :param resource_group_name: The name of the resource group that contains policy assignments. + Required. :type resource_group_name: str :param filter: The filter to apply on the operation. Valid values for $filter are: 'atScope()' or 'policyDefinitionId eq '{value}''. If $filter is not provided, no filtering is performed. Default value is None. :type filter: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either PolicyAssignmentListResult or the result of - cls(response) + :return: An iterator like instance of either PolicyAssignment or the result of cls(response) :rtype: - ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.resource.policy.v2019_09_01.models.PolicyAssignmentListResult] - :raises: ~azure.core.exceptions.HttpResponseError + ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.resource.policy.v2019_09_01.models.PolicyAssignment] + :raises ~azure.core.exceptions.HttpResponseError: """ - api_version = kwargs.pop('api_version', "2019-09-01") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2019-09-01")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[_models.PolicyAssignmentListResult] - cls = kwargs.pop('cls', None) # type: ClsType["_models.PolicyAssignmentListResult"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) + def prepare_request(next_link=None): if not next_link: - + request = build_policy_assignments_list_for_resource_group_request( resource_group_name=resource_group_name, subscription_id=self._config.subscription_id, - api_version=api_version, filter=filter, - template_url=self.list_for_resource_group.metadata['url'], + api_version=api_version, + template_url=self.list_for_resource_group.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore else: - - request = build_policy_assignments_list_for_resource_group_request( - resource_group_name=resource_group_name, - subscription_id=self._config.subscription_id, - template_url=next_link, - ) + # make call to next link with the client's api-version + _parsed_next_link = urlparse(next_link) + _next_request_params = case_insensitive_dict(parse_qs(_parsed_next_link.query)) + _next_request_params["api-version"] = self._config.api_version + request = HttpRequest("GET", urljoin(next_link, _parsed_next_link.path), params=_next_request_params) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore request.method = "GET" return request @@ -323,10 +457,8 @@ async def extract_data(pipeline_response): async def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) response = pipeline_response.http_response @@ -336,11 +468,9 @@ async def get_next(next_link=None): return pipeline_response + return AsyncItemPaged(get_next, extract_data) - return AsyncItemPaged( - get_next, extract_data - ) - list_for_resource_group.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Authorization/policyAssignments"} # type: ignore + list_for_resource_group.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Authorization/policyAssignments"} # type: ignore @distributed_trace def list_for_resource( @@ -352,7 +482,7 @@ def list_for_resource( resource_name: str, filter: Optional[str] = None, **kwargs: Any - ) -> AsyncIterable["_models.PolicyAssignmentListResult"]: + ) -> AsyncIterable["_models.PolicyAssignment"]: """Retrieves all policy assignments that apply to a resource. This operation retrieves the list of all policy assignments associated with the specified @@ -378,39 +508,47 @@ def list_for_resource( {parentResourcePath} == '', {resourceType} == 'Microsoft.Web/sites', {resourceName} == 'MyWebApp'). - :param resource_group_name: The name of the resource group containing the resource. + :param resource_group_name: The name of the resource group containing the resource. Required. :type resource_group_name: str :param resource_provider_namespace: The namespace of the resource provider. For example, the namespace of a virtual machine is Microsoft.Compute (from Microsoft.Compute/virtualMachines). + Required. :type resource_provider_namespace: str :param parent_resource_path: The parent resource path. Use empty string if there is none. + Required. :type parent_resource_path: str :param resource_type: The resource type name. For example the type name of a web app is 'sites' - (from Microsoft.Web/sites). + (from Microsoft.Web/sites). Required. :type resource_type: str - :param resource_name: The name of the resource. + :param resource_name: The name of the resource. Required. :type resource_name: str :param filter: The filter to apply on the operation. Valid values for $filter are: 'atScope()' or 'policyDefinitionId eq '{value}''. If $filter is not provided, no filtering is performed. Default value is None. :type filter: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either PolicyAssignmentListResult or the result of - cls(response) + :return: An iterator like instance of either PolicyAssignment or the result of cls(response) :rtype: - ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.resource.policy.v2019_09_01.models.PolicyAssignmentListResult] - :raises: ~azure.core.exceptions.HttpResponseError + ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.resource.policy.v2019_09_01.models.PolicyAssignment] + :raises ~azure.core.exceptions.HttpResponseError: """ - api_version = kwargs.pop('api_version', "2019-09-01") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2019-09-01")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[_models.PolicyAssignmentListResult] - cls = kwargs.pop('cls', None) # type: ClsType["_models.PolicyAssignmentListResult"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) + def prepare_request(next_link=None): if not next_link: - + request = build_policy_assignments_list_for_resource_request( resource_group_name=resource_group_name, resource_provider_namespace=resource_provider_namespace, @@ -418,26 +556,23 @@ def prepare_request(next_link=None): resource_type=resource_type, resource_name=resource_name, subscription_id=self._config.subscription_id, - api_version=api_version, filter=filter, - template_url=self.list_for_resource.metadata['url'], + api_version=api_version, + template_url=self.list_for_resource.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore else: - - request = build_policy_assignments_list_for_resource_request( - resource_group_name=resource_group_name, - resource_provider_namespace=resource_provider_namespace, - parent_resource_path=parent_resource_path, - resource_type=resource_type, - resource_name=resource_name, - subscription_id=self._config.subscription_id, - template_url=next_link, - ) + # make call to next link with the client's api-version + _parsed_next_link = urlparse(next_link) + _next_request_params = case_insensitive_dict(parse_qs(_parsed_next_link.query)) + _next_request_params["api-version"] = self._config.api_version + request = HttpRequest("GET", urljoin(next_link, _parsed_next_link.path), params=_next_request_params) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore request.method = "GET" return request @@ -451,10 +586,8 @@ async def extract_data(pipeline_response): async def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) response = pipeline_response.http_response @@ -464,19 +597,14 @@ async def get_next(next_link=None): return pipeline_response + return AsyncItemPaged(get_next, extract_data) - return AsyncItemPaged( - get_next, extract_data - ) - list_for_resource.metadata = {'url': "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{parentResourcePath}/{resourceType}/{resourceName}/providers/Microsoft.Authorization/policyAssignments"} # type: ignore + list_for_resource.metadata = {"url": "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{parentResourcePath}/{resourceType}/{resourceName}/providers/Microsoft.Authorization/policyAssignments"} # type: ignore @distributed_trace def list_for_management_group( - self, - management_group_id: str, - filter: str, - **kwargs: Any - ) -> AsyncIterable["_models.PolicyAssignmentListResult"]: + self, management_group_id: str, filter: str, **kwargs: Any + ) -> AsyncIterable["_models.PolicyAssignment"]: """Retrieves all policy assignments that apply to a management group. This operation retrieves the list of all policy assignments applicable to the management group @@ -486,46 +614,54 @@ def list_for_management_group( $filter=policyDefinitionId eq '{value}' is provided, the returned list includes all policy assignments of the policy definition whose id is {value} that apply to the management group. - :param management_group_id: The ID of the management group. + :param management_group_id: The ID of the management group. Required. :type management_group_id: str :param filter: The filter to apply on the operation. Valid values for $filter are: 'atScope()' or 'policyDefinitionId eq '{value}''. A filter is required when listing policy assignments at - management group scope. + management group scope. Required. :type filter: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either PolicyAssignmentListResult or the result of - cls(response) + :return: An iterator like instance of either PolicyAssignment or the result of cls(response) :rtype: - ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.resource.policy.v2019_09_01.models.PolicyAssignmentListResult] - :raises: ~azure.core.exceptions.HttpResponseError + ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.resource.policy.v2019_09_01.models.PolicyAssignment] + :raises ~azure.core.exceptions.HttpResponseError: """ - api_version = kwargs.pop('api_version', "2019-09-01") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2019-09-01")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[_models.PolicyAssignmentListResult] - cls = kwargs.pop('cls', None) # type: ClsType["_models.PolicyAssignmentListResult"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) + def prepare_request(next_link=None): if not next_link: - + request = build_policy_assignments_list_for_management_group_request( management_group_id=management_group_id, - api_version=api_version, filter=filter, - template_url=self.list_for_management_group.metadata['url'], + api_version=api_version, + template_url=self.list_for_management_group.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore else: - - request = build_policy_assignments_list_for_management_group_request( - management_group_id=management_group_id, - template_url=next_link, - ) + # make call to next link with the client's api-version + _parsed_next_link = urlparse(next_link) + _next_request_params = case_insensitive_dict(parse_qs(_parsed_next_link.query)) + _next_request_params["api-version"] = self._config.api_version + request = HttpRequest("GET", urljoin(next_link, _parsed_next_link.path), params=_next_request_params) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore request.method = "GET" return request @@ -539,10 +675,8 @@ async def extract_data(pipeline_response): async def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) response = pipeline_response.http_response @@ -552,18 +686,12 @@ async def get_next(next_link=None): return pipeline_response + return AsyncItemPaged(get_next, extract_data) - return AsyncItemPaged( - get_next, extract_data - ) - list_for_management_group.metadata = {'url': "/providers/Microsoft.Management/managementgroups/{managementGroupId}/providers/Microsoft.Authorization/policyAssignments"} # type: ignore + list_for_management_group.metadata = {"url": "/providers/Microsoft.Management/managementgroups/{managementGroupId}/providers/Microsoft.Authorization/policyAssignments"} # type: ignore @distributed_trace - def list( - self, - filter: Optional[str] = None, - **kwargs: Any - ) -> AsyncIterable["_models.PolicyAssignmentListResult"]: + def list(self, filter: Optional[str] = None, **kwargs: Any) -> AsyncIterable["_models.PolicyAssignment"]: """Retrieves all policy assignments that apply to a subscription. This operation retrieves the list of all policy assignments associated with the given @@ -582,39 +710,47 @@ def list( Default value is None. :type filter: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either PolicyAssignmentListResult or the result of - cls(response) + :return: An iterator like instance of either PolicyAssignment or the result of cls(response) :rtype: - ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.resource.policy.v2019_09_01.models.PolicyAssignmentListResult] - :raises: ~azure.core.exceptions.HttpResponseError + ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.resource.policy.v2019_09_01.models.PolicyAssignment] + :raises ~azure.core.exceptions.HttpResponseError: """ - api_version = kwargs.pop('api_version', "2019-09-01") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2019-09-01")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[_models.PolicyAssignmentListResult] - cls = kwargs.pop('cls', None) # type: ClsType["_models.PolicyAssignmentListResult"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) + def prepare_request(next_link=None): if not next_link: - + request = build_policy_assignments_list_request( subscription_id=self._config.subscription_id, - api_version=api_version, filter=filter, - template_url=self.list.metadata['url'], + 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.url = self._client.format_url(request.url) # type: ignore else: - - request = build_policy_assignments_list_request( - subscription_id=self._config.subscription_id, - template_url=next_link, - ) + # make call to next link with the client's api-version + _parsed_next_link = urlparse(next_link) + _next_request_params = case_insensitive_dict(parse_qs(_parsed_next_link.query)) + _next_request_params["api-version"] = self._config.api_version + request = HttpRequest("GET", urljoin(next_link, _parsed_next_link.path), params=_next_request_params) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore request.method = "GET" return request @@ -628,10 +764,8 @@ async def extract_data(pipeline_response): async def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) response = pipeline_response.http_response @@ -641,18 +775,12 @@ async def get_next(next_link=None): return pipeline_response + return AsyncItemPaged(get_next, extract_data) - return AsyncItemPaged( - get_next, extract_data - ) - list.metadata = {'url': "/subscriptions/{subscriptionId}/providers/Microsoft.Authorization/policyAssignments"} # type: ignore + list.metadata = {"url": "/subscriptions/{subscriptionId}/providers/Microsoft.Authorization/policyAssignments"} # type: ignore @distributed_trace_async - async def delete_by_id( - self, - policy_assignment_id: str, - **kwargs: Any - ) -> Optional["_models.PolicyAssignment"]: + async def delete_by_id(self, policy_assignment_id: str, **kwargs: Any) -> Optional[_models.PolicyAssignment]: """Deletes a policy assignment. This operation deletes the policy with the given ID. Policy assignment IDs have this format: @@ -664,35 +792,41 @@ async def delete_by_id( (resource). :param policy_assignment_id: The ID of the policy assignment to delete. Use the format - '{scope}/providers/Microsoft.Authorization/policyAssignments/{policyAssignmentName}'. + '{scope}/providers/Microsoft.Authorization/policyAssignments/{policyAssignmentName}'. Required. :type policy_assignment_id: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: PolicyAssignment, or the result of cls(response) + :return: PolicyAssignment or None or the result of cls(response) :rtype: ~azure.mgmt.resource.policy.v2019_09_01.models.PolicyAssignment or None - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType[Optional["_models.PolicyAssignment"]] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) - api_version = kwargs.pop('api_version', "2019-09-01") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2019-09-01")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[Optional[_models.PolicyAssignment]] - request = build_policy_assignments_delete_by_id_request( policy_assignment_id=policy_assignment_id, api_version=api_version, - template_url=self.delete_by_id.metadata['url'], + template_url=self.delete_by_id.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200, 204]: @@ -701,23 +835,24 @@ async def delete_by_id( deserialized = None if response.status_code == 200: - deserialized = self._deserialize('PolicyAssignment', pipeline_response) + deserialized = self._deserialize("PolicyAssignment", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - delete_by_id.metadata = {'url': "/{policyAssignmentId}"} # type: ignore - + delete_by_id.metadata = {"url": "/{policyAssignmentId}"} # type: ignore - @distributed_trace_async + @overload async def create_by_id( self, policy_assignment_id: str, - parameters: "_models.PolicyAssignment", + parameters: _models.PolicyAssignment, + *, + content_type: str = "application/json", **kwargs: Any - ) -> "_models.PolicyAssignment": + ) -> _models.PolicyAssignment: """Creates or updates a policy assignment. This operation creates or updates the policy assignment with the given ID. Policy assignments @@ -732,63 +867,138 @@ async def create_by_id( '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{resourceProviderNamespace}/[{parentResourcePath}/]{resourceType}/{resourceName}'. :param policy_assignment_id: The ID of the policy assignment to create. Use the format - '{scope}/providers/Microsoft.Authorization/policyAssignments/{policyAssignmentName}'. + '{scope}/providers/Microsoft.Authorization/policyAssignments/{policyAssignmentName}'. Required. :type policy_assignment_id: str - :param parameters: Parameters for policy assignment. + :param parameters: Parameters for policy assignment. Required. :type parameters: ~azure.mgmt.resource.policy.v2019_09_01.models.PolicyAssignment + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: PolicyAssignment or the result of cls(response) + :rtype: ~azure.mgmt.resource.policy.v2019_09_01.models.PolicyAssignment + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + async def create_by_id( + self, policy_assignment_id: str, parameters: IO, *, content_type: str = "application/json", **kwargs: Any + ) -> _models.PolicyAssignment: + """Creates or updates a policy assignment. + + This operation creates or updates the policy assignment with the given ID. Policy assignments + made on a scope apply to all resources contained in that scope. For example, when you assign a + policy to a resource group that policy applies to all resources in the group. Policy assignment + IDs have this format: + '{scope}/providers/Microsoft.Authorization/policyAssignments/{policyAssignmentName}'. Valid + scopes are: management group (format: + '/providers/Microsoft.Management/managementGroups/{managementGroup}'), subscription (format: + '/subscriptions/{subscriptionId}'), resource group (format: + '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}', or resource (format: + '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{resourceProviderNamespace}/[{parentResourcePath}/]{resourceType}/{resourceName}'. + + :param policy_assignment_id: The ID of the policy assignment to create. Use the format + '{scope}/providers/Microsoft.Authorization/policyAssignments/{policyAssignmentName}'. Required. + :type policy_assignment_id: str + :param parameters: Parameters for policy assignment. Required. + :type parameters: IO + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: PolicyAssignment, or the result of cls(response) + :return: PolicyAssignment or the result of cls(response) :rtype: ~azure.mgmt.resource.policy.v2019_09_01.models.PolicyAssignment - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace_async + async def create_by_id( + self, policy_assignment_id: str, parameters: Union[_models.PolicyAssignment, IO], **kwargs: Any + ) -> _models.PolicyAssignment: + """Creates or updates a policy assignment. + + This operation creates or updates the policy assignment with the given ID. Policy assignments + made on a scope apply to all resources contained in that scope. For example, when you assign a + policy to a resource group that policy applies to all resources in the group. Policy assignment + IDs have this format: + '{scope}/providers/Microsoft.Authorization/policyAssignments/{policyAssignmentName}'. Valid + scopes are: management group (format: + '/providers/Microsoft.Management/managementGroups/{managementGroup}'), subscription (format: + '/subscriptions/{subscriptionId}'), resource group (format: + '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}', or resource (format: + '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{resourceProviderNamespace}/[{parentResourcePath}/]{resourceType}/{resourceName}'. + + :param policy_assignment_id: The ID of the policy assignment to create. Use the format + '{scope}/providers/Microsoft.Authorization/policyAssignments/{policyAssignmentName}'. Required. + :type policy_assignment_id: str + :param parameters: Parameters for policy assignment. Is either a model type or a IO type. + Required. + :type parameters: ~azure.mgmt.resource.policy.v2019_09_01.models.PolicyAssignment or IO + :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. + Default value is None. + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: PolicyAssignment or the result of cls(response) + :rtype: ~azure.mgmt.resource.policy.v2019_09_01.models.PolicyAssignment + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.PolicyAssignment"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', "2019-09-01") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + api_version = kwargs.pop("api_version", _params.pop("api-version", "2019-09-01")) # type: str + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.PolicyAssignment] - _json = self._serialize.body(parameters, 'PolicyAssignment') + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(parameters, (IO, bytes)): + _content = parameters + else: + _json = self._serialize.body(parameters, "PolicyAssignment") request = build_policy_assignments_create_by_id_request( policy_assignment_id=policy_assignment_id, api_version=api_version, content_type=content_type, json=_json, - template_url=self.create_by_id.metadata['url'], + content=_content, + template_url=self.create_by_id.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [201]: map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) - deserialized = self._deserialize('PolicyAssignment', pipeline_response) + deserialized = self._deserialize("PolicyAssignment", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - create_by_id.metadata = {'url': "/{policyAssignmentId}"} # type: ignore - + create_by_id.metadata = {"url": "/{policyAssignmentId}"} # type: ignore @distributed_trace_async - async def get_by_id( - self, - policy_assignment_id: str, - **kwargs: Any - ) -> "_models.PolicyAssignment": + async def get_by_id(self, policy_assignment_id: str, **kwargs: Any) -> _models.PolicyAssignment: """Retrieves the policy assignment with the given ID. The operation retrieves the policy assignment with the given ID. Policy assignment IDs have @@ -801,103 +1011,169 @@ async def get_by_id( '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{resourceProviderNamespace}/[{parentResourcePath}/]{resourceType}/{resourceName}'. :param policy_assignment_id: The ID of the policy assignment to get. Use the format - '{scope}/providers/Microsoft.Authorization/policyAssignments/{policyAssignmentName}'. + '{scope}/providers/Microsoft.Authorization/policyAssignments/{policyAssignmentName}'. Required. :type policy_assignment_id: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: PolicyAssignment, or the result of cls(response) + :return: PolicyAssignment or the result of cls(response) :rtype: ~azure.mgmt.resource.policy.v2019_09_01.models.PolicyAssignment - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.PolicyAssignment"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) - api_version = kwargs.pop('api_version', "2019-09-01") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2019-09-01")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[_models.PolicyAssignment] - request = build_policy_assignments_get_by_id_request( policy_assignment_id=policy_assignment_id, api_version=api_version, - template_url=self.get_by_id.metadata['url'], + template_url=self.get_by_id.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) - deserialized = self._deserialize('PolicyAssignment', pipeline_response) + deserialized = self._deserialize("PolicyAssignment", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - get_by_id.metadata = {'url': "/{policyAssignmentId}"} # type: ignore + get_by_id.metadata = {"url": "/{policyAssignmentId}"} # type: ignore -class PolicyDefinitionsOperations: - """PolicyDefinitionsOperations async operations. - You should not instantiate this class directly. Instead, you should create a Client instance that - instantiates it for you and attaches it as an attribute. +class PolicyDefinitionsOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. - :ivar models: Alias to model classes used in this operation group. - :type models: ~azure.mgmt.resource.policy.v2019_09_01.models - :param client: Client for service requests. - :param config: Configuration of service client. - :param serializer: An object model serializer. - :param deserializer: An object model deserializer. + Instead, you should access the following operations through + :class:`~azure.mgmt.resource.policy.v2019_09_01.aio.PolicyClient`'s + :attr:`policy_definitions` attribute. """ models = _models - def __init__(self, client, config, serializer, deserializer) -> None: - self._client = client - self._serialize = serializer - self._deserialize = deserializer - self._config = config + def __init__(self, *args, **kwargs) -> None: + input_args = list(args) + self._client = input_args.pop(0) if input_args else kwargs.pop("client") + self._config = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") - @distributed_trace_async + @overload async def create_or_update( self, policy_definition_name: str, - parameters: "_models.PolicyDefinition", + parameters: _models.PolicyDefinition, + *, + content_type: str = "application/json", **kwargs: Any - ) -> "_models.PolicyDefinition": + ) -> _models.PolicyDefinition: """Creates or updates a policy definition in a subscription. This operation creates or updates a policy definition in the given subscription with the given name. - :param policy_definition_name: The name of the policy definition to create. + :param policy_definition_name: The name of the policy definition to create. Required. :type policy_definition_name: str - :param parameters: The policy definition properties. + :param parameters: The policy definition properties. Required. :type parameters: ~azure.mgmt.resource.policy.v2019_09_01.models.PolicyDefinition + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: PolicyDefinition, or the result of cls(response) + :return: PolicyDefinition or the result of cls(response) :rtype: ~azure.mgmt.resource.policy.v2019_09_01.models.PolicyDefinition - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + async def create_or_update( + self, policy_definition_name: str, parameters: IO, *, content_type: str = "application/json", **kwargs: Any + ) -> _models.PolicyDefinition: + """Creates or updates a policy definition in a subscription. + + This operation creates or updates a policy definition in the given subscription with the given + name. + + :param policy_definition_name: The name of the policy definition to create. Required. + :type policy_definition_name: str + :param parameters: The policy definition properties. Required. + :type parameters: IO + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: PolicyDefinition or the result of cls(response) + :rtype: ~azure.mgmt.resource.policy.v2019_09_01.models.PolicyDefinition + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace_async + async def create_or_update( + self, policy_definition_name: str, parameters: Union[_models.PolicyDefinition, IO], **kwargs: Any + ) -> _models.PolicyDefinition: + """Creates or updates a policy definition in a subscription. + + This operation creates or updates a policy definition in the given subscription with the given + name. + + :param policy_definition_name: The name of the policy definition to create. Required. + :type policy_definition_name: str + :param parameters: The policy definition properties. Is either a model type or a IO type. + Required. + :type parameters: ~azure.mgmt.resource.policy.v2019_09_01.models.PolicyDefinition or IO + :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. + Default value is None. + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: PolicyDefinition or the result of cls(response) + :rtype: ~azure.mgmt.resource.policy.v2019_09_01.models.PolicyDefinition + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.PolicyDefinition"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', "2019-09-01") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + api_version = kwargs.pop("api_version", _params.pop("api-version", "2019-09-01")) # type: str + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.PolicyDefinition] - _json = self._serialize.body(parameters, 'PolicyDefinition') + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(parameters, (IO, bytes)): + _content = parameters + else: + _json = self._serialize.body(parameters, "PolicyDefinition") request = build_policy_definitions_create_or_update_request( policy_definition_name=policy_definition_name, @@ -905,72 +1181,77 @@ async def create_or_update( api_version=api_version, content_type=content_type, json=_json, - template_url=self.create_or_update.metadata['url'], + content=_content, + template_url=self.create_or_update.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [201]: map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) - deserialized = self._deserialize('PolicyDefinition', pipeline_response) + deserialized = self._deserialize("PolicyDefinition", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - create_or_update.metadata = {'url': "/subscriptions/{subscriptionId}/providers/Microsoft.Authorization/policyDefinitions/{policyDefinitionName}"} # type: ignore - + create_or_update.metadata = {"url": "/subscriptions/{subscriptionId}/providers/Microsoft.Authorization/policyDefinitions/{policyDefinitionName}"} # type: ignore @distributed_trace_async async def delete( # pylint: disable=inconsistent-return-statements - self, - policy_definition_name: str, - **kwargs: Any + self, policy_definition_name: str, **kwargs: Any ) -> None: """Deletes a policy definition in a subscription. This operation deletes the policy definition in the given subscription with the given name. - :param policy_definition_name: The name of the policy definition to delete. + :param policy_definition_name: The name of the policy definition to delete. Required. :type policy_definition_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: None, or the result of cls(response) + :return: None or the result of cls(response) :rtype: None - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType[None] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + 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', "2019-09-01") # type: str + api_version = kwargs.pop("api_version", _params.pop("api-version", "2019-09-01")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[None] - request = build_policy_definitions_delete_request( policy_definition_name=policy_definition_name, subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.delete.metadata['url'], + template_url=self.delete.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200, 204]: @@ -980,154 +1261,231 @@ async def delete( # pylint: disable=inconsistent-return-statements if cls: return cls(pipeline_response, None, {}) - delete.metadata = {'url': "/subscriptions/{subscriptionId}/providers/Microsoft.Authorization/policyDefinitions/{policyDefinitionName}"} # type: ignore - + delete.metadata = {"url": "/subscriptions/{subscriptionId}/providers/Microsoft.Authorization/policyDefinitions/{policyDefinitionName}"} # type: ignore @distributed_trace_async - async def get( - self, - policy_definition_name: str, - **kwargs: Any - ) -> "_models.PolicyDefinition": + async def get(self, policy_definition_name: str, **kwargs: Any) -> _models.PolicyDefinition: """Retrieves a policy definition in a subscription. This operation retrieves the policy definition in the given subscription with the given name. - :param policy_definition_name: The name of the policy definition to get. + :param policy_definition_name: The name of the policy definition to get. Required. :type policy_definition_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: PolicyDefinition, or the result of cls(response) + :return: PolicyDefinition or the result of cls(response) :rtype: ~azure.mgmt.resource.policy.v2019_09_01.models.PolicyDefinition - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.PolicyDefinition"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + 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', "2019-09-01") # type: str + api_version = kwargs.pop("api_version", _params.pop("api-version", "2019-09-01")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[_models.PolicyDefinition] - request = build_policy_definitions_get_request( policy_definition_name=policy_definition_name, subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.get.metadata['url'], + template_url=self.get.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) - deserialized = self._deserialize('PolicyDefinition', pipeline_response) + deserialized = self._deserialize("PolicyDefinition", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - get.metadata = {'url': "/subscriptions/{subscriptionId}/providers/Microsoft.Authorization/policyDefinitions/{policyDefinitionName}"} # type: ignore - + get.metadata = {"url": "/subscriptions/{subscriptionId}/providers/Microsoft.Authorization/policyDefinitions/{policyDefinitionName}"} # type: ignore @distributed_trace_async - async def get_built_in( - self, - policy_definition_name: str, - **kwargs: Any - ) -> "_models.PolicyDefinition": + async def get_built_in(self, policy_definition_name: str, **kwargs: Any) -> _models.PolicyDefinition: """Retrieves a built-in policy definition. This operation retrieves the built-in policy definition with the given name. - :param policy_definition_name: The name of the built-in policy definition to get. + :param policy_definition_name: The name of the built-in policy definition to get. Required. :type policy_definition_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: PolicyDefinition, or the result of cls(response) + :return: PolicyDefinition or the result of cls(response) :rtype: ~azure.mgmt.resource.policy.v2019_09_01.models.PolicyDefinition - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.PolicyDefinition"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) - api_version = kwargs.pop('api_version', "2019-09-01") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2019-09-01")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[_models.PolicyDefinition] - request = build_policy_definitions_get_built_in_request( policy_definition_name=policy_definition_name, api_version=api_version, - template_url=self.get_built_in.metadata['url'], + template_url=self.get_built_in.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) - deserialized = self._deserialize('PolicyDefinition', pipeline_response) + deserialized = self._deserialize("PolicyDefinition", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - get_built_in.metadata = {'url': "/providers/Microsoft.Authorization/policyDefinitions/{policyDefinitionName}"} # type: ignore + get_built_in.metadata = {"url": "/providers/Microsoft.Authorization/policyDefinitions/{policyDefinitionName}"} # type: ignore + + @overload + async def create_or_update_at_management_group( + self, + policy_definition_name: str, + management_group_id: str, + parameters: _models.PolicyDefinition, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.PolicyDefinition: + """Creates or updates a policy definition in a management group. + + This operation creates or updates a policy definition in the given management group with the + given name. + + :param policy_definition_name: The name of the policy definition to create. Required. + :type policy_definition_name: str + :param management_group_id: The ID of the management group. Required. + :type management_group_id: str + :param parameters: The policy definition properties. Required. + :type parameters: ~azure.mgmt.resource.policy.v2019_09_01.models.PolicyDefinition + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: PolicyDefinition or the result of cls(response) + :rtype: ~azure.mgmt.resource.policy.v2019_09_01.models.PolicyDefinition + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + async def create_or_update_at_management_group( + self, + policy_definition_name: str, + management_group_id: str, + parameters: IO, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.PolicyDefinition: + """Creates or updates a policy definition in a management group. + + This operation creates or updates a policy definition in the given management group with the + given name. + :param policy_definition_name: The name of the policy definition to create. Required. + :type policy_definition_name: str + :param management_group_id: The ID of the management group. Required. + :type management_group_id: str + :param parameters: The policy definition properties. Required. + :type parameters: IO + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: PolicyDefinition or the result of cls(response) + :rtype: ~azure.mgmt.resource.policy.v2019_09_01.models.PolicyDefinition + :raises ~azure.core.exceptions.HttpResponseError: + """ @distributed_trace_async async def create_or_update_at_management_group( self, policy_definition_name: str, management_group_id: str, - parameters: "_models.PolicyDefinition", + parameters: Union[_models.PolicyDefinition, IO], **kwargs: Any - ) -> "_models.PolicyDefinition": + ) -> _models.PolicyDefinition: """Creates or updates a policy definition in a management group. This operation creates or updates a policy definition in the given management group with the given name. - :param policy_definition_name: The name of the policy definition to create. + :param policy_definition_name: The name of the policy definition to create. Required. :type policy_definition_name: str - :param management_group_id: The ID of the management group. + :param management_group_id: The ID of the management group. Required. :type management_group_id: str - :param parameters: The policy definition properties. - :type parameters: ~azure.mgmt.resource.policy.v2019_09_01.models.PolicyDefinition + :param parameters: The policy definition properties. Is either a model type or a IO type. + Required. + :type parameters: ~azure.mgmt.resource.policy.v2019_09_01.models.PolicyDefinition or IO + :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. + Default value is None. + :paramtype content_type: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: PolicyDefinition, or the result of cls(response) + :return: PolicyDefinition or the result of cls(response) :rtype: ~azure.mgmt.resource.policy.v2019_09_01.models.PolicyDefinition - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.PolicyDefinition"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', "2019-09-01") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + api_version = kwargs.pop("api_version", _params.pop("api-version", "2019-09-01")) # type: str + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.PolicyDefinition] - _json = self._serialize.body(parameters, 'PolicyDefinition') + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(parameters, (IO, bytes)): + _content = parameters + else: + _json = self._serialize.body(parameters, "PolicyDefinition") request = build_policy_definitions_create_or_update_at_management_group_request( policy_definition_name=policy_definition_name, @@ -1135,75 +1493,79 @@ async def create_or_update_at_management_group( api_version=api_version, content_type=content_type, json=_json, - template_url=self.create_or_update_at_management_group.metadata['url'], + content=_content, + template_url=self.create_or_update_at_management_group.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [201]: map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) - deserialized = self._deserialize('PolicyDefinition', pipeline_response) + deserialized = self._deserialize("PolicyDefinition", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - create_or_update_at_management_group.metadata = {'url': "/providers/Microsoft.Management/managementgroups/{managementGroupId}/providers/Microsoft.Authorization/policyDefinitions/{policyDefinitionName}"} # type: ignore - + create_or_update_at_management_group.metadata = {"url": "/providers/Microsoft.Management/managementgroups/{managementGroupId}/providers/Microsoft.Authorization/policyDefinitions/{policyDefinitionName}"} # type: ignore @distributed_trace_async async def delete_at_management_group( # pylint: disable=inconsistent-return-statements - self, - policy_definition_name: str, - management_group_id: str, - **kwargs: Any + self, policy_definition_name: str, management_group_id: str, **kwargs: Any ) -> None: """Deletes a policy definition in a management group. This operation deletes the policy definition in the given management group with the given name. - :param policy_definition_name: The name of the policy definition to delete. + :param policy_definition_name: The name of the policy definition to delete. Required. :type policy_definition_name: str - :param management_group_id: The ID of the management group. + :param management_group_id: The ID of the management group. Required. :type management_group_id: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: None, or the result of cls(response) + :return: None or the result of cls(response) :rtype: None - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType[None] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + 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', "2019-09-01") # type: str + api_version = kwargs.pop("api_version", _params.pop("api-version", "2019-09-01")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[None] - request = build_policy_definitions_delete_at_management_group_request( policy_definition_name=policy_definition_name, management_group_id=management_group_id, api_version=api_version, - template_url=self.delete_at_management_group.metadata['url'], + template_url=self.delete_at_management_group.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200, 204]: @@ -1213,111 +1575,117 @@ async def delete_at_management_group( # pylint: disable=inconsistent-return-sta if cls: return cls(pipeline_response, None, {}) - delete_at_management_group.metadata = {'url': "/providers/Microsoft.Management/managementgroups/{managementGroupId}/providers/Microsoft.Authorization/policyDefinitions/{policyDefinitionName}"} # type: ignore - + delete_at_management_group.metadata = {"url": "/providers/Microsoft.Management/managementgroups/{managementGroupId}/providers/Microsoft.Authorization/policyDefinitions/{policyDefinitionName}"} # type: ignore @distributed_trace_async async def get_at_management_group( - self, - policy_definition_name: str, - management_group_id: str, - **kwargs: Any - ) -> "_models.PolicyDefinition": + self, policy_definition_name: str, management_group_id: str, **kwargs: Any + ) -> _models.PolicyDefinition: """Retrieve a policy definition in a management group. This operation retrieves the policy definition in the given management group with the given name. - :param policy_definition_name: The name of the policy definition to get. + :param policy_definition_name: The name of the policy definition to get. Required. :type policy_definition_name: str - :param management_group_id: The ID of the management group. + :param management_group_id: The ID of the management group. Required. :type management_group_id: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: PolicyDefinition, or the result of cls(response) + :return: PolicyDefinition or the result of cls(response) :rtype: ~azure.mgmt.resource.policy.v2019_09_01.models.PolicyDefinition - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.PolicyDefinition"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) - api_version = kwargs.pop('api_version', "2019-09-01") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2019-09-01")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[_models.PolicyDefinition] - request = build_policy_definitions_get_at_management_group_request( policy_definition_name=policy_definition_name, management_group_id=management_group_id, api_version=api_version, - template_url=self.get_at_management_group.metadata['url'], + template_url=self.get_at_management_group.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) - deserialized = self._deserialize('PolicyDefinition', pipeline_response) + deserialized = self._deserialize("PolicyDefinition", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - get_at_management_group.metadata = {'url': "/providers/Microsoft.Management/managementgroups/{managementGroupId}/providers/Microsoft.Authorization/policyDefinitions/{policyDefinitionName}"} # type: ignore - + get_at_management_group.metadata = {"url": "/providers/Microsoft.Management/managementgroups/{managementGroupId}/providers/Microsoft.Authorization/policyDefinitions/{policyDefinitionName}"} # type: ignore @distributed_trace - def list( - self, - **kwargs: Any - ) -> AsyncIterable["_models.PolicyDefinitionListResult"]: + def list(self, **kwargs: Any) -> AsyncIterable["_models.PolicyDefinition"]: """Retrieves policy definitions in a subscription. This operation retrieves a list of all the policy definitions in a given subscription. :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either PolicyDefinitionListResult or the result of - cls(response) + :return: An iterator like instance of either PolicyDefinition or the result of cls(response) :rtype: - ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.resource.policy.v2019_09_01.models.PolicyDefinitionListResult] - :raises: ~azure.core.exceptions.HttpResponseError + ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.resource.policy.v2019_09_01.models.PolicyDefinition] + :raises ~azure.core.exceptions.HttpResponseError: """ - api_version = kwargs.pop('api_version', "2019-09-01") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2019-09-01")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[_models.PolicyDefinitionListResult] - cls = kwargs.pop('cls', None) # type: ClsType["_models.PolicyDefinitionListResult"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) + def prepare_request(next_link=None): if not next_link: - + request = build_policy_definitions_list_request( subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.list.metadata['url'], + template_url=self.list.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore else: - - request = build_policy_definitions_list_request( - subscription_id=self._config.subscription_id, - template_url=next_link, - ) + # make call to next link with the client's api-version + _parsed_next_link = urlparse(next_link) + _next_request_params = case_insensitive_dict(parse_qs(_parsed_next_link.query)) + _next_request_params["api-version"] = self._config.api_version + request = HttpRequest("GET", urljoin(next_link, _parsed_next_link.path), params=_next_request_params) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore request.method = "GET" return request @@ -1331,10 +1699,8 @@ async def extract_data(pipeline_response): async def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) response = pipeline_response.http_response @@ -1344,52 +1710,56 @@ async def get_next(next_link=None): return pipeline_response + return AsyncItemPaged(get_next, extract_data) - return AsyncItemPaged( - get_next, extract_data - ) - list.metadata = {'url': "/subscriptions/{subscriptionId}/providers/Microsoft.Authorization/policyDefinitions"} # type: ignore + list.metadata = {"url": "/subscriptions/{subscriptionId}/providers/Microsoft.Authorization/policyDefinitions"} # type: ignore @distributed_trace - def list_built_in( - self, - **kwargs: Any - ) -> AsyncIterable["_models.PolicyDefinitionListResult"]: + def list_built_in(self, **kwargs: Any) -> AsyncIterable["_models.PolicyDefinition"]: """Retrieve built-in policy definitions. This operation retrieves a list of all the built-in policy definitions. :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either PolicyDefinitionListResult or the result of - cls(response) + :return: An iterator like instance of either PolicyDefinition or the result of cls(response) :rtype: - ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.resource.policy.v2019_09_01.models.PolicyDefinitionListResult] - :raises: ~azure.core.exceptions.HttpResponseError + ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.resource.policy.v2019_09_01.models.PolicyDefinition] + :raises ~azure.core.exceptions.HttpResponseError: """ - api_version = kwargs.pop('api_version', "2019-09-01") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2019-09-01")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[_models.PolicyDefinitionListResult] - cls = kwargs.pop('cls', None) # type: ClsType["_models.PolicyDefinitionListResult"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) + def prepare_request(next_link=None): if not next_link: - + request = build_policy_definitions_list_built_in_request( api_version=api_version, - template_url=self.list_built_in.metadata['url'], + template_url=self.list_built_in.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore else: - - request = build_policy_definitions_list_built_in_request( - template_url=next_link, - ) + # make call to next link with the client's api-version + _parsed_next_link = urlparse(next_link) + _next_request_params = case_insensitive_dict(parse_qs(_parsed_next_link.query)) + _next_request_params["api-version"] = self._config.api_version + request = HttpRequest("GET", urljoin(next_link, _parsed_next_link.path), params=_next_request_params) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore request.method = "GET" return request @@ -1403,10 +1773,8 @@ async def extract_data(pipeline_response): async def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) response = pipeline_response.http_response @@ -1416,57 +1784,61 @@ async def get_next(next_link=None): return pipeline_response + return AsyncItemPaged(get_next, extract_data) - return AsyncItemPaged( - get_next, extract_data - ) - list_built_in.metadata = {'url': "/providers/Microsoft.Authorization/policyDefinitions"} # type: ignore + list_built_in.metadata = {"url": "/providers/Microsoft.Authorization/policyDefinitions"} # type: ignore @distributed_trace def list_by_management_group( - self, - management_group_id: str, - **kwargs: Any - ) -> AsyncIterable["_models.PolicyDefinitionListResult"]: + self, management_group_id: str, **kwargs: Any + ) -> AsyncIterable["_models.PolicyDefinition"]: """Retrieve policy definitions in a management group. This operation retrieves a list of all the policy definitions in a given management group. - :param management_group_id: The ID of the management group. + :param management_group_id: The ID of the management group. Required. :type management_group_id: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either PolicyDefinitionListResult or the result of - cls(response) + :return: An iterator like instance of either PolicyDefinition or the result of cls(response) :rtype: - ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.resource.policy.v2019_09_01.models.PolicyDefinitionListResult] - :raises: ~azure.core.exceptions.HttpResponseError + ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.resource.policy.v2019_09_01.models.PolicyDefinition] + :raises ~azure.core.exceptions.HttpResponseError: """ - api_version = kwargs.pop('api_version', "2019-09-01") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2019-09-01")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[_models.PolicyDefinitionListResult] - cls = kwargs.pop('cls', None) # type: ClsType["_models.PolicyDefinitionListResult"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) + def prepare_request(next_link=None): if not next_link: - + request = build_policy_definitions_list_by_management_group_request( management_group_id=management_group_id, api_version=api_version, - template_url=self.list_by_management_group.metadata['url'], + template_url=self.list_by_management_group.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore else: - - request = build_policy_definitions_list_by_management_group_request( - management_group_id=management_group_id, - template_url=next_link, - ) + # make call to next link with the client's api-version + _parsed_next_link = urlparse(next_link) + _next_request_params = case_insensitive_dict(parse_qs(_parsed_next_link.query)) + _next_request_params["api-version"] = self._config.api_version + request = HttpRequest("GET", urljoin(next_link, _parsed_next_link.path), params=_next_request_params) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore request.method = "GET" return request @@ -1480,10 +1852,8 @@ async def extract_data(pipeline_response): async def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) response = pipeline_response.http_response @@ -1493,64 +1863,123 @@ async def get_next(next_link=None): return pipeline_response + return AsyncItemPaged(get_next, extract_data) - return AsyncItemPaged( - get_next, extract_data - ) - list_by_management_group.metadata = {'url': "/providers/Microsoft.Management/managementgroups/{managementGroupId}/providers/Microsoft.Authorization/policyDefinitions"} # type: ignore -class PolicySetDefinitionsOperations: - """PolicySetDefinitionsOperations async operations. + list_by_management_group.metadata = {"url": "/providers/Microsoft.Management/managementgroups/{managementGroupId}/providers/Microsoft.Authorization/policyDefinitions"} # type: ignore - You should not instantiate this class directly. Instead, you should create a Client instance that - instantiates it for you and attaches it as an attribute. - :ivar models: Alias to model classes used in this operation group. - :type models: ~azure.mgmt.resource.policy.v2019_09_01.models - :param client: Client for service requests. - :param config: Configuration of service client. - :param serializer: An object model serializer. - :param deserializer: An object model deserializer. +class PolicySetDefinitionsOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. + + Instead, you should access the following operations through + :class:`~azure.mgmt.resource.policy.v2019_09_01.aio.PolicyClient`'s + :attr:`policy_set_definitions` attribute. """ models = _models - def __init__(self, client, config, serializer, deserializer) -> None: - self._client = client - self._serialize = serializer - self._deserialize = deserializer - self._config = config + def __init__(self, *args, **kwargs) -> None: + input_args = list(args) + self._client = input_args.pop(0) if input_args else kwargs.pop("client") + self._config = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") - @distributed_trace_async + @overload async def create_or_update( self, policy_set_definition_name: str, - parameters: "_models.PolicySetDefinition", + parameters: _models.PolicySetDefinition, + *, + content_type: str = "application/json", **kwargs: Any - ) -> "_models.PolicySetDefinition": + ) -> _models.PolicySetDefinition: """Creates or updates a policy set definition. This operation creates or updates a policy set definition in the given subscription with the given name. - :param policy_set_definition_name: The name of the policy set definition to create. + :param policy_set_definition_name: The name of the policy set definition to create. Required. :type policy_set_definition_name: str - :param parameters: The policy set definition properties. + :param parameters: The policy set definition properties. Required. :type parameters: ~azure.mgmt.resource.policy.v2019_09_01.models.PolicySetDefinition + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: PolicySetDefinition or the result of cls(response) + :rtype: ~azure.mgmt.resource.policy.v2019_09_01.models.PolicySetDefinition + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + async def create_or_update( + self, policy_set_definition_name: str, parameters: IO, *, content_type: str = "application/json", **kwargs: Any + ) -> _models.PolicySetDefinition: + """Creates or updates a policy set definition. + + This operation creates or updates a policy set definition in the given subscription with the + given name. + + :param policy_set_definition_name: The name of the policy set definition to create. Required. + :type policy_set_definition_name: str + :param parameters: The policy set definition properties. Required. + :type parameters: IO + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: PolicySetDefinition, or the result of cls(response) + :return: PolicySetDefinition or the result of cls(response) :rtype: ~azure.mgmt.resource.policy.v2019_09_01.models.PolicySetDefinition - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace_async + async def create_or_update( + self, policy_set_definition_name: str, parameters: Union[_models.PolicySetDefinition, IO], **kwargs: Any + ) -> _models.PolicySetDefinition: + """Creates or updates a policy set definition. + + This operation creates or updates a policy set definition in the given subscription with the + given name. + + :param policy_set_definition_name: The name of the policy set definition to create. Required. + :type policy_set_definition_name: str + :param parameters: The policy set definition properties. Is either a model type or a IO type. + Required. + :type parameters: ~azure.mgmt.resource.policy.v2019_09_01.models.PolicySetDefinition or IO + :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. + Default value is None. + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: PolicySetDefinition or the result of cls(response) + :rtype: ~azure.mgmt.resource.policy.v2019_09_01.models.PolicySetDefinition + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.PolicySetDefinition"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', "2019-09-01") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + api_version = kwargs.pop("api_version", _params.pop("api-version", "2019-09-01")) # type: str + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.PolicySetDefinition] - _json = self._serialize.body(parameters, 'PolicySetDefinition') + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(parameters, (IO, bytes)): + _content = parameters + else: + _json = self._serialize.body(parameters, "PolicySetDefinition") request = build_policy_set_definitions_create_or_update_request( policy_set_definition_name=policy_set_definition_name, @@ -1558,16 +1987,18 @@ async def create_or_update( api_version=api_version, content_type=content_type, json=_json, - template_url=self.create_or_update.metadata['url'], + content=_content, + template_url=self.create_or_update.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200, 201]: @@ -1575,59 +2006,62 @@ async def create_or_update( raise HttpResponseError(response=response, error_format=ARMErrorFormat) if response.status_code == 200: - deserialized = self._deserialize('PolicySetDefinition', pipeline_response) + deserialized = self._deserialize("PolicySetDefinition", pipeline_response) if response.status_code == 201: - deserialized = self._deserialize('PolicySetDefinition', pipeline_response) + deserialized = self._deserialize("PolicySetDefinition", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - create_or_update.metadata = {'url': "/subscriptions/{subscriptionId}/providers/Microsoft.Authorization/policySetDefinitions/{policySetDefinitionName}"} # type: ignore - + create_or_update.metadata = {"url": "/subscriptions/{subscriptionId}/providers/Microsoft.Authorization/policySetDefinitions/{policySetDefinitionName}"} # type: ignore @distributed_trace_async async def delete( # pylint: disable=inconsistent-return-statements - self, - policy_set_definition_name: str, - **kwargs: Any + self, policy_set_definition_name: str, **kwargs: Any ) -> None: """Deletes a policy set definition. This operation deletes the policy set definition in the given subscription with the given name. - :param policy_set_definition_name: The name of the policy set definition to delete. + :param policy_set_definition_name: The name of the policy set definition to delete. Required. :type policy_set_definition_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: None, or the result of cls(response) + :return: None or the result of cls(response) :rtype: None - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType[None] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + 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', "2019-09-01") # type: str + api_version = kwargs.pop("api_version", _params.pop("api-version", "2019-09-01")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[None] - request = build_policy_set_definitions_delete_request( policy_set_definition_name=policy_set_definition_name, subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.delete.metadata['url'], + template_url=self.delete.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200, 204]: @@ -1637,163 +2071,169 @@ async def delete( # pylint: disable=inconsistent-return-statements if cls: return cls(pipeline_response, None, {}) - delete.metadata = {'url': "/subscriptions/{subscriptionId}/providers/Microsoft.Authorization/policySetDefinitions/{policySetDefinitionName}"} # type: ignore - + delete.metadata = {"url": "/subscriptions/{subscriptionId}/providers/Microsoft.Authorization/policySetDefinitions/{policySetDefinitionName}"} # type: ignore @distributed_trace_async - async def get( - self, - policy_set_definition_name: str, - **kwargs: Any - ) -> "_models.PolicySetDefinition": + async def get(self, policy_set_definition_name: str, **kwargs: Any) -> _models.PolicySetDefinition: """Retrieves a policy set definition. This operation retrieves the policy set definition in the given subscription with the given name. - :param policy_set_definition_name: The name of the policy set definition to get. + :param policy_set_definition_name: The name of the policy set definition to get. Required. :type policy_set_definition_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: PolicySetDefinition, or the result of cls(response) + :return: PolicySetDefinition or the result of cls(response) :rtype: ~azure.mgmt.resource.policy.v2019_09_01.models.PolicySetDefinition - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.PolicySetDefinition"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) - api_version = kwargs.pop('api_version', "2019-09-01") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2019-09-01")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[_models.PolicySetDefinition] - request = build_policy_set_definitions_get_request( policy_set_definition_name=policy_set_definition_name, subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.get.metadata['url'], + template_url=self.get.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) - deserialized = self._deserialize('PolicySetDefinition', pipeline_response) + deserialized = self._deserialize("PolicySetDefinition", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - get.metadata = {'url': "/subscriptions/{subscriptionId}/providers/Microsoft.Authorization/policySetDefinitions/{policySetDefinitionName}"} # type: ignore - + get.metadata = {"url": "/subscriptions/{subscriptionId}/providers/Microsoft.Authorization/policySetDefinitions/{policySetDefinitionName}"} # type: ignore @distributed_trace_async - async def get_built_in( - self, - policy_set_definition_name: str, - **kwargs: Any - ) -> "_models.PolicySetDefinition": + async def get_built_in(self, policy_set_definition_name: str, **kwargs: Any) -> _models.PolicySetDefinition: """Retrieves a built in policy set definition. This operation retrieves the built-in policy set definition with the given name. - :param policy_set_definition_name: The name of the policy set definition to get. + :param policy_set_definition_name: The name of the policy set definition to get. Required. :type policy_set_definition_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: PolicySetDefinition, or the result of cls(response) + :return: PolicySetDefinition or the result of cls(response) :rtype: ~azure.mgmt.resource.policy.v2019_09_01.models.PolicySetDefinition - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.PolicySetDefinition"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) - api_version = kwargs.pop('api_version', "2019-09-01") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2019-09-01")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[_models.PolicySetDefinition] - request = build_policy_set_definitions_get_built_in_request( policy_set_definition_name=policy_set_definition_name, api_version=api_version, - template_url=self.get_built_in.metadata['url'], + template_url=self.get_built_in.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) - deserialized = self._deserialize('PolicySetDefinition', pipeline_response) + deserialized = self._deserialize("PolicySetDefinition", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - get_built_in.metadata = {'url': "/providers/Microsoft.Authorization/policySetDefinitions/{policySetDefinitionName}"} # type: ignore - + get_built_in.metadata = {"url": "/providers/Microsoft.Authorization/policySetDefinitions/{policySetDefinitionName}"} # type: ignore @distributed_trace - def list( - self, - **kwargs: Any - ) -> AsyncIterable["_models.PolicySetDefinitionListResult"]: + def list(self, **kwargs: Any) -> AsyncIterable["_models.PolicySetDefinition"]: """Retrieves the policy set definitions for a subscription. This operation retrieves a list of all the policy set definitions in the given subscription. :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either PolicySetDefinitionListResult or the result of - cls(response) + :return: An iterator like instance of either PolicySetDefinition or the result of cls(response) :rtype: - ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.resource.policy.v2019_09_01.models.PolicySetDefinitionListResult] - :raises: ~azure.core.exceptions.HttpResponseError + ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.resource.policy.v2019_09_01.models.PolicySetDefinition] + :raises ~azure.core.exceptions.HttpResponseError: """ - api_version = kwargs.pop('api_version', "2019-09-01") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2019-09-01")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[_models.PolicySetDefinitionListResult] - cls = kwargs.pop('cls', None) # type: ClsType["_models.PolicySetDefinitionListResult"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) + def prepare_request(next_link=None): if not next_link: - + request = build_policy_set_definitions_list_request( subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.list.metadata['url'], + template_url=self.list.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore else: - - request = build_policy_set_definitions_list_request( - subscription_id=self._config.subscription_id, - template_url=next_link, - ) + # make call to next link with the client's api-version + _parsed_next_link = urlparse(next_link) + _next_request_params = case_insensitive_dict(parse_qs(_parsed_next_link.query)) + _next_request_params["api-version"] = self._config.api_version + request = HttpRequest("GET", urljoin(next_link, _parsed_next_link.path), params=_next_request_params) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore request.method = "GET" return request @@ -1807,10 +2247,8 @@ async def extract_data(pipeline_response): async def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) response = pipeline_response.http_response @@ -1820,52 +2258,56 @@ async def get_next(next_link=None): return pipeline_response + return AsyncItemPaged(get_next, extract_data) - return AsyncItemPaged( - get_next, extract_data - ) - list.metadata = {'url': "/subscriptions/{subscriptionId}/providers/Microsoft.Authorization/policySetDefinitions"} # type: ignore + list.metadata = {"url": "/subscriptions/{subscriptionId}/providers/Microsoft.Authorization/policySetDefinitions"} # type: ignore @distributed_trace - def list_built_in( - self, - **kwargs: Any - ) -> AsyncIterable["_models.PolicySetDefinitionListResult"]: + def list_built_in(self, **kwargs: Any) -> AsyncIterable["_models.PolicySetDefinition"]: """Retrieves built-in policy set definitions. This operation retrieves a list of all the built-in policy set definitions. :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either PolicySetDefinitionListResult or the result of - cls(response) + :return: An iterator like instance of either PolicySetDefinition or the result of cls(response) :rtype: - ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.resource.policy.v2019_09_01.models.PolicySetDefinitionListResult] - :raises: ~azure.core.exceptions.HttpResponseError + ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.resource.policy.v2019_09_01.models.PolicySetDefinition] + :raises ~azure.core.exceptions.HttpResponseError: """ - api_version = kwargs.pop('api_version', "2019-09-01") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2019-09-01")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[_models.PolicySetDefinitionListResult] - cls = kwargs.pop('cls', None) # type: ClsType["_models.PolicySetDefinitionListResult"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) + def prepare_request(next_link=None): if not next_link: - + request = build_policy_set_definitions_list_built_in_request( api_version=api_version, - template_url=self.list_built_in.metadata['url'], + template_url=self.list_built_in.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore else: - - request = build_policy_set_definitions_list_built_in_request( - template_url=next_link, - ) + # make call to next link with the client's api-version + _parsed_next_link = urlparse(next_link) + _next_request_params = case_insensitive_dict(parse_qs(_parsed_next_link.query)) + _next_request_params["api-version"] = self._config.api_version + request = HttpRequest("GET", urljoin(next_link, _parsed_next_link.path), params=_next_request_params) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore request.method = "GET" return request @@ -1879,10 +2321,8 @@ async def extract_data(pipeline_response): async def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) response = pipeline_response.http_response @@ -1892,46 +2332,120 @@ async def get_next(next_link=None): return pipeline_response + return AsyncItemPaged(get_next, extract_data) - return AsyncItemPaged( - get_next, extract_data - ) - list_built_in.metadata = {'url': "/providers/Microsoft.Authorization/policySetDefinitions"} # type: ignore + list_built_in.metadata = {"url": "/providers/Microsoft.Authorization/policySetDefinitions"} # type: ignore - @distributed_trace_async + @overload async def create_or_update_at_management_group( self, policy_set_definition_name: str, management_group_id: str, - parameters: "_models.PolicySetDefinition", + parameters: _models.PolicySetDefinition, + *, + content_type: str = "application/json", **kwargs: Any - ) -> "_models.PolicySetDefinition": + ) -> _models.PolicySetDefinition: """Creates or updates a policy set definition. This operation creates or updates a policy set definition in the given management group with the given name. - :param policy_set_definition_name: The name of the policy set definition to create. + :param policy_set_definition_name: The name of the policy set definition to create. Required. :type policy_set_definition_name: str - :param management_group_id: The ID of the management group. + :param management_group_id: The ID of the management group. Required. :type management_group_id: str - :param parameters: The policy set definition properties. + :param parameters: The policy set definition properties. Required. :type parameters: ~azure.mgmt.resource.policy.v2019_09_01.models.PolicySetDefinition + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: PolicySetDefinition or the result of cls(response) + :rtype: ~azure.mgmt.resource.policy.v2019_09_01.models.PolicySetDefinition + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + async def create_or_update_at_management_group( + self, + policy_set_definition_name: str, + management_group_id: str, + parameters: IO, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.PolicySetDefinition: + """Creates or updates a policy set definition. + + This operation creates or updates a policy set definition in the given management group with + the given name. + + :param policy_set_definition_name: The name of the policy set definition to create. Required. + :type policy_set_definition_name: str + :param management_group_id: The ID of the management group. Required. + :type management_group_id: str + :param parameters: The policy set definition properties. Required. + :type parameters: IO + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: PolicySetDefinition, or the result of cls(response) + :return: PolicySetDefinition or the result of cls(response) :rtype: ~azure.mgmt.resource.policy.v2019_09_01.models.PolicySetDefinition - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace_async + async def create_or_update_at_management_group( + self, + policy_set_definition_name: str, + management_group_id: str, + parameters: Union[_models.PolicySetDefinition, IO], + **kwargs: Any + ) -> _models.PolicySetDefinition: + """Creates or updates a policy set definition. + + This operation creates or updates a policy set definition in the given management group with + the given name. + + :param policy_set_definition_name: The name of the policy set definition to create. Required. + :type policy_set_definition_name: str + :param management_group_id: The ID of the management group. Required. + :type management_group_id: str + :param parameters: The policy set definition properties. Is either a model type or a IO type. + Required. + :type parameters: ~azure.mgmt.resource.policy.v2019_09_01.models.PolicySetDefinition or IO + :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. + Default value is None. + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: PolicySetDefinition or the result of cls(response) + :rtype: ~azure.mgmt.resource.policy.v2019_09_01.models.PolicySetDefinition + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.PolicySetDefinition"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', "2019-09-01") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + api_version = kwargs.pop("api_version", _params.pop("api-version", "2019-09-01")) # type: str + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.PolicySetDefinition] - _json = self._serialize.body(parameters, 'PolicySetDefinition') + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(parameters, (IO, bytes)): + _content = parameters + else: + _json = self._serialize.body(parameters, "PolicySetDefinition") request = build_policy_set_definitions_create_or_update_at_management_group_request( policy_set_definition_name=policy_set_definition_name, @@ -1939,16 +2453,18 @@ async def create_or_update_at_management_group( api_version=api_version, content_type=content_type, json=_json, - template_url=self.create_or_update_at_management_group.metadata['url'], + content=_content, + template_url=self.create_or_update_at_management_group.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200, 201]: @@ -1956,63 +2472,65 @@ async def create_or_update_at_management_group( raise HttpResponseError(response=response, error_format=ARMErrorFormat) if response.status_code == 200: - deserialized = self._deserialize('PolicySetDefinition', pipeline_response) + deserialized = self._deserialize("PolicySetDefinition", pipeline_response) if response.status_code == 201: - deserialized = self._deserialize('PolicySetDefinition', pipeline_response) + deserialized = self._deserialize("PolicySetDefinition", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - create_or_update_at_management_group.metadata = {'url': "/providers/Microsoft.Management/managementgroups/{managementGroupId}/providers/Microsoft.Authorization/policySetDefinitions/{policySetDefinitionName}"} # type: ignore - + create_or_update_at_management_group.metadata = {"url": "/providers/Microsoft.Management/managementgroups/{managementGroupId}/providers/Microsoft.Authorization/policySetDefinitions/{policySetDefinitionName}"} # type: ignore @distributed_trace_async async def delete_at_management_group( # pylint: disable=inconsistent-return-statements - self, - policy_set_definition_name: str, - management_group_id: str, - **kwargs: Any + self, policy_set_definition_name: str, management_group_id: str, **kwargs: Any ) -> None: """Deletes a policy set definition. This operation deletes the policy set definition in the given management group with the given name. - :param policy_set_definition_name: The name of the policy set definition to delete. + :param policy_set_definition_name: The name of the policy set definition to delete. Required. :type policy_set_definition_name: str - :param management_group_id: The ID of the management group. + :param management_group_id: The ID of the management group. Required. :type management_group_id: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: None, or the result of cls(response) + :return: None or the result of cls(response) :rtype: None - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType[None] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + 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', "2019-09-01") # type: str + api_version = kwargs.pop("api_version", _params.pop("api-version", "2019-09-01")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[None] - request = build_policy_set_definitions_delete_at_management_group_request( policy_set_definition_name=policy_set_definition_name, management_group_id=management_group_id, api_version=api_version, - template_url=self.delete_at_management_group.metadata['url'], + template_url=self.delete_at_management_group.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200, 204]: @@ -2022,115 +2540,122 @@ async def delete_at_management_group( # pylint: disable=inconsistent-return-sta if cls: return cls(pipeline_response, None, {}) - delete_at_management_group.metadata = {'url': "/providers/Microsoft.Management/managementgroups/{managementGroupId}/providers/Microsoft.Authorization/policySetDefinitions/{policySetDefinitionName}"} # type: ignore - + delete_at_management_group.metadata = {"url": "/providers/Microsoft.Management/managementgroups/{managementGroupId}/providers/Microsoft.Authorization/policySetDefinitions/{policySetDefinitionName}"} # type: ignore @distributed_trace_async async def get_at_management_group( - self, - policy_set_definition_name: str, - management_group_id: str, - **kwargs: Any - ) -> "_models.PolicySetDefinition": + self, policy_set_definition_name: str, management_group_id: str, **kwargs: Any + ) -> _models.PolicySetDefinition: """Retrieves a policy set definition. This operation retrieves the policy set definition in the given management group with the given name. - :param policy_set_definition_name: The name of the policy set definition to get. + :param policy_set_definition_name: The name of the policy set definition to get. Required. :type policy_set_definition_name: str - :param management_group_id: The ID of the management group. + :param management_group_id: The ID of the management group. Required. :type management_group_id: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: PolicySetDefinition, or the result of cls(response) + :return: PolicySetDefinition or the result of cls(response) :rtype: ~azure.mgmt.resource.policy.v2019_09_01.models.PolicySetDefinition - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.PolicySetDefinition"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) - api_version = kwargs.pop('api_version', "2019-09-01") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2019-09-01")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[_models.PolicySetDefinition] - request = build_policy_set_definitions_get_at_management_group_request( policy_set_definition_name=policy_set_definition_name, management_group_id=management_group_id, api_version=api_version, - template_url=self.get_at_management_group.metadata['url'], + template_url=self.get_at_management_group.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) - deserialized = self._deserialize('PolicySetDefinition', pipeline_response) + deserialized = self._deserialize("PolicySetDefinition", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - get_at_management_group.metadata = {'url': "/providers/Microsoft.Management/managementgroups/{managementGroupId}/providers/Microsoft.Authorization/policySetDefinitions/{policySetDefinitionName}"} # type: ignore - + get_at_management_group.metadata = {"url": "/providers/Microsoft.Management/managementgroups/{managementGroupId}/providers/Microsoft.Authorization/policySetDefinitions/{policySetDefinitionName}"} # type: ignore @distributed_trace def list_by_management_group( - self, - management_group_id: str, - **kwargs: Any - ) -> AsyncIterable["_models.PolicySetDefinitionListResult"]: + self, management_group_id: str, **kwargs: Any + ) -> AsyncIterable["_models.PolicySetDefinition"]: """Retrieves all policy set definitions in management group. This operation retrieves a list of all the a policy set definition in the given management group. - :param management_group_id: The ID of the management group. + :param management_group_id: The ID of the management group. Required. :type management_group_id: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either PolicySetDefinitionListResult or the result of - cls(response) + :return: An iterator like instance of either PolicySetDefinition or the result of cls(response) :rtype: - ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.resource.policy.v2019_09_01.models.PolicySetDefinitionListResult] - :raises: ~azure.core.exceptions.HttpResponseError + ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.resource.policy.v2019_09_01.models.PolicySetDefinition] + :raises ~azure.core.exceptions.HttpResponseError: """ - api_version = kwargs.pop('api_version', "2019-09-01") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2019-09-01")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[_models.PolicySetDefinitionListResult] - cls = kwargs.pop('cls', None) # type: ClsType["_models.PolicySetDefinitionListResult"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) + def prepare_request(next_link=None): if not next_link: - + request = build_policy_set_definitions_list_by_management_group_request( management_group_id=management_group_id, api_version=api_version, - template_url=self.list_by_management_group.metadata['url'], + template_url=self.list_by_management_group.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore else: - - request = build_policy_set_definitions_list_by_management_group_request( - management_group_id=management_group_id, - template_url=next_link, - ) + # make call to next link with the client's api-version + _parsed_next_link = urlparse(next_link) + _next_request_params = case_insensitive_dict(parse_qs(_parsed_next_link.query)) + _next_request_params["api-version"] = self._config.api_version + request = HttpRequest("GET", urljoin(next_link, _parsed_next_link.path), params=_next_request_params) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore request.method = "GET" return request @@ -2144,10 +2669,8 @@ async def extract_data(pipeline_response): async def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) response = pipeline_response.http_response @@ -2157,8 +2680,6 @@ async def get_next(next_link=None): return pipeline_response + return AsyncItemPaged(get_next, extract_data) - return AsyncItemPaged( - get_next, extract_data - ) - list_by_management_group.metadata = {'url': "/providers/Microsoft.Management/managementgroups/{managementGroupId}/providers/Microsoft.Authorization/policySetDefinitions"} # type: ignore + list_by_management_group.metadata = {"url": "/providers/Microsoft.Management/managementgroups/{managementGroupId}/providers/Microsoft.Authorization/policySetDefinitions"} # type: ignore diff --git a/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/policy/v2019_09_01/aio/operations/_patch.py b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/policy/v2019_09_01/aio/operations/_patch.py new file mode 100644 index 0000000000000..f7dd32510333d --- /dev/null +++ b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/policy/v2019_09_01/aio/operations/_patch.py @@ -0,0 +1,20 @@ +# ------------------------------------ +# Copyright (c) Microsoft Corporation. +# Licensed under the MIT License. +# ------------------------------------ +"""Customize generated code here. + +Follow our quickstart for examples: https://aka.ms/azsdk/python/dpcodegen/python/customize +""" +from typing import List + +__all__: List[str] = [] # Add all objects you want publicly available to users at this package level + + +def patch_sdk(): + """Do not remove from this file. + + `patch_sdk` is a last resort escape hatch that allows you to do customizations + you can't accomplish using the techniques described in + https://aka.ms/azsdk/python/dpcodegen/python/customize + """ diff --git a/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/policy/v2019_09_01/models/__init__.py b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/policy/v2019_09_01/models/__init__.py index 53a01f3ffc851..bdf37e25fe91d 100644 --- a/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/policy/v2019_09_01/models/__init__.py +++ b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/policy/v2019_09_01/models/__init__.py @@ -22,32 +22,34 @@ from ._models_py3 import PolicySetDefinitionListResult from ._models_py3 import PolicySku - -from ._policy_client_enums import ( - EnforcementMode, - ParameterType, - PolicyType, - ResourceIdentityType, -) +from ._policy_client_enums import EnforcementMode +from ._policy_client_enums import ParameterType +from ._policy_client_enums import PolicyType +from ._policy_client_enums import ResourceIdentityType +from ._patch import __all__ as _patch_all +from ._patch import * # type: ignore # pylint: disable=unused-wildcard-import +from ._patch import patch_sdk as _patch_sdk __all__ = [ - 'ErrorAdditionalInfo', - 'ErrorResponse', - 'Identity', - 'ParameterDefinitionsValue', - 'ParameterDefinitionsValueMetadata', - 'ParameterValuesValue', - 'PolicyAssignment', - 'PolicyAssignmentListResult', - 'PolicyDefinition', - 'PolicyDefinitionGroup', - 'PolicyDefinitionListResult', - 'PolicyDefinitionReference', - 'PolicySetDefinition', - 'PolicySetDefinitionListResult', - 'PolicySku', - 'EnforcementMode', - 'ParameterType', - 'PolicyType', - 'ResourceIdentityType', + "ErrorAdditionalInfo", + "ErrorResponse", + "Identity", + "ParameterDefinitionsValue", + "ParameterDefinitionsValueMetadata", + "ParameterValuesValue", + "PolicyAssignment", + "PolicyAssignmentListResult", + "PolicyDefinition", + "PolicyDefinitionGroup", + "PolicyDefinitionListResult", + "PolicyDefinitionReference", + "PolicySetDefinition", + "PolicySetDefinitionListResult", + "PolicySku", + "EnforcementMode", + "ParameterType", + "PolicyType", + "ResourceIdentityType", ] +__all__.extend([p for p in _patch_all if p not in __all__]) +_patch_sdk() diff --git a/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/policy/v2019_09_01/models/_models_py3.py b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/policy/v2019_09_01/models/_models_py3.py index c65435bf8a869..c7e7173b75b99 100644 --- a/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/policy/v2019_09_01/models/_models_py3.py +++ b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/policy/v2019_09_01/models/_models_py3.py @@ -1,4 +1,5 @@ # coding=utf-8 +# pylint: disable=too-many-lines # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. # Licensed under the MIT License. See License.txt in the project root for license information. @@ -6,14 +7,22 @@ # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -from typing import Any, Dict, List, Optional, Union +import sys +from typing import Any, Dict, List, Optional, TYPE_CHECKING, Union -import msrest.serialization +from ... import _serialization -from ._policy_client_enums import * +if TYPE_CHECKING: + # pylint: disable=unused-import,ungrouped-imports + from .. import models as _models +if sys.version_info >= (3, 9): + from collections.abc import MutableMapping +else: + from typing import MutableMapping # type: ignore # pylint: disable=ungrouped-imports +JSON = MutableMapping[str, Any] # pylint: disable=unsubscriptable-object -class ErrorAdditionalInfo(msrest.serialization.Model): +class ErrorAdditionalInfo(_serialization.Model): """The resource management error additional info. Variables are only populated by the server, and will be ignored when sending a request. @@ -21,31 +30,27 @@ class ErrorAdditionalInfo(msrest.serialization.Model): :ivar type: The additional info type. :vartype type: str :ivar info: The additional info. - :vartype info: any + :vartype info: JSON """ _validation = { - 'type': {'readonly': True}, - 'info': {'readonly': True}, + "type": {"readonly": True}, + "info": {"readonly": True}, } _attribute_map = { - 'type': {'key': 'type', 'type': 'str'}, - 'info': {'key': 'info', 'type': 'object'}, + "type": {"key": "type", "type": "str"}, + "info": {"key": "info", "type": "object"}, } - def __init__( - self, - **kwargs - ): - """ - """ - super(ErrorAdditionalInfo, self).__init__(**kwargs) + def __init__(self, **kwargs): + """ """ + super().__init__(**kwargs) self.type = None self.info = None -class ErrorResponse(msrest.serialization.Model): +class ErrorResponse(_serialization.Model): """Common error response for all Azure Resource Manager APIs to return error details for failed operations. (This also follows the OData error response format.). Variables are only populated by the server, and will be ignored when sending a request. @@ -64,28 +69,24 @@ class ErrorResponse(msrest.serialization.Model): """ _validation = { - 'code': {'readonly': True}, - 'message': {'readonly': True}, - 'target': {'readonly': True}, - 'details': {'readonly': True}, - 'additional_info': {'readonly': True}, + "code": {"readonly": True}, + "message": {"readonly": True}, + "target": {"readonly": True}, + "details": {"readonly": True}, + "additional_info": {"readonly": True}, } _attribute_map = { - 'code': {'key': 'code', 'type': 'str'}, - 'message': {'key': 'message', 'type': 'str'}, - 'target': {'key': 'target', 'type': 'str'}, - 'details': {'key': 'details', 'type': '[ErrorResponse]'}, - 'additional_info': {'key': 'additionalInfo', 'type': '[ErrorAdditionalInfo]'}, + "code": {"key": "code", "type": "str"}, + "message": {"key": "message", "type": "str"}, + "target": {"key": "target", "type": "str"}, + "details": {"key": "details", "type": "[ErrorResponse]"}, + "additional_info": {"key": "additionalInfo", "type": "[ErrorAdditionalInfo]"}, } - def __init__( - self, - **kwargs - ): - """ - """ - super(ErrorResponse, self).__init__(**kwargs) + def __init__(self, **kwargs): + """ """ + super().__init__(**kwargs) self.code = None self.message = None self.target = None @@ -93,7 +94,7 @@ def __init__( self.additional_info = None -class Identity(msrest.serialization.Model): +class Identity(_serialization.Model): """Identity for the resource. Variables are only populated by the server, and will be ignored when sending a request. @@ -103,94 +104,89 @@ class Identity(msrest.serialization.Model): :ivar tenant_id: The tenant ID of the resource identity. :vartype tenant_id: str :ivar type: The identity type. This is the only required field when adding a system assigned - identity to a resource. Possible values include: "SystemAssigned", "None". + identity to a resource. Known values are: "SystemAssigned" and "None". :vartype type: str or ~azure.mgmt.resource.policy.v2019_09_01.models.ResourceIdentityType """ _validation = { - 'principal_id': {'readonly': True}, - 'tenant_id': {'readonly': True}, + "principal_id": {"readonly": True}, + "tenant_id": {"readonly": True}, } _attribute_map = { - 'principal_id': {'key': 'principalId', 'type': 'str'}, - 'tenant_id': {'key': 'tenantId', 'type': 'str'}, - 'type': {'key': 'type', 'type': 'str'}, + "principal_id": {"key": "principalId", "type": "str"}, + "tenant_id": {"key": "tenantId", "type": "str"}, + "type": {"key": "type", "type": "str"}, } - def __init__( - self, - *, - type: Optional[Union[str, "ResourceIdentityType"]] = None, - **kwargs - ): + def __init__(self, *, type: Optional[Union[str, "_models.ResourceIdentityType"]] = None, **kwargs): """ :keyword type: The identity type. This is the only required field when adding a system assigned - identity to a resource. Possible values include: "SystemAssigned", "None". + identity to a resource. Known values are: "SystemAssigned" and "None". :paramtype type: str or ~azure.mgmt.resource.policy.v2019_09_01.models.ResourceIdentityType """ - super(Identity, self).__init__(**kwargs) + super().__init__(**kwargs) self.principal_id = None self.tenant_id = None self.type = type -class ParameterDefinitionsValue(msrest.serialization.Model): +class ParameterDefinitionsValue(_serialization.Model): """The definition of a parameter that can be provided to the policy. - :ivar type: The data type of the parameter. Possible values include: "String", "Array", - "Object", "Boolean", "Integer", "Float", "DateTime". + :ivar type: The data type of the parameter. Known values are: "String", "Array", "Object", + "Boolean", "Integer", "Float", and "DateTime". :vartype type: str or ~azure.mgmt.resource.policy.v2019_09_01.models.ParameterType :ivar allowed_values: The allowed values for the parameter. - :vartype allowed_values: list[any] + :vartype allowed_values: list[JSON] :ivar default_value: The default value for the parameter if no value is provided. - :vartype default_value: any + :vartype default_value: JSON :ivar metadata: General metadata for the parameter. :vartype metadata: ~azure.mgmt.resource.policy.v2019_09_01.models.ParameterDefinitionsValueMetadata """ _attribute_map = { - 'type': {'key': 'type', 'type': 'str'}, - 'allowed_values': {'key': 'allowedValues', 'type': '[object]'}, - 'default_value': {'key': 'defaultValue', 'type': 'object'}, - 'metadata': {'key': 'metadata', 'type': 'ParameterDefinitionsValueMetadata'}, + "type": {"key": "type", "type": "str"}, + "allowed_values": {"key": "allowedValues", "type": "[object]"}, + "default_value": {"key": "defaultValue", "type": "object"}, + "metadata": {"key": "metadata", "type": "ParameterDefinitionsValueMetadata"}, } def __init__( self, *, - type: Optional[Union[str, "ParameterType"]] = None, - allowed_values: Optional[List[Any]] = None, - default_value: Optional[Any] = None, - metadata: Optional["ParameterDefinitionsValueMetadata"] = None, + type: Optional[Union[str, "_models.ParameterType"]] = None, + allowed_values: Optional[List[JSON]] = None, + default_value: Optional[JSON] = None, + metadata: Optional["_models.ParameterDefinitionsValueMetadata"] = None, **kwargs ): """ - :keyword type: The data type of the parameter. Possible values include: "String", "Array", - "Object", "Boolean", "Integer", "Float", "DateTime". + :keyword type: The data type of the parameter. Known values are: "String", "Array", "Object", + "Boolean", "Integer", "Float", and "DateTime". :paramtype type: str or ~azure.mgmt.resource.policy.v2019_09_01.models.ParameterType :keyword allowed_values: The allowed values for the parameter. - :paramtype allowed_values: list[any] + :paramtype allowed_values: list[JSON] :keyword default_value: The default value for the parameter if no value is provided. - :paramtype default_value: any + :paramtype default_value: JSON :keyword metadata: General metadata for the parameter. :paramtype metadata: ~azure.mgmt.resource.policy.v2019_09_01.models.ParameterDefinitionsValueMetadata """ - super(ParameterDefinitionsValue, self).__init__(**kwargs) + super().__init__(**kwargs) self.type = type self.allowed_values = allowed_values self.default_value = default_value self.metadata = metadata -class ParameterDefinitionsValueMetadata(msrest.serialization.Model): +class ParameterDefinitionsValueMetadata(_serialization.Model): """General metadata for the parameter. :ivar additional_properties: Unmatched properties from the message are deserialized to this collection. - :vartype additional_properties: dict[str, any] + :vartype additional_properties: dict[str, JSON] :ivar display_name: The display name for the parameter. :vartype display_name: str :ivar description: The description of the parameter. @@ -198,15 +194,15 @@ class ParameterDefinitionsValueMetadata(msrest.serialization.Model): """ _attribute_map = { - 'additional_properties': {'key': '', 'type': '{object}'}, - 'display_name': {'key': 'displayName', 'type': 'str'}, - 'description': {'key': 'description', 'type': 'str'}, + "additional_properties": {"key": "", "type": "{object}"}, + "display_name": {"key": "displayName", "type": "str"}, + "description": {"key": "description", "type": "str"}, } def __init__( self, *, - additional_properties: Optional[Dict[str, Any]] = None, + additional_properties: Optional[Dict[str, JSON]] = None, display_name: Optional[str] = None, description: Optional[str] = None, **kwargs @@ -214,44 +210,39 @@ def __init__( """ :keyword additional_properties: Unmatched properties from the message are deserialized to this collection. - :paramtype additional_properties: dict[str, any] + :paramtype additional_properties: dict[str, JSON] :keyword display_name: The display name for the parameter. :paramtype display_name: str :keyword description: The description of the parameter. :paramtype description: str """ - super(ParameterDefinitionsValueMetadata, self).__init__(**kwargs) + super().__init__(**kwargs) self.additional_properties = additional_properties self.display_name = display_name self.description = description -class ParameterValuesValue(msrest.serialization.Model): +class ParameterValuesValue(_serialization.Model): """The value of a parameter. :ivar value: The value of the parameter. - :vartype value: any + :vartype value: JSON """ _attribute_map = { - 'value': {'key': 'value', 'type': 'object'}, + "value": {"key": "value", "type": "object"}, } - def __init__( - self, - *, - value: Optional[Any] = None, - **kwargs - ): + def __init__(self, *, value: Optional[JSON] = None, **kwargs): """ :keyword value: The value of the parameter. - :paramtype value: any + :paramtype value: JSON """ - super(ParameterValuesValue, self).__init__(**kwargs) + super().__init__(**kwargs) self.value = value -class PolicyAssignment(msrest.serialization.Model): +class PolicyAssignment(_serialization.Model): # pylint: disable=too-many-instance-attributes """The policy assignment. Variables are only populated by the server, and will be ignored when sending a request. @@ -286,50 +277,50 @@ class PolicyAssignment(msrest.serialization.Model): :vartype description: str :ivar metadata: The policy assignment metadata. Metadata is an open ended object and is typically a collection of key value pairs. - :vartype metadata: any + :vartype metadata: JSON :ivar enforcement_mode: The policy assignment enforcement mode. Possible values are Default and - DoNotEnforce. Possible values include: "Default", "DoNotEnforce". + DoNotEnforce. Known values are: "Default" and "DoNotEnforce". :vartype enforcement_mode: str or ~azure.mgmt.resource.policy.v2019_09_01.models.EnforcementMode """ _validation = { - 'id': {'readonly': True}, - 'type': {'readonly': True}, - 'name': {'readonly': True}, + "id": {"readonly": True}, + "type": {"readonly": True}, + "name": {"readonly": True}, } _attribute_map = { - 'id': {'key': 'id', 'type': 'str'}, - 'type': {'key': 'type', 'type': 'str'}, - 'name': {'key': 'name', 'type': 'str'}, - 'sku': {'key': 'sku', 'type': 'PolicySku'}, - 'location': {'key': 'location', 'type': 'str'}, - 'identity': {'key': 'identity', 'type': 'Identity'}, - 'display_name': {'key': 'properties.displayName', 'type': 'str'}, - 'policy_definition_id': {'key': 'properties.policyDefinitionId', 'type': 'str'}, - 'scope': {'key': 'properties.scope', 'type': 'str'}, - 'not_scopes': {'key': 'properties.notScopes', 'type': '[str]'}, - 'parameters': {'key': 'properties.parameters', 'type': '{ParameterValuesValue}'}, - 'description': {'key': 'properties.description', 'type': 'str'}, - 'metadata': {'key': 'properties.metadata', 'type': 'object'}, - 'enforcement_mode': {'key': 'properties.enforcementMode', 'type': 'str'}, + "id": {"key": "id", "type": "str"}, + "type": {"key": "type", "type": "str"}, + "name": {"key": "name", "type": "str"}, + "sku": {"key": "sku", "type": "PolicySku"}, + "location": {"key": "location", "type": "str"}, + "identity": {"key": "identity", "type": "Identity"}, + "display_name": {"key": "properties.displayName", "type": "str"}, + "policy_definition_id": {"key": "properties.policyDefinitionId", "type": "str"}, + "scope": {"key": "properties.scope", "type": "str"}, + "not_scopes": {"key": "properties.notScopes", "type": "[str]"}, + "parameters": {"key": "properties.parameters", "type": "{ParameterValuesValue}"}, + "description": {"key": "properties.description", "type": "str"}, + "metadata": {"key": "properties.metadata", "type": "object"}, + "enforcement_mode": {"key": "properties.enforcementMode", "type": "str"}, } def __init__( self, *, - sku: Optional["PolicySku"] = None, + sku: Optional["_models.PolicySku"] = None, location: Optional[str] = None, - identity: Optional["Identity"] = None, + identity: Optional["_models.Identity"] = None, display_name: Optional[str] = None, policy_definition_id: Optional[str] = None, scope: Optional[str] = None, not_scopes: Optional[List[str]] = None, - parameters: Optional[Dict[str, "ParameterValuesValue"]] = None, + parameters: Optional[Dict[str, "_models.ParameterValuesValue"]] = None, description: Optional[str] = None, - metadata: Optional[Any] = None, - enforcement_mode: Optional[Union[str, "EnforcementMode"]] = None, + metadata: Optional[JSON] = None, + enforcement_mode: Optional[Union[str, "_models.EnforcementMode"]] = None, **kwargs ): """ @@ -357,13 +348,13 @@ def __init__( :paramtype description: str :keyword metadata: The policy assignment metadata. Metadata is an open ended object and is typically a collection of key value pairs. - :paramtype metadata: any + :paramtype metadata: JSON :keyword enforcement_mode: The policy assignment enforcement mode. Possible values are Default - and DoNotEnforce. Possible values include: "Default", "DoNotEnforce". + and DoNotEnforce. Known values are: "Default" and "DoNotEnforce". :paramtype enforcement_mode: str or ~azure.mgmt.resource.policy.v2019_09_01.models.EnforcementMode """ - super(PolicyAssignment, self).__init__(**kwargs) + super().__init__(**kwargs) self.id = None self.type = None self.name = None @@ -380,7 +371,7 @@ def __init__( self.enforcement_mode = enforcement_mode -class PolicyAssignmentListResult(msrest.serialization.Model): +class PolicyAssignmentListResult(_serialization.Model): """List of policy assignments. :ivar value: An array of policy assignments. @@ -390,16 +381,12 @@ class PolicyAssignmentListResult(msrest.serialization.Model): """ _attribute_map = { - 'value': {'key': 'value', 'type': '[PolicyAssignment]'}, - 'next_link': {'key': 'nextLink', 'type': 'str'}, + "value": {"key": "value", "type": "[PolicyAssignment]"}, + "next_link": {"key": "nextLink", "type": "str"}, } def __init__( - self, - *, - value: Optional[List["PolicyAssignment"]] = None, - next_link: Optional[str] = None, - **kwargs + self, *, value: Optional[List["_models.PolicyAssignment"]] = None, next_link: Optional[str] = None, **kwargs ): """ :keyword value: An array of policy assignments. @@ -407,12 +394,12 @@ def __init__( :keyword next_link: The URL to use for getting the next set of results. :paramtype next_link: str """ - super(PolicyAssignmentListResult, self).__init__(**kwargs) + super().__init__(**kwargs) self.value = value self.next_link = next_link -class PolicyDefinition(msrest.serialization.Model): +class PolicyDefinition(_serialization.Model): """The policy definition. Variables are only populated by the server, and will be ignored when sending a request. @@ -424,7 +411,7 @@ class PolicyDefinition(msrest.serialization.Model): :ivar type: The type of the resource (Microsoft.Authorization/policyDefinitions). :vartype type: str :ivar policy_type: The type of policy definition. Possible values are NotSpecified, BuiltIn, - Custom, and Static. Possible values include: "NotSpecified", "BuiltIn", "Custom", "Static". + Custom, and Static. Known values are: "NotSpecified", "BuiltIn", "Custom", and "Static". :vartype policy_type: str or ~azure.mgmt.resource.policy.v2019_09_01.models.PolicyType :ivar mode: The policy definition mode. Some examples are All, Indexed, Microsoft.KeyVault.Data. @@ -434,10 +421,10 @@ class PolicyDefinition(msrest.serialization.Model): :ivar description: The policy definition description. :vartype description: str :ivar policy_rule: The policy rule. - :vartype policy_rule: any + :vartype policy_rule: JSON :ivar metadata: The policy definition metadata. Metadata is an open ended object and is typically a collection of key value pairs. - :vartype metadata: any + :vartype metadata: JSON :ivar parameters: The parameter definitions for parameters used in the policy rule. The keys are the parameter names. :vartype parameters: dict[str, @@ -445,39 +432,39 @@ class PolicyDefinition(msrest.serialization.Model): """ _validation = { - 'id': {'readonly': True}, - 'name': {'readonly': True}, - 'type': {'readonly': True}, + "id": {"readonly": True}, + "name": {"readonly": True}, + "type": {"readonly": True}, } _attribute_map = { - 'id': {'key': 'id', 'type': 'str'}, - 'name': {'key': 'name', 'type': 'str'}, - 'type': {'key': 'type', 'type': 'str'}, - 'policy_type': {'key': 'properties.policyType', 'type': 'str'}, - 'mode': {'key': 'properties.mode', 'type': 'str'}, - 'display_name': {'key': 'properties.displayName', 'type': 'str'}, - 'description': {'key': 'properties.description', 'type': 'str'}, - 'policy_rule': {'key': 'properties.policyRule', 'type': 'object'}, - 'metadata': {'key': 'properties.metadata', 'type': 'object'}, - 'parameters': {'key': 'properties.parameters', 'type': '{ParameterDefinitionsValue}'}, + "id": {"key": "id", "type": "str"}, + "name": {"key": "name", "type": "str"}, + "type": {"key": "type", "type": "str"}, + "policy_type": {"key": "properties.policyType", "type": "str"}, + "mode": {"key": "properties.mode", "type": "str"}, + "display_name": {"key": "properties.displayName", "type": "str"}, + "description": {"key": "properties.description", "type": "str"}, + "policy_rule": {"key": "properties.policyRule", "type": "object"}, + "metadata": {"key": "properties.metadata", "type": "object"}, + "parameters": {"key": "properties.parameters", "type": "{ParameterDefinitionsValue}"}, } def __init__( self, *, - policy_type: Optional[Union[str, "PolicyType"]] = None, + policy_type: Optional[Union[str, "_models.PolicyType"]] = None, mode: Optional[str] = None, display_name: Optional[str] = None, description: Optional[str] = None, - policy_rule: Optional[Any] = None, - metadata: Optional[Any] = None, - parameters: Optional[Dict[str, "ParameterDefinitionsValue"]] = None, + policy_rule: Optional[JSON] = None, + metadata: Optional[JSON] = None, + parameters: Optional[Dict[str, "_models.ParameterDefinitionsValue"]] = None, **kwargs ): """ :keyword policy_type: The type of policy definition. Possible values are NotSpecified, BuiltIn, - Custom, and Static. Possible values include: "NotSpecified", "BuiltIn", "Custom", "Static". + Custom, and Static. Known values are: "NotSpecified", "BuiltIn", "Custom", and "Static". :paramtype policy_type: str or ~azure.mgmt.resource.policy.v2019_09_01.models.PolicyType :keyword mode: The policy definition mode. Some examples are All, Indexed, Microsoft.KeyVault.Data. @@ -487,16 +474,16 @@ def __init__( :keyword description: The policy definition description. :paramtype description: str :keyword policy_rule: The policy rule. - :paramtype policy_rule: any + :paramtype policy_rule: JSON :keyword metadata: The policy definition metadata. Metadata is an open ended object and is typically a collection of key value pairs. - :paramtype metadata: any + :paramtype metadata: JSON :keyword parameters: The parameter definitions for parameters used in the policy rule. The keys are the parameter names. :paramtype parameters: dict[str, ~azure.mgmt.resource.policy.v2019_09_01.models.ParameterDefinitionsValue] """ - super(PolicyDefinition, self).__init__(**kwargs) + super().__init__(**kwargs) self.id = None self.name = None self.type = None @@ -509,12 +496,12 @@ def __init__( self.parameters = parameters -class PolicyDefinitionGroup(msrest.serialization.Model): +class PolicyDefinitionGroup(_serialization.Model): """The policy definition group. All required parameters must be populated in order to send to Azure. - :ivar name: Required. The name of the group. + :ivar name: The name of the group. Required. :vartype name: str :ivar display_name: The group's display name. :vartype display_name: str @@ -528,15 +515,15 @@ class PolicyDefinitionGroup(msrest.serialization.Model): """ _validation = { - 'name': {'required': True}, + "name": {"required": True}, } _attribute_map = { - 'name': {'key': 'name', 'type': 'str'}, - 'display_name': {'key': 'displayName', 'type': 'str'}, - 'category': {'key': 'category', 'type': 'str'}, - 'description': {'key': 'description', 'type': 'str'}, - 'additional_metadata_id': {'key': 'additionalMetadataId', 'type': 'str'}, + "name": {"key": "name", "type": "str"}, + "display_name": {"key": "displayName", "type": "str"}, + "category": {"key": "category", "type": "str"}, + "description": {"key": "description", "type": "str"}, + "additional_metadata_id": {"key": "additionalMetadataId", "type": "str"}, } def __init__( @@ -550,7 +537,7 @@ def __init__( **kwargs ): """ - :keyword name: Required. The name of the group. + :keyword name: The name of the group. Required. :paramtype name: str :keyword display_name: The group's display name. :paramtype display_name: str @@ -562,7 +549,7 @@ def __init__( about the group. :paramtype additional_metadata_id: str """ - super(PolicyDefinitionGroup, self).__init__(**kwargs) + super().__init__(**kwargs) self.name = name self.display_name = display_name self.category = category @@ -570,7 +557,7 @@ def __init__( self.additional_metadata_id = additional_metadata_id -class PolicyDefinitionListResult(msrest.serialization.Model): +class PolicyDefinitionListResult(_serialization.Model): """List of policy definitions. :ivar value: An array of policy definitions. @@ -580,16 +567,12 @@ class PolicyDefinitionListResult(msrest.serialization.Model): """ _attribute_map = { - 'value': {'key': 'value', 'type': '[PolicyDefinition]'}, - 'next_link': {'key': 'nextLink', 'type': 'str'}, + "value": {"key": "value", "type": "[PolicyDefinition]"}, + "next_link": {"key": "nextLink", "type": "str"}, } def __init__( - self, - *, - value: Optional[List["PolicyDefinition"]] = None, - next_link: Optional[str] = None, - **kwargs + self, *, value: Optional[List["_models.PolicyDefinition"]] = None, next_link: Optional[str] = None, **kwargs ): """ :keyword value: An array of policy definitions. @@ -597,17 +580,17 @@ def __init__( :keyword next_link: The URL to use for getting the next set of results. :paramtype next_link: str """ - super(PolicyDefinitionListResult, self).__init__(**kwargs) + super().__init__(**kwargs) self.value = value self.next_link = next_link -class PolicyDefinitionReference(msrest.serialization.Model): +class PolicyDefinitionReference(_serialization.Model): """The policy definition reference. All required parameters must be populated in order to send to Azure. - :ivar policy_definition_id: Required. The ID of the policy definition or policy set definition. + :ivar policy_definition_id: The ID of the policy definition or policy set definition. Required. :vartype policy_definition_id: str :ivar parameters: The parameter values for the referenced policy rule. The keys are the parameter names. @@ -621,28 +604,28 @@ class PolicyDefinitionReference(msrest.serialization.Model): """ _validation = { - 'policy_definition_id': {'required': True}, + "policy_definition_id": {"required": True}, } _attribute_map = { - 'policy_definition_id': {'key': 'policyDefinitionId', 'type': 'str'}, - 'parameters': {'key': 'parameters', 'type': '{ParameterValuesValue}'}, - 'policy_definition_reference_id': {'key': 'policyDefinitionReferenceId', 'type': 'str'}, - 'group_names': {'key': 'groupNames', 'type': '[str]'}, + "policy_definition_id": {"key": "policyDefinitionId", "type": "str"}, + "parameters": {"key": "parameters", "type": "{ParameterValuesValue}"}, + "policy_definition_reference_id": {"key": "policyDefinitionReferenceId", "type": "str"}, + "group_names": {"key": "groupNames", "type": "[str]"}, } def __init__( self, *, policy_definition_id: str, - parameters: Optional[Dict[str, "ParameterValuesValue"]] = None, + parameters: Optional[Dict[str, "_models.ParameterValuesValue"]] = None, policy_definition_reference_id: Optional[str] = None, group_names: Optional[List[str]] = None, **kwargs ): """ - :keyword policy_definition_id: Required. The ID of the policy definition or policy set - definition. + :keyword policy_definition_id: The ID of the policy definition or policy set definition. + Required. :paramtype policy_definition_id: str :keyword parameters: The parameter values for the referenced policy rule. The keys are the parameter names. @@ -654,14 +637,14 @@ def __init__( :keyword group_names: The name of the groups that this policy definition reference belongs to. :paramtype group_names: list[str] """ - super(PolicyDefinitionReference, self).__init__(**kwargs) + super().__init__(**kwargs) self.policy_definition_id = policy_definition_id self.parameters = parameters self.policy_definition_reference_id = policy_definition_reference_id self.group_names = group_names -class PolicySetDefinition(msrest.serialization.Model): +class PolicySetDefinition(_serialization.Model): """The policy set definition. Variables are only populated by the server, and will be ignored when sending a request. @@ -673,7 +656,7 @@ class PolicySetDefinition(msrest.serialization.Model): :ivar type: The type of the resource (Microsoft.Authorization/policySetDefinitions). :vartype type: str :ivar policy_type: The type of policy definition. Possible values are NotSpecified, BuiltIn, - Custom, and Static. Possible values include: "NotSpecified", "BuiltIn", "Custom", "Static". + Custom, and Static. Known values are: "NotSpecified", "BuiltIn", "Custom", and "Static". :vartype policy_type: str or ~azure.mgmt.resource.policy.v2019_09_01.models.PolicyType :ivar display_name: The display name of the policy set definition. :vartype display_name: str @@ -681,7 +664,7 @@ class PolicySetDefinition(msrest.serialization.Model): :vartype description: str :ivar metadata: The policy set definition metadata. Metadata is an open ended object and is typically a collection of key value pairs. - :vartype metadata: any + :vartype metadata: JSON :ivar parameters: The policy set definition parameters that can be used in policy definition references. :vartype parameters: dict[str, @@ -696,39 +679,39 @@ class PolicySetDefinition(msrest.serialization.Model): """ _validation = { - 'id': {'readonly': True}, - 'name': {'readonly': True}, - 'type': {'readonly': True}, + "id": {"readonly": True}, + "name": {"readonly": True}, + "type": {"readonly": True}, } _attribute_map = { - 'id': {'key': 'id', 'type': 'str'}, - 'name': {'key': 'name', 'type': 'str'}, - 'type': {'key': 'type', 'type': 'str'}, - 'policy_type': {'key': 'properties.policyType', 'type': 'str'}, - 'display_name': {'key': 'properties.displayName', 'type': 'str'}, - 'description': {'key': 'properties.description', 'type': 'str'}, - 'metadata': {'key': 'properties.metadata', 'type': 'object'}, - 'parameters': {'key': 'properties.parameters', 'type': '{ParameterDefinitionsValue}'}, - 'policy_definitions': {'key': 'properties.policyDefinitions', 'type': '[PolicyDefinitionReference]'}, - 'policy_definition_groups': {'key': 'properties.policyDefinitionGroups', 'type': '[PolicyDefinitionGroup]'}, + "id": {"key": "id", "type": "str"}, + "name": {"key": "name", "type": "str"}, + "type": {"key": "type", "type": "str"}, + "policy_type": {"key": "properties.policyType", "type": "str"}, + "display_name": {"key": "properties.displayName", "type": "str"}, + "description": {"key": "properties.description", "type": "str"}, + "metadata": {"key": "properties.metadata", "type": "object"}, + "parameters": {"key": "properties.parameters", "type": "{ParameterDefinitionsValue}"}, + "policy_definitions": {"key": "properties.policyDefinitions", "type": "[PolicyDefinitionReference]"}, + "policy_definition_groups": {"key": "properties.policyDefinitionGroups", "type": "[PolicyDefinitionGroup]"}, } def __init__( self, *, - policy_type: Optional[Union[str, "PolicyType"]] = None, + policy_type: Optional[Union[str, "_models.PolicyType"]] = None, display_name: Optional[str] = None, description: Optional[str] = None, - metadata: Optional[Any] = None, - parameters: Optional[Dict[str, "ParameterDefinitionsValue"]] = None, - policy_definitions: Optional[List["PolicyDefinitionReference"]] = None, - policy_definition_groups: Optional[List["PolicyDefinitionGroup"]] = None, + metadata: Optional[JSON] = None, + parameters: Optional[Dict[str, "_models.ParameterDefinitionsValue"]] = None, + policy_definitions: Optional[List["_models.PolicyDefinitionReference"]] = None, + policy_definition_groups: Optional[List["_models.PolicyDefinitionGroup"]] = None, **kwargs ): """ :keyword policy_type: The type of policy definition. Possible values are NotSpecified, BuiltIn, - Custom, and Static. Possible values include: "NotSpecified", "BuiltIn", "Custom", "Static". + Custom, and Static. Known values are: "NotSpecified", "BuiltIn", "Custom", and "Static". :paramtype policy_type: str or ~azure.mgmt.resource.policy.v2019_09_01.models.PolicyType :keyword display_name: The display name of the policy set definition. :paramtype display_name: str @@ -736,7 +719,7 @@ def __init__( :paramtype description: str :keyword metadata: The policy set definition metadata. Metadata is an open ended object and is typically a collection of key value pairs. - :paramtype metadata: any + :paramtype metadata: JSON :keyword parameters: The policy set definition parameters that can be used in policy definition references. :paramtype parameters: dict[str, @@ -749,7 +732,7 @@ def __init__( :paramtype policy_definition_groups: list[~azure.mgmt.resource.policy.v2019_09_01.models.PolicyDefinitionGroup] """ - super(PolicySetDefinition, self).__init__(**kwargs) + super().__init__(**kwargs) self.id = None self.name = None self.type = None @@ -762,7 +745,7 @@ def __init__( self.policy_definition_groups = policy_definition_groups -class PolicySetDefinitionListResult(msrest.serialization.Model): +class PolicySetDefinitionListResult(_serialization.Model): """List of policy set definitions. :ivar value: An array of policy set definitions. @@ -772,16 +755,12 @@ class PolicySetDefinitionListResult(msrest.serialization.Model): """ _attribute_map = { - 'value': {'key': 'value', 'type': '[PolicySetDefinition]'}, - 'next_link': {'key': 'nextLink', 'type': 'str'}, + "value": {"key": "value", "type": "[PolicySetDefinition]"}, + "next_link": {"key": "nextLink", "type": "str"}, } def __init__( - self, - *, - value: Optional[List["PolicySetDefinition"]] = None, - next_link: Optional[str] = None, - **kwargs + self, *, value: Optional[List["_models.PolicySetDefinition"]] = None, next_link: Optional[str] = None, **kwargs ): """ :keyword value: An array of policy set definitions. @@ -789,44 +768,38 @@ def __init__( :keyword next_link: The URL to use for getting the next set of results. :paramtype next_link: str """ - super(PolicySetDefinitionListResult, self).__init__(**kwargs) + super().__init__(**kwargs) self.value = value self.next_link = next_link -class PolicySku(msrest.serialization.Model): +class PolicySku(_serialization.Model): """The policy sku. This property is optional, obsolete, and will be ignored. All required parameters must be populated in order to send to Azure. - :ivar name: Required. The name of the policy sku. Possible values are A0 and A1. + :ivar name: The name of the policy sku. Possible values are A0 and A1. Required. :vartype name: str :ivar tier: The policy sku tier. Possible values are Free and Standard. :vartype tier: str """ _validation = { - 'name': {'required': True}, + "name": {"required": True}, } _attribute_map = { - 'name': {'key': 'name', 'type': 'str'}, - 'tier': {'key': 'tier', 'type': 'str'}, + "name": {"key": "name", "type": "str"}, + "tier": {"key": "tier", "type": "str"}, } - def __init__( - self, - *, - name: str, - tier: Optional[str] = None, - **kwargs - ): + def __init__(self, *, name: str, tier: Optional[str] = None, **kwargs): """ - :keyword name: Required. The name of the policy sku. Possible values are A0 and A1. + :keyword name: The name of the policy sku. Possible values are A0 and A1. Required. :paramtype name: str :keyword tier: The policy sku tier. Possible values are Free and Standard. :paramtype tier: str """ - super(PolicySku, self).__init__(**kwargs) + super().__init__(**kwargs) self.name = name self.tier = tier diff --git a/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/policy/v2019_09_01/models/_patch.py b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/policy/v2019_09_01/models/_patch.py new file mode 100644 index 0000000000000..f7dd32510333d --- /dev/null +++ b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/policy/v2019_09_01/models/_patch.py @@ -0,0 +1,20 @@ +# ------------------------------------ +# Copyright (c) Microsoft Corporation. +# Licensed under the MIT License. +# ------------------------------------ +"""Customize generated code here. + +Follow our quickstart for examples: https://aka.ms/azsdk/python/dpcodegen/python/customize +""" +from typing import List + +__all__: List[str] = [] # Add all objects you want publicly available to users at this package level + + +def patch_sdk(): + """Do not remove from this file. + + `patch_sdk` is a last resort escape hatch that allows you to do customizations + you can't accomplish using the techniques described in + https://aka.ms/azsdk/python/dpcodegen/python/customize + """ diff --git a/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/policy/v2019_09_01/models/_policy_client_enums.py b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/policy/v2019_09_01/models/_policy_client_enums.py index 74e077ddc5f12..32d926e71d180 100644 --- a/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/policy/v2019_09_01/models/_policy_client_enums.py +++ b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/policy/v2019_09_01/models/_policy_client_enums.py @@ -7,22 +7,20 @@ # -------------------------------------------------------------------------- from enum import Enum -from six import with_metaclass from azure.core import CaseInsensitiveEnumMeta -class EnforcementMode(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): - """The policy assignment enforcement mode. Possible values are Default and DoNotEnforce. - """ +class EnforcementMode(str, Enum, metaclass=CaseInsensitiveEnumMeta): + """The policy assignment enforcement mode. Possible values are Default and DoNotEnforce.""" #: The policy effect is enforced during resource creation or update. DEFAULT = "Default" #: The policy effect is not enforced during resource creation or update. DO_NOT_ENFORCE = "DoNotEnforce" -class ParameterType(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): - """The data type of the parameter. - """ + +class ParameterType(str, Enum, metaclass=CaseInsensitiveEnumMeta): + """The data type of the parameter.""" STRING = "String" ARRAY = "Array" @@ -32,16 +30,17 @@ class ParameterType(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): FLOAT = "Float" DATE_TIME = "DateTime" -class PolicyType(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): - """The type of policy definition. Possible values are NotSpecified, BuiltIn, Custom, and Static. - """ + +class PolicyType(str, Enum, metaclass=CaseInsensitiveEnumMeta): + """The type of policy definition. Possible values are NotSpecified, BuiltIn, Custom, and Static.""" NOT_SPECIFIED = "NotSpecified" BUILT_IN = "BuiltIn" CUSTOM = "Custom" STATIC = "Static" -class ResourceIdentityType(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): + +class ResourceIdentityType(str, Enum, metaclass=CaseInsensitiveEnumMeta): """The identity type. This is the only required field when adding a system assigned identity to a resource. """ diff --git a/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/policy/v2019_09_01/operations/__init__.py b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/policy/v2019_09_01/operations/__init__.py index b2ae6190b03fb..4e1971e3e3247 100644 --- a/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/policy/v2019_09_01/operations/__init__.py +++ b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/policy/v2019_09_01/operations/__init__.py @@ -10,8 +10,14 @@ from ._operations import PolicyDefinitionsOperations from ._operations import PolicySetDefinitionsOperations +from ._patch import __all__ as _patch_all +from ._patch import * # type: ignore # pylint: disable=unused-wildcard-import +from ._patch import patch_sdk as _patch_sdk + __all__ = [ - 'PolicyAssignmentsOperations', - 'PolicyDefinitionsOperations', - 'PolicySetDefinitionsOperations', + "PolicyAssignmentsOperations", + "PolicyDefinitionsOperations", + "PolicySetDefinitionsOperations", ] +__all__.extend([p for p in _patch_all if p not in __all__]) +_patch_sdk() diff --git a/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/policy/v2019_09_01/operations/_operations.py b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/policy/v2019_09_01/operations/_operations.py index 39ce172c45414..0f8bb38a916a7 100644 --- a/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/policy/v2019_09_01/operations/_operations.py +++ b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/policy/v2019_09_01/operations/_operations.py @@ -6,173 +6,152 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -from typing import Any, Callable, Dict, Iterable, Optional, TypeVar - -from msrest import Serializer - -from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error +from typing import Any, Callable, Dict, IO, Iterable, Optional, TypeVar, Union, overload +from urllib.parse import parse_qs, urljoin, urlparse + +from azure.core.exceptions import ( + ClientAuthenticationError, + HttpResponseError, + ResourceExistsError, + ResourceNotFoundError, + ResourceNotModifiedError, + map_error, +) from azure.core.paging import ItemPaged from azure.core.pipeline import PipelineResponse from azure.core.pipeline.transport import HttpResponse from azure.core.rest import HttpRequest from azure.core.tracing.decorator import distributed_trace +from azure.core.utils import case_insensitive_dict from azure.mgmt.core.exceptions import ARMErrorFormat from .. import models as _models +from ..._serialization import Serializer from .._vendor import _convert_request, _format_url_section -T = TypeVar('T') -JSONType = Any + +T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] _SERIALIZER = Serializer() _SERIALIZER.client_side_validation = False -def build_policy_assignments_delete_request( - scope: str, - policy_assignment_name: str, - **kwargs: Any -) -> HttpRequest: - api_version = kwargs.pop('api_version', "2019-09-01") # type: str - accept = "application/json" +def build_policy_assignments_delete_request(scope: str, policy_assignment_name: 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", "2019-09-01")) # type: str + accept = _headers.pop("Accept", "application/json") + # Construct URL - _url = kwargs.pop("template_url", "/{scope}/providers/Microsoft.Authorization/policyAssignments/{policyAssignmentName}") + _url = kwargs.pop( + "template_url", "/{scope}/providers/Microsoft.Authorization/policyAssignments/{policyAssignmentName}" + ) path_format_arguments = { - "scope": _SERIALIZER.url("scope", scope, 'str', skip_quote=True), - "policyAssignmentName": _SERIALIZER.url("policy_assignment_name", policy_assignment_name, 'str'), + "scope": _SERIALIZER.url("scope", scope, "str", skip_quote=True), + "policyAssignmentName": _SERIALIZER.url("policy_assignment_name", policy_assignment_name, "str"), } _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') - - return HttpRequest( - method="DELETE", - url=_url, - params=_query_parameters, - headers=_header_parameters, - **kwargs - ) + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + return HttpRequest(method="DELETE", url=_url, params=_params, headers=_headers, **kwargs) -def build_policy_assignments_create_request( - scope: str, - policy_assignment_name: str, - *, - json: JSONType = None, - content: Any = None, - **kwargs: Any -) -> HttpRequest: - api_version = kwargs.pop('api_version', "2019-09-01") # type: str - content_type = kwargs.pop('content_type', None) # type: Optional[str] - accept = "application/json" +def build_policy_assignments_create_request(scope: str, policy_assignment_name: 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", "2019-09-01")) # type: str + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + accept = _headers.pop("Accept", "application/json") + # Construct URL - _url = kwargs.pop("template_url", "/{scope}/providers/Microsoft.Authorization/policyAssignments/{policyAssignmentName}") + _url = kwargs.pop( + "template_url", "/{scope}/providers/Microsoft.Authorization/policyAssignments/{policyAssignmentName}" + ) path_format_arguments = { - "scope": _SERIALIZER.url("scope", scope, 'str', skip_quote=True), - "policyAssignmentName": _SERIALIZER.url("policy_assignment_name", policy_assignment_name, 'str'), + "scope": _SERIALIZER.url("scope", scope, "str", skip_quote=True), + "policyAssignmentName": _SERIALIZER.url("policy_assignment_name", policy_assignment_name, "str"), } _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] if content_type is not None: - _header_parameters['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') - _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') - - return HttpRequest( - method="PUT", - url=_url, - params=_query_parameters, - headers=_header_parameters, - json=json, - content=content, - **kwargs - ) + _headers["Content-Type"] = _SERIALIZER.header("content_type", content_type, "str") + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + return HttpRequest(method="PUT", url=_url, params=_params, headers=_headers, **kwargs) -def build_policy_assignments_get_request( - scope: str, - policy_assignment_name: str, - **kwargs: Any -) -> HttpRequest: - api_version = kwargs.pop('api_version', "2019-09-01") # type: str - accept = "application/json" +def build_policy_assignments_get_request(scope: str, policy_assignment_name: 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", "2019-09-01")) # type: str + accept = _headers.pop("Accept", "application/json") + # Construct URL - _url = kwargs.pop("template_url", "/{scope}/providers/Microsoft.Authorization/policyAssignments/{policyAssignmentName}") + _url = kwargs.pop( + "template_url", "/{scope}/providers/Microsoft.Authorization/policyAssignments/{policyAssignmentName}" + ) path_format_arguments = { - "scope": _SERIALIZER.url("scope", scope, 'str', skip_quote=True), - "policyAssignmentName": _SERIALIZER.url("policy_assignment_name", policy_assignment_name, 'str'), + "scope": _SERIALIZER.url("scope", scope, "str", skip_quote=True), + "policyAssignmentName": _SERIALIZER.url("policy_assignment_name", policy_assignment_name, "str"), } _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') - - return HttpRequest( - method="GET", - url=_url, - params=_query_parameters, - headers=_header_parameters, - **kwargs - ) + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) def build_policy_assignments_list_for_resource_group_request( - resource_group_name: str, - subscription_id: str, - *, - filter: Optional[str] = None, - **kwargs: Any + resource_group_name: str, subscription_id: str, *, filter: Optional[str] = None, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2019-09-01") # type: 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", "2019-09-01")) # type: str + accept = _headers.pop("Accept", "application/json") - accept = "application/json" # Construct URL - _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Authorization/policyAssignments") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Authorization/policyAssignments", + ) # pylint: disable=line-too-long path_format_arguments = { - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._\(\)]+$'), - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), + "resourceGroupName": _SERIALIZER.url( + "resource_group_name", resource_group_name, "str", max_length=90, min_length=1, pattern=r"^[-\w\._\(\)]+$" + ), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), } _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] if filter is not None: - _query_parameters['$filter'] = _SERIALIZER.query("filter", filter, 'str', skip_quote=True) - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["$filter"] = _SERIALIZER.query("filter", filter, "str", skip_quote=True) + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') - - return HttpRequest( - method="GET", - url=_url, - params=_query_parameters, - headers=_header_parameters, - **kwargs - ) + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) def build_policy_assignments_list_for_resource_request( @@ -186,928 +165,765 @@ def build_policy_assignments_list_for_resource_request( filter: Optional[str] = None, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2019-09-01") # type: 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", "2019-09-01")) # type: str + accept = _headers.pop("Accept", "application/json") - accept = "application/json" # Construct URL - _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{parentResourcePath}/{resourceType}/{resourceName}/providers/Microsoft.Authorization/policyAssignments") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{parentResourcePath}/{resourceType}/{resourceName}/providers/Microsoft.Authorization/policyAssignments", + ) # pylint: disable=line-too-long path_format_arguments = { - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._\(\)]+$'), - "resourceProviderNamespace": _SERIALIZER.url("resource_provider_namespace", resource_provider_namespace, 'str'), - "parentResourcePath": _SERIALIZER.url("parent_resource_path", parent_resource_path, 'str', skip_quote=True), - "resourceType": _SERIALIZER.url("resource_type", resource_type, 'str', skip_quote=True), - "resourceName": _SERIALIZER.url("resource_name", resource_name, 'str'), - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), + "resourceGroupName": _SERIALIZER.url( + "resource_group_name", resource_group_name, "str", max_length=90, min_length=1, pattern=r"^[-\w\._\(\)]+$" + ), + "resourceProviderNamespace": _SERIALIZER.url("resource_provider_namespace", resource_provider_namespace, "str"), + "parentResourcePath": _SERIALIZER.url("parent_resource_path", parent_resource_path, "str", skip_quote=True), + "resourceType": _SERIALIZER.url("resource_type", resource_type, "str", skip_quote=True), + "resourceName": _SERIALIZER.url("resource_name", resource_name, "str"), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), } _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] if filter is not None: - _query_parameters['$filter'] = _SERIALIZER.query("filter", filter, 'str') - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["$filter"] = _SERIALIZER.query("filter", filter, "str") + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') - - return HttpRequest( - method="GET", - url=_url, - params=_query_parameters, - headers=_header_parameters, - **kwargs - ) + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) def build_policy_assignments_list_for_management_group_request( - management_group_id: str, - *, - filter: str, - **kwargs: Any + management_group_id: str, *, filter: str, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2019-09-01") # type: 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", "2019-09-01")) # type: str + accept = _headers.pop("Accept", "application/json") - accept = "application/json" # Construct URL - _url = kwargs.pop("template_url", "/providers/Microsoft.Management/managementgroups/{managementGroupId}/providers/Microsoft.Authorization/policyAssignments") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", + "/providers/Microsoft.Management/managementgroups/{managementGroupId}/providers/Microsoft.Authorization/policyAssignments", + ) # pylint: disable=line-too-long path_format_arguments = { - "managementGroupId": _SERIALIZER.url("management_group_id", management_group_id, 'str'), + "managementGroupId": _SERIALIZER.url("management_group_id", management_group_id, "str"), } _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['$filter'] = _SERIALIZER.query("filter", filter, 'str', skip_quote=True) - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["$filter"] = _SERIALIZER.query("filter", filter, "str", skip_quote=True) + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') - - return HttpRequest( - method="GET", - url=_url, - params=_query_parameters, - headers=_header_parameters, - **kwargs - ) + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) def build_policy_assignments_list_request( - subscription_id: str, - *, - filter: Optional[str] = None, - **kwargs: Any + subscription_id: str, *, filter: Optional[str] = None, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2019-09-01") # type: 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", "2019-09-01")) # type: str + accept = _headers.pop("Accept", "application/json") - accept = "application/json" # Construct URL - _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/providers/Microsoft.Authorization/policyAssignments") + _url = kwargs.pop( + "template_url", "/subscriptions/{subscriptionId}/providers/Microsoft.Authorization/policyAssignments" + ) path_format_arguments = { - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), } _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] if filter is not None: - _query_parameters['$filter'] = _SERIALIZER.query("filter", filter, 'str') - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["$filter"] = _SERIALIZER.query("filter", filter, "str") + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') - - return HttpRequest( - method="GET", - url=_url, - params=_query_parameters, - headers=_header_parameters, - **kwargs - ) + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) -def build_policy_assignments_delete_by_id_request( - policy_assignment_id: str, - **kwargs: Any -) -> HttpRequest: - api_version = kwargs.pop('api_version', "2019-09-01") # type: str - accept = "application/json" +def build_policy_assignments_delete_by_id_request(policy_assignment_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", "2019-09-01")) # type: str + accept = _headers.pop("Accept", "application/json") + # Construct URL _url = kwargs.pop("template_url", "/{policyAssignmentId}") path_format_arguments = { - "policyAssignmentId": _SERIALIZER.url("policy_assignment_id", policy_assignment_id, 'str', skip_quote=True), + "policyAssignmentId": _SERIALIZER.url("policy_assignment_id", policy_assignment_id, "str", skip_quote=True), } _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') - - return HttpRequest( - method="DELETE", - url=_url, - params=_query_parameters, - headers=_header_parameters, - **kwargs - ) + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + return HttpRequest(method="DELETE", url=_url, params=_params, headers=_headers, **kwargs) -def build_policy_assignments_create_by_id_request( - policy_assignment_id: str, - *, - json: JSONType = None, - content: Any = None, - **kwargs: Any -) -> HttpRequest: - api_version = kwargs.pop('api_version', "2019-09-01") # type: str - content_type = kwargs.pop('content_type', None) # type: Optional[str] - accept = "application/json" +def build_policy_assignments_create_by_id_request(policy_assignment_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", "2019-09-01")) # type: str + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + accept = _headers.pop("Accept", "application/json") + # Construct URL _url = kwargs.pop("template_url", "/{policyAssignmentId}") path_format_arguments = { - "policyAssignmentId": _SERIALIZER.url("policy_assignment_id", policy_assignment_id, 'str', skip_quote=True), + "policyAssignmentId": _SERIALIZER.url("policy_assignment_id", policy_assignment_id, "str", skip_quote=True), } _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] if content_type is not None: - _header_parameters['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') - _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') - - return HttpRequest( - method="PUT", - url=_url, - params=_query_parameters, - headers=_header_parameters, - json=json, - content=content, - **kwargs - ) + _headers["Content-Type"] = _SERIALIZER.header("content_type", content_type, "str") + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + return HttpRequest(method="PUT", url=_url, params=_params, headers=_headers, **kwargs) -def build_policy_assignments_get_by_id_request( - policy_assignment_id: str, - **kwargs: Any -) -> HttpRequest: - api_version = kwargs.pop('api_version', "2019-09-01") # type: str - accept = "application/json" +def build_policy_assignments_get_by_id_request(policy_assignment_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", "2019-09-01")) # type: str + accept = _headers.pop("Accept", "application/json") + # Construct URL _url = kwargs.pop("template_url", "/{policyAssignmentId}") path_format_arguments = { - "policyAssignmentId": _SERIALIZER.url("policy_assignment_id", policy_assignment_id, 'str', skip_quote=True), + "policyAssignmentId": _SERIALIZER.url("policy_assignment_id", policy_assignment_id, "str", skip_quote=True), } _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') - - return HttpRequest( - method="GET", - url=_url, - params=_query_parameters, - headers=_header_parameters, - **kwargs - ) + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) def build_policy_definitions_create_or_update_request( - policy_definition_name: str, - subscription_id: str, - *, - json: JSONType = None, - content: Any = None, - **kwargs: Any + policy_definition_name: str, subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2019-09-01") # type: str - content_type = kwargs.pop('content_type', None) # type: Optional[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", "2019-09-01")) # type: str + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + accept = _headers.pop("Accept", "application/json") - accept = "application/json" # Construct URL - _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/providers/Microsoft.Authorization/policyDefinitions/{policyDefinitionName}") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/providers/Microsoft.Authorization/policyDefinitions/{policyDefinitionName}", + ) # pylint: disable=line-too-long path_format_arguments = { - "policyDefinitionName": _SERIALIZER.url("policy_definition_name", policy_definition_name, 'str'), - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), + "policyDefinitionName": _SERIALIZER.url("policy_definition_name", policy_definition_name, "str"), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), } _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] if content_type is not None: - _header_parameters['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') - _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') - - return HttpRequest( - method="PUT", - url=_url, - params=_query_parameters, - headers=_header_parameters, - json=json, - content=content, - **kwargs - ) + _headers["Content-Type"] = _SERIALIZER.header("content_type", content_type, "str") + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="PUT", url=_url, params=_params, headers=_headers, **kwargs) def build_policy_definitions_delete_request( - policy_definition_name: str, - subscription_id: str, - **kwargs: Any + policy_definition_name: str, subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2019-09-01") # type: 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", "2019-09-01")) # type: str + accept = _headers.pop("Accept", "application/json") - accept = "application/json" # Construct URL - _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/providers/Microsoft.Authorization/policyDefinitions/{policyDefinitionName}") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/providers/Microsoft.Authorization/policyDefinitions/{policyDefinitionName}", + ) # pylint: disable=line-too-long path_format_arguments = { - "policyDefinitionName": _SERIALIZER.url("policy_definition_name", policy_definition_name, 'str'), - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), + "policyDefinitionName": _SERIALIZER.url("policy_definition_name", policy_definition_name, "str"), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), } _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') - - return HttpRequest( - method="DELETE", - url=_url, - params=_query_parameters, - headers=_header_parameters, - **kwargs - ) + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="DELETE", url=_url, params=_params, headers=_headers, **kwargs) def build_policy_definitions_get_request( - policy_definition_name: str, - subscription_id: str, - **kwargs: Any + policy_definition_name: str, subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2019-09-01") # type: 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", "2019-09-01")) # type: str + accept = _headers.pop("Accept", "application/json") - accept = "application/json" # Construct URL - _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/providers/Microsoft.Authorization/policyDefinitions/{policyDefinitionName}") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/providers/Microsoft.Authorization/policyDefinitions/{policyDefinitionName}", + ) # pylint: disable=line-too-long path_format_arguments = { - "policyDefinitionName": _SERIALIZER.url("policy_definition_name", policy_definition_name, 'str'), - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), + "policyDefinitionName": _SERIALIZER.url("policy_definition_name", policy_definition_name, "str"), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), } _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') - - return HttpRequest( - method="GET", - url=_url, - params=_query_parameters, - headers=_header_parameters, - **kwargs - ) + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) -def build_policy_definitions_get_built_in_request( - policy_definition_name: str, - **kwargs: Any -) -> HttpRequest: - api_version = kwargs.pop('api_version', "2019-09-01") # type: str - accept = "application/json" +def build_policy_definitions_get_built_in_request(policy_definition_name: 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", "2019-09-01")) # type: str + accept = _headers.pop("Accept", "application/json") + # Construct URL _url = kwargs.pop("template_url", "/providers/Microsoft.Authorization/policyDefinitions/{policyDefinitionName}") path_format_arguments = { - "policyDefinitionName": _SERIALIZER.url("policy_definition_name", policy_definition_name, 'str'), + "policyDefinitionName": _SERIALIZER.url("policy_definition_name", policy_definition_name, "str"), } _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') - - return HttpRequest( - method="GET", - url=_url, - params=_query_parameters, - headers=_header_parameters, - **kwargs - ) + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) def build_policy_definitions_create_or_update_at_management_group_request( - policy_definition_name: str, - management_group_id: str, - *, - json: JSONType = None, - content: Any = None, - **kwargs: Any + policy_definition_name: str, management_group_id: str, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2019-09-01") # type: str - content_type = kwargs.pop('content_type', None) # type: Optional[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", "2019-09-01")) # type: str + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + accept = _headers.pop("Accept", "application/json") - accept = "application/json" # Construct URL - _url = kwargs.pop("template_url", "/providers/Microsoft.Management/managementgroups/{managementGroupId}/providers/Microsoft.Authorization/policyDefinitions/{policyDefinitionName}") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", + "/providers/Microsoft.Management/managementgroups/{managementGroupId}/providers/Microsoft.Authorization/policyDefinitions/{policyDefinitionName}", + ) # pylint: disable=line-too-long path_format_arguments = { - "policyDefinitionName": _SERIALIZER.url("policy_definition_name", policy_definition_name, 'str'), - "managementGroupId": _SERIALIZER.url("management_group_id", management_group_id, 'str'), + "policyDefinitionName": _SERIALIZER.url("policy_definition_name", policy_definition_name, "str"), + "managementGroupId": _SERIALIZER.url("management_group_id", management_group_id, "str"), } _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] if content_type is not None: - _header_parameters['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') - _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') - - return HttpRequest( - method="PUT", - url=_url, - params=_query_parameters, - headers=_header_parameters, - json=json, - content=content, - **kwargs - ) + _headers["Content-Type"] = _SERIALIZER.header("content_type", content_type, "str") + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="PUT", url=_url, params=_params, headers=_headers, **kwargs) def build_policy_definitions_delete_at_management_group_request( - policy_definition_name: str, - management_group_id: str, - **kwargs: Any + policy_definition_name: str, management_group_id: str, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2019-09-01") # type: 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", "2019-09-01")) # type: str + accept = _headers.pop("Accept", "application/json") - accept = "application/json" # Construct URL - _url = kwargs.pop("template_url", "/providers/Microsoft.Management/managementgroups/{managementGroupId}/providers/Microsoft.Authorization/policyDefinitions/{policyDefinitionName}") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", + "/providers/Microsoft.Management/managementgroups/{managementGroupId}/providers/Microsoft.Authorization/policyDefinitions/{policyDefinitionName}", + ) # pylint: disable=line-too-long path_format_arguments = { - "policyDefinitionName": _SERIALIZER.url("policy_definition_name", policy_definition_name, 'str'), - "managementGroupId": _SERIALIZER.url("management_group_id", management_group_id, 'str'), + "policyDefinitionName": _SERIALIZER.url("policy_definition_name", policy_definition_name, "str"), + "managementGroupId": _SERIALIZER.url("management_group_id", management_group_id, "str"), } _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') - - return HttpRequest( - method="DELETE", - url=_url, - params=_query_parameters, - headers=_header_parameters, - **kwargs - ) + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="DELETE", url=_url, params=_params, headers=_headers, **kwargs) def build_policy_definitions_get_at_management_group_request( - policy_definition_name: str, - management_group_id: str, - **kwargs: Any + policy_definition_name: str, management_group_id: str, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2019-09-01") # type: 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", "2019-09-01")) # type: str + accept = _headers.pop("Accept", "application/json") - accept = "application/json" # Construct URL - _url = kwargs.pop("template_url", "/providers/Microsoft.Management/managementgroups/{managementGroupId}/providers/Microsoft.Authorization/policyDefinitions/{policyDefinitionName}") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", + "/providers/Microsoft.Management/managementgroups/{managementGroupId}/providers/Microsoft.Authorization/policyDefinitions/{policyDefinitionName}", + ) # pylint: disable=line-too-long path_format_arguments = { - "policyDefinitionName": _SERIALIZER.url("policy_definition_name", policy_definition_name, 'str'), - "managementGroupId": _SERIALIZER.url("management_group_id", management_group_id, 'str'), + "policyDefinitionName": _SERIALIZER.url("policy_definition_name", policy_definition_name, "str"), + "managementGroupId": _SERIALIZER.url("management_group_id", management_group_id, "str"), } _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') - - return HttpRequest( - method="GET", - url=_url, - params=_query_parameters, - headers=_header_parameters, - **kwargs - ) + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) -def build_policy_definitions_list_request( - subscription_id: str, - **kwargs: Any -) -> HttpRequest: - api_version = kwargs.pop('api_version', "2019-09-01") # type: str - accept = "application/json" +def build_policy_definitions_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", "2019-09-01")) # type: str + accept = _headers.pop("Accept", "application/json") + # Construct URL - _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/providers/Microsoft.Authorization/policyDefinitions") + _url = kwargs.pop( + "template_url", "/subscriptions/{subscriptionId}/providers/Microsoft.Authorization/policyDefinitions" + ) path_format_arguments = { - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), } _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') - - return HttpRequest( - method="GET", - url=_url, - params=_query_parameters, - headers=_header_parameters, - **kwargs - ) + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) -def build_policy_definitions_list_built_in_request( - **kwargs: Any -) -> HttpRequest: - api_version = kwargs.pop('api_version', "2019-09-01") # type: str - accept = "application/json" +def build_policy_definitions_list_built_in_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", "2019-09-01")) # type: str + accept = _headers.pop("Accept", "application/json") + # Construct URL _url = kwargs.pop("template_url", "/providers/Microsoft.Authorization/policyDefinitions") # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') - - return HttpRequest( - method="GET", - url=_url, - params=_query_parameters, - headers=_header_parameters, - **kwargs - ) + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) -def build_policy_definitions_list_by_management_group_request( - management_group_id: str, - **kwargs: Any -) -> HttpRequest: - api_version = kwargs.pop('api_version', "2019-09-01") # type: str - accept = "application/json" +def build_policy_definitions_list_by_management_group_request(management_group_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", "2019-09-01")) # type: str + accept = _headers.pop("Accept", "application/json") + # Construct URL - _url = kwargs.pop("template_url", "/providers/Microsoft.Management/managementgroups/{managementGroupId}/providers/Microsoft.Authorization/policyDefinitions") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", + "/providers/Microsoft.Management/managementgroups/{managementGroupId}/providers/Microsoft.Authorization/policyDefinitions", + ) # pylint: disable=line-too-long path_format_arguments = { - "managementGroupId": _SERIALIZER.url("management_group_id", management_group_id, 'str'), + "managementGroupId": _SERIALIZER.url("management_group_id", management_group_id, "str"), } _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') - - return HttpRequest( - method="GET", - url=_url, - params=_query_parameters, - headers=_header_parameters, - **kwargs - ) + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) def build_policy_set_definitions_create_or_update_request( - policy_set_definition_name: str, - subscription_id: str, - *, - json: JSONType = None, - content: Any = None, - **kwargs: Any + policy_set_definition_name: str, subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2019-09-01") # type: str - content_type = kwargs.pop('content_type', None) # type: Optional[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", "2019-09-01")) # type: str + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + accept = _headers.pop("Accept", "application/json") - accept = "application/json" # Construct URL - _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/providers/Microsoft.Authorization/policySetDefinitions/{policySetDefinitionName}") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/providers/Microsoft.Authorization/policySetDefinitions/{policySetDefinitionName}", + ) # pylint: disable=line-too-long path_format_arguments = { - "policySetDefinitionName": _SERIALIZER.url("policy_set_definition_name", policy_set_definition_name, 'str'), - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), + "policySetDefinitionName": _SERIALIZER.url("policy_set_definition_name", policy_set_definition_name, "str"), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), } _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] if content_type is not None: - _header_parameters['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') - _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') - - return HttpRequest( - method="PUT", - url=_url, - params=_query_parameters, - headers=_header_parameters, - json=json, - content=content, - **kwargs - ) + _headers["Content-Type"] = _SERIALIZER.header("content_type", content_type, "str") + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="PUT", url=_url, params=_params, headers=_headers, **kwargs) def build_policy_set_definitions_delete_request( - policy_set_definition_name: str, - subscription_id: str, - **kwargs: Any + policy_set_definition_name: str, subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2019-09-01") # type: 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", "2019-09-01")) # type: str + accept = _headers.pop("Accept", "application/json") - accept = "application/json" # Construct URL - _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/providers/Microsoft.Authorization/policySetDefinitions/{policySetDefinitionName}") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/providers/Microsoft.Authorization/policySetDefinitions/{policySetDefinitionName}", + ) # pylint: disable=line-too-long path_format_arguments = { - "policySetDefinitionName": _SERIALIZER.url("policy_set_definition_name", policy_set_definition_name, 'str'), - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), + "policySetDefinitionName": _SERIALIZER.url("policy_set_definition_name", policy_set_definition_name, "str"), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), } _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') - - return HttpRequest( - method="DELETE", - url=_url, - params=_query_parameters, - headers=_header_parameters, - **kwargs - ) + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="DELETE", url=_url, params=_params, headers=_headers, **kwargs) def build_policy_set_definitions_get_request( - policy_set_definition_name: str, - subscription_id: str, - **kwargs: Any + policy_set_definition_name: str, subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2019-09-01") # type: 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", "2019-09-01")) # type: str + accept = _headers.pop("Accept", "application/json") - accept = "application/json" # Construct URL - _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/providers/Microsoft.Authorization/policySetDefinitions/{policySetDefinitionName}") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/providers/Microsoft.Authorization/policySetDefinitions/{policySetDefinitionName}", + ) # pylint: disable=line-too-long path_format_arguments = { - "policySetDefinitionName": _SERIALIZER.url("policy_set_definition_name", policy_set_definition_name, 'str'), - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), + "policySetDefinitionName": _SERIALIZER.url("policy_set_definition_name", policy_set_definition_name, "str"), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), } _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') - - return HttpRequest( - method="GET", - url=_url, - params=_query_parameters, - headers=_header_parameters, - **kwargs - ) + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) -def build_policy_set_definitions_get_built_in_request( - policy_set_definition_name: str, - **kwargs: Any -) -> HttpRequest: - api_version = kwargs.pop('api_version', "2019-09-01") # type: str - accept = "application/json" +def build_policy_set_definitions_get_built_in_request(policy_set_definition_name: 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", "2019-09-01")) # type: str + accept = _headers.pop("Accept", "application/json") + # Construct URL - _url = kwargs.pop("template_url", "/providers/Microsoft.Authorization/policySetDefinitions/{policySetDefinitionName}") + _url = kwargs.pop( + "template_url", "/providers/Microsoft.Authorization/policySetDefinitions/{policySetDefinitionName}" + ) path_format_arguments = { - "policySetDefinitionName": _SERIALIZER.url("policy_set_definition_name", policy_set_definition_name, 'str'), + "policySetDefinitionName": _SERIALIZER.url("policy_set_definition_name", policy_set_definition_name, "str"), } _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') - - return HttpRequest( - method="GET", - url=_url, - params=_query_parameters, - headers=_header_parameters, - **kwargs - ) + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) -def build_policy_set_definitions_list_request( - subscription_id: str, - **kwargs: Any -) -> HttpRequest: - api_version = kwargs.pop('api_version', "2019-09-01") # type: str - accept = "application/json" +def build_policy_set_definitions_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", "2019-09-01")) # type: str + accept = _headers.pop("Accept", "application/json") + # Construct URL - _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/providers/Microsoft.Authorization/policySetDefinitions") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", "/subscriptions/{subscriptionId}/providers/Microsoft.Authorization/policySetDefinitions" + ) # pylint: disable=line-too-long path_format_arguments = { - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), } _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') - - return HttpRequest( - method="GET", - url=_url, - params=_query_parameters, - headers=_header_parameters, - **kwargs - ) + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) -def build_policy_set_definitions_list_built_in_request( - **kwargs: Any -) -> HttpRequest: - api_version = kwargs.pop('api_version', "2019-09-01") # type: str - accept = "application/json" +def build_policy_set_definitions_list_built_in_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", "2019-09-01")) # type: str + accept = _headers.pop("Accept", "application/json") + # Construct URL _url = kwargs.pop("template_url", "/providers/Microsoft.Authorization/policySetDefinitions") # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') - - return HttpRequest( - method="GET", - url=_url, - params=_query_parameters, - headers=_header_parameters, - **kwargs - ) + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) def build_policy_set_definitions_create_or_update_at_management_group_request( - policy_set_definition_name: str, - management_group_id: str, - *, - json: JSONType = None, - content: Any = None, - **kwargs: Any + policy_set_definition_name: str, management_group_id: str, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2019-09-01") # type: str - content_type = kwargs.pop('content_type', None) # type: Optional[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", "2019-09-01")) # type: str + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + accept = _headers.pop("Accept", "application/json") - accept = "application/json" # Construct URL - _url = kwargs.pop("template_url", "/providers/Microsoft.Management/managementgroups/{managementGroupId}/providers/Microsoft.Authorization/policySetDefinitions/{policySetDefinitionName}") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", + "/providers/Microsoft.Management/managementgroups/{managementGroupId}/providers/Microsoft.Authorization/policySetDefinitions/{policySetDefinitionName}", + ) # pylint: disable=line-too-long path_format_arguments = { - "policySetDefinitionName": _SERIALIZER.url("policy_set_definition_name", policy_set_definition_name, 'str'), - "managementGroupId": _SERIALIZER.url("management_group_id", management_group_id, 'str'), + "policySetDefinitionName": _SERIALIZER.url("policy_set_definition_name", policy_set_definition_name, "str"), + "managementGroupId": _SERIALIZER.url("management_group_id", management_group_id, "str"), } _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] if content_type is not None: - _header_parameters['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') - _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') - - return HttpRequest( - method="PUT", - url=_url, - params=_query_parameters, - headers=_header_parameters, - json=json, - content=content, - **kwargs - ) + _headers["Content-Type"] = _SERIALIZER.header("content_type", content_type, "str") + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="PUT", url=_url, params=_params, headers=_headers, **kwargs) def build_policy_set_definitions_delete_at_management_group_request( - policy_set_definition_name: str, - management_group_id: str, - **kwargs: Any + policy_set_definition_name: str, management_group_id: str, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2019-09-01") # type: 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", "2019-09-01")) # type: str + accept = _headers.pop("Accept", "application/json") - accept = "application/json" # Construct URL - _url = kwargs.pop("template_url", "/providers/Microsoft.Management/managementgroups/{managementGroupId}/providers/Microsoft.Authorization/policySetDefinitions/{policySetDefinitionName}") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", + "/providers/Microsoft.Management/managementgroups/{managementGroupId}/providers/Microsoft.Authorization/policySetDefinitions/{policySetDefinitionName}", + ) # pylint: disable=line-too-long path_format_arguments = { - "policySetDefinitionName": _SERIALIZER.url("policy_set_definition_name", policy_set_definition_name, 'str'), - "managementGroupId": _SERIALIZER.url("management_group_id", management_group_id, 'str'), + "policySetDefinitionName": _SERIALIZER.url("policy_set_definition_name", policy_set_definition_name, "str"), + "managementGroupId": _SERIALIZER.url("management_group_id", management_group_id, "str"), } _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') - - return HttpRequest( - method="DELETE", - url=_url, - params=_query_parameters, - headers=_header_parameters, - **kwargs - ) + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="DELETE", url=_url, params=_params, headers=_headers, **kwargs) def build_policy_set_definitions_get_at_management_group_request( - policy_set_definition_name: str, - management_group_id: str, - **kwargs: Any + policy_set_definition_name: str, management_group_id: str, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2019-09-01") # type: 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", "2019-09-01")) # type: str + accept = _headers.pop("Accept", "application/json") - accept = "application/json" # Construct URL - _url = kwargs.pop("template_url", "/providers/Microsoft.Management/managementgroups/{managementGroupId}/providers/Microsoft.Authorization/policySetDefinitions/{policySetDefinitionName}") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", + "/providers/Microsoft.Management/managementgroups/{managementGroupId}/providers/Microsoft.Authorization/policySetDefinitions/{policySetDefinitionName}", + ) # pylint: disable=line-too-long path_format_arguments = { - "policySetDefinitionName": _SERIALIZER.url("policy_set_definition_name", policy_set_definition_name, 'str'), - "managementGroupId": _SERIALIZER.url("management_group_id", management_group_id, 'str'), + "policySetDefinitionName": _SERIALIZER.url("policy_set_definition_name", policy_set_definition_name, "str"), + "managementGroupId": _SERIALIZER.url("management_group_id", management_group_id, "str"), } _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') - - return HttpRequest( - method="GET", - url=_url, - params=_query_parameters, - headers=_header_parameters, - **kwargs - ) + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) def build_policy_set_definitions_list_by_management_group_request( - management_group_id: str, - **kwargs: Any + management_group_id: str, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2019-09-01") # type: 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", "2019-09-01")) # type: str + accept = _headers.pop("Accept", "application/json") - accept = "application/json" # Construct URL - _url = kwargs.pop("template_url", "/providers/Microsoft.Management/managementgroups/{managementGroupId}/providers/Microsoft.Authorization/policySetDefinitions") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", + "/providers/Microsoft.Management/managementgroups/{managementGroupId}/providers/Microsoft.Authorization/policySetDefinitions", + ) # pylint: disable=line-too-long path_format_arguments = { - "managementGroupId": _SERIALIZER.url("management_group_id", management_group_id, 'str'), + "managementGroupId": _SERIALIZER.url("management_group_id", management_group_id, "str"), } _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') - - return HttpRequest( - method="GET", - url=_url, - params=_query_parameters, - headers=_header_parameters, - **kwargs - ) + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") -class PolicyAssignmentsOperations(object): - """PolicyAssignmentsOperations operations. + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) - You should not instantiate this class directly. Instead, you should create a Client instance that - instantiates it for you and attaches it as an attribute. - :ivar models: Alias to model classes used in this operation group. - :type models: ~azure.mgmt.resource.policy.v2019_09_01.models - :param client: Client for service requests. - :param config: Configuration of service client. - :param serializer: An object model serializer. - :param deserializer: An object model deserializer. +class PolicyAssignmentsOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. + + Instead, you should access the following operations through + :class:`~azure.mgmt.resource.policy.v2019_09_01.PolicyClient`'s + :attr:`policy_assignments` attribute. """ models = _models - def __init__(self, client, config, serializer, deserializer): - self._client = client - self._serialize = serializer - self._deserialize = deserializer - self._config = config + def __init__(self, *args, **kwargs): + input_args = list(args) + self._client = input_args.pop(0) if input_args else kwargs.pop("client") + self._config = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") @distributed_trace - def delete( - self, - scope: str, - policy_assignment_name: str, - **kwargs: Any - ) -> Optional["_models.PolicyAssignment"]: + def delete(self, scope: str, policy_assignment_name: str, **kwargs: Any) -> Optional[_models.PolicyAssignment]: """Deletes a policy assignment. This operation deletes a policy assignment, given its name and the scope it was created in. The @@ -1119,37 +935,44 @@ def delete( '/subscriptions/{subscriptionId}'), resource group (format: '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}', or resource (format: '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{resourceProviderNamespace}/[{parentResourcePath}/]{resourceType}/{resourceName}'. + Required. :type scope: str - :param policy_assignment_name: The name of the policy assignment to delete. + :param policy_assignment_name: The name of the policy assignment to delete. Required. :type policy_assignment_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: PolicyAssignment, or the result of cls(response) + :return: PolicyAssignment or None or the result of cls(response) :rtype: ~azure.mgmt.resource.policy.v2019_09_01.models.PolicyAssignment or None - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType[Optional["_models.PolicyAssignment"]] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) - api_version = kwargs.pop('api_version', "2019-09-01") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2019-09-01")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[Optional[_models.PolicyAssignment]] - request = build_policy_assignments_delete_request( scope=scope, policy_assignment_name=policy_assignment_name, api_version=api_version, - template_url=self.delete.metadata['url'], + template_url=self.delete.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200, 204]: @@ -1158,24 +981,25 @@ def delete( deserialized = None if response.status_code == 200: - deserialized = self._deserialize('PolicyAssignment', pipeline_response) + deserialized = self._deserialize("PolicyAssignment", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - delete.metadata = {'url': "/{scope}/providers/Microsoft.Authorization/policyAssignments/{policyAssignmentName}"} # type: ignore - + delete.metadata = {"url": "/{scope}/providers/Microsoft.Authorization/policyAssignments/{policyAssignmentName}"} # type: ignore - @distributed_trace + @overload def create( self, scope: str, policy_assignment_name: str, - parameters: "_models.PolicyAssignment", + parameters: _models.PolicyAssignment, + *, + content_type: str = "application/json", **kwargs: Any - ) -> "_models.PolicyAssignment": + ) -> _models.PolicyAssignment: """Creates or updates a policy assignment. This operation creates or updates a policy assignment with the given scope and name. Policy @@ -1187,26 +1011,109 @@ def create( '/subscriptions/{subscriptionId}'), resource group (format: '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}', or resource (format: '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{resourceProviderNamespace}/[{parentResourcePath}/]{resourceType}/{resourceName}'. + Required. :type scope: str - :param policy_assignment_name: The name of the policy assignment. + :param policy_assignment_name: The name of the policy assignment. Required. :type policy_assignment_name: str - :param parameters: Parameters for the policy assignment. + :param parameters: Parameters for the policy assignment. Required. :type parameters: ~azure.mgmt.resource.policy.v2019_09_01.models.PolicyAssignment + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: PolicyAssignment or the result of cls(response) + :rtype: ~azure.mgmt.resource.policy.v2019_09_01.models.PolicyAssignment + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + def create( + self, + scope: str, + policy_assignment_name: str, + parameters: IO, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.PolicyAssignment: + """Creates or updates a policy assignment. + + This operation creates or updates a policy assignment with the given scope and name. Policy + assignments apply to all resources contained within their scope. For example, when you assign a + policy at resource group scope, that policy applies to all resources in the group. + + :param scope: The scope of the policy assignment. Valid scopes are: management group (format: + '/providers/Microsoft.Management/managementGroups/{managementGroup}'), subscription (format: + '/subscriptions/{subscriptionId}'), resource group (format: + '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}', or resource (format: + '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{resourceProviderNamespace}/[{parentResourcePath}/]{resourceType}/{resourceName}'. + Required. + :type scope: str + :param policy_assignment_name: The name of the policy assignment. Required. + :type policy_assignment_name: str + :param parameters: Parameters for the policy assignment. Required. + :type parameters: IO + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: PolicyAssignment, or the result of cls(response) + :return: PolicyAssignment or the result of cls(response) :rtype: ~azure.mgmt.resource.policy.v2019_09_01.models.PolicyAssignment - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace + def create( + self, scope: str, policy_assignment_name: str, parameters: Union[_models.PolicyAssignment, IO], **kwargs: Any + ) -> _models.PolicyAssignment: + """Creates or updates a policy assignment. + + This operation creates or updates a policy assignment with the given scope and name. Policy + assignments apply to all resources contained within their scope. For example, when you assign a + policy at resource group scope, that policy applies to all resources in the group. + + :param scope: The scope of the policy assignment. Valid scopes are: management group (format: + '/providers/Microsoft.Management/managementGroups/{managementGroup}'), subscription (format: + '/subscriptions/{subscriptionId}'), resource group (format: + '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}', or resource (format: + '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{resourceProviderNamespace}/[{parentResourcePath}/]{resourceType}/{resourceName}'. + Required. + :type scope: str + :param policy_assignment_name: The name of the policy assignment. Required. + :type policy_assignment_name: str + :param parameters: Parameters for the policy assignment. Is either a model type or a IO type. + Required. + :type parameters: ~azure.mgmt.resource.policy.v2019_09_01.models.PolicyAssignment or IO + :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. + Default value is None. + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: PolicyAssignment or the result of cls(response) + :rtype: ~azure.mgmt.resource.policy.v2019_09_01.models.PolicyAssignment + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.PolicyAssignment"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', "2019-09-01") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + api_version = kwargs.pop("api_version", _params.pop("api-version", "2019-09-01")) # type: str + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.PolicyAssignment] - _json = self._serialize.body(parameters, 'PolicyAssignment') + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(parameters, (IO, bytes)): + _content = parameters + else: + _json = self._serialize.body(parameters, "PolicyAssignment") request = build_policy_assignments_create_request( scope=scope, @@ -1214,39 +1121,35 @@ def create( api_version=api_version, content_type=content_type, json=_json, - template_url=self.create.metadata['url'], + content=_content, + template_url=self.create.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [201]: map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) - deserialized = self._deserialize('PolicyAssignment', pipeline_response) + deserialized = self._deserialize("PolicyAssignment", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - create.metadata = {'url': "/{scope}/providers/Microsoft.Authorization/policyAssignments/{policyAssignmentName}"} # type: ignore - + create.metadata = {"url": "/{scope}/providers/Microsoft.Authorization/policyAssignments/{policyAssignmentName}"} # type: ignore @distributed_trace - def get( - self, - scope: str, - policy_assignment_name: str, - **kwargs: Any - ) -> "_models.PolicyAssignment": + def get(self, scope: str, policy_assignment_name: str, **kwargs: Any) -> _models.PolicyAssignment: """Retrieves a policy assignment. This operation retrieves a single policy assignment, given its name and the scope it was @@ -1257,60 +1160,63 @@ def get( '/subscriptions/{subscriptionId}'), resource group (format: '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}', or resource (format: '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{resourceProviderNamespace}/[{parentResourcePath}/]{resourceType}/{resourceName}'. + Required. :type scope: str - :param policy_assignment_name: The name of the policy assignment to get. + :param policy_assignment_name: The name of the policy assignment to get. Required. :type policy_assignment_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: PolicyAssignment, or the result of cls(response) + :return: PolicyAssignment or the result of cls(response) :rtype: ~azure.mgmt.resource.policy.v2019_09_01.models.PolicyAssignment - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.PolicyAssignment"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) - api_version = kwargs.pop('api_version', "2019-09-01") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2019-09-01")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[_models.PolicyAssignment] - request = build_policy_assignments_get_request( scope=scope, policy_assignment_name=policy_assignment_name, api_version=api_version, - template_url=self.get.metadata['url'], + template_url=self.get.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) - deserialized = self._deserialize('PolicyAssignment', pipeline_response) + deserialized = self._deserialize("PolicyAssignment", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - get.metadata = {'url': "/{scope}/providers/Microsoft.Authorization/policyAssignments/{policyAssignmentName}"} # type: ignore - + get.metadata = {"url": "/{scope}/providers/Microsoft.Authorization/policyAssignments/{policyAssignmentName}"} # type: ignore @distributed_trace def list_for_resource_group( - self, - resource_group_name: str, - filter: Optional[str] = None, - **kwargs: Any - ) -> Iterable["_models.PolicyAssignmentListResult"]: + self, resource_group_name: str, filter: Optional[str] = None, **kwargs: Any + ) -> Iterable["_models.PolicyAssignment"]: """Retrieves all policy assignments that apply to a resource group. This operation retrieves the list of all policy assignments associated with the given resource @@ -1325,47 +1231,55 @@ def list_for_resource_group( assignments of the policy definition whose id is {value} that apply to the resource group. :param resource_group_name: The name of the resource group that contains policy assignments. + Required. :type resource_group_name: str :param filter: The filter to apply on the operation. Valid values for $filter are: 'atScope()' or 'policyDefinitionId eq '{value}''. If $filter is not provided, no filtering is performed. Default value is None. :type filter: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either PolicyAssignmentListResult or the result of - cls(response) + :return: An iterator like instance of either PolicyAssignment or the result of cls(response) :rtype: - ~azure.core.paging.ItemPaged[~azure.mgmt.resource.policy.v2019_09_01.models.PolicyAssignmentListResult] - :raises: ~azure.core.exceptions.HttpResponseError + ~azure.core.paging.ItemPaged[~azure.mgmt.resource.policy.v2019_09_01.models.PolicyAssignment] + :raises ~azure.core.exceptions.HttpResponseError: """ - api_version = kwargs.pop('api_version', "2019-09-01") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2019-09-01")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[_models.PolicyAssignmentListResult] - cls = kwargs.pop('cls', None) # type: ClsType["_models.PolicyAssignmentListResult"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) + def prepare_request(next_link=None): if not next_link: - + request = build_policy_assignments_list_for_resource_group_request( resource_group_name=resource_group_name, subscription_id=self._config.subscription_id, - api_version=api_version, filter=filter, - template_url=self.list_for_resource_group.metadata['url'], + api_version=api_version, + template_url=self.list_for_resource_group.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore else: - - request = build_policy_assignments_list_for_resource_group_request( - resource_group_name=resource_group_name, - subscription_id=self._config.subscription_id, - template_url=next_link, - ) + # make call to next link with the client's api-version + _parsed_next_link = urlparse(next_link) + _next_request_params = case_insensitive_dict(parse_qs(_parsed_next_link.query)) + _next_request_params["api-version"] = self._config.api_version + request = HttpRequest("GET", urljoin(next_link, _parsed_next_link.path), params=_next_request_params) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore request.method = "GET" return request @@ -1379,10 +1293,8 @@ def extract_data(pipeline_response): def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) response = pipeline_response.http_response @@ -1392,11 +1304,9 @@ def get_next(next_link=None): return pipeline_response + return ItemPaged(get_next, extract_data) - return ItemPaged( - get_next, extract_data - ) - list_for_resource_group.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Authorization/policyAssignments"} # type: ignore + list_for_resource_group.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Authorization/policyAssignments"} # type: ignore @distributed_trace def list_for_resource( @@ -1408,7 +1318,7 @@ def list_for_resource( resource_name: str, filter: Optional[str] = None, **kwargs: Any - ) -> Iterable["_models.PolicyAssignmentListResult"]: + ) -> Iterable["_models.PolicyAssignment"]: """Retrieves all policy assignments that apply to a resource. This operation retrieves the list of all policy assignments associated with the specified @@ -1434,39 +1344,47 @@ def list_for_resource( {parentResourcePath} == '', {resourceType} == 'Microsoft.Web/sites', {resourceName} == 'MyWebApp'). - :param resource_group_name: The name of the resource group containing the resource. + :param resource_group_name: The name of the resource group containing the resource. Required. :type resource_group_name: str :param resource_provider_namespace: The namespace of the resource provider. For example, the namespace of a virtual machine is Microsoft.Compute (from Microsoft.Compute/virtualMachines). + Required. :type resource_provider_namespace: str :param parent_resource_path: The parent resource path. Use empty string if there is none. + Required. :type parent_resource_path: str :param resource_type: The resource type name. For example the type name of a web app is 'sites' - (from Microsoft.Web/sites). + (from Microsoft.Web/sites). Required. :type resource_type: str - :param resource_name: The name of the resource. + :param resource_name: The name of the resource. Required. :type resource_name: str :param filter: The filter to apply on the operation. Valid values for $filter are: 'atScope()' or 'policyDefinitionId eq '{value}''. If $filter is not provided, no filtering is performed. Default value is None. :type filter: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either PolicyAssignmentListResult or the result of - cls(response) + :return: An iterator like instance of either PolicyAssignment or the result of cls(response) :rtype: - ~azure.core.paging.ItemPaged[~azure.mgmt.resource.policy.v2019_09_01.models.PolicyAssignmentListResult] - :raises: ~azure.core.exceptions.HttpResponseError + ~azure.core.paging.ItemPaged[~azure.mgmt.resource.policy.v2019_09_01.models.PolicyAssignment] + :raises ~azure.core.exceptions.HttpResponseError: """ - api_version = kwargs.pop('api_version', "2019-09-01") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2019-09-01")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[_models.PolicyAssignmentListResult] - cls = kwargs.pop('cls', None) # type: ClsType["_models.PolicyAssignmentListResult"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) + def prepare_request(next_link=None): if not next_link: - + request = build_policy_assignments_list_for_resource_request( resource_group_name=resource_group_name, resource_provider_namespace=resource_provider_namespace, @@ -1474,26 +1392,23 @@ def prepare_request(next_link=None): resource_type=resource_type, resource_name=resource_name, subscription_id=self._config.subscription_id, - api_version=api_version, filter=filter, - template_url=self.list_for_resource.metadata['url'], + api_version=api_version, + template_url=self.list_for_resource.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore else: - - request = build_policy_assignments_list_for_resource_request( - resource_group_name=resource_group_name, - resource_provider_namespace=resource_provider_namespace, - parent_resource_path=parent_resource_path, - resource_type=resource_type, - resource_name=resource_name, - subscription_id=self._config.subscription_id, - template_url=next_link, - ) + # make call to next link with the client's api-version + _parsed_next_link = urlparse(next_link) + _next_request_params = case_insensitive_dict(parse_qs(_parsed_next_link.query)) + _next_request_params["api-version"] = self._config.api_version + request = HttpRequest("GET", urljoin(next_link, _parsed_next_link.path), params=_next_request_params) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore request.method = "GET" return request @@ -1507,10 +1422,8 @@ def extract_data(pipeline_response): def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) response = pipeline_response.http_response @@ -1520,19 +1433,14 @@ def get_next(next_link=None): return pipeline_response + return ItemPaged(get_next, extract_data) - return ItemPaged( - get_next, extract_data - ) - list_for_resource.metadata = {'url': "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{parentResourcePath}/{resourceType}/{resourceName}/providers/Microsoft.Authorization/policyAssignments"} # type: ignore + list_for_resource.metadata = {"url": "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{parentResourcePath}/{resourceType}/{resourceName}/providers/Microsoft.Authorization/policyAssignments"} # type: ignore @distributed_trace def list_for_management_group( - self, - management_group_id: str, - filter: str, - **kwargs: Any - ) -> Iterable["_models.PolicyAssignmentListResult"]: + self, management_group_id: str, filter: str, **kwargs: Any + ) -> Iterable["_models.PolicyAssignment"]: """Retrieves all policy assignments that apply to a management group. This operation retrieves the list of all policy assignments applicable to the management group @@ -1542,46 +1450,54 @@ def list_for_management_group( $filter=policyDefinitionId eq '{value}' is provided, the returned list includes all policy assignments of the policy definition whose id is {value} that apply to the management group. - :param management_group_id: The ID of the management group. + :param management_group_id: The ID of the management group. Required. :type management_group_id: str :param filter: The filter to apply on the operation. Valid values for $filter are: 'atScope()' or 'policyDefinitionId eq '{value}''. A filter is required when listing policy assignments at - management group scope. + management group scope. Required. :type filter: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either PolicyAssignmentListResult or the result of - cls(response) + :return: An iterator like instance of either PolicyAssignment or the result of cls(response) :rtype: - ~azure.core.paging.ItemPaged[~azure.mgmt.resource.policy.v2019_09_01.models.PolicyAssignmentListResult] - :raises: ~azure.core.exceptions.HttpResponseError + ~azure.core.paging.ItemPaged[~azure.mgmt.resource.policy.v2019_09_01.models.PolicyAssignment] + :raises ~azure.core.exceptions.HttpResponseError: """ - api_version = kwargs.pop('api_version', "2019-09-01") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2019-09-01")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[_models.PolicyAssignmentListResult] - cls = kwargs.pop('cls', None) # type: ClsType["_models.PolicyAssignmentListResult"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) + def prepare_request(next_link=None): if not next_link: - + request = build_policy_assignments_list_for_management_group_request( management_group_id=management_group_id, - api_version=api_version, filter=filter, - template_url=self.list_for_management_group.metadata['url'], + api_version=api_version, + template_url=self.list_for_management_group.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore else: - - request = build_policy_assignments_list_for_management_group_request( - management_group_id=management_group_id, - template_url=next_link, - ) + # make call to next link with the client's api-version + _parsed_next_link = urlparse(next_link) + _next_request_params = case_insensitive_dict(parse_qs(_parsed_next_link.query)) + _next_request_params["api-version"] = self._config.api_version + request = HttpRequest("GET", urljoin(next_link, _parsed_next_link.path), params=_next_request_params) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore request.method = "GET" return request @@ -1595,10 +1511,8 @@ def extract_data(pipeline_response): def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) response = pipeline_response.http_response @@ -1608,18 +1522,12 @@ def get_next(next_link=None): return pipeline_response + return ItemPaged(get_next, extract_data) - return ItemPaged( - get_next, extract_data - ) - list_for_management_group.metadata = {'url': "/providers/Microsoft.Management/managementgroups/{managementGroupId}/providers/Microsoft.Authorization/policyAssignments"} # type: ignore + list_for_management_group.metadata = {"url": "/providers/Microsoft.Management/managementgroups/{managementGroupId}/providers/Microsoft.Authorization/policyAssignments"} # type: ignore @distributed_trace - def list( - self, - filter: Optional[str] = None, - **kwargs: Any - ) -> Iterable["_models.PolicyAssignmentListResult"]: + def list(self, filter: Optional[str] = None, **kwargs: Any) -> Iterable["_models.PolicyAssignment"]: """Retrieves all policy assignments that apply to a subscription. This operation retrieves the list of all policy assignments associated with the given @@ -1638,39 +1546,47 @@ def list( Default value is None. :type filter: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either PolicyAssignmentListResult or the result of - cls(response) + :return: An iterator like instance of either PolicyAssignment or the result of cls(response) :rtype: - ~azure.core.paging.ItemPaged[~azure.mgmt.resource.policy.v2019_09_01.models.PolicyAssignmentListResult] - :raises: ~azure.core.exceptions.HttpResponseError + ~azure.core.paging.ItemPaged[~azure.mgmt.resource.policy.v2019_09_01.models.PolicyAssignment] + :raises ~azure.core.exceptions.HttpResponseError: """ - api_version = kwargs.pop('api_version', "2019-09-01") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2019-09-01")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[_models.PolicyAssignmentListResult] - cls = kwargs.pop('cls', None) # type: ClsType["_models.PolicyAssignmentListResult"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) + def prepare_request(next_link=None): if not next_link: - + request = build_policy_assignments_list_request( subscription_id=self._config.subscription_id, - api_version=api_version, filter=filter, - template_url=self.list.metadata['url'], + 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.url = self._client.format_url(request.url) # type: ignore else: - - request = build_policy_assignments_list_request( - subscription_id=self._config.subscription_id, - template_url=next_link, - ) + # make call to next link with the client's api-version + _parsed_next_link = urlparse(next_link) + _next_request_params = case_insensitive_dict(parse_qs(_parsed_next_link.query)) + _next_request_params["api-version"] = self._config.api_version + request = HttpRequest("GET", urljoin(next_link, _parsed_next_link.path), params=_next_request_params) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore request.method = "GET" return request @@ -1684,10 +1600,8 @@ def extract_data(pipeline_response): def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) response = pipeline_response.http_response @@ -1697,18 +1611,12 @@ def get_next(next_link=None): return pipeline_response + return ItemPaged(get_next, extract_data) - return ItemPaged( - get_next, extract_data - ) - list.metadata = {'url': "/subscriptions/{subscriptionId}/providers/Microsoft.Authorization/policyAssignments"} # type: ignore + list.metadata = {"url": "/subscriptions/{subscriptionId}/providers/Microsoft.Authorization/policyAssignments"} # type: ignore @distributed_trace - def delete_by_id( - self, - policy_assignment_id: str, - **kwargs: Any - ) -> Optional["_models.PolicyAssignment"]: + def delete_by_id(self, policy_assignment_id: str, **kwargs: Any) -> Optional[_models.PolicyAssignment]: """Deletes a policy assignment. This operation deletes the policy with the given ID. Policy assignment IDs have this format: @@ -1720,35 +1628,41 @@ def delete_by_id( (resource). :param policy_assignment_id: The ID of the policy assignment to delete. Use the format - '{scope}/providers/Microsoft.Authorization/policyAssignments/{policyAssignmentName}'. + '{scope}/providers/Microsoft.Authorization/policyAssignments/{policyAssignmentName}'. Required. :type policy_assignment_id: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: PolicyAssignment, or the result of cls(response) + :return: PolicyAssignment or None or the result of cls(response) :rtype: ~azure.mgmt.resource.policy.v2019_09_01.models.PolicyAssignment or None - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType[Optional["_models.PolicyAssignment"]] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + 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', "2019-09-01") # type: str + api_version = kwargs.pop("api_version", _params.pop("api-version", "2019-09-01")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[Optional[_models.PolicyAssignment]] - request = build_policy_assignments_delete_by_id_request( policy_assignment_id=policy_assignment_id, api_version=api_version, - template_url=self.delete_by_id.metadata['url'], + template_url=self.delete_by_id.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200, 204]: @@ -1757,23 +1671,24 @@ def delete_by_id( deserialized = None if response.status_code == 200: - deserialized = self._deserialize('PolicyAssignment', pipeline_response) + deserialized = self._deserialize("PolicyAssignment", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - delete_by_id.metadata = {'url': "/{policyAssignmentId}"} # type: ignore - + delete_by_id.metadata = {"url": "/{policyAssignmentId}"} # type: ignore - @distributed_trace + @overload def create_by_id( self, policy_assignment_id: str, - parameters: "_models.PolicyAssignment", + parameters: _models.PolicyAssignment, + *, + content_type: str = "application/json", **kwargs: Any - ) -> "_models.PolicyAssignment": + ) -> _models.PolicyAssignment: """Creates or updates a policy assignment. This operation creates or updates the policy assignment with the given ID. Policy assignments @@ -1788,63 +1703,138 @@ def create_by_id( '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{resourceProviderNamespace}/[{parentResourcePath}/]{resourceType}/{resourceName}'. :param policy_assignment_id: The ID of the policy assignment to create. Use the format - '{scope}/providers/Microsoft.Authorization/policyAssignments/{policyAssignmentName}'. + '{scope}/providers/Microsoft.Authorization/policyAssignments/{policyAssignmentName}'. Required. :type policy_assignment_id: str - :param parameters: Parameters for policy assignment. + :param parameters: Parameters for policy assignment. Required. :type parameters: ~azure.mgmt.resource.policy.v2019_09_01.models.PolicyAssignment + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: PolicyAssignment, or the result of cls(response) + :return: PolicyAssignment or the result of cls(response) :rtype: ~azure.mgmt.resource.policy.v2019_09_01.models.PolicyAssignment - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + def create_by_id( + self, policy_assignment_id: str, parameters: IO, *, content_type: str = "application/json", **kwargs: Any + ) -> _models.PolicyAssignment: + """Creates or updates a policy assignment. + + This operation creates or updates the policy assignment with the given ID. Policy assignments + made on a scope apply to all resources contained in that scope. For example, when you assign a + policy to a resource group that policy applies to all resources in the group. Policy assignment + IDs have this format: + '{scope}/providers/Microsoft.Authorization/policyAssignments/{policyAssignmentName}'. Valid + scopes are: management group (format: + '/providers/Microsoft.Management/managementGroups/{managementGroup}'), subscription (format: + '/subscriptions/{subscriptionId}'), resource group (format: + '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}', or resource (format: + '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{resourceProviderNamespace}/[{parentResourcePath}/]{resourceType}/{resourceName}'. + + :param policy_assignment_id: The ID of the policy assignment to create. Use the format + '{scope}/providers/Microsoft.Authorization/policyAssignments/{policyAssignmentName}'. Required. + :type policy_assignment_id: str + :param parameters: Parameters for policy assignment. Required. + :type parameters: IO + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: PolicyAssignment or the result of cls(response) + :rtype: ~azure.mgmt.resource.policy.v2019_09_01.models.PolicyAssignment + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace + def create_by_id( + self, policy_assignment_id: str, parameters: Union[_models.PolicyAssignment, IO], **kwargs: Any + ) -> _models.PolicyAssignment: + """Creates or updates a policy assignment. + + This operation creates or updates the policy assignment with the given ID. Policy assignments + made on a scope apply to all resources contained in that scope. For example, when you assign a + policy to a resource group that policy applies to all resources in the group. Policy assignment + IDs have this format: + '{scope}/providers/Microsoft.Authorization/policyAssignments/{policyAssignmentName}'. Valid + scopes are: management group (format: + '/providers/Microsoft.Management/managementGroups/{managementGroup}'), subscription (format: + '/subscriptions/{subscriptionId}'), resource group (format: + '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}', or resource (format: + '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{resourceProviderNamespace}/[{parentResourcePath}/]{resourceType}/{resourceName}'. + + :param policy_assignment_id: The ID of the policy assignment to create. Use the format + '{scope}/providers/Microsoft.Authorization/policyAssignments/{policyAssignmentName}'. Required. + :type policy_assignment_id: str + :param parameters: Parameters for policy assignment. Is either a model type or a IO type. + Required. + :type parameters: ~azure.mgmt.resource.policy.v2019_09_01.models.PolicyAssignment or IO + :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. + Default value is None. + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: PolicyAssignment or the result of cls(response) + :rtype: ~azure.mgmt.resource.policy.v2019_09_01.models.PolicyAssignment + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.PolicyAssignment"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', "2019-09-01") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + api_version = kwargs.pop("api_version", _params.pop("api-version", "2019-09-01")) # type: str + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.PolicyAssignment] - _json = self._serialize.body(parameters, 'PolicyAssignment') + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(parameters, (IO, bytes)): + _content = parameters + else: + _json = self._serialize.body(parameters, "PolicyAssignment") request = build_policy_assignments_create_by_id_request( policy_assignment_id=policy_assignment_id, api_version=api_version, content_type=content_type, json=_json, - template_url=self.create_by_id.metadata['url'], + content=_content, + template_url=self.create_by_id.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [201]: map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) - deserialized = self._deserialize('PolicyAssignment', pipeline_response) + deserialized = self._deserialize("PolicyAssignment", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - create_by_id.metadata = {'url': "/{policyAssignmentId}"} # type: ignore - + create_by_id.metadata = {"url": "/{policyAssignmentId}"} # type: ignore @distributed_trace - def get_by_id( - self, - policy_assignment_id: str, - **kwargs: Any - ) -> "_models.PolicyAssignment": + def get_by_id(self, policy_assignment_id: str, **kwargs: Any) -> _models.PolicyAssignment: """Retrieves the policy assignment with the given ID. The operation retrieves the policy assignment with the given ID. Policy assignment IDs have @@ -1857,103 +1847,169 @@ def get_by_id( '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{resourceProviderNamespace}/[{parentResourcePath}/]{resourceType}/{resourceName}'. :param policy_assignment_id: The ID of the policy assignment to get. Use the format - '{scope}/providers/Microsoft.Authorization/policyAssignments/{policyAssignmentName}'. + '{scope}/providers/Microsoft.Authorization/policyAssignments/{policyAssignmentName}'. Required. :type policy_assignment_id: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: PolicyAssignment, or the result of cls(response) + :return: PolicyAssignment or the result of cls(response) :rtype: ~azure.mgmt.resource.policy.v2019_09_01.models.PolicyAssignment - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.PolicyAssignment"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) - api_version = kwargs.pop('api_version', "2019-09-01") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2019-09-01")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[_models.PolicyAssignment] - request = build_policy_assignments_get_by_id_request( policy_assignment_id=policy_assignment_id, api_version=api_version, - template_url=self.get_by_id.metadata['url'], + template_url=self.get_by_id.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) - deserialized = self._deserialize('PolicyAssignment', pipeline_response) + deserialized = self._deserialize("PolicyAssignment", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - get_by_id.metadata = {'url': "/{policyAssignmentId}"} # type: ignore + get_by_id.metadata = {"url": "/{policyAssignmentId}"} # type: ignore -class PolicyDefinitionsOperations(object): - """PolicyDefinitionsOperations operations. - You should not instantiate this class directly. Instead, you should create a Client instance that - instantiates it for you and attaches it as an attribute. +class PolicyDefinitionsOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. - :ivar models: Alias to model classes used in this operation group. - :type models: ~azure.mgmt.resource.policy.v2019_09_01.models - :param client: Client for service requests. - :param config: Configuration of service client. - :param serializer: An object model serializer. - :param deserializer: An object model deserializer. + Instead, you should access the following operations through + :class:`~azure.mgmt.resource.policy.v2019_09_01.PolicyClient`'s + :attr:`policy_definitions` attribute. """ models = _models - def __init__(self, client, config, serializer, deserializer): - self._client = client - self._serialize = serializer - self._deserialize = deserializer - self._config = config + def __init__(self, *args, **kwargs): + input_args = list(args) + self._client = input_args.pop(0) if input_args else kwargs.pop("client") + self._config = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") - @distributed_trace + @overload def create_or_update( self, policy_definition_name: str, - parameters: "_models.PolicyDefinition", + parameters: _models.PolicyDefinition, + *, + content_type: str = "application/json", **kwargs: Any - ) -> "_models.PolicyDefinition": + ) -> _models.PolicyDefinition: """Creates or updates a policy definition in a subscription. This operation creates or updates a policy definition in the given subscription with the given name. - :param policy_definition_name: The name of the policy definition to create. + :param policy_definition_name: The name of the policy definition to create. Required. :type policy_definition_name: str - :param parameters: The policy definition properties. + :param parameters: The policy definition properties. Required. :type parameters: ~azure.mgmt.resource.policy.v2019_09_01.models.PolicyDefinition + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: PolicyDefinition or the result of cls(response) + :rtype: ~azure.mgmt.resource.policy.v2019_09_01.models.PolicyDefinition + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + def create_or_update( + self, policy_definition_name: str, parameters: IO, *, content_type: str = "application/json", **kwargs: Any + ) -> _models.PolicyDefinition: + """Creates or updates a policy definition in a subscription. + + This operation creates or updates a policy definition in the given subscription with the given + name. + + :param policy_definition_name: The name of the policy definition to create. Required. + :type policy_definition_name: str + :param parameters: The policy definition properties. Required. + :type parameters: IO + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: PolicyDefinition or the result of cls(response) + :rtype: ~azure.mgmt.resource.policy.v2019_09_01.models.PolicyDefinition + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace + def create_or_update( + self, policy_definition_name: str, parameters: Union[_models.PolicyDefinition, IO], **kwargs: Any + ) -> _models.PolicyDefinition: + """Creates or updates a policy definition in a subscription. + + This operation creates or updates a policy definition in the given subscription with the given + name. + + :param policy_definition_name: The name of the policy definition to create. Required. + :type policy_definition_name: str + :param parameters: The policy definition properties. Is either a model type or a IO type. + Required. + :type parameters: ~azure.mgmt.resource.policy.v2019_09_01.models.PolicyDefinition or IO + :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. + Default value is None. + :paramtype content_type: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: PolicyDefinition, or the result of cls(response) + :return: PolicyDefinition or the result of cls(response) :rtype: ~azure.mgmt.resource.policy.v2019_09_01.models.PolicyDefinition - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.PolicyDefinition"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) - api_version = kwargs.pop('api_version', "2019-09-01") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - _json = self._serialize.body(parameters, 'PolicyDefinition') + api_version = kwargs.pop("api_version", _params.pop("api-version", "2019-09-01")) # type: str + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.PolicyDefinition] + + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(parameters, (IO, bytes)): + _content = parameters + else: + _json = self._serialize.body(parameters, "PolicyDefinition") request = build_policy_definitions_create_or_update_request( policy_definition_name=policy_definition_name, @@ -1961,72 +2017,77 @@ def create_or_update( api_version=api_version, content_type=content_type, json=_json, - template_url=self.create_or_update.metadata['url'], + content=_content, + template_url=self.create_or_update.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [201]: map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) - deserialized = self._deserialize('PolicyDefinition', pipeline_response) + deserialized = self._deserialize("PolicyDefinition", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - create_or_update.metadata = {'url': "/subscriptions/{subscriptionId}/providers/Microsoft.Authorization/policyDefinitions/{policyDefinitionName}"} # type: ignore - + create_or_update.metadata = {"url": "/subscriptions/{subscriptionId}/providers/Microsoft.Authorization/policyDefinitions/{policyDefinitionName}"} # type: ignore @distributed_trace def delete( # pylint: disable=inconsistent-return-statements - self, - policy_definition_name: str, - **kwargs: Any + self, policy_definition_name: str, **kwargs: Any ) -> None: """Deletes a policy definition in a subscription. This operation deletes the policy definition in the given subscription with the given name. - :param policy_definition_name: The name of the policy definition to delete. + :param policy_definition_name: The name of the policy definition to delete. Required. :type policy_definition_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: None, or the result of cls(response) + :return: None or the result of cls(response) :rtype: None - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType[None] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) - api_version = kwargs.pop('api_version', "2019-09-01") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2019-09-01")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[None] - request = build_policy_definitions_delete_request( policy_definition_name=policy_definition_name, subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.delete.metadata['url'], + template_url=self.delete.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200, 204]: @@ -2036,154 +2097,231 @@ def delete( # pylint: disable=inconsistent-return-statements if cls: return cls(pipeline_response, None, {}) - delete.metadata = {'url': "/subscriptions/{subscriptionId}/providers/Microsoft.Authorization/policyDefinitions/{policyDefinitionName}"} # type: ignore - + delete.metadata = {"url": "/subscriptions/{subscriptionId}/providers/Microsoft.Authorization/policyDefinitions/{policyDefinitionName}"} # type: ignore @distributed_trace - def get( - self, - policy_definition_name: str, - **kwargs: Any - ) -> "_models.PolicyDefinition": + def get(self, policy_definition_name: str, **kwargs: Any) -> _models.PolicyDefinition: """Retrieves a policy definition in a subscription. This operation retrieves the policy definition in the given subscription with the given name. - :param policy_definition_name: The name of the policy definition to get. + :param policy_definition_name: The name of the policy definition to get. Required. :type policy_definition_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: PolicyDefinition, or the result of cls(response) + :return: PolicyDefinition or the result of cls(response) :rtype: ~azure.mgmt.resource.policy.v2019_09_01.models.PolicyDefinition - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.PolicyDefinition"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) - api_version = kwargs.pop('api_version', "2019-09-01") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2019-09-01")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[_models.PolicyDefinition] - request = build_policy_definitions_get_request( policy_definition_name=policy_definition_name, subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.get.metadata['url'], + template_url=self.get.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) - deserialized = self._deserialize('PolicyDefinition', pipeline_response) + deserialized = self._deserialize("PolicyDefinition", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - get.metadata = {'url': "/subscriptions/{subscriptionId}/providers/Microsoft.Authorization/policyDefinitions/{policyDefinitionName}"} # type: ignore - + get.metadata = {"url": "/subscriptions/{subscriptionId}/providers/Microsoft.Authorization/policyDefinitions/{policyDefinitionName}"} # type: ignore @distributed_trace - def get_built_in( - self, - policy_definition_name: str, - **kwargs: Any - ) -> "_models.PolicyDefinition": + def get_built_in(self, policy_definition_name: str, **kwargs: Any) -> _models.PolicyDefinition: """Retrieves a built-in policy definition. This operation retrieves the built-in policy definition with the given name. - :param policy_definition_name: The name of the built-in policy definition to get. + :param policy_definition_name: The name of the built-in policy definition to get. Required. :type policy_definition_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: PolicyDefinition, or the result of cls(response) + :return: PolicyDefinition or the result of cls(response) :rtype: ~azure.mgmt.resource.policy.v2019_09_01.models.PolicyDefinition - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.PolicyDefinition"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) - api_version = kwargs.pop('api_version', "2019-09-01") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2019-09-01")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[_models.PolicyDefinition] - request = build_policy_definitions_get_built_in_request( policy_definition_name=policy_definition_name, api_version=api_version, - template_url=self.get_built_in.metadata['url'], + template_url=self.get_built_in.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) - deserialized = self._deserialize('PolicyDefinition', pipeline_response) + deserialized = self._deserialize("PolicyDefinition", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - get_built_in.metadata = {'url': "/providers/Microsoft.Authorization/policyDefinitions/{policyDefinitionName}"} # type: ignore + get_built_in.metadata = {"url": "/providers/Microsoft.Authorization/policyDefinitions/{policyDefinitionName}"} # type: ignore + + @overload + def create_or_update_at_management_group( + self, + policy_definition_name: str, + management_group_id: str, + parameters: _models.PolicyDefinition, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.PolicyDefinition: + """Creates or updates a policy definition in a management group. + + This operation creates or updates a policy definition in the given management group with the + given name. + + :param policy_definition_name: The name of the policy definition to create. Required. + :type policy_definition_name: str + :param management_group_id: The ID of the management group. Required. + :type management_group_id: str + :param parameters: The policy definition properties. Required. + :type parameters: ~azure.mgmt.resource.policy.v2019_09_01.models.PolicyDefinition + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: PolicyDefinition or the result of cls(response) + :rtype: ~azure.mgmt.resource.policy.v2019_09_01.models.PolicyDefinition + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + def create_or_update_at_management_group( + self, + policy_definition_name: str, + management_group_id: str, + parameters: IO, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.PolicyDefinition: + """Creates or updates a policy definition in a management group. + + This operation creates or updates a policy definition in the given management group with the + given name. + :param policy_definition_name: The name of the policy definition to create. Required. + :type policy_definition_name: str + :param management_group_id: The ID of the management group. Required. + :type management_group_id: str + :param parameters: The policy definition properties. Required. + :type parameters: IO + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: PolicyDefinition or the result of cls(response) + :rtype: ~azure.mgmt.resource.policy.v2019_09_01.models.PolicyDefinition + :raises ~azure.core.exceptions.HttpResponseError: + """ @distributed_trace def create_or_update_at_management_group( self, policy_definition_name: str, management_group_id: str, - parameters: "_models.PolicyDefinition", + parameters: Union[_models.PolicyDefinition, IO], **kwargs: Any - ) -> "_models.PolicyDefinition": + ) -> _models.PolicyDefinition: """Creates or updates a policy definition in a management group. This operation creates or updates a policy definition in the given management group with the given name. - :param policy_definition_name: The name of the policy definition to create. + :param policy_definition_name: The name of the policy definition to create. Required. :type policy_definition_name: str - :param management_group_id: The ID of the management group. + :param management_group_id: The ID of the management group. Required. :type management_group_id: str - :param parameters: The policy definition properties. - :type parameters: ~azure.mgmt.resource.policy.v2019_09_01.models.PolicyDefinition + :param parameters: The policy definition properties. Is either a model type or a IO type. + Required. + :type parameters: ~azure.mgmt.resource.policy.v2019_09_01.models.PolicyDefinition or IO + :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. + Default value is None. + :paramtype content_type: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: PolicyDefinition, or the result of cls(response) + :return: PolicyDefinition or the result of cls(response) :rtype: ~azure.mgmt.resource.policy.v2019_09_01.models.PolicyDefinition - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.PolicyDefinition"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) - api_version = kwargs.pop('api_version', "2019-09-01") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - _json = self._serialize.body(parameters, 'PolicyDefinition') + api_version = kwargs.pop("api_version", _params.pop("api-version", "2019-09-01")) # type: str + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.PolicyDefinition] + + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(parameters, (IO, bytes)): + _content = parameters + else: + _json = self._serialize.body(parameters, "PolicyDefinition") request = build_policy_definitions_create_or_update_at_management_group_request( policy_definition_name=policy_definition_name, @@ -2191,75 +2329,79 @@ def create_or_update_at_management_group( api_version=api_version, content_type=content_type, json=_json, - template_url=self.create_or_update_at_management_group.metadata['url'], + content=_content, + template_url=self.create_or_update_at_management_group.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [201]: map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) - deserialized = self._deserialize('PolicyDefinition', pipeline_response) + deserialized = self._deserialize("PolicyDefinition", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - create_or_update_at_management_group.metadata = {'url': "/providers/Microsoft.Management/managementgroups/{managementGroupId}/providers/Microsoft.Authorization/policyDefinitions/{policyDefinitionName}"} # type: ignore - + create_or_update_at_management_group.metadata = {"url": "/providers/Microsoft.Management/managementgroups/{managementGroupId}/providers/Microsoft.Authorization/policyDefinitions/{policyDefinitionName}"} # type: ignore @distributed_trace def delete_at_management_group( # pylint: disable=inconsistent-return-statements - self, - policy_definition_name: str, - management_group_id: str, - **kwargs: Any + self, policy_definition_name: str, management_group_id: str, **kwargs: Any ) -> None: """Deletes a policy definition in a management group. This operation deletes the policy definition in the given management group with the given name. - :param policy_definition_name: The name of the policy definition to delete. + :param policy_definition_name: The name of the policy definition to delete. Required. :type policy_definition_name: str - :param management_group_id: The ID of the management group. + :param management_group_id: The ID of the management group. Required. :type management_group_id: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: None, or the result of cls(response) + :return: None or the result of cls(response) :rtype: None - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType[None] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + 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', "2019-09-01") # type: str + api_version = kwargs.pop("api_version", _params.pop("api-version", "2019-09-01")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[None] - request = build_policy_definitions_delete_at_management_group_request( policy_definition_name=policy_definition_name, management_group_id=management_group_id, api_version=api_version, - template_url=self.delete_at_management_group.metadata['url'], + template_url=self.delete_at_management_group.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200, 204]: @@ -2269,111 +2411,117 @@ def delete_at_management_group( # pylint: disable=inconsistent-return-statement if cls: return cls(pipeline_response, None, {}) - delete_at_management_group.metadata = {'url': "/providers/Microsoft.Management/managementgroups/{managementGroupId}/providers/Microsoft.Authorization/policyDefinitions/{policyDefinitionName}"} # type: ignore - + delete_at_management_group.metadata = {"url": "/providers/Microsoft.Management/managementgroups/{managementGroupId}/providers/Microsoft.Authorization/policyDefinitions/{policyDefinitionName}"} # type: ignore @distributed_trace def get_at_management_group( - self, - policy_definition_name: str, - management_group_id: str, - **kwargs: Any - ) -> "_models.PolicyDefinition": + self, policy_definition_name: str, management_group_id: str, **kwargs: Any + ) -> _models.PolicyDefinition: """Retrieve a policy definition in a management group. This operation retrieves the policy definition in the given management group with the given name. - :param policy_definition_name: The name of the policy definition to get. + :param policy_definition_name: The name of the policy definition to get. Required. :type policy_definition_name: str - :param management_group_id: The ID of the management group. + :param management_group_id: The ID of the management group. Required. :type management_group_id: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: PolicyDefinition, or the result of cls(response) + :return: PolicyDefinition or the result of cls(response) :rtype: ~azure.mgmt.resource.policy.v2019_09_01.models.PolicyDefinition - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.PolicyDefinition"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) - api_version = kwargs.pop('api_version', "2019-09-01") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2019-09-01")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[_models.PolicyDefinition] - request = build_policy_definitions_get_at_management_group_request( policy_definition_name=policy_definition_name, management_group_id=management_group_id, api_version=api_version, - template_url=self.get_at_management_group.metadata['url'], + template_url=self.get_at_management_group.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) - deserialized = self._deserialize('PolicyDefinition', pipeline_response) + deserialized = self._deserialize("PolicyDefinition", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - get_at_management_group.metadata = {'url': "/providers/Microsoft.Management/managementgroups/{managementGroupId}/providers/Microsoft.Authorization/policyDefinitions/{policyDefinitionName}"} # type: ignore - + get_at_management_group.metadata = {"url": "/providers/Microsoft.Management/managementgroups/{managementGroupId}/providers/Microsoft.Authorization/policyDefinitions/{policyDefinitionName}"} # type: ignore @distributed_trace - def list( - self, - **kwargs: Any - ) -> Iterable["_models.PolicyDefinitionListResult"]: + def list(self, **kwargs: Any) -> Iterable["_models.PolicyDefinition"]: """Retrieves policy definitions in a subscription. This operation retrieves a list of all the policy definitions in a given subscription. :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either PolicyDefinitionListResult or the result of - cls(response) + :return: An iterator like instance of either PolicyDefinition or the result of cls(response) :rtype: - ~azure.core.paging.ItemPaged[~azure.mgmt.resource.policy.v2019_09_01.models.PolicyDefinitionListResult] - :raises: ~azure.core.exceptions.HttpResponseError + ~azure.core.paging.ItemPaged[~azure.mgmt.resource.policy.v2019_09_01.models.PolicyDefinition] + :raises ~azure.core.exceptions.HttpResponseError: """ - api_version = kwargs.pop('api_version', "2019-09-01") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2019-09-01")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[_models.PolicyDefinitionListResult] - cls = kwargs.pop('cls', None) # type: ClsType["_models.PolicyDefinitionListResult"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) + def prepare_request(next_link=None): if not next_link: - + request = build_policy_definitions_list_request( subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.list.metadata['url'], + template_url=self.list.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore else: - - request = build_policy_definitions_list_request( - subscription_id=self._config.subscription_id, - template_url=next_link, - ) + # make call to next link with the client's api-version + _parsed_next_link = urlparse(next_link) + _next_request_params = case_insensitive_dict(parse_qs(_parsed_next_link.query)) + _next_request_params["api-version"] = self._config.api_version + request = HttpRequest("GET", urljoin(next_link, _parsed_next_link.path), params=_next_request_params) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore request.method = "GET" return request @@ -2387,10 +2535,8 @@ def extract_data(pipeline_response): def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) response = pipeline_response.http_response @@ -2400,52 +2546,56 @@ def get_next(next_link=None): return pipeline_response + return ItemPaged(get_next, extract_data) - return ItemPaged( - get_next, extract_data - ) - list.metadata = {'url': "/subscriptions/{subscriptionId}/providers/Microsoft.Authorization/policyDefinitions"} # type: ignore + list.metadata = {"url": "/subscriptions/{subscriptionId}/providers/Microsoft.Authorization/policyDefinitions"} # type: ignore @distributed_trace - def list_built_in( - self, - **kwargs: Any - ) -> Iterable["_models.PolicyDefinitionListResult"]: + def list_built_in(self, **kwargs: Any) -> Iterable["_models.PolicyDefinition"]: """Retrieve built-in policy definitions. This operation retrieves a list of all the built-in policy definitions. :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either PolicyDefinitionListResult or the result of - cls(response) + :return: An iterator like instance of either PolicyDefinition or the result of cls(response) :rtype: - ~azure.core.paging.ItemPaged[~azure.mgmt.resource.policy.v2019_09_01.models.PolicyDefinitionListResult] - :raises: ~azure.core.exceptions.HttpResponseError + ~azure.core.paging.ItemPaged[~azure.mgmt.resource.policy.v2019_09_01.models.PolicyDefinition] + :raises ~azure.core.exceptions.HttpResponseError: """ - api_version = kwargs.pop('api_version', "2019-09-01") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2019-09-01")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[_models.PolicyDefinitionListResult] - cls = kwargs.pop('cls', None) # type: ClsType["_models.PolicyDefinitionListResult"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) + def prepare_request(next_link=None): if not next_link: - + request = build_policy_definitions_list_built_in_request( api_version=api_version, - template_url=self.list_built_in.metadata['url'], + template_url=self.list_built_in.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore else: - - request = build_policy_definitions_list_built_in_request( - template_url=next_link, - ) + # make call to next link with the client's api-version + _parsed_next_link = urlparse(next_link) + _next_request_params = case_insensitive_dict(parse_qs(_parsed_next_link.query)) + _next_request_params["api-version"] = self._config.api_version + request = HttpRequest("GET", urljoin(next_link, _parsed_next_link.path), params=_next_request_params) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore request.method = "GET" return request @@ -2459,10 +2609,8 @@ def extract_data(pipeline_response): def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) response = pipeline_response.http_response @@ -2472,57 +2620,59 @@ def get_next(next_link=None): return pipeline_response + return ItemPaged(get_next, extract_data) - return ItemPaged( - get_next, extract_data - ) - list_built_in.metadata = {'url': "/providers/Microsoft.Authorization/policyDefinitions"} # type: ignore + list_built_in.metadata = {"url": "/providers/Microsoft.Authorization/policyDefinitions"} # type: ignore @distributed_trace - def list_by_management_group( - self, - management_group_id: str, - **kwargs: Any - ) -> Iterable["_models.PolicyDefinitionListResult"]: + def list_by_management_group(self, management_group_id: str, **kwargs: Any) -> Iterable["_models.PolicyDefinition"]: """Retrieve policy definitions in a management group. This operation retrieves a list of all the policy definitions in a given management group. - :param management_group_id: The ID of the management group. + :param management_group_id: The ID of the management group. Required. :type management_group_id: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either PolicyDefinitionListResult or the result of - cls(response) + :return: An iterator like instance of either PolicyDefinition or the result of cls(response) :rtype: - ~azure.core.paging.ItemPaged[~azure.mgmt.resource.policy.v2019_09_01.models.PolicyDefinitionListResult] - :raises: ~azure.core.exceptions.HttpResponseError + ~azure.core.paging.ItemPaged[~azure.mgmt.resource.policy.v2019_09_01.models.PolicyDefinition] + :raises ~azure.core.exceptions.HttpResponseError: """ - api_version = kwargs.pop('api_version', "2019-09-01") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2019-09-01")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[_models.PolicyDefinitionListResult] - cls = kwargs.pop('cls', None) # type: ClsType["_models.PolicyDefinitionListResult"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) + def prepare_request(next_link=None): if not next_link: - + request = build_policy_definitions_list_by_management_group_request( management_group_id=management_group_id, api_version=api_version, - template_url=self.list_by_management_group.metadata['url'], + template_url=self.list_by_management_group.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore else: - - request = build_policy_definitions_list_by_management_group_request( - management_group_id=management_group_id, - template_url=next_link, - ) + # make call to next link with the client's api-version + _parsed_next_link = urlparse(next_link) + _next_request_params = case_insensitive_dict(parse_qs(_parsed_next_link.query)) + _next_request_params["api-version"] = self._config.api_version + request = HttpRequest("GET", urljoin(next_link, _parsed_next_link.path), params=_next_request_params) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore request.method = "GET" return request @@ -2536,10 +2686,8 @@ def extract_data(pipeline_response): def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) response = pipeline_response.http_response @@ -2549,64 +2697,123 @@ def get_next(next_link=None): return pipeline_response + return ItemPaged(get_next, extract_data) - return ItemPaged( - get_next, extract_data - ) - list_by_management_group.metadata = {'url': "/providers/Microsoft.Management/managementgroups/{managementGroupId}/providers/Microsoft.Authorization/policyDefinitions"} # type: ignore -class PolicySetDefinitionsOperations(object): - """PolicySetDefinitionsOperations operations. - - You should not instantiate this class directly. Instead, you should create a Client instance that - instantiates it for you and attaches it as an attribute. - - :ivar models: Alias to model classes used in this operation group. - :type models: ~azure.mgmt.resource.policy.v2019_09_01.models - :param client: Client for service requests. - :param config: Configuration of service client. - :param serializer: An object model serializer. - :param deserializer: An object model deserializer. + list_by_management_group.metadata = {"url": "/providers/Microsoft.Management/managementgroups/{managementGroupId}/providers/Microsoft.Authorization/policyDefinitions"} # type: ignore + + +class PolicySetDefinitionsOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. + + Instead, you should access the following operations through + :class:`~azure.mgmt.resource.policy.v2019_09_01.PolicyClient`'s + :attr:`policy_set_definitions` attribute. """ models = _models - def __init__(self, client, config, serializer, deserializer): - self._client = client - self._serialize = serializer - self._deserialize = deserializer - self._config = config + def __init__(self, *args, **kwargs): + input_args = list(args) + self._client = input_args.pop(0) if input_args else kwargs.pop("client") + self._config = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") - @distributed_trace + @overload def create_or_update( self, policy_set_definition_name: str, - parameters: "_models.PolicySetDefinition", + parameters: _models.PolicySetDefinition, + *, + content_type: str = "application/json", **kwargs: Any - ) -> "_models.PolicySetDefinition": + ) -> _models.PolicySetDefinition: """Creates or updates a policy set definition. This operation creates or updates a policy set definition in the given subscription with the given name. - :param policy_set_definition_name: The name of the policy set definition to create. + :param policy_set_definition_name: The name of the policy set definition to create. Required. :type policy_set_definition_name: str - :param parameters: The policy set definition properties. + :param parameters: The policy set definition properties. Required. :type parameters: ~azure.mgmt.resource.policy.v2019_09_01.models.PolicySetDefinition + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: PolicySetDefinition or the result of cls(response) + :rtype: ~azure.mgmt.resource.policy.v2019_09_01.models.PolicySetDefinition + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + def create_or_update( + self, policy_set_definition_name: str, parameters: IO, *, content_type: str = "application/json", **kwargs: Any + ) -> _models.PolicySetDefinition: + """Creates or updates a policy set definition. + + This operation creates or updates a policy set definition in the given subscription with the + given name. + + :param policy_set_definition_name: The name of the policy set definition to create. Required. + :type policy_set_definition_name: str + :param parameters: The policy set definition properties. Required. + :type parameters: IO + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: PolicySetDefinition or the result of cls(response) + :rtype: ~azure.mgmt.resource.policy.v2019_09_01.models.PolicySetDefinition + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace + def create_or_update( + self, policy_set_definition_name: str, parameters: Union[_models.PolicySetDefinition, IO], **kwargs: Any + ) -> _models.PolicySetDefinition: + """Creates or updates a policy set definition. + + This operation creates or updates a policy set definition in the given subscription with the + given name. + + :param policy_set_definition_name: The name of the policy set definition to create. Required. + :type policy_set_definition_name: str + :param parameters: The policy set definition properties. Is either a model type or a IO type. + Required. + :type parameters: ~azure.mgmt.resource.policy.v2019_09_01.models.PolicySetDefinition or IO + :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. + Default value is None. + :paramtype content_type: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: PolicySetDefinition, or the result of cls(response) + :return: PolicySetDefinition or the result of cls(response) :rtype: ~azure.mgmt.resource.policy.v2019_09_01.models.PolicySetDefinition - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.PolicySetDefinition"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) - api_version = kwargs.pop('api_version', "2019-09-01") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - _json = self._serialize.body(parameters, 'PolicySetDefinition') + api_version = kwargs.pop("api_version", _params.pop("api-version", "2019-09-01")) # type: str + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.PolicySetDefinition] + + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(parameters, (IO, bytes)): + _content = parameters + else: + _json = self._serialize.body(parameters, "PolicySetDefinition") request = build_policy_set_definitions_create_or_update_request( policy_set_definition_name=policy_set_definition_name, @@ -2614,16 +2821,18 @@ def create_or_update( api_version=api_version, content_type=content_type, json=_json, - template_url=self.create_or_update.metadata['url'], + content=_content, + template_url=self.create_or_update.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200, 201]: @@ -2631,59 +2840,62 @@ def create_or_update( raise HttpResponseError(response=response, error_format=ARMErrorFormat) if response.status_code == 200: - deserialized = self._deserialize('PolicySetDefinition', pipeline_response) + deserialized = self._deserialize("PolicySetDefinition", pipeline_response) if response.status_code == 201: - deserialized = self._deserialize('PolicySetDefinition', pipeline_response) + deserialized = self._deserialize("PolicySetDefinition", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - create_or_update.metadata = {'url': "/subscriptions/{subscriptionId}/providers/Microsoft.Authorization/policySetDefinitions/{policySetDefinitionName}"} # type: ignore - + create_or_update.metadata = {"url": "/subscriptions/{subscriptionId}/providers/Microsoft.Authorization/policySetDefinitions/{policySetDefinitionName}"} # type: ignore @distributed_trace def delete( # pylint: disable=inconsistent-return-statements - self, - policy_set_definition_name: str, - **kwargs: Any + self, policy_set_definition_name: str, **kwargs: Any ) -> None: """Deletes a policy set definition. This operation deletes the policy set definition in the given subscription with the given name. - :param policy_set_definition_name: The name of the policy set definition to delete. + :param policy_set_definition_name: The name of the policy set definition to delete. Required. :type policy_set_definition_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: None, or the result of cls(response) + :return: None or the result of cls(response) :rtype: None - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType[None] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) - api_version = kwargs.pop('api_version', "2019-09-01") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2019-09-01")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[None] - request = build_policy_set_definitions_delete_request( policy_set_definition_name=policy_set_definition_name, subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.delete.metadata['url'], + template_url=self.delete.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200, 204]: @@ -2693,163 +2905,169 @@ def delete( # pylint: disable=inconsistent-return-statements if cls: return cls(pipeline_response, None, {}) - delete.metadata = {'url': "/subscriptions/{subscriptionId}/providers/Microsoft.Authorization/policySetDefinitions/{policySetDefinitionName}"} # type: ignore - + delete.metadata = {"url": "/subscriptions/{subscriptionId}/providers/Microsoft.Authorization/policySetDefinitions/{policySetDefinitionName}"} # type: ignore @distributed_trace - def get( - self, - policy_set_definition_name: str, - **kwargs: Any - ) -> "_models.PolicySetDefinition": + def get(self, policy_set_definition_name: str, **kwargs: Any) -> _models.PolicySetDefinition: """Retrieves a policy set definition. This operation retrieves the policy set definition in the given subscription with the given name. - :param policy_set_definition_name: The name of the policy set definition to get. + :param policy_set_definition_name: The name of the policy set definition to get. Required. :type policy_set_definition_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: PolicySetDefinition, or the result of cls(response) + :return: PolicySetDefinition or the result of cls(response) :rtype: ~azure.mgmt.resource.policy.v2019_09_01.models.PolicySetDefinition - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.PolicySetDefinition"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) - api_version = kwargs.pop('api_version', "2019-09-01") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2019-09-01")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[_models.PolicySetDefinition] - request = build_policy_set_definitions_get_request( policy_set_definition_name=policy_set_definition_name, subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.get.metadata['url'], + template_url=self.get.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) - deserialized = self._deserialize('PolicySetDefinition', pipeline_response) + deserialized = self._deserialize("PolicySetDefinition", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - get.metadata = {'url': "/subscriptions/{subscriptionId}/providers/Microsoft.Authorization/policySetDefinitions/{policySetDefinitionName}"} # type: ignore - + get.metadata = {"url": "/subscriptions/{subscriptionId}/providers/Microsoft.Authorization/policySetDefinitions/{policySetDefinitionName}"} # type: ignore @distributed_trace - def get_built_in( - self, - policy_set_definition_name: str, - **kwargs: Any - ) -> "_models.PolicySetDefinition": + def get_built_in(self, policy_set_definition_name: str, **kwargs: Any) -> _models.PolicySetDefinition: """Retrieves a built in policy set definition. This operation retrieves the built-in policy set definition with the given name. - :param policy_set_definition_name: The name of the policy set definition to get. + :param policy_set_definition_name: The name of the policy set definition to get. Required. :type policy_set_definition_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: PolicySetDefinition, or the result of cls(response) + :return: PolicySetDefinition or the result of cls(response) :rtype: ~azure.mgmt.resource.policy.v2019_09_01.models.PolicySetDefinition - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.PolicySetDefinition"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) - api_version = kwargs.pop('api_version', "2019-09-01") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2019-09-01")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[_models.PolicySetDefinition] - request = build_policy_set_definitions_get_built_in_request( policy_set_definition_name=policy_set_definition_name, api_version=api_version, - template_url=self.get_built_in.metadata['url'], + template_url=self.get_built_in.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) - deserialized = self._deserialize('PolicySetDefinition', pipeline_response) + deserialized = self._deserialize("PolicySetDefinition", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - get_built_in.metadata = {'url': "/providers/Microsoft.Authorization/policySetDefinitions/{policySetDefinitionName}"} # type: ignore - + get_built_in.metadata = {"url": "/providers/Microsoft.Authorization/policySetDefinitions/{policySetDefinitionName}"} # type: ignore @distributed_trace - def list( - self, - **kwargs: Any - ) -> Iterable["_models.PolicySetDefinitionListResult"]: + def list(self, **kwargs: Any) -> Iterable["_models.PolicySetDefinition"]: """Retrieves the policy set definitions for a subscription. This operation retrieves a list of all the policy set definitions in the given subscription. :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either PolicySetDefinitionListResult or the result of - cls(response) + :return: An iterator like instance of either PolicySetDefinition or the result of cls(response) :rtype: - ~azure.core.paging.ItemPaged[~azure.mgmt.resource.policy.v2019_09_01.models.PolicySetDefinitionListResult] - :raises: ~azure.core.exceptions.HttpResponseError + ~azure.core.paging.ItemPaged[~azure.mgmt.resource.policy.v2019_09_01.models.PolicySetDefinition] + :raises ~azure.core.exceptions.HttpResponseError: """ - api_version = kwargs.pop('api_version', "2019-09-01") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2019-09-01")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[_models.PolicySetDefinitionListResult] - cls = kwargs.pop('cls', None) # type: ClsType["_models.PolicySetDefinitionListResult"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) + def prepare_request(next_link=None): if not next_link: - + request = build_policy_set_definitions_list_request( subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.list.metadata['url'], + template_url=self.list.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore else: - - request = build_policy_set_definitions_list_request( - subscription_id=self._config.subscription_id, - template_url=next_link, - ) + # make call to next link with the client's api-version + _parsed_next_link = urlparse(next_link) + _next_request_params = case_insensitive_dict(parse_qs(_parsed_next_link.query)) + _next_request_params["api-version"] = self._config.api_version + request = HttpRequest("GET", urljoin(next_link, _parsed_next_link.path), params=_next_request_params) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore request.method = "GET" return request @@ -2863,10 +3081,8 @@ def extract_data(pipeline_response): def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) response = pipeline_response.http_response @@ -2876,52 +3092,56 @@ def get_next(next_link=None): return pipeline_response + return ItemPaged(get_next, extract_data) - return ItemPaged( - get_next, extract_data - ) - list.metadata = {'url': "/subscriptions/{subscriptionId}/providers/Microsoft.Authorization/policySetDefinitions"} # type: ignore + list.metadata = {"url": "/subscriptions/{subscriptionId}/providers/Microsoft.Authorization/policySetDefinitions"} # type: ignore @distributed_trace - def list_built_in( - self, - **kwargs: Any - ) -> Iterable["_models.PolicySetDefinitionListResult"]: + def list_built_in(self, **kwargs: Any) -> Iterable["_models.PolicySetDefinition"]: """Retrieves built-in policy set definitions. This operation retrieves a list of all the built-in policy set definitions. :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either PolicySetDefinitionListResult or the result of - cls(response) + :return: An iterator like instance of either PolicySetDefinition or the result of cls(response) :rtype: - ~azure.core.paging.ItemPaged[~azure.mgmt.resource.policy.v2019_09_01.models.PolicySetDefinitionListResult] - :raises: ~azure.core.exceptions.HttpResponseError + ~azure.core.paging.ItemPaged[~azure.mgmt.resource.policy.v2019_09_01.models.PolicySetDefinition] + :raises ~azure.core.exceptions.HttpResponseError: """ - api_version = kwargs.pop('api_version', "2019-09-01") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2019-09-01")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[_models.PolicySetDefinitionListResult] - cls = kwargs.pop('cls', None) # type: ClsType["_models.PolicySetDefinitionListResult"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) + def prepare_request(next_link=None): if not next_link: - + request = build_policy_set_definitions_list_built_in_request( api_version=api_version, - template_url=self.list_built_in.metadata['url'], + template_url=self.list_built_in.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore else: - - request = build_policy_set_definitions_list_built_in_request( - template_url=next_link, - ) + # make call to next link with the client's api-version + _parsed_next_link = urlparse(next_link) + _next_request_params = case_insensitive_dict(parse_qs(_parsed_next_link.query)) + _next_request_params["api-version"] = self._config.api_version + request = HttpRequest("GET", urljoin(next_link, _parsed_next_link.path), params=_next_request_params) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore request.method = "GET" return request @@ -2935,10 +3155,8 @@ def extract_data(pipeline_response): def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) response = pipeline_response.http_response @@ -2948,46 +3166,120 @@ def get_next(next_link=None): return pipeline_response + return ItemPaged(get_next, extract_data) - return ItemPaged( - get_next, extract_data - ) - list_built_in.metadata = {'url': "/providers/Microsoft.Authorization/policySetDefinitions"} # type: ignore + list_built_in.metadata = {"url": "/providers/Microsoft.Authorization/policySetDefinitions"} # type: ignore - @distributed_trace + @overload def create_or_update_at_management_group( self, policy_set_definition_name: str, management_group_id: str, - parameters: "_models.PolicySetDefinition", + parameters: _models.PolicySetDefinition, + *, + content_type: str = "application/json", **kwargs: Any - ) -> "_models.PolicySetDefinition": + ) -> _models.PolicySetDefinition: """Creates or updates a policy set definition. This operation creates or updates a policy set definition in the given management group with the given name. - :param policy_set_definition_name: The name of the policy set definition to create. + :param policy_set_definition_name: The name of the policy set definition to create. Required. :type policy_set_definition_name: str - :param management_group_id: The ID of the management group. + :param management_group_id: The ID of the management group. Required. :type management_group_id: str - :param parameters: The policy set definition properties. + :param parameters: The policy set definition properties. Required. :type parameters: ~azure.mgmt.resource.policy.v2019_09_01.models.PolicySetDefinition + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: PolicySetDefinition or the result of cls(response) + :rtype: ~azure.mgmt.resource.policy.v2019_09_01.models.PolicySetDefinition + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + def create_or_update_at_management_group( + self, + policy_set_definition_name: str, + management_group_id: str, + parameters: IO, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.PolicySetDefinition: + """Creates or updates a policy set definition. + + This operation creates or updates a policy set definition in the given management group with + the given name. + + :param policy_set_definition_name: The name of the policy set definition to create. Required. + :type policy_set_definition_name: str + :param management_group_id: The ID of the management group. Required. + :type management_group_id: str + :param parameters: The policy set definition properties. Required. + :type parameters: IO + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: PolicySetDefinition or the result of cls(response) + :rtype: ~azure.mgmt.resource.policy.v2019_09_01.models.PolicySetDefinition + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace + def create_or_update_at_management_group( + self, + policy_set_definition_name: str, + management_group_id: str, + parameters: Union[_models.PolicySetDefinition, IO], + **kwargs: Any + ) -> _models.PolicySetDefinition: + """Creates or updates a policy set definition. + + This operation creates or updates a policy set definition in the given management group with + the given name. + + :param policy_set_definition_name: The name of the policy set definition to create. Required. + :type policy_set_definition_name: str + :param management_group_id: The ID of the management group. Required. + :type management_group_id: str + :param parameters: The policy set definition properties. Is either a model type or a IO type. + Required. + :type parameters: ~azure.mgmt.resource.policy.v2019_09_01.models.PolicySetDefinition or IO + :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. + Default value is None. + :paramtype content_type: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: PolicySetDefinition, or the result of cls(response) + :return: PolicySetDefinition or the result of cls(response) :rtype: ~azure.mgmt.resource.policy.v2019_09_01.models.PolicySetDefinition - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.PolicySetDefinition"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', "2019-09-01") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + api_version = kwargs.pop("api_version", _params.pop("api-version", "2019-09-01")) # type: str + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.PolicySetDefinition] - _json = self._serialize.body(parameters, 'PolicySetDefinition') + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(parameters, (IO, bytes)): + _content = parameters + else: + _json = self._serialize.body(parameters, "PolicySetDefinition") request = build_policy_set_definitions_create_or_update_at_management_group_request( policy_set_definition_name=policy_set_definition_name, @@ -2995,16 +3287,18 @@ def create_or_update_at_management_group( api_version=api_version, content_type=content_type, json=_json, - template_url=self.create_or_update_at_management_group.metadata['url'], + content=_content, + template_url=self.create_or_update_at_management_group.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200, 201]: @@ -3012,63 +3306,65 @@ def create_or_update_at_management_group( raise HttpResponseError(response=response, error_format=ARMErrorFormat) if response.status_code == 200: - deserialized = self._deserialize('PolicySetDefinition', pipeline_response) + deserialized = self._deserialize("PolicySetDefinition", pipeline_response) if response.status_code == 201: - deserialized = self._deserialize('PolicySetDefinition', pipeline_response) + deserialized = self._deserialize("PolicySetDefinition", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - create_or_update_at_management_group.metadata = {'url': "/providers/Microsoft.Management/managementgroups/{managementGroupId}/providers/Microsoft.Authorization/policySetDefinitions/{policySetDefinitionName}"} # type: ignore - + create_or_update_at_management_group.metadata = {"url": "/providers/Microsoft.Management/managementgroups/{managementGroupId}/providers/Microsoft.Authorization/policySetDefinitions/{policySetDefinitionName}"} # type: ignore @distributed_trace def delete_at_management_group( # pylint: disable=inconsistent-return-statements - self, - policy_set_definition_name: str, - management_group_id: str, - **kwargs: Any + self, policy_set_definition_name: str, management_group_id: str, **kwargs: Any ) -> None: """Deletes a policy set definition. This operation deletes the policy set definition in the given management group with the given name. - :param policy_set_definition_name: The name of the policy set definition to delete. + :param policy_set_definition_name: The name of the policy set definition to delete. Required. :type policy_set_definition_name: str - :param management_group_id: The ID of the management group. + :param management_group_id: The ID of the management group. Required. :type management_group_id: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: None, or the result of cls(response) + :return: None or the result of cls(response) :rtype: None - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType[None] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) - api_version = kwargs.pop('api_version', "2019-09-01") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2019-09-01")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[None] - request = build_policy_set_definitions_delete_at_management_group_request( policy_set_definition_name=policy_set_definition_name, management_group_id=management_group_id, api_version=api_version, - template_url=self.delete_at_management_group.metadata['url'], + template_url=self.delete_at_management_group.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200, 204]: @@ -3078,115 +3374,122 @@ def delete_at_management_group( # pylint: disable=inconsistent-return-statement if cls: return cls(pipeline_response, None, {}) - delete_at_management_group.metadata = {'url': "/providers/Microsoft.Management/managementgroups/{managementGroupId}/providers/Microsoft.Authorization/policySetDefinitions/{policySetDefinitionName}"} # type: ignore - + delete_at_management_group.metadata = {"url": "/providers/Microsoft.Management/managementgroups/{managementGroupId}/providers/Microsoft.Authorization/policySetDefinitions/{policySetDefinitionName}"} # type: ignore @distributed_trace def get_at_management_group( - self, - policy_set_definition_name: str, - management_group_id: str, - **kwargs: Any - ) -> "_models.PolicySetDefinition": + self, policy_set_definition_name: str, management_group_id: str, **kwargs: Any + ) -> _models.PolicySetDefinition: """Retrieves a policy set definition. This operation retrieves the policy set definition in the given management group with the given name. - :param policy_set_definition_name: The name of the policy set definition to get. + :param policy_set_definition_name: The name of the policy set definition to get. Required. :type policy_set_definition_name: str - :param management_group_id: The ID of the management group. + :param management_group_id: The ID of the management group. Required. :type management_group_id: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: PolicySetDefinition, or the result of cls(response) + :return: PolicySetDefinition or the result of cls(response) :rtype: ~azure.mgmt.resource.policy.v2019_09_01.models.PolicySetDefinition - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.PolicySetDefinition"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + 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', "2019-09-01") # type: str + api_version = kwargs.pop("api_version", _params.pop("api-version", "2019-09-01")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[_models.PolicySetDefinition] - request = build_policy_set_definitions_get_at_management_group_request( policy_set_definition_name=policy_set_definition_name, management_group_id=management_group_id, api_version=api_version, - template_url=self.get_at_management_group.metadata['url'], + template_url=self.get_at_management_group.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) - deserialized = self._deserialize('PolicySetDefinition', pipeline_response) + deserialized = self._deserialize("PolicySetDefinition", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - get_at_management_group.metadata = {'url': "/providers/Microsoft.Management/managementgroups/{managementGroupId}/providers/Microsoft.Authorization/policySetDefinitions/{policySetDefinitionName}"} # type: ignore - + get_at_management_group.metadata = {"url": "/providers/Microsoft.Management/managementgroups/{managementGroupId}/providers/Microsoft.Authorization/policySetDefinitions/{policySetDefinitionName}"} # type: ignore @distributed_trace def list_by_management_group( - self, - management_group_id: str, - **kwargs: Any - ) -> Iterable["_models.PolicySetDefinitionListResult"]: + self, management_group_id: str, **kwargs: Any + ) -> Iterable["_models.PolicySetDefinition"]: """Retrieves all policy set definitions in management group. This operation retrieves a list of all the a policy set definition in the given management group. - :param management_group_id: The ID of the management group. + :param management_group_id: The ID of the management group. Required. :type management_group_id: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either PolicySetDefinitionListResult or the result of - cls(response) + :return: An iterator like instance of either PolicySetDefinition or the result of cls(response) :rtype: - ~azure.core.paging.ItemPaged[~azure.mgmt.resource.policy.v2019_09_01.models.PolicySetDefinitionListResult] - :raises: ~azure.core.exceptions.HttpResponseError + ~azure.core.paging.ItemPaged[~azure.mgmt.resource.policy.v2019_09_01.models.PolicySetDefinition] + :raises ~azure.core.exceptions.HttpResponseError: """ - api_version = kwargs.pop('api_version', "2019-09-01") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2019-09-01")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[_models.PolicySetDefinitionListResult] - cls = kwargs.pop('cls', None) # type: ClsType["_models.PolicySetDefinitionListResult"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) + def prepare_request(next_link=None): if not next_link: - + request = build_policy_set_definitions_list_by_management_group_request( management_group_id=management_group_id, api_version=api_version, - template_url=self.list_by_management_group.metadata['url'], + template_url=self.list_by_management_group.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore else: - - request = build_policy_set_definitions_list_by_management_group_request( - management_group_id=management_group_id, - template_url=next_link, - ) + # make call to next link with the client's api-version + _parsed_next_link = urlparse(next_link) + _next_request_params = case_insensitive_dict(parse_qs(_parsed_next_link.query)) + _next_request_params["api-version"] = self._config.api_version + request = HttpRequest("GET", urljoin(next_link, _parsed_next_link.path), params=_next_request_params) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore request.method = "GET" return request @@ -3200,10 +3503,8 @@ def extract_data(pipeline_response): def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) response = pipeline_response.http_response @@ -3213,8 +3514,6 @@ def get_next(next_link=None): return pipeline_response + return ItemPaged(get_next, extract_data) - return ItemPaged( - get_next, extract_data - ) - list_by_management_group.metadata = {'url': "/providers/Microsoft.Management/managementgroups/{managementGroupId}/providers/Microsoft.Authorization/policySetDefinitions"} # type: ignore + list_by_management_group.metadata = {"url": "/providers/Microsoft.Management/managementgroups/{managementGroupId}/providers/Microsoft.Authorization/policySetDefinitions"} # type: ignore diff --git a/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/policy/v2019_09_01/operations/_patch.py b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/policy/v2019_09_01/operations/_patch.py new file mode 100644 index 0000000000000..f7dd32510333d --- /dev/null +++ b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/policy/v2019_09_01/operations/_patch.py @@ -0,0 +1,20 @@ +# ------------------------------------ +# Copyright (c) Microsoft Corporation. +# Licensed under the MIT License. +# ------------------------------------ +"""Customize generated code here. + +Follow our quickstart for examples: https://aka.ms/azsdk/python/dpcodegen/python/customize +""" +from typing import List + +__all__: List[str] = [] # Add all objects you want publicly available to users at this package level + + +def patch_sdk(): + """Do not remove from this file. + + `patch_sdk` is a last resort escape hatch that allows you to do customizations + you can't accomplish using the techniques described in + https://aka.ms/azsdk/python/dpcodegen/python/customize + """ diff --git a/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/policy/v2020_09_01/__init__.py b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/policy/v2020_09_01/__init__.py index 89180ab440872..bb1ffe59afae7 100644 --- a/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/policy/v2020_09_01/__init__.py +++ b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/policy/v2020_09_01/__init__.py @@ -10,9 +10,15 @@ from ._version import VERSION __version__ = VERSION -__all__ = ['PolicyClient'] -# `._patch.py` is used for handwritten extensions to the generated code -# Example: https://github.com/Azure/azure-sdk-for-python/blob/main/doc/dev/customize_code/how-to-patch-sdk-code.md -from ._patch import patch_sdk -patch_sdk() +try: + from ._patch import __all__ as _patch_all + from ._patch import * # type: ignore # pylint: disable=unused-wildcard-import +except ImportError: + _patch_all = [] +from ._patch import patch_sdk as _patch_sdk + +__all__ = ["PolicyClient"] +__all__.extend([p for p in _patch_all if p not in __all__]) + +_patch_sdk() diff --git a/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/policy/v2020_09_01/_configuration.py b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/policy/v2020_09_01/_configuration.py index 4c2ba31e56c60..c6a430f1f8bdc 100644 --- a/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/policy/v2020_09_01/_configuration.py +++ b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/policy/v2020_09_01/_configuration.py @@ -25,18 +25,13 @@ class PolicyClientConfiguration(Configuration): # pylint: disable=too-many-inst Note that all parameters used to create this instance are saved as instance attributes. - :param credential: Credential needed for the client to connect to Azure. + :param credential: Credential needed for the client to connect to Azure. Required. :type credential: ~azure.core.credentials.TokenCredential - :param subscription_id: The ID of the target subscription. + :param subscription_id: The ID of the target subscription. Required. :type subscription_id: str """ - def __init__( - self, - credential: "TokenCredential", - subscription_id: str, - **kwargs: Any - ) -> None: + def __init__(self, credential: "TokenCredential", subscription_id: str, **kwargs: Any) -> None: super(PolicyClientConfiguration, self).__init__(**kwargs) if credential is None: raise ValueError("Parameter 'credential' must not be None.") @@ -45,23 +40,24 @@ def __init__( self.credential = credential self.subscription_id = subscription_id - self.credential_scopes = kwargs.pop('credential_scopes', ['https://management.azure.com/.default']) - kwargs.setdefault('sdk_moniker', 'mgmt-resource/{}'.format(VERSION)) + self.credential_scopes = kwargs.pop("credential_scopes", ["https://management.azure.com/.default"]) + kwargs.setdefault("sdk_moniker", "mgmt-resource/{}".format(VERSION)) self._configure(**kwargs) def _configure( - self, - **kwargs # type: Any + self, **kwargs # type: Any ): # type: (...) -> 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) - self.logging_policy = kwargs.get('logging_policy') or policies.NetworkTraceLoggingPolicy(**kwargs) - self.http_logging_policy = kwargs.get('http_logging_policy') or ARMHttpLoggingPolicy(**kwargs) - self.retry_policy = kwargs.get('retry_policy') or policies.RetryPolicy(**kwargs) - self.custom_hook_policy = kwargs.get('custom_hook_policy') or policies.CustomHookPolicy(**kwargs) - self.redirect_policy = kwargs.get('redirect_policy') or policies.RedirectPolicy(**kwargs) - self.authentication_policy = kwargs.get('authentication_policy') + 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) + self.logging_policy = kwargs.get("logging_policy") or policies.NetworkTraceLoggingPolicy(**kwargs) + self.http_logging_policy = kwargs.get("http_logging_policy") or ARMHttpLoggingPolicy(**kwargs) + self.retry_policy = kwargs.get("retry_policy") or policies.RetryPolicy(**kwargs) + self.custom_hook_policy = kwargs.get("custom_hook_policy") or policies.CustomHookPolicy(**kwargs) + self.redirect_policy = kwargs.get("redirect_policy") or policies.RedirectPolicy(**kwargs) + self.authentication_policy = kwargs.get("authentication_policy") if self.credential and not self.authentication_policy: - self.authentication_policy = ARMChallengeAuthenticationPolicy(self.credential, *self.credential_scopes, **kwargs) + self.authentication_policy = ARMChallengeAuthenticationPolicy( + self.credential, *self.credential_scopes, **kwargs + ) diff --git a/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/policy/v2020_09_01/_metadata.json b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/policy/v2020_09_01/_metadata.json index e0a83d04c6810..1123064510827 100644 --- a/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/policy/v2020_09_01/_metadata.json +++ b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/policy/v2020_09_01/_metadata.json @@ -10,20 +10,20 @@ "azure_arm": true, "has_lro_operations": false, "client_side_validation": false, - "sync_imports": "{\"typing\": {\"azurecore\": {\"azure.core.credentials\": [\"TokenCredential\"]}}, \"regular\": {\"azurecore\": {\"azure.profiles\": [\"KnownProfiles\", \"ProfileDefinition\"], \"azure.profiles.multiapiclient\": [\"MultiApiClientMixin\"], \"azure.mgmt.core\": [\"ARMPipelineClient\"]}, \"local\": {\"._configuration\": [\"PolicyClientConfiguration\"]}, \"thirdparty\": {\"msrest\": [\"Deserializer\", \"Serializer\"]}}, \"conditional\": {\"stdlib\": {\"typing\": [\"Any\", \"Optional\"]}}}", - "async_imports": "{\"typing\": {\"azurecore\": {\"azure.core.credentials_async\": [\"AsyncTokenCredential\"], \"azure.core.credentials\": [\"TokenCredential\"]}}, \"regular\": {\"azurecore\": {\"azure.profiles\": [\"KnownProfiles\", \"ProfileDefinition\"], \"azure.profiles.multiapiclient\": [\"MultiApiClientMixin\"], \"azure.mgmt.core\": [\"AsyncARMPipelineClient\"]}, \"local\": {\"._configuration\": [\"PolicyClientConfiguration\"]}, \"thirdparty\": {\"msrest\": [\"Deserializer\", \"Serializer\"]}}, \"conditional\": {\"stdlib\": {\"typing\": [\"Any\", \"Optional\"]}}}" + "sync_imports": "{\"conditional\": {\"stdlib\": {\"typing\": [\"Any\", \"Optional\"]}}, \"regular\": {\"azurecore\": {\"azure.mgmt.core\": [\"ARMPipelineClient\"], \"azure.profiles\": [\"KnownProfiles\", \"ProfileDefinition\"], \"azure.profiles.multiapiclient\": [\"MultiApiClientMixin\"]}, \"local\": {\"._configuration\": [\"PolicyClientConfiguration\"], \".._serialization\": [\"Deserializer\", \"Serializer\"]}}, \"typing\": {\"azurecore\": {\"azure.core.credentials\": [\"TokenCredential\"]}}}", + "async_imports": "{\"conditional\": {\"stdlib\": {\"typing\": [\"Any\", \"Optional\"]}}, \"regular\": {\"azurecore\": {\"azure.mgmt.core\": [\"AsyncARMPipelineClient\"], \"azure.profiles\": [\"KnownProfiles\", \"ProfileDefinition\"], \"azure.profiles.multiapiclient\": [\"MultiApiClientMixin\"]}, \"local\": {\"._configuration\": [\"PolicyClientConfiguration\"], \"..._serialization\": [\"Deserializer\", \"Serializer\"]}}, \"typing\": {\"azurecore\": {\"azure.core.credentials_async\": [\"AsyncTokenCredential\"]}}}" }, "global_parameters": { "sync": { "credential": { - "signature": "credential, # type: \"TokenCredential\"", - "description": "Credential needed for the client to connect to Azure.", + "signature": "credential: \"TokenCredential\",", + "description": "Credential needed for the client to connect to Azure. Required.", "docstring_type": "~azure.core.credentials.TokenCredential", "required": true }, "subscription_id": { - "signature": "subscription_id, # type: str", - "description": "The ID of the target subscription.", + "signature": "subscription_id: str,", + "description": "The ID of the target subscription. Required.", "docstring_type": "str", "required": true } @@ -31,13 +31,13 @@ "async": { "credential": { "signature": "credential: \"AsyncTokenCredential\",", - "description": "Credential needed for the client to connect to Azure.", + "description": "Credential needed for the client to connect to Azure. Required.", "docstring_type": "~azure.core.credentials_async.AsyncTokenCredential", "required": true }, "subscription_id": { "signature": "subscription_id: str,", - "description": "The ID of the target subscription.", + "description": "The ID of the target subscription. Required.", "docstring_type": "str", "required": true } @@ -54,7 +54,7 @@ "required": false }, "base_url": { - "signature": "base_url=\"https://management.azure.com\", # type: str", + "signature": "base_url: str = \"https://management.azure.com\",", "description": "Service URL", "docstring_type": "str", "required": false diff --git a/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/policy/v2020_09_01/_patch.py b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/policy/v2020_09_01/_patch.py index 74e48ecd07cf3..f99e77fef9861 100644 --- a/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/policy/v2020_09_01/_patch.py +++ b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/policy/v2020_09_01/_patch.py @@ -28,4 +28,4 @@ # This file is used for handwritten extensions to the generated code. Example: # https://github.com/Azure/azure-sdk-for-python/blob/main/doc/dev/customize_code/how-to-patch-sdk-code.md def patch_sdk(): - pass \ No newline at end of file + pass diff --git a/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/policy/v2020_09_01/_policy_client.py b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/policy/v2020_09_01/_policy_client.py index 5661973131bd1..7e92dbeb628e5 100644 --- a/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/policy/v2020_09_01/_policy_client.py +++ b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/policy/v2020_09_01/_policy_client.py @@ -9,20 +9,26 @@ from copy import deepcopy from typing import Any, TYPE_CHECKING -from msrest import Deserializer, Serializer - from azure.core.rest import HttpRequest, HttpResponse from azure.mgmt.core import ARMPipelineClient from . import models +from .._serialization import Deserializer, Serializer from ._configuration import PolicyClientConfiguration -from .operations import DataPolicyManifestsOperations, PolicyAssignmentsOperations, PolicyDefinitionsOperations, PolicyExemptionsOperations, PolicySetDefinitionsOperations +from .operations import ( + DataPolicyManifestsOperations, + PolicyAssignmentsOperations, + PolicyDefinitionsOperations, + PolicyExemptionsOperations, + PolicySetDefinitionsOperations, +) if TYPE_CHECKING: # pylint: disable=unused-import,ungrouped-imports from azure.core.credentials import TokenCredential -class PolicyClient: + +class PolicyClient: # pylint: disable=client-accepts-api-version-keyword """To manage and control access to your resources, you can define customized policies and assign them at a scope. @@ -41,9 +47,9 @@ class PolicyClient: :ivar policy_exemptions: PolicyExemptionsOperations operations :vartype policy_exemptions: azure.mgmt.resource.policy.v2020_09_01.operations.PolicyExemptionsOperations - :param credential: Credential needed for the client to connect to Azure. + :param credential: Credential needed for the client to connect to Azure. Required. :type credential: ~azure.core.credentials.TokenCredential - :param subscription_id: The ID of the target subscription. + :param subscription_id: The ID of the target subscription. Required. :type subscription_id: str :param base_url: Service URL. Default value is "https://management.azure.com". :type base_url: str @@ -63,18 +69,23 @@ def __init__( self._serialize = Serializer(client_models) self._deserialize = Deserializer(client_models) self._serialize.client_side_validation = False - self.data_policy_manifests = DataPolicyManifestsOperations(self._client, self._config, self._serialize, self._deserialize) - self.policy_assignments = PolicyAssignmentsOperations(self._client, self._config, self._serialize, self._deserialize) - self.policy_definitions = PolicyDefinitionsOperations(self._client, self._config, self._serialize, self._deserialize) - self.policy_set_definitions = PolicySetDefinitionsOperations(self._client, self._config, self._serialize, self._deserialize) - self.policy_exemptions = PolicyExemptionsOperations(self._client, self._config, self._serialize, self._deserialize) - - - def _send_request( - self, - request: HttpRequest, - **kwargs: Any - ) -> HttpResponse: + self.data_policy_manifests = DataPolicyManifestsOperations( + self._client, self._config, self._serialize, self._deserialize + ) + self.policy_assignments = PolicyAssignmentsOperations( + self._client, self._config, self._serialize, self._deserialize + ) + self.policy_definitions = PolicyDefinitionsOperations( + self._client, self._config, self._serialize, self._deserialize + ) + self.policy_set_definitions = PolicySetDefinitionsOperations( + self._client, self._config, self._serialize, self._deserialize + ) + self.policy_exemptions = PolicyExemptionsOperations( + self._client, self._config, self._serialize, self._deserialize + ) + + def _send_request(self, request: HttpRequest, **kwargs: Any) -> HttpResponse: """Runs the network request through the client's chained policies. >>> from azure.core.rest import HttpRequest @@ -83,7 +94,7 @@ def _send_request( >>> response = client._send_request(request) - For more information on this code flow, see https://aka.ms/azsdk/python/protocol/quickstart + For more information on this code flow, see https://aka.ms/azsdk/dpcodegen/python/send_request :param request: The network request you want to make. Required. :type request: ~azure.core.rest.HttpRequest diff --git a/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/policy/v2020_09_01/_vendor.py b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/policy/v2020_09_01/_vendor.py index 138f663c53a4e..9aad73fc743e7 100644 --- a/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/policy/v2020_09_01/_vendor.py +++ b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/policy/v2020_09_01/_vendor.py @@ -7,6 +7,7 @@ from azure.core.pipeline.transport import HttpRequest + def _convert_request(request, files=None): data = request.content if not files else None request = HttpRequest(method=request.method, url=request.url, headers=request.headers, data=data) @@ -14,6 +15,7 @@ def _convert_request(request, files=None): request.set_formdata_body(files) return request + def _format_url_section(template, **kwargs): components = template.split("/") while components: @@ -21,7 +23,5 @@ def _format_url_section(template, **kwargs): 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 - ] + components = [c for c in formatted_components if "{}".format(key.args[0]) not in c] template = "/".join(components) diff --git a/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/policy/v2020_09_01/_version.py b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/policy/v2020_09_01/_version.py index a012ac01c480c..e5754a47ce68f 100644 --- a/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/policy/v2020_09_01/_version.py +++ b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/policy/v2020_09_01/_version.py @@ -6,4 +6,4 @@ # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -VERSION = "21.1.0" +VERSION = "1.0.0b1" diff --git a/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/policy/v2020_09_01/aio/__init__.py b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/policy/v2020_09_01/aio/__init__.py index 2784ce3f14bf5..4622bf1f396a7 100644 --- a/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/policy/v2020_09_01/aio/__init__.py +++ b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/policy/v2020_09_01/aio/__init__.py @@ -7,9 +7,15 @@ # -------------------------------------------------------------------------- from ._policy_client import PolicyClient -__all__ = ['PolicyClient'] -# `._patch.py` is used for handwritten extensions to the generated code -# Example: https://github.com/Azure/azure-sdk-for-python/blob/main/doc/dev/customize_code/how-to-patch-sdk-code.md -from ._patch import patch_sdk -patch_sdk() +try: + from ._patch import __all__ as _patch_all + from ._patch import * # type: ignore # pylint: disable=unused-wildcard-import +except ImportError: + _patch_all = [] +from ._patch import patch_sdk as _patch_sdk + +__all__ = ["PolicyClient"] +__all__.extend([p for p in _patch_all if p not in __all__]) + +_patch_sdk() diff --git a/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/policy/v2020_09_01/aio/_configuration.py b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/policy/v2020_09_01/aio/_configuration.py index 21e375a7dd621..c52b0ba98ee82 100644 --- a/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/policy/v2020_09_01/aio/_configuration.py +++ b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/policy/v2020_09_01/aio/_configuration.py @@ -25,18 +25,13 @@ class PolicyClientConfiguration(Configuration): # pylint: disable=too-many-inst Note that all parameters used to create this instance are saved as instance attributes. - :param credential: Credential needed for the client to connect to Azure. + :param credential: Credential needed for the client to connect to Azure. Required. :type credential: ~azure.core.credentials_async.AsyncTokenCredential - :param subscription_id: The ID of the target subscription. + :param subscription_id: The ID of the target subscription. Required. :type subscription_id: str """ - def __init__( - self, - credential: "AsyncTokenCredential", - subscription_id: str, - **kwargs: Any - ) -> None: + def __init__(self, credential: "AsyncTokenCredential", subscription_id: str, **kwargs: Any) -> None: super(PolicyClientConfiguration, self).__init__(**kwargs) if credential is None: raise ValueError("Parameter 'credential' must not be None.") @@ -45,22 +40,21 @@ def __init__( self.credential = credential self.subscription_id = subscription_id - self.credential_scopes = kwargs.pop('credential_scopes', ['https://management.azure.com/.default']) - kwargs.setdefault('sdk_moniker', 'mgmt-resource/{}'.format(VERSION)) + self.credential_scopes = kwargs.pop("credential_scopes", ["https://management.azure.com/.default"]) + kwargs.setdefault("sdk_moniker", "mgmt-resource/{}".format(VERSION)) self._configure(**kwargs) - 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) - self.logging_policy = kwargs.get('logging_policy') or policies.NetworkTraceLoggingPolicy(**kwargs) - self.http_logging_policy = kwargs.get('http_logging_policy') or ARMHttpLoggingPolicy(**kwargs) - self.retry_policy = kwargs.get('retry_policy') or policies.AsyncRetryPolicy(**kwargs) - self.custom_hook_policy = kwargs.get('custom_hook_policy') or policies.CustomHookPolicy(**kwargs) - self.redirect_policy = kwargs.get('redirect_policy') or policies.AsyncRedirectPolicy(**kwargs) - self.authentication_policy = kwargs.get('authentication_policy') + 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) + self.logging_policy = kwargs.get("logging_policy") or policies.NetworkTraceLoggingPolicy(**kwargs) + self.http_logging_policy = kwargs.get("http_logging_policy") or ARMHttpLoggingPolicy(**kwargs) + self.retry_policy = kwargs.get("retry_policy") or policies.AsyncRetryPolicy(**kwargs) + self.custom_hook_policy = kwargs.get("custom_hook_policy") or policies.CustomHookPolicy(**kwargs) + self.redirect_policy = kwargs.get("redirect_policy") or policies.AsyncRedirectPolicy(**kwargs) + self.authentication_policy = kwargs.get("authentication_policy") if self.credential and not self.authentication_policy: - self.authentication_policy = AsyncARMChallengeAuthenticationPolicy(self.credential, *self.credential_scopes, **kwargs) + self.authentication_policy = AsyncARMChallengeAuthenticationPolicy( + self.credential, *self.credential_scopes, **kwargs + ) diff --git a/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/policy/v2020_09_01/aio/_patch.py b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/policy/v2020_09_01/aio/_patch.py index 74e48ecd07cf3..f99e77fef9861 100644 --- a/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/policy/v2020_09_01/aio/_patch.py +++ b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/policy/v2020_09_01/aio/_patch.py @@ -28,4 +28,4 @@ # This file is used for handwritten extensions to the generated code. Example: # https://github.com/Azure/azure-sdk-for-python/blob/main/doc/dev/customize_code/how-to-patch-sdk-code.md def patch_sdk(): - pass \ No newline at end of file + pass diff --git a/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/policy/v2020_09_01/aio/_policy_client.py b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/policy/v2020_09_01/aio/_policy_client.py index 5910f301279bf..591e209b22443 100644 --- a/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/policy/v2020_09_01/aio/_policy_client.py +++ b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/policy/v2020_09_01/aio/_policy_client.py @@ -9,20 +9,26 @@ from copy import deepcopy from typing import Any, Awaitable, TYPE_CHECKING -from msrest import Deserializer, Serializer - from azure.core.rest import AsyncHttpResponse, HttpRequest from azure.mgmt.core import AsyncARMPipelineClient from .. import models +from ..._serialization import Deserializer, Serializer from ._configuration import PolicyClientConfiguration -from .operations import DataPolicyManifestsOperations, PolicyAssignmentsOperations, PolicyDefinitionsOperations, PolicyExemptionsOperations, PolicySetDefinitionsOperations +from .operations import ( + DataPolicyManifestsOperations, + PolicyAssignmentsOperations, + PolicyDefinitionsOperations, + PolicyExemptionsOperations, + PolicySetDefinitionsOperations, +) if TYPE_CHECKING: # pylint: disable=unused-import,ungrouped-imports from azure.core.credentials_async import AsyncTokenCredential -class PolicyClient: + +class PolicyClient: # pylint: disable=client-accepts-api-version-keyword """To manage and control access to your resources, you can define customized policies and assign them at a scope. @@ -41,9 +47,9 @@ class PolicyClient: :ivar policy_exemptions: PolicyExemptionsOperations operations :vartype policy_exemptions: azure.mgmt.resource.policy.v2020_09_01.aio.operations.PolicyExemptionsOperations - :param credential: Credential needed for the client to connect to Azure. + :param credential: Credential needed for the client to connect to Azure. Required. :type credential: ~azure.core.credentials_async.AsyncTokenCredential - :param subscription_id: The ID of the target subscription. + :param subscription_id: The ID of the target subscription. Required. :type subscription_id: str :param base_url: Service URL. Default value is "https://management.azure.com". :type base_url: str @@ -63,18 +69,23 @@ def __init__( self._serialize = Serializer(client_models) self._deserialize = Deserializer(client_models) self._serialize.client_side_validation = False - self.data_policy_manifests = DataPolicyManifestsOperations(self._client, self._config, self._serialize, self._deserialize) - self.policy_assignments = PolicyAssignmentsOperations(self._client, self._config, self._serialize, self._deserialize) - self.policy_definitions = PolicyDefinitionsOperations(self._client, self._config, self._serialize, self._deserialize) - self.policy_set_definitions = PolicySetDefinitionsOperations(self._client, self._config, self._serialize, self._deserialize) - self.policy_exemptions = PolicyExemptionsOperations(self._client, self._config, self._serialize, self._deserialize) - - - def _send_request( - self, - request: HttpRequest, - **kwargs: Any - ) -> Awaitable[AsyncHttpResponse]: + self.data_policy_manifests = DataPolicyManifestsOperations( + self._client, self._config, self._serialize, self._deserialize + ) + self.policy_assignments = PolicyAssignmentsOperations( + self._client, self._config, self._serialize, self._deserialize + ) + self.policy_definitions = PolicyDefinitionsOperations( + self._client, self._config, self._serialize, self._deserialize + ) + self.policy_set_definitions = PolicySetDefinitionsOperations( + self._client, self._config, self._serialize, self._deserialize + ) + self.policy_exemptions = PolicyExemptionsOperations( + self._client, self._config, self._serialize, self._deserialize + ) + + def _send_request(self, request: HttpRequest, **kwargs: Any) -> Awaitable[AsyncHttpResponse]: """Runs the network request through the client's chained policies. >>> from azure.core.rest import HttpRequest @@ -83,7 +94,7 @@ def _send_request( >>> response = await client._send_request(request) - For more information on this code flow, see https://aka.ms/azsdk/python/protocol/quickstart + For more information on this code flow, see https://aka.ms/azsdk/dpcodegen/python/send_request :param request: The network request you want to make. Required. :type request: ~azure.core.rest.HttpRequest diff --git a/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/policy/v2020_09_01/aio/operations/__init__.py b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/policy/v2020_09_01/aio/operations/__init__.py index 07b8f47f6b817..bb444fce72789 100644 --- a/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/policy/v2020_09_01/aio/operations/__init__.py +++ b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/policy/v2020_09_01/aio/operations/__init__.py @@ -12,10 +12,16 @@ from ._operations import PolicySetDefinitionsOperations from ._operations import PolicyExemptionsOperations +from ._patch import __all__ as _patch_all +from ._patch import * # type: ignore # pylint: disable=unused-wildcard-import +from ._patch import patch_sdk as _patch_sdk + __all__ = [ - 'DataPolicyManifestsOperations', - 'PolicyAssignmentsOperations', - 'PolicyDefinitionsOperations', - 'PolicySetDefinitionsOperations', - 'PolicyExemptionsOperations', + "DataPolicyManifestsOperations", + "PolicyAssignmentsOperations", + "PolicyDefinitionsOperations", + "PolicySetDefinitionsOperations", + "PolicyExemptionsOperations", ] +__all__.extend([p for p in _patch_all if p not in __all__]) +_patch_sdk() diff --git a/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/policy/v2020_09_01/aio/operations/_operations.py b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/policy/v2020_09_01/aio/operations/_operations.py index 79e239eb398ce..ce0669f0ade21 100644 --- a/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/policy/v2020_09_01/aio/operations/_operations.py +++ b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/policy/v2020_09_01/aio/operations/_operations.py @@ -6,109 +6,150 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -from typing import Any, AsyncIterable, Callable, Dict, Optional, TypeVar +from typing import Any, AsyncIterable, Callable, Dict, IO, Optional, TypeVar, Union, overload from azure.core.async_paging import AsyncItemPaged, AsyncList -from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error +from azure.core.exceptions import ( + ClientAuthenticationError, + HttpResponseError, + ResourceExistsError, + ResourceNotFoundError, + ResourceNotModifiedError, + map_error, +) from azure.core.pipeline import PipelineResponse from azure.core.pipeline.transport import AsyncHttpResponse from azure.core.rest import HttpRequest from azure.core.tracing.decorator import distributed_trace from azure.core.tracing.decorator_async import distributed_trace_async +from azure.core.utils import case_insensitive_dict from azure.mgmt.core.exceptions import ARMErrorFormat from ... import models as _models from ..._vendor import _convert_request -from ...operations._operations import build_data_policy_manifests_get_by_policy_mode_request, build_data_policy_manifests_list_request, build_policy_assignments_create_by_id_request, build_policy_assignments_create_request, build_policy_assignments_delete_by_id_request, build_policy_assignments_delete_request, build_policy_assignments_get_by_id_request, build_policy_assignments_get_request, build_policy_assignments_list_for_management_group_request, build_policy_assignments_list_for_resource_group_request, build_policy_assignments_list_for_resource_request, build_policy_assignments_list_request, build_policy_definitions_create_or_update_at_management_group_request, build_policy_definitions_create_or_update_request, build_policy_definitions_delete_at_management_group_request, build_policy_definitions_delete_request, build_policy_definitions_get_at_management_group_request, build_policy_definitions_get_built_in_request, build_policy_definitions_get_request, build_policy_definitions_list_built_in_request, build_policy_definitions_list_by_management_group_request, build_policy_definitions_list_request, build_policy_exemptions_create_or_update_request, build_policy_exemptions_delete_request, build_policy_exemptions_get_request, build_policy_exemptions_list_for_management_group_request, build_policy_exemptions_list_for_resource_group_request, build_policy_exemptions_list_for_resource_request, build_policy_exemptions_list_request, build_policy_set_definitions_create_or_update_at_management_group_request, build_policy_set_definitions_create_or_update_request, build_policy_set_definitions_delete_at_management_group_request, build_policy_set_definitions_delete_request, build_policy_set_definitions_get_at_management_group_request, build_policy_set_definitions_get_built_in_request, build_policy_set_definitions_get_request, build_policy_set_definitions_list_built_in_request, build_policy_set_definitions_list_by_management_group_request, build_policy_set_definitions_list_request -T = TypeVar('T') +from ...operations._operations import ( + build_data_policy_manifests_get_by_policy_mode_request, + build_data_policy_manifests_list_request, + build_policy_assignments_create_by_id_request, + build_policy_assignments_create_request, + build_policy_assignments_delete_by_id_request, + build_policy_assignments_delete_request, + build_policy_assignments_get_by_id_request, + build_policy_assignments_get_request, + build_policy_assignments_list_for_management_group_request, + build_policy_assignments_list_for_resource_group_request, + build_policy_assignments_list_for_resource_request, + build_policy_assignments_list_request, + build_policy_definitions_create_or_update_at_management_group_request, + build_policy_definitions_create_or_update_request, + build_policy_definitions_delete_at_management_group_request, + build_policy_definitions_delete_request, + build_policy_definitions_get_at_management_group_request, + build_policy_definitions_get_built_in_request, + build_policy_definitions_get_request, + build_policy_definitions_list_built_in_request, + build_policy_definitions_list_by_management_group_request, + build_policy_definitions_list_request, + build_policy_exemptions_create_or_update_request, + build_policy_exemptions_delete_request, + build_policy_exemptions_get_request, + build_policy_exemptions_list_for_management_group_request, + build_policy_exemptions_list_for_resource_group_request, + build_policy_exemptions_list_for_resource_request, + build_policy_exemptions_list_request, + build_policy_set_definitions_create_or_update_at_management_group_request, + build_policy_set_definitions_create_or_update_request, + build_policy_set_definitions_delete_at_management_group_request, + build_policy_set_definitions_delete_request, + build_policy_set_definitions_get_at_management_group_request, + build_policy_set_definitions_get_built_in_request, + build_policy_set_definitions_get_request, + build_policy_set_definitions_list_built_in_request, + build_policy_set_definitions_list_by_management_group_request, + build_policy_set_definitions_list_request, +) + +T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] -class DataPolicyManifestsOperations: - """DataPolicyManifestsOperations async operations. - You should not instantiate this class directly. Instead, you should create a Client instance that - instantiates it for you and attaches it as an attribute. +class DataPolicyManifestsOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. - :ivar models: Alias to model classes used in this operation group. - :type models: ~azure.mgmt.resource.policy.v2020_09_01.models - :param client: Client for service requests. - :param config: Configuration of service client. - :param serializer: An object model serializer. - :param deserializer: An object model deserializer. + Instead, you should access the following operations through + :class:`~azure.mgmt.resource.policy.v2020_09_01.aio.PolicyClient`'s + :attr:`data_policy_manifests` attribute. """ models = _models - def __init__(self, client, config, serializer, deserializer) -> None: - self._client = client - self._serialize = serializer - self._deserialize = deserializer - self._config = config + def __init__(self, *args, **kwargs) -> None: + input_args = list(args) + self._client = input_args.pop(0) if input_args else kwargs.pop("client") + self._config = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") @distributed_trace_async - async def get_by_policy_mode( - self, - policy_mode: str, - **kwargs: Any - ) -> "_models.DataPolicyManifest": + async def get_by_policy_mode(self, policy_mode: str, **kwargs: Any) -> _models.DataPolicyManifest: """Retrieves a data policy manifest. This operation retrieves the data policy manifest with the given policy mode. - :param policy_mode: The policy mode of the data policy manifest to get. + :param policy_mode: The policy mode of the data policy manifest to get. Required. :type policy_mode: str - :keyword api_version: Api Version. Default value is "2020-09-01". Note that overriding this - default value may result in unsupported behavior. - :paramtype api_version: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: DataPolicyManifest, or the result of cls(response) + :return: DataPolicyManifest or the result of cls(response) :rtype: ~azure.mgmt.resource.policy.v2020_09_01.models.DataPolicyManifest - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.DataPolicyManifest"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + 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', "2020-09-01") # type: str + api_version = kwargs.pop("api_version", _params.pop("api-version", "2020-09-01")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[_models.DataPolicyManifest] - request = build_data_policy_manifests_get_by_policy_mode_request( policy_mode=policy_mode, api_version=api_version, - template_url=self.get_by_policy_mode.metadata['url'], + template_url=self.get_by_policy_mode.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) - deserialized = self._deserialize('DataPolicyManifest', pipeline_response) + deserialized = self._deserialize("DataPolicyManifest", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - get_by_policy_mode.metadata = {'url': "/providers/Microsoft.Authorization/dataPolicyManifests/{policyMode}"} # type: ignore - + get_by_policy_mode.metadata = {"url": "/providers/Microsoft.Authorization/dataPolicyManifests/{policyMode}"} # type: ignore @distributed_trace - def list( - self, - filter: Optional[str] = None, - **kwargs: Any - ) -> AsyncIterable["_models.DataPolicyManifestListResult"]: + def list(self, filter: Optional[str] = None, **kwargs: Any) -> AsyncIterable["_models.DataPolicyManifest"]: """Retrieves data policy manifests. This operation retrieves a list of all the data policy manifests that match the optional given @@ -122,41 +163,43 @@ def list( '{value}' is provided, the returned list only includes all data policy manifests that have a namespace matching the provided value. Default value is None. :type filter: str - :keyword api_version: Api Version. Default value is "2020-09-01". Note that overriding this - default value may result in unsupported behavior. - :paramtype api_version: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either DataPolicyManifestListResult or the result of - cls(response) + :return: An iterator like instance of either DataPolicyManifest or the result of cls(response) :rtype: - ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.resource.policy.v2020_09_01.models.DataPolicyManifestListResult] - :raises: ~azure.core.exceptions.HttpResponseError + ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.resource.policy.v2020_09_01.models.DataPolicyManifest] + :raises ~azure.core.exceptions.HttpResponseError: """ - api_version = kwargs.pop('api_version', "2020-09-01") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2020-09-01")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[_models.DataPolicyManifestListResult] - cls = kwargs.pop('cls', None) # type: ClsType["_models.DataPolicyManifestListResult"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) + def prepare_request(next_link=None): if not next_link: - + request = build_data_policy_manifests_list_request( - api_version=api_version, filter=filter, - template_url=self.list.metadata['url'], + 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.url = self._client.format_url(request.url) # type: ignore else: - - request = build_data_policy_manifests_list_request( - template_url=next_link, - ) + request = HttpRequest("GET", next_link) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore request.method = "GET" return request @@ -170,10 +213,8 @@ async def extract_data(pipeline_response): async def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) response = pipeline_response.http_response @@ -183,40 +224,34 @@ async def get_next(next_link=None): return pipeline_response + return AsyncItemPaged(get_next, extract_data) + + list.metadata = {"url": "/providers/Microsoft.Authorization/dataPolicyManifests"} # type: ignore - return AsyncItemPaged( - get_next, extract_data - ) - list.metadata = {'url': "/providers/Microsoft.Authorization/dataPolicyManifests"} # type: ignore -class PolicyAssignmentsOperations: - """PolicyAssignmentsOperations async operations. - You should not instantiate this class directly. Instead, you should create a Client instance that - instantiates it for you and attaches it as an attribute. +class PolicyAssignmentsOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. - :ivar models: Alias to model classes used in this operation group. - :type models: ~azure.mgmt.resource.policy.v2020_09_01.models - :param client: Client for service requests. - :param config: Configuration of service client. - :param serializer: An object model serializer. - :param deserializer: An object model deserializer. + Instead, you should access the following operations through + :class:`~azure.mgmt.resource.policy.v2020_09_01.aio.PolicyClient`'s + :attr:`policy_assignments` attribute. """ models = _models - def __init__(self, client, config, serializer, deserializer) -> None: - self._client = client - self._serialize = serializer - self._deserialize = deserializer - self._config = config + def __init__(self, *args, **kwargs) -> None: + input_args = list(args) + self._client = input_args.pop(0) if input_args else kwargs.pop("client") + self._config = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") @distributed_trace_async async def delete( - self, - scope: str, - policy_assignment_name: str, - **kwargs: Any - ) -> Optional["_models.PolicyAssignment"]: + self, scope: str, policy_assignment_name: str, **kwargs: Any + ) -> Optional[_models.PolicyAssignment]: """Deletes a policy assignment. This operation deletes a policy assignment, given its name and the scope it was created in. The @@ -228,40 +263,44 @@ async def delete( '/subscriptions/{subscriptionId}'), resource group (format: '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}', or resource (format: '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{resourceProviderNamespace}/[{parentResourcePath}/]{resourceType}/{resourceName}'. + Required. :type scope: str - :param policy_assignment_name: The name of the policy assignment to delete. + :param policy_assignment_name: The name of the policy assignment to delete. Required. :type policy_assignment_name: str - :keyword api_version: Api Version. Default value is "2020-09-01". Note that overriding this - default value may result in unsupported behavior. - :paramtype api_version: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: PolicyAssignment, or the result of cls(response) + :return: PolicyAssignment or None or the result of cls(response) :rtype: ~azure.mgmt.resource.policy.v2020_09_01.models.PolicyAssignment or None - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType[Optional["_models.PolicyAssignment"]] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) - api_version = kwargs.pop('api_version', "2020-09-01") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2020-09-01")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[Optional[_models.PolicyAssignment]] - request = build_policy_assignments_delete_request( scope=scope, policy_assignment_name=policy_assignment_name, api_version=api_version, - template_url=self.delete.metadata['url'], + template_url=self.delete.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200, 204]: @@ -270,24 +309,25 @@ async def delete( deserialized = None if response.status_code == 200: - deserialized = self._deserialize('PolicyAssignment', pipeline_response) + deserialized = self._deserialize("PolicyAssignment", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - delete.metadata = {'url': "/{scope}/providers/Microsoft.Authorization/policyAssignments/{policyAssignmentName}"} # type: ignore - + delete.metadata = {"url": "/{scope}/providers/Microsoft.Authorization/policyAssignments/{policyAssignmentName}"} # type: ignore - @distributed_trace_async + @overload async def create( self, scope: str, policy_assignment_name: str, - parameters: "_models.PolicyAssignment", + parameters: _models.PolicyAssignment, + *, + content_type: str = "application/json", **kwargs: Any - ) -> "_models.PolicyAssignment": + ) -> _models.PolicyAssignment: """Creates or updates a policy assignment. This operation creates or updates a policy assignment with the given scope and name. Policy @@ -299,29 +339,109 @@ async def create( '/subscriptions/{subscriptionId}'), resource group (format: '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}', or resource (format: '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{resourceProviderNamespace}/[{parentResourcePath}/]{resourceType}/{resourceName}'. + Required. :type scope: str - :param policy_assignment_name: The name of the policy assignment. + :param policy_assignment_name: The name of the policy assignment. Required. :type policy_assignment_name: str - :param parameters: Parameters for the policy assignment. + :param parameters: Parameters for the policy assignment. Required. :type parameters: ~azure.mgmt.resource.policy.v2020_09_01.models.PolicyAssignment - :keyword api_version: Api Version. Default value is "2020-09-01". Note that overriding this - default value may result in unsupported behavior. - :paramtype api_version: str + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: PolicyAssignment, or the result of cls(response) + :return: PolicyAssignment or the result of cls(response) :rtype: ~azure.mgmt.resource.policy.v2020_09_01.models.PolicyAssignment - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + async def create( + self, + scope: str, + policy_assignment_name: str, + parameters: IO, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.PolicyAssignment: + """Creates or updates a policy assignment. + + This operation creates or updates a policy assignment with the given scope and name. Policy + assignments apply to all resources contained within their scope. For example, when you assign a + policy at resource group scope, that policy applies to all resources in the group. + + :param scope: The scope of the policy assignment. Valid scopes are: management group (format: + '/providers/Microsoft.Management/managementGroups/{managementGroup}'), subscription (format: + '/subscriptions/{subscriptionId}'), resource group (format: + '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}', or resource (format: + '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{resourceProviderNamespace}/[{parentResourcePath}/]{resourceType}/{resourceName}'. + Required. + :type scope: str + :param policy_assignment_name: The name of the policy assignment. Required. + :type policy_assignment_name: str + :param parameters: Parameters for the policy assignment. Required. + :type parameters: IO + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: PolicyAssignment or the result of cls(response) + :rtype: ~azure.mgmt.resource.policy.v2020_09_01.models.PolicyAssignment + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace_async + async def create( + self, scope: str, policy_assignment_name: str, parameters: Union[_models.PolicyAssignment, IO], **kwargs: Any + ) -> _models.PolicyAssignment: + """Creates or updates a policy assignment. + + This operation creates or updates a policy assignment with the given scope and name. Policy + assignments apply to all resources contained within their scope. For example, when you assign a + policy at resource group scope, that policy applies to all resources in the group. + + :param scope: The scope of the policy assignment. Valid scopes are: management group (format: + '/providers/Microsoft.Management/managementGroups/{managementGroup}'), subscription (format: + '/subscriptions/{subscriptionId}'), resource group (format: + '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}', or resource (format: + '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{resourceProviderNamespace}/[{parentResourcePath}/]{resourceType}/{resourceName}'. + Required. + :type scope: str + :param policy_assignment_name: The name of the policy assignment. Required. + :type policy_assignment_name: str + :param parameters: Parameters for the policy assignment. Is either a model type or a IO type. + Required. + :type parameters: ~azure.mgmt.resource.policy.v2020_09_01.models.PolicyAssignment or IO + :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. + Default value is None. + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: PolicyAssignment or the result of cls(response) + :rtype: ~azure.mgmt.resource.policy.v2020_09_01.models.PolicyAssignment + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.PolicyAssignment"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', "2020-09-01") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + api_version = kwargs.pop("api_version", _params.pop("api-version", "2020-09-01")) # type: str + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.PolicyAssignment] - _json = self._serialize.body(parameters, 'PolicyAssignment') + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(parameters, (IO, bytes)): + _content = parameters + else: + _json = self._serialize.body(parameters, "PolicyAssignment") request = build_policy_assignments_create_request( scope=scope, @@ -329,39 +449,35 @@ async def create( api_version=api_version, content_type=content_type, json=_json, - template_url=self.create.metadata['url'], + content=_content, + template_url=self.create.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [201]: map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) - deserialized = self._deserialize('PolicyAssignment', pipeline_response) + deserialized = self._deserialize("PolicyAssignment", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - create.metadata = {'url': "/{scope}/providers/Microsoft.Authorization/policyAssignments/{policyAssignmentName}"} # type: ignore - + create.metadata = {"url": "/{scope}/providers/Microsoft.Authorization/policyAssignments/{policyAssignmentName}"} # type: ignore @distributed_trace_async - async def get( - self, - scope: str, - policy_assignment_name: str, - **kwargs: Any - ) -> "_models.PolicyAssignment": + async def get(self, scope: str, policy_assignment_name: str, **kwargs: Any) -> _models.PolicyAssignment: """Retrieves a policy assignment. This operation retrieves a single policy assignment, given its name and the scope it was @@ -372,64 +488,63 @@ async def get( '/subscriptions/{subscriptionId}'), resource group (format: '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}', or resource (format: '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{resourceProviderNamespace}/[{parentResourcePath}/]{resourceType}/{resourceName}'. + Required. :type scope: str - :param policy_assignment_name: The name of the policy assignment to get. + :param policy_assignment_name: The name of the policy assignment to get. Required. :type policy_assignment_name: str - :keyword api_version: Api Version. Default value is "2020-09-01". Note that overriding this - default value may result in unsupported behavior. - :paramtype api_version: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: PolicyAssignment, or the result of cls(response) + :return: PolicyAssignment or the result of cls(response) :rtype: ~azure.mgmt.resource.policy.v2020_09_01.models.PolicyAssignment - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.PolicyAssignment"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) - api_version = kwargs.pop('api_version', "2020-09-01") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2020-09-01")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[_models.PolicyAssignment] - request = build_policy_assignments_get_request( scope=scope, policy_assignment_name=policy_assignment_name, api_version=api_version, - template_url=self.get.metadata['url'], + template_url=self.get.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) - deserialized = self._deserialize('PolicyAssignment', pipeline_response) + deserialized = self._deserialize("PolicyAssignment", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - get.metadata = {'url': "/{scope}/providers/Microsoft.Authorization/policyAssignments/{policyAssignmentName}"} # type: ignore - + get.metadata = {"url": "/{scope}/providers/Microsoft.Authorization/policyAssignments/{policyAssignmentName}"} # type: ignore @distributed_trace def list_for_resource_group( - self, - resource_group_name: str, - filter: Optional[str] = None, - top: Optional[int] = None, - **kwargs: Any - ) -> AsyncIterable["_models.PolicyAssignmentListResult"]: + self, resource_group_name: str, filter: Optional[str] = None, top: Optional[int] = None, **kwargs: Any + ) -> AsyncIterable["_models.PolicyAssignment"]: """Retrieves all policy assignments that apply to a resource group. This operation retrieves the list of all policy assignments associated with the given resource @@ -446,6 +561,7 @@ def list_for_resource_group( is {value} that apply to the resource group. :param resource_group_name: The name of the resource group that contains policy assignments. + Required. :type resource_group_name: str :param filter: The filter to apply on the operation. Valid values for $filter are: 'atScope()', 'atExactScope()' or 'policyDefinitionId eq '{value}''. If $filter is not provided, no filtering @@ -459,46 +575,46 @@ def list_for_resource_group( :param top: Maximum number of records to return. When the $top filter is not provided, it will return 500 records. Default value is None. :type top: int - :keyword api_version: Api Version. Default value is "2020-09-01". Note that overriding this - default value may result in unsupported behavior. - :paramtype api_version: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either PolicyAssignmentListResult or the result of - cls(response) + :return: An iterator like instance of either PolicyAssignment or the result of cls(response) :rtype: - ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.resource.policy.v2020_09_01.models.PolicyAssignmentListResult] - :raises: ~azure.core.exceptions.HttpResponseError + ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.resource.policy.v2020_09_01.models.PolicyAssignment] + :raises ~azure.core.exceptions.HttpResponseError: """ - api_version = kwargs.pop('api_version', "2020-09-01") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2020-09-01")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[_models.PolicyAssignmentListResult] - cls = kwargs.pop('cls', None) # type: ClsType["_models.PolicyAssignmentListResult"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) + def prepare_request(next_link=None): if not next_link: - + request = build_policy_assignments_list_for_resource_group_request( resource_group_name=resource_group_name, subscription_id=self._config.subscription_id, - api_version=api_version, filter=filter, top=top, - template_url=self.list_for_resource_group.metadata['url'], + api_version=api_version, + template_url=self.list_for_resource_group.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore else: - - request = build_policy_assignments_list_for_resource_group_request( - resource_group_name=resource_group_name, - subscription_id=self._config.subscription_id, - template_url=next_link, - ) + request = HttpRequest("GET", next_link) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore request.method = "GET" return request @@ -512,10 +628,8 @@ async def extract_data(pipeline_response): async def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) response = pipeline_response.http_response @@ -525,11 +639,9 @@ async def get_next(next_link=None): return pipeline_response + return AsyncItemPaged(get_next, extract_data) - return AsyncItemPaged( - get_next, extract_data - ) - list_for_resource_group.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Authorization/policyAssignments"} # type: ignore + list_for_resource_group.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Authorization/policyAssignments"} # type: ignore @distributed_trace def list_for_resource( @@ -542,7 +654,7 @@ def list_for_resource( filter: Optional[str] = None, top: Optional[int] = None, **kwargs: Any - ) -> AsyncIterable["_models.PolicyAssignmentListResult"]: + ) -> AsyncIterable["_models.PolicyAssignment"]: """Retrieves all policy assignments that apply to a resource. This operation retrieves the list of all policy assignments associated with the specified @@ -569,17 +681,19 @@ def list_for_resource( {parentResourcePath} == '', {resourceType} == 'Microsoft.Web/sites', {resourceName} == 'MyWebApp'). - :param resource_group_name: The name of the resource group containing the resource. + :param resource_group_name: The name of the resource group containing the resource. Required. :type resource_group_name: str :param resource_provider_namespace: The namespace of the resource provider. For example, the namespace of a virtual machine is Microsoft.Compute (from Microsoft.Compute/virtualMachines). + Required. :type resource_provider_namespace: str :param parent_resource_path: The parent resource path. Use empty string if there is none. + Required. :type parent_resource_path: str :param resource_type: The resource type name. For example the type name of a web app is 'sites' - (from Microsoft.Web/sites). + (from Microsoft.Web/sites). Required. :type resource_type: str - :param resource_name: The name of the resource. + :param resource_name: The name of the resource. Required. :type resource_name: str :param filter: The filter to apply on the operation. Valid values for $filter are: 'atScope()', 'atExactScope()' or 'policyDefinitionId eq '{value}''. If $filter is not provided, no filtering @@ -593,26 +707,29 @@ def list_for_resource( :param top: Maximum number of records to return. When the $top filter is not provided, it will return 500 records. Default value is None. :type top: int - :keyword api_version: Api Version. Default value is "2020-09-01". Note that overriding this - default value may result in unsupported behavior. - :paramtype api_version: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either PolicyAssignmentListResult or the result of - cls(response) + :return: An iterator like instance of either PolicyAssignment or the result of cls(response) :rtype: - ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.resource.policy.v2020_09_01.models.PolicyAssignmentListResult] - :raises: ~azure.core.exceptions.HttpResponseError + ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.resource.policy.v2020_09_01.models.PolicyAssignment] + :raises ~azure.core.exceptions.HttpResponseError: """ - api_version = kwargs.pop('api_version', "2020-09-01") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2020-09-01")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[_models.PolicyAssignmentListResult] - cls = kwargs.pop('cls', None) # type: ClsType["_models.PolicyAssignmentListResult"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) + def prepare_request(next_link=None): if not next_link: - + request = build_policy_assignments_list_for_resource_request( resource_group_name=resource_group_name, resource_provider_namespace=resource_provider_namespace, @@ -620,27 +737,20 @@ def prepare_request(next_link=None): resource_type=resource_type, resource_name=resource_name, subscription_id=self._config.subscription_id, - api_version=api_version, filter=filter, top=top, - template_url=self.list_for_resource.metadata['url'], + api_version=api_version, + template_url=self.list_for_resource.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore else: - - request = build_policy_assignments_list_for_resource_request( - resource_group_name=resource_group_name, - resource_provider_namespace=resource_provider_namespace, - parent_resource_path=parent_resource_path, - resource_type=resource_type, - resource_name=resource_name, - subscription_id=self._config.subscription_id, - template_url=next_link, - ) + request = HttpRequest("GET", next_link) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore request.method = "GET" return request @@ -654,10 +764,8 @@ async def extract_data(pipeline_response): async def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) response = pipeline_response.http_response @@ -667,20 +775,14 @@ async def get_next(next_link=None): return pipeline_response + return AsyncItemPaged(get_next, extract_data) - return AsyncItemPaged( - get_next, extract_data - ) - list_for_resource.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{parentResourcePath}/{resourceType}/{resourceName}/providers/Microsoft.Authorization/policyAssignments"} # type: ignore + list_for_resource.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{parentResourcePath}/{resourceType}/{resourceName}/providers/Microsoft.Authorization/policyAssignments"} # type: ignore @distributed_trace def list_for_management_group( - self, - management_group_id: str, - filter: Optional[str] = None, - top: Optional[int] = None, - **kwargs: Any - ) -> AsyncIterable["_models.PolicyAssignmentListResult"]: + self, management_group_id: str, filter: Optional[str] = None, top: Optional[int] = None, **kwargs: Any + ) -> AsyncIterable["_models.PolicyAssignment"]: """Retrieves all policy assignments that apply to a management group. This operation retrieves the list of all policy assignments applicable to the management group @@ -692,7 +794,7 @@ def list_for_management_group( provided, the returned list includes all policy assignments of the policy definition whose id is {value} that apply to the management group. - :param management_group_id: The ID of the management group. + :param management_group_id: The ID of the management group. Required. :type management_group_id: str :param filter: The filter to apply on the operation. Valid values for $filter are: 'atScope()', 'atExactScope()' or 'policyDefinitionId eq '{value}''. If $filter is not provided, no filtering @@ -706,44 +808,45 @@ def list_for_management_group( :param top: Maximum number of records to return. When the $top filter is not provided, it will return 500 records. Default value is None. :type top: int - :keyword api_version: Api Version. Default value is "2020-09-01". Note that overriding this - default value may result in unsupported behavior. - :paramtype api_version: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either PolicyAssignmentListResult or the result of - cls(response) + :return: An iterator like instance of either PolicyAssignment or the result of cls(response) :rtype: - ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.resource.policy.v2020_09_01.models.PolicyAssignmentListResult] - :raises: ~azure.core.exceptions.HttpResponseError + ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.resource.policy.v2020_09_01.models.PolicyAssignment] + :raises ~azure.core.exceptions.HttpResponseError: """ - api_version = kwargs.pop('api_version', "2020-09-01") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2020-09-01")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[_models.PolicyAssignmentListResult] - cls = kwargs.pop('cls', None) # type: ClsType["_models.PolicyAssignmentListResult"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) + def prepare_request(next_link=None): if not next_link: - + request = build_policy_assignments_list_for_management_group_request( management_group_id=management_group_id, - api_version=api_version, filter=filter, top=top, - template_url=self.list_for_management_group.metadata['url'], + api_version=api_version, + template_url=self.list_for_management_group.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore else: - - request = build_policy_assignments_list_for_management_group_request( - management_group_id=management_group_id, - template_url=next_link, - ) + request = HttpRequest("GET", next_link) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore request.method = "GET" return request @@ -757,10 +860,8 @@ async def extract_data(pipeline_response): async def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) response = pipeline_response.http_response @@ -770,19 +871,14 @@ async def get_next(next_link=None): return pipeline_response + return AsyncItemPaged(get_next, extract_data) - return AsyncItemPaged( - get_next, extract_data - ) - list_for_management_group.metadata = {'url': "/providers/Microsoft.Management/managementGroups/{managementGroupId}/providers/Microsoft.Authorization/policyAssignments"} # type: ignore + list_for_management_group.metadata = {"url": "/providers/Microsoft.Management/managementGroups/{managementGroupId}/providers/Microsoft.Authorization/policyAssignments"} # type: ignore @distributed_trace def list( - self, - filter: Optional[str] = None, - top: Optional[int] = None, - **kwargs: Any - ) -> AsyncIterable["_models.PolicyAssignmentListResult"]: + self, filter: Optional[str] = None, top: Optional[int] = None, **kwargs: Any + ) -> AsyncIterable["_models.PolicyAssignment"]: """Retrieves all policy assignments that apply to a subscription. This operation retrieves the list of all policy assignments associated with the given @@ -809,44 +905,45 @@ def list( :param top: Maximum number of records to return. When the $top filter is not provided, it will return 500 records. Default value is None. :type top: int - :keyword api_version: Api Version. Default value is "2020-09-01". Note that overriding this - default value may result in unsupported behavior. - :paramtype api_version: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either PolicyAssignmentListResult or the result of - cls(response) + :return: An iterator like instance of either PolicyAssignment or the result of cls(response) :rtype: - ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.resource.policy.v2020_09_01.models.PolicyAssignmentListResult] - :raises: ~azure.core.exceptions.HttpResponseError + ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.resource.policy.v2020_09_01.models.PolicyAssignment] + :raises ~azure.core.exceptions.HttpResponseError: """ - api_version = kwargs.pop('api_version', "2020-09-01") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2020-09-01")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[_models.PolicyAssignmentListResult] - cls = kwargs.pop('cls', None) # type: ClsType["_models.PolicyAssignmentListResult"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) + def prepare_request(next_link=None): if not next_link: - + request = build_policy_assignments_list_request( subscription_id=self._config.subscription_id, - api_version=api_version, filter=filter, top=top, - template_url=self.list.metadata['url'], + 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.url = self._client.format_url(request.url) # type: ignore else: - - request = build_policy_assignments_list_request( - subscription_id=self._config.subscription_id, - template_url=next_link, - ) + request = HttpRequest("GET", next_link) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore request.method = "GET" return request @@ -860,10 +957,8 @@ async def extract_data(pipeline_response): async def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) response = pipeline_response.http_response @@ -873,18 +968,12 @@ async def get_next(next_link=None): return pipeline_response + return AsyncItemPaged(get_next, extract_data) - return AsyncItemPaged( - get_next, extract_data - ) - list.metadata = {'url': "/subscriptions/{subscriptionId}/providers/Microsoft.Authorization/policyAssignments"} # type: ignore + list.metadata = {"url": "/subscriptions/{subscriptionId}/providers/Microsoft.Authorization/policyAssignments"} # type: ignore @distributed_trace_async - async def delete_by_id( - self, - policy_assignment_id: str, - **kwargs: Any - ) -> Optional["_models.PolicyAssignment"]: + async def delete_by_id(self, policy_assignment_id: str, **kwargs: Any) -> Optional[_models.PolicyAssignment]: """Deletes a policy assignment. This operation deletes the policy with the given ID. Policy assignment IDs have this format: @@ -896,38 +985,41 @@ async def delete_by_id( (resource). :param policy_assignment_id: The ID of the policy assignment to delete. Use the format - '{scope}/providers/Microsoft.Authorization/policyAssignments/{policyAssignmentName}'. + '{scope}/providers/Microsoft.Authorization/policyAssignments/{policyAssignmentName}'. Required. :type policy_assignment_id: str - :keyword api_version: Api Version. Default value is "2020-09-01". Note that overriding this - default value may result in unsupported behavior. - :paramtype api_version: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: PolicyAssignment, or the result of cls(response) + :return: PolicyAssignment or None or the result of cls(response) :rtype: ~azure.mgmt.resource.policy.v2020_09_01.models.PolicyAssignment or None - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType[Optional["_models.PolicyAssignment"]] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + 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', "2020-09-01") # type: str + api_version = kwargs.pop("api_version", _params.pop("api-version", "2020-09-01")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[Optional[_models.PolicyAssignment]] - request = build_policy_assignments_delete_by_id_request( policy_assignment_id=policy_assignment_id, api_version=api_version, - template_url=self.delete_by_id.metadata['url'], + template_url=self.delete_by_id.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200, 204]: @@ -936,23 +1028,24 @@ async def delete_by_id( deserialized = None if response.status_code == 200: - deserialized = self._deserialize('PolicyAssignment', pipeline_response) + deserialized = self._deserialize("PolicyAssignment", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - delete_by_id.metadata = {'url': "/{policyAssignmentId}"} # type: ignore + delete_by_id.metadata = {"url": "/{policyAssignmentId}"} # type: ignore - - @distributed_trace_async + @overload async def create_by_id( self, policy_assignment_id: str, - parameters: "_models.PolicyAssignment", + parameters: _models.PolicyAssignment, + *, + content_type: str = "application/json", **kwargs: Any - ) -> "_models.PolicyAssignment": + ) -> _models.PolicyAssignment: """Creates or updates a policy assignment. This operation creates or updates the policy assignment with the given ID. Policy assignments @@ -967,66 +1060,138 @@ async def create_by_id( '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{resourceProviderNamespace}/[{parentResourcePath}/]{resourceType}/{resourceName}'. :param policy_assignment_id: The ID of the policy assignment to create. Use the format - '{scope}/providers/Microsoft.Authorization/policyAssignments/{policyAssignmentName}'. + '{scope}/providers/Microsoft.Authorization/policyAssignments/{policyAssignmentName}'. Required. :type policy_assignment_id: str - :param parameters: Parameters for policy assignment. + :param parameters: Parameters for policy assignment. Required. :type parameters: ~azure.mgmt.resource.policy.v2020_09_01.models.PolicyAssignment - :keyword api_version: Api Version. Default value is "2020-09-01". Note that overriding this - default value may result in unsupported behavior. - :paramtype api_version: str + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: PolicyAssignment, or the result of cls(response) + :return: PolicyAssignment or the result of cls(response) :rtype: ~azure.mgmt.resource.policy.v2020_09_01.models.PolicyAssignment - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + async def create_by_id( + self, policy_assignment_id: str, parameters: IO, *, content_type: str = "application/json", **kwargs: Any + ) -> _models.PolicyAssignment: + """Creates or updates a policy assignment. + + This operation creates or updates the policy assignment with the given ID. Policy assignments + made on a scope apply to all resources contained in that scope. For example, when you assign a + policy to a resource group that policy applies to all resources in the group. Policy assignment + IDs have this format: + '{scope}/providers/Microsoft.Authorization/policyAssignments/{policyAssignmentName}'. Valid + scopes are: management group (format: + '/providers/Microsoft.Management/managementGroups/{managementGroup}'), subscription (format: + '/subscriptions/{subscriptionId}'), resource group (format: + '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}', or resource (format: + '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{resourceProviderNamespace}/[{parentResourcePath}/]{resourceType}/{resourceName}'. + + :param policy_assignment_id: The ID of the policy assignment to create. Use the format + '{scope}/providers/Microsoft.Authorization/policyAssignments/{policyAssignmentName}'. Required. + :type policy_assignment_id: str + :param parameters: Parameters for policy assignment. Required. + :type parameters: IO + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: PolicyAssignment or the result of cls(response) + :rtype: ~azure.mgmt.resource.policy.v2020_09_01.models.PolicyAssignment + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace_async + async def create_by_id( + self, policy_assignment_id: str, parameters: Union[_models.PolicyAssignment, IO], **kwargs: Any + ) -> _models.PolicyAssignment: + """Creates or updates a policy assignment. + + This operation creates or updates the policy assignment with the given ID. Policy assignments + made on a scope apply to all resources contained in that scope. For example, when you assign a + policy to a resource group that policy applies to all resources in the group. Policy assignment + IDs have this format: + '{scope}/providers/Microsoft.Authorization/policyAssignments/{policyAssignmentName}'. Valid + scopes are: management group (format: + '/providers/Microsoft.Management/managementGroups/{managementGroup}'), subscription (format: + '/subscriptions/{subscriptionId}'), resource group (format: + '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}', or resource (format: + '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{resourceProviderNamespace}/[{parentResourcePath}/]{resourceType}/{resourceName}'. + + :param policy_assignment_id: The ID of the policy assignment to create. Use the format + '{scope}/providers/Microsoft.Authorization/policyAssignments/{policyAssignmentName}'. Required. + :type policy_assignment_id: str + :param parameters: Parameters for policy assignment. Is either a model type or a IO type. + Required. + :type parameters: ~azure.mgmt.resource.policy.v2020_09_01.models.PolicyAssignment or IO + :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. + Default value is None. + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: PolicyAssignment or the result of cls(response) + :rtype: ~azure.mgmt.resource.policy.v2020_09_01.models.PolicyAssignment + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.PolicyAssignment"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) - api_version = kwargs.pop('api_version', "2020-09-01") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - _json = self._serialize.body(parameters, 'PolicyAssignment') + api_version = kwargs.pop("api_version", _params.pop("api-version", "2020-09-01")) # type: str + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.PolicyAssignment] + + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(parameters, (IO, bytes)): + _content = parameters + else: + _json = self._serialize.body(parameters, "PolicyAssignment") request = build_policy_assignments_create_by_id_request( policy_assignment_id=policy_assignment_id, api_version=api_version, content_type=content_type, json=_json, - template_url=self.create_by_id.metadata['url'], + content=_content, + template_url=self.create_by_id.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [201]: map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) - deserialized = self._deserialize('PolicyAssignment', pipeline_response) + deserialized = self._deserialize("PolicyAssignment", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - create_by_id.metadata = {'url': "/{policyAssignmentId}"} # type: ignore - + create_by_id.metadata = {"url": "/{policyAssignmentId}"} # type: ignore @distributed_trace_async - async def get_by_id( - self, - policy_assignment_id: str, - **kwargs: Any - ) -> "_models.PolicyAssignment": + async def get_by_id(self, policy_assignment_id: str, **kwargs: Any) -> _models.PolicyAssignment: """Retrieves the policy assignment with the given ID. The operation retrieves the policy assignment with the given ID. Policy assignment IDs have @@ -1039,109 +1204,169 @@ async def get_by_id( '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{resourceProviderNamespace}/[{parentResourcePath}/]{resourceType}/{resourceName}'. :param policy_assignment_id: The ID of the policy assignment to get. Use the format - '{scope}/providers/Microsoft.Authorization/policyAssignments/{policyAssignmentName}'. + '{scope}/providers/Microsoft.Authorization/policyAssignments/{policyAssignmentName}'. Required. :type policy_assignment_id: str - :keyword api_version: Api Version. Default value is "2020-09-01". Note that overriding this - default value may result in unsupported behavior. - :paramtype api_version: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: PolicyAssignment, or the result of cls(response) + :return: PolicyAssignment or the result of cls(response) :rtype: ~azure.mgmt.resource.policy.v2020_09_01.models.PolicyAssignment - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.PolicyAssignment"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) - api_version = kwargs.pop('api_version', "2020-09-01") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2020-09-01")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[_models.PolicyAssignment] - request = build_policy_assignments_get_by_id_request( policy_assignment_id=policy_assignment_id, api_version=api_version, - template_url=self.get_by_id.metadata['url'], + template_url=self.get_by_id.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) - deserialized = self._deserialize('PolicyAssignment', pipeline_response) + deserialized = self._deserialize("PolicyAssignment", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - get_by_id.metadata = {'url': "/{policyAssignmentId}"} # type: ignore + get_by_id.metadata = {"url": "/{policyAssignmentId}"} # type: ignore -class PolicyDefinitionsOperations: - """PolicyDefinitionsOperations async operations. - You should not instantiate this class directly. Instead, you should create a Client instance that - instantiates it for you and attaches it as an attribute. +class PolicyDefinitionsOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. - :ivar models: Alias to model classes used in this operation group. - :type models: ~azure.mgmt.resource.policy.v2020_09_01.models - :param client: Client for service requests. - :param config: Configuration of service client. - :param serializer: An object model serializer. - :param deserializer: An object model deserializer. + Instead, you should access the following operations through + :class:`~azure.mgmt.resource.policy.v2020_09_01.aio.PolicyClient`'s + :attr:`policy_definitions` attribute. """ models = _models - def __init__(self, client, config, serializer, deserializer) -> None: - self._client = client - self._serialize = serializer - self._deserialize = deserializer - self._config = config + def __init__(self, *args, **kwargs) -> None: + input_args = list(args) + self._client = input_args.pop(0) if input_args else kwargs.pop("client") + self._config = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") - @distributed_trace_async + @overload async def create_or_update( self, policy_definition_name: str, - parameters: "_models.PolicyDefinition", + parameters: _models.PolicyDefinition, + *, + content_type: str = "application/json", **kwargs: Any - ) -> "_models.PolicyDefinition": + ) -> _models.PolicyDefinition: """Creates or updates a policy definition in a subscription. This operation creates or updates a policy definition in the given subscription with the given name. - :param policy_definition_name: The name of the policy definition to create. + :param policy_definition_name: The name of the policy definition to create. Required. :type policy_definition_name: str - :param parameters: The policy definition properties. + :param parameters: The policy definition properties. Required. :type parameters: ~azure.mgmt.resource.policy.v2020_09_01.models.PolicyDefinition - :keyword api_version: Api Version. Default value is "2020-09-01". Note that overriding this - default value may result in unsupported behavior. - :paramtype api_version: str + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: PolicyDefinition or the result of cls(response) + :rtype: ~azure.mgmt.resource.policy.v2020_09_01.models.PolicyDefinition + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + async def create_or_update( + self, policy_definition_name: str, parameters: IO, *, content_type: str = "application/json", **kwargs: Any + ) -> _models.PolicyDefinition: + """Creates or updates a policy definition in a subscription. + + This operation creates or updates a policy definition in the given subscription with the given + name. + + :param policy_definition_name: The name of the policy definition to create. Required. + :type policy_definition_name: str + :param parameters: The policy definition properties. Required. + :type parameters: IO + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: PolicyDefinition or the result of cls(response) + :rtype: ~azure.mgmt.resource.policy.v2020_09_01.models.PolicyDefinition + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace_async + async def create_or_update( + self, policy_definition_name: str, parameters: Union[_models.PolicyDefinition, IO], **kwargs: Any + ) -> _models.PolicyDefinition: + """Creates or updates a policy definition in a subscription. + + This operation creates or updates a policy definition in the given subscription with the given + name. + + :param policy_definition_name: The name of the policy definition to create. Required. + :type policy_definition_name: str + :param parameters: The policy definition properties. Is either a model type or a IO type. + Required. + :type parameters: ~azure.mgmt.resource.policy.v2020_09_01.models.PolicyDefinition or IO + :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. + Default value is None. + :paramtype content_type: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: PolicyDefinition, or the result of cls(response) + :return: PolicyDefinition or the result of cls(response) :rtype: ~azure.mgmt.resource.policy.v2020_09_01.models.PolicyDefinition - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.PolicyDefinition"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) - api_version = kwargs.pop('api_version', "2020-09-01") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - _json = self._serialize.body(parameters, 'PolicyDefinition') + api_version = kwargs.pop("api_version", _params.pop("api-version", "2020-09-01")) # type: str + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.PolicyDefinition] + + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(parameters, (IO, bytes)): + _content = parameters + else: + _json = self._serialize.body(parameters, "PolicyDefinition") request = build_policy_definitions_create_or_update_request( policy_definition_name=policy_definition_name, @@ -1149,75 +1374,77 @@ async def create_or_update( api_version=api_version, content_type=content_type, json=_json, - template_url=self.create_or_update.metadata['url'], + content=_content, + template_url=self.create_or_update.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [201]: map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) - deserialized = self._deserialize('PolicyDefinition', pipeline_response) + deserialized = self._deserialize("PolicyDefinition", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - create_or_update.metadata = {'url': "/subscriptions/{subscriptionId}/providers/Microsoft.Authorization/policyDefinitions/{policyDefinitionName}"} # type: ignore - + create_or_update.metadata = {"url": "/subscriptions/{subscriptionId}/providers/Microsoft.Authorization/policyDefinitions/{policyDefinitionName}"} # type: ignore @distributed_trace_async async def delete( # pylint: disable=inconsistent-return-statements - self, - policy_definition_name: str, - **kwargs: Any + self, policy_definition_name: str, **kwargs: Any ) -> None: """Deletes a policy definition in a subscription. This operation deletes the policy definition in the given subscription with the given name. - :param policy_definition_name: The name of the policy definition to delete. + :param policy_definition_name: The name of the policy definition to delete. Required. :type policy_definition_name: str - :keyword api_version: Api Version. Default value is "2020-09-01". Note that overriding this - default value may result in unsupported behavior. - :paramtype api_version: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: None, or the result of cls(response) + :return: None or the result of cls(response) :rtype: None - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType[None] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + 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', "2020-09-01") # type: str + api_version = kwargs.pop("api_version", _params.pop("api-version", "2020-09-01")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[None] - request = build_policy_definitions_delete_request( policy_definition_name=policy_definition_name, subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.delete.metadata['url'], + template_url=self.delete.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200, 204]: @@ -1227,163 +1454,231 @@ async def delete( # pylint: disable=inconsistent-return-statements if cls: return cls(pipeline_response, None, {}) - delete.metadata = {'url': "/subscriptions/{subscriptionId}/providers/Microsoft.Authorization/policyDefinitions/{policyDefinitionName}"} # type: ignore - + delete.metadata = {"url": "/subscriptions/{subscriptionId}/providers/Microsoft.Authorization/policyDefinitions/{policyDefinitionName}"} # type: ignore @distributed_trace_async - async def get( - self, - policy_definition_name: str, - **kwargs: Any - ) -> "_models.PolicyDefinition": + async def get(self, policy_definition_name: str, **kwargs: Any) -> _models.PolicyDefinition: """Retrieves a policy definition in a subscription. This operation retrieves the policy definition in the given subscription with the given name. - :param policy_definition_name: The name of the policy definition to get. + :param policy_definition_name: The name of the policy definition to get. Required. :type policy_definition_name: str - :keyword api_version: Api Version. Default value is "2020-09-01". Note that overriding this - default value may result in unsupported behavior. - :paramtype api_version: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: PolicyDefinition, or the result of cls(response) + :return: PolicyDefinition or the result of cls(response) :rtype: ~azure.mgmt.resource.policy.v2020_09_01.models.PolicyDefinition - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.PolicyDefinition"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + 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', "2020-09-01") # type: str + api_version = kwargs.pop("api_version", _params.pop("api-version", "2020-09-01")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[_models.PolicyDefinition] - request = build_policy_definitions_get_request( policy_definition_name=policy_definition_name, subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.get.metadata['url'], + template_url=self.get.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) - deserialized = self._deserialize('PolicyDefinition', pipeline_response) + deserialized = self._deserialize("PolicyDefinition", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - get.metadata = {'url': "/subscriptions/{subscriptionId}/providers/Microsoft.Authorization/policyDefinitions/{policyDefinitionName}"} # type: ignore - + get.metadata = {"url": "/subscriptions/{subscriptionId}/providers/Microsoft.Authorization/policyDefinitions/{policyDefinitionName}"} # type: ignore @distributed_trace_async - async def get_built_in( - self, - policy_definition_name: str, - **kwargs: Any - ) -> "_models.PolicyDefinition": + async def get_built_in(self, policy_definition_name: str, **kwargs: Any) -> _models.PolicyDefinition: """Retrieves a built-in policy definition. This operation retrieves the built-in policy definition with the given name. - :param policy_definition_name: The name of the built-in policy definition to get. + :param policy_definition_name: The name of the built-in policy definition to get. Required. :type policy_definition_name: str - :keyword api_version: Api Version. Default value is "2020-09-01". Note that overriding this - default value may result in unsupported behavior. - :paramtype api_version: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: PolicyDefinition, or the result of cls(response) + :return: PolicyDefinition or the result of cls(response) :rtype: ~azure.mgmt.resource.policy.v2020_09_01.models.PolicyDefinition - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.PolicyDefinition"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + 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', "2020-09-01") # type: str + api_version = kwargs.pop("api_version", _params.pop("api-version", "2020-09-01")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[_models.PolicyDefinition] - request = build_policy_definitions_get_built_in_request( policy_definition_name=policy_definition_name, api_version=api_version, - template_url=self.get_built_in.metadata['url'], + template_url=self.get_built_in.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) - deserialized = self._deserialize('PolicyDefinition', pipeline_response) + deserialized = self._deserialize("PolicyDefinition", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - get_built_in.metadata = {'url': "/providers/Microsoft.Authorization/policyDefinitions/{policyDefinitionName}"} # type: ignore + get_built_in.metadata = {"url": "/providers/Microsoft.Authorization/policyDefinitions/{policyDefinitionName}"} # type: ignore + + @overload + async def create_or_update_at_management_group( + self, + policy_definition_name: str, + management_group_id: str, + parameters: _models.PolicyDefinition, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.PolicyDefinition: + """Creates or updates a policy definition in a management group. + + This operation creates or updates a policy definition in the given management group with the + given name. + + :param policy_definition_name: The name of the policy definition to create. Required. + :type policy_definition_name: str + :param management_group_id: The ID of the management group. Required. + :type management_group_id: str + :param parameters: The policy definition properties. Required. + :type parameters: ~azure.mgmt.resource.policy.v2020_09_01.models.PolicyDefinition + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: PolicyDefinition or the result of cls(response) + :rtype: ~azure.mgmt.resource.policy.v2020_09_01.models.PolicyDefinition + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + async def create_or_update_at_management_group( + self, + policy_definition_name: str, + management_group_id: str, + parameters: IO, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.PolicyDefinition: + """Creates or updates a policy definition in a management group. + This operation creates or updates a policy definition in the given management group with the + given name. + + :param policy_definition_name: The name of the policy definition to create. Required. + :type policy_definition_name: str + :param management_group_id: The ID of the management group. Required. + :type management_group_id: str + :param parameters: The policy definition properties. Required. + :type parameters: IO + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: PolicyDefinition or the result of cls(response) + :rtype: ~azure.mgmt.resource.policy.v2020_09_01.models.PolicyDefinition + :raises ~azure.core.exceptions.HttpResponseError: + """ @distributed_trace_async async def create_or_update_at_management_group( self, policy_definition_name: str, management_group_id: str, - parameters: "_models.PolicyDefinition", + parameters: Union[_models.PolicyDefinition, IO], **kwargs: Any - ) -> "_models.PolicyDefinition": + ) -> _models.PolicyDefinition: """Creates or updates a policy definition in a management group. This operation creates or updates a policy definition in the given management group with the given name. - :param policy_definition_name: The name of the policy definition to create. + :param policy_definition_name: The name of the policy definition to create. Required. :type policy_definition_name: str - :param management_group_id: The ID of the management group. + :param management_group_id: The ID of the management group. Required. :type management_group_id: str - :param parameters: The policy definition properties. - :type parameters: ~azure.mgmt.resource.policy.v2020_09_01.models.PolicyDefinition - :keyword api_version: Api Version. Default value is "2020-09-01". Note that overriding this - default value may result in unsupported behavior. - :paramtype api_version: str + :param parameters: The policy definition properties. Is either a model type or a IO type. + Required. + :type parameters: ~azure.mgmt.resource.policy.v2020_09_01.models.PolicyDefinition or IO + :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. + Default value is None. + :paramtype content_type: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: PolicyDefinition, or the result of cls(response) + :return: PolicyDefinition or the result of cls(response) :rtype: ~azure.mgmt.resource.policy.v2020_09_01.models.PolicyDefinition - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.PolicyDefinition"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', "2020-09-01") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + api_version = kwargs.pop("api_version", _params.pop("api-version", "2020-09-01")) # type: str + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.PolicyDefinition] - _json = self._serialize.body(parameters, 'PolicyDefinition') + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(parameters, (IO, bytes)): + _content = parameters + else: + _json = self._serialize.body(parameters, "PolicyDefinition") request = build_policy_definitions_create_or_update_at_management_group_request( policy_definition_name=policy_definition_name, @@ -1391,78 +1686,79 @@ async def create_or_update_at_management_group( api_version=api_version, content_type=content_type, json=_json, - template_url=self.create_or_update_at_management_group.metadata['url'], + content=_content, + template_url=self.create_or_update_at_management_group.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [201]: map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) - deserialized = self._deserialize('PolicyDefinition', pipeline_response) + deserialized = self._deserialize("PolicyDefinition", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - create_or_update_at_management_group.metadata = {'url': "/providers/Microsoft.Management/managementGroups/{managementGroupId}/providers/Microsoft.Authorization/policyDefinitions/{policyDefinitionName}"} # type: ignore - + create_or_update_at_management_group.metadata = {"url": "/providers/Microsoft.Management/managementGroups/{managementGroupId}/providers/Microsoft.Authorization/policyDefinitions/{policyDefinitionName}"} # type: ignore @distributed_trace_async async def delete_at_management_group( # pylint: disable=inconsistent-return-statements - self, - policy_definition_name: str, - management_group_id: str, - **kwargs: Any + self, policy_definition_name: str, management_group_id: str, **kwargs: Any ) -> None: """Deletes a policy definition in a management group. This operation deletes the policy definition in the given management group with the given name. - :param policy_definition_name: The name of the policy definition to delete. + :param policy_definition_name: The name of the policy definition to delete. Required. :type policy_definition_name: str - :param management_group_id: The ID of the management group. + :param management_group_id: The ID of the management group. Required. :type management_group_id: str - :keyword api_version: Api Version. Default value is "2020-09-01". Note that overriding this - default value may result in unsupported behavior. - :paramtype api_version: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: None, or the result of cls(response) + :return: None or the result of cls(response) :rtype: None - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType[None] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + 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', "2020-09-01") # type: str + api_version = kwargs.pop("api_version", _params.pop("api-version", "2020-09-01")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[None] - request = build_policy_definitions_delete_at_management_group_request( policy_definition_name=policy_definition_name, management_group_id=management_group_id, api_version=api_version, - template_url=self.delete_at_management_group.metadata['url'], + template_url=self.delete_at_management_group.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200, 204]: @@ -1472,79 +1768,74 @@ async def delete_at_management_group( # pylint: disable=inconsistent-return-sta if cls: return cls(pipeline_response, None, {}) - delete_at_management_group.metadata = {'url': "/providers/Microsoft.Management/managementGroups/{managementGroupId}/providers/Microsoft.Authorization/policyDefinitions/{policyDefinitionName}"} # type: ignore - + delete_at_management_group.metadata = {"url": "/providers/Microsoft.Management/managementGroups/{managementGroupId}/providers/Microsoft.Authorization/policyDefinitions/{policyDefinitionName}"} # type: ignore @distributed_trace_async async def get_at_management_group( - self, - policy_definition_name: str, - management_group_id: str, - **kwargs: Any - ) -> "_models.PolicyDefinition": + self, policy_definition_name: str, management_group_id: str, **kwargs: Any + ) -> _models.PolicyDefinition: """Retrieve a policy definition in a management group. This operation retrieves the policy definition in the given management group with the given name. - :param policy_definition_name: The name of the policy definition to get. + :param policy_definition_name: The name of the policy definition to get. Required. :type policy_definition_name: str - :param management_group_id: The ID of the management group. + :param management_group_id: The ID of the management group. Required. :type management_group_id: str - :keyword api_version: Api Version. Default value is "2020-09-01". Note that overriding this - default value may result in unsupported behavior. - :paramtype api_version: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: PolicyDefinition, or the result of cls(response) + :return: PolicyDefinition or the result of cls(response) :rtype: ~azure.mgmt.resource.policy.v2020_09_01.models.PolicyDefinition - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.PolicyDefinition"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + 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', "2020-09-01") # type: str + api_version = kwargs.pop("api_version", _params.pop("api-version", "2020-09-01")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[_models.PolicyDefinition] - request = build_policy_definitions_get_at_management_group_request( policy_definition_name=policy_definition_name, management_group_id=management_group_id, api_version=api_version, - template_url=self.get_at_management_group.metadata['url'], + template_url=self.get_at_management_group.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) - deserialized = self._deserialize('PolicyDefinition', pipeline_response) + deserialized = self._deserialize("PolicyDefinition", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - get_at_management_group.metadata = {'url': "/providers/Microsoft.Management/managementGroups/{managementGroupId}/providers/Microsoft.Authorization/policyDefinitions/{policyDefinitionName}"} # type: ignore - + get_at_management_group.metadata = {"url": "/providers/Microsoft.Management/managementGroups/{managementGroupId}/providers/Microsoft.Authorization/policyDefinitions/{policyDefinitionName}"} # type: ignore @distributed_trace def list( - self, - filter: Optional[str] = None, - top: Optional[int] = None, - **kwargs: Any - ) -> AsyncIterable["_models.PolicyDefinitionListResult"]: + self, filter: Optional[str] = None, top: Optional[int] = None, **kwargs: Any + ) -> AsyncIterable["_models.PolicyDefinition"]: """Retrieves policy definitions in a subscription. This operation retrieves a list of all the policy definitions in a given subscription that @@ -1570,44 +1861,45 @@ def list( :param top: Maximum number of records to return. When the $top filter is not provided, it will return 500 records. Default value is None. :type top: int - :keyword api_version: Api Version. Default value is "2020-09-01". Note that overriding this - default value may result in unsupported behavior. - :paramtype api_version: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either PolicyDefinitionListResult or the result of - cls(response) + :return: An iterator like instance of either PolicyDefinition or the result of cls(response) :rtype: - ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.resource.policy.v2020_09_01.models.PolicyDefinitionListResult] - :raises: ~azure.core.exceptions.HttpResponseError + ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.resource.policy.v2020_09_01.models.PolicyDefinition] + :raises ~azure.core.exceptions.HttpResponseError: """ - api_version = kwargs.pop('api_version', "2020-09-01") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2020-09-01")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[_models.PolicyDefinitionListResult] - cls = kwargs.pop('cls', None) # type: ClsType["_models.PolicyDefinitionListResult"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) + def prepare_request(next_link=None): if not next_link: - + request = build_policy_definitions_list_request( subscription_id=self._config.subscription_id, - api_version=api_version, filter=filter, top=top, - template_url=self.list.metadata['url'], + 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.url = self._client.format_url(request.url) # type: ignore else: - - request = build_policy_definitions_list_request( - subscription_id=self._config.subscription_id, - template_url=next_link, - ) + request = HttpRequest("GET", next_link) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore request.method = "GET" return request @@ -1621,10 +1913,8 @@ async def extract_data(pipeline_response): async def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) response = pipeline_response.http_response @@ -1634,19 +1924,14 @@ async def get_next(next_link=None): return pipeline_response + return AsyncItemPaged(get_next, extract_data) - return AsyncItemPaged( - get_next, extract_data - ) - list.metadata = {'url': "/subscriptions/{subscriptionId}/providers/Microsoft.Authorization/policyDefinitions"} # type: ignore + list.metadata = {"url": "/subscriptions/{subscriptionId}/providers/Microsoft.Authorization/policyDefinitions"} # type: ignore @distributed_trace def list_built_in( - self, - filter: Optional[str] = None, - top: Optional[int] = None, - **kwargs: Any - ) -> AsyncIterable["_models.PolicyDefinitionListResult"]: + self, filter: Optional[str] = None, top: Optional[int] = None, **kwargs: Any + ) -> AsyncIterable["_models.PolicyDefinition"]: """Retrieve built-in policy definitions. This operation retrieves a list of all the built-in policy definitions that match the optional @@ -1667,42 +1952,44 @@ def list_built_in( :param top: Maximum number of records to return. When the $top filter is not provided, it will return 500 records. Default value is None. :type top: int - :keyword api_version: Api Version. Default value is "2020-09-01". Note that overriding this - default value may result in unsupported behavior. - :paramtype api_version: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either PolicyDefinitionListResult or the result of - cls(response) + :return: An iterator like instance of either PolicyDefinition or the result of cls(response) :rtype: - ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.resource.policy.v2020_09_01.models.PolicyDefinitionListResult] - :raises: ~azure.core.exceptions.HttpResponseError + ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.resource.policy.v2020_09_01.models.PolicyDefinition] + :raises ~azure.core.exceptions.HttpResponseError: """ - api_version = kwargs.pop('api_version', "2020-09-01") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2020-09-01")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[_models.PolicyDefinitionListResult] - cls = kwargs.pop('cls', None) # type: ClsType["_models.PolicyDefinitionListResult"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) + def prepare_request(next_link=None): if not next_link: - + request = build_policy_definitions_list_built_in_request( - api_version=api_version, filter=filter, top=top, - template_url=self.list_built_in.metadata['url'], + api_version=api_version, + template_url=self.list_built_in.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore else: - - request = build_policy_definitions_list_built_in_request( - template_url=next_link, - ) + request = HttpRequest("GET", next_link) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore request.method = "GET" return request @@ -1716,10 +2003,8 @@ async def extract_data(pipeline_response): async def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) response = pipeline_response.http_response @@ -1729,20 +2014,14 @@ async def get_next(next_link=None): return pipeline_response + return AsyncItemPaged(get_next, extract_data) - return AsyncItemPaged( - get_next, extract_data - ) - list_built_in.metadata = {'url': "/providers/Microsoft.Authorization/policyDefinitions"} # type: ignore + list_built_in.metadata = {"url": "/providers/Microsoft.Authorization/policyDefinitions"} # type: ignore @distributed_trace def list_by_management_group( - self, - management_group_id: str, - filter: Optional[str] = None, - top: Optional[int] = None, - **kwargs: Any - ) -> AsyncIterable["_models.PolicyDefinitionListResult"]: + self, management_group_id: str, filter: Optional[str] = None, top: Optional[int] = None, **kwargs: Any + ) -> AsyncIterable["_models.PolicyDefinition"]: """Retrieve policy definitions in a management group. This operation retrieves a list of all the policy definitions in a given management group that @@ -1757,7 +2036,7 @@ def list_by_management_group( provided, the returned list only includes all policy definitions whose category match the {value}. - :param management_group_id: The ID of the management group. + :param management_group_id: The ID of the management group. Required. :type management_group_id: str :param filter: The filter to apply on the operation. Valid values for $filter are: 'atExactScope()', 'policyType -eq {value}' or 'category eq '{value}''. If $filter is not @@ -1771,44 +2050,45 @@ def list_by_management_group( :param top: Maximum number of records to return. When the $top filter is not provided, it will return 500 records. Default value is None. :type top: int - :keyword api_version: Api Version. Default value is "2020-09-01". Note that overriding this - default value may result in unsupported behavior. - :paramtype api_version: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either PolicyDefinitionListResult or the result of - cls(response) + :return: An iterator like instance of either PolicyDefinition or the result of cls(response) :rtype: - ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.resource.policy.v2020_09_01.models.PolicyDefinitionListResult] - :raises: ~azure.core.exceptions.HttpResponseError + ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.resource.policy.v2020_09_01.models.PolicyDefinition] + :raises ~azure.core.exceptions.HttpResponseError: """ - api_version = kwargs.pop('api_version', "2020-09-01") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2020-09-01")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[_models.PolicyDefinitionListResult] - cls = kwargs.pop('cls', None) # type: ClsType["_models.PolicyDefinitionListResult"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) + def prepare_request(next_link=None): if not next_link: - + request = build_policy_definitions_list_by_management_group_request( management_group_id=management_group_id, - api_version=api_version, filter=filter, top=top, - template_url=self.list_by_management_group.metadata['url'], + api_version=api_version, + template_url=self.list_by_management_group.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore else: - - request = build_policy_definitions_list_by_management_group_request( - management_group_id=management_group_id, - template_url=next_link, - ) + request = HttpRequest("GET", next_link) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore request.method = "GET" return request @@ -1822,10 +2102,8 @@ async def extract_data(pipeline_response): async def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) response = pipeline_response.http_response @@ -1835,67 +2113,123 @@ async def get_next(next_link=None): return pipeline_response + return AsyncItemPaged(get_next, extract_data) + + list_by_management_group.metadata = {"url": "/providers/Microsoft.Management/managementGroups/{managementGroupId}/providers/Microsoft.Authorization/policyDefinitions"} # type: ignore + - return AsyncItemPaged( - get_next, extract_data - ) - list_by_management_group.metadata = {'url': "/providers/Microsoft.Management/managementGroups/{managementGroupId}/providers/Microsoft.Authorization/policyDefinitions"} # type: ignore class PolicySetDefinitionsOperations: - """PolicySetDefinitionsOperations async operations. + """ + .. warning:: + **DO NOT** instantiate this class directly. + + Instead, you should access the following operations through + :class:`~azure.mgmt.resource.policy.v2020_09_01.aio.PolicyClient`'s + :attr:`policy_set_definitions` attribute. + """ + + models = _models + + def __init__(self, *args, **kwargs) -> None: + input_args = list(args) + self._client = input_args.pop(0) if input_args else kwargs.pop("client") + self._config = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") + + @overload + async def create_or_update( + self, + policy_set_definition_name: str, + parameters: _models.PolicySetDefinition, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.PolicySetDefinition: + """Creates or updates a policy set definition. - You should not instantiate this class directly. Instead, you should create a Client instance that - instantiates it for you and attaches it as an attribute. + This operation creates or updates a policy set definition in the given subscription with the + given name. - :ivar models: Alias to model classes used in this operation group. - :type models: ~azure.mgmt.resource.policy.v2020_09_01.models - :param client: Client for service requests. - :param config: Configuration of service client. - :param serializer: An object model serializer. - :param deserializer: An object model deserializer. - """ + :param policy_set_definition_name: The name of the policy set definition to create. Required. + :type policy_set_definition_name: str + :param parameters: The policy set definition properties. Required. + :type parameters: ~azure.mgmt.resource.policy.v2020_09_01.models.PolicySetDefinition + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: PolicySetDefinition or the result of cls(response) + :rtype: ~azure.mgmt.resource.policy.v2020_09_01.models.PolicySetDefinition + :raises ~azure.core.exceptions.HttpResponseError: + """ - models = _models + @overload + async def create_or_update( + self, policy_set_definition_name: str, parameters: IO, *, content_type: str = "application/json", **kwargs: Any + ) -> _models.PolicySetDefinition: + """Creates or updates a policy set definition. + + This operation creates or updates a policy set definition in the given subscription with the + given name. - def __init__(self, client, config, serializer, deserializer) -> None: - self._client = client - self._serialize = serializer - self._deserialize = deserializer - self._config = config + :param policy_set_definition_name: The name of the policy set definition to create. Required. + :type policy_set_definition_name: str + :param parameters: The policy set definition properties. Required. + :type parameters: IO + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: PolicySetDefinition or the result of cls(response) + :rtype: ~azure.mgmt.resource.policy.v2020_09_01.models.PolicySetDefinition + :raises ~azure.core.exceptions.HttpResponseError: + """ @distributed_trace_async async def create_or_update( - self, - policy_set_definition_name: str, - parameters: "_models.PolicySetDefinition", - **kwargs: Any - ) -> "_models.PolicySetDefinition": + self, policy_set_definition_name: str, parameters: Union[_models.PolicySetDefinition, IO], **kwargs: Any + ) -> _models.PolicySetDefinition: """Creates or updates a policy set definition. This operation creates or updates a policy set definition in the given subscription with the given name. - :param policy_set_definition_name: The name of the policy set definition to create. + :param policy_set_definition_name: The name of the policy set definition to create. Required. :type policy_set_definition_name: str - :param parameters: The policy set definition properties. - :type parameters: ~azure.mgmt.resource.policy.v2020_09_01.models.PolicySetDefinition - :keyword api_version: Api Version. Default value is "2020-09-01". Note that overriding this - default value may result in unsupported behavior. - :paramtype api_version: str + :param parameters: The policy set definition properties. Is either a model type or a IO type. + Required. + :type parameters: ~azure.mgmt.resource.policy.v2020_09_01.models.PolicySetDefinition or IO + :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. + Default value is None. + :paramtype content_type: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: PolicySetDefinition, or the result of cls(response) + :return: PolicySetDefinition or the result of cls(response) :rtype: ~azure.mgmt.resource.policy.v2020_09_01.models.PolicySetDefinition - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.PolicySetDefinition"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) - api_version = kwargs.pop('api_version', "2020-09-01") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - _json = self._serialize.body(parameters, 'PolicySetDefinition') + api_version = kwargs.pop("api_version", _params.pop("api-version", "2020-09-01")) # type: str + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.PolicySetDefinition] + + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(parameters, (IO, bytes)): + _content = parameters + else: + _json = self._serialize.body(parameters, "PolicySetDefinition") request = build_policy_set_definitions_create_or_update_request( policy_set_definition_name=policy_set_definition_name, @@ -1903,16 +2237,18 @@ async def create_or_update( api_version=api_version, content_type=content_type, json=_json, - template_url=self.create_or_update.metadata['url'], + content=_content, + template_url=self.create_or_update.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200, 201]: @@ -1920,62 +2256,62 @@ async def create_or_update( raise HttpResponseError(response=response, error_format=ARMErrorFormat) if response.status_code == 200: - deserialized = self._deserialize('PolicySetDefinition', pipeline_response) + deserialized = self._deserialize("PolicySetDefinition", pipeline_response) if response.status_code == 201: - deserialized = self._deserialize('PolicySetDefinition', pipeline_response) + deserialized = self._deserialize("PolicySetDefinition", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - create_or_update.metadata = {'url': "/subscriptions/{subscriptionId}/providers/Microsoft.Authorization/policySetDefinitions/{policySetDefinitionName}"} # type: ignore - + create_or_update.metadata = {"url": "/subscriptions/{subscriptionId}/providers/Microsoft.Authorization/policySetDefinitions/{policySetDefinitionName}"} # type: ignore @distributed_trace_async async def delete( # pylint: disable=inconsistent-return-statements - self, - policy_set_definition_name: str, - **kwargs: Any + self, policy_set_definition_name: str, **kwargs: Any ) -> None: """Deletes a policy set definition. This operation deletes the policy set definition in the given subscription with the given name. - :param policy_set_definition_name: The name of the policy set definition to delete. + :param policy_set_definition_name: The name of the policy set definition to delete. Required. :type policy_set_definition_name: str - :keyword api_version: Api Version. Default value is "2020-09-01". Note that overriding this - default value may result in unsupported behavior. - :paramtype api_version: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: None, or the result of cls(response) + :return: None or the result of cls(response) :rtype: None - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType[None] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) - api_version = kwargs.pop('api_version', "2020-09-01") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2020-09-01")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[None] - request = build_policy_set_definitions_delete_request( policy_set_definition_name=policy_set_definition_name, subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.delete.metadata['url'], + template_url=self.delete.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200, 204]: @@ -1985,134 +2321,126 @@ async def delete( # pylint: disable=inconsistent-return-statements if cls: return cls(pipeline_response, None, {}) - delete.metadata = {'url': "/subscriptions/{subscriptionId}/providers/Microsoft.Authorization/policySetDefinitions/{policySetDefinitionName}"} # type: ignore - + delete.metadata = {"url": "/subscriptions/{subscriptionId}/providers/Microsoft.Authorization/policySetDefinitions/{policySetDefinitionName}"} # type: ignore @distributed_trace_async - async def get( - self, - policy_set_definition_name: str, - **kwargs: Any - ) -> "_models.PolicySetDefinition": + async def get(self, policy_set_definition_name: str, **kwargs: Any) -> _models.PolicySetDefinition: """Retrieves a policy set definition. This operation retrieves the policy set definition in the given subscription with the given name. - :param policy_set_definition_name: The name of the policy set definition to get. + :param policy_set_definition_name: The name of the policy set definition to get. Required. :type policy_set_definition_name: str - :keyword api_version: Api Version. Default value is "2020-09-01". Note that overriding this - default value may result in unsupported behavior. - :paramtype api_version: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: PolicySetDefinition, or the result of cls(response) + :return: PolicySetDefinition or the result of cls(response) :rtype: ~azure.mgmt.resource.policy.v2020_09_01.models.PolicySetDefinition - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.PolicySetDefinition"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) - api_version = kwargs.pop('api_version', "2020-09-01") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2020-09-01")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[_models.PolicySetDefinition] - request = build_policy_set_definitions_get_request( policy_set_definition_name=policy_set_definition_name, subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.get.metadata['url'], + template_url=self.get.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) - deserialized = self._deserialize('PolicySetDefinition', pipeline_response) + deserialized = self._deserialize("PolicySetDefinition", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - get.metadata = {'url': "/subscriptions/{subscriptionId}/providers/Microsoft.Authorization/policySetDefinitions/{policySetDefinitionName}"} # type: ignore - + get.metadata = {"url": "/subscriptions/{subscriptionId}/providers/Microsoft.Authorization/policySetDefinitions/{policySetDefinitionName}"} # type: ignore @distributed_trace_async - async def get_built_in( - self, - policy_set_definition_name: str, - **kwargs: Any - ) -> "_models.PolicySetDefinition": + async def get_built_in(self, policy_set_definition_name: str, **kwargs: Any) -> _models.PolicySetDefinition: """Retrieves a built in policy set definition. This operation retrieves the built-in policy set definition with the given name. - :param policy_set_definition_name: The name of the policy set definition to get. + :param policy_set_definition_name: The name of the policy set definition to get. Required. :type policy_set_definition_name: str - :keyword api_version: Api Version. Default value is "2020-09-01". Note that overriding this - default value may result in unsupported behavior. - :paramtype api_version: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: PolicySetDefinition, or the result of cls(response) + :return: PolicySetDefinition or the result of cls(response) :rtype: ~azure.mgmt.resource.policy.v2020_09_01.models.PolicySetDefinition - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.PolicySetDefinition"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) - api_version = kwargs.pop('api_version', "2020-09-01") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2020-09-01")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[_models.PolicySetDefinition] - request = build_policy_set_definitions_get_built_in_request( policy_set_definition_name=policy_set_definition_name, api_version=api_version, - template_url=self.get_built_in.metadata['url'], + template_url=self.get_built_in.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) - deserialized = self._deserialize('PolicySetDefinition', pipeline_response) + deserialized = self._deserialize("PolicySetDefinition", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - get_built_in.metadata = {'url': "/providers/Microsoft.Authorization/policySetDefinitions/{policySetDefinitionName}"} # type: ignore - + get_built_in.metadata = {"url": "/providers/Microsoft.Authorization/policySetDefinitions/{policySetDefinitionName}"} # type: ignore @distributed_trace def list( - self, - filter: Optional[str] = None, - top: Optional[int] = None, - **kwargs: Any - ) -> AsyncIterable["_models.PolicySetDefinitionListResult"]: + self, filter: Optional[str] = None, top: Optional[int] = None, **kwargs: Any + ) -> AsyncIterable["_models.PolicySetDefinition"]: """Retrieves the policy set definitions for a subscription. This operation retrieves a list of all the policy set definitions in a given subscription that @@ -2138,44 +2466,45 @@ def list( :param top: Maximum number of records to return. When the $top filter is not provided, it will return 500 records. Default value is None. :type top: int - :keyword api_version: Api Version. Default value is "2020-09-01". Note that overriding this - default value may result in unsupported behavior. - :paramtype api_version: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either PolicySetDefinitionListResult or the result of - cls(response) + :return: An iterator like instance of either PolicySetDefinition or the result of cls(response) :rtype: - ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.resource.policy.v2020_09_01.models.PolicySetDefinitionListResult] - :raises: ~azure.core.exceptions.HttpResponseError + ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.resource.policy.v2020_09_01.models.PolicySetDefinition] + :raises ~azure.core.exceptions.HttpResponseError: """ - api_version = kwargs.pop('api_version', "2020-09-01") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2020-09-01")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[_models.PolicySetDefinitionListResult] - cls = kwargs.pop('cls', None) # type: ClsType["_models.PolicySetDefinitionListResult"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) + def prepare_request(next_link=None): if not next_link: - + request = build_policy_set_definitions_list_request( subscription_id=self._config.subscription_id, - api_version=api_version, filter=filter, top=top, - template_url=self.list.metadata['url'], + 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.url = self._client.format_url(request.url) # type: ignore else: - - request = build_policy_set_definitions_list_request( - subscription_id=self._config.subscription_id, - template_url=next_link, - ) + request = HttpRequest("GET", next_link) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore request.method = "GET" return request @@ -2189,10 +2518,8 @@ async def extract_data(pipeline_response): async def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) response = pipeline_response.http_response @@ -2202,19 +2529,14 @@ async def get_next(next_link=None): return pipeline_response + return AsyncItemPaged(get_next, extract_data) - return AsyncItemPaged( - get_next, extract_data - ) - list.metadata = {'url': "/subscriptions/{subscriptionId}/providers/Microsoft.Authorization/policySetDefinitions"} # type: ignore + list.metadata = {"url": "/subscriptions/{subscriptionId}/providers/Microsoft.Authorization/policySetDefinitions"} # type: ignore @distributed_trace def list_built_in( - self, - filter: Optional[str] = None, - top: Optional[int] = None, - **kwargs: Any - ) -> AsyncIterable["_models.PolicySetDefinitionListResult"]: + self, filter: Optional[str] = None, top: Optional[int] = None, **kwargs: Any + ) -> AsyncIterable["_models.PolicySetDefinition"]: """Retrieves built-in policy set definitions. This operation retrieves a list of all the built-in policy set definitions that match the @@ -2233,42 +2555,44 @@ def list_built_in( :param top: Maximum number of records to return. When the $top filter is not provided, it will return 500 records. Default value is None. :type top: int - :keyword api_version: Api Version. Default value is "2020-09-01". Note that overriding this - default value may result in unsupported behavior. - :paramtype api_version: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either PolicySetDefinitionListResult or the result of - cls(response) + :return: An iterator like instance of either PolicySetDefinition or the result of cls(response) :rtype: - ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.resource.policy.v2020_09_01.models.PolicySetDefinitionListResult] - :raises: ~azure.core.exceptions.HttpResponseError + ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.resource.policy.v2020_09_01.models.PolicySetDefinition] + :raises ~azure.core.exceptions.HttpResponseError: """ - api_version = kwargs.pop('api_version', "2020-09-01") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2020-09-01")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[_models.PolicySetDefinitionListResult] - cls = kwargs.pop('cls', None) # type: ClsType["_models.PolicySetDefinitionListResult"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) + def prepare_request(next_link=None): if not next_link: - + request = build_policy_set_definitions_list_built_in_request( - api_version=api_version, filter=filter, top=top, - template_url=self.list_built_in.metadata['url'], + api_version=api_version, + template_url=self.list_built_in.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore else: - - request = build_policy_set_definitions_list_built_in_request( - template_url=next_link, - ) + request = HttpRequest("GET", next_link) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore request.method = "GET" return request @@ -2282,10 +2606,8 @@ async def extract_data(pipeline_response): async def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) response = pipeline_response.http_response @@ -2295,49 +2617,120 @@ async def get_next(next_link=None): return pipeline_response + return AsyncItemPaged(get_next, extract_data) - return AsyncItemPaged( - get_next, extract_data - ) - list_built_in.metadata = {'url': "/providers/Microsoft.Authorization/policySetDefinitions"} # type: ignore + list_built_in.metadata = {"url": "/providers/Microsoft.Authorization/policySetDefinitions"} # type: ignore - @distributed_trace_async + @overload async def create_or_update_at_management_group( self, policy_set_definition_name: str, management_group_id: str, - parameters: "_models.PolicySetDefinition", + parameters: _models.PolicySetDefinition, + *, + content_type: str = "application/json", **kwargs: Any - ) -> "_models.PolicySetDefinition": + ) -> _models.PolicySetDefinition: """Creates or updates a policy set definition. This operation creates or updates a policy set definition in the given management group with the given name. - :param policy_set_definition_name: The name of the policy set definition to create. + :param policy_set_definition_name: The name of the policy set definition to create. Required. :type policy_set_definition_name: str - :param management_group_id: The ID of the management group. + :param management_group_id: The ID of the management group. Required. :type management_group_id: str - :param parameters: The policy set definition properties. + :param parameters: The policy set definition properties. Required. :type parameters: ~azure.mgmt.resource.policy.v2020_09_01.models.PolicySetDefinition - :keyword api_version: Api Version. Default value is "2020-09-01". Note that overriding this - default value may result in unsupported behavior. - :paramtype api_version: str + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: PolicySetDefinition or the result of cls(response) + :rtype: ~azure.mgmt.resource.policy.v2020_09_01.models.PolicySetDefinition + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + async def create_or_update_at_management_group( + self, + policy_set_definition_name: str, + management_group_id: str, + parameters: IO, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.PolicySetDefinition: + """Creates or updates a policy set definition. + + This operation creates or updates a policy set definition in the given management group with + the given name. + + :param policy_set_definition_name: The name of the policy set definition to create. Required. + :type policy_set_definition_name: str + :param management_group_id: The ID of the management group. Required. + :type management_group_id: str + :param parameters: The policy set definition properties. Required. + :type parameters: IO + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: PolicySetDefinition or the result of cls(response) + :rtype: ~azure.mgmt.resource.policy.v2020_09_01.models.PolicySetDefinition + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace_async + async def create_or_update_at_management_group( + self, + policy_set_definition_name: str, + management_group_id: str, + parameters: Union[_models.PolicySetDefinition, IO], + **kwargs: Any + ) -> _models.PolicySetDefinition: + """Creates or updates a policy set definition. + + This operation creates or updates a policy set definition in the given management group with + the given name. + + :param policy_set_definition_name: The name of the policy set definition to create. Required. + :type policy_set_definition_name: str + :param management_group_id: The ID of the management group. Required. + :type management_group_id: str + :param parameters: The policy set definition properties. Is either a model type or a IO type. + Required. + :type parameters: ~azure.mgmt.resource.policy.v2020_09_01.models.PolicySetDefinition or IO + :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. + Default value is None. + :paramtype content_type: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: PolicySetDefinition, or the result of cls(response) + :return: PolicySetDefinition or the result of cls(response) :rtype: ~azure.mgmt.resource.policy.v2020_09_01.models.PolicySetDefinition - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.PolicySetDefinition"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) - api_version = kwargs.pop('api_version', "2020-09-01") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - _json = self._serialize.body(parameters, 'PolicySetDefinition') + api_version = kwargs.pop("api_version", _params.pop("api-version", "2020-09-01")) # type: str + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.PolicySetDefinition] + + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(parameters, (IO, bytes)): + _content = parameters + else: + _json = self._serialize.body(parameters, "PolicySetDefinition") request = build_policy_set_definitions_create_or_update_at_management_group_request( policy_set_definition_name=policy_set_definition_name, @@ -2345,16 +2738,18 @@ async def create_or_update_at_management_group( api_version=api_version, content_type=content_type, json=_json, - template_url=self.create_or_update_at_management_group.metadata['url'], + content=_content, + template_url=self.create_or_update_at_management_group.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200, 201]: @@ -2362,66 +2757,65 @@ async def create_or_update_at_management_group( raise HttpResponseError(response=response, error_format=ARMErrorFormat) if response.status_code == 200: - deserialized = self._deserialize('PolicySetDefinition', pipeline_response) + deserialized = self._deserialize("PolicySetDefinition", pipeline_response) if response.status_code == 201: - deserialized = self._deserialize('PolicySetDefinition', pipeline_response) + deserialized = self._deserialize("PolicySetDefinition", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - create_or_update_at_management_group.metadata = {'url': "/providers/Microsoft.Management/managementGroups/{managementGroupId}/providers/Microsoft.Authorization/policySetDefinitions/{policySetDefinitionName}"} # type: ignore - + create_or_update_at_management_group.metadata = {"url": "/providers/Microsoft.Management/managementGroups/{managementGroupId}/providers/Microsoft.Authorization/policySetDefinitions/{policySetDefinitionName}"} # type: ignore @distributed_trace_async async def delete_at_management_group( # pylint: disable=inconsistent-return-statements - self, - policy_set_definition_name: str, - management_group_id: str, - **kwargs: Any + self, policy_set_definition_name: str, management_group_id: str, **kwargs: Any ) -> None: """Deletes a policy set definition. This operation deletes the policy set definition in the given management group with the given name. - :param policy_set_definition_name: The name of the policy set definition to delete. + :param policy_set_definition_name: The name of the policy set definition to delete. Required. :type policy_set_definition_name: str - :param management_group_id: The ID of the management group. + :param management_group_id: The ID of the management group. Required. :type management_group_id: str - :keyword api_version: Api Version. Default value is "2020-09-01". Note that overriding this - default value may result in unsupported behavior. - :paramtype api_version: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: None, or the result of cls(response) + :return: None or the result of cls(response) :rtype: None - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType[None] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + 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', "2020-09-01") # type: str + api_version = kwargs.pop("api_version", _params.pop("api-version", "2020-09-01")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[None] - request = build_policy_set_definitions_delete_at_management_group_request( policy_set_definition_name=policy_set_definition_name, management_group_id=management_group_id, api_version=api_version, - template_url=self.delete_at_management_group.metadata['url'], + template_url=self.delete_at_management_group.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200, 204]: @@ -2431,80 +2825,74 @@ async def delete_at_management_group( # pylint: disable=inconsistent-return-sta if cls: return cls(pipeline_response, None, {}) - delete_at_management_group.metadata = {'url': "/providers/Microsoft.Management/managementGroups/{managementGroupId}/providers/Microsoft.Authorization/policySetDefinitions/{policySetDefinitionName}"} # type: ignore - + delete_at_management_group.metadata = {"url": "/providers/Microsoft.Management/managementGroups/{managementGroupId}/providers/Microsoft.Authorization/policySetDefinitions/{policySetDefinitionName}"} # type: ignore @distributed_trace_async async def get_at_management_group( - self, - policy_set_definition_name: str, - management_group_id: str, - **kwargs: Any - ) -> "_models.PolicySetDefinition": + self, policy_set_definition_name: str, management_group_id: str, **kwargs: Any + ) -> _models.PolicySetDefinition: """Retrieves a policy set definition. This operation retrieves the policy set definition in the given management group with the given name. - :param policy_set_definition_name: The name of the policy set definition to get. + :param policy_set_definition_name: The name of the policy set definition to get. Required. :type policy_set_definition_name: str - :param management_group_id: The ID of the management group. + :param management_group_id: The ID of the management group. Required. :type management_group_id: str - :keyword api_version: Api Version. Default value is "2020-09-01". Note that overriding this - default value may result in unsupported behavior. - :paramtype api_version: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: PolicySetDefinition, or the result of cls(response) + :return: PolicySetDefinition or the result of cls(response) :rtype: ~azure.mgmt.resource.policy.v2020_09_01.models.PolicySetDefinition - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.PolicySetDefinition"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) - api_version = kwargs.pop('api_version', "2020-09-01") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2020-09-01")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[_models.PolicySetDefinition] - request = build_policy_set_definitions_get_at_management_group_request( policy_set_definition_name=policy_set_definition_name, management_group_id=management_group_id, api_version=api_version, - template_url=self.get_at_management_group.metadata['url'], + template_url=self.get_at_management_group.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) - deserialized = self._deserialize('PolicySetDefinition', pipeline_response) + deserialized = self._deserialize("PolicySetDefinition", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - get_at_management_group.metadata = {'url': "/providers/Microsoft.Management/managementGroups/{managementGroupId}/providers/Microsoft.Authorization/policySetDefinitions/{policySetDefinitionName}"} # type: ignore - + get_at_management_group.metadata = {"url": "/providers/Microsoft.Management/managementGroups/{managementGroupId}/providers/Microsoft.Authorization/policySetDefinitions/{policySetDefinitionName}"} # type: ignore @distributed_trace def list_by_management_group( - self, - management_group_id: str, - filter: Optional[str] = None, - top: Optional[int] = None, - **kwargs: Any - ) -> AsyncIterable["_models.PolicySetDefinitionListResult"]: + self, management_group_id: str, filter: Optional[str] = None, top: Optional[int] = None, **kwargs: Any + ) -> AsyncIterable["_models.PolicySetDefinition"]: """Retrieves all policy set definitions in management group. This operation retrieves a list of all the policy set definitions in a given management group @@ -2519,7 +2907,7 @@ def list_by_management_group( provided, the returned list only includes all policy set definitions whose category match the {value}. - :param management_group_id: The ID of the management group. + :param management_group_id: The ID of the management group. Required. :type management_group_id: str :param filter: The filter to apply on the operation. Valid values for $filter are: 'atExactScope()', 'policyType -eq {value}' or 'category eq '{value}''. If $filter is not @@ -2533,44 +2921,45 @@ def list_by_management_group( :param top: Maximum number of records to return. When the $top filter is not provided, it will return 500 records. Default value is None. :type top: int - :keyword api_version: Api Version. Default value is "2020-09-01". Note that overriding this - default value may result in unsupported behavior. - :paramtype api_version: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either PolicySetDefinitionListResult or the result of - cls(response) + :return: An iterator like instance of either PolicySetDefinition or the result of cls(response) :rtype: - ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.resource.policy.v2020_09_01.models.PolicySetDefinitionListResult] - :raises: ~azure.core.exceptions.HttpResponseError + ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.resource.policy.v2020_09_01.models.PolicySetDefinition] + :raises ~azure.core.exceptions.HttpResponseError: """ - api_version = kwargs.pop('api_version', "2020-09-01") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2020-09-01")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[_models.PolicySetDefinitionListResult] - cls = kwargs.pop('cls', None) # type: ClsType["_models.PolicySetDefinitionListResult"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) + def prepare_request(next_link=None): if not next_link: - + request = build_policy_set_definitions_list_by_management_group_request( management_group_id=management_group_id, - api_version=api_version, filter=filter, top=top, - template_url=self.list_by_management_group.metadata['url'], + api_version=api_version, + template_url=self.list_by_management_group.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore else: - - request = build_policy_set_definitions_list_by_management_group_request( - management_group_id=management_group_id, - template_url=next_link, - ) + request = HttpRequest("GET", next_link) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore request.method = "GET" return request @@ -2584,10 +2973,8 @@ async def extract_data(pipeline_response): async def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) response = pipeline_response.http_response @@ -2597,39 +2984,33 @@ async def get_next(next_link=None): return pipeline_response + return AsyncItemPaged(get_next, extract_data) - return AsyncItemPaged( - get_next, extract_data - ) - list_by_management_group.metadata = {'url': "/providers/Microsoft.Management/managementGroups/{managementGroupId}/providers/Microsoft.Authorization/policySetDefinitions"} # type: ignore -class PolicyExemptionsOperations: - """PolicyExemptionsOperations async operations. + list_by_management_group.metadata = {"url": "/providers/Microsoft.Management/managementGroups/{managementGroupId}/providers/Microsoft.Authorization/policySetDefinitions"} # type: ignore - You should not instantiate this class directly. Instead, you should create a Client instance that - instantiates it for you and attaches it as an attribute. - :ivar models: Alias to model classes used in this operation group. - :type models: ~azure.mgmt.resource.policy.v2020_09_01.models - :param client: Client for service requests. - :param config: Configuration of service client. - :param serializer: An object model serializer. - :param deserializer: An object model deserializer. +class PolicyExemptionsOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. + + Instead, you should access the following operations through + :class:`~azure.mgmt.resource.policy.v2020_09_01.aio.PolicyClient`'s + :attr:`policy_exemptions` attribute. """ models = _models - def __init__(self, client, config, serializer, deserializer) -> None: - self._client = client - self._serialize = serializer - self._deserialize = deserializer - self._config = config + def __init__(self, *args, **kwargs) -> None: + input_args = list(args) + self._client = input_args.pop(0) if input_args else kwargs.pop("client") + self._config = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") @distributed_trace_async async def delete( # pylint: disable=inconsistent-return-statements - self, - scope: str, - policy_exemption_name: str, - **kwargs: Any + self, scope: str, policy_exemption_name: str, **kwargs: Any ) -> None: """Deletes a policy exemption. @@ -2642,40 +3023,44 @@ async def delete( # pylint: disable=inconsistent-return-statements '/subscriptions/{subscriptionId}'), resource group (format: '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}', or resource (format: '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{resourceProviderNamespace}/[{parentResourcePath}/]{resourceType}/{resourceName}'. + Required. :type scope: str - :param policy_exemption_name: The name of the policy exemption to delete. + :param policy_exemption_name: The name of the policy exemption to delete. Required. :type policy_exemption_name: str - :keyword api_version: Api Version. Default value is "2020-07-01-preview". Note that overriding - this default value may result in unsupported behavior. - :paramtype api_version: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: None, or the result of cls(response) + :return: None or the result of cls(response) :rtype: None - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType[None] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + 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', "2020-07-01-preview") # type: str + api_version = kwargs.pop("api_version", _params.pop("api-version", "2020-07-01-preview")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[None] - request = build_policy_exemptions_delete_request( scope=scope, policy_exemption_name=policy_exemption_name, api_version=api_version, - template_url=self.delete.metadata['url'], + template_url=self.delete.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200, 204]: @@ -2685,17 +3070,18 @@ async def delete( # pylint: disable=inconsistent-return-statements if cls: return cls(pipeline_response, None, {}) - delete.metadata = {'url': "/{scope}/providers/Microsoft.Authorization/policyExemptions/{policyExemptionName}"} # type: ignore - + delete.metadata = {"url": "/{scope}/providers/Microsoft.Authorization/policyExemptions/{policyExemptionName}"} # type: ignore - @distributed_trace_async + @overload async def create_or_update( self, scope: str, policy_exemption_name: str, - parameters: "_models.PolicyExemption", + parameters: _models.PolicyExemption, + *, + content_type: str = "application/json", **kwargs: Any - ) -> "_models.PolicyExemption": + ) -> _models.PolicyExemption: """Creates or updates a policy exemption. This operation creates or updates a policy exemption with the given scope and name. Policy @@ -2708,29 +3094,111 @@ async def create_or_update( '/subscriptions/{subscriptionId}'), resource group (format: '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}', or resource (format: '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{resourceProviderNamespace}/[{parentResourcePath}/]{resourceType}/{resourceName}'. + Required. :type scope: str - :param policy_exemption_name: The name of the policy exemption to delete. + :param policy_exemption_name: The name of the policy exemption to delete. Required. :type policy_exemption_name: str - :param parameters: Parameters for the policy exemption. + :param parameters: Parameters for the policy exemption. Required. :type parameters: ~azure.mgmt.resource.policy.v2020_09_01.models.PolicyExemption - :keyword api_version: Api Version. Default value is "2020-07-01-preview". Note that overriding - this default value may result in unsupported behavior. - :paramtype api_version: str + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: PolicyExemption or the result of cls(response) + :rtype: ~azure.mgmt.resource.policy.v2020_09_01.models.PolicyExemption + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + async def create_or_update( + self, + scope: str, + policy_exemption_name: str, + parameters: IO, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.PolicyExemption: + """Creates or updates a policy exemption. + + This operation creates or updates a policy exemption with the given scope and name. Policy + exemptions apply to all resources contained within their scope. For example, when you create a + policy exemption at resource group scope for a policy assignment at the same or above level, + the exemption exempts to all applicable resources in the resource group. + + :param scope: The scope of the policy exemption. Valid scopes are: management group (format: + '/providers/Microsoft.Management/managementGroups/{managementGroup}'), subscription (format: + '/subscriptions/{subscriptionId}'), resource group (format: + '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}', or resource (format: + '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{resourceProviderNamespace}/[{parentResourcePath}/]{resourceType}/{resourceName}'. + Required. + :type scope: str + :param policy_exemption_name: The name of the policy exemption to delete. Required. + :type policy_exemption_name: str + :param parameters: Parameters for the policy exemption. Required. + :type parameters: IO + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: PolicyExemption or the result of cls(response) + :rtype: ~azure.mgmt.resource.policy.v2020_09_01.models.PolicyExemption + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace_async + async def create_or_update( + self, scope: str, policy_exemption_name: str, parameters: Union[_models.PolicyExemption, IO], **kwargs: Any + ) -> _models.PolicyExemption: + """Creates or updates a policy exemption. + + This operation creates or updates a policy exemption with the given scope and name. Policy + exemptions apply to all resources contained within their scope. For example, when you create a + policy exemption at resource group scope for a policy assignment at the same or above level, + the exemption exempts to all applicable resources in the resource group. + + :param scope: The scope of the policy exemption. Valid scopes are: management group (format: + '/providers/Microsoft.Management/managementGroups/{managementGroup}'), subscription (format: + '/subscriptions/{subscriptionId}'), resource group (format: + '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}', or resource (format: + '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{resourceProviderNamespace}/[{parentResourcePath}/]{resourceType}/{resourceName}'. + Required. + :type scope: str + :param policy_exemption_name: The name of the policy exemption to delete. Required. + :type policy_exemption_name: str + :param parameters: Parameters for the policy exemption. Is either a model type or a IO type. + Required. + :type parameters: ~azure.mgmt.resource.policy.v2020_09_01.models.PolicyExemption or IO + :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. + Default value is None. + :paramtype content_type: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: PolicyExemption, or the result of cls(response) + :return: PolicyExemption or the result of cls(response) :rtype: ~azure.mgmt.resource.policy.v2020_09_01.models.PolicyExemption - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.PolicyExemption"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) - api_version = kwargs.pop('api_version', "2020-07-01-preview") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - _json = self._serialize.body(parameters, 'PolicyExemption') + api_version = kwargs.pop("api_version", _params.pop("api-version", "2020-07-01-preview")) # type: str + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.PolicyExemption] + + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(parameters, (IO, bytes)): + _content = parameters + else: + _json = self._serialize.body(parameters, "PolicyExemption") request = build_policy_exemptions_create_or_update_request( scope=scope, @@ -2738,16 +3206,18 @@ async def create_or_update( api_version=api_version, content_type=content_type, json=_json, - template_url=self.create_or_update.metadata['url'], + content=_content, + template_url=self.create_or_update.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200, 201]: @@ -2755,26 +3225,20 @@ async def create_or_update( raise HttpResponseError(response=response, error_format=ARMErrorFormat) if response.status_code == 200: - deserialized = self._deserialize('PolicyExemption', pipeline_response) + deserialized = self._deserialize("PolicyExemption", pipeline_response) if response.status_code == 201: - deserialized = self._deserialize('PolicyExemption', pipeline_response) + deserialized = self._deserialize("PolicyExemption", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - create_or_update.metadata = {'url': "/{scope}/providers/Microsoft.Authorization/policyExemptions/{policyExemptionName}"} # type: ignore - + create_or_update.metadata = {"url": "/{scope}/providers/Microsoft.Authorization/policyExemptions/{policyExemptionName}"} # type: ignore @distributed_trace_async - async def get( - self, - scope: str, - policy_exemption_name: str, - **kwargs: Any - ) -> "_models.PolicyExemption": + async def get(self, scope: str, policy_exemption_name: str, **kwargs: Any) -> _models.PolicyExemption: """Retrieves a policy exemption. This operation retrieves a single policy exemption, given its name and the scope it was created @@ -2785,62 +3249,61 @@ async def get( '/subscriptions/{subscriptionId}'), resource group (format: '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}', or resource (format: '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{resourceProviderNamespace}/[{parentResourcePath}/]{resourceType}/{resourceName}'. + Required. :type scope: str - :param policy_exemption_name: The name of the policy exemption to delete. + :param policy_exemption_name: The name of the policy exemption to delete. Required. :type policy_exemption_name: str - :keyword api_version: Api Version. Default value is "2020-07-01-preview". Note that overriding - this default value may result in unsupported behavior. - :paramtype api_version: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: PolicyExemption, or the result of cls(response) + :return: PolicyExemption or the result of cls(response) :rtype: ~azure.mgmt.resource.policy.v2020_09_01.models.PolicyExemption - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.PolicyExemption"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + 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', "2020-07-01-preview") # type: str + api_version = kwargs.pop("api_version", _params.pop("api-version", "2020-07-01-preview")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[_models.PolicyExemption] - request = build_policy_exemptions_get_request( scope=scope, policy_exemption_name=policy_exemption_name, api_version=api_version, - template_url=self.get.metadata['url'], + template_url=self.get.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) - deserialized = self._deserialize('PolicyExemption', pipeline_response) + deserialized = self._deserialize("PolicyExemption", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - get.metadata = {'url': "/{scope}/providers/Microsoft.Authorization/policyExemptions/{policyExemptionName}"} # type: ignore - + get.metadata = {"url": "/{scope}/providers/Microsoft.Authorization/policyExemptions/{policyExemptionName}"} # type: ignore @distributed_trace - def list( - self, - filter: Optional[str] = None, - **kwargs: Any - ) -> AsyncIterable["_models.PolicyExemptionListResult"]: + def list(self, filter: Optional[str] = None, **kwargs: Any) -> AsyncIterable["_models.PolicyExemption"]: """Retrieves all policy exemptions that apply to a subscription. This operation retrieves the list of all policy exemptions associated with the given @@ -2863,43 +3326,44 @@ def list( '{value}' is provided. the returned list only includes all policy exemptions that are associated with the give policyAssignmentId. Default value is None. :type filter: str - :keyword api_version: Api Version. Default value is "2020-07-01-preview". Note that overriding - this default value may result in unsupported behavior. - :paramtype api_version: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either PolicyExemptionListResult or the result of - cls(response) + :return: An iterator like instance of either PolicyExemption or the result of cls(response) :rtype: - ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.resource.policy.v2020_09_01.models.PolicyExemptionListResult] - :raises: ~azure.core.exceptions.HttpResponseError + ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.resource.policy.v2020_09_01.models.PolicyExemption] + :raises ~azure.core.exceptions.HttpResponseError: """ - api_version = kwargs.pop('api_version', "2020-07-01-preview") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2020-07-01-preview")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[_models.PolicyExemptionListResult] - cls = kwargs.pop('cls', None) # type: ClsType["_models.PolicyExemptionListResult"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) + def prepare_request(next_link=None): if not next_link: - + request = build_policy_exemptions_list_request( subscription_id=self._config.subscription_id, - api_version=api_version, filter=filter, - template_url=self.list.metadata['url'], + 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.url = self._client.format_url(request.url) # type: ignore else: - - request = build_policy_exemptions_list_request( - subscription_id=self._config.subscription_id, - template_url=next_link, - ) + request = HttpRequest("GET", next_link) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore request.method = "GET" return request @@ -2913,10 +3377,8 @@ async def extract_data(pipeline_response): async def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) response = pipeline_response.http_response @@ -2926,19 +3388,14 @@ async def get_next(next_link=None): return pipeline_response + return AsyncItemPaged(get_next, extract_data) - return AsyncItemPaged( - get_next, extract_data - ) - list.metadata = {'url': "/subscriptions/{subscriptionId}/providers/Microsoft.Authorization/policyExemptions"} # type: ignore + list.metadata = {"url": "/subscriptions/{subscriptionId}/providers/Microsoft.Authorization/policyExemptions"} # type: ignore @distributed_trace def list_for_resource_group( - self, - resource_group_name: str, - filter: Optional[str] = None, - **kwargs: Any - ) -> AsyncIterable["_models.PolicyExemptionListResult"]: + self, resource_group_name: str, filter: Optional[str] = None, **kwargs: Any + ) -> AsyncIterable["_models.PolicyExemption"]: """Retrieves all policy exemptions that apply to a resource group. This operation retrieves the list of all policy exemptions associated with the given resource @@ -2948,7 +3405,7 @@ def list_for_resource_group( resource group, including those that apply directly or apply from containing scopes, as well as any applied to resources contained within the resource group. - :param resource_group_name: The name of the resource group containing the resource. + :param resource_group_name: The name of the resource group containing the resource. Required. :type resource_group_name: str :param filter: The filter to apply on the operation. Valid values for $filter are: 'atScope()', 'atExactScope()', 'excludeExpired()' or 'policyAssignmentId eq '{value}''. If $filter is not @@ -2963,45 +3420,45 @@ def list_for_resource_group( '{value}' is provided. the returned list only includes all policy exemptions that are associated with the give policyAssignmentId. Default value is None. :type filter: str - :keyword api_version: Api Version. Default value is "2020-07-01-preview". Note that overriding - this default value may result in unsupported behavior. - :paramtype api_version: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either PolicyExemptionListResult or the result of - cls(response) + :return: An iterator like instance of either PolicyExemption or the result of cls(response) :rtype: - ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.resource.policy.v2020_09_01.models.PolicyExemptionListResult] - :raises: ~azure.core.exceptions.HttpResponseError + ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.resource.policy.v2020_09_01.models.PolicyExemption] + :raises ~azure.core.exceptions.HttpResponseError: """ - api_version = kwargs.pop('api_version', "2020-07-01-preview") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2020-07-01-preview")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[_models.PolicyExemptionListResult] - cls = kwargs.pop('cls', None) # type: ClsType["_models.PolicyExemptionListResult"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) + def prepare_request(next_link=None): if not next_link: - + request = build_policy_exemptions_list_for_resource_group_request( - subscription_id=self._config.subscription_id, resource_group_name=resource_group_name, - api_version=api_version, + subscription_id=self._config.subscription_id, filter=filter, - template_url=self.list_for_resource_group.metadata['url'], + api_version=api_version, + template_url=self.list_for_resource_group.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore else: - - request = build_policy_exemptions_list_for_resource_group_request( - subscription_id=self._config.subscription_id, - resource_group_name=resource_group_name, - template_url=next_link, - ) + request = HttpRequest("GET", next_link) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore request.method = "GET" return request @@ -3015,10 +3472,8 @@ async def extract_data(pipeline_response): async def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) response = pipeline_response.http_response @@ -3028,11 +3483,9 @@ async def get_next(next_link=None): return pipeline_response + return AsyncItemPaged(get_next, extract_data) - return AsyncItemPaged( - get_next, extract_data - ) - list_for_resource_group.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Authorization/policyExemptions"} # type: ignore + list_for_resource_group.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Authorization/policyExemptions"} # type: ignore @distributed_trace def list_for_resource( @@ -3044,7 +3497,7 @@ def list_for_resource( resource_name: str, filter: Optional[str] = None, **kwargs: Any - ) -> AsyncIterable["_models.PolicyExemptionListResult"]: + ) -> AsyncIterable["_models.PolicyExemption"]: """Retrieves all policy exemptions that apply to a resource. This operation retrieves the list of all policy exemptions associated with the specified @@ -3066,17 +3519,19 @@ def list_for_resource( {parentResourcePath} == '', {resourceType} == 'Microsoft.Web/sites', {resourceName} == 'MyWebApp'). - :param resource_group_name: The name of the resource group containing the resource. + :param resource_group_name: The name of the resource group containing the resource. Required. :type resource_group_name: str :param resource_provider_namespace: The namespace of the resource provider. For example, the namespace of a virtual machine is Microsoft.Compute (from Microsoft.Compute/virtualMachines). + Required. :type resource_provider_namespace: str :param parent_resource_path: The parent resource path. Use empty string if there is none. + Required. :type parent_resource_path: str :param resource_type: The resource type name. For example the type name of a web app is 'sites' - (from Microsoft.Web/sites). + (from Microsoft.Web/sites). Required. :type resource_type: str - :param resource_name: The name of the resource. + :param resource_name: The name of the resource. Required. :type resource_name: str :param filter: The filter to apply on the operation. Valid values for $filter are: 'atScope()', 'atExactScope()', 'excludeExpired()' or 'policyAssignmentId eq '{value}''. If $filter is not @@ -3091,53 +3546,49 @@ def list_for_resource( '{value}' is provided. the returned list only includes all policy exemptions that are associated with the give policyAssignmentId. Default value is None. :type filter: str - :keyword api_version: Api Version. Default value is "2020-07-01-preview". Note that overriding - this default value may result in unsupported behavior. - :paramtype api_version: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either PolicyExemptionListResult or the result of - cls(response) + :return: An iterator like instance of either PolicyExemption or the result of cls(response) :rtype: - ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.resource.policy.v2020_09_01.models.PolicyExemptionListResult] - :raises: ~azure.core.exceptions.HttpResponseError + ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.resource.policy.v2020_09_01.models.PolicyExemption] + :raises ~azure.core.exceptions.HttpResponseError: """ - api_version = kwargs.pop('api_version', "2020-07-01-preview") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2020-07-01-preview")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[_models.PolicyExemptionListResult] - cls = kwargs.pop('cls', None) # type: ClsType["_models.PolicyExemptionListResult"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) + def prepare_request(next_link=None): if not next_link: - + request = build_policy_exemptions_list_for_resource_request( - subscription_id=self._config.subscription_id, resource_group_name=resource_group_name, resource_provider_namespace=resource_provider_namespace, parent_resource_path=parent_resource_path, resource_type=resource_type, resource_name=resource_name, - api_version=api_version, + subscription_id=self._config.subscription_id, filter=filter, - template_url=self.list_for_resource.metadata['url'], + api_version=api_version, + template_url=self.list_for_resource.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore else: - - request = build_policy_exemptions_list_for_resource_request( - subscription_id=self._config.subscription_id, - resource_group_name=resource_group_name, - resource_provider_namespace=resource_provider_namespace, - parent_resource_path=parent_resource_path, - resource_type=resource_type, - resource_name=resource_name, - template_url=next_link, - ) + request = HttpRequest("GET", next_link) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore request.method = "GET" return request @@ -3151,10 +3602,8 @@ async def extract_data(pipeline_response): async def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) response = pipeline_response.http_response @@ -3164,19 +3613,14 @@ async def get_next(next_link=None): return pipeline_response + return AsyncItemPaged(get_next, extract_data) - return AsyncItemPaged( - get_next, extract_data - ) - list_for_resource.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{parentResourcePath}/{resourceType}/{resourceName}/providers/Microsoft.Authorization/policyExemptions"} # type: ignore + list_for_resource.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{parentResourcePath}/{resourceType}/{resourceName}/providers/Microsoft.Authorization/policyExemptions"} # type: ignore @distributed_trace def list_for_management_group( - self, - management_group_id: str, - filter: Optional[str] = None, - **kwargs: Any - ) -> AsyncIterable["_models.PolicyExemptionListResult"]: + self, management_group_id: str, filter: Optional[str] = None, **kwargs: Any + ) -> AsyncIterable["_models.PolicyExemption"]: """Retrieves all policy exemptions that apply to a management group. This operation retrieves the list of all policy exemptions applicable to the management group @@ -3185,7 +3629,7 @@ def list_for_management_group( returned list includes all policy exemptions that are assigned to the management group or the management group's ancestors. - :param management_group_id: The ID of the management group. + :param management_group_id: The ID of the management group. Required. :type management_group_id: str :param filter: The filter to apply on the operation. Valid values for $filter are: 'atScope()', 'atExactScope()', 'excludeExpired()' or 'policyAssignmentId eq '{value}''. If $filter is not @@ -3200,43 +3644,44 @@ def list_for_management_group( '{value}' is provided. the returned list only includes all policy exemptions that are associated with the give policyAssignmentId. Default value is None. :type filter: str - :keyword api_version: Api Version. Default value is "2020-07-01-preview". Note that overriding - this default value may result in unsupported behavior. - :paramtype api_version: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either PolicyExemptionListResult or the result of - cls(response) + :return: An iterator like instance of either PolicyExemption or the result of cls(response) :rtype: - ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.resource.policy.v2020_09_01.models.PolicyExemptionListResult] - :raises: ~azure.core.exceptions.HttpResponseError + ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.resource.policy.v2020_09_01.models.PolicyExemption] + :raises ~azure.core.exceptions.HttpResponseError: """ - api_version = kwargs.pop('api_version', "2020-07-01-preview") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2020-07-01-preview")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[_models.PolicyExemptionListResult] - cls = kwargs.pop('cls', None) # type: ClsType["_models.PolicyExemptionListResult"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) + def prepare_request(next_link=None): if not next_link: - + request = build_policy_exemptions_list_for_management_group_request( management_group_id=management_group_id, - api_version=api_version, filter=filter, - template_url=self.list_for_management_group.metadata['url'], + api_version=api_version, + template_url=self.list_for_management_group.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore else: - - request = build_policy_exemptions_list_for_management_group_request( - management_group_id=management_group_id, - template_url=next_link, - ) + request = HttpRequest("GET", next_link) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore request.method = "GET" return request @@ -3250,10 +3695,8 @@ async def extract_data(pipeline_response): async def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) response = pipeline_response.http_response @@ -3263,8 +3706,6 @@ async def get_next(next_link=None): return pipeline_response + return AsyncItemPaged(get_next, extract_data) - return AsyncItemPaged( - get_next, extract_data - ) - list_for_management_group.metadata = {'url': "/providers/Microsoft.Management/managementGroups/{managementGroupId}/providers/Microsoft.Authorization/policyExemptions"} # type: ignore + list_for_management_group.metadata = {"url": "/providers/Microsoft.Management/managementGroups/{managementGroupId}/providers/Microsoft.Authorization/policyExemptions"} # type: ignore diff --git a/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/policy/v2020_09_01/aio/operations/_patch.py b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/policy/v2020_09_01/aio/operations/_patch.py new file mode 100644 index 0000000000000..f7dd32510333d --- /dev/null +++ b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/policy/v2020_09_01/aio/operations/_patch.py @@ -0,0 +1,20 @@ +# ------------------------------------ +# Copyright (c) Microsoft Corporation. +# Licensed under the MIT License. +# ------------------------------------ +"""Customize generated code here. + +Follow our quickstart for examples: https://aka.ms/azsdk/python/dpcodegen/python/customize +""" +from typing import List + +__all__: List[str] = [] # Add all objects you want publicly available to users at this package level + + +def patch_sdk(): + """Do not remove from this file. + + `patch_sdk` is a last resort escape hatch that allows you to do customizations + you can't accomplish using the techniques described in + https://aka.ms/azsdk/python/dpcodegen/python/customize + """ diff --git a/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/policy/v2020_09_01/models/__init__.py b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/policy/v2020_09_01/models/__init__.py index 712dbf6af5911..639f58ca314a8 100644 --- a/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/policy/v2020_09_01/models/__init__.py +++ b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/policy/v2020_09_01/models/__init__.py @@ -34,56 +34,58 @@ from ._models_py3 import ResourceTypeAliases from ._models_py3 import SystemData - -from ._policy_client_enums import ( - AliasPathAttributes, - AliasPathTokenType, - AliasPatternType, - AliasType, - CreatedByType, - EnforcementMode, - ExemptionCategory, - ParameterType, - PolicyType, - ResourceIdentityType, -) +from ._policy_client_enums import AliasPathAttributes +from ._policy_client_enums import AliasPathTokenType +from ._policy_client_enums import AliasPatternType +from ._policy_client_enums import AliasType +from ._policy_client_enums import CreatedByType +from ._policy_client_enums import EnforcementMode +from ._policy_client_enums import ExemptionCategory +from ._policy_client_enums import ParameterType +from ._policy_client_enums import PolicyType +from ._policy_client_enums import ResourceIdentityType +from ._patch import __all__ as _patch_all +from ._patch import * # type: ignore # pylint: disable=unused-wildcard-import +from ._patch import patch_sdk as _patch_sdk __all__ = [ - 'Alias', - 'AliasPath', - 'AliasPathMetadata', - 'AliasPattern', - 'DataEffect', - 'DataManifestCustomResourceFunctionDefinition', - 'DataPolicyManifest', - 'DataPolicyManifestListResult', - 'ErrorAdditionalInfo', - 'ErrorResponse', - 'Identity', - 'NonComplianceMessage', - 'ParameterDefinitionsValue', - 'ParameterDefinitionsValueMetadata', - 'ParameterValuesValue', - 'PolicyAssignment', - 'PolicyAssignmentListResult', - 'PolicyDefinition', - 'PolicyDefinitionGroup', - 'PolicyDefinitionListResult', - 'PolicyDefinitionReference', - 'PolicyExemption', - 'PolicyExemptionListResult', - 'PolicySetDefinition', - 'PolicySetDefinitionListResult', - 'ResourceTypeAliases', - 'SystemData', - 'AliasPathAttributes', - 'AliasPathTokenType', - 'AliasPatternType', - 'AliasType', - 'CreatedByType', - 'EnforcementMode', - 'ExemptionCategory', - 'ParameterType', - 'PolicyType', - 'ResourceIdentityType', + "Alias", + "AliasPath", + "AliasPathMetadata", + "AliasPattern", + "DataEffect", + "DataManifestCustomResourceFunctionDefinition", + "DataPolicyManifest", + "DataPolicyManifestListResult", + "ErrorAdditionalInfo", + "ErrorResponse", + "Identity", + "NonComplianceMessage", + "ParameterDefinitionsValue", + "ParameterDefinitionsValueMetadata", + "ParameterValuesValue", + "PolicyAssignment", + "PolicyAssignmentListResult", + "PolicyDefinition", + "PolicyDefinitionGroup", + "PolicyDefinitionListResult", + "PolicyDefinitionReference", + "PolicyExemption", + "PolicyExemptionListResult", + "PolicySetDefinition", + "PolicySetDefinitionListResult", + "ResourceTypeAliases", + "SystemData", + "AliasPathAttributes", + "AliasPathTokenType", + "AliasPatternType", + "AliasType", + "CreatedByType", + "EnforcementMode", + "ExemptionCategory", + "ParameterType", + "PolicyType", + "ResourceIdentityType", ] +__all__.extend([p for p in _patch_all if p not in __all__]) +_patch_sdk() diff --git a/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/policy/v2020_09_01/models/_models_py3.py b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/policy/v2020_09_01/models/_models_py3.py index 5a6e3e56fab95..06aff85d2ac66 100644 --- a/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/policy/v2020_09_01/models/_models_py3.py +++ b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/policy/v2020_09_01/models/_models_py3.py @@ -1,4 +1,5 @@ # coding=utf-8 +# pylint: disable=too-many-lines # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. # Licensed under the MIT License. See License.txt in the project root for license information. @@ -7,14 +8,22 @@ # -------------------------------------------------------------------------- import datetime -from typing import Any, Dict, List, Optional, Union +import sys +from typing import Any, Dict, List, Optional, TYPE_CHECKING, Union -import msrest.serialization +from ... import _serialization -from ._policy_client_enums import * +if TYPE_CHECKING: + # pylint: disable=unused-import,ungrouped-imports + from .. import models as _models +if sys.version_info >= (3, 9): + from collections.abc import MutableMapping +else: + from typing import MutableMapping # type: ignore # pylint: disable=ungrouped-imports +JSON = MutableMapping[str, Any] # pylint: disable=unsubscriptable-object -class Alias(msrest.serialization.Model): +class Alias(_serialization.Model): """The alias type. Variables are only populated by the server, and will be ignored when sending a request. @@ -23,8 +32,7 @@ class Alias(msrest.serialization.Model): :vartype name: str :ivar paths: The paths for an alias. :vartype paths: list[~azure.mgmt.resource.policy.v2020_09_01.models.AliasPath] - :ivar type: The type of the alias. Possible values include: "NotSpecified", "PlainText", - "Mask". + :ivar type: The type of the alias. Known values are: "NotSpecified", "PlainText", and "Mask". :vartype type: str or ~azure.mgmt.resource.policy.v2020_09_01.models.AliasType :ivar default_path: The default path for an alias. :vartype default_path: str @@ -36,26 +44,26 @@ class Alias(msrest.serialization.Model): """ _validation = { - 'default_metadata': {'readonly': True}, + "default_metadata": {"readonly": True}, } _attribute_map = { - 'name': {'key': 'name', 'type': 'str'}, - 'paths': {'key': 'paths', 'type': '[AliasPath]'}, - 'type': {'key': 'type', 'type': 'str'}, - 'default_path': {'key': 'defaultPath', 'type': 'str'}, - 'default_pattern': {'key': 'defaultPattern', 'type': 'AliasPattern'}, - 'default_metadata': {'key': 'defaultMetadata', 'type': 'AliasPathMetadata'}, + "name": {"key": "name", "type": "str"}, + "paths": {"key": "paths", "type": "[AliasPath]"}, + "type": {"key": "type", "type": "str"}, + "default_path": {"key": "defaultPath", "type": "str"}, + "default_pattern": {"key": "defaultPattern", "type": "AliasPattern"}, + "default_metadata": {"key": "defaultMetadata", "type": "AliasPathMetadata"}, } def __init__( self, *, name: Optional[str] = None, - paths: Optional[List["AliasPath"]] = None, - type: Optional[Union[str, "AliasType"]] = None, + paths: Optional[List["_models.AliasPath"]] = None, + type: Optional[Union[str, "_models.AliasType"]] = None, default_path: Optional[str] = None, - default_pattern: Optional["AliasPattern"] = None, + default_pattern: Optional["_models.AliasPattern"] = None, **kwargs ): """ @@ -63,7 +71,7 @@ def __init__( :paramtype name: str :keyword paths: The paths for an alias. :paramtype paths: list[~azure.mgmt.resource.policy.v2020_09_01.models.AliasPath] - :keyword type: The type of the alias. Possible values include: "NotSpecified", "PlainText", + :keyword type: The type of the alias. Known values are: "NotSpecified", "PlainText", and "Mask". :paramtype type: str or ~azure.mgmt.resource.policy.v2020_09_01.models.AliasType :keyword default_path: The default path for an alias. @@ -71,7 +79,7 @@ def __init__( :keyword default_pattern: The default pattern for an alias. :paramtype default_pattern: ~azure.mgmt.resource.policy.v2020_09_01.models.AliasPattern """ - super(Alias, self).__init__(**kwargs) + super().__init__(**kwargs) self.name = name self.paths = paths self.type = type @@ -80,7 +88,7 @@ def __init__( self.default_metadata = None -class AliasPath(msrest.serialization.Model): +class AliasPath(_serialization.Model): """The type of the paths for alias. Variables are only populated by the server, and will be ignored when sending a request. @@ -97,14 +105,14 @@ class AliasPath(msrest.serialization.Model): """ _validation = { - 'metadata': {'readonly': True}, + "metadata": {"readonly": True}, } _attribute_map = { - 'path': {'key': 'path', 'type': 'str'}, - 'api_versions': {'key': 'apiVersions', 'type': '[str]'}, - 'pattern': {'key': 'pattern', 'type': 'AliasPattern'}, - 'metadata': {'key': 'metadata', 'type': 'AliasPathMetadata'}, + "path": {"key": "path", "type": "str"}, + "api_versions": {"key": "apiVersions", "type": "[str]"}, + "pattern": {"key": "pattern", "type": "AliasPattern"}, + "metadata": {"key": "metadata", "type": "AliasPathMetadata"}, } def __init__( @@ -112,7 +120,7 @@ def __init__( *, path: Optional[str] = None, api_versions: Optional[List[str]] = None, - pattern: Optional["AliasPattern"] = None, + pattern: Optional["_models.AliasPattern"] = None, **kwargs ): """ @@ -123,62 +131,58 @@ def __init__( :keyword pattern: The pattern for an alias path. :paramtype pattern: ~azure.mgmt.resource.policy.v2020_09_01.models.AliasPattern """ - super(AliasPath, self).__init__(**kwargs) + super().__init__(**kwargs) self.path = path self.api_versions = api_versions self.pattern = pattern self.metadata = None -class AliasPathMetadata(msrest.serialization.Model): +class AliasPathMetadata(_serialization.Model): """AliasPathMetadata. Variables are only populated by the server, and will be ignored when sending a request. - :ivar type: The type of the token that the alias path is referring to. Possible values include: - "NotSpecified", "Any", "String", "Object", "Array", "Integer", "Number", "Boolean". + :ivar type: The type of the token that the alias path is referring to. Known values are: + "NotSpecified", "Any", "String", "Object", "Array", "Integer", "Number", and "Boolean". :vartype type: str or ~azure.mgmt.resource.policy.v2020_09_01.models.AliasPathTokenType - :ivar attributes: The attributes of the token that the alias path is referring to. Possible - values include: "None", "Modifiable". + :ivar attributes: The attributes of the token that the alias path is referring to. Known values + are: "None" and "Modifiable". :vartype attributes: str or ~azure.mgmt.resource.policy.v2020_09_01.models.AliasPathAttributes """ _validation = { - 'type': {'readonly': True}, - 'attributes': {'readonly': True}, + "type": {"readonly": True}, + "attributes": {"readonly": True}, } _attribute_map = { - 'type': {'key': 'type', 'type': 'str'}, - 'attributes': {'key': 'attributes', 'type': 'str'}, + "type": {"key": "type", "type": "str"}, + "attributes": {"key": "attributes", "type": "str"}, } - def __init__( - self, - **kwargs - ): - """ - """ - super(AliasPathMetadata, self).__init__(**kwargs) + def __init__(self, **kwargs): + """ """ + super().__init__(**kwargs) self.type = None self.attributes = None -class AliasPattern(msrest.serialization.Model): +class AliasPattern(_serialization.Model): """The type of the pattern for an alias path. :ivar phrase: The alias pattern phrase. :vartype phrase: str :ivar variable: The alias pattern variable. :vartype variable: str - :ivar type: The type of alias pattern. Possible values include: "NotSpecified", "Extract". + :ivar type: The type of alias pattern. Known values are: "NotSpecified" and "Extract". :vartype type: str or ~azure.mgmt.resource.policy.v2020_09_01.models.AliasPatternType """ _attribute_map = { - 'phrase': {'key': 'phrase', 'type': 'str'}, - 'variable': {'key': 'variable', 'type': 'str'}, - 'type': {'key': 'type', 'type': 'str'}, + "phrase": {"key": "phrase", "type": "str"}, + "variable": {"key": "variable", "type": "str"}, + "type": {"key": "type", "type": "str"}, } def __init__( @@ -186,7 +190,7 @@ def __init__( *, phrase: Optional[str] = None, variable: Optional[str] = None, - type: Optional[Union[str, "AliasPatternType"]] = None, + type: Optional[Union[str, "_models.AliasPatternType"]] = None, **kwargs ): """ @@ -194,48 +198,42 @@ def __init__( :paramtype phrase: str :keyword variable: The alias pattern variable. :paramtype variable: str - :keyword type: The type of alias pattern. Possible values include: "NotSpecified", "Extract". + :keyword type: The type of alias pattern. Known values are: "NotSpecified" and "Extract". :paramtype type: str or ~azure.mgmt.resource.policy.v2020_09_01.models.AliasPatternType """ - super(AliasPattern, self).__init__(**kwargs) + super().__init__(**kwargs) self.phrase = phrase self.variable = variable self.type = type -class DataEffect(msrest.serialization.Model): +class DataEffect(_serialization.Model): """The data effect definition. :ivar name: The data effect name. :vartype name: str :ivar details_schema: The data effect details schema. - :vartype details_schema: any + :vartype details_schema: JSON """ _attribute_map = { - 'name': {'key': 'name', 'type': 'str'}, - 'details_schema': {'key': 'detailsSchema', 'type': 'object'}, + "name": {"key": "name", "type": "str"}, + "details_schema": {"key": "detailsSchema", "type": "object"}, } - def __init__( - self, - *, - name: Optional[str] = None, - details_schema: Optional[Any] = None, - **kwargs - ): + def __init__(self, *, name: Optional[str] = None, details_schema: Optional[JSON] = None, **kwargs): """ :keyword name: The data effect name. :paramtype name: str :keyword details_schema: The data effect details schema. - :paramtype details_schema: any + :paramtype details_schema: JSON """ - super(DataEffect, self).__init__(**kwargs) + super().__init__(**kwargs) self.name = name self.details_schema = details_schema -class DataManifestCustomResourceFunctionDefinition(msrest.serialization.Model): +class DataManifestCustomResourceFunctionDefinition(_serialization.Model): """The custom resource function definition. :ivar name: The function name as it will appear in the policy rule. eg - 'vault'. @@ -253,10 +251,10 @@ class DataManifestCustomResourceFunctionDefinition(msrest.serialization.Model): """ _attribute_map = { - 'name': {'key': 'name', 'type': 'str'}, - 'fully_qualified_resource_type': {'key': 'fullyQualifiedResourceType', 'type': 'str'}, - 'default_properties': {'key': 'defaultProperties', 'type': '[str]'}, - 'allow_custom_properties': {'key': 'allowCustomProperties', 'type': 'bool'}, + "name": {"key": "name", "type": "str"}, + "fully_qualified_resource_type": {"key": "fullyQualifiedResourceType", "type": "str"}, + "default_properties": {"key": "defaultProperties", "type": "[str]"}, + "allow_custom_properties": {"key": "allowCustomProperties", "type": "bool"}, } def __init__( @@ -282,14 +280,14 @@ def __init__( vault('2019-06-01'). :paramtype allow_custom_properties: bool """ - super(DataManifestCustomResourceFunctionDefinition, self).__init__(**kwargs) + super().__init__(**kwargs) self.name = name self.fully_qualified_resource_type = fully_qualified_resource_type self.default_properties = default_properties self.allow_custom_properties = allow_custom_properties -class DataPolicyManifest(msrest.serialization.Model): +class DataPolicyManifest(_serialization.Model): # pylint: disable=too-many-instance-attributes """The data policy manifest. Variables are only populated by the server, and will be ignored when sending a request. @@ -322,23 +320,26 @@ class DataPolicyManifest(msrest.serialization.Model): """ _validation = { - 'id': {'readonly': True}, - 'name': {'readonly': True}, - 'type': {'readonly': True}, + "id": {"readonly": True}, + "name": {"readonly": True}, + "type": {"readonly": True}, } _attribute_map = { - 'id': {'key': 'id', 'type': 'str'}, - 'name': {'key': 'name', 'type': 'str'}, - 'type': {'key': 'type', 'type': 'str'}, - 'namespaces': {'key': 'properties.namespaces', 'type': '[str]'}, - 'policy_mode': {'key': 'properties.policyMode', 'type': 'str'}, - 'is_built_in_only': {'key': 'properties.isBuiltInOnly', 'type': 'bool'}, - 'resource_type_aliases': {'key': 'properties.resourceTypeAliases', 'type': '[ResourceTypeAliases]'}, - 'effects': {'key': 'properties.effects', 'type': '[DataEffect]'}, - 'field_values': {'key': 'properties.fieldValues', 'type': '[str]'}, - 'standard': {'key': 'properties.resourceFunctions.standard', 'type': '[str]'}, - 'custom': {'key': 'properties.resourceFunctions.custom', 'type': '[DataManifestCustomResourceFunctionDefinition]'}, + "id": {"key": "id", "type": "str"}, + "name": {"key": "name", "type": "str"}, + "type": {"key": "type", "type": "str"}, + "namespaces": {"key": "properties.namespaces", "type": "[str]"}, + "policy_mode": {"key": "properties.policyMode", "type": "str"}, + "is_built_in_only": {"key": "properties.isBuiltInOnly", "type": "bool"}, + "resource_type_aliases": {"key": "properties.resourceTypeAliases", "type": "[ResourceTypeAliases]"}, + "effects": {"key": "properties.effects", "type": "[DataEffect]"}, + "field_values": {"key": "properties.fieldValues", "type": "[str]"}, + "standard": {"key": "properties.resourceFunctions.standard", "type": "[str]"}, + "custom": { + "key": "properties.resourceFunctions.custom", + "type": "[DataManifestCustomResourceFunctionDefinition]", + }, } def __init__( @@ -347,11 +348,11 @@ def __init__( namespaces: Optional[List[str]] = None, policy_mode: Optional[str] = None, is_built_in_only: Optional[bool] = None, - resource_type_aliases: Optional[List["ResourceTypeAliases"]] = None, - effects: Optional[List["DataEffect"]] = None, + resource_type_aliases: Optional[List["_models.ResourceTypeAliases"]] = None, + effects: Optional[List["_models.DataEffect"]] = None, field_values: Optional[List[str]] = None, standard: Optional[List[str]] = None, - custom: Optional[List["DataManifestCustomResourceFunctionDefinition"]] = None, + custom: Optional[List["_models.DataManifestCustomResourceFunctionDefinition"]] = None, **kwargs ): """ @@ -375,7 +376,7 @@ def __init__( :paramtype custom: list[~azure.mgmt.resource.policy.v2020_09_01.models.DataManifestCustomResourceFunctionDefinition] """ - super(DataPolicyManifest, self).__init__(**kwargs) + super().__init__(**kwargs) self.id = None self.name = None self.type = None @@ -389,7 +390,7 @@ def __init__( self.custom = custom -class DataPolicyManifestListResult(msrest.serialization.Model): +class DataPolicyManifestListResult(_serialization.Model): """List of data policy manifests. :ivar value: An array of data policy manifests. @@ -399,16 +400,12 @@ class DataPolicyManifestListResult(msrest.serialization.Model): """ _attribute_map = { - 'value': {'key': 'value', 'type': '[DataPolicyManifest]'}, - 'next_link': {'key': 'nextLink', 'type': 'str'}, + "value": {"key": "value", "type": "[DataPolicyManifest]"}, + "next_link": {"key": "nextLink", "type": "str"}, } def __init__( - self, - *, - value: Optional[List["DataPolicyManifest"]] = None, - next_link: Optional[str] = None, - **kwargs + self, *, value: Optional[List["_models.DataPolicyManifest"]] = None, next_link: Optional[str] = None, **kwargs ): """ :keyword value: An array of data policy manifests. @@ -416,12 +413,12 @@ def __init__( :keyword next_link: The URL to use for getting the next set of results. :paramtype next_link: str """ - super(DataPolicyManifestListResult, self).__init__(**kwargs) + super().__init__(**kwargs) self.value = value self.next_link = next_link -class ErrorAdditionalInfo(msrest.serialization.Model): +class ErrorAdditionalInfo(_serialization.Model): """The resource management error additional info. Variables are only populated by the server, and will be ignored when sending a request. @@ -429,31 +426,27 @@ class ErrorAdditionalInfo(msrest.serialization.Model): :ivar type: The additional info type. :vartype type: str :ivar info: The additional info. - :vartype info: any + :vartype info: JSON """ _validation = { - 'type': {'readonly': True}, - 'info': {'readonly': True}, + "type": {"readonly": True}, + "info": {"readonly": True}, } _attribute_map = { - 'type': {'key': 'type', 'type': 'str'}, - 'info': {'key': 'info', 'type': 'object'}, + "type": {"key": "type", "type": "str"}, + "info": {"key": "info", "type": "object"}, } - def __init__( - self, - **kwargs - ): - """ - """ - super(ErrorAdditionalInfo, self).__init__(**kwargs) + def __init__(self, **kwargs): + """ """ + super().__init__(**kwargs) self.type = None self.info = None -class ErrorResponse(msrest.serialization.Model): +class ErrorResponse(_serialization.Model): """Common error response for all Azure Resource Manager APIs to return error details for failed operations. (This also follows the OData error response format.). Variables are only populated by the server, and will be ignored when sending a request. @@ -472,28 +465,24 @@ class ErrorResponse(msrest.serialization.Model): """ _validation = { - 'code': {'readonly': True}, - 'message': {'readonly': True}, - 'target': {'readonly': True}, - 'details': {'readonly': True}, - 'additional_info': {'readonly': True}, + "code": {"readonly": True}, + "message": {"readonly": True}, + "target": {"readonly": True}, + "details": {"readonly": True}, + "additional_info": {"readonly": True}, } _attribute_map = { - 'code': {'key': 'code', 'type': 'str'}, - 'message': {'key': 'message', 'type': 'str'}, - 'target': {'key': 'target', 'type': 'str'}, - 'details': {'key': 'details', 'type': '[ErrorResponse]'}, - 'additional_info': {'key': 'additionalInfo', 'type': '[ErrorAdditionalInfo]'}, + "code": {"key": "code", "type": "str"}, + "message": {"key": "message", "type": "str"}, + "target": {"key": "target", "type": "str"}, + "details": {"key": "details", "type": "[ErrorResponse]"}, + "additional_info": {"key": "additionalInfo", "type": "[ErrorAdditionalInfo]"}, } - def __init__( - self, - **kwargs - ): - """ - """ - super(ErrorResponse, self).__init__(**kwargs) + def __init__(self, **kwargs): + """ """ + super().__init__(**kwargs) self.code = None self.message = None self.target = None @@ -501,7 +490,7 @@ def __init__( self.additional_info = None -class Identity(msrest.serialization.Model): +class Identity(_serialization.Model): """Identity for the resource. Variables are only populated by the server, and will be ignored when sending a request. @@ -511,46 +500,40 @@ class Identity(msrest.serialization.Model): :ivar tenant_id: The tenant ID of the resource identity. :vartype tenant_id: str :ivar type: The identity type. This is the only required field when adding a system assigned - identity to a resource. Possible values include: "SystemAssigned", "None". + identity to a resource. Known values are: "SystemAssigned" and "None". :vartype type: str or ~azure.mgmt.resource.policy.v2020_09_01.models.ResourceIdentityType """ _validation = { - 'principal_id': {'readonly': True}, - 'tenant_id': {'readonly': True}, + "principal_id": {"readonly": True}, + "tenant_id": {"readonly": True}, } _attribute_map = { - 'principal_id': {'key': 'principalId', 'type': 'str'}, - 'tenant_id': {'key': 'tenantId', 'type': 'str'}, - 'type': {'key': 'type', 'type': 'str'}, + "principal_id": {"key": "principalId", "type": "str"}, + "tenant_id": {"key": "tenantId", "type": "str"}, + "type": {"key": "type", "type": "str"}, } - def __init__( - self, - *, - type: Optional[Union[str, "ResourceIdentityType"]] = None, - **kwargs - ): + def __init__(self, *, type: Optional[Union[str, "_models.ResourceIdentityType"]] = None, **kwargs): """ :keyword type: The identity type. This is the only required field when adding a system assigned - identity to a resource. Possible values include: "SystemAssigned", "None". + identity to a resource. Known values are: "SystemAssigned" and "None". :paramtype type: str or ~azure.mgmt.resource.policy.v2020_09_01.models.ResourceIdentityType """ - super(Identity, self).__init__(**kwargs) + super().__init__(**kwargs) self.principal_id = None self.tenant_id = None self.type = type -class NonComplianceMessage(msrest.serialization.Model): +class NonComplianceMessage(_serialization.Model): """A message that describes why a resource is non-compliant with the policy. This is shown in 'deny' error messages and on resource's non-compliant compliance results. All required parameters must be populated in order to send to Azure. - :ivar message: Required. A message that describes why a resource is non-compliant with the - policy. This is shown in 'deny' error messages and on resource's non-compliant compliance - results. + :ivar message: A message that describes why a resource is non-compliant with the policy. This + is shown in 'deny' error messages and on resource's non-compliant compliance results. Required. :vartype message: str :ivar policy_definition_reference_id: The policy definition reference ID within a policy set definition the message is intended for. This is only applicable if the policy assignment @@ -560,25 +543,19 @@ class NonComplianceMessage(msrest.serialization.Model): """ _validation = { - 'message': {'required': True}, + "message": {"required": True}, } _attribute_map = { - 'message': {'key': 'message', 'type': 'str'}, - 'policy_definition_reference_id': {'key': 'policyDefinitionReferenceId', 'type': 'str'}, + "message": {"key": "message", "type": "str"}, + "policy_definition_reference_id": {"key": "policyDefinitionReferenceId", "type": "str"}, } - def __init__( - self, - *, - message: str, - policy_definition_reference_id: Optional[str] = None, - **kwargs - ): + def __init__(self, *, message: str, policy_definition_reference_id: Optional[str] = None, **kwargs): """ - :keyword message: Required. A message that describes why a resource is non-compliant with the - policy. This is shown in 'deny' error messages and on resource's non-compliant compliance - results. + :keyword message: A message that describes why a resource is non-compliant with the policy. + This is shown in 'deny' error messages and on resource's non-compliant compliance results. + Required. :paramtype message: str :keyword policy_definition_reference_id: The policy definition reference ID within a policy set definition the message is intended for. This is only applicable if the policy assignment @@ -586,67 +563,67 @@ def __init__( assigned by this policy assignment. :paramtype policy_definition_reference_id: str """ - super(NonComplianceMessage, self).__init__(**kwargs) + super().__init__(**kwargs) self.message = message self.policy_definition_reference_id = policy_definition_reference_id -class ParameterDefinitionsValue(msrest.serialization.Model): +class ParameterDefinitionsValue(_serialization.Model): """The definition of a parameter that can be provided to the policy. - :ivar type: The data type of the parameter. Possible values include: "String", "Array", - "Object", "Boolean", "Integer", "Float", "DateTime". + :ivar type: The data type of the parameter. Known values are: "String", "Array", "Object", + "Boolean", "Integer", "Float", and "DateTime". :vartype type: str or ~azure.mgmt.resource.policy.v2020_09_01.models.ParameterType :ivar allowed_values: The allowed values for the parameter. - :vartype allowed_values: list[any] + :vartype allowed_values: list[JSON] :ivar default_value: The default value for the parameter if no value is provided. - :vartype default_value: any + :vartype default_value: JSON :ivar metadata: General metadata for the parameter. :vartype metadata: ~azure.mgmt.resource.policy.v2020_09_01.models.ParameterDefinitionsValueMetadata """ _attribute_map = { - 'type': {'key': 'type', 'type': 'str'}, - 'allowed_values': {'key': 'allowedValues', 'type': '[object]'}, - 'default_value': {'key': 'defaultValue', 'type': 'object'}, - 'metadata': {'key': 'metadata', 'type': 'ParameterDefinitionsValueMetadata'}, + "type": {"key": "type", "type": "str"}, + "allowed_values": {"key": "allowedValues", "type": "[object]"}, + "default_value": {"key": "defaultValue", "type": "object"}, + "metadata": {"key": "metadata", "type": "ParameterDefinitionsValueMetadata"}, } def __init__( self, *, - type: Optional[Union[str, "ParameterType"]] = None, - allowed_values: Optional[List[Any]] = None, - default_value: Optional[Any] = None, - metadata: Optional["ParameterDefinitionsValueMetadata"] = None, + type: Optional[Union[str, "_models.ParameterType"]] = None, + allowed_values: Optional[List[JSON]] = None, + default_value: Optional[JSON] = None, + metadata: Optional["_models.ParameterDefinitionsValueMetadata"] = None, **kwargs ): """ - :keyword type: The data type of the parameter. Possible values include: "String", "Array", - "Object", "Boolean", "Integer", "Float", "DateTime". + :keyword type: The data type of the parameter. Known values are: "String", "Array", "Object", + "Boolean", "Integer", "Float", and "DateTime". :paramtype type: str or ~azure.mgmt.resource.policy.v2020_09_01.models.ParameterType :keyword allowed_values: The allowed values for the parameter. - :paramtype allowed_values: list[any] + :paramtype allowed_values: list[JSON] :keyword default_value: The default value for the parameter if no value is provided. - :paramtype default_value: any + :paramtype default_value: JSON :keyword metadata: General metadata for the parameter. :paramtype metadata: ~azure.mgmt.resource.policy.v2020_09_01.models.ParameterDefinitionsValueMetadata """ - super(ParameterDefinitionsValue, self).__init__(**kwargs) + super().__init__(**kwargs) self.type = type self.allowed_values = allowed_values self.default_value = default_value self.metadata = metadata -class ParameterDefinitionsValueMetadata(msrest.serialization.Model): +class ParameterDefinitionsValueMetadata(_serialization.Model): """General metadata for the parameter. :ivar additional_properties: Unmatched properties from the message are deserialized to this collection. - :vartype additional_properties: dict[str, any] + :vartype additional_properties: dict[str, JSON] :ivar display_name: The display name for the parameter. :vartype display_name: str :ivar description: The description of the parameter. @@ -661,17 +638,17 @@ class ParameterDefinitionsValueMetadata(msrest.serialization.Model): """ _attribute_map = { - 'additional_properties': {'key': '', 'type': '{object}'}, - 'display_name': {'key': 'displayName', 'type': 'str'}, - 'description': {'key': 'description', 'type': 'str'}, - 'strong_type': {'key': 'strongType', 'type': 'str'}, - 'assign_permissions': {'key': 'assignPermissions', 'type': 'bool'}, + "additional_properties": {"key": "", "type": "{object}"}, + "display_name": {"key": "displayName", "type": "str"}, + "description": {"key": "description", "type": "str"}, + "strong_type": {"key": "strongType", "type": "str"}, + "assign_permissions": {"key": "assignPermissions", "type": "bool"}, } def __init__( self, *, - additional_properties: Optional[Dict[str, Any]] = None, + additional_properties: Optional[Dict[str, JSON]] = None, display_name: Optional[str] = None, description: Optional[str] = None, strong_type: Optional[str] = None, @@ -681,7 +658,7 @@ def __init__( """ :keyword additional_properties: Unmatched properties from the message are deserialized to this collection. - :paramtype additional_properties: dict[str, any] + :paramtype additional_properties: dict[str, JSON] :keyword display_name: The display name for the parameter. :paramtype display_name: str :keyword description: The description of the parameter. @@ -694,7 +671,7 @@ def __init__( is useful in case you wish to assign permissions outside the assignment scope. :paramtype assign_permissions: bool """ - super(ParameterDefinitionsValueMetadata, self).__init__(**kwargs) + super().__init__(**kwargs) self.additional_properties = additional_properties self.display_name = display_name self.description = description @@ -702,32 +679,27 @@ def __init__( self.assign_permissions = assign_permissions -class ParameterValuesValue(msrest.serialization.Model): +class ParameterValuesValue(_serialization.Model): """The value of a parameter. :ivar value: The value of the parameter. - :vartype value: any + :vartype value: JSON """ _attribute_map = { - 'value': {'key': 'value', 'type': 'object'}, + "value": {"key": "value", "type": "object"}, } - def __init__( - self, - *, - value: Optional[Any] = None, - **kwargs - ): + def __init__(self, *, value: Optional[JSON] = None, **kwargs): """ :keyword value: The value of the parameter. - :paramtype value: any + :paramtype value: JSON """ - super(ParameterValuesValue, self).__init__(**kwargs) + super().__init__(**kwargs) self.value = value -class PolicyAssignment(msrest.serialization.Model): +class PolicyAssignment(_serialization.Model): # pylint: disable=too-many-instance-attributes """The policy assignment. Variables are only populated by the server, and will be ignored when sending a request. @@ -760,9 +732,9 @@ class PolicyAssignment(msrest.serialization.Model): :vartype description: str :ivar metadata: The policy assignment metadata. Metadata is an open ended object and is typically a collection of key value pairs. - :vartype metadata: any + :vartype metadata: JSON :ivar enforcement_mode: The policy assignment enforcement mode. Possible values are Default and - DoNotEnforce. Possible values include: "Default", "DoNotEnforce". Default value: "Default". + DoNotEnforce. Known values are: "Default" and "DoNotEnforce". :vartype enforcement_mode: str or ~azure.mgmt.resource.policy.v2020_09_01.models.EnforcementMode :ivar non_compliance_messages: The messages that describe why a resource is non-compliant with @@ -772,42 +744,42 @@ class PolicyAssignment(msrest.serialization.Model): """ _validation = { - 'id': {'readonly': True}, - 'type': {'readonly': True}, - 'name': {'readonly': True}, - 'scope': {'readonly': True}, + "id": {"readonly": True}, + "type": {"readonly": True}, + "name": {"readonly": True}, + "scope": {"readonly": True}, } _attribute_map = { - 'id': {'key': 'id', 'type': 'str'}, - 'type': {'key': 'type', 'type': 'str'}, - 'name': {'key': 'name', 'type': 'str'}, - 'location': {'key': 'location', 'type': 'str'}, - 'identity': {'key': 'identity', 'type': 'Identity'}, - 'display_name': {'key': 'properties.displayName', 'type': 'str'}, - 'policy_definition_id': {'key': 'properties.policyDefinitionId', 'type': 'str'}, - 'scope': {'key': 'properties.scope', 'type': 'str'}, - 'not_scopes': {'key': 'properties.notScopes', 'type': '[str]'}, - 'parameters': {'key': 'properties.parameters', 'type': '{ParameterValuesValue}'}, - 'description': {'key': 'properties.description', 'type': 'str'}, - 'metadata': {'key': 'properties.metadata', 'type': 'object'}, - 'enforcement_mode': {'key': 'properties.enforcementMode', 'type': 'str'}, - 'non_compliance_messages': {'key': 'properties.nonComplianceMessages', 'type': '[NonComplianceMessage]'}, + "id": {"key": "id", "type": "str"}, + "type": {"key": "type", "type": "str"}, + "name": {"key": "name", "type": "str"}, + "location": {"key": "location", "type": "str"}, + "identity": {"key": "identity", "type": "Identity"}, + "display_name": {"key": "properties.displayName", "type": "str"}, + "policy_definition_id": {"key": "properties.policyDefinitionId", "type": "str"}, + "scope": {"key": "properties.scope", "type": "str"}, + "not_scopes": {"key": "properties.notScopes", "type": "[str]"}, + "parameters": {"key": "properties.parameters", "type": "{ParameterValuesValue}"}, + "description": {"key": "properties.description", "type": "str"}, + "metadata": {"key": "properties.metadata", "type": "object"}, + "enforcement_mode": {"key": "properties.enforcementMode", "type": "str"}, + "non_compliance_messages": {"key": "properties.nonComplianceMessages", "type": "[NonComplianceMessage]"}, } def __init__( self, *, location: Optional[str] = None, - identity: Optional["Identity"] = None, + identity: Optional["_models.Identity"] = None, display_name: Optional[str] = None, policy_definition_id: Optional[str] = None, not_scopes: Optional[List[str]] = None, - parameters: Optional[Dict[str, "ParameterValuesValue"]] = None, + parameters: Optional[Dict[str, "_models.ParameterValuesValue"]] = None, description: Optional[str] = None, - metadata: Optional[Any] = None, - enforcement_mode: Optional[Union[str, "EnforcementMode"]] = "Default", - non_compliance_messages: Optional[List["NonComplianceMessage"]] = None, + metadata: Optional[JSON] = None, + enforcement_mode: Union[str, "_models.EnforcementMode"] = "Default", + non_compliance_messages: Optional[List["_models.NonComplianceMessage"]] = None, **kwargs ): """ @@ -831,9 +803,9 @@ def __init__( :paramtype description: str :keyword metadata: The policy assignment metadata. Metadata is an open ended object and is typically a collection of key value pairs. - :paramtype metadata: any + :paramtype metadata: JSON :keyword enforcement_mode: The policy assignment enforcement mode. Possible values are Default - and DoNotEnforce. Possible values include: "Default", "DoNotEnforce". Default value: "Default". + and DoNotEnforce. Known values are: "Default" and "DoNotEnforce". :paramtype enforcement_mode: str or ~azure.mgmt.resource.policy.v2020_09_01.models.EnforcementMode :keyword non_compliance_messages: The messages that describe why a resource is non-compliant @@ -841,7 +813,7 @@ def __init__( :paramtype non_compliance_messages: list[~azure.mgmt.resource.policy.v2020_09_01.models.NonComplianceMessage] """ - super(PolicyAssignment, self).__init__(**kwargs) + super().__init__(**kwargs) self.id = None self.type = None self.name = None @@ -858,7 +830,7 @@ def __init__( self.non_compliance_messages = non_compliance_messages -class PolicyAssignmentListResult(msrest.serialization.Model): +class PolicyAssignmentListResult(_serialization.Model): """List of policy assignments. :ivar value: An array of policy assignments. @@ -868,16 +840,12 @@ class PolicyAssignmentListResult(msrest.serialization.Model): """ _attribute_map = { - 'value': {'key': 'value', 'type': '[PolicyAssignment]'}, - 'next_link': {'key': 'nextLink', 'type': 'str'}, + "value": {"key": "value", "type": "[PolicyAssignment]"}, + "next_link": {"key": "nextLink", "type": "str"}, } def __init__( - self, - *, - value: Optional[List["PolicyAssignment"]] = None, - next_link: Optional[str] = None, - **kwargs + self, *, value: Optional[List["_models.PolicyAssignment"]] = None, next_link: Optional[str] = None, **kwargs ): """ :keyword value: An array of policy assignments. @@ -885,12 +853,12 @@ def __init__( :keyword next_link: The URL to use for getting the next set of results. :paramtype next_link: str """ - super(PolicyAssignmentListResult, self).__init__(**kwargs) + super().__init__(**kwargs) self.value = value self.next_link = next_link -class PolicyDefinition(msrest.serialization.Model): +class PolicyDefinition(_serialization.Model): """The policy definition. Variables are only populated by the server, and will be ignored when sending a request. @@ -902,7 +870,7 @@ class PolicyDefinition(msrest.serialization.Model): :ivar type: The type of the resource (Microsoft.Authorization/policyDefinitions). :vartype type: str :ivar policy_type: The type of policy definition. Possible values are NotSpecified, BuiltIn, - Custom, and Static. Possible values include: "NotSpecified", "BuiltIn", "Custom", "Static". + Custom, and Static. Known values are: "NotSpecified", "BuiltIn", "Custom", and "Static". :vartype policy_type: str or ~azure.mgmt.resource.policy.v2020_09_01.models.PolicyType :ivar mode: The policy definition mode. Some examples are All, Indexed, Microsoft.KeyVault.Data. @@ -912,10 +880,10 @@ class PolicyDefinition(msrest.serialization.Model): :ivar description: The policy definition description. :vartype description: str :ivar policy_rule: The policy rule. - :vartype policy_rule: any + :vartype policy_rule: JSON :ivar metadata: The policy definition metadata. Metadata is an open ended object and is typically a collection of key value pairs. - :vartype metadata: any + :vartype metadata: JSON :ivar parameters: The parameter definitions for parameters used in the policy rule. The keys are the parameter names. :vartype parameters: dict[str, @@ -923,39 +891,39 @@ class PolicyDefinition(msrest.serialization.Model): """ _validation = { - 'id': {'readonly': True}, - 'name': {'readonly': True}, - 'type': {'readonly': True}, + "id": {"readonly": True}, + "name": {"readonly": True}, + "type": {"readonly": True}, } _attribute_map = { - 'id': {'key': 'id', 'type': 'str'}, - 'name': {'key': 'name', 'type': 'str'}, - 'type': {'key': 'type', 'type': 'str'}, - 'policy_type': {'key': 'properties.policyType', 'type': 'str'}, - 'mode': {'key': 'properties.mode', 'type': 'str'}, - 'display_name': {'key': 'properties.displayName', 'type': 'str'}, - 'description': {'key': 'properties.description', 'type': 'str'}, - 'policy_rule': {'key': 'properties.policyRule', 'type': 'object'}, - 'metadata': {'key': 'properties.metadata', 'type': 'object'}, - 'parameters': {'key': 'properties.parameters', 'type': '{ParameterDefinitionsValue}'}, + "id": {"key": "id", "type": "str"}, + "name": {"key": "name", "type": "str"}, + "type": {"key": "type", "type": "str"}, + "policy_type": {"key": "properties.policyType", "type": "str"}, + "mode": {"key": "properties.mode", "type": "str"}, + "display_name": {"key": "properties.displayName", "type": "str"}, + "description": {"key": "properties.description", "type": "str"}, + "policy_rule": {"key": "properties.policyRule", "type": "object"}, + "metadata": {"key": "properties.metadata", "type": "object"}, + "parameters": {"key": "properties.parameters", "type": "{ParameterDefinitionsValue}"}, } def __init__( self, *, - policy_type: Optional[Union[str, "PolicyType"]] = None, - mode: Optional[str] = "Indexed", + policy_type: Optional[Union[str, "_models.PolicyType"]] = None, + mode: str = "Indexed", display_name: Optional[str] = None, description: Optional[str] = None, - policy_rule: Optional[Any] = None, - metadata: Optional[Any] = None, - parameters: Optional[Dict[str, "ParameterDefinitionsValue"]] = None, + policy_rule: Optional[JSON] = None, + metadata: Optional[JSON] = None, + parameters: Optional[Dict[str, "_models.ParameterDefinitionsValue"]] = None, **kwargs ): """ :keyword policy_type: The type of policy definition. Possible values are NotSpecified, BuiltIn, - Custom, and Static. Possible values include: "NotSpecified", "BuiltIn", "Custom", "Static". + Custom, and Static. Known values are: "NotSpecified", "BuiltIn", "Custom", and "Static". :paramtype policy_type: str or ~azure.mgmt.resource.policy.v2020_09_01.models.PolicyType :keyword mode: The policy definition mode. Some examples are All, Indexed, Microsoft.KeyVault.Data. @@ -965,16 +933,16 @@ def __init__( :keyword description: The policy definition description. :paramtype description: str :keyword policy_rule: The policy rule. - :paramtype policy_rule: any + :paramtype policy_rule: JSON :keyword metadata: The policy definition metadata. Metadata is an open ended object and is typically a collection of key value pairs. - :paramtype metadata: any + :paramtype metadata: JSON :keyword parameters: The parameter definitions for parameters used in the policy rule. The keys are the parameter names. :paramtype parameters: dict[str, ~azure.mgmt.resource.policy.v2020_09_01.models.ParameterDefinitionsValue] """ - super(PolicyDefinition, self).__init__(**kwargs) + super().__init__(**kwargs) self.id = None self.name = None self.type = None @@ -987,12 +955,12 @@ def __init__( self.parameters = parameters -class PolicyDefinitionGroup(msrest.serialization.Model): +class PolicyDefinitionGroup(_serialization.Model): """The policy definition group. All required parameters must be populated in order to send to Azure. - :ivar name: Required. The name of the group. + :ivar name: The name of the group. Required. :vartype name: str :ivar display_name: The group's display name. :vartype display_name: str @@ -1006,15 +974,15 @@ class PolicyDefinitionGroup(msrest.serialization.Model): """ _validation = { - 'name': {'required': True}, + "name": {"required": True}, } _attribute_map = { - 'name': {'key': 'name', 'type': 'str'}, - 'display_name': {'key': 'displayName', 'type': 'str'}, - 'category': {'key': 'category', 'type': 'str'}, - 'description': {'key': 'description', 'type': 'str'}, - 'additional_metadata_id': {'key': 'additionalMetadataId', 'type': 'str'}, + "name": {"key": "name", "type": "str"}, + "display_name": {"key": "displayName", "type": "str"}, + "category": {"key": "category", "type": "str"}, + "description": {"key": "description", "type": "str"}, + "additional_metadata_id": {"key": "additionalMetadataId", "type": "str"}, } def __init__( @@ -1028,7 +996,7 @@ def __init__( **kwargs ): """ - :keyword name: Required. The name of the group. + :keyword name: The name of the group. Required. :paramtype name: str :keyword display_name: The group's display name. :paramtype display_name: str @@ -1040,7 +1008,7 @@ def __init__( about the group. :paramtype additional_metadata_id: str """ - super(PolicyDefinitionGroup, self).__init__(**kwargs) + super().__init__(**kwargs) self.name = name self.display_name = display_name self.category = category @@ -1048,7 +1016,7 @@ def __init__( self.additional_metadata_id = additional_metadata_id -class PolicyDefinitionListResult(msrest.serialization.Model): +class PolicyDefinitionListResult(_serialization.Model): """List of policy definitions. :ivar value: An array of policy definitions. @@ -1058,16 +1026,12 @@ class PolicyDefinitionListResult(msrest.serialization.Model): """ _attribute_map = { - 'value': {'key': 'value', 'type': '[PolicyDefinition]'}, - 'next_link': {'key': 'nextLink', 'type': 'str'}, + "value": {"key": "value", "type": "[PolicyDefinition]"}, + "next_link": {"key": "nextLink", "type": "str"}, } def __init__( - self, - *, - value: Optional[List["PolicyDefinition"]] = None, - next_link: Optional[str] = None, - **kwargs + self, *, value: Optional[List["_models.PolicyDefinition"]] = None, next_link: Optional[str] = None, **kwargs ): """ :keyword value: An array of policy definitions. @@ -1075,17 +1039,17 @@ def __init__( :keyword next_link: The URL to use for getting the next set of results. :paramtype next_link: str """ - super(PolicyDefinitionListResult, self).__init__(**kwargs) + super().__init__(**kwargs) self.value = value self.next_link = next_link -class PolicyDefinitionReference(msrest.serialization.Model): +class PolicyDefinitionReference(_serialization.Model): """The policy definition reference. All required parameters must be populated in order to send to Azure. - :ivar policy_definition_id: Required. The ID of the policy definition or policy set definition. + :ivar policy_definition_id: The ID of the policy definition or policy set definition. Required. :vartype policy_definition_id: str :ivar parameters: The parameter values for the referenced policy rule. The keys are the parameter names. @@ -1099,28 +1063,28 @@ class PolicyDefinitionReference(msrest.serialization.Model): """ _validation = { - 'policy_definition_id': {'required': True}, + "policy_definition_id": {"required": True}, } _attribute_map = { - 'policy_definition_id': {'key': 'policyDefinitionId', 'type': 'str'}, - 'parameters': {'key': 'parameters', 'type': '{ParameterValuesValue}'}, - 'policy_definition_reference_id': {'key': 'policyDefinitionReferenceId', 'type': 'str'}, - 'group_names': {'key': 'groupNames', 'type': '[str]'}, + "policy_definition_id": {"key": "policyDefinitionId", "type": "str"}, + "parameters": {"key": "parameters", "type": "{ParameterValuesValue}"}, + "policy_definition_reference_id": {"key": "policyDefinitionReferenceId", "type": "str"}, + "group_names": {"key": "groupNames", "type": "[str]"}, } def __init__( self, *, policy_definition_id: str, - parameters: Optional[Dict[str, "ParameterValuesValue"]] = None, + parameters: Optional[Dict[str, "_models.ParameterValuesValue"]] = None, policy_definition_reference_id: Optional[str] = None, group_names: Optional[List[str]] = None, **kwargs ): """ - :keyword policy_definition_id: Required. The ID of the policy definition or policy set - definition. + :keyword policy_definition_id: The ID of the policy definition or policy set definition. + Required. :paramtype policy_definition_id: str :keyword parameters: The parameter values for the referenced policy rule. The keys are the parameter names. @@ -1132,14 +1096,14 @@ def __init__( :keyword group_names: The name of the groups that this policy definition reference belongs to. :paramtype group_names: list[str] """ - super(PolicyDefinitionReference, self).__init__(**kwargs) + super().__init__(**kwargs) self.policy_definition_id = policy_definition_id self.parameters = parameters self.policy_definition_reference_id = policy_definition_reference_id self.group_names = group_names -class PolicyExemption(msrest.serialization.Model): +class PolicyExemption(_serialization.Model): # pylint: disable=too-many-instance-attributes """The policy exemption. Variables are only populated by the server, and will be ignored when sending a request. @@ -1155,13 +1119,13 @@ class PolicyExemption(msrest.serialization.Model): :vartype name: str :ivar type: The type of the resource (Microsoft.Authorization/policyExemptions). :vartype type: str - :ivar policy_assignment_id: Required. The ID of the policy assignment that is being exempted. + :ivar policy_assignment_id: The ID of the policy assignment that is being exempted. Required. :vartype policy_assignment_id: str :ivar policy_definition_reference_ids: The policy definition reference ID list when the associated policy assignment is an assignment of a policy set definition. :vartype policy_definition_reference_ids: list[str] - :ivar exemption_category: Required. The policy exemption category. Possible values are Waiver - and Mitigated. Possible values include: "Waiver", "Mitigated". + :ivar exemption_category: The policy exemption category. Possible values are Waiver and + Mitigated. Required. Known values are: "Waiver" and "Mitigated". :vartype exemption_category: str or ~azure.mgmt.resource.policy.v2020_09_01.models.ExemptionCategory :ivar expires_on: The expiration date and time (in UTC ISO 8601 format yyyy-MM-ddTHH:mm:ssZ) of @@ -1173,53 +1137,53 @@ class PolicyExemption(msrest.serialization.Model): :vartype description: str :ivar metadata: The policy exemption metadata. Metadata is an open ended object and is typically a collection of key value pairs. - :vartype metadata: any + :vartype metadata: JSON """ _validation = { - 'system_data': {'readonly': True}, - 'id': {'readonly': True}, - 'name': {'readonly': True}, - 'type': {'readonly': True}, - 'policy_assignment_id': {'required': True}, - 'exemption_category': {'required': True}, + "system_data": {"readonly": True}, + "id": {"readonly": True}, + "name": {"readonly": True}, + "type": {"readonly": True}, + "policy_assignment_id": {"required": True}, + "exemption_category": {"required": True}, } _attribute_map = { - 'system_data': {'key': 'systemData', 'type': 'SystemData'}, - 'id': {'key': 'id', 'type': 'str'}, - 'name': {'key': 'name', 'type': 'str'}, - 'type': {'key': 'type', 'type': 'str'}, - 'policy_assignment_id': {'key': 'properties.policyAssignmentId', 'type': 'str'}, - 'policy_definition_reference_ids': {'key': 'properties.policyDefinitionReferenceIds', 'type': '[str]'}, - 'exemption_category': {'key': 'properties.exemptionCategory', 'type': 'str'}, - 'expires_on': {'key': 'properties.expiresOn', 'type': 'iso-8601'}, - 'display_name': {'key': 'properties.displayName', 'type': 'str'}, - 'description': {'key': 'properties.description', 'type': 'str'}, - 'metadata': {'key': 'properties.metadata', 'type': 'object'}, + "system_data": {"key": "systemData", "type": "SystemData"}, + "id": {"key": "id", "type": "str"}, + "name": {"key": "name", "type": "str"}, + "type": {"key": "type", "type": "str"}, + "policy_assignment_id": {"key": "properties.policyAssignmentId", "type": "str"}, + "policy_definition_reference_ids": {"key": "properties.policyDefinitionReferenceIds", "type": "[str]"}, + "exemption_category": {"key": "properties.exemptionCategory", "type": "str"}, + "expires_on": {"key": "properties.expiresOn", "type": "iso-8601"}, + "display_name": {"key": "properties.displayName", "type": "str"}, + "description": {"key": "properties.description", "type": "str"}, + "metadata": {"key": "properties.metadata", "type": "object"}, } def __init__( self, *, policy_assignment_id: str, - exemption_category: Union[str, "ExemptionCategory"], + exemption_category: Union[str, "_models.ExemptionCategory"], policy_definition_reference_ids: Optional[List[str]] = None, expires_on: Optional[datetime.datetime] = None, display_name: Optional[str] = None, description: Optional[str] = None, - metadata: Optional[Any] = None, + metadata: Optional[JSON] = None, **kwargs ): """ - :keyword policy_assignment_id: Required. The ID of the policy assignment that is being - exempted. + :keyword policy_assignment_id: The ID of the policy assignment that is being exempted. + Required. :paramtype policy_assignment_id: str :keyword policy_definition_reference_ids: The policy definition reference ID list when the associated policy assignment is an assignment of a policy set definition. :paramtype policy_definition_reference_ids: list[str] - :keyword exemption_category: Required. The policy exemption category. Possible values are - Waiver and Mitigated. Possible values include: "Waiver", "Mitigated". + :keyword exemption_category: The policy exemption category. Possible values are Waiver and + Mitigated. Required. Known values are: "Waiver" and "Mitigated". :paramtype exemption_category: str or ~azure.mgmt.resource.policy.v2020_09_01.models.ExemptionCategory :keyword expires_on: The expiration date and time (in UTC ISO 8601 format yyyy-MM-ddTHH:mm:ssZ) @@ -1231,9 +1195,9 @@ def __init__( :paramtype description: str :keyword metadata: The policy exemption metadata. Metadata is an open ended object and is typically a collection of key value pairs. - :paramtype metadata: any + :paramtype metadata: JSON """ - super(PolicyExemption, self).__init__(**kwargs) + super().__init__(**kwargs) self.system_data = None self.id = None self.name = None @@ -1247,7 +1211,7 @@ def __init__( self.metadata = metadata -class PolicyExemptionListResult(msrest.serialization.Model): +class PolicyExemptionListResult(_serialization.Model): """List of policy exemptions. Variables are only populated by the server, and will be ignored when sending a request. @@ -1259,30 +1223,25 @@ class PolicyExemptionListResult(msrest.serialization.Model): """ _validation = { - 'next_link': {'readonly': True}, + "next_link": {"readonly": True}, } _attribute_map = { - 'value': {'key': 'value', 'type': '[PolicyExemption]'}, - 'next_link': {'key': 'nextLink', 'type': 'str'}, + "value": {"key": "value", "type": "[PolicyExemption]"}, + "next_link": {"key": "nextLink", "type": "str"}, } - def __init__( - self, - *, - value: Optional[List["PolicyExemption"]] = None, - **kwargs - ): + def __init__(self, *, value: Optional[List["_models.PolicyExemption"]] = None, **kwargs): """ :keyword value: An array of policy exemptions. :paramtype value: list[~azure.mgmt.resource.policy.v2020_09_01.models.PolicyExemption] """ - super(PolicyExemptionListResult, self).__init__(**kwargs) + super().__init__(**kwargs) self.value = value self.next_link = None -class PolicySetDefinition(msrest.serialization.Model): +class PolicySetDefinition(_serialization.Model): """The policy set definition. Variables are only populated by the server, and will be ignored when sending a request. @@ -1294,7 +1253,7 @@ class PolicySetDefinition(msrest.serialization.Model): :ivar type: The type of the resource (Microsoft.Authorization/policySetDefinitions). :vartype type: str :ivar policy_type: The type of policy definition. Possible values are NotSpecified, BuiltIn, - Custom, and Static. Possible values include: "NotSpecified", "BuiltIn", "Custom", "Static". + Custom, and Static. Known values are: "NotSpecified", "BuiltIn", "Custom", and "Static". :vartype policy_type: str or ~azure.mgmt.resource.policy.v2020_09_01.models.PolicyType :ivar display_name: The display name of the policy set definition. :vartype display_name: str @@ -1302,7 +1261,7 @@ class PolicySetDefinition(msrest.serialization.Model): :vartype description: str :ivar metadata: The policy set definition metadata. Metadata is an open ended object and is typically a collection of key value pairs. - :vartype metadata: any + :vartype metadata: JSON :ivar parameters: The policy set definition parameters that can be used in policy definition references. :vartype parameters: dict[str, @@ -1317,39 +1276,39 @@ class PolicySetDefinition(msrest.serialization.Model): """ _validation = { - 'id': {'readonly': True}, - 'name': {'readonly': True}, - 'type': {'readonly': True}, + "id": {"readonly": True}, + "name": {"readonly": True}, + "type": {"readonly": True}, } _attribute_map = { - 'id': {'key': 'id', 'type': 'str'}, - 'name': {'key': 'name', 'type': 'str'}, - 'type': {'key': 'type', 'type': 'str'}, - 'policy_type': {'key': 'properties.policyType', 'type': 'str'}, - 'display_name': {'key': 'properties.displayName', 'type': 'str'}, - 'description': {'key': 'properties.description', 'type': 'str'}, - 'metadata': {'key': 'properties.metadata', 'type': 'object'}, - 'parameters': {'key': 'properties.parameters', 'type': '{ParameterDefinitionsValue}'}, - 'policy_definitions': {'key': 'properties.policyDefinitions', 'type': '[PolicyDefinitionReference]'}, - 'policy_definition_groups': {'key': 'properties.policyDefinitionGroups', 'type': '[PolicyDefinitionGroup]'}, + "id": {"key": "id", "type": "str"}, + "name": {"key": "name", "type": "str"}, + "type": {"key": "type", "type": "str"}, + "policy_type": {"key": "properties.policyType", "type": "str"}, + "display_name": {"key": "properties.displayName", "type": "str"}, + "description": {"key": "properties.description", "type": "str"}, + "metadata": {"key": "properties.metadata", "type": "object"}, + "parameters": {"key": "properties.parameters", "type": "{ParameterDefinitionsValue}"}, + "policy_definitions": {"key": "properties.policyDefinitions", "type": "[PolicyDefinitionReference]"}, + "policy_definition_groups": {"key": "properties.policyDefinitionGroups", "type": "[PolicyDefinitionGroup]"}, } def __init__( self, *, - policy_type: Optional[Union[str, "PolicyType"]] = None, + policy_type: Optional[Union[str, "_models.PolicyType"]] = None, display_name: Optional[str] = None, description: Optional[str] = None, - metadata: Optional[Any] = None, - parameters: Optional[Dict[str, "ParameterDefinitionsValue"]] = None, - policy_definitions: Optional[List["PolicyDefinitionReference"]] = None, - policy_definition_groups: Optional[List["PolicyDefinitionGroup"]] = None, + metadata: Optional[JSON] = None, + parameters: Optional[Dict[str, "_models.ParameterDefinitionsValue"]] = None, + policy_definitions: Optional[List["_models.PolicyDefinitionReference"]] = None, + policy_definition_groups: Optional[List["_models.PolicyDefinitionGroup"]] = None, **kwargs ): """ :keyword policy_type: The type of policy definition. Possible values are NotSpecified, BuiltIn, - Custom, and Static. Possible values include: "NotSpecified", "BuiltIn", "Custom", "Static". + Custom, and Static. Known values are: "NotSpecified", "BuiltIn", "Custom", and "Static". :paramtype policy_type: str or ~azure.mgmt.resource.policy.v2020_09_01.models.PolicyType :keyword display_name: The display name of the policy set definition. :paramtype display_name: str @@ -1357,7 +1316,7 @@ def __init__( :paramtype description: str :keyword metadata: The policy set definition metadata. Metadata is an open ended object and is typically a collection of key value pairs. - :paramtype metadata: any + :paramtype metadata: JSON :keyword parameters: The policy set definition parameters that can be used in policy definition references. :paramtype parameters: dict[str, @@ -1370,7 +1329,7 @@ def __init__( :paramtype policy_definition_groups: list[~azure.mgmt.resource.policy.v2020_09_01.models.PolicyDefinitionGroup] """ - super(PolicySetDefinition, self).__init__(**kwargs) + super().__init__(**kwargs) self.id = None self.name = None self.type = None @@ -1383,7 +1342,7 @@ def __init__( self.policy_definition_groups = policy_definition_groups -class PolicySetDefinitionListResult(msrest.serialization.Model): +class PolicySetDefinitionListResult(_serialization.Model): """List of policy set definitions. :ivar value: An array of policy set definitions. @@ -1393,16 +1352,12 @@ class PolicySetDefinitionListResult(msrest.serialization.Model): """ _attribute_map = { - 'value': {'key': 'value', 'type': '[PolicySetDefinition]'}, - 'next_link': {'key': 'nextLink', 'type': 'str'}, + "value": {"key": "value", "type": "[PolicySetDefinition]"}, + "next_link": {"key": "nextLink", "type": "str"}, } def __init__( - self, - *, - value: Optional[List["PolicySetDefinition"]] = None, - next_link: Optional[str] = None, - **kwargs + self, *, value: Optional[List["_models.PolicySetDefinition"]] = None, next_link: Optional[str] = None, **kwargs ): """ :keyword value: An array of policy set definitions. @@ -1410,12 +1365,12 @@ def __init__( :keyword next_link: The URL to use for getting the next set of results. :paramtype next_link: str """ - super(PolicySetDefinitionListResult, self).__init__(**kwargs) + super().__init__(**kwargs) self.value = value self.next_link = next_link -class ResourceTypeAliases(msrest.serialization.Model): +class ResourceTypeAliases(_serialization.Model): """The resource type aliases definition. :ivar resource_type: The resource type name. @@ -1425,16 +1380,12 @@ class ResourceTypeAliases(msrest.serialization.Model): """ _attribute_map = { - 'resource_type': {'key': 'resourceType', 'type': 'str'}, - 'aliases': {'key': 'aliases', 'type': '[Alias]'}, + "resource_type": {"key": "resourceType", "type": "str"}, + "aliases": {"key": "aliases", "type": "[Alias]"}, } def __init__( - self, - *, - resource_type: Optional[str] = None, - aliases: Optional[List["Alias"]] = None, - **kwargs + self, *, resource_type: Optional[str] = None, aliases: Optional[List["_models.Alias"]] = None, **kwargs ): """ :keyword resource_type: The resource type name. @@ -1442,25 +1393,25 @@ def __init__( :keyword aliases: The aliases for property names. :paramtype aliases: list[~azure.mgmt.resource.policy.v2020_09_01.models.Alias] """ - super(ResourceTypeAliases, self).__init__(**kwargs) + super().__init__(**kwargs) self.resource_type = resource_type self.aliases = aliases -class SystemData(msrest.serialization.Model): +class SystemData(_serialization.Model): """Metadata pertaining to creation and last modification of the resource. :ivar created_by: The identity that created the resource. :vartype created_by: str - :ivar created_by_type: The type of identity that created the resource. Possible values include: - "User", "Application", "ManagedIdentity", "Key". + :ivar created_by_type: The type of identity that created the resource. Known values are: + "User", "Application", "ManagedIdentity", and "Key". :vartype created_by_type: str or ~azure.mgmt.resource.policy.v2020_09_01.models.CreatedByType :ivar created_at: The timestamp of resource creation (UTC). :vartype created_at: ~datetime.datetime :ivar last_modified_by: The identity that last modified the resource. :vartype last_modified_by: str - :ivar last_modified_by_type: The type of identity that last modified the resource. Possible - values include: "User", "Application", "ManagedIdentity", "Key". + :ivar last_modified_by_type: The type of identity that last modified the resource. Known values + are: "User", "Application", "ManagedIdentity", and "Key". :vartype last_modified_by_type: str or ~azure.mgmt.resource.policy.v2020_09_01.models.CreatedByType :ivar last_modified_at: The timestamp of resource last modification (UTC). @@ -1468,43 +1419,43 @@ class SystemData(msrest.serialization.Model): """ _attribute_map = { - 'created_by': {'key': 'createdBy', 'type': 'str'}, - 'created_by_type': {'key': 'createdByType', 'type': 'str'}, - 'created_at': {'key': 'createdAt', 'type': 'iso-8601'}, - 'last_modified_by': {'key': 'lastModifiedBy', 'type': 'str'}, - 'last_modified_by_type': {'key': 'lastModifiedByType', 'type': 'str'}, - 'last_modified_at': {'key': 'lastModifiedAt', 'type': 'iso-8601'}, + "created_by": {"key": "createdBy", "type": "str"}, + "created_by_type": {"key": "createdByType", "type": "str"}, + "created_at": {"key": "createdAt", "type": "iso-8601"}, + "last_modified_by": {"key": "lastModifiedBy", "type": "str"}, + "last_modified_by_type": {"key": "lastModifiedByType", "type": "str"}, + "last_modified_at": {"key": "lastModifiedAt", "type": "iso-8601"}, } def __init__( self, *, created_by: Optional[str] = None, - created_by_type: Optional[Union[str, "CreatedByType"]] = None, + created_by_type: Optional[Union[str, "_models.CreatedByType"]] = None, created_at: Optional[datetime.datetime] = None, last_modified_by: Optional[str] = None, - last_modified_by_type: Optional[Union[str, "CreatedByType"]] = None, + last_modified_by_type: Optional[Union[str, "_models.CreatedByType"]] = None, last_modified_at: Optional[datetime.datetime] = None, **kwargs ): """ :keyword created_by: The identity that created the resource. :paramtype created_by: str - :keyword created_by_type: The type of identity that created the resource. Possible values - include: "User", "Application", "ManagedIdentity", "Key". + :keyword created_by_type: The type of identity that created the resource. Known values are: + "User", "Application", "ManagedIdentity", and "Key". :paramtype created_by_type: str or ~azure.mgmt.resource.policy.v2020_09_01.models.CreatedByType :keyword created_at: The timestamp of resource creation (UTC). :paramtype created_at: ~datetime.datetime :keyword last_modified_by: The identity that last modified the resource. :paramtype last_modified_by: str - :keyword last_modified_by_type: The type of identity that last modified the resource. Possible - values include: "User", "Application", "ManagedIdentity", "Key". + :keyword last_modified_by_type: The type of identity that last modified the resource. Known + values are: "User", "Application", "ManagedIdentity", and "Key". :paramtype last_modified_by_type: str or ~azure.mgmt.resource.policy.v2020_09_01.models.CreatedByType :keyword last_modified_at: The timestamp of resource last modification (UTC). :paramtype last_modified_at: ~datetime.datetime """ - super(SystemData, self).__init__(**kwargs) + super().__init__(**kwargs) self.created_by = created_by self.created_by_type = created_by_type self.created_at = created_at diff --git a/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/policy/v2020_09_01/models/_patch.py b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/policy/v2020_09_01/models/_patch.py new file mode 100644 index 0000000000000..f7dd32510333d --- /dev/null +++ b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/policy/v2020_09_01/models/_patch.py @@ -0,0 +1,20 @@ +# ------------------------------------ +# Copyright (c) Microsoft Corporation. +# Licensed under the MIT License. +# ------------------------------------ +"""Customize generated code here. + +Follow our quickstart for examples: https://aka.ms/azsdk/python/dpcodegen/python/customize +""" +from typing import List + +__all__: List[str] = [] # Add all objects you want publicly available to users at this package level + + +def patch_sdk(): + """Do not remove from this file. + + `patch_sdk` is a last resort escape hatch that allows you to do customizations + you can't accomplish using the techniques described in + https://aka.ms/azsdk/python/dpcodegen/python/customize + """ diff --git a/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/policy/v2020_09_01/models/_policy_client_enums.py b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/policy/v2020_09_01/models/_policy_client_enums.py index 2aff8db04710e..dfa3190a3b57f 100644 --- a/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/policy/v2020_09_01/models/_policy_client_enums.py +++ b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/policy/v2020_09_01/models/_policy_client_enums.py @@ -7,22 +7,20 @@ # -------------------------------------------------------------------------- from enum import Enum -from six import with_metaclass from azure.core import CaseInsensitiveEnumMeta -class AliasPathAttributes(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): - """The attributes of the token that the alias path is referring to. - """ +class AliasPathAttributes(str, Enum, metaclass=CaseInsensitiveEnumMeta): + """The attributes of the token that the alias path is referring to.""" #: The token that the alias path is referring to has no attributes. NONE = "None" #: The token that the alias path is referring to is modifiable by policies with 'modify' effect. MODIFIABLE = "Modifiable" -class AliasPathTokenType(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): - """The type of the token that the alias path is referring to. - """ + +class AliasPathTokenType(str, Enum, metaclass=CaseInsensitiveEnumMeta): + """The type of the token that the alias path is referring to.""" #: The token type is not specified. NOT_SPECIFIED = "NotSpecified" @@ -41,18 +39,18 @@ class AliasPathTokenType(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): #: The token type is boolean. BOOLEAN = "Boolean" -class AliasPatternType(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): - """The type of alias pattern - """ + +class AliasPatternType(str, Enum, metaclass=CaseInsensitiveEnumMeta): + """The type of alias pattern.""" #: NotSpecified is not allowed. NOT_SPECIFIED = "NotSpecified" #: Extract is the only allowed value. EXTRACT = "Extract" -class AliasType(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): - """The type of the alias. - """ + +class AliasType(str, Enum, metaclass=CaseInsensitiveEnumMeta): + """The type of the alias.""" #: Alias type is unknown (same as not providing alias type). NOT_SPECIFIED = "NotSpecified" @@ -61,27 +59,27 @@ class AliasType(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): #: Alias value is secret. MASK = "Mask" -class CreatedByType(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): - """The type of identity that created the resource. - """ + +class CreatedByType(str, Enum, metaclass=CaseInsensitiveEnumMeta): + """The type of identity that created the resource.""" USER = "User" APPLICATION = "Application" MANAGED_IDENTITY = "ManagedIdentity" KEY = "Key" -class EnforcementMode(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): - """The policy assignment enforcement mode. Possible values are Default and DoNotEnforce. - """ + +class EnforcementMode(str, Enum, metaclass=CaseInsensitiveEnumMeta): + """The policy assignment enforcement mode. Possible values are Default and DoNotEnforce.""" #: The policy effect is enforced during resource creation or update. DEFAULT = "Default" #: The policy effect is not enforced during resource creation or update. DO_NOT_ENFORCE = "DoNotEnforce" -class ExemptionCategory(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): - """The policy exemption category. Possible values are Waiver and Mitigated. - """ + +class ExemptionCategory(str, Enum, metaclass=CaseInsensitiveEnumMeta): + """The policy exemption category. Possible values are Waiver and Mitigated.""" #: This category of exemptions usually means the scope is not applicable for the policy. WAIVER = "Waiver" @@ -89,9 +87,9 @@ class ExemptionCategory(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): #: scope. MITIGATED = "Mitigated" -class ParameterType(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): - """The data type of the parameter. - """ + +class ParameterType(str, Enum, metaclass=CaseInsensitiveEnumMeta): + """The data type of the parameter.""" STRING = "String" ARRAY = "Array" @@ -101,16 +99,17 @@ class ParameterType(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): FLOAT = "Float" DATE_TIME = "DateTime" -class PolicyType(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): - """The type of policy definition. Possible values are NotSpecified, BuiltIn, Custom, and Static. - """ + +class PolicyType(str, Enum, metaclass=CaseInsensitiveEnumMeta): + """The type of policy definition. Possible values are NotSpecified, BuiltIn, Custom, and Static.""" NOT_SPECIFIED = "NotSpecified" BUILT_IN = "BuiltIn" CUSTOM = "Custom" STATIC = "Static" -class ResourceIdentityType(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): + +class ResourceIdentityType(str, Enum, metaclass=CaseInsensitiveEnumMeta): """The identity type. This is the only required field when adding a system assigned identity to a resource. """ diff --git a/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/policy/v2020_09_01/operations/__init__.py b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/policy/v2020_09_01/operations/__init__.py index 07b8f47f6b817..bb444fce72789 100644 --- a/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/policy/v2020_09_01/operations/__init__.py +++ b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/policy/v2020_09_01/operations/__init__.py @@ -12,10 +12,16 @@ from ._operations import PolicySetDefinitionsOperations from ._operations import PolicyExemptionsOperations +from ._patch import __all__ as _patch_all +from ._patch import * # type: ignore # pylint: disable=unused-wildcard-import +from ._patch import patch_sdk as _patch_sdk + __all__ = [ - 'DataPolicyManifestsOperations', - 'PolicyAssignmentsOperations', - 'PolicyDefinitionsOperations', - 'PolicySetDefinitionsOperations', - 'PolicyExemptionsOperations', + "DataPolicyManifestsOperations", + "PolicyAssignmentsOperations", + "PolicyDefinitionsOperations", + "PolicySetDefinitionsOperations", + "PolicyExemptionsOperations", ] +__all__.extend([p for p in _patch_all if p not in __all__]) +_patch_sdk() diff --git a/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/policy/v2020_09_01/operations/_operations.py b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/policy/v2020_09_01/operations/_operations.py index fdffb5a4000d9..730ac7f61b1ae 100644 --- a/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/policy/v2020_09_01/operations/_operations.py +++ b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/policy/v2020_09_01/operations/_operations.py @@ -6,197 +6,162 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -from typing import Any, Callable, Dict, Iterable, Optional, TypeVar - -from msrest import Serializer - -from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error +from typing import Any, Callable, Dict, IO, Iterable, Optional, TypeVar, Union, overload + +from azure.core.exceptions import ( + ClientAuthenticationError, + HttpResponseError, + ResourceExistsError, + ResourceNotFoundError, + ResourceNotModifiedError, + map_error, +) from azure.core.paging import ItemPaged from azure.core.pipeline import PipelineResponse from azure.core.pipeline.transport import HttpResponse from azure.core.rest import HttpRequest from azure.core.tracing.decorator import distributed_trace +from azure.core.utils import case_insensitive_dict from azure.mgmt.core.exceptions import ARMErrorFormat from .. import models as _models +from ..._serialization import Serializer from .._vendor import _convert_request, _format_url_section -T = TypeVar('T') + +T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] -JSONType = Any _SERIALIZER = Serializer() _SERIALIZER.client_side_validation = False -def build_data_policy_manifests_get_by_policy_mode_request( - policy_mode: str, - **kwargs: Any -) -> HttpRequest: - api_version = kwargs.pop('api_version', "2020-09-01") # type: str - accept = "application/json" +def build_data_policy_manifests_get_by_policy_mode_request(policy_mode: 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", "2020-09-01")) # type: str + accept = _headers.pop("Accept", "application/json") + # Construct URL _url = kwargs.pop("template_url", "/providers/Microsoft.Authorization/dataPolicyManifests/{policyMode}") path_format_arguments = { - "policyMode": _SERIALIZER.url("policy_mode", policy_mode, 'str'), + "policyMode": _SERIALIZER.url("policy_mode", policy_mode, "str"), } _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') - - return HttpRequest( - method="GET", - url=_url, - params=_query_parameters, - headers=_header_parameters, - **kwargs - ) + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) -def build_data_policy_manifests_list_request( - *, - filter: Optional[str] = None, - **kwargs: Any -) -> HttpRequest: - api_version = kwargs.pop('api_version', "2020-09-01") # type: str - accept = "application/json" +def build_data_policy_manifests_list_request(*, filter: Optional[str] = None, **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", "2020-09-01")) # type: str + accept = _headers.pop("Accept", "application/json") + # Construct URL _url = kwargs.pop("template_url", "/providers/Microsoft.Authorization/dataPolicyManifests") # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") if filter is not None: - _query_parameters['$filter'] = _SERIALIZER.query("filter", filter, 'str', skip_quote=True) + _params["$filter"] = _SERIALIZER.query("filter", filter, "str", skip_quote=True) # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') - - return HttpRequest( - method="GET", - url=_url, - params=_query_parameters, - headers=_header_parameters, - **kwargs - ) + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) -def build_policy_assignments_delete_request( - scope: str, - policy_assignment_name: str, - **kwargs: Any -) -> HttpRequest: - api_version = kwargs.pop('api_version', "2020-09-01") # type: str - accept = "application/json" +def build_policy_assignments_delete_request(scope: str, policy_assignment_name: 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", "2020-09-01")) # type: str + accept = _headers.pop("Accept", "application/json") + # Construct URL - _url = kwargs.pop("template_url", "/{scope}/providers/Microsoft.Authorization/policyAssignments/{policyAssignmentName}") + _url = kwargs.pop( + "template_url", "/{scope}/providers/Microsoft.Authorization/policyAssignments/{policyAssignmentName}" + ) path_format_arguments = { - "scope": _SERIALIZER.url("scope", scope, 'str', skip_quote=True), - "policyAssignmentName": _SERIALIZER.url("policy_assignment_name", policy_assignment_name, 'str'), + "scope": _SERIALIZER.url("scope", scope, "str", skip_quote=True), + "policyAssignmentName": _SERIALIZER.url("policy_assignment_name", policy_assignment_name, "str"), } _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') - - return HttpRequest( - method="DELETE", - url=_url, - params=_query_parameters, - headers=_header_parameters, - **kwargs - ) + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + return HttpRequest(method="DELETE", url=_url, params=_params, headers=_headers, **kwargs) -def build_policy_assignments_create_request( - scope: str, - policy_assignment_name: str, - *, - json: JSONType = None, - content: Any = None, - **kwargs: Any -) -> HttpRequest: - api_version = kwargs.pop('api_version', "2020-09-01") # type: str - content_type = kwargs.pop('content_type', None) # type: Optional[str] - accept = "application/json" +def build_policy_assignments_create_request(scope: str, policy_assignment_name: 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", "2020-09-01")) # type: str + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + accept = _headers.pop("Accept", "application/json") + # Construct URL - _url = kwargs.pop("template_url", "/{scope}/providers/Microsoft.Authorization/policyAssignments/{policyAssignmentName}") + _url = kwargs.pop( + "template_url", "/{scope}/providers/Microsoft.Authorization/policyAssignments/{policyAssignmentName}" + ) path_format_arguments = { - "scope": _SERIALIZER.url("scope", scope, 'str', skip_quote=True), - "policyAssignmentName": _SERIALIZER.url("policy_assignment_name", policy_assignment_name, 'str'), + "scope": _SERIALIZER.url("scope", scope, "str", skip_quote=True), + "policyAssignmentName": _SERIALIZER.url("policy_assignment_name", policy_assignment_name, "str"), } _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] if content_type is not None: - _header_parameters['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') - _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') - - return HttpRequest( - method="PUT", - url=_url, - params=_query_parameters, - headers=_header_parameters, - json=json, - content=content, - **kwargs - ) + _headers["Content-Type"] = _SERIALIZER.header("content_type", content_type, "str") + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + return HttpRequest(method="PUT", url=_url, params=_params, headers=_headers, **kwargs) -def build_policy_assignments_get_request( - scope: str, - policy_assignment_name: str, - **kwargs: Any -) -> HttpRequest: - api_version = kwargs.pop('api_version', "2020-09-01") # type: str - accept = "application/json" +def build_policy_assignments_get_request(scope: str, policy_assignment_name: 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", "2020-09-01")) # type: str + accept = _headers.pop("Accept", "application/json") + # Construct URL - _url = kwargs.pop("template_url", "/{scope}/providers/Microsoft.Authorization/policyAssignments/{policyAssignmentName}") + _url = kwargs.pop( + "template_url", "/{scope}/providers/Microsoft.Authorization/policyAssignments/{policyAssignmentName}" + ) path_format_arguments = { - "scope": _SERIALIZER.url("scope", scope, 'str', skip_quote=True), - "policyAssignmentName": _SERIALIZER.url("policy_assignment_name", policy_assignment_name, 'str'), + "scope": _SERIALIZER.url("scope", scope, "str", skip_quote=True), + "policyAssignmentName": _SERIALIZER.url("policy_assignment_name", policy_assignment_name, "str"), } _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') - - return HttpRequest( - method="GET", - url=_url, - params=_query_parameters, - headers=_header_parameters, - **kwargs - ) + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) def build_policy_assignments_list_for_resource_group_request( @@ -207,37 +172,37 @@ def build_policy_assignments_list_for_resource_group_request( top: Optional[int] = None, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2020-09-01") # type: 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", "2020-09-01")) # type: str + accept = _headers.pop("Accept", "application/json") - accept = "application/json" # Construct URL - _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Authorization/policyAssignments") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Authorization/policyAssignments", + ) # pylint: disable=line-too-long path_format_arguments = { - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._\(\)]+$'), - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), + "resourceGroupName": _SERIALIZER.url( + "resource_group_name", resource_group_name, "str", max_length=90, min_length=1, pattern=r"^[-\w\._\(\)]+$" + ), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), } _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] if filter is not None: - _query_parameters['$filter'] = _SERIALIZER.query("filter", filter, 'str', skip_quote=True) + _params["$filter"] = _SERIALIZER.query("filter", filter, "str", skip_quote=True) if top is not None: - _query_parameters['$top'] = _SERIALIZER.query("top", top, 'int', maximum=1000, minimum=1) - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["$top"] = _SERIALIZER.query("top", top, "int", maximum=1000, minimum=1) + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') - - return HttpRequest( - method="GET", - url=_url, - params=_query_parameters, - headers=_header_parameters, - **kwargs - ) + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) def build_policy_assignments_list_for_resource_request( @@ -252,1302 +217,1089 @@ def build_policy_assignments_list_for_resource_request( top: Optional[int] = None, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2020-09-01") # type: 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", "2020-09-01")) # type: str + accept = _headers.pop("Accept", "application/json") - accept = "application/json" # Construct URL - _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{parentResourcePath}/{resourceType}/{resourceName}/providers/Microsoft.Authorization/policyAssignments") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{parentResourcePath}/{resourceType}/{resourceName}/providers/Microsoft.Authorization/policyAssignments", + ) # pylint: disable=line-too-long path_format_arguments = { - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._\(\)]+$'), - "resourceProviderNamespace": _SERIALIZER.url("resource_provider_namespace", resource_provider_namespace, 'str'), - "parentResourcePath": _SERIALIZER.url("parent_resource_path", parent_resource_path, 'str', skip_quote=True), - "resourceType": _SERIALIZER.url("resource_type", resource_type, 'str', skip_quote=True), - "resourceName": _SERIALIZER.url("resource_name", resource_name, 'str'), - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), + "resourceGroupName": _SERIALIZER.url( + "resource_group_name", resource_group_name, "str", max_length=90, min_length=1, pattern=r"^[-\w\._\(\)]+$" + ), + "resourceProviderNamespace": _SERIALIZER.url("resource_provider_namespace", resource_provider_namespace, "str"), + "parentResourcePath": _SERIALIZER.url("parent_resource_path", parent_resource_path, "str", skip_quote=True), + "resourceType": _SERIALIZER.url("resource_type", resource_type, "str", skip_quote=True), + "resourceName": _SERIALIZER.url("resource_name", resource_name, "str"), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), } _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] if filter is not None: - _query_parameters['$filter'] = _SERIALIZER.query("filter", filter, 'str', skip_quote=True) + _params["$filter"] = _SERIALIZER.query("filter", filter, "str", skip_quote=True) if top is not None: - _query_parameters['$top'] = _SERIALIZER.query("top", top, 'int', maximum=1000, minimum=1) - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["$top"] = _SERIALIZER.query("top", top, "int", maximum=1000, minimum=1) + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') - - return HttpRequest( - method="GET", - url=_url, - params=_query_parameters, - headers=_header_parameters, - **kwargs - ) + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) def build_policy_assignments_list_for_management_group_request( - management_group_id: str, - *, - filter: Optional[str] = None, - top: Optional[int] = None, - **kwargs: Any + management_group_id: str, *, filter: Optional[str] = None, top: Optional[int] = None, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2020-09-01") # type: 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", "2020-09-01")) # type: str + accept = _headers.pop("Accept", "application/json") - accept = "application/json" # Construct URL - _url = kwargs.pop("template_url", "/providers/Microsoft.Management/managementGroups/{managementGroupId}/providers/Microsoft.Authorization/policyAssignments") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", + "/providers/Microsoft.Management/managementGroups/{managementGroupId}/providers/Microsoft.Authorization/policyAssignments", + ) # pylint: disable=line-too-long path_format_arguments = { - "managementGroupId": _SERIALIZER.url("management_group_id", management_group_id, 'str'), + "managementGroupId": _SERIALIZER.url("management_group_id", management_group_id, "str"), } _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] if filter is not None: - _query_parameters['$filter'] = _SERIALIZER.query("filter", filter, 'str', skip_quote=True) + _params["$filter"] = _SERIALIZER.query("filter", filter, "str", skip_quote=True) if top is not None: - _query_parameters['$top'] = _SERIALIZER.query("top", top, 'int', maximum=1000, minimum=1) - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["$top"] = _SERIALIZER.query("top", top, "int", maximum=1000, minimum=1) + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') - - return HttpRequest( - method="GET", - url=_url, - params=_query_parameters, - headers=_header_parameters, - **kwargs - ) + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) def build_policy_assignments_list_request( - subscription_id: str, - *, - filter: Optional[str] = None, - top: Optional[int] = None, - **kwargs: Any + subscription_id: str, *, filter: Optional[str] = None, top: Optional[int] = None, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2020-09-01") # type: 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", "2020-09-01")) # type: str + accept = _headers.pop("Accept", "application/json") - accept = "application/json" # Construct URL - _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/providers/Microsoft.Authorization/policyAssignments") + _url = kwargs.pop( + "template_url", "/subscriptions/{subscriptionId}/providers/Microsoft.Authorization/policyAssignments" + ) path_format_arguments = { - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), } _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] if filter is not None: - _query_parameters['$filter'] = _SERIALIZER.query("filter", filter, 'str', skip_quote=True) + _params["$filter"] = _SERIALIZER.query("filter", filter, "str", skip_quote=True) if top is not None: - _query_parameters['$top'] = _SERIALIZER.query("top", top, 'int', maximum=1000, minimum=1) - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["$top"] = _SERIALIZER.query("top", top, "int", maximum=1000, minimum=1) + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') - - return HttpRequest( - method="GET", - url=_url, - params=_query_parameters, - headers=_header_parameters, - **kwargs - ) + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) -def build_policy_assignments_delete_by_id_request( - policy_assignment_id: str, - **kwargs: Any -) -> HttpRequest: - api_version = kwargs.pop('api_version', "2020-09-01") # type: str - accept = "application/json" +def build_policy_assignments_delete_by_id_request(policy_assignment_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", "2020-09-01")) # type: str + accept = _headers.pop("Accept", "application/json") + # Construct URL _url = kwargs.pop("template_url", "/{policyAssignmentId}") path_format_arguments = { - "policyAssignmentId": _SERIALIZER.url("policy_assignment_id", policy_assignment_id, 'str', skip_quote=True), + "policyAssignmentId": _SERIALIZER.url("policy_assignment_id", policy_assignment_id, "str", skip_quote=True), } _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') - - return HttpRequest( - method="DELETE", - url=_url, - params=_query_parameters, - headers=_header_parameters, - **kwargs - ) + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + return HttpRequest(method="DELETE", url=_url, params=_params, headers=_headers, **kwargs) -def build_policy_assignments_create_by_id_request( - policy_assignment_id: str, - *, - json: JSONType = None, - content: Any = None, - **kwargs: Any -) -> HttpRequest: - api_version = kwargs.pop('api_version', "2020-09-01") # type: str - content_type = kwargs.pop('content_type', None) # type: Optional[str] - accept = "application/json" +def build_policy_assignments_create_by_id_request(policy_assignment_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", "2020-09-01")) # type: str + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + accept = _headers.pop("Accept", "application/json") + # Construct URL _url = kwargs.pop("template_url", "/{policyAssignmentId}") path_format_arguments = { - "policyAssignmentId": _SERIALIZER.url("policy_assignment_id", policy_assignment_id, 'str', skip_quote=True), + "policyAssignmentId": _SERIALIZER.url("policy_assignment_id", policy_assignment_id, "str", skip_quote=True), } _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] if content_type is not None: - _header_parameters['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') - _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') - - return HttpRequest( - method="PUT", - url=_url, - params=_query_parameters, - headers=_header_parameters, - json=json, - content=content, - **kwargs - ) + _headers["Content-Type"] = _SERIALIZER.header("content_type", content_type, "str") + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + return HttpRequest(method="PUT", url=_url, params=_params, headers=_headers, **kwargs) -def build_policy_assignments_get_by_id_request( - policy_assignment_id: str, - **kwargs: Any -) -> HttpRequest: - api_version = kwargs.pop('api_version', "2020-09-01") # type: str - accept = "application/json" +def build_policy_assignments_get_by_id_request(policy_assignment_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", "2020-09-01")) # type: str + accept = _headers.pop("Accept", "application/json") + # Construct URL _url = kwargs.pop("template_url", "/{policyAssignmentId}") path_format_arguments = { - "policyAssignmentId": _SERIALIZER.url("policy_assignment_id", policy_assignment_id, 'str', skip_quote=True), + "policyAssignmentId": _SERIALIZER.url("policy_assignment_id", policy_assignment_id, "str", skip_quote=True), } _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') - - return HttpRequest( - method="GET", - url=_url, - params=_query_parameters, - headers=_header_parameters, - **kwargs - ) + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) def build_policy_definitions_create_or_update_request( - policy_definition_name: str, - subscription_id: str, - *, - json: JSONType = None, - content: Any = None, - **kwargs: Any + policy_definition_name: str, subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2020-09-01") # type: str - content_type = kwargs.pop('content_type', None) # type: Optional[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", "2020-09-01")) # type: str + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + accept = _headers.pop("Accept", "application/json") - accept = "application/json" # Construct URL - _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/providers/Microsoft.Authorization/policyDefinitions/{policyDefinitionName}") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/providers/Microsoft.Authorization/policyDefinitions/{policyDefinitionName}", + ) # pylint: disable=line-too-long path_format_arguments = { - "policyDefinitionName": _SERIALIZER.url("policy_definition_name", policy_definition_name, 'str'), - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), + "policyDefinitionName": _SERIALIZER.url("policy_definition_name", policy_definition_name, "str"), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), } _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] if content_type is not None: - _header_parameters['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') - _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') - - return HttpRequest( - method="PUT", - url=_url, - params=_query_parameters, - headers=_header_parameters, - json=json, - content=content, - **kwargs - ) + _headers["Content-Type"] = _SERIALIZER.header("content_type", content_type, "str") + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="PUT", url=_url, params=_params, headers=_headers, **kwargs) def build_policy_definitions_delete_request( - policy_definition_name: str, - subscription_id: str, - **kwargs: Any + policy_definition_name: str, subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2020-09-01") # type: 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", "2020-09-01")) # type: str + accept = _headers.pop("Accept", "application/json") - accept = "application/json" # Construct URL - _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/providers/Microsoft.Authorization/policyDefinitions/{policyDefinitionName}") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/providers/Microsoft.Authorization/policyDefinitions/{policyDefinitionName}", + ) # pylint: disable=line-too-long path_format_arguments = { - "policyDefinitionName": _SERIALIZER.url("policy_definition_name", policy_definition_name, 'str'), - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), + "policyDefinitionName": _SERIALIZER.url("policy_definition_name", policy_definition_name, "str"), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), } _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') - - return HttpRequest( - method="DELETE", - url=_url, - params=_query_parameters, - headers=_header_parameters, - **kwargs - ) + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="DELETE", url=_url, params=_params, headers=_headers, **kwargs) def build_policy_definitions_get_request( - policy_definition_name: str, - subscription_id: str, - **kwargs: Any + policy_definition_name: str, subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2020-09-01") # type: 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", "2020-09-01")) # type: str + accept = _headers.pop("Accept", "application/json") - accept = "application/json" # Construct URL - _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/providers/Microsoft.Authorization/policyDefinitions/{policyDefinitionName}") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/providers/Microsoft.Authorization/policyDefinitions/{policyDefinitionName}", + ) # pylint: disable=line-too-long path_format_arguments = { - "policyDefinitionName": _SERIALIZER.url("policy_definition_name", policy_definition_name, 'str'), - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), + "policyDefinitionName": _SERIALIZER.url("policy_definition_name", policy_definition_name, "str"), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), } _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') - - return HttpRequest( - method="GET", - url=_url, - params=_query_parameters, - headers=_header_parameters, - **kwargs - ) + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) -def build_policy_definitions_get_built_in_request( - policy_definition_name: str, - **kwargs: Any -) -> HttpRequest: - api_version = kwargs.pop('api_version', "2020-09-01") # type: str - accept = "application/json" +def build_policy_definitions_get_built_in_request(policy_definition_name: 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", "2020-09-01")) # type: str + accept = _headers.pop("Accept", "application/json") + # Construct URL _url = kwargs.pop("template_url", "/providers/Microsoft.Authorization/policyDefinitions/{policyDefinitionName}") path_format_arguments = { - "policyDefinitionName": _SERIALIZER.url("policy_definition_name", policy_definition_name, 'str'), + "policyDefinitionName": _SERIALIZER.url("policy_definition_name", policy_definition_name, "str"), } _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') - - return HttpRequest( - method="GET", - url=_url, - params=_query_parameters, - headers=_header_parameters, - **kwargs - ) + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) def build_policy_definitions_create_or_update_at_management_group_request( - policy_definition_name: str, - management_group_id: str, - *, - json: JSONType = None, - content: Any = None, - **kwargs: Any + policy_definition_name: str, management_group_id: str, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2020-09-01") # type: str - content_type = kwargs.pop('content_type', None) # type: Optional[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", "2020-09-01")) # type: str + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + accept = _headers.pop("Accept", "application/json") - accept = "application/json" # Construct URL - _url = kwargs.pop("template_url", "/providers/Microsoft.Management/managementGroups/{managementGroupId}/providers/Microsoft.Authorization/policyDefinitions/{policyDefinitionName}") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", + "/providers/Microsoft.Management/managementGroups/{managementGroupId}/providers/Microsoft.Authorization/policyDefinitions/{policyDefinitionName}", + ) # pylint: disable=line-too-long path_format_arguments = { - "policyDefinitionName": _SERIALIZER.url("policy_definition_name", policy_definition_name, 'str'), - "managementGroupId": _SERIALIZER.url("management_group_id", management_group_id, 'str'), + "policyDefinitionName": _SERIALIZER.url("policy_definition_name", policy_definition_name, "str"), + "managementGroupId": _SERIALIZER.url("management_group_id", management_group_id, "str"), } _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] if content_type is not None: - _header_parameters['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') - _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') - - return HttpRequest( - method="PUT", - url=_url, - params=_query_parameters, - headers=_header_parameters, - json=json, - content=content, - **kwargs - ) + _headers["Content-Type"] = _SERIALIZER.header("content_type", content_type, "str") + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="PUT", url=_url, params=_params, headers=_headers, **kwargs) def build_policy_definitions_delete_at_management_group_request( - policy_definition_name: str, - management_group_id: str, - **kwargs: Any + policy_definition_name: str, management_group_id: str, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2020-09-01") # type: 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", "2020-09-01")) # type: str + accept = _headers.pop("Accept", "application/json") - accept = "application/json" # Construct URL - _url = kwargs.pop("template_url", "/providers/Microsoft.Management/managementGroups/{managementGroupId}/providers/Microsoft.Authorization/policyDefinitions/{policyDefinitionName}") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", + "/providers/Microsoft.Management/managementGroups/{managementGroupId}/providers/Microsoft.Authorization/policyDefinitions/{policyDefinitionName}", + ) # pylint: disable=line-too-long path_format_arguments = { - "policyDefinitionName": _SERIALIZER.url("policy_definition_name", policy_definition_name, 'str'), - "managementGroupId": _SERIALIZER.url("management_group_id", management_group_id, 'str'), + "policyDefinitionName": _SERIALIZER.url("policy_definition_name", policy_definition_name, "str"), + "managementGroupId": _SERIALIZER.url("management_group_id", management_group_id, "str"), } _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') - - return HttpRequest( - method="DELETE", - url=_url, - params=_query_parameters, - headers=_header_parameters, - **kwargs - ) + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="DELETE", url=_url, params=_params, headers=_headers, **kwargs) def build_policy_definitions_get_at_management_group_request( - policy_definition_name: str, - management_group_id: str, - **kwargs: Any + policy_definition_name: str, management_group_id: str, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2020-09-01") # type: 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", "2020-09-01")) # type: str + accept = _headers.pop("Accept", "application/json") - accept = "application/json" # Construct URL - _url = kwargs.pop("template_url", "/providers/Microsoft.Management/managementGroups/{managementGroupId}/providers/Microsoft.Authorization/policyDefinitions/{policyDefinitionName}") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", + "/providers/Microsoft.Management/managementGroups/{managementGroupId}/providers/Microsoft.Authorization/policyDefinitions/{policyDefinitionName}", + ) # pylint: disable=line-too-long path_format_arguments = { - "policyDefinitionName": _SERIALIZER.url("policy_definition_name", policy_definition_name, 'str'), - "managementGroupId": _SERIALIZER.url("management_group_id", management_group_id, 'str'), + "policyDefinitionName": _SERIALIZER.url("policy_definition_name", policy_definition_name, "str"), + "managementGroupId": _SERIALIZER.url("management_group_id", management_group_id, "str"), } _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') - - return HttpRequest( - method="GET", - url=_url, - params=_query_parameters, - headers=_header_parameters, - **kwargs - ) + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) def build_policy_definitions_list_request( - subscription_id: str, - *, - filter: Optional[str] = None, - top: Optional[int] = None, - **kwargs: Any + subscription_id: str, *, filter: Optional[str] = None, top: Optional[int] = None, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2020-09-01") # type: 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", "2020-09-01")) # type: str + accept = _headers.pop("Accept", "application/json") - accept = "application/json" # Construct URL - _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/providers/Microsoft.Authorization/policyDefinitions") + _url = kwargs.pop( + "template_url", "/subscriptions/{subscriptionId}/providers/Microsoft.Authorization/policyDefinitions" + ) path_format_arguments = { - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), } _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") if filter is not None: - _query_parameters['$filter'] = _SERIALIZER.query("filter", filter, 'str', skip_quote=True) + _params["$filter"] = _SERIALIZER.query("filter", filter, "str", skip_quote=True) if top is not None: - _query_parameters['$top'] = _SERIALIZER.query("top", top, 'int', maximum=1000, minimum=1) + _params["$top"] = _SERIALIZER.query("top", top, "int", maximum=1000, minimum=1) # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') - - return HttpRequest( - method="GET", - url=_url, - params=_query_parameters, - headers=_header_parameters, - **kwargs - ) + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) def build_policy_definitions_list_built_in_request( - *, - filter: Optional[str] = None, - top: Optional[int] = None, - **kwargs: Any + *, filter: Optional[str] = None, top: Optional[int] = None, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2020-09-01") # type: 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", "2020-09-01")) # type: str + accept = _headers.pop("Accept", "application/json") - accept = "application/json" # Construct URL _url = kwargs.pop("template_url", "/providers/Microsoft.Authorization/policyDefinitions") # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") if filter is not None: - _query_parameters['$filter'] = _SERIALIZER.query("filter", filter, 'str', skip_quote=True) + _params["$filter"] = _SERIALIZER.query("filter", filter, "str", skip_quote=True) if top is not None: - _query_parameters['$top'] = _SERIALIZER.query("top", top, 'int', maximum=1000, minimum=1) + _params["$top"] = _SERIALIZER.query("top", top, "int", maximum=1000, minimum=1) # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') - - return HttpRequest( - method="GET", - url=_url, - params=_query_parameters, - headers=_header_parameters, - **kwargs - ) + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) def build_policy_definitions_list_by_management_group_request( - management_group_id: str, - *, - filter: Optional[str] = None, - top: Optional[int] = None, - **kwargs: Any + management_group_id: str, *, filter: Optional[str] = None, top: Optional[int] = None, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2020-09-01") # type: 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", "2020-09-01")) # type: str + accept = _headers.pop("Accept", "application/json") - accept = "application/json" # Construct URL - _url = kwargs.pop("template_url", "/providers/Microsoft.Management/managementGroups/{managementGroupId}/providers/Microsoft.Authorization/policyDefinitions") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", + "/providers/Microsoft.Management/managementGroups/{managementGroupId}/providers/Microsoft.Authorization/policyDefinitions", + ) # pylint: disable=line-too-long path_format_arguments = { - "managementGroupId": _SERIALIZER.url("management_group_id", management_group_id, 'str'), + "managementGroupId": _SERIALIZER.url("management_group_id", management_group_id, "str"), } _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") if filter is not None: - _query_parameters['$filter'] = _SERIALIZER.query("filter", filter, 'str', skip_quote=True) + _params["$filter"] = _SERIALIZER.query("filter", filter, "str", skip_quote=True) if top is not None: - _query_parameters['$top'] = _SERIALIZER.query("top", top, 'int', maximum=1000, minimum=1) + _params["$top"] = _SERIALIZER.query("top", top, "int", maximum=1000, minimum=1) # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') - - return HttpRequest( - method="GET", - url=_url, - params=_query_parameters, - headers=_header_parameters, - **kwargs - ) + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) def build_policy_set_definitions_create_or_update_request( - policy_set_definition_name: str, - subscription_id: str, - *, - json: JSONType = None, - content: Any = None, - **kwargs: Any + policy_set_definition_name: str, subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2020-09-01") # type: str - content_type = kwargs.pop('content_type', None) # type: Optional[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", "2020-09-01")) # type: str + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + accept = _headers.pop("Accept", "application/json") - accept = "application/json" # Construct URL - _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/providers/Microsoft.Authorization/policySetDefinitions/{policySetDefinitionName}") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/providers/Microsoft.Authorization/policySetDefinitions/{policySetDefinitionName}", + ) # pylint: disable=line-too-long path_format_arguments = { - "policySetDefinitionName": _SERIALIZER.url("policy_set_definition_name", policy_set_definition_name, 'str'), - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), + "policySetDefinitionName": _SERIALIZER.url("policy_set_definition_name", policy_set_definition_name, "str"), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), } _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] if content_type is not None: - _header_parameters['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') - _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') - - return HttpRequest( - method="PUT", - url=_url, - params=_query_parameters, - headers=_header_parameters, - json=json, - content=content, - **kwargs - ) + _headers["Content-Type"] = _SERIALIZER.header("content_type", content_type, "str") + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="PUT", url=_url, params=_params, headers=_headers, **kwargs) def build_policy_set_definitions_delete_request( - policy_set_definition_name: str, - subscription_id: str, - **kwargs: Any + policy_set_definition_name: str, subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2020-09-01") # type: 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", "2020-09-01")) # type: str + accept = _headers.pop("Accept", "application/json") - accept = "application/json" # Construct URL - _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/providers/Microsoft.Authorization/policySetDefinitions/{policySetDefinitionName}") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/providers/Microsoft.Authorization/policySetDefinitions/{policySetDefinitionName}", + ) # pylint: disable=line-too-long path_format_arguments = { - "policySetDefinitionName": _SERIALIZER.url("policy_set_definition_name", policy_set_definition_name, 'str'), - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), + "policySetDefinitionName": _SERIALIZER.url("policy_set_definition_name", policy_set_definition_name, "str"), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), } _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') - - return HttpRequest( - method="DELETE", - url=_url, - params=_query_parameters, - headers=_header_parameters, - **kwargs - ) + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="DELETE", url=_url, params=_params, headers=_headers, **kwargs) def build_policy_set_definitions_get_request( - policy_set_definition_name: str, - subscription_id: str, - **kwargs: Any + policy_set_definition_name: str, subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2020-09-01") # type: 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", "2020-09-01")) # type: str + accept = _headers.pop("Accept", "application/json") - accept = "application/json" # Construct URL - _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/providers/Microsoft.Authorization/policySetDefinitions/{policySetDefinitionName}") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/providers/Microsoft.Authorization/policySetDefinitions/{policySetDefinitionName}", + ) # pylint: disable=line-too-long path_format_arguments = { - "policySetDefinitionName": _SERIALIZER.url("policy_set_definition_name", policy_set_definition_name, 'str'), - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), + "policySetDefinitionName": _SERIALIZER.url("policy_set_definition_name", policy_set_definition_name, "str"), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), } _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') - - return HttpRequest( - method="GET", - url=_url, - params=_query_parameters, - headers=_header_parameters, - **kwargs - ) + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) -def build_policy_set_definitions_get_built_in_request( - policy_set_definition_name: str, - **kwargs: Any -) -> HttpRequest: - api_version = kwargs.pop('api_version', "2020-09-01") # type: str - accept = "application/json" +def build_policy_set_definitions_get_built_in_request(policy_set_definition_name: 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", "2020-09-01")) # type: str + accept = _headers.pop("Accept", "application/json") + # Construct URL - _url = kwargs.pop("template_url", "/providers/Microsoft.Authorization/policySetDefinitions/{policySetDefinitionName}") + _url = kwargs.pop( + "template_url", "/providers/Microsoft.Authorization/policySetDefinitions/{policySetDefinitionName}" + ) path_format_arguments = { - "policySetDefinitionName": _SERIALIZER.url("policy_set_definition_name", policy_set_definition_name, 'str'), + "policySetDefinitionName": _SERIALIZER.url("policy_set_definition_name", policy_set_definition_name, "str"), } _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') - - return HttpRequest( - method="GET", - url=_url, - params=_query_parameters, - headers=_header_parameters, - **kwargs - ) + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) def build_policy_set_definitions_list_request( - subscription_id: str, - *, - filter: Optional[str] = None, - top: Optional[int] = None, - **kwargs: Any + subscription_id: str, *, filter: Optional[str] = None, top: Optional[int] = None, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2020-09-01") # type: 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", "2020-09-01")) # type: str + accept = _headers.pop("Accept", "application/json") - accept = "application/json" # Construct URL - _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/providers/Microsoft.Authorization/policySetDefinitions") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", "/subscriptions/{subscriptionId}/providers/Microsoft.Authorization/policySetDefinitions" + ) # pylint: disable=line-too-long path_format_arguments = { - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), } _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") if filter is not None: - _query_parameters['$filter'] = _SERIALIZER.query("filter", filter, 'str', skip_quote=True) + _params["$filter"] = _SERIALIZER.query("filter", filter, "str", skip_quote=True) if top is not None: - _query_parameters['$top'] = _SERIALIZER.query("top", top, 'int', maximum=1000, minimum=1) + _params["$top"] = _SERIALIZER.query("top", top, "int", maximum=1000, minimum=1) # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') - - return HttpRequest( - method="GET", - url=_url, - params=_query_parameters, - headers=_header_parameters, - **kwargs - ) + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) def build_policy_set_definitions_list_built_in_request( - *, - filter: Optional[str] = None, - top: Optional[int] = None, - **kwargs: Any + *, filter: Optional[str] = None, top: Optional[int] = None, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2020-09-01") # type: 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", "2020-09-01")) # type: str + accept = _headers.pop("Accept", "application/json") - accept = "application/json" # Construct URL _url = kwargs.pop("template_url", "/providers/Microsoft.Authorization/policySetDefinitions") # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") if filter is not None: - _query_parameters['$filter'] = _SERIALIZER.query("filter", filter, 'str', skip_quote=True) + _params["$filter"] = _SERIALIZER.query("filter", filter, "str", skip_quote=True) if top is not None: - _query_parameters['$top'] = _SERIALIZER.query("top", top, 'int', maximum=1000, minimum=1) + _params["$top"] = _SERIALIZER.query("top", top, "int", maximum=1000, minimum=1) # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') - - return HttpRequest( - method="GET", - url=_url, - params=_query_parameters, - headers=_header_parameters, - **kwargs - ) + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) def build_policy_set_definitions_create_or_update_at_management_group_request( - policy_set_definition_name: str, - management_group_id: str, - *, - json: JSONType = None, - content: Any = None, - **kwargs: Any + policy_set_definition_name: str, management_group_id: str, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2020-09-01") # type: str - content_type = kwargs.pop('content_type', None) # type: Optional[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", "2020-09-01")) # type: str + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + accept = _headers.pop("Accept", "application/json") - accept = "application/json" # Construct URL - _url = kwargs.pop("template_url", "/providers/Microsoft.Management/managementGroups/{managementGroupId}/providers/Microsoft.Authorization/policySetDefinitions/{policySetDefinitionName}") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", + "/providers/Microsoft.Management/managementGroups/{managementGroupId}/providers/Microsoft.Authorization/policySetDefinitions/{policySetDefinitionName}", + ) # pylint: disable=line-too-long path_format_arguments = { - "policySetDefinitionName": _SERIALIZER.url("policy_set_definition_name", policy_set_definition_name, 'str'), - "managementGroupId": _SERIALIZER.url("management_group_id", management_group_id, 'str'), + "policySetDefinitionName": _SERIALIZER.url("policy_set_definition_name", policy_set_definition_name, "str"), + "managementGroupId": _SERIALIZER.url("management_group_id", management_group_id, "str"), } _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] if content_type is not None: - _header_parameters['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') - _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') - - return HttpRequest( - method="PUT", - url=_url, - params=_query_parameters, - headers=_header_parameters, - json=json, - content=content, - **kwargs - ) + _headers["Content-Type"] = _SERIALIZER.header("content_type", content_type, "str") + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="PUT", url=_url, params=_params, headers=_headers, **kwargs) def build_policy_set_definitions_delete_at_management_group_request( - policy_set_definition_name: str, - management_group_id: str, - **kwargs: Any + policy_set_definition_name: str, management_group_id: str, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2020-09-01") # type: 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", "2020-09-01")) # type: str + accept = _headers.pop("Accept", "application/json") - accept = "application/json" # Construct URL - _url = kwargs.pop("template_url", "/providers/Microsoft.Management/managementGroups/{managementGroupId}/providers/Microsoft.Authorization/policySetDefinitions/{policySetDefinitionName}") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", + "/providers/Microsoft.Management/managementGroups/{managementGroupId}/providers/Microsoft.Authorization/policySetDefinitions/{policySetDefinitionName}", + ) # pylint: disable=line-too-long path_format_arguments = { - "policySetDefinitionName": _SERIALIZER.url("policy_set_definition_name", policy_set_definition_name, 'str'), - "managementGroupId": _SERIALIZER.url("management_group_id", management_group_id, 'str'), + "policySetDefinitionName": _SERIALIZER.url("policy_set_definition_name", policy_set_definition_name, "str"), + "managementGroupId": _SERIALIZER.url("management_group_id", management_group_id, "str"), } _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') - - return HttpRequest( - method="DELETE", - url=_url, - params=_query_parameters, - headers=_header_parameters, - **kwargs - ) + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="DELETE", url=_url, params=_params, headers=_headers, **kwargs) def build_policy_set_definitions_get_at_management_group_request( - policy_set_definition_name: str, - management_group_id: str, - **kwargs: Any + policy_set_definition_name: str, management_group_id: str, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2020-09-01") # type: 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", "2020-09-01")) # type: str + accept = _headers.pop("Accept", "application/json") - accept = "application/json" # Construct URL - _url = kwargs.pop("template_url", "/providers/Microsoft.Management/managementGroups/{managementGroupId}/providers/Microsoft.Authorization/policySetDefinitions/{policySetDefinitionName}") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", + "/providers/Microsoft.Management/managementGroups/{managementGroupId}/providers/Microsoft.Authorization/policySetDefinitions/{policySetDefinitionName}", + ) # pylint: disable=line-too-long path_format_arguments = { - "policySetDefinitionName": _SERIALIZER.url("policy_set_definition_name", policy_set_definition_name, 'str'), - "managementGroupId": _SERIALIZER.url("management_group_id", management_group_id, 'str'), + "policySetDefinitionName": _SERIALIZER.url("policy_set_definition_name", policy_set_definition_name, "str"), + "managementGroupId": _SERIALIZER.url("management_group_id", management_group_id, "str"), } _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') - - return HttpRequest( - method="GET", - url=_url, - params=_query_parameters, - headers=_header_parameters, - **kwargs - ) + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) def build_policy_set_definitions_list_by_management_group_request( - management_group_id: str, - *, - filter: Optional[str] = None, - top: Optional[int] = None, - **kwargs: Any + management_group_id: str, *, filter: Optional[str] = None, top: Optional[int] = None, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2020-09-01") # type: 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", "2020-09-01")) # type: str + accept = _headers.pop("Accept", "application/json") - accept = "application/json" # Construct URL - _url = kwargs.pop("template_url", "/providers/Microsoft.Management/managementGroups/{managementGroupId}/providers/Microsoft.Authorization/policySetDefinitions") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", + "/providers/Microsoft.Management/managementGroups/{managementGroupId}/providers/Microsoft.Authorization/policySetDefinitions", + ) # pylint: disable=line-too-long path_format_arguments = { - "managementGroupId": _SERIALIZER.url("management_group_id", management_group_id, 'str'), + "managementGroupId": _SERIALIZER.url("management_group_id", management_group_id, "str"), } _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") if filter is not None: - _query_parameters['$filter'] = _SERIALIZER.query("filter", filter, 'str', skip_quote=True) + _params["$filter"] = _SERIALIZER.query("filter", filter, "str", skip_quote=True) if top is not None: - _query_parameters['$top'] = _SERIALIZER.query("top", top, 'int', maximum=1000, minimum=1) + _params["$top"] = _SERIALIZER.query("top", top, "int", maximum=1000, minimum=1) # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') - - return HttpRequest( - method="GET", - url=_url, - params=_query_parameters, - headers=_header_parameters, - **kwargs - ) + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) -def build_policy_exemptions_delete_request( - scope: str, - policy_exemption_name: str, - **kwargs: Any -) -> HttpRequest: - api_version = kwargs.pop('api_version', "2020-07-01-preview") # type: str - accept = "application/json" +def build_policy_exemptions_delete_request(scope: str, policy_exemption_name: 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", "2020-07-01-preview")) # type: str + accept = _headers.pop("Accept", "application/json") + # Construct URL - _url = kwargs.pop("template_url", "/{scope}/providers/Microsoft.Authorization/policyExemptions/{policyExemptionName}") + _url = kwargs.pop( + "template_url", "/{scope}/providers/Microsoft.Authorization/policyExemptions/{policyExemptionName}" + ) path_format_arguments = { - "scope": _SERIALIZER.url("scope", scope, 'str', skip_quote=True), - "policyExemptionName": _SERIALIZER.url("policy_exemption_name", policy_exemption_name, 'str'), + "scope": _SERIALIZER.url("scope", scope, "str", skip_quote=True), + "policyExemptionName": _SERIALIZER.url("policy_exemption_name", policy_exemption_name, "str"), } _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') - - return HttpRequest( - method="DELETE", - url=_url, - params=_query_parameters, - headers=_header_parameters, - **kwargs - ) + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="DELETE", url=_url, params=_params, headers=_headers, **kwargs) def build_policy_exemptions_create_or_update_request( - scope: str, - policy_exemption_name: str, - *, - json: JSONType = None, - content: Any = None, - **kwargs: Any + scope: str, policy_exemption_name: str, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2020-07-01-preview") # type: str - content_type = kwargs.pop('content_type', None) # type: Optional[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", "2020-07-01-preview")) # type: str + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + accept = _headers.pop("Accept", "application/json") - accept = "application/json" # Construct URL - _url = kwargs.pop("template_url", "/{scope}/providers/Microsoft.Authorization/policyExemptions/{policyExemptionName}") + _url = kwargs.pop( + "template_url", "/{scope}/providers/Microsoft.Authorization/policyExemptions/{policyExemptionName}" + ) path_format_arguments = { - "scope": _SERIALIZER.url("scope", scope, 'str', skip_quote=True), - "policyExemptionName": _SERIALIZER.url("policy_exemption_name", policy_exemption_name, 'str'), + "scope": _SERIALIZER.url("scope", scope, "str", skip_quote=True), + "policyExemptionName": _SERIALIZER.url("policy_exemption_name", policy_exemption_name, "str"), } _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] if content_type is not None: - _header_parameters['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') - _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') - - return HttpRequest( - method="PUT", - url=_url, - params=_query_parameters, - headers=_header_parameters, - json=json, - content=content, - **kwargs - ) + _headers["Content-Type"] = _SERIALIZER.header("content_type", content_type, "str") + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + return HttpRequest(method="PUT", url=_url, params=_params, headers=_headers, **kwargs) -def build_policy_exemptions_get_request( - scope: str, - policy_exemption_name: str, - **kwargs: Any -) -> HttpRequest: - api_version = kwargs.pop('api_version', "2020-07-01-preview") # type: str - accept = "application/json" +def build_policy_exemptions_get_request(scope: str, policy_exemption_name: 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", "2020-07-01-preview")) # type: str + accept = _headers.pop("Accept", "application/json") + # Construct URL - _url = kwargs.pop("template_url", "/{scope}/providers/Microsoft.Authorization/policyExemptions/{policyExemptionName}") + _url = kwargs.pop( + "template_url", "/{scope}/providers/Microsoft.Authorization/policyExemptions/{policyExemptionName}" + ) path_format_arguments = { - "scope": _SERIALIZER.url("scope", scope, 'str', skip_quote=True), - "policyExemptionName": _SERIALIZER.url("policy_exemption_name", policy_exemption_name, 'str'), + "scope": _SERIALIZER.url("scope", scope, "str", skip_quote=True), + "policyExemptionName": _SERIALIZER.url("policy_exemption_name", policy_exemption_name, "str"), } _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') - - return HttpRequest( - method="GET", - url=_url, - params=_query_parameters, - headers=_header_parameters, - **kwargs - ) + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) def build_policy_exemptions_list_request( - subscription_id: str, - *, - filter: Optional[str] = None, - **kwargs: Any + subscription_id: str, *, filter: Optional[str] = None, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2020-07-01-preview") # type: 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", "2020-07-01-preview")) # type: str + accept = _headers.pop("Accept", "application/json") - accept = "application/json" # Construct URL - _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/providers/Microsoft.Authorization/policyExemptions") + _url = kwargs.pop( + "template_url", "/subscriptions/{subscriptionId}/providers/Microsoft.Authorization/policyExemptions" + ) path_format_arguments = { - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), } _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] if filter is not None: - _query_parameters['$filter'] = _SERIALIZER.query("filter", filter, 'str', skip_quote=True) - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["$filter"] = _SERIALIZER.query("filter", filter, "str", skip_quote=True) + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') - - return HttpRequest( - method="GET", - url=_url, - params=_query_parameters, - headers=_header_parameters, - **kwargs - ) + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) def build_policy_exemptions_list_for_resource_group_request( - subscription_id: str, - resource_group_name: str, - *, - filter: Optional[str] = None, - **kwargs: Any + resource_group_name: str, subscription_id: str, *, filter: Optional[str] = None, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2020-07-01-preview") # type: 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", "2020-07-01-preview")) # type: str + accept = _headers.pop("Accept", "application/json") - accept = "application/json" # Construct URL - _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Authorization/policyExemptions") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Authorization/policyExemptions", + ) # pylint: disable=line-too-long path_format_arguments = { - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._\(\)]+$'), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url( + "resource_group_name", resource_group_name, "str", max_length=90, min_length=1, pattern=r"^[-\w\._\(\)]+$" + ), } _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] if filter is not None: - _query_parameters['$filter'] = _SERIALIZER.query("filter", filter, 'str', skip_quote=True) - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["$filter"] = _SERIALIZER.query("filter", filter, "str", skip_quote=True) + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') - - return HttpRequest( - method="GET", - url=_url, - params=_query_parameters, - headers=_header_parameters, - **kwargs - ) + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) def build_policy_exemptions_list_for_resource_request( - subscription_id: str, resource_group_name: str, resource_provider_namespace: str, parent_resource_path: str, resource_type: str, resource_name: str, + subscription_id: str, *, filter: Optional[str] = None, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2020-07-01-preview") # type: 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", "2020-07-01-preview")) # type: str + accept = _headers.pop("Accept", "application/json") - accept = "application/json" # Construct URL - _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{parentResourcePath}/{resourceType}/{resourceName}/providers/Microsoft.Authorization/policyExemptions") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{parentResourcePath}/{resourceType}/{resourceName}/providers/Microsoft.Authorization/policyExemptions", + ) # pylint: disable=line-too-long path_format_arguments = { - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._\(\)]+$'), - "resourceProviderNamespace": _SERIALIZER.url("resource_provider_namespace", resource_provider_namespace, 'str'), - "parentResourcePath": _SERIALIZER.url("parent_resource_path", parent_resource_path, 'str', skip_quote=True), - "resourceType": _SERIALIZER.url("resource_type", resource_type, 'str', skip_quote=True), - "resourceName": _SERIALIZER.url("resource_name", resource_name, 'str'), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url( + "resource_group_name", resource_group_name, "str", max_length=90, min_length=1, pattern=r"^[-\w\._\(\)]+$" + ), + "resourceProviderNamespace": _SERIALIZER.url("resource_provider_namespace", resource_provider_namespace, "str"), + "parentResourcePath": _SERIALIZER.url("parent_resource_path", parent_resource_path, "str", skip_quote=True), + "resourceType": _SERIALIZER.url("resource_type", resource_type, "str", skip_quote=True), + "resourceName": _SERIALIZER.url("resource_name", resource_name, "str"), } _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] if filter is not None: - _query_parameters['$filter'] = _SERIALIZER.query("filter", filter, 'str', skip_quote=True) - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["$filter"] = _SERIALIZER.query("filter", filter, "str", skip_quote=True) + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') - - return HttpRequest( - method="GET", - url=_url, - params=_query_parameters, - headers=_header_parameters, - **kwargs - ) + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) def build_policy_exemptions_list_for_management_group_request( - management_group_id: str, - *, - filter: Optional[str] = None, - **kwargs: Any + management_group_id: str, *, filter: Optional[str] = None, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2020-07-01-preview") # type: 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", "2020-07-01-preview")) # type: str + accept = _headers.pop("Accept", "application/json") - accept = "application/json" # Construct URL - _url = kwargs.pop("template_url", "/providers/Microsoft.Management/managementGroups/{managementGroupId}/providers/Microsoft.Authorization/policyExemptions") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", + "/providers/Microsoft.Management/managementGroups/{managementGroupId}/providers/Microsoft.Authorization/policyExemptions", + ) # pylint: disable=line-too-long path_format_arguments = { - "managementGroupId": _SERIALIZER.url("management_group_id", management_group_id, 'str'), + "managementGroupId": _SERIALIZER.url("management_group_id", management_group_id, "str"), } _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] if filter is not None: - _query_parameters['$filter'] = _SERIALIZER.query("filter", filter, 'str', skip_quote=True) - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["$filter"] = _SERIALIZER.query("filter", filter, "str", skip_quote=True) + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') - - return HttpRequest( - method="GET", - url=_url, - params=_query_parameters, - headers=_header_parameters, - **kwargs - ) + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) -class DataPolicyManifestsOperations(object): - """DataPolicyManifestsOperations operations. - You should not instantiate this class directly. Instead, you should create a Client instance that - instantiates it for you and attaches it as an attribute. +class DataPolicyManifestsOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. - :ivar models: Alias to model classes used in this operation group. - :type models: ~azure.mgmt.resource.policy.v2020_09_01.models - :param client: Client for service requests. - :param config: Configuration of service client. - :param serializer: An object model serializer. - :param deserializer: An object model deserializer. + Instead, you should access the following operations through + :class:`~azure.mgmt.resource.policy.v2020_09_01.PolicyClient`'s + :attr:`data_policy_manifests` attribute. """ models = _models - def __init__(self, client, config, serializer, deserializer): - self._client = client - self._serialize = serializer - self._deserialize = deserializer - self._config = config + def __init__(self, *args, **kwargs): + input_args = list(args) + self._client = input_args.pop(0) if input_args else kwargs.pop("client") + self._config = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") @distributed_trace - def get_by_policy_mode( - self, - policy_mode: str, - **kwargs: Any - ) -> "_models.DataPolicyManifest": + def get_by_policy_mode(self, policy_mode: str, **kwargs: Any) -> _models.DataPolicyManifest: """Retrieves a data policy manifest. This operation retrieves the data policy manifest with the given policy mode. - :param policy_mode: The policy mode of the data policy manifest to get. + :param policy_mode: The policy mode of the data policy manifest to get. Required. :type policy_mode: str - :keyword api_version: Api Version. Default value is "2020-09-01". Note that overriding this - default value may result in unsupported behavior. - :paramtype api_version: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: DataPolicyManifest, or the result of cls(response) + :return: DataPolicyManifest or the result of cls(response) :rtype: ~azure.mgmt.resource.policy.v2020_09_01.models.DataPolicyManifest - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.DataPolicyManifest"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) - api_version = kwargs.pop('api_version', "2020-09-01") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2020-09-01")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[_models.DataPolicyManifest] - request = build_data_policy_manifests_get_by_policy_mode_request( policy_mode=policy_mode, api_version=api_version, - template_url=self.get_by_policy_mode.metadata['url'], + template_url=self.get_by_policy_mode.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) - deserialized = self._deserialize('DataPolicyManifest', pipeline_response) + deserialized = self._deserialize("DataPolicyManifest", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - get_by_policy_mode.metadata = {'url': "/providers/Microsoft.Authorization/dataPolicyManifests/{policyMode}"} # type: ignore - + get_by_policy_mode.metadata = {"url": "/providers/Microsoft.Authorization/dataPolicyManifests/{policyMode}"} # type: ignore @distributed_trace - def list( - self, - filter: Optional[str] = None, - **kwargs: Any - ) -> Iterable["_models.DataPolicyManifestListResult"]: + def list(self, filter: Optional[str] = None, **kwargs: Any) -> Iterable["_models.DataPolicyManifest"]: """Retrieves data policy manifests. This operation retrieves a list of all the data policy manifests that match the optional given @@ -1561,41 +1313,43 @@ def list( '{value}' is provided, the returned list only includes all data policy manifests that have a namespace matching the provided value. Default value is None. :type filter: str - :keyword api_version: Api Version. Default value is "2020-09-01". Note that overriding this - default value may result in unsupported behavior. - :paramtype api_version: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either DataPolicyManifestListResult or the result of - cls(response) + :return: An iterator like instance of either DataPolicyManifest or the result of cls(response) :rtype: - ~azure.core.paging.ItemPaged[~azure.mgmt.resource.policy.v2020_09_01.models.DataPolicyManifestListResult] - :raises: ~azure.core.exceptions.HttpResponseError + ~azure.core.paging.ItemPaged[~azure.mgmt.resource.policy.v2020_09_01.models.DataPolicyManifest] + :raises ~azure.core.exceptions.HttpResponseError: """ - api_version = kwargs.pop('api_version', "2020-09-01") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2020-09-01")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[_models.DataPolicyManifestListResult] - cls = kwargs.pop('cls', None) # type: ClsType["_models.DataPolicyManifestListResult"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) + def prepare_request(next_link=None): if not next_link: - + request = build_data_policy_manifests_list_request( - api_version=api_version, filter=filter, - template_url=self.list.metadata['url'], + 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.url = self._client.format_url(request.url) # type: ignore else: - - request = build_data_policy_manifests_list_request( - template_url=next_link, - ) + request = HttpRequest("GET", next_link) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore request.method = "GET" return request @@ -1609,10 +1363,8 @@ def extract_data(pipeline_response): def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) response = pipeline_response.http_response @@ -1622,40 +1374,32 @@ def get_next(next_link=None): return pipeline_response + return ItemPaged(get_next, extract_data) - return ItemPaged( - get_next, extract_data - ) - list.metadata = {'url': "/providers/Microsoft.Authorization/dataPolicyManifests"} # type: ignore -class PolicyAssignmentsOperations(object): - """PolicyAssignmentsOperations operations. - - You should not instantiate this class directly. Instead, you should create a Client instance that - instantiates it for you and attaches it as an attribute. - - :ivar models: Alias to model classes used in this operation group. - :type models: ~azure.mgmt.resource.policy.v2020_09_01.models - :param client: Client for service requests. - :param config: Configuration of service client. - :param serializer: An object model serializer. - :param deserializer: An object model deserializer. + list.metadata = {"url": "/providers/Microsoft.Authorization/dataPolicyManifests"} # type: ignore + + +class PolicyAssignmentsOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. + + Instead, you should access the following operations through + :class:`~azure.mgmt.resource.policy.v2020_09_01.PolicyClient`'s + :attr:`policy_assignments` attribute. """ models = _models - def __init__(self, client, config, serializer, deserializer): - self._client = client - self._serialize = serializer - self._deserialize = deserializer - self._config = config + def __init__(self, *args, **kwargs): + input_args = list(args) + self._client = input_args.pop(0) if input_args else kwargs.pop("client") + self._config = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") @distributed_trace - def delete( - self, - scope: str, - policy_assignment_name: str, - **kwargs: Any - ) -> Optional["_models.PolicyAssignment"]: + def delete(self, scope: str, policy_assignment_name: str, **kwargs: Any) -> Optional[_models.PolicyAssignment]: """Deletes a policy assignment. This operation deletes a policy assignment, given its name and the scope it was created in. The @@ -1667,40 +1411,44 @@ def delete( '/subscriptions/{subscriptionId}'), resource group (format: '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}', or resource (format: '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{resourceProviderNamespace}/[{parentResourcePath}/]{resourceType}/{resourceName}'. + Required. :type scope: str - :param policy_assignment_name: The name of the policy assignment to delete. + :param policy_assignment_name: The name of the policy assignment to delete. Required. :type policy_assignment_name: str - :keyword api_version: Api Version. Default value is "2020-09-01". Note that overriding this - default value may result in unsupported behavior. - :paramtype api_version: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: PolicyAssignment, or the result of cls(response) + :return: PolicyAssignment or None or the result of cls(response) :rtype: ~azure.mgmt.resource.policy.v2020_09_01.models.PolicyAssignment or None - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType[Optional["_models.PolicyAssignment"]] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) - api_version = kwargs.pop('api_version', "2020-09-01") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2020-09-01")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[Optional[_models.PolicyAssignment]] - request = build_policy_assignments_delete_request( scope=scope, policy_assignment_name=policy_assignment_name, api_version=api_version, - template_url=self.delete.metadata['url'], + template_url=self.delete.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200, 204]: @@ -1709,24 +1457,25 @@ def delete( deserialized = None if response.status_code == 200: - deserialized = self._deserialize('PolicyAssignment', pipeline_response) + deserialized = self._deserialize("PolicyAssignment", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - delete.metadata = {'url': "/{scope}/providers/Microsoft.Authorization/policyAssignments/{policyAssignmentName}"} # type: ignore + delete.metadata = {"url": "/{scope}/providers/Microsoft.Authorization/policyAssignments/{policyAssignmentName}"} # type: ignore - - @distributed_trace + @overload def create( self, scope: str, policy_assignment_name: str, - parameters: "_models.PolicyAssignment", + parameters: _models.PolicyAssignment, + *, + content_type: str = "application/json", **kwargs: Any - ) -> "_models.PolicyAssignment": + ) -> _models.PolicyAssignment: """Creates or updates a policy assignment. This operation creates or updates a policy assignment with the given scope and name. Policy @@ -1738,29 +1487,109 @@ def create( '/subscriptions/{subscriptionId}'), resource group (format: '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}', or resource (format: '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{resourceProviderNamespace}/[{parentResourcePath}/]{resourceType}/{resourceName}'. + Required. :type scope: str - :param policy_assignment_name: The name of the policy assignment. + :param policy_assignment_name: The name of the policy assignment. Required. :type policy_assignment_name: str - :param parameters: Parameters for the policy assignment. + :param parameters: Parameters for the policy assignment. Required. :type parameters: ~azure.mgmt.resource.policy.v2020_09_01.models.PolicyAssignment - :keyword api_version: Api Version. Default value is "2020-09-01". Note that overriding this - default value may result in unsupported behavior. - :paramtype api_version: str + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: PolicyAssignment, or the result of cls(response) + :return: PolicyAssignment or the result of cls(response) :rtype: ~azure.mgmt.resource.policy.v2020_09_01.models.PolicyAssignment - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + def create( + self, + scope: str, + policy_assignment_name: str, + parameters: IO, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.PolicyAssignment: + """Creates or updates a policy assignment. + + This operation creates or updates a policy assignment with the given scope and name. Policy + assignments apply to all resources contained within their scope. For example, when you assign a + policy at resource group scope, that policy applies to all resources in the group. + + :param scope: The scope of the policy assignment. Valid scopes are: management group (format: + '/providers/Microsoft.Management/managementGroups/{managementGroup}'), subscription (format: + '/subscriptions/{subscriptionId}'), resource group (format: + '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}', or resource (format: + '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{resourceProviderNamespace}/[{parentResourcePath}/]{resourceType}/{resourceName}'. + Required. + :type scope: str + :param policy_assignment_name: The name of the policy assignment. Required. + :type policy_assignment_name: str + :param parameters: Parameters for the policy assignment. Required. + :type parameters: IO + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: PolicyAssignment or the result of cls(response) + :rtype: ~azure.mgmt.resource.policy.v2020_09_01.models.PolicyAssignment + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace + def create( + self, scope: str, policy_assignment_name: str, parameters: Union[_models.PolicyAssignment, IO], **kwargs: Any + ) -> _models.PolicyAssignment: + """Creates or updates a policy assignment. + + This operation creates or updates a policy assignment with the given scope and name. Policy + assignments apply to all resources contained within their scope. For example, when you assign a + policy at resource group scope, that policy applies to all resources in the group. + + :param scope: The scope of the policy assignment. Valid scopes are: management group (format: + '/providers/Microsoft.Management/managementGroups/{managementGroup}'), subscription (format: + '/subscriptions/{subscriptionId}'), resource group (format: + '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}', or resource (format: + '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{resourceProviderNamespace}/[{parentResourcePath}/]{resourceType}/{resourceName}'. + Required. + :type scope: str + :param policy_assignment_name: The name of the policy assignment. Required. + :type policy_assignment_name: str + :param parameters: Parameters for the policy assignment. Is either a model type or a IO type. + Required. + :type parameters: ~azure.mgmt.resource.policy.v2020_09_01.models.PolicyAssignment or IO + :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. + Default value is None. + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: PolicyAssignment or the result of cls(response) + :rtype: ~azure.mgmt.resource.policy.v2020_09_01.models.PolicyAssignment + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.PolicyAssignment"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) - api_version = kwargs.pop('api_version', "2020-09-01") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - _json = self._serialize.body(parameters, 'PolicyAssignment') + api_version = kwargs.pop("api_version", _params.pop("api-version", "2020-09-01")) # type: str + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.PolicyAssignment] + + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(parameters, (IO, bytes)): + _content = parameters + else: + _json = self._serialize.body(parameters, "PolicyAssignment") request = build_policy_assignments_create_request( scope=scope, @@ -1768,39 +1597,35 @@ def create( api_version=api_version, content_type=content_type, json=_json, - template_url=self.create.metadata['url'], + content=_content, + template_url=self.create.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [201]: map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) - deserialized = self._deserialize('PolicyAssignment', pipeline_response) + deserialized = self._deserialize("PolicyAssignment", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - create.metadata = {'url': "/{scope}/providers/Microsoft.Authorization/policyAssignments/{policyAssignmentName}"} # type: ignore - + create.metadata = {"url": "/{scope}/providers/Microsoft.Authorization/policyAssignments/{policyAssignmentName}"} # type: ignore @distributed_trace - def get( - self, - scope: str, - policy_assignment_name: str, - **kwargs: Any - ) -> "_models.PolicyAssignment": + def get(self, scope: str, policy_assignment_name: str, **kwargs: Any) -> _models.PolicyAssignment: """Retrieves a policy assignment. This operation retrieves a single policy assignment, given its name and the scope it was @@ -1811,64 +1636,63 @@ def get( '/subscriptions/{subscriptionId}'), resource group (format: '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}', or resource (format: '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{resourceProviderNamespace}/[{parentResourcePath}/]{resourceType}/{resourceName}'. + Required. :type scope: str - :param policy_assignment_name: The name of the policy assignment to get. + :param policy_assignment_name: The name of the policy assignment to get. Required. :type policy_assignment_name: str - :keyword api_version: Api Version. Default value is "2020-09-01". Note that overriding this - default value may result in unsupported behavior. - :paramtype api_version: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: PolicyAssignment, or the result of cls(response) + :return: PolicyAssignment or the result of cls(response) :rtype: ~azure.mgmt.resource.policy.v2020_09_01.models.PolicyAssignment - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.PolicyAssignment"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) - api_version = kwargs.pop('api_version', "2020-09-01") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2020-09-01")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[_models.PolicyAssignment] - request = build_policy_assignments_get_request( scope=scope, policy_assignment_name=policy_assignment_name, api_version=api_version, - template_url=self.get.metadata['url'], + template_url=self.get.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) - deserialized = self._deserialize('PolicyAssignment', pipeline_response) + deserialized = self._deserialize("PolicyAssignment", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - get.metadata = {'url': "/{scope}/providers/Microsoft.Authorization/policyAssignments/{policyAssignmentName}"} # type: ignore - + get.metadata = {"url": "/{scope}/providers/Microsoft.Authorization/policyAssignments/{policyAssignmentName}"} # type: ignore @distributed_trace def list_for_resource_group( - self, - resource_group_name: str, - filter: Optional[str] = None, - top: Optional[int] = None, - **kwargs: Any - ) -> Iterable["_models.PolicyAssignmentListResult"]: + self, resource_group_name: str, filter: Optional[str] = None, top: Optional[int] = None, **kwargs: Any + ) -> Iterable["_models.PolicyAssignment"]: """Retrieves all policy assignments that apply to a resource group. This operation retrieves the list of all policy assignments associated with the given resource @@ -1885,6 +1709,7 @@ def list_for_resource_group( is {value} that apply to the resource group. :param resource_group_name: The name of the resource group that contains policy assignments. + Required. :type resource_group_name: str :param filter: The filter to apply on the operation. Valid values for $filter are: 'atScope()', 'atExactScope()' or 'policyDefinitionId eq '{value}''. If $filter is not provided, no filtering @@ -1898,46 +1723,46 @@ def list_for_resource_group( :param top: Maximum number of records to return. When the $top filter is not provided, it will return 500 records. Default value is None. :type top: int - :keyword api_version: Api Version. Default value is "2020-09-01". Note that overriding this - default value may result in unsupported behavior. - :paramtype api_version: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either PolicyAssignmentListResult or the result of - cls(response) + :return: An iterator like instance of either PolicyAssignment or the result of cls(response) :rtype: - ~azure.core.paging.ItemPaged[~azure.mgmt.resource.policy.v2020_09_01.models.PolicyAssignmentListResult] - :raises: ~azure.core.exceptions.HttpResponseError + ~azure.core.paging.ItemPaged[~azure.mgmt.resource.policy.v2020_09_01.models.PolicyAssignment] + :raises ~azure.core.exceptions.HttpResponseError: """ - api_version = kwargs.pop('api_version', "2020-09-01") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2020-09-01")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[_models.PolicyAssignmentListResult] - cls = kwargs.pop('cls', None) # type: ClsType["_models.PolicyAssignmentListResult"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) + def prepare_request(next_link=None): if not next_link: - + request = build_policy_assignments_list_for_resource_group_request( resource_group_name=resource_group_name, subscription_id=self._config.subscription_id, - api_version=api_version, filter=filter, top=top, - template_url=self.list_for_resource_group.metadata['url'], + api_version=api_version, + template_url=self.list_for_resource_group.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore else: - - request = build_policy_assignments_list_for_resource_group_request( - resource_group_name=resource_group_name, - subscription_id=self._config.subscription_id, - template_url=next_link, - ) + request = HttpRequest("GET", next_link) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore request.method = "GET" return request @@ -1951,10 +1776,8 @@ def extract_data(pipeline_response): def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) response = pipeline_response.http_response @@ -1964,11 +1787,9 @@ def get_next(next_link=None): return pipeline_response + return ItemPaged(get_next, extract_data) - return ItemPaged( - get_next, extract_data - ) - list_for_resource_group.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Authorization/policyAssignments"} # type: ignore + list_for_resource_group.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Authorization/policyAssignments"} # type: ignore @distributed_trace def list_for_resource( @@ -1981,7 +1802,7 @@ def list_for_resource( filter: Optional[str] = None, top: Optional[int] = None, **kwargs: Any - ) -> Iterable["_models.PolicyAssignmentListResult"]: + ) -> Iterable["_models.PolicyAssignment"]: """Retrieves all policy assignments that apply to a resource. This operation retrieves the list of all policy assignments associated with the specified @@ -2008,17 +1829,19 @@ def list_for_resource( {parentResourcePath} == '', {resourceType} == 'Microsoft.Web/sites', {resourceName} == 'MyWebApp'). - :param resource_group_name: The name of the resource group containing the resource. + :param resource_group_name: The name of the resource group containing the resource. Required. :type resource_group_name: str :param resource_provider_namespace: The namespace of the resource provider. For example, the namespace of a virtual machine is Microsoft.Compute (from Microsoft.Compute/virtualMachines). + Required. :type resource_provider_namespace: str :param parent_resource_path: The parent resource path. Use empty string if there is none. + Required. :type parent_resource_path: str :param resource_type: The resource type name. For example the type name of a web app is 'sites' - (from Microsoft.Web/sites). + (from Microsoft.Web/sites). Required. :type resource_type: str - :param resource_name: The name of the resource. + :param resource_name: The name of the resource. Required. :type resource_name: str :param filter: The filter to apply on the operation. Valid values for $filter are: 'atScope()', 'atExactScope()' or 'policyDefinitionId eq '{value}''. If $filter is not provided, no filtering @@ -2032,26 +1855,29 @@ def list_for_resource( :param top: Maximum number of records to return. When the $top filter is not provided, it will return 500 records. Default value is None. :type top: int - :keyword api_version: Api Version. Default value is "2020-09-01". Note that overriding this - default value may result in unsupported behavior. - :paramtype api_version: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either PolicyAssignmentListResult or the result of - cls(response) + :return: An iterator like instance of either PolicyAssignment or the result of cls(response) :rtype: - ~azure.core.paging.ItemPaged[~azure.mgmt.resource.policy.v2020_09_01.models.PolicyAssignmentListResult] - :raises: ~azure.core.exceptions.HttpResponseError + ~azure.core.paging.ItemPaged[~azure.mgmt.resource.policy.v2020_09_01.models.PolicyAssignment] + :raises ~azure.core.exceptions.HttpResponseError: """ - api_version = kwargs.pop('api_version', "2020-09-01") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2020-09-01")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[_models.PolicyAssignmentListResult] - cls = kwargs.pop('cls', None) # type: ClsType["_models.PolicyAssignmentListResult"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) + def prepare_request(next_link=None): if not next_link: - + request = build_policy_assignments_list_for_resource_request( resource_group_name=resource_group_name, resource_provider_namespace=resource_provider_namespace, @@ -2059,27 +1885,20 @@ def prepare_request(next_link=None): resource_type=resource_type, resource_name=resource_name, subscription_id=self._config.subscription_id, - api_version=api_version, filter=filter, top=top, - template_url=self.list_for_resource.metadata['url'], + api_version=api_version, + template_url=self.list_for_resource.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore else: - - request = build_policy_assignments_list_for_resource_request( - resource_group_name=resource_group_name, - resource_provider_namespace=resource_provider_namespace, - parent_resource_path=parent_resource_path, - resource_type=resource_type, - resource_name=resource_name, - subscription_id=self._config.subscription_id, - template_url=next_link, - ) + request = HttpRequest("GET", next_link) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore request.method = "GET" return request @@ -2093,10 +1912,8 @@ def extract_data(pipeline_response): def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) response = pipeline_response.http_response @@ -2106,20 +1923,14 @@ def get_next(next_link=None): return pipeline_response + return ItemPaged(get_next, extract_data) - return ItemPaged( - get_next, extract_data - ) - list_for_resource.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{parentResourcePath}/{resourceType}/{resourceName}/providers/Microsoft.Authorization/policyAssignments"} # type: ignore + list_for_resource.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{parentResourcePath}/{resourceType}/{resourceName}/providers/Microsoft.Authorization/policyAssignments"} # type: ignore @distributed_trace def list_for_management_group( - self, - management_group_id: str, - filter: Optional[str] = None, - top: Optional[int] = None, - **kwargs: Any - ) -> Iterable["_models.PolicyAssignmentListResult"]: + self, management_group_id: str, filter: Optional[str] = None, top: Optional[int] = None, **kwargs: Any + ) -> Iterable["_models.PolicyAssignment"]: """Retrieves all policy assignments that apply to a management group. This operation retrieves the list of all policy assignments applicable to the management group @@ -2131,7 +1942,7 @@ def list_for_management_group( provided, the returned list includes all policy assignments of the policy definition whose id is {value} that apply to the management group. - :param management_group_id: The ID of the management group. + :param management_group_id: The ID of the management group. Required. :type management_group_id: str :param filter: The filter to apply on the operation. Valid values for $filter are: 'atScope()', 'atExactScope()' or 'policyDefinitionId eq '{value}''. If $filter is not provided, no filtering @@ -2145,44 +1956,45 @@ def list_for_management_group( :param top: Maximum number of records to return. When the $top filter is not provided, it will return 500 records. Default value is None. :type top: int - :keyword api_version: Api Version. Default value is "2020-09-01". Note that overriding this - default value may result in unsupported behavior. - :paramtype api_version: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either PolicyAssignmentListResult or the result of - cls(response) + :return: An iterator like instance of either PolicyAssignment or the result of cls(response) :rtype: - ~azure.core.paging.ItemPaged[~azure.mgmt.resource.policy.v2020_09_01.models.PolicyAssignmentListResult] - :raises: ~azure.core.exceptions.HttpResponseError + ~azure.core.paging.ItemPaged[~azure.mgmt.resource.policy.v2020_09_01.models.PolicyAssignment] + :raises ~azure.core.exceptions.HttpResponseError: """ - api_version = kwargs.pop('api_version', "2020-09-01") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2020-09-01")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[_models.PolicyAssignmentListResult] - cls = kwargs.pop('cls', None) # type: ClsType["_models.PolicyAssignmentListResult"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) + def prepare_request(next_link=None): if not next_link: - + request = build_policy_assignments_list_for_management_group_request( management_group_id=management_group_id, - api_version=api_version, filter=filter, top=top, - template_url=self.list_for_management_group.metadata['url'], + api_version=api_version, + template_url=self.list_for_management_group.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore else: - - request = build_policy_assignments_list_for_management_group_request( - management_group_id=management_group_id, - template_url=next_link, - ) + request = HttpRequest("GET", next_link) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore request.method = "GET" return request @@ -2196,10 +2008,8 @@ def extract_data(pipeline_response): def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) response = pipeline_response.http_response @@ -2209,19 +2019,14 @@ def get_next(next_link=None): return pipeline_response + return ItemPaged(get_next, extract_data) - return ItemPaged( - get_next, extract_data - ) - list_for_management_group.metadata = {'url': "/providers/Microsoft.Management/managementGroups/{managementGroupId}/providers/Microsoft.Authorization/policyAssignments"} # type: ignore + list_for_management_group.metadata = {"url": "/providers/Microsoft.Management/managementGroups/{managementGroupId}/providers/Microsoft.Authorization/policyAssignments"} # type: ignore @distributed_trace def list( - self, - filter: Optional[str] = None, - top: Optional[int] = None, - **kwargs: Any - ) -> Iterable["_models.PolicyAssignmentListResult"]: + self, filter: Optional[str] = None, top: Optional[int] = None, **kwargs: Any + ) -> Iterable["_models.PolicyAssignment"]: """Retrieves all policy assignments that apply to a subscription. This operation retrieves the list of all policy assignments associated with the given @@ -2248,44 +2053,45 @@ def list( :param top: Maximum number of records to return. When the $top filter is not provided, it will return 500 records. Default value is None. :type top: int - :keyword api_version: Api Version. Default value is "2020-09-01". Note that overriding this - default value may result in unsupported behavior. - :paramtype api_version: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either PolicyAssignmentListResult or the result of - cls(response) + :return: An iterator like instance of either PolicyAssignment or the result of cls(response) :rtype: - ~azure.core.paging.ItemPaged[~azure.mgmt.resource.policy.v2020_09_01.models.PolicyAssignmentListResult] - :raises: ~azure.core.exceptions.HttpResponseError + ~azure.core.paging.ItemPaged[~azure.mgmt.resource.policy.v2020_09_01.models.PolicyAssignment] + :raises ~azure.core.exceptions.HttpResponseError: """ - api_version = kwargs.pop('api_version', "2020-09-01") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2020-09-01")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[_models.PolicyAssignmentListResult] - cls = kwargs.pop('cls', None) # type: ClsType["_models.PolicyAssignmentListResult"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) + def prepare_request(next_link=None): if not next_link: - + request = build_policy_assignments_list_request( subscription_id=self._config.subscription_id, - api_version=api_version, filter=filter, top=top, - template_url=self.list.metadata['url'], + 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.url = self._client.format_url(request.url) # type: ignore else: - - request = build_policy_assignments_list_request( - subscription_id=self._config.subscription_id, - template_url=next_link, - ) + request = HttpRequest("GET", next_link) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore request.method = "GET" return request @@ -2299,10 +2105,8 @@ def extract_data(pipeline_response): def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) response = pipeline_response.http_response @@ -2312,18 +2116,12 @@ def get_next(next_link=None): return pipeline_response + return ItemPaged(get_next, extract_data) - return ItemPaged( - get_next, extract_data - ) - list.metadata = {'url': "/subscriptions/{subscriptionId}/providers/Microsoft.Authorization/policyAssignments"} # type: ignore + list.metadata = {"url": "/subscriptions/{subscriptionId}/providers/Microsoft.Authorization/policyAssignments"} # type: ignore @distributed_trace - def delete_by_id( - self, - policy_assignment_id: str, - **kwargs: Any - ) -> Optional["_models.PolicyAssignment"]: + def delete_by_id(self, policy_assignment_id: str, **kwargs: Any) -> Optional[_models.PolicyAssignment]: """Deletes a policy assignment. This operation deletes the policy with the given ID. Policy assignment IDs have this format: @@ -2335,38 +2133,41 @@ def delete_by_id( (resource). :param policy_assignment_id: The ID of the policy assignment to delete. Use the format - '{scope}/providers/Microsoft.Authorization/policyAssignments/{policyAssignmentName}'. + '{scope}/providers/Microsoft.Authorization/policyAssignments/{policyAssignmentName}'. Required. :type policy_assignment_id: str - :keyword api_version: Api Version. Default value is "2020-09-01". Note that overriding this - default value may result in unsupported behavior. - :paramtype api_version: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: PolicyAssignment, or the result of cls(response) + :return: PolicyAssignment or None or the result of cls(response) :rtype: ~azure.mgmt.resource.policy.v2020_09_01.models.PolicyAssignment or None - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType[Optional["_models.PolicyAssignment"]] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + 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', "2020-09-01") # type: str + api_version = kwargs.pop("api_version", _params.pop("api-version", "2020-09-01")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[Optional[_models.PolicyAssignment]] - request = build_policy_assignments_delete_by_id_request( policy_assignment_id=policy_assignment_id, api_version=api_version, - template_url=self.delete_by_id.metadata['url'], + template_url=self.delete_by_id.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200, 204]: @@ -2375,23 +2176,24 @@ def delete_by_id( deserialized = None if response.status_code == 200: - deserialized = self._deserialize('PolicyAssignment', pipeline_response) + deserialized = self._deserialize("PolicyAssignment", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - delete_by_id.metadata = {'url': "/{policyAssignmentId}"} # type: ignore - + delete_by_id.metadata = {"url": "/{policyAssignmentId}"} # type: ignore - @distributed_trace + @overload def create_by_id( self, policy_assignment_id: str, - parameters: "_models.PolicyAssignment", + parameters: _models.PolicyAssignment, + *, + content_type: str = "application/json", **kwargs: Any - ) -> "_models.PolicyAssignment": + ) -> _models.PolicyAssignment: """Creates or updates a policy assignment. This operation creates or updates the policy assignment with the given ID. Policy assignments @@ -2406,66 +2208,138 @@ def create_by_id( '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{resourceProviderNamespace}/[{parentResourcePath}/]{resourceType}/{resourceName}'. :param policy_assignment_id: The ID of the policy assignment to create. Use the format - '{scope}/providers/Microsoft.Authorization/policyAssignments/{policyAssignmentName}'. + '{scope}/providers/Microsoft.Authorization/policyAssignments/{policyAssignmentName}'. Required. :type policy_assignment_id: str - :param parameters: Parameters for policy assignment. + :param parameters: Parameters for policy assignment. Required. :type parameters: ~azure.mgmt.resource.policy.v2020_09_01.models.PolicyAssignment - :keyword api_version: Api Version. Default value is "2020-09-01". Note that overriding this - default value may result in unsupported behavior. - :paramtype api_version: str + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: PolicyAssignment or the result of cls(response) + :rtype: ~azure.mgmt.resource.policy.v2020_09_01.models.PolicyAssignment + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + def create_by_id( + self, policy_assignment_id: str, parameters: IO, *, content_type: str = "application/json", **kwargs: Any + ) -> _models.PolicyAssignment: + """Creates or updates a policy assignment. + + This operation creates or updates the policy assignment with the given ID. Policy assignments + made on a scope apply to all resources contained in that scope. For example, when you assign a + policy to a resource group that policy applies to all resources in the group. Policy assignment + IDs have this format: + '{scope}/providers/Microsoft.Authorization/policyAssignments/{policyAssignmentName}'. Valid + scopes are: management group (format: + '/providers/Microsoft.Management/managementGroups/{managementGroup}'), subscription (format: + '/subscriptions/{subscriptionId}'), resource group (format: + '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}', or resource (format: + '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{resourceProviderNamespace}/[{parentResourcePath}/]{resourceType}/{resourceName}'. + + :param policy_assignment_id: The ID of the policy assignment to create. Use the format + '{scope}/providers/Microsoft.Authorization/policyAssignments/{policyAssignmentName}'. Required. + :type policy_assignment_id: str + :param parameters: Parameters for policy assignment. Required. + :type parameters: IO + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: PolicyAssignment or the result of cls(response) + :rtype: ~azure.mgmt.resource.policy.v2020_09_01.models.PolicyAssignment + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace + def create_by_id( + self, policy_assignment_id: str, parameters: Union[_models.PolicyAssignment, IO], **kwargs: Any + ) -> _models.PolicyAssignment: + """Creates or updates a policy assignment. + + This operation creates or updates the policy assignment with the given ID. Policy assignments + made on a scope apply to all resources contained in that scope. For example, when you assign a + policy to a resource group that policy applies to all resources in the group. Policy assignment + IDs have this format: + '{scope}/providers/Microsoft.Authorization/policyAssignments/{policyAssignmentName}'. Valid + scopes are: management group (format: + '/providers/Microsoft.Management/managementGroups/{managementGroup}'), subscription (format: + '/subscriptions/{subscriptionId}'), resource group (format: + '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}', or resource (format: + '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{resourceProviderNamespace}/[{parentResourcePath}/]{resourceType}/{resourceName}'. + + :param policy_assignment_id: The ID of the policy assignment to create. Use the format + '{scope}/providers/Microsoft.Authorization/policyAssignments/{policyAssignmentName}'. Required. + :type policy_assignment_id: str + :param parameters: Parameters for policy assignment. Is either a model type or a IO type. + Required. + :type parameters: ~azure.mgmt.resource.policy.v2020_09_01.models.PolicyAssignment or IO + :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. + Default value is None. + :paramtype content_type: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: PolicyAssignment, or the result of cls(response) + :return: PolicyAssignment or the result of cls(response) :rtype: ~azure.mgmt.resource.policy.v2020_09_01.models.PolicyAssignment - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.PolicyAssignment"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) - api_version = kwargs.pop('api_version', "2020-09-01") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - _json = self._serialize.body(parameters, 'PolicyAssignment') + api_version = kwargs.pop("api_version", _params.pop("api-version", "2020-09-01")) # type: str + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.PolicyAssignment] + + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(parameters, (IO, bytes)): + _content = parameters + else: + _json = self._serialize.body(parameters, "PolicyAssignment") request = build_policy_assignments_create_by_id_request( policy_assignment_id=policy_assignment_id, api_version=api_version, content_type=content_type, json=_json, - template_url=self.create_by_id.metadata['url'], + content=_content, + template_url=self.create_by_id.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [201]: map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) - deserialized = self._deserialize('PolicyAssignment', pipeline_response) + deserialized = self._deserialize("PolicyAssignment", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - create_by_id.metadata = {'url': "/{policyAssignmentId}"} # type: ignore - + create_by_id.metadata = {"url": "/{policyAssignmentId}"} # type: ignore @distributed_trace - def get_by_id( - self, - policy_assignment_id: str, - **kwargs: Any - ) -> "_models.PolicyAssignment": + def get_by_id(self, policy_assignment_id: str, **kwargs: Any) -> _models.PolicyAssignment: """Retrieves the policy assignment with the given ID. The operation retrieves the policy assignment with the given ID. Policy assignment IDs have @@ -2478,109 +2352,169 @@ def get_by_id( '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{resourceProviderNamespace}/[{parentResourcePath}/]{resourceType}/{resourceName}'. :param policy_assignment_id: The ID of the policy assignment to get. Use the format - '{scope}/providers/Microsoft.Authorization/policyAssignments/{policyAssignmentName}'. + '{scope}/providers/Microsoft.Authorization/policyAssignments/{policyAssignmentName}'. Required. :type policy_assignment_id: str - :keyword api_version: Api Version. Default value is "2020-09-01". Note that overriding this - default value may result in unsupported behavior. - :paramtype api_version: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: PolicyAssignment, or the result of cls(response) + :return: PolicyAssignment or the result of cls(response) :rtype: ~azure.mgmt.resource.policy.v2020_09_01.models.PolicyAssignment - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.PolicyAssignment"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) - api_version = kwargs.pop('api_version', "2020-09-01") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2020-09-01")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[_models.PolicyAssignment] - request = build_policy_assignments_get_by_id_request( policy_assignment_id=policy_assignment_id, api_version=api_version, - template_url=self.get_by_id.metadata['url'], + template_url=self.get_by_id.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) - deserialized = self._deserialize('PolicyAssignment', pipeline_response) + deserialized = self._deserialize("PolicyAssignment", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - get_by_id.metadata = {'url': "/{policyAssignmentId}"} # type: ignore + get_by_id.metadata = {"url": "/{policyAssignmentId}"} # type: ignore -class PolicyDefinitionsOperations(object): - """PolicyDefinitionsOperations operations. - You should not instantiate this class directly. Instead, you should create a Client instance that - instantiates it for you and attaches it as an attribute. +class PolicyDefinitionsOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. - :ivar models: Alias to model classes used in this operation group. - :type models: ~azure.mgmt.resource.policy.v2020_09_01.models - :param client: Client for service requests. - :param config: Configuration of service client. - :param serializer: An object model serializer. - :param deserializer: An object model deserializer. + Instead, you should access the following operations through + :class:`~azure.mgmt.resource.policy.v2020_09_01.PolicyClient`'s + :attr:`policy_definitions` attribute. """ models = _models - def __init__(self, client, config, serializer, deserializer): - self._client = client - self._serialize = serializer - self._deserialize = deserializer - self._config = config + def __init__(self, *args, **kwargs): + input_args = list(args) + self._client = input_args.pop(0) if input_args else kwargs.pop("client") + self._config = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") - @distributed_trace + @overload def create_or_update( self, policy_definition_name: str, - parameters: "_models.PolicyDefinition", + parameters: _models.PolicyDefinition, + *, + content_type: str = "application/json", **kwargs: Any - ) -> "_models.PolicyDefinition": + ) -> _models.PolicyDefinition: """Creates or updates a policy definition in a subscription. This operation creates or updates a policy definition in the given subscription with the given name. - :param policy_definition_name: The name of the policy definition to create. + :param policy_definition_name: The name of the policy definition to create. Required. :type policy_definition_name: str - :param parameters: The policy definition properties. + :param parameters: The policy definition properties. Required. :type parameters: ~azure.mgmt.resource.policy.v2020_09_01.models.PolicyDefinition - :keyword api_version: Api Version. Default value is "2020-09-01". Note that overriding this - default value may result in unsupported behavior. - :paramtype api_version: str + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: PolicyDefinition or the result of cls(response) + :rtype: ~azure.mgmt.resource.policy.v2020_09_01.models.PolicyDefinition + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + def create_or_update( + self, policy_definition_name: str, parameters: IO, *, content_type: str = "application/json", **kwargs: Any + ) -> _models.PolicyDefinition: + """Creates or updates a policy definition in a subscription. + + This operation creates or updates a policy definition in the given subscription with the given + name. + + :param policy_definition_name: The name of the policy definition to create. Required. + :type policy_definition_name: str + :param parameters: The policy definition properties. Required. + :type parameters: IO + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: PolicyDefinition or the result of cls(response) + :rtype: ~azure.mgmt.resource.policy.v2020_09_01.models.PolicyDefinition + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace + def create_or_update( + self, policy_definition_name: str, parameters: Union[_models.PolicyDefinition, IO], **kwargs: Any + ) -> _models.PolicyDefinition: + """Creates or updates a policy definition in a subscription. + + This operation creates or updates a policy definition in the given subscription with the given + name. + + :param policy_definition_name: The name of the policy definition to create. Required. + :type policy_definition_name: str + :param parameters: The policy definition properties. Is either a model type or a IO type. + Required. + :type parameters: ~azure.mgmt.resource.policy.v2020_09_01.models.PolicyDefinition or IO + :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. + Default value is None. + :paramtype content_type: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: PolicyDefinition, or the result of cls(response) + :return: PolicyDefinition or the result of cls(response) :rtype: ~azure.mgmt.resource.policy.v2020_09_01.models.PolicyDefinition - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.PolicyDefinition"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', "2020-09-01") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + api_version = kwargs.pop("api_version", _params.pop("api-version", "2020-09-01")) # type: str + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.PolicyDefinition] - _json = self._serialize.body(parameters, 'PolicyDefinition') + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(parameters, (IO, bytes)): + _content = parameters + else: + _json = self._serialize.body(parameters, "PolicyDefinition") request = build_policy_definitions_create_or_update_request( policy_definition_name=policy_definition_name, @@ -2588,75 +2522,77 @@ def create_or_update( api_version=api_version, content_type=content_type, json=_json, - template_url=self.create_or_update.metadata['url'], + content=_content, + template_url=self.create_or_update.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [201]: map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) - deserialized = self._deserialize('PolicyDefinition', pipeline_response) + deserialized = self._deserialize("PolicyDefinition", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - create_or_update.metadata = {'url': "/subscriptions/{subscriptionId}/providers/Microsoft.Authorization/policyDefinitions/{policyDefinitionName}"} # type: ignore - + create_or_update.metadata = {"url": "/subscriptions/{subscriptionId}/providers/Microsoft.Authorization/policyDefinitions/{policyDefinitionName}"} # type: ignore @distributed_trace def delete( # pylint: disable=inconsistent-return-statements - self, - policy_definition_name: str, - **kwargs: Any + self, policy_definition_name: str, **kwargs: Any ) -> None: """Deletes a policy definition in a subscription. This operation deletes the policy definition in the given subscription with the given name. - :param policy_definition_name: The name of the policy definition to delete. + :param policy_definition_name: The name of the policy definition to delete. Required. :type policy_definition_name: str - :keyword api_version: Api Version. Default value is "2020-09-01". Note that overriding this - default value may result in unsupported behavior. - :paramtype api_version: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: None, or the result of cls(response) + :return: None or the result of cls(response) :rtype: None - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType[None] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + 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', "2020-09-01") # type: str + api_version = kwargs.pop("api_version", _params.pop("api-version", "2020-09-01")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[None] - request = build_policy_definitions_delete_request( policy_definition_name=policy_definition_name, subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.delete.metadata['url'], + template_url=self.delete.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200, 204]: @@ -2666,163 +2602,231 @@ def delete( # pylint: disable=inconsistent-return-statements if cls: return cls(pipeline_response, None, {}) - delete.metadata = {'url': "/subscriptions/{subscriptionId}/providers/Microsoft.Authorization/policyDefinitions/{policyDefinitionName}"} # type: ignore - + delete.metadata = {"url": "/subscriptions/{subscriptionId}/providers/Microsoft.Authorization/policyDefinitions/{policyDefinitionName}"} # type: ignore @distributed_trace - def get( - self, - policy_definition_name: str, - **kwargs: Any - ) -> "_models.PolicyDefinition": + def get(self, policy_definition_name: str, **kwargs: Any) -> _models.PolicyDefinition: """Retrieves a policy definition in a subscription. This operation retrieves the policy definition in the given subscription with the given name. - :param policy_definition_name: The name of the policy definition to get. + :param policy_definition_name: The name of the policy definition to get. Required. :type policy_definition_name: str - :keyword api_version: Api Version. Default value is "2020-09-01". Note that overriding this - default value may result in unsupported behavior. - :paramtype api_version: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: PolicyDefinition, or the result of cls(response) + :return: PolicyDefinition or the result of cls(response) :rtype: ~azure.mgmt.resource.policy.v2020_09_01.models.PolicyDefinition - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.PolicyDefinition"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + 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', "2020-09-01") # type: str + api_version = kwargs.pop("api_version", _params.pop("api-version", "2020-09-01")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[_models.PolicyDefinition] - request = build_policy_definitions_get_request( policy_definition_name=policy_definition_name, subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.get.metadata['url'], + template_url=self.get.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) - deserialized = self._deserialize('PolicyDefinition', pipeline_response) + deserialized = self._deserialize("PolicyDefinition", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - get.metadata = {'url': "/subscriptions/{subscriptionId}/providers/Microsoft.Authorization/policyDefinitions/{policyDefinitionName}"} # type: ignore - + get.metadata = {"url": "/subscriptions/{subscriptionId}/providers/Microsoft.Authorization/policyDefinitions/{policyDefinitionName}"} # type: ignore @distributed_trace - def get_built_in( - self, - policy_definition_name: str, - **kwargs: Any - ) -> "_models.PolicyDefinition": + def get_built_in(self, policy_definition_name: str, **kwargs: Any) -> _models.PolicyDefinition: """Retrieves a built-in policy definition. This operation retrieves the built-in policy definition with the given name. - :param policy_definition_name: The name of the built-in policy definition to get. + :param policy_definition_name: The name of the built-in policy definition to get. Required. :type policy_definition_name: str - :keyword api_version: Api Version. Default value is "2020-09-01". Note that overriding this - default value may result in unsupported behavior. - :paramtype api_version: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: PolicyDefinition, or the result of cls(response) + :return: PolicyDefinition or the result of cls(response) :rtype: ~azure.mgmt.resource.policy.v2020_09_01.models.PolicyDefinition - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.PolicyDefinition"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + 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', "2020-09-01") # type: str + api_version = kwargs.pop("api_version", _params.pop("api-version", "2020-09-01")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[_models.PolicyDefinition] - request = build_policy_definitions_get_built_in_request( policy_definition_name=policy_definition_name, api_version=api_version, - template_url=self.get_built_in.metadata['url'], + template_url=self.get_built_in.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) - deserialized = self._deserialize('PolicyDefinition', pipeline_response) + deserialized = self._deserialize("PolicyDefinition", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - get_built_in.metadata = {'url': "/providers/Microsoft.Authorization/policyDefinitions/{policyDefinitionName}"} # type: ignore + get_built_in.metadata = {"url": "/providers/Microsoft.Authorization/policyDefinitions/{policyDefinitionName}"} # type: ignore + + @overload + def create_or_update_at_management_group( + self, + policy_definition_name: str, + management_group_id: str, + parameters: _models.PolicyDefinition, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.PolicyDefinition: + """Creates or updates a policy definition in a management group. + + This operation creates or updates a policy definition in the given management group with the + given name. + + :param policy_definition_name: The name of the policy definition to create. Required. + :type policy_definition_name: str + :param management_group_id: The ID of the management group. Required. + :type management_group_id: str + :param parameters: The policy definition properties. Required. + :type parameters: ~azure.mgmt.resource.policy.v2020_09_01.models.PolicyDefinition + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: PolicyDefinition or the result of cls(response) + :rtype: ~azure.mgmt.resource.policy.v2020_09_01.models.PolicyDefinition + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + def create_or_update_at_management_group( + self, + policy_definition_name: str, + management_group_id: str, + parameters: IO, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.PolicyDefinition: + """Creates or updates a policy definition in a management group. + + This operation creates or updates a policy definition in the given management group with the + given name. + :param policy_definition_name: The name of the policy definition to create. Required. + :type policy_definition_name: str + :param management_group_id: The ID of the management group. Required. + :type management_group_id: str + :param parameters: The policy definition properties. Required. + :type parameters: IO + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: PolicyDefinition or the result of cls(response) + :rtype: ~azure.mgmt.resource.policy.v2020_09_01.models.PolicyDefinition + :raises ~azure.core.exceptions.HttpResponseError: + """ @distributed_trace def create_or_update_at_management_group( self, policy_definition_name: str, management_group_id: str, - parameters: "_models.PolicyDefinition", + parameters: Union[_models.PolicyDefinition, IO], **kwargs: Any - ) -> "_models.PolicyDefinition": + ) -> _models.PolicyDefinition: """Creates or updates a policy definition in a management group. This operation creates or updates a policy definition in the given management group with the given name. - :param policy_definition_name: The name of the policy definition to create. + :param policy_definition_name: The name of the policy definition to create. Required. :type policy_definition_name: str - :param management_group_id: The ID of the management group. + :param management_group_id: The ID of the management group. Required. :type management_group_id: str - :param parameters: The policy definition properties. - :type parameters: ~azure.mgmt.resource.policy.v2020_09_01.models.PolicyDefinition - :keyword api_version: Api Version. Default value is "2020-09-01". Note that overriding this - default value may result in unsupported behavior. - :paramtype api_version: str + :param parameters: The policy definition properties. Is either a model type or a IO type. + Required. + :type parameters: ~azure.mgmt.resource.policy.v2020_09_01.models.PolicyDefinition or IO + :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. + Default value is None. + :paramtype content_type: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: PolicyDefinition, or the result of cls(response) + :return: PolicyDefinition or the result of cls(response) :rtype: ~azure.mgmt.resource.policy.v2020_09_01.models.PolicyDefinition - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.PolicyDefinition"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) - api_version = kwargs.pop('api_version', "2020-09-01") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - _json = self._serialize.body(parameters, 'PolicyDefinition') + api_version = kwargs.pop("api_version", _params.pop("api-version", "2020-09-01")) # type: str + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.PolicyDefinition] + + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(parameters, (IO, bytes)): + _content = parameters + else: + _json = self._serialize.body(parameters, "PolicyDefinition") request = build_policy_definitions_create_or_update_at_management_group_request( policy_definition_name=policy_definition_name, @@ -2830,78 +2834,79 @@ def create_or_update_at_management_group( api_version=api_version, content_type=content_type, json=_json, - template_url=self.create_or_update_at_management_group.metadata['url'], + content=_content, + template_url=self.create_or_update_at_management_group.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [201]: map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) - deserialized = self._deserialize('PolicyDefinition', pipeline_response) + deserialized = self._deserialize("PolicyDefinition", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - create_or_update_at_management_group.metadata = {'url': "/providers/Microsoft.Management/managementGroups/{managementGroupId}/providers/Microsoft.Authorization/policyDefinitions/{policyDefinitionName}"} # type: ignore - + create_or_update_at_management_group.metadata = {"url": "/providers/Microsoft.Management/managementGroups/{managementGroupId}/providers/Microsoft.Authorization/policyDefinitions/{policyDefinitionName}"} # type: ignore @distributed_trace def delete_at_management_group( # pylint: disable=inconsistent-return-statements - self, - policy_definition_name: str, - management_group_id: str, - **kwargs: Any + self, policy_definition_name: str, management_group_id: str, **kwargs: Any ) -> None: """Deletes a policy definition in a management group. This operation deletes the policy definition in the given management group with the given name. - :param policy_definition_name: The name of the policy definition to delete. + :param policy_definition_name: The name of the policy definition to delete. Required. :type policy_definition_name: str - :param management_group_id: The ID of the management group. + :param management_group_id: The ID of the management group. Required. :type management_group_id: str - :keyword api_version: Api Version. Default value is "2020-09-01". Note that overriding this - default value may result in unsupported behavior. - :paramtype api_version: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: None, or the result of cls(response) + :return: None or the result of cls(response) :rtype: None - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType[None] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + 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', "2020-09-01") # type: str + api_version = kwargs.pop("api_version", _params.pop("api-version", "2020-09-01")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[None] - request = build_policy_definitions_delete_at_management_group_request( policy_definition_name=policy_definition_name, management_group_id=management_group_id, api_version=api_version, - template_url=self.delete_at_management_group.metadata['url'], + template_url=self.delete_at_management_group.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200, 204]: @@ -2911,79 +2916,74 @@ def delete_at_management_group( # pylint: disable=inconsistent-return-statement if cls: return cls(pipeline_response, None, {}) - delete_at_management_group.metadata = {'url': "/providers/Microsoft.Management/managementGroups/{managementGroupId}/providers/Microsoft.Authorization/policyDefinitions/{policyDefinitionName}"} # type: ignore - + delete_at_management_group.metadata = {"url": "/providers/Microsoft.Management/managementGroups/{managementGroupId}/providers/Microsoft.Authorization/policyDefinitions/{policyDefinitionName}"} # type: ignore @distributed_trace def get_at_management_group( - self, - policy_definition_name: str, - management_group_id: str, - **kwargs: Any - ) -> "_models.PolicyDefinition": + self, policy_definition_name: str, management_group_id: str, **kwargs: Any + ) -> _models.PolicyDefinition: """Retrieve a policy definition in a management group. This operation retrieves the policy definition in the given management group with the given name. - :param policy_definition_name: The name of the policy definition to get. + :param policy_definition_name: The name of the policy definition to get. Required. :type policy_definition_name: str - :param management_group_id: The ID of the management group. + :param management_group_id: The ID of the management group. Required. :type management_group_id: str - :keyword api_version: Api Version. Default value is "2020-09-01". Note that overriding this - default value may result in unsupported behavior. - :paramtype api_version: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: PolicyDefinition, or the result of cls(response) + :return: PolicyDefinition or the result of cls(response) :rtype: ~azure.mgmt.resource.policy.v2020_09_01.models.PolicyDefinition - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.PolicyDefinition"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) - api_version = kwargs.pop('api_version', "2020-09-01") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2020-09-01")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[_models.PolicyDefinition] - request = build_policy_definitions_get_at_management_group_request( policy_definition_name=policy_definition_name, management_group_id=management_group_id, api_version=api_version, - template_url=self.get_at_management_group.metadata['url'], + template_url=self.get_at_management_group.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) - deserialized = self._deserialize('PolicyDefinition', pipeline_response) + deserialized = self._deserialize("PolicyDefinition", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - get_at_management_group.metadata = {'url': "/providers/Microsoft.Management/managementGroups/{managementGroupId}/providers/Microsoft.Authorization/policyDefinitions/{policyDefinitionName}"} # type: ignore - + get_at_management_group.metadata = {"url": "/providers/Microsoft.Management/managementGroups/{managementGroupId}/providers/Microsoft.Authorization/policyDefinitions/{policyDefinitionName}"} # type: ignore @distributed_trace def list( - self, - filter: Optional[str] = None, - top: Optional[int] = None, - **kwargs: Any - ) -> Iterable["_models.PolicyDefinitionListResult"]: + self, filter: Optional[str] = None, top: Optional[int] = None, **kwargs: Any + ) -> Iterable["_models.PolicyDefinition"]: """Retrieves policy definitions in a subscription. This operation retrieves a list of all the policy definitions in a given subscription that @@ -3009,44 +3009,45 @@ def list( :param top: Maximum number of records to return. When the $top filter is not provided, it will return 500 records. Default value is None. :type top: int - :keyword api_version: Api Version. Default value is "2020-09-01". Note that overriding this - default value may result in unsupported behavior. - :paramtype api_version: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either PolicyDefinitionListResult or the result of - cls(response) + :return: An iterator like instance of either PolicyDefinition or the result of cls(response) :rtype: - ~azure.core.paging.ItemPaged[~azure.mgmt.resource.policy.v2020_09_01.models.PolicyDefinitionListResult] - :raises: ~azure.core.exceptions.HttpResponseError + ~azure.core.paging.ItemPaged[~azure.mgmt.resource.policy.v2020_09_01.models.PolicyDefinition] + :raises ~azure.core.exceptions.HttpResponseError: """ - api_version = kwargs.pop('api_version', "2020-09-01") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2020-09-01")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[_models.PolicyDefinitionListResult] - cls = kwargs.pop('cls', None) # type: ClsType["_models.PolicyDefinitionListResult"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) + def prepare_request(next_link=None): if not next_link: - + request = build_policy_definitions_list_request( subscription_id=self._config.subscription_id, - api_version=api_version, filter=filter, top=top, - template_url=self.list.metadata['url'], + 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.url = self._client.format_url(request.url) # type: ignore else: - - request = build_policy_definitions_list_request( - subscription_id=self._config.subscription_id, - template_url=next_link, - ) + request = HttpRequest("GET", next_link) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore request.method = "GET" return request @@ -3060,10 +3061,8 @@ def extract_data(pipeline_response): def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) response = pipeline_response.http_response @@ -3073,19 +3072,14 @@ def get_next(next_link=None): return pipeline_response + return ItemPaged(get_next, extract_data) - return ItemPaged( - get_next, extract_data - ) - list.metadata = {'url': "/subscriptions/{subscriptionId}/providers/Microsoft.Authorization/policyDefinitions"} # type: ignore + list.metadata = {"url": "/subscriptions/{subscriptionId}/providers/Microsoft.Authorization/policyDefinitions"} # type: ignore @distributed_trace def list_built_in( - self, - filter: Optional[str] = None, - top: Optional[int] = None, - **kwargs: Any - ) -> Iterable["_models.PolicyDefinitionListResult"]: + self, filter: Optional[str] = None, top: Optional[int] = None, **kwargs: Any + ) -> Iterable["_models.PolicyDefinition"]: """Retrieve built-in policy definitions. This operation retrieves a list of all the built-in policy definitions that match the optional @@ -3106,42 +3100,44 @@ def list_built_in( :param top: Maximum number of records to return. When the $top filter is not provided, it will return 500 records. Default value is None. :type top: int - :keyword api_version: Api Version. Default value is "2020-09-01". Note that overriding this - default value may result in unsupported behavior. - :paramtype api_version: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either PolicyDefinitionListResult or the result of - cls(response) + :return: An iterator like instance of either PolicyDefinition or the result of cls(response) :rtype: - ~azure.core.paging.ItemPaged[~azure.mgmt.resource.policy.v2020_09_01.models.PolicyDefinitionListResult] - :raises: ~azure.core.exceptions.HttpResponseError + ~azure.core.paging.ItemPaged[~azure.mgmt.resource.policy.v2020_09_01.models.PolicyDefinition] + :raises ~azure.core.exceptions.HttpResponseError: """ - api_version = kwargs.pop('api_version', "2020-09-01") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2020-09-01")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[_models.PolicyDefinitionListResult] - cls = kwargs.pop('cls', None) # type: ClsType["_models.PolicyDefinitionListResult"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) + def prepare_request(next_link=None): if not next_link: - + request = build_policy_definitions_list_built_in_request( - api_version=api_version, filter=filter, top=top, - template_url=self.list_built_in.metadata['url'], + api_version=api_version, + template_url=self.list_built_in.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore else: - - request = build_policy_definitions_list_built_in_request( - template_url=next_link, - ) + request = HttpRequest("GET", next_link) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore request.method = "GET" return request @@ -3155,10 +3151,8 @@ def extract_data(pipeline_response): def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) response = pipeline_response.http_response @@ -3168,20 +3162,14 @@ def get_next(next_link=None): return pipeline_response + return ItemPaged(get_next, extract_data) - return ItemPaged( - get_next, extract_data - ) - list_built_in.metadata = {'url': "/providers/Microsoft.Authorization/policyDefinitions"} # type: ignore + list_built_in.metadata = {"url": "/providers/Microsoft.Authorization/policyDefinitions"} # type: ignore @distributed_trace def list_by_management_group( - self, - management_group_id: str, - filter: Optional[str] = None, - top: Optional[int] = None, - **kwargs: Any - ) -> Iterable["_models.PolicyDefinitionListResult"]: + self, management_group_id: str, filter: Optional[str] = None, top: Optional[int] = None, **kwargs: Any + ) -> Iterable["_models.PolicyDefinition"]: """Retrieve policy definitions in a management group. This operation retrieves a list of all the policy definitions in a given management group that @@ -3196,7 +3184,7 @@ def list_by_management_group( provided, the returned list only includes all policy definitions whose category match the {value}. - :param management_group_id: The ID of the management group. + :param management_group_id: The ID of the management group. Required. :type management_group_id: str :param filter: The filter to apply on the operation. Valid values for $filter are: 'atExactScope()', 'policyType -eq {value}' or 'category eq '{value}''. If $filter is not @@ -3210,44 +3198,45 @@ def list_by_management_group( :param top: Maximum number of records to return. When the $top filter is not provided, it will return 500 records. Default value is None. :type top: int - :keyword api_version: Api Version. Default value is "2020-09-01". Note that overriding this - default value may result in unsupported behavior. - :paramtype api_version: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either PolicyDefinitionListResult or the result of - cls(response) + :return: An iterator like instance of either PolicyDefinition or the result of cls(response) :rtype: - ~azure.core.paging.ItemPaged[~azure.mgmt.resource.policy.v2020_09_01.models.PolicyDefinitionListResult] - :raises: ~azure.core.exceptions.HttpResponseError + ~azure.core.paging.ItemPaged[~azure.mgmt.resource.policy.v2020_09_01.models.PolicyDefinition] + :raises ~azure.core.exceptions.HttpResponseError: """ - api_version = kwargs.pop('api_version', "2020-09-01") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2020-09-01")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[_models.PolicyDefinitionListResult] - cls = kwargs.pop('cls', None) # type: ClsType["_models.PolicyDefinitionListResult"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) + def prepare_request(next_link=None): if not next_link: - + request = build_policy_definitions_list_by_management_group_request( management_group_id=management_group_id, - api_version=api_version, filter=filter, top=top, - template_url=self.list_by_management_group.metadata['url'], + api_version=api_version, + template_url=self.list_by_management_group.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore else: - - request = build_policy_definitions_list_by_management_group_request( - management_group_id=management_group_id, - template_url=next_link, - ) + request = HttpRequest("GET", next_link) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore request.method = "GET" return request @@ -3261,10 +3250,8 @@ def extract_data(pipeline_response): def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) response = pipeline_response.http_response @@ -3274,67 +3261,123 @@ def get_next(next_link=None): return pipeline_response + return ItemPaged(get_next, extract_data) + + list_by_management_group.metadata = {"url": "/providers/Microsoft.Management/managementGroups/{managementGroupId}/providers/Microsoft.Authorization/policyDefinitions"} # type: ignore + + +class PolicySetDefinitionsOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. + + Instead, you should access the following operations through + :class:`~azure.mgmt.resource.policy.v2020_09_01.PolicyClient`'s + :attr:`policy_set_definitions` attribute. + """ + + models = _models + + def __init__(self, *args, **kwargs): + input_args = list(args) + self._client = input_args.pop(0) if input_args else kwargs.pop("client") + self._config = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") + + @overload + def create_or_update( + self, + policy_set_definition_name: str, + parameters: _models.PolicySetDefinition, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.PolicySetDefinition: + """Creates or updates a policy set definition. + + This operation creates or updates a policy set definition in the given subscription with the + given name. + + :param policy_set_definition_name: The name of the policy set definition to create. Required. + :type policy_set_definition_name: str + :param parameters: The policy set definition properties. Required. + :type parameters: ~azure.mgmt.resource.policy.v2020_09_01.models.PolicySetDefinition + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: PolicySetDefinition or the result of cls(response) + :rtype: ~azure.mgmt.resource.policy.v2020_09_01.models.PolicySetDefinition + :raises ~azure.core.exceptions.HttpResponseError: + """ - return ItemPaged( - get_next, extract_data - ) - list_by_management_group.metadata = {'url': "/providers/Microsoft.Management/managementGroups/{managementGroupId}/providers/Microsoft.Authorization/policyDefinitions"} # type: ignore -class PolicySetDefinitionsOperations(object): - """PolicySetDefinitionsOperations operations. - - You should not instantiate this class directly. Instead, you should create a Client instance that - instantiates it for you and attaches it as an attribute. - - :ivar models: Alias to model classes used in this operation group. - :type models: ~azure.mgmt.resource.policy.v2020_09_01.models - :param client: Client for service requests. - :param config: Configuration of service client. - :param serializer: An object model serializer. - :param deserializer: An object model deserializer. - """ + @overload + def create_or_update( + self, policy_set_definition_name: str, parameters: IO, *, content_type: str = "application/json", **kwargs: Any + ) -> _models.PolicySetDefinition: + """Creates or updates a policy set definition. - models = _models + This operation creates or updates a policy set definition in the given subscription with the + given name. - def __init__(self, client, config, serializer, deserializer): - self._client = client - self._serialize = serializer - self._deserialize = deserializer - self._config = config + :param policy_set_definition_name: The name of the policy set definition to create. Required. + :type policy_set_definition_name: str + :param parameters: The policy set definition properties. Required. + :type parameters: IO + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: PolicySetDefinition or the result of cls(response) + :rtype: ~azure.mgmt.resource.policy.v2020_09_01.models.PolicySetDefinition + :raises ~azure.core.exceptions.HttpResponseError: + """ @distributed_trace def create_or_update( - self, - policy_set_definition_name: str, - parameters: "_models.PolicySetDefinition", - **kwargs: Any - ) -> "_models.PolicySetDefinition": + self, policy_set_definition_name: str, parameters: Union[_models.PolicySetDefinition, IO], **kwargs: Any + ) -> _models.PolicySetDefinition: """Creates or updates a policy set definition. This operation creates or updates a policy set definition in the given subscription with the given name. - :param policy_set_definition_name: The name of the policy set definition to create. + :param policy_set_definition_name: The name of the policy set definition to create. Required. :type policy_set_definition_name: str - :param parameters: The policy set definition properties. - :type parameters: ~azure.mgmt.resource.policy.v2020_09_01.models.PolicySetDefinition - :keyword api_version: Api Version. Default value is "2020-09-01". Note that overriding this - default value may result in unsupported behavior. - :paramtype api_version: str + :param parameters: The policy set definition properties. Is either a model type or a IO type. + Required. + :type parameters: ~azure.mgmt.resource.policy.v2020_09_01.models.PolicySetDefinition or IO + :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. + Default value is None. + :paramtype content_type: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: PolicySetDefinition, or the result of cls(response) + :return: PolicySetDefinition or the result of cls(response) :rtype: ~azure.mgmt.resource.policy.v2020_09_01.models.PolicySetDefinition - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.PolicySetDefinition"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) - api_version = kwargs.pop('api_version', "2020-09-01") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - _json = self._serialize.body(parameters, 'PolicySetDefinition') + api_version = kwargs.pop("api_version", _params.pop("api-version", "2020-09-01")) # type: str + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.PolicySetDefinition] + + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(parameters, (IO, bytes)): + _content = parameters + else: + _json = self._serialize.body(parameters, "PolicySetDefinition") request = build_policy_set_definitions_create_or_update_request( policy_set_definition_name=policy_set_definition_name, @@ -3342,16 +3385,18 @@ def create_or_update( api_version=api_version, content_type=content_type, json=_json, - template_url=self.create_or_update.metadata['url'], + content=_content, + template_url=self.create_or_update.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200, 201]: @@ -3359,62 +3404,62 @@ def create_or_update( raise HttpResponseError(response=response, error_format=ARMErrorFormat) if response.status_code == 200: - deserialized = self._deserialize('PolicySetDefinition', pipeline_response) + deserialized = self._deserialize("PolicySetDefinition", pipeline_response) if response.status_code == 201: - deserialized = self._deserialize('PolicySetDefinition', pipeline_response) + deserialized = self._deserialize("PolicySetDefinition", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - create_or_update.metadata = {'url': "/subscriptions/{subscriptionId}/providers/Microsoft.Authorization/policySetDefinitions/{policySetDefinitionName}"} # type: ignore - + create_or_update.metadata = {"url": "/subscriptions/{subscriptionId}/providers/Microsoft.Authorization/policySetDefinitions/{policySetDefinitionName}"} # type: ignore @distributed_trace def delete( # pylint: disable=inconsistent-return-statements - self, - policy_set_definition_name: str, - **kwargs: Any + self, policy_set_definition_name: str, **kwargs: Any ) -> None: """Deletes a policy set definition. This operation deletes the policy set definition in the given subscription with the given name. - :param policy_set_definition_name: The name of the policy set definition to delete. + :param policy_set_definition_name: The name of the policy set definition to delete. Required. :type policy_set_definition_name: str - :keyword api_version: Api Version. Default value is "2020-09-01". Note that overriding this - default value may result in unsupported behavior. - :paramtype api_version: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: None, or the result of cls(response) + :return: None or the result of cls(response) :rtype: None - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType[None] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) - api_version = kwargs.pop('api_version', "2020-09-01") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2020-09-01")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[None] - request = build_policy_set_definitions_delete_request( policy_set_definition_name=policy_set_definition_name, subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.delete.metadata['url'], + template_url=self.delete.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200, 204]: @@ -3424,134 +3469,126 @@ def delete( # pylint: disable=inconsistent-return-statements if cls: return cls(pipeline_response, None, {}) - delete.metadata = {'url': "/subscriptions/{subscriptionId}/providers/Microsoft.Authorization/policySetDefinitions/{policySetDefinitionName}"} # type: ignore - + delete.metadata = {"url": "/subscriptions/{subscriptionId}/providers/Microsoft.Authorization/policySetDefinitions/{policySetDefinitionName}"} # type: ignore @distributed_trace - def get( - self, - policy_set_definition_name: str, - **kwargs: Any - ) -> "_models.PolicySetDefinition": + def get(self, policy_set_definition_name: str, **kwargs: Any) -> _models.PolicySetDefinition: """Retrieves a policy set definition. This operation retrieves the policy set definition in the given subscription with the given name. - :param policy_set_definition_name: The name of the policy set definition to get. + :param policy_set_definition_name: The name of the policy set definition to get. Required. :type policy_set_definition_name: str - :keyword api_version: Api Version. Default value is "2020-09-01". Note that overriding this - default value may result in unsupported behavior. - :paramtype api_version: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: PolicySetDefinition, or the result of cls(response) + :return: PolicySetDefinition or the result of cls(response) :rtype: ~azure.mgmt.resource.policy.v2020_09_01.models.PolicySetDefinition - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.PolicySetDefinition"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) - api_version = kwargs.pop('api_version', "2020-09-01") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2020-09-01")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[_models.PolicySetDefinition] - request = build_policy_set_definitions_get_request( policy_set_definition_name=policy_set_definition_name, subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.get.metadata['url'], + template_url=self.get.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) - deserialized = self._deserialize('PolicySetDefinition', pipeline_response) + deserialized = self._deserialize("PolicySetDefinition", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - get.metadata = {'url': "/subscriptions/{subscriptionId}/providers/Microsoft.Authorization/policySetDefinitions/{policySetDefinitionName}"} # type: ignore - + get.metadata = {"url": "/subscriptions/{subscriptionId}/providers/Microsoft.Authorization/policySetDefinitions/{policySetDefinitionName}"} # type: ignore @distributed_trace - def get_built_in( - self, - policy_set_definition_name: str, - **kwargs: Any - ) -> "_models.PolicySetDefinition": + def get_built_in(self, policy_set_definition_name: str, **kwargs: Any) -> _models.PolicySetDefinition: """Retrieves a built in policy set definition. This operation retrieves the built-in policy set definition with the given name. - :param policy_set_definition_name: The name of the policy set definition to get. + :param policy_set_definition_name: The name of the policy set definition to get. Required. :type policy_set_definition_name: str - :keyword api_version: Api Version. Default value is "2020-09-01". Note that overriding this - default value may result in unsupported behavior. - :paramtype api_version: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: PolicySetDefinition, or the result of cls(response) + :return: PolicySetDefinition or the result of cls(response) :rtype: ~azure.mgmt.resource.policy.v2020_09_01.models.PolicySetDefinition - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.PolicySetDefinition"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) - api_version = kwargs.pop('api_version', "2020-09-01") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2020-09-01")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[_models.PolicySetDefinition] - request = build_policy_set_definitions_get_built_in_request( policy_set_definition_name=policy_set_definition_name, api_version=api_version, - template_url=self.get_built_in.metadata['url'], + template_url=self.get_built_in.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) - deserialized = self._deserialize('PolicySetDefinition', pipeline_response) + deserialized = self._deserialize("PolicySetDefinition", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - get_built_in.metadata = {'url': "/providers/Microsoft.Authorization/policySetDefinitions/{policySetDefinitionName}"} # type: ignore - + get_built_in.metadata = {"url": "/providers/Microsoft.Authorization/policySetDefinitions/{policySetDefinitionName}"} # type: ignore @distributed_trace def list( - self, - filter: Optional[str] = None, - top: Optional[int] = None, - **kwargs: Any - ) -> Iterable["_models.PolicySetDefinitionListResult"]: + self, filter: Optional[str] = None, top: Optional[int] = None, **kwargs: Any + ) -> Iterable["_models.PolicySetDefinition"]: """Retrieves the policy set definitions for a subscription. This operation retrieves a list of all the policy set definitions in a given subscription that @@ -3577,44 +3614,45 @@ def list( :param top: Maximum number of records to return. When the $top filter is not provided, it will return 500 records. Default value is None. :type top: int - :keyword api_version: Api Version. Default value is "2020-09-01". Note that overriding this - default value may result in unsupported behavior. - :paramtype api_version: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either PolicySetDefinitionListResult or the result of - cls(response) + :return: An iterator like instance of either PolicySetDefinition or the result of cls(response) :rtype: - ~azure.core.paging.ItemPaged[~azure.mgmt.resource.policy.v2020_09_01.models.PolicySetDefinitionListResult] - :raises: ~azure.core.exceptions.HttpResponseError + ~azure.core.paging.ItemPaged[~azure.mgmt.resource.policy.v2020_09_01.models.PolicySetDefinition] + :raises ~azure.core.exceptions.HttpResponseError: """ - api_version = kwargs.pop('api_version', "2020-09-01") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2020-09-01")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[_models.PolicySetDefinitionListResult] - cls = kwargs.pop('cls', None) # type: ClsType["_models.PolicySetDefinitionListResult"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) + def prepare_request(next_link=None): if not next_link: - + request = build_policy_set_definitions_list_request( subscription_id=self._config.subscription_id, - api_version=api_version, filter=filter, top=top, - template_url=self.list.metadata['url'], + 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.url = self._client.format_url(request.url) # type: ignore else: - - request = build_policy_set_definitions_list_request( - subscription_id=self._config.subscription_id, - template_url=next_link, - ) + request = HttpRequest("GET", next_link) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore request.method = "GET" return request @@ -3628,10 +3666,8 @@ def extract_data(pipeline_response): def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) response = pipeline_response.http_response @@ -3641,19 +3677,14 @@ def get_next(next_link=None): return pipeline_response + return ItemPaged(get_next, extract_data) - return ItemPaged( - get_next, extract_data - ) - list.metadata = {'url': "/subscriptions/{subscriptionId}/providers/Microsoft.Authorization/policySetDefinitions"} # type: ignore + list.metadata = {"url": "/subscriptions/{subscriptionId}/providers/Microsoft.Authorization/policySetDefinitions"} # type: ignore @distributed_trace def list_built_in( - self, - filter: Optional[str] = None, - top: Optional[int] = None, - **kwargs: Any - ) -> Iterable["_models.PolicySetDefinitionListResult"]: + self, filter: Optional[str] = None, top: Optional[int] = None, **kwargs: Any + ) -> Iterable["_models.PolicySetDefinition"]: """Retrieves built-in policy set definitions. This operation retrieves a list of all the built-in policy set definitions that match the @@ -3672,42 +3703,44 @@ def list_built_in( :param top: Maximum number of records to return. When the $top filter is not provided, it will return 500 records. Default value is None. :type top: int - :keyword api_version: Api Version. Default value is "2020-09-01". Note that overriding this - default value may result in unsupported behavior. - :paramtype api_version: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either PolicySetDefinitionListResult or the result of - cls(response) + :return: An iterator like instance of either PolicySetDefinition or the result of cls(response) :rtype: - ~azure.core.paging.ItemPaged[~azure.mgmt.resource.policy.v2020_09_01.models.PolicySetDefinitionListResult] - :raises: ~azure.core.exceptions.HttpResponseError + ~azure.core.paging.ItemPaged[~azure.mgmt.resource.policy.v2020_09_01.models.PolicySetDefinition] + :raises ~azure.core.exceptions.HttpResponseError: """ - api_version = kwargs.pop('api_version', "2020-09-01") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2020-09-01")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[_models.PolicySetDefinitionListResult] - cls = kwargs.pop('cls', None) # type: ClsType["_models.PolicySetDefinitionListResult"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) + def prepare_request(next_link=None): if not next_link: - + request = build_policy_set_definitions_list_built_in_request( - api_version=api_version, filter=filter, top=top, - template_url=self.list_built_in.metadata['url'], + api_version=api_version, + template_url=self.list_built_in.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore else: - - request = build_policy_set_definitions_list_built_in_request( - template_url=next_link, - ) + request = HttpRequest("GET", next_link) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore request.method = "GET" return request @@ -3721,10 +3754,8 @@ def extract_data(pipeline_response): def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) response = pipeline_response.http_response @@ -3734,49 +3765,120 @@ def get_next(next_link=None): return pipeline_response + return ItemPaged(get_next, extract_data) - return ItemPaged( - get_next, extract_data - ) - list_built_in.metadata = {'url': "/providers/Microsoft.Authorization/policySetDefinitions"} # type: ignore + list_built_in.metadata = {"url": "/providers/Microsoft.Authorization/policySetDefinitions"} # type: ignore - @distributed_trace + @overload def create_or_update_at_management_group( self, policy_set_definition_name: str, management_group_id: str, - parameters: "_models.PolicySetDefinition", + parameters: _models.PolicySetDefinition, + *, + content_type: str = "application/json", **kwargs: Any - ) -> "_models.PolicySetDefinition": + ) -> _models.PolicySetDefinition: """Creates or updates a policy set definition. This operation creates or updates a policy set definition in the given management group with the given name. - :param policy_set_definition_name: The name of the policy set definition to create. + :param policy_set_definition_name: The name of the policy set definition to create. Required. :type policy_set_definition_name: str - :param management_group_id: The ID of the management group. + :param management_group_id: The ID of the management group. Required. :type management_group_id: str - :param parameters: The policy set definition properties. + :param parameters: The policy set definition properties. Required. :type parameters: ~azure.mgmt.resource.policy.v2020_09_01.models.PolicySetDefinition - :keyword api_version: Api Version. Default value is "2020-09-01". Note that overriding this - default value may result in unsupported behavior. - :paramtype api_version: str + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: PolicySetDefinition or the result of cls(response) + :rtype: ~azure.mgmt.resource.policy.v2020_09_01.models.PolicySetDefinition + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + def create_or_update_at_management_group( + self, + policy_set_definition_name: str, + management_group_id: str, + parameters: IO, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.PolicySetDefinition: + """Creates or updates a policy set definition. + + This operation creates or updates a policy set definition in the given management group with + the given name. + + :param policy_set_definition_name: The name of the policy set definition to create. Required. + :type policy_set_definition_name: str + :param management_group_id: The ID of the management group. Required. + :type management_group_id: str + :param parameters: The policy set definition properties. Required. + :type parameters: IO + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: PolicySetDefinition or the result of cls(response) + :rtype: ~azure.mgmt.resource.policy.v2020_09_01.models.PolicySetDefinition + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace + def create_or_update_at_management_group( + self, + policy_set_definition_name: str, + management_group_id: str, + parameters: Union[_models.PolicySetDefinition, IO], + **kwargs: Any + ) -> _models.PolicySetDefinition: + """Creates or updates a policy set definition. + + This operation creates or updates a policy set definition in the given management group with + the given name. + + :param policy_set_definition_name: The name of the policy set definition to create. Required. + :type policy_set_definition_name: str + :param management_group_id: The ID of the management group. Required. + :type management_group_id: str + :param parameters: The policy set definition properties. Is either a model type or a IO type. + Required. + :type parameters: ~azure.mgmt.resource.policy.v2020_09_01.models.PolicySetDefinition or IO + :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. + Default value is None. + :paramtype content_type: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: PolicySetDefinition, or the result of cls(response) + :return: PolicySetDefinition or the result of cls(response) :rtype: ~azure.mgmt.resource.policy.v2020_09_01.models.PolicySetDefinition - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.PolicySetDefinition"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) - api_version = kwargs.pop('api_version', "2020-09-01") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - _json = self._serialize.body(parameters, 'PolicySetDefinition') + api_version = kwargs.pop("api_version", _params.pop("api-version", "2020-09-01")) # type: str + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.PolicySetDefinition] + + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(parameters, (IO, bytes)): + _content = parameters + else: + _json = self._serialize.body(parameters, "PolicySetDefinition") request = build_policy_set_definitions_create_or_update_at_management_group_request( policy_set_definition_name=policy_set_definition_name, @@ -3784,16 +3886,18 @@ def create_or_update_at_management_group( api_version=api_version, content_type=content_type, json=_json, - template_url=self.create_or_update_at_management_group.metadata['url'], + content=_content, + template_url=self.create_or_update_at_management_group.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200, 201]: @@ -3801,66 +3905,65 @@ def create_or_update_at_management_group( raise HttpResponseError(response=response, error_format=ARMErrorFormat) if response.status_code == 200: - deserialized = self._deserialize('PolicySetDefinition', pipeline_response) + deserialized = self._deserialize("PolicySetDefinition", pipeline_response) if response.status_code == 201: - deserialized = self._deserialize('PolicySetDefinition', pipeline_response) + deserialized = self._deserialize("PolicySetDefinition", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - create_or_update_at_management_group.metadata = {'url': "/providers/Microsoft.Management/managementGroups/{managementGroupId}/providers/Microsoft.Authorization/policySetDefinitions/{policySetDefinitionName}"} # type: ignore - + create_or_update_at_management_group.metadata = {"url": "/providers/Microsoft.Management/managementGroups/{managementGroupId}/providers/Microsoft.Authorization/policySetDefinitions/{policySetDefinitionName}"} # type: ignore @distributed_trace def delete_at_management_group( # pylint: disable=inconsistent-return-statements - self, - policy_set_definition_name: str, - management_group_id: str, - **kwargs: Any + self, policy_set_definition_name: str, management_group_id: str, **kwargs: Any ) -> None: """Deletes a policy set definition. This operation deletes the policy set definition in the given management group with the given name. - :param policy_set_definition_name: The name of the policy set definition to delete. + :param policy_set_definition_name: The name of the policy set definition to delete. Required. :type policy_set_definition_name: str - :param management_group_id: The ID of the management group. + :param management_group_id: The ID of the management group. Required. :type management_group_id: str - :keyword api_version: Api Version. Default value is "2020-09-01". Note that overriding this - default value may result in unsupported behavior. - :paramtype api_version: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: None, or the result of cls(response) + :return: None or the result of cls(response) :rtype: None - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType[None] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + 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', "2020-09-01") # type: str + api_version = kwargs.pop("api_version", _params.pop("api-version", "2020-09-01")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[None] - request = build_policy_set_definitions_delete_at_management_group_request( policy_set_definition_name=policy_set_definition_name, management_group_id=management_group_id, api_version=api_version, - template_url=self.delete_at_management_group.metadata['url'], + template_url=self.delete_at_management_group.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200, 204]: @@ -3870,80 +3973,74 @@ def delete_at_management_group( # pylint: disable=inconsistent-return-statement if cls: return cls(pipeline_response, None, {}) - delete_at_management_group.metadata = {'url': "/providers/Microsoft.Management/managementGroups/{managementGroupId}/providers/Microsoft.Authorization/policySetDefinitions/{policySetDefinitionName}"} # type: ignore - + delete_at_management_group.metadata = {"url": "/providers/Microsoft.Management/managementGroups/{managementGroupId}/providers/Microsoft.Authorization/policySetDefinitions/{policySetDefinitionName}"} # type: ignore @distributed_trace def get_at_management_group( - self, - policy_set_definition_name: str, - management_group_id: str, - **kwargs: Any - ) -> "_models.PolicySetDefinition": + self, policy_set_definition_name: str, management_group_id: str, **kwargs: Any + ) -> _models.PolicySetDefinition: """Retrieves a policy set definition. This operation retrieves the policy set definition in the given management group with the given name. - :param policy_set_definition_name: The name of the policy set definition to get. + :param policy_set_definition_name: The name of the policy set definition to get. Required. :type policy_set_definition_name: str - :param management_group_id: The ID of the management group. + :param management_group_id: The ID of the management group. Required. :type management_group_id: str - :keyword api_version: Api Version. Default value is "2020-09-01". Note that overriding this - default value may result in unsupported behavior. - :paramtype api_version: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: PolicySetDefinition, or the result of cls(response) + :return: PolicySetDefinition or the result of cls(response) :rtype: ~azure.mgmt.resource.policy.v2020_09_01.models.PolicySetDefinition - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.PolicySetDefinition"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) - api_version = kwargs.pop('api_version', "2020-09-01") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2020-09-01")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[_models.PolicySetDefinition] - request = build_policy_set_definitions_get_at_management_group_request( policy_set_definition_name=policy_set_definition_name, management_group_id=management_group_id, api_version=api_version, - template_url=self.get_at_management_group.metadata['url'], + template_url=self.get_at_management_group.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) - deserialized = self._deserialize('PolicySetDefinition', pipeline_response) + deserialized = self._deserialize("PolicySetDefinition", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - get_at_management_group.metadata = {'url': "/providers/Microsoft.Management/managementGroups/{managementGroupId}/providers/Microsoft.Authorization/policySetDefinitions/{policySetDefinitionName}"} # type: ignore - + get_at_management_group.metadata = {"url": "/providers/Microsoft.Management/managementGroups/{managementGroupId}/providers/Microsoft.Authorization/policySetDefinitions/{policySetDefinitionName}"} # type: ignore @distributed_trace def list_by_management_group( - self, - management_group_id: str, - filter: Optional[str] = None, - top: Optional[int] = None, - **kwargs: Any - ) -> Iterable["_models.PolicySetDefinitionListResult"]: + self, management_group_id: str, filter: Optional[str] = None, top: Optional[int] = None, **kwargs: Any + ) -> Iterable["_models.PolicySetDefinition"]: """Retrieves all policy set definitions in management group. This operation retrieves a list of all the policy set definitions in a given management group @@ -3958,7 +4055,7 @@ def list_by_management_group( provided, the returned list only includes all policy set definitions whose category match the {value}. - :param management_group_id: The ID of the management group. + :param management_group_id: The ID of the management group. Required. :type management_group_id: str :param filter: The filter to apply on the operation. Valid values for $filter are: 'atExactScope()', 'policyType -eq {value}' or 'category eq '{value}''. If $filter is not @@ -3972,44 +4069,45 @@ def list_by_management_group( :param top: Maximum number of records to return. When the $top filter is not provided, it will return 500 records. Default value is None. :type top: int - :keyword api_version: Api Version. Default value is "2020-09-01". Note that overriding this - default value may result in unsupported behavior. - :paramtype api_version: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either PolicySetDefinitionListResult or the result of - cls(response) + :return: An iterator like instance of either PolicySetDefinition or the result of cls(response) :rtype: - ~azure.core.paging.ItemPaged[~azure.mgmt.resource.policy.v2020_09_01.models.PolicySetDefinitionListResult] - :raises: ~azure.core.exceptions.HttpResponseError + ~azure.core.paging.ItemPaged[~azure.mgmt.resource.policy.v2020_09_01.models.PolicySetDefinition] + :raises ~azure.core.exceptions.HttpResponseError: """ - api_version = kwargs.pop('api_version', "2020-09-01") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2020-09-01")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[_models.PolicySetDefinitionListResult] - cls = kwargs.pop('cls', None) # type: ClsType["_models.PolicySetDefinitionListResult"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) + def prepare_request(next_link=None): if not next_link: - + request = build_policy_set_definitions_list_by_management_group_request( management_group_id=management_group_id, - api_version=api_version, filter=filter, top=top, - template_url=self.list_by_management_group.metadata['url'], + api_version=api_version, + template_url=self.list_by_management_group.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore else: - - request = build_policy_set_definitions_list_by_management_group_request( - management_group_id=management_group_id, - template_url=next_link, - ) + request = HttpRequest("GET", next_link) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore request.method = "GET" return request @@ -4023,10 +4121,8 @@ def extract_data(pipeline_response): def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) response = pipeline_response.http_response @@ -4036,39 +4132,33 @@ def get_next(next_link=None): return pipeline_response + return ItemPaged(get_next, extract_data) - return ItemPaged( - get_next, extract_data - ) - list_by_management_group.metadata = {'url': "/providers/Microsoft.Management/managementGroups/{managementGroupId}/providers/Microsoft.Authorization/policySetDefinitions"} # type: ignore -class PolicyExemptionsOperations(object): - """PolicyExemptionsOperations operations. - - You should not instantiate this class directly. Instead, you should create a Client instance that - instantiates it for you and attaches it as an attribute. - - :ivar models: Alias to model classes used in this operation group. - :type models: ~azure.mgmt.resource.policy.v2020_09_01.models - :param client: Client for service requests. - :param config: Configuration of service client. - :param serializer: An object model serializer. - :param deserializer: An object model deserializer. + list_by_management_group.metadata = {"url": "/providers/Microsoft.Management/managementGroups/{managementGroupId}/providers/Microsoft.Authorization/policySetDefinitions"} # type: ignore + + +class PolicyExemptionsOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. + + Instead, you should access the following operations through + :class:`~azure.mgmt.resource.policy.v2020_09_01.PolicyClient`'s + :attr:`policy_exemptions` attribute. """ models = _models - def __init__(self, client, config, serializer, deserializer): - self._client = client - self._serialize = serializer - self._deserialize = deserializer - self._config = config + def __init__(self, *args, **kwargs): + input_args = list(args) + self._client = input_args.pop(0) if input_args else kwargs.pop("client") + self._config = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") @distributed_trace def delete( # pylint: disable=inconsistent-return-statements - self, - scope: str, - policy_exemption_name: str, - **kwargs: Any + self, scope: str, policy_exemption_name: str, **kwargs: Any ) -> None: """Deletes a policy exemption. @@ -4081,40 +4171,44 @@ def delete( # pylint: disable=inconsistent-return-statements '/subscriptions/{subscriptionId}'), resource group (format: '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}', or resource (format: '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{resourceProviderNamespace}/[{parentResourcePath}/]{resourceType}/{resourceName}'. + Required. :type scope: str - :param policy_exemption_name: The name of the policy exemption to delete. + :param policy_exemption_name: The name of the policy exemption to delete. Required. :type policy_exemption_name: str - :keyword api_version: Api Version. Default value is "2020-07-01-preview". Note that overriding - this default value may result in unsupported behavior. - :paramtype api_version: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: None, or the result of cls(response) + :return: None or the result of cls(response) :rtype: None - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType[None] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + 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', "2020-07-01-preview") # type: str + api_version = kwargs.pop("api_version", _params.pop("api-version", "2020-07-01-preview")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[None] - request = build_policy_exemptions_delete_request( scope=scope, policy_exemption_name=policy_exemption_name, api_version=api_version, - template_url=self.delete.metadata['url'], + template_url=self.delete.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200, 204]: @@ -4124,17 +4218,18 @@ def delete( # pylint: disable=inconsistent-return-statements if cls: return cls(pipeline_response, None, {}) - delete.metadata = {'url': "/{scope}/providers/Microsoft.Authorization/policyExemptions/{policyExemptionName}"} # type: ignore - + delete.metadata = {"url": "/{scope}/providers/Microsoft.Authorization/policyExemptions/{policyExemptionName}"} # type: ignore - @distributed_trace + @overload def create_or_update( self, scope: str, policy_exemption_name: str, - parameters: "_models.PolicyExemption", + parameters: _models.PolicyExemption, + *, + content_type: str = "application/json", **kwargs: Any - ) -> "_models.PolicyExemption": + ) -> _models.PolicyExemption: """Creates or updates a policy exemption. This operation creates or updates a policy exemption with the given scope and name. Policy @@ -4147,29 +4242,111 @@ def create_or_update( '/subscriptions/{subscriptionId}'), resource group (format: '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}', or resource (format: '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{resourceProviderNamespace}/[{parentResourcePath}/]{resourceType}/{resourceName}'. + Required. :type scope: str - :param policy_exemption_name: The name of the policy exemption to delete. + :param policy_exemption_name: The name of the policy exemption to delete. Required. :type policy_exemption_name: str - :param parameters: Parameters for the policy exemption. + :param parameters: Parameters for the policy exemption. Required. :type parameters: ~azure.mgmt.resource.policy.v2020_09_01.models.PolicyExemption - :keyword api_version: Api Version. Default value is "2020-07-01-preview". Note that overriding - this default value may result in unsupported behavior. - :paramtype api_version: str + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: PolicyExemption or the result of cls(response) + :rtype: ~azure.mgmt.resource.policy.v2020_09_01.models.PolicyExemption + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + def create_or_update( + self, + scope: str, + policy_exemption_name: str, + parameters: IO, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.PolicyExemption: + """Creates or updates a policy exemption. + + This operation creates or updates a policy exemption with the given scope and name. Policy + exemptions apply to all resources contained within their scope. For example, when you create a + policy exemption at resource group scope for a policy assignment at the same or above level, + the exemption exempts to all applicable resources in the resource group. + + :param scope: The scope of the policy exemption. Valid scopes are: management group (format: + '/providers/Microsoft.Management/managementGroups/{managementGroup}'), subscription (format: + '/subscriptions/{subscriptionId}'), resource group (format: + '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}', or resource (format: + '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{resourceProviderNamespace}/[{parentResourcePath}/]{resourceType}/{resourceName}'. + Required. + :type scope: str + :param policy_exemption_name: The name of the policy exemption to delete. Required. + :type policy_exemption_name: str + :param parameters: Parameters for the policy exemption. Required. + :type parameters: IO + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: PolicyExemption or the result of cls(response) + :rtype: ~azure.mgmt.resource.policy.v2020_09_01.models.PolicyExemption + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace + def create_or_update( + self, scope: str, policy_exemption_name: str, parameters: Union[_models.PolicyExemption, IO], **kwargs: Any + ) -> _models.PolicyExemption: + """Creates or updates a policy exemption. + + This operation creates or updates a policy exemption with the given scope and name. Policy + exemptions apply to all resources contained within their scope. For example, when you create a + policy exemption at resource group scope for a policy assignment at the same or above level, + the exemption exempts to all applicable resources in the resource group. + + :param scope: The scope of the policy exemption. Valid scopes are: management group (format: + '/providers/Microsoft.Management/managementGroups/{managementGroup}'), subscription (format: + '/subscriptions/{subscriptionId}'), resource group (format: + '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}', or resource (format: + '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{resourceProviderNamespace}/[{parentResourcePath}/]{resourceType}/{resourceName}'. + Required. + :type scope: str + :param policy_exemption_name: The name of the policy exemption to delete. Required. + :type policy_exemption_name: str + :param parameters: Parameters for the policy exemption. Is either a model type or a IO type. + Required. + :type parameters: ~azure.mgmt.resource.policy.v2020_09_01.models.PolicyExemption or IO + :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. + Default value is None. + :paramtype content_type: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: PolicyExemption, or the result of cls(response) + :return: PolicyExemption or the result of cls(response) :rtype: ~azure.mgmt.resource.policy.v2020_09_01.models.PolicyExemption - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.PolicyExemption"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) - api_version = kwargs.pop('api_version', "2020-07-01-preview") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - _json = self._serialize.body(parameters, 'PolicyExemption') + api_version = kwargs.pop("api_version", _params.pop("api-version", "2020-07-01-preview")) # type: str + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.PolicyExemption] + + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(parameters, (IO, bytes)): + _content = parameters + else: + _json = self._serialize.body(parameters, "PolicyExemption") request = build_policy_exemptions_create_or_update_request( scope=scope, @@ -4177,16 +4354,18 @@ def create_or_update( api_version=api_version, content_type=content_type, json=_json, - template_url=self.create_or_update.metadata['url'], + content=_content, + template_url=self.create_or_update.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200, 201]: @@ -4194,26 +4373,20 @@ def create_or_update( raise HttpResponseError(response=response, error_format=ARMErrorFormat) if response.status_code == 200: - deserialized = self._deserialize('PolicyExemption', pipeline_response) + deserialized = self._deserialize("PolicyExemption", pipeline_response) if response.status_code == 201: - deserialized = self._deserialize('PolicyExemption', pipeline_response) + deserialized = self._deserialize("PolicyExemption", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - create_or_update.metadata = {'url': "/{scope}/providers/Microsoft.Authorization/policyExemptions/{policyExemptionName}"} # type: ignore - + create_or_update.metadata = {"url": "/{scope}/providers/Microsoft.Authorization/policyExemptions/{policyExemptionName}"} # type: ignore @distributed_trace - def get( - self, - scope: str, - policy_exemption_name: str, - **kwargs: Any - ) -> "_models.PolicyExemption": + def get(self, scope: str, policy_exemption_name: str, **kwargs: Any) -> _models.PolicyExemption: """Retrieves a policy exemption. This operation retrieves a single policy exemption, given its name and the scope it was created @@ -4224,62 +4397,61 @@ def get( '/subscriptions/{subscriptionId}'), resource group (format: '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}', or resource (format: '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{resourceProviderNamespace}/[{parentResourcePath}/]{resourceType}/{resourceName}'. + Required. :type scope: str - :param policy_exemption_name: The name of the policy exemption to delete. + :param policy_exemption_name: The name of the policy exemption to delete. Required. :type policy_exemption_name: str - :keyword api_version: Api Version. Default value is "2020-07-01-preview". Note that overriding - this default value may result in unsupported behavior. - :paramtype api_version: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: PolicyExemption, or the result of cls(response) + :return: PolicyExemption or the result of cls(response) :rtype: ~azure.mgmt.resource.policy.v2020_09_01.models.PolicyExemption - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.PolicyExemption"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + 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', "2020-07-01-preview") # type: str + api_version = kwargs.pop("api_version", _params.pop("api-version", "2020-07-01-preview")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[_models.PolicyExemption] - request = build_policy_exemptions_get_request( scope=scope, policy_exemption_name=policy_exemption_name, api_version=api_version, - template_url=self.get.metadata['url'], + template_url=self.get.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) - deserialized = self._deserialize('PolicyExemption', pipeline_response) + deserialized = self._deserialize("PolicyExemption", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - get.metadata = {'url': "/{scope}/providers/Microsoft.Authorization/policyExemptions/{policyExemptionName}"} # type: ignore - + get.metadata = {"url": "/{scope}/providers/Microsoft.Authorization/policyExemptions/{policyExemptionName}"} # type: ignore @distributed_trace - def list( - self, - filter: Optional[str] = None, - **kwargs: Any - ) -> Iterable["_models.PolicyExemptionListResult"]: + def list(self, filter: Optional[str] = None, **kwargs: Any) -> Iterable["_models.PolicyExemption"]: """Retrieves all policy exemptions that apply to a subscription. This operation retrieves the list of all policy exemptions associated with the given @@ -4302,43 +4474,44 @@ def list( '{value}' is provided. the returned list only includes all policy exemptions that are associated with the give policyAssignmentId. Default value is None. :type filter: str - :keyword api_version: Api Version. Default value is "2020-07-01-preview". Note that overriding - this default value may result in unsupported behavior. - :paramtype api_version: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either PolicyExemptionListResult or the result of - cls(response) + :return: An iterator like instance of either PolicyExemption or the result of cls(response) :rtype: - ~azure.core.paging.ItemPaged[~azure.mgmt.resource.policy.v2020_09_01.models.PolicyExemptionListResult] - :raises: ~azure.core.exceptions.HttpResponseError + ~azure.core.paging.ItemPaged[~azure.mgmt.resource.policy.v2020_09_01.models.PolicyExemption] + :raises ~azure.core.exceptions.HttpResponseError: """ - api_version = kwargs.pop('api_version', "2020-07-01-preview") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2020-07-01-preview")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[_models.PolicyExemptionListResult] - cls = kwargs.pop('cls', None) # type: ClsType["_models.PolicyExemptionListResult"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) + def prepare_request(next_link=None): if not next_link: - + request = build_policy_exemptions_list_request( subscription_id=self._config.subscription_id, - api_version=api_version, filter=filter, - template_url=self.list.metadata['url'], + 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.url = self._client.format_url(request.url) # type: ignore else: - - request = build_policy_exemptions_list_request( - subscription_id=self._config.subscription_id, - template_url=next_link, - ) + request = HttpRequest("GET", next_link) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore request.method = "GET" return request @@ -4352,10 +4525,8 @@ def extract_data(pipeline_response): def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) response = pipeline_response.http_response @@ -4365,19 +4536,14 @@ def get_next(next_link=None): return pipeline_response + return ItemPaged(get_next, extract_data) - return ItemPaged( - get_next, extract_data - ) - list.metadata = {'url': "/subscriptions/{subscriptionId}/providers/Microsoft.Authorization/policyExemptions"} # type: ignore + list.metadata = {"url": "/subscriptions/{subscriptionId}/providers/Microsoft.Authorization/policyExemptions"} # type: ignore @distributed_trace def list_for_resource_group( - self, - resource_group_name: str, - filter: Optional[str] = None, - **kwargs: Any - ) -> Iterable["_models.PolicyExemptionListResult"]: + self, resource_group_name: str, filter: Optional[str] = None, **kwargs: Any + ) -> Iterable["_models.PolicyExemption"]: """Retrieves all policy exemptions that apply to a resource group. This operation retrieves the list of all policy exemptions associated with the given resource @@ -4387,7 +4553,7 @@ def list_for_resource_group( resource group, including those that apply directly or apply from containing scopes, as well as any applied to resources contained within the resource group. - :param resource_group_name: The name of the resource group containing the resource. + :param resource_group_name: The name of the resource group containing the resource. Required. :type resource_group_name: str :param filter: The filter to apply on the operation. Valid values for $filter are: 'atScope()', 'atExactScope()', 'excludeExpired()' or 'policyAssignmentId eq '{value}''. If $filter is not @@ -4402,45 +4568,45 @@ def list_for_resource_group( '{value}' is provided. the returned list only includes all policy exemptions that are associated with the give policyAssignmentId. Default value is None. :type filter: str - :keyword api_version: Api Version. Default value is "2020-07-01-preview". Note that overriding - this default value may result in unsupported behavior. - :paramtype api_version: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either PolicyExemptionListResult or the result of - cls(response) + :return: An iterator like instance of either PolicyExemption or the result of cls(response) :rtype: - ~azure.core.paging.ItemPaged[~azure.mgmt.resource.policy.v2020_09_01.models.PolicyExemptionListResult] - :raises: ~azure.core.exceptions.HttpResponseError + ~azure.core.paging.ItemPaged[~azure.mgmt.resource.policy.v2020_09_01.models.PolicyExemption] + :raises ~azure.core.exceptions.HttpResponseError: """ - api_version = kwargs.pop('api_version', "2020-07-01-preview") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2020-07-01-preview")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[_models.PolicyExemptionListResult] - cls = kwargs.pop('cls', None) # type: ClsType["_models.PolicyExemptionListResult"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) + def prepare_request(next_link=None): if not next_link: - + request = build_policy_exemptions_list_for_resource_group_request( - subscription_id=self._config.subscription_id, resource_group_name=resource_group_name, - api_version=api_version, + subscription_id=self._config.subscription_id, filter=filter, - template_url=self.list_for_resource_group.metadata['url'], + api_version=api_version, + template_url=self.list_for_resource_group.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore else: - - request = build_policy_exemptions_list_for_resource_group_request( - subscription_id=self._config.subscription_id, - resource_group_name=resource_group_name, - template_url=next_link, - ) + request = HttpRequest("GET", next_link) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore request.method = "GET" return request @@ -4454,10 +4620,8 @@ def extract_data(pipeline_response): def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) response = pipeline_response.http_response @@ -4467,11 +4631,9 @@ def get_next(next_link=None): return pipeline_response + return ItemPaged(get_next, extract_data) - return ItemPaged( - get_next, extract_data - ) - list_for_resource_group.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Authorization/policyExemptions"} # type: ignore + list_for_resource_group.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Authorization/policyExemptions"} # type: ignore @distributed_trace def list_for_resource( @@ -4483,7 +4645,7 @@ def list_for_resource( resource_name: str, filter: Optional[str] = None, **kwargs: Any - ) -> Iterable["_models.PolicyExemptionListResult"]: + ) -> Iterable["_models.PolicyExemption"]: """Retrieves all policy exemptions that apply to a resource. This operation retrieves the list of all policy exemptions associated with the specified @@ -4505,17 +4667,19 @@ def list_for_resource( {parentResourcePath} == '', {resourceType} == 'Microsoft.Web/sites', {resourceName} == 'MyWebApp'). - :param resource_group_name: The name of the resource group containing the resource. + :param resource_group_name: The name of the resource group containing the resource. Required. :type resource_group_name: str :param resource_provider_namespace: The namespace of the resource provider. For example, the namespace of a virtual machine is Microsoft.Compute (from Microsoft.Compute/virtualMachines). + Required. :type resource_provider_namespace: str :param parent_resource_path: The parent resource path. Use empty string if there is none. + Required. :type parent_resource_path: str :param resource_type: The resource type name. For example the type name of a web app is 'sites' - (from Microsoft.Web/sites). + (from Microsoft.Web/sites). Required. :type resource_type: str - :param resource_name: The name of the resource. + :param resource_name: The name of the resource. Required. :type resource_name: str :param filter: The filter to apply on the operation. Valid values for $filter are: 'atScope()', 'atExactScope()', 'excludeExpired()' or 'policyAssignmentId eq '{value}''. If $filter is not @@ -4530,53 +4694,49 @@ def list_for_resource( '{value}' is provided. the returned list only includes all policy exemptions that are associated with the give policyAssignmentId. Default value is None. :type filter: str - :keyword api_version: Api Version. Default value is "2020-07-01-preview". Note that overriding - this default value may result in unsupported behavior. - :paramtype api_version: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either PolicyExemptionListResult or the result of - cls(response) + :return: An iterator like instance of either PolicyExemption or the result of cls(response) :rtype: - ~azure.core.paging.ItemPaged[~azure.mgmt.resource.policy.v2020_09_01.models.PolicyExemptionListResult] - :raises: ~azure.core.exceptions.HttpResponseError + ~azure.core.paging.ItemPaged[~azure.mgmt.resource.policy.v2020_09_01.models.PolicyExemption] + :raises ~azure.core.exceptions.HttpResponseError: """ - api_version = kwargs.pop('api_version', "2020-07-01-preview") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2020-07-01-preview")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[_models.PolicyExemptionListResult] - cls = kwargs.pop('cls', None) # type: ClsType["_models.PolicyExemptionListResult"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) + def prepare_request(next_link=None): if not next_link: - + request = build_policy_exemptions_list_for_resource_request( - subscription_id=self._config.subscription_id, resource_group_name=resource_group_name, resource_provider_namespace=resource_provider_namespace, parent_resource_path=parent_resource_path, resource_type=resource_type, resource_name=resource_name, - api_version=api_version, + subscription_id=self._config.subscription_id, filter=filter, - template_url=self.list_for_resource.metadata['url'], + api_version=api_version, + template_url=self.list_for_resource.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore else: - - request = build_policy_exemptions_list_for_resource_request( - subscription_id=self._config.subscription_id, - resource_group_name=resource_group_name, - resource_provider_namespace=resource_provider_namespace, - parent_resource_path=parent_resource_path, - resource_type=resource_type, - resource_name=resource_name, - template_url=next_link, - ) + request = HttpRequest("GET", next_link) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore request.method = "GET" return request @@ -4590,10 +4750,8 @@ def extract_data(pipeline_response): def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) response = pipeline_response.http_response @@ -4603,19 +4761,14 @@ def get_next(next_link=None): return pipeline_response + return ItemPaged(get_next, extract_data) - return ItemPaged( - get_next, extract_data - ) - list_for_resource.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{parentResourcePath}/{resourceType}/{resourceName}/providers/Microsoft.Authorization/policyExemptions"} # type: ignore + list_for_resource.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{parentResourcePath}/{resourceType}/{resourceName}/providers/Microsoft.Authorization/policyExemptions"} # type: ignore @distributed_trace def list_for_management_group( - self, - management_group_id: str, - filter: Optional[str] = None, - **kwargs: Any - ) -> Iterable["_models.PolicyExemptionListResult"]: + self, management_group_id: str, filter: Optional[str] = None, **kwargs: Any + ) -> Iterable["_models.PolicyExemption"]: """Retrieves all policy exemptions that apply to a management group. This operation retrieves the list of all policy exemptions applicable to the management group @@ -4624,7 +4777,7 @@ def list_for_management_group( returned list includes all policy exemptions that are assigned to the management group or the management group's ancestors. - :param management_group_id: The ID of the management group. + :param management_group_id: The ID of the management group. Required. :type management_group_id: str :param filter: The filter to apply on the operation. Valid values for $filter are: 'atScope()', 'atExactScope()', 'excludeExpired()' or 'policyAssignmentId eq '{value}''. If $filter is not @@ -4639,43 +4792,44 @@ def list_for_management_group( '{value}' is provided. the returned list only includes all policy exemptions that are associated with the give policyAssignmentId. Default value is None. :type filter: str - :keyword api_version: Api Version. Default value is "2020-07-01-preview". Note that overriding - this default value may result in unsupported behavior. - :paramtype api_version: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either PolicyExemptionListResult or the result of - cls(response) + :return: An iterator like instance of either PolicyExemption or the result of cls(response) :rtype: - ~azure.core.paging.ItemPaged[~azure.mgmt.resource.policy.v2020_09_01.models.PolicyExemptionListResult] - :raises: ~azure.core.exceptions.HttpResponseError + ~azure.core.paging.ItemPaged[~azure.mgmt.resource.policy.v2020_09_01.models.PolicyExemption] + :raises ~azure.core.exceptions.HttpResponseError: """ - api_version = kwargs.pop('api_version', "2020-07-01-preview") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2020-07-01-preview")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[_models.PolicyExemptionListResult] - cls = kwargs.pop('cls', None) # type: ClsType["_models.PolicyExemptionListResult"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) + def prepare_request(next_link=None): if not next_link: - + request = build_policy_exemptions_list_for_management_group_request( management_group_id=management_group_id, - api_version=api_version, filter=filter, - template_url=self.list_for_management_group.metadata['url'], + api_version=api_version, + template_url=self.list_for_management_group.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore else: - - request = build_policy_exemptions_list_for_management_group_request( - management_group_id=management_group_id, - template_url=next_link, - ) + request = HttpRequest("GET", next_link) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore request.method = "GET" return request @@ -4689,10 +4843,8 @@ def extract_data(pipeline_response): def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) response = pipeline_response.http_response @@ -4702,8 +4854,6 @@ def get_next(next_link=None): return pipeline_response + return ItemPaged(get_next, extract_data) - return ItemPaged( - get_next, extract_data - ) - list_for_management_group.metadata = {'url': "/providers/Microsoft.Management/managementGroups/{managementGroupId}/providers/Microsoft.Authorization/policyExemptions"} # type: ignore + list_for_management_group.metadata = {"url": "/providers/Microsoft.Management/managementGroups/{managementGroupId}/providers/Microsoft.Authorization/policyExemptions"} # type: ignore diff --git a/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/policy/v2020_09_01/operations/_patch.py b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/policy/v2020_09_01/operations/_patch.py new file mode 100644 index 0000000000000..f7dd32510333d --- /dev/null +++ b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/policy/v2020_09_01/operations/_patch.py @@ -0,0 +1,20 @@ +# ------------------------------------ +# Copyright (c) Microsoft Corporation. +# Licensed under the MIT License. +# ------------------------------------ +"""Customize generated code here. + +Follow our quickstart for examples: https://aka.ms/azsdk/python/dpcodegen/python/customize +""" +from typing import List + +__all__: List[str] = [] # Add all objects you want publicly available to users at this package level + + +def patch_sdk(): + """Do not remove from this file. + + `patch_sdk` is a last resort escape hatch that allows you to do customizations + you can't accomplish using the techniques described in + https://aka.ms/azsdk/python/dpcodegen/python/customize + """ diff --git a/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/policy/v2021_06_01/__init__.py b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/policy/v2021_06_01/__init__.py index 89180ab440872..bb1ffe59afae7 100644 --- a/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/policy/v2021_06_01/__init__.py +++ b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/policy/v2021_06_01/__init__.py @@ -10,9 +10,15 @@ from ._version import VERSION __version__ = VERSION -__all__ = ['PolicyClient'] -# `._patch.py` is used for handwritten extensions to the generated code -# Example: https://github.com/Azure/azure-sdk-for-python/blob/main/doc/dev/customize_code/how-to-patch-sdk-code.md -from ._patch import patch_sdk -patch_sdk() +try: + from ._patch import __all__ as _patch_all + from ._patch import * # type: ignore # pylint: disable=unused-wildcard-import +except ImportError: + _patch_all = [] +from ._patch import patch_sdk as _patch_sdk + +__all__ = ["PolicyClient"] +__all__.extend([p for p in _patch_all if p not in __all__]) + +_patch_sdk() diff --git a/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/policy/v2021_06_01/_configuration.py b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/policy/v2021_06_01/_configuration.py index 4c2ba31e56c60..c6a430f1f8bdc 100644 --- a/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/policy/v2021_06_01/_configuration.py +++ b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/policy/v2021_06_01/_configuration.py @@ -25,18 +25,13 @@ class PolicyClientConfiguration(Configuration): # pylint: disable=too-many-inst Note that all parameters used to create this instance are saved as instance attributes. - :param credential: Credential needed for the client to connect to Azure. + :param credential: Credential needed for the client to connect to Azure. Required. :type credential: ~azure.core.credentials.TokenCredential - :param subscription_id: The ID of the target subscription. + :param subscription_id: The ID of the target subscription. Required. :type subscription_id: str """ - def __init__( - self, - credential: "TokenCredential", - subscription_id: str, - **kwargs: Any - ) -> None: + def __init__(self, credential: "TokenCredential", subscription_id: str, **kwargs: Any) -> None: super(PolicyClientConfiguration, self).__init__(**kwargs) if credential is None: raise ValueError("Parameter 'credential' must not be None.") @@ -45,23 +40,24 @@ def __init__( self.credential = credential self.subscription_id = subscription_id - self.credential_scopes = kwargs.pop('credential_scopes', ['https://management.azure.com/.default']) - kwargs.setdefault('sdk_moniker', 'mgmt-resource/{}'.format(VERSION)) + self.credential_scopes = kwargs.pop("credential_scopes", ["https://management.azure.com/.default"]) + kwargs.setdefault("sdk_moniker", "mgmt-resource/{}".format(VERSION)) self._configure(**kwargs) def _configure( - self, - **kwargs # type: Any + self, **kwargs # type: Any ): # type: (...) -> 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) - self.logging_policy = kwargs.get('logging_policy') or policies.NetworkTraceLoggingPolicy(**kwargs) - self.http_logging_policy = kwargs.get('http_logging_policy') or ARMHttpLoggingPolicy(**kwargs) - self.retry_policy = kwargs.get('retry_policy') or policies.RetryPolicy(**kwargs) - self.custom_hook_policy = kwargs.get('custom_hook_policy') or policies.CustomHookPolicy(**kwargs) - self.redirect_policy = kwargs.get('redirect_policy') or policies.RedirectPolicy(**kwargs) - self.authentication_policy = kwargs.get('authentication_policy') + 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) + self.logging_policy = kwargs.get("logging_policy") or policies.NetworkTraceLoggingPolicy(**kwargs) + self.http_logging_policy = kwargs.get("http_logging_policy") or ARMHttpLoggingPolicy(**kwargs) + self.retry_policy = kwargs.get("retry_policy") or policies.RetryPolicy(**kwargs) + self.custom_hook_policy = kwargs.get("custom_hook_policy") or policies.CustomHookPolicy(**kwargs) + self.redirect_policy = kwargs.get("redirect_policy") or policies.RedirectPolicy(**kwargs) + self.authentication_policy = kwargs.get("authentication_policy") if self.credential and not self.authentication_policy: - self.authentication_policy = ARMChallengeAuthenticationPolicy(self.credential, *self.credential_scopes, **kwargs) + self.authentication_policy = ARMChallengeAuthenticationPolicy( + self.credential, *self.credential_scopes, **kwargs + ) diff --git a/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/policy/v2021_06_01/_metadata.json b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/policy/v2021_06_01/_metadata.json index 6037599e101be..cd635bb190435 100644 --- a/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/policy/v2021_06_01/_metadata.json +++ b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/policy/v2021_06_01/_metadata.json @@ -1,6 +1,6 @@ { "chosen_version": "2021-06-01", - "total_api_version_list": ["2020-07-01-preview", "2020-09-01", "2021-06-01"], + "total_api_version_list": ["2020-07-01-preview", "2020-09-01", "2021-06-01", "2022-08-01-preview"], "client": { "name": "PolicyClient", "filename": "_policy_client", @@ -10,20 +10,20 @@ "azure_arm": true, "has_lro_operations": false, "client_side_validation": false, - "sync_imports": "{\"typing\": {\"azurecore\": {\"azure.core.credentials\": [\"TokenCredential\"]}}, \"regular\": {\"azurecore\": {\"azure.profiles\": [\"KnownProfiles\", \"ProfileDefinition\"], \"azure.profiles.multiapiclient\": [\"MultiApiClientMixin\"], \"azure.mgmt.core\": [\"ARMPipelineClient\"]}, \"local\": {\"._configuration\": [\"PolicyClientConfiguration\"]}, \"thirdparty\": {\"msrest\": [\"Deserializer\", \"Serializer\"]}}, \"conditional\": {\"stdlib\": {\"typing\": [\"Any\", \"Optional\"]}}}", - "async_imports": "{\"typing\": {\"azurecore\": {\"azure.core.credentials_async\": [\"AsyncTokenCredential\"], \"azure.core.credentials\": [\"TokenCredential\"]}}, \"regular\": {\"azurecore\": {\"azure.profiles\": [\"KnownProfiles\", \"ProfileDefinition\"], \"azure.profiles.multiapiclient\": [\"MultiApiClientMixin\"], \"azure.mgmt.core\": [\"AsyncARMPipelineClient\"]}, \"local\": {\"._configuration\": [\"PolicyClientConfiguration\"]}, \"thirdparty\": {\"msrest\": [\"Deserializer\", \"Serializer\"]}}, \"conditional\": {\"stdlib\": {\"typing\": [\"Any\", \"Optional\"]}}}" + "sync_imports": "{\"conditional\": {\"stdlib\": {\"typing\": [\"Any\", \"Optional\"]}}, \"regular\": {\"azurecore\": {\"azure.mgmt.core\": [\"ARMPipelineClient\"], \"azure.profiles\": [\"KnownProfiles\", \"ProfileDefinition\"], \"azure.profiles.multiapiclient\": [\"MultiApiClientMixin\"]}, \"local\": {\"._configuration\": [\"PolicyClientConfiguration\"], \".._serialization\": [\"Deserializer\", \"Serializer\"]}}, \"typing\": {\"azurecore\": {\"azure.core.credentials\": [\"TokenCredential\"]}}}", + "async_imports": "{\"conditional\": {\"stdlib\": {\"typing\": [\"Any\", \"Optional\"]}}, \"regular\": {\"azurecore\": {\"azure.mgmt.core\": [\"AsyncARMPipelineClient\"], \"azure.profiles\": [\"KnownProfiles\", \"ProfileDefinition\"], \"azure.profiles.multiapiclient\": [\"MultiApiClientMixin\"]}, \"local\": {\"._configuration\": [\"PolicyClientConfiguration\"], \"..._serialization\": [\"Deserializer\", \"Serializer\"]}}, \"typing\": {\"azurecore\": {\"azure.core.credentials_async\": [\"AsyncTokenCredential\"]}}}" }, "global_parameters": { "sync": { "credential": { - "signature": "credential, # type: \"TokenCredential\"", - "description": "Credential needed for the client to connect to Azure.", + "signature": "credential: \"TokenCredential\",", + "description": "Credential needed for the client to connect to Azure. Required.", "docstring_type": "~azure.core.credentials.TokenCredential", "required": true }, "subscription_id": { - "signature": "subscription_id, # type: str", - "description": "The ID of the target subscription.", + "signature": "subscription_id: str,", + "description": "The ID of the target subscription. Required.", "docstring_type": "str", "required": true } @@ -31,13 +31,13 @@ "async": { "credential": { "signature": "credential: \"AsyncTokenCredential\",", - "description": "Credential needed for the client to connect to Azure.", + "description": "Credential needed for the client to connect to Azure. Required.", "docstring_type": "~azure.core.credentials_async.AsyncTokenCredential", "required": true }, "subscription_id": { "signature": "subscription_id: str,", - "description": "The ID of the target subscription.", + "description": "The ID of the target subscription. Required.", "docstring_type": "str", "required": true } @@ -54,7 +54,7 @@ "required": false }, "base_url": { - "signature": "base_url=\"https://management.azure.com\", # type: str", + "signature": "base_url: str = \"https://management.azure.com\",", "description": "Service URL", "docstring_type": "str", "required": false @@ -101,6 +101,8 @@ "policy_assignments": "PolicyAssignmentsOperations", "policy_definitions": "PolicyDefinitionsOperations", "policy_set_definitions": "PolicySetDefinitionsOperations", - "policy_exemptions": "PolicyExemptionsOperations" + "policy_exemptions": "PolicyExemptionsOperations", + "variables": "VariablesOperations", + "variable_values": "VariableValuesOperations" } } \ No newline at end of file diff --git a/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/policy/v2021_06_01/_patch.py b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/policy/v2021_06_01/_patch.py index 74e48ecd07cf3..f99e77fef9861 100644 --- a/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/policy/v2021_06_01/_patch.py +++ b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/policy/v2021_06_01/_patch.py @@ -28,4 +28,4 @@ # This file is used for handwritten extensions to the generated code. Example: # https://github.com/Azure/azure-sdk-for-python/blob/main/doc/dev/customize_code/how-to-patch-sdk-code.md def patch_sdk(): - pass \ No newline at end of file + pass diff --git a/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/policy/v2021_06_01/_policy_client.py b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/policy/v2021_06_01/_policy_client.py index 394a2a9935b21..71eed95ac0e06 100644 --- a/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/policy/v2021_06_01/_policy_client.py +++ b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/policy/v2021_06_01/_policy_client.py @@ -9,20 +9,28 @@ from copy import deepcopy from typing import Any, TYPE_CHECKING -from msrest import Deserializer, Serializer - from azure.core.rest import HttpRequest, HttpResponse from azure.mgmt.core import ARMPipelineClient from . import models +from .._serialization import Deserializer, Serializer from ._configuration import PolicyClientConfiguration -from .operations import DataPolicyManifestsOperations, PolicyAssignmentsOperations, PolicyDefinitionsOperations, PolicyExemptionsOperations, PolicySetDefinitionsOperations +from .operations import ( + DataPolicyManifestsOperations, + PolicyAssignmentsOperations, + PolicyDefinitionsOperations, + PolicyExemptionsOperations, + PolicySetDefinitionsOperations, + VariableValuesOperations, + VariablesOperations, +) if TYPE_CHECKING: # pylint: disable=unused-import,ungrouped-imports from azure.core.credentials import TokenCredential -class PolicyClient: + +class PolicyClient: # pylint: disable=client-accepts-api-version-keyword,too-many-instance-attributes """To manage and control access to your resources, you can define customized policies and assign them at a scope. @@ -41,9 +49,14 @@ class PolicyClient: :ivar policy_exemptions: PolicyExemptionsOperations operations :vartype policy_exemptions: azure.mgmt.resource.policy.v2021_06_01.operations.PolicyExemptionsOperations - :param credential: Credential needed for the client to connect to Azure. + :ivar variables: VariablesOperations operations + :vartype variables: azure.mgmt.resource.policy.v2021_06_01.operations.VariablesOperations + :ivar variable_values: VariableValuesOperations operations + :vartype variable_values: + azure.mgmt.resource.policy.v2021_06_01.operations.VariableValuesOperations + :param credential: Credential needed for the client to connect to Azure. Required. :type credential: ~azure.core.credentials.TokenCredential - :param subscription_id: The ID of the target subscription. + :param subscription_id: The ID of the target subscription. Required. :type subscription_id: str :param base_url: Service URL. Default value is "https://management.azure.com". :type base_url: str @@ -63,18 +76,25 @@ def __init__( self._serialize = Serializer(client_models) self._deserialize = Deserializer(client_models) self._serialize.client_side_validation = False - self.data_policy_manifests = DataPolicyManifestsOperations(self._client, self._config, self._serialize, self._deserialize) - self.policy_assignments = PolicyAssignmentsOperations(self._client, self._config, self._serialize, self._deserialize) - self.policy_definitions = PolicyDefinitionsOperations(self._client, self._config, self._serialize, self._deserialize) - self.policy_set_definitions = PolicySetDefinitionsOperations(self._client, self._config, self._serialize, self._deserialize) - self.policy_exemptions = PolicyExemptionsOperations(self._client, self._config, self._serialize, self._deserialize) - - - def _send_request( - self, - request: HttpRequest, - **kwargs: Any - ) -> HttpResponse: + self.data_policy_manifests = DataPolicyManifestsOperations( + self._client, self._config, self._serialize, self._deserialize + ) + self.policy_assignments = PolicyAssignmentsOperations( + self._client, self._config, self._serialize, self._deserialize + ) + self.policy_definitions = PolicyDefinitionsOperations( + self._client, self._config, self._serialize, self._deserialize + ) + self.policy_set_definitions = PolicySetDefinitionsOperations( + self._client, self._config, self._serialize, self._deserialize + ) + self.policy_exemptions = PolicyExemptionsOperations( + self._client, self._config, self._serialize, self._deserialize + ) + self.variables = VariablesOperations(self._client, self._config, self._serialize, self._deserialize) + self.variable_values = VariableValuesOperations(self._client, self._config, self._serialize, self._deserialize) + + def _send_request(self, request: HttpRequest, **kwargs: Any) -> HttpResponse: """Runs the network request through the client's chained policies. >>> from azure.core.rest import HttpRequest @@ -83,7 +103,7 @@ def _send_request( >>> response = client._send_request(request) - For more information on this code flow, see https://aka.ms/azsdk/python/protocol/quickstart + For more information on this code flow, see https://aka.ms/azsdk/dpcodegen/python/send_request :param request: The network request you want to make. Required. :type request: ~azure.core.rest.HttpRequest diff --git a/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/policy/v2021_06_01/_vendor.py b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/policy/v2021_06_01/_vendor.py index 138f663c53a4e..9aad73fc743e7 100644 --- a/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/policy/v2021_06_01/_vendor.py +++ b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/policy/v2021_06_01/_vendor.py @@ -7,6 +7,7 @@ from azure.core.pipeline.transport import HttpRequest + def _convert_request(request, files=None): data = request.content if not files else None request = HttpRequest(method=request.method, url=request.url, headers=request.headers, data=data) @@ -14,6 +15,7 @@ def _convert_request(request, files=None): request.set_formdata_body(files) return request + def _format_url_section(template, **kwargs): components = template.split("/") while components: @@ -21,7 +23,5 @@ def _format_url_section(template, **kwargs): 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 - ] + components = [c for c in formatted_components if "{}".format(key.args[0]) not in c] template = "/".join(components) diff --git a/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/policy/v2021_06_01/_version.py b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/policy/v2021_06_01/_version.py index a012ac01c480c..e5754a47ce68f 100644 --- a/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/policy/v2021_06_01/_version.py +++ b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/policy/v2021_06_01/_version.py @@ -6,4 +6,4 @@ # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -VERSION = "21.1.0" +VERSION = "1.0.0b1" diff --git a/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/policy/v2021_06_01/aio/__init__.py b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/policy/v2021_06_01/aio/__init__.py index 2784ce3f14bf5..4622bf1f396a7 100644 --- a/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/policy/v2021_06_01/aio/__init__.py +++ b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/policy/v2021_06_01/aio/__init__.py @@ -7,9 +7,15 @@ # -------------------------------------------------------------------------- from ._policy_client import PolicyClient -__all__ = ['PolicyClient'] -# `._patch.py` is used for handwritten extensions to the generated code -# Example: https://github.com/Azure/azure-sdk-for-python/blob/main/doc/dev/customize_code/how-to-patch-sdk-code.md -from ._patch import patch_sdk -patch_sdk() +try: + from ._patch import __all__ as _patch_all + from ._patch import * # type: ignore # pylint: disable=unused-wildcard-import +except ImportError: + _patch_all = [] +from ._patch import patch_sdk as _patch_sdk + +__all__ = ["PolicyClient"] +__all__.extend([p for p in _patch_all if p not in __all__]) + +_patch_sdk() diff --git a/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/policy/v2021_06_01/aio/_configuration.py b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/policy/v2021_06_01/aio/_configuration.py index 21e375a7dd621..c52b0ba98ee82 100644 --- a/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/policy/v2021_06_01/aio/_configuration.py +++ b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/policy/v2021_06_01/aio/_configuration.py @@ -25,18 +25,13 @@ class PolicyClientConfiguration(Configuration): # pylint: disable=too-many-inst Note that all parameters used to create this instance are saved as instance attributes. - :param credential: Credential needed for the client to connect to Azure. + :param credential: Credential needed for the client to connect to Azure. Required. :type credential: ~azure.core.credentials_async.AsyncTokenCredential - :param subscription_id: The ID of the target subscription. + :param subscription_id: The ID of the target subscription. Required. :type subscription_id: str """ - def __init__( - self, - credential: "AsyncTokenCredential", - subscription_id: str, - **kwargs: Any - ) -> None: + def __init__(self, credential: "AsyncTokenCredential", subscription_id: str, **kwargs: Any) -> None: super(PolicyClientConfiguration, self).__init__(**kwargs) if credential is None: raise ValueError("Parameter 'credential' must not be None.") @@ -45,22 +40,21 @@ def __init__( self.credential = credential self.subscription_id = subscription_id - self.credential_scopes = kwargs.pop('credential_scopes', ['https://management.azure.com/.default']) - kwargs.setdefault('sdk_moniker', 'mgmt-resource/{}'.format(VERSION)) + self.credential_scopes = kwargs.pop("credential_scopes", ["https://management.azure.com/.default"]) + kwargs.setdefault("sdk_moniker", "mgmt-resource/{}".format(VERSION)) self._configure(**kwargs) - 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) - self.logging_policy = kwargs.get('logging_policy') or policies.NetworkTraceLoggingPolicy(**kwargs) - self.http_logging_policy = kwargs.get('http_logging_policy') or ARMHttpLoggingPolicy(**kwargs) - self.retry_policy = kwargs.get('retry_policy') or policies.AsyncRetryPolicy(**kwargs) - self.custom_hook_policy = kwargs.get('custom_hook_policy') or policies.CustomHookPolicy(**kwargs) - self.redirect_policy = kwargs.get('redirect_policy') or policies.AsyncRedirectPolicy(**kwargs) - self.authentication_policy = kwargs.get('authentication_policy') + 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) + self.logging_policy = kwargs.get("logging_policy") or policies.NetworkTraceLoggingPolicy(**kwargs) + self.http_logging_policy = kwargs.get("http_logging_policy") or ARMHttpLoggingPolicy(**kwargs) + self.retry_policy = kwargs.get("retry_policy") or policies.AsyncRetryPolicy(**kwargs) + self.custom_hook_policy = kwargs.get("custom_hook_policy") or policies.CustomHookPolicy(**kwargs) + self.redirect_policy = kwargs.get("redirect_policy") or policies.AsyncRedirectPolicy(**kwargs) + self.authentication_policy = kwargs.get("authentication_policy") if self.credential and not self.authentication_policy: - self.authentication_policy = AsyncARMChallengeAuthenticationPolicy(self.credential, *self.credential_scopes, **kwargs) + self.authentication_policy = AsyncARMChallengeAuthenticationPolicy( + self.credential, *self.credential_scopes, **kwargs + ) diff --git a/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/policy/v2021_06_01/aio/_patch.py b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/policy/v2021_06_01/aio/_patch.py index 74e48ecd07cf3..f99e77fef9861 100644 --- a/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/policy/v2021_06_01/aio/_patch.py +++ b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/policy/v2021_06_01/aio/_patch.py @@ -28,4 +28,4 @@ # This file is used for handwritten extensions to the generated code. Example: # https://github.com/Azure/azure-sdk-for-python/blob/main/doc/dev/customize_code/how-to-patch-sdk-code.md def patch_sdk(): - pass \ No newline at end of file + pass diff --git a/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/policy/v2021_06_01/aio/_policy_client.py b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/policy/v2021_06_01/aio/_policy_client.py index a03b87bc12db6..d44f0dca76b93 100644 --- a/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/policy/v2021_06_01/aio/_policy_client.py +++ b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/policy/v2021_06_01/aio/_policy_client.py @@ -9,20 +9,28 @@ from copy import deepcopy from typing import Any, Awaitable, TYPE_CHECKING -from msrest import Deserializer, Serializer - from azure.core.rest import AsyncHttpResponse, HttpRequest from azure.mgmt.core import AsyncARMPipelineClient from .. import models +from ..._serialization import Deserializer, Serializer from ._configuration import PolicyClientConfiguration -from .operations import DataPolicyManifestsOperations, PolicyAssignmentsOperations, PolicyDefinitionsOperations, PolicyExemptionsOperations, PolicySetDefinitionsOperations +from .operations import ( + DataPolicyManifestsOperations, + PolicyAssignmentsOperations, + PolicyDefinitionsOperations, + PolicyExemptionsOperations, + PolicySetDefinitionsOperations, + VariableValuesOperations, + VariablesOperations, +) if TYPE_CHECKING: # pylint: disable=unused-import,ungrouped-imports from azure.core.credentials_async import AsyncTokenCredential -class PolicyClient: + +class PolicyClient: # pylint: disable=client-accepts-api-version-keyword,too-many-instance-attributes """To manage and control access to your resources, you can define customized policies and assign them at a scope. @@ -41,9 +49,14 @@ class PolicyClient: :ivar policy_exemptions: PolicyExemptionsOperations operations :vartype policy_exemptions: azure.mgmt.resource.policy.v2021_06_01.aio.operations.PolicyExemptionsOperations - :param credential: Credential needed for the client to connect to Azure. + :ivar variables: VariablesOperations operations + :vartype variables: azure.mgmt.resource.policy.v2021_06_01.aio.operations.VariablesOperations + :ivar variable_values: VariableValuesOperations operations + :vartype variable_values: + azure.mgmt.resource.policy.v2021_06_01.aio.operations.VariableValuesOperations + :param credential: Credential needed for the client to connect to Azure. Required. :type credential: ~azure.core.credentials_async.AsyncTokenCredential - :param subscription_id: The ID of the target subscription. + :param subscription_id: The ID of the target subscription. Required. :type subscription_id: str :param base_url: Service URL. Default value is "https://management.azure.com". :type base_url: str @@ -63,18 +76,25 @@ def __init__( self._serialize = Serializer(client_models) self._deserialize = Deserializer(client_models) self._serialize.client_side_validation = False - self.data_policy_manifests = DataPolicyManifestsOperations(self._client, self._config, self._serialize, self._deserialize) - self.policy_assignments = PolicyAssignmentsOperations(self._client, self._config, self._serialize, self._deserialize) - self.policy_definitions = PolicyDefinitionsOperations(self._client, self._config, self._serialize, self._deserialize) - self.policy_set_definitions = PolicySetDefinitionsOperations(self._client, self._config, self._serialize, self._deserialize) - self.policy_exemptions = PolicyExemptionsOperations(self._client, self._config, self._serialize, self._deserialize) - - - def _send_request( - self, - request: HttpRequest, - **kwargs: Any - ) -> Awaitable[AsyncHttpResponse]: + self.data_policy_manifests = DataPolicyManifestsOperations( + self._client, self._config, self._serialize, self._deserialize + ) + self.policy_assignments = PolicyAssignmentsOperations( + self._client, self._config, self._serialize, self._deserialize + ) + self.policy_definitions = PolicyDefinitionsOperations( + self._client, self._config, self._serialize, self._deserialize + ) + self.policy_set_definitions = PolicySetDefinitionsOperations( + self._client, self._config, self._serialize, self._deserialize + ) + self.policy_exemptions = PolicyExemptionsOperations( + self._client, self._config, self._serialize, self._deserialize + ) + self.variables = VariablesOperations(self._client, self._config, self._serialize, self._deserialize) + self.variable_values = VariableValuesOperations(self._client, self._config, self._serialize, self._deserialize) + + def _send_request(self, request: HttpRequest, **kwargs: Any) -> Awaitable[AsyncHttpResponse]: """Runs the network request through the client's chained policies. >>> from azure.core.rest import HttpRequest @@ -83,7 +103,7 @@ def _send_request( >>> response = await client._send_request(request) - For more information on this code flow, see https://aka.ms/azsdk/python/protocol/quickstart + For more information on this code flow, see https://aka.ms/azsdk/dpcodegen/python/send_request :param request: The network request you want to make. Required. :type request: ~azure.core.rest.HttpRequest diff --git a/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/policy/v2021_06_01/aio/operations/__init__.py b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/policy/v2021_06_01/aio/operations/__init__.py index 07b8f47f6b817..fb12b9c0f5fde 100644 --- a/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/policy/v2021_06_01/aio/operations/__init__.py +++ b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/policy/v2021_06_01/aio/operations/__init__.py @@ -11,11 +11,21 @@ from ._operations import PolicyDefinitionsOperations from ._operations import PolicySetDefinitionsOperations from ._operations import PolicyExemptionsOperations +from ._operations import VariablesOperations +from ._operations import VariableValuesOperations + +from ._patch import __all__ as _patch_all +from ._patch import * # type: ignore # pylint: disable=unused-wildcard-import +from ._patch import patch_sdk as _patch_sdk __all__ = [ - 'DataPolicyManifestsOperations', - 'PolicyAssignmentsOperations', - 'PolicyDefinitionsOperations', - 'PolicySetDefinitionsOperations', - 'PolicyExemptionsOperations', + "DataPolicyManifestsOperations", + "PolicyAssignmentsOperations", + "PolicyDefinitionsOperations", + "PolicySetDefinitionsOperations", + "PolicyExemptionsOperations", + "VariablesOperations", + "VariableValuesOperations", ] +__all__.extend([p for p in _patch_all if p not in __all__]) +_patch_sdk() diff --git a/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/policy/v2021_06_01/aio/operations/_operations.py b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/policy/v2021_06_01/aio/operations/_operations.py index 3efed9f7f4f99..6b9829552214c 100644 --- a/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/policy/v2021_06_01/aio/operations/_operations.py +++ b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/policy/v2021_06_01/aio/operations/_operations.py @@ -6,109 +6,168 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -from typing import Any, AsyncIterable, Callable, Dict, Optional, TypeVar +from typing import Any, AsyncIterable, Callable, Dict, IO, Optional, TypeVar, Union, overload from azure.core.async_paging import AsyncItemPaged, AsyncList -from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error +from azure.core.exceptions import ( + ClientAuthenticationError, + HttpResponseError, + ResourceExistsError, + ResourceNotFoundError, + ResourceNotModifiedError, + map_error, +) from azure.core.pipeline import PipelineResponse from azure.core.pipeline.transport import AsyncHttpResponse from azure.core.rest import HttpRequest from azure.core.tracing.decorator import distributed_trace from azure.core.tracing.decorator_async import distributed_trace_async +from azure.core.utils import case_insensitive_dict from azure.mgmt.core.exceptions import ARMErrorFormat from ... import models as _models from ..._vendor import _convert_request -from ...operations._operations import build_data_policy_manifests_get_by_policy_mode_request, build_data_policy_manifests_list_request, build_policy_assignments_create_by_id_request, build_policy_assignments_create_request, build_policy_assignments_delete_by_id_request, build_policy_assignments_delete_request, build_policy_assignments_get_by_id_request, build_policy_assignments_get_request, build_policy_assignments_list_for_management_group_request, build_policy_assignments_list_for_resource_group_request, build_policy_assignments_list_for_resource_request, build_policy_assignments_list_request, build_policy_assignments_update_by_id_request, build_policy_assignments_update_request, build_policy_definitions_create_or_update_at_management_group_request, build_policy_definitions_create_or_update_request, build_policy_definitions_delete_at_management_group_request, build_policy_definitions_delete_request, build_policy_definitions_get_at_management_group_request, build_policy_definitions_get_built_in_request, build_policy_definitions_get_request, build_policy_definitions_list_built_in_request, build_policy_definitions_list_by_management_group_request, build_policy_definitions_list_request, build_policy_exemptions_create_or_update_request, build_policy_exemptions_delete_request, build_policy_exemptions_get_request, build_policy_exemptions_list_for_management_group_request, build_policy_exemptions_list_for_resource_group_request, build_policy_exemptions_list_for_resource_request, build_policy_exemptions_list_request, build_policy_set_definitions_create_or_update_at_management_group_request, build_policy_set_definitions_create_or_update_request, build_policy_set_definitions_delete_at_management_group_request, build_policy_set_definitions_delete_request, build_policy_set_definitions_get_at_management_group_request, build_policy_set_definitions_get_built_in_request, build_policy_set_definitions_get_request, build_policy_set_definitions_list_built_in_request, build_policy_set_definitions_list_by_management_group_request, build_policy_set_definitions_list_request -T = TypeVar('T') +from ...operations._operations import ( + build_data_policy_manifests_get_by_policy_mode_request, + build_data_policy_manifests_list_request, + build_policy_assignments_create_by_id_request, + build_policy_assignments_create_request, + build_policy_assignments_delete_by_id_request, + build_policy_assignments_delete_request, + build_policy_assignments_get_by_id_request, + build_policy_assignments_get_request, + build_policy_assignments_list_for_management_group_request, + build_policy_assignments_list_for_resource_group_request, + build_policy_assignments_list_for_resource_request, + build_policy_assignments_list_request, + build_policy_assignments_update_by_id_request, + build_policy_assignments_update_request, + build_policy_definitions_create_or_update_at_management_group_request, + build_policy_definitions_create_or_update_request, + build_policy_definitions_delete_at_management_group_request, + build_policy_definitions_delete_request, + build_policy_definitions_get_at_management_group_request, + build_policy_definitions_get_built_in_request, + build_policy_definitions_get_request, + build_policy_definitions_list_built_in_request, + build_policy_definitions_list_by_management_group_request, + build_policy_definitions_list_request, + build_policy_exemptions_create_or_update_request, + build_policy_exemptions_delete_request, + build_policy_exemptions_get_request, + build_policy_exemptions_list_for_management_group_request, + build_policy_exemptions_list_for_resource_group_request, + build_policy_exemptions_list_for_resource_request, + build_policy_exemptions_list_request, + build_policy_set_definitions_create_or_update_at_management_group_request, + build_policy_set_definitions_create_or_update_request, + build_policy_set_definitions_delete_at_management_group_request, + build_policy_set_definitions_delete_request, + build_policy_set_definitions_get_at_management_group_request, + build_policy_set_definitions_get_built_in_request, + build_policy_set_definitions_get_request, + build_policy_set_definitions_list_built_in_request, + build_policy_set_definitions_list_by_management_group_request, + build_policy_set_definitions_list_request, + build_variable_values_create_or_update_at_management_group_request, + build_variable_values_create_or_update_request, + build_variable_values_delete_at_management_group_request, + build_variable_values_delete_request, + build_variable_values_get_at_management_group_request, + build_variable_values_get_request, + build_variable_values_list_for_management_group_request, + build_variable_values_list_request, + build_variables_create_or_update_at_management_group_request, + build_variables_create_or_update_request, + build_variables_delete_at_management_group_request, + build_variables_delete_request, + build_variables_get_at_management_group_request, + build_variables_get_request, + build_variables_list_for_management_group_request, + build_variables_list_request, +) + +T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] -class DataPolicyManifestsOperations: - """DataPolicyManifestsOperations async operations. - You should not instantiate this class directly. Instead, you should create a Client instance that - instantiates it for you and attaches it as an attribute. +class DataPolicyManifestsOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. - :ivar models: Alias to model classes used in this operation group. - :type models: ~azure.mgmt.resource.policy.v2021_06_01.models - :param client: Client for service requests. - :param config: Configuration of service client. - :param serializer: An object model serializer. - :param deserializer: An object model deserializer. + Instead, you should access the following operations through + :class:`~azure.mgmt.resource.policy.v2021_06_01.aio.PolicyClient`'s + :attr:`data_policy_manifests` attribute. """ models = _models - def __init__(self, client, config, serializer, deserializer) -> None: - self._client = client - self._serialize = serializer - self._deserialize = deserializer - self._config = config + def __init__(self, *args, **kwargs) -> None: + input_args = list(args) + self._client = input_args.pop(0) if input_args else kwargs.pop("client") + self._config = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") @distributed_trace_async - async def get_by_policy_mode( - self, - policy_mode: str, - **kwargs: Any - ) -> "_models.DataPolicyManifest": + async def get_by_policy_mode(self, policy_mode: str, **kwargs: Any) -> _models.DataPolicyManifest: """Retrieves a data policy manifest. This operation retrieves the data policy manifest with the given policy mode. - :param policy_mode: The policy mode of the data policy manifest to get. + :param policy_mode: The policy mode of the data policy manifest to get. Required. :type policy_mode: str - :keyword api_version: Api Version. Default value is "2020-09-01". Note that overriding this - default value may result in unsupported behavior. - :paramtype api_version: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: DataPolicyManifest, or the result of cls(response) + :return: DataPolicyManifest or the result of cls(response) :rtype: ~azure.mgmt.resource.policy.v2021_06_01.models.DataPolicyManifest - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.DataPolicyManifest"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + 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', "2020-09-01") # type: str + api_version = kwargs.pop("api_version", _params.pop("api-version", "2020-09-01")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[_models.DataPolicyManifest] - request = build_data_policy_manifests_get_by_policy_mode_request( policy_mode=policy_mode, api_version=api_version, - template_url=self.get_by_policy_mode.metadata['url'], + template_url=self.get_by_policy_mode.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) - deserialized = self._deserialize('DataPolicyManifest', pipeline_response) + deserialized = self._deserialize("DataPolicyManifest", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - get_by_policy_mode.metadata = {'url': "/providers/Microsoft.Authorization/dataPolicyManifests/{policyMode}"} # type: ignore - + get_by_policy_mode.metadata = {"url": "/providers/Microsoft.Authorization/dataPolicyManifests/{policyMode}"} # type: ignore @distributed_trace - def list( - self, - filter: Optional[str] = None, - **kwargs: Any - ) -> AsyncIterable["_models.DataPolicyManifestListResult"]: + def list(self, filter: Optional[str] = None, **kwargs: Any) -> AsyncIterable["_models.DataPolicyManifest"]: """Retrieves data policy manifests. This operation retrieves a list of all the data policy manifests that match the optional given @@ -122,41 +181,43 @@ def list( '{value}' is provided, the returned list only includes all data policy manifests that have a namespace matching the provided value. Default value is None. :type filter: str - :keyword api_version: Api Version. Default value is "2020-09-01". Note that overriding this - default value may result in unsupported behavior. - :paramtype api_version: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either DataPolicyManifestListResult or the result of - cls(response) + :return: An iterator like instance of either DataPolicyManifest or the result of cls(response) :rtype: - ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.resource.policy.v2021_06_01.models.DataPolicyManifestListResult] - :raises: ~azure.core.exceptions.HttpResponseError + ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.resource.policy.v2021_06_01.models.DataPolicyManifest] + :raises ~azure.core.exceptions.HttpResponseError: """ - api_version = kwargs.pop('api_version', "2020-09-01") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2020-09-01")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[_models.DataPolicyManifestListResult] - cls = kwargs.pop('cls', None) # type: ClsType["_models.DataPolicyManifestListResult"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) + def prepare_request(next_link=None): if not next_link: - + request = build_data_policy_manifests_list_request( - api_version=api_version, filter=filter, - template_url=self.list.metadata['url'], + 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.url = self._client.format_url(request.url) # type: ignore else: - - request = build_data_policy_manifests_list_request( - template_url=next_link, - ) + request = HttpRequest("GET", next_link) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore request.method = "GET" return request @@ -170,10 +231,8 @@ async def extract_data(pipeline_response): async def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) response = pipeline_response.http_response @@ -183,40 +242,34 @@ async def get_next(next_link=None): return pipeline_response + return AsyncItemPaged(get_next, extract_data) + + list.metadata = {"url": "/providers/Microsoft.Authorization/dataPolicyManifests"} # type: ignore - return AsyncItemPaged( - get_next, extract_data - ) - list.metadata = {'url': "/providers/Microsoft.Authorization/dataPolicyManifests"} # type: ignore -class PolicyAssignmentsOperations: - """PolicyAssignmentsOperations async operations. - You should not instantiate this class directly. Instead, you should create a Client instance that - instantiates it for you and attaches it as an attribute. +class PolicyAssignmentsOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. - :ivar models: Alias to model classes used in this operation group. - :type models: ~azure.mgmt.resource.policy.v2021_06_01.models - :param client: Client for service requests. - :param config: Configuration of service client. - :param serializer: An object model serializer. - :param deserializer: An object model deserializer. + Instead, you should access the following operations through + :class:`~azure.mgmt.resource.policy.v2021_06_01.aio.PolicyClient`'s + :attr:`policy_assignments` attribute. """ models = _models - def __init__(self, client, config, serializer, deserializer) -> None: - self._client = client - self._serialize = serializer - self._deserialize = deserializer - self._config = config + def __init__(self, *args, **kwargs) -> None: + input_args = list(args) + self._client = input_args.pop(0) if input_args else kwargs.pop("client") + self._config = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") @distributed_trace_async async def delete( - self, - scope: str, - policy_assignment_name: str, - **kwargs: Any - ) -> Optional["_models.PolicyAssignment"]: + self, scope: str, policy_assignment_name: str, **kwargs: Any + ) -> Optional[_models.PolicyAssignment]: """Deletes a policy assignment. This operation deletes a policy assignment, given its name and the scope it was created in. The @@ -228,40 +281,44 @@ async def delete( '/subscriptions/{subscriptionId}'), resource group (format: '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}', or resource (format: '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{resourceProviderNamespace}/[{parentResourcePath}/]{resourceType}/{resourceName}'. + Required. :type scope: str - :param policy_assignment_name: The name of the policy assignment to delete. + :param policy_assignment_name: The name of the policy assignment to delete. Required. :type policy_assignment_name: str - :keyword api_version: Api Version. Default value is "2021-06-01". Note that overriding this - default value may result in unsupported behavior. - :paramtype api_version: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: PolicyAssignment, or the result of cls(response) + :return: PolicyAssignment or None or the result of cls(response) :rtype: ~azure.mgmt.resource.policy.v2021_06_01.models.PolicyAssignment or None - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType[Optional["_models.PolicyAssignment"]] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) - api_version = kwargs.pop('api_version', "2021-06-01") # type: str + _headers = 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: str + cls = kwargs.pop("cls", None) # type: ClsType[Optional[_models.PolicyAssignment]] - request = build_policy_assignments_delete_request( scope=scope, policy_assignment_name=policy_assignment_name, api_version=api_version, - template_url=self.delete.metadata['url'], + template_url=self.delete.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200, 204]: @@ -270,24 +327,25 @@ async def delete( deserialized = None if response.status_code == 200: - deserialized = self._deserialize('PolicyAssignment', pipeline_response) + deserialized = self._deserialize("PolicyAssignment", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - delete.metadata = {'url': "/{scope}/providers/Microsoft.Authorization/policyAssignments/{policyAssignmentName}"} # type: ignore + delete.metadata = {"url": "/{scope}/providers/Microsoft.Authorization/policyAssignments/{policyAssignmentName}"} # type: ignore - - @distributed_trace_async + @overload async def create( self, scope: str, policy_assignment_name: str, - parameters: "_models.PolicyAssignment", + parameters: _models.PolicyAssignment, + *, + content_type: str = "application/json", **kwargs: Any - ) -> "_models.PolicyAssignment": + ) -> _models.PolicyAssignment: """Creates or updates a policy assignment. This operation creates or updates a policy assignment with the given scope and name. Policy @@ -299,29 +357,109 @@ async def create( '/subscriptions/{subscriptionId}'), resource group (format: '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}', or resource (format: '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{resourceProviderNamespace}/[{parentResourcePath}/]{resourceType}/{resourceName}'. + Required. :type scope: str - :param policy_assignment_name: The name of the policy assignment. + :param policy_assignment_name: The name of the policy assignment. Required. :type policy_assignment_name: str - :param parameters: Parameters for the policy assignment. + :param parameters: Parameters for the policy assignment. Required. :type parameters: ~azure.mgmt.resource.policy.v2021_06_01.models.PolicyAssignment - :keyword api_version: Api Version. Default value is "2021-06-01". Note that overriding this - default value may result in unsupported behavior. - :paramtype api_version: str + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: PolicyAssignment or the result of cls(response) + :rtype: ~azure.mgmt.resource.policy.v2021_06_01.models.PolicyAssignment + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + async def create( + self, + scope: str, + policy_assignment_name: str, + parameters: IO, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.PolicyAssignment: + """Creates or updates a policy assignment. + + This operation creates or updates a policy assignment with the given scope and name. Policy + assignments apply to all resources contained within their scope. For example, when you assign a + policy at resource group scope, that policy applies to all resources in the group. + + :param scope: The scope of the policy assignment. Valid scopes are: management group (format: + '/providers/Microsoft.Management/managementGroups/{managementGroup}'), subscription (format: + '/subscriptions/{subscriptionId}'), resource group (format: + '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}', or resource (format: + '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{resourceProviderNamespace}/[{parentResourcePath}/]{resourceType}/{resourceName}'. + Required. + :type scope: str + :param policy_assignment_name: The name of the policy assignment. Required. + :type policy_assignment_name: str + :param parameters: Parameters for the policy assignment. Required. + :type parameters: IO + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: PolicyAssignment or the result of cls(response) + :rtype: ~azure.mgmt.resource.policy.v2021_06_01.models.PolicyAssignment + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace_async + async def create( + self, scope: str, policy_assignment_name: str, parameters: Union[_models.PolicyAssignment, IO], **kwargs: Any + ) -> _models.PolicyAssignment: + """Creates or updates a policy assignment. + + This operation creates or updates a policy assignment with the given scope and name. Policy + assignments apply to all resources contained within their scope. For example, when you assign a + policy at resource group scope, that policy applies to all resources in the group. + + :param scope: The scope of the policy assignment. Valid scopes are: management group (format: + '/providers/Microsoft.Management/managementGroups/{managementGroup}'), subscription (format: + '/subscriptions/{subscriptionId}'), resource group (format: + '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}', or resource (format: + '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{resourceProviderNamespace}/[{parentResourcePath}/]{resourceType}/{resourceName}'. + Required. + :type scope: str + :param policy_assignment_name: The name of the policy assignment. Required. + :type policy_assignment_name: str + :param parameters: Parameters for the policy assignment. Is either a model type or a IO type. + Required. + :type parameters: ~azure.mgmt.resource.policy.v2021_06_01.models.PolicyAssignment or IO + :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. + Default value is None. + :paramtype content_type: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: PolicyAssignment, or the result of cls(response) + :return: PolicyAssignment or the result of cls(response) :rtype: ~azure.mgmt.resource.policy.v2021_06_01.models.PolicyAssignment - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.PolicyAssignment"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', "2021-06-01") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-06-01")) # type: str + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.PolicyAssignment] - _json = self._serialize.body(parameters, 'PolicyAssignment') + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(parameters, (IO, bytes)): + _content = parameters + else: + _json = self._serialize.body(parameters, "PolicyAssignment") request = build_policy_assignments_create_request( scope=scope, @@ -329,39 +467,35 @@ async def create( api_version=api_version, content_type=content_type, json=_json, - template_url=self.create.metadata['url'], + content=_content, + template_url=self.create.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [201]: map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) - deserialized = self._deserialize('PolicyAssignment', pipeline_response) + deserialized = self._deserialize("PolicyAssignment", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - create.metadata = {'url': "/{scope}/providers/Microsoft.Authorization/policyAssignments/{policyAssignmentName}"} # type: ignore - + create.metadata = {"url": "/{scope}/providers/Microsoft.Authorization/policyAssignments/{policyAssignmentName}"} # type: ignore @distributed_trace_async - async def get( - self, - scope: str, - policy_assignment_name: str, - **kwargs: Any - ) -> "_models.PolicyAssignment": + async def get(self, scope: str, policy_assignment_name: str, **kwargs: Any) -> _models.PolicyAssignment: """Retrieves a policy assignment. This operation retrieves a single policy assignment, given its name and the scope it was @@ -372,64 +506,139 @@ async def get( '/subscriptions/{subscriptionId}'), resource group (format: '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}', or resource (format: '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{resourceProviderNamespace}/[{parentResourcePath}/]{resourceType}/{resourceName}'. + Required. :type scope: str - :param policy_assignment_name: The name of the policy assignment to get. + :param policy_assignment_name: The name of the policy assignment to get. Required. :type policy_assignment_name: str - :keyword api_version: Api Version. Default value is "2021-06-01". Note that overriding this - default value may result in unsupported behavior. - :paramtype api_version: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: PolicyAssignment, or the result of cls(response) + :return: PolicyAssignment or the result of cls(response) :rtype: ~azure.mgmt.resource.policy.v2021_06_01.models.PolicyAssignment - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.PolicyAssignment"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) - api_version = kwargs.pop('api_version', "2021-06-01") # type: str + _headers = 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: str + cls = kwargs.pop("cls", None) # type: ClsType[_models.PolicyAssignment] - request = build_policy_assignments_get_request( scope=scope, policy_assignment_name=policy_assignment_name, api_version=api_version, - template_url=self.get.metadata['url'], + template_url=self.get.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) - deserialized = self._deserialize('PolicyAssignment', pipeline_response) + deserialized = self._deserialize("PolicyAssignment", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - get.metadata = {'url': "/{scope}/providers/Microsoft.Authorization/policyAssignments/{policyAssignmentName}"} # type: ignore + get.metadata = {"url": "/{scope}/providers/Microsoft.Authorization/policyAssignments/{policyAssignmentName}"} # type: ignore + + @overload + async def update( + self, + scope: str, + policy_assignment_name: str, + parameters: _models.PolicyAssignmentUpdate, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.PolicyAssignment: + """Updates a policy assignment. + + This operation updates a policy assignment with the given scope and name. Policy assignments + apply to all resources contained within their scope. For example, when you assign a policy at + resource group scope, that policy applies to all resources in the group. + + :param scope: The scope of the policy assignment. Valid scopes are: management group (format: + '/providers/Microsoft.Management/managementGroups/{managementGroup}'), subscription (format: + '/subscriptions/{subscriptionId}'), resource group (format: + '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}', or resource (format: + '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{resourceProviderNamespace}/[{parentResourcePath}/]{resourceType}/{resourceName}'. + Required. + :type scope: str + :param policy_assignment_name: The name of the policy assignment. Required. + :type policy_assignment_name: str + :param parameters: Parameters for policy assignment patch request. Required. + :type parameters: ~azure.mgmt.resource.policy.v2021_06_01.models.PolicyAssignmentUpdate + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: PolicyAssignment or the result of cls(response) + :rtype: ~azure.mgmt.resource.policy.v2021_06_01.models.PolicyAssignment + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + async def update( + self, + scope: str, + policy_assignment_name: str, + parameters: IO, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.PolicyAssignment: + """Updates a policy assignment. + + This operation updates a policy assignment with the given scope and name. Policy assignments + apply to all resources contained within their scope. For example, when you assign a policy at + resource group scope, that policy applies to all resources in the group. + :param scope: The scope of the policy assignment. Valid scopes are: management group (format: + '/providers/Microsoft.Management/managementGroups/{managementGroup}'), subscription (format: + '/subscriptions/{subscriptionId}'), resource group (format: + '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}', or resource (format: + '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{resourceProviderNamespace}/[{parentResourcePath}/]{resourceType}/{resourceName}'. + Required. + :type scope: str + :param policy_assignment_name: The name of the policy assignment. Required. + :type policy_assignment_name: str + :param parameters: Parameters for policy assignment patch request. Required. + :type parameters: IO + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: PolicyAssignment or the result of cls(response) + :rtype: ~azure.mgmt.resource.policy.v2021_06_01.models.PolicyAssignment + :raises ~azure.core.exceptions.HttpResponseError: + """ @distributed_trace_async async def update( self, scope: str, policy_assignment_name: str, - parameters: "_models.PolicyAssignmentUpdate", + parameters: Union[_models.PolicyAssignmentUpdate, IO], **kwargs: Any - ) -> "_models.PolicyAssignment": + ) -> _models.PolicyAssignment: """Updates a policy assignment. This operation updates a policy assignment with the given scope and name. Policy assignments @@ -441,29 +650,43 @@ async def update( '/subscriptions/{subscriptionId}'), resource group (format: '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}', or resource (format: '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{resourceProviderNamespace}/[{parentResourcePath}/]{resourceType}/{resourceName}'. + Required. :type scope: str - :param policy_assignment_name: The name of the policy assignment. + :param policy_assignment_name: The name of the policy assignment. Required. :type policy_assignment_name: str - :param parameters: Parameters for policy assignment patch request. - :type parameters: ~azure.mgmt.resource.policy.v2021_06_01.models.PolicyAssignmentUpdate - :keyword api_version: Api Version. Default value is "2021-06-01". Note that overriding this - default value may result in unsupported behavior. - :paramtype api_version: str + :param parameters: Parameters for policy assignment patch request. Is either a model type or a + IO type. Required. + :type parameters: ~azure.mgmt.resource.policy.v2021_06_01.models.PolicyAssignmentUpdate or IO + :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. + Default value is None. + :paramtype content_type: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: PolicyAssignment, or the result of cls(response) + :return: PolicyAssignment or the result of cls(response) :rtype: ~azure.mgmt.resource.policy.v2021_06_01.models.PolicyAssignment - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.PolicyAssignment"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', "2021-06-01") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-06-01")) # type: str + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.PolicyAssignment] - _json = self._serialize.body(parameters, 'PolicyAssignmentUpdate') + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(parameters, (IO, bytes)): + _content = parameters + else: + _json = self._serialize.body(parameters, "PolicyAssignmentUpdate") request = build_policy_assignments_update_request( scope=scope, @@ -471,40 +694,37 @@ async def update( api_version=api_version, content_type=content_type, json=_json, - template_url=self.update.metadata['url'], + content=_content, + template_url=self.update.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) - deserialized = self._deserialize('PolicyAssignment', pipeline_response) + deserialized = self._deserialize("PolicyAssignment", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - update.metadata = {'url': "/{scope}/providers/Microsoft.Authorization/policyAssignments/{policyAssignmentName}"} # type: ignore - + update.metadata = {"url": "/{scope}/providers/Microsoft.Authorization/policyAssignments/{policyAssignmentName}"} # type: ignore @distributed_trace def list_for_resource_group( - self, - resource_group_name: str, - filter: Optional[str] = None, - top: Optional[int] = None, - **kwargs: Any - ) -> AsyncIterable["_models.PolicyAssignmentListResult"]: + self, resource_group_name: str, filter: Optional[str] = None, top: Optional[int] = None, **kwargs: Any + ) -> AsyncIterable["_models.PolicyAssignment"]: """Retrieves all policy assignments that apply to a resource group. This operation retrieves the list of all policy assignments associated with the given resource @@ -521,6 +741,7 @@ def list_for_resource_group( is {value} that apply to the resource group. :param resource_group_name: The name of the resource group that contains policy assignments. + Required. :type resource_group_name: str :param filter: The filter to apply on the operation. Valid values for $filter are: 'atScope()', 'atExactScope()' or 'policyDefinitionId eq '{value}''. If $filter is not provided, no filtering @@ -534,46 +755,46 @@ def list_for_resource_group( :param top: Maximum number of records to return. When the $top filter is not provided, it will return 500 records. Default value is None. :type top: int - :keyword api_version: Api Version. Default value is "2021-06-01". Note that overriding this - default value may result in unsupported behavior. - :paramtype api_version: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either PolicyAssignmentListResult or the result of - cls(response) + :return: An iterator like instance of either PolicyAssignment or the result of cls(response) :rtype: - ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.resource.policy.v2021_06_01.models.PolicyAssignmentListResult] - :raises: ~azure.core.exceptions.HttpResponseError + ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.resource.policy.v2021_06_01.models.PolicyAssignment] + :raises ~azure.core.exceptions.HttpResponseError: """ - api_version = kwargs.pop('api_version', "2021-06-01") # type: str + _headers = 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: str + cls = kwargs.pop("cls", None) # type: ClsType[_models.PolicyAssignmentListResult] - cls = kwargs.pop('cls', None) # type: ClsType["_models.PolicyAssignmentListResult"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) + def prepare_request(next_link=None): if not next_link: - + request = build_policy_assignments_list_for_resource_group_request( resource_group_name=resource_group_name, subscription_id=self._config.subscription_id, - api_version=api_version, filter=filter, top=top, - template_url=self.list_for_resource_group.metadata['url'], + api_version=api_version, + template_url=self.list_for_resource_group.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore else: - - request = build_policy_assignments_list_for_resource_group_request( - resource_group_name=resource_group_name, - subscription_id=self._config.subscription_id, - template_url=next_link, - ) + request = HttpRequest("GET", next_link) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore request.method = "GET" return request @@ -587,10 +808,8 @@ async def extract_data(pipeline_response): async def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) response = pipeline_response.http_response @@ -600,11 +819,9 @@ async def get_next(next_link=None): return pipeline_response + return AsyncItemPaged(get_next, extract_data) - return AsyncItemPaged( - get_next, extract_data - ) - list_for_resource_group.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Authorization/policyAssignments"} # type: ignore + list_for_resource_group.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Authorization/policyAssignments"} # type: ignore @distributed_trace def list_for_resource( @@ -617,7 +834,7 @@ def list_for_resource( filter: Optional[str] = None, top: Optional[int] = None, **kwargs: Any - ) -> AsyncIterable["_models.PolicyAssignmentListResult"]: + ) -> AsyncIterable["_models.PolicyAssignment"]: """Retrieves all policy assignments that apply to a resource. This operation retrieves the list of all policy assignments associated with the specified @@ -644,17 +861,19 @@ def list_for_resource( {parentResourcePath} == '', {resourceType} == 'Microsoft.Web/sites', {resourceName} == 'MyWebApp'). - :param resource_group_name: The name of the resource group containing the resource. + :param resource_group_name: The name of the resource group containing the resource. Required. :type resource_group_name: str :param resource_provider_namespace: The namespace of the resource provider. For example, the namespace of a virtual machine is Microsoft.Compute (from Microsoft.Compute/virtualMachines). + Required. :type resource_provider_namespace: str :param parent_resource_path: The parent resource path. Use empty string if there is none. + Required. :type parent_resource_path: str :param resource_type: The resource type name. For example the type name of a web app is 'sites' - (from Microsoft.Web/sites). + (from Microsoft.Web/sites). Required. :type resource_type: str - :param resource_name: The name of the resource. + :param resource_name: The name of the resource. Required. :type resource_name: str :param filter: The filter to apply on the operation. Valid values for $filter are: 'atScope()', 'atExactScope()' or 'policyDefinitionId eq '{value}''. If $filter is not provided, no filtering @@ -668,26 +887,29 @@ def list_for_resource( :param top: Maximum number of records to return. When the $top filter is not provided, it will return 500 records. Default value is None. :type top: int - :keyword api_version: Api Version. Default value is "2021-06-01". Note that overriding this - default value may result in unsupported behavior. - :paramtype api_version: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either PolicyAssignmentListResult or the result of - cls(response) + :return: An iterator like instance of either PolicyAssignment or the result of cls(response) :rtype: - ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.resource.policy.v2021_06_01.models.PolicyAssignmentListResult] - :raises: ~azure.core.exceptions.HttpResponseError + ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.resource.policy.v2021_06_01.models.PolicyAssignment] + :raises ~azure.core.exceptions.HttpResponseError: """ - api_version = kwargs.pop('api_version', "2021-06-01") # type: str + _headers = 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: str + cls = kwargs.pop("cls", None) # type: ClsType[_models.PolicyAssignmentListResult] - cls = kwargs.pop('cls', None) # type: ClsType["_models.PolicyAssignmentListResult"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) + def prepare_request(next_link=None): if not next_link: - + request = build_policy_assignments_list_for_resource_request( resource_group_name=resource_group_name, resource_provider_namespace=resource_provider_namespace, @@ -695,27 +917,20 @@ def prepare_request(next_link=None): resource_type=resource_type, resource_name=resource_name, subscription_id=self._config.subscription_id, - api_version=api_version, filter=filter, top=top, - template_url=self.list_for_resource.metadata['url'], + api_version=api_version, + template_url=self.list_for_resource.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore else: - - request = build_policy_assignments_list_for_resource_request( - resource_group_name=resource_group_name, - resource_provider_namespace=resource_provider_namespace, - parent_resource_path=parent_resource_path, - resource_type=resource_type, - resource_name=resource_name, - subscription_id=self._config.subscription_id, - template_url=next_link, - ) + request = HttpRequest("GET", next_link) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore request.method = "GET" return request @@ -729,10 +944,8 @@ async def extract_data(pipeline_response): async def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) response = pipeline_response.http_response @@ -742,20 +955,14 @@ async def get_next(next_link=None): return pipeline_response + return AsyncItemPaged(get_next, extract_data) - return AsyncItemPaged( - get_next, extract_data - ) - list_for_resource.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{parentResourcePath}/{resourceType}/{resourceName}/providers/Microsoft.Authorization/policyAssignments"} # type: ignore + list_for_resource.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{parentResourcePath}/{resourceType}/{resourceName}/providers/Microsoft.Authorization/policyAssignments"} # type: ignore @distributed_trace def list_for_management_group( - self, - management_group_id: str, - filter: Optional[str] = None, - top: Optional[int] = None, - **kwargs: Any - ) -> AsyncIterable["_models.PolicyAssignmentListResult"]: + self, management_group_id: str, filter: Optional[str] = None, top: Optional[int] = None, **kwargs: Any + ) -> AsyncIterable["_models.PolicyAssignment"]: """Retrieves all policy assignments that apply to a management group. This operation retrieves the list of all policy assignments applicable to the management group @@ -767,7 +974,7 @@ def list_for_management_group( provided, the returned list includes all policy assignments of the policy definition whose id is {value} that apply to the management group. - :param management_group_id: The ID of the management group. + :param management_group_id: The ID of the management group. Required. :type management_group_id: str :param filter: The filter to apply on the operation. Valid values for $filter are: 'atScope()', 'atExactScope()' or 'policyDefinitionId eq '{value}''. If $filter is not provided, no filtering @@ -781,44 +988,45 @@ def list_for_management_group( :param top: Maximum number of records to return. When the $top filter is not provided, it will return 500 records. Default value is None. :type top: int - :keyword api_version: Api Version. Default value is "2021-06-01". Note that overriding this - default value may result in unsupported behavior. - :paramtype api_version: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either PolicyAssignmentListResult or the result of - cls(response) + :return: An iterator like instance of either PolicyAssignment or the result of cls(response) :rtype: - ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.resource.policy.v2021_06_01.models.PolicyAssignmentListResult] - :raises: ~azure.core.exceptions.HttpResponseError + ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.resource.policy.v2021_06_01.models.PolicyAssignment] + :raises ~azure.core.exceptions.HttpResponseError: """ - api_version = kwargs.pop('api_version', "2021-06-01") # type: str + _headers = 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: str + cls = kwargs.pop("cls", None) # type: ClsType[_models.PolicyAssignmentListResult] - cls = kwargs.pop('cls', None) # type: ClsType["_models.PolicyAssignmentListResult"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) + def prepare_request(next_link=None): if not next_link: - + request = build_policy_assignments_list_for_management_group_request( management_group_id=management_group_id, - api_version=api_version, filter=filter, top=top, - template_url=self.list_for_management_group.metadata['url'], + api_version=api_version, + template_url=self.list_for_management_group.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore else: - - request = build_policy_assignments_list_for_management_group_request( - management_group_id=management_group_id, - template_url=next_link, - ) + request = HttpRequest("GET", next_link) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore request.method = "GET" return request @@ -832,10 +1040,8 @@ async def extract_data(pipeline_response): async def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) response = pipeline_response.http_response @@ -845,19 +1051,14 @@ async def get_next(next_link=None): return pipeline_response + return AsyncItemPaged(get_next, extract_data) - return AsyncItemPaged( - get_next, extract_data - ) - list_for_management_group.metadata = {'url': "/providers/Microsoft.Management/managementGroups/{managementGroupId}/providers/Microsoft.Authorization/policyAssignments"} # type: ignore + list_for_management_group.metadata = {"url": "/providers/Microsoft.Management/managementGroups/{managementGroupId}/providers/Microsoft.Authorization/policyAssignments"} # type: ignore @distributed_trace def list( - self, - filter: Optional[str] = None, - top: Optional[int] = None, - **kwargs: Any - ) -> AsyncIterable["_models.PolicyAssignmentListResult"]: + self, filter: Optional[str] = None, top: Optional[int] = None, **kwargs: Any + ) -> AsyncIterable["_models.PolicyAssignment"]: """Retrieves all policy assignments that apply to a subscription. This operation retrieves the list of all policy assignments associated with the given @@ -884,44 +1085,45 @@ def list( :param top: Maximum number of records to return. When the $top filter is not provided, it will return 500 records. Default value is None. :type top: int - :keyword api_version: Api Version. Default value is "2021-06-01". Note that overriding this - default value may result in unsupported behavior. - :paramtype api_version: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either PolicyAssignmentListResult or the result of - cls(response) + :return: An iterator like instance of either PolicyAssignment or the result of cls(response) :rtype: - ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.resource.policy.v2021_06_01.models.PolicyAssignmentListResult] - :raises: ~azure.core.exceptions.HttpResponseError + ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.resource.policy.v2021_06_01.models.PolicyAssignment] + :raises ~azure.core.exceptions.HttpResponseError: """ - api_version = kwargs.pop('api_version', "2021-06-01") # type: str + _headers = 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: str + cls = kwargs.pop("cls", None) # type: ClsType[_models.PolicyAssignmentListResult] - cls = kwargs.pop('cls', None) # type: ClsType["_models.PolicyAssignmentListResult"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) + def prepare_request(next_link=None): if not next_link: - + request = build_policy_assignments_list_request( subscription_id=self._config.subscription_id, - api_version=api_version, filter=filter, top=top, - template_url=self.list.metadata['url'], + 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.url = self._client.format_url(request.url) # type: ignore else: - - request = build_policy_assignments_list_request( - subscription_id=self._config.subscription_id, - template_url=next_link, - ) + request = HttpRequest("GET", next_link) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore request.method = "GET" return request @@ -935,10 +1137,8 @@ async def extract_data(pipeline_response): async def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) response = pipeline_response.http_response @@ -948,18 +1148,12 @@ async def get_next(next_link=None): return pipeline_response + return AsyncItemPaged(get_next, extract_data) - return AsyncItemPaged( - get_next, extract_data - ) - list.metadata = {'url': "/subscriptions/{subscriptionId}/providers/Microsoft.Authorization/policyAssignments"} # type: ignore + list.metadata = {"url": "/subscriptions/{subscriptionId}/providers/Microsoft.Authorization/policyAssignments"} # type: ignore @distributed_trace_async - async def delete_by_id( - self, - policy_assignment_id: str, - **kwargs: Any - ) -> Optional["_models.PolicyAssignment"]: + async def delete_by_id(self, policy_assignment_id: str, **kwargs: Any) -> Optional[_models.PolicyAssignment]: """Deletes a policy assignment. This operation deletes the policy with the given ID. Policy assignment IDs have this format: @@ -971,38 +1165,41 @@ async def delete_by_id( (resource). :param policy_assignment_id: The ID of the policy assignment to delete. Use the format - '{scope}/providers/Microsoft.Authorization/policyAssignments/{policyAssignmentName}'. + '{scope}/providers/Microsoft.Authorization/policyAssignments/{policyAssignmentName}'. Required. :type policy_assignment_id: str - :keyword api_version: Api Version. Default value is "2021-06-01". Note that overriding this - default value may result in unsupported behavior. - :paramtype api_version: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: PolicyAssignment, or the result of cls(response) + :return: PolicyAssignment or None or the result of cls(response) :rtype: ~azure.mgmt.resource.policy.v2021_06_01.models.PolicyAssignment or None - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType[Optional["_models.PolicyAssignment"]] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + 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', "2021-06-01") # type: str + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-06-01")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[Optional[_models.PolicyAssignment]] - request = build_policy_assignments_delete_by_id_request( policy_assignment_id=policy_assignment_id, api_version=api_version, - template_url=self.delete_by_id.metadata['url'], + template_url=self.delete_by_id.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200, 204]: @@ -1011,23 +1208,24 @@ async def delete_by_id( deserialized = None if response.status_code == 200: - deserialized = self._deserialize('PolicyAssignment', pipeline_response) + deserialized = self._deserialize("PolicyAssignment", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - delete_by_id.metadata = {'url': "/{policyAssignmentId}"} # type: ignore - + delete_by_id.metadata = {"url": "/{policyAssignmentId}"} # type: ignore - @distributed_trace_async + @overload async def create_by_id( self, policy_assignment_id: str, - parameters: "_models.PolicyAssignment", + parameters: _models.PolicyAssignment, + *, + content_type: str = "application/json", **kwargs: Any - ) -> "_models.PolicyAssignment": + ) -> _models.PolicyAssignment: """Creates or updates a policy assignment. This operation creates or updates the policy assignment with the given ID. Policy assignments @@ -1042,66 +1240,138 @@ async def create_by_id( '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{resourceProviderNamespace}/[{parentResourcePath}/]{resourceType}/{resourceName}'. :param policy_assignment_id: The ID of the policy assignment to create. Use the format - '{scope}/providers/Microsoft.Authorization/policyAssignments/{policyAssignmentName}'. + '{scope}/providers/Microsoft.Authorization/policyAssignments/{policyAssignmentName}'. Required. :type policy_assignment_id: str - :param parameters: Parameters for policy assignment. + :param parameters: Parameters for policy assignment. Required. :type parameters: ~azure.mgmt.resource.policy.v2021_06_01.models.PolicyAssignment - :keyword api_version: Api Version. Default value is "2021-06-01". Note that overriding this - default value may result in unsupported behavior. - :paramtype api_version: str + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: PolicyAssignment or the result of cls(response) + :rtype: ~azure.mgmt.resource.policy.v2021_06_01.models.PolicyAssignment + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + async def create_by_id( + self, policy_assignment_id: str, parameters: IO, *, content_type: str = "application/json", **kwargs: Any + ) -> _models.PolicyAssignment: + """Creates or updates a policy assignment. + + This operation creates or updates the policy assignment with the given ID. Policy assignments + made on a scope apply to all resources contained in that scope. For example, when you assign a + policy to a resource group that policy applies to all resources in the group. Policy assignment + IDs have this format: + '{scope}/providers/Microsoft.Authorization/policyAssignments/{policyAssignmentName}'. Valid + scopes are: management group (format: + '/providers/Microsoft.Management/managementGroups/{managementGroup}'), subscription (format: + '/subscriptions/{subscriptionId}'), resource group (format: + '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}', or resource (format: + '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{resourceProviderNamespace}/[{parentResourcePath}/]{resourceType}/{resourceName}'. + + :param policy_assignment_id: The ID of the policy assignment to create. Use the format + '{scope}/providers/Microsoft.Authorization/policyAssignments/{policyAssignmentName}'. Required. + :type policy_assignment_id: str + :param parameters: Parameters for policy assignment. Required. + :type parameters: IO + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: PolicyAssignment or the result of cls(response) + :rtype: ~azure.mgmt.resource.policy.v2021_06_01.models.PolicyAssignment + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace_async + async def create_by_id( + self, policy_assignment_id: str, parameters: Union[_models.PolicyAssignment, IO], **kwargs: Any + ) -> _models.PolicyAssignment: + """Creates or updates a policy assignment. + + This operation creates or updates the policy assignment with the given ID. Policy assignments + made on a scope apply to all resources contained in that scope. For example, when you assign a + policy to a resource group that policy applies to all resources in the group. Policy assignment + IDs have this format: + '{scope}/providers/Microsoft.Authorization/policyAssignments/{policyAssignmentName}'. Valid + scopes are: management group (format: + '/providers/Microsoft.Management/managementGroups/{managementGroup}'), subscription (format: + '/subscriptions/{subscriptionId}'), resource group (format: + '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}', or resource (format: + '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{resourceProviderNamespace}/[{parentResourcePath}/]{resourceType}/{resourceName}'. + + :param policy_assignment_id: The ID of the policy assignment to create. Use the format + '{scope}/providers/Microsoft.Authorization/policyAssignments/{policyAssignmentName}'. Required. + :type policy_assignment_id: str + :param parameters: Parameters for policy assignment. Is either a model type or a IO type. + Required. + :type parameters: ~azure.mgmt.resource.policy.v2021_06_01.models.PolicyAssignment or IO + :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. + Default value is None. + :paramtype content_type: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: PolicyAssignment, or the result of cls(response) + :return: PolicyAssignment or the result of cls(response) :rtype: ~azure.mgmt.resource.policy.v2021_06_01.models.PolicyAssignment - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.PolicyAssignment"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) - api_version = kwargs.pop('api_version', "2021-06-01") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - _json = self._serialize.body(parameters, 'PolicyAssignment') + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-06-01")) # type: str + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.PolicyAssignment] + + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(parameters, (IO, bytes)): + _content = parameters + else: + _json = self._serialize.body(parameters, "PolicyAssignment") request = build_policy_assignments_create_by_id_request( policy_assignment_id=policy_assignment_id, api_version=api_version, content_type=content_type, json=_json, - template_url=self.create_by_id.metadata['url'], + content=_content, + template_url=self.create_by_id.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [201]: map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) - deserialized = self._deserialize('PolicyAssignment', pipeline_response) + deserialized = self._deserialize("PolicyAssignment", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - create_by_id.metadata = {'url': "/{policyAssignmentId}"} # type: ignore - + create_by_id.metadata = {"url": "/{policyAssignmentId}"} # type: ignore @distributed_trace_async - async def get_by_id( - self, - policy_assignment_id: str, - **kwargs: Any - ) -> "_models.PolicyAssignment": + async def get_by_id(self, policy_assignment_id: str, **kwargs: Any) -> _models.PolicyAssignment: """Retrieves the policy assignment with the given ID. The operation retrieves the policy assignment with the given ID. Policy assignment IDs have @@ -1114,61 +1384,65 @@ async def get_by_id( '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{resourceProviderNamespace}/[{parentResourcePath}/]{resourceType}/{resourceName}'. :param policy_assignment_id: The ID of the policy assignment to get. Use the format - '{scope}/providers/Microsoft.Authorization/policyAssignments/{policyAssignmentName}'. + '{scope}/providers/Microsoft.Authorization/policyAssignments/{policyAssignmentName}'. Required. :type policy_assignment_id: str - :keyword api_version: Api Version. Default value is "2021-06-01". Note that overriding this - default value may result in unsupported behavior. - :paramtype api_version: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: PolicyAssignment, or the result of cls(response) + :return: PolicyAssignment or the result of cls(response) :rtype: ~azure.mgmt.resource.policy.v2021_06_01.models.PolicyAssignment - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.PolicyAssignment"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) - api_version = kwargs.pop('api_version', "2021-06-01") # type: str + _headers = 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: str + cls = kwargs.pop("cls", None) # type: ClsType[_models.PolicyAssignment] - request = build_policy_assignments_get_by_id_request( policy_assignment_id=policy_assignment_id, api_version=api_version, - template_url=self.get_by_id.metadata['url'], + template_url=self.get_by_id.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) - deserialized = self._deserialize('PolicyAssignment', pipeline_response) + deserialized = self._deserialize("PolicyAssignment", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - get_by_id.metadata = {'url': "/{policyAssignmentId}"} # type: ignore + get_by_id.metadata = {"url": "/{policyAssignmentId}"} # type: ignore - - @distributed_trace_async + @overload async def update_by_id( self, policy_assignment_id: str, - parameters: "_models.PolicyAssignmentUpdate", + parameters: _models.PolicyAssignmentUpdate, + *, + content_type: str = "application/json", **kwargs: Any - ) -> "_models.PolicyAssignment": + ) -> _models.PolicyAssignment: """Updates a policy assignment. This operation updates the policy assignment with the given ID. Policy assignments made on a @@ -1183,115 +1457,249 @@ async def update_by_id( '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{resourceProviderNamespace}/[{parentResourcePath}/]{resourceType}/{resourceName}'. :param policy_assignment_id: The ID of the policy assignment to update. Use the format - '{scope}/providers/Microsoft.Authorization/policyAssignments/{policyAssignmentName}'. + '{scope}/providers/Microsoft.Authorization/policyAssignments/{policyAssignmentName}'. Required. :type policy_assignment_id: str - :param parameters: Parameters for policy assignment patch request. + :param parameters: Parameters for policy assignment patch request. Required. :type parameters: ~azure.mgmt.resource.policy.v2021_06_01.models.PolicyAssignmentUpdate - :keyword api_version: Api Version. Default value is "2021-06-01". Note that overriding this - default value may result in unsupported behavior. - :paramtype api_version: str + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: PolicyAssignment, or the result of cls(response) + :return: PolicyAssignment or the result of cls(response) :rtype: ~azure.mgmt.resource.policy.v2021_06_01.models.PolicyAssignment - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.PolicyAssignment"] - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {})) - api_version = kwargs.pop('api_version', "2021-06-01") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] - - _json = self._serialize.body(parameters, 'PolicyAssignmentUpdate') + @overload + async def update_by_id( + self, policy_assignment_id: str, parameters: IO, *, content_type: str = "application/json", **kwargs: Any + ) -> _models.PolicyAssignment: + """Updates a policy assignment. - request = build_policy_assignments_update_by_id_request( - policy_assignment_id=policy_assignment_id, - api_version=api_version, - content_type=content_type, - json=_json, - template_url=self.update_by_id.metadata['url'], - ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) + This operation updates the policy assignment with the given ID. Policy assignments made on a + scope apply to all resources contained in that scope. For example, when you assign a policy to + a resource group that policy applies to all resources in the group. Policy assignment IDs have + this format: + '{scope}/providers/Microsoft.Authorization/policyAssignments/{policyAssignmentName}'. Valid + scopes are: management group (format: + '/providers/Microsoft.Management/managementGroups/{managementGroup}'), subscription (format: + '/subscriptions/{subscriptionId}'), resource group (format: + '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}', or resource (format: + '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{resourceProviderNamespace}/[{parentResourcePath}/]{resourceType}/{resourceName}'. + + :param policy_assignment_id: The ID of the policy assignment to update. Use the format + '{scope}/providers/Microsoft.Authorization/policyAssignments/{policyAssignmentName}'. Required. + :type policy_assignment_id: str + :param parameters: Parameters for policy assignment patch request. Required. + :type parameters: IO + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: PolicyAssignment or the result of cls(response) + :rtype: ~azure.mgmt.resource.policy.v2021_06_01.models.PolicyAssignment + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace_async + async def update_by_id( + self, policy_assignment_id: str, parameters: Union[_models.PolicyAssignmentUpdate, IO], **kwargs: Any + ) -> _models.PolicyAssignment: + """Updates a policy assignment. + + This operation updates the policy assignment with the given ID. Policy assignments made on a + scope apply to all resources contained in that scope. For example, when you assign a policy to + a resource group that policy applies to all resources in the group. Policy assignment IDs have + this format: + '{scope}/providers/Microsoft.Authorization/policyAssignments/{policyAssignmentName}'. Valid + scopes are: management group (format: + '/providers/Microsoft.Management/managementGroups/{managementGroup}'), subscription (format: + '/subscriptions/{subscriptionId}'), resource group (format: + '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}', or resource (format: + '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{resourceProviderNamespace}/[{parentResourcePath}/]{resourceType}/{resourceName}'. + + :param policy_assignment_id: The ID of the policy assignment to update. Use the format + '{scope}/providers/Microsoft.Authorization/policyAssignments/{policyAssignmentName}'. Required. + :type policy_assignment_id: str + :param parameters: Parameters for policy assignment patch request. Is either a model type or a + IO type. Required. + :type parameters: ~azure.mgmt.resource.policy.v2021_06_01.models.PolicyAssignmentUpdate or IO + :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. + Default value is None. + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: PolicyAssignment or the result of cls(response) + :rtype: ~azure.mgmt.resource.policy.v2021_06_01.models.PolicyAssignment + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-06-01")) # type: str + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.PolicyAssignment] + + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(parameters, (IO, bytes)): + _content = parameters + else: + _json = self._serialize.body(parameters, "PolicyAssignmentUpdate") + + request = build_policy_assignments_update_by_id_request( + policy_assignment_id=policy_assignment_id, + api_version=api_version, + content_type=content_type, + json=_json, + content=_content, + template_url=self.update_by_id.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( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) - deserialized = self._deserialize('PolicyAssignment', pipeline_response) + deserialized = self._deserialize("PolicyAssignment", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - update_by_id.metadata = {'url': "/{policyAssignmentId}"} # type: ignore + update_by_id.metadata = {"url": "/{policyAssignmentId}"} # type: ignore -class PolicyDefinitionsOperations: - """PolicyDefinitionsOperations async operations. - You should not instantiate this class directly. Instead, you should create a Client instance that - instantiates it for you and attaches it as an attribute. +class PolicyDefinitionsOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. - :ivar models: Alias to model classes used in this operation group. - :type models: ~azure.mgmt.resource.policy.v2021_06_01.models - :param client: Client for service requests. - :param config: Configuration of service client. - :param serializer: An object model serializer. - :param deserializer: An object model deserializer. + Instead, you should access the following operations through + :class:`~azure.mgmt.resource.policy.v2021_06_01.aio.PolicyClient`'s + :attr:`policy_definitions` attribute. """ models = _models - def __init__(self, client, config, serializer, deserializer) -> None: - self._client = client - self._serialize = serializer - self._deserialize = deserializer - self._config = config + def __init__(self, *args, **kwargs) -> None: + input_args = list(args) + self._client = input_args.pop(0) if input_args else kwargs.pop("client") + self._config = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") - @distributed_trace_async + @overload async def create_or_update( self, policy_definition_name: str, - parameters: "_models.PolicyDefinition", + parameters: _models.PolicyDefinition, + *, + content_type: str = "application/json", **kwargs: Any - ) -> "_models.PolicyDefinition": + ) -> _models.PolicyDefinition: """Creates or updates a policy definition in a subscription. This operation creates or updates a policy definition in the given subscription with the given name. - :param policy_definition_name: The name of the policy definition to create. + :param policy_definition_name: The name of the policy definition to create. Required. :type policy_definition_name: str - :param parameters: The policy definition properties. + :param parameters: The policy definition properties. Required. :type parameters: ~azure.mgmt.resource.policy.v2021_06_01.models.PolicyDefinition - :keyword api_version: Api Version. Default value is "2021-06-01". Note that overriding this - default value may result in unsupported behavior. - :paramtype api_version: str + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: PolicyDefinition or the result of cls(response) + :rtype: ~azure.mgmt.resource.policy.v2021_06_01.models.PolicyDefinition + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + async def create_or_update( + self, policy_definition_name: str, parameters: IO, *, content_type: str = "application/json", **kwargs: Any + ) -> _models.PolicyDefinition: + """Creates or updates a policy definition in a subscription. + + This operation creates or updates a policy definition in the given subscription with the given + name. + + :param policy_definition_name: The name of the policy definition to create. Required. + :type policy_definition_name: str + :param parameters: The policy definition properties. Required. + :type parameters: IO + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: PolicyDefinition or the result of cls(response) + :rtype: ~azure.mgmt.resource.policy.v2021_06_01.models.PolicyDefinition + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace_async + async def create_or_update( + self, policy_definition_name: str, parameters: Union[_models.PolicyDefinition, IO], **kwargs: Any + ) -> _models.PolicyDefinition: + """Creates or updates a policy definition in a subscription. + + This operation creates or updates a policy definition in the given subscription with the given + name. + + :param policy_definition_name: The name of the policy definition to create. Required. + :type policy_definition_name: str + :param parameters: The policy definition properties. Is either a model type or a IO type. + Required. + :type parameters: ~azure.mgmt.resource.policy.v2021_06_01.models.PolicyDefinition or IO + :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. + Default value is None. + :paramtype content_type: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: PolicyDefinition, or the result of cls(response) + :return: PolicyDefinition or the result of cls(response) :rtype: ~azure.mgmt.resource.policy.v2021_06_01.models.PolicyDefinition - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.PolicyDefinition"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) - api_version = kwargs.pop('api_version', "2021-06-01") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - _json = self._serialize.body(parameters, 'PolicyDefinition') + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-06-01")) # type: str + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.PolicyDefinition] + + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(parameters, (IO, bytes)): + _content = parameters + else: + _json = self._serialize.body(parameters, "PolicyDefinition") request = build_policy_definitions_create_or_update_request( policy_definition_name=policy_definition_name, @@ -1299,75 +1707,77 @@ async def create_or_update( api_version=api_version, content_type=content_type, json=_json, - template_url=self.create_or_update.metadata['url'], + content=_content, + template_url=self.create_or_update.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [201]: map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) - deserialized = self._deserialize('PolicyDefinition', pipeline_response) + deserialized = self._deserialize("PolicyDefinition", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - create_or_update.metadata = {'url': "/subscriptions/{subscriptionId}/providers/Microsoft.Authorization/policyDefinitions/{policyDefinitionName}"} # type: ignore - + create_or_update.metadata = {"url": "/subscriptions/{subscriptionId}/providers/Microsoft.Authorization/policyDefinitions/{policyDefinitionName}"} # type: ignore @distributed_trace_async async def delete( # pylint: disable=inconsistent-return-statements - self, - policy_definition_name: str, - **kwargs: Any + self, policy_definition_name: str, **kwargs: Any ) -> None: """Deletes a policy definition in a subscription. This operation deletes the policy definition in the given subscription with the given name. - :param policy_definition_name: The name of the policy definition to delete. + :param policy_definition_name: The name of the policy definition to delete. Required. :type policy_definition_name: str - :keyword api_version: Api Version. Default value is "2021-06-01". Note that overriding this - default value may result in unsupported behavior. - :paramtype api_version: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: None, or the result of cls(response) + :return: None or the result of cls(response) :rtype: None - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType[None] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) - api_version = kwargs.pop('api_version', "2021-06-01") # type: str + _headers = 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: str + cls = kwargs.pop("cls", None) # type: ClsType[None] - request = build_policy_definitions_delete_request( policy_definition_name=policy_definition_name, subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.delete.metadata['url'], + template_url=self.delete.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200, 204]: @@ -1377,163 +1787,231 @@ async def delete( # pylint: disable=inconsistent-return-statements if cls: return cls(pipeline_response, None, {}) - delete.metadata = {'url': "/subscriptions/{subscriptionId}/providers/Microsoft.Authorization/policyDefinitions/{policyDefinitionName}"} # type: ignore - + delete.metadata = {"url": "/subscriptions/{subscriptionId}/providers/Microsoft.Authorization/policyDefinitions/{policyDefinitionName}"} # type: ignore @distributed_trace_async - async def get( - self, - policy_definition_name: str, - **kwargs: Any - ) -> "_models.PolicyDefinition": + async def get(self, policy_definition_name: str, **kwargs: Any) -> _models.PolicyDefinition: """Retrieves a policy definition in a subscription. This operation retrieves the policy definition in the given subscription with the given name. - :param policy_definition_name: The name of the policy definition to get. + :param policy_definition_name: The name of the policy definition to get. Required. :type policy_definition_name: str - :keyword api_version: Api Version. Default value is "2021-06-01". Note that overriding this - default value may result in unsupported behavior. - :paramtype api_version: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: PolicyDefinition, or the result of cls(response) + :return: PolicyDefinition or the result of cls(response) :rtype: ~azure.mgmt.resource.policy.v2021_06_01.models.PolicyDefinition - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.PolicyDefinition"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) - api_version = kwargs.pop('api_version', "2021-06-01") # type: str + _headers = 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: str + cls = kwargs.pop("cls", None) # type: ClsType[_models.PolicyDefinition] - request = build_policy_definitions_get_request( policy_definition_name=policy_definition_name, subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.get.metadata['url'], + template_url=self.get.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) - deserialized = self._deserialize('PolicyDefinition', pipeline_response) + deserialized = self._deserialize("PolicyDefinition", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - get.metadata = {'url': "/subscriptions/{subscriptionId}/providers/Microsoft.Authorization/policyDefinitions/{policyDefinitionName}"} # type: ignore - + get.metadata = {"url": "/subscriptions/{subscriptionId}/providers/Microsoft.Authorization/policyDefinitions/{policyDefinitionName}"} # type: ignore @distributed_trace_async - async def get_built_in( - self, - policy_definition_name: str, - **kwargs: Any - ) -> "_models.PolicyDefinition": + async def get_built_in(self, policy_definition_name: str, **kwargs: Any) -> _models.PolicyDefinition: """Retrieves a built-in policy definition. This operation retrieves the built-in policy definition with the given name. - :param policy_definition_name: The name of the built-in policy definition to get. + :param policy_definition_name: The name of the built-in policy definition to get. Required. :type policy_definition_name: str - :keyword api_version: Api Version. Default value is "2021-06-01". Note that overriding this - default value may result in unsupported behavior. - :paramtype api_version: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: PolicyDefinition, or the result of cls(response) + :return: PolicyDefinition or the result of cls(response) :rtype: ~azure.mgmt.resource.policy.v2021_06_01.models.PolicyDefinition - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.PolicyDefinition"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) - api_version = kwargs.pop('api_version', "2021-06-01") # type: str + _headers = 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: str + cls = kwargs.pop("cls", None) # type: ClsType[_models.PolicyDefinition] - request = build_policy_definitions_get_built_in_request( policy_definition_name=policy_definition_name, api_version=api_version, - template_url=self.get_built_in.metadata['url'], + template_url=self.get_built_in.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) - deserialized = self._deserialize('PolicyDefinition', pipeline_response) + deserialized = self._deserialize("PolicyDefinition", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - get_built_in.metadata = {'url': "/providers/Microsoft.Authorization/policyDefinitions/{policyDefinitionName}"} # type: ignore + get_built_in.metadata = {"url": "/providers/Microsoft.Authorization/policyDefinitions/{policyDefinitionName}"} # type: ignore + + @overload + async def create_or_update_at_management_group( + self, + policy_definition_name: str, + management_group_id: str, + parameters: _models.PolicyDefinition, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.PolicyDefinition: + """Creates or updates a policy definition in a management group. + + This operation creates or updates a policy definition in the given management group with the + given name. + + :param policy_definition_name: The name of the policy definition to create. Required. + :type policy_definition_name: str + :param management_group_id: The ID of the management group. Required. + :type management_group_id: str + :param parameters: The policy definition properties. Required. + :type parameters: ~azure.mgmt.resource.policy.v2021_06_01.models.PolicyDefinition + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: PolicyDefinition or the result of cls(response) + :rtype: ~azure.mgmt.resource.policy.v2021_06_01.models.PolicyDefinition + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + async def create_or_update_at_management_group( + self, + policy_definition_name: str, + management_group_id: str, + parameters: IO, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.PolicyDefinition: + """Creates or updates a policy definition in a management group. + + This operation creates or updates a policy definition in the given management group with the + given name. + :param policy_definition_name: The name of the policy definition to create. Required. + :type policy_definition_name: str + :param management_group_id: The ID of the management group. Required. + :type management_group_id: str + :param parameters: The policy definition properties. Required. + :type parameters: IO + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: PolicyDefinition or the result of cls(response) + :rtype: ~azure.mgmt.resource.policy.v2021_06_01.models.PolicyDefinition + :raises ~azure.core.exceptions.HttpResponseError: + """ @distributed_trace_async async def create_or_update_at_management_group( self, policy_definition_name: str, management_group_id: str, - parameters: "_models.PolicyDefinition", + parameters: Union[_models.PolicyDefinition, IO], **kwargs: Any - ) -> "_models.PolicyDefinition": + ) -> _models.PolicyDefinition: """Creates or updates a policy definition in a management group. This operation creates or updates a policy definition in the given management group with the given name. - :param policy_definition_name: The name of the policy definition to create. + :param policy_definition_name: The name of the policy definition to create. Required. :type policy_definition_name: str - :param management_group_id: The ID of the management group. + :param management_group_id: The ID of the management group. Required. :type management_group_id: str - :param parameters: The policy definition properties. - :type parameters: ~azure.mgmt.resource.policy.v2021_06_01.models.PolicyDefinition - :keyword api_version: Api Version. Default value is "2021-06-01". Note that overriding this - default value may result in unsupported behavior. - :paramtype api_version: str + :param parameters: The policy definition properties. Is either a model type or a IO type. + Required. + :type parameters: ~azure.mgmt.resource.policy.v2021_06_01.models.PolicyDefinition or IO + :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. + Default value is None. + :paramtype content_type: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: PolicyDefinition, or the result of cls(response) + :return: PolicyDefinition or the result of cls(response) :rtype: ~azure.mgmt.resource.policy.v2021_06_01.models.PolicyDefinition - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.PolicyDefinition"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', "2021-06-01") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-06-01")) # type: str + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.PolicyDefinition] - _json = self._serialize.body(parameters, 'PolicyDefinition') + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(parameters, (IO, bytes)): + _content = parameters + else: + _json = self._serialize.body(parameters, "PolicyDefinition") request = build_policy_definitions_create_or_update_at_management_group_request( policy_definition_name=policy_definition_name, @@ -1541,78 +2019,79 @@ async def create_or_update_at_management_group( api_version=api_version, content_type=content_type, json=_json, - template_url=self.create_or_update_at_management_group.metadata['url'], + content=_content, + template_url=self.create_or_update_at_management_group.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [201]: map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) - deserialized = self._deserialize('PolicyDefinition', pipeline_response) + deserialized = self._deserialize("PolicyDefinition", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - create_or_update_at_management_group.metadata = {'url': "/providers/Microsoft.Management/managementGroups/{managementGroupId}/providers/Microsoft.Authorization/policyDefinitions/{policyDefinitionName}"} # type: ignore - + create_or_update_at_management_group.metadata = {"url": "/providers/Microsoft.Management/managementGroups/{managementGroupId}/providers/Microsoft.Authorization/policyDefinitions/{policyDefinitionName}"} # type: ignore @distributed_trace_async async def delete_at_management_group( # pylint: disable=inconsistent-return-statements - self, - policy_definition_name: str, - management_group_id: str, - **kwargs: Any + self, policy_definition_name: str, management_group_id: str, **kwargs: Any ) -> None: """Deletes a policy definition in a management group. This operation deletes the policy definition in the given management group with the given name. - :param policy_definition_name: The name of the policy definition to delete. + :param policy_definition_name: The name of the policy definition to delete. Required. :type policy_definition_name: str - :param management_group_id: The ID of the management group. + :param management_group_id: The ID of the management group. Required. :type management_group_id: str - :keyword api_version: Api Version. Default value is "2021-06-01". Note that overriding this - default value may result in unsupported behavior. - :paramtype api_version: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: None, or the result of cls(response) + :return: None or the result of cls(response) :rtype: None - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType[None] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) - api_version = kwargs.pop('api_version', "2021-06-01") # type: str + _headers = 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: str + cls = kwargs.pop("cls", None) # type: ClsType[None] - request = build_policy_definitions_delete_at_management_group_request( policy_definition_name=policy_definition_name, management_group_id=management_group_id, api_version=api_version, - template_url=self.delete_at_management_group.metadata['url'], + template_url=self.delete_at_management_group.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200, 204]: @@ -1622,79 +2101,74 @@ async def delete_at_management_group( # pylint: disable=inconsistent-return-sta if cls: return cls(pipeline_response, None, {}) - delete_at_management_group.metadata = {'url': "/providers/Microsoft.Management/managementGroups/{managementGroupId}/providers/Microsoft.Authorization/policyDefinitions/{policyDefinitionName}"} # type: ignore - + delete_at_management_group.metadata = {"url": "/providers/Microsoft.Management/managementGroups/{managementGroupId}/providers/Microsoft.Authorization/policyDefinitions/{policyDefinitionName}"} # type: ignore @distributed_trace_async async def get_at_management_group( - self, - policy_definition_name: str, - management_group_id: str, - **kwargs: Any - ) -> "_models.PolicyDefinition": + self, policy_definition_name: str, management_group_id: str, **kwargs: Any + ) -> _models.PolicyDefinition: """Retrieve a policy definition in a management group. This operation retrieves the policy definition in the given management group with the given name. - :param policy_definition_name: The name of the policy definition to get. + :param policy_definition_name: The name of the policy definition to get. Required. :type policy_definition_name: str - :param management_group_id: The ID of the management group. + :param management_group_id: The ID of the management group. Required. :type management_group_id: str - :keyword api_version: Api Version. Default value is "2021-06-01". Note that overriding this - default value may result in unsupported behavior. - :paramtype api_version: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: PolicyDefinition, or the result of cls(response) + :return: PolicyDefinition or the result of cls(response) :rtype: ~azure.mgmt.resource.policy.v2021_06_01.models.PolicyDefinition - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.PolicyDefinition"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + 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', "2021-06-01") # type: str + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-06-01")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[_models.PolicyDefinition] - request = build_policy_definitions_get_at_management_group_request( policy_definition_name=policy_definition_name, management_group_id=management_group_id, api_version=api_version, - template_url=self.get_at_management_group.metadata['url'], + template_url=self.get_at_management_group.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) - deserialized = self._deserialize('PolicyDefinition', pipeline_response) + deserialized = self._deserialize("PolicyDefinition", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - get_at_management_group.metadata = {'url': "/providers/Microsoft.Management/managementGroups/{managementGroupId}/providers/Microsoft.Authorization/policyDefinitions/{policyDefinitionName}"} # type: ignore - + get_at_management_group.metadata = {"url": "/providers/Microsoft.Management/managementGroups/{managementGroupId}/providers/Microsoft.Authorization/policyDefinitions/{policyDefinitionName}"} # type: ignore @distributed_trace def list( - self, - filter: Optional[str] = None, - top: Optional[int] = None, - **kwargs: Any - ) -> AsyncIterable["_models.PolicyDefinitionListResult"]: + self, filter: Optional[str] = None, top: Optional[int] = None, **kwargs: Any + ) -> AsyncIterable["_models.PolicyDefinition"]: """Retrieves policy definitions in a subscription. This operation retrieves a list of all the policy definitions in a given subscription that @@ -1720,44 +2194,45 @@ def list( :param top: Maximum number of records to return. When the $top filter is not provided, it will return 500 records. Default value is None. :type top: int - :keyword api_version: Api Version. Default value is "2021-06-01". Note that overriding this - default value may result in unsupported behavior. - :paramtype api_version: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either PolicyDefinitionListResult or the result of - cls(response) + :return: An iterator like instance of either PolicyDefinition or the result of cls(response) :rtype: - ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.resource.policy.v2021_06_01.models.PolicyDefinitionListResult] - :raises: ~azure.core.exceptions.HttpResponseError + ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.resource.policy.v2021_06_01.models.PolicyDefinition] + :raises ~azure.core.exceptions.HttpResponseError: """ - api_version = kwargs.pop('api_version', "2021-06-01") # type: str + _headers = 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: str + cls = kwargs.pop("cls", None) # type: ClsType[_models.PolicyDefinitionListResult] - cls = kwargs.pop('cls', None) # type: ClsType["_models.PolicyDefinitionListResult"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) + def prepare_request(next_link=None): if not next_link: - + request = build_policy_definitions_list_request( subscription_id=self._config.subscription_id, - api_version=api_version, filter=filter, top=top, - template_url=self.list.metadata['url'], + 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.url = self._client.format_url(request.url) # type: ignore else: - - request = build_policy_definitions_list_request( - subscription_id=self._config.subscription_id, - template_url=next_link, - ) + request = HttpRequest("GET", next_link) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore request.method = "GET" return request @@ -1771,10 +2246,8 @@ async def extract_data(pipeline_response): async def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) response = pipeline_response.http_response @@ -1784,19 +2257,14 @@ async def get_next(next_link=None): return pipeline_response + return AsyncItemPaged(get_next, extract_data) - return AsyncItemPaged( - get_next, extract_data - ) - list.metadata = {'url': "/subscriptions/{subscriptionId}/providers/Microsoft.Authorization/policyDefinitions"} # type: ignore + list.metadata = {"url": "/subscriptions/{subscriptionId}/providers/Microsoft.Authorization/policyDefinitions"} # type: ignore @distributed_trace def list_built_in( - self, - filter: Optional[str] = None, - top: Optional[int] = None, - **kwargs: Any - ) -> AsyncIterable["_models.PolicyDefinitionListResult"]: + self, filter: Optional[str] = None, top: Optional[int] = None, **kwargs: Any + ) -> AsyncIterable["_models.PolicyDefinition"]: """Retrieve built-in policy definitions. This operation retrieves a list of all the built-in policy definitions that match the optional @@ -1817,42 +2285,44 @@ def list_built_in( :param top: Maximum number of records to return. When the $top filter is not provided, it will return 500 records. Default value is None. :type top: int - :keyword api_version: Api Version. Default value is "2021-06-01". Note that overriding this - default value may result in unsupported behavior. - :paramtype api_version: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either PolicyDefinitionListResult or the result of - cls(response) + :return: An iterator like instance of either PolicyDefinition or the result of cls(response) :rtype: - ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.resource.policy.v2021_06_01.models.PolicyDefinitionListResult] - :raises: ~azure.core.exceptions.HttpResponseError + ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.resource.policy.v2021_06_01.models.PolicyDefinition] + :raises ~azure.core.exceptions.HttpResponseError: """ - api_version = kwargs.pop('api_version', "2021-06-01") # type: str + _headers = 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: str + cls = kwargs.pop("cls", None) # type: ClsType[_models.PolicyDefinitionListResult] - cls = kwargs.pop('cls', None) # type: ClsType["_models.PolicyDefinitionListResult"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) + def prepare_request(next_link=None): if not next_link: - + request = build_policy_definitions_list_built_in_request( - api_version=api_version, filter=filter, top=top, - template_url=self.list_built_in.metadata['url'], + api_version=api_version, + template_url=self.list_built_in.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore else: - - request = build_policy_definitions_list_built_in_request( - template_url=next_link, - ) + request = HttpRequest("GET", next_link) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore request.method = "GET" return request @@ -1866,10 +2336,8 @@ async def extract_data(pipeline_response): async def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) response = pipeline_response.http_response @@ -1879,20 +2347,14 @@ async def get_next(next_link=None): return pipeline_response + return AsyncItemPaged(get_next, extract_data) - return AsyncItemPaged( - get_next, extract_data - ) - list_built_in.metadata = {'url': "/providers/Microsoft.Authorization/policyDefinitions"} # type: ignore + list_built_in.metadata = {"url": "/providers/Microsoft.Authorization/policyDefinitions"} # type: ignore @distributed_trace def list_by_management_group( - self, - management_group_id: str, - filter: Optional[str] = None, - top: Optional[int] = None, - **kwargs: Any - ) -> AsyncIterable["_models.PolicyDefinitionListResult"]: + self, management_group_id: str, filter: Optional[str] = None, top: Optional[int] = None, **kwargs: Any + ) -> AsyncIterable["_models.PolicyDefinition"]: """Retrieve policy definitions in a management group. This operation retrieves a list of all the policy definitions in a given management group that @@ -1907,7 +2369,7 @@ def list_by_management_group( provided, the returned list only includes all policy definitions whose category match the {value}. - :param management_group_id: The ID of the management group. + :param management_group_id: The ID of the management group. Required. :type management_group_id: str :param filter: The filter to apply on the operation. Valid values for $filter are: 'atExactScope()', 'policyType -eq {value}' or 'category eq '{value}''. If $filter is not @@ -1921,44 +2383,45 @@ def list_by_management_group( :param top: Maximum number of records to return. When the $top filter is not provided, it will return 500 records. Default value is None. :type top: int - :keyword api_version: Api Version. Default value is "2021-06-01". Note that overriding this - default value may result in unsupported behavior. - :paramtype api_version: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either PolicyDefinitionListResult or the result of - cls(response) + :return: An iterator like instance of either PolicyDefinition or the result of cls(response) :rtype: - ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.resource.policy.v2021_06_01.models.PolicyDefinitionListResult] - :raises: ~azure.core.exceptions.HttpResponseError + ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.resource.policy.v2021_06_01.models.PolicyDefinition] + :raises ~azure.core.exceptions.HttpResponseError: """ - api_version = kwargs.pop('api_version', "2021-06-01") # type: str + _headers = 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: str + cls = kwargs.pop("cls", None) # type: ClsType[_models.PolicyDefinitionListResult] - cls = kwargs.pop('cls', None) # type: ClsType["_models.PolicyDefinitionListResult"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) + def prepare_request(next_link=None): if not next_link: - + request = build_policy_definitions_list_by_management_group_request( management_group_id=management_group_id, - api_version=api_version, filter=filter, top=top, - template_url=self.list_by_management_group.metadata['url'], + api_version=api_version, + template_url=self.list_by_management_group.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore else: - - request = build_policy_definitions_list_by_management_group_request( - management_group_id=management_group_id, - template_url=next_link, - ) + request = HttpRequest("GET", next_link) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore request.method = "GET" return request @@ -1972,10 +2435,8 @@ async def extract_data(pipeline_response): async def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) response = pipeline_response.http_response @@ -1985,67 +2446,123 @@ async def get_next(next_link=None): return pipeline_response + return AsyncItemPaged(get_next, extract_data) - return AsyncItemPaged( - get_next, extract_data - ) - list_by_management_group.metadata = {'url': "/providers/Microsoft.Management/managementGroups/{managementGroupId}/providers/Microsoft.Authorization/policyDefinitions"} # type: ignore -class PolicySetDefinitionsOperations: - """PolicySetDefinitionsOperations async operations. + list_by_management_group.metadata = {"url": "/providers/Microsoft.Management/managementGroups/{managementGroupId}/providers/Microsoft.Authorization/policyDefinitions"} # type: ignore - You should not instantiate this class directly. Instead, you should create a Client instance that - instantiates it for you and attaches it as an attribute. - :ivar models: Alias to model classes used in this operation group. - :type models: ~azure.mgmt.resource.policy.v2021_06_01.models - :param client: Client for service requests. - :param config: Configuration of service client. - :param serializer: An object model serializer. - :param deserializer: An object model deserializer. +class PolicySetDefinitionsOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. + + Instead, you should access the following operations through + :class:`~azure.mgmt.resource.policy.v2021_06_01.aio.PolicyClient`'s + :attr:`policy_set_definitions` attribute. """ models = _models - def __init__(self, client, config, serializer, deserializer) -> None: - self._client = client - self._serialize = serializer - self._deserialize = deserializer - self._config = config + def __init__(self, *args, **kwargs) -> None: + input_args = list(args) + self._client = input_args.pop(0) if input_args else kwargs.pop("client") + self._config = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") - @distributed_trace_async + @overload async def create_or_update( self, policy_set_definition_name: str, - parameters: "_models.PolicySetDefinition", + parameters: _models.PolicySetDefinition, + *, + content_type: str = "application/json", **kwargs: Any - ) -> "_models.PolicySetDefinition": + ) -> _models.PolicySetDefinition: """Creates or updates a policy set definition. This operation creates or updates a policy set definition in the given subscription with the given name. - :param policy_set_definition_name: The name of the policy set definition to create. + :param policy_set_definition_name: The name of the policy set definition to create. Required. :type policy_set_definition_name: str - :param parameters: The policy set definition properties. + :param parameters: The policy set definition properties. Required. :type parameters: ~azure.mgmt.resource.policy.v2021_06_01.models.PolicySetDefinition - :keyword api_version: Api Version. Default value is "2021-06-01". Note that overriding this - default value may result in unsupported behavior. - :paramtype api_version: str + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: PolicySetDefinition, or the result of cls(response) + :return: PolicySetDefinition or the result of cls(response) :rtype: ~azure.mgmt.resource.policy.v2021_06_01.models.PolicySetDefinition - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + async def create_or_update( + self, policy_set_definition_name: str, parameters: IO, *, content_type: str = "application/json", **kwargs: Any + ) -> _models.PolicySetDefinition: + """Creates or updates a policy set definition. + + This operation creates or updates a policy set definition in the given subscription with the + given name. + + :param policy_set_definition_name: The name of the policy set definition to create. Required. + :type policy_set_definition_name: str + :param parameters: The policy set definition properties. Required. + :type parameters: IO + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: PolicySetDefinition or the result of cls(response) + :rtype: ~azure.mgmt.resource.policy.v2021_06_01.models.PolicySetDefinition + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace_async + async def create_or_update( + self, policy_set_definition_name: str, parameters: Union[_models.PolicySetDefinition, IO], **kwargs: Any + ) -> _models.PolicySetDefinition: + """Creates or updates a policy set definition. + + This operation creates or updates a policy set definition in the given subscription with the + given name. + + :param policy_set_definition_name: The name of the policy set definition to create. Required. + :type policy_set_definition_name: str + :param parameters: The policy set definition properties. Is either a model type or a IO type. + Required. + :type parameters: ~azure.mgmt.resource.policy.v2021_06_01.models.PolicySetDefinition or IO + :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. + Default value is None. + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: PolicySetDefinition or the result of cls(response) + :rtype: ~azure.mgmt.resource.policy.v2021_06_01.models.PolicySetDefinition + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.PolicySetDefinition"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', "2021-06-01") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-06-01")) # type: str + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.PolicySetDefinition] - _json = self._serialize.body(parameters, 'PolicySetDefinition') + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(parameters, (IO, bytes)): + _content = parameters + else: + _json = self._serialize.body(parameters, "PolicySetDefinition") request = build_policy_set_definitions_create_or_update_request( policy_set_definition_name=policy_set_definition_name, @@ -2053,16 +2570,18 @@ async def create_or_update( api_version=api_version, content_type=content_type, json=_json, - template_url=self.create_or_update.metadata['url'], + content=_content, + template_url=self.create_or_update.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200, 201]: @@ -2070,62 +2589,62 @@ async def create_or_update( raise HttpResponseError(response=response, error_format=ARMErrorFormat) if response.status_code == 200: - deserialized = self._deserialize('PolicySetDefinition', pipeline_response) + deserialized = self._deserialize("PolicySetDefinition", pipeline_response) if response.status_code == 201: - deserialized = self._deserialize('PolicySetDefinition', pipeline_response) + deserialized = self._deserialize("PolicySetDefinition", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - create_or_update.metadata = {'url': "/subscriptions/{subscriptionId}/providers/Microsoft.Authorization/policySetDefinitions/{policySetDefinitionName}"} # type: ignore - + create_or_update.metadata = {"url": "/subscriptions/{subscriptionId}/providers/Microsoft.Authorization/policySetDefinitions/{policySetDefinitionName}"} # type: ignore @distributed_trace_async async def delete( # pylint: disable=inconsistent-return-statements - self, - policy_set_definition_name: str, - **kwargs: Any + self, policy_set_definition_name: str, **kwargs: Any ) -> None: """Deletes a policy set definition. This operation deletes the policy set definition in the given subscription with the given name. - :param policy_set_definition_name: The name of the policy set definition to delete. + :param policy_set_definition_name: The name of the policy set definition to delete. Required. :type policy_set_definition_name: str - :keyword api_version: Api Version. Default value is "2021-06-01". Note that overriding this - default value may result in unsupported behavior. - :paramtype api_version: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: None, or the result of cls(response) + :return: None or the result of cls(response) :rtype: None - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType[None] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + 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', "2021-06-01") # type: str + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-06-01")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[None] - request = build_policy_set_definitions_delete_request( policy_set_definition_name=policy_set_definition_name, subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.delete.metadata['url'], + template_url=self.delete.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200, 204]: @@ -2135,134 +2654,126 @@ async def delete( # pylint: disable=inconsistent-return-statements if cls: return cls(pipeline_response, None, {}) - delete.metadata = {'url': "/subscriptions/{subscriptionId}/providers/Microsoft.Authorization/policySetDefinitions/{policySetDefinitionName}"} # type: ignore - + delete.metadata = {"url": "/subscriptions/{subscriptionId}/providers/Microsoft.Authorization/policySetDefinitions/{policySetDefinitionName}"} # type: ignore @distributed_trace_async - async def get( - self, - policy_set_definition_name: str, - **kwargs: Any - ) -> "_models.PolicySetDefinition": + async def get(self, policy_set_definition_name: str, **kwargs: Any) -> _models.PolicySetDefinition: """Retrieves a policy set definition. This operation retrieves the policy set definition in the given subscription with the given name. - :param policy_set_definition_name: The name of the policy set definition to get. + :param policy_set_definition_name: The name of the policy set definition to get. Required. :type policy_set_definition_name: str - :keyword api_version: Api Version. Default value is "2021-06-01". Note that overriding this - default value may result in unsupported behavior. - :paramtype api_version: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: PolicySetDefinition, or the result of cls(response) + :return: PolicySetDefinition or the result of cls(response) :rtype: ~azure.mgmt.resource.policy.v2021_06_01.models.PolicySetDefinition - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.PolicySetDefinition"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + 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', "2021-06-01") # type: str + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-06-01")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[_models.PolicySetDefinition] - request = build_policy_set_definitions_get_request( policy_set_definition_name=policy_set_definition_name, subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.get.metadata['url'], + template_url=self.get.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) - deserialized = self._deserialize('PolicySetDefinition', pipeline_response) + deserialized = self._deserialize("PolicySetDefinition", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - get.metadata = {'url': "/subscriptions/{subscriptionId}/providers/Microsoft.Authorization/policySetDefinitions/{policySetDefinitionName}"} # type: ignore - + get.metadata = {"url": "/subscriptions/{subscriptionId}/providers/Microsoft.Authorization/policySetDefinitions/{policySetDefinitionName}"} # type: ignore @distributed_trace_async - async def get_built_in( - self, - policy_set_definition_name: str, - **kwargs: Any - ) -> "_models.PolicySetDefinition": + async def get_built_in(self, policy_set_definition_name: str, **kwargs: Any) -> _models.PolicySetDefinition: """Retrieves a built in policy set definition. This operation retrieves the built-in policy set definition with the given name. - :param policy_set_definition_name: The name of the policy set definition to get. + :param policy_set_definition_name: The name of the policy set definition to get. Required. :type policy_set_definition_name: str - :keyword api_version: Api Version. Default value is "2021-06-01". Note that overriding this - default value may result in unsupported behavior. - :paramtype api_version: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: PolicySetDefinition, or the result of cls(response) + :return: PolicySetDefinition or the result of cls(response) :rtype: ~azure.mgmt.resource.policy.v2021_06_01.models.PolicySetDefinition - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.PolicySetDefinition"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + 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', "2021-06-01") # type: str + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-06-01")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[_models.PolicySetDefinition] - request = build_policy_set_definitions_get_built_in_request( policy_set_definition_name=policy_set_definition_name, api_version=api_version, - template_url=self.get_built_in.metadata['url'], + template_url=self.get_built_in.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) - deserialized = self._deserialize('PolicySetDefinition', pipeline_response) + deserialized = self._deserialize("PolicySetDefinition", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - get_built_in.metadata = {'url': "/providers/Microsoft.Authorization/policySetDefinitions/{policySetDefinitionName}"} # type: ignore - + get_built_in.metadata = {"url": "/providers/Microsoft.Authorization/policySetDefinitions/{policySetDefinitionName}"} # type: ignore @distributed_trace def list( - self, - filter: Optional[str] = None, - top: Optional[int] = None, - **kwargs: Any - ) -> AsyncIterable["_models.PolicySetDefinitionListResult"]: + self, filter: Optional[str] = None, top: Optional[int] = None, **kwargs: Any + ) -> AsyncIterable["_models.PolicySetDefinition"]: """Retrieves the policy set definitions for a subscription. This operation retrieves a list of all the policy set definitions in a given subscription that @@ -2288,44 +2799,45 @@ def list( :param top: Maximum number of records to return. When the $top filter is not provided, it will return 500 records. Default value is None. :type top: int - :keyword api_version: Api Version. Default value is "2021-06-01". Note that overriding this - default value may result in unsupported behavior. - :paramtype api_version: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either PolicySetDefinitionListResult or the result of - cls(response) + :return: An iterator like instance of either PolicySetDefinition or the result of cls(response) :rtype: - ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.resource.policy.v2021_06_01.models.PolicySetDefinitionListResult] - :raises: ~azure.core.exceptions.HttpResponseError + ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.resource.policy.v2021_06_01.models.PolicySetDefinition] + :raises ~azure.core.exceptions.HttpResponseError: """ - api_version = kwargs.pop('api_version', "2021-06-01") # type: str + _headers = 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: str + cls = kwargs.pop("cls", None) # type: ClsType[_models.PolicySetDefinitionListResult] - cls = kwargs.pop('cls', None) # type: ClsType["_models.PolicySetDefinitionListResult"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) + def prepare_request(next_link=None): if not next_link: - + request = build_policy_set_definitions_list_request( subscription_id=self._config.subscription_id, - api_version=api_version, filter=filter, top=top, - template_url=self.list.metadata['url'], + 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.url = self._client.format_url(request.url) # type: ignore else: - - request = build_policy_set_definitions_list_request( - subscription_id=self._config.subscription_id, - template_url=next_link, - ) + request = HttpRequest("GET", next_link) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore request.method = "GET" return request @@ -2339,10 +2851,8 @@ async def extract_data(pipeline_response): async def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) response = pipeline_response.http_response @@ -2352,19 +2862,14 @@ async def get_next(next_link=None): return pipeline_response + return AsyncItemPaged(get_next, extract_data) - return AsyncItemPaged( - get_next, extract_data - ) - list.metadata = {'url': "/subscriptions/{subscriptionId}/providers/Microsoft.Authorization/policySetDefinitions"} # type: ignore + list.metadata = {"url": "/subscriptions/{subscriptionId}/providers/Microsoft.Authorization/policySetDefinitions"} # type: ignore @distributed_trace def list_built_in( - self, - filter: Optional[str] = None, - top: Optional[int] = None, - **kwargs: Any - ) -> AsyncIterable["_models.PolicySetDefinitionListResult"]: + self, filter: Optional[str] = None, top: Optional[int] = None, **kwargs: Any + ) -> AsyncIterable["_models.PolicySetDefinition"]: """Retrieves built-in policy set definitions. This operation retrieves a list of all the built-in policy set definitions that match the @@ -2383,42 +2888,44 @@ def list_built_in( :param top: Maximum number of records to return. When the $top filter is not provided, it will return 500 records. Default value is None. :type top: int - :keyword api_version: Api Version. Default value is "2021-06-01". Note that overriding this - default value may result in unsupported behavior. - :paramtype api_version: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either PolicySetDefinitionListResult or the result of - cls(response) + :return: An iterator like instance of either PolicySetDefinition or the result of cls(response) :rtype: - ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.resource.policy.v2021_06_01.models.PolicySetDefinitionListResult] - :raises: ~azure.core.exceptions.HttpResponseError + ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.resource.policy.v2021_06_01.models.PolicySetDefinition] + :raises ~azure.core.exceptions.HttpResponseError: """ - api_version = kwargs.pop('api_version', "2021-06-01") # type: str + _headers = 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: str + cls = kwargs.pop("cls", None) # type: ClsType[_models.PolicySetDefinitionListResult] - cls = kwargs.pop('cls', None) # type: ClsType["_models.PolicySetDefinitionListResult"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) + def prepare_request(next_link=None): if not next_link: - + request = build_policy_set_definitions_list_built_in_request( - api_version=api_version, filter=filter, top=top, - template_url=self.list_built_in.metadata['url'], + api_version=api_version, + template_url=self.list_built_in.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore else: - - request = build_policy_set_definitions_list_built_in_request( - template_url=next_link, - ) + request = HttpRequest("GET", next_link) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore request.method = "GET" return request @@ -2432,10 +2939,8 @@ async def extract_data(pipeline_response): async def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) response = pipeline_response.http_response @@ -2445,49 +2950,120 @@ async def get_next(next_link=None): return pipeline_response + return AsyncItemPaged(get_next, extract_data) - return AsyncItemPaged( - get_next, extract_data - ) - list_built_in.metadata = {'url': "/providers/Microsoft.Authorization/policySetDefinitions"} # type: ignore + list_built_in.metadata = {"url": "/providers/Microsoft.Authorization/policySetDefinitions"} # type: ignore - @distributed_trace_async + @overload async def create_or_update_at_management_group( self, policy_set_definition_name: str, management_group_id: str, - parameters: "_models.PolicySetDefinition", + parameters: _models.PolicySetDefinition, + *, + content_type: str = "application/json", **kwargs: Any - ) -> "_models.PolicySetDefinition": + ) -> _models.PolicySetDefinition: """Creates or updates a policy set definition. This operation creates or updates a policy set definition in the given management group with the given name. - :param policy_set_definition_name: The name of the policy set definition to create. + :param policy_set_definition_name: The name of the policy set definition to create. Required. :type policy_set_definition_name: str - :param management_group_id: The ID of the management group. + :param management_group_id: The ID of the management group. Required. :type management_group_id: str - :param parameters: The policy set definition properties. + :param parameters: The policy set definition properties. Required. :type parameters: ~azure.mgmt.resource.policy.v2021_06_01.models.PolicySetDefinition - :keyword api_version: Api Version. Default value is "2021-06-01". Note that overriding this - default value may result in unsupported behavior. - :paramtype api_version: str + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: PolicySetDefinition or the result of cls(response) + :rtype: ~azure.mgmt.resource.policy.v2021_06_01.models.PolicySetDefinition + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + async def create_or_update_at_management_group( + self, + policy_set_definition_name: str, + management_group_id: str, + parameters: IO, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.PolicySetDefinition: + """Creates or updates a policy set definition. + + This operation creates or updates a policy set definition in the given management group with + the given name. + + :param policy_set_definition_name: The name of the policy set definition to create. Required. + :type policy_set_definition_name: str + :param management_group_id: The ID of the management group. Required. + :type management_group_id: str + :param parameters: The policy set definition properties. Required. + :type parameters: IO + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: PolicySetDefinition or the result of cls(response) + :rtype: ~azure.mgmt.resource.policy.v2021_06_01.models.PolicySetDefinition + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace_async + async def create_or_update_at_management_group( + self, + policy_set_definition_name: str, + management_group_id: str, + parameters: Union[_models.PolicySetDefinition, IO], + **kwargs: Any + ) -> _models.PolicySetDefinition: + """Creates or updates a policy set definition. + + This operation creates or updates a policy set definition in the given management group with + the given name. + + :param policy_set_definition_name: The name of the policy set definition to create. Required. + :type policy_set_definition_name: str + :param management_group_id: The ID of the management group. Required. + :type management_group_id: str + :param parameters: The policy set definition properties. Is either a model type or a IO type. + Required. + :type parameters: ~azure.mgmt.resource.policy.v2021_06_01.models.PolicySetDefinition or IO + :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. + Default value is None. + :paramtype content_type: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: PolicySetDefinition, or the result of cls(response) + :return: PolicySetDefinition or the result of cls(response) :rtype: ~azure.mgmt.resource.policy.v2021_06_01.models.PolicySetDefinition - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.PolicySetDefinition"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', "2021-06-01") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-06-01")) # type: str + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.PolicySetDefinition] - _json = self._serialize.body(parameters, 'PolicySetDefinition') + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(parameters, (IO, bytes)): + _content = parameters + else: + _json = self._serialize.body(parameters, "PolicySetDefinition") request = build_policy_set_definitions_create_or_update_at_management_group_request( policy_set_definition_name=policy_set_definition_name, @@ -2495,16 +3071,18 @@ async def create_or_update_at_management_group( api_version=api_version, content_type=content_type, json=_json, - template_url=self.create_or_update_at_management_group.metadata['url'], + content=_content, + template_url=self.create_or_update_at_management_group.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200, 201]: @@ -2512,66 +3090,65 @@ async def create_or_update_at_management_group( raise HttpResponseError(response=response, error_format=ARMErrorFormat) if response.status_code == 200: - deserialized = self._deserialize('PolicySetDefinition', pipeline_response) + deserialized = self._deserialize("PolicySetDefinition", pipeline_response) if response.status_code == 201: - deserialized = self._deserialize('PolicySetDefinition', pipeline_response) + deserialized = self._deserialize("PolicySetDefinition", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - create_or_update_at_management_group.metadata = {'url': "/providers/Microsoft.Management/managementGroups/{managementGroupId}/providers/Microsoft.Authorization/policySetDefinitions/{policySetDefinitionName}"} # type: ignore - + create_or_update_at_management_group.metadata = {"url": "/providers/Microsoft.Management/managementGroups/{managementGroupId}/providers/Microsoft.Authorization/policySetDefinitions/{policySetDefinitionName}"} # type: ignore @distributed_trace_async async def delete_at_management_group( # pylint: disable=inconsistent-return-statements - self, - policy_set_definition_name: str, - management_group_id: str, - **kwargs: Any + self, policy_set_definition_name: str, management_group_id: str, **kwargs: Any ) -> None: """Deletes a policy set definition. This operation deletes the policy set definition in the given management group with the given name. - :param policy_set_definition_name: The name of the policy set definition to delete. + :param policy_set_definition_name: The name of the policy set definition to delete. Required. :type policy_set_definition_name: str - :param management_group_id: The ID of the management group. + :param management_group_id: The ID of the management group. Required. :type management_group_id: str - :keyword api_version: Api Version. Default value is "2021-06-01". Note that overriding this - default value may result in unsupported behavior. - :paramtype api_version: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: None, or the result of cls(response) + :return: None or the result of cls(response) :rtype: None - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType[None] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) - api_version = kwargs.pop('api_version', "2021-06-01") # type: str + _headers = 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: str + cls = kwargs.pop("cls", None) # type: ClsType[None] - request = build_policy_set_definitions_delete_at_management_group_request( policy_set_definition_name=policy_set_definition_name, management_group_id=management_group_id, api_version=api_version, - template_url=self.delete_at_management_group.metadata['url'], + template_url=self.delete_at_management_group.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200, 204]: @@ -2581,80 +3158,74 @@ async def delete_at_management_group( # pylint: disable=inconsistent-return-sta if cls: return cls(pipeline_response, None, {}) - delete_at_management_group.metadata = {'url': "/providers/Microsoft.Management/managementGroups/{managementGroupId}/providers/Microsoft.Authorization/policySetDefinitions/{policySetDefinitionName}"} # type: ignore - + delete_at_management_group.metadata = {"url": "/providers/Microsoft.Management/managementGroups/{managementGroupId}/providers/Microsoft.Authorization/policySetDefinitions/{policySetDefinitionName}"} # type: ignore @distributed_trace_async async def get_at_management_group( - self, - policy_set_definition_name: str, - management_group_id: str, - **kwargs: Any - ) -> "_models.PolicySetDefinition": + self, policy_set_definition_name: str, management_group_id: str, **kwargs: Any + ) -> _models.PolicySetDefinition: """Retrieves a policy set definition. This operation retrieves the policy set definition in the given management group with the given name. - :param policy_set_definition_name: The name of the policy set definition to get. + :param policy_set_definition_name: The name of the policy set definition to get. Required. :type policy_set_definition_name: str - :param management_group_id: The ID of the management group. + :param management_group_id: The ID of the management group. Required. :type management_group_id: str - :keyword api_version: Api Version. Default value is "2021-06-01". Note that overriding this - default value may result in unsupported behavior. - :paramtype api_version: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: PolicySetDefinition, or the result of cls(response) + :return: PolicySetDefinition or the result of cls(response) :rtype: ~azure.mgmt.resource.policy.v2021_06_01.models.PolicySetDefinition - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.PolicySetDefinition"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + 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', "2021-06-01") # type: str + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-06-01")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[_models.PolicySetDefinition] - request = build_policy_set_definitions_get_at_management_group_request( policy_set_definition_name=policy_set_definition_name, management_group_id=management_group_id, api_version=api_version, - template_url=self.get_at_management_group.metadata['url'], + template_url=self.get_at_management_group.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) - deserialized = self._deserialize('PolicySetDefinition', pipeline_response) + deserialized = self._deserialize("PolicySetDefinition", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - get_at_management_group.metadata = {'url': "/providers/Microsoft.Management/managementGroups/{managementGroupId}/providers/Microsoft.Authorization/policySetDefinitions/{policySetDefinitionName}"} # type: ignore - + get_at_management_group.metadata = {"url": "/providers/Microsoft.Management/managementGroups/{managementGroupId}/providers/Microsoft.Authorization/policySetDefinitions/{policySetDefinitionName}"} # type: ignore @distributed_trace def list_by_management_group( - self, - management_group_id: str, - filter: Optional[str] = None, - top: Optional[int] = None, - **kwargs: Any - ) -> AsyncIterable["_models.PolicySetDefinitionListResult"]: + self, management_group_id: str, filter: Optional[str] = None, top: Optional[int] = None, **kwargs: Any + ) -> AsyncIterable["_models.PolicySetDefinition"]: """Retrieves all policy set definitions in management group. This operation retrieves a list of all the policy set definitions in a given management group @@ -2669,7 +3240,7 @@ def list_by_management_group( provided, the returned list only includes all policy set definitions whose category match the {value}. - :param management_group_id: The ID of the management group. + :param management_group_id: The ID of the management group. Required. :type management_group_id: str :param filter: The filter to apply on the operation. Valid values for $filter are: 'atExactScope()', 'policyType -eq {value}' or 'category eq '{value}''. If $filter is not @@ -2683,44 +3254,45 @@ def list_by_management_group( :param top: Maximum number of records to return. When the $top filter is not provided, it will return 500 records. Default value is None. :type top: int - :keyword api_version: Api Version. Default value is "2021-06-01". Note that overriding this - default value may result in unsupported behavior. - :paramtype api_version: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either PolicySetDefinitionListResult or the result of - cls(response) + :return: An iterator like instance of either PolicySetDefinition or the result of cls(response) :rtype: - ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.resource.policy.v2021_06_01.models.PolicySetDefinitionListResult] - :raises: ~azure.core.exceptions.HttpResponseError + ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.resource.policy.v2021_06_01.models.PolicySetDefinition] + :raises ~azure.core.exceptions.HttpResponseError: """ - api_version = kwargs.pop('api_version', "2021-06-01") # type: str + _headers = 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: str + cls = kwargs.pop("cls", None) # type: ClsType[_models.PolicySetDefinitionListResult] - cls = kwargs.pop('cls', None) # type: ClsType["_models.PolicySetDefinitionListResult"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) + def prepare_request(next_link=None): if not next_link: - + request = build_policy_set_definitions_list_by_management_group_request( management_group_id=management_group_id, - api_version=api_version, filter=filter, top=top, - template_url=self.list_by_management_group.metadata['url'], + api_version=api_version, + template_url=self.list_by_management_group.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore else: - - request = build_policy_set_definitions_list_by_management_group_request( - management_group_id=management_group_id, - template_url=next_link, - ) + request = HttpRequest("GET", next_link) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore request.method = "GET" return request @@ -2734,10 +3306,8 @@ async def extract_data(pipeline_response): async def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) response = pipeline_response.http_response @@ -2747,39 +3317,33 @@ async def get_next(next_link=None): return pipeline_response + return AsyncItemPaged(get_next, extract_data) + + list_by_management_group.metadata = {"url": "/providers/Microsoft.Management/managementGroups/{managementGroupId}/providers/Microsoft.Authorization/policySetDefinitions"} # type: ignore - return AsyncItemPaged( - get_next, extract_data - ) - list_by_management_group.metadata = {'url': "/providers/Microsoft.Management/managementGroups/{managementGroupId}/providers/Microsoft.Authorization/policySetDefinitions"} # type: ignore -class PolicyExemptionsOperations: - """PolicyExemptionsOperations async operations. - You should not instantiate this class directly. Instead, you should create a Client instance that - instantiates it for you and attaches it as an attribute. +class PolicyExemptionsOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. - :ivar models: Alias to model classes used in this operation group. - :type models: ~azure.mgmt.resource.policy.v2021_06_01.models - :param client: Client for service requests. - :param config: Configuration of service client. - :param serializer: An object model serializer. - :param deserializer: An object model deserializer. + Instead, you should access the following operations through + :class:`~azure.mgmt.resource.policy.v2021_06_01.aio.PolicyClient`'s + :attr:`policy_exemptions` attribute. """ models = _models - def __init__(self, client, config, serializer, deserializer) -> None: - self._client = client - self._serialize = serializer - self._deserialize = deserializer - self._config = config + def __init__(self, *args, **kwargs) -> None: + input_args = list(args) + self._client = input_args.pop(0) if input_args else kwargs.pop("client") + self._config = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") @distributed_trace_async async def delete( # pylint: disable=inconsistent-return-statements - self, - scope: str, - policy_exemption_name: str, - **kwargs: Any + self, scope: str, policy_exemption_name: str, **kwargs: Any ) -> None: """Deletes a policy exemption. @@ -2792,40 +3356,44 @@ async def delete( # pylint: disable=inconsistent-return-statements '/subscriptions/{subscriptionId}'), resource group (format: '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}', or resource (format: '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{resourceProviderNamespace}/[{parentResourcePath}/]{resourceType}/{resourceName}'. + Required. :type scope: str - :param policy_exemption_name: The name of the policy exemption to delete. + :param policy_exemption_name: The name of the policy exemption to delete. Required. :type policy_exemption_name: str - :keyword api_version: Api Version. Default value is "2020-07-01-preview". Note that overriding - this default value may result in unsupported behavior. - :paramtype api_version: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: None, or the result of cls(response) + :return: None or the result of cls(response) :rtype: None - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType[None] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) - api_version = kwargs.pop('api_version', "2020-07-01-preview") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2020-07-01-preview")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[None] - request = build_policy_exemptions_delete_request( scope=scope, policy_exemption_name=policy_exemption_name, api_version=api_version, - template_url=self.delete.metadata['url'], + template_url=self.delete.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200, 204]: @@ -2835,17 +3403,18 @@ async def delete( # pylint: disable=inconsistent-return-statements if cls: return cls(pipeline_response, None, {}) - delete.metadata = {'url': "/{scope}/providers/Microsoft.Authorization/policyExemptions/{policyExemptionName}"} # type: ignore + delete.metadata = {"url": "/{scope}/providers/Microsoft.Authorization/policyExemptions/{policyExemptionName}"} # type: ignore - - @distributed_trace_async + @overload async def create_or_update( self, scope: str, policy_exemption_name: str, - parameters: "_models.PolicyExemption", + parameters: _models.PolicyExemption, + *, + content_type: str = "application/json", **kwargs: Any - ) -> "_models.PolicyExemption": + ) -> _models.PolicyExemption: """Creates or updates a policy exemption. This operation creates or updates a policy exemption with the given scope and name. Policy @@ -2858,29 +3427,111 @@ async def create_or_update( '/subscriptions/{subscriptionId}'), resource group (format: '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}', or resource (format: '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{resourceProviderNamespace}/[{parentResourcePath}/]{resourceType}/{resourceName}'. + Required. :type scope: str - :param policy_exemption_name: The name of the policy exemption to delete. + :param policy_exemption_name: The name of the policy exemption to delete. Required. :type policy_exemption_name: str - :param parameters: Parameters for the policy exemption. + :param parameters: Parameters for the policy exemption. Required. :type parameters: ~azure.mgmt.resource.policy.v2021_06_01.models.PolicyExemption - :keyword api_version: Api Version. Default value is "2020-07-01-preview". Note that overriding - this default value may result in unsupported behavior. - :paramtype api_version: str + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: PolicyExemption or the result of cls(response) + :rtype: ~azure.mgmt.resource.policy.v2021_06_01.models.PolicyExemption + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + async def create_or_update( + self, + scope: str, + policy_exemption_name: str, + parameters: IO, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.PolicyExemption: + """Creates or updates a policy exemption. + + This operation creates or updates a policy exemption with the given scope and name. Policy + exemptions apply to all resources contained within their scope. For example, when you create a + policy exemption at resource group scope for a policy assignment at the same or above level, + the exemption exempts to all applicable resources in the resource group. + + :param scope: The scope of the policy exemption. Valid scopes are: management group (format: + '/providers/Microsoft.Management/managementGroups/{managementGroup}'), subscription (format: + '/subscriptions/{subscriptionId}'), resource group (format: + '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}', or resource (format: + '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{resourceProviderNamespace}/[{parentResourcePath}/]{resourceType}/{resourceName}'. + Required. + :type scope: str + :param policy_exemption_name: The name of the policy exemption to delete. Required. + :type policy_exemption_name: str + :param parameters: Parameters for the policy exemption. Required. + :type parameters: IO + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: PolicyExemption or the result of cls(response) + :rtype: ~azure.mgmt.resource.policy.v2021_06_01.models.PolicyExemption + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace_async + async def create_or_update( + self, scope: str, policy_exemption_name: str, parameters: Union[_models.PolicyExemption, IO], **kwargs: Any + ) -> _models.PolicyExemption: + """Creates or updates a policy exemption. + + This operation creates or updates a policy exemption with the given scope and name. Policy + exemptions apply to all resources contained within their scope. For example, when you create a + policy exemption at resource group scope for a policy assignment at the same or above level, + the exemption exempts to all applicable resources in the resource group. + + :param scope: The scope of the policy exemption. Valid scopes are: management group (format: + '/providers/Microsoft.Management/managementGroups/{managementGroup}'), subscription (format: + '/subscriptions/{subscriptionId}'), resource group (format: + '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}', or resource (format: + '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{resourceProviderNamespace}/[{parentResourcePath}/]{resourceType}/{resourceName}'. + Required. + :type scope: str + :param policy_exemption_name: The name of the policy exemption to delete. Required. + :type policy_exemption_name: str + :param parameters: Parameters for the policy exemption. Is either a model type or a IO type. + Required. + :type parameters: ~azure.mgmt.resource.policy.v2021_06_01.models.PolicyExemption or IO + :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. + Default value is None. + :paramtype content_type: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: PolicyExemption, or the result of cls(response) + :return: PolicyExemption or the result of cls(response) :rtype: ~azure.mgmt.resource.policy.v2021_06_01.models.PolicyExemption - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.PolicyExemption"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', "2020-07-01-preview") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + api_version = kwargs.pop("api_version", _params.pop("api-version", "2020-07-01-preview")) # type: str + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.PolicyExemption] - _json = self._serialize.body(parameters, 'PolicyExemption') + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(parameters, (IO, bytes)): + _content = parameters + else: + _json = self._serialize.body(parameters, "PolicyExemption") request = build_policy_exemptions_create_or_update_request( scope=scope, @@ -2888,16 +3539,18 @@ async def create_or_update( api_version=api_version, content_type=content_type, json=_json, - template_url=self.create_or_update.metadata['url'], + content=_content, + template_url=self.create_or_update.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200, 201]: @@ -2905,26 +3558,20 @@ async def create_or_update( raise HttpResponseError(response=response, error_format=ARMErrorFormat) if response.status_code == 200: - deserialized = self._deserialize('PolicyExemption', pipeline_response) + deserialized = self._deserialize("PolicyExemption", pipeline_response) if response.status_code == 201: - deserialized = self._deserialize('PolicyExemption', pipeline_response) + deserialized = self._deserialize("PolicyExemption", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - create_or_update.metadata = {'url': "/{scope}/providers/Microsoft.Authorization/policyExemptions/{policyExemptionName}"} # type: ignore - + create_or_update.metadata = {"url": "/{scope}/providers/Microsoft.Authorization/policyExemptions/{policyExemptionName}"} # type: ignore @distributed_trace_async - async def get( - self, - scope: str, - policy_exemption_name: str, - **kwargs: Any - ) -> "_models.PolicyExemption": + async def get(self, scope: str, policy_exemption_name: str, **kwargs: Any) -> _models.PolicyExemption: """Retrieves a policy exemption. This operation retrieves a single policy exemption, given its name and the scope it was created @@ -2935,62 +3582,61 @@ async def get( '/subscriptions/{subscriptionId}'), resource group (format: '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}', or resource (format: '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{resourceProviderNamespace}/[{parentResourcePath}/]{resourceType}/{resourceName}'. + Required. :type scope: str - :param policy_exemption_name: The name of the policy exemption to delete. + :param policy_exemption_name: The name of the policy exemption to delete. Required. :type policy_exemption_name: str - :keyword api_version: Api Version. Default value is "2020-07-01-preview". Note that overriding - this default value may result in unsupported behavior. - :paramtype api_version: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: PolicyExemption, or the result of cls(response) + :return: PolicyExemption or the result of cls(response) :rtype: ~azure.mgmt.resource.policy.v2021_06_01.models.PolicyExemption - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.PolicyExemption"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) - api_version = kwargs.pop('api_version', "2020-07-01-preview") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2020-07-01-preview")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[_models.PolicyExemption] - request = build_policy_exemptions_get_request( scope=scope, policy_exemption_name=policy_exemption_name, api_version=api_version, - template_url=self.get.metadata['url'], + template_url=self.get.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) - deserialized = self._deserialize('PolicyExemption', pipeline_response) + deserialized = self._deserialize("PolicyExemption", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - get.metadata = {'url': "/{scope}/providers/Microsoft.Authorization/policyExemptions/{policyExemptionName}"} # type: ignore - + get.metadata = {"url": "/{scope}/providers/Microsoft.Authorization/policyExemptions/{policyExemptionName}"} # type: ignore @distributed_trace - def list( - self, - filter: Optional[str] = None, - **kwargs: Any - ) -> AsyncIterable["_models.PolicyExemptionListResult"]: + def list(self, filter: Optional[str] = None, **kwargs: Any) -> AsyncIterable["_models.PolicyExemption"]: """Retrieves all policy exemptions that apply to a subscription. This operation retrieves the list of all policy exemptions associated with the given @@ -3013,43 +3659,44 @@ def list( '{value}' is provided. the returned list only includes all policy exemptions that are associated with the give policyAssignmentId. Default value is None. :type filter: str - :keyword api_version: Api Version. Default value is "2020-07-01-preview". Note that overriding - this default value may result in unsupported behavior. - :paramtype api_version: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either PolicyExemptionListResult or the result of - cls(response) + :return: An iterator like instance of either PolicyExemption or the result of cls(response) :rtype: - ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.resource.policy.v2021_06_01.models.PolicyExemptionListResult] - :raises: ~azure.core.exceptions.HttpResponseError + ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.resource.policy.v2021_06_01.models.PolicyExemption] + :raises ~azure.core.exceptions.HttpResponseError: """ - api_version = kwargs.pop('api_version', "2020-07-01-preview") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2020-07-01-preview")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[_models.PolicyExemptionListResult] - cls = kwargs.pop('cls', None) # type: ClsType["_models.PolicyExemptionListResult"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) + def prepare_request(next_link=None): if not next_link: - + request = build_policy_exemptions_list_request( subscription_id=self._config.subscription_id, - api_version=api_version, filter=filter, - template_url=self.list.metadata['url'], + 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.url = self._client.format_url(request.url) # type: ignore else: - - request = build_policy_exemptions_list_request( - subscription_id=self._config.subscription_id, - template_url=next_link, - ) + request = HttpRequest("GET", next_link) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore request.method = "GET" return request @@ -3063,10 +3710,8 @@ async def extract_data(pipeline_response): async def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) response = pipeline_response.http_response @@ -3076,19 +3721,14 @@ async def get_next(next_link=None): return pipeline_response + return AsyncItemPaged(get_next, extract_data) - return AsyncItemPaged( - get_next, extract_data - ) - list.metadata = {'url': "/subscriptions/{subscriptionId}/providers/Microsoft.Authorization/policyExemptions"} # type: ignore + list.metadata = {"url": "/subscriptions/{subscriptionId}/providers/Microsoft.Authorization/policyExemptions"} # type: ignore @distributed_trace def list_for_resource_group( - self, - resource_group_name: str, - filter: Optional[str] = None, - **kwargs: Any - ) -> AsyncIterable["_models.PolicyExemptionListResult"]: + self, resource_group_name: str, filter: Optional[str] = None, **kwargs: Any + ) -> AsyncIterable["_models.PolicyExemption"]: """Retrieves all policy exemptions that apply to a resource group. This operation retrieves the list of all policy exemptions associated with the given resource @@ -3098,7 +3738,7 @@ def list_for_resource_group( resource group, including those that apply directly or apply from containing scopes, as well as any applied to resources contained within the resource group. - :param resource_group_name: The name of the resource group containing the resource. + :param resource_group_name: The name of the resource group containing the resource. Required. :type resource_group_name: str :param filter: The filter to apply on the operation. Valid values for $filter are: 'atScope()', 'atExactScope()', 'excludeExpired()' or 'policyAssignmentId eq '{value}''. If $filter is not @@ -3113,45 +3753,45 @@ def list_for_resource_group( '{value}' is provided. the returned list only includes all policy exemptions that are associated with the give policyAssignmentId. Default value is None. :type filter: str - :keyword api_version: Api Version. Default value is "2020-07-01-preview". Note that overriding - this default value may result in unsupported behavior. - :paramtype api_version: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either PolicyExemptionListResult or the result of - cls(response) + :return: An iterator like instance of either PolicyExemption or the result of cls(response) :rtype: - ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.resource.policy.v2021_06_01.models.PolicyExemptionListResult] - :raises: ~azure.core.exceptions.HttpResponseError + ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.resource.policy.v2021_06_01.models.PolicyExemption] + :raises ~azure.core.exceptions.HttpResponseError: """ - api_version = kwargs.pop('api_version', "2020-07-01-preview") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2020-07-01-preview")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[_models.PolicyExemptionListResult] - cls = kwargs.pop('cls', None) # type: ClsType["_models.PolicyExemptionListResult"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) + def prepare_request(next_link=None): if not next_link: - + request = build_policy_exemptions_list_for_resource_group_request( - subscription_id=self._config.subscription_id, resource_group_name=resource_group_name, - api_version=api_version, + subscription_id=self._config.subscription_id, filter=filter, - template_url=self.list_for_resource_group.metadata['url'], + api_version=api_version, + template_url=self.list_for_resource_group.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore else: - - request = build_policy_exemptions_list_for_resource_group_request( - subscription_id=self._config.subscription_id, - resource_group_name=resource_group_name, - template_url=next_link, - ) + request = HttpRequest("GET", next_link) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore request.method = "GET" return request @@ -3165,10 +3805,8 @@ async def extract_data(pipeline_response): async def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) response = pipeline_response.http_response @@ -3178,11 +3816,9 @@ async def get_next(next_link=None): return pipeline_response + return AsyncItemPaged(get_next, extract_data) - return AsyncItemPaged( - get_next, extract_data - ) - list_for_resource_group.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Authorization/policyExemptions"} # type: ignore + list_for_resource_group.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Authorization/policyExemptions"} # type: ignore @distributed_trace def list_for_resource( @@ -3194,7 +3830,7 @@ def list_for_resource( resource_name: str, filter: Optional[str] = None, **kwargs: Any - ) -> AsyncIterable["_models.PolicyExemptionListResult"]: + ) -> AsyncIterable["_models.PolicyExemption"]: """Retrieves all policy exemptions that apply to a resource. This operation retrieves the list of all policy exemptions associated with the specified @@ -3216,17 +3852,19 @@ def list_for_resource( {parentResourcePath} == '', {resourceType} == 'Microsoft.Web/sites', {resourceName} == 'MyWebApp'). - :param resource_group_name: The name of the resource group containing the resource. + :param resource_group_name: The name of the resource group containing the resource. Required. :type resource_group_name: str :param resource_provider_namespace: The namespace of the resource provider. For example, the namespace of a virtual machine is Microsoft.Compute (from Microsoft.Compute/virtualMachines). + Required. :type resource_provider_namespace: str :param parent_resource_path: The parent resource path. Use empty string if there is none. + Required. :type parent_resource_path: str :param resource_type: The resource type name. For example the type name of a web app is 'sites' - (from Microsoft.Web/sites). + (from Microsoft.Web/sites). Required. :type resource_type: str - :param resource_name: The name of the resource. + :param resource_name: The name of the resource. Required. :type resource_name: str :param filter: The filter to apply on the operation. Valid values for $filter are: 'atScope()', 'atExactScope()', 'excludeExpired()' or 'policyAssignmentId eq '{value}''. If $filter is not @@ -3241,53 +3879,49 @@ def list_for_resource( '{value}' is provided. the returned list only includes all policy exemptions that are associated with the give policyAssignmentId. Default value is None. :type filter: str - :keyword api_version: Api Version. Default value is "2020-07-01-preview". Note that overriding - this default value may result in unsupported behavior. - :paramtype api_version: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either PolicyExemptionListResult or the result of - cls(response) + :return: An iterator like instance of either PolicyExemption or the result of cls(response) :rtype: - ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.resource.policy.v2021_06_01.models.PolicyExemptionListResult] - :raises: ~azure.core.exceptions.HttpResponseError + ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.resource.policy.v2021_06_01.models.PolicyExemption] + :raises ~azure.core.exceptions.HttpResponseError: """ - api_version = kwargs.pop('api_version', "2020-07-01-preview") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2020-07-01-preview")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[_models.PolicyExemptionListResult] - cls = kwargs.pop('cls', None) # type: ClsType["_models.PolicyExemptionListResult"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) + def prepare_request(next_link=None): if not next_link: - + request = build_policy_exemptions_list_for_resource_request( - subscription_id=self._config.subscription_id, resource_group_name=resource_group_name, resource_provider_namespace=resource_provider_namespace, parent_resource_path=parent_resource_path, resource_type=resource_type, resource_name=resource_name, - api_version=api_version, + subscription_id=self._config.subscription_id, filter=filter, - template_url=self.list_for_resource.metadata['url'], + api_version=api_version, + template_url=self.list_for_resource.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore else: - - request = build_policy_exemptions_list_for_resource_request( - subscription_id=self._config.subscription_id, - resource_group_name=resource_group_name, - resource_provider_namespace=resource_provider_namespace, - parent_resource_path=parent_resource_path, - resource_type=resource_type, - resource_name=resource_name, - template_url=next_link, - ) + request = HttpRequest("GET", next_link) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore request.method = "GET" return request @@ -3301,10 +3935,8 @@ async def extract_data(pipeline_response): async def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) response = pipeline_response.http_response @@ -3314,19 +3946,14 @@ async def get_next(next_link=None): return pipeline_response + return AsyncItemPaged(get_next, extract_data) - return AsyncItemPaged( - get_next, extract_data - ) - list_for_resource.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{parentResourcePath}/{resourceType}/{resourceName}/providers/Microsoft.Authorization/policyExemptions"} # type: ignore + list_for_resource.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{parentResourcePath}/{resourceType}/{resourceName}/providers/Microsoft.Authorization/policyExemptions"} # type: ignore @distributed_trace def list_for_management_group( - self, - management_group_id: str, - filter: Optional[str] = None, - **kwargs: Any - ) -> AsyncIterable["_models.PolicyExemptionListResult"]: + self, management_group_id: str, filter: Optional[str] = None, **kwargs: Any + ) -> AsyncIterable["_models.PolicyExemption"]: """Retrieves all policy exemptions that apply to a management group. This operation retrieves the list of all policy exemptions applicable to the management group @@ -3335,7 +3962,7 @@ def list_for_management_group( returned list includes all policy exemptions that are assigned to the management group or the management group's ancestors. - :param management_group_id: The ID of the management group. + :param management_group_id: The ID of the management group. Required. :type management_group_id: str :param filter: The filter to apply on the operation. Valid values for $filter are: 'atScope()', 'atExactScope()', 'excludeExpired()' or 'policyAssignmentId eq '{value}''. If $filter is not @@ -3350,43 +3977,44 @@ def list_for_management_group( '{value}' is provided. the returned list only includes all policy exemptions that are associated with the give policyAssignmentId. Default value is None. :type filter: str - :keyword api_version: Api Version. Default value is "2020-07-01-preview". Note that overriding - this default value may result in unsupported behavior. - :paramtype api_version: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either PolicyExemptionListResult or the result of - cls(response) + :return: An iterator like instance of either PolicyExemption or the result of cls(response) :rtype: - ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.resource.policy.v2021_06_01.models.PolicyExemptionListResult] - :raises: ~azure.core.exceptions.HttpResponseError + ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.resource.policy.v2021_06_01.models.PolicyExemption] + :raises ~azure.core.exceptions.HttpResponseError: """ - api_version = kwargs.pop('api_version', "2020-07-01-preview") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2020-07-01-preview")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[_models.PolicyExemptionListResult] - cls = kwargs.pop('cls', None) # type: ClsType["_models.PolicyExemptionListResult"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) + def prepare_request(next_link=None): if not next_link: - + request = build_policy_exemptions_list_for_management_group_request( management_group_id=management_group_id, - api_version=api_version, filter=filter, - template_url=self.list_for_management_group.metadata['url'], + api_version=api_version, + template_url=self.list_for_management_group.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore else: - - request = build_policy_exemptions_list_for_management_group_request( - management_group_id=management_group_id, - template_url=next_link, - ) + request = HttpRequest("GET", next_link) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore request.method = "GET" return request @@ -3400,10 +4028,8 @@ async def extract_data(pipeline_response): async def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) response = pipeline_response.http_response @@ -3413,8 +4039,1397 @@ async def get_next(next_link=None): return pipeline_response + return AsyncItemPaged(get_next, extract_data) - return AsyncItemPaged( - get_next, extract_data + list_for_management_group.metadata = {"url": "/providers/Microsoft.Management/managementGroups/{managementGroupId}/providers/Microsoft.Authorization/policyExemptions"} # type: ignore + + +class VariablesOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. + + Instead, you should access the following operations through + :class:`~azure.mgmt.resource.policy.v2021_06_01.aio.PolicyClient`'s + :attr:`variables` attribute. + """ + + models = _models + + def __init__(self, *args, **kwargs) -> None: + input_args = list(args) + self._client = input_args.pop(0) if input_args else kwargs.pop("client") + self._config = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") + + @distributed_trace_async + async def delete(self, variable_name: str, **kwargs: Any) -> None: # pylint: disable=inconsistent-return-statements + """Deletes a variable. + + This operation deletes a variable, given its name and the subscription it was created in. The + scope of a variable is the part of its ID preceding + '/providers/Microsoft.Authorization/variables/{variableName}'. + + :param variable_name: The name of the variable to operate on. Required. + :type variable_name: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: None or the result of cls(response) + :rtype: None + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2022-08-01-preview")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[None] + + request = build_variables_delete_request( + variable_name=variable_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + template_url=self.delete.metadata["url"], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore + + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [200, 204]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + if cls: + return cls(pipeline_response, None, {}) + + delete.metadata = {"url": "/subscriptions/{subscriptionId}/providers/Microsoft.Authorization/variables/{variableName}"} # type: ignore + + @overload + async def create_or_update( + self, variable_name: str, parameters: _models.Variable, *, content_type: str = "application/json", **kwargs: Any + ) -> _models.Variable: + """Creates or updates a variable. + + This operation creates or updates a variable with the given subscription and name. Policy + variables can only be used by a policy definition at the scope they are created or below. + + :param variable_name: The name of the variable to operate on. Required. + :type variable_name: str + :param parameters: Parameters for the variable. Required. + :type parameters: ~azure.mgmt.resource.policy.v2021_06_01.models.Variable + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: Variable or the result of cls(response) + :rtype: ~azure.mgmt.resource.policy.v2021_06_01.models.Variable + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + async def create_or_update( + self, variable_name: str, parameters: IO, *, content_type: str = "application/json", **kwargs: Any + ) -> _models.Variable: + """Creates or updates a variable. + + This operation creates or updates a variable with the given subscription and name. Policy + variables can only be used by a policy definition at the scope they are created or below. + + :param variable_name: The name of the variable to operate on. Required. + :type variable_name: str + :param parameters: Parameters for the variable. Required. + :type parameters: IO + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: Variable or the result of cls(response) + :rtype: ~azure.mgmt.resource.policy.v2021_06_01.models.Variable + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace_async + async def create_or_update( + self, variable_name: str, parameters: Union[_models.Variable, IO], **kwargs: Any + ) -> _models.Variable: + """Creates or updates a variable. + + This operation creates or updates a variable with the given subscription and name. Policy + variables can only be used by a policy definition at the scope they are created or below. + + :param variable_name: The name of the variable to operate on. Required. + :type variable_name: str + :param parameters: Parameters for the variable. Is either a model type or a IO type. Required. + :type parameters: ~azure.mgmt.resource.policy.v2021_06_01.models.Variable or IO + :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. + Default value is None. + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: Variable or the result of cls(response) + :rtype: ~azure.mgmt.resource.policy.v2021_06_01.models.Variable + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2022-08-01-preview")) # type: str + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.Variable] + + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(parameters, (IO, bytes)): + _content = parameters + else: + _json = self._serialize.body(parameters, "Variable") + + request = build_variables_create_or_update_request( + variable_name=variable_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + content_type=content_type, + json=_json, + content=_content, + template_url=self.create_or_update.metadata["url"], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore + + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) - list_for_management_group.metadata = {'url': "/providers/Microsoft.Management/managementGroups/{managementGroupId}/providers/Microsoft.Authorization/policyExemptions"} # type: ignore + + response = pipeline_response.http_response + + if response.status_code not in [200, 201]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + if response.status_code == 200: + deserialized = self._deserialize("Variable", pipeline_response) + + if response.status_code == 201: + deserialized = self._deserialize("Variable", pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + + create_or_update.metadata = {"url": "/subscriptions/{subscriptionId}/providers/Microsoft.Authorization/variables/{variableName}"} # type: ignore + + @distributed_trace_async + async def get(self, variable_name: str, **kwargs: Any) -> _models.Variable: + """Retrieves a variable. + + This operation retrieves a single variable, given its name and the subscription it was created + at. + + :param variable_name: The name of the variable to operate on. Required. + :type variable_name: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: Variable or the result of cls(response) + :rtype: ~azure.mgmt.resource.policy.v2021_06_01.models.Variable + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2022-08-01-preview")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[_models.Variable] + + request = build_variables_get_request( + variable_name=variable_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + template_url=self.get.metadata["url"], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore + + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + deserialized = self._deserialize("Variable", pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + + get.metadata = {"url": "/subscriptions/{subscriptionId}/providers/Microsoft.Authorization/variables/{variableName}"} # type: ignore + + @distributed_trace_async + async def delete_at_management_group( # pylint: disable=inconsistent-return-statements + self, management_group_id: str, variable_name: str, **kwargs: Any + ) -> None: + """Deletes a variable. + + This operation deletes a variable, given its name and the management group it was created in. + The scope of a variable is the part of its ID preceding + '/providers/Microsoft.Authorization/variables/{variableName}'. + + :param management_group_id: The ID of the management group. Required. + :type management_group_id: str + :param variable_name: The name of the variable to operate on. Required. + :type variable_name: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: None or the result of cls(response) + :rtype: None + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2022-08-01-preview")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[None] + + request = build_variables_delete_at_management_group_request( + management_group_id=management_group_id, + variable_name=variable_name, + api_version=api_version, + template_url=self.delete_at_management_group.metadata["url"], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore + + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [200, 204]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + if cls: + return cls(pipeline_response, None, {}) + + delete_at_management_group.metadata = {"url": "/providers/Microsoft.Management/managementGroups/{managementGroupId}/providers/Microsoft.Authorization/variables/{variableName}"} # type: ignore + + @overload + async def create_or_update_at_management_group( + self, + management_group_id: str, + variable_name: str, + parameters: _models.Variable, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.Variable: + """Creates or updates a variable. + + This operation creates or updates a variable with the given management group and name. Policy + variables can only be used by a policy definition at the scope they are created or below. + + :param management_group_id: The ID of the management group. Required. + :type management_group_id: str + :param variable_name: The name of the variable to operate on. Required. + :type variable_name: str + :param parameters: Parameters for the variable. Required. + :type parameters: ~azure.mgmt.resource.policy.v2021_06_01.models.Variable + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: Variable or the result of cls(response) + :rtype: ~azure.mgmt.resource.policy.v2021_06_01.models.Variable + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + async def create_or_update_at_management_group( + self, + management_group_id: str, + variable_name: str, + parameters: IO, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.Variable: + """Creates or updates a variable. + + This operation creates or updates a variable with the given management group and name. Policy + variables can only be used by a policy definition at the scope they are created or below. + + :param management_group_id: The ID of the management group. Required. + :type management_group_id: str + :param variable_name: The name of the variable to operate on. Required. + :type variable_name: str + :param parameters: Parameters for the variable. Required. + :type parameters: IO + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: Variable or the result of cls(response) + :rtype: ~azure.mgmt.resource.policy.v2021_06_01.models.Variable + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace_async + async def create_or_update_at_management_group( + self, management_group_id: str, variable_name: str, parameters: Union[_models.Variable, IO], **kwargs: Any + ) -> _models.Variable: + """Creates or updates a variable. + + This operation creates or updates a variable with the given management group and name. Policy + variables can only be used by a policy definition at the scope they are created or below. + + :param management_group_id: The ID of the management group. Required. + :type management_group_id: str + :param variable_name: The name of the variable to operate on. Required. + :type variable_name: str + :param parameters: Parameters for the variable. Is either a model type or a IO type. Required. + :type parameters: ~azure.mgmt.resource.policy.v2021_06_01.models.Variable or IO + :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. + Default value is None. + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: Variable or the result of cls(response) + :rtype: ~azure.mgmt.resource.policy.v2021_06_01.models.Variable + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2022-08-01-preview")) # type: str + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.Variable] + + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(parameters, (IO, bytes)): + _content = parameters + else: + _json = self._serialize.body(parameters, "Variable") + + request = build_variables_create_or_update_at_management_group_request( + management_group_id=management_group_id, + variable_name=variable_name, + api_version=api_version, + content_type=content_type, + json=_json, + content=_content, + template_url=self.create_or_update_at_management_group.metadata["url"], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore + + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [200, 201]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + if response.status_code == 200: + deserialized = self._deserialize("Variable", pipeline_response) + + if response.status_code == 201: + deserialized = self._deserialize("Variable", pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + + create_or_update_at_management_group.metadata = {"url": "/providers/Microsoft.Management/managementGroups/{managementGroupId}/providers/Microsoft.Authorization/variables/{variableName}"} # type: ignore + + @distributed_trace_async + async def get_at_management_group( + self, management_group_id: str, variable_name: str, **kwargs: Any + ) -> _models.Variable: + """Retrieves a variable. + + This operation retrieves a single variable, given its name and the management group it was + created at. + + :param management_group_id: The ID of the management group. Required. + :type management_group_id: str + :param variable_name: The name of the variable to operate on. Required. + :type variable_name: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: Variable or the result of cls(response) + :rtype: ~azure.mgmt.resource.policy.v2021_06_01.models.Variable + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2022-08-01-preview")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[_models.Variable] + + request = build_variables_get_at_management_group_request( + management_group_id=management_group_id, + variable_name=variable_name, + api_version=api_version, + template_url=self.get_at_management_group.metadata["url"], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore + + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + deserialized = self._deserialize("Variable", pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + + get_at_management_group.metadata = {"url": "/providers/Microsoft.Management/managementGroups/{managementGroupId}/providers/Microsoft.Authorization/variables/{variableName}"} # type: ignore + + @distributed_trace + def list(self, **kwargs: Any) -> AsyncIterable["_models.Variable"]: + """Retrieves all variables that are at this subscription level. + + This operation retrieves the list of all variables associated with the given subscription. + + :keyword callable cls: A custom type or function that will be passed the direct response + :return: An iterator like instance of either Variable or the result of cls(response) + :rtype: + ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.resource.policy.v2021_06_01.models.Variable] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2022-08-01-preview")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[_models.VariableListResult] + + error_map = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + def prepare_request(next_link=None): + if not next_link: + + request = build_variables_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 + + else: + request = HttpRequest("GET", next_link) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore + request.method = "GET" + return request + + async def extract_data(pipeline_response): + deserialized = self._deserialize("VariableListResult", pipeline_response) + list_of_elem = deserialized.value + if cls: + list_of_elem = cls(list_of_elem) + 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 + ) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + return pipeline_response + + return AsyncItemPaged(get_next, extract_data) + + list.metadata = {"url": "/subscriptions/{subscriptionId}/providers/Microsoft.Authorization/variables"} # type: ignore + + @distributed_trace + def list_for_management_group(self, management_group_id: str, **kwargs: Any) -> AsyncIterable["_models.Variable"]: + """Retrieves all variables that are at this management group level. + + This operation retrieves the list of all variables applicable to the management group. + + :param management_group_id: The ID of the management group. Required. + :type management_group_id: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: An iterator like instance of either Variable or the result of cls(response) + :rtype: + ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.resource.policy.v2021_06_01.models.Variable] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2022-08-01-preview")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[_models.VariableListResult] + + error_map = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + def prepare_request(next_link=None): + if not next_link: + + request = build_variables_list_for_management_group_request( + management_group_id=management_group_id, + api_version=api_version, + template_url=self.list_for_management_group.metadata["url"], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore + + else: + request = HttpRequest("GET", next_link) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore + request.method = "GET" + return request + + async def extract_data(pipeline_response): + deserialized = self._deserialize("VariableListResult", pipeline_response) + list_of_elem = deserialized.value + if cls: + list_of_elem = cls(list_of_elem) + 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 + ) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + return pipeline_response + + return AsyncItemPaged(get_next, extract_data) + + list_for_management_group.metadata = {"url": "/providers/Microsoft.Management/managementGroups/{managementGroupId}/providers/Microsoft.Authorization/variables"} # type: ignore + + +class VariableValuesOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. + + Instead, you should access the following operations through + :class:`~azure.mgmt.resource.policy.v2021_06_01.aio.PolicyClient`'s + :attr:`variable_values` attribute. + """ + + models = _models + + def __init__(self, *args, **kwargs) -> None: + input_args = list(args) + self._client = input_args.pop(0) if input_args else kwargs.pop("client") + self._config = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") + + @distributed_trace_async + async def delete( # pylint: disable=inconsistent-return-statements + self, variable_name: str, variable_value_name: str, **kwargs: Any + ) -> None: + """Deletes a variable value. + + This operation deletes a variable value, given its name, the subscription it was created in, + and the variable it belongs to. The scope of a variable value is the part of its ID preceding + '/providers/Microsoft.Authorization/variables/{variableName}'. + + :param variable_name: The name of the variable to operate on. Required. + :type variable_name: str + :param variable_value_name: The name of the variable value to operate on. Required. + :type variable_value_name: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: None or the result of cls(response) + :rtype: None + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2022-08-01-preview")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[None] + + request = build_variable_values_delete_request( + variable_name=variable_name, + variable_value_name=variable_value_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + template_url=self.delete.metadata["url"], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore + + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [200, 204]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + if cls: + return cls(pipeline_response, None, {}) + + delete.metadata = {"url": "/subscriptions/{subscriptionId}/providers/Microsoft.Authorization/variables/{variableName}/values/{variableValueName}"} # type: ignore + + @overload + async def create_or_update( + self, + variable_name: str, + variable_value_name: str, + parameters: _models.VariableValue, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.VariableValue: + """Creates or updates a variable value. + + This operation creates or updates a variable value with the given subscription and name for a + given variable. Variable values are scoped to the variable for which they are created for. + + :param variable_name: The name of the variable to operate on. Required. + :type variable_name: str + :param variable_value_name: The name of the variable value to operate on. Required. + :type variable_value_name: str + :param parameters: Parameters for the variable value. Required. + :type parameters: ~azure.mgmt.resource.policy.v2021_06_01.models.VariableValue + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: VariableValue or the result of cls(response) + :rtype: ~azure.mgmt.resource.policy.v2021_06_01.models.VariableValue + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + async def create_or_update( + self, + variable_name: str, + variable_value_name: str, + parameters: IO, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.VariableValue: + """Creates or updates a variable value. + + This operation creates or updates a variable value with the given subscription and name for a + given variable. Variable values are scoped to the variable for which they are created for. + + :param variable_name: The name of the variable to operate on. Required. + :type variable_name: str + :param variable_value_name: The name of the variable value to operate on. Required. + :type variable_value_name: str + :param parameters: Parameters for the variable value. Required. + :type parameters: IO + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: VariableValue or the result of cls(response) + :rtype: ~azure.mgmt.resource.policy.v2021_06_01.models.VariableValue + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace_async + async def create_or_update( + self, variable_name: str, variable_value_name: str, parameters: Union[_models.VariableValue, IO], **kwargs: Any + ) -> _models.VariableValue: + """Creates or updates a variable value. + + This operation creates or updates a variable value with the given subscription and name for a + given variable. Variable values are scoped to the variable for which they are created for. + + :param variable_name: The name of the variable to operate on. Required. + :type variable_name: str + :param variable_value_name: The name of the variable value to operate on. Required. + :type variable_value_name: str + :param parameters: Parameters for the variable value. Is either a model type or a IO type. + Required. + :type parameters: ~azure.mgmt.resource.policy.v2021_06_01.models.VariableValue or IO + :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. + Default value is None. + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: VariableValue or the result of cls(response) + :rtype: ~azure.mgmt.resource.policy.v2021_06_01.models.VariableValue + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2022-08-01-preview")) # type: str + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.VariableValue] + + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(parameters, (IO, bytes)): + _content = parameters + else: + _json = self._serialize.body(parameters, "VariableValue") + + request = build_variable_values_create_or_update_request( + variable_name=variable_name, + variable_value_name=variable_value_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + content_type=content_type, + json=_json, + content=_content, + template_url=self.create_or_update.metadata["url"], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore + + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [200, 201]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + if response.status_code == 200: + deserialized = self._deserialize("VariableValue", pipeline_response) + + if response.status_code == 201: + deserialized = self._deserialize("VariableValue", pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + + create_or_update.metadata = {"url": "/subscriptions/{subscriptionId}/providers/Microsoft.Authorization/variables/{variableName}/values/{variableValueName}"} # type: ignore + + @distributed_trace_async + async def get(self, variable_name: str, variable_value_name: str, **kwargs: Any) -> _models.VariableValue: + """Retrieves a variable value. + + This operation retrieves a single variable value; given its name, subscription it was created + at and the variable it's created for. + + :param variable_name: The name of the variable to operate on. Required. + :type variable_name: str + :param variable_value_name: The name of the variable value to operate on. Required. + :type variable_value_name: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: VariableValue or the result of cls(response) + :rtype: ~azure.mgmt.resource.policy.v2021_06_01.models.VariableValue + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2022-08-01-preview")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[_models.VariableValue] + + request = build_variable_values_get_request( + variable_name=variable_name, + variable_value_name=variable_value_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + template_url=self.get.metadata["url"], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore + + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + deserialized = self._deserialize("VariableValue", pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + + get.metadata = {"url": "/subscriptions/{subscriptionId}/providers/Microsoft.Authorization/variables/{variableName}/values/{variableValueName}"} # type: ignore + + @distributed_trace + def list(self, variable_name: str, **kwargs: Any) -> AsyncIterable["_models.VariableValue"]: + """List variable values for a variable. + + This operation retrieves the list of all variable values associated with the given variable + that is at a subscription level. + + :param variable_name: The name of the variable to operate on. Required. + :type variable_name: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: An iterator like instance of either VariableValue or the result of cls(response) + :rtype: + ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.resource.policy.v2021_06_01.models.VariableValue] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2022-08-01-preview")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[_models.VariableValueListResult] + + error_map = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + def prepare_request(next_link=None): + if not next_link: + + request = build_variable_values_list_request( + variable_name=variable_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 + + else: + request = HttpRequest("GET", next_link) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore + request.method = "GET" + return request + + async def extract_data(pipeline_response): + deserialized = self._deserialize("VariableValueListResult", pipeline_response) + list_of_elem = deserialized.value + if cls: + list_of_elem = cls(list_of_elem) + 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 + ) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + return pipeline_response + + return AsyncItemPaged(get_next, extract_data) + + list.metadata = {"url": "/subscriptions/{subscriptionId}/providers/Microsoft.Authorization/variables/{variableName}/values"} # type: ignore + + @distributed_trace + def list_for_management_group( + self, management_group_id: str, variable_name: str, **kwargs: Any + ) -> AsyncIterable["_models.VariableValue"]: + """List variable values at management group level. + + This operation retrieves the list of all variable values applicable the variable indicated at + the management group scope. + + :param management_group_id: The ID of the management group. Required. + :type management_group_id: str + :param variable_name: The name of the variable to operate on. Required. + :type variable_name: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: An iterator like instance of either VariableValue or the result of cls(response) + :rtype: + ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.resource.policy.v2021_06_01.models.VariableValue] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2022-08-01-preview")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[_models.VariableValueListResult] + + error_map = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + def prepare_request(next_link=None): + if not next_link: + + request = build_variable_values_list_for_management_group_request( + management_group_id=management_group_id, + variable_name=variable_name, + api_version=api_version, + template_url=self.list_for_management_group.metadata["url"], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore + + else: + request = HttpRequest("GET", next_link) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore + request.method = "GET" + return request + + async def extract_data(pipeline_response): + deserialized = self._deserialize("VariableValueListResult", pipeline_response) + list_of_elem = deserialized.value + if cls: + list_of_elem = cls(list_of_elem) + 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 + ) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + return pipeline_response + + return AsyncItemPaged(get_next, extract_data) + + list_for_management_group.metadata = {"url": "/providers/Microsoft.Management/managementGroups/{managementGroupId}/providers/Microsoft.Authorization/variables/{variableName}/values"} # type: ignore + + @distributed_trace_async + async def delete_at_management_group( # pylint: disable=inconsistent-return-statements + self, management_group_id: str, variable_name: str, variable_value_name: str, **kwargs: Any + ) -> None: + """Deletes a variable value. + + This operation deletes a variable value, given its name, the management group it was created + in, and the variable it belongs to. The scope of a variable value is the part of its ID + preceding '/providers/Microsoft.Authorization/variables/{variableName}'. + + :param management_group_id: The ID of the management group. Required. + :type management_group_id: str + :param variable_name: The name of the variable to operate on. Required. + :type variable_name: str + :param variable_value_name: The name of the variable value to operate on. Required. + :type variable_value_name: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: None or the result of cls(response) + :rtype: None + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2022-08-01-preview")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[None] + + request = build_variable_values_delete_at_management_group_request( + management_group_id=management_group_id, + variable_name=variable_name, + variable_value_name=variable_value_name, + api_version=api_version, + template_url=self.delete_at_management_group.metadata["url"], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore + + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [200, 204]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + if cls: + return cls(pipeline_response, None, {}) + + delete_at_management_group.metadata = {"url": "/providers/Microsoft.Management/managementGroups/{managementGroupId}/providers/Microsoft.Authorization/variables/{variableName}/values/{variableValueName}"} # type: ignore + + @overload + async def create_or_update_at_management_group( + self, + management_group_id: str, + variable_name: str, + variable_value_name: str, + parameters: _models.VariableValue, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.VariableValue: + """Creates or updates a variable value. + + This operation creates or updates a variable value with the given management group and name for + a given variable. Variable values are scoped to the variable for which they are created for. + + :param management_group_id: The ID of the management group. Required. + :type management_group_id: str + :param variable_name: The name of the variable to operate on. Required. + :type variable_name: str + :param variable_value_name: The name of the variable value to operate on. Required. + :type variable_value_name: str + :param parameters: Parameters for the variable value. Required. + :type parameters: ~azure.mgmt.resource.policy.v2021_06_01.models.VariableValue + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: VariableValue or the result of cls(response) + :rtype: ~azure.mgmt.resource.policy.v2021_06_01.models.VariableValue + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + async def create_or_update_at_management_group( + self, + management_group_id: str, + variable_name: str, + variable_value_name: str, + parameters: IO, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.VariableValue: + """Creates or updates a variable value. + + This operation creates or updates a variable value with the given management group and name for + a given variable. Variable values are scoped to the variable for which they are created for. + + :param management_group_id: The ID of the management group. Required. + :type management_group_id: str + :param variable_name: The name of the variable to operate on. Required. + :type variable_name: str + :param variable_value_name: The name of the variable value to operate on. Required. + :type variable_value_name: str + :param parameters: Parameters for the variable value. Required. + :type parameters: IO + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: VariableValue or the result of cls(response) + :rtype: ~azure.mgmt.resource.policy.v2021_06_01.models.VariableValue + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace_async + async def create_or_update_at_management_group( + self, + management_group_id: str, + variable_name: str, + variable_value_name: str, + parameters: Union[_models.VariableValue, IO], + **kwargs: Any + ) -> _models.VariableValue: + """Creates or updates a variable value. + + This operation creates or updates a variable value with the given management group and name for + a given variable. Variable values are scoped to the variable for which they are created for. + + :param management_group_id: The ID of the management group. Required. + :type management_group_id: str + :param variable_name: The name of the variable to operate on. Required. + :type variable_name: str + :param variable_value_name: The name of the variable value to operate on. Required. + :type variable_value_name: str + :param parameters: Parameters for the variable value. Is either a model type or a IO type. + Required. + :type parameters: ~azure.mgmt.resource.policy.v2021_06_01.models.VariableValue or IO + :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. + Default value is None. + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: VariableValue or the result of cls(response) + :rtype: ~azure.mgmt.resource.policy.v2021_06_01.models.VariableValue + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2022-08-01-preview")) # type: str + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.VariableValue] + + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(parameters, (IO, bytes)): + _content = parameters + else: + _json = self._serialize.body(parameters, "VariableValue") + + request = build_variable_values_create_or_update_at_management_group_request( + management_group_id=management_group_id, + variable_name=variable_name, + variable_value_name=variable_value_name, + api_version=api_version, + content_type=content_type, + json=_json, + content=_content, + template_url=self.create_or_update_at_management_group.metadata["url"], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore + + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [200, 201]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + if response.status_code == 200: + deserialized = self._deserialize("VariableValue", pipeline_response) + + if response.status_code == 201: + deserialized = self._deserialize("VariableValue", pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + + create_or_update_at_management_group.metadata = {"url": "/providers/Microsoft.Management/managementGroups/{managementGroupId}/providers/Microsoft.Authorization/variables/{variableName}/values/{variableValueName}"} # type: ignore + + @distributed_trace_async + async def get_at_management_group( + self, management_group_id: str, variable_name: str, variable_value_name: str, **kwargs: Any + ) -> _models.VariableValue: + """Retrieves a variable value. + + This operation retrieves a single variable value; given its name, management group it was + created at and the variable it's created for. + + :param management_group_id: The ID of the management group. Required. + :type management_group_id: str + :param variable_name: The name of the variable to operate on. Required. + :type variable_name: str + :param variable_value_name: The name of the variable value to operate on. Required. + :type variable_value_name: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: VariableValue or the result of cls(response) + :rtype: ~azure.mgmt.resource.policy.v2021_06_01.models.VariableValue + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2022-08-01-preview")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[_models.VariableValue] + + request = build_variable_values_get_at_management_group_request( + management_group_id=management_group_id, + variable_name=variable_name, + variable_value_name=variable_value_name, + api_version=api_version, + template_url=self.get_at_management_group.metadata["url"], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore + + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + deserialized = self._deserialize("VariableValue", pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + + get_at_management_group.metadata = {"url": "/providers/Microsoft.Management/managementGroups/{managementGroupId}/providers/Microsoft.Authorization/variables/{variableName}/values/{variableValueName}"} # type: ignore diff --git a/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/policy/v2021_06_01/aio/operations/_patch.py b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/policy/v2021_06_01/aio/operations/_patch.py new file mode 100644 index 0000000000000..f7dd32510333d --- /dev/null +++ b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/policy/v2021_06_01/aio/operations/_patch.py @@ -0,0 +1,20 @@ +# ------------------------------------ +# Copyright (c) Microsoft Corporation. +# Licensed under the MIT License. +# ------------------------------------ +"""Customize generated code here. + +Follow our quickstart for examples: https://aka.ms/azsdk/python/dpcodegen/python/customize +""" +from typing import List + +__all__: List[str] = [] # Add all objects you want publicly available to users at this package level + + +def patch_sdk(): + """Do not remove from this file. + + `patch_sdk` is a last resort escape hatch that allows you to do customizations + you can't accomplish using the techniques described in + https://aka.ms/azsdk/python/dpcodegen/python/customize + """ diff --git a/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/policy/v2021_06_01/models/__init__.py b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/policy/v2021_06_01/models/__init__.py index f0d8ab758f7b3..d40809480e0e4 100644 --- a/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/policy/v2021_06_01/models/__init__.py +++ b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/policy/v2021_06_01/models/__init__.py @@ -32,62 +32,76 @@ from ._models_py3 import PolicyExemptionListResult from ._models_py3 import PolicySetDefinition from ._models_py3 import PolicySetDefinitionListResult +from ._models_py3 import PolicyVariableColumn +from ._models_py3 import PolicyVariableValueColumnValue from ._models_py3 import ResourceTypeAliases from ._models_py3 import SystemData from ._models_py3 import UserAssignedIdentitiesValue +from ._models_py3 import Variable +from ._models_py3 import VariableListResult +from ._models_py3 import VariableValue +from ._models_py3 import VariableValueListResult - -from ._policy_client_enums import ( - AliasPathAttributes, - AliasPathTokenType, - AliasPatternType, - AliasType, - CreatedByType, - EnforcementMode, - ExemptionCategory, - ParameterType, - PolicyType, - ResourceIdentityType, -) +from ._policy_client_enums import AliasPathAttributes +from ._policy_client_enums import AliasPathTokenType +from ._policy_client_enums import AliasPatternType +from ._policy_client_enums import AliasType +from ._policy_client_enums import CreatedByType +from ._policy_client_enums import EnforcementMode +from ._policy_client_enums import ExemptionCategory +from ._policy_client_enums import ParameterType +from ._policy_client_enums import PolicyType +from ._policy_client_enums import ResourceIdentityType +from ._patch import __all__ as _patch_all +from ._patch import * # type: ignore # pylint: disable=unused-wildcard-import +from ._patch import patch_sdk as _patch_sdk __all__ = [ - 'Alias', - 'AliasPath', - 'AliasPathMetadata', - 'AliasPattern', - 'DataEffect', - 'DataManifestCustomResourceFunctionDefinition', - 'DataPolicyManifest', - 'DataPolicyManifestListResult', - 'ErrorAdditionalInfo', - 'ErrorResponse', - 'Identity', - 'NonComplianceMessage', - 'ParameterDefinitionsValue', - 'ParameterDefinitionsValueMetadata', - 'ParameterValuesValue', - 'PolicyAssignment', - 'PolicyAssignmentListResult', - 'PolicyAssignmentUpdate', - 'PolicyDefinition', - 'PolicyDefinitionGroup', - 'PolicyDefinitionListResult', - 'PolicyDefinitionReference', - 'PolicyExemption', - 'PolicyExemptionListResult', - 'PolicySetDefinition', - 'PolicySetDefinitionListResult', - 'ResourceTypeAliases', - 'SystemData', - 'UserAssignedIdentitiesValue', - 'AliasPathAttributes', - 'AliasPathTokenType', - 'AliasPatternType', - 'AliasType', - 'CreatedByType', - 'EnforcementMode', - 'ExemptionCategory', - 'ParameterType', - 'PolicyType', - 'ResourceIdentityType', + "Alias", + "AliasPath", + "AliasPathMetadata", + "AliasPattern", + "DataEffect", + "DataManifestCustomResourceFunctionDefinition", + "DataPolicyManifest", + "DataPolicyManifestListResult", + "ErrorAdditionalInfo", + "ErrorResponse", + "Identity", + "NonComplianceMessage", + "ParameterDefinitionsValue", + "ParameterDefinitionsValueMetadata", + "ParameterValuesValue", + "PolicyAssignment", + "PolicyAssignmentListResult", + "PolicyAssignmentUpdate", + "PolicyDefinition", + "PolicyDefinitionGroup", + "PolicyDefinitionListResult", + "PolicyDefinitionReference", + "PolicyExemption", + "PolicyExemptionListResult", + "PolicySetDefinition", + "PolicySetDefinitionListResult", + "PolicyVariableColumn", + "PolicyVariableValueColumnValue", + "ResourceTypeAliases", + "SystemData", + "UserAssignedIdentitiesValue", + "Variable", + "VariableListResult", + "VariableValue", + "VariableValueListResult", + "AliasPathAttributes", + "AliasPathTokenType", + "AliasPatternType", + "AliasType", + "CreatedByType", + "EnforcementMode", + "ExemptionCategory", + "ParameterType", + "PolicyType", + "ResourceIdentityType", ] +__all__.extend([p for p in _patch_all if p not in __all__]) +_patch_sdk() diff --git a/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/policy/v2021_06_01/models/_models_py3.py b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/policy/v2021_06_01/models/_models_py3.py index 9af87342f0b79..071740402b3a6 100644 --- a/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/policy/v2021_06_01/models/_models_py3.py +++ b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/policy/v2021_06_01/models/_models_py3.py @@ -1,4 +1,5 @@ # coding=utf-8 +# pylint: disable=too-many-lines # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. # Licensed under the MIT License. See License.txt in the project root for license information. @@ -7,14 +8,22 @@ # -------------------------------------------------------------------------- import datetime -from typing import Any, Dict, List, Optional, Union +import sys +from typing import Any, Dict, List, Optional, TYPE_CHECKING, Union -import msrest.serialization +from ... import _serialization -from ._policy_client_enums import * +if TYPE_CHECKING: + # pylint: disable=unused-import,ungrouped-imports + from .. import models as _models +if sys.version_info >= (3, 9): + from collections.abc import MutableMapping +else: + from typing import MutableMapping # type: ignore # pylint: disable=ungrouped-imports +JSON = MutableMapping[str, Any] # pylint: disable=unsubscriptable-object -class Alias(msrest.serialization.Model): +class Alias(_serialization.Model): """The alias type. Variables are only populated by the server, and will be ignored when sending a request. @@ -23,8 +32,7 @@ class Alias(msrest.serialization.Model): :vartype name: str :ivar paths: The paths for an alias. :vartype paths: list[~azure.mgmt.resource.policy.v2021_06_01.models.AliasPath] - :ivar type: The type of the alias. Possible values include: "NotSpecified", "PlainText", - "Mask". + :ivar type: The type of the alias. Known values are: "NotSpecified", "PlainText", and "Mask". :vartype type: str or ~azure.mgmt.resource.policy.v2021_06_01.models.AliasType :ivar default_path: The default path for an alias. :vartype default_path: str @@ -36,26 +44,26 @@ class Alias(msrest.serialization.Model): """ _validation = { - 'default_metadata': {'readonly': True}, + "default_metadata": {"readonly": True}, } _attribute_map = { - 'name': {'key': 'name', 'type': 'str'}, - 'paths': {'key': 'paths', 'type': '[AliasPath]'}, - 'type': {'key': 'type', 'type': 'str'}, - 'default_path': {'key': 'defaultPath', 'type': 'str'}, - 'default_pattern': {'key': 'defaultPattern', 'type': 'AliasPattern'}, - 'default_metadata': {'key': 'defaultMetadata', 'type': 'AliasPathMetadata'}, + "name": {"key": "name", "type": "str"}, + "paths": {"key": "paths", "type": "[AliasPath]"}, + "type": {"key": "type", "type": "str"}, + "default_path": {"key": "defaultPath", "type": "str"}, + "default_pattern": {"key": "defaultPattern", "type": "AliasPattern"}, + "default_metadata": {"key": "defaultMetadata", "type": "AliasPathMetadata"}, } def __init__( self, *, name: Optional[str] = None, - paths: Optional[List["AliasPath"]] = None, - type: Optional[Union[str, "AliasType"]] = None, + paths: Optional[List["_models.AliasPath"]] = None, + type: Optional[Union[str, "_models.AliasType"]] = None, default_path: Optional[str] = None, - default_pattern: Optional["AliasPattern"] = None, + default_pattern: Optional["_models.AliasPattern"] = None, **kwargs ): """ @@ -63,7 +71,7 @@ def __init__( :paramtype name: str :keyword paths: The paths for an alias. :paramtype paths: list[~azure.mgmt.resource.policy.v2021_06_01.models.AliasPath] - :keyword type: The type of the alias. Possible values include: "NotSpecified", "PlainText", + :keyword type: The type of the alias. Known values are: "NotSpecified", "PlainText", and "Mask". :paramtype type: str or ~azure.mgmt.resource.policy.v2021_06_01.models.AliasType :keyword default_path: The default path for an alias. @@ -71,7 +79,7 @@ def __init__( :keyword default_pattern: The default pattern for an alias. :paramtype default_pattern: ~azure.mgmt.resource.policy.v2021_06_01.models.AliasPattern """ - super(Alias, self).__init__(**kwargs) + super().__init__(**kwargs) self.name = name self.paths = paths self.type = type @@ -80,7 +88,7 @@ def __init__( self.default_metadata = None -class AliasPath(msrest.serialization.Model): +class AliasPath(_serialization.Model): """The type of the paths for alias. Variables are only populated by the server, and will be ignored when sending a request. @@ -97,14 +105,14 @@ class AliasPath(msrest.serialization.Model): """ _validation = { - 'metadata': {'readonly': True}, + "metadata": {"readonly": True}, } _attribute_map = { - 'path': {'key': 'path', 'type': 'str'}, - 'api_versions': {'key': 'apiVersions', 'type': '[str]'}, - 'pattern': {'key': 'pattern', 'type': 'AliasPattern'}, - 'metadata': {'key': 'metadata', 'type': 'AliasPathMetadata'}, + "path": {"key": "path", "type": "str"}, + "api_versions": {"key": "apiVersions", "type": "[str]"}, + "pattern": {"key": "pattern", "type": "AliasPattern"}, + "metadata": {"key": "metadata", "type": "AliasPathMetadata"}, } def __init__( @@ -112,7 +120,7 @@ def __init__( *, path: Optional[str] = None, api_versions: Optional[List[str]] = None, - pattern: Optional["AliasPattern"] = None, + pattern: Optional["_models.AliasPattern"] = None, **kwargs ): """ @@ -123,62 +131,58 @@ def __init__( :keyword pattern: The pattern for an alias path. :paramtype pattern: ~azure.mgmt.resource.policy.v2021_06_01.models.AliasPattern """ - super(AliasPath, self).__init__(**kwargs) + super().__init__(**kwargs) self.path = path self.api_versions = api_versions self.pattern = pattern self.metadata = None -class AliasPathMetadata(msrest.serialization.Model): +class AliasPathMetadata(_serialization.Model): """AliasPathMetadata. Variables are only populated by the server, and will be ignored when sending a request. - :ivar type: The type of the token that the alias path is referring to. Possible values include: - "NotSpecified", "Any", "String", "Object", "Array", "Integer", "Number", "Boolean". + :ivar type: The type of the token that the alias path is referring to. Known values are: + "NotSpecified", "Any", "String", "Object", "Array", "Integer", "Number", and "Boolean". :vartype type: str or ~azure.mgmt.resource.policy.v2021_06_01.models.AliasPathTokenType - :ivar attributes: The attributes of the token that the alias path is referring to. Possible - values include: "None", "Modifiable". + :ivar attributes: The attributes of the token that the alias path is referring to. Known values + are: "None" and "Modifiable". :vartype attributes: str or ~azure.mgmt.resource.policy.v2021_06_01.models.AliasPathAttributes """ _validation = { - 'type': {'readonly': True}, - 'attributes': {'readonly': True}, + "type": {"readonly": True}, + "attributes": {"readonly": True}, } _attribute_map = { - 'type': {'key': 'type', 'type': 'str'}, - 'attributes': {'key': 'attributes', 'type': 'str'}, + "type": {"key": "type", "type": "str"}, + "attributes": {"key": "attributes", "type": "str"}, } - def __init__( - self, - **kwargs - ): - """ - """ - super(AliasPathMetadata, self).__init__(**kwargs) + def __init__(self, **kwargs): + """ """ + super().__init__(**kwargs) self.type = None self.attributes = None -class AliasPattern(msrest.serialization.Model): +class AliasPattern(_serialization.Model): """The type of the pattern for an alias path. :ivar phrase: The alias pattern phrase. :vartype phrase: str :ivar variable: The alias pattern variable. :vartype variable: str - :ivar type: The type of alias pattern. Possible values include: "NotSpecified", "Extract". + :ivar type: The type of alias pattern. Known values are: "NotSpecified" and "Extract". :vartype type: str or ~azure.mgmt.resource.policy.v2021_06_01.models.AliasPatternType """ _attribute_map = { - 'phrase': {'key': 'phrase', 'type': 'str'}, - 'variable': {'key': 'variable', 'type': 'str'}, - 'type': {'key': 'type', 'type': 'str'}, + "phrase": {"key": "phrase", "type": "str"}, + "variable": {"key": "variable", "type": "str"}, + "type": {"key": "type", "type": "str"}, } def __init__( @@ -186,7 +190,7 @@ def __init__( *, phrase: Optional[str] = None, variable: Optional[str] = None, - type: Optional[Union[str, "AliasPatternType"]] = None, + type: Optional[Union[str, "_models.AliasPatternType"]] = None, **kwargs ): """ @@ -194,48 +198,42 @@ def __init__( :paramtype phrase: str :keyword variable: The alias pattern variable. :paramtype variable: str - :keyword type: The type of alias pattern. Possible values include: "NotSpecified", "Extract". + :keyword type: The type of alias pattern. Known values are: "NotSpecified" and "Extract". :paramtype type: str or ~azure.mgmt.resource.policy.v2021_06_01.models.AliasPatternType """ - super(AliasPattern, self).__init__(**kwargs) + super().__init__(**kwargs) self.phrase = phrase self.variable = variable self.type = type -class DataEffect(msrest.serialization.Model): +class DataEffect(_serialization.Model): """The data effect definition. :ivar name: The data effect name. :vartype name: str :ivar details_schema: The data effect details schema. - :vartype details_schema: any + :vartype details_schema: JSON """ _attribute_map = { - 'name': {'key': 'name', 'type': 'str'}, - 'details_schema': {'key': 'detailsSchema', 'type': 'object'}, + "name": {"key": "name", "type": "str"}, + "details_schema": {"key": "detailsSchema", "type": "object"}, } - def __init__( - self, - *, - name: Optional[str] = None, - details_schema: Optional[Any] = None, - **kwargs - ): + def __init__(self, *, name: Optional[str] = None, details_schema: Optional[JSON] = None, **kwargs): """ :keyword name: The data effect name. :paramtype name: str :keyword details_schema: The data effect details schema. - :paramtype details_schema: any + :paramtype details_schema: JSON """ - super(DataEffect, self).__init__(**kwargs) + super().__init__(**kwargs) self.name = name self.details_schema = details_schema -class DataManifestCustomResourceFunctionDefinition(msrest.serialization.Model): +class DataManifestCustomResourceFunctionDefinition(_serialization.Model): """The custom resource function definition. :ivar name: The function name as it will appear in the policy rule. eg - 'vault'. @@ -253,10 +251,10 @@ class DataManifestCustomResourceFunctionDefinition(msrest.serialization.Model): """ _attribute_map = { - 'name': {'key': 'name', 'type': 'str'}, - 'fully_qualified_resource_type': {'key': 'fullyQualifiedResourceType', 'type': 'str'}, - 'default_properties': {'key': 'defaultProperties', 'type': '[str]'}, - 'allow_custom_properties': {'key': 'allowCustomProperties', 'type': 'bool'}, + "name": {"key": "name", "type": "str"}, + "fully_qualified_resource_type": {"key": "fullyQualifiedResourceType", "type": "str"}, + "default_properties": {"key": "defaultProperties", "type": "[str]"}, + "allow_custom_properties": {"key": "allowCustomProperties", "type": "bool"}, } def __init__( @@ -282,14 +280,14 @@ def __init__( vault('2019-06-01'). :paramtype allow_custom_properties: bool """ - super(DataManifestCustomResourceFunctionDefinition, self).__init__(**kwargs) + super().__init__(**kwargs) self.name = name self.fully_qualified_resource_type = fully_qualified_resource_type self.default_properties = default_properties self.allow_custom_properties = allow_custom_properties -class DataPolicyManifest(msrest.serialization.Model): +class DataPolicyManifest(_serialization.Model): # pylint: disable=too-many-instance-attributes """The data policy manifest. Variables are only populated by the server, and will be ignored when sending a request. @@ -322,23 +320,26 @@ class DataPolicyManifest(msrest.serialization.Model): """ _validation = { - 'id': {'readonly': True}, - 'name': {'readonly': True}, - 'type': {'readonly': True}, + "id": {"readonly": True}, + "name": {"readonly": True}, + "type": {"readonly": True}, } _attribute_map = { - 'id': {'key': 'id', 'type': 'str'}, - 'name': {'key': 'name', 'type': 'str'}, - 'type': {'key': 'type', 'type': 'str'}, - 'namespaces': {'key': 'properties.namespaces', 'type': '[str]'}, - 'policy_mode': {'key': 'properties.policyMode', 'type': 'str'}, - 'is_built_in_only': {'key': 'properties.isBuiltInOnly', 'type': 'bool'}, - 'resource_type_aliases': {'key': 'properties.resourceTypeAliases', 'type': '[ResourceTypeAliases]'}, - 'effects': {'key': 'properties.effects', 'type': '[DataEffect]'}, - 'field_values': {'key': 'properties.fieldValues', 'type': '[str]'}, - 'standard': {'key': 'properties.resourceFunctions.standard', 'type': '[str]'}, - 'custom': {'key': 'properties.resourceFunctions.custom', 'type': '[DataManifestCustomResourceFunctionDefinition]'}, + "id": {"key": "id", "type": "str"}, + "name": {"key": "name", "type": "str"}, + "type": {"key": "type", "type": "str"}, + "namespaces": {"key": "properties.namespaces", "type": "[str]"}, + "policy_mode": {"key": "properties.policyMode", "type": "str"}, + "is_built_in_only": {"key": "properties.isBuiltInOnly", "type": "bool"}, + "resource_type_aliases": {"key": "properties.resourceTypeAliases", "type": "[ResourceTypeAliases]"}, + "effects": {"key": "properties.effects", "type": "[DataEffect]"}, + "field_values": {"key": "properties.fieldValues", "type": "[str]"}, + "standard": {"key": "properties.resourceFunctions.standard", "type": "[str]"}, + "custom": { + "key": "properties.resourceFunctions.custom", + "type": "[DataManifestCustomResourceFunctionDefinition]", + }, } def __init__( @@ -347,11 +348,11 @@ def __init__( namespaces: Optional[List[str]] = None, policy_mode: Optional[str] = None, is_built_in_only: Optional[bool] = None, - resource_type_aliases: Optional[List["ResourceTypeAliases"]] = None, - effects: Optional[List["DataEffect"]] = None, + resource_type_aliases: Optional[List["_models.ResourceTypeAliases"]] = None, + effects: Optional[List["_models.DataEffect"]] = None, field_values: Optional[List[str]] = None, standard: Optional[List[str]] = None, - custom: Optional[List["DataManifestCustomResourceFunctionDefinition"]] = None, + custom: Optional[List["_models.DataManifestCustomResourceFunctionDefinition"]] = None, **kwargs ): """ @@ -375,7 +376,7 @@ def __init__( :paramtype custom: list[~azure.mgmt.resource.policy.v2021_06_01.models.DataManifestCustomResourceFunctionDefinition] """ - super(DataPolicyManifest, self).__init__(**kwargs) + super().__init__(**kwargs) self.id = None self.name = None self.type = None @@ -389,7 +390,7 @@ def __init__( self.custom = custom -class DataPolicyManifestListResult(msrest.serialization.Model): +class DataPolicyManifestListResult(_serialization.Model): """List of data policy manifests. :ivar value: An array of data policy manifests. @@ -399,16 +400,12 @@ class DataPolicyManifestListResult(msrest.serialization.Model): """ _attribute_map = { - 'value': {'key': 'value', 'type': '[DataPolicyManifest]'}, - 'next_link': {'key': 'nextLink', 'type': 'str'}, + "value": {"key": "value", "type": "[DataPolicyManifest]"}, + "next_link": {"key": "nextLink", "type": "str"}, } def __init__( - self, - *, - value: Optional[List["DataPolicyManifest"]] = None, - next_link: Optional[str] = None, - **kwargs + self, *, value: Optional[List["_models.DataPolicyManifest"]] = None, next_link: Optional[str] = None, **kwargs ): """ :keyword value: An array of data policy manifests. @@ -416,12 +413,12 @@ def __init__( :keyword next_link: The URL to use for getting the next set of results. :paramtype next_link: str """ - super(DataPolicyManifestListResult, self).__init__(**kwargs) + super().__init__(**kwargs) self.value = value self.next_link = next_link -class ErrorAdditionalInfo(msrest.serialization.Model): +class ErrorAdditionalInfo(_serialization.Model): """The resource management error additional info. Variables are only populated by the server, and will be ignored when sending a request. @@ -429,31 +426,27 @@ class ErrorAdditionalInfo(msrest.serialization.Model): :ivar type: The additional info type. :vartype type: str :ivar info: The additional info. - :vartype info: any + :vartype info: JSON """ _validation = { - 'type': {'readonly': True}, - 'info': {'readonly': True}, + "type": {"readonly": True}, + "info": {"readonly": True}, } _attribute_map = { - 'type': {'key': 'type', 'type': 'str'}, - 'info': {'key': 'info', 'type': 'object'}, + "type": {"key": "type", "type": "str"}, + "info": {"key": "info", "type": "object"}, } - def __init__( - self, - **kwargs - ): - """ - """ - super(ErrorAdditionalInfo, self).__init__(**kwargs) + def __init__(self, **kwargs): + """ """ + super().__init__(**kwargs) self.type = None self.info = None -class ErrorResponse(msrest.serialization.Model): +class ErrorResponse(_serialization.Model): """Common error response for all Azure Resource Manager APIs to return error details for failed operations. (This also follows the OData error response format.). Variables are only populated by the server, and will be ignored when sending a request. @@ -472,28 +465,24 @@ class ErrorResponse(msrest.serialization.Model): """ _validation = { - 'code': {'readonly': True}, - 'message': {'readonly': True}, - 'target': {'readonly': True}, - 'details': {'readonly': True}, - 'additional_info': {'readonly': True}, + "code": {"readonly": True}, + "message": {"readonly": True}, + "target": {"readonly": True}, + "details": {"readonly": True}, + "additional_info": {"readonly": True}, } _attribute_map = { - 'code': {'key': 'code', 'type': 'str'}, - 'message': {'key': 'message', 'type': 'str'}, - 'target': {'key': 'target', 'type': 'str'}, - 'details': {'key': 'details', 'type': '[ErrorResponse]'}, - 'additional_info': {'key': 'additionalInfo', 'type': '[ErrorAdditionalInfo]'}, + "code": {"key": "code", "type": "str"}, + "message": {"key": "message", "type": "str"}, + "target": {"key": "target", "type": "str"}, + "details": {"key": "details", "type": "[ErrorResponse]"}, + "additional_info": {"key": "additionalInfo", "type": "[ErrorAdditionalInfo]"}, } - def __init__( - self, - **kwargs - ): - """ - """ - super(ErrorResponse, self).__init__(**kwargs) + def __init__(self, **kwargs): + """ """ + super().__init__(**kwargs) self.code = None self.message = None self.target = None @@ -501,7 +490,7 @@ def __init__( self.additional_info = None -class Identity(msrest.serialization.Model): +class Identity(_serialization.Model): """Identity for the resource. Policy assignments support a maximum of one identity. That is either a system assigned identity or a single user assigned identity. Variables are only populated by the server, and will be ignored when sending a request. @@ -513,7 +502,7 @@ class Identity(msrest.serialization.Model): for a system assigned identity. :vartype tenant_id: str :ivar type: The identity type. This is the only required field when adding a system or user - assigned identity to a resource. Possible values include: "SystemAssigned", "UserAssigned", + assigned identity to a resource. Known values are: "SystemAssigned", "UserAssigned", and "None". :vartype type: str or ~azure.mgmt.resource.policy.v2021_06_01.models.ResourceIdentityType :ivar user_assigned_identities: The user identity associated with the policy. The user identity @@ -524,27 +513,27 @@ class Identity(msrest.serialization.Model): """ _validation = { - 'principal_id': {'readonly': True}, - 'tenant_id': {'readonly': True}, + "principal_id": {"readonly": True}, + "tenant_id": {"readonly": True}, } _attribute_map = { - 'principal_id': {'key': 'principalId', 'type': 'str'}, - 'tenant_id': {'key': 'tenantId', 'type': 'str'}, - 'type': {'key': 'type', 'type': 'str'}, - 'user_assigned_identities': {'key': 'userAssignedIdentities', 'type': '{UserAssignedIdentitiesValue}'}, + "principal_id": {"key": "principalId", "type": "str"}, + "tenant_id": {"key": "tenantId", "type": "str"}, + "type": {"key": "type", "type": "str"}, + "user_assigned_identities": {"key": "userAssignedIdentities", "type": "{UserAssignedIdentitiesValue}"}, } def __init__( self, *, - type: Optional[Union[str, "ResourceIdentityType"]] = None, - user_assigned_identities: Optional[Dict[str, "UserAssignedIdentitiesValue"]] = None, + type: Optional[Union[str, "_models.ResourceIdentityType"]] = None, + user_assigned_identities: Optional[Dict[str, "_models.UserAssignedIdentitiesValue"]] = None, **kwargs ): """ :keyword type: The identity type. This is the only required field when adding a system or user - assigned identity to a resource. Possible values include: "SystemAssigned", "UserAssigned", + assigned identity to a resource. Known values are: "SystemAssigned", "UserAssigned", and "None". :paramtype type: str or ~azure.mgmt.resource.policy.v2021_06_01.models.ResourceIdentityType :keyword user_assigned_identities: The user identity associated with the policy. The user @@ -553,21 +542,20 @@ def __init__( :paramtype user_assigned_identities: dict[str, ~azure.mgmt.resource.policy.v2021_06_01.models.UserAssignedIdentitiesValue] """ - super(Identity, self).__init__(**kwargs) + super().__init__(**kwargs) self.principal_id = None self.tenant_id = None self.type = type self.user_assigned_identities = user_assigned_identities -class NonComplianceMessage(msrest.serialization.Model): +class NonComplianceMessage(_serialization.Model): """A message that describes why a resource is non-compliant with the policy. This is shown in 'deny' error messages and on resource's non-compliant compliance results. All required parameters must be populated in order to send to Azure. - :ivar message: Required. A message that describes why a resource is non-compliant with the - policy. This is shown in 'deny' error messages and on resource's non-compliant compliance - results. + :ivar message: A message that describes why a resource is non-compliant with the policy. This + is shown in 'deny' error messages and on resource's non-compliant compliance results. Required. :vartype message: str :ivar policy_definition_reference_id: The policy definition reference ID within a policy set definition the message is intended for. This is only applicable if the policy assignment @@ -577,25 +565,19 @@ class NonComplianceMessage(msrest.serialization.Model): """ _validation = { - 'message': {'required': True}, + "message": {"required": True}, } _attribute_map = { - 'message': {'key': 'message', 'type': 'str'}, - 'policy_definition_reference_id': {'key': 'policyDefinitionReferenceId', 'type': 'str'}, + "message": {"key": "message", "type": "str"}, + "policy_definition_reference_id": {"key": "policyDefinitionReferenceId", "type": "str"}, } - def __init__( - self, - *, - message: str, - policy_definition_reference_id: Optional[str] = None, - **kwargs - ): + def __init__(self, *, message: str, policy_definition_reference_id: Optional[str] = None, **kwargs): """ - :keyword message: Required. A message that describes why a resource is non-compliant with the - policy. This is shown in 'deny' error messages and on resource's non-compliant compliance - results. + :keyword message: A message that describes why a resource is non-compliant with the policy. + This is shown in 'deny' error messages and on resource's non-compliant compliance results. + Required. :paramtype message: str :keyword policy_definition_reference_id: The policy definition reference ID within a policy set definition the message is intended for. This is only applicable if the policy assignment @@ -603,67 +585,67 @@ def __init__( assigned by this policy assignment. :paramtype policy_definition_reference_id: str """ - super(NonComplianceMessage, self).__init__(**kwargs) + super().__init__(**kwargs) self.message = message self.policy_definition_reference_id = policy_definition_reference_id -class ParameterDefinitionsValue(msrest.serialization.Model): +class ParameterDefinitionsValue(_serialization.Model): """The definition of a parameter that can be provided to the policy. - :ivar type: The data type of the parameter. Possible values include: "String", "Array", - "Object", "Boolean", "Integer", "Float", "DateTime". + :ivar type: The data type of the parameter. Known values are: "String", "Array", "Object", + "Boolean", "Integer", "Float", and "DateTime". :vartype type: str or ~azure.mgmt.resource.policy.v2021_06_01.models.ParameterType :ivar allowed_values: The allowed values for the parameter. - :vartype allowed_values: list[any] + :vartype allowed_values: list[JSON] :ivar default_value: The default value for the parameter if no value is provided. - :vartype default_value: any + :vartype default_value: JSON :ivar metadata: General metadata for the parameter. :vartype metadata: ~azure.mgmt.resource.policy.v2021_06_01.models.ParameterDefinitionsValueMetadata """ _attribute_map = { - 'type': {'key': 'type', 'type': 'str'}, - 'allowed_values': {'key': 'allowedValues', 'type': '[object]'}, - 'default_value': {'key': 'defaultValue', 'type': 'object'}, - 'metadata': {'key': 'metadata', 'type': 'ParameterDefinitionsValueMetadata'}, + "type": {"key": "type", "type": "str"}, + "allowed_values": {"key": "allowedValues", "type": "[object]"}, + "default_value": {"key": "defaultValue", "type": "object"}, + "metadata": {"key": "metadata", "type": "ParameterDefinitionsValueMetadata"}, } def __init__( self, *, - type: Optional[Union[str, "ParameterType"]] = None, - allowed_values: Optional[List[Any]] = None, - default_value: Optional[Any] = None, - metadata: Optional["ParameterDefinitionsValueMetadata"] = None, + type: Optional[Union[str, "_models.ParameterType"]] = None, + allowed_values: Optional[List[JSON]] = None, + default_value: Optional[JSON] = None, + metadata: Optional["_models.ParameterDefinitionsValueMetadata"] = None, **kwargs ): """ - :keyword type: The data type of the parameter. Possible values include: "String", "Array", - "Object", "Boolean", "Integer", "Float", "DateTime". + :keyword type: The data type of the parameter. Known values are: "String", "Array", "Object", + "Boolean", "Integer", "Float", and "DateTime". :paramtype type: str or ~azure.mgmt.resource.policy.v2021_06_01.models.ParameterType :keyword allowed_values: The allowed values for the parameter. - :paramtype allowed_values: list[any] + :paramtype allowed_values: list[JSON] :keyword default_value: The default value for the parameter if no value is provided. - :paramtype default_value: any + :paramtype default_value: JSON :keyword metadata: General metadata for the parameter. :paramtype metadata: ~azure.mgmt.resource.policy.v2021_06_01.models.ParameterDefinitionsValueMetadata """ - super(ParameterDefinitionsValue, self).__init__(**kwargs) + super().__init__(**kwargs) self.type = type self.allowed_values = allowed_values self.default_value = default_value self.metadata = metadata -class ParameterDefinitionsValueMetadata(msrest.serialization.Model): +class ParameterDefinitionsValueMetadata(_serialization.Model): """General metadata for the parameter. :ivar additional_properties: Unmatched properties from the message are deserialized to this collection. - :vartype additional_properties: dict[str, any] + :vartype additional_properties: dict[str, JSON] :ivar display_name: The display name for the parameter. :vartype display_name: str :ivar description: The description of the parameter. @@ -678,17 +660,17 @@ class ParameterDefinitionsValueMetadata(msrest.serialization.Model): """ _attribute_map = { - 'additional_properties': {'key': '', 'type': '{object}'}, - 'display_name': {'key': 'displayName', 'type': 'str'}, - 'description': {'key': 'description', 'type': 'str'}, - 'strong_type': {'key': 'strongType', 'type': 'str'}, - 'assign_permissions': {'key': 'assignPermissions', 'type': 'bool'}, + "additional_properties": {"key": "", "type": "{object}"}, + "display_name": {"key": "displayName", "type": "str"}, + "description": {"key": "description", "type": "str"}, + "strong_type": {"key": "strongType", "type": "str"}, + "assign_permissions": {"key": "assignPermissions", "type": "bool"}, } def __init__( self, *, - additional_properties: Optional[Dict[str, Any]] = None, + additional_properties: Optional[Dict[str, JSON]] = None, display_name: Optional[str] = None, description: Optional[str] = None, strong_type: Optional[str] = None, @@ -698,7 +680,7 @@ def __init__( """ :keyword additional_properties: Unmatched properties from the message are deserialized to this collection. - :paramtype additional_properties: dict[str, any] + :paramtype additional_properties: dict[str, JSON] :keyword display_name: The display name for the parameter. :paramtype display_name: str :keyword description: The description of the parameter. @@ -711,7 +693,7 @@ def __init__( is useful in case you wish to assign permissions outside the assignment scope. :paramtype assign_permissions: bool """ - super(ParameterDefinitionsValueMetadata, self).__init__(**kwargs) + super().__init__(**kwargs) self.additional_properties = additional_properties self.display_name = display_name self.description = description @@ -719,32 +701,27 @@ def __init__( self.assign_permissions = assign_permissions -class ParameterValuesValue(msrest.serialization.Model): +class ParameterValuesValue(_serialization.Model): """The value of a parameter. :ivar value: The value of the parameter. - :vartype value: any + :vartype value: JSON """ _attribute_map = { - 'value': {'key': 'value', 'type': 'object'}, + "value": {"key": "value", "type": "object"}, } - def __init__( - self, - *, - value: Optional[Any] = None, - **kwargs - ): + def __init__(self, *, value: Optional[JSON] = None, **kwargs): """ :keyword value: The value of the parameter. - :paramtype value: any + :paramtype value: JSON """ - super(ParameterValuesValue, self).__init__(**kwargs) + super().__init__(**kwargs) self.value = value -class PolicyAssignment(msrest.serialization.Model): +class PolicyAssignment(_serialization.Model): # pylint: disable=too-many-instance-attributes """The policy assignment. Variables are only populated by the server, and will be ignored when sending a request. @@ -779,9 +756,9 @@ class PolicyAssignment(msrest.serialization.Model): :vartype description: str :ivar metadata: The policy assignment metadata. Metadata is an open ended object and is typically a collection of key value pairs. - :vartype metadata: any + :vartype metadata: JSON :ivar enforcement_mode: The policy assignment enforcement mode. Possible values are Default and - DoNotEnforce. Possible values include: "Default", "DoNotEnforce". Default value: "Default". + DoNotEnforce. Known values are: "Default" and "DoNotEnforce". :vartype enforcement_mode: str or ~azure.mgmt.resource.policy.v2021_06_01.models.EnforcementMode :ivar non_compliance_messages: The messages that describe why a resource is non-compliant with @@ -791,44 +768,44 @@ class PolicyAssignment(msrest.serialization.Model): """ _validation = { - 'id': {'readonly': True}, - 'type': {'readonly': True}, - 'name': {'readonly': True}, - 'system_data': {'readonly': True}, - 'scope': {'readonly': True}, + "id": {"readonly": True}, + "type": {"readonly": True}, + "name": {"readonly": True}, + "system_data": {"readonly": True}, + "scope": {"readonly": True}, } _attribute_map = { - 'id': {'key': 'id', 'type': 'str'}, - 'type': {'key': 'type', 'type': 'str'}, - 'name': {'key': 'name', 'type': 'str'}, - 'location': {'key': 'location', 'type': 'str'}, - 'identity': {'key': 'identity', 'type': 'Identity'}, - 'system_data': {'key': 'systemData', 'type': 'SystemData'}, - 'display_name': {'key': 'properties.displayName', 'type': 'str'}, - 'policy_definition_id': {'key': 'properties.policyDefinitionId', 'type': 'str'}, - 'scope': {'key': 'properties.scope', 'type': 'str'}, - 'not_scopes': {'key': 'properties.notScopes', 'type': '[str]'}, - 'parameters': {'key': 'properties.parameters', 'type': '{ParameterValuesValue}'}, - 'description': {'key': 'properties.description', 'type': 'str'}, - 'metadata': {'key': 'properties.metadata', 'type': 'object'}, - 'enforcement_mode': {'key': 'properties.enforcementMode', 'type': 'str'}, - 'non_compliance_messages': {'key': 'properties.nonComplianceMessages', 'type': '[NonComplianceMessage]'}, + "id": {"key": "id", "type": "str"}, + "type": {"key": "type", "type": "str"}, + "name": {"key": "name", "type": "str"}, + "location": {"key": "location", "type": "str"}, + "identity": {"key": "identity", "type": "Identity"}, + "system_data": {"key": "systemData", "type": "SystemData"}, + "display_name": {"key": "properties.displayName", "type": "str"}, + "policy_definition_id": {"key": "properties.policyDefinitionId", "type": "str"}, + "scope": {"key": "properties.scope", "type": "str"}, + "not_scopes": {"key": "properties.notScopes", "type": "[str]"}, + "parameters": {"key": "properties.parameters", "type": "{ParameterValuesValue}"}, + "description": {"key": "properties.description", "type": "str"}, + "metadata": {"key": "properties.metadata", "type": "object"}, + "enforcement_mode": {"key": "properties.enforcementMode", "type": "str"}, + "non_compliance_messages": {"key": "properties.nonComplianceMessages", "type": "[NonComplianceMessage]"}, } def __init__( self, *, location: Optional[str] = None, - identity: Optional["Identity"] = None, + identity: Optional["_models.Identity"] = None, display_name: Optional[str] = None, policy_definition_id: Optional[str] = None, not_scopes: Optional[List[str]] = None, - parameters: Optional[Dict[str, "ParameterValuesValue"]] = None, + parameters: Optional[Dict[str, "_models.ParameterValuesValue"]] = None, description: Optional[str] = None, - metadata: Optional[Any] = None, - enforcement_mode: Optional[Union[str, "EnforcementMode"]] = "Default", - non_compliance_messages: Optional[List["NonComplianceMessage"]] = None, + metadata: Optional[JSON] = None, + enforcement_mode: Union[str, "_models.EnforcementMode"] = "Default", + non_compliance_messages: Optional[List["_models.NonComplianceMessage"]] = None, **kwargs ): """ @@ -852,9 +829,9 @@ def __init__( :paramtype description: str :keyword metadata: The policy assignment metadata. Metadata is an open ended object and is typically a collection of key value pairs. - :paramtype metadata: any + :paramtype metadata: JSON :keyword enforcement_mode: The policy assignment enforcement mode. Possible values are Default - and DoNotEnforce. Possible values include: "Default", "DoNotEnforce". Default value: "Default". + and DoNotEnforce. Known values are: "Default" and "DoNotEnforce". :paramtype enforcement_mode: str or ~azure.mgmt.resource.policy.v2021_06_01.models.EnforcementMode :keyword non_compliance_messages: The messages that describe why a resource is non-compliant @@ -862,7 +839,7 @@ def __init__( :paramtype non_compliance_messages: list[~azure.mgmt.resource.policy.v2021_06_01.models.NonComplianceMessage] """ - super(PolicyAssignment, self).__init__(**kwargs) + super().__init__(**kwargs) self.id = None self.type = None self.name = None @@ -880,7 +857,7 @@ def __init__( self.non_compliance_messages = non_compliance_messages -class PolicyAssignmentListResult(msrest.serialization.Model): +class PolicyAssignmentListResult(_serialization.Model): """List of policy assignments. :ivar value: An array of policy assignments. @@ -890,16 +867,12 @@ class PolicyAssignmentListResult(msrest.serialization.Model): """ _attribute_map = { - 'value': {'key': 'value', 'type': '[PolicyAssignment]'}, - 'next_link': {'key': 'nextLink', 'type': 'str'}, + "value": {"key": "value", "type": "[PolicyAssignment]"}, + "next_link": {"key": "nextLink", "type": "str"}, } def __init__( - self, - *, - value: Optional[List["PolicyAssignment"]] = None, - next_link: Optional[str] = None, - **kwargs + self, *, value: Optional[List["_models.PolicyAssignment"]] = None, next_link: Optional[str] = None, **kwargs ): """ :keyword value: An array of policy assignments. @@ -907,12 +880,12 @@ def __init__( :keyword next_link: The URL to use for getting the next set of results. :paramtype next_link: str """ - super(PolicyAssignmentListResult, self).__init__(**kwargs) + super().__init__(**kwargs) self.value = value self.next_link = next_link -class PolicyAssignmentUpdate(msrest.serialization.Model): +class PolicyAssignmentUpdate(_serialization.Model): """PolicyAssignmentUpdate. :ivar location: The location of the policy assignment. Only required when utilizing managed @@ -923,17 +896,11 @@ class PolicyAssignmentUpdate(msrest.serialization.Model): """ _attribute_map = { - 'location': {'key': 'location', 'type': 'str'}, - 'identity': {'key': 'identity', 'type': 'Identity'}, + "location": {"key": "location", "type": "str"}, + "identity": {"key": "identity", "type": "Identity"}, } - def __init__( - self, - *, - location: Optional[str] = None, - identity: Optional["Identity"] = None, - **kwargs - ): + def __init__(self, *, location: Optional[str] = None, identity: Optional["_models.Identity"] = None, **kwargs): """ :keyword location: The location of the policy assignment. Only required when utilizing managed identity. @@ -941,12 +908,12 @@ def __init__( :keyword identity: The managed identity associated with the policy assignment. :paramtype identity: ~azure.mgmt.resource.policy.v2021_06_01.models.Identity """ - super(PolicyAssignmentUpdate, self).__init__(**kwargs) + super().__init__(**kwargs) self.location = location self.identity = identity -class PolicyDefinition(msrest.serialization.Model): +class PolicyDefinition(_serialization.Model): # pylint: disable=too-many-instance-attributes """The policy definition. Variables are only populated by the server, and will be ignored when sending a request. @@ -960,7 +927,7 @@ class PolicyDefinition(msrest.serialization.Model): :ivar system_data: The system metadata relating to this resource. :vartype system_data: ~azure.mgmt.resource.policy.v2021_06_01.models.SystemData :ivar policy_type: The type of policy definition. Possible values are NotSpecified, BuiltIn, - Custom, and Static. Possible values include: "NotSpecified", "BuiltIn", "Custom", "Static". + Custom, and Static. Known values are: "NotSpecified", "BuiltIn", "Custom", and "Static". :vartype policy_type: str or ~azure.mgmt.resource.policy.v2021_06_01.models.PolicyType :ivar mode: The policy definition mode. Some examples are All, Indexed, Microsoft.KeyVault.Data. @@ -970,10 +937,10 @@ class PolicyDefinition(msrest.serialization.Model): :ivar description: The policy definition description. :vartype description: str :ivar policy_rule: The policy rule. - :vartype policy_rule: any + :vartype policy_rule: JSON :ivar metadata: The policy definition metadata. Metadata is an open ended object and is typically a collection of key value pairs. - :vartype metadata: any + :vartype metadata: JSON :ivar parameters: The parameter definitions for parameters used in the policy rule. The keys are the parameter names. :vartype parameters: dict[str, @@ -981,41 +948,41 @@ class PolicyDefinition(msrest.serialization.Model): """ _validation = { - 'id': {'readonly': True}, - 'name': {'readonly': True}, - 'type': {'readonly': True}, - 'system_data': {'readonly': True}, + "id": {"readonly": True}, + "name": {"readonly": True}, + "type": {"readonly": True}, + "system_data": {"readonly": True}, } _attribute_map = { - 'id': {'key': 'id', 'type': 'str'}, - 'name': {'key': 'name', 'type': 'str'}, - 'type': {'key': 'type', 'type': 'str'}, - 'system_data': {'key': 'systemData', 'type': 'SystemData'}, - 'policy_type': {'key': 'properties.policyType', 'type': 'str'}, - 'mode': {'key': 'properties.mode', 'type': 'str'}, - 'display_name': {'key': 'properties.displayName', 'type': 'str'}, - 'description': {'key': 'properties.description', 'type': 'str'}, - 'policy_rule': {'key': 'properties.policyRule', 'type': 'object'}, - 'metadata': {'key': 'properties.metadata', 'type': 'object'}, - 'parameters': {'key': 'properties.parameters', 'type': '{ParameterDefinitionsValue}'}, + "id": {"key": "id", "type": "str"}, + "name": {"key": "name", "type": "str"}, + "type": {"key": "type", "type": "str"}, + "system_data": {"key": "systemData", "type": "SystemData"}, + "policy_type": {"key": "properties.policyType", "type": "str"}, + "mode": {"key": "properties.mode", "type": "str"}, + "display_name": {"key": "properties.displayName", "type": "str"}, + "description": {"key": "properties.description", "type": "str"}, + "policy_rule": {"key": "properties.policyRule", "type": "object"}, + "metadata": {"key": "properties.metadata", "type": "object"}, + "parameters": {"key": "properties.parameters", "type": "{ParameterDefinitionsValue}"}, } def __init__( self, *, - policy_type: Optional[Union[str, "PolicyType"]] = None, - mode: Optional[str] = "Indexed", + policy_type: Optional[Union[str, "_models.PolicyType"]] = None, + mode: str = "Indexed", display_name: Optional[str] = None, description: Optional[str] = None, - policy_rule: Optional[Any] = None, - metadata: Optional[Any] = None, - parameters: Optional[Dict[str, "ParameterDefinitionsValue"]] = None, + policy_rule: Optional[JSON] = None, + metadata: Optional[JSON] = None, + parameters: Optional[Dict[str, "_models.ParameterDefinitionsValue"]] = None, **kwargs ): """ :keyword policy_type: The type of policy definition. Possible values are NotSpecified, BuiltIn, - Custom, and Static. Possible values include: "NotSpecified", "BuiltIn", "Custom", "Static". + Custom, and Static. Known values are: "NotSpecified", "BuiltIn", "Custom", and "Static". :paramtype policy_type: str or ~azure.mgmt.resource.policy.v2021_06_01.models.PolicyType :keyword mode: The policy definition mode. Some examples are All, Indexed, Microsoft.KeyVault.Data. @@ -1025,16 +992,16 @@ def __init__( :keyword description: The policy definition description. :paramtype description: str :keyword policy_rule: The policy rule. - :paramtype policy_rule: any + :paramtype policy_rule: JSON :keyword metadata: The policy definition metadata. Metadata is an open ended object and is typically a collection of key value pairs. - :paramtype metadata: any + :paramtype metadata: JSON :keyword parameters: The parameter definitions for parameters used in the policy rule. The keys are the parameter names. :paramtype parameters: dict[str, ~azure.mgmt.resource.policy.v2021_06_01.models.ParameterDefinitionsValue] """ - super(PolicyDefinition, self).__init__(**kwargs) + super().__init__(**kwargs) self.id = None self.name = None self.type = None @@ -1048,12 +1015,12 @@ def __init__( self.parameters = parameters -class PolicyDefinitionGroup(msrest.serialization.Model): +class PolicyDefinitionGroup(_serialization.Model): """The policy definition group. All required parameters must be populated in order to send to Azure. - :ivar name: Required. The name of the group. + :ivar name: The name of the group. Required. :vartype name: str :ivar display_name: The group's display name. :vartype display_name: str @@ -1067,15 +1034,15 @@ class PolicyDefinitionGroup(msrest.serialization.Model): """ _validation = { - 'name': {'required': True}, + "name": {"required": True}, } _attribute_map = { - 'name': {'key': 'name', 'type': 'str'}, - 'display_name': {'key': 'displayName', 'type': 'str'}, - 'category': {'key': 'category', 'type': 'str'}, - 'description': {'key': 'description', 'type': 'str'}, - 'additional_metadata_id': {'key': 'additionalMetadataId', 'type': 'str'}, + "name": {"key": "name", "type": "str"}, + "display_name": {"key": "displayName", "type": "str"}, + "category": {"key": "category", "type": "str"}, + "description": {"key": "description", "type": "str"}, + "additional_metadata_id": {"key": "additionalMetadataId", "type": "str"}, } def __init__( @@ -1089,7 +1056,7 @@ def __init__( **kwargs ): """ - :keyword name: Required. The name of the group. + :keyword name: The name of the group. Required. :paramtype name: str :keyword display_name: The group's display name. :paramtype display_name: str @@ -1101,7 +1068,7 @@ def __init__( about the group. :paramtype additional_metadata_id: str """ - super(PolicyDefinitionGroup, self).__init__(**kwargs) + super().__init__(**kwargs) self.name = name self.display_name = display_name self.category = category @@ -1109,7 +1076,7 @@ def __init__( self.additional_metadata_id = additional_metadata_id -class PolicyDefinitionListResult(msrest.serialization.Model): +class PolicyDefinitionListResult(_serialization.Model): """List of policy definitions. :ivar value: An array of policy definitions. @@ -1119,16 +1086,12 @@ class PolicyDefinitionListResult(msrest.serialization.Model): """ _attribute_map = { - 'value': {'key': 'value', 'type': '[PolicyDefinition]'}, - 'next_link': {'key': 'nextLink', 'type': 'str'}, + "value": {"key": "value", "type": "[PolicyDefinition]"}, + "next_link": {"key": "nextLink", "type": "str"}, } def __init__( - self, - *, - value: Optional[List["PolicyDefinition"]] = None, - next_link: Optional[str] = None, - **kwargs + self, *, value: Optional[List["_models.PolicyDefinition"]] = None, next_link: Optional[str] = None, **kwargs ): """ :keyword value: An array of policy definitions. @@ -1136,17 +1099,17 @@ def __init__( :keyword next_link: The URL to use for getting the next set of results. :paramtype next_link: str """ - super(PolicyDefinitionListResult, self).__init__(**kwargs) + super().__init__(**kwargs) self.value = value self.next_link = next_link -class PolicyDefinitionReference(msrest.serialization.Model): +class PolicyDefinitionReference(_serialization.Model): """The policy definition reference. All required parameters must be populated in order to send to Azure. - :ivar policy_definition_id: Required. The ID of the policy definition or policy set definition. + :ivar policy_definition_id: The ID of the policy definition or policy set definition. Required. :vartype policy_definition_id: str :ivar parameters: The parameter values for the referenced policy rule. The keys are the parameter names. @@ -1160,28 +1123,28 @@ class PolicyDefinitionReference(msrest.serialization.Model): """ _validation = { - 'policy_definition_id': {'required': True}, + "policy_definition_id": {"required": True}, } _attribute_map = { - 'policy_definition_id': {'key': 'policyDefinitionId', 'type': 'str'}, - 'parameters': {'key': 'parameters', 'type': '{ParameterValuesValue}'}, - 'policy_definition_reference_id': {'key': 'policyDefinitionReferenceId', 'type': 'str'}, - 'group_names': {'key': 'groupNames', 'type': '[str]'}, + "policy_definition_id": {"key": "policyDefinitionId", "type": "str"}, + "parameters": {"key": "parameters", "type": "{ParameterValuesValue}"}, + "policy_definition_reference_id": {"key": "policyDefinitionReferenceId", "type": "str"}, + "group_names": {"key": "groupNames", "type": "[str]"}, } def __init__( self, *, policy_definition_id: str, - parameters: Optional[Dict[str, "ParameterValuesValue"]] = None, + parameters: Optional[Dict[str, "_models.ParameterValuesValue"]] = None, policy_definition_reference_id: Optional[str] = None, group_names: Optional[List[str]] = None, **kwargs ): """ - :keyword policy_definition_id: Required. The ID of the policy definition or policy set - definition. + :keyword policy_definition_id: The ID of the policy definition or policy set definition. + Required. :paramtype policy_definition_id: str :keyword parameters: The parameter values for the referenced policy rule. The keys are the parameter names. @@ -1193,14 +1156,14 @@ def __init__( :keyword group_names: The name of the groups that this policy definition reference belongs to. :paramtype group_names: list[str] """ - super(PolicyDefinitionReference, self).__init__(**kwargs) + super().__init__(**kwargs) self.policy_definition_id = policy_definition_id self.parameters = parameters self.policy_definition_reference_id = policy_definition_reference_id self.group_names = group_names -class PolicyExemption(msrest.serialization.Model): +class PolicyExemption(_serialization.Model): # pylint: disable=too-many-instance-attributes """The policy exemption. Variables are only populated by the server, and will be ignored when sending a request. @@ -1216,13 +1179,13 @@ class PolicyExemption(msrest.serialization.Model): :vartype name: str :ivar type: The type of the resource (Microsoft.Authorization/policyExemptions). :vartype type: str - :ivar policy_assignment_id: Required. The ID of the policy assignment that is being exempted. + :ivar policy_assignment_id: The ID of the policy assignment that is being exempted. Required. :vartype policy_assignment_id: str :ivar policy_definition_reference_ids: The policy definition reference ID list when the associated policy assignment is an assignment of a policy set definition. :vartype policy_definition_reference_ids: list[str] - :ivar exemption_category: Required. The policy exemption category. Possible values are Waiver - and Mitigated. Possible values include: "Waiver", "Mitigated". + :ivar exemption_category: The policy exemption category. Possible values are Waiver and + Mitigated. Required. Known values are: "Waiver" and "Mitigated". :vartype exemption_category: str or ~azure.mgmt.resource.policy.v2021_06_01.models.ExemptionCategory :ivar expires_on: The expiration date and time (in UTC ISO 8601 format yyyy-MM-ddTHH:mm:ssZ) of @@ -1234,53 +1197,53 @@ class PolicyExemption(msrest.serialization.Model): :vartype description: str :ivar metadata: The policy exemption metadata. Metadata is an open ended object and is typically a collection of key value pairs. - :vartype metadata: any + :vartype metadata: JSON """ _validation = { - 'system_data': {'readonly': True}, - 'id': {'readonly': True}, - 'name': {'readonly': True}, - 'type': {'readonly': True}, - 'policy_assignment_id': {'required': True}, - 'exemption_category': {'required': True}, + "system_data": {"readonly": True}, + "id": {"readonly": True}, + "name": {"readonly": True}, + "type": {"readonly": True}, + "policy_assignment_id": {"required": True}, + "exemption_category": {"required": True}, } _attribute_map = { - 'system_data': {'key': 'systemData', 'type': 'SystemData'}, - 'id': {'key': 'id', 'type': 'str'}, - 'name': {'key': 'name', 'type': 'str'}, - 'type': {'key': 'type', 'type': 'str'}, - 'policy_assignment_id': {'key': 'properties.policyAssignmentId', 'type': 'str'}, - 'policy_definition_reference_ids': {'key': 'properties.policyDefinitionReferenceIds', 'type': '[str]'}, - 'exemption_category': {'key': 'properties.exemptionCategory', 'type': 'str'}, - 'expires_on': {'key': 'properties.expiresOn', 'type': 'iso-8601'}, - 'display_name': {'key': 'properties.displayName', 'type': 'str'}, - 'description': {'key': 'properties.description', 'type': 'str'}, - 'metadata': {'key': 'properties.metadata', 'type': 'object'}, + "system_data": {"key": "systemData", "type": "SystemData"}, + "id": {"key": "id", "type": "str"}, + "name": {"key": "name", "type": "str"}, + "type": {"key": "type", "type": "str"}, + "policy_assignment_id": {"key": "properties.policyAssignmentId", "type": "str"}, + "policy_definition_reference_ids": {"key": "properties.policyDefinitionReferenceIds", "type": "[str]"}, + "exemption_category": {"key": "properties.exemptionCategory", "type": "str"}, + "expires_on": {"key": "properties.expiresOn", "type": "iso-8601"}, + "display_name": {"key": "properties.displayName", "type": "str"}, + "description": {"key": "properties.description", "type": "str"}, + "metadata": {"key": "properties.metadata", "type": "object"}, } def __init__( self, *, policy_assignment_id: str, - exemption_category: Union[str, "ExemptionCategory"], + exemption_category: Union[str, "_models.ExemptionCategory"], policy_definition_reference_ids: Optional[List[str]] = None, expires_on: Optional[datetime.datetime] = None, display_name: Optional[str] = None, description: Optional[str] = None, - metadata: Optional[Any] = None, + metadata: Optional[JSON] = None, **kwargs ): """ - :keyword policy_assignment_id: Required. The ID of the policy assignment that is being - exempted. + :keyword policy_assignment_id: The ID of the policy assignment that is being exempted. + Required. :paramtype policy_assignment_id: str :keyword policy_definition_reference_ids: The policy definition reference ID list when the associated policy assignment is an assignment of a policy set definition. :paramtype policy_definition_reference_ids: list[str] - :keyword exemption_category: Required. The policy exemption category. Possible values are - Waiver and Mitigated. Possible values include: "Waiver", "Mitigated". + :keyword exemption_category: The policy exemption category. Possible values are Waiver and + Mitigated. Required. Known values are: "Waiver" and "Mitigated". :paramtype exemption_category: str or ~azure.mgmt.resource.policy.v2021_06_01.models.ExemptionCategory :keyword expires_on: The expiration date and time (in UTC ISO 8601 format yyyy-MM-ddTHH:mm:ssZ) @@ -1292,9 +1255,9 @@ def __init__( :paramtype description: str :keyword metadata: The policy exemption metadata. Metadata is an open ended object and is typically a collection of key value pairs. - :paramtype metadata: any + :paramtype metadata: JSON """ - super(PolicyExemption, self).__init__(**kwargs) + super().__init__(**kwargs) self.system_data = None self.id = None self.name = None @@ -1308,7 +1271,7 @@ def __init__( self.metadata = metadata -class PolicyExemptionListResult(msrest.serialization.Model): +class PolicyExemptionListResult(_serialization.Model): """List of policy exemptions. Variables are only populated by the server, and will be ignored when sending a request. @@ -1320,30 +1283,25 @@ class PolicyExemptionListResult(msrest.serialization.Model): """ _validation = { - 'next_link': {'readonly': True}, + "next_link": {"readonly": True}, } _attribute_map = { - 'value': {'key': 'value', 'type': '[PolicyExemption]'}, - 'next_link': {'key': 'nextLink', 'type': 'str'}, + "value": {"key": "value", "type": "[PolicyExemption]"}, + "next_link": {"key": "nextLink", "type": "str"}, } - def __init__( - self, - *, - value: Optional[List["PolicyExemption"]] = None, - **kwargs - ): + def __init__(self, *, value: Optional[List["_models.PolicyExemption"]] = None, **kwargs): """ :keyword value: An array of policy exemptions. :paramtype value: list[~azure.mgmt.resource.policy.v2021_06_01.models.PolicyExemption] """ - super(PolicyExemptionListResult, self).__init__(**kwargs) + super().__init__(**kwargs) self.value = value self.next_link = None -class PolicySetDefinition(msrest.serialization.Model): +class PolicySetDefinition(_serialization.Model): # pylint: disable=too-many-instance-attributes """The policy set definition. Variables are only populated by the server, and will be ignored when sending a request. @@ -1357,7 +1315,7 @@ class PolicySetDefinition(msrest.serialization.Model): :ivar system_data: The system metadata relating to this resource. :vartype system_data: ~azure.mgmt.resource.policy.v2021_06_01.models.SystemData :ivar policy_type: The type of policy definition. Possible values are NotSpecified, BuiltIn, - Custom, and Static. Possible values include: "NotSpecified", "BuiltIn", "Custom", "Static". + Custom, and Static. Known values are: "NotSpecified", "BuiltIn", "Custom", and "Static". :vartype policy_type: str or ~azure.mgmt.resource.policy.v2021_06_01.models.PolicyType :ivar display_name: The display name of the policy set definition. :vartype display_name: str @@ -1365,7 +1323,7 @@ class PolicySetDefinition(msrest.serialization.Model): :vartype description: str :ivar metadata: The policy set definition metadata. Metadata is an open ended object and is typically a collection of key value pairs. - :vartype metadata: any + :vartype metadata: JSON :ivar parameters: The policy set definition parameters that can be used in policy definition references. :vartype parameters: dict[str, @@ -1380,41 +1338,41 @@ class PolicySetDefinition(msrest.serialization.Model): """ _validation = { - 'id': {'readonly': True}, - 'name': {'readonly': True}, - 'type': {'readonly': True}, - 'system_data': {'readonly': True}, + "id": {"readonly": True}, + "name": {"readonly": True}, + "type": {"readonly": True}, + "system_data": {"readonly": True}, } _attribute_map = { - 'id': {'key': 'id', 'type': 'str'}, - 'name': {'key': 'name', 'type': 'str'}, - 'type': {'key': 'type', 'type': 'str'}, - 'system_data': {'key': 'systemData', 'type': 'SystemData'}, - 'policy_type': {'key': 'properties.policyType', 'type': 'str'}, - 'display_name': {'key': 'properties.displayName', 'type': 'str'}, - 'description': {'key': 'properties.description', 'type': 'str'}, - 'metadata': {'key': 'properties.metadata', 'type': 'object'}, - 'parameters': {'key': 'properties.parameters', 'type': '{ParameterDefinitionsValue}'}, - 'policy_definitions': {'key': 'properties.policyDefinitions', 'type': '[PolicyDefinitionReference]'}, - 'policy_definition_groups': {'key': 'properties.policyDefinitionGroups', 'type': '[PolicyDefinitionGroup]'}, + "id": {"key": "id", "type": "str"}, + "name": {"key": "name", "type": "str"}, + "type": {"key": "type", "type": "str"}, + "system_data": {"key": "systemData", "type": "SystemData"}, + "policy_type": {"key": "properties.policyType", "type": "str"}, + "display_name": {"key": "properties.displayName", "type": "str"}, + "description": {"key": "properties.description", "type": "str"}, + "metadata": {"key": "properties.metadata", "type": "object"}, + "parameters": {"key": "properties.parameters", "type": "{ParameterDefinitionsValue}"}, + "policy_definitions": {"key": "properties.policyDefinitions", "type": "[PolicyDefinitionReference]"}, + "policy_definition_groups": {"key": "properties.policyDefinitionGroups", "type": "[PolicyDefinitionGroup]"}, } def __init__( self, *, - policy_type: Optional[Union[str, "PolicyType"]] = None, + policy_type: Optional[Union[str, "_models.PolicyType"]] = None, display_name: Optional[str] = None, description: Optional[str] = None, - metadata: Optional[Any] = None, - parameters: Optional[Dict[str, "ParameterDefinitionsValue"]] = None, - policy_definitions: Optional[List["PolicyDefinitionReference"]] = None, - policy_definition_groups: Optional[List["PolicyDefinitionGroup"]] = None, + metadata: Optional[JSON] = None, + parameters: Optional[Dict[str, "_models.ParameterDefinitionsValue"]] = None, + policy_definitions: Optional[List["_models.PolicyDefinitionReference"]] = None, + policy_definition_groups: Optional[List["_models.PolicyDefinitionGroup"]] = None, **kwargs ): """ :keyword policy_type: The type of policy definition. Possible values are NotSpecified, BuiltIn, - Custom, and Static. Possible values include: "NotSpecified", "BuiltIn", "Custom", "Static". + Custom, and Static. Known values are: "NotSpecified", "BuiltIn", "Custom", and "Static". :paramtype policy_type: str or ~azure.mgmt.resource.policy.v2021_06_01.models.PolicyType :keyword display_name: The display name of the policy set definition. :paramtype display_name: str @@ -1422,7 +1380,7 @@ def __init__( :paramtype description: str :keyword metadata: The policy set definition metadata. Metadata is an open ended object and is typically a collection of key value pairs. - :paramtype metadata: any + :paramtype metadata: JSON :keyword parameters: The policy set definition parameters that can be used in policy definition references. :paramtype parameters: dict[str, @@ -1435,7 +1393,7 @@ def __init__( :paramtype policy_definition_groups: list[~azure.mgmt.resource.policy.v2021_06_01.models.PolicyDefinitionGroup] """ - super(PolicySetDefinition, self).__init__(**kwargs) + super().__init__(**kwargs) self.id = None self.name = None self.type = None @@ -1449,7 +1407,7 @@ def __init__( self.policy_definition_groups = policy_definition_groups -class PolicySetDefinitionListResult(msrest.serialization.Model): +class PolicySetDefinitionListResult(_serialization.Model): """List of policy set definitions. :ivar value: An array of policy set definitions. @@ -1459,16 +1417,12 @@ class PolicySetDefinitionListResult(msrest.serialization.Model): """ _attribute_map = { - 'value': {'key': 'value', 'type': '[PolicySetDefinition]'}, - 'next_link': {'key': 'nextLink', 'type': 'str'}, + "value": {"key": "value", "type": "[PolicySetDefinition]"}, + "next_link": {"key": "nextLink", "type": "str"}, } def __init__( - self, - *, - value: Optional[List["PolicySetDefinition"]] = None, - next_link: Optional[str] = None, - **kwargs + self, *, value: Optional[List["_models.PolicySetDefinition"]] = None, next_link: Optional[str] = None, **kwargs ): """ :keyword value: An array of policy set definitions. @@ -1476,12 +1430,73 @@ def __init__( :keyword next_link: The URL to use for getting the next set of results. :paramtype next_link: str """ - super(PolicySetDefinitionListResult, self).__init__(**kwargs) + super().__init__(**kwargs) self.value = value self.next_link = next_link -class ResourceTypeAliases(msrest.serialization.Model): +class PolicyVariableColumn(_serialization.Model): + """The variable column. + + All required parameters must be populated in order to send to Azure. + + :ivar column_name: The name of this policy variable column. Required. + :vartype column_name: str + """ + + _validation = { + "column_name": {"required": True}, + } + + _attribute_map = { + "column_name": {"key": "columnName", "type": "str"}, + } + + def __init__(self, *, column_name: str, **kwargs): + """ + :keyword column_name: The name of this policy variable column. Required. + :paramtype column_name: str + """ + super().__init__(**kwargs) + self.column_name = column_name + + +class PolicyVariableValueColumnValue(_serialization.Model): + """The name value tuple for this variable value column. + + All required parameters must be populated in order to send to Azure. + + :ivar column_name: Column name for the variable value. Required. + :vartype column_name: str + :ivar column_value: Column value for the variable value; this can be an integer, double, + boolean, null or a string. Required. + :vartype column_value: JSON + """ + + _validation = { + "column_name": {"required": True}, + "column_value": {"required": True}, + } + + _attribute_map = { + "column_name": {"key": "columnName", "type": "str"}, + "column_value": {"key": "columnValue", "type": "object"}, + } + + def __init__(self, *, column_name: str, column_value: JSON, **kwargs): + """ + :keyword column_name: Column name for the variable value. Required. + :paramtype column_name: str + :keyword column_value: Column value for the variable value; this can be an integer, double, + boolean, null or a string. Required. + :paramtype column_value: JSON + """ + super().__init__(**kwargs) + self.column_name = column_name + self.column_value = column_value + + +class ResourceTypeAliases(_serialization.Model): """The resource type aliases definition. :ivar resource_type: The resource type name. @@ -1491,16 +1506,12 @@ class ResourceTypeAliases(msrest.serialization.Model): """ _attribute_map = { - 'resource_type': {'key': 'resourceType', 'type': 'str'}, - 'aliases': {'key': 'aliases', 'type': '[Alias]'}, + "resource_type": {"key": "resourceType", "type": "str"}, + "aliases": {"key": "aliases", "type": "[Alias]"}, } def __init__( - self, - *, - resource_type: Optional[str] = None, - aliases: Optional[List["Alias"]] = None, - **kwargs + self, *, resource_type: Optional[str] = None, aliases: Optional[List["_models.Alias"]] = None, **kwargs ): """ :keyword resource_type: The resource type name. @@ -1508,25 +1519,25 @@ def __init__( :keyword aliases: The aliases for property names. :paramtype aliases: list[~azure.mgmt.resource.policy.v2021_06_01.models.Alias] """ - super(ResourceTypeAliases, self).__init__(**kwargs) + super().__init__(**kwargs) self.resource_type = resource_type self.aliases = aliases -class SystemData(msrest.serialization.Model): +class SystemData(_serialization.Model): """Metadata pertaining to creation and last modification of the resource. :ivar created_by: The identity that created the resource. :vartype created_by: str - :ivar created_by_type: The type of identity that created the resource. Possible values include: - "User", "Application", "ManagedIdentity", "Key". + :ivar created_by_type: The type of identity that created the resource. Known values are: + "User", "Application", "ManagedIdentity", and "Key". :vartype created_by_type: str or ~azure.mgmt.resource.policy.v2021_06_01.models.CreatedByType :ivar created_at: The timestamp of resource creation (UTC). :vartype created_at: ~datetime.datetime :ivar last_modified_by: The identity that last modified the resource. :vartype last_modified_by: str - :ivar last_modified_by_type: The type of identity that last modified the resource. Possible - values include: "User", "Application", "ManagedIdentity", "Key". + :ivar last_modified_by_type: The type of identity that last modified the resource. Known values + are: "User", "Application", "ManagedIdentity", and "Key". :vartype last_modified_by_type: str or ~azure.mgmt.resource.policy.v2021_06_01.models.CreatedByType :ivar last_modified_at: The timestamp of resource last modification (UTC). @@ -1534,43 +1545,43 @@ class SystemData(msrest.serialization.Model): """ _attribute_map = { - 'created_by': {'key': 'createdBy', 'type': 'str'}, - 'created_by_type': {'key': 'createdByType', 'type': 'str'}, - 'created_at': {'key': 'createdAt', 'type': 'iso-8601'}, - 'last_modified_by': {'key': 'lastModifiedBy', 'type': 'str'}, - 'last_modified_by_type': {'key': 'lastModifiedByType', 'type': 'str'}, - 'last_modified_at': {'key': 'lastModifiedAt', 'type': 'iso-8601'}, + "created_by": {"key": "createdBy", "type": "str"}, + "created_by_type": {"key": "createdByType", "type": "str"}, + "created_at": {"key": "createdAt", "type": "iso-8601"}, + "last_modified_by": {"key": "lastModifiedBy", "type": "str"}, + "last_modified_by_type": {"key": "lastModifiedByType", "type": "str"}, + "last_modified_at": {"key": "lastModifiedAt", "type": "iso-8601"}, } def __init__( self, *, created_by: Optional[str] = None, - created_by_type: Optional[Union[str, "CreatedByType"]] = None, + created_by_type: Optional[Union[str, "_models.CreatedByType"]] = None, created_at: Optional[datetime.datetime] = None, last_modified_by: Optional[str] = None, - last_modified_by_type: Optional[Union[str, "CreatedByType"]] = None, + last_modified_by_type: Optional[Union[str, "_models.CreatedByType"]] = None, last_modified_at: Optional[datetime.datetime] = None, **kwargs ): """ :keyword created_by: The identity that created the resource. :paramtype created_by: str - :keyword created_by_type: The type of identity that created the resource. Possible values - include: "User", "Application", "ManagedIdentity", "Key". + :keyword created_by_type: The type of identity that created the resource. Known values are: + "User", "Application", "ManagedIdentity", and "Key". :paramtype created_by_type: str or ~azure.mgmt.resource.policy.v2021_06_01.models.CreatedByType :keyword created_at: The timestamp of resource creation (UTC). :paramtype created_at: ~datetime.datetime :keyword last_modified_by: The identity that last modified the resource. :paramtype last_modified_by: str - :keyword last_modified_by_type: The type of identity that last modified the resource. Possible - values include: "User", "Application", "ManagedIdentity", "Key". + :keyword last_modified_by_type: The type of identity that last modified the resource. Known + values are: "User", "Application", "ManagedIdentity", and "Key". :paramtype last_modified_by_type: str or ~azure.mgmt.resource.policy.v2021_06_01.models.CreatedByType :keyword last_modified_at: The timestamp of resource last modification (UTC). :paramtype last_modified_at: ~datetime.datetime """ - super(SystemData, self).__init__(**kwargs) + super().__init__(**kwargs) self.created_by = created_by self.created_by_type = created_by_type self.created_at = created_at @@ -1579,7 +1590,7 @@ def __init__( self.last_modified_at = last_modified_at -class UserAssignedIdentitiesValue(msrest.serialization.Model): +class UserAssignedIdentitiesValue(_serialization.Model): """UserAssignedIdentitiesValue. Variables are only populated by the server, and will be ignored when sending a request. @@ -1591,21 +1602,177 @@ class UserAssignedIdentitiesValue(msrest.serialization.Model): """ _validation = { - 'principal_id': {'readonly': True}, - 'client_id': {'readonly': True}, + "principal_id": {"readonly": True}, + "client_id": {"readonly": True}, } _attribute_map = { - 'principal_id': {'key': 'principalId', 'type': 'str'}, - 'client_id': {'key': 'clientId', 'type': 'str'}, + "principal_id": {"key": "principalId", "type": "str"}, + "client_id": {"key": "clientId", "type": "str"}, } - def __init__( - self, - **kwargs - ): - """ - """ - super(UserAssignedIdentitiesValue, self).__init__(**kwargs) + def __init__(self, **kwargs): + """ """ + super().__init__(**kwargs) self.principal_id = None self.client_id = None + + +class Variable(_serialization.Model): + """The variable. + + Variables are only populated by the server, and will be ignored when sending a request. + + All required parameters must be populated in order to send to Azure. + + :ivar system_data: Azure Resource Manager metadata containing createdBy and modifiedBy + information. + :vartype system_data: ~azure.mgmt.resource.policy.v2021_06_01.models.SystemData + :ivar id: The ID of the variable. + :vartype id: str + :ivar name: The name of the variable. + :vartype name: str + :ivar type: The type of the resource (Microsoft.Authorization/variables). + :vartype type: str + :ivar columns: Variable column definitions. Required. + :vartype columns: list[~azure.mgmt.resource.policy.v2021_06_01.models.PolicyVariableColumn] + """ + + _validation = { + "system_data": {"readonly": True}, + "id": {"readonly": True}, + "name": {"readonly": True}, + "type": {"readonly": True}, + "columns": {"required": True}, + } + + _attribute_map = { + "system_data": {"key": "systemData", "type": "SystemData"}, + "id": {"key": "id", "type": "str"}, + "name": {"key": "name", "type": "str"}, + "type": {"key": "type", "type": "str"}, + "columns": {"key": "properties.columns", "type": "[PolicyVariableColumn]"}, + } + + def __init__(self, *, columns: List["_models.PolicyVariableColumn"], **kwargs): + """ + :keyword columns: Variable column definitions. Required. + :paramtype columns: list[~azure.mgmt.resource.policy.v2021_06_01.models.PolicyVariableColumn] + """ + super().__init__(**kwargs) + self.system_data = None + self.id = None + self.name = None + self.type = None + self.columns = columns + + +class VariableListResult(_serialization.Model): + """List of variables. + + Variables are only populated by the server, and will be ignored when sending a request. + + :ivar value: An array of variables. + :vartype value: list[~azure.mgmt.resource.policy.v2021_06_01.models.Variable] + :ivar next_link: The URL to use for getting the next set of results. + :vartype next_link: str + """ + + _validation = { + "next_link": {"readonly": True}, + } + + _attribute_map = { + "value": {"key": "value", "type": "[Variable]"}, + "next_link": {"key": "nextLink", "type": "str"}, + } + + def __init__(self, *, value: Optional[List["_models.Variable"]] = None, **kwargs): + """ + :keyword value: An array of variables. + :paramtype value: list[~azure.mgmt.resource.policy.v2021_06_01.models.Variable] + """ + super().__init__(**kwargs) + self.value = value + self.next_link = None + + +class VariableValue(_serialization.Model): + """The variable value. + + Variables are only populated by the server, and will be ignored when sending a request. + + All required parameters must be populated in order to send to Azure. + + :ivar system_data: Azure Resource Manager metadata containing createdBy and modifiedBy + information. + :vartype system_data: ~azure.mgmt.resource.policy.v2021_06_01.models.SystemData + :ivar id: The ID of the variable. + :vartype id: str + :ivar name: The name of the variable. + :vartype name: str + :ivar type: The type of the resource (Microsoft.Authorization/variables/values). + :vartype type: str + :ivar values: Variable value column value array. Required. + :vartype values: + list[~azure.mgmt.resource.policy.v2021_06_01.models.PolicyVariableValueColumnValue] + """ + + _validation = { + "system_data": {"readonly": True}, + "id": {"readonly": True}, + "name": {"readonly": True}, + "type": {"readonly": True}, + "values": {"required": True}, + } + + _attribute_map = { + "system_data": {"key": "systemData", "type": "SystemData"}, + "id": {"key": "id", "type": "str"}, + "name": {"key": "name", "type": "str"}, + "type": {"key": "type", "type": "str"}, + "values": {"key": "properties.values", "type": "[PolicyVariableValueColumnValue]"}, + } + + def __init__(self, *, values: List["_models.PolicyVariableValueColumnValue"], **kwargs): + """ + :keyword values: Variable value column value array. Required. + :paramtype values: + list[~azure.mgmt.resource.policy.v2021_06_01.models.PolicyVariableValueColumnValue] + """ + super().__init__(**kwargs) + self.system_data = None + self.id = None + self.name = None + self.type = None + self.values = values + + +class VariableValueListResult(_serialization.Model): + """List of variable values. + + Variables are only populated by the server, and will be ignored when sending a request. + + :ivar value: An array of variable values. + :vartype value: list[~azure.mgmt.resource.policy.v2021_06_01.models.VariableValue] + :ivar next_link: The URL to use for getting the next set of results. + :vartype next_link: str + """ + + _validation = { + "next_link": {"readonly": True}, + } + + _attribute_map = { + "value": {"key": "value", "type": "[VariableValue]"}, + "next_link": {"key": "nextLink", "type": "str"}, + } + + def __init__(self, *, value: Optional[List["_models.VariableValue"]] = None, **kwargs): + """ + :keyword value: An array of variable values. + :paramtype value: list[~azure.mgmt.resource.policy.v2021_06_01.models.VariableValue] + """ + super().__init__(**kwargs) + self.value = value + self.next_link = None diff --git a/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/policy/v2021_06_01/models/_patch.py b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/policy/v2021_06_01/models/_patch.py new file mode 100644 index 0000000000000..f7dd32510333d --- /dev/null +++ b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/policy/v2021_06_01/models/_patch.py @@ -0,0 +1,20 @@ +# ------------------------------------ +# Copyright (c) Microsoft Corporation. +# Licensed under the MIT License. +# ------------------------------------ +"""Customize generated code here. + +Follow our quickstart for examples: https://aka.ms/azsdk/python/dpcodegen/python/customize +""" +from typing import List + +__all__: List[str] = [] # Add all objects you want publicly available to users at this package level + + +def patch_sdk(): + """Do not remove from this file. + + `patch_sdk` is a last resort escape hatch that allows you to do customizations + you can't accomplish using the techniques described in + https://aka.ms/azsdk/python/dpcodegen/python/customize + """ diff --git a/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/policy/v2021_06_01/models/_policy_client_enums.py b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/policy/v2021_06_01/models/_policy_client_enums.py index 10eb931285027..d3c9137c492fa 100644 --- a/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/policy/v2021_06_01/models/_policy_client_enums.py +++ b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/policy/v2021_06_01/models/_policy_client_enums.py @@ -7,22 +7,20 @@ # -------------------------------------------------------------------------- from enum import Enum -from six import with_metaclass from azure.core import CaseInsensitiveEnumMeta -class AliasPathAttributes(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): - """The attributes of the token that the alias path is referring to. - """ +class AliasPathAttributes(str, Enum, metaclass=CaseInsensitiveEnumMeta): + """The attributes of the token that the alias path is referring to.""" #: The token that the alias path is referring to has no attributes. NONE = "None" #: The token that the alias path is referring to is modifiable by policies with 'modify' effect. MODIFIABLE = "Modifiable" -class AliasPathTokenType(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): - """The type of the token that the alias path is referring to. - """ + +class AliasPathTokenType(str, Enum, metaclass=CaseInsensitiveEnumMeta): + """The type of the token that the alias path is referring to.""" #: The token type is not specified. NOT_SPECIFIED = "NotSpecified" @@ -41,18 +39,18 @@ class AliasPathTokenType(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): #: The token type is boolean. BOOLEAN = "Boolean" -class AliasPatternType(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): - """The type of alias pattern - """ + +class AliasPatternType(str, Enum, metaclass=CaseInsensitiveEnumMeta): + """The type of alias pattern.""" #: NotSpecified is not allowed. NOT_SPECIFIED = "NotSpecified" #: Extract is the only allowed value. EXTRACT = "Extract" -class AliasType(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): - """The type of the alias. - """ + +class AliasType(str, Enum, metaclass=CaseInsensitiveEnumMeta): + """The type of the alias.""" #: Alias type is unknown (same as not providing alias type). NOT_SPECIFIED = "NotSpecified" @@ -61,27 +59,27 @@ class AliasType(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): #: Alias value is secret. MASK = "Mask" -class CreatedByType(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): - """The type of identity that created the resource. - """ + +class CreatedByType(str, Enum, metaclass=CaseInsensitiveEnumMeta): + """The type of identity that created the resource.""" USER = "User" APPLICATION = "Application" MANAGED_IDENTITY = "ManagedIdentity" KEY = "Key" -class EnforcementMode(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): - """The policy assignment enforcement mode. Possible values are Default and DoNotEnforce. - """ + +class EnforcementMode(str, Enum, metaclass=CaseInsensitiveEnumMeta): + """The policy assignment enforcement mode. Possible values are Default and DoNotEnforce.""" #: The policy effect is enforced during resource creation or update. DEFAULT = "Default" #: The policy effect is not enforced during resource creation or update. DO_NOT_ENFORCE = "DoNotEnforce" -class ExemptionCategory(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): - """The policy exemption category. Possible values are Waiver and Mitigated. - """ + +class ExemptionCategory(str, Enum, metaclass=CaseInsensitiveEnumMeta): + """The policy exemption category. Possible values are Waiver and Mitigated.""" #: This category of exemptions usually means the scope is not applicable for the policy. WAIVER = "Waiver" @@ -89,9 +87,9 @@ class ExemptionCategory(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): #: scope. MITIGATED = "Mitigated" -class ParameterType(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): - """The data type of the parameter. - """ + +class ParameterType(str, Enum, metaclass=CaseInsensitiveEnumMeta): + """The data type of the parameter.""" STRING = "String" ARRAY = "Array" @@ -101,16 +99,17 @@ class ParameterType(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): FLOAT = "Float" DATE_TIME = "DateTime" -class PolicyType(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): - """The type of policy definition. Possible values are NotSpecified, BuiltIn, Custom, and Static. - """ + +class PolicyType(str, Enum, metaclass=CaseInsensitiveEnumMeta): + """The type of policy definition. Possible values are NotSpecified, BuiltIn, Custom, and Static.""" NOT_SPECIFIED = "NotSpecified" BUILT_IN = "BuiltIn" CUSTOM = "Custom" STATIC = "Static" -class ResourceIdentityType(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): + +class ResourceIdentityType(str, Enum, metaclass=CaseInsensitiveEnumMeta): """The identity type. This is the only required field when adding a system or user assigned identity to a resource. """ diff --git a/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/policy/v2021_06_01/operations/__init__.py b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/policy/v2021_06_01/operations/__init__.py index 07b8f47f6b817..fb12b9c0f5fde 100644 --- a/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/policy/v2021_06_01/operations/__init__.py +++ b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/policy/v2021_06_01/operations/__init__.py @@ -11,11 +11,21 @@ from ._operations import PolicyDefinitionsOperations from ._operations import PolicySetDefinitionsOperations from ._operations import PolicyExemptionsOperations +from ._operations import VariablesOperations +from ._operations import VariableValuesOperations + +from ._patch import __all__ as _patch_all +from ._patch import * # type: ignore # pylint: disable=unused-wildcard-import +from ._patch import patch_sdk as _patch_sdk __all__ = [ - 'DataPolicyManifestsOperations', - 'PolicyAssignmentsOperations', - 'PolicyDefinitionsOperations', - 'PolicySetDefinitionsOperations', - 'PolicyExemptionsOperations', + "DataPolicyManifestsOperations", + "PolicyAssignmentsOperations", + "PolicyDefinitionsOperations", + "PolicySetDefinitionsOperations", + "PolicyExemptionsOperations", + "VariablesOperations", + "VariableValuesOperations", ] +__all__.extend([p for p in _patch_all if p not in __all__]) +_patch_sdk() diff --git a/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/policy/v2021_06_01/operations/_operations.py b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/policy/v2021_06_01/operations/_operations.py index c8b773e3988b0..2b54a968098a0 100644 --- a/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/policy/v2021_06_01/operations/_operations.py +++ b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/policy/v2021_06_01/operations/_operations.py @@ -6,239 +6,192 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -from typing import Any, Callable, Dict, Iterable, Optional, TypeVar - -from msrest import Serializer - -from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error +from typing import Any, Callable, Dict, IO, Iterable, Optional, TypeVar, Union, overload + +from azure.core.exceptions import ( + ClientAuthenticationError, + HttpResponseError, + ResourceExistsError, + ResourceNotFoundError, + ResourceNotModifiedError, + map_error, +) from azure.core.paging import ItemPaged from azure.core.pipeline import PipelineResponse from azure.core.pipeline.transport import HttpResponse from azure.core.rest import HttpRequest from azure.core.tracing.decorator import distributed_trace +from azure.core.utils import case_insensitive_dict from azure.mgmt.core.exceptions import ARMErrorFormat from .. import models as _models +from ..._serialization import Serializer from .._vendor import _convert_request, _format_url_section -T = TypeVar('T') + +T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] -JSONType = Any _SERIALIZER = Serializer() _SERIALIZER.client_side_validation = False -def build_data_policy_manifests_get_by_policy_mode_request( - policy_mode: str, - **kwargs: Any -) -> HttpRequest: - api_version = kwargs.pop('api_version', "2020-09-01") # type: str - accept = "application/json" +def build_data_policy_manifests_get_by_policy_mode_request(policy_mode: 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", "2020-09-01")) # type: str + accept = _headers.pop("Accept", "application/json") + # Construct URL _url = kwargs.pop("template_url", "/providers/Microsoft.Authorization/dataPolicyManifests/{policyMode}") path_format_arguments = { - "policyMode": _SERIALIZER.url("policy_mode", policy_mode, 'str'), + "policyMode": _SERIALIZER.url("policy_mode", policy_mode, "str"), } _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') - - return HttpRequest( - method="GET", - url=_url, - params=_query_parameters, - headers=_header_parameters, - **kwargs - ) + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) -def build_data_policy_manifests_list_request( - *, - filter: Optional[str] = None, - **kwargs: Any -) -> HttpRequest: - api_version = kwargs.pop('api_version', "2020-09-01") # type: str - accept = "application/json" +def build_data_policy_manifests_list_request(*, filter: Optional[str] = None, **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", "2020-09-01")) # type: str + accept = _headers.pop("Accept", "application/json") + # Construct URL _url = kwargs.pop("template_url", "/providers/Microsoft.Authorization/dataPolicyManifests") # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") if filter is not None: - _query_parameters['$filter'] = _SERIALIZER.query("filter", filter, 'str', skip_quote=True) + _params["$filter"] = _SERIALIZER.query("filter", filter, "str", skip_quote=True) # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') - - return HttpRequest( - method="GET", - url=_url, - params=_query_parameters, - headers=_header_parameters, - **kwargs - ) + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) -def build_policy_assignments_delete_request( - scope: str, - policy_assignment_name: str, - **kwargs: Any -) -> HttpRequest: - api_version = kwargs.pop('api_version', "2021-06-01") # type: str - accept = "application/json" +def build_policy_assignments_delete_request(scope: str, policy_assignment_name: 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: str + accept = _headers.pop("Accept", "application/json") + # Construct URL - _url = kwargs.pop("template_url", "/{scope}/providers/Microsoft.Authorization/policyAssignments/{policyAssignmentName}") + _url = kwargs.pop( + "template_url", "/{scope}/providers/Microsoft.Authorization/policyAssignments/{policyAssignmentName}" + ) path_format_arguments = { - "scope": _SERIALIZER.url("scope", scope, 'str', skip_quote=True), - "policyAssignmentName": _SERIALIZER.url("policy_assignment_name", policy_assignment_name, 'str'), + "scope": _SERIALIZER.url("scope", scope, "str", skip_quote=True), + "policyAssignmentName": _SERIALIZER.url("policy_assignment_name", policy_assignment_name, "str"), } _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') - - return HttpRequest( - method="DELETE", - url=_url, - params=_query_parameters, - headers=_header_parameters, - **kwargs - ) + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + return HttpRequest(method="DELETE", url=_url, params=_params, headers=_headers, **kwargs) -def build_policy_assignments_create_request( - scope: str, - policy_assignment_name: str, - *, - json: JSONType = None, - content: Any = None, - **kwargs: Any -) -> HttpRequest: - api_version = kwargs.pop('api_version', "2021-06-01") # type: str - content_type = kwargs.pop('content_type', None) # type: Optional[str] - accept = "application/json" +def build_policy_assignments_create_request(scope: str, policy_assignment_name: 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: str + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + accept = _headers.pop("Accept", "application/json") + # Construct URL - _url = kwargs.pop("template_url", "/{scope}/providers/Microsoft.Authorization/policyAssignments/{policyAssignmentName}") + _url = kwargs.pop( + "template_url", "/{scope}/providers/Microsoft.Authorization/policyAssignments/{policyAssignmentName}" + ) path_format_arguments = { - "scope": _SERIALIZER.url("scope", scope, 'str', skip_quote=True), - "policyAssignmentName": _SERIALIZER.url("policy_assignment_name", policy_assignment_name, 'str'), + "scope": _SERIALIZER.url("scope", scope, "str", skip_quote=True), + "policyAssignmentName": _SERIALIZER.url("policy_assignment_name", policy_assignment_name, "str"), } _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] if content_type is not None: - _header_parameters['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') - _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') - - return HttpRequest( - method="PUT", - url=_url, - params=_query_parameters, - headers=_header_parameters, - json=json, - content=content, - **kwargs - ) + _headers["Content-Type"] = _SERIALIZER.header("content_type", content_type, "str") + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + return HttpRequest(method="PUT", url=_url, params=_params, headers=_headers, **kwargs) -def build_policy_assignments_get_request( - scope: str, - policy_assignment_name: str, - **kwargs: Any -) -> HttpRequest: - api_version = kwargs.pop('api_version', "2021-06-01") # type: str - accept = "application/json" +def build_policy_assignments_get_request(scope: str, policy_assignment_name: 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: str + accept = _headers.pop("Accept", "application/json") + # Construct URL - _url = kwargs.pop("template_url", "/{scope}/providers/Microsoft.Authorization/policyAssignments/{policyAssignmentName}") + _url = kwargs.pop( + "template_url", "/{scope}/providers/Microsoft.Authorization/policyAssignments/{policyAssignmentName}" + ) path_format_arguments = { - "scope": _SERIALIZER.url("scope", scope, 'str', skip_quote=True), - "policyAssignmentName": _SERIALIZER.url("policy_assignment_name", policy_assignment_name, 'str'), + "scope": _SERIALIZER.url("scope", scope, "str", skip_quote=True), + "policyAssignmentName": _SERIALIZER.url("policy_assignment_name", policy_assignment_name, "str"), } _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') - - return HttpRequest( - method="GET", - url=_url, - params=_query_parameters, - headers=_header_parameters, - **kwargs - ) + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) -def build_policy_assignments_update_request( - scope: str, - policy_assignment_name: str, - *, - json: JSONType = None, - content: Any = None, - **kwargs: Any -) -> HttpRequest: - api_version = kwargs.pop('api_version', "2021-06-01") # type: str - content_type = kwargs.pop('content_type', None) # type: Optional[str] - accept = "application/json" +def build_policy_assignments_update_request(scope: str, policy_assignment_name: 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: str + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + accept = _headers.pop("Accept", "application/json") + # Construct URL - _url = kwargs.pop("template_url", "/{scope}/providers/Microsoft.Authorization/policyAssignments/{policyAssignmentName}") + _url = kwargs.pop( + "template_url", "/{scope}/providers/Microsoft.Authorization/policyAssignments/{policyAssignmentName}" + ) path_format_arguments = { - "scope": _SERIALIZER.url("scope", scope, 'str', skip_quote=True), - "policyAssignmentName": _SERIALIZER.url("policy_assignment_name", policy_assignment_name, 'str'), + "scope": _SERIALIZER.url("scope", scope, "str", skip_quote=True), + "policyAssignmentName": _SERIALIZER.url("policy_assignment_name", policy_assignment_name, "str"), } _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] if content_type is not None: - _header_parameters['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') - _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') - - return HttpRequest( - method="PATCH", - url=_url, - params=_query_parameters, - headers=_header_parameters, - json=json, - content=content, - **kwargs - ) + _headers["Content-Type"] = _SERIALIZER.header("content_type", content_type, "str") + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="PATCH", url=_url, params=_params, headers=_headers, **kwargs) def build_policy_assignments_list_for_resource_group_request( @@ -249,37 +202,37 @@ def build_policy_assignments_list_for_resource_group_request( top: Optional[int] = None, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2021-06-01") # type: 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: str + accept = _headers.pop("Accept", "application/json") - accept = "application/json" # Construct URL - _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Authorization/policyAssignments") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Authorization/policyAssignments", + ) # pylint: disable=line-too-long path_format_arguments = { - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._\(\)]+$'), - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), + "resourceGroupName": _SERIALIZER.url( + "resource_group_name", resource_group_name, "str", max_length=90, min_length=1, pattern=r"^[-\w\._\(\)]+$" + ), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), } _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] if filter is not None: - _query_parameters['$filter'] = _SERIALIZER.query("filter", filter, 'str', skip_quote=True) + _params["$filter"] = _SERIALIZER.query("filter", filter, "str", skip_quote=True) if top is not None: - _query_parameters['$top'] = _SERIALIZER.query("top", top, 'int', maximum=1000, minimum=1) - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["$top"] = _SERIALIZER.query("top", top, "int", maximum=1000, minimum=1) + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') - - return HttpRequest( - method="GET", - url=_url, - params=_query_parameters, - headers=_header_parameters, - **kwargs - ) + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) def build_policy_assignments_list_for_resource_request( @@ -294,1342 +247,1594 @@ def build_policy_assignments_list_for_resource_request( top: Optional[int] = None, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2021-06-01") # type: 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: str + accept = _headers.pop("Accept", "application/json") - accept = "application/json" # Construct URL - _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{parentResourcePath}/{resourceType}/{resourceName}/providers/Microsoft.Authorization/policyAssignments") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{parentResourcePath}/{resourceType}/{resourceName}/providers/Microsoft.Authorization/policyAssignments", + ) # pylint: disable=line-too-long path_format_arguments = { - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._\(\)]+$'), - "resourceProviderNamespace": _SERIALIZER.url("resource_provider_namespace", resource_provider_namespace, 'str'), - "parentResourcePath": _SERIALIZER.url("parent_resource_path", parent_resource_path, 'str', skip_quote=True), - "resourceType": _SERIALIZER.url("resource_type", resource_type, 'str', skip_quote=True), - "resourceName": _SERIALIZER.url("resource_name", resource_name, 'str'), - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), + "resourceGroupName": _SERIALIZER.url( + "resource_group_name", resource_group_name, "str", max_length=90, min_length=1, pattern=r"^[-\w\._\(\)]+$" + ), + "resourceProviderNamespace": _SERIALIZER.url("resource_provider_namespace", resource_provider_namespace, "str"), + "parentResourcePath": _SERIALIZER.url("parent_resource_path", parent_resource_path, "str", skip_quote=True), + "resourceType": _SERIALIZER.url("resource_type", resource_type, "str", skip_quote=True), + "resourceName": _SERIALIZER.url("resource_name", resource_name, "str"), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), } _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] if filter is not None: - _query_parameters['$filter'] = _SERIALIZER.query("filter", filter, 'str', skip_quote=True) + _params["$filter"] = _SERIALIZER.query("filter", filter, "str", skip_quote=True) if top is not None: - _query_parameters['$top'] = _SERIALIZER.query("top", top, 'int', maximum=1000, minimum=1) - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["$top"] = _SERIALIZER.query("top", top, "int", maximum=1000, minimum=1) + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') - - return HttpRequest( - method="GET", - url=_url, - params=_query_parameters, - headers=_header_parameters, - **kwargs - ) + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) def build_policy_assignments_list_for_management_group_request( - management_group_id: str, - *, - filter: Optional[str] = None, - top: Optional[int] = None, - **kwargs: Any + management_group_id: str, *, filter: Optional[str] = None, top: Optional[int] = None, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2021-06-01") # type: 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: str + accept = _headers.pop("Accept", "application/json") - accept = "application/json" # Construct URL - _url = kwargs.pop("template_url", "/providers/Microsoft.Management/managementGroups/{managementGroupId}/providers/Microsoft.Authorization/policyAssignments") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", + "/providers/Microsoft.Management/managementGroups/{managementGroupId}/providers/Microsoft.Authorization/policyAssignments", + ) # pylint: disable=line-too-long path_format_arguments = { - "managementGroupId": _SERIALIZER.url("management_group_id", management_group_id, 'str'), + "managementGroupId": _SERIALIZER.url("management_group_id", management_group_id, "str"), } _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] if filter is not None: - _query_parameters['$filter'] = _SERIALIZER.query("filter", filter, 'str', skip_quote=True) + _params["$filter"] = _SERIALIZER.query("filter", filter, "str", skip_quote=True) if top is not None: - _query_parameters['$top'] = _SERIALIZER.query("top", top, 'int', maximum=1000, minimum=1) - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["$top"] = _SERIALIZER.query("top", top, "int", maximum=1000, minimum=1) + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') - - return HttpRequest( - method="GET", - url=_url, - params=_query_parameters, - headers=_header_parameters, - **kwargs - ) + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) def build_policy_assignments_list_request( - subscription_id: str, - *, - filter: Optional[str] = None, - top: Optional[int] = None, - **kwargs: Any + subscription_id: str, *, filter: Optional[str] = None, top: Optional[int] = None, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2021-06-01") # type: 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: str + accept = _headers.pop("Accept", "application/json") - accept = "application/json" # Construct URL - _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/providers/Microsoft.Authorization/policyAssignments") + _url = kwargs.pop( + "template_url", "/subscriptions/{subscriptionId}/providers/Microsoft.Authorization/policyAssignments" + ) path_format_arguments = { - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), } _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] if filter is not None: - _query_parameters['$filter'] = _SERIALIZER.query("filter", filter, 'str', skip_quote=True) + _params["$filter"] = _SERIALIZER.query("filter", filter, "str", skip_quote=True) if top is not None: - _query_parameters['$top'] = _SERIALIZER.query("top", top, 'int', maximum=1000, minimum=1) - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["$top"] = _SERIALIZER.query("top", top, "int", maximum=1000, minimum=1) + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') - - return HttpRequest( - method="GET", - url=_url, - params=_query_parameters, - headers=_header_parameters, - **kwargs - ) + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) -def build_policy_assignments_delete_by_id_request( - policy_assignment_id: str, - **kwargs: Any -) -> HttpRequest: - api_version = kwargs.pop('api_version', "2021-06-01") # type: str - accept = "application/json" +def build_policy_assignments_delete_by_id_request(policy_assignment_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: str + accept = _headers.pop("Accept", "application/json") + # Construct URL _url = kwargs.pop("template_url", "/{policyAssignmentId}") path_format_arguments = { - "policyAssignmentId": _SERIALIZER.url("policy_assignment_id", policy_assignment_id, 'str', skip_quote=True), + "policyAssignmentId": _SERIALIZER.url("policy_assignment_id", policy_assignment_id, "str", skip_quote=True), } _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') - - return HttpRequest( - method="DELETE", - url=_url, - params=_query_parameters, - headers=_header_parameters, - **kwargs - ) + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + return HttpRequest(method="DELETE", url=_url, params=_params, headers=_headers, **kwargs) -def build_policy_assignments_create_by_id_request( - policy_assignment_id: str, - *, - json: JSONType = None, - content: Any = None, - **kwargs: Any -) -> HttpRequest: - api_version = kwargs.pop('api_version', "2021-06-01") # type: str - content_type = kwargs.pop('content_type', None) # type: Optional[str] - accept = "application/json" +def build_policy_assignments_create_by_id_request(policy_assignment_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: str + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + accept = _headers.pop("Accept", "application/json") + # Construct URL _url = kwargs.pop("template_url", "/{policyAssignmentId}") path_format_arguments = { - "policyAssignmentId": _SERIALIZER.url("policy_assignment_id", policy_assignment_id, 'str', skip_quote=True), + "policyAssignmentId": _SERIALIZER.url("policy_assignment_id", policy_assignment_id, "str", skip_quote=True), } _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] if content_type is not None: - _header_parameters['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') - _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') - - return HttpRequest( - method="PUT", - url=_url, - params=_query_parameters, - headers=_header_parameters, - json=json, - content=content, - **kwargs - ) + _headers["Content-Type"] = _SERIALIZER.header("content_type", content_type, "str") + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + return HttpRequest(method="PUT", url=_url, params=_params, headers=_headers, **kwargs) -def build_policy_assignments_get_by_id_request( - policy_assignment_id: str, - **kwargs: Any -) -> HttpRequest: - api_version = kwargs.pop('api_version', "2021-06-01") # type: str - accept = "application/json" +def build_policy_assignments_get_by_id_request(policy_assignment_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: str + accept = _headers.pop("Accept", "application/json") + # Construct URL _url = kwargs.pop("template_url", "/{policyAssignmentId}") path_format_arguments = { - "policyAssignmentId": _SERIALIZER.url("policy_assignment_id", policy_assignment_id, 'str', skip_quote=True), + "policyAssignmentId": _SERIALIZER.url("policy_assignment_id", policy_assignment_id, "str", skip_quote=True), } _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') - - return HttpRequest( - method="GET", - url=_url, - params=_query_parameters, - headers=_header_parameters, - **kwargs - ) + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) -def build_policy_assignments_update_by_id_request( - policy_assignment_id: str, - *, - json: JSONType = None, - content: Any = None, - **kwargs: Any -) -> HttpRequest: - api_version = kwargs.pop('api_version', "2021-06-01") # type: str - content_type = kwargs.pop('content_type', None) # type: Optional[str] - accept = "application/json" +def build_policy_assignments_update_by_id_request(policy_assignment_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: str + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + accept = _headers.pop("Accept", "application/json") + # Construct URL _url = kwargs.pop("template_url", "/{policyAssignmentId}") path_format_arguments = { - "policyAssignmentId": _SERIALIZER.url("policy_assignment_id", policy_assignment_id, 'str', skip_quote=True), + "policyAssignmentId": _SERIALIZER.url("policy_assignment_id", policy_assignment_id, "str", skip_quote=True), } _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] if content_type is not None: - _header_parameters['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') - _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') - - return HttpRequest( - method="PATCH", - url=_url, - params=_query_parameters, - headers=_header_parameters, - json=json, - content=content, - **kwargs - ) + _headers["Content-Type"] = _SERIALIZER.header("content_type", content_type, "str") + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="PATCH", url=_url, params=_params, headers=_headers, **kwargs) def build_policy_definitions_create_or_update_request( - policy_definition_name: str, - subscription_id: str, - *, - json: JSONType = None, - content: Any = None, - **kwargs: Any + policy_definition_name: str, subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2021-06-01") # type: str - content_type = kwargs.pop('content_type', None) # type: Optional[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: str + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + accept = _headers.pop("Accept", "application/json") - accept = "application/json" # Construct URL - _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/providers/Microsoft.Authorization/policyDefinitions/{policyDefinitionName}") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/providers/Microsoft.Authorization/policyDefinitions/{policyDefinitionName}", + ) # pylint: disable=line-too-long path_format_arguments = { - "policyDefinitionName": _SERIALIZER.url("policy_definition_name", policy_definition_name, 'str'), - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), + "policyDefinitionName": _SERIALIZER.url("policy_definition_name", policy_definition_name, "str"), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), } _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] if content_type is not None: - _header_parameters['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') - _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') - - return HttpRequest( - method="PUT", - url=_url, - params=_query_parameters, - headers=_header_parameters, - json=json, - content=content, - **kwargs - ) + _headers["Content-Type"] = _SERIALIZER.header("content_type", content_type, "str") + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="PUT", url=_url, params=_params, headers=_headers, **kwargs) def build_policy_definitions_delete_request( - policy_definition_name: str, - subscription_id: str, - **kwargs: Any + policy_definition_name: str, subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2021-06-01") # type: 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: str + accept = _headers.pop("Accept", "application/json") - accept = "application/json" # Construct URL - _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/providers/Microsoft.Authorization/policyDefinitions/{policyDefinitionName}") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/providers/Microsoft.Authorization/policyDefinitions/{policyDefinitionName}", + ) # pylint: disable=line-too-long path_format_arguments = { - "policyDefinitionName": _SERIALIZER.url("policy_definition_name", policy_definition_name, 'str'), - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), + "policyDefinitionName": _SERIALIZER.url("policy_definition_name", policy_definition_name, "str"), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), } _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') - - return HttpRequest( - method="DELETE", - url=_url, - params=_query_parameters, - headers=_header_parameters, - **kwargs - ) + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="DELETE", url=_url, params=_params, headers=_headers, **kwargs) def build_policy_definitions_get_request( - policy_definition_name: str, - subscription_id: str, - **kwargs: Any + policy_definition_name: str, subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2021-06-01") # type: 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: str + accept = _headers.pop("Accept", "application/json") - accept = "application/json" # Construct URL - _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/providers/Microsoft.Authorization/policyDefinitions/{policyDefinitionName}") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/providers/Microsoft.Authorization/policyDefinitions/{policyDefinitionName}", + ) # pylint: disable=line-too-long path_format_arguments = { - "policyDefinitionName": _SERIALIZER.url("policy_definition_name", policy_definition_name, 'str'), - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), + "policyDefinitionName": _SERIALIZER.url("policy_definition_name", policy_definition_name, "str"), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), } _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') - - return HttpRequest( - method="GET", - url=_url, - params=_query_parameters, - headers=_header_parameters, - **kwargs - ) + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) -def build_policy_definitions_get_built_in_request( - policy_definition_name: str, - **kwargs: Any -) -> HttpRequest: - api_version = kwargs.pop('api_version', "2021-06-01") # type: str - accept = "application/json" +def build_policy_definitions_get_built_in_request(policy_definition_name: 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: str + accept = _headers.pop("Accept", "application/json") + # Construct URL _url = kwargs.pop("template_url", "/providers/Microsoft.Authorization/policyDefinitions/{policyDefinitionName}") path_format_arguments = { - "policyDefinitionName": _SERIALIZER.url("policy_definition_name", policy_definition_name, 'str'), + "policyDefinitionName": _SERIALIZER.url("policy_definition_name", policy_definition_name, "str"), } _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') - - return HttpRequest( - method="GET", - url=_url, - params=_query_parameters, - headers=_header_parameters, - **kwargs - ) + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) def build_policy_definitions_create_or_update_at_management_group_request( - policy_definition_name: str, - management_group_id: str, - *, - json: JSONType = None, - content: Any = None, - **kwargs: Any + policy_definition_name: str, management_group_id: str, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2021-06-01") # type: str - content_type = kwargs.pop('content_type', None) # type: Optional[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: str + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + accept = _headers.pop("Accept", "application/json") - accept = "application/json" # Construct URL - _url = kwargs.pop("template_url", "/providers/Microsoft.Management/managementGroups/{managementGroupId}/providers/Microsoft.Authorization/policyDefinitions/{policyDefinitionName}") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", + "/providers/Microsoft.Management/managementGroups/{managementGroupId}/providers/Microsoft.Authorization/policyDefinitions/{policyDefinitionName}", + ) # pylint: disable=line-too-long path_format_arguments = { - "policyDefinitionName": _SERIALIZER.url("policy_definition_name", policy_definition_name, 'str'), - "managementGroupId": _SERIALIZER.url("management_group_id", management_group_id, 'str'), + "policyDefinitionName": _SERIALIZER.url("policy_definition_name", policy_definition_name, "str"), + "managementGroupId": _SERIALIZER.url("management_group_id", management_group_id, "str"), } _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] if content_type is not None: - _header_parameters['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') - _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') - - return HttpRequest( - method="PUT", - url=_url, - params=_query_parameters, - headers=_header_parameters, - json=json, - content=content, - **kwargs - ) + _headers["Content-Type"] = _SERIALIZER.header("content_type", content_type, "str") + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="PUT", url=_url, params=_params, headers=_headers, **kwargs) def build_policy_definitions_delete_at_management_group_request( - policy_definition_name: str, - management_group_id: str, - **kwargs: Any + policy_definition_name: str, management_group_id: str, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2021-06-01") # type: 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: str + accept = _headers.pop("Accept", "application/json") - accept = "application/json" # Construct URL - _url = kwargs.pop("template_url", "/providers/Microsoft.Management/managementGroups/{managementGroupId}/providers/Microsoft.Authorization/policyDefinitions/{policyDefinitionName}") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", + "/providers/Microsoft.Management/managementGroups/{managementGroupId}/providers/Microsoft.Authorization/policyDefinitions/{policyDefinitionName}", + ) # pylint: disable=line-too-long path_format_arguments = { - "policyDefinitionName": _SERIALIZER.url("policy_definition_name", policy_definition_name, 'str'), - "managementGroupId": _SERIALIZER.url("management_group_id", management_group_id, 'str'), + "policyDefinitionName": _SERIALIZER.url("policy_definition_name", policy_definition_name, "str"), + "managementGroupId": _SERIALIZER.url("management_group_id", management_group_id, "str"), } _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') - - return HttpRequest( - method="DELETE", - url=_url, - params=_query_parameters, - headers=_header_parameters, - **kwargs - ) + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="DELETE", url=_url, params=_params, headers=_headers, **kwargs) def build_policy_definitions_get_at_management_group_request( - policy_definition_name: str, - management_group_id: str, - **kwargs: Any + policy_definition_name: str, management_group_id: str, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2021-06-01") # type: 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: str + accept = _headers.pop("Accept", "application/json") - accept = "application/json" # Construct URL - _url = kwargs.pop("template_url", "/providers/Microsoft.Management/managementGroups/{managementGroupId}/providers/Microsoft.Authorization/policyDefinitions/{policyDefinitionName}") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", + "/providers/Microsoft.Management/managementGroups/{managementGroupId}/providers/Microsoft.Authorization/policyDefinitions/{policyDefinitionName}", + ) # pylint: disable=line-too-long path_format_arguments = { - "policyDefinitionName": _SERIALIZER.url("policy_definition_name", policy_definition_name, 'str'), - "managementGroupId": _SERIALIZER.url("management_group_id", management_group_id, 'str'), + "policyDefinitionName": _SERIALIZER.url("policy_definition_name", policy_definition_name, "str"), + "managementGroupId": _SERIALIZER.url("management_group_id", management_group_id, "str"), } _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') - - return HttpRequest( - method="GET", - url=_url, - params=_query_parameters, - headers=_header_parameters, - **kwargs - ) + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) def build_policy_definitions_list_request( - subscription_id: str, - *, - filter: Optional[str] = None, - top: Optional[int] = None, - **kwargs: Any + subscription_id: str, *, filter: Optional[str] = None, top: Optional[int] = None, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2021-06-01") # type: 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: str + accept = _headers.pop("Accept", "application/json") - accept = "application/json" # Construct URL - _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/providers/Microsoft.Authorization/policyDefinitions") + _url = kwargs.pop( + "template_url", "/subscriptions/{subscriptionId}/providers/Microsoft.Authorization/policyDefinitions" + ) path_format_arguments = { - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), } _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") if filter is not None: - _query_parameters['$filter'] = _SERIALIZER.query("filter", filter, 'str', skip_quote=True) + _params["$filter"] = _SERIALIZER.query("filter", filter, "str", skip_quote=True) if top is not None: - _query_parameters['$top'] = _SERIALIZER.query("top", top, 'int', maximum=1000, minimum=1) + _params["$top"] = _SERIALIZER.query("top", top, "int", maximum=1000, minimum=1) # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') - - return HttpRequest( - method="GET", - url=_url, - params=_query_parameters, - headers=_header_parameters, - **kwargs - ) + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) def build_policy_definitions_list_built_in_request( - *, - filter: Optional[str] = None, - top: Optional[int] = None, - **kwargs: Any + *, filter: Optional[str] = None, top: Optional[int] = None, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2021-06-01") # type: 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: str + accept = _headers.pop("Accept", "application/json") - accept = "application/json" # Construct URL _url = kwargs.pop("template_url", "/providers/Microsoft.Authorization/policyDefinitions") # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") if filter is not None: - _query_parameters['$filter'] = _SERIALIZER.query("filter", filter, 'str', skip_quote=True) + _params["$filter"] = _SERIALIZER.query("filter", filter, "str", skip_quote=True) if top is not None: - _query_parameters['$top'] = _SERIALIZER.query("top", top, 'int', maximum=1000, minimum=1) + _params["$top"] = _SERIALIZER.query("top", top, "int", maximum=1000, minimum=1) # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') - - return HttpRequest( - method="GET", - url=_url, - params=_query_parameters, - headers=_header_parameters, - **kwargs - ) + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) def build_policy_definitions_list_by_management_group_request( - management_group_id: str, - *, - filter: Optional[str] = None, - top: Optional[int] = None, - **kwargs: Any + management_group_id: str, *, filter: Optional[str] = None, top: Optional[int] = None, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2021-06-01") # type: 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: str + accept = _headers.pop("Accept", "application/json") - accept = "application/json" # Construct URL - _url = kwargs.pop("template_url", "/providers/Microsoft.Management/managementGroups/{managementGroupId}/providers/Microsoft.Authorization/policyDefinitions") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", + "/providers/Microsoft.Management/managementGroups/{managementGroupId}/providers/Microsoft.Authorization/policyDefinitions", + ) # pylint: disable=line-too-long path_format_arguments = { - "managementGroupId": _SERIALIZER.url("management_group_id", management_group_id, 'str'), + "managementGroupId": _SERIALIZER.url("management_group_id", management_group_id, "str"), } _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") if filter is not None: - _query_parameters['$filter'] = _SERIALIZER.query("filter", filter, 'str', skip_quote=True) + _params["$filter"] = _SERIALIZER.query("filter", filter, "str", skip_quote=True) if top is not None: - _query_parameters['$top'] = _SERIALIZER.query("top", top, 'int', maximum=1000, minimum=1) + _params["$top"] = _SERIALIZER.query("top", top, "int", maximum=1000, minimum=1) # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') - - return HttpRequest( - method="GET", - url=_url, - params=_query_parameters, - headers=_header_parameters, - **kwargs - ) + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) def build_policy_set_definitions_create_or_update_request( - policy_set_definition_name: str, - subscription_id: str, - *, - json: JSONType = None, - content: Any = None, - **kwargs: Any + policy_set_definition_name: str, subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2021-06-01") # type: str - content_type = kwargs.pop('content_type', None) # type: Optional[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: str + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + accept = _headers.pop("Accept", "application/json") - accept = "application/json" # Construct URL - _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/providers/Microsoft.Authorization/policySetDefinitions/{policySetDefinitionName}") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/providers/Microsoft.Authorization/policySetDefinitions/{policySetDefinitionName}", + ) # pylint: disable=line-too-long path_format_arguments = { - "policySetDefinitionName": _SERIALIZER.url("policy_set_definition_name", policy_set_definition_name, 'str'), - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), + "policySetDefinitionName": _SERIALIZER.url("policy_set_definition_name", policy_set_definition_name, "str"), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), } _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] if content_type is not None: - _header_parameters['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') - _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') - - return HttpRequest( - method="PUT", - url=_url, - params=_query_parameters, - headers=_header_parameters, - json=json, - content=content, - **kwargs - ) + _headers["Content-Type"] = _SERIALIZER.header("content_type", content_type, "str") + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="PUT", url=_url, params=_params, headers=_headers, **kwargs) def build_policy_set_definitions_delete_request( - policy_set_definition_name: str, - subscription_id: str, - **kwargs: Any + policy_set_definition_name: str, subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2021-06-01") # type: 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: str + accept = _headers.pop("Accept", "application/json") - accept = "application/json" # Construct URL - _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/providers/Microsoft.Authorization/policySetDefinitions/{policySetDefinitionName}") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/providers/Microsoft.Authorization/policySetDefinitions/{policySetDefinitionName}", + ) # pylint: disable=line-too-long path_format_arguments = { - "policySetDefinitionName": _SERIALIZER.url("policy_set_definition_name", policy_set_definition_name, 'str'), - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), + "policySetDefinitionName": _SERIALIZER.url("policy_set_definition_name", policy_set_definition_name, "str"), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), } _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') - - return HttpRequest( - method="DELETE", - url=_url, - params=_query_parameters, - headers=_header_parameters, - **kwargs - ) + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="DELETE", url=_url, params=_params, headers=_headers, **kwargs) def build_policy_set_definitions_get_request( - policy_set_definition_name: str, - subscription_id: str, - **kwargs: Any + policy_set_definition_name: str, subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2021-06-01") # type: 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: str + accept = _headers.pop("Accept", "application/json") - accept = "application/json" # Construct URL - _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/providers/Microsoft.Authorization/policySetDefinitions/{policySetDefinitionName}") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/providers/Microsoft.Authorization/policySetDefinitions/{policySetDefinitionName}", + ) # pylint: disable=line-too-long path_format_arguments = { - "policySetDefinitionName": _SERIALIZER.url("policy_set_definition_name", policy_set_definition_name, 'str'), - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), + "policySetDefinitionName": _SERIALIZER.url("policy_set_definition_name", policy_set_definition_name, "str"), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), } _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') - - return HttpRequest( - method="GET", - url=_url, - params=_query_parameters, - headers=_header_parameters, - **kwargs - ) + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) -def build_policy_set_definitions_get_built_in_request( - policy_set_definition_name: str, - **kwargs: Any -) -> HttpRequest: - api_version = kwargs.pop('api_version', "2021-06-01") # type: str - accept = "application/json" +def build_policy_set_definitions_get_built_in_request(policy_set_definition_name: 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: str + accept = _headers.pop("Accept", "application/json") + # Construct URL - _url = kwargs.pop("template_url", "/providers/Microsoft.Authorization/policySetDefinitions/{policySetDefinitionName}") + _url = kwargs.pop( + "template_url", "/providers/Microsoft.Authorization/policySetDefinitions/{policySetDefinitionName}" + ) path_format_arguments = { - "policySetDefinitionName": _SERIALIZER.url("policy_set_definition_name", policy_set_definition_name, 'str'), + "policySetDefinitionName": _SERIALIZER.url("policy_set_definition_name", policy_set_definition_name, "str"), } _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') - - return HttpRequest( - method="GET", - url=_url, - params=_query_parameters, - headers=_header_parameters, - **kwargs - ) + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) def build_policy_set_definitions_list_request( - subscription_id: str, - *, - filter: Optional[str] = None, - top: Optional[int] = None, - **kwargs: Any + subscription_id: str, *, filter: Optional[str] = None, top: Optional[int] = None, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2021-06-01") # type: 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: str + accept = _headers.pop("Accept", "application/json") - accept = "application/json" # Construct URL - _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/providers/Microsoft.Authorization/policySetDefinitions") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", "/subscriptions/{subscriptionId}/providers/Microsoft.Authorization/policySetDefinitions" + ) # pylint: disable=line-too-long path_format_arguments = { - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), } _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") if filter is not None: - _query_parameters['$filter'] = _SERIALIZER.query("filter", filter, 'str', skip_quote=True) + _params["$filter"] = _SERIALIZER.query("filter", filter, "str", skip_quote=True) if top is not None: - _query_parameters['$top'] = _SERIALIZER.query("top", top, 'int', maximum=1000, minimum=1) + _params["$top"] = _SERIALIZER.query("top", top, "int", maximum=1000, minimum=1) # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') - - return HttpRequest( - method="GET", - url=_url, - params=_query_parameters, - headers=_header_parameters, - **kwargs - ) + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) def build_policy_set_definitions_list_built_in_request( - *, - filter: Optional[str] = None, - top: Optional[int] = None, - **kwargs: Any + *, filter: Optional[str] = None, top: Optional[int] = None, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2021-06-01") # type: 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: str + accept = _headers.pop("Accept", "application/json") - accept = "application/json" # Construct URL _url = kwargs.pop("template_url", "/providers/Microsoft.Authorization/policySetDefinitions") # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") if filter is not None: - _query_parameters['$filter'] = _SERIALIZER.query("filter", filter, 'str', skip_quote=True) + _params["$filter"] = _SERIALIZER.query("filter", filter, "str", skip_quote=True) if top is not None: - _query_parameters['$top'] = _SERIALIZER.query("top", top, 'int', maximum=1000, minimum=1) + _params["$top"] = _SERIALIZER.query("top", top, "int", maximum=1000, minimum=1) # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') - - return HttpRequest( - method="GET", - url=_url, - params=_query_parameters, - headers=_header_parameters, - **kwargs - ) + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) def build_policy_set_definitions_create_or_update_at_management_group_request( - policy_set_definition_name: str, - management_group_id: str, - *, - json: JSONType = None, - content: Any = None, - **kwargs: Any + policy_set_definition_name: str, management_group_id: str, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2021-06-01") # type: str - content_type = kwargs.pop('content_type', None) # type: Optional[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: str + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + accept = _headers.pop("Accept", "application/json") - accept = "application/json" # Construct URL - _url = kwargs.pop("template_url", "/providers/Microsoft.Management/managementGroups/{managementGroupId}/providers/Microsoft.Authorization/policySetDefinitions/{policySetDefinitionName}") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", + "/providers/Microsoft.Management/managementGroups/{managementGroupId}/providers/Microsoft.Authorization/policySetDefinitions/{policySetDefinitionName}", + ) # pylint: disable=line-too-long path_format_arguments = { - "policySetDefinitionName": _SERIALIZER.url("policy_set_definition_name", policy_set_definition_name, 'str'), - "managementGroupId": _SERIALIZER.url("management_group_id", management_group_id, 'str'), + "policySetDefinitionName": _SERIALIZER.url("policy_set_definition_name", policy_set_definition_name, "str"), + "managementGroupId": _SERIALIZER.url("management_group_id", management_group_id, "str"), } _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] if content_type is not None: - _header_parameters['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') - _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') - - return HttpRequest( - method="PUT", - url=_url, - params=_query_parameters, - headers=_header_parameters, - json=json, - content=content, - **kwargs - ) + _headers["Content-Type"] = _SERIALIZER.header("content_type", content_type, "str") + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="PUT", url=_url, params=_params, headers=_headers, **kwargs) def build_policy_set_definitions_delete_at_management_group_request( - policy_set_definition_name: str, - management_group_id: str, - **kwargs: Any + policy_set_definition_name: str, management_group_id: str, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2021-06-01") # type: 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: str + accept = _headers.pop("Accept", "application/json") - accept = "application/json" # Construct URL - _url = kwargs.pop("template_url", "/providers/Microsoft.Management/managementGroups/{managementGroupId}/providers/Microsoft.Authorization/policySetDefinitions/{policySetDefinitionName}") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", + "/providers/Microsoft.Management/managementGroups/{managementGroupId}/providers/Microsoft.Authorization/policySetDefinitions/{policySetDefinitionName}", + ) # pylint: disable=line-too-long path_format_arguments = { - "policySetDefinitionName": _SERIALIZER.url("policy_set_definition_name", policy_set_definition_name, 'str'), - "managementGroupId": _SERIALIZER.url("management_group_id", management_group_id, 'str'), + "policySetDefinitionName": _SERIALIZER.url("policy_set_definition_name", policy_set_definition_name, "str"), + "managementGroupId": _SERIALIZER.url("management_group_id", management_group_id, "str"), } _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') - - return HttpRequest( - method="DELETE", - url=_url, - params=_query_parameters, - headers=_header_parameters, - **kwargs - ) + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="DELETE", url=_url, params=_params, headers=_headers, **kwargs) def build_policy_set_definitions_get_at_management_group_request( - policy_set_definition_name: str, - management_group_id: str, - **kwargs: Any + policy_set_definition_name: str, management_group_id: str, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2021-06-01") # type: 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: str + accept = _headers.pop("Accept", "application/json") - accept = "application/json" # Construct URL - _url = kwargs.pop("template_url", "/providers/Microsoft.Management/managementGroups/{managementGroupId}/providers/Microsoft.Authorization/policySetDefinitions/{policySetDefinitionName}") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", + "/providers/Microsoft.Management/managementGroups/{managementGroupId}/providers/Microsoft.Authorization/policySetDefinitions/{policySetDefinitionName}", + ) # pylint: disable=line-too-long path_format_arguments = { - "policySetDefinitionName": _SERIALIZER.url("policy_set_definition_name", policy_set_definition_name, 'str'), - "managementGroupId": _SERIALIZER.url("management_group_id", management_group_id, 'str'), + "policySetDefinitionName": _SERIALIZER.url("policy_set_definition_name", policy_set_definition_name, "str"), + "managementGroupId": _SERIALIZER.url("management_group_id", management_group_id, "str"), } _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') - - return HttpRequest( - method="GET", - url=_url, - params=_query_parameters, - headers=_header_parameters, - **kwargs - ) + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) def build_policy_set_definitions_list_by_management_group_request( - management_group_id: str, - *, - filter: Optional[str] = None, - top: Optional[int] = None, - **kwargs: Any + management_group_id: str, *, filter: Optional[str] = None, top: Optional[int] = None, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2021-06-01") # type: 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: str + accept = _headers.pop("Accept", "application/json") - accept = "application/json" # Construct URL - _url = kwargs.pop("template_url", "/providers/Microsoft.Management/managementGroups/{managementGroupId}/providers/Microsoft.Authorization/policySetDefinitions") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", + "/providers/Microsoft.Management/managementGroups/{managementGroupId}/providers/Microsoft.Authorization/policySetDefinitions", + ) # pylint: disable=line-too-long path_format_arguments = { - "managementGroupId": _SERIALIZER.url("management_group_id", management_group_id, 'str'), + "managementGroupId": _SERIALIZER.url("management_group_id", management_group_id, "str"), } _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") if filter is not None: - _query_parameters['$filter'] = _SERIALIZER.query("filter", filter, 'str', skip_quote=True) + _params["$filter"] = _SERIALIZER.query("filter", filter, "str", skip_quote=True) if top is not None: - _query_parameters['$top'] = _SERIALIZER.query("top", top, 'int', maximum=1000, minimum=1) + _params["$top"] = _SERIALIZER.query("top", top, "int", maximum=1000, minimum=1) # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') - - return HttpRequest( - method="GET", - url=_url, - params=_query_parameters, - headers=_header_parameters, - **kwargs - ) + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) -def build_policy_exemptions_delete_request( - scope: str, - policy_exemption_name: str, - **kwargs: Any -) -> HttpRequest: - api_version = kwargs.pop('api_version', "2020-07-01-preview") # type: str - accept = "application/json" +def build_policy_exemptions_delete_request(scope: str, policy_exemption_name: 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", "2020-07-01-preview")) # type: str + accept = _headers.pop("Accept", "application/json") + # Construct URL - _url = kwargs.pop("template_url", "/{scope}/providers/Microsoft.Authorization/policyExemptions/{policyExemptionName}") + _url = kwargs.pop( + "template_url", "/{scope}/providers/Microsoft.Authorization/policyExemptions/{policyExemptionName}" + ) path_format_arguments = { - "scope": _SERIALIZER.url("scope", scope, 'str', skip_quote=True), - "policyExemptionName": _SERIALIZER.url("policy_exemption_name", policy_exemption_name, 'str'), + "scope": _SERIALIZER.url("scope", scope, "str", skip_quote=True), + "policyExemptionName": _SERIALIZER.url("policy_exemption_name", policy_exemption_name, "str"), } _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') - - return HttpRequest( - method="DELETE", - url=_url, - params=_query_parameters, - headers=_header_parameters, - **kwargs - ) + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="DELETE", url=_url, params=_params, headers=_headers, **kwargs) def build_policy_exemptions_create_or_update_request( - scope: str, - policy_exemption_name: str, - *, - json: JSONType = None, - content: Any = None, - **kwargs: Any + scope: str, policy_exemption_name: str, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2020-07-01-preview") # type: str - content_type = kwargs.pop('content_type', None) # type: Optional[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", "2020-07-01-preview")) # type: str + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + accept = _headers.pop("Accept", "application/json") - accept = "application/json" # Construct URL - _url = kwargs.pop("template_url", "/{scope}/providers/Microsoft.Authorization/policyExemptions/{policyExemptionName}") + _url = kwargs.pop( + "template_url", "/{scope}/providers/Microsoft.Authorization/policyExemptions/{policyExemptionName}" + ) path_format_arguments = { - "scope": _SERIALIZER.url("scope", scope, 'str', skip_quote=True), - "policyExemptionName": _SERIALIZER.url("policy_exemption_name", policy_exemption_name, 'str'), + "scope": _SERIALIZER.url("scope", scope, "str", skip_quote=True), + "policyExemptionName": _SERIALIZER.url("policy_exemption_name", policy_exemption_name, "str"), } _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] if content_type is not None: - _header_parameters['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') - _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') - - return HttpRequest( - method="PUT", - url=_url, - params=_query_parameters, - headers=_header_parameters, - json=json, - content=content, - **kwargs - ) + _headers["Content-Type"] = _SERIALIZER.header("content_type", content_type, "str") + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + return HttpRequest(method="PUT", url=_url, params=_params, headers=_headers, **kwargs) -def build_policy_exemptions_get_request( - scope: str, - policy_exemption_name: str, - **kwargs: Any -) -> HttpRequest: - api_version = kwargs.pop('api_version', "2020-07-01-preview") # type: str - accept = "application/json" +def build_policy_exemptions_get_request(scope: str, policy_exemption_name: 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", "2020-07-01-preview")) # type: str + accept = _headers.pop("Accept", "application/json") + # Construct URL - _url = kwargs.pop("template_url", "/{scope}/providers/Microsoft.Authorization/policyExemptions/{policyExemptionName}") + _url = kwargs.pop( + "template_url", "/{scope}/providers/Microsoft.Authorization/policyExemptions/{policyExemptionName}" + ) path_format_arguments = { - "scope": _SERIALIZER.url("scope", scope, 'str', skip_quote=True), - "policyExemptionName": _SERIALIZER.url("policy_exemption_name", policy_exemption_name, 'str'), + "scope": _SERIALIZER.url("scope", scope, "str", skip_quote=True), + "policyExemptionName": _SERIALIZER.url("policy_exemption_name", policy_exemption_name, "str"), } _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') - - return HttpRequest( - method="GET", - url=_url, - params=_query_parameters, - headers=_header_parameters, - **kwargs - ) + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) def build_policy_exemptions_list_request( - subscription_id: str, - *, - filter: Optional[str] = None, - **kwargs: Any + subscription_id: str, *, filter: Optional[str] = None, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2020-07-01-preview") # type: 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", "2020-07-01-preview")) # type: str + accept = _headers.pop("Accept", "application/json") - accept = "application/json" # Construct URL - _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/providers/Microsoft.Authorization/policyExemptions") + _url = kwargs.pop( + "template_url", "/subscriptions/{subscriptionId}/providers/Microsoft.Authorization/policyExemptions" + ) path_format_arguments = { - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), } _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] if filter is not None: - _query_parameters['$filter'] = _SERIALIZER.query("filter", filter, 'str', skip_quote=True) - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["$filter"] = _SERIALIZER.query("filter", filter, "str", skip_quote=True) + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') - - return HttpRequest( - method="GET", - url=_url, - params=_query_parameters, - headers=_header_parameters, - **kwargs - ) + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) def build_policy_exemptions_list_for_resource_group_request( - subscription_id: str, - resource_group_name: str, - *, - filter: Optional[str] = None, - **kwargs: Any + resource_group_name: str, subscription_id: str, *, filter: Optional[str] = None, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2020-07-01-preview") # type: 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", "2020-07-01-preview")) # type: str + accept = _headers.pop("Accept", "application/json") - accept = "application/json" # Construct URL - _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Authorization/policyExemptions") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Authorization/policyExemptions", + ) # pylint: disable=line-too-long path_format_arguments = { - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._\(\)]+$'), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url( + "resource_group_name", resource_group_name, "str", max_length=90, min_length=1, pattern=r"^[-\w\._\(\)]+$" + ), } _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] if filter is not None: - _query_parameters['$filter'] = _SERIALIZER.query("filter", filter, 'str', skip_quote=True) - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["$filter"] = _SERIALIZER.query("filter", filter, "str", skip_quote=True) + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') - - return HttpRequest( - method="GET", - url=_url, - params=_query_parameters, - headers=_header_parameters, - **kwargs - ) + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) def build_policy_exemptions_list_for_resource_request( - subscription_id: str, resource_group_name: str, resource_provider_namespace: str, parent_resource_path: str, resource_type: str, resource_name: str, + subscription_id: str, *, filter: Optional[str] = None, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2020-07-01-preview") # type: 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", "2020-07-01-preview")) # type: str + accept = _headers.pop("Accept", "application/json") - accept = "application/json" # Construct URL - _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{parentResourcePath}/{resourceType}/{resourceName}/providers/Microsoft.Authorization/policyExemptions") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{parentResourcePath}/{resourceType}/{resourceName}/providers/Microsoft.Authorization/policyExemptions", + ) # pylint: disable=line-too-long path_format_arguments = { - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._\(\)]+$'), - "resourceProviderNamespace": _SERIALIZER.url("resource_provider_namespace", resource_provider_namespace, 'str'), - "parentResourcePath": _SERIALIZER.url("parent_resource_path", parent_resource_path, 'str', skip_quote=True), - "resourceType": _SERIALIZER.url("resource_type", resource_type, 'str', skip_quote=True), - "resourceName": _SERIALIZER.url("resource_name", resource_name, 'str'), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url( + "resource_group_name", resource_group_name, "str", max_length=90, min_length=1, pattern=r"^[-\w\._\(\)]+$" + ), + "resourceProviderNamespace": _SERIALIZER.url("resource_provider_namespace", resource_provider_namespace, "str"), + "parentResourcePath": _SERIALIZER.url("parent_resource_path", parent_resource_path, "str", skip_quote=True), + "resourceType": _SERIALIZER.url("resource_type", resource_type, "str", skip_quote=True), + "resourceName": _SERIALIZER.url("resource_name", resource_name, "str"), } _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] if filter is not None: - _query_parameters['$filter'] = _SERIALIZER.query("filter", filter, 'str', skip_quote=True) - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["$filter"] = _SERIALIZER.query("filter", filter, "str", skip_quote=True) + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') - - return HttpRequest( - method="GET", - url=_url, - params=_query_parameters, - headers=_header_parameters, - **kwargs - ) + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) def build_policy_exemptions_list_for_management_group_request( - management_group_id: str, - *, - filter: Optional[str] = None, - **kwargs: Any + management_group_id: str, *, filter: Optional[str] = None, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2020-07-01-preview") # type: 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", "2020-07-01-preview")) # type: str + accept = _headers.pop("Accept", "application/json") - accept = "application/json" # Construct URL - _url = kwargs.pop("template_url", "/providers/Microsoft.Management/managementGroups/{managementGroupId}/providers/Microsoft.Authorization/policyExemptions") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", + "/providers/Microsoft.Management/managementGroups/{managementGroupId}/providers/Microsoft.Authorization/policyExemptions", + ) # pylint: disable=line-too-long path_format_arguments = { - "managementGroupId": _SERIALIZER.url("management_group_id", management_group_id, 'str'), + "managementGroupId": _SERIALIZER.url("management_group_id", management_group_id, "str"), } _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] if filter is not None: - _query_parameters['$filter'] = _SERIALIZER.query("filter", filter, 'str', skip_quote=True) - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["$filter"] = _SERIALIZER.query("filter", filter, "str", skip_quote=True) + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') - - return HttpRequest( - method="GET", - url=_url, - params=_query_parameters, - headers=_header_parameters, - **kwargs - ) + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") -class DataPolicyManifestsOperations(object): - """DataPolicyManifestsOperations operations. + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) - You should not instantiate this class directly. Instead, you should create a Client instance that - instantiates it for you and attaches it as an attribute. - :ivar models: Alias to model classes used in this operation group. - :type models: ~azure.mgmt.resource.policy.v2021_06_01.models - :param client: Client for service requests. - :param config: Configuration of service client. - :param serializer: An object model serializer. - :param deserializer: An object model deserializer. - """ +def build_variables_delete_request(variable_name: str, subscription_id: str, **kwargs: Any) -> HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - models = _models + api_version = kwargs.pop("api_version", _params.pop("api-version", "2022-08-01-preview")) # type: str + accept = _headers.pop("Accept", "application/json") - def __init__(self, client, config, serializer, deserializer): - self._client = client - self._serialize = serializer - self._deserialize = deserializer - self._config = config + # Construct URL + _url = kwargs.pop( + "template_url", "/subscriptions/{subscriptionId}/providers/Microsoft.Authorization/variables/{variableName}" + ) # pylint: disable=line-too-long + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "variableName": _SERIALIZER.url("variable_name", variable_name, "str"), + } - @distributed_trace - def get_by_policy_mode( - self, - policy_mode: str, - **kwargs: Any - ) -> "_models.DataPolicyManifest": - """Retrieves a data policy manifest. + _url = _format_url_section(_url, **path_format_arguments) - This operation retrieves the data policy manifest with the given policy mode. + # Construct parameters + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") - :param policy_mode: The policy mode of the data policy manifest to get. + # Construct headers + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="DELETE", url=_url, params=_params, headers=_headers, **kwargs) + + +def build_variables_create_or_update_request(variable_name: str, subscription_id: str, **kwargs: Any) -> HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2022-08-01-preview")) # type: str + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = kwargs.pop( + "template_url", "/subscriptions/{subscriptionId}/providers/Microsoft.Authorization/variables/{variableName}" + ) # pylint: disable=line-too-long + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "variableName": _SERIALIZER.url("variable_name", variable_name, "str"), + } + + _url = _format_url_section(_url, **path_format_arguments) + + # Construct parameters + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") + + # Construct headers + if content_type is not None: + _headers["Content-Type"] = _SERIALIZER.header("content_type", content_type, "str") + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="PUT", url=_url, params=_params, headers=_headers, **kwargs) + + +def build_variables_get_request(variable_name: str, subscription_id: str, **kwargs: Any) -> HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2022-08-01-preview")) # type: str + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = kwargs.pop( + "template_url", "/subscriptions/{subscriptionId}/providers/Microsoft.Authorization/variables/{variableName}" + ) # pylint: disable=line-too-long + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "variableName": _SERIALIZER.url("variable_name", variable_name, "str"), + } + + _url = _format_url_section(_url, **path_format_arguments) + + # Construct parameters + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") + + # Construct headers + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) + + +def build_variables_delete_at_management_group_request( + management_group_id: str, variable_name: str, **kwargs: Any +) -> HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2022-08-01-preview")) # type: str + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = kwargs.pop( + "template_url", + "/providers/Microsoft.Management/managementGroups/{managementGroupId}/providers/Microsoft.Authorization/variables/{variableName}", + ) # pylint: disable=line-too-long + path_format_arguments = { + "managementGroupId": _SERIALIZER.url("management_group_id", management_group_id, "str"), + "variableName": _SERIALIZER.url("variable_name", variable_name, "str"), + } + + _url = _format_url_section(_url, **path_format_arguments) + + # Construct parameters + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") + + # Construct headers + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="DELETE", url=_url, params=_params, headers=_headers, **kwargs) + + +def build_variables_create_or_update_at_management_group_request( + management_group_id: str, variable_name: str, **kwargs: Any +) -> HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2022-08-01-preview")) # type: str + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = kwargs.pop( + "template_url", + "/providers/Microsoft.Management/managementGroups/{managementGroupId}/providers/Microsoft.Authorization/variables/{variableName}", + ) # pylint: disable=line-too-long + path_format_arguments = { + "managementGroupId": _SERIALIZER.url("management_group_id", management_group_id, "str"), + "variableName": _SERIALIZER.url("variable_name", variable_name, "str"), + } + + _url = _format_url_section(_url, **path_format_arguments) + + # Construct parameters + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") + + # Construct headers + if content_type is not None: + _headers["Content-Type"] = _SERIALIZER.header("content_type", content_type, "str") + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="PUT", url=_url, params=_params, headers=_headers, **kwargs) + + +def build_variables_get_at_management_group_request( + management_group_id: str, variable_name: str, **kwargs: Any +) -> HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2022-08-01-preview")) # type: str + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = kwargs.pop( + "template_url", + "/providers/Microsoft.Management/managementGroups/{managementGroupId}/providers/Microsoft.Authorization/variables/{variableName}", + ) # pylint: disable=line-too-long + path_format_arguments = { + "managementGroupId": _SERIALIZER.url("management_group_id", management_group_id, "str"), + "variableName": _SERIALIZER.url("variable_name", variable_name, "str"), + } + + _url = _format_url_section(_url, **path_format_arguments) + + # Construct parameters + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") + + # Construct headers + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) + + +def build_variables_list_request(subscription_id: str, **kwargs: Any) -> HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2022-08-01-preview")) # type: str + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/providers/Microsoft.Authorization/variables") + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + } + + _url = _format_url_section(_url, **path_format_arguments) + + # Construct parameters + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") + + # Construct headers + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) + + +def build_variables_list_for_management_group_request(management_group_id: str, **kwargs: Any) -> HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2022-08-01-preview")) # type: str + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = kwargs.pop( + "template_url", + "/providers/Microsoft.Management/managementGroups/{managementGroupId}/providers/Microsoft.Authorization/variables", + ) # pylint: disable=line-too-long + path_format_arguments = { + "managementGroupId": _SERIALIZER.url("management_group_id", management_group_id, "str"), + } + + _url = _format_url_section(_url, **path_format_arguments) + + # Construct parameters + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") + + # Construct headers + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) + + +def build_variable_values_delete_request( + variable_name: str, variable_value_name: str, subscription_id: str, **kwargs: Any +) -> HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2022-08-01-preview")) # type: str + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/providers/Microsoft.Authorization/variables/{variableName}/values/{variableValueName}", + ) # pylint: disable=line-too-long + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "variableName": _SERIALIZER.url("variable_name", variable_name, "str"), + "variableValueName": _SERIALIZER.url("variable_value_name", variable_value_name, "str"), + } + + _url = _format_url_section(_url, **path_format_arguments) + + # Construct parameters + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") + + # Construct headers + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="DELETE", url=_url, params=_params, headers=_headers, **kwargs) + + +def build_variable_values_create_or_update_request( + variable_name: str, variable_value_name: str, subscription_id: str, **kwargs: Any +) -> HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2022-08-01-preview")) # type: str + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/providers/Microsoft.Authorization/variables/{variableName}/values/{variableValueName}", + ) # pylint: disable=line-too-long + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "variableName": _SERIALIZER.url("variable_name", variable_name, "str"), + "variableValueName": _SERIALIZER.url("variable_value_name", variable_value_name, "str"), + } + + _url = _format_url_section(_url, **path_format_arguments) + + # Construct parameters + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") + + # Construct headers + if content_type is not None: + _headers["Content-Type"] = _SERIALIZER.header("content_type", content_type, "str") + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="PUT", url=_url, params=_params, headers=_headers, **kwargs) + + +def build_variable_values_get_request( + variable_name: str, variable_value_name: str, subscription_id: str, **kwargs: Any +) -> HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2022-08-01-preview")) # type: str + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/providers/Microsoft.Authorization/variables/{variableName}/values/{variableValueName}", + ) # pylint: disable=line-too-long + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "variableName": _SERIALIZER.url("variable_name", variable_name, "str"), + "variableValueName": _SERIALIZER.url("variable_value_name", variable_value_name, "str"), + } + + _url = _format_url_section(_url, **path_format_arguments) + + # Construct parameters + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") + + # Construct headers + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) + + +def build_variable_values_list_request(variable_name: str, subscription_id: str, **kwargs: Any) -> HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2022-08-01-preview")) # type: str + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/providers/Microsoft.Authorization/variables/{variableName}/values", + ) # pylint: disable=line-too-long + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "variableName": _SERIALIZER.url("variable_name", variable_name, "str"), + } + + _url = _format_url_section(_url, **path_format_arguments) + + # Construct parameters + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") + + # Construct headers + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) + + +def build_variable_values_list_for_management_group_request( + management_group_id: str, variable_name: str, **kwargs: Any +) -> HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2022-08-01-preview")) # type: str + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = kwargs.pop( + "template_url", + "/providers/Microsoft.Management/managementGroups/{managementGroupId}/providers/Microsoft.Authorization/variables/{variableName}/values", + ) # pylint: disable=line-too-long + path_format_arguments = { + "managementGroupId": _SERIALIZER.url("management_group_id", management_group_id, "str"), + "variableName": _SERIALIZER.url("variable_name", variable_name, "str"), + } + + _url = _format_url_section(_url, **path_format_arguments) + + # Construct parameters + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") + + # Construct headers + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) + + +def build_variable_values_delete_at_management_group_request( + management_group_id: str, variable_name: str, variable_value_name: str, **kwargs: Any +) -> HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2022-08-01-preview")) # type: str + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = kwargs.pop( + "template_url", + "/providers/Microsoft.Management/managementGroups/{managementGroupId}/providers/Microsoft.Authorization/variables/{variableName}/values/{variableValueName}", + ) # pylint: disable=line-too-long + path_format_arguments = { + "managementGroupId": _SERIALIZER.url("management_group_id", management_group_id, "str"), + "variableName": _SERIALIZER.url("variable_name", variable_name, "str"), + "variableValueName": _SERIALIZER.url("variable_value_name", variable_value_name, "str"), + } + + _url = _format_url_section(_url, **path_format_arguments) + + # Construct parameters + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") + + # Construct headers + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="DELETE", url=_url, params=_params, headers=_headers, **kwargs) + + +def build_variable_values_create_or_update_at_management_group_request( + management_group_id: str, variable_name: str, variable_value_name: str, **kwargs: Any +) -> HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2022-08-01-preview")) # type: str + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = kwargs.pop( + "template_url", + "/providers/Microsoft.Management/managementGroups/{managementGroupId}/providers/Microsoft.Authorization/variables/{variableName}/values/{variableValueName}", + ) # pylint: disable=line-too-long + path_format_arguments = { + "managementGroupId": _SERIALIZER.url("management_group_id", management_group_id, "str"), + "variableName": _SERIALIZER.url("variable_name", variable_name, "str"), + "variableValueName": _SERIALIZER.url("variable_value_name", variable_value_name, "str"), + } + + _url = _format_url_section(_url, **path_format_arguments) + + # Construct parameters + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") + + # Construct headers + if content_type is not None: + _headers["Content-Type"] = _SERIALIZER.header("content_type", content_type, "str") + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="PUT", url=_url, params=_params, headers=_headers, **kwargs) + + +def build_variable_values_get_at_management_group_request( + management_group_id: str, variable_name: str, variable_value_name: str, **kwargs: Any +) -> HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2022-08-01-preview")) # type: str + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = kwargs.pop( + "template_url", + "/providers/Microsoft.Management/managementGroups/{managementGroupId}/providers/Microsoft.Authorization/variables/{variableName}/values/{variableValueName}", + ) # pylint: disable=line-too-long + path_format_arguments = { + "managementGroupId": _SERIALIZER.url("management_group_id", management_group_id, "str"), + "variableName": _SERIALIZER.url("variable_name", variable_name, "str"), + "variableValueName": _SERIALIZER.url("variable_value_name", variable_value_name, "str"), + } + + _url = _format_url_section(_url, **path_format_arguments) + + # Construct parameters + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") + + # Construct headers + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) + + +class DataPolicyManifestsOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. + + Instead, you should access the following operations through + :class:`~azure.mgmt.resource.policy.v2021_06_01.PolicyClient`'s + :attr:`data_policy_manifests` attribute. + """ + + models = _models + + def __init__(self, *args, **kwargs): + input_args = list(args) + self._client = input_args.pop(0) if input_args else kwargs.pop("client") + self._config = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") + + @distributed_trace + def get_by_policy_mode(self, policy_mode: str, **kwargs: Any) -> _models.DataPolicyManifest: + """Retrieves a data policy manifest. + + This operation retrieves the data policy manifest with the given policy mode. + + :param policy_mode: The policy mode of the data policy manifest to get. Required. :type policy_mode: str - :keyword api_version: Api Version. Default value is "2020-09-01". Note that overriding this - default value may result in unsupported behavior. - :paramtype api_version: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: DataPolicyManifest, or the result of cls(response) + :return: DataPolicyManifest or the result of cls(response) :rtype: ~azure.mgmt.resource.policy.v2021_06_01.models.DataPolicyManifest - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.DataPolicyManifest"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) - api_version = kwargs.pop('api_version', "2020-09-01") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2020-09-01")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[_models.DataPolicyManifest] - request = build_data_policy_manifests_get_by_policy_mode_request( policy_mode=policy_mode, api_version=api_version, - template_url=self.get_by_policy_mode.metadata['url'], + template_url=self.get_by_policy_mode.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) - deserialized = self._deserialize('DataPolicyManifest', pipeline_response) + deserialized = self._deserialize("DataPolicyManifest", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - get_by_policy_mode.metadata = {'url': "/providers/Microsoft.Authorization/dataPolicyManifests/{policyMode}"} # type: ignore - + get_by_policy_mode.metadata = {"url": "/providers/Microsoft.Authorization/dataPolicyManifests/{policyMode}"} # type: ignore @distributed_trace - def list( - self, - filter: Optional[str] = None, - **kwargs: Any - ) -> Iterable["_models.DataPolicyManifestListResult"]: + def list(self, filter: Optional[str] = None, **kwargs: Any) -> Iterable["_models.DataPolicyManifest"]: """Retrieves data policy manifests. This operation retrieves a list of all the data policy manifests that match the optional given @@ -1643,41 +1848,43 @@ def list( '{value}' is provided, the returned list only includes all data policy manifests that have a namespace matching the provided value. Default value is None. :type filter: str - :keyword api_version: Api Version. Default value is "2020-09-01". Note that overriding this - default value may result in unsupported behavior. - :paramtype api_version: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either DataPolicyManifestListResult or the result of - cls(response) + :return: An iterator like instance of either DataPolicyManifest or the result of cls(response) :rtype: - ~azure.core.paging.ItemPaged[~azure.mgmt.resource.policy.v2021_06_01.models.DataPolicyManifestListResult] - :raises: ~azure.core.exceptions.HttpResponseError + ~azure.core.paging.ItemPaged[~azure.mgmt.resource.policy.v2021_06_01.models.DataPolicyManifest] + :raises ~azure.core.exceptions.HttpResponseError: """ - api_version = kwargs.pop('api_version', "2020-09-01") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2020-09-01")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[_models.DataPolicyManifestListResult] - cls = kwargs.pop('cls', None) # type: ClsType["_models.DataPolicyManifestListResult"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) + def prepare_request(next_link=None): if not next_link: - + request = build_data_policy_manifests_list_request( - api_version=api_version, filter=filter, - template_url=self.list.metadata['url'], + 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.url = self._client.format_url(request.url) # type: ignore else: - - request = build_data_policy_manifests_list_request( - template_url=next_link, - ) + request = HttpRequest("GET", next_link) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore request.method = "GET" return request @@ -1691,10 +1898,8 @@ def extract_data(pipeline_response): def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) response = pipeline_response.http_response @@ -1704,40 +1909,32 @@ def get_next(next_link=None): return pipeline_response + return ItemPaged(get_next, extract_data) - return ItemPaged( - get_next, extract_data - ) - list.metadata = {'url': "/providers/Microsoft.Authorization/dataPolicyManifests"} # type: ignore -class PolicyAssignmentsOperations(object): - """PolicyAssignmentsOperations operations. - - You should not instantiate this class directly. Instead, you should create a Client instance that - instantiates it for you and attaches it as an attribute. - - :ivar models: Alias to model classes used in this operation group. - :type models: ~azure.mgmt.resource.policy.v2021_06_01.models - :param client: Client for service requests. - :param config: Configuration of service client. - :param serializer: An object model serializer. - :param deserializer: An object model deserializer. - """ + list.metadata = {"url": "/providers/Microsoft.Authorization/dataPolicyManifests"} # type: ignore + + +class PolicyAssignmentsOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. + + Instead, you should access the following operations through + :class:`~azure.mgmt.resource.policy.v2021_06_01.PolicyClient`'s + :attr:`policy_assignments` attribute. + """ models = _models - def __init__(self, client, config, serializer, deserializer): - self._client = client - self._serialize = serializer - self._deserialize = deserializer - self._config = config + def __init__(self, *args, **kwargs): + input_args = list(args) + self._client = input_args.pop(0) if input_args else kwargs.pop("client") + self._config = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") @distributed_trace - def delete( - self, - scope: str, - policy_assignment_name: str, - **kwargs: Any - ) -> Optional["_models.PolicyAssignment"]: + def delete(self, scope: str, policy_assignment_name: str, **kwargs: Any) -> Optional[_models.PolicyAssignment]: """Deletes a policy assignment. This operation deletes a policy assignment, given its name and the scope it was created in. The @@ -1749,40 +1946,44 @@ def delete( '/subscriptions/{subscriptionId}'), resource group (format: '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}', or resource (format: '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{resourceProviderNamespace}/[{parentResourcePath}/]{resourceType}/{resourceName}'. + Required. :type scope: str - :param policy_assignment_name: The name of the policy assignment to delete. + :param policy_assignment_name: The name of the policy assignment to delete. Required. :type policy_assignment_name: str - :keyword api_version: Api Version. Default value is "2021-06-01". Note that overriding this - default value may result in unsupported behavior. - :paramtype api_version: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: PolicyAssignment, or the result of cls(response) + :return: PolicyAssignment or None or the result of cls(response) :rtype: ~azure.mgmt.resource.policy.v2021_06_01.models.PolicyAssignment or None - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType[Optional["_models.PolicyAssignment"]] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + 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', "2021-06-01") # type: str + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-06-01")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[Optional[_models.PolicyAssignment]] - request = build_policy_assignments_delete_request( scope=scope, policy_assignment_name=policy_assignment_name, api_version=api_version, - template_url=self.delete.metadata['url'], + template_url=self.delete.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200, 204]: @@ -1791,24 +1992,25 @@ def delete( deserialized = None if response.status_code == 200: - deserialized = self._deserialize('PolicyAssignment', pipeline_response) + deserialized = self._deserialize("PolicyAssignment", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - delete.metadata = {'url': "/{scope}/providers/Microsoft.Authorization/policyAssignments/{policyAssignmentName}"} # type: ignore - + delete.metadata = {"url": "/{scope}/providers/Microsoft.Authorization/policyAssignments/{policyAssignmentName}"} # type: ignore - @distributed_trace + @overload def create( self, scope: str, policy_assignment_name: str, - parameters: "_models.PolicyAssignment", + parameters: _models.PolicyAssignment, + *, + content_type: str = "application/json", **kwargs: Any - ) -> "_models.PolicyAssignment": + ) -> _models.PolicyAssignment: """Creates or updates a policy assignment. This operation creates or updates a policy assignment with the given scope and name. Policy @@ -1820,29 +2022,109 @@ def create( '/subscriptions/{subscriptionId}'), resource group (format: '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}', or resource (format: '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{resourceProviderNamespace}/[{parentResourcePath}/]{resourceType}/{resourceName}'. + Required. :type scope: str - :param policy_assignment_name: The name of the policy assignment. + :param policy_assignment_name: The name of the policy assignment. Required. :type policy_assignment_name: str - :param parameters: Parameters for the policy assignment. + :param parameters: Parameters for the policy assignment. Required. :type parameters: ~azure.mgmt.resource.policy.v2021_06_01.models.PolicyAssignment - :keyword api_version: Api Version. Default value is "2021-06-01". Note that overriding this - default value may result in unsupported behavior. - :paramtype api_version: str + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: PolicyAssignment or the result of cls(response) + :rtype: ~azure.mgmt.resource.policy.v2021_06_01.models.PolicyAssignment + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + def create( + self, + scope: str, + policy_assignment_name: str, + parameters: IO, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.PolicyAssignment: + """Creates or updates a policy assignment. + + This operation creates or updates a policy assignment with the given scope and name. Policy + assignments apply to all resources contained within their scope. For example, when you assign a + policy at resource group scope, that policy applies to all resources in the group. + + :param scope: The scope of the policy assignment. Valid scopes are: management group (format: + '/providers/Microsoft.Management/managementGroups/{managementGroup}'), subscription (format: + '/subscriptions/{subscriptionId}'), resource group (format: + '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}', or resource (format: + '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{resourceProviderNamespace}/[{parentResourcePath}/]{resourceType}/{resourceName}'. + Required. + :type scope: str + :param policy_assignment_name: The name of the policy assignment. Required. + :type policy_assignment_name: str + :param parameters: Parameters for the policy assignment. Required. + :type parameters: IO + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: PolicyAssignment or the result of cls(response) + :rtype: ~azure.mgmt.resource.policy.v2021_06_01.models.PolicyAssignment + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace + def create( + self, scope: str, policy_assignment_name: str, parameters: Union[_models.PolicyAssignment, IO], **kwargs: Any + ) -> _models.PolicyAssignment: + """Creates or updates a policy assignment. + + This operation creates or updates a policy assignment with the given scope and name. Policy + assignments apply to all resources contained within their scope. For example, when you assign a + policy at resource group scope, that policy applies to all resources in the group. + + :param scope: The scope of the policy assignment. Valid scopes are: management group (format: + '/providers/Microsoft.Management/managementGroups/{managementGroup}'), subscription (format: + '/subscriptions/{subscriptionId}'), resource group (format: + '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}', or resource (format: + '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{resourceProviderNamespace}/[{parentResourcePath}/]{resourceType}/{resourceName}'. + Required. + :type scope: str + :param policy_assignment_name: The name of the policy assignment. Required. + :type policy_assignment_name: str + :param parameters: Parameters for the policy assignment. Is either a model type or a IO type. + Required. + :type parameters: ~azure.mgmt.resource.policy.v2021_06_01.models.PolicyAssignment or IO + :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. + Default value is None. + :paramtype content_type: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: PolicyAssignment, or the result of cls(response) + :return: PolicyAssignment or the result of cls(response) :rtype: ~azure.mgmt.resource.policy.v2021_06_01.models.PolicyAssignment - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.PolicyAssignment"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) - api_version = kwargs.pop('api_version', "2021-06-01") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - _json = self._serialize.body(parameters, 'PolicyAssignment') + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-06-01")) # type: str + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.PolicyAssignment] + + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(parameters, (IO, bytes)): + _content = parameters + else: + _json = self._serialize.body(parameters, "PolicyAssignment") request = build_policy_assignments_create_request( scope=scope, @@ -1850,39 +2132,35 @@ def create( api_version=api_version, content_type=content_type, json=_json, - template_url=self.create.metadata['url'], + content=_content, + template_url=self.create.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [201]: map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) - deserialized = self._deserialize('PolicyAssignment', pipeline_response) + deserialized = self._deserialize("PolicyAssignment", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - create.metadata = {'url': "/{scope}/providers/Microsoft.Authorization/policyAssignments/{policyAssignmentName}"} # type: ignore - + create.metadata = {"url": "/{scope}/providers/Microsoft.Authorization/policyAssignments/{policyAssignmentName}"} # type: ignore @distributed_trace - def get( - self, - scope: str, - policy_assignment_name: str, - **kwargs: Any - ) -> "_models.PolicyAssignment": + def get(self, scope: str, policy_assignment_name: str, **kwargs: Any) -> _models.PolicyAssignment: """Retrieves a policy assignment. This operation retrieves a single policy assignment, given its name and the scope it was @@ -1893,64 +2171,139 @@ def get( '/subscriptions/{subscriptionId}'), resource group (format: '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}', or resource (format: '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{resourceProviderNamespace}/[{parentResourcePath}/]{resourceType}/{resourceName}'. + Required. :type scope: str - :param policy_assignment_name: The name of the policy assignment to get. + :param policy_assignment_name: The name of the policy assignment to get. Required. :type policy_assignment_name: str - :keyword api_version: Api Version. Default value is "2021-06-01". Note that overriding this - default value may result in unsupported behavior. - :paramtype api_version: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: PolicyAssignment, or the result of cls(response) + :return: PolicyAssignment or the result of cls(response) :rtype: ~azure.mgmt.resource.policy.v2021_06_01.models.PolicyAssignment - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.PolicyAssignment"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + 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', "2021-06-01") # type: str + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-06-01")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[_models.PolicyAssignment] - request = build_policy_assignments_get_request( scope=scope, policy_assignment_name=policy_assignment_name, api_version=api_version, - template_url=self.get.metadata['url'], + template_url=self.get.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) - deserialized = self._deserialize('PolicyAssignment', pipeline_response) + deserialized = self._deserialize("PolicyAssignment", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - get.metadata = {'url': "/{scope}/providers/Microsoft.Authorization/policyAssignments/{policyAssignmentName}"} # type: ignore + get.metadata = {"url": "/{scope}/providers/Microsoft.Authorization/policyAssignments/{policyAssignmentName}"} # type: ignore + + @overload + def update( + self, + scope: str, + policy_assignment_name: str, + parameters: _models.PolicyAssignmentUpdate, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.PolicyAssignment: + """Updates a policy assignment. + + This operation updates a policy assignment with the given scope and name. Policy assignments + apply to all resources contained within their scope. For example, when you assign a policy at + resource group scope, that policy applies to all resources in the group. + + :param scope: The scope of the policy assignment. Valid scopes are: management group (format: + '/providers/Microsoft.Management/managementGroups/{managementGroup}'), subscription (format: + '/subscriptions/{subscriptionId}'), resource group (format: + '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}', or resource (format: + '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{resourceProviderNamespace}/[{parentResourcePath}/]{resourceType}/{resourceName}'. + Required. + :type scope: str + :param policy_assignment_name: The name of the policy assignment. Required. + :type policy_assignment_name: str + :param parameters: Parameters for policy assignment patch request. Required. + :type parameters: ~azure.mgmt.resource.policy.v2021_06_01.models.PolicyAssignmentUpdate + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: PolicyAssignment or the result of cls(response) + :rtype: ~azure.mgmt.resource.policy.v2021_06_01.models.PolicyAssignment + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + def update( + self, + scope: str, + policy_assignment_name: str, + parameters: IO, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.PolicyAssignment: + """Updates a policy assignment. + + This operation updates a policy assignment with the given scope and name. Policy assignments + apply to all resources contained within their scope. For example, when you assign a policy at + resource group scope, that policy applies to all resources in the group. + :param scope: The scope of the policy assignment. Valid scopes are: management group (format: + '/providers/Microsoft.Management/managementGroups/{managementGroup}'), subscription (format: + '/subscriptions/{subscriptionId}'), resource group (format: + '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}', or resource (format: + '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{resourceProviderNamespace}/[{parentResourcePath}/]{resourceType}/{resourceName}'. + Required. + :type scope: str + :param policy_assignment_name: The name of the policy assignment. Required. + :type policy_assignment_name: str + :param parameters: Parameters for policy assignment patch request. Required. + :type parameters: IO + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: PolicyAssignment or the result of cls(response) + :rtype: ~azure.mgmt.resource.policy.v2021_06_01.models.PolicyAssignment + :raises ~azure.core.exceptions.HttpResponseError: + """ @distributed_trace def update( self, scope: str, policy_assignment_name: str, - parameters: "_models.PolicyAssignmentUpdate", + parameters: Union[_models.PolicyAssignmentUpdate, IO], **kwargs: Any - ) -> "_models.PolicyAssignment": + ) -> _models.PolicyAssignment: """Updates a policy assignment. This operation updates a policy assignment with the given scope and name. Policy assignments @@ -1962,29 +2315,43 @@ def update( '/subscriptions/{subscriptionId}'), resource group (format: '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}', or resource (format: '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{resourceProviderNamespace}/[{parentResourcePath}/]{resourceType}/{resourceName}'. + Required. :type scope: str - :param policy_assignment_name: The name of the policy assignment. + :param policy_assignment_name: The name of the policy assignment. Required. :type policy_assignment_name: str - :param parameters: Parameters for policy assignment patch request. - :type parameters: ~azure.mgmt.resource.policy.v2021_06_01.models.PolicyAssignmentUpdate - :keyword api_version: Api Version. Default value is "2021-06-01". Note that overriding this - default value may result in unsupported behavior. - :paramtype api_version: str + :param parameters: Parameters for policy assignment patch request. Is either a model type or a + IO type. Required. + :type parameters: ~azure.mgmt.resource.policy.v2021_06_01.models.PolicyAssignmentUpdate or IO + :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. + Default value is None. + :paramtype content_type: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: PolicyAssignment, or the result of cls(response) + :return: PolicyAssignment or the result of cls(response) :rtype: ~azure.mgmt.resource.policy.v2021_06_01.models.PolicyAssignment - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.PolicyAssignment"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) - api_version = kwargs.pop('api_version', "2021-06-01") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - _json = self._serialize.body(parameters, 'PolicyAssignmentUpdate') + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-06-01")) # type: str + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.PolicyAssignment] + + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(parameters, (IO, bytes)): + _content = parameters + else: + _json = self._serialize.body(parameters, "PolicyAssignmentUpdate") request = build_policy_assignments_update_request( scope=scope, @@ -1992,40 +2359,37 @@ def update( api_version=api_version, content_type=content_type, json=_json, - template_url=self.update.metadata['url'], + content=_content, + template_url=self.update.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) - deserialized = self._deserialize('PolicyAssignment', pipeline_response) + deserialized = self._deserialize("PolicyAssignment", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - update.metadata = {'url': "/{scope}/providers/Microsoft.Authorization/policyAssignments/{policyAssignmentName}"} # type: ignore - + update.metadata = {"url": "/{scope}/providers/Microsoft.Authorization/policyAssignments/{policyAssignmentName}"} # type: ignore @distributed_trace def list_for_resource_group( - self, - resource_group_name: str, - filter: Optional[str] = None, - top: Optional[int] = None, - **kwargs: Any - ) -> Iterable["_models.PolicyAssignmentListResult"]: + self, resource_group_name: str, filter: Optional[str] = None, top: Optional[int] = None, **kwargs: Any + ) -> Iterable["_models.PolicyAssignment"]: """Retrieves all policy assignments that apply to a resource group. This operation retrieves the list of all policy assignments associated with the given resource @@ -2042,6 +2406,7 @@ def list_for_resource_group( is {value} that apply to the resource group. :param resource_group_name: The name of the resource group that contains policy assignments. + Required. :type resource_group_name: str :param filter: The filter to apply on the operation. Valid values for $filter are: 'atScope()', 'atExactScope()' or 'policyDefinitionId eq '{value}''. If $filter is not provided, no filtering @@ -2055,46 +2420,46 @@ def list_for_resource_group( :param top: Maximum number of records to return. When the $top filter is not provided, it will return 500 records. Default value is None. :type top: int - :keyword api_version: Api Version. Default value is "2021-06-01". Note that overriding this - default value may result in unsupported behavior. - :paramtype api_version: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either PolicyAssignmentListResult or the result of - cls(response) + :return: An iterator like instance of either PolicyAssignment or the result of cls(response) :rtype: - ~azure.core.paging.ItemPaged[~azure.mgmt.resource.policy.v2021_06_01.models.PolicyAssignmentListResult] - :raises: ~azure.core.exceptions.HttpResponseError + ~azure.core.paging.ItemPaged[~azure.mgmt.resource.policy.v2021_06_01.models.PolicyAssignment] + :raises ~azure.core.exceptions.HttpResponseError: """ - api_version = kwargs.pop('api_version', "2021-06-01") # type: str + _headers = 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: str + cls = kwargs.pop("cls", None) # type: ClsType[_models.PolicyAssignmentListResult] - cls = kwargs.pop('cls', None) # type: ClsType["_models.PolicyAssignmentListResult"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) + def prepare_request(next_link=None): if not next_link: - + request = build_policy_assignments_list_for_resource_group_request( resource_group_name=resource_group_name, subscription_id=self._config.subscription_id, - api_version=api_version, filter=filter, top=top, - template_url=self.list_for_resource_group.metadata['url'], + api_version=api_version, + template_url=self.list_for_resource_group.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore else: - - request = build_policy_assignments_list_for_resource_group_request( - resource_group_name=resource_group_name, - subscription_id=self._config.subscription_id, - template_url=next_link, - ) + request = HttpRequest("GET", next_link) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore request.method = "GET" return request @@ -2108,10 +2473,8 @@ def extract_data(pipeline_response): def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) response = pipeline_response.http_response @@ -2121,11 +2484,9 @@ def get_next(next_link=None): return pipeline_response + return ItemPaged(get_next, extract_data) - return ItemPaged( - get_next, extract_data - ) - list_for_resource_group.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Authorization/policyAssignments"} # type: ignore + list_for_resource_group.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Authorization/policyAssignments"} # type: ignore @distributed_trace def list_for_resource( @@ -2138,7 +2499,7 @@ def list_for_resource( filter: Optional[str] = None, top: Optional[int] = None, **kwargs: Any - ) -> Iterable["_models.PolicyAssignmentListResult"]: + ) -> Iterable["_models.PolicyAssignment"]: """Retrieves all policy assignments that apply to a resource. This operation retrieves the list of all policy assignments associated with the specified @@ -2165,17 +2526,19 @@ def list_for_resource( {parentResourcePath} == '', {resourceType} == 'Microsoft.Web/sites', {resourceName} == 'MyWebApp'). - :param resource_group_name: The name of the resource group containing the resource. + :param resource_group_name: The name of the resource group containing the resource. Required. :type resource_group_name: str :param resource_provider_namespace: The namespace of the resource provider. For example, the namespace of a virtual machine is Microsoft.Compute (from Microsoft.Compute/virtualMachines). + Required. :type resource_provider_namespace: str :param parent_resource_path: The parent resource path. Use empty string if there is none. + Required. :type parent_resource_path: str :param resource_type: The resource type name. For example the type name of a web app is 'sites' - (from Microsoft.Web/sites). + (from Microsoft.Web/sites). Required. :type resource_type: str - :param resource_name: The name of the resource. + :param resource_name: The name of the resource. Required. :type resource_name: str :param filter: The filter to apply on the operation. Valid values for $filter are: 'atScope()', 'atExactScope()' or 'policyDefinitionId eq '{value}''. If $filter is not provided, no filtering @@ -2189,26 +2552,29 @@ def list_for_resource( :param top: Maximum number of records to return. When the $top filter is not provided, it will return 500 records. Default value is None. :type top: int - :keyword api_version: Api Version. Default value is "2021-06-01". Note that overriding this - default value may result in unsupported behavior. - :paramtype api_version: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either PolicyAssignmentListResult or the result of - cls(response) + :return: An iterator like instance of either PolicyAssignment or the result of cls(response) :rtype: - ~azure.core.paging.ItemPaged[~azure.mgmt.resource.policy.v2021_06_01.models.PolicyAssignmentListResult] - :raises: ~azure.core.exceptions.HttpResponseError + ~azure.core.paging.ItemPaged[~azure.mgmt.resource.policy.v2021_06_01.models.PolicyAssignment] + :raises ~azure.core.exceptions.HttpResponseError: """ - api_version = kwargs.pop('api_version', "2021-06-01") # type: str + _headers = 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: str + cls = kwargs.pop("cls", None) # type: ClsType[_models.PolicyAssignmentListResult] - cls = kwargs.pop('cls', None) # type: ClsType["_models.PolicyAssignmentListResult"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) + def prepare_request(next_link=None): if not next_link: - + request = build_policy_assignments_list_for_resource_request( resource_group_name=resource_group_name, resource_provider_namespace=resource_provider_namespace, @@ -2216,27 +2582,20 @@ def prepare_request(next_link=None): resource_type=resource_type, resource_name=resource_name, subscription_id=self._config.subscription_id, - api_version=api_version, filter=filter, top=top, - template_url=self.list_for_resource.metadata['url'], + api_version=api_version, + template_url=self.list_for_resource.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore else: - - request = build_policy_assignments_list_for_resource_request( - resource_group_name=resource_group_name, - resource_provider_namespace=resource_provider_namespace, - parent_resource_path=parent_resource_path, - resource_type=resource_type, - resource_name=resource_name, - subscription_id=self._config.subscription_id, - template_url=next_link, - ) + request = HttpRequest("GET", next_link) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore request.method = "GET" return request @@ -2250,10 +2609,8 @@ def extract_data(pipeline_response): def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) response = pipeline_response.http_response @@ -2263,20 +2620,14 @@ def get_next(next_link=None): return pipeline_response + return ItemPaged(get_next, extract_data) - return ItemPaged( - get_next, extract_data - ) - list_for_resource.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{parentResourcePath}/{resourceType}/{resourceName}/providers/Microsoft.Authorization/policyAssignments"} # type: ignore + list_for_resource.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{parentResourcePath}/{resourceType}/{resourceName}/providers/Microsoft.Authorization/policyAssignments"} # type: ignore @distributed_trace def list_for_management_group( - self, - management_group_id: str, - filter: Optional[str] = None, - top: Optional[int] = None, - **kwargs: Any - ) -> Iterable["_models.PolicyAssignmentListResult"]: + self, management_group_id: str, filter: Optional[str] = None, top: Optional[int] = None, **kwargs: Any + ) -> Iterable["_models.PolicyAssignment"]: """Retrieves all policy assignments that apply to a management group. This operation retrieves the list of all policy assignments applicable to the management group @@ -2288,7 +2639,7 @@ def list_for_management_group( provided, the returned list includes all policy assignments of the policy definition whose id is {value} that apply to the management group. - :param management_group_id: The ID of the management group. + :param management_group_id: The ID of the management group. Required. :type management_group_id: str :param filter: The filter to apply on the operation. Valid values for $filter are: 'atScope()', 'atExactScope()' or 'policyDefinitionId eq '{value}''. If $filter is not provided, no filtering @@ -2302,44 +2653,45 @@ def list_for_management_group( :param top: Maximum number of records to return. When the $top filter is not provided, it will return 500 records. Default value is None. :type top: int - :keyword api_version: Api Version. Default value is "2021-06-01". Note that overriding this - default value may result in unsupported behavior. - :paramtype api_version: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either PolicyAssignmentListResult or the result of - cls(response) + :return: An iterator like instance of either PolicyAssignment or the result of cls(response) :rtype: - ~azure.core.paging.ItemPaged[~azure.mgmt.resource.policy.v2021_06_01.models.PolicyAssignmentListResult] - :raises: ~azure.core.exceptions.HttpResponseError + ~azure.core.paging.ItemPaged[~azure.mgmt.resource.policy.v2021_06_01.models.PolicyAssignment] + :raises ~azure.core.exceptions.HttpResponseError: """ - api_version = kwargs.pop('api_version', "2021-06-01") # type: str + _headers = 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: str + cls = kwargs.pop("cls", None) # type: ClsType[_models.PolicyAssignmentListResult] - cls = kwargs.pop('cls', None) # type: ClsType["_models.PolicyAssignmentListResult"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) + def prepare_request(next_link=None): if not next_link: - + request = build_policy_assignments_list_for_management_group_request( management_group_id=management_group_id, - api_version=api_version, filter=filter, top=top, - template_url=self.list_for_management_group.metadata['url'], + api_version=api_version, + template_url=self.list_for_management_group.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore else: - - request = build_policy_assignments_list_for_management_group_request( - management_group_id=management_group_id, - template_url=next_link, - ) + request = HttpRequest("GET", next_link) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore request.method = "GET" return request @@ -2353,10 +2705,8 @@ def extract_data(pipeline_response): def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) response = pipeline_response.http_response @@ -2366,19 +2716,14 @@ def get_next(next_link=None): return pipeline_response + return ItemPaged(get_next, extract_data) - return ItemPaged( - get_next, extract_data - ) - list_for_management_group.metadata = {'url': "/providers/Microsoft.Management/managementGroups/{managementGroupId}/providers/Microsoft.Authorization/policyAssignments"} # type: ignore + list_for_management_group.metadata = {"url": "/providers/Microsoft.Management/managementGroups/{managementGroupId}/providers/Microsoft.Authorization/policyAssignments"} # type: ignore @distributed_trace def list( - self, - filter: Optional[str] = None, - top: Optional[int] = None, - **kwargs: Any - ) -> Iterable["_models.PolicyAssignmentListResult"]: + self, filter: Optional[str] = None, top: Optional[int] = None, **kwargs: Any + ) -> Iterable["_models.PolicyAssignment"]: """Retrieves all policy assignments that apply to a subscription. This operation retrieves the list of all policy assignments associated with the given @@ -2405,44 +2750,45 @@ def list( :param top: Maximum number of records to return. When the $top filter is not provided, it will return 500 records. Default value is None. :type top: int - :keyword api_version: Api Version. Default value is "2021-06-01". Note that overriding this - default value may result in unsupported behavior. - :paramtype api_version: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either PolicyAssignmentListResult or the result of - cls(response) + :return: An iterator like instance of either PolicyAssignment or the result of cls(response) :rtype: - ~azure.core.paging.ItemPaged[~azure.mgmt.resource.policy.v2021_06_01.models.PolicyAssignmentListResult] - :raises: ~azure.core.exceptions.HttpResponseError + ~azure.core.paging.ItemPaged[~azure.mgmt.resource.policy.v2021_06_01.models.PolicyAssignment] + :raises ~azure.core.exceptions.HttpResponseError: """ - api_version = kwargs.pop('api_version', "2021-06-01") # type: str + _headers = 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: str + cls = kwargs.pop("cls", None) # type: ClsType[_models.PolicyAssignmentListResult] - cls = kwargs.pop('cls', None) # type: ClsType["_models.PolicyAssignmentListResult"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) + def prepare_request(next_link=None): if not next_link: - + request = build_policy_assignments_list_request( subscription_id=self._config.subscription_id, - api_version=api_version, filter=filter, top=top, - template_url=self.list.metadata['url'], + 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.url = self._client.format_url(request.url) # type: ignore else: - - request = build_policy_assignments_list_request( - subscription_id=self._config.subscription_id, - template_url=next_link, - ) + request = HttpRequest("GET", next_link) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore request.method = "GET" return request @@ -2456,10 +2802,8 @@ def extract_data(pipeline_response): def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) response = pipeline_response.http_response @@ -2469,18 +2813,12 @@ def get_next(next_link=None): return pipeline_response + return ItemPaged(get_next, extract_data) - return ItemPaged( - get_next, extract_data - ) - list.metadata = {'url': "/subscriptions/{subscriptionId}/providers/Microsoft.Authorization/policyAssignments"} # type: ignore + list.metadata = {"url": "/subscriptions/{subscriptionId}/providers/Microsoft.Authorization/policyAssignments"} # type: ignore @distributed_trace - def delete_by_id( - self, - policy_assignment_id: str, - **kwargs: Any - ) -> Optional["_models.PolicyAssignment"]: + def delete_by_id(self, policy_assignment_id: str, **kwargs: Any) -> Optional[_models.PolicyAssignment]: """Deletes a policy assignment. This operation deletes the policy with the given ID. Policy assignment IDs have this format: @@ -2492,38 +2830,41 @@ def delete_by_id( (resource). :param policy_assignment_id: The ID of the policy assignment to delete. Use the format - '{scope}/providers/Microsoft.Authorization/policyAssignments/{policyAssignmentName}'. + '{scope}/providers/Microsoft.Authorization/policyAssignments/{policyAssignmentName}'. Required. :type policy_assignment_id: str - :keyword api_version: Api Version. Default value is "2021-06-01". Note that overriding this - default value may result in unsupported behavior. - :paramtype api_version: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: PolicyAssignment, or the result of cls(response) + :return: PolicyAssignment or None or the result of cls(response) :rtype: ~azure.mgmt.resource.policy.v2021_06_01.models.PolicyAssignment or None - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType[Optional["_models.PolicyAssignment"]] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) - api_version = kwargs.pop('api_version', "2021-06-01") # type: str + _headers = 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: str + cls = kwargs.pop("cls", None) # type: ClsType[Optional[_models.PolicyAssignment]] - request = build_policy_assignments_delete_by_id_request( policy_assignment_id=policy_assignment_id, api_version=api_version, - template_url=self.delete_by_id.metadata['url'], + template_url=self.delete_by_id.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200, 204]: @@ -2532,23 +2873,24 @@ def delete_by_id( deserialized = None if response.status_code == 200: - deserialized = self._deserialize('PolicyAssignment', pipeline_response) + deserialized = self._deserialize("PolicyAssignment", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - delete_by_id.metadata = {'url': "/{policyAssignmentId}"} # type: ignore + delete_by_id.metadata = {"url": "/{policyAssignmentId}"} # type: ignore - - @distributed_trace + @overload def create_by_id( self, policy_assignment_id: str, - parameters: "_models.PolicyAssignment", + parameters: _models.PolicyAssignment, + *, + content_type: str = "application/json", **kwargs: Any - ) -> "_models.PolicyAssignment": + ) -> _models.PolicyAssignment: """Creates or updates a policy assignment. This operation creates or updates the policy assignment with the given ID. Policy assignments @@ -2563,66 +2905,138 @@ def create_by_id( '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{resourceProviderNamespace}/[{parentResourcePath}/]{resourceType}/{resourceName}'. :param policy_assignment_id: The ID of the policy assignment to create. Use the format - '{scope}/providers/Microsoft.Authorization/policyAssignments/{policyAssignmentName}'. + '{scope}/providers/Microsoft.Authorization/policyAssignments/{policyAssignmentName}'. Required. :type policy_assignment_id: str - :param parameters: Parameters for policy assignment. + :param parameters: Parameters for policy assignment. Required. :type parameters: ~azure.mgmt.resource.policy.v2021_06_01.models.PolicyAssignment - :keyword api_version: Api Version. Default value is "2021-06-01". Note that overriding this - default value may result in unsupported behavior. - :paramtype api_version: str + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: PolicyAssignment or the result of cls(response) + :rtype: ~azure.mgmt.resource.policy.v2021_06_01.models.PolicyAssignment + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + def create_by_id( + self, policy_assignment_id: str, parameters: IO, *, content_type: str = "application/json", **kwargs: Any + ) -> _models.PolicyAssignment: + """Creates or updates a policy assignment. + + This operation creates or updates the policy assignment with the given ID. Policy assignments + made on a scope apply to all resources contained in that scope. For example, when you assign a + policy to a resource group that policy applies to all resources in the group. Policy assignment + IDs have this format: + '{scope}/providers/Microsoft.Authorization/policyAssignments/{policyAssignmentName}'. Valid + scopes are: management group (format: + '/providers/Microsoft.Management/managementGroups/{managementGroup}'), subscription (format: + '/subscriptions/{subscriptionId}'), resource group (format: + '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}', or resource (format: + '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{resourceProviderNamespace}/[{parentResourcePath}/]{resourceType}/{resourceName}'. + + :param policy_assignment_id: The ID of the policy assignment to create. Use the format + '{scope}/providers/Microsoft.Authorization/policyAssignments/{policyAssignmentName}'. Required. + :type policy_assignment_id: str + :param parameters: Parameters for policy assignment. Required. + :type parameters: IO + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: PolicyAssignment or the result of cls(response) + :rtype: ~azure.mgmt.resource.policy.v2021_06_01.models.PolicyAssignment + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace + def create_by_id( + self, policy_assignment_id: str, parameters: Union[_models.PolicyAssignment, IO], **kwargs: Any + ) -> _models.PolicyAssignment: + """Creates or updates a policy assignment. + + This operation creates or updates the policy assignment with the given ID. Policy assignments + made on a scope apply to all resources contained in that scope. For example, when you assign a + policy to a resource group that policy applies to all resources in the group. Policy assignment + IDs have this format: + '{scope}/providers/Microsoft.Authorization/policyAssignments/{policyAssignmentName}'. Valid + scopes are: management group (format: + '/providers/Microsoft.Management/managementGroups/{managementGroup}'), subscription (format: + '/subscriptions/{subscriptionId}'), resource group (format: + '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}', or resource (format: + '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{resourceProviderNamespace}/[{parentResourcePath}/]{resourceType}/{resourceName}'. + + :param policy_assignment_id: The ID of the policy assignment to create. Use the format + '{scope}/providers/Microsoft.Authorization/policyAssignments/{policyAssignmentName}'. Required. + :type policy_assignment_id: str + :param parameters: Parameters for policy assignment. Is either a model type or a IO type. + Required. + :type parameters: ~azure.mgmt.resource.policy.v2021_06_01.models.PolicyAssignment or IO + :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. + Default value is None. + :paramtype content_type: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: PolicyAssignment, or the result of cls(response) + :return: PolicyAssignment or the result of cls(response) :rtype: ~azure.mgmt.resource.policy.v2021_06_01.models.PolicyAssignment - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.PolicyAssignment"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', "2021-06-01") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-06-01")) # type: str + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.PolicyAssignment] - _json = self._serialize.body(parameters, 'PolicyAssignment') + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(parameters, (IO, bytes)): + _content = parameters + else: + _json = self._serialize.body(parameters, "PolicyAssignment") request = build_policy_assignments_create_by_id_request( policy_assignment_id=policy_assignment_id, api_version=api_version, content_type=content_type, json=_json, - template_url=self.create_by_id.metadata['url'], + content=_content, + template_url=self.create_by_id.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [201]: map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) - deserialized = self._deserialize('PolicyAssignment', pipeline_response) + deserialized = self._deserialize("PolicyAssignment", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - create_by_id.metadata = {'url': "/{policyAssignmentId}"} # type: ignore - + create_by_id.metadata = {"url": "/{policyAssignmentId}"} # type: ignore @distributed_trace - def get_by_id( - self, - policy_assignment_id: str, - **kwargs: Any - ) -> "_models.PolicyAssignment": + def get_by_id(self, policy_assignment_id: str, **kwargs: Any) -> _models.PolicyAssignment: """Retrieves the policy assignment with the given ID. The operation retrieves the policy assignment with the given ID. Policy assignment IDs have @@ -2635,61 +3049,65 @@ def get_by_id( '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{resourceProviderNamespace}/[{parentResourcePath}/]{resourceType}/{resourceName}'. :param policy_assignment_id: The ID of the policy assignment to get. Use the format - '{scope}/providers/Microsoft.Authorization/policyAssignments/{policyAssignmentName}'. + '{scope}/providers/Microsoft.Authorization/policyAssignments/{policyAssignmentName}'. Required. :type policy_assignment_id: str - :keyword api_version: Api Version. Default value is "2021-06-01". Note that overriding this - default value may result in unsupported behavior. - :paramtype api_version: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: PolicyAssignment, or the result of cls(response) + :return: PolicyAssignment or the result of cls(response) :rtype: ~azure.mgmt.resource.policy.v2021_06_01.models.PolicyAssignment - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.PolicyAssignment"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + 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', "2021-06-01") # type: str + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-06-01")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[_models.PolicyAssignment] - request = build_policy_assignments_get_by_id_request( policy_assignment_id=policy_assignment_id, api_version=api_version, - template_url=self.get_by_id.metadata['url'], + template_url=self.get_by_id.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) - deserialized = self._deserialize('PolicyAssignment', pipeline_response) + deserialized = self._deserialize("PolicyAssignment", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - get_by_id.metadata = {'url': "/{policyAssignmentId}"} # type: ignore - + get_by_id.metadata = {"url": "/{policyAssignmentId}"} # type: ignore - @distributed_trace + @overload def update_by_id( self, policy_assignment_id: str, - parameters: "_models.PolicyAssignmentUpdate", + parameters: _models.PolicyAssignmentUpdate, + *, + content_type: str = "application/json", **kwargs: Any - ) -> "_models.PolicyAssignment": + ) -> _models.PolicyAssignment: """Updates a policy assignment. This operation updates the policy assignment with the given ID. Policy assignments made on a @@ -2704,115 +3122,249 @@ def update_by_id( '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{resourceProviderNamespace}/[{parentResourcePath}/]{resourceType}/{resourceName}'. :param policy_assignment_id: The ID of the policy assignment to update. Use the format - '{scope}/providers/Microsoft.Authorization/policyAssignments/{policyAssignmentName}'. + '{scope}/providers/Microsoft.Authorization/policyAssignments/{policyAssignmentName}'. Required. :type policy_assignment_id: str - :param parameters: Parameters for policy assignment patch request. + :param parameters: Parameters for policy assignment patch request. Required. :type parameters: ~azure.mgmt.resource.policy.v2021_06_01.models.PolicyAssignmentUpdate - :keyword api_version: Api Version. Default value is "2021-06-01". Note that overriding this - default value may result in unsupported behavior. - :paramtype api_version: str + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: PolicyAssignment, or the result of cls(response) + :return: PolicyAssignment or the result of cls(response) :rtype: ~azure.mgmt.resource.policy.v2021_06_01.models.PolicyAssignment - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.PolicyAssignment"] - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {})) - api_version = kwargs.pop('api_version', "2021-06-01") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + @overload + def update_by_id( + self, policy_assignment_id: str, parameters: IO, *, content_type: str = "application/json", **kwargs: Any + ) -> _models.PolicyAssignment: + """Updates a policy assignment. - _json = self._serialize.body(parameters, 'PolicyAssignmentUpdate') + This operation updates the policy assignment with the given ID. Policy assignments made on a + scope apply to all resources contained in that scope. For example, when you assign a policy to + a resource group that policy applies to all resources in the group. Policy assignment IDs have + this format: + '{scope}/providers/Microsoft.Authorization/policyAssignments/{policyAssignmentName}'. Valid + scopes are: management group (format: + '/providers/Microsoft.Management/managementGroups/{managementGroup}'), subscription (format: + '/subscriptions/{subscriptionId}'), resource group (format: + '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}', or resource (format: + '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{resourceProviderNamespace}/[{parentResourcePath}/]{resourceType}/{resourceName}'. - request = build_policy_assignments_update_by_id_request( - policy_assignment_id=policy_assignment_id, - api_version=api_version, - content_type=content_type, - json=_json, - template_url=self.update_by_id.metadata['url'], - ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) + :param policy_assignment_id: The ID of the policy assignment to update. Use the format + '{scope}/providers/Microsoft.Authorization/policyAssignments/{policyAssignmentName}'. Required. + :type policy_assignment_id: str + :param parameters: Parameters for policy assignment patch request. Required. + :type parameters: IO + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: PolicyAssignment or the result of cls(response) + :rtype: ~azure.mgmt.resource.policy.v2021_06_01.models.PolicyAssignment + :raises ~azure.core.exceptions.HttpResponseError: + """ - pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs - ) - response = pipeline_response.http_response + @distributed_trace + def update_by_id( + self, policy_assignment_id: str, parameters: Union[_models.PolicyAssignmentUpdate, IO], **kwargs: Any + ) -> _models.PolicyAssignment: + """Updates a policy assignment. + + This operation updates the policy assignment with the given ID. Policy assignments made on a + scope apply to all resources contained in that scope. For example, when you assign a policy to + a resource group that policy applies to all resources in the group. Policy assignment IDs have + this format: + '{scope}/providers/Microsoft.Authorization/policyAssignments/{policyAssignmentName}'. Valid + scopes are: management group (format: + '/providers/Microsoft.Management/managementGroups/{managementGroup}'), subscription (format: + '/subscriptions/{subscriptionId}'), resource group (format: + '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}', or resource (format: + '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{resourceProviderNamespace}/[{parentResourcePath}/]{resourceType}/{resourceName}'. + + :param policy_assignment_id: The ID of the policy assignment to update. Use the format + '{scope}/providers/Microsoft.Authorization/policyAssignments/{policyAssignmentName}'. Required. + :type policy_assignment_id: str + :param parameters: Parameters for policy assignment patch request. Is either a model type or a + IO type. Required. + :type parameters: ~azure.mgmt.resource.policy.v2021_06_01.models.PolicyAssignmentUpdate or IO + :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. + Default value is None. + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: PolicyAssignment or the result of cls(response) + :rtype: ~azure.mgmt.resource.policy.v2021_06_01.models.PolicyAssignment + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-06-01")) # type: str + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.PolicyAssignment] + + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(parameters, (IO, bytes)): + _content = parameters + else: + _json = self._serialize.body(parameters, "PolicyAssignmentUpdate") + + request = build_policy_assignments_update_by_id_request( + policy_assignment_id=policy_assignment_id, + api_version=api_version, + content_type=content_type, + json=_json, + content=_content, + template_url=self.update_by_id.metadata["url"], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore + + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs + ) + + response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) - deserialized = self._deserialize('PolicyAssignment', pipeline_response) + deserialized = self._deserialize("PolicyAssignment", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - update_by_id.metadata = {'url': "/{policyAssignmentId}"} # type: ignore + update_by_id.metadata = {"url": "/{policyAssignmentId}"} # type: ignore -class PolicyDefinitionsOperations(object): - """PolicyDefinitionsOperations operations. - You should not instantiate this class directly. Instead, you should create a Client instance that - instantiates it for you and attaches it as an attribute. +class PolicyDefinitionsOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. - :ivar models: Alias to model classes used in this operation group. - :type models: ~azure.mgmt.resource.policy.v2021_06_01.models - :param client: Client for service requests. - :param config: Configuration of service client. - :param serializer: An object model serializer. - :param deserializer: An object model deserializer. + Instead, you should access the following operations through + :class:`~azure.mgmt.resource.policy.v2021_06_01.PolicyClient`'s + :attr:`policy_definitions` attribute. """ models = _models - def __init__(self, client, config, serializer, deserializer): - self._client = client - self._serialize = serializer - self._deserialize = deserializer - self._config = config + def __init__(self, *args, **kwargs): + input_args = list(args) + self._client = input_args.pop(0) if input_args else kwargs.pop("client") + self._config = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") - @distributed_trace + @overload def create_or_update( self, policy_definition_name: str, - parameters: "_models.PolicyDefinition", + parameters: _models.PolicyDefinition, + *, + content_type: str = "application/json", **kwargs: Any - ) -> "_models.PolicyDefinition": + ) -> _models.PolicyDefinition: """Creates or updates a policy definition in a subscription. This operation creates or updates a policy definition in the given subscription with the given name. - :param policy_definition_name: The name of the policy definition to create. + :param policy_definition_name: The name of the policy definition to create. Required. :type policy_definition_name: str - :param parameters: The policy definition properties. + :param parameters: The policy definition properties. Required. :type parameters: ~azure.mgmt.resource.policy.v2021_06_01.models.PolicyDefinition - :keyword api_version: Api Version. Default value is "2021-06-01". Note that overriding this - default value may result in unsupported behavior. - :paramtype api_version: str + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: PolicyDefinition or the result of cls(response) + :rtype: ~azure.mgmt.resource.policy.v2021_06_01.models.PolicyDefinition + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + def create_or_update( + self, policy_definition_name: str, parameters: IO, *, content_type: str = "application/json", **kwargs: Any + ) -> _models.PolicyDefinition: + """Creates or updates a policy definition in a subscription. + + This operation creates or updates a policy definition in the given subscription with the given + name. + + :param policy_definition_name: The name of the policy definition to create. Required. + :type policy_definition_name: str + :param parameters: The policy definition properties. Required. + :type parameters: IO + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: PolicyDefinition or the result of cls(response) + :rtype: ~azure.mgmt.resource.policy.v2021_06_01.models.PolicyDefinition + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace + def create_or_update( + self, policy_definition_name: str, parameters: Union[_models.PolicyDefinition, IO], **kwargs: Any + ) -> _models.PolicyDefinition: + """Creates or updates a policy definition in a subscription. + + This operation creates or updates a policy definition in the given subscription with the given + name. + + :param policy_definition_name: The name of the policy definition to create. Required. + :type policy_definition_name: str + :param parameters: The policy definition properties. Is either a model type or a IO type. + Required. + :type parameters: ~azure.mgmt.resource.policy.v2021_06_01.models.PolicyDefinition or IO + :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. + Default value is None. + :paramtype content_type: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: PolicyDefinition, or the result of cls(response) + :return: PolicyDefinition or the result of cls(response) :rtype: ~azure.mgmt.resource.policy.v2021_06_01.models.PolicyDefinition - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.PolicyDefinition"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', "2021-06-01") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-06-01")) # type: str + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.PolicyDefinition] - _json = self._serialize.body(parameters, 'PolicyDefinition') + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(parameters, (IO, bytes)): + _content = parameters + else: + _json = self._serialize.body(parameters, "PolicyDefinition") request = build_policy_definitions_create_or_update_request( policy_definition_name=policy_definition_name, @@ -2820,75 +3372,77 @@ def create_or_update( api_version=api_version, content_type=content_type, json=_json, - template_url=self.create_or_update.metadata['url'], + content=_content, + template_url=self.create_or_update.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [201]: map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) - deserialized = self._deserialize('PolicyDefinition', pipeline_response) + deserialized = self._deserialize("PolicyDefinition", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - create_or_update.metadata = {'url': "/subscriptions/{subscriptionId}/providers/Microsoft.Authorization/policyDefinitions/{policyDefinitionName}"} # type: ignore - + create_or_update.metadata = {"url": "/subscriptions/{subscriptionId}/providers/Microsoft.Authorization/policyDefinitions/{policyDefinitionName}"} # type: ignore @distributed_trace def delete( # pylint: disable=inconsistent-return-statements - self, - policy_definition_name: str, - **kwargs: Any + self, policy_definition_name: str, **kwargs: Any ) -> None: """Deletes a policy definition in a subscription. This operation deletes the policy definition in the given subscription with the given name. - :param policy_definition_name: The name of the policy definition to delete. + :param policy_definition_name: The name of the policy definition to delete. Required. :type policy_definition_name: str - :keyword api_version: Api Version. Default value is "2021-06-01". Note that overriding this - default value may result in unsupported behavior. - :paramtype api_version: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: None, or the result of cls(response) + :return: None or the result of cls(response) :rtype: None - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType[None] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + 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', "2021-06-01") # type: str + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-06-01")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[None] - request = build_policy_definitions_delete_request( policy_definition_name=policy_definition_name, subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.delete.metadata['url'], + template_url=self.delete.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200, 204]: @@ -2898,163 +3452,231 @@ def delete( # pylint: disable=inconsistent-return-statements if cls: return cls(pipeline_response, None, {}) - delete.metadata = {'url': "/subscriptions/{subscriptionId}/providers/Microsoft.Authorization/policyDefinitions/{policyDefinitionName}"} # type: ignore - + delete.metadata = {"url": "/subscriptions/{subscriptionId}/providers/Microsoft.Authorization/policyDefinitions/{policyDefinitionName}"} # type: ignore @distributed_trace - def get( - self, - policy_definition_name: str, - **kwargs: Any - ) -> "_models.PolicyDefinition": + def get(self, policy_definition_name: str, **kwargs: Any) -> _models.PolicyDefinition: """Retrieves a policy definition in a subscription. This operation retrieves the policy definition in the given subscription with the given name. - :param policy_definition_name: The name of the policy definition to get. + :param policy_definition_name: The name of the policy definition to get. Required. :type policy_definition_name: str - :keyword api_version: Api Version. Default value is "2021-06-01". Note that overriding this - default value may result in unsupported behavior. - :paramtype api_version: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: PolicyDefinition, or the result of cls(response) + :return: PolicyDefinition or the result of cls(response) :rtype: ~azure.mgmt.resource.policy.v2021_06_01.models.PolicyDefinition - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.PolicyDefinition"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + 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', "2021-06-01") # type: str + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-06-01")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[_models.PolicyDefinition] - request = build_policy_definitions_get_request( policy_definition_name=policy_definition_name, subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.get.metadata['url'], + template_url=self.get.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) - deserialized = self._deserialize('PolicyDefinition', pipeline_response) + deserialized = self._deserialize("PolicyDefinition", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - get.metadata = {'url': "/subscriptions/{subscriptionId}/providers/Microsoft.Authorization/policyDefinitions/{policyDefinitionName}"} # type: ignore - + get.metadata = {"url": "/subscriptions/{subscriptionId}/providers/Microsoft.Authorization/policyDefinitions/{policyDefinitionName}"} # type: ignore @distributed_trace - def get_built_in( - self, - policy_definition_name: str, - **kwargs: Any - ) -> "_models.PolicyDefinition": + def get_built_in(self, policy_definition_name: str, **kwargs: Any) -> _models.PolicyDefinition: """Retrieves a built-in policy definition. This operation retrieves the built-in policy definition with the given name. - :param policy_definition_name: The name of the built-in policy definition to get. + :param policy_definition_name: The name of the built-in policy definition to get. Required. :type policy_definition_name: str - :keyword api_version: Api Version. Default value is "2021-06-01". Note that overriding this - default value may result in unsupported behavior. - :paramtype api_version: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: PolicyDefinition, or the result of cls(response) + :return: PolicyDefinition or the result of cls(response) :rtype: ~azure.mgmt.resource.policy.v2021_06_01.models.PolicyDefinition - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.PolicyDefinition"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + 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', "2021-06-01") # type: str + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-06-01")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[_models.PolicyDefinition] - request = build_policy_definitions_get_built_in_request( policy_definition_name=policy_definition_name, api_version=api_version, - template_url=self.get_built_in.metadata['url'], + template_url=self.get_built_in.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) - deserialized = self._deserialize('PolicyDefinition', pipeline_response) + deserialized = self._deserialize("PolicyDefinition", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - get_built_in.metadata = {'url': "/providers/Microsoft.Authorization/policyDefinitions/{policyDefinitionName}"} # type: ignore + get_built_in.metadata = {"url": "/providers/Microsoft.Authorization/policyDefinitions/{policyDefinitionName}"} # type: ignore + + @overload + def create_or_update_at_management_group( + self, + policy_definition_name: str, + management_group_id: str, + parameters: _models.PolicyDefinition, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.PolicyDefinition: + """Creates or updates a policy definition in a management group. + + This operation creates or updates a policy definition in the given management group with the + given name. + + :param policy_definition_name: The name of the policy definition to create. Required. + :type policy_definition_name: str + :param management_group_id: The ID of the management group. Required. + :type management_group_id: str + :param parameters: The policy definition properties. Required. + :type parameters: ~azure.mgmt.resource.policy.v2021_06_01.models.PolicyDefinition + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: PolicyDefinition or the result of cls(response) + :rtype: ~azure.mgmt.resource.policy.v2021_06_01.models.PolicyDefinition + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + def create_or_update_at_management_group( + self, + policy_definition_name: str, + management_group_id: str, + parameters: IO, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.PolicyDefinition: + """Creates or updates a policy definition in a management group. + + This operation creates or updates a policy definition in the given management group with the + given name. + :param policy_definition_name: The name of the policy definition to create. Required. + :type policy_definition_name: str + :param management_group_id: The ID of the management group. Required. + :type management_group_id: str + :param parameters: The policy definition properties. Required. + :type parameters: IO + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: PolicyDefinition or the result of cls(response) + :rtype: ~azure.mgmt.resource.policy.v2021_06_01.models.PolicyDefinition + :raises ~azure.core.exceptions.HttpResponseError: + """ @distributed_trace def create_or_update_at_management_group( self, policy_definition_name: str, management_group_id: str, - parameters: "_models.PolicyDefinition", + parameters: Union[_models.PolicyDefinition, IO], **kwargs: Any - ) -> "_models.PolicyDefinition": + ) -> _models.PolicyDefinition: """Creates or updates a policy definition in a management group. This operation creates or updates a policy definition in the given management group with the given name. - :param policy_definition_name: The name of the policy definition to create. + :param policy_definition_name: The name of the policy definition to create. Required. :type policy_definition_name: str - :param management_group_id: The ID of the management group. + :param management_group_id: The ID of the management group. Required. :type management_group_id: str - :param parameters: The policy definition properties. - :type parameters: ~azure.mgmt.resource.policy.v2021_06_01.models.PolicyDefinition - :keyword api_version: Api Version. Default value is "2021-06-01". Note that overriding this - default value may result in unsupported behavior. - :paramtype api_version: str + :param parameters: The policy definition properties. Is either a model type or a IO type. + Required. + :type parameters: ~azure.mgmt.resource.policy.v2021_06_01.models.PolicyDefinition or IO + :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. + Default value is None. + :paramtype content_type: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: PolicyDefinition, or the result of cls(response) + :return: PolicyDefinition or the result of cls(response) :rtype: ~azure.mgmt.resource.policy.v2021_06_01.models.PolicyDefinition - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.PolicyDefinition"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) - api_version = kwargs.pop('api_version', "2021-06-01") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - _json = self._serialize.body(parameters, 'PolicyDefinition') + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-06-01")) # type: str + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.PolicyDefinition] + + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(parameters, (IO, bytes)): + _content = parameters + else: + _json = self._serialize.body(parameters, "PolicyDefinition") request = build_policy_definitions_create_or_update_at_management_group_request( policy_definition_name=policy_definition_name, @@ -3062,78 +3684,79 @@ def create_or_update_at_management_group( api_version=api_version, content_type=content_type, json=_json, - template_url=self.create_or_update_at_management_group.metadata['url'], + content=_content, + template_url=self.create_or_update_at_management_group.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [201]: map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) - deserialized = self._deserialize('PolicyDefinition', pipeline_response) + deserialized = self._deserialize("PolicyDefinition", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - create_or_update_at_management_group.metadata = {'url': "/providers/Microsoft.Management/managementGroups/{managementGroupId}/providers/Microsoft.Authorization/policyDefinitions/{policyDefinitionName}"} # type: ignore - + create_or_update_at_management_group.metadata = {"url": "/providers/Microsoft.Management/managementGroups/{managementGroupId}/providers/Microsoft.Authorization/policyDefinitions/{policyDefinitionName}"} # type: ignore @distributed_trace def delete_at_management_group( # pylint: disable=inconsistent-return-statements - self, - policy_definition_name: str, - management_group_id: str, - **kwargs: Any + self, policy_definition_name: str, management_group_id: str, **kwargs: Any ) -> None: """Deletes a policy definition in a management group. This operation deletes the policy definition in the given management group with the given name. - :param policy_definition_name: The name of the policy definition to delete. + :param policy_definition_name: The name of the policy definition to delete. Required. :type policy_definition_name: str - :param management_group_id: The ID of the management group. + :param management_group_id: The ID of the management group. Required. :type management_group_id: str - :keyword api_version: Api Version. Default value is "2021-06-01". Note that overriding this - default value may result in unsupported behavior. - :paramtype api_version: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: None, or the result of cls(response) + :return: None or the result of cls(response) :rtype: None - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType[None] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + 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', "2021-06-01") # type: str + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-06-01")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[None] - request = build_policy_definitions_delete_at_management_group_request( policy_definition_name=policy_definition_name, management_group_id=management_group_id, api_version=api_version, - template_url=self.delete_at_management_group.metadata['url'], + template_url=self.delete_at_management_group.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200, 204]: @@ -3143,79 +3766,74 @@ def delete_at_management_group( # pylint: disable=inconsistent-return-statement if cls: return cls(pipeline_response, None, {}) - delete_at_management_group.metadata = {'url': "/providers/Microsoft.Management/managementGroups/{managementGroupId}/providers/Microsoft.Authorization/policyDefinitions/{policyDefinitionName}"} # type: ignore - + delete_at_management_group.metadata = {"url": "/providers/Microsoft.Management/managementGroups/{managementGroupId}/providers/Microsoft.Authorization/policyDefinitions/{policyDefinitionName}"} # type: ignore @distributed_trace def get_at_management_group( - self, - policy_definition_name: str, - management_group_id: str, - **kwargs: Any - ) -> "_models.PolicyDefinition": + self, policy_definition_name: str, management_group_id: str, **kwargs: Any + ) -> _models.PolicyDefinition: """Retrieve a policy definition in a management group. This operation retrieves the policy definition in the given management group with the given name. - :param policy_definition_name: The name of the policy definition to get. + :param policy_definition_name: The name of the policy definition to get. Required. :type policy_definition_name: str - :param management_group_id: The ID of the management group. + :param management_group_id: The ID of the management group. Required. :type management_group_id: str - :keyword api_version: Api Version. Default value is "2021-06-01". Note that overriding this - default value may result in unsupported behavior. - :paramtype api_version: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: PolicyDefinition, or the result of cls(response) + :return: PolicyDefinition or the result of cls(response) :rtype: ~azure.mgmt.resource.policy.v2021_06_01.models.PolicyDefinition - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.PolicyDefinition"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) - api_version = kwargs.pop('api_version', "2021-06-01") # type: str + _headers = 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: str + cls = kwargs.pop("cls", None) # type: ClsType[_models.PolicyDefinition] - request = build_policy_definitions_get_at_management_group_request( policy_definition_name=policy_definition_name, management_group_id=management_group_id, api_version=api_version, - template_url=self.get_at_management_group.metadata['url'], + template_url=self.get_at_management_group.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) - deserialized = self._deserialize('PolicyDefinition', pipeline_response) + deserialized = self._deserialize("PolicyDefinition", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - get_at_management_group.metadata = {'url': "/providers/Microsoft.Management/managementGroups/{managementGroupId}/providers/Microsoft.Authorization/policyDefinitions/{policyDefinitionName}"} # type: ignore - + get_at_management_group.metadata = {"url": "/providers/Microsoft.Management/managementGroups/{managementGroupId}/providers/Microsoft.Authorization/policyDefinitions/{policyDefinitionName}"} # type: ignore @distributed_trace def list( - self, - filter: Optional[str] = None, - top: Optional[int] = None, - **kwargs: Any - ) -> Iterable["_models.PolicyDefinitionListResult"]: + self, filter: Optional[str] = None, top: Optional[int] = None, **kwargs: Any + ) -> Iterable["_models.PolicyDefinition"]: """Retrieves policy definitions in a subscription. This operation retrieves a list of all the policy definitions in a given subscription that @@ -3241,250 +3859,1110 @@ def list( :param top: Maximum number of records to return. When the $top filter is not provided, it will return 500 records. Default value is None. :type top: int - :keyword api_version: Api Version. Default value is "2021-06-01". Note that overriding this - default value may result in unsupported behavior. - :paramtype api_version: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either PolicyDefinitionListResult or the result of - cls(response) + :return: An iterator like instance of either PolicyDefinition or the result of cls(response) :rtype: - ~azure.core.paging.ItemPaged[~azure.mgmt.resource.policy.v2021_06_01.models.PolicyDefinitionListResult] - :raises: ~azure.core.exceptions.HttpResponseError + ~azure.core.paging.ItemPaged[~azure.mgmt.resource.policy.v2021_06_01.models.PolicyDefinition] + :raises ~azure.core.exceptions.HttpResponseError: """ - api_version = kwargs.pop('api_version', "2021-06-01") # type: str + _headers = 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: str + cls = kwargs.pop("cls", None) # type: ClsType[_models.PolicyDefinitionListResult] - cls = kwargs.pop('cls', None) # type: ClsType["_models.PolicyDefinitionListResult"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) + def prepare_request(next_link=None): if not next_link: - + request = build_policy_definitions_list_request( subscription_id=self._config.subscription_id, - api_version=api_version, filter=filter, top=top, - template_url=self.list.metadata['url'], + 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.url = self._client.format_url(request.url) # type: ignore else: - - request = build_policy_definitions_list_request( - subscription_id=self._config.subscription_id, - template_url=next_link, + request = HttpRequest("GET", next_link) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore + request.method = "GET" + return request + + def extract_data(pipeline_response): + deserialized = self._deserialize("PolicyDefinitionListResult", pipeline_response) + list_of_elem = deserialized.value + if cls: + list_of_elem = cls(list_of_elem) + 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 + ) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + return pipeline_response + + return ItemPaged(get_next, extract_data) + + list.metadata = {"url": "/subscriptions/{subscriptionId}/providers/Microsoft.Authorization/policyDefinitions"} # type: ignore + + @distributed_trace + def list_built_in( + self, filter: Optional[str] = None, top: Optional[int] = None, **kwargs: Any + ) -> Iterable["_models.PolicyDefinition"]: + """Retrieve built-in policy definitions. + + This operation retrieves a list of all the built-in policy definitions that match the optional + given $filter. If $filter='policyType -eq {value}' is provided, the returned list only includes + all built-in policy definitions whose type match the {value}. Possible policyType values are + NotSpecified, BuiltIn, Custom, and Static. If $filter='category -eq {value}' is provided, the + returned list only includes all built-in policy definitions whose category match the {value}. + + :param filter: The filter to apply on the operation. Valid values for $filter are: + 'atExactScope()', 'policyType -eq {value}' or 'category eq '{value}''. If $filter is not + provided, no filtering is performed. If $filter=atExactScope() is provided, the returned list + only includes all policy definitions that at the given scope. If $filter='policyType -eq + {value}' is provided, the returned list only includes all policy definitions whose type match + the {value}. Possible policyType values are NotSpecified, BuiltIn, Custom, and Static. If + $filter='category -eq {value}' is provided, the returned list only includes all policy + definitions whose category match the {value}. Default value is None. + :type filter: str + :param top: Maximum number of records to return. When the $top filter is not provided, it will + return 500 records. Default value is None. + :type top: int + :keyword callable cls: A custom type or function that will be passed the direct response + :return: An iterator like instance of either PolicyDefinition or the result of cls(response) + :rtype: + ~azure.core.paging.ItemPaged[~azure.mgmt.resource.policy.v2021_06_01.models.PolicyDefinition] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _headers = 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: str + cls = kwargs.pop("cls", None) # type: ClsType[_models.PolicyDefinitionListResult] + + error_map = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + def prepare_request(next_link=None): + if not next_link: + + request = build_policy_definitions_list_built_in_request( + filter=filter, + top=top, + api_version=api_version, + template_url=self.list_built_in.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore + + else: + request = HttpRequest("GET", next_link) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore request.method = "GET" return request - def extract_data(pipeline_response): - deserialized = self._deserialize("PolicyDefinitionListResult", pipeline_response) - list_of_elem = deserialized.value - if cls: - list_of_elem = cls(list_of_elem) - return deserialized.next_link or None, iter(list_of_elem) + def extract_data(pipeline_response): + deserialized = self._deserialize("PolicyDefinitionListResult", pipeline_response) + list_of_elem = deserialized.value + if cls: + list_of_elem = cls(list_of_elem) + 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 + ) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + return pipeline_response + + return ItemPaged(get_next, extract_data) + + list_built_in.metadata = {"url": "/providers/Microsoft.Authorization/policyDefinitions"} # type: ignore + + @distributed_trace + def list_by_management_group( + self, management_group_id: str, filter: Optional[str] = None, top: Optional[int] = None, **kwargs: Any + ) -> Iterable["_models.PolicyDefinition"]: + """Retrieve policy definitions in a management group. + + This operation retrieves a list of all the policy definitions in a given management group that + match the optional given $filter. Valid values for $filter are: 'atExactScope()', 'policyType + -eq {value}' or 'category eq '{value}''. If $filter is not provided, the unfiltered list + includes all policy definitions associated with the management group, including those that + apply directly or from management groups that contain the given management group. If + $filter=atExactScope() is provided, the returned list only includes all policy definitions that + at the given management group. If $filter='policyType -eq {value}' is provided, the returned + list only includes all policy definitions whose type match the {value}. Possible policyType + values are NotSpecified, BuiltIn, Custom, and Static. If $filter='category -eq {value}' is + provided, the returned list only includes all policy definitions whose category match the + {value}. + + :param management_group_id: The ID of the management group. Required. + :type management_group_id: str + :param filter: The filter to apply on the operation. Valid values for $filter are: + 'atExactScope()', 'policyType -eq {value}' or 'category eq '{value}''. If $filter is not + provided, no filtering is performed. If $filter=atExactScope() is provided, the returned list + only includes all policy definitions that at the given scope. If $filter='policyType -eq + {value}' is provided, the returned list only includes all policy definitions whose type match + the {value}. Possible policyType values are NotSpecified, BuiltIn, Custom, and Static. If + $filter='category -eq {value}' is provided, the returned list only includes all policy + definitions whose category match the {value}. Default value is None. + :type filter: str + :param top: Maximum number of records to return. When the $top filter is not provided, it will + return 500 records. Default value is None. + :type top: int + :keyword callable cls: A custom type or function that will be passed the direct response + :return: An iterator like instance of either PolicyDefinition or the result of cls(response) + :rtype: + ~azure.core.paging.ItemPaged[~azure.mgmt.resource.policy.v2021_06_01.models.PolicyDefinition] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _headers = 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: str + cls = kwargs.pop("cls", None) # type: ClsType[_models.PolicyDefinitionListResult] + + error_map = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + def prepare_request(next_link=None): + if not next_link: + + request = build_policy_definitions_list_by_management_group_request( + management_group_id=management_group_id, + filter=filter, + top=top, + api_version=api_version, + template_url=self.list_by_management_group.metadata["url"], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore + + else: + request = HttpRequest("GET", next_link) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore + request.method = "GET" + return request + + def extract_data(pipeline_response): + deserialized = self._deserialize("PolicyDefinitionListResult", pipeline_response) + list_of_elem = deserialized.value + if cls: + list_of_elem = cls(list_of_elem) + 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 + ) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + return pipeline_response + + return ItemPaged(get_next, extract_data) + + list_by_management_group.metadata = {"url": "/providers/Microsoft.Management/managementGroups/{managementGroupId}/providers/Microsoft.Authorization/policyDefinitions"} # type: ignore + + +class PolicySetDefinitionsOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. + + Instead, you should access the following operations through + :class:`~azure.mgmt.resource.policy.v2021_06_01.PolicyClient`'s + :attr:`policy_set_definitions` attribute. + """ + + models = _models + + def __init__(self, *args, **kwargs): + input_args = list(args) + self._client = input_args.pop(0) if input_args else kwargs.pop("client") + self._config = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") + + @overload + def create_or_update( + self, + policy_set_definition_name: str, + parameters: _models.PolicySetDefinition, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.PolicySetDefinition: + """Creates or updates a policy set definition. + + This operation creates or updates a policy set definition in the given subscription with the + given name. + + :param policy_set_definition_name: The name of the policy set definition to create. Required. + :type policy_set_definition_name: str + :param parameters: The policy set definition properties. Required. + :type parameters: ~azure.mgmt.resource.policy.v2021_06_01.models.PolicySetDefinition + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: PolicySetDefinition or the result of cls(response) + :rtype: ~azure.mgmt.resource.policy.v2021_06_01.models.PolicySetDefinition + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + def create_or_update( + self, policy_set_definition_name: str, parameters: IO, *, content_type: str = "application/json", **kwargs: Any + ) -> _models.PolicySetDefinition: + """Creates or updates a policy set definition. + + This operation creates or updates a policy set definition in the given subscription with the + given name. + + :param policy_set_definition_name: The name of the policy set definition to create. Required. + :type policy_set_definition_name: str + :param parameters: The policy set definition properties. Required. + :type parameters: IO + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: PolicySetDefinition or the result of cls(response) + :rtype: ~azure.mgmt.resource.policy.v2021_06_01.models.PolicySetDefinition + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace + def create_or_update( + self, policy_set_definition_name: str, parameters: Union[_models.PolicySetDefinition, IO], **kwargs: Any + ) -> _models.PolicySetDefinition: + """Creates or updates a policy set definition. + + This operation creates or updates a policy set definition in the given subscription with the + given name. + + :param policy_set_definition_name: The name of the policy set definition to create. Required. + :type policy_set_definition_name: str + :param parameters: The policy set definition properties. Is either a model type or a IO type. + Required. + :type parameters: ~azure.mgmt.resource.policy.v2021_06_01.models.PolicySetDefinition or IO + :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. + Default value is None. + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: PolicySetDefinition or the result of cls(response) + :rtype: ~azure.mgmt.resource.policy.v2021_06_01.models.PolicySetDefinition + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-06-01")) # type: str + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.PolicySetDefinition] + + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(parameters, (IO, bytes)): + _content = parameters + else: + _json = self._serialize.body(parameters, "PolicySetDefinition") + + request = build_policy_set_definitions_create_or_update_request( + policy_set_definition_name=policy_set_definition_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + content_type=content_type, + json=_json, + content=_content, + template_url=self.create_or_update.metadata["url"], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore + + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [200, 201]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + if response.status_code == 200: + deserialized = self._deserialize("PolicySetDefinition", pipeline_response) + + if response.status_code == 201: + deserialized = self._deserialize("PolicySetDefinition", pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + + create_or_update.metadata = {"url": "/subscriptions/{subscriptionId}/providers/Microsoft.Authorization/policySetDefinitions/{policySetDefinitionName}"} # type: ignore + + @distributed_trace + def delete( # pylint: disable=inconsistent-return-statements + self, policy_set_definition_name: str, **kwargs: Any + ) -> None: + """Deletes a policy set definition. + + This operation deletes the policy set definition in the given subscription with the given name. + + :param policy_set_definition_name: The name of the policy set definition to delete. Required. + :type policy_set_definition_name: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: None or the result of cls(response) + :rtype: None + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-06-01")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[None] + + request = build_policy_set_definitions_delete_request( + policy_set_definition_name=policy_set_definition_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + template_url=self.delete.metadata["url"], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore + + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [200, 204]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + if cls: + return cls(pipeline_response, None, {}) + + delete.metadata = {"url": "/subscriptions/{subscriptionId}/providers/Microsoft.Authorization/policySetDefinitions/{policySetDefinitionName}"} # type: ignore + + @distributed_trace + def get(self, policy_set_definition_name: str, **kwargs: Any) -> _models.PolicySetDefinition: + """Retrieves a policy set definition. + + This operation retrieves the policy set definition in the given subscription with the given + name. + + :param policy_set_definition_name: The name of the policy set definition to get. Required. + :type policy_set_definition_name: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: PolicySetDefinition or the result of cls(response) + :rtype: ~azure.mgmt.resource.policy.v2021_06_01.models.PolicySetDefinition + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-06-01")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[_models.PolicySetDefinition] + + request = build_policy_set_definitions_get_request( + policy_set_definition_name=policy_set_definition_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + template_url=self.get.metadata["url"], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore + + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + deserialized = self._deserialize("PolicySetDefinition", pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + + get.metadata = {"url": "/subscriptions/{subscriptionId}/providers/Microsoft.Authorization/policySetDefinitions/{policySetDefinitionName}"} # type: ignore + + @distributed_trace + def get_built_in(self, policy_set_definition_name: str, **kwargs: Any) -> _models.PolicySetDefinition: + """Retrieves a built in policy set definition. + + This operation retrieves the built-in policy set definition with the given name. + + :param policy_set_definition_name: The name of the policy set definition to get. Required. + :type policy_set_definition_name: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: PolicySetDefinition or the result of cls(response) + :rtype: ~azure.mgmt.resource.policy.v2021_06_01.models.PolicySetDefinition + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-06-01")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[_models.PolicySetDefinition] + + request = build_policy_set_definitions_get_built_in_request( + policy_set_definition_name=policy_set_definition_name, + api_version=api_version, + template_url=self.get_built_in.metadata["url"], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore + + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + deserialized = self._deserialize("PolicySetDefinition", pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + + get_built_in.metadata = {"url": "/providers/Microsoft.Authorization/policySetDefinitions/{policySetDefinitionName}"} # type: ignore + + @distributed_trace + def list( + self, filter: Optional[str] = None, top: Optional[int] = None, **kwargs: Any + ) -> Iterable["_models.PolicySetDefinition"]: + """Retrieves the policy set definitions for a subscription. + + This operation retrieves a list of all the policy set definitions in a given subscription that + match the optional given $filter. Valid values for $filter are: 'atExactScope()', 'policyType + -eq {value}' or 'category eq '{value}''. If $filter is not provided, the unfiltered list + includes all policy set definitions associated with the subscription, including those that + apply directly or from management groups that contain the given subscription. If + $filter=atExactScope() is provided, the returned list only includes all policy set definitions + that at the given subscription. If $filter='policyType -eq {value}' is provided, the returned + list only includes all policy set definitions whose type match the {value}. Possible policyType + values are NotSpecified, BuiltIn and Custom. If $filter='category -eq {value}' is provided, the + returned list only includes all policy set definitions whose category match the {value}. + + :param filter: The filter to apply on the operation. Valid values for $filter are: + 'atExactScope()', 'policyType -eq {value}' or 'category eq '{value}''. If $filter is not + provided, no filtering is performed. If $filter=atExactScope() is provided, the returned list + only includes all policy set definitions that at the given scope. If $filter='policyType -eq + {value}' is provided, the returned list only includes all policy set definitions whose type + match the {value}. Possible policyType values are NotSpecified, BuiltIn, Custom, and Static. If + $filter='category -eq {value}' is provided, the returned list only includes all policy set + definitions whose category match the {value}. Default value is None. + :type filter: str + :param top: Maximum number of records to return. When the $top filter is not provided, it will + return 500 records. Default value is None. + :type top: int + :keyword callable cls: A custom type or function that will be passed the direct response + :return: An iterator like instance of either PolicySetDefinition or the result of cls(response) + :rtype: + ~azure.core.paging.ItemPaged[~azure.mgmt.resource.policy.v2021_06_01.models.PolicySetDefinition] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _headers = 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: str + cls = kwargs.pop("cls", None) # type: ClsType[_models.PolicySetDefinitionListResult] + + error_map = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + def prepare_request(next_link=None): + if not next_link: + + request = build_policy_set_definitions_list_request( + subscription_id=self._config.subscription_id, + filter=filter, + top=top, + 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 + + else: + request = HttpRequest("GET", next_link) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore + request.method = "GET" + return request + + def extract_data(pipeline_response): + deserialized = self._deserialize("PolicySetDefinitionListResult", pipeline_response) + list_of_elem = deserialized.value + if cls: + list_of_elem = cls(list_of_elem) + 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 + ) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + return pipeline_response + + return ItemPaged(get_next, extract_data) + + list.metadata = {"url": "/subscriptions/{subscriptionId}/providers/Microsoft.Authorization/policySetDefinitions"} # type: ignore + + @distributed_trace + def list_built_in( + self, filter: Optional[str] = None, top: Optional[int] = None, **kwargs: Any + ) -> Iterable["_models.PolicySetDefinition"]: + """Retrieves built-in policy set definitions. + + This operation retrieves a list of all the built-in policy set definitions that match the + optional given $filter. If $filter='category -eq {value}' is provided, the returned list only + includes all built-in policy set definitions whose category match the {value}. + + :param filter: The filter to apply on the operation. Valid values for $filter are: + 'atExactScope()', 'policyType -eq {value}' or 'category eq '{value}''. If $filter is not + provided, no filtering is performed. If $filter=atExactScope() is provided, the returned list + only includes all policy set definitions that at the given scope. If $filter='policyType -eq + {value}' is provided, the returned list only includes all policy set definitions whose type + match the {value}. Possible policyType values are NotSpecified, BuiltIn, Custom, and Static. If + $filter='category -eq {value}' is provided, the returned list only includes all policy set + definitions whose category match the {value}. Default value is None. + :type filter: str + :param top: Maximum number of records to return. When the $top filter is not provided, it will + return 500 records. Default value is None. + :type top: int + :keyword callable cls: A custom type or function that will be passed the direct response + :return: An iterator like instance of either PolicySetDefinition or the result of cls(response) + :rtype: + ~azure.core.paging.ItemPaged[~azure.mgmt.resource.policy.v2021_06_01.models.PolicySetDefinition] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _headers = 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: str + cls = kwargs.pop("cls", None) # type: ClsType[_models.PolicySetDefinitionListResult] + + error_map = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + def prepare_request(next_link=None): + if not next_link: + + request = build_policy_set_definitions_list_built_in_request( + filter=filter, + top=top, + api_version=api_version, + template_url=self.list_built_in.metadata["url"], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore + + else: + request = HttpRequest("GET", next_link) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore + request.method = "GET" + return request + + def extract_data(pipeline_response): + deserialized = self._deserialize("PolicySetDefinitionListResult", pipeline_response) + list_of_elem = deserialized.value + if cls: + list_of_elem = cls(list_of_elem) + 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 + ) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + return pipeline_response + + return ItemPaged(get_next, extract_data) + + list_built_in.metadata = {"url": "/providers/Microsoft.Authorization/policySetDefinitions"} # type: ignore + + @overload + def create_or_update_at_management_group( + self, + policy_set_definition_name: str, + management_group_id: str, + parameters: _models.PolicySetDefinition, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.PolicySetDefinition: + """Creates or updates a policy set definition. + + This operation creates or updates a policy set definition in the given management group with + the given name. + + :param policy_set_definition_name: The name of the policy set definition to create. Required. + :type policy_set_definition_name: str + :param management_group_id: The ID of the management group. Required. + :type management_group_id: str + :param parameters: The policy set definition properties. Required. + :type parameters: ~azure.mgmt.resource.policy.v2021_06_01.models.PolicySetDefinition + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: PolicySetDefinition or the result of cls(response) + :rtype: ~azure.mgmt.resource.policy.v2021_06_01.models.PolicySetDefinition + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + def create_or_update_at_management_group( + self, + policy_set_definition_name: str, + management_group_id: str, + parameters: IO, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.PolicySetDefinition: + """Creates or updates a policy set definition. + + This operation creates or updates a policy set definition in the given management group with + the given name. + + :param policy_set_definition_name: The name of the policy set definition to create. Required. + :type policy_set_definition_name: str + :param management_group_id: The ID of the management group. Required. + :type management_group_id: str + :param parameters: The policy set definition properties. Required. + :type parameters: IO + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: PolicySetDefinition or the result of cls(response) + :rtype: ~azure.mgmt.resource.policy.v2021_06_01.models.PolicySetDefinition + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace + def create_or_update_at_management_group( + self, + policy_set_definition_name: str, + management_group_id: str, + parameters: Union[_models.PolicySetDefinition, IO], + **kwargs: Any + ) -> _models.PolicySetDefinition: + """Creates or updates a policy set definition. + + This operation creates or updates a policy set definition in the given management group with + the given name. + + :param policy_set_definition_name: The name of the policy set definition to create. Required. + :type policy_set_definition_name: str + :param management_group_id: The ID of the management group. Required. + :type management_group_id: str + :param parameters: The policy set definition properties. Is either a model type or a IO type. + Required. + :type parameters: ~azure.mgmt.resource.policy.v2021_06_01.models.PolicySetDefinition or IO + :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. + Default value is None. + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: PolicySetDefinition or the result of cls(response) + :rtype: ~azure.mgmt.resource.policy.v2021_06_01.models.PolicySetDefinition + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-06-01")) # type: str + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.PolicySetDefinition] + + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(parameters, (IO, bytes)): + _content = parameters + else: + _json = self._serialize.body(parameters, "PolicySetDefinition") + + request = build_policy_set_definitions_create_or_update_at_management_group_request( + policy_set_definition_name=policy_set_definition_name, + management_group_id=management_group_id, + api_version=api_version, + content_type=content_type, + json=_json, + content=_content, + template_url=self.create_or_update_at_management_group.metadata["url"], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore + + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [200, 201]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + if response.status_code == 200: + deserialized = self._deserialize("PolicySetDefinition", pipeline_response) + + if response.status_code == 201: + deserialized = self._deserialize("PolicySetDefinition", pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + + create_or_update_at_management_group.metadata = {"url": "/providers/Microsoft.Management/managementGroups/{managementGroupId}/providers/Microsoft.Authorization/policySetDefinitions/{policySetDefinitionName}"} # type: ignore + + @distributed_trace + def delete_at_management_group( # pylint: disable=inconsistent-return-statements + self, policy_set_definition_name: str, management_group_id: str, **kwargs: Any + ) -> None: + """Deletes a policy set definition. + + This operation deletes the policy set definition in the given management group with the given + name. + + :param policy_set_definition_name: The name of the policy set definition to delete. Required. + :type policy_set_definition_name: str + :param management_group_id: The ID of the management group. Required. + :type management_group_id: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: None or the result of cls(response) + :rtype: None + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - def get_next(next_link=None): - request = prepare_request(next_link) + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-06-01")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[None] - pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs - ) - response = pipeline_response.http_response + request = build_policy_set_definitions_delete_at_management_group_request( + policy_set_definition_name=policy_set_definition_name, + management_group_id=management_group_id, + api_version=api_version, + template_url=self.delete_at_management_group.metadata["url"], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore - if response.status_code not in [200]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - raise HttpResponseError(response=response, error_format=ARMErrorFormat) + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs + ) - return pipeline_response + response = pipeline_response.http_response + if response.status_code not in [200, 204]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) - return ItemPaged( - get_next, extract_data - ) - list.metadata = {'url': "/subscriptions/{subscriptionId}/providers/Microsoft.Authorization/policyDefinitions"} # type: ignore + if cls: + return cls(pipeline_response, None, {}) + + delete_at_management_group.metadata = {"url": "/providers/Microsoft.Management/managementGroups/{managementGroupId}/providers/Microsoft.Authorization/policySetDefinitions/{policySetDefinitionName}"} # type: ignore @distributed_trace - def list_built_in( - self, - filter: Optional[str] = None, - top: Optional[int] = None, - **kwargs: Any - ) -> Iterable["_models.PolicyDefinitionListResult"]: - """Retrieve built-in policy definitions. + def get_at_management_group( + self, policy_set_definition_name: str, management_group_id: str, **kwargs: Any + ) -> _models.PolicySetDefinition: + """Retrieves a policy set definition. - This operation retrieves a list of all the built-in policy definitions that match the optional - given $filter. If $filter='policyType -eq {value}' is provided, the returned list only includes - all built-in policy definitions whose type match the {value}. Possible policyType values are - NotSpecified, BuiltIn, Custom, and Static. If $filter='category -eq {value}' is provided, the - returned list only includes all built-in policy definitions whose category match the {value}. + This operation retrieves the policy set definition in the given management group with the given + name. - :param filter: The filter to apply on the operation. Valid values for $filter are: - 'atExactScope()', 'policyType -eq {value}' or 'category eq '{value}''. If $filter is not - provided, no filtering is performed. If $filter=atExactScope() is provided, the returned list - only includes all policy definitions that at the given scope. If $filter='policyType -eq - {value}' is provided, the returned list only includes all policy definitions whose type match - the {value}. Possible policyType values are NotSpecified, BuiltIn, Custom, and Static. If - $filter='category -eq {value}' is provided, the returned list only includes all policy - definitions whose category match the {value}. Default value is None. - :type filter: str - :param top: Maximum number of records to return. When the $top filter is not provided, it will - return 500 records. Default value is None. - :type top: int - :keyword api_version: Api Version. Default value is "2021-06-01". Note that overriding this - default value may result in unsupported behavior. - :paramtype api_version: str + :param policy_set_definition_name: The name of the policy set definition to get. Required. + :type policy_set_definition_name: str + :param management_group_id: The ID of the management group. Required. + :type management_group_id: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either PolicyDefinitionListResult or the result of - cls(response) - :rtype: - ~azure.core.paging.ItemPaged[~azure.mgmt.resource.policy.v2021_06_01.models.PolicyDefinitionListResult] - :raises: ~azure.core.exceptions.HttpResponseError + :return: PolicySetDefinition or the result of cls(response) + :rtype: ~azure.mgmt.resource.policy.v2021_06_01.models.PolicySetDefinition + :raises ~azure.core.exceptions.HttpResponseError: """ - api_version = kwargs.pop('api_version', "2021-06-01") # type: str - - cls = kwargs.pop('cls', None) # type: ClsType["_models.PolicyDefinitionListResult"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) - def prepare_request(next_link=None): - if not next_link: - - request = build_policy_definitions_list_built_in_request( - api_version=api_version, - filter=filter, - top=top, - template_url=self.list_built_in.metadata['url'], - ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) + error_map.update(kwargs.pop("error_map", {}) or {}) - else: - - request = build_policy_definitions_list_built_in_request( - template_url=next_link, - ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) - request.method = "GET" - return request + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - def extract_data(pipeline_response): - deserialized = self._deserialize("PolicyDefinitionListResult", pipeline_response) - list_of_elem = deserialized.value - if cls: - list_of_elem = cls(list_of_elem) - return deserialized.next_link or None, iter(list_of_elem) + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-06-01")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[_models.PolicySetDefinition] - def get_next(next_link=None): - request = prepare_request(next_link) + request = build_policy_set_definitions_get_at_management_group_request( + policy_set_definition_name=policy_set_definition_name, + management_group_id=management_group_id, + api_version=api_version, + template_url=self.get_at_management_group.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( # pylint: disable=protected-access - request, - stream=False, - **kwargs - ) - response = pipeline_response.http_response + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs + ) - if response.status_code not in [200]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - raise HttpResponseError(response=response, error_format=ARMErrorFormat) + response = pipeline_response.http_response - return pipeline_response + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + deserialized = self._deserialize("PolicySetDefinition", pipeline_response) - return ItemPaged( - get_next, extract_data - ) - list_built_in.metadata = {'url': "/providers/Microsoft.Authorization/policyDefinitions"} # type: ignore + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + + get_at_management_group.metadata = {"url": "/providers/Microsoft.Management/managementGroups/{managementGroupId}/providers/Microsoft.Authorization/policySetDefinitions/{policySetDefinitionName}"} # type: ignore @distributed_trace def list_by_management_group( - self, - management_group_id: str, - filter: Optional[str] = None, - top: Optional[int] = None, - **kwargs: Any - ) -> Iterable["_models.PolicyDefinitionListResult"]: - """Retrieve policy definitions in a management group. + self, management_group_id: str, filter: Optional[str] = None, top: Optional[int] = None, **kwargs: Any + ) -> Iterable["_models.PolicySetDefinition"]: + """Retrieves all policy set definitions in management group. - This operation retrieves a list of all the policy definitions in a given management group that - match the optional given $filter. Valid values for $filter are: 'atExactScope()', 'policyType - -eq {value}' or 'category eq '{value}''. If $filter is not provided, the unfiltered list - includes all policy definitions associated with the management group, including those that - apply directly or from management groups that contain the given management group. If - $filter=atExactScope() is provided, the returned list only includes all policy definitions that - at the given management group. If $filter='policyType -eq {value}' is provided, the returned - list only includes all policy definitions whose type match the {value}. Possible policyType - values are NotSpecified, BuiltIn, Custom, and Static. If $filter='category -eq {value}' is - provided, the returned list only includes all policy definitions whose category match the + This operation retrieves a list of all the policy set definitions in a given management group + that match the optional given $filter. Valid values for $filter are: 'atExactScope()', + 'policyType -eq {value}' or 'category eq '{value}''. If $filter is not provided, the unfiltered + list includes all policy set definitions associated with the management group, including those + that apply directly or from management groups that contain the given management group. If + $filter=atExactScope() is provided, the returned list only includes all policy set definitions + that at the given management group. If $filter='policyType -eq {value}' is provided, the + returned list only includes all policy set definitions whose type match the {value}. Possible + policyType values are NotSpecified, BuiltIn and Custom. If $filter='category -eq {value}' is + provided, the returned list only includes all policy set definitions whose category match the {value}. - :param management_group_id: The ID of the management group. + :param management_group_id: The ID of the management group. Required. :type management_group_id: str :param filter: The filter to apply on the operation. Valid values for $filter are: 'atExactScope()', 'policyType -eq {value}' or 'category eq '{value}''. If $filter is not provided, no filtering is performed. If $filter=atExactScope() is provided, the returned list - only includes all policy definitions that at the given scope. If $filter='policyType -eq - {value}' is provided, the returned list only includes all policy definitions whose type match - the {value}. Possible policyType values are NotSpecified, BuiltIn, Custom, and Static. If - $filter='category -eq {value}' is provided, the returned list only includes all policy + only includes all policy set definitions that at the given scope. If $filter='policyType -eq + {value}' is provided, the returned list only includes all policy set definitions whose type + match the {value}. Possible policyType values are NotSpecified, BuiltIn, Custom, and Static. If + $filter='category -eq {value}' is provided, the returned list only includes all policy set definitions whose category match the {value}. Default value is None. :type filter: str :param top: Maximum number of records to return. When the $top filter is not provided, it will return 500 records. Default value is None. :type top: int - :keyword api_version: Api Version. Default value is "2021-06-01". Note that overriding this - default value may result in unsupported behavior. - :paramtype api_version: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either PolicyDefinitionListResult or the result of - cls(response) + :return: An iterator like instance of either PolicySetDefinition or the result of cls(response) :rtype: - ~azure.core.paging.ItemPaged[~azure.mgmt.resource.policy.v2021_06_01.models.PolicyDefinitionListResult] - :raises: ~azure.core.exceptions.HttpResponseError + ~azure.core.paging.ItemPaged[~azure.mgmt.resource.policy.v2021_06_01.models.PolicySetDefinition] + :raises ~azure.core.exceptions.HttpResponseError: """ - api_version = kwargs.pop('api_version', "2021-06-01") # type: str + _headers = 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: str + cls = kwargs.pop("cls", None) # type: ClsType[_models.PolicySetDefinitionListResult] - cls = kwargs.pop('cls', None) # type: ClsType["_models.PolicyDefinitionListResult"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) + def prepare_request(next_link=None): if not next_link: - - request = build_policy_definitions_list_by_management_group_request( + + request = build_policy_set_definitions_list_by_management_group_request( management_group_id=management_group_id, - api_version=api_version, filter=filter, top=top, - template_url=self.list_by_management_group.metadata['url'], + api_version=api_version, + template_url=self.list_by_management_group.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore else: - - request = build_policy_definitions_list_by_management_group_request( - management_group_id=management_group_id, - template_url=next_link, - ) + request = HttpRequest("GET", next_link) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore request.method = "GET" return request def extract_data(pipeline_response): - deserialized = self._deserialize("PolicyDefinitionListResult", pipeline_response) + deserialized = self._deserialize("PolicySetDefinitionListResult", pipeline_response) list_of_elem = deserialized.value if cls: list_of_elem = cls(list_of_elem) @@ -3493,10 +4971,8 @@ def extract_data(pipeline_response): def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) response = pipeline_response.http_response @@ -3506,84 +4982,240 @@ def get_next(next_link=None): return pipeline_response + return ItemPaged(get_next, extract_data) - return ItemPaged( - get_next, extract_data - ) - list_by_management_group.metadata = {'url': "/providers/Microsoft.Management/managementGroups/{managementGroupId}/providers/Microsoft.Authorization/policyDefinitions"} # type: ignore -class PolicySetDefinitionsOperations(object): - """PolicySetDefinitionsOperations operations. - - You should not instantiate this class directly. Instead, you should create a Client instance that - instantiates it for you and attaches it as an attribute. - - :ivar models: Alias to model classes used in this operation group. - :type models: ~azure.mgmt.resource.policy.v2021_06_01.models - :param client: Client for service requests. - :param config: Configuration of service client. - :param serializer: An object model serializer. - :param deserializer: An object model deserializer. + list_by_management_group.metadata = {"url": "/providers/Microsoft.Management/managementGroups/{managementGroupId}/providers/Microsoft.Authorization/policySetDefinitions"} # type: ignore + + +class PolicyExemptionsOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. + + Instead, you should access the following operations through + :class:`~azure.mgmt.resource.policy.v2021_06_01.PolicyClient`'s + :attr:`policy_exemptions` attribute. """ models = _models - def __init__(self, client, config, serializer, deserializer): - self._client = client - self._serialize = serializer - self._deserialize = deserializer - self._config = config + def __init__(self, *args, **kwargs): + input_args = list(args) + self._client = input_args.pop(0) if input_args else kwargs.pop("client") + self._config = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") @distributed_trace + def delete( # pylint: disable=inconsistent-return-statements + self, scope: str, policy_exemption_name: str, **kwargs: Any + ) -> None: + """Deletes a policy exemption. + + This operation deletes a policy exemption, given its name and the scope it was created in. The + scope of a policy exemption is the part of its ID preceding + '/providers/Microsoft.Authorization/policyExemptions/{policyExemptionName}'. + + :param scope: The scope of the policy exemption. Valid scopes are: management group (format: + '/providers/Microsoft.Management/managementGroups/{managementGroup}'), subscription (format: + '/subscriptions/{subscriptionId}'), resource group (format: + '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}', or resource (format: + '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{resourceProviderNamespace}/[{parentResourcePath}/]{resourceType}/{resourceName}'. + Required. + :type scope: str + :param policy_exemption_name: The name of the policy exemption to delete. Required. + :type policy_exemption_name: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: None or the result of cls(response) + :rtype: None + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2020-07-01-preview")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[None] + + request = build_policy_exemptions_delete_request( + scope=scope, + policy_exemption_name=policy_exemption_name, + api_version=api_version, + template_url=self.delete.metadata["url"], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore + + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [200, 204]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + if cls: + return cls(pipeline_response, None, {}) + + delete.metadata = {"url": "/{scope}/providers/Microsoft.Authorization/policyExemptions/{policyExemptionName}"} # type: ignore + + @overload def create_or_update( self, - policy_set_definition_name: str, - parameters: "_models.PolicySetDefinition", + scope: str, + policy_exemption_name: str, + parameters: _models.PolicyExemption, + *, + content_type: str = "application/json", **kwargs: Any - ) -> "_models.PolicySetDefinition": - """Creates or updates a policy set definition. + ) -> _models.PolicyExemption: + """Creates or updates a policy exemption. - This operation creates or updates a policy set definition in the given subscription with the - given name. + This operation creates or updates a policy exemption with the given scope and name. Policy + exemptions apply to all resources contained within their scope. For example, when you create a + policy exemption at resource group scope for a policy assignment at the same or above level, + the exemption exempts to all applicable resources in the resource group. + + :param scope: The scope of the policy exemption. Valid scopes are: management group (format: + '/providers/Microsoft.Management/managementGroups/{managementGroup}'), subscription (format: + '/subscriptions/{subscriptionId}'), resource group (format: + '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}', or resource (format: + '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{resourceProviderNamespace}/[{parentResourcePath}/]{resourceType}/{resourceName}'. + Required. + :type scope: str + :param policy_exemption_name: The name of the policy exemption to delete. Required. + :type policy_exemption_name: str + :param parameters: Parameters for the policy exemption. Required. + :type parameters: ~azure.mgmt.resource.policy.v2021_06_01.models.PolicyExemption + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: PolicyExemption or the result of cls(response) + :rtype: ~azure.mgmt.resource.policy.v2021_06_01.models.PolicyExemption + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + def create_or_update( + self, + scope: str, + policy_exemption_name: str, + parameters: IO, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.PolicyExemption: + """Creates or updates a policy exemption. + + This operation creates or updates a policy exemption with the given scope and name. Policy + exemptions apply to all resources contained within their scope. For example, when you create a + policy exemption at resource group scope for a policy assignment at the same or above level, + the exemption exempts to all applicable resources in the resource group. + + :param scope: The scope of the policy exemption. Valid scopes are: management group (format: + '/providers/Microsoft.Management/managementGroups/{managementGroup}'), subscription (format: + '/subscriptions/{subscriptionId}'), resource group (format: + '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}', or resource (format: + '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{resourceProviderNamespace}/[{parentResourcePath}/]{resourceType}/{resourceName}'. + Required. + :type scope: str + :param policy_exemption_name: The name of the policy exemption to delete. Required. + :type policy_exemption_name: str + :param parameters: Parameters for the policy exemption. Required. + :type parameters: IO + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: PolicyExemption or the result of cls(response) + :rtype: ~azure.mgmt.resource.policy.v2021_06_01.models.PolicyExemption + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace + def create_or_update( + self, scope: str, policy_exemption_name: str, parameters: Union[_models.PolicyExemption, IO], **kwargs: Any + ) -> _models.PolicyExemption: + """Creates or updates a policy exemption. + + This operation creates or updates a policy exemption with the given scope and name. Policy + exemptions apply to all resources contained within their scope. For example, when you create a + policy exemption at resource group scope for a policy assignment at the same or above level, + the exemption exempts to all applicable resources in the resource group. - :param policy_set_definition_name: The name of the policy set definition to create. - :type policy_set_definition_name: str - :param parameters: The policy set definition properties. - :type parameters: ~azure.mgmt.resource.policy.v2021_06_01.models.PolicySetDefinition - :keyword api_version: Api Version. Default value is "2021-06-01". Note that overriding this - default value may result in unsupported behavior. - :paramtype api_version: str + :param scope: The scope of the policy exemption. Valid scopes are: management group (format: + '/providers/Microsoft.Management/managementGroups/{managementGroup}'), subscription (format: + '/subscriptions/{subscriptionId}'), resource group (format: + '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}', or resource (format: + '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{resourceProviderNamespace}/[{parentResourcePath}/]{resourceType}/{resourceName}'. + Required. + :type scope: str + :param policy_exemption_name: The name of the policy exemption to delete. Required. + :type policy_exemption_name: str + :param parameters: Parameters for the policy exemption. Is either a model type or a IO type. + Required. + :type parameters: ~azure.mgmt.resource.policy.v2021_06_01.models.PolicyExemption or IO + :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. + Default value is None. + :paramtype content_type: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: PolicySetDefinition, or the result of cls(response) - :rtype: ~azure.mgmt.resource.policy.v2021_06_01.models.PolicySetDefinition - :raises: ~azure.core.exceptions.HttpResponseError + :return: PolicyExemption or the result of cls(response) + :rtype: ~azure.mgmt.resource.policy.v2021_06_01.models.PolicyExemption + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.PolicySetDefinition"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) - api_version = kwargs.pop('api_version', "2021-06-01") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - _json = self._serialize.body(parameters, 'PolicySetDefinition') + api_version = kwargs.pop("api_version", _params.pop("api-version", "2020-07-01-preview")) # type: str + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.PolicyExemption] - request = build_policy_set_definitions_create_or_update_request( - policy_set_definition_name=policy_set_definition_name, - subscription_id=self._config.subscription_id, + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(parameters, (IO, bytes)): + _content = parameters + else: + _json = self._serialize.body(parameters, "PolicyExemption") + + request = build_policy_exemptions_create_or_update_request( + scope=scope, + policy_exemption_name=policy_exemption_name, api_version=api_version, content_type=content_type, json=_json, - template_url=self.create_or_update.metadata['url'], + content=_content, + template_url=self.create_or_update.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200, 201]: @@ -3591,267 +5223,375 @@ def create_or_update( raise HttpResponseError(response=response, error_format=ARMErrorFormat) if response.status_code == 200: - deserialized = self._deserialize('PolicySetDefinition', pipeline_response) + deserialized = self._deserialize("PolicyExemption", pipeline_response) if response.status_code == 201: - deserialized = self._deserialize('PolicySetDefinition', pipeline_response) + deserialized = self._deserialize("PolicyExemption", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - create_or_update.metadata = {'url': "/subscriptions/{subscriptionId}/providers/Microsoft.Authorization/policySetDefinitions/{policySetDefinitionName}"} # type: ignore - + create_or_update.metadata = {"url": "/{scope}/providers/Microsoft.Authorization/policyExemptions/{policyExemptionName}"} # type: ignore @distributed_trace - def delete( # pylint: disable=inconsistent-return-statements - self, - policy_set_definition_name: str, - **kwargs: Any - ) -> None: - """Deletes a policy set definition. + def get(self, scope: str, policy_exemption_name: str, **kwargs: Any) -> _models.PolicyExemption: + """Retrieves a policy exemption. - This operation deletes the policy set definition in the given subscription with the given name. + This operation retrieves a single policy exemption, given its name and the scope it was created + at. - :param policy_set_definition_name: The name of the policy set definition to delete. - :type policy_set_definition_name: str - :keyword api_version: Api Version. Default value is "2021-06-01". Note that overriding this - default value may result in unsupported behavior. - :paramtype api_version: str + :param scope: The scope of the policy exemption. Valid scopes are: management group (format: + '/providers/Microsoft.Management/managementGroups/{managementGroup}'), subscription (format: + '/subscriptions/{subscriptionId}'), resource group (format: + '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}', or resource (format: + '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{resourceProviderNamespace}/[{parentResourcePath}/]{resourceType}/{resourceName}'. + Required. + :type scope: str + :param policy_exemption_name: The name of the policy exemption to delete. Required. + :type policy_exemption_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: None, or the result of cls(response) - :rtype: None - :raises: ~azure.core.exceptions.HttpResponseError + :return: PolicyExemption or the result of cls(response) + :rtype: ~azure.mgmt.resource.policy.v2021_06_01.models.PolicyExemption + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType[None] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) - api_version = kwargs.pop('api_version', "2021-06-01") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - request = build_policy_set_definitions_delete_request( - policy_set_definition_name=policy_set_definition_name, - subscription_id=self._config.subscription_id, + api_version = kwargs.pop("api_version", _params.pop("api-version", "2020-07-01-preview")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[_models.PolicyExemption] + + request = build_policy_exemptions_get_request( + scope=scope, + policy_exemption_name=policy_exemption_name, api_version=api_version, - template_url=self.delete.metadata['url'], + template_url=self.get.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response - if response.status_code not in [200, 204]: + if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) + deserialized = self._deserialize("PolicyExemption", pipeline_response) + if cls: - return cls(pipeline_response, None, {}) + return cls(pipeline_response, deserialized, {}) - delete.metadata = {'url': "/subscriptions/{subscriptionId}/providers/Microsoft.Authorization/policySetDefinitions/{policySetDefinitionName}"} # type: ignore + return deserialized + get.metadata = {"url": "/{scope}/providers/Microsoft.Authorization/policyExemptions/{policyExemptionName}"} # type: ignore @distributed_trace - def get( - self, - policy_set_definition_name: str, - **kwargs: Any - ) -> "_models.PolicySetDefinition": - """Retrieves a policy set definition. + def list(self, filter: Optional[str] = None, **kwargs: Any) -> Iterable["_models.PolicyExemption"]: + """Retrieves all policy exemptions that apply to a subscription. - This operation retrieves the policy set definition in the given subscription with the given - name. + This operation retrieves the list of all policy exemptions associated with the given + subscription that match the optional given $filter. Valid values for $filter are: 'atScope()', + 'atExactScope()', 'excludeExpired()' or 'policyAssignmentId eq '{value}''. If $filter is not + provided, the unfiltered list includes all policy exemptions associated with the subscription, + including those that apply directly or from management groups that contain the given + subscription, as well as any applied to objects contained within the subscription. - :param policy_set_definition_name: The name of the policy set definition to get. - :type policy_set_definition_name: str - :keyword api_version: Api Version. Default value is "2021-06-01". Note that overriding this - default value may result in unsupported behavior. - :paramtype api_version: str + :param filter: The filter to apply on the operation. Valid values for $filter are: 'atScope()', + 'atExactScope()', 'excludeExpired()' or 'policyAssignmentId eq '{value}''. If $filter is not + provided, no filtering is performed. If $filter is not provided, the unfiltered list includes + all policy exemptions associated with the scope, including those that apply directly or apply + from containing scopes. If $filter=atScope() is provided, the returned list only includes all + policy exemptions that apply to the scope, which is everything in the unfiltered list except + those applied to sub scopes contained within the given scope. If $filter=atExactScope() is + provided, the returned list only includes all policy exemptions that at the given scope. If + $filter=excludeExpired() is provided, the returned list only includes all policy exemptions + that either haven't expired or didn't set expiration date. If $filter=policyAssignmentId eq + '{value}' is provided. the returned list only includes all policy exemptions that are + associated with the give policyAssignmentId. Default value is None. + :type filter: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: PolicySetDefinition, or the result of cls(response) - :rtype: ~azure.mgmt.resource.policy.v2021_06_01.models.PolicySetDefinition - :raises: ~azure.core.exceptions.HttpResponseError + :return: An iterator like instance of either PolicyExemption or the result of cls(response) + :rtype: + ~azure.core.paging.ItemPaged[~azure.mgmt.resource.policy.v2021_06_01.models.PolicyExemption] + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.PolicySetDefinition"] + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2020-07-01-preview")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[_models.PolicyExemptionListResult] + error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) - api_version = kwargs.pop('api_version', "2021-06-01") # type: str + def prepare_request(next_link=None): + if not next_link: - - request = build_policy_set_definitions_get_request( - policy_set_definition_name=policy_set_definition_name, - subscription_id=self._config.subscription_id, - api_version=api_version, - template_url=self.get.metadata['url'], - ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) + request = build_policy_exemptions_list_request( + subscription_id=self._config.subscription_id, + filter=filter, + 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( # pylint: disable=protected-access - request, - stream=False, - **kwargs - ) - response = pipeline_response.http_response + else: + request = HttpRequest("GET", next_link) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore + request.method = "GET" + return request - if response.status_code not in [200]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - raise HttpResponseError(response=response, error_format=ARMErrorFormat) + def extract_data(pipeline_response): + deserialized = self._deserialize("PolicyExemptionListResult", pipeline_response) + list_of_elem = deserialized.value + if cls: + list_of_elem = cls(list_of_elem) + return deserialized.next_link or None, iter(list_of_elem) - deserialized = self._deserialize('PolicySetDefinition', pipeline_response) + def get_next(next_link=None): + request = prepare_request(next_link) - if cls: - return cls(pipeline_response, deserialized, {}) + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs + ) + response = pipeline_response.http_response - return deserialized + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + return pipeline_response - get.metadata = {'url': "/subscriptions/{subscriptionId}/providers/Microsoft.Authorization/policySetDefinitions/{policySetDefinitionName}"} # type: ignore + return ItemPaged(get_next, extract_data) + list.metadata = {"url": "/subscriptions/{subscriptionId}/providers/Microsoft.Authorization/policyExemptions"} # type: ignore @distributed_trace - def get_built_in( - self, - policy_set_definition_name: str, - **kwargs: Any - ) -> "_models.PolicySetDefinition": - """Retrieves a built in policy set definition. + def list_for_resource_group( + self, resource_group_name: str, filter: Optional[str] = None, **kwargs: Any + ) -> Iterable["_models.PolicyExemption"]: + """Retrieves all policy exemptions that apply to a resource group. - This operation retrieves the built-in policy set definition with the given name. + This operation retrieves the list of all policy exemptions associated with the given resource + group in the given subscription that match the optional given $filter. Valid values for $filter + are: 'atScope()', 'atExactScope()', 'excludeExpired()' or 'policyAssignmentId eq '{value}''. If + $filter is not provided, the unfiltered list includes all policy exemptions associated with the + resource group, including those that apply directly or apply from containing scopes, as well as + any applied to resources contained within the resource group. - :param policy_set_definition_name: The name of the policy set definition to get. - :type policy_set_definition_name: str - :keyword api_version: Api Version. Default value is "2021-06-01". Note that overriding this - default value may result in unsupported behavior. - :paramtype api_version: str + :param resource_group_name: The name of the resource group containing the resource. Required. + :type resource_group_name: str + :param filter: The filter to apply on the operation. Valid values for $filter are: 'atScope()', + 'atExactScope()', 'excludeExpired()' or 'policyAssignmentId eq '{value}''. If $filter is not + provided, no filtering is performed. If $filter is not provided, the unfiltered list includes + all policy exemptions associated with the scope, including those that apply directly or apply + from containing scopes. If $filter=atScope() is provided, the returned list only includes all + policy exemptions that apply to the scope, which is everything in the unfiltered list except + those applied to sub scopes contained within the given scope. If $filter=atExactScope() is + provided, the returned list only includes all policy exemptions that at the given scope. If + $filter=excludeExpired() is provided, the returned list only includes all policy exemptions + that either haven't expired or didn't set expiration date. If $filter=policyAssignmentId eq + '{value}' is provided. the returned list only includes all policy exemptions that are + associated with the give policyAssignmentId. Default value is None. + :type filter: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: PolicySetDefinition, or the result of cls(response) - :rtype: ~azure.mgmt.resource.policy.v2021_06_01.models.PolicySetDefinition - :raises: ~azure.core.exceptions.HttpResponseError + :return: An iterator like instance of either PolicyExemption or the result of cls(response) + :rtype: + ~azure.core.paging.ItemPaged[~azure.mgmt.resource.policy.v2021_06_01.models.PolicyExemption] + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.PolicySetDefinition"] + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2020-07-01-preview")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[_models.PolicyExemptionListResult] + error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) - api_version = kwargs.pop('api_version', "2021-06-01") # type: str + def prepare_request(next_link=None): + if not next_link: - - request = build_policy_set_definitions_get_built_in_request( - policy_set_definition_name=policy_set_definition_name, - api_version=api_version, - template_url=self.get_built_in.metadata['url'], - ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) + request = build_policy_exemptions_list_for_resource_group_request( + resource_group_name=resource_group_name, + subscription_id=self._config.subscription_id, + filter=filter, + api_version=api_version, + template_url=self.list_for_resource_group.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( # pylint: disable=protected-access - request, - stream=False, - **kwargs - ) - response = pipeline_response.http_response + else: + request = HttpRequest("GET", next_link) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore + request.method = "GET" + return request - if response.status_code not in [200]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - raise HttpResponseError(response=response, error_format=ARMErrorFormat) + def extract_data(pipeline_response): + deserialized = self._deserialize("PolicyExemptionListResult", pipeline_response) + list_of_elem = deserialized.value + if cls: + list_of_elem = cls(list_of_elem) + return deserialized.next_link or None, iter(list_of_elem) - deserialized = self._deserialize('PolicySetDefinition', pipeline_response) + def get_next(next_link=None): + request = prepare_request(next_link) - if cls: - return cls(pipeline_response, deserialized, {}) + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs + ) + response = pipeline_response.http_response - return deserialized + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + return pipeline_response - get_built_in.metadata = {'url': "/providers/Microsoft.Authorization/policySetDefinitions/{policySetDefinitionName}"} # type: ignore + return ItemPaged(get_next, extract_data) + list_for_resource_group.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Authorization/policyExemptions"} # type: ignore @distributed_trace - def list( + def list_for_resource( self, + resource_group_name: str, + resource_provider_namespace: str, + parent_resource_path: str, + resource_type: str, + resource_name: str, filter: Optional[str] = None, - top: Optional[int] = None, **kwargs: Any - ) -> Iterable["_models.PolicySetDefinitionListResult"]: - """Retrieves the policy set definitions for a subscription. + ) -> Iterable["_models.PolicyExemption"]: + """Retrieves all policy exemptions that apply to a resource. - This operation retrieves a list of all the policy set definitions in a given subscription that - match the optional given $filter. Valid values for $filter are: 'atExactScope()', 'policyType - -eq {value}' or 'category eq '{value}''. If $filter is not provided, the unfiltered list - includes all policy set definitions associated with the subscription, including those that - apply directly or from management groups that contain the given subscription. If - $filter=atExactScope() is provided, the returned list only includes all policy set definitions - that at the given subscription. If $filter='policyType -eq {value}' is provided, the returned - list only includes all policy set definitions whose type match the {value}. Possible policyType - values are NotSpecified, BuiltIn and Custom. If $filter='category -eq {value}' is provided, the - returned list only includes all policy set definitions whose category match the {value}. + This operation retrieves the list of all policy exemptions associated with the specified + resource in the given resource group and subscription that match the optional given $filter. + Valid values for $filter are: 'atScope()', 'atExactScope()', 'excludeExpired()' or + 'policyAssignmentId eq '{value}''. If $filter is not provided, the unfiltered list includes all + policy exemptions associated with the resource, including those that apply directly or from all + containing scopes, as well as any applied to resources contained within the resource. Three + parameters plus the resource name are used to identify a specific resource. If the resource is + not part of a parent resource (the more common case), the parent resource path should not be + provided (or provided as ''). For example a web app could be specified as + ({resourceProviderNamespace} == 'Microsoft.Web', {parentResourcePath} == '', {resourceType} == + 'sites', {resourceName} == 'MyWebApp'). If the resource is part of a parent resource, then all + parameters should be provided. For example a virtual machine DNS name could be specified as + ({resourceProviderNamespace} == 'Microsoft.Compute', {parentResourcePath} == + 'virtualMachines/MyVirtualMachine', {resourceType} == 'domainNames', {resourceName} == + 'MyComputerName'). A convenient alternative to providing the namespace and type name separately + is to provide both in the {resourceType} parameter, format: ({resourceProviderNamespace} == '', + {parentResourcePath} == '', {resourceType} == 'Microsoft.Web/sites', {resourceName} == + 'MyWebApp'). - :param filter: The filter to apply on the operation. Valid values for $filter are: - 'atExactScope()', 'policyType -eq {value}' or 'category eq '{value}''. If $filter is not - provided, no filtering is performed. If $filter=atExactScope() is provided, the returned list - only includes all policy set definitions that at the given scope. If $filter='policyType -eq - {value}' is provided, the returned list only includes all policy set definitions whose type - match the {value}. Possible policyType values are NotSpecified, BuiltIn, Custom, and Static. If - $filter='category -eq {value}' is provided, the returned list only includes all policy set - definitions whose category match the {value}. Default value is None. + :param resource_group_name: The name of the resource group containing the resource. Required. + :type resource_group_name: str + :param resource_provider_namespace: The namespace of the resource provider. For example, the + namespace of a virtual machine is Microsoft.Compute (from Microsoft.Compute/virtualMachines). + Required. + :type resource_provider_namespace: str + :param parent_resource_path: The parent resource path. Use empty string if there is none. + Required. + :type parent_resource_path: str + :param resource_type: The resource type name. For example the type name of a web app is 'sites' + (from Microsoft.Web/sites). Required. + :type resource_type: str + :param resource_name: The name of the resource. Required. + :type resource_name: str + :param filter: The filter to apply on the operation. Valid values for $filter are: 'atScope()', + 'atExactScope()', 'excludeExpired()' or 'policyAssignmentId eq '{value}''. If $filter is not + provided, no filtering is performed. If $filter is not provided, the unfiltered list includes + all policy exemptions associated with the scope, including those that apply directly or apply + from containing scopes. If $filter=atScope() is provided, the returned list only includes all + policy exemptions that apply to the scope, which is everything in the unfiltered list except + those applied to sub scopes contained within the given scope. If $filter=atExactScope() is + provided, the returned list only includes all policy exemptions that at the given scope. If + $filter=excludeExpired() is provided, the returned list only includes all policy exemptions + that either haven't expired or didn't set expiration date. If $filter=policyAssignmentId eq + '{value}' is provided. the returned list only includes all policy exemptions that are + associated with the give policyAssignmentId. Default value is None. :type filter: str - :param top: Maximum number of records to return. When the $top filter is not provided, it will - return 500 records. Default value is None. - :type top: int - :keyword api_version: Api Version. Default value is "2021-06-01". Note that overriding this - default value may result in unsupported behavior. - :paramtype api_version: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either PolicySetDefinitionListResult or the result of - cls(response) + :return: An iterator like instance of either PolicyExemption or the result of cls(response) :rtype: - ~azure.core.paging.ItemPaged[~azure.mgmt.resource.policy.v2021_06_01.models.PolicySetDefinitionListResult] - :raises: ~azure.core.exceptions.HttpResponseError + ~azure.core.paging.ItemPaged[~azure.mgmt.resource.policy.v2021_06_01.models.PolicyExemption] + :raises ~azure.core.exceptions.HttpResponseError: """ - api_version = kwargs.pop('api_version', "2021-06-01") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2020-07-01-preview")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[_models.PolicyExemptionListResult] - cls = kwargs.pop('cls', None) # type: ClsType["_models.PolicySetDefinitionListResult"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) + def prepare_request(next_link=None): if not next_link: - - request = build_policy_set_definitions_list_request( + + request = build_policy_exemptions_list_for_resource_request( + resource_group_name=resource_group_name, + resource_provider_namespace=resource_provider_namespace, + parent_resource_path=parent_resource_path, + resource_type=resource_type, + resource_name=resource_name, subscription_id=self._config.subscription_id, - api_version=api_version, filter=filter, - top=top, - template_url=self.list.metadata['url'], + api_version=api_version, + template_url=self.list_for_resource.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore else: - - request = build_policy_set_definitions_list_request( - subscription_id=self._config.subscription_id, - template_url=next_link, - ) + request = HttpRequest("GET", next_link) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore request.method = "GET" return request def extract_data(pipeline_response): - deserialized = self._deserialize("PolicySetDefinitionListResult", pipeline_response) + deserialized = self._deserialize("PolicyExemptionListResult", pipeline_response) list_of_elem = deserialized.value if cls: list_of_elem = cls(list_of_elem) @@ -3860,10 +5600,8 @@ def extract_data(pipeline_response): def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) response = pipeline_response.http_response @@ -3873,78 +5611,80 @@ def get_next(next_link=None): return pipeline_response + return ItemPaged(get_next, extract_data) - return ItemPaged( - get_next, extract_data - ) - list.metadata = {'url': "/subscriptions/{subscriptionId}/providers/Microsoft.Authorization/policySetDefinitions"} # type: ignore + list_for_resource.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{parentResourcePath}/{resourceType}/{resourceName}/providers/Microsoft.Authorization/policyExemptions"} # type: ignore @distributed_trace - def list_built_in( - self, - filter: Optional[str] = None, - top: Optional[int] = None, - **kwargs: Any - ) -> Iterable["_models.PolicySetDefinitionListResult"]: - """Retrieves built-in policy set definitions. + def list_for_management_group( + self, management_group_id: str, filter: Optional[str] = None, **kwargs: Any + ) -> Iterable["_models.PolicyExemption"]: + """Retrieves all policy exemptions that apply to a management group. - This operation retrieves a list of all the built-in policy set definitions that match the - optional given $filter. If $filter='category -eq {value}' is provided, the returned list only - includes all built-in policy set definitions whose category match the {value}. + This operation retrieves the list of all policy exemptions applicable to the management group + that match the given $filter. Valid values for $filter are: 'atScope()', 'atExactScope()', + 'excludeExpired()' or 'policyAssignmentId eq '{value}''. If $filter=atScope() is provided, the + returned list includes all policy exemptions that are assigned to the management group or the + management group's ancestors. - :param filter: The filter to apply on the operation. Valid values for $filter are: - 'atExactScope()', 'policyType -eq {value}' or 'category eq '{value}''. If $filter is not - provided, no filtering is performed. If $filter=atExactScope() is provided, the returned list - only includes all policy set definitions that at the given scope. If $filter='policyType -eq - {value}' is provided, the returned list only includes all policy set definitions whose type - match the {value}. Possible policyType values are NotSpecified, BuiltIn, Custom, and Static. If - $filter='category -eq {value}' is provided, the returned list only includes all policy set - definitions whose category match the {value}. Default value is None. + :param management_group_id: The ID of the management group. Required. + :type management_group_id: str + :param filter: The filter to apply on the operation. Valid values for $filter are: 'atScope()', + 'atExactScope()', 'excludeExpired()' or 'policyAssignmentId eq '{value}''. If $filter is not + provided, no filtering is performed. If $filter is not provided, the unfiltered list includes + all policy exemptions associated with the scope, including those that apply directly or apply + from containing scopes. If $filter=atScope() is provided, the returned list only includes all + policy exemptions that apply to the scope, which is everything in the unfiltered list except + those applied to sub scopes contained within the given scope. If $filter=atExactScope() is + provided, the returned list only includes all policy exemptions that at the given scope. If + $filter=excludeExpired() is provided, the returned list only includes all policy exemptions + that either haven't expired or didn't set expiration date. If $filter=policyAssignmentId eq + '{value}' is provided. the returned list only includes all policy exemptions that are + associated with the give policyAssignmentId. Default value is None. :type filter: str - :param top: Maximum number of records to return. When the $top filter is not provided, it will - return 500 records. Default value is None. - :type top: int - :keyword api_version: Api Version. Default value is "2021-06-01". Note that overriding this - default value may result in unsupported behavior. - :paramtype api_version: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either PolicySetDefinitionListResult or the result of - cls(response) + :return: An iterator like instance of either PolicyExemption or the result of cls(response) :rtype: - ~azure.core.paging.ItemPaged[~azure.mgmt.resource.policy.v2021_06_01.models.PolicySetDefinitionListResult] - :raises: ~azure.core.exceptions.HttpResponseError + ~azure.core.paging.ItemPaged[~azure.mgmt.resource.policy.v2021_06_01.models.PolicyExemption] + :raises ~azure.core.exceptions.HttpResponseError: """ - api_version = kwargs.pop('api_version', "2021-06-01") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2020-07-01-preview")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[_models.PolicyExemptionListResult] - cls = kwargs.pop('cls', None) # type: ClsType["_models.PolicySetDefinitionListResult"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) + def prepare_request(next_link=None): if not next_link: - - request = build_policy_set_definitions_list_built_in_request( - api_version=api_version, + + request = build_policy_exemptions_list_for_management_group_request( + management_group_id=management_group_id, filter=filter, - top=top, - template_url=self.list_built_in.metadata['url'], + api_version=api_version, + template_url=self.list_for_management_group.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore else: - - request = build_policy_set_definitions_list_built_in_request( - template_url=next_link, - ) + request = HttpRequest("GET", next_link) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore request.method = "GET" return request def extract_data(pipeline_response): - deserialized = self._deserialize("PolicySetDefinitionListResult", pipeline_response) + deserialized = self._deserialize("PolicyExemptionListResult", pipeline_response) list_of_elem = deserialized.value if cls: list_of_elem = cls(list_of_elem) @@ -3953,10 +5693,8 @@ def extract_data(pipeline_response): def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) response = pipeline_response.http_response @@ -3966,66 +5704,191 @@ def get_next(next_link=None): return pipeline_response + return ItemPaged(get_next, extract_data) + + list_for_management_group.metadata = {"url": "/providers/Microsoft.Management/managementGroups/{managementGroupId}/providers/Microsoft.Authorization/policyExemptions"} # type: ignore - return ItemPaged( - get_next, extract_data - ) - list_built_in.metadata = {'url': "/providers/Microsoft.Authorization/policySetDefinitions"} # type: ignore + +class VariablesOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. + + Instead, you should access the following operations through + :class:`~azure.mgmt.resource.policy.v2021_06_01.PolicyClient`'s + :attr:`variables` attribute. + """ + + models = _models + + def __init__(self, *args, **kwargs): + input_args = list(args) + self._client = input_args.pop(0) if input_args else kwargs.pop("client") + self._config = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") @distributed_trace - def create_or_update_at_management_group( - self, - policy_set_definition_name: str, - management_group_id: str, - parameters: "_models.PolicySetDefinition", - **kwargs: Any - ) -> "_models.PolicySetDefinition": - """Creates or updates a policy set definition. + def delete(self, variable_name: str, **kwargs: Any) -> None: # pylint: disable=inconsistent-return-statements + """Deletes a variable. - This operation creates or updates a policy set definition in the given management group with - the given name. + This operation deletes a variable, given its name and the subscription it was created in. The + scope of a variable is the part of its ID preceding + '/providers/Microsoft.Authorization/variables/{variableName}'. - :param policy_set_definition_name: The name of the policy set definition to create. - :type policy_set_definition_name: str - :param management_group_id: The ID of the management group. - :type management_group_id: str - :param parameters: The policy set definition properties. - :type parameters: ~azure.mgmt.resource.policy.v2021_06_01.models.PolicySetDefinition - :keyword api_version: Api Version. Default value is "2021-06-01". Note that overriding this - default value may result in unsupported behavior. - :paramtype api_version: str + :param variable_name: The name of the variable to operate on. Required. + :type variable_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: PolicySetDefinition, or the result of cls(response) - :rtype: ~azure.mgmt.resource.policy.v2021_06_01.models.PolicySetDefinition - :raises: ~azure.core.exceptions.HttpResponseError + :return: None or the result of cls(response) + :rtype: None + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.PolicySetDefinition"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) - api_version = kwargs.pop('api_version', "2021-06-01") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - _json = self._serialize.body(parameters, 'PolicySetDefinition') + api_version = kwargs.pop("api_version", _params.pop("api-version", "2022-08-01-preview")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[None] - request = build_policy_set_definitions_create_or_update_at_management_group_request( - policy_set_definition_name=policy_set_definition_name, - management_group_id=management_group_id, + request = build_variables_delete_request( + variable_name=variable_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + template_url=self.delete.metadata["url"], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore + + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [200, 204]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + if cls: + return cls(pipeline_response, None, {}) + + delete.metadata = {"url": "/subscriptions/{subscriptionId}/providers/Microsoft.Authorization/variables/{variableName}"} # type: ignore + + @overload + def create_or_update( + self, variable_name: str, parameters: _models.Variable, *, content_type: str = "application/json", **kwargs: Any + ) -> _models.Variable: + """Creates or updates a variable. + + This operation creates or updates a variable with the given subscription and name. Policy + variables can only be used by a policy definition at the scope they are created or below. + + :param variable_name: The name of the variable to operate on. Required. + :type variable_name: str + :param parameters: Parameters for the variable. Required. + :type parameters: ~azure.mgmt.resource.policy.v2021_06_01.models.Variable + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: Variable or the result of cls(response) + :rtype: ~azure.mgmt.resource.policy.v2021_06_01.models.Variable + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + def create_or_update( + self, variable_name: str, parameters: IO, *, content_type: str = "application/json", **kwargs: Any + ) -> _models.Variable: + """Creates or updates a variable. + + This operation creates or updates a variable with the given subscription and name. Policy + variables can only be used by a policy definition at the scope they are created or below. + + :param variable_name: The name of the variable to operate on. Required. + :type variable_name: str + :param parameters: Parameters for the variable. Required. + :type parameters: IO + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: Variable or the result of cls(response) + :rtype: ~azure.mgmt.resource.policy.v2021_06_01.models.Variable + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace + def create_or_update( + self, variable_name: str, parameters: Union[_models.Variable, IO], **kwargs: Any + ) -> _models.Variable: + """Creates or updates a variable. + + This operation creates or updates a variable with the given subscription and name. Policy + variables can only be used by a policy definition at the scope they are created or below. + + :param variable_name: The name of the variable to operate on. Required. + :type variable_name: str + :param parameters: Parameters for the variable. Is either a model type or a IO type. Required. + :type parameters: ~azure.mgmt.resource.policy.v2021_06_01.models.Variable or IO + :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. + Default value is None. + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: Variable or the result of cls(response) + :rtype: ~azure.mgmt.resource.policy.v2021_06_01.models.Variable + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2022-08-01-preview")) # type: str + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.Variable] + + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(parameters, (IO, bytes)): + _content = parameters + else: + _json = self._serialize.body(parameters, "Variable") + + request = build_variables_create_or_update_request( + variable_name=variable_name, + subscription_id=self._config.subscription_id, api_version=api_version, content_type=content_type, json=_json, - template_url=self.create_or_update_at_management_group.metadata['url'], + content=_content, + template_url=self.create_or_update.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200, 201]: @@ -4033,66 +5896,124 @@ def create_or_update_at_management_group( raise HttpResponseError(response=response, error_format=ARMErrorFormat) if response.status_code == 200: - deserialized = self._deserialize('PolicySetDefinition', pipeline_response) + deserialized = self._deserialize("Variable", pipeline_response) if response.status_code == 201: - deserialized = self._deserialize('PolicySetDefinition', pipeline_response) + deserialized = self._deserialize("Variable", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - create_or_update_at_management_group.metadata = {'url': "/providers/Microsoft.Management/managementGroups/{managementGroupId}/providers/Microsoft.Authorization/policySetDefinitions/{policySetDefinitionName}"} # type: ignore + create_or_update.metadata = {"url": "/subscriptions/{subscriptionId}/providers/Microsoft.Authorization/variables/{variableName}"} # type: ignore + + @distributed_trace + def get(self, variable_name: str, **kwargs: Any) -> _models.Variable: + """Retrieves a variable. + + This operation retrieves a single variable, given its name and the subscription it was created + at. + + :param variable_name: The name of the variable to operate on. Required. + :type variable_name: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: Variable or the result of cls(response) + :rtype: ~azure.mgmt.resource.policy.v2021_06_01.models.Variable + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2022-08-01-preview")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[_models.Variable] + + request = build_variables_get_request( + variable_name=variable_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + template_url=self.get.metadata["url"], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore + + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + deserialized = self._deserialize("Variable", pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + return deserialized + + get.metadata = {"url": "/subscriptions/{subscriptionId}/providers/Microsoft.Authorization/variables/{variableName}"} # type: ignore @distributed_trace def delete_at_management_group( # pylint: disable=inconsistent-return-statements - self, - policy_set_definition_name: str, - management_group_id: str, - **kwargs: Any + self, management_group_id: str, variable_name: str, **kwargs: Any ) -> None: - """Deletes a policy set definition. + """Deletes a variable. - This operation deletes the policy set definition in the given management group with the given - name. + This operation deletes a variable, given its name and the management group it was created in. + The scope of a variable is the part of its ID preceding + '/providers/Microsoft.Authorization/variables/{variableName}'. - :param policy_set_definition_name: The name of the policy set definition to delete. - :type policy_set_definition_name: str - :param management_group_id: The ID of the management group. + :param management_group_id: The ID of the management group. Required. :type management_group_id: str - :keyword api_version: Api Version. Default value is "2021-06-01". Note that overriding this - default value may result in unsupported behavior. - :paramtype api_version: str + :param variable_name: The name of the variable to operate on. Required. + :type variable_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: None, or the result of cls(response) + :return: None or the result of cls(response) :rtype: None - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType[None] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) - api_version = kwargs.pop('api_version', "2021-06-01") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - request = build_policy_set_definitions_delete_at_management_group_request( - policy_set_definition_name=policy_set_definition_name, + api_version = kwargs.pop("api_version", _params.pop("api-version", "2022-08-01-preview")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[None] + + request = build_variables_delete_at_management_group_request( management_group_id=management_group_id, + variable_name=variable_name, api_version=api_version, - template_url=self.delete_at_management_group.metadata['url'], + template_url=self.delete_at_management_group.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200, 204]: @@ -4102,151 +6023,330 @@ def delete_at_management_group( # pylint: disable=inconsistent-return-statement if cls: return cls(pipeline_response, None, {}) - delete_at_management_group.metadata = {'url': "/providers/Microsoft.Management/managementGroups/{managementGroupId}/providers/Microsoft.Authorization/policySetDefinitions/{policySetDefinitionName}"} # type: ignore + delete_at_management_group.metadata = {"url": "/providers/Microsoft.Management/managementGroups/{managementGroupId}/providers/Microsoft.Authorization/variables/{variableName}"} # type: ignore + + @overload + def create_or_update_at_management_group( + self, + management_group_id: str, + variable_name: str, + parameters: _models.Variable, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.Variable: + """Creates or updates a variable. + + This operation creates or updates a variable with the given management group and name. Policy + variables can only be used by a policy definition at the scope they are created or below. + :param management_group_id: The ID of the management group. Required. + :type management_group_id: str + :param variable_name: The name of the variable to operate on. Required. + :type variable_name: str + :param parameters: Parameters for the variable. Required. + :type parameters: ~azure.mgmt.resource.policy.v2021_06_01.models.Variable + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: Variable or the result of cls(response) + :rtype: ~azure.mgmt.resource.policy.v2021_06_01.models.Variable + :raises ~azure.core.exceptions.HttpResponseError: + """ - @distributed_trace - def get_at_management_group( + @overload + def create_or_update_at_management_group( self, - policy_set_definition_name: str, management_group_id: str, + variable_name: str, + parameters: IO, + *, + content_type: str = "application/json", **kwargs: Any - ) -> "_models.PolicySetDefinition": - """Retrieves a policy set definition. + ) -> _models.Variable: + """Creates or updates a variable. - This operation retrieves the policy set definition in the given management group with the given - name. + This operation creates or updates a variable with the given management group and name. Policy + variables can only be used by a policy definition at the scope they are created or below. - :param policy_set_definition_name: The name of the policy set definition to get. - :type policy_set_definition_name: str - :param management_group_id: The ID of the management group. + :param management_group_id: The ID of the management group. Required. :type management_group_id: str - :keyword api_version: Api Version. Default value is "2021-06-01". Note that overriding this - default value may result in unsupported behavior. - :paramtype api_version: str + :param variable_name: The name of the variable to operate on. Required. + :type variable_name: str + :param parameters: Parameters for the variable. Required. + :type parameters: IO + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: PolicySetDefinition, or the result of cls(response) - :rtype: ~azure.mgmt.resource.policy.v2021_06_01.models.PolicySetDefinition - :raises: ~azure.core.exceptions.HttpResponseError + :return: Variable or the result of cls(response) + :rtype: ~azure.mgmt.resource.policy.v2021_06_01.models.Variable + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace + def create_or_update_at_management_group( + self, management_group_id: str, variable_name: str, parameters: Union[_models.Variable, IO], **kwargs: Any + ) -> _models.Variable: + """Creates or updates a variable. + + This operation creates or updates a variable with the given management group and name. Policy + variables can only be used by a policy definition at the scope they are created or below. + + :param management_group_id: The ID of the management group. Required. + :type management_group_id: str + :param variable_name: The name of the variable to operate on. Required. + :type variable_name: str + :param parameters: Parameters for the variable. Is either a model type or a IO type. Required. + :type parameters: ~azure.mgmt.resource.policy.v2021_06_01.models.Variable or IO + :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. + Default value is None. + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: Variable or the result of cls(response) + :rtype: ~azure.mgmt.resource.policy.v2021_06_01.models.Variable + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.PolicySetDefinition"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) - api_version = kwargs.pop('api_version', "2021-06-01") # type: str + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - request = build_policy_set_definitions_get_at_management_group_request( - policy_set_definition_name=policy_set_definition_name, + api_version = kwargs.pop("api_version", _params.pop("api-version", "2022-08-01-preview")) # type: str + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.Variable] + + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(parameters, (IO, bytes)): + _content = parameters + else: + _json = self._serialize.body(parameters, "Variable") + + request = build_variables_create_or_update_at_management_group_request( + management_group_id=management_group_id, + variable_name=variable_name, + api_version=api_version, + content_type=content_type, + json=_json, + content=_content, + template_url=self.create_or_update_at_management_group.metadata["url"], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore + + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [200, 201]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + if response.status_code == 200: + deserialized = self._deserialize("Variable", pipeline_response) + + if response.status_code == 201: + deserialized = self._deserialize("Variable", pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + + create_or_update_at_management_group.metadata = {"url": "/providers/Microsoft.Management/managementGroups/{managementGroupId}/providers/Microsoft.Authorization/variables/{variableName}"} # type: ignore + + @distributed_trace + def get_at_management_group(self, management_group_id: str, variable_name: str, **kwargs: Any) -> _models.Variable: + """Retrieves a variable. + + This operation retrieves a single variable, given its name and the management group it was + created at. + + :param management_group_id: The ID of the management group. Required. + :type management_group_id: str + :param variable_name: The name of the variable to operate on. Required. + :type variable_name: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: Variable or the result of cls(response) + :rtype: ~azure.mgmt.resource.policy.v2021_06_01.models.Variable + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2022-08-01-preview")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[_models.Variable] + + request = build_variables_get_at_management_group_request( management_group_id=management_group_id, + variable_name=variable_name, api_version=api_version, - template_url=self.get_at_management_group.metadata['url'], + template_url=self.get_at_management_group.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) - deserialized = self._deserialize('PolicySetDefinition', pipeline_response) + deserialized = self._deserialize("Variable", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - get_at_management_group.metadata = {'url': "/providers/Microsoft.Management/managementGroups/{managementGroupId}/providers/Microsoft.Authorization/policySetDefinitions/{policySetDefinitionName}"} # type: ignore + get_at_management_group.metadata = {"url": "/providers/Microsoft.Management/managementGroups/{managementGroupId}/providers/Microsoft.Authorization/variables/{variableName}"} # type: ignore + + @distributed_trace + def list(self, **kwargs: Any) -> Iterable["_models.Variable"]: + """Retrieves all variables that are at this subscription level. + + This operation retrieves the list of all variables associated with the given subscription. + + :keyword callable cls: A custom type or function that will be passed the direct response + :return: An iterator like instance of either Variable or the result of cls(response) + :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.resource.policy.v2021_06_01.models.Variable] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2022-08-01-preview")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[_models.VariableListResult] + + error_map = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + def prepare_request(next_link=None): + if not next_link: + + request = build_variables_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 + + else: + request = HttpRequest("GET", next_link) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore + request.method = "GET" + return request + + def extract_data(pipeline_response): + deserialized = self._deserialize("VariableListResult", pipeline_response) + list_of_elem = deserialized.value + if cls: + list_of_elem = cls(list_of_elem) + 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 + ) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + return pipeline_response + + return ItemPaged(get_next, extract_data) + list.metadata = {"url": "/subscriptions/{subscriptionId}/providers/Microsoft.Authorization/variables"} # type: ignore @distributed_trace - def list_by_management_group( - self, - management_group_id: str, - filter: Optional[str] = None, - top: Optional[int] = None, - **kwargs: Any - ) -> Iterable["_models.PolicySetDefinitionListResult"]: - """Retrieves all policy set definitions in management group. + def list_for_management_group(self, management_group_id: str, **kwargs: Any) -> Iterable["_models.Variable"]: + """Retrieves all variables that are at this management group level. - This operation retrieves a list of all the policy set definitions in a given management group - that match the optional given $filter. Valid values for $filter are: 'atExactScope()', - 'policyType -eq {value}' or 'category eq '{value}''. If $filter is not provided, the unfiltered - list includes all policy set definitions associated with the management group, including those - that apply directly or from management groups that contain the given management group. If - $filter=atExactScope() is provided, the returned list only includes all policy set definitions - that at the given management group. If $filter='policyType -eq {value}' is provided, the - returned list only includes all policy set definitions whose type match the {value}. Possible - policyType values are NotSpecified, BuiltIn and Custom. If $filter='category -eq {value}' is - provided, the returned list only includes all policy set definitions whose category match the - {value}. + This operation retrieves the list of all variables applicable to the management group. - :param management_group_id: The ID of the management group. + :param management_group_id: The ID of the management group. Required. :type management_group_id: str - :param filter: The filter to apply on the operation. Valid values for $filter are: - 'atExactScope()', 'policyType -eq {value}' or 'category eq '{value}''. If $filter is not - provided, no filtering is performed. If $filter=atExactScope() is provided, the returned list - only includes all policy set definitions that at the given scope. If $filter='policyType -eq - {value}' is provided, the returned list only includes all policy set definitions whose type - match the {value}. Possible policyType values are NotSpecified, BuiltIn, Custom, and Static. If - $filter='category -eq {value}' is provided, the returned list only includes all policy set - definitions whose category match the {value}. Default value is None. - :type filter: str - :param top: Maximum number of records to return. When the $top filter is not provided, it will - return 500 records. Default value is None. - :type top: int - :keyword api_version: Api Version. Default value is "2021-06-01". Note that overriding this - default value may result in unsupported behavior. - :paramtype api_version: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either PolicySetDefinitionListResult or the result of - cls(response) - :rtype: - ~azure.core.paging.ItemPaged[~azure.mgmt.resource.policy.v2021_06_01.models.PolicySetDefinitionListResult] - :raises: ~azure.core.exceptions.HttpResponseError + :return: An iterator like instance of either Variable or the result of cls(response) + :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.resource.policy.v2021_06_01.models.Variable] + :raises ~azure.core.exceptions.HttpResponseError: """ - api_version = kwargs.pop('api_version', "2021-06-01") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2022-08-01-preview")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[_models.VariableListResult] - cls = kwargs.pop('cls', None) # type: ClsType["_models.PolicySetDefinitionListResult"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) + def prepare_request(next_link=None): if not next_link: - - request = build_policy_set_definitions_list_by_management_group_request( + + request = build_variables_list_for_management_group_request( management_group_id=management_group_id, api_version=api_version, - filter=filter, - top=top, - template_url=self.list_by_management_group.metadata['url'], + template_url=self.list_for_management_group.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore else: - - request = build_policy_set_definitions_list_by_management_group_request( - management_group_id=management_group_id, - template_url=next_link, - ) + request = HttpRequest("GET", next_link) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore request.method = "GET" return request def extract_data(pipeline_response): - deserialized = self._deserialize("PolicySetDefinitionListResult", pipeline_response) + deserialized = self._deserialize("VariableListResult", pipeline_response) list_of_elem = deserialized.value if cls: list_of_elem = cls(list_of_elem) @@ -4255,10 +6355,8 @@ def extract_data(pipeline_response): def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) response = pipeline_response.http_response @@ -4268,85 +6366,79 @@ def get_next(next_link=None): return pipeline_response + return ItemPaged(get_next, extract_data) - return ItemPaged( - get_next, extract_data - ) - list_by_management_group.metadata = {'url': "/providers/Microsoft.Management/managementGroups/{managementGroupId}/providers/Microsoft.Authorization/policySetDefinitions"} # type: ignore -class PolicyExemptionsOperations(object): - """PolicyExemptionsOperations operations. - - You should not instantiate this class directly. Instead, you should create a Client instance that - instantiates it for you and attaches it as an attribute. - - :ivar models: Alias to model classes used in this operation group. - :type models: ~azure.mgmt.resource.policy.v2021_06_01.models - :param client: Client for service requests. - :param config: Configuration of service client. - :param serializer: An object model serializer. - :param deserializer: An object model deserializer. + list_for_management_group.metadata = {"url": "/providers/Microsoft.Management/managementGroups/{managementGroupId}/providers/Microsoft.Authorization/variables"} # type: ignore + + +class VariableValuesOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. + + Instead, you should access the following operations through + :class:`~azure.mgmt.resource.policy.v2021_06_01.PolicyClient`'s + :attr:`variable_values` attribute. """ models = _models - def __init__(self, client, config, serializer, deserializer): - self._client = client - self._serialize = serializer - self._deserialize = deserializer - self._config = config + def __init__(self, *args, **kwargs): + input_args = list(args) + self._client = input_args.pop(0) if input_args else kwargs.pop("client") + self._config = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") @distributed_trace def delete( # pylint: disable=inconsistent-return-statements - self, - scope: str, - policy_exemption_name: str, - **kwargs: Any + self, variable_name: str, variable_value_name: str, **kwargs: Any ) -> None: - """Deletes a policy exemption. + """Deletes a variable value. - This operation deletes a policy exemption, given its name and the scope it was created in. The - scope of a policy exemption is the part of its ID preceding - '/providers/Microsoft.Authorization/policyExemptions/{policyExemptionName}'. + This operation deletes a variable value, given its name, the subscription it was created in, + and the variable it belongs to. The scope of a variable value is the part of its ID preceding + '/providers/Microsoft.Authorization/variables/{variableName}'. - :param scope: The scope of the policy exemption. Valid scopes are: management group (format: - '/providers/Microsoft.Management/managementGroups/{managementGroup}'), subscription (format: - '/subscriptions/{subscriptionId}'), resource group (format: - '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}', or resource (format: - '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{resourceProviderNamespace}/[{parentResourcePath}/]{resourceType}/{resourceName}'. - :type scope: str - :param policy_exemption_name: The name of the policy exemption to delete. - :type policy_exemption_name: str - :keyword api_version: Api Version. Default value is "2020-07-01-preview". Note that overriding - this default value may result in unsupported behavior. - :paramtype api_version: str + :param variable_name: The name of the variable to operate on. Required. + :type variable_name: str + :param variable_value_name: The name of the variable value to operate on. Required. + :type variable_value_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: None, or the result of cls(response) + :return: None or the result of cls(response) :rtype: None - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType[None] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) - api_version = kwargs.pop('api_version', "2020-07-01-preview") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - request = build_policy_exemptions_delete_request( - scope=scope, - policy_exemption_name=policy_exemption_name, + api_version = kwargs.pop("api_version", _params.pop("api-version", "2022-08-01-preview")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[None] + + request = build_variable_values_delete_request( + variable_name=variable_name, + variable_value_name=variable_value_name, + subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.delete.metadata['url'], + template_url=self.delete.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200, 204]: @@ -4356,69 +6448,134 @@ def delete( # pylint: disable=inconsistent-return-statements if cls: return cls(pipeline_response, None, {}) - delete.metadata = {'url': "/{scope}/providers/Microsoft.Authorization/policyExemptions/{policyExemptionName}"} # type: ignore - + delete.metadata = {"url": "/subscriptions/{subscriptionId}/providers/Microsoft.Authorization/variables/{variableName}/values/{variableValueName}"} # type: ignore - @distributed_trace + @overload def create_or_update( self, - scope: str, - policy_exemption_name: str, - parameters: "_models.PolicyExemption", + variable_name: str, + variable_value_name: str, + parameters: _models.VariableValue, + *, + content_type: str = "application/json", **kwargs: Any - ) -> "_models.PolicyExemption": - """Creates or updates a policy exemption. + ) -> _models.VariableValue: + """Creates or updates a variable value. + + This operation creates or updates a variable value with the given subscription and name for a + given variable. Variable values are scoped to the variable for which they are created for. + + :param variable_name: The name of the variable to operate on. Required. + :type variable_name: str + :param variable_value_name: The name of the variable value to operate on. Required. + :type variable_value_name: str + :param parameters: Parameters for the variable value. Required. + :type parameters: ~azure.mgmt.resource.policy.v2021_06_01.models.VariableValue + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: VariableValue or the result of cls(response) + :rtype: ~azure.mgmt.resource.policy.v2021_06_01.models.VariableValue + :raises ~azure.core.exceptions.HttpResponseError: + """ - This operation creates or updates a policy exemption with the given scope and name. Policy - exemptions apply to all resources contained within their scope. For example, when you create a - policy exemption at resource group scope for a policy assignment at the same or above level, - the exemption exempts to all applicable resources in the resource group. + @overload + def create_or_update( + self, + variable_name: str, + variable_value_name: str, + parameters: IO, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.VariableValue: + """Creates or updates a variable value. + + This operation creates or updates a variable value with the given subscription and name for a + given variable. Variable values are scoped to the variable for which they are created for. + + :param variable_name: The name of the variable to operate on. Required. + :type variable_name: str + :param variable_value_name: The name of the variable value to operate on. Required. + :type variable_value_name: str + :param parameters: Parameters for the variable value. Required. + :type parameters: IO + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: VariableValue or the result of cls(response) + :rtype: ~azure.mgmt.resource.policy.v2021_06_01.models.VariableValue + :raises ~azure.core.exceptions.HttpResponseError: + """ - :param scope: The scope of the policy exemption. Valid scopes are: management group (format: - '/providers/Microsoft.Management/managementGroups/{managementGroup}'), subscription (format: - '/subscriptions/{subscriptionId}'), resource group (format: - '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}', or resource (format: - '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{resourceProviderNamespace}/[{parentResourcePath}/]{resourceType}/{resourceName}'. - :type scope: str - :param policy_exemption_name: The name of the policy exemption to delete. - :type policy_exemption_name: str - :param parameters: Parameters for the policy exemption. - :type parameters: ~azure.mgmt.resource.policy.v2021_06_01.models.PolicyExemption - :keyword api_version: Api Version. Default value is "2020-07-01-preview". Note that overriding - this default value may result in unsupported behavior. - :paramtype api_version: str + @distributed_trace + def create_or_update( + self, variable_name: str, variable_value_name: str, parameters: Union[_models.VariableValue, IO], **kwargs: Any + ) -> _models.VariableValue: + """Creates or updates a variable value. + + This operation creates or updates a variable value with the given subscription and name for a + given variable. Variable values are scoped to the variable for which they are created for. + + :param variable_name: The name of the variable to operate on. Required. + :type variable_name: str + :param variable_value_name: The name of the variable value to operate on. Required. + :type variable_value_name: str + :param parameters: Parameters for the variable value. Is either a model type or a IO type. + Required. + :type parameters: ~azure.mgmt.resource.policy.v2021_06_01.models.VariableValue or IO + :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. + Default value is None. + :paramtype content_type: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: PolicyExemption, or the result of cls(response) - :rtype: ~azure.mgmt.resource.policy.v2021_06_01.models.PolicyExemption - :raises: ~azure.core.exceptions.HttpResponseError + :return: VariableValue or the result of cls(response) + :rtype: ~azure.mgmt.resource.policy.v2021_06_01.models.VariableValue + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.PolicyExemption"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) - - api_version = kwargs.pop('api_version', "2020-07-01-preview") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] - - _json = self._serialize.body(parameters, 'PolicyExemption') - - request = build_policy_exemptions_create_or_update_request( - scope=scope, - policy_exemption_name=policy_exemption_name, + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2022-08-01-preview")) # type: str + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.VariableValue] + + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(parameters, (IO, bytes)): + _content = parameters + else: + _json = self._serialize.body(parameters, "VariableValue") + + request = build_variable_values_create_or_update_request( + variable_name=variable_name, + variable_value_name=variable_value_name, + subscription_id=self._config.subscription_id, api_version=api_version, content_type=content_type, json=_json, - template_url=self.create_or_update.metadata['url'], + content=_content, + template_url=self.create_or_update.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200, 201]: @@ -4426,258 +6583,131 @@ def create_or_update( raise HttpResponseError(response=response, error_format=ARMErrorFormat) if response.status_code == 200: - deserialized = self._deserialize('PolicyExemption', pipeline_response) + deserialized = self._deserialize("VariableValue", pipeline_response) if response.status_code == 201: - deserialized = self._deserialize('PolicyExemption', pipeline_response) + deserialized = self._deserialize("VariableValue", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - create_or_update.metadata = {'url': "/{scope}/providers/Microsoft.Authorization/policyExemptions/{policyExemptionName}"} # type: ignore - + create_or_update.metadata = {"url": "/subscriptions/{subscriptionId}/providers/Microsoft.Authorization/variables/{variableName}/values/{variableValueName}"} # type: ignore @distributed_trace - def get( - self, - scope: str, - policy_exemption_name: str, - **kwargs: Any - ) -> "_models.PolicyExemption": - """Retrieves a policy exemption. + def get(self, variable_name: str, variable_value_name: str, **kwargs: Any) -> _models.VariableValue: + """Retrieves a variable value. - This operation retrieves a single policy exemption, given its name and the scope it was created - at. + This operation retrieves a single variable value; given its name, subscription it was created + at and the variable it's created for. - :param scope: The scope of the policy exemption. Valid scopes are: management group (format: - '/providers/Microsoft.Management/managementGroups/{managementGroup}'), subscription (format: - '/subscriptions/{subscriptionId}'), resource group (format: - '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}', or resource (format: - '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{resourceProviderNamespace}/[{parentResourcePath}/]{resourceType}/{resourceName}'. - :type scope: str - :param policy_exemption_name: The name of the policy exemption to delete. - :type policy_exemption_name: str - :keyword api_version: Api Version. Default value is "2020-07-01-preview". Note that overriding - this default value may result in unsupported behavior. - :paramtype api_version: str + :param variable_name: The name of the variable to operate on. Required. + :type variable_name: str + :param variable_value_name: The name of the variable value to operate on. Required. + :type variable_value_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: PolicyExemption, or the result of cls(response) - :rtype: ~azure.mgmt.resource.policy.v2021_06_01.models.PolicyExemption - :raises: ~azure.core.exceptions.HttpResponseError + :return: VariableValue or the result of cls(response) + :rtype: ~azure.mgmt.resource.policy.v2021_06_01.models.VariableValue + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.PolicyExemption"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) - api_version = kwargs.pop('api_version', "2020-07-01-preview") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - request = build_policy_exemptions_get_request( - scope=scope, - policy_exemption_name=policy_exemption_name, + api_version = kwargs.pop("api_version", _params.pop("api-version", "2022-08-01-preview")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[_models.VariableValue] + + request = build_variable_values_get_request( + variable_name=variable_name, + variable_value_name=variable_value_name, + subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.get.metadata['url'], + template_url=self.get.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) - deserialized = self._deserialize('PolicyExemption', pipeline_response) + deserialized = self._deserialize("VariableValue", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - get.metadata = {'url': "/{scope}/providers/Microsoft.Authorization/policyExemptions/{policyExemptionName}"} # type: ignore - - - @distributed_trace - def list( - self, - filter: Optional[str] = None, - **kwargs: Any - ) -> Iterable["_models.PolicyExemptionListResult"]: - """Retrieves all policy exemptions that apply to a subscription. - - This operation retrieves the list of all policy exemptions associated with the given - subscription that match the optional given $filter. Valid values for $filter are: 'atScope()', - 'atExactScope()', 'excludeExpired()' or 'policyAssignmentId eq '{value}''. If $filter is not - provided, the unfiltered list includes all policy exemptions associated with the subscription, - including those that apply directly or from management groups that contain the given - subscription, as well as any applied to objects contained within the subscription. - - :param filter: The filter to apply on the operation. Valid values for $filter are: 'atScope()', - 'atExactScope()', 'excludeExpired()' or 'policyAssignmentId eq '{value}''. If $filter is not - provided, no filtering is performed. If $filter is not provided, the unfiltered list includes - all policy exemptions associated with the scope, including those that apply directly or apply - from containing scopes. If $filter=atScope() is provided, the returned list only includes all - policy exemptions that apply to the scope, which is everything in the unfiltered list except - those applied to sub scopes contained within the given scope. If $filter=atExactScope() is - provided, the returned list only includes all policy exemptions that at the given scope. If - $filter=excludeExpired() is provided, the returned list only includes all policy exemptions - that either haven't expired or didn't set expiration date. If $filter=policyAssignmentId eq - '{value}' is provided. the returned list only includes all policy exemptions that are - associated with the give policyAssignmentId. Default value is None. - :type filter: str - :keyword api_version: Api Version. Default value is "2020-07-01-preview". Note that overriding - this default value may result in unsupported behavior. - :paramtype api_version: str - :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either PolicyExemptionListResult or the result of - cls(response) - :rtype: - ~azure.core.paging.ItemPaged[~azure.mgmt.resource.policy.v2021_06_01.models.PolicyExemptionListResult] - :raises: ~azure.core.exceptions.HttpResponseError - """ - api_version = kwargs.pop('api_version', "2020-07-01-preview") # type: str - - cls = kwargs.pop('cls', None) # type: ClsType["_models.PolicyExemptionListResult"] - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {})) - def prepare_request(next_link=None): - if not next_link: - - request = build_policy_exemptions_list_request( - subscription_id=self._config.subscription_id, - api_version=api_version, - filter=filter, - template_url=self.list.metadata['url'], - ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) - - else: - - request = build_policy_exemptions_list_request( - subscription_id=self._config.subscription_id, - template_url=next_link, - ) - 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("PolicyExemptionListResult", pipeline_response) - list_of_elem = deserialized.value - if cls: - list_of_elem = cls(list_of_elem) - 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( # pylint: disable=protected-access - request, - stream=False, - **kwargs - ) - response = pipeline_response.http_response - - if response.status_code not in [200]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - raise HttpResponseError(response=response, error_format=ARMErrorFormat) - - return pipeline_response - - - return ItemPaged( - get_next, extract_data - ) - list.metadata = {'url': "/subscriptions/{subscriptionId}/providers/Microsoft.Authorization/policyExemptions"} # type: ignore - - @distributed_trace - def list_for_resource_group( - self, - resource_group_name: str, - filter: Optional[str] = None, - **kwargs: Any - ) -> Iterable["_models.PolicyExemptionListResult"]: - """Retrieves all policy exemptions that apply to a resource group. - - This operation retrieves the list of all policy exemptions associated with the given resource - group in the given subscription that match the optional given $filter. Valid values for $filter - are: 'atScope()', 'atExactScope()', 'excludeExpired()' or 'policyAssignmentId eq '{value}''. If - $filter is not provided, the unfiltered list includes all policy exemptions associated with the - resource group, including those that apply directly or apply from containing scopes, as well as - any applied to resources contained within the resource group. + get.metadata = {"url": "/subscriptions/{subscriptionId}/providers/Microsoft.Authorization/variables/{variableName}/values/{variableValueName}"} # type: ignore - :param resource_group_name: The name of the resource group containing the resource. - :type resource_group_name: str - :param filter: The filter to apply on the operation. Valid values for $filter are: 'atScope()', - 'atExactScope()', 'excludeExpired()' or 'policyAssignmentId eq '{value}''. If $filter is not - provided, no filtering is performed. If $filter is not provided, the unfiltered list includes - all policy exemptions associated with the scope, including those that apply directly or apply - from containing scopes. If $filter=atScope() is provided, the returned list only includes all - policy exemptions that apply to the scope, which is everything in the unfiltered list except - those applied to sub scopes contained within the given scope. If $filter=atExactScope() is - provided, the returned list only includes all policy exemptions that at the given scope. If - $filter=excludeExpired() is provided, the returned list only includes all policy exemptions - that either haven't expired or didn't set expiration date. If $filter=policyAssignmentId eq - '{value}' is provided. the returned list only includes all policy exemptions that are - associated with the give policyAssignmentId. Default value is None. - :type filter: str - :keyword api_version: Api Version. Default value is "2020-07-01-preview". Note that overriding - this default value may result in unsupported behavior. - :paramtype api_version: str + @distributed_trace + def list(self, variable_name: str, **kwargs: Any) -> Iterable["_models.VariableValue"]: + """List variable values for a variable. + + This operation retrieves the list of all variable values associated with the given variable + that is at a subscription level. + + :param variable_name: The name of the variable to operate on. Required. + :type variable_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either PolicyExemptionListResult or the result of - cls(response) + :return: An iterator like instance of either VariableValue or the result of cls(response) :rtype: - ~azure.core.paging.ItemPaged[~azure.mgmt.resource.policy.v2021_06_01.models.PolicyExemptionListResult] - :raises: ~azure.core.exceptions.HttpResponseError + ~azure.core.paging.ItemPaged[~azure.mgmt.resource.policy.v2021_06_01.models.VariableValue] + :raises ~azure.core.exceptions.HttpResponseError: """ - api_version = kwargs.pop('api_version', "2020-07-01-preview") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2022-08-01-preview")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[_models.VariableValueListResult] - cls = kwargs.pop('cls', None) # type: ClsType["_models.PolicyExemptionListResult"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) + def prepare_request(next_link=None): if not next_link: - - request = build_policy_exemptions_list_for_resource_group_request( + + request = build_variable_values_list_request( + variable_name=variable_name, subscription_id=self._config.subscription_id, - resource_group_name=resource_group_name, api_version=api_version, - filter=filter, - template_url=self.list_for_resource_group.metadata['url'], + template_url=self.list.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore else: - - request = build_policy_exemptions_list_for_resource_group_request( - subscription_id=self._config.subscription_id, - resource_group_name=resource_group_name, - template_url=next_link, - ) + request = HttpRequest("GET", next_link) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore request.method = "GET" return request def extract_data(pipeline_response): - deserialized = self._deserialize("PolicyExemptionListResult", pipeline_response) + deserialized = self._deserialize("VariableValueListResult", pipeline_response) list_of_elem = deserialized.value if cls: list_of_elem = cls(list_of_elem) @@ -4686,10 +6716,8 @@ def extract_data(pipeline_response): def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) response = pipeline_response.http_response @@ -4699,121 +6727,66 @@ def get_next(next_link=None): return pipeline_response + return ItemPaged(get_next, extract_data) - return ItemPaged( - get_next, extract_data - ) - list_for_resource_group.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Authorization/policyExemptions"} # type: ignore + list.metadata = {"url": "/subscriptions/{subscriptionId}/providers/Microsoft.Authorization/variables/{variableName}/values"} # type: ignore @distributed_trace - def list_for_resource( - self, - resource_group_name: str, - resource_provider_namespace: str, - parent_resource_path: str, - resource_type: str, - resource_name: str, - filter: Optional[str] = None, - **kwargs: Any - ) -> Iterable["_models.PolicyExemptionListResult"]: - """Retrieves all policy exemptions that apply to a resource. + def list_for_management_group( + self, management_group_id: str, variable_name: str, **kwargs: Any + ) -> Iterable["_models.VariableValue"]: + """List variable values at management group level. - This operation retrieves the list of all policy exemptions associated with the specified - resource in the given resource group and subscription that match the optional given $filter. - Valid values for $filter are: 'atScope()', 'atExactScope()', 'excludeExpired()' or - 'policyAssignmentId eq '{value}''. If $filter is not provided, the unfiltered list includes all - policy exemptions associated with the resource, including those that apply directly or from all - containing scopes, as well as any applied to resources contained within the resource. Three - parameters plus the resource name are used to identify a specific resource. If the resource is - not part of a parent resource (the more common case), the parent resource path should not be - provided (or provided as ''). For example a web app could be specified as - ({resourceProviderNamespace} == 'Microsoft.Web', {parentResourcePath} == '', {resourceType} == - 'sites', {resourceName} == 'MyWebApp'). If the resource is part of a parent resource, then all - parameters should be provided. For example a virtual machine DNS name could be specified as - ({resourceProviderNamespace} == 'Microsoft.Compute', {parentResourcePath} == - 'virtualMachines/MyVirtualMachine', {resourceType} == 'domainNames', {resourceName} == - 'MyComputerName'). A convenient alternative to providing the namespace and type name separately - is to provide both in the {resourceType} parameter, format: ({resourceProviderNamespace} == '', - {parentResourcePath} == '', {resourceType} == 'Microsoft.Web/sites', {resourceName} == - 'MyWebApp'). + This operation retrieves the list of all variable values applicable the variable indicated at + the management group scope. - :param resource_group_name: The name of the resource group containing the resource. - :type resource_group_name: str - :param resource_provider_namespace: The namespace of the resource provider. For example, the - namespace of a virtual machine is Microsoft.Compute (from Microsoft.Compute/virtualMachines). - :type resource_provider_namespace: str - :param parent_resource_path: The parent resource path. Use empty string if there is none. - :type parent_resource_path: str - :param resource_type: The resource type name. For example the type name of a web app is 'sites' - (from Microsoft.Web/sites). - :type resource_type: str - :param resource_name: The name of the resource. - :type resource_name: str - :param filter: The filter to apply on the operation. Valid values for $filter are: 'atScope()', - 'atExactScope()', 'excludeExpired()' or 'policyAssignmentId eq '{value}''. If $filter is not - provided, no filtering is performed. If $filter is not provided, the unfiltered list includes - all policy exemptions associated with the scope, including those that apply directly or apply - from containing scopes. If $filter=atScope() is provided, the returned list only includes all - policy exemptions that apply to the scope, which is everything in the unfiltered list except - those applied to sub scopes contained within the given scope. If $filter=atExactScope() is - provided, the returned list only includes all policy exemptions that at the given scope. If - $filter=excludeExpired() is provided, the returned list only includes all policy exemptions - that either haven't expired or didn't set expiration date. If $filter=policyAssignmentId eq - '{value}' is provided. the returned list only includes all policy exemptions that are - associated with the give policyAssignmentId. Default value is None. - :type filter: str - :keyword api_version: Api Version. Default value is "2020-07-01-preview". Note that overriding - this default value may result in unsupported behavior. - :paramtype api_version: str + :param management_group_id: The ID of the management group. Required. + :type management_group_id: str + :param variable_name: The name of the variable to operate on. Required. + :type variable_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either PolicyExemptionListResult or the result of - cls(response) + :return: An iterator like instance of either VariableValue or the result of cls(response) :rtype: - ~azure.core.paging.ItemPaged[~azure.mgmt.resource.policy.v2021_06_01.models.PolicyExemptionListResult] - :raises: ~azure.core.exceptions.HttpResponseError + ~azure.core.paging.ItemPaged[~azure.mgmt.resource.policy.v2021_06_01.models.VariableValue] + :raises ~azure.core.exceptions.HttpResponseError: """ - api_version = kwargs.pop('api_version', "2020-07-01-preview") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2022-08-01-preview")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[_models.VariableValueListResult] - cls = kwargs.pop('cls', None) # type: ClsType["_models.PolicyExemptionListResult"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) + def prepare_request(next_link=None): if not next_link: - - request = build_policy_exemptions_list_for_resource_request( - subscription_id=self._config.subscription_id, - resource_group_name=resource_group_name, - resource_provider_namespace=resource_provider_namespace, - parent_resource_path=parent_resource_path, - resource_type=resource_type, - resource_name=resource_name, + + request = build_variable_values_list_for_management_group_request( + management_group_id=management_group_id, + variable_name=variable_name, api_version=api_version, - filter=filter, - template_url=self.list_for_resource.metadata['url'], + template_url=self.list_for_management_group.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore else: - - request = build_policy_exemptions_list_for_resource_request( - subscription_id=self._config.subscription_id, - resource_group_name=resource_group_name, - resource_provider_namespace=resource_provider_namespace, - parent_resource_path=parent_resource_path, - resource_type=resource_type, - resource_name=resource_name, - template_url=next_link, - ) + request = HttpRequest("GET", next_link) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore request.method = "GET" return request def extract_data(pipeline_response): - deserialized = self._deserialize("PolicyExemptionListResult", pipeline_response) + deserialized = self._deserialize("VariableValueListResult", pipeline_response) list_of_elem = deserialized.value if cls: list_of_elem = cls(list_of_elem) @@ -4822,10 +6795,8 @@ def extract_data(pipeline_response): def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) response = pipeline_response.http_response @@ -4835,107 +6806,291 @@ def get_next(next_link=None): return pipeline_response + return ItemPaged(get_next, extract_data) - return ItemPaged( - get_next, extract_data - ) - list_for_resource.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{parentResourcePath}/{resourceType}/{resourceName}/providers/Microsoft.Authorization/policyExemptions"} # type: ignore + list_for_management_group.metadata = {"url": "/providers/Microsoft.Management/managementGroups/{managementGroupId}/providers/Microsoft.Authorization/variables/{variableName}/values"} # type: ignore @distributed_trace - def list_for_management_group( + def delete_at_management_group( # pylint: disable=inconsistent-return-statements + self, management_group_id: str, variable_name: str, variable_value_name: str, **kwargs: Any + ) -> None: + """Deletes a variable value. + + This operation deletes a variable value, given its name, the management group it was created + in, and the variable it belongs to. The scope of a variable value is the part of its ID + preceding '/providers/Microsoft.Authorization/variables/{variableName}'. + + :param management_group_id: The ID of the management group. Required. + :type management_group_id: str + :param variable_name: The name of the variable to operate on. Required. + :type variable_name: str + :param variable_value_name: The name of the variable value to operate on. Required. + :type variable_value_name: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: None or the result of cls(response) + :rtype: None + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2022-08-01-preview")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[None] + + request = build_variable_values_delete_at_management_group_request( + management_group_id=management_group_id, + variable_name=variable_name, + variable_value_name=variable_value_name, + api_version=api_version, + template_url=self.delete_at_management_group.metadata["url"], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore + + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [200, 204]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + if cls: + return cls(pipeline_response, None, {}) + + delete_at_management_group.metadata = {"url": "/providers/Microsoft.Management/managementGroups/{managementGroupId}/providers/Microsoft.Authorization/variables/{variableName}/values/{variableValueName}"} # type: ignore + + @overload + def create_or_update_at_management_group( self, management_group_id: str, - filter: Optional[str] = None, + variable_name: str, + variable_value_name: str, + parameters: _models.VariableValue, + *, + content_type: str = "application/json", **kwargs: Any - ) -> Iterable["_models.PolicyExemptionListResult"]: - """Retrieves all policy exemptions that apply to a management group. + ) -> _models.VariableValue: + """Creates or updates a variable value. - This operation retrieves the list of all policy exemptions applicable to the management group - that match the given $filter. Valid values for $filter are: 'atScope()', 'atExactScope()', - 'excludeExpired()' or 'policyAssignmentId eq '{value}''. If $filter=atScope() is provided, the - returned list includes all policy exemptions that are assigned to the management group or the - management group's ancestors. + This operation creates or updates a variable value with the given management group and name for + a given variable. Variable values are scoped to the variable for which they are created for. - :param management_group_id: The ID of the management group. + :param management_group_id: The ID of the management group. Required. :type management_group_id: str - :param filter: The filter to apply on the operation. Valid values for $filter are: 'atScope()', - 'atExactScope()', 'excludeExpired()' or 'policyAssignmentId eq '{value}''. If $filter is not - provided, no filtering is performed. If $filter is not provided, the unfiltered list includes - all policy exemptions associated with the scope, including those that apply directly or apply - from containing scopes. If $filter=atScope() is provided, the returned list only includes all - policy exemptions that apply to the scope, which is everything in the unfiltered list except - those applied to sub scopes contained within the given scope. If $filter=atExactScope() is - provided, the returned list only includes all policy exemptions that at the given scope. If - $filter=excludeExpired() is provided, the returned list only includes all policy exemptions - that either haven't expired or didn't set expiration date. If $filter=policyAssignmentId eq - '{value}' is provided. the returned list only includes all policy exemptions that are - associated with the give policyAssignmentId. Default value is None. - :type filter: str - :keyword api_version: Api Version. Default value is "2020-07-01-preview". Note that overriding - this default value may result in unsupported behavior. - :paramtype api_version: str + :param variable_name: The name of the variable to operate on. Required. + :type variable_name: str + :param variable_value_name: The name of the variable value to operate on. Required. + :type variable_value_name: str + :param parameters: Parameters for the variable value. Required. + :type parameters: ~azure.mgmt.resource.policy.v2021_06_01.models.VariableValue + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either PolicyExemptionListResult or the result of - cls(response) - :rtype: - ~azure.core.paging.ItemPaged[~azure.mgmt.resource.policy.v2021_06_01.models.PolicyExemptionListResult] - :raises: ~azure.core.exceptions.HttpResponseError + :return: VariableValue or the result of cls(response) + :rtype: ~azure.mgmt.resource.policy.v2021_06_01.models.VariableValue + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + def create_or_update_at_management_group( + self, + management_group_id: str, + variable_name: str, + variable_value_name: str, + parameters: IO, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.VariableValue: + """Creates or updates a variable value. + + This operation creates or updates a variable value with the given management group and name for + a given variable. Variable values are scoped to the variable for which they are created for. + + :param management_group_id: The ID of the management group. Required. + :type management_group_id: str + :param variable_name: The name of the variable to operate on. Required. + :type variable_name: str + :param variable_value_name: The name of the variable value to operate on. Required. + :type variable_value_name: str + :param parameters: Parameters for the variable value. Required. + :type parameters: IO + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: VariableValue or the result of cls(response) + :rtype: ~azure.mgmt.resource.policy.v2021_06_01.models.VariableValue + :raises ~azure.core.exceptions.HttpResponseError: """ - api_version = kwargs.pop('api_version', "2020-07-01-preview") # type: str - cls = kwargs.pop('cls', None) # type: ClsType["_models.PolicyExemptionListResult"] + @distributed_trace + def create_or_update_at_management_group( + self, + management_group_id: str, + variable_name: str, + variable_value_name: str, + parameters: Union[_models.VariableValue, IO], + **kwargs: Any + ) -> _models.VariableValue: + """Creates or updates a variable value. + + This operation creates or updates a variable value with the given management group and name for + a given variable. Variable values are scoped to the variable for which they are created for. + + :param management_group_id: The ID of the management group. Required. + :type management_group_id: str + :param variable_name: The name of the variable to operate on. Required. + :type variable_name: str + :param variable_value_name: The name of the variable value to operate on. Required. + :type variable_value_name: str + :param parameters: Parameters for the variable value. Is either a model type or a IO type. + Required. + :type parameters: ~azure.mgmt.resource.policy.v2021_06_01.models.VariableValue or IO + :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. + Default value is None. + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: VariableValue or the result of cls(response) + :rtype: ~azure.mgmt.resource.policy.v2021_06_01.models.VariableValue + :raises ~azure.core.exceptions.HttpResponseError: + """ error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) - def prepare_request(next_link=None): - if not next_link: - - request = build_policy_exemptions_list_for_management_group_request( - management_group_id=management_group_id, - api_version=api_version, - filter=filter, - template_url=self.list_for_management_group.metadata['url'], - ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) + error_map.update(kwargs.pop("error_map", {}) or {}) - else: - - request = build_policy_exemptions_list_for_management_group_request( - management_group_id=management_group_id, - template_url=next_link, - ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) - request.method = "GET" - return request + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - def extract_data(pipeline_response): - deserialized = self._deserialize("PolicyExemptionListResult", pipeline_response) - list_of_elem = deserialized.value - if cls: - list_of_elem = cls(list_of_elem) - return deserialized.next_link or None, iter(list_of_elem) + api_version = kwargs.pop("api_version", _params.pop("api-version", "2022-08-01-preview")) # type: str + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.VariableValue] - def get_next(next_link=None): - request = prepare_request(next_link) + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(parameters, (IO, bytes)): + _content = parameters + else: + _json = self._serialize.body(parameters, "VariableValue") - pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs - ) - response = pipeline_response.http_response + request = build_variable_values_create_or_update_at_management_group_request( + management_group_id=management_group_id, + variable_name=variable_name, + variable_value_name=variable_value_name, + api_version=api_version, + content_type=content_type, + json=_json, + content=_content, + template_url=self.create_or_update_at_management_group.metadata["url"], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore - if response.status_code not in [200]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - raise HttpResponseError(response=response, error_format=ARMErrorFormat) + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs + ) - return pipeline_response + response = pipeline_response.http_response + + if response.status_code not in [200, 201]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + if response.status_code == 200: + deserialized = self._deserialize("VariableValue", pipeline_response) + + if response.status_code == 201: + deserialized = self._deserialize("VariableValue", pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + return deserialized + + create_or_update_at_management_group.metadata = {"url": "/providers/Microsoft.Management/managementGroups/{managementGroupId}/providers/Microsoft.Authorization/variables/{variableName}/values/{variableValueName}"} # type: ignore + + @distributed_trace + def get_at_management_group( + self, management_group_id: str, variable_name: str, variable_value_name: str, **kwargs: Any + ) -> _models.VariableValue: + """Retrieves a variable value. + + This operation retrieves a single variable value; given its name, management group it was + created at and the variable it's created for. + + :param management_group_id: The ID of the management group. Required. + :type management_group_id: str + :param variable_name: The name of the variable to operate on. Required. + :type variable_name: str + :param variable_value_name: The name of the variable value to operate on. Required. + :type variable_value_name: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: VariableValue or the result of cls(response) + :rtype: ~azure.mgmt.resource.policy.v2021_06_01.models.VariableValue + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2022-08-01-preview")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[_models.VariableValue] + + request = build_variable_values_get_at_management_group_request( + management_group_id=management_group_id, + variable_name=variable_name, + variable_value_name=variable_value_name, + api_version=api_version, + template_url=self.get_at_management_group.metadata["url"], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore - return ItemPaged( - get_next, extract_data + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) - list_for_management_group.metadata = {'url': "/providers/Microsoft.Management/managementGroups/{managementGroupId}/providers/Microsoft.Authorization/policyExemptions"} # type: ignore + + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + deserialized = self._deserialize("VariableValue", pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + + get_at_management_group.metadata = {"url": "/providers/Microsoft.Management/managementGroups/{managementGroupId}/providers/Microsoft.Authorization/variables/{variableName}/values/{variableValueName}"} # type: ignore diff --git a/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/policy/v2021_06_01/operations/_patch.py b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/policy/v2021_06_01/operations/_patch.py new file mode 100644 index 0000000000000..f7dd32510333d --- /dev/null +++ b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/policy/v2021_06_01/operations/_patch.py @@ -0,0 +1,20 @@ +# ------------------------------------ +# Copyright (c) Microsoft Corporation. +# Licensed under the MIT License. +# ------------------------------------ +"""Customize generated code here. + +Follow our quickstart for examples: https://aka.ms/azsdk/python/dpcodegen/python/customize +""" +from typing import List + +__all__: List[str] = [] # Add all objects you want publicly available to users at this package level + + +def patch_sdk(): + """Do not remove from this file. + + `patch_sdk` is a last resort escape hatch that allows you to do customizations + you can't accomplish using the techniques described in + https://aka.ms/azsdk/python/dpcodegen/python/customize + """ diff --git a/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/privatelinks/__init__.py b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/privatelinks/__init__.py index d13d62b308100..a2c58980ab455 100644 --- a/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/privatelinks/__init__.py +++ b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/privatelinks/__init__.py @@ -14,3 +14,7 @@ patch_sdk() except ImportError: pass + +from ._version import VERSION + +__version__ = VERSION diff --git a/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/privatelinks/_configuration.py b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/privatelinks/_configuration.py index 8a1cdcccefd7e..8ecb6f8476768 100644 --- a/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/privatelinks/_configuration.py +++ b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/privatelinks/_configuration.py @@ -8,7 +8,7 @@ # Changes may cause incorrect behavior and will be lost if the code is # regenerated. # -------------------------------------------------------------------------- -from typing import TYPE_CHECKING +from typing import Any, TYPE_CHECKING from azure.core.configuration import Configuration from azure.core.pipeline import policies @@ -18,8 +18,6 @@ if TYPE_CHECKING: # pylint: disable=unused-import,ungrouped-imports - from typing import Any - from azure.core.credentials import TokenCredential class ResourcePrivateLinkClientConfiguration(Configuration): @@ -28,16 +26,16 @@ class ResourcePrivateLinkClientConfiguration(Configuration): Note that all parameters used to create this instance are saved as instance attributes. - :param credential: Credential needed for the client to connect to Azure. + :param credential: Credential needed for the client to connect to Azure. Required. :type credential: ~azure.core.credentials.TokenCredential - :param subscription_id: The ID of the target subscription. + :param subscription_id: The ID of the target subscription. Required. :type subscription_id: str """ def __init__( self, - credential, # type: "TokenCredential" - subscription_id, # type: str + credential: "TokenCredential", + subscription_id: str, **kwargs # type: Any ): # type: (...) -> None diff --git a/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/privatelinks/_resource_private_link_client.py b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/privatelinks/_resource_private_link_client.py index 919080689e07b..7b56f3fd42e62 100644 --- a/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/privatelinks/_resource_private_link_client.py +++ b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/privatelinks/_resource_private_link_client.py @@ -9,20 +9,17 @@ # regenerated. # -------------------------------------------------------------------------- -from typing import TYPE_CHECKING - -from msrest import Deserializer, Serializer +from typing import Any, Optional, TYPE_CHECKING from azure.mgmt.core import ARMPipelineClient from azure.profiles import KnownProfiles, ProfileDefinition from azure.profiles.multiapiclient import MultiApiClientMixin from ._configuration import ResourcePrivateLinkClientConfiguration +from ._serialization import Deserializer, Serializer if TYPE_CHECKING: # pylint: disable=unused-import,ungrouped-imports - from typing import Any, Optional - from azure.core.credentials import TokenCredential class _SDKClient(object): @@ -43,9 +40,9 @@ class ResourcePrivateLinkClient(MultiApiClientMixin, _SDKClient): The api-version parameter sets the default API version if the operation group is not described in the profile. - :param credential: Credential needed for the client to connect to Azure. + :param credential: Credential needed for the client to connect to Azure. Required. :type credential: ~azure.core.credentials.TokenCredential - :param subscription_id: The ID of the target subscription. + :param subscription_id: The ID of the target subscription. Required. :type subscription_id: str :param api_version: API version to use if no profile is provided, or if missing in profile. :type api_version: str @@ -66,10 +63,10 @@ class ResourcePrivateLinkClient(MultiApiClientMixin, _SDKClient): def __init__( self, - credential, # type: "TokenCredential" - subscription_id, # type: str + credential: "TokenCredential", + subscription_id: str, api_version=None, # type: Optional[str] - base_url="https://management.azure.com", # type: str + base_url: str = "https://management.azure.com", profile=KnownProfiles.default, # type: KnownProfiles **kwargs # type: Any ): diff --git a/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/privatelinks/_serialization.py b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/privatelinks/_serialization.py new file mode 100644 index 0000000000000..240df16c57f3c --- /dev/null +++ b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/privatelinks/_serialization.py @@ -0,0 +1,2006 @@ +# -------------------------------------------------------------------------- +# +# Copyright (c) Microsoft Corporation. All rights reserved. +# +# The MIT License (MIT) +# +# Permission is hereby granted, free of charge, to any person obtaining a copy +# of this software and associated documentation files (the ""Software""), to +# deal in the Software without restriction, including without limitation the +# rights to use, copy, modify, merge, publish, distribute, sublicense, and/or +# sell copies of the Software, and to permit persons to whom the Software is +# furnished to do so, subject to the following conditions: +# +# The above copyright notice and this permission notice shall be included in +# all copies or substantial portions of the Software. +# +# THE SOFTWARE IS PROVIDED *AS IS*, WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING +# FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS +# IN THE SOFTWARE. +# +# -------------------------------------------------------------------------- + +# pylint: skip-file + +from base64 import b64decode, b64encode +import calendar +import datetime +import decimal +import email +from enum import Enum +import json +import logging +import re +import sys +import codecs +try: + from urllib import quote # type: ignore +except ImportError: + from urllib.parse import quote # type: ignore +import xml.etree.ElementTree as ET + +import isodate + +from typing import Dict, Any, cast, TYPE_CHECKING + +from azure.core.exceptions import DeserializationError, SerializationError, raise_with_traceback + +_BOM = codecs.BOM_UTF8.decode(encoding='utf-8') + +if TYPE_CHECKING: + from typing import Optional, Union, AnyStr, IO, Mapping + +class RawDeserializer: + + # Accept "text" because we're open minded people... + JSON_REGEXP = re.compile(r'^(application|text)/([a-z+.]+\+)?json$') + + # Name used in context + CONTEXT_NAME = "deserialized_data" + + @classmethod + def deserialize_from_text(cls, data, content_type=None): + # type: (Optional[Union[AnyStr, IO]], Optional[str]) -> Any + """Decode data according to content-type. + + Accept a stream of data as well, but will be load at once in memory for now. + + If no content-type, will return the string version (not bytes, not stream) + + :param data: Input, could be bytes or stream (will be decoded with UTF8) or text + :type data: str or bytes or IO + :param str content_type: The content type. + """ + if hasattr(data, 'read'): + # Assume a stream + data = cast(IO, data).read() + + if isinstance(data, bytes): + data_as_str = data.decode(encoding='utf-8-sig') + else: + # Explain to mypy the correct type. + data_as_str = cast(str, data) + + # Remove Byte Order Mark if present in string + data_as_str = data_as_str.lstrip(_BOM) + + if content_type is None: + return data + + if cls.JSON_REGEXP.match(content_type): + try: + return json.loads(data_as_str) + except ValueError as err: + raise DeserializationError("JSON is invalid: {}".format(err), err) + elif "xml" in (content_type or []): + try: + + try: + if isinstance(data, unicode): # type: ignore + # If I'm Python 2.7 and unicode XML will scream if I try a "fromstring" on unicode string + data_as_str = data_as_str.encode(encoding="utf-8") # type: ignore + except NameError: + pass + + return ET.fromstring(data_as_str) # nosec + except ET.ParseError: + # It might be because the server has an issue, and returned JSON with + # content-type XML.... + # So let's try a JSON load, and if it's still broken + # let's flow the initial exception + def _json_attemp(data): + try: + return True, json.loads(data) + except ValueError: + return False, None # Don't care about this one + success, json_result = _json_attemp(data) + if success: + return json_result + # If i'm here, it's not JSON, it's not XML, let's scream + # and raise the last context in this block (the XML exception) + # The function hack is because Py2.7 messes up with exception + # context otherwise. + _LOGGER.critical("Wasn't XML not JSON, failing") + raise_with_traceback(DeserializationError, "XML is invalid") + 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 + """Deserialize from HTTP response. + + Use bytes and headers to NOT use any requests/aiohttp or whatever + specific implementation. + Headers will tested for "content-type" + """ + # Try to use content-type from headers if available + content_type = None + if 'content-type' in headers: + content_type = headers['content-type'].split(";")[0].strip().lower() + # Ouch, this server did not declare what it sent... + # Let's guess it's JSON... + # Also, since Autorest was considering that an empty body was a valid JSON, + # need that test as well.... + else: + content_type = "application/json" + + if body_bytes: + return cls.deserialize_from_text(body_bytes, content_type) + return None + +try: + basestring # type: ignore + unicode_str = unicode # type: ignore +except NameError: + basestring = str # type: ignore + unicode_str = str # type: ignore + +_LOGGER = logging.getLogger(__name__) + +try: + _long_type = long # type: ignore +except NameError: + _long_type = int + +class UTC(datetime.tzinfo): + """Time Zone info for handling UTC""" + + def utcoffset(self, dt): + """UTF offset for UTC is 0.""" + return datetime.timedelta(0) + + def tzname(self, dt): + """Timestamp representation.""" + return "Z" + + def dst(self, dt): + """No daylight saving for UTC.""" + return datetime.timedelta(hours=1) + +try: + from datetime import timezone as _FixedOffset +except ImportError: # Python 2.7 + class _FixedOffset(datetime.tzinfo): # type: ignore + """Fixed offset in minutes east from UTC. + Copy/pasted from Python doc + :param datetime.timedelta offset: offset in timedelta format + """ + + def __init__(self, offset): + self.__offset = offset + + def utcoffset(self, dt): + return self.__offset + + def tzname(self, dt): + return str(self.__offset.total_seconds()/3600) + + def __repr__(self): + return "".format(self.tzname(None)) + + def dst(self, dt): + return datetime.timedelta(0) + + def __getinitargs__(self): + return (self.__offset,) + +try: + from datetime import timezone + TZ_UTC = timezone.utc # type: ignore +except ImportError: + TZ_UTC = UTC() # type: ignore + +_FLATTEN = re.compile(r"(? y, + "minimum": lambda x, y: x < y, + "maximum": lambda x, y: x > y, + "minimum_ex": lambda x, y: x <= y, + "maximum_ex": lambda x, y: x >= y, + "min_items": lambda x, y: len(x) < y, + "max_items": lambda x, y: len(x) > y, + "pattern": lambda x, y: not re.match(y, x, re.UNICODE), + "unique": lambda x, y: len(x) != len(set(x)), + "multiple": lambda x, y: x % y != 0 + } + + def __init__(self, classes=None): + self.serialize_type = { + 'iso-8601': Serializer.serialize_iso, + 'rfc-1123': Serializer.serialize_rfc, + 'unix-time': Serializer.serialize_unix, + 'duration': Serializer.serialize_duration, + 'date': Serializer.serialize_date, + 'time': Serializer.serialize_time, + 'decimal': Serializer.serialize_decimal, + 'long': Serializer.serialize_long, + 'bytearray': Serializer.serialize_bytearray, + 'base64': Serializer.serialize_base64, + 'object': self.serialize_object, + '[]': self.serialize_iter, + '{}': self.serialize_dict + } + self.dependencies = dict(classes) if classes else {} + self.key_transformer = full_restapi_key_transformer + self.client_side_validation = True + + def _serialize(self, target_obj, data_type=None, **kwargs): + """Serialize data into a string according to type. + + :param target_obj: The data to be serialized. + :param str data_type: The type to be serialized from. + :rtype: str, dict + :raises: SerializationError if serialization fails. + """ + key_transformer = kwargs.get("key_transformer", self.key_transformer) + keep_readonly = kwargs.get("keep_readonly", False) + if target_obj is None: + return None + + attr_name = None + class_name = target_obj.__class__.__name__ + + if data_type: + return self.serialize_data( + target_obj, data_type, **kwargs) + + if not hasattr(target_obj, "_attribute_map"): + data_type = type(target_obj).__name__ + if data_type in self.basic_types.values(): + return self.serialize_data( + target_obj, data_type, **kwargs) + + # Force "is_xml" kwargs if we detect a XML model + try: + is_xml_model_serialization = kwargs["is_xml"] + except KeyError: + is_xml_model_serialization = kwargs.setdefault("is_xml", target_obj.is_xml_model()) + + serialized = {} + if is_xml_model_serialization: + serialized = target_obj._create_xml_node() + try: + attributes = target_obj._attribute_map + for attr, attr_desc in attributes.items(): + attr_name = attr + if not keep_readonly and target_obj._validation.get(attr_name, {}).get('readonly', False): + continue + + if attr_name == "additional_properties" and attr_desc["key"] == '': + if target_obj.additional_properties is not None: + serialized.update(target_obj.additional_properties) + continue + try: + + orig_attr = getattr(target_obj, attr) + if is_xml_model_serialization: + pass # Don't provide "transformer" for XML for now. Keep "orig_attr" + else: # JSON + keys, orig_attr = key_transformer(attr, attr_desc.copy(), orig_attr) + keys = keys if isinstance(keys, list) else [keys] + + + kwargs["serialization_ctxt"] = attr_desc + new_attr = self.serialize_data(orig_attr, attr_desc['type'], **kwargs) + + + if is_xml_model_serialization: + xml_desc = attr_desc.get('xml', {}) + xml_name = xml_desc.get('name', attr_desc['key']) + xml_prefix = xml_desc.get('prefix', None) + xml_ns = xml_desc.get('ns', None) + 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) + continue + if xml_desc.get("text", False): + serialized.text = new_attr + continue + if isinstance(new_attr, list): + serialized.extend(new_attr) + 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', {}): + splitted_tag = new_attr.tag.split("}") + if len(splitted_tag) == 2: # Namespace + new_attr.tag = "}".join([splitted_tag[0], xml_name]) + else: + new_attr.tag = xml_name + serialized.append(new_attr) + 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) + else: # JSON + for k in reversed(keys): + unflattened = {k: new_attr} + new_attr = unflattened + + _new_attr = new_attr + _serialized = serialized + for k in keys: + if k not in _serialized: + _serialized.update(_new_attr) + _new_attr = _new_attr[k] + _serialized = _serialized[k] + except ValueError: + continue + + except (AttributeError, KeyError, TypeError) as err: + msg = "Attribute {} in object {} cannot be serialized.\n{}".format( + attr_name, class_name, str(target_obj)) + raise_with_traceback(SerializationError, msg, err) + else: + return serialized + + def body(self, data, data_type, **kwargs): + """Serialize data intended for a request body. + + :param data: The data to be serialized. + :param str data_type: The type to be serialized from. + :rtype: dict + :raises: SerializationError if serialization fails. + :raises: ValueError if data is None + """ + + # Just in case this is a dict + internal_data_type = data_type.strip('[]{}') + internal_data_type = self.dependencies.get(internal_data_type, None) + try: + is_xml_model_serialization = kwargs["is_xml"] + except KeyError: + if internal_data_type and issubclass(internal_data_type, Model): + is_xml_model_serialization = kwargs.setdefault("is_xml", internal_data_type.is_xml_model()) + else: + is_xml_model_serialization = False + if internal_data_type and not isinstance(internal_data_type, Enum): + try: + deserializer = Deserializer(self.dependencies) + # Since it's on serialization, it's almost sure that format is not JSON REST + # We're not able to deal with additional properties for now. + deserializer.additional_properties_detection = False + if is_xml_model_serialization: + deserializer.key_extractors = [ + attribute_key_case_insensitive_extractor, + ] + else: + deserializer.key_extractors = [ + rest_key_case_insensitive_extractor, + attribute_key_case_insensitive_extractor, + last_rest_key_case_insensitive_extractor + ] + data = deserializer._deserialize(data_type, data) + except DeserializationError as err: + raise_with_traceback( + SerializationError, "Unable to build a model: "+str(err), err) + + return self._serialize(data, data_type, **kwargs) + + def url(self, name, data, data_type, **kwargs): + """Serialize data intended for a URL path. + + :param data: The data to be serialized. + :param str data_type: The type to be serialized from. + :rtype: str + :raises: TypeError if serialization fails. + :raises: ValueError if data is None + """ + try: + output = self.serialize_data(data, data_type, **kwargs) + if data_type == 'bool': + output = json.dumps(output) + + if kwargs.get('skip_quote') is True: + output = str(output) + else: + output = quote(str(output), safe='') + except SerializationError: + raise TypeError("{} must be type {}.".format(name, data_type)) + else: + return output + + def query(self, name, data, data_type, **kwargs): + """Serialize data intended for a URL query. + + :param data: The data to be serialized. + :param str data_type: The type to be serialized from. + :rtype: str + :raises: TypeError if serialization fails. + :raises: ValueError if data is None + """ + try: + # 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)) + + # Not a list, regular serialization + output = self.serialize_data(data, data_type, **kwargs) + if data_type == 'bool': + output = json.dumps(output) + if kwargs.get('skip_quote') is True: + output = str(output) + else: + output = quote(str(output), safe='') + except SerializationError: + raise TypeError("{} must be type {}.".format(name, data_type)) + else: + return str(output) + + def header(self, name, data, data_type, **kwargs): + """Serialize data intended for a request header. + + :param data: The data to be serialized. + :param str data_type: The type to be serialized from. + :rtype: str + :raises: TypeError if serialization fails. + :raises: ValueError if data is None + """ + try: + if data_type in ['[str]']: + data = ["" if d is None else d for d in data] + + output = self.serialize_data(data, data_type, **kwargs) + if data_type == 'bool': + output = json.dumps(output) + except SerializationError: + raise TypeError("{} must be type {}.".format(name, data_type)) + else: + return str(output) + + def serialize_data(self, data, data_type, **kwargs): + """Serialize generic data according to supplied data type. + + :param data: The data to be serialized. + :param str data_type: The type to be serialized from. + :param bool required: Whether it's essential that the data not be + empty or None + :raises: AttributeError if required data is None. + :raises: ValueError if data is None + :raises: SerializationError if serialization fails. + """ + if data is None: + raise ValueError("No value for given attribute") + + try: + if data_type in self.basic_types.values(): + return self.serialize_basic(data, data_type, **kwargs) + + elif data_type in self.serialize_type: + return self.serialize_type[data_type](data, **kwargs) + + # If dependencies is empty, try with current data class + # It has to be a subclass of Enum anyway + enum_type = self.dependencies.get(data_type, data.__class__) + if issubclass(enum_type, Enum): + return Serializer.serialize_enum(data, enum_obj=enum_type) + + iter_type = data_type[0] + data_type[-1] + if iter_type in self.serialize_type: + return self.serialize_type[iter_type]( + data, data_type[1:-1], **kwargs) + + except (ValueError, TypeError) as err: + msg = "Unable to serialize value: {!r} as type: {!r}." + raise_with_traceback( + SerializationError, msg.format(data, data_type), err) + else: + return self._serialize(data, **kwargs) + + @classmethod + def _get_custom_serializers(cls, data_type, **kwargs): + custom_serializer = kwargs.get("basic_types_serializers", {}).get(data_type) + if custom_serializer: + return custom_serializer + if kwargs.get("is_xml", False): + return cls._xml_basic_types_serializers.get(data_type) + + @classmethod + def serialize_basic(cls, data, data_type, **kwargs): + """Serialize basic builting data type. + Serializes objects to str, int, float or bool. + + Possible kwargs: + - basic_types_serializers dict[str, callable] : If set, use the callable as serializer + - is_xml bool : If set, use xml_basic_types_serializers + + :param data: Object to be serialized. + :param str data_type: Type of object in the iterable. + """ + custom_serializer = cls._get_custom_serializers(data_type, **kwargs) + if custom_serializer: + return custom_serializer(data) + if data_type == 'str': + return cls.serialize_unicode(data) + return eval(data_type)(data) # nosec + + @classmethod + def serialize_unicode(cls, data): + """Special handling for serializing unicode strings in Py2. + Encode to UTF-8 if unicode, otherwise handle as a str. + + :param data: Object to be serialized. + :rtype: str + """ + try: # If I received an enum, return its value + return data.value + except AttributeError: + pass + + try: + if isinstance(data, unicode): + # Don't change it, JSON and XML ElementTree are totally able + # to serialize correctly u'' strings + return data + except NameError: + return str(data) + else: + return str(data) + + def serialize_iter(self, data, iter_type, div=None, **kwargs): + """Serialize iterable. + + Supported kwargs: + - serialization_ctxt dict : The current entry of _attribute_map, or same format. + serialization_ctxt['type'] should be same as data_type. + - is_xml bool : If set, serialize as XML + + :param list attr: Object to be serialized. + :param str iter_type: Type of object in the iterable. + :param bool required: Whether the objects in the iterable must + not be None or empty. + :param str div: If set, this str will be used to combine the elements + in the iterable into a combined string. Default is 'None'. + :rtype: list, str + """ + if isinstance(data, str): + raise SerializationError("Refuse str type as a valid iter type.") + + serialization_ctxt = kwargs.get("serialization_ctxt", {}) + is_xml = kwargs.get("is_xml", False) + + serialized = [] + for d in data: + try: + serialized.append(self.serialize_data(d, iter_type, **kwargs)) + except ValueError: + serialized.append(None) + + if div: + serialized = ['' if s is None else str(s) for s in serialized] + serialized = div.join(serialized) + + if 'xml' in serialization_ctxt or is_xml: + # XML serialization is more complicated + xml_desc = serialization_ctxt.get('xml', {}) + xml_name = xml_desc.get('name') + if not xml_name: + xml_name = serialization_ctxt['key'] + + # Create a wrap node if necessary (use the fact that Element and list have "append") + is_wrapped = xml_desc.get("wrapped", False) + node_name = xml_desc.get("itemsName", xml_name) + if is_wrapped: + final_result = _create_xml_node( + xml_name, + xml_desc.get('prefix', None), + xml_desc.get('ns', None) + ) + else: + final_result = [] + # All list elements to "local_node" + for el in serialized: + if isinstance(el, ET.Element): + el_node = el + else: + el_node = _create_xml_node( + node_name, + xml_desc.get('prefix', None), + xml_desc.get('ns', None) + ) + if el is not None: # Otherwise it writes "None" :-p + el_node.text = str(el) + final_result.append(el_node) + return final_result + return serialized + + def serialize_dict(self, attr, dict_type, **kwargs): + """Serialize a dictionary of objects. + + :param dict attr: Object to be serialized. + :param str dict_type: Type of object in the dictionary. + :param bool required: Whether the objects in the dictionary must + not be None or empty. + :rtype: dict + """ + serialization_ctxt = kwargs.get("serialization_ctxt", {}) + serialized = {} + for key, value in attr.items(): + try: + serialized[self.serialize_unicode(key)] = self.serialize_data( + value, dict_type, **kwargs) + except ValueError: + serialized[self.serialize_unicode(key)] = None + + if 'xml' in serialization_ctxt: + # XML serialization is more complicated + xml_desc = serialization_ctxt['xml'] + xml_name = xml_desc['name'] + + final_result = _create_xml_node( + xml_name, + xml_desc.get('prefix', None), + xml_desc.get('ns', None) + ) + for key, value in serialized.items(): + ET.SubElement(final_result, key).text = value + return final_result + + return serialized + + def serialize_object(self, attr, **kwargs): + """Serialize a generic object. + This will be handled as a dictionary. If object passed in is not + a basic type (str, int, float, dict, list) it will simply be + cast to str. + + :param dict attr: Object to be serialized. + :rtype: dict or str + """ + if attr is None: + return None + if isinstance(attr, ET.Element): + return attr + obj_type = type(attr) + if obj_type in self.basic_types: + return self.serialize_basic(attr, self.basic_types[obj_type], **kwargs) + if obj_type is _long_type: + return self.serialize_long(attr) + if obj_type is unicode_str: + return self.serialize_unicode(attr) + if obj_type is datetime.datetime: + return self.serialize_iso(attr) + if obj_type is datetime.date: + return self.serialize_date(attr) + if obj_type is datetime.time: + return self.serialize_time(attr) + if obj_type is datetime.timedelta: + return self.serialize_duration(attr) + if obj_type is decimal.Decimal: + return self.serialize_decimal(attr) + + # If it's a model or I know this dependency, serialize as a Model + elif obj_type in self.dependencies.values() or isinstance(attr, Model): + return self._serialize(attr) + + if obj_type == dict: + serialized = {} + for key, value in attr.items(): + try: + serialized[self.serialize_unicode(key)] = self.serialize_object( + value, **kwargs) + except ValueError: + serialized[self.serialize_unicode(key)] = None + return serialized + + if obj_type == list: + serialized = [] + for obj in attr: + try: + serialized.append(self.serialize_object( + obj, **kwargs)) + except ValueError: + pass + return serialized + return str(attr) + + @staticmethod + def serialize_enum(attr, enum_obj=None): + try: + result = attr.value + except AttributeError: + result = attr + try: + enum_obj(result) + return result + except ValueError: + for enum_value in enum_obj: + if enum_value.value.lower() == str(attr).lower(): + return enum_value.value + error = "{!r} is not valid value for enum {!r}" + raise SerializationError(error.format(attr, enum_obj)) + + @staticmethod + def serialize_bytearray(attr, **kwargs): + """Serialize bytearray into base-64 string. + + :param attr: Object to be serialized. + :rtype: str + """ + return b64encode(attr).decode() + + @staticmethod + def serialize_base64(attr, **kwargs): + """Serialize str into base-64 string. + + :param attr: Object to be serialized. + :rtype: str + """ + encoded = b64encode(attr).decode('ascii') + return encoded.strip('=').replace('+', '-').replace('/', '_') + + @staticmethod + def serialize_decimal(attr, **kwargs): + """Serialize Decimal object to float. + + :param attr: Object to be serialized. + :rtype: float + """ + return float(attr) + + @staticmethod + def serialize_long(attr, **kwargs): + """Serialize long (Py2) or int (Py3). + + :param attr: Object to be serialized. + :rtype: int/long + """ + return _long_type(attr) + + @staticmethod + def serialize_date(attr, **kwargs): + """Serialize Date object into ISO-8601 formatted string. + + :param Date attr: Object to be serialized. + :rtype: str + """ + if isinstance(attr, str): + attr = isodate.parse_date(attr) + t = "{:04}-{:02}-{:02}".format(attr.year, attr.month, attr.day) + return t + + @staticmethod + def serialize_time(attr, **kwargs): + """Serialize Time object into ISO-8601 formatted string. + + :param datetime.time attr: Object to be serialized. + :rtype: str + """ + if isinstance(attr, str): + attr = isodate.parse_time(attr) + t = "{:02}:{:02}:{:02}".format(attr.hour, attr.minute, attr.second) + if attr.microsecond: + t += ".{:02}".format(attr.microsecond) + return t + + @staticmethod + def serialize_duration(attr, **kwargs): + """Serialize TimeDelta object into ISO-8601 formatted string. + + :param TimeDelta attr: Object to be serialized. + :rtype: str + """ + if isinstance(attr, str): + attr = isodate.parse_duration(attr) + return isodate.duration_isoformat(attr) + + @staticmethod + def serialize_rfc(attr, **kwargs): + """Serialize Datetime object into RFC-1123 formatted string. + + :param Datetime attr: Object to be serialized. + :rtype: str + :raises: TypeError if format invalid. + """ + try: + if not attr.tzinfo: + _LOGGER.warning( + "Datetime with no tzinfo will be considered UTC.") + utc = attr.utctimetuple() + except AttributeError: + raise TypeError("RFC1123 object must be valid Datetime object.") + + return "{}, {:02} {} {:04} {:02}:{:02}:{:02} GMT".format( + Serializer.days[utc.tm_wday], utc.tm_mday, + Serializer.months[utc.tm_mon], utc.tm_year, + utc.tm_hour, utc.tm_min, utc.tm_sec) + + @staticmethod + def serialize_iso(attr, **kwargs): + """Serialize Datetime object into ISO-8601 formatted string. + + :param Datetime attr: Object to be serialized. + :rtype: str + :raises: SerializationError if format invalid. + """ + if isinstance(attr, str): + attr = isodate.parse_datetime(attr) + try: + if not attr.tzinfo: + _LOGGER.warning( + "Datetime with no tzinfo will be considered UTC.") + utc = attr.utctimetuple() + if utc.tm_year > 9999 or utc.tm_year < 1: + raise OverflowError("Hit max or min date") + + microseconds = str(attr.microsecond).rjust(6,'0').rstrip('0').ljust(3, '0') + if microseconds: + microseconds = '.'+microseconds + date = "{:04}-{:02}-{:02}T{:02}:{:02}:{:02}".format( + utc.tm_year, utc.tm_mon, utc.tm_mday, + utc.tm_hour, utc.tm_min, utc.tm_sec) + return date + microseconds + 'Z' + except (ValueError, OverflowError) as err: + msg = "Unable to serialize datetime object." + raise_with_traceback(SerializationError, msg, err) + except AttributeError as err: + msg = "ISO-8601 object must be valid Datetime object." + raise_with_traceback(TypeError, msg, err) + + @staticmethod + def serialize_unix(attr, **kwargs): + """Serialize Datetime object into IntTime format. + This is represented as seconds. + + :param Datetime attr: Object to be serialized. + :rtype: int + :raises: SerializationError if format invalid + """ + if isinstance(attr, int): + return attr + try: + if not attr.tzinfo: + _LOGGER.warning( + "Datetime with no tzinfo will be considered UTC.") + return int(calendar.timegm(attr.utctimetuple())) + except AttributeError: + raise TypeError("Unix time object must be valid Datetime object.") + +def rest_key_extractor(attr, attr_desc, data): + key = attr_desc['key'] + working_data = data + + while '.' in key: + dict_keys = _FLATTEN.split(key) + if len(dict_keys) == 1: + key = _decode_attribute_map_key(dict_keys[0]) + break + working_key = _decode_attribute_map_key(dict_keys[0]) + working_data = working_data.get(working_key, data) + if working_data is None: + # If at any point while following flatten JSON path see None, it means + # that all properties under are None as well + # https://github.com/Azure/msrest-for-python/issues/197 + return None + key = '.'.join(dict_keys[1:]) + + return working_data.get(key) + +def rest_key_case_insensitive_extractor(attr, attr_desc, data): + key = attr_desc['key'] + working_data = data + + while '.' in key: + dict_keys = _FLATTEN.split(key) + if len(dict_keys) == 1: + key = _decode_attribute_map_key(dict_keys[0]) + break + working_key = _decode_attribute_map_key(dict_keys[0]) + working_data = attribute_key_case_insensitive_extractor(working_key, None, working_data) + if working_data is None: + # If at any point while following flatten JSON path see None, it means + # that all properties under are None as well + # https://github.com/Azure/msrest-for-python/issues/197 + return None + key = '.'.join(dict_keys[1:]) + + if working_data: + return attribute_key_case_insensitive_extractor(key, None, working_data) + +def last_rest_key_extractor(attr, attr_desc, data): + """Extract the attribute in "data" based on the last part of the JSON path key. + """ + key = attr_desc['key'] + dict_keys = _FLATTEN.split(key) + return attribute_key_extractor(dict_keys[-1], None, data) + +def last_rest_key_case_insensitive_extractor(attr, attr_desc, data): + """Extract the attribute in "data" based on the last part of the JSON path key. + + This is the case insensitive version of "last_rest_key_extractor" + """ + key = attr_desc['key'] + dict_keys = _FLATTEN.split(key) + return attribute_key_case_insensitive_extractor(dict_keys[-1], None, data) + +def attribute_key_extractor(attr, _, data): + return data.get(attr) + +def attribute_key_case_insensitive_extractor(attr, _, data): + found_key = None + lower_attr = attr.lower() + for key in data: + if lower_attr == key.lower(): + found_key = key + break + + return data.get(found_key) + +def _extract_name_from_internal_type(internal_type): + """Given an internal type XML description, extract correct XML name with namespace. + + :param dict internal_type: An model type + :rtype: tuple + :returns: A tuple XML name + namespace dict + """ + internal_type_xml_map = getattr(internal_type, "_xml_map", {}) + 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) + return xml_name + + +def xml_key_extractor(attr, attr_desc, data): + if isinstance(data, dict): + return None + + # Test if this model is XML ready first + if not isinstance(data, ET.Element): + return None + + xml_desc = attr_desc.get('xml', {}) + xml_name = xml_desc.get('name', attr_desc['key']) + + # Look for a children + is_iter_type = attr_desc['type'].startswith("[") + is_wrapped = xml_desc.get("wrapped", False) + internal_type = attr_desc.get("internalType", None) + internal_type_xml_map = getattr(internal_type, "_xml_map", {}) + + # 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) + + # If it's an attribute, that's simple + if xml_desc.get("attr", False): + return data.get(xml_name) + + # If it's x-ms-text, that's simple too + if xml_desc.get("text", False): + return data.text + + # Scenario where I take the local name: + # - Wrapped node + # - Internal type is an enum (considered basic types) + # - Internal type has no XML/Name node + if is_wrapped or (internal_type and (issubclass(internal_type, Enum) or 'name' not in internal_type_xml_map)): + children = data.findall(xml_name) + # If internal type has a local name and it's not a list, I use that name + elif not is_iter_type and internal_type and 'name' in internal_type_xml_map: + xml_name = _extract_name_from_internal_type(internal_type) + children = data.findall(xml_name) + # That's an array + else: + if internal_type: # Complex type, ignore itemsName and use the complex type name + items_name = _extract_name_from_internal_type(internal_type) + else: + items_name = xml_desc.get("itemsName", xml_name) + children = data.findall(items_name) + + if len(children) == 0: + if is_iter_type: + if is_wrapped: + return None # is_wrapped no node, we want None + else: + return [] # not wrapped, assume empty list + return None # Assume it's not there, maybe an optional node. + + # If is_iter_type and not wrapped, return all found children + if is_iter_type: + if not is_wrapped: + return children + else: # Iter and wrapped, should have found one node only (the wrap one) + if len(children) != 1: + raise DeserializationError( + "Tried to deserialize an array not wrapped, and found several nodes '{}'. Maybe you should declare this array as wrapped?".format( + xml_name + )) + return list(children[0]) # Might be empty list and that's ok. + + # Here it's not a itertype, we should have found one element only or empty + if len(children) > 1: + raise DeserializationError("Find several XML '{}' where it was not expected".format(xml_name)) + return children[0] + +class Deserializer(object): + """Response object model deserializer. + + :param dict classes: Class type dictionary for deserializing complex types. + :ivar list key_extractors: Ordered list of extractors to be used by this deserializer. + """ + + basic_types = {str: 'str', int: 'int', bool: 'bool', float: 'float'} + + valid_date = re.compile( + r'\d{4}[-]\d{2}[-]\d{2}T\d{2}:\d{2}:\d{2}' + r'\.?\d*Z?[-+]?[\d{2}]?:?[\d{2}]?') + + def __init__(self, classes=None): + self.deserialize_type = { + 'iso-8601': Deserializer.deserialize_iso, + 'rfc-1123': Deserializer.deserialize_rfc, + 'unix-time': Deserializer.deserialize_unix, + 'duration': Deserializer.deserialize_duration, + 'date': Deserializer.deserialize_date, + 'time': Deserializer.deserialize_time, + 'decimal': Deserializer.deserialize_decimal, + 'long': Deserializer.deserialize_long, + 'bytearray': Deserializer.deserialize_bytearray, + 'base64': Deserializer.deserialize_base64, + 'object': self.deserialize_object, + '[]': self.deserialize_iter, + '{}': self.deserialize_dict + } + self.deserialize_expected_types = { + 'duration': (isodate.Duration, datetime.timedelta), + 'iso-8601': (datetime.datetime) + } + self.dependencies = 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 + # complicated, with no real scenario for now. + # So adding a flag to disable additional properties detection. This flag should be + # used if your expect the deserialization to NOT come from a JSON REST syntax. + # Otherwise, result are unexpected + self.additional_properties_detection = True + + def __call__(self, target_obj, response_data, content_type=None): + """Call the deserializer to process a REST response. + + :param str target_obj: Target data type to deserialize to. + :param requests.Response response_data: REST response object. + :param str content_type: Swagger "produces" if available. + :raises: DeserializationError if deserialization fails. + :return: Deserialized object. + """ + data = self._unpack_content(response_data, content_type) + return self._deserialize(target_obj, data) + + def _deserialize(self, target_obj, data): + """Call the deserializer on a model. + + Data needs to be already deserialized as JSON or XML ElementTree + + :param str target_obj: Target data type to deserialize to. + :param object data: Object to deserialize. + :raises: DeserializationError if deserialization fails. + :return: Deserialized object. + """ + # This is already a model, go recursive just in case + if hasattr(data, "_attribute_map"): + constants = [name for name, config in getattr(data, '_validation', {}).items() + if config.get('constant')] + try: + for attr, mapconfig in data._attribute_map.items(): + if attr in constants: + continue + value = getattr(data, attr) + if value is None: + continue + local_type = mapconfig['type'] + internal_data_type = local_type.strip('[]{}') + if internal_data_type not in self.dependencies or isinstance(internal_data_type, Enum): + continue + setattr( + data, + attr, + self._deserialize(local_type, value) + ) + return data + except AttributeError: + return + + response, class_name = self._classify_target(target_obj, data) + + if isinstance(response, basestring): + return self.deserialize_data(data, response) + elif isinstance(response, type) and issubclass(response, Enum): + return self.deserialize_enum(data, response) + + if data is None: + return data + try: + attributes = response._attribute_map + d_attrs = {} + for attr, attr_desc in attributes.items(): + # Check empty string. If it's not empty, someone has a real "additionalProperties"... + if attr == "additional_properties" and attr_desc["key"] == '': + continue + raw_value = None + # Enhance attr_desc with some dynamic data + attr_desc = attr_desc.copy() # Do a copy, do not change the real one + internal_data_type = attr_desc["type"].strip('[]{}') + if internal_data_type in self.dependencies: + attr_desc["internalType"] = self.dependencies[internal_data_type] + + for key_extractor in self.key_extractors: + found_value = key_extractor(attr, attr_desc, data) + if found_value is not None: + if raw_value is not None and raw_value != found_value: + msg = ("Ignoring extracted value '%s' from %s for key '%s'" + " (duplicate extraction, follow extractors order)" ) + _LOGGER.warning( + msg, + found_value, + key_extractor, + attr + ) + continue + raw_value = found_value + + 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 + raise_with_traceback(DeserializationError, msg, err) + else: + additional_properties = self._build_additional_properties(attributes, data) + return self._instantiate_model(response, d_attrs, additional_properties) + + def _build_additional_properties(self, attribute_map, data): + if not self.additional_properties_detection: + return None + if "additional_properties" in attribute_map and attribute_map.get("additional_properties", {}).get("key") != '': + # Check empty string. If it's not empty, someone has a real "additionalProperties" + return None + if isinstance(data, ET.Element): + data = {el.tag: el.text for el in data} + + known_keys = {_decode_attribute_map_key(_FLATTEN.split(desc['key'])[0]) + for desc in attribute_map.values() if desc['key'] != ''} + present_keys = set(data.keys()) + missing_keys = present_keys - known_keys + return {key: data[key] for key in missing_keys} + + def _classify_target(self, target, data): + """Check to see whether the deserialization target object can + be classified into a subclass. + 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. + """ + if target is None: + return None, None + + if isinstance(target, basestring): + try: + target = self.dependencies[target] + except KeyError: + return target, target + + try: + target = target._classify(data, self.dependencies) + except AttributeError: + pass # Target is not a Model, no classify + return target, target.__class__.__name__ + + def failsafe_deserialize(self, target_obj, data, content_type=None): + """Ignores any errors encountered in deserialization, + and falls back to not deserializing the object. Recommended + for use in error deserialization, as we want to return the + HttpResponseError to users, and not have them deal with + 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 content_type: Swagger "produces" if available. + """ + try: + return self(target_obj, data, content_type=content_type) + except: + _LOGGER.debug( + "Ran into a deserialization error. Ignoring since this is failsafe deserialization", + exc_info=True + ) + return None + + @staticmethod + def _unpack_content(raw_data, content_type=None): + """Extract the correct structure for deserialization. + + If raw_data is a PipelineResponse, try to extract the result of RawDeserializer. + if we can't, raise. Your Pipeline should have a RawDeserializer. + + If not a pipeline response and raw_data is bytes or string, use content-type + to decode it. If no content-type, try JSON. + + If raw_data is something else, bypass all logic and return it directly. + + :param raw_data: Data to be processed. + :param content_type: How to parse if raw_data is a string/bytes. + :raises JSONDecodeError: If JSON is requested and parsing is impossible. + :raises UnicodeDecodeError: If bytes is not UTF8 + """ + # Assume this is enough to detect a Pipeline Response without importing it + context = getattr(raw_data, "context", {}) + if context: + if RawDeserializer.CONTEXT_NAME in context: + return context[RawDeserializer.CONTEXT_NAME] + raise ValueError("This pipeline didn't have the RawDeserializer policy; can't deserialize") + + #Assume this is enough to recognize universal_http.ClientResponse without importing it + if hasattr(raw_data, "body"): + return RawDeserializer.deserialize_from_http_generics( + raw_data.text(), + raw_data.headers + ) + + # Assume this enough to recognize requests.Response without importing it. + if hasattr(raw_data, '_content_consumed'): + 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 raw_data + + def _instantiate_model(self, response, attrs, additional_properties=None): + """Instantiate a response model passing in deserialized args. + + :param response: The response model class. + :param d_attrs: The deserialized response attributes. + """ + if callable(response): + subtype = getattr(response, '_subtype_map', {}) + try: + readonly = [k for k, v in response._validation.items() + if v.get('readonly')] + const = [k for k, v in response._validation.items() + if v.get('constant')] + kwargs = {k: v for k, v in attrs.items() + if k not in subtype and k not in readonly + const} + response_obj = response(**kwargs) + for attr in readonly: + setattr(response_obj, attr, attrs.get(attr)) + if additional_properties: + response_obj.additional_properties = additional_properties + return response_obj + except TypeError as err: + msg = "Unable to deserialize {} into model {}. ".format( + kwargs, response) + raise DeserializationError(msg + str(err)) + else: + try: + for attr, value in attrs.items(): + setattr(response, attr, value) + return response + except Exception as exp: + msg = "Unable to populate response model. " + msg += "Type: {}, Error: {}".format(type(response), exp) + raise DeserializationError(msg) + + def deserialize_data(self, data, data_type): + """Process data for deserialization according to data type. + + :param str data: The response string to be deserialized. + :param str data_type: The type to deserialize to. + :raises: DeserializationError if deserialization fails. + :return: Deserialized object. + """ + if data is None: + return data + + try: + if not data_type: + return data + if data_type in self.basic_types.values(): + return self.deserialize_basic(data, data_type) + if data_type in self.deserialize_type: + if isinstance(data, self.deserialize_expected_types.get(data_type, tuple())): + return data + + is_a_text_parsing_type = lambda x: x not in ["object", "[]", r"{}"] + if isinstance(data, ET.Element) and is_a_text_parsing_type(data_type) and not data.text: + return None + data_val = self.deserialize_type[data_type](data) + return data_val + + iter_type = data_type[0] + data_type[-1] + if iter_type in self.deserialize_type: + return self.deserialize_type[iter_type](data, data_type[1:-1]) + + obj_type = self.dependencies[data_type] + if issubclass(obj_type, Enum): + if isinstance(data, ET.Element): + data = data.text + return self.deserialize_enum(data, obj_type) + + except (ValueError, TypeError, AttributeError) as err: + msg = "Unable to deserialize response data." + msg += " Data: {}, {}".format(data, data_type) + raise_with_traceback(DeserializationError, msg, err) + else: + return self._deserialize(obj_type, data) + + def deserialize_iter(self, attr, iter_type): + """Deserialize an iterable. + + :param list attr: Iterable to be deserialized. + :param str iter_type: The type of object in the iterable. + :rtype: list + """ + if attr is None: + return None + if isinstance(attr, ET.Element): # If I receive an element here, get the children + attr = list(attr) + if not isinstance(attr, (list, set)): + raise DeserializationError("Cannot deserialize as [{}] an object of type {}".format( + iter_type, + type(attr) + )) + return [self.deserialize_data(a, iter_type) for a in attr] + + def deserialize_dict(self, attr, dict_type): + """Deserialize a dictionary. + + :param dict/list attr: Dictionary to be deserialized. Also accepts + a list of key, value pairs. + :param str dict_type: The object type of the items in the dictionary. + :rtype: dict + """ + if isinstance(attr, list): + return {x['key']: self.deserialize_data(x['value'], dict_type) for x in attr} + + if isinstance(attr, ET.Element): + # Transform value into {"Key": "value"} + attr = {el.tag: el.text for el in attr} + return {k: self.deserialize_data(v, dict_type) for k, v in attr.items()} + + def deserialize_object(self, attr, **kwargs): + """Deserialize a generic object. + This will be handled as a dictionary. + + :param dict attr: Dictionary to be deserialized. + :rtype: dict + :raises: TypeError if non-builtin datatype encountered. + """ + if attr is None: + return None + if isinstance(attr, ET.Element): + # Do no recurse on XML, just return the tree as-is + return attr + if isinstance(attr, basestring): + return self.deserialize_basic(attr, 'str') + obj_type = type(attr) + if obj_type in self.basic_types: + return self.deserialize_basic(attr, self.basic_types[obj_type]) + if obj_type is _long_type: + return self.deserialize_long(attr) + + if obj_type == dict: + deserialized = {} + for key, value in attr.items(): + try: + deserialized[key] = self.deserialize_object( + value, **kwargs) + except ValueError: + deserialized[key] = None + return deserialized + + if obj_type == list: + deserialized = [] + for obj in attr: + try: + deserialized.append(self.deserialize_object( + obj, **kwargs)) + except ValueError: + pass + return deserialized + + else: + error = "Cannot deserialize generic object with type: " + raise TypeError(error + str(obj_type)) + + def deserialize_basic(self, attr, data_type): + """Deserialize basic builtin data type from string. + Will attempt to convert to str, int, float and bool. + This function will also accept '1', '0', 'true' and 'false' as + valid bool values. + + :param str attr: response string to be deserialized. + :param str data_type: deserialization data type. + :rtype: str, int, float or bool + :raises: TypeError if string format is not valid. + """ + # If we're here, data is supposed to be a basic type. + # If it's still an XML node, take the text + if isinstance(attr, ET.Element): + attr = attr.text + if not attr: + if data_type == "str": + # None or '', node is empty string. + return '' + else: + # None or '', node with a strong type is None. + # Don't try to model "empty bool" or "empty int" + return None + + if data_type == 'bool': + if attr in [True, False, 1, 0]: + return bool(attr) + elif isinstance(attr, basestring): + if attr.lower() in ['true', '1']: + return True + elif attr.lower() in ['false', '0']: + return False + raise TypeError("Invalid boolean value: {}".format(attr)) + + if data_type == 'str': + return self.deserialize_unicode(attr) + return eval(data_type)(attr) # nosec + + @staticmethod + def deserialize_unicode(data): + """Preserve unicode objects in Python 2, otherwise return data + as a string. + + :param str data: response string to be deserialized. + :rtype: str or unicode + """ + # We might be here because we have an enum modeled as string, + # and we try to deserialize a partial dict with enum inside + if isinstance(data, Enum): + return data + + # Consider this is real string + try: + if isinstance(data, unicode): + return data + except NameError: + return str(data) + else: + return str(data) + + @staticmethod + def deserialize_enum(data, enum_obj): + """Deserialize string into enum object. + + If the string is not a valid enum value it will be returned as-is + and a warning will be logged. + + :param str data: Response string to be deserialized. If this value is + None or invalid it will be returned as-is. + :param Enum enum_obj: Enum object to deserialize to. + :rtype: Enum + """ + if isinstance(data, enum_obj) or data is None: + return data + if isinstance(data, Enum): + data = data.value + if isinstance(data, int): + # Workaround. We might consider remove it in the future. + # https://github.com/Azure/azure-rest-api-specs/issues/141 + try: + return list(enum_obj.__members__.values())[data] + except IndexError: + error = "{!r} is not a valid index for enum {!r}" + raise DeserializationError(error.format(data, enum_obj)) + try: + return enum_obj(str(data)) + except ValueError: + for enum_value in enum_obj: + if enum_value.value.lower() == str(data).lower(): + return enum_value + # We don't fail anymore for unknown value, we deserialize as a string + _LOGGER.warning("Deserializer is not able to find %s as valid enum in %s", data, enum_obj) + return Deserializer.deserialize_unicode(data) + + @staticmethod + def deserialize_bytearray(attr): + """Deserialize string into bytearray. + + :param str attr: response string to be deserialized. + :rtype: bytearray + :raises: TypeError if string format invalid. + """ + if isinstance(attr, ET.Element): + attr = attr.text + return bytearray(b64decode(attr)) + + @staticmethod + def deserialize_base64(attr): + """Deserialize base64 encoded string into string. + + :param str attr: response string to be deserialized. + :rtype: bytearray + :raises: TypeError if string format invalid. + """ + if isinstance(attr, ET.Element): + attr = attr.text + padding = '=' * (3 - (len(attr) + 3) % 4) + attr = attr + padding + encoded = attr.replace('-', '+').replace('_', '/') + return b64decode(encoded) + + @staticmethod + def deserialize_decimal(attr): + """Deserialize string into Decimal object. + + :param str attr: response string to be deserialized. + :rtype: Decimal + :raises: DeserializationError if string format invalid. + """ + if isinstance(attr, ET.Element): + attr = attr.text + try: + return decimal.Decimal(attr) + except decimal.DecimalException as err: + msg = "Invalid decimal {}".format(attr) + raise_with_traceback(DeserializationError, msg, err) + + @staticmethod + def deserialize_long(attr): + """Deserialize string into long (Py2) or int (Py3). + + :param str attr: response string to be deserialized. + :rtype: long or int + :raises: ValueError if string format invalid. + """ + if isinstance(attr, ET.Element): + attr = attr.text + return _long_type(attr) + + @staticmethod + def deserialize_duration(attr): + """Deserialize ISO-8601 formatted string into TimeDelta object. + + :param str attr: response string to be deserialized. + :rtype: TimeDelta + :raises: DeserializationError if string format invalid. + """ + if isinstance(attr, ET.Element): + attr = attr.text + try: + duration = isodate.parse_duration(attr) + except(ValueError, OverflowError, AttributeError) as err: + msg = "Cannot deserialize duration object." + raise_with_traceback(DeserializationError, msg, err) + else: + return duration + + @staticmethod + def deserialize_date(attr): + """Deserialize ISO-8601 formatted string into Date object. + + :param str attr: response string to be deserialized. + :rtype: Date + :raises: DeserializationError if string format invalid. + """ + if isinstance(attr, ET.Element): + attr = attr.text + if re.search(r"[^\W\d_]", attr, re.I + re.U): + 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) + + @staticmethod + def deserialize_time(attr): + """Deserialize ISO-8601 formatted string into time object. + + :param str attr: response string to be deserialized. + :rtype: datetime.time + :raises: DeserializationError if string format invalid. + """ + if isinstance(attr, ET.Element): + attr = attr.text + if re.search(r"[^\W\d_]", attr, re.I + re.U): + raise DeserializationError("Date must have only digits and -. Received: %s" % attr) + return isodate.parse_time(attr) + + @staticmethod + def deserialize_rfc(attr): + """Deserialize RFC-1123 formatted string into Datetime object. + + :param str attr: response string to be deserialized. + :rtype: Datetime + :raises: DeserializationError if string format invalid. + """ + if isinstance(attr, ET.Element): + attr = attr.text + try: + parsed_date = email.utils.parsedate_tz(attr) + date_obj = datetime.datetime( + *parsed_date[:6], + tzinfo=_FixedOffset(datetime.timedelta(minutes=(parsed_date[9] or 0)/60)) + ) + if not date_obj.tzinfo: + date_obj = date_obj.astimezone(tz=TZ_UTC) + except ValueError as err: + msg = "Cannot deserialize to rfc datetime object." + raise_with_traceback(DeserializationError, msg, err) + else: + return date_obj + + @staticmethod + def deserialize_iso(attr): + """Deserialize ISO-8601 formatted string into Datetime object. + + :param str attr: response string to be deserialized. + :rtype: Datetime + :raises: DeserializationError if string format invalid. + """ + if isinstance(attr, ET.Element): + attr = attr.text + try: + attr = attr.upper() + match = Deserializer.valid_date.match(attr) + if not match: + raise ValueError("Invalid datetime string: " + attr) + + check_decimal = attr.split('.') + if len(check_decimal) > 1: + decimal_str = "" + for digit in check_decimal[1]: + if digit.isdigit(): + decimal_str += digit + else: + break + if len(decimal_str) > 6: + attr = attr.replace(decimal_str, decimal_str[0:6]) + + date_obj = isodate.parse_datetime(attr) + test_utc = date_obj.utctimetuple() + if test_utc.tm_year > 9999 or test_utc.tm_year < 1: + raise OverflowError("Hit max or min date") + except(ValueError, OverflowError, AttributeError) as err: + msg = "Cannot deserialize datetime object." + raise_with_traceback(DeserializationError, msg, err) + else: + return date_obj + + @staticmethod + def deserialize_unix(attr): + """Serialize Datetime object into IntTime format. + This is represented as seconds. + + :param int attr: Object to be serialized. + :rtype: Datetime + :raises: DeserializationError if format invalid + """ + if isinstance(attr, ET.Element): + attr = int(attr.text) + try: + date_obj = datetime.datetime.fromtimestamp(attr, TZ_UTC) + except ValueError as err: + msg = "Cannot deserialize to unix datetime object." + raise_with_traceback(DeserializationError, msg, err) + else: + return date_obj diff --git a/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/privatelinks/aio/_configuration.py b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/privatelinks/aio/_configuration.py index c032fb15cf689..bc9f0a8eb0dc8 100644 --- a/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/privatelinks/aio/_configuration.py +++ b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/privatelinks/aio/_configuration.py @@ -26,9 +26,9 @@ class ResourcePrivateLinkClientConfiguration(Configuration): Note that all parameters used to create this instance are saved as instance attributes. - :param credential: Credential needed for the client to connect to Azure. + :param credential: Credential needed for the client to connect to Azure. Required. :type credential: ~azure.core.credentials_async.AsyncTokenCredential - :param subscription_id: The ID of the target subscription. + :param subscription_id: The ID of the target subscription. Required. :type subscription_id: str """ diff --git a/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/privatelinks/aio/_resource_private_link_client.py b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/privatelinks/aio/_resource_private_link_client.py index 0fd36f3a9d034..7f8bd28ba8f19 100644 --- a/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/privatelinks/aio/_resource_private_link_client.py +++ b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/privatelinks/aio/_resource_private_link_client.py @@ -11,17 +11,15 @@ from typing import Any, Optional, TYPE_CHECKING -from msrest import Deserializer, Serializer - from azure.mgmt.core import AsyncARMPipelineClient from azure.profiles import KnownProfiles, ProfileDefinition from azure.profiles.multiapiclient import MultiApiClientMixin +from .._serialization import Deserializer, Serializer from ._configuration import ResourcePrivateLinkClientConfiguration if TYPE_CHECKING: # pylint: disable=unused-import,ungrouped-imports - from azure.core.credentials import TokenCredential from azure.core.credentials_async import AsyncTokenCredential class _SDKClient(object): @@ -42,9 +40,9 @@ class ResourcePrivateLinkClient(MultiApiClientMixin, _SDKClient): The api-version parameter sets the default API version if the operation group is not described in the profile. - :param credential: Credential needed for the client to connect to Azure. + :param credential: Credential needed for the client to connect to Azure. Required. :type credential: ~azure.core.credentials_async.AsyncTokenCredential - :param subscription_id: The ID of the target subscription. + :param subscription_id: The ID of the target subscription. Required. :type subscription_id: str :param api_version: API version to use if no profile is provided, or if missing in profile. :type api_version: str diff --git a/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/privatelinks/v2020_05_01/__init__.py b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/privatelinks/v2020_05_01/__init__.py index 3b3183bd23be0..42152adb690db 100644 --- a/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/privatelinks/v2020_05_01/__init__.py +++ b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/privatelinks/v2020_05_01/__init__.py @@ -10,9 +10,15 @@ from ._version import VERSION __version__ = VERSION -__all__ = ['ResourcePrivateLinkClient'] -# `._patch.py` is used for handwritten extensions to the generated code -# Example: https://github.com/Azure/azure-sdk-for-python/blob/main/doc/dev/customize_code/how-to-patch-sdk-code.md -from ._patch import patch_sdk -patch_sdk() +try: + from ._patch import __all__ as _patch_all + from ._patch import * # type: ignore # pylint: disable=unused-wildcard-import +except ImportError: + _patch_all = [] +from ._patch import patch_sdk as _patch_sdk + +__all__ = ["ResourcePrivateLinkClient"] +__all__.extend([p for p in _patch_all if p not in __all__]) + +_patch_sdk() diff --git a/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/privatelinks/v2020_05_01/_configuration.py b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/privatelinks/v2020_05_01/_configuration.py index 93ac989316c42..f3f3c6dc83886 100644 --- a/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/privatelinks/v2020_05_01/_configuration.py +++ b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/privatelinks/v2020_05_01/_configuration.py @@ -25,23 +25,18 @@ class ResourcePrivateLinkClientConfiguration(Configuration): # pylint: disable= Note that all parameters used to create this instance are saved as instance attributes. - :param credential: Credential needed for the client to connect to Azure. + :param credential: Credential needed for the client to connect to Azure. Required. :type credential: ~azure.core.credentials.TokenCredential - :param subscription_id: The ID of the target subscription. + :param subscription_id: The ID of the target subscription. Required. :type subscription_id: str :keyword api_version: Api Version. Default value is "2020-05-01". Note that overriding this default value may result in unsupported behavior. :paramtype api_version: str """ - def __init__( - self, - credential: "TokenCredential", - subscription_id: str, - **kwargs: Any - ) -> None: + def __init__(self, credential: "TokenCredential", subscription_id: str, **kwargs: Any) -> None: super(ResourcePrivateLinkClientConfiguration, self).__init__(**kwargs) - api_version = kwargs.pop('api_version', "2020-05-01") # type: str + api_version = kwargs.pop("api_version", "2020-05-01") # type: str if credential is None: raise ValueError("Parameter 'credential' must not be None.") @@ -51,23 +46,24 @@ def __init__( self.credential = credential self.subscription_id = subscription_id self.api_version = api_version - self.credential_scopes = kwargs.pop('credential_scopes', ['https://management.azure.com/.default']) - kwargs.setdefault('sdk_moniker', 'mgmt-resource/{}'.format(VERSION)) + self.credential_scopes = kwargs.pop("credential_scopes", ["https://management.azure.com/.default"]) + kwargs.setdefault("sdk_moniker", "mgmt-resource/{}".format(VERSION)) self._configure(**kwargs) def _configure( - self, - **kwargs # type: Any + self, **kwargs # type: Any ): # type: (...) -> 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) - self.logging_policy = kwargs.get('logging_policy') or policies.NetworkTraceLoggingPolicy(**kwargs) - self.http_logging_policy = kwargs.get('http_logging_policy') or ARMHttpLoggingPolicy(**kwargs) - self.retry_policy = kwargs.get('retry_policy') or policies.RetryPolicy(**kwargs) - self.custom_hook_policy = kwargs.get('custom_hook_policy') or policies.CustomHookPolicy(**kwargs) - self.redirect_policy = kwargs.get('redirect_policy') or policies.RedirectPolicy(**kwargs) - self.authentication_policy = kwargs.get('authentication_policy') + 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) + self.logging_policy = kwargs.get("logging_policy") or policies.NetworkTraceLoggingPolicy(**kwargs) + self.http_logging_policy = kwargs.get("http_logging_policy") or ARMHttpLoggingPolicy(**kwargs) + self.retry_policy = kwargs.get("retry_policy") or policies.RetryPolicy(**kwargs) + self.custom_hook_policy = kwargs.get("custom_hook_policy") or policies.CustomHookPolicy(**kwargs) + self.redirect_policy = kwargs.get("redirect_policy") or policies.RedirectPolicy(**kwargs) + self.authentication_policy = kwargs.get("authentication_policy") if self.credential and not self.authentication_policy: - self.authentication_policy = ARMChallengeAuthenticationPolicy(self.credential, *self.credential_scopes, **kwargs) + self.authentication_policy = ARMChallengeAuthenticationPolicy( + self.credential, *self.credential_scopes, **kwargs + ) diff --git a/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/privatelinks/v2020_05_01/_metadata.json b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/privatelinks/v2020_05_01/_metadata.json index 514feb810168b..143f94cc95549 100644 --- a/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/privatelinks/v2020_05_01/_metadata.json +++ b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/privatelinks/v2020_05_01/_metadata.json @@ -10,20 +10,20 @@ "azure_arm": true, "has_lro_operations": false, "client_side_validation": false, - "sync_imports": "{\"typing\": {\"azurecore\": {\"azure.core.credentials\": [\"TokenCredential\"]}}, \"regular\": {\"azurecore\": {\"azure.profiles\": [\"KnownProfiles\", \"ProfileDefinition\"], \"azure.profiles.multiapiclient\": [\"MultiApiClientMixin\"], \"azure.mgmt.core\": [\"ARMPipelineClient\"]}, \"local\": {\"._configuration\": [\"ResourcePrivateLinkClientConfiguration\"]}, \"thirdparty\": {\"msrest\": [\"Deserializer\", \"Serializer\"]}}, \"conditional\": {\"stdlib\": {\"typing\": [\"Any\", \"Optional\"]}}}", - "async_imports": "{\"typing\": {\"azurecore\": {\"azure.core.credentials_async\": [\"AsyncTokenCredential\"], \"azure.core.credentials\": [\"TokenCredential\"]}}, \"regular\": {\"azurecore\": {\"azure.profiles\": [\"KnownProfiles\", \"ProfileDefinition\"], \"azure.profiles.multiapiclient\": [\"MultiApiClientMixin\"], \"azure.mgmt.core\": [\"AsyncARMPipelineClient\"]}, \"local\": {\"._configuration\": [\"ResourcePrivateLinkClientConfiguration\"]}, \"thirdparty\": {\"msrest\": [\"Deserializer\", \"Serializer\"]}}, \"conditional\": {\"stdlib\": {\"typing\": [\"Any\", \"Optional\"]}}}" + "sync_imports": "{\"conditional\": {\"stdlib\": {\"typing\": [\"Any\", \"Optional\"]}}, \"regular\": {\"azurecore\": {\"azure.mgmt.core\": [\"ARMPipelineClient\"], \"azure.profiles\": [\"KnownProfiles\", \"ProfileDefinition\"], \"azure.profiles.multiapiclient\": [\"MultiApiClientMixin\"]}, \"local\": {\"._configuration\": [\"ResourcePrivateLinkClientConfiguration\"], \".._serialization\": [\"Deserializer\", \"Serializer\"]}}, \"typing\": {\"azurecore\": {\"azure.core.credentials\": [\"TokenCredential\"]}}}", + "async_imports": "{\"conditional\": {\"stdlib\": {\"typing\": [\"Any\", \"Optional\"]}}, \"regular\": {\"azurecore\": {\"azure.mgmt.core\": [\"AsyncARMPipelineClient\"], \"azure.profiles\": [\"KnownProfiles\", \"ProfileDefinition\"], \"azure.profiles.multiapiclient\": [\"MultiApiClientMixin\"]}, \"local\": {\"._configuration\": [\"ResourcePrivateLinkClientConfiguration\"], \"..._serialization\": [\"Deserializer\", \"Serializer\"]}}, \"typing\": {\"azurecore\": {\"azure.core.credentials_async\": [\"AsyncTokenCredential\"]}}}" }, "global_parameters": { "sync": { "credential": { - "signature": "credential, # type: \"TokenCredential\"", - "description": "Credential needed for the client to connect to Azure.", + "signature": "credential: \"TokenCredential\",", + "description": "Credential needed for the client to connect to Azure. Required.", "docstring_type": "~azure.core.credentials.TokenCredential", "required": true }, "subscription_id": { - "signature": "subscription_id, # type: str", - "description": "The ID of the target subscription.", + "signature": "subscription_id: str,", + "description": "The ID of the target subscription. Required.", "docstring_type": "str", "required": true } @@ -31,13 +31,13 @@ "async": { "credential": { "signature": "credential: \"AsyncTokenCredential\",", - "description": "Credential needed for the client to connect to Azure.", + "description": "Credential needed for the client to connect to Azure. Required.", "docstring_type": "~azure.core.credentials_async.AsyncTokenCredential", "required": true }, "subscription_id": { "signature": "subscription_id: str,", - "description": "The ID of the target subscription.", + "description": "The ID of the target subscription. Required.", "docstring_type": "str", "required": true } @@ -54,7 +54,7 @@ "required": false }, "base_url": { - "signature": "base_url=\"https://management.azure.com\", # type: str", + "signature": "base_url: str = \"https://management.azure.com\",", "description": "Service URL", "docstring_type": "str", "required": false diff --git a/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/privatelinks/v2020_05_01/_patch.py b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/privatelinks/v2020_05_01/_patch.py index 74e48ecd07cf3..f99e77fef9861 100644 --- a/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/privatelinks/v2020_05_01/_patch.py +++ b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/privatelinks/v2020_05_01/_patch.py @@ -28,4 +28,4 @@ # This file is used for handwritten extensions to the generated code. Example: # https://github.com/Azure/azure-sdk-for-python/blob/main/doc/dev/customize_code/how-to-patch-sdk-code.md def patch_sdk(): - pass \ No newline at end of file + pass diff --git a/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/privatelinks/v2020_05_01/_resource_private_link_client.py b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/privatelinks/v2020_05_01/_resource_private_link_client.py index aff407612d2cb..ac06d8dafc423 100644 --- a/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/privatelinks/v2020_05_01/_resource_private_link_client.py +++ b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/privatelinks/v2020_05_01/_resource_private_link_client.py @@ -9,12 +9,11 @@ from copy import deepcopy from typing import Any, TYPE_CHECKING -from msrest import Deserializer, Serializer - from azure.core.rest import HttpRequest, HttpResponse from azure.mgmt.core import ARMPipelineClient from . import models +from .._serialization import Deserializer, Serializer from ._configuration import ResourcePrivateLinkClientConfiguration from .operations import PrivateLinkAssociationOperations, ResourceManagementPrivateLinkOperations @@ -22,7 +21,8 @@ # pylint: disable=unused-import,ungrouped-imports from azure.core.credentials import TokenCredential -class ResourcePrivateLinkClient: + +class ResourcePrivateLinkClient: # pylint: disable=client-accepts-api-version-keyword """Provides operations for managing private link resources. :ivar private_link_association: PrivateLinkAssociationOperations operations @@ -31,9 +31,9 @@ class ResourcePrivateLinkClient: :ivar resource_management_private_link: ResourceManagementPrivateLinkOperations operations :vartype resource_management_private_link: azure.mgmt.resource.privatelinks.v2020_05_01.operations.ResourceManagementPrivateLinkOperations - :param credential: Credential needed for the client to connect to Azure. + :param credential: Credential needed for the client to connect to Azure. Required. :type credential: ~azure.core.credentials.TokenCredential - :param subscription_id: The ID of the target subscription. + :param subscription_id: The ID of the target subscription. Required. :type subscription_id: str :param base_url: Service URL. Default value is "https://management.azure.com". :type base_url: str @@ -49,22 +49,23 @@ def __init__( base_url: str = "https://management.azure.com", **kwargs: Any ) -> None: - self._config = ResourcePrivateLinkClientConfiguration(credential=credential, subscription_id=subscription_id, **kwargs) + self._config = ResourcePrivateLinkClientConfiguration( + credential=credential, subscription_id=subscription_id, **kwargs + ) self._client = ARMPipelineClient(base_url=base_url, config=self._config, **kwargs) client_models = {k: v for k, v in models.__dict__.items() if isinstance(v, type)} self._serialize = Serializer(client_models) self._deserialize = Deserializer(client_models) self._serialize.client_side_validation = False - self.private_link_association = PrivateLinkAssociationOperations(self._client, self._config, self._serialize, self._deserialize) - self.resource_management_private_link = ResourceManagementPrivateLinkOperations(self._client, self._config, self._serialize, self._deserialize) - - - def _send_request( - self, - request: HttpRequest, - **kwargs: Any - ) -> HttpResponse: + self.private_link_association = PrivateLinkAssociationOperations( + self._client, self._config, self._serialize, self._deserialize + ) + self.resource_management_private_link = ResourceManagementPrivateLinkOperations( + self._client, self._config, self._serialize, self._deserialize + ) + + def _send_request(self, request: HttpRequest, **kwargs: Any) -> HttpResponse: """Runs the network request through the client's chained policies. >>> from azure.core.rest import HttpRequest @@ -73,7 +74,7 @@ def _send_request( >>> response = client._send_request(request) - For more information on this code flow, see https://aka.ms/azsdk/python/protocol/quickstart + For more information on this code flow, see https://aka.ms/azsdk/dpcodegen/python/send_request :param request: The network request you want to make. Required. :type request: ~azure.core.rest.HttpRequest diff --git a/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/privatelinks/v2020_05_01/_vendor.py b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/privatelinks/v2020_05_01/_vendor.py index 138f663c53a4e..9aad73fc743e7 100644 --- a/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/privatelinks/v2020_05_01/_vendor.py +++ b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/privatelinks/v2020_05_01/_vendor.py @@ -7,6 +7,7 @@ from azure.core.pipeline.transport import HttpRequest + def _convert_request(request, files=None): data = request.content if not files else None request = HttpRequest(method=request.method, url=request.url, headers=request.headers, data=data) @@ -14,6 +15,7 @@ def _convert_request(request, files=None): request.set_formdata_body(files) return request + def _format_url_section(template, **kwargs): components = template.split("/") while components: @@ -21,7 +23,5 @@ def _format_url_section(template, **kwargs): 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 - ] + components = [c for c in formatted_components if "{}".format(key.args[0]) not in c] template = "/".join(components) diff --git a/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/privatelinks/v2020_05_01/_version.py b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/privatelinks/v2020_05_01/_version.py index a012ac01c480c..e5754a47ce68f 100644 --- a/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/privatelinks/v2020_05_01/_version.py +++ b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/privatelinks/v2020_05_01/_version.py @@ -6,4 +6,4 @@ # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -VERSION = "21.1.0" +VERSION = "1.0.0b1" diff --git a/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/privatelinks/v2020_05_01/aio/__init__.py b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/privatelinks/v2020_05_01/aio/__init__.py index 2dbfec1449d85..868caff8f6324 100644 --- a/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/privatelinks/v2020_05_01/aio/__init__.py +++ b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/privatelinks/v2020_05_01/aio/__init__.py @@ -7,9 +7,15 @@ # -------------------------------------------------------------------------- from ._resource_private_link_client import ResourcePrivateLinkClient -__all__ = ['ResourcePrivateLinkClient'] -# `._patch.py` is used for handwritten extensions to the generated code -# Example: https://github.com/Azure/azure-sdk-for-python/blob/main/doc/dev/customize_code/how-to-patch-sdk-code.md -from ._patch import patch_sdk -patch_sdk() +try: + from ._patch import __all__ as _patch_all + from ._patch import * # type: ignore # pylint: disable=unused-wildcard-import +except ImportError: + _patch_all = [] +from ._patch import patch_sdk as _patch_sdk + +__all__ = ["ResourcePrivateLinkClient"] +__all__.extend([p for p in _patch_all if p not in __all__]) + +_patch_sdk() diff --git a/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/privatelinks/v2020_05_01/aio/_configuration.py b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/privatelinks/v2020_05_01/aio/_configuration.py index 2d96ee16dec84..eabd72caa44e7 100644 --- a/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/privatelinks/v2020_05_01/aio/_configuration.py +++ b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/privatelinks/v2020_05_01/aio/_configuration.py @@ -25,23 +25,18 @@ class ResourcePrivateLinkClientConfiguration(Configuration): # pylint: disable= Note that all parameters used to create this instance are saved as instance attributes. - :param credential: Credential needed for the client to connect to Azure. + :param credential: Credential needed for the client to connect to Azure. Required. :type credential: ~azure.core.credentials_async.AsyncTokenCredential - :param subscription_id: The ID of the target subscription. + :param subscription_id: The ID of the target subscription. Required. :type subscription_id: str :keyword api_version: Api Version. Default value is "2020-05-01". Note that overriding this default value may result in unsupported behavior. :paramtype api_version: str """ - def __init__( - self, - credential: "AsyncTokenCredential", - subscription_id: str, - **kwargs: Any - ) -> None: + def __init__(self, credential: "AsyncTokenCredential", subscription_id: str, **kwargs: Any) -> None: super(ResourcePrivateLinkClientConfiguration, self).__init__(**kwargs) - api_version = kwargs.pop('api_version', "2020-05-01") # type: str + api_version = kwargs.pop("api_version", "2020-05-01") # type: str if credential is None: raise ValueError("Parameter 'credential' must not be None.") @@ -51,22 +46,21 @@ def __init__( self.credential = credential self.subscription_id = subscription_id self.api_version = api_version - self.credential_scopes = kwargs.pop('credential_scopes', ['https://management.azure.com/.default']) - kwargs.setdefault('sdk_moniker', 'mgmt-resource/{}'.format(VERSION)) + self.credential_scopes = kwargs.pop("credential_scopes", ["https://management.azure.com/.default"]) + kwargs.setdefault("sdk_moniker", "mgmt-resource/{}".format(VERSION)) self._configure(**kwargs) - 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) - self.logging_policy = kwargs.get('logging_policy') or policies.NetworkTraceLoggingPolicy(**kwargs) - self.http_logging_policy = kwargs.get('http_logging_policy') or ARMHttpLoggingPolicy(**kwargs) - self.retry_policy = kwargs.get('retry_policy') or policies.AsyncRetryPolicy(**kwargs) - self.custom_hook_policy = kwargs.get('custom_hook_policy') or policies.CustomHookPolicy(**kwargs) - self.redirect_policy = kwargs.get('redirect_policy') or policies.AsyncRedirectPolicy(**kwargs) - self.authentication_policy = kwargs.get('authentication_policy') + 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) + self.logging_policy = kwargs.get("logging_policy") or policies.NetworkTraceLoggingPolicy(**kwargs) + self.http_logging_policy = kwargs.get("http_logging_policy") or ARMHttpLoggingPolicy(**kwargs) + self.retry_policy = kwargs.get("retry_policy") or policies.AsyncRetryPolicy(**kwargs) + self.custom_hook_policy = kwargs.get("custom_hook_policy") or policies.CustomHookPolicy(**kwargs) + self.redirect_policy = kwargs.get("redirect_policy") or policies.AsyncRedirectPolicy(**kwargs) + self.authentication_policy = kwargs.get("authentication_policy") if self.credential and not self.authentication_policy: - self.authentication_policy = AsyncARMChallengeAuthenticationPolicy(self.credential, *self.credential_scopes, **kwargs) + self.authentication_policy = AsyncARMChallengeAuthenticationPolicy( + self.credential, *self.credential_scopes, **kwargs + ) diff --git a/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/privatelinks/v2020_05_01/aio/_patch.py b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/privatelinks/v2020_05_01/aio/_patch.py index 74e48ecd07cf3..f99e77fef9861 100644 --- a/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/privatelinks/v2020_05_01/aio/_patch.py +++ b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/privatelinks/v2020_05_01/aio/_patch.py @@ -28,4 +28,4 @@ # This file is used for handwritten extensions to the generated code. Example: # https://github.com/Azure/azure-sdk-for-python/blob/main/doc/dev/customize_code/how-to-patch-sdk-code.md def patch_sdk(): - pass \ No newline at end of file + pass diff --git a/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/privatelinks/v2020_05_01/aio/_resource_private_link_client.py b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/privatelinks/v2020_05_01/aio/_resource_private_link_client.py index 23074dfd3f3aa..dd3a17819b2a2 100644 --- a/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/privatelinks/v2020_05_01/aio/_resource_private_link_client.py +++ b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/privatelinks/v2020_05_01/aio/_resource_private_link_client.py @@ -9,12 +9,11 @@ from copy import deepcopy from typing import Any, Awaitable, TYPE_CHECKING -from msrest import Deserializer, Serializer - from azure.core.rest import AsyncHttpResponse, HttpRequest from azure.mgmt.core import AsyncARMPipelineClient from .. import models +from ..._serialization import Deserializer, Serializer from ._configuration import ResourcePrivateLinkClientConfiguration from .operations import PrivateLinkAssociationOperations, ResourceManagementPrivateLinkOperations @@ -22,7 +21,8 @@ # pylint: disable=unused-import,ungrouped-imports from azure.core.credentials_async import AsyncTokenCredential -class ResourcePrivateLinkClient: + +class ResourcePrivateLinkClient: # pylint: disable=client-accepts-api-version-keyword """Provides operations for managing private link resources. :ivar private_link_association: PrivateLinkAssociationOperations operations @@ -31,9 +31,9 @@ class ResourcePrivateLinkClient: :ivar resource_management_private_link: ResourceManagementPrivateLinkOperations operations :vartype resource_management_private_link: azure.mgmt.resource.privatelinks.v2020_05_01.aio.operations.ResourceManagementPrivateLinkOperations - :param credential: Credential needed for the client to connect to Azure. + :param credential: Credential needed for the client to connect to Azure. Required. :type credential: ~azure.core.credentials_async.AsyncTokenCredential - :param subscription_id: The ID of the target subscription. + :param subscription_id: The ID of the target subscription. Required. :type subscription_id: str :param base_url: Service URL. Default value is "https://management.azure.com". :type base_url: str @@ -49,22 +49,23 @@ def __init__( base_url: str = "https://management.azure.com", **kwargs: Any ) -> None: - self._config = ResourcePrivateLinkClientConfiguration(credential=credential, subscription_id=subscription_id, **kwargs) + self._config = ResourcePrivateLinkClientConfiguration( + credential=credential, subscription_id=subscription_id, **kwargs + ) self._client = AsyncARMPipelineClient(base_url=base_url, config=self._config, **kwargs) client_models = {k: v for k, v in models.__dict__.items() if isinstance(v, type)} self._serialize = Serializer(client_models) self._deserialize = Deserializer(client_models) self._serialize.client_side_validation = False - self.private_link_association = PrivateLinkAssociationOperations(self._client, self._config, self._serialize, self._deserialize) - self.resource_management_private_link = ResourceManagementPrivateLinkOperations(self._client, self._config, self._serialize, self._deserialize) - - - def _send_request( - self, - request: HttpRequest, - **kwargs: Any - ) -> Awaitable[AsyncHttpResponse]: + self.private_link_association = PrivateLinkAssociationOperations( + self._client, self._config, self._serialize, self._deserialize + ) + self.resource_management_private_link = ResourceManagementPrivateLinkOperations( + self._client, self._config, self._serialize, self._deserialize + ) + + def _send_request(self, request: HttpRequest, **kwargs: Any) -> Awaitable[AsyncHttpResponse]: """Runs the network request through the client's chained policies. >>> from azure.core.rest import HttpRequest @@ -73,7 +74,7 @@ def _send_request( >>> response = await client._send_request(request) - For more information on this code flow, see https://aka.ms/azsdk/python/protocol/quickstart + For more information on this code flow, see https://aka.ms/azsdk/dpcodegen/python/send_request :param request: The network request you want to make. Required. :type request: ~azure.core.rest.HttpRequest diff --git a/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/privatelinks/v2020_05_01/aio/operations/__init__.py b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/privatelinks/v2020_05_01/aio/operations/__init__.py index 56aef7386788c..07a01cf18452f 100644 --- a/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/privatelinks/v2020_05_01/aio/operations/__init__.py +++ b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/privatelinks/v2020_05_01/aio/operations/__init__.py @@ -9,7 +9,13 @@ from ._operations import PrivateLinkAssociationOperations from ._operations import ResourceManagementPrivateLinkOperations +from ._patch import __all__ as _patch_all +from ._patch import * # type: ignore # pylint: disable=unused-wildcard-import +from ._patch import patch_sdk as _patch_sdk + __all__ = [ - 'PrivateLinkAssociationOperations', - 'ResourceManagementPrivateLinkOperations', + "PrivateLinkAssociationOperations", + "ResourceManagementPrivateLinkOperations", ] +__all__.extend([p for p in _patch_all if p not in __all__]) +_patch_sdk() diff --git a/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/privatelinks/v2020_05_01/aio/operations/_operations.py b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/privatelinks/v2020_05_01/aio/operations/_operations.py index 09f6bbbc30001..e9a8ed756e17c 100644 --- a/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/privatelinks/v2020_05_01/aio/operations/_operations.py +++ b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/privatelinks/v2020_05_01/aio/operations/_operations.py @@ -6,75 +6,153 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -from typing import Any, Callable, Dict, Optional, TypeVar - -from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error +from typing import Any, Callable, Dict, IO, Optional, TypeVar, Union, overload + +from azure.core.exceptions import ( + ClientAuthenticationError, + HttpResponseError, + ResourceExistsError, + ResourceNotFoundError, + ResourceNotModifiedError, + map_error, +) from azure.core.pipeline import PipelineResponse from azure.core.pipeline.transport import AsyncHttpResponse from azure.core.rest import HttpRequest from azure.core.tracing.decorator_async import distributed_trace_async +from azure.core.utils import case_insensitive_dict from azure.mgmt.core.exceptions import ARMErrorFormat from ... import models as _models from ..._vendor import _convert_request -from ...operations._operations import build_private_link_association_delete_request, build_private_link_association_get_request, build_private_link_association_list_request, build_private_link_association_put_request, build_resource_management_private_link_delete_request, build_resource_management_private_link_get_request, build_resource_management_private_link_list_by_resource_group_request, build_resource_management_private_link_list_request, build_resource_management_private_link_put_request -T = TypeVar('T') +from ...operations._operations import ( + build_private_link_association_delete_request, + build_private_link_association_get_request, + build_private_link_association_list_request, + build_private_link_association_put_request, + build_resource_management_private_link_delete_request, + build_resource_management_private_link_get_request, + build_resource_management_private_link_list_by_resource_group_request, + build_resource_management_private_link_list_request, + build_resource_management_private_link_put_request, +) + +T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] -class PrivateLinkAssociationOperations: - """PrivateLinkAssociationOperations async operations. - You should not instantiate this class directly. Instead, you should create a Client instance that - instantiates it for you and attaches it as an attribute. +class PrivateLinkAssociationOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. - :ivar models: Alias to model classes used in this operation group. - :type models: ~azure.mgmt.resource.privatelinks.v2020_05_01.models - :param client: Client for service requests. - :param config: Configuration of service client. - :param serializer: An object model serializer. - :param deserializer: An object model deserializer. + Instead, you should access the following operations through + :class:`~azure.mgmt.resource.privatelinks.v2020_05_01.aio.ResourcePrivateLinkClient`'s + :attr:`private_link_association` attribute. """ models = _models - def __init__(self, client, config, serializer, deserializer) -> None: - self._client = client - self._serialize = serializer - self._deserialize = deserializer - self._config = config + def __init__(self, *args, **kwargs) -> None: + input_args = list(args) + self._client = input_args.pop(0) if input_args else kwargs.pop("client") + self._config = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") - @distributed_trace_async + @overload async def put( self, group_id: str, pla_id: str, - parameters: "_models.PrivateLinkAssociationObject", + parameters: _models.PrivateLinkAssociationObject, + *, + content_type: str = "application/json", **kwargs: Any - ) -> "_models.PrivateLinkAssociation": + ) -> _models.PrivateLinkAssociation: """Create a PrivateLinkAssociation. - :param group_id: The management group ID. + :param group_id: The management group ID. Required. :type group_id: str - :param pla_id: The ID of the PLA. + :param pla_id: The ID of the PLA. Required. :type pla_id: str - :param parameters: Parameters supplied to create the private link association. + :param parameters: Parameters supplied to create the private link association. Required. :type parameters: ~azure.mgmt.resource.privatelinks.v2020_05_01.models.PrivateLinkAssociationObject + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: PrivateLinkAssociation or the result of cls(response) + :rtype: ~azure.mgmt.resource.privatelinks.v2020_05_01.models.PrivateLinkAssociation + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + async def put( + self, group_id: str, pla_id: str, parameters: IO, *, content_type: str = "application/json", **kwargs: Any + ) -> _models.PrivateLinkAssociation: + """Create a PrivateLinkAssociation. + + :param group_id: The management group ID. Required. + :type group_id: str + :param pla_id: The ID of the PLA. Required. + :type pla_id: str + :param parameters: Parameters supplied to create the private link association. Required. + :type parameters: IO + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: PrivateLinkAssociation or the result of cls(response) + :rtype: ~azure.mgmt.resource.privatelinks.v2020_05_01.models.PrivateLinkAssociation + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace_async + async def put( + self, group_id: str, pla_id: str, parameters: Union[_models.PrivateLinkAssociationObject, IO], **kwargs: Any + ) -> _models.PrivateLinkAssociation: + """Create a PrivateLinkAssociation. + + :param group_id: The management group ID. Required. + :type group_id: str + :param pla_id: The ID of the PLA. Required. + :type pla_id: str + :param parameters: Parameters supplied to create the private link association. Is either a + model type or a IO type. Required. + :type parameters: + ~azure.mgmt.resource.privatelinks.v2020_05_01.models.PrivateLinkAssociationObject or IO + :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. + Default value is None. + :paramtype content_type: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: PrivateLinkAssociation, or the result of cls(response) + :return: PrivateLinkAssociation or the result of cls(response) :rtype: ~azure.mgmt.resource.privatelinks.v2020_05_01.models.PrivateLinkAssociation - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.PrivateLinkAssociation"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) - api_version = kwargs.pop('api_version', "2020-05-01") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - _json = self._serialize.body(parameters, 'PrivateLinkAssociationObject') + api_version = kwargs.pop("api_version", _params.pop("api-version", "2020-05-01")) # type: str + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.PrivateLinkAssociation] + + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(parameters, (IO, bytes)): + _content = parameters + else: + _json = self._serialize.body(parameters, "PrivateLinkAssociationObject") request = build_private_link_association_put_request( group_id=group_id, @@ -82,16 +160,18 @@ async def put( api_version=api_version, content_type=content_type, json=_json, - template_url=self.put.metadata['url'], + content=_content, + template_url=self.put.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200, 201]: @@ -99,117 +179,119 @@ async def put( raise HttpResponseError(response=response, error_format=ARMErrorFormat) if response.status_code == 200: - deserialized = self._deserialize('PrivateLinkAssociation', pipeline_response) + deserialized = self._deserialize("PrivateLinkAssociation", pipeline_response) if response.status_code == 201: - deserialized = self._deserialize('PrivateLinkAssociation', pipeline_response) + deserialized = self._deserialize("PrivateLinkAssociation", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - put.metadata = {'url': "/providers/Microsoft.Management/managementGroups/{groupId}/providers/Microsoft.Authorization/privateLinkAssociations/{plaId}"} # type: ignore - + put.metadata = {"url": "/providers/Microsoft.Management/managementGroups/{groupId}/providers/Microsoft.Authorization/privateLinkAssociations/{plaId}"} # type: ignore @distributed_trace_async - async def get( - self, - group_id: str, - pla_id: str, - **kwargs: Any - ) -> "_models.PrivateLinkAssociation": + async def get(self, group_id: str, pla_id: str, **kwargs: Any) -> _models.PrivateLinkAssociation: """Get a single private link association. - :param group_id: The management group ID. + :param group_id: The management group ID. Required. :type group_id: str - :param pla_id: The ID of the PLA. + :param pla_id: The ID of the PLA. Required. :type pla_id: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: PrivateLinkAssociation, or the result of cls(response) + :return: PrivateLinkAssociation or the result of cls(response) :rtype: ~azure.mgmt.resource.privatelinks.v2020_05_01.models.PrivateLinkAssociation - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.PrivateLinkAssociation"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + 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', "2020-05-01") # type: str + api_version = kwargs.pop("api_version", _params.pop("api-version", "2020-05-01")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[_models.PrivateLinkAssociation] - request = build_private_link_association_get_request( group_id=group_id, pla_id=pla_id, api_version=api_version, - template_url=self.get.metadata['url'], + template_url=self.get.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) - deserialized = self._deserialize('PrivateLinkAssociation', pipeline_response) + deserialized = self._deserialize("PrivateLinkAssociation", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - get.metadata = {'url': "/providers/Microsoft.Management/managementGroups/{groupId}/providers/Microsoft.Authorization/privateLinkAssociations/{plaId}"} # type: ignore - + get.metadata = {"url": "/providers/Microsoft.Management/managementGroups/{groupId}/providers/Microsoft.Authorization/privateLinkAssociations/{plaId}"} # type: ignore @distributed_trace_async async def delete( # pylint: disable=inconsistent-return-statements - self, - group_id: str, - pla_id: str, - **kwargs: Any + self, group_id: str, pla_id: str, **kwargs: Any ) -> None: """Delete a PrivateLinkAssociation. - :param group_id: The management group ID. + :param group_id: The management group ID. Required. :type group_id: str - :param pla_id: The ID of the PLA. + :param pla_id: The ID of the PLA. Required. :type pla_id: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: None, or the result of cls(response) + :return: None or the result of cls(response) :rtype: None - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType[None] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) - api_version = kwargs.pop('api_version', "2020-05-01") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2020-05-01")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[None] - request = build_private_link_association_delete_request( group_id=group_id, pla_id=pla_id, api_version=api_version, - template_url=self.delete.metadata['url'], + template_url=self.delete.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200, 204]: @@ -219,133 +301,209 @@ async def delete( # pylint: disable=inconsistent-return-statements if cls: return cls(pipeline_response, None, {}) - delete.metadata = {'url': "/providers/Microsoft.Management/managementGroups/{groupId}/providers/Microsoft.Authorization/privateLinkAssociations/{plaId}"} # type: ignore - + delete.metadata = {"url": "/providers/Microsoft.Management/managementGroups/{groupId}/providers/Microsoft.Authorization/privateLinkAssociations/{plaId}"} # type: ignore @distributed_trace_async - async def list( - self, - group_id: str, - **kwargs: Any - ) -> "_models.PrivateLinkAssociationGetResult": + async def list(self, group_id: str, **kwargs: Any) -> _models.PrivateLinkAssociationGetResult: """Get a private link association for a management group scope. - :param group_id: The management group ID. + :param group_id: The management group ID. Required. :type group_id: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: PrivateLinkAssociationGetResult, or the result of cls(response) + :return: PrivateLinkAssociationGetResult or the result of cls(response) :rtype: ~azure.mgmt.resource.privatelinks.v2020_05_01.models.PrivateLinkAssociationGetResult - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.PrivateLinkAssociationGetResult"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + 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', "2020-05-01") # type: str + api_version = kwargs.pop("api_version", _params.pop("api-version", "2020-05-01")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[_models.PrivateLinkAssociationGetResult] - request = build_private_link_association_list_request( group_id=group_id, api_version=api_version, - template_url=self.list.metadata['url'], + template_url=self.list.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) - deserialized = self._deserialize('PrivateLinkAssociationGetResult', pipeline_response) + deserialized = self._deserialize("PrivateLinkAssociationGetResult", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - list.metadata = {'url': "/providers/Microsoft.Management/managementGroups/{groupId}/providers/Microsoft.Authorization/privateLinkAssociations"} # type: ignore + list.metadata = {"url": "/providers/Microsoft.Management/managementGroups/{groupId}/providers/Microsoft.Authorization/privateLinkAssociations"} # type: ignore -class ResourceManagementPrivateLinkOperations: - """ResourceManagementPrivateLinkOperations async operations. - You should not instantiate this class directly. Instead, you should create a Client instance that - instantiates it for you and attaches it as an attribute. +class ResourceManagementPrivateLinkOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. - :ivar models: Alias to model classes used in this operation group. - :type models: ~azure.mgmt.resource.privatelinks.v2020_05_01.models - :param client: Client for service requests. - :param config: Configuration of service client. - :param serializer: An object model serializer. - :param deserializer: An object model deserializer. + Instead, you should access the following operations through + :class:`~azure.mgmt.resource.privatelinks.v2020_05_01.aio.ResourcePrivateLinkClient`'s + :attr:`resource_management_private_link` attribute. """ models = _models - def __init__(self, client, config, serializer, deserializer) -> None: - self._client = client - self._serialize = serializer - self._deserialize = deserializer - self._config = config + def __init__(self, *args, **kwargs) -> None: + input_args = list(args) + self._client = input_args.pop(0) if input_args else kwargs.pop("client") + self._config = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") - @distributed_trace_async + @overload async def put( self, resource_group_name: str, rmpl_name: str, - parameters: "_models.ResourceManagementPrivateLinkLocation", + parameters: _models.ResourceManagementPrivateLinkLocation, + *, + content_type: str = "application/json", **kwargs: Any - ) -> "_models.ResourceManagementPrivateLink": + ) -> _models.ResourceManagementPrivateLink: """Create a resource management group private link. :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. :type resource_group_name: str - :param rmpl_name: The name of the resource management private link. + :param rmpl_name: The name of the resource management private link. Required. :type rmpl_name: str - :param parameters: The region to create the Resource Management private link. + :param parameters: The region to create the Resource Management private link. Required. :type parameters: ~azure.mgmt.resource.privatelinks.v2020_05_01.models.ResourceManagementPrivateLinkLocation + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: ResourceManagementPrivateLink or the result of cls(response) + :rtype: ~azure.mgmt.resource.privatelinks.v2020_05_01.models.ResourceManagementPrivateLink + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + async def put( + self, + resource_group_name: str, + rmpl_name: str, + parameters: IO, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.ResourceManagementPrivateLink: + """Create a resource management group private link. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param rmpl_name: The name of the resource management private link. Required. + :type rmpl_name: str + :param parameters: The region to create the Resource Management private link. Required. + :type parameters: IO + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: ResourceManagementPrivateLink or the result of cls(response) + :rtype: ~azure.mgmt.resource.privatelinks.v2020_05_01.models.ResourceManagementPrivateLink + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace_async + async def put( + self, + resource_group_name: str, + rmpl_name: str, + parameters: Union[_models.ResourceManagementPrivateLinkLocation, IO], + **kwargs: Any + ) -> _models.ResourceManagementPrivateLink: + """Create a resource management group private link. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param rmpl_name: The name of the resource management private link. Required. + :type rmpl_name: str + :param parameters: The region to create the Resource Management private link. Is either a model + type or a IO type. Required. + :type parameters: + ~azure.mgmt.resource.privatelinks.v2020_05_01.models.ResourceManagementPrivateLinkLocation or + IO + :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. + Default value is None. + :paramtype content_type: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: ResourceManagementPrivateLink, or the result of cls(response) + :return: ResourceManagementPrivateLink or the result of cls(response) :rtype: ~azure.mgmt.resource.privatelinks.v2020_05_01.models.ResourceManagementPrivateLink - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.ResourceManagementPrivateLink"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) - api_version = kwargs.pop('api_version', "2020-05-01") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - _json = self._serialize.body(parameters, 'ResourceManagementPrivateLinkLocation') + api_version = kwargs.pop("api_version", _params.pop("api-version", "2020-05-01")) # type: str + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.ResourceManagementPrivateLink] + + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(parameters, (IO, bytes)): + _content = parameters + else: + _json = self._serialize.body(parameters, "ResourceManagementPrivateLinkLocation") request = build_resource_management_private_link_put_request( - subscription_id=self._config.subscription_id, resource_group_name=resource_group_name, rmpl_name=rmpl_name, + subscription_id=self._config.subscription_id, api_version=api_version, content_type=content_type, json=_json, - template_url=self.put.metadata['url'], + content=_content, + template_url=self.put.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200, 201]: @@ -353,119 +511,125 @@ async def put( raise HttpResponseError(response=response, error_format=ARMErrorFormat) if response.status_code == 200: - deserialized = self._deserialize('ResourceManagementPrivateLink', pipeline_response) + deserialized = self._deserialize("ResourceManagementPrivateLink", pipeline_response) if response.status_code == 201: - deserialized = self._deserialize('ResourceManagementPrivateLink', pipeline_response) + deserialized = self._deserialize("ResourceManagementPrivateLink", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - put.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Authorization/resourceManagementPrivateLinks/{rmplName}"} # type: ignore - + put.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Authorization/resourceManagementPrivateLinks/{rmplName}"} # type: ignore @distributed_trace_async async def get( - self, - resource_group_name: str, - rmpl_name: str, - **kwargs: Any - ) -> "_models.ResourceManagementPrivateLink": + self, resource_group_name: str, rmpl_name: str, **kwargs: Any + ) -> _models.ResourceManagementPrivateLink: """Get a resource management private link(resource-level). :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. :type resource_group_name: str - :param rmpl_name: The name of the resource management private link. + :param rmpl_name: The name of the resource management private link. Required. :type rmpl_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: ResourceManagementPrivateLink, or the result of cls(response) + :return: ResourceManagementPrivateLink or the result of cls(response) :rtype: ~azure.mgmt.resource.privatelinks.v2020_05_01.models.ResourceManagementPrivateLink - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.ResourceManagementPrivateLink"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) - api_version = kwargs.pop('api_version', "2020-05-01") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2020-05-01")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[_models.ResourceManagementPrivateLink] - request = build_resource_management_private_link_get_request( - subscription_id=self._config.subscription_id, resource_group_name=resource_group_name, rmpl_name=rmpl_name, + subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.get.metadata['url'], + template_url=self.get.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) - deserialized = self._deserialize('ResourceManagementPrivateLink', pipeline_response) + deserialized = self._deserialize("ResourceManagementPrivateLink", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - get.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Authorization/resourceManagementPrivateLinks/{rmplName}"} # type: ignore - + get.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Authorization/resourceManagementPrivateLinks/{rmplName}"} # type: ignore @distributed_trace_async async def delete( # pylint: disable=inconsistent-return-statements - self, - resource_group_name: str, - rmpl_name: str, - **kwargs: Any + self, resource_group_name: str, rmpl_name: str, **kwargs: Any ) -> None: """Delete a resource management private link. :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. :type resource_group_name: str - :param rmpl_name: The name of the resource management private link. + :param rmpl_name: The name of the resource management private link. Required. :type rmpl_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: None, or the result of cls(response) + :return: None or the result of cls(response) :rtype: None - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType[None] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + 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', "2020-05-01") # type: str + api_version = kwargs.pop("api_version", _params.pop("api-version", "2020-05-01")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[None] - request = build_resource_management_private_link_delete_request( - subscription_id=self._config.subscription_id, resource_group_name=resource_group_name, rmpl_name=rmpl_name, + subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.delete.metadata['url'], + template_url=self.delete.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200, 204]: @@ -475,111 +639,116 @@ async def delete( # pylint: disable=inconsistent-return-statements if cls: return cls(pipeline_response, None, {}) - delete.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Authorization/resourceManagementPrivateLinks/{rmplName}"} # type: ignore - + delete.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Authorization/resourceManagementPrivateLinks/{rmplName}"} # type: ignore @distributed_trace_async - async def list( - self, - **kwargs: Any - ) -> "_models.ResourceManagementPrivateLinkListResult": + async def list(self, **kwargs: Any) -> _models.ResourceManagementPrivateLinkListResult: """Get all the resource management private links in a subscription. :keyword callable cls: A custom type or function that will be passed the direct response - :return: ResourceManagementPrivateLinkListResult, or the result of cls(response) + :return: ResourceManagementPrivateLinkListResult or the result of cls(response) :rtype: ~azure.mgmt.resource.privatelinks.v2020_05_01.models.ResourceManagementPrivateLinkListResult - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.ResourceManagementPrivateLinkListResult"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + 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', "2020-05-01") # type: str + api_version = kwargs.pop("api_version", _params.pop("api-version", "2020-05-01")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[_models.ResourceManagementPrivateLinkListResult] - request = build_resource_management_private_link_list_request( subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.list.metadata['url'], + template_url=self.list.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) - deserialized = self._deserialize('ResourceManagementPrivateLinkListResult', pipeline_response) + deserialized = self._deserialize("ResourceManagementPrivateLinkListResult", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - list.metadata = {'url': "/subscriptions/{subscriptionId}/providers/Microsoft.Authorization/resourceManagementPrivateLinks"} # type: ignore - + list.metadata = {"url": "/subscriptions/{subscriptionId}/providers/Microsoft.Authorization/resourceManagementPrivateLinks"} # type: ignore @distributed_trace_async async def list_by_resource_group( - self, - resource_group_name: str, - **kwargs: Any - ) -> "_models.ResourceManagementPrivateLinkListResult": + self, resource_group_name: str, **kwargs: Any + ) -> _models.ResourceManagementPrivateLinkListResult: """Get all the resource management private links in a resource group. :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. :type resource_group_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: ResourceManagementPrivateLinkListResult, or the result of cls(response) + :return: ResourceManagementPrivateLinkListResult or the result of cls(response) :rtype: ~azure.mgmt.resource.privatelinks.v2020_05_01.models.ResourceManagementPrivateLinkListResult - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.ResourceManagementPrivateLinkListResult"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) - api_version = kwargs.pop('api_version', "2020-05-01") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2020-05-01")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[_models.ResourceManagementPrivateLinkListResult] - request = build_resource_management_private_link_list_by_resource_group_request( - subscription_id=self._config.subscription_id, 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'], + 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.url = self._client.format_url(request.url) # type: ignore - pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) - deserialized = self._deserialize('ResourceManagementPrivateLinkListResult', pipeline_response) + deserialized = self._deserialize("ResourceManagementPrivateLinkListResult", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - list_by_resource_group.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Authorization/resourceManagementPrivateLinks"} # type: ignore - + list_by_resource_group.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Authorization/resourceManagementPrivateLinks"} # type: ignore diff --git a/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/privatelinks/v2020_05_01/aio/operations/_patch.py b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/privatelinks/v2020_05_01/aio/operations/_patch.py new file mode 100644 index 0000000000000..f7dd32510333d --- /dev/null +++ b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/privatelinks/v2020_05_01/aio/operations/_patch.py @@ -0,0 +1,20 @@ +# ------------------------------------ +# Copyright (c) Microsoft Corporation. +# Licensed under the MIT License. +# ------------------------------------ +"""Customize generated code here. + +Follow our quickstart for examples: https://aka.ms/azsdk/python/dpcodegen/python/customize +""" +from typing import List + +__all__: List[str] = [] # Add all objects you want publicly available to users at this package level + + +def patch_sdk(): + """Do not remove from this file. + + `patch_sdk` is a last resort escape hatch that allows you to do customizations + you can't accomplish using the techniques described in + https://aka.ms/azsdk/python/dpcodegen/python/customize + """ diff --git a/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/privatelinks/v2020_05_01/models/__init__.py b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/privatelinks/v2020_05_01/models/__init__.py index d04c4536f1ac0..adb088ce0a2df 100644 --- a/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/privatelinks/v2020_05_01/models/__init__.py +++ b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/privatelinks/v2020_05_01/models/__init__.py @@ -18,22 +18,24 @@ from ._models_py3 import ResourceManagementPrivateLinkListResult from ._models_py3 import ResourceManagementPrivateLinkLocation - -from ._resource_private_link_client_enums import ( - PublicNetworkAccessOptions, -) +from ._resource_private_link_client_enums import PublicNetworkAccessOptions +from ._patch import __all__ as _patch_all +from ._patch import * # type: ignore # pylint: disable=unused-wildcard-import +from ._patch import patch_sdk as _patch_sdk __all__ = [ - 'ErrorAdditionalInfo', - 'ErrorResponse', - 'PrivateLinkAssociation', - 'PrivateLinkAssociationGetResult', - 'PrivateLinkAssociationObject', - 'PrivateLinkAssociationProperties', - 'PrivateLinkAssociationPropertiesExpanded', - 'ResourceManagementPrivateLink', - 'ResourceManagementPrivateLinkEndpointConnections', - 'ResourceManagementPrivateLinkListResult', - 'ResourceManagementPrivateLinkLocation', - 'PublicNetworkAccessOptions', + "ErrorAdditionalInfo", + "ErrorResponse", + "PrivateLinkAssociation", + "PrivateLinkAssociationGetResult", + "PrivateLinkAssociationObject", + "PrivateLinkAssociationProperties", + "PrivateLinkAssociationPropertiesExpanded", + "ResourceManagementPrivateLink", + "ResourceManagementPrivateLinkEndpointConnections", + "ResourceManagementPrivateLinkListResult", + "ResourceManagementPrivateLinkLocation", + "PublicNetworkAccessOptions", ] +__all__.extend([p for p in _patch_all if p not in __all__]) +_patch_sdk() diff --git a/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/privatelinks/v2020_05_01/models/_models_py3.py b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/privatelinks/v2020_05_01/models/_models_py3.py index 28251c55b2760..bc928f8be2b19 100644 --- a/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/privatelinks/v2020_05_01/models/_models_py3.py +++ b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/privatelinks/v2020_05_01/models/_models_py3.py @@ -1,4 +1,5 @@ # coding=utf-8 +# pylint: disable=too-many-lines # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. # Licensed under the MIT License. See License.txt in the project root for license information. @@ -6,14 +7,16 @@ # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -from typing import List, Optional, Union +from typing import List, Optional, TYPE_CHECKING, Union -import msrest.serialization +from ... import _serialization -from ._resource_private_link_client_enums import * +if TYPE_CHECKING: + # pylint: disable=unused-import,ungrouped-imports + from .. import models as _models -class ErrorAdditionalInfo(msrest.serialization.Model): +class ErrorAdditionalInfo(_serialization.Model): """The resource management error additional info. Variables are only populated by the server, and will be ignored when sending a request. @@ -21,31 +24,27 @@ class ErrorAdditionalInfo(msrest.serialization.Model): :ivar type: The additional info type. :vartype type: str :ivar info: The additional info. - :vartype info: any + :vartype info: JSON """ _validation = { - 'type': {'readonly': True}, - 'info': {'readonly': True}, + "type": {"readonly": True}, + "info": {"readonly": True}, } _attribute_map = { - 'type': {'key': 'type', 'type': 'str'}, - 'info': {'key': 'info', 'type': 'object'}, + "type": {"key": "type", "type": "str"}, + "info": {"key": "info", "type": "object"}, } - def __init__( - self, - **kwargs - ): - """ - """ - super(ErrorAdditionalInfo, self).__init__(**kwargs) + def __init__(self, **kwargs): + """ """ + super().__init__(**kwargs) self.type = None self.info = None -class ErrorResponse(msrest.serialization.Model): +class ErrorResponse(_serialization.Model): """Common error response for all Azure Resource Manager APIs to return error details for failed operations. (This also follows the OData error response format.). Variables are only populated by the server, and will be ignored when sending a request. @@ -64,28 +63,24 @@ class ErrorResponse(msrest.serialization.Model): """ _validation = { - 'code': {'readonly': True}, - 'message': {'readonly': True}, - 'target': {'readonly': True}, - 'details': {'readonly': True}, - 'additional_info': {'readonly': True}, + "code": {"readonly": True}, + "message": {"readonly": True}, + "target": {"readonly": True}, + "details": {"readonly": True}, + "additional_info": {"readonly": True}, } _attribute_map = { - 'code': {'key': 'code', 'type': 'str'}, - 'message': {'key': 'message', 'type': 'str'}, - 'target': {'key': 'target', 'type': 'str'}, - 'details': {'key': 'details', 'type': '[ErrorResponse]'}, - 'additional_info': {'key': 'additionalInfo', 'type': '[ErrorAdditionalInfo]'}, + "code": {"key": "code", "type": "str"}, + "message": {"key": "message", "type": "str"}, + "target": {"key": "target", "type": "str"}, + "details": {"key": "details", "type": "[ErrorResponse]"}, + "additional_info": {"key": "additionalInfo", "type": "[ErrorAdditionalInfo]"}, } - def __init__( - self, - **kwargs - ): - """ - """ - super(ErrorResponse, self).__init__(**kwargs) + def __init__(self, **kwargs): + """ """ + super().__init__(**kwargs) self.code = None self.message = None self.target = None @@ -93,7 +88,7 @@ def __init__( self.additional_info = None -class PrivateLinkAssociation(msrest.serialization.Model): +class PrivateLinkAssociation(_serialization.Model): """PrivateLinkAssociation. Variables are only populated by the server, and will be ignored when sending a request. @@ -110,37 +105,32 @@ class PrivateLinkAssociation(msrest.serialization.Model): """ _validation = { - 'id': {'readonly': True}, - 'type': {'readonly': True}, - 'name': {'readonly': True}, + "id": {"readonly": True}, + "type": {"readonly": True}, + "name": {"readonly": True}, } _attribute_map = { - 'properties': {'key': 'properties', 'type': 'PrivateLinkAssociationPropertiesExpanded'}, - 'id': {'key': 'id', 'type': 'str'}, - 'type': {'key': 'type', 'type': 'str'}, - 'name': {'key': 'name', 'type': 'str'}, + "properties": {"key": "properties", "type": "PrivateLinkAssociationPropertiesExpanded"}, + "id": {"key": "id", "type": "str"}, + "type": {"key": "type", "type": "str"}, + "name": {"key": "name", "type": "str"}, } - def __init__( - self, - *, - properties: Optional["PrivateLinkAssociationPropertiesExpanded"] = None, - **kwargs - ): + def __init__(self, *, properties: Optional["_models.PrivateLinkAssociationPropertiesExpanded"] = None, **kwargs): """ :keyword properties: The private link association properties. :paramtype properties: ~azure.mgmt.resource.privatelinks.v2020_05_01.models.PrivateLinkAssociationPropertiesExpanded """ - super(PrivateLinkAssociation, self).__init__(**kwargs) + super().__init__(**kwargs) self.properties = properties self.id = None self.type = None self.name = None -class PrivateLinkAssociationGetResult(msrest.serialization.Model): +class PrivateLinkAssociationGetResult(_serialization.Model): """Result of the request to get PLA for a MG scope. :ivar value: private link association information. @@ -149,25 +139,20 @@ class PrivateLinkAssociationGetResult(msrest.serialization.Model): """ _attribute_map = { - 'value': {'key': 'value', 'type': '[PrivateLinkAssociation]'}, + "value": {"key": "value", "type": "[PrivateLinkAssociation]"}, } - def __init__( - self, - *, - value: Optional[List["PrivateLinkAssociation"]] = None, - **kwargs - ): + def __init__(self, *, value: Optional[List["_models.PrivateLinkAssociation"]] = None, **kwargs): """ :keyword value: private link association information. :paramtype value: list[~azure.mgmt.resource.privatelinks.v2020_05_01.models.PrivateLinkAssociation] """ - super(PrivateLinkAssociationGetResult, self).__init__(**kwargs) + super().__init__(**kwargs) self.value = value -class PrivateLinkAssociationObject(msrest.serialization.Model): +class PrivateLinkAssociationObject(_serialization.Model): """PrivateLinkAssociationObject. :ivar properties: The properties of the PrivateLinkAssociation. @@ -176,64 +161,59 @@ class PrivateLinkAssociationObject(msrest.serialization.Model): """ _attribute_map = { - 'properties': {'key': 'properties', 'type': 'PrivateLinkAssociationProperties'}, + "properties": {"key": "properties", "type": "PrivateLinkAssociationProperties"}, } - def __init__( - self, - *, - properties: Optional["PrivateLinkAssociationProperties"] = None, - **kwargs - ): + def __init__(self, *, properties: Optional["_models.PrivateLinkAssociationProperties"] = None, **kwargs): """ :keyword properties: The properties of the PrivateLinkAssociation. :paramtype properties: ~azure.mgmt.resource.privatelinks.v2020_05_01.models.PrivateLinkAssociationProperties """ - super(PrivateLinkAssociationObject, self).__init__(**kwargs) + super().__init__(**kwargs) self.properties = properties -class PrivateLinkAssociationProperties(msrest.serialization.Model): +class PrivateLinkAssociationProperties(_serialization.Model): """PrivateLinkAssociationProperties. :ivar private_link: The rmpl Resource ID. :vartype private_link: str - :ivar public_network_access: Possible values include: "Enabled", "Disabled". + :ivar public_network_access: Known values are: "Enabled" and "Disabled". :vartype public_network_access: str or ~azure.mgmt.resource.privatelinks.v2020_05_01.models.PublicNetworkAccessOptions """ _attribute_map = { - 'private_link': {'key': 'privateLink', 'type': 'str'}, - 'public_network_access': {'key': 'publicNetworkAccess', 'type': 'str'}, + "private_link": {"key": "privateLink", "type": "str"}, + "public_network_access": {"key": "publicNetworkAccess", "type": "str"}, } def __init__( self, *, private_link: Optional[str] = None, - public_network_access: Optional[Union[str, "PublicNetworkAccessOptions"]] = None, + public_network_access: Optional[Union[str, "_models.PublicNetworkAccessOptions"]] = None, **kwargs ): """ :keyword private_link: The rmpl Resource ID. :paramtype private_link: str - :keyword public_network_access: Possible values include: "Enabled", "Disabled". + :keyword public_network_access: Known values are: "Enabled" and "Disabled". :paramtype public_network_access: str or ~azure.mgmt.resource.privatelinks.v2020_05_01.models.PublicNetworkAccessOptions """ - super(PrivateLinkAssociationProperties, self).__init__(**kwargs) + super().__init__(**kwargs) self.private_link = private_link self.public_network_access = public_network_access -class PrivateLinkAssociationPropertiesExpanded(msrest.serialization.Model): +class PrivateLinkAssociationPropertiesExpanded(_serialization.Model): """Private Link Association Properties. :ivar private_link: The rmpl Resource ID. :vartype private_link: str - :ivar public_network_access: Possible values include: "Enabled", "Disabled". + :ivar public_network_access: Known values are: "Enabled" and "Disabled". :vartype public_network_access: str or ~azure.mgmt.resource.privatelinks.v2020_05_01.models.PublicNetworkAccessOptions :ivar tenant_id: The TenantID. @@ -243,17 +223,17 @@ class PrivateLinkAssociationPropertiesExpanded(msrest.serialization.Model): """ _attribute_map = { - 'private_link': {'key': 'privateLink', 'type': 'str'}, - 'public_network_access': {'key': 'publicNetworkAccess', 'type': 'str'}, - 'tenant_id': {'key': 'tenantID', 'type': 'str'}, - 'scope': {'key': 'scope', 'type': 'str'}, + "private_link": {"key": "privateLink", "type": "str"}, + "public_network_access": {"key": "publicNetworkAccess", "type": "str"}, + "tenant_id": {"key": "tenantID", "type": "str"}, + "scope": {"key": "scope", "type": "str"}, } def __init__( self, *, private_link: Optional[str] = None, - public_network_access: Optional[Union[str, "PublicNetworkAccessOptions"]] = None, + public_network_access: Optional[Union[str, "_models.PublicNetworkAccessOptions"]] = None, tenant_id: Optional[str] = None, scope: Optional[str] = None, **kwargs @@ -261,7 +241,7 @@ def __init__( """ :keyword private_link: The rmpl Resource ID. :paramtype private_link: str - :keyword public_network_access: Possible values include: "Enabled", "Disabled". + :keyword public_network_access: Known values are: "Enabled" and "Disabled". :paramtype public_network_access: str or ~azure.mgmt.resource.privatelinks.v2020_05_01.models.PublicNetworkAccessOptions :keyword tenant_id: The TenantID. @@ -269,14 +249,14 @@ def __init__( :keyword scope: The scope of the private link association. :paramtype scope: str """ - super(PrivateLinkAssociationPropertiesExpanded, self).__init__(**kwargs) + super().__init__(**kwargs) self.private_link = private_link self.public_network_access = public_network_access self.tenant_id = tenant_id self.scope = scope -class ResourceManagementPrivateLink(msrest.serialization.Model): +class ResourceManagementPrivateLink(_serialization.Model): """ResourceManagementPrivateLink. Variables are only populated by the server, and will be ignored when sending a request. @@ -295,23 +275,23 @@ class ResourceManagementPrivateLink(msrest.serialization.Model): """ _validation = { - 'id': {'readonly': True}, - 'name': {'readonly': True}, - 'type': {'readonly': True}, + "id": {"readonly": True}, + "name": {"readonly": True}, + "type": {"readonly": True}, } _attribute_map = { - 'properties': {'key': 'properties', 'type': 'ResourceManagementPrivateLinkEndpointConnections'}, - 'id': {'key': 'id', 'type': 'str'}, - 'name': {'key': 'name', 'type': 'str'}, - 'type': {'key': 'type', 'type': 'str'}, - 'location': {'key': 'location', 'type': 'str'}, + "properties": {"key": "properties", "type": "ResourceManagementPrivateLinkEndpointConnections"}, + "id": {"key": "id", "type": "str"}, + "name": {"key": "name", "type": "str"}, + "type": {"key": "type", "type": "str"}, + "location": {"key": "location", "type": "str"}, } def __init__( self, *, - properties: Optional["ResourceManagementPrivateLinkEndpointConnections"] = None, + properties: Optional["_models.ResourceManagementPrivateLinkEndpointConnections"] = None, location: Optional[str] = None, **kwargs ): @@ -322,7 +302,7 @@ def __init__( :keyword location: the region of the rmpl. :paramtype location: str """ - super(ResourceManagementPrivateLink, self).__init__(**kwargs) + super().__init__(**kwargs) self.properties = properties self.id = None self.name = None @@ -330,7 +310,7 @@ def __init__( self.location = location -class ResourceManagementPrivateLinkEndpointConnections(msrest.serialization.Model): +class ResourceManagementPrivateLinkEndpointConnections(_serialization.Model): """ResourceManagementPrivateLinkEndpointConnections. :ivar private_endpoint_connections: The private endpoint connections. @@ -338,24 +318,19 @@ class ResourceManagementPrivateLinkEndpointConnections(msrest.serialization.Mode """ _attribute_map = { - 'private_endpoint_connections': {'key': 'privateEndpointConnections', 'type': '[str]'}, + "private_endpoint_connections": {"key": "privateEndpointConnections", "type": "[str]"}, } - def __init__( - self, - *, - private_endpoint_connections: Optional[List[str]] = None, - **kwargs - ): + def __init__(self, *, private_endpoint_connections: Optional[List[str]] = None, **kwargs): """ :keyword private_endpoint_connections: The private endpoint connections. :paramtype private_endpoint_connections: list[str] """ - super(ResourceManagementPrivateLinkEndpointConnections, self).__init__(**kwargs) + super().__init__(**kwargs) self.private_endpoint_connections = private_endpoint_connections -class ResourceManagementPrivateLinkListResult(msrest.serialization.Model): +class ResourceManagementPrivateLinkListResult(_serialization.Model): """ResourceManagementPrivateLinkListResult. :ivar value: An array of resource management private links. @@ -364,25 +339,20 @@ class ResourceManagementPrivateLinkListResult(msrest.serialization.Model): """ _attribute_map = { - 'value': {'key': 'value', 'type': '[ResourceManagementPrivateLink]'}, + "value": {"key": "value", "type": "[ResourceManagementPrivateLink]"}, } - def __init__( - self, - *, - value: Optional[List["ResourceManagementPrivateLink"]] = None, - **kwargs - ): + def __init__(self, *, value: Optional[List["_models.ResourceManagementPrivateLink"]] = None, **kwargs): """ :keyword value: An array of resource management private links. :paramtype value: list[~azure.mgmt.resource.privatelinks.v2020_05_01.models.ResourceManagementPrivateLink] """ - super(ResourceManagementPrivateLinkListResult, self).__init__(**kwargs) + super().__init__(**kwargs) self.value = value -class ResourceManagementPrivateLinkLocation(msrest.serialization.Model): +class ResourceManagementPrivateLinkLocation(_serialization.Model): """ResourceManagementPrivateLinkLocation. :ivar location: the region to create private link association. @@ -390,18 +360,13 @@ class ResourceManagementPrivateLinkLocation(msrest.serialization.Model): """ _attribute_map = { - 'location': {'key': 'location', 'type': 'str'}, + "location": {"key": "location", "type": "str"}, } - def __init__( - self, - *, - location: Optional[str] = None, - **kwargs - ): + def __init__(self, *, location: Optional[str] = None, **kwargs): """ :keyword location: the region to create private link association. :paramtype location: str """ - super(ResourceManagementPrivateLinkLocation, self).__init__(**kwargs) + super().__init__(**kwargs) self.location = location diff --git a/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/privatelinks/v2020_05_01/models/_patch.py b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/privatelinks/v2020_05_01/models/_patch.py new file mode 100644 index 0000000000000..f7dd32510333d --- /dev/null +++ b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/privatelinks/v2020_05_01/models/_patch.py @@ -0,0 +1,20 @@ +# ------------------------------------ +# Copyright (c) Microsoft Corporation. +# Licensed under the MIT License. +# ------------------------------------ +"""Customize generated code here. + +Follow our quickstart for examples: https://aka.ms/azsdk/python/dpcodegen/python/customize +""" +from typing import List + +__all__: List[str] = [] # Add all objects you want publicly available to users at this package level + + +def patch_sdk(): + """Do not remove from this file. + + `patch_sdk` is a last resort escape hatch that allows you to do customizations + you can't accomplish using the techniques described in + https://aka.ms/azsdk/python/dpcodegen/python/customize + """ diff --git a/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/privatelinks/v2020_05_01/models/_resource_private_link_client_enums.py b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/privatelinks/v2020_05_01/models/_resource_private_link_client_enums.py index 67c84bd88b696..bf713fd07ea67 100644 --- a/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/privatelinks/v2020_05_01/models/_resource_private_link_client_enums.py +++ b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/privatelinks/v2020_05_01/models/_resource_private_link_client_enums.py @@ -7,11 +7,11 @@ # -------------------------------------------------------------------------- from enum import Enum -from six import with_metaclass from azure.core import CaseInsensitiveEnumMeta -class PublicNetworkAccessOptions(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): +class PublicNetworkAccessOptions(str, Enum, metaclass=CaseInsensitiveEnumMeta): + """PublicNetworkAccessOptions.""" ENABLED = "Enabled" DISABLED = "Disabled" diff --git a/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/privatelinks/v2020_05_01/operations/__init__.py b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/privatelinks/v2020_05_01/operations/__init__.py index 56aef7386788c..07a01cf18452f 100644 --- a/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/privatelinks/v2020_05_01/operations/__init__.py +++ b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/privatelinks/v2020_05_01/operations/__init__.py @@ -9,7 +9,13 @@ from ._operations import PrivateLinkAssociationOperations from ._operations import ResourceManagementPrivateLinkOperations +from ._patch import __all__ as _patch_all +from ._patch import * # type: ignore # pylint: disable=unused-wildcard-import +from ._patch import patch_sdk as _patch_sdk + __all__ = [ - 'PrivateLinkAssociationOperations', - 'ResourceManagementPrivateLinkOperations', + "PrivateLinkAssociationOperations", + "ResourceManagementPrivateLinkOperations", ] +__all__.extend([p for p in _patch_all if p not in __all__]) +_patch_sdk() diff --git a/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/privatelinks/v2020_05_01/operations/_operations.py b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/privatelinks/v2020_05_01/operations/_operations.py index a92dcd2209146..016462c39f629 100644 --- a/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/privatelinks/v2020_05_01/operations/_operations.py +++ b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/privatelinks/v2020_05_01/operations/_operations.py @@ -6,403 +6,421 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -from typing import Any, Callable, Dict, Optional, TypeVar - -from msrest import Serializer - -from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error +from typing import Any, Callable, Dict, IO, Optional, TypeVar, Union, overload + +from azure.core.exceptions import ( + ClientAuthenticationError, + HttpResponseError, + ResourceExistsError, + ResourceNotFoundError, + ResourceNotModifiedError, + map_error, +) from azure.core.pipeline import PipelineResponse from azure.core.pipeline.transport import HttpResponse from azure.core.rest import HttpRequest from azure.core.tracing.decorator import distributed_trace +from azure.core.utils import case_insensitive_dict from azure.mgmt.core.exceptions import ARMErrorFormat from .. import models as _models +from ..._serialization import Serializer from .._vendor import _convert_request, _format_url_section -T = TypeVar('T') -JSONType = Any + +T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] _SERIALIZER = Serializer() _SERIALIZER.client_side_validation = False -def build_private_link_association_put_request( - group_id: str, - pla_id: str, - *, - json: JSONType = None, - content: Any = None, - **kwargs: Any -) -> HttpRequest: - api_version = kwargs.pop('api_version', "2020-05-01") # type: str - content_type = kwargs.pop('content_type', None) # type: Optional[str] - accept = "application/json" +def build_private_link_association_put_request(group_id: str, pla_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", "2020-05-01")) # type: str + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + accept = _headers.pop("Accept", "application/json") + # Construct URL - _url = kwargs.pop("template_url", "/providers/Microsoft.Management/managementGroups/{groupId}/providers/Microsoft.Authorization/privateLinkAssociations/{plaId}") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", + "/providers/Microsoft.Management/managementGroups/{groupId}/providers/Microsoft.Authorization/privateLinkAssociations/{plaId}", + ) # pylint: disable=line-too-long path_format_arguments = { - "groupId": _SERIALIZER.url("group_id", group_id, 'str', max_length=90, min_length=1), - "plaId": _SERIALIZER.url("pla_id", pla_id, 'str'), + "groupId": _SERIALIZER.url("group_id", group_id, "str", max_length=90, min_length=1), + "plaId": _SERIALIZER.url("pla_id", pla_id, "str"), } _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] if content_type is not None: - _header_parameters['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') - _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') - - return HttpRequest( - method="PUT", - url=_url, - params=_query_parameters, - headers=_header_parameters, - json=json, - content=content, - **kwargs - ) - - -def build_private_link_association_get_request( - group_id: str, - pla_id: str, - **kwargs: Any -) -> HttpRequest: - api_version = kwargs.pop('api_version', "2020-05-01") # type: str + _headers["Content-Type"] = _SERIALIZER.header("content_type", content_type, "str") + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="PUT", url=_url, params=_params, headers=_headers, **kwargs) + + +def build_private_link_association_get_request(group_id: str, pla_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", "2020-05-01")) # type: str + accept = _headers.pop("Accept", "application/json") - accept = "application/json" # Construct URL - _url = kwargs.pop("template_url", "/providers/Microsoft.Management/managementGroups/{groupId}/providers/Microsoft.Authorization/privateLinkAssociations/{plaId}") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", + "/providers/Microsoft.Management/managementGroups/{groupId}/providers/Microsoft.Authorization/privateLinkAssociations/{plaId}", + ) # pylint: disable=line-too-long path_format_arguments = { - "groupId": _SERIALIZER.url("group_id", group_id, 'str', max_length=90, min_length=1), - "plaId": _SERIALIZER.url("pla_id", pla_id, 'str'), + "groupId": _SERIALIZER.url("group_id", group_id, "str", max_length=90, min_length=1), + "plaId": _SERIALIZER.url("pla_id", pla_id, "str"), } _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') - - return HttpRequest( - method="GET", - url=_url, - params=_query_parameters, - headers=_header_parameters, - **kwargs - ) - - -def build_private_link_association_delete_request( - group_id: str, - pla_id: str, - **kwargs: Any -) -> HttpRequest: - api_version = kwargs.pop('api_version', "2020-05-01") # type: str + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) + + +def build_private_link_association_delete_request(group_id: str, pla_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", "2020-05-01")) # type: str + accept = _headers.pop("Accept", "application/json") - accept = "application/json" # Construct URL - _url = kwargs.pop("template_url", "/providers/Microsoft.Management/managementGroups/{groupId}/providers/Microsoft.Authorization/privateLinkAssociations/{plaId}") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", + "/providers/Microsoft.Management/managementGroups/{groupId}/providers/Microsoft.Authorization/privateLinkAssociations/{plaId}", + ) # pylint: disable=line-too-long path_format_arguments = { - "groupId": _SERIALIZER.url("group_id", group_id, 'str', max_length=90, min_length=1), - "plaId": _SERIALIZER.url("pla_id", pla_id, 'str'), + "groupId": _SERIALIZER.url("group_id", group_id, "str", max_length=90, min_length=1), + "plaId": _SERIALIZER.url("pla_id", pla_id, "str"), } _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - return HttpRequest( - method="DELETE", - url=_url, - params=_query_parameters, - headers=_header_parameters, - **kwargs - ) + return HttpRequest(method="DELETE", url=_url, params=_params, headers=_headers, **kwargs) -def build_private_link_association_list_request( - group_id: str, - **kwargs: Any -) -> HttpRequest: - api_version = kwargs.pop('api_version', "2020-05-01") # type: str +def build_private_link_association_list_request(group_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", "2020-05-01")) # type: str + accept = _headers.pop("Accept", "application/json") - accept = "application/json" # Construct URL - _url = kwargs.pop("template_url", "/providers/Microsoft.Management/managementGroups/{groupId}/providers/Microsoft.Authorization/privateLinkAssociations") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", + "/providers/Microsoft.Management/managementGroups/{groupId}/providers/Microsoft.Authorization/privateLinkAssociations", + ) # pylint: disable=line-too-long path_format_arguments = { - "groupId": _SERIALIZER.url("group_id", group_id, 'str', max_length=90, min_length=1), + "groupId": _SERIALIZER.url("group_id", group_id, "str", max_length=90, min_length=1), } _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - return HttpRequest( - method="GET", - url=_url, - params=_query_parameters, - headers=_header_parameters, - **kwargs - ) + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) def build_resource_management_private_link_put_request( - subscription_id: str, - resource_group_name: str, - rmpl_name: str, - *, - json: JSONType = None, - content: Any = None, - **kwargs: Any + resource_group_name: str, rmpl_name: str, subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2020-05-01") # type: str - content_type = kwargs.pop('content_type', None) # type: Optional[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", "2020-05-01")) # type: str + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + accept = _headers.pop("Accept", "application/json") - accept = "application/json" # Construct URL - _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Authorization/resourceManagementPrivateLinks/{rmplName}") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Authorization/resourceManagementPrivateLinks/{rmplName}", + ) # pylint: disable=line-too-long path_format_arguments = { - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1), - "rmplName": _SERIALIZER.url("rmpl_name", rmpl_name, 'str'), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url( + "resource_group_name", resource_group_name, "str", max_length=90, min_length=1 + ), + "rmplName": _SERIALIZER.url("rmpl_name", rmpl_name, "str"), } _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] if content_type is not None: - _header_parameters['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') - _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers["Content-Type"] = _SERIALIZER.header("content_type", content_type, "str") + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - return HttpRequest( - method="PUT", - url=_url, - params=_query_parameters, - headers=_header_parameters, - json=json, - content=content, - **kwargs - ) + return HttpRequest(method="PUT", url=_url, params=_params, headers=_headers, **kwargs) def build_resource_management_private_link_get_request( - subscription_id: str, - resource_group_name: str, - rmpl_name: str, - **kwargs: Any + resource_group_name: str, rmpl_name: str, subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2020-05-01") # type: 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", "2020-05-01")) # type: str + accept = _headers.pop("Accept", "application/json") - accept = "application/json" # Construct URL - _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Authorization/resourceManagementPrivateLinks/{rmplName}") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Authorization/resourceManagementPrivateLinks/{rmplName}", + ) # pylint: disable=line-too-long path_format_arguments = { - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1), - "rmplName": _SERIALIZER.url("rmpl_name", rmpl_name, 'str'), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url( + "resource_group_name", resource_group_name, "str", max_length=90, min_length=1 + ), + "rmplName": _SERIALIZER.url("rmpl_name", rmpl_name, "str"), } _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - return HttpRequest( - method="GET", - url=_url, - params=_query_parameters, - headers=_header_parameters, - **kwargs - ) + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) def build_resource_management_private_link_delete_request( - subscription_id: str, - resource_group_name: str, - rmpl_name: str, - **kwargs: Any + resource_group_name: str, rmpl_name: str, subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2020-05-01") # type: 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", "2020-05-01")) # type: str + accept = _headers.pop("Accept", "application/json") - accept = "application/json" # Construct URL - _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Authorization/resourceManagementPrivateLinks/{rmplName}") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Authorization/resourceManagementPrivateLinks/{rmplName}", + ) # pylint: disable=line-too-long path_format_arguments = { - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1), - "rmplName": _SERIALIZER.url("rmpl_name", rmpl_name, 'str'), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url( + "resource_group_name", resource_group_name, "str", max_length=90, min_length=1 + ), + "rmplName": _SERIALIZER.url("rmpl_name", rmpl_name, "str"), } _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - return HttpRequest( - method="DELETE", - url=_url, - params=_query_parameters, - headers=_header_parameters, - **kwargs - ) + return HttpRequest(method="DELETE", url=_url, params=_params, headers=_headers, **kwargs) -def build_resource_management_private_link_list_request( - subscription_id: str, - **kwargs: Any -) -> HttpRequest: - api_version = kwargs.pop('api_version', "2020-05-01") # type: str +def build_resource_management_private_link_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", "2020-05-01")) # type: str + accept = _headers.pop("Accept", "application/json") - accept = "application/json" # Construct URL - _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/providers/Microsoft.Authorization/resourceManagementPrivateLinks") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/providers/Microsoft.Authorization/resourceManagementPrivateLinks", + ) # pylint: disable=line-too-long path_format_arguments = { - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), } _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - return HttpRequest( - method="GET", - url=_url, - params=_query_parameters, - headers=_header_parameters, - **kwargs - ) + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) def build_resource_management_private_link_list_by_resource_group_request( - subscription_id: str, - resource_group_name: str, - **kwargs: Any + resource_group_name: str, subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2020-05-01") # type: 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", "2020-05-01")) # type: str + accept = _headers.pop("Accept", "application/json") - accept = "application/json" # Construct URL - _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Authorization/resourceManagementPrivateLinks") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Authorization/resourceManagementPrivateLinks", + ) # pylint: disable=line-too-long path_format_arguments = { - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url( + "resource_group_name", resource_group_name, "str", max_length=90, min_length=1 + ), } _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') - - return HttpRequest( - method="GET", - url=_url, - params=_query_parameters, - headers=_header_parameters, - **kwargs - ) - -class PrivateLinkAssociationOperations(object): - """PrivateLinkAssociationOperations operations. - - You should not instantiate this class directly. Instead, you should create a Client instance that - instantiates it for you and attaches it as an attribute. - - :ivar models: Alias to model classes used in this operation group. - :type models: ~azure.mgmt.resource.privatelinks.v2020_05_01.models - :param client: Client for service requests. - :param config: Configuration of service client. - :param serializer: An object model serializer. - :param deserializer: An object model deserializer. + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) + + +class PrivateLinkAssociationOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. + + Instead, you should access the following operations through + :class:`~azure.mgmt.resource.privatelinks.v2020_05_01.ResourcePrivateLinkClient`'s + :attr:`private_link_association` attribute. """ models = _models - def __init__(self, client, config, serializer, deserializer): - self._client = client - self._serialize = serializer - self._deserialize = deserializer - self._config = config + def __init__(self, *args, **kwargs): + input_args = list(args) + self._client = input_args.pop(0) if input_args else kwargs.pop("client") + self._config = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") - @distributed_trace + @overload def put( self, group_id: str, pla_id: str, - parameters: "_models.PrivateLinkAssociationObject", + parameters: _models.PrivateLinkAssociationObject, + *, + content_type: str = "application/json", **kwargs: Any - ) -> "_models.PrivateLinkAssociation": + ) -> _models.PrivateLinkAssociation: """Create a PrivateLinkAssociation. - :param group_id: The management group ID. + :param group_id: The management group ID. Required. :type group_id: str - :param pla_id: The ID of the PLA. + :param pla_id: The ID of the PLA. Required. :type pla_id: str - :param parameters: Parameters supplied to create the private link association. + :param parameters: Parameters supplied to create the private link association. Required. :type parameters: ~azure.mgmt.resource.privatelinks.v2020_05_01.models.PrivateLinkAssociationObject + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: PrivateLinkAssociation or the result of cls(response) + :rtype: ~azure.mgmt.resource.privatelinks.v2020_05_01.models.PrivateLinkAssociation + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + def put( + self, group_id: str, pla_id: str, parameters: IO, *, content_type: str = "application/json", **kwargs: Any + ) -> _models.PrivateLinkAssociation: + """Create a PrivateLinkAssociation. + + :param group_id: The management group ID. Required. + :type group_id: str + :param pla_id: The ID of the PLA. Required. + :type pla_id: str + :param parameters: Parameters supplied to create the private link association. Required. + :type parameters: IO + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: PrivateLinkAssociation or the result of cls(response) + :rtype: ~azure.mgmt.resource.privatelinks.v2020_05_01.models.PrivateLinkAssociation + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace + def put( + self, group_id: str, pla_id: str, parameters: Union[_models.PrivateLinkAssociationObject, IO], **kwargs: Any + ) -> _models.PrivateLinkAssociation: + """Create a PrivateLinkAssociation. + + :param group_id: The management group ID. Required. + :type group_id: str + :param pla_id: The ID of the PLA. Required. + :type pla_id: str + :param parameters: Parameters supplied to create the private link association. Is either a + model type or a IO type. Required. + :type parameters: + ~azure.mgmt.resource.privatelinks.v2020_05_01.models.PrivateLinkAssociationObject or IO + :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. + Default value is None. + :paramtype content_type: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: PrivateLinkAssociation, or the result of cls(response) + :return: PrivateLinkAssociation or the result of cls(response) :rtype: ~azure.mgmt.resource.privatelinks.v2020_05_01.models.PrivateLinkAssociation - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.PrivateLinkAssociation"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', "2020-05-01") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + api_version = kwargs.pop("api_version", _params.pop("api-version", "2020-05-01")) # type: str + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.PrivateLinkAssociation] - _json = self._serialize.body(parameters, 'PrivateLinkAssociationObject') + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(parameters, (IO, bytes)): + _content = parameters + else: + _json = self._serialize.body(parameters, "PrivateLinkAssociationObject") request = build_private_link_association_put_request( group_id=group_id, @@ -410,16 +428,18 @@ def put( api_version=api_version, content_type=content_type, json=_json, - template_url=self.put.metadata['url'], + content=_content, + template_url=self.put.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200, 201]: @@ -427,117 +447,119 @@ def put( raise HttpResponseError(response=response, error_format=ARMErrorFormat) if response.status_code == 200: - deserialized = self._deserialize('PrivateLinkAssociation', pipeline_response) + deserialized = self._deserialize("PrivateLinkAssociation", pipeline_response) if response.status_code == 201: - deserialized = self._deserialize('PrivateLinkAssociation', pipeline_response) + deserialized = self._deserialize("PrivateLinkAssociation", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - put.metadata = {'url': "/providers/Microsoft.Management/managementGroups/{groupId}/providers/Microsoft.Authorization/privateLinkAssociations/{plaId}"} # type: ignore - + put.metadata = {"url": "/providers/Microsoft.Management/managementGroups/{groupId}/providers/Microsoft.Authorization/privateLinkAssociations/{plaId}"} # type: ignore @distributed_trace - def get( - self, - group_id: str, - pla_id: str, - **kwargs: Any - ) -> "_models.PrivateLinkAssociation": + def get(self, group_id: str, pla_id: str, **kwargs: Any) -> _models.PrivateLinkAssociation: """Get a single private link association. - :param group_id: The management group ID. + :param group_id: The management group ID. Required. :type group_id: str - :param pla_id: The ID of the PLA. + :param pla_id: The ID of the PLA. Required. :type pla_id: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: PrivateLinkAssociation, or the result of cls(response) + :return: PrivateLinkAssociation or the result of cls(response) :rtype: ~azure.mgmt.resource.privatelinks.v2020_05_01.models.PrivateLinkAssociation - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.PrivateLinkAssociation"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + 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', "2020-05-01") # type: str + api_version = kwargs.pop("api_version", _params.pop("api-version", "2020-05-01")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[_models.PrivateLinkAssociation] - request = build_private_link_association_get_request( group_id=group_id, pla_id=pla_id, api_version=api_version, - template_url=self.get.metadata['url'], + template_url=self.get.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) - deserialized = self._deserialize('PrivateLinkAssociation', pipeline_response) + deserialized = self._deserialize("PrivateLinkAssociation", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - get.metadata = {'url': "/providers/Microsoft.Management/managementGroups/{groupId}/providers/Microsoft.Authorization/privateLinkAssociations/{plaId}"} # type: ignore - + get.metadata = {"url": "/providers/Microsoft.Management/managementGroups/{groupId}/providers/Microsoft.Authorization/privateLinkAssociations/{plaId}"} # type: ignore @distributed_trace def delete( # pylint: disable=inconsistent-return-statements - self, - group_id: str, - pla_id: str, - **kwargs: Any + self, group_id: str, pla_id: str, **kwargs: Any ) -> None: """Delete a PrivateLinkAssociation. - :param group_id: The management group ID. + :param group_id: The management group ID. Required. :type group_id: str - :param pla_id: The ID of the PLA. + :param pla_id: The ID of the PLA. Required. :type pla_id: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: None, or the result of cls(response) + :return: None or the result of cls(response) :rtype: None - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType[None] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) - api_version = kwargs.pop('api_version', "2020-05-01") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2020-05-01")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[None] - request = build_private_link_association_delete_request( group_id=group_id, pla_id=pla_id, api_version=api_version, - template_url=self.delete.metadata['url'], + template_url=self.delete.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200, 204]: @@ -547,133 +569,209 @@ def delete( # pylint: disable=inconsistent-return-statements if cls: return cls(pipeline_response, None, {}) - delete.metadata = {'url': "/providers/Microsoft.Management/managementGroups/{groupId}/providers/Microsoft.Authorization/privateLinkAssociations/{plaId}"} # type: ignore - + delete.metadata = {"url": "/providers/Microsoft.Management/managementGroups/{groupId}/providers/Microsoft.Authorization/privateLinkAssociations/{plaId}"} # type: ignore @distributed_trace - def list( - self, - group_id: str, - **kwargs: Any - ) -> "_models.PrivateLinkAssociationGetResult": + def list(self, group_id: str, **kwargs: Any) -> _models.PrivateLinkAssociationGetResult: """Get a private link association for a management group scope. - :param group_id: The management group ID. + :param group_id: The management group ID. Required. :type group_id: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: PrivateLinkAssociationGetResult, or the result of cls(response) + :return: PrivateLinkAssociationGetResult or the result of cls(response) :rtype: ~azure.mgmt.resource.privatelinks.v2020_05_01.models.PrivateLinkAssociationGetResult - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.PrivateLinkAssociationGetResult"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) - api_version = kwargs.pop('api_version', "2020-05-01") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2020-05-01")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[_models.PrivateLinkAssociationGetResult] - request = build_private_link_association_list_request( group_id=group_id, api_version=api_version, - template_url=self.list.metadata['url'], + template_url=self.list.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) - deserialized = self._deserialize('PrivateLinkAssociationGetResult', pipeline_response) + deserialized = self._deserialize("PrivateLinkAssociationGetResult", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - list.metadata = {'url': "/providers/Microsoft.Management/managementGroups/{groupId}/providers/Microsoft.Authorization/privateLinkAssociations"} # type: ignore + list.metadata = {"url": "/providers/Microsoft.Management/managementGroups/{groupId}/providers/Microsoft.Authorization/privateLinkAssociations"} # type: ignore -class ResourceManagementPrivateLinkOperations(object): - """ResourceManagementPrivateLinkOperations operations. - You should not instantiate this class directly. Instead, you should create a Client instance that - instantiates it for you and attaches it as an attribute. +class ResourceManagementPrivateLinkOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. - :ivar models: Alias to model classes used in this operation group. - :type models: ~azure.mgmt.resource.privatelinks.v2020_05_01.models - :param client: Client for service requests. - :param config: Configuration of service client. - :param serializer: An object model serializer. - :param deserializer: An object model deserializer. + Instead, you should access the following operations through + :class:`~azure.mgmt.resource.privatelinks.v2020_05_01.ResourcePrivateLinkClient`'s + :attr:`resource_management_private_link` attribute. """ models = _models - def __init__(self, client, config, serializer, deserializer): - self._client = client - self._serialize = serializer - self._deserialize = deserializer - self._config = config + def __init__(self, *args, **kwargs): + input_args = list(args) + self._client = input_args.pop(0) if input_args else kwargs.pop("client") + self._config = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") - @distributed_trace + @overload def put( self, resource_group_name: str, rmpl_name: str, - parameters: "_models.ResourceManagementPrivateLinkLocation", + parameters: _models.ResourceManagementPrivateLinkLocation, + *, + content_type: str = "application/json", **kwargs: Any - ) -> "_models.ResourceManagementPrivateLink": + ) -> _models.ResourceManagementPrivateLink: """Create a resource management group private link. :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. :type resource_group_name: str - :param rmpl_name: The name of the resource management private link. + :param rmpl_name: The name of the resource management private link. Required. :type rmpl_name: str - :param parameters: The region to create the Resource Management private link. + :param parameters: The region to create the Resource Management private link. Required. :type parameters: ~azure.mgmt.resource.privatelinks.v2020_05_01.models.ResourceManagementPrivateLinkLocation + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: ResourceManagementPrivateLink or the result of cls(response) + :rtype: ~azure.mgmt.resource.privatelinks.v2020_05_01.models.ResourceManagementPrivateLink + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + def put( + self, + resource_group_name: str, + rmpl_name: str, + parameters: IO, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.ResourceManagementPrivateLink: + """Create a resource management group private link. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param rmpl_name: The name of the resource management private link. Required. + :type rmpl_name: str + :param parameters: The region to create the Resource Management private link. Required. + :type parameters: IO + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: ResourceManagementPrivateLink, or the result of cls(response) + :return: ResourceManagementPrivateLink or the result of cls(response) :rtype: ~azure.mgmt.resource.privatelinks.v2020_05_01.models.ResourceManagementPrivateLink - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace + def put( + self, + resource_group_name: str, + rmpl_name: str, + parameters: Union[_models.ResourceManagementPrivateLinkLocation, IO], + **kwargs: Any + ) -> _models.ResourceManagementPrivateLink: + """Create a resource management group private link. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param rmpl_name: The name of the resource management private link. Required. + :type rmpl_name: str + :param parameters: The region to create the Resource Management private link. Is either a model + type or a IO type. Required. + :type parameters: + ~azure.mgmt.resource.privatelinks.v2020_05_01.models.ResourceManagementPrivateLinkLocation or + IO + :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. + Default value is None. + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: ResourceManagementPrivateLink or the result of cls(response) + :rtype: ~azure.mgmt.resource.privatelinks.v2020_05_01.models.ResourceManagementPrivateLink + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.ResourceManagementPrivateLink"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', "2020-05-01") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + api_version = kwargs.pop("api_version", _params.pop("api-version", "2020-05-01")) # type: str + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.ResourceManagementPrivateLink] - _json = self._serialize.body(parameters, 'ResourceManagementPrivateLinkLocation') + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(parameters, (IO, bytes)): + _content = parameters + else: + _json = self._serialize.body(parameters, "ResourceManagementPrivateLinkLocation") request = build_resource_management_private_link_put_request( - subscription_id=self._config.subscription_id, resource_group_name=resource_group_name, rmpl_name=rmpl_name, + subscription_id=self._config.subscription_id, api_version=api_version, content_type=content_type, json=_json, - template_url=self.put.metadata['url'], + content=_content, + template_url=self.put.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200, 201]: @@ -681,119 +779,123 @@ def put( raise HttpResponseError(response=response, error_format=ARMErrorFormat) if response.status_code == 200: - deserialized = self._deserialize('ResourceManagementPrivateLink', pipeline_response) + deserialized = self._deserialize("ResourceManagementPrivateLink", pipeline_response) if response.status_code == 201: - deserialized = self._deserialize('ResourceManagementPrivateLink', pipeline_response) + deserialized = self._deserialize("ResourceManagementPrivateLink", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - put.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Authorization/resourceManagementPrivateLinks/{rmplName}"} # type: ignore - + put.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Authorization/resourceManagementPrivateLinks/{rmplName}"} # type: ignore @distributed_trace - def get( - self, - resource_group_name: str, - rmpl_name: str, - **kwargs: Any - ) -> "_models.ResourceManagementPrivateLink": + def get(self, resource_group_name: str, rmpl_name: str, **kwargs: Any) -> _models.ResourceManagementPrivateLink: """Get a resource management private link(resource-level). :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. :type resource_group_name: str - :param rmpl_name: The name of the resource management private link. + :param rmpl_name: The name of the resource management private link. Required. :type rmpl_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: ResourceManagementPrivateLink, or the result of cls(response) + :return: ResourceManagementPrivateLink or the result of cls(response) :rtype: ~azure.mgmt.resource.privatelinks.v2020_05_01.models.ResourceManagementPrivateLink - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.ResourceManagementPrivateLink"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + 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', "2020-05-01") # type: str + api_version = kwargs.pop("api_version", _params.pop("api-version", "2020-05-01")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[_models.ResourceManagementPrivateLink] - request = build_resource_management_private_link_get_request( - subscription_id=self._config.subscription_id, resource_group_name=resource_group_name, rmpl_name=rmpl_name, + subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.get.metadata['url'], + template_url=self.get.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) - deserialized = self._deserialize('ResourceManagementPrivateLink', pipeline_response) + deserialized = self._deserialize("ResourceManagementPrivateLink", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - get.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Authorization/resourceManagementPrivateLinks/{rmplName}"} # type: ignore - + get.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Authorization/resourceManagementPrivateLinks/{rmplName}"} # type: ignore @distributed_trace def delete( # pylint: disable=inconsistent-return-statements - self, - resource_group_name: str, - rmpl_name: str, - **kwargs: Any + self, resource_group_name: str, rmpl_name: str, **kwargs: Any ) -> None: """Delete a resource management private link. :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. :type resource_group_name: str - :param rmpl_name: The name of the resource management private link. + :param rmpl_name: The name of the resource management private link. Required. :type rmpl_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: None, or the result of cls(response) + :return: None or the result of cls(response) :rtype: None - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType[None] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + 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', "2020-05-01") # type: str + api_version = kwargs.pop("api_version", _params.pop("api-version", "2020-05-01")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[None] - request = build_resource_management_private_link_delete_request( - subscription_id=self._config.subscription_id, resource_group_name=resource_group_name, rmpl_name=rmpl_name, + subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.delete.metadata['url'], + template_url=self.delete.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200, 204]: @@ -803,111 +905,116 @@ def delete( # pylint: disable=inconsistent-return-statements if cls: return cls(pipeline_response, None, {}) - delete.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Authorization/resourceManagementPrivateLinks/{rmplName}"} # type: ignore - + delete.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Authorization/resourceManagementPrivateLinks/{rmplName}"} # type: ignore @distributed_trace - def list( - self, - **kwargs: Any - ) -> "_models.ResourceManagementPrivateLinkListResult": + def list(self, **kwargs: Any) -> _models.ResourceManagementPrivateLinkListResult: """Get all the resource management private links in a subscription. :keyword callable cls: A custom type or function that will be passed the direct response - :return: ResourceManagementPrivateLinkListResult, or the result of cls(response) + :return: ResourceManagementPrivateLinkListResult or the result of cls(response) :rtype: ~azure.mgmt.resource.privatelinks.v2020_05_01.models.ResourceManagementPrivateLinkListResult - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.ResourceManagementPrivateLinkListResult"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + 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', "2020-05-01") # type: str + api_version = kwargs.pop("api_version", _params.pop("api-version", "2020-05-01")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[_models.ResourceManagementPrivateLinkListResult] - request = build_resource_management_private_link_list_request( subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.list.metadata['url'], + template_url=self.list.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) - deserialized = self._deserialize('ResourceManagementPrivateLinkListResult', pipeline_response) + deserialized = self._deserialize("ResourceManagementPrivateLinkListResult", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - list.metadata = {'url': "/subscriptions/{subscriptionId}/providers/Microsoft.Authorization/resourceManagementPrivateLinks"} # type: ignore - + list.metadata = {"url": "/subscriptions/{subscriptionId}/providers/Microsoft.Authorization/resourceManagementPrivateLinks"} # type: ignore @distributed_trace def list_by_resource_group( - self, - resource_group_name: str, - **kwargs: Any - ) -> "_models.ResourceManagementPrivateLinkListResult": + self, resource_group_name: str, **kwargs: Any + ) -> _models.ResourceManagementPrivateLinkListResult: """Get all the resource management private links in a resource group. :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. :type resource_group_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: ResourceManagementPrivateLinkListResult, or the result of cls(response) + :return: ResourceManagementPrivateLinkListResult or the result of cls(response) :rtype: ~azure.mgmt.resource.privatelinks.v2020_05_01.models.ResourceManagementPrivateLinkListResult - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.ResourceManagementPrivateLinkListResult"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + 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', "2020-05-01") # type: str + api_version = kwargs.pop("api_version", _params.pop("api-version", "2020-05-01")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[_models.ResourceManagementPrivateLinkListResult] - request = build_resource_management_private_link_list_by_resource_group_request( - subscription_id=self._config.subscription_id, 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'], + 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.url = self._client.format_url(request.url) # type: ignore - pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) - deserialized = self._deserialize('ResourceManagementPrivateLinkListResult', pipeline_response) + deserialized = self._deserialize("ResourceManagementPrivateLinkListResult", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - list_by_resource_group.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Authorization/resourceManagementPrivateLinks"} # type: ignore - + list_by_resource_group.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Authorization/resourceManagementPrivateLinks"} # type: ignore diff --git a/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/privatelinks/v2020_05_01/operations/_patch.py b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/privatelinks/v2020_05_01/operations/_patch.py new file mode 100644 index 0000000000000..f7dd32510333d --- /dev/null +++ b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/privatelinks/v2020_05_01/operations/_patch.py @@ -0,0 +1,20 @@ +# ------------------------------------ +# Copyright (c) Microsoft Corporation. +# Licensed under the MIT License. +# ------------------------------------ +"""Customize generated code here. + +Follow our quickstart for examples: https://aka.ms/azsdk/python/dpcodegen/python/customize +""" +from typing import List + +__all__: List[str] = [] # Add all objects you want publicly available to users at this package level + + +def patch_sdk(): + """Do not remove from this file. + + `patch_sdk` is a last resort escape hatch that allows you to do customizations + you can't accomplish using the techniques described in + https://aka.ms/azsdk/python/dpcodegen/python/customize + """ diff --git a/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/resources/__init__.py b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/resources/__init__.py index 07fb5205b898a..f8fba53f9a0e6 100644 --- a/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/resources/__init__.py +++ b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/resources/__init__.py @@ -14,3 +14,7 @@ patch_sdk() except ImportError: pass + +from ._version import VERSION + +__version__ = VERSION diff --git a/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/resources/_configuration.py b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/resources/_configuration.py index 52422f4e9cded..811c96df4fbb9 100644 --- a/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/resources/_configuration.py +++ b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/resources/_configuration.py @@ -8,7 +8,7 @@ # Changes may cause incorrect behavior and will be lost if the code is # regenerated. # -------------------------------------------------------------------------- -from typing import TYPE_CHECKING +from typing import Any, TYPE_CHECKING from azure.core.configuration import Configuration from azure.core.pipeline import policies @@ -18,8 +18,6 @@ if TYPE_CHECKING: # pylint: disable=unused-import,ungrouped-imports - from typing import Any - from azure.core.credentials import TokenCredential class ResourceManagementClientConfiguration(Configuration): @@ -28,16 +26,16 @@ class ResourceManagementClientConfiguration(Configuration): Note that all parameters used to create this instance are saved as instance attributes. - :param credential: Credential needed for the client to connect to Azure. + :param credential: Credential needed for the client to connect to Azure. Required. :type credential: ~azure.core.credentials.TokenCredential - :param subscription_id: The Microsoft Azure subscription ID. + :param subscription_id: The Microsoft Azure subscription ID. Required. :type subscription_id: str """ def __init__( self, - credential, # type: "TokenCredential" - subscription_id, # type: str + credential: "TokenCredential", + subscription_id: str, **kwargs # type: Any ): # type: (...) -> None diff --git a/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/resources/_resource_management_client.py b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/resources/_resource_management_client.py index 3b84bfb69970d..00c13ecdf8d57 100644 --- a/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/resources/_resource_management_client.py +++ b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/resources/_resource_management_client.py @@ -9,20 +9,17 @@ # regenerated. # -------------------------------------------------------------------------- -from typing import TYPE_CHECKING - -from msrest import Deserializer, Serializer +from typing import Any, Optional, TYPE_CHECKING from azure.mgmt.core import ARMPipelineClient from azure.profiles import KnownProfiles, ProfileDefinition from azure.profiles.multiapiclient import MultiApiClientMixin from ._configuration import ResourceManagementClientConfiguration +from ._serialization import Deserializer, Serializer if TYPE_CHECKING: # pylint: disable=unused-import,ungrouped-imports - from typing import Any, Optional - from azure.core.credentials import TokenCredential class _SDKClient(object): @@ -43,9 +40,9 @@ class ResourceManagementClient(MultiApiClientMixin, _SDKClient): The api-version parameter sets the default API version if the operation group is not described in the profile. - :param credential: Credential needed for the client to connect to Azure. + :param credential: Credential needed for the client to connect to Azure. Required. :type credential: ~azure.core.credentials.TokenCredential - :param subscription_id: The Microsoft Azure subscription ID. + :param subscription_id: The Microsoft Azure subscription ID. Required. :type subscription_id: str :param api_version: API version to use if no profile is provided, or if missing in profile. :type api_version: str @@ -67,10 +64,10 @@ class ResourceManagementClient(MultiApiClientMixin, _SDKClient): def __init__( self, - credential, # type: "TokenCredential" - subscription_id, # type: str + credential: "TokenCredential", + subscription_id: str, api_version=None, # type: Optional[str] - base_url="https://management.azure.com", # type: str + base_url: str = "https://management.azure.com", profile=KnownProfiles.default, # type: KnownProfiles **kwargs # type: Any ): diff --git a/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/resources/_serialization.py b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/resources/_serialization.py new file mode 100644 index 0000000000000..240df16c57f3c --- /dev/null +++ b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/resources/_serialization.py @@ -0,0 +1,2006 @@ +# -------------------------------------------------------------------------- +# +# Copyright (c) Microsoft Corporation. All rights reserved. +# +# The MIT License (MIT) +# +# Permission is hereby granted, free of charge, to any person obtaining a copy +# of this software and associated documentation files (the ""Software""), to +# deal in the Software without restriction, including without limitation the +# rights to use, copy, modify, merge, publish, distribute, sublicense, and/or +# sell copies of the Software, and to permit persons to whom the Software is +# furnished to do so, subject to the following conditions: +# +# The above copyright notice and this permission notice shall be included in +# all copies or substantial portions of the Software. +# +# THE SOFTWARE IS PROVIDED *AS IS*, WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING +# FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS +# IN THE SOFTWARE. +# +# -------------------------------------------------------------------------- + +# pylint: skip-file + +from base64 import b64decode, b64encode +import calendar +import datetime +import decimal +import email +from enum import Enum +import json +import logging +import re +import sys +import codecs +try: + from urllib import quote # type: ignore +except ImportError: + from urllib.parse import quote # type: ignore +import xml.etree.ElementTree as ET + +import isodate + +from typing import Dict, Any, cast, TYPE_CHECKING + +from azure.core.exceptions import DeserializationError, SerializationError, raise_with_traceback + +_BOM = codecs.BOM_UTF8.decode(encoding='utf-8') + +if TYPE_CHECKING: + from typing import Optional, Union, AnyStr, IO, Mapping + +class RawDeserializer: + + # Accept "text" because we're open minded people... + JSON_REGEXP = re.compile(r'^(application|text)/([a-z+.]+\+)?json$') + + # Name used in context + CONTEXT_NAME = "deserialized_data" + + @classmethod + def deserialize_from_text(cls, data, content_type=None): + # type: (Optional[Union[AnyStr, IO]], Optional[str]) -> Any + """Decode data according to content-type. + + Accept a stream of data as well, but will be load at once in memory for now. + + If no content-type, will return the string version (not bytes, not stream) + + :param data: Input, could be bytes or stream (will be decoded with UTF8) or text + :type data: str or bytes or IO + :param str content_type: The content type. + """ + if hasattr(data, 'read'): + # Assume a stream + data = cast(IO, data).read() + + if isinstance(data, bytes): + data_as_str = data.decode(encoding='utf-8-sig') + else: + # Explain to mypy the correct type. + data_as_str = cast(str, data) + + # Remove Byte Order Mark if present in string + data_as_str = data_as_str.lstrip(_BOM) + + if content_type is None: + return data + + if cls.JSON_REGEXP.match(content_type): + try: + return json.loads(data_as_str) + except ValueError as err: + raise DeserializationError("JSON is invalid: {}".format(err), err) + elif "xml" in (content_type or []): + try: + + try: + if isinstance(data, unicode): # type: ignore + # If I'm Python 2.7 and unicode XML will scream if I try a "fromstring" on unicode string + data_as_str = data_as_str.encode(encoding="utf-8") # type: ignore + except NameError: + pass + + return ET.fromstring(data_as_str) # nosec + except ET.ParseError: + # It might be because the server has an issue, and returned JSON with + # content-type XML.... + # So let's try a JSON load, and if it's still broken + # let's flow the initial exception + def _json_attemp(data): + try: + return True, json.loads(data) + except ValueError: + return False, None # Don't care about this one + success, json_result = _json_attemp(data) + if success: + return json_result + # If i'm here, it's not JSON, it's not XML, let's scream + # and raise the last context in this block (the XML exception) + # The function hack is because Py2.7 messes up with exception + # context otherwise. + _LOGGER.critical("Wasn't XML not JSON, failing") + raise_with_traceback(DeserializationError, "XML is invalid") + 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 + """Deserialize from HTTP response. + + Use bytes and headers to NOT use any requests/aiohttp or whatever + specific implementation. + Headers will tested for "content-type" + """ + # Try to use content-type from headers if available + content_type = None + if 'content-type' in headers: + content_type = headers['content-type'].split(";")[0].strip().lower() + # Ouch, this server did not declare what it sent... + # Let's guess it's JSON... + # Also, since Autorest was considering that an empty body was a valid JSON, + # need that test as well.... + else: + content_type = "application/json" + + if body_bytes: + return cls.deserialize_from_text(body_bytes, content_type) + return None + +try: + basestring # type: ignore + unicode_str = unicode # type: ignore +except NameError: + basestring = str # type: ignore + unicode_str = str # type: ignore + +_LOGGER = logging.getLogger(__name__) + +try: + _long_type = long # type: ignore +except NameError: + _long_type = int + +class UTC(datetime.tzinfo): + """Time Zone info for handling UTC""" + + def utcoffset(self, dt): + """UTF offset for UTC is 0.""" + return datetime.timedelta(0) + + def tzname(self, dt): + """Timestamp representation.""" + return "Z" + + def dst(self, dt): + """No daylight saving for UTC.""" + return datetime.timedelta(hours=1) + +try: + from datetime import timezone as _FixedOffset +except ImportError: # Python 2.7 + class _FixedOffset(datetime.tzinfo): # type: ignore + """Fixed offset in minutes east from UTC. + Copy/pasted from Python doc + :param datetime.timedelta offset: offset in timedelta format + """ + + def __init__(self, offset): + self.__offset = offset + + def utcoffset(self, dt): + return self.__offset + + def tzname(self, dt): + return str(self.__offset.total_seconds()/3600) + + def __repr__(self): + return "".format(self.tzname(None)) + + def dst(self, dt): + return datetime.timedelta(0) + + def __getinitargs__(self): + return (self.__offset,) + +try: + from datetime import timezone + TZ_UTC = timezone.utc # type: ignore +except ImportError: + TZ_UTC = UTC() # type: ignore + +_FLATTEN = re.compile(r"(? y, + "minimum": lambda x, y: x < y, + "maximum": lambda x, y: x > y, + "minimum_ex": lambda x, y: x <= y, + "maximum_ex": lambda x, y: x >= y, + "min_items": lambda x, y: len(x) < y, + "max_items": lambda x, y: len(x) > y, + "pattern": lambda x, y: not re.match(y, x, re.UNICODE), + "unique": lambda x, y: len(x) != len(set(x)), + "multiple": lambda x, y: x % y != 0 + } + + def __init__(self, classes=None): + self.serialize_type = { + 'iso-8601': Serializer.serialize_iso, + 'rfc-1123': Serializer.serialize_rfc, + 'unix-time': Serializer.serialize_unix, + 'duration': Serializer.serialize_duration, + 'date': Serializer.serialize_date, + 'time': Serializer.serialize_time, + 'decimal': Serializer.serialize_decimal, + 'long': Serializer.serialize_long, + 'bytearray': Serializer.serialize_bytearray, + 'base64': Serializer.serialize_base64, + 'object': self.serialize_object, + '[]': self.serialize_iter, + '{}': self.serialize_dict + } + self.dependencies = dict(classes) if classes else {} + self.key_transformer = full_restapi_key_transformer + self.client_side_validation = True + + def _serialize(self, target_obj, data_type=None, **kwargs): + """Serialize data into a string according to type. + + :param target_obj: The data to be serialized. + :param str data_type: The type to be serialized from. + :rtype: str, dict + :raises: SerializationError if serialization fails. + """ + key_transformer = kwargs.get("key_transformer", self.key_transformer) + keep_readonly = kwargs.get("keep_readonly", False) + if target_obj is None: + return None + + attr_name = None + class_name = target_obj.__class__.__name__ + + if data_type: + return self.serialize_data( + target_obj, data_type, **kwargs) + + if not hasattr(target_obj, "_attribute_map"): + data_type = type(target_obj).__name__ + if data_type in self.basic_types.values(): + return self.serialize_data( + target_obj, data_type, **kwargs) + + # Force "is_xml" kwargs if we detect a XML model + try: + is_xml_model_serialization = kwargs["is_xml"] + except KeyError: + is_xml_model_serialization = kwargs.setdefault("is_xml", target_obj.is_xml_model()) + + serialized = {} + if is_xml_model_serialization: + serialized = target_obj._create_xml_node() + try: + attributes = target_obj._attribute_map + for attr, attr_desc in attributes.items(): + attr_name = attr + if not keep_readonly and target_obj._validation.get(attr_name, {}).get('readonly', False): + continue + + if attr_name == "additional_properties" and attr_desc["key"] == '': + if target_obj.additional_properties is not None: + serialized.update(target_obj.additional_properties) + continue + try: + + orig_attr = getattr(target_obj, attr) + if is_xml_model_serialization: + pass # Don't provide "transformer" for XML for now. Keep "orig_attr" + else: # JSON + keys, orig_attr = key_transformer(attr, attr_desc.copy(), orig_attr) + keys = keys if isinstance(keys, list) else [keys] + + + kwargs["serialization_ctxt"] = attr_desc + new_attr = self.serialize_data(orig_attr, attr_desc['type'], **kwargs) + + + if is_xml_model_serialization: + xml_desc = attr_desc.get('xml', {}) + xml_name = xml_desc.get('name', attr_desc['key']) + xml_prefix = xml_desc.get('prefix', None) + xml_ns = xml_desc.get('ns', None) + 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) + continue + if xml_desc.get("text", False): + serialized.text = new_attr + continue + if isinstance(new_attr, list): + serialized.extend(new_attr) + 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', {}): + splitted_tag = new_attr.tag.split("}") + if len(splitted_tag) == 2: # Namespace + new_attr.tag = "}".join([splitted_tag[0], xml_name]) + else: + new_attr.tag = xml_name + serialized.append(new_attr) + 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) + else: # JSON + for k in reversed(keys): + unflattened = {k: new_attr} + new_attr = unflattened + + _new_attr = new_attr + _serialized = serialized + for k in keys: + if k not in _serialized: + _serialized.update(_new_attr) + _new_attr = _new_attr[k] + _serialized = _serialized[k] + except ValueError: + continue + + except (AttributeError, KeyError, TypeError) as err: + msg = "Attribute {} in object {} cannot be serialized.\n{}".format( + attr_name, class_name, str(target_obj)) + raise_with_traceback(SerializationError, msg, err) + else: + return serialized + + def body(self, data, data_type, **kwargs): + """Serialize data intended for a request body. + + :param data: The data to be serialized. + :param str data_type: The type to be serialized from. + :rtype: dict + :raises: SerializationError if serialization fails. + :raises: ValueError if data is None + """ + + # Just in case this is a dict + internal_data_type = data_type.strip('[]{}') + internal_data_type = self.dependencies.get(internal_data_type, None) + try: + is_xml_model_serialization = kwargs["is_xml"] + except KeyError: + if internal_data_type and issubclass(internal_data_type, Model): + is_xml_model_serialization = kwargs.setdefault("is_xml", internal_data_type.is_xml_model()) + else: + is_xml_model_serialization = False + if internal_data_type and not isinstance(internal_data_type, Enum): + try: + deserializer = Deserializer(self.dependencies) + # Since it's on serialization, it's almost sure that format is not JSON REST + # We're not able to deal with additional properties for now. + deserializer.additional_properties_detection = False + if is_xml_model_serialization: + deserializer.key_extractors = [ + attribute_key_case_insensitive_extractor, + ] + else: + deserializer.key_extractors = [ + rest_key_case_insensitive_extractor, + attribute_key_case_insensitive_extractor, + last_rest_key_case_insensitive_extractor + ] + data = deserializer._deserialize(data_type, data) + except DeserializationError as err: + raise_with_traceback( + SerializationError, "Unable to build a model: "+str(err), err) + + return self._serialize(data, data_type, **kwargs) + + def url(self, name, data, data_type, **kwargs): + """Serialize data intended for a URL path. + + :param data: The data to be serialized. + :param str data_type: The type to be serialized from. + :rtype: str + :raises: TypeError if serialization fails. + :raises: ValueError if data is None + """ + try: + output = self.serialize_data(data, data_type, **kwargs) + if data_type == 'bool': + output = json.dumps(output) + + if kwargs.get('skip_quote') is True: + output = str(output) + else: + output = quote(str(output), safe='') + except SerializationError: + raise TypeError("{} must be type {}.".format(name, data_type)) + else: + return output + + def query(self, name, data, data_type, **kwargs): + """Serialize data intended for a URL query. + + :param data: The data to be serialized. + :param str data_type: The type to be serialized from. + :rtype: str + :raises: TypeError if serialization fails. + :raises: ValueError if data is None + """ + try: + # 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)) + + # Not a list, regular serialization + output = self.serialize_data(data, data_type, **kwargs) + if data_type == 'bool': + output = json.dumps(output) + if kwargs.get('skip_quote') is True: + output = str(output) + else: + output = quote(str(output), safe='') + except SerializationError: + raise TypeError("{} must be type {}.".format(name, data_type)) + else: + return str(output) + + def header(self, name, data, data_type, **kwargs): + """Serialize data intended for a request header. + + :param data: The data to be serialized. + :param str data_type: The type to be serialized from. + :rtype: str + :raises: TypeError if serialization fails. + :raises: ValueError if data is None + """ + try: + if data_type in ['[str]']: + data = ["" if d is None else d for d in data] + + output = self.serialize_data(data, data_type, **kwargs) + if data_type == 'bool': + output = json.dumps(output) + except SerializationError: + raise TypeError("{} must be type {}.".format(name, data_type)) + else: + return str(output) + + def serialize_data(self, data, data_type, **kwargs): + """Serialize generic data according to supplied data type. + + :param data: The data to be serialized. + :param str data_type: The type to be serialized from. + :param bool required: Whether it's essential that the data not be + empty or None + :raises: AttributeError if required data is None. + :raises: ValueError if data is None + :raises: SerializationError if serialization fails. + """ + if data is None: + raise ValueError("No value for given attribute") + + try: + if data_type in self.basic_types.values(): + return self.serialize_basic(data, data_type, **kwargs) + + elif data_type in self.serialize_type: + return self.serialize_type[data_type](data, **kwargs) + + # If dependencies is empty, try with current data class + # It has to be a subclass of Enum anyway + enum_type = self.dependencies.get(data_type, data.__class__) + if issubclass(enum_type, Enum): + return Serializer.serialize_enum(data, enum_obj=enum_type) + + iter_type = data_type[0] + data_type[-1] + if iter_type in self.serialize_type: + return self.serialize_type[iter_type]( + data, data_type[1:-1], **kwargs) + + except (ValueError, TypeError) as err: + msg = "Unable to serialize value: {!r} as type: {!r}." + raise_with_traceback( + SerializationError, msg.format(data, data_type), err) + else: + return self._serialize(data, **kwargs) + + @classmethod + def _get_custom_serializers(cls, data_type, **kwargs): + custom_serializer = kwargs.get("basic_types_serializers", {}).get(data_type) + if custom_serializer: + return custom_serializer + if kwargs.get("is_xml", False): + return cls._xml_basic_types_serializers.get(data_type) + + @classmethod + def serialize_basic(cls, data, data_type, **kwargs): + """Serialize basic builting data type. + Serializes objects to str, int, float or bool. + + Possible kwargs: + - basic_types_serializers dict[str, callable] : If set, use the callable as serializer + - is_xml bool : If set, use xml_basic_types_serializers + + :param data: Object to be serialized. + :param str data_type: Type of object in the iterable. + """ + custom_serializer = cls._get_custom_serializers(data_type, **kwargs) + if custom_serializer: + return custom_serializer(data) + if data_type == 'str': + return cls.serialize_unicode(data) + return eval(data_type)(data) # nosec + + @classmethod + def serialize_unicode(cls, data): + """Special handling for serializing unicode strings in Py2. + Encode to UTF-8 if unicode, otherwise handle as a str. + + :param data: Object to be serialized. + :rtype: str + """ + try: # If I received an enum, return its value + return data.value + except AttributeError: + pass + + try: + if isinstance(data, unicode): + # Don't change it, JSON and XML ElementTree are totally able + # to serialize correctly u'' strings + return data + except NameError: + return str(data) + else: + return str(data) + + def serialize_iter(self, data, iter_type, div=None, **kwargs): + """Serialize iterable. + + Supported kwargs: + - serialization_ctxt dict : The current entry of _attribute_map, or same format. + serialization_ctxt['type'] should be same as data_type. + - is_xml bool : If set, serialize as XML + + :param list attr: Object to be serialized. + :param str iter_type: Type of object in the iterable. + :param bool required: Whether the objects in the iterable must + not be None or empty. + :param str div: If set, this str will be used to combine the elements + in the iterable into a combined string. Default is 'None'. + :rtype: list, str + """ + if isinstance(data, str): + raise SerializationError("Refuse str type as a valid iter type.") + + serialization_ctxt = kwargs.get("serialization_ctxt", {}) + is_xml = kwargs.get("is_xml", False) + + serialized = [] + for d in data: + try: + serialized.append(self.serialize_data(d, iter_type, **kwargs)) + except ValueError: + serialized.append(None) + + if div: + serialized = ['' if s is None else str(s) for s in serialized] + serialized = div.join(serialized) + + if 'xml' in serialization_ctxt or is_xml: + # XML serialization is more complicated + xml_desc = serialization_ctxt.get('xml', {}) + xml_name = xml_desc.get('name') + if not xml_name: + xml_name = serialization_ctxt['key'] + + # Create a wrap node if necessary (use the fact that Element and list have "append") + is_wrapped = xml_desc.get("wrapped", False) + node_name = xml_desc.get("itemsName", xml_name) + if is_wrapped: + final_result = _create_xml_node( + xml_name, + xml_desc.get('prefix', None), + xml_desc.get('ns', None) + ) + else: + final_result = [] + # All list elements to "local_node" + for el in serialized: + if isinstance(el, ET.Element): + el_node = el + else: + el_node = _create_xml_node( + node_name, + xml_desc.get('prefix', None), + xml_desc.get('ns', None) + ) + if el is not None: # Otherwise it writes "None" :-p + el_node.text = str(el) + final_result.append(el_node) + return final_result + return serialized + + def serialize_dict(self, attr, dict_type, **kwargs): + """Serialize a dictionary of objects. + + :param dict attr: Object to be serialized. + :param str dict_type: Type of object in the dictionary. + :param bool required: Whether the objects in the dictionary must + not be None or empty. + :rtype: dict + """ + serialization_ctxt = kwargs.get("serialization_ctxt", {}) + serialized = {} + for key, value in attr.items(): + try: + serialized[self.serialize_unicode(key)] = self.serialize_data( + value, dict_type, **kwargs) + except ValueError: + serialized[self.serialize_unicode(key)] = None + + if 'xml' in serialization_ctxt: + # XML serialization is more complicated + xml_desc = serialization_ctxt['xml'] + xml_name = xml_desc['name'] + + final_result = _create_xml_node( + xml_name, + xml_desc.get('prefix', None), + xml_desc.get('ns', None) + ) + for key, value in serialized.items(): + ET.SubElement(final_result, key).text = value + return final_result + + return serialized + + def serialize_object(self, attr, **kwargs): + """Serialize a generic object. + This will be handled as a dictionary. If object passed in is not + a basic type (str, int, float, dict, list) it will simply be + cast to str. + + :param dict attr: Object to be serialized. + :rtype: dict or str + """ + if attr is None: + return None + if isinstance(attr, ET.Element): + return attr + obj_type = type(attr) + if obj_type in self.basic_types: + return self.serialize_basic(attr, self.basic_types[obj_type], **kwargs) + if obj_type is _long_type: + return self.serialize_long(attr) + if obj_type is unicode_str: + return self.serialize_unicode(attr) + if obj_type is datetime.datetime: + return self.serialize_iso(attr) + if obj_type is datetime.date: + return self.serialize_date(attr) + if obj_type is datetime.time: + return self.serialize_time(attr) + if obj_type is datetime.timedelta: + return self.serialize_duration(attr) + if obj_type is decimal.Decimal: + return self.serialize_decimal(attr) + + # If it's a model or I know this dependency, serialize as a Model + elif obj_type in self.dependencies.values() or isinstance(attr, Model): + return self._serialize(attr) + + if obj_type == dict: + serialized = {} + for key, value in attr.items(): + try: + serialized[self.serialize_unicode(key)] = self.serialize_object( + value, **kwargs) + except ValueError: + serialized[self.serialize_unicode(key)] = None + return serialized + + if obj_type == list: + serialized = [] + for obj in attr: + try: + serialized.append(self.serialize_object( + obj, **kwargs)) + except ValueError: + pass + return serialized + return str(attr) + + @staticmethod + def serialize_enum(attr, enum_obj=None): + try: + result = attr.value + except AttributeError: + result = attr + try: + enum_obj(result) + return result + except ValueError: + for enum_value in enum_obj: + if enum_value.value.lower() == str(attr).lower(): + return enum_value.value + error = "{!r} is not valid value for enum {!r}" + raise SerializationError(error.format(attr, enum_obj)) + + @staticmethod + def serialize_bytearray(attr, **kwargs): + """Serialize bytearray into base-64 string. + + :param attr: Object to be serialized. + :rtype: str + """ + return b64encode(attr).decode() + + @staticmethod + def serialize_base64(attr, **kwargs): + """Serialize str into base-64 string. + + :param attr: Object to be serialized. + :rtype: str + """ + encoded = b64encode(attr).decode('ascii') + return encoded.strip('=').replace('+', '-').replace('/', '_') + + @staticmethod + def serialize_decimal(attr, **kwargs): + """Serialize Decimal object to float. + + :param attr: Object to be serialized. + :rtype: float + """ + return float(attr) + + @staticmethod + def serialize_long(attr, **kwargs): + """Serialize long (Py2) or int (Py3). + + :param attr: Object to be serialized. + :rtype: int/long + """ + return _long_type(attr) + + @staticmethod + def serialize_date(attr, **kwargs): + """Serialize Date object into ISO-8601 formatted string. + + :param Date attr: Object to be serialized. + :rtype: str + """ + if isinstance(attr, str): + attr = isodate.parse_date(attr) + t = "{:04}-{:02}-{:02}".format(attr.year, attr.month, attr.day) + return t + + @staticmethod + def serialize_time(attr, **kwargs): + """Serialize Time object into ISO-8601 formatted string. + + :param datetime.time attr: Object to be serialized. + :rtype: str + """ + if isinstance(attr, str): + attr = isodate.parse_time(attr) + t = "{:02}:{:02}:{:02}".format(attr.hour, attr.minute, attr.second) + if attr.microsecond: + t += ".{:02}".format(attr.microsecond) + return t + + @staticmethod + def serialize_duration(attr, **kwargs): + """Serialize TimeDelta object into ISO-8601 formatted string. + + :param TimeDelta attr: Object to be serialized. + :rtype: str + """ + if isinstance(attr, str): + attr = isodate.parse_duration(attr) + return isodate.duration_isoformat(attr) + + @staticmethod + def serialize_rfc(attr, **kwargs): + """Serialize Datetime object into RFC-1123 formatted string. + + :param Datetime attr: Object to be serialized. + :rtype: str + :raises: TypeError if format invalid. + """ + try: + if not attr.tzinfo: + _LOGGER.warning( + "Datetime with no tzinfo will be considered UTC.") + utc = attr.utctimetuple() + except AttributeError: + raise TypeError("RFC1123 object must be valid Datetime object.") + + return "{}, {:02} {} {:04} {:02}:{:02}:{:02} GMT".format( + Serializer.days[utc.tm_wday], utc.tm_mday, + Serializer.months[utc.tm_mon], utc.tm_year, + utc.tm_hour, utc.tm_min, utc.tm_sec) + + @staticmethod + def serialize_iso(attr, **kwargs): + """Serialize Datetime object into ISO-8601 formatted string. + + :param Datetime attr: Object to be serialized. + :rtype: str + :raises: SerializationError if format invalid. + """ + if isinstance(attr, str): + attr = isodate.parse_datetime(attr) + try: + if not attr.tzinfo: + _LOGGER.warning( + "Datetime with no tzinfo will be considered UTC.") + utc = attr.utctimetuple() + if utc.tm_year > 9999 or utc.tm_year < 1: + raise OverflowError("Hit max or min date") + + microseconds = str(attr.microsecond).rjust(6,'0').rstrip('0').ljust(3, '0') + if microseconds: + microseconds = '.'+microseconds + date = "{:04}-{:02}-{:02}T{:02}:{:02}:{:02}".format( + utc.tm_year, utc.tm_mon, utc.tm_mday, + utc.tm_hour, utc.tm_min, utc.tm_sec) + return date + microseconds + 'Z' + except (ValueError, OverflowError) as err: + msg = "Unable to serialize datetime object." + raise_with_traceback(SerializationError, msg, err) + except AttributeError as err: + msg = "ISO-8601 object must be valid Datetime object." + raise_with_traceback(TypeError, msg, err) + + @staticmethod + def serialize_unix(attr, **kwargs): + """Serialize Datetime object into IntTime format. + This is represented as seconds. + + :param Datetime attr: Object to be serialized. + :rtype: int + :raises: SerializationError if format invalid + """ + if isinstance(attr, int): + return attr + try: + if not attr.tzinfo: + _LOGGER.warning( + "Datetime with no tzinfo will be considered UTC.") + return int(calendar.timegm(attr.utctimetuple())) + except AttributeError: + raise TypeError("Unix time object must be valid Datetime object.") + +def rest_key_extractor(attr, attr_desc, data): + key = attr_desc['key'] + working_data = data + + while '.' in key: + dict_keys = _FLATTEN.split(key) + if len(dict_keys) == 1: + key = _decode_attribute_map_key(dict_keys[0]) + break + working_key = _decode_attribute_map_key(dict_keys[0]) + working_data = working_data.get(working_key, data) + if working_data is None: + # If at any point while following flatten JSON path see None, it means + # that all properties under are None as well + # https://github.com/Azure/msrest-for-python/issues/197 + return None + key = '.'.join(dict_keys[1:]) + + return working_data.get(key) + +def rest_key_case_insensitive_extractor(attr, attr_desc, data): + key = attr_desc['key'] + working_data = data + + while '.' in key: + dict_keys = _FLATTEN.split(key) + if len(dict_keys) == 1: + key = _decode_attribute_map_key(dict_keys[0]) + break + working_key = _decode_attribute_map_key(dict_keys[0]) + working_data = attribute_key_case_insensitive_extractor(working_key, None, working_data) + if working_data is None: + # If at any point while following flatten JSON path see None, it means + # that all properties under are None as well + # https://github.com/Azure/msrest-for-python/issues/197 + return None + key = '.'.join(dict_keys[1:]) + + if working_data: + return attribute_key_case_insensitive_extractor(key, None, working_data) + +def last_rest_key_extractor(attr, attr_desc, data): + """Extract the attribute in "data" based on the last part of the JSON path key. + """ + key = attr_desc['key'] + dict_keys = _FLATTEN.split(key) + return attribute_key_extractor(dict_keys[-1], None, data) + +def last_rest_key_case_insensitive_extractor(attr, attr_desc, data): + """Extract the attribute in "data" based on the last part of the JSON path key. + + This is the case insensitive version of "last_rest_key_extractor" + """ + key = attr_desc['key'] + dict_keys = _FLATTEN.split(key) + return attribute_key_case_insensitive_extractor(dict_keys[-1], None, data) + +def attribute_key_extractor(attr, _, data): + return data.get(attr) + +def attribute_key_case_insensitive_extractor(attr, _, data): + found_key = None + lower_attr = attr.lower() + for key in data: + if lower_attr == key.lower(): + found_key = key + break + + return data.get(found_key) + +def _extract_name_from_internal_type(internal_type): + """Given an internal type XML description, extract correct XML name with namespace. + + :param dict internal_type: An model type + :rtype: tuple + :returns: A tuple XML name + namespace dict + """ + internal_type_xml_map = getattr(internal_type, "_xml_map", {}) + 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) + return xml_name + + +def xml_key_extractor(attr, attr_desc, data): + if isinstance(data, dict): + return None + + # Test if this model is XML ready first + if not isinstance(data, ET.Element): + return None + + xml_desc = attr_desc.get('xml', {}) + xml_name = xml_desc.get('name', attr_desc['key']) + + # Look for a children + is_iter_type = attr_desc['type'].startswith("[") + is_wrapped = xml_desc.get("wrapped", False) + internal_type = attr_desc.get("internalType", None) + internal_type_xml_map = getattr(internal_type, "_xml_map", {}) + + # 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) + + # If it's an attribute, that's simple + if xml_desc.get("attr", False): + return data.get(xml_name) + + # If it's x-ms-text, that's simple too + if xml_desc.get("text", False): + return data.text + + # Scenario where I take the local name: + # - Wrapped node + # - Internal type is an enum (considered basic types) + # - Internal type has no XML/Name node + if is_wrapped or (internal_type and (issubclass(internal_type, Enum) or 'name' not in internal_type_xml_map)): + children = data.findall(xml_name) + # If internal type has a local name and it's not a list, I use that name + elif not is_iter_type and internal_type and 'name' in internal_type_xml_map: + xml_name = _extract_name_from_internal_type(internal_type) + children = data.findall(xml_name) + # That's an array + else: + if internal_type: # Complex type, ignore itemsName and use the complex type name + items_name = _extract_name_from_internal_type(internal_type) + else: + items_name = xml_desc.get("itemsName", xml_name) + children = data.findall(items_name) + + if len(children) == 0: + if is_iter_type: + if is_wrapped: + return None # is_wrapped no node, we want None + else: + return [] # not wrapped, assume empty list + return None # Assume it's not there, maybe an optional node. + + # If is_iter_type and not wrapped, return all found children + if is_iter_type: + if not is_wrapped: + return children + else: # Iter and wrapped, should have found one node only (the wrap one) + if len(children) != 1: + raise DeserializationError( + "Tried to deserialize an array not wrapped, and found several nodes '{}'. Maybe you should declare this array as wrapped?".format( + xml_name + )) + return list(children[0]) # Might be empty list and that's ok. + + # Here it's not a itertype, we should have found one element only or empty + if len(children) > 1: + raise DeserializationError("Find several XML '{}' where it was not expected".format(xml_name)) + return children[0] + +class Deserializer(object): + """Response object model deserializer. + + :param dict classes: Class type dictionary for deserializing complex types. + :ivar list key_extractors: Ordered list of extractors to be used by this deserializer. + """ + + basic_types = {str: 'str', int: 'int', bool: 'bool', float: 'float'} + + valid_date = re.compile( + r'\d{4}[-]\d{2}[-]\d{2}T\d{2}:\d{2}:\d{2}' + r'\.?\d*Z?[-+]?[\d{2}]?:?[\d{2}]?') + + def __init__(self, classes=None): + self.deserialize_type = { + 'iso-8601': Deserializer.deserialize_iso, + 'rfc-1123': Deserializer.deserialize_rfc, + 'unix-time': Deserializer.deserialize_unix, + 'duration': Deserializer.deserialize_duration, + 'date': Deserializer.deserialize_date, + 'time': Deserializer.deserialize_time, + 'decimal': Deserializer.deserialize_decimal, + 'long': Deserializer.deserialize_long, + 'bytearray': Deserializer.deserialize_bytearray, + 'base64': Deserializer.deserialize_base64, + 'object': self.deserialize_object, + '[]': self.deserialize_iter, + '{}': self.deserialize_dict + } + self.deserialize_expected_types = { + 'duration': (isodate.Duration, datetime.timedelta), + 'iso-8601': (datetime.datetime) + } + self.dependencies = 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 + # complicated, with no real scenario for now. + # So adding a flag to disable additional properties detection. This flag should be + # used if your expect the deserialization to NOT come from a JSON REST syntax. + # Otherwise, result are unexpected + self.additional_properties_detection = True + + def __call__(self, target_obj, response_data, content_type=None): + """Call the deserializer to process a REST response. + + :param str target_obj: Target data type to deserialize to. + :param requests.Response response_data: REST response object. + :param str content_type: Swagger "produces" if available. + :raises: DeserializationError if deserialization fails. + :return: Deserialized object. + """ + data = self._unpack_content(response_data, content_type) + return self._deserialize(target_obj, data) + + def _deserialize(self, target_obj, data): + """Call the deserializer on a model. + + Data needs to be already deserialized as JSON or XML ElementTree + + :param str target_obj: Target data type to deserialize to. + :param object data: Object to deserialize. + :raises: DeserializationError if deserialization fails. + :return: Deserialized object. + """ + # This is already a model, go recursive just in case + if hasattr(data, "_attribute_map"): + constants = [name for name, config in getattr(data, '_validation', {}).items() + if config.get('constant')] + try: + for attr, mapconfig in data._attribute_map.items(): + if attr in constants: + continue + value = getattr(data, attr) + if value is None: + continue + local_type = mapconfig['type'] + internal_data_type = local_type.strip('[]{}') + if internal_data_type not in self.dependencies or isinstance(internal_data_type, Enum): + continue + setattr( + data, + attr, + self._deserialize(local_type, value) + ) + return data + except AttributeError: + return + + response, class_name = self._classify_target(target_obj, data) + + if isinstance(response, basestring): + return self.deserialize_data(data, response) + elif isinstance(response, type) and issubclass(response, Enum): + return self.deserialize_enum(data, response) + + if data is None: + return data + try: + attributes = response._attribute_map + d_attrs = {} + for attr, attr_desc in attributes.items(): + # Check empty string. If it's not empty, someone has a real "additionalProperties"... + if attr == "additional_properties" and attr_desc["key"] == '': + continue + raw_value = None + # Enhance attr_desc with some dynamic data + attr_desc = attr_desc.copy() # Do a copy, do not change the real one + internal_data_type = attr_desc["type"].strip('[]{}') + if internal_data_type in self.dependencies: + attr_desc["internalType"] = self.dependencies[internal_data_type] + + for key_extractor in self.key_extractors: + found_value = key_extractor(attr, attr_desc, data) + if found_value is not None: + if raw_value is not None and raw_value != found_value: + msg = ("Ignoring extracted value '%s' from %s for key '%s'" + " (duplicate extraction, follow extractors order)" ) + _LOGGER.warning( + msg, + found_value, + key_extractor, + attr + ) + continue + raw_value = found_value + + 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 + raise_with_traceback(DeserializationError, msg, err) + else: + additional_properties = self._build_additional_properties(attributes, data) + return self._instantiate_model(response, d_attrs, additional_properties) + + def _build_additional_properties(self, attribute_map, data): + if not self.additional_properties_detection: + return None + if "additional_properties" in attribute_map and attribute_map.get("additional_properties", {}).get("key") != '': + # Check empty string. If it's not empty, someone has a real "additionalProperties" + return None + if isinstance(data, ET.Element): + data = {el.tag: el.text for el in data} + + known_keys = {_decode_attribute_map_key(_FLATTEN.split(desc['key'])[0]) + for desc in attribute_map.values() if desc['key'] != ''} + present_keys = set(data.keys()) + missing_keys = present_keys - known_keys + return {key: data[key] for key in missing_keys} + + def _classify_target(self, target, data): + """Check to see whether the deserialization target object can + be classified into a subclass. + 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. + """ + if target is None: + return None, None + + if isinstance(target, basestring): + try: + target = self.dependencies[target] + except KeyError: + return target, target + + try: + target = target._classify(data, self.dependencies) + except AttributeError: + pass # Target is not a Model, no classify + return target, target.__class__.__name__ + + def failsafe_deserialize(self, target_obj, data, content_type=None): + """Ignores any errors encountered in deserialization, + and falls back to not deserializing the object. Recommended + for use in error deserialization, as we want to return the + HttpResponseError to users, and not have them deal with + 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 content_type: Swagger "produces" if available. + """ + try: + return self(target_obj, data, content_type=content_type) + except: + _LOGGER.debug( + "Ran into a deserialization error. Ignoring since this is failsafe deserialization", + exc_info=True + ) + return None + + @staticmethod + def _unpack_content(raw_data, content_type=None): + """Extract the correct structure for deserialization. + + If raw_data is a PipelineResponse, try to extract the result of RawDeserializer. + if we can't, raise. Your Pipeline should have a RawDeserializer. + + If not a pipeline response and raw_data is bytes or string, use content-type + to decode it. If no content-type, try JSON. + + If raw_data is something else, bypass all logic and return it directly. + + :param raw_data: Data to be processed. + :param content_type: How to parse if raw_data is a string/bytes. + :raises JSONDecodeError: If JSON is requested and parsing is impossible. + :raises UnicodeDecodeError: If bytes is not UTF8 + """ + # Assume this is enough to detect a Pipeline Response without importing it + context = getattr(raw_data, "context", {}) + if context: + if RawDeserializer.CONTEXT_NAME in context: + return context[RawDeserializer.CONTEXT_NAME] + raise ValueError("This pipeline didn't have the RawDeserializer policy; can't deserialize") + + #Assume this is enough to recognize universal_http.ClientResponse without importing it + if hasattr(raw_data, "body"): + return RawDeserializer.deserialize_from_http_generics( + raw_data.text(), + raw_data.headers + ) + + # Assume this enough to recognize requests.Response without importing it. + if hasattr(raw_data, '_content_consumed'): + 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 raw_data + + def _instantiate_model(self, response, attrs, additional_properties=None): + """Instantiate a response model passing in deserialized args. + + :param response: The response model class. + :param d_attrs: The deserialized response attributes. + """ + if callable(response): + subtype = getattr(response, '_subtype_map', {}) + try: + readonly = [k for k, v in response._validation.items() + if v.get('readonly')] + const = [k for k, v in response._validation.items() + if v.get('constant')] + kwargs = {k: v for k, v in attrs.items() + if k not in subtype and k not in readonly + const} + response_obj = response(**kwargs) + for attr in readonly: + setattr(response_obj, attr, attrs.get(attr)) + if additional_properties: + response_obj.additional_properties = additional_properties + return response_obj + except TypeError as err: + msg = "Unable to deserialize {} into model {}. ".format( + kwargs, response) + raise DeserializationError(msg + str(err)) + else: + try: + for attr, value in attrs.items(): + setattr(response, attr, value) + return response + except Exception as exp: + msg = "Unable to populate response model. " + msg += "Type: {}, Error: {}".format(type(response), exp) + raise DeserializationError(msg) + + def deserialize_data(self, data, data_type): + """Process data for deserialization according to data type. + + :param str data: The response string to be deserialized. + :param str data_type: The type to deserialize to. + :raises: DeserializationError if deserialization fails. + :return: Deserialized object. + """ + if data is None: + return data + + try: + if not data_type: + return data + if data_type in self.basic_types.values(): + return self.deserialize_basic(data, data_type) + if data_type in self.deserialize_type: + if isinstance(data, self.deserialize_expected_types.get(data_type, tuple())): + return data + + is_a_text_parsing_type = lambda x: x not in ["object", "[]", r"{}"] + if isinstance(data, ET.Element) and is_a_text_parsing_type(data_type) and not data.text: + return None + data_val = self.deserialize_type[data_type](data) + return data_val + + iter_type = data_type[0] + data_type[-1] + if iter_type in self.deserialize_type: + return self.deserialize_type[iter_type](data, data_type[1:-1]) + + obj_type = self.dependencies[data_type] + if issubclass(obj_type, Enum): + if isinstance(data, ET.Element): + data = data.text + return self.deserialize_enum(data, obj_type) + + except (ValueError, TypeError, AttributeError) as err: + msg = "Unable to deserialize response data." + msg += " Data: {}, {}".format(data, data_type) + raise_with_traceback(DeserializationError, msg, err) + else: + return self._deserialize(obj_type, data) + + def deserialize_iter(self, attr, iter_type): + """Deserialize an iterable. + + :param list attr: Iterable to be deserialized. + :param str iter_type: The type of object in the iterable. + :rtype: list + """ + if attr is None: + return None + if isinstance(attr, ET.Element): # If I receive an element here, get the children + attr = list(attr) + if not isinstance(attr, (list, set)): + raise DeserializationError("Cannot deserialize as [{}] an object of type {}".format( + iter_type, + type(attr) + )) + return [self.deserialize_data(a, iter_type) for a in attr] + + def deserialize_dict(self, attr, dict_type): + """Deserialize a dictionary. + + :param dict/list attr: Dictionary to be deserialized. Also accepts + a list of key, value pairs. + :param str dict_type: The object type of the items in the dictionary. + :rtype: dict + """ + if isinstance(attr, list): + return {x['key']: self.deserialize_data(x['value'], dict_type) for x in attr} + + if isinstance(attr, ET.Element): + # Transform value into {"Key": "value"} + attr = {el.tag: el.text for el in attr} + return {k: self.deserialize_data(v, dict_type) for k, v in attr.items()} + + def deserialize_object(self, attr, **kwargs): + """Deserialize a generic object. + This will be handled as a dictionary. + + :param dict attr: Dictionary to be deserialized. + :rtype: dict + :raises: TypeError if non-builtin datatype encountered. + """ + if attr is None: + return None + if isinstance(attr, ET.Element): + # Do no recurse on XML, just return the tree as-is + return attr + if isinstance(attr, basestring): + return self.deserialize_basic(attr, 'str') + obj_type = type(attr) + if obj_type in self.basic_types: + return self.deserialize_basic(attr, self.basic_types[obj_type]) + if obj_type is _long_type: + return self.deserialize_long(attr) + + if obj_type == dict: + deserialized = {} + for key, value in attr.items(): + try: + deserialized[key] = self.deserialize_object( + value, **kwargs) + except ValueError: + deserialized[key] = None + return deserialized + + if obj_type == list: + deserialized = [] + for obj in attr: + try: + deserialized.append(self.deserialize_object( + obj, **kwargs)) + except ValueError: + pass + return deserialized + + else: + error = "Cannot deserialize generic object with type: " + raise TypeError(error + str(obj_type)) + + def deserialize_basic(self, attr, data_type): + """Deserialize basic builtin data type from string. + Will attempt to convert to str, int, float and bool. + This function will also accept '1', '0', 'true' and 'false' as + valid bool values. + + :param str attr: response string to be deserialized. + :param str data_type: deserialization data type. + :rtype: str, int, float or bool + :raises: TypeError if string format is not valid. + """ + # If we're here, data is supposed to be a basic type. + # If it's still an XML node, take the text + if isinstance(attr, ET.Element): + attr = attr.text + if not attr: + if data_type == "str": + # None or '', node is empty string. + return '' + else: + # None or '', node with a strong type is None. + # Don't try to model "empty bool" or "empty int" + return None + + if data_type == 'bool': + if attr in [True, False, 1, 0]: + return bool(attr) + elif isinstance(attr, basestring): + if attr.lower() in ['true', '1']: + return True + elif attr.lower() in ['false', '0']: + return False + raise TypeError("Invalid boolean value: {}".format(attr)) + + if data_type == 'str': + return self.deserialize_unicode(attr) + return eval(data_type)(attr) # nosec + + @staticmethod + def deserialize_unicode(data): + """Preserve unicode objects in Python 2, otherwise return data + as a string. + + :param str data: response string to be deserialized. + :rtype: str or unicode + """ + # We might be here because we have an enum modeled as string, + # and we try to deserialize a partial dict with enum inside + if isinstance(data, Enum): + return data + + # Consider this is real string + try: + if isinstance(data, unicode): + return data + except NameError: + return str(data) + else: + return str(data) + + @staticmethod + def deserialize_enum(data, enum_obj): + """Deserialize string into enum object. + + If the string is not a valid enum value it will be returned as-is + and a warning will be logged. + + :param str data: Response string to be deserialized. If this value is + None or invalid it will be returned as-is. + :param Enum enum_obj: Enum object to deserialize to. + :rtype: Enum + """ + if isinstance(data, enum_obj) or data is None: + return data + if isinstance(data, Enum): + data = data.value + if isinstance(data, int): + # Workaround. We might consider remove it in the future. + # https://github.com/Azure/azure-rest-api-specs/issues/141 + try: + return list(enum_obj.__members__.values())[data] + except IndexError: + error = "{!r} is not a valid index for enum {!r}" + raise DeserializationError(error.format(data, enum_obj)) + try: + return enum_obj(str(data)) + except ValueError: + for enum_value in enum_obj: + if enum_value.value.lower() == str(data).lower(): + return enum_value + # We don't fail anymore for unknown value, we deserialize as a string + _LOGGER.warning("Deserializer is not able to find %s as valid enum in %s", data, enum_obj) + return Deserializer.deserialize_unicode(data) + + @staticmethod + def deserialize_bytearray(attr): + """Deserialize string into bytearray. + + :param str attr: response string to be deserialized. + :rtype: bytearray + :raises: TypeError if string format invalid. + """ + if isinstance(attr, ET.Element): + attr = attr.text + return bytearray(b64decode(attr)) + + @staticmethod + def deserialize_base64(attr): + """Deserialize base64 encoded string into string. + + :param str attr: response string to be deserialized. + :rtype: bytearray + :raises: TypeError if string format invalid. + """ + if isinstance(attr, ET.Element): + attr = attr.text + padding = '=' * (3 - (len(attr) + 3) % 4) + attr = attr + padding + encoded = attr.replace('-', '+').replace('_', '/') + return b64decode(encoded) + + @staticmethod + def deserialize_decimal(attr): + """Deserialize string into Decimal object. + + :param str attr: response string to be deserialized. + :rtype: Decimal + :raises: DeserializationError if string format invalid. + """ + if isinstance(attr, ET.Element): + attr = attr.text + try: + return decimal.Decimal(attr) + except decimal.DecimalException as err: + msg = "Invalid decimal {}".format(attr) + raise_with_traceback(DeserializationError, msg, err) + + @staticmethod + def deserialize_long(attr): + """Deserialize string into long (Py2) or int (Py3). + + :param str attr: response string to be deserialized. + :rtype: long or int + :raises: ValueError if string format invalid. + """ + if isinstance(attr, ET.Element): + attr = attr.text + return _long_type(attr) + + @staticmethod + def deserialize_duration(attr): + """Deserialize ISO-8601 formatted string into TimeDelta object. + + :param str attr: response string to be deserialized. + :rtype: TimeDelta + :raises: DeserializationError if string format invalid. + """ + if isinstance(attr, ET.Element): + attr = attr.text + try: + duration = isodate.parse_duration(attr) + except(ValueError, OverflowError, AttributeError) as err: + msg = "Cannot deserialize duration object." + raise_with_traceback(DeserializationError, msg, err) + else: + return duration + + @staticmethod + def deserialize_date(attr): + """Deserialize ISO-8601 formatted string into Date object. + + :param str attr: response string to be deserialized. + :rtype: Date + :raises: DeserializationError if string format invalid. + """ + if isinstance(attr, ET.Element): + attr = attr.text + if re.search(r"[^\W\d_]", attr, re.I + re.U): + 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) + + @staticmethod + def deserialize_time(attr): + """Deserialize ISO-8601 formatted string into time object. + + :param str attr: response string to be deserialized. + :rtype: datetime.time + :raises: DeserializationError if string format invalid. + """ + if isinstance(attr, ET.Element): + attr = attr.text + if re.search(r"[^\W\d_]", attr, re.I + re.U): + raise DeserializationError("Date must have only digits and -. Received: %s" % attr) + return isodate.parse_time(attr) + + @staticmethod + def deserialize_rfc(attr): + """Deserialize RFC-1123 formatted string into Datetime object. + + :param str attr: response string to be deserialized. + :rtype: Datetime + :raises: DeserializationError if string format invalid. + """ + if isinstance(attr, ET.Element): + attr = attr.text + try: + parsed_date = email.utils.parsedate_tz(attr) + date_obj = datetime.datetime( + *parsed_date[:6], + tzinfo=_FixedOffset(datetime.timedelta(minutes=(parsed_date[9] or 0)/60)) + ) + if not date_obj.tzinfo: + date_obj = date_obj.astimezone(tz=TZ_UTC) + except ValueError as err: + msg = "Cannot deserialize to rfc datetime object." + raise_with_traceback(DeserializationError, msg, err) + else: + return date_obj + + @staticmethod + def deserialize_iso(attr): + """Deserialize ISO-8601 formatted string into Datetime object. + + :param str attr: response string to be deserialized. + :rtype: Datetime + :raises: DeserializationError if string format invalid. + """ + if isinstance(attr, ET.Element): + attr = attr.text + try: + attr = attr.upper() + match = Deserializer.valid_date.match(attr) + if not match: + raise ValueError("Invalid datetime string: " + attr) + + check_decimal = attr.split('.') + if len(check_decimal) > 1: + decimal_str = "" + for digit in check_decimal[1]: + if digit.isdigit(): + decimal_str += digit + else: + break + if len(decimal_str) > 6: + attr = attr.replace(decimal_str, decimal_str[0:6]) + + date_obj = isodate.parse_datetime(attr) + test_utc = date_obj.utctimetuple() + if test_utc.tm_year > 9999 or test_utc.tm_year < 1: + raise OverflowError("Hit max or min date") + except(ValueError, OverflowError, AttributeError) as err: + msg = "Cannot deserialize datetime object." + raise_with_traceback(DeserializationError, msg, err) + else: + return date_obj + + @staticmethod + def deserialize_unix(attr): + """Serialize Datetime object into IntTime format. + This is represented as seconds. + + :param int attr: Object to be serialized. + :rtype: Datetime + :raises: DeserializationError if format invalid + """ + if isinstance(attr, ET.Element): + attr = int(attr.text) + try: + date_obj = datetime.datetime.fromtimestamp(attr, TZ_UTC) + except ValueError as err: + msg = "Cannot deserialize to unix datetime object." + raise_with_traceback(DeserializationError, msg, err) + else: + return date_obj diff --git a/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/resources/aio/_configuration.py b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/resources/aio/_configuration.py index ac0116dee2a39..0e1eedb7f5269 100644 --- a/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/resources/aio/_configuration.py +++ b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/resources/aio/_configuration.py @@ -26,9 +26,9 @@ class ResourceManagementClientConfiguration(Configuration): Note that all parameters used to create this instance are saved as instance attributes. - :param credential: Credential needed for the client to connect to Azure. + :param credential: Credential needed for the client to connect to Azure. Required. :type credential: ~azure.core.credentials_async.AsyncTokenCredential - :param subscription_id: The Microsoft Azure subscription ID. + :param subscription_id: The Microsoft Azure subscription ID. Required. :type subscription_id: str """ diff --git a/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/resources/aio/_resource_management_client.py b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/resources/aio/_resource_management_client.py index 228f88d742200..35fa2c403b1eb 100644 --- a/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/resources/aio/_resource_management_client.py +++ b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/resources/aio/_resource_management_client.py @@ -11,17 +11,15 @@ from typing import Any, Optional, TYPE_CHECKING -from msrest import Deserializer, Serializer - from azure.mgmt.core import AsyncARMPipelineClient from azure.profiles import KnownProfiles, ProfileDefinition from azure.profiles.multiapiclient import MultiApiClientMixin +from .._serialization import Deserializer, Serializer from ._configuration import ResourceManagementClientConfiguration if TYPE_CHECKING: # pylint: disable=unused-import,ungrouped-imports - from azure.core.credentials import TokenCredential from azure.core.credentials_async import AsyncTokenCredential class _SDKClient(object): @@ -42,9 +40,9 @@ class ResourceManagementClient(MultiApiClientMixin, _SDKClient): The api-version parameter sets the default API version if the operation group is not described in the profile. - :param credential: Credential needed for the client to connect to Azure. + :param credential: Credential needed for the client to connect to Azure. Required. :type credential: ~azure.core.credentials_async.AsyncTokenCredential - :param subscription_id: The Microsoft Azure subscription ID. + :param subscription_id: The Microsoft Azure subscription ID. Required. :type subscription_id: str :param api_version: API version to use if no profile is provided, or if missing in profile. :type api_version: str diff --git a/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/resources/v2016_02_01/__init__.py b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/resources/v2016_02_01/__init__.py index 449220069f2f2..2b201470d075e 100644 --- a/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/resources/v2016_02_01/__init__.py +++ b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/resources/v2016_02_01/__init__.py @@ -10,9 +10,15 @@ from ._version import VERSION __version__ = VERSION -__all__ = ['ResourceManagementClient'] -# `._patch.py` is used for handwritten extensions to the generated code -# Example: https://github.com/Azure/azure-sdk-for-python/blob/main/doc/dev/customize_code/how-to-patch-sdk-code.md -from ._patch import patch_sdk -patch_sdk() +try: + from ._patch import __all__ as _patch_all + from ._patch import * # type: ignore # pylint: disable=unused-wildcard-import +except ImportError: + _patch_all = [] +from ._patch import patch_sdk as _patch_sdk + +__all__ = ["ResourceManagementClient"] +__all__.extend([p for p in _patch_all if p not in __all__]) + +_patch_sdk() diff --git a/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/resources/v2016_02_01/_configuration.py b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/resources/v2016_02_01/_configuration.py index 4fd754343f7e5..d6906cfc8dc9a 100644 --- a/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/resources/v2016_02_01/_configuration.py +++ b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/resources/v2016_02_01/_configuration.py @@ -25,23 +25,18 @@ class ResourceManagementClientConfiguration(Configuration): # pylint: disable=t Note that all parameters used to create this instance are saved as instance attributes. - :param credential: Credential needed for the client to connect to Azure. + :param credential: Credential needed for the client to connect to Azure. Required. :type credential: ~azure.core.credentials.TokenCredential - :param subscription_id: The ID of the target subscription. + :param subscription_id: The ID of the target subscription. Required. :type subscription_id: str :keyword api_version: Api Version. Default value is "2016-02-01". Note that overriding this default value may result in unsupported behavior. :paramtype api_version: str """ - def __init__( - self, - credential: "TokenCredential", - subscription_id: str, - **kwargs: Any - ) -> None: + def __init__(self, credential: "TokenCredential", subscription_id: str, **kwargs: Any) -> None: super(ResourceManagementClientConfiguration, self).__init__(**kwargs) - api_version = kwargs.pop('api_version', "2016-02-01") # type: str + api_version = kwargs.pop("api_version", "2016-02-01") # type: str if credential is None: raise ValueError("Parameter 'credential' must not be None.") @@ -51,23 +46,24 @@ def __init__( self.credential = credential self.subscription_id = subscription_id self.api_version = api_version - self.credential_scopes = kwargs.pop('credential_scopes', ['https://management.azure.com/.default']) - kwargs.setdefault('sdk_moniker', 'mgmt-resource/{}'.format(VERSION)) + self.credential_scopes = kwargs.pop("credential_scopes", ["https://management.azure.com/.default"]) + kwargs.setdefault("sdk_moniker", "mgmt-resource/{}".format(VERSION)) self._configure(**kwargs) def _configure( - self, - **kwargs # type: Any + self, **kwargs # type: Any ): # type: (...) -> 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) - self.logging_policy = kwargs.get('logging_policy') or policies.NetworkTraceLoggingPolicy(**kwargs) - self.http_logging_policy = kwargs.get('http_logging_policy') or ARMHttpLoggingPolicy(**kwargs) - self.retry_policy = kwargs.get('retry_policy') or policies.RetryPolicy(**kwargs) - self.custom_hook_policy = kwargs.get('custom_hook_policy') or policies.CustomHookPolicy(**kwargs) - self.redirect_policy = kwargs.get('redirect_policy') or policies.RedirectPolicy(**kwargs) - self.authentication_policy = kwargs.get('authentication_policy') + 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) + self.logging_policy = kwargs.get("logging_policy") or policies.NetworkTraceLoggingPolicy(**kwargs) + self.http_logging_policy = kwargs.get("http_logging_policy") or ARMHttpLoggingPolicy(**kwargs) + self.retry_policy = kwargs.get("retry_policy") or policies.RetryPolicy(**kwargs) + self.custom_hook_policy = kwargs.get("custom_hook_policy") or policies.CustomHookPolicy(**kwargs) + self.redirect_policy = kwargs.get("redirect_policy") or policies.RedirectPolicy(**kwargs) + self.authentication_policy = kwargs.get("authentication_policy") if self.credential and not self.authentication_policy: - self.authentication_policy = ARMChallengeAuthenticationPolicy(self.credential, *self.credential_scopes, **kwargs) + self.authentication_policy = ARMChallengeAuthenticationPolicy( + self.credential, *self.credential_scopes, **kwargs + ) diff --git a/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/resources/v2016_02_01/_metadata.json b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/resources/v2016_02_01/_metadata.json index 1974636512a7b..1b9cc645d0502 100644 --- a/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/resources/v2016_02_01/_metadata.json +++ b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/resources/v2016_02_01/_metadata.json @@ -10,20 +10,20 @@ "azure_arm": true, "has_lro_operations": true, "client_side_validation": false, - "sync_imports": "{\"typing\": {\"azurecore\": {\"azure.core.credentials\": [\"TokenCredential\"]}}, \"regular\": {\"azurecore\": {\"azure.profiles\": [\"KnownProfiles\", \"ProfileDefinition\"], \"azure.profiles.multiapiclient\": [\"MultiApiClientMixin\"], \"azure.mgmt.core\": [\"ARMPipelineClient\"]}, \"local\": {\"._configuration\": [\"ResourceManagementClientConfiguration\"]}, \"thirdparty\": {\"msrest\": [\"Deserializer\", \"Serializer\"]}}, \"conditional\": {\"stdlib\": {\"typing\": [\"Any\", \"Optional\"]}}}", - "async_imports": "{\"typing\": {\"azurecore\": {\"azure.core.credentials_async\": [\"AsyncTokenCredential\"], \"azure.core.credentials\": [\"TokenCredential\"]}}, \"regular\": {\"azurecore\": {\"azure.profiles\": [\"KnownProfiles\", \"ProfileDefinition\"], \"azure.profiles.multiapiclient\": [\"MultiApiClientMixin\"], \"azure.mgmt.core\": [\"AsyncARMPipelineClient\"]}, \"local\": {\"._configuration\": [\"ResourceManagementClientConfiguration\"]}, \"thirdparty\": {\"msrest\": [\"Deserializer\", \"Serializer\"]}}, \"conditional\": {\"stdlib\": {\"typing\": [\"Any\", \"Optional\"]}}}" + "sync_imports": "{\"conditional\": {\"stdlib\": {\"typing\": [\"Any\", \"Optional\"]}}, \"regular\": {\"azurecore\": {\"azure.mgmt.core\": [\"ARMPipelineClient\"], \"azure.profiles\": [\"KnownProfiles\", \"ProfileDefinition\"], \"azure.profiles.multiapiclient\": [\"MultiApiClientMixin\"]}, \"local\": {\"._configuration\": [\"ResourceManagementClientConfiguration\"], \".._serialization\": [\"Deserializer\", \"Serializer\"]}}, \"typing\": {\"azurecore\": {\"azure.core.credentials\": [\"TokenCredential\"]}}}", + "async_imports": "{\"conditional\": {\"stdlib\": {\"typing\": [\"Any\", \"Optional\"]}}, \"regular\": {\"azurecore\": {\"azure.mgmt.core\": [\"AsyncARMPipelineClient\"], \"azure.profiles\": [\"KnownProfiles\", \"ProfileDefinition\"], \"azure.profiles.multiapiclient\": [\"MultiApiClientMixin\"]}, \"local\": {\"._configuration\": [\"ResourceManagementClientConfiguration\"], \"..._serialization\": [\"Deserializer\", \"Serializer\"]}}, \"typing\": {\"azurecore\": {\"azure.core.credentials_async\": [\"AsyncTokenCredential\"]}}}" }, "global_parameters": { "sync": { "credential": { - "signature": "credential, # type: \"TokenCredential\"", - "description": "Credential needed for the client to connect to Azure.", + "signature": "credential: \"TokenCredential\",", + "description": "Credential needed for the client to connect to Azure. Required.", "docstring_type": "~azure.core.credentials.TokenCredential", "required": true }, "subscription_id": { - "signature": "subscription_id, # type: str", - "description": "The ID of the target subscription.", + "signature": "subscription_id: str,", + "description": "The ID of the target subscription. Required.", "docstring_type": "str", "required": true } @@ -31,13 +31,13 @@ "async": { "credential": { "signature": "credential: \"AsyncTokenCredential\",", - "description": "Credential needed for the client to connect to Azure.", + "description": "Credential needed for the client to connect to Azure. Required.", "docstring_type": "~azure.core.credentials_async.AsyncTokenCredential", "required": true }, "subscription_id": { "signature": "subscription_id: str,", - "description": "The ID of the target subscription.", + "description": "The ID of the target subscription. Required.", "docstring_type": "str", "required": true } @@ -54,7 +54,7 @@ "required": false }, "base_url": { - "signature": "base_url=\"https://management.azure.com\", # type: str", + "signature": "base_url: str = \"https://management.azure.com\",", "description": "Service URL", "docstring_type": "str", "required": false diff --git a/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/resources/v2016_02_01/_patch.py b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/resources/v2016_02_01/_patch.py index 74e48ecd07cf3..f99e77fef9861 100644 --- a/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/resources/v2016_02_01/_patch.py +++ b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/resources/v2016_02_01/_patch.py @@ -28,4 +28,4 @@ # This file is used for handwritten extensions to the generated code. Example: # https://github.com/Azure/azure-sdk-for-python/blob/main/doc/dev/customize_code/how-to-patch-sdk-code.md def patch_sdk(): - pass \ No newline at end of file + pass diff --git a/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/resources/v2016_02_01/_resource_management_client.py b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/resources/v2016_02_01/_resource_management_client.py index ea17564977844..d8fe4f023b4af 100644 --- a/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/resources/v2016_02_01/_resource_management_client.py +++ b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/resources/v2016_02_01/_resource_management_client.py @@ -9,20 +9,27 @@ from copy import deepcopy from typing import Any, TYPE_CHECKING -from msrest import Deserializer, Serializer - from azure.core.rest import HttpRequest, HttpResponse from azure.mgmt.core import ARMPipelineClient from . import models +from .._serialization import Deserializer, Serializer from ._configuration import ResourceManagementClientConfiguration -from .operations import DeploymentOperationsOperations, DeploymentsOperations, ProvidersOperations, ResourceGroupsOperations, ResourcesOperations, TagsOperations +from .operations import ( + DeploymentOperationsOperations, + DeploymentsOperations, + ProvidersOperations, + ResourceGroupsOperations, + ResourcesOperations, + TagsOperations, +) if TYPE_CHECKING: # pylint: disable=unused-import,ungrouped-imports from azure.core.credentials import TokenCredential -class ResourceManagementClient: + +class ResourceManagementClient: # pylint: disable=client-accepts-api-version-keyword """ResourceManagementClient. :ivar deployments: DeploymentsOperations operations @@ -40,9 +47,9 @@ class ResourceManagementClient: :ivar deployment_operations: DeploymentOperationsOperations operations :vartype deployment_operations: azure.mgmt.resource.resources.v2016_02_01.operations.DeploymentOperationsOperations - :param credential: Credential needed for the client to connect to Azure. + :param credential: Credential needed for the client to connect to Azure. Required. :type credential: ~azure.core.credentials.TokenCredential - :param subscription_id: The ID of the target subscription. + :param subscription_id: The ID of the target subscription. Required. :type subscription_id: str :param base_url: Service URL. Default value is "https://management.azure.com". :type base_url: str @@ -60,7 +67,9 @@ def __init__( base_url: str = "https://management.azure.com", **kwargs: Any ) -> None: - self._config = ResourceManagementClientConfiguration(credential=credential, subscription_id=subscription_id, **kwargs) + self._config = ResourceManagementClientConfiguration( + credential=credential, subscription_id=subscription_id, **kwargs + ) self._client = ARMPipelineClient(base_url=base_url, config=self._config, **kwargs) client_models = {k: v for k, v in models.__dict__.items() if isinstance(v, type)} @@ -72,14 +81,11 @@ def __init__( self.resource_groups = ResourceGroupsOperations(self._client, self._config, self._serialize, self._deserialize) self.resources = ResourcesOperations(self._client, self._config, self._serialize, self._deserialize) self.tags = TagsOperations(self._client, self._config, self._serialize, self._deserialize) - self.deployment_operations = DeploymentOperationsOperations(self._client, self._config, self._serialize, self._deserialize) - + self.deployment_operations = DeploymentOperationsOperations( + self._client, self._config, self._serialize, self._deserialize + ) - def _send_request( - self, - request: HttpRequest, - **kwargs: Any - ) -> HttpResponse: + def _send_request(self, request: HttpRequest, **kwargs: Any) -> HttpResponse: """Runs the network request through the client's chained policies. >>> from azure.core.rest import HttpRequest @@ -88,7 +94,7 @@ def _send_request( >>> response = client._send_request(request) - For more information on this code flow, see https://aka.ms/azsdk/python/protocol/quickstart + For more information on this code flow, see https://aka.ms/azsdk/dpcodegen/python/send_request :param request: The network request you want to make. Required. :type request: ~azure.core.rest.HttpRequest diff --git a/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/resources/v2016_02_01/_vendor.py b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/resources/v2016_02_01/_vendor.py index 138f663c53a4e..9aad73fc743e7 100644 --- a/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/resources/v2016_02_01/_vendor.py +++ b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/resources/v2016_02_01/_vendor.py @@ -7,6 +7,7 @@ from azure.core.pipeline.transport import HttpRequest + def _convert_request(request, files=None): data = request.content if not files else None request = HttpRequest(method=request.method, url=request.url, headers=request.headers, data=data) @@ -14,6 +15,7 @@ def _convert_request(request, files=None): request.set_formdata_body(files) return request + def _format_url_section(template, **kwargs): components = template.split("/") while components: @@ -21,7 +23,5 @@ def _format_url_section(template, **kwargs): 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 - ] + components = [c for c in formatted_components if "{}".format(key.args[0]) not in c] template = "/".join(components) diff --git a/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/resources/v2016_02_01/_version.py b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/resources/v2016_02_01/_version.py index a012ac01c480c..e5754a47ce68f 100644 --- a/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/resources/v2016_02_01/_version.py +++ b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/resources/v2016_02_01/_version.py @@ -6,4 +6,4 @@ # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -VERSION = "21.1.0" +VERSION = "1.0.0b1" diff --git a/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/resources/v2016_02_01/aio/__init__.py b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/resources/v2016_02_01/aio/__init__.py index c6c3cf64a37a6..98d6782c2530c 100644 --- a/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/resources/v2016_02_01/aio/__init__.py +++ b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/resources/v2016_02_01/aio/__init__.py @@ -7,9 +7,15 @@ # -------------------------------------------------------------------------- from ._resource_management_client import ResourceManagementClient -__all__ = ['ResourceManagementClient'] -# `._patch.py` is used for handwritten extensions to the generated code -# Example: https://github.com/Azure/azure-sdk-for-python/blob/main/doc/dev/customize_code/how-to-patch-sdk-code.md -from ._patch import patch_sdk -patch_sdk() +try: + from ._patch import __all__ as _patch_all + from ._patch import * # type: ignore # pylint: disable=unused-wildcard-import +except ImportError: + _patch_all = [] +from ._patch import patch_sdk as _patch_sdk + +__all__ = ["ResourceManagementClient"] +__all__.extend([p for p in _patch_all if p not in __all__]) + +_patch_sdk() diff --git a/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/resources/v2016_02_01/aio/_configuration.py b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/resources/v2016_02_01/aio/_configuration.py index 6c541d0e1186f..9861c4dcbf33b 100644 --- a/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/resources/v2016_02_01/aio/_configuration.py +++ b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/resources/v2016_02_01/aio/_configuration.py @@ -25,23 +25,18 @@ class ResourceManagementClientConfiguration(Configuration): # pylint: disable=t Note that all parameters used to create this instance are saved as instance attributes. - :param credential: Credential needed for the client to connect to Azure. + :param credential: Credential needed for the client to connect to Azure. Required. :type credential: ~azure.core.credentials_async.AsyncTokenCredential - :param subscription_id: The ID of the target subscription. + :param subscription_id: The ID of the target subscription. Required. :type subscription_id: str :keyword api_version: Api Version. Default value is "2016-02-01". Note that overriding this default value may result in unsupported behavior. :paramtype api_version: str """ - def __init__( - self, - credential: "AsyncTokenCredential", - subscription_id: str, - **kwargs: Any - ) -> None: + def __init__(self, credential: "AsyncTokenCredential", subscription_id: str, **kwargs: Any) -> None: super(ResourceManagementClientConfiguration, self).__init__(**kwargs) - api_version = kwargs.pop('api_version', "2016-02-01") # type: str + api_version = kwargs.pop("api_version", "2016-02-01") # type: str if credential is None: raise ValueError("Parameter 'credential' must not be None.") @@ -51,22 +46,21 @@ def __init__( self.credential = credential self.subscription_id = subscription_id self.api_version = api_version - self.credential_scopes = kwargs.pop('credential_scopes', ['https://management.azure.com/.default']) - kwargs.setdefault('sdk_moniker', 'mgmt-resource/{}'.format(VERSION)) + self.credential_scopes = kwargs.pop("credential_scopes", ["https://management.azure.com/.default"]) + kwargs.setdefault("sdk_moniker", "mgmt-resource/{}".format(VERSION)) self._configure(**kwargs) - 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) - self.logging_policy = kwargs.get('logging_policy') or policies.NetworkTraceLoggingPolicy(**kwargs) - self.http_logging_policy = kwargs.get('http_logging_policy') or ARMHttpLoggingPolicy(**kwargs) - self.retry_policy = kwargs.get('retry_policy') or policies.AsyncRetryPolicy(**kwargs) - self.custom_hook_policy = kwargs.get('custom_hook_policy') or policies.CustomHookPolicy(**kwargs) - self.redirect_policy = kwargs.get('redirect_policy') or policies.AsyncRedirectPolicy(**kwargs) - self.authentication_policy = kwargs.get('authentication_policy') + 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) + self.logging_policy = kwargs.get("logging_policy") or policies.NetworkTraceLoggingPolicy(**kwargs) + self.http_logging_policy = kwargs.get("http_logging_policy") or ARMHttpLoggingPolicy(**kwargs) + self.retry_policy = kwargs.get("retry_policy") or policies.AsyncRetryPolicy(**kwargs) + self.custom_hook_policy = kwargs.get("custom_hook_policy") or policies.CustomHookPolicy(**kwargs) + self.redirect_policy = kwargs.get("redirect_policy") or policies.AsyncRedirectPolicy(**kwargs) + self.authentication_policy = kwargs.get("authentication_policy") if self.credential and not self.authentication_policy: - self.authentication_policy = AsyncARMChallengeAuthenticationPolicy(self.credential, *self.credential_scopes, **kwargs) + self.authentication_policy = AsyncARMChallengeAuthenticationPolicy( + self.credential, *self.credential_scopes, **kwargs + ) diff --git a/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/resources/v2016_02_01/aio/_patch.py b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/resources/v2016_02_01/aio/_patch.py index 74e48ecd07cf3..f99e77fef9861 100644 --- a/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/resources/v2016_02_01/aio/_patch.py +++ b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/resources/v2016_02_01/aio/_patch.py @@ -28,4 +28,4 @@ # This file is used for handwritten extensions to the generated code. Example: # https://github.com/Azure/azure-sdk-for-python/blob/main/doc/dev/customize_code/how-to-patch-sdk-code.md def patch_sdk(): - pass \ No newline at end of file + pass diff --git a/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/resources/v2016_02_01/aio/_resource_management_client.py b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/resources/v2016_02_01/aio/_resource_management_client.py index 429e6be562a29..3670fb3c648d0 100644 --- a/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/resources/v2016_02_01/aio/_resource_management_client.py +++ b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/resources/v2016_02_01/aio/_resource_management_client.py @@ -9,20 +9,27 @@ from copy import deepcopy from typing import Any, Awaitable, TYPE_CHECKING -from msrest import Deserializer, Serializer - from azure.core.rest import AsyncHttpResponse, HttpRequest from azure.mgmt.core import AsyncARMPipelineClient from .. import models +from ..._serialization import Deserializer, Serializer from ._configuration import ResourceManagementClientConfiguration -from .operations import DeploymentOperationsOperations, DeploymentsOperations, ProvidersOperations, ResourceGroupsOperations, ResourcesOperations, TagsOperations +from .operations import ( + DeploymentOperationsOperations, + DeploymentsOperations, + ProvidersOperations, + ResourceGroupsOperations, + ResourcesOperations, + TagsOperations, +) if TYPE_CHECKING: # pylint: disable=unused-import,ungrouped-imports from azure.core.credentials_async import AsyncTokenCredential -class ResourceManagementClient: + +class ResourceManagementClient: # pylint: disable=client-accepts-api-version-keyword """ResourceManagementClient. :ivar deployments: DeploymentsOperations operations @@ -42,9 +49,9 @@ class ResourceManagementClient: :ivar deployment_operations: DeploymentOperationsOperations operations :vartype deployment_operations: azure.mgmt.resource.resources.v2016_02_01.aio.operations.DeploymentOperationsOperations - :param credential: Credential needed for the client to connect to Azure. + :param credential: Credential needed for the client to connect to Azure. Required. :type credential: ~azure.core.credentials_async.AsyncTokenCredential - :param subscription_id: The ID of the target subscription. + :param subscription_id: The ID of the target subscription. Required. :type subscription_id: str :param base_url: Service URL. Default value is "https://management.azure.com". :type base_url: str @@ -62,7 +69,9 @@ def __init__( base_url: str = "https://management.azure.com", **kwargs: Any ) -> None: - self._config = ResourceManagementClientConfiguration(credential=credential, subscription_id=subscription_id, **kwargs) + self._config = ResourceManagementClientConfiguration( + credential=credential, subscription_id=subscription_id, **kwargs + ) self._client = AsyncARMPipelineClient(base_url=base_url, config=self._config, **kwargs) client_models = {k: v for k, v in models.__dict__.items() if isinstance(v, type)} @@ -74,14 +83,11 @@ def __init__( self.resource_groups = ResourceGroupsOperations(self._client, self._config, self._serialize, self._deserialize) self.resources = ResourcesOperations(self._client, self._config, self._serialize, self._deserialize) self.tags = TagsOperations(self._client, self._config, self._serialize, self._deserialize) - self.deployment_operations = DeploymentOperationsOperations(self._client, self._config, self._serialize, self._deserialize) - + self.deployment_operations = DeploymentOperationsOperations( + self._client, self._config, self._serialize, self._deserialize + ) - def _send_request( - self, - request: HttpRequest, - **kwargs: Any - ) -> Awaitable[AsyncHttpResponse]: + def _send_request(self, request: HttpRequest, **kwargs: Any) -> Awaitable[AsyncHttpResponse]: """Runs the network request through the client's chained policies. >>> from azure.core.rest import HttpRequest @@ -90,7 +96,7 @@ def _send_request( >>> response = await client._send_request(request) - For more information on this code flow, see https://aka.ms/azsdk/python/protocol/quickstart + For more information on this code flow, see https://aka.ms/azsdk/dpcodegen/python/send_request :param request: The network request you want to make. Required. :type request: ~azure.core.rest.HttpRequest diff --git a/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/resources/v2016_02_01/aio/operations/__init__.py b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/resources/v2016_02_01/aio/operations/__init__.py index ad38d1291a450..ada6e7edc9b2c 100644 --- a/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/resources/v2016_02_01/aio/operations/__init__.py +++ b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/resources/v2016_02_01/aio/operations/__init__.py @@ -13,11 +13,17 @@ from ._operations import TagsOperations from ._operations import DeploymentOperationsOperations +from ._patch import __all__ as _patch_all +from ._patch import * # type: ignore # pylint: disable=unused-wildcard-import +from ._patch import patch_sdk as _patch_sdk + __all__ = [ - 'DeploymentsOperations', - 'ProvidersOperations', - 'ResourceGroupsOperations', - 'ResourcesOperations', - 'TagsOperations', - 'DeploymentOperationsOperations', + "DeploymentsOperations", + "ProvidersOperations", + "ResourceGroupsOperations", + "ResourcesOperations", + "TagsOperations", + "DeploymentOperationsOperations", ] +__all__.extend([p for p in _patch_all if p not in __all__]) +_patch_sdk() diff --git a/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/resources/v2016_02_01/aio/operations/_operations.py b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/resources/v2016_02_01/aio/operations/_operations.py index 430a5f525c7e0..b73b5db859516 100644 --- a/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/resources/v2016_02_01/aio/operations/_operations.py +++ b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/resources/v2016_02_01/aio/operations/_operations.py @@ -6,77 +6,130 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -from typing import Any, AsyncIterable, Callable, Dict, Optional, TypeVar, Union +import sys +from typing import Any, AsyncIterable, Callable, Dict, IO, Optional, TypeVar, Union, cast, overload +from urllib.parse import parse_qs, urljoin, urlparse from azure.core.async_paging import AsyncItemPaged, AsyncList -from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error +from azure.core.exceptions import ( + ClientAuthenticationError, + HttpResponseError, + ResourceExistsError, + ResourceNotFoundError, + ResourceNotModifiedError, + map_error, +) from azure.core.pipeline import PipelineResponse from azure.core.pipeline.transport import AsyncHttpResponse from azure.core.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 from azure.mgmt.core.polling.async_arm_polling import AsyncARMPolling from ... import models as _models from ..._vendor import _convert_request -from ...operations._operations import build_deployment_operations_get_request, build_deployment_operations_list_request, build_deployments_calculate_template_hash_request, build_deployments_cancel_request, build_deployments_check_existence_request, build_deployments_create_or_update_request_initial, build_deployments_delete_request_initial, build_deployments_export_template_request, build_deployments_get_request, build_deployments_list_request, build_deployments_validate_request, build_providers_get_request, build_providers_list_request, build_providers_register_request, build_providers_unregister_request, build_resource_groups_check_existence_request, build_resource_groups_create_or_update_request, build_resource_groups_delete_request_initial, build_resource_groups_export_template_request, build_resource_groups_get_request, build_resource_groups_list_request, build_resource_groups_list_resources_request, build_resource_groups_patch_request, build_resources_check_existence_request, build_resources_create_or_update_request, build_resources_delete_request, build_resources_get_request, build_resources_list_request, build_resources_move_resources_request_initial, build_resources_update_request_initial, build_tags_create_or_update_request, build_tags_create_or_update_value_request, build_tags_delete_request, build_tags_delete_value_request, build_tags_list_request -T = TypeVar('T') +from ...operations._operations import ( + build_deployment_operations_get_request, + build_deployment_operations_list_request, + build_deployments_calculate_template_hash_request, + build_deployments_cancel_request, + build_deployments_check_existence_request, + build_deployments_create_or_update_request, + build_deployments_delete_request, + build_deployments_export_template_request, + build_deployments_get_request, + build_deployments_list_request, + build_deployments_validate_request, + build_providers_get_request, + build_providers_list_request, + build_providers_register_request, + build_providers_unregister_request, + build_resource_groups_check_existence_request, + build_resource_groups_create_or_update_request, + build_resource_groups_delete_request, + build_resource_groups_export_template_request, + build_resource_groups_get_request, + build_resource_groups_list_request, + build_resource_groups_list_resources_request, + build_resource_groups_patch_request, + build_resources_check_existence_request, + build_resources_create_or_update_request, + build_resources_delete_request, + build_resources_get_request, + build_resources_list_request, + build_resources_move_resources_request, + build_resources_update_request, + build_tags_create_or_update_request, + build_tags_create_or_update_value_request, + build_tags_delete_request, + build_tags_delete_value_request, + build_tags_list_request, +) + +if sys.version_info >= (3, 9): + from collections.abc import MutableMapping +else: + from typing import MutableMapping # type: ignore # pylint: disable=ungrouped-imports +JSON = MutableMapping[str, Any] # pylint: disable=unsubscriptable-object +T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] -class DeploymentsOperations: - """DeploymentsOperations async operations. - You should not instantiate this class directly. Instead, you should create a Client instance that - instantiates it for you and attaches it as an attribute. +class DeploymentsOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. - :ivar models: Alias to model classes used in this operation group. - :type models: ~azure.mgmt.resource.resources.v2016_02_01.models - :param client: Client for service requests. - :param config: Configuration of service client. - :param serializer: An object model serializer. - :param deserializer: An object model deserializer. + Instead, you should access the following operations through + :class:`~azure.mgmt.resource.resources.v2016_02_01.aio.ResourceManagementClient`'s + :attr:`deployments` attribute. """ models = _models - def __init__(self, client, config, serializer, deserializer) -> None: - self._client = client - self._serialize = serializer - self._deserialize = deserializer - self._config = config + def __init__(self, *args, **kwargs) -> None: + input_args = list(args) + self._client = input_args.pop(0) if input_args else kwargs.pop("client") + self._config = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") async def _delete_initial( # pylint: disable=inconsistent-return-statements - self, - resource_group_name: str, - deployment_name: str, - **kwargs: Any + self, resource_group_name: str, deployment_name: str, **kwargs: Any ) -> None: - cls = kwargs.pop('cls', None) # type: ClsType[None] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + 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', "2016-02-01") # type: str + api_version = kwargs.pop("api_version", _params.pop("api-version", "2016-02-01")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[None] - - request = build_deployments_delete_request_initial( + request = build_deployments_delete_request( resource_group_name=resource_group_name, deployment_name=deployment_name, subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self._delete_initial.metadata['url'], + template_url=self._delete_initial.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [202, 204]: @@ -86,21 +139,16 @@ 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.Resources/deployments/{deploymentName}"} # type: ignore - + _delete_initial.metadata = {"url": "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/Microsoft.Resources/deployments/{deploymentName}"} # type: ignore @distributed_trace_async - async def begin_delete( # pylint: disable=inconsistent-return-statements - self, - resource_group_name: str, - deployment_name: str, - **kwargs: Any - ) -> AsyncLROPoller[None]: + async def begin_delete(self, resource_group_name: str, deployment_name: str, **kwargs: Any) -> AsyncLROPoller[None]: """Delete deployment. :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. :type resource_group_name: str - :param deployment_name: The name of the deployment to be deleted. + :param deployment_name: The name of the deployment to be deleted. Required. :type deployment_name: str :keyword callable cls: A custom type or function that will be passed the direct response :keyword str continuation_token: A continuation token to restart a poller from a saved state. @@ -112,88 +160,93 @@ async def begin_delete( # pylint: disable=inconsistent-return-statements Retry-After header is present. :return: An instance of AsyncLROPoller that returns either None or the result of cls(response) :rtype: ~azure.core.polling.AsyncLROPoller[None] - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - api_version = kwargs.pop('api_version', "2016-02-01") # type: str - polling = kwargs.pop('polling', True) # type: Union[bool, AsyncPollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType[None] - lro_delay = kwargs.pop( - 'polling_interval', - self._config.polling_interval - ) - cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2016-02-01")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[None] + polling = kwargs.pop("polling", True) # type: Union[bool, AsyncPollingMethod] + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token = kwargs.pop("continuation_token", None) # type: Optional[str] if cont_token is None: - raw_result = await self._delete_initial( + raw_result = await self._delete_initial( # type: ignore resource_group_name=resource_group_name, deployment_name=deployment_name, api_version=api_version, - cls=lambda x,y,z: x, + cls=lambda x, y, z: x, + headers=_headers, + params=_params, **kwargs ) - kwargs.pop('error_map', None) + kwargs.pop("error_map", None) - def get_long_running_output(pipeline_response): + def get_long_running_output(pipeline_response): # pylint: disable=inconsistent-return-statements if cls: return cls(pipeline_response, None, {}) - - if polling is True: polling_method = AsyncARMPolling(lro_delay, **kwargs) - elif polling is False: polling_method = AsyncNoPolling() - else: polling_method = polling + if polling is True: + polling_method = cast(AsyncPollingMethod, AsyncARMPolling(lro_delay, **kwargs)) # type: AsyncPollingMethod + elif polling is False: + polling_method = cast(AsyncPollingMethod, AsyncNoPolling()) + else: + polling_method = polling if cont_token: return AsyncLROPoller.from_continuation_token( polling_method=polling_method, continuation_token=cont_token, client=self._client, - deserialization_callback=get_long_running_output + deserialization_callback=get_long_running_output, ) return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) - begin_delete.metadata = {'url': "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/Microsoft.Resources/deployments/{deploymentName}"} # type: ignore + begin_delete.metadata = {"url": "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/Microsoft.Resources/deployments/{deploymentName}"} # type: ignore @distributed_trace_async - async def check_existence( - self, - resource_group_name: str, - deployment_name: str, - **kwargs: Any - ) -> bool: + async def check_existence(self, resource_group_name: str, deployment_name: str, **kwargs: Any) -> bool: """Checks whether deployment exists. :param resource_group_name: The name of the resource group to check. The name is case - insensitive. + insensitive. Required. :type resource_group_name: str - :param deployment_name: The name of the deployment. + :param deployment_name: The name of the deployment. Required. :type deployment_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: bool, or the result of cls(response) + :return: bool or the result of cls(response) :rtype: bool - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType[None] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) - api_version = kwargs.pop('api_version', "2016-02-01") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2016-02-01")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[None] - request = build_deployments_check_existence_request( resource_group_name=resource_group_name, deployment_name=deployment_name, subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.check_existence.metadata['url'], + template_url=self.check_existence.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [204, 404]: @@ -204,44 +257,53 @@ async def check_existence( return cls(pipeline_response, None, {}) return 200 <= response.status_code <= 299 - check_existence.metadata = {'url': "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/Microsoft.Resources/deployments/{deploymentName}"} # type: ignore - + check_existence.metadata = {"url": "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/Microsoft.Resources/deployments/{deploymentName}"} # type: ignore async def _create_or_update_initial( - self, - resource_group_name: str, - deployment_name: str, - parameters: "_models.Deployment", - **kwargs: Any - ) -> "_models.DeploymentExtended": - cls = kwargs.pop('cls', None) # type: ClsType["_models.DeploymentExtended"] + self, resource_group_name: str, deployment_name: str, parameters: Union[_models.Deployment, IO], **kwargs: Any + ) -> _models.DeploymentExtended: error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', "2016-02-01") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + api_version = kwargs.pop("api_version", _params.pop("api-version", "2016-02-01")) # type: str + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.DeploymentExtended] - _json = self._serialize.body(parameters, 'Deployment') + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(parameters, (IO, bytes)): + _content = parameters + else: + _json = self._serialize.body(parameters, "Deployment") - request = build_deployments_create_or_update_request_initial( + request = build_deployments_create_or_update_request( resource_group_name=resource_group_name, deployment_name=deployment_name, subscription_id=self._config.subscription_id, api_version=api_version, content_type=content_type, json=_json, - template_url=self._create_or_update_initial.metadata['url'], + content=_content, + template_url=self._create_or_update_initial.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200, 201]: @@ -249,35 +311,40 @@ async def _create_or_update_initial( raise HttpResponseError(response=response, error_format=ARMErrorFormat) if response.status_code == 200: - deserialized = self._deserialize('DeploymentExtended', pipeline_response) + deserialized = self._deserialize("DeploymentExtended", pipeline_response) if response.status_code == 201: - deserialized = self._deserialize('DeploymentExtended', pipeline_response) + deserialized = self._deserialize("DeploymentExtended", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - _create_or_update_initial.metadata = {'url': "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/Microsoft.Resources/deployments/{deploymentName}"} # type: ignore - + _create_or_update_initial.metadata = {"url": "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/Microsoft.Resources/deployments/{deploymentName}"} # type: ignore - @distributed_trace_async + @overload async def begin_create_or_update( self, resource_group_name: str, deployment_name: str, - parameters: "_models.Deployment", + parameters: _models.Deployment, + *, + content_type: str = "application/json", **kwargs: Any - ) -> AsyncLROPoller["_models.DeploymentExtended"]: + ) -> AsyncLROPoller[_models.DeploymentExtended]: """Create a named template deployment using a template. :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. :type resource_group_name: str - :param deployment_name: The name of the deployment. + :param deployment_name: The name of the deployment. Required. :type deployment_name: str - :param parameters: Additional parameters supplied to the operation. + :param parameters: Additional parameters supplied to the operation. Required. :type parameters: ~azure.mgmt.resource.resources.v2016_02_01.models.Deployment + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str :keyword callable cls: A custom type or function that will be passed the direct response :keyword str continuation_token: A continuation token to restart a poller from a saved state. :keyword polling: By default, your polling method will be AsyncARMPolling. Pass in False for @@ -290,152 +357,228 @@ async def begin_create_or_update( cls(response) :rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.resource.resources.v2016_02_01.models.DeploymentExtended] - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - api_version = kwargs.pop('api_version', "2016-02-01") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] - polling = kwargs.pop('polling', True) # type: Union[bool, AsyncPollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType["_models.DeploymentExtended"] - lro_delay = kwargs.pop( - 'polling_interval', - self._config.polling_interval - ) - cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] + + @overload + async def begin_create_or_update( + self, + resource_group_name: str, + deployment_name: str, + parameters: IO, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> AsyncLROPoller[_models.DeploymentExtended]: + """Create a named template deployment using a template. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param deployment_name: The name of the deployment. Required. + :type deployment_name: str + :param parameters: Additional parameters supplied to the operation. Required. + :type parameters: IO + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be AsyncARMPolling. Pass in False for + this operation to not poll, or pass in your own initialized polling object for a personal + polling strategy. + :paramtype polling: bool or ~azure.core.polling.AsyncPollingMethod + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of AsyncLROPoller that returns either DeploymentExtended or the result of + cls(response) + :rtype: + ~azure.core.polling.AsyncLROPoller[~azure.mgmt.resource.resources.v2016_02_01.models.DeploymentExtended] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace_async + async def begin_create_or_update( + self, resource_group_name: str, deployment_name: str, parameters: Union[_models.Deployment, IO], **kwargs: Any + ) -> AsyncLROPoller[_models.DeploymentExtended]: + """Create a named template deployment using a template. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param deployment_name: The name of the deployment. Required. + :type deployment_name: str + :param parameters: Additional parameters supplied to the operation. Is either a model type or a + IO type. Required. + :type parameters: ~azure.mgmt.resource.resources.v2016_02_01.models.Deployment or IO + :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. + Default value is None. + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be AsyncARMPolling. Pass in False for + this operation to not poll, or pass in your own initialized polling object for a personal + polling strategy. + :paramtype polling: bool or ~azure.core.polling.AsyncPollingMethod + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of AsyncLROPoller that returns either DeploymentExtended or the result of + cls(response) + :rtype: + ~azure.core.polling.AsyncLROPoller[~azure.mgmt.resource.resources.v2016_02_01.models.DeploymentExtended] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _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", "2016-02-01")) # type: str + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.DeploymentExtended] + polling = kwargs.pop("polling", True) # type: Union[bool, AsyncPollingMethod] + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token = kwargs.pop("continuation_token", None) # type: Optional[str] if cont_token is None: - raw_result = await self._create_or_update_initial( + raw_result = await self._create_or_update_initial( # type: ignore resource_group_name=resource_group_name, deployment_name=deployment_name, parameters=parameters, api_version=api_version, content_type=content_type, - cls=lambda x,y,z: x, + cls=lambda x, y, z: x, + headers=_headers, + params=_params, **kwargs ) - kwargs.pop('error_map', None) + kwargs.pop("error_map", None) def get_long_running_output(pipeline_response): - response = pipeline_response.http_response - deserialized = self._deserialize('DeploymentExtended', pipeline_response) + deserialized = self._deserialize("DeploymentExtended", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - - if polling is True: polling_method = AsyncARMPolling(lro_delay, **kwargs) - elif polling is False: polling_method = AsyncNoPolling() - else: polling_method = polling + if polling is True: + polling_method = cast(AsyncPollingMethod, AsyncARMPolling(lro_delay, **kwargs)) # type: AsyncPollingMethod + elif polling is False: + polling_method = cast(AsyncPollingMethod, AsyncNoPolling()) + else: + polling_method = polling if cont_token: return AsyncLROPoller.from_continuation_token( polling_method=polling_method, continuation_token=cont_token, client=self._client, - deserialization_callback=get_long_running_output + deserialization_callback=get_long_running_output, ) return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) - begin_create_or_update.metadata = {'url': "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/Microsoft.Resources/deployments/{deploymentName}"} # type: ignore + begin_create_or_update.metadata = {"url": "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/Microsoft.Resources/deployments/{deploymentName}"} # type: ignore @distributed_trace_async - async def get( - self, - resource_group_name: str, - deployment_name: str, - **kwargs: Any - ) -> "_models.DeploymentExtended": + async def get(self, resource_group_name: str, deployment_name: str, **kwargs: Any) -> _models.DeploymentExtended: """Get a deployment. :param resource_group_name: The name of the resource group to get. The name is case - insensitive. + insensitive. Required. :type resource_group_name: str - :param deployment_name: The name of the deployment. + :param deployment_name: The name of the deployment. Required. :type deployment_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: DeploymentExtended, or the result of cls(response) + :return: DeploymentExtended or the result of cls(response) :rtype: ~azure.mgmt.resource.resources.v2016_02_01.models.DeploymentExtended - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.DeploymentExtended"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) - api_version = kwargs.pop('api_version', "2016-02-01") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2016-02-01")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[_models.DeploymentExtended] - request = build_deployments_get_request( resource_group_name=resource_group_name, deployment_name=deployment_name, subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.get.metadata['url'], + template_url=self.get.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) - deserialized = self._deserialize('DeploymentExtended', pipeline_response) + deserialized = self._deserialize("DeploymentExtended", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - get.metadata = {'url': "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/Microsoft.Resources/deployments/{deploymentName}"} # type: ignore - + get.metadata = {"url": "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/Microsoft.Resources/deployments/{deploymentName}"} # type: ignore @distributed_trace_async async def cancel( # pylint: disable=inconsistent-return-statements - self, - resource_group_name: str, - deployment_name: str, - **kwargs: Any + self, resource_group_name: str, deployment_name: str, **kwargs: Any ) -> None: """Cancel a currently running template deployment. :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. :type resource_group_name: str - :param deployment_name: The name of the deployment. + :param deployment_name: The name of the deployment. Required. :type deployment_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: None, or the result of cls(response) + :return: None or the result of cls(response) :rtype: None - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType[None] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + 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', "2016-02-01") # type: str + api_version = kwargs.pop("api_version", _params.pop("api-version", "2016-02-01")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[None] - request = build_deployments_cancel_request( resource_group_name=resource_group_name, deployment_name=deployment_name, subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.cancel.metadata['url'], + template_url=self.cancel.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [204]: @@ -445,40 +588,107 @@ async def cancel( # pylint: disable=inconsistent-return-statements if cls: return cls(pipeline_response, None, {}) - cancel.metadata = {'url': "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/Microsoft.Resources/deployments/{deploymentName}/cancel"} # type: ignore - + cancel.metadata = {"url": "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/Microsoft.Resources/deployments/{deploymentName}/cancel"} # type: ignore - @distributed_trace_async + @overload async def validate( self, resource_group_name: str, deployment_name: str, - parameters: "_models.Deployment", + parameters: _models.Deployment, + *, + content_type: str = "application/json", **kwargs: Any - ) -> "_models.DeploymentValidateResult": + ) -> _models.DeploymentValidateResult: """Validate a deployment template. :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. :type resource_group_name: str - :param deployment_name: The name of the deployment. + :param deployment_name: The name of the deployment. Required. :type deployment_name: str - :param parameters: Deployment to validate. + :param parameters: Deployment to validate. Required. :type parameters: ~azure.mgmt.resource.resources.v2016_02_01.models.Deployment + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: DeploymentValidateResult or the result of cls(response) + :rtype: ~azure.mgmt.resource.resources.v2016_02_01.models.DeploymentValidateResult + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + async def validate( + self, + resource_group_name: str, + deployment_name: str, + parameters: IO, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.DeploymentValidateResult: + """Validate a deployment template. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param deployment_name: The name of the deployment. Required. + :type deployment_name: str + :param parameters: Deployment to validate. Required. + :type parameters: IO + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: DeploymentValidateResult or the result of cls(response) + :rtype: ~azure.mgmt.resource.resources.v2016_02_01.models.DeploymentValidateResult + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace_async + async def validate( + self, resource_group_name: str, deployment_name: str, parameters: Union[_models.Deployment, IO], **kwargs: Any + ) -> _models.DeploymentValidateResult: + """Validate a deployment template. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param deployment_name: The name of the deployment. Required. + :type deployment_name: str + :param parameters: Deployment to validate. Is either a model type or a IO type. Required. + :type parameters: ~azure.mgmt.resource.resources.v2016_02_01.models.Deployment or IO + :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. + Default value is None. + :paramtype content_type: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: DeploymentValidateResult, or the result of cls(response) + :return: DeploymentValidateResult or the result of cls(response) :rtype: ~azure.mgmt.resource.resources.v2016_02_01.models.DeploymentValidateResult - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.DeploymentValidateResult"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) - api_version = kwargs.pop('api_version', "2016-02-01") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - _json = self._serialize.body(parameters, 'Deployment') + api_version = kwargs.pop("api_version", _params.pop("api-version", "2016-02-01")) # type: str + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.DeploymentValidateResult] + + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(parameters, (IO, bytes)): + _content = parameters + else: + _json = self._serialize.body(parameters, "Deployment") request = build_deployments_validate_request( resource_group_name=resource_group_name, @@ -487,16 +697,18 @@ async def validate( api_version=api_version, content_type=content_type, json=_json, - template_url=self.validate.metadata['url'], + content=_content, + template_url=self.validate.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200, 400]: @@ -504,131 +716,136 @@ async def validate( raise HttpResponseError(response=response, error_format=ARMErrorFormat) if response.status_code == 200: - deserialized = self._deserialize('DeploymentValidateResult', pipeline_response) + deserialized = self._deserialize("DeploymentValidateResult", pipeline_response) if response.status_code == 400: - deserialized = self._deserialize('DeploymentValidateResult', pipeline_response) + deserialized = self._deserialize("DeploymentValidateResult", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - validate.metadata = {'url': "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/Microsoft.Resources/deployments/{deploymentName}/validate"} # type: ignore - + validate.metadata = {"url": "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/Microsoft.Resources/deployments/{deploymentName}/validate"} # type: ignore @distributed_trace_async async def export_template( - self, - resource_group_name: str, - deployment_name: str, - **kwargs: Any - ) -> "_models.DeploymentExportResult": + self, resource_group_name: str, deployment_name: str, **kwargs: Any + ) -> _models.DeploymentExportResult: """Exports a deployment template. :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. :type resource_group_name: str - :param deployment_name: The name of the deployment. + :param deployment_name: The name of the deployment. Required. :type deployment_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: DeploymentExportResult, or the result of cls(response) + :return: DeploymentExportResult or the result of cls(response) :rtype: ~azure.mgmt.resource.resources.v2016_02_01.models.DeploymentExportResult - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.DeploymentExportResult"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + 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', "2016-02-01") # type: str + api_version = kwargs.pop("api_version", _params.pop("api-version", "2016-02-01")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[_models.DeploymentExportResult] - request = build_deployments_export_template_request( resource_group_name=resource_group_name, deployment_name=deployment_name, subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.export_template.metadata['url'], + template_url=self.export_template.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) - deserialized = self._deserialize('DeploymentExportResult', pipeline_response) + deserialized = self._deserialize("DeploymentExportResult", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - export_template.metadata = {'url': "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/Microsoft.Resources/deployments/{deploymentName}/exportTemplate"} # type: ignore - + export_template.metadata = {"url": "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/Microsoft.Resources/deployments/{deploymentName}/exportTemplate"} # type: ignore @distributed_trace def list( - self, - resource_group_name: str, - filter: Optional[str] = None, - top: Optional[int] = None, - **kwargs: Any - ) -> AsyncIterable["_models.DeploymentListResult"]: + self, resource_group_name: str, filter: Optional[str] = None, top: Optional[int] = None, **kwargs: Any + ) -> AsyncIterable["_models.DeploymentExtended"]: """Get a list of deployments. :param resource_group_name: The name of the resource group to filter by. The name is case - insensitive. + insensitive. Required. :type resource_group_name: str :param filter: The filter to apply on the operation. Default value is None. :type filter: str :param top: Query parameters. If null is passed returns all deployments. Default value is None. :type top: int :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either DeploymentListResult or the result of - cls(response) + :return: An iterator like instance of either DeploymentExtended or the result of cls(response) :rtype: - ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.resource.resources.v2016_02_01.models.DeploymentListResult] - :raises: ~azure.core.exceptions.HttpResponseError + ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.resource.resources.v2016_02_01.models.DeploymentExtended] + :raises ~azure.core.exceptions.HttpResponseError: """ - api_version = kwargs.pop('api_version', "2016-02-01") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2016-02-01")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[_models.DeploymentListResult] - cls = kwargs.pop('cls', None) # type: ClsType["_models.DeploymentListResult"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) + def prepare_request(next_link=None): if not next_link: - + request = build_deployments_list_request( resource_group_name=resource_group_name, subscription_id=self._config.subscription_id, - api_version=api_version, filter=filter, top=top, - template_url=self.list.metadata['url'], + 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.url = self._client.format_url(request.url) # type: ignore else: - - request = build_deployments_list_request( - resource_group_name=resource_group_name, - subscription_id=self._config.subscription_id, - template_url=next_link, - ) + # make call to next link with the client's api-version + _parsed_next_link = urlparse(next_link) + _next_request_params = case_insensitive_dict(parse_qs(_parsed_next_link.query)) + _next_request_params["api-version"] = self._config.api_version + request = HttpRequest("GET", urljoin(next_link, _parsed_next_link.path), params=_next_request_params) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore request.method = "GET" return request @@ -642,10 +859,8 @@ async def extract_data(pipeline_response): async def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) response = pipeline_response.http_response @@ -655,204 +870,202 @@ async def get_next(next_link=None): return pipeline_response + return AsyncItemPaged(get_next, extract_data) - return AsyncItemPaged( - get_next, extract_data - ) - list.metadata = {'url': "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/Microsoft.Resources/deployments/"} # type: ignore + list.metadata = {"url": "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/Microsoft.Resources/deployments/"} # type: ignore @distributed_trace_async - async def calculate_template_hash( - self, - template: Any, - **kwargs: Any - ) -> "_models.TemplateHashResult": + async def calculate_template_hash(self, template: JSON, **kwargs: Any) -> _models.TemplateHashResult: """Calculate the hash of the given template. - :param template: The template provided to calculate hash. - :type template: any + :param template: The template provided to calculate hash. Required. + :type template: JSON :keyword callable cls: A custom type or function that will be passed the direct response - :return: TemplateHashResult, or the result of cls(response) + :return: TemplateHashResult or the result of cls(response) :rtype: ~azure.mgmt.resource.resources.v2016_02_01.models.TemplateHashResult - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.TemplateHashResult"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', "2016-02-01") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + api_version = kwargs.pop("api_version", _params.pop("api-version", "2016-02-01")) # type: str + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", "application/json")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[_models.TemplateHashResult] - _json = self._serialize.body(template, 'object') + _json = self._serialize.body(template, "object") request = build_deployments_calculate_template_hash_request( api_version=api_version, content_type=content_type, json=_json, - template_url=self.calculate_template_hash.metadata['url'], + template_url=self.calculate_template_hash.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) - deserialized = self._deserialize('TemplateHashResult', pipeline_response) + deserialized = self._deserialize("TemplateHashResult", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - calculate_template_hash.metadata = {'url': "/providers/Microsoft.Resources/calculateTemplateHash"} # type: ignore + calculate_template_hash.metadata = {"url": "/providers/Microsoft.Resources/calculateTemplateHash"} # type: ignore -class ProvidersOperations: - """ProvidersOperations async operations. - You should not instantiate this class directly. Instead, you should create a Client instance that - instantiates it for you and attaches it as an attribute. +class ProvidersOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. - :ivar models: Alias to model classes used in this operation group. - :type models: ~azure.mgmt.resource.resources.v2016_02_01.models - :param client: Client for service requests. - :param config: Configuration of service client. - :param serializer: An object model serializer. - :param deserializer: An object model deserializer. + Instead, you should access the following operations through + :class:`~azure.mgmt.resource.resources.v2016_02_01.aio.ResourceManagementClient`'s + :attr:`providers` attribute. """ models = _models - def __init__(self, client, config, serializer, deserializer) -> None: - self._client = client - self._serialize = serializer - self._deserialize = deserializer - self._config = config + def __init__(self, *args, **kwargs) -> None: + input_args = list(args) + self._client = input_args.pop(0) if input_args else kwargs.pop("client") + self._config = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") @distributed_trace_async - async def unregister( - self, - resource_provider_namespace: str, - **kwargs: Any - ) -> "_models.Provider": + async def unregister(self, resource_provider_namespace: str, **kwargs: Any) -> _models.Provider: """Unregisters provider from a subscription. - :param resource_provider_namespace: Namespace of the resource provider. + :param resource_provider_namespace: Namespace of the resource provider. Required. :type resource_provider_namespace: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: Provider, or the result of cls(response) + :return: Provider or the result of cls(response) :rtype: ~azure.mgmt.resource.resources.v2016_02_01.models.Provider - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.Provider"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + 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', "2016-02-01") # type: str + api_version = kwargs.pop("api_version", _params.pop("api-version", "2016-02-01")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[_models.Provider] - request = build_providers_unregister_request( resource_provider_namespace=resource_provider_namespace, subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.unregister.metadata['url'], + template_url=self.unregister.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) - deserialized = self._deserialize('Provider', pipeline_response) + deserialized = self._deserialize("Provider", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - unregister.metadata = {'url': "/subscriptions/{subscriptionId}/providers/{resourceProviderNamespace}/unregister"} # type: ignore - + unregister.metadata = {"url": "/subscriptions/{subscriptionId}/providers/{resourceProviderNamespace}/unregister"} # type: ignore @distributed_trace_async - async def register( - self, - resource_provider_namespace: str, - **kwargs: Any - ) -> "_models.Provider": + async def register(self, resource_provider_namespace: str, **kwargs: Any) -> _models.Provider: """Registers provider to be used with a subscription. - :param resource_provider_namespace: Namespace of the resource provider. + :param resource_provider_namespace: Namespace of the resource provider. Required. :type resource_provider_namespace: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: Provider, or the result of cls(response) + :return: Provider or the result of cls(response) :rtype: ~azure.mgmt.resource.resources.v2016_02_01.models.Provider - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.Provider"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + 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', "2016-02-01") # type: str + api_version = kwargs.pop("api_version", _params.pop("api-version", "2016-02-01")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[_models.Provider] - request = build_providers_register_request( resource_provider_namespace=resource_provider_namespace, subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.register.metadata['url'], + template_url=self.register.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) - deserialized = self._deserialize('Provider', pipeline_response) + deserialized = self._deserialize("Provider", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - register.metadata = {'url': "/subscriptions/{subscriptionId}/providers/{resourceProviderNamespace}/register"} # type: ignore - + register.metadata = {"url": "/subscriptions/{subscriptionId}/providers/{resourceProviderNamespace}/register"} # type: ignore @distributed_trace def list( - self, - top: Optional[int] = None, - expand: Optional[str] = None, - **kwargs: Any - ) -> AsyncIterable["_models.ProviderListResult"]: + self, top: Optional[int] = None, expand: Optional[str] = None, **kwargs: Any + ) -> AsyncIterable["_models.Provider"]: """Gets a list of resource providers. :param top: Query parameters. If null is passed returns all deployments. Default value is None. @@ -861,39 +1074,48 @@ def list( $expand=resourceTypes/aliases. Default value is None. :type expand: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either ProviderListResult or the result of cls(response) + :return: An iterator like instance of either Provider or the result of cls(response) :rtype: - ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.resource.resources.v2016_02_01.models.ProviderListResult] - :raises: ~azure.core.exceptions.HttpResponseError + ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.resource.resources.v2016_02_01.models.Provider] + :raises ~azure.core.exceptions.HttpResponseError: """ - api_version = kwargs.pop('api_version', "2016-02-01") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2016-02-01")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[_models.ProviderListResult] - cls = kwargs.pop('cls', None) # type: ClsType["_models.ProviderListResult"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) + def prepare_request(next_link=None): if not next_link: - + request = build_providers_list_request( subscription_id=self._config.subscription_id, - api_version=api_version, top=top, expand=expand, - template_url=self.list.metadata['url'], + 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.url = self._client.format_url(request.url) # type: ignore else: - - request = build_providers_list_request( - subscription_id=self._config.subscription_id, - template_url=next_link, - ) + # make call to next link with the client's api-version + _parsed_next_link = urlparse(next_link) + _next_request_params = case_insensitive_dict(parse_qs(_parsed_next_link.query)) + _next_request_params["api-version"] = self._config.api_version + request = HttpRequest("GET", urljoin(next_link, _parsed_next_link.path), params=_next_request_params) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore request.method = "GET" return request @@ -907,10 +1129,8 @@ async def extract_data(pipeline_response): async def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) response = pipeline_response.http_response @@ -920,91 +1140,90 @@ async def get_next(next_link=None): return pipeline_response + return AsyncItemPaged(get_next, extract_data) - return AsyncItemPaged( - get_next, extract_data - ) - list.metadata = {'url': "/subscriptions/{subscriptionId}/providers"} # type: ignore + list.metadata = {"url": "/subscriptions/{subscriptionId}/providers"} # type: ignore @distributed_trace_async async def get( - self, - resource_provider_namespace: str, - expand: Optional[str] = None, - **kwargs: Any - ) -> "_models.Provider": + self, resource_provider_namespace: str, expand: Optional[str] = None, **kwargs: Any + ) -> _models.Provider: """Gets a resource provider. - :param resource_provider_namespace: Namespace of the resource provider. + :param resource_provider_namespace: Namespace of the resource provider. Required. :type resource_provider_namespace: str :param expand: The $expand query parameter. e.g. To include property aliases in response, use $expand=resourceTypes/aliases. Default value is None. :type expand: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: Provider, or the result of cls(response) + :return: Provider or the result of cls(response) :rtype: ~azure.mgmt.resource.resources.v2016_02_01.models.Provider - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.Provider"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) - api_version = kwargs.pop('api_version', "2016-02-01") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2016-02-01")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[_models.Provider] - request = build_providers_get_request( resource_provider_namespace=resource_provider_namespace, subscription_id=self._config.subscription_id, - api_version=api_version, expand=expand, - template_url=self.get.metadata['url'], + api_version=api_version, + template_url=self.get.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) - deserialized = self._deserialize('Provider', pipeline_response) + deserialized = self._deserialize("Provider", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - get.metadata = {'url': "/subscriptions/{subscriptionId}/providers/{resourceProviderNamespace}"} # type: ignore + get.metadata = {"url": "/subscriptions/{subscriptionId}/providers/{resourceProviderNamespace}"} # type: ignore -class ResourceGroupsOperations: - """ResourceGroupsOperations async operations. - You should not instantiate this class directly. Instead, you should create a Client instance that - instantiates it for you and attaches it as an attribute. +class ResourceGroupsOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. - :ivar models: Alias to model classes used in this operation group. - :type models: ~azure.mgmt.resource.resources.v2016_02_01.models - :param client: Client for service requests. - :param config: Configuration of service client. - :param serializer: An object model serializer. - :param deserializer: An object model deserializer. + Instead, you should access the following operations through + :class:`~azure.mgmt.resource.resources.v2016_02_01.aio.ResourceManagementClient`'s + :attr:`resource_groups` attribute. """ models = _models - def __init__(self, client, config, serializer, deserializer) -> None: - self._client = client - self._serialize = serializer - self._deserialize = deserializer - self._config = config + def __init__(self, *args, **kwargs) -> None: + input_args = list(args) + self._client = input_args.pop(0) if input_args else kwargs.pop("client") + self._config = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") @distributed_trace def list_resources( @@ -1014,10 +1233,11 @@ def list_resources( expand: Optional[str] = None, top: Optional[int] = None, **kwargs: Any - ) -> AsyncIterable["_models.ResourceListResult"]: + ) -> AsyncIterable["_models.GenericResourceExpanded"]: """Get all of the resources under a subscription. :param resource_group_name: Query parameters. If null is passed returns all resource groups. + Required. :type resource_group_name: str :param filter: The filter to apply on the operation. Default value is None. :type filter: str @@ -1029,42 +1249,51 @@ def list_resources( None. :type top: int :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either ResourceListResult or the result of cls(response) + :return: An iterator like instance of either GenericResourceExpanded or the result of + cls(response) :rtype: - ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.resource.resources.v2016_02_01.models.ResourceListResult] - :raises: ~azure.core.exceptions.HttpResponseError + ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.resource.resources.v2016_02_01.models.GenericResourceExpanded] + :raises ~azure.core.exceptions.HttpResponseError: """ - api_version = kwargs.pop('api_version', "2016-02-01") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2016-02-01")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[_models.ResourceListResult] - cls = kwargs.pop('cls', None) # type: ClsType["_models.ResourceListResult"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) + def prepare_request(next_link=None): if not next_link: - + request = build_resource_groups_list_resources_request( resource_group_name=resource_group_name, subscription_id=self._config.subscription_id, - api_version=api_version, filter=filter, expand=expand, top=top, - template_url=self.list_resources.metadata['url'], + api_version=api_version, + template_url=self.list_resources.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore else: - - request = build_resource_groups_list_resources_request( - resource_group_name=resource_group_name, - subscription_id=self._config.subscription_id, - template_url=next_link, - ) + # make call to next link with the client's api-version + _parsed_next_link = urlparse(next_link) + _next_request_params = case_insensitive_dict(parse_qs(_parsed_next_link.query)) + _next_request_params["api-version"] = self._config.api_version + request = HttpRequest("GET", urljoin(next_link, _parsed_next_link.path), params=_next_request_params) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore request.method = "GET" return request @@ -1078,10 +1307,8 @@ async def extract_data(pipeline_response): async def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) response = pipeline_response.http_response @@ -1091,51 +1318,51 @@ async def get_next(next_link=None): return pipeline_response + return AsyncItemPaged(get_next, extract_data) - return AsyncItemPaged( - get_next, extract_data - ) - list_resources.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/resources"} # type: ignore + list_resources.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/resources"} # type: ignore @distributed_trace_async - async def check_existence( - self, - resource_group_name: str, - **kwargs: Any - ) -> bool: + async def check_existence(self, resource_group_name: str, **kwargs: Any) -> bool: """Checks whether resource group exists. :param resource_group_name: The name of the resource group to check. The name is case - insensitive. + insensitive. Required. :type resource_group_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: bool, or the result of cls(response) + :return: bool or the result of cls(response) :rtype: bool - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType[None] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) - api_version = kwargs.pop('api_version', "2016-02-01") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2016-02-01")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[None] - request = build_resource_groups_check_existence_request( resource_group_name=resource_group_name, subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.check_existence.metadata['url'], + template_url=self.check_existence.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [204, 404]: @@ -1146,38 +1373,94 @@ async def check_existence( return cls(pipeline_response, None, {}) return 200 <= response.status_code <= 299 - check_existence.metadata = {'url': "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}"} # type: ignore + check_existence.metadata = {"url": "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}"} # type: ignore - - @distributed_trace_async + @overload async def create_or_update( self, resource_group_name: str, - parameters: "_models.ResourceGroup", + parameters: _models.ResourceGroup, + *, + content_type: str = "application/json", **kwargs: Any - ) -> "_models.ResourceGroup": + ) -> _models.ResourceGroup: """Create a resource group. - :param resource_group_name: The name of the resource group to be created or updated. + :param resource_group_name: The name of the resource group to be created or updated. Required. :type resource_group_name: str :param parameters: Parameters supplied to the create or update resource group service - operation. + operation. Required. :type parameters: ~azure.mgmt.resource.resources.v2016_02_01.models.ResourceGroup + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: ResourceGroup or the result of cls(response) + :rtype: ~azure.mgmt.resource.resources.v2016_02_01.models.ResourceGroup + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + async def create_or_update( + self, resource_group_name: str, parameters: IO, *, content_type: str = "application/json", **kwargs: Any + ) -> _models.ResourceGroup: + """Create a resource group. + + :param resource_group_name: The name of the resource group to be created or updated. Required. + :type resource_group_name: str + :param parameters: Parameters supplied to the create or update resource group service + operation. Required. + :type parameters: IO + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: ResourceGroup or the result of cls(response) + :rtype: ~azure.mgmt.resource.resources.v2016_02_01.models.ResourceGroup + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace_async + async def create_or_update( + self, resource_group_name: str, parameters: Union[_models.ResourceGroup, IO], **kwargs: Any + ) -> _models.ResourceGroup: + """Create a resource group. + + :param resource_group_name: The name of the resource group to be created or updated. Required. + :type resource_group_name: str + :param parameters: Parameters supplied to the create or update resource group service + operation. Is either a model type or a IO type. Required. + :type parameters: ~azure.mgmt.resource.resources.v2016_02_01.models.ResourceGroup or IO + :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. + Default value is None. + :paramtype content_type: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: ResourceGroup, or the result of cls(response) + :return: ResourceGroup or the result of cls(response) :rtype: ~azure.mgmt.resource.resources.v2016_02_01.models.ResourceGroup - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.ResourceGroup"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', "2016-02-01") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + api_version = kwargs.pop("api_version", _params.pop("api-version", "2016-02-01")) # type: str + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.ResourceGroup] - _json = self._serialize.body(parameters, 'ResourceGroup') + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(parameters, (IO, bytes)): + _content = parameters + else: + _json = self._serialize.body(parameters, "ResourceGroup") request = build_resource_groups_create_or_update_request( resource_group_name=resource_group_name, @@ -1185,16 +1468,18 @@ async def create_or_update( api_version=api_version, content_type=content_type, json=_json, - template_url=self.create_or_update.metadata['url'], + content=_content, + template_url=self.create_or_update.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200, 201]: @@ -1202,47 +1487,50 @@ async def create_or_update( raise HttpResponseError(response=response, error_format=ARMErrorFormat) if response.status_code == 200: - deserialized = self._deserialize('ResourceGroup', pipeline_response) + deserialized = self._deserialize("ResourceGroup", pipeline_response) if response.status_code == 201: - deserialized = self._deserialize('ResourceGroup', pipeline_response) + deserialized = self._deserialize("ResourceGroup", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - create_or_update.metadata = {'url': "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}"} # type: ignore - + create_or_update.metadata = {"url": "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}"} # type: ignore async def _delete_initial( # pylint: disable=inconsistent-return-statements - self, - resource_group_name: str, - **kwargs: Any + self, resource_group_name: str, **kwargs: Any ) -> None: - cls = kwargs.pop('cls', None) # type: ClsType[None] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + 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', "2016-02-01") # type: str + api_version = kwargs.pop("api_version", _params.pop("api-version", "2016-02-01")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[None] - - request = build_resource_groups_delete_request_initial( + request = build_resource_groups_delete_request( resource_group_name=resource_group_name, subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self._delete_initial.metadata['url'], + template_url=self._delete_initial.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200, 202]: @@ -1252,19 +1540,14 @@ async def _delete_initial( # pylint: disable=inconsistent-return-statements if cls: return cls(pipeline_response, None, {}) - _delete_initial.metadata = {'url': "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}"} # type: ignore - + _delete_initial.metadata = {"url": "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}"} # type: ignore @distributed_trace_async - async def begin_delete( # pylint: disable=inconsistent-return-statements - self, - resource_group_name: str, - **kwargs: Any - ) -> AsyncLROPoller[None]: + async def begin_delete(self, resource_group_name: str, **kwargs: Any) -> AsyncLROPoller[None]: """Delete resource group. :param resource_group_name: The name of the resource group to be deleted. The name is case - insensitive. + insensitive. Required. :type resource_group_name: str :keyword callable cls: A custom type or function that will be passed the direct response :keyword str continuation_token: A continuation token to restart a poller from a saved state. @@ -1276,130 +1559,199 @@ async def begin_delete( # pylint: disable=inconsistent-return-statements Retry-After header is present. :return: An instance of AsyncLROPoller that returns either None or the result of cls(response) :rtype: ~azure.core.polling.AsyncLROPoller[None] - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - api_version = kwargs.pop('api_version', "2016-02-01") # type: str - polling = kwargs.pop('polling', True) # type: Union[bool, AsyncPollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType[None] - lro_delay = kwargs.pop( - 'polling_interval', - self._config.polling_interval - ) - cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2016-02-01")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[None] + polling = kwargs.pop("polling", True) # type: Union[bool, AsyncPollingMethod] + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token = kwargs.pop("continuation_token", None) # type: Optional[str] if cont_token is None: - raw_result = await self._delete_initial( + raw_result = await self._delete_initial( # type: ignore resource_group_name=resource_group_name, api_version=api_version, - cls=lambda x,y,z: x, + cls=lambda x, y, z: x, + headers=_headers, + params=_params, **kwargs ) - kwargs.pop('error_map', None) + kwargs.pop("error_map", None) - def get_long_running_output(pipeline_response): + def get_long_running_output(pipeline_response): # pylint: disable=inconsistent-return-statements if cls: return cls(pipeline_response, None, {}) - - if polling is True: polling_method = AsyncARMPolling(lro_delay, **kwargs) - elif polling is False: polling_method = AsyncNoPolling() - else: polling_method = polling + if polling is True: + polling_method = cast(AsyncPollingMethod, AsyncARMPolling(lro_delay, **kwargs)) # type: AsyncPollingMethod + elif polling is False: + polling_method = cast(AsyncPollingMethod, AsyncNoPolling()) + else: + polling_method = polling if cont_token: return AsyncLROPoller.from_continuation_token( polling_method=polling_method, continuation_token=cont_token, client=self._client, - deserialization_callback=get_long_running_output + deserialization_callback=get_long_running_output, ) return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) - begin_delete.metadata = {'url': "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}"} # type: ignore + begin_delete.metadata = {"url": "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}"} # type: ignore @distributed_trace_async - async def get( - self, - resource_group_name: str, - **kwargs: Any - ) -> "_models.ResourceGroup": + async def get(self, resource_group_name: str, **kwargs: Any) -> _models.ResourceGroup: """Get a resource group. :param resource_group_name: The name of the resource group to get. The name is case - insensitive. + insensitive. Required. :type resource_group_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: ResourceGroup, or the result of cls(response) + :return: ResourceGroup or the result of cls(response) :rtype: ~azure.mgmt.resource.resources.v2016_02_01.models.ResourceGroup - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.ResourceGroup"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + 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', "2016-02-01") # type: str + api_version = kwargs.pop("api_version", _params.pop("api-version", "2016-02-01")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[_models.ResourceGroup] - request = build_resource_groups_get_request( resource_group_name=resource_group_name, subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.get.metadata['url'], + template_url=self.get.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) - deserialized = self._deserialize('ResourceGroup', pipeline_response) + deserialized = self._deserialize("ResourceGroup", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - get.metadata = {'url': "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}"} # type: ignore - + get.metadata = {"url": "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}"} # type: ignore - @distributed_trace_async + @overload async def patch( self, resource_group_name: str, - parameters: "_models.ResourceGroup", + parameters: _models.ResourceGroup, + *, + content_type: str = "application/json", **kwargs: Any - ) -> "_models.ResourceGroup": + ) -> _models.ResourceGroup: """Resource groups can be updated through a simple PATCH operation to a group address. The format of the request is the same as that for creating a resource groups, though if a field is unspecified current value will be carried over. :param resource_group_name: The name of the resource group to be created or updated. The name - is case insensitive. + is case insensitive. Required. :type resource_group_name: str :param parameters: Parameters supplied to the update state resource group service operation. + Required. :type parameters: ~azure.mgmt.resource.resources.v2016_02_01.models.ResourceGroup + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: ResourceGroup or the result of cls(response) + :rtype: ~azure.mgmt.resource.resources.v2016_02_01.models.ResourceGroup + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + async def patch( + self, resource_group_name: str, parameters: IO, *, content_type: str = "application/json", **kwargs: Any + ) -> _models.ResourceGroup: + """Resource groups can be updated through a simple PATCH operation to a group address. The format + of the request is the same as that for creating a resource groups, though if a field is + unspecified current value will be carried over. + + :param resource_group_name: The name of the resource group to be created or updated. The name + is case insensitive. Required. + :type resource_group_name: str + :param parameters: Parameters supplied to the update state resource group service operation. + Required. + :type parameters: IO + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: ResourceGroup or the result of cls(response) + :rtype: ~azure.mgmt.resource.resources.v2016_02_01.models.ResourceGroup + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace_async + async def patch( + self, resource_group_name: str, parameters: Union[_models.ResourceGroup, IO], **kwargs: Any + ) -> _models.ResourceGroup: + """Resource groups can be updated through a simple PATCH operation to a group address. The format + of the request is the same as that for creating a resource groups, though if a field is + unspecified current value will be carried over. + + :param resource_group_name: The name of the resource group to be created or updated. The name + is case insensitive. Required. + :type resource_group_name: str + :param parameters: Parameters supplied to the update state resource group service operation. Is + either a model type or a IO type. Required. + :type parameters: ~azure.mgmt.resource.resources.v2016_02_01.models.ResourceGroup or IO + :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. + Default value is None. + :paramtype content_type: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: ResourceGroup, or the result of cls(response) + :return: ResourceGroup or the result of cls(response) :rtype: ~azure.mgmt.resource.resources.v2016_02_01.models.ResourceGroup - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.ResourceGroup"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) - api_version = kwargs.pop('api_version', "2016-02-01") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - _json = self._serialize.body(parameters, 'ResourceGroup') + api_version = kwargs.pop("api_version", _params.pop("api-version", "2016-02-01")) # type: str + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.ResourceGroup] + + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(parameters, (IO, bytes)): + _content = parameters + else: + _json = self._serialize.body(parameters, "ResourceGroup") request = build_resource_groups_patch_request( resource_group_name=resource_group_name, @@ -1407,60 +1759,119 @@ async def patch( api_version=api_version, content_type=content_type, json=_json, - template_url=self.patch.metadata['url'], + content=_content, + template_url=self.patch.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) - deserialized = self._deserialize('ResourceGroup', pipeline_response) + deserialized = self._deserialize("ResourceGroup", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - patch.metadata = {'url': "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}"} # type: ignore - + patch.metadata = {"url": "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}"} # type: ignore - @distributed_trace_async + @overload async def export_template( self, resource_group_name: str, - parameters: "_models.ExportTemplateRequest", + parameters: _models.ExportTemplateRequest, + *, + content_type: str = "application/json", **kwargs: Any - ) -> "_models.ResourceGroupExportResult": + ) -> _models.ResourceGroupExportResult: """Captures the specified resource group as a template. - :param resource_group_name: The name of the resource group to be created or updated. + :param resource_group_name: The name of the resource group to be created or updated. Required. :type resource_group_name: str :param parameters: Parameters supplied to the export template resource group operation. + Required. :type parameters: ~azure.mgmt.resource.resources.v2016_02_01.models.ExportTemplateRequest + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: ResourceGroupExportResult, or the result of cls(response) + :return: ResourceGroupExportResult or the result of cls(response) :rtype: ~azure.mgmt.resource.resources.v2016_02_01.models.ResourceGroupExportResult - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + async def export_template( + self, resource_group_name: str, parameters: IO, *, content_type: str = "application/json", **kwargs: Any + ) -> _models.ResourceGroupExportResult: + """Captures the specified resource group as a template. + + :param resource_group_name: The name of the resource group to be created or updated. Required. + :type resource_group_name: str + :param parameters: Parameters supplied to the export template resource group operation. + Required. + :type parameters: IO + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: ResourceGroupExportResult or the result of cls(response) + :rtype: ~azure.mgmt.resource.resources.v2016_02_01.models.ResourceGroupExportResult + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace_async + async def export_template( + self, resource_group_name: str, parameters: Union[_models.ExportTemplateRequest, IO], **kwargs: Any + ) -> _models.ResourceGroupExportResult: + """Captures the specified resource group as a template. + + :param resource_group_name: The name of the resource group to be created or updated. Required. + :type resource_group_name: str + :param parameters: Parameters supplied to the export template resource group operation. Is + either a model type or a IO type. Required. + :type parameters: ~azure.mgmt.resource.resources.v2016_02_01.models.ExportTemplateRequest or IO + :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. + Default value is None. + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: ResourceGroupExportResult or the result of cls(response) + :rtype: ~azure.mgmt.resource.resources.v2016_02_01.models.ResourceGroupExportResult + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.ResourceGroupExportResult"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', "2016-02-01") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + api_version = kwargs.pop("api_version", _params.pop("api-version", "2016-02-01")) # type: str + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.ResourceGroupExportResult] - _json = self._serialize.body(parameters, 'ExportTemplateRequest') + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(parameters, (IO, bytes)): + _content = parameters + else: + _json = self._serialize.body(parameters, "ExportTemplateRequest") request = build_resource_groups_export_template_request( resource_group_name=resource_group_name, @@ -1468,39 +1879,37 @@ async def export_template( api_version=api_version, content_type=content_type, json=_json, - template_url=self.export_template.metadata['url'], + content=_content, + template_url=self.export_template.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) - deserialized = self._deserialize('ResourceGroupExportResult', pipeline_response) + deserialized = self._deserialize("ResourceGroupExportResult", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - export_template.metadata = {'url': "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/exportTemplate"} # type: ignore - + export_template.metadata = {"url": "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/exportTemplate"} # type: ignore @distributed_trace def list( - self, - filter: Optional[str] = None, - top: Optional[int] = None, - **kwargs: Any - ) -> AsyncIterable["_models.ResourceGroupListResult"]: + self, filter: Optional[str] = None, top: Optional[int] = None, **kwargs: Any + ) -> AsyncIterable["_models.ResourceGroup"]: """Gets a collection of resource groups. :param filter: The filter to apply on the operation. Default value is None. @@ -1509,40 +1918,48 @@ def list( None. :type top: int :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either ResourceGroupListResult or the result of - cls(response) + :return: An iterator like instance of either ResourceGroup or the result of cls(response) :rtype: - ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.resource.resources.v2016_02_01.models.ResourceGroupListResult] - :raises: ~azure.core.exceptions.HttpResponseError + ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.resource.resources.v2016_02_01.models.ResourceGroup] + :raises ~azure.core.exceptions.HttpResponseError: """ - api_version = kwargs.pop('api_version', "2016-02-01") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2016-02-01")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[_models.ResourceGroupListResult] - cls = kwargs.pop('cls', None) # type: ClsType["_models.ResourceGroupListResult"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) + def prepare_request(next_link=None): if not next_link: - + request = build_resource_groups_list_request( subscription_id=self._config.subscription_id, - api_version=api_version, filter=filter, top=top, - template_url=self.list.metadata['url'], + 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.url = self._client.format_url(request.url) # type: ignore else: - - request = build_resource_groups_list_request( - subscription_id=self._config.subscription_id, - template_url=next_link, - ) + # make call to next link with the client's api-version + _parsed_next_link = urlparse(next_link) + _next_request_params = case_insensitive_dict(parse_qs(_parsed_next_link.query)) + _next_request_params["api-version"] = self._config.api_version + request = HttpRequest("GET", urljoin(next_link, _parsed_next_link.path), params=_next_request_params) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore request.method = "GET" return request @@ -1556,10 +1973,8 @@ async def extract_data(pipeline_response): async def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) response = pipeline_response.http_response @@ -1569,66 +1984,74 @@ async def get_next(next_link=None): return pipeline_response + return AsyncItemPaged(get_next, extract_data) - return AsyncItemPaged( - get_next, extract_data - ) - list.metadata = {'url': "/subscriptions/{subscriptionId}/resourcegroups"} # type: ignore -class ResourcesOperations: - """ResourcesOperations async operations. + list.metadata = {"url": "/subscriptions/{subscriptionId}/resourcegroups"} # type: ignore - You should not instantiate this class directly. Instead, you should create a Client instance that - instantiates it for you and attaches it as an attribute. - :ivar models: Alias to model classes used in this operation group. - :type models: ~azure.mgmt.resource.resources.v2016_02_01.models - :param client: Client for service requests. - :param config: Configuration of service client. - :param serializer: An object model serializer. - :param deserializer: An object model deserializer. +class ResourcesOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. + + Instead, you should access the following operations through + :class:`~azure.mgmt.resource.resources.v2016_02_01.aio.ResourceManagementClient`'s + :attr:`resources` attribute. """ models = _models - def __init__(self, client, config, serializer, deserializer) -> None: - self._client = client - self._serialize = serializer - self._deserialize = deserializer - self._config = config + def __init__(self, *args, **kwargs) -> None: + input_args = list(args) + self._client = input_args.pop(0) if input_args else kwargs.pop("client") + self._config = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") async def _move_resources_initial( # pylint: disable=inconsistent-return-statements - self, - source_resource_group_name: str, - parameters: "_models.ResourcesMoveInfo", - **kwargs: Any + self, source_resource_group_name: str, parameters: Union[_models.ResourcesMoveInfo, IO], **kwargs: Any ) -> None: - cls = kwargs.pop('cls', None) # type: ClsType[None] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', "2016-02-01") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + api_version = kwargs.pop("api_version", _params.pop("api-version", "2016-02-01")) # type: str + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[None] - _json = self._serialize.body(parameters, 'ResourcesMoveInfo') + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(parameters, (IO, bytes)): + _content = parameters + else: + _json = self._serialize.body(parameters, "ResourcesMoveInfo") - request = build_resources_move_resources_request_initial( + request = build_resources_move_resources_request( source_resource_group_name=source_resource_group_name, subscription_id=self._config.subscription_id, api_version=api_version, content_type=content_type, json=_json, - template_url=self._move_resources_initial.metadata['url'], + content=_content, + template_url=self._move_resources_initial.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [202, 204]: @@ -1638,23 +2061,27 @@ async def _move_resources_initial( # pylint: disable=inconsistent-return-statem if cls: return cls(pipeline_response, None, {}) - _move_resources_initial.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{sourceResourceGroupName}/moveResources"} # type: ignore + _move_resources_initial.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{sourceResourceGroupName}/moveResources"} # type: ignore - - @distributed_trace_async - async def begin_move_resources( # pylint: disable=inconsistent-return-statements + @overload + async def begin_move_resources( self, source_resource_group_name: str, - parameters: "_models.ResourcesMoveInfo", + parameters: _models.ResourcesMoveInfo, + *, + content_type: str = "application/json", **kwargs: Any ) -> AsyncLROPoller[None]: """Move resources from one resource group to another. The resources being moved should all be in the same resource group. - :param source_resource_group_name: Source resource group name. + :param source_resource_group_name: Source resource group name. Required. :type source_resource_group_name: str - :param parameters: move resources' parameters. + :param parameters: move resources' parameters. Required. :type parameters: ~azure.mgmt.resource.resources.v2016_02_01.models.ResourcesMoveInfo + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str :keyword callable cls: A custom type or function that will be passed the direct response :keyword str continuation_token: A continuation token to restart a poller from a saved state. :keyword polling: By default, your polling method will be AsyncARMPolling. Pass in False for @@ -1665,55 +2092,109 @@ async def begin_move_resources( # pylint: disable=inconsistent-return-statement Retry-After header is present. :return: An instance of AsyncLROPoller that returns either None or the result of cls(response) :rtype: ~azure.core.polling.AsyncLROPoller[None] - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - api_version = kwargs.pop('api_version', "2016-02-01") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] - polling = kwargs.pop('polling', True) # type: Union[bool, AsyncPollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType[None] - lro_delay = kwargs.pop( - 'polling_interval', - self._config.polling_interval - ) - cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] + + @overload + async def begin_move_resources( + self, source_resource_group_name: str, parameters: IO, *, content_type: str = "application/json", **kwargs: Any + ) -> AsyncLROPoller[None]: + """Move resources from one resource group to another. The resources being moved should all be in + the same resource group. + + :param source_resource_group_name: Source resource group name. Required. + :type source_resource_group_name: str + :param parameters: move resources' parameters. Required. + :type parameters: IO + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be AsyncARMPolling. Pass in False for + this operation to not poll, or pass in your own initialized polling object for a personal + polling strategy. + :paramtype polling: bool or ~azure.core.polling.AsyncPollingMethod + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of AsyncLROPoller that returns either None or the result of cls(response) + :rtype: ~azure.core.polling.AsyncLROPoller[None] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace_async + async def begin_move_resources( + self, source_resource_group_name: str, parameters: Union[_models.ResourcesMoveInfo, IO], **kwargs: Any + ) -> AsyncLROPoller[None]: + """Move resources from one resource group to another. The resources being moved should all be in + the same resource group. + + :param source_resource_group_name: Source resource group name. Required. + :type source_resource_group_name: str + :param parameters: move resources' parameters. Is either a model type or a IO type. Required. + :type parameters: ~azure.mgmt.resource.resources.v2016_02_01.models.ResourcesMoveInfo or IO + :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. + Default value is None. + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be AsyncARMPolling. Pass in False for + this operation to not poll, or pass in your own initialized polling object for a personal + polling strategy. + :paramtype polling: bool or ~azure.core.polling.AsyncPollingMethod + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of AsyncLROPoller that returns either None or the result of cls(response) + :rtype: ~azure.core.polling.AsyncLROPoller[None] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _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", "2016-02-01")) # type: str + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[None] + polling = kwargs.pop("polling", True) # type: Union[bool, AsyncPollingMethod] + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token = kwargs.pop("continuation_token", None) # type: Optional[str] if cont_token is None: - raw_result = await self._move_resources_initial( + raw_result = await self._move_resources_initial( # type: ignore source_resource_group_name=source_resource_group_name, parameters=parameters, api_version=api_version, content_type=content_type, - cls=lambda x,y,z: x, + cls=lambda x, y, z: x, + headers=_headers, + params=_params, **kwargs ) - kwargs.pop('error_map', None) + kwargs.pop("error_map", None) - def get_long_running_output(pipeline_response): + def get_long_running_output(pipeline_response): # pylint: disable=inconsistent-return-statements if cls: return cls(pipeline_response, None, {}) - - if polling is True: polling_method = AsyncARMPolling(lro_delay, **kwargs) - elif polling is False: polling_method = AsyncNoPolling() - else: polling_method = polling + if polling is True: + polling_method = cast(AsyncPollingMethod, AsyncARMPolling(lro_delay, **kwargs)) # type: AsyncPollingMethod + elif polling is False: + polling_method = cast(AsyncPollingMethod, AsyncNoPolling()) + else: + polling_method = polling if cont_token: return AsyncLROPoller.from_continuation_token( polling_method=polling_method, continuation_token=cont_token, client=self._client, - deserialization_callback=get_long_running_output + deserialization_callback=get_long_running_output, ) return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) - begin_move_resources.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{sourceResourceGroupName}/moveResources"} # type: ignore + begin_move_resources.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{sourceResourceGroupName}/moveResources"} # type: ignore @distributed_trace def list( - self, - filter: Optional[str] = None, - expand: Optional[str] = None, - top: Optional[int] = None, - **kwargs: Any - ) -> AsyncIterable["_models.ResourceListResult"]: + self, filter: Optional[str] = None, expand: Optional[str] = None, top: Optional[int] = None, **kwargs: Any + ) -> AsyncIterable["_models.GenericResourceExpanded"]: """Get all of the resources under a subscription. :param filter: The filter to apply on the operation. Default value is None. @@ -1726,40 +2207,50 @@ def list( value is None. :type top: int :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either ResourceListResult or the result of cls(response) + :return: An iterator like instance of either GenericResourceExpanded or the result of + cls(response) :rtype: - ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.resource.resources.v2016_02_01.models.ResourceListResult] - :raises: ~azure.core.exceptions.HttpResponseError + ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.resource.resources.v2016_02_01.models.GenericResourceExpanded] + :raises ~azure.core.exceptions.HttpResponseError: """ - api_version = kwargs.pop('api_version', "2016-02-01") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2016-02-01")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[_models.ResourceListResult] - cls = kwargs.pop('cls', None) # type: ClsType["_models.ResourceListResult"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) + def prepare_request(next_link=None): if not next_link: - + request = build_resources_list_request( subscription_id=self._config.subscription_id, - api_version=api_version, filter=filter, expand=expand, top=top, - template_url=self.list.metadata['url'], + 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.url = self._client.format_url(request.url) # type: ignore else: - - request = build_resources_list_request( - subscription_id=self._config.subscription_id, - template_url=next_link, - ) + # make call to next link with the client's api-version + _parsed_next_link = urlparse(next_link) + _next_request_params = case_insensitive_dict(parse_qs(_parsed_next_link.query)) + _next_request_params["api-version"] = self._config.api_version + request = HttpRequest("GET", urljoin(next_link, _parsed_next_link.path), params=_next_request_params) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore request.method = "GET" return request @@ -1773,10 +2264,8 @@ async def extract_data(pipeline_response): async def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) response = pipeline_response.http_response @@ -1786,11 +2275,9 @@ async def get_next(next_link=None): return pipeline_response + return AsyncItemPaged(get_next, extract_data) - return AsyncItemPaged( - get_next, extract_data - ) - list.metadata = {'url': "/subscriptions/{subscriptionId}/resources"} # type: ignore + list.metadata = {"url": "/subscriptions/{subscriptionId}/resources"} # type: ignore @distributed_trace_async async def check_existence( @@ -1806,29 +2293,36 @@ async def check_existence( """Checks whether resource exists. :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. :type resource_group_name: str - :param resource_provider_namespace: Resource identity. + :param resource_provider_namespace: Resource identity. Required. :type resource_provider_namespace: str - :param parent_resource_path: Resource identity. + :param parent_resource_path: Resource identity. Required. :type parent_resource_path: str - :param resource_type: Resource identity. + :param resource_type: Resource identity. Required. :type resource_type: str - :param resource_name: Resource identity. + :param resource_name: Resource identity. Required. :type resource_name: str - :param api_version: + :param api_version: Required. :type api_version: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: bool, or the result of cls(response) + :return: bool or the result of cls(response) :rtype: bool - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType[None] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = kwargs.pop("params", {}) or {} + + cls = kwargs.pop("cls", None) # type: ClsType[None] - request = build_resources_check_existence_request( resource_group_name=resource_group_name, resource_provider_namespace=resource_provider_namespace, @@ -1837,16 +2331,17 @@ async def check_existence( resource_name=resource_name, subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.check_existence.metadata['url'], + template_url=self.check_existence.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [204, 404]: @@ -1857,8 +2352,7 @@ async def check_existence( return cls(pipeline_response, None, {}) return 200 <= response.status_code <= 299 - check_existence.metadata = {'url': "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{parentResourcePath}/{resourceType}/{resourceName}"} # type: ignore - + check_existence.metadata = {"url": "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{parentResourcePath}/{resourceType}/{resourceName}"} # type: ignore @distributed_trace_async async def delete( # pylint: disable=inconsistent-return-statements @@ -1874,29 +2368,36 @@ async def delete( # pylint: disable=inconsistent-return-statements """Delete resource and all of its resources. :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. :type resource_group_name: str - :param resource_provider_namespace: Resource identity. + :param resource_provider_namespace: Resource identity. Required. :type resource_provider_namespace: str - :param parent_resource_path: Resource identity. + :param parent_resource_path: Resource identity. Required. :type parent_resource_path: str - :param resource_type: Resource identity. + :param resource_type: Resource identity. Required. :type resource_type: str - :param resource_name: Resource identity. + :param resource_name: Resource identity. Required. :type resource_name: str - :param api_version: + :param api_version: Required. :type api_version: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: None, or the result of cls(response) + :return: None or the result of cls(response) :rtype: None - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType[None] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = kwargs.pop("params", {}) or {} + + cls = kwargs.pop("cls", None) # type: ClsType[None] - request = build_resources_delete_request( resource_group_name=resource_group_name, resource_provider_namespace=resource_provider_namespace, @@ -1905,16 +2406,17 @@ async def delete( # pylint: disable=inconsistent-return-statements resource_name=resource_name, subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.delete.metadata['url'], + template_url=self.delete.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200, 202, 204]: @@ -1924,8 +2426,87 @@ async def delete( # pylint: disable=inconsistent-return-statements if cls: return cls(pipeline_response, None, {}) - delete.metadata = {'url': "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{parentResourcePath}/{resourceType}/{resourceName}"} # type: ignore + delete.metadata = {"url": "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{parentResourcePath}/{resourceType}/{resourceName}"} # type: ignore + + @overload + async def create_or_update( + self, + resource_group_name: str, + resource_provider_namespace: str, + parent_resource_path: str, + resource_type: str, + resource_name: str, + api_version: str, + parameters: _models.GenericResource, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.GenericResource: + """Create a resource. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param resource_provider_namespace: Resource identity. Required. + :type resource_provider_namespace: str + :param parent_resource_path: Resource identity. Required. + :type parent_resource_path: str + :param resource_type: Resource identity. Required. + :type resource_type: str + :param resource_name: Resource identity. Required. + :type resource_name: str + :param api_version: Required. + :type api_version: str + :param parameters: Create or update resource parameters. Required. + :type parameters: ~azure.mgmt.resource.resources.v2016_02_01.models.GenericResource + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: GenericResource or the result of cls(response) + :rtype: ~azure.mgmt.resource.resources.v2016_02_01.models.GenericResource + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + async def create_or_update( + self, + resource_group_name: str, + resource_provider_namespace: str, + parent_resource_path: str, + resource_type: str, + resource_name: str, + api_version: str, + parameters: IO, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.GenericResource: + """Create a resource. + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param resource_provider_namespace: Resource identity. Required. + :type resource_provider_namespace: str + :param parent_resource_path: Resource identity. Required. + :type parent_resource_path: str + :param resource_type: Resource identity. Required. + :type resource_type: str + :param resource_name: Resource identity. Required. + :type resource_name: str + :param api_version: Required. + :type api_version: str + :param parameters: Create or update resource parameters. Required. + :type parameters: IO + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: GenericResource or the result of cls(response) + :rtype: ~azure.mgmt.resource.resources.v2016_02_01.models.GenericResource + :raises ~azure.core.exceptions.HttpResponseError: + """ @distributed_trace_async async def create_or_update( @@ -1936,39 +2517,56 @@ async def create_or_update( resource_type: str, resource_name: str, api_version: str, - parameters: "_models.GenericResource", + parameters: Union[_models.GenericResource, IO], **kwargs: Any - ) -> "_models.GenericResource": + ) -> _models.GenericResource: """Create a resource. :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. :type resource_group_name: str - :param resource_provider_namespace: Resource identity. + :param resource_provider_namespace: Resource identity. Required. :type resource_provider_namespace: str - :param parent_resource_path: Resource identity. + :param parent_resource_path: Resource identity. Required. :type parent_resource_path: str - :param resource_type: Resource identity. + :param resource_type: Resource identity. Required. :type resource_type: str - :param resource_name: Resource identity. + :param resource_name: Resource identity. Required. :type resource_name: str - :param api_version: + :param api_version: Required. :type api_version: str - :param parameters: Create or update resource parameters. - :type parameters: ~azure.mgmt.resource.resources.v2016_02_01.models.GenericResource + :param parameters: Create or update resource parameters. Is either a model type or a IO type. + Required. + :type parameters: ~azure.mgmt.resource.resources.v2016_02_01.models.GenericResource or IO + :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. + Default value is None. + :paramtype content_type: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: GenericResource, or the result of cls(response) + :return: GenericResource or the result of cls(response) :rtype: ~azure.mgmt.resource.resources.v2016_02_01.models.GenericResource - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.GenericResource"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = kwargs.pop("params", {}) or {} - _json = self._serialize.body(parameters, 'GenericResource') + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.GenericResource] + + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(parameters, (IO, bytes)): + _content = parameters + else: + _json = self._serialize.body(parameters, "GenericResource") request = build_resources_create_or_update_request( resource_group_name=resource_group_name, @@ -1977,19 +2575,21 @@ async def create_or_update( resource_type=resource_type, resource_name=resource_name, subscription_id=self._config.subscription_id, - content_type=content_type, api_version=api_version, + content_type=content_type, json=_json, - template_url=self.create_or_update.metadata['url'], + content=_content, + template_url=self.create_or_update.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200, 201]: @@ -1997,18 +2597,17 @@ async def create_or_update( raise HttpResponseError(response=response, error_format=ARMErrorFormat) if response.status_code == 200: - deserialized = self._deserialize('GenericResource', pipeline_response) + deserialized = self._deserialize("GenericResource", pipeline_response) if response.status_code == 201: - deserialized = self._deserialize('GenericResource', pipeline_response) + deserialized = self._deserialize("GenericResource", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - create_or_update.metadata = {'url': "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{parentResourcePath}/{resourceType}/{resourceName}"} # type: ignore - + create_or_update.metadata = {"url": "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{parentResourcePath}/{resourceType}/{resourceName}"} # type: ignore async def _update_initial( self, @@ -2018,39 +2617,53 @@ async def _update_initial( resource_type: str, resource_name: str, api_version: str, - parameters: "_models.GenericResource", + parameters: Union[_models.GenericResource, IO], **kwargs: Any - ) -> Optional["_models.GenericResource"]: - cls = kwargs.pop('cls', None) # type: ClsType[Optional["_models.GenericResource"]] + ) -> Optional[_models.GenericResource]: error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = kwargs.pop("params", {}) or {} - _json = self._serialize.body(parameters, 'GenericResource') + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[Optional[_models.GenericResource]] - request = build_resources_update_request_initial( + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(parameters, (IO, bytes)): + _content = parameters + else: + _json = self._serialize.body(parameters, "GenericResource") + + request = build_resources_update_request( resource_group_name=resource_group_name, resource_provider_namespace=resource_provider_namespace, parent_resource_path=parent_resource_path, resource_type=resource_type, resource_name=resource_name, subscription_id=self._config.subscription_id, - content_type=content_type, api_version=api_version, + content_type=content_type, json=_json, - template_url=self._update_initial.metadata['url'], + content=_content, + template_url=self._update_initial.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200, 202]: @@ -2059,15 +2672,112 @@ async def _update_initial( deserialized = None if response.status_code == 200: - deserialized = self._deserialize('GenericResource', pipeline_response) + deserialized = self._deserialize("GenericResource", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - _update_initial.metadata = {'url': "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{parentResourcePath}/{resourceType}/{resourceName}"} # type: ignore + _update_initial.metadata = {"url": "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{parentResourcePath}/{resourceType}/{resourceName}"} # type: ignore + @overload + async def begin_update( + self, + resource_group_name: str, + resource_provider_namespace: str, + parent_resource_path: str, + resource_type: str, + resource_name: str, + api_version: str, + parameters: _models.GenericResource, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> AsyncLROPoller[_models.GenericResource]: + """Updates a resource. + + :param resource_group_name: The name of the resource group for the resource. The name is case + insensitive. Required. + :type resource_group_name: str + :param resource_provider_namespace: The namespace of the resource provider. Required. + :type resource_provider_namespace: str + :param parent_resource_path: The parent resource identity. Required. + :type parent_resource_path: str + :param resource_type: The resource type of the resource to update. Required. + :type resource_type: str + :param resource_name: The name of the resource to update. Required. + :type resource_name: str + :param api_version: The API version to use for the operation. Required. + :type api_version: str + :param parameters: Parameters for updating the resource. Required. + :type parameters: ~azure.mgmt.resource.resources.v2016_02_01.models.GenericResource + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be AsyncARMPolling. Pass in False for + this operation to not poll, or pass in your own initialized polling object for a personal + polling strategy. + :paramtype polling: bool or ~azure.core.polling.AsyncPollingMethod + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of AsyncLROPoller that returns either GenericResource or the result of + cls(response) + :rtype: + ~azure.core.polling.AsyncLROPoller[~azure.mgmt.resource.resources.v2016_02_01.models.GenericResource] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + async def begin_update( + self, + resource_group_name: str, + resource_provider_namespace: str, + parent_resource_path: str, + resource_type: str, + resource_name: str, + api_version: str, + parameters: IO, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> AsyncLROPoller[_models.GenericResource]: + """Updates a resource. + + :param resource_group_name: The name of the resource group for the resource. The name is case + insensitive. Required. + :type resource_group_name: str + :param resource_provider_namespace: The namespace of the resource provider. Required. + :type resource_provider_namespace: str + :param parent_resource_path: The parent resource identity. Required. + :type parent_resource_path: str + :param resource_type: The resource type of the resource to update. Required. + :type resource_type: str + :param resource_name: The name of the resource to update. Required. + :type resource_name: str + :param api_version: The API version to use for the operation. Required. + :type api_version: str + :param parameters: Parameters for updating the resource. Required. + :type parameters: IO + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be AsyncARMPolling. Pass in False for + this operation to not poll, or pass in your own initialized polling object for a personal + polling strategy. + :paramtype polling: bool or ~azure.core.polling.AsyncPollingMethod + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of AsyncLROPoller that returns either GenericResource or the result of + cls(response) + :rtype: + ~azure.core.polling.AsyncLROPoller[~azure.mgmt.resource.resources.v2016_02_01.models.GenericResource] + :raises ~azure.core.exceptions.HttpResponseError: + """ @distributed_trace_async async def begin_update( @@ -2078,26 +2788,30 @@ async def begin_update( resource_type: str, resource_name: str, api_version: str, - parameters: "_models.GenericResource", + parameters: Union[_models.GenericResource, IO], **kwargs: Any - ) -> AsyncLROPoller["_models.GenericResource"]: + ) -> AsyncLROPoller[_models.GenericResource]: """Updates a resource. :param resource_group_name: The name of the resource group for the resource. The name is case - insensitive. + insensitive. Required. :type resource_group_name: str - :param resource_provider_namespace: The namespace of the resource provider. + :param resource_provider_namespace: The namespace of the resource provider. Required. :type resource_provider_namespace: str - :param parent_resource_path: The parent resource identity. + :param parent_resource_path: The parent resource identity. Required. :type parent_resource_path: str - :param resource_type: The resource type of the resource to update. + :param resource_type: The resource type of the resource to update. Required. :type resource_type: str - :param resource_name: The name of the resource to update. + :param resource_name: The name of the resource to update. Required. :type resource_name: str - :param api_version: The API version to use for the operation. + :param api_version: The API version to use for the operation. Required. :type api_version: str - :param parameters: Parameters for updating the resource. - :type parameters: ~azure.mgmt.resource.resources.v2016_02_01.models.GenericResource + :param parameters: Parameters for updating the resource. Is either a model type or a IO type. + Required. + :type parameters: ~azure.mgmt.resource.resources.v2016_02_01.models.GenericResource or IO + :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. + Default value is None. + :paramtype content_type: str :keyword callable cls: A custom type or function that will be passed the direct response :keyword str continuation_token: A continuation token to restart a poller from a saved state. :keyword polling: By default, your polling method will be AsyncARMPolling. Pass in False for @@ -2110,18 +2824,18 @@ async def begin_update( cls(response) :rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.resource.resources.v2016_02_01.models.GenericResource] - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] - polling = kwargs.pop('polling', True) # type: Union[bool, AsyncPollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType["_models.GenericResource"] - lro_delay = kwargs.pop( - 'polling_interval', - self._config.polling_interval - ) - cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = kwargs.pop("params", {}) or {} + + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.GenericResource] + polling = kwargs.pop("polling", True) # type: Union[bool, AsyncPollingMethod] + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token = kwargs.pop("continuation_token", None) # type: Optional[str] if cont_token is None: - raw_result = await self._update_initial( + raw_result = await self._update_initial( # type: ignore resource_group_name=resource_group_name, resource_provider_namespace=resource_provider_namespace, parent_resource_path=parent_resource_path, @@ -2130,32 +2844,35 @@ async def begin_update( api_version=api_version, parameters=parameters, content_type=content_type, - cls=lambda x,y,z: x, + cls=lambda x, y, z: x, + headers=_headers, + params=_params, **kwargs ) - kwargs.pop('error_map', None) + kwargs.pop("error_map", None) def get_long_running_output(pipeline_response): - response = pipeline_response.http_response - deserialized = self._deserialize('GenericResource', pipeline_response) + deserialized = self._deserialize("GenericResource", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - - if polling is True: polling_method = AsyncARMPolling(lro_delay, **kwargs) - elif polling is False: polling_method = AsyncNoPolling() - else: polling_method = polling + if polling is True: + polling_method = cast(AsyncPollingMethod, AsyncARMPolling(lro_delay, **kwargs)) # type: AsyncPollingMethod + elif polling is False: + polling_method = cast(AsyncPollingMethod, AsyncNoPolling()) + else: + polling_method = polling if cont_token: return AsyncLROPoller.from_continuation_token( polling_method=polling_method, continuation_token=cont_token, client=self._client, - deserialization_callback=get_long_running_output + deserialization_callback=get_long_running_output, ) return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) - begin_update.metadata = {'url': "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{parentResourcePath}/{resourceType}/{resourceName}"} # type: ignore + begin_update.metadata = {"url": "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{parentResourcePath}/{resourceType}/{resourceName}"} # type: ignore @distributed_trace_async async def get( @@ -2167,33 +2884,40 @@ async def get( resource_name: str, api_version: str, **kwargs: Any - ) -> "_models.GenericResource": + ) -> _models.GenericResource: """Returns a resource belonging to a resource group. :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. :type resource_group_name: str - :param resource_provider_namespace: Resource identity. + :param resource_provider_namespace: Resource identity. Required. :type resource_provider_namespace: str - :param parent_resource_path: Resource identity. + :param parent_resource_path: Resource identity. Required. :type parent_resource_path: str - :param resource_type: Resource identity. + :param resource_type: Resource identity. Required. :type resource_type: str - :param resource_name: Resource identity. + :param resource_name: Resource identity. Required. :type resource_name: str - :param api_version: + :param api_version: Required. :type api_version: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: GenericResource, or the result of cls(response) + :return: GenericResource or the result of cls(response) :rtype: ~azure.mgmt.resource.resources.v2016_02_01.models.GenericResource - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.GenericResource"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = kwargs.pop("params", {}) or {} + + cls = kwargs.pop("cls", None) # type: ClsType[_models.GenericResource] - request = build_resources_get_request( resource_group_name=resource_group_name, resource_provider_namespace=resource_provider_namespace, @@ -2202,95 +2926,97 @@ async def get( resource_name=resource_name, subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.get.metadata['url'], + template_url=self.get.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) - deserialized = self._deserialize('GenericResource', pipeline_response) + deserialized = self._deserialize("GenericResource", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - get.metadata = {'url': "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{parentResourcePath}/{resourceType}/{resourceName}"} # type: ignore + get.metadata = {"url": "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{parentResourcePath}/{resourceType}/{resourceName}"} # type: ignore -class TagsOperations: - """TagsOperations async operations. - You should not instantiate this class directly. Instead, you should create a Client instance that - instantiates it for you and attaches it as an attribute. +class TagsOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. - :ivar models: Alias to model classes used in this operation group. - :type models: ~azure.mgmt.resource.resources.v2016_02_01.models - :param client: Client for service requests. - :param config: Configuration of service client. - :param serializer: An object model serializer. - :param deserializer: An object model deserializer. + Instead, you should access the following operations through + :class:`~azure.mgmt.resource.resources.v2016_02_01.aio.ResourceManagementClient`'s + :attr:`tags` attribute. """ models = _models - def __init__(self, client, config, serializer, deserializer) -> None: - self._client = client - self._serialize = serializer - self._deserialize = deserializer - self._config = config + def __init__(self, *args, **kwargs) -> None: + input_args = list(args) + self._client = input_args.pop(0) if input_args else kwargs.pop("client") + self._config = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") @distributed_trace_async async def delete_value( # pylint: disable=inconsistent-return-statements - self, - tag_name: str, - tag_value: str, - **kwargs: Any + self, tag_name: str, tag_value: str, **kwargs: Any ) -> None: """Delete a subscription resource tag value. - :param tag_name: The name of the tag. + :param tag_name: The name of the tag. Required. :type tag_name: str - :param tag_value: The value of the tag. + :param tag_value: The value of the tag. Required. :type tag_value: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: None, or the result of cls(response) + :return: None or the result of cls(response) :rtype: None - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType[None] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) - api_version = kwargs.pop('api_version', "2016-02-01") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2016-02-01")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[None] - request = build_tags_delete_value_request( tag_name=tag_name, tag_value=tag_value, subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.delete_value.metadata['url'], + template_url=self.delete_value.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200, 204]: @@ -2300,51 +3026,51 @@ async def delete_value( # pylint: disable=inconsistent-return-statements if cls: return cls(pipeline_response, None, {}) - delete_value.metadata = {'url': "/subscriptions/{subscriptionId}/tagNames/{tagName}/tagValues/{tagValue}"} # type: ignore - + delete_value.metadata = {"url": "/subscriptions/{subscriptionId}/tagNames/{tagName}/tagValues/{tagValue}"} # type: ignore @distributed_trace_async - async def create_or_update_value( - self, - tag_name: str, - tag_value: str, - **kwargs: Any - ) -> "_models.TagValue": + async def create_or_update_value(self, tag_name: str, tag_value: str, **kwargs: Any) -> _models.TagValue: """Create a subscription resource tag value. - :param tag_name: The name of the tag. + :param tag_name: The name of the tag. Required. :type tag_name: str - :param tag_value: The value of the tag. + :param tag_value: The value of the tag. Required. :type tag_value: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: TagValue, or the result of cls(response) + :return: TagValue or the result of cls(response) :rtype: ~azure.mgmt.resource.resources.v2016_02_01.models.TagValue - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.TagValue"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) - api_version = kwargs.pop('api_version', "2016-02-01") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2016-02-01")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[_models.TagValue] - request = build_tags_create_or_update_value_request( tag_name=tag_name, tag_value=tag_value, subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.create_or_update_value.metadata['url'], + template_url=self.create_or_update_value.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200, 201]: @@ -2352,57 +3078,58 @@ async def create_or_update_value( raise HttpResponseError(response=response, error_format=ARMErrorFormat) if response.status_code == 200: - deserialized = self._deserialize('TagValue', pipeline_response) + deserialized = self._deserialize("TagValue", pipeline_response) if response.status_code == 201: - deserialized = self._deserialize('TagValue', pipeline_response) + deserialized = self._deserialize("TagValue", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - create_or_update_value.metadata = {'url': "/subscriptions/{subscriptionId}/tagNames/{tagName}/tagValues/{tagValue}"} # type: ignore - + create_or_update_value.metadata = {"url": "/subscriptions/{subscriptionId}/tagNames/{tagName}/tagValues/{tagValue}"} # type: ignore @distributed_trace_async - async def create_or_update( - self, - tag_name: str, - **kwargs: Any - ) -> "_models.TagDetails": + async def create_or_update(self, tag_name: str, **kwargs: Any) -> _models.TagDetails: """Create a subscription resource tag. - :param tag_name: The name of the tag. + :param tag_name: The name of the tag. Required. :type tag_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: TagDetails, or the result of cls(response) + :return: TagDetails or the result of cls(response) :rtype: ~azure.mgmt.resource.resources.v2016_02_01.models.TagDetails - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.TagDetails"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + 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', "2016-02-01") # type: str + api_version = kwargs.pop("api_version", _params.pop("api-version", "2016-02-01")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[_models.TagDetails] - request = build_tags_create_or_update_request( tag_name=tag_name, subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.create_or_update.metadata['url'], + template_url=self.create_or_update.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200, 201]: @@ -2410,57 +3137,58 @@ async def create_or_update( raise HttpResponseError(response=response, error_format=ARMErrorFormat) if response.status_code == 200: - deserialized = self._deserialize('TagDetails', pipeline_response) + deserialized = self._deserialize("TagDetails", pipeline_response) if response.status_code == 201: - deserialized = self._deserialize('TagDetails', pipeline_response) + deserialized = self._deserialize("TagDetails", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - create_or_update.metadata = {'url': "/subscriptions/{subscriptionId}/tagNames/{tagName}"} # type: ignore - + create_or_update.metadata = {"url": "/subscriptions/{subscriptionId}/tagNames/{tagName}"} # type: ignore @distributed_trace_async - async def delete( # pylint: disable=inconsistent-return-statements - self, - tag_name: str, - **kwargs: Any - ) -> None: + async def delete(self, tag_name: str, **kwargs: Any) -> None: # pylint: disable=inconsistent-return-statements """Delete a subscription resource tag. - :param tag_name: The name of the tag. + :param tag_name: The name of the tag. Required. :type tag_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: None, or the result of cls(response) + :return: None or the result of cls(response) :rtype: None - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType[None] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) - api_version = kwargs.pop('api_version', "2016-02-01") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2016-02-01")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[None] - request = build_tags_delete_request( tag_name=tag_name, subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.delete.metadata['url'], + template_url=self.delete.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200, 204]: @@ -2470,48 +3198,53 @@ async def delete( # pylint: disable=inconsistent-return-statements if cls: return cls(pipeline_response, None, {}) - delete.metadata = {'url': "/subscriptions/{subscriptionId}/tagNames/{tagName}"} # type: ignore - + delete.metadata = {"url": "/subscriptions/{subscriptionId}/tagNames/{tagName}"} # type: ignore @distributed_trace - def list( - self, - **kwargs: Any - ) -> AsyncIterable["_models.TagsListResult"]: + def list(self, **kwargs: Any) -> AsyncIterable["_models.TagDetails"]: """Get a list of subscription resource tags. :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either TagsListResult or the result of cls(response) + :return: An iterator like instance of either TagDetails or the result of cls(response) :rtype: - ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.resource.resources.v2016_02_01.models.TagsListResult] - :raises: ~azure.core.exceptions.HttpResponseError + ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.resource.resources.v2016_02_01.models.TagDetails] + :raises ~azure.core.exceptions.HttpResponseError: """ - api_version = kwargs.pop('api_version', "2016-02-01") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2016-02-01")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[_models.TagsListResult] - cls = kwargs.pop('cls', None) # type: ClsType["_models.TagsListResult"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) + def prepare_request(next_link=None): if not next_link: - + request = build_tags_list_request( subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.list.metadata['url'], + template_url=self.list.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore else: - - request = build_tags_list_request( - subscription_id=self._config.subscription_id, - template_url=next_link, - ) + # make call to next link with the client's api-version + _parsed_next_link = urlparse(next_link) + _next_request_params = case_insensitive_dict(parse_qs(_parsed_next_link.query)) + _next_request_params["api-version"] = self._config.api_version + request = HttpRequest("GET", urljoin(next_link, _parsed_next_link.path), params=_next_request_params) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore request.method = "GET" return request @@ -2525,10 +3258,8 @@ async def extract_data(pipeline_response): async def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) response = pipeline_response.http_response @@ -2538,149 +3269,151 @@ async def get_next(next_link=None): return pipeline_response + return AsyncItemPaged(get_next, extract_data) + + list.metadata = {"url": "/subscriptions/{subscriptionId}/tagNames"} # type: ignore - return AsyncItemPaged( - get_next, extract_data - ) - list.metadata = {'url': "/subscriptions/{subscriptionId}/tagNames"} # type: ignore -class DeploymentOperationsOperations: - """DeploymentOperationsOperations async operations. - You should not instantiate this class directly. Instead, you should create a Client instance that - instantiates it for you and attaches it as an attribute. +class DeploymentOperationsOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. - :ivar models: Alias to model classes used in this operation group. - :type models: ~azure.mgmt.resource.resources.v2016_02_01.models - :param client: Client for service requests. - :param config: Configuration of service client. - :param serializer: An object model serializer. - :param deserializer: An object model deserializer. + Instead, you should access the following operations through + :class:`~azure.mgmt.resource.resources.v2016_02_01.aio.ResourceManagementClient`'s + :attr:`deployment_operations` attribute. """ models = _models - def __init__(self, client, config, serializer, deserializer) -> None: - self._client = client - self._serialize = serializer - self._deserialize = deserializer - self._config = config + def __init__(self, *args, **kwargs) -> None: + input_args = list(args) + self._client = input_args.pop(0) if input_args else kwargs.pop("client") + self._config = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") @distributed_trace_async async def get( - self, - resource_group_name: str, - deployment_name: str, - operation_id: str, - **kwargs: Any - ) -> "_models.DeploymentOperation": + self, resource_group_name: str, deployment_name: str, operation_id: str, **kwargs: Any + ) -> _models.DeploymentOperation: """Get a list of deployments operations. :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. :type resource_group_name: str - :param deployment_name: The name of the deployment. + :param deployment_name: The name of the deployment. Required. :type deployment_name: str - :param operation_id: Operation Id. + :param operation_id: Operation Id. Required. :type operation_id: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: DeploymentOperation, or the result of cls(response) + :return: DeploymentOperation or the result of cls(response) :rtype: ~azure.mgmt.resource.resources.v2016_02_01.models.DeploymentOperation - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.DeploymentOperation"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + 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', "2016-02-01") # type: str + api_version = kwargs.pop("api_version", _params.pop("api-version", "2016-02-01")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[_models.DeploymentOperation] - request = build_deployment_operations_get_request( resource_group_name=resource_group_name, deployment_name=deployment_name, operation_id=operation_id, subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.get.metadata['url'], + template_url=self.get.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) - deserialized = self._deserialize('DeploymentOperation', pipeline_response) + deserialized = self._deserialize("DeploymentOperation", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - get.metadata = {'url': "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/deployments/{deploymentName}/operations/{operationId}"} # type: ignore - + get.metadata = {"url": "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/deployments/{deploymentName}/operations/{operationId}"} # type: ignore @distributed_trace def list( - self, - resource_group_name: str, - deployment_name: str, - top: Optional[int] = None, - **kwargs: Any - ) -> AsyncIterable["_models.DeploymentOperationsListResult"]: + self, resource_group_name: str, deployment_name: str, top: Optional[int] = None, **kwargs: Any + ) -> AsyncIterable["_models.DeploymentOperation"]: """Gets a list of deployments operations. :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. :type resource_group_name: str - :param deployment_name: The name of the deployment. + :param deployment_name: The name of the deployment. Required. :type deployment_name: str :param top: Query parameters. Default value is None. :type top: int :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either DeploymentOperationsListResult or the result of - cls(response) + :return: An iterator like instance of either DeploymentOperation or the result of cls(response) :rtype: - ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.resource.resources.v2016_02_01.models.DeploymentOperationsListResult] - :raises: ~azure.core.exceptions.HttpResponseError + ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.resource.resources.v2016_02_01.models.DeploymentOperation] + :raises ~azure.core.exceptions.HttpResponseError: """ - api_version = kwargs.pop('api_version', "2016-02-01") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2016-02-01")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[_models.DeploymentOperationsListResult] - cls = kwargs.pop('cls', None) # type: ClsType["_models.DeploymentOperationsListResult"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) + def prepare_request(next_link=None): if not next_link: - + request = build_deployment_operations_list_request( resource_group_name=resource_group_name, deployment_name=deployment_name, subscription_id=self._config.subscription_id, - api_version=api_version, top=top, - template_url=self.list.metadata['url'], + 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.url = self._client.format_url(request.url) # type: ignore else: - - request = build_deployment_operations_list_request( - resource_group_name=resource_group_name, - deployment_name=deployment_name, - subscription_id=self._config.subscription_id, - template_url=next_link, - ) + # make call to next link with the client's api-version + _parsed_next_link = urlparse(next_link) + _next_request_params = case_insensitive_dict(parse_qs(_parsed_next_link.query)) + _next_request_params["api-version"] = self._config.api_version + request = HttpRequest("GET", urljoin(next_link, _parsed_next_link.path), params=_next_request_params) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore request.method = "GET" return request @@ -2694,10 +3427,8 @@ async def extract_data(pipeline_response): async def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) response = pipeline_response.http_response @@ -2707,8 +3438,6 @@ async def get_next(next_link=None): return pipeline_response + return AsyncItemPaged(get_next, extract_data) - return AsyncItemPaged( - get_next, extract_data - ) - list.metadata = {'url': "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/deployments/{deploymentName}/operations"} # type: ignore + list.metadata = {"url": "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/deployments/{deploymentName}/operations"} # type: ignore diff --git a/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/resources/v2016_02_01/aio/operations/_patch.py b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/resources/v2016_02_01/aio/operations/_patch.py new file mode 100644 index 0000000000000..f7dd32510333d --- /dev/null +++ b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/resources/v2016_02_01/aio/operations/_patch.py @@ -0,0 +1,20 @@ +# ------------------------------------ +# Copyright (c) Microsoft Corporation. +# Licensed under the MIT License. +# ------------------------------------ +"""Customize generated code here. + +Follow our quickstart for examples: https://aka.ms/azsdk/python/dpcodegen/python/customize +""" +from typing import List + +__all__: List[str] = [] # Add all objects you want publicly available to users at this package level + + +def patch_sdk(): + """Do not remove from this file. + + `patch_sdk` is a last resort escape hatch that allows you to do customizations + you can't accomplish using the techniques described in + https://aka.ms/azsdk/python/dpcodegen/python/customize + """ diff --git a/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/resources/v2016_02_01/models/__init__.py b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/resources/v2016_02_01/models/__init__.py index f63132cf9be03..eaa324864a38e 100644 --- a/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/resources/v2016_02_01/models/__init__.py +++ b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/resources/v2016_02_01/models/__init__.py @@ -55,59 +55,61 @@ from ._models_py3 import TemplateHashResult from ._models_py3 import TemplateLink - -from ._resource_management_client_enums import ( - DeploymentMode, -) +from ._resource_management_client_enums import DeploymentMode +from ._patch import __all__ as _patch_all +from ._patch import * # type: ignore # pylint: disable=unused-wildcard-import +from ._patch import patch_sdk as _patch_sdk __all__ = [ - 'AliasPathType', - 'AliasType', - 'BasicDependency', - 'DebugSetting', - 'Dependency', - 'Deployment', - 'DeploymentExportResult', - 'DeploymentExtended', - 'DeploymentExtendedFilter', - 'DeploymentListResult', - 'DeploymentOperation', - 'DeploymentOperationProperties', - 'DeploymentOperationsListResult', - 'DeploymentProperties', - 'DeploymentPropertiesExtended', - 'DeploymentValidateResult', - 'ErrorAdditionalInfo', - 'ErrorResponse', - 'ExportTemplateRequest', - 'GenericResource', - 'GenericResourceExpanded', - 'GenericResourceFilter', - 'HttpMessage', - 'Identity', - 'ParametersLink', - 'Plan', - 'Provider', - 'ProviderListResult', - 'ProviderResourceType', - 'Resource', - 'ResourceGroup', - 'ResourceGroupExportResult', - 'ResourceGroupFilter', - 'ResourceGroupListResult', - 'ResourceGroupProperties', - 'ResourceListResult', - 'ResourceManagementErrorWithDetails', - 'ResourceProviderOperationDisplayProperties', - 'ResourcesMoveInfo', - 'Sku', - 'SubResource', - 'TagCount', - 'TagDetails', - 'TagValue', - 'TagsListResult', - 'TargetResource', - 'TemplateHashResult', - 'TemplateLink', - 'DeploymentMode', + "AliasPathType", + "AliasType", + "BasicDependency", + "DebugSetting", + "Dependency", + "Deployment", + "DeploymentExportResult", + "DeploymentExtended", + "DeploymentExtendedFilter", + "DeploymentListResult", + "DeploymentOperation", + "DeploymentOperationProperties", + "DeploymentOperationsListResult", + "DeploymentProperties", + "DeploymentPropertiesExtended", + "DeploymentValidateResult", + "ErrorAdditionalInfo", + "ErrorResponse", + "ExportTemplateRequest", + "GenericResource", + "GenericResourceExpanded", + "GenericResourceFilter", + "HttpMessage", + "Identity", + "ParametersLink", + "Plan", + "Provider", + "ProviderListResult", + "ProviderResourceType", + "Resource", + "ResourceGroup", + "ResourceGroupExportResult", + "ResourceGroupFilter", + "ResourceGroupListResult", + "ResourceGroupProperties", + "ResourceListResult", + "ResourceManagementErrorWithDetails", + "ResourceProviderOperationDisplayProperties", + "ResourcesMoveInfo", + "Sku", + "SubResource", + "TagCount", + "TagDetails", + "TagValue", + "TagsListResult", + "TargetResource", + "TemplateHashResult", + "TemplateLink", + "DeploymentMode", ] +__all__.extend([p for p in _patch_all if p not in __all__]) +_patch_sdk() diff --git a/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/resources/v2016_02_01/models/_models_py3.py b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/resources/v2016_02_01/models/_models_py3.py index 81da3138d9a12..8f685d1105177 100644 --- a/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/resources/v2016_02_01/models/_models_py3.py +++ b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/resources/v2016_02_01/models/_models_py3.py @@ -1,4 +1,5 @@ # coding=utf-8 +# pylint: disable=too-many-lines # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. # Licensed under the MIT License. See License.txt in the project root for license information. @@ -7,14 +8,22 @@ # -------------------------------------------------------------------------- import datetime -from typing import Any, Dict, List, Optional, Union +import sys +from typing import Any, Dict, List, Optional, TYPE_CHECKING, Union -import msrest.serialization +from ... import _serialization -from ._resource_management_client_enums import * +if TYPE_CHECKING: + # pylint: disable=unused-import,ungrouped-imports + from .. import models as _models +if sys.version_info >= (3, 9): + from collections.abc import MutableMapping +else: + from typing import MutableMapping # type: ignore # pylint: disable=ungrouped-imports +JSON = MutableMapping[str, Any] # pylint: disable=unsubscriptable-object -class AliasPathType(msrest.serialization.Model): +class AliasPathType(_serialization.Model): """AliasPathType. :ivar path: The path of an alias. @@ -24,29 +33,23 @@ class AliasPathType(msrest.serialization.Model): """ _attribute_map = { - 'path': {'key': 'path', 'type': 'str'}, - 'api_versions': {'key': 'apiVersions', 'type': '[str]'}, + "path": {"key": "path", "type": "str"}, + "api_versions": {"key": "apiVersions", "type": "[str]"}, } - def __init__( - self, - *, - path: Optional[str] = None, - api_versions: Optional[List[str]] = None, - **kwargs - ): + def __init__(self, *, path: Optional[str] = None, api_versions: Optional[List[str]] = None, **kwargs): """ :keyword path: The path of an alias. :paramtype path: str :keyword api_versions: The api versions. :paramtype api_versions: list[str] """ - super(AliasPathType, self).__init__(**kwargs) + super().__init__(**kwargs) self.path = path self.api_versions = api_versions -class AliasType(msrest.serialization.Model): +class AliasType(_serialization.Model): """AliasType. :ivar name: The alias name. @@ -56,29 +59,23 @@ class AliasType(msrest.serialization.Model): """ _attribute_map = { - 'name': {'key': 'name', 'type': 'str'}, - 'paths': {'key': 'paths', 'type': '[AliasPathType]'}, + "name": {"key": "name", "type": "str"}, + "paths": {"key": "paths", "type": "[AliasPathType]"}, } - def __init__( - self, - *, - name: Optional[str] = None, - paths: Optional[List["AliasPathType"]] = None, - **kwargs - ): + def __init__(self, *, name: Optional[str] = None, paths: Optional[List["_models.AliasPathType"]] = None, **kwargs): """ :keyword name: The alias name. :paramtype name: str :keyword paths: The paths for an alias. :paramtype paths: list[~azure.mgmt.resource.resources.v2016_02_01.models.AliasPathType] """ - super(AliasType, self).__init__(**kwargs) + super().__init__(**kwargs) self.name = name self.paths = paths -class BasicDependency(msrest.serialization.Model): +class BasicDependency(_serialization.Model): """Deployment dependency information. :ivar id: The ID of the dependency. @@ -90,15 +87,15 @@ class BasicDependency(msrest.serialization.Model): """ _attribute_map = { - 'id': {'key': 'id', 'type': 'str'}, - 'resource_type': {'key': 'resourceType', 'type': 'str'}, - 'resource_name': {'key': 'resourceName', 'type': 'str'}, + "id": {"key": "id", "type": "str"}, + "resource_type": {"key": "resourceType", "type": "str"}, + "resource_name": {"key": "resourceName", "type": "str"}, } def __init__( self, *, - id: Optional[str] = None, + id: Optional[str] = None, # pylint: disable=redefined-builtin resource_type: Optional[str] = None, resource_name: Optional[str] = None, **kwargs @@ -111,13 +108,13 @@ def __init__( :keyword resource_name: The dependency resource name. :paramtype resource_name: str """ - super(BasicDependency, self).__init__(**kwargs) + super().__init__(**kwargs) self.id = id self.resource_type = resource_type self.resource_name = resource_name -class DebugSetting(msrest.serialization.Model): +class DebugSetting(_serialization.Model): """DebugSetting. :ivar detail_level: The debug detail level. @@ -125,24 +122,19 @@ class DebugSetting(msrest.serialization.Model): """ _attribute_map = { - 'detail_level': {'key': 'detailLevel', 'type': 'str'}, + "detail_level": {"key": "detailLevel", "type": "str"}, } - def __init__( - self, - *, - detail_level: Optional[str] = None, - **kwargs - ): + def __init__(self, *, detail_level: Optional[str] = None, **kwargs): """ :keyword detail_level: The debug detail level. :paramtype detail_level: str """ - super(DebugSetting, self).__init__(**kwargs) + super().__init__(**kwargs) self.detail_level = detail_level -class Dependency(msrest.serialization.Model): +class Dependency(_serialization.Model): """Deployment dependency information. :ivar depends_on: The list of dependencies. @@ -156,17 +148,17 @@ class Dependency(msrest.serialization.Model): """ _attribute_map = { - 'depends_on': {'key': 'dependsOn', 'type': '[BasicDependency]'}, - 'id': {'key': 'id', 'type': 'str'}, - 'resource_type': {'key': 'resourceType', 'type': 'str'}, - 'resource_name': {'key': 'resourceName', 'type': 'str'}, + "depends_on": {"key": "dependsOn", "type": "[BasicDependency]"}, + "id": {"key": "id", "type": "str"}, + "resource_type": {"key": "resourceType", "type": "str"}, + "resource_name": {"key": "resourceName", "type": "str"}, } def __init__( self, *, - depends_on: Optional[List["BasicDependency"]] = None, - id: Optional[str] = None, + depends_on: Optional[List["_models.BasicDependency"]] = None, + id: Optional[str] = None, # pylint: disable=redefined-builtin resource_type: Optional[str] = None, resource_name: Optional[str] = None, **kwargs @@ -181,14 +173,14 @@ def __init__( :keyword resource_name: The dependency resource name. :paramtype resource_name: str """ - super(Dependency, self).__init__(**kwargs) + super().__init__(**kwargs) self.depends_on = depends_on self.id = id self.resource_type = resource_type self.resource_name = resource_name -class Deployment(msrest.serialization.Model): +class Deployment(_serialization.Model): """Deployment operation parameters. :ivar properties: The deployment properties. @@ -196,49 +188,39 @@ class Deployment(msrest.serialization.Model): """ _attribute_map = { - 'properties': {'key': 'properties', 'type': 'DeploymentProperties'}, + "properties": {"key": "properties", "type": "DeploymentProperties"}, } - def __init__( - self, - *, - properties: Optional["DeploymentProperties"] = None, - **kwargs - ): + def __init__(self, *, properties: Optional["_models.DeploymentProperties"] = None, **kwargs): """ :keyword properties: The deployment properties. :paramtype properties: ~azure.mgmt.resource.resources.v2016_02_01.models.DeploymentProperties """ - super(Deployment, self).__init__(**kwargs) + super().__init__(**kwargs) self.properties = properties -class DeploymentExportResult(msrest.serialization.Model): +class DeploymentExportResult(_serialization.Model): """DeploymentExportResult. :ivar template: The template content. - :vartype template: any + :vartype template: JSON """ _attribute_map = { - 'template': {'key': 'template', 'type': 'object'}, + "template": {"key": "template", "type": "object"}, } - def __init__( - self, - *, - template: Optional[Any] = None, - **kwargs - ): + def __init__(self, *, template: Optional[JSON] = None, **kwargs): """ :keyword template: The template content. - :paramtype template: any + :paramtype template: JSON """ - super(DeploymentExportResult, self).__init__(**kwargs) + super().__init__(**kwargs) self.template = template -class DeploymentExtended(msrest.serialization.Model): +class DeploymentExtended(_serialization.Model): """Deployment information. Variables are only populated by the server, and will be ignored when sending a request. @@ -247,7 +229,7 @@ class DeploymentExtended(msrest.serialization.Model): :ivar id: The ID of the deployment. :vartype id: str - :ivar name: Required. The name of the deployment. + :ivar name: The name of the deployment. Required. :vartype name: str :ivar properties: Deployment properties. :vartype properties: @@ -255,37 +237,31 @@ class DeploymentExtended(msrest.serialization.Model): """ _validation = { - 'id': {'readonly': True}, - 'name': {'required': True}, + "id": {"readonly": True}, + "name": {"required": True}, } _attribute_map = { - 'id': {'key': 'id', 'type': 'str'}, - 'name': {'key': 'name', 'type': 'str'}, - 'properties': {'key': 'properties', 'type': 'DeploymentPropertiesExtended'}, + "id": {"key": "id", "type": "str"}, + "name": {"key": "name", "type": "str"}, + "properties": {"key": "properties", "type": "DeploymentPropertiesExtended"}, } - def __init__( - self, - *, - name: str, - properties: Optional["DeploymentPropertiesExtended"] = None, - **kwargs - ): + def __init__(self, *, name: str, properties: Optional["_models.DeploymentPropertiesExtended"] = None, **kwargs): """ - :keyword name: Required. The name of the deployment. + :keyword name: The name of the deployment. Required. :paramtype name: str :keyword properties: Deployment properties. :paramtype properties: ~azure.mgmt.resource.resources.v2016_02_01.models.DeploymentPropertiesExtended """ - super(DeploymentExtended, self).__init__(**kwargs) + super().__init__(**kwargs) self.id = None self.name = name self.properties = properties -class DeploymentExtendedFilter(msrest.serialization.Model): +class DeploymentExtendedFilter(_serialization.Model): """Deployment filter. :ivar provisioning_state: The provisioning state. @@ -293,24 +269,19 @@ class DeploymentExtendedFilter(msrest.serialization.Model): """ _attribute_map = { - 'provisioning_state': {'key': 'provisioningState', 'type': 'str'}, + "provisioning_state": {"key": "provisioningState", "type": "str"}, } - def __init__( - self, - *, - provisioning_state: Optional[str] = None, - **kwargs - ): + def __init__(self, *, provisioning_state: Optional[str] = None, **kwargs): """ :keyword provisioning_state: The provisioning state. :paramtype provisioning_state: str """ - super(DeploymentExtendedFilter, self).__init__(**kwargs) + super().__init__(**kwargs) self.provisioning_state = provisioning_state -class DeploymentListResult(msrest.serialization.Model): +class DeploymentListResult(_serialization.Model): """List of deployments. :ivar value: The list of deployments. @@ -320,16 +291,12 @@ class DeploymentListResult(msrest.serialization.Model): """ _attribute_map = { - 'value': {'key': 'value', 'type': '[DeploymentExtended]'}, - 'next_link': {'key': 'nextLink', 'type': 'str'}, + "value": {"key": "value", "type": "[DeploymentExtended]"}, + "next_link": {"key": "nextLink", "type": "str"}, } def __init__( - self, - *, - value: Optional[List["DeploymentExtended"]] = None, - next_link: Optional[str] = None, - **kwargs + self, *, value: Optional[List["_models.DeploymentExtended"]] = None, next_link: Optional[str] = None, **kwargs ): """ :keyword value: The list of deployments. @@ -337,12 +304,12 @@ def __init__( :keyword next_link: The URL to get the next set of results. :paramtype next_link: str """ - super(DeploymentListResult, self).__init__(**kwargs) + super().__init__(**kwargs) self.value = value self.next_link = next_link -class DeploymentOperation(msrest.serialization.Model): +class DeploymentOperation(_serialization.Model): """Deployment operation information. :ivar id: Full deployment operation id. @@ -355,17 +322,17 @@ class DeploymentOperation(msrest.serialization.Model): """ _attribute_map = { - 'id': {'key': 'id', 'type': 'str'}, - 'operation_id': {'key': 'operationId', 'type': 'str'}, - 'properties': {'key': 'properties', 'type': 'DeploymentOperationProperties'}, + "id": {"key": "id", "type": "str"}, + "operation_id": {"key": "operationId", "type": "str"}, + "properties": {"key": "properties", "type": "DeploymentOperationProperties"}, } def __init__( self, *, - id: Optional[str] = None, + id: Optional[str] = None, # pylint: disable=redefined-builtin operation_id: Optional[str] = None, - properties: Optional["DeploymentOperationProperties"] = None, + properties: Optional["_models.DeploymentOperationProperties"] = None, **kwargs ): """ @@ -377,13 +344,13 @@ def __init__( :paramtype properties: ~azure.mgmt.resource.resources.v2016_02_01.models.DeploymentOperationProperties """ - super(DeploymentOperation, self).__init__(**kwargs) + super().__init__(**kwargs) self.id = id self.operation_id = operation_id self.properties = properties -class DeploymentOperationProperties(msrest.serialization.Model): +class DeploymentOperationProperties(_serialization.Model): """Deployment operation properties. :ivar provisioning_state: The state of the provisioning. @@ -405,14 +372,14 @@ class DeploymentOperationProperties(msrest.serialization.Model): """ _attribute_map = { - 'provisioning_state': {'key': 'provisioningState', 'type': 'str'}, - 'timestamp': {'key': 'timestamp', 'type': 'iso-8601'}, - 'service_request_id': {'key': 'serviceRequestId', 'type': 'str'}, - 'status_code': {'key': 'statusCode', 'type': 'str'}, - 'status_message': {'key': 'statusMessage', 'type': 'object'}, - 'target_resource': {'key': 'targetResource', 'type': 'TargetResource'}, - 'request': {'key': 'request', 'type': 'HttpMessage'}, - 'response': {'key': 'response', 'type': 'HttpMessage'}, + "provisioning_state": {"key": "provisioningState", "type": "str"}, + "timestamp": {"key": "timestamp", "type": "iso-8601"}, + "service_request_id": {"key": "serviceRequestId", "type": "str"}, + "status_code": {"key": "statusCode", "type": "str"}, + "status_message": {"key": "statusMessage", "type": "object"}, + "target_resource": {"key": "targetResource", "type": "TargetResource"}, + "request": {"key": "request", "type": "HttpMessage"}, + "response": {"key": "response", "type": "HttpMessage"}, } def __init__( @@ -423,9 +390,9 @@ def __init__( service_request_id: Optional[str] = None, status_code: Optional[str] = None, status_message: Optional[Any] = None, - target_resource: Optional["TargetResource"] = None, - request: Optional["HttpMessage"] = None, - response: Optional["HttpMessage"] = None, + target_resource: Optional["_models.TargetResource"] = None, + request: Optional["_models.HttpMessage"] = None, + response: Optional["_models.HttpMessage"] = None, **kwargs ): """ @@ -446,7 +413,7 @@ def __init__( :keyword response: The HTTP response message. :paramtype response: ~azure.mgmt.resource.resources.v2016_02_01.models.HttpMessage """ - super(DeploymentOperationProperties, self).__init__(**kwargs) + super().__init__(**kwargs) self.provisioning_state = provisioning_state self.timestamp = timestamp self.service_request_id = service_request_id @@ -457,7 +424,7 @@ def __init__( self.response = response -class DeploymentOperationsListResult(msrest.serialization.Model): +class DeploymentOperationsListResult(_serialization.Model): """List of deployment operations. :ivar value: The list of deployments. @@ -467,16 +434,12 @@ class DeploymentOperationsListResult(msrest.serialization.Model): """ _attribute_map = { - 'value': {'key': 'value', 'type': '[DeploymentOperation]'}, - 'next_link': {'key': 'nextLink', 'type': 'str'}, + "value": {"key": "value", "type": "[DeploymentOperation]"}, + "next_link": {"key": "nextLink", "type": "str"}, } def __init__( - self, - *, - value: Optional[List["DeploymentOperation"]] = None, - next_link: Optional[str] = None, - **kwargs + self, *, value: Optional[List["_models.DeploymentOperation"]] = None, next_link: Optional[str] = None, **kwargs ): """ :keyword value: The list of deployments. @@ -484,74 +447,73 @@ def __init__( :keyword next_link: The URL to get the next set of results. :paramtype next_link: str """ - super(DeploymentOperationsListResult, self).__init__(**kwargs) + super().__init__(**kwargs) self.value = value self.next_link = next_link -class DeploymentProperties(msrest.serialization.Model): +class DeploymentProperties(_serialization.Model): """Deployment properties. All required parameters must be populated in order to send to Azure. :ivar template: The template content. It can be a JObject or a well formed JSON string. Use only one of Template or TemplateLink. - :vartype template: any + :vartype template: JSON :ivar template_link: The template URI. Use only one of Template or TemplateLink. :vartype template_link: ~azure.mgmt.resource.resources.v2016_02_01.models.TemplateLink :ivar parameters: Deployment parameters. It can be a JObject or a well formed JSON string. Use only one of Parameters or ParametersLink. - :vartype parameters: any + :vartype parameters: JSON :ivar parameters_link: The parameters URI. Use only one of Parameters or ParametersLink. :vartype parameters_link: ~azure.mgmt.resource.resources.v2016_02_01.models.ParametersLink - :ivar mode: Required. The deployment mode. Possible values include: "Incremental", "Complete". + :ivar mode: The deployment mode. Required. Known values are: "Incremental" and "Complete". :vartype mode: str or ~azure.mgmt.resource.resources.v2016_02_01.models.DeploymentMode :ivar debug_setting: The debug setting of the deployment. :vartype debug_setting: ~azure.mgmt.resource.resources.v2016_02_01.models.DebugSetting """ _validation = { - 'mode': {'required': True}, + "mode": {"required": True}, } _attribute_map = { - 'template': {'key': 'template', 'type': 'object'}, - 'template_link': {'key': 'templateLink', 'type': 'TemplateLink'}, - 'parameters': {'key': 'parameters', 'type': 'object'}, - 'parameters_link': {'key': 'parametersLink', 'type': 'ParametersLink'}, - 'mode': {'key': 'mode', 'type': 'str'}, - 'debug_setting': {'key': 'debugSetting', 'type': 'DebugSetting'}, + "template": {"key": "template", "type": "object"}, + "template_link": {"key": "templateLink", "type": "TemplateLink"}, + "parameters": {"key": "parameters", "type": "object"}, + "parameters_link": {"key": "parametersLink", "type": "ParametersLink"}, + "mode": {"key": "mode", "type": "str"}, + "debug_setting": {"key": "debugSetting", "type": "DebugSetting"}, } def __init__( self, *, - mode: Union[str, "DeploymentMode"], - template: Optional[Any] = None, - template_link: Optional["TemplateLink"] = None, - parameters: Optional[Any] = None, - parameters_link: Optional["ParametersLink"] = None, - debug_setting: Optional["DebugSetting"] = None, + mode: Union[str, "_models.DeploymentMode"], + template: Optional[JSON] = None, + template_link: Optional["_models.TemplateLink"] = None, + parameters: Optional[JSON] = None, + parameters_link: Optional["_models.ParametersLink"] = None, + debug_setting: Optional["_models.DebugSetting"] = None, **kwargs ): """ :keyword template: The template content. It can be a JObject or a well formed JSON string. Use only one of Template or TemplateLink. - :paramtype template: any + :paramtype template: JSON :keyword template_link: The template URI. Use only one of Template or TemplateLink. :paramtype template_link: ~azure.mgmt.resource.resources.v2016_02_01.models.TemplateLink :keyword parameters: Deployment parameters. It can be a JObject or a well formed JSON string. Use only one of Parameters or ParametersLink. - :paramtype parameters: any + :paramtype parameters: JSON :keyword parameters_link: The parameters URI. Use only one of Parameters or ParametersLink. :paramtype parameters_link: ~azure.mgmt.resource.resources.v2016_02_01.models.ParametersLink - :keyword mode: Required. The deployment mode. Possible values include: "Incremental", - "Complete". + :keyword mode: The deployment mode. Required. Known values are: "Incremental" and "Complete". :paramtype mode: str or ~azure.mgmt.resource.resources.v2016_02_01.models.DeploymentMode :keyword debug_setting: The debug setting of the deployment. :paramtype debug_setting: ~azure.mgmt.resource.resources.v2016_02_01.models.DebugSetting """ - super(DeploymentProperties, self).__init__(**kwargs) + super().__init__(**kwargs) self.template = template self.template_link = template_link self.parameters = parameters @@ -560,7 +522,7 @@ def __init__( self.debug_setting = debug_setting -class DeploymentPropertiesExtended(msrest.serialization.Model): +class DeploymentPropertiesExtended(_serialization.Model): # pylint: disable=too-many-instance-attributes """Deployment properties with additional details. Variables are only populated by the server, and will be ignored when sending a request. @@ -572,22 +534,22 @@ class DeploymentPropertiesExtended(msrest.serialization.Model): :ivar timestamp: The timestamp of the template deployment. :vartype timestamp: ~datetime.datetime :ivar outputs: Key/value pairs that represent deployment output. - :vartype outputs: any + :vartype outputs: JSON :ivar providers: The list of resource providers needed for the deployment. :vartype providers: list[~azure.mgmt.resource.resources.v2016_02_01.models.Provider] :ivar dependencies: The list of deployment dependencies. :vartype dependencies: list[~azure.mgmt.resource.resources.v2016_02_01.models.Dependency] :ivar template: The template content. Use only one of Template or TemplateLink. - :vartype template: any + :vartype template: JSON :ivar template_link: The URI referencing the template. Use only one of Template or TemplateLink. :vartype template_link: ~azure.mgmt.resource.resources.v2016_02_01.models.TemplateLink :ivar parameters: Deployment parameters. Use only one of Parameters or ParametersLink. - :vartype parameters: any + :vartype parameters: JSON :ivar parameters_link: The URI referencing the parameters. Use only one of Parameters or ParametersLink. :vartype parameters_link: ~azure.mgmt.resource.resources.v2016_02_01.models.ParametersLink - :ivar mode: The deployment mode. Possible values include: "Incremental", "Complete". + :ivar mode: The deployment mode. Known values are: "Incremental" and "Complete". :vartype mode: str or ~azure.mgmt.resource.resources.v2016_02_01.models.DeploymentMode :ivar debug_setting: The debug setting of the deployment. :vartype debug_setting: ~azure.mgmt.resource.resources.v2016_02_01.models.DebugSetting @@ -596,23 +558,23 @@ class DeploymentPropertiesExtended(msrest.serialization.Model): """ _validation = { - 'error': {'readonly': True}, + "error": {"readonly": True}, } _attribute_map = { - 'provisioning_state': {'key': 'provisioningState', 'type': 'str'}, - 'correlation_id': {'key': 'correlationId', 'type': 'str'}, - 'timestamp': {'key': 'timestamp', 'type': 'iso-8601'}, - 'outputs': {'key': 'outputs', 'type': 'object'}, - 'providers': {'key': 'providers', 'type': '[Provider]'}, - 'dependencies': {'key': 'dependencies', 'type': '[Dependency]'}, - 'template': {'key': 'template', 'type': 'object'}, - 'template_link': {'key': 'templateLink', 'type': 'TemplateLink'}, - 'parameters': {'key': 'parameters', 'type': 'object'}, - 'parameters_link': {'key': 'parametersLink', 'type': 'ParametersLink'}, - 'mode': {'key': 'mode', 'type': 'str'}, - 'debug_setting': {'key': 'debugSetting', 'type': 'DebugSetting'}, - 'error': {'key': 'error', 'type': 'ErrorResponse'}, + "provisioning_state": {"key": "provisioningState", "type": "str"}, + "correlation_id": {"key": "correlationId", "type": "str"}, + "timestamp": {"key": "timestamp", "type": "iso-8601"}, + "outputs": {"key": "outputs", "type": "object"}, + "providers": {"key": "providers", "type": "[Provider]"}, + "dependencies": {"key": "dependencies", "type": "[Dependency]"}, + "template": {"key": "template", "type": "object"}, + "template_link": {"key": "templateLink", "type": "TemplateLink"}, + "parameters": {"key": "parameters", "type": "object"}, + "parameters_link": {"key": "parametersLink", "type": "ParametersLink"}, + "mode": {"key": "mode", "type": "str"}, + "debug_setting": {"key": "debugSetting", "type": "DebugSetting"}, + "error": {"key": "error", "type": "ErrorResponse"}, } def __init__( @@ -621,15 +583,15 @@ def __init__( provisioning_state: Optional[str] = None, correlation_id: Optional[str] = None, timestamp: Optional[datetime.datetime] = None, - outputs: Optional[Any] = None, - providers: Optional[List["Provider"]] = None, - dependencies: Optional[List["Dependency"]] = None, - template: Optional[Any] = None, - template_link: Optional["TemplateLink"] = None, - parameters: Optional[Any] = None, - parameters_link: Optional["ParametersLink"] = None, - mode: Optional[Union[str, "DeploymentMode"]] = None, - debug_setting: Optional["DebugSetting"] = None, + outputs: Optional[JSON] = None, + providers: Optional[List["_models.Provider"]] = None, + dependencies: Optional[List["_models.Dependency"]] = None, + template: Optional[JSON] = None, + template_link: Optional["_models.TemplateLink"] = None, + parameters: Optional[JSON] = None, + parameters_link: Optional["_models.ParametersLink"] = None, + mode: Optional[Union[str, "_models.DeploymentMode"]] = None, + debug_setting: Optional["_models.DebugSetting"] = None, **kwargs ): """ @@ -640,27 +602,27 @@ def __init__( :keyword timestamp: The timestamp of the template deployment. :paramtype timestamp: ~datetime.datetime :keyword outputs: Key/value pairs that represent deployment output. - :paramtype outputs: any + :paramtype outputs: JSON :keyword providers: The list of resource providers needed for the deployment. :paramtype providers: list[~azure.mgmt.resource.resources.v2016_02_01.models.Provider] :keyword dependencies: The list of deployment dependencies. :paramtype dependencies: list[~azure.mgmt.resource.resources.v2016_02_01.models.Dependency] :keyword template: The template content. Use only one of Template or TemplateLink. - :paramtype template: any + :paramtype template: JSON :keyword template_link: The URI referencing the template. Use only one of Template or TemplateLink. :paramtype template_link: ~azure.mgmt.resource.resources.v2016_02_01.models.TemplateLink :keyword parameters: Deployment parameters. Use only one of Parameters or ParametersLink. - :paramtype parameters: any + :paramtype parameters: JSON :keyword parameters_link: The URI referencing the parameters. Use only one of Parameters or ParametersLink. :paramtype parameters_link: ~azure.mgmt.resource.resources.v2016_02_01.models.ParametersLink - :keyword mode: The deployment mode. Possible values include: "Incremental", "Complete". + :keyword mode: The deployment mode. Known values are: "Incremental" and "Complete". :paramtype mode: str or ~azure.mgmt.resource.resources.v2016_02_01.models.DeploymentMode :keyword debug_setting: The debug setting of the deployment. :paramtype debug_setting: ~azure.mgmt.resource.resources.v2016_02_01.models.DebugSetting """ - super(DeploymentPropertiesExtended, self).__init__(**kwargs) + super().__init__(**kwargs) self.provisioning_state = provisioning_state self.correlation_id = correlation_id self.timestamp = timestamp @@ -676,7 +638,7 @@ def __init__( self.error = None -class DeploymentValidateResult(msrest.serialization.Model): +class DeploymentValidateResult(_serialization.Model): """Information from validate template deployment response. :ivar error: Validation error. @@ -688,15 +650,15 @@ class DeploymentValidateResult(msrest.serialization.Model): """ _attribute_map = { - 'error': {'key': 'error', 'type': 'ResourceManagementErrorWithDetails'}, - 'properties': {'key': 'properties', 'type': 'DeploymentPropertiesExtended'}, + "error": {"key": "error", "type": "ResourceManagementErrorWithDetails"}, + "properties": {"key": "properties", "type": "DeploymentPropertiesExtended"}, } def __init__( self, *, - error: Optional["ResourceManagementErrorWithDetails"] = None, - properties: Optional["DeploymentPropertiesExtended"] = None, + error: Optional["_models.ResourceManagementErrorWithDetails"] = None, + properties: Optional["_models.DeploymentPropertiesExtended"] = None, **kwargs ): """ @@ -707,12 +669,12 @@ def __init__( :paramtype properties: ~azure.mgmt.resource.resources.v2016_02_01.models.DeploymentPropertiesExtended """ - super(DeploymentValidateResult, self).__init__(**kwargs) + super().__init__(**kwargs) self.error = error self.properties = properties -class ErrorAdditionalInfo(msrest.serialization.Model): +class ErrorAdditionalInfo(_serialization.Model): """The resource management error additional info. Variables are only populated by the server, and will be ignored when sending a request. @@ -720,31 +682,27 @@ class ErrorAdditionalInfo(msrest.serialization.Model): :ivar type: The additional info type. :vartype type: str :ivar info: The additional info. - :vartype info: any + :vartype info: JSON """ _validation = { - 'type': {'readonly': True}, - 'info': {'readonly': True}, + "type": {"readonly": True}, + "info": {"readonly": True}, } _attribute_map = { - 'type': {'key': 'type', 'type': 'str'}, - 'info': {'key': 'info', 'type': 'object'}, + "type": {"key": "type", "type": "str"}, + "info": {"key": "info", "type": "object"}, } - def __init__( - self, - **kwargs - ): - """ - """ - super(ErrorAdditionalInfo, self).__init__(**kwargs) + def __init__(self, **kwargs): + """ """ + super().__init__(**kwargs) self.type = None self.info = None -class ErrorResponse(msrest.serialization.Model): +class ErrorResponse(_serialization.Model): """Common error response for all Azure Resource Manager APIs to return error details for failed operations. (This also follows the OData error response format.). Variables are only populated by the server, and will be ignored when sending a request. @@ -763,28 +721,24 @@ class ErrorResponse(msrest.serialization.Model): """ _validation = { - 'code': {'readonly': True}, - 'message': {'readonly': True}, - 'target': {'readonly': True}, - 'details': {'readonly': True}, - 'additional_info': {'readonly': True}, + "code": {"readonly": True}, + "message": {"readonly": True}, + "target": {"readonly": True}, + "details": {"readonly": True}, + "additional_info": {"readonly": True}, } _attribute_map = { - 'code': {'key': 'code', 'type': 'str'}, - 'message': {'key': 'message', 'type': 'str'}, - 'target': {'key': 'target', 'type': 'str'}, - 'details': {'key': 'details', 'type': '[ErrorResponse]'}, - 'additional_info': {'key': 'additionalInfo', 'type': '[ErrorAdditionalInfo]'}, + "code": {"key": "code", "type": "str"}, + "message": {"key": "message", "type": "str"}, + "target": {"key": "target", "type": "str"}, + "details": {"key": "details", "type": "[ErrorResponse]"}, + "additional_info": {"key": "additionalInfo", "type": "[ErrorAdditionalInfo]"}, } - def __init__( - self, - **kwargs - ): - """ - """ - super(ErrorResponse, self).__init__(**kwargs) + def __init__(self, **kwargs): + """ """ + super().__init__(**kwargs) self.code = None self.message = None self.target = None @@ -792,7 +746,7 @@ def __init__( self.additional_info = None -class ExportTemplateRequest(msrest.serialization.Model): +class ExportTemplateRequest(_serialization.Model): """Export resource group template request parameters. :ivar resources: The IDs of the resources to filter the export by. To export all resources, @@ -805,17 +759,11 @@ class ExportTemplateRequest(msrest.serialization.Model): """ _attribute_map = { - 'resources': {'key': 'resources', 'type': '[str]'}, - 'options': {'key': 'options', 'type': 'str'}, + "resources": {"key": "resources", "type": "[str]"}, + "options": {"key": "options", "type": "str"}, } - def __init__( - self, - *, - resources: Optional[List[str]] = None, - options: Optional[str] = None, - **kwargs - ): + def __init__(self, *, resources: Optional[List[str]] = None, options: Optional[str] = None, **kwargs): """ :keyword resources: The IDs of the resources to filter the export by. To export all resources, supply an array with single entry '*'. @@ -825,12 +773,12 @@ def __init__( 'SkipResourceNameParameterization', 'SkipAllParameterization'. :paramtype options: str """ - super(ExportTemplateRequest, self).__init__(**kwargs) + super().__init__(**kwargs) self.resources = resources self.options = options -class Resource(msrest.serialization.Model): +class Resource(_serialization.Model): """Resource. Variables are only populated by the server, and will be ignored when sending a request. @@ -843,38 +791,32 @@ class Resource(msrest.serialization.Model): :vartype type: str :ivar location: Resource location. :vartype location: str - :ivar tags: A set of tags. Resource tags. + :ivar tags: Resource tags. :vartype tags: dict[str, str] """ _validation = { - 'id': {'readonly': True}, - 'name': {'readonly': True}, - 'type': {'readonly': True}, + "id": {"readonly": True}, + "name": {"readonly": True}, + "type": {"readonly": True}, } _attribute_map = { - 'id': {'key': 'id', 'type': 'str'}, - 'name': {'key': 'name', 'type': 'str'}, - 'type': {'key': 'type', 'type': 'str'}, - 'location': {'key': 'location', 'type': 'str'}, - 'tags': {'key': 'tags', 'type': '{str}'}, + "id": {"key": "id", "type": "str"}, + "name": {"key": "name", "type": "str"}, + "type": {"key": "type", "type": "str"}, + "location": {"key": "location", "type": "str"}, + "tags": {"key": "tags", "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): """ :keyword location: Resource location. :paramtype location: str - :keyword tags: A set of tags. Resource tags. + :keyword tags: Resource tags. :paramtype tags: dict[str, str] """ - super(Resource, self).__init__(**kwargs) + super().__init__(**kwargs) self.id = None self.name = None self.type = None @@ -882,7 +824,7 @@ def __init__( self.tags = tags -class GenericResource(Resource): +class GenericResource(Resource): # pylint: disable=too-many-instance-attributes """Resource information. Variables are only populated by the server, and will be ignored when sending a request. @@ -895,12 +837,12 @@ class GenericResource(Resource): :vartype type: str :ivar location: Resource location. :vartype location: str - :ivar tags: A set of tags. Resource tags. + :ivar tags: Resource tags. :vartype tags: dict[str, str] :ivar plan: The plan of the resource. :vartype plan: ~azure.mgmt.resource.resources.v2016_02_01.models.Plan :ivar properties: The resource properties. - :vartype properties: any + :vartype properties: JSON :ivar kind: The kind of the resource. :vartype kind: str :ivar managed_by: Id of the resource that manages this resource. @@ -912,23 +854,23 @@ class GenericResource(Resource): """ _validation = { - 'id': {'readonly': True}, - 'name': {'readonly': True}, - 'type': {'readonly': True}, + "id": {"readonly": True}, + "name": {"readonly": True}, + "type": {"readonly": True}, } _attribute_map = { - 'id': {'key': 'id', 'type': 'str'}, - 'name': {'key': 'name', 'type': 'str'}, - 'type': {'key': 'type', 'type': 'str'}, - 'location': {'key': 'location', 'type': 'str'}, - 'tags': {'key': 'tags', 'type': '{str}'}, - 'plan': {'key': 'plan', 'type': 'Plan'}, - 'properties': {'key': 'properties', 'type': 'object'}, - 'kind': {'key': 'kind', 'type': 'str'}, - 'managed_by': {'key': 'managedBy', 'type': 'str'}, - 'sku': {'key': 'sku', 'type': 'Sku'}, - 'identity': {'key': 'identity', 'type': 'Identity'}, + "id": {"key": "id", "type": "str"}, + "name": {"key": "name", "type": "str"}, + "type": {"key": "type", "type": "str"}, + "location": {"key": "location", "type": "str"}, + "tags": {"key": "tags", "type": "{str}"}, + "plan": {"key": "plan", "type": "Plan"}, + "properties": {"key": "properties", "type": "object"}, + "kind": {"key": "kind", "type": "str"}, + "managed_by": {"key": "managedBy", "type": "str"}, + "sku": {"key": "sku", "type": "Sku"}, + "identity": {"key": "identity", "type": "Identity"}, } def __init__( @@ -936,23 +878,23 @@ def __init__( *, location: Optional[str] = None, tags: Optional[Dict[str, str]] = None, - plan: Optional["Plan"] = None, - properties: Optional[Any] = None, + plan: Optional["_models.Plan"] = None, + properties: Optional[JSON] = None, kind: Optional[str] = None, managed_by: Optional[str] = None, - sku: Optional["Sku"] = None, - identity: Optional["Identity"] = None, + sku: Optional["_models.Sku"] = None, + identity: Optional["_models.Identity"] = None, **kwargs ): """ :keyword location: Resource location. :paramtype location: str - :keyword tags: A set of tags. Resource tags. + :keyword tags: Resource tags. :paramtype tags: dict[str, str] :keyword plan: The plan of the resource. :paramtype plan: ~azure.mgmt.resource.resources.v2016_02_01.models.Plan :keyword properties: The resource properties. - :paramtype properties: any + :paramtype properties: JSON :keyword kind: The kind of the resource. :paramtype kind: str :keyword managed_by: Id of the resource that manages this resource. @@ -962,7 +904,7 @@ def __init__( :keyword identity: The identity of the resource. :paramtype identity: ~azure.mgmt.resource.resources.v2016_02_01.models.Identity """ - super(GenericResource, self).__init__(location=location, tags=tags, **kwargs) + super().__init__(location=location, tags=tags, **kwargs) self.plan = plan self.properties = properties self.kind = kind @@ -971,7 +913,7 @@ def __init__( self.identity = identity -class GenericResourceExpanded(GenericResource): +class GenericResourceExpanded(GenericResource): # pylint: disable=too-many-instance-attributes """Resource information. Variables are only populated by the server, and will be ignored when sending a request. @@ -984,12 +926,12 @@ class GenericResourceExpanded(GenericResource): :vartype type: str :ivar location: Resource location. :vartype location: str - :ivar tags: A set of tags. Resource tags. + :ivar tags: Resource tags. :vartype tags: dict[str, str] :ivar plan: The plan of the resource. :vartype plan: ~azure.mgmt.resource.resources.v2016_02_01.models.Plan :ivar properties: The resource properties. - :vartype properties: any + :vartype properties: JSON :ivar kind: The kind of the resource. :vartype kind: str :ivar managed_by: Id of the resource that manages this resource. @@ -1010,29 +952,29 @@ class GenericResourceExpanded(GenericResource): """ _validation = { - 'id': {'readonly': True}, - 'name': {'readonly': True}, - 'type': {'readonly': True}, - 'created_time': {'readonly': True}, - 'changed_time': {'readonly': True}, - 'provisioning_state': {'readonly': True}, + "id": {"readonly": True}, + "name": {"readonly": True}, + "type": {"readonly": True}, + "created_time": {"readonly": True}, + "changed_time": {"readonly": True}, + "provisioning_state": {"readonly": True}, } _attribute_map = { - 'id': {'key': 'id', 'type': 'str'}, - 'name': {'key': 'name', 'type': 'str'}, - 'type': {'key': 'type', 'type': 'str'}, - 'location': {'key': 'location', 'type': 'str'}, - 'tags': {'key': 'tags', 'type': '{str}'}, - 'plan': {'key': 'plan', 'type': 'Plan'}, - 'properties': {'key': 'properties', 'type': 'object'}, - 'kind': {'key': 'kind', 'type': 'str'}, - 'managed_by': {'key': 'managedBy', 'type': 'str'}, - 'sku': {'key': 'sku', 'type': 'Sku'}, - 'identity': {'key': 'identity', 'type': 'Identity'}, - 'created_time': {'key': 'createdTime', 'type': 'iso-8601'}, - 'changed_time': {'key': 'changedTime', 'type': 'iso-8601'}, - 'provisioning_state': {'key': 'provisioningState', 'type': 'str'}, + "id": {"key": "id", "type": "str"}, + "name": {"key": "name", "type": "str"}, + "type": {"key": "type", "type": "str"}, + "location": {"key": "location", "type": "str"}, + "tags": {"key": "tags", "type": "{str}"}, + "plan": {"key": "plan", "type": "Plan"}, + "properties": {"key": "properties", "type": "object"}, + "kind": {"key": "kind", "type": "str"}, + "managed_by": {"key": "managedBy", "type": "str"}, + "sku": {"key": "sku", "type": "Sku"}, + "identity": {"key": "identity", "type": "Identity"}, + "created_time": {"key": "createdTime", "type": "iso-8601"}, + "changed_time": {"key": "changedTime", "type": "iso-8601"}, + "provisioning_state": {"key": "provisioningState", "type": "str"}, } def __init__( @@ -1040,23 +982,23 @@ def __init__( *, location: Optional[str] = None, tags: Optional[Dict[str, str]] = None, - plan: Optional["Plan"] = None, - properties: Optional[Any] = None, + plan: Optional["_models.Plan"] = None, + properties: Optional[JSON] = None, kind: Optional[str] = None, managed_by: Optional[str] = None, - sku: Optional["Sku"] = None, - identity: Optional["Identity"] = None, + sku: Optional["_models.Sku"] = None, + identity: Optional["_models.Identity"] = None, **kwargs ): """ :keyword location: Resource location. :paramtype location: str - :keyword tags: A set of tags. Resource tags. + :keyword tags: Resource tags. :paramtype tags: dict[str, str] :keyword plan: The plan of the resource. :paramtype plan: ~azure.mgmt.resource.resources.v2016_02_01.models.Plan :keyword properties: The resource properties. - :paramtype properties: any + :paramtype properties: JSON :keyword kind: The kind of the resource. :paramtype kind: str :keyword managed_by: Id of the resource that manages this resource. @@ -1066,13 +1008,23 @@ def __init__( :keyword identity: The identity of the resource. :paramtype identity: ~azure.mgmt.resource.resources.v2016_02_01.models.Identity """ - super(GenericResourceExpanded, self).__init__(location=location, tags=tags, plan=plan, properties=properties, kind=kind, managed_by=managed_by, sku=sku, identity=identity, **kwargs) + super().__init__( + location=location, + tags=tags, + plan=plan, + properties=properties, + kind=kind, + managed_by=managed_by, + sku=sku, + identity=identity, + **kwargs + ) self.created_time = None self.changed_time = None self.provisioning_state = None -class GenericResourceFilter(msrest.serialization.Model): +class GenericResourceFilter(_serialization.Model): """Resource filter. :ivar resource_type: The resource type. @@ -1084,9 +1036,9 @@ class GenericResourceFilter(msrest.serialization.Model): """ _attribute_map = { - 'resource_type': {'key': 'resourceType', 'type': 'str'}, - 'tagname': {'key': 'tagname', 'type': 'str'}, - 'tagvalue': {'key': 'tagvalue', 'type': 'str'}, + "resource_type": {"key": "resourceType", "type": "str"}, + "tagname": {"key": "tagname", "type": "str"}, + "tagvalue": {"key": "tagvalue", "type": "str"}, } def __init__( @@ -1105,38 +1057,33 @@ def __init__( :keyword tagvalue: The tag value. :paramtype tagvalue: str """ - super(GenericResourceFilter, self).__init__(**kwargs) + super().__init__(**kwargs) self.resource_type = resource_type self.tagname = tagname self.tagvalue = tagvalue -class HttpMessage(msrest.serialization.Model): +class HttpMessage(_serialization.Model): """HttpMessage. :ivar content: HTTP message content. - :vartype content: any + :vartype content: JSON """ _attribute_map = { - 'content': {'key': 'content', 'type': 'object'}, + "content": {"key": "content", "type": "object"}, } - def __init__( - self, - *, - content: Optional[Any] = None, - **kwargs - ): + def __init__(self, *, content: Optional[JSON] = None, **kwargs): """ :keyword content: HTTP message content. - :paramtype content: any + :paramtype content: JSON """ - super(HttpMessage, self).__init__(**kwargs) + super().__init__(**kwargs) self.content = content -class Identity(msrest.serialization.Model): +class Identity(_serialization.Model): """Identity for the resource. Variables are only populated by the server, and will be ignored when sending a request. @@ -1145,78 +1092,65 @@ class Identity(msrest.serialization.Model): :vartype principal_id: str :ivar tenant_id: The tenant id of resource. :vartype tenant_id: str - :ivar type: The identity type. The only acceptable values to pass in are None and - "SystemAssigned". The default value is None. + :ivar type: The identity type. Default value is "SystemAssigned". :vartype type: str """ _validation = { - 'principal_id': {'readonly': True}, - 'tenant_id': {'readonly': True}, + "principal_id": {"readonly": True}, + "tenant_id": {"readonly": True}, } _attribute_map = { - 'principal_id': {'key': 'principalId', 'type': 'str'}, - 'tenant_id': {'key': 'tenantId', 'type': 'str'}, - 'type': {'key': 'type', 'type': 'str'}, + "principal_id": {"key": "principalId", "type": "str"}, + "tenant_id": {"key": "tenantId", "type": "str"}, + "type": {"key": "type", "type": "str"}, } - def __init__( - self, - *, - type: Optional[str] = None, - **kwargs - ): + def __init__(self, *, type: Optional[str] = None, **kwargs): """ - :keyword type: The identity type. The only acceptable values to pass in are None and - "SystemAssigned". The default value is None. + :keyword type: The identity type. Default value is "SystemAssigned". :paramtype type: str """ - super(Identity, self).__init__(**kwargs) + super().__init__(**kwargs) self.principal_id = None self.tenant_id = None self.type = type -class ParametersLink(msrest.serialization.Model): +class ParametersLink(_serialization.Model): """Entity representing the reference to the deployment parameters. All required parameters must be populated in order to send to Azure. - :ivar uri: Required. URI referencing the template. + :ivar uri: URI referencing the template. Required. :vartype uri: str :ivar content_version: If included it must match the ContentVersion in the template. :vartype content_version: str """ _validation = { - 'uri': {'required': True}, + "uri": {"required": True}, } _attribute_map = { - 'uri': {'key': 'uri', 'type': 'str'}, - 'content_version': {'key': 'contentVersion', 'type': 'str'}, + "uri": {"key": "uri", "type": "str"}, + "content_version": {"key": "contentVersion", "type": "str"}, } - def __init__( - self, - *, - uri: str, - content_version: Optional[str] = None, - **kwargs - ): + def __init__(self, *, uri: str, content_version: Optional[str] = None, **kwargs): """ - :keyword uri: Required. URI referencing the template. + :keyword uri: URI referencing the template. Required. :paramtype uri: str :keyword content_version: If included it must match the ContentVersion in the template. :paramtype content_version: str """ - super(ParametersLink, self).__init__(**kwargs) + super().__init__(**kwargs) self.uri = uri self.content_version = content_version -class Plan(msrest.serialization.Model): +class Plan(_serialization.Model): """Plan for the resource. :ivar name: The plan ID. @@ -1230,10 +1164,10 @@ class Plan(msrest.serialization.Model): """ _attribute_map = { - 'name': {'key': 'name', 'type': 'str'}, - 'publisher': {'key': 'publisher', 'type': 'str'}, - 'product': {'key': 'product', 'type': 'str'}, - 'promotion_code': {'key': 'promotionCode', 'type': 'str'}, + "name": {"key": "name", "type": "str"}, + "publisher": {"key": "publisher", "type": "str"}, + "product": {"key": "product", "type": "str"}, + "promotion_code": {"key": "promotionCode", "type": "str"}, } def __init__( @@ -1255,14 +1189,14 @@ def __init__( :keyword promotion_code: The promotion code. :paramtype promotion_code: str """ - super(Plan, self).__init__(**kwargs) + super().__init__(**kwargs) self.name = name self.publisher = publisher self.product = product self.promotion_code = promotion_code -class Provider(msrest.serialization.Model): +class Provider(_serialization.Model): """Resource provider information. :ivar id: The provider id. @@ -1277,19 +1211,19 @@ class Provider(msrest.serialization.Model): """ _attribute_map = { - 'id': {'key': 'id', 'type': 'str'}, - 'namespace': {'key': 'namespace', 'type': 'str'}, - 'registration_state': {'key': 'registrationState', 'type': 'str'}, - 'resource_types': {'key': 'resourceTypes', 'type': '[ProviderResourceType]'}, + "id": {"key": "id", "type": "str"}, + "namespace": {"key": "namespace", "type": "str"}, + "registration_state": {"key": "registrationState", "type": "str"}, + "resource_types": {"key": "resourceTypes", "type": "[ProviderResourceType]"}, } def __init__( self, *, - id: Optional[str] = None, + id: Optional[str] = None, # pylint: disable=redefined-builtin namespace: Optional[str] = None, registration_state: Optional[str] = None, - resource_types: Optional[List["ProviderResourceType"]] = None, + resource_types: Optional[List["_models.ProviderResourceType"]] = None, **kwargs ): """ @@ -1303,14 +1237,14 @@ def __init__( :paramtype resource_types: list[~azure.mgmt.resource.resources.v2016_02_01.models.ProviderResourceType] """ - super(Provider, self).__init__(**kwargs) + super().__init__(**kwargs) self.id = id self.namespace = namespace self.registration_state = registration_state self.resource_types = resource_types -class ProviderListResult(msrest.serialization.Model): +class ProviderListResult(_serialization.Model): """List of resource providers. :ivar value: The list of resource providers. @@ -1320,29 +1254,23 @@ class ProviderListResult(msrest.serialization.Model): """ _attribute_map = { - 'value': {'key': 'value', 'type': '[Provider]'}, - 'next_link': {'key': 'nextLink', 'type': 'str'}, + "value": {"key": "value", "type": "[Provider]"}, + "next_link": {"key": "nextLink", "type": "str"}, } - def __init__( - self, - *, - value: Optional[List["Provider"]] = None, - next_link: Optional[str] = None, - **kwargs - ): + def __init__(self, *, value: Optional[List["_models.Provider"]] = None, next_link: Optional[str] = None, **kwargs): """ :keyword value: The list of resource providers. :paramtype value: list[~azure.mgmt.resource.resources.v2016_02_01.models.Provider] :keyword next_link: The URL to get the next set of results. :paramtype next_link: str """ - super(ProviderListResult, self).__init__(**kwargs) + super().__init__(**kwargs) self.value = value self.next_link = next_link -class ProviderResourceType(msrest.serialization.Model): +class ProviderResourceType(_serialization.Model): """Resource type managed by the resource provider. :ivar resource_type: The resource type. @@ -1358,11 +1286,11 @@ class ProviderResourceType(msrest.serialization.Model): """ _attribute_map = { - 'resource_type': {'key': 'resourceType', 'type': 'str'}, - 'locations': {'key': 'locations', 'type': '[str]'}, - 'aliases': {'key': 'aliases', 'type': '[AliasType]'}, - 'api_versions': {'key': 'apiVersions', 'type': '[str]'}, - 'properties': {'key': 'properties', 'type': '{str}'}, + "resource_type": {"key": "resourceType", "type": "str"}, + "locations": {"key": "locations", "type": "[str]"}, + "aliases": {"key": "aliases", "type": "[AliasType]"}, + "api_versions": {"key": "apiVersions", "type": "[str]"}, + "properties": {"key": "properties", "type": "{str}"}, } def __init__( @@ -1370,7 +1298,7 @@ def __init__( *, resource_type: Optional[str] = None, locations: Optional[List[str]] = None, - aliases: Optional[List["AliasType"]] = None, + aliases: Optional[List["_models.AliasType"]] = None, api_versions: Optional[List[str]] = None, properties: Optional[Dict[str, str]] = None, **kwargs @@ -1387,7 +1315,7 @@ def __init__( :keyword properties: The properties. :paramtype properties: dict[str, str] """ - super(ProviderResourceType, self).__init__(**kwargs) + super().__init__(**kwargs) self.resource_type = resource_type self.locations = locations self.aliases = aliases @@ -1395,7 +1323,7 @@ def __init__( self.properties = properties -class ResourceGroup(msrest.serialization.Model): +class ResourceGroup(_serialization.Model): """Resource group information. Variables are only populated by the server, and will be ignored when sending a request. @@ -1408,25 +1336,25 @@ class ResourceGroup(msrest.serialization.Model): :vartype name: str :ivar properties: The resource group properties. :vartype properties: ~azure.mgmt.resource.resources.v2016_02_01.models.ResourceGroupProperties - :ivar location: Required. The location of the resource group. It cannot be changed after the - resource group has been created. Has to be one of the supported Azure Locations, such as West - US, East US, West Europe, East Asia, etc. + :ivar location: The location of the resource group. It cannot be changed after the resource + group has been created. Has to be one of the supported Azure Locations, such as West US, East + US, West Europe, East Asia, etc. Required. :vartype location: str - :ivar tags: A set of tags. The tags attached to the resource group. + :ivar tags: The tags attached to the resource group. :vartype tags: dict[str, str] """ _validation = { - 'id': {'readonly': True}, - 'location': {'required': True}, + "id": {"readonly": True}, + "location": {"required": True}, } _attribute_map = { - 'id': {'key': 'id', 'type': 'str'}, - 'name': {'key': 'name', 'type': 'str'}, - 'properties': {'key': 'properties', 'type': 'ResourceGroupProperties'}, - 'location': {'key': 'location', 'type': 'str'}, - 'tags': {'key': 'tags', 'type': '{str}'}, + "id": {"key": "id", "type": "str"}, + "name": {"key": "name", "type": "str"}, + "properties": {"key": "properties", "type": "ResourceGroupProperties"}, + "location": {"key": "location", "type": "str"}, + "tags": {"key": "tags", "type": "{str}"}, } def __init__( @@ -1434,7 +1362,7 @@ def __init__( *, location: str, name: Optional[str] = None, - properties: Optional["ResourceGroupProperties"] = None, + properties: Optional["_models.ResourceGroupProperties"] = None, tags: Optional[Dict[str, str]] = None, **kwargs ): @@ -1444,14 +1372,14 @@ def __init__( :keyword properties: The resource group properties. :paramtype properties: ~azure.mgmt.resource.resources.v2016_02_01.models.ResourceGroupProperties - :keyword location: Required. The location of the resource group. It cannot be changed after the - resource group has been created. Has to be one of the supported Azure Locations, such as West - US, East US, West Europe, East Asia, etc. + :keyword location: The location of the resource group. It cannot be changed after the resource + group has been created. Has to be one of the supported Azure Locations, such as West US, East + US, West Europe, East Asia, etc. Required. :paramtype location: str - :keyword tags: A set of tags. The tags attached to the resource group. + :keyword tags: The tags attached to the resource group. :paramtype tags: dict[str, str] """ - super(ResourceGroup, self).__init__(**kwargs) + super().__init__(**kwargs) self.id = None self.name = name self.properties = properties @@ -1459,41 +1387,41 @@ def __init__( self.tags = tags -class ResourceGroupExportResult(msrest.serialization.Model): +class ResourceGroupExportResult(_serialization.Model): """ResourceGroupExportResult. :ivar template: The template content. - :vartype template: any + :vartype template: JSON :ivar error: The error. :vartype error: ~azure.mgmt.resource.resources.v2016_02_01.models.ResourceManagementErrorWithDetails """ _attribute_map = { - 'template': {'key': 'template', 'type': 'object'}, - 'error': {'key': 'error', 'type': 'ResourceManagementErrorWithDetails'}, + "template": {"key": "template", "type": "object"}, + "error": {"key": "error", "type": "ResourceManagementErrorWithDetails"}, } def __init__( self, *, - template: Optional[Any] = None, - error: Optional["ResourceManagementErrorWithDetails"] = None, + template: Optional[JSON] = None, + error: Optional["_models.ResourceManagementErrorWithDetails"] = None, **kwargs ): """ :keyword template: The template content. - :paramtype template: any + :paramtype template: JSON :keyword error: The error. :paramtype error: ~azure.mgmt.resource.resources.v2016_02_01.models.ResourceManagementErrorWithDetails """ - super(ResourceGroupExportResult, self).__init__(**kwargs) + super().__init__(**kwargs) self.template = template self.error = error -class ResourceGroupFilter(msrest.serialization.Model): +class ResourceGroupFilter(_serialization.Model): """Resource group filter. :ivar tag_name: The tag name. @@ -1503,67 +1431,55 @@ class ResourceGroupFilter(msrest.serialization.Model): """ _attribute_map = { - 'tag_name': {'key': 'tagName', 'type': 'str'}, - 'tag_value': {'key': 'tagValue', 'type': 'str'}, + "tag_name": {"key": "tagName", "type": "str"}, + "tag_value": {"key": "tagValue", "type": "str"}, } - def __init__( - self, - *, - tag_name: Optional[str] = None, - tag_value: Optional[str] = None, - **kwargs - ): + def __init__(self, *, tag_name: Optional[str] = None, tag_value: Optional[str] = None, **kwargs): """ :keyword tag_name: The tag name. :paramtype tag_name: str :keyword tag_value: The tag value. :paramtype tag_value: str """ - super(ResourceGroupFilter, self).__init__(**kwargs) + super().__init__(**kwargs) self.tag_name = tag_name self.tag_value = tag_value -class ResourceGroupListResult(msrest.serialization.Model): +class ResourceGroupListResult(_serialization.Model): """List of resource groups. All required parameters must be populated in order to send to Azure. :ivar value: The list of resource groups. :vartype value: list[~azure.mgmt.resource.resources.v2016_02_01.models.ResourceGroup] - :ivar next_link: Required. The URL to get the next set of results. + :ivar next_link: The URL to get the next set of results. Required. :vartype next_link: str """ _validation = { - 'next_link': {'required': True}, + "next_link": {"required": True}, } _attribute_map = { - 'value': {'key': 'value', 'type': '[ResourceGroup]'}, - 'next_link': {'key': 'nextLink', 'type': 'str'}, + "value": {"key": "value", "type": "[ResourceGroup]"}, + "next_link": {"key": "nextLink", "type": "str"}, } - def __init__( - self, - *, - next_link: str, - value: Optional[List["ResourceGroup"]] = None, - **kwargs - ): + def __init__(self, *, next_link: str, value: Optional[List["_models.ResourceGroup"]] = None, **kwargs): """ :keyword value: The list of resource groups. :paramtype value: list[~azure.mgmt.resource.resources.v2016_02_01.models.ResourceGroup] - :keyword next_link: Required. The URL to get the next set of results. + :keyword next_link: The URL to get the next set of results. Required. :paramtype next_link: str """ - super(ResourceGroupListResult, self).__init__(**kwargs) + super().__init__(**kwargs) self.value = value self.next_link = next_link -class ResourceGroupProperties(msrest.serialization.Model): +class ResourceGroupProperties(_serialization.Model): """The resource group properties. Variables are only populated by the server, and will be ignored when sending a request. @@ -1573,70 +1489,60 @@ class ResourceGroupProperties(msrest.serialization.Model): """ _validation = { - 'provisioning_state': {'readonly': True}, + "provisioning_state": {"readonly": True}, } _attribute_map = { - 'provisioning_state': {'key': 'provisioningState', 'type': 'str'}, + "provisioning_state": {"key": "provisioningState", "type": "str"}, } - def __init__( - self, - **kwargs - ): - """ - """ - super(ResourceGroupProperties, self).__init__(**kwargs) + def __init__(self, **kwargs): + """ """ + super().__init__(**kwargs) self.provisioning_state = None -class ResourceListResult(msrest.serialization.Model): +class ResourceListResult(_serialization.Model): """List of resource groups. All required parameters must be populated in order to send to Azure. :ivar value: The list of resources. :vartype value: list[~azure.mgmt.resource.resources.v2016_02_01.models.GenericResourceExpanded] - :ivar next_link: Required. The URL to get the next set of results. + :ivar next_link: The URL to get the next set of results. Required. :vartype next_link: str """ _validation = { - 'next_link': {'required': True}, + "next_link": {"required": True}, } _attribute_map = { - 'value': {'key': 'value', 'type': '[GenericResourceExpanded]'}, - 'next_link': {'key': 'nextLink', 'type': 'str'}, + "value": {"key": "value", "type": "[GenericResourceExpanded]"}, + "next_link": {"key": "nextLink", "type": "str"}, } - def __init__( - self, - *, - next_link: str, - value: Optional[List["GenericResourceExpanded"]] = None, - **kwargs - ): + def __init__(self, *, next_link: str, value: Optional[List["_models.GenericResourceExpanded"]] = None, **kwargs): """ :keyword value: The list of resources. :paramtype value: list[~azure.mgmt.resource.resources.v2016_02_01.models.GenericResourceExpanded] - :keyword next_link: Required. The URL to get the next set of results. + :keyword next_link: The URL to get the next set of results. Required. :paramtype next_link: str """ - super(ResourceListResult, self).__init__(**kwargs) + super().__init__(**kwargs) self.value = value self.next_link = next_link -class ResourceManagementErrorWithDetails(msrest.serialization.Model): +class ResourceManagementErrorWithDetails(_serialization.Model): """ResourceManagementErrorWithDetails. All required parameters must be populated in order to send to Azure. - :ivar code: Required. The error code returned from the server. + :ivar code: The error code returned from the server. Required. :vartype code: str - :ivar message: Required. The error message returned from the server. + :ivar message: The error message returned from the server. Required. :vartype message: str :ivar target: The target of the error. :vartype target: str @@ -1646,15 +1552,15 @@ class ResourceManagementErrorWithDetails(msrest.serialization.Model): """ _validation = { - 'code': {'required': True}, - 'message': {'required': True}, + "code": {"required": True}, + "message": {"required": True}, } _attribute_map = { - 'code': {'key': 'code', 'type': 'str'}, - 'message': {'key': 'message', 'type': 'str'}, - 'target': {'key': 'target', 'type': 'str'}, - 'details': {'key': 'details', 'type': '[ResourceManagementErrorWithDetails]'}, + "code": {"key": "code", "type": "str"}, + "message": {"key": "message", "type": "str"}, + "target": {"key": "target", "type": "str"}, + "details": {"key": "details", "type": "[ResourceManagementErrorWithDetails]"}, } def __init__( @@ -1663,13 +1569,13 @@ def __init__( code: str, message: str, target: Optional[str] = None, - details: Optional[List["ResourceManagementErrorWithDetails"]] = None, + details: Optional[List["_models.ResourceManagementErrorWithDetails"]] = None, **kwargs ): """ - :keyword code: Required. The error code returned from the server. + :keyword code: The error code returned from the server. Required. :paramtype code: str - :keyword message: Required. The error message returned from the server. + :keyword message: The error message returned from the server. Required. :paramtype message: str :keyword target: The target of the error. :paramtype target: str @@ -1677,14 +1583,14 @@ def __init__( :paramtype details: list[~azure.mgmt.resource.resources.v2016_02_01.models.ResourceManagementErrorWithDetails] """ - super(ResourceManagementErrorWithDetails, self).__init__(**kwargs) + super().__init__(**kwargs) self.code = code self.message = message self.target = target self.details = details -class ResourceProviderOperationDisplayProperties(msrest.serialization.Model): +class ResourceProviderOperationDisplayProperties(_serialization.Model): """Resource provider operation's display properties. :ivar publisher: Operation description. @@ -1700,11 +1606,11 @@ class ResourceProviderOperationDisplayProperties(msrest.serialization.Model): """ _attribute_map = { - 'publisher': {'key': 'publisher', 'type': 'str'}, - 'provider': {'key': 'provider', 'type': 'str'}, - 'resource': {'key': 'resource', 'type': 'str'}, - 'operation': {'key': 'operation', 'type': 'str'}, - 'description': {'key': 'description', 'type': 'str'}, + "publisher": {"key": "publisher", "type": "str"}, + "provider": {"key": "provider", "type": "str"}, + "resource": {"key": "resource", "type": "str"}, + "operation": {"key": "operation", "type": "str"}, + "description": {"key": "description", "type": "str"}, } def __init__( @@ -1729,7 +1635,7 @@ def __init__( :keyword description: Operation description. :paramtype description: str """ - super(ResourceProviderOperationDisplayProperties, self).__init__(**kwargs) + super().__init__(**kwargs) self.publisher = publisher self.provider = provider self.resource = resource @@ -1737,7 +1643,7 @@ def __init__( self.description = description -class ResourcesMoveInfo(msrest.serialization.Model): +class ResourcesMoveInfo(_serialization.Model): """Parameters of move resources. :ivar resources: The ids of the resources. @@ -1747,29 +1653,23 @@ class ResourcesMoveInfo(msrest.serialization.Model): """ _attribute_map = { - 'resources': {'key': 'resources', 'type': '[str]'}, - 'target_resource_group': {'key': 'targetResourceGroup', 'type': 'str'}, + "resources": {"key": "resources", "type": "[str]"}, + "target_resource_group": {"key": "targetResourceGroup", "type": "str"}, } - def __init__( - self, - *, - resources: Optional[List[str]] = None, - target_resource_group: Optional[str] = None, - **kwargs - ): + def __init__(self, *, resources: Optional[List[str]] = None, target_resource_group: Optional[str] = None, **kwargs): """ :keyword resources: The ids of the resources. :paramtype resources: list[str] :keyword target_resource_group: The target resource group. :paramtype target_resource_group: str """ - super(ResourcesMoveInfo, self).__init__(**kwargs) + super().__init__(**kwargs) self.resources = resources self.target_resource_group = target_resource_group -class Sku(msrest.serialization.Model): +class Sku(_serialization.Model): """Sku for the resource. :ivar name: The sku name. @@ -1787,12 +1687,12 @@ class Sku(msrest.serialization.Model): """ _attribute_map = { - 'name': {'key': 'name', 'type': 'str'}, - 'tier': {'key': 'tier', 'type': 'str'}, - 'size': {'key': 'size', 'type': 'str'}, - 'family': {'key': 'family', 'type': 'str'}, - 'model': {'key': 'model', 'type': 'str'}, - 'capacity': {'key': 'capacity', 'type': 'int'}, + "name": {"key": "name", "type": "str"}, + "tier": {"key": "tier", "type": "str"}, + "size": {"key": "size", "type": "str"}, + "family": {"key": "family", "type": "str"}, + "model": {"key": "model", "type": "str"}, + "capacity": {"key": "capacity", "type": "int"}, } def __init__( @@ -1820,7 +1720,7 @@ def __init__( :keyword capacity: The sku capacity. :paramtype capacity: int """ - super(Sku, self).__init__(**kwargs) + super().__init__(**kwargs) self.name = name self.tier = tier self.size = size @@ -1829,7 +1729,7 @@ def __init__( self.capacity = capacity -class SubResource(msrest.serialization.Model): +class SubResource(_serialization.Model): """SubResource. :ivar id: Resource Id. @@ -1837,24 +1737,19 @@ class SubResource(msrest.serialization.Model): """ _attribute_map = { - 'id': {'key': 'id', 'type': 'str'}, + "id": {"key": "id", "type": "str"}, } - def __init__( - self, - *, - id: Optional[str] = None, - **kwargs - ): + def __init__(self, *, id: Optional[str] = None, **kwargs): # pylint: disable=redefined-builtin """ :keyword id: Resource Id. :paramtype id: str """ - super(SubResource, self).__init__(**kwargs) + super().__init__(**kwargs) self.id = id -class TagCount(msrest.serialization.Model): +class TagCount(_serialization.Model): """Tag count. :ivar type: Type of count. @@ -1864,29 +1759,23 @@ class TagCount(msrest.serialization.Model): """ _attribute_map = { - 'type': {'key': 'type', 'type': 'str'}, - 'value': {'key': 'value', 'type': 'str'}, + "type": {"key": "type", "type": "str"}, + "value": {"key": "value", "type": "str"}, } - def __init__( - self, - *, - type: Optional[str] = None, - value: Optional[str] = None, - **kwargs - ): + def __init__(self, *, type: Optional[str] = None, value: Optional[str] = None, **kwargs): """ :keyword type: Type of count. :paramtype type: str :keyword value: Value of count. :paramtype value: str """ - super(TagCount, self).__init__(**kwargs) + super().__init__(**kwargs) self.type = type self.value = value -class TagDetails(msrest.serialization.Model): +class TagDetails(_serialization.Model): """Tag details. Variables are only populated by the server, and will be ignored when sending a request. @@ -1902,22 +1791,22 @@ class TagDetails(msrest.serialization.Model): """ _validation = { - 'id': {'readonly': True}, + "id": {"readonly": True}, } _attribute_map = { - 'id': {'key': 'id', 'type': 'str'}, - 'tag_name': {'key': 'tagName', 'type': 'str'}, - 'count': {'key': 'count', 'type': 'TagCount'}, - 'values': {'key': 'values', 'type': '[TagValue]'}, + "id": {"key": "id", "type": "str"}, + "tag_name": {"key": "tagName", "type": "str"}, + "count": {"key": "count", "type": "TagCount"}, + "values": {"key": "values", "type": "[TagValue]"}, } def __init__( self, *, tag_name: Optional[str] = None, - count: Optional["TagCount"] = None, - values: Optional[List["TagValue"]] = None, + count: Optional["_models.TagCount"] = None, + values: Optional[List["_models.TagValue"]] = None, **kwargs ): """ @@ -1928,52 +1817,46 @@ def __init__( :keyword values: The list of tag values. :paramtype values: list[~azure.mgmt.resource.resources.v2016_02_01.models.TagValue] """ - super(TagDetails, self).__init__(**kwargs) + super().__init__(**kwargs) self.id = None self.tag_name = tag_name self.count = count self.values = values -class TagsListResult(msrest.serialization.Model): +class TagsListResult(_serialization.Model): """List of subscription tags. All required parameters must be populated in order to send to Azure. :ivar value: The list of tags. :vartype value: list[~azure.mgmt.resource.resources.v2016_02_01.models.TagDetails] - :ivar next_link: Required. The URL to get the next set of results. + :ivar next_link: The URL to get the next set of results. Required. :vartype next_link: str """ _validation = { - 'next_link': {'required': True}, + "next_link": {"required": True}, } _attribute_map = { - 'value': {'key': 'value', 'type': '[TagDetails]'}, - 'next_link': {'key': 'nextLink', 'type': 'str'}, + "value": {"key": "value", "type": "[TagDetails]"}, + "next_link": {"key": "nextLink", "type": "str"}, } - def __init__( - self, - *, - next_link: str, - value: Optional[List["TagDetails"]] = None, - **kwargs - ): + def __init__(self, *, next_link: str, value: Optional[List["_models.TagDetails"]] = None, **kwargs): """ :keyword value: The list of tags. :paramtype value: list[~azure.mgmt.resource.resources.v2016_02_01.models.TagDetails] - :keyword next_link: Required. The URL to get the next set of results. + :keyword next_link: The URL to get the next set of results. Required. :paramtype next_link: str """ - super(TagsListResult, self).__init__(**kwargs) + super().__init__(**kwargs) self.value = value self.next_link = next_link -class TagValue(msrest.serialization.Model): +class TagValue(_serialization.Model): """Tag information. Variables are only populated by the server, and will be ignored when sending a request. @@ -1987,35 +1870,29 @@ class TagValue(msrest.serialization.Model): """ _validation = { - 'id': {'readonly': True}, + "id": {"readonly": True}, } _attribute_map = { - 'id': {'key': 'id', 'type': 'str'}, - 'tag_value': {'key': 'tagValue', 'type': 'str'}, - 'count': {'key': 'count', 'type': 'TagCount'}, + "id": {"key": "id", "type": "str"}, + "tag_value": {"key": "tagValue", "type": "str"}, + "count": {"key": "count", "type": "TagCount"}, } - def __init__( - self, - *, - tag_value: Optional[str] = None, - count: Optional["TagCount"] = None, - **kwargs - ): + def __init__(self, *, tag_value: Optional[str] = None, count: Optional["_models.TagCount"] = None, **kwargs): """ :keyword tag_value: The tag value. :paramtype tag_value: str :keyword count: The tag value count. :paramtype count: ~azure.mgmt.resource.resources.v2016_02_01.models.TagCount """ - super(TagValue, self).__init__(**kwargs) + super().__init__(**kwargs) self.id = None self.tag_value = tag_value self.count = count -class TargetResource(msrest.serialization.Model): +class TargetResource(_serialization.Model): """Target resource. :ivar id: The ID of the resource. @@ -2027,15 +1904,15 @@ class TargetResource(msrest.serialization.Model): """ _attribute_map = { - 'id': {'key': 'id', 'type': 'str'}, - 'resource_name': {'key': 'resourceName', 'type': 'str'}, - 'resource_type': {'key': 'resourceType', 'type': 'str'}, + "id": {"key": "id", "type": "str"}, + "resource_name": {"key": "resourceName", "type": "str"}, + "resource_type": {"key": "resourceType", "type": "str"}, } def __init__( self, *, - id: Optional[str] = None, + id: Optional[str] = None, # pylint: disable=redefined-builtin resource_name: Optional[str] = None, resource_type: Optional[str] = None, **kwargs @@ -2048,13 +1925,13 @@ def __init__( :keyword resource_type: The type of the resource. :paramtype resource_type: str """ - super(TargetResource, self).__init__(**kwargs) + super().__init__(**kwargs) self.id = id self.resource_name = resource_name self.resource_type = resource_type -class TemplateHashResult(msrest.serialization.Model): +class TemplateHashResult(_serialization.Model): """Result of the request to calculate template hash. It contains a string of minified template and its hash. :ivar minified_template: The minified template string. @@ -2064,61 +1941,49 @@ class TemplateHashResult(msrest.serialization.Model): """ _attribute_map = { - 'minified_template': {'key': 'minifiedTemplate', 'type': 'str'}, - 'template_hash': {'key': 'templateHash', 'type': 'str'}, + "minified_template": {"key": "minifiedTemplate", "type": "str"}, + "template_hash": {"key": "templateHash", "type": "str"}, } - def __init__( - self, - *, - minified_template: Optional[str] = None, - template_hash: Optional[str] = None, - **kwargs - ): + def __init__(self, *, minified_template: Optional[str] = None, template_hash: Optional[str] = None, **kwargs): """ :keyword minified_template: The minified template string. :paramtype minified_template: str :keyword template_hash: The template hash. :paramtype template_hash: str """ - super(TemplateHashResult, self).__init__(**kwargs) + super().__init__(**kwargs) self.minified_template = minified_template self.template_hash = template_hash -class TemplateLink(msrest.serialization.Model): +class TemplateLink(_serialization.Model): """Entity representing the reference to the template. All required parameters must be populated in order to send to Azure. - :ivar uri: Required. URI referencing the template. + :ivar uri: URI referencing the template. Required. :vartype uri: str :ivar content_version: If included it must match the ContentVersion in the template. :vartype content_version: str """ _validation = { - 'uri': {'required': True}, + "uri": {"required": True}, } _attribute_map = { - 'uri': {'key': 'uri', 'type': 'str'}, - 'content_version': {'key': 'contentVersion', 'type': 'str'}, + "uri": {"key": "uri", "type": "str"}, + "content_version": {"key": "contentVersion", "type": "str"}, } - def __init__( - self, - *, - uri: str, - content_version: Optional[str] = None, - **kwargs - ): + def __init__(self, *, uri: str, content_version: Optional[str] = None, **kwargs): """ - :keyword uri: Required. URI referencing the template. + :keyword uri: URI referencing the template. Required. :paramtype uri: str :keyword content_version: If included it must match the ContentVersion in the template. :paramtype content_version: str """ - super(TemplateLink, self).__init__(**kwargs) + super().__init__(**kwargs) self.uri = uri self.content_version = content_version diff --git a/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/resources/v2016_02_01/models/_patch.py b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/resources/v2016_02_01/models/_patch.py new file mode 100644 index 0000000000000..f7dd32510333d --- /dev/null +++ b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/resources/v2016_02_01/models/_patch.py @@ -0,0 +1,20 @@ +# ------------------------------------ +# Copyright (c) Microsoft Corporation. +# Licensed under the MIT License. +# ------------------------------------ +"""Customize generated code here. + +Follow our quickstart for examples: https://aka.ms/azsdk/python/dpcodegen/python/customize +""" +from typing import List + +__all__: List[str] = [] # Add all objects you want publicly available to users at this package level + + +def patch_sdk(): + """Do not remove from this file. + + `patch_sdk` is a last resort escape hatch that allows you to do customizations + you can't accomplish using the techniques described in + https://aka.ms/azsdk/python/dpcodegen/python/customize + """ diff --git a/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/resources/v2016_02_01/models/_resource_management_client_enums.py b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/resources/v2016_02_01/models/_resource_management_client_enums.py index b78febf5720e4..b44e25c0f2bd9 100644 --- a/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/resources/v2016_02_01/models/_resource_management_client_enums.py +++ b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/resources/v2016_02_01/models/_resource_management_client_enums.py @@ -7,13 +7,11 @@ # -------------------------------------------------------------------------- from enum import Enum -from six import with_metaclass from azure.core import CaseInsensitiveEnumMeta -class DeploymentMode(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): - """The deployment mode. - """ +class DeploymentMode(str, Enum, metaclass=CaseInsensitiveEnumMeta): + """The deployment mode.""" INCREMENTAL = "Incremental" COMPLETE = "Complete" diff --git a/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/resources/v2016_02_01/operations/__init__.py b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/resources/v2016_02_01/operations/__init__.py index ad38d1291a450..ada6e7edc9b2c 100644 --- a/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/resources/v2016_02_01/operations/__init__.py +++ b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/resources/v2016_02_01/operations/__init__.py @@ -13,11 +13,17 @@ from ._operations import TagsOperations from ._operations import DeploymentOperationsOperations +from ._patch import __all__ as _patch_all +from ._patch import * # type: ignore # pylint: disable=unused-wildcard-import +from ._patch import patch_sdk as _patch_sdk + __all__ = [ - 'DeploymentsOperations', - 'ProvidersOperations', - 'ResourceGroupsOperations', - 'ResourcesOperations', - 'TagsOperations', - 'DeploymentOperationsOperations', + "DeploymentsOperations", + "ProvidersOperations", + "ResourceGroupsOperations", + "ResourcesOperations", + "TagsOperations", + "DeploymentOperationsOperations", ] +__all__.extend([p for p in _patch_all if p not in __all__]) +_patch_sdk() diff --git a/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/resources/v2016_02_01/operations/_operations.py b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/resources/v2016_02_01/operations/_operations.py index 9ec120eebe650..2ca881a401e2c 100644 --- a/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/resources/v2016_02_01/operations/_operations.py +++ b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/resources/v2016_02_01/operations/_operations.py @@ -6,277 +6,261 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -from typing import Any, Callable, Dict, Iterable, Optional, TypeVar, Union - -from msrest import Serializer - -from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error +import sys +from typing import Any, Callable, Dict, IO, Iterable, Optional, TypeVar, Union, cast, overload +from urllib.parse import parse_qs, urljoin, urlparse + +from azure.core.exceptions import ( + ClientAuthenticationError, + HttpResponseError, + ResourceExistsError, + ResourceNotFoundError, + ResourceNotModifiedError, + map_error, +) from azure.core.paging import ItemPaged from azure.core.pipeline import PipelineResponse from azure.core.pipeline.transport import HttpResponse from azure.core.polling import LROPoller, NoPolling, PollingMethod from azure.core.rest import HttpRequest from azure.core.tracing.decorator import distributed_trace +from azure.core.utils import case_insensitive_dict from azure.mgmt.core.exceptions import ARMErrorFormat from azure.mgmt.core.polling.arm_polling import ARMPolling from .. import models as _models +from ..._serialization import Serializer from .._vendor import _convert_request, _format_url_section -T = TypeVar('T') -JSONType = Any + +if sys.version_info >= (3, 9): + from collections.abc import MutableMapping +else: + from typing import MutableMapping # type: ignore # pylint: disable=ungrouped-imports +JSON = MutableMapping[str, Any] # pylint: disable=unsubscriptable-object +T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] _SERIALIZER = Serializer() _SERIALIZER.client_side_validation = False -def build_deployments_delete_request_initial( - resource_group_name: str, - deployment_name: str, - subscription_id: str, - **kwargs: Any + +def build_deployments_delete_request( + resource_group_name: str, deployment_name: str, subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2016-02-01") # type: str + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + api_version = kwargs.pop("api_version", _params.pop("api-version", "2016-02-01")) # type: str # Construct URL - _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/Microsoft.Resources/deployments/{deploymentName}") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/Microsoft.Resources/deployments/{deploymentName}", + ) # pylint: disable=line-too-long path_format_arguments = { - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._\(\)]+$'), - "deploymentName": _SERIALIZER.url("deployment_name", deployment_name, 'str'), - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), + "resourceGroupName": _SERIALIZER.url( + "resource_group_name", resource_group_name, "str", max_length=90, min_length=1, pattern=r"^[-\w\._\(\)]+$" + ), + "deploymentName": _SERIALIZER.url("deployment_name", deployment_name, "str"), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), } _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') - - return HttpRequest( - method="DELETE", - url=_url, - params=_query_parameters, - **kwargs - ) + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") + + return HttpRequest(method="DELETE", url=_url, params=_params, **kwargs) def build_deployments_check_existence_request( - resource_group_name: str, - deployment_name: str, - subscription_id: str, - **kwargs: Any + resource_group_name: str, deployment_name: str, subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2016-02-01") # type: str + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + api_version = kwargs.pop("api_version", _params.pop("api-version", "2016-02-01")) # type: str # Construct URL - _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/Microsoft.Resources/deployments/{deploymentName}") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/Microsoft.Resources/deployments/{deploymentName}", + ) # pylint: disable=line-too-long path_format_arguments = { - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._\(\)]+$'), - "deploymentName": _SERIALIZER.url("deployment_name", deployment_name, 'str'), - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), + "resourceGroupName": _SERIALIZER.url( + "resource_group_name", resource_group_name, "str", max_length=90, min_length=1, pattern=r"^[-\w\._\(\)]+$" + ), + "deploymentName": _SERIALIZER.url("deployment_name", deployment_name, "str"), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), } _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') - - return HttpRequest( - method="HEAD", - url=_url, - params=_query_parameters, - **kwargs - ) + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") + return HttpRequest(method="HEAD", url=_url, params=_params, **kwargs) -def build_deployments_create_or_update_request_initial( - resource_group_name: str, - deployment_name: str, - subscription_id: str, - *, - json: JSONType = None, - content: Any = None, - **kwargs: Any + +def build_deployments_create_or_update_request( + resource_group_name: str, deployment_name: str, subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2016-02-01") # type: str - content_type = kwargs.pop('content_type', None) # type: Optional[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", "2016-02-01")) # type: str + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + accept = _headers.pop("Accept", "application/json") - accept = "application/json" # Construct URL - _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/Microsoft.Resources/deployments/{deploymentName}") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/Microsoft.Resources/deployments/{deploymentName}", + ) # pylint: disable=line-too-long path_format_arguments = { - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._\(\)]+$'), - "deploymentName": _SERIALIZER.url("deployment_name", deployment_name, 'str'), - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), + "resourceGroupName": _SERIALIZER.url( + "resource_group_name", resource_group_name, "str", max_length=90, min_length=1, pattern=r"^[-\w\._\(\)]+$" + ), + "deploymentName": _SERIALIZER.url("deployment_name", deployment_name, "str"), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), } _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] if content_type is not None: - _header_parameters['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') - _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') - - return HttpRequest( - method="PUT", - url=_url, - params=_query_parameters, - headers=_header_parameters, - json=json, - content=content, - **kwargs - ) + _headers["Content-Type"] = _SERIALIZER.header("content_type", content_type, "str") + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="PUT", url=_url, params=_params, headers=_headers, **kwargs) def build_deployments_get_request( - resource_group_name: str, - deployment_name: str, - subscription_id: str, - **kwargs: Any + resource_group_name: str, deployment_name: str, subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2016-02-01") # type: 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", "2016-02-01")) # type: str + accept = _headers.pop("Accept", "application/json") - accept = "application/json" # Construct URL - _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/Microsoft.Resources/deployments/{deploymentName}") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/Microsoft.Resources/deployments/{deploymentName}", + ) # pylint: disable=line-too-long path_format_arguments = { - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._\(\)]+$'), - "deploymentName": _SERIALIZER.url("deployment_name", deployment_name, 'str'), - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), + "resourceGroupName": _SERIALIZER.url( + "resource_group_name", resource_group_name, "str", max_length=90, min_length=1, pattern=r"^[-\w\._\(\)]+$" + ), + "deploymentName": _SERIALIZER.url("deployment_name", deployment_name, "str"), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), } _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') - - return HttpRequest( - method="GET", - url=_url, - params=_query_parameters, - headers=_header_parameters, - **kwargs - ) + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) def build_deployments_cancel_request( - resource_group_name: str, - deployment_name: str, - subscription_id: str, - **kwargs: Any + resource_group_name: str, deployment_name: str, subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2016-02-01") # type: str + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + api_version = kwargs.pop("api_version", _params.pop("api-version", "2016-02-01")) # type: str # Construct URL - _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/Microsoft.Resources/deployments/{deploymentName}/cancel") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/Microsoft.Resources/deployments/{deploymentName}/cancel", + ) # pylint: disable=line-too-long path_format_arguments = { - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._\(\)]+$'), - "deploymentName": _SERIALIZER.url("deployment_name", deployment_name, 'str'), - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), + "resourceGroupName": _SERIALIZER.url( + "resource_group_name", resource_group_name, "str", max_length=90, min_length=1, pattern=r"^[-\w\._\(\)]+$" + ), + "deploymentName": _SERIALIZER.url("deployment_name", deployment_name, "str"), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), } _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') - - return HttpRequest( - method="POST", - url=_url, - params=_query_parameters, - **kwargs - ) + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") + + return HttpRequest(method="POST", url=_url, params=_params, **kwargs) def build_deployments_validate_request( - resource_group_name: str, - deployment_name: str, - subscription_id: str, - *, - json: JSONType = None, - content: Any = None, - **kwargs: Any + resource_group_name: str, deployment_name: str, subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2016-02-01") # type: str - content_type = kwargs.pop('content_type', None) # type: Optional[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", "2016-02-01")) # type: str + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + accept = _headers.pop("Accept", "application/json") - accept = "application/json" # Construct URL - _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/Microsoft.Resources/deployments/{deploymentName}/validate") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/Microsoft.Resources/deployments/{deploymentName}/validate", + ) # pylint: disable=line-too-long path_format_arguments = { - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._\(\)]+$'), - "deploymentName": _SERIALIZER.url("deployment_name", deployment_name, 'str'), - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), + "resourceGroupName": _SERIALIZER.url( + "resource_group_name", resource_group_name, "str", max_length=90, min_length=1, pattern=r"^[-\w\._\(\)]+$" + ), + "deploymentName": _SERIALIZER.url("deployment_name", deployment_name, "str"), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), } _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] if content_type is not None: - _header_parameters['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') - _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') - - return HttpRequest( - method="POST", - url=_url, - params=_query_parameters, - headers=_header_parameters, - json=json, - content=content, - **kwargs - ) + _headers["Content-Type"] = _SERIALIZER.header("content_type", content_type, "str") + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="POST", url=_url, params=_params, headers=_headers, **kwargs) def build_deployments_export_template_request( - resource_group_name: str, - deployment_name: str, - subscription_id: str, - **kwargs: Any + resource_group_name: str, deployment_name: str, subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2016-02-01") # type: 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", "2016-02-01")) # type: str + accept = _headers.pop("Accept", "application/json") - accept = "application/json" # Construct URL - _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/Microsoft.Resources/deployments/{deploymentName}/exportTemplate") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/Microsoft.Resources/deployments/{deploymentName}/exportTemplate", + ) # pylint: disable=line-too-long path_format_arguments = { - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._\(\)]+$'), - "deploymentName": _SERIALIZER.url("deployment_name", deployment_name, 'str'), - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), + "resourceGroupName": _SERIALIZER.url( + "resource_group_name", resource_group_name, "str", max_length=90, min_length=1, pattern=r"^[-\w\._\(\)]+$" + ), + "deploymentName": _SERIALIZER.url("deployment_name", deployment_name, "str"), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), } _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') - - return HttpRequest( - method="POST", - url=_url, - params=_query_parameters, - headers=_header_parameters, - **kwargs - ) + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="POST", url=_url, params=_params, headers=_headers, **kwargs) def build_deployments_list_request( @@ -287,216 +271,174 @@ def build_deployments_list_request( top: Optional[int] = None, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2016-02-01") # type: 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", "2016-02-01")) # type: str + accept = _headers.pop("Accept", "application/json") - accept = "application/json" # Construct URL - _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/Microsoft.Resources/deployments/") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/Microsoft.Resources/deployments/", + ) # pylint: disable=line-too-long path_format_arguments = { - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._\(\)]+$'), - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), + "resourceGroupName": _SERIALIZER.url( + "resource_group_name", resource_group_name, "str", max_length=90, min_length=1, pattern=r"^[-\w\._\(\)]+$" + ), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), } _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] if filter is not None: - _query_parameters['$filter'] = _SERIALIZER.query("filter", filter, 'str') + _params["$filter"] = _SERIALIZER.query("filter", filter, "str") if top is not None: - _query_parameters['$top'] = _SERIALIZER.query("top", top, 'int') - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["$top"] = _SERIALIZER.query("top", top, "int") + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') - - return HttpRequest( - method="GET", - url=_url, - params=_query_parameters, - headers=_header_parameters, - **kwargs - ) + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) -def build_deployments_calculate_template_hash_request( - *, - json: JSONType = None, - content: Any = None, - **kwargs: Any -) -> HttpRequest: - api_version = kwargs.pop('api_version', "2016-02-01") # type: str - content_type = kwargs.pop('content_type', None) # type: Optional[str] - accept = "application/json" +def build_deployments_calculate_template_hash_request(*, json: JSON, **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", "2016-02-01")) # type: str + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + accept = _headers.pop("Accept", "application/json") + # Construct URL _url = kwargs.pop("template_url", "/providers/Microsoft.Resources/calculateTemplateHash") # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] if content_type is not None: - _header_parameters['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') - _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') - - return HttpRequest( - method="POST", - url=_url, - params=_query_parameters, - headers=_header_parameters, - json=json, - content=content, - **kwargs - ) + _headers["Content-Type"] = _SERIALIZER.header("content_type", content_type, "str") + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="POST", url=_url, params=_params, headers=_headers, json=json, **kwargs) def build_providers_unregister_request( - resource_provider_namespace: str, - subscription_id: str, - **kwargs: Any + resource_provider_namespace: str, subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2016-02-01") # type: 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", "2016-02-01")) # type: str + accept = _headers.pop("Accept", "application/json") - accept = "application/json" # Construct URL - _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/providers/{resourceProviderNamespace}/unregister") + _url = kwargs.pop( + "template_url", "/subscriptions/{subscriptionId}/providers/{resourceProviderNamespace}/unregister" + ) path_format_arguments = { - "resourceProviderNamespace": _SERIALIZER.url("resource_provider_namespace", resource_provider_namespace, 'str'), - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), + "resourceProviderNamespace": _SERIALIZER.url("resource_provider_namespace", resource_provider_namespace, "str"), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), } _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') - - return HttpRequest( - method="POST", - url=_url, - params=_query_parameters, - headers=_header_parameters, - **kwargs - ) + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="POST", url=_url, params=_params, headers=_headers, **kwargs) def build_providers_register_request( - resource_provider_namespace: str, - subscription_id: str, - **kwargs: Any + resource_provider_namespace: str, subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2016-02-01") # type: 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", "2016-02-01")) # type: str + accept = _headers.pop("Accept", "application/json") - accept = "application/json" # Construct URL _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/providers/{resourceProviderNamespace}/register") path_format_arguments = { - "resourceProviderNamespace": _SERIALIZER.url("resource_provider_namespace", resource_provider_namespace, 'str'), - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), + "resourceProviderNamespace": _SERIALIZER.url("resource_provider_namespace", resource_provider_namespace, "str"), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), } _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') - - return HttpRequest( - method="POST", - url=_url, - params=_query_parameters, - headers=_header_parameters, - **kwargs - ) + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="POST", url=_url, params=_params, headers=_headers, **kwargs) def build_providers_list_request( - subscription_id: str, - *, - top: Optional[int] = None, - expand: Optional[str] = None, - **kwargs: Any + subscription_id: str, *, top: Optional[int] = None, expand: Optional[str] = None, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2016-02-01") # type: 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", "2016-02-01")) # type: str + accept = _headers.pop("Accept", "application/json") - accept = "application/json" # Construct URL _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/providers") path_format_arguments = { - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), } _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] if top is not None: - _query_parameters['$top'] = _SERIALIZER.query("top", top, 'int') + _params["$top"] = _SERIALIZER.query("top", top, "int") if expand is not None: - _query_parameters['$expand'] = _SERIALIZER.query("expand", expand, 'str') - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["$expand"] = _SERIALIZER.query("expand", expand, "str") + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') - - return HttpRequest( - method="GET", - url=_url, - params=_query_parameters, - headers=_header_parameters, - **kwargs - ) + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) def build_providers_get_request( - resource_provider_namespace: str, - subscription_id: str, - *, - expand: Optional[str] = None, - **kwargs: Any + resource_provider_namespace: str, subscription_id: str, *, expand: Optional[str] = None, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2016-02-01") # type: 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", "2016-02-01")) # type: str + accept = _headers.pop("Accept", "application/json") - accept = "application/json" # Construct URL _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/providers/{resourceProviderNamespace}") path_format_arguments = { - "resourceProviderNamespace": _SERIALIZER.url("resource_provider_namespace", resource_provider_namespace, 'str'), - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), + "resourceProviderNamespace": _SERIALIZER.url("resource_provider_namespace", resource_provider_namespace, "str"), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), } _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] if expand is not None: - _query_parameters['$expand'] = _SERIALIZER.query("expand", expand, 'str') - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["$expand"] = _SERIALIZER.query("expand", expand, "str") + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') - - return HttpRequest( - method="GET", - url=_url, - params=_query_parameters, - headers=_header_parameters, - **kwargs - ) + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) def build_resource_groups_list_resources_request( @@ -508,334 +450,269 @@ def build_resource_groups_list_resources_request( top: Optional[int] = None, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2016-02-01") # type: 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", "2016-02-01")) # type: str + accept = _headers.pop("Accept", "application/json") - accept = "application/json" # Construct URL _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/resources") path_format_arguments = { - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._\(\)]+$'), - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), + "resourceGroupName": _SERIALIZER.url( + "resource_group_name", resource_group_name, "str", max_length=90, min_length=1, pattern=r"^[-\w\._\(\)]+$" + ), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), } _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] if filter is not None: - _query_parameters['$filter'] = _SERIALIZER.query("filter", filter, 'str') + _params["$filter"] = _SERIALIZER.query("filter", filter, "str") if expand is not None: - _query_parameters['$expand'] = _SERIALIZER.query("expand", expand, 'str') + _params["$expand"] = _SERIALIZER.query("expand", expand, "str") if top is not None: - _query_parameters['$top'] = _SERIALIZER.query("top", top, 'int') - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["$top"] = _SERIALIZER.query("top", top, "int") + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') - - return HttpRequest( - method="GET", - url=_url, - params=_query_parameters, - headers=_header_parameters, - **kwargs - ) + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) def build_resource_groups_check_existence_request( - resource_group_name: str, - subscription_id: str, - **kwargs: Any + resource_group_name: str, subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2016-02-01") # type: str + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + api_version = kwargs.pop("api_version", _params.pop("api-version", "2016-02-01")) # type: str # Construct URL _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}") path_format_arguments = { - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._\(\)]+$'), - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), + "resourceGroupName": _SERIALIZER.url( + "resource_group_name", resource_group_name, "str", max_length=90, min_length=1, pattern=r"^[-\w\._\(\)]+$" + ), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), } _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') - - return HttpRequest( - method="HEAD", - url=_url, - params=_query_parameters, - **kwargs - ) + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") + + return HttpRequest(method="HEAD", url=_url, params=_params, **kwargs) def build_resource_groups_create_or_update_request( - resource_group_name: str, - subscription_id: str, - *, - json: JSONType = None, - content: Any = None, - **kwargs: Any + resource_group_name: str, subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2016-02-01") # type: str - content_type = kwargs.pop('content_type', None) # type: Optional[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", "2016-02-01")) # type: str + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + accept = _headers.pop("Accept", "application/json") - accept = "application/json" # Construct URL _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}") path_format_arguments = { - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._\(\)]+$'), - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), + "resourceGroupName": _SERIALIZER.url( + "resource_group_name", resource_group_name, "str", max_length=90, min_length=1, pattern=r"^[-\w\._\(\)]+$" + ), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), } _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] if content_type is not None: - _header_parameters['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') - _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') - - return HttpRequest( - method="PUT", - url=_url, - params=_query_parameters, - headers=_header_parameters, - json=json, - content=content, - **kwargs - ) + _headers["Content-Type"] = _SERIALIZER.header("content_type", content_type, "str") + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + return HttpRequest(method="PUT", url=_url, params=_params, headers=_headers, **kwargs) -def build_resource_groups_delete_request_initial( - resource_group_name: str, - subscription_id: str, - **kwargs: Any -) -> HttpRequest: - api_version = kwargs.pop('api_version', "2016-02-01") # type: str +def build_resource_groups_delete_request(resource_group_name: str, subscription_id: str, **kwargs: Any) -> HttpRequest: + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2016-02-01")) # type: str # Construct URL _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}") path_format_arguments = { - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._\(\)]+$'), - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), + "resourceGroupName": _SERIALIZER.url( + "resource_group_name", resource_group_name, "str", max_length=90, min_length=1, pattern=r"^[-\w\._\(\)]+$" + ), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), } _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') - - return HttpRequest( - method="DELETE", - url=_url, - params=_query_parameters, - **kwargs - ) + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") + return HttpRequest(method="DELETE", url=_url, params=_params, **kwargs) -def build_resource_groups_get_request( - resource_group_name: str, - subscription_id: str, - **kwargs: Any -) -> HttpRequest: - api_version = kwargs.pop('api_version', "2016-02-01") # type: str - accept = "application/json" +def build_resource_groups_get_request(resource_group_name: str, subscription_id: str, **kwargs: Any) -> HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2016-02-01")) # type: str + accept = _headers.pop("Accept", "application/json") + # Construct URL _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}") path_format_arguments = { - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._\(\)]+$'), - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), + "resourceGroupName": _SERIALIZER.url( + "resource_group_name", resource_group_name, "str", max_length=90, min_length=1, pattern=r"^[-\w\._\(\)]+$" + ), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), } _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') - - return HttpRequest( - method="GET", - url=_url, - params=_query_parameters, - headers=_header_parameters, - **kwargs - ) + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) -def build_resource_groups_patch_request( - resource_group_name: str, - subscription_id: str, - *, - json: JSONType = None, - content: Any = None, - **kwargs: Any -) -> HttpRequest: - api_version = kwargs.pop('api_version', "2016-02-01") # type: str - content_type = kwargs.pop('content_type', None) # type: Optional[str] - accept = "application/json" +def build_resource_groups_patch_request(resource_group_name: str, subscription_id: str, **kwargs: Any) -> HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2016-02-01")) # type: str + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + accept = _headers.pop("Accept", "application/json") + # Construct URL _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}") path_format_arguments = { - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._\(\)]+$'), - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), + "resourceGroupName": _SERIALIZER.url( + "resource_group_name", resource_group_name, "str", max_length=90, min_length=1, pattern=r"^[-\w\._\(\)]+$" + ), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), } _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] if content_type is not None: - _header_parameters['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') - _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') - - return HttpRequest( - method="PATCH", - url=_url, - params=_query_parameters, - headers=_header_parameters, - json=json, - content=content, - **kwargs - ) + _headers["Content-Type"] = _SERIALIZER.header("content_type", content_type, "str") + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="PATCH", url=_url, params=_params, headers=_headers, **kwargs) def build_resource_groups_export_template_request( - resource_group_name: str, - subscription_id: str, - *, - json: JSONType = None, - content: Any = None, - **kwargs: Any + resource_group_name: str, subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2016-02-01") # type: str - content_type = kwargs.pop('content_type', None) # type: Optional[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", "2016-02-01")) # type: str + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + accept = _headers.pop("Accept", "application/json") - accept = "application/json" # Construct URL - _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/exportTemplate") + _url = kwargs.pop( + "template_url", "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/exportTemplate" + ) path_format_arguments = { - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._\(\)]+$'), - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), + "resourceGroupName": _SERIALIZER.url( + "resource_group_name", resource_group_name, "str", max_length=90, min_length=1, pattern=r"^[-\w\._\(\)]+$" + ), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), } _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] if content_type is not None: - _header_parameters['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') - _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') - - return HttpRequest( - method="POST", - url=_url, - params=_query_parameters, - headers=_header_parameters, - json=json, - content=content, - **kwargs - ) + _headers["Content-Type"] = _SERIALIZER.header("content_type", content_type, "str") + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="POST", url=_url, params=_params, headers=_headers, **kwargs) def build_resource_groups_list_request( - subscription_id: str, - *, - filter: Optional[str] = None, - top: Optional[int] = None, - **kwargs: Any + subscription_id: str, *, filter: Optional[str] = None, top: Optional[int] = None, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2016-02-01") # type: 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", "2016-02-01")) # type: str + accept = _headers.pop("Accept", "application/json") - accept = "application/json" # Construct URL _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourcegroups") path_format_arguments = { - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), } _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] if filter is not None: - _query_parameters['$filter'] = _SERIALIZER.query("filter", filter, 'str') + _params["$filter"] = _SERIALIZER.query("filter", filter, "str") if top is not None: - _query_parameters['$top'] = _SERIALIZER.query("top", top, 'int') - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["$top"] = _SERIALIZER.query("top", top, "int") + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') - - return HttpRequest( - method="GET", - url=_url, - params=_query_parameters, - headers=_header_parameters, - **kwargs - ) + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) -def build_resources_move_resources_request_initial( - source_resource_group_name: str, - subscription_id: str, - *, - json: JSONType = None, - content: Any = None, - **kwargs: Any + +def build_resources_move_resources_request( + source_resource_group_name: str, subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2016-02-01") # type: str - content_type = kwargs.pop('content_type', None) # type: Optional[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", "2016-02-01")) # type: str + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] # Construct URL - _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{sourceResourceGroupName}/moveResources") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", "/subscriptions/{subscriptionId}/resourceGroups/{sourceResourceGroupName}/moveResources" + ) # pylint: disable=line-too-long path_format_arguments = { - "sourceResourceGroupName": _SERIALIZER.url("source_resource_group_name", source_resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._\(\)]+$'), - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), + "sourceResourceGroupName": _SERIALIZER.url( + "source_resource_group_name", + source_resource_group_name, + "str", + max_length=90, + min_length=1, + pattern=r"^[-\w\._\(\)]+$", + ), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), } _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] if content_type is not None: - _header_parameters['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') - - return HttpRequest( - method="POST", - url=_url, - params=_query_parameters, - headers=_header_parameters, - json=json, - content=content, - **kwargs - ) + _headers["Content-Type"] = _SERIALIZER.header("content_type", content_type, "str") + + return HttpRequest(method="POST", url=_url, params=_params, headers=_headers, **kwargs) def build_resources_list_request( @@ -846,38 +723,33 @@ def build_resources_list_request( top: Optional[int] = None, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2016-02-01") # type: 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", "2016-02-01")) # type: str + accept = _headers.pop("Accept", "application/json") - accept = "application/json" # Construct URL _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resources") path_format_arguments = { - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), } _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] if filter is not None: - _query_parameters['$filter'] = _SERIALIZER.query("filter", filter, 'str') + _params["$filter"] = _SERIALIZER.query("filter", filter, "str") if expand is not None: - _query_parameters['$expand'] = _SERIALIZER.query("expand", expand, 'str') + _params["$expand"] = _SERIALIZER.query("expand", expand, "str") if top is not None: - _query_parameters['$top'] = _SERIALIZER.query("top", top, 'int') - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["$top"] = _SERIALIZER.query("top", top, "int") + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') - - return HttpRequest( - method="GET", - url=_url, - params=_query_parameters, - headers=_header_parameters, - **kwargs - ) + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) def build_resources_check_existence_request( @@ -891,29 +763,30 @@ def build_resources_check_existence_request( api_version: str, **kwargs: Any ) -> HttpRequest: + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + # Construct URL - _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{parentResourcePath}/{resourceType}/{resourceName}") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{parentResourcePath}/{resourceType}/{resourceName}", + ) # pylint: disable=line-too-long path_format_arguments = { - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._\(\)]+$'), - "resourceProviderNamespace": _SERIALIZER.url("resource_provider_namespace", resource_provider_namespace, 'str'), - "parentResourcePath": _SERIALIZER.url("parent_resource_path", parent_resource_path, 'str', skip_quote=True), - "resourceType": _SERIALIZER.url("resource_type", resource_type, 'str', skip_quote=True), - "resourceName": _SERIALIZER.url("resource_name", resource_name, 'str'), - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), + "resourceGroupName": _SERIALIZER.url( + "resource_group_name", resource_group_name, "str", max_length=90, min_length=1, pattern=r"^[-\w\._\(\)]+$" + ), + "resourceProviderNamespace": _SERIALIZER.url("resource_provider_namespace", resource_provider_namespace, "str"), + "parentResourcePath": _SERIALIZER.url("parent_resource_path", parent_resource_path, "str", skip_quote=True), + "resourceType": _SERIALIZER.url("resource_type", resource_type, "str", skip_quote=True), + "resourceName": _SERIALIZER.url("resource_name", resource_name, "str"), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), } _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') - - return HttpRequest( - method="HEAD", - url=_url, - params=_query_parameters, - **kwargs - ) + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") + + return HttpRequest(method="HEAD", url=_url, params=_params, **kwargs) def build_resources_delete_request( @@ -927,29 +800,30 @@ def build_resources_delete_request( api_version: str, **kwargs: Any ) -> HttpRequest: + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + # Construct URL - _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{parentResourcePath}/{resourceType}/{resourceName}") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{parentResourcePath}/{resourceType}/{resourceName}", + ) # pylint: disable=line-too-long path_format_arguments = { - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._\(\)]+$'), - "resourceProviderNamespace": _SERIALIZER.url("resource_provider_namespace", resource_provider_namespace, 'str'), - "parentResourcePath": _SERIALIZER.url("parent_resource_path", parent_resource_path, 'str', skip_quote=True), - "resourceType": _SERIALIZER.url("resource_type", resource_type, 'str', skip_quote=True), - "resourceName": _SERIALIZER.url("resource_name", resource_name, 'str'), - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), + "resourceGroupName": _SERIALIZER.url( + "resource_group_name", resource_group_name, "str", max_length=90, min_length=1, pattern=r"^[-\w\._\(\)]+$" + ), + "resourceProviderNamespace": _SERIALIZER.url("resource_provider_namespace", resource_provider_namespace, "str"), + "parentResourcePath": _SERIALIZER.url("parent_resource_path", parent_resource_path, "str", skip_quote=True), + "resourceType": _SERIALIZER.url("resource_type", resource_type, "str", skip_quote=True), + "resourceName": _SERIALIZER.url("resource_name", resource_name, "str"), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), } _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') - - return HttpRequest( - method="DELETE", - url=_url, - params=_query_parameters, - **kwargs - ) + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") + + return HttpRequest(method="DELETE", url=_url, params=_params, **kwargs) def build_resources_create_or_update_request( @@ -961,48 +835,44 @@ def build_resources_create_or_update_request( subscription_id: str, *, api_version: str, - json: JSONType = None, - content: Any = None, **kwargs: Any ) -> HttpRequest: - content_type = kwargs.pop('content_type', None) # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + accept = _headers.pop("Accept", "application/json") - accept = "application/json" # Construct URL - _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{parentResourcePath}/{resourceType}/{resourceName}") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{parentResourcePath}/{resourceType}/{resourceName}", + ) # pylint: disable=line-too-long path_format_arguments = { - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._\(\)]+$'), - "resourceProviderNamespace": _SERIALIZER.url("resource_provider_namespace", resource_provider_namespace, 'str'), - "parentResourcePath": _SERIALIZER.url("parent_resource_path", parent_resource_path, 'str', skip_quote=True), - "resourceType": _SERIALIZER.url("resource_type", resource_type, 'str', skip_quote=True), - "resourceName": _SERIALIZER.url("resource_name", resource_name, 'str'), - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), + "resourceGroupName": _SERIALIZER.url( + "resource_group_name", resource_group_name, "str", max_length=90, min_length=1, pattern=r"^[-\w\._\(\)]+$" + ), + "resourceProviderNamespace": _SERIALIZER.url("resource_provider_namespace", resource_provider_namespace, "str"), + "parentResourcePath": _SERIALIZER.url("parent_resource_path", parent_resource_path, "str", skip_quote=True), + "resourceType": _SERIALIZER.url("resource_type", resource_type, "str", skip_quote=True), + "resourceName": _SERIALIZER.url("resource_name", resource_name, "str"), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), } _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] if content_type is not None: - _header_parameters['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') - _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') - - return HttpRequest( - method="PUT", - url=_url, - params=_query_parameters, - headers=_header_parameters, - json=json, - content=content, - **kwargs - ) + _headers["Content-Type"] = _SERIALIZER.header("content_type", content_type, "str") + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="PUT", url=_url, params=_params, headers=_headers, **kwargs) -def build_resources_update_request_initial( +def build_resources_update_request( resource_group_name: str, resource_provider_namespace: str, parent_resource_path: str, @@ -1011,45 +881,41 @@ def build_resources_update_request_initial( subscription_id: str, *, api_version: str, - json: JSONType = None, - content: Any = None, **kwargs: Any ) -> HttpRequest: - content_type = kwargs.pop('content_type', None) # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + accept = _headers.pop("Accept", "application/json") - accept = "application/json" # Construct URL - _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{parentResourcePath}/{resourceType}/{resourceName}") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{parentResourcePath}/{resourceType}/{resourceName}", + ) # pylint: disable=line-too-long path_format_arguments = { - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._\(\)]+$'), - "resourceProviderNamespace": _SERIALIZER.url("resource_provider_namespace", resource_provider_namespace, 'str'), - "parentResourcePath": _SERIALIZER.url("parent_resource_path", parent_resource_path, 'str', skip_quote=True), - "resourceType": _SERIALIZER.url("resource_type", resource_type, 'str', skip_quote=True), - "resourceName": _SERIALIZER.url("resource_name", resource_name, 'str'), - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), + "resourceGroupName": _SERIALIZER.url( + "resource_group_name", resource_group_name, "str", max_length=90, min_length=1, pattern=r"^[-\w\._\(\)]+$" + ), + "resourceProviderNamespace": _SERIALIZER.url("resource_provider_namespace", resource_provider_namespace, "str"), + "parentResourcePath": _SERIALIZER.url("parent_resource_path", parent_resource_path, "str", skip_quote=True), + "resourceType": _SERIALIZER.url("resource_type", resource_type, "str", skip_quote=True), + "resourceName": _SERIALIZER.url("resource_name", resource_name, "str"), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), } _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] if content_type is not None: - _header_parameters['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') - _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') - - return HttpRequest( - method="PATCH", - url=_url, - params=_query_parameters, - headers=_header_parameters, - json=json, - content=content, - **kwargs - ) + _headers["Content-Type"] = _SERIALIZER.header("content_type", content_type, "str") + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="PATCH", url=_url, params=_params, headers=_headers, **kwargs) def build_resources_get_request( @@ -1063,326 +929,275 @@ def build_resources_get_request( api_version: str, **kwargs: Any ) -> HttpRequest: - accept = "application/json" + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + accept = _headers.pop("Accept", "application/json") + # Construct URL - _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{parentResourcePath}/{resourceType}/{resourceName}") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{parentResourcePath}/{resourceType}/{resourceName}", + ) # pylint: disable=line-too-long path_format_arguments = { - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._\(\)]+$'), - "resourceProviderNamespace": _SERIALIZER.url("resource_provider_namespace", resource_provider_namespace, 'str'), - "parentResourcePath": _SERIALIZER.url("parent_resource_path", parent_resource_path, 'str', skip_quote=True), - "resourceType": _SERIALIZER.url("resource_type", resource_type, 'str', skip_quote=True), - "resourceName": _SERIALIZER.url("resource_name", resource_name, 'str'), - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), + "resourceGroupName": _SERIALIZER.url( + "resource_group_name", resource_group_name, "str", max_length=90, min_length=1, pattern=r"^[-\w\._\(\)]+$" + ), + "resourceProviderNamespace": _SERIALIZER.url("resource_provider_namespace", resource_provider_namespace, "str"), + "parentResourcePath": _SERIALIZER.url("parent_resource_path", parent_resource_path, "str", skip_quote=True), + "resourceType": _SERIALIZER.url("resource_type", resource_type, "str", skip_quote=True), + "resourceName": _SERIALIZER.url("resource_name", resource_name, "str"), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), } _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') - - return HttpRequest( - method="GET", - url=_url, - params=_query_parameters, - headers=_header_parameters, - **kwargs - ) + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) -def build_tags_delete_value_request( - tag_name: str, - tag_value: str, - subscription_id: str, - **kwargs: Any -) -> HttpRequest: - api_version = kwargs.pop('api_version', "2016-02-01") # type: str +def build_tags_delete_value_request(tag_name: str, tag_value: str, subscription_id: str, **kwargs: Any) -> HttpRequest: + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2016-02-01")) # type: str # Construct URL _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/tagNames/{tagName}/tagValues/{tagValue}") path_format_arguments = { - "tagName": _SERIALIZER.url("tag_name", tag_name, 'str'), - "tagValue": _SERIALIZER.url("tag_value", tag_value, 'str'), - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), + "tagName": _SERIALIZER.url("tag_name", tag_name, "str"), + "tagValue": _SERIALIZER.url("tag_value", tag_value, "str"), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), } _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') - - return HttpRequest( - method="DELETE", - url=_url, - params=_query_parameters, - **kwargs - ) + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") + + return HttpRequest(method="DELETE", url=_url, params=_params, **kwargs) def build_tags_create_or_update_value_request( - tag_name: str, - tag_value: str, - subscription_id: str, - **kwargs: Any + tag_name: str, tag_value: str, subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2016-02-01") # type: 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", "2016-02-01")) # type: str + accept = _headers.pop("Accept", "application/json") - accept = "application/json" # Construct URL _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/tagNames/{tagName}/tagValues/{tagValue}") path_format_arguments = { - "tagName": _SERIALIZER.url("tag_name", tag_name, 'str'), - "tagValue": _SERIALIZER.url("tag_value", tag_value, 'str'), - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), + "tagName": _SERIALIZER.url("tag_name", tag_name, "str"), + "tagValue": _SERIALIZER.url("tag_value", tag_value, "str"), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), } _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') - - return HttpRequest( - method="PUT", - url=_url, - params=_query_parameters, - headers=_header_parameters, - **kwargs - ) + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + return HttpRequest(method="PUT", url=_url, params=_params, headers=_headers, **kwargs) -def build_tags_create_or_update_request( - tag_name: str, - subscription_id: str, - **kwargs: Any -) -> HttpRequest: - api_version = kwargs.pop('api_version', "2016-02-01") # type: str - accept = "application/json" +def build_tags_create_or_update_request(tag_name: str, subscription_id: str, **kwargs: Any) -> HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2016-02-01")) # type: str + accept = _headers.pop("Accept", "application/json") + # Construct URL _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/tagNames/{tagName}") path_format_arguments = { - "tagName": _SERIALIZER.url("tag_name", tag_name, 'str'), - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), + "tagName": _SERIALIZER.url("tag_name", tag_name, "str"), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), } _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') - - return HttpRequest( - method="PUT", - url=_url, - params=_query_parameters, - headers=_header_parameters, - **kwargs - ) + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + return HttpRequest(method="PUT", url=_url, params=_params, headers=_headers, **kwargs) -def build_tags_delete_request( - tag_name: str, - subscription_id: str, - **kwargs: Any -) -> HttpRequest: - api_version = kwargs.pop('api_version', "2016-02-01") # type: str +def build_tags_delete_request(tag_name: str, subscription_id: str, **kwargs: Any) -> HttpRequest: + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2016-02-01")) # type: str # Construct URL _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/tagNames/{tagName}") path_format_arguments = { - "tagName": _SERIALIZER.url("tag_name", tag_name, 'str'), - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), + "tagName": _SERIALIZER.url("tag_name", tag_name, "str"), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), } _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') - - return HttpRequest( - method="DELETE", - url=_url, - params=_query_parameters, - **kwargs - ) + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") + return HttpRequest(method="DELETE", url=_url, params=_params, **kwargs) -def build_tags_list_request( - subscription_id: str, - **kwargs: Any -) -> HttpRequest: - api_version = kwargs.pop('api_version', "2016-02-01") # type: str - accept = "application/json" +def build_tags_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", "2016-02-01")) # type: str + accept = _headers.pop("Accept", "application/json") + # Construct URL _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/tagNames") path_format_arguments = { - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), } _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') - - return HttpRequest( - method="GET", - url=_url, - params=_query_parameters, - headers=_header_parameters, - **kwargs - ) + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) def build_deployment_operations_get_request( - resource_group_name: str, - deployment_name: str, - operation_id: str, - subscription_id: str, - **kwargs: Any + resource_group_name: str, deployment_name: str, operation_id: str, subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2016-02-01") # type: 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", "2016-02-01")) # type: str + accept = _headers.pop("Accept", "application/json") - accept = "application/json" # Construct URL - _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/deployments/{deploymentName}/operations/{operationId}") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/deployments/{deploymentName}/operations/{operationId}", + ) # pylint: disable=line-too-long path_format_arguments = { - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._\(\)]+$'), - "deploymentName": _SERIALIZER.url("deployment_name", deployment_name, 'str'), - "operationId": _SERIALIZER.url("operation_id", operation_id, 'str'), - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), + "resourceGroupName": _SERIALIZER.url( + "resource_group_name", resource_group_name, "str", max_length=90, min_length=1, pattern=r"^[-\w\._\(\)]+$" + ), + "deploymentName": _SERIALIZER.url("deployment_name", deployment_name, "str"), + "operationId": _SERIALIZER.url("operation_id", operation_id, "str"), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), } _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') - - return HttpRequest( - method="GET", - url=_url, - params=_query_parameters, - headers=_header_parameters, - **kwargs - ) + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) def build_deployment_operations_list_request( - resource_group_name: str, - deployment_name: str, - subscription_id: str, - *, - top: Optional[int] = None, - **kwargs: Any + resource_group_name: str, deployment_name: str, subscription_id: str, *, top: Optional[int] = None, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2016-02-01") # type: 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", "2016-02-01")) # type: str + accept = _headers.pop("Accept", "application/json") - accept = "application/json" # Construct URL - _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/deployments/{deploymentName}/operations") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/deployments/{deploymentName}/operations", + ) # pylint: disable=line-too-long path_format_arguments = { - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._\(\)]+$'), - "deploymentName": _SERIALIZER.url("deployment_name", deployment_name, 'str'), - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), + "resourceGroupName": _SERIALIZER.url( + "resource_group_name", resource_group_name, "str", max_length=90, min_length=1, pattern=r"^[-\w\._\(\)]+$" + ), + "deploymentName": _SERIALIZER.url("deployment_name", deployment_name, "str"), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), } _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] if top is not None: - _query_parameters['$top'] = _SERIALIZER.query("top", top, 'int') - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["$top"] = _SERIALIZER.query("top", top, "int") + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') - - return HttpRequest( - method="GET", - url=_url, - params=_query_parameters, - headers=_header_parameters, - **kwargs - ) + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) -class DeploymentsOperations(object): - """DeploymentsOperations operations. - You should not instantiate this class directly. Instead, you should create a Client instance that - instantiates it for you and attaches it as an attribute. +class DeploymentsOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. - :ivar models: Alias to model classes used in this operation group. - :type models: ~azure.mgmt.resource.resources.v2016_02_01.models - :param client: Client for service requests. - :param config: Configuration of service client. - :param serializer: An object model serializer. - :param deserializer: An object model deserializer. + Instead, you should access the following operations through + :class:`~azure.mgmt.resource.resources.v2016_02_01.ResourceManagementClient`'s + :attr:`deployments` attribute. """ models = _models - def __init__(self, client, config, serializer, deserializer): - self._client = client - self._serialize = serializer - self._deserialize = deserializer - self._config = config + def __init__(self, *args, **kwargs): + input_args = list(args) + self._client = input_args.pop(0) if input_args else kwargs.pop("client") + self._config = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") def _delete_initial( # pylint: disable=inconsistent-return-statements - self, - resource_group_name: str, - deployment_name: str, - **kwargs: Any + self, resource_group_name: str, deployment_name: str, **kwargs: Any ) -> None: - cls = kwargs.pop('cls', None) # type: ClsType[None] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + 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', "2016-02-01") # type: str + api_version = kwargs.pop("api_version", _params.pop("api-version", "2016-02-01")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[None] - - request = build_deployments_delete_request_initial( + request = build_deployments_delete_request( resource_group_name=resource_group_name, deployment_name=deployment_name, subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self._delete_initial.metadata['url'], + template_url=self._delete_initial.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [202, 204]: @@ -1392,21 +1207,16 @@ 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.Resources/deployments/{deploymentName}"} # type: ignore - + _delete_initial.metadata = {"url": "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/Microsoft.Resources/deployments/{deploymentName}"} # type: ignore @distributed_trace - def begin_delete( # pylint: disable=inconsistent-return-statements - self, - resource_group_name: str, - deployment_name: str, - **kwargs: Any - ) -> LROPoller[None]: + def begin_delete(self, resource_group_name: str, deployment_name: str, **kwargs: Any) -> LROPoller[None]: """Delete deployment. :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. :type resource_group_name: str - :param deployment_name: The name of the deployment to be deleted. + :param deployment_name: The name of the deployment to be deleted. Required. :type deployment_name: str :keyword callable cls: A custom type or function that will be passed the direct response :keyword str continuation_token: A continuation token to restart a poller from a saved state. @@ -1418,88 +1228,93 @@ def begin_delete( # pylint: disable=inconsistent-return-statements Retry-After header is present. :return: An instance of LROPoller that returns either None or the result of cls(response) :rtype: ~azure.core.polling.LROPoller[None] - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - api_version = kwargs.pop('api_version', "2016-02-01") # type: str - polling = kwargs.pop('polling', True) # type: Union[bool, PollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType[None] - lro_delay = kwargs.pop( - 'polling_interval', - self._config.polling_interval - ) - cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2016-02-01")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[None] + polling = kwargs.pop("polling", True) # type: Union[bool, PollingMethod] + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token = kwargs.pop("continuation_token", None) # type: Optional[str] if cont_token is None: - raw_result = self._delete_initial( + raw_result = self._delete_initial( # type: ignore resource_group_name=resource_group_name, deployment_name=deployment_name, api_version=api_version, - cls=lambda x,y,z: x, + cls=lambda x, y, z: x, + headers=_headers, + params=_params, **kwargs ) - kwargs.pop('error_map', None) + kwargs.pop("error_map", None) - def get_long_running_output(pipeline_response): + def get_long_running_output(pipeline_response): # pylint: disable=inconsistent-return-statements if cls: return cls(pipeline_response, None, {}) - - if polling is True: polling_method = ARMPolling(lro_delay, **kwargs) - elif polling is False: polling_method = NoPolling() - else: polling_method = polling + if polling is True: + polling_method = cast(PollingMethod, ARMPolling(lro_delay, **kwargs)) # type: PollingMethod + elif polling is False: + polling_method = cast(PollingMethod, NoPolling()) + else: + polling_method = polling if cont_token: return LROPoller.from_continuation_token( polling_method=polling_method, continuation_token=cont_token, client=self._client, - deserialization_callback=get_long_running_output + deserialization_callback=get_long_running_output, ) return LROPoller(self._client, raw_result, get_long_running_output, polling_method) - begin_delete.metadata = {'url': "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/Microsoft.Resources/deployments/{deploymentName}"} # type: ignore + begin_delete.metadata = {"url": "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/Microsoft.Resources/deployments/{deploymentName}"} # type: ignore @distributed_trace - def check_existence( - self, - resource_group_name: str, - deployment_name: str, - **kwargs: Any - ) -> bool: + def check_existence(self, resource_group_name: str, deployment_name: str, **kwargs: Any) -> bool: """Checks whether deployment exists. :param resource_group_name: The name of the resource group to check. The name is case - insensitive. + insensitive. Required. :type resource_group_name: str - :param deployment_name: The name of the deployment. + :param deployment_name: The name of the deployment. Required. :type deployment_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: bool, or the result of cls(response) + :return: bool or the result of cls(response) :rtype: bool - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType[None] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) - api_version = kwargs.pop('api_version', "2016-02-01") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2016-02-01")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[None] - request = build_deployments_check_existence_request( resource_group_name=resource_group_name, deployment_name=deployment_name, subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.check_existence.metadata['url'], + template_url=self.check_existence.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [204, 404]: @@ -1510,44 +1325,53 @@ def check_existence( return cls(pipeline_response, None, {}) return 200 <= response.status_code <= 299 - check_existence.metadata = {'url': "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/Microsoft.Resources/deployments/{deploymentName}"} # type: ignore - + check_existence.metadata = {"url": "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/Microsoft.Resources/deployments/{deploymentName}"} # type: ignore def _create_or_update_initial( - self, - resource_group_name: str, - deployment_name: str, - parameters: "_models.Deployment", - **kwargs: Any - ) -> "_models.DeploymentExtended": - cls = kwargs.pop('cls', None) # type: ClsType["_models.DeploymentExtended"] + self, resource_group_name: str, deployment_name: str, parameters: Union[_models.Deployment, IO], **kwargs: Any + ) -> _models.DeploymentExtended: error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', "2016-02-01") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + api_version = kwargs.pop("api_version", _params.pop("api-version", "2016-02-01")) # type: str + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.DeploymentExtended] - _json = self._serialize.body(parameters, 'Deployment') + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(parameters, (IO, bytes)): + _content = parameters + else: + _json = self._serialize.body(parameters, "Deployment") - request = build_deployments_create_or_update_request_initial( + request = build_deployments_create_or_update_request( resource_group_name=resource_group_name, deployment_name=deployment_name, subscription_id=self._config.subscription_id, api_version=api_version, content_type=content_type, json=_json, - template_url=self._create_or_update_initial.metadata['url'], + content=_content, + template_url=self._create_or_update_initial.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200, 201]: @@ -1555,35 +1379,40 @@ def _create_or_update_initial( raise HttpResponseError(response=response, error_format=ARMErrorFormat) if response.status_code == 200: - deserialized = self._deserialize('DeploymentExtended', pipeline_response) + deserialized = self._deserialize("DeploymentExtended", pipeline_response) if response.status_code == 201: - deserialized = self._deserialize('DeploymentExtended', pipeline_response) + deserialized = self._deserialize("DeploymentExtended", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - _create_or_update_initial.metadata = {'url': "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/Microsoft.Resources/deployments/{deploymentName}"} # type: ignore - + _create_or_update_initial.metadata = {"url": "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/Microsoft.Resources/deployments/{deploymentName}"} # type: ignore - @distributed_trace + @overload def begin_create_or_update( self, resource_group_name: str, deployment_name: str, - parameters: "_models.Deployment", + parameters: _models.Deployment, + *, + content_type: str = "application/json", **kwargs: Any - ) -> LROPoller["_models.DeploymentExtended"]: + ) -> LROPoller[_models.DeploymentExtended]: """Create a named template deployment using a template. :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. :type resource_group_name: str - :param deployment_name: The name of the deployment. + :param deployment_name: The name of the deployment. Required. :type deployment_name: str - :param parameters: Additional parameters supplied to the operation. + :param parameters: Additional parameters supplied to the operation. Required. :type parameters: ~azure.mgmt.resource.resources.v2016_02_01.models.Deployment + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str :keyword callable cls: A custom type or function that will be passed the direct response :keyword str continuation_token: A continuation token to restart a poller from a saved state. :keyword polling: By default, your polling method will be ARMPolling. Pass in False for this @@ -1596,152 +1425,228 @@ def begin_create_or_update( cls(response) :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.resource.resources.v2016_02_01.models.DeploymentExtended] - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - api_version = kwargs.pop('api_version', "2016-02-01") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] - polling = kwargs.pop('polling', True) # type: Union[bool, PollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType["_models.DeploymentExtended"] - lro_delay = kwargs.pop( - 'polling_interval', - self._config.polling_interval - ) - cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] - if cont_token is None: - raw_result = self._create_or_update_initial( - resource_group_name=resource_group_name, - deployment_name=deployment_name, - parameters=parameters, - api_version=api_version, - content_type=content_type, - cls=lambda x,y,z: x, - **kwargs - ) - kwargs.pop('error_map', None) - - def get_long_running_output(pipeline_response): - response = pipeline_response.http_response - deserialized = self._deserialize('DeploymentExtended', pipeline_response) - if cls: - return cls(pipeline_response, deserialized, {}) - return deserialized + @overload + def begin_create_or_update( + self, + resource_group_name: str, + deployment_name: str, + parameters: IO, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> LROPoller[_models.DeploymentExtended]: + """Create a named template deployment using a template. - if polling is True: polling_method = ARMPolling(lro_delay, **kwargs) - elif polling is False: polling_method = NoPolling() - else: polling_method = polling - if cont_token: - return LROPoller.from_continuation_token( + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param deployment_name: The name of the deployment. Required. + :type deployment_name: str + :param parameters: Additional parameters supplied to the operation. Required. + :type parameters: IO + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be ARMPolling. Pass in False for this + operation to not poll, or pass in your own initialized polling object for a personal polling + strategy. + :paramtype polling: bool or ~azure.core.polling.PollingMethod + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of LROPoller that returns either DeploymentExtended or the result of + cls(response) + :rtype: + ~azure.core.polling.LROPoller[~azure.mgmt.resource.resources.v2016_02_01.models.DeploymentExtended] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace + def begin_create_or_update( + self, resource_group_name: str, deployment_name: str, parameters: Union[_models.Deployment, IO], **kwargs: Any + ) -> LROPoller[_models.DeploymentExtended]: + """Create a named template deployment using a template. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param deployment_name: The name of the deployment. Required. + :type deployment_name: str + :param parameters: Additional parameters supplied to the operation. Is either a model type or a + IO type. Required. + :type parameters: ~azure.mgmt.resource.resources.v2016_02_01.models.Deployment or IO + :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. + Default value is None. + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be ARMPolling. Pass in False for this + operation to not poll, or pass in your own initialized polling object for a personal polling + strategy. + :paramtype polling: bool or ~azure.core.polling.PollingMethod + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of LROPoller that returns either DeploymentExtended or the result of + cls(response) + :rtype: + ~azure.core.polling.LROPoller[~azure.mgmt.resource.resources.v2016_02_01.models.DeploymentExtended] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _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", "2016-02-01")) # type: str + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.DeploymentExtended] + polling = kwargs.pop("polling", True) # type: Union[bool, PollingMethod] + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token = kwargs.pop("continuation_token", None) # type: Optional[str] + if cont_token is None: + raw_result = self._create_or_update_initial( # type: ignore + resource_group_name=resource_group_name, + deployment_name=deployment_name, + parameters=parameters, + api_version=api_version, + content_type=content_type, + cls=lambda x, y, z: x, + headers=_headers, + params=_params, + **kwargs + ) + kwargs.pop("error_map", None) + + def get_long_running_output(pipeline_response): + deserialized = self._deserialize("DeploymentExtended", pipeline_response) + if cls: + return cls(pipeline_response, deserialized, {}) + return deserialized + + if polling is True: + polling_method = cast(PollingMethod, ARMPolling(lro_delay, **kwargs)) # type: PollingMethod + elif polling is False: + polling_method = cast(PollingMethod, NoPolling()) + else: + polling_method = polling + if cont_token: + return LROPoller.from_continuation_token( polling_method=polling_method, continuation_token=cont_token, client=self._client, - deserialization_callback=get_long_running_output + deserialization_callback=get_long_running_output, ) return LROPoller(self._client, raw_result, get_long_running_output, polling_method) - begin_create_or_update.metadata = {'url': "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/Microsoft.Resources/deployments/{deploymentName}"} # type: ignore + begin_create_or_update.metadata = {"url": "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/Microsoft.Resources/deployments/{deploymentName}"} # type: ignore @distributed_trace - def get( - self, - resource_group_name: str, - deployment_name: str, - **kwargs: Any - ) -> "_models.DeploymentExtended": + def get(self, resource_group_name: str, deployment_name: str, **kwargs: Any) -> _models.DeploymentExtended: """Get a deployment. :param resource_group_name: The name of the resource group to get. The name is case - insensitive. + insensitive. Required. :type resource_group_name: str - :param deployment_name: The name of the deployment. + :param deployment_name: The name of the deployment. Required. :type deployment_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: DeploymentExtended, or the result of cls(response) + :return: DeploymentExtended or the result of cls(response) :rtype: ~azure.mgmt.resource.resources.v2016_02_01.models.DeploymentExtended - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.DeploymentExtended"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + 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', "2016-02-01") # type: str + api_version = kwargs.pop("api_version", _params.pop("api-version", "2016-02-01")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[_models.DeploymentExtended] - request = build_deployments_get_request( resource_group_name=resource_group_name, deployment_name=deployment_name, subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.get.metadata['url'], + template_url=self.get.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) - deserialized = self._deserialize('DeploymentExtended', pipeline_response) + deserialized = self._deserialize("DeploymentExtended", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - get.metadata = {'url': "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/Microsoft.Resources/deployments/{deploymentName}"} # type: ignore - + get.metadata = {"url": "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/Microsoft.Resources/deployments/{deploymentName}"} # type: ignore @distributed_trace def cancel( # pylint: disable=inconsistent-return-statements - self, - resource_group_name: str, - deployment_name: str, - **kwargs: Any + self, resource_group_name: str, deployment_name: str, **kwargs: Any ) -> None: """Cancel a currently running template deployment. :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. :type resource_group_name: str - :param deployment_name: The name of the deployment. + :param deployment_name: The name of the deployment. Required. :type deployment_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: None, or the result of cls(response) + :return: None or the result of cls(response) :rtype: None - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType[None] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + 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', "2016-02-01") # type: str + api_version = kwargs.pop("api_version", _params.pop("api-version", "2016-02-01")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[None] - request = build_deployments_cancel_request( resource_group_name=resource_group_name, deployment_name=deployment_name, subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.cancel.metadata['url'], + template_url=self.cancel.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [204]: @@ -1751,40 +1656,107 @@ def cancel( # pylint: disable=inconsistent-return-statements if cls: return cls(pipeline_response, None, {}) - cancel.metadata = {'url': "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/Microsoft.Resources/deployments/{deploymentName}/cancel"} # type: ignore - + cancel.metadata = {"url": "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/Microsoft.Resources/deployments/{deploymentName}/cancel"} # type: ignore - @distributed_trace + @overload def validate( self, resource_group_name: str, deployment_name: str, - parameters: "_models.Deployment", + parameters: _models.Deployment, + *, + content_type: str = "application/json", **kwargs: Any - ) -> "_models.DeploymentValidateResult": + ) -> _models.DeploymentValidateResult: """Validate a deployment template. :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. :type resource_group_name: str - :param deployment_name: The name of the deployment. + :param deployment_name: The name of the deployment. Required. :type deployment_name: str - :param parameters: Deployment to validate. + :param parameters: Deployment to validate. Required. :type parameters: ~azure.mgmt.resource.resources.v2016_02_01.models.Deployment + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: DeploymentValidateResult or the result of cls(response) + :rtype: ~azure.mgmt.resource.resources.v2016_02_01.models.DeploymentValidateResult + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + def validate( + self, + resource_group_name: str, + deployment_name: str, + parameters: IO, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.DeploymentValidateResult: + """Validate a deployment template. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param deployment_name: The name of the deployment. Required. + :type deployment_name: str + :param parameters: Deployment to validate. Required. + :type parameters: IO + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: DeploymentValidateResult or the result of cls(response) + :rtype: ~azure.mgmt.resource.resources.v2016_02_01.models.DeploymentValidateResult + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace + def validate( + self, resource_group_name: str, deployment_name: str, parameters: Union[_models.Deployment, IO], **kwargs: Any + ) -> _models.DeploymentValidateResult: + """Validate a deployment template. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param deployment_name: The name of the deployment. Required. + :type deployment_name: str + :param parameters: Deployment to validate. Is either a model type or a IO type. Required. + :type parameters: ~azure.mgmt.resource.resources.v2016_02_01.models.Deployment or IO + :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. + Default value is None. + :paramtype content_type: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: DeploymentValidateResult, or the result of cls(response) + :return: DeploymentValidateResult or the result of cls(response) :rtype: ~azure.mgmt.resource.resources.v2016_02_01.models.DeploymentValidateResult - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.DeploymentValidateResult"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) - api_version = kwargs.pop('api_version', "2016-02-01") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - _json = self._serialize.body(parameters, 'Deployment') + api_version = kwargs.pop("api_version", _params.pop("api-version", "2016-02-01")) # type: str + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.DeploymentValidateResult] + + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(parameters, (IO, bytes)): + _content = parameters + else: + _json = self._serialize.body(parameters, "Deployment") request = build_deployments_validate_request( resource_group_name=resource_group_name, @@ -1793,16 +1765,18 @@ def validate( api_version=api_version, content_type=content_type, json=_json, - template_url=self.validate.metadata['url'], + content=_content, + template_url=self.validate.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200, 400]: @@ -1810,131 +1784,136 @@ def validate( raise HttpResponseError(response=response, error_format=ARMErrorFormat) if response.status_code == 200: - deserialized = self._deserialize('DeploymentValidateResult', pipeline_response) + deserialized = self._deserialize("DeploymentValidateResult", pipeline_response) if response.status_code == 400: - deserialized = self._deserialize('DeploymentValidateResult', pipeline_response) + deserialized = self._deserialize("DeploymentValidateResult", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - validate.metadata = {'url': "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/Microsoft.Resources/deployments/{deploymentName}/validate"} # type: ignore - + validate.metadata = {"url": "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/Microsoft.Resources/deployments/{deploymentName}/validate"} # type: ignore @distributed_trace def export_template( - self, - resource_group_name: str, - deployment_name: str, - **kwargs: Any - ) -> "_models.DeploymentExportResult": + self, resource_group_name: str, deployment_name: str, **kwargs: Any + ) -> _models.DeploymentExportResult: """Exports a deployment template. :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. :type resource_group_name: str - :param deployment_name: The name of the deployment. + :param deployment_name: The name of the deployment. Required. :type deployment_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: DeploymentExportResult, or the result of cls(response) + :return: DeploymentExportResult or the result of cls(response) :rtype: ~azure.mgmt.resource.resources.v2016_02_01.models.DeploymentExportResult - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.DeploymentExportResult"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + 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', "2016-02-01") # type: str + api_version = kwargs.pop("api_version", _params.pop("api-version", "2016-02-01")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[_models.DeploymentExportResult] - request = build_deployments_export_template_request( resource_group_name=resource_group_name, deployment_name=deployment_name, subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.export_template.metadata['url'], + template_url=self.export_template.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) - deserialized = self._deserialize('DeploymentExportResult', pipeline_response) + deserialized = self._deserialize("DeploymentExportResult", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - export_template.metadata = {'url': "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/Microsoft.Resources/deployments/{deploymentName}/exportTemplate"} # type: ignore - + export_template.metadata = {"url": "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/Microsoft.Resources/deployments/{deploymentName}/exportTemplate"} # type: ignore @distributed_trace def list( - self, - resource_group_name: str, - filter: Optional[str] = None, - top: Optional[int] = None, - **kwargs: Any - ) -> Iterable["_models.DeploymentListResult"]: + self, resource_group_name: str, filter: Optional[str] = None, top: Optional[int] = None, **kwargs: Any + ) -> Iterable["_models.DeploymentExtended"]: """Get a list of deployments. :param resource_group_name: The name of the resource group to filter by. The name is case - insensitive. + insensitive. Required. :type resource_group_name: str :param filter: The filter to apply on the operation. Default value is None. :type filter: str :param top: Query parameters. If null is passed returns all deployments. Default value is None. :type top: int :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either DeploymentListResult or the result of - cls(response) + :return: An iterator like instance of either DeploymentExtended or the result of cls(response) :rtype: - ~azure.core.paging.ItemPaged[~azure.mgmt.resource.resources.v2016_02_01.models.DeploymentListResult] - :raises: ~azure.core.exceptions.HttpResponseError + ~azure.core.paging.ItemPaged[~azure.mgmt.resource.resources.v2016_02_01.models.DeploymentExtended] + :raises ~azure.core.exceptions.HttpResponseError: """ - api_version = kwargs.pop('api_version', "2016-02-01") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2016-02-01")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[_models.DeploymentListResult] - cls = kwargs.pop('cls', None) # type: ClsType["_models.DeploymentListResult"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) + def prepare_request(next_link=None): if not next_link: - + request = build_deployments_list_request( resource_group_name=resource_group_name, subscription_id=self._config.subscription_id, - api_version=api_version, filter=filter, top=top, - template_url=self.list.metadata['url'], + 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.url = self._client.format_url(request.url) # type: ignore else: - - request = build_deployments_list_request( - resource_group_name=resource_group_name, - subscription_id=self._config.subscription_id, - template_url=next_link, - ) + # make call to next link with the client's api-version + _parsed_next_link = urlparse(next_link) + _next_request_params = case_insensitive_dict(parse_qs(_parsed_next_link.query)) + _next_request_params["api-version"] = self._config.api_version + request = HttpRequest("GET", urljoin(next_link, _parsed_next_link.path), params=_next_request_params) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore request.method = "GET" return request @@ -1948,10 +1927,8 @@ def extract_data(pipeline_response): def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) response = pipeline_response.http_response @@ -1961,204 +1938,202 @@ def get_next(next_link=None): return pipeline_response + return ItemPaged(get_next, extract_data) - return ItemPaged( - get_next, extract_data - ) - list.metadata = {'url': "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/Microsoft.Resources/deployments/"} # type: ignore + list.metadata = {"url": "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/Microsoft.Resources/deployments/"} # type: ignore @distributed_trace - def calculate_template_hash( - self, - template: Any, - **kwargs: Any - ) -> "_models.TemplateHashResult": + def calculate_template_hash(self, template: JSON, **kwargs: Any) -> _models.TemplateHashResult: """Calculate the hash of the given template. - :param template: The template provided to calculate hash. - :type template: any + :param template: The template provided to calculate hash. Required. + :type template: JSON :keyword callable cls: A custom type or function that will be passed the direct response - :return: TemplateHashResult, or the result of cls(response) + :return: TemplateHashResult or the result of cls(response) :rtype: ~azure.mgmt.resource.resources.v2016_02_01.models.TemplateHashResult - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.TemplateHashResult"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) - api_version = kwargs.pop('api_version', "2016-02-01") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - _json = self._serialize.body(template, 'object') + api_version = kwargs.pop("api_version", _params.pop("api-version", "2016-02-01")) # type: str + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", "application/json")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[_models.TemplateHashResult] + + _json = self._serialize.body(template, "object") request = build_deployments_calculate_template_hash_request( api_version=api_version, content_type=content_type, json=_json, - template_url=self.calculate_template_hash.metadata['url'], + template_url=self.calculate_template_hash.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) - deserialized = self._deserialize('TemplateHashResult', pipeline_response) + deserialized = self._deserialize("TemplateHashResult", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - calculate_template_hash.metadata = {'url': "/providers/Microsoft.Resources/calculateTemplateHash"} # type: ignore + calculate_template_hash.metadata = {"url": "/providers/Microsoft.Resources/calculateTemplateHash"} # type: ignore -class ProvidersOperations(object): - """ProvidersOperations operations. - You should not instantiate this class directly. Instead, you should create a Client instance that - instantiates it for you and attaches it as an attribute. +class ProvidersOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. - :ivar models: Alias to model classes used in this operation group. - :type models: ~azure.mgmt.resource.resources.v2016_02_01.models - :param client: Client for service requests. - :param config: Configuration of service client. - :param serializer: An object model serializer. - :param deserializer: An object model deserializer. + Instead, you should access the following operations through + :class:`~azure.mgmt.resource.resources.v2016_02_01.ResourceManagementClient`'s + :attr:`providers` attribute. """ models = _models - def __init__(self, client, config, serializer, deserializer): - self._client = client - self._serialize = serializer - self._deserialize = deserializer - self._config = config + def __init__(self, *args, **kwargs): + input_args = list(args) + self._client = input_args.pop(0) if input_args else kwargs.pop("client") + self._config = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") @distributed_trace - def unregister( - self, - resource_provider_namespace: str, - **kwargs: Any - ) -> "_models.Provider": + def unregister(self, resource_provider_namespace: str, **kwargs: Any) -> _models.Provider: """Unregisters provider from a subscription. - :param resource_provider_namespace: Namespace of the resource provider. + :param resource_provider_namespace: Namespace of the resource provider. Required. :type resource_provider_namespace: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: Provider, or the result of cls(response) + :return: Provider or the result of cls(response) :rtype: ~azure.mgmt.resource.resources.v2016_02_01.models.Provider - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.Provider"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + 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', "2016-02-01") # type: str + api_version = kwargs.pop("api_version", _params.pop("api-version", "2016-02-01")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[_models.Provider] - request = build_providers_unregister_request( resource_provider_namespace=resource_provider_namespace, subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.unregister.metadata['url'], + template_url=self.unregister.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) - deserialized = self._deserialize('Provider', pipeline_response) + deserialized = self._deserialize("Provider", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - unregister.metadata = {'url': "/subscriptions/{subscriptionId}/providers/{resourceProviderNamespace}/unregister"} # type: ignore - + unregister.metadata = {"url": "/subscriptions/{subscriptionId}/providers/{resourceProviderNamespace}/unregister"} # type: ignore @distributed_trace - def register( - self, - resource_provider_namespace: str, - **kwargs: Any - ) -> "_models.Provider": + def register(self, resource_provider_namespace: str, **kwargs: Any) -> _models.Provider: """Registers provider to be used with a subscription. - :param resource_provider_namespace: Namespace of the resource provider. + :param resource_provider_namespace: Namespace of the resource provider. Required. :type resource_provider_namespace: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: Provider, or the result of cls(response) + :return: Provider or the result of cls(response) :rtype: ~azure.mgmt.resource.resources.v2016_02_01.models.Provider - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.Provider"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) - api_version = kwargs.pop('api_version', "2016-02-01") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2016-02-01")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[_models.Provider] - request = build_providers_register_request( resource_provider_namespace=resource_provider_namespace, subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.register.metadata['url'], + template_url=self.register.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) - deserialized = self._deserialize('Provider', pipeline_response) + deserialized = self._deserialize("Provider", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - register.metadata = {'url': "/subscriptions/{subscriptionId}/providers/{resourceProviderNamespace}/register"} # type: ignore - + register.metadata = {"url": "/subscriptions/{subscriptionId}/providers/{resourceProviderNamespace}/register"} # type: ignore @distributed_trace def list( - self, - top: Optional[int] = None, - expand: Optional[str] = None, - **kwargs: Any - ) -> Iterable["_models.ProviderListResult"]: + self, top: Optional[int] = None, expand: Optional[str] = None, **kwargs: Any + ) -> Iterable["_models.Provider"]: """Gets a list of resource providers. :param top: Query parameters. If null is passed returns all deployments. Default value is None. @@ -2167,39 +2142,48 @@ def list( $expand=resourceTypes/aliases. Default value is None. :type expand: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either ProviderListResult or the result of cls(response) + :return: An iterator like instance of either Provider or the result of cls(response) :rtype: - ~azure.core.paging.ItemPaged[~azure.mgmt.resource.resources.v2016_02_01.models.ProviderListResult] - :raises: ~azure.core.exceptions.HttpResponseError + ~azure.core.paging.ItemPaged[~azure.mgmt.resource.resources.v2016_02_01.models.Provider] + :raises ~azure.core.exceptions.HttpResponseError: """ - api_version = kwargs.pop('api_version', "2016-02-01") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2016-02-01")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[_models.ProviderListResult] - cls = kwargs.pop('cls', None) # type: ClsType["_models.ProviderListResult"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) + def prepare_request(next_link=None): if not next_link: - + request = build_providers_list_request( subscription_id=self._config.subscription_id, - api_version=api_version, top=top, expand=expand, - template_url=self.list.metadata['url'], + 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.url = self._client.format_url(request.url) # type: ignore else: - - request = build_providers_list_request( - subscription_id=self._config.subscription_id, - template_url=next_link, - ) + # make call to next link with the client's api-version + _parsed_next_link = urlparse(next_link) + _next_request_params = case_insensitive_dict(parse_qs(_parsed_next_link.query)) + _next_request_params["api-version"] = self._config.api_version + request = HttpRequest("GET", urljoin(next_link, _parsed_next_link.path), params=_next_request_params) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore request.method = "GET" return request @@ -2213,10 +2197,8 @@ def extract_data(pipeline_response): def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) response = pipeline_response.http_response @@ -2226,91 +2208,88 @@ def get_next(next_link=None): return pipeline_response + return ItemPaged(get_next, extract_data) - return ItemPaged( - get_next, extract_data - ) - list.metadata = {'url': "/subscriptions/{subscriptionId}/providers"} # type: ignore + list.metadata = {"url": "/subscriptions/{subscriptionId}/providers"} # type: ignore @distributed_trace - def get( - self, - resource_provider_namespace: str, - expand: Optional[str] = None, - **kwargs: Any - ) -> "_models.Provider": + def get(self, resource_provider_namespace: str, expand: Optional[str] = None, **kwargs: Any) -> _models.Provider: """Gets a resource provider. - :param resource_provider_namespace: Namespace of the resource provider. + :param resource_provider_namespace: Namespace of the resource provider. Required. :type resource_provider_namespace: str :param expand: The $expand query parameter. e.g. To include property aliases in response, use $expand=resourceTypes/aliases. Default value is None. :type expand: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: Provider, or the result of cls(response) + :return: Provider or the result of cls(response) :rtype: ~azure.mgmt.resource.resources.v2016_02_01.models.Provider - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.Provider"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + 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', "2016-02-01") # type: str + api_version = kwargs.pop("api_version", _params.pop("api-version", "2016-02-01")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[_models.Provider] - request = build_providers_get_request( resource_provider_namespace=resource_provider_namespace, subscription_id=self._config.subscription_id, - api_version=api_version, expand=expand, - template_url=self.get.metadata['url'], + api_version=api_version, + template_url=self.get.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) - deserialized = self._deserialize('Provider', pipeline_response) + deserialized = self._deserialize("Provider", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - get.metadata = {'url': "/subscriptions/{subscriptionId}/providers/{resourceProviderNamespace}"} # type: ignore + get.metadata = {"url": "/subscriptions/{subscriptionId}/providers/{resourceProviderNamespace}"} # type: ignore -class ResourceGroupsOperations(object): - """ResourceGroupsOperations operations. - You should not instantiate this class directly. Instead, you should create a Client instance that - instantiates it for you and attaches it as an attribute. +class ResourceGroupsOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. - :ivar models: Alias to model classes used in this operation group. - :type models: ~azure.mgmt.resource.resources.v2016_02_01.models - :param client: Client for service requests. - :param config: Configuration of service client. - :param serializer: An object model serializer. - :param deserializer: An object model deserializer. + Instead, you should access the following operations through + :class:`~azure.mgmt.resource.resources.v2016_02_01.ResourceManagementClient`'s + :attr:`resource_groups` attribute. """ models = _models - def __init__(self, client, config, serializer, deserializer): - self._client = client - self._serialize = serializer - self._deserialize = deserializer - self._config = config + def __init__(self, *args, **kwargs): + input_args = list(args) + self._client = input_args.pop(0) if input_args else kwargs.pop("client") + self._config = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") @distributed_trace def list_resources( @@ -2320,10 +2299,11 @@ def list_resources( expand: Optional[str] = None, top: Optional[int] = None, **kwargs: Any - ) -> Iterable["_models.ResourceListResult"]: + ) -> Iterable["_models.GenericResourceExpanded"]: """Get all of the resources under a subscription. :param resource_group_name: Query parameters. If null is passed returns all resource groups. + Required. :type resource_group_name: str :param filter: The filter to apply on the operation. Default value is None. :type filter: str @@ -2335,42 +2315,51 @@ def list_resources( None. :type top: int :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either ResourceListResult or the result of cls(response) + :return: An iterator like instance of either GenericResourceExpanded or the result of + cls(response) :rtype: - ~azure.core.paging.ItemPaged[~azure.mgmt.resource.resources.v2016_02_01.models.ResourceListResult] - :raises: ~azure.core.exceptions.HttpResponseError + ~azure.core.paging.ItemPaged[~azure.mgmt.resource.resources.v2016_02_01.models.GenericResourceExpanded] + :raises ~azure.core.exceptions.HttpResponseError: """ - api_version = kwargs.pop('api_version', "2016-02-01") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2016-02-01")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[_models.ResourceListResult] - cls = kwargs.pop('cls', None) # type: ClsType["_models.ResourceListResult"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) + def prepare_request(next_link=None): if not next_link: - + request = build_resource_groups_list_resources_request( resource_group_name=resource_group_name, subscription_id=self._config.subscription_id, - api_version=api_version, filter=filter, expand=expand, top=top, - template_url=self.list_resources.metadata['url'], + api_version=api_version, + template_url=self.list_resources.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore else: - - request = build_resource_groups_list_resources_request( - resource_group_name=resource_group_name, - subscription_id=self._config.subscription_id, - template_url=next_link, - ) + # make call to next link with the client's api-version + _parsed_next_link = urlparse(next_link) + _next_request_params = case_insensitive_dict(parse_qs(_parsed_next_link.query)) + _next_request_params["api-version"] = self._config.api_version + request = HttpRequest("GET", urljoin(next_link, _parsed_next_link.path), params=_next_request_params) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore request.method = "GET" return request @@ -2384,10 +2373,8 @@ def extract_data(pipeline_response): def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) response = pipeline_response.http_response @@ -2397,51 +2384,51 @@ def get_next(next_link=None): return pipeline_response + return ItemPaged(get_next, extract_data) - return ItemPaged( - get_next, extract_data - ) - list_resources.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/resources"} # type: ignore + list_resources.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/resources"} # type: ignore @distributed_trace - def check_existence( - self, - resource_group_name: str, - **kwargs: Any - ) -> bool: + def check_existence(self, resource_group_name: str, **kwargs: Any) -> bool: """Checks whether resource group exists. :param resource_group_name: The name of the resource group to check. The name is case - insensitive. + insensitive. Required. :type resource_group_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: bool, or the result of cls(response) + :return: bool or the result of cls(response) :rtype: bool - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType[None] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) - api_version = kwargs.pop('api_version', "2016-02-01") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2016-02-01")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[None] - request = build_resource_groups_check_existence_request( resource_group_name=resource_group_name, subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.check_existence.metadata['url'], + template_url=self.check_existence.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [204, 404]: @@ -2452,38 +2439,94 @@ def check_existence( return cls(pipeline_response, None, {}) return 200 <= response.status_code <= 299 - check_existence.metadata = {'url': "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}"} # type: ignore - + check_existence.metadata = {"url": "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}"} # type: ignore - @distributed_trace + @overload def create_or_update( self, resource_group_name: str, - parameters: "_models.ResourceGroup", + parameters: _models.ResourceGroup, + *, + content_type: str = "application/json", **kwargs: Any - ) -> "_models.ResourceGroup": + ) -> _models.ResourceGroup: """Create a resource group. - :param resource_group_name: The name of the resource group to be created or updated. + :param resource_group_name: The name of the resource group to be created or updated. Required. :type resource_group_name: str :param parameters: Parameters supplied to the create or update resource group service - operation. + operation. Required. :type parameters: ~azure.mgmt.resource.resources.v2016_02_01.models.ResourceGroup + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: ResourceGroup, or the result of cls(response) + :return: ResourceGroup or the result of cls(response) :rtype: ~azure.mgmt.resource.resources.v2016_02_01.models.ResourceGroup - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + def create_or_update( + self, resource_group_name: str, parameters: IO, *, content_type: str = "application/json", **kwargs: Any + ) -> _models.ResourceGroup: + """Create a resource group. + + :param resource_group_name: The name of the resource group to be created or updated. Required. + :type resource_group_name: str + :param parameters: Parameters supplied to the create or update resource group service + operation. Required. + :type parameters: IO + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: ResourceGroup or the result of cls(response) + :rtype: ~azure.mgmt.resource.resources.v2016_02_01.models.ResourceGroup + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace + def create_or_update( + self, resource_group_name: str, parameters: Union[_models.ResourceGroup, IO], **kwargs: Any + ) -> _models.ResourceGroup: + """Create a resource group. + + :param resource_group_name: The name of the resource group to be created or updated. Required. + :type resource_group_name: str + :param parameters: Parameters supplied to the create or update resource group service + operation. Is either a model type or a IO type. Required. + :type parameters: ~azure.mgmt.resource.resources.v2016_02_01.models.ResourceGroup or IO + :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. + Default value is None. + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: ResourceGroup or the result of cls(response) + :rtype: ~azure.mgmt.resource.resources.v2016_02_01.models.ResourceGroup + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.ResourceGroup"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', "2016-02-01") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + api_version = kwargs.pop("api_version", _params.pop("api-version", "2016-02-01")) # type: str + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.ResourceGroup] - _json = self._serialize.body(parameters, 'ResourceGroup') + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(parameters, (IO, bytes)): + _content = parameters + else: + _json = self._serialize.body(parameters, "ResourceGroup") request = build_resource_groups_create_or_update_request( resource_group_name=resource_group_name, @@ -2491,16 +2534,18 @@ def create_or_update( api_version=api_version, content_type=content_type, json=_json, - template_url=self.create_or_update.metadata['url'], + content=_content, + template_url=self.create_or_update.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200, 201]: @@ -2508,47 +2553,50 @@ def create_or_update( raise HttpResponseError(response=response, error_format=ARMErrorFormat) if response.status_code == 200: - deserialized = self._deserialize('ResourceGroup', pipeline_response) + deserialized = self._deserialize("ResourceGroup", pipeline_response) if response.status_code == 201: - deserialized = self._deserialize('ResourceGroup', pipeline_response) + deserialized = self._deserialize("ResourceGroup", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - create_or_update.metadata = {'url': "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}"} # type: ignore - + create_or_update.metadata = {"url": "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}"} # type: ignore def _delete_initial( # pylint: disable=inconsistent-return-statements - self, - resource_group_name: str, - **kwargs: Any + self, resource_group_name: str, **kwargs: Any ) -> None: - cls = kwargs.pop('cls', None) # type: ClsType[None] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + 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', "2016-02-01") # type: str + api_version = kwargs.pop("api_version", _params.pop("api-version", "2016-02-01")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[None] - - request = build_resource_groups_delete_request_initial( + request = build_resource_groups_delete_request( resource_group_name=resource_group_name, subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self._delete_initial.metadata['url'], + template_url=self._delete_initial.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200, 202]: @@ -2558,19 +2606,14 @@ def _delete_initial( # pylint: disable=inconsistent-return-statements if cls: return cls(pipeline_response, None, {}) - _delete_initial.metadata = {'url': "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}"} # type: ignore - + _delete_initial.metadata = {"url": "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}"} # type: ignore @distributed_trace - def begin_delete( # pylint: disable=inconsistent-return-statements - self, - resource_group_name: str, - **kwargs: Any - ) -> LROPoller[None]: + def begin_delete(self, resource_group_name: str, **kwargs: Any) -> LROPoller[None]: """Delete resource group. :param resource_group_name: The name of the resource group to be deleted. The name is case - insensitive. + insensitive. Required. :type resource_group_name: str :keyword callable cls: A custom type or function that will be passed the direct response :keyword str continuation_token: A continuation token to restart a poller from a saved state. @@ -2582,130 +2625,199 @@ def begin_delete( # pylint: disable=inconsistent-return-statements Retry-After header is present. :return: An instance of LROPoller that returns either None or the result of cls(response) :rtype: ~azure.core.polling.LROPoller[None] - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - api_version = kwargs.pop('api_version', "2016-02-01") # type: str - polling = kwargs.pop('polling', True) # type: Union[bool, PollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType[None] - lro_delay = kwargs.pop( - 'polling_interval', - self._config.polling_interval - ) - cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2016-02-01")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[None] + polling = kwargs.pop("polling", True) # type: Union[bool, PollingMethod] + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token = kwargs.pop("continuation_token", None) # type: Optional[str] if cont_token is None: - raw_result = self._delete_initial( + raw_result = self._delete_initial( # type: ignore resource_group_name=resource_group_name, api_version=api_version, - cls=lambda x,y,z: x, + cls=lambda x, y, z: x, + headers=_headers, + params=_params, **kwargs ) - kwargs.pop('error_map', None) + kwargs.pop("error_map", None) - def get_long_running_output(pipeline_response): + def get_long_running_output(pipeline_response): # pylint: disable=inconsistent-return-statements if cls: return cls(pipeline_response, None, {}) - - if polling is True: polling_method = ARMPolling(lro_delay, **kwargs) - elif polling is False: polling_method = NoPolling() - else: polling_method = polling + if polling is True: + polling_method = cast(PollingMethod, ARMPolling(lro_delay, **kwargs)) # type: PollingMethod + elif polling is False: + polling_method = cast(PollingMethod, NoPolling()) + else: + polling_method = polling if cont_token: return LROPoller.from_continuation_token( polling_method=polling_method, continuation_token=cont_token, client=self._client, - deserialization_callback=get_long_running_output + deserialization_callback=get_long_running_output, ) return LROPoller(self._client, raw_result, get_long_running_output, polling_method) - begin_delete.metadata = {'url': "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}"} # type: ignore + begin_delete.metadata = {"url": "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}"} # type: ignore @distributed_trace - def get( - self, - resource_group_name: str, - **kwargs: Any - ) -> "_models.ResourceGroup": + def get(self, resource_group_name: str, **kwargs: Any) -> _models.ResourceGroup: """Get a resource group. :param resource_group_name: The name of the resource group to get. The name is case - insensitive. + insensitive. Required. :type resource_group_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: ResourceGroup, or the result of cls(response) + :return: ResourceGroup or the result of cls(response) :rtype: ~azure.mgmt.resource.resources.v2016_02_01.models.ResourceGroup - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.ResourceGroup"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + 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', "2016-02-01") # type: str + api_version = kwargs.pop("api_version", _params.pop("api-version", "2016-02-01")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[_models.ResourceGroup] - request = build_resource_groups_get_request( resource_group_name=resource_group_name, subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.get.metadata['url'], + template_url=self.get.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) - deserialized = self._deserialize('ResourceGroup', pipeline_response) + deserialized = self._deserialize("ResourceGroup", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - get.metadata = {'url': "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}"} # type: ignore - + get.metadata = {"url": "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}"} # type: ignore - @distributed_trace + @overload def patch( self, resource_group_name: str, - parameters: "_models.ResourceGroup", + parameters: _models.ResourceGroup, + *, + content_type: str = "application/json", **kwargs: Any - ) -> "_models.ResourceGroup": + ) -> _models.ResourceGroup: """Resource groups can be updated through a simple PATCH operation to a group address. The format of the request is the same as that for creating a resource groups, though if a field is unspecified current value will be carried over. :param resource_group_name: The name of the resource group to be created or updated. The name - is case insensitive. + is case insensitive. Required. :type resource_group_name: str :param parameters: Parameters supplied to the update state resource group service operation. + Required. :type parameters: ~azure.mgmt.resource.resources.v2016_02_01.models.ResourceGroup + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: ResourceGroup, or the result of cls(response) + :return: ResourceGroup or the result of cls(response) :rtype: ~azure.mgmt.resource.resources.v2016_02_01.models.ResourceGroup - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + def patch( + self, resource_group_name: str, parameters: IO, *, content_type: str = "application/json", **kwargs: Any + ) -> _models.ResourceGroup: + """Resource groups can be updated through a simple PATCH operation to a group address. The format + of the request is the same as that for creating a resource groups, though if a field is + unspecified current value will be carried over. + + :param resource_group_name: The name of the resource group to be created or updated. The name + is case insensitive. Required. + :type resource_group_name: str + :param parameters: Parameters supplied to the update state resource group service operation. + Required. + :type parameters: IO + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: ResourceGroup or the result of cls(response) + :rtype: ~azure.mgmt.resource.resources.v2016_02_01.models.ResourceGroup + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace + def patch( + self, resource_group_name: str, parameters: Union[_models.ResourceGroup, IO], **kwargs: Any + ) -> _models.ResourceGroup: + """Resource groups can be updated through a simple PATCH operation to a group address. The format + of the request is the same as that for creating a resource groups, though if a field is + unspecified current value will be carried over. + + :param resource_group_name: The name of the resource group to be created or updated. The name + is case insensitive. Required. + :type resource_group_name: str + :param parameters: Parameters supplied to the update state resource group service operation. Is + either a model type or a IO type. Required. + :type parameters: ~azure.mgmt.resource.resources.v2016_02_01.models.ResourceGroup or IO + :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. + Default value is None. + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: ResourceGroup or the result of cls(response) + :rtype: ~azure.mgmt.resource.resources.v2016_02_01.models.ResourceGroup + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.ResourceGroup"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', "2016-02-01") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + api_version = kwargs.pop("api_version", _params.pop("api-version", "2016-02-01")) # type: str + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.ResourceGroup] - _json = self._serialize.body(parameters, 'ResourceGroup') + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(parameters, (IO, bytes)): + _content = parameters + else: + _json = self._serialize.body(parameters, "ResourceGroup") request = build_resource_groups_patch_request( resource_group_name=resource_group_name, @@ -2713,60 +2825,119 @@ def patch( api_version=api_version, content_type=content_type, json=_json, - template_url=self.patch.metadata['url'], + content=_content, + template_url=self.patch.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) - deserialized = self._deserialize('ResourceGroup', pipeline_response) + deserialized = self._deserialize("ResourceGroup", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - patch.metadata = {'url': "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}"} # type: ignore - + patch.metadata = {"url": "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}"} # type: ignore - @distributed_trace + @overload def export_template( self, resource_group_name: str, - parameters: "_models.ExportTemplateRequest", + parameters: _models.ExportTemplateRequest, + *, + content_type: str = "application/json", **kwargs: Any - ) -> "_models.ResourceGroupExportResult": + ) -> _models.ResourceGroupExportResult: """Captures the specified resource group as a template. - :param resource_group_name: The name of the resource group to be created or updated. + :param resource_group_name: The name of the resource group to be created or updated. Required. :type resource_group_name: str :param parameters: Parameters supplied to the export template resource group operation. + Required. :type parameters: ~azure.mgmt.resource.resources.v2016_02_01.models.ExportTemplateRequest + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: ResourceGroupExportResult or the result of cls(response) + :rtype: ~azure.mgmt.resource.resources.v2016_02_01.models.ResourceGroupExportResult + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + def export_template( + self, resource_group_name: str, parameters: IO, *, content_type: str = "application/json", **kwargs: Any + ) -> _models.ResourceGroupExportResult: + """Captures the specified resource group as a template. + + :param resource_group_name: The name of the resource group to be created or updated. Required. + :type resource_group_name: str + :param parameters: Parameters supplied to the export template resource group operation. + Required. + :type parameters: IO + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: ResourceGroupExportResult or the result of cls(response) + :rtype: ~azure.mgmt.resource.resources.v2016_02_01.models.ResourceGroupExportResult + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace + def export_template( + self, resource_group_name: str, parameters: Union[_models.ExportTemplateRequest, IO], **kwargs: Any + ) -> _models.ResourceGroupExportResult: + """Captures the specified resource group as a template. + + :param resource_group_name: The name of the resource group to be created or updated. Required. + :type resource_group_name: str + :param parameters: Parameters supplied to the export template resource group operation. Is + either a model type or a IO type. Required. + :type parameters: ~azure.mgmt.resource.resources.v2016_02_01.models.ExportTemplateRequest or IO + :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. + Default value is None. + :paramtype content_type: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: ResourceGroupExportResult, or the result of cls(response) + :return: ResourceGroupExportResult or the result of cls(response) :rtype: ~azure.mgmt.resource.resources.v2016_02_01.models.ResourceGroupExportResult - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.ResourceGroupExportResult"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) - api_version = kwargs.pop('api_version', "2016-02-01") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - _json = self._serialize.body(parameters, 'ExportTemplateRequest') + api_version = kwargs.pop("api_version", _params.pop("api-version", "2016-02-01")) # type: str + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.ResourceGroupExportResult] + + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(parameters, (IO, bytes)): + _content = parameters + else: + _json = self._serialize.body(parameters, "ExportTemplateRequest") request = build_resource_groups_export_template_request( resource_group_name=resource_group_name, @@ -2774,39 +2945,37 @@ def export_template( api_version=api_version, content_type=content_type, json=_json, - template_url=self.export_template.metadata['url'], + content=_content, + template_url=self.export_template.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) - deserialized = self._deserialize('ResourceGroupExportResult', pipeline_response) + deserialized = self._deserialize("ResourceGroupExportResult", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - export_template.metadata = {'url': "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/exportTemplate"} # type: ignore - + export_template.metadata = {"url": "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/exportTemplate"} # type: ignore @distributed_trace def list( - self, - filter: Optional[str] = None, - top: Optional[int] = None, - **kwargs: Any - ) -> Iterable["_models.ResourceGroupListResult"]: + self, filter: Optional[str] = None, top: Optional[int] = None, **kwargs: Any + ) -> Iterable["_models.ResourceGroup"]: """Gets a collection of resource groups. :param filter: The filter to apply on the operation. Default value is None. @@ -2815,40 +2984,48 @@ def list( None. :type top: int :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either ResourceGroupListResult or the result of - cls(response) + :return: An iterator like instance of either ResourceGroup or the result of cls(response) :rtype: - ~azure.core.paging.ItemPaged[~azure.mgmt.resource.resources.v2016_02_01.models.ResourceGroupListResult] - :raises: ~azure.core.exceptions.HttpResponseError + ~azure.core.paging.ItemPaged[~azure.mgmt.resource.resources.v2016_02_01.models.ResourceGroup] + :raises ~azure.core.exceptions.HttpResponseError: """ - api_version = kwargs.pop('api_version', "2016-02-01") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2016-02-01")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[_models.ResourceGroupListResult] - cls = kwargs.pop('cls', None) # type: ClsType["_models.ResourceGroupListResult"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) + def prepare_request(next_link=None): if not next_link: - + request = build_resource_groups_list_request( subscription_id=self._config.subscription_id, - api_version=api_version, filter=filter, top=top, - template_url=self.list.metadata['url'], + 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.url = self._client.format_url(request.url) # type: ignore else: - - request = build_resource_groups_list_request( - subscription_id=self._config.subscription_id, - template_url=next_link, - ) + # make call to next link with the client's api-version + _parsed_next_link = urlparse(next_link) + _next_request_params = case_insensitive_dict(parse_qs(_parsed_next_link.query)) + _next_request_params["api-version"] = self._config.api_version + request = HttpRequest("GET", urljoin(next_link, _parsed_next_link.path), params=_next_request_params) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore request.method = "GET" return request @@ -2862,10 +3039,8 @@ def extract_data(pipeline_response): def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) response = pipeline_response.http_response @@ -2875,66 +3050,74 @@ def get_next(next_link=None): return pipeline_response + return ItemPaged(get_next, extract_data) - return ItemPaged( - get_next, extract_data - ) - list.metadata = {'url': "/subscriptions/{subscriptionId}/resourcegroups"} # type: ignore -class ResourcesOperations(object): - """ResourcesOperations operations. - - You should not instantiate this class directly. Instead, you should create a Client instance that - instantiates it for you and attaches it as an attribute. - - :ivar models: Alias to model classes used in this operation group. - :type models: ~azure.mgmt.resource.resources.v2016_02_01.models - :param client: Client for service requests. - :param config: Configuration of service client. - :param serializer: An object model serializer. - :param deserializer: An object model deserializer. + list.metadata = {"url": "/subscriptions/{subscriptionId}/resourcegroups"} # type: ignore + + +class ResourcesOperations: """ + .. warning:: + **DO NOT** instantiate this class directly. - models = _models + Instead, you should access the following operations through + :class:`~azure.mgmt.resource.resources.v2016_02_01.ResourceManagementClient`'s + :attr:`resources` attribute. + """ - def __init__(self, client, config, serializer, deserializer): - self._client = client - self._serialize = serializer - self._deserialize = deserializer - self._config = config + models = _models - def _move_resources_initial( # pylint: disable=inconsistent-return-statements - self, - source_resource_group_name: str, - parameters: "_models.ResourcesMoveInfo", - **kwargs: Any + def __init__(self, *args, **kwargs): + input_args = list(args) + self._client = input_args.pop(0) if input_args else kwargs.pop("client") + self._config = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") + + def _move_resources_initial( # pylint: disable=inconsistent-return-statements + self, source_resource_group_name: str, parameters: Union[_models.ResourcesMoveInfo, IO], **kwargs: Any ) -> None: - cls = kwargs.pop('cls', None) # type: ClsType[None] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) - api_version = kwargs.pop('api_version', "2016-02-01") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - _json = self._serialize.body(parameters, 'ResourcesMoveInfo') + api_version = kwargs.pop("api_version", _params.pop("api-version", "2016-02-01")) # type: str + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[None] - request = build_resources_move_resources_request_initial( + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(parameters, (IO, bytes)): + _content = parameters + else: + _json = self._serialize.body(parameters, "ResourcesMoveInfo") + + request = build_resources_move_resources_request( source_resource_group_name=source_resource_group_name, subscription_id=self._config.subscription_id, api_version=api_version, content_type=content_type, json=_json, - template_url=self._move_resources_initial.metadata['url'], + content=_content, + template_url=self._move_resources_initial.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [202, 204]: @@ -2944,23 +3127,27 @@ def _move_resources_initial( # pylint: disable=inconsistent-return-statements if cls: return cls(pipeline_response, None, {}) - _move_resources_initial.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{sourceResourceGroupName}/moveResources"} # type: ignore + _move_resources_initial.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{sourceResourceGroupName}/moveResources"} # type: ignore - - @distributed_trace - def begin_move_resources( # pylint: disable=inconsistent-return-statements + @overload + def begin_move_resources( self, source_resource_group_name: str, - parameters: "_models.ResourcesMoveInfo", + parameters: _models.ResourcesMoveInfo, + *, + content_type: str = "application/json", **kwargs: Any ) -> LROPoller[None]: """Move resources from one resource group to another. The resources being moved should all be in the same resource group. - :param source_resource_group_name: Source resource group name. + :param source_resource_group_name: Source resource group name. Required. :type source_resource_group_name: str - :param parameters: move resources' parameters. + :param parameters: move resources' parameters. Required. :type parameters: ~azure.mgmt.resource.resources.v2016_02_01.models.ResourcesMoveInfo + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str :keyword callable cls: A custom type or function that will be passed the direct response :keyword str continuation_token: A continuation token to restart a poller from a saved state. :keyword polling: By default, your polling method will be ARMPolling. Pass in False for this @@ -2971,55 +3158,109 @@ def begin_move_resources( # pylint: disable=inconsistent-return-statements Retry-After header is present. :return: An instance of LROPoller that returns either None or the result of cls(response) :rtype: ~azure.core.polling.LROPoller[None] - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - api_version = kwargs.pop('api_version', "2016-02-01") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] - polling = kwargs.pop('polling', True) # type: Union[bool, PollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType[None] - lro_delay = kwargs.pop( - 'polling_interval', - self._config.polling_interval - ) - cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] + + @overload + def begin_move_resources( + self, source_resource_group_name: str, parameters: IO, *, content_type: str = "application/json", **kwargs: Any + ) -> LROPoller[None]: + """Move resources from one resource group to another. The resources being moved should all be in + the same resource group. + + :param source_resource_group_name: Source resource group name. Required. + :type source_resource_group_name: str + :param parameters: move resources' parameters. Required. + :type parameters: IO + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be ARMPolling. Pass in False for this + operation to not poll, or pass in your own initialized polling object for a personal polling + strategy. + :paramtype polling: bool or ~azure.core.polling.PollingMethod + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of LROPoller that returns either None or the result of cls(response) + :rtype: ~azure.core.polling.LROPoller[None] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace + def begin_move_resources( + self, source_resource_group_name: str, parameters: Union[_models.ResourcesMoveInfo, IO], **kwargs: Any + ) -> LROPoller[None]: + """Move resources from one resource group to another. The resources being moved should all be in + the same resource group. + + :param source_resource_group_name: Source resource group name. Required. + :type source_resource_group_name: str + :param parameters: move resources' parameters. Is either a model type or a IO type. Required. + :type parameters: ~azure.mgmt.resource.resources.v2016_02_01.models.ResourcesMoveInfo or IO + :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. + Default value is None. + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be ARMPolling. Pass in False for this + operation to not poll, or pass in your own initialized polling object for a personal polling + strategy. + :paramtype polling: bool or ~azure.core.polling.PollingMethod + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of LROPoller that returns either None or the result of cls(response) + :rtype: ~azure.core.polling.LROPoller[None] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _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", "2016-02-01")) # type: str + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[None] + polling = kwargs.pop("polling", True) # type: Union[bool, PollingMethod] + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token = kwargs.pop("continuation_token", None) # type: Optional[str] if cont_token is None: - raw_result = self._move_resources_initial( + raw_result = self._move_resources_initial( # type: ignore source_resource_group_name=source_resource_group_name, parameters=parameters, api_version=api_version, content_type=content_type, - cls=lambda x,y,z: x, + cls=lambda x, y, z: x, + headers=_headers, + params=_params, **kwargs ) - kwargs.pop('error_map', None) + kwargs.pop("error_map", None) - def get_long_running_output(pipeline_response): + def get_long_running_output(pipeline_response): # pylint: disable=inconsistent-return-statements if cls: return cls(pipeline_response, None, {}) - - if polling is True: polling_method = ARMPolling(lro_delay, **kwargs) - elif polling is False: polling_method = NoPolling() - else: polling_method = polling + if polling is True: + polling_method = cast(PollingMethod, ARMPolling(lro_delay, **kwargs)) # type: PollingMethod + elif polling is False: + polling_method = cast(PollingMethod, NoPolling()) + else: + polling_method = polling if cont_token: return LROPoller.from_continuation_token( polling_method=polling_method, continuation_token=cont_token, client=self._client, - deserialization_callback=get_long_running_output + deserialization_callback=get_long_running_output, ) return LROPoller(self._client, raw_result, get_long_running_output, polling_method) - begin_move_resources.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{sourceResourceGroupName}/moveResources"} # type: ignore + begin_move_resources.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{sourceResourceGroupName}/moveResources"} # type: ignore @distributed_trace def list( - self, - filter: Optional[str] = None, - expand: Optional[str] = None, - top: Optional[int] = None, - **kwargs: Any - ) -> Iterable["_models.ResourceListResult"]: + self, filter: Optional[str] = None, expand: Optional[str] = None, top: Optional[int] = None, **kwargs: Any + ) -> Iterable["_models.GenericResourceExpanded"]: """Get all of the resources under a subscription. :param filter: The filter to apply on the operation. Default value is None. @@ -3032,40 +3273,50 @@ def list( value is None. :type top: int :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either ResourceListResult or the result of cls(response) + :return: An iterator like instance of either GenericResourceExpanded or the result of + cls(response) :rtype: - ~azure.core.paging.ItemPaged[~azure.mgmt.resource.resources.v2016_02_01.models.ResourceListResult] - :raises: ~azure.core.exceptions.HttpResponseError + ~azure.core.paging.ItemPaged[~azure.mgmt.resource.resources.v2016_02_01.models.GenericResourceExpanded] + :raises ~azure.core.exceptions.HttpResponseError: """ - api_version = kwargs.pop('api_version', "2016-02-01") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2016-02-01")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[_models.ResourceListResult] - cls = kwargs.pop('cls', None) # type: ClsType["_models.ResourceListResult"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) + def prepare_request(next_link=None): if not next_link: - + request = build_resources_list_request( subscription_id=self._config.subscription_id, - api_version=api_version, filter=filter, expand=expand, top=top, - template_url=self.list.metadata['url'], + 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.url = self._client.format_url(request.url) # type: ignore else: - - request = build_resources_list_request( - subscription_id=self._config.subscription_id, - template_url=next_link, - ) + # make call to next link with the client's api-version + _parsed_next_link = urlparse(next_link) + _next_request_params = case_insensitive_dict(parse_qs(_parsed_next_link.query)) + _next_request_params["api-version"] = self._config.api_version + request = HttpRequest("GET", urljoin(next_link, _parsed_next_link.path), params=_next_request_params) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore request.method = "GET" return request @@ -3079,10 +3330,8 @@ def extract_data(pipeline_response): def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) response = pipeline_response.http_response @@ -3092,11 +3341,9 @@ def get_next(next_link=None): return pipeline_response + return ItemPaged(get_next, extract_data) - return ItemPaged( - get_next, extract_data - ) - list.metadata = {'url': "/subscriptions/{subscriptionId}/resources"} # type: ignore + list.metadata = {"url": "/subscriptions/{subscriptionId}/resources"} # type: ignore @distributed_trace def check_existence( @@ -3112,29 +3359,36 @@ def check_existence( """Checks whether resource exists. :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. :type resource_group_name: str - :param resource_provider_namespace: Resource identity. + :param resource_provider_namespace: Resource identity. Required. :type resource_provider_namespace: str - :param parent_resource_path: Resource identity. + :param parent_resource_path: Resource identity. Required. :type parent_resource_path: str - :param resource_type: Resource identity. + :param resource_type: Resource identity. Required. :type resource_type: str - :param resource_name: Resource identity. + :param resource_name: Resource identity. Required. :type resource_name: str - :param api_version: + :param api_version: Required. :type api_version: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: bool, or the result of cls(response) + :return: bool or the result of cls(response) :rtype: bool - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType[None] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = kwargs.pop("params", {}) or {} + + cls = kwargs.pop("cls", None) # type: ClsType[None] - request = build_resources_check_existence_request( resource_group_name=resource_group_name, resource_provider_namespace=resource_provider_namespace, @@ -3143,16 +3397,17 @@ def check_existence( resource_name=resource_name, subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.check_existence.metadata['url'], + template_url=self.check_existence.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [204, 404]: @@ -3163,8 +3418,7 @@ def check_existence( return cls(pipeline_response, None, {}) return 200 <= response.status_code <= 299 - check_existence.metadata = {'url': "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{parentResourcePath}/{resourceType}/{resourceName}"} # type: ignore - + check_existence.metadata = {"url": "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{parentResourcePath}/{resourceType}/{resourceName}"} # type: ignore @distributed_trace def delete( # pylint: disable=inconsistent-return-statements @@ -3180,29 +3434,36 @@ def delete( # pylint: disable=inconsistent-return-statements """Delete resource and all of its resources. :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. :type resource_group_name: str - :param resource_provider_namespace: Resource identity. + :param resource_provider_namespace: Resource identity. Required. :type resource_provider_namespace: str - :param parent_resource_path: Resource identity. + :param parent_resource_path: Resource identity. Required. :type parent_resource_path: str - :param resource_type: Resource identity. + :param resource_type: Resource identity. Required. :type resource_type: str - :param resource_name: Resource identity. + :param resource_name: Resource identity. Required. :type resource_name: str - :param api_version: + :param api_version: Required. :type api_version: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: None, or the result of cls(response) + :return: None or the result of cls(response) :rtype: None - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType[None] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = kwargs.pop("params", {}) or {} + + cls = kwargs.pop("cls", None) # type: ClsType[None] - request = build_resources_delete_request( resource_group_name=resource_group_name, resource_provider_namespace=resource_provider_namespace, @@ -3211,16 +3472,17 @@ def delete( # pylint: disable=inconsistent-return-statements resource_name=resource_name, subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.delete.metadata['url'], + template_url=self.delete.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200, 202, 204]: @@ -3230,8 +3492,87 @@ def delete( # pylint: disable=inconsistent-return-statements if cls: return cls(pipeline_response, None, {}) - delete.metadata = {'url': "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{parentResourcePath}/{resourceType}/{resourceName}"} # type: ignore + delete.metadata = {"url": "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{parentResourcePath}/{resourceType}/{resourceName}"} # type: ignore + + @overload + def create_or_update( + self, + resource_group_name: str, + resource_provider_namespace: str, + parent_resource_path: str, + resource_type: str, + resource_name: str, + api_version: str, + parameters: _models.GenericResource, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.GenericResource: + """Create a resource. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param resource_provider_namespace: Resource identity. Required. + :type resource_provider_namespace: str + :param parent_resource_path: Resource identity. Required. + :type parent_resource_path: str + :param resource_type: Resource identity. Required. + :type resource_type: str + :param resource_name: Resource identity. Required. + :type resource_name: str + :param api_version: Required. + :type api_version: str + :param parameters: Create or update resource parameters. Required. + :type parameters: ~azure.mgmt.resource.resources.v2016_02_01.models.GenericResource + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: GenericResource or the result of cls(response) + :rtype: ~azure.mgmt.resource.resources.v2016_02_01.models.GenericResource + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + def create_or_update( + self, + resource_group_name: str, + resource_provider_namespace: str, + parent_resource_path: str, + resource_type: str, + resource_name: str, + api_version: str, + parameters: IO, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.GenericResource: + """Create a resource. + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param resource_provider_namespace: Resource identity. Required. + :type resource_provider_namespace: str + :param parent_resource_path: Resource identity. Required. + :type parent_resource_path: str + :param resource_type: Resource identity. Required. + :type resource_type: str + :param resource_name: Resource identity. Required. + :type resource_name: str + :param api_version: Required. + :type api_version: str + :param parameters: Create or update resource parameters. Required. + :type parameters: IO + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: GenericResource or the result of cls(response) + :rtype: ~azure.mgmt.resource.resources.v2016_02_01.models.GenericResource + :raises ~azure.core.exceptions.HttpResponseError: + """ @distributed_trace def create_or_update( @@ -3242,39 +3583,56 @@ def create_or_update( resource_type: str, resource_name: str, api_version: str, - parameters: "_models.GenericResource", + parameters: Union[_models.GenericResource, IO], **kwargs: Any - ) -> "_models.GenericResource": + ) -> _models.GenericResource: """Create a resource. :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. :type resource_group_name: str - :param resource_provider_namespace: Resource identity. + :param resource_provider_namespace: Resource identity. Required. :type resource_provider_namespace: str - :param parent_resource_path: Resource identity. + :param parent_resource_path: Resource identity. Required. :type parent_resource_path: str - :param resource_type: Resource identity. + :param resource_type: Resource identity. Required. :type resource_type: str - :param resource_name: Resource identity. + :param resource_name: Resource identity. Required. :type resource_name: str - :param api_version: + :param api_version: Required. :type api_version: str - :param parameters: Create or update resource parameters. - :type parameters: ~azure.mgmt.resource.resources.v2016_02_01.models.GenericResource + :param parameters: Create or update resource parameters. Is either a model type or a IO type. + Required. + :type parameters: ~azure.mgmt.resource.resources.v2016_02_01.models.GenericResource or IO + :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. + Default value is None. + :paramtype content_type: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: GenericResource, or the result of cls(response) + :return: GenericResource or the result of cls(response) :rtype: ~azure.mgmt.resource.resources.v2016_02_01.models.GenericResource - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.GenericResource"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = kwargs.pop("params", {}) or {} - _json = self._serialize.body(parameters, 'GenericResource') + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.GenericResource] + + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(parameters, (IO, bytes)): + _content = parameters + else: + _json = self._serialize.body(parameters, "GenericResource") request = build_resources_create_or_update_request( resource_group_name=resource_group_name, @@ -3283,19 +3641,21 @@ def create_or_update( resource_type=resource_type, resource_name=resource_name, subscription_id=self._config.subscription_id, - content_type=content_type, api_version=api_version, + content_type=content_type, json=_json, - template_url=self.create_or_update.metadata['url'], + content=_content, + template_url=self.create_or_update.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200, 201]: @@ -3303,18 +3663,17 @@ def create_or_update( raise HttpResponseError(response=response, error_format=ARMErrorFormat) if response.status_code == 200: - deserialized = self._deserialize('GenericResource', pipeline_response) + deserialized = self._deserialize("GenericResource", pipeline_response) if response.status_code == 201: - deserialized = self._deserialize('GenericResource', pipeline_response) + deserialized = self._deserialize("GenericResource", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - create_or_update.metadata = {'url': "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{parentResourcePath}/{resourceType}/{resourceName}"} # type: ignore - + create_or_update.metadata = {"url": "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{parentResourcePath}/{resourceType}/{resourceName}"} # type: ignore def _update_initial( self, @@ -3324,39 +3683,53 @@ def _update_initial( resource_type: str, resource_name: str, api_version: str, - parameters: "_models.GenericResource", + parameters: Union[_models.GenericResource, IO], **kwargs: Any - ) -> Optional["_models.GenericResource"]: - cls = kwargs.pop('cls', None) # type: ClsType[Optional["_models.GenericResource"]] + ) -> Optional[_models.GenericResource]: error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = kwargs.pop("params", {}) or {} - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[Optional[_models.GenericResource]] - _json = self._serialize.body(parameters, 'GenericResource') + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(parameters, (IO, bytes)): + _content = parameters + else: + _json = self._serialize.body(parameters, "GenericResource") - request = build_resources_update_request_initial( + request = build_resources_update_request( resource_group_name=resource_group_name, resource_provider_namespace=resource_provider_namespace, parent_resource_path=parent_resource_path, resource_type=resource_type, resource_name=resource_name, subscription_id=self._config.subscription_id, - content_type=content_type, api_version=api_version, + content_type=content_type, json=_json, - template_url=self._update_initial.metadata['url'], + content=_content, + template_url=self._update_initial.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200, 202]: @@ -3365,15 +3738,112 @@ def _update_initial( deserialized = None if response.status_code == 200: - deserialized = self._deserialize('GenericResource', pipeline_response) + deserialized = self._deserialize("GenericResource", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - _update_initial.metadata = {'url': "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{parentResourcePath}/{resourceType}/{resourceName}"} # type: ignore + _update_initial.metadata = {"url": "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{parentResourcePath}/{resourceType}/{resourceName}"} # type: ignore + + @overload + def begin_update( + self, + resource_group_name: str, + resource_provider_namespace: str, + parent_resource_path: str, + resource_type: str, + resource_name: str, + api_version: str, + parameters: _models.GenericResource, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> LROPoller[_models.GenericResource]: + """Updates a resource. + + :param resource_group_name: The name of the resource group for the resource. The name is case + insensitive. Required. + :type resource_group_name: str + :param resource_provider_namespace: The namespace of the resource provider. Required. + :type resource_provider_namespace: str + :param parent_resource_path: The parent resource identity. Required. + :type parent_resource_path: str + :param resource_type: The resource type of the resource to update. Required. + :type resource_type: str + :param resource_name: The name of the resource to update. Required. + :type resource_name: str + :param api_version: The API version to use for the operation. Required. + :type api_version: str + :param parameters: Parameters for updating the resource. Required. + :type parameters: ~azure.mgmt.resource.resources.v2016_02_01.models.GenericResource + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be ARMPolling. Pass in False for this + operation to not poll, or pass in your own initialized polling object for a personal polling + strategy. + :paramtype polling: bool or ~azure.core.polling.PollingMethod + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of LROPoller that returns either GenericResource or the result of + cls(response) + :rtype: + ~azure.core.polling.LROPoller[~azure.mgmt.resource.resources.v2016_02_01.models.GenericResource] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + def begin_update( + self, + resource_group_name: str, + resource_provider_namespace: str, + parent_resource_path: str, + resource_type: str, + resource_name: str, + api_version: str, + parameters: IO, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> LROPoller[_models.GenericResource]: + """Updates a resource. + :param resource_group_name: The name of the resource group for the resource. The name is case + insensitive. Required. + :type resource_group_name: str + :param resource_provider_namespace: The namespace of the resource provider. Required. + :type resource_provider_namespace: str + :param parent_resource_path: The parent resource identity. Required. + :type parent_resource_path: str + :param resource_type: The resource type of the resource to update. Required. + :type resource_type: str + :param resource_name: The name of the resource to update. Required. + :type resource_name: str + :param api_version: The API version to use for the operation. Required. + :type api_version: str + :param parameters: Parameters for updating the resource. Required. + :type parameters: IO + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be ARMPolling. Pass in False for this + operation to not poll, or pass in your own initialized polling object for a personal polling + strategy. + :paramtype polling: bool or ~azure.core.polling.PollingMethod + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of LROPoller that returns either GenericResource or the result of + cls(response) + :rtype: + ~azure.core.polling.LROPoller[~azure.mgmt.resource.resources.v2016_02_01.models.GenericResource] + :raises ~azure.core.exceptions.HttpResponseError: + """ @distributed_trace def begin_update( @@ -3384,26 +3854,30 @@ def begin_update( resource_type: str, resource_name: str, api_version: str, - parameters: "_models.GenericResource", + parameters: Union[_models.GenericResource, IO], **kwargs: Any - ) -> LROPoller["_models.GenericResource"]: + ) -> LROPoller[_models.GenericResource]: """Updates a resource. :param resource_group_name: The name of the resource group for the resource. The name is case - insensitive. + insensitive. Required. :type resource_group_name: str - :param resource_provider_namespace: The namespace of the resource provider. + :param resource_provider_namespace: The namespace of the resource provider. Required. :type resource_provider_namespace: str - :param parent_resource_path: The parent resource identity. + :param parent_resource_path: The parent resource identity. Required. :type parent_resource_path: str - :param resource_type: The resource type of the resource to update. + :param resource_type: The resource type of the resource to update. Required. :type resource_type: str - :param resource_name: The name of the resource to update. + :param resource_name: The name of the resource to update. Required. :type resource_name: str - :param api_version: The API version to use for the operation. + :param api_version: The API version to use for the operation. Required. :type api_version: str - :param parameters: Parameters for updating the resource. - :type parameters: ~azure.mgmt.resource.resources.v2016_02_01.models.GenericResource + :param parameters: Parameters for updating the resource. Is either a model type or a IO type. + Required. + :type parameters: ~azure.mgmt.resource.resources.v2016_02_01.models.GenericResource or IO + :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. + Default value is None. + :paramtype content_type: str :keyword callable cls: A custom type or function that will be passed the direct response :keyword str continuation_token: A continuation token to restart a poller from a saved state. :keyword polling: By default, your polling method will be ARMPolling. Pass in False for this @@ -3416,18 +3890,18 @@ def begin_update( cls(response) :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.resource.resources.v2016_02_01.models.GenericResource] - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] - polling = kwargs.pop('polling', True) # type: Union[bool, PollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType["_models.GenericResource"] - lro_delay = kwargs.pop( - 'polling_interval', - self._config.polling_interval - ) - cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = kwargs.pop("params", {}) or {} + + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.GenericResource] + polling = kwargs.pop("polling", True) # type: Union[bool, PollingMethod] + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token = kwargs.pop("continuation_token", None) # type: Optional[str] if cont_token is None: - raw_result = self._update_initial( + raw_result = self._update_initial( # type: ignore resource_group_name=resource_group_name, resource_provider_namespace=resource_provider_namespace, parent_resource_path=parent_resource_path, @@ -3436,32 +3910,35 @@ def begin_update( api_version=api_version, parameters=parameters, content_type=content_type, - cls=lambda x,y,z: x, + cls=lambda x, y, z: x, + headers=_headers, + params=_params, **kwargs ) - kwargs.pop('error_map', None) + kwargs.pop("error_map", None) def get_long_running_output(pipeline_response): - response = pipeline_response.http_response - deserialized = self._deserialize('GenericResource', pipeline_response) + deserialized = self._deserialize("GenericResource", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - - if polling is True: polling_method = ARMPolling(lro_delay, **kwargs) - elif polling is False: polling_method = NoPolling() - else: polling_method = polling + if polling is True: + polling_method = cast(PollingMethod, ARMPolling(lro_delay, **kwargs)) # type: PollingMethod + elif polling is False: + polling_method = cast(PollingMethod, NoPolling()) + else: + polling_method = polling if cont_token: return LROPoller.from_continuation_token( polling_method=polling_method, continuation_token=cont_token, client=self._client, - deserialization_callback=get_long_running_output + deserialization_callback=get_long_running_output, ) return LROPoller(self._client, raw_result, get_long_running_output, polling_method) - begin_update.metadata = {'url': "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{parentResourcePath}/{resourceType}/{resourceName}"} # type: ignore + begin_update.metadata = {"url": "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{parentResourcePath}/{resourceType}/{resourceName}"} # type: ignore @distributed_trace def get( @@ -3473,33 +3950,40 @@ def get( resource_name: str, api_version: str, **kwargs: Any - ) -> "_models.GenericResource": + ) -> _models.GenericResource: """Returns a resource belonging to a resource group. :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. :type resource_group_name: str - :param resource_provider_namespace: Resource identity. + :param resource_provider_namespace: Resource identity. Required. :type resource_provider_namespace: str - :param parent_resource_path: Resource identity. + :param parent_resource_path: Resource identity. Required. :type parent_resource_path: str - :param resource_type: Resource identity. + :param resource_type: Resource identity. Required. :type resource_type: str - :param resource_name: Resource identity. + :param resource_name: Resource identity. Required. :type resource_name: str - :param api_version: + :param api_version: Required. :type api_version: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: GenericResource, or the result of cls(response) + :return: GenericResource or the result of cls(response) :rtype: ~azure.mgmt.resource.resources.v2016_02_01.models.GenericResource - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.GenericResource"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = kwargs.pop("params", {}) or {} + + cls = kwargs.pop("cls", None) # type: ClsType[_models.GenericResource] - request = build_resources_get_request( resource_group_name=resource_group_name, resource_provider_namespace=resource_provider_namespace, @@ -3508,95 +3992,97 @@ def get( resource_name=resource_name, subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.get.metadata['url'], + template_url=self.get.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) - deserialized = self._deserialize('GenericResource', pipeline_response) + deserialized = self._deserialize("GenericResource", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - get.metadata = {'url': "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{parentResourcePath}/{resourceType}/{resourceName}"} # type: ignore + get.metadata = {"url": "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{parentResourcePath}/{resourceType}/{resourceName}"} # type: ignore -class TagsOperations(object): - """TagsOperations operations. - You should not instantiate this class directly. Instead, you should create a Client instance that - instantiates it for you and attaches it as an attribute. +class TagsOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. - :ivar models: Alias to model classes used in this operation group. - :type models: ~azure.mgmt.resource.resources.v2016_02_01.models - :param client: Client for service requests. - :param config: Configuration of service client. - :param serializer: An object model serializer. - :param deserializer: An object model deserializer. + Instead, you should access the following operations through + :class:`~azure.mgmt.resource.resources.v2016_02_01.ResourceManagementClient`'s + :attr:`tags` attribute. """ models = _models - def __init__(self, client, config, serializer, deserializer): - self._client = client - self._serialize = serializer - self._deserialize = deserializer - self._config = config + def __init__(self, *args, **kwargs): + input_args = list(args) + self._client = input_args.pop(0) if input_args else kwargs.pop("client") + self._config = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") @distributed_trace def delete_value( # pylint: disable=inconsistent-return-statements - self, - tag_name: str, - tag_value: str, - **kwargs: Any + self, tag_name: str, tag_value: str, **kwargs: Any ) -> None: """Delete a subscription resource tag value. - :param tag_name: The name of the tag. + :param tag_name: The name of the tag. Required. :type tag_name: str - :param tag_value: The value of the tag. + :param tag_value: The value of the tag. Required. :type tag_value: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: None, or the result of cls(response) + :return: None or the result of cls(response) :rtype: None - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType[None] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + 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', "2016-02-01") # type: str + api_version = kwargs.pop("api_version", _params.pop("api-version", "2016-02-01")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[None] - request = build_tags_delete_value_request( tag_name=tag_name, tag_value=tag_value, subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.delete_value.metadata['url'], + template_url=self.delete_value.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200, 204]: @@ -3606,51 +4092,51 @@ def delete_value( # pylint: disable=inconsistent-return-statements if cls: return cls(pipeline_response, None, {}) - delete_value.metadata = {'url': "/subscriptions/{subscriptionId}/tagNames/{tagName}/tagValues/{tagValue}"} # type: ignore - + delete_value.metadata = {"url": "/subscriptions/{subscriptionId}/tagNames/{tagName}/tagValues/{tagValue}"} # type: ignore @distributed_trace - def create_or_update_value( - self, - tag_name: str, - tag_value: str, - **kwargs: Any - ) -> "_models.TagValue": + def create_or_update_value(self, tag_name: str, tag_value: str, **kwargs: Any) -> _models.TagValue: """Create a subscription resource tag value. - :param tag_name: The name of the tag. + :param tag_name: The name of the tag. Required. :type tag_name: str - :param tag_value: The value of the tag. + :param tag_value: The value of the tag. Required. :type tag_value: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: TagValue, or the result of cls(response) + :return: TagValue or the result of cls(response) :rtype: ~azure.mgmt.resource.resources.v2016_02_01.models.TagValue - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.TagValue"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) - api_version = kwargs.pop('api_version', "2016-02-01") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2016-02-01")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[_models.TagValue] - request = build_tags_create_or_update_value_request( tag_name=tag_name, tag_value=tag_value, subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.create_or_update_value.metadata['url'], + template_url=self.create_or_update_value.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200, 201]: @@ -3658,57 +4144,58 @@ def create_or_update_value( raise HttpResponseError(response=response, error_format=ARMErrorFormat) if response.status_code == 200: - deserialized = self._deserialize('TagValue', pipeline_response) + deserialized = self._deserialize("TagValue", pipeline_response) if response.status_code == 201: - deserialized = self._deserialize('TagValue', pipeline_response) + deserialized = self._deserialize("TagValue", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - create_or_update_value.metadata = {'url': "/subscriptions/{subscriptionId}/tagNames/{tagName}/tagValues/{tagValue}"} # type: ignore - + create_or_update_value.metadata = {"url": "/subscriptions/{subscriptionId}/tagNames/{tagName}/tagValues/{tagValue}"} # type: ignore @distributed_trace - def create_or_update( - self, - tag_name: str, - **kwargs: Any - ) -> "_models.TagDetails": + def create_or_update(self, tag_name: str, **kwargs: Any) -> _models.TagDetails: """Create a subscription resource tag. - :param tag_name: The name of the tag. + :param tag_name: The name of the tag. Required. :type tag_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: TagDetails, or the result of cls(response) + :return: TagDetails or the result of cls(response) :rtype: ~azure.mgmt.resource.resources.v2016_02_01.models.TagDetails - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.TagDetails"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) - api_version = kwargs.pop('api_version', "2016-02-01") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2016-02-01")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[_models.TagDetails] - request = build_tags_create_or_update_request( tag_name=tag_name, subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.create_or_update.metadata['url'], + template_url=self.create_or_update.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200, 201]: @@ -3716,57 +4203,58 @@ def create_or_update( raise HttpResponseError(response=response, error_format=ARMErrorFormat) if response.status_code == 200: - deserialized = self._deserialize('TagDetails', pipeline_response) + deserialized = self._deserialize("TagDetails", pipeline_response) if response.status_code == 201: - deserialized = self._deserialize('TagDetails', pipeline_response) + deserialized = self._deserialize("TagDetails", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - create_or_update.metadata = {'url': "/subscriptions/{subscriptionId}/tagNames/{tagName}"} # type: ignore - + create_or_update.metadata = {"url": "/subscriptions/{subscriptionId}/tagNames/{tagName}"} # type: ignore @distributed_trace - def delete( # pylint: disable=inconsistent-return-statements - self, - tag_name: str, - **kwargs: Any - ) -> None: + def delete(self, tag_name: str, **kwargs: Any) -> None: # pylint: disable=inconsistent-return-statements """Delete a subscription resource tag. - :param tag_name: The name of the tag. + :param tag_name: The name of the tag. Required. :type tag_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: None, or the result of cls(response) + :return: None or the result of cls(response) :rtype: None - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType[None] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + 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', "2016-02-01") # type: str + api_version = kwargs.pop("api_version", _params.pop("api-version", "2016-02-01")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[None] - request = build_tags_delete_request( tag_name=tag_name, subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.delete.metadata['url'], + template_url=self.delete.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200, 204]: @@ -3776,48 +4264,53 @@ def delete( # pylint: disable=inconsistent-return-statements if cls: return cls(pipeline_response, None, {}) - delete.metadata = {'url': "/subscriptions/{subscriptionId}/tagNames/{tagName}"} # type: ignore - + delete.metadata = {"url": "/subscriptions/{subscriptionId}/tagNames/{tagName}"} # type: ignore @distributed_trace - def list( - self, - **kwargs: Any - ) -> Iterable["_models.TagsListResult"]: + def list(self, **kwargs: Any) -> Iterable["_models.TagDetails"]: """Get a list of subscription resource tags. :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either TagsListResult or the result of cls(response) + :return: An iterator like instance of either TagDetails or the result of cls(response) :rtype: - ~azure.core.paging.ItemPaged[~azure.mgmt.resource.resources.v2016_02_01.models.TagsListResult] - :raises: ~azure.core.exceptions.HttpResponseError + ~azure.core.paging.ItemPaged[~azure.mgmt.resource.resources.v2016_02_01.models.TagDetails] + :raises ~azure.core.exceptions.HttpResponseError: """ - api_version = kwargs.pop('api_version', "2016-02-01") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2016-02-01")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[_models.TagsListResult] - cls = kwargs.pop('cls', None) # type: ClsType["_models.TagsListResult"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) + def prepare_request(next_link=None): if not next_link: - + request = build_tags_list_request( subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.list.metadata['url'], + template_url=self.list.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore else: - - request = build_tags_list_request( - subscription_id=self._config.subscription_id, - template_url=next_link, - ) + # make call to next link with the client's api-version + _parsed_next_link = urlparse(next_link) + _next_request_params = case_insensitive_dict(parse_qs(_parsed_next_link.query)) + _next_request_params["api-version"] = self._config.api_version + request = HttpRequest("GET", urljoin(next_link, _parsed_next_link.path), params=_next_request_params) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore request.method = "GET" return request @@ -3831,10 +4324,8 @@ def extract_data(pipeline_response): def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) response = pipeline_response.http_response @@ -3844,149 +4335,151 @@ def get_next(next_link=None): return pipeline_response + return ItemPaged(get_next, extract_data) - return ItemPaged( - get_next, extract_data - ) - list.metadata = {'url': "/subscriptions/{subscriptionId}/tagNames"} # type: ignore -class DeploymentOperationsOperations(object): - """DeploymentOperationsOperations operations. - - You should not instantiate this class directly. Instead, you should create a Client instance that - instantiates it for you and attaches it as an attribute. - - :ivar models: Alias to model classes used in this operation group. - :type models: ~azure.mgmt.resource.resources.v2016_02_01.models - :param client: Client for service requests. - :param config: Configuration of service client. - :param serializer: An object model serializer. - :param deserializer: An object model deserializer. + list.metadata = {"url": "/subscriptions/{subscriptionId}/tagNames"} # type: ignore + + +class DeploymentOperationsOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. + + Instead, you should access the following operations through + :class:`~azure.mgmt.resource.resources.v2016_02_01.ResourceManagementClient`'s + :attr:`deployment_operations` attribute. """ models = _models - def __init__(self, client, config, serializer, deserializer): - self._client = client - self._serialize = serializer - self._deserialize = deserializer - self._config = config + def __init__(self, *args, **kwargs): + input_args = list(args) + self._client = input_args.pop(0) if input_args else kwargs.pop("client") + self._config = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") @distributed_trace def get( - self, - resource_group_name: str, - deployment_name: str, - operation_id: str, - **kwargs: Any - ) -> "_models.DeploymentOperation": + self, resource_group_name: str, deployment_name: str, operation_id: str, **kwargs: Any + ) -> _models.DeploymentOperation: """Get a list of deployments operations. :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. :type resource_group_name: str - :param deployment_name: The name of the deployment. + :param deployment_name: The name of the deployment. Required. :type deployment_name: str - :param operation_id: Operation Id. + :param operation_id: Operation Id. Required. :type operation_id: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: DeploymentOperation, or the result of cls(response) + :return: DeploymentOperation or the result of cls(response) :rtype: ~azure.mgmt.resource.resources.v2016_02_01.models.DeploymentOperation - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.DeploymentOperation"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + 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', "2016-02-01") # type: str + api_version = kwargs.pop("api_version", _params.pop("api-version", "2016-02-01")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[_models.DeploymentOperation] - request = build_deployment_operations_get_request( resource_group_name=resource_group_name, deployment_name=deployment_name, operation_id=operation_id, subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.get.metadata['url'], + template_url=self.get.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) - deserialized = self._deserialize('DeploymentOperation', pipeline_response) + deserialized = self._deserialize("DeploymentOperation", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - get.metadata = {'url': "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/deployments/{deploymentName}/operations/{operationId}"} # type: ignore - + get.metadata = {"url": "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/deployments/{deploymentName}/operations/{operationId}"} # type: ignore @distributed_trace def list( - self, - resource_group_name: str, - deployment_name: str, - top: Optional[int] = None, - **kwargs: Any - ) -> Iterable["_models.DeploymentOperationsListResult"]: + self, resource_group_name: str, deployment_name: str, top: Optional[int] = None, **kwargs: Any + ) -> Iterable["_models.DeploymentOperation"]: """Gets a list of deployments operations. :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. :type resource_group_name: str - :param deployment_name: The name of the deployment. + :param deployment_name: The name of the deployment. Required. :type deployment_name: str :param top: Query parameters. Default value is None. :type top: int :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either DeploymentOperationsListResult or the result of - cls(response) + :return: An iterator like instance of either DeploymentOperation or the result of cls(response) :rtype: - ~azure.core.paging.ItemPaged[~azure.mgmt.resource.resources.v2016_02_01.models.DeploymentOperationsListResult] - :raises: ~azure.core.exceptions.HttpResponseError + ~azure.core.paging.ItemPaged[~azure.mgmt.resource.resources.v2016_02_01.models.DeploymentOperation] + :raises ~azure.core.exceptions.HttpResponseError: """ - api_version = kwargs.pop('api_version', "2016-02-01") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2016-02-01")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[_models.DeploymentOperationsListResult] - cls = kwargs.pop('cls', None) # type: ClsType["_models.DeploymentOperationsListResult"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) + def prepare_request(next_link=None): if not next_link: - + request = build_deployment_operations_list_request( resource_group_name=resource_group_name, deployment_name=deployment_name, subscription_id=self._config.subscription_id, - api_version=api_version, top=top, - template_url=self.list.metadata['url'], + 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.url = self._client.format_url(request.url) # type: ignore else: - - request = build_deployment_operations_list_request( - resource_group_name=resource_group_name, - deployment_name=deployment_name, - subscription_id=self._config.subscription_id, - template_url=next_link, - ) + # make call to next link with the client's api-version + _parsed_next_link = urlparse(next_link) + _next_request_params = case_insensitive_dict(parse_qs(_parsed_next_link.query)) + _next_request_params["api-version"] = self._config.api_version + request = HttpRequest("GET", urljoin(next_link, _parsed_next_link.path), params=_next_request_params) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore request.method = "GET" return request @@ -4000,10 +4493,8 @@ def extract_data(pipeline_response): def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) response = pipeline_response.http_response @@ -4013,8 +4504,6 @@ def get_next(next_link=None): return pipeline_response + return ItemPaged(get_next, extract_data) - return ItemPaged( - get_next, extract_data - ) - list.metadata = {'url': "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/deployments/{deploymentName}/operations"} # type: ignore + list.metadata = {"url": "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/deployments/{deploymentName}/operations"} # type: ignore diff --git a/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/resources/v2016_02_01/operations/_patch.py b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/resources/v2016_02_01/operations/_patch.py new file mode 100644 index 0000000000000..f7dd32510333d --- /dev/null +++ b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/resources/v2016_02_01/operations/_patch.py @@ -0,0 +1,20 @@ +# ------------------------------------ +# Copyright (c) Microsoft Corporation. +# Licensed under the MIT License. +# ------------------------------------ +"""Customize generated code here. + +Follow our quickstart for examples: https://aka.ms/azsdk/python/dpcodegen/python/customize +""" +from typing import List + +__all__: List[str] = [] # Add all objects you want publicly available to users at this package level + + +def patch_sdk(): + """Do not remove from this file. + + `patch_sdk` is a last resort escape hatch that allows you to do customizations + you can't accomplish using the techniques described in + https://aka.ms/azsdk/python/dpcodegen/python/customize + """ diff --git a/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/resources/v2016_09_01/__init__.py b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/resources/v2016_09_01/__init__.py index 449220069f2f2..2b201470d075e 100644 --- a/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/resources/v2016_09_01/__init__.py +++ b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/resources/v2016_09_01/__init__.py @@ -10,9 +10,15 @@ from ._version import VERSION __version__ = VERSION -__all__ = ['ResourceManagementClient'] -# `._patch.py` is used for handwritten extensions to the generated code -# Example: https://github.com/Azure/azure-sdk-for-python/blob/main/doc/dev/customize_code/how-to-patch-sdk-code.md -from ._patch import patch_sdk -patch_sdk() +try: + from ._patch import __all__ as _patch_all + from ._patch import * # type: ignore # pylint: disable=unused-wildcard-import +except ImportError: + _patch_all = [] +from ._patch import patch_sdk as _patch_sdk + +__all__ = ["ResourceManagementClient"] +__all__.extend([p for p in _patch_all if p not in __all__]) + +_patch_sdk() diff --git a/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/resources/v2016_09_01/_configuration.py b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/resources/v2016_09_01/_configuration.py index d31d958b5884e..b09b52128d708 100644 --- a/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/resources/v2016_09_01/_configuration.py +++ b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/resources/v2016_09_01/_configuration.py @@ -25,23 +25,18 @@ class ResourceManagementClientConfiguration(Configuration): # pylint: disable=t Note that all parameters used to create this instance are saved as instance attributes. - :param credential: Credential needed for the client to connect to Azure. + :param credential: Credential needed for the client to connect to Azure. Required. :type credential: ~azure.core.credentials.TokenCredential - :param subscription_id: The ID of the target subscription. + :param subscription_id: The ID of the target subscription. Required. :type subscription_id: str :keyword api_version: Api Version. Default value is "2016-09-01". Note that overriding this default value may result in unsupported behavior. :paramtype api_version: str """ - def __init__( - self, - credential: "TokenCredential", - subscription_id: str, - **kwargs: Any - ) -> None: + def __init__(self, credential: "TokenCredential", subscription_id: str, **kwargs: Any) -> None: super(ResourceManagementClientConfiguration, self).__init__(**kwargs) - api_version = kwargs.pop('api_version', "2016-09-01") # type: str + api_version = kwargs.pop("api_version", "2016-09-01") # type: str if credential is None: raise ValueError("Parameter 'credential' must not be None.") @@ -51,23 +46,24 @@ def __init__( self.credential = credential self.subscription_id = subscription_id self.api_version = api_version - self.credential_scopes = kwargs.pop('credential_scopes', ['https://management.azure.com/.default']) - kwargs.setdefault('sdk_moniker', 'mgmt-resource/{}'.format(VERSION)) + self.credential_scopes = kwargs.pop("credential_scopes", ["https://management.azure.com/.default"]) + kwargs.setdefault("sdk_moniker", "mgmt-resource/{}".format(VERSION)) self._configure(**kwargs) def _configure( - self, - **kwargs # type: Any + self, **kwargs # type: Any ): # type: (...) -> 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) - self.logging_policy = kwargs.get('logging_policy') or policies.NetworkTraceLoggingPolicy(**kwargs) - self.http_logging_policy = kwargs.get('http_logging_policy') or ARMHttpLoggingPolicy(**kwargs) - self.retry_policy = kwargs.get('retry_policy') or policies.RetryPolicy(**kwargs) - self.custom_hook_policy = kwargs.get('custom_hook_policy') or policies.CustomHookPolicy(**kwargs) - self.redirect_policy = kwargs.get('redirect_policy') or policies.RedirectPolicy(**kwargs) - self.authentication_policy = kwargs.get('authentication_policy') + 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) + self.logging_policy = kwargs.get("logging_policy") or policies.NetworkTraceLoggingPolicy(**kwargs) + self.http_logging_policy = kwargs.get("http_logging_policy") or ARMHttpLoggingPolicy(**kwargs) + self.retry_policy = kwargs.get("retry_policy") or policies.RetryPolicy(**kwargs) + self.custom_hook_policy = kwargs.get("custom_hook_policy") or policies.CustomHookPolicy(**kwargs) + self.redirect_policy = kwargs.get("redirect_policy") or policies.RedirectPolicy(**kwargs) + self.authentication_policy = kwargs.get("authentication_policy") if self.credential and not self.authentication_policy: - self.authentication_policy = ARMChallengeAuthenticationPolicy(self.credential, *self.credential_scopes, **kwargs) + self.authentication_policy = ARMChallengeAuthenticationPolicy( + self.credential, *self.credential_scopes, **kwargs + ) diff --git a/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/resources/v2016_09_01/_metadata.json b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/resources/v2016_09_01/_metadata.json index bb05ed78ad4f8..0219ab23053b5 100644 --- a/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/resources/v2016_09_01/_metadata.json +++ b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/resources/v2016_09_01/_metadata.json @@ -10,20 +10,20 @@ "azure_arm": true, "has_lro_operations": true, "client_side_validation": false, - "sync_imports": "{\"typing\": {\"azurecore\": {\"azure.core.credentials\": [\"TokenCredential\"]}}, \"regular\": {\"azurecore\": {\"azure.profiles\": [\"KnownProfiles\", \"ProfileDefinition\"], \"azure.profiles.multiapiclient\": [\"MultiApiClientMixin\"], \"azure.mgmt.core\": [\"ARMPipelineClient\"]}, \"local\": {\"._configuration\": [\"ResourceManagementClientConfiguration\"]}, \"thirdparty\": {\"msrest\": [\"Deserializer\", \"Serializer\"]}}, \"conditional\": {\"stdlib\": {\"typing\": [\"Any\", \"Optional\"]}}}", - "async_imports": "{\"typing\": {\"azurecore\": {\"azure.core.credentials_async\": [\"AsyncTokenCredential\"], \"azure.core.credentials\": [\"TokenCredential\"]}}, \"regular\": {\"azurecore\": {\"azure.profiles\": [\"KnownProfiles\", \"ProfileDefinition\"], \"azure.profiles.multiapiclient\": [\"MultiApiClientMixin\"], \"azure.mgmt.core\": [\"AsyncARMPipelineClient\"]}, \"local\": {\"._configuration\": [\"ResourceManagementClientConfiguration\"]}, \"thirdparty\": {\"msrest\": [\"Deserializer\", \"Serializer\"]}}, \"conditional\": {\"stdlib\": {\"typing\": [\"Any\", \"Optional\"]}}}" + "sync_imports": "{\"conditional\": {\"stdlib\": {\"typing\": [\"Any\", \"Optional\"]}}, \"regular\": {\"azurecore\": {\"azure.mgmt.core\": [\"ARMPipelineClient\"], \"azure.profiles\": [\"KnownProfiles\", \"ProfileDefinition\"], \"azure.profiles.multiapiclient\": [\"MultiApiClientMixin\"]}, \"local\": {\"._configuration\": [\"ResourceManagementClientConfiguration\"], \".._serialization\": [\"Deserializer\", \"Serializer\"]}}, \"typing\": {\"azurecore\": {\"azure.core.credentials\": [\"TokenCredential\"]}}}", + "async_imports": "{\"conditional\": {\"stdlib\": {\"typing\": [\"Any\", \"Optional\"]}}, \"regular\": {\"azurecore\": {\"azure.mgmt.core\": [\"AsyncARMPipelineClient\"], \"azure.profiles\": [\"KnownProfiles\", \"ProfileDefinition\"], \"azure.profiles.multiapiclient\": [\"MultiApiClientMixin\"]}, \"local\": {\"._configuration\": [\"ResourceManagementClientConfiguration\"], \"..._serialization\": [\"Deserializer\", \"Serializer\"]}}, \"typing\": {\"azurecore\": {\"azure.core.credentials_async\": [\"AsyncTokenCredential\"]}}}" }, "global_parameters": { "sync": { "credential": { - "signature": "credential, # type: \"TokenCredential\"", - "description": "Credential needed for the client to connect to Azure.", + "signature": "credential: \"TokenCredential\",", + "description": "Credential needed for the client to connect to Azure. Required.", "docstring_type": "~azure.core.credentials.TokenCredential", "required": true }, "subscription_id": { - "signature": "subscription_id, # type: str", - "description": "The ID of the target subscription.", + "signature": "subscription_id: str,", + "description": "The ID of the target subscription. Required.", "docstring_type": "str", "required": true } @@ -31,13 +31,13 @@ "async": { "credential": { "signature": "credential: \"AsyncTokenCredential\",", - "description": "Credential needed for the client to connect to Azure.", + "description": "Credential needed for the client to connect to Azure. Required.", "docstring_type": "~azure.core.credentials_async.AsyncTokenCredential", "required": true }, "subscription_id": { "signature": "subscription_id: str,", - "description": "The ID of the target subscription.", + "description": "The ID of the target subscription. Required.", "docstring_type": "str", "required": true } @@ -54,7 +54,7 @@ "required": false }, "base_url": { - "signature": "base_url=\"https://management.azure.com\", # type: str", + "signature": "base_url: str = \"https://management.azure.com\",", "description": "Service URL", "docstring_type": "str", "required": false diff --git a/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/resources/v2016_09_01/_patch.py b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/resources/v2016_09_01/_patch.py index 74e48ecd07cf3..f99e77fef9861 100644 --- a/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/resources/v2016_09_01/_patch.py +++ b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/resources/v2016_09_01/_patch.py @@ -28,4 +28,4 @@ # This file is used for handwritten extensions to the generated code. Example: # https://github.com/Azure/azure-sdk-for-python/blob/main/doc/dev/customize_code/how-to-patch-sdk-code.md def patch_sdk(): - pass \ No newline at end of file + pass diff --git a/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/resources/v2016_09_01/_resource_management_client.py b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/resources/v2016_09_01/_resource_management_client.py index 69bd266bbe27c..3b1210b7d5b66 100644 --- a/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/resources/v2016_09_01/_resource_management_client.py +++ b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/resources/v2016_09_01/_resource_management_client.py @@ -9,20 +9,27 @@ from copy import deepcopy from typing import Any, TYPE_CHECKING -from msrest import Deserializer, Serializer - from azure.core.rest import HttpRequest, HttpResponse from azure.mgmt.core import ARMPipelineClient from . import models +from .._serialization import Deserializer, Serializer from ._configuration import ResourceManagementClientConfiguration -from .operations import DeploymentOperationsOperations, DeploymentsOperations, ProvidersOperations, ResourceGroupsOperations, ResourcesOperations, TagsOperations +from .operations import ( + DeploymentOperationsOperations, + DeploymentsOperations, + ProvidersOperations, + ResourceGroupsOperations, + ResourcesOperations, + TagsOperations, +) if TYPE_CHECKING: # pylint: disable=unused-import,ungrouped-imports from azure.core.credentials import TokenCredential -class ResourceManagementClient: + +class ResourceManagementClient: # pylint: disable=client-accepts-api-version-keyword """Provides operations for working with resources and resource groups. :ivar deployments: DeploymentsOperations operations @@ -40,9 +47,9 @@ class ResourceManagementClient: :ivar deployment_operations: DeploymentOperationsOperations operations :vartype deployment_operations: azure.mgmt.resource.resources.v2016_09_01.operations.DeploymentOperationsOperations - :param credential: Credential needed for the client to connect to Azure. + :param credential: Credential needed for the client to connect to Azure. Required. :type credential: ~azure.core.credentials.TokenCredential - :param subscription_id: The ID of the target subscription. + :param subscription_id: The ID of the target subscription. Required. :type subscription_id: str :param base_url: Service URL. Default value is "https://management.azure.com". :type base_url: str @@ -60,7 +67,9 @@ def __init__( base_url: str = "https://management.azure.com", **kwargs: Any ) -> None: - self._config = ResourceManagementClientConfiguration(credential=credential, subscription_id=subscription_id, **kwargs) + self._config = ResourceManagementClientConfiguration( + credential=credential, subscription_id=subscription_id, **kwargs + ) self._client = ARMPipelineClient(base_url=base_url, config=self._config, **kwargs) client_models = {k: v for k, v in models.__dict__.items() if isinstance(v, type)} @@ -72,14 +81,11 @@ def __init__( self.resource_groups = ResourceGroupsOperations(self._client, self._config, self._serialize, self._deserialize) self.resources = ResourcesOperations(self._client, self._config, self._serialize, self._deserialize) self.tags = TagsOperations(self._client, self._config, self._serialize, self._deserialize) - self.deployment_operations = DeploymentOperationsOperations(self._client, self._config, self._serialize, self._deserialize) - + self.deployment_operations = DeploymentOperationsOperations( + self._client, self._config, self._serialize, self._deserialize + ) - def _send_request( - self, - request: HttpRequest, - **kwargs: Any - ) -> HttpResponse: + def _send_request(self, request: HttpRequest, **kwargs: Any) -> HttpResponse: """Runs the network request through the client's chained policies. >>> from azure.core.rest import HttpRequest @@ -88,7 +94,7 @@ def _send_request( >>> response = client._send_request(request) - For more information on this code flow, see https://aka.ms/azsdk/python/protocol/quickstart + For more information on this code flow, see https://aka.ms/azsdk/dpcodegen/python/send_request :param request: The network request you want to make. Required. :type request: ~azure.core.rest.HttpRequest diff --git a/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/resources/v2016_09_01/_vendor.py b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/resources/v2016_09_01/_vendor.py index 138f663c53a4e..9aad73fc743e7 100644 --- a/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/resources/v2016_09_01/_vendor.py +++ b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/resources/v2016_09_01/_vendor.py @@ -7,6 +7,7 @@ from azure.core.pipeline.transport import HttpRequest + def _convert_request(request, files=None): data = request.content if not files else None request = HttpRequest(method=request.method, url=request.url, headers=request.headers, data=data) @@ -14,6 +15,7 @@ def _convert_request(request, files=None): request.set_formdata_body(files) return request + def _format_url_section(template, **kwargs): components = template.split("/") while components: @@ -21,7 +23,5 @@ def _format_url_section(template, **kwargs): 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 - ] + components = [c for c in formatted_components if "{}".format(key.args[0]) not in c] template = "/".join(components) diff --git a/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/resources/v2016_09_01/_version.py b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/resources/v2016_09_01/_version.py index a012ac01c480c..e5754a47ce68f 100644 --- a/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/resources/v2016_09_01/_version.py +++ b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/resources/v2016_09_01/_version.py @@ -6,4 +6,4 @@ # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -VERSION = "21.1.0" +VERSION = "1.0.0b1" diff --git a/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/resources/v2016_09_01/aio/__init__.py b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/resources/v2016_09_01/aio/__init__.py index c6c3cf64a37a6..98d6782c2530c 100644 --- a/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/resources/v2016_09_01/aio/__init__.py +++ b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/resources/v2016_09_01/aio/__init__.py @@ -7,9 +7,15 @@ # -------------------------------------------------------------------------- from ._resource_management_client import ResourceManagementClient -__all__ = ['ResourceManagementClient'] -# `._patch.py` is used for handwritten extensions to the generated code -# Example: https://github.com/Azure/azure-sdk-for-python/blob/main/doc/dev/customize_code/how-to-patch-sdk-code.md -from ._patch import patch_sdk -patch_sdk() +try: + from ._patch import __all__ as _patch_all + from ._patch import * # type: ignore # pylint: disable=unused-wildcard-import +except ImportError: + _patch_all = [] +from ._patch import patch_sdk as _patch_sdk + +__all__ = ["ResourceManagementClient"] +__all__.extend([p for p in _patch_all if p not in __all__]) + +_patch_sdk() diff --git a/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/resources/v2016_09_01/aio/_configuration.py b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/resources/v2016_09_01/aio/_configuration.py index 1291e19741a4e..e30e5a4f70753 100644 --- a/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/resources/v2016_09_01/aio/_configuration.py +++ b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/resources/v2016_09_01/aio/_configuration.py @@ -25,23 +25,18 @@ class ResourceManagementClientConfiguration(Configuration): # pylint: disable=t Note that all parameters used to create this instance are saved as instance attributes. - :param credential: Credential needed for the client to connect to Azure. + :param credential: Credential needed for the client to connect to Azure. Required. :type credential: ~azure.core.credentials_async.AsyncTokenCredential - :param subscription_id: The ID of the target subscription. + :param subscription_id: The ID of the target subscription. Required. :type subscription_id: str :keyword api_version: Api Version. Default value is "2016-09-01". Note that overriding this default value may result in unsupported behavior. :paramtype api_version: str """ - def __init__( - self, - credential: "AsyncTokenCredential", - subscription_id: str, - **kwargs: Any - ) -> None: + def __init__(self, credential: "AsyncTokenCredential", subscription_id: str, **kwargs: Any) -> None: super(ResourceManagementClientConfiguration, self).__init__(**kwargs) - api_version = kwargs.pop('api_version', "2016-09-01") # type: str + api_version = kwargs.pop("api_version", "2016-09-01") # type: str if credential is None: raise ValueError("Parameter 'credential' must not be None.") @@ -51,22 +46,21 @@ def __init__( self.credential = credential self.subscription_id = subscription_id self.api_version = api_version - self.credential_scopes = kwargs.pop('credential_scopes', ['https://management.azure.com/.default']) - kwargs.setdefault('sdk_moniker', 'mgmt-resource/{}'.format(VERSION)) + self.credential_scopes = kwargs.pop("credential_scopes", ["https://management.azure.com/.default"]) + kwargs.setdefault("sdk_moniker", "mgmt-resource/{}".format(VERSION)) self._configure(**kwargs) - 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) - self.logging_policy = kwargs.get('logging_policy') or policies.NetworkTraceLoggingPolicy(**kwargs) - self.http_logging_policy = kwargs.get('http_logging_policy') or ARMHttpLoggingPolicy(**kwargs) - self.retry_policy = kwargs.get('retry_policy') or policies.AsyncRetryPolicy(**kwargs) - self.custom_hook_policy = kwargs.get('custom_hook_policy') or policies.CustomHookPolicy(**kwargs) - self.redirect_policy = kwargs.get('redirect_policy') or policies.AsyncRedirectPolicy(**kwargs) - self.authentication_policy = kwargs.get('authentication_policy') + 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) + self.logging_policy = kwargs.get("logging_policy") or policies.NetworkTraceLoggingPolicy(**kwargs) + self.http_logging_policy = kwargs.get("http_logging_policy") or ARMHttpLoggingPolicy(**kwargs) + self.retry_policy = kwargs.get("retry_policy") or policies.AsyncRetryPolicy(**kwargs) + self.custom_hook_policy = kwargs.get("custom_hook_policy") or policies.CustomHookPolicy(**kwargs) + self.redirect_policy = kwargs.get("redirect_policy") or policies.AsyncRedirectPolicy(**kwargs) + self.authentication_policy = kwargs.get("authentication_policy") if self.credential and not self.authentication_policy: - self.authentication_policy = AsyncARMChallengeAuthenticationPolicy(self.credential, *self.credential_scopes, **kwargs) + self.authentication_policy = AsyncARMChallengeAuthenticationPolicy( + self.credential, *self.credential_scopes, **kwargs + ) diff --git a/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/resources/v2016_09_01/aio/_patch.py b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/resources/v2016_09_01/aio/_patch.py index 74e48ecd07cf3..f99e77fef9861 100644 --- a/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/resources/v2016_09_01/aio/_patch.py +++ b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/resources/v2016_09_01/aio/_patch.py @@ -28,4 +28,4 @@ # This file is used for handwritten extensions to the generated code. Example: # https://github.com/Azure/azure-sdk-for-python/blob/main/doc/dev/customize_code/how-to-patch-sdk-code.md def patch_sdk(): - pass \ No newline at end of file + pass diff --git a/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/resources/v2016_09_01/aio/_resource_management_client.py b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/resources/v2016_09_01/aio/_resource_management_client.py index 24ace031b4903..35cfb79ce2201 100644 --- a/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/resources/v2016_09_01/aio/_resource_management_client.py +++ b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/resources/v2016_09_01/aio/_resource_management_client.py @@ -9,20 +9,27 @@ from copy import deepcopy from typing import Any, Awaitable, TYPE_CHECKING -from msrest import Deserializer, Serializer - from azure.core.rest import AsyncHttpResponse, HttpRequest from azure.mgmt.core import AsyncARMPipelineClient from .. import models +from ..._serialization import Deserializer, Serializer from ._configuration import ResourceManagementClientConfiguration -from .operations import DeploymentOperationsOperations, DeploymentsOperations, ProvidersOperations, ResourceGroupsOperations, ResourcesOperations, TagsOperations +from .operations import ( + DeploymentOperationsOperations, + DeploymentsOperations, + ProvidersOperations, + ResourceGroupsOperations, + ResourcesOperations, + TagsOperations, +) if TYPE_CHECKING: # pylint: disable=unused-import,ungrouped-imports from azure.core.credentials_async import AsyncTokenCredential -class ResourceManagementClient: + +class ResourceManagementClient: # pylint: disable=client-accepts-api-version-keyword """Provides operations for working with resources and resource groups. :ivar deployments: DeploymentsOperations operations @@ -42,9 +49,9 @@ class ResourceManagementClient: :ivar deployment_operations: DeploymentOperationsOperations operations :vartype deployment_operations: azure.mgmt.resource.resources.v2016_09_01.aio.operations.DeploymentOperationsOperations - :param credential: Credential needed for the client to connect to Azure. + :param credential: Credential needed for the client to connect to Azure. Required. :type credential: ~azure.core.credentials_async.AsyncTokenCredential - :param subscription_id: The ID of the target subscription. + :param subscription_id: The ID of the target subscription. Required. :type subscription_id: str :param base_url: Service URL. Default value is "https://management.azure.com". :type base_url: str @@ -62,7 +69,9 @@ def __init__( base_url: str = "https://management.azure.com", **kwargs: Any ) -> None: - self._config = ResourceManagementClientConfiguration(credential=credential, subscription_id=subscription_id, **kwargs) + self._config = ResourceManagementClientConfiguration( + credential=credential, subscription_id=subscription_id, **kwargs + ) self._client = AsyncARMPipelineClient(base_url=base_url, config=self._config, **kwargs) client_models = {k: v for k, v in models.__dict__.items() if isinstance(v, type)} @@ -74,14 +83,11 @@ def __init__( self.resource_groups = ResourceGroupsOperations(self._client, self._config, self._serialize, self._deserialize) self.resources = ResourcesOperations(self._client, self._config, self._serialize, self._deserialize) self.tags = TagsOperations(self._client, self._config, self._serialize, self._deserialize) - self.deployment_operations = DeploymentOperationsOperations(self._client, self._config, self._serialize, self._deserialize) - + self.deployment_operations = DeploymentOperationsOperations( + self._client, self._config, self._serialize, self._deserialize + ) - def _send_request( - self, - request: HttpRequest, - **kwargs: Any - ) -> Awaitable[AsyncHttpResponse]: + def _send_request(self, request: HttpRequest, **kwargs: Any) -> Awaitable[AsyncHttpResponse]: """Runs the network request through the client's chained policies. >>> from azure.core.rest import HttpRequest @@ -90,7 +96,7 @@ def _send_request( >>> response = await client._send_request(request) - For more information on this code flow, see https://aka.ms/azsdk/python/protocol/quickstart + For more information on this code flow, see https://aka.ms/azsdk/dpcodegen/python/send_request :param request: The network request you want to make. Required. :type request: ~azure.core.rest.HttpRequest diff --git a/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/resources/v2016_09_01/aio/operations/__init__.py b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/resources/v2016_09_01/aio/operations/__init__.py index ad38d1291a450..ada6e7edc9b2c 100644 --- a/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/resources/v2016_09_01/aio/operations/__init__.py +++ b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/resources/v2016_09_01/aio/operations/__init__.py @@ -13,11 +13,17 @@ from ._operations import TagsOperations from ._operations import DeploymentOperationsOperations +from ._patch import __all__ as _patch_all +from ._patch import * # type: ignore # pylint: disable=unused-wildcard-import +from ._patch import patch_sdk as _patch_sdk + __all__ = [ - 'DeploymentsOperations', - 'ProvidersOperations', - 'ResourceGroupsOperations', - 'ResourcesOperations', - 'TagsOperations', - 'DeploymentOperationsOperations', + "DeploymentsOperations", + "ProvidersOperations", + "ResourceGroupsOperations", + "ResourcesOperations", + "TagsOperations", + "DeploymentOperationsOperations", ] +__all__.extend([p for p in _patch_all if p not in __all__]) +_patch_sdk() diff --git a/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/resources/v2016_09_01/aio/operations/_operations.py b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/resources/v2016_09_01/aio/operations/_operations.py index 9b1818c9350d4..312a074e86bb7 100644 --- a/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/resources/v2016_09_01/aio/operations/_operations.py +++ b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/resources/v2016_09_01/aio/operations/_operations.py @@ -6,77 +6,135 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -from typing import Any, AsyncIterable, Callable, Dict, Optional, TypeVar, Union +import sys +from typing import Any, AsyncIterable, Callable, Dict, IO, Optional, TypeVar, Union, cast, overload +from urllib.parse import parse_qs, urljoin, urlparse from azure.core.async_paging import AsyncItemPaged, AsyncList -from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error +from azure.core.exceptions import ( + ClientAuthenticationError, + HttpResponseError, + ResourceExistsError, + ResourceNotFoundError, + ResourceNotModifiedError, + map_error, +) from azure.core.pipeline import PipelineResponse from azure.core.pipeline.transport import AsyncHttpResponse from azure.core.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 from azure.mgmt.core.polling.async_arm_polling import AsyncARMPolling from ... import models as _models from ..._vendor import _convert_request -from ...operations._operations import build_deployment_operations_get_request, build_deployment_operations_list_request, build_deployments_calculate_template_hash_request, build_deployments_cancel_request, build_deployments_check_existence_request, build_deployments_create_or_update_request_initial, build_deployments_delete_request_initial, build_deployments_export_template_request, build_deployments_get_request, build_deployments_list_request, build_deployments_validate_request, build_providers_get_request, build_providers_list_request, build_providers_register_request, build_providers_unregister_request, build_resource_groups_check_existence_request, build_resource_groups_create_or_update_request, build_resource_groups_delete_request_initial, build_resource_groups_export_template_request, build_resource_groups_get_request, build_resource_groups_list_request, build_resource_groups_list_resources_request, build_resource_groups_patch_request, build_resources_check_existence_by_id_request, build_resources_check_existence_request, build_resources_create_or_update_by_id_request_initial, build_resources_create_or_update_request_initial, build_resources_delete_by_id_request_initial, build_resources_delete_request_initial, build_resources_get_by_id_request, build_resources_get_request, build_resources_list_request, build_resources_move_resources_request_initial, build_resources_update_by_id_request_initial, build_resources_update_request_initial, build_tags_create_or_update_request, build_tags_create_or_update_value_request, build_tags_delete_request, build_tags_delete_value_request, build_tags_list_request -T = TypeVar('T') +from ...operations._operations import ( + build_deployment_operations_get_request, + build_deployment_operations_list_request, + build_deployments_calculate_template_hash_request, + build_deployments_cancel_request, + build_deployments_check_existence_request, + build_deployments_create_or_update_request, + build_deployments_delete_request, + build_deployments_export_template_request, + build_deployments_get_request, + build_deployments_list_request, + build_deployments_validate_request, + build_providers_get_request, + build_providers_list_request, + build_providers_register_request, + build_providers_unregister_request, + build_resource_groups_check_existence_request, + build_resource_groups_create_or_update_request, + build_resource_groups_delete_request, + build_resource_groups_export_template_request, + build_resource_groups_get_request, + build_resource_groups_list_request, + build_resource_groups_list_resources_request, + build_resource_groups_patch_request, + build_resources_check_existence_by_id_request, + build_resources_check_existence_request, + build_resources_create_or_update_by_id_request, + build_resources_create_or_update_request, + build_resources_delete_by_id_request, + build_resources_delete_request, + build_resources_get_by_id_request, + build_resources_get_request, + build_resources_list_request, + build_resources_move_resources_request, + build_resources_update_by_id_request, + build_resources_update_request, + build_tags_create_or_update_request, + build_tags_create_or_update_value_request, + build_tags_delete_request, + build_tags_delete_value_request, + build_tags_list_request, +) + +if sys.version_info >= (3, 9): + from collections.abc import MutableMapping +else: + from typing import MutableMapping # type: ignore # pylint: disable=ungrouped-imports +JSON = MutableMapping[str, Any] # pylint: disable=unsubscriptable-object +T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] -class DeploymentsOperations: - """DeploymentsOperations async operations. - You should not instantiate this class directly. Instead, you should create a Client instance that - instantiates it for you and attaches it as an attribute. +class DeploymentsOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. - :ivar models: Alias to model classes used in this operation group. - :type models: ~azure.mgmt.resource.resources.v2016_09_01.models - :param client: Client for service requests. - :param config: Configuration of service client. - :param serializer: An object model serializer. - :param deserializer: An object model deserializer. + Instead, you should access the following operations through + :class:`~azure.mgmt.resource.resources.v2016_09_01.aio.ResourceManagementClient`'s + :attr:`deployments` attribute. """ models = _models - def __init__(self, client, config, serializer, deserializer) -> None: - self._client = client - self._serialize = serializer - self._deserialize = deserializer - self._config = config + def __init__(self, *args, **kwargs) -> None: + input_args = list(args) + self._client = input_args.pop(0) if input_args else kwargs.pop("client") + self._config = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") async def _delete_initial( # pylint: disable=inconsistent-return-statements - self, - resource_group_name: str, - deployment_name: str, - **kwargs: Any + self, resource_group_name: str, deployment_name: str, **kwargs: Any ) -> None: - cls = kwargs.pop('cls', None) # type: ClsType[None] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + 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', "2016-09-01") # type: str + api_version = kwargs.pop("api_version", _params.pop("api-version", "2016-09-01")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[None] - - request = build_deployments_delete_request_initial( + request = build_deployments_delete_request( resource_group_name=resource_group_name, deployment_name=deployment_name, subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self._delete_initial.metadata['url'], + template_url=self._delete_initial.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [202, 204]: @@ -86,16 +144,10 @@ 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.Resources/deployments/{deploymentName}"} # type: ignore - + _delete_initial.metadata = {"url": "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/Microsoft.Resources/deployments/{deploymentName}"} # type: ignore @distributed_trace_async - async def begin_delete( # pylint: disable=inconsistent-return-statements - self, - resource_group_name: str, - deployment_name: str, - **kwargs: Any - ) -> AsyncLROPoller[None]: + async def begin_delete(self, resource_group_name: str, deployment_name: str, **kwargs: Any) -> AsyncLROPoller[None]: """Deletes a deployment from the deployment history. A template deployment that is currently running cannot be deleted. Deleting a template @@ -108,9 +160,9 @@ async def begin_delete( # pylint: disable=inconsistent-return-statements asynchronous request failed, the URI in the Location header returns an error-level status code. :param resource_group_name: The name of the resource group with the deployment to delete. The - name is case insensitive. + name is case insensitive. Required. :type resource_group_name: str - :param deployment_name: The name of the deployment to delete. + :param deployment_name: The name of the deployment to delete. Required. :type deployment_name: str :keyword callable cls: A custom type or function that will be passed the direct response :keyword str continuation_token: A continuation token to restart a poller from a saved state. @@ -122,88 +174,93 @@ async def begin_delete( # pylint: disable=inconsistent-return-statements Retry-After header is present. :return: An instance of AsyncLROPoller that returns either None or the result of cls(response) :rtype: ~azure.core.polling.AsyncLROPoller[None] - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - api_version = kwargs.pop('api_version', "2016-09-01") # type: str - polling = kwargs.pop('polling', True) # type: Union[bool, AsyncPollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType[None] - lro_delay = kwargs.pop( - 'polling_interval', - self._config.polling_interval - ) - cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2016-09-01")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[None] + polling = kwargs.pop("polling", True) # type: Union[bool, AsyncPollingMethod] + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token = kwargs.pop("continuation_token", None) # type: Optional[str] if cont_token is None: - raw_result = await self._delete_initial( + raw_result = await self._delete_initial( # type: ignore resource_group_name=resource_group_name, deployment_name=deployment_name, api_version=api_version, - cls=lambda x,y,z: x, + cls=lambda x, y, z: x, + headers=_headers, + params=_params, **kwargs ) - kwargs.pop('error_map', None) + kwargs.pop("error_map", None) - def get_long_running_output(pipeline_response): + def get_long_running_output(pipeline_response): # pylint: disable=inconsistent-return-statements if cls: return cls(pipeline_response, None, {}) - - if polling is True: polling_method = AsyncARMPolling(lro_delay, **kwargs) - elif polling is False: polling_method = AsyncNoPolling() - else: polling_method = polling + if polling is True: + polling_method = cast(AsyncPollingMethod, AsyncARMPolling(lro_delay, **kwargs)) # type: AsyncPollingMethod + elif polling is False: + polling_method = cast(AsyncPollingMethod, AsyncNoPolling()) + else: + polling_method = polling if cont_token: return AsyncLROPoller.from_continuation_token( polling_method=polling_method, continuation_token=cont_token, client=self._client, - deserialization_callback=get_long_running_output + deserialization_callback=get_long_running_output, ) return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) - begin_delete.metadata = {'url': "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/Microsoft.Resources/deployments/{deploymentName}"} # type: ignore + begin_delete.metadata = {"url": "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/Microsoft.Resources/deployments/{deploymentName}"} # type: ignore @distributed_trace_async - async def check_existence( - self, - resource_group_name: str, - deployment_name: str, - **kwargs: Any - ) -> bool: + async def check_existence(self, resource_group_name: str, deployment_name: str, **kwargs: Any) -> bool: """Checks whether the deployment exists. :param resource_group_name: The name of the resource group with the deployment to check. The - name is case insensitive. + name is case insensitive. Required. :type resource_group_name: str - :param deployment_name: The name of the deployment to check. + :param deployment_name: The name of the deployment to check. Required. :type deployment_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: bool, or the result of cls(response) + :return: bool or the result of cls(response) :rtype: bool - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType[None] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + 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', "2016-09-01") # type: str + api_version = kwargs.pop("api_version", _params.pop("api-version", "2016-09-01")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[None] - request = build_deployments_check_existence_request( resource_group_name=resource_group_name, deployment_name=deployment_name, subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.check_existence.metadata['url'], + template_url=self.check_existence.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [204, 404]: @@ -214,44 +271,53 @@ async def check_existence( return cls(pipeline_response, None, {}) return 200 <= response.status_code <= 299 - check_existence.metadata = {'url': "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/Microsoft.Resources/deployments/{deploymentName}"} # type: ignore - + check_existence.metadata = {"url": "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/Microsoft.Resources/deployments/{deploymentName}"} # type: ignore async def _create_or_update_initial( - self, - resource_group_name: str, - deployment_name: str, - parameters: "_models.Deployment", - **kwargs: Any - ) -> "_models.DeploymentExtended": - cls = kwargs.pop('cls', None) # type: ClsType["_models.DeploymentExtended"] + self, resource_group_name: str, deployment_name: str, parameters: Union[_models.Deployment, IO], **kwargs: Any + ) -> _models.DeploymentExtended: error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) - api_version = kwargs.pop('api_version', "2016-09-01") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - _json = self._serialize.body(parameters, 'Deployment') + api_version = kwargs.pop("api_version", _params.pop("api-version", "2016-09-01")) # type: str + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.DeploymentExtended] - request = build_deployments_create_or_update_request_initial( + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(parameters, (IO, bytes)): + _content = parameters + else: + _json = self._serialize.body(parameters, "Deployment") + + request = build_deployments_create_or_update_request( resource_group_name=resource_group_name, deployment_name=deployment_name, subscription_id=self._config.subscription_id, api_version=api_version, content_type=content_type, json=_json, - template_url=self._create_or_update_initial.metadata['url'], + content=_content, + template_url=self._create_or_update_initial.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200, 201]: @@ -259,38 +325,115 @@ async def _create_or_update_initial( raise HttpResponseError(response=response, error_format=ARMErrorFormat) if response.status_code == 200: - deserialized = self._deserialize('DeploymentExtended', pipeline_response) + deserialized = self._deserialize("DeploymentExtended", pipeline_response) if response.status_code == 201: - deserialized = self._deserialize('DeploymentExtended', pipeline_response) + deserialized = self._deserialize("DeploymentExtended", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - _create_or_update_initial.metadata = {'url': "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/Microsoft.Resources/deployments/{deploymentName}"} # type: ignore + _create_or_update_initial.metadata = {"url": "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/Microsoft.Resources/deployments/{deploymentName}"} # type: ignore - - @distributed_trace_async + @overload async def begin_create_or_update( self, resource_group_name: str, deployment_name: str, - parameters: "_models.Deployment", + parameters: _models.Deployment, + *, + content_type: str = "application/json", **kwargs: Any - ) -> AsyncLROPoller["_models.DeploymentExtended"]: + ) -> AsyncLROPoller[_models.DeploymentExtended]: """Deploys resources to a resource group. You can provide the template and parameters directly in the request or link to JSON files. :param resource_group_name: The name of the resource group to deploy the resources to. The name - is case insensitive. The resource group must already exist. + is case insensitive. The resource group must already exist. Required. :type resource_group_name: str - :param deployment_name: The name of the deployment. + :param deployment_name: The name of the deployment. Required. :type deployment_name: str - :param parameters: Additional parameters supplied to the operation. + :param parameters: Additional parameters supplied to the operation. Required. :type parameters: ~azure.mgmt.resource.resources.v2016_09_01.models.Deployment + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be AsyncARMPolling. Pass in False for + this operation to not poll, or pass in your own initialized polling object for a personal + polling strategy. + :paramtype polling: bool or ~azure.core.polling.AsyncPollingMethod + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of AsyncLROPoller that returns either DeploymentExtended or the result of + cls(response) + :rtype: + ~azure.core.polling.AsyncLROPoller[~azure.mgmt.resource.resources.v2016_09_01.models.DeploymentExtended] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + async def begin_create_or_update( + self, + resource_group_name: str, + deployment_name: str, + parameters: IO, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> AsyncLROPoller[_models.DeploymentExtended]: + """Deploys resources to a resource group. + + You can provide the template and parameters directly in the request or link to JSON files. + + :param resource_group_name: The name of the resource group to deploy the resources to. The name + is case insensitive. The resource group must already exist. Required. + :type resource_group_name: str + :param deployment_name: The name of the deployment. Required. + :type deployment_name: str + :param parameters: Additional parameters supplied to the operation. Required. + :type parameters: IO + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be AsyncARMPolling. Pass in False for + this operation to not poll, or pass in your own initialized polling object for a personal + polling strategy. + :paramtype polling: bool or ~azure.core.polling.AsyncPollingMethod + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of AsyncLROPoller that returns either DeploymentExtended or the result of + cls(response) + :rtype: + ~azure.core.polling.AsyncLROPoller[~azure.mgmt.resource.resources.v2016_09_01.models.DeploymentExtended] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace_async + async def begin_create_or_update( + self, resource_group_name: str, deployment_name: str, parameters: Union[_models.Deployment, IO], **kwargs: Any + ) -> AsyncLROPoller[_models.DeploymentExtended]: + """Deploys resources to a resource group. + + You can provide the template and parameters directly in the request or link to JSON files. + + :param resource_group_name: The name of the resource group to deploy the resources to. The name + is case insensitive. The resource group must already exist. Required. + :type resource_group_name: str + :param deployment_name: The name of the deployment. Required. + :type deployment_name: str + :param parameters: Additional parameters supplied to the operation. Is either a model type or a + IO type. Required. + :type parameters: ~azure.mgmt.resource.resources.v2016_09_01.models.Deployment or IO + :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. + Default value is None. + :paramtype content_type: str :keyword callable cls: A custom type or function that will be passed the direct response :keyword str continuation_token: A continuation token to restart a poller from a saved state. :keyword polling: By default, your polling method will be AsyncARMPolling. Pass in False for @@ -303,115 +446,116 @@ async def begin_create_or_update( cls(response) :rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.resource.resources.v2016_09_01.models.DeploymentExtended] - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - api_version = kwargs.pop('api_version', "2016-09-01") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] - polling = kwargs.pop('polling', True) # type: Union[bool, AsyncPollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType["_models.DeploymentExtended"] - lro_delay = kwargs.pop( - 'polling_interval', - self._config.polling_interval - ) - cont_token = kwargs.pop('continuation_token', None) # type: Optional[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", "2016-09-01")) # type: str + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.DeploymentExtended] + polling = kwargs.pop("polling", True) # type: Union[bool, AsyncPollingMethod] + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token = kwargs.pop("continuation_token", None) # type: Optional[str] if cont_token is None: - raw_result = await self._create_or_update_initial( + raw_result = await self._create_or_update_initial( # type: ignore resource_group_name=resource_group_name, deployment_name=deployment_name, parameters=parameters, api_version=api_version, content_type=content_type, - cls=lambda x,y,z: x, + cls=lambda x, y, z: x, + headers=_headers, + params=_params, **kwargs ) - kwargs.pop('error_map', None) + kwargs.pop("error_map", None) def get_long_running_output(pipeline_response): - response = pipeline_response.http_response - deserialized = self._deserialize('DeploymentExtended', pipeline_response) + deserialized = self._deserialize("DeploymentExtended", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - - if polling is True: polling_method = AsyncARMPolling(lro_delay, **kwargs) - elif polling is False: polling_method = AsyncNoPolling() - else: polling_method = polling + if polling is True: + polling_method = cast(AsyncPollingMethod, AsyncARMPolling(lro_delay, **kwargs)) # type: AsyncPollingMethod + elif polling is False: + polling_method = cast(AsyncPollingMethod, AsyncNoPolling()) + else: + polling_method = polling if cont_token: return AsyncLROPoller.from_continuation_token( polling_method=polling_method, continuation_token=cont_token, client=self._client, - deserialization_callback=get_long_running_output + deserialization_callback=get_long_running_output, ) return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) - begin_create_or_update.metadata = {'url': "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/Microsoft.Resources/deployments/{deploymentName}"} # type: ignore + begin_create_or_update.metadata = {"url": "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/Microsoft.Resources/deployments/{deploymentName}"} # type: ignore @distributed_trace_async - async def get( - self, - resource_group_name: str, - deployment_name: str, - **kwargs: Any - ) -> "_models.DeploymentExtended": + async def get(self, resource_group_name: str, deployment_name: str, **kwargs: Any) -> _models.DeploymentExtended: """Gets a deployment. :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. :type resource_group_name: str - :param deployment_name: The name of the deployment to get. + :param deployment_name: The name of the deployment to get. Required. :type deployment_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: DeploymentExtended, or the result of cls(response) + :return: DeploymentExtended or the result of cls(response) :rtype: ~azure.mgmt.resource.resources.v2016_09_01.models.DeploymentExtended - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.DeploymentExtended"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + 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', "2016-09-01") # type: str + api_version = kwargs.pop("api_version", _params.pop("api-version", "2016-09-01")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[_models.DeploymentExtended] - request = build_deployments_get_request( resource_group_name=resource_group_name, deployment_name=deployment_name, subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.get.metadata['url'], + template_url=self.get.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) - deserialized = self._deserialize('DeploymentExtended', pipeline_response) + deserialized = self._deserialize("DeploymentExtended", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - get.metadata = {'url': "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/Microsoft.Resources/deployments/{deploymentName}"} # type: ignore - + get.metadata = {"url": "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/Microsoft.Resources/deployments/{deploymentName}"} # type: ignore @distributed_trace_async async def cancel( # pylint: disable=inconsistent-return-statements - self, - resource_group_name: str, - deployment_name: str, - **kwargs: Any + self, resource_group_name: str, deployment_name: str, **kwargs: Any ) -> None: """Cancels a currently running template deployment. @@ -421,38 +565,45 @@ async def cancel( # pylint: disable=inconsistent-return-statements partially deployed. :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. :type resource_group_name: str - :param deployment_name: The name of the deployment to cancel. + :param deployment_name: The name of the deployment to cancel. Required. :type deployment_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: None, or the result of cls(response) + :return: None or the result of cls(response) :rtype: None - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType[None] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) - api_version = kwargs.pop('api_version', "2016-09-01") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2016-09-01")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[None] - request = build_deployments_cancel_request( resource_group_name=resource_group_name, deployment_name=deployment_name, subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.cancel.metadata['url'], + template_url=self.cancel.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [204]: @@ -462,42 +613,110 @@ async def cancel( # pylint: disable=inconsistent-return-statements if cls: return cls(pipeline_response, None, {}) - cancel.metadata = {'url': "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/Microsoft.Resources/deployments/{deploymentName}/cancel"} # type: ignore + cancel.metadata = {"url": "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/Microsoft.Resources/deployments/{deploymentName}/cancel"} # type: ignore - - @distributed_trace_async + @overload async def validate( self, resource_group_name: str, deployment_name: str, - parameters: "_models.Deployment", + parameters: _models.Deployment, + *, + content_type: str = "application/json", **kwargs: Any - ) -> "_models.DeploymentValidateResult": + ) -> _models.DeploymentValidateResult: """Validates whether the specified template is syntactically correct and will be accepted by Azure Resource Manager.. :param resource_group_name: The name of the resource group the template will be deployed to. - The name is case insensitive. + The name is case insensitive. Required. :type resource_group_name: str - :param deployment_name: The name of the deployment. + :param deployment_name: The name of the deployment. Required. :type deployment_name: str - :param parameters: Parameters to validate. + :param parameters: Parameters to validate. Required. :type parameters: ~azure.mgmt.resource.resources.v2016_09_01.models.Deployment + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: DeploymentValidateResult or the result of cls(response) + :rtype: ~azure.mgmt.resource.resources.v2016_09_01.models.DeploymentValidateResult + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + async def validate( + self, + resource_group_name: str, + deployment_name: str, + parameters: IO, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.DeploymentValidateResult: + """Validates whether the specified template is syntactically correct and will be accepted by Azure + Resource Manager.. + + :param resource_group_name: The name of the resource group the template will be deployed to. + The name is case insensitive. Required. + :type resource_group_name: str + :param deployment_name: The name of the deployment. Required. + :type deployment_name: str + :param parameters: Parameters to validate. Required. + :type parameters: IO + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: DeploymentValidateResult or the result of cls(response) + :rtype: ~azure.mgmt.resource.resources.v2016_09_01.models.DeploymentValidateResult + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace_async + async def validate( + self, resource_group_name: str, deployment_name: str, parameters: Union[_models.Deployment, IO], **kwargs: Any + ) -> _models.DeploymentValidateResult: + """Validates whether the specified template is syntactically correct and will be accepted by Azure + Resource Manager.. + + :param resource_group_name: The name of the resource group the template will be deployed to. + The name is case insensitive. Required. + :type resource_group_name: str + :param deployment_name: The name of the deployment. Required. + :type deployment_name: str + :param parameters: Parameters to validate. Is either a model type or a IO type. Required. + :type parameters: ~azure.mgmt.resource.resources.v2016_09_01.models.Deployment or IO + :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. + Default value is None. + :paramtype content_type: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: DeploymentValidateResult, or the result of cls(response) + :return: DeploymentValidateResult or the result of cls(response) :rtype: ~azure.mgmt.resource.resources.v2016_09_01.models.DeploymentValidateResult - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.DeploymentValidateResult"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) - api_version = kwargs.pop('api_version', "2016-09-01") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - _json = self._serialize.body(parameters, 'Deployment') + api_version = kwargs.pop("api_version", _params.pop("api-version", "2016-09-01")) # type: str + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.DeploymentValidateResult] + + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(parameters, (IO, bytes)): + _content = parameters + else: + _json = self._serialize.body(parameters, "Deployment") request = build_deployments_validate_request( resource_group_name=resource_group_name, @@ -506,16 +725,18 @@ async def validate( api_version=api_version, content_type=content_type, json=_json, - template_url=self.validate.metadata['url'], + content=_content, + template_url=self.validate.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200, 400]: @@ -523,89 +744,87 @@ async def validate( raise HttpResponseError(response=response, error_format=ARMErrorFormat) if response.status_code == 200: - deserialized = self._deserialize('DeploymentValidateResult', pipeline_response) + deserialized = self._deserialize("DeploymentValidateResult", pipeline_response) if response.status_code == 400: - deserialized = self._deserialize('DeploymentValidateResult', pipeline_response) + deserialized = self._deserialize("DeploymentValidateResult", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - validate.metadata = {'url': "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/Microsoft.Resources/deployments/{deploymentName}/validate"} # type: ignore - + validate.metadata = {"url": "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/Microsoft.Resources/deployments/{deploymentName}/validate"} # type: ignore @distributed_trace_async async def export_template( - self, - resource_group_name: str, - deployment_name: str, - **kwargs: Any - ) -> "_models.DeploymentExportResult": + self, resource_group_name: str, deployment_name: str, **kwargs: Any + ) -> _models.DeploymentExportResult: """Exports the template used for specified deployment. :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. :type resource_group_name: str - :param deployment_name: The name of the deployment from which to get the template. + :param deployment_name: The name of the deployment from which to get the template. Required. :type deployment_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: DeploymentExportResult, or the result of cls(response) + :return: DeploymentExportResult or the result of cls(response) :rtype: ~azure.mgmt.resource.resources.v2016_09_01.models.DeploymentExportResult - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.DeploymentExportResult"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + 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', "2016-09-01") # type: str + api_version = kwargs.pop("api_version", _params.pop("api-version", "2016-09-01")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[_models.DeploymentExportResult] - request = build_deployments_export_template_request( resource_group_name=resource_group_name, deployment_name=deployment_name, subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.export_template.metadata['url'], + template_url=self.export_template.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) - deserialized = self._deserialize('DeploymentExportResult', pipeline_response) + deserialized = self._deserialize("DeploymentExportResult", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - export_template.metadata = {'url': "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/Microsoft.Resources/deployments/{deploymentName}/exportTemplate"} # type: ignore - + export_template.metadata = {"url": "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/Microsoft.Resources/deployments/{deploymentName}/exportTemplate"} # type: ignore @distributed_trace def list( - self, - resource_group_name: str, - filter: Optional[str] = None, - top: Optional[int] = None, - **kwargs: Any - ) -> AsyncIterable["_models.DeploymentListResult"]: + self, resource_group_name: str, filter: Optional[str] = None, top: Optional[int] = None, **kwargs: Any + ) -> AsyncIterable["_models.DeploymentExtended"]: """Get all the deployments for a resource group. :param resource_group_name: The name of the resource group with the deployments to get. The - name is case insensitive. + name is case insensitive. Required. :type resource_group_name: str :param filter: The filter to apply on the operation. For example, you can use $filter=provisioningState eq '{state}'. Default value is None. @@ -614,42 +833,49 @@ def list( value is None. :type top: int :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either DeploymentListResult or the result of - cls(response) + :return: An iterator like instance of either DeploymentExtended or the result of cls(response) :rtype: - ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.resource.resources.v2016_09_01.models.DeploymentListResult] - :raises: ~azure.core.exceptions.HttpResponseError + ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.resource.resources.v2016_09_01.models.DeploymentExtended] + :raises ~azure.core.exceptions.HttpResponseError: """ - api_version = kwargs.pop('api_version', "2016-09-01") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2016-09-01")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[_models.DeploymentListResult] - cls = kwargs.pop('cls', None) # type: ClsType["_models.DeploymentListResult"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) + def prepare_request(next_link=None): if not next_link: - + request = build_deployments_list_request( resource_group_name=resource_group_name, subscription_id=self._config.subscription_id, - api_version=api_version, filter=filter, top=top, - template_url=self.list.metadata['url'], + 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.url = self._client.format_url(request.url) # type: ignore else: - - request = build_deployments_list_request( - resource_group_name=resource_group_name, - subscription_id=self._config.subscription_id, - template_url=next_link, - ) + # make call to next link with the client's api-version + _parsed_next_link = urlparse(next_link) + _next_request_params = case_insensitive_dict(parse_qs(_parsed_next_link.query)) + _next_request_params["api-version"] = self._config.api_version + request = HttpRequest("GET", urljoin(next_link, _parsed_next_link.path), params=_next_request_params) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore request.method = "GET" return request @@ -663,10 +889,8 @@ async def extract_data(pipeline_response): async def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) response = pipeline_response.http_response @@ -676,204 +900,204 @@ async def get_next(next_link=None): return pipeline_response + return AsyncItemPaged(get_next, extract_data) - return AsyncItemPaged( - get_next, extract_data - ) - list.metadata = {'url': "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/Microsoft.Resources/deployments/"} # type: ignore + list.metadata = {"url": "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/Microsoft.Resources/deployments/"} # type: ignore @distributed_trace_async - async def calculate_template_hash( - self, - template: Any, - **kwargs: Any - ) -> "_models.TemplateHashResult": + async def calculate_template_hash(self, template: JSON, **kwargs: Any) -> _models.TemplateHashResult: """Calculate the hash of the given template. - :param template: The template provided to calculate hash. - :type template: any + :param template: The template provided to calculate hash. Required. + :type template: JSON :keyword callable cls: A custom type or function that will be passed the direct response - :return: TemplateHashResult, or the result of cls(response) + :return: TemplateHashResult or the result of cls(response) :rtype: ~azure.mgmt.resource.resources.v2016_09_01.models.TemplateHashResult - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.TemplateHashResult"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', "2016-09-01") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + api_version = kwargs.pop("api_version", _params.pop("api-version", "2016-09-01")) # type: str + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", "application/json")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[_models.TemplateHashResult] - _json = self._serialize.body(template, 'object') + _json = self._serialize.body(template, "object") request = build_deployments_calculate_template_hash_request( api_version=api_version, content_type=content_type, json=_json, - template_url=self.calculate_template_hash.metadata['url'], + template_url=self.calculate_template_hash.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) - deserialized = self._deserialize('TemplateHashResult', pipeline_response) + deserialized = self._deserialize("TemplateHashResult", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - calculate_template_hash.metadata = {'url': "/providers/Microsoft.Resources/calculateTemplateHash"} # type: ignore + calculate_template_hash.metadata = {"url": "/providers/Microsoft.Resources/calculateTemplateHash"} # type: ignore -class ProvidersOperations: - """ProvidersOperations async operations. - You should not instantiate this class directly. Instead, you should create a Client instance that - instantiates it for you and attaches it as an attribute. +class ProvidersOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. - :ivar models: Alias to model classes used in this operation group. - :type models: ~azure.mgmt.resource.resources.v2016_09_01.models - :param client: Client for service requests. - :param config: Configuration of service client. - :param serializer: An object model serializer. - :param deserializer: An object model deserializer. + Instead, you should access the following operations through + :class:`~azure.mgmt.resource.resources.v2016_09_01.aio.ResourceManagementClient`'s + :attr:`providers` attribute. """ models = _models - def __init__(self, client, config, serializer, deserializer) -> None: - self._client = client - self._serialize = serializer - self._deserialize = deserializer - self._config = config + def __init__(self, *args, **kwargs) -> None: + input_args = list(args) + self._client = input_args.pop(0) if input_args else kwargs.pop("client") + self._config = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") @distributed_trace_async - async def unregister( - self, - resource_provider_namespace: str, - **kwargs: Any - ) -> "_models.Provider": + async def unregister(self, resource_provider_namespace: str, **kwargs: Any) -> _models.Provider: """Unregisters a subscription from a resource provider. :param resource_provider_namespace: The namespace of the resource provider to unregister. + Required. :type resource_provider_namespace: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: Provider, or the result of cls(response) + :return: Provider or the result of cls(response) :rtype: ~azure.mgmt.resource.resources.v2016_09_01.models.Provider - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.Provider"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + 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', "2016-09-01") # type: str + api_version = kwargs.pop("api_version", _params.pop("api-version", "2016-09-01")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[_models.Provider] - request = build_providers_unregister_request( resource_provider_namespace=resource_provider_namespace, subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.unregister.metadata['url'], + template_url=self.unregister.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) - deserialized = self._deserialize('Provider', pipeline_response) + deserialized = self._deserialize("Provider", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - unregister.metadata = {'url': "/subscriptions/{subscriptionId}/providers/{resourceProviderNamespace}/unregister"} # type: ignore - + unregister.metadata = {"url": "/subscriptions/{subscriptionId}/providers/{resourceProviderNamespace}/unregister"} # type: ignore @distributed_trace_async - async def register( - self, - resource_provider_namespace: str, - **kwargs: Any - ) -> "_models.Provider": + async def register(self, resource_provider_namespace: str, **kwargs: Any) -> _models.Provider: """Registers a subscription with a resource provider. :param resource_provider_namespace: The namespace of the resource provider to register. + Required. :type resource_provider_namespace: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: Provider, or the result of cls(response) + :return: Provider or the result of cls(response) :rtype: ~azure.mgmt.resource.resources.v2016_09_01.models.Provider - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.Provider"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + 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', "2016-09-01") # type: str + api_version = kwargs.pop("api_version", _params.pop("api-version", "2016-09-01")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[_models.Provider] - request = build_providers_register_request( resource_provider_namespace=resource_provider_namespace, subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.register.metadata['url'], + template_url=self.register.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) - deserialized = self._deserialize('Provider', pipeline_response) + deserialized = self._deserialize("Provider", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - register.metadata = {'url': "/subscriptions/{subscriptionId}/providers/{resourceProviderNamespace}/register"} # type: ignore - + register.metadata = {"url": "/subscriptions/{subscriptionId}/providers/{resourceProviderNamespace}/register"} # type: ignore @distributed_trace def list( - self, - top: Optional[int] = None, - expand: Optional[str] = None, - **kwargs: Any - ) -> AsyncIterable["_models.ProviderListResult"]: + self, top: Optional[int] = None, expand: Optional[str] = None, **kwargs: Any + ) -> AsyncIterable["_models.Provider"]: """Gets all resource providers for a subscription. :param top: The number of results to return. If null is passed returns all deployments. Default @@ -884,39 +1108,48 @@ def list( response, use $expand=resourceTypes/aliases. Default value is None. :type expand: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either ProviderListResult or the result of cls(response) + :return: An iterator like instance of either Provider or the result of cls(response) :rtype: - ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.resource.resources.v2016_09_01.models.ProviderListResult] - :raises: ~azure.core.exceptions.HttpResponseError + ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.resource.resources.v2016_09_01.models.Provider] + :raises ~azure.core.exceptions.HttpResponseError: """ - api_version = kwargs.pop('api_version', "2016-09-01") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2016-09-01")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[_models.ProviderListResult] - cls = kwargs.pop('cls', None) # type: ClsType["_models.ProviderListResult"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) + def prepare_request(next_link=None): if not next_link: - + request = build_providers_list_request( subscription_id=self._config.subscription_id, - api_version=api_version, top=top, expand=expand, - template_url=self.list.metadata['url'], + 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.url = self._client.format_url(request.url) # type: ignore else: - - request = build_providers_list_request( - subscription_id=self._config.subscription_id, - template_url=next_link, - ) + # make call to next link with the client's api-version + _parsed_next_link = urlparse(next_link) + _next_request_params = case_insensitive_dict(parse_qs(_parsed_next_link.query)) + _next_request_params["api-version"] = self._config.api_version + request = HttpRequest("GET", urljoin(next_link, _parsed_next_link.path), params=_next_request_params) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore request.method = "GET" return request @@ -930,10 +1163,8 @@ async def extract_data(pipeline_response): async def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) response = pipeline_response.http_response @@ -943,91 +1174,90 @@ async def get_next(next_link=None): return pipeline_response + return AsyncItemPaged(get_next, extract_data) - return AsyncItemPaged( - get_next, extract_data - ) - list.metadata = {'url': "/subscriptions/{subscriptionId}/providers"} # type: ignore + list.metadata = {"url": "/subscriptions/{subscriptionId}/providers"} # type: ignore @distributed_trace_async async def get( - self, - resource_provider_namespace: str, - expand: Optional[str] = None, - **kwargs: Any - ) -> "_models.Provider": + self, resource_provider_namespace: str, expand: Optional[str] = None, **kwargs: Any + ) -> _models.Provider: """Gets the specified resource provider. - :param resource_provider_namespace: The namespace of the resource provider. + :param resource_provider_namespace: The namespace of the resource provider. Required. :type resource_provider_namespace: str :param expand: The $expand query parameter. For example, to include property aliases in response, use $expand=resourceTypes/aliases. Default value is None. :type expand: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: Provider, or the result of cls(response) + :return: Provider or the result of cls(response) :rtype: ~azure.mgmt.resource.resources.v2016_09_01.models.Provider - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.Provider"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) - api_version = kwargs.pop('api_version', "2016-09-01") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2016-09-01")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[_models.Provider] - request = build_providers_get_request( resource_provider_namespace=resource_provider_namespace, subscription_id=self._config.subscription_id, - api_version=api_version, expand=expand, - template_url=self.get.metadata['url'], + api_version=api_version, + template_url=self.get.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) - deserialized = self._deserialize('Provider', pipeline_response) + deserialized = self._deserialize("Provider", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - get.metadata = {'url': "/subscriptions/{subscriptionId}/providers/{resourceProviderNamespace}"} # type: ignore + get.metadata = {"url": "/subscriptions/{subscriptionId}/providers/{resourceProviderNamespace}"} # type: ignore -class ResourceGroupsOperations: - """ResourceGroupsOperations async operations. - You should not instantiate this class directly. Instead, you should create a Client instance that - instantiates it for you and attaches it as an attribute. +class ResourceGroupsOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. - :ivar models: Alias to model classes used in this operation group. - :type models: ~azure.mgmt.resource.resources.v2016_09_01.models - :param client: Client for service requests. - :param config: Configuration of service client. - :param serializer: An object model serializer. - :param deserializer: An object model deserializer. + Instead, you should access the following operations through + :class:`~azure.mgmt.resource.resources.v2016_09_01.aio.ResourceManagementClient`'s + :attr:`resource_groups` attribute. """ models = _models - def __init__(self, client, config, serializer, deserializer) -> None: - self._client = client - self._serialize = serializer - self._deserialize = deserializer - self._config = config + def __init__(self, *args, **kwargs) -> None: + input_args = list(args) + self._client = input_args.pop(0) if input_args else kwargs.pop("client") + self._config = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") @distributed_trace def list_resources( @@ -1037,10 +1267,10 @@ def list_resources( expand: Optional[str] = None, top: Optional[int] = None, **kwargs: Any - ) -> AsyncIterable["_models.ResourceListResult"]: + ) -> AsyncIterable["_models.GenericResourceExpanded"]: """Get all the resources for a resource group. - :param resource_group_name: The resource group with the resources to get. + :param resource_group_name: The resource group with the resources to get. Required. :type resource_group_name: str :param filter: The filter to apply on the operation. Default value is None. :type filter: str @@ -1052,42 +1282,51 @@ def list_resources( value is None. :type top: int :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either ResourceListResult or the result of cls(response) + :return: An iterator like instance of either GenericResourceExpanded or the result of + cls(response) :rtype: - ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.resource.resources.v2016_09_01.models.ResourceListResult] - :raises: ~azure.core.exceptions.HttpResponseError + ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.resource.resources.v2016_09_01.models.GenericResourceExpanded] + :raises ~azure.core.exceptions.HttpResponseError: """ - api_version = kwargs.pop('api_version', "2016-09-01") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2016-09-01")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[_models.ResourceListResult] - cls = kwargs.pop('cls', None) # type: ClsType["_models.ResourceListResult"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) + def prepare_request(next_link=None): if not next_link: - + request = build_resource_groups_list_resources_request( resource_group_name=resource_group_name, subscription_id=self._config.subscription_id, - api_version=api_version, filter=filter, expand=expand, top=top, - template_url=self.list_resources.metadata['url'], + api_version=api_version, + template_url=self.list_resources.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore else: - - request = build_resource_groups_list_resources_request( - resource_group_name=resource_group_name, - subscription_id=self._config.subscription_id, - template_url=next_link, - ) + # make call to next link with the client's api-version + _parsed_next_link = urlparse(next_link) + _next_request_params = case_insensitive_dict(parse_qs(_parsed_next_link.query)) + _next_request_params["api-version"] = self._config.api_version + request = HttpRequest("GET", urljoin(next_link, _parsed_next_link.path), params=_next_request_params) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore request.method = "GET" return request @@ -1101,10 +1340,8 @@ async def extract_data(pipeline_response): async def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) response = pipeline_response.http_response @@ -1114,51 +1351,51 @@ async def get_next(next_link=None): return pipeline_response + return AsyncItemPaged(get_next, extract_data) - return AsyncItemPaged( - get_next, extract_data - ) - list_resources.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/resources"} # type: ignore + list_resources.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/resources"} # type: ignore @distributed_trace_async - async def check_existence( - self, - resource_group_name: str, - **kwargs: Any - ) -> bool: + async def check_existence(self, resource_group_name: str, **kwargs: Any) -> bool: """Checks whether a resource group exists. :param resource_group_name: The name of the resource group to check. The name is case - insensitive. + insensitive. Required. :type resource_group_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: bool, or the result of cls(response) + :return: bool or the result of cls(response) :rtype: bool - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType[None] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) - api_version = kwargs.pop('api_version', "2016-09-01") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2016-09-01")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[None] - request = build_resource_groups_check_existence_request( resource_group_name=resource_group_name, subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.check_existence.metadata['url'], + template_url=self.check_existence.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [204, 404]: @@ -1169,37 +1406,92 @@ async def check_existence( return cls(pipeline_response, None, {}) return 200 <= response.status_code <= 299 - check_existence.metadata = {'url': "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}"} # type: ignore + check_existence.metadata = {"url": "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}"} # type: ignore - - @distributed_trace_async + @overload async def create_or_update( self, resource_group_name: str, - parameters: "_models.ResourceGroup", + parameters: _models.ResourceGroup, + *, + content_type: str = "application/json", **kwargs: Any - ) -> "_models.ResourceGroup": + ) -> _models.ResourceGroup: """Creates a resource group. - :param resource_group_name: The name of the resource group to create or update. + :param resource_group_name: The name of the resource group to create or update. Required. :type resource_group_name: str - :param parameters: Parameters supplied to the create or update a resource group. + :param parameters: Parameters supplied to the create or update a resource group. Required. :type parameters: ~azure.mgmt.resource.resources.v2016_09_01.models.ResourceGroup + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: ResourceGroup or the result of cls(response) + :rtype: ~azure.mgmt.resource.resources.v2016_09_01.models.ResourceGroup + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + async def create_or_update( + self, resource_group_name: str, parameters: IO, *, content_type: str = "application/json", **kwargs: Any + ) -> _models.ResourceGroup: + """Creates a resource group. + + :param resource_group_name: The name of the resource group to create or update. Required. + :type resource_group_name: str + :param parameters: Parameters supplied to the create or update a resource group. Required. + :type parameters: IO + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: ResourceGroup or the result of cls(response) + :rtype: ~azure.mgmt.resource.resources.v2016_09_01.models.ResourceGroup + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace_async + async def create_or_update( + self, resource_group_name: str, parameters: Union[_models.ResourceGroup, IO], **kwargs: Any + ) -> _models.ResourceGroup: + """Creates a resource group. + + :param resource_group_name: The name of the resource group to create or update. Required. + :type resource_group_name: str + :param parameters: Parameters supplied to the create or update a resource group. Is either a + model type or a IO type. Required. + :type parameters: ~azure.mgmt.resource.resources.v2016_09_01.models.ResourceGroup or IO + :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. + Default value is None. + :paramtype content_type: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: ResourceGroup, or the result of cls(response) + :return: ResourceGroup or the result of cls(response) :rtype: ~azure.mgmt.resource.resources.v2016_09_01.models.ResourceGroup - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.ResourceGroup"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) - api_version = kwargs.pop('api_version', "2016-09-01") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - _json = self._serialize.body(parameters, 'ResourceGroup') + api_version = kwargs.pop("api_version", _params.pop("api-version", "2016-09-01")) # type: str + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.ResourceGroup] + + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(parameters, (IO, bytes)): + _content = parameters + else: + _json = self._serialize.body(parameters, "ResourceGroup") request = build_resource_groups_create_or_update_request( resource_group_name=resource_group_name, @@ -1207,16 +1499,18 @@ async def create_or_update( api_version=api_version, content_type=content_type, json=_json, - template_url=self.create_or_update.metadata['url'], + content=_content, + template_url=self.create_or_update.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200, 201]: @@ -1224,47 +1518,50 @@ async def create_or_update( raise HttpResponseError(response=response, error_format=ARMErrorFormat) if response.status_code == 200: - deserialized = self._deserialize('ResourceGroup', pipeline_response) + deserialized = self._deserialize("ResourceGroup", pipeline_response) if response.status_code == 201: - deserialized = self._deserialize('ResourceGroup', pipeline_response) + deserialized = self._deserialize("ResourceGroup", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - create_or_update.metadata = {'url': "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}"} # type: ignore - + create_or_update.metadata = {"url": "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}"} # type: ignore async def _delete_initial( # pylint: disable=inconsistent-return-statements - self, - resource_group_name: str, - **kwargs: Any + self, resource_group_name: str, **kwargs: Any ) -> None: - cls = kwargs.pop('cls', None) # type: ClsType[None] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) - api_version = kwargs.pop('api_version', "2016-09-01") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - request = build_resource_groups_delete_request_initial( + api_version = kwargs.pop("api_version", _params.pop("api-version", "2016-09-01")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[None] + + request = build_resource_groups_delete_request( resource_group_name=resource_group_name, subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self._delete_initial.metadata['url'], + template_url=self._delete_initial.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200, 202]: @@ -1274,22 +1571,17 @@ async def _delete_initial( # pylint: disable=inconsistent-return-statements if cls: return cls(pipeline_response, None, {}) - _delete_initial.metadata = {'url': "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}"} # type: ignore - + _delete_initial.metadata = {"url": "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}"} # type: ignore @distributed_trace_async - async def begin_delete( # pylint: disable=inconsistent-return-statements - self, - resource_group_name: str, - **kwargs: Any - ) -> AsyncLROPoller[None]: + async def begin_delete(self, resource_group_name: str, **kwargs: Any) -> AsyncLROPoller[None]: """Deletes a resource group. When you delete a resource group, all of its resources are also deleted. Deleting a resource group deletes all of its template deployments and currently stored operations. :param resource_group_name: The name of the resource group to delete. The name is case - insensitive. + insensitive. Required. :type resource_group_name: str :keyword callable cls: A custom type or function that will be passed the direct response :keyword str continuation_token: A continuation token to restart a poller from a saved state. @@ -1301,106 +1593,113 @@ async def begin_delete( # pylint: disable=inconsistent-return-statements Retry-After header is present. :return: An instance of AsyncLROPoller that returns either None or the result of cls(response) :rtype: ~azure.core.polling.AsyncLROPoller[None] - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - api_version = kwargs.pop('api_version', "2016-09-01") # type: str - polling = kwargs.pop('polling', True) # type: Union[bool, AsyncPollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType[None] - lro_delay = kwargs.pop( - 'polling_interval', - self._config.polling_interval - ) - cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2016-09-01")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[None] + polling = kwargs.pop("polling", True) # type: Union[bool, AsyncPollingMethod] + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token = kwargs.pop("continuation_token", None) # type: Optional[str] if cont_token is None: - raw_result = await self._delete_initial( + raw_result = await self._delete_initial( # type: ignore resource_group_name=resource_group_name, api_version=api_version, - cls=lambda x,y,z: x, + cls=lambda x, y, z: x, + headers=_headers, + params=_params, **kwargs ) - kwargs.pop('error_map', None) + kwargs.pop("error_map", None) - def get_long_running_output(pipeline_response): + def get_long_running_output(pipeline_response): # pylint: disable=inconsistent-return-statements if cls: return cls(pipeline_response, None, {}) - - if polling is True: polling_method = AsyncARMPolling(lro_delay, **kwargs) - elif polling is False: polling_method = AsyncNoPolling() - else: polling_method = polling + if polling is True: + polling_method = cast(AsyncPollingMethod, AsyncARMPolling(lro_delay, **kwargs)) # type: AsyncPollingMethod + elif polling is False: + polling_method = cast(AsyncPollingMethod, AsyncNoPolling()) + else: + polling_method = polling if cont_token: return AsyncLROPoller.from_continuation_token( polling_method=polling_method, continuation_token=cont_token, client=self._client, - deserialization_callback=get_long_running_output + deserialization_callback=get_long_running_output, ) return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) - begin_delete.metadata = {'url': "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}"} # type: ignore + begin_delete.metadata = {"url": "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}"} # type: ignore @distributed_trace_async - async def get( - self, - resource_group_name: str, - **kwargs: Any - ) -> "_models.ResourceGroup": + async def get(self, resource_group_name: str, **kwargs: Any) -> _models.ResourceGroup: """Gets a resource group. :param resource_group_name: The name of the resource group to get. The name is case - insensitive. + insensitive. Required. :type resource_group_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: ResourceGroup, or the result of cls(response) + :return: ResourceGroup or the result of cls(response) :rtype: ~azure.mgmt.resource.resources.v2016_09_01.models.ResourceGroup - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.ResourceGroup"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) - api_version = kwargs.pop('api_version', "2016-09-01") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2016-09-01")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[_models.ResourceGroup] - request = build_resource_groups_get_request( resource_group_name=resource_group_name, subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.get.metadata['url'], + template_url=self.get.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) - deserialized = self._deserialize('ResourceGroup', pipeline_response) + deserialized = self._deserialize("ResourceGroup", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - get.metadata = {'url': "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}"} # type: ignore + get.metadata = {"url": "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}"} # type: ignore - - @distributed_trace_async + @overload async def patch( self, resource_group_name: str, - parameters: "_models.ResourceGroup", + parameters: _models.ResourceGroup, + *, + content_type: str = "application/json", **kwargs: Any - ) -> "_models.ResourceGroup": + ) -> _models.ResourceGroup: """Updates a resource group. Resource groups can be updated through a simple PATCH operation to a group address. The format @@ -1408,25 +1707,89 @@ async def patch( the current value is retained. :param resource_group_name: The name of the resource group to update. The name is case - insensitive. + insensitive. Required. :type resource_group_name: str - :param parameters: Parameters supplied to update a resource group. + :param parameters: Parameters supplied to update a resource group. Required. :type parameters: ~azure.mgmt.resource.resources.v2016_09_01.models.ResourceGroup + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: ResourceGroup or the result of cls(response) + :rtype: ~azure.mgmt.resource.resources.v2016_09_01.models.ResourceGroup + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + async def patch( + self, resource_group_name: str, parameters: IO, *, content_type: str = "application/json", **kwargs: Any + ) -> _models.ResourceGroup: + """Updates a resource group. + + Resource groups can be updated through a simple PATCH operation to a group address. The format + of the request is the same as that for creating a resource group. If a field is unspecified, + the current value is retained. + + :param resource_group_name: The name of the resource group to update. The name is case + insensitive. Required. + :type resource_group_name: str + :param parameters: Parameters supplied to update a resource group. Required. + :type parameters: IO + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: ResourceGroup or the result of cls(response) + :rtype: ~azure.mgmt.resource.resources.v2016_09_01.models.ResourceGroup + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace_async + async def patch( + self, resource_group_name: str, parameters: Union[_models.ResourceGroup, IO], **kwargs: Any + ) -> _models.ResourceGroup: + """Updates a resource group. + + Resource groups can be updated through a simple PATCH operation to a group address. The format + of the request is the same as that for creating a resource group. If a field is unspecified, + the current value is retained. + + :param resource_group_name: The name of the resource group to update. The name is case + insensitive. Required. + :type resource_group_name: str + :param parameters: Parameters supplied to update a resource group. Is either a model type or a + IO type. Required. + :type parameters: ~azure.mgmt.resource.resources.v2016_09_01.models.ResourceGroup or IO + :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. + Default value is None. + :paramtype content_type: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: ResourceGroup, or the result of cls(response) + :return: ResourceGroup or the result of cls(response) :rtype: ~azure.mgmt.resource.resources.v2016_09_01.models.ResourceGroup - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.ResourceGroup"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) - api_version = kwargs.pop('api_version', "2016-09-01") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - _json = self._serialize.body(parameters, 'ResourceGroup') + api_version = kwargs.pop("api_version", _params.pop("api-version", "2016-09-01")) # type: str + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.ResourceGroup] + + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(parameters, (IO, bytes)): + _content = parameters + else: + _json = self._serialize.body(parameters, "ResourceGroup") request = build_resource_groups_patch_request( resource_group_name=resource_group_name, @@ -1434,60 +1797,117 @@ async def patch( api_version=api_version, content_type=content_type, json=_json, - template_url=self.patch.metadata['url'], + content=_content, + template_url=self.patch.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) - deserialized = self._deserialize('ResourceGroup', pipeline_response) + deserialized = self._deserialize("ResourceGroup", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - patch.metadata = {'url': "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}"} # type: ignore - + patch.metadata = {"url": "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}"} # type: ignore - @distributed_trace_async + @overload async def export_template( self, resource_group_name: str, - parameters: "_models.ExportTemplateRequest", + parameters: _models.ExportTemplateRequest, + *, + content_type: str = "application/json", **kwargs: Any - ) -> "_models.ResourceGroupExportResult": + ) -> _models.ResourceGroupExportResult: """Captures the specified resource group as a template. - :param resource_group_name: The name of the resource group to export as a template. + :param resource_group_name: The name of the resource group to export as a template. Required. :type resource_group_name: str - :param parameters: Parameters for exporting the template. + :param parameters: Parameters for exporting the template. Required. :type parameters: ~azure.mgmt.resource.resources.v2016_09_01.models.ExportTemplateRequest + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: ResourceGroupExportResult or the result of cls(response) + :rtype: ~azure.mgmt.resource.resources.v2016_09_01.models.ResourceGroupExportResult + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + async def export_template( + self, resource_group_name: str, parameters: IO, *, content_type: str = "application/json", **kwargs: Any + ) -> _models.ResourceGroupExportResult: + """Captures the specified resource group as a template. + + :param resource_group_name: The name of the resource group to export as a template. Required. + :type resource_group_name: str + :param parameters: Parameters for exporting the template. Required. + :type parameters: IO + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: ResourceGroupExportResult or the result of cls(response) + :rtype: ~azure.mgmt.resource.resources.v2016_09_01.models.ResourceGroupExportResult + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace_async + async def export_template( + self, resource_group_name: str, parameters: Union[_models.ExportTemplateRequest, IO], **kwargs: Any + ) -> _models.ResourceGroupExportResult: + """Captures the specified resource group as a template. + + :param resource_group_name: The name of the resource group to export as a template. Required. + :type resource_group_name: str + :param parameters: Parameters for exporting the template. Is either a model type or a IO type. + Required. + :type parameters: ~azure.mgmt.resource.resources.v2016_09_01.models.ExportTemplateRequest or IO + :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. + Default value is None. + :paramtype content_type: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: ResourceGroupExportResult, or the result of cls(response) + :return: ResourceGroupExportResult or the result of cls(response) :rtype: ~azure.mgmt.resource.resources.v2016_09_01.models.ResourceGroupExportResult - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.ResourceGroupExportResult"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) - api_version = kwargs.pop('api_version', "2016-09-01") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - _json = self._serialize.body(parameters, 'ExportTemplateRequest') + api_version = kwargs.pop("api_version", _params.pop("api-version", "2016-09-01")) # type: str + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.ResourceGroupExportResult] + + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(parameters, (IO, bytes)): + _content = parameters + else: + _json = self._serialize.body(parameters, "ExportTemplateRequest") request = build_resource_groups_export_template_request( resource_group_name=resource_group_name, @@ -1495,39 +1915,37 @@ async def export_template( api_version=api_version, content_type=content_type, json=_json, - template_url=self.export_template.metadata['url'], + content=_content, + template_url=self.export_template.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) - deserialized = self._deserialize('ResourceGroupExportResult', pipeline_response) + deserialized = self._deserialize("ResourceGroupExportResult", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - export_template.metadata = {'url': "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/exportTemplate"} # type: ignore - + export_template.metadata = {"url": "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/exportTemplate"} # type: ignore @distributed_trace def list( - self, - filter: Optional[str] = None, - top: Optional[int] = None, - **kwargs: Any - ) -> AsyncIterable["_models.ResourceGroupListResult"]: + self, filter: Optional[str] = None, top: Optional[int] = None, **kwargs: Any + ) -> AsyncIterable["_models.ResourceGroup"]: """Gets all the resource groups for a subscription. :param filter: The filter to apply on the operation. Default value is None. @@ -1536,40 +1954,48 @@ def list( Default value is None. :type top: int :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either ResourceGroupListResult or the result of - cls(response) + :return: An iterator like instance of either ResourceGroup or the result of cls(response) :rtype: - ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.resource.resources.v2016_09_01.models.ResourceGroupListResult] - :raises: ~azure.core.exceptions.HttpResponseError + ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.resource.resources.v2016_09_01.models.ResourceGroup] + :raises ~azure.core.exceptions.HttpResponseError: """ - api_version = kwargs.pop('api_version', "2016-09-01") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2016-09-01")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[_models.ResourceGroupListResult] - cls = kwargs.pop('cls', None) # type: ClsType["_models.ResourceGroupListResult"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) + def prepare_request(next_link=None): if not next_link: - + request = build_resource_groups_list_request( subscription_id=self._config.subscription_id, - api_version=api_version, filter=filter, top=top, - template_url=self.list.metadata['url'], + 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.url = self._client.format_url(request.url) # type: ignore else: - - request = build_resource_groups_list_request( - subscription_id=self._config.subscription_id, - template_url=next_link, - ) + # make call to next link with the client's api-version + _parsed_next_link = urlparse(next_link) + _next_request_params = case_insensitive_dict(parse_qs(_parsed_next_link.query)) + _next_request_params["api-version"] = self._config.api_version + request = HttpRequest("GET", urljoin(next_link, _parsed_next_link.path), params=_next_request_params) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore request.method = "GET" return request @@ -1583,10 +2009,8 @@ async def extract_data(pipeline_response): async def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) response = pipeline_response.http_response @@ -1596,66 +2020,74 @@ async def get_next(next_link=None): return pipeline_response + return AsyncItemPaged(get_next, extract_data) - return AsyncItemPaged( - get_next, extract_data - ) - list.metadata = {'url': "/subscriptions/{subscriptionId}/resourcegroups"} # type: ignore -class ResourcesOperations: - """ResourcesOperations async operations. + list.metadata = {"url": "/subscriptions/{subscriptionId}/resourcegroups"} # type: ignore - You should not instantiate this class directly. Instead, you should create a Client instance that - instantiates it for you and attaches it as an attribute. - :ivar models: Alias to model classes used in this operation group. - :type models: ~azure.mgmt.resource.resources.v2016_09_01.models - :param client: Client for service requests. - :param config: Configuration of service client. - :param serializer: An object model serializer. - :param deserializer: An object model deserializer. +class ResourcesOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. + + Instead, you should access the following operations through + :class:`~azure.mgmt.resource.resources.v2016_09_01.aio.ResourceManagementClient`'s + :attr:`resources` attribute. """ models = _models - def __init__(self, client, config, serializer, deserializer) -> None: - self._client = client - self._serialize = serializer - self._deserialize = deserializer - self._config = config + def __init__(self, *args, **kwargs) -> None: + input_args = list(args) + self._client = input_args.pop(0) if input_args else kwargs.pop("client") + self._config = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") async def _move_resources_initial( # pylint: disable=inconsistent-return-statements - self, - source_resource_group_name: str, - parameters: "_models.ResourcesMoveInfo", - **kwargs: Any + self, source_resource_group_name: str, parameters: Union[_models.ResourcesMoveInfo, IO], **kwargs: Any ) -> None: - cls = kwargs.pop('cls', None) # type: ClsType[None] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', "2016-09-01") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + api_version = kwargs.pop("api_version", _params.pop("api-version", "2016-09-01")) # type: str + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[None] - _json = self._serialize.body(parameters, 'ResourcesMoveInfo') + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(parameters, (IO, bytes)): + _content = parameters + else: + _json = self._serialize.body(parameters, "ResourcesMoveInfo") - request = build_resources_move_resources_request_initial( + request = build_resources_move_resources_request( source_resource_group_name=source_resource_group_name, subscription_id=self._config.subscription_id, api_version=api_version, content_type=content_type, json=_json, - template_url=self._move_resources_initial.metadata['url'], + content=_content, + template_url=self._move_resources_initial.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [202, 204]: @@ -1665,14 +2097,15 @@ async def _move_resources_initial( # pylint: disable=inconsistent-return-statem if cls: return cls(pipeline_response, None, {}) - _move_resources_initial.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{sourceResourceGroupName}/moveResources"} # type: ignore - + _move_resources_initial.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{sourceResourceGroupName}/moveResources"} # type: ignore - @distributed_trace_async - async def begin_move_resources( # pylint: disable=inconsistent-return-statements + @overload + async def begin_move_resources( self, source_resource_group_name: str, - parameters: "_models.ResourcesMoveInfo", + parameters: _models.ResourcesMoveInfo, + *, + content_type: str = "application/json", **kwargs: Any ) -> AsyncLROPoller[None]: """Moves resources from one resource group to another resource group. @@ -1683,10 +2116,13 @@ async def begin_move_resources( # pylint: disable=inconsistent-return-statement the groups until the move completes. :param source_resource_group_name: The name of the resource group containing the resources to - move. + move. Required. :type source_resource_group_name: str - :param parameters: Parameters for moving resources. + :param parameters: Parameters for moving resources. Required. :type parameters: ~azure.mgmt.resource.resources.v2016_09_01.models.ResourcesMoveInfo + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str :keyword callable cls: A custom type or function that will be passed the direct response :keyword str continuation_token: A continuation token to restart a poller from a saved state. :keyword polling: By default, your polling method will be AsyncARMPolling. Pass in False for @@ -1697,55 +2133,120 @@ async def begin_move_resources( # pylint: disable=inconsistent-return-statement Retry-After header is present. :return: An instance of AsyncLROPoller that returns either None or the result of cls(response) :rtype: ~azure.core.polling.AsyncLROPoller[None] - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - api_version = kwargs.pop('api_version', "2016-09-01") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] - polling = kwargs.pop('polling', True) # type: Union[bool, AsyncPollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType[None] - lro_delay = kwargs.pop( - 'polling_interval', - self._config.polling_interval - ) - cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] + + @overload + async def begin_move_resources( + self, source_resource_group_name: str, parameters: IO, *, content_type: str = "application/json", **kwargs: Any + ) -> AsyncLROPoller[None]: + """Moves resources from one resource group to another resource group. + + The resources to move must be in the same source resource group. The target resource group may + be in a different subscription. When moving resources, both the source group and the target + group are locked for the duration of the operation. Write and delete operations are blocked on + the groups until the move completes. + + :param source_resource_group_name: The name of the resource group containing the resources to + move. Required. + :type source_resource_group_name: str + :param parameters: Parameters for moving resources. Required. + :type parameters: IO + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be AsyncARMPolling. Pass in False for + this operation to not poll, or pass in your own initialized polling object for a personal + polling strategy. + :paramtype polling: bool or ~azure.core.polling.AsyncPollingMethod + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of AsyncLROPoller that returns either None or the result of cls(response) + :rtype: ~azure.core.polling.AsyncLROPoller[None] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace_async + async def begin_move_resources( + self, source_resource_group_name: str, parameters: Union[_models.ResourcesMoveInfo, IO], **kwargs: Any + ) -> AsyncLROPoller[None]: + """Moves resources from one resource group to another resource group. + + The resources to move must be in the same source resource group. The target resource group may + be in a different subscription. When moving resources, both the source group and the target + group are locked for the duration of the operation. Write and delete operations are blocked on + the groups until the move completes. + + :param source_resource_group_name: The name of the resource group containing the resources to + move. Required. + :type source_resource_group_name: str + :param parameters: Parameters for moving resources. Is either a model type or a IO type. + Required. + :type parameters: ~azure.mgmt.resource.resources.v2016_09_01.models.ResourcesMoveInfo or IO + :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. + Default value is None. + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be AsyncARMPolling. Pass in False for + this operation to not poll, or pass in your own initialized polling object for a personal + polling strategy. + :paramtype polling: bool or ~azure.core.polling.AsyncPollingMethod + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of AsyncLROPoller that returns either None or the result of cls(response) + :rtype: ~azure.core.polling.AsyncLROPoller[None] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _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", "2016-09-01")) # type: str + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[None] + polling = kwargs.pop("polling", True) # type: Union[bool, AsyncPollingMethod] + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token = kwargs.pop("continuation_token", None) # type: Optional[str] if cont_token is None: - raw_result = await self._move_resources_initial( + raw_result = await self._move_resources_initial( # type: ignore source_resource_group_name=source_resource_group_name, parameters=parameters, api_version=api_version, content_type=content_type, - cls=lambda x,y,z: x, + cls=lambda x, y, z: x, + headers=_headers, + params=_params, **kwargs ) - kwargs.pop('error_map', None) + kwargs.pop("error_map", None) - def get_long_running_output(pipeline_response): + def get_long_running_output(pipeline_response): # pylint: disable=inconsistent-return-statements if cls: return cls(pipeline_response, None, {}) - - if polling is True: polling_method = AsyncARMPolling(lro_delay, **kwargs) - elif polling is False: polling_method = AsyncNoPolling() - else: polling_method = polling + if polling is True: + polling_method = cast(AsyncPollingMethod, AsyncARMPolling(lro_delay, **kwargs)) # type: AsyncPollingMethod + elif polling is False: + polling_method = cast(AsyncPollingMethod, AsyncNoPolling()) + else: + polling_method = polling if cont_token: return AsyncLROPoller.from_continuation_token( polling_method=polling_method, continuation_token=cont_token, client=self._client, - deserialization_callback=get_long_running_output + deserialization_callback=get_long_running_output, ) return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) - begin_move_resources.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{sourceResourceGroupName}/moveResources"} # type: ignore + begin_move_resources.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{sourceResourceGroupName}/moveResources"} # type: ignore @distributed_trace def list( - self, - filter: Optional[str] = None, - expand: Optional[str] = None, - top: Optional[int] = None, - **kwargs: Any - ) -> AsyncIterable["_models.ResourceListResult"]: + self, filter: Optional[str] = None, expand: Optional[str] = None, top: Optional[int] = None, **kwargs: Any + ) -> AsyncIterable["_models.GenericResourceExpanded"]: """Get all the resources in a subscription. :param filter: The filter to apply on the operation. Default value is None. @@ -1758,40 +2259,50 @@ def list( value is None. :type top: int :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either ResourceListResult or the result of cls(response) + :return: An iterator like instance of either GenericResourceExpanded or the result of + cls(response) :rtype: - ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.resource.resources.v2016_09_01.models.ResourceListResult] - :raises: ~azure.core.exceptions.HttpResponseError + ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.resource.resources.v2016_09_01.models.GenericResourceExpanded] + :raises ~azure.core.exceptions.HttpResponseError: """ - api_version = kwargs.pop('api_version', "2016-09-01") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2016-09-01")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[_models.ResourceListResult] - cls = kwargs.pop('cls', None) # type: ClsType["_models.ResourceListResult"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) + def prepare_request(next_link=None): if not next_link: - + request = build_resources_list_request( subscription_id=self._config.subscription_id, - api_version=api_version, filter=filter, expand=expand, top=top, - template_url=self.list.metadata['url'], + 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.url = self._client.format_url(request.url) # type: ignore else: - - request = build_resources_list_request( - subscription_id=self._config.subscription_id, - template_url=next_link, - ) + # make call to next link with the client's api-version + _parsed_next_link = urlparse(next_link) + _next_request_params = case_insensitive_dict(parse_qs(_parsed_next_link.query)) + _next_request_params["api-version"] = self._config.api_version + request = HttpRequest("GET", urljoin(next_link, _parsed_next_link.path), params=_next_request_params) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore request.method = "GET" return request @@ -1805,10 +2316,8 @@ async def extract_data(pipeline_response): async def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) response = pipeline_response.http_response @@ -1818,11 +2327,9 @@ async def get_next(next_link=None): return pipeline_response + return AsyncItemPaged(get_next, extract_data) - return AsyncItemPaged( - get_next, extract_data - ) - list.metadata = {'url': "/subscriptions/{subscriptionId}/resources"} # type: ignore + list.metadata = {"url": "/subscriptions/{subscriptionId}/resources"} # type: ignore @distributed_trace_async async def check_existence( @@ -1838,30 +2345,36 @@ async def check_existence( """Checks whether a resource exists. :param resource_group_name: The name of the resource group containing the resource to check. - The name is case insensitive. + The name is case insensitive. Required. :type resource_group_name: str - :param resource_provider_namespace: The resource provider of the resource to check. + :param resource_provider_namespace: The resource provider of the resource to check. Required. :type resource_provider_namespace: str - :param parent_resource_path: The parent resource identity. + :param parent_resource_path: The parent resource identity. Required. :type parent_resource_path: str - :param resource_type: The resource type. + :param resource_type: The resource type. Required. :type resource_type: str - :param resource_name: The name of the resource to check whether it exists. + :param resource_name: The name of the resource to check whether it exists. Required. :type resource_name: str - :param api_version: The API version to use for the operation. + :param api_version: The API version to use for the operation. Required. :type api_version: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: bool, or the result of cls(response) + :return: bool or the result of cls(response) :rtype: bool - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType[None] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = kwargs.pop("params", {}) or {} + + cls = kwargs.pop("cls", None) # type: ClsType[None] - request = build_resources_check_existence_request( resource_group_name=resource_group_name, resource_provider_namespace=resource_provider_namespace, @@ -1870,16 +2383,17 @@ async def check_existence( resource_name=resource_name, subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.check_existence.metadata['url'], + template_url=self.check_existence.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [204, 404]: @@ -1890,8 +2404,7 @@ async def check_existence( return cls(pipeline_response, None, {}) return 200 <= response.status_code <= 299 - check_existence.metadata = {'url': "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{parentResourcePath}/{resourceType}/{resourceName}"} # type: ignore - + check_existence.metadata = {"url": "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{parentResourcePath}/{resourceType}/{resourceName}"} # type: ignore async def _delete_initial( # pylint: disable=inconsistent-return-statements self, @@ -1903,14 +2416,20 @@ async def _delete_initial( # pylint: disable=inconsistent-return-statements api_version: str, **kwargs: Any ) -> None: - cls = kwargs.pop('cls', None) # type: ClsType[None] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = kwargs.pop("params", {}) or {} + + cls = kwargs.pop("cls", None) # type: ClsType[None] - - request = build_resources_delete_request_initial( + request = build_resources_delete_request( resource_group_name=resource_group_name, resource_provider_namespace=resource_provider_namespace, parent_resource_path=parent_resource_path, @@ -1918,16 +2437,17 @@ async def _delete_initial( # pylint: disable=inconsistent-return-statements resource_name=resource_name, subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self._delete_initial.metadata['url'], + template_url=self._delete_initial.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200, 202, 204]: @@ -1937,11 +2457,10 @@ 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/{resourceProviderNamespace}/{parentResourcePath}/{resourceType}/{resourceName}"} # type: ignore - + _delete_initial.metadata = {"url": "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{parentResourcePath}/{resourceType}/{resourceName}"} # type: ignore @distributed_trace_async - async def begin_delete( # pylint: disable=inconsistent-return-statements + async def begin_delete( self, resource_group_name: str, resource_provider_namespace: str, @@ -1954,17 +2473,17 @@ async def begin_delete( # pylint: disable=inconsistent-return-statements """Deletes a resource. :param resource_group_name: The name of the resource group that contains the resource to - delete. The name is case insensitive. + delete. The name is case insensitive. Required. :type resource_group_name: str - :param resource_provider_namespace: The namespace of the resource provider. + :param resource_provider_namespace: The namespace of the resource provider. Required. :type resource_provider_namespace: str - :param parent_resource_path: The parent resource identity. + :param parent_resource_path: The parent resource identity. Required. :type parent_resource_path: str - :param resource_type: The resource type. + :param resource_type: The resource type. Required. :type resource_type: str - :param resource_name: The name of the resource to delete. + :param resource_name: The name of the resource to delete. Required. :type resource_name: str - :param api_version: The API version to use for the operation. + :param api_version: The API version to use for the operation. Required. :type api_version: str :keyword callable cls: A custom type or function that will be passed the direct response :keyword str continuation_token: A continuation token to restart a poller from a saved state. @@ -1976,46 +2495,50 @@ async def begin_delete( # pylint: disable=inconsistent-return-statements Retry-After header is present. :return: An instance of AsyncLROPoller that returns either None or the result of cls(response) :rtype: ~azure.core.polling.AsyncLROPoller[None] - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - polling = kwargs.pop('polling', True) # type: Union[bool, AsyncPollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType[None] - lro_delay = kwargs.pop( - 'polling_interval', - self._config.polling_interval - ) - cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] + _headers = kwargs.pop("headers", {}) or {} + _params = kwargs.pop("params", {}) or {} + + cls = kwargs.pop("cls", None) # type: ClsType[None] + polling = kwargs.pop("polling", True) # type: Union[bool, AsyncPollingMethod] + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token = kwargs.pop("continuation_token", None) # type: Optional[str] if cont_token is None: - raw_result = await self._delete_initial( + raw_result = await self._delete_initial( # type: ignore resource_group_name=resource_group_name, resource_provider_namespace=resource_provider_namespace, parent_resource_path=parent_resource_path, resource_type=resource_type, resource_name=resource_name, api_version=api_version, - cls=lambda x,y,z: x, + cls=lambda x, y, z: x, + headers=_headers, + params=_params, **kwargs ) - kwargs.pop('error_map', None) + kwargs.pop("error_map", None) - def get_long_running_output(pipeline_response): + def get_long_running_output(pipeline_response): # pylint: disable=inconsistent-return-statements if cls: return cls(pipeline_response, None, {}) - - if polling is True: polling_method = AsyncARMPolling(lro_delay, **kwargs) - elif polling is False: polling_method = AsyncNoPolling() - else: polling_method = polling + if polling is True: + polling_method = cast(AsyncPollingMethod, AsyncARMPolling(lro_delay, **kwargs)) # type: AsyncPollingMethod + elif polling is False: + polling_method = cast(AsyncPollingMethod, AsyncNoPolling()) + else: + polling_method = polling if cont_token: return AsyncLROPoller.from_continuation_token( polling_method=polling_method, continuation_token=cont_token, client=self._client, - deserialization_callback=get_long_running_output + deserialization_callback=get_long_running_output, ) return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) - begin_delete.metadata = {'url': "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{parentResourcePath}/{resourceType}/{resourceName}"} # type: ignore + begin_delete.metadata = {"url": "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{parentResourcePath}/{resourceType}/{resourceName}"} # type: ignore async def _create_or_update_initial( self, @@ -2025,39 +2548,53 @@ async def _create_or_update_initial( resource_type: str, resource_name: str, api_version: str, - parameters: "_models.GenericResource", + parameters: Union[_models.GenericResource, IO], **kwargs: Any - ) -> Optional["_models.GenericResource"]: - cls = kwargs.pop('cls', None) # type: ClsType[Optional["_models.GenericResource"]] + ) -> Optional[_models.GenericResource]: error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = kwargs.pop("params", {}) or {} - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[Optional[_models.GenericResource]] - _json = self._serialize.body(parameters, 'GenericResource') + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(parameters, (IO, bytes)): + _content = parameters + else: + _json = self._serialize.body(parameters, "GenericResource") - request = build_resources_create_or_update_request_initial( + request = build_resources_create_or_update_request( resource_group_name=resource_group_name, resource_provider_namespace=resource_provider_namespace, parent_resource_path=parent_resource_path, resource_type=resource_type, resource_name=resource_name, subscription_id=self._config.subscription_id, - content_type=content_type, api_version=api_version, + content_type=content_type, json=_json, - template_url=self._create_or_update_initial.metadata['url'], + content=_content, + template_url=self._create_or_update_initial.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200, 201, 202]: @@ -2066,18 +2603,115 @@ async def _create_or_update_initial( deserialized = None if response.status_code == 200: - deserialized = self._deserialize('GenericResource', pipeline_response) + deserialized = self._deserialize("GenericResource", pipeline_response) if response.status_code == 201: - deserialized = self._deserialize('GenericResource', pipeline_response) + deserialized = self._deserialize("GenericResource", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - _create_or_update_initial.metadata = {'url': "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{parentResourcePath}/{resourceType}/{resourceName}"} # type: ignore + _create_or_update_initial.metadata = {"url": "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{parentResourcePath}/{resourceType}/{resourceName}"} # type: ignore + + @overload + async def begin_create_or_update( + self, + resource_group_name: str, + resource_provider_namespace: str, + parent_resource_path: str, + resource_type: str, + resource_name: str, + api_version: str, + parameters: _models.GenericResource, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> AsyncLROPoller[_models.GenericResource]: + """Creates a resource. + + :param resource_group_name: The name of the resource group for the resource. The name is case + insensitive. Required. + :type resource_group_name: str + :param resource_provider_namespace: The namespace of the resource provider. Required. + :type resource_provider_namespace: str + :param parent_resource_path: The parent resource identity. Required. + :type parent_resource_path: str + :param resource_type: The resource type of the resource to create. Required. + :type resource_type: str + :param resource_name: The name of the resource to create. Required. + :type resource_name: str + :param api_version: The API version to use for the operation. Required. + :type api_version: str + :param parameters: Parameters for creating or updating the resource. Required. + :type parameters: ~azure.mgmt.resource.resources.v2016_09_01.models.GenericResource + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be AsyncARMPolling. Pass in False for + this operation to not poll, or pass in your own initialized polling object for a personal + polling strategy. + :paramtype polling: bool or ~azure.core.polling.AsyncPollingMethod + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of AsyncLROPoller that returns either GenericResource or the result of + cls(response) + :rtype: + ~azure.core.polling.AsyncLROPoller[~azure.mgmt.resource.resources.v2016_09_01.models.GenericResource] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + async def begin_create_or_update( + self, + resource_group_name: str, + resource_provider_namespace: str, + parent_resource_path: str, + resource_type: str, + resource_name: str, + api_version: str, + parameters: IO, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> AsyncLROPoller[_models.GenericResource]: + """Creates a resource. + :param resource_group_name: The name of the resource group for the resource. The name is case + insensitive. Required. + :type resource_group_name: str + :param resource_provider_namespace: The namespace of the resource provider. Required. + :type resource_provider_namespace: str + :param parent_resource_path: The parent resource identity. Required. + :type parent_resource_path: str + :param resource_type: The resource type of the resource to create. Required. + :type resource_type: str + :param resource_name: The name of the resource to create. Required. + :type resource_name: str + :param api_version: The API version to use for the operation. Required. + :type api_version: str + :param parameters: Parameters for creating or updating the resource. Required. + :type parameters: IO + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be AsyncARMPolling. Pass in False for + this operation to not poll, or pass in your own initialized polling object for a personal + polling strategy. + :paramtype polling: bool or ~azure.core.polling.AsyncPollingMethod + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of AsyncLROPoller that returns either GenericResource or the result of + cls(response) + :rtype: + ~azure.core.polling.AsyncLROPoller[~azure.mgmt.resource.resources.v2016_09_01.models.GenericResource] + :raises ~azure.core.exceptions.HttpResponseError: + """ @distributed_trace_async async def begin_create_or_update( @@ -2088,26 +2722,30 @@ async def begin_create_or_update( resource_type: str, resource_name: str, api_version: str, - parameters: "_models.GenericResource", + parameters: Union[_models.GenericResource, IO], **kwargs: Any - ) -> AsyncLROPoller["_models.GenericResource"]: + ) -> AsyncLROPoller[_models.GenericResource]: """Creates a resource. :param resource_group_name: The name of the resource group for the resource. The name is case - insensitive. + insensitive. Required. :type resource_group_name: str - :param resource_provider_namespace: The namespace of the resource provider. + :param resource_provider_namespace: The namespace of the resource provider. Required. :type resource_provider_namespace: str - :param parent_resource_path: The parent resource identity. + :param parent_resource_path: The parent resource identity. Required. :type parent_resource_path: str - :param resource_type: The resource type of the resource to create. + :param resource_type: The resource type of the resource to create. Required. :type resource_type: str - :param resource_name: The name of the resource to create. + :param resource_name: The name of the resource to create. Required. :type resource_name: str - :param api_version: The API version to use for the operation. + :param api_version: The API version to use for the operation. Required. :type api_version: str - :param parameters: Parameters for creating or updating the resource. - :type parameters: ~azure.mgmt.resource.resources.v2016_09_01.models.GenericResource + :param parameters: Parameters for creating or updating the resource. Is either a model type or + a IO type. Required. + :type parameters: ~azure.mgmt.resource.resources.v2016_09_01.models.GenericResource or IO + :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. + Default value is None. + :paramtype content_type: str :keyword callable cls: A custom type or function that will be passed the direct response :keyword str continuation_token: A continuation token to restart a poller from a saved state. :keyword polling: By default, your polling method will be AsyncARMPolling. Pass in False for @@ -2120,18 +2758,18 @@ async def begin_create_or_update( cls(response) :rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.resource.resources.v2016_09_01.models.GenericResource] - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] - polling = kwargs.pop('polling', True) # type: Union[bool, AsyncPollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType["_models.GenericResource"] - lro_delay = kwargs.pop( - 'polling_interval', - self._config.polling_interval - ) - cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = kwargs.pop("params", {}) or {} + + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.GenericResource] + polling = kwargs.pop("polling", True) # type: Union[bool, AsyncPollingMethod] + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token = kwargs.pop("continuation_token", None) # type: Optional[str] if cont_token is None: - raw_result = await self._create_or_update_initial( + raw_result = await self._create_or_update_initial( # type: ignore resource_group_name=resource_group_name, resource_provider_namespace=resource_provider_namespace, parent_resource_path=parent_resource_path, @@ -2140,32 +2778,35 @@ async def begin_create_or_update( api_version=api_version, parameters=parameters, content_type=content_type, - cls=lambda x,y,z: x, + cls=lambda x, y, z: x, + headers=_headers, + params=_params, **kwargs ) - kwargs.pop('error_map', None) + kwargs.pop("error_map", None) def get_long_running_output(pipeline_response): - response = pipeline_response.http_response - deserialized = self._deserialize('GenericResource', pipeline_response) + deserialized = self._deserialize("GenericResource", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - - if polling is True: polling_method = AsyncARMPolling(lro_delay, **kwargs) - elif polling is False: polling_method = AsyncNoPolling() - else: polling_method = polling + if polling is True: + polling_method = cast(AsyncPollingMethod, AsyncARMPolling(lro_delay, **kwargs)) # type: AsyncPollingMethod + elif polling is False: + polling_method = cast(AsyncPollingMethod, AsyncNoPolling()) + else: + polling_method = polling if cont_token: return AsyncLROPoller.from_continuation_token( polling_method=polling_method, continuation_token=cont_token, client=self._client, - deserialization_callback=get_long_running_output + deserialization_callback=get_long_running_output, ) return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) - begin_create_or_update.metadata = {'url': "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{parentResourcePath}/{resourceType}/{resourceName}"} # type: ignore + begin_create_or_update.metadata = {"url": "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{parentResourcePath}/{resourceType}/{resourceName}"} # type: ignore async def _update_initial( self, @@ -2175,39 +2816,53 @@ async def _update_initial( resource_type: str, resource_name: str, api_version: str, - parameters: "_models.GenericResource", + parameters: Union[_models.GenericResource, IO], **kwargs: Any - ) -> Optional["_models.GenericResource"]: - cls = kwargs.pop('cls', None) # type: ClsType[Optional["_models.GenericResource"]] + ) -> Optional[_models.GenericResource]: error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = kwargs.pop("params", {}) or {} - _json = self._serialize.body(parameters, 'GenericResource') + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[Optional[_models.GenericResource]] - request = build_resources_update_request_initial( + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(parameters, (IO, bytes)): + _content = parameters + else: + _json = self._serialize.body(parameters, "GenericResource") + + request = build_resources_update_request( resource_group_name=resource_group_name, resource_provider_namespace=resource_provider_namespace, parent_resource_path=parent_resource_path, resource_type=resource_type, resource_name=resource_name, subscription_id=self._config.subscription_id, - content_type=content_type, api_version=api_version, + content_type=content_type, json=_json, - template_url=self._update_initial.metadata['url'], + content=_content, + template_url=self._update_initial.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200, 202]: @@ -2216,15 +2871,112 @@ async def _update_initial( deserialized = None if response.status_code == 200: - deserialized = self._deserialize('GenericResource', pipeline_response) + deserialized = self._deserialize("GenericResource", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - _update_initial.metadata = {'url': "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{parentResourcePath}/{resourceType}/{resourceName}"} # type: ignore + _update_initial.metadata = {"url": "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{parentResourcePath}/{resourceType}/{resourceName}"} # type: ignore + + @overload + async def begin_update( + self, + resource_group_name: str, + resource_provider_namespace: str, + parent_resource_path: str, + resource_type: str, + resource_name: str, + api_version: str, + parameters: _models.GenericResource, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> AsyncLROPoller[_models.GenericResource]: + """Updates a resource. + + :param resource_group_name: The name of the resource group for the resource. The name is case + insensitive. Required. + :type resource_group_name: str + :param resource_provider_namespace: The namespace of the resource provider. Required. + :type resource_provider_namespace: str + :param parent_resource_path: The parent resource identity. Required. + :type parent_resource_path: str + :param resource_type: The resource type of the resource to update. Required. + :type resource_type: str + :param resource_name: The name of the resource to update. Required. + :type resource_name: str + :param api_version: The API version to use for the operation. Required. + :type api_version: str + :param parameters: Parameters for updating the resource. Required. + :type parameters: ~azure.mgmt.resource.resources.v2016_09_01.models.GenericResource + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be AsyncARMPolling. Pass in False for + this operation to not poll, or pass in your own initialized polling object for a personal + polling strategy. + :paramtype polling: bool or ~azure.core.polling.AsyncPollingMethod + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of AsyncLROPoller that returns either GenericResource or the result of + cls(response) + :rtype: + ~azure.core.polling.AsyncLROPoller[~azure.mgmt.resource.resources.v2016_09_01.models.GenericResource] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + async def begin_update( + self, + resource_group_name: str, + resource_provider_namespace: str, + parent_resource_path: str, + resource_type: str, + resource_name: str, + api_version: str, + parameters: IO, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> AsyncLROPoller[_models.GenericResource]: + """Updates a resource. + :param resource_group_name: The name of the resource group for the resource. The name is case + insensitive. Required. + :type resource_group_name: str + :param resource_provider_namespace: The namespace of the resource provider. Required. + :type resource_provider_namespace: str + :param parent_resource_path: The parent resource identity. Required. + :type parent_resource_path: str + :param resource_type: The resource type of the resource to update. Required. + :type resource_type: str + :param resource_name: The name of the resource to update. Required. + :type resource_name: str + :param api_version: The API version to use for the operation. Required. + :type api_version: str + :param parameters: Parameters for updating the resource. Required. + :type parameters: IO + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be AsyncARMPolling. Pass in False for + this operation to not poll, or pass in your own initialized polling object for a personal + polling strategy. + :paramtype polling: bool or ~azure.core.polling.AsyncPollingMethod + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of AsyncLROPoller that returns either GenericResource or the result of + cls(response) + :rtype: + ~azure.core.polling.AsyncLROPoller[~azure.mgmt.resource.resources.v2016_09_01.models.GenericResource] + :raises ~azure.core.exceptions.HttpResponseError: + """ @distributed_trace_async async def begin_update( @@ -2235,26 +2987,30 @@ async def begin_update( resource_type: str, resource_name: str, api_version: str, - parameters: "_models.GenericResource", + parameters: Union[_models.GenericResource, IO], **kwargs: Any - ) -> AsyncLROPoller["_models.GenericResource"]: + ) -> AsyncLROPoller[_models.GenericResource]: """Updates a resource. :param resource_group_name: The name of the resource group for the resource. The name is case - insensitive. + insensitive. Required. :type resource_group_name: str - :param resource_provider_namespace: The namespace of the resource provider. + :param resource_provider_namespace: The namespace of the resource provider. Required. :type resource_provider_namespace: str - :param parent_resource_path: The parent resource identity. + :param parent_resource_path: The parent resource identity. Required. :type parent_resource_path: str - :param resource_type: The resource type of the resource to update. + :param resource_type: The resource type of the resource to update. Required. :type resource_type: str - :param resource_name: The name of the resource to update. + :param resource_name: The name of the resource to update. Required. :type resource_name: str - :param api_version: The API version to use for the operation. + :param api_version: The API version to use for the operation. Required. :type api_version: str - :param parameters: Parameters for updating the resource. - :type parameters: ~azure.mgmt.resource.resources.v2016_09_01.models.GenericResource + :param parameters: Parameters for updating the resource. Is either a model type or a IO type. + Required. + :type parameters: ~azure.mgmt.resource.resources.v2016_09_01.models.GenericResource or IO + :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. + Default value is None. + :paramtype content_type: str :keyword callable cls: A custom type or function that will be passed the direct response :keyword str continuation_token: A continuation token to restart a poller from a saved state. :keyword polling: By default, your polling method will be AsyncARMPolling. Pass in False for @@ -2267,18 +3023,18 @@ async def begin_update( cls(response) :rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.resource.resources.v2016_09_01.models.GenericResource] - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] - polling = kwargs.pop('polling', True) # type: Union[bool, AsyncPollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType["_models.GenericResource"] - lro_delay = kwargs.pop( - 'polling_interval', - self._config.polling_interval - ) - cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = kwargs.pop("params", {}) or {} + + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.GenericResource] + polling = kwargs.pop("polling", True) # type: Union[bool, AsyncPollingMethod] + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token = kwargs.pop("continuation_token", None) # type: Optional[str] if cont_token is None: - raw_result = await self._update_initial( + raw_result = await self._update_initial( # type: ignore resource_group_name=resource_group_name, resource_provider_namespace=resource_provider_namespace, parent_resource_path=parent_resource_path, @@ -2287,32 +3043,35 @@ async def begin_update( api_version=api_version, parameters=parameters, content_type=content_type, - cls=lambda x,y,z: x, + cls=lambda x, y, z: x, + headers=_headers, + params=_params, **kwargs ) - kwargs.pop('error_map', None) + kwargs.pop("error_map", None) def get_long_running_output(pipeline_response): - response = pipeline_response.http_response - deserialized = self._deserialize('GenericResource', pipeline_response) + deserialized = self._deserialize("GenericResource", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - - if polling is True: polling_method = AsyncARMPolling(lro_delay, **kwargs) - elif polling is False: polling_method = AsyncNoPolling() - else: polling_method = polling + if polling is True: + polling_method = cast(AsyncPollingMethod, AsyncARMPolling(lro_delay, **kwargs)) # type: AsyncPollingMethod + elif polling is False: + polling_method = cast(AsyncPollingMethod, AsyncNoPolling()) + else: + polling_method = polling if cont_token: return AsyncLROPoller.from_continuation_token( polling_method=polling_method, continuation_token=cont_token, client=self._client, - deserialization_callback=get_long_running_output + deserialization_callback=get_long_running_output, ) return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) - begin_update.metadata = {'url': "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{parentResourcePath}/{resourceType}/{resourceName}"} # type: ignore + begin_update.metadata = {"url": "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{parentResourcePath}/{resourceType}/{resourceName}"} # type: ignore @distributed_trace_async async def get( @@ -2324,34 +3083,40 @@ async def get( resource_name: str, api_version: str, **kwargs: Any - ) -> "_models.GenericResource": + ) -> _models.GenericResource: """Gets a resource. :param resource_group_name: The name of the resource group containing the resource to get. The - name is case insensitive. + name is case insensitive. Required. :type resource_group_name: str - :param resource_provider_namespace: The namespace of the resource provider. + :param resource_provider_namespace: The namespace of the resource provider. Required. :type resource_provider_namespace: str - :param parent_resource_path: The parent resource identity. + :param parent_resource_path: The parent resource identity. Required. :type parent_resource_path: str - :param resource_type: The resource type of the resource. + :param resource_type: The resource type of the resource. Required. :type resource_type: str - :param resource_name: The name of the resource to get. + :param resource_name: The name of the resource to get. Required. :type resource_name: str - :param api_version: The API version to use for the operation. + :param api_version: The API version to use for the operation. Required. :type api_version: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: GenericResource, or the result of cls(response) + :return: GenericResource or the result of cls(response) :rtype: ~azure.mgmt.resource.resources.v2016_09_01.models.GenericResource - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.GenericResource"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = kwargs.pop("params", {}) or {} + + cls = kwargs.pop("cls", None) # type: ClsType[_models.GenericResource] - request = build_resources_get_request( resource_group_name=resource_group_name, resource_provider_namespace=resource_provider_namespace, @@ -2360,72 +3125,75 @@ async def get( resource_name=resource_name, subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.get.metadata['url'], + template_url=self.get.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) - deserialized = self._deserialize('GenericResource', pipeline_response) + deserialized = self._deserialize("GenericResource", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - get.metadata = {'url': "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{parentResourcePath}/{resourceType}/{resourceName}"} # type: ignore - + get.metadata = {"url": "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{parentResourcePath}/{resourceType}/{resourceName}"} # type: ignore @distributed_trace_async - async def check_existence_by_id( - self, - resource_id: str, - api_version: str, - **kwargs: Any - ) -> bool: + async def check_existence_by_id(self, resource_id: str, api_version: str, **kwargs: Any) -> bool: """Checks by ID whether a resource exists. :param resource_id: The fully qualified ID of the resource, including the resource name and resource type. Use the format, /subscriptions/{guid}/resourceGroups/{resource-group-name}/{resource-provider-namespace}/{resource-type}/{resource-name}. + Required. :type resource_id: str - :param api_version: The API version to use for the operation. + :param api_version: The API version to use for the operation. Required. :type api_version: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: bool, or the result of cls(response) + :return: bool or the result of cls(response) :rtype: bool - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType[None] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = kwargs.pop("params", {}) or {} + + cls = kwargs.pop("cls", None) # type: ClsType[None] - request = build_resources_check_existence_by_id_request( resource_id=resource_id, api_version=api_version, - template_url=self.check_existence_by_id.metadata['url'], + template_url=self.check_existence_by_id.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [204, 404]: @@ -2436,35 +3204,38 @@ async def check_existence_by_id( return cls(pipeline_response, None, {}) return 200 <= response.status_code <= 299 - check_existence_by_id.metadata = {'url': "/{resourceId}"} # type: ignore - + check_existence_by_id.metadata = {"url": "/{resourceId}"} # type: ignore async def _delete_by_id_initial( # pylint: disable=inconsistent-return-statements - self, - resource_id: str, - api_version: str, - **kwargs: Any + self, resource_id: str, api_version: str, **kwargs: Any ) -> None: - cls = kwargs.pop('cls', None) # type: ClsType[None] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = kwargs.pop("params", {}) or {} - - request = build_resources_delete_by_id_request_initial( + cls = kwargs.pop("cls", None) # type: ClsType[None] + + request = build_resources_delete_by_id_request( resource_id=resource_id, api_version=api_version, - template_url=self._delete_by_id_initial.metadata['url'], + template_url=self._delete_by_id_initial.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200, 202, 204]: @@ -2474,23 +3245,18 @@ async def _delete_by_id_initial( # pylint: disable=inconsistent-return-statemen if cls: return cls(pipeline_response, None, {}) - _delete_by_id_initial.metadata = {'url': "/{resourceId}"} # type: ignore - + _delete_by_id_initial.metadata = {"url": "/{resourceId}"} # type: ignore @distributed_trace_async - async def begin_delete_by_id( # pylint: disable=inconsistent-return-statements - self, - resource_id: str, - api_version: str, - **kwargs: Any - ) -> AsyncLROPoller[None]: + async def begin_delete_by_id(self, resource_id: str, api_version: str, **kwargs: Any) -> AsyncLROPoller[None]: """Deletes a resource by ID. :param resource_id: The fully qualified ID of the resource, including the resource name and resource type. Use the format, /subscriptions/{guid}/resourceGroups/{resource-group-name}/{resource-provider-namespace}/{resource-type}/{resource-name}. + Required. :type resource_id: str - :param api_version: The API version to use for the operation. + :param api_version: The API version to use for the operation. Required. :type api_version: str :keyword callable cls: A custom type or function that will be passed the direct response :keyword str continuation_token: A continuation token to restart a poller from a saved state. @@ -2502,75 +3268,89 @@ async def begin_delete_by_id( # pylint: disable=inconsistent-return-statements Retry-After header is present. :return: An instance of AsyncLROPoller that returns either None or the result of cls(response) :rtype: ~azure.core.polling.AsyncLROPoller[None] - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - polling = kwargs.pop('polling', True) # type: Union[bool, AsyncPollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType[None] - lro_delay = kwargs.pop( - 'polling_interval', - self._config.polling_interval - ) - cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] + _headers = kwargs.pop("headers", {}) or {} + _params = kwargs.pop("params", {}) or {} + + cls = kwargs.pop("cls", None) # type: ClsType[None] + polling = kwargs.pop("polling", True) # type: Union[bool, AsyncPollingMethod] + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token = kwargs.pop("continuation_token", None) # type: Optional[str] if cont_token is None: - raw_result = await self._delete_by_id_initial( + raw_result = await self._delete_by_id_initial( # type: ignore resource_id=resource_id, api_version=api_version, - cls=lambda x,y,z: x, + cls=lambda x, y, z: x, + headers=_headers, + params=_params, **kwargs ) - kwargs.pop('error_map', None) + kwargs.pop("error_map", None) - def get_long_running_output(pipeline_response): + def get_long_running_output(pipeline_response): # pylint: disable=inconsistent-return-statements if cls: return cls(pipeline_response, None, {}) - - if polling is True: polling_method = AsyncARMPolling(lro_delay, **kwargs) - elif polling is False: polling_method = AsyncNoPolling() - else: polling_method = polling + if polling is True: + polling_method = cast(AsyncPollingMethod, AsyncARMPolling(lro_delay, **kwargs)) # type: AsyncPollingMethod + elif polling is False: + polling_method = cast(AsyncPollingMethod, AsyncNoPolling()) + else: + polling_method = polling if cont_token: return AsyncLROPoller.from_continuation_token( polling_method=polling_method, continuation_token=cont_token, client=self._client, - deserialization_callback=get_long_running_output + deserialization_callback=get_long_running_output, ) return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) - begin_delete_by_id.metadata = {'url': "/{resourceId}"} # type: ignore + begin_delete_by_id.metadata = {"url": "/{resourceId}"} # type: ignore async def _create_or_update_by_id_initial( - self, - resource_id: str, - api_version: str, - parameters: "_models.GenericResource", - **kwargs: Any - ) -> Optional["_models.GenericResource"]: - cls = kwargs.pop('cls', None) # type: ClsType[Optional["_models.GenericResource"]] + self, resource_id: str, api_version: str, parameters: Union[_models.GenericResource, IO], **kwargs: Any + ) -> Optional[_models.GenericResource]: error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = kwargs.pop("params", {}) or {} - _json = self._serialize.body(parameters, 'GenericResource') + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[Optional[_models.GenericResource]] - request = build_resources_create_or_update_by_id_request_initial( + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(parameters, (IO, bytes)): + _content = parameters + else: + _json = self._serialize.body(parameters, "GenericResource") + + request = build_resources_create_or_update_by_id_request( resource_id=resource_id, - content_type=content_type, api_version=api_version, + content_type=content_type, json=_json, - template_url=self._create_or_update_by_id_initial.metadata['url'], + content=_content, + template_url=self._create_or_update_by_id_initial.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200, 201, 202]: @@ -2579,37 +3359,81 @@ async def _create_or_update_by_id_initial( deserialized = None if response.status_code == 200: - deserialized = self._deserialize('GenericResource', pipeline_response) + deserialized = self._deserialize("GenericResource", pipeline_response) if response.status_code == 201: - deserialized = self._deserialize('GenericResource', pipeline_response) + deserialized = self._deserialize("GenericResource", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - _create_or_update_by_id_initial.metadata = {'url': "/{resourceId}"} # type: ignore + _create_or_update_by_id_initial.metadata = {"url": "/{resourceId}"} # type: ignore - - @distributed_trace_async + @overload async def begin_create_or_update_by_id( self, resource_id: str, api_version: str, - parameters: "_models.GenericResource", + parameters: _models.GenericResource, + *, + content_type: str = "application/json", **kwargs: Any - ) -> AsyncLROPoller["_models.GenericResource"]: + ) -> AsyncLROPoller[_models.GenericResource]: """Create a resource by ID. :param resource_id: The fully qualified ID of the resource, including the resource name and resource type. Use the format, /subscriptions/{guid}/resourceGroups/{resource-group-name}/{resource-provider-namespace}/{resource-type}/{resource-name}. + Required. :type resource_id: str - :param api_version: The API version to use for the operation. + :param api_version: The API version to use for the operation. Required. :type api_version: str - :param parameters: Create or update resource parameters. + :param parameters: Create or update resource parameters. Required. :type parameters: ~azure.mgmt.resource.resources.v2016_09_01.models.GenericResource + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be AsyncARMPolling. Pass in False for + this operation to not poll, or pass in your own initialized polling object for a personal + polling strategy. + :paramtype polling: bool or ~azure.core.polling.AsyncPollingMethod + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of AsyncLROPoller that returns either GenericResource or the result of + cls(response) + :rtype: + ~azure.core.polling.AsyncLROPoller[~azure.mgmt.resource.resources.v2016_09_01.models.GenericResource] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + async def begin_create_or_update_by_id( + self, + resource_id: str, + api_version: str, + parameters: IO, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> AsyncLROPoller[_models.GenericResource]: + """Create a resource by ID. + + :param resource_id: The fully qualified ID of the resource, including the resource name and + resource type. Use the format, + /subscriptions/{guid}/resourceGroups/{resource-group-name}/{resource-provider-namespace}/{resource-type}/{resource-name}. + Required. + :type resource_id: str + :param api_version: The API version to use for the operation. Required. + :type api_version: str + :param parameters: Create or update resource parameters. Required. + :type parameters: IO + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: str :keyword callable cls: A custom type or function that will be passed the direct response :keyword str continuation_token: A continuation token to restart a poller from a saved state. :keyword polling: By default, your polling method will be AsyncARMPolling. Pass in False for @@ -2622,81 +3446,128 @@ async def begin_create_or_update_by_id( cls(response) :rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.resource.resources.v2016_09_01.models.GenericResource] - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] - polling = kwargs.pop('polling', True) # type: Union[bool, AsyncPollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType["_models.GenericResource"] - lro_delay = kwargs.pop( - 'polling_interval', - self._config.polling_interval - ) - cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] + + @distributed_trace_async + async def begin_create_or_update_by_id( + self, resource_id: str, api_version: str, parameters: Union[_models.GenericResource, IO], **kwargs: Any + ) -> AsyncLROPoller[_models.GenericResource]: + """Create a resource by ID. + + :param resource_id: The fully qualified ID of the resource, including the resource name and + resource type. Use the format, + /subscriptions/{guid}/resourceGroups/{resource-group-name}/{resource-provider-namespace}/{resource-type}/{resource-name}. + Required. + :type resource_id: str + :param api_version: The API version to use for the operation. Required. + :type api_version: str + :param parameters: Create or update resource parameters. Is either a model type or a IO type. + Required. + :type parameters: ~azure.mgmt.resource.resources.v2016_09_01.models.GenericResource or IO + :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. + Default value is None. + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be AsyncARMPolling. Pass in False for + this operation to not poll, or pass in your own initialized polling object for a personal + polling strategy. + :paramtype polling: bool or ~azure.core.polling.AsyncPollingMethod + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of AsyncLROPoller that returns either GenericResource or the result of + cls(response) + :rtype: + ~azure.core.polling.AsyncLROPoller[~azure.mgmt.resource.resources.v2016_09_01.models.GenericResource] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = kwargs.pop("params", {}) or {} + + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.GenericResource] + polling = kwargs.pop("polling", True) # type: Union[bool, AsyncPollingMethod] + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token = kwargs.pop("continuation_token", None) # type: Optional[str] if cont_token is None: - raw_result = await self._create_or_update_by_id_initial( + raw_result = await self._create_or_update_by_id_initial( # type: ignore resource_id=resource_id, api_version=api_version, parameters=parameters, content_type=content_type, - cls=lambda x,y,z: x, + cls=lambda x, y, z: x, + headers=_headers, + params=_params, **kwargs ) - kwargs.pop('error_map', None) + kwargs.pop("error_map", None) def get_long_running_output(pipeline_response): - response = pipeline_response.http_response - deserialized = self._deserialize('GenericResource', pipeline_response) + deserialized = self._deserialize("GenericResource", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - - if polling is True: polling_method = AsyncARMPolling(lro_delay, **kwargs) - elif polling is False: polling_method = AsyncNoPolling() - else: polling_method = polling + if polling is True: + polling_method = cast(AsyncPollingMethod, AsyncARMPolling(lro_delay, **kwargs)) # type: AsyncPollingMethod + elif polling is False: + polling_method = cast(AsyncPollingMethod, AsyncNoPolling()) + else: + polling_method = polling if cont_token: return AsyncLROPoller.from_continuation_token( polling_method=polling_method, continuation_token=cont_token, client=self._client, - deserialization_callback=get_long_running_output + deserialization_callback=get_long_running_output, ) return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) - begin_create_or_update_by_id.metadata = {'url': "/{resourceId}"} # type: ignore + begin_create_or_update_by_id.metadata = {"url": "/{resourceId}"} # type: ignore async def _update_by_id_initial( - self, - resource_id: str, - api_version: str, - parameters: "_models.GenericResource", - **kwargs: Any - ) -> Optional["_models.GenericResource"]: - cls = kwargs.pop('cls', None) # type: ClsType[Optional["_models.GenericResource"]] + self, resource_id: str, api_version: str, parameters: Union[_models.GenericResource, IO], **kwargs: Any + ) -> Optional[_models.GenericResource]: error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = kwargs.pop("params", {}) or {} - _json = self._serialize.body(parameters, 'GenericResource') + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[Optional[_models.GenericResource]] - request = build_resources_update_by_id_request_initial( + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(parameters, (IO, bytes)): + _content = parameters + else: + _json = self._serialize.body(parameters, "GenericResource") + + request = build_resources_update_by_id_request( resource_id=resource_id, - content_type=content_type, api_version=api_version, + content_type=content_type, json=_json, - template_url=self._update_by_id_initial.metadata['url'], + content=_content, + template_url=self._update_by_id_initial.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200, 202]: @@ -2705,34 +3576,111 @@ async def _update_by_id_initial( deserialized = None if response.status_code == 200: - deserialized = self._deserialize('GenericResource', pipeline_response) + deserialized = self._deserialize("GenericResource", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - _update_by_id_initial.metadata = {'url': "/{resourceId}"} # type: ignore + _update_by_id_initial.metadata = {"url": "/{resourceId}"} # type: ignore - - @distributed_trace_async + @overload async def begin_update_by_id( self, resource_id: str, api_version: str, - parameters: "_models.GenericResource", + parameters: _models.GenericResource, + *, + content_type: str = "application/json", **kwargs: Any - ) -> AsyncLROPoller["_models.GenericResource"]: + ) -> AsyncLROPoller[_models.GenericResource]: """Updates a resource by ID. :param resource_id: The fully qualified ID of the resource, including the resource name and resource type. Use the format, /subscriptions/{guid}/resourceGroups/{resource-group-name}/{resource-provider-namespace}/{resource-type}/{resource-name}. + Required. :type resource_id: str - :param api_version: The API version to use for the operation. + :param api_version: The API version to use for the operation. Required. :type api_version: str - :param parameters: Update resource parameters. + :param parameters: Update resource parameters. Required. :type parameters: ~azure.mgmt.resource.resources.v2016_09_01.models.GenericResource + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be AsyncARMPolling. Pass in False for + this operation to not poll, or pass in your own initialized polling object for a personal + polling strategy. + :paramtype polling: bool or ~azure.core.polling.AsyncPollingMethod + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of AsyncLROPoller that returns either GenericResource or the result of + cls(response) + :rtype: + ~azure.core.polling.AsyncLROPoller[~azure.mgmt.resource.resources.v2016_09_01.models.GenericResource] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + async def begin_update_by_id( + self, + resource_id: str, + api_version: str, + parameters: IO, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> AsyncLROPoller[_models.GenericResource]: + """Updates a resource by ID. + + :param resource_id: The fully qualified ID of the resource, including the resource name and + resource type. Use the format, + /subscriptions/{guid}/resourceGroups/{resource-group-name}/{resource-provider-namespace}/{resource-type}/{resource-name}. + Required. + :type resource_id: str + :param api_version: The API version to use for the operation. Required. + :type api_version: str + :param parameters: Update resource parameters. Required. + :type parameters: IO + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be AsyncARMPolling. Pass in False for + this operation to not poll, or pass in your own initialized polling object for a personal + polling strategy. + :paramtype polling: bool or ~azure.core.polling.AsyncPollingMethod + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of AsyncLROPoller that returns either GenericResource or the result of + cls(response) + :rtype: + ~azure.core.polling.AsyncLROPoller[~azure.mgmt.resource.resources.v2016_09_01.models.GenericResource] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace_async + async def begin_update_by_id( + self, resource_id: str, api_version: str, parameters: Union[_models.GenericResource, IO], **kwargs: Any + ) -> AsyncLROPoller[_models.GenericResource]: + """Updates a resource by ID. + + :param resource_id: The fully qualified ID of the resource, including the resource name and + resource type. Use the format, + /subscriptions/{guid}/resourceGroups/{resource-group-name}/{resource-provider-namespace}/{resource-type}/{resource-name}. + Required. + :type resource_id: str + :param api_version: The API version to use for the operation. Required. + :type api_version: str + :param parameters: Update resource parameters. Is either a model type or a IO type. Required. + :type parameters: ~azure.mgmt.resource.resources.v2016_09_01.models.GenericResource or IO + :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. + Default value is None. + :paramtype content_type: str :keyword callable cls: A custom type or function that will be passed the direct response :keyword str continuation_token: A continuation token to restart a poller from a saved state. :keyword polling: By default, your polling method will be AsyncARMPolling. Pass in False for @@ -2745,168 +3693,175 @@ async def begin_update_by_id( cls(response) :rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.resource.resources.v2016_09_01.models.GenericResource] - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] - polling = kwargs.pop('polling', True) # type: Union[bool, AsyncPollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType["_models.GenericResource"] - lro_delay = kwargs.pop( - 'polling_interval', - self._config.polling_interval - ) - cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = kwargs.pop("params", {}) or {} + + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.GenericResource] + polling = kwargs.pop("polling", True) # type: Union[bool, AsyncPollingMethod] + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token = kwargs.pop("continuation_token", None) # type: Optional[str] if cont_token is None: - raw_result = await self._update_by_id_initial( + raw_result = await self._update_by_id_initial( # type: ignore resource_id=resource_id, api_version=api_version, parameters=parameters, content_type=content_type, - cls=lambda x,y,z: x, + cls=lambda x, y, z: x, + headers=_headers, + params=_params, **kwargs ) - kwargs.pop('error_map', None) + kwargs.pop("error_map", None) def get_long_running_output(pipeline_response): - response = pipeline_response.http_response - deserialized = self._deserialize('GenericResource', pipeline_response) + deserialized = self._deserialize("GenericResource", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - - if polling is True: polling_method = AsyncARMPolling(lro_delay, **kwargs) - elif polling is False: polling_method = AsyncNoPolling() - else: polling_method = polling + if polling is True: + polling_method = cast(AsyncPollingMethod, AsyncARMPolling(lro_delay, **kwargs)) # type: AsyncPollingMethod + elif polling is False: + polling_method = cast(AsyncPollingMethod, AsyncNoPolling()) + else: + polling_method = polling if cont_token: return AsyncLROPoller.from_continuation_token( polling_method=polling_method, continuation_token=cont_token, client=self._client, - deserialization_callback=get_long_running_output + deserialization_callback=get_long_running_output, ) return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) - begin_update_by_id.metadata = {'url': "/{resourceId}"} # type: ignore + begin_update_by_id.metadata = {"url": "/{resourceId}"} # type: ignore @distributed_trace_async - async def get_by_id( - self, - resource_id: str, - api_version: str, - **kwargs: Any - ) -> "_models.GenericResource": + async def get_by_id(self, resource_id: str, api_version: str, **kwargs: Any) -> _models.GenericResource: """Gets a resource by ID. :param resource_id: The fully qualified ID of the resource, including the resource name and resource type. Use the format, /subscriptions/{guid}/resourceGroups/{resource-group-name}/{resource-provider-namespace}/{resource-type}/{resource-name}. + Required. :type resource_id: str - :param api_version: The API version to use for the operation. + :param api_version: The API version to use for the operation. Required. :type api_version: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: GenericResource, or the result of cls(response) + :return: GenericResource or the result of cls(response) :rtype: ~azure.mgmt.resource.resources.v2016_09_01.models.GenericResource - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.GenericResource"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = kwargs.pop("params", {}) or {} + + cls = kwargs.pop("cls", None) # type: ClsType[_models.GenericResource] - request = build_resources_get_by_id_request( resource_id=resource_id, api_version=api_version, - template_url=self.get_by_id.metadata['url'], + template_url=self.get_by_id.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) - deserialized = self._deserialize('GenericResource', pipeline_response) + deserialized = self._deserialize("GenericResource", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - get_by_id.metadata = {'url': "/{resourceId}"} # type: ignore + get_by_id.metadata = {"url": "/{resourceId}"} # type: ignore -class TagsOperations: - """TagsOperations async operations. - You should not instantiate this class directly. Instead, you should create a Client instance that - instantiates it for you and attaches it as an attribute. +class TagsOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. - :ivar models: Alias to model classes used in this operation group. - :type models: ~azure.mgmt.resource.resources.v2016_09_01.models - :param client: Client for service requests. - :param config: Configuration of service client. - :param serializer: An object model serializer. - :param deserializer: An object model deserializer. + Instead, you should access the following operations through + :class:`~azure.mgmt.resource.resources.v2016_09_01.aio.ResourceManagementClient`'s + :attr:`tags` attribute. """ models = _models - def __init__(self, client, config, serializer, deserializer) -> None: - self._client = client - self._serialize = serializer - self._deserialize = deserializer - self._config = config + def __init__(self, *args, **kwargs) -> None: + input_args = list(args) + self._client = input_args.pop(0) if input_args else kwargs.pop("client") + self._config = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") @distributed_trace_async async def delete_value( # pylint: disable=inconsistent-return-statements - self, - tag_name: str, - tag_value: str, - **kwargs: Any + self, tag_name: str, tag_value: str, **kwargs: Any ) -> None: """Deletes a tag value. - :param tag_name: The name of the tag. + :param tag_name: The name of the tag. Required. :type tag_name: str - :param tag_value: The value of the tag to delete. + :param tag_value: The value of the tag to delete. Required. :type tag_value: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: None, or the result of cls(response) + :return: None or the result of cls(response) :rtype: None - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType[None] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) - api_version = kwargs.pop('api_version', "2016-09-01") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2016-09-01")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[None] - request = build_tags_delete_value_request( tag_name=tag_name, tag_value=tag_value, subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.delete_value.metadata['url'], + template_url=self.delete_value.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200, 204]: @@ -2916,51 +3871,51 @@ async def delete_value( # pylint: disable=inconsistent-return-statements if cls: return cls(pipeline_response, None, {}) - delete_value.metadata = {'url': "/subscriptions/{subscriptionId}/tagNames/{tagName}/tagValues/{tagValue}"} # type: ignore - + delete_value.metadata = {"url": "/subscriptions/{subscriptionId}/tagNames/{tagName}/tagValues/{tagValue}"} # type: ignore @distributed_trace_async - async def create_or_update_value( - self, - tag_name: str, - tag_value: str, - **kwargs: Any - ) -> "_models.TagValue": + async def create_or_update_value(self, tag_name: str, tag_value: str, **kwargs: Any) -> _models.TagValue: """Creates a tag value. The name of the tag must already exist. - :param tag_name: The name of the tag. + :param tag_name: The name of the tag. Required. :type tag_name: str - :param tag_value: The value of the tag to create. + :param tag_value: The value of the tag to create. Required. :type tag_value: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: TagValue, or the result of cls(response) + :return: TagValue or the result of cls(response) :rtype: ~azure.mgmt.resource.resources.v2016_09_01.models.TagValue - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.TagValue"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + 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', "2016-09-01") # type: str + api_version = kwargs.pop("api_version", _params.pop("api-version", "2016-09-01")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[_models.TagValue] - request = build_tags_create_or_update_value_request( tag_name=tag_name, tag_value=tag_value, subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.create_or_update_value.metadata['url'], + template_url=self.create_or_update_value.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200, 201]: @@ -2968,61 +3923,62 @@ async def create_or_update_value( raise HttpResponseError(response=response, error_format=ARMErrorFormat) if response.status_code == 200: - deserialized = self._deserialize('TagValue', pipeline_response) + deserialized = self._deserialize("TagValue", pipeline_response) if response.status_code == 201: - deserialized = self._deserialize('TagValue', pipeline_response) + deserialized = self._deserialize("TagValue", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - create_or_update_value.metadata = {'url': "/subscriptions/{subscriptionId}/tagNames/{tagName}/tagValues/{tagValue}"} # type: ignore - + create_or_update_value.metadata = {"url": "/subscriptions/{subscriptionId}/tagNames/{tagName}/tagValues/{tagValue}"} # type: ignore @distributed_trace_async - async def create_or_update( - self, - tag_name: str, - **kwargs: Any - ) -> "_models.TagDetails": + async def create_or_update(self, tag_name: str, **kwargs: Any) -> _models.TagDetails: """Creates a tag in the subscription. The tag name can have a maximum of 512 characters and is case insensitive. Tag names created by Azure have prefixes of microsoft, azure, or windows. You cannot create tags with one of these prefixes. - :param tag_name: The name of the tag to create. + :param tag_name: The name of the tag to create. Required. :type tag_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: TagDetails, or the result of cls(response) + :return: TagDetails or the result of cls(response) :rtype: ~azure.mgmt.resource.resources.v2016_09_01.models.TagDetails - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.TagDetails"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + 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', "2016-09-01") # type: str + api_version = kwargs.pop("api_version", _params.pop("api-version", "2016-09-01")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[_models.TagDetails] - request = build_tags_create_or_update_request( tag_name=tag_name, subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.create_or_update.metadata['url'], + template_url=self.create_or_update.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200, 201]: @@ -3030,59 +3986,60 @@ async def create_or_update( raise HttpResponseError(response=response, error_format=ARMErrorFormat) if response.status_code == 200: - deserialized = self._deserialize('TagDetails', pipeline_response) + deserialized = self._deserialize("TagDetails", pipeline_response) if response.status_code == 201: - deserialized = self._deserialize('TagDetails', pipeline_response) + deserialized = self._deserialize("TagDetails", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - create_or_update.metadata = {'url': "/subscriptions/{subscriptionId}/tagNames/{tagName}"} # type: ignore - + create_or_update.metadata = {"url": "/subscriptions/{subscriptionId}/tagNames/{tagName}"} # type: ignore @distributed_trace_async - async def delete( # pylint: disable=inconsistent-return-statements - self, - tag_name: str, - **kwargs: Any - ) -> None: + async def delete(self, tag_name: str, **kwargs: Any) -> None: # pylint: disable=inconsistent-return-statements """Deletes a tag from the subscription. You must remove all values from a resource tag before you can delete it. - :param tag_name: The name of the tag. + :param tag_name: The name of the tag. Required. :type tag_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: None, or the result of cls(response) + :return: None or the result of cls(response) :rtype: None - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType[None] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + 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', "2016-09-01") # type: str + api_version = kwargs.pop("api_version", _params.pop("api-version", "2016-09-01")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[None] - request = build_tags_delete_request( tag_name=tag_name, subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.delete.metadata['url'], + template_url=self.delete.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200, 204]: @@ -3092,48 +4049,53 @@ async def delete( # pylint: disable=inconsistent-return-statements if cls: return cls(pipeline_response, None, {}) - delete.metadata = {'url': "/subscriptions/{subscriptionId}/tagNames/{tagName}"} # type: ignore - + delete.metadata = {"url": "/subscriptions/{subscriptionId}/tagNames/{tagName}"} # type: ignore @distributed_trace - def list( - self, - **kwargs: Any - ) -> AsyncIterable["_models.TagsListResult"]: + def list(self, **kwargs: Any) -> AsyncIterable["_models.TagDetails"]: """Gets the names and values of all resource tags that are defined in a subscription. :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either TagsListResult or the result of cls(response) + :return: An iterator like instance of either TagDetails or the result of cls(response) :rtype: - ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.resource.resources.v2016_09_01.models.TagsListResult] - :raises: ~azure.core.exceptions.HttpResponseError + ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.resource.resources.v2016_09_01.models.TagDetails] + :raises ~azure.core.exceptions.HttpResponseError: """ - api_version = kwargs.pop('api_version', "2016-09-01") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2016-09-01")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[_models.TagsListResult] - cls = kwargs.pop('cls', None) # type: ClsType["_models.TagsListResult"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) + def prepare_request(next_link=None): if not next_link: - + request = build_tags_list_request( subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.list.metadata['url'], + template_url=self.list.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore else: - - request = build_tags_list_request( - subscription_id=self._config.subscription_id, - template_url=next_link, - ) + # make call to next link with the client's api-version + _parsed_next_link = urlparse(next_link) + _next_request_params = case_insensitive_dict(parse_qs(_parsed_next_link.query)) + _next_request_params["api-version"] = self._config.api_version + request = HttpRequest("GET", urljoin(next_link, _parsed_next_link.path), params=_next_request_params) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore request.method = "GET" return request @@ -3147,10 +4109,8 @@ async def extract_data(pipeline_response): async def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) response = pipeline_response.http_response @@ -3160,149 +4120,151 @@ async def get_next(next_link=None): return pipeline_response + return AsyncItemPaged(get_next, extract_data) - return AsyncItemPaged( - get_next, extract_data - ) - list.metadata = {'url': "/subscriptions/{subscriptionId}/tagNames"} # type: ignore -class DeploymentOperationsOperations: - """DeploymentOperationsOperations async operations. + list.metadata = {"url": "/subscriptions/{subscriptionId}/tagNames"} # type: ignore - You should not instantiate this class directly. Instead, you should create a Client instance that - instantiates it for you and attaches it as an attribute. - :ivar models: Alias to model classes used in this operation group. - :type models: ~azure.mgmt.resource.resources.v2016_09_01.models - :param client: Client for service requests. - :param config: Configuration of service client. - :param serializer: An object model serializer. - :param deserializer: An object model deserializer. +class DeploymentOperationsOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. + + Instead, you should access the following operations through + :class:`~azure.mgmt.resource.resources.v2016_09_01.aio.ResourceManagementClient`'s + :attr:`deployment_operations` attribute. """ models = _models - def __init__(self, client, config, serializer, deserializer) -> None: - self._client = client - self._serialize = serializer - self._deserialize = deserializer - self._config = config + def __init__(self, *args, **kwargs) -> None: + input_args = list(args) + self._client = input_args.pop(0) if input_args else kwargs.pop("client") + self._config = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") @distributed_trace_async async def get( - self, - resource_group_name: str, - deployment_name: str, - operation_id: str, - **kwargs: Any - ) -> "_models.DeploymentOperation": + self, resource_group_name: str, deployment_name: str, operation_id: str, **kwargs: Any + ) -> _models.DeploymentOperation: """Gets a deployments operation. :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. :type resource_group_name: str - :param deployment_name: The name of the deployment. + :param deployment_name: The name of the deployment. Required. :type deployment_name: str - :param operation_id: The ID of the operation to get. + :param operation_id: The ID of the operation to get. Required. :type operation_id: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: DeploymentOperation, or the result of cls(response) + :return: DeploymentOperation or the result of cls(response) :rtype: ~azure.mgmt.resource.resources.v2016_09_01.models.DeploymentOperation - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.DeploymentOperation"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + 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', "2016-09-01") # type: str + api_version = kwargs.pop("api_version", _params.pop("api-version", "2016-09-01")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[_models.DeploymentOperation] - request = build_deployment_operations_get_request( resource_group_name=resource_group_name, deployment_name=deployment_name, operation_id=operation_id, subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.get.metadata['url'], + template_url=self.get.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) - deserialized = self._deserialize('DeploymentOperation', pipeline_response) + deserialized = self._deserialize("DeploymentOperation", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - get.metadata = {'url': "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/deployments/{deploymentName}/operations/{operationId}"} # type: ignore - + get.metadata = {"url": "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/deployments/{deploymentName}/operations/{operationId}"} # type: ignore @distributed_trace def list( - self, - resource_group_name: str, - deployment_name: str, - top: Optional[int] = None, - **kwargs: Any - ) -> AsyncIterable["_models.DeploymentOperationsListResult"]: + self, resource_group_name: str, deployment_name: str, top: Optional[int] = None, **kwargs: Any + ) -> AsyncIterable["_models.DeploymentOperation"]: """Gets all deployments operations for a deployment. :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. :type resource_group_name: str - :param deployment_name: The name of the deployment with the operation to get. + :param deployment_name: The name of the deployment with the operation to get. Required. :type deployment_name: str :param top: The number of results to return. Default value is None. :type top: int :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either DeploymentOperationsListResult or the result of - cls(response) + :return: An iterator like instance of either DeploymentOperation or the result of cls(response) :rtype: - ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.resource.resources.v2016_09_01.models.DeploymentOperationsListResult] - :raises: ~azure.core.exceptions.HttpResponseError + ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.resource.resources.v2016_09_01.models.DeploymentOperation] + :raises ~azure.core.exceptions.HttpResponseError: """ - api_version = kwargs.pop('api_version', "2016-09-01") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2016-09-01")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[_models.DeploymentOperationsListResult] - cls = kwargs.pop('cls', None) # type: ClsType["_models.DeploymentOperationsListResult"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) + def prepare_request(next_link=None): if not next_link: - + request = build_deployment_operations_list_request( resource_group_name=resource_group_name, deployment_name=deployment_name, subscription_id=self._config.subscription_id, - api_version=api_version, top=top, - template_url=self.list.metadata['url'], + 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.url = self._client.format_url(request.url) # type: ignore else: - - request = build_deployment_operations_list_request( - resource_group_name=resource_group_name, - deployment_name=deployment_name, - subscription_id=self._config.subscription_id, - template_url=next_link, - ) + # make call to next link with the client's api-version + _parsed_next_link = urlparse(next_link) + _next_request_params = case_insensitive_dict(parse_qs(_parsed_next_link.query)) + _next_request_params["api-version"] = self._config.api_version + request = HttpRequest("GET", urljoin(next_link, _parsed_next_link.path), params=_next_request_params) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore request.method = "GET" return request @@ -3316,10 +4278,8 @@ async def extract_data(pipeline_response): async def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) response = pipeline_response.http_response @@ -3329,8 +4289,6 @@ async def get_next(next_link=None): return pipeline_response + return AsyncItemPaged(get_next, extract_data) - return AsyncItemPaged( - get_next, extract_data - ) - list.metadata = {'url': "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/deployments/{deploymentName}/operations"} # type: ignore + list.metadata = {"url": "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/deployments/{deploymentName}/operations"} # type: ignore diff --git a/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/resources/v2016_09_01/aio/operations/_patch.py b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/resources/v2016_09_01/aio/operations/_patch.py new file mode 100644 index 0000000000000..f7dd32510333d --- /dev/null +++ b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/resources/v2016_09_01/aio/operations/_patch.py @@ -0,0 +1,20 @@ +# ------------------------------------ +# Copyright (c) Microsoft Corporation. +# Licensed under the MIT License. +# ------------------------------------ +"""Customize generated code here. + +Follow our quickstart for examples: https://aka.ms/azsdk/python/dpcodegen/python/customize +""" +from typing import List + +__all__: List[str] = [] # Add all objects you want publicly available to users at this package level + + +def patch_sdk(): + """Do not remove from this file. + + `patch_sdk` is a last resort escape hatch that allows you to do customizations + you can't accomplish using the techniques described in + https://aka.ms/azsdk/python/dpcodegen/python/customize + """ diff --git a/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/resources/v2016_09_01/models/__init__.py b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/resources/v2016_09_01/models/__init__.py index 81e815dcb62e5..20011090feec5 100644 --- a/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/resources/v2016_09_01/models/__init__.py +++ b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/resources/v2016_09_01/models/__init__.py @@ -56,60 +56,62 @@ from ._models_py3 import TemplateLink from ._models_py3 import ZoneMapping - -from ._resource_management_client_enums import ( - DeploymentMode, -) +from ._resource_management_client_enums import DeploymentMode +from ._patch import __all__ as _patch_all +from ._patch import * # type: ignore # pylint: disable=unused-wildcard-import +from ._patch import patch_sdk as _patch_sdk __all__ = [ - 'AliasPathType', - 'AliasType', - 'BasicDependency', - 'DebugSetting', - 'Dependency', - 'Deployment', - 'DeploymentExportResult', - 'DeploymentExtended', - 'DeploymentExtendedFilter', - 'DeploymentListResult', - 'DeploymentOperation', - 'DeploymentOperationProperties', - 'DeploymentOperationsListResult', - 'DeploymentProperties', - 'DeploymentPropertiesExtended', - 'DeploymentValidateResult', - 'ErrorAdditionalInfo', - 'ErrorResponse', - 'ExportTemplateRequest', - 'GenericResource', - 'GenericResourceExpanded', - 'GenericResourceFilter', - 'HttpMessage', - 'Identity', - 'ParametersLink', - 'Plan', - 'Provider', - 'ProviderListResult', - 'ProviderResourceType', - 'Resource', - 'ResourceGroup', - 'ResourceGroupExportResult', - 'ResourceGroupFilter', - 'ResourceGroupListResult', - 'ResourceGroupProperties', - 'ResourceListResult', - 'ResourceManagementErrorWithDetails', - 'ResourceProviderOperationDisplayProperties', - 'ResourcesMoveInfo', - 'Sku', - 'SubResource', - 'TagCount', - 'TagDetails', - 'TagValue', - 'TagsListResult', - 'TargetResource', - 'TemplateHashResult', - 'TemplateLink', - 'ZoneMapping', - 'DeploymentMode', + "AliasPathType", + "AliasType", + "BasicDependency", + "DebugSetting", + "Dependency", + "Deployment", + "DeploymentExportResult", + "DeploymentExtended", + "DeploymentExtendedFilter", + "DeploymentListResult", + "DeploymentOperation", + "DeploymentOperationProperties", + "DeploymentOperationsListResult", + "DeploymentProperties", + "DeploymentPropertiesExtended", + "DeploymentValidateResult", + "ErrorAdditionalInfo", + "ErrorResponse", + "ExportTemplateRequest", + "GenericResource", + "GenericResourceExpanded", + "GenericResourceFilter", + "HttpMessage", + "Identity", + "ParametersLink", + "Plan", + "Provider", + "ProviderListResult", + "ProviderResourceType", + "Resource", + "ResourceGroup", + "ResourceGroupExportResult", + "ResourceGroupFilter", + "ResourceGroupListResult", + "ResourceGroupProperties", + "ResourceListResult", + "ResourceManagementErrorWithDetails", + "ResourceProviderOperationDisplayProperties", + "ResourcesMoveInfo", + "Sku", + "SubResource", + "TagCount", + "TagDetails", + "TagValue", + "TagsListResult", + "TargetResource", + "TemplateHashResult", + "TemplateLink", + "ZoneMapping", + "DeploymentMode", ] +__all__.extend([p for p in _patch_all if p not in __all__]) +_patch_sdk() diff --git a/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/resources/v2016_09_01/models/_models_py3.py b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/resources/v2016_09_01/models/_models_py3.py index 477eb0159ec6e..e4f5e74189015 100644 --- a/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/resources/v2016_09_01/models/_models_py3.py +++ b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/resources/v2016_09_01/models/_models_py3.py @@ -1,4 +1,5 @@ # coding=utf-8 +# pylint: disable=too-many-lines # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. # Licensed under the MIT License. See License.txt in the project root for license information. @@ -6,14 +7,22 @@ # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -from typing import Any, Dict, List, Optional, Union +import sys +from typing import Any, Dict, List, Optional, TYPE_CHECKING, Union -import msrest.serialization +from ... import _serialization -from ._resource_management_client_enums import * +if TYPE_CHECKING: + # pylint: disable=unused-import,ungrouped-imports + from .. import models as _models +if sys.version_info >= (3, 9): + from collections.abc import MutableMapping +else: + from typing import MutableMapping # type: ignore # pylint: disable=ungrouped-imports +JSON = MutableMapping[str, Any] # pylint: disable=unsubscriptable-object -class AliasPathType(msrest.serialization.Model): +class AliasPathType(_serialization.Model): """The type of the paths for alias. :ivar path: The path of an alias. @@ -23,29 +32,23 @@ class AliasPathType(msrest.serialization.Model): """ _attribute_map = { - 'path': {'key': 'path', 'type': 'str'}, - 'api_versions': {'key': 'apiVersions', 'type': '[str]'}, + "path": {"key": "path", "type": "str"}, + "api_versions": {"key": "apiVersions", "type": "[str]"}, } - def __init__( - self, - *, - path: Optional[str] = None, - api_versions: Optional[List[str]] = None, - **kwargs - ): + def __init__(self, *, path: Optional[str] = None, api_versions: Optional[List[str]] = None, **kwargs): """ :keyword path: The path of an alias. :paramtype path: str :keyword api_versions: The API versions. :paramtype api_versions: list[str] """ - super(AliasPathType, self).__init__(**kwargs) + super().__init__(**kwargs) self.path = path self.api_versions = api_versions -class AliasType(msrest.serialization.Model): +class AliasType(_serialization.Model): """The alias type. :ivar name: The alias name. @@ -55,29 +58,23 @@ class AliasType(msrest.serialization.Model): """ _attribute_map = { - 'name': {'key': 'name', 'type': 'str'}, - 'paths': {'key': 'paths', 'type': '[AliasPathType]'}, + "name": {"key": "name", "type": "str"}, + "paths": {"key": "paths", "type": "[AliasPathType]"}, } - def __init__( - self, - *, - name: Optional[str] = None, - paths: Optional[List["AliasPathType"]] = None, - **kwargs - ): + def __init__(self, *, name: Optional[str] = None, paths: Optional[List["_models.AliasPathType"]] = None, **kwargs): """ :keyword name: The alias name. :paramtype name: str :keyword paths: The paths for an alias. :paramtype paths: list[~azure.mgmt.resource.resources.v2016_09_01.models.AliasPathType] """ - super(AliasType, self).__init__(**kwargs) + super().__init__(**kwargs) self.name = name self.paths = paths -class BasicDependency(msrest.serialization.Model): +class BasicDependency(_serialization.Model): """Deployment dependency information. :ivar id: The ID of the dependency. @@ -89,15 +86,15 @@ class BasicDependency(msrest.serialization.Model): """ _attribute_map = { - 'id': {'key': 'id', 'type': 'str'}, - 'resource_type': {'key': 'resourceType', 'type': 'str'}, - 'resource_name': {'key': 'resourceName', 'type': 'str'}, + "id": {"key": "id", "type": "str"}, + "resource_type": {"key": "resourceType", "type": "str"}, + "resource_name": {"key": "resourceName", "type": "str"}, } def __init__( self, *, - id: Optional[str] = None, + id: Optional[str] = None, # pylint: disable=redefined-builtin resource_type: Optional[str] = None, resource_name: Optional[str] = None, **kwargs @@ -110,13 +107,13 @@ def __init__( :keyword resource_name: The dependency resource name. :paramtype resource_name: str """ - super(BasicDependency, self).__init__(**kwargs) + super().__init__(**kwargs) self.id = id self.resource_type = resource_type self.resource_name = resource_name -class DebugSetting(msrest.serialization.Model): +class DebugSetting(_serialization.Model): """DebugSetting. :ivar detail_level: Specifies the type of information to log for debugging. The permitted @@ -129,15 +126,10 @@ class DebugSetting(msrest.serialization.Model): """ _attribute_map = { - 'detail_level': {'key': 'detailLevel', 'type': 'str'}, + "detail_level": {"key": "detailLevel", "type": "str"}, } - def __init__( - self, - *, - detail_level: Optional[str] = None, - **kwargs - ): + def __init__(self, *, detail_level: Optional[str] = None, **kwargs): """ :keyword detail_level: Specifies the type of information to log for debugging. The permitted values are none, requestContent, responseContent, or both requestContent and responseContent @@ -147,11 +139,11 @@ def __init__( deployment operations. :paramtype detail_level: str """ - super(DebugSetting, self).__init__(**kwargs) + super().__init__(**kwargs) self.detail_level = detail_level -class Dependency(msrest.serialization.Model): +class Dependency(_serialization.Model): """Deployment dependency information. :ivar depends_on: The list of dependencies. @@ -165,17 +157,17 @@ class Dependency(msrest.serialization.Model): """ _attribute_map = { - 'depends_on': {'key': 'dependsOn', 'type': '[BasicDependency]'}, - 'id': {'key': 'id', 'type': 'str'}, - 'resource_type': {'key': 'resourceType', 'type': 'str'}, - 'resource_name': {'key': 'resourceName', 'type': 'str'}, + "depends_on": {"key": "dependsOn", "type": "[BasicDependency]"}, + "id": {"key": "id", "type": "str"}, + "resource_type": {"key": "resourceType", "type": "str"}, + "resource_name": {"key": "resourceName", "type": "str"}, } def __init__( self, *, - depends_on: Optional[List["BasicDependency"]] = None, - id: Optional[str] = None, + depends_on: Optional[List["_models.BasicDependency"]] = None, + id: Optional[str] = None, # pylint: disable=redefined-builtin resource_type: Optional[str] = None, resource_name: Optional[str] = None, **kwargs @@ -190,70 +182,60 @@ def __init__( :keyword resource_name: The dependency resource name. :paramtype resource_name: str """ - super(Dependency, self).__init__(**kwargs) + super().__init__(**kwargs) self.depends_on = depends_on self.id = id self.resource_type = resource_type self.resource_name = resource_name -class Deployment(msrest.serialization.Model): +class Deployment(_serialization.Model): """Deployment operation parameters. All required parameters must be populated in order to send to Azure. - :ivar properties: Required. The deployment properties. + :ivar properties: The deployment properties. Required. :vartype properties: ~azure.mgmt.resource.resources.v2016_09_01.models.DeploymentProperties """ _validation = { - 'properties': {'required': True}, + "properties": {"required": True}, } _attribute_map = { - 'properties': {'key': 'properties', 'type': 'DeploymentProperties'}, + "properties": {"key": "properties", "type": "DeploymentProperties"}, } - def __init__( - self, - *, - properties: "DeploymentProperties", - **kwargs - ): + def __init__(self, *, properties: "_models.DeploymentProperties", **kwargs): """ - :keyword properties: Required. The deployment properties. + :keyword properties: The deployment properties. Required. :paramtype properties: ~azure.mgmt.resource.resources.v2016_09_01.models.DeploymentProperties """ - super(Deployment, self).__init__(**kwargs) + super().__init__(**kwargs) self.properties = properties -class DeploymentExportResult(msrest.serialization.Model): +class DeploymentExportResult(_serialization.Model): """The deployment export result. :ivar template: The template content. - :vartype template: any + :vartype template: JSON """ _attribute_map = { - 'template': {'key': 'template', 'type': 'object'}, + "template": {"key": "template", "type": "object"}, } - def __init__( - self, - *, - template: Optional[Any] = None, - **kwargs - ): + def __init__(self, *, template: Optional[JSON] = None, **kwargs): """ :keyword template: The template content. - :paramtype template: any + :paramtype template: JSON """ - super(DeploymentExportResult, self).__init__(**kwargs) + super().__init__(**kwargs) self.template = template -class DeploymentExtended(msrest.serialization.Model): +class DeploymentExtended(_serialization.Model): """Deployment information. Variables are only populated by the server, and will be ignored when sending a request. @@ -262,7 +244,7 @@ class DeploymentExtended(msrest.serialization.Model): :ivar id: The ID of the deployment. :vartype id: str - :ivar name: Required. The name of the deployment. + :ivar name: The name of the deployment. Required. :vartype name: str :ivar properties: Deployment properties. :vartype properties: @@ -270,37 +252,31 @@ class DeploymentExtended(msrest.serialization.Model): """ _validation = { - 'id': {'readonly': True}, - 'name': {'required': True}, + "id": {"readonly": True}, + "name": {"required": True}, } _attribute_map = { - 'id': {'key': 'id', 'type': 'str'}, - 'name': {'key': 'name', 'type': 'str'}, - 'properties': {'key': 'properties', 'type': 'DeploymentPropertiesExtended'}, + "id": {"key": "id", "type": "str"}, + "name": {"key": "name", "type": "str"}, + "properties": {"key": "properties", "type": "DeploymentPropertiesExtended"}, } - def __init__( - self, - *, - name: str, - properties: Optional["DeploymentPropertiesExtended"] = None, - **kwargs - ): + def __init__(self, *, name: str, properties: Optional["_models.DeploymentPropertiesExtended"] = None, **kwargs): """ - :keyword name: Required. The name of the deployment. + :keyword name: The name of the deployment. Required. :paramtype name: str :keyword properties: Deployment properties. :paramtype properties: ~azure.mgmt.resource.resources.v2016_09_01.models.DeploymentPropertiesExtended """ - super(DeploymentExtended, self).__init__(**kwargs) + super().__init__(**kwargs) self.id = None self.name = name self.properties = properties -class DeploymentExtendedFilter(msrest.serialization.Model): +class DeploymentExtendedFilter(_serialization.Model): """Deployment filter. :ivar provisioning_state: The provisioning state. @@ -308,24 +284,19 @@ class DeploymentExtendedFilter(msrest.serialization.Model): """ _attribute_map = { - 'provisioning_state': {'key': 'provisioningState', 'type': 'str'}, + "provisioning_state": {"key": "provisioningState", "type": "str"}, } - def __init__( - self, - *, - provisioning_state: Optional[str] = None, - **kwargs - ): + def __init__(self, *, provisioning_state: Optional[str] = None, **kwargs): """ :keyword provisioning_state: The provisioning state. :paramtype provisioning_state: str """ - super(DeploymentExtendedFilter, self).__init__(**kwargs) + super().__init__(**kwargs) self.provisioning_state = provisioning_state -class DeploymentListResult(msrest.serialization.Model): +class DeploymentListResult(_serialization.Model): """List of deployments. Variables are only populated by the server, and will be ignored when sending a request. @@ -337,30 +308,25 @@ class DeploymentListResult(msrest.serialization.Model): """ _validation = { - 'next_link': {'readonly': True}, + "next_link": {"readonly": True}, } _attribute_map = { - 'value': {'key': 'value', 'type': '[DeploymentExtended]'}, - 'next_link': {'key': 'nextLink', 'type': 'str'}, + "value": {"key": "value", "type": "[DeploymentExtended]"}, + "next_link": {"key": "nextLink", "type": "str"}, } - def __init__( - self, - *, - value: Optional[List["DeploymentExtended"]] = None, - **kwargs - ): + def __init__(self, *, value: Optional[List["_models.DeploymentExtended"]] = None, **kwargs): """ :keyword value: An array of deployments. :paramtype value: list[~azure.mgmt.resource.resources.v2016_09_01.models.DeploymentExtended] """ - super(DeploymentListResult, self).__init__(**kwargs) + super().__init__(**kwargs) self.value = value self.next_link = None -class DeploymentOperation(msrest.serialization.Model): +class DeploymentOperation(_serialization.Model): """Deployment operation information. Variables are only populated by the server, and will be ignored when sending a request. @@ -375,34 +341,29 @@ class DeploymentOperation(msrest.serialization.Model): """ _validation = { - 'id': {'readonly': True}, - 'operation_id': {'readonly': True}, + "id": {"readonly": True}, + "operation_id": {"readonly": True}, } _attribute_map = { - 'id': {'key': 'id', 'type': 'str'}, - 'operation_id': {'key': 'operationId', 'type': 'str'}, - 'properties': {'key': 'properties', 'type': 'DeploymentOperationProperties'}, + "id": {"key": "id", "type": "str"}, + "operation_id": {"key": "operationId", "type": "str"}, + "properties": {"key": "properties", "type": "DeploymentOperationProperties"}, } - def __init__( - self, - *, - properties: Optional["DeploymentOperationProperties"] = None, - **kwargs - ): + def __init__(self, *, properties: Optional["_models.DeploymentOperationProperties"] = None, **kwargs): """ :keyword properties: Deployment properties. :paramtype properties: ~azure.mgmt.resource.resources.v2016_09_01.models.DeploymentOperationProperties """ - super(DeploymentOperation, self).__init__(**kwargs) + super().__init__(**kwargs) self.id = None self.operation_id = None self.properties = properties -class DeploymentOperationProperties(msrest.serialization.Model): +class DeploymentOperationProperties(_serialization.Model): """Deployment operation properties. Variables are only populated by the server, and will be ignored when sending a request. @@ -426,34 +387,30 @@ class DeploymentOperationProperties(msrest.serialization.Model): """ _validation = { - 'provisioning_state': {'readonly': True}, - 'timestamp': {'readonly': True}, - 'service_request_id': {'readonly': True}, - 'status_code': {'readonly': True}, - 'status_message': {'readonly': True}, - 'target_resource': {'readonly': True}, - 'request': {'readonly': True}, - 'response': {'readonly': True}, + "provisioning_state": {"readonly": True}, + "timestamp": {"readonly": True}, + "service_request_id": {"readonly": True}, + "status_code": {"readonly": True}, + "status_message": {"readonly": True}, + "target_resource": {"readonly": True}, + "request": {"readonly": True}, + "response": {"readonly": True}, } _attribute_map = { - 'provisioning_state': {'key': 'provisioningState', 'type': 'str'}, - 'timestamp': {'key': 'timestamp', 'type': 'iso-8601'}, - 'service_request_id': {'key': 'serviceRequestId', 'type': 'str'}, - 'status_code': {'key': 'statusCode', 'type': 'str'}, - 'status_message': {'key': 'statusMessage', 'type': 'object'}, - 'target_resource': {'key': 'targetResource', 'type': 'TargetResource'}, - 'request': {'key': 'request', 'type': 'HttpMessage'}, - 'response': {'key': 'response', 'type': 'HttpMessage'}, - } - - def __init__( - self, - **kwargs - ): - """ - """ - super(DeploymentOperationProperties, self).__init__(**kwargs) + "provisioning_state": {"key": "provisioningState", "type": "str"}, + "timestamp": {"key": "timestamp", "type": "iso-8601"}, + "service_request_id": {"key": "serviceRequestId", "type": "str"}, + "status_code": {"key": "statusCode", "type": "str"}, + "status_message": {"key": "statusMessage", "type": "object"}, + "target_resource": {"key": "targetResource", "type": "TargetResource"}, + "request": {"key": "request", "type": "HttpMessage"}, + "response": {"key": "response", "type": "HttpMessage"}, + } + + def __init__(self, **kwargs): + """ """ + super().__init__(**kwargs) self.provisioning_state = None self.timestamp = None self.service_request_id = None @@ -464,7 +421,7 @@ def __init__( self.response = None -class DeploymentOperationsListResult(msrest.serialization.Model): +class DeploymentOperationsListResult(_serialization.Model): """List of deployment operations. Variables are only populated by the server, and will be ignored when sending a request. @@ -476,30 +433,25 @@ class DeploymentOperationsListResult(msrest.serialization.Model): """ _validation = { - 'next_link': {'readonly': True}, + "next_link": {"readonly": True}, } _attribute_map = { - 'value': {'key': 'value', 'type': '[DeploymentOperation]'}, - 'next_link': {'key': 'nextLink', 'type': 'str'}, + "value": {"key": "value", "type": "[DeploymentOperation]"}, + "next_link": {"key": "nextLink", "type": "str"}, } - def __init__( - self, - *, - value: Optional[List["DeploymentOperation"]] = None, - **kwargs - ): + def __init__(self, *, value: Optional[List["_models.DeploymentOperation"]] = None, **kwargs): """ :keyword value: An array of deployment operations. :paramtype value: list[~azure.mgmt.resource.resources.v2016_09_01.models.DeploymentOperation] """ - super(DeploymentOperationsListResult, self).__init__(**kwargs) + super().__init__(**kwargs) self.value = value self.next_link = None -class DeploymentProperties(msrest.serialization.Model): +class DeploymentProperties(_serialization.Model): """Deployment properties. All required parameters must be populated in order to send to Azure. @@ -508,7 +460,7 @@ class DeploymentProperties(msrest.serialization.Model): syntax directly in the request rather than link to an existing template. It can be a JObject or well-formed JSON string. Use either the templateLink property or the template property, but not both. - :vartype template: any + :vartype template: JSON :ivar template_link: The URI of the template. Use either the templateLink property or the template property, but not both. :vartype template_link: ~azure.mgmt.resource.resources.v2016_09_01.models.TemplateLink @@ -516,44 +468,44 @@ class DeploymentProperties(msrest.serialization.Model): You use this element when you want to provide the parameter values directly in the request rather than link to an existing parameter file. Use either the parametersLink property or the parameters property, but not both. It can be a JObject or a well formed JSON string. - :vartype parameters: any + :vartype parameters: JSON :ivar parameters_link: The URI of parameters file. You use this element to link to an existing parameters file. Use either the parametersLink property or the parameters property, but not both. :vartype parameters_link: ~azure.mgmt.resource.resources.v2016_09_01.models.ParametersLink - :ivar mode: Required. The mode that is used to deploy resources. This value can be either - Incremental or Complete. In Incremental mode, resources are deployed without deleting existing - resources that are not included in the template. In Complete mode, resources are deployed and - existing resources in the resource group that are not included in the template are deleted. Be - careful when using Complete mode as you may unintentionally delete resources. Possible values - include: "Incremental", "Complete". + :ivar mode: The mode that is used to deploy resources. This value can be either Incremental or + Complete. In Incremental mode, resources are deployed without deleting existing resources that + are not included in the template. In Complete mode, resources are deployed and existing + resources in the resource group that are not included in the template are deleted. Be careful + when using Complete mode as you may unintentionally delete resources. Required. Known values + are: "Incremental" and "Complete". :vartype mode: str or ~azure.mgmt.resource.resources.v2016_09_01.models.DeploymentMode :ivar debug_setting: The debug setting of the deployment. :vartype debug_setting: ~azure.mgmt.resource.resources.v2016_09_01.models.DebugSetting """ _validation = { - 'mode': {'required': True}, + "mode": {"required": True}, } _attribute_map = { - 'template': {'key': 'template', 'type': 'object'}, - 'template_link': {'key': 'templateLink', 'type': 'TemplateLink'}, - 'parameters': {'key': 'parameters', 'type': 'object'}, - 'parameters_link': {'key': 'parametersLink', 'type': 'ParametersLink'}, - 'mode': {'key': 'mode', 'type': 'str'}, - 'debug_setting': {'key': 'debugSetting', 'type': 'DebugSetting'}, + "template": {"key": "template", "type": "object"}, + "template_link": {"key": "templateLink", "type": "TemplateLink"}, + "parameters": {"key": "parameters", "type": "object"}, + "parameters_link": {"key": "parametersLink", "type": "ParametersLink"}, + "mode": {"key": "mode", "type": "str"}, + "debug_setting": {"key": "debugSetting", "type": "DebugSetting"}, } def __init__( self, *, - mode: Union[str, "DeploymentMode"], - template: Optional[Any] = None, - template_link: Optional["TemplateLink"] = None, - parameters: Optional[Any] = None, - parameters_link: Optional["ParametersLink"] = None, - debug_setting: Optional["DebugSetting"] = None, + mode: Union[str, "_models.DeploymentMode"], + template: Optional[JSON] = None, + template_link: Optional["_models.TemplateLink"] = None, + parameters: Optional[JSON] = None, + parameters_link: Optional["_models.ParametersLink"] = None, + debug_setting: Optional["_models.DebugSetting"] = None, **kwargs ): """ @@ -561,7 +513,7 @@ def __init__( template syntax directly in the request rather than link to an existing template. It can be a JObject or well-formed JSON string. Use either the templateLink property or the template property, but not both. - :paramtype template: any + :paramtype template: JSON :keyword template_link: The URI of the template. Use either the templateLink property or the template property, but not both. :paramtype template_link: ~azure.mgmt.resource.resources.v2016_09_01.models.TemplateLink @@ -569,22 +521,22 @@ def __init__( template. You use this element when you want to provide the parameter values directly in the request rather than link to an existing parameter file. Use either the parametersLink property or the parameters property, but not both. It can be a JObject or a well formed JSON string. - :paramtype parameters: any + :paramtype parameters: JSON :keyword parameters_link: The URI of parameters file. You use this element to link to an existing parameters file. Use either the parametersLink property or the parameters property, but not both. :paramtype parameters_link: ~azure.mgmt.resource.resources.v2016_09_01.models.ParametersLink - :keyword mode: Required. The mode that is used to deploy resources. This value can be either - Incremental or Complete. In Incremental mode, resources are deployed without deleting existing - resources that are not included in the template. In Complete mode, resources are deployed and - existing resources in the resource group that are not included in the template are deleted. Be - careful when using Complete mode as you may unintentionally delete resources. Possible values - include: "Incremental", "Complete". + :keyword mode: The mode that is used to deploy resources. This value can be either Incremental + or Complete. In Incremental mode, resources are deployed without deleting existing resources + that are not included in the template. In Complete mode, resources are deployed and existing + resources in the resource group that are not included in the template are deleted. Be careful + when using Complete mode as you may unintentionally delete resources. Required. Known values + are: "Incremental" and "Complete". :paramtype mode: str or ~azure.mgmt.resource.resources.v2016_09_01.models.DeploymentMode :keyword debug_setting: The debug setting of the deployment. :paramtype debug_setting: ~azure.mgmt.resource.resources.v2016_09_01.models.DebugSetting """ - super(DeploymentProperties, self).__init__(**kwargs) + super().__init__(**kwargs) self.template = template self.template_link = template_link self.parameters = parameters @@ -593,7 +545,7 @@ def __init__( self.debug_setting = debug_setting -class DeploymentPropertiesExtended(msrest.serialization.Model): +class DeploymentPropertiesExtended(_serialization.Model): # pylint: disable=too-many-instance-attributes """Deployment properties with additional details. Variables are only populated by the server, and will be ignored when sending a request. @@ -605,23 +557,23 @@ class DeploymentPropertiesExtended(msrest.serialization.Model): :ivar timestamp: The timestamp of the template deployment. :vartype timestamp: ~datetime.datetime :ivar outputs: Key/value pairs that represent deployment output. - :vartype outputs: any + :vartype outputs: JSON :ivar providers: The list of resource providers needed for the deployment. :vartype providers: list[~azure.mgmt.resource.resources.v2016_09_01.models.Provider] :ivar dependencies: The list of deployment dependencies. :vartype dependencies: list[~azure.mgmt.resource.resources.v2016_09_01.models.Dependency] :ivar template: The template content. Use only one of Template or TemplateLink. - :vartype template: any + :vartype template: JSON :ivar template_link: The URI referencing the template. Use only one of Template or TemplateLink. :vartype template_link: ~azure.mgmt.resource.resources.v2016_09_01.models.TemplateLink :ivar parameters: Deployment parameters. Use only one of Parameters or ParametersLink. - :vartype parameters: any + :vartype parameters: JSON :ivar parameters_link: The URI referencing the parameters. Use only one of Parameters or ParametersLink. :vartype parameters_link: ~azure.mgmt.resource.resources.v2016_09_01.models.ParametersLink - :ivar mode: The deployment mode. Possible values are Incremental and Complete. Possible values - include: "Incremental", "Complete". + :ivar mode: The deployment mode. Possible values are Incremental and Complete. Known values + are: "Incremental" and "Complete". :vartype mode: str or ~azure.mgmt.resource.resources.v2016_09_01.models.DeploymentMode :ivar debug_setting: The debug setting of the deployment. :vartype debug_setting: ~azure.mgmt.resource.resources.v2016_09_01.models.DebugSetting @@ -630,66 +582,66 @@ class DeploymentPropertiesExtended(msrest.serialization.Model): """ _validation = { - 'provisioning_state': {'readonly': True}, - 'correlation_id': {'readonly': True}, - 'timestamp': {'readonly': True}, - 'error': {'readonly': True}, + "provisioning_state": {"readonly": True}, + "correlation_id": {"readonly": True}, + "timestamp": {"readonly": True}, + "error": {"readonly": True}, } _attribute_map = { - 'provisioning_state': {'key': 'provisioningState', 'type': 'str'}, - 'correlation_id': {'key': 'correlationId', 'type': 'str'}, - 'timestamp': {'key': 'timestamp', 'type': 'iso-8601'}, - 'outputs': {'key': 'outputs', 'type': 'object'}, - 'providers': {'key': 'providers', 'type': '[Provider]'}, - 'dependencies': {'key': 'dependencies', 'type': '[Dependency]'}, - 'template': {'key': 'template', 'type': 'object'}, - 'template_link': {'key': 'templateLink', 'type': 'TemplateLink'}, - 'parameters': {'key': 'parameters', 'type': 'object'}, - 'parameters_link': {'key': 'parametersLink', 'type': 'ParametersLink'}, - 'mode': {'key': 'mode', 'type': 'str'}, - 'debug_setting': {'key': 'debugSetting', 'type': 'DebugSetting'}, - 'error': {'key': 'error', 'type': 'ErrorResponse'}, + "provisioning_state": {"key": "provisioningState", "type": "str"}, + "correlation_id": {"key": "correlationId", "type": "str"}, + "timestamp": {"key": "timestamp", "type": "iso-8601"}, + "outputs": {"key": "outputs", "type": "object"}, + "providers": {"key": "providers", "type": "[Provider]"}, + "dependencies": {"key": "dependencies", "type": "[Dependency]"}, + "template": {"key": "template", "type": "object"}, + "template_link": {"key": "templateLink", "type": "TemplateLink"}, + "parameters": {"key": "parameters", "type": "object"}, + "parameters_link": {"key": "parametersLink", "type": "ParametersLink"}, + "mode": {"key": "mode", "type": "str"}, + "debug_setting": {"key": "debugSetting", "type": "DebugSetting"}, + "error": {"key": "error", "type": "ErrorResponse"}, } def __init__( self, *, - outputs: Optional[Any] = None, - providers: Optional[List["Provider"]] = None, - dependencies: Optional[List["Dependency"]] = None, - template: Optional[Any] = None, - template_link: Optional["TemplateLink"] = None, - parameters: Optional[Any] = None, - parameters_link: Optional["ParametersLink"] = None, - mode: Optional[Union[str, "DeploymentMode"]] = None, - debug_setting: Optional["DebugSetting"] = None, + outputs: Optional[JSON] = None, + providers: Optional[List["_models.Provider"]] = None, + dependencies: Optional[List["_models.Dependency"]] = None, + template: Optional[JSON] = None, + template_link: Optional["_models.TemplateLink"] = None, + parameters: Optional[JSON] = None, + parameters_link: Optional["_models.ParametersLink"] = None, + mode: Optional[Union[str, "_models.DeploymentMode"]] = None, + debug_setting: Optional["_models.DebugSetting"] = None, **kwargs ): """ :keyword outputs: Key/value pairs that represent deployment output. - :paramtype outputs: any + :paramtype outputs: JSON :keyword providers: The list of resource providers needed for the deployment. :paramtype providers: list[~azure.mgmt.resource.resources.v2016_09_01.models.Provider] :keyword dependencies: The list of deployment dependencies. :paramtype dependencies: list[~azure.mgmt.resource.resources.v2016_09_01.models.Dependency] :keyword template: The template content. Use only one of Template or TemplateLink. - :paramtype template: any + :paramtype template: JSON :keyword template_link: The URI referencing the template. Use only one of Template or TemplateLink. :paramtype template_link: ~azure.mgmt.resource.resources.v2016_09_01.models.TemplateLink :keyword parameters: Deployment parameters. Use only one of Parameters or ParametersLink. - :paramtype parameters: any + :paramtype parameters: JSON :keyword parameters_link: The URI referencing the parameters. Use only one of Parameters or ParametersLink. :paramtype parameters_link: ~azure.mgmt.resource.resources.v2016_09_01.models.ParametersLink - :keyword mode: The deployment mode. Possible values are Incremental and Complete. Possible - values include: "Incremental", "Complete". + :keyword mode: The deployment mode. Possible values are Incremental and Complete. Known values + are: "Incremental" and "Complete". :paramtype mode: str or ~azure.mgmt.resource.resources.v2016_09_01.models.DeploymentMode :keyword debug_setting: The debug setting of the deployment. :paramtype debug_setting: ~azure.mgmt.resource.resources.v2016_09_01.models.DebugSetting """ - super(DeploymentPropertiesExtended, self).__init__(**kwargs) + super().__init__(**kwargs) self.provisioning_state = None self.correlation_id = None self.timestamp = None @@ -705,7 +657,7 @@ def __init__( self.error = None -class DeploymentValidateResult(msrest.serialization.Model): +class DeploymentValidateResult(_serialization.Model): """Information from validate template deployment response. :ivar error: Validation error. @@ -717,15 +669,15 @@ class DeploymentValidateResult(msrest.serialization.Model): """ _attribute_map = { - 'error': {'key': 'error', 'type': 'ResourceManagementErrorWithDetails'}, - 'properties': {'key': 'properties', 'type': 'DeploymentPropertiesExtended'}, + "error": {"key": "error", "type": "ResourceManagementErrorWithDetails"}, + "properties": {"key": "properties", "type": "DeploymentPropertiesExtended"}, } def __init__( self, *, - error: Optional["ResourceManagementErrorWithDetails"] = None, - properties: Optional["DeploymentPropertiesExtended"] = None, + error: Optional["_models.ResourceManagementErrorWithDetails"] = None, + properties: Optional["_models.DeploymentPropertiesExtended"] = None, **kwargs ): """ @@ -736,12 +688,12 @@ def __init__( :paramtype properties: ~azure.mgmt.resource.resources.v2016_09_01.models.DeploymentPropertiesExtended """ - super(DeploymentValidateResult, self).__init__(**kwargs) + super().__init__(**kwargs) self.error = error self.properties = properties -class ErrorAdditionalInfo(msrest.serialization.Model): +class ErrorAdditionalInfo(_serialization.Model): """The resource management error additional info. Variables are only populated by the server, and will be ignored when sending a request. @@ -749,31 +701,27 @@ class ErrorAdditionalInfo(msrest.serialization.Model): :ivar type: The additional info type. :vartype type: str :ivar info: The additional info. - :vartype info: any + :vartype info: JSON """ _validation = { - 'type': {'readonly': True}, - 'info': {'readonly': True}, + "type": {"readonly": True}, + "info": {"readonly": True}, } _attribute_map = { - 'type': {'key': 'type', 'type': 'str'}, - 'info': {'key': 'info', 'type': 'object'}, + "type": {"key": "type", "type": "str"}, + "info": {"key": "info", "type": "object"}, } - def __init__( - self, - **kwargs - ): - """ - """ - super(ErrorAdditionalInfo, self).__init__(**kwargs) + def __init__(self, **kwargs): + """ """ + super().__init__(**kwargs) self.type = None self.info = None -class ErrorResponse(msrest.serialization.Model): +class ErrorResponse(_serialization.Model): """Common error response for all Azure Resource Manager APIs to return error details for failed operations. (This also follows the OData error response format.). Variables are only populated by the server, and will be ignored when sending a request. @@ -792,28 +740,24 @@ class ErrorResponse(msrest.serialization.Model): """ _validation = { - 'code': {'readonly': True}, - 'message': {'readonly': True}, - 'target': {'readonly': True}, - 'details': {'readonly': True}, - 'additional_info': {'readonly': True}, + "code": {"readonly": True}, + "message": {"readonly": True}, + "target": {"readonly": True}, + "details": {"readonly": True}, + "additional_info": {"readonly": True}, } _attribute_map = { - 'code': {'key': 'code', 'type': 'str'}, - 'message': {'key': 'message', 'type': 'str'}, - 'target': {'key': 'target', 'type': 'str'}, - 'details': {'key': 'details', 'type': '[ErrorResponse]'}, - 'additional_info': {'key': 'additionalInfo', 'type': '[ErrorAdditionalInfo]'}, + "code": {"key": "code", "type": "str"}, + "message": {"key": "message", "type": "str"}, + "target": {"key": "target", "type": "str"}, + "details": {"key": "details", "type": "[ErrorResponse]"}, + "additional_info": {"key": "additionalInfo", "type": "[ErrorAdditionalInfo]"}, } - def __init__( - self, - **kwargs - ): - """ - """ - super(ErrorResponse, self).__init__(**kwargs) + def __init__(self, **kwargs): + """ """ + super().__init__(**kwargs) self.code = None self.message = None self.target = None @@ -821,7 +765,7 @@ def __init__( self.additional_info = None -class ExportTemplateRequest(msrest.serialization.Model): +class ExportTemplateRequest(_serialization.Model): """Export resource group template request parameters. :ivar resources: The IDs of the resources to filter the export by. To export all resources, @@ -834,17 +778,11 @@ class ExportTemplateRequest(msrest.serialization.Model): """ _attribute_map = { - 'resources': {'key': 'resources', 'type': '[str]'}, - 'options': {'key': 'options', 'type': 'str'}, + "resources": {"key": "resources", "type": "[str]"}, + "options": {"key": "options", "type": "str"}, } - def __init__( - self, - *, - resources: Optional[List[str]] = None, - options: Optional[str] = None, - **kwargs - ): + def __init__(self, *, resources: Optional[List[str]] = None, options: Optional[str] = None, **kwargs): """ :keyword resources: The IDs of the resources to filter the export by. To export all resources, supply an array with single entry '*'. @@ -854,12 +792,12 @@ def __init__( 'SkipResourceNameParameterization', 'SkipAllParameterization'. :paramtype options: str """ - super(ExportTemplateRequest, self).__init__(**kwargs) + super().__init__(**kwargs) self.resources = resources self.options = options -class Resource(msrest.serialization.Model): +class Resource(_serialization.Model): """Resource. Variables are only populated by the server, and will be ignored when sending a request. @@ -872,38 +810,32 @@ class Resource(msrest.serialization.Model): :vartype type: str :ivar location: Resource location. :vartype location: str - :ivar tags: A set of tags. Resource tags. + :ivar tags: Resource tags. :vartype tags: dict[str, str] """ _validation = { - 'id': {'readonly': True}, - 'name': {'readonly': True}, - 'type': {'readonly': True}, + "id": {"readonly": True}, + "name": {"readonly": True}, + "type": {"readonly": True}, } _attribute_map = { - 'id': {'key': 'id', 'type': 'str'}, - 'name': {'key': 'name', 'type': 'str'}, - 'type': {'key': 'type', 'type': 'str'}, - 'location': {'key': 'location', 'type': 'str'}, - 'tags': {'key': 'tags', 'type': '{str}'}, + "id": {"key": "id", "type": "str"}, + "name": {"key": "name", "type": "str"}, + "type": {"key": "type", "type": "str"}, + "location": {"key": "location", "type": "str"}, + "tags": {"key": "tags", "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): """ :keyword location: Resource location. :paramtype location: str - :keyword tags: A set of tags. Resource tags. + :keyword tags: Resource tags. :paramtype tags: dict[str, str] """ - super(Resource, self).__init__(**kwargs) + super().__init__(**kwargs) self.id = None self.name = None self.type = None @@ -911,7 +843,7 @@ def __init__( self.tags = tags -class GenericResource(Resource): +class GenericResource(Resource): # pylint: disable=too-many-instance-attributes """Resource information. Variables are only populated by the server, and will be ignored when sending a request. @@ -924,12 +856,12 @@ class GenericResource(Resource): :vartype type: str :ivar location: Resource location. :vartype location: str - :ivar tags: A set of tags. Resource tags. + :ivar tags: Resource tags. :vartype tags: dict[str, str] :ivar plan: The plan of the resource. :vartype plan: ~azure.mgmt.resource.resources.v2016_09_01.models.Plan :ivar properties: The resource properties. - :vartype properties: any + :vartype properties: JSON :ivar kind: The kind of the resource. :vartype kind: str :ivar managed_by: ID of the resource that manages this resource. @@ -941,24 +873,24 @@ class GenericResource(Resource): """ _validation = { - 'id': {'readonly': True}, - 'name': {'readonly': True}, - 'type': {'readonly': True}, - 'kind': {'pattern': r'^[-\w\._,\(\)]+$'}, + "id": {"readonly": True}, + "name": {"readonly": True}, + "type": {"readonly": True}, + "kind": {"pattern": r"^[-\w\._,\(\)]+$"}, } _attribute_map = { - 'id': {'key': 'id', 'type': 'str'}, - 'name': {'key': 'name', 'type': 'str'}, - 'type': {'key': 'type', 'type': 'str'}, - 'location': {'key': 'location', 'type': 'str'}, - 'tags': {'key': 'tags', 'type': '{str}'}, - 'plan': {'key': 'plan', 'type': 'Plan'}, - 'properties': {'key': 'properties', 'type': 'object'}, - 'kind': {'key': 'kind', 'type': 'str'}, - 'managed_by': {'key': 'managedBy', 'type': 'str'}, - 'sku': {'key': 'sku', 'type': 'Sku'}, - 'identity': {'key': 'identity', 'type': 'Identity'}, + "id": {"key": "id", "type": "str"}, + "name": {"key": "name", "type": "str"}, + "type": {"key": "type", "type": "str"}, + "location": {"key": "location", "type": "str"}, + "tags": {"key": "tags", "type": "{str}"}, + "plan": {"key": "plan", "type": "Plan"}, + "properties": {"key": "properties", "type": "object"}, + "kind": {"key": "kind", "type": "str"}, + "managed_by": {"key": "managedBy", "type": "str"}, + "sku": {"key": "sku", "type": "Sku"}, + "identity": {"key": "identity", "type": "Identity"}, } def __init__( @@ -966,23 +898,23 @@ def __init__( *, location: Optional[str] = None, tags: Optional[Dict[str, str]] = None, - plan: Optional["Plan"] = None, - properties: Optional[Any] = None, + plan: Optional["_models.Plan"] = None, + properties: Optional[JSON] = None, kind: Optional[str] = None, managed_by: Optional[str] = None, - sku: Optional["Sku"] = None, - identity: Optional["Identity"] = None, + sku: Optional["_models.Sku"] = None, + identity: Optional["_models.Identity"] = None, **kwargs ): """ :keyword location: Resource location. :paramtype location: str - :keyword tags: A set of tags. Resource tags. + :keyword tags: Resource tags. :paramtype tags: dict[str, str] :keyword plan: The plan of the resource. :paramtype plan: ~azure.mgmt.resource.resources.v2016_09_01.models.Plan :keyword properties: The resource properties. - :paramtype properties: any + :paramtype properties: JSON :keyword kind: The kind of the resource. :paramtype kind: str :keyword managed_by: ID of the resource that manages this resource. @@ -992,7 +924,7 @@ def __init__( :keyword identity: The identity of the resource. :paramtype identity: ~azure.mgmt.resource.resources.v2016_09_01.models.Identity """ - super(GenericResource, self).__init__(location=location, tags=tags, **kwargs) + super().__init__(location=location, tags=tags, **kwargs) self.plan = plan self.properties = properties self.kind = kind @@ -1001,7 +933,7 @@ def __init__( self.identity = identity -class GenericResourceExpanded(GenericResource): +class GenericResourceExpanded(GenericResource): # pylint: disable=too-many-instance-attributes """Resource information. Variables are only populated by the server, and will be ignored when sending a request. @@ -1014,12 +946,12 @@ class GenericResourceExpanded(GenericResource): :vartype type: str :ivar location: Resource location. :vartype location: str - :ivar tags: A set of tags. Resource tags. + :ivar tags: Resource tags. :vartype tags: dict[str, str] :ivar plan: The plan of the resource. :vartype plan: ~azure.mgmt.resource.resources.v2016_09_01.models.Plan :ivar properties: The resource properties. - :vartype properties: any + :vartype properties: JSON :ivar kind: The kind of the resource. :vartype kind: str :ivar managed_by: ID of the resource that manages this resource. @@ -1040,30 +972,30 @@ class GenericResourceExpanded(GenericResource): """ _validation = { - 'id': {'readonly': True}, - 'name': {'readonly': True}, - 'type': {'readonly': True}, - 'kind': {'pattern': r'^[-\w\._,\(\)]+$'}, - 'created_time': {'readonly': True}, - 'changed_time': {'readonly': True}, - 'provisioning_state': {'readonly': True}, + "id": {"readonly": True}, + "name": {"readonly": True}, + "type": {"readonly": True}, + "kind": {"pattern": r"^[-\w\._,\(\)]+$"}, + "created_time": {"readonly": True}, + "changed_time": {"readonly": True}, + "provisioning_state": {"readonly": True}, } _attribute_map = { - 'id': {'key': 'id', 'type': 'str'}, - 'name': {'key': 'name', 'type': 'str'}, - 'type': {'key': 'type', 'type': 'str'}, - 'location': {'key': 'location', 'type': 'str'}, - 'tags': {'key': 'tags', 'type': '{str}'}, - 'plan': {'key': 'plan', 'type': 'Plan'}, - 'properties': {'key': 'properties', 'type': 'object'}, - 'kind': {'key': 'kind', 'type': 'str'}, - 'managed_by': {'key': 'managedBy', 'type': 'str'}, - 'sku': {'key': 'sku', 'type': 'Sku'}, - 'identity': {'key': 'identity', 'type': 'Identity'}, - 'created_time': {'key': 'createdTime', 'type': 'iso-8601'}, - 'changed_time': {'key': 'changedTime', 'type': 'iso-8601'}, - 'provisioning_state': {'key': 'provisioningState', 'type': 'str'}, + "id": {"key": "id", "type": "str"}, + "name": {"key": "name", "type": "str"}, + "type": {"key": "type", "type": "str"}, + "location": {"key": "location", "type": "str"}, + "tags": {"key": "tags", "type": "{str}"}, + "plan": {"key": "plan", "type": "Plan"}, + "properties": {"key": "properties", "type": "object"}, + "kind": {"key": "kind", "type": "str"}, + "managed_by": {"key": "managedBy", "type": "str"}, + "sku": {"key": "sku", "type": "Sku"}, + "identity": {"key": "identity", "type": "Identity"}, + "created_time": {"key": "createdTime", "type": "iso-8601"}, + "changed_time": {"key": "changedTime", "type": "iso-8601"}, + "provisioning_state": {"key": "provisioningState", "type": "str"}, } def __init__( @@ -1071,23 +1003,23 @@ def __init__( *, location: Optional[str] = None, tags: Optional[Dict[str, str]] = None, - plan: Optional["Plan"] = None, - properties: Optional[Any] = None, + plan: Optional["_models.Plan"] = None, + properties: Optional[JSON] = None, kind: Optional[str] = None, managed_by: Optional[str] = None, - sku: Optional["Sku"] = None, - identity: Optional["Identity"] = None, + sku: Optional["_models.Sku"] = None, + identity: Optional["_models.Identity"] = None, **kwargs ): """ :keyword location: Resource location. :paramtype location: str - :keyword tags: A set of tags. Resource tags. + :keyword tags: Resource tags. :paramtype tags: dict[str, str] :keyword plan: The plan of the resource. :paramtype plan: ~azure.mgmt.resource.resources.v2016_09_01.models.Plan :keyword properties: The resource properties. - :paramtype properties: any + :paramtype properties: JSON :keyword kind: The kind of the resource. :paramtype kind: str :keyword managed_by: ID of the resource that manages this resource. @@ -1097,13 +1029,23 @@ def __init__( :keyword identity: The identity of the resource. :paramtype identity: ~azure.mgmt.resource.resources.v2016_09_01.models.Identity """ - super(GenericResourceExpanded, self).__init__(location=location, tags=tags, plan=plan, properties=properties, kind=kind, managed_by=managed_by, sku=sku, identity=identity, **kwargs) + super().__init__( + location=location, + tags=tags, + plan=plan, + properties=properties, + kind=kind, + managed_by=managed_by, + sku=sku, + identity=identity, + **kwargs + ) self.created_time = None self.changed_time = None self.provisioning_state = None -class GenericResourceFilter(msrest.serialization.Model): +class GenericResourceFilter(_serialization.Model): """Resource filter. :ivar resource_type: The resource type. @@ -1115,9 +1057,9 @@ class GenericResourceFilter(msrest.serialization.Model): """ _attribute_map = { - 'resource_type': {'key': 'resourceType', 'type': 'str'}, - 'tagname': {'key': 'tagname', 'type': 'str'}, - 'tagvalue': {'key': 'tagvalue', 'type': 'str'}, + "resource_type": {"key": "resourceType", "type": "str"}, + "tagname": {"key": "tagname", "type": "str"}, + "tagvalue": {"key": "tagvalue", "type": "str"}, } def __init__( @@ -1136,38 +1078,33 @@ def __init__( :keyword tagvalue: The tag value. :paramtype tagvalue: str """ - super(GenericResourceFilter, self).__init__(**kwargs) + super().__init__(**kwargs) self.resource_type = resource_type self.tagname = tagname self.tagvalue = tagvalue -class HttpMessage(msrest.serialization.Model): +class HttpMessage(_serialization.Model): """HttpMessage. :ivar content: HTTP message content. - :vartype content: any + :vartype content: JSON """ _attribute_map = { - 'content': {'key': 'content', 'type': 'object'}, + "content": {"key": "content", "type": "object"}, } - def __init__( - self, - *, - content: Optional[Any] = None, - **kwargs - ): + def __init__(self, *, content: Optional[JSON] = None, **kwargs): """ :keyword content: HTTP message content. - :paramtype content: any + :paramtype content: JSON """ - super(HttpMessage, self).__init__(**kwargs) + super().__init__(**kwargs) self.content = content -class Identity(msrest.serialization.Model): +class Identity(_serialization.Model): """Identity for the resource. Variables are only populated by the server, and will be ignored when sending a request. @@ -1176,78 +1113,65 @@ class Identity(msrest.serialization.Model): :vartype principal_id: str :ivar tenant_id: The tenant ID of resource. :vartype tenant_id: str - :ivar type: The identity type. The only acceptable values to pass in are None and - "SystemAssigned". The default value is None. + :ivar type: The identity type. Default value is "SystemAssigned". :vartype type: str """ _validation = { - 'principal_id': {'readonly': True}, - 'tenant_id': {'readonly': True}, + "principal_id": {"readonly": True}, + "tenant_id": {"readonly": True}, } _attribute_map = { - 'principal_id': {'key': 'principalId', 'type': 'str'}, - 'tenant_id': {'key': 'tenantId', 'type': 'str'}, - 'type': {'key': 'type', 'type': 'str'}, + "principal_id": {"key": "principalId", "type": "str"}, + "tenant_id": {"key": "tenantId", "type": "str"}, + "type": {"key": "type", "type": "str"}, } - def __init__( - self, - *, - type: Optional[str] = None, - **kwargs - ): + def __init__(self, *, type: Optional[str] = None, **kwargs): """ - :keyword type: The identity type. The only acceptable values to pass in are None and - "SystemAssigned". The default value is None. + :keyword type: The identity type. Default value is "SystemAssigned". :paramtype type: str """ - super(Identity, self).__init__(**kwargs) + super().__init__(**kwargs) self.principal_id = None self.tenant_id = None self.type = type -class ParametersLink(msrest.serialization.Model): +class ParametersLink(_serialization.Model): """Entity representing the reference to the deployment parameters. All required parameters must be populated in order to send to Azure. - :ivar uri: Required. The URI of the parameters file. + :ivar uri: The URI of the parameters file. Required. :vartype uri: str :ivar content_version: If included, must match the ContentVersion in the template. :vartype content_version: str """ _validation = { - 'uri': {'required': True}, + "uri": {"required": True}, } _attribute_map = { - 'uri': {'key': 'uri', 'type': 'str'}, - 'content_version': {'key': 'contentVersion', 'type': 'str'}, + "uri": {"key": "uri", "type": "str"}, + "content_version": {"key": "contentVersion", "type": "str"}, } - def __init__( - self, - *, - uri: str, - content_version: Optional[str] = None, - **kwargs - ): + def __init__(self, *, uri: str, content_version: Optional[str] = None, **kwargs): """ - :keyword uri: Required. The URI of the parameters file. + :keyword uri: The URI of the parameters file. Required. :paramtype uri: str :keyword content_version: If included, must match the ContentVersion in the template. :paramtype content_version: str """ - super(ParametersLink, self).__init__(**kwargs) + super().__init__(**kwargs) self.uri = uri self.content_version = content_version -class Plan(msrest.serialization.Model): +class Plan(_serialization.Model): """Plan for the resource. :ivar name: The plan ID. @@ -1261,10 +1185,10 @@ class Plan(msrest.serialization.Model): """ _attribute_map = { - 'name': {'key': 'name', 'type': 'str'}, - 'publisher': {'key': 'publisher', 'type': 'str'}, - 'product': {'key': 'product', 'type': 'str'}, - 'promotion_code': {'key': 'promotionCode', 'type': 'str'}, + "name": {"key": "name", "type": "str"}, + "publisher": {"key": "publisher", "type": "str"}, + "product": {"key": "product", "type": "str"}, + "promotion_code": {"key": "promotionCode", "type": "str"}, } def __init__( @@ -1286,14 +1210,14 @@ def __init__( :keyword promotion_code: The promotion code. :paramtype promotion_code: str """ - super(Plan, self).__init__(**kwargs) + super().__init__(**kwargs) self.name = name self.publisher = publisher self.product = product self.promotion_code = promotion_code -class Provider(msrest.serialization.Model): +class Provider(_serialization.Model): """Resource provider information. Variables are only populated by the server, and will be ignored when sending a request. @@ -1310,36 +1234,31 @@ class Provider(msrest.serialization.Model): """ _validation = { - 'id': {'readonly': True}, - 'registration_state': {'readonly': True}, - 'resource_types': {'readonly': True}, + "id": {"readonly": True}, + "registration_state": {"readonly": True}, + "resource_types": {"readonly": True}, } _attribute_map = { - 'id': {'key': 'id', 'type': 'str'}, - 'namespace': {'key': 'namespace', 'type': 'str'}, - 'registration_state': {'key': 'registrationState', 'type': 'str'}, - 'resource_types': {'key': 'resourceTypes', 'type': '[ProviderResourceType]'}, + "id": {"key": "id", "type": "str"}, + "namespace": {"key": "namespace", "type": "str"}, + "registration_state": {"key": "registrationState", "type": "str"}, + "resource_types": {"key": "resourceTypes", "type": "[ProviderResourceType]"}, } - def __init__( - self, - *, - namespace: Optional[str] = None, - **kwargs - ): + def __init__(self, *, namespace: Optional[str] = None, **kwargs): """ :keyword namespace: The namespace of the resource provider. :paramtype namespace: str """ - super(Provider, self).__init__(**kwargs) + super().__init__(**kwargs) self.id = None self.namespace = namespace self.registration_state = None self.resource_types = None -class ProviderListResult(msrest.serialization.Model): +class ProviderListResult(_serialization.Model): """List of resource providers. Variables are only populated by the server, and will be ignored when sending a request. @@ -1351,30 +1270,25 @@ class ProviderListResult(msrest.serialization.Model): """ _validation = { - 'next_link': {'readonly': True}, + "next_link": {"readonly": True}, } _attribute_map = { - 'value': {'key': 'value', 'type': '[Provider]'}, - 'next_link': {'key': 'nextLink', 'type': 'str'}, + "value": {"key": "value", "type": "[Provider]"}, + "next_link": {"key": "nextLink", "type": "str"}, } - def __init__( - self, - *, - value: Optional[List["Provider"]] = None, - **kwargs - ): + def __init__(self, *, value: Optional[List["_models.Provider"]] = None, **kwargs): """ :keyword value: An array of resource providers. :paramtype value: list[~azure.mgmt.resource.resources.v2016_09_01.models.Provider] """ - super(ProviderListResult, self).__init__(**kwargs) + super().__init__(**kwargs) self.value = value self.next_link = None -class ProviderResourceType(msrest.serialization.Model): +class ProviderResourceType(_serialization.Model): """Resource type managed by the resource provider. :ivar resource_type: The resource type. @@ -1392,12 +1306,12 @@ class ProviderResourceType(msrest.serialization.Model): """ _attribute_map = { - 'resource_type': {'key': 'resourceType', 'type': 'str'}, - 'locations': {'key': 'locations', 'type': '[str]'}, - 'aliases': {'key': 'aliases', 'type': '[AliasType]'}, - 'api_versions': {'key': 'apiVersions', 'type': '[str]'}, - 'zone_mappings': {'key': 'zoneMappings', 'type': '[ZoneMapping]'}, - 'properties': {'key': 'properties', 'type': '{str}'}, + "resource_type": {"key": "resourceType", "type": "str"}, + "locations": {"key": "locations", "type": "[str]"}, + "aliases": {"key": "aliases", "type": "[AliasType]"}, + "api_versions": {"key": "apiVersions", "type": "[str]"}, + "zone_mappings": {"key": "zoneMappings", "type": "[ZoneMapping]"}, + "properties": {"key": "properties", "type": "{str}"}, } def __init__( @@ -1405,9 +1319,9 @@ def __init__( *, resource_type: Optional[str] = None, locations: Optional[List[str]] = None, - aliases: Optional[List["AliasType"]] = None, + aliases: Optional[List["_models.AliasType"]] = None, api_versions: Optional[List[str]] = None, - zone_mappings: Optional[List["ZoneMapping"]] = None, + zone_mappings: Optional[List["_models.ZoneMapping"]] = None, properties: Optional[Dict[str, str]] = None, **kwargs ): @@ -1425,7 +1339,7 @@ def __init__( :keyword properties: The properties. :paramtype properties: dict[str, str] """ - super(ProviderResourceType, self).__init__(**kwargs) + super().__init__(**kwargs) self.resource_type = resource_type self.locations = locations self.aliases = aliases @@ -1434,7 +1348,7 @@ def __init__( self.properties = properties -class ResourceGroup(msrest.serialization.Model): +class ResourceGroup(_serialization.Model): """Resource group information. Variables are only populated by the server, and will be ignored when sending a request. @@ -1447,27 +1361,27 @@ class ResourceGroup(msrest.serialization.Model): :vartype name: str :ivar properties: The resource group properties. :vartype properties: ~azure.mgmt.resource.resources.v2016_09_01.models.ResourceGroupProperties - :ivar location: Required. The location of the resource group. It cannot be changed after the - resource group has been created. It must be one of the supported Azure locations. + :ivar location: The location of the resource group. It cannot be changed after the resource + group has been created. It must be one of the supported Azure locations. Required. :vartype location: str :ivar managed_by: The ID of the resource that manages this resource group. :vartype managed_by: str - :ivar tags: A set of tags. The tags attached to the resource group. + :ivar tags: The tags attached to the resource group. :vartype tags: dict[str, str] """ _validation = { - 'id': {'readonly': True}, - 'location': {'required': True}, + "id": {"readonly": True}, + "location": {"required": True}, } _attribute_map = { - 'id': {'key': 'id', 'type': 'str'}, - 'name': {'key': 'name', 'type': 'str'}, - 'properties': {'key': 'properties', 'type': 'ResourceGroupProperties'}, - 'location': {'key': 'location', 'type': 'str'}, - 'managed_by': {'key': 'managedBy', 'type': 'str'}, - 'tags': {'key': 'tags', 'type': '{str}'}, + "id": {"key": "id", "type": "str"}, + "name": {"key": "name", "type": "str"}, + "properties": {"key": "properties", "type": "ResourceGroupProperties"}, + "location": {"key": "location", "type": "str"}, + "managed_by": {"key": "managedBy", "type": "str"}, + "tags": {"key": "tags", "type": "{str}"}, } def __init__( @@ -1475,7 +1389,7 @@ def __init__( *, location: str, name: Optional[str] = None, - properties: Optional["ResourceGroupProperties"] = None, + properties: Optional["_models.ResourceGroupProperties"] = None, managed_by: Optional[str] = None, tags: Optional[Dict[str, str]] = None, **kwargs @@ -1486,15 +1400,15 @@ def __init__( :keyword properties: The resource group properties. :paramtype properties: ~azure.mgmt.resource.resources.v2016_09_01.models.ResourceGroupProperties - :keyword location: Required. The location of the resource group. It cannot be changed after the - resource group has been created. It must be one of the supported Azure locations. + :keyword location: The location of the resource group. It cannot be changed after the resource + group has been created. It must be one of the supported Azure locations. Required. :paramtype location: str :keyword managed_by: The ID of the resource that manages this resource group. :paramtype managed_by: str - :keyword tags: A set of tags. The tags attached to the resource group. + :keyword tags: The tags attached to the resource group. :paramtype tags: dict[str, str] """ - super(ResourceGroup, self).__init__(**kwargs) + super().__init__(**kwargs) self.id = None self.name = name self.properties = properties @@ -1503,41 +1417,41 @@ def __init__( self.tags = tags -class ResourceGroupExportResult(msrest.serialization.Model): +class ResourceGroupExportResult(_serialization.Model): """ResourceGroupExportResult. :ivar template: The template content. - :vartype template: any + :vartype template: JSON :ivar error: The error. :vartype error: ~azure.mgmt.resource.resources.v2016_09_01.models.ResourceManagementErrorWithDetails """ _attribute_map = { - 'template': {'key': 'template', 'type': 'object'}, - 'error': {'key': 'error', 'type': 'ResourceManagementErrorWithDetails'}, + "template": {"key": "template", "type": "object"}, + "error": {"key": "error", "type": "ResourceManagementErrorWithDetails"}, } def __init__( self, *, - template: Optional[Any] = None, - error: Optional["ResourceManagementErrorWithDetails"] = None, + template: Optional[JSON] = None, + error: Optional["_models.ResourceManagementErrorWithDetails"] = None, **kwargs ): """ :keyword template: The template content. - :paramtype template: any + :paramtype template: JSON :keyword error: The error. :paramtype error: ~azure.mgmt.resource.resources.v2016_09_01.models.ResourceManagementErrorWithDetails """ - super(ResourceGroupExportResult, self).__init__(**kwargs) + super().__init__(**kwargs) self.template = template self.error = error -class ResourceGroupFilter(msrest.serialization.Model): +class ResourceGroupFilter(_serialization.Model): """Resource group filter. :ivar tag_name: The tag name. @@ -1547,29 +1461,23 @@ class ResourceGroupFilter(msrest.serialization.Model): """ _attribute_map = { - 'tag_name': {'key': 'tagName', 'type': 'str'}, - 'tag_value': {'key': 'tagValue', 'type': 'str'}, + "tag_name": {"key": "tagName", "type": "str"}, + "tag_value": {"key": "tagValue", "type": "str"}, } - def __init__( - self, - *, - tag_name: Optional[str] = None, - tag_value: Optional[str] = None, - **kwargs - ): + def __init__(self, *, tag_name: Optional[str] = None, tag_value: Optional[str] = None, **kwargs): """ :keyword tag_name: The tag name. :paramtype tag_name: str :keyword tag_value: The tag value. :paramtype tag_value: str """ - super(ResourceGroupFilter, self).__init__(**kwargs) + super().__init__(**kwargs) self.tag_name = tag_name self.tag_value = tag_value -class ResourceGroupListResult(msrest.serialization.Model): +class ResourceGroupListResult(_serialization.Model): """List of resource groups. Variables are only populated by the server, and will be ignored when sending a request. @@ -1581,30 +1489,25 @@ class ResourceGroupListResult(msrest.serialization.Model): """ _validation = { - 'next_link': {'readonly': True}, + "next_link": {"readonly": True}, } _attribute_map = { - 'value': {'key': 'value', 'type': '[ResourceGroup]'}, - 'next_link': {'key': 'nextLink', 'type': 'str'}, + "value": {"key": "value", "type": "[ResourceGroup]"}, + "next_link": {"key": "nextLink", "type": "str"}, } - def __init__( - self, - *, - value: Optional[List["ResourceGroup"]] = None, - **kwargs - ): + def __init__(self, *, value: Optional[List["_models.ResourceGroup"]] = None, **kwargs): """ :keyword value: An array of resource groups. :paramtype value: list[~azure.mgmt.resource.resources.v2016_09_01.models.ResourceGroup] """ - super(ResourceGroupListResult, self).__init__(**kwargs) + super().__init__(**kwargs) self.value = value self.next_link = None -class ResourceGroupProperties(msrest.serialization.Model): +class ResourceGroupProperties(_serialization.Model): """The resource group properties. Variables are only populated by the server, and will be ignored when sending a request. @@ -1614,24 +1517,20 @@ class ResourceGroupProperties(msrest.serialization.Model): """ _validation = { - 'provisioning_state': {'readonly': True}, + "provisioning_state": {"readonly": True}, } _attribute_map = { - 'provisioning_state': {'key': 'provisioningState', 'type': 'str'}, + "provisioning_state": {"key": "provisioningState", "type": "str"}, } - def __init__( - self, - **kwargs - ): - """ - """ - super(ResourceGroupProperties, self).__init__(**kwargs) + def __init__(self, **kwargs): + """ """ + super().__init__(**kwargs) self.provisioning_state = None -class ResourceListResult(msrest.serialization.Model): +class ResourceListResult(_serialization.Model): """List of resource groups. Variables are only populated by the server, and will be ignored when sending a request. @@ -1643,31 +1542,26 @@ class ResourceListResult(msrest.serialization.Model): """ _validation = { - 'next_link': {'readonly': True}, + "next_link": {"readonly": True}, } _attribute_map = { - 'value': {'key': 'value', 'type': '[GenericResourceExpanded]'}, - 'next_link': {'key': 'nextLink', 'type': 'str'}, + "value": {"key": "value", "type": "[GenericResourceExpanded]"}, + "next_link": {"key": "nextLink", "type": "str"}, } - def __init__( - self, - *, - value: Optional[List["GenericResourceExpanded"]] = None, - **kwargs - ): + def __init__(self, *, value: Optional[List["_models.GenericResourceExpanded"]] = None, **kwargs): """ :keyword value: An array of resources. :paramtype value: list[~azure.mgmt.resource.resources.v2016_09_01.models.GenericResourceExpanded] """ - super(ResourceListResult, self).__init__(**kwargs) + super().__init__(**kwargs) self.value = value self.next_link = None -class ResourceManagementErrorWithDetails(msrest.serialization.Model): +class ResourceManagementErrorWithDetails(_serialization.Model): """ResourceManagementErrorWithDetails. Variables are only populated by the server, and will be ignored when sending a request. @@ -1684,33 +1578,29 @@ class ResourceManagementErrorWithDetails(msrest.serialization.Model): """ _validation = { - 'code': {'readonly': True}, - 'message': {'readonly': True}, - 'target': {'readonly': True}, - 'details': {'readonly': True}, + "code": {"readonly": True}, + "message": {"readonly": True}, + "target": {"readonly": True}, + "details": {"readonly": True}, } _attribute_map = { - 'code': {'key': 'code', 'type': 'str'}, - 'message': {'key': 'message', 'type': 'str'}, - 'target': {'key': 'target', 'type': 'str'}, - 'details': {'key': 'details', 'type': '[ResourceManagementErrorWithDetails]'}, + "code": {"key": "code", "type": "str"}, + "message": {"key": "message", "type": "str"}, + "target": {"key": "target", "type": "str"}, + "details": {"key": "details", "type": "[ResourceManagementErrorWithDetails]"}, } - def __init__( - self, - **kwargs - ): - """ - """ - super(ResourceManagementErrorWithDetails, self).__init__(**kwargs) + def __init__(self, **kwargs): + """ """ + super().__init__(**kwargs) self.code = None self.message = None self.target = None self.details = None -class ResourceProviderOperationDisplayProperties(msrest.serialization.Model): +class ResourceProviderOperationDisplayProperties(_serialization.Model): """Resource provider operation's display properties. :ivar publisher: Operation description. @@ -1726,11 +1616,11 @@ class ResourceProviderOperationDisplayProperties(msrest.serialization.Model): """ _attribute_map = { - 'publisher': {'key': 'publisher', 'type': 'str'}, - 'provider': {'key': 'provider', 'type': 'str'}, - 'resource': {'key': 'resource', 'type': 'str'}, - 'operation': {'key': 'operation', 'type': 'str'}, - 'description': {'key': 'description', 'type': 'str'}, + "publisher": {"key": "publisher", "type": "str"}, + "provider": {"key": "provider", "type": "str"}, + "resource": {"key": "resource", "type": "str"}, + "operation": {"key": "operation", "type": "str"}, + "description": {"key": "description", "type": "str"}, } def __init__( @@ -1755,7 +1645,7 @@ def __init__( :keyword description: Operation description. :paramtype description: str """ - super(ResourceProviderOperationDisplayProperties, self).__init__(**kwargs) + super().__init__(**kwargs) self.publisher = publisher self.provider = provider self.resource = resource @@ -1763,7 +1653,7 @@ def __init__( self.description = description -class ResourcesMoveInfo(msrest.serialization.Model): +class ResourcesMoveInfo(_serialization.Model): """Parameters of move resources. :ivar resources: The IDs of the resources. @@ -1773,29 +1663,23 @@ class ResourcesMoveInfo(msrest.serialization.Model): """ _attribute_map = { - 'resources': {'key': 'resources', 'type': '[str]'}, - 'target_resource_group': {'key': 'targetResourceGroup', 'type': 'str'}, + "resources": {"key": "resources", "type": "[str]"}, + "target_resource_group": {"key": "targetResourceGroup", "type": "str"}, } - def __init__( - self, - *, - resources: Optional[List[str]] = None, - target_resource_group: Optional[str] = None, - **kwargs - ): + def __init__(self, *, resources: Optional[List[str]] = None, target_resource_group: Optional[str] = None, **kwargs): """ :keyword resources: The IDs of the resources. :paramtype resources: list[str] :keyword target_resource_group: The target resource group. :paramtype target_resource_group: str """ - super(ResourcesMoveInfo, self).__init__(**kwargs) + super().__init__(**kwargs) self.resources = resources self.target_resource_group = target_resource_group -class Sku(msrest.serialization.Model): +class Sku(_serialization.Model): """SKU for the resource. :ivar name: The SKU name. @@ -1813,12 +1697,12 @@ class Sku(msrest.serialization.Model): """ _attribute_map = { - 'name': {'key': 'name', 'type': 'str'}, - 'tier': {'key': 'tier', 'type': 'str'}, - 'size': {'key': 'size', 'type': 'str'}, - 'family': {'key': 'family', 'type': 'str'}, - 'model': {'key': 'model', 'type': 'str'}, - 'capacity': {'key': 'capacity', 'type': 'int'}, + "name": {"key": "name", "type": "str"}, + "tier": {"key": "tier", "type": "str"}, + "size": {"key": "size", "type": "str"}, + "family": {"key": "family", "type": "str"}, + "model": {"key": "model", "type": "str"}, + "capacity": {"key": "capacity", "type": "int"}, } def __init__( @@ -1846,7 +1730,7 @@ def __init__( :keyword capacity: The SKU capacity. :paramtype capacity: int """ - super(Sku, self).__init__(**kwargs) + super().__init__(**kwargs) self.name = name self.tier = tier self.size = size @@ -1855,7 +1739,7 @@ def __init__( self.capacity = capacity -class SubResource(msrest.serialization.Model): +class SubResource(_serialization.Model): """SubResource. :ivar id: Resource ID. @@ -1863,24 +1747,19 @@ class SubResource(msrest.serialization.Model): """ _attribute_map = { - 'id': {'key': 'id', 'type': 'str'}, + "id": {"key": "id", "type": "str"}, } - def __init__( - self, - *, - id: Optional[str] = None, - **kwargs - ): + def __init__(self, *, id: Optional[str] = None, **kwargs): # pylint: disable=redefined-builtin """ :keyword id: Resource ID. :paramtype id: str """ - super(SubResource, self).__init__(**kwargs) + super().__init__(**kwargs) self.id = id -class TagCount(msrest.serialization.Model): +class TagCount(_serialization.Model): """Tag count. :ivar type: Type of count. @@ -1890,29 +1769,23 @@ class TagCount(msrest.serialization.Model): """ _attribute_map = { - 'type': {'key': 'type', 'type': 'str'}, - 'value': {'key': 'value', 'type': 'int'}, + "type": {"key": "type", "type": "str"}, + "value": {"key": "value", "type": "int"}, } - def __init__( - self, - *, - type: Optional[str] = None, - value: Optional[int] = None, - **kwargs - ): + def __init__(self, *, type: Optional[str] = None, value: Optional[int] = None, **kwargs): """ :keyword type: Type of count. :paramtype type: str :keyword value: Value of count. :paramtype value: int """ - super(TagCount, self).__init__(**kwargs) + super().__init__(**kwargs) self.type = type self.value = value -class TagDetails(msrest.serialization.Model): +class TagDetails(_serialization.Model): """Tag details. Variables are only populated by the server, and will be ignored when sending a request. @@ -1929,22 +1802,22 @@ class TagDetails(msrest.serialization.Model): """ _validation = { - 'id': {'readonly': True}, + "id": {"readonly": True}, } _attribute_map = { - 'id': {'key': 'id', 'type': 'str'}, - 'tag_name': {'key': 'tagName', 'type': 'str'}, - 'count': {'key': 'count', 'type': 'TagCount'}, - 'values': {'key': 'values', 'type': '[TagValue]'}, + "id": {"key": "id", "type": "str"}, + "tag_name": {"key": "tagName", "type": "str"}, + "count": {"key": "count", "type": "TagCount"}, + "values": {"key": "values", "type": "[TagValue]"}, } def __init__( self, *, tag_name: Optional[str] = None, - count: Optional["TagCount"] = None, - values: Optional[List["TagValue"]] = None, + count: Optional["_models.TagCount"] = None, + values: Optional[List["_models.TagValue"]] = None, **kwargs ): """ @@ -1956,14 +1829,14 @@ def __init__( :keyword values: The list of tag values. :paramtype values: list[~azure.mgmt.resource.resources.v2016_09_01.models.TagValue] """ - super(TagDetails, self).__init__(**kwargs) + super().__init__(**kwargs) self.id = None self.tag_name = tag_name self.count = count self.values = values -class TagsListResult(msrest.serialization.Model): +class TagsListResult(_serialization.Model): """List of subscription tags. Variables are only populated by the server, and will be ignored when sending a request. @@ -1975,30 +1848,25 @@ class TagsListResult(msrest.serialization.Model): """ _validation = { - 'next_link': {'readonly': True}, + "next_link": {"readonly": True}, } _attribute_map = { - 'value': {'key': 'value', 'type': '[TagDetails]'}, - 'next_link': {'key': 'nextLink', 'type': 'str'}, + "value": {"key": "value", "type": "[TagDetails]"}, + "next_link": {"key": "nextLink", "type": "str"}, } - def __init__( - self, - *, - value: Optional[List["TagDetails"]] = None, - **kwargs - ): + def __init__(self, *, value: Optional[List["_models.TagDetails"]] = None, **kwargs): """ :keyword value: An array of tags. :paramtype value: list[~azure.mgmt.resource.resources.v2016_09_01.models.TagDetails] """ - super(TagsListResult, self).__init__(**kwargs) + super().__init__(**kwargs) self.value = value self.next_link = None -class TagValue(msrest.serialization.Model): +class TagValue(_serialization.Model): """Tag information. Variables are only populated by the server, and will be ignored when sending a request. @@ -2012,35 +1880,29 @@ class TagValue(msrest.serialization.Model): """ _validation = { - 'id': {'readonly': True}, + "id": {"readonly": True}, } _attribute_map = { - 'id': {'key': 'id', 'type': 'str'}, - 'tag_value': {'key': 'tagValue', 'type': 'str'}, - 'count': {'key': 'count', 'type': 'TagCount'}, + "id": {"key": "id", "type": "str"}, + "tag_value": {"key": "tagValue", "type": "str"}, + "count": {"key": "count", "type": "TagCount"}, } - def __init__( - self, - *, - tag_value: Optional[str] = None, - count: Optional["TagCount"] = None, - **kwargs - ): + def __init__(self, *, tag_value: Optional[str] = None, count: Optional["_models.TagCount"] = None, **kwargs): """ :keyword tag_value: The tag value. :paramtype tag_value: str :keyword count: The tag value count. :paramtype count: ~azure.mgmt.resource.resources.v2016_09_01.models.TagCount """ - super(TagValue, self).__init__(**kwargs) + super().__init__(**kwargs) self.id = None self.tag_value = tag_value self.count = count -class TargetResource(msrest.serialization.Model): +class TargetResource(_serialization.Model): """Target resource. :ivar id: The ID of the resource. @@ -2052,15 +1914,15 @@ class TargetResource(msrest.serialization.Model): """ _attribute_map = { - 'id': {'key': 'id', 'type': 'str'}, - 'resource_name': {'key': 'resourceName', 'type': 'str'}, - 'resource_type': {'key': 'resourceType', 'type': 'str'}, + "id": {"key": "id", "type": "str"}, + "resource_name": {"key": "resourceName", "type": "str"}, + "resource_type": {"key": "resourceType", "type": "str"}, } def __init__( self, *, - id: Optional[str] = None, + id: Optional[str] = None, # pylint: disable=redefined-builtin resource_name: Optional[str] = None, resource_type: Optional[str] = None, **kwargs @@ -2073,13 +1935,13 @@ def __init__( :keyword resource_type: The type of the resource. :paramtype resource_type: str """ - super(TargetResource, self).__init__(**kwargs) + super().__init__(**kwargs) self.id = id self.resource_name = resource_name self.resource_type = resource_type -class TemplateHashResult(msrest.serialization.Model): +class TemplateHashResult(_serialization.Model): """Result of the request to calculate template hash. It contains a string of minified template and its hash. :ivar minified_template: The minified template string. @@ -2089,67 +1951,55 @@ class TemplateHashResult(msrest.serialization.Model): """ _attribute_map = { - 'minified_template': {'key': 'minifiedTemplate', 'type': 'str'}, - 'template_hash': {'key': 'templateHash', 'type': 'str'}, + "minified_template": {"key": "minifiedTemplate", "type": "str"}, + "template_hash": {"key": "templateHash", "type": "str"}, } - def __init__( - self, - *, - minified_template: Optional[str] = None, - template_hash: Optional[str] = None, - **kwargs - ): + def __init__(self, *, minified_template: Optional[str] = None, template_hash: Optional[str] = None, **kwargs): """ :keyword minified_template: The minified template string. :paramtype minified_template: str :keyword template_hash: The template hash. :paramtype template_hash: str """ - super(TemplateHashResult, self).__init__(**kwargs) + super().__init__(**kwargs) self.minified_template = minified_template self.template_hash = template_hash -class TemplateLink(msrest.serialization.Model): +class TemplateLink(_serialization.Model): """Entity representing the reference to the template. All required parameters must be populated in order to send to Azure. - :ivar uri: Required. The URI of the template to deploy. + :ivar uri: The URI of the template to deploy. Required. :vartype uri: str :ivar content_version: If included, must match the ContentVersion in the template. :vartype content_version: str """ _validation = { - 'uri': {'required': True}, + "uri": {"required": True}, } _attribute_map = { - 'uri': {'key': 'uri', 'type': 'str'}, - 'content_version': {'key': 'contentVersion', 'type': 'str'}, + "uri": {"key": "uri", "type": "str"}, + "content_version": {"key": "contentVersion", "type": "str"}, } - def __init__( - self, - *, - uri: str, - content_version: Optional[str] = None, - **kwargs - ): + def __init__(self, *, uri: str, content_version: Optional[str] = None, **kwargs): """ - :keyword uri: Required. The URI of the template to deploy. + :keyword uri: The URI of the template to deploy. Required. :paramtype uri: str :keyword content_version: If included, must match the ContentVersion in the template. :paramtype content_version: str """ - super(TemplateLink, self).__init__(**kwargs) + super().__init__(**kwargs) self.uri = uri self.content_version = content_version -class ZoneMapping(msrest.serialization.Model): +class ZoneMapping(_serialization.Model): """ZoneMapping. :ivar location: The location of the zone mapping. @@ -2159,23 +2009,17 @@ class ZoneMapping(msrest.serialization.Model): """ _attribute_map = { - 'location': {'key': 'location', 'type': 'str'}, - 'zones': {'key': 'zones', 'type': '[str]'}, + "location": {"key": "location", "type": "str"}, + "zones": {"key": "zones", "type": "[str]"}, } - def __init__( - self, - *, - location: Optional[str] = None, - zones: Optional[List[str]] = None, - **kwargs - ): + def __init__(self, *, location: Optional[str] = None, zones: Optional[List[str]] = None, **kwargs): """ :keyword location: The location of the zone mapping. :paramtype location: str :keyword zones: :paramtype zones: list[str] """ - super(ZoneMapping, self).__init__(**kwargs) + super().__init__(**kwargs) self.location = location self.zones = zones diff --git a/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/resources/v2016_09_01/models/_patch.py b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/resources/v2016_09_01/models/_patch.py new file mode 100644 index 0000000000000..f7dd32510333d --- /dev/null +++ b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/resources/v2016_09_01/models/_patch.py @@ -0,0 +1,20 @@ +# ------------------------------------ +# Copyright (c) Microsoft Corporation. +# Licensed under the MIT License. +# ------------------------------------ +"""Customize generated code here. + +Follow our quickstart for examples: https://aka.ms/azsdk/python/dpcodegen/python/customize +""" +from typing import List + +__all__: List[str] = [] # Add all objects you want publicly available to users at this package level + + +def patch_sdk(): + """Do not remove from this file. + + `patch_sdk` is a last resort escape hatch that allows you to do customizations + you can't accomplish using the techniques described in + https://aka.ms/azsdk/python/dpcodegen/python/customize + """ diff --git a/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/resources/v2016_09_01/models/_resource_management_client_enums.py b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/resources/v2016_09_01/models/_resource_management_client_enums.py index 760e6d04925dd..936818e6d44ac 100644 --- a/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/resources/v2016_09_01/models/_resource_management_client_enums.py +++ b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/resources/v2016_09_01/models/_resource_management_client_enums.py @@ -7,11 +7,10 @@ # -------------------------------------------------------------------------- from enum import Enum -from six import with_metaclass from azure.core import CaseInsensitiveEnumMeta -class DeploymentMode(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): +class DeploymentMode(str, Enum, metaclass=CaseInsensitiveEnumMeta): """The mode that is used to deploy resources. This value can be either Incremental or Complete. In Incremental mode, resources are deployed without deleting existing resources that are not included in the template. In Complete mode, resources are deployed and existing resources in diff --git a/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/resources/v2016_09_01/operations/__init__.py b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/resources/v2016_09_01/operations/__init__.py index ad38d1291a450..ada6e7edc9b2c 100644 --- a/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/resources/v2016_09_01/operations/__init__.py +++ b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/resources/v2016_09_01/operations/__init__.py @@ -13,11 +13,17 @@ from ._operations import TagsOperations from ._operations import DeploymentOperationsOperations +from ._patch import __all__ as _patch_all +from ._patch import * # type: ignore # pylint: disable=unused-wildcard-import +from ._patch import patch_sdk as _patch_sdk + __all__ = [ - 'DeploymentsOperations', - 'ProvidersOperations', - 'ResourceGroupsOperations', - 'ResourcesOperations', - 'TagsOperations', - 'DeploymentOperationsOperations', + "DeploymentsOperations", + "ProvidersOperations", + "ResourceGroupsOperations", + "ResourcesOperations", + "TagsOperations", + "DeploymentOperationsOperations", ] +__all__.extend([p for p in _patch_all if p not in __all__]) +_patch_sdk() diff --git a/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/resources/v2016_09_01/operations/_operations.py b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/resources/v2016_09_01/operations/_operations.py index f1efbd347fc2a..35614cf986ffb 100644 --- a/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/resources/v2016_09_01/operations/_operations.py +++ b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/resources/v2016_09_01/operations/_operations.py @@ -6,277 +6,275 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -from typing import Any, Callable, Dict, Iterable, Optional, TypeVar, Union - -from msrest import Serializer - -from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error +import sys +from typing import Any, Callable, Dict, IO, Iterable, Optional, TypeVar, Union, cast, overload +from urllib.parse import parse_qs, urljoin, urlparse + +from azure.core.exceptions import ( + ClientAuthenticationError, + HttpResponseError, + ResourceExistsError, + ResourceNotFoundError, + ResourceNotModifiedError, + map_error, +) from azure.core.paging import ItemPaged from azure.core.pipeline import PipelineResponse from azure.core.pipeline.transport import HttpResponse from azure.core.polling import LROPoller, NoPolling, PollingMethod from azure.core.rest import HttpRequest from azure.core.tracing.decorator import distributed_trace +from azure.core.utils import case_insensitive_dict from azure.mgmt.core.exceptions import ARMErrorFormat from azure.mgmt.core.polling.arm_polling import ARMPolling from .. import models as _models +from ..._serialization import Serializer from .._vendor import _convert_request, _format_url_section -T = TypeVar('T') -JSONType = Any + +if sys.version_info >= (3, 9): + from collections.abc import MutableMapping +else: + from typing import MutableMapping # type: ignore # pylint: disable=ungrouped-imports +JSON = MutableMapping[str, Any] # pylint: disable=unsubscriptable-object +T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] _SERIALIZER = Serializer() _SERIALIZER.client_side_validation = False -def build_deployments_delete_request_initial( - resource_group_name: str, - deployment_name: str, - subscription_id: str, - **kwargs: Any + +def build_deployments_delete_request( + resource_group_name: str, deployment_name: str, subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2016-09-01") # type: str + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + api_version = kwargs.pop("api_version", _params.pop("api-version", "2016-09-01")) # type: str # Construct URL - _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/Microsoft.Resources/deployments/{deploymentName}") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/Microsoft.Resources/deployments/{deploymentName}", + ) # pylint: disable=line-too-long path_format_arguments = { - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._\(\)]+$'), - "deploymentName": _SERIALIZER.url("deployment_name", deployment_name, 'str', max_length=64, min_length=1, pattern=r'^[-\w\._\(\)]+$'), - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), + "resourceGroupName": _SERIALIZER.url( + "resource_group_name", resource_group_name, "str", max_length=90, min_length=1, pattern=r"^[-\w\._\(\)]+$" + ), + "deploymentName": _SERIALIZER.url( + "deployment_name", deployment_name, "str", max_length=64, min_length=1, pattern=r"^[-\w\._\(\)]+$" + ), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), } _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') - - return HttpRequest( - method="DELETE", - url=_url, - params=_query_parameters, - **kwargs - ) + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") + + return HttpRequest(method="DELETE", url=_url, params=_params, **kwargs) def build_deployments_check_existence_request( - resource_group_name: str, - deployment_name: str, - subscription_id: str, - **kwargs: Any + resource_group_name: str, deployment_name: str, subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2016-09-01") # type: str + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + api_version = kwargs.pop("api_version", _params.pop("api-version", "2016-09-01")) # type: str # Construct URL - _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/Microsoft.Resources/deployments/{deploymentName}") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/Microsoft.Resources/deployments/{deploymentName}", + ) # pylint: disable=line-too-long path_format_arguments = { - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._\(\)]+$'), - "deploymentName": _SERIALIZER.url("deployment_name", deployment_name, 'str', max_length=64, min_length=1, pattern=r'^[-\w\._\(\)]+$'), - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), + "resourceGroupName": _SERIALIZER.url( + "resource_group_name", resource_group_name, "str", max_length=90, min_length=1, pattern=r"^[-\w\._\(\)]+$" + ), + "deploymentName": _SERIALIZER.url( + "deployment_name", deployment_name, "str", max_length=64, min_length=1, pattern=r"^[-\w\._\(\)]+$" + ), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), } _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') - - return HttpRequest( - method="HEAD", - url=_url, - params=_query_parameters, - **kwargs - ) + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") + return HttpRequest(method="HEAD", url=_url, params=_params, **kwargs) -def build_deployments_create_or_update_request_initial( - resource_group_name: str, - deployment_name: str, - subscription_id: str, - *, - json: JSONType = None, - content: Any = None, - **kwargs: Any + +def build_deployments_create_or_update_request( + resource_group_name: str, deployment_name: str, subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2016-09-01") # type: str - content_type = kwargs.pop('content_type', None) # type: Optional[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", "2016-09-01")) # type: str + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + accept = _headers.pop("Accept", "application/json") - accept = "application/json" # Construct URL - _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/Microsoft.Resources/deployments/{deploymentName}") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/Microsoft.Resources/deployments/{deploymentName}", + ) # pylint: disable=line-too-long path_format_arguments = { - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._\(\)]+$'), - "deploymentName": _SERIALIZER.url("deployment_name", deployment_name, 'str', max_length=64, min_length=1, pattern=r'^[-\w\._\(\)]+$'), - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), + "resourceGroupName": _SERIALIZER.url( + "resource_group_name", resource_group_name, "str", max_length=90, min_length=1, pattern=r"^[-\w\._\(\)]+$" + ), + "deploymentName": _SERIALIZER.url( + "deployment_name", deployment_name, "str", max_length=64, min_length=1, pattern=r"^[-\w\._\(\)]+$" + ), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), } _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] if content_type is not None: - _header_parameters['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') - _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') - - return HttpRequest( - method="PUT", - url=_url, - params=_query_parameters, - headers=_header_parameters, - json=json, - content=content, - **kwargs - ) + _headers["Content-Type"] = _SERIALIZER.header("content_type", content_type, "str") + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="PUT", url=_url, params=_params, headers=_headers, **kwargs) def build_deployments_get_request( - resource_group_name: str, - deployment_name: str, - subscription_id: str, - **kwargs: Any + resource_group_name: str, deployment_name: str, subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2016-09-01") # type: 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", "2016-09-01")) # type: str + accept = _headers.pop("Accept", "application/json") - accept = "application/json" # Construct URL - _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/Microsoft.Resources/deployments/{deploymentName}") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/Microsoft.Resources/deployments/{deploymentName}", + ) # pylint: disable=line-too-long path_format_arguments = { - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._\(\)]+$'), - "deploymentName": _SERIALIZER.url("deployment_name", deployment_name, 'str', max_length=64, min_length=1, pattern=r'^[-\w\._\(\)]+$'), - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), + "resourceGroupName": _SERIALIZER.url( + "resource_group_name", resource_group_name, "str", max_length=90, min_length=1, pattern=r"^[-\w\._\(\)]+$" + ), + "deploymentName": _SERIALIZER.url( + "deployment_name", deployment_name, "str", max_length=64, min_length=1, pattern=r"^[-\w\._\(\)]+$" + ), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), } _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') - - return HttpRequest( - method="GET", - url=_url, - params=_query_parameters, - headers=_header_parameters, - **kwargs - ) + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) def build_deployments_cancel_request( - resource_group_name: str, - deployment_name: str, - subscription_id: str, - **kwargs: Any + resource_group_name: str, deployment_name: str, subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2016-09-01") # type: str + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + api_version = kwargs.pop("api_version", _params.pop("api-version", "2016-09-01")) # type: str # Construct URL - _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/Microsoft.Resources/deployments/{deploymentName}/cancel") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/Microsoft.Resources/deployments/{deploymentName}/cancel", + ) # pylint: disable=line-too-long path_format_arguments = { - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._\(\)]+$'), - "deploymentName": _SERIALIZER.url("deployment_name", deployment_name, 'str', max_length=64, min_length=1, pattern=r'^[-\w\._\(\)]+$'), - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), + "resourceGroupName": _SERIALIZER.url( + "resource_group_name", resource_group_name, "str", max_length=90, min_length=1, pattern=r"^[-\w\._\(\)]+$" + ), + "deploymentName": _SERIALIZER.url( + "deployment_name", deployment_name, "str", max_length=64, min_length=1, pattern=r"^[-\w\._\(\)]+$" + ), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), } _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') - - return HttpRequest( - method="POST", - url=_url, - params=_query_parameters, - **kwargs - ) + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") + + return HttpRequest(method="POST", url=_url, params=_params, **kwargs) def build_deployments_validate_request( - resource_group_name: str, - deployment_name: str, - subscription_id: str, - *, - json: JSONType = None, - content: Any = None, - **kwargs: Any + resource_group_name: str, deployment_name: str, subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2016-09-01") # type: str - content_type = kwargs.pop('content_type', None) # type: Optional[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", "2016-09-01")) # type: str + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + accept = _headers.pop("Accept", "application/json") - accept = "application/json" # Construct URL - _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/Microsoft.Resources/deployments/{deploymentName}/validate") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/Microsoft.Resources/deployments/{deploymentName}/validate", + ) # pylint: disable=line-too-long path_format_arguments = { - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._\(\)]+$'), - "deploymentName": _SERIALIZER.url("deployment_name", deployment_name, 'str', max_length=64, min_length=1, pattern=r'^[-\w\._\(\)]+$'), - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), + "resourceGroupName": _SERIALIZER.url( + "resource_group_name", resource_group_name, "str", max_length=90, min_length=1, pattern=r"^[-\w\._\(\)]+$" + ), + "deploymentName": _SERIALIZER.url( + "deployment_name", deployment_name, "str", max_length=64, min_length=1, pattern=r"^[-\w\._\(\)]+$" + ), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), } _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] if content_type is not None: - _header_parameters['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') - _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') - - return HttpRequest( - method="POST", - url=_url, - params=_query_parameters, - headers=_header_parameters, - json=json, - content=content, - **kwargs - ) + _headers["Content-Type"] = _SERIALIZER.header("content_type", content_type, "str") + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="POST", url=_url, params=_params, headers=_headers, **kwargs) def build_deployments_export_template_request( - resource_group_name: str, - deployment_name: str, - subscription_id: str, - **kwargs: Any + resource_group_name: str, deployment_name: str, subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2016-09-01") # type: 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", "2016-09-01")) # type: str + accept = _headers.pop("Accept", "application/json") - accept = "application/json" # Construct URL - _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/Microsoft.Resources/deployments/{deploymentName}/exportTemplate") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/Microsoft.Resources/deployments/{deploymentName}/exportTemplate", + ) # pylint: disable=line-too-long path_format_arguments = { - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._\(\)]+$'), - "deploymentName": _SERIALIZER.url("deployment_name", deployment_name, 'str', max_length=64, min_length=1, pattern=r'^[-\w\._\(\)]+$'), - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), + "resourceGroupName": _SERIALIZER.url( + "resource_group_name", resource_group_name, "str", max_length=90, min_length=1, pattern=r"^[-\w\._\(\)]+$" + ), + "deploymentName": _SERIALIZER.url( + "deployment_name", deployment_name, "str", max_length=64, min_length=1, pattern=r"^[-\w\._\(\)]+$" + ), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), } _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') - - return HttpRequest( - method="POST", - url=_url, - params=_query_parameters, - headers=_header_parameters, - **kwargs - ) + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="POST", url=_url, params=_params, headers=_headers, **kwargs) def build_deployments_list_request( @@ -287,216 +285,174 @@ def build_deployments_list_request( top: Optional[int] = None, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2016-09-01") # type: 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", "2016-09-01")) # type: str + accept = _headers.pop("Accept", "application/json") - accept = "application/json" # Construct URL - _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/Microsoft.Resources/deployments/") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/Microsoft.Resources/deployments/", + ) # pylint: disable=line-too-long path_format_arguments = { - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._\(\)]+$'), - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), + "resourceGroupName": _SERIALIZER.url( + "resource_group_name", resource_group_name, "str", max_length=90, min_length=1, pattern=r"^[-\w\._\(\)]+$" + ), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), } _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] if filter is not None: - _query_parameters['$filter'] = _SERIALIZER.query("filter", filter, 'str') + _params["$filter"] = _SERIALIZER.query("filter", filter, "str") if top is not None: - _query_parameters['$top'] = _SERIALIZER.query("top", top, 'int') - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["$top"] = _SERIALIZER.query("top", top, "int") + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') - - return HttpRequest( - method="GET", - url=_url, - params=_query_parameters, - headers=_header_parameters, - **kwargs - ) + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) -def build_deployments_calculate_template_hash_request( - *, - json: JSONType = None, - content: Any = None, - **kwargs: Any -) -> HttpRequest: - api_version = kwargs.pop('api_version', "2016-09-01") # type: str - content_type = kwargs.pop('content_type', None) # type: Optional[str] - accept = "application/json" +def build_deployments_calculate_template_hash_request(*, json: JSON, **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", "2016-09-01")) # type: str + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + accept = _headers.pop("Accept", "application/json") + # Construct URL _url = kwargs.pop("template_url", "/providers/Microsoft.Resources/calculateTemplateHash") # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] if content_type is not None: - _header_parameters['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') - _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') - - return HttpRequest( - method="POST", - url=_url, - params=_query_parameters, - headers=_header_parameters, - json=json, - content=content, - **kwargs - ) + _headers["Content-Type"] = _SERIALIZER.header("content_type", content_type, "str") + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="POST", url=_url, params=_params, headers=_headers, json=json, **kwargs) def build_providers_unregister_request( - resource_provider_namespace: str, - subscription_id: str, - **kwargs: Any + resource_provider_namespace: str, subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2016-09-01") # type: 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", "2016-09-01")) # type: str + accept = _headers.pop("Accept", "application/json") - accept = "application/json" # Construct URL - _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/providers/{resourceProviderNamespace}/unregister") + _url = kwargs.pop( + "template_url", "/subscriptions/{subscriptionId}/providers/{resourceProviderNamespace}/unregister" + ) path_format_arguments = { - "resourceProviderNamespace": _SERIALIZER.url("resource_provider_namespace", resource_provider_namespace, 'str'), - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), + "resourceProviderNamespace": _SERIALIZER.url("resource_provider_namespace", resource_provider_namespace, "str"), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), } _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') - - return HttpRequest( - method="POST", - url=_url, - params=_query_parameters, - headers=_header_parameters, - **kwargs - ) + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="POST", url=_url, params=_params, headers=_headers, **kwargs) def build_providers_register_request( - resource_provider_namespace: str, - subscription_id: str, - **kwargs: Any + resource_provider_namespace: str, subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2016-09-01") # type: 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", "2016-09-01")) # type: str + accept = _headers.pop("Accept", "application/json") - accept = "application/json" # Construct URL _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/providers/{resourceProviderNamespace}/register") path_format_arguments = { - "resourceProviderNamespace": _SERIALIZER.url("resource_provider_namespace", resource_provider_namespace, 'str'), - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), + "resourceProviderNamespace": _SERIALIZER.url("resource_provider_namespace", resource_provider_namespace, "str"), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), } _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') - - return HttpRequest( - method="POST", - url=_url, - params=_query_parameters, - headers=_header_parameters, - **kwargs - ) + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="POST", url=_url, params=_params, headers=_headers, **kwargs) def build_providers_list_request( - subscription_id: str, - *, - top: Optional[int] = None, - expand: Optional[str] = None, - **kwargs: Any + subscription_id: str, *, top: Optional[int] = None, expand: Optional[str] = None, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2016-09-01") # type: 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", "2016-09-01")) # type: str + accept = _headers.pop("Accept", "application/json") - accept = "application/json" # Construct URL _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/providers") path_format_arguments = { - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), } _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] if top is not None: - _query_parameters['$top'] = _SERIALIZER.query("top", top, 'int') + _params["$top"] = _SERIALIZER.query("top", top, "int") if expand is not None: - _query_parameters['$expand'] = _SERIALIZER.query("expand", expand, 'str') - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["$expand"] = _SERIALIZER.query("expand", expand, "str") + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') - - return HttpRequest( - method="GET", - url=_url, - params=_query_parameters, - headers=_header_parameters, - **kwargs - ) + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) def build_providers_get_request( - resource_provider_namespace: str, - subscription_id: str, - *, - expand: Optional[str] = None, - **kwargs: Any + resource_provider_namespace: str, subscription_id: str, *, expand: Optional[str] = None, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2016-09-01") # type: 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", "2016-09-01")) # type: str + accept = _headers.pop("Accept", "application/json") - accept = "application/json" # Construct URL _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/providers/{resourceProviderNamespace}") path_format_arguments = { - "resourceProviderNamespace": _SERIALIZER.url("resource_provider_namespace", resource_provider_namespace, 'str'), - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), + "resourceProviderNamespace": _SERIALIZER.url("resource_provider_namespace", resource_provider_namespace, "str"), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), } _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] if expand is not None: - _query_parameters['$expand'] = _SERIALIZER.query("expand", expand, 'str') - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["$expand"] = _SERIALIZER.query("expand", expand, "str") + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') - - return HttpRequest( - method="GET", - url=_url, - params=_query_parameters, - headers=_header_parameters, - **kwargs - ) + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) def build_resource_groups_list_resources_request( @@ -508,334 +464,269 @@ def build_resource_groups_list_resources_request( top: Optional[int] = None, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2016-09-01") # type: 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", "2016-09-01")) # type: str + accept = _headers.pop("Accept", "application/json") - accept = "application/json" # Construct URL _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/resources") path_format_arguments = { - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._\(\)]+$'), - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), + "resourceGroupName": _SERIALIZER.url( + "resource_group_name", resource_group_name, "str", max_length=90, min_length=1, pattern=r"^[-\w\._\(\)]+$" + ), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), } _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] if filter is not None: - _query_parameters['$filter'] = _SERIALIZER.query("filter", filter, 'str') + _params["$filter"] = _SERIALIZER.query("filter", filter, "str") if expand is not None: - _query_parameters['$expand'] = _SERIALIZER.query("expand", expand, 'str') + _params["$expand"] = _SERIALIZER.query("expand", expand, "str") if top is not None: - _query_parameters['$top'] = _SERIALIZER.query("top", top, 'int') - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["$top"] = _SERIALIZER.query("top", top, "int") + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') - - return HttpRequest( - method="GET", - url=_url, - params=_query_parameters, - headers=_header_parameters, - **kwargs - ) + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) def build_resource_groups_check_existence_request( - resource_group_name: str, - subscription_id: str, - **kwargs: Any + resource_group_name: str, subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2016-09-01") # type: str + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + api_version = kwargs.pop("api_version", _params.pop("api-version", "2016-09-01")) # type: str # Construct URL _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}") path_format_arguments = { - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._\(\)]+$'), - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), + "resourceGroupName": _SERIALIZER.url( + "resource_group_name", resource_group_name, "str", max_length=90, min_length=1, pattern=r"^[-\w\._\(\)]+$" + ), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), } _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') - - return HttpRequest( - method="HEAD", - url=_url, - params=_query_parameters, - **kwargs - ) + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") + + return HttpRequest(method="HEAD", url=_url, params=_params, **kwargs) def build_resource_groups_create_or_update_request( - resource_group_name: str, - subscription_id: str, - *, - json: JSONType = None, - content: Any = None, - **kwargs: Any + resource_group_name: str, subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2016-09-01") # type: str - content_type = kwargs.pop('content_type', None) # type: Optional[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", "2016-09-01")) # type: str + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + accept = _headers.pop("Accept", "application/json") - accept = "application/json" # Construct URL _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}") path_format_arguments = { - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._\(\)]+$'), - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), + "resourceGroupName": _SERIALIZER.url( + "resource_group_name", resource_group_name, "str", max_length=90, min_length=1, pattern=r"^[-\w\._\(\)]+$" + ), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), } _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] if content_type is not None: - _header_parameters['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') - _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') - - return HttpRequest( - method="PUT", - url=_url, - params=_query_parameters, - headers=_header_parameters, - json=json, - content=content, - **kwargs - ) + _headers["Content-Type"] = _SERIALIZER.header("content_type", content_type, "str") + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + return HttpRequest(method="PUT", url=_url, params=_params, headers=_headers, **kwargs) -def build_resource_groups_delete_request_initial( - resource_group_name: str, - subscription_id: str, - **kwargs: Any -) -> HttpRequest: - api_version = kwargs.pop('api_version', "2016-09-01") # type: str +def build_resource_groups_delete_request(resource_group_name: str, subscription_id: str, **kwargs: Any) -> HttpRequest: + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2016-09-01")) # type: str # Construct URL _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}") path_format_arguments = { - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._\(\)]+$'), - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), + "resourceGroupName": _SERIALIZER.url( + "resource_group_name", resource_group_name, "str", max_length=90, min_length=1, pattern=r"^[-\w\._\(\)]+$" + ), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), } _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') - - return HttpRequest( - method="DELETE", - url=_url, - params=_query_parameters, - **kwargs - ) + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") + return HttpRequest(method="DELETE", url=_url, params=_params, **kwargs) -def build_resource_groups_get_request( - resource_group_name: str, - subscription_id: str, - **kwargs: Any -) -> HttpRequest: - api_version = kwargs.pop('api_version', "2016-09-01") # type: str - accept = "application/json" +def build_resource_groups_get_request(resource_group_name: str, subscription_id: str, **kwargs: Any) -> HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2016-09-01")) # type: str + accept = _headers.pop("Accept", "application/json") + # Construct URL _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}") path_format_arguments = { - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._\(\)]+$'), - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), + "resourceGroupName": _SERIALIZER.url( + "resource_group_name", resource_group_name, "str", max_length=90, min_length=1, pattern=r"^[-\w\._\(\)]+$" + ), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), } _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') - - return HttpRequest( - method="GET", - url=_url, - params=_query_parameters, - headers=_header_parameters, - **kwargs - ) + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) -def build_resource_groups_patch_request( - resource_group_name: str, - subscription_id: str, - *, - json: JSONType = None, - content: Any = None, - **kwargs: Any -) -> HttpRequest: - api_version = kwargs.pop('api_version', "2016-09-01") # type: str - content_type = kwargs.pop('content_type', None) # type: Optional[str] - accept = "application/json" +def build_resource_groups_patch_request(resource_group_name: str, subscription_id: str, **kwargs: Any) -> HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2016-09-01")) # type: str + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + accept = _headers.pop("Accept", "application/json") + # Construct URL _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}") path_format_arguments = { - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._\(\)]+$'), - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), + "resourceGroupName": _SERIALIZER.url( + "resource_group_name", resource_group_name, "str", max_length=90, min_length=1, pattern=r"^[-\w\._\(\)]+$" + ), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), } _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] if content_type is not None: - _header_parameters['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') - _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') - - return HttpRequest( - method="PATCH", - url=_url, - params=_query_parameters, - headers=_header_parameters, - json=json, - content=content, - **kwargs - ) + _headers["Content-Type"] = _SERIALIZER.header("content_type", content_type, "str") + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="PATCH", url=_url, params=_params, headers=_headers, **kwargs) def build_resource_groups_export_template_request( - resource_group_name: str, - subscription_id: str, - *, - json: JSONType = None, - content: Any = None, - **kwargs: Any + resource_group_name: str, subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2016-09-01") # type: str - content_type = kwargs.pop('content_type', None) # type: Optional[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", "2016-09-01")) # type: str + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + accept = _headers.pop("Accept", "application/json") - accept = "application/json" # Construct URL - _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/exportTemplate") + _url = kwargs.pop( + "template_url", "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/exportTemplate" + ) path_format_arguments = { - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._\(\)]+$'), - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), + "resourceGroupName": _SERIALIZER.url( + "resource_group_name", resource_group_name, "str", max_length=90, min_length=1, pattern=r"^[-\w\._\(\)]+$" + ), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), } _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] if content_type is not None: - _header_parameters['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') - _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') - - return HttpRequest( - method="POST", - url=_url, - params=_query_parameters, - headers=_header_parameters, - json=json, - content=content, - **kwargs - ) + _headers["Content-Type"] = _SERIALIZER.header("content_type", content_type, "str") + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="POST", url=_url, params=_params, headers=_headers, **kwargs) def build_resource_groups_list_request( - subscription_id: str, - *, - filter: Optional[str] = None, - top: Optional[int] = None, - **kwargs: Any + subscription_id: str, *, filter: Optional[str] = None, top: Optional[int] = None, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2016-09-01") # type: 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", "2016-09-01")) # type: str + accept = _headers.pop("Accept", "application/json") - accept = "application/json" # Construct URL _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourcegroups") path_format_arguments = { - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), } _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] if filter is not None: - _query_parameters['$filter'] = _SERIALIZER.query("filter", filter, 'str') + _params["$filter"] = _SERIALIZER.query("filter", filter, "str") if top is not None: - _query_parameters['$top'] = _SERIALIZER.query("top", top, 'int') - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["$top"] = _SERIALIZER.query("top", top, "int") + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') - - return HttpRequest( - method="GET", - url=_url, - params=_query_parameters, - headers=_header_parameters, - **kwargs - ) + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) -def build_resources_move_resources_request_initial( - source_resource_group_name: str, - subscription_id: str, - *, - json: JSONType = None, - content: Any = None, - **kwargs: Any + +def build_resources_move_resources_request( + source_resource_group_name: str, subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2016-09-01") # type: str - content_type = kwargs.pop('content_type', None) # type: Optional[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", "2016-09-01")) # type: str + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] # Construct URL - _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{sourceResourceGroupName}/moveResources") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", "/subscriptions/{subscriptionId}/resourceGroups/{sourceResourceGroupName}/moveResources" + ) # pylint: disable=line-too-long path_format_arguments = { - "sourceResourceGroupName": _SERIALIZER.url("source_resource_group_name", source_resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._\(\)]+$'), - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), + "sourceResourceGroupName": _SERIALIZER.url( + "source_resource_group_name", + source_resource_group_name, + "str", + max_length=90, + min_length=1, + pattern=r"^[-\w\._\(\)]+$", + ), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), } _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] if content_type is not None: - _header_parameters['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') - - return HttpRequest( - method="POST", - url=_url, - params=_query_parameters, - headers=_header_parameters, - json=json, - content=content, - **kwargs - ) + _headers["Content-Type"] = _SERIALIZER.header("content_type", content_type, "str") + + return HttpRequest(method="POST", url=_url, params=_params, headers=_headers, **kwargs) def build_resources_list_request( @@ -846,38 +737,33 @@ def build_resources_list_request( top: Optional[int] = None, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2016-09-01") # type: 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", "2016-09-01")) # type: str + accept = _headers.pop("Accept", "application/json") - accept = "application/json" # Construct URL _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resources") path_format_arguments = { - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), } _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] if filter is not None: - _query_parameters['$filter'] = _SERIALIZER.query("filter", filter, 'str') + _params["$filter"] = _SERIALIZER.query("filter", filter, "str") if expand is not None: - _query_parameters['$expand'] = _SERIALIZER.query("expand", expand, 'str') + _params["$expand"] = _SERIALIZER.query("expand", expand, "str") if top is not None: - _query_parameters['$top'] = _SERIALIZER.query("top", top, 'int') - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["$top"] = _SERIALIZER.query("top", top, "int") + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') - - return HttpRequest( - method="GET", - url=_url, - params=_query_parameters, - headers=_header_parameters, - **kwargs - ) + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) def build_resources_check_existence_request( @@ -891,32 +777,33 @@ def build_resources_check_existence_request( api_version: str, **kwargs: Any ) -> HttpRequest: + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + # Construct URL - _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{parentResourcePath}/{resourceType}/{resourceName}") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{parentResourcePath}/{resourceType}/{resourceName}", + ) # pylint: disable=line-too-long path_format_arguments = { - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._\(\)]+$'), - "resourceProviderNamespace": _SERIALIZER.url("resource_provider_namespace", resource_provider_namespace, 'str'), - "parentResourcePath": _SERIALIZER.url("parent_resource_path", parent_resource_path, 'str', skip_quote=True), - "resourceType": _SERIALIZER.url("resource_type", resource_type, 'str', skip_quote=True), - "resourceName": _SERIALIZER.url("resource_name", resource_name, 'str'), - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), + "resourceGroupName": _SERIALIZER.url( + "resource_group_name", resource_group_name, "str", max_length=90, min_length=1, pattern=r"^[-\w\._\(\)]+$" + ), + "resourceProviderNamespace": _SERIALIZER.url("resource_provider_namespace", resource_provider_namespace, "str"), + "parentResourcePath": _SERIALIZER.url("parent_resource_path", parent_resource_path, "str", skip_quote=True), + "resourceType": _SERIALIZER.url("resource_type", resource_type, "str", skip_quote=True), + "resourceName": _SERIALIZER.url("resource_name", resource_name, "str"), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), } _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') - - return HttpRequest( - method="HEAD", - url=_url, - params=_query_parameters, - **kwargs - ) + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") + + return HttpRequest(method="HEAD", url=_url, params=_params, **kwargs) -def build_resources_delete_request_initial( +def build_resources_delete_request( resource_group_name: str, resource_provider_namespace: str, parent_resource_path: str, @@ -927,32 +814,33 @@ def build_resources_delete_request_initial( api_version: str, **kwargs: Any ) -> HttpRequest: + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + # Construct URL - _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{parentResourcePath}/{resourceType}/{resourceName}") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{parentResourcePath}/{resourceType}/{resourceName}", + ) # pylint: disable=line-too-long path_format_arguments = { - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._\(\)]+$'), - "resourceProviderNamespace": _SERIALIZER.url("resource_provider_namespace", resource_provider_namespace, 'str'), - "parentResourcePath": _SERIALIZER.url("parent_resource_path", parent_resource_path, 'str', skip_quote=True), - "resourceType": _SERIALIZER.url("resource_type", resource_type, 'str', skip_quote=True), - "resourceName": _SERIALIZER.url("resource_name", resource_name, 'str'), - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), + "resourceGroupName": _SERIALIZER.url( + "resource_group_name", resource_group_name, "str", max_length=90, min_length=1, pattern=r"^[-\w\._\(\)]+$" + ), + "resourceProviderNamespace": _SERIALIZER.url("resource_provider_namespace", resource_provider_namespace, "str"), + "parentResourcePath": _SERIALIZER.url("parent_resource_path", parent_resource_path, "str", skip_quote=True), + "resourceType": _SERIALIZER.url("resource_type", resource_type, "str", skip_quote=True), + "resourceName": _SERIALIZER.url("resource_name", resource_name, "str"), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), } _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') - - return HttpRequest( - method="DELETE", - url=_url, - params=_query_parameters, - **kwargs - ) + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") + return HttpRequest(method="DELETE", url=_url, params=_params, **kwargs) -def build_resources_create_or_update_request_initial( + +def build_resources_create_or_update_request( resource_group_name: str, resource_provider_namespace: str, parent_resource_path: str, @@ -961,48 +849,44 @@ def build_resources_create_or_update_request_initial( subscription_id: str, *, api_version: str, - json: JSONType = None, - content: Any = None, **kwargs: Any ) -> HttpRequest: - content_type = kwargs.pop('content_type', None) # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + accept = _headers.pop("Accept", "application/json") - accept = "application/json" # Construct URL - _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{parentResourcePath}/{resourceType}/{resourceName}") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{parentResourcePath}/{resourceType}/{resourceName}", + ) # pylint: disable=line-too-long path_format_arguments = { - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._\(\)]+$'), - "resourceProviderNamespace": _SERIALIZER.url("resource_provider_namespace", resource_provider_namespace, 'str'), - "parentResourcePath": _SERIALIZER.url("parent_resource_path", parent_resource_path, 'str', skip_quote=True), - "resourceType": _SERIALIZER.url("resource_type", resource_type, 'str', skip_quote=True), - "resourceName": _SERIALIZER.url("resource_name", resource_name, 'str'), - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), + "resourceGroupName": _SERIALIZER.url( + "resource_group_name", resource_group_name, "str", max_length=90, min_length=1, pattern=r"^[-\w\._\(\)]+$" + ), + "resourceProviderNamespace": _SERIALIZER.url("resource_provider_namespace", resource_provider_namespace, "str"), + "parentResourcePath": _SERIALIZER.url("parent_resource_path", parent_resource_path, "str", skip_quote=True), + "resourceType": _SERIALIZER.url("resource_type", resource_type, "str", skip_quote=True), + "resourceName": _SERIALIZER.url("resource_name", resource_name, "str"), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), } _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] if content_type is not None: - _header_parameters['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') - _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') - - return HttpRequest( - method="PUT", - url=_url, - params=_query_parameters, - headers=_header_parameters, - json=json, - content=content, - **kwargs - ) + _headers["Content-Type"] = _SERIALIZER.header("content_type", content_type, "str") + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="PUT", url=_url, params=_params, headers=_headers, **kwargs) -def build_resources_update_request_initial( +def build_resources_update_request( resource_group_name: str, resource_provider_namespace: str, parent_resource_path: str, @@ -1011,45 +895,41 @@ def build_resources_update_request_initial( subscription_id: str, *, api_version: str, - json: JSONType = None, - content: Any = None, **kwargs: Any ) -> HttpRequest: - content_type = kwargs.pop('content_type', None) # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + accept = _headers.pop("Accept", "application/json") - accept = "application/json" # Construct URL - _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{parentResourcePath}/{resourceType}/{resourceName}") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{parentResourcePath}/{resourceType}/{resourceName}", + ) # pylint: disable=line-too-long path_format_arguments = { - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._\(\)]+$'), - "resourceProviderNamespace": _SERIALIZER.url("resource_provider_namespace", resource_provider_namespace, 'str'), - "parentResourcePath": _SERIALIZER.url("parent_resource_path", parent_resource_path, 'str', skip_quote=True), - "resourceType": _SERIALIZER.url("resource_type", resource_type, 'str', skip_quote=True), - "resourceName": _SERIALIZER.url("resource_name", resource_name, 'str'), - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), + "resourceGroupName": _SERIALIZER.url( + "resource_group_name", resource_group_name, "str", max_length=90, min_length=1, pattern=r"^[-\w\._\(\)]+$" + ), + "resourceProviderNamespace": _SERIALIZER.url("resource_provider_namespace", resource_provider_namespace, "str"), + "parentResourcePath": _SERIALIZER.url("parent_resource_path", parent_resource_path, "str", skip_quote=True), + "resourceType": _SERIALIZER.url("resource_type", resource_type, "str", skip_quote=True), + "resourceName": _SERIALIZER.url("resource_name", resource_name, "str"), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), } _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] if content_type is not None: - _header_parameters['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') - _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') - - return HttpRequest( - method="PATCH", - url=_url, - params=_query_parameters, - headers=_header_parameters, - json=json, - content=content, - **kwargs - ) + _headers["Content-Type"] = _SERIALIZER.header("content_type", content_type, "str") + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="PATCH", url=_url, params=_params, headers=_headers, **kwargs) def build_resources_get_request( @@ -1063,490 +943,388 @@ def build_resources_get_request( api_version: str, **kwargs: Any ) -> HttpRequest: - accept = "application/json" + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + accept = _headers.pop("Accept", "application/json") + # Construct URL - _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{parentResourcePath}/{resourceType}/{resourceName}") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{parentResourcePath}/{resourceType}/{resourceName}", + ) # pylint: disable=line-too-long path_format_arguments = { - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._\(\)]+$'), - "resourceProviderNamespace": _SERIALIZER.url("resource_provider_namespace", resource_provider_namespace, 'str'), - "parentResourcePath": _SERIALIZER.url("parent_resource_path", parent_resource_path, 'str', skip_quote=True), - "resourceType": _SERIALIZER.url("resource_type", resource_type, 'str', skip_quote=True), - "resourceName": _SERIALIZER.url("resource_name", resource_name, 'str'), - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), + "resourceGroupName": _SERIALIZER.url( + "resource_group_name", resource_group_name, "str", max_length=90, min_length=1, pattern=r"^[-\w\._\(\)]+$" + ), + "resourceProviderNamespace": _SERIALIZER.url("resource_provider_namespace", resource_provider_namespace, "str"), + "parentResourcePath": _SERIALIZER.url("parent_resource_path", parent_resource_path, "str", skip_quote=True), + "resourceType": _SERIALIZER.url("resource_type", resource_type, "str", skip_quote=True), + "resourceName": _SERIALIZER.url("resource_name", resource_name, "str"), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), } _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') - - return HttpRequest( - method="GET", - url=_url, - params=_query_parameters, - headers=_header_parameters, - **kwargs - ) + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) + + +def build_resources_check_existence_by_id_request(resource_id: str, *, api_version: str, **kwargs: Any) -> HttpRequest: + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) -def build_resources_check_existence_by_id_request( - resource_id: str, - *, - api_version: str, - **kwargs: Any -) -> HttpRequest: # Construct URL _url = kwargs.pop("template_url", "/{resourceId}") path_format_arguments = { - "resourceId": _SERIALIZER.url("resource_id", resource_id, 'str', skip_quote=True), + "resourceId": _SERIALIZER.url("resource_id", resource_id, "str", skip_quote=True), } _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') - - return HttpRequest( - method="HEAD", - url=_url, - params=_query_parameters, - **kwargs - ) + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") + return HttpRequest(method="HEAD", url=_url, params=_params, **kwargs) + + +def build_resources_delete_by_id_request(resource_id: str, *, api_version: str, **kwargs: Any) -> HttpRequest: + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) -def build_resources_delete_by_id_request_initial( - resource_id: str, - *, - api_version: str, - **kwargs: Any -) -> HttpRequest: # Construct URL _url = kwargs.pop("template_url", "/{resourceId}") path_format_arguments = { - "resourceId": _SERIALIZER.url("resource_id", resource_id, 'str', skip_quote=True), + "resourceId": _SERIALIZER.url("resource_id", resource_id, "str", skip_quote=True), } _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') - - return HttpRequest( - method="DELETE", - url=_url, - params=_query_parameters, - **kwargs - ) + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") + return HttpRequest(method="DELETE", url=_url, params=_params, **kwargs) -def build_resources_create_or_update_by_id_request_initial( - resource_id: str, - *, - api_version: str, - json: JSONType = None, - content: Any = None, - **kwargs: Any -) -> HttpRequest: - content_type = kwargs.pop('content_type', None) # type: Optional[str] - accept = "application/json" +def build_resources_create_or_update_by_id_request(resource_id: str, *, api_version: str, **kwargs: Any) -> HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + accept = _headers.pop("Accept", "application/json") + # Construct URL _url = kwargs.pop("template_url", "/{resourceId}") path_format_arguments = { - "resourceId": _SERIALIZER.url("resource_id", resource_id, 'str', skip_quote=True), + "resourceId": _SERIALIZER.url("resource_id", resource_id, "str", skip_quote=True), } _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] if content_type is not None: - _header_parameters['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') - _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') - - return HttpRequest( - method="PUT", - url=_url, - params=_query_parameters, - headers=_header_parameters, - json=json, - content=content, - **kwargs - ) + _headers["Content-Type"] = _SERIALIZER.header("content_type", content_type, "str") + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + return HttpRequest(method="PUT", url=_url, params=_params, headers=_headers, **kwargs) -def build_resources_update_by_id_request_initial( - resource_id: str, - *, - api_version: str, - json: JSONType = None, - content: Any = None, - **kwargs: Any -) -> HttpRequest: - content_type = kwargs.pop('content_type', None) # type: Optional[str] - accept = "application/json" +def build_resources_update_by_id_request(resource_id: str, *, api_version: str, **kwargs: Any) -> HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + accept = _headers.pop("Accept", "application/json") + # Construct URL _url = kwargs.pop("template_url", "/{resourceId}") path_format_arguments = { - "resourceId": _SERIALIZER.url("resource_id", resource_id, 'str', skip_quote=True), + "resourceId": _SERIALIZER.url("resource_id", resource_id, "str", skip_quote=True), } _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] if content_type is not None: - _header_parameters['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') - _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') - - return HttpRequest( - method="PATCH", - url=_url, - params=_query_parameters, - headers=_header_parameters, - json=json, - content=content, - **kwargs - ) + _headers["Content-Type"] = _SERIALIZER.header("content_type", content_type, "str") + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + return HttpRequest(method="PATCH", url=_url, params=_params, headers=_headers, **kwargs) + + +def build_resources_get_by_id_request(resource_id: str, *, api_version: str, **kwargs: Any) -> HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + accept = _headers.pop("Accept", "application/json") -def build_resources_get_by_id_request( - resource_id: str, - *, - api_version: str, - **kwargs: Any -) -> HttpRequest: - accept = "application/json" # Construct URL _url = kwargs.pop("template_url", "/{resourceId}") path_format_arguments = { - "resourceId": _SERIALIZER.url("resource_id", resource_id, 'str', skip_quote=True), + "resourceId": _SERIALIZER.url("resource_id", resource_id, "str", skip_quote=True), } _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') - - return HttpRequest( - method="GET", - url=_url, - params=_query_parameters, - headers=_header_parameters, - **kwargs - ) + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) -def build_tags_delete_value_request( - tag_name: str, - tag_value: str, - subscription_id: str, - **kwargs: Any -) -> HttpRequest: - api_version = kwargs.pop('api_version', "2016-09-01") # type: str +def build_tags_delete_value_request(tag_name: str, tag_value: str, subscription_id: str, **kwargs: Any) -> HttpRequest: + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2016-09-01")) # type: str # Construct URL _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/tagNames/{tagName}/tagValues/{tagValue}") path_format_arguments = { - "tagName": _SERIALIZER.url("tag_name", tag_name, 'str'), - "tagValue": _SERIALIZER.url("tag_value", tag_value, 'str'), - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), + "tagName": _SERIALIZER.url("tag_name", tag_name, "str"), + "tagValue": _SERIALIZER.url("tag_value", tag_value, "str"), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), } _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') - - return HttpRequest( - method="DELETE", - url=_url, - params=_query_parameters, - **kwargs - ) + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") + + return HttpRequest(method="DELETE", url=_url, params=_params, **kwargs) def build_tags_create_or_update_value_request( - tag_name: str, - tag_value: str, - subscription_id: str, - **kwargs: Any + tag_name: str, tag_value: str, subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2016-09-01") # type: 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", "2016-09-01")) # type: str + accept = _headers.pop("Accept", "application/json") - accept = "application/json" # Construct URL _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/tagNames/{tagName}/tagValues/{tagValue}") path_format_arguments = { - "tagName": _SERIALIZER.url("tag_name", tag_name, 'str'), - "tagValue": _SERIALIZER.url("tag_value", tag_value, 'str'), - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), + "tagName": _SERIALIZER.url("tag_name", tag_name, "str"), + "tagValue": _SERIALIZER.url("tag_value", tag_value, "str"), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), } _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') - - return HttpRequest( - method="PUT", - url=_url, - params=_query_parameters, - headers=_header_parameters, - **kwargs - ) + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + return HttpRequest(method="PUT", url=_url, params=_params, headers=_headers, **kwargs) -def build_tags_create_or_update_request( - tag_name: str, - subscription_id: str, - **kwargs: Any -) -> HttpRequest: - api_version = kwargs.pop('api_version', "2016-09-01") # type: str - accept = "application/json" +def build_tags_create_or_update_request(tag_name: str, subscription_id: str, **kwargs: Any) -> HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2016-09-01")) # type: str + accept = _headers.pop("Accept", "application/json") + # Construct URL _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/tagNames/{tagName}") path_format_arguments = { - "tagName": _SERIALIZER.url("tag_name", tag_name, 'str'), - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), + "tagName": _SERIALIZER.url("tag_name", tag_name, "str"), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), } _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') - - return HttpRequest( - method="PUT", - url=_url, - params=_query_parameters, - headers=_header_parameters, - **kwargs - ) + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + return HttpRequest(method="PUT", url=_url, params=_params, headers=_headers, **kwargs) -def build_tags_delete_request( - tag_name: str, - subscription_id: str, - **kwargs: Any -) -> HttpRequest: - api_version = kwargs.pop('api_version', "2016-09-01") # type: str +def build_tags_delete_request(tag_name: str, subscription_id: str, **kwargs: Any) -> HttpRequest: + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2016-09-01")) # type: str # Construct URL _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/tagNames/{tagName}") path_format_arguments = { - "tagName": _SERIALIZER.url("tag_name", tag_name, 'str'), - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), + "tagName": _SERIALIZER.url("tag_name", tag_name, "str"), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), } _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') - - return HttpRequest( - method="DELETE", - url=_url, - params=_query_parameters, - **kwargs - ) + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") + return HttpRequest(method="DELETE", url=_url, params=_params, **kwargs) -def build_tags_list_request( - subscription_id: str, - **kwargs: Any -) -> HttpRequest: - api_version = kwargs.pop('api_version', "2016-09-01") # type: str - accept = "application/json" +def build_tags_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", "2016-09-01")) # type: str + accept = _headers.pop("Accept", "application/json") + # Construct URL _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/tagNames") path_format_arguments = { - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), } _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') - - return HttpRequest( - method="GET", - url=_url, - params=_query_parameters, - headers=_header_parameters, - **kwargs - ) + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) def build_deployment_operations_get_request( - resource_group_name: str, - deployment_name: str, - operation_id: str, - subscription_id: str, - **kwargs: Any + resource_group_name: str, deployment_name: str, operation_id: str, subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2016-09-01") # type: 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", "2016-09-01")) # type: str + accept = _headers.pop("Accept", "application/json") - accept = "application/json" # Construct URL - _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/deployments/{deploymentName}/operations/{operationId}") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/deployments/{deploymentName}/operations/{operationId}", + ) # pylint: disable=line-too-long path_format_arguments = { - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._\(\)]+$'), - "deploymentName": _SERIALIZER.url("deployment_name", deployment_name, 'str', max_length=64, min_length=1, pattern=r'^[-\w\._\(\)]+$'), - "operationId": _SERIALIZER.url("operation_id", operation_id, 'str'), - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), + "resourceGroupName": _SERIALIZER.url( + "resource_group_name", resource_group_name, "str", max_length=90, min_length=1, pattern=r"^[-\w\._\(\)]+$" + ), + "deploymentName": _SERIALIZER.url( + "deployment_name", deployment_name, "str", max_length=64, min_length=1, pattern=r"^[-\w\._\(\)]+$" + ), + "operationId": _SERIALIZER.url("operation_id", operation_id, "str"), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), } _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') - - return HttpRequest( - method="GET", - url=_url, - params=_query_parameters, - headers=_header_parameters, - **kwargs - ) + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) def build_deployment_operations_list_request( - resource_group_name: str, - deployment_name: str, - subscription_id: str, - *, - top: Optional[int] = None, - **kwargs: Any + resource_group_name: str, deployment_name: str, subscription_id: str, *, top: Optional[int] = None, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2016-09-01") # type: 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", "2016-09-01")) # type: str + accept = _headers.pop("Accept", "application/json") - accept = "application/json" # Construct URL - _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/deployments/{deploymentName}/operations") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/deployments/{deploymentName}/operations", + ) # pylint: disable=line-too-long path_format_arguments = { - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._\(\)]+$'), - "deploymentName": _SERIALIZER.url("deployment_name", deployment_name, 'str', max_length=64, min_length=1, pattern=r'^[-\w\._\(\)]+$'), - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), + "resourceGroupName": _SERIALIZER.url( + "resource_group_name", resource_group_name, "str", max_length=90, min_length=1, pattern=r"^[-\w\._\(\)]+$" + ), + "deploymentName": _SERIALIZER.url( + "deployment_name", deployment_name, "str", max_length=64, min_length=1, pattern=r"^[-\w\._\(\)]+$" + ), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), } _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] if top is not None: - _query_parameters['$top'] = _SERIALIZER.query("top", top, 'int') - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["$top"] = _SERIALIZER.query("top", top, "int") + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') - - return HttpRequest( - method="GET", - url=_url, - params=_query_parameters, - headers=_header_parameters, - **kwargs - ) + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) -class DeploymentsOperations(object): - """DeploymentsOperations operations. - You should not instantiate this class directly. Instead, you should create a Client instance that - instantiates it for you and attaches it as an attribute. +class DeploymentsOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. - :ivar models: Alias to model classes used in this operation group. - :type models: ~azure.mgmt.resource.resources.v2016_09_01.models - :param client: Client for service requests. - :param config: Configuration of service client. - :param serializer: An object model serializer. - :param deserializer: An object model deserializer. + Instead, you should access the following operations through + :class:`~azure.mgmt.resource.resources.v2016_09_01.ResourceManagementClient`'s + :attr:`deployments` attribute. """ models = _models - def __init__(self, client, config, serializer, deserializer): - self._client = client - self._serialize = serializer - self._deserialize = deserializer - self._config = config + def __init__(self, *args, **kwargs): + input_args = list(args) + self._client = input_args.pop(0) if input_args else kwargs.pop("client") + self._config = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") def _delete_initial( # pylint: disable=inconsistent-return-statements - self, - resource_group_name: str, - deployment_name: str, - **kwargs: Any + self, resource_group_name: str, deployment_name: str, **kwargs: Any ) -> None: - cls = kwargs.pop('cls', None) # type: ClsType[None] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + 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', "2016-09-01") # type: str + api_version = kwargs.pop("api_version", _params.pop("api-version", "2016-09-01")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[None] - - request = build_deployments_delete_request_initial( + request = build_deployments_delete_request( resource_group_name=resource_group_name, deployment_name=deployment_name, subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self._delete_initial.metadata['url'], + template_url=self._delete_initial.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [202, 204]: @@ -1556,16 +1334,10 @@ 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.Resources/deployments/{deploymentName}"} # type: ignore - + _delete_initial.metadata = {"url": "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/Microsoft.Resources/deployments/{deploymentName}"} # type: ignore @distributed_trace - def begin_delete( # pylint: disable=inconsistent-return-statements - self, - resource_group_name: str, - deployment_name: str, - **kwargs: Any - ) -> LROPoller[None]: + def begin_delete(self, resource_group_name: str, deployment_name: str, **kwargs: Any) -> LROPoller[None]: """Deletes a deployment from the deployment history. A template deployment that is currently running cannot be deleted. Deleting a template @@ -1578,9 +1350,9 @@ def begin_delete( # pylint: disable=inconsistent-return-statements asynchronous request failed, the URI in the Location header returns an error-level status code. :param resource_group_name: The name of the resource group with the deployment to delete. The - name is case insensitive. + name is case insensitive. Required. :type resource_group_name: str - :param deployment_name: The name of the deployment to delete. + :param deployment_name: The name of the deployment to delete. Required. :type deployment_name: str :keyword callable cls: A custom type or function that will be passed the direct response :keyword str continuation_token: A continuation token to restart a poller from a saved state. @@ -1592,88 +1364,93 @@ def begin_delete( # pylint: disable=inconsistent-return-statements Retry-After header is present. :return: An instance of LROPoller that returns either None or the result of cls(response) :rtype: ~azure.core.polling.LROPoller[None] - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - api_version = kwargs.pop('api_version', "2016-09-01") # type: str - polling = kwargs.pop('polling', True) # type: Union[bool, PollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType[None] - lro_delay = kwargs.pop( - 'polling_interval', - self._config.polling_interval - ) - cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2016-09-01")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[None] + polling = kwargs.pop("polling", True) # type: Union[bool, PollingMethod] + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token = kwargs.pop("continuation_token", None) # type: Optional[str] if cont_token is None: - raw_result = self._delete_initial( + raw_result = self._delete_initial( # type: ignore resource_group_name=resource_group_name, deployment_name=deployment_name, api_version=api_version, - cls=lambda x,y,z: x, + cls=lambda x, y, z: x, + headers=_headers, + params=_params, **kwargs ) - kwargs.pop('error_map', None) + kwargs.pop("error_map", None) - def get_long_running_output(pipeline_response): + def get_long_running_output(pipeline_response): # pylint: disable=inconsistent-return-statements if cls: return cls(pipeline_response, None, {}) - - if polling is True: polling_method = ARMPolling(lro_delay, **kwargs) - elif polling is False: polling_method = NoPolling() - else: polling_method = polling + if polling is True: + polling_method = cast(PollingMethod, ARMPolling(lro_delay, **kwargs)) # type: PollingMethod + elif polling is False: + polling_method = cast(PollingMethod, NoPolling()) + else: + polling_method = polling if cont_token: return LROPoller.from_continuation_token( polling_method=polling_method, continuation_token=cont_token, client=self._client, - deserialization_callback=get_long_running_output + deserialization_callback=get_long_running_output, ) return LROPoller(self._client, raw_result, get_long_running_output, polling_method) - begin_delete.metadata = {'url': "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/Microsoft.Resources/deployments/{deploymentName}"} # type: ignore + begin_delete.metadata = {"url": "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/Microsoft.Resources/deployments/{deploymentName}"} # type: ignore @distributed_trace - def check_existence( - self, - resource_group_name: str, - deployment_name: str, - **kwargs: Any - ) -> bool: + def check_existence(self, resource_group_name: str, deployment_name: str, **kwargs: Any) -> bool: """Checks whether the deployment exists. :param resource_group_name: The name of the resource group with the deployment to check. The - name is case insensitive. + name is case insensitive. Required. :type resource_group_name: str - :param deployment_name: The name of the deployment to check. + :param deployment_name: The name of the deployment to check. Required. :type deployment_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: bool, or the result of cls(response) + :return: bool or the result of cls(response) :rtype: bool - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType[None] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) - api_version = kwargs.pop('api_version', "2016-09-01") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2016-09-01")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[None] - request = build_deployments_check_existence_request( resource_group_name=resource_group_name, deployment_name=deployment_name, subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.check_existence.metadata['url'], + template_url=self.check_existence.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [204, 404]: @@ -1684,44 +1461,53 @@ def check_existence( return cls(pipeline_response, None, {}) return 200 <= response.status_code <= 299 - check_existence.metadata = {'url': "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/Microsoft.Resources/deployments/{deploymentName}"} # type: ignore - + check_existence.metadata = {"url": "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/Microsoft.Resources/deployments/{deploymentName}"} # type: ignore def _create_or_update_initial( - self, - resource_group_name: str, - deployment_name: str, - parameters: "_models.Deployment", - **kwargs: Any - ) -> "_models.DeploymentExtended": - cls = kwargs.pop('cls', None) # type: ClsType["_models.DeploymentExtended"] + self, resource_group_name: str, deployment_name: str, parameters: Union[_models.Deployment, IO], **kwargs: Any + ) -> _models.DeploymentExtended: error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', "2016-09-01") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + api_version = kwargs.pop("api_version", _params.pop("api-version", "2016-09-01")) # type: str + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.DeploymentExtended] - _json = self._serialize.body(parameters, 'Deployment') + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(parameters, (IO, bytes)): + _content = parameters + else: + _json = self._serialize.body(parameters, "Deployment") - request = build_deployments_create_or_update_request_initial( + request = build_deployments_create_or_update_request( resource_group_name=resource_group_name, deployment_name=deployment_name, subscription_id=self._config.subscription_id, api_version=api_version, content_type=content_type, json=_json, - template_url=self._create_or_update_initial.metadata['url'], + content=_content, + template_url=self._create_or_update_initial.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200, 201]: @@ -1729,38 +1515,42 @@ def _create_or_update_initial( raise HttpResponseError(response=response, error_format=ARMErrorFormat) if response.status_code == 200: - deserialized = self._deserialize('DeploymentExtended', pipeline_response) + deserialized = self._deserialize("DeploymentExtended", pipeline_response) if response.status_code == 201: - deserialized = self._deserialize('DeploymentExtended', pipeline_response) + deserialized = self._deserialize("DeploymentExtended", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - _create_or_update_initial.metadata = {'url': "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/Microsoft.Resources/deployments/{deploymentName}"} # type: ignore - + _create_or_update_initial.metadata = {"url": "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/Microsoft.Resources/deployments/{deploymentName}"} # type: ignore - @distributed_trace + @overload def begin_create_or_update( self, resource_group_name: str, deployment_name: str, - parameters: "_models.Deployment", + parameters: _models.Deployment, + *, + content_type: str = "application/json", **kwargs: Any - ) -> LROPoller["_models.DeploymentExtended"]: + ) -> LROPoller[_models.DeploymentExtended]: """Deploys resources to a resource group. You can provide the template and parameters directly in the request or link to JSON files. :param resource_group_name: The name of the resource group to deploy the resources to. The name - is case insensitive. The resource group must already exist. + is case insensitive. The resource group must already exist. Required. :type resource_group_name: str - :param deployment_name: The name of the deployment. + :param deployment_name: The name of the deployment. Required. :type deployment_name: str - :param parameters: Additional parameters supplied to the operation. + :param parameters: Additional parameters supplied to the operation. Required. :type parameters: ~azure.mgmt.resource.resources.v2016_09_01.models.Deployment + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str :keyword callable cls: A custom type or function that will be passed the direct response :keyword str continuation_token: A continuation token to restart a poller from a saved state. :keyword polling: By default, your polling method will be ARMPolling. Pass in False for this @@ -1773,115 +1563,189 @@ def begin_create_or_update( cls(response) :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.resource.resources.v2016_09_01.models.DeploymentExtended] - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - api_version = kwargs.pop('api_version', "2016-09-01") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] - polling = kwargs.pop('polling', True) # type: Union[bool, PollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType["_models.DeploymentExtended"] - lro_delay = kwargs.pop( - 'polling_interval', - self._config.polling_interval - ) - cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] + + @overload + def begin_create_or_update( + self, + resource_group_name: str, + deployment_name: str, + parameters: IO, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> LROPoller[_models.DeploymentExtended]: + """Deploys resources to a resource group. + + You can provide the template and parameters directly in the request or link to JSON files. + + :param resource_group_name: The name of the resource group to deploy the resources to. The name + is case insensitive. The resource group must already exist. Required. + :type resource_group_name: str + :param deployment_name: The name of the deployment. Required. + :type deployment_name: str + :param parameters: Additional parameters supplied to the operation. Required. + :type parameters: IO + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be ARMPolling. Pass in False for this + operation to not poll, or pass in your own initialized polling object for a personal polling + strategy. + :paramtype polling: bool or ~azure.core.polling.PollingMethod + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of LROPoller that returns either DeploymentExtended or the result of + cls(response) + :rtype: + ~azure.core.polling.LROPoller[~azure.mgmt.resource.resources.v2016_09_01.models.DeploymentExtended] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace + def begin_create_or_update( + self, resource_group_name: str, deployment_name: str, parameters: Union[_models.Deployment, IO], **kwargs: Any + ) -> LROPoller[_models.DeploymentExtended]: + """Deploys resources to a resource group. + + You can provide the template and parameters directly in the request or link to JSON files. + + :param resource_group_name: The name of the resource group to deploy the resources to. The name + is case insensitive. The resource group must already exist. Required. + :type resource_group_name: str + :param deployment_name: The name of the deployment. Required. + :type deployment_name: str + :param parameters: Additional parameters supplied to the operation. Is either a model type or a + IO type. Required. + :type parameters: ~azure.mgmt.resource.resources.v2016_09_01.models.Deployment or IO + :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. + Default value is None. + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be ARMPolling. Pass in False for this + operation to not poll, or pass in your own initialized polling object for a personal polling + strategy. + :paramtype polling: bool or ~azure.core.polling.PollingMethod + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of LROPoller that returns either DeploymentExtended or the result of + cls(response) + :rtype: + ~azure.core.polling.LROPoller[~azure.mgmt.resource.resources.v2016_09_01.models.DeploymentExtended] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _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", "2016-09-01")) # type: str + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.DeploymentExtended] + polling = kwargs.pop("polling", True) # type: Union[bool, PollingMethod] + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token = kwargs.pop("continuation_token", None) # type: Optional[str] if cont_token is None: - raw_result = self._create_or_update_initial( + raw_result = self._create_or_update_initial( # type: ignore resource_group_name=resource_group_name, deployment_name=deployment_name, parameters=parameters, api_version=api_version, content_type=content_type, - cls=lambda x,y,z: x, + cls=lambda x, y, z: x, + headers=_headers, + params=_params, **kwargs ) - kwargs.pop('error_map', None) + kwargs.pop("error_map", None) def get_long_running_output(pipeline_response): - response = pipeline_response.http_response - deserialized = self._deserialize('DeploymentExtended', pipeline_response) + deserialized = self._deserialize("DeploymentExtended", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - - if polling is True: polling_method = ARMPolling(lro_delay, **kwargs) - elif polling is False: polling_method = NoPolling() - else: polling_method = polling + if polling is True: + polling_method = cast(PollingMethod, ARMPolling(lro_delay, **kwargs)) # type: PollingMethod + elif polling is False: + polling_method = cast(PollingMethod, NoPolling()) + else: + polling_method = polling if cont_token: return LROPoller.from_continuation_token( polling_method=polling_method, continuation_token=cont_token, client=self._client, - deserialization_callback=get_long_running_output + deserialization_callback=get_long_running_output, ) return LROPoller(self._client, raw_result, get_long_running_output, polling_method) - begin_create_or_update.metadata = {'url': "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/Microsoft.Resources/deployments/{deploymentName}"} # type: ignore + begin_create_or_update.metadata = {"url": "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/Microsoft.Resources/deployments/{deploymentName}"} # type: ignore @distributed_trace - def get( - self, - resource_group_name: str, - deployment_name: str, - **kwargs: Any - ) -> "_models.DeploymentExtended": + def get(self, resource_group_name: str, deployment_name: str, **kwargs: Any) -> _models.DeploymentExtended: """Gets a deployment. :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. :type resource_group_name: str - :param deployment_name: The name of the deployment to get. + :param deployment_name: The name of the deployment to get. Required. :type deployment_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: DeploymentExtended, or the result of cls(response) + :return: DeploymentExtended or the result of cls(response) :rtype: ~azure.mgmt.resource.resources.v2016_09_01.models.DeploymentExtended - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.DeploymentExtended"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + 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', "2016-09-01") # type: str + api_version = kwargs.pop("api_version", _params.pop("api-version", "2016-09-01")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[_models.DeploymentExtended] - request = build_deployments_get_request( resource_group_name=resource_group_name, deployment_name=deployment_name, subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.get.metadata['url'], + template_url=self.get.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) - deserialized = self._deserialize('DeploymentExtended', pipeline_response) + deserialized = self._deserialize("DeploymentExtended", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - get.metadata = {'url': "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/Microsoft.Resources/deployments/{deploymentName}"} # type: ignore - + get.metadata = {"url": "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/Microsoft.Resources/deployments/{deploymentName}"} # type: ignore @distributed_trace def cancel( # pylint: disable=inconsistent-return-statements - self, - resource_group_name: str, - deployment_name: str, - **kwargs: Any + self, resource_group_name: str, deployment_name: str, **kwargs: Any ) -> None: """Cancels a currently running template deployment. @@ -1891,38 +1755,45 @@ def cancel( # pylint: disable=inconsistent-return-statements partially deployed. :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. :type resource_group_name: str - :param deployment_name: The name of the deployment to cancel. + :param deployment_name: The name of the deployment to cancel. Required. :type deployment_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: None, or the result of cls(response) + :return: None or the result of cls(response) :rtype: None - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType[None] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) - api_version = kwargs.pop('api_version', "2016-09-01") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2016-09-01")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[None] - request = build_deployments_cancel_request( resource_group_name=resource_group_name, deployment_name=deployment_name, subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.cancel.metadata['url'], + template_url=self.cancel.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [204]: @@ -1932,42 +1803,110 @@ def cancel( # pylint: disable=inconsistent-return-statements if cls: return cls(pipeline_response, None, {}) - cancel.metadata = {'url': "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/Microsoft.Resources/deployments/{deploymentName}/cancel"} # type: ignore + cancel.metadata = {"url": "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/Microsoft.Resources/deployments/{deploymentName}/cancel"} # type: ignore - - @distributed_trace + @overload def validate( self, resource_group_name: str, deployment_name: str, - parameters: "_models.Deployment", + parameters: _models.Deployment, + *, + content_type: str = "application/json", **kwargs: Any - ) -> "_models.DeploymentValidateResult": + ) -> _models.DeploymentValidateResult: """Validates whether the specified template is syntactically correct and will be accepted by Azure Resource Manager.. :param resource_group_name: The name of the resource group the template will be deployed to. - The name is case insensitive. + The name is case insensitive. Required. :type resource_group_name: str - :param deployment_name: The name of the deployment. + :param deployment_name: The name of the deployment. Required. :type deployment_name: str - :param parameters: Parameters to validate. + :param parameters: Parameters to validate. Required. :type parameters: ~azure.mgmt.resource.resources.v2016_09_01.models.Deployment + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: DeploymentValidateResult or the result of cls(response) + :rtype: ~azure.mgmt.resource.resources.v2016_09_01.models.DeploymentValidateResult + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + def validate( + self, + resource_group_name: str, + deployment_name: str, + parameters: IO, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.DeploymentValidateResult: + """Validates whether the specified template is syntactically correct and will be accepted by Azure + Resource Manager.. + + :param resource_group_name: The name of the resource group the template will be deployed to. + The name is case insensitive. Required. + :type resource_group_name: str + :param deployment_name: The name of the deployment. Required. + :type deployment_name: str + :param parameters: Parameters to validate. Required. + :type parameters: IO + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: DeploymentValidateResult or the result of cls(response) + :rtype: ~azure.mgmt.resource.resources.v2016_09_01.models.DeploymentValidateResult + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace + def validate( + self, resource_group_name: str, deployment_name: str, parameters: Union[_models.Deployment, IO], **kwargs: Any + ) -> _models.DeploymentValidateResult: + """Validates whether the specified template is syntactically correct and will be accepted by Azure + Resource Manager.. + + :param resource_group_name: The name of the resource group the template will be deployed to. + The name is case insensitive. Required. + :type resource_group_name: str + :param deployment_name: The name of the deployment. Required. + :type deployment_name: str + :param parameters: Parameters to validate. Is either a model type or a IO type. Required. + :type parameters: ~azure.mgmt.resource.resources.v2016_09_01.models.Deployment or IO + :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. + Default value is None. + :paramtype content_type: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: DeploymentValidateResult, or the result of cls(response) + :return: DeploymentValidateResult or the result of cls(response) :rtype: ~azure.mgmt.resource.resources.v2016_09_01.models.DeploymentValidateResult - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.DeploymentValidateResult"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) - api_version = kwargs.pop('api_version', "2016-09-01") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - _json = self._serialize.body(parameters, 'Deployment') + api_version = kwargs.pop("api_version", _params.pop("api-version", "2016-09-01")) # type: str + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.DeploymentValidateResult] + + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(parameters, (IO, bytes)): + _content = parameters + else: + _json = self._serialize.body(parameters, "Deployment") request = build_deployments_validate_request( resource_group_name=resource_group_name, @@ -1976,16 +1915,18 @@ def validate( api_version=api_version, content_type=content_type, json=_json, - template_url=self.validate.metadata['url'], + content=_content, + template_url=self.validate.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200, 400]: @@ -1993,89 +1934,87 @@ def validate( raise HttpResponseError(response=response, error_format=ARMErrorFormat) if response.status_code == 200: - deserialized = self._deserialize('DeploymentValidateResult', pipeline_response) + deserialized = self._deserialize("DeploymentValidateResult", pipeline_response) if response.status_code == 400: - deserialized = self._deserialize('DeploymentValidateResult', pipeline_response) + deserialized = self._deserialize("DeploymentValidateResult", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - validate.metadata = {'url': "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/Microsoft.Resources/deployments/{deploymentName}/validate"} # type: ignore - + validate.metadata = {"url": "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/Microsoft.Resources/deployments/{deploymentName}/validate"} # type: ignore @distributed_trace def export_template( - self, - resource_group_name: str, - deployment_name: str, - **kwargs: Any - ) -> "_models.DeploymentExportResult": + self, resource_group_name: str, deployment_name: str, **kwargs: Any + ) -> _models.DeploymentExportResult: """Exports the template used for specified deployment. :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. :type resource_group_name: str - :param deployment_name: The name of the deployment from which to get the template. + :param deployment_name: The name of the deployment from which to get the template. Required. :type deployment_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: DeploymentExportResult, or the result of cls(response) + :return: DeploymentExportResult or the result of cls(response) :rtype: ~azure.mgmt.resource.resources.v2016_09_01.models.DeploymentExportResult - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.DeploymentExportResult"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + 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', "2016-09-01") # type: str + api_version = kwargs.pop("api_version", _params.pop("api-version", "2016-09-01")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[_models.DeploymentExportResult] - request = build_deployments_export_template_request( resource_group_name=resource_group_name, deployment_name=deployment_name, subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.export_template.metadata['url'], + template_url=self.export_template.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) - deserialized = self._deserialize('DeploymentExportResult', pipeline_response) + deserialized = self._deserialize("DeploymentExportResult", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - export_template.metadata = {'url': "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/Microsoft.Resources/deployments/{deploymentName}/exportTemplate"} # type: ignore - + export_template.metadata = {"url": "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/Microsoft.Resources/deployments/{deploymentName}/exportTemplate"} # type: ignore @distributed_trace def list( - self, - resource_group_name: str, - filter: Optional[str] = None, - top: Optional[int] = None, - **kwargs: Any - ) -> Iterable["_models.DeploymentListResult"]: + self, resource_group_name: str, filter: Optional[str] = None, top: Optional[int] = None, **kwargs: Any + ) -> Iterable["_models.DeploymentExtended"]: """Get all the deployments for a resource group. :param resource_group_name: The name of the resource group with the deployments to get. The - name is case insensitive. + name is case insensitive. Required. :type resource_group_name: str :param filter: The filter to apply on the operation. For example, you can use $filter=provisioningState eq '{state}'. Default value is None. @@ -2084,42 +2023,49 @@ def list( value is None. :type top: int :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either DeploymentListResult or the result of - cls(response) + :return: An iterator like instance of either DeploymentExtended or the result of cls(response) :rtype: - ~azure.core.paging.ItemPaged[~azure.mgmt.resource.resources.v2016_09_01.models.DeploymentListResult] - :raises: ~azure.core.exceptions.HttpResponseError + ~azure.core.paging.ItemPaged[~azure.mgmt.resource.resources.v2016_09_01.models.DeploymentExtended] + :raises ~azure.core.exceptions.HttpResponseError: """ - api_version = kwargs.pop('api_version', "2016-09-01") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2016-09-01")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[_models.DeploymentListResult] - cls = kwargs.pop('cls', None) # type: ClsType["_models.DeploymentListResult"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) + def prepare_request(next_link=None): if not next_link: - + request = build_deployments_list_request( resource_group_name=resource_group_name, subscription_id=self._config.subscription_id, - api_version=api_version, filter=filter, top=top, - template_url=self.list.metadata['url'], + 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.url = self._client.format_url(request.url) # type: ignore else: - - request = build_deployments_list_request( - resource_group_name=resource_group_name, - subscription_id=self._config.subscription_id, - template_url=next_link, - ) + # make call to next link with the client's api-version + _parsed_next_link = urlparse(next_link) + _next_request_params = case_insensitive_dict(parse_qs(_parsed_next_link.query)) + _next_request_params["api-version"] = self._config.api_version + request = HttpRequest("GET", urljoin(next_link, _parsed_next_link.path), params=_next_request_params) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore request.method = "GET" return request @@ -2133,10 +2079,8 @@ def extract_data(pipeline_response): def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) response = pipeline_response.http_response @@ -2146,204 +2090,204 @@ def get_next(next_link=None): return pipeline_response + return ItemPaged(get_next, extract_data) - return ItemPaged( - get_next, extract_data - ) - list.metadata = {'url': "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/Microsoft.Resources/deployments/"} # type: ignore + list.metadata = {"url": "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/Microsoft.Resources/deployments/"} # type: ignore @distributed_trace - def calculate_template_hash( - self, - template: Any, - **kwargs: Any - ) -> "_models.TemplateHashResult": + def calculate_template_hash(self, template: JSON, **kwargs: Any) -> _models.TemplateHashResult: """Calculate the hash of the given template. - :param template: The template provided to calculate hash. - :type template: any + :param template: The template provided to calculate hash. Required. + :type template: JSON :keyword callable cls: A custom type or function that will be passed the direct response - :return: TemplateHashResult, or the result of cls(response) + :return: TemplateHashResult or the result of cls(response) :rtype: ~azure.mgmt.resource.resources.v2016_09_01.models.TemplateHashResult - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.TemplateHashResult"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', "2016-09-01") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + api_version = kwargs.pop("api_version", _params.pop("api-version", "2016-09-01")) # type: str + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", "application/json")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[_models.TemplateHashResult] - _json = self._serialize.body(template, 'object') + _json = self._serialize.body(template, "object") request = build_deployments_calculate_template_hash_request( api_version=api_version, content_type=content_type, json=_json, - template_url=self.calculate_template_hash.metadata['url'], + template_url=self.calculate_template_hash.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) - deserialized = self._deserialize('TemplateHashResult', pipeline_response) + deserialized = self._deserialize("TemplateHashResult", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - calculate_template_hash.metadata = {'url': "/providers/Microsoft.Resources/calculateTemplateHash"} # type: ignore + calculate_template_hash.metadata = {"url": "/providers/Microsoft.Resources/calculateTemplateHash"} # type: ignore -class ProvidersOperations(object): - """ProvidersOperations operations. - You should not instantiate this class directly. Instead, you should create a Client instance that - instantiates it for you and attaches it as an attribute. +class ProvidersOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. - :ivar models: Alias to model classes used in this operation group. - :type models: ~azure.mgmt.resource.resources.v2016_09_01.models - :param client: Client for service requests. - :param config: Configuration of service client. - :param serializer: An object model serializer. - :param deserializer: An object model deserializer. + Instead, you should access the following operations through + :class:`~azure.mgmt.resource.resources.v2016_09_01.ResourceManagementClient`'s + :attr:`providers` attribute. """ models = _models - def __init__(self, client, config, serializer, deserializer): - self._client = client - self._serialize = serializer - self._deserialize = deserializer - self._config = config + def __init__(self, *args, **kwargs): + input_args = list(args) + self._client = input_args.pop(0) if input_args else kwargs.pop("client") + self._config = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") @distributed_trace - def unregister( - self, - resource_provider_namespace: str, - **kwargs: Any - ) -> "_models.Provider": + def unregister(self, resource_provider_namespace: str, **kwargs: Any) -> _models.Provider: """Unregisters a subscription from a resource provider. :param resource_provider_namespace: The namespace of the resource provider to unregister. + Required. :type resource_provider_namespace: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: Provider, or the result of cls(response) + :return: Provider or the result of cls(response) :rtype: ~azure.mgmt.resource.resources.v2016_09_01.models.Provider - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.Provider"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + 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', "2016-09-01") # type: str + api_version = kwargs.pop("api_version", _params.pop("api-version", "2016-09-01")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[_models.Provider] - request = build_providers_unregister_request( resource_provider_namespace=resource_provider_namespace, subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.unregister.metadata['url'], + template_url=self.unregister.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) - deserialized = self._deserialize('Provider', pipeline_response) + deserialized = self._deserialize("Provider", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - unregister.metadata = {'url': "/subscriptions/{subscriptionId}/providers/{resourceProviderNamespace}/unregister"} # type: ignore - + unregister.metadata = {"url": "/subscriptions/{subscriptionId}/providers/{resourceProviderNamespace}/unregister"} # type: ignore @distributed_trace - def register( - self, - resource_provider_namespace: str, - **kwargs: Any - ) -> "_models.Provider": + def register(self, resource_provider_namespace: str, **kwargs: Any) -> _models.Provider: """Registers a subscription with a resource provider. :param resource_provider_namespace: The namespace of the resource provider to register. + Required. :type resource_provider_namespace: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: Provider, or the result of cls(response) + :return: Provider or the result of cls(response) :rtype: ~azure.mgmt.resource.resources.v2016_09_01.models.Provider - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.Provider"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + 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', "2016-09-01") # type: str + api_version = kwargs.pop("api_version", _params.pop("api-version", "2016-09-01")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[_models.Provider] - request = build_providers_register_request( resource_provider_namespace=resource_provider_namespace, subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.register.metadata['url'], + template_url=self.register.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) - deserialized = self._deserialize('Provider', pipeline_response) + deserialized = self._deserialize("Provider", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - register.metadata = {'url': "/subscriptions/{subscriptionId}/providers/{resourceProviderNamespace}/register"} # type: ignore - + register.metadata = {"url": "/subscriptions/{subscriptionId}/providers/{resourceProviderNamespace}/register"} # type: ignore @distributed_trace def list( - self, - top: Optional[int] = None, - expand: Optional[str] = None, - **kwargs: Any - ) -> Iterable["_models.ProviderListResult"]: + self, top: Optional[int] = None, expand: Optional[str] = None, **kwargs: Any + ) -> Iterable["_models.Provider"]: """Gets all resource providers for a subscription. :param top: The number of results to return. If null is passed returns all deployments. Default @@ -2354,39 +2298,48 @@ def list( response, use $expand=resourceTypes/aliases. Default value is None. :type expand: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either ProviderListResult or the result of cls(response) + :return: An iterator like instance of either Provider or the result of cls(response) :rtype: - ~azure.core.paging.ItemPaged[~azure.mgmt.resource.resources.v2016_09_01.models.ProviderListResult] - :raises: ~azure.core.exceptions.HttpResponseError + ~azure.core.paging.ItemPaged[~azure.mgmt.resource.resources.v2016_09_01.models.Provider] + :raises ~azure.core.exceptions.HttpResponseError: """ - api_version = kwargs.pop('api_version', "2016-09-01") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2016-09-01")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[_models.ProviderListResult] - cls = kwargs.pop('cls', None) # type: ClsType["_models.ProviderListResult"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) + def prepare_request(next_link=None): if not next_link: - + request = build_providers_list_request( subscription_id=self._config.subscription_id, - api_version=api_version, top=top, expand=expand, - template_url=self.list.metadata['url'], + 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.url = self._client.format_url(request.url) # type: ignore else: - - request = build_providers_list_request( - subscription_id=self._config.subscription_id, - template_url=next_link, - ) + # make call to next link with the client's api-version + _parsed_next_link = urlparse(next_link) + _next_request_params = case_insensitive_dict(parse_qs(_parsed_next_link.query)) + _next_request_params["api-version"] = self._config.api_version + request = HttpRequest("GET", urljoin(next_link, _parsed_next_link.path), params=_next_request_params) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore request.method = "GET" return request @@ -2400,10 +2353,8 @@ def extract_data(pipeline_response): def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) response = pipeline_response.http_response @@ -2413,91 +2364,88 @@ def get_next(next_link=None): return pipeline_response + return ItemPaged(get_next, extract_data) - return ItemPaged( - get_next, extract_data - ) - list.metadata = {'url': "/subscriptions/{subscriptionId}/providers"} # type: ignore + list.metadata = {"url": "/subscriptions/{subscriptionId}/providers"} # type: ignore @distributed_trace - def get( - self, - resource_provider_namespace: str, - expand: Optional[str] = None, - **kwargs: Any - ) -> "_models.Provider": + def get(self, resource_provider_namespace: str, expand: Optional[str] = None, **kwargs: Any) -> _models.Provider: """Gets the specified resource provider. - :param resource_provider_namespace: The namespace of the resource provider. + :param resource_provider_namespace: The namespace of the resource provider. Required. :type resource_provider_namespace: str :param expand: The $expand query parameter. For example, to include property aliases in response, use $expand=resourceTypes/aliases. Default value is None. :type expand: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: Provider, or the result of cls(response) + :return: Provider or the result of cls(response) :rtype: ~azure.mgmt.resource.resources.v2016_09_01.models.Provider - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.Provider"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + 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', "2016-09-01") # type: str + api_version = kwargs.pop("api_version", _params.pop("api-version", "2016-09-01")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[_models.Provider] - request = build_providers_get_request( resource_provider_namespace=resource_provider_namespace, subscription_id=self._config.subscription_id, - api_version=api_version, expand=expand, - template_url=self.get.metadata['url'], + api_version=api_version, + template_url=self.get.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) - deserialized = self._deserialize('Provider', pipeline_response) + deserialized = self._deserialize("Provider", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - get.metadata = {'url': "/subscriptions/{subscriptionId}/providers/{resourceProviderNamespace}"} # type: ignore + get.metadata = {"url": "/subscriptions/{subscriptionId}/providers/{resourceProviderNamespace}"} # type: ignore -class ResourceGroupsOperations(object): - """ResourceGroupsOperations operations. - You should not instantiate this class directly. Instead, you should create a Client instance that - instantiates it for you and attaches it as an attribute. +class ResourceGroupsOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. - :ivar models: Alias to model classes used in this operation group. - :type models: ~azure.mgmt.resource.resources.v2016_09_01.models - :param client: Client for service requests. - :param config: Configuration of service client. - :param serializer: An object model serializer. - :param deserializer: An object model deserializer. + Instead, you should access the following operations through + :class:`~azure.mgmt.resource.resources.v2016_09_01.ResourceManagementClient`'s + :attr:`resource_groups` attribute. """ models = _models - def __init__(self, client, config, serializer, deserializer): - self._client = client - self._serialize = serializer - self._deserialize = deserializer - self._config = config + def __init__(self, *args, **kwargs): + input_args = list(args) + self._client = input_args.pop(0) if input_args else kwargs.pop("client") + self._config = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") @distributed_trace def list_resources( @@ -2507,10 +2455,10 @@ def list_resources( expand: Optional[str] = None, top: Optional[int] = None, **kwargs: Any - ) -> Iterable["_models.ResourceListResult"]: + ) -> Iterable["_models.GenericResourceExpanded"]: """Get all the resources for a resource group. - :param resource_group_name: The resource group with the resources to get. + :param resource_group_name: The resource group with the resources to get. Required. :type resource_group_name: str :param filter: The filter to apply on the operation. Default value is None. :type filter: str @@ -2522,42 +2470,51 @@ def list_resources( value is None. :type top: int :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either ResourceListResult or the result of cls(response) + :return: An iterator like instance of either GenericResourceExpanded or the result of + cls(response) :rtype: - ~azure.core.paging.ItemPaged[~azure.mgmt.resource.resources.v2016_09_01.models.ResourceListResult] - :raises: ~azure.core.exceptions.HttpResponseError + ~azure.core.paging.ItemPaged[~azure.mgmt.resource.resources.v2016_09_01.models.GenericResourceExpanded] + :raises ~azure.core.exceptions.HttpResponseError: """ - api_version = kwargs.pop('api_version', "2016-09-01") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2016-09-01")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[_models.ResourceListResult] - cls = kwargs.pop('cls', None) # type: ClsType["_models.ResourceListResult"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) + def prepare_request(next_link=None): if not next_link: - + request = build_resource_groups_list_resources_request( resource_group_name=resource_group_name, subscription_id=self._config.subscription_id, - api_version=api_version, filter=filter, expand=expand, top=top, - template_url=self.list_resources.metadata['url'], + api_version=api_version, + template_url=self.list_resources.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore else: - - request = build_resource_groups_list_resources_request( - resource_group_name=resource_group_name, - subscription_id=self._config.subscription_id, - template_url=next_link, - ) + # make call to next link with the client's api-version + _parsed_next_link = urlparse(next_link) + _next_request_params = case_insensitive_dict(parse_qs(_parsed_next_link.query)) + _next_request_params["api-version"] = self._config.api_version + request = HttpRequest("GET", urljoin(next_link, _parsed_next_link.path), params=_next_request_params) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore request.method = "GET" return request @@ -2571,10 +2528,8 @@ def extract_data(pipeline_response): def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) response = pipeline_response.http_response @@ -2584,51 +2539,51 @@ def get_next(next_link=None): return pipeline_response + return ItemPaged(get_next, extract_data) - return ItemPaged( - get_next, extract_data - ) - list_resources.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/resources"} # type: ignore + list_resources.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/resources"} # type: ignore @distributed_trace - def check_existence( - self, - resource_group_name: str, - **kwargs: Any - ) -> bool: + def check_existence(self, resource_group_name: str, **kwargs: Any) -> bool: """Checks whether a resource group exists. :param resource_group_name: The name of the resource group to check. The name is case - insensitive. + insensitive. Required. :type resource_group_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: bool, or the result of cls(response) + :return: bool or the result of cls(response) :rtype: bool - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType[None] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + 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', "2016-09-01") # type: str + api_version = kwargs.pop("api_version", _params.pop("api-version", "2016-09-01")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[None] - request = build_resource_groups_check_existence_request( resource_group_name=resource_group_name, subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.check_existence.metadata['url'], + template_url=self.check_existence.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [204, 404]: @@ -2639,37 +2594,92 @@ def check_existence( return cls(pipeline_response, None, {}) return 200 <= response.status_code <= 299 - check_existence.metadata = {'url': "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}"} # type: ignore - + check_existence.metadata = {"url": "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}"} # type: ignore - @distributed_trace + @overload def create_or_update( self, resource_group_name: str, - parameters: "_models.ResourceGroup", + parameters: _models.ResourceGroup, + *, + content_type: str = "application/json", **kwargs: Any - ) -> "_models.ResourceGroup": + ) -> _models.ResourceGroup: """Creates a resource group. - :param resource_group_name: The name of the resource group to create or update. + :param resource_group_name: The name of the resource group to create or update. Required. :type resource_group_name: str - :param parameters: Parameters supplied to the create or update a resource group. + :param parameters: Parameters supplied to the create or update a resource group. Required. :type parameters: ~azure.mgmt.resource.resources.v2016_09_01.models.ResourceGroup + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: ResourceGroup or the result of cls(response) + :rtype: ~azure.mgmt.resource.resources.v2016_09_01.models.ResourceGroup + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + def create_or_update( + self, resource_group_name: str, parameters: IO, *, content_type: str = "application/json", **kwargs: Any + ) -> _models.ResourceGroup: + """Creates a resource group. + + :param resource_group_name: The name of the resource group to create or update. Required. + :type resource_group_name: str + :param parameters: Parameters supplied to the create or update a resource group. Required. + :type parameters: IO + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: ResourceGroup or the result of cls(response) + :rtype: ~azure.mgmt.resource.resources.v2016_09_01.models.ResourceGroup + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace + def create_or_update( + self, resource_group_name: str, parameters: Union[_models.ResourceGroup, IO], **kwargs: Any + ) -> _models.ResourceGroup: + """Creates a resource group. + + :param resource_group_name: The name of the resource group to create or update. Required. + :type resource_group_name: str + :param parameters: Parameters supplied to the create or update a resource group. Is either a + model type or a IO type. Required. + :type parameters: ~azure.mgmt.resource.resources.v2016_09_01.models.ResourceGroup or IO + :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. + Default value is None. + :paramtype content_type: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: ResourceGroup, or the result of cls(response) + :return: ResourceGroup or the result of cls(response) :rtype: ~azure.mgmt.resource.resources.v2016_09_01.models.ResourceGroup - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.ResourceGroup"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', "2016-09-01") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + api_version = kwargs.pop("api_version", _params.pop("api-version", "2016-09-01")) # type: str + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.ResourceGroup] - _json = self._serialize.body(parameters, 'ResourceGroup') + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(parameters, (IO, bytes)): + _content = parameters + else: + _json = self._serialize.body(parameters, "ResourceGroup") request = build_resource_groups_create_or_update_request( resource_group_name=resource_group_name, @@ -2677,16 +2687,18 @@ def create_or_update( api_version=api_version, content_type=content_type, json=_json, - template_url=self.create_or_update.metadata['url'], + content=_content, + template_url=self.create_or_update.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200, 201]: @@ -2694,47 +2706,50 @@ def create_or_update( raise HttpResponseError(response=response, error_format=ARMErrorFormat) if response.status_code == 200: - deserialized = self._deserialize('ResourceGroup', pipeline_response) + deserialized = self._deserialize("ResourceGroup", pipeline_response) if response.status_code == 201: - deserialized = self._deserialize('ResourceGroup', pipeline_response) + deserialized = self._deserialize("ResourceGroup", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - create_or_update.metadata = {'url': "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}"} # type: ignore - + create_or_update.metadata = {"url": "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}"} # type: ignore def _delete_initial( # pylint: disable=inconsistent-return-statements - self, - resource_group_name: str, - **kwargs: Any + self, resource_group_name: str, **kwargs: Any ) -> None: - cls = kwargs.pop('cls', None) # type: ClsType[None] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + 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', "2016-09-01") # type: str + api_version = kwargs.pop("api_version", _params.pop("api-version", "2016-09-01")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[None] - - request = build_resource_groups_delete_request_initial( + request = build_resource_groups_delete_request( resource_group_name=resource_group_name, subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self._delete_initial.metadata['url'], + template_url=self._delete_initial.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200, 202]: @@ -2744,22 +2759,17 @@ def _delete_initial( # pylint: disable=inconsistent-return-statements if cls: return cls(pipeline_response, None, {}) - _delete_initial.metadata = {'url': "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}"} # type: ignore - + _delete_initial.metadata = {"url": "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}"} # type: ignore @distributed_trace - def begin_delete( # pylint: disable=inconsistent-return-statements - self, - resource_group_name: str, - **kwargs: Any - ) -> LROPoller[None]: + def begin_delete(self, resource_group_name: str, **kwargs: Any) -> LROPoller[None]: """Deletes a resource group. When you delete a resource group, all of its resources are also deleted. Deleting a resource group deletes all of its template deployments and currently stored operations. :param resource_group_name: The name of the resource group to delete. The name is case - insensitive. + insensitive. Required. :type resource_group_name: str :keyword callable cls: A custom type or function that will be passed the direct response :keyword str continuation_token: A continuation token to restart a poller from a saved state. @@ -2771,106 +2781,113 @@ def begin_delete( # pylint: disable=inconsistent-return-statements Retry-After header is present. :return: An instance of LROPoller that returns either None or the result of cls(response) :rtype: ~azure.core.polling.LROPoller[None] - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - api_version = kwargs.pop('api_version', "2016-09-01") # type: str - polling = kwargs.pop('polling', True) # type: Union[bool, PollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType[None] - lro_delay = kwargs.pop( - 'polling_interval', - self._config.polling_interval - ) - cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2016-09-01")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[None] + polling = kwargs.pop("polling", True) # type: Union[bool, PollingMethod] + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token = kwargs.pop("continuation_token", None) # type: Optional[str] if cont_token is None: - raw_result = self._delete_initial( + raw_result = self._delete_initial( # type: ignore resource_group_name=resource_group_name, api_version=api_version, - cls=lambda x,y,z: x, + cls=lambda x, y, z: x, + headers=_headers, + params=_params, **kwargs ) - kwargs.pop('error_map', None) + kwargs.pop("error_map", None) - def get_long_running_output(pipeline_response): + def get_long_running_output(pipeline_response): # pylint: disable=inconsistent-return-statements if cls: return cls(pipeline_response, None, {}) - - if polling is True: polling_method = ARMPolling(lro_delay, **kwargs) - elif polling is False: polling_method = NoPolling() - else: polling_method = polling + if polling is True: + polling_method = cast(PollingMethod, ARMPolling(lro_delay, **kwargs)) # type: PollingMethod + elif polling is False: + polling_method = cast(PollingMethod, NoPolling()) + else: + polling_method = polling if cont_token: return LROPoller.from_continuation_token( polling_method=polling_method, continuation_token=cont_token, client=self._client, - deserialization_callback=get_long_running_output + deserialization_callback=get_long_running_output, ) return LROPoller(self._client, raw_result, get_long_running_output, polling_method) - begin_delete.metadata = {'url': "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}"} # type: ignore + begin_delete.metadata = {"url": "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}"} # type: ignore @distributed_trace - def get( - self, - resource_group_name: str, - **kwargs: Any - ) -> "_models.ResourceGroup": + def get(self, resource_group_name: str, **kwargs: Any) -> _models.ResourceGroup: """Gets a resource group. :param resource_group_name: The name of the resource group to get. The name is case - insensitive. + insensitive. Required. :type resource_group_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: ResourceGroup, or the result of cls(response) + :return: ResourceGroup or the result of cls(response) :rtype: ~azure.mgmt.resource.resources.v2016_09_01.models.ResourceGroup - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.ResourceGroup"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + 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', "2016-09-01") # type: str + api_version = kwargs.pop("api_version", _params.pop("api-version", "2016-09-01")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[_models.ResourceGroup] - request = build_resource_groups_get_request( resource_group_name=resource_group_name, subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.get.metadata['url'], + template_url=self.get.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) - deserialized = self._deserialize('ResourceGroup', pipeline_response) + deserialized = self._deserialize("ResourceGroup", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - get.metadata = {'url': "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}"} # type: ignore - + get.metadata = {"url": "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}"} # type: ignore - @distributed_trace + @overload def patch( self, resource_group_name: str, - parameters: "_models.ResourceGroup", + parameters: _models.ResourceGroup, + *, + content_type: str = "application/json", **kwargs: Any - ) -> "_models.ResourceGroup": + ) -> _models.ResourceGroup: """Updates a resource group. Resource groups can be updated through a simple PATCH operation to a group address. The format @@ -2878,86 +2895,207 @@ def patch( the current value is retained. :param resource_group_name: The name of the resource group to update. The name is case - insensitive. + insensitive. Required. :type resource_group_name: str - :param parameters: Parameters supplied to update a resource group. + :param parameters: Parameters supplied to update a resource group. Required. :type parameters: ~azure.mgmt.resource.resources.v2016_09_01.models.ResourceGroup + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: ResourceGroup, or the result of cls(response) + :return: ResourceGroup or the result of cls(response) :rtype: ~azure.mgmt.resource.resources.v2016_09_01.models.ResourceGroup - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.ResourceGroup"] - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {})) - api_version = kwargs.pop('api_version', "2016-09-01") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + @overload + def patch( + self, resource_group_name: str, parameters: IO, *, content_type: str = "application/json", **kwargs: Any + ) -> _models.ResourceGroup: + """Updates a resource group. - _json = self._serialize.body(parameters, 'ResourceGroup') + Resource groups can be updated through a simple PATCH operation to a group address. The format + of the request is the same as that for creating a resource group. If a field is unspecified, + the current value is retained. - request = build_resource_groups_patch_request( - resource_group_name=resource_group_name, - subscription_id=self._config.subscription_id, - api_version=api_version, - content_type=content_type, - json=_json, - template_url=self.patch.metadata['url'], - ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) + :param resource_group_name: The name of the resource group to update. The name is case + insensitive. Required. + :type resource_group_name: str + :param parameters: Parameters supplied to update a resource group. Required. + :type parameters: IO + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: ResourceGroup or the result of cls(response) + :rtype: ~azure.mgmt.resource.resources.v2016_09_01.models.ResourceGroup + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace + def patch( + self, resource_group_name: str, parameters: Union[_models.ResourceGroup, IO], **kwargs: Any + ) -> _models.ResourceGroup: + """Updates a resource group. - pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + Resource groups can be updated through a simple PATCH operation to a group address. The format + of the request is the same as that for creating a resource group. If a field is unspecified, + the current value is retained. + + :param resource_group_name: The name of the resource group to update. The name is case + insensitive. Required. + :type resource_group_name: str + :param parameters: Parameters supplied to update a resource group. Is either a model type or a + IO type. Required. + :type parameters: ~azure.mgmt.resource.resources.v2016_09_01.models.ResourceGroup or IO + :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. + Default value is None. + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: ResourceGroup or the result of cls(response) + :rtype: ~azure.mgmt.resource.resources.v2016_09_01.models.ResourceGroup + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2016-09-01")) # type: str + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.ResourceGroup] + + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(parameters, (IO, bytes)): + _content = parameters + else: + _json = self._serialize.body(parameters, "ResourceGroup") + + request = build_resource_groups_patch_request( + resource_group_name=resource_group_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + content_type=content_type, + json=_json, + content=_content, + template_url=self.patch.metadata["url"], + headers=_headers, + params=_params, ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore + + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs + ) + response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) - deserialized = self._deserialize('ResourceGroup', pipeline_response) + deserialized = self._deserialize("ResourceGroup", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - patch.metadata = {'url': "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}"} # type: ignore + patch.metadata = {"url": "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}"} # type: ignore - - @distributed_trace + @overload def export_template( self, resource_group_name: str, - parameters: "_models.ExportTemplateRequest", + parameters: _models.ExportTemplateRequest, + *, + content_type: str = "application/json", **kwargs: Any - ) -> "_models.ResourceGroupExportResult": + ) -> _models.ResourceGroupExportResult: """Captures the specified resource group as a template. - :param resource_group_name: The name of the resource group to export as a template. + :param resource_group_name: The name of the resource group to export as a template. Required. :type resource_group_name: str - :param parameters: Parameters for exporting the template. + :param parameters: Parameters for exporting the template. Required. :type parameters: ~azure.mgmt.resource.resources.v2016_09_01.models.ExportTemplateRequest + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: ResourceGroupExportResult or the result of cls(response) + :rtype: ~azure.mgmt.resource.resources.v2016_09_01.models.ResourceGroupExportResult + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + def export_template( + self, resource_group_name: str, parameters: IO, *, content_type: str = "application/json", **kwargs: Any + ) -> _models.ResourceGroupExportResult: + """Captures the specified resource group as a template. + + :param resource_group_name: The name of the resource group to export as a template. Required. + :type resource_group_name: str + :param parameters: Parameters for exporting the template. Required. + :type parameters: IO + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: ResourceGroupExportResult, or the result of cls(response) + :return: ResourceGroupExportResult or the result of cls(response) :rtype: ~azure.mgmt.resource.resources.v2016_09_01.models.ResourceGroupExportResult - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace + def export_template( + self, resource_group_name: str, parameters: Union[_models.ExportTemplateRequest, IO], **kwargs: Any + ) -> _models.ResourceGroupExportResult: + """Captures the specified resource group as a template. + + :param resource_group_name: The name of the resource group to export as a template. Required. + :type resource_group_name: str + :param parameters: Parameters for exporting the template. Is either a model type or a IO type. + Required. + :type parameters: ~azure.mgmt.resource.resources.v2016_09_01.models.ExportTemplateRequest or IO + :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. + Default value is None. + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: ResourceGroupExportResult or the result of cls(response) + :rtype: ~azure.mgmt.resource.resources.v2016_09_01.models.ResourceGroupExportResult + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.ResourceGroupExportResult"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', "2016-09-01") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + api_version = kwargs.pop("api_version", _params.pop("api-version", "2016-09-01")) # type: str + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.ResourceGroupExportResult] - _json = self._serialize.body(parameters, 'ExportTemplateRequest') + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(parameters, (IO, bytes)): + _content = parameters + else: + _json = self._serialize.body(parameters, "ExportTemplateRequest") request = build_resource_groups_export_template_request( resource_group_name=resource_group_name, @@ -2965,39 +3103,37 @@ def export_template( api_version=api_version, content_type=content_type, json=_json, - template_url=self.export_template.metadata['url'], + content=_content, + template_url=self.export_template.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) - deserialized = self._deserialize('ResourceGroupExportResult', pipeline_response) + deserialized = self._deserialize("ResourceGroupExportResult", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - export_template.metadata = {'url': "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/exportTemplate"} # type: ignore - + export_template.metadata = {"url": "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/exportTemplate"} # type: ignore @distributed_trace def list( - self, - filter: Optional[str] = None, - top: Optional[int] = None, - **kwargs: Any - ) -> Iterable["_models.ResourceGroupListResult"]: + self, filter: Optional[str] = None, top: Optional[int] = None, **kwargs: Any + ) -> Iterable["_models.ResourceGroup"]: """Gets all the resource groups for a subscription. :param filter: The filter to apply on the operation. Default value is None. @@ -3006,40 +3142,48 @@ def list( Default value is None. :type top: int :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either ResourceGroupListResult or the result of - cls(response) + :return: An iterator like instance of either ResourceGroup or the result of cls(response) :rtype: - ~azure.core.paging.ItemPaged[~azure.mgmt.resource.resources.v2016_09_01.models.ResourceGroupListResult] - :raises: ~azure.core.exceptions.HttpResponseError + ~azure.core.paging.ItemPaged[~azure.mgmt.resource.resources.v2016_09_01.models.ResourceGroup] + :raises ~azure.core.exceptions.HttpResponseError: """ - api_version = kwargs.pop('api_version', "2016-09-01") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2016-09-01")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[_models.ResourceGroupListResult] - cls = kwargs.pop('cls', None) # type: ClsType["_models.ResourceGroupListResult"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) + def prepare_request(next_link=None): if not next_link: - + request = build_resource_groups_list_request( subscription_id=self._config.subscription_id, - api_version=api_version, filter=filter, top=top, - template_url=self.list.metadata['url'], + 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.url = self._client.format_url(request.url) # type: ignore else: - - request = build_resource_groups_list_request( - subscription_id=self._config.subscription_id, - template_url=next_link, - ) + # make call to next link with the client's api-version + _parsed_next_link = urlparse(next_link) + _next_request_params = case_insensitive_dict(parse_qs(_parsed_next_link.query)) + _next_request_params["api-version"] = self._config.api_version + request = HttpRequest("GET", urljoin(next_link, _parsed_next_link.path), params=_next_request_params) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore request.method = "GET" return request @@ -3053,10 +3197,8 @@ def extract_data(pipeline_response): def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) response = pipeline_response.http_response @@ -3066,66 +3208,74 @@ def get_next(next_link=None): return pipeline_response + return ItemPaged(get_next, extract_data) - return ItemPaged( - get_next, extract_data - ) - list.metadata = {'url': "/subscriptions/{subscriptionId}/resourcegroups"} # type: ignore -class ResourcesOperations(object): - """ResourcesOperations operations. - - You should not instantiate this class directly. Instead, you should create a Client instance that - instantiates it for you and attaches it as an attribute. - - :ivar models: Alias to model classes used in this operation group. - :type models: ~azure.mgmt.resource.resources.v2016_09_01.models - :param client: Client for service requests. - :param config: Configuration of service client. - :param serializer: An object model serializer. - :param deserializer: An object model deserializer. + list.metadata = {"url": "/subscriptions/{subscriptionId}/resourcegroups"} # type: ignore + + +class ResourcesOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. + + Instead, you should access the following operations through + :class:`~azure.mgmt.resource.resources.v2016_09_01.ResourceManagementClient`'s + :attr:`resources` attribute. """ models = _models - def __init__(self, client, config, serializer, deserializer): - self._client = client - self._serialize = serializer - self._deserialize = deserializer - self._config = config + def __init__(self, *args, **kwargs): + input_args = list(args) + self._client = input_args.pop(0) if input_args else kwargs.pop("client") + self._config = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") def _move_resources_initial( # pylint: disable=inconsistent-return-statements - self, - source_resource_group_name: str, - parameters: "_models.ResourcesMoveInfo", - **kwargs: Any + self, source_resource_group_name: str, parameters: Union[_models.ResourcesMoveInfo, IO], **kwargs: Any ) -> None: - cls = kwargs.pop('cls', None) # type: ClsType[None] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', "2016-09-01") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + api_version = kwargs.pop("api_version", _params.pop("api-version", "2016-09-01")) # type: str + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[None] - _json = self._serialize.body(parameters, 'ResourcesMoveInfo') + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(parameters, (IO, bytes)): + _content = parameters + else: + _json = self._serialize.body(parameters, "ResourcesMoveInfo") - request = build_resources_move_resources_request_initial( + request = build_resources_move_resources_request( source_resource_group_name=source_resource_group_name, subscription_id=self._config.subscription_id, api_version=api_version, content_type=content_type, json=_json, - template_url=self._move_resources_initial.metadata['url'], + content=_content, + template_url=self._move_resources_initial.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [202, 204]: @@ -3135,14 +3285,15 @@ def _move_resources_initial( # pylint: disable=inconsistent-return-statements if cls: return cls(pipeline_response, None, {}) - _move_resources_initial.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{sourceResourceGroupName}/moveResources"} # type: ignore + _move_resources_initial.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{sourceResourceGroupName}/moveResources"} # type: ignore - - @distributed_trace - def begin_move_resources( # pylint: disable=inconsistent-return-statements + @overload + def begin_move_resources( self, source_resource_group_name: str, - parameters: "_models.ResourcesMoveInfo", + parameters: _models.ResourcesMoveInfo, + *, + content_type: str = "application/json", **kwargs: Any ) -> LROPoller[None]: """Moves resources from one resource group to another resource group. @@ -3153,10 +3304,13 @@ def begin_move_resources( # pylint: disable=inconsistent-return-statements the groups until the move completes. :param source_resource_group_name: The name of the resource group containing the resources to - move. + move. Required. :type source_resource_group_name: str - :param parameters: Parameters for moving resources. + :param parameters: Parameters for moving resources. Required. :type parameters: ~azure.mgmt.resource.resources.v2016_09_01.models.ResourcesMoveInfo + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str :keyword callable cls: A custom type or function that will be passed the direct response :keyword str continuation_token: A continuation token to restart a poller from a saved state. :keyword polling: By default, your polling method will be ARMPolling. Pass in False for this @@ -3167,55 +3321,120 @@ def begin_move_resources( # pylint: disable=inconsistent-return-statements Retry-After header is present. :return: An instance of LROPoller that returns either None or the result of cls(response) :rtype: ~azure.core.polling.LROPoller[None] - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - api_version = kwargs.pop('api_version', "2016-09-01") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] - polling = kwargs.pop('polling', True) # type: Union[bool, PollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType[None] - lro_delay = kwargs.pop( - 'polling_interval', - self._config.polling_interval - ) - cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] + + @overload + def begin_move_resources( + self, source_resource_group_name: str, parameters: IO, *, content_type: str = "application/json", **kwargs: Any + ) -> LROPoller[None]: + """Moves resources from one resource group to another resource group. + + The resources to move must be in the same source resource group. The target resource group may + be in a different subscription. When moving resources, both the source group and the target + group are locked for the duration of the operation. Write and delete operations are blocked on + the groups until the move completes. + + :param source_resource_group_name: The name of the resource group containing the resources to + move. Required. + :type source_resource_group_name: str + :param parameters: Parameters for moving resources. Required. + :type parameters: IO + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be ARMPolling. Pass in False for this + operation to not poll, or pass in your own initialized polling object for a personal polling + strategy. + :paramtype polling: bool or ~azure.core.polling.PollingMethod + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of LROPoller that returns either None or the result of cls(response) + :rtype: ~azure.core.polling.LROPoller[None] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace + def begin_move_resources( + self, source_resource_group_name: str, parameters: Union[_models.ResourcesMoveInfo, IO], **kwargs: Any + ) -> LROPoller[None]: + """Moves resources from one resource group to another resource group. + + The resources to move must be in the same source resource group. The target resource group may + be in a different subscription. When moving resources, both the source group and the target + group are locked for the duration of the operation. Write and delete operations are blocked on + the groups until the move completes. + + :param source_resource_group_name: The name of the resource group containing the resources to + move. Required. + :type source_resource_group_name: str + :param parameters: Parameters for moving resources. Is either a model type or a IO type. + Required. + :type parameters: ~azure.mgmt.resource.resources.v2016_09_01.models.ResourcesMoveInfo or IO + :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. + Default value is None. + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be ARMPolling. Pass in False for this + operation to not poll, or pass in your own initialized polling object for a personal polling + strategy. + :paramtype polling: bool or ~azure.core.polling.PollingMethod + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of LROPoller that returns either None or the result of cls(response) + :rtype: ~azure.core.polling.LROPoller[None] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _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", "2016-09-01")) # type: str + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[None] + polling = kwargs.pop("polling", True) # type: Union[bool, PollingMethod] + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token = kwargs.pop("continuation_token", None) # type: Optional[str] if cont_token is None: - raw_result = self._move_resources_initial( + raw_result = self._move_resources_initial( # type: ignore source_resource_group_name=source_resource_group_name, parameters=parameters, api_version=api_version, content_type=content_type, - cls=lambda x,y,z: x, + cls=lambda x, y, z: x, + headers=_headers, + params=_params, **kwargs ) - kwargs.pop('error_map', None) + kwargs.pop("error_map", None) - def get_long_running_output(pipeline_response): + def get_long_running_output(pipeline_response): # pylint: disable=inconsistent-return-statements if cls: return cls(pipeline_response, None, {}) - - if polling is True: polling_method = ARMPolling(lro_delay, **kwargs) - elif polling is False: polling_method = NoPolling() - else: polling_method = polling + if polling is True: + polling_method = cast(PollingMethod, ARMPolling(lro_delay, **kwargs)) # type: PollingMethod + elif polling is False: + polling_method = cast(PollingMethod, NoPolling()) + else: + polling_method = polling if cont_token: return LROPoller.from_continuation_token( polling_method=polling_method, continuation_token=cont_token, client=self._client, - deserialization_callback=get_long_running_output + deserialization_callback=get_long_running_output, ) return LROPoller(self._client, raw_result, get_long_running_output, polling_method) - begin_move_resources.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{sourceResourceGroupName}/moveResources"} # type: ignore + begin_move_resources.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{sourceResourceGroupName}/moveResources"} # type: ignore @distributed_trace def list( - self, - filter: Optional[str] = None, - expand: Optional[str] = None, - top: Optional[int] = None, - **kwargs: Any - ) -> Iterable["_models.ResourceListResult"]: + self, filter: Optional[str] = None, expand: Optional[str] = None, top: Optional[int] = None, **kwargs: Any + ) -> Iterable["_models.GenericResourceExpanded"]: """Get all the resources in a subscription. :param filter: The filter to apply on the operation. Default value is None. @@ -3228,40 +3447,50 @@ def list( value is None. :type top: int :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either ResourceListResult or the result of cls(response) + :return: An iterator like instance of either GenericResourceExpanded or the result of + cls(response) :rtype: - ~azure.core.paging.ItemPaged[~azure.mgmt.resource.resources.v2016_09_01.models.ResourceListResult] - :raises: ~azure.core.exceptions.HttpResponseError + ~azure.core.paging.ItemPaged[~azure.mgmt.resource.resources.v2016_09_01.models.GenericResourceExpanded] + :raises ~azure.core.exceptions.HttpResponseError: """ - api_version = kwargs.pop('api_version', "2016-09-01") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2016-09-01")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[_models.ResourceListResult] - cls = kwargs.pop('cls', None) # type: ClsType["_models.ResourceListResult"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) + def prepare_request(next_link=None): if not next_link: - + request = build_resources_list_request( subscription_id=self._config.subscription_id, - api_version=api_version, filter=filter, expand=expand, top=top, - template_url=self.list.metadata['url'], + 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.url = self._client.format_url(request.url) # type: ignore else: - - request = build_resources_list_request( - subscription_id=self._config.subscription_id, - template_url=next_link, - ) + # make call to next link with the client's api-version + _parsed_next_link = urlparse(next_link) + _next_request_params = case_insensitive_dict(parse_qs(_parsed_next_link.query)) + _next_request_params["api-version"] = self._config.api_version + request = HttpRequest("GET", urljoin(next_link, _parsed_next_link.path), params=_next_request_params) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore request.method = "GET" return request @@ -3275,10 +3504,8 @@ def extract_data(pipeline_response): def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) response = pipeline_response.http_response @@ -3288,11 +3515,9 @@ def get_next(next_link=None): return pipeline_response + return ItemPaged(get_next, extract_data) - return ItemPaged( - get_next, extract_data - ) - list.metadata = {'url': "/subscriptions/{subscriptionId}/resources"} # type: ignore + list.metadata = {"url": "/subscriptions/{subscriptionId}/resources"} # type: ignore @distributed_trace def check_existence( @@ -3308,30 +3533,36 @@ def check_existence( """Checks whether a resource exists. :param resource_group_name: The name of the resource group containing the resource to check. - The name is case insensitive. + The name is case insensitive. Required. :type resource_group_name: str - :param resource_provider_namespace: The resource provider of the resource to check. + :param resource_provider_namespace: The resource provider of the resource to check. Required. :type resource_provider_namespace: str - :param parent_resource_path: The parent resource identity. + :param parent_resource_path: The parent resource identity. Required. :type parent_resource_path: str - :param resource_type: The resource type. + :param resource_type: The resource type. Required. :type resource_type: str - :param resource_name: The name of the resource to check whether it exists. + :param resource_name: The name of the resource to check whether it exists. Required. :type resource_name: str - :param api_version: The API version to use for the operation. + :param api_version: The API version to use for the operation. Required. :type api_version: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: bool, or the result of cls(response) + :return: bool or the result of cls(response) :rtype: bool - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType[None] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = kwargs.pop("params", {}) or {} + + cls = kwargs.pop("cls", None) # type: ClsType[None] - request = build_resources_check_existence_request( resource_group_name=resource_group_name, resource_provider_namespace=resource_provider_namespace, @@ -3340,16 +3571,17 @@ def check_existence( resource_name=resource_name, subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.check_existence.metadata['url'], + template_url=self.check_existence.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [204, 404]: @@ -3360,8 +3592,7 @@ def check_existence( return cls(pipeline_response, None, {}) return 200 <= response.status_code <= 299 - check_existence.metadata = {'url': "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{parentResourcePath}/{resourceType}/{resourceName}"} # type: ignore - + check_existence.metadata = {"url": "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{parentResourcePath}/{resourceType}/{resourceName}"} # type: ignore def _delete_initial( # pylint: disable=inconsistent-return-statements self, @@ -3373,14 +3604,20 @@ def _delete_initial( # pylint: disable=inconsistent-return-statements api_version: str, **kwargs: Any ) -> None: - cls = kwargs.pop('cls', None) # type: ClsType[None] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) - - request = build_resources_delete_request_initial( + _headers = kwargs.pop("headers", {}) or {} + _params = kwargs.pop("params", {}) or {} + + cls = kwargs.pop("cls", None) # type: ClsType[None] + + request = build_resources_delete_request( resource_group_name=resource_group_name, resource_provider_namespace=resource_provider_namespace, parent_resource_path=parent_resource_path, @@ -3388,16 +3625,17 @@ def _delete_initial( # pylint: disable=inconsistent-return-statements resource_name=resource_name, subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self._delete_initial.metadata['url'], + template_url=self._delete_initial.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200, 202, 204]: @@ -3407,11 +3645,10 @@ def _delete_initial( # pylint: disable=inconsistent-return-statements if cls: return cls(pipeline_response, None, {}) - _delete_initial.metadata = {'url': "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{parentResourcePath}/{resourceType}/{resourceName}"} # type: ignore - + _delete_initial.metadata = {"url": "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{parentResourcePath}/{resourceType}/{resourceName}"} # type: ignore @distributed_trace - def begin_delete( # pylint: disable=inconsistent-return-statements + def begin_delete( self, resource_group_name: str, resource_provider_namespace: str, @@ -3424,17 +3661,17 @@ def begin_delete( # pylint: disable=inconsistent-return-statements """Deletes a resource. :param resource_group_name: The name of the resource group that contains the resource to - delete. The name is case insensitive. + delete. The name is case insensitive. Required. :type resource_group_name: str - :param resource_provider_namespace: The namespace of the resource provider. + :param resource_provider_namespace: The namespace of the resource provider. Required. :type resource_provider_namespace: str - :param parent_resource_path: The parent resource identity. + :param parent_resource_path: The parent resource identity. Required. :type parent_resource_path: str - :param resource_type: The resource type. + :param resource_type: The resource type. Required. :type resource_type: str - :param resource_name: The name of the resource to delete. + :param resource_name: The name of the resource to delete. Required. :type resource_name: str - :param api_version: The API version to use for the operation. + :param api_version: The API version to use for the operation. Required. :type api_version: str :keyword callable cls: A custom type or function that will be passed the direct response :keyword str continuation_token: A continuation token to restart a poller from a saved state. @@ -3446,46 +3683,50 @@ def begin_delete( # pylint: disable=inconsistent-return-statements Retry-After header is present. :return: An instance of LROPoller that returns either None or the result of cls(response) :rtype: ~azure.core.polling.LROPoller[None] - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - polling = kwargs.pop('polling', True) # type: Union[bool, PollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType[None] - lro_delay = kwargs.pop( - 'polling_interval', - self._config.polling_interval - ) - cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] + _headers = kwargs.pop("headers", {}) or {} + _params = kwargs.pop("params", {}) or {} + + cls = kwargs.pop("cls", None) # type: ClsType[None] + polling = kwargs.pop("polling", True) # type: Union[bool, PollingMethod] + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token = kwargs.pop("continuation_token", None) # type: Optional[str] if cont_token is None: - raw_result = self._delete_initial( + raw_result = self._delete_initial( # type: ignore resource_group_name=resource_group_name, resource_provider_namespace=resource_provider_namespace, parent_resource_path=parent_resource_path, resource_type=resource_type, resource_name=resource_name, api_version=api_version, - cls=lambda x,y,z: x, + cls=lambda x, y, z: x, + headers=_headers, + params=_params, **kwargs ) - kwargs.pop('error_map', None) + kwargs.pop("error_map", None) - def get_long_running_output(pipeline_response): + def get_long_running_output(pipeline_response): # pylint: disable=inconsistent-return-statements if cls: return cls(pipeline_response, None, {}) - - if polling is True: polling_method = ARMPolling(lro_delay, **kwargs) - elif polling is False: polling_method = NoPolling() - else: polling_method = polling + if polling is True: + polling_method = cast(PollingMethod, ARMPolling(lro_delay, **kwargs)) # type: PollingMethod + elif polling is False: + polling_method = cast(PollingMethod, NoPolling()) + else: + polling_method = polling if cont_token: return LROPoller.from_continuation_token( polling_method=polling_method, continuation_token=cont_token, client=self._client, - deserialization_callback=get_long_running_output + deserialization_callback=get_long_running_output, ) return LROPoller(self._client, raw_result, get_long_running_output, polling_method) - begin_delete.metadata = {'url': "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{parentResourcePath}/{resourceType}/{resourceName}"} # type: ignore + begin_delete.metadata = {"url": "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{parentResourcePath}/{resourceType}/{resourceName}"} # type: ignore def _create_or_update_initial( self, @@ -3495,39 +3736,53 @@ def _create_or_update_initial( resource_type: str, resource_name: str, api_version: str, - parameters: "_models.GenericResource", + parameters: Union[_models.GenericResource, IO], **kwargs: Any - ) -> Optional["_models.GenericResource"]: - cls = kwargs.pop('cls', None) # type: ClsType[Optional["_models.GenericResource"]] + ) -> Optional[_models.GenericResource]: error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = kwargs.pop("params", {}) or {} - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[Optional[_models.GenericResource]] - _json = self._serialize.body(parameters, 'GenericResource') + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(parameters, (IO, bytes)): + _content = parameters + else: + _json = self._serialize.body(parameters, "GenericResource") - request = build_resources_create_or_update_request_initial( + request = build_resources_create_or_update_request( resource_group_name=resource_group_name, resource_provider_namespace=resource_provider_namespace, parent_resource_path=parent_resource_path, resource_type=resource_type, resource_name=resource_name, subscription_id=self._config.subscription_id, - content_type=content_type, api_version=api_version, + content_type=content_type, json=_json, - template_url=self._create_or_update_initial.metadata['url'], + content=_content, + template_url=self._create_or_update_initial.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200, 201, 202]: @@ -3536,18 +3791,115 @@ def _create_or_update_initial( deserialized = None if response.status_code == 200: - deserialized = self._deserialize('GenericResource', pipeline_response) + deserialized = self._deserialize("GenericResource", pipeline_response) if response.status_code == 201: - deserialized = self._deserialize('GenericResource', pipeline_response) + deserialized = self._deserialize("GenericResource", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - _create_or_update_initial.metadata = {'url': "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{parentResourcePath}/{resourceType}/{resourceName}"} # type: ignore + _create_or_update_initial.metadata = {"url": "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{parentResourcePath}/{resourceType}/{resourceName}"} # type: ignore + + @overload + def begin_create_or_update( + self, + resource_group_name: str, + resource_provider_namespace: str, + parent_resource_path: str, + resource_type: str, + resource_name: str, + api_version: str, + parameters: _models.GenericResource, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> LROPoller[_models.GenericResource]: + """Creates a resource. + + :param resource_group_name: The name of the resource group for the resource. The name is case + insensitive. Required. + :type resource_group_name: str + :param resource_provider_namespace: The namespace of the resource provider. Required. + :type resource_provider_namespace: str + :param parent_resource_path: The parent resource identity. Required. + :type parent_resource_path: str + :param resource_type: The resource type of the resource to create. Required. + :type resource_type: str + :param resource_name: The name of the resource to create. Required. + :type resource_name: str + :param api_version: The API version to use for the operation. Required. + :type api_version: str + :param parameters: Parameters for creating or updating the resource. Required. + :type parameters: ~azure.mgmt.resource.resources.v2016_09_01.models.GenericResource + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be ARMPolling. Pass in False for this + operation to not poll, or pass in your own initialized polling object for a personal polling + strategy. + :paramtype polling: bool or ~azure.core.polling.PollingMethod + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of LROPoller that returns either GenericResource or the result of + cls(response) + :rtype: + ~azure.core.polling.LROPoller[~azure.mgmt.resource.resources.v2016_09_01.models.GenericResource] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + def begin_create_or_update( + self, + resource_group_name: str, + resource_provider_namespace: str, + parent_resource_path: str, + resource_type: str, + resource_name: str, + api_version: str, + parameters: IO, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> LROPoller[_models.GenericResource]: + """Creates a resource. + :param resource_group_name: The name of the resource group for the resource. The name is case + insensitive. Required. + :type resource_group_name: str + :param resource_provider_namespace: The namespace of the resource provider. Required. + :type resource_provider_namespace: str + :param parent_resource_path: The parent resource identity. Required. + :type parent_resource_path: str + :param resource_type: The resource type of the resource to create. Required. + :type resource_type: str + :param resource_name: The name of the resource to create. Required. + :type resource_name: str + :param api_version: The API version to use for the operation. Required. + :type api_version: str + :param parameters: Parameters for creating or updating the resource. Required. + :type parameters: IO + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be ARMPolling. Pass in False for this + operation to not poll, or pass in your own initialized polling object for a personal polling + strategy. + :paramtype polling: bool or ~azure.core.polling.PollingMethod + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of LROPoller that returns either GenericResource or the result of + cls(response) + :rtype: + ~azure.core.polling.LROPoller[~azure.mgmt.resource.resources.v2016_09_01.models.GenericResource] + :raises ~azure.core.exceptions.HttpResponseError: + """ @distributed_trace def begin_create_or_update( @@ -3558,26 +3910,30 @@ def begin_create_or_update( resource_type: str, resource_name: str, api_version: str, - parameters: "_models.GenericResource", + parameters: Union[_models.GenericResource, IO], **kwargs: Any - ) -> LROPoller["_models.GenericResource"]: + ) -> LROPoller[_models.GenericResource]: """Creates a resource. :param resource_group_name: The name of the resource group for the resource. The name is case - insensitive. + insensitive. Required. :type resource_group_name: str - :param resource_provider_namespace: The namespace of the resource provider. + :param resource_provider_namespace: The namespace of the resource provider. Required. :type resource_provider_namespace: str - :param parent_resource_path: The parent resource identity. + :param parent_resource_path: The parent resource identity. Required. :type parent_resource_path: str - :param resource_type: The resource type of the resource to create. + :param resource_type: The resource type of the resource to create. Required. :type resource_type: str - :param resource_name: The name of the resource to create. + :param resource_name: The name of the resource to create. Required. :type resource_name: str - :param api_version: The API version to use for the operation. + :param api_version: The API version to use for the operation. Required. :type api_version: str - :param parameters: Parameters for creating or updating the resource. - :type parameters: ~azure.mgmt.resource.resources.v2016_09_01.models.GenericResource + :param parameters: Parameters for creating or updating the resource. Is either a model type or + a IO type. Required. + :type parameters: ~azure.mgmt.resource.resources.v2016_09_01.models.GenericResource or IO + :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. + Default value is None. + :paramtype content_type: str :keyword callable cls: A custom type or function that will be passed the direct response :keyword str continuation_token: A continuation token to restart a poller from a saved state. :keyword polling: By default, your polling method will be ARMPolling. Pass in False for this @@ -3590,18 +3946,18 @@ def begin_create_or_update( cls(response) :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.resource.resources.v2016_09_01.models.GenericResource] - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] - polling = kwargs.pop('polling', True) # type: Union[bool, PollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType["_models.GenericResource"] - lro_delay = kwargs.pop( - 'polling_interval', - self._config.polling_interval - ) - cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = kwargs.pop("params", {}) or {} + + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.GenericResource] + polling = kwargs.pop("polling", True) # type: Union[bool, PollingMethod] + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token = kwargs.pop("continuation_token", None) # type: Optional[str] if cont_token is None: - raw_result = self._create_or_update_initial( + raw_result = self._create_or_update_initial( # type: ignore resource_group_name=resource_group_name, resource_provider_namespace=resource_provider_namespace, parent_resource_path=parent_resource_path, @@ -3610,32 +3966,35 @@ def begin_create_or_update( api_version=api_version, parameters=parameters, content_type=content_type, - cls=lambda x,y,z: x, + cls=lambda x, y, z: x, + headers=_headers, + params=_params, **kwargs ) - kwargs.pop('error_map', None) + kwargs.pop("error_map", None) def get_long_running_output(pipeline_response): - response = pipeline_response.http_response - deserialized = self._deserialize('GenericResource', pipeline_response) + deserialized = self._deserialize("GenericResource", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - - if polling is True: polling_method = ARMPolling(lro_delay, **kwargs) - elif polling is False: polling_method = NoPolling() - else: polling_method = polling + if polling is True: + polling_method = cast(PollingMethod, ARMPolling(lro_delay, **kwargs)) # type: PollingMethod + elif polling is False: + polling_method = cast(PollingMethod, NoPolling()) + else: + polling_method = polling if cont_token: return LROPoller.from_continuation_token( polling_method=polling_method, continuation_token=cont_token, client=self._client, - deserialization_callback=get_long_running_output + deserialization_callback=get_long_running_output, ) return LROPoller(self._client, raw_result, get_long_running_output, polling_method) - begin_create_or_update.metadata = {'url': "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{parentResourcePath}/{resourceType}/{resourceName}"} # type: ignore + begin_create_or_update.metadata = {"url": "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{parentResourcePath}/{resourceType}/{resourceName}"} # type: ignore def _update_initial( self, @@ -3645,39 +4004,53 @@ def _update_initial( resource_type: str, resource_name: str, api_version: str, - parameters: "_models.GenericResource", + parameters: Union[_models.GenericResource, IO], **kwargs: Any - ) -> Optional["_models.GenericResource"]: - cls = kwargs.pop('cls', None) # type: ClsType[Optional["_models.GenericResource"]] + ) -> Optional[_models.GenericResource]: error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = kwargs.pop("params", {}) or {} - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[Optional[_models.GenericResource]] - _json = self._serialize.body(parameters, 'GenericResource') + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(parameters, (IO, bytes)): + _content = parameters + else: + _json = self._serialize.body(parameters, "GenericResource") - request = build_resources_update_request_initial( + request = build_resources_update_request( resource_group_name=resource_group_name, resource_provider_namespace=resource_provider_namespace, parent_resource_path=parent_resource_path, resource_type=resource_type, resource_name=resource_name, subscription_id=self._config.subscription_id, - content_type=content_type, api_version=api_version, + content_type=content_type, json=_json, - template_url=self._update_initial.metadata['url'], + content=_content, + template_url=self._update_initial.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200, 202]: @@ -3686,15 +4059,112 @@ def _update_initial( deserialized = None if response.status_code == 200: - deserialized = self._deserialize('GenericResource', pipeline_response) + deserialized = self._deserialize("GenericResource", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - _update_initial.metadata = {'url': "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{parentResourcePath}/{resourceType}/{resourceName}"} # type: ignore + _update_initial.metadata = {"url": "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{parentResourcePath}/{resourceType}/{resourceName}"} # type: ignore + + @overload + def begin_update( + self, + resource_group_name: str, + resource_provider_namespace: str, + parent_resource_path: str, + resource_type: str, + resource_name: str, + api_version: str, + parameters: _models.GenericResource, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> LROPoller[_models.GenericResource]: + """Updates a resource. + + :param resource_group_name: The name of the resource group for the resource. The name is case + insensitive. Required. + :type resource_group_name: str + :param resource_provider_namespace: The namespace of the resource provider. Required. + :type resource_provider_namespace: str + :param parent_resource_path: The parent resource identity. Required. + :type parent_resource_path: str + :param resource_type: The resource type of the resource to update. Required. + :type resource_type: str + :param resource_name: The name of the resource to update. Required. + :type resource_name: str + :param api_version: The API version to use for the operation. Required. + :type api_version: str + :param parameters: Parameters for updating the resource. Required. + :type parameters: ~azure.mgmt.resource.resources.v2016_09_01.models.GenericResource + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be ARMPolling. Pass in False for this + operation to not poll, or pass in your own initialized polling object for a personal polling + strategy. + :paramtype polling: bool or ~azure.core.polling.PollingMethod + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of LROPoller that returns either GenericResource or the result of + cls(response) + :rtype: + ~azure.core.polling.LROPoller[~azure.mgmt.resource.resources.v2016_09_01.models.GenericResource] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + def begin_update( + self, + resource_group_name: str, + resource_provider_namespace: str, + parent_resource_path: str, + resource_type: str, + resource_name: str, + api_version: str, + parameters: IO, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> LROPoller[_models.GenericResource]: + """Updates a resource. + :param resource_group_name: The name of the resource group for the resource. The name is case + insensitive. Required. + :type resource_group_name: str + :param resource_provider_namespace: The namespace of the resource provider. Required. + :type resource_provider_namespace: str + :param parent_resource_path: The parent resource identity. Required. + :type parent_resource_path: str + :param resource_type: The resource type of the resource to update. Required. + :type resource_type: str + :param resource_name: The name of the resource to update. Required. + :type resource_name: str + :param api_version: The API version to use for the operation. Required. + :type api_version: str + :param parameters: Parameters for updating the resource. Required. + :type parameters: IO + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be ARMPolling. Pass in False for this + operation to not poll, or pass in your own initialized polling object for a personal polling + strategy. + :paramtype polling: bool or ~azure.core.polling.PollingMethod + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of LROPoller that returns either GenericResource or the result of + cls(response) + :rtype: + ~azure.core.polling.LROPoller[~azure.mgmt.resource.resources.v2016_09_01.models.GenericResource] + :raises ~azure.core.exceptions.HttpResponseError: + """ @distributed_trace def begin_update( @@ -3705,26 +4175,30 @@ def begin_update( resource_type: str, resource_name: str, api_version: str, - parameters: "_models.GenericResource", + parameters: Union[_models.GenericResource, IO], **kwargs: Any - ) -> LROPoller["_models.GenericResource"]: + ) -> LROPoller[_models.GenericResource]: """Updates a resource. :param resource_group_name: The name of the resource group for the resource. The name is case - insensitive. + insensitive. Required. :type resource_group_name: str - :param resource_provider_namespace: The namespace of the resource provider. + :param resource_provider_namespace: The namespace of the resource provider. Required. :type resource_provider_namespace: str - :param parent_resource_path: The parent resource identity. + :param parent_resource_path: The parent resource identity. Required. :type parent_resource_path: str - :param resource_type: The resource type of the resource to update. + :param resource_type: The resource type of the resource to update. Required. :type resource_type: str - :param resource_name: The name of the resource to update. + :param resource_name: The name of the resource to update. Required. :type resource_name: str - :param api_version: The API version to use for the operation. + :param api_version: The API version to use for the operation. Required. :type api_version: str - :param parameters: Parameters for updating the resource. - :type parameters: ~azure.mgmt.resource.resources.v2016_09_01.models.GenericResource + :param parameters: Parameters for updating the resource. Is either a model type or a IO type. + Required. + :type parameters: ~azure.mgmt.resource.resources.v2016_09_01.models.GenericResource or IO + :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. + Default value is None. + :paramtype content_type: str :keyword callable cls: A custom type or function that will be passed the direct response :keyword str continuation_token: A continuation token to restart a poller from a saved state. :keyword polling: By default, your polling method will be ARMPolling. Pass in False for this @@ -3737,18 +4211,18 @@ def begin_update( cls(response) :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.resource.resources.v2016_09_01.models.GenericResource] - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] - polling = kwargs.pop('polling', True) # type: Union[bool, PollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType["_models.GenericResource"] - lro_delay = kwargs.pop( - 'polling_interval', - self._config.polling_interval - ) - cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = kwargs.pop("params", {}) or {} + + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.GenericResource] + polling = kwargs.pop("polling", True) # type: Union[bool, PollingMethod] + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token = kwargs.pop("continuation_token", None) # type: Optional[str] if cont_token is None: - raw_result = self._update_initial( + raw_result = self._update_initial( # type: ignore resource_group_name=resource_group_name, resource_provider_namespace=resource_provider_namespace, parent_resource_path=parent_resource_path, @@ -3757,32 +4231,35 @@ def begin_update( api_version=api_version, parameters=parameters, content_type=content_type, - cls=lambda x,y,z: x, + cls=lambda x, y, z: x, + headers=_headers, + params=_params, **kwargs ) - kwargs.pop('error_map', None) + kwargs.pop("error_map", None) def get_long_running_output(pipeline_response): - response = pipeline_response.http_response - deserialized = self._deserialize('GenericResource', pipeline_response) + deserialized = self._deserialize("GenericResource", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - - if polling is True: polling_method = ARMPolling(lro_delay, **kwargs) - elif polling is False: polling_method = NoPolling() - else: polling_method = polling + if polling is True: + polling_method = cast(PollingMethod, ARMPolling(lro_delay, **kwargs)) # type: PollingMethod + elif polling is False: + polling_method = cast(PollingMethod, NoPolling()) + else: + polling_method = polling if cont_token: return LROPoller.from_continuation_token( polling_method=polling_method, continuation_token=cont_token, client=self._client, - deserialization_callback=get_long_running_output + deserialization_callback=get_long_running_output, ) return LROPoller(self._client, raw_result, get_long_running_output, polling_method) - begin_update.metadata = {'url': "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{parentResourcePath}/{resourceType}/{resourceName}"} # type: ignore + begin_update.metadata = {"url": "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{parentResourcePath}/{resourceType}/{resourceName}"} # type: ignore @distributed_trace def get( @@ -3794,34 +4271,40 @@ def get( resource_name: str, api_version: str, **kwargs: Any - ) -> "_models.GenericResource": + ) -> _models.GenericResource: """Gets a resource. :param resource_group_name: The name of the resource group containing the resource to get. The - name is case insensitive. + name is case insensitive. Required. :type resource_group_name: str - :param resource_provider_namespace: The namespace of the resource provider. + :param resource_provider_namespace: The namespace of the resource provider. Required. :type resource_provider_namespace: str - :param parent_resource_path: The parent resource identity. + :param parent_resource_path: The parent resource identity. Required. :type parent_resource_path: str - :param resource_type: The resource type of the resource. + :param resource_type: The resource type of the resource. Required. :type resource_type: str - :param resource_name: The name of the resource to get. + :param resource_name: The name of the resource to get. Required. :type resource_name: str - :param api_version: The API version to use for the operation. + :param api_version: The API version to use for the operation. Required. :type api_version: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: GenericResource, or the result of cls(response) + :return: GenericResource or the result of cls(response) :rtype: ~azure.mgmt.resource.resources.v2016_09_01.models.GenericResource - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.GenericResource"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = kwargs.pop("params", {}) or {} + + cls = kwargs.pop("cls", None) # type: ClsType[_models.GenericResource] - request = build_resources_get_request( resource_group_name=resource_group_name, resource_provider_namespace=resource_provider_namespace, @@ -3830,72 +4313,75 @@ def get( resource_name=resource_name, subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.get.metadata['url'], + template_url=self.get.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) - deserialized = self._deserialize('GenericResource', pipeline_response) + deserialized = self._deserialize("GenericResource", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - get.metadata = {'url': "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{parentResourcePath}/{resourceType}/{resourceName}"} # type: ignore - + get.metadata = {"url": "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{parentResourcePath}/{resourceType}/{resourceName}"} # type: ignore @distributed_trace - def check_existence_by_id( - self, - resource_id: str, - api_version: str, - **kwargs: Any - ) -> bool: + def check_existence_by_id(self, resource_id: str, api_version: str, **kwargs: Any) -> bool: """Checks by ID whether a resource exists. :param resource_id: The fully qualified ID of the resource, including the resource name and resource type. Use the format, /subscriptions/{guid}/resourceGroups/{resource-group-name}/{resource-provider-namespace}/{resource-type}/{resource-name}. + Required. :type resource_id: str - :param api_version: The API version to use for the operation. + :param api_version: The API version to use for the operation. Required. :type api_version: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: bool, or the result of cls(response) + :return: bool or the result of cls(response) :rtype: bool - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType[None] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = kwargs.pop("params", {}) or {} + + cls = kwargs.pop("cls", None) # type: ClsType[None] - request = build_resources_check_existence_by_id_request( resource_id=resource_id, api_version=api_version, - template_url=self.check_existence_by_id.metadata['url'], + template_url=self.check_existence_by_id.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [204, 404]: @@ -3906,35 +4392,38 @@ def check_existence_by_id( return cls(pipeline_response, None, {}) return 200 <= response.status_code <= 299 - check_existence_by_id.metadata = {'url': "/{resourceId}"} # type: ignore - + check_existence_by_id.metadata = {"url": "/{resourceId}"} # type: ignore def _delete_by_id_initial( # pylint: disable=inconsistent-return-statements - self, - resource_id: str, - api_version: str, - **kwargs: Any + self, resource_id: str, api_version: str, **kwargs: Any ) -> None: - cls = kwargs.pop('cls', None) # type: ClsType[None] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = kwargs.pop("params", {}) or {} - - request = build_resources_delete_by_id_request_initial( + cls = kwargs.pop("cls", None) # type: ClsType[None] + + request = build_resources_delete_by_id_request( resource_id=resource_id, api_version=api_version, - template_url=self._delete_by_id_initial.metadata['url'], + template_url=self._delete_by_id_initial.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200, 202, 204]: @@ -3944,23 +4433,18 @@ def _delete_by_id_initial( # pylint: disable=inconsistent-return-statements if cls: return cls(pipeline_response, None, {}) - _delete_by_id_initial.metadata = {'url': "/{resourceId}"} # type: ignore - + _delete_by_id_initial.metadata = {"url": "/{resourceId}"} # type: ignore @distributed_trace - def begin_delete_by_id( # pylint: disable=inconsistent-return-statements - self, - resource_id: str, - api_version: str, - **kwargs: Any - ) -> LROPoller[None]: + def begin_delete_by_id(self, resource_id: str, api_version: str, **kwargs: Any) -> LROPoller[None]: """Deletes a resource by ID. :param resource_id: The fully qualified ID of the resource, including the resource name and resource type. Use the format, /subscriptions/{guid}/resourceGroups/{resource-group-name}/{resource-provider-namespace}/{resource-type}/{resource-name}. + Required. :type resource_id: str - :param api_version: The API version to use for the operation. + :param api_version: The API version to use for the operation. Required. :type api_version: str :keyword callable cls: A custom type or function that will be passed the direct response :keyword str continuation_token: A continuation token to restart a poller from a saved state. @@ -3972,75 +4456,89 @@ def begin_delete_by_id( # pylint: disable=inconsistent-return-statements Retry-After header is present. :return: An instance of LROPoller that returns either None or the result of cls(response) :rtype: ~azure.core.polling.LROPoller[None] - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - polling = kwargs.pop('polling', True) # type: Union[bool, PollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType[None] - lro_delay = kwargs.pop( - 'polling_interval', - self._config.polling_interval - ) - cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] + _headers = kwargs.pop("headers", {}) or {} + _params = kwargs.pop("params", {}) or {} + + cls = kwargs.pop("cls", None) # type: ClsType[None] + polling = kwargs.pop("polling", True) # type: Union[bool, PollingMethod] + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token = kwargs.pop("continuation_token", None) # type: Optional[str] if cont_token is None: - raw_result = self._delete_by_id_initial( + raw_result = self._delete_by_id_initial( # type: ignore resource_id=resource_id, api_version=api_version, - cls=lambda x,y,z: x, + cls=lambda x, y, z: x, + headers=_headers, + params=_params, **kwargs ) - kwargs.pop('error_map', None) + kwargs.pop("error_map", None) - def get_long_running_output(pipeline_response): + def get_long_running_output(pipeline_response): # pylint: disable=inconsistent-return-statements if cls: return cls(pipeline_response, None, {}) - - if polling is True: polling_method = ARMPolling(lro_delay, **kwargs) - elif polling is False: polling_method = NoPolling() - else: polling_method = polling + if polling is True: + polling_method = cast(PollingMethod, ARMPolling(lro_delay, **kwargs)) # type: PollingMethod + elif polling is False: + polling_method = cast(PollingMethod, NoPolling()) + else: + polling_method = polling if cont_token: return LROPoller.from_continuation_token( polling_method=polling_method, continuation_token=cont_token, client=self._client, - deserialization_callback=get_long_running_output + deserialization_callback=get_long_running_output, ) return LROPoller(self._client, raw_result, get_long_running_output, polling_method) - begin_delete_by_id.metadata = {'url': "/{resourceId}"} # type: ignore + begin_delete_by_id.metadata = {"url": "/{resourceId}"} # type: ignore def _create_or_update_by_id_initial( - self, - resource_id: str, - api_version: str, - parameters: "_models.GenericResource", - **kwargs: Any - ) -> Optional["_models.GenericResource"]: - cls = kwargs.pop('cls', None) # type: ClsType[Optional["_models.GenericResource"]] + self, resource_id: str, api_version: str, parameters: Union[_models.GenericResource, IO], **kwargs: Any + ) -> Optional[_models.GenericResource]: error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = kwargs.pop("params", {}) or {} - _json = self._serialize.body(parameters, 'GenericResource') + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[Optional[_models.GenericResource]] - request = build_resources_create_or_update_by_id_request_initial( + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(parameters, (IO, bytes)): + _content = parameters + else: + _json = self._serialize.body(parameters, "GenericResource") + + request = build_resources_create_or_update_by_id_request( resource_id=resource_id, - content_type=content_type, api_version=api_version, + content_type=content_type, json=_json, - template_url=self._create_or_update_by_id_initial.metadata['url'], + content=_content, + template_url=self._create_or_update_by_id_initial.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200, 201, 202]: @@ -4049,37 +4547,42 @@ def _create_or_update_by_id_initial( deserialized = None if response.status_code == 200: - deserialized = self._deserialize('GenericResource', pipeline_response) + deserialized = self._deserialize("GenericResource", pipeline_response) if response.status_code == 201: - deserialized = self._deserialize('GenericResource', pipeline_response) + deserialized = self._deserialize("GenericResource", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - _create_or_update_by_id_initial.metadata = {'url': "/{resourceId}"} # type: ignore + _create_or_update_by_id_initial.metadata = {"url": "/{resourceId}"} # type: ignore - - @distributed_trace + @overload def begin_create_or_update_by_id( self, resource_id: str, api_version: str, - parameters: "_models.GenericResource", + parameters: _models.GenericResource, + *, + content_type: str = "application/json", **kwargs: Any - ) -> LROPoller["_models.GenericResource"]: + ) -> LROPoller[_models.GenericResource]: """Create a resource by ID. :param resource_id: The fully qualified ID of the resource, including the resource name and resource type. Use the format, /subscriptions/{guid}/resourceGroups/{resource-group-name}/{resource-provider-namespace}/{resource-type}/{resource-name}. + Required. :type resource_id: str - :param api_version: The API version to use for the operation. + :param api_version: The API version to use for the operation. Required. :type api_version: str - :param parameters: Create or update resource parameters. + :param parameters: Create or update resource parameters. Required. :type parameters: ~azure.mgmt.resource.resources.v2016_09_01.models.GenericResource + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str :keyword callable cls: A custom type or function that will be passed the direct response :keyword str continuation_token: A continuation token to restart a poller from a saved state. :keyword polling: By default, your polling method will be ARMPolling. Pass in False for this @@ -4092,81 +4595,167 @@ def begin_create_or_update_by_id( cls(response) :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.resource.resources.v2016_09_01.models.GenericResource] - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] - polling = kwargs.pop('polling', True) # type: Union[bool, PollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType["_models.GenericResource"] - lro_delay = kwargs.pop( - 'polling_interval', - self._config.polling_interval - ) - cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] + + @overload + def begin_create_or_update_by_id( + self, + resource_id: str, + api_version: str, + parameters: IO, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> LROPoller[_models.GenericResource]: + """Create a resource by ID. + + :param resource_id: The fully qualified ID of the resource, including the resource name and + resource type. Use the format, + /subscriptions/{guid}/resourceGroups/{resource-group-name}/{resource-provider-namespace}/{resource-type}/{resource-name}. + Required. + :type resource_id: str + :param api_version: The API version to use for the operation. Required. + :type api_version: str + :param parameters: Create or update resource parameters. Required. + :type parameters: IO + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be ARMPolling. Pass in False for this + operation to not poll, or pass in your own initialized polling object for a personal polling + strategy. + :paramtype polling: bool or ~azure.core.polling.PollingMethod + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of LROPoller that returns either GenericResource or the result of + cls(response) + :rtype: + ~azure.core.polling.LROPoller[~azure.mgmt.resource.resources.v2016_09_01.models.GenericResource] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace + def begin_create_or_update_by_id( + self, resource_id: str, api_version: str, parameters: Union[_models.GenericResource, IO], **kwargs: Any + ) -> LROPoller[_models.GenericResource]: + """Create a resource by ID. + + :param resource_id: The fully qualified ID of the resource, including the resource name and + resource type. Use the format, + /subscriptions/{guid}/resourceGroups/{resource-group-name}/{resource-provider-namespace}/{resource-type}/{resource-name}. + Required. + :type resource_id: str + :param api_version: The API version to use for the operation. Required. + :type api_version: str + :param parameters: Create or update resource parameters. Is either a model type or a IO type. + Required. + :type parameters: ~azure.mgmt.resource.resources.v2016_09_01.models.GenericResource or IO + :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. + Default value is None. + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be ARMPolling. Pass in False for this + operation to not poll, or pass in your own initialized polling object for a personal polling + strategy. + :paramtype polling: bool or ~azure.core.polling.PollingMethod + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of LROPoller that returns either GenericResource or the result of + cls(response) + :rtype: + ~azure.core.polling.LROPoller[~azure.mgmt.resource.resources.v2016_09_01.models.GenericResource] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = kwargs.pop("params", {}) or {} + + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.GenericResource] + polling = kwargs.pop("polling", True) # type: Union[bool, PollingMethod] + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token = kwargs.pop("continuation_token", None) # type: Optional[str] if cont_token is None: - raw_result = self._create_or_update_by_id_initial( + raw_result = self._create_or_update_by_id_initial( # type: ignore resource_id=resource_id, api_version=api_version, parameters=parameters, content_type=content_type, - cls=lambda x,y,z: x, + cls=lambda x, y, z: x, + headers=_headers, + params=_params, **kwargs ) - kwargs.pop('error_map', None) + kwargs.pop("error_map", None) def get_long_running_output(pipeline_response): - response = pipeline_response.http_response - deserialized = self._deserialize('GenericResource', pipeline_response) + deserialized = self._deserialize("GenericResource", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - - if polling is True: polling_method = ARMPolling(lro_delay, **kwargs) - elif polling is False: polling_method = NoPolling() - else: polling_method = polling + if polling is True: + polling_method = cast(PollingMethod, ARMPolling(lro_delay, **kwargs)) # type: PollingMethod + elif polling is False: + polling_method = cast(PollingMethod, NoPolling()) + else: + polling_method = polling if cont_token: return LROPoller.from_continuation_token( polling_method=polling_method, continuation_token=cont_token, client=self._client, - deserialization_callback=get_long_running_output + deserialization_callback=get_long_running_output, ) return LROPoller(self._client, raw_result, get_long_running_output, polling_method) - begin_create_or_update_by_id.metadata = {'url': "/{resourceId}"} # type: ignore + begin_create_or_update_by_id.metadata = {"url": "/{resourceId}"} # type: ignore def _update_by_id_initial( - self, - resource_id: str, - api_version: str, - parameters: "_models.GenericResource", - **kwargs: Any - ) -> Optional["_models.GenericResource"]: - cls = kwargs.pop('cls', None) # type: ClsType[Optional["_models.GenericResource"]] + self, resource_id: str, api_version: str, parameters: Union[_models.GenericResource, IO], **kwargs: Any + ) -> Optional[_models.GenericResource]: error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = kwargs.pop("params", {}) or {} - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[Optional[_models.GenericResource]] - _json = self._serialize.body(parameters, 'GenericResource') + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(parameters, (IO, bytes)): + _content = parameters + else: + _json = self._serialize.body(parameters, "GenericResource") - request = build_resources_update_by_id_request_initial( + request = build_resources_update_by_id_request( resource_id=resource_id, - content_type=content_type, api_version=api_version, + content_type=content_type, json=_json, - template_url=self._update_by_id_initial.metadata['url'], + content=_content, + template_url=self._update_by_id_initial.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200, 202]: @@ -4175,34 +4764,39 @@ def _update_by_id_initial( deserialized = None if response.status_code == 200: - deserialized = self._deserialize('GenericResource', pipeline_response) + deserialized = self._deserialize("GenericResource", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - _update_by_id_initial.metadata = {'url': "/{resourceId}"} # type: ignore - + _update_by_id_initial.metadata = {"url": "/{resourceId}"} # type: ignore - @distributed_trace + @overload def begin_update_by_id( self, resource_id: str, api_version: str, - parameters: "_models.GenericResource", + parameters: _models.GenericResource, + *, + content_type: str = "application/json", **kwargs: Any - ) -> LROPoller["_models.GenericResource"]: + ) -> LROPoller[_models.GenericResource]: """Updates a resource by ID. :param resource_id: The fully qualified ID of the resource, including the resource name and resource type. Use the format, /subscriptions/{guid}/resourceGroups/{resource-group-name}/{resource-provider-namespace}/{resource-type}/{resource-name}. + Required. :type resource_id: str - :param api_version: The API version to use for the operation. + :param api_version: The API version to use for the operation. Required. :type api_version: str - :param parameters: Update resource parameters. + :param parameters: Update resource parameters. Required. :type parameters: ~azure.mgmt.resource.resources.v2016_09_01.models.GenericResource + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str :keyword callable cls: A custom type or function that will be passed the direct response :keyword str continuation_token: A continuation token to restart a poller from a saved state. :keyword polling: By default, your polling method will be ARMPolling. Pass in False for this @@ -4215,168 +4809,247 @@ def begin_update_by_id( cls(response) :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.resource.resources.v2016_09_01.models.GenericResource] - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] - polling = kwargs.pop('polling', True) # type: Union[bool, PollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType["_models.GenericResource"] - lro_delay = kwargs.pop( - 'polling_interval', - self._config.polling_interval - ) - cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] + + @overload + def begin_update_by_id( + self, + resource_id: str, + api_version: str, + parameters: IO, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> LROPoller[_models.GenericResource]: + """Updates a resource by ID. + + :param resource_id: The fully qualified ID of the resource, including the resource name and + resource type. Use the format, + /subscriptions/{guid}/resourceGroups/{resource-group-name}/{resource-provider-namespace}/{resource-type}/{resource-name}. + Required. + :type resource_id: str + :param api_version: The API version to use for the operation. Required. + :type api_version: str + :param parameters: Update resource parameters. Required. + :type parameters: IO + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be ARMPolling. Pass in False for this + operation to not poll, or pass in your own initialized polling object for a personal polling + strategy. + :paramtype polling: bool or ~azure.core.polling.PollingMethod + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of LROPoller that returns either GenericResource or the result of + cls(response) + :rtype: + ~azure.core.polling.LROPoller[~azure.mgmt.resource.resources.v2016_09_01.models.GenericResource] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace + def begin_update_by_id( + self, resource_id: str, api_version: str, parameters: Union[_models.GenericResource, IO], **kwargs: Any + ) -> LROPoller[_models.GenericResource]: + """Updates a resource by ID. + + :param resource_id: The fully qualified ID of the resource, including the resource name and + resource type. Use the format, + /subscriptions/{guid}/resourceGroups/{resource-group-name}/{resource-provider-namespace}/{resource-type}/{resource-name}. + Required. + :type resource_id: str + :param api_version: The API version to use for the operation. Required. + :type api_version: str + :param parameters: Update resource parameters. Is either a model type or a IO type. Required. + :type parameters: ~azure.mgmt.resource.resources.v2016_09_01.models.GenericResource or IO + :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. + Default value is None. + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be ARMPolling. Pass in False for this + operation to not poll, or pass in your own initialized polling object for a personal polling + strategy. + :paramtype polling: bool or ~azure.core.polling.PollingMethod + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of LROPoller that returns either GenericResource or the result of + cls(response) + :rtype: + ~azure.core.polling.LROPoller[~azure.mgmt.resource.resources.v2016_09_01.models.GenericResource] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = kwargs.pop("params", {}) or {} + + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.GenericResource] + polling = kwargs.pop("polling", True) # type: Union[bool, PollingMethod] + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token = kwargs.pop("continuation_token", None) # type: Optional[str] if cont_token is None: - raw_result = self._update_by_id_initial( + raw_result = self._update_by_id_initial( # type: ignore resource_id=resource_id, api_version=api_version, parameters=parameters, content_type=content_type, - cls=lambda x,y,z: x, + cls=lambda x, y, z: x, + headers=_headers, + params=_params, **kwargs ) - kwargs.pop('error_map', None) + kwargs.pop("error_map", None) def get_long_running_output(pipeline_response): - response = pipeline_response.http_response - deserialized = self._deserialize('GenericResource', pipeline_response) + deserialized = self._deserialize("GenericResource", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - - if polling is True: polling_method = ARMPolling(lro_delay, **kwargs) - elif polling is False: polling_method = NoPolling() - else: polling_method = polling + if polling is True: + polling_method = cast(PollingMethod, ARMPolling(lro_delay, **kwargs)) # type: PollingMethod + elif polling is False: + polling_method = cast(PollingMethod, NoPolling()) + else: + polling_method = polling if cont_token: return LROPoller.from_continuation_token( polling_method=polling_method, continuation_token=cont_token, client=self._client, - deserialization_callback=get_long_running_output + deserialization_callback=get_long_running_output, ) return LROPoller(self._client, raw_result, get_long_running_output, polling_method) - begin_update_by_id.metadata = {'url': "/{resourceId}"} # type: ignore + begin_update_by_id.metadata = {"url": "/{resourceId}"} # type: ignore @distributed_trace - def get_by_id( - self, - resource_id: str, - api_version: str, - **kwargs: Any - ) -> "_models.GenericResource": + def get_by_id(self, resource_id: str, api_version: str, **kwargs: Any) -> _models.GenericResource: """Gets a resource by ID. :param resource_id: The fully qualified ID of the resource, including the resource name and resource type. Use the format, /subscriptions/{guid}/resourceGroups/{resource-group-name}/{resource-provider-namespace}/{resource-type}/{resource-name}. + Required. :type resource_id: str - :param api_version: The API version to use for the operation. + :param api_version: The API version to use for the operation. Required. :type api_version: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: GenericResource, or the result of cls(response) + :return: GenericResource or the result of cls(response) :rtype: ~azure.mgmt.resource.resources.v2016_09_01.models.GenericResource - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.GenericResource"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = kwargs.pop("params", {}) or {} + + cls = kwargs.pop("cls", None) # type: ClsType[_models.GenericResource] - request = build_resources_get_by_id_request( resource_id=resource_id, api_version=api_version, - template_url=self.get_by_id.metadata['url'], + template_url=self.get_by_id.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) - deserialized = self._deserialize('GenericResource', pipeline_response) + deserialized = self._deserialize("GenericResource", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - get_by_id.metadata = {'url': "/{resourceId}"} # type: ignore + get_by_id.metadata = {"url": "/{resourceId}"} # type: ignore -class TagsOperations(object): - """TagsOperations operations. - You should not instantiate this class directly. Instead, you should create a Client instance that - instantiates it for you and attaches it as an attribute. +class TagsOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. - :ivar models: Alias to model classes used in this operation group. - :type models: ~azure.mgmt.resource.resources.v2016_09_01.models - :param client: Client for service requests. - :param config: Configuration of service client. - :param serializer: An object model serializer. - :param deserializer: An object model deserializer. + Instead, you should access the following operations through + :class:`~azure.mgmt.resource.resources.v2016_09_01.ResourceManagementClient`'s + :attr:`tags` attribute. """ models = _models - def __init__(self, client, config, serializer, deserializer): - self._client = client - self._serialize = serializer - self._deserialize = deserializer - self._config = config + def __init__(self, *args, **kwargs): + input_args = list(args) + self._client = input_args.pop(0) if input_args else kwargs.pop("client") + self._config = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") @distributed_trace def delete_value( # pylint: disable=inconsistent-return-statements - self, - tag_name: str, - tag_value: str, - **kwargs: Any + self, tag_name: str, tag_value: str, **kwargs: Any ) -> None: """Deletes a tag value. - :param tag_name: The name of the tag. + :param tag_name: The name of the tag. Required. :type tag_name: str - :param tag_value: The value of the tag to delete. + :param tag_value: The value of the tag to delete. Required. :type tag_value: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: None, or the result of cls(response) + :return: None or the result of cls(response) :rtype: None - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType[None] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) - api_version = kwargs.pop('api_version', "2016-09-01") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2016-09-01")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[None] - request = build_tags_delete_value_request( tag_name=tag_name, tag_value=tag_value, subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.delete_value.metadata['url'], + template_url=self.delete_value.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200, 204]: @@ -4386,51 +5059,51 @@ def delete_value( # pylint: disable=inconsistent-return-statements if cls: return cls(pipeline_response, None, {}) - delete_value.metadata = {'url': "/subscriptions/{subscriptionId}/tagNames/{tagName}/tagValues/{tagValue}"} # type: ignore - + delete_value.metadata = {"url": "/subscriptions/{subscriptionId}/tagNames/{tagName}/tagValues/{tagValue}"} # type: ignore @distributed_trace - def create_or_update_value( - self, - tag_name: str, - tag_value: str, - **kwargs: Any - ) -> "_models.TagValue": + def create_or_update_value(self, tag_name: str, tag_value: str, **kwargs: Any) -> _models.TagValue: """Creates a tag value. The name of the tag must already exist. - :param tag_name: The name of the tag. + :param tag_name: The name of the tag. Required. :type tag_name: str - :param tag_value: The value of the tag to create. + :param tag_value: The value of the tag to create. Required. :type tag_value: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: TagValue, or the result of cls(response) + :return: TagValue or the result of cls(response) :rtype: ~azure.mgmt.resource.resources.v2016_09_01.models.TagValue - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.TagValue"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + 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', "2016-09-01") # type: str + api_version = kwargs.pop("api_version", _params.pop("api-version", "2016-09-01")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[_models.TagValue] - request = build_tags_create_or_update_value_request( tag_name=tag_name, tag_value=tag_value, subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.create_or_update_value.metadata['url'], + template_url=self.create_or_update_value.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200, 201]: @@ -4438,61 +5111,62 @@ def create_or_update_value( raise HttpResponseError(response=response, error_format=ARMErrorFormat) if response.status_code == 200: - deserialized = self._deserialize('TagValue', pipeline_response) + deserialized = self._deserialize("TagValue", pipeline_response) if response.status_code == 201: - deserialized = self._deserialize('TagValue', pipeline_response) + deserialized = self._deserialize("TagValue", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - create_or_update_value.metadata = {'url': "/subscriptions/{subscriptionId}/tagNames/{tagName}/tagValues/{tagValue}"} # type: ignore - + create_or_update_value.metadata = {"url": "/subscriptions/{subscriptionId}/tagNames/{tagName}/tagValues/{tagValue}"} # type: ignore @distributed_trace - def create_or_update( - self, - tag_name: str, - **kwargs: Any - ) -> "_models.TagDetails": + def create_or_update(self, tag_name: str, **kwargs: Any) -> _models.TagDetails: """Creates a tag in the subscription. The tag name can have a maximum of 512 characters and is case insensitive. Tag names created by Azure have prefixes of microsoft, azure, or windows. You cannot create tags with one of these prefixes. - :param tag_name: The name of the tag to create. + :param tag_name: The name of the tag to create. Required. :type tag_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: TagDetails, or the result of cls(response) + :return: TagDetails or the result of cls(response) :rtype: ~azure.mgmt.resource.resources.v2016_09_01.models.TagDetails - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.TagDetails"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + 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', "2016-09-01") # type: str + api_version = kwargs.pop("api_version", _params.pop("api-version", "2016-09-01")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[_models.TagDetails] - request = build_tags_create_or_update_request( tag_name=tag_name, subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.create_or_update.metadata['url'], + template_url=self.create_or_update.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200, 201]: @@ -4500,59 +5174,60 @@ def create_or_update( raise HttpResponseError(response=response, error_format=ARMErrorFormat) if response.status_code == 200: - deserialized = self._deserialize('TagDetails', pipeline_response) + deserialized = self._deserialize("TagDetails", pipeline_response) if response.status_code == 201: - deserialized = self._deserialize('TagDetails', pipeline_response) + deserialized = self._deserialize("TagDetails", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - create_or_update.metadata = {'url': "/subscriptions/{subscriptionId}/tagNames/{tagName}"} # type: ignore - + create_or_update.metadata = {"url": "/subscriptions/{subscriptionId}/tagNames/{tagName}"} # type: ignore @distributed_trace - def delete( # pylint: disable=inconsistent-return-statements - self, - tag_name: str, - **kwargs: Any - ) -> None: + def delete(self, tag_name: str, **kwargs: Any) -> None: # pylint: disable=inconsistent-return-statements """Deletes a tag from the subscription. You must remove all values from a resource tag before you can delete it. - :param tag_name: The name of the tag. + :param tag_name: The name of the tag. Required. :type tag_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: None, or the result of cls(response) + :return: None or the result of cls(response) :rtype: None - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType[None] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + 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', "2016-09-01") # type: str + api_version = kwargs.pop("api_version", _params.pop("api-version", "2016-09-01")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[None] - request = build_tags_delete_request( tag_name=tag_name, subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.delete.metadata['url'], + template_url=self.delete.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200, 204]: @@ -4562,48 +5237,53 @@ def delete( # pylint: disable=inconsistent-return-statements if cls: return cls(pipeline_response, None, {}) - delete.metadata = {'url': "/subscriptions/{subscriptionId}/tagNames/{tagName}"} # type: ignore - + delete.metadata = {"url": "/subscriptions/{subscriptionId}/tagNames/{tagName}"} # type: ignore @distributed_trace - def list( - self, - **kwargs: Any - ) -> Iterable["_models.TagsListResult"]: + def list(self, **kwargs: Any) -> Iterable["_models.TagDetails"]: """Gets the names and values of all resource tags that are defined in a subscription. :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either TagsListResult or the result of cls(response) + :return: An iterator like instance of either TagDetails or the result of cls(response) :rtype: - ~azure.core.paging.ItemPaged[~azure.mgmt.resource.resources.v2016_09_01.models.TagsListResult] - :raises: ~azure.core.exceptions.HttpResponseError + ~azure.core.paging.ItemPaged[~azure.mgmt.resource.resources.v2016_09_01.models.TagDetails] + :raises ~azure.core.exceptions.HttpResponseError: """ - api_version = kwargs.pop('api_version', "2016-09-01") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2016-09-01")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[_models.TagsListResult] - cls = kwargs.pop('cls', None) # type: ClsType["_models.TagsListResult"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) + def prepare_request(next_link=None): if not next_link: - + request = build_tags_list_request( subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.list.metadata['url'], + template_url=self.list.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore else: - - request = build_tags_list_request( - subscription_id=self._config.subscription_id, - template_url=next_link, - ) + # make call to next link with the client's api-version + _parsed_next_link = urlparse(next_link) + _next_request_params = case_insensitive_dict(parse_qs(_parsed_next_link.query)) + _next_request_params["api-version"] = self._config.api_version + request = HttpRequest("GET", urljoin(next_link, _parsed_next_link.path), params=_next_request_params) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore request.method = "GET" return request @@ -4617,10 +5297,8 @@ def extract_data(pipeline_response): def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) response = pipeline_response.http_response @@ -4630,149 +5308,151 @@ def get_next(next_link=None): return pipeline_response + return ItemPaged(get_next, extract_data) - return ItemPaged( - get_next, extract_data - ) - list.metadata = {'url': "/subscriptions/{subscriptionId}/tagNames"} # type: ignore -class DeploymentOperationsOperations(object): - """DeploymentOperationsOperations operations. - - You should not instantiate this class directly. Instead, you should create a Client instance that - instantiates it for you and attaches it as an attribute. - - :ivar models: Alias to model classes used in this operation group. - :type models: ~azure.mgmt.resource.resources.v2016_09_01.models - :param client: Client for service requests. - :param config: Configuration of service client. - :param serializer: An object model serializer. - :param deserializer: An object model deserializer. + list.metadata = {"url": "/subscriptions/{subscriptionId}/tagNames"} # type: ignore + + +class DeploymentOperationsOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. + + Instead, you should access the following operations through + :class:`~azure.mgmt.resource.resources.v2016_09_01.ResourceManagementClient`'s + :attr:`deployment_operations` attribute. """ models = _models - def __init__(self, client, config, serializer, deserializer): - self._client = client - self._serialize = serializer - self._deserialize = deserializer - self._config = config + def __init__(self, *args, **kwargs): + input_args = list(args) + self._client = input_args.pop(0) if input_args else kwargs.pop("client") + self._config = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") @distributed_trace def get( - self, - resource_group_name: str, - deployment_name: str, - operation_id: str, - **kwargs: Any - ) -> "_models.DeploymentOperation": + self, resource_group_name: str, deployment_name: str, operation_id: str, **kwargs: Any + ) -> _models.DeploymentOperation: """Gets a deployments operation. :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. :type resource_group_name: str - :param deployment_name: The name of the deployment. + :param deployment_name: The name of the deployment. Required. :type deployment_name: str - :param operation_id: The ID of the operation to get. + :param operation_id: The ID of the operation to get. Required. :type operation_id: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: DeploymentOperation, or the result of cls(response) + :return: DeploymentOperation or the result of cls(response) :rtype: ~azure.mgmt.resource.resources.v2016_09_01.models.DeploymentOperation - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.DeploymentOperation"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + 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', "2016-09-01") # type: str + api_version = kwargs.pop("api_version", _params.pop("api-version", "2016-09-01")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[_models.DeploymentOperation] - request = build_deployment_operations_get_request( resource_group_name=resource_group_name, deployment_name=deployment_name, operation_id=operation_id, subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.get.metadata['url'], + template_url=self.get.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) - deserialized = self._deserialize('DeploymentOperation', pipeline_response) + deserialized = self._deserialize("DeploymentOperation", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - get.metadata = {'url': "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/deployments/{deploymentName}/operations/{operationId}"} # type: ignore - + get.metadata = {"url": "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/deployments/{deploymentName}/operations/{operationId}"} # type: ignore @distributed_trace def list( - self, - resource_group_name: str, - deployment_name: str, - top: Optional[int] = None, - **kwargs: Any - ) -> Iterable["_models.DeploymentOperationsListResult"]: + self, resource_group_name: str, deployment_name: str, top: Optional[int] = None, **kwargs: Any + ) -> Iterable["_models.DeploymentOperation"]: """Gets all deployments operations for a deployment. :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. :type resource_group_name: str - :param deployment_name: The name of the deployment with the operation to get. + :param deployment_name: The name of the deployment with the operation to get. Required. :type deployment_name: str :param top: The number of results to return. Default value is None. :type top: int :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either DeploymentOperationsListResult or the result of - cls(response) + :return: An iterator like instance of either DeploymentOperation or the result of cls(response) :rtype: - ~azure.core.paging.ItemPaged[~azure.mgmt.resource.resources.v2016_09_01.models.DeploymentOperationsListResult] - :raises: ~azure.core.exceptions.HttpResponseError + ~azure.core.paging.ItemPaged[~azure.mgmt.resource.resources.v2016_09_01.models.DeploymentOperation] + :raises ~azure.core.exceptions.HttpResponseError: """ - api_version = kwargs.pop('api_version', "2016-09-01") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2016-09-01")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[_models.DeploymentOperationsListResult] - cls = kwargs.pop('cls', None) # type: ClsType["_models.DeploymentOperationsListResult"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) + def prepare_request(next_link=None): if not next_link: - + request = build_deployment_operations_list_request( resource_group_name=resource_group_name, deployment_name=deployment_name, subscription_id=self._config.subscription_id, - api_version=api_version, top=top, - template_url=self.list.metadata['url'], + 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.url = self._client.format_url(request.url) # type: ignore else: - - request = build_deployment_operations_list_request( - resource_group_name=resource_group_name, - deployment_name=deployment_name, - subscription_id=self._config.subscription_id, - template_url=next_link, - ) + # make call to next link with the client's api-version + _parsed_next_link = urlparse(next_link) + _next_request_params = case_insensitive_dict(parse_qs(_parsed_next_link.query)) + _next_request_params["api-version"] = self._config.api_version + request = HttpRequest("GET", urljoin(next_link, _parsed_next_link.path), params=_next_request_params) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore request.method = "GET" return request @@ -4786,10 +5466,8 @@ def extract_data(pipeline_response): def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) response = pipeline_response.http_response @@ -4799,8 +5477,6 @@ def get_next(next_link=None): return pipeline_response + return ItemPaged(get_next, extract_data) - return ItemPaged( - get_next, extract_data - ) - list.metadata = {'url': "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/deployments/{deploymentName}/operations"} # type: ignore + list.metadata = {"url": "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/deployments/{deploymentName}/operations"} # type: ignore diff --git a/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/resources/v2016_09_01/operations/_patch.py b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/resources/v2016_09_01/operations/_patch.py new file mode 100644 index 0000000000000..f7dd32510333d --- /dev/null +++ b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/resources/v2016_09_01/operations/_patch.py @@ -0,0 +1,20 @@ +# ------------------------------------ +# Copyright (c) Microsoft Corporation. +# Licensed under the MIT License. +# ------------------------------------ +"""Customize generated code here. + +Follow our quickstart for examples: https://aka.ms/azsdk/python/dpcodegen/python/customize +""" +from typing import List + +__all__: List[str] = [] # Add all objects you want publicly available to users at this package level + + +def patch_sdk(): + """Do not remove from this file. + + `patch_sdk` is a last resort escape hatch that allows you to do customizations + you can't accomplish using the techniques described in + https://aka.ms/azsdk/python/dpcodegen/python/customize + """ diff --git a/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/resources/v2017_05_10/__init__.py b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/resources/v2017_05_10/__init__.py index 449220069f2f2..2b201470d075e 100644 --- a/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/resources/v2017_05_10/__init__.py +++ b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/resources/v2017_05_10/__init__.py @@ -10,9 +10,15 @@ from ._version import VERSION __version__ = VERSION -__all__ = ['ResourceManagementClient'] -# `._patch.py` is used for handwritten extensions to the generated code -# Example: https://github.com/Azure/azure-sdk-for-python/blob/main/doc/dev/customize_code/how-to-patch-sdk-code.md -from ._patch import patch_sdk -patch_sdk() +try: + from ._patch import __all__ as _patch_all + from ._patch import * # type: ignore # pylint: disable=unused-wildcard-import +except ImportError: + _patch_all = [] +from ._patch import patch_sdk as _patch_sdk + +__all__ = ["ResourceManagementClient"] +__all__.extend([p for p in _patch_all if p not in __all__]) + +_patch_sdk() diff --git a/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/resources/v2017_05_10/_configuration.py b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/resources/v2017_05_10/_configuration.py index a67369333750b..29d8a09c0edb9 100644 --- a/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/resources/v2017_05_10/_configuration.py +++ b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/resources/v2017_05_10/_configuration.py @@ -25,23 +25,18 @@ class ResourceManagementClientConfiguration(Configuration): # pylint: disable=t Note that all parameters used to create this instance are saved as instance attributes. - :param credential: Credential needed for the client to connect to Azure. + :param credential: Credential needed for the client to connect to Azure. Required. :type credential: ~azure.core.credentials.TokenCredential - :param subscription_id: The ID of the target subscription. + :param subscription_id: The ID of the target subscription. Required. :type subscription_id: str :keyword api_version: Api Version. Default value is "2017-05-10". Note that overriding this default value may result in unsupported behavior. :paramtype api_version: str """ - def __init__( - self, - credential: "TokenCredential", - subscription_id: str, - **kwargs: Any - ) -> None: + def __init__(self, credential: "TokenCredential", subscription_id: str, **kwargs: Any) -> None: super(ResourceManagementClientConfiguration, self).__init__(**kwargs) - api_version = kwargs.pop('api_version', "2017-05-10") # type: str + api_version = kwargs.pop("api_version", "2017-05-10") # type: str if credential is None: raise ValueError("Parameter 'credential' must not be None.") @@ -51,23 +46,24 @@ def __init__( self.credential = credential self.subscription_id = subscription_id self.api_version = api_version - self.credential_scopes = kwargs.pop('credential_scopes', ['https://management.azure.com/.default']) - kwargs.setdefault('sdk_moniker', 'mgmt-resource/{}'.format(VERSION)) + self.credential_scopes = kwargs.pop("credential_scopes", ["https://management.azure.com/.default"]) + kwargs.setdefault("sdk_moniker", "mgmt-resource/{}".format(VERSION)) self._configure(**kwargs) def _configure( - self, - **kwargs # type: Any + self, **kwargs # type: Any ): # type: (...) -> 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) - self.logging_policy = kwargs.get('logging_policy') or policies.NetworkTraceLoggingPolicy(**kwargs) - self.http_logging_policy = kwargs.get('http_logging_policy') or ARMHttpLoggingPolicy(**kwargs) - self.retry_policy = kwargs.get('retry_policy') or policies.RetryPolicy(**kwargs) - self.custom_hook_policy = kwargs.get('custom_hook_policy') or policies.CustomHookPolicy(**kwargs) - self.redirect_policy = kwargs.get('redirect_policy') or policies.RedirectPolicy(**kwargs) - self.authentication_policy = kwargs.get('authentication_policy') + 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) + self.logging_policy = kwargs.get("logging_policy") or policies.NetworkTraceLoggingPolicy(**kwargs) + self.http_logging_policy = kwargs.get("http_logging_policy") or ARMHttpLoggingPolicy(**kwargs) + self.retry_policy = kwargs.get("retry_policy") or policies.RetryPolicy(**kwargs) + self.custom_hook_policy = kwargs.get("custom_hook_policy") or policies.CustomHookPolicy(**kwargs) + self.redirect_policy = kwargs.get("redirect_policy") or policies.RedirectPolicy(**kwargs) + self.authentication_policy = kwargs.get("authentication_policy") if self.credential and not self.authentication_policy: - self.authentication_policy = ARMChallengeAuthenticationPolicy(self.credential, *self.credential_scopes, **kwargs) + self.authentication_policy = ARMChallengeAuthenticationPolicy( + self.credential, *self.credential_scopes, **kwargs + ) diff --git a/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/resources/v2017_05_10/_metadata.json b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/resources/v2017_05_10/_metadata.json index 41b8fcd8b6e22..58c261f9e0bfa 100644 --- a/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/resources/v2017_05_10/_metadata.json +++ b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/resources/v2017_05_10/_metadata.json @@ -10,20 +10,20 @@ "azure_arm": true, "has_lro_operations": true, "client_side_validation": false, - "sync_imports": "{\"typing\": {\"azurecore\": {\"azure.core.credentials\": [\"TokenCredential\"]}}, \"regular\": {\"azurecore\": {\"azure.profiles\": [\"KnownProfiles\", \"ProfileDefinition\"], \"azure.profiles.multiapiclient\": [\"MultiApiClientMixin\"], \"azure.mgmt.core\": [\"ARMPipelineClient\"]}, \"local\": {\"._configuration\": [\"ResourceManagementClientConfiguration\"]}, \"thirdparty\": {\"msrest\": [\"Deserializer\", \"Serializer\"]}}, \"conditional\": {\"stdlib\": {\"typing\": [\"Any\", \"Optional\"]}}}", - "async_imports": "{\"typing\": {\"azurecore\": {\"azure.core.credentials_async\": [\"AsyncTokenCredential\"], \"azure.core.credentials\": [\"TokenCredential\"]}}, \"regular\": {\"azurecore\": {\"azure.profiles\": [\"KnownProfiles\", \"ProfileDefinition\"], \"azure.profiles.multiapiclient\": [\"MultiApiClientMixin\"], \"azure.mgmt.core\": [\"AsyncARMPipelineClient\"]}, \"local\": {\"._configuration\": [\"ResourceManagementClientConfiguration\"]}, \"thirdparty\": {\"msrest\": [\"Deserializer\", \"Serializer\"]}}, \"conditional\": {\"stdlib\": {\"typing\": [\"Any\", \"Optional\"]}}}" + "sync_imports": "{\"conditional\": {\"stdlib\": {\"typing\": [\"Any\", \"Optional\"]}}, \"regular\": {\"azurecore\": {\"azure.mgmt.core\": [\"ARMPipelineClient\"], \"azure.profiles\": [\"KnownProfiles\", \"ProfileDefinition\"], \"azure.profiles.multiapiclient\": [\"MultiApiClientMixin\"]}, \"local\": {\"._configuration\": [\"ResourceManagementClientConfiguration\"], \".._serialization\": [\"Deserializer\", \"Serializer\"]}}, \"typing\": {\"azurecore\": {\"azure.core.credentials\": [\"TokenCredential\"]}}}", + "async_imports": "{\"conditional\": {\"stdlib\": {\"typing\": [\"Any\", \"Optional\"]}}, \"regular\": {\"azurecore\": {\"azure.mgmt.core\": [\"AsyncARMPipelineClient\"], \"azure.profiles\": [\"KnownProfiles\", \"ProfileDefinition\"], \"azure.profiles.multiapiclient\": [\"MultiApiClientMixin\"]}, \"local\": {\"._configuration\": [\"ResourceManagementClientConfiguration\"], \"..._serialization\": [\"Deserializer\", \"Serializer\"]}}, \"typing\": {\"azurecore\": {\"azure.core.credentials_async\": [\"AsyncTokenCredential\"]}}}" }, "global_parameters": { "sync": { "credential": { - "signature": "credential, # type: \"TokenCredential\"", - "description": "Credential needed for the client to connect to Azure.", + "signature": "credential: \"TokenCredential\",", + "description": "Credential needed for the client to connect to Azure. Required.", "docstring_type": "~azure.core.credentials.TokenCredential", "required": true }, "subscription_id": { - "signature": "subscription_id, # type: str", - "description": "The ID of the target subscription.", + "signature": "subscription_id: str,", + "description": "The ID of the target subscription. Required.", "docstring_type": "str", "required": true } @@ -31,13 +31,13 @@ "async": { "credential": { "signature": "credential: \"AsyncTokenCredential\",", - "description": "Credential needed for the client to connect to Azure.", + "description": "Credential needed for the client to connect to Azure. Required.", "docstring_type": "~azure.core.credentials_async.AsyncTokenCredential", "required": true }, "subscription_id": { "signature": "subscription_id: str,", - "description": "The ID of the target subscription.", + "description": "The ID of the target subscription. Required.", "docstring_type": "str", "required": true } @@ -54,7 +54,7 @@ "required": false }, "base_url": { - "signature": "base_url=\"https://management.azure.com\", # type: str", + "signature": "base_url: str = \"https://management.azure.com\",", "description": "Service URL", "docstring_type": "str", "required": false diff --git a/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/resources/v2017_05_10/_patch.py b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/resources/v2017_05_10/_patch.py index 74e48ecd07cf3..f99e77fef9861 100644 --- a/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/resources/v2017_05_10/_patch.py +++ b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/resources/v2017_05_10/_patch.py @@ -28,4 +28,4 @@ # This file is used for handwritten extensions to the generated code. Example: # https://github.com/Azure/azure-sdk-for-python/blob/main/doc/dev/customize_code/how-to-patch-sdk-code.md def patch_sdk(): - pass \ No newline at end of file + pass diff --git a/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/resources/v2017_05_10/_resource_management_client.py b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/resources/v2017_05_10/_resource_management_client.py index 3dfe69851cc14..4b1f6be065feb 100644 --- a/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/resources/v2017_05_10/_resource_management_client.py +++ b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/resources/v2017_05_10/_resource_management_client.py @@ -9,20 +9,27 @@ from copy import deepcopy from typing import Any, TYPE_CHECKING -from msrest import Deserializer, Serializer - from azure.core.rest import HttpRequest, HttpResponse from azure.mgmt.core import ARMPipelineClient from . import models +from .._serialization import Deserializer, Serializer from ._configuration import ResourceManagementClientConfiguration -from .operations import DeploymentOperationsOperations, DeploymentsOperations, ProvidersOperations, ResourceGroupsOperations, ResourcesOperations, TagsOperations +from .operations import ( + DeploymentOperationsOperations, + DeploymentsOperations, + ProvidersOperations, + ResourceGroupsOperations, + ResourcesOperations, + TagsOperations, +) if TYPE_CHECKING: # pylint: disable=unused-import,ungrouped-imports from azure.core.credentials import TokenCredential -class ResourceManagementClient: + +class ResourceManagementClient: # pylint: disable=client-accepts-api-version-keyword """Provides operations for working with resources and resource groups. :ivar deployments: DeploymentsOperations operations @@ -40,9 +47,9 @@ class ResourceManagementClient: :ivar deployment_operations: DeploymentOperationsOperations operations :vartype deployment_operations: azure.mgmt.resource.resources.v2017_05_10.operations.DeploymentOperationsOperations - :param credential: Credential needed for the client to connect to Azure. + :param credential: Credential needed for the client to connect to Azure. Required. :type credential: ~azure.core.credentials.TokenCredential - :param subscription_id: The ID of the target subscription. + :param subscription_id: The ID of the target subscription. Required. :type subscription_id: str :param base_url: Service URL. Default value is "https://management.azure.com". :type base_url: str @@ -60,7 +67,9 @@ def __init__( base_url: str = "https://management.azure.com", **kwargs: Any ) -> None: - self._config = ResourceManagementClientConfiguration(credential=credential, subscription_id=subscription_id, **kwargs) + self._config = ResourceManagementClientConfiguration( + credential=credential, subscription_id=subscription_id, **kwargs + ) self._client = ARMPipelineClient(base_url=base_url, config=self._config, **kwargs) client_models = {k: v for k, v in models.__dict__.items() if isinstance(v, type)} @@ -72,14 +81,11 @@ def __init__( self.resources = ResourcesOperations(self._client, self._config, self._serialize, self._deserialize) self.resource_groups = ResourceGroupsOperations(self._client, self._config, self._serialize, self._deserialize) self.tags = TagsOperations(self._client, self._config, self._serialize, self._deserialize) - self.deployment_operations = DeploymentOperationsOperations(self._client, self._config, self._serialize, self._deserialize) - + self.deployment_operations = DeploymentOperationsOperations( + self._client, self._config, self._serialize, self._deserialize + ) - def _send_request( - self, - request: HttpRequest, - **kwargs: Any - ) -> HttpResponse: + def _send_request(self, request: HttpRequest, **kwargs: Any) -> HttpResponse: """Runs the network request through the client's chained policies. >>> from azure.core.rest import HttpRequest @@ -88,7 +94,7 @@ def _send_request( >>> response = client._send_request(request) - For more information on this code flow, see https://aka.ms/azsdk/python/protocol/quickstart + For more information on this code flow, see https://aka.ms/azsdk/dpcodegen/python/send_request :param request: The network request you want to make. Required. :type request: ~azure.core.rest.HttpRequest diff --git a/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/resources/v2017_05_10/_vendor.py b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/resources/v2017_05_10/_vendor.py index 138f663c53a4e..9aad73fc743e7 100644 --- a/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/resources/v2017_05_10/_vendor.py +++ b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/resources/v2017_05_10/_vendor.py @@ -7,6 +7,7 @@ from azure.core.pipeline.transport import HttpRequest + def _convert_request(request, files=None): data = request.content if not files else None request = HttpRequest(method=request.method, url=request.url, headers=request.headers, data=data) @@ -14,6 +15,7 @@ def _convert_request(request, files=None): request.set_formdata_body(files) return request + def _format_url_section(template, **kwargs): components = template.split("/") while components: @@ -21,7 +23,5 @@ def _format_url_section(template, **kwargs): 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 - ] + components = [c for c in formatted_components if "{}".format(key.args[0]) not in c] template = "/".join(components) diff --git a/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/resources/v2017_05_10/_version.py b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/resources/v2017_05_10/_version.py index a012ac01c480c..e5754a47ce68f 100644 --- a/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/resources/v2017_05_10/_version.py +++ b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/resources/v2017_05_10/_version.py @@ -6,4 +6,4 @@ # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -VERSION = "21.1.0" +VERSION = "1.0.0b1" diff --git a/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/resources/v2017_05_10/aio/__init__.py b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/resources/v2017_05_10/aio/__init__.py index c6c3cf64a37a6..98d6782c2530c 100644 --- a/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/resources/v2017_05_10/aio/__init__.py +++ b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/resources/v2017_05_10/aio/__init__.py @@ -7,9 +7,15 @@ # -------------------------------------------------------------------------- from ._resource_management_client import ResourceManagementClient -__all__ = ['ResourceManagementClient'] -# `._patch.py` is used for handwritten extensions to the generated code -# Example: https://github.com/Azure/azure-sdk-for-python/blob/main/doc/dev/customize_code/how-to-patch-sdk-code.md -from ._patch import patch_sdk -patch_sdk() +try: + from ._patch import __all__ as _patch_all + from ._patch import * # type: ignore # pylint: disable=unused-wildcard-import +except ImportError: + _patch_all = [] +from ._patch import patch_sdk as _patch_sdk + +__all__ = ["ResourceManagementClient"] +__all__.extend([p for p in _patch_all if p not in __all__]) + +_patch_sdk() diff --git a/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/resources/v2017_05_10/aio/_configuration.py b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/resources/v2017_05_10/aio/_configuration.py index f07972b5b1c92..3bdbdf2b0598b 100644 --- a/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/resources/v2017_05_10/aio/_configuration.py +++ b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/resources/v2017_05_10/aio/_configuration.py @@ -25,23 +25,18 @@ class ResourceManagementClientConfiguration(Configuration): # pylint: disable=t Note that all parameters used to create this instance are saved as instance attributes. - :param credential: Credential needed for the client to connect to Azure. + :param credential: Credential needed for the client to connect to Azure. Required. :type credential: ~azure.core.credentials_async.AsyncTokenCredential - :param subscription_id: The ID of the target subscription. + :param subscription_id: The ID of the target subscription. Required. :type subscription_id: str :keyword api_version: Api Version. Default value is "2017-05-10". Note that overriding this default value may result in unsupported behavior. :paramtype api_version: str """ - def __init__( - self, - credential: "AsyncTokenCredential", - subscription_id: str, - **kwargs: Any - ) -> None: + def __init__(self, credential: "AsyncTokenCredential", subscription_id: str, **kwargs: Any) -> None: super(ResourceManagementClientConfiguration, self).__init__(**kwargs) - api_version = kwargs.pop('api_version', "2017-05-10") # type: str + api_version = kwargs.pop("api_version", "2017-05-10") # type: str if credential is None: raise ValueError("Parameter 'credential' must not be None.") @@ -51,22 +46,21 @@ def __init__( self.credential = credential self.subscription_id = subscription_id self.api_version = api_version - self.credential_scopes = kwargs.pop('credential_scopes', ['https://management.azure.com/.default']) - kwargs.setdefault('sdk_moniker', 'mgmt-resource/{}'.format(VERSION)) + self.credential_scopes = kwargs.pop("credential_scopes", ["https://management.azure.com/.default"]) + kwargs.setdefault("sdk_moniker", "mgmt-resource/{}".format(VERSION)) self._configure(**kwargs) - 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) - self.logging_policy = kwargs.get('logging_policy') or policies.NetworkTraceLoggingPolicy(**kwargs) - self.http_logging_policy = kwargs.get('http_logging_policy') or ARMHttpLoggingPolicy(**kwargs) - self.retry_policy = kwargs.get('retry_policy') or policies.AsyncRetryPolicy(**kwargs) - self.custom_hook_policy = kwargs.get('custom_hook_policy') or policies.CustomHookPolicy(**kwargs) - self.redirect_policy = kwargs.get('redirect_policy') or policies.AsyncRedirectPolicy(**kwargs) - self.authentication_policy = kwargs.get('authentication_policy') + 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) + self.logging_policy = kwargs.get("logging_policy") or policies.NetworkTraceLoggingPolicy(**kwargs) + self.http_logging_policy = kwargs.get("http_logging_policy") or ARMHttpLoggingPolicy(**kwargs) + self.retry_policy = kwargs.get("retry_policy") or policies.AsyncRetryPolicy(**kwargs) + self.custom_hook_policy = kwargs.get("custom_hook_policy") or policies.CustomHookPolicy(**kwargs) + self.redirect_policy = kwargs.get("redirect_policy") or policies.AsyncRedirectPolicy(**kwargs) + self.authentication_policy = kwargs.get("authentication_policy") if self.credential and not self.authentication_policy: - self.authentication_policy = AsyncARMChallengeAuthenticationPolicy(self.credential, *self.credential_scopes, **kwargs) + self.authentication_policy = AsyncARMChallengeAuthenticationPolicy( + self.credential, *self.credential_scopes, **kwargs + ) diff --git a/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/resources/v2017_05_10/aio/_patch.py b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/resources/v2017_05_10/aio/_patch.py index 74e48ecd07cf3..f99e77fef9861 100644 --- a/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/resources/v2017_05_10/aio/_patch.py +++ b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/resources/v2017_05_10/aio/_patch.py @@ -28,4 +28,4 @@ # This file is used for handwritten extensions to the generated code. Example: # https://github.com/Azure/azure-sdk-for-python/blob/main/doc/dev/customize_code/how-to-patch-sdk-code.md def patch_sdk(): - pass \ No newline at end of file + pass diff --git a/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/resources/v2017_05_10/aio/_resource_management_client.py b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/resources/v2017_05_10/aio/_resource_management_client.py index 241ecec1232e5..34de0f43db85b 100644 --- a/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/resources/v2017_05_10/aio/_resource_management_client.py +++ b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/resources/v2017_05_10/aio/_resource_management_client.py @@ -9,20 +9,27 @@ from copy import deepcopy from typing import Any, Awaitable, TYPE_CHECKING -from msrest import Deserializer, Serializer - from azure.core.rest import AsyncHttpResponse, HttpRequest from azure.mgmt.core import AsyncARMPipelineClient from .. import models +from ..._serialization import Deserializer, Serializer from ._configuration import ResourceManagementClientConfiguration -from .operations import DeploymentOperationsOperations, DeploymentsOperations, ProvidersOperations, ResourceGroupsOperations, ResourcesOperations, TagsOperations +from .operations import ( + DeploymentOperationsOperations, + DeploymentsOperations, + ProvidersOperations, + ResourceGroupsOperations, + ResourcesOperations, + TagsOperations, +) if TYPE_CHECKING: # pylint: disable=unused-import,ungrouped-imports from azure.core.credentials_async import AsyncTokenCredential -class ResourceManagementClient: + +class ResourceManagementClient: # pylint: disable=client-accepts-api-version-keyword """Provides operations for working with resources and resource groups. :ivar deployments: DeploymentsOperations operations @@ -42,9 +49,9 @@ class ResourceManagementClient: :ivar deployment_operations: DeploymentOperationsOperations operations :vartype deployment_operations: azure.mgmt.resource.resources.v2017_05_10.aio.operations.DeploymentOperationsOperations - :param credential: Credential needed for the client to connect to Azure. + :param credential: Credential needed for the client to connect to Azure. Required. :type credential: ~azure.core.credentials_async.AsyncTokenCredential - :param subscription_id: The ID of the target subscription. + :param subscription_id: The ID of the target subscription. Required. :type subscription_id: str :param base_url: Service URL. Default value is "https://management.azure.com". :type base_url: str @@ -62,7 +69,9 @@ def __init__( base_url: str = "https://management.azure.com", **kwargs: Any ) -> None: - self._config = ResourceManagementClientConfiguration(credential=credential, subscription_id=subscription_id, **kwargs) + self._config = ResourceManagementClientConfiguration( + credential=credential, subscription_id=subscription_id, **kwargs + ) self._client = AsyncARMPipelineClient(base_url=base_url, config=self._config, **kwargs) client_models = {k: v for k, v in models.__dict__.items() if isinstance(v, type)} @@ -74,14 +83,11 @@ def __init__( self.resources = ResourcesOperations(self._client, self._config, self._serialize, self._deserialize) self.resource_groups = ResourceGroupsOperations(self._client, self._config, self._serialize, self._deserialize) self.tags = TagsOperations(self._client, self._config, self._serialize, self._deserialize) - self.deployment_operations = DeploymentOperationsOperations(self._client, self._config, self._serialize, self._deserialize) - + self.deployment_operations = DeploymentOperationsOperations( + self._client, self._config, self._serialize, self._deserialize + ) - def _send_request( - self, - request: HttpRequest, - **kwargs: Any - ) -> Awaitable[AsyncHttpResponse]: + def _send_request(self, request: HttpRequest, **kwargs: Any) -> Awaitable[AsyncHttpResponse]: """Runs the network request through the client's chained policies. >>> from azure.core.rest import HttpRequest @@ -90,7 +96,7 @@ def _send_request( >>> response = await client._send_request(request) - For more information on this code flow, see https://aka.ms/azsdk/python/protocol/quickstart + For more information on this code flow, see https://aka.ms/azsdk/dpcodegen/python/send_request :param request: The network request you want to make. Required. :type request: ~azure.core.rest.HttpRequest diff --git a/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/resources/v2017_05_10/aio/operations/__init__.py b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/resources/v2017_05_10/aio/operations/__init__.py index 45c6c8515ee40..25795ec366414 100644 --- a/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/resources/v2017_05_10/aio/operations/__init__.py +++ b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/resources/v2017_05_10/aio/operations/__init__.py @@ -13,11 +13,17 @@ from ._operations import TagsOperations from ._operations import DeploymentOperationsOperations +from ._patch import __all__ as _patch_all +from ._patch import * # type: ignore # pylint: disable=unused-wildcard-import +from ._patch import patch_sdk as _patch_sdk + __all__ = [ - 'DeploymentsOperations', - 'ProvidersOperations', - 'ResourcesOperations', - 'ResourceGroupsOperations', - 'TagsOperations', - 'DeploymentOperationsOperations', + "DeploymentsOperations", + "ProvidersOperations", + "ResourcesOperations", + "ResourceGroupsOperations", + "TagsOperations", + "DeploymentOperationsOperations", ] +__all__.extend([p for p in _patch_all if p not in __all__]) +_patch_sdk() diff --git a/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/resources/v2017_05_10/aio/operations/_operations.py b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/resources/v2017_05_10/aio/operations/_operations.py index 38125e85a04bd..c82954170775c 100644 --- a/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/resources/v2017_05_10/aio/operations/_operations.py +++ b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/resources/v2017_05_10/aio/operations/_operations.py @@ -6,77 +6,136 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -from typing import Any, AsyncIterable, Callable, Dict, Optional, TypeVar, Union +import sys +from typing import Any, AsyncIterable, Callable, Dict, IO, Optional, TypeVar, Union, cast, overload +from urllib.parse import parse_qs, urljoin, urlparse from azure.core.async_paging import AsyncItemPaged, AsyncList -from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error +from azure.core.exceptions import ( + ClientAuthenticationError, + HttpResponseError, + ResourceExistsError, + ResourceNotFoundError, + ResourceNotModifiedError, + map_error, +) from azure.core.pipeline import PipelineResponse from azure.core.pipeline.transport import AsyncHttpResponse from azure.core.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 from azure.mgmt.core.polling.async_arm_polling import AsyncARMPolling from ... import models as _models from ..._vendor import _convert_request -from ...operations._operations import build_deployment_operations_get_request, build_deployment_operations_list_request, build_deployments_calculate_template_hash_request, build_deployments_cancel_request, build_deployments_check_existence_request, build_deployments_create_or_update_request_initial, build_deployments_delete_request_initial, build_deployments_export_template_request, build_deployments_get_request, build_deployments_list_by_resource_group_request, build_deployments_validate_request, build_providers_get_request, build_providers_list_request, build_providers_register_request, build_providers_unregister_request, build_resource_groups_check_existence_request, build_resource_groups_create_or_update_request, build_resource_groups_delete_request_initial, build_resource_groups_export_template_request, build_resource_groups_get_request, build_resource_groups_list_request, build_resource_groups_update_request, build_resources_check_existence_by_id_request, build_resources_check_existence_request, build_resources_create_or_update_by_id_request_initial, build_resources_create_or_update_request_initial, build_resources_delete_by_id_request_initial, build_resources_delete_request_initial, build_resources_get_by_id_request, build_resources_get_request, build_resources_list_by_resource_group_request, build_resources_list_request, build_resources_move_resources_request_initial, build_resources_update_by_id_request_initial, build_resources_update_request_initial, build_resources_validate_move_resources_request_initial, build_tags_create_or_update_request, build_tags_create_or_update_value_request, build_tags_delete_request, build_tags_delete_value_request, build_tags_list_request -T = TypeVar('T') +from ...operations._operations import ( + build_deployment_operations_get_request, + build_deployment_operations_list_request, + build_deployments_calculate_template_hash_request, + build_deployments_cancel_request, + build_deployments_check_existence_request, + build_deployments_create_or_update_request, + build_deployments_delete_request, + build_deployments_export_template_request, + build_deployments_get_request, + build_deployments_list_by_resource_group_request, + build_deployments_validate_request, + build_providers_get_request, + build_providers_list_request, + build_providers_register_request, + build_providers_unregister_request, + build_resource_groups_check_existence_request, + build_resource_groups_create_or_update_request, + build_resource_groups_delete_request, + build_resource_groups_export_template_request, + build_resource_groups_get_request, + build_resource_groups_list_request, + build_resource_groups_update_request, + build_resources_check_existence_by_id_request, + build_resources_check_existence_request, + build_resources_create_or_update_by_id_request, + build_resources_create_or_update_request, + build_resources_delete_by_id_request, + build_resources_delete_request, + build_resources_get_by_id_request, + build_resources_get_request, + build_resources_list_by_resource_group_request, + build_resources_list_request, + build_resources_move_resources_request, + build_resources_update_by_id_request, + build_resources_update_request, + build_resources_validate_move_resources_request, + build_tags_create_or_update_request, + build_tags_create_or_update_value_request, + build_tags_delete_request, + build_tags_delete_value_request, + build_tags_list_request, +) + +if sys.version_info >= (3, 9): + from collections.abc import MutableMapping +else: + from typing import MutableMapping # type: ignore # pylint: disable=ungrouped-imports +JSON = MutableMapping[str, Any] # pylint: disable=unsubscriptable-object +T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] -class DeploymentsOperations: - """DeploymentsOperations async operations. - You should not instantiate this class directly. Instead, you should create a Client instance that - instantiates it for you and attaches it as an attribute. +class DeploymentsOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. - :ivar models: Alias to model classes used in this operation group. - :type models: ~azure.mgmt.resource.resources.v2017_05_10.models - :param client: Client for service requests. - :param config: Configuration of service client. - :param serializer: An object model serializer. - :param deserializer: An object model deserializer. + Instead, you should access the following operations through + :class:`~azure.mgmt.resource.resources.v2017_05_10.aio.ResourceManagementClient`'s + :attr:`deployments` attribute. """ models = _models - def __init__(self, client, config, serializer, deserializer) -> None: - self._client = client - self._serialize = serializer - self._deserialize = deserializer - self._config = config + def __init__(self, *args, **kwargs) -> None: + input_args = list(args) + self._client = input_args.pop(0) if input_args else kwargs.pop("client") + self._config = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") async def _delete_initial( # pylint: disable=inconsistent-return-statements - self, - resource_group_name: str, - deployment_name: str, - **kwargs: Any + self, resource_group_name: str, deployment_name: str, **kwargs: Any ) -> None: - cls = kwargs.pop('cls', None) # type: ClsType[None] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + 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', "2017-05-10") # type: str + api_version = kwargs.pop("api_version", _params.pop("api-version", "2017-05-10")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[None] - - request = build_deployments_delete_request_initial( + request = build_deployments_delete_request( resource_group_name=resource_group_name, deployment_name=deployment_name, subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self._delete_initial.metadata['url'], + template_url=self._delete_initial.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [202, 204]: @@ -86,16 +145,10 @@ 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.Resources/deployments/{deploymentName}"} # type: ignore - + _delete_initial.metadata = {"url": "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/Microsoft.Resources/deployments/{deploymentName}"} # type: ignore @distributed_trace_async - async def begin_delete( # pylint: disable=inconsistent-return-statements - self, - resource_group_name: str, - deployment_name: str, - **kwargs: Any - ) -> AsyncLROPoller[None]: + async def begin_delete(self, resource_group_name: str, deployment_name: str, **kwargs: Any) -> AsyncLROPoller[None]: """Deletes a deployment from the deployment history. A template deployment that is currently running cannot be deleted. Deleting a template @@ -108,9 +161,9 @@ async def begin_delete( # pylint: disable=inconsistent-return-statements asynchronous request failed, the URI in the Location header returns an error-level status code. :param resource_group_name: The name of the resource group with the deployment to delete. The - name is case insensitive. + name is case insensitive. Required. :type resource_group_name: str - :param deployment_name: The name of the deployment to delete. + :param deployment_name: The name of the deployment to delete. Required. :type deployment_name: str :keyword callable cls: A custom type or function that will be passed the direct response :keyword str continuation_token: A continuation token to restart a poller from a saved state. @@ -122,88 +175,93 @@ async def begin_delete( # pylint: disable=inconsistent-return-statements Retry-After header is present. :return: An instance of AsyncLROPoller that returns either None or the result of cls(response) :rtype: ~azure.core.polling.AsyncLROPoller[None] - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - api_version = kwargs.pop('api_version', "2017-05-10") # type: str - polling = kwargs.pop('polling', True) # type: Union[bool, AsyncPollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType[None] - lro_delay = kwargs.pop( - 'polling_interval', - self._config.polling_interval - ) - cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2017-05-10")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[None] + polling = kwargs.pop("polling", True) # type: Union[bool, AsyncPollingMethod] + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token = kwargs.pop("continuation_token", None) # type: Optional[str] if cont_token is None: - raw_result = await self._delete_initial( + raw_result = await self._delete_initial( # type: ignore resource_group_name=resource_group_name, deployment_name=deployment_name, api_version=api_version, - cls=lambda x,y,z: x, + cls=lambda x, y, z: x, + headers=_headers, + params=_params, **kwargs ) - kwargs.pop('error_map', None) + kwargs.pop("error_map", None) - def get_long_running_output(pipeline_response): + def get_long_running_output(pipeline_response): # pylint: disable=inconsistent-return-statements if cls: return cls(pipeline_response, None, {}) - - if polling is True: polling_method = AsyncARMPolling(lro_delay, **kwargs) - elif polling is False: polling_method = AsyncNoPolling() - else: polling_method = polling + if polling is True: + polling_method = cast(AsyncPollingMethod, AsyncARMPolling(lro_delay, **kwargs)) # type: AsyncPollingMethod + elif polling is False: + polling_method = cast(AsyncPollingMethod, AsyncNoPolling()) + else: + polling_method = polling if cont_token: return AsyncLROPoller.from_continuation_token( polling_method=polling_method, continuation_token=cont_token, client=self._client, - deserialization_callback=get_long_running_output + deserialization_callback=get_long_running_output, ) return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) - begin_delete.metadata = {'url': "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/Microsoft.Resources/deployments/{deploymentName}"} # type: ignore + begin_delete.metadata = {"url": "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/Microsoft.Resources/deployments/{deploymentName}"} # type: ignore @distributed_trace_async - async def check_existence( - self, - resource_group_name: str, - deployment_name: str, - **kwargs: Any - ) -> bool: + async def check_existence(self, resource_group_name: str, deployment_name: str, **kwargs: Any) -> bool: """Checks whether the deployment exists. :param resource_group_name: The name of the resource group with the deployment to check. The - name is case insensitive. + name is case insensitive. Required. :type resource_group_name: str - :param deployment_name: The name of the deployment to check. + :param deployment_name: The name of the deployment to check. Required. :type deployment_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: bool, or the result of cls(response) + :return: bool or the result of cls(response) :rtype: bool - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType[None] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + 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', "2017-05-10") # type: str + api_version = kwargs.pop("api_version", _params.pop("api-version", "2017-05-10")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[None] - request = build_deployments_check_existence_request( resource_group_name=resource_group_name, deployment_name=deployment_name, subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.check_existence.metadata['url'], + template_url=self.check_existence.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [204, 404]: @@ -214,44 +272,53 @@ async def check_existence( return cls(pipeline_response, None, {}) return 200 <= response.status_code <= 299 - check_existence.metadata = {'url': "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/Microsoft.Resources/deployments/{deploymentName}"} # type: ignore - + check_existence.metadata = {"url": "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/Microsoft.Resources/deployments/{deploymentName}"} # type: ignore async def _create_or_update_initial( - self, - resource_group_name: str, - deployment_name: str, - parameters: "_models.Deployment", - **kwargs: Any - ) -> "_models.DeploymentExtended": - cls = kwargs.pop('cls', None) # type: ClsType["_models.DeploymentExtended"] + self, resource_group_name: str, deployment_name: str, parameters: Union[_models.Deployment, IO], **kwargs: Any + ) -> _models.DeploymentExtended: error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) - api_version = kwargs.pop('api_version', "2017-05-10") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - _json = self._serialize.body(parameters, 'Deployment') + api_version = kwargs.pop("api_version", _params.pop("api-version", "2017-05-10")) # type: str + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.DeploymentExtended] - request = build_deployments_create_or_update_request_initial( + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(parameters, (IO, bytes)): + _content = parameters + else: + _json = self._serialize.body(parameters, "Deployment") + + request = build_deployments_create_or_update_request( resource_group_name=resource_group_name, deployment_name=deployment_name, subscription_id=self._config.subscription_id, api_version=api_version, content_type=content_type, json=_json, - template_url=self._create_or_update_initial.metadata['url'], + content=_content, + template_url=self._create_or_update_initial.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200, 201]: @@ -259,38 +326,115 @@ async def _create_or_update_initial( raise HttpResponseError(response=response, error_format=ARMErrorFormat) if response.status_code == 200: - deserialized = self._deserialize('DeploymentExtended', pipeline_response) + deserialized = self._deserialize("DeploymentExtended", pipeline_response) if response.status_code == 201: - deserialized = self._deserialize('DeploymentExtended', pipeline_response) + deserialized = self._deserialize("DeploymentExtended", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - _create_or_update_initial.metadata = {'url': "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/Microsoft.Resources/deployments/{deploymentName}"} # type: ignore + _create_or_update_initial.metadata = {"url": "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/Microsoft.Resources/deployments/{deploymentName}"} # type: ignore - - @distributed_trace_async + @overload async def begin_create_or_update( self, resource_group_name: str, deployment_name: str, - parameters: "_models.Deployment", + parameters: _models.Deployment, + *, + content_type: str = "application/json", **kwargs: Any - ) -> AsyncLROPoller["_models.DeploymentExtended"]: + ) -> AsyncLROPoller[_models.DeploymentExtended]: """Deploys resources to a resource group. You can provide the template and parameters directly in the request or link to JSON files. :param resource_group_name: The name of the resource group to deploy the resources to. The name - is case insensitive. The resource group must already exist. + is case insensitive. The resource group must already exist. Required. :type resource_group_name: str - :param deployment_name: The name of the deployment. + :param deployment_name: The name of the deployment. Required. :type deployment_name: str - :param parameters: Additional parameters supplied to the operation. + :param parameters: Additional parameters supplied to the operation. Required. :type parameters: ~azure.mgmt.resource.resources.v2017_05_10.models.Deployment + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be AsyncARMPolling. Pass in False for + this operation to not poll, or pass in your own initialized polling object for a personal + polling strategy. + :paramtype polling: bool or ~azure.core.polling.AsyncPollingMethod + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of AsyncLROPoller that returns either DeploymentExtended or the result of + cls(response) + :rtype: + ~azure.core.polling.AsyncLROPoller[~azure.mgmt.resource.resources.v2017_05_10.models.DeploymentExtended] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + async def begin_create_or_update( + self, + resource_group_name: str, + deployment_name: str, + parameters: IO, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> AsyncLROPoller[_models.DeploymentExtended]: + """Deploys resources to a resource group. + + You can provide the template and parameters directly in the request or link to JSON files. + + :param resource_group_name: The name of the resource group to deploy the resources to. The name + is case insensitive. The resource group must already exist. Required. + :type resource_group_name: str + :param deployment_name: The name of the deployment. Required. + :type deployment_name: str + :param parameters: Additional parameters supplied to the operation. Required. + :type parameters: IO + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be AsyncARMPolling. Pass in False for + this operation to not poll, or pass in your own initialized polling object for a personal + polling strategy. + :paramtype polling: bool or ~azure.core.polling.AsyncPollingMethod + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of AsyncLROPoller that returns either DeploymentExtended or the result of + cls(response) + :rtype: + ~azure.core.polling.AsyncLROPoller[~azure.mgmt.resource.resources.v2017_05_10.models.DeploymentExtended] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace_async + async def begin_create_or_update( + self, resource_group_name: str, deployment_name: str, parameters: Union[_models.Deployment, IO], **kwargs: Any + ) -> AsyncLROPoller[_models.DeploymentExtended]: + """Deploys resources to a resource group. + + You can provide the template and parameters directly in the request or link to JSON files. + + :param resource_group_name: The name of the resource group to deploy the resources to. The name + is case insensitive. The resource group must already exist. Required. + :type resource_group_name: str + :param deployment_name: The name of the deployment. Required. + :type deployment_name: str + :param parameters: Additional parameters supplied to the operation. Is either a model type or a + IO type. Required. + :type parameters: ~azure.mgmt.resource.resources.v2017_05_10.models.Deployment or IO + :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. + Default value is None. + :paramtype content_type: str :keyword callable cls: A custom type or function that will be passed the direct response :keyword str continuation_token: A continuation token to restart a poller from a saved state. :keyword polling: By default, your polling method will be AsyncARMPolling. Pass in False for @@ -303,115 +447,116 @@ async def begin_create_or_update( cls(response) :rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.resource.resources.v2017_05_10.models.DeploymentExtended] - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - api_version = kwargs.pop('api_version', "2017-05-10") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] - polling = kwargs.pop('polling', True) # type: Union[bool, AsyncPollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType["_models.DeploymentExtended"] - lro_delay = kwargs.pop( - 'polling_interval', - self._config.polling_interval - ) - cont_token = kwargs.pop('continuation_token', None) # type: Optional[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", "2017-05-10")) # type: str + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.DeploymentExtended] + polling = kwargs.pop("polling", True) # type: Union[bool, AsyncPollingMethod] + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token = kwargs.pop("continuation_token", None) # type: Optional[str] if cont_token is None: - raw_result = await self._create_or_update_initial( + raw_result = await self._create_or_update_initial( # type: ignore resource_group_name=resource_group_name, deployment_name=deployment_name, parameters=parameters, api_version=api_version, content_type=content_type, - cls=lambda x,y,z: x, + cls=lambda x, y, z: x, + headers=_headers, + params=_params, **kwargs ) - kwargs.pop('error_map', None) + kwargs.pop("error_map", None) def get_long_running_output(pipeline_response): - response = pipeline_response.http_response - deserialized = self._deserialize('DeploymentExtended', pipeline_response) + deserialized = self._deserialize("DeploymentExtended", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - - if polling is True: polling_method = AsyncARMPolling(lro_delay, **kwargs) - elif polling is False: polling_method = AsyncNoPolling() - else: polling_method = polling + if polling is True: + polling_method = cast(AsyncPollingMethod, AsyncARMPolling(lro_delay, **kwargs)) # type: AsyncPollingMethod + elif polling is False: + polling_method = cast(AsyncPollingMethod, AsyncNoPolling()) + else: + polling_method = polling if cont_token: return AsyncLROPoller.from_continuation_token( polling_method=polling_method, continuation_token=cont_token, client=self._client, - deserialization_callback=get_long_running_output + deserialization_callback=get_long_running_output, ) return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) - begin_create_or_update.metadata = {'url': "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/Microsoft.Resources/deployments/{deploymentName}"} # type: ignore + begin_create_or_update.metadata = {"url": "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/Microsoft.Resources/deployments/{deploymentName}"} # type: ignore @distributed_trace_async - async def get( - self, - resource_group_name: str, - deployment_name: str, - **kwargs: Any - ) -> "_models.DeploymentExtended": + async def get(self, resource_group_name: str, deployment_name: str, **kwargs: Any) -> _models.DeploymentExtended: """Gets a deployment. :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. :type resource_group_name: str - :param deployment_name: The name of the deployment to get. + :param deployment_name: The name of the deployment to get. Required. :type deployment_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: DeploymentExtended, or the result of cls(response) + :return: DeploymentExtended or the result of cls(response) :rtype: ~azure.mgmt.resource.resources.v2017_05_10.models.DeploymentExtended - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.DeploymentExtended"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + 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', "2017-05-10") # type: str + api_version = kwargs.pop("api_version", _params.pop("api-version", "2017-05-10")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[_models.DeploymentExtended] - request = build_deployments_get_request( resource_group_name=resource_group_name, deployment_name=deployment_name, subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.get.metadata['url'], + template_url=self.get.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) - deserialized = self._deserialize('DeploymentExtended', pipeline_response) + deserialized = self._deserialize("DeploymentExtended", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - get.metadata = {'url': "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/Microsoft.Resources/deployments/{deploymentName}"} # type: ignore - + get.metadata = {"url": "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/Microsoft.Resources/deployments/{deploymentName}"} # type: ignore @distributed_trace_async async def cancel( # pylint: disable=inconsistent-return-statements - self, - resource_group_name: str, - deployment_name: str, - **kwargs: Any + self, resource_group_name: str, deployment_name: str, **kwargs: Any ) -> None: """Cancels a currently running template deployment. @@ -421,38 +566,45 @@ async def cancel( # pylint: disable=inconsistent-return-statements partially deployed. :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. :type resource_group_name: str - :param deployment_name: The name of the deployment to cancel. + :param deployment_name: The name of the deployment to cancel. Required. :type deployment_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: None, or the result of cls(response) + :return: None or the result of cls(response) :rtype: None - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType[None] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) - api_version = kwargs.pop('api_version', "2017-05-10") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2017-05-10")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[None] - request = build_deployments_cancel_request( resource_group_name=resource_group_name, deployment_name=deployment_name, subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.cancel.metadata['url'], + template_url=self.cancel.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [204]: @@ -462,42 +614,110 @@ async def cancel( # pylint: disable=inconsistent-return-statements if cls: return cls(pipeline_response, None, {}) - cancel.metadata = {'url': "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/Microsoft.Resources/deployments/{deploymentName}/cancel"} # type: ignore + cancel.metadata = {"url": "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/Microsoft.Resources/deployments/{deploymentName}/cancel"} # type: ignore - - @distributed_trace_async + @overload async def validate( self, resource_group_name: str, deployment_name: str, - parameters: "_models.Deployment", + parameters: _models.Deployment, + *, + content_type: str = "application/json", **kwargs: Any - ) -> "_models.DeploymentValidateResult": + ) -> _models.DeploymentValidateResult: """Validates whether the specified template is syntactically correct and will be accepted by Azure Resource Manager.. :param resource_group_name: The name of the resource group the template will be deployed to. - The name is case insensitive. + The name is case insensitive. Required. :type resource_group_name: str - :param deployment_name: The name of the deployment. + :param deployment_name: The name of the deployment. Required. :type deployment_name: str - :param parameters: Parameters to validate. + :param parameters: Parameters to validate. Required. :type parameters: ~azure.mgmt.resource.resources.v2017_05_10.models.Deployment + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: DeploymentValidateResult or the result of cls(response) + :rtype: ~azure.mgmt.resource.resources.v2017_05_10.models.DeploymentValidateResult + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + async def validate( + self, + resource_group_name: str, + deployment_name: str, + parameters: IO, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.DeploymentValidateResult: + """Validates whether the specified template is syntactically correct and will be accepted by Azure + Resource Manager.. + + :param resource_group_name: The name of the resource group the template will be deployed to. + The name is case insensitive. Required. + :type resource_group_name: str + :param deployment_name: The name of the deployment. Required. + :type deployment_name: str + :param parameters: Parameters to validate. Required. + :type parameters: IO + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: DeploymentValidateResult or the result of cls(response) + :rtype: ~azure.mgmt.resource.resources.v2017_05_10.models.DeploymentValidateResult + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace_async + async def validate( + self, resource_group_name: str, deployment_name: str, parameters: Union[_models.Deployment, IO], **kwargs: Any + ) -> _models.DeploymentValidateResult: + """Validates whether the specified template is syntactically correct and will be accepted by Azure + Resource Manager.. + + :param resource_group_name: The name of the resource group the template will be deployed to. + The name is case insensitive. Required. + :type resource_group_name: str + :param deployment_name: The name of the deployment. Required. + :type deployment_name: str + :param parameters: Parameters to validate. Is either a model type or a IO type. Required. + :type parameters: ~azure.mgmt.resource.resources.v2017_05_10.models.Deployment or IO + :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. + Default value is None. + :paramtype content_type: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: DeploymentValidateResult, or the result of cls(response) + :return: DeploymentValidateResult or the result of cls(response) :rtype: ~azure.mgmt.resource.resources.v2017_05_10.models.DeploymentValidateResult - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.DeploymentValidateResult"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) - api_version = kwargs.pop('api_version', "2017-05-10") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - _json = self._serialize.body(parameters, 'Deployment') + api_version = kwargs.pop("api_version", _params.pop("api-version", "2017-05-10")) # type: str + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.DeploymentValidateResult] + + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(parameters, (IO, bytes)): + _content = parameters + else: + _json = self._serialize.body(parameters, "Deployment") request = build_deployments_validate_request( resource_group_name=resource_group_name, @@ -506,16 +726,18 @@ async def validate( api_version=api_version, content_type=content_type, json=_json, - template_url=self.validate.metadata['url'], + content=_content, + template_url=self.validate.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200, 400]: @@ -523,89 +745,87 @@ async def validate( raise HttpResponseError(response=response, error_format=ARMErrorFormat) if response.status_code == 200: - deserialized = self._deserialize('DeploymentValidateResult', pipeline_response) + deserialized = self._deserialize("DeploymentValidateResult", pipeline_response) if response.status_code == 400: - deserialized = self._deserialize('DeploymentValidateResult', pipeline_response) + deserialized = self._deserialize("DeploymentValidateResult", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - validate.metadata = {'url': "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/Microsoft.Resources/deployments/{deploymentName}/validate"} # type: ignore - + validate.metadata = {"url": "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/Microsoft.Resources/deployments/{deploymentName}/validate"} # type: ignore @distributed_trace_async async def export_template( - self, - resource_group_name: str, - deployment_name: str, - **kwargs: Any - ) -> "_models.DeploymentExportResult": + self, resource_group_name: str, deployment_name: str, **kwargs: Any + ) -> _models.DeploymentExportResult: """Exports the template used for specified deployment. :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. :type resource_group_name: str - :param deployment_name: The name of the deployment from which to get the template. + :param deployment_name: The name of the deployment from which to get the template. Required. :type deployment_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: DeploymentExportResult, or the result of cls(response) + :return: DeploymentExportResult or the result of cls(response) :rtype: ~azure.mgmt.resource.resources.v2017_05_10.models.DeploymentExportResult - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.DeploymentExportResult"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + 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', "2017-05-10") # type: str + api_version = kwargs.pop("api_version", _params.pop("api-version", "2017-05-10")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[_models.DeploymentExportResult] - request = build_deployments_export_template_request( resource_group_name=resource_group_name, deployment_name=deployment_name, subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.export_template.metadata['url'], + template_url=self.export_template.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) - deserialized = self._deserialize('DeploymentExportResult', pipeline_response) + deserialized = self._deserialize("DeploymentExportResult", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - export_template.metadata = {'url': "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/Microsoft.Resources/deployments/{deploymentName}/exportTemplate"} # type: ignore - + export_template.metadata = {"url": "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/Microsoft.Resources/deployments/{deploymentName}/exportTemplate"} # type: ignore @distributed_trace def list_by_resource_group( - self, - resource_group_name: str, - filter: Optional[str] = None, - top: Optional[int] = None, - **kwargs: Any - ) -> AsyncIterable["_models.DeploymentListResult"]: + self, resource_group_name: str, filter: Optional[str] = None, top: Optional[int] = None, **kwargs: Any + ) -> AsyncIterable["_models.DeploymentExtended"]: """Get all the deployments for a resource group. :param resource_group_name: The name of the resource group with the deployments to get. The - name is case insensitive. + name is case insensitive. Required. :type resource_group_name: str :param filter: The filter to apply on the operation. For example, you can use $filter=provisioningState eq '{state}'. Default value is None. @@ -614,42 +834,49 @@ def list_by_resource_group( value is None. :type top: int :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either DeploymentListResult or the result of - cls(response) + :return: An iterator like instance of either DeploymentExtended or the result of cls(response) :rtype: - ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.resource.resources.v2017_05_10.models.DeploymentListResult] - :raises: ~azure.core.exceptions.HttpResponseError + ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.resource.resources.v2017_05_10.models.DeploymentExtended] + :raises ~azure.core.exceptions.HttpResponseError: """ - api_version = kwargs.pop('api_version', "2017-05-10") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2017-05-10")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[_models.DeploymentListResult] - cls = kwargs.pop('cls', None) # type: ClsType["_models.DeploymentListResult"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) + def prepare_request(next_link=None): if not next_link: - + request = build_deployments_list_by_resource_group_request( resource_group_name=resource_group_name, subscription_id=self._config.subscription_id, - api_version=api_version, filter=filter, top=top, - template_url=self.list_by_resource_group.metadata['url'], + 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.url = self._client.format_url(request.url) # type: ignore else: - - request = build_deployments_list_by_resource_group_request( - resource_group_name=resource_group_name, - subscription_id=self._config.subscription_id, - template_url=next_link, - ) + # make call to next link with the client's api-version + _parsed_next_link = urlparse(next_link) + _next_request_params = case_insensitive_dict(parse_qs(_parsed_next_link.query)) + _next_request_params["api-version"] = self._config.api_version + request = HttpRequest("GET", urljoin(next_link, _parsed_next_link.path), params=_next_request_params) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore request.method = "GET" return request @@ -663,10 +890,8 @@ async def extract_data(pipeline_response): async def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) response = pipeline_response.http_response @@ -676,204 +901,204 @@ async def get_next(next_link=None): return pipeline_response + return AsyncItemPaged(get_next, extract_data) - return AsyncItemPaged( - get_next, extract_data - ) - list_by_resource_group.metadata = {'url': "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/Microsoft.Resources/deployments/"} # type: ignore + list_by_resource_group.metadata = {"url": "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/Microsoft.Resources/deployments/"} # type: ignore @distributed_trace_async - async def calculate_template_hash( - self, - template: Any, - **kwargs: Any - ) -> "_models.TemplateHashResult": + async def calculate_template_hash(self, template: JSON, **kwargs: Any) -> _models.TemplateHashResult: """Calculate the hash of the given template. - :param template: The template provided to calculate hash. - :type template: any + :param template: The template provided to calculate hash. Required. + :type template: JSON :keyword callable cls: A custom type or function that will be passed the direct response - :return: TemplateHashResult, or the result of cls(response) + :return: TemplateHashResult or the result of cls(response) :rtype: ~azure.mgmt.resource.resources.v2017_05_10.models.TemplateHashResult - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.TemplateHashResult"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', "2017-05-10") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + api_version = kwargs.pop("api_version", _params.pop("api-version", "2017-05-10")) # type: str + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", "application/json")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[_models.TemplateHashResult] - _json = self._serialize.body(template, 'object') + _json = self._serialize.body(template, "object") request = build_deployments_calculate_template_hash_request( api_version=api_version, content_type=content_type, json=_json, - template_url=self.calculate_template_hash.metadata['url'], + template_url=self.calculate_template_hash.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) - deserialized = self._deserialize('TemplateHashResult', pipeline_response) + deserialized = self._deserialize("TemplateHashResult", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - calculate_template_hash.metadata = {'url': "/providers/Microsoft.Resources/calculateTemplateHash"} # type: ignore + calculate_template_hash.metadata = {"url": "/providers/Microsoft.Resources/calculateTemplateHash"} # type: ignore -class ProvidersOperations: - """ProvidersOperations async operations. - You should not instantiate this class directly. Instead, you should create a Client instance that - instantiates it for you and attaches it as an attribute. +class ProvidersOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. - :ivar models: Alias to model classes used in this operation group. - :type models: ~azure.mgmt.resource.resources.v2017_05_10.models - :param client: Client for service requests. - :param config: Configuration of service client. - :param serializer: An object model serializer. - :param deserializer: An object model deserializer. + Instead, you should access the following operations through + :class:`~azure.mgmt.resource.resources.v2017_05_10.aio.ResourceManagementClient`'s + :attr:`providers` attribute. """ models = _models - def __init__(self, client, config, serializer, deserializer) -> None: - self._client = client - self._serialize = serializer - self._deserialize = deserializer - self._config = config + def __init__(self, *args, **kwargs) -> None: + input_args = list(args) + self._client = input_args.pop(0) if input_args else kwargs.pop("client") + self._config = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") @distributed_trace_async - async def unregister( - self, - resource_provider_namespace: str, - **kwargs: Any - ) -> "_models.Provider": + async def unregister(self, resource_provider_namespace: str, **kwargs: Any) -> _models.Provider: """Unregisters a subscription from a resource provider. :param resource_provider_namespace: The namespace of the resource provider to unregister. + Required. :type resource_provider_namespace: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: Provider, or the result of cls(response) + :return: Provider or the result of cls(response) :rtype: ~azure.mgmt.resource.resources.v2017_05_10.models.Provider - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.Provider"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + 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', "2017-05-10") # type: str + api_version = kwargs.pop("api_version", _params.pop("api-version", "2017-05-10")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[_models.Provider] - request = build_providers_unregister_request( resource_provider_namespace=resource_provider_namespace, subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.unregister.metadata['url'], + template_url=self.unregister.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) - deserialized = self._deserialize('Provider', pipeline_response) + deserialized = self._deserialize("Provider", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - unregister.metadata = {'url': "/subscriptions/{subscriptionId}/providers/{resourceProviderNamespace}/unregister"} # type: ignore - + unregister.metadata = {"url": "/subscriptions/{subscriptionId}/providers/{resourceProviderNamespace}/unregister"} # type: ignore @distributed_trace_async - async def register( - self, - resource_provider_namespace: str, - **kwargs: Any - ) -> "_models.Provider": + async def register(self, resource_provider_namespace: str, **kwargs: Any) -> _models.Provider: """Registers a subscription with a resource provider. :param resource_provider_namespace: The namespace of the resource provider to register. + Required. :type resource_provider_namespace: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: Provider, or the result of cls(response) + :return: Provider or the result of cls(response) :rtype: ~azure.mgmt.resource.resources.v2017_05_10.models.Provider - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.Provider"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + 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', "2017-05-10") # type: str + api_version = kwargs.pop("api_version", _params.pop("api-version", "2017-05-10")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[_models.Provider] - request = build_providers_register_request( resource_provider_namespace=resource_provider_namespace, subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.register.metadata['url'], + template_url=self.register.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) - deserialized = self._deserialize('Provider', pipeline_response) + deserialized = self._deserialize("Provider", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - register.metadata = {'url': "/subscriptions/{subscriptionId}/providers/{resourceProviderNamespace}/register"} # type: ignore - + register.metadata = {"url": "/subscriptions/{subscriptionId}/providers/{resourceProviderNamespace}/register"} # type: ignore @distributed_trace def list( - self, - top: Optional[int] = None, - expand: Optional[str] = None, - **kwargs: Any - ) -> AsyncIterable["_models.ProviderListResult"]: + self, top: Optional[int] = None, expand: Optional[str] = None, **kwargs: Any + ) -> AsyncIterable["_models.Provider"]: """Gets all resource providers for a subscription. :param top: The number of results to return. If null is passed returns all deployments. Default @@ -884,39 +1109,48 @@ def list( response, use $expand=resourceTypes/aliases. Default value is None. :type expand: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either ProviderListResult or the result of cls(response) + :return: An iterator like instance of either Provider or the result of cls(response) :rtype: - ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.resource.resources.v2017_05_10.models.ProviderListResult] - :raises: ~azure.core.exceptions.HttpResponseError + ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.resource.resources.v2017_05_10.models.Provider] + :raises ~azure.core.exceptions.HttpResponseError: """ - api_version = kwargs.pop('api_version', "2017-05-10") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2017-05-10")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[_models.ProviderListResult] - cls = kwargs.pop('cls', None) # type: ClsType["_models.ProviderListResult"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) + def prepare_request(next_link=None): if not next_link: - + request = build_providers_list_request( subscription_id=self._config.subscription_id, - api_version=api_version, top=top, expand=expand, - template_url=self.list.metadata['url'], + 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.url = self._client.format_url(request.url) # type: ignore else: - - request = build_providers_list_request( - subscription_id=self._config.subscription_id, - template_url=next_link, - ) + # make call to next link with the client's api-version + _parsed_next_link = urlparse(next_link) + _next_request_params = case_insensitive_dict(parse_qs(_parsed_next_link.query)) + _next_request_params["api-version"] = self._config.api_version + request = HttpRequest("GET", urljoin(next_link, _parsed_next_link.path), params=_next_request_params) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore request.method = "GET" return request @@ -930,10 +1164,8 @@ async def extract_data(pipeline_response): async def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) response = pipeline_response.http_response @@ -943,91 +1175,90 @@ async def get_next(next_link=None): return pipeline_response + return AsyncItemPaged(get_next, extract_data) - return AsyncItemPaged( - get_next, extract_data - ) - list.metadata = {'url': "/subscriptions/{subscriptionId}/providers"} # type: ignore + list.metadata = {"url": "/subscriptions/{subscriptionId}/providers"} # type: ignore @distributed_trace_async async def get( - self, - resource_provider_namespace: str, - expand: Optional[str] = None, - **kwargs: Any - ) -> "_models.Provider": + self, resource_provider_namespace: str, expand: Optional[str] = None, **kwargs: Any + ) -> _models.Provider: """Gets the specified resource provider. - :param resource_provider_namespace: The namespace of the resource provider. + :param resource_provider_namespace: The namespace of the resource provider. Required. :type resource_provider_namespace: str :param expand: The $expand query parameter. For example, to include property aliases in response, use $expand=resourceTypes/aliases. Default value is None. :type expand: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: Provider, or the result of cls(response) + :return: Provider or the result of cls(response) :rtype: ~azure.mgmt.resource.resources.v2017_05_10.models.Provider - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.Provider"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) - api_version = kwargs.pop('api_version', "2017-05-10") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2017-05-10")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[_models.Provider] - request = build_providers_get_request( resource_provider_namespace=resource_provider_namespace, subscription_id=self._config.subscription_id, - api_version=api_version, expand=expand, - template_url=self.get.metadata['url'], + api_version=api_version, + template_url=self.get.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) - deserialized = self._deserialize('Provider', pipeline_response) + deserialized = self._deserialize("Provider", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - get.metadata = {'url': "/subscriptions/{subscriptionId}/providers/{resourceProviderNamespace}"} # type: ignore + get.metadata = {"url": "/subscriptions/{subscriptionId}/providers/{resourceProviderNamespace}"} # type: ignore -class ResourcesOperations: # pylint: disable=too-many-public-methods - """ResourcesOperations async operations. - You should not instantiate this class directly. Instead, you should create a Client instance that - instantiates it for you and attaches it as an attribute. +class ResourcesOperations: # pylint: disable=too-many-public-methods + """ + .. warning:: + **DO NOT** instantiate this class directly. - :ivar models: Alias to model classes used in this operation group. - :type models: ~azure.mgmt.resource.resources.v2017_05_10.models - :param client: Client for service requests. - :param config: Configuration of service client. - :param serializer: An object model serializer. - :param deserializer: An object model deserializer. + Instead, you should access the following operations through + :class:`~azure.mgmt.resource.resources.v2017_05_10.aio.ResourceManagementClient`'s + :attr:`resources` attribute. """ models = _models - def __init__(self, client, config, serializer, deserializer) -> None: - self._client = client - self._serialize = serializer - self._deserialize = deserializer - self._config = config + def __init__(self, *args, **kwargs) -> None: + input_args = list(args) + self._client = input_args.pop(0) if input_args else kwargs.pop("client") + self._config = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") @distributed_trace def list_by_resource_group( @@ -1037,10 +1268,10 @@ def list_by_resource_group( expand: Optional[str] = None, top: Optional[int] = None, **kwargs: Any - ) -> AsyncIterable["_models.ResourceListResult"]: + ) -> AsyncIterable["_models.GenericResourceExpanded"]: """Get all the resources for a resource group. - :param resource_group_name: The resource group with the resources to get. + :param resource_group_name: The resource group with the resources to get. Required. :type resource_group_name: str :param filter: The filter to apply on the operation. Default value is None. :type filter: str @@ -1052,42 +1283,51 @@ def list_by_resource_group( value is None. :type top: int :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either ResourceListResult or the result of cls(response) + :return: An iterator like instance of either GenericResourceExpanded or the result of + cls(response) :rtype: - ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.resource.resources.v2017_05_10.models.ResourceListResult] - :raises: ~azure.core.exceptions.HttpResponseError + ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.resource.resources.v2017_05_10.models.GenericResourceExpanded] + :raises ~azure.core.exceptions.HttpResponseError: """ - api_version = kwargs.pop('api_version', "2017-05-10") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2017-05-10")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[_models.ResourceListResult] - cls = kwargs.pop('cls', None) # type: ClsType["_models.ResourceListResult"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) + def prepare_request(next_link=None): if not next_link: - + request = build_resources_list_by_resource_group_request( resource_group_name=resource_group_name, subscription_id=self._config.subscription_id, - api_version=api_version, filter=filter, expand=expand, top=top, - template_url=self.list_by_resource_group.metadata['url'], + 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.url = self._client.format_url(request.url) # type: ignore else: - - request = build_resources_list_by_resource_group_request( - resource_group_name=resource_group_name, - subscription_id=self._config.subscription_id, - template_url=next_link, - ) + # make call to next link with the client's api-version + _parsed_next_link = urlparse(next_link) + _next_request_params = case_insensitive_dict(parse_qs(_parsed_next_link.query)) + _next_request_params["api-version"] = self._config.api_version + request = HttpRequest("GET", urljoin(next_link, _parsed_next_link.path), params=_next_request_params) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore request.method = "GET" return request @@ -1101,10 +1341,8 @@ async def extract_data(pipeline_response): async def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) response = pipeline_response.http_response @@ -1114,45 +1352,54 @@ async def get_next(next_link=None): return pipeline_response + return AsyncItemPaged(get_next, extract_data) - return AsyncItemPaged( - get_next, extract_data - ) - list_by_resource_group.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/resources"} # type: ignore + list_by_resource_group.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/resources"} # type: ignore async def _move_resources_initial( # pylint: disable=inconsistent-return-statements - self, - source_resource_group_name: str, - parameters: "_models.ResourcesMoveInfo", - **kwargs: Any + self, source_resource_group_name: str, parameters: Union[_models.ResourcesMoveInfo, IO], **kwargs: Any ) -> None: - cls = kwargs.pop('cls', None) # type: ClsType[None] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) - api_version = kwargs.pop('api_version', "2017-05-10") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - _json = self._serialize.body(parameters, 'ResourcesMoveInfo') + api_version = kwargs.pop("api_version", _params.pop("api-version", "2017-05-10")) # type: str + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[None] - request = build_resources_move_resources_request_initial( + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(parameters, (IO, bytes)): + _content = parameters + else: + _json = self._serialize.body(parameters, "ResourcesMoveInfo") + + request = build_resources_move_resources_request( source_resource_group_name=source_resource_group_name, subscription_id=self._config.subscription_id, api_version=api_version, content_type=content_type, json=_json, - template_url=self._move_resources_initial.metadata['url'], + content=_content, + template_url=self._move_resources_initial.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [202, 204]: @@ -1162,14 +1409,15 @@ async def _move_resources_initial( # pylint: disable=inconsistent-return-statem if cls: return cls(pipeline_response, None, {}) - _move_resources_initial.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{sourceResourceGroupName}/moveResources"} # type: ignore + _move_resources_initial.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{sourceResourceGroupName}/moveResources"} # type: ignore - - @distributed_trace_async - async def begin_move_resources( # pylint: disable=inconsistent-return-statements + @overload + async def begin_move_resources( self, source_resource_group_name: str, - parameters: "_models.ResourcesMoveInfo", + parameters: _models.ResourcesMoveInfo, + *, + content_type: str = "application/json", **kwargs: Any ) -> AsyncLROPoller[None]: """Moves resources from one resource group to another resource group. @@ -1180,10 +1428,13 @@ async def begin_move_resources( # pylint: disable=inconsistent-return-statement the groups until the move completes. :param source_resource_group_name: The name of the resource group containing the resources to - move. + move. Required. :type source_resource_group_name: str - :param parameters: Parameters for moving resources. + :param parameters: Parameters for moving resources. Required. :type parameters: ~azure.mgmt.resource.resources.v2017_05_10.models.ResourcesMoveInfo + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str :keyword callable cls: A custom type or function that will be passed the direct response :keyword str continuation_token: A continuation token to restart a poller from a saved state. :keyword polling: By default, your polling method will be AsyncARMPolling. Pass in False for @@ -1194,80 +1445,160 @@ async def begin_move_resources( # pylint: disable=inconsistent-return-statement Retry-After header is present. :return: An instance of AsyncLROPoller that returns either None or the result of cls(response) :rtype: ~azure.core.polling.AsyncLROPoller[None] - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - api_version = kwargs.pop('api_version', "2017-05-10") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] - polling = kwargs.pop('polling', True) # type: Union[bool, AsyncPollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType[None] - lro_delay = kwargs.pop( - 'polling_interval', - self._config.polling_interval - ) - cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] - if cont_token is None: - raw_result = await self._move_resources_initial( - source_resource_group_name=source_resource_group_name, - parameters=parameters, - api_version=api_version, - content_type=content_type, - cls=lambda x,y,z: x, - **kwargs - ) - kwargs.pop('error_map', None) - def get_long_running_output(pipeline_response): - if cls: - return cls(pipeline_response, None, {}) + @overload + async def begin_move_resources( + self, source_resource_group_name: str, parameters: IO, *, content_type: str = "application/json", **kwargs: Any + ) -> AsyncLROPoller[None]: + """Moves resources from one resource group to another resource group. + The resources to move must be in the same source resource group. The target resource group may + be in a different subscription. When moving resources, both the source group and the target + group are locked for the duration of the operation. Write and delete operations are blocked on + the groups until the move completes. - if polling is True: polling_method = AsyncARMPolling(lro_delay, **kwargs) - elif polling is False: polling_method = AsyncNoPolling() - else: polling_method = polling - if cont_token: - return AsyncLROPoller.from_continuation_token( - polling_method=polling_method, - continuation_token=cont_token, - client=self._client, - deserialization_callback=get_long_running_output - ) - return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) + :param source_resource_group_name: The name of the resource group containing the resources to + move. Required. + :type source_resource_group_name: str + :param parameters: Parameters for moving resources. Required. + :type parameters: IO + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be AsyncARMPolling. Pass in False for + this operation to not poll, or pass in your own initialized polling object for a personal + polling strategy. + :paramtype polling: bool or ~azure.core.polling.AsyncPollingMethod + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of AsyncLROPoller that returns either None or the result of cls(response) + :rtype: ~azure.core.polling.AsyncLROPoller[None] + :raises ~azure.core.exceptions.HttpResponseError: + """ - begin_move_resources.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{sourceResourceGroupName}/moveResources"} # type: ignore + @distributed_trace_async + async def begin_move_resources( + self, source_resource_group_name: str, parameters: Union[_models.ResourcesMoveInfo, IO], **kwargs: Any + ) -> AsyncLROPoller[None]: + """Moves resources from one resource group to another resource group. + + The resources to move must be in the same source resource group. The target resource group may + be in a different subscription. When moving resources, both the source group and the target + group are locked for the duration of the operation. Write and delete operations are blocked on + the groups until the move completes. + + :param source_resource_group_name: The name of the resource group containing the resources to + move. Required. + :type source_resource_group_name: str + :param parameters: Parameters for moving resources. Is either a model type or a IO type. + Required. + :type parameters: ~azure.mgmt.resource.resources.v2017_05_10.models.ResourcesMoveInfo or IO + :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. + Default value is None. + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be AsyncARMPolling. Pass in False for + this operation to not poll, or pass in your own initialized polling object for a personal + polling strategy. + :paramtype polling: bool or ~azure.core.polling.AsyncPollingMethod + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of AsyncLROPoller that returns either None or the result of cls(response) + :rtype: ~azure.core.polling.AsyncLROPoller[None] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _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", "2017-05-10")) # type: str + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[None] + polling = kwargs.pop("polling", True) # type: Union[bool, AsyncPollingMethod] + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token = kwargs.pop("continuation_token", None) # type: Optional[str] + if cont_token is None: + raw_result = await self._move_resources_initial( # type: ignore + source_resource_group_name=source_resource_group_name, + parameters=parameters, + api_version=api_version, + content_type=content_type, + cls=lambda x, y, z: x, + headers=_headers, + params=_params, + **kwargs + ) + kwargs.pop("error_map", None) + + def get_long_running_output(pipeline_response): # pylint: disable=inconsistent-return-statements + if cls: + return cls(pipeline_response, None, {}) + + if polling is True: + polling_method = cast(AsyncPollingMethod, AsyncARMPolling(lro_delay, **kwargs)) # type: AsyncPollingMethod + elif polling is False: + polling_method = cast(AsyncPollingMethod, AsyncNoPolling()) + else: + polling_method = polling + if cont_token: + return AsyncLROPoller.from_continuation_token( + polling_method=polling_method, + continuation_token=cont_token, + client=self._client, + deserialization_callback=get_long_running_output, + ) + return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) + + begin_move_resources.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{sourceResourceGroupName}/moveResources"} # type: ignore async def _validate_move_resources_initial( # pylint: disable=inconsistent-return-statements - self, - source_resource_group_name: str, - parameters: "_models.ResourcesMoveInfo", - **kwargs: Any + self, source_resource_group_name: str, parameters: Union[_models.ResourcesMoveInfo, IO], **kwargs: Any ) -> None: - cls = kwargs.pop('cls', None) # type: ClsType[None] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', "2017-05-10") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + api_version = kwargs.pop("api_version", _params.pop("api-version", "2017-05-10")) # type: str + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[None] - _json = self._serialize.body(parameters, 'ResourcesMoveInfo') + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(parameters, (IO, bytes)): + _content = parameters + else: + _json = self._serialize.body(parameters, "ResourcesMoveInfo") - request = build_resources_validate_move_resources_request_initial( + request = build_resources_validate_move_resources_request( source_resource_group_name=source_resource_group_name, subscription_id=self._config.subscription_id, api_version=api_version, content_type=content_type, json=_json, - template_url=self._validate_move_resources_initial.metadata['url'], + content=_content, + template_url=self._validate_move_resources_initial.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [202, 204, 409]: @@ -1277,14 +1608,15 @@ async def _validate_move_resources_initial( # pylint: disable=inconsistent-retu if cls: return cls(pipeline_response, None, {}) - _validate_move_resources_initial.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{sourceResourceGroupName}/validateMoveResources"} # type: ignore - + _validate_move_resources_initial.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{sourceResourceGroupName}/validateMoveResources"} # type: ignore - @distributed_trace_async - async def begin_validate_move_resources( # pylint: disable=inconsistent-return-statements + @overload + async def begin_validate_move_resources( self, source_resource_group_name: str, - parameters: "_models.ResourcesMoveInfo", + parameters: _models.ResourcesMoveInfo, + *, + content_type: str = "application/json", **kwargs: Any ) -> AsyncLROPoller[None]: """Validates whether resources can be moved from one resource group to another resource group. @@ -1297,10 +1629,47 @@ async def begin_validate_move_resources( # pylint: disable=inconsistent-return- operation. :param source_resource_group_name: The name of the resource group containing the resources to - validate for move. + validate for move. Required. :type source_resource_group_name: str - :param parameters: Parameters for moving resources. + :param parameters: Parameters for moving resources. Required. :type parameters: ~azure.mgmt.resource.resources.v2017_05_10.models.ResourcesMoveInfo + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be AsyncARMPolling. Pass in False for + this operation to not poll, or pass in your own initialized polling object for a personal + polling strategy. + :paramtype polling: bool or ~azure.core.polling.AsyncPollingMethod + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of AsyncLROPoller that returns either None or the result of cls(response) + :rtype: ~azure.core.polling.AsyncLROPoller[None] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + async def begin_validate_move_resources( + self, source_resource_group_name: str, parameters: IO, *, content_type: str = "application/json", **kwargs: Any + ) -> AsyncLROPoller[None]: + """Validates whether resources can be moved from one resource group to another resource group. + + This operation checks whether the specified resources can be moved to the target. The resources + to move must be in the same source resource group. The target resource group may be in a + different subscription. If validation succeeds, it returns HTTP response code 204 (no content). + If validation fails, it returns HTTP response code 409 (Conflict) with an error message. + Retrieve the URL in the Location header value to check the result of the long-running + operation. + + :param source_resource_group_name: The name of the resource group containing the resources to + validate for move. Required. + :type source_resource_group_name: str + :param parameters: Parameters for moving resources. Required. + :type parameters: IO + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: str :keyword callable cls: A custom type or function that will be passed the direct response :keyword str continuation_token: A continuation token to restart a poller from a saved state. :keyword polling: By default, your polling method will be AsyncARMPolling. Pass in False for @@ -1311,55 +1680,90 @@ async def begin_validate_move_resources( # pylint: disable=inconsistent-return- Retry-After header is present. :return: An instance of AsyncLROPoller that returns either None or the result of cls(response) :rtype: ~azure.core.polling.AsyncLROPoller[None] - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - api_version = kwargs.pop('api_version', "2017-05-10") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] - polling = kwargs.pop('polling', True) # type: Union[bool, AsyncPollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType[None] - lro_delay = kwargs.pop( - 'polling_interval', - self._config.polling_interval - ) - cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] + + @distributed_trace_async + async def begin_validate_move_resources( + self, source_resource_group_name: str, parameters: Union[_models.ResourcesMoveInfo, IO], **kwargs: Any + ) -> AsyncLROPoller[None]: + """Validates whether resources can be moved from one resource group to another resource group. + + This operation checks whether the specified resources can be moved to the target. The resources + to move must be in the same source resource group. The target resource group may be in a + different subscription. If validation succeeds, it returns HTTP response code 204 (no content). + If validation fails, it returns HTTP response code 409 (Conflict) with an error message. + Retrieve the URL in the Location header value to check the result of the long-running + operation. + + :param source_resource_group_name: The name of the resource group containing the resources to + validate for move. Required. + :type source_resource_group_name: str + :param parameters: Parameters for moving resources. Is either a model type or a IO type. + Required. + :type parameters: ~azure.mgmt.resource.resources.v2017_05_10.models.ResourcesMoveInfo or IO + :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. + Default value is None. + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be AsyncARMPolling. Pass in False for + this operation to not poll, or pass in your own initialized polling object for a personal + polling strategy. + :paramtype polling: bool or ~azure.core.polling.AsyncPollingMethod + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of AsyncLROPoller that returns either None or the result of cls(response) + :rtype: ~azure.core.polling.AsyncLROPoller[None] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _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", "2017-05-10")) # type: str + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[None] + polling = kwargs.pop("polling", True) # type: Union[bool, AsyncPollingMethod] + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token = kwargs.pop("continuation_token", None) # type: Optional[str] if cont_token is None: - raw_result = await self._validate_move_resources_initial( + raw_result = await self._validate_move_resources_initial( # type: ignore source_resource_group_name=source_resource_group_name, parameters=parameters, api_version=api_version, content_type=content_type, - cls=lambda x,y,z: x, + cls=lambda x, y, z: x, + headers=_headers, + params=_params, **kwargs ) - kwargs.pop('error_map', None) + kwargs.pop("error_map", None) - def get_long_running_output(pipeline_response): + def get_long_running_output(pipeline_response): # pylint: disable=inconsistent-return-statements if cls: return cls(pipeline_response, None, {}) - - if polling is True: polling_method = AsyncARMPolling(lro_delay, **kwargs) - elif polling is False: polling_method = AsyncNoPolling() - else: polling_method = polling + if polling is True: + polling_method = cast(AsyncPollingMethod, AsyncARMPolling(lro_delay, **kwargs)) # type: AsyncPollingMethod + elif polling is False: + polling_method = cast(AsyncPollingMethod, AsyncNoPolling()) + else: + polling_method = polling if cont_token: return AsyncLROPoller.from_continuation_token( polling_method=polling_method, continuation_token=cont_token, client=self._client, - deserialization_callback=get_long_running_output + deserialization_callback=get_long_running_output, ) return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) - begin_validate_move_resources.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{sourceResourceGroupName}/validateMoveResources"} # type: ignore + begin_validate_move_resources.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{sourceResourceGroupName}/validateMoveResources"} # type: ignore @distributed_trace def list( - self, - filter: Optional[str] = None, - expand: Optional[str] = None, - top: Optional[int] = None, - **kwargs: Any - ) -> AsyncIterable["_models.ResourceListResult"]: + self, filter: Optional[str] = None, expand: Optional[str] = None, top: Optional[int] = None, **kwargs: Any + ) -> AsyncIterable["_models.GenericResourceExpanded"]: """Get all the resources in a subscription. :param filter: The filter to apply on the operation. Default value is None. @@ -1372,40 +1776,50 @@ def list( value is None. :type top: int :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either ResourceListResult or the result of cls(response) + :return: An iterator like instance of either GenericResourceExpanded or the result of + cls(response) :rtype: - ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.resource.resources.v2017_05_10.models.ResourceListResult] - :raises: ~azure.core.exceptions.HttpResponseError + ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.resource.resources.v2017_05_10.models.GenericResourceExpanded] + :raises ~azure.core.exceptions.HttpResponseError: """ - api_version = kwargs.pop('api_version', "2017-05-10") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2017-05-10")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[_models.ResourceListResult] - cls = kwargs.pop('cls', None) # type: ClsType["_models.ResourceListResult"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) + def prepare_request(next_link=None): if not next_link: - + request = build_resources_list_request( subscription_id=self._config.subscription_id, - api_version=api_version, filter=filter, expand=expand, top=top, - template_url=self.list.metadata['url'], + 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.url = self._client.format_url(request.url) # type: ignore else: - - request = build_resources_list_request( - subscription_id=self._config.subscription_id, - template_url=next_link, - ) + # make call to next link with the client's api-version + _parsed_next_link = urlparse(next_link) + _next_request_params = case_insensitive_dict(parse_qs(_parsed_next_link.query)) + _next_request_params["api-version"] = self._config.api_version + request = HttpRequest("GET", urljoin(next_link, _parsed_next_link.path), params=_next_request_params) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore request.method = "GET" return request @@ -1419,10 +1833,8 @@ async def extract_data(pipeline_response): async def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) response = pipeline_response.http_response @@ -1432,11 +1844,9 @@ async def get_next(next_link=None): return pipeline_response + return AsyncItemPaged(get_next, extract_data) - return AsyncItemPaged( - get_next, extract_data - ) - list.metadata = {'url': "/subscriptions/{subscriptionId}/resources"} # type: ignore + list.metadata = {"url": "/subscriptions/{subscriptionId}/resources"} # type: ignore @distributed_trace_async async def check_existence( @@ -1452,30 +1862,36 @@ async def check_existence( """Checks whether a resource exists. :param resource_group_name: The name of the resource group containing the resource to check. - The name is case insensitive. + The name is case insensitive. Required. :type resource_group_name: str - :param resource_provider_namespace: The resource provider of the resource to check. + :param resource_provider_namespace: The resource provider of the resource to check. Required. :type resource_provider_namespace: str - :param parent_resource_path: The parent resource identity. + :param parent_resource_path: The parent resource identity. Required. :type parent_resource_path: str - :param resource_type: The resource type. + :param resource_type: The resource type. Required. :type resource_type: str - :param resource_name: The name of the resource to check whether it exists. + :param resource_name: The name of the resource to check whether it exists. Required. :type resource_name: str - :param api_version: The API version to use for the operation. + :param api_version: The API version to use for the operation. Required. :type api_version: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: bool, or the result of cls(response) + :return: bool or the result of cls(response) :rtype: bool - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType[None] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = kwargs.pop("params", {}) or {} + + cls = kwargs.pop("cls", None) # type: ClsType[None] - request = build_resources_check_existence_request( resource_group_name=resource_group_name, resource_provider_namespace=resource_provider_namespace, @@ -1484,16 +1900,17 @@ async def check_existence( resource_name=resource_name, subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.check_existence.metadata['url'], + template_url=self.check_existence.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [204, 404]: @@ -1504,8 +1921,7 @@ async def check_existence( return cls(pipeline_response, None, {}) return 200 <= response.status_code <= 299 - check_existence.metadata = {'url': "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{parentResourcePath}/{resourceType}/{resourceName}"} # type: ignore - + check_existence.metadata = {"url": "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{parentResourcePath}/{resourceType}/{resourceName}"} # type: ignore async def _delete_initial( # pylint: disable=inconsistent-return-statements self, @@ -1517,14 +1933,20 @@ async def _delete_initial( # pylint: disable=inconsistent-return-statements api_version: str, **kwargs: Any ) -> None: - cls = kwargs.pop('cls', None) # type: ClsType[None] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) - - request = build_resources_delete_request_initial( + _headers = kwargs.pop("headers", {}) or {} + _params = kwargs.pop("params", {}) or {} + + cls = kwargs.pop("cls", None) # type: ClsType[None] + + request = build_resources_delete_request( resource_group_name=resource_group_name, resource_provider_namespace=resource_provider_namespace, parent_resource_path=parent_resource_path, @@ -1532,16 +1954,17 @@ async def _delete_initial( # pylint: disable=inconsistent-return-statements resource_name=resource_name, subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self._delete_initial.metadata['url'], + template_url=self._delete_initial.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200, 202, 204]: @@ -1551,11 +1974,10 @@ 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/{resourceProviderNamespace}/{parentResourcePath}/{resourceType}/{resourceName}"} # type: ignore - + _delete_initial.metadata = {"url": "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{parentResourcePath}/{resourceType}/{resourceName}"} # type: ignore @distributed_trace_async - async def begin_delete( # pylint: disable=inconsistent-return-statements + async def begin_delete( self, resource_group_name: str, resource_provider_namespace: str, @@ -1568,17 +1990,17 @@ async def begin_delete( # pylint: disable=inconsistent-return-statements """Deletes a resource. :param resource_group_name: The name of the resource group that contains the resource to - delete. The name is case insensitive. + delete. The name is case insensitive. Required. :type resource_group_name: str - :param resource_provider_namespace: The namespace of the resource provider. + :param resource_provider_namespace: The namespace of the resource provider. Required. :type resource_provider_namespace: str - :param parent_resource_path: The parent resource identity. + :param parent_resource_path: The parent resource identity. Required. :type parent_resource_path: str - :param resource_type: The resource type. + :param resource_type: The resource type. Required. :type resource_type: str - :param resource_name: The name of the resource to delete. + :param resource_name: The name of the resource to delete. Required. :type resource_name: str - :param api_version: The API version to use for the operation. + :param api_version: The API version to use for the operation. Required. :type api_version: str :keyword callable cls: A custom type or function that will be passed the direct response :keyword str continuation_token: A continuation token to restart a poller from a saved state. @@ -1590,46 +2012,50 @@ async def begin_delete( # pylint: disable=inconsistent-return-statements Retry-After header is present. :return: An instance of AsyncLROPoller that returns either None or the result of cls(response) :rtype: ~azure.core.polling.AsyncLROPoller[None] - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - polling = kwargs.pop('polling', True) # type: Union[bool, AsyncPollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType[None] - lro_delay = kwargs.pop( - 'polling_interval', - self._config.polling_interval - ) - cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] + _headers = kwargs.pop("headers", {}) or {} + _params = kwargs.pop("params", {}) or {} + + cls = kwargs.pop("cls", None) # type: ClsType[None] + polling = kwargs.pop("polling", True) # type: Union[bool, AsyncPollingMethod] + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token = kwargs.pop("continuation_token", None) # type: Optional[str] if cont_token is None: - raw_result = await self._delete_initial( + raw_result = await self._delete_initial( # type: ignore resource_group_name=resource_group_name, resource_provider_namespace=resource_provider_namespace, parent_resource_path=parent_resource_path, resource_type=resource_type, resource_name=resource_name, api_version=api_version, - cls=lambda x,y,z: x, + cls=lambda x, y, z: x, + headers=_headers, + params=_params, **kwargs ) - kwargs.pop('error_map', None) + kwargs.pop("error_map", None) - def get_long_running_output(pipeline_response): + def get_long_running_output(pipeline_response): # pylint: disable=inconsistent-return-statements if cls: return cls(pipeline_response, None, {}) - - if polling is True: polling_method = AsyncARMPolling(lro_delay, **kwargs) - elif polling is False: polling_method = AsyncNoPolling() - else: polling_method = polling + if polling is True: + polling_method = cast(AsyncPollingMethod, AsyncARMPolling(lro_delay, **kwargs)) # type: AsyncPollingMethod + elif polling is False: + polling_method = cast(AsyncPollingMethod, AsyncNoPolling()) + else: + polling_method = polling if cont_token: return AsyncLROPoller.from_continuation_token( polling_method=polling_method, continuation_token=cont_token, client=self._client, - deserialization_callback=get_long_running_output + deserialization_callback=get_long_running_output, ) return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) - begin_delete.metadata = {'url': "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{parentResourcePath}/{resourceType}/{resourceName}"} # type: ignore + begin_delete.metadata = {"url": "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{parentResourcePath}/{resourceType}/{resourceName}"} # type: ignore async def _create_or_update_initial( self, @@ -1639,39 +2065,53 @@ async def _create_or_update_initial( resource_type: str, resource_name: str, api_version: str, - parameters: "_models.GenericResource", + parameters: Union[_models.GenericResource, IO], **kwargs: Any - ) -> Optional["_models.GenericResource"]: - cls = kwargs.pop('cls', None) # type: ClsType[Optional["_models.GenericResource"]] + ) -> Optional[_models.GenericResource]: error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = kwargs.pop("params", {}) or {} - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[Optional[_models.GenericResource]] - _json = self._serialize.body(parameters, 'GenericResource') + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(parameters, (IO, bytes)): + _content = parameters + else: + _json = self._serialize.body(parameters, "GenericResource") - request = build_resources_create_or_update_request_initial( + request = build_resources_create_or_update_request( resource_group_name=resource_group_name, resource_provider_namespace=resource_provider_namespace, parent_resource_path=parent_resource_path, resource_type=resource_type, resource_name=resource_name, subscription_id=self._config.subscription_id, - content_type=content_type, api_version=api_version, + content_type=content_type, json=_json, - template_url=self._create_or_update_initial.metadata['url'], + content=_content, + template_url=self._create_or_update_initial.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200, 201, 202]: @@ -1680,18 +2120,115 @@ async def _create_or_update_initial( deserialized = None if response.status_code == 200: - deserialized = self._deserialize('GenericResource', pipeline_response) + deserialized = self._deserialize("GenericResource", pipeline_response) if response.status_code == 201: - deserialized = self._deserialize('GenericResource', pipeline_response) + deserialized = self._deserialize("GenericResource", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - _create_or_update_initial.metadata = {'url': "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{parentResourcePath}/{resourceType}/{resourceName}"} # type: ignore + _create_or_update_initial.metadata = {"url": "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{parentResourcePath}/{resourceType}/{resourceName}"} # type: ignore + @overload + async def begin_create_or_update( + self, + resource_group_name: str, + resource_provider_namespace: str, + parent_resource_path: str, + resource_type: str, + resource_name: str, + api_version: str, + parameters: _models.GenericResource, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> AsyncLROPoller[_models.GenericResource]: + """Creates a resource. + + :param resource_group_name: The name of the resource group for the resource. The name is case + insensitive. Required. + :type resource_group_name: str + :param resource_provider_namespace: The namespace of the resource provider. Required. + :type resource_provider_namespace: str + :param parent_resource_path: The parent resource identity. Required. + :type parent_resource_path: str + :param resource_type: The resource type of the resource to create. Required. + :type resource_type: str + :param resource_name: The name of the resource to create. Required. + :type resource_name: str + :param api_version: The API version to use for the operation. Required. + :type api_version: str + :param parameters: Parameters for creating or updating the resource. Required. + :type parameters: ~azure.mgmt.resource.resources.v2017_05_10.models.GenericResource + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be AsyncARMPolling. Pass in False for + this operation to not poll, or pass in your own initialized polling object for a personal + polling strategy. + :paramtype polling: bool or ~azure.core.polling.AsyncPollingMethod + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of AsyncLROPoller that returns either GenericResource or the result of + cls(response) + :rtype: + ~azure.core.polling.AsyncLROPoller[~azure.mgmt.resource.resources.v2017_05_10.models.GenericResource] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + async def begin_create_or_update( + self, + resource_group_name: str, + resource_provider_namespace: str, + parent_resource_path: str, + resource_type: str, + resource_name: str, + api_version: str, + parameters: IO, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> AsyncLROPoller[_models.GenericResource]: + """Creates a resource. + + :param resource_group_name: The name of the resource group for the resource. The name is case + insensitive. Required. + :type resource_group_name: str + :param resource_provider_namespace: The namespace of the resource provider. Required. + :type resource_provider_namespace: str + :param parent_resource_path: The parent resource identity. Required. + :type parent_resource_path: str + :param resource_type: The resource type of the resource to create. Required. + :type resource_type: str + :param resource_name: The name of the resource to create. Required. + :type resource_name: str + :param api_version: The API version to use for the operation. Required. + :type api_version: str + :param parameters: Parameters for creating or updating the resource. Required. + :type parameters: IO + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be AsyncARMPolling. Pass in False for + this operation to not poll, or pass in your own initialized polling object for a personal + polling strategy. + :paramtype polling: bool or ~azure.core.polling.AsyncPollingMethod + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of AsyncLROPoller that returns either GenericResource or the result of + cls(response) + :rtype: + ~azure.core.polling.AsyncLROPoller[~azure.mgmt.resource.resources.v2017_05_10.models.GenericResource] + :raises ~azure.core.exceptions.HttpResponseError: + """ @distributed_trace_async async def begin_create_or_update( @@ -1702,26 +2239,30 @@ async def begin_create_or_update( resource_type: str, resource_name: str, api_version: str, - parameters: "_models.GenericResource", + parameters: Union[_models.GenericResource, IO], **kwargs: Any - ) -> AsyncLROPoller["_models.GenericResource"]: + ) -> AsyncLROPoller[_models.GenericResource]: """Creates a resource. :param resource_group_name: The name of the resource group for the resource. The name is case - insensitive. + insensitive. Required. :type resource_group_name: str - :param resource_provider_namespace: The namespace of the resource provider. + :param resource_provider_namespace: The namespace of the resource provider. Required. :type resource_provider_namespace: str - :param parent_resource_path: The parent resource identity. + :param parent_resource_path: The parent resource identity. Required. :type parent_resource_path: str - :param resource_type: The resource type of the resource to create. + :param resource_type: The resource type of the resource to create. Required. :type resource_type: str - :param resource_name: The name of the resource to create. + :param resource_name: The name of the resource to create. Required. :type resource_name: str - :param api_version: The API version to use for the operation. + :param api_version: The API version to use for the operation. Required. :type api_version: str - :param parameters: Parameters for creating or updating the resource. - :type parameters: ~azure.mgmt.resource.resources.v2017_05_10.models.GenericResource + :param parameters: Parameters for creating or updating the resource. Is either a model type or + a IO type. Required. + :type parameters: ~azure.mgmt.resource.resources.v2017_05_10.models.GenericResource or IO + :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. + Default value is None. + :paramtype content_type: str :keyword callable cls: A custom type or function that will be passed the direct response :keyword str continuation_token: A continuation token to restart a poller from a saved state. :keyword polling: By default, your polling method will be AsyncARMPolling. Pass in False for @@ -1734,18 +2275,18 @@ async def begin_create_or_update( cls(response) :rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.resource.resources.v2017_05_10.models.GenericResource] - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] - polling = kwargs.pop('polling', True) # type: Union[bool, AsyncPollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType["_models.GenericResource"] - lro_delay = kwargs.pop( - 'polling_interval', - self._config.polling_interval - ) - cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = kwargs.pop("params", {}) or {} + + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.GenericResource] + polling = kwargs.pop("polling", True) # type: Union[bool, AsyncPollingMethod] + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token = kwargs.pop("continuation_token", None) # type: Optional[str] if cont_token is None: - raw_result = await self._create_or_update_initial( + raw_result = await self._create_or_update_initial( # type: ignore resource_group_name=resource_group_name, resource_provider_namespace=resource_provider_namespace, parent_resource_path=parent_resource_path, @@ -1754,32 +2295,35 @@ async def begin_create_or_update( api_version=api_version, parameters=parameters, content_type=content_type, - cls=lambda x,y,z: x, + cls=lambda x, y, z: x, + headers=_headers, + params=_params, **kwargs ) - kwargs.pop('error_map', None) + kwargs.pop("error_map", None) def get_long_running_output(pipeline_response): - response = pipeline_response.http_response - deserialized = self._deserialize('GenericResource', pipeline_response) + deserialized = self._deserialize("GenericResource", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - - if polling is True: polling_method = AsyncARMPolling(lro_delay, **kwargs) - elif polling is False: polling_method = AsyncNoPolling() - else: polling_method = polling + if polling is True: + polling_method = cast(AsyncPollingMethod, AsyncARMPolling(lro_delay, **kwargs)) # type: AsyncPollingMethod + elif polling is False: + polling_method = cast(AsyncPollingMethod, AsyncNoPolling()) + else: + polling_method = polling if cont_token: return AsyncLROPoller.from_continuation_token( polling_method=polling_method, continuation_token=cont_token, client=self._client, - deserialization_callback=get_long_running_output + deserialization_callback=get_long_running_output, ) return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) - begin_create_or_update.metadata = {'url': "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{parentResourcePath}/{resourceType}/{resourceName}"} # type: ignore + begin_create_or_update.metadata = {"url": "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{parentResourcePath}/{resourceType}/{resourceName}"} # type: ignore async def _update_initial( self, @@ -1789,39 +2333,53 @@ async def _update_initial( resource_type: str, resource_name: str, api_version: str, - parameters: "_models.GenericResource", + parameters: Union[_models.GenericResource, IO], **kwargs: Any - ) -> Optional["_models.GenericResource"]: - cls = kwargs.pop('cls', None) # type: ClsType[Optional["_models.GenericResource"]] + ) -> Optional[_models.GenericResource]: error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = kwargs.pop("params", {}) or {} - _json = self._serialize.body(parameters, 'GenericResource') + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[Optional[_models.GenericResource]] - request = build_resources_update_request_initial( + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(parameters, (IO, bytes)): + _content = parameters + else: + _json = self._serialize.body(parameters, "GenericResource") + + request = build_resources_update_request( resource_group_name=resource_group_name, resource_provider_namespace=resource_provider_namespace, parent_resource_path=parent_resource_path, resource_type=resource_type, resource_name=resource_name, subscription_id=self._config.subscription_id, - content_type=content_type, api_version=api_version, + content_type=content_type, json=_json, - template_url=self._update_initial.metadata['url'], + content=_content, + template_url=self._update_initial.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200, 202]: @@ -1830,15 +2388,112 @@ async def _update_initial( deserialized = None if response.status_code == 200: - deserialized = self._deserialize('GenericResource', pipeline_response) + deserialized = self._deserialize("GenericResource", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - _update_initial.metadata = {'url': "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{parentResourcePath}/{resourceType}/{resourceName}"} # type: ignore + _update_initial.metadata = {"url": "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{parentResourcePath}/{resourceType}/{resourceName}"} # type: ignore + @overload + async def begin_update( + self, + resource_group_name: str, + resource_provider_namespace: str, + parent_resource_path: str, + resource_type: str, + resource_name: str, + api_version: str, + parameters: _models.GenericResource, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> AsyncLROPoller[_models.GenericResource]: + """Updates a resource. + + :param resource_group_name: The name of the resource group for the resource. The name is case + insensitive. Required. + :type resource_group_name: str + :param resource_provider_namespace: The namespace of the resource provider. Required. + :type resource_provider_namespace: str + :param parent_resource_path: The parent resource identity. Required. + :type parent_resource_path: str + :param resource_type: The resource type of the resource to update. Required. + :type resource_type: str + :param resource_name: The name of the resource to update. Required. + :type resource_name: str + :param api_version: The API version to use for the operation. Required. + :type api_version: str + :param parameters: Parameters for updating the resource. Required. + :type parameters: ~azure.mgmt.resource.resources.v2017_05_10.models.GenericResource + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be AsyncARMPolling. Pass in False for + this operation to not poll, or pass in your own initialized polling object for a personal + polling strategy. + :paramtype polling: bool or ~azure.core.polling.AsyncPollingMethod + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of AsyncLROPoller that returns either GenericResource or the result of + cls(response) + :rtype: + ~azure.core.polling.AsyncLROPoller[~azure.mgmt.resource.resources.v2017_05_10.models.GenericResource] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + async def begin_update( + self, + resource_group_name: str, + resource_provider_namespace: str, + parent_resource_path: str, + resource_type: str, + resource_name: str, + api_version: str, + parameters: IO, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> AsyncLROPoller[_models.GenericResource]: + """Updates a resource. + + :param resource_group_name: The name of the resource group for the resource. The name is case + insensitive. Required. + :type resource_group_name: str + :param resource_provider_namespace: The namespace of the resource provider. Required. + :type resource_provider_namespace: str + :param parent_resource_path: The parent resource identity. Required. + :type parent_resource_path: str + :param resource_type: The resource type of the resource to update. Required. + :type resource_type: str + :param resource_name: The name of the resource to update. Required. + :type resource_name: str + :param api_version: The API version to use for the operation. Required. + :type api_version: str + :param parameters: Parameters for updating the resource. Required. + :type parameters: IO + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be AsyncARMPolling. Pass in False for + this operation to not poll, or pass in your own initialized polling object for a personal + polling strategy. + :paramtype polling: bool or ~azure.core.polling.AsyncPollingMethod + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of AsyncLROPoller that returns either GenericResource or the result of + cls(response) + :rtype: + ~azure.core.polling.AsyncLROPoller[~azure.mgmt.resource.resources.v2017_05_10.models.GenericResource] + :raises ~azure.core.exceptions.HttpResponseError: + """ @distributed_trace_async async def begin_update( @@ -1849,26 +2504,30 @@ async def begin_update( resource_type: str, resource_name: str, api_version: str, - parameters: "_models.GenericResource", + parameters: Union[_models.GenericResource, IO], **kwargs: Any - ) -> AsyncLROPoller["_models.GenericResource"]: + ) -> AsyncLROPoller[_models.GenericResource]: """Updates a resource. :param resource_group_name: The name of the resource group for the resource. The name is case - insensitive. + insensitive. Required. :type resource_group_name: str - :param resource_provider_namespace: The namespace of the resource provider. + :param resource_provider_namespace: The namespace of the resource provider. Required. :type resource_provider_namespace: str - :param parent_resource_path: The parent resource identity. + :param parent_resource_path: The parent resource identity. Required. :type parent_resource_path: str - :param resource_type: The resource type of the resource to update. + :param resource_type: The resource type of the resource to update. Required. :type resource_type: str - :param resource_name: The name of the resource to update. + :param resource_name: The name of the resource to update. Required. :type resource_name: str - :param api_version: The API version to use for the operation. + :param api_version: The API version to use for the operation. Required. :type api_version: str - :param parameters: Parameters for updating the resource. - :type parameters: ~azure.mgmt.resource.resources.v2017_05_10.models.GenericResource + :param parameters: Parameters for updating the resource. Is either a model type or a IO type. + Required. + :type parameters: ~azure.mgmt.resource.resources.v2017_05_10.models.GenericResource or IO + :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. + Default value is None. + :paramtype content_type: str :keyword callable cls: A custom type or function that will be passed the direct response :keyword str continuation_token: A continuation token to restart a poller from a saved state. :keyword polling: By default, your polling method will be AsyncARMPolling. Pass in False for @@ -1881,18 +2540,18 @@ async def begin_update( cls(response) :rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.resource.resources.v2017_05_10.models.GenericResource] - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] - polling = kwargs.pop('polling', True) # type: Union[bool, AsyncPollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType["_models.GenericResource"] - lro_delay = kwargs.pop( - 'polling_interval', - self._config.polling_interval - ) - cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = kwargs.pop("params", {}) or {} + + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.GenericResource] + polling = kwargs.pop("polling", True) # type: Union[bool, AsyncPollingMethod] + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token = kwargs.pop("continuation_token", None) # type: Optional[str] if cont_token is None: - raw_result = await self._update_initial( + raw_result = await self._update_initial( # type: ignore resource_group_name=resource_group_name, resource_provider_namespace=resource_provider_namespace, parent_resource_path=parent_resource_path, @@ -1901,32 +2560,35 @@ async def begin_update( api_version=api_version, parameters=parameters, content_type=content_type, - cls=lambda x,y,z: x, + cls=lambda x, y, z: x, + headers=_headers, + params=_params, **kwargs ) - kwargs.pop('error_map', None) + kwargs.pop("error_map", None) def get_long_running_output(pipeline_response): - response = pipeline_response.http_response - deserialized = self._deserialize('GenericResource', pipeline_response) + deserialized = self._deserialize("GenericResource", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - - if polling is True: polling_method = AsyncARMPolling(lro_delay, **kwargs) - elif polling is False: polling_method = AsyncNoPolling() - else: polling_method = polling + if polling is True: + polling_method = cast(AsyncPollingMethod, AsyncARMPolling(lro_delay, **kwargs)) # type: AsyncPollingMethod + elif polling is False: + polling_method = cast(AsyncPollingMethod, AsyncNoPolling()) + else: + polling_method = polling if cont_token: return AsyncLROPoller.from_continuation_token( polling_method=polling_method, continuation_token=cont_token, client=self._client, - deserialization_callback=get_long_running_output + deserialization_callback=get_long_running_output, ) return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) - begin_update.metadata = {'url': "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{parentResourcePath}/{resourceType}/{resourceName}"} # type: ignore + begin_update.metadata = {"url": "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{parentResourcePath}/{resourceType}/{resourceName}"} # type: ignore @distributed_trace_async async def get( @@ -1938,34 +2600,40 @@ async def get( resource_name: str, api_version: str, **kwargs: Any - ) -> "_models.GenericResource": + ) -> _models.GenericResource: """Gets a resource. :param resource_group_name: The name of the resource group containing the resource to get. The - name is case insensitive. + name is case insensitive. Required. :type resource_group_name: str - :param resource_provider_namespace: The namespace of the resource provider. + :param resource_provider_namespace: The namespace of the resource provider. Required. :type resource_provider_namespace: str - :param parent_resource_path: The parent resource identity. + :param parent_resource_path: The parent resource identity. Required. :type parent_resource_path: str - :param resource_type: The resource type of the resource. + :param resource_type: The resource type of the resource. Required. :type resource_type: str - :param resource_name: The name of the resource to get. + :param resource_name: The name of the resource to get. Required. :type resource_name: str - :param api_version: The API version to use for the operation. + :param api_version: The API version to use for the operation. Required. :type api_version: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: GenericResource, or the result of cls(response) + :return: GenericResource or the result of cls(response) :rtype: ~azure.mgmt.resource.resources.v2017_05_10.models.GenericResource - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.GenericResource"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = kwargs.pop("params", {}) or {} + + cls = kwargs.pop("cls", None) # type: ClsType[_models.GenericResource] - request = build_resources_get_request( resource_group_name=resource_group_name, resource_provider_namespace=resource_provider_namespace, @@ -1974,72 +2642,75 @@ async def get( resource_name=resource_name, subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.get.metadata['url'], + template_url=self.get.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) - deserialized = self._deserialize('GenericResource', pipeline_response) + deserialized = self._deserialize("GenericResource", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - get.metadata = {'url': "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{parentResourcePath}/{resourceType}/{resourceName}"} # type: ignore - + get.metadata = {"url": "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{parentResourcePath}/{resourceType}/{resourceName}"} # type: ignore @distributed_trace_async - async def check_existence_by_id( - self, - resource_id: str, - api_version: str, - **kwargs: Any - ) -> bool: + async def check_existence_by_id(self, resource_id: str, api_version: str, **kwargs: Any) -> bool: """Checks by ID whether a resource exists. :param resource_id: The fully qualified ID of the resource, including the resource name and resource type. Use the format, /subscriptions/{guid}/resourceGroups/{resource-group-name}/{resource-provider-namespace}/{resource-type}/{resource-name}. + Required. :type resource_id: str - :param api_version: The API version to use for the operation. + :param api_version: The API version to use for the operation. Required. :type api_version: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: bool, or the result of cls(response) + :return: bool or the result of cls(response) :rtype: bool - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType[None] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = kwargs.pop("params", {}) or {} + + cls = kwargs.pop("cls", None) # type: ClsType[None] - request = build_resources_check_existence_by_id_request( resource_id=resource_id, api_version=api_version, - template_url=self.check_existence_by_id.metadata['url'], + template_url=self.check_existence_by_id.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [204, 404]: @@ -2050,35 +2721,38 @@ async def check_existence_by_id( return cls(pipeline_response, None, {}) return 200 <= response.status_code <= 299 - check_existence_by_id.metadata = {'url': "/{resourceId}"} # type: ignore - + check_existence_by_id.metadata = {"url": "/{resourceId}"} # type: ignore async def _delete_by_id_initial( # pylint: disable=inconsistent-return-statements - self, - resource_id: str, - api_version: str, - **kwargs: Any + self, resource_id: str, api_version: str, **kwargs: Any ) -> None: - cls = kwargs.pop('cls', None) # type: ClsType[None] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = kwargs.pop("params", {}) or {} + + cls = kwargs.pop("cls", None) # type: ClsType[None] - - request = build_resources_delete_by_id_request_initial( + request = build_resources_delete_by_id_request( resource_id=resource_id, api_version=api_version, - template_url=self._delete_by_id_initial.metadata['url'], + template_url=self._delete_by_id_initial.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200, 202, 204]: @@ -2088,23 +2762,18 @@ async def _delete_by_id_initial( # pylint: disable=inconsistent-return-statemen if cls: return cls(pipeline_response, None, {}) - _delete_by_id_initial.metadata = {'url': "/{resourceId}"} # type: ignore - + _delete_by_id_initial.metadata = {"url": "/{resourceId}"} # type: ignore @distributed_trace_async - async def begin_delete_by_id( # pylint: disable=inconsistent-return-statements - self, - resource_id: str, - api_version: str, - **kwargs: Any - ) -> AsyncLROPoller[None]: + async def begin_delete_by_id(self, resource_id: str, api_version: str, **kwargs: Any) -> AsyncLROPoller[None]: """Deletes a resource by ID. :param resource_id: The fully qualified ID of the resource, including the resource name and resource type. Use the format, /subscriptions/{guid}/resourceGroups/{resource-group-name}/{resource-provider-namespace}/{resource-type}/{resource-name}. + Required. :type resource_id: str - :param api_version: The API version to use for the operation. + :param api_version: The API version to use for the operation. Required. :type api_version: str :keyword callable cls: A custom type or function that will be passed the direct response :keyword str continuation_token: A continuation token to restart a poller from a saved state. @@ -2116,75 +2785,89 @@ async def begin_delete_by_id( # pylint: disable=inconsistent-return-statements Retry-After header is present. :return: An instance of AsyncLROPoller that returns either None or the result of cls(response) :rtype: ~azure.core.polling.AsyncLROPoller[None] - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - polling = kwargs.pop('polling', True) # type: Union[bool, AsyncPollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType[None] - lro_delay = kwargs.pop( - 'polling_interval', - self._config.polling_interval - ) - cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] + _headers = kwargs.pop("headers", {}) or {} + _params = kwargs.pop("params", {}) or {} + + cls = kwargs.pop("cls", None) # type: ClsType[None] + polling = kwargs.pop("polling", True) # type: Union[bool, AsyncPollingMethod] + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token = kwargs.pop("continuation_token", None) # type: Optional[str] if cont_token is None: - raw_result = await self._delete_by_id_initial( + raw_result = await self._delete_by_id_initial( # type: ignore resource_id=resource_id, api_version=api_version, - cls=lambda x,y,z: x, + cls=lambda x, y, z: x, + headers=_headers, + params=_params, **kwargs ) - kwargs.pop('error_map', None) + kwargs.pop("error_map", None) - def get_long_running_output(pipeline_response): + def get_long_running_output(pipeline_response): # pylint: disable=inconsistent-return-statements if cls: return cls(pipeline_response, None, {}) - - if polling is True: polling_method = AsyncARMPolling(lro_delay, **kwargs) - elif polling is False: polling_method = AsyncNoPolling() - else: polling_method = polling + if polling is True: + polling_method = cast(AsyncPollingMethod, AsyncARMPolling(lro_delay, **kwargs)) # type: AsyncPollingMethod + elif polling is False: + polling_method = cast(AsyncPollingMethod, AsyncNoPolling()) + else: + polling_method = polling if cont_token: return AsyncLROPoller.from_continuation_token( polling_method=polling_method, continuation_token=cont_token, client=self._client, - deserialization_callback=get_long_running_output + deserialization_callback=get_long_running_output, ) return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) - begin_delete_by_id.metadata = {'url': "/{resourceId}"} # type: ignore + begin_delete_by_id.metadata = {"url": "/{resourceId}"} # type: ignore async def _create_or_update_by_id_initial( - self, - resource_id: str, - api_version: str, - parameters: "_models.GenericResource", - **kwargs: Any - ) -> Optional["_models.GenericResource"]: - cls = kwargs.pop('cls', None) # type: ClsType[Optional["_models.GenericResource"]] + self, resource_id: str, api_version: str, parameters: Union[_models.GenericResource, IO], **kwargs: Any + ) -> Optional[_models.GenericResource]: error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = kwargs.pop("params", {}) or {} - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[Optional[_models.GenericResource]] - _json = self._serialize.body(parameters, 'GenericResource') + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(parameters, (IO, bytes)): + _content = parameters + else: + _json = self._serialize.body(parameters, "GenericResource") - request = build_resources_create_or_update_by_id_request_initial( + request = build_resources_create_or_update_by_id_request( resource_id=resource_id, - content_type=content_type, api_version=api_version, + content_type=content_type, json=_json, - template_url=self._create_or_update_by_id_initial.metadata['url'], + content=_content, + template_url=self._create_or_update_by_id_initial.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200, 201, 202]: @@ -2193,37 +2876,42 @@ async def _create_or_update_by_id_initial( deserialized = None if response.status_code == 200: - deserialized = self._deserialize('GenericResource', pipeline_response) + deserialized = self._deserialize("GenericResource", pipeline_response) if response.status_code == 201: - deserialized = self._deserialize('GenericResource', pipeline_response) + deserialized = self._deserialize("GenericResource", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - _create_or_update_by_id_initial.metadata = {'url': "/{resourceId}"} # type: ignore - + _create_or_update_by_id_initial.metadata = {"url": "/{resourceId}"} # type: ignore - @distributed_trace_async + @overload async def begin_create_or_update_by_id( self, resource_id: str, api_version: str, - parameters: "_models.GenericResource", + parameters: _models.GenericResource, + *, + content_type: str = "application/json", **kwargs: Any - ) -> AsyncLROPoller["_models.GenericResource"]: + ) -> AsyncLROPoller[_models.GenericResource]: """Create a resource by ID. :param resource_id: The fully qualified ID of the resource, including the resource name and resource type. Use the format, /subscriptions/{guid}/resourceGroups/{resource-group-name}/{resource-provider-namespace}/{resource-type}/{resource-name}. + Required. :type resource_id: str - :param api_version: The API version to use for the operation. + :param api_version: The API version to use for the operation. Required. :type api_version: str - :param parameters: Create or update resource parameters. + :param parameters: Create or update resource parameters. Required. :type parameters: ~azure.mgmt.resource.resources.v2017_05_10.models.GenericResource + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str :keyword callable cls: A custom type or function that will be passed the direct response :keyword str continuation_token: A continuation token to restart a poller from a saved state. :keyword polling: By default, your polling method will be AsyncARMPolling. Pass in False for @@ -2236,81 +2924,167 @@ async def begin_create_or_update_by_id( cls(response) :rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.resource.resources.v2017_05_10.models.GenericResource] - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] - polling = kwargs.pop('polling', True) # type: Union[bool, AsyncPollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType["_models.GenericResource"] - lro_delay = kwargs.pop( - 'polling_interval', - self._config.polling_interval - ) - cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] + + @overload + async def begin_create_or_update_by_id( + self, + resource_id: str, + api_version: str, + parameters: IO, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> AsyncLROPoller[_models.GenericResource]: + """Create a resource by ID. + + :param resource_id: The fully qualified ID of the resource, including the resource name and + resource type. Use the format, + /subscriptions/{guid}/resourceGroups/{resource-group-name}/{resource-provider-namespace}/{resource-type}/{resource-name}. + Required. + :type resource_id: str + :param api_version: The API version to use for the operation. Required. + :type api_version: str + :param parameters: Create or update resource parameters. Required. + :type parameters: IO + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be AsyncARMPolling. Pass in False for + this operation to not poll, or pass in your own initialized polling object for a personal + polling strategy. + :paramtype polling: bool or ~azure.core.polling.AsyncPollingMethod + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of AsyncLROPoller that returns either GenericResource or the result of + cls(response) + :rtype: + ~azure.core.polling.AsyncLROPoller[~azure.mgmt.resource.resources.v2017_05_10.models.GenericResource] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace_async + async def begin_create_or_update_by_id( + self, resource_id: str, api_version: str, parameters: Union[_models.GenericResource, IO], **kwargs: Any + ) -> AsyncLROPoller[_models.GenericResource]: + """Create a resource by ID. + + :param resource_id: The fully qualified ID of the resource, including the resource name and + resource type. Use the format, + /subscriptions/{guid}/resourceGroups/{resource-group-name}/{resource-provider-namespace}/{resource-type}/{resource-name}. + Required. + :type resource_id: str + :param api_version: The API version to use for the operation. Required. + :type api_version: str + :param parameters: Create or update resource parameters. Is either a model type or a IO type. + Required. + :type parameters: ~azure.mgmt.resource.resources.v2017_05_10.models.GenericResource or IO + :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. + Default value is None. + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be AsyncARMPolling. Pass in False for + this operation to not poll, or pass in your own initialized polling object for a personal + polling strategy. + :paramtype polling: bool or ~azure.core.polling.AsyncPollingMethod + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of AsyncLROPoller that returns either GenericResource or the result of + cls(response) + :rtype: + ~azure.core.polling.AsyncLROPoller[~azure.mgmt.resource.resources.v2017_05_10.models.GenericResource] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = kwargs.pop("params", {}) or {} + + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.GenericResource] + polling = kwargs.pop("polling", True) # type: Union[bool, AsyncPollingMethod] + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token = kwargs.pop("continuation_token", None) # type: Optional[str] if cont_token is None: - raw_result = await self._create_or_update_by_id_initial( + raw_result = await self._create_or_update_by_id_initial( # type: ignore resource_id=resource_id, api_version=api_version, parameters=parameters, content_type=content_type, - cls=lambda x,y,z: x, + cls=lambda x, y, z: x, + headers=_headers, + params=_params, **kwargs ) - kwargs.pop('error_map', None) + kwargs.pop("error_map", None) def get_long_running_output(pipeline_response): - response = pipeline_response.http_response - deserialized = self._deserialize('GenericResource', pipeline_response) + deserialized = self._deserialize("GenericResource", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - - if polling is True: polling_method = AsyncARMPolling(lro_delay, **kwargs) - elif polling is False: polling_method = AsyncNoPolling() - else: polling_method = polling + if polling is True: + polling_method = cast(AsyncPollingMethod, AsyncARMPolling(lro_delay, **kwargs)) # type: AsyncPollingMethod + elif polling is False: + polling_method = cast(AsyncPollingMethod, AsyncNoPolling()) + else: + polling_method = polling if cont_token: return AsyncLROPoller.from_continuation_token( polling_method=polling_method, continuation_token=cont_token, client=self._client, - deserialization_callback=get_long_running_output + deserialization_callback=get_long_running_output, ) return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) - begin_create_or_update_by_id.metadata = {'url': "/{resourceId}"} # type: ignore + begin_create_or_update_by_id.metadata = {"url": "/{resourceId}"} # type: ignore async def _update_by_id_initial( - self, - resource_id: str, - api_version: str, - parameters: "_models.GenericResource", - **kwargs: Any - ) -> Optional["_models.GenericResource"]: - cls = kwargs.pop('cls', None) # type: ClsType[Optional["_models.GenericResource"]] + self, resource_id: str, api_version: str, parameters: Union[_models.GenericResource, IO], **kwargs: Any + ) -> Optional[_models.GenericResource]: error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = kwargs.pop("params", {}) or {} - _json = self._serialize.body(parameters, 'GenericResource') + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[Optional[_models.GenericResource]] - request = build_resources_update_by_id_request_initial( + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(parameters, (IO, bytes)): + _content = parameters + else: + _json = self._serialize.body(parameters, "GenericResource") + + request = build_resources_update_by_id_request( resource_id=resource_id, - content_type=content_type, api_version=api_version, + content_type=content_type, json=_json, - template_url=self._update_by_id_initial.metadata['url'], + content=_content, + template_url=self._update_by_id_initial.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200, 202]: @@ -2319,34 +3093,111 @@ async def _update_by_id_initial( deserialized = None if response.status_code == 200: - deserialized = self._deserialize('GenericResource', pipeline_response) + deserialized = self._deserialize("GenericResource", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - _update_by_id_initial.metadata = {'url': "/{resourceId}"} # type: ignore + _update_by_id_initial.metadata = {"url": "/{resourceId}"} # type: ignore - - @distributed_trace_async + @overload async def begin_update_by_id( self, resource_id: str, api_version: str, - parameters: "_models.GenericResource", + parameters: _models.GenericResource, + *, + content_type: str = "application/json", **kwargs: Any - ) -> AsyncLROPoller["_models.GenericResource"]: + ) -> AsyncLROPoller[_models.GenericResource]: """Updates a resource by ID. :param resource_id: The fully qualified ID of the resource, including the resource name and resource type. Use the format, /subscriptions/{guid}/resourceGroups/{resource-group-name}/{resource-provider-namespace}/{resource-type}/{resource-name}. + Required. :type resource_id: str - :param api_version: The API version to use for the operation. + :param api_version: The API version to use for the operation. Required. :type api_version: str - :param parameters: Update resource parameters. + :param parameters: Update resource parameters. Required. :type parameters: ~azure.mgmt.resource.resources.v2017_05_10.models.GenericResource + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be AsyncARMPolling. Pass in False for + this operation to not poll, or pass in your own initialized polling object for a personal + polling strategy. + :paramtype polling: bool or ~azure.core.polling.AsyncPollingMethod + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of AsyncLROPoller that returns either GenericResource or the result of + cls(response) + :rtype: + ~azure.core.polling.AsyncLROPoller[~azure.mgmt.resource.resources.v2017_05_10.models.GenericResource] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + async def begin_update_by_id( + self, + resource_id: str, + api_version: str, + parameters: IO, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> AsyncLROPoller[_models.GenericResource]: + """Updates a resource by ID. + + :param resource_id: The fully qualified ID of the resource, including the resource name and + resource type. Use the format, + /subscriptions/{guid}/resourceGroups/{resource-group-name}/{resource-provider-namespace}/{resource-type}/{resource-name}. + Required. + :type resource_id: str + :param api_version: The API version to use for the operation. Required. + :type api_version: str + :param parameters: Update resource parameters. Required. + :type parameters: IO + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be AsyncARMPolling. Pass in False for + this operation to not poll, or pass in your own initialized polling object for a personal + polling strategy. + :paramtype polling: bool or ~azure.core.polling.AsyncPollingMethod + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of AsyncLROPoller that returns either GenericResource or the result of + cls(response) + :rtype: + ~azure.core.polling.AsyncLROPoller[~azure.mgmt.resource.resources.v2017_05_10.models.GenericResource] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace_async + async def begin_update_by_id( + self, resource_id: str, api_version: str, parameters: Union[_models.GenericResource, IO], **kwargs: Any + ) -> AsyncLROPoller[_models.GenericResource]: + """Updates a resource by ID. + + :param resource_id: The fully qualified ID of the resource, including the resource name and + resource type. Use the format, + /subscriptions/{guid}/resourceGroups/{resource-group-name}/{resource-provider-namespace}/{resource-type}/{resource-name}. + Required. + :type resource_id: str + :param api_version: The API version to use for the operation. Required. + :type api_version: str + :param parameters: Update resource parameters. Is either a model type or a IO type. Required. + :type parameters: ~azure.mgmt.resource.resources.v2017_05_10.models.GenericResource or IO + :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. + Default value is None. + :paramtype content_type: str :keyword callable cls: A custom type or function that will be passed the direct response :keyword str continuation_token: A continuation token to restart a poller from a saved state. :keyword polling: By default, your polling method will be AsyncARMPolling. Pass in False for @@ -2359,165 +3210,171 @@ async def begin_update_by_id( cls(response) :rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.resource.resources.v2017_05_10.models.GenericResource] - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] - polling = kwargs.pop('polling', True) # type: Union[bool, AsyncPollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType["_models.GenericResource"] - lro_delay = kwargs.pop( - 'polling_interval', - self._config.polling_interval - ) - cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = kwargs.pop("params", {}) or {} + + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.GenericResource] + polling = kwargs.pop("polling", True) # type: Union[bool, AsyncPollingMethod] + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token = kwargs.pop("continuation_token", None) # type: Optional[str] if cont_token is None: - raw_result = await self._update_by_id_initial( + raw_result = await self._update_by_id_initial( # type: ignore resource_id=resource_id, api_version=api_version, parameters=parameters, content_type=content_type, - cls=lambda x,y,z: x, + cls=lambda x, y, z: x, + headers=_headers, + params=_params, **kwargs ) - kwargs.pop('error_map', None) + kwargs.pop("error_map", None) def get_long_running_output(pipeline_response): - response = pipeline_response.http_response - deserialized = self._deserialize('GenericResource', pipeline_response) + deserialized = self._deserialize("GenericResource", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - - if polling is True: polling_method = AsyncARMPolling(lro_delay, **kwargs) - elif polling is False: polling_method = AsyncNoPolling() - else: polling_method = polling + if polling is True: + polling_method = cast(AsyncPollingMethod, AsyncARMPolling(lro_delay, **kwargs)) # type: AsyncPollingMethod + elif polling is False: + polling_method = cast(AsyncPollingMethod, AsyncNoPolling()) + else: + polling_method = polling if cont_token: return AsyncLROPoller.from_continuation_token( polling_method=polling_method, continuation_token=cont_token, client=self._client, - deserialization_callback=get_long_running_output + deserialization_callback=get_long_running_output, ) return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) - begin_update_by_id.metadata = {'url': "/{resourceId}"} # type: ignore + begin_update_by_id.metadata = {"url": "/{resourceId}"} # type: ignore @distributed_trace_async - async def get_by_id( - self, - resource_id: str, - api_version: str, - **kwargs: Any - ) -> "_models.GenericResource": + async def get_by_id(self, resource_id: str, api_version: str, **kwargs: Any) -> _models.GenericResource: """Gets a resource by ID. :param resource_id: The fully qualified ID of the resource, including the resource name and resource type. Use the format, /subscriptions/{guid}/resourceGroups/{resource-group-name}/{resource-provider-namespace}/{resource-type}/{resource-name}. + Required. :type resource_id: str - :param api_version: The API version to use for the operation. + :param api_version: The API version to use for the operation. Required. :type api_version: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: GenericResource, or the result of cls(response) + :return: GenericResource or the result of cls(response) :rtype: ~azure.mgmt.resource.resources.v2017_05_10.models.GenericResource - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.GenericResource"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = kwargs.pop("params", {}) or {} + + cls = kwargs.pop("cls", None) # type: ClsType[_models.GenericResource] - request = build_resources_get_by_id_request( resource_id=resource_id, api_version=api_version, - template_url=self.get_by_id.metadata['url'], + template_url=self.get_by_id.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) - deserialized = self._deserialize('GenericResource', pipeline_response) + deserialized = self._deserialize("GenericResource", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - get_by_id.metadata = {'url': "/{resourceId}"} # type: ignore + get_by_id.metadata = {"url": "/{resourceId}"} # type: ignore -class ResourceGroupsOperations: - """ResourceGroupsOperations async operations. - You should not instantiate this class directly. Instead, you should create a Client instance that - instantiates it for you and attaches it as an attribute. +class ResourceGroupsOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. - :ivar models: Alias to model classes used in this operation group. - :type models: ~azure.mgmt.resource.resources.v2017_05_10.models - :param client: Client for service requests. - :param config: Configuration of service client. - :param serializer: An object model serializer. - :param deserializer: An object model deserializer. + Instead, you should access the following operations through + :class:`~azure.mgmt.resource.resources.v2017_05_10.aio.ResourceManagementClient`'s + :attr:`resource_groups` attribute. """ models = _models - def __init__(self, client, config, serializer, deserializer) -> None: - self._client = client - self._serialize = serializer - self._deserialize = deserializer - self._config = config + def __init__(self, *args, **kwargs) -> None: + input_args = list(args) + self._client = input_args.pop(0) if input_args else kwargs.pop("client") + self._config = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") @distributed_trace_async - async def check_existence( - self, - resource_group_name: str, - **kwargs: Any - ) -> bool: + async def check_existence(self, resource_group_name: str, **kwargs: Any) -> bool: """Checks whether a resource group exists. :param resource_group_name: The name of the resource group to check. The name is case - insensitive. + insensitive. Required. :type resource_group_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: bool, or the result of cls(response) + :return: bool or the result of cls(response) :rtype: bool - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType[None] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + 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', "2017-05-10") # type: str + api_version = kwargs.pop("api_version", _params.pop("api-version", "2017-05-10")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[None] - request = build_resource_groups_check_existence_request( resource_group_name=resource_group_name, subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.check_existence.metadata['url'], + template_url=self.check_existence.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [204, 404]: @@ -2528,37 +3385,92 @@ async def check_existence( return cls(pipeline_response, None, {}) return 200 <= response.status_code <= 299 - check_existence.metadata = {'url': "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}"} # type: ignore - + check_existence.metadata = {"url": "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}"} # type: ignore - @distributed_trace_async + @overload async def create_or_update( self, resource_group_name: str, - parameters: "_models.ResourceGroup", + parameters: _models.ResourceGroup, + *, + content_type: str = "application/json", **kwargs: Any - ) -> "_models.ResourceGroup": + ) -> _models.ResourceGroup: """Creates or updates a resource group. - :param resource_group_name: The name of the resource group to create or update. + :param resource_group_name: The name of the resource group to create or update. Required. :type resource_group_name: str - :param parameters: Parameters supplied to the create or update a resource group. + :param parameters: Parameters supplied to the create or update a resource group. Required. :type parameters: ~azure.mgmt.resource.resources.v2017_05_10.models.ResourceGroup + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: ResourceGroup or the result of cls(response) + :rtype: ~azure.mgmt.resource.resources.v2017_05_10.models.ResourceGroup + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + async def create_or_update( + self, resource_group_name: str, parameters: IO, *, content_type: str = "application/json", **kwargs: Any + ) -> _models.ResourceGroup: + """Creates or updates a resource group. + + :param resource_group_name: The name of the resource group to create or update. Required. + :type resource_group_name: str + :param parameters: Parameters supplied to the create or update a resource group. Required. + :type parameters: IO + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: ResourceGroup or the result of cls(response) + :rtype: ~azure.mgmt.resource.resources.v2017_05_10.models.ResourceGroup + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace_async + async def create_or_update( + self, resource_group_name: str, parameters: Union[_models.ResourceGroup, IO], **kwargs: Any + ) -> _models.ResourceGroup: + """Creates or updates a resource group. + + :param resource_group_name: The name of the resource group to create or update. Required. + :type resource_group_name: str + :param parameters: Parameters supplied to the create or update a resource group. Is either a + model type or a IO type. Required. + :type parameters: ~azure.mgmt.resource.resources.v2017_05_10.models.ResourceGroup or IO + :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. + Default value is None. + :paramtype content_type: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: ResourceGroup, or the result of cls(response) + :return: ResourceGroup or the result of cls(response) :rtype: ~azure.mgmt.resource.resources.v2017_05_10.models.ResourceGroup - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.ResourceGroup"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', "2017-05-10") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + api_version = kwargs.pop("api_version", _params.pop("api-version", "2017-05-10")) # type: str + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.ResourceGroup] - _json = self._serialize.body(parameters, 'ResourceGroup') + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(parameters, (IO, bytes)): + _content = parameters + else: + _json = self._serialize.body(parameters, "ResourceGroup") request = build_resource_groups_create_or_update_request( resource_group_name=resource_group_name, @@ -2566,16 +3478,18 @@ async def create_or_update( api_version=api_version, content_type=content_type, json=_json, - template_url=self.create_or_update.metadata['url'], + content=_content, + template_url=self.create_or_update.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200, 201]: @@ -2583,47 +3497,50 @@ async def create_or_update( raise HttpResponseError(response=response, error_format=ARMErrorFormat) if response.status_code == 200: - deserialized = self._deserialize('ResourceGroup', pipeline_response) + deserialized = self._deserialize("ResourceGroup", pipeline_response) if response.status_code == 201: - deserialized = self._deserialize('ResourceGroup', pipeline_response) + deserialized = self._deserialize("ResourceGroup", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - create_or_update.metadata = {'url': "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}"} # type: ignore - + create_or_update.metadata = {"url": "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}"} # type: ignore async def _delete_initial( # pylint: disable=inconsistent-return-statements - self, - resource_group_name: str, - **kwargs: Any + self, resource_group_name: str, **kwargs: Any ) -> None: - cls = kwargs.pop('cls', None) # type: ClsType[None] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + 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', "2017-05-10") # type: str + api_version = kwargs.pop("api_version", _params.pop("api-version", "2017-05-10")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[None] - - request = build_resource_groups_delete_request_initial( + request = build_resource_groups_delete_request( resource_group_name=resource_group_name, subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self._delete_initial.metadata['url'], + template_url=self._delete_initial.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200, 202]: @@ -2633,22 +3550,17 @@ async def _delete_initial( # pylint: disable=inconsistent-return-statements if cls: return cls(pipeline_response, None, {}) - _delete_initial.metadata = {'url': "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}"} # type: ignore - + _delete_initial.metadata = {"url": "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}"} # type: ignore @distributed_trace_async - async def begin_delete( # pylint: disable=inconsistent-return-statements - self, - resource_group_name: str, - **kwargs: Any - ) -> AsyncLROPoller[None]: + async def begin_delete(self, resource_group_name: str, **kwargs: Any) -> AsyncLROPoller[None]: """Deletes a resource group. When you delete a resource group, all of its resources are also deleted. Deleting a resource group deletes all of its template deployments and currently stored operations. :param resource_group_name: The name of the resource group to delete. The name is case - insensitive. + insensitive. Required. :type resource_group_name: str :keyword callable cls: A custom type or function that will be passed the direct response :keyword str continuation_token: A continuation token to restart a poller from a saved state. @@ -2660,106 +3572,113 @@ async def begin_delete( # pylint: disable=inconsistent-return-statements Retry-After header is present. :return: An instance of AsyncLROPoller that returns either None or the result of cls(response) :rtype: ~azure.core.polling.AsyncLROPoller[None] - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - api_version = kwargs.pop('api_version', "2017-05-10") # type: str - polling = kwargs.pop('polling', True) # type: Union[bool, AsyncPollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType[None] - lro_delay = kwargs.pop( - 'polling_interval', - self._config.polling_interval - ) - cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2017-05-10")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[None] + polling = kwargs.pop("polling", True) # type: Union[bool, AsyncPollingMethod] + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token = kwargs.pop("continuation_token", None) # type: Optional[str] if cont_token is None: - raw_result = await self._delete_initial( + raw_result = await self._delete_initial( # type: ignore resource_group_name=resource_group_name, api_version=api_version, - cls=lambda x,y,z: x, + cls=lambda x, y, z: x, + headers=_headers, + params=_params, **kwargs ) - kwargs.pop('error_map', None) + kwargs.pop("error_map", None) - def get_long_running_output(pipeline_response): + def get_long_running_output(pipeline_response): # pylint: disable=inconsistent-return-statements if cls: return cls(pipeline_response, None, {}) - - if polling is True: polling_method = AsyncARMPolling(lro_delay, **kwargs) - elif polling is False: polling_method = AsyncNoPolling() - else: polling_method = polling + if polling is True: + polling_method = cast(AsyncPollingMethod, AsyncARMPolling(lro_delay, **kwargs)) # type: AsyncPollingMethod + elif polling is False: + polling_method = cast(AsyncPollingMethod, AsyncNoPolling()) + else: + polling_method = polling if cont_token: return AsyncLROPoller.from_continuation_token( polling_method=polling_method, continuation_token=cont_token, client=self._client, - deserialization_callback=get_long_running_output + deserialization_callback=get_long_running_output, ) return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) - begin_delete.metadata = {'url': "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}"} # type: ignore + begin_delete.metadata = {"url": "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}"} # type: ignore @distributed_trace_async - async def get( - self, - resource_group_name: str, - **kwargs: Any - ) -> "_models.ResourceGroup": + async def get(self, resource_group_name: str, **kwargs: Any) -> _models.ResourceGroup: """Gets a resource group. :param resource_group_name: The name of the resource group to get. The name is case - insensitive. + insensitive. Required. :type resource_group_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: ResourceGroup, or the result of cls(response) + :return: ResourceGroup or the result of cls(response) :rtype: ~azure.mgmt.resource.resources.v2017_05_10.models.ResourceGroup - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.ResourceGroup"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) - api_version = kwargs.pop('api_version', "2017-05-10") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2017-05-10")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[_models.ResourceGroup] - request = build_resource_groups_get_request( resource_group_name=resource_group_name, subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.get.metadata['url'], + template_url=self.get.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) - deserialized = self._deserialize('ResourceGroup', pipeline_response) + deserialized = self._deserialize("ResourceGroup", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - get.metadata = {'url': "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}"} # type: ignore + get.metadata = {"url": "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}"} # type: ignore - - @distributed_trace_async + @overload async def update( self, resource_group_name: str, - parameters: "_models.ResourceGroupPatchable", + parameters: _models.ResourceGroupPatchable, + *, + content_type: str = "application/json", **kwargs: Any - ) -> "_models.ResourceGroup": + ) -> _models.ResourceGroup: """Updates a resource group. Resource groups can be updated through a simple PATCH operation to a group address. The format @@ -2767,25 +3686,90 @@ async def update( the current value is retained. :param resource_group_name: The name of the resource group to update. The name is case - insensitive. + insensitive. Required. :type resource_group_name: str - :param parameters: Parameters supplied to update a resource group. + :param parameters: Parameters supplied to update a resource group. Required. :type parameters: ~azure.mgmt.resource.resources.v2017_05_10.models.ResourceGroupPatchable + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: ResourceGroup or the result of cls(response) + :rtype: ~azure.mgmt.resource.resources.v2017_05_10.models.ResourceGroup + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + async def update( + self, resource_group_name: str, parameters: IO, *, content_type: str = "application/json", **kwargs: Any + ) -> _models.ResourceGroup: + """Updates a resource group. + + Resource groups can be updated through a simple PATCH operation to a group address. The format + of the request is the same as that for creating a resource group. If a field is unspecified, + the current value is retained. + + :param resource_group_name: The name of the resource group to update. The name is case + insensitive. Required. + :type resource_group_name: str + :param parameters: Parameters supplied to update a resource group. Required. + :type parameters: IO + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: ResourceGroup or the result of cls(response) + :rtype: ~azure.mgmt.resource.resources.v2017_05_10.models.ResourceGroup + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace_async + async def update( + self, resource_group_name: str, parameters: Union[_models.ResourceGroupPatchable, IO], **kwargs: Any + ) -> _models.ResourceGroup: + """Updates a resource group. + + Resource groups can be updated through a simple PATCH operation to a group address. The format + of the request is the same as that for creating a resource group. If a field is unspecified, + the current value is retained. + + :param resource_group_name: The name of the resource group to update. The name is case + insensitive. Required. + :type resource_group_name: str + :param parameters: Parameters supplied to update a resource group. Is either a model type or a + IO type. Required. + :type parameters: ~azure.mgmt.resource.resources.v2017_05_10.models.ResourceGroupPatchable or + IO + :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. + Default value is None. + :paramtype content_type: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: ResourceGroup, or the result of cls(response) + :return: ResourceGroup or the result of cls(response) :rtype: ~azure.mgmt.resource.resources.v2017_05_10.models.ResourceGroup - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.ResourceGroup"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) - api_version = kwargs.pop('api_version', "2017-05-10") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - _json = self._serialize.body(parameters, 'ResourceGroupPatchable') + api_version = kwargs.pop("api_version", _params.pop("api-version", "2017-05-10")) # type: str + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.ResourceGroup] + + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(parameters, (IO, bytes)): + _content = parameters + else: + _json = self._serialize.body(parameters, "ResourceGroupPatchable") request = build_resource_groups_update_request( resource_group_name=resource_group_name, @@ -2793,60 +3777,117 @@ async def update( api_version=api_version, content_type=content_type, json=_json, - template_url=self.update.metadata['url'], + content=_content, + template_url=self.update.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) - deserialized = self._deserialize('ResourceGroup', pipeline_response) + deserialized = self._deserialize("ResourceGroup", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - update.metadata = {'url': "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}"} # type: ignore + update.metadata = {"url": "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}"} # type: ignore - - @distributed_trace_async + @overload async def export_template( self, resource_group_name: str, - parameters: "_models.ExportTemplateRequest", + parameters: _models.ExportTemplateRequest, + *, + content_type: str = "application/json", **kwargs: Any - ) -> "_models.ResourceGroupExportResult": + ) -> _models.ResourceGroupExportResult: """Captures the specified resource group as a template. - :param resource_group_name: The name of the resource group to export as a template. + :param resource_group_name: The name of the resource group to export as a template. Required. :type resource_group_name: str - :param parameters: Parameters for exporting the template. + :param parameters: Parameters for exporting the template. Required. :type parameters: ~azure.mgmt.resource.resources.v2017_05_10.models.ExportTemplateRequest + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: ResourceGroupExportResult or the result of cls(response) + :rtype: ~azure.mgmt.resource.resources.v2017_05_10.models.ResourceGroupExportResult + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + async def export_template( + self, resource_group_name: str, parameters: IO, *, content_type: str = "application/json", **kwargs: Any + ) -> _models.ResourceGroupExportResult: + """Captures the specified resource group as a template. + + :param resource_group_name: The name of the resource group to export as a template. Required. + :type resource_group_name: str + :param parameters: Parameters for exporting the template. Required. + :type parameters: IO + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: ResourceGroupExportResult or the result of cls(response) + :rtype: ~azure.mgmt.resource.resources.v2017_05_10.models.ResourceGroupExportResult + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace_async + async def export_template( + self, resource_group_name: str, parameters: Union[_models.ExportTemplateRequest, IO], **kwargs: Any + ) -> _models.ResourceGroupExportResult: + """Captures the specified resource group as a template. + + :param resource_group_name: The name of the resource group to export as a template. Required. + :type resource_group_name: str + :param parameters: Parameters for exporting the template. Is either a model type or a IO type. + Required. + :type parameters: ~azure.mgmt.resource.resources.v2017_05_10.models.ExportTemplateRequest or IO + :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. + Default value is None. + :paramtype content_type: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: ResourceGroupExportResult, or the result of cls(response) + :return: ResourceGroupExportResult or the result of cls(response) :rtype: ~azure.mgmt.resource.resources.v2017_05_10.models.ResourceGroupExportResult - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.ResourceGroupExportResult"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) - api_version = kwargs.pop('api_version', "2017-05-10") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - _json = self._serialize.body(parameters, 'ExportTemplateRequest') + api_version = kwargs.pop("api_version", _params.pop("api-version", "2017-05-10")) # type: str + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.ResourceGroupExportResult] + + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(parameters, (IO, bytes)): + _content = parameters + else: + _json = self._serialize.body(parameters, "ExportTemplateRequest") request = build_resource_groups_export_template_request( resource_group_name=resource_group_name, @@ -2854,39 +3895,37 @@ async def export_template( api_version=api_version, content_type=content_type, json=_json, - template_url=self.export_template.metadata['url'], + content=_content, + template_url=self.export_template.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) - deserialized = self._deserialize('ResourceGroupExportResult', pipeline_response) + deserialized = self._deserialize("ResourceGroupExportResult", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - export_template.metadata = {'url': "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/exportTemplate"} # type: ignore - + export_template.metadata = {"url": "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/exportTemplate"} # type: ignore @distributed_trace def list( - self, - filter: Optional[str] = None, - top: Optional[int] = None, - **kwargs: Any - ) -> AsyncIterable["_models.ResourceGroupListResult"]: + self, filter: Optional[str] = None, top: Optional[int] = None, **kwargs: Any + ) -> AsyncIterable["_models.ResourceGroup"]: """Gets all the resource groups for a subscription. :param filter: The filter to apply on the operation. Default value is None. @@ -2895,40 +3934,48 @@ def list( Default value is None. :type top: int :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either ResourceGroupListResult or the result of - cls(response) + :return: An iterator like instance of either ResourceGroup or the result of cls(response) :rtype: - ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.resource.resources.v2017_05_10.models.ResourceGroupListResult] - :raises: ~azure.core.exceptions.HttpResponseError + ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.resource.resources.v2017_05_10.models.ResourceGroup] + :raises ~azure.core.exceptions.HttpResponseError: """ - api_version = kwargs.pop('api_version', "2017-05-10") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2017-05-10")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[_models.ResourceGroupListResult] - cls = kwargs.pop('cls', None) # type: ClsType["_models.ResourceGroupListResult"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) + def prepare_request(next_link=None): if not next_link: - + request = build_resource_groups_list_request( subscription_id=self._config.subscription_id, - api_version=api_version, filter=filter, top=top, - template_url=self.list.metadata['url'], + 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.url = self._client.format_url(request.url) # type: ignore else: - - request = build_resource_groups_list_request( - subscription_id=self._config.subscription_id, - template_url=next_link, - ) + # make call to next link with the client's api-version + _parsed_next_link = urlparse(next_link) + _next_request_params = case_insensitive_dict(parse_qs(_parsed_next_link.query)) + _next_request_params["api-version"] = self._config.api_version + request = HttpRequest("GET", urljoin(next_link, _parsed_next_link.path), params=_next_request_params) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore request.method = "GET" return request @@ -2942,10 +3989,8 @@ async def extract_data(pipeline_response): async def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) response = pipeline_response.http_response @@ -2955,75 +4000,75 @@ async def get_next(next_link=None): return pipeline_response + return AsyncItemPaged(get_next, extract_data) + + list.metadata = {"url": "/subscriptions/{subscriptionId}/resourcegroups"} # type: ignore - return AsyncItemPaged( - get_next, extract_data - ) - list.metadata = {'url': "/subscriptions/{subscriptionId}/resourcegroups"} # type: ignore -class TagsOperations: - """TagsOperations async operations. - You should not instantiate this class directly. Instead, you should create a Client instance that - instantiates it for you and attaches it as an attribute. +class TagsOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. - :ivar models: Alias to model classes used in this operation group. - :type models: ~azure.mgmt.resource.resources.v2017_05_10.models - :param client: Client for service requests. - :param config: Configuration of service client. - :param serializer: An object model serializer. - :param deserializer: An object model deserializer. + Instead, you should access the following operations through + :class:`~azure.mgmt.resource.resources.v2017_05_10.aio.ResourceManagementClient`'s + :attr:`tags` attribute. """ models = _models - def __init__(self, client, config, serializer, deserializer) -> None: - self._client = client - self._serialize = serializer - self._deserialize = deserializer - self._config = config + def __init__(self, *args, **kwargs) -> None: + input_args = list(args) + self._client = input_args.pop(0) if input_args else kwargs.pop("client") + self._config = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") @distributed_trace_async async def delete_value( # pylint: disable=inconsistent-return-statements - self, - tag_name: str, - tag_value: str, - **kwargs: Any + self, tag_name: str, tag_value: str, **kwargs: Any ) -> None: """Deletes a tag value. - :param tag_name: The name of the tag. + :param tag_name: The name of the tag. Required. :type tag_name: str - :param tag_value: The value of the tag to delete. + :param tag_value: The value of the tag to delete. Required. :type tag_value: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: None, or the result of cls(response) + :return: None or the result of cls(response) :rtype: None - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType[None] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) - api_version = kwargs.pop('api_version', "2017-05-10") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2017-05-10")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[None] - request = build_tags_delete_value_request( tag_name=tag_name, tag_value=tag_value, subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.delete_value.metadata['url'], + template_url=self.delete_value.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200, 204]: @@ -3033,51 +4078,51 @@ async def delete_value( # pylint: disable=inconsistent-return-statements if cls: return cls(pipeline_response, None, {}) - delete_value.metadata = {'url': "/subscriptions/{subscriptionId}/tagNames/{tagName}/tagValues/{tagValue}"} # type: ignore - + delete_value.metadata = {"url": "/subscriptions/{subscriptionId}/tagNames/{tagName}/tagValues/{tagValue}"} # type: ignore @distributed_trace_async - async def create_or_update_value( - self, - tag_name: str, - tag_value: str, - **kwargs: Any - ) -> "_models.TagValue": + async def create_or_update_value(self, tag_name: str, tag_value: str, **kwargs: Any) -> _models.TagValue: """Creates a tag value. The name of the tag must already exist. - :param tag_name: The name of the tag. + :param tag_name: The name of the tag. Required. :type tag_name: str - :param tag_value: The value of the tag to create. + :param tag_value: The value of the tag to create. Required. :type tag_value: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: TagValue, or the result of cls(response) + :return: TagValue or the result of cls(response) :rtype: ~azure.mgmt.resource.resources.v2017_05_10.models.TagValue - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.TagValue"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + 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', "2017-05-10") # type: str + api_version = kwargs.pop("api_version", _params.pop("api-version", "2017-05-10")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[_models.TagValue] - request = build_tags_create_or_update_value_request( tag_name=tag_name, tag_value=tag_value, subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.create_or_update_value.metadata['url'], + template_url=self.create_or_update_value.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200, 201]: @@ -3085,61 +4130,62 @@ async def create_or_update_value( raise HttpResponseError(response=response, error_format=ARMErrorFormat) if response.status_code == 200: - deserialized = self._deserialize('TagValue', pipeline_response) + deserialized = self._deserialize("TagValue", pipeline_response) if response.status_code == 201: - deserialized = self._deserialize('TagValue', pipeline_response) + deserialized = self._deserialize("TagValue", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - create_or_update_value.metadata = {'url': "/subscriptions/{subscriptionId}/tagNames/{tagName}/tagValues/{tagValue}"} # type: ignore - + create_or_update_value.metadata = {"url": "/subscriptions/{subscriptionId}/tagNames/{tagName}/tagValues/{tagValue}"} # type: ignore @distributed_trace_async - async def create_or_update( - self, - tag_name: str, - **kwargs: Any - ) -> "_models.TagDetails": + async def create_or_update(self, tag_name: str, **kwargs: Any) -> _models.TagDetails: """Creates a tag in the subscription. The tag name can have a maximum of 512 characters and is case insensitive. Tag names created by Azure have prefixes of microsoft, azure, or windows. You cannot create tags with one of these prefixes. - :param tag_name: The name of the tag to create. + :param tag_name: The name of the tag to create. Required. :type tag_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: TagDetails, or the result of cls(response) + :return: TagDetails or the result of cls(response) :rtype: ~azure.mgmt.resource.resources.v2017_05_10.models.TagDetails - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.TagDetails"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + 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', "2017-05-10") # type: str + api_version = kwargs.pop("api_version", _params.pop("api-version", "2017-05-10")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[_models.TagDetails] - request = build_tags_create_or_update_request( tag_name=tag_name, subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.create_or_update.metadata['url'], + template_url=self.create_or_update.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200, 201]: @@ -3147,59 +4193,60 @@ async def create_or_update( raise HttpResponseError(response=response, error_format=ARMErrorFormat) if response.status_code == 200: - deserialized = self._deserialize('TagDetails', pipeline_response) + deserialized = self._deserialize("TagDetails", pipeline_response) if response.status_code == 201: - deserialized = self._deserialize('TagDetails', pipeline_response) + deserialized = self._deserialize("TagDetails", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - create_or_update.metadata = {'url': "/subscriptions/{subscriptionId}/tagNames/{tagName}"} # type: ignore - + create_or_update.metadata = {"url": "/subscriptions/{subscriptionId}/tagNames/{tagName}"} # type: ignore @distributed_trace_async - async def delete( # pylint: disable=inconsistent-return-statements - self, - tag_name: str, - **kwargs: Any - ) -> None: + async def delete(self, tag_name: str, **kwargs: Any) -> None: # pylint: disable=inconsistent-return-statements """Deletes a tag from the subscription. You must remove all values from a resource tag before you can delete it. - :param tag_name: The name of the tag. + :param tag_name: The name of the tag. Required. :type tag_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: None, or the result of cls(response) + :return: None or the result of cls(response) :rtype: None - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType[None] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + 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', "2017-05-10") # type: str + api_version = kwargs.pop("api_version", _params.pop("api-version", "2017-05-10")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[None] - request = build_tags_delete_request( tag_name=tag_name, subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.delete.metadata['url'], + template_url=self.delete.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200, 204]: @@ -3209,48 +4256,53 @@ async def delete( # pylint: disable=inconsistent-return-statements if cls: return cls(pipeline_response, None, {}) - delete.metadata = {'url': "/subscriptions/{subscriptionId}/tagNames/{tagName}"} # type: ignore - + delete.metadata = {"url": "/subscriptions/{subscriptionId}/tagNames/{tagName}"} # type: ignore @distributed_trace - def list( - self, - **kwargs: Any - ) -> AsyncIterable["_models.TagsListResult"]: + def list(self, **kwargs: Any) -> AsyncIterable["_models.TagDetails"]: """Gets the names and values of all resource tags that are defined in a subscription. :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either TagsListResult or the result of cls(response) + :return: An iterator like instance of either TagDetails or the result of cls(response) :rtype: - ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.resource.resources.v2017_05_10.models.TagsListResult] - :raises: ~azure.core.exceptions.HttpResponseError + ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.resource.resources.v2017_05_10.models.TagDetails] + :raises ~azure.core.exceptions.HttpResponseError: """ - api_version = kwargs.pop('api_version', "2017-05-10") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2017-05-10")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[_models.TagsListResult] - cls = kwargs.pop('cls', None) # type: ClsType["_models.TagsListResult"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) + def prepare_request(next_link=None): if not next_link: - + request = build_tags_list_request( subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.list.metadata['url'], + template_url=self.list.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore else: - - request = build_tags_list_request( - subscription_id=self._config.subscription_id, - template_url=next_link, - ) + # make call to next link with the client's api-version + _parsed_next_link = urlparse(next_link) + _next_request_params = case_insensitive_dict(parse_qs(_parsed_next_link.query)) + _next_request_params["api-version"] = self._config.api_version + request = HttpRequest("GET", urljoin(next_link, _parsed_next_link.path), params=_next_request_params) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore request.method = "GET" return request @@ -3264,10 +4316,8 @@ async def extract_data(pipeline_response): async def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) response = pipeline_response.http_response @@ -3277,149 +4327,151 @@ async def get_next(next_link=None): return pipeline_response + return AsyncItemPaged(get_next, extract_data) - return AsyncItemPaged( - get_next, extract_data - ) - list.metadata = {'url': "/subscriptions/{subscriptionId}/tagNames"} # type: ignore -class DeploymentOperationsOperations: - """DeploymentOperationsOperations async operations. + list.metadata = {"url": "/subscriptions/{subscriptionId}/tagNames"} # type: ignore - You should not instantiate this class directly. Instead, you should create a Client instance that - instantiates it for you and attaches it as an attribute. - :ivar models: Alias to model classes used in this operation group. - :type models: ~azure.mgmt.resource.resources.v2017_05_10.models - :param client: Client for service requests. - :param config: Configuration of service client. - :param serializer: An object model serializer. - :param deserializer: An object model deserializer. +class DeploymentOperationsOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. + + Instead, you should access the following operations through + :class:`~azure.mgmt.resource.resources.v2017_05_10.aio.ResourceManagementClient`'s + :attr:`deployment_operations` attribute. """ models = _models - def __init__(self, client, config, serializer, deserializer) -> None: - self._client = client - self._serialize = serializer - self._deserialize = deserializer - self._config = config + def __init__(self, *args, **kwargs) -> None: + input_args = list(args) + self._client = input_args.pop(0) if input_args else kwargs.pop("client") + self._config = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") @distributed_trace_async async def get( - self, - resource_group_name: str, - deployment_name: str, - operation_id: str, - **kwargs: Any - ) -> "_models.DeploymentOperation": + self, resource_group_name: str, deployment_name: str, operation_id: str, **kwargs: Any + ) -> _models.DeploymentOperation: """Gets a deployments operation. :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. :type resource_group_name: str - :param deployment_name: The name of the deployment. + :param deployment_name: The name of the deployment. Required. :type deployment_name: str - :param operation_id: The ID of the operation to get. + :param operation_id: The ID of the operation to get. Required. :type operation_id: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: DeploymentOperation, or the result of cls(response) + :return: DeploymentOperation or the result of cls(response) :rtype: ~azure.mgmt.resource.resources.v2017_05_10.models.DeploymentOperation - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.DeploymentOperation"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + 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', "2017-05-10") # type: str + api_version = kwargs.pop("api_version", _params.pop("api-version", "2017-05-10")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[_models.DeploymentOperation] - request = build_deployment_operations_get_request( resource_group_name=resource_group_name, deployment_name=deployment_name, operation_id=operation_id, subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.get.metadata['url'], + template_url=self.get.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) - deserialized = self._deserialize('DeploymentOperation', pipeline_response) + deserialized = self._deserialize("DeploymentOperation", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - get.metadata = {'url': "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/deployments/{deploymentName}/operations/{operationId}"} # type: ignore - + get.metadata = {"url": "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/deployments/{deploymentName}/operations/{operationId}"} # type: ignore @distributed_trace def list( - self, - resource_group_name: str, - deployment_name: str, - top: Optional[int] = None, - **kwargs: Any - ) -> AsyncIterable["_models.DeploymentOperationsListResult"]: + self, resource_group_name: str, deployment_name: str, top: Optional[int] = None, **kwargs: Any + ) -> AsyncIterable["_models.DeploymentOperation"]: """Gets all deployments operations for a deployment. :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. :type resource_group_name: str - :param deployment_name: The name of the deployment with the operation to get. + :param deployment_name: The name of the deployment with the operation to get. Required. :type deployment_name: str :param top: The number of results to return. Default value is None. :type top: int :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either DeploymentOperationsListResult or the result of - cls(response) + :return: An iterator like instance of either DeploymentOperation or the result of cls(response) :rtype: - ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.resource.resources.v2017_05_10.models.DeploymentOperationsListResult] - :raises: ~azure.core.exceptions.HttpResponseError + ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.resource.resources.v2017_05_10.models.DeploymentOperation] + :raises ~azure.core.exceptions.HttpResponseError: """ - api_version = kwargs.pop('api_version', "2017-05-10") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2017-05-10")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[_models.DeploymentOperationsListResult] - cls = kwargs.pop('cls', None) # type: ClsType["_models.DeploymentOperationsListResult"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) + def prepare_request(next_link=None): if not next_link: - + request = build_deployment_operations_list_request( resource_group_name=resource_group_name, deployment_name=deployment_name, subscription_id=self._config.subscription_id, - api_version=api_version, top=top, - template_url=self.list.metadata['url'], + 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.url = self._client.format_url(request.url) # type: ignore else: - - request = build_deployment_operations_list_request( - resource_group_name=resource_group_name, - deployment_name=deployment_name, - subscription_id=self._config.subscription_id, - template_url=next_link, - ) + # make call to next link with the client's api-version + _parsed_next_link = urlparse(next_link) + _next_request_params = case_insensitive_dict(parse_qs(_parsed_next_link.query)) + _next_request_params["api-version"] = self._config.api_version + request = HttpRequest("GET", urljoin(next_link, _parsed_next_link.path), params=_next_request_params) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore request.method = "GET" return request @@ -3433,10 +4485,8 @@ async def extract_data(pipeline_response): async def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) response = pipeline_response.http_response @@ -3446,8 +4496,6 @@ async def get_next(next_link=None): return pipeline_response + return AsyncItemPaged(get_next, extract_data) - return AsyncItemPaged( - get_next, extract_data - ) - list.metadata = {'url': "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/deployments/{deploymentName}/operations"} # type: ignore + list.metadata = {"url": "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/deployments/{deploymentName}/operations"} # type: ignore diff --git a/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/resources/v2017_05_10/aio/operations/_patch.py b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/resources/v2017_05_10/aio/operations/_patch.py new file mode 100644 index 0000000000000..f7dd32510333d --- /dev/null +++ b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/resources/v2017_05_10/aio/operations/_patch.py @@ -0,0 +1,20 @@ +# ------------------------------------ +# Copyright (c) Microsoft Corporation. +# Licensed under the MIT License. +# ------------------------------------ +"""Customize generated code here. + +Follow our quickstart for examples: https://aka.ms/azsdk/python/dpcodegen/python/customize +""" +from typing import List + +__all__: List[str] = [] # Add all objects you want publicly available to users at this package level + + +def patch_sdk(): + """Do not remove from this file. + + `patch_sdk` is a last resort escape hatch that allows you to do customizations + you can't accomplish using the techniques described in + https://aka.ms/azsdk/python/dpcodegen/python/customize + """ diff --git a/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/resources/v2017_05_10/models/__init__.py b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/resources/v2017_05_10/models/__init__.py index 207f336d74c19..159f71a2c451c 100644 --- a/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/resources/v2017_05_10/models/__init__.py +++ b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/resources/v2017_05_10/models/__init__.py @@ -57,61 +57,63 @@ from ._models_py3 import TemplateLink from ._models_py3 import ZoneMapping - -from ._resource_management_client_enums import ( - DeploymentMode, -) +from ._resource_management_client_enums import DeploymentMode +from ._patch import __all__ as _patch_all +from ._patch import * # type: ignore # pylint: disable=unused-wildcard-import +from ._patch import patch_sdk as _patch_sdk __all__ = [ - 'AliasPathType', - 'AliasType', - 'BasicDependency', - 'DebugSetting', - 'Dependency', - 'Deployment', - 'DeploymentExportResult', - 'DeploymentExtended', - 'DeploymentExtendedFilter', - 'DeploymentListResult', - 'DeploymentOperation', - 'DeploymentOperationProperties', - 'DeploymentOperationsListResult', - 'DeploymentProperties', - 'DeploymentPropertiesExtended', - 'DeploymentValidateResult', - 'ErrorAdditionalInfo', - 'ErrorResponse', - 'ExportTemplateRequest', - 'GenericResource', - 'GenericResourceExpanded', - 'GenericResourceFilter', - 'HttpMessage', - 'Identity', - 'ParametersLink', - 'Plan', - 'Provider', - 'ProviderListResult', - 'ProviderResourceType', - 'Resource', - 'ResourceGroup', - 'ResourceGroupExportResult', - 'ResourceGroupFilter', - 'ResourceGroupListResult', - 'ResourceGroupPatchable', - 'ResourceGroupProperties', - 'ResourceListResult', - 'ResourceManagementErrorWithDetails', - 'ResourceProviderOperationDisplayProperties', - 'ResourcesMoveInfo', - 'Sku', - 'SubResource', - 'TagCount', - 'TagDetails', - 'TagValue', - 'TagsListResult', - 'TargetResource', - 'TemplateHashResult', - 'TemplateLink', - 'ZoneMapping', - 'DeploymentMode', + "AliasPathType", + "AliasType", + "BasicDependency", + "DebugSetting", + "Dependency", + "Deployment", + "DeploymentExportResult", + "DeploymentExtended", + "DeploymentExtendedFilter", + "DeploymentListResult", + "DeploymentOperation", + "DeploymentOperationProperties", + "DeploymentOperationsListResult", + "DeploymentProperties", + "DeploymentPropertiesExtended", + "DeploymentValidateResult", + "ErrorAdditionalInfo", + "ErrorResponse", + "ExportTemplateRequest", + "GenericResource", + "GenericResourceExpanded", + "GenericResourceFilter", + "HttpMessage", + "Identity", + "ParametersLink", + "Plan", + "Provider", + "ProviderListResult", + "ProviderResourceType", + "Resource", + "ResourceGroup", + "ResourceGroupExportResult", + "ResourceGroupFilter", + "ResourceGroupListResult", + "ResourceGroupPatchable", + "ResourceGroupProperties", + "ResourceListResult", + "ResourceManagementErrorWithDetails", + "ResourceProviderOperationDisplayProperties", + "ResourcesMoveInfo", + "Sku", + "SubResource", + "TagCount", + "TagDetails", + "TagValue", + "TagsListResult", + "TargetResource", + "TemplateHashResult", + "TemplateLink", + "ZoneMapping", + "DeploymentMode", ] +__all__.extend([p for p in _patch_all if p not in __all__]) +_patch_sdk() diff --git a/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/resources/v2017_05_10/models/_models_py3.py b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/resources/v2017_05_10/models/_models_py3.py index d500e8c3daf5f..bd045b0b080d5 100644 --- a/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/resources/v2017_05_10/models/_models_py3.py +++ b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/resources/v2017_05_10/models/_models_py3.py @@ -1,4 +1,5 @@ # coding=utf-8 +# pylint: disable=too-many-lines # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. # Licensed under the MIT License. See License.txt in the project root for license information. @@ -6,14 +7,22 @@ # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -from typing import Any, Dict, List, Optional, Union +import sys +from typing import Any, Dict, List, Optional, TYPE_CHECKING, Union -import msrest.serialization +from ... import _serialization -from ._resource_management_client_enums import * +if TYPE_CHECKING: + # pylint: disable=unused-import,ungrouped-imports + from .. import models as _models +if sys.version_info >= (3, 9): + from collections.abc import MutableMapping +else: + from typing import MutableMapping # type: ignore # pylint: disable=ungrouped-imports +JSON = MutableMapping[str, Any] # pylint: disable=unsubscriptable-object -class AliasPathType(msrest.serialization.Model): +class AliasPathType(_serialization.Model): """The type of the paths for alias. :ivar path: The path of an alias. @@ -23,29 +32,23 @@ class AliasPathType(msrest.serialization.Model): """ _attribute_map = { - 'path': {'key': 'path', 'type': 'str'}, - 'api_versions': {'key': 'apiVersions', 'type': '[str]'}, + "path": {"key": "path", "type": "str"}, + "api_versions": {"key": "apiVersions", "type": "[str]"}, } - def __init__( - self, - *, - path: Optional[str] = None, - api_versions: Optional[List[str]] = None, - **kwargs - ): + def __init__(self, *, path: Optional[str] = None, api_versions: Optional[List[str]] = None, **kwargs): """ :keyword path: The path of an alias. :paramtype path: str :keyword api_versions: The API versions. :paramtype api_versions: list[str] """ - super(AliasPathType, self).__init__(**kwargs) + super().__init__(**kwargs) self.path = path self.api_versions = api_versions -class AliasType(msrest.serialization.Model): +class AliasType(_serialization.Model): """The alias type. :ivar name: The alias name. @@ -55,29 +58,23 @@ class AliasType(msrest.serialization.Model): """ _attribute_map = { - 'name': {'key': 'name', 'type': 'str'}, - 'paths': {'key': 'paths', 'type': '[AliasPathType]'}, + "name": {"key": "name", "type": "str"}, + "paths": {"key": "paths", "type": "[AliasPathType]"}, } - def __init__( - self, - *, - name: Optional[str] = None, - paths: Optional[List["AliasPathType"]] = None, - **kwargs - ): + def __init__(self, *, name: Optional[str] = None, paths: Optional[List["_models.AliasPathType"]] = None, **kwargs): """ :keyword name: The alias name. :paramtype name: str :keyword paths: The paths for an alias. :paramtype paths: list[~azure.mgmt.resource.resources.v2017_05_10.models.AliasPathType] """ - super(AliasType, self).__init__(**kwargs) + super().__init__(**kwargs) self.name = name self.paths = paths -class BasicDependency(msrest.serialization.Model): +class BasicDependency(_serialization.Model): """Deployment dependency information. :ivar id: The ID of the dependency. @@ -89,15 +86,15 @@ class BasicDependency(msrest.serialization.Model): """ _attribute_map = { - 'id': {'key': 'id', 'type': 'str'}, - 'resource_type': {'key': 'resourceType', 'type': 'str'}, - 'resource_name': {'key': 'resourceName', 'type': 'str'}, + "id": {"key": "id", "type": "str"}, + "resource_type": {"key": "resourceType", "type": "str"}, + "resource_name": {"key": "resourceName", "type": "str"}, } def __init__( self, *, - id: Optional[str] = None, + id: Optional[str] = None, # pylint: disable=redefined-builtin resource_type: Optional[str] = None, resource_name: Optional[str] = None, **kwargs @@ -110,13 +107,13 @@ def __init__( :keyword resource_name: The dependency resource name. :paramtype resource_name: str """ - super(BasicDependency, self).__init__(**kwargs) + super().__init__(**kwargs) self.id = id self.resource_type = resource_type self.resource_name = resource_name -class DebugSetting(msrest.serialization.Model): +class DebugSetting(_serialization.Model): """DebugSetting. :ivar detail_level: Specifies the type of information to log for debugging. The permitted @@ -129,15 +126,10 @@ class DebugSetting(msrest.serialization.Model): """ _attribute_map = { - 'detail_level': {'key': 'detailLevel', 'type': 'str'}, + "detail_level": {"key": "detailLevel", "type": "str"}, } - def __init__( - self, - *, - detail_level: Optional[str] = None, - **kwargs - ): + def __init__(self, *, detail_level: Optional[str] = None, **kwargs): """ :keyword detail_level: Specifies the type of information to log for debugging. The permitted values are none, requestContent, responseContent, or both requestContent and responseContent @@ -147,11 +139,11 @@ def __init__( deployment operations. :paramtype detail_level: str """ - super(DebugSetting, self).__init__(**kwargs) + super().__init__(**kwargs) self.detail_level = detail_level -class Dependency(msrest.serialization.Model): +class Dependency(_serialization.Model): """Deployment dependency information. :ivar depends_on: The list of dependencies. @@ -165,17 +157,17 @@ class Dependency(msrest.serialization.Model): """ _attribute_map = { - 'depends_on': {'key': 'dependsOn', 'type': '[BasicDependency]'}, - 'id': {'key': 'id', 'type': 'str'}, - 'resource_type': {'key': 'resourceType', 'type': 'str'}, - 'resource_name': {'key': 'resourceName', 'type': 'str'}, + "depends_on": {"key": "dependsOn", "type": "[BasicDependency]"}, + "id": {"key": "id", "type": "str"}, + "resource_type": {"key": "resourceType", "type": "str"}, + "resource_name": {"key": "resourceName", "type": "str"}, } def __init__( self, *, - depends_on: Optional[List["BasicDependency"]] = None, - id: Optional[str] = None, + depends_on: Optional[List["_models.BasicDependency"]] = None, + id: Optional[str] = None, # pylint: disable=redefined-builtin resource_type: Optional[str] = None, resource_name: Optional[str] = None, **kwargs @@ -190,70 +182,60 @@ def __init__( :keyword resource_name: The dependency resource name. :paramtype resource_name: str """ - super(Dependency, self).__init__(**kwargs) + super().__init__(**kwargs) self.depends_on = depends_on self.id = id self.resource_type = resource_type self.resource_name = resource_name -class Deployment(msrest.serialization.Model): +class Deployment(_serialization.Model): """Deployment operation parameters. All required parameters must be populated in order to send to Azure. - :ivar properties: Required. The deployment properties. + :ivar properties: The deployment properties. Required. :vartype properties: ~azure.mgmt.resource.resources.v2017_05_10.models.DeploymentProperties """ _validation = { - 'properties': {'required': True}, + "properties": {"required": True}, } _attribute_map = { - 'properties': {'key': 'properties', 'type': 'DeploymentProperties'}, + "properties": {"key": "properties", "type": "DeploymentProperties"}, } - def __init__( - self, - *, - properties: "DeploymentProperties", - **kwargs - ): + def __init__(self, *, properties: "_models.DeploymentProperties", **kwargs): """ - :keyword properties: Required. The deployment properties. + :keyword properties: The deployment properties. Required. :paramtype properties: ~azure.mgmt.resource.resources.v2017_05_10.models.DeploymentProperties """ - super(Deployment, self).__init__(**kwargs) + super().__init__(**kwargs) self.properties = properties -class DeploymentExportResult(msrest.serialization.Model): +class DeploymentExportResult(_serialization.Model): """The deployment export result. :ivar template: The template content. - :vartype template: any + :vartype template: JSON """ _attribute_map = { - 'template': {'key': 'template', 'type': 'object'}, + "template": {"key": "template", "type": "object"}, } - def __init__( - self, - *, - template: Optional[Any] = None, - **kwargs - ): + def __init__(self, *, template: Optional[JSON] = None, **kwargs): """ :keyword template: The template content. - :paramtype template: any + :paramtype template: JSON """ - super(DeploymentExportResult, self).__init__(**kwargs) + super().__init__(**kwargs) self.template = template -class DeploymentExtended(msrest.serialization.Model): +class DeploymentExtended(_serialization.Model): """Deployment information. Variables are only populated by the server, and will be ignored when sending a request. @@ -262,7 +244,7 @@ class DeploymentExtended(msrest.serialization.Model): :ivar id: The ID of the deployment. :vartype id: str - :ivar name: Required. The name of the deployment. + :ivar name: The name of the deployment. Required. :vartype name: str :ivar properties: Deployment properties. :vartype properties: @@ -270,37 +252,31 @@ class DeploymentExtended(msrest.serialization.Model): """ _validation = { - 'id': {'readonly': True}, - 'name': {'required': True}, + "id": {"readonly": True}, + "name": {"required": True}, } _attribute_map = { - 'id': {'key': 'id', 'type': 'str'}, - 'name': {'key': 'name', 'type': 'str'}, - 'properties': {'key': 'properties', 'type': 'DeploymentPropertiesExtended'}, + "id": {"key": "id", "type": "str"}, + "name": {"key": "name", "type": "str"}, + "properties": {"key": "properties", "type": "DeploymentPropertiesExtended"}, } - def __init__( - self, - *, - name: str, - properties: Optional["DeploymentPropertiesExtended"] = None, - **kwargs - ): + def __init__(self, *, name: str, properties: Optional["_models.DeploymentPropertiesExtended"] = None, **kwargs): """ - :keyword name: Required. The name of the deployment. + :keyword name: The name of the deployment. Required. :paramtype name: str :keyword properties: Deployment properties. :paramtype properties: ~azure.mgmt.resource.resources.v2017_05_10.models.DeploymentPropertiesExtended """ - super(DeploymentExtended, self).__init__(**kwargs) + super().__init__(**kwargs) self.id = None self.name = name self.properties = properties -class DeploymentExtendedFilter(msrest.serialization.Model): +class DeploymentExtendedFilter(_serialization.Model): """Deployment filter. :ivar provisioning_state: The provisioning state. @@ -308,24 +284,19 @@ class DeploymentExtendedFilter(msrest.serialization.Model): """ _attribute_map = { - 'provisioning_state': {'key': 'provisioningState', 'type': 'str'}, + "provisioning_state": {"key": "provisioningState", "type": "str"}, } - def __init__( - self, - *, - provisioning_state: Optional[str] = None, - **kwargs - ): + def __init__(self, *, provisioning_state: Optional[str] = None, **kwargs): """ :keyword provisioning_state: The provisioning state. :paramtype provisioning_state: str """ - super(DeploymentExtendedFilter, self).__init__(**kwargs) + super().__init__(**kwargs) self.provisioning_state = provisioning_state -class DeploymentListResult(msrest.serialization.Model): +class DeploymentListResult(_serialization.Model): """List of deployments. Variables are only populated by the server, and will be ignored when sending a request. @@ -337,30 +308,25 @@ class DeploymentListResult(msrest.serialization.Model): """ _validation = { - 'next_link': {'readonly': True}, + "next_link": {"readonly": True}, } _attribute_map = { - 'value': {'key': 'value', 'type': '[DeploymentExtended]'}, - 'next_link': {'key': 'nextLink', 'type': 'str'}, + "value": {"key": "value", "type": "[DeploymentExtended]"}, + "next_link": {"key": "nextLink", "type": "str"}, } - def __init__( - self, - *, - value: Optional[List["DeploymentExtended"]] = None, - **kwargs - ): + def __init__(self, *, value: Optional[List["_models.DeploymentExtended"]] = None, **kwargs): """ :keyword value: An array of deployments. :paramtype value: list[~azure.mgmt.resource.resources.v2017_05_10.models.DeploymentExtended] """ - super(DeploymentListResult, self).__init__(**kwargs) + super().__init__(**kwargs) self.value = value self.next_link = None -class DeploymentOperation(msrest.serialization.Model): +class DeploymentOperation(_serialization.Model): """Deployment operation information. Variables are only populated by the server, and will be ignored when sending a request. @@ -375,34 +341,29 @@ class DeploymentOperation(msrest.serialization.Model): """ _validation = { - 'id': {'readonly': True}, - 'operation_id': {'readonly': True}, + "id": {"readonly": True}, + "operation_id": {"readonly": True}, } _attribute_map = { - 'id': {'key': 'id', 'type': 'str'}, - 'operation_id': {'key': 'operationId', 'type': 'str'}, - 'properties': {'key': 'properties', 'type': 'DeploymentOperationProperties'}, + "id": {"key": "id", "type": "str"}, + "operation_id": {"key": "operationId", "type": "str"}, + "properties": {"key": "properties", "type": "DeploymentOperationProperties"}, } - def __init__( - self, - *, - properties: Optional["DeploymentOperationProperties"] = None, - **kwargs - ): + def __init__(self, *, properties: Optional["_models.DeploymentOperationProperties"] = None, **kwargs): """ :keyword properties: Deployment properties. :paramtype properties: ~azure.mgmt.resource.resources.v2017_05_10.models.DeploymentOperationProperties """ - super(DeploymentOperation, self).__init__(**kwargs) + super().__init__(**kwargs) self.id = None self.operation_id = None self.properties = properties -class DeploymentOperationProperties(msrest.serialization.Model): +class DeploymentOperationProperties(_serialization.Model): """Deployment operation properties. Variables are only populated by the server, and will be ignored when sending a request. @@ -426,34 +387,30 @@ class DeploymentOperationProperties(msrest.serialization.Model): """ _validation = { - 'provisioning_state': {'readonly': True}, - 'timestamp': {'readonly': True}, - 'service_request_id': {'readonly': True}, - 'status_code': {'readonly': True}, - 'status_message': {'readonly': True}, - 'target_resource': {'readonly': True}, - 'request': {'readonly': True}, - 'response': {'readonly': True}, + "provisioning_state": {"readonly": True}, + "timestamp": {"readonly": True}, + "service_request_id": {"readonly": True}, + "status_code": {"readonly": True}, + "status_message": {"readonly": True}, + "target_resource": {"readonly": True}, + "request": {"readonly": True}, + "response": {"readonly": True}, } _attribute_map = { - 'provisioning_state': {'key': 'provisioningState', 'type': 'str'}, - 'timestamp': {'key': 'timestamp', 'type': 'iso-8601'}, - 'service_request_id': {'key': 'serviceRequestId', 'type': 'str'}, - 'status_code': {'key': 'statusCode', 'type': 'str'}, - 'status_message': {'key': 'statusMessage', 'type': 'object'}, - 'target_resource': {'key': 'targetResource', 'type': 'TargetResource'}, - 'request': {'key': 'request', 'type': 'HttpMessage'}, - 'response': {'key': 'response', 'type': 'HttpMessage'}, - } - - def __init__( - self, - **kwargs - ): - """ - """ - super(DeploymentOperationProperties, self).__init__(**kwargs) + "provisioning_state": {"key": "provisioningState", "type": "str"}, + "timestamp": {"key": "timestamp", "type": "iso-8601"}, + "service_request_id": {"key": "serviceRequestId", "type": "str"}, + "status_code": {"key": "statusCode", "type": "str"}, + "status_message": {"key": "statusMessage", "type": "object"}, + "target_resource": {"key": "targetResource", "type": "TargetResource"}, + "request": {"key": "request", "type": "HttpMessage"}, + "response": {"key": "response", "type": "HttpMessage"}, + } + + def __init__(self, **kwargs): + """ """ + super().__init__(**kwargs) self.provisioning_state = None self.timestamp = None self.service_request_id = None @@ -464,7 +421,7 @@ def __init__( self.response = None -class DeploymentOperationsListResult(msrest.serialization.Model): +class DeploymentOperationsListResult(_serialization.Model): """List of deployment operations. Variables are only populated by the server, and will be ignored when sending a request. @@ -476,30 +433,25 @@ class DeploymentOperationsListResult(msrest.serialization.Model): """ _validation = { - 'next_link': {'readonly': True}, + "next_link": {"readonly": True}, } _attribute_map = { - 'value': {'key': 'value', 'type': '[DeploymentOperation]'}, - 'next_link': {'key': 'nextLink', 'type': 'str'}, + "value": {"key": "value", "type": "[DeploymentOperation]"}, + "next_link": {"key": "nextLink", "type": "str"}, } - def __init__( - self, - *, - value: Optional[List["DeploymentOperation"]] = None, - **kwargs - ): + def __init__(self, *, value: Optional[List["_models.DeploymentOperation"]] = None, **kwargs): """ :keyword value: An array of deployment operations. :paramtype value: list[~azure.mgmt.resource.resources.v2017_05_10.models.DeploymentOperation] """ - super(DeploymentOperationsListResult, self).__init__(**kwargs) + super().__init__(**kwargs) self.value = value self.next_link = None -class DeploymentProperties(msrest.serialization.Model): +class DeploymentProperties(_serialization.Model): """Deployment properties. All required parameters must be populated in order to send to Azure. @@ -508,7 +460,7 @@ class DeploymentProperties(msrest.serialization.Model): syntax directly in the request rather than link to an existing template. It can be a JObject or well-formed JSON string. Use either the templateLink property or the template property, but not both. - :vartype template: any + :vartype template: JSON :ivar template_link: The URI of the template. Use either the templateLink property or the template property, but not both. :vartype template_link: ~azure.mgmt.resource.resources.v2017_05_10.models.TemplateLink @@ -516,44 +468,44 @@ class DeploymentProperties(msrest.serialization.Model): You use this element when you want to provide the parameter values directly in the request rather than link to an existing parameter file. Use either the parametersLink property or the parameters property, but not both. It can be a JObject or a well formed JSON string. - :vartype parameters: any + :vartype parameters: JSON :ivar parameters_link: The URI of parameters file. You use this element to link to an existing parameters file. Use either the parametersLink property or the parameters property, but not both. :vartype parameters_link: ~azure.mgmt.resource.resources.v2017_05_10.models.ParametersLink - :ivar mode: Required. The mode that is used to deploy resources. This value can be either - Incremental or Complete. In Incremental mode, resources are deployed without deleting existing - resources that are not included in the template. In Complete mode, resources are deployed and - existing resources in the resource group that are not included in the template are deleted. Be - careful when using Complete mode as you may unintentionally delete resources. Possible values - include: "Incremental", "Complete". + :ivar mode: The mode that is used to deploy resources. This value can be either Incremental or + Complete. In Incremental mode, resources are deployed without deleting existing resources that + are not included in the template. In Complete mode, resources are deployed and existing + resources in the resource group that are not included in the template are deleted. Be careful + when using Complete mode as you may unintentionally delete resources. Required. Known values + are: "Incremental" and "Complete". :vartype mode: str or ~azure.mgmt.resource.resources.v2017_05_10.models.DeploymentMode :ivar debug_setting: The debug setting of the deployment. :vartype debug_setting: ~azure.mgmt.resource.resources.v2017_05_10.models.DebugSetting """ _validation = { - 'mode': {'required': True}, + "mode": {"required": True}, } _attribute_map = { - 'template': {'key': 'template', 'type': 'object'}, - 'template_link': {'key': 'templateLink', 'type': 'TemplateLink'}, - 'parameters': {'key': 'parameters', 'type': 'object'}, - 'parameters_link': {'key': 'parametersLink', 'type': 'ParametersLink'}, - 'mode': {'key': 'mode', 'type': 'str'}, - 'debug_setting': {'key': 'debugSetting', 'type': 'DebugSetting'}, + "template": {"key": "template", "type": "object"}, + "template_link": {"key": "templateLink", "type": "TemplateLink"}, + "parameters": {"key": "parameters", "type": "object"}, + "parameters_link": {"key": "parametersLink", "type": "ParametersLink"}, + "mode": {"key": "mode", "type": "str"}, + "debug_setting": {"key": "debugSetting", "type": "DebugSetting"}, } def __init__( self, *, - mode: Union[str, "DeploymentMode"], - template: Optional[Any] = None, - template_link: Optional["TemplateLink"] = None, - parameters: Optional[Any] = None, - parameters_link: Optional["ParametersLink"] = None, - debug_setting: Optional["DebugSetting"] = None, + mode: Union[str, "_models.DeploymentMode"], + template: Optional[JSON] = None, + template_link: Optional["_models.TemplateLink"] = None, + parameters: Optional[JSON] = None, + parameters_link: Optional["_models.ParametersLink"] = None, + debug_setting: Optional["_models.DebugSetting"] = None, **kwargs ): """ @@ -561,7 +513,7 @@ def __init__( template syntax directly in the request rather than link to an existing template. It can be a JObject or well-formed JSON string. Use either the templateLink property or the template property, but not both. - :paramtype template: any + :paramtype template: JSON :keyword template_link: The URI of the template. Use either the templateLink property or the template property, but not both. :paramtype template_link: ~azure.mgmt.resource.resources.v2017_05_10.models.TemplateLink @@ -569,22 +521,22 @@ def __init__( template. You use this element when you want to provide the parameter values directly in the request rather than link to an existing parameter file. Use either the parametersLink property or the parameters property, but not both. It can be a JObject or a well formed JSON string. - :paramtype parameters: any + :paramtype parameters: JSON :keyword parameters_link: The URI of parameters file. You use this element to link to an existing parameters file. Use either the parametersLink property or the parameters property, but not both. :paramtype parameters_link: ~azure.mgmt.resource.resources.v2017_05_10.models.ParametersLink - :keyword mode: Required. The mode that is used to deploy resources. This value can be either - Incremental or Complete. In Incremental mode, resources are deployed without deleting existing - resources that are not included in the template. In Complete mode, resources are deployed and - existing resources in the resource group that are not included in the template are deleted. Be - careful when using Complete mode as you may unintentionally delete resources. Possible values - include: "Incremental", "Complete". + :keyword mode: The mode that is used to deploy resources. This value can be either Incremental + or Complete. In Incremental mode, resources are deployed without deleting existing resources + that are not included in the template. In Complete mode, resources are deployed and existing + resources in the resource group that are not included in the template are deleted. Be careful + when using Complete mode as you may unintentionally delete resources. Required. Known values + are: "Incremental" and "Complete". :paramtype mode: str or ~azure.mgmt.resource.resources.v2017_05_10.models.DeploymentMode :keyword debug_setting: The debug setting of the deployment. :paramtype debug_setting: ~azure.mgmt.resource.resources.v2017_05_10.models.DebugSetting """ - super(DeploymentProperties, self).__init__(**kwargs) + super().__init__(**kwargs) self.template = template self.template_link = template_link self.parameters = parameters @@ -593,7 +545,7 @@ def __init__( self.debug_setting = debug_setting -class DeploymentPropertiesExtended(msrest.serialization.Model): +class DeploymentPropertiesExtended(_serialization.Model): # pylint: disable=too-many-instance-attributes """Deployment properties with additional details. Variables are only populated by the server, and will be ignored when sending a request. @@ -605,23 +557,23 @@ class DeploymentPropertiesExtended(msrest.serialization.Model): :ivar timestamp: The timestamp of the template deployment. :vartype timestamp: ~datetime.datetime :ivar outputs: Key/value pairs that represent deployment output. - :vartype outputs: any + :vartype outputs: JSON :ivar providers: The list of resource providers needed for the deployment. :vartype providers: list[~azure.mgmt.resource.resources.v2017_05_10.models.Provider] :ivar dependencies: The list of deployment dependencies. :vartype dependencies: list[~azure.mgmt.resource.resources.v2017_05_10.models.Dependency] :ivar template: The template content. Use only one of Template or TemplateLink. - :vartype template: any + :vartype template: JSON :ivar template_link: The URI referencing the template. Use only one of Template or TemplateLink. :vartype template_link: ~azure.mgmt.resource.resources.v2017_05_10.models.TemplateLink :ivar parameters: Deployment parameters. Use only one of Parameters or ParametersLink. - :vartype parameters: any + :vartype parameters: JSON :ivar parameters_link: The URI referencing the parameters. Use only one of Parameters or ParametersLink. :vartype parameters_link: ~azure.mgmt.resource.resources.v2017_05_10.models.ParametersLink - :ivar mode: The deployment mode. Possible values are Incremental and Complete. Possible values - include: "Incremental", "Complete". + :ivar mode: The deployment mode. Possible values are Incremental and Complete. Known values + are: "Incremental" and "Complete". :vartype mode: str or ~azure.mgmt.resource.resources.v2017_05_10.models.DeploymentMode :ivar debug_setting: The debug setting of the deployment. :vartype debug_setting: ~azure.mgmt.resource.resources.v2017_05_10.models.DebugSetting @@ -630,66 +582,66 @@ class DeploymentPropertiesExtended(msrest.serialization.Model): """ _validation = { - 'provisioning_state': {'readonly': True}, - 'correlation_id': {'readonly': True}, - 'timestamp': {'readonly': True}, - 'error': {'readonly': True}, + "provisioning_state": {"readonly": True}, + "correlation_id": {"readonly": True}, + "timestamp": {"readonly": True}, + "error": {"readonly": True}, } _attribute_map = { - 'provisioning_state': {'key': 'provisioningState', 'type': 'str'}, - 'correlation_id': {'key': 'correlationId', 'type': 'str'}, - 'timestamp': {'key': 'timestamp', 'type': 'iso-8601'}, - 'outputs': {'key': 'outputs', 'type': 'object'}, - 'providers': {'key': 'providers', 'type': '[Provider]'}, - 'dependencies': {'key': 'dependencies', 'type': '[Dependency]'}, - 'template': {'key': 'template', 'type': 'object'}, - 'template_link': {'key': 'templateLink', 'type': 'TemplateLink'}, - 'parameters': {'key': 'parameters', 'type': 'object'}, - 'parameters_link': {'key': 'parametersLink', 'type': 'ParametersLink'}, - 'mode': {'key': 'mode', 'type': 'str'}, - 'debug_setting': {'key': 'debugSetting', 'type': 'DebugSetting'}, - 'error': {'key': 'error', 'type': 'ErrorResponse'}, + "provisioning_state": {"key": "provisioningState", "type": "str"}, + "correlation_id": {"key": "correlationId", "type": "str"}, + "timestamp": {"key": "timestamp", "type": "iso-8601"}, + "outputs": {"key": "outputs", "type": "object"}, + "providers": {"key": "providers", "type": "[Provider]"}, + "dependencies": {"key": "dependencies", "type": "[Dependency]"}, + "template": {"key": "template", "type": "object"}, + "template_link": {"key": "templateLink", "type": "TemplateLink"}, + "parameters": {"key": "parameters", "type": "object"}, + "parameters_link": {"key": "parametersLink", "type": "ParametersLink"}, + "mode": {"key": "mode", "type": "str"}, + "debug_setting": {"key": "debugSetting", "type": "DebugSetting"}, + "error": {"key": "error", "type": "ErrorResponse"}, } def __init__( self, *, - outputs: Optional[Any] = None, - providers: Optional[List["Provider"]] = None, - dependencies: Optional[List["Dependency"]] = None, - template: Optional[Any] = None, - template_link: Optional["TemplateLink"] = None, - parameters: Optional[Any] = None, - parameters_link: Optional["ParametersLink"] = None, - mode: Optional[Union[str, "DeploymentMode"]] = None, - debug_setting: Optional["DebugSetting"] = None, + outputs: Optional[JSON] = None, + providers: Optional[List["_models.Provider"]] = None, + dependencies: Optional[List["_models.Dependency"]] = None, + template: Optional[JSON] = None, + template_link: Optional["_models.TemplateLink"] = None, + parameters: Optional[JSON] = None, + parameters_link: Optional["_models.ParametersLink"] = None, + mode: Optional[Union[str, "_models.DeploymentMode"]] = None, + debug_setting: Optional["_models.DebugSetting"] = None, **kwargs ): """ :keyword outputs: Key/value pairs that represent deployment output. - :paramtype outputs: any + :paramtype outputs: JSON :keyword providers: The list of resource providers needed for the deployment. :paramtype providers: list[~azure.mgmt.resource.resources.v2017_05_10.models.Provider] :keyword dependencies: The list of deployment dependencies. :paramtype dependencies: list[~azure.mgmt.resource.resources.v2017_05_10.models.Dependency] :keyword template: The template content. Use only one of Template or TemplateLink. - :paramtype template: any + :paramtype template: JSON :keyword template_link: The URI referencing the template. Use only one of Template or TemplateLink. :paramtype template_link: ~azure.mgmt.resource.resources.v2017_05_10.models.TemplateLink :keyword parameters: Deployment parameters. Use only one of Parameters or ParametersLink. - :paramtype parameters: any + :paramtype parameters: JSON :keyword parameters_link: The URI referencing the parameters. Use only one of Parameters or ParametersLink. :paramtype parameters_link: ~azure.mgmt.resource.resources.v2017_05_10.models.ParametersLink - :keyword mode: The deployment mode. Possible values are Incremental and Complete. Possible - values include: "Incremental", "Complete". + :keyword mode: The deployment mode. Possible values are Incremental and Complete. Known values + are: "Incremental" and "Complete". :paramtype mode: str or ~azure.mgmt.resource.resources.v2017_05_10.models.DeploymentMode :keyword debug_setting: The debug setting of the deployment. :paramtype debug_setting: ~azure.mgmt.resource.resources.v2017_05_10.models.DebugSetting """ - super(DeploymentPropertiesExtended, self).__init__(**kwargs) + super().__init__(**kwargs) self.provisioning_state = None self.correlation_id = None self.timestamp = None @@ -705,7 +657,7 @@ def __init__( self.error = None -class DeploymentValidateResult(msrest.serialization.Model): +class DeploymentValidateResult(_serialization.Model): """Information from validate template deployment response. :ivar error: Validation error. @@ -717,15 +669,15 @@ class DeploymentValidateResult(msrest.serialization.Model): """ _attribute_map = { - 'error': {'key': 'error', 'type': 'ResourceManagementErrorWithDetails'}, - 'properties': {'key': 'properties', 'type': 'DeploymentPropertiesExtended'}, + "error": {"key": "error", "type": "ResourceManagementErrorWithDetails"}, + "properties": {"key": "properties", "type": "DeploymentPropertiesExtended"}, } def __init__( self, *, - error: Optional["ResourceManagementErrorWithDetails"] = None, - properties: Optional["DeploymentPropertiesExtended"] = None, + error: Optional["_models.ResourceManagementErrorWithDetails"] = None, + properties: Optional["_models.DeploymentPropertiesExtended"] = None, **kwargs ): """ @@ -736,12 +688,12 @@ def __init__( :paramtype properties: ~azure.mgmt.resource.resources.v2017_05_10.models.DeploymentPropertiesExtended """ - super(DeploymentValidateResult, self).__init__(**kwargs) + super().__init__(**kwargs) self.error = error self.properties = properties -class ErrorAdditionalInfo(msrest.serialization.Model): +class ErrorAdditionalInfo(_serialization.Model): """The resource management error additional info. Variables are only populated by the server, and will be ignored when sending a request. @@ -749,31 +701,27 @@ class ErrorAdditionalInfo(msrest.serialization.Model): :ivar type: The additional info type. :vartype type: str :ivar info: The additional info. - :vartype info: any + :vartype info: JSON """ _validation = { - 'type': {'readonly': True}, - 'info': {'readonly': True}, + "type": {"readonly": True}, + "info": {"readonly": True}, } _attribute_map = { - 'type': {'key': 'type', 'type': 'str'}, - 'info': {'key': 'info', 'type': 'object'}, + "type": {"key": "type", "type": "str"}, + "info": {"key": "info", "type": "object"}, } - def __init__( - self, - **kwargs - ): - """ - """ - super(ErrorAdditionalInfo, self).__init__(**kwargs) + def __init__(self, **kwargs): + """ """ + super().__init__(**kwargs) self.type = None self.info = None -class ErrorResponse(msrest.serialization.Model): +class ErrorResponse(_serialization.Model): """Common error response for all Azure Resource Manager APIs to return error details for failed operations. (This also follows the OData error response format.). Variables are only populated by the server, and will be ignored when sending a request. @@ -792,28 +740,24 @@ class ErrorResponse(msrest.serialization.Model): """ _validation = { - 'code': {'readonly': True}, - 'message': {'readonly': True}, - 'target': {'readonly': True}, - 'details': {'readonly': True}, - 'additional_info': {'readonly': True}, + "code": {"readonly": True}, + "message": {"readonly": True}, + "target": {"readonly": True}, + "details": {"readonly": True}, + "additional_info": {"readonly": True}, } _attribute_map = { - 'code': {'key': 'code', 'type': 'str'}, - 'message': {'key': 'message', 'type': 'str'}, - 'target': {'key': 'target', 'type': 'str'}, - 'details': {'key': 'details', 'type': '[ErrorResponse]'}, - 'additional_info': {'key': 'additionalInfo', 'type': '[ErrorAdditionalInfo]'}, + "code": {"key": "code", "type": "str"}, + "message": {"key": "message", "type": "str"}, + "target": {"key": "target", "type": "str"}, + "details": {"key": "details", "type": "[ErrorResponse]"}, + "additional_info": {"key": "additionalInfo", "type": "[ErrorAdditionalInfo]"}, } - def __init__( - self, - **kwargs - ): - """ - """ - super(ErrorResponse, self).__init__(**kwargs) + def __init__(self, **kwargs): + """ """ + super().__init__(**kwargs) self.code = None self.message = None self.target = None @@ -821,7 +765,7 @@ def __init__( self.additional_info = None -class ExportTemplateRequest(msrest.serialization.Model): +class ExportTemplateRequest(_serialization.Model): """Export resource group template request parameters. :ivar resources: The IDs of the resources to filter the export by. To export all resources, @@ -834,17 +778,11 @@ class ExportTemplateRequest(msrest.serialization.Model): """ _attribute_map = { - 'resources': {'key': 'resources', 'type': '[str]'}, - 'options': {'key': 'options', 'type': 'str'}, + "resources": {"key": "resources", "type": "[str]"}, + "options": {"key": "options", "type": "str"}, } - def __init__( - self, - *, - resources: Optional[List[str]] = None, - options: Optional[str] = None, - **kwargs - ): + def __init__(self, *, resources: Optional[List[str]] = None, options: Optional[str] = None, **kwargs): """ :keyword resources: The IDs of the resources to filter the export by. To export all resources, supply an array with single entry '*'. @@ -854,12 +792,12 @@ def __init__( 'SkipResourceNameParameterization', 'SkipAllParameterization'. :paramtype options: str """ - super(ExportTemplateRequest, self).__init__(**kwargs) + super().__init__(**kwargs) self.resources = resources self.options = options -class Resource(msrest.serialization.Model): +class Resource(_serialization.Model): """Basic set of the resource properties. Variables are only populated by the server, and will be ignored when sending a request. @@ -872,38 +810,32 @@ class Resource(msrest.serialization.Model): :vartype type: str :ivar location: Resource location. :vartype location: str - :ivar tags: A set of tags. Resource tags. + :ivar tags: Resource tags. :vartype tags: dict[str, str] """ _validation = { - 'id': {'readonly': True}, - 'name': {'readonly': True}, - 'type': {'readonly': True}, + "id": {"readonly": True}, + "name": {"readonly": True}, + "type": {"readonly": True}, } _attribute_map = { - 'id': {'key': 'id', 'type': 'str'}, - 'name': {'key': 'name', 'type': 'str'}, - 'type': {'key': 'type', 'type': 'str'}, - 'location': {'key': 'location', 'type': 'str'}, - 'tags': {'key': 'tags', 'type': '{str}'}, + "id": {"key": "id", "type": "str"}, + "name": {"key": "name", "type": "str"}, + "type": {"key": "type", "type": "str"}, + "location": {"key": "location", "type": "str"}, + "tags": {"key": "tags", "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): """ :keyword location: Resource location. :paramtype location: str - :keyword tags: A set of tags. Resource tags. + :keyword tags: Resource tags. :paramtype tags: dict[str, str] """ - super(Resource, self).__init__(**kwargs) + super().__init__(**kwargs) self.id = None self.name = None self.type = None @@ -911,7 +843,7 @@ def __init__( self.tags = tags -class GenericResource(Resource): +class GenericResource(Resource): # pylint: disable=too-many-instance-attributes """Resource information. Variables are only populated by the server, and will be ignored when sending a request. @@ -924,12 +856,12 @@ class GenericResource(Resource): :vartype type: str :ivar location: Resource location. :vartype location: str - :ivar tags: A set of tags. Resource tags. + :ivar tags: Resource tags. :vartype tags: dict[str, str] :ivar plan: The plan of the resource. :vartype plan: ~azure.mgmt.resource.resources.v2017_05_10.models.Plan :ivar properties: The resource properties. - :vartype properties: any + :vartype properties: JSON :ivar kind: The kind of the resource. :vartype kind: str :ivar managed_by: ID of the resource that manages this resource. @@ -941,24 +873,24 @@ class GenericResource(Resource): """ _validation = { - 'id': {'readonly': True}, - 'name': {'readonly': True}, - 'type': {'readonly': True}, - 'kind': {'pattern': r'^[-\w\._,\(\)]+$'}, + "id": {"readonly": True}, + "name": {"readonly": True}, + "type": {"readonly": True}, + "kind": {"pattern": r"^[-\w\._,\(\)]+$"}, } _attribute_map = { - 'id': {'key': 'id', 'type': 'str'}, - 'name': {'key': 'name', 'type': 'str'}, - 'type': {'key': 'type', 'type': 'str'}, - 'location': {'key': 'location', 'type': 'str'}, - 'tags': {'key': 'tags', 'type': '{str}'}, - 'plan': {'key': 'plan', 'type': 'Plan'}, - 'properties': {'key': 'properties', 'type': 'object'}, - 'kind': {'key': 'kind', 'type': 'str'}, - 'managed_by': {'key': 'managedBy', 'type': 'str'}, - 'sku': {'key': 'sku', 'type': 'Sku'}, - 'identity': {'key': 'identity', 'type': 'Identity'}, + "id": {"key": "id", "type": "str"}, + "name": {"key": "name", "type": "str"}, + "type": {"key": "type", "type": "str"}, + "location": {"key": "location", "type": "str"}, + "tags": {"key": "tags", "type": "{str}"}, + "plan": {"key": "plan", "type": "Plan"}, + "properties": {"key": "properties", "type": "object"}, + "kind": {"key": "kind", "type": "str"}, + "managed_by": {"key": "managedBy", "type": "str"}, + "sku": {"key": "sku", "type": "Sku"}, + "identity": {"key": "identity", "type": "Identity"}, } def __init__( @@ -966,23 +898,23 @@ def __init__( *, location: Optional[str] = None, tags: Optional[Dict[str, str]] = None, - plan: Optional["Plan"] = None, - properties: Optional[Any] = None, + plan: Optional["_models.Plan"] = None, + properties: Optional[JSON] = None, kind: Optional[str] = None, managed_by: Optional[str] = None, - sku: Optional["Sku"] = None, - identity: Optional["Identity"] = None, + sku: Optional["_models.Sku"] = None, + identity: Optional["_models.Identity"] = None, **kwargs ): """ :keyword location: Resource location. :paramtype location: str - :keyword tags: A set of tags. Resource tags. + :keyword tags: Resource tags. :paramtype tags: dict[str, str] :keyword plan: The plan of the resource. :paramtype plan: ~azure.mgmt.resource.resources.v2017_05_10.models.Plan :keyword properties: The resource properties. - :paramtype properties: any + :paramtype properties: JSON :keyword kind: The kind of the resource. :paramtype kind: str :keyword managed_by: ID of the resource that manages this resource. @@ -992,7 +924,7 @@ def __init__( :keyword identity: The identity of the resource. :paramtype identity: ~azure.mgmt.resource.resources.v2017_05_10.models.Identity """ - super(GenericResource, self).__init__(location=location, tags=tags, **kwargs) + super().__init__(location=location, tags=tags, **kwargs) self.plan = plan self.properties = properties self.kind = kind @@ -1001,7 +933,7 @@ def __init__( self.identity = identity -class GenericResourceExpanded(GenericResource): +class GenericResourceExpanded(GenericResource): # pylint: disable=too-many-instance-attributes """Resource information. Variables are only populated by the server, and will be ignored when sending a request. @@ -1014,12 +946,12 @@ class GenericResourceExpanded(GenericResource): :vartype type: str :ivar location: Resource location. :vartype location: str - :ivar tags: A set of tags. Resource tags. + :ivar tags: Resource tags. :vartype tags: dict[str, str] :ivar plan: The plan of the resource. :vartype plan: ~azure.mgmt.resource.resources.v2017_05_10.models.Plan :ivar properties: The resource properties. - :vartype properties: any + :vartype properties: JSON :ivar kind: The kind of the resource. :vartype kind: str :ivar managed_by: ID of the resource that manages this resource. @@ -1040,30 +972,30 @@ class GenericResourceExpanded(GenericResource): """ _validation = { - 'id': {'readonly': True}, - 'name': {'readonly': True}, - 'type': {'readonly': True}, - 'kind': {'pattern': r'^[-\w\._,\(\)]+$'}, - 'created_time': {'readonly': True}, - 'changed_time': {'readonly': True}, - 'provisioning_state': {'readonly': True}, + "id": {"readonly": True}, + "name": {"readonly": True}, + "type": {"readonly": True}, + "kind": {"pattern": r"^[-\w\._,\(\)]+$"}, + "created_time": {"readonly": True}, + "changed_time": {"readonly": True}, + "provisioning_state": {"readonly": True}, } _attribute_map = { - 'id': {'key': 'id', 'type': 'str'}, - 'name': {'key': 'name', 'type': 'str'}, - 'type': {'key': 'type', 'type': 'str'}, - 'location': {'key': 'location', 'type': 'str'}, - 'tags': {'key': 'tags', 'type': '{str}'}, - 'plan': {'key': 'plan', 'type': 'Plan'}, - 'properties': {'key': 'properties', 'type': 'object'}, - 'kind': {'key': 'kind', 'type': 'str'}, - 'managed_by': {'key': 'managedBy', 'type': 'str'}, - 'sku': {'key': 'sku', 'type': 'Sku'}, - 'identity': {'key': 'identity', 'type': 'Identity'}, - 'created_time': {'key': 'createdTime', 'type': 'iso-8601'}, - 'changed_time': {'key': 'changedTime', 'type': 'iso-8601'}, - 'provisioning_state': {'key': 'provisioningState', 'type': 'str'}, + "id": {"key": "id", "type": "str"}, + "name": {"key": "name", "type": "str"}, + "type": {"key": "type", "type": "str"}, + "location": {"key": "location", "type": "str"}, + "tags": {"key": "tags", "type": "{str}"}, + "plan": {"key": "plan", "type": "Plan"}, + "properties": {"key": "properties", "type": "object"}, + "kind": {"key": "kind", "type": "str"}, + "managed_by": {"key": "managedBy", "type": "str"}, + "sku": {"key": "sku", "type": "Sku"}, + "identity": {"key": "identity", "type": "Identity"}, + "created_time": {"key": "createdTime", "type": "iso-8601"}, + "changed_time": {"key": "changedTime", "type": "iso-8601"}, + "provisioning_state": {"key": "provisioningState", "type": "str"}, } def __init__( @@ -1071,23 +1003,23 @@ def __init__( *, location: Optional[str] = None, tags: Optional[Dict[str, str]] = None, - plan: Optional["Plan"] = None, - properties: Optional[Any] = None, + plan: Optional["_models.Plan"] = None, + properties: Optional[JSON] = None, kind: Optional[str] = None, managed_by: Optional[str] = None, - sku: Optional["Sku"] = None, - identity: Optional["Identity"] = None, + sku: Optional["_models.Sku"] = None, + identity: Optional["_models.Identity"] = None, **kwargs ): """ :keyword location: Resource location. :paramtype location: str - :keyword tags: A set of tags. Resource tags. + :keyword tags: Resource tags. :paramtype tags: dict[str, str] :keyword plan: The plan of the resource. :paramtype plan: ~azure.mgmt.resource.resources.v2017_05_10.models.Plan :keyword properties: The resource properties. - :paramtype properties: any + :paramtype properties: JSON :keyword kind: The kind of the resource. :paramtype kind: str :keyword managed_by: ID of the resource that manages this resource. @@ -1097,13 +1029,23 @@ def __init__( :keyword identity: The identity of the resource. :paramtype identity: ~azure.mgmt.resource.resources.v2017_05_10.models.Identity """ - super(GenericResourceExpanded, self).__init__(location=location, tags=tags, plan=plan, properties=properties, kind=kind, managed_by=managed_by, sku=sku, identity=identity, **kwargs) + super().__init__( + location=location, + tags=tags, + plan=plan, + properties=properties, + kind=kind, + managed_by=managed_by, + sku=sku, + identity=identity, + **kwargs + ) self.created_time = None self.changed_time = None self.provisioning_state = None -class GenericResourceFilter(msrest.serialization.Model): +class GenericResourceFilter(_serialization.Model): """Resource filter. :ivar resource_type: The resource type. @@ -1115,9 +1057,9 @@ class GenericResourceFilter(msrest.serialization.Model): """ _attribute_map = { - 'resource_type': {'key': 'resourceType', 'type': 'str'}, - 'tagname': {'key': 'tagname', 'type': 'str'}, - 'tagvalue': {'key': 'tagvalue', 'type': 'str'}, + "resource_type": {"key": "resourceType", "type": "str"}, + "tagname": {"key": "tagname", "type": "str"}, + "tagvalue": {"key": "tagvalue", "type": "str"}, } def __init__( @@ -1136,38 +1078,33 @@ def __init__( :keyword tagvalue: The tag value. :paramtype tagvalue: str """ - super(GenericResourceFilter, self).__init__(**kwargs) + super().__init__(**kwargs) self.resource_type = resource_type self.tagname = tagname self.tagvalue = tagvalue -class HttpMessage(msrest.serialization.Model): +class HttpMessage(_serialization.Model): """HTTP message. :ivar content: HTTP message content. - :vartype content: any + :vartype content: JSON """ _attribute_map = { - 'content': {'key': 'content', 'type': 'object'}, + "content": {"key": "content", "type": "object"}, } - def __init__( - self, - *, - content: Optional[Any] = None, - **kwargs - ): + def __init__(self, *, content: Optional[JSON] = None, **kwargs): """ :keyword content: HTTP message content. - :paramtype content: any + :paramtype content: JSON """ - super(HttpMessage, self).__init__(**kwargs) + super().__init__(**kwargs) self.content = content -class Identity(msrest.serialization.Model): +class Identity(_serialization.Model): """Identity for the resource. Variables are only populated by the server, and will be ignored when sending a request. @@ -1176,78 +1113,65 @@ class Identity(msrest.serialization.Model): :vartype principal_id: str :ivar tenant_id: The tenant ID of resource. :vartype tenant_id: str - :ivar type: The identity type. The only acceptable values to pass in are None and - "SystemAssigned". The default value is None. + :ivar type: The identity type. Default value is "SystemAssigned". :vartype type: str """ _validation = { - 'principal_id': {'readonly': True}, - 'tenant_id': {'readonly': True}, + "principal_id": {"readonly": True}, + "tenant_id": {"readonly": True}, } _attribute_map = { - 'principal_id': {'key': 'principalId', 'type': 'str'}, - 'tenant_id': {'key': 'tenantId', 'type': 'str'}, - 'type': {'key': 'type', 'type': 'str'}, + "principal_id": {"key": "principalId", "type": "str"}, + "tenant_id": {"key": "tenantId", "type": "str"}, + "type": {"key": "type", "type": "str"}, } - def __init__( - self, - *, - type: Optional[str] = None, - **kwargs - ): + def __init__(self, *, type: Optional[str] = None, **kwargs): """ - :keyword type: The identity type. The only acceptable values to pass in are None and - "SystemAssigned". The default value is None. + :keyword type: The identity type. Default value is "SystemAssigned". :paramtype type: str """ - super(Identity, self).__init__(**kwargs) + super().__init__(**kwargs) self.principal_id = None self.tenant_id = None self.type = type -class ParametersLink(msrest.serialization.Model): +class ParametersLink(_serialization.Model): """Entity representing the reference to the deployment parameters. All required parameters must be populated in order to send to Azure. - :ivar uri: Required. The URI of the parameters file. + :ivar uri: The URI of the parameters file. Required. :vartype uri: str :ivar content_version: If included, must match the ContentVersion in the template. :vartype content_version: str """ _validation = { - 'uri': {'required': True}, + "uri": {"required": True}, } _attribute_map = { - 'uri': {'key': 'uri', 'type': 'str'}, - 'content_version': {'key': 'contentVersion', 'type': 'str'}, + "uri": {"key": "uri", "type": "str"}, + "content_version": {"key": "contentVersion", "type": "str"}, } - def __init__( - self, - *, - uri: str, - content_version: Optional[str] = None, - **kwargs - ): + def __init__(self, *, uri: str, content_version: Optional[str] = None, **kwargs): """ - :keyword uri: Required. The URI of the parameters file. + :keyword uri: The URI of the parameters file. Required. :paramtype uri: str :keyword content_version: If included, must match the ContentVersion in the template. :paramtype content_version: str """ - super(ParametersLink, self).__init__(**kwargs) + super().__init__(**kwargs) self.uri = uri self.content_version = content_version -class Plan(msrest.serialization.Model): +class Plan(_serialization.Model): """Plan for the resource. :ivar name: The plan ID. @@ -1263,11 +1187,11 @@ class Plan(msrest.serialization.Model): """ _attribute_map = { - 'name': {'key': 'name', 'type': 'str'}, - 'publisher': {'key': 'publisher', 'type': 'str'}, - 'product': {'key': 'product', 'type': 'str'}, - 'promotion_code': {'key': 'promotionCode', 'type': 'str'}, - 'version': {'key': 'version', 'type': 'str'}, + "name": {"key": "name", "type": "str"}, + "publisher": {"key": "publisher", "type": "str"}, + "product": {"key": "product", "type": "str"}, + "promotion_code": {"key": "promotionCode", "type": "str"}, + "version": {"key": "version", "type": "str"}, } def __init__( @@ -1292,7 +1216,7 @@ def __init__( :keyword version: The plan's version. :paramtype version: str """ - super(Plan, self).__init__(**kwargs) + super().__init__(**kwargs) self.name = name self.publisher = publisher self.product = product @@ -1300,7 +1224,7 @@ def __init__( self.version = version -class Provider(msrest.serialization.Model): +class Provider(_serialization.Model): """Resource provider information. Variables are only populated by the server, and will be ignored when sending a request. @@ -1317,36 +1241,31 @@ class Provider(msrest.serialization.Model): """ _validation = { - 'id': {'readonly': True}, - 'registration_state': {'readonly': True}, - 'resource_types': {'readonly': True}, + "id": {"readonly": True}, + "registration_state": {"readonly": True}, + "resource_types": {"readonly": True}, } _attribute_map = { - 'id': {'key': 'id', 'type': 'str'}, - 'namespace': {'key': 'namespace', 'type': 'str'}, - 'registration_state': {'key': 'registrationState', 'type': 'str'}, - 'resource_types': {'key': 'resourceTypes', 'type': '[ProviderResourceType]'}, + "id": {"key": "id", "type": "str"}, + "namespace": {"key": "namespace", "type": "str"}, + "registration_state": {"key": "registrationState", "type": "str"}, + "resource_types": {"key": "resourceTypes", "type": "[ProviderResourceType]"}, } - def __init__( - self, - *, - namespace: Optional[str] = None, - **kwargs - ): + def __init__(self, *, namespace: Optional[str] = None, **kwargs): """ :keyword namespace: The namespace of the resource provider. :paramtype namespace: str """ - super(Provider, self).__init__(**kwargs) + super().__init__(**kwargs) self.id = None self.namespace = namespace self.registration_state = None self.resource_types = None -class ProviderListResult(msrest.serialization.Model): +class ProviderListResult(_serialization.Model): """List of resource providers. Variables are only populated by the server, and will be ignored when sending a request. @@ -1358,30 +1277,25 @@ class ProviderListResult(msrest.serialization.Model): """ _validation = { - 'next_link': {'readonly': True}, + "next_link": {"readonly": True}, } _attribute_map = { - 'value': {'key': 'value', 'type': '[Provider]'}, - 'next_link': {'key': 'nextLink', 'type': 'str'}, + "value": {"key": "value", "type": "[Provider]"}, + "next_link": {"key": "nextLink", "type": "str"}, } - def __init__( - self, - *, - value: Optional[List["Provider"]] = None, - **kwargs - ): + def __init__(self, *, value: Optional[List["_models.Provider"]] = None, **kwargs): """ :keyword value: An array of resource providers. :paramtype value: list[~azure.mgmt.resource.resources.v2017_05_10.models.Provider] """ - super(ProviderListResult, self).__init__(**kwargs) + super().__init__(**kwargs) self.value = value self.next_link = None -class ProviderResourceType(msrest.serialization.Model): +class ProviderResourceType(_serialization.Model): """Resource type managed by the resource provider. :ivar resource_type: The resource type. @@ -1399,12 +1313,12 @@ class ProviderResourceType(msrest.serialization.Model): """ _attribute_map = { - 'resource_type': {'key': 'resourceType', 'type': 'str'}, - 'locations': {'key': 'locations', 'type': '[str]'}, - 'aliases': {'key': 'aliases', 'type': '[AliasType]'}, - 'api_versions': {'key': 'apiVersions', 'type': '[str]'}, - 'zone_mappings': {'key': 'zoneMappings', 'type': '[ZoneMapping]'}, - 'properties': {'key': 'properties', 'type': '{str}'}, + "resource_type": {"key": "resourceType", "type": "str"}, + "locations": {"key": "locations", "type": "[str]"}, + "aliases": {"key": "aliases", "type": "[AliasType]"}, + "api_versions": {"key": "apiVersions", "type": "[str]"}, + "zone_mappings": {"key": "zoneMappings", "type": "[ZoneMapping]"}, + "properties": {"key": "properties", "type": "{str}"}, } def __init__( @@ -1412,9 +1326,9 @@ def __init__( *, resource_type: Optional[str] = None, locations: Optional[List[str]] = None, - aliases: Optional[List["AliasType"]] = None, + aliases: Optional[List["_models.AliasType"]] = None, api_versions: Optional[List[str]] = None, - zone_mappings: Optional[List["ZoneMapping"]] = None, + zone_mappings: Optional[List["_models.ZoneMapping"]] = None, properties: Optional[Dict[str, str]] = None, **kwargs ): @@ -1432,7 +1346,7 @@ def __init__( :keyword properties: The properties. :paramtype properties: dict[str, str] """ - super(ProviderResourceType, self).__init__(**kwargs) + super().__init__(**kwargs) self.resource_type = resource_type self.locations = locations self.aliases = aliases @@ -1441,7 +1355,7 @@ def __init__( self.properties = properties -class ResourceGroup(msrest.serialization.Model): +class ResourceGroup(_serialization.Model): """Resource group information. Variables are only populated by the server, and will be ignored when sending a request. @@ -1454,27 +1368,27 @@ class ResourceGroup(msrest.serialization.Model): :vartype name: str :ivar properties: The resource group properties. :vartype properties: ~azure.mgmt.resource.resources.v2017_05_10.models.ResourceGroupProperties - :ivar location: Required. The location of the resource group. It cannot be changed after the - resource group has been created. It must be one of the supported Azure locations. + :ivar location: The location of the resource group. It cannot be changed after the resource + group has been created. It must be one of the supported Azure locations. Required. :vartype location: str :ivar managed_by: The ID of the resource that manages this resource group. :vartype managed_by: str - :ivar tags: A set of tags. The tags attached to the resource group. + :ivar tags: The tags attached to the resource group. :vartype tags: dict[str, str] """ _validation = { - 'id': {'readonly': True}, - 'location': {'required': True}, + "id": {"readonly": True}, + "location": {"required": True}, } _attribute_map = { - 'id': {'key': 'id', 'type': 'str'}, - 'name': {'key': 'name', 'type': 'str'}, - 'properties': {'key': 'properties', 'type': 'ResourceGroupProperties'}, - 'location': {'key': 'location', 'type': 'str'}, - 'managed_by': {'key': 'managedBy', 'type': 'str'}, - 'tags': {'key': 'tags', 'type': '{str}'}, + "id": {"key": "id", "type": "str"}, + "name": {"key": "name", "type": "str"}, + "properties": {"key": "properties", "type": "ResourceGroupProperties"}, + "location": {"key": "location", "type": "str"}, + "managed_by": {"key": "managedBy", "type": "str"}, + "tags": {"key": "tags", "type": "{str}"}, } def __init__( @@ -1482,7 +1396,7 @@ def __init__( *, location: str, name: Optional[str] = None, - properties: Optional["ResourceGroupProperties"] = None, + properties: Optional["_models.ResourceGroupProperties"] = None, managed_by: Optional[str] = None, tags: Optional[Dict[str, str]] = None, **kwargs @@ -1493,15 +1407,15 @@ def __init__( :keyword properties: The resource group properties. :paramtype properties: ~azure.mgmt.resource.resources.v2017_05_10.models.ResourceGroupProperties - :keyword location: Required. The location of the resource group. It cannot be changed after the - resource group has been created. It must be one of the supported Azure locations. + :keyword location: The location of the resource group. It cannot be changed after the resource + group has been created. It must be one of the supported Azure locations. Required. :paramtype location: str :keyword managed_by: The ID of the resource that manages this resource group. :paramtype managed_by: str - :keyword tags: A set of tags. The tags attached to the resource group. + :keyword tags: The tags attached to the resource group. :paramtype tags: dict[str, str] """ - super(ResourceGroup, self).__init__(**kwargs) + super().__init__(**kwargs) self.id = None self.name = name self.properties = properties @@ -1510,41 +1424,41 @@ def __init__( self.tags = tags -class ResourceGroupExportResult(msrest.serialization.Model): +class ResourceGroupExportResult(_serialization.Model): """Resource group export result. :ivar template: The template content. - :vartype template: any + :vartype template: JSON :ivar error: The error. :vartype error: ~azure.mgmt.resource.resources.v2017_05_10.models.ResourceManagementErrorWithDetails """ _attribute_map = { - 'template': {'key': 'template', 'type': 'object'}, - 'error': {'key': 'error', 'type': 'ResourceManagementErrorWithDetails'}, + "template": {"key": "template", "type": "object"}, + "error": {"key": "error", "type": "ResourceManagementErrorWithDetails"}, } def __init__( self, *, - template: Optional[Any] = None, - error: Optional["ResourceManagementErrorWithDetails"] = None, + template: Optional[JSON] = None, + error: Optional["_models.ResourceManagementErrorWithDetails"] = None, **kwargs ): """ :keyword template: The template content. - :paramtype template: any + :paramtype template: JSON :keyword error: The error. :paramtype error: ~azure.mgmt.resource.resources.v2017_05_10.models.ResourceManagementErrorWithDetails """ - super(ResourceGroupExportResult, self).__init__(**kwargs) + super().__init__(**kwargs) self.template = template self.error = error -class ResourceGroupFilter(msrest.serialization.Model): +class ResourceGroupFilter(_serialization.Model): """Resource group filter. :ivar tag_name: The tag name. @@ -1554,29 +1468,23 @@ class ResourceGroupFilter(msrest.serialization.Model): """ _attribute_map = { - 'tag_name': {'key': 'tagName', 'type': 'str'}, - 'tag_value': {'key': 'tagValue', 'type': 'str'}, + "tag_name": {"key": "tagName", "type": "str"}, + "tag_value": {"key": "tagValue", "type": "str"}, } - def __init__( - self, - *, - tag_name: Optional[str] = None, - tag_value: Optional[str] = None, - **kwargs - ): + def __init__(self, *, tag_name: Optional[str] = None, tag_value: Optional[str] = None, **kwargs): """ :keyword tag_name: The tag name. :paramtype tag_name: str :keyword tag_value: The tag value. :paramtype tag_value: str """ - super(ResourceGroupFilter, self).__init__(**kwargs) + super().__init__(**kwargs) self.tag_name = tag_name self.tag_value = tag_value -class ResourceGroupListResult(msrest.serialization.Model): +class ResourceGroupListResult(_serialization.Model): """List of resource groups. Variables are only populated by the server, and will be ignored when sending a request. @@ -1588,30 +1496,25 @@ class ResourceGroupListResult(msrest.serialization.Model): """ _validation = { - 'next_link': {'readonly': True}, + "next_link": {"readonly": True}, } _attribute_map = { - 'value': {'key': 'value', 'type': '[ResourceGroup]'}, - 'next_link': {'key': 'nextLink', 'type': 'str'}, + "value": {"key": "value", "type": "[ResourceGroup]"}, + "next_link": {"key": "nextLink", "type": "str"}, } - def __init__( - self, - *, - value: Optional[List["ResourceGroup"]] = None, - **kwargs - ): + def __init__(self, *, value: Optional[List["_models.ResourceGroup"]] = None, **kwargs): """ :keyword value: An array of resource groups. :paramtype value: list[~azure.mgmt.resource.resources.v2017_05_10.models.ResourceGroup] """ - super(ResourceGroupListResult, self).__init__(**kwargs) + super().__init__(**kwargs) self.value = value self.next_link = None -class ResourceGroupPatchable(msrest.serialization.Model): +class ResourceGroupPatchable(_serialization.Model): """Resource group information. :ivar name: The name of the resource group. @@ -1620,22 +1523,22 @@ class ResourceGroupPatchable(msrest.serialization.Model): :vartype properties: ~azure.mgmt.resource.resources.v2017_05_10.models.ResourceGroupProperties :ivar managed_by: The ID of the resource that manages this resource group. :vartype managed_by: str - :ivar tags: A set of tags. The tags attached to the resource group. + :ivar tags: The tags attached to the resource group. :vartype tags: dict[str, str] """ _attribute_map = { - 'name': {'key': 'name', 'type': 'str'}, - 'properties': {'key': 'properties', 'type': 'ResourceGroupProperties'}, - 'managed_by': {'key': 'managedBy', 'type': 'str'}, - 'tags': {'key': 'tags', 'type': '{str}'}, + "name": {"key": "name", "type": "str"}, + "properties": {"key": "properties", "type": "ResourceGroupProperties"}, + "managed_by": {"key": "managedBy", "type": "str"}, + "tags": {"key": "tags", "type": "{str}"}, } def __init__( self, *, name: Optional[str] = None, - properties: Optional["ResourceGroupProperties"] = None, + properties: Optional["_models.ResourceGroupProperties"] = None, managed_by: Optional[str] = None, tags: Optional[Dict[str, str]] = None, **kwargs @@ -1648,17 +1551,17 @@ def __init__( ~azure.mgmt.resource.resources.v2017_05_10.models.ResourceGroupProperties :keyword managed_by: The ID of the resource that manages this resource group. :paramtype managed_by: str - :keyword tags: A set of tags. The tags attached to the resource group. + :keyword tags: The tags attached to the resource group. :paramtype tags: dict[str, str] """ - super(ResourceGroupPatchable, self).__init__(**kwargs) + super().__init__(**kwargs) self.name = name self.properties = properties self.managed_by = managed_by self.tags = tags -class ResourceGroupProperties(msrest.serialization.Model): +class ResourceGroupProperties(_serialization.Model): """The resource group properties. Variables are only populated by the server, and will be ignored when sending a request. @@ -1668,24 +1571,20 @@ class ResourceGroupProperties(msrest.serialization.Model): """ _validation = { - 'provisioning_state': {'readonly': True}, + "provisioning_state": {"readonly": True}, } _attribute_map = { - 'provisioning_state': {'key': 'provisioningState', 'type': 'str'}, + "provisioning_state": {"key": "provisioningState", "type": "str"}, } - def __init__( - self, - **kwargs - ): - """ - """ - super(ResourceGroupProperties, self).__init__(**kwargs) + def __init__(self, **kwargs): + """ """ + super().__init__(**kwargs) self.provisioning_state = None -class ResourceListResult(msrest.serialization.Model): +class ResourceListResult(_serialization.Model): """List of resource groups. Variables are only populated by the server, and will be ignored when sending a request. @@ -1697,31 +1596,26 @@ class ResourceListResult(msrest.serialization.Model): """ _validation = { - 'next_link': {'readonly': True}, + "next_link": {"readonly": True}, } _attribute_map = { - 'value': {'key': 'value', 'type': '[GenericResourceExpanded]'}, - 'next_link': {'key': 'nextLink', 'type': 'str'}, + "value": {"key": "value", "type": "[GenericResourceExpanded]"}, + "next_link": {"key": "nextLink", "type": "str"}, } - def __init__( - self, - *, - value: Optional[List["GenericResourceExpanded"]] = None, - **kwargs - ): + def __init__(self, *, value: Optional[List["_models.GenericResourceExpanded"]] = None, **kwargs): """ :keyword value: An array of resources. :paramtype value: list[~azure.mgmt.resource.resources.v2017_05_10.models.GenericResourceExpanded] """ - super(ResourceListResult, self).__init__(**kwargs) + super().__init__(**kwargs) self.value = value self.next_link = None -class ResourceManagementErrorWithDetails(msrest.serialization.Model): +class ResourceManagementErrorWithDetails(_serialization.Model): """The detailed error message of resource management. Variables are only populated by the server, and will be ignored when sending a request. @@ -1738,33 +1632,29 @@ class ResourceManagementErrorWithDetails(msrest.serialization.Model): """ _validation = { - 'code': {'readonly': True}, - 'message': {'readonly': True}, - 'target': {'readonly': True}, - 'details': {'readonly': True}, + "code": {"readonly": True}, + "message": {"readonly": True}, + "target": {"readonly": True}, + "details": {"readonly": True}, } _attribute_map = { - 'code': {'key': 'code', 'type': 'str'}, - 'message': {'key': 'message', 'type': 'str'}, - 'target': {'key': 'target', 'type': 'str'}, - 'details': {'key': 'details', 'type': '[ResourceManagementErrorWithDetails]'}, + "code": {"key": "code", "type": "str"}, + "message": {"key": "message", "type": "str"}, + "target": {"key": "target", "type": "str"}, + "details": {"key": "details", "type": "[ResourceManagementErrorWithDetails]"}, } - def __init__( - self, - **kwargs - ): - """ - """ - super(ResourceManagementErrorWithDetails, self).__init__(**kwargs) + def __init__(self, **kwargs): + """ """ + super().__init__(**kwargs) self.code = None self.message = None self.target = None self.details = None -class ResourceProviderOperationDisplayProperties(msrest.serialization.Model): +class ResourceProviderOperationDisplayProperties(_serialization.Model): """Resource provider operation's display properties. :ivar publisher: Operation description. @@ -1780,11 +1670,11 @@ class ResourceProviderOperationDisplayProperties(msrest.serialization.Model): """ _attribute_map = { - 'publisher': {'key': 'publisher', 'type': 'str'}, - 'provider': {'key': 'provider', 'type': 'str'}, - 'resource': {'key': 'resource', 'type': 'str'}, - 'operation': {'key': 'operation', 'type': 'str'}, - 'description': {'key': 'description', 'type': 'str'}, + "publisher": {"key": "publisher", "type": "str"}, + "provider": {"key": "provider", "type": "str"}, + "resource": {"key": "resource", "type": "str"}, + "operation": {"key": "operation", "type": "str"}, + "description": {"key": "description", "type": "str"}, } def __init__( @@ -1809,7 +1699,7 @@ def __init__( :keyword description: Operation description. :paramtype description: str """ - super(ResourceProviderOperationDisplayProperties, self).__init__(**kwargs) + super().__init__(**kwargs) self.publisher = publisher self.provider = provider self.resource = resource @@ -1817,7 +1707,7 @@ def __init__( self.description = description -class ResourcesMoveInfo(msrest.serialization.Model): +class ResourcesMoveInfo(_serialization.Model): """Parameters of move resources. :ivar resources: The IDs of the resources. @@ -1827,29 +1717,23 @@ class ResourcesMoveInfo(msrest.serialization.Model): """ _attribute_map = { - 'resources': {'key': 'resources', 'type': '[str]'}, - 'target_resource_group': {'key': 'targetResourceGroup', 'type': 'str'}, + "resources": {"key": "resources", "type": "[str]"}, + "target_resource_group": {"key": "targetResourceGroup", "type": "str"}, } - def __init__( - self, - *, - resources: Optional[List[str]] = None, - target_resource_group: Optional[str] = None, - **kwargs - ): + def __init__(self, *, resources: Optional[List[str]] = None, target_resource_group: Optional[str] = None, **kwargs): """ :keyword resources: The IDs of the resources. :paramtype resources: list[str] :keyword target_resource_group: The target resource group. :paramtype target_resource_group: str """ - super(ResourcesMoveInfo, self).__init__(**kwargs) + super().__init__(**kwargs) self.resources = resources self.target_resource_group = target_resource_group -class Sku(msrest.serialization.Model): +class Sku(_serialization.Model): """SKU for the resource. :ivar name: The SKU name. @@ -1867,12 +1751,12 @@ class Sku(msrest.serialization.Model): """ _attribute_map = { - 'name': {'key': 'name', 'type': 'str'}, - 'tier': {'key': 'tier', 'type': 'str'}, - 'size': {'key': 'size', 'type': 'str'}, - 'family': {'key': 'family', 'type': 'str'}, - 'model': {'key': 'model', 'type': 'str'}, - 'capacity': {'key': 'capacity', 'type': 'int'}, + "name": {"key": "name", "type": "str"}, + "tier": {"key": "tier", "type": "str"}, + "size": {"key": "size", "type": "str"}, + "family": {"key": "family", "type": "str"}, + "model": {"key": "model", "type": "str"}, + "capacity": {"key": "capacity", "type": "int"}, } def __init__( @@ -1900,7 +1784,7 @@ def __init__( :keyword capacity: The SKU capacity. :paramtype capacity: int """ - super(Sku, self).__init__(**kwargs) + super().__init__(**kwargs) self.name = name self.tier = tier self.size = size @@ -1909,7 +1793,7 @@ def __init__( self.capacity = capacity -class SubResource(msrest.serialization.Model): +class SubResource(_serialization.Model): """Sub-resource. :ivar id: Resource ID. @@ -1917,24 +1801,19 @@ class SubResource(msrest.serialization.Model): """ _attribute_map = { - 'id': {'key': 'id', 'type': 'str'}, + "id": {"key": "id", "type": "str"}, } - def __init__( - self, - *, - id: Optional[str] = None, - **kwargs - ): + def __init__(self, *, id: Optional[str] = None, **kwargs): # pylint: disable=redefined-builtin """ :keyword id: Resource ID. :paramtype id: str """ - super(SubResource, self).__init__(**kwargs) + super().__init__(**kwargs) self.id = id -class TagCount(msrest.serialization.Model): +class TagCount(_serialization.Model): """Tag count. :ivar type: Type of count. @@ -1944,29 +1823,23 @@ class TagCount(msrest.serialization.Model): """ _attribute_map = { - 'type': {'key': 'type', 'type': 'str'}, - 'value': {'key': 'value', 'type': 'int'}, + "type": {"key": "type", "type": "str"}, + "value": {"key": "value", "type": "int"}, } - def __init__( - self, - *, - type: Optional[str] = None, - value: Optional[int] = None, - **kwargs - ): + def __init__(self, *, type: Optional[str] = None, value: Optional[int] = None, **kwargs): """ :keyword type: Type of count. :paramtype type: str :keyword value: Value of count. :paramtype value: int """ - super(TagCount, self).__init__(**kwargs) + super().__init__(**kwargs) self.type = type self.value = value -class TagDetails(msrest.serialization.Model): +class TagDetails(_serialization.Model): """Tag details. Variables are only populated by the server, and will be ignored when sending a request. @@ -1983,22 +1856,22 @@ class TagDetails(msrest.serialization.Model): """ _validation = { - 'id': {'readonly': True}, + "id": {"readonly": True}, } _attribute_map = { - 'id': {'key': 'id', 'type': 'str'}, - 'tag_name': {'key': 'tagName', 'type': 'str'}, - 'count': {'key': 'count', 'type': 'TagCount'}, - 'values': {'key': 'values', 'type': '[TagValue]'}, + "id": {"key": "id", "type": "str"}, + "tag_name": {"key": "tagName", "type": "str"}, + "count": {"key": "count", "type": "TagCount"}, + "values": {"key": "values", "type": "[TagValue]"}, } def __init__( self, *, tag_name: Optional[str] = None, - count: Optional["TagCount"] = None, - values: Optional[List["TagValue"]] = None, + count: Optional["_models.TagCount"] = None, + values: Optional[List["_models.TagValue"]] = None, **kwargs ): """ @@ -2010,14 +1883,14 @@ def __init__( :keyword values: The list of tag values. :paramtype values: list[~azure.mgmt.resource.resources.v2017_05_10.models.TagValue] """ - super(TagDetails, self).__init__(**kwargs) + super().__init__(**kwargs) self.id = None self.tag_name = tag_name self.count = count self.values = values -class TagsListResult(msrest.serialization.Model): +class TagsListResult(_serialization.Model): """List of subscription tags. Variables are only populated by the server, and will be ignored when sending a request. @@ -2029,30 +1902,25 @@ class TagsListResult(msrest.serialization.Model): """ _validation = { - 'next_link': {'readonly': True}, + "next_link": {"readonly": True}, } _attribute_map = { - 'value': {'key': 'value', 'type': '[TagDetails]'}, - 'next_link': {'key': 'nextLink', 'type': 'str'}, + "value": {"key": "value", "type": "[TagDetails]"}, + "next_link": {"key": "nextLink", "type": "str"}, } - def __init__( - self, - *, - value: Optional[List["TagDetails"]] = None, - **kwargs - ): + def __init__(self, *, value: Optional[List["_models.TagDetails"]] = None, **kwargs): """ :keyword value: An array of tags. :paramtype value: list[~azure.mgmt.resource.resources.v2017_05_10.models.TagDetails] """ - super(TagsListResult, self).__init__(**kwargs) + super().__init__(**kwargs) self.value = value self.next_link = None -class TagValue(msrest.serialization.Model): +class TagValue(_serialization.Model): """Tag information. Variables are only populated by the server, and will be ignored when sending a request. @@ -2066,35 +1934,29 @@ class TagValue(msrest.serialization.Model): """ _validation = { - 'id': {'readonly': True}, + "id": {"readonly": True}, } _attribute_map = { - 'id': {'key': 'id', 'type': 'str'}, - 'tag_value': {'key': 'tagValue', 'type': 'str'}, - 'count': {'key': 'count', 'type': 'TagCount'}, + "id": {"key": "id", "type": "str"}, + "tag_value": {"key": "tagValue", "type": "str"}, + "count": {"key": "count", "type": "TagCount"}, } - def __init__( - self, - *, - tag_value: Optional[str] = None, - count: Optional["TagCount"] = None, - **kwargs - ): + def __init__(self, *, tag_value: Optional[str] = None, count: Optional["_models.TagCount"] = None, **kwargs): """ :keyword tag_value: The tag value. :paramtype tag_value: str :keyword count: The tag value count. :paramtype count: ~azure.mgmt.resource.resources.v2017_05_10.models.TagCount """ - super(TagValue, self).__init__(**kwargs) + super().__init__(**kwargs) self.id = None self.tag_value = tag_value self.count = count -class TargetResource(msrest.serialization.Model): +class TargetResource(_serialization.Model): """Target resource. :ivar id: The ID of the resource. @@ -2106,15 +1968,15 @@ class TargetResource(msrest.serialization.Model): """ _attribute_map = { - 'id': {'key': 'id', 'type': 'str'}, - 'resource_name': {'key': 'resourceName', 'type': 'str'}, - 'resource_type': {'key': 'resourceType', 'type': 'str'}, + "id": {"key": "id", "type": "str"}, + "resource_name": {"key": "resourceName", "type": "str"}, + "resource_type": {"key": "resourceType", "type": "str"}, } def __init__( self, *, - id: Optional[str] = None, + id: Optional[str] = None, # pylint: disable=redefined-builtin resource_name: Optional[str] = None, resource_type: Optional[str] = None, **kwargs @@ -2127,13 +1989,13 @@ def __init__( :keyword resource_type: The type of the resource. :paramtype resource_type: str """ - super(TargetResource, self).__init__(**kwargs) + super().__init__(**kwargs) self.id = id self.resource_name = resource_name self.resource_type = resource_type -class TemplateHashResult(msrest.serialization.Model): +class TemplateHashResult(_serialization.Model): """Result of the request to calculate template hash. It contains a string of minified template and its hash. :ivar minified_template: The minified template string. @@ -2143,67 +2005,55 @@ class TemplateHashResult(msrest.serialization.Model): """ _attribute_map = { - 'minified_template': {'key': 'minifiedTemplate', 'type': 'str'}, - 'template_hash': {'key': 'templateHash', 'type': 'str'}, + "minified_template": {"key": "minifiedTemplate", "type": "str"}, + "template_hash": {"key": "templateHash", "type": "str"}, } - def __init__( - self, - *, - minified_template: Optional[str] = None, - template_hash: Optional[str] = None, - **kwargs - ): + def __init__(self, *, minified_template: Optional[str] = None, template_hash: Optional[str] = None, **kwargs): """ :keyword minified_template: The minified template string. :paramtype minified_template: str :keyword template_hash: The template hash. :paramtype template_hash: str """ - super(TemplateHashResult, self).__init__(**kwargs) + super().__init__(**kwargs) self.minified_template = minified_template self.template_hash = template_hash -class TemplateLink(msrest.serialization.Model): +class TemplateLink(_serialization.Model): """Entity representing the reference to the template. All required parameters must be populated in order to send to Azure. - :ivar uri: Required. The URI of the template to deploy. + :ivar uri: The URI of the template to deploy. Required. :vartype uri: str :ivar content_version: If included, must match the ContentVersion in the template. :vartype content_version: str """ _validation = { - 'uri': {'required': True}, + "uri": {"required": True}, } _attribute_map = { - 'uri': {'key': 'uri', 'type': 'str'}, - 'content_version': {'key': 'contentVersion', 'type': 'str'}, + "uri": {"key": "uri", "type": "str"}, + "content_version": {"key": "contentVersion", "type": "str"}, } - def __init__( - self, - *, - uri: str, - content_version: Optional[str] = None, - **kwargs - ): + def __init__(self, *, uri: str, content_version: Optional[str] = None, **kwargs): """ - :keyword uri: Required. The URI of the template to deploy. + :keyword uri: The URI of the template to deploy. Required. :paramtype uri: str :keyword content_version: If included, must match the ContentVersion in the template. :paramtype content_version: str """ - super(TemplateLink, self).__init__(**kwargs) + super().__init__(**kwargs) self.uri = uri self.content_version = content_version -class ZoneMapping(msrest.serialization.Model): +class ZoneMapping(_serialization.Model): """ZoneMapping. :ivar location: The location of the zone mapping. @@ -2213,23 +2063,17 @@ class ZoneMapping(msrest.serialization.Model): """ _attribute_map = { - 'location': {'key': 'location', 'type': 'str'}, - 'zones': {'key': 'zones', 'type': '[str]'}, + "location": {"key": "location", "type": "str"}, + "zones": {"key": "zones", "type": "[str]"}, } - def __init__( - self, - *, - location: Optional[str] = None, - zones: Optional[List[str]] = None, - **kwargs - ): + def __init__(self, *, location: Optional[str] = None, zones: Optional[List[str]] = None, **kwargs): """ :keyword location: The location of the zone mapping. :paramtype location: str :keyword zones: :paramtype zones: list[str] """ - super(ZoneMapping, self).__init__(**kwargs) + super().__init__(**kwargs) self.location = location self.zones = zones diff --git a/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/resources/v2017_05_10/models/_patch.py b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/resources/v2017_05_10/models/_patch.py new file mode 100644 index 0000000000000..f7dd32510333d --- /dev/null +++ b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/resources/v2017_05_10/models/_patch.py @@ -0,0 +1,20 @@ +# ------------------------------------ +# Copyright (c) Microsoft Corporation. +# Licensed under the MIT License. +# ------------------------------------ +"""Customize generated code here. + +Follow our quickstart for examples: https://aka.ms/azsdk/python/dpcodegen/python/customize +""" +from typing import List + +__all__: List[str] = [] # Add all objects you want publicly available to users at this package level + + +def patch_sdk(): + """Do not remove from this file. + + `patch_sdk` is a last resort escape hatch that allows you to do customizations + you can't accomplish using the techniques described in + https://aka.ms/azsdk/python/dpcodegen/python/customize + """ diff --git a/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/resources/v2017_05_10/models/_resource_management_client_enums.py b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/resources/v2017_05_10/models/_resource_management_client_enums.py index 760e6d04925dd..936818e6d44ac 100644 --- a/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/resources/v2017_05_10/models/_resource_management_client_enums.py +++ b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/resources/v2017_05_10/models/_resource_management_client_enums.py @@ -7,11 +7,10 @@ # -------------------------------------------------------------------------- from enum import Enum -from six import with_metaclass from azure.core import CaseInsensitiveEnumMeta -class DeploymentMode(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): +class DeploymentMode(str, Enum, metaclass=CaseInsensitiveEnumMeta): """The mode that is used to deploy resources. This value can be either Incremental or Complete. In Incremental mode, resources are deployed without deleting existing resources that are not included in the template. In Complete mode, resources are deployed and existing resources in diff --git a/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/resources/v2017_05_10/operations/__init__.py b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/resources/v2017_05_10/operations/__init__.py index 45c6c8515ee40..25795ec366414 100644 --- a/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/resources/v2017_05_10/operations/__init__.py +++ b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/resources/v2017_05_10/operations/__init__.py @@ -13,11 +13,17 @@ from ._operations import TagsOperations from ._operations import DeploymentOperationsOperations +from ._patch import __all__ as _patch_all +from ._patch import * # type: ignore # pylint: disable=unused-wildcard-import +from ._patch import patch_sdk as _patch_sdk + __all__ = [ - 'DeploymentsOperations', - 'ProvidersOperations', - 'ResourcesOperations', - 'ResourceGroupsOperations', - 'TagsOperations', - 'DeploymentOperationsOperations', + "DeploymentsOperations", + "ProvidersOperations", + "ResourcesOperations", + "ResourceGroupsOperations", + "TagsOperations", + "DeploymentOperationsOperations", ] +__all__.extend([p for p in _patch_all if p not in __all__]) +_patch_sdk() diff --git a/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/resources/v2017_05_10/operations/_operations.py b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/resources/v2017_05_10/operations/_operations.py index a2f0e24781155..cbb84b8c4ffcd 100644 --- a/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/resources/v2017_05_10/operations/_operations.py +++ b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/resources/v2017_05_10/operations/_operations.py @@ -6,277 +6,275 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -from typing import Any, Callable, Dict, Iterable, Optional, TypeVar, Union - -from msrest import Serializer - -from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error +import sys +from typing import Any, Callable, Dict, IO, Iterable, Optional, TypeVar, Union, cast, overload +from urllib.parse import parse_qs, urljoin, urlparse + +from azure.core.exceptions import ( + ClientAuthenticationError, + HttpResponseError, + ResourceExistsError, + ResourceNotFoundError, + ResourceNotModifiedError, + map_error, +) from azure.core.paging import ItemPaged from azure.core.pipeline import PipelineResponse from azure.core.pipeline.transport import HttpResponse from azure.core.polling import LROPoller, NoPolling, PollingMethod from azure.core.rest import HttpRequest from azure.core.tracing.decorator import distributed_trace +from azure.core.utils import case_insensitive_dict from azure.mgmt.core.exceptions import ARMErrorFormat from azure.mgmt.core.polling.arm_polling import ARMPolling from .. import models as _models +from ..._serialization import Serializer from .._vendor import _convert_request, _format_url_section -T = TypeVar('T') -JSONType = Any + +if sys.version_info >= (3, 9): + from collections.abc import MutableMapping +else: + from typing import MutableMapping # type: ignore # pylint: disable=ungrouped-imports +JSON = MutableMapping[str, Any] # pylint: disable=unsubscriptable-object +T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] _SERIALIZER = Serializer() _SERIALIZER.client_side_validation = False -def build_deployments_delete_request_initial( - resource_group_name: str, - deployment_name: str, - subscription_id: str, - **kwargs: Any + +def build_deployments_delete_request( + resource_group_name: str, deployment_name: str, subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2017-05-10") # type: str + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + api_version = kwargs.pop("api_version", _params.pop("api-version", "2017-05-10")) # type: str # Construct URL - _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/Microsoft.Resources/deployments/{deploymentName}") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/Microsoft.Resources/deployments/{deploymentName}", + ) # pylint: disable=line-too-long path_format_arguments = { - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._\(\)]+$'), - "deploymentName": _SERIALIZER.url("deployment_name", deployment_name, 'str', max_length=64, min_length=1, pattern=r'^[-\w\._\(\)]+$'), - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), + "resourceGroupName": _SERIALIZER.url( + "resource_group_name", resource_group_name, "str", max_length=90, min_length=1, pattern=r"^[-\w\._\(\)]+$" + ), + "deploymentName": _SERIALIZER.url( + "deployment_name", deployment_name, "str", max_length=64, min_length=1, pattern=r"^[-\w\._\(\)]+$" + ), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), } _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') - - return HttpRequest( - method="DELETE", - url=_url, - params=_query_parameters, - **kwargs - ) + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") + + return HttpRequest(method="DELETE", url=_url, params=_params, **kwargs) def build_deployments_check_existence_request( - resource_group_name: str, - deployment_name: str, - subscription_id: str, - **kwargs: Any + resource_group_name: str, deployment_name: str, subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2017-05-10") # type: str + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + api_version = kwargs.pop("api_version", _params.pop("api-version", "2017-05-10")) # type: str # Construct URL - _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/Microsoft.Resources/deployments/{deploymentName}") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/Microsoft.Resources/deployments/{deploymentName}", + ) # pylint: disable=line-too-long path_format_arguments = { - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._\(\)]+$'), - "deploymentName": _SERIALIZER.url("deployment_name", deployment_name, 'str', max_length=64, min_length=1, pattern=r'^[-\w\._\(\)]+$'), - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), + "resourceGroupName": _SERIALIZER.url( + "resource_group_name", resource_group_name, "str", max_length=90, min_length=1, pattern=r"^[-\w\._\(\)]+$" + ), + "deploymentName": _SERIALIZER.url( + "deployment_name", deployment_name, "str", max_length=64, min_length=1, pattern=r"^[-\w\._\(\)]+$" + ), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), } _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') - - return HttpRequest( - method="HEAD", - url=_url, - params=_query_parameters, - **kwargs - ) + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") + return HttpRequest(method="HEAD", url=_url, params=_params, **kwargs) -def build_deployments_create_or_update_request_initial( - resource_group_name: str, - deployment_name: str, - subscription_id: str, - *, - json: JSONType = None, - content: Any = None, - **kwargs: Any + +def build_deployments_create_or_update_request( + resource_group_name: str, deployment_name: str, subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2017-05-10") # type: str - content_type = kwargs.pop('content_type', None) # type: Optional[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", "2017-05-10")) # type: str + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + accept = _headers.pop("Accept", "application/json") - accept = "application/json" # Construct URL - _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/Microsoft.Resources/deployments/{deploymentName}") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/Microsoft.Resources/deployments/{deploymentName}", + ) # pylint: disable=line-too-long path_format_arguments = { - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._\(\)]+$'), - "deploymentName": _SERIALIZER.url("deployment_name", deployment_name, 'str', max_length=64, min_length=1, pattern=r'^[-\w\._\(\)]+$'), - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), + "resourceGroupName": _SERIALIZER.url( + "resource_group_name", resource_group_name, "str", max_length=90, min_length=1, pattern=r"^[-\w\._\(\)]+$" + ), + "deploymentName": _SERIALIZER.url( + "deployment_name", deployment_name, "str", max_length=64, min_length=1, pattern=r"^[-\w\._\(\)]+$" + ), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), } _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] if content_type is not None: - _header_parameters['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') - _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') - - return HttpRequest( - method="PUT", - url=_url, - params=_query_parameters, - headers=_header_parameters, - json=json, - content=content, - **kwargs - ) + _headers["Content-Type"] = _SERIALIZER.header("content_type", content_type, "str") + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="PUT", url=_url, params=_params, headers=_headers, **kwargs) def build_deployments_get_request( - resource_group_name: str, - deployment_name: str, - subscription_id: str, - **kwargs: Any + resource_group_name: str, deployment_name: str, subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2017-05-10") # type: 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", "2017-05-10")) # type: str + accept = _headers.pop("Accept", "application/json") - accept = "application/json" # Construct URL - _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/Microsoft.Resources/deployments/{deploymentName}") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/Microsoft.Resources/deployments/{deploymentName}", + ) # pylint: disable=line-too-long path_format_arguments = { - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._\(\)]+$'), - "deploymentName": _SERIALIZER.url("deployment_name", deployment_name, 'str', max_length=64, min_length=1, pattern=r'^[-\w\._\(\)]+$'), - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), + "resourceGroupName": _SERIALIZER.url( + "resource_group_name", resource_group_name, "str", max_length=90, min_length=1, pattern=r"^[-\w\._\(\)]+$" + ), + "deploymentName": _SERIALIZER.url( + "deployment_name", deployment_name, "str", max_length=64, min_length=1, pattern=r"^[-\w\._\(\)]+$" + ), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), } _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') - - return HttpRequest( - method="GET", - url=_url, - params=_query_parameters, - headers=_header_parameters, - **kwargs - ) + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) def build_deployments_cancel_request( - resource_group_name: str, - deployment_name: str, - subscription_id: str, - **kwargs: Any + resource_group_name: str, deployment_name: str, subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2017-05-10") # type: str + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + api_version = kwargs.pop("api_version", _params.pop("api-version", "2017-05-10")) # type: str # Construct URL - _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/Microsoft.Resources/deployments/{deploymentName}/cancel") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/Microsoft.Resources/deployments/{deploymentName}/cancel", + ) # pylint: disable=line-too-long path_format_arguments = { - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._\(\)]+$'), - "deploymentName": _SERIALIZER.url("deployment_name", deployment_name, 'str', max_length=64, min_length=1, pattern=r'^[-\w\._\(\)]+$'), - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), + "resourceGroupName": _SERIALIZER.url( + "resource_group_name", resource_group_name, "str", max_length=90, min_length=1, pattern=r"^[-\w\._\(\)]+$" + ), + "deploymentName": _SERIALIZER.url( + "deployment_name", deployment_name, "str", max_length=64, min_length=1, pattern=r"^[-\w\._\(\)]+$" + ), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), } _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') - - return HttpRequest( - method="POST", - url=_url, - params=_query_parameters, - **kwargs - ) + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") + + return HttpRequest(method="POST", url=_url, params=_params, **kwargs) def build_deployments_validate_request( - resource_group_name: str, - deployment_name: str, - subscription_id: str, - *, - json: JSONType = None, - content: Any = None, - **kwargs: Any + resource_group_name: str, deployment_name: str, subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2017-05-10") # type: str - content_type = kwargs.pop('content_type', None) # type: Optional[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", "2017-05-10")) # type: str + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + accept = _headers.pop("Accept", "application/json") - accept = "application/json" # Construct URL - _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/Microsoft.Resources/deployments/{deploymentName}/validate") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/Microsoft.Resources/deployments/{deploymentName}/validate", + ) # pylint: disable=line-too-long path_format_arguments = { - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._\(\)]+$'), - "deploymentName": _SERIALIZER.url("deployment_name", deployment_name, 'str', max_length=64, min_length=1, pattern=r'^[-\w\._\(\)]+$'), - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), + "resourceGroupName": _SERIALIZER.url( + "resource_group_name", resource_group_name, "str", max_length=90, min_length=1, pattern=r"^[-\w\._\(\)]+$" + ), + "deploymentName": _SERIALIZER.url( + "deployment_name", deployment_name, "str", max_length=64, min_length=1, pattern=r"^[-\w\._\(\)]+$" + ), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), } _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] if content_type is not None: - _header_parameters['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') - _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') - - return HttpRequest( - method="POST", - url=_url, - params=_query_parameters, - headers=_header_parameters, - json=json, - content=content, - **kwargs - ) + _headers["Content-Type"] = _SERIALIZER.header("content_type", content_type, "str") + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="POST", url=_url, params=_params, headers=_headers, **kwargs) def build_deployments_export_template_request( - resource_group_name: str, - deployment_name: str, - subscription_id: str, - **kwargs: Any + resource_group_name: str, deployment_name: str, subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2017-05-10") # type: 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", "2017-05-10")) # type: str + accept = _headers.pop("Accept", "application/json") - accept = "application/json" # Construct URL - _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/Microsoft.Resources/deployments/{deploymentName}/exportTemplate") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/Microsoft.Resources/deployments/{deploymentName}/exportTemplate", + ) # pylint: disable=line-too-long path_format_arguments = { - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._\(\)]+$'), - "deploymentName": _SERIALIZER.url("deployment_name", deployment_name, 'str', max_length=64, min_length=1, pattern=r'^[-\w\._\(\)]+$'), - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), + "resourceGroupName": _SERIALIZER.url( + "resource_group_name", resource_group_name, "str", max_length=90, min_length=1, pattern=r"^[-\w\._\(\)]+$" + ), + "deploymentName": _SERIALIZER.url( + "deployment_name", deployment_name, "str", max_length=64, min_length=1, pattern=r"^[-\w\._\(\)]+$" + ), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), } _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') - - return HttpRequest( - method="POST", - url=_url, - params=_query_parameters, - headers=_header_parameters, - **kwargs - ) + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="POST", url=_url, params=_params, headers=_headers, **kwargs) def build_deployments_list_by_resource_group_request( @@ -287,216 +285,174 @@ def build_deployments_list_by_resource_group_request( top: Optional[int] = None, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2017-05-10") # type: 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", "2017-05-10")) # type: str + accept = _headers.pop("Accept", "application/json") - accept = "application/json" # Construct URL - _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/Microsoft.Resources/deployments/") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/Microsoft.Resources/deployments/", + ) # pylint: disable=line-too-long path_format_arguments = { - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._\(\)]+$'), - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), + "resourceGroupName": _SERIALIZER.url( + "resource_group_name", resource_group_name, "str", max_length=90, min_length=1, pattern=r"^[-\w\._\(\)]+$" + ), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), } _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] if filter is not None: - _query_parameters['$filter'] = _SERIALIZER.query("filter", filter, 'str') + _params["$filter"] = _SERIALIZER.query("filter", filter, "str") if top is not None: - _query_parameters['$top'] = _SERIALIZER.query("top", top, 'int') - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["$top"] = _SERIALIZER.query("top", top, "int") + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') - - return HttpRequest( - method="GET", - url=_url, - params=_query_parameters, - headers=_header_parameters, - **kwargs - ) + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) -def build_deployments_calculate_template_hash_request( - *, - json: JSONType = None, - content: Any = None, - **kwargs: Any -) -> HttpRequest: - api_version = kwargs.pop('api_version', "2017-05-10") # type: str - content_type = kwargs.pop('content_type', None) # type: Optional[str] - accept = "application/json" +def build_deployments_calculate_template_hash_request(*, json: JSON, **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", "2017-05-10")) # type: str + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + accept = _headers.pop("Accept", "application/json") + # Construct URL _url = kwargs.pop("template_url", "/providers/Microsoft.Resources/calculateTemplateHash") # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] if content_type is not None: - _header_parameters['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') - _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') - - return HttpRequest( - method="POST", - url=_url, - params=_query_parameters, - headers=_header_parameters, - json=json, - content=content, - **kwargs - ) + _headers["Content-Type"] = _SERIALIZER.header("content_type", content_type, "str") + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="POST", url=_url, params=_params, headers=_headers, json=json, **kwargs) def build_providers_unregister_request( - resource_provider_namespace: str, - subscription_id: str, - **kwargs: Any + resource_provider_namespace: str, subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2017-05-10") # type: 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", "2017-05-10")) # type: str + accept = _headers.pop("Accept", "application/json") - accept = "application/json" # Construct URL - _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/providers/{resourceProviderNamespace}/unregister") + _url = kwargs.pop( + "template_url", "/subscriptions/{subscriptionId}/providers/{resourceProviderNamespace}/unregister" + ) path_format_arguments = { - "resourceProviderNamespace": _SERIALIZER.url("resource_provider_namespace", resource_provider_namespace, 'str'), - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), + "resourceProviderNamespace": _SERIALIZER.url("resource_provider_namespace", resource_provider_namespace, "str"), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), } _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') - - return HttpRequest( - method="POST", - url=_url, - params=_query_parameters, - headers=_header_parameters, - **kwargs - ) + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="POST", url=_url, params=_params, headers=_headers, **kwargs) def build_providers_register_request( - resource_provider_namespace: str, - subscription_id: str, - **kwargs: Any + resource_provider_namespace: str, subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2017-05-10") # type: 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", "2017-05-10")) # type: str + accept = _headers.pop("Accept", "application/json") - accept = "application/json" # Construct URL _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/providers/{resourceProviderNamespace}/register") path_format_arguments = { - "resourceProviderNamespace": _SERIALIZER.url("resource_provider_namespace", resource_provider_namespace, 'str'), - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), + "resourceProviderNamespace": _SERIALIZER.url("resource_provider_namespace", resource_provider_namespace, "str"), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), } _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') - - return HttpRequest( - method="POST", - url=_url, - params=_query_parameters, - headers=_header_parameters, - **kwargs - ) + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="POST", url=_url, params=_params, headers=_headers, **kwargs) def build_providers_list_request( - subscription_id: str, - *, - top: Optional[int] = None, - expand: Optional[str] = None, - **kwargs: Any + subscription_id: str, *, top: Optional[int] = None, expand: Optional[str] = None, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2017-05-10") # type: 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", "2017-05-10")) # type: str + accept = _headers.pop("Accept", "application/json") - accept = "application/json" # Construct URL _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/providers") path_format_arguments = { - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), } _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] if top is not None: - _query_parameters['$top'] = _SERIALIZER.query("top", top, 'int') + _params["$top"] = _SERIALIZER.query("top", top, "int") if expand is not None: - _query_parameters['$expand'] = _SERIALIZER.query("expand", expand, 'str') - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["$expand"] = _SERIALIZER.query("expand", expand, "str") + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') - - return HttpRequest( - method="GET", - url=_url, - params=_query_parameters, - headers=_header_parameters, - **kwargs - ) + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) def build_providers_get_request( - resource_provider_namespace: str, - subscription_id: str, - *, - expand: Optional[str] = None, - **kwargs: Any + resource_provider_namespace: str, subscription_id: str, *, expand: Optional[str] = None, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2017-05-10") # type: 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", "2017-05-10")) # type: str + accept = _headers.pop("Accept", "application/json") - accept = "application/json" # Construct URL _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/providers/{resourceProviderNamespace}") path_format_arguments = { - "resourceProviderNamespace": _SERIALIZER.url("resource_provider_namespace", resource_provider_namespace, 'str'), - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), + "resourceProviderNamespace": _SERIALIZER.url("resource_provider_namespace", resource_provider_namespace, "str"), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), } _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] if expand is not None: - _query_parameters['$expand'] = _SERIALIZER.query("expand", expand, 'str') - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["$expand"] = _SERIALIZER.query("expand", expand, "str") + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') - - return HttpRequest( - method="GET", - url=_url, - params=_query_parameters, - headers=_header_parameters, - **kwargs - ) + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) def build_resources_list_by_resource_group_request( @@ -508,119 +464,108 @@ def build_resources_list_by_resource_group_request( top: Optional[int] = None, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2017-05-10") # type: 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", "2017-05-10")) # type: str + accept = _headers.pop("Accept", "application/json") - accept = "application/json" # Construct URL _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/resources") path_format_arguments = { - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._\(\)]+$'), - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), + "resourceGroupName": _SERIALIZER.url( + "resource_group_name", resource_group_name, "str", max_length=90, min_length=1, pattern=r"^[-\w\._\(\)]+$" + ), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), } _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] if filter is not None: - _query_parameters['$filter'] = _SERIALIZER.query("filter", filter, 'str') + _params["$filter"] = _SERIALIZER.query("filter", filter, "str") if expand is not None: - _query_parameters['$expand'] = _SERIALIZER.query("expand", expand, 'str') + _params["$expand"] = _SERIALIZER.query("expand", expand, "str") if top is not None: - _query_parameters['$top'] = _SERIALIZER.query("top", top, 'int') - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["$top"] = _SERIALIZER.query("top", top, "int") + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') - - return HttpRequest( - method="GET", - url=_url, - params=_query_parameters, - headers=_header_parameters, - **kwargs - ) + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) -def build_resources_move_resources_request_initial( - source_resource_group_name: str, - subscription_id: str, - *, - json: JSONType = None, - content: Any = None, - **kwargs: Any + +def build_resources_move_resources_request( + source_resource_group_name: str, subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2017-05-10") # type: str - content_type = kwargs.pop('content_type', None) # type: Optional[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", "2017-05-10")) # type: str + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] # Construct URL - _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{sourceResourceGroupName}/moveResources") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", "/subscriptions/{subscriptionId}/resourceGroups/{sourceResourceGroupName}/moveResources" + ) # pylint: disable=line-too-long path_format_arguments = { - "sourceResourceGroupName": _SERIALIZER.url("source_resource_group_name", source_resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._\(\)]+$'), - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), + "sourceResourceGroupName": _SERIALIZER.url( + "source_resource_group_name", + source_resource_group_name, + "str", + max_length=90, + min_length=1, + pattern=r"^[-\w\._\(\)]+$", + ), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), } _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] if content_type is not None: - _header_parameters['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') - - return HttpRequest( - method="POST", - url=_url, - params=_query_parameters, - headers=_header_parameters, - json=json, - content=content, - **kwargs - ) + _headers["Content-Type"] = _SERIALIZER.header("content_type", content_type, "str") + return HttpRequest(method="POST", url=_url, params=_params, headers=_headers, **kwargs) -def build_resources_validate_move_resources_request_initial( - source_resource_group_name: str, - subscription_id: str, - *, - json: JSONType = None, - content: Any = None, - **kwargs: Any + +def build_resources_validate_move_resources_request( + source_resource_group_name: str, subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2017-05-10") # type: str - content_type = kwargs.pop('content_type', None) # type: Optional[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", "2017-05-10")) # type: str + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] # Construct URL - _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{sourceResourceGroupName}/validateMoveResources") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", "/subscriptions/{subscriptionId}/resourceGroups/{sourceResourceGroupName}/validateMoveResources" + ) # pylint: disable=line-too-long path_format_arguments = { - "sourceResourceGroupName": _SERIALIZER.url("source_resource_group_name", source_resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._\(\)]+$'), - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), + "sourceResourceGroupName": _SERIALIZER.url( + "source_resource_group_name", + source_resource_group_name, + "str", + max_length=90, + min_length=1, + pattern=r"^[-\w\._\(\)]+$", + ), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), } _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] if content_type is not None: - _header_parameters['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') - - return HttpRequest( - method="POST", - url=_url, - params=_query_parameters, - headers=_header_parameters, - json=json, - content=content, - **kwargs - ) + _headers["Content-Type"] = _SERIALIZER.header("content_type", content_type, "str") + + return HttpRequest(method="POST", url=_url, params=_params, headers=_headers, **kwargs) def build_resources_list_request( @@ -631,38 +576,33 @@ def build_resources_list_request( top: Optional[int] = None, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2017-05-10") # type: 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", "2017-05-10")) # type: str + accept = _headers.pop("Accept", "application/json") - accept = "application/json" # Construct URL _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resources") path_format_arguments = { - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), } _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] if filter is not None: - _query_parameters['$filter'] = _SERIALIZER.query("filter", filter, 'str') + _params["$filter"] = _SERIALIZER.query("filter", filter, "str") if expand is not None: - _query_parameters['$expand'] = _SERIALIZER.query("expand", expand, 'str') + _params["$expand"] = _SERIALIZER.query("expand", expand, "str") if top is not None: - _query_parameters['$top'] = _SERIALIZER.query("top", top, 'int') - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["$top"] = _SERIALIZER.query("top", top, "int") + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') - - return HttpRequest( - method="GET", - url=_url, - params=_query_parameters, - headers=_header_parameters, - **kwargs - ) + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) def build_resources_check_existence_request( @@ -676,32 +616,33 @@ def build_resources_check_existence_request( api_version: str, **kwargs: Any ) -> HttpRequest: + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + # Construct URL - _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{parentResourcePath}/{resourceType}/{resourceName}") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{parentResourcePath}/{resourceType}/{resourceName}", + ) # pylint: disable=line-too-long path_format_arguments = { - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._\(\)]+$'), - "resourceProviderNamespace": _SERIALIZER.url("resource_provider_namespace", resource_provider_namespace, 'str'), - "parentResourcePath": _SERIALIZER.url("parent_resource_path", parent_resource_path, 'str', skip_quote=True), - "resourceType": _SERIALIZER.url("resource_type", resource_type, 'str', skip_quote=True), - "resourceName": _SERIALIZER.url("resource_name", resource_name, 'str'), - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), + "resourceGroupName": _SERIALIZER.url( + "resource_group_name", resource_group_name, "str", max_length=90, min_length=1, pattern=r"^[-\w\._\(\)]+$" + ), + "resourceProviderNamespace": _SERIALIZER.url("resource_provider_namespace", resource_provider_namespace, "str"), + "parentResourcePath": _SERIALIZER.url("parent_resource_path", parent_resource_path, "str", skip_quote=True), + "resourceType": _SERIALIZER.url("resource_type", resource_type, "str", skip_quote=True), + "resourceName": _SERIALIZER.url("resource_name", resource_name, "str"), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), } _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') - - return HttpRequest( - method="HEAD", - url=_url, - params=_query_parameters, - **kwargs - ) + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") + + return HttpRequest(method="HEAD", url=_url, params=_params, **kwargs) -def build_resources_delete_request_initial( +def build_resources_delete_request( resource_group_name: str, resource_provider_namespace: str, parent_resource_path: str, @@ -712,32 +653,33 @@ def build_resources_delete_request_initial( api_version: str, **kwargs: Any ) -> HttpRequest: + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + # Construct URL - _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{parentResourcePath}/{resourceType}/{resourceName}") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{parentResourcePath}/{resourceType}/{resourceName}", + ) # pylint: disable=line-too-long path_format_arguments = { - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._\(\)]+$'), - "resourceProviderNamespace": _SERIALIZER.url("resource_provider_namespace", resource_provider_namespace, 'str'), - "parentResourcePath": _SERIALIZER.url("parent_resource_path", parent_resource_path, 'str', skip_quote=True), - "resourceType": _SERIALIZER.url("resource_type", resource_type, 'str', skip_quote=True), - "resourceName": _SERIALIZER.url("resource_name", resource_name, 'str'), - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), + "resourceGroupName": _SERIALIZER.url( + "resource_group_name", resource_group_name, "str", max_length=90, min_length=1, pattern=r"^[-\w\._\(\)]+$" + ), + "resourceProviderNamespace": _SERIALIZER.url("resource_provider_namespace", resource_provider_namespace, "str"), + "parentResourcePath": _SERIALIZER.url("parent_resource_path", parent_resource_path, "str", skip_quote=True), + "resourceType": _SERIALIZER.url("resource_type", resource_type, "str", skip_quote=True), + "resourceName": _SERIALIZER.url("resource_name", resource_name, "str"), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), } _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') - - return HttpRequest( - method="DELETE", - url=_url, - params=_query_parameters, - **kwargs - ) + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") + return HttpRequest(method="DELETE", url=_url, params=_params, **kwargs) -def build_resources_create_or_update_request_initial( + +def build_resources_create_or_update_request( resource_group_name: str, resource_provider_namespace: str, parent_resource_path: str, @@ -746,48 +688,44 @@ def build_resources_create_or_update_request_initial( subscription_id: str, *, api_version: str, - json: JSONType = None, - content: Any = None, **kwargs: Any ) -> HttpRequest: - content_type = kwargs.pop('content_type', None) # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + accept = _headers.pop("Accept", "application/json") - accept = "application/json" # Construct URL - _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{parentResourcePath}/{resourceType}/{resourceName}") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{parentResourcePath}/{resourceType}/{resourceName}", + ) # pylint: disable=line-too-long path_format_arguments = { - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._\(\)]+$'), - "resourceProviderNamespace": _SERIALIZER.url("resource_provider_namespace", resource_provider_namespace, 'str'), - "parentResourcePath": _SERIALIZER.url("parent_resource_path", parent_resource_path, 'str', skip_quote=True), - "resourceType": _SERIALIZER.url("resource_type", resource_type, 'str', skip_quote=True), - "resourceName": _SERIALIZER.url("resource_name", resource_name, 'str'), - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), + "resourceGroupName": _SERIALIZER.url( + "resource_group_name", resource_group_name, "str", max_length=90, min_length=1, pattern=r"^[-\w\._\(\)]+$" + ), + "resourceProviderNamespace": _SERIALIZER.url("resource_provider_namespace", resource_provider_namespace, "str"), + "parentResourcePath": _SERIALIZER.url("parent_resource_path", parent_resource_path, "str", skip_quote=True), + "resourceType": _SERIALIZER.url("resource_type", resource_type, "str", skip_quote=True), + "resourceName": _SERIALIZER.url("resource_name", resource_name, "str"), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), } _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] if content_type is not None: - _header_parameters['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') - _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') - - return HttpRequest( - method="PUT", - url=_url, - params=_query_parameters, - headers=_header_parameters, - json=json, - content=content, - **kwargs - ) + _headers["Content-Type"] = _SERIALIZER.header("content_type", content_type, "str") + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="PUT", url=_url, params=_params, headers=_headers, **kwargs) -def build_resources_update_request_initial( +def build_resources_update_request( resource_group_name: str, resource_provider_namespace: str, parent_resource_path: str, @@ -796,45 +734,41 @@ def build_resources_update_request_initial( subscription_id: str, *, api_version: str, - json: JSONType = None, - content: Any = None, **kwargs: Any ) -> HttpRequest: - content_type = kwargs.pop('content_type', None) # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + accept = _headers.pop("Accept", "application/json") - accept = "application/json" # Construct URL - _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{parentResourcePath}/{resourceType}/{resourceName}") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{parentResourcePath}/{resourceType}/{resourceName}", + ) # pylint: disable=line-too-long path_format_arguments = { - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._\(\)]+$'), - "resourceProviderNamespace": _SERIALIZER.url("resource_provider_namespace", resource_provider_namespace, 'str'), - "parentResourcePath": _SERIALIZER.url("parent_resource_path", parent_resource_path, 'str', skip_quote=True), - "resourceType": _SERIALIZER.url("resource_type", resource_type, 'str', skip_quote=True), - "resourceName": _SERIALIZER.url("resource_name", resource_name, 'str'), - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), + "resourceGroupName": _SERIALIZER.url( + "resource_group_name", resource_group_name, "str", max_length=90, min_length=1, pattern=r"^[-\w\._\(\)]+$" + ), + "resourceProviderNamespace": _SERIALIZER.url("resource_provider_namespace", resource_provider_namespace, "str"), + "parentResourcePath": _SERIALIZER.url("parent_resource_path", parent_resource_path, "str", skip_quote=True), + "resourceType": _SERIALIZER.url("resource_type", resource_type, "str", skip_quote=True), + "resourceName": _SERIALIZER.url("resource_name", resource_name, "str"), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), } _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] if content_type is not None: - _header_parameters['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') - _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') - - return HttpRequest( - method="PATCH", - url=_url, - params=_query_parameters, - headers=_header_parameters, - json=json, - content=content, - **kwargs - ) + _headers["Content-Type"] = _SERIALIZER.header("content_type", content_type, "str") + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="PATCH", url=_url, params=_params, headers=_headers, **kwargs) def build_resources_get_request( @@ -848,745 +782,585 @@ def build_resources_get_request( api_version: str, **kwargs: Any ) -> HttpRequest: - accept = "application/json" + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + accept = _headers.pop("Accept", "application/json") + # Construct URL - _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{parentResourcePath}/{resourceType}/{resourceName}") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{parentResourcePath}/{resourceType}/{resourceName}", + ) # pylint: disable=line-too-long path_format_arguments = { - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._\(\)]+$'), - "resourceProviderNamespace": _SERIALIZER.url("resource_provider_namespace", resource_provider_namespace, 'str'), - "parentResourcePath": _SERIALIZER.url("parent_resource_path", parent_resource_path, 'str', skip_quote=True), - "resourceType": _SERIALIZER.url("resource_type", resource_type, 'str', skip_quote=True), - "resourceName": _SERIALIZER.url("resource_name", resource_name, 'str'), - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), + "resourceGroupName": _SERIALIZER.url( + "resource_group_name", resource_group_name, "str", max_length=90, min_length=1, pattern=r"^[-\w\._\(\)]+$" + ), + "resourceProviderNamespace": _SERIALIZER.url("resource_provider_namespace", resource_provider_namespace, "str"), + "parentResourcePath": _SERIALIZER.url("parent_resource_path", parent_resource_path, "str", skip_quote=True), + "resourceType": _SERIALIZER.url("resource_type", resource_type, "str", skip_quote=True), + "resourceName": _SERIALIZER.url("resource_name", resource_name, "str"), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), } _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') - - return HttpRequest( - method="GET", - url=_url, - params=_query_parameters, - headers=_header_parameters, - **kwargs - ) + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) + + +def build_resources_check_existence_by_id_request(resource_id: str, *, api_version: str, **kwargs: Any) -> HttpRequest: + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) -def build_resources_check_existence_by_id_request( - resource_id: str, - *, - api_version: str, - **kwargs: Any -) -> HttpRequest: # Construct URL _url = kwargs.pop("template_url", "/{resourceId}") path_format_arguments = { - "resourceId": _SERIALIZER.url("resource_id", resource_id, 'str', skip_quote=True), + "resourceId": _SERIALIZER.url("resource_id", resource_id, "str", skip_quote=True), } _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') - - return HttpRequest( - method="HEAD", - url=_url, - params=_query_parameters, - **kwargs - ) + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") + return HttpRequest(method="HEAD", url=_url, params=_params, **kwargs) + + +def build_resources_delete_by_id_request(resource_id: str, *, api_version: str, **kwargs: Any) -> HttpRequest: + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) -def build_resources_delete_by_id_request_initial( - resource_id: str, - *, - api_version: str, - **kwargs: Any -) -> HttpRequest: # Construct URL _url = kwargs.pop("template_url", "/{resourceId}") path_format_arguments = { - "resourceId": _SERIALIZER.url("resource_id", resource_id, 'str', skip_quote=True), + "resourceId": _SERIALIZER.url("resource_id", resource_id, "str", skip_quote=True), } _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') - - return HttpRequest( - method="DELETE", - url=_url, - params=_query_parameters, - **kwargs - ) + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") + return HttpRequest(method="DELETE", url=_url, params=_params, **kwargs) -def build_resources_create_or_update_by_id_request_initial( - resource_id: str, - *, - api_version: str, - json: JSONType = None, - content: Any = None, - **kwargs: Any -) -> HttpRequest: - content_type = kwargs.pop('content_type', None) # type: Optional[str] - accept = "application/json" +def build_resources_create_or_update_by_id_request(resource_id: str, *, api_version: str, **kwargs: Any) -> HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + accept = _headers.pop("Accept", "application/json") + # Construct URL _url = kwargs.pop("template_url", "/{resourceId}") path_format_arguments = { - "resourceId": _SERIALIZER.url("resource_id", resource_id, 'str', skip_quote=True), + "resourceId": _SERIALIZER.url("resource_id", resource_id, "str", skip_quote=True), } _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] if content_type is not None: - _header_parameters['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') - _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') - - return HttpRequest( - method="PUT", - url=_url, - params=_query_parameters, - headers=_header_parameters, - json=json, - content=content, - **kwargs - ) + _headers["Content-Type"] = _SERIALIZER.header("content_type", content_type, "str") + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + return HttpRequest(method="PUT", url=_url, params=_params, headers=_headers, **kwargs) -def build_resources_update_by_id_request_initial( - resource_id: str, - *, - api_version: str, - json: JSONType = None, - content: Any = None, - **kwargs: Any -) -> HttpRequest: - content_type = kwargs.pop('content_type', None) # type: Optional[str] - accept = "application/json" +def build_resources_update_by_id_request(resource_id: str, *, api_version: str, **kwargs: Any) -> HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + accept = _headers.pop("Accept", "application/json") + # Construct URL _url = kwargs.pop("template_url", "/{resourceId}") path_format_arguments = { - "resourceId": _SERIALIZER.url("resource_id", resource_id, 'str', skip_quote=True), + "resourceId": _SERIALIZER.url("resource_id", resource_id, "str", skip_quote=True), } _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] if content_type is not None: - _header_parameters['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') - _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') - - return HttpRequest( - method="PATCH", - url=_url, - params=_query_parameters, - headers=_header_parameters, - json=json, - content=content, - **kwargs - ) + _headers["Content-Type"] = _SERIALIZER.header("content_type", content_type, "str") + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + return HttpRequest(method="PATCH", url=_url, params=_params, headers=_headers, **kwargs) + + +def build_resources_get_by_id_request(resource_id: str, *, api_version: str, **kwargs: Any) -> HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + accept = _headers.pop("Accept", "application/json") -def build_resources_get_by_id_request( - resource_id: str, - *, - api_version: str, - **kwargs: Any -) -> HttpRequest: - accept = "application/json" # Construct URL _url = kwargs.pop("template_url", "/{resourceId}") path_format_arguments = { - "resourceId": _SERIALIZER.url("resource_id", resource_id, 'str', skip_quote=True), + "resourceId": _SERIALIZER.url("resource_id", resource_id, "str", skip_quote=True), } _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') - - return HttpRequest( - method="GET", - url=_url, - params=_query_parameters, - headers=_header_parameters, - **kwargs - ) + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) def build_resource_groups_check_existence_request( - resource_group_name: str, - subscription_id: str, - **kwargs: Any + resource_group_name: str, subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2017-05-10") # type: str + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + api_version = kwargs.pop("api_version", _params.pop("api-version", "2017-05-10")) # type: str # Construct URL _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}") path_format_arguments = { - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._\(\)]+$'), - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), + "resourceGroupName": _SERIALIZER.url( + "resource_group_name", resource_group_name, "str", max_length=90, min_length=1, pattern=r"^[-\w\._\(\)]+$" + ), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), } _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') - - return HttpRequest( - method="HEAD", - url=_url, - params=_query_parameters, - **kwargs - ) + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") + + return HttpRequest(method="HEAD", url=_url, params=_params, **kwargs) def build_resource_groups_create_or_update_request( - resource_group_name: str, - subscription_id: str, - *, - json: JSONType = None, - content: Any = None, - **kwargs: Any + resource_group_name: str, subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2017-05-10") # type: str - content_type = kwargs.pop('content_type', None) # type: Optional[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", "2017-05-10")) # type: str + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + accept = _headers.pop("Accept", "application/json") - accept = "application/json" # Construct URL _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}") path_format_arguments = { - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._\(\)]+$'), - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), + "resourceGroupName": _SERIALIZER.url( + "resource_group_name", resource_group_name, "str", max_length=90, min_length=1, pattern=r"^[-\w\._\(\)]+$" + ), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), } _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] if content_type is not None: - _header_parameters['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') - _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') - - return HttpRequest( - method="PUT", - url=_url, - params=_query_parameters, - headers=_header_parameters, - json=json, - content=content, - **kwargs - ) + _headers["Content-Type"] = _SERIALIZER.header("content_type", content_type, "str") + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + return HttpRequest(method="PUT", url=_url, params=_params, headers=_headers, **kwargs) -def build_resource_groups_delete_request_initial( - resource_group_name: str, - subscription_id: str, - **kwargs: Any -) -> HttpRequest: - api_version = kwargs.pop('api_version', "2017-05-10") # type: str +def build_resource_groups_delete_request(resource_group_name: str, subscription_id: str, **kwargs: Any) -> HttpRequest: + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2017-05-10")) # type: str # Construct URL _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}") path_format_arguments = { - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._\(\)]+$'), - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), + "resourceGroupName": _SERIALIZER.url( + "resource_group_name", resource_group_name, "str", max_length=90, min_length=1, pattern=r"^[-\w\._\(\)]+$" + ), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), } _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') - - return HttpRequest( - method="DELETE", - url=_url, - params=_query_parameters, - **kwargs - ) + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") + return HttpRequest(method="DELETE", url=_url, params=_params, **kwargs) -def build_resource_groups_get_request( - resource_group_name: str, - subscription_id: str, - **kwargs: Any -) -> HttpRequest: - api_version = kwargs.pop('api_version', "2017-05-10") # type: str - accept = "application/json" +def build_resource_groups_get_request(resource_group_name: str, subscription_id: str, **kwargs: Any) -> HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2017-05-10")) # type: str + accept = _headers.pop("Accept", "application/json") + # Construct URL _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}") path_format_arguments = { - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._\(\)]+$'), - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), + "resourceGroupName": _SERIALIZER.url( + "resource_group_name", resource_group_name, "str", max_length=90, min_length=1, pattern=r"^[-\w\._\(\)]+$" + ), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), } _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') - - return HttpRequest( - method="GET", - url=_url, - params=_query_parameters, - headers=_header_parameters, - **kwargs - ) + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) -def build_resource_groups_update_request( - resource_group_name: str, - subscription_id: str, - *, - json: JSONType = None, - content: Any = None, - **kwargs: Any -) -> HttpRequest: - api_version = kwargs.pop('api_version', "2017-05-10") # type: str - content_type = kwargs.pop('content_type', None) # type: Optional[str] - accept = "application/json" +def build_resource_groups_update_request(resource_group_name: str, subscription_id: str, **kwargs: Any) -> HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2017-05-10")) # type: str + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + accept = _headers.pop("Accept", "application/json") + # Construct URL _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}") path_format_arguments = { - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._\(\)]+$'), - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), + "resourceGroupName": _SERIALIZER.url( + "resource_group_name", resource_group_name, "str", max_length=90, min_length=1, pattern=r"^[-\w\._\(\)]+$" + ), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), } _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] if content_type is not None: - _header_parameters['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') - _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') - - return HttpRequest( - method="PATCH", - url=_url, - params=_query_parameters, - headers=_header_parameters, - json=json, - content=content, - **kwargs - ) + _headers["Content-Type"] = _SERIALIZER.header("content_type", content_type, "str") + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="PATCH", url=_url, params=_params, headers=_headers, **kwargs) def build_resource_groups_export_template_request( - resource_group_name: str, - subscription_id: str, - *, - json: JSONType = None, - content: Any = None, - **kwargs: Any + resource_group_name: str, subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2017-05-10") # type: str - content_type = kwargs.pop('content_type', None) # type: Optional[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", "2017-05-10")) # type: str + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + accept = _headers.pop("Accept", "application/json") - accept = "application/json" # Construct URL - _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/exportTemplate") + _url = kwargs.pop( + "template_url", "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/exportTemplate" + ) path_format_arguments = { - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._\(\)]+$'), - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), + "resourceGroupName": _SERIALIZER.url( + "resource_group_name", resource_group_name, "str", max_length=90, min_length=1, pattern=r"^[-\w\._\(\)]+$" + ), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), } _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] if content_type is not None: - _header_parameters['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') - _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') - - return HttpRequest( - method="POST", - url=_url, - params=_query_parameters, - headers=_header_parameters, - json=json, - content=content, - **kwargs - ) + _headers["Content-Type"] = _SERIALIZER.header("content_type", content_type, "str") + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="POST", url=_url, params=_params, headers=_headers, **kwargs) def build_resource_groups_list_request( - subscription_id: str, - *, - filter: Optional[str] = None, - top: Optional[int] = None, - **kwargs: Any + subscription_id: str, *, filter: Optional[str] = None, top: Optional[int] = None, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2017-05-10") # type: 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", "2017-05-10")) # type: str + accept = _headers.pop("Accept", "application/json") - accept = "application/json" # Construct URL _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourcegroups") path_format_arguments = { - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), } _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] if filter is not None: - _query_parameters['$filter'] = _SERIALIZER.query("filter", filter, 'str') + _params["$filter"] = _SERIALIZER.query("filter", filter, "str") if top is not None: - _query_parameters['$top'] = _SERIALIZER.query("top", top, 'int') - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["$top"] = _SERIALIZER.query("top", top, "int") + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') - - return HttpRequest( - method="GET", - url=_url, - params=_query_parameters, - headers=_header_parameters, - **kwargs - ) + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) -def build_tags_delete_value_request( - tag_name: str, - tag_value: str, - subscription_id: str, - **kwargs: Any -) -> HttpRequest: - api_version = kwargs.pop('api_version', "2017-05-10") # type: str +def build_tags_delete_value_request(tag_name: str, tag_value: str, subscription_id: str, **kwargs: Any) -> HttpRequest: + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2017-05-10")) # type: str # Construct URL _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/tagNames/{tagName}/tagValues/{tagValue}") path_format_arguments = { - "tagName": _SERIALIZER.url("tag_name", tag_name, 'str'), - "tagValue": _SERIALIZER.url("tag_value", tag_value, 'str'), - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), + "tagName": _SERIALIZER.url("tag_name", tag_name, "str"), + "tagValue": _SERIALIZER.url("tag_value", tag_value, "str"), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), } _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') - - return HttpRequest( - method="DELETE", - url=_url, - params=_query_parameters, - **kwargs - ) + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") + + return HttpRequest(method="DELETE", url=_url, params=_params, **kwargs) def build_tags_create_or_update_value_request( - tag_name: str, - tag_value: str, - subscription_id: str, - **kwargs: Any + tag_name: str, tag_value: str, subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2017-05-10") # type: 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", "2017-05-10")) # type: str + accept = _headers.pop("Accept", "application/json") - accept = "application/json" # Construct URL _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/tagNames/{tagName}/tagValues/{tagValue}") path_format_arguments = { - "tagName": _SERIALIZER.url("tag_name", tag_name, 'str'), - "tagValue": _SERIALIZER.url("tag_value", tag_value, 'str'), - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), + "tagName": _SERIALIZER.url("tag_name", tag_name, "str"), + "tagValue": _SERIALIZER.url("tag_value", tag_value, "str"), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), } _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') - - return HttpRequest( - method="PUT", - url=_url, - params=_query_parameters, - headers=_header_parameters, - **kwargs - ) + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + return HttpRequest(method="PUT", url=_url, params=_params, headers=_headers, **kwargs) -def build_tags_create_or_update_request( - tag_name: str, - subscription_id: str, - **kwargs: Any -) -> HttpRequest: - api_version = kwargs.pop('api_version', "2017-05-10") # type: str - accept = "application/json" +def build_tags_create_or_update_request(tag_name: str, subscription_id: str, **kwargs: Any) -> HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2017-05-10")) # type: str + accept = _headers.pop("Accept", "application/json") + # Construct URL _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/tagNames/{tagName}") path_format_arguments = { - "tagName": _SERIALIZER.url("tag_name", tag_name, 'str'), - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), + "tagName": _SERIALIZER.url("tag_name", tag_name, "str"), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), } _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') - - return HttpRequest( - method="PUT", - url=_url, - params=_query_parameters, - headers=_header_parameters, - **kwargs - ) + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + return HttpRequest(method="PUT", url=_url, params=_params, headers=_headers, **kwargs) -def build_tags_delete_request( - tag_name: str, - subscription_id: str, - **kwargs: Any -) -> HttpRequest: - api_version = kwargs.pop('api_version', "2017-05-10") # type: str +def build_tags_delete_request(tag_name: str, subscription_id: str, **kwargs: Any) -> HttpRequest: + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2017-05-10")) # type: str # Construct URL _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/tagNames/{tagName}") path_format_arguments = { - "tagName": _SERIALIZER.url("tag_name", tag_name, 'str'), - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), + "tagName": _SERIALIZER.url("tag_name", tag_name, "str"), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), } _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') - - return HttpRequest( - method="DELETE", - url=_url, - params=_query_parameters, - **kwargs - ) + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") + return HttpRequest(method="DELETE", url=_url, params=_params, **kwargs) -def build_tags_list_request( - subscription_id: str, - **kwargs: Any -) -> HttpRequest: - api_version = kwargs.pop('api_version', "2017-05-10") # type: str - accept = "application/json" +def build_tags_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", "2017-05-10")) # type: str + accept = _headers.pop("Accept", "application/json") + # Construct URL _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/tagNames") path_format_arguments = { - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), } _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') - - return HttpRequest( - method="GET", - url=_url, - params=_query_parameters, - headers=_header_parameters, - **kwargs - ) + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) def build_deployment_operations_get_request( - resource_group_name: str, - deployment_name: str, - operation_id: str, - subscription_id: str, - **kwargs: Any + resource_group_name: str, deployment_name: str, operation_id: str, subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2017-05-10") # type: 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", "2017-05-10")) # type: str + accept = _headers.pop("Accept", "application/json") - accept = "application/json" # Construct URL - _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/deployments/{deploymentName}/operations/{operationId}") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/deployments/{deploymentName}/operations/{operationId}", + ) # pylint: disable=line-too-long path_format_arguments = { - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._\(\)]+$'), - "deploymentName": _SERIALIZER.url("deployment_name", deployment_name, 'str', max_length=64, min_length=1, pattern=r'^[-\w\._\(\)]+$'), - "operationId": _SERIALIZER.url("operation_id", operation_id, 'str'), - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), + "resourceGroupName": _SERIALIZER.url( + "resource_group_name", resource_group_name, "str", max_length=90, min_length=1, pattern=r"^[-\w\._\(\)]+$" + ), + "deploymentName": _SERIALIZER.url( + "deployment_name", deployment_name, "str", max_length=64, min_length=1, pattern=r"^[-\w\._\(\)]+$" + ), + "operationId": _SERIALIZER.url("operation_id", operation_id, "str"), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), } _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') - - return HttpRequest( - method="GET", - url=_url, - params=_query_parameters, - headers=_header_parameters, - **kwargs - ) + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) def build_deployment_operations_list_request( - resource_group_name: str, - deployment_name: str, - subscription_id: str, - *, - top: Optional[int] = None, - **kwargs: Any + resource_group_name: str, deployment_name: str, subscription_id: str, *, top: Optional[int] = None, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2017-05-10") # type: 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", "2017-05-10")) # type: str + accept = _headers.pop("Accept", "application/json") - accept = "application/json" # Construct URL - _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/deployments/{deploymentName}/operations") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/deployments/{deploymentName}/operations", + ) # pylint: disable=line-too-long path_format_arguments = { - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._\(\)]+$'), - "deploymentName": _SERIALIZER.url("deployment_name", deployment_name, 'str', max_length=64, min_length=1, pattern=r'^[-\w\._\(\)]+$'), - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), + "resourceGroupName": _SERIALIZER.url( + "resource_group_name", resource_group_name, "str", max_length=90, min_length=1, pattern=r"^[-\w\._\(\)]+$" + ), + "deploymentName": _SERIALIZER.url( + "deployment_name", deployment_name, "str", max_length=64, min_length=1, pattern=r"^[-\w\._\(\)]+$" + ), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), } _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] if top is not None: - _query_parameters['$top'] = _SERIALIZER.query("top", top, 'int') - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["$top"] = _SERIALIZER.query("top", top, "int") + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') - - return HttpRequest( - method="GET", - url=_url, - params=_query_parameters, - headers=_header_parameters, - **kwargs - ) + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") -class DeploymentsOperations(object): - """DeploymentsOperations operations. + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) - You should not instantiate this class directly. Instead, you should create a Client instance that - instantiates it for you and attaches it as an attribute. - :ivar models: Alias to model classes used in this operation group. - :type models: ~azure.mgmt.resource.resources.v2017_05_10.models - :param client: Client for service requests. - :param config: Configuration of service client. - :param serializer: An object model serializer. - :param deserializer: An object model deserializer. +class DeploymentsOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. + + Instead, you should access the following operations through + :class:`~azure.mgmt.resource.resources.v2017_05_10.ResourceManagementClient`'s + :attr:`deployments` attribute. """ models = _models - def __init__(self, client, config, serializer, deserializer): - self._client = client - self._serialize = serializer - self._deserialize = deserializer - self._config = config + def __init__(self, *args, **kwargs): + input_args = list(args) + self._client = input_args.pop(0) if input_args else kwargs.pop("client") + self._config = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") def _delete_initial( # pylint: disable=inconsistent-return-statements - self, - resource_group_name: str, - deployment_name: str, - **kwargs: Any + self, resource_group_name: str, deployment_name: str, **kwargs: Any ) -> None: - cls = kwargs.pop('cls', None) # type: ClsType[None] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) - api_version = kwargs.pop('api_version', "2017-05-10") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - request = build_deployments_delete_request_initial( + api_version = kwargs.pop("api_version", _params.pop("api-version", "2017-05-10")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[None] + + request = build_deployments_delete_request( resource_group_name=resource_group_name, deployment_name=deployment_name, subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self._delete_initial.metadata['url'], + template_url=self._delete_initial.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [202, 204]: @@ -1596,16 +1370,10 @@ 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.Resources/deployments/{deploymentName}"} # type: ignore - + _delete_initial.metadata = {"url": "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/Microsoft.Resources/deployments/{deploymentName}"} # type: ignore @distributed_trace - def begin_delete( # pylint: disable=inconsistent-return-statements - self, - resource_group_name: str, - deployment_name: str, - **kwargs: Any - ) -> LROPoller[None]: + def begin_delete(self, resource_group_name: str, deployment_name: str, **kwargs: Any) -> LROPoller[None]: """Deletes a deployment from the deployment history. A template deployment that is currently running cannot be deleted. Deleting a template @@ -1618,9 +1386,9 @@ def begin_delete( # pylint: disable=inconsistent-return-statements asynchronous request failed, the URI in the Location header returns an error-level status code. :param resource_group_name: The name of the resource group with the deployment to delete. The - name is case insensitive. + name is case insensitive. Required. :type resource_group_name: str - :param deployment_name: The name of the deployment to delete. + :param deployment_name: The name of the deployment to delete. Required. :type deployment_name: str :keyword callable cls: A custom type or function that will be passed the direct response :keyword str continuation_token: A continuation token to restart a poller from a saved state. @@ -1632,88 +1400,93 @@ def begin_delete( # pylint: disable=inconsistent-return-statements Retry-After header is present. :return: An instance of LROPoller that returns either None or the result of cls(response) :rtype: ~azure.core.polling.LROPoller[None] - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - api_version = kwargs.pop('api_version', "2017-05-10") # type: str - polling = kwargs.pop('polling', True) # type: Union[bool, PollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType[None] - lro_delay = kwargs.pop( - 'polling_interval', - self._config.polling_interval - ) - cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2017-05-10")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[None] + polling = kwargs.pop("polling", True) # type: Union[bool, PollingMethod] + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token = kwargs.pop("continuation_token", None) # type: Optional[str] if cont_token is None: - raw_result = self._delete_initial( + raw_result = self._delete_initial( # type: ignore resource_group_name=resource_group_name, deployment_name=deployment_name, api_version=api_version, - cls=lambda x,y,z: x, + cls=lambda x, y, z: x, + headers=_headers, + params=_params, **kwargs ) - kwargs.pop('error_map', None) + kwargs.pop("error_map", None) - def get_long_running_output(pipeline_response): + def get_long_running_output(pipeline_response): # pylint: disable=inconsistent-return-statements if cls: return cls(pipeline_response, None, {}) - - if polling is True: polling_method = ARMPolling(lro_delay, **kwargs) - elif polling is False: polling_method = NoPolling() - else: polling_method = polling + if polling is True: + polling_method = cast(PollingMethod, ARMPolling(lro_delay, **kwargs)) # type: PollingMethod + elif polling is False: + polling_method = cast(PollingMethod, NoPolling()) + else: + polling_method = polling if cont_token: return LROPoller.from_continuation_token( polling_method=polling_method, continuation_token=cont_token, client=self._client, - deserialization_callback=get_long_running_output + deserialization_callback=get_long_running_output, ) return LROPoller(self._client, raw_result, get_long_running_output, polling_method) - begin_delete.metadata = {'url': "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/Microsoft.Resources/deployments/{deploymentName}"} # type: ignore + begin_delete.metadata = {"url": "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/Microsoft.Resources/deployments/{deploymentName}"} # type: ignore @distributed_trace - def check_existence( - self, - resource_group_name: str, - deployment_name: str, - **kwargs: Any - ) -> bool: + def check_existence(self, resource_group_name: str, deployment_name: str, **kwargs: Any) -> bool: """Checks whether the deployment exists. :param resource_group_name: The name of the resource group with the deployment to check. The - name is case insensitive. + name is case insensitive. Required. :type resource_group_name: str - :param deployment_name: The name of the deployment to check. + :param deployment_name: The name of the deployment to check. Required. :type deployment_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: bool, or the result of cls(response) + :return: bool or the result of cls(response) :rtype: bool - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType[None] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + 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', "2017-05-10") # type: str + api_version = kwargs.pop("api_version", _params.pop("api-version", "2017-05-10")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[None] - request = build_deployments_check_existence_request( resource_group_name=resource_group_name, deployment_name=deployment_name, subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.check_existence.metadata['url'], + template_url=self.check_existence.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [204, 404]: @@ -1724,44 +1497,53 @@ def check_existence( return cls(pipeline_response, None, {}) return 200 <= response.status_code <= 299 - check_existence.metadata = {'url': "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/Microsoft.Resources/deployments/{deploymentName}"} # type: ignore - + check_existence.metadata = {"url": "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/Microsoft.Resources/deployments/{deploymentName}"} # type: ignore def _create_or_update_initial( - self, - resource_group_name: str, - deployment_name: str, - parameters: "_models.Deployment", - **kwargs: Any - ) -> "_models.DeploymentExtended": - cls = kwargs.pop('cls', None) # type: ClsType["_models.DeploymentExtended"] + self, resource_group_name: str, deployment_name: str, parameters: Union[_models.Deployment, IO], **kwargs: Any + ) -> _models.DeploymentExtended: error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) - api_version = kwargs.pop('api_version', "2017-05-10") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - _json = self._serialize.body(parameters, 'Deployment') + api_version = kwargs.pop("api_version", _params.pop("api-version", "2017-05-10")) # type: str + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.DeploymentExtended] - request = build_deployments_create_or_update_request_initial( + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(parameters, (IO, bytes)): + _content = parameters + else: + _json = self._serialize.body(parameters, "Deployment") + + request = build_deployments_create_or_update_request( resource_group_name=resource_group_name, deployment_name=deployment_name, subscription_id=self._config.subscription_id, api_version=api_version, content_type=content_type, json=_json, - template_url=self._create_or_update_initial.metadata['url'], + content=_content, + template_url=self._create_or_update_initial.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200, 201]: @@ -1769,38 +1551,42 @@ def _create_or_update_initial( raise HttpResponseError(response=response, error_format=ARMErrorFormat) if response.status_code == 200: - deserialized = self._deserialize('DeploymentExtended', pipeline_response) + deserialized = self._deserialize("DeploymentExtended", pipeline_response) if response.status_code == 201: - deserialized = self._deserialize('DeploymentExtended', pipeline_response) + deserialized = self._deserialize("DeploymentExtended", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - _create_or_update_initial.metadata = {'url': "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/Microsoft.Resources/deployments/{deploymentName}"} # type: ignore + _create_or_update_initial.metadata = {"url": "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/Microsoft.Resources/deployments/{deploymentName}"} # type: ignore - - @distributed_trace + @overload def begin_create_or_update( self, resource_group_name: str, deployment_name: str, - parameters: "_models.Deployment", + parameters: _models.Deployment, + *, + content_type: str = "application/json", **kwargs: Any - ) -> LROPoller["_models.DeploymentExtended"]: + ) -> LROPoller[_models.DeploymentExtended]: """Deploys resources to a resource group. You can provide the template and parameters directly in the request or link to JSON files. :param resource_group_name: The name of the resource group to deploy the resources to. The name - is case insensitive. The resource group must already exist. + is case insensitive. The resource group must already exist. Required. :type resource_group_name: str - :param deployment_name: The name of the deployment. + :param deployment_name: The name of the deployment. Required. :type deployment_name: str - :param parameters: Additional parameters supplied to the operation. + :param parameters: Additional parameters supplied to the operation. Required. :type parameters: ~azure.mgmt.resource.resources.v2017_05_10.models.Deployment + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str :keyword callable cls: A custom type or function that will be passed the direct response :keyword str continuation_token: A continuation token to restart a poller from a saved state. :keyword polling: By default, your polling method will be ARMPolling. Pass in False for this @@ -1813,115 +1599,189 @@ def begin_create_or_update( cls(response) :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.resource.resources.v2017_05_10.models.DeploymentExtended] - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - api_version = kwargs.pop('api_version', "2017-05-10") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] - polling = kwargs.pop('polling', True) # type: Union[bool, PollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType["_models.DeploymentExtended"] - lro_delay = kwargs.pop( - 'polling_interval', - self._config.polling_interval - ) - cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] + + @overload + def begin_create_or_update( + self, + resource_group_name: str, + deployment_name: str, + parameters: IO, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> LROPoller[_models.DeploymentExtended]: + """Deploys resources to a resource group. + + You can provide the template and parameters directly in the request or link to JSON files. + + :param resource_group_name: The name of the resource group to deploy the resources to. The name + is case insensitive. The resource group must already exist. Required. + :type resource_group_name: str + :param deployment_name: The name of the deployment. Required. + :type deployment_name: str + :param parameters: Additional parameters supplied to the operation. Required. + :type parameters: IO + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be ARMPolling. Pass in False for this + operation to not poll, or pass in your own initialized polling object for a personal polling + strategy. + :paramtype polling: bool or ~azure.core.polling.PollingMethod + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of LROPoller that returns either DeploymentExtended or the result of + cls(response) + :rtype: + ~azure.core.polling.LROPoller[~azure.mgmt.resource.resources.v2017_05_10.models.DeploymentExtended] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace + def begin_create_or_update( + self, resource_group_name: str, deployment_name: str, parameters: Union[_models.Deployment, IO], **kwargs: Any + ) -> LROPoller[_models.DeploymentExtended]: + """Deploys resources to a resource group. + + You can provide the template and parameters directly in the request or link to JSON files. + + :param resource_group_name: The name of the resource group to deploy the resources to. The name + is case insensitive. The resource group must already exist. Required. + :type resource_group_name: str + :param deployment_name: The name of the deployment. Required. + :type deployment_name: str + :param parameters: Additional parameters supplied to the operation. Is either a model type or a + IO type. Required. + :type parameters: ~azure.mgmt.resource.resources.v2017_05_10.models.Deployment or IO + :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. + Default value is None. + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be ARMPolling. Pass in False for this + operation to not poll, or pass in your own initialized polling object for a personal polling + strategy. + :paramtype polling: bool or ~azure.core.polling.PollingMethod + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of LROPoller that returns either DeploymentExtended or the result of + cls(response) + :rtype: + ~azure.core.polling.LROPoller[~azure.mgmt.resource.resources.v2017_05_10.models.DeploymentExtended] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _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", "2017-05-10")) # type: str + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.DeploymentExtended] + polling = kwargs.pop("polling", True) # type: Union[bool, PollingMethod] + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token = kwargs.pop("continuation_token", None) # type: Optional[str] if cont_token is None: - raw_result = self._create_or_update_initial( + raw_result = self._create_or_update_initial( # type: ignore resource_group_name=resource_group_name, deployment_name=deployment_name, parameters=parameters, api_version=api_version, content_type=content_type, - cls=lambda x,y,z: x, + cls=lambda x, y, z: x, + headers=_headers, + params=_params, **kwargs ) - kwargs.pop('error_map', None) + kwargs.pop("error_map", None) def get_long_running_output(pipeline_response): - response = pipeline_response.http_response - deserialized = self._deserialize('DeploymentExtended', pipeline_response) + deserialized = self._deserialize("DeploymentExtended", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - - if polling is True: polling_method = ARMPolling(lro_delay, **kwargs) - elif polling is False: polling_method = NoPolling() - else: polling_method = polling + if polling is True: + polling_method = cast(PollingMethod, ARMPolling(lro_delay, **kwargs)) # type: PollingMethod + elif polling is False: + polling_method = cast(PollingMethod, NoPolling()) + else: + polling_method = polling if cont_token: return LROPoller.from_continuation_token( polling_method=polling_method, continuation_token=cont_token, client=self._client, - deserialization_callback=get_long_running_output + deserialization_callback=get_long_running_output, ) return LROPoller(self._client, raw_result, get_long_running_output, polling_method) - begin_create_or_update.metadata = {'url': "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/Microsoft.Resources/deployments/{deploymentName}"} # type: ignore + begin_create_or_update.metadata = {"url": "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/Microsoft.Resources/deployments/{deploymentName}"} # type: ignore @distributed_trace - def get( - self, - resource_group_name: str, - deployment_name: str, - **kwargs: Any - ) -> "_models.DeploymentExtended": + def get(self, resource_group_name: str, deployment_name: str, **kwargs: Any) -> _models.DeploymentExtended: """Gets a deployment. :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. :type resource_group_name: str - :param deployment_name: The name of the deployment to get. + :param deployment_name: The name of the deployment to get. Required. :type deployment_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: DeploymentExtended, or the result of cls(response) + :return: DeploymentExtended or the result of cls(response) :rtype: ~azure.mgmt.resource.resources.v2017_05_10.models.DeploymentExtended - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.DeploymentExtended"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) - api_version = kwargs.pop('api_version', "2017-05-10") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2017-05-10")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[_models.DeploymentExtended] - request = build_deployments_get_request( resource_group_name=resource_group_name, deployment_name=deployment_name, subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.get.metadata['url'], + template_url=self.get.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) - deserialized = self._deserialize('DeploymentExtended', pipeline_response) + deserialized = self._deserialize("DeploymentExtended", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - get.metadata = {'url': "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/Microsoft.Resources/deployments/{deploymentName}"} # type: ignore - + get.metadata = {"url": "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/Microsoft.Resources/deployments/{deploymentName}"} # type: ignore @distributed_trace def cancel( # pylint: disable=inconsistent-return-statements - self, - resource_group_name: str, - deployment_name: str, - **kwargs: Any + self, resource_group_name: str, deployment_name: str, **kwargs: Any ) -> None: """Cancels a currently running template deployment. @@ -1931,38 +1791,45 @@ def cancel( # pylint: disable=inconsistent-return-statements partially deployed. :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. :type resource_group_name: str - :param deployment_name: The name of the deployment to cancel. + :param deployment_name: The name of the deployment to cancel. Required. :type deployment_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: None, or the result of cls(response) + :return: None or the result of cls(response) :rtype: None - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType[None] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + 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', "2017-05-10") # type: str + api_version = kwargs.pop("api_version", _params.pop("api-version", "2017-05-10")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[None] - request = build_deployments_cancel_request( resource_group_name=resource_group_name, deployment_name=deployment_name, subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.cancel.metadata['url'], + template_url=self.cancel.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [204]: @@ -1972,42 +1839,110 @@ def cancel( # pylint: disable=inconsistent-return-statements if cls: return cls(pipeline_response, None, {}) - cancel.metadata = {'url': "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/Microsoft.Resources/deployments/{deploymentName}/cancel"} # type: ignore - + cancel.metadata = {"url": "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/Microsoft.Resources/deployments/{deploymentName}/cancel"} # type: ignore - @distributed_trace + @overload def validate( self, resource_group_name: str, deployment_name: str, - parameters: "_models.Deployment", + parameters: _models.Deployment, + *, + content_type: str = "application/json", **kwargs: Any - ) -> "_models.DeploymentValidateResult": + ) -> _models.DeploymentValidateResult: """Validates whether the specified template is syntactically correct and will be accepted by Azure Resource Manager.. :param resource_group_name: The name of the resource group the template will be deployed to. - The name is case insensitive. + The name is case insensitive. Required. :type resource_group_name: str - :param deployment_name: The name of the deployment. + :param deployment_name: The name of the deployment. Required. :type deployment_name: str - :param parameters: Parameters to validate. + :param parameters: Parameters to validate. Required. :type parameters: ~azure.mgmt.resource.resources.v2017_05_10.models.Deployment + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: DeploymentValidateResult or the result of cls(response) + :rtype: ~azure.mgmt.resource.resources.v2017_05_10.models.DeploymentValidateResult + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + def validate( + self, + resource_group_name: str, + deployment_name: str, + parameters: IO, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.DeploymentValidateResult: + """Validates whether the specified template is syntactically correct and will be accepted by Azure + Resource Manager.. + + :param resource_group_name: The name of the resource group the template will be deployed to. + The name is case insensitive. Required. + :type resource_group_name: str + :param deployment_name: The name of the deployment. Required. + :type deployment_name: str + :param parameters: Parameters to validate. Required. + :type parameters: IO + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: DeploymentValidateResult or the result of cls(response) + :rtype: ~azure.mgmt.resource.resources.v2017_05_10.models.DeploymentValidateResult + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace + def validate( + self, resource_group_name: str, deployment_name: str, parameters: Union[_models.Deployment, IO], **kwargs: Any + ) -> _models.DeploymentValidateResult: + """Validates whether the specified template is syntactically correct and will be accepted by Azure + Resource Manager.. + + :param resource_group_name: The name of the resource group the template will be deployed to. + The name is case insensitive. Required. + :type resource_group_name: str + :param deployment_name: The name of the deployment. Required. + :type deployment_name: str + :param parameters: Parameters to validate. Is either a model type or a IO type. Required. + :type parameters: ~azure.mgmt.resource.resources.v2017_05_10.models.Deployment or IO + :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. + Default value is None. + :paramtype content_type: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: DeploymentValidateResult, or the result of cls(response) + :return: DeploymentValidateResult or the result of cls(response) :rtype: ~azure.mgmt.resource.resources.v2017_05_10.models.DeploymentValidateResult - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.DeploymentValidateResult"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', "2017-05-10") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + api_version = kwargs.pop("api_version", _params.pop("api-version", "2017-05-10")) # type: str + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.DeploymentValidateResult] - _json = self._serialize.body(parameters, 'Deployment') + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(parameters, (IO, bytes)): + _content = parameters + else: + _json = self._serialize.body(parameters, "Deployment") request = build_deployments_validate_request( resource_group_name=resource_group_name, @@ -2016,16 +1951,18 @@ def validate( api_version=api_version, content_type=content_type, json=_json, - template_url=self.validate.metadata['url'], + content=_content, + template_url=self.validate.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200, 400]: @@ -2033,89 +1970,87 @@ def validate( raise HttpResponseError(response=response, error_format=ARMErrorFormat) if response.status_code == 200: - deserialized = self._deserialize('DeploymentValidateResult', pipeline_response) + deserialized = self._deserialize("DeploymentValidateResult", pipeline_response) if response.status_code == 400: - deserialized = self._deserialize('DeploymentValidateResult', pipeline_response) + deserialized = self._deserialize("DeploymentValidateResult", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - validate.metadata = {'url': "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/Microsoft.Resources/deployments/{deploymentName}/validate"} # type: ignore - + validate.metadata = {"url": "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/Microsoft.Resources/deployments/{deploymentName}/validate"} # type: ignore @distributed_trace def export_template( - self, - resource_group_name: str, - deployment_name: str, - **kwargs: Any - ) -> "_models.DeploymentExportResult": + self, resource_group_name: str, deployment_name: str, **kwargs: Any + ) -> _models.DeploymentExportResult: """Exports the template used for specified deployment. :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. :type resource_group_name: str - :param deployment_name: The name of the deployment from which to get the template. + :param deployment_name: The name of the deployment from which to get the template. Required. :type deployment_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: DeploymentExportResult, or the result of cls(response) + :return: DeploymentExportResult or the result of cls(response) :rtype: ~azure.mgmt.resource.resources.v2017_05_10.models.DeploymentExportResult - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.DeploymentExportResult"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) - api_version = kwargs.pop('api_version', "2017-05-10") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2017-05-10")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[_models.DeploymentExportResult] - request = build_deployments_export_template_request( resource_group_name=resource_group_name, deployment_name=deployment_name, subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.export_template.metadata['url'], + template_url=self.export_template.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) - deserialized = self._deserialize('DeploymentExportResult', pipeline_response) + deserialized = self._deserialize("DeploymentExportResult", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - export_template.metadata = {'url': "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/Microsoft.Resources/deployments/{deploymentName}/exportTemplate"} # type: ignore - + export_template.metadata = {"url": "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/Microsoft.Resources/deployments/{deploymentName}/exportTemplate"} # type: ignore @distributed_trace def list_by_resource_group( - self, - resource_group_name: str, - filter: Optional[str] = None, - top: Optional[int] = None, - **kwargs: Any - ) -> Iterable["_models.DeploymentListResult"]: + self, resource_group_name: str, filter: Optional[str] = None, top: Optional[int] = None, **kwargs: Any + ) -> Iterable["_models.DeploymentExtended"]: """Get all the deployments for a resource group. :param resource_group_name: The name of the resource group with the deployments to get. The - name is case insensitive. + name is case insensitive. Required. :type resource_group_name: str :param filter: The filter to apply on the operation. For example, you can use $filter=provisioningState eq '{state}'. Default value is None. @@ -2124,42 +2059,49 @@ def list_by_resource_group( value is None. :type top: int :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either DeploymentListResult or the result of - cls(response) + :return: An iterator like instance of either DeploymentExtended or the result of cls(response) :rtype: - ~azure.core.paging.ItemPaged[~azure.mgmt.resource.resources.v2017_05_10.models.DeploymentListResult] - :raises: ~azure.core.exceptions.HttpResponseError + ~azure.core.paging.ItemPaged[~azure.mgmt.resource.resources.v2017_05_10.models.DeploymentExtended] + :raises ~azure.core.exceptions.HttpResponseError: """ - api_version = kwargs.pop('api_version', "2017-05-10") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2017-05-10")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[_models.DeploymentListResult] - cls = kwargs.pop('cls', None) # type: ClsType["_models.DeploymentListResult"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) + def prepare_request(next_link=None): if not next_link: - + request = build_deployments_list_by_resource_group_request( resource_group_name=resource_group_name, subscription_id=self._config.subscription_id, - api_version=api_version, filter=filter, top=top, - template_url=self.list_by_resource_group.metadata['url'], + 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.url = self._client.format_url(request.url) # type: ignore else: - - request = build_deployments_list_by_resource_group_request( - resource_group_name=resource_group_name, - subscription_id=self._config.subscription_id, - template_url=next_link, - ) + # make call to next link with the client's api-version + _parsed_next_link = urlparse(next_link) + _next_request_params = case_insensitive_dict(parse_qs(_parsed_next_link.query)) + _next_request_params["api-version"] = self._config.api_version + request = HttpRequest("GET", urljoin(next_link, _parsed_next_link.path), params=_next_request_params) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore request.method = "GET" return request @@ -2173,10 +2115,8 @@ def extract_data(pipeline_response): def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) response = pipeline_response.http_response @@ -2186,204 +2126,204 @@ def get_next(next_link=None): return pipeline_response + return ItemPaged(get_next, extract_data) - return ItemPaged( - get_next, extract_data - ) - list_by_resource_group.metadata = {'url': "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/Microsoft.Resources/deployments/"} # type: ignore + list_by_resource_group.metadata = {"url": "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/Microsoft.Resources/deployments/"} # type: ignore @distributed_trace - def calculate_template_hash( - self, - template: Any, - **kwargs: Any - ) -> "_models.TemplateHashResult": + def calculate_template_hash(self, template: JSON, **kwargs: Any) -> _models.TemplateHashResult: """Calculate the hash of the given template. - :param template: The template provided to calculate hash. - :type template: any + :param template: The template provided to calculate hash. Required. + :type template: JSON :keyword callable cls: A custom type or function that will be passed the direct response - :return: TemplateHashResult, or the result of cls(response) + :return: TemplateHashResult or the result of cls(response) :rtype: ~azure.mgmt.resource.resources.v2017_05_10.models.TemplateHashResult - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.TemplateHashResult"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) - api_version = kwargs.pop('api_version', "2017-05-10") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - _json = self._serialize.body(template, 'object') + api_version = kwargs.pop("api_version", _params.pop("api-version", "2017-05-10")) # type: str + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", "application/json")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[_models.TemplateHashResult] + + _json = self._serialize.body(template, "object") request = build_deployments_calculate_template_hash_request( api_version=api_version, content_type=content_type, json=_json, - template_url=self.calculate_template_hash.metadata['url'], + template_url=self.calculate_template_hash.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) - deserialized = self._deserialize('TemplateHashResult', pipeline_response) + deserialized = self._deserialize("TemplateHashResult", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - calculate_template_hash.metadata = {'url': "/providers/Microsoft.Resources/calculateTemplateHash"} # type: ignore + calculate_template_hash.metadata = {"url": "/providers/Microsoft.Resources/calculateTemplateHash"} # type: ignore -class ProvidersOperations(object): - """ProvidersOperations operations. - You should not instantiate this class directly. Instead, you should create a Client instance that - instantiates it for you and attaches it as an attribute. +class ProvidersOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. - :ivar models: Alias to model classes used in this operation group. - :type models: ~azure.mgmt.resource.resources.v2017_05_10.models - :param client: Client for service requests. - :param config: Configuration of service client. - :param serializer: An object model serializer. - :param deserializer: An object model deserializer. + Instead, you should access the following operations through + :class:`~azure.mgmt.resource.resources.v2017_05_10.ResourceManagementClient`'s + :attr:`providers` attribute. """ models = _models - def __init__(self, client, config, serializer, deserializer): - self._client = client - self._serialize = serializer - self._deserialize = deserializer - self._config = config + def __init__(self, *args, **kwargs): + input_args = list(args) + self._client = input_args.pop(0) if input_args else kwargs.pop("client") + self._config = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") @distributed_trace - def unregister( - self, - resource_provider_namespace: str, - **kwargs: Any - ) -> "_models.Provider": + def unregister(self, resource_provider_namespace: str, **kwargs: Any) -> _models.Provider: """Unregisters a subscription from a resource provider. :param resource_provider_namespace: The namespace of the resource provider to unregister. + Required. :type resource_provider_namespace: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: Provider, or the result of cls(response) + :return: Provider or the result of cls(response) :rtype: ~azure.mgmt.resource.resources.v2017_05_10.models.Provider - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.Provider"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) - api_version = kwargs.pop('api_version', "2017-05-10") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2017-05-10")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[_models.Provider] - request = build_providers_unregister_request( resource_provider_namespace=resource_provider_namespace, subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.unregister.metadata['url'], + template_url=self.unregister.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) - deserialized = self._deserialize('Provider', pipeline_response) + deserialized = self._deserialize("Provider", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - unregister.metadata = {'url': "/subscriptions/{subscriptionId}/providers/{resourceProviderNamespace}/unregister"} # type: ignore - + unregister.metadata = {"url": "/subscriptions/{subscriptionId}/providers/{resourceProviderNamespace}/unregister"} # type: ignore @distributed_trace - def register( - self, - resource_provider_namespace: str, - **kwargs: Any - ) -> "_models.Provider": + def register(self, resource_provider_namespace: str, **kwargs: Any) -> _models.Provider: """Registers a subscription with a resource provider. :param resource_provider_namespace: The namespace of the resource provider to register. + Required. :type resource_provider_namespace: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: Provider, or the result of cls(response) + :return: Provider or the result of cls(response) :rtype: ~azure.mgmt.resource.resources.v2017_05_10.models.Provider - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.Provider"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) - api_version = kwargs.pop('api_version', "2017-05-10") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2017-05-10")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[_models.Provider] - request = build_providers_register_request( resource_provider_namespace=resource_provider_namespace, subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.register.metadata['url'], + template_url=self.register.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) - deserialized = self._deserialize('Provider', pipeline_response) + deserialized = self._deserialize("Provider", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - register.metadata = {'url': "/subscriptions/{subscriptionId}/providers/{resourceProviderNamespace}/register"} # type: ignore - + register.metadata = {"url": "/subscriptions/{subscriptionId}/providers/{resourceProviderNamespace}/register"} # type: ignore @distributed_trace def list( - self, - top: Optional[int] = None, - expand: Optional[str] = None, - **kwargs: Any - ) -> Iterable["_models.ProviderListResult"]: + self, top: Optional[int] = None, expand: Optional[str] = None, **kwargs: Any + ) -> Iterable["_models.Provider"]: """Gets all resource providers for a subscription. :param top: The number of results to return. If null is passed returns all deployments. Default @@ -2394,39 +2334,48 @@ def list( response, use $expand=resourceTypes/aliases. Default value is None. :type expand: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either ProviderListResult or the result of cls(response) + :return: An iterator like instance of either Provider or the result of cls(response) :rtype: - ~azure.core.paging.ItemPaged[~azure.mgmt.resource.resources.v2017_05_10.models.ProviderListResult] - :raises: ~azure.core.exceptions.HttpResponseError + ~azure.core.paging.ItemPaged[~azure.mgmt.resource.resources.v2017_05_10.models.Provider] + :raises ~azure.core.exceptions.HttpResponseError: """ - api_version = kwargs.pop('api_version', "2017-05-10") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2017-05-10")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[_models.ProviderListResult] - cls = kwargs.pop('cls', None) # type: ClsType["_models.ProviderListResult"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) + def prepare_request(next_link=None): if not next_link: - + request = build_providers_list_request( subscription_id=self._config.subscription_id, - api_version=api_version, top=top, expand=expand, - template_url=self.list.metadata['url'], + 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.url = self._client.format_url(request.url) # type: ignore else: - - request = build_providers_list_request( - subscription_id=self._config.subscription_id, - template_url=next_link, - ) + # make call to next link with the client's api-version + _parsed_next_link = urlparse(next_link) + _next_request_params = case_insensitive_dict(parse_qs(_parsed_next_link.query)) + _next_request_params["api-version"] = self._config.api_version + request = HttpRequest("GET", urljoin(next_link, _parsed_next_link.path), params=_next_request_params) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore request.method = "GET" return request @@ -2440,10 +2389,8 @@ def extract_data(pipeline_response): def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) response = pipeline_response.http_response @@ -2453,91 +2400,88 @@ def get_next(next_link=None): return pipeline_response + return ItemPaged(get_next, extract_data) - return ItemPaged( - get_next, extract_data - ) - list.metadata = {'url': "/subscriptions/{subscriptionId}/providers"} # type: ignore + list.metadata = {"url": "/subscriptions/{subscriptionId}/providers"} # type: ignore @distributed_trace - def get( - self, - resource_provider_namespace: str, - expand: Optional[str] = None, - **kwargs: Any - ) -> "_models.Provider": + def get(self, resource_provider_namespace: str, expand: Optional[str] = None, **kwargs: Any) -> _models.Provider: """Gets the specified resource provider. - :param resource_provider_namespace: The namespace of the resource provider. + :param resource_provider_namespace: The namespace of the resource provider. Required. :type resource_provider_namespace: str :param expand: The $expand query parameter. For example, to include property aliases in response, use $expand=resourceTypes/aliases. Default value is None. :type expand: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: Provider, or the result of cls(response) + :return: Provider or the result of cls(response) :rtype: ~azure.mgmt.resource.resources.v2017_05_10.models.Provider - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.Provider"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) - api_version = kwargs.pop('api_version', "2017-05-10") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2017-05-10")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[_models.Provider] - request = build_providers_get_request( resource_provider_namespace=resource_provider_namespace, subscription_id=self._config.subscription_id, - api_version=api_version, expand=expand, - template_url=self.get.metadata['url'], + api_version=api_version, + template_url=self.get.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) - deserialized = self._deserialize('Provider', pipeline_response) + deserialized = self._deserialize("Provider", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - get.metadata = {'url': "/subscriptions/{subscriptionId}/providers/{resourceProviderNamespace}"} # type: ignore + get.metadata = {"url": "/subscriptions/{subscriptionId}/providers/{resourceProviderNamespace}"} # type: ignore -class ResourcesOperations(object): # pylint: disable=too-many-public-methods - """ResourcesOperations operations. - You should not instantiate this class directly. Instead, you should create a Client instance that - instantiates it for you and attaches it as an attribute. +class ResourcesOperations: # pylint: disable=too-many-public-methods + """ + .. warning:: + **DO NOT** instantiate this class directly. - :ivar models: Alias to model classes used in this operation group. - :type models: ~azure.mgmt.resource.resources.v2017_05_10.models - :param client: Client for service requests. - :param config: Configuration of service client. - :param serializer: An object model serializer. - :param deserializer: An object model deserializer. + Instead, you should access the following operations through + :class:`~azure.mgmt.resource.resources.v2017_05_10.ResourceManagementClient`'s + :attr:`resources` attribute. """ models = _models - def __init__(self, client, config, serializer, deserializer): - self._client = client - self._serialize = serializer - self._deserialize = deserializer - self._config = config + def __init__(self, *args, **kwargs): + input_args = list(args) + self._client = input_args.pop(0) if input_args else kwargs.pop("client") + self._config = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") @distributed_trace def list_by_resource_group( @@ -2547,10 +2491,10 @@ def list_by_resource_group( expand: Optional[str] = None, top: Optional[int] = None, **kwargs: Any - ) -> Iterable["_models.ResourceListResult"]: + ) -> Iterable["_models.GenericResourceExpanded"]: """Get all the resources for a resource group. - :param resource_group_name: The resource group with the resources to get. + :param resource_group_name: The resource group with the resources to get. Required. :type resource_group_name: str :param filter: The filter to apply on the operation. Default value is None. :type filter: str @@ -2562,42 +2506,51 @@ def list_by_resource_group( value is None. :type top: int :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either ResourceListResult or the result of cls(response) + :return: An iterator like instance of either GenericResourceExpanded or the result of + cls(response) :rtype: - ~azure.core.paging.ItemPaged[~azure.mgmt.resource.resources.v2017_05_10.models.ResourceListResult] - :raises: ~azure.core.exceptions.HttpResponseError + ~azure.core.paging.ItemPaged[~azure.mgmt.resource.resources.v2017_05_10.models.GenericResourceExpanded] + :raises ~azure.core.exceptions.HttpResponseError: """ - api_version = kwargs.pop('api_version', "2017-05-10") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2017-05-10")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[_models.ResourceListResult] - cls = kwargs.pop('cls', None) # type: ClsType["_models.ResourceListResult"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) + def prepare_request(next_link=None): if not next_link: - + request = build_resources_list_by_resource_group_request( resource_group_name=resource_group_name, subscription_id=self._config.subscription_id, - api_version=api_version, filter=filter, expand=expand, top=top, - template_url=self.list_by_resource_group.metadata['url'], + 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.url = self._client.format_url(request.url) # type: ignore else: - - request = build_resources_list_by_resource_group_request( - resource_group_name=resource_group_name, - subscription_id=self._config.subscription_id, - template_url=next_link, - ) + # make call to next link with the client's api-version + _parsed_next_link = urlparse(next_link) + _next_request_params = case_insensitive_dict(parse_qs(_parsed_next_link.query)) + _next_request_params["api-version"] = self._config.api_version + request = HttpRequest("GET", urljoin(next_link, _parsed_next_link.path), params=_next_request_params) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore request.method = "GET" return request @@ -2611,10 +2564,8 @@ def extract_data(pipeline_response): def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) response = pipeline_response.http_response @@ -2624,45 +2575,54 @@ def get_next(next_link=None): return pipeline_response + return ItemPaged(get_next, extract_data) - return ItemPaged( - get_next, extract_data - ) - list_by_resource_group.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/resources"} # type: ignore + list_by_resource_group.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/resources"} # type: ignore def _move_resources_initial( # pylint: disable=inconsistent-return-statements - self, - source_resource_group_name: str, - parameters: "_models.ResourcesMoveInfo", - **kwargs: Any + self, source_resource_group_name: str, parameters: Union[_models.ResourcesMoveInfo, IO], **kwargs: Any ) -> None: - cls = kwargs.pop('cls', None) # type: ClsType[None] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) - api_version = kwargs.pop('api_version', "2017-05-10") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - _json = self._serialize.body(parameters, 'ResourcesMoveInfo') + api_version = kwargs.pop("api_version", _params.pop("api-version", "2017-05-10")) # type: str + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[None] - request = build_resources_move_resources_request_initial( + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(parameters, (IO, bytes)): + _content = parameters + else: + _json = self._serialize.body(parameters, "ResourcesMoveInfo") + + request = build_resources_move_resources_request( source_resource_group_name=source_resource_group_name, subscription_id=self._config.subscription_id, api_version=api_version, content_type=content_type, json=_json, - template_url=self._move_resources_initial.metadata['url'], + content=_content, + template_url=self._move_resources_initial.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [202, 204]: @@ -2672,14 +2632,15 @@ def _move_resources_initial( # pylint: disable=inconsistent-return-statements if cls: return cls(pipeline_response, None, {}) - _move_resources_initial.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{sourceResourceGroupName}/moveResources"} # type: ignore + _move_resources_initial.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{sourceResourceGroupName}/moveResources"} # type: ignore - - @distributed_trace - def begin_move_resources( # pylint: disable=inconsistent-return-statements + @overload + def begin_move_resources( self, source_resource_group_name: str, - parameters: "_models.ResourcesMoveInfo", + parameters: _models.ResourcesMoveInfo, + *, + content_type: str = "application/json", **kwargs: Any ) -> LROPoller[None]: """Moves resources from one resource group to another resource group. @@ -2690,10 +2651,13 @@ def begin_move_resources( # pylint: disable=inconsistent-return-statements the groups until the move completes. :param source_resource_group_name: The name of the resource group containing the resources to - move. + move. Required. :type source_resource_group_name: str - :param parameters: Parameters for moving resources. + :param parameters: Parameters for moving resources. Required. :type parameters: ~azure.mgmt.resource.resources.v2017_05_10.models.ResourcesMoveInfo + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str :keyword callable cls: A custom type or function that will be passed the direct response :keyword str continuation_token: A continuation token to restart a poller from a saved state. :keyword polling: By default, your polling method will be ARMPolling. Pass in False for this @@ -2704,80 +2668,160 @@ def begin_move_resources( # pylint: disable=inconsistent-return-statements Retry-After header is present. :return: An instance of LROPoller that returns either None or the result of cls(response) :rtype: ~azure.core.polling.LROPoller[None] - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - api_version = kwargs.pop('api_version', "2017-05-10") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] - polling = kwargs.pop('polling', True) # type: Union[bool, PollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType[None] - lro_delay = kwargs.pop( - 'polling_interval', - self._config.polling_interval - ) - cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] + + @overload + def begin_move_resources( + self, source_resource_group_name: str, parameters: IO, *, content_type: str = "application/json", **kwargs: Any + ) -> LROPoller[None]: + """Moves resources from one resource group to another resource group. + + The resources to move must be in the same source resource group. The target resource group may + be in a different subscription. When moving resources, both the source group and the target + group are locked for the duration of the operation. Write and delete operations are blocked on + the groups until the move completes. + + :param source_resource_group_name: The name of the resource group containing the resources to + move. Required. + :type source_resource_group_name: str + :param parameters: Parameters for moving resources. Required. + :type parameters: IO + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be ARMPolling. Pass in False for this + operation to not poll, or pass in your own initialized polling object for a personal polling + strategy. + :paramtype polling: bool or ~azure.core.polling.PollingMethod + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of LROPoller that returns either None or the result of cls(response) + :rtype: ~azure.core.polling.LROPoller[None] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace + def begin_move_resources( + self, source_resource_group_name: str, parameters: Union[_models.ResourcesMoveInfo, IO], **kwargs: Any + ) -> LROPoller[None]: + """Moves resources from one resource group to another resource group. + + The resources to move must be in the same source resource group. The target resource group may + be in a different subscription. When moving resources, both the source group and the target + group are locked for the duration of the operation. Write and delete operations are blocked on + the groups until the move completes. + + :param source_resource_group_name: The name of the resource group containing the resources to + move. Required. + :type source_resource_group_name: str + :param parameters: Parameters for moving resources. Is either a model type or a IO type. + Required. + :type parameters: ~azure.mgmt.resource.resources.v2017_05_10.models.ResourcesMoveInfo or IO + :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. + Default value is None. + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be ARMPolling. Pass in False for this + operation to not poll, or pass in your own initialized polling object for a personal polling + strategy. + :paramtype polling: bool or ~azure.core.polling.PollingMethod + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of LROPoller that returns either None or the result of cls(response) + :rtype: ~azure.core.polling.LROPoller[None] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _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", "2017-05-10")) # type: str + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[None] + polling = kwargs.pop("polling", True) # type: Union[bool, PollingMethod] + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token = kwargs.pop("continuation_token", None) # type: Optional[str] if cont_token is None: - raw_result = self._move_resources_initial( + raw_result = self._move_resources_initial( # type: ignore source_resource_group_name=source_resource_group_name, parameters=parameters, api_version=api_version, content_type=content_type, - cls=lambda x,y,z: x, + cls=lambda x, y, z: x, + headers=_headers, + params=_params, **kwargs ) - kwargs.pop('error_map', None) + kwargs.pop("error_map", None) - def get_long_running_output(pipeline_response): + def get_long_running_output(pipeline_response): # pylint: disable=inconsistent-return-statements if cls: return cls(pipeline_response, None, {}) - - if polling is True: polling_method = ARMPolling(lro_delay, **kwargs) - elif polling is False: polling_method = NoPolling() - else: polling_method = polling + if polling is True: + polling_method = cast(PollingMethod, ARMPolling(lro_delay, **kwargs)) # type: PollingMethod + elif polling is False: + polling_method = cast(PollingMethod, NoPolling()) + else: + polling_method = polling if cont_token: return LROPoller.from_continuation_token( polling_method=polling_method, continuation_token=cont_token, client=self._client, - deserialization_callback=get_long_running_output + deserialization_callback=get_long_running_output, ) return LROPoller(self._client, raw_result, get_long_running_output, polling_method) - begin_move_resources.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{sourceResourceGroupName}/moveResources"} # type: ignore + begin_move_resources.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{sourceResourceGroupName}/moveResources"} # type: ignore def _validate_move_resources_initial( # pylint: disable=inconsistent-return-statements - self, - source_resource_group_name: str, - parameters: "_models.ResourcesMoveInfo", - **kwargs: Any + self, source_resource_group_name: str, parameters: Union[_models.ResourcesMoveInfo, IO], **kwargs: Any ) -> None: - cls = kwargs.pop('cls', None) # type: ClsType[None] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) - api_version = kwargs.pop('api_version', "2017-05-10") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - _json = self._serialize.body(parameters, 'ResourcesMoveInfo') + api_version = kwargs.pop("api_version", _params.pop("api-version", "2017-05-10")) # type: str + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[None] - request = build_resources_validate_move_resources_request_initial( + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(parameters, (IO, bytes)): + _content = parameters + else: + _json = self._serialize.body(parameters, "ResourcesMoveInfo") + + request = build_resources_validate_move_resources_request( source_resource_group_name=source_resource_group_name, subscription_id=self._config.subscription_id, api_version=api_version, content_type=content_type, json=_json, - template_url=self._validate_move_resources_initial.metadata['url'], + content=_content, + template_url=self._validate_move_resources_initial.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [202, 204, 409]: @@ -2787,14 +2831,15 @@ def _validate_move_resources_initial( # pylint: disable=inconsistent-return-sta if cls: return cls(pipeline_response, None, {}) - _validate_move_resources_initial.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{sourceResourceGroupName}/validateMoveResources"} # type: ignore + _validate_move_resources_initial.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{sourceResourceGroupName}/validateMoveResources"} # type: ignore - - @distributed_trace - def begin_validate_move_resources( # pylint: disable=inconsistent-return-statements + @overload + def begin_validate_move_resources( self, source_resource_group_name: str, - parameters: "_models.ResourcesMoveInfo", + parameters: _models.ResourcesMoveInfo, + *, + content_type: str = "application/json", **kwargs: Any ) -> LROPoller[None]: """Validates whether resources can be moved from one resource group to another resource group. @@ -2807,10 +2852,13 @@ def begin_validate_move_resources( # pylint: disable=inconsistent-return-statem operation. :param source_resource_group_name: The name of the resource group containing the resources to - validate for move. + validate for move. Required. :type source_resource_group_name: str - :param parameters: Parameters for moving resources. + :param parameters: Parameters for moving resources. Required. :type parameters: ~azure.mgmt.resource.resources.v2017_05_10.models.ResourcesMoveInfo + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str :keyword callable cls: A custom type or function that will be passed the direct response :keyword str continuation_token: A continuation token to restart a poller from a saved state. :keyword polling: By default, your polling method will be ARMPolling. Pass in False for this @@ -2821,55 +2869,124 @@ def begin_validate_move_resources( # pylint: disable=inconsistent-return-statem Retry-After header is present. :return: An instance of LROPoller that returns either None or the result of cls(response) :rtype: ~azure.core.polling.LROPoller[None] - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - api_version = kwargs.pop('api_version', "2017-05-10") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] - polling = kwargs.pop('polling', True) # type: Union[bool, PollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType[None] - lro_delay = kwargs.pop( - 'polling_interval', - self._config.polling_interval - ) - cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] + + @overload + def begin_validate_move_resources( + self, source_resource_group_name: str, parameters: IO, *, content_type: str = "application/json", **kwargs: Any + ) -> LROPoller[None]: + """Validates whether resources can be moved from one resource group to another resource group. + + This operation checks whether the specified resources can be moved to the target. The resources + to move must be in the same source resource group. The target resource group may be in a + different subscription. If validation succeeds, it returns HTTP response code 204 (no content). + If validation fails, it returns HTTP response code 409 (Conflict) with an error message. + Retrieve the URL in the Location header value to check the result of the long-running + operation. + + :param source_resource_group_name: The name of the resource group containing the resources to + validate for move. Required. + :type source_resource_group_name: str + :param parameters: Parameters for moving resources. Required. + :type parameters: IO + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be ARMPolling. Pass in False for this + operation to not poll, or pass in your own initialized polling object for a personal polling + strategy. + :paramtype polling: bool or ~azure.core.polling.PollingMethod + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of LROPoller that returns either None or the result of cls(response) + :rtype: ~azure.core.polling.LROPoller[None] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace + def begin_validate_move_resources( + self, source_resource_group_name: str, parameters: Union[_models.ResourcesMoveInfo, IO], **kwargs: Any + ) -> LROPoller[None]: + """Validates whether resources can be moved from one resource group to another resource group. + + This operation checks whether the specified resources can be moved to the target. The resources + to move must be in the same source resource group. The target resource group may be in a + different subscription. If validation succeeds, it returns HTTP response code 204 (no content). + If validation fails, it returns HTTP response code 409 (Conflict) with an error message. + Retrieve the URL in the Location header value to check the result of the long-running + operation. + + :param source_resource_group_name: The name of the resource group containing the resources to + validate for move. Required. + :type source_resource_group_name: str + :param parameters: Parameters for moving resources. Is either a model type or a IO type. + Required. + :type parameters: ~azure.mgmt.resource.resources.v2017_05_10.models.ResourcesMoveInfo or IO + :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. + Default value is None. + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be ARMPolling. Pass in False for this + operation to not poll, or pass in your own initialized polling object for a personal polling + strategy. + :paramtype polling: bool or ~azure.core.polling.PollingMethod + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of LROPoller that returns either None or the result of cls(response) + :rtype: ~azure.core.polling.LROPoller[None] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _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", "2017-05-10")) # type: str + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[None] + polling = kwargs.pop("polling", True) # type: Union[bool, PollingMethod] + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token = kwargs.pop("continuation_token", None) # type: Optional[str] if cont_token is None: - raw_result = self._validate_move_resources_initial( + raw_result = self._validate_move_resources_initial( # type: ignore source_resource_group_name=source_resource_group_name, parameters=parameters, api_version=api_version, content_type=content_type, - cls=lambda x,y,z: x, + cls=lambda x, y, z: x, + headers=_headers, + params=_params, **kwargs ) - kwargs.pop('error_map', None) + kwargs.pop("error_map", None) - def get_long_running_output(pipeline_response): + def get_long_running_output(pipeline_response): # pylint: disable=inconsistent-return-statements if cls: return cls(pipeline_response, None, {}) - - if polling is True: polling_method = ARMPolling(lro_delay, **kwargs) - elif polling is False: polling_method = NoPolling() - else: polling_method = polling + if polling is True: + polling_method = cast(PollingMethod, ARMPolling(lro_delay, **kwargs)) # type: PollingMethod + elif polling is False: + polling_method = cast(PollingMethod, NoPolling()) + else: + polling_method = polling if cont_token: return LROPoller.from_continuation_token( polling_method=polling_method, continuation_token=cont_token, client=self._client, - deserialization_callback=get_long_running_output + deserialization_callback=get_long_running_output, ) return LROPoller(self._client, raw_result, get_long_running_output, polling_method) - begin_validate_move_resources.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{sourceResourceGroupName}/validateMoveResources"} # type: ignore + begin_validate_move_resources.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{sourceResourceGroupName}/validateMoveResources"} # type: ignore @distributed_trace def list( - self, - filter: Optional[str] = None, - expand: Optional[str] = None, - top: Optional[int] = None, - **kwargs: Any - ) -> Iterable["_models.ResourceListResult"]: + self, filter: Optional[str] = None, expand: Optional[str] = None, top: Optional[int] = None, **kwargs: Any + ) -> Iterable["_models.GenericResourceExpanded"]: """Get all the resources in a subscription. :param filter: The filter to apply on the operation. Default value is None. @@ -2882,40 +2999,50 @@ def list( value is None. :type top: int :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either ResourceListResult or the result of cls(response) + :return: An iterator like instance of either GenericResourceExpanded or the result of + cls(response) :rtype: - ~azure.core.paging.ItemPaged[~azure.mgmt.resource.resources.v2017_05_10.models.ResourceListResult] - :raises: ~azure.core.exceptions.HttpResponseError + ~azure.core.paging.ItemPaged[~azure.mgmt.resource.resources.v2017_05_10.models.GenericResourceExpanded] + :raises ~azure.core.exceptions.HttpResponseError: """ - api_version = kwargs.pop('api_version', "2017-05-10") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2017-05-10")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[_models.ResourceListResult] - cls = kwargs.pop('cls', None) # type: ClsType["_models.ResourceListResult"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) + def prepare_request(next_link=None): if not next_link: - + request = build_resources_list_request( subscription_id=self._config.subscription_id, - api_version=api_version, filter=filter, expand=expand, top=top, - template_url=self.list.metadata['url'], + 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.url = self._client.format_url(request.url) # type: ignore else: - - request = build_resources_list_request( - subscription_id=self._config.subscription_id, - template_url=next_link, - ) + # make call to next link with the client's api-version + _parsed_next_link = urlparse(next_link) + _next_request_params = case_insensitive_dict(parse_qs(_parsed_next_link.query)) + _next_request_params["api-version"] = self._config.api_version + request = HttpRequest("GET", urljoin(next_link, _parsed_next_link.path), params=_next_request_params) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore request.method = "GET" return request @@ -2929,10 +3056,8 @@ def extract_data(pipeline_response): def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) response = pipeline_response.http_response @@ -2942,11 +3067,9 @@ def get_next(next_link=None): return pipeline_response + return ItemPaged(get_next, extract_data) - return ItemPaged( - get_next, extract_data - ) - list.metadata = {'url': "/subscriptions/{subscriptionId}/resources"} # type: ignore + list.metadata = {"url": "/subscriptions/{subscriptionId}/resources"} # type: ignore @distributed_trace def check_existence( @@ -2962,30 +3085,36 @@ def check_existence( """Checks whether a resource exists. :param resource_group_name: The name of the resource group containing the resource to check. - The name is case insensitive. + The name is case insensitive. Required. :type resource_group_name: str - :param resource_provider_namespace: The resource provider of the resource to check. + :param resource_provider_namespace: The resource provider of the resource to check. Required. :type resource_provider_namespace: str - :param parent_resource_path: The parent resource identity. + :param parent_resource_path: The parent resource identity. Required. :type parent_resource_path: str - :param resource_type: The resource type. + :param resource_type: The resource type. Required. :type resource_type: str - :param resource_name: The name of the resource to check whether it exists. + :param resource_name: The name of the resource to check whether it exists. Required. :type resource_name: str - :param api_version: The API version to use for the operation. + :param api_version: The API version to use for the operation. Required. :type api_version: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: bool, or the result of cls(response) + :return: bool or the result of cls(response) :rtype: bool - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType[None] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = kwargs.pop("params", {}) or {} + + cls = kwargs.pop("cls", None) # type: ClsType[None] - request = build_resources_check_existence_request( resource_group_name=resource_group_name, resource_provider_namespace=resource_provider_namespace, @@ -2994,16 +3123,17 @@ def check_existence( resource_name=resource_name, subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.check_existence.metadata['url'], + template_url=self.check_existence.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [204, 404]: @@ -3014,8 +3144,7 @@ def check_existence( return cls(pipeline_response, None, {}) return 200 <= response.status_code <= 299 - check_existence.metadata = {'url': "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{parentResourcePath}/{resourceType}/{resourceName}"} # type: ignore - + check_existence.metadata = {"url": "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{parentResourcePath}/{resourceType}/{resourceName}"} # type: ignore def _delete_initial( # pylint: disable=inconsistent-return-statements self, @@ -3027,14 +3156,20 @@ def _delete_initial( # pylint: disable=inconsistent-return-statements api_version: str, **kwargs: Any ) -> None: - cls = kwargs.pop('cls', None) # type: ClsType[None] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = kwargs.pop("params", {}) or {} - - request = build_resources_delete_request_initial( + cls = kwargs.pop("cls", None) # type: ClsType[None] + + request = build_resources_delete_request( resource_group_name=resource_group_name, resource_provider_namespace=resource_provider_namespace, parent_resource_path=parent_resource_path, @@ -3042,16 +3177,17 @@ def _delete_initial( # pylint: disable=inconsistent-return-statements resource_name=resource_name, subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self._delete_initial.metadata['url'], + template_url=self._delete_initial.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200, 202, 204]: @@ -3061,11 +3197,10 @@ def _delete_initial( # pylint: disable=inconsistent-return-statements if cls: return cls(pipeline_response, None, {}) - _delete_initial.metadata = {'url': "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{parentResourcePath}/{resourceType}/{resourceName}"} # type: ignore - + _delete_initial.metadata = {"url": "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{parentResourcePath}/{resourceType}/{resourceName}"} # type: ignore @distributed_trace - def begin_delete( # pylint: disable=inconsistent-return-statements + def begin_delete( self, resource_group_name: str, resource_provider_namespace: str, @@ -3078,17 +3213,17 @@ def begin_delete( # pylint: disable=inconsistent-return-statements """Deletes a resource. :param resource_group_name: The name of the resource group that contains the resource to - delete. The name is case insensitive. + delete. The name is case insensitive. Required. :type resource_group_name: str - :param resource_provider_namespace: The namespace of the resource provider. + :param resource_provider_namespace: The namespace of the resource provider. Required. :type resource_provider_namespace: str - :param parent_resource_path: The parent resource identity. + :param parent_resource_path: The parent resource identity. Required. :type parent_resource_path: str - :param resource_type: The resource type. + :param resource_type: The resource type. Required. :type resource_type: str - :param resource_name: The name of the resource to delete. + :param resource_name: The name of the resource to delete. Required. :type resource_name: str - :param api_version: The API version to use for the operation. + :param api_version: The API version to use for the operation. Required. :type api_version: str :keyword callable cls: A custom type or function that will be passed the direct response :keyword str continuation_token: A continuation token to restart a poller from a saved state. @@ -3100,46 +3235,50 @@ def begin_delete( # pylint: disable=inconsistent-return-statements Retry-After header is present. :return: An instance of LROPoller that returns either None or the result of cls(response) :rtype: ~azure.core.polling.LROPoller[None] - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - polling = kwargs.pop('polling', True) # type: Union[bool, PollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType[None] - lro_delay = kwargs.pop( - 'polling_interval', - self._config.polling_interval - ) - cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] + _headers = kwargs.pop("headers", {}) or {} + _params = kwargs.pop("params", {}) or {} + + cls = kwargs.pop("cls", None) # type: ClsType[None] + polling = kwargs.pop("polling", True) # type: Union[bool, PollingMethod] + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token = kwargs.pop("continuation_token", None) # type: Optional[str] if cont_token is None: - raw_result = self._delete_initial( + raw_result = self._delete_initial( # type: ignore resource_group_name=resource_group_name, resource_provider_namespace=resource_provider_namespace, parent_resource_path=parent_resource_path, resource_type=resource_type, resource_name=resource_name, api_version=api_version, - cls=lambda x,y,z: x, + cls=lambda x, y, z: x, + headers=_headers, + params=_params, **kwargs ) - kwargs.pop('error_map', None) + kwargs.pop("error_map", None) - def get_long_running_output(pipeline_response): + def get_long_running_output(pipeline_response): # pylint: disable=inconsistent-return-statements if cls: return cls(pipeline_response, None, {}) - - if polling is True: polling_method = ARMPolling(lro_delay, **kwargs) - elif polling is False: polling_method = NoPolling() - else: polling_method = polling + if polling is True: + polling_method = cast(PollingMethod, ARMPolling(lro_delay, **kwargs)) # type: PollingMethod + elif polling is False: + polling_method = cast(PollingMethod, NoPolling()) + else: + polling_method = polling if cont_token: return LROPoller.from_continuation_token( polling_method=polling_method, continuation_token=cont_token, client=self._client, - deserialization_callback=get_long_running_output + deserialization_callback=get_long_running_output, ) return LROPoller(self._client, raw_result, get_long_running_output, polling_method) - begin_delete.metadata = {'url': "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{parentResourcePath}/{resourceType}/{resourceName}"} # type: ignore + begin_delete.metadata = {"url": "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{parentResourcePath}/{resourceType}/{resourceName}"} # type: ignore def _create_or_update_initial( self, @@ -3149,39 +3288,53 @@ def _create_or_update_initial( resource_type: str, resource_name: str, api_version: str, - parameters: "_models.GenericResource", + parameters: Union[_models.GenericResource, IO], **kwargs: Any - ) -> Optional["_models.GenericResource"]: - cls = kwargs.pop('cls', None) # type: ClsType[Optional["_models.GenericResource"]] + ) -> Optional[_models.GenericResource]: error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = kwargs.pop("params", {}) or {} - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[Optional[_models.GenericResource]] - _json = self._serialize.body(parameters, 'GenericResource') + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(parameters, (IO, bytes)): + _content = parameters + else: + _json = self._serialize.body(parameters, "GenericResource") - request = build_resources_create_or_update_request_initial( + request = build_resources_create_or_update_request( resource_group_name=resource_group_name, resource_provider_namespace=resource_provider_namespace, parent_resource_path=parent_resource_path, resource_type=resource_type, resource_name=resource_name, subscription_id=self._config.subscription_id, - content_type=content_type, api_version=api_version, + content_type=content_type, json=_json, - template_url=self._create_or_update_initial.metadata['url'], + content=_content, + template_url=self._create_or_update_initial.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200, 201, 202]: @@ -3190,18 +3343,115 @@ def _create_or_update_initial( deserialized = None if response.status_code == 200: - deserialized = self._deserialize('GenericResource', pipeline_response) + deserialized = self._deserialize("GenericResource", pipeline_response) if response.status_code == 201: - deserialized = self._deserialize('GenericResource', pipeline_response) + deserialized = self._deserialize("GenericResource", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - _create_or_update_initial.metadata = {'url': "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{parentResourcePath}/{resourceType}/{resourceName}"} # type: ignore + _create_or_update_initial.metadata = {"url": "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{parentResourcePath}/{resourceType}/{resourceName}"} # type: ignore + + @overload + def begin_create_or_update( + self, + resource_group_name: str, + resource_provider_namespace: str, + parent_resource_path: str, + resource_type: str, + resource_name: str, + api_version: str, + parameters: _models.GenericResource, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> LROPoller[_models.GenericResource]: + """Creates a resource. + + :param resource_group_name: The name of the resource group for the resource. The name is case + insensitive. Required. + :type resource_group_name: str + :param resource_provider_namespace: The namespace of the resource provider. Required. + :type resource_provider_namespace: str + :param parent_resource_path: The parent resource identity. Required. + :type parent_resource_path: str + :param resource_type: The resource type of the resource to create. Required. + :type resource_type: str + :param resource_name: The name of the resource to create. Required. + :type resource_name: str + :param api_version: The API version to use for the operation. Required. + :type api_version: str + :param parameters: Parameters for creating or updating the resource. Required. + :type parameters: ~azure.mgmt.resource.resources.v2017_05_10.models.GenericResource + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be ARMPolling. Pass in False for this + operation to not poll, or pass in your own initialized polling object for a personal polling + strategy. + :paramtype polling: bool or ~azure.core.polling.PollingMethod + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of LROPoller that returns either GenericResource or the result of + cls(response) + :rtype: + ~azure.core.polling.LROPoller[~azure.mgmt.resource.resources.v2017_05_10.models.GenericResource] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + def begin_create_or_update( + self, + resource_group_name: str, + resource_provider_namespace: str, + parent_resource_path: str, + resource_type: str, + resource_name: str, + api_version: str, + parameters: IO, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> LROPoller[_models.GenericResource]: + """Creates a resource. + :param resource_group_name: The name of the resource group for the resource. The name is case + insensitive. Required. + :type resource_group_name: str + :param resource_provider_namespace: The namespace of the resource provider. Required. + :type resource_provider_namespace: str + :param parent_resource_path: The parent resource identity. Required. + :type parent_resource_path: str + :param resource_type: The resource type of the resource to create. Required. + :type resource_type: str + :param resource_name: The name of the resource to create. Required. + :type resource_name: str + :param api_version: The API version to use for the operation. Required. + :type api_version: str + :param parameters: Parameters for creating or updating the resource. Required. + :type parameters: IO + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be ARMPolling. Pass in False for this + operation to not poll, or pass in your own initialized polling object for a personal polling + strategy. + :paramtype polling: bool or ~azure.core.polling.PollingMethod + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of LROPoller that returns either GenericResource or the result of + cls(response) + :rtype: + ~azure.core.polling.LROPoller[~azure.mgmt.resource.resources.v2017_05_10.models.GenericResource] + :raises ~azure.core.exceptions.HttpResponseError: + """ @distributed_trace def begin_create_or_update( @@ -3212,26 +3462,30 @@ def begin_create_or_update( resource_type: str, resource_name: str, api_version: str, - parameters: "_models.GenericResource", + parameters: Union[_models.GenericResource, IO], **kwargs: Any - ) -> LROPoller["_models.GenericResource"]: + ) -> LROPoller[_models.GenericResource]: """Creates a resource. :param resource_group_name: The name of the resource group for the resource. The name is case - insensitive. + insensitive. Required. :type resource_group_name: str - :param resource_provider_namespace: The namespace of the resource provider. + :param resource_provider_namespace: The namespace of the resource provider. Required. :type resource_provider_namespace: str - :param parent_resource_path: The parent resource identity. + :param parent_resource_path: The parent resource identity. Required. :type parent_resource_path: str - :param resource_type: The resource type of the resource to create. + :param resource_type: The resource type of the resource to create. Required. :type resource_type: str - :param resource_name: The name of the resource to create. + :param resource_name: The name of the resource to create. Required. :type resource_name: str - :param api_version: The API version to use for the operation. + :param api_version: The API version to use for the operation. Required. :type api_version: str - :param parameters: Parameters for creating or updating the resource. - :type parameters: ~azure.mgmt.resource.resources.v2017_05_10.models.GenericResource + :param parameters: Parameters for creating or updating the resource. Is either a model type or + a IO type. Required. + :type parameters: ~azure.mgmt.resource.resources.v2017_05_10.models.GenericResource or IO + :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. + Default value is None. + :paramtype content_type: str :keyword callable cls: A custom type or function that will be passed the direct response :keyword str continuation_token: A continuation token to restart a poller from a saved state. :keyword polling: By default, your polling method will be ARMPolling. Pass in False for this @@ -3244,18 +3498,18 @@ def begin_create_or_update( cls(response) :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.resource.resources.v2017_05_10.models.GenericResource] - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] - polling = kwargs.pop('polling', True) # type: Union[bool, PollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType["_models.GenericResource"] - lro_delay = kwargs.pop( - 'polling_interval', - self._config.polling_interval - ) - cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = kwargs.pop("params", {}) or {} + + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.GenericResource] + polling = kwargs.pop("polling", True) # type: Union[bool, PollingMethod] + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token = kwargs.pop("continuation_token", None) # type: Optional[str] if cont_token is None: - raw_result = self._create_or_update_initial( + raw_result = self._create_or_update_initial( # type: ignore resource_group_name=resource_group_name, resource_provider_namespace=resource_provider_namespace, parent_resource_path=parent_resource_path, @@ -3264,32 +3518,35 @@ def begin_create_or_update( api_version=api_version, parameters=parameters, content_type=content_type, - cls=lambda x,y,z: x, + cls=lambda x, y, z: x, + headers=_headers, + params=_params, **kwargs ) - kwargs.pop('error_map', None) + kwargs.pop("error_map", None) def get_long_running_output(pipeline_response): - response = pipeline_response.http_response - deserialized = self._deserialize('GenericResource', pipeline_response) + deserialized = self._deserialize("GenericResource", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - - if polling is True: polling_method = ARMPolling(lro_delay, **kwargs) - elif polling is False: polling_method = NoPolling() - else: polling_method = polling + if polling is True: + polling_method = cast(PollingMethod, ARMPolling(lro_delay, **kwargs)) # type: PollingMethod + elif polling is False: + polling_method = cast(PollingMethod, NoPolling()) + else: + polling_method = polling if cont_token: return LROPoller.from_continuation_token( polling_method=polling_method, continuation_token=cont_token, client=self._client, - deserialization_callback=get_long_running_output + deserialization_callback=get_long_running_output, ) return LROPoller(self._client, raw_result, get_long_running_output, polling_method) - begin_create_or_update.metadata = {'url': "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{parentResourcePath}/{resourceType}/{resourceName}"} # type: ignore + begin_create_or_update.metadata = {"url": "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{parentResourcePath}/{resourceType}/{resourceName}"} # type: ignore def _update_initial( self, @@ -3299,39 +3556,53 @@ def _update_initial( resource_type: str, resource_name: str, api_version: str, - parameters: "_models.GenericResource", + parameters: Union[_models.GenericResource, IO], **kwargs: Any - ) -> Optional["_models.GenericResource"]: - cls = kwargs.pop('cls', None) # type: ClsType[Optional["_models.GenericResource"]] + ) -> Optional[_models.GenericResource]: error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = kwargs.pop("params", {}) or {} - _json = self._serialize.body(parameters, 'GenericResource') + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[Optional[_models.GenericResource]] - request = build_resources_update_request_initial( + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(parameters, (IO, bytes)): + _content = parameters + else: + _json = self._serialize.body(parameters, "GenericResource") + + request = build_resources_update_request( resource_group_name=resource_group_name, resource_provider_namespace=resource_provider_namespace, parent_resource_path=parent_resource_path, resource_type=resource_type, resource_name=resource_name, subscription_id=self._config.subscription_id, - content_type=content_type, api_version=api_version, + content_type=content_type, json=_json, - template_url=self._update_initial.metadata['url'], + content=_content, + template_url=self._update_initial.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200, 202]: @@ -3340,15 +3611,112 @@ def _update_initial( deserialized = None if response.status_code == 200: - deserialized = self._deserialize('GenericResource', pipeline_response) + deserialized = self._deserialize("GenericResource", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - _update_initial.metadata = {'url': "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{parentResourcePath}/{resourceType}/{resourceName}"} # type: ignore + _update_initial.metadata = {"url": "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{parentResourcePath}/{resourceType}/{resourceName}"} # type: ignore + + @overload + def begin_update( + self, + resource_group_name: str, + resource_provider_namespace: str, + parent_resource_path: str, + resource_type: str, + resource_name: str, + api_version: str, + parameters: _models.GenericResource, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> LROPoller[_models.GenericResource]: + """Updates a resource. + :param resource_group_name: The name of the resource group for the resource. The name is case + insensitive. Required. + :type resource_group_name: str + :param resource_provider_namespace: The namespace of the resource provider. Required. + :type resource_provider_namespace: str + :param parent_resource_path: The parent resource identity. Required. + :type parent_resource_path: str + :param resource_type: The resource type of the resource to update. Required. + :type resource_type: str + :param resource_name: The name of the resource to update. Required. + :type resource_name: str + :param api_version: The API version to use for the operation. Required. + :type api_version: str + :param parameters: Parameters for updating the resource. Required. + :type parameters: ~azure.mgmt.resource.resources.v2017_05_10.models.GenericResource + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be ARMPolling. Pass in False for this + operation to not poll, or pass in your own initialized polling object for a personal polling + strategy. + :paramtype polling: bool or ~azure.core.polling.PollingMethod + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of LROPoller that returns either GenericResource or the result of + cls(response) + :rtype: + ~azure.core.polling.LROPoller[~azure.mgmt.resource.resources.v2017_05_10.models.GenericResource] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + def begin_update( + self, + resource_group_name: str, + resource_provider_namespace: str, + parent_resource_path: str, + resource_type: str, + resource_name: str, + api_version: str, + parameters: IO, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> LROPoller[_models.GenericResource]: + """Updates a resource. + + :param resource_group_name: The name of the resource group for the resource. The name is case + insensitive. Required. + :type resource_group_name: str + :param resource_provider_namespace: The namespace of the resource provider. Required. + :type resource_provider_namespace: str + :param parent_resource_path: The parent resource identity. Required. + :type parent_resource_path: str + :param resource_type: The resource type of the resource to update. Required. + :type resource_type: str + :param resource_name: The name of the resource to update. Required. + :type resource_name: str + :param api_version: The API version to use for the operation. Required. + :type api_version: str + :param parameters: Parameters for updating the resource. Required. + :type parameters: IO + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be ARMPolling. Pass in False for this + operation to not poll, or pass in your own initialized polling object for a personal polling + strategy. + :paramtype polling: bool or ~azure.core.polling.PollingMethod + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of LROPoller that returns either GenericResource or the result of + cls(response) + :rtype: + ~azure.core.polling.LROPoller[~azure.mgmt.resource.resources.v2017_05_10.models.GenericResource] + :raises ~azure.core.exceptions.HttpResponseError: + """ @distributed_trace def begin_update( @@ -3359,26 +3727,30 @@ def begin_update( resource_type: str, resource_name: str, api_version: str, - parameters: "_models.GenericResource", + parameters: Union[_models.GenericResource, IO], **kwargs: Any - ) -> LROPoller["_models.GenericResource"]: + ) -> LROPoller[_models.GenericResource]: """Updates a resource. :param resource_group_name: The name of the resource group for the resource. The name is case - insensitive. + insensitive. Required. :type resource_group_name: str - :param resource_provider_namespace: The namespace of the resource provider. + :param resource_provider_namespace: The namespace of the resource provider. Required. :type resource_provider_namespace: str - :param parent_resource_path: The parent resource identity. + :param parent_resource_path: The parent resource identity. Required. :type parent_resource_path: str - :param resource_type: The resource type of the resource to update. + :param resource_type: The resource type of the resource to update. Required. :type resource_type: str - :param resource_name: The name of the resource to update. + :param resource_name: The name of the resource to update. Required. :type resource_name: str - :param api_version: The API version to use for the operation. + :param api_version: The API version to use for the operation. Required. :type api_version: str - :param parameters: Parameters for updating the resource. - :type parameters: ~azure.mgmt.resource.resources.v2017_05_10.models.GenericResource + :param parameters: Parameters for updating the resource. Is either a model type or a IO type. + Required. + :type parameters: ~azure.mgmt.resource.resources.v2017_05_10.models.GenericResource or IO + :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. + Default value is None. + :paramtype content_type: str :keyword callable cls: A custom type or function that will be passed the direct response :keyword str continuation_token: A continuation token to restart a poller from a saved state. :keyword polling: By default, your polling method will be ARMPolling. Pass in False for this @@ -3391,18 +3763,18 @@ def begin_update( cls(response) :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.resource.resources.v2017_05_10.models.GenericResource] - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] - polling = kwargs.pop('polling', True) # type: Union[bool, PollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType["_models.GenericResource"] - lro_delay = kwargs.pop( - 'polling_interval', - self._config.polling_interval - ) - cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = kwargs.pop("params", {}) or {} + + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.GenericResource] + polling = kwargs.pop("polling", True) # type: Union[bool, PollingMethod] + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token = kwargs.pop("continuation_token", None) # type: Optional[str] if cont_token is None: - raw_result = self._update_initial( + raw_result = self._update_initial( # type: ignore resource_group_name=resource_group_name, resource_provider_namespace=resource_provider_namespace, parent_resource_path=parent_resource_path, @@ -3411,32 +3783,35 @@ def begin_update( api_version=api_version, parameters=parameters, content_type=content_type, - cls=lambda x,y,z: x, + cls=lambda x, y, z: x, + headers=_headers, + params=_params, **kwargs ) - kwargs.pop('error_map', None) + kwargs.pop("error_map", None) def get_long_running_output(pipeline_response): - response = pipeline_response.http_response - deserialized = self._deserialize('GenericResource', pipeline_response) + deserialized = self._deserialize("GenericResource", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - - if polling is True: polling_method = ARMPolling(lro_delay, **kwargs) - elif polling is False: polling_method = NoPolling() - else: polling_method = polling + if polling is True: + polling_method = cast(PollingMethod, ARMPolling(lro_delay, **kwargs)) # type: PollingMethod + elif polling is False: + polling_method = cast(PollingMethod, NoPolling()) + else: + polling_method = polling if cont_token: return LROPoller.from_continuation_token( polling_method=polling_method, continuation_token=cont_token, client=self._client, - deserialization_callback=get_long_running_output + deserialization_callback=get_long_running_output, ) return LROPoller(self._client, raw_result, get_long_running_output, polling_method) - begin_update.metadata = {'url': "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{parentResourcePath}/{resourceType}/{resourceName}"} # type: ignore + begin_update.metadata = {"url": "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{parentResourcePath}/{resourceType}/{resourceName}"} # type: ignore @distributed_trace def get( @@ -3448,34 +3823,40 @@ def get( resource_name: str, api_version: str, **kwargs: Any - ) -> "_models.GenericResource": + ) -> _models.GenericResource: """Gets a resource. :param resource_group_name: The name of the resource group containing the resource to get. The - name is case insensitive. + name is case insensitive. Required. :type resource_group_name: str - :param resource_provider_namespace: The namespace of the resource provider. + :param resource_provider_namespace: The namespace of the resource provider. Required. :type resource_provider_namespace: str - :param parent_resource_path: The parent resource identity. + :param parent_resource_path: The parent resource identity. Required. :type parent_resource_path: str - :param resource_type: The resource type of the resource. + :param resource_type: The resource type of the resource. Required. :type resource_type: str - :param resource_name: The name of the resource to get. + :param resource_name: The name of the resource to get. Required. :type resource_name: str - :param api_version: The API version to use for the operation. + :param api_version: The API version to use for the operation. Required. :type api_version: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: GenericResource, or the result of cls(response) + :return: GenericResource or the result of cls(response) :rtype: ~azure.mgmt.resource.resources.v2017_05_10.models.GenericResource - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.GenericResource"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = kwargs.pop("params", {}) or {} + + cls = kwargs.pop("cls", None) # type: ClsType[_models.GenericResource] - request = build_resources_get_request( resource_group_name=resource_group_name, resource_provider_namespace=resource_provider_namespace, @@ -3484,72 +3865,75 @@ def get( resource_name=resource_name, subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.get.metadata['url'], + template_url=self.get.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) - deserialized = self._deserialize('GenericResource', pipeline_response) + deserialized = self._deserialize("GenericResource", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - get.metadata = {'url': "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{parentResourcePath}/{resourceType}/{resourceName}"} # type: ignore - + get.metadata = {"url": "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{parentResourcePath}/{resourceType}/{resourceName}"} # type: ignore @distributed_trace - def check_existence_by_id( - self, - resource_id: str, - api_version: str, - **kwargs: Any - ) -> bool: + def check_existence_by_id(self, resource_id: str, api_version: str, **kwargs: Any) -> bool: """Checks by ID whether a resource exists. :param resource_id: The fully qualified ID of the resource, including the resource name and resource type. Use the format, /subscriptions/{guid}/resourceGroups/{resource-group-name}/{resource-provider-namespace}/{resource-type}/{resource-name}. + Required. :type resource_id: str - :param api_version: The API version to use for the operation. + :param api_version: The API version to use for the operation. Required. :type api_version: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: bool, or the result of cls(response) + :return: bool or the result of cls(response) :rtype: bool - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType[None] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = kwargs.pop("params", {}) or {} + + cls = kwargs.pop("cls", None) # type: ClsType[None] - request = build_resources_check_existence_by_id_request( resource_id=resource_id, api_version=api_version, - template_url=self.check_existence_by_id.metadata['url'], + template_url=self.check_existence_by_id.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [204, 404]: @@ -3560,35 +3944,38 @@ def check_existence_by_id( return cls(pipeline_response, None, {}) return 200 <= response.status_code <= 299 - check_existence_by_id.metadata = {'url': "/{resourceId}"} # type: ignore - + check_existence_by_id.metadata = {"url": "/{resourceId}"} # type: ignore def _delete_by_id_initial( # pylint: disable=inconsistent-return-statements - self, - resource_id: str, - api_version: str, - **kwargs: Any + self, resource_id: str, api_version: str, **kwargs: Any ) -> None: - cls = kwargs.pop('cls', None) # type: ClsType[None] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = kwargs.pop("params", {}) or {} - - request = build_resources_delete_by_id_request_initial( + cls = kwargs.pop("cls", None) # type: ClsType[None] + + request = build_resources_delete_by_id_request( resource_id=resource_id, api_version=api_version, - template_url=self._delete_by_id_initial.metadata['url'], + template_url=self._delete_by_id_initial.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200, 202, 204]: @@ -3598,23 +3985,18 @@ def _delete_by_id_initial( # pylint: disable=inconsistent-return-statements if cls: return cls(pipeline_response, None, {}) - _delete_by_id_initial.metadata = {'url': "/{resourceId}"} # type: ignore - + _delete_by_id_initial.metadata = {"url": "/{resourceId}"} # type: ignore @distributed_trace - def begin_delete_by_id( # pylint: disable=inconsistent-return-statements - self, - resource_id: str, - api_version: str, - **kwargs: Any - ) -> LROPoller[None]: + def begin_delete_by_id(self, resource_id: str, api_version: str, **kwargs: Any) -> LROPoller[None]: """Deletes a resource by ID. :param resource_id: The fully qualified ID of the resource, including the resource name and resource type. Use the format, /subscriptions/{guid}/resourceGroups/{resource-group-name}/{resource-provider-namespace}/{resource-type}/{resource-name}. + Required. :type resource_id: str - :param api_version: The API version to use for the operation. + :param api_version: The API version to use for the operation. Required. :type api_version: str :keyword callable cls: A custom type or function that will be passed the direct response :keyword str continuation_token: A continuation token to restart a poller from a saved state. @@ -3626,75 +4008,89 @@ def begin_delete_by_id( # pylint: disable=inconsistent-return-statements Retry-After header is present. :return: An instance of LROPoller that returns either None or the result of cls(response) :rtype: ~azure.core.polling.LROPoller[None] - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - polling = kwargs.pop('polling', True) # type: Union[bool, PollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType[None] - lro_delay = kwargs.pop( - 'polling_interval', - self._config.polling_interval - ) - cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] + _headers = kwargs.pop("headers", {}) or {} + _params = kwargs.pop("params", {}) or {} + + cls = kwargs.pop("cls", None) # type: ClsType[None] + polling = kwargs.pop("polling", True) # type: Union[bool, PollingMethod] + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token = kwargs.pop("continuation_token", None) # type: Optional[str] if cont_token is None: - raw_result = self._delete_by_id_initial( + raw_result = self._delete_by_id_initial( # type: ignore resource_id=resource_id, api_version=api_version, - cls=lambda x,y,z: x, + cls=lambda x, y, z: x, + headers=_headers, + params=_params, **kwargs ) - kwargs.pop('error_map', None) + kwargs.pop("error_map", None) - def get_long_running_output(pipeline_response): + def get_long_running_output(pipeline_response): # pylint: disable=inconsistent-return-statements if cls: return cls(pipeline_response, None, {}) - - if polling is True: polling_method = ARMPolling(lro_delay, **kwargs) - elif polling is False: polling_method = NoPolling() - else: polling_method = polling + if polling is True: + polling_method = cast(PollingMethod, ARMPolling(lro_delay, **kwargs)) # type: PollingMethod + elif polling is False: + polling_method = cast(PollingMethod, NoPolling()) + else: + polling_method = polling if cont_token: return LROPoller.from_continuation_token( polling_method=polling_method, continuation_token=cont_token, client=self._client, - deserialization_callback=get_long_running_output + deserialization_callback=get_long_running_output, ) return LROPoller(self._client, raw_result, get_long_running_output, polling_method) - begin_delete_by_id.metadata = {'url': "/{resourceId}"} # type: ignore + begin_delete_by_id.metadata = {"url": "/{resourceId}"} # type: ignore def _create_or_update_by_id_initial( - self, - resource_id: str, - api_version: str, - parameters: "_models.GenericResource", - **kwargs: Any - ) -> Optional["_models.GenericResource"]: - cls = kwargs.pop('cls', None) # type: ClsType[Optional["_models.GenericResource"]] + self, resource_id: str, api_version: str, parameters: Union[_models.GenericResource, IO], **kwargs: Any + ) -> Optional[_models.GenericResource]: error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = kwargs.pop("params", {}) or {} - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[Optional[_models.GenericResource]] - _json = self._serialize.body(parameters, 'GenericResource') + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(parameters, (IO, bytes)): + _content = parameters + else: + _json = self._serialize.body(parameters, "GenericResource") - request = build_resources_create_or_update_by_id_request_initial( + request = build_resources_create_or_update_by_id_request( resource_id=resource_id, - content_type=content_type, api_version=api_version, + content_type=content_type, json=_json, - template_url=self._create_or_update_by_id_initial.metadata['url'], + content=_content, + template_url=self._create_or_update_by_id_initial.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200, 201, 202]: @@ -3703,37 +4099,42 @@ def _create_or_update_by_id_initial( deserialized = None if response.status_code == 200: - deserialized = self._deserialize('GenericResource', pipeline_response) + deserialized = self._deserialize("GenericResource", pipeline_response) if response.status_code == 201: - deserialized = self._deserialize('GenericResource', pipeline_response) + deserialized = self._deserialize("GenericResource", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - _create_or_update_by_id_initial.metadata = {'url': "/{resourceId}"} # type: ignore + _create_or_update_by_id_initial.metadata = {"url": "/{resourceId}"} # type: ignore - - @distributed_trace + @overload def begin_create_or_update_by_id( self, resource_id: str, api_version: str, - parameters: "_models.GenericResource", + parameters: _models.GenericResource, + *, + content_type: str = "application/json", **kwargs: Any - ) -> LROPoller["_models.GenericResource"]: + ) -> LROPoller[_models.GenericResource]: """Create a resource by ID. :param resource_id: The fully qualified ID of the resource, including the resource name and resource type. Use the format, /subscriptions/{guid}/resourceGroups/{resource-group-name}/{resource-provider-namespace}/{resource-type}/{resource-name}. + Required. :type resource_id: str - :param api_version: The API version to use for the operation. + :param api_version: The API version to use for the operation. Required. :type api_version: str - :param parameters: Create or update resource parameters. + :param parameters: Create or update resource parameters. Required. :type parameters: ~azure.mgmt.resource.resources.v2017_05_10.models.GenericResource + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str :keyword callable cls: A custom type or function that will be passed the direct response :keyword str continuation_token: A continuation token to restart a poller from a saved state. :keyword polling: By default, your polling method will be ARMPolling. Pass in False for this @@ -3746,81 +4147,167 @@ def begin_create_or_update_by_id( cls(response) :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.resource.resources.v2017_05_10.models.GenericResource] - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] - polling = kwargs.pop('polling', True) # type: Union[bool, PollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType["_models.GenericResource"] - lro_delay = kwargs.pop( - 'polling_interval', - self._config.polling_interval - ) - cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] + + @overload + def begin_create_or_update_by_id( + self, + resource_id: str, + api_version: str, + parameters: IO, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> LROPoller[_models.GenericResource]: + """Create a resource by ID. + + :param resource_id: The fully qualified ID of the resource, including the resource name and + resource type. Use the format, + /subscriptions/{guid}/resourceGroups/{resource-group-name}/{resource-provider-namespace}/{resource-type}/{resource-name}. + Required. + :type resource_id: str + :param api_version: The API version to use for the operation. Required. + :type api_version: str + :param parameters: Create or update resource parameters. Required. + :type parameters: IO + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be ARMPolling. Pass in False for this + operation to not poll, or pass in your own initialized polling object for a personal polling + strategy. + :paramtype polling: bool or ~azure.core.polling.PollingMethod + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of LROPoller that returns either GenericResource or the result of + cls(response) + :rtype: + ~azure.core.polling.LROPoller[~azure.mgmt.resource.resources.v2017_05_10.models.GenericResource] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace + def begin_create_or_update_by_id( + self, resource_id: str, api_version: str, parameters: Union[_models.GenericResource, IO], **kwargs: Any + ) -> LROPoller[_models.GenericResource]: + """Create a resource by ID. + + :param resource_id: The fully qualified ID of the resource, including the resource name and + resource type. Use the format, + /subscriptions/{guid}/resourceGroups/{resource-group-name}/{resource-provider-namespace}/{resource-type}/{resource-name}. + Required. + :type resource_id: str + :param api_version: The API version to use for the operation. Required. + :type api_version: str + :param parameters: Create or update resource parameters. Is either a model type or a IO type. + Required. + :type parameters: ~azure.mgmt.resource.resources.v2017_05_10.models.GenericResource or IO + :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. + Default value is None. + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be ARMPolling. Pass in False for this + operation to not poll, or pass in your own initialized polling object for a personal polling + strategy. + :paramtype polling: bool or ~azure.core.polling.PollingMethod + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of LROPoller that returns either GenericResource or the result of + cls(response) + :rtype: + ~azure.core.polling.LROPoller[~azure.mgmt.resource.resources.v2017_05_10.models.GenericResource] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = kwargs.pop("params", {}) or {} + + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.GenericResource] + polling = kwargs.pop("polling", True) # type: Union[bool, PollingMethod] + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token = kwargs.pop("continuation_token", None) # type: Optional[str] if cont_token is None: - raw_result = self._create_or_update_by_id_initial( + raw_result = self._create_or_update_by_id_initial( # type: ignore resource_id=resource_id, api_version=api_version, parameters=parameters, content_type=content_type, - cls=lambda x,y,z: x, + cls=lambda x, y, z: x, + headers=_headers, + params=_params, **kwargs ) - kwargs.pop('error_map', None) + kwargs.pop("error_map", None) def get_long_running_output(pipeline_response): - response = pipeline_response.http_response - deserialized = self._deserialize('GenericResource', pipeline_response) + deserialized = self._deserialize("GenericResource", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - - if polling is True: polling_method = ARMPolling(lro_delay, **kwargs) - elif polling is False: polling_method = NoPolling() - else: polling_method = polling + if polling is True: + polling_method = cast(PollingMethod, ARMPolling(lro_delay, **kwargs)) # type: PollingMethod + elif polling is False: + polling_method = cast(PollingMethod, NoPolling()) + else: + polling_method = polling if cont_token: return LROPoller.from_continuation_token( polling_method=polling_method, continuation_token=cont_token, client=self._client, - deserialization_callback=get_long_running_output + deserialization_callback=get_long_running_output, ) return LROPoller(self._client, raw_result, get_long_running_output, polling_method) - begin_create_or_update_by_id.metadata = {'url': "/{resourceId}"} # type: ignore + begin_create_or_update_by_id.metadata = {"url": "/{resourceId}"} # type: ignore def _update_by_id_initial( - self, - resource_id: str, - api_version: str, - parameters: "_models.GenericResource", - **kwargs: Any - ) -> Optional["_models.GenericResource"]: - cls = kwargs.pop('cls', None) # type: ClsType[Optional["_models.GenericResource"]] + self, resource_id: str, api_version: str, parameters: Union[_models.GenericResource, IO], **kwargs: Any + ) -> Optional[_models.GenericResource]: error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = kwargs.pop("params", {}) or {} - _json = self._serialize.body(parameters, 'GenericResource') + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[Optional[_models.GenericResource]] - request = build_resources_update_by_id_request_initial( + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(parameters, (IO, bytes)): + _content = parameters + else: + _json = self._serialize.body(parameters, "GenericResource") + + request = build_resources_update_by_id_request( resource_id=resource_id, - content_type=content_type, api_version=api_version, + content_type=content_type, json=_json, - template_url=self._update_by_id_initial.metadata['url'], + content=_content, + template_url=self._update_by_id_initial.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200, 202]: @@ -3829,34 +4316,39 @@ def _update_by_id_initial( deserialized = None if response.status_code == 200: - deserialized = self._deserialize('GenericResource', pipeline_response) + deserialized = self._deserialize("GenericResource", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - _update_by_id_initial.metadata = {'url': "/{resourceId}"} # type: ignore + _update_by_id_initial.metadata = {"url": "/{resourceId}"} # type: ignore - - @distributed_trace + @overload def begin_update_by_id( self, resource_id: str, api_version: str, - parameters: "_models.GenericResource", + parameters: _models.GenericResource, + *, + content_type: str = "application/json", **kwargs: Any - ) -> LROPoller["_models.GenericResource"]: + ) -> LROPoller[_models.GenericResource]: """Updates a resource by ID. :param resource_id: The fully qualified ID of the resource, including the resource name and resource type. Use the format, /subscriptions/{guid}/resourceGroups/{resource-group-name}/{resource-provider-namespace}/{resource-type}/{resource-name}. + Required. :type resource_id: str - :param api_version: The API version to use for the operation. + :param api_version: The API version to use for the operation. Required. :type api_version: str - :param parameters: Update resource parameters. + :param parameters: Update resource parameters. Required. :type parameters: ~azure.mgmt.resource.resources.v2017_05_10.models.GenericResource + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str :keyword callable cls: A custom type or function that will be passed the direct response :keyword str continuation_token: A continuation token to restart a poller from a saved state. :keyword polling: By default, your polling method will be ARMPolling. Pass in False for this @@ -3869,165 +4361,243 @@ def begin_update_by_id( cls(response) :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.resource.resources.v2017_05_10.models.GenericResource] - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] - polling = kwargs.pop('polling', True) # type: Union[bool, PollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType["_models.GenericResource"] - lro_delay = kwargs.pop( - 'polling_interval', - self._config.polling_interval - ) - cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] + + @overload + def begin_update_by_id( + self, + resource_id: str, + api_version: str, + parameters: IO, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> LROPoller[_models.GenericResource]: + """Updates a resource by ID. + + :param resource_id: The fully qualified ID of the resource, including the resource name and + resource type. Use the format, + /subscriptions/{guid}/resourceGroups/{resource-group-name}/{resource-provider-namespace}/{resource-type}/{resource-name}. + Required. + :type resource_id: str + :param api_version: The API version to use for the operation. Required. + :type api_version: str + :param parameters: Update resource parameters. Required. + :type parameters: IO + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be ARMPolling. Pass in False for this + operation to not poll, or pass in your own initialized polling object for a personal polling + strategy. + :paramtype polling: bool or ~azure.core.polling.PollingMethod + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of LROPoller that returns either GenericResource or the result of + cls(response) + :rtype: + ~azure.core.polling.LROPoller[~azure.mgmt.resource.resources.v2017_05_10.models.GenericResource] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace + def begin_update_by_id( + self, resource_id: str, api_version: str, parameters: Union[_models.GenericResource, IO], **kwargs: Any + ) -> LROPoller[_models.GenericResource]: + """Updates a resource by ID. + + :param resource_id: The fully qualified ID of the resource, including the resource name and + resource type. Use the format, + /subscriptions/{guid}/resourceGroups/{resource-group-name}/{resource-provider-namespace}/{resource-type}/{resource-name}. + Required. + :type resource_id: str + :param api_version: The API version to use for the operation. Required. + :type api_version: str + :param parameters: Update resource parameters. Is either a model type or a IO type. Required. + :type parameters: ~azure.mgmt.resource.resources.v2017_05_10.models.GenericResource or IO + :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. + Default value is None. + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be ARMPolling. Pass in False for this + operation to not poll, or pass in your own initialized polling object for a personal polling + strategy. + :paramtype polling: bool or ~azure.core.polling.PollingMethod + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of LROPoller that returns either GenericResource or the result of + cls(response) + :rtype: + ~azure.core.polling.LROPoller[~azure.mgmt.resource.resources.v2017_05_10.models.GenericResource] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = kwargs.pop("params", {}) or {} + + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.GenericResource] + polling = kwargs.pop("polling", True) # type: Union[bool, PollingMethod] + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token = kwargs.pop("continuation_token", None) # type: Optional[str] if cont_token is None: - raw_result = self._update_by_id_initial( + raw_result = self._update_by_id_initial( # type: ignore resource_id=resource_id, api_version=api_version, parameters=parameters, content_type=content_type, - cls=lambda x,y,z: x, + cls=lambda x, y, z: x, + headers=_headers, + params=_params, **kwargs ) - kwargs.pop('error_map', None) + kwargs.pop("error_map", None) def get_long_running_output(pipeline_response): - response = pipeline_response.http_response - deserialized = self._deserialize('GenericResource', pipeline_response) + deserialized = self._deserialize("GenericResource", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - - if polling is True: polling_method = ARMPolling(lro_delay, **kwargs) - elif polling is False: polling_method = NoPolling() - else: polling_method = polling + if polling is True: + polling_method = cast(PollingMethod, ARMPolling(lro_delay, **kwargs)) # type: PollingMethod + elif polling is False: + polling_method = cast(PollingMethod, NoPolling()) + else: + polling_method = polling if cont_token: return LROPoller.from_continuation_token( polling_method=polling_method, continuation_token=cont_token, client=self._client, - deserialization_callback=get_long_running_output + deserialization_callback=get_long_running_output, ) return LROPoller(self._client, raw_result, get_long_running_output, polling_method) - begin_update_by_id.metadata = {'url': "/{resourceId}"} # type: ignore + begin_update_by_id.metadata = {"url": "/{resourceId}"} # type: ignore @distributed_trace - def get_by_id( - self, - resource_id: str, - api_version: str, - **kwargs: Any - ) -> "_models.GenericResource": + def get_by_id(self, resource_id: str, api_version: str, **kwargs: Any) -> _models.GenericResource: """Gets a resource by ID. :param resource_id: The fully qualified ID of the resource, including the resource name and resource type. Use the format, /subscriptions/{guid}/resourceGroups/{resource-group-name}/{resource-provider-namespace}/{resource-type}/{resource-name}. + Required. :type resource_id: str - :param api_version: The API version to use for the operation. + :param api_version: The API version to use for the operation. Required. :type api_version: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: GenericResource, or the result of cls(response) + :return: GenericResource or the result of cls(response) :rtype: ~azure.mgmt.resource.resources.v2017_05_10.models.GenericResource - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.GenericResource"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = kwargs.pop("params", {}) or {} + + cls = kwargs.pop("cls", None) # type: ClsType[_models.GenericResource] - request = build_resources_get_by_id_request( resource_id=resource_id, api_version=api_version, - template_url=self.get_by_id.metadata['url'], + template_url=self.get_by_id.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) - deserialized = self._deserialize('GenericResource', pipeline_response) + deserialized = self._deserialize("GenericResource", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - get_by_id.metadata = {'url': "/{resourceId}"} # type: ignore + get_by_id.metadata = {"url": "/{resourceId}"} # type: ignore -class ResourceGroupsOperations(object): - """ResourceGroupsOperations operations. - You should not instantiate this class directly. Instead, you should create a Client instance that - instantiates it for you and attaches it as an attribute. +class ResourceGroupsOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. - :ivar models: Alias to model classes used in this operation group. - :type models: ~azure.mgmt.resource.resources.v2017_05_10.models - :param client: Client for service requests. - :param config: Configuration of service client. - :param serializer: An object model serializer. - :param deserializer: An object model deserializer. + Instead, you should access the following operations through + :class:`~azure.mgmt.resource.resources.v2017_05_10.ResourceManagementClient`'s + :attr:`resource_groups` attribute. """ models = _models - def __init__(self, client, config, serializer, deserializer): - self._client = client - self._serialize = serializer - self._deserialize = deserializer - self._config = config + def __init__(self, *args, **kwargs): + input_args = list(args) + self._client = input_args.pop(0) if input_args else kwargs.pop("client") + self._config = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") @distributed_trace - def check_existence( - self, - resource_group_name: str, - **kwargs: Any - ) -> bool: + def check_existence(self, resource_group_name: str, **kwargs: Any) -> bool: """Checks whether a resource group exists. :param resource_group_name: The name of the resource group to check. The name is case - insensitive. + insensitive. Required. :type resource_group_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: bool, or the result of cls(response) + :return: bool or the result of cls(response) :rtype: bool - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType[None] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) - api_version = kwargs.pop('api_version', "2017-05-10") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2017-05-10")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[None] - request = build_resource_groups_check_existence_request( resource_group_name=resource_group_name, subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.check_existence.metadata['url'], + template_url=self.check_existence.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [204, 404]: @@ -4038,37 +4608,92 @@ def check_existence( return cls(pipeline_response, None, {}) return 200 <= response.status_code <= 299 - check_existence.metadata = {'url': "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}"} # type: ignore + check_existence.metadata = {"url": "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}"} # type: ignore - - @distributed_trace + @overload def create_or_update( self, resource_group_name: str, - parameters: "_models.ResourceGroup", + parameters: _models.ResourceGroup, + *, + content_type: str = "application/json", **kwargs: Any - ) -> "_models.ResourceGroup": + ) -> _models.ResourceGroup: """Creates or updates a resource group. - :param resource_group_name: The name of the resource group to create or update. + :param resource_group_name: The name of the resource group to create or update. Required. :type resource_group_name: str - :param parameters: Parameters supplied to the create or update a resource group. + :param parameters: Parameters supplied to the create or update a resource group. Required. :type parameters: ~azure.mgmt.resource.resources.v2017_05_10.models.ResourceGroup + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: ResourceGroup or the result of cls(response) + :rtype: ~azure.mgmt.resource.resources.v2017_05_10.models.ResourceGroup + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + def create_or_update( + self, resource_group_name: str, parameters: IO, *, content_type: str = "application/json", **kwargs: Any + ) -> _models.ResourceGroup: + """Creates or updates a resource group. + + :param resource_group_name: The name of the resource group to create or update. Required. + :type resource_group_name: str + :param parameters: Parameters supplied to the create or update a resource group. Required. + :type parameters: IO + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: ResourceGroup or the result of cls(response) + :rtype: ~azure.mgmt.resource.resources.v2017_05_10.models.ResourceGroup + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace + def create_or_update( + self, resource_group_name: str, parameters: Union[_models.ResourceGroup, IO], **kwargs: Any + ) -> _models.ResourceGroup: + """Creates or updates a resource group. + + :param resource_group_name: The name of the resource group to create or update. Required. + :type resource_group_name: str + :param parameters: Parameters supplied to the create or update a resource group. Is either a + model type or a IO type. Required. + :type parameters: ~azure.mgmt.resource.resources.v2017_05_10.models.ResourceGroup or IO + :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. + Default value is None. + :paramtype content_type: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: ResourceGroup, or the result of cls(response) + :return: ResourceGroup or the result of cls(response) :rtype: ~azure.mgmt.resource.resources.v2017_05_10.models.ResourceGroup - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.ResourceGroup"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) - api_version = kwargs.pop('api_version', "2017-05-10") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - _json = self._serialize.body(parameters, 'ResourceGroup') + api_version = kwargs.pop("api_version", _params.pop("api-version", "2017-05-10")) # type: str + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.ResourceGroup] + + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(parameters, (IO, bytes)): + _content = parameters + else: + _json = self._serialize.body(parameters, "ResourceGroup") request = build_resource_groups_create_or_update_request( resource_group_name=resource_group_name, @@ -4076,16 +4701,18 @@ def create_or_update( api_version=api_version, content_type=content_type, json=_json, - template_url=self.create_or_update.metadata['url'], + content=_content, + template_url=self.create_or_update.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200, 201]: @@ -4093,47 +4720,50 @@ def create_or_update( raise HttpResponseError(response=response, error_format=ARMErrorFormat) if response.status_code == 200: - deserialized = self._deserialize('ResourceGroup', pipeline_response) + deserialized = self._deserialize("ResourceGroup", pipeline_response) if response.status_code == 201: - deserialized = self._deserialize('ResourceGroup', pipeline_response) + deserialized = self._deserialize("ResourceGroup", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - create_or_update.metadata = {'url': "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}"} # type: ignore - + create_or_update.metadata = {"url": "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}"} # type: ignore def _delete_initial( # pylint: disable=inconsistent-return-statements - self, - resource_group_name: str, - **kwargs: Any + self, resource_group_name: str, **kwargs: Any ) -> None: - cls = kwargs.pop('cls', None) # type: ClsType[None] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) - api_version = kwargs.pop('api_version', "2017-05-10") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - request = build_resource_groups_delete_request_initial( + api_version = kwargs.pop("api_version", _params.pop("api-version", "2017-05-10")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[None] + + request = build_resource_groups_delete_request( resource_group_name=resource_group_name, subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self._delete_initial.metadata['url'], + template_url=self._delete_initial.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200, 202]: @@ -4143,22 +4773,17 @@ def _delete_initial( # pylint: disable=inconsistent-return-statements if cls: return cls(pipeline_response, None, {}) - _delete_initial.metadata = {'url': "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}"} # type: ignore - + _delete_initial.metadata = {"url": "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}"} # type: ignore @distributed_trace - def begin_delete( # pylint: disable=inconsistent-return-statements - self, - resource_group_name: str, - **kwargs: Any - ) -> LROPoller[None]: + def begin_delete(self, resource_group_name: str, **kwargs: Any) -> LROPoller[None]: """Deletes a resource group. When you delete a resource group, all of its resources are also deleted. Deleting a resource group deletes all of its template deployments and currently stored operations. :param resource_group_name: The name of the resource group to delete. The name is case - insensitive. + insensitive. Required. :type resource_group_name: str :keyword callable cls: A custom type or function that will be passed the direct response :keyword str continuation_token: A continuation token to restart a poller from a saved state. @@ -4170,106 +4795,113 @@ def begin_delete( # pylint: disable=inconsistent-return-statements Retry-After header is present. :return: An instance of LROPoller that returns either None or the result of cls(response) :rtype: ~azure.core.polling.LROPoller[None] - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - api_version = kwargs.pop('api_version', "2017-05-10") # type: str - polling = kwargs.pop('polling', True) # type: Union[bool, PollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType[None] - lro_delay = kwargs.pop( - 'polling_interval', - self._config.polling_interval - ) - cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2017-05-10")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[None] + polling = kwargs.pop("polling", True) # type: Union[bool, PollingMethod] + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token = kwargs.pop("continuation_token", None) # type: Optional[str] if cont_token is None: - raw_result = self._delete_initial( + raw_result = self._delete_initial( # type: ignore resource_group_name=resource_group_name, api_version=api_version, - cls=lambda x,y,z: x, + cls=lambda x, y, z: x, + headers=_headers, + params=_params, **kwargs ) - kwargs.pop('error_map', None) + kwargs.pop("error_map", None) - def get_long_running_output(pipeline_response): + def get_long_running_output(pipeline_response): # pylint: disable=inconsistent-return-statements if cls: return cls(pipeline_response, None, {}) - - if polling is True: polling_method = ARMPolling(lro_delay, **kwargs) - elif polling is False: polling_method = NoPolling() - else: polling_method = polling + if polling is True: + polling_method = cast(PollingMethod, ARMPolling(lro_delay, **kwargs)) # type: PollingMethod + elif polling is False: + polling_method = cast(PollingMethod, NoPolling()) + else: + polling_method = polling if cont_token: return LROPoller.from_continuation_token( polling_method=polling_method, continuation_token=cont_token, client=self._client, - deserialization_callback=get_long_running_output + deserialization_callback=get_long_running_output, ) return LROPoller(self._client, raw_result, get_long_running_output, polling_method) - begin_delete.metadata = {'url': "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}"} # type: ignore + begin_delete.metadata = {"url": "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}"} # type: ignore @distributed_trace - def get( - self, - resource_group_name: str, - **kwargs: Any - ) -> "_models.ResourceGroup": + def get(self, resource_group_name: str, **kwargs: Any) -> _models.ResourceGroup: """Gets a resource group. :param resource_group_name: The name of the resource group to get. The name is case - insensitive. + insensitive. Required. :type resource_group_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: ResourceGroup, or the result of cls(response) + :return: ResourceGroup or the result of cls(response) :rtype: ~azure.mgmt.resource.resources.v2017_05_10.models.ResourceGroup - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.ResourceGroup"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) - api_version = kwargs.pop('api_version', "2017-05-10") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2017-05-10")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[_models.ResourceGroup] - request = build_resource_groups_get_request( resource_group_name=resource_group_name, subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.get.metadata['url'], + template_url=self.get.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) - deserialized = self._deserialize('ResourceGroup', pipeline_response) + deserialized = self._deserialize("ResourceGroup", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - get.metadata = {'url': "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}"} # type: ignore + get.metadata = {"url": "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}"} # type: ignore - - @distributed_trace + @overload def update( self, resource_group_name: str, - parameters: "_models.ResourceGroupPatchable", + parameters: _models.ResourceGroupPatchable, + *, + content_type: str = "application/json", **kwargs: Any - ) -> "_models.ResourceGroup": + ) -> _models.ResourceGroup: """Updates a resource group. Resource groups can be updated through a simple PATCH operation to a group address. The format @@ -4277,25 +4909,90 @@ def update( the current value is retained. :param resource_group_name: The name of the resource group to update. The name is case - insensitive. + insensitive. Required. :type resource_group_name: str - :param parameters: Parameters supplied to update a resource group. + :param parameters: Parameters supplied to update a resource group. Required. :type parameters: ~azure.mgmt.resource.resources.v2017_05_10.models.ResourceGroupPatchable + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: ResourceGroup or the result of cls(response) + :rtype: ~azure.mgmt.resource.resources.v2017_05_10.models.ResourceGroup + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + def update( + self, resource_group_name: str, parameters: IO, *, content_type: str = "application/json", **kwargs: Any + ) -> _models.ResourceGroup: + """Updates a resource group. + + Resource groups can be updated through a simple PATCH operation to a group address. The format + of the request is the same as that for creating a resource group. If a field is unspecified, + the current value is retained. + + :param resource_group_name: The name of the resource group to update. The name is case + insensitive. Required. + :type resource_group_name: str + :param parameters: Parameters supplied to update a resource group. Required. + :type parameters: IO + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: ResourceGroup or the result of cls(response) + :rtype: ~azure.mgmt.resource.resources.v2017_05_10.models.ResourceGroup + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace + def update( + self, resource_group_name: str, parameters: Union[_models.ResourceGroupPatchable, IO], **kwargs: Any + ) -> _models.ResourceGroup: + """Updates a resource group. + + Resource groups can be updated through a simple PATCH operation to a group address. The format + of the request is the same as that for creating a resource group. If a field is unspecified, + the current value is retained. + + :param resource_group_name: The name of the resource group to update. The name is case + insensitive. Required. + :type resource_group_name: str + :param parameters: Parameters supplied to update a resource group. Is either a model type or a + IO type. Required. + :type parameters: ~azure.mgmt.resource.resources.v2017_05_10.models.ResourceGroupPatchable or + IO + :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. + Default value is None. + :paramtype content_type: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: ResourceGroup, or the result of cls(response) + :return: ResourceGroup or the result of cls(response) :rtype: ~azure.mgmt.resource.resources.v2017_05_10.models.ResourceGroup - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.ResourceGroup"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) - api_version = kwargs.pop('api_version', "2017-05-10") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - _json = self._serialize.body(parameters, 'ResourceGroupPatchable') + api_version = kwargs.pop("api_version", _params.pop("api-version", "2017-05-10")) # type: str + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.ResourceGroup] + + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(parameters, (IO, bytes)): + _content = parameters + else: + _json = self._serialize.body(parameters, "ResourceGroupPatchable") request = build_resource_groups_update_request( resource_group_name=resource_group_name, @@ -4303,60 +5000,117 @@ def update( api_version=api_version, content_type=content_type, json=_json, - template_url=self.update.metadata['url'], + content=_content, + template_url=self.update.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) - deserialized = self._deserialize('ResourceGroup', pipeline_response) + deserialized = self._deserialize("ResourceGroup", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - update.metadata = {'url': "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}"} # type: ignore + update.metadata = {"url": "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}"} # type: ignore - - @distributed_trace + @overload def export_template( self, resource_group_name: str, - parameters: "_models.ExportTemplateRequest", + parameters: _models.ExportTemplateRequest, + *, + content_type: str = "application/json", **kwargs: Any - ) -> "_models.ResourceGroupExportResult": + ) -> _models.ResourceGroupExportResult: """Captures the specified resource group as a template. - :param resource_group_name: The name of the resource group to export as a template. + :param resource_group_name: The name of the resource group to export as a template. Required. :type resource_group_name: str - :param parameters: Parameters for exporting the template. + :param parameters: Parameters for exporting the template. Required. :type parameters: ~azure.mgmt.resource.resources.v2017_05_10.models.ExportTemplateRequest + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: ResourceGroupExportResult or the result of cls(response) + :rtype: ~azure.mgmt.resource.resources.v2017_05_10.models.ResourceGroupExportResult + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + def export_template( + self, resource_group_name: str, parameters: IO, *, content_type: str = "application/json", **kwargs: Any + ) -> _models.ResourceGroupExportResult: + """Captures the specified resource group as a template. + + :param resource_group_name: The name of the resource group to export as a template. Required. + :type resource_group_name: str + :param parameters: Parameters for exporting the template. Required. + :type parameters: IO + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: ResourceGroupExportResult or the result of cls(response) + :rtype: ~azure.mgmt.resource.resources.v2017_05_10.models.ResourceGroupExportResult + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace + def export_template( + self, resource_group_name: str, parameters: Union[_models.ExportTemplateRequest, IO], **kwargs: Any + ) -> _models.ResourceGroupExportResult: + """Captures the specified resource group as a template. + + :param resource_group_name: The name of the resource group to export as a template. Required. + :type resource_group_name: str + :param parameters: Parameters for exporting the template. Is either a model type or a IO type. + Required. + :type parameters: ~azure.mgmt.resource.resources.v2017_05_10.models.ExportTemplateRequest or IO + :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. + Default value is None. + :paramtype content_type: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: ResourceGroupExportResult, or the result of cls(response) + :return: ResourceGroupExportResult or the result of cls(response) :rtype: ~azure.mgmt.resource.resources.v2017_05_10.models.ResourceGroupExportResult - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.ResourceGroupExportResult"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) - api_version = kwargs.pop('api_version', "2017-05-10") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - _json = self._serialize.body(parameters, 'ExportTemplateRequest') + api_version = kwargs.pop("api_version", _params.pop("api-version", "2017-05-10")) # type: str + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.ResourceGroupExportResult] + + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(parameters, (IO, bytes)): + _content = parameters + else: + _json = self._serialize.body(parameters, "ExportTemplateRequest") request = build_resource_groups_export_template_request( resource_group_name=resource_group_name, @@ -4364,39 +5118,37 @@ def export_template( api_version=api_version, content_type=content_type, json=_json, - template_url=self.export_template.metadata['url'], + content=_content, + template_url=self.export_template.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) - deserialized = self._deserialize('ResourceGroupExportResult', pipeline_response) + deserialized = self._deserialize("ResourceGroupExportResult", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - export_template.metadata = {'url': "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/exportTemplate"} # type: ignore - + export_template.metadata = {"url": "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/exportTemplate"} # type: ignore @distributed_trace def list( - self, - filter: Optional[str] = None, - top: Optional[int] = None, - **kwargs: Any - ) -> Iterable["_models.ResourceGroupListResult"]: + self, filter: Optional[str] = None, top: Optional[int] = None, **kwargs: Any + ) -> Iterable["_models.ResourceGroup"]: """Gets all the resource groups for a subscription. :param filter: The filter to apply on the operation. Default value is None. @@ -4405,40 +5157,48 @@ def list( Default value is None. :type top: int :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either ResourceGroupListResult or the result of - cls(response) + :return: An iterator like instance of either ResourceGroup or the result of cls(response) :rtype: - ~azure.core.paging.ItemPaged[~azure.mgmt.resource.resources.v2017_05_10.models.ResourceGroupListResult] - :raises: ~azure.core.exceptions.HttpResponseError + ~azure.core.paging.ItemPaged[~azure.mgmt.resource.resources.v2017_05_10.models.ResourceGroup] + :raises ~azure.core.exceptions.HttpResponseError: """ - api_version = kwargs.pop('api_version', "2017-05-10") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2017-05-10")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[_models.ResourceGroupListResult] - cls = kwargs.pop('cls', None) # type: ClsType["_models.ResourceGroupListResult"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) + def prepare_request(next_link=None): if not next_link: - + request = build_resource_groups_list_request( subscription_id=self._config.subscription_id, - api_version=api_version, filter=filter, top=top, - template_url=self.list.metadata['url'], + 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.url = self._client.format_url(request.url) # type: ignore else: - - request = build_resource_groups_list_request( - subscription_id=self._config.subscription_id, - template_url=next_link, - ) + # make call to next link with the client's api-version + _parsed_next_link = urlparse(next_link) + _next_request_params = case_insensitive_dict(parse_qs(_parsed_next_link.query)) + _next_request_params["api-version"] = self._config.api_version + request = HttpRequest("GET", urljoin(next_link, _parsed_next_link.path), params=_next_request_params) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore request.method = "GET" return request @@ -4452,10 +5212,8 @@ def extract_data(pipeline_response): def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) response = pipeline_response.http_response @@ -4465,75 +5223,75 @@ def get_next(next_link=None): return pipeline_response + return ItemPaged(get_next, extract_data) - return ItemPaged( - get_next, extract_data - ) - list.metadata = {'url': "/subscriptions/{subscriptionId}/resourcegroups"} # type: ignore -class TagsOperations(object): - """TagsOperations operations. - - You should not instantiate this class directly. Instead, you should create a Client instance that - instantiates it for you and attaches it as an attribute. - - :ivar models: Alias to model classes used in this operation group. - :type models: ~azure.mgmt.resource.resources.v2017_05_10.models - :param client: Client for service requests. - :param config: Configuration of service client. - :param serializer: An object model serializer. - :param deserializer: An object model deserializer. + list.metadata = {"url": "/subscriptions/{subscriptionId}/resourcegroups"} # type: ignore + + +class TagsOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. + + Instead, you should access the following operations through + :class:`~azure.mgmt.resource.resources.v2017_05_10.ResourceManagementClient`'s + :attr:`tags` attribute. """ models = _models - def __init__(self, client, config, serializer, deserializer): - self._client = client - self._serialize = serializer - self._deserialize = deserializer - self._config = config + def __init__(self, *args, **kwargs): + input_args = list(args) + self._client = input_args.pop(0) if input_args else kwargs.pop("client") + self._config = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") @distributed_trace def delete_value( # pylint: disable=inconsistent-return-statements - self, - tag_name: str, - tag_value: str, - **kwargs: Any + self, tag_name: str, tag_value: str, **kwargs: Any ) -> None: """Deletes a tag value. - :param tag_name: The name of the tag. + :param tag_name: The name of the tag. Required. :type tag_name: str - :param tag_value: The value of the tag to delete. + :param tag_value: The value of the tag to delete. Required. :type tag_value: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: None, or the result of cls(response) + :return: None or the result of cls(response) :rtype: None - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType[None] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) - api_version = kwargs.pop('api_version', "2017-05-10") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2017-05-10")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[None] - request = build_tags_delete_value_request( tag_name=tag_name, tag_value=tag_value, subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.delete_value.metadata['url'], + template_url=self.delete_value.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200, 204]: @@ -4543,51 +5301,51 @@ def delete_value( # pylint: disable=inconsistent-return-statements if cls: return cls(pipeline_response, None, {}) - delete_value.metadata = {'url': "/subscriptions/{subscriptionId}/tagNames/{tagName}/tagValues/{tagValue}"} # type: ignore - + delete_value.metadata = {"url": "/subscriptions/{subscriptionId}/tagNames/{tagName}/tagValues/{tagValue}"} # type: ignore @distributed_trace - def create_or_update_value( - self, - tag_name: str, - tag_value: str, - **kwargs: Any - ) -> "_models.TagValue": + def create_or_update_value(self, tag_name: str, tag_value: str, **kwargs: Any) -> _models.TagValue: """Creates a tag value. The name of the tag must already exist. - :param tag_name: The name of the tag. + :param tag_name: The name of the tag. Required. :type tag_name: str - :param tag_value: The value of the tag to create. + :param tag_value: The value of the tag to create. Required. :type tag_value: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: TagValue, or the result of cls(response) + :return: TagValue or the result of cls(response) :rtype: ~azure.mgmt.resource.resources.v2017_05_10.models.TagValue - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.TagValue"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + 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', "2017-05-10") # type: str + api_version = kwargs.pop("api_version", _params.pop("api-version", "2017-05-10")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[_models.TagValue] - request = build_tags_create_or_update_value_request( tag_name=tag_name, tag_value=tag_value, subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.create_or_update_value.metadata['url'], + template_url=self.create_or_update_value.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200, 201]: @@ -4595,61 +5353,62 @@ def create_or_update_value( raise HttpResponseError(response=response, error_format=ARMErrorFormat) if response.status_code == 200: - deserialized = self._deserialize('TagValue', pipeline_response) + deserialized = self._deserialize("TagValue", pipeline_response) if response.status_code == 201: - deserialized = self._deserialize('TagValue', pipeline_response) + deserialized = self._deserialize("TagValue", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - create_or_update_value.metadata = {'url': "/subscriptions/{subscriptionId}/tagNames/{tagName}/tagValues/{tagValue}"} # type: ignore - + create_or_update_value.metadata = {"url": "/subscriptions/{subscriptionId}/tagNames/{tagName}/tagValues/{tagValue}"} # type: ignore @distributed_trace - def create_or_update( - self, - tag_name: str, - **kwargs: Any - ) -> "_models.TagDetails": + def create_or_update(self, tag_name: str, **kwargs: Any) -> _models.TagDetails: """Creates a tag in the subscription. The tag name can have a maximum of 512 characters and is case insensitive. Tag names created by Azure have prefixes of microsoft, azure, or windows. You cannot create tags with one of these prefixes. - :param tag_name: The name of the tag to create. + :param tag_name: The name of the tag to create. Required. :type tag_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: TagDetails, or the result of cls(response) + :return: TagDetails or the result of cls(response) :rtype: ~azure.mgmt.resource.resources.v2017_05_10.models.TagDetails - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.TagDetails"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + 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', "2017-05-10") # type: str + api_version = kwargs.pop("api_version", _params.pop("api-version", "2017-05-10")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[_models.TagDetails] - request = build_tags_create_or_update_request( tag_name=tag_name, subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.create_or_update.metadata['url'], + template_url=self.create_or_update.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200, 201]: @@ -4657,59 +5416,60 @@ def create_or_update( raise HttpResponseError(response=response, error_format=ARMErrorFormat) if response.status_code == 200: - deserialized = self._deserialize('TagDetails', pipeline_response) + deserialized = self._deserialize("TagDetails", pipeline_response) if response.status_code == 201: - deserialized = self._deserialize('TagDetails', pipeline_response) + deserialized = self._deserialize("TagDetails", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - create_or_update.metadata = {'url': "/subscriptions/{subscriptionId}/tagNames/{tagName}"} # type: ignore - + create_or_update.metadata = {"url": "/subscriptions/{subscriptionId}/tagNames/{tagName}"} # type: ignore @distributed_trace - def delete( # pylint: disable=inconsistent-return-statements - self, - tag_name: str, - **kwargs: Any - ) -> None: + def delete(self, tag_name: str, **kwargs: Any) -> None: # pylint: disable=inconsistent-return-statements """Deletes a tag from the subscription. You must remove all values from a resource tag before you can delete it. - :param tag_name: The name of the tag. + :param tag_name: The name of the tag. Required. :type tag_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: None, or the result of cls(response) + :return: None or the result of cls(response) :rtype: None - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType[None] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + 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', "2017-05-10") # type: str + api_version = kwargs.pop("api_version", _params.pop("api-version", "2017-05-10")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[None] - request = build_tags_delete_request( tag_name=tag_name, subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.delete.metadata['url'], + template_url=self.delete.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200, 204]: @@ -4719,48 +5479,53 @@ def delete( # pylint: disable=inconsistent-return-statements if cls: return cls(pipeline_response, None, {}) - delete.metadata = {'url': "/subscriptions/{subscriptionId}/tagNames/{tagName}"} # type: ignore - + delete.metadata = {"url": "/subscriptions/{subscriptionId}/tagNames/{tagName}"} # type: ignore @distributed_trace - def list( - self, - **kwargs: Any - ) -> Iterable["_models.TagsListResult"]: + def list(self, **kwargs: Any) -> Iterable["_models.TagDetails"]: """Gets the names and values of all resource tags that are defined in a subscription. :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either TagsListResult or the result of cls(response) + :return: An iterator like instance of either TagDetails or the result of cls(response) :rtype: - ~azure.core.paging.ItemPaged[~azure.mgmt.resource.resources.v2017_05_10.models.TagsListResult] - :raises: ~azure.core.exceptions.HttpResponseError + ~azure.core.paging.ItemPaged[~azure.mgmt.resource.resources.v2017_05_10.models.TagDetails] + :raises ~azure.core.exceptions.HttpResponseError: """ - api_version = kwargs.pop('api_version', "2017-05-10") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2017-05-10")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[_models.TagsListResult] - cls = kwargs.pop('cls', None) # type: ClsType["_models.TagsListResult"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) + def prepare_request(next_link=None): if not next_link: - + request = build_tags_list_request( subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.list.metadata['url'], + template_url=self.list.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore else: - - request = build_tags_list_request( - subscription_id=self._config.subscription_id, - template_url=next_link, - ) + # make call to next link with the client's api-version + _parsed_next_link = urlparse(next_link) + _next_request_params = case_insensitive_dict(parse_qs(_parsed_next_link.query)) + _next_request_params["api-version"] = self._config.api_version + request = HttpRequest("GET", urljoin(next_link, _parsed_next_link.path), params=_next_request_params) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore request.method = "GET" return request @@ -4774,10 +5539,8 @@ def extract_data(pipeline_response): def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) response = pipeline_response.http_response @@ -4787,149 +5550,151 @@ def get_next(next_link=None): return pipeline_response + return ItemPaged(get_next, extract_data) - return ItemPaged( - get_next, extract_data - ) - list.metadata = {'url': "/subscriptions/{subscriptionId}/tagNames"} # type: ignore -class DeploymentOperationsOperations(object): - """DeploymentOperationsOperations operations. - - You should not instantiate this class directly. Instead, you should create a Client instance that - instantiates it for you and attaches it as an attribute. - - :ivar models: Alias to model classes used in this operation group. - :type models: ~azure.mgmt.resource.resources.v2017_05_10.models - :param client: Client for service requests. - :param config: Configuration of service client. - :param serializer: An object model serializer. - :param deserializer: An object model deserializer. + list.metadata = {"url": "/subscriptions/{subscriptionId}/tagNames"} # type: ignore + + +class DeploymentOperationsOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. + + Instead, you should access the following operations through + :class:`~azure.mgmt.resource.resources.v2017_05_10.ResourceManagementClient`'s + :attr:`deployment_operations` attribute. """ models = _models - def __init__(self, client, config, serializer, deserializer): - self._client = client - self._serialize = serializer - self._deserialize = deserializer - self._config = config + def __init__(self, *args, **kwargs): + input_args = list(args) + self._client = input_args.pop(0) if input_args else kwargs.pop("client") + self._config = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") @distributed_trace def get( - self, - resource_group_name: str, - deployment_name: str, - operation_id: str, - **kwargs: Any - ) -> "_models.DeploymentOperation": + self, resource_group_name: str, deployment_name: str, operation_id: str, **kwargs: Any + ) -> _models.DeploymentOperation: """Gets a deployments operation. :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. :type resource_group_name: str - :param deployment_name: The name of the deployment. + :param deployment_name: The name of the deployment. Required. :type deployment_name: str - :param operation_id: The ID of the operation to get. + :param operation_id: The ID of the operation to get. Required. :type operation_id: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: DeploymentOperation, or the result of cls(response) + :return: DeploymentOperation or the result of cls(response) :rtype: ~azure.mgmt.resource.resources.v2017_05_10.models.DeploymentOperation - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.DeploymentOperation"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + 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', "2017-05-10") # type: str + api_version = kwargs.pop("api_version", _params.pop("api-version", "2017-05-10")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[_models.DeploymentOperation] - request = build_deployment_operations_get_request( resource_group_name=resource_group_name, deployment_name=deployment_name, operation_id=operation_id, subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.get.metadata['url'], + template_url=self.get.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) - deserialized = self._deserialize('DeploymentOperation', pipeline_response) + deserialized = self._deserialize("DeploymentOperation", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - get.metadata = {'url': "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/deployments/{deploymentName}/operations/{operationId}"} # type: ignore - + get.metadata = {"url": "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/deployments/{deploymentName}/operations/{operationId}"} # type: ignore @distributed_trace def list( - self, - resource_group_name: str, - deployment_name: str, - top: Optional[int] = None, - **kwargs: Any - ) -> Iterable["_models.DeploymentOperationsListResult"]: + self, resource_group_name: str, deployment_name: str, top: Optional[int] = None, **kwargs: Any + ) -> Iterable["_models.DeploymentOperation"]: """Gets all deployments operations for a deployment. :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. :type resource_group_name: str - :param deployment_name: The name of the deployment with the operation to get. + :param deployment_name: The name of the deployment with the operation to get. Required. :type deployment_name: str :param top: The number of results to return. Default value is None. :type top: int :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either DeploymentOperationsListResult or the result of - cls(response) + :return: An iterator like instance of either DeploymentOperation or the result of cls(response) :rtype: - ~azure.core.paging.ItemPaged[~azure.mgmt.resource.resources.v2017_05_10.models.DeploymentOperationsListResult] - :raises: ~azure.core.exceptions.HttpResponseError + ~azure.core.paging.ItemPaged[~azure.mgmt.resource.resources.v2017_05_10.models.DeploymentOperation] + :raises ~azure.core.exceptions.HttpResponseError: """ - api_version = kwargs.pop('api_version', "2017-05-10") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2017-05-10")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[_models.DeploymentOperationsListResult] - cls = kwargs.pop('cls', None) # type: ClsType["_models.DeploymentOperationsListResult"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) + def prepare_request(next_link=None): if not next_link: - + request = build_deployment_operations_list_request( resource_group_name=resource_group_name, deployment_name=deployment_name, subscription_id=self._config.subscription_id, - api_version=api_version, top=top, - template_url=self.list.metadata['url'], + 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.url = self._client.format_url(request.url) # type: ignore else: - - request = build_deployment_operations_list_request( - resource_group_name=resource_group_name, - deployment_name=deployment_name, - subscription_id=self._config.subscription_id, - template_url=next_link, - ) + # make call to next link with the client's api-version + _parsed_next_link = urlparse(next_link) + _next_request_params = case_insensitive_dict(parse_qs(_parsed_next_link.query)) + _next_request_params["api-version"] = self._config.api_version + request = HttpRequest("GET", urljoin(next_link, _parsed_next_link.path), params=_next_request_params) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore request.method = "GET" return request @@ -4943,10 +5708,8 @@ def extract_data(pipeline_response): def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) response = pipeline_response.http_response @@ -4956,8 +5719,6 @@ def get_next(next_link=None): return pipeline_response + return ItemPaged(get_next, extract_data) - return ItemPaged( - get_next, extract_data - ) - list.metadata = {'url': "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/deployments/{deploymentName}/operations"} # type: ignore + list.metadata = {"url": "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/deployments/{deploymentName}/operations"} # type: ignore diff --git a/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/resources/v2017_05_10/operations/_patch.py b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/resources/v2017_05_10/operations/_patch.py new file mode 100644 index 0000000000000..f7dd32510333d --- /dev/null +++ b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/resources/v2017_05_10/operations/_patch.py @@ -0,0 +1,20 @@ +# ------------------------------------ +# Copyright (c) Microsoft Corporation. +# Licensed under the MIT License. +# ------------------------------------ +"""Customize generated code here. + +Follow our quickstart for examples: https://aka.ms/azsdk/python/dpcodegen/python/customize +""" +from typing import List + +__all__: List[str] = [] # Add all objects you want publicly available to users at this package level + + +def patch_sdk(): + """Do not remove from this file. + + `patch_sdk` is a last resort escape hatch that allows you to do customizations + you can't accomplish using the techniques described in + https://aka.ms/azsdk/python/dpcodegen/python/customize + """ diff --git a/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/resources/v2018_02_01/__init__.py b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/resources/v2018_02_01/__init__.py index 449220069f2f2..2b201470d075e 100644 --- a/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/resources/v2018_02_01/__init__.py +++ b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/resources/v2018_02_01/__init__.py @@ -10,9 +10,15 @@ from ._version import VERSION __version__ = VERSION -__all__ = ['ResourceManagementClient'] -# `._patch.py` is used for handwritten extensions to the generated code -# Example: https://github.com/Azure/azure-sdk-for-python/blob/main/doc/dev/customize_code/how-to-patch-sdk-code.md -from ._patch import patch_sdk -patch_sdk() +try: + from ._patch import __all__ as _patch_all + from ._patch import * # type: ignore # pylint: disable=unused-wildcard-import +except ImportError: + _patch_all = [] +from ._patch import patch_sdk as _patch_sdk + +__all__ = ["ResourceManagementClient"] +__all__.extend([p for p in _patch_all if p not in __all__]) + +_patch_sdk() diff --git a/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/resources/v2018_02_01/_configuration.py b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/resources/v2018_02_01/_configuration.py index 11cb24e37e458..1c649d8743651 100644 --- a/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/resources/v2018_02_01/_configuration.py +++ b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/resources/v2018_02_01/_configuration.py @@ -25,23 +25,18 @@ class ResourceManagementClientConfiguration(Configuration): # pylint: disable=t Note that all parameters used to create this instance are saved as instance attributes. - :param credential: Credential needed for the client to connect to Azure. + :param credential: Credential needed for the client to connect to Azure. Required. :type credential: ~azure.core.credentials.TokenCredential - :param subscription_id: The ID of the target subscription. + :param subscription_id: The ID of the target subscription. Required. :type subscription_id: str :keyword api_version: Api Version. Default value is "2018-02-01". Note that overriding this default value may result in unsupported behavior. :paramtype api_version: str """ - def __init__( - self, - credential: "TokenCredential", - subscription_id: str, - **kwargs: Any - ) -> None: + def __init__(self, credential: "TokenCredential", subscription_id: str, **kwargs: Any) -> None: super(ResourceManagementClientConfiguration, self).__init__(**kwargs) - api_version = kwargs.pop('api_version', "2018-02-01") # type: str + api_version = kwargs.pop("api_version", "2018-02-01") # type: str if credential is None: raise ValueError("Parameter 'credential' must not be None.") @@ -51,23 +46,24 @@ def __init__( self.credential = credential self.subscription_id = subscription_id self.api_version = api_version - self.credential_scopes = kwargs.pop('credential_scopes', ['https://management.azure.com/.default']) - kwargs.setdefault('sdk_moniker', 'mgmt-resource/{}'.format(VERSION)) + self.credential_scopes = kwargs.pop("credential_scopes", ["https://management.azure.com/.default"]) + kwargs.setdefault("sdk_moniker", "mgmt-resource/{}".format(VERSION)) self._configure(**kwargs) def _configure( - self, - **kwargs # type: Any + self, **kwargs # type: Any ): # type: (...) -> 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) - self.logging_policy = kwargs.get('logging_policy') or policies.NetworkTraceLoggingPolicy(**kwargs) - self.http_logging_policy = kwargs.get('http_logging_policy') or ARMHttpLoggingPolicy(**kwargs) - self.retry_policy = kwargs.get('retry_policy') or policies.RetryPolicy(**kwargs) - self.custom_hook_policy = kwargs.get('custom_hook_policy') or policies.CustomHookPolicy(**kwargs) - self.redirect_policy = kwargs.get('redirect_policy') or policies.RedirectPolicy(**kwargs) - self.authentication_policy = kwargs.get('authentication_policy') + 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) + self.logging_policy = kwargs.get("logging_policy") or policies.NetworkTraceLoggingPolicy(**kwargs) + self.http_logging_policy = kwargs.get("http_logging_policy") or ARMHttpLoggingPolicy(**kwargs) + self.retry_policy = kwargs.get("retry_policy") or policies.RetryPolicy(**kwargs) + self.custom_hook_policy = kwargs.get("custom_hook_policy") or policies.CustomHookPolicy(**kwargs) + self.redirect_policy = kwargs.get("redirect_policy") or policies.RedirectPolicy(**kwargs) + self.authentication_policy = kwargs.get("authentication_policy") if self.credential and not self.authentication_policy: - self.authentication_policy = ARMChallengeAuthenticationPolicy(self.credential, *self.credential_scopes, **kwargs) + self.authentication_policy = ARMChallengeAuthenticationPolicy( + self.credential, *self.credential_scopes, **kwargs + ) diff --git a/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/resources/v2018_02_01/_metadata.json b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/resources/v2018_02_01/_metadata.json index e68a005ce110d..1d4857ee70cfd 100644 --- a/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/resources/v2018_02_01/_metadata.json +++ b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/resources/v2018_02_01/_metadata.json @@ -10,20 +10,20 @@ "azure_arm": true, "has_lro_operations": true, "client_side_validation": false, - "sync_imports": "{\"typing\": {\"azurecore\": {\"azure.core.credentials\": [\"TokenCredential\"]}}, \"regular\": {\"azurecore\": {\"azure.profiles\": [\"KnownProfiles\", \"ProfileDefinition\"], \"azure.profiles.multiapiclient\": [\"MultiApiClientMixin\"], \"azure.mgmt.core\": [\"ARMPipelineClient\"]}, \"local\": {\"._configuration\": [\"ResourceManagementClientConfiguration\"]}, \"thirdparty\": {\"msrest\": [\"Deserializer\", \"Serializer\"]}}, \"conditional\": {\"stdlib\": {\"typing\": [\"Any\", \"Optional\"]}}}", - "async_imports": "{\"typing\": {\"azurecore\": {\"azure.core.credentials_async\": [\"AsyncTokenCredential\"], \"azure.core.credentials\": [\"TokenCredential\"]}}, \"regular\": {\"azurecore\": {\"azure.profiles\": [\"KnownProfiles\", \"ProfileDefinition\"], \"azure.profiles.multiapiclient\": [\"MultiApiClientMixin\"], \"azure.mgmt.core\": [\"AsyncARMPipelineClient\"]}, \"local\": {\"._configuration\": [\"ResourceManagementClientConfiguration\"]}, \"thirdparty\": {\"msrest\": [\"Deserializer\", \"Serializer\"]}}, \"conditional\": {\"stdlib\": {\"typing\": [\"Any\", \"Optional\"]}}}" + "sync_imports": "{\"conditional\": {\"stdlib\": {\"typing\": [\"Any\", \"Optional\"]}}, \"regular\": {\"azurecore\": {\"azure.mgmt.core\": [\"ARMPipelineClient\"], \"azure.profiles\": [\"KnownProfiles\", \"ProfileDefinition\"], \"azure.profiles.multiapiclient\": [\"MultiApiClientMixin\"]}, \"local\": {\"._configuration\": [\"ResourceManagementClientConfiguration\"], \".._serialization\": [\"Deserializer\", \"Serializer\"]}}, \"typing\": {\"azurecore\": {\"azure.core.credentials\": [\"TokenCredential\"]}}}", + "async_imports": "{\"conditional\": {\"stdlib\": {\"typing\": [\"Any\", \"Optional\"]}}, \"regular\": {\"azurecore\": {\"azure.mgmt.core\": [\"AsyncARMPipelineClient\"], \"azure.profiles\": [\"KnownProfiles\", \"ProfileDefinition\"], \"azure.profiles.multiapiclient\": [\"MultiApiClientMixin\"]}, \"local\": {\"._configuration\": [\"ResourceManagementClientConfiguration\"], \"..._serialization\": [\"Deserializer\", \"Serializer\"]}}, \"typing\": {\"azurecore\": {\"azure.core.credentials_async\": [\"AsyncTokenCredential\"]}}}" }, "global_parameters": { "sync": { "credential": { - "signature": "credential, # type: \"TokenCredential\"", - "description": "Credential needed for the client to connect to Azure.", + "signature": "credential: \"TokenCredential\",", + "description": "Credential needed for the client to connect to Azure. Required.", "docstring_type": "~azure.core.credentials.TokenCredential", "required": true }, "subscription_id": { - "signature": "subscription_id, # type: str", - "description": "The ID of the target subscription.", + "signature": "subscription_id: str,", + "description": "The ID of the target subscription. Required.", "docstring_type": "str", "required": true } @@ -31,13 +31,13 @@ "async": { "credential": { "signature": "credential: \"AsyncTokenCredential\",", - "description": "Credential needed for the client to connect to Azure.", + "description": "Credential needed for the client to connect to Azure. Required.", "docstring_type": "~azure.core.credentials_async.AsyncTokenCredential", "required": true }, "subscription_id": { "signature": "subscription_id: str,", - "description": "The ID of the target subscription.", + "description": "The ID of the target subscription. Required.", "docstring_type": "str", "required": true } @@ -54,7 +54,7 @@ "required": false }, "base_url": { - "signature": "base_url=\"https://management.azure.com\", # type: str", + "signature": "base_url: str = \"https://management.azure.com\",", "description": "Service URL", "docstring_type": "str", "required": false diff --git a/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/resources/v2018_02_01/_patch.py b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/resources/v2018_02_01/_patch.py index 74e48ecd07cf3..f99e77fef9861 100644 --- a/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/resources/v2018_02_01/_patch.py +++ b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/resources/v2018_02_01/_patch.py @@ -28,4 +28,4 @@ # This file is used for handwritten extensions to the generated code. Example: # https://github.com/Azure/azure-sdk-for-python/blob/main/doc/dev/customize_code/how-to-patch-sdk-code.md def patch_sdk(): - pass \ No newline at end of file + pass diff --git a/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/resources/v2018_02_01/_resource_management_client.py b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/resources/v2018_02_01/_resource_management_client.py index 5f4fa377b2056..7c0c09ccc3fd9 100644 --- a/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/resources/v2018_02_01/_resource_management_client.py +++ b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/resources/v2018_02_01/_resource_management_client.py @@ -9,20 +9,27 @@ from copy import deepcopy from typing import Any, TYPE_CHECKING -from msrest import Deserializer, Serializer - from azure.core.rest import HttpRequest, HttpResponse from azure.mgmt.core import ARMPipelineClient from . import models +from .._serialization import Deserializer, Serializer from ._configuration import ResourceManagementClientConfiguration -from .operations import DeploymentOperationsOperations, DeploymentsOperations, ProvidersOperations, ResourceGroupsOperations, ResourcesOperations, TagsOperations +from .operations import ( + DeploymentOperationsOperations, + DeploymentsOperations, + ProvidersOperations, + ResourceGroupsOperations, + ResourcesOperations, + TagsOperations, +) if TYPE_CHECKING: # pylint: disable=unused-import,ungrouped-imports from azure.core.credentials import TokenCredential -class ResourceManagementClient: + +class ResourceManagementClient: # pylint: disable=client-accepts-api-version-keyword """Provides operations for working with resources and resource groups. :ivar deployments: DeploymentsOperations operations @@ -40,9 +47,9 @@ class ResourceManagementClient: :ivar deployment_operations: DeploymentOperationsOperations operations :vartype deployment_operations: azure.mgmt.resource.resources.v2018_02_01.operations.DeploymentOperationsOperations - :param credential: Credential needed for the client to connect to Azure. + :param credential: Credential needed for the client to connect to Azure. Required. :type credential: ~azure.core.credentials.TokenCredential - :param subscription_id: The ID of the target subscription. + :param subscription_id: The ID of the target subscription. Required. :type subscription_id: str :param base_url: Service URL. Default value is "https://management.azure.com". :type base_url: str @@ -60,7 +67,9 @@ def __init__( base_url: str = "https://management.azure.com", **kwargs: Any ) -> None: - self._config = ResourceManagementClientConfiguration(credential=credential, subscription_id=subscription_id, **kwargs) + self._config = ResourceManagementClientConfiguration( + credential=credential, subscription_id=subscription_id, **kwargs + ) self._client = ARMPipelineClient(base_url=base_url, config=self._config, **kwargs) client_models = {k: v for k, v in models.__dict__.items() if isinstance(v, type)} @@ -72,14 +81,11 @@ def __init__( self.resources = ResourcesOperations(self._client, self._config, self._serialize, self._deserialize) self.resource_groups = ResourceGroupsOperations(self._client, self._config, self._serialize, self._deserialize) self.tags = TagsOperations(self._client, self._config, self._serialize, self._deserialize) - self.deployment_operations = DeploymentOperationsOperations(self._client, self._config, self._serialize, self._deserialize) - + self.deployment_operations = DeploymentOperationsOperations( + self._client, self._config, self._serialize, self._deserialize + ) - def _send_request( - self, - request: HttpRequest, - **kwargs: Any - ) -> HttpResponse: + def _send_request(self, request: HttpRequest, **kwargs: Any) -> HttpResponse: """Runs the network request through the client's chained policies. >>> from azure.core.rest import HttpRequest @@ -88,7 +94,7 @@ def _send_request( >>> response = client._send_request(request) - For more information on this code flow, see https://aka.ms/azsdk/python/protocol/quickstart + For more information on this code flow, see https://aka.ms/azsdk/dpcodegen/python/send_request :param request: The network request you want to make. Required. :type request: ~azure.core.rest.HttpRequest diff --git a/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/resources/v2018_02_01/_vendor.py b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/resources/v2018_02_01/_vendor.py index 138f663c53a4e..9aad73fc743e7 100644 --- a/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/resources/v2018_02_01/_vendor.py +++ b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/resources/v2018_02_01/_vendor.py @@ -7,6 +7,7 @@ from azure.core.pipeline.transport import HttpRequest + def _convert_request(request, files=None): data = request.content if not files else None request = HttpRequest(method=request.method, url=request.url, headers=request.headers, data=data) @@ -14,6 +15,7 @@ def _convert_request(request, files=None): request.set_formdata_body(files) return request + def _format_url_section(template, **kwargs): components = template.split("/") while components: @@ -21,7 +23,5 @@ def _format_url_section(template, **kwargs): 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 - ] + components = [c for c in formatted_components if "{}".format(key.args[0]) not in c] template = "/".join(components) diff --git a/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/resources/v2018_02_01/_version.py b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/resources/v2018_02_01/_version.py index a012ac01c480c..e5754a47ce68f 100644 --- a/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/resources/v2018_02_01/_version.py +++ b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/resources/v2018_02_01/_version.py @@ -6,4 +6,4 @@ # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -VERSION = "21.1.0" +VERSION = "1.0.0b1" diff --git a/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/resources/v2018_02_01/aio/__init__.py b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/resources/v2018_02_01/aio/__init__.py index c6c3cf64a37a6..98d6782c2530c 100644 --- a/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/resources/v2018_02_01/aio/__init__.py +++ b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/resources/v2018_02_01/aio/__init__.py @@ -7,9 +7,15 @@ # -------------------------------------------------------------------------- from ._resource_management_client import ResourceManagementClient -__all__ = ['ResourceManagementClient'] -# `._patch.py` is used for handwritten extensions to the generated code -# Example: https://github.com/Azure/azure-sdk-for-python/blob/main/doc/dev/customize_code/how-to-patch-sdk-code.md -from ._patch import patch_sdk -patch_sdk() +try: + from ._patch import __all__ as _patch_all + from ._patch import * # type: ignore # pylint: disable=unused-wildcard-import +except ImportError: + _patch_all = [] +from ._patch import patch_sdk as _patch_sdk + +__all__ = ["ResourceManagementClient"] +__all__.extend([p for p in _patch_all if p not in __all__]) + +_patch_sdk() diff --git a/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/resources/v2018_02_01/aio/_configuration.py b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/resources/v2018_02_01/aio/_configuration.py index 9dfe270318d62..2225991801dc0 100644 --- a/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/resources/v2018_02_01/aio/_configuration.py +++ b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/resources/v2018_02_01/aio/_configuration.py @@ -25,23 +25,18 @@ class ResourceManagementClientConfiguration(Configuration): # pylint: disable=t Note that all parameters used to create this instance are saved as instance attributes. - :param credential: Credential needed for the client to connect to Azure. + :param credential: Credential needed for the client to connect to Azure. Required. :type credential: ~azure.core.credentials_async.AsyncTokenCredential - :param subscription_id: The ID of the target subscription. + :param subscription_id: The ID of the target subscription. Required. :type subscription_id: str :keyword api_version: Api Version. Default value is "2018-02-01". Note that overriding this default value may result in unsupported behavior. :paramtype api_version: str """ - def __init__( - self, - credential: "AsyncTokenCredential", - subscription_id: str, - **kwargs: Any - ) -> None: + def __init__(self, credential: "AsyncTokenCredential", subscription_id: str, **kwargs: Any) -> None: super(ResourceManagementClientConfiguration, self).__init__(**kwargs) - api_version = kwargs.pop('api_version', "2018-02-01") # type: str + api_version = kwargs.pop("api_version", "2018-02-01") # type: str if credential is None: raise ValueError("Parameter 'credential' must not be None.") @@ -51,22 +46,21 @@ def __init__( self.credential = credential self.subscription_id = subscription_id self.api_version = api_version - self.credential_scopes = kwargs.pop('credential_scopes', ['https://management.azure.com/.default']) - kwargs.setdefault('sdk_moniker', 'mgmt-resource/{}'.format(VERSION)) + self.credential_scopes = kwargs.pop("credential_scopes", ["https://management.azure.com/.default"]) + kwargs.setdefault("sdk_moniker", "mgmt-resource/{}".format(VERSION)) self._configure(**kwargs) - 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) - self.logging_policy = kwargs.get('logging_policy') or policies.NetworkTraceLoggingPolicy(**kwargs) - self.http_logging_policy = kwargs.get('http_logging_policy') or ARMHttpLoggingPolicy(**kwargs) - self.retry_policy = kwargs.get('retry_policy') or policies.AsyncRetryPolicy(**kwargs) - self.custom_hook_policy = kwargs.get('custom_hook_policy') or policies.CustomHookPolicy(**kwargs) - self.redirect_policy = kwargs.get('redirect_policy') or policies.AsyncRedirectPolicy(**kwargs) - self.authentication_policy = kwargs.get('authentication_policy') + 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) + self.logging_policy = kwargs.get("logging_policy") or policies.NetworkTraceLoggingPolicy(**kwargs) + self.http_logging_policy = kwargs.get("http_logging_policy") or ARMHttpLoggingPolicy(**kwargs) + self.retry_policy = kwargs.get("retry_policy") or policies.AsyncRetryPolicy(**kwargs) + self.custom_hook_policy = kwargs.get("custom_hook_policy") or policies.CustomHookPolicy(**kwargs) + self.redirect_policy = kwargs.get("redirect_policy") or policies.AsyncRedirectPolicy(**kwargs) + self.authentication_policy = kwargs.get("authentication_policy") if self.credential and not self.authentication_policy: - self.authentication_policy = AsyncARMChallengeAuthenticationPolicy(self.credential, *self.credential_scopes, **kwargs) + self.authentication_policy = AsyncARMChallengeAuthenticationPolicy( + self.credential, *self.credential_scopes, **kwargs + ) diff --git a/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/resources/v2018_02_01/aio/_patch.py b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/resources/v2018_02_01/aio/_patch.py index 74e48ecd07cf3..f99e77fef9861 100644 --- a/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/resources/v2018_02_01/aio/_patch.py +++ b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/resources/v2018_02_01/aio/_patch.py @@ -28,4 +28,4 @@ # This file is used for handwritten extensions to the generated code. Example: # https://github.com/Azure/azure-sdk-for-python/blob/main/doc/dev/customize_code/how-to-patch-sdk-code.md def patch_sdk(): - pass \ No newline at end of file + pass diff --git a/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/resources/v2018_02_01/aio/_resource_management_client.py b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/resources/v2018_02_01/aio/_resource_management_client.py index cd805e54bb910..099ef29335df5 100644 --- a/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/resources/v2018_02_01/aio/_resource_management_client.py +++ b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/resources/v2018_02_01/aio/_resource_management_client.py @@ -9,20 +9,27 @@ from copy import deepcopy from typing import Any, Awaitable, TYPE_CHECKING -from msrest import Deserializer, Serializer - from azure.core.rest import AsyncHttpResponse, HttpRequest from azure.mgmt.core import AsyncARMPipelineClient from .. import models +from ..._serialization import Deserializer, Serializer from ._configuration import ResourceManagementClientConfiguration -from .operations import DeploymentOperationsOperations, DeploymentsOperations, ProvidersOperations, ResourceGroupsOperations, ResourcesOperations, TagsOperations +from .operations import ( + DeploymentOperationsOperations, + DeploymentsOperations, + ProvidersOperations, + ResourceGroupsOperations, + ResourcesOperations, + TagsOperations, +) if TYPE_CHECKING: # pylint: disable=unused-import,ungrouped-imports from azure.core.credentials_async import AsyncTokenCredential -class ResourceManagementClient: + +class ResourceManagementClient: # pylint: disable=client-accepts-api-version-keyword """Provides operations for working with resources and resource groups. :ivar deployments: DeploymentsOperations operations @@ -42,9 +49,9 @@ class ResourceManagementClient: :ivar deployment_operations: DeploymentOperationsOperations operations :vartype deployment_operations: azure.mgmt.resource.resources.v2018_02_01.aio.operations.DeploymentOperationsOperations - :param credential: Credential needed for the client to connect to Azure. + :param credential: Credential needed for the client to connect to Azure. Required. :type credential: ~azure.core.credentials_async.AsyncTokenCredential - :param subscription_id: The ID of the target subscription. + :param subscription_id: The ID of the target subscription. Required. :type subscription_id: str :param base_url: Service URL. Default value is "https://management.azure.com". :type base_url: str @@ -62,7 +69,9 @@ def __init__( base_url: str = "https://management.azure.com", **kwargs: Any ) -> None: - self._config = ResourceManagementClientConfiguration(credential=credential, subscription_id=subscription_id, **kwargs) + self._config = ResourceManagementClientConfiguration( + credential=credential, subscription_id=subscription_id, **kwargs + ) self._client = AsyncARMPipelineClient(base_url=base_url, config=self._config, **kwargs) client_models = {k: v for k, v in models.__dict__.items() if isinstance(v, type)} @@ -74,14 +83,11 @@ def __init__( self.resources = ResourcesOperations(self._client, self._config, self._serialize, self._deserialize) self.resource_groups = ResourceGroupsOperations(self._client, self._config, self._serialize, self._deserialize) self.tags = TagsOperations(self._client, self._config, self._serialize, self._deserialize) - self.deployment_operations = DeploymentOperationsOperations(self._client, self._config, self._serialize, self._deserialize) - + self.deployment_operations = DeploymentOperationsOperations( + self._client, self._config, self._serialize, self._deserialize + ) - def _send_request( - self, - request: HttpRequest, - **kwargs: Any - ) -> Awaitable[AsyncHttpResponse]: + def _send_request(self, request: HttpRequest, **kwargs: Any) -> Awaitable[AsyncHttpResponse]: """Runs the network request through the client's chained policies. >>> from azure.core.rest import HttpRequest @@ -90,7 +96,7 @@ def _send_request( >>> response = await client._send_request(request) - For more information on this code flow, see https://aka.ms/azsdk/python/protocol/quickstart + For more information on this code flow, see https://aka.ms/azsdk/dpcodegen/python/send_request :param request: The network request you want to make. Required. :type request: ~azure.core.rest.HttpRequest diff --git a/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/resources/v2018_02_01/aio/operations/__init__.py b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/resources/v2018_02_01/aio/operations/__init__.py index 45c6c8515ee40..25795ec366414 100644 --- a/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/resources/v2018_02_01/aio/operations/__init__.py +++ b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/resources/v2018_02_01/aio/operations/__init__.py @@ -13,11 +13,17 @@ from ._operations import TagsOperations from ._operations import DeploymentOperationsOperations +from ._patch import __all__ as _patch_all +from ._patch import * # type: ignore # pylint: disable=unused-wildcard-import +from ._patch import patch_sdk as _patch_sdk + __all__ = [ - 'DeploymentsOperations', - 'ProvidersOperations', - 'ResourcesOperations', - 'ResourceGroupsOperations', - 'TagsOperations', - 'DeploymentOperationsOperations', + "DeploymentsOperations", + "ProvidersOperations", + "ResourcesOperations", + "ResourceGroupsOperations", + "TagsOperations", + "DeploymentOperationsOperations", ] +__all__.extend([p for p in _patch_all if p not in __all__]) +_patch_sdk() diff --git a/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/resources/v2018_02_01/aio/operations/_operations.py b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/resources/v2018_02_01/aio/operations/_operations.py index 2e26bd1f824da..f4cb3f8194644 100644 --- a/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/resources/v2018_02_01/aio/operations/_operations.py +++ b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/resources/v2018_02_01/aio/operations/_operations.py @@ -6,77 +6,136 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -from typing import Any, AsyncIterable, Callable, Dict, Optional, TypeVar, Union +import sys +from typing import Any, AsyncIterable, Callable, Dict, IO, Optional, TypeVar, Union, cast, overload +from urllib.parse import parse_qs, urljoin, urlparse from azure.core.async_paging import AsyncItemPaged, AsyncList -from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error +from azure.core.exceptions import ( + ClientAuthenticationError, + HttpResponseError, + ResourceExistsError, + ResourceNotFoundError, + ResourceNotModifiedError, + map_error, +) from azure.core.pipeline import PipelineResponse from azure.core.pipeline.transport import AsyncHttpResponse from azure.core.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 from azure.mgmt.core.polling.async_arm_polling import AsyncARMPolling from ... import models as _models from ..._vendor import _convert_request -from ...operations._operations import build_deployment_operations_get_request, build_deployment_operations_list_request, build_deployments_calculate_template_hash_request, build_deployments_cancel_request, build_deployments_check_existence_request, build_deployments_create_or_update_request_initial, build_deployments_delete_request_initial, build_deployments_export_template_request, build_deployments_get_request, build_deployments_list_by_resource_group_request, build_deployments_validate_request, build_providers_get_request, build_providers_list_request, build_providers_register_request, build_providers_unregister_request, build_resource_groups_check_existence_request, build_resource_groups_create_or_update_request, build_resource_groups_delete_request_initial, build_resource_groups_export_template_request, build_resource_groups_get_request, build_resource_groups_list_request, build_resource_groups_update_request, build_resources_check_existence_by_id_request, build_resources_check_existence_request, build_resources_create_or_update_by_id_request_initial, build_resources_create_or_update_request_initial, build_resources_delete_by_id_request_initial, build_resources_delete_request_initial, build_resources_get_by_id_request, build_resources_get_request, build_resources_list_by_resource_group_request, build_resources_list_request, build_resources_move_resources_request_initial, build_resources_update_by_id_request_initial, build_resources_update_request_initial, build_resources_validate_move_resources_request_initial, build_tags_create_or_update_request, build_tags_create_or_update_value_request, build_tags_delete_request, build_tags_delete_value_request, build_tags_list_request -T = TypeVar('T') +from ...operations._operations import ( + build_deployment_operations_get_request, + build_deployment_operations_list_request, + build_deployments_calculate_template_hash_request, + build_deployments_cancel_request, + build_deployments_check_existence_request, + build_deployments_create_or_update_request, + build_deployments_delete_request, + build_deployments_export_template_request, + build_deployments_get_request, + build_deployments_list_by_resource_group_request, + build_deployments_validate_request, + build_providers_get_request, + build_providers_list_request, + build_providers_register_request, + build_providers_unregister_request, + build_resource_groups_check_existence_request, + build_resource_groups_create_or_update_request, + build_resource_groups_delete_request, + build_resource_groups_export_template_request, + build_resource_groups_get_request, + build_resource_groups_list_request, + build_resource_groups_update_request, + build_resources_check_existence_by_id_request, + build_resources_check_existence_request, + build_resources_create_or_update_by_id_request, + build_resources_create_or_update_request, + build_resources_delete_by_id_request, + build_resources_delete_request, + build_resources_get_by_id_request, + build_resources_get_request, + build_resources_list_by_resource_group_request, + build_resources_list_request, + build_resources_move_resources_request, + build_resources_update_by_id_request, + build_resources_update_request, + build_resources_validate_move_resources_request, + build_tags_create_or_update_request, + build_tags_create_or_update_value_request, + build_tags_delete_request, + build_tags_delete_value_request, + build_tags_list_request, +) + +if sys.version_info >= (3, 9): + from collections.abc import MutableMapping +else: + from typing import MutableMapping # type: ignore # pylint: disable=ungrouped-imports +JSON = MutableMapping[str, Any] # pylint: disable=unsubscriptable-object +T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] -class DeploymentsOperations: - """DeploymentsOperations async operations. - You should not instantiate this class directly. Instead, you should create a Client instance that - instantiates it for you and attaches it as an attribute. +class DeploymentsOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. - :ivar models: Alias to model classes used in this operation group. - :type models: ~azure.mgmt.resource.resources.v2018_02_01.models - :param client: Client for service requests. - :param config: Configuration of service client. - :param serializer: An object model serializer. - :param deserializer: An object model deserializer. + Instead, you should access the following operations through + :class:`~azure.mgmt.resource.resources.v2018_02_01.aio.ResourceManagementClient`'s + :attr:`deployments` attribute. """ models = _models - def __init__(self, client, config, serializer, deserializer) -> None: - self._client = client - self._serialize = serializer - self._deserialize = deserializer - self._config = config + def __init__(self, *args, **kwargs) -> None: + input_args = list(args) + self._client = input_args.pop(0) if input_args else kwargs.pop("client") + self._config = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") async def _delete_initial( # pylint: disable=inconsistent-return-statements - self, - resource_group_name: str, - deployment_name: str, - **kwargs: Any + self, resource_group_name: str, deployment_name: str, **kwargs: Any ) -> None: - cls = kwargs.pop('cls', None) # type: ClsType[None] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + 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', "2018-02-01") # type: str + api_version = kwargs.pop("api_version", _params.pop("api-version", "2018-02-01")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[None] - - request = build_deployments_delete_request_initial( + request = build_deployments_delete_request( resource_group_name=resource_group_name, deployment_name=deployment_name, subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self._delete_initial.metadata['url'], + template_url=self._delete_initial.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [202, 204]: @@ -86,16 +145,10 @@ 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.Resources/deployments/{deploymentName}"} # type: ignore - + _delete_initial.metadata = {"url": "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/Microsoft.Resources/deployments/{deploymentName}"} # type: ignore @distributed_trace_async - async def begin_delete( # pylint: disable=inconsistent-return-statements - self, - resource_group_name: str, - deployment_name: str, - **kwargs: Any - ) -> AsyncLROPoller[None]: + async def begin_delete(self, resource_group_name: str, deployment_name: str, **kwargs: Any) -> AsyncLROPoller[None]: """Deletes a deployment from the deployment history. A template deployment that is currently running cannot be deleted. Deleting a template @@ -108,9 +161,9 @@ async def begin_delete( # pylint: disable=inconsistent-return-statements asynchronous request failed, the URI in the Location header returns an error-level status code. :param resource_group_name: The name of the resource group with the deployment to delete. The - name is case insensitive. + name is case insensitive. Required. :type resource_group_name: str - :param deployment_name: The name of the deployment to delete. + :param deployment_name: The name of the deployment to delete. Required. :type deployment_name: str :keyword callable cls: A custom type or function that will be passed the direct response :keyword str continuation_token: A continuation token to restart a poller from a saved state. @@ -122,88 +175,93 @@ async def begin_delete( # pylint: disable=inconsistent-return-statements Retry-After header is present. :return: An instance of AsyncLROPoller that returns either None or the result of cls(response) :rtype: ~azure.core.polling.AsyncLROPoller[None] - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - api_version = kwargs.pop('api_version', "2018-02-01") # type: str - polling = kwargs.pop('polling', True) # type: Union[bool, AsyncPollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType[None] - lro_delay = kwargs.pop( - 'polling_interval', - self._config.polling_interval - ) - cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2018-02-01")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[None] + polling = kwargs.pop("polling", True) # type: Union[bool, AsyncPollingMethod] + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token = kwargs.pop("continuation_token", None) # type: Optional[str] if cont_token is None: - raw_result = await self._delete_initial( + raw_result = await self._delete_initial( # type: ignore resource_group_name=resource_group_name, deployment_name=deployment_name, api_version=api_version, - cls=lambda x,y,z: x, + cls=lambda x, y, z: x, + headers=_headers, + params=_params, **kwargs ) - kwargs.pop('error_map', None) + kwargs.pop("error_map", None) - def get_long_running_output(pipeline_response): + def get_long_running_output(pipeline_response): # pylint: disable=inconsistent-return-statements if cls: return cls(pipeline_response, None, {}) - - if polling is True: polling_method = AsyncARMPolling(lro_delay, **kwargs) - elif polling is False: polling_method = AsyncNoPolling() - else: polling_method = polling + if polling is True: + polling_method = cast(AsyncPollingMethod, AsyncARMPolling(lro_delay, **kwargs)) # type: AsyncPollingMethod + elif polling is False: + polling_method = cast(AsyncPollingMethod, AsyncNoPolling()) + else: + polling_method = polling if cont_token: return AsyncLROPoller.from_continuation_token( polling_method=polling_method, continuation_token=cont_token, client=self._client, - deserialization_callback=get_long_running_output + deserialization_callback=get_long_running_output, ) return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) - begin_delete.metadata = {'url': "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/Microsoft.Resources/deployments/{deploymentName}"} # type: ignore + begin_delete.metadata = {"url": "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/Microsoft.Resources/deployments/{deploymentName}"} # type: ignore @distributed_trace_async - async def check_existence( - self, - resource_group_name: str, - deployment_name: str, - **kwargs: Any - ) -> bool: + async def check_existence(self, resource_group_name: str, deployment_name: str, **kwargs: Any) -> bool: """Checks whether the deployment exists. :param resource_group_name: The name of the resource group with the deployment to check. The - name is case insensitive. + name is case insensitive. Required. :type resource_group_name: str - :param deployment_name: The name of the deployment to check. + :param deployment_name: The name of the deployment to check. Required. :type deployment_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: bool, or the result of cls(response) + :return: bool or the result of cls(response) :rtype: bool - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType[None] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + 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', "2018-02-01") # type: str + api_version = kwargs.pop("api_version", _params.pop("api-version", "2018-02-01")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[None] - request = build_deployments_check_existence_request( resource_group_name=resource_group_name, deployment_name=deployment_name, subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.check_existence.metadata['url'], + template_url=self.check_existence.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [204, 404]: @@ -214,44 +272,53 @@ async def check_existence( return cls(pipeline_response, None, {}) return 200 <= response.status_code <= 299 - check_existence.metadata = {'url': "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/Microsoft.Resources/deployments/{deploymentName}"} # type: ignore - + check_existence.metadata = {"url": "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/Microsoft.Resources/deployments/{deploymentName}"} # type: ignore async def _create_or_update_initial( - self, - resource_group_name: str, - deployment_name: str, - parameters: "_models.Deployment", - **kwargs: Any - ) -> "_models.DeploymentExtended": - cls = kwargs.pop('cls', None) # type: ClsType["_models.DeploymentExtended"] + self, resource_group_name: str, deployment_name: str, parameters: Union[_models.Deployment, IO], **kwargs: Any + ) -> _models.DeploymentExtended: error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) - api_version = kwargs.pop('api_version', "2018-02-01") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - _json = self._serialize.body(parameters, 'Deployment') + api_version = kwargs.pop("api_version", _params.pop("api-version", "2018-02-01")) # type: str + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.DeploymentExtended] - request = build_deployments_create_or_update_request_initial( + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(parameters, (IO, bytes)): + _content = parameters + else: + _json = self._serialize.body(parameters, "Deployment") + + request = build_deployments_create_or_update_request( resource_group_name=resource_group_name, deployment_name=deployment_name, subscription_id=self._config.subscription_id, api_version=api_version, content_type=content_type, json=_json, - template_url=self._create_or_update_initial.metadata['url'], + content=_content, + template_url=self._create_or_update_initial.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200, 201]: @@ -259,38 +326,115 @@ async def _create_or_update_initial( raise HttpResponseError(response=response, error_format=ARMErrorFormat) if response.status_code == 200: - deserialized = self._deserialize('DeploymentExtended', pipeline_response) + deserialized = self._deserialize("DeploymentExtended", pipeline_response) if response.status_code == 201: - deserialized = self._deserialize('DeploymentExtended', pipeline_response) + deserialized = self._deserialize("DeploymentExtended", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - _create_or_update_initial.metadata = {'url': "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/Microsoft.Resources/deployments/{deploymentName}"} # type: ignore + _create_or_update_initial.metadata = {"url": "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/Microsoft.Resources/deployments/{deploymentName}"} # type: ignore - - @distributed_trace_async + @overload async def begin_create_or_update( self, resource_group_name: str, deployment_name: str, - parameters: "_models.Deployment", + parameters: _models.Deployment, + *, + content_type: str = "application/json", **kwargs: Any - ) -> AsyncLROPoller["_models.DeploymentExtended"]: + ) -> AsyncLROPoller[_models.DeploymentExtended]: """Deploys resources to a resource group. You can provide the template and parameters directly in the request or link to JSON files. :param resource_group_name: The name of the resource group to deploy the resources to. The name - is case insensitive. The resource group must already exist. + is case insensitive. The resource group must already exist. Required. :type resource_group_name: str - :param deployment_name: The name of the deployment. + :param deployment_name: The name of the deployment. Required. :type deployment_name: str - :param parameters: Additional parameters supplied to the operation. + :param parameters: Additional parameters supplied to the operation. Required. :type parameters: ~azure.mgmt.resource.resources.v2018_02_01.models.Deployment + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be AsyncARMPolling. Pass in False for + this operation to not poll, or pass in your own initialized polling object for a personal + polling strategy. + :paramtype polling: bool or ~azure.core.polling.AsyncPollingMethod + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of AsyncLROPoller that returns either DeploymentExtended or the result of + cls(response) + :rtype: + ~azure.core.polling.AsyncLROPoller[~azure.mgmt.resource.resources.v2018_02_01.models.DeploymentExtended] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + async def begin_create_or_update( + self, + resource_group_name: str, + deployment_name: str, + parameters: IO, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> AsyncLROPoller[_models.DeploymentExtended]: + """Deploys resources to a resource group. + + You can provide the template and parameters directly in the request or link to JSON files. + + :param resource_group_name: The name of the resource group to deploy the resources to. The name + is case insensitive. The resource group must already exist. Required. + :type resource_group_name: str + :param deployment_name: The name of the deployment. Required. + :type deployment_name: str + :param parameters: Additional parameters supplied to the operation. Required. + :type parameters: IO + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be AsyncARMPolling. Pass in False for + this operation to not poll, or pass in your own initialized polling object for a personal + polling strategy. + :paramtype polling: bool or ~azure.core.polling.AsyncPollingMethod + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of AsyncLROPoller that returns either DeploymentExtended or the result of + cls(response) + :rtype: + ~azure.core.polling.AsyncLROPoller[~azure.mgmt.resource.resources.v2018_02_01.models.DeploymentExtended] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace_async + async def begin_create_or_update( + self, resource_group_name: str, deployment_name: str, parameters: Union[_models.Deployment, IO], **kwargs: Any + ) -> AsyncLROPoller[_models.DeploymentExtended]: + """Deploys resources to a resource group. + + You can provide the template and parameters directly in the request or link to JSON files. + + :param resource_group_name: The name of the resource group to deploy the resources to. The name + is case insensitive. The resource group must already exist. Required. + :type resource_group_name: str + :param deployment_name: The name of the deployment. Required. + :type deployment_name: str + :param parameters: Additional parameters supplied to the operation. Is either a model type or a + IO type. Required. + :type parameters: ~azure.mgmt.resource.resources.v2018_02_01.models.Deployment or IO + :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. + Default value is None. + :paramtype content_type: str :keyword callable cls: A custom type or function that will be passed the direct response :keyword str continuation_token: A continuation token to restart a poller from a saved state. :keyword polling: By default, your polling method will be AsyncARMPolling. Pass in False for @@ -303,115 +447,116 @@ async def begin_create_or_update( cls(response) :rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.resource.resources.v2018_02_01.models.DeploymentExtended] - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - api_version = kwargs.pop('api_version', "2018-02-01") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] - polling = kwargs.pop('polling', True) # type: Union[bool, AsyncPollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType["_models.DeploymentExtended"] - lro_delay = kwargs.pop( - 'polling_interval', - self._config.polling_interval - ) - cont_token = kwargs.pop('continuation_token', None) # type: Optional[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", "2018-02-01")) # type: str + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.DeploymentExtended] + polling = kwargs.pop("polling", True) # type: Union[bool, AsyncPollingMethod] + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token = kwargs.pop("continuation_token", None) # type: Optional[str] if cont_token is None: - raw_result = await self._create_or_update_initial( + raw_result = await self._create_or_update_initial( # type: ignore resource_group_name=resource_group_name, deployment_name=deployment_name, parameters=parameters, api_version=api_version, content_type=content_type, - cls=lambda x,y,z: x, + cls=lambda x, y, z: x, + headers=_headers, + params=_params, **kwargs ) - kwargs.pop('error_map', None) + kwargs.pop("error_map", None) def get_long_running_output(pipeline_response): - response = pipeline_response.http_response - deserialized = self._deserialize('DeploymentExtended', pipeline_response) + deserialized = self._deserialize("DeploymentExtended", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - - if polling is True: polling_method = AsyncARMPolling(lro_delay, **kwargs) - elif polling is False: polling_method = AsyncNoPolling() - else: polling_method = polling + if polling is True: + polling_method = cast(AsyncPollingMethod, AsyncARMPolling(lro_delay, **kwargs)) # type: AsyncPollingMethod + elif polling is False: + polling_method = cast(AsyncPollingMethod, AsyncNoPolling()) + else: + polling_method = polling if cont_token: return AsyncLROPoller.from_continuation_token( polling_method=polling_method, continuation_token=cont_token, client=self._client, - deserialization_callback=get_long_running_output + deserialization_callback=get_long_running_output, ) return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) - begin_create_or_update.metadata = {'url': "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/Microsoft.Resources/deployments/{deploymentName}"} # type: ignore + begin_create_or_update.metadata = {"url": "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/Microsoft.Resources/deployments/{deploymentName}"} # type: ignore @distributed_trace_async - async def get( - self, - resource_group_name: str, - deployment_name: str, - **kwargs: Any - ) -> "_models.DeploymentExtended": + async def get(self, resource_group_name: str, deployment_name: str, **kwargs: Any) -> _models.DeploymentExtended: """Gets a deployment. :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. :type resource_group_name: str - :param deployment_name: The name of the deployment to get. + :param deployment_name: The name of the deployment to get. Required. :type deployment_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: DeploymentExtended, or the result of cls(response) + :return: DeploymentExtended or the result of cls(response) :rtype: ~azure.mgmt.resource.resources.v2018_02_01.models.DeploymentExtended - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.DeploymentExtended"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + 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', "2018-02-01") # type: str + api_version = kwargs.pop("api_version", _params.pop("api-version", "2018-02-01")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[_models.DeploymentExtended] - request = build_deployments_get_request( resource_group_name=resource_group_name, deployment_name=deployment_name, subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.get.metadata['url'], + template_url=self.get.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) - deserialized = self._deserialize('DeploymentExtended', pipeline_response) + deserialized = self._deserialize("DeploymentExtended", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - get.metadata = {'url': "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/Microsoft.Resources/deployments/{deploymentName}"} # type: ignore - + get.metadata = {"url": "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/Microsoft.Resources/deployments/{deploymentName}"} # type: ignore @distributed_trace_async async def cancel( # pylint: disable=inconsistent-return-statements - self, - resource_group_name: str, - deployment_name: str, - **kwargs: Any + self, resource_group_name: str, deployment_name: str, **kwargs: Any ) -> None: """Cancels a currently running template deployment. @@ -421,38 +566,45 @@ async def cancel( # pylint: disable=inconsistent-return-statements partially deployed. :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. :type resource_group_name: str - :param deployment_name: The name of the deployment to cancel. + :param deployment_name: The name of the deployment to cancel. Required. :type deployment_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: None, or the result of cls(response) + :return: None or the result of cls(response) :rtype: None - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType[None] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) - api_version = kwargs.pop('api_version', "2018-02-01") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2018-02-01")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[None] - request = build_deployments_cancel_request( resource_group_name=resource_group_name, deployment_name=deployment_name, subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.cancel.metadata['url'], + template_url=self.cancel.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [204]: @@ -462,42 +614,110 @@ async def cancel( # pylint: disable=inconsistent-return-statements if cls: return cls(pipeline_response, None, {}) - cancel.metadata = {'url': "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/Microsoft.Resources/deployments/{deploymentName}/cancel"} # type: ignore + cancel.metadata = {"url": "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/Microsoft.Resources/deployments/{deploymentName}/cancel"} # type: ignore - - @distributed_trace_async + @overload async def validate( self, resource_group_name: str, deployment_name: str, - parameters: "_models.Deployment", + parameters: _models.Deployment, + *, + content_type: str = "application/json", **kwargs: Any - ) -> "_models.DeploymentValidateResult": + ) -> _models.DeploymentValidateResult: """Validates whether the specified template is syntactically correct and will be accepted by Azure Resource Manager.. :param resource_group_name: The name of the resource group the template will be deployed to. - The name is case insensitive. + The name is case insensitive. Required. :type resource_group_name: str - :param deployment_name: The name of the deployment. + :param deployment_name: The name of the deployment. Required. :type deployment_name: str - :param parameters: Parameters to validate. + :param parameters: Parameters to validate. Required. :type parameters: ~azure.mgmt.resource.resources.v2018_02_01.models.Deployment + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: DeploymentValidateResult or the result of cls(response) + :rtype: ~azure.mgmt.resource.resources.v2018_02_01.models.DeploymentValidateResult + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + async def validate( + self, + resource_group_name: str, + deployment_name: str, + parameters: IO, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.DeploymentValidateResult: + """Validates whether the specified template is syntactically correct and will be accepted by Azure + Resource Manager.. + + :param resource_group_name: The name of the resource group the template will be deployed to. + The name is case insensitive. Required. + :type resource_group_name: str + :param deployment_name: The name of the deployment. Required. + :type deployment_name: str + :param parameters: Parameters to validate. Required. + :type parameters: IO + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: DeploymentValidateResult or the result of cls(response) + :rtype: ~azure.mgmt.resource.resources.v2018_02_01.models.DeploymentValidateResult + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace_async + async def validate( + self, resource_group_name: str, deployment_name: str, parameters: Union[_models.Deployment, IO], **kwargs: Any + ) -> _models.DeploymentValidateResult: + """Validates whether the specified template is syntactically correct and will be accepted by Azure + Resource Manager.. + + :param resource_group_name: The name of the resource group the template will be deployed to. + The name is case insensitive. Required. + :type resource_group_name: str + :param deployment_name: The name of the deployment. Required. + :type deployment_name: str + :param parameters: Parameters to validate. Is either a model type or a IO type. Required. + :type parameters: ~azure.mgmt.resource.resources.v2018_02_01.models.Deployment or IO + :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. + Default value is None. + :paramtype content_type: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: DeploymentValidateResult, or the result of cls(response) + :return: DeploymentValidateResult or the result of cls(response) :rtype: ~azure.mgmt.resource.resources.v2018_02_01.models.DeploymentValidateResult - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.DeploymentValidateResult"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) - api_version = kwargs.pop('api_version', "2018-02-01") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - _json = self._serialize.body(parameters, 'Deployment') + api_version = kwargs.pop("api_version", _params.pop("api-version", "2018-02-01")) # type: str + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.DeploymentValidateResult] + + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(parameters, (IO, bytes)): + _content = parameters + else: + _json = self._serialize.body(parameters, "Deployment") request = build_deployments_validate_request( resource_group_name=resource_group_name, @@ -506,16 +726,18 @@ async def validate( api_version=api_version, content_type=content_type, json=_json, - template_url=self.validate.metadata['url'], + content=_content, + template_url=self.validate.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200, 400]: @@ -523,89 +745,87 @@ async def validate( raise HttpResponseError(response=response, error_format=ARMErrorFormat) if response.status_code == 200: - deserialized = self._deserialize('DeploymentValidateResult', pipeline_response) + deserialized = self._deserialize("DeploymentValidateResult", pipeline_response) if response.status_code == 400: - deserialized = self._deserialize('DeploymentValidateResult', pipeline_response) + deserialized = self._deserialize("DeploymentValidateResult", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - validate.metadata = {'url': "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/Microsoft.Resources/deployments/{deploymentName}/validate"} # type: ignore - + validate.metadata = {"url": "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/Microsoft.Resources/deployments/{deploymentName}/validate"} # type: ignore @distributed_trace_async async def export_template( - self, - resource_group_name: str, - deployment_name: str, - **kwargs: Any - ) -> "_models.DeploymentExportResult": + self, resource_group_name: str, deployment_name: str, **kwargs: Any + ) -> _models.DeploymentExportResult: """Exports the template used for specified deployment. :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. :type resource_group_name: str - :param deployment_name: The name of the deployment from which to get the template. + :param deployment_name: The name of the deployment from which to get the template. Required. :type deployment_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: DeploymentExportResult, or the result of cls(response) + :return: DeploymentExportResult or the result of cls(response) :rtype: ~azure.mgmt.resource.resources.v2018_02_01.models.DeploymentExportResult - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.DeploymentExportResult"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + 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', "2018-02-01") # type: str + api_version = kwargs.pop("api_version", _params.pop("api-version", "2018-02-01")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[_models.DeploymentExportResult] - request = build_deployments_export_template_request( resource_group_name=resource_group_name, deployment_name=deployment_name, subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.export_template.metadata['url'], + template_url=self.export_template.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) - deserialized = self._deserialize('DeploymentExportResult', pipeline_response) + deserialized = self._deserialize("DeploymentExportResult", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - export_template.metadata = {'url': "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/Microsoft.Resources/deployments/{deploymentName}/exportTemplate"} # type: ignore - + export_template.metadata = {"url": "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/Microsoft.Resources/deployments/{deploymentName}/exportTemplate"} # type: ignore @distributed_trace def list_by_resource_group( - self, - resource_group_name: str, - filter: Optional[str] = None, - top: Optional[int] = None, - **kwargs: Any - ) -> AsyncIterable["_models.DeploymentListResult"]: + self, resource_group_name: str, filter: Optional[str] = None, top: Optional[int] = None, **kwargs: Any + ) -> AsyncIterable["_models.DeploymentExtended"]: """Get all the deployments for a resource group. :param resource_group_name: The name of the resource group with the deployments to get. The - name is case insensitive. + name is case insensitive. Required. :type resource_group_name: str :param filter: The filter to apply on the operation. For example, you can use $filter=provisioningState eq '{state}'. Default value is None. @@ -614,42 +834,49 @@ def list_by_resource_group( value is None. :type top: int :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either DeploymentListResult or the result of - cls(response) + :return: An iterator like instance of either DeploymentExtended or the result of cls(response) :rtype: - ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.resource.resources.v2018_02_01.models.DeploymentListResult] - :raises: ~azure.core.exceptions.HttpResponseError + ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.resource.resources.v2018_02_01.models.DeploymentExtended] + :raises ~azure.core.exceptions.HttpResponseError: """ - api_version = kwargs.pop('api_version', "2018-02-01") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2018-02-01")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[_models.DeploymentListResult] - cls = kwargs.pop('cls', None) # type: ClsType["_models.DeploymentListResult"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) + def prepare_request(next_link=None): if not next_link: - + request = build_deployments_list_by_resource_group_request( resource_group_name=resource_group_name, subscription_id=self._config.subscription_id, - api_version=api_version, filter=filter, top=top, - template_url=self.list_by_resource_group.metadata['url'], + 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.url = self._client.format_url(request.url) # type: ignore else: - - request = build_deployments_list_by_resource_group_request( - resource_group_name=resource_group_name, - subscription_id=self._config.subscription_id, - template_url=next_link, - ) + # make call to next link with the client's api-version + _parsed_next_link = urlparse(next_link) + _next_request_params = case_insensitive_dict(parse_qs(_parsed_next_link.query)) + _next_request_params["api-version"] = self._config.api_version + request = HttpRequest("GET", urljoin(next_link, _parsed_next_link.path), params=_next_request_params) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore request.method = "GET" return request @@ -663,10 +890,8 @@ async def extract_data(pipeline_response): async def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) response = pipeline_response.http_response @@ -676,204 +901,204 @@ async def get_next(next_link=None): return pipeline_response + return AsyncItemPaged(get_next, extract_data) - return AsyncItemPaged( - get_next, extract_data - ) - list_by_resource_group.metadata = {'url': "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/Microsoft.Resources/deployments/"} # type: ignore + list_by_resource_group.metadata = {"url": "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/Microsoft.Resources/deployments/"} # type: ignore @distributed_trace_async - async def calculate_template_hash( - self, - template: Any, - **kwargs: Any - ) -> "_models.TemplateHashResult": + async def calculate_template_hash(self, template: JSON, **kwargs: Any) -> _models.TemplateHashResult: """Calculate the hash of the given template. - :param template: The template provided to calculate hash. - :type template: any + :param template: The template provided to calculate hash. Required. + :type template: JSON :keyword callable cls: A custom type or function that will be passed the direct response - :return: TemplateHashResult, or the result of cls(response) + :return: TemplateHashResult or the result of cls(response) :rtype: ~azure.mgmt.resource.resources.v2018_02_01.models.TemplateHashResult - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.TemplateHashResult"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', "2018-02-01") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + api_version = kwargs.pop("api_version", _params.pop("api-version", "2018-02-01")) # type: str + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", "application/json")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[_models.TemplateHashResult] - _json = self._serialize.body(template, 'object') + _json = self._serialize.body(template, "object") request = build_deployments_calculate_template_hash_request( api_version=api_version, content_type=content_type, json=_json, - template_url=self.calculate_template_hash.metadata['url'], + template_url=self.calculate_template_hash.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) - deserialized = self._deserialize('TemplateHashResult', pipeline_response) + deserialized = self._deserialize("TemplateHashResult", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - calculate_template_hash.metadata = {'url': "/providers/Microsoft.Resources/calculateTemplateHash"} # type: ignore + calculate_template_hash.metadata = {"url": "/providers/Microsoft.Resources/calculateTemplateHash"} # type: ignore -class ProvidersOperations: - """ProvidersOperations async operations. - You should not instantiate this class directly. Instead, you should create a Client instance that - instantiates it for you and attaches it as an attribute. +class ProvidersOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. - :ivar models: Alias to model classes used in this operation group. - :type models: ~azure.mgmt.resource.resources.v2018_02_01.models - :param client: Client for service requests. - :param config: Configuration of service client. - :param serializer: An object model serializer. - :param deserializer: An object model deserializer. + Instead, you should access the following operations through + :class:`~azure.mgmt.resource.resources.v2018_02_01.aio.ResourceManagementClient`'s + :attr:`providers` attribute. """ models = _models - def __init__(self, client, config, serializer, deserializer) -> None: - self._client = client - self._serialize = serializer - self._deserialize = deserializer - self._config = config + def __init__(self, *args, **kwargs) -> None: + input_args = list(args) + self._client = input_args.pop(0) if input_args else kwargs.pop("client") + self._config = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") @distributed_trace_async - async def unregister( - self, - resource_provider_namespace: str, - **kwargs: Any - ) -> "_models.Provider": + async def unregister(self, resource_provider_namespace: str, **kwargs: Any) -> _models.Provider: """Unregisters a subscription from a resource provider. :param resource_provider_namespace: The namespace of the resource provider to unregister. + Required. :type resource_provider_namespace: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: Provider, or the result of cls(response) + :return: Provider or the result of cls(response) :rtype: ~azure.mgmt.resource.resources.v2018_02_01.models.Provider - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.Provider"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + 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', "2018-02-01") # type: str + api_version = kwargs.pop("api_version", _params.pop("api-version", "2018-02-01")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[_models.Provider] - request = build_providers_unregister_request( resource_provider_namespace=resource_provider_namespace, subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.unregister.metadata['url'], + template_url=self.unregister.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) - deserialized = self._deserialize('Provider', pipeline_response) + deserialized = self._deserialize("Provider", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - unregister.metadata = {'url': "/subscriptions/{subscriptionId}/providers/{resourceProviderNamespace}/unregister"} # type: ignore - + unregister.metadata = {"url": "/subscriptions/{subscriptionId}/providers/{resourceProviderNamespace}/unregister"} # type: ignore @distributed_trace_async - async def register( - self, - resource_provider_namespace: str, - **kwargs: Any - ) -> "_models.Provider": + async def register(self, resource_provider_namespace: str, **kwargs: Any) -> _models.Provider: """Registers a subscription with a resource provider. :param resource_provider_namespace: The namespace of the resource provider to register. + Required. :type resource_provider_namespace: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: Provider, or the result of cls(response) + :return: Provider or the result of cls(response) :rtype: ~azure.mgmt.resource.resources.v2018_02_01.models.Provider - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.Provider"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + 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', "2018-02-01") # type: str + api_version = kwargs.pop("api_version", _params.pop("api-version", "2018-02-01")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[_models.Provider] - request = build_providers_register_request( resource_provider_namespace=resource_provider_namespace, subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.register.metadata['url'], + template_url=self.register.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) - deserialized = self._deserialize('Provider', pipeline_response) + deserialized = self._deserialize("Provider", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - register.metadata = {'url': "/subscriptions/{subscriptionId}/providers/{resourceProviderNamespace}/register"} # type: ignore - + register.metadata = {"url": "/subscriptions/{subscriptionId}/providers/{resourceProviderNamespace}/register"} # type: ignore @distributed_trace def list( - self, - top: Optional[int] = None, - expand: Optional[str] = None, - **kwargs: Any - ) -> AsyncIterable["_models.ProviderListResult"]: + self, top: Optional[int] = None, expand: Optional[str] = None, **kwargs: Any + ) -> AsyncIterable["_models.Provider"]: """Gets all resource providers for a subscription. :param top: The number of results to return. If null is passed returns all deployments. Default @@ -884,39 +1109,48 @@ def list( response, use $expand=resourceTypes/aliases. Default value is None. :type expand: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either ProviderListResult or the result of cls(response) + :return: An iterator like instance of either Provider or the result of cls(response) :rtype: - ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.resource.resources.v2018_02_01.models.ProviderListResult] - :raises: ~azure.core.exceptions.HttpResponseError + ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.resource.resources.v2018_02_01.models.Provider] + :raises ~azure.core.exceptions.HttpResponseError: """ - api_version = kwargs.pop('api_version', "2018-02-01") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2018-02-01")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[_models.ProviderListResult] - cls = kwargs.pop('cls', None) # type: ClsType["_models.ProviderListResult"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) + def prepare_request(next_link=None): if not next_link: - + request = build_providers_list_request( subscription_id=self._config.subscription_id, - api_version=api_version, top=top, expand=expand, - template_url=self.list.metadata['url'], + 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.url = self._client.format_url(request.url) # type: ignore else: - - request = build_providers_list_request( - subscription_id=self._config.subscription_id, - template_url=next_link, - ) + # make call to next link with the client's api-version + _parsed_next_link = urlparse(next_link) + _next_request_params = case_insensitive_dict(parse_qs(_parsed_next_link.query)) + _next_request_params["api-version"] = self._config.api_version + request = HttpRequest("GET", urljoin(next_link, _parsed_next_link.path), params=_next_request_params) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore request.method = "GET" return request @@ -930,10 +1164,8 @@ async def extract_data(pipeline_response): async def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) response = pipeline_response.http_response @@ -943,91 +1175,90 @@ async def get_next(next_link=None): return pipeline_response + return AsyncItemPaged(get_next, extract_data) - return AsyncItemPaged( - get_next, extract_data - ) - list.metadata = {'url': "/subscriptions/{subscriptionId}/providers"} # type: ignore + list.metadata = {"url": "/subscriptions/{subscriptionId}/providers"} # type: ignore @distributed_trace_async async def get( - self, - resource_provider_namespace: str, - expand: Optional[str] = None, - **kwargs: Any - ) -> "_models.Provider": + self, resource_provider_namespace: str, expand: Optional[str] = None, **kwargs: Any + ) -> _models.Provider: """Gets the specified resource provider. - :param resource_provider_namespace: The namespace of the resource provider. + :param resource_provider_namespace: The namespace of the resource provider. Required. :type resource_provider_namespace: str :param expand: The $expand query parameter. For example, to include property aliases in response, use $expand=resourceTypes/aliases. Default value is None. :type expand: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: Provider, or the result of cls(response) + :return: Provider or the result of cls(response) :rtype: ~azure.mgmt.resource.resources.v2018_02_01.models.Provider - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.Provider"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) - api_version = kwargs.pop('api_version', "2018-02-01") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2018-02-01")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[_models.Provider] - request = build_providers_get_request( resource_provider_namespace=resource_provider_namespace, subscription_id=self._config.subscription_id, - api_version=api_version, expand=expand, - template_url=self.get.metadata['url'], + api_version=api_version, + template_url=self.get.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) - deserialized = self._deserialize('Provider', pipeline_response) + deserialized = self._deserialize("Provider", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - get.metadata = {'url': "/subscriptions/{subscriptionId}/providers/{resourceProviderNamespace}"} # type: ignore + get.metadata = {"url": "/subscriptions/{subscriptionId}/providers/{resourceProviderNamespace}"} # type: ignore -class ResourcesOperations: # pylint: disable=too-many-public-methods - """ResourcesOperations async operations. - You should not instantiate this class directly. Instead, you should create a Client instance that - instantiates it for you and attaches it as an attribute. +class ResourcesOperations: # pylint: disable=too-many-public-methods + """ + .. warning:: + **DO NOT** instantiate this class directly. - :ivar models: Alias to model classes used in this operation group. - :type models: ~azure.mgmt.resource.resources.v2018_02_01.models - :param client: Client for service requests. - :param config: Configuration of service client. - :param serializer: An object model serializer. - :param deserializer: An object model deserializer. + Instead, you should access the following operations through + :class:`~azure.mgmt.resource.resources.v2018_02_01.aio.ResourceManagementClient`'s + :attr:`resources` attribute. """ models = _models - def __init__(self, client, config, serializer, deserializer) -> None: - self._client = client - self._serialize = serializer - self._deserialize = deserializer - self._config = config + def __init__(self, *args, **kwargs) -> None: + input_args = list(args) + self._client = input_args.pop(0) if input_args else kwargs.pop("client") + self._config = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") @distributed_trace def list_by_resource_group( @@ -1037,10 +1268,10 @@ def list_by_resource_group( expand: Optional[str] = None, top: Optional[int] = None, **kwargs: Any - ) -> AsyncIterable["_models.ResourceListResult"]: + ) -> AsyncIterable["_models.GenericResourceExpanded"]: """Get all the resources for a resource group. - :param resource_group_name: The resource group with the resources to get. + :param resource_group_name: The resource group with the resources to get. Required. :type resource_group_name: str :param filter: The filter to apply on the operation. Default value is None. :type filter: str @@ -1052,42 +1283,51 @@ def list_by_resource_group( value is None. :type top: int :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either ResourceListResult or the result of cls(response) + :return: An iterator like instance of either GenericResourceExpanded or the result of + cls(response) :rtype: - ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.resource.resources.v2018_02_01.models.ResourceListResult] - :raises: ~azure.core.exceptions.HttpResponseError + ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.resource.resources.v2018_02_01.models.GenericResourceExpanded] + :raises ~azure.core.exceptions.HttpResponseError: """ - api_version = kwargs.pop('api_version', "2018-02-01") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2018-02-01")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[_models.ResourceListResult] - cls = kwargs.pop('cls', None) # type: ClsType["_models.ResourceListResult"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) + def prepare_request(next_link=None): if not next_link: - + request = build_resources_list_by_resource_group_request( resource_group_name=resource_group_name, subscription_id=self._config.subscription_id, - api_version=api_version, filter=filter, expand=expand, top=top, - template_url=self.list_by_resource_group.metadata['url'], + 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.url = self._client.format_url(request.url) # type: ignore else: - - request = build_resources_list_by_resource_group_request( - resource_group_name=resource_group_name, - subscription_id=self._config.subscription_id, - template_url=next_link, - ) + # make call to next link with the client's api-version + _parsed_next_link = urlparse(next_link) + _next_request_params = case_insensitive_dict(parse_qs(_parsed_next_link.query)) + _next_request_params["api-version"] = self._config.api_version + request = HttpRequest("GET", urljoin(next_link, _parsed_next_link.path), params=_next_request_params) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore request.method = "GET" return request @@ -1101,10 +1341,8 @@ async def extract_data(pipeline_response): async def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) response = pipeline_response.http_response @@ -1114,45 +1352,54 @@ async def get_next(next_link=None): return pipeline_response + return AsyncItemPaged(get_next, extract_data) - return AsyncItemPaged( - get_next, extract_data - ) - list_by_resource_group.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/resources"} # type: ignore + list_by_resource_group.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/resources"} # type: ignore async def _move_resources_initial( # pylint: disable=inconsistent-return-statements - self, - source_resource_group_name: str, - parameters: "_models.ResourcesMoveInfo", - **kwargs: Any + self, source_resource_group_name: str, parameters: Union[_models.ResourcesMoveInfo, IO], **kwargs: Any ) -> None: - cls = kwargs.pop('cls', None) # type: ClsType[None] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) - api_version = kwargs.pop('api_version', "2018-02-01") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - _json = self._serialize.body(parameters, 'ResourcesMoveInfo') + api_version = kwargs.pop("api_version", _params.pop("api-version", "2018-02-01")) # type: str + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[None] - request = build_resources_move_resources_request_initial( + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(parameters, (IO, bytes)): + _content = parameters + else: + _json = self._serialize.body(parameters, "ResourcesMoveInfo") + + request = build_resources_move_resources_request( source_resource_group_name=source_resource_group_name, subscription_id=self._config.subscription_id, api_version=api_version, content_type=content_type, json=_json, - template_url=self._move_resources_initial.metadata['url'], + content=_content, + template_url=self._move_resources_initial.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [202, 204]: @@ -1162,14 +1409,15 @@ async def _move_resources_initial( # pylint: disable=inconsistent-return-statem if cls: return cls(pipeline_response, None, {}) - _move_resources_initial.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{sourceResourceGroupName}/moveResources"} # type: ignore + _move_resources_initial.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{sourceResourceGroupName}/moveResources"} # type: ignore - - @distributed_trace_async - async def begin_move_resources( # pylint: disable=inconsistent-return-statements + @overload + async def begin_move_resources( self, source_resource_group_name: str, - parameters: "_models.ResourcesMoveInfo", + parameters: _models.ResourcesMoveInfo, + *, + content_type: str = "application/json", **kwargs: Any ) -> AsyncLROPoller[None]: """Moves resources from one resource group to another resource group. @@ -1180,10 +1428,13 @@ async def begin_move_resources( # pylint: disable=inconsistent-return-statement the groups until the move completes. :param source_resource_group_name: The name of the resource group containing the resources to - move. + move. Required. :type source_resource_group_name: str - :param parameters: Parameters for moving resources. + :param parameters: Parameters for moving resources. Required. :type parameters: ~azure.mgmt.resource.resources.v2018_02_01.models.ResourcesMoveInfo + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str :keyword callable cls: A custom type or function that will be passed the direct response :keyword str continuation_token: A continuation token to restart a poller from a saved state. :keyword polling: By default, your polling method will be AsyncARMPolling. Pass in False for @@ -1194,80 +1445,160 @@ async def begin_move_resources( # pylint: disable=inconsistent-return-statement Retry-After header is present. :return: An instance of AsyncLROPoller that returns either None or the result of cls(response) :rtype: ~azure.core.polling.AsyncLROPoller[None] - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - api_version = kwargs.pop('api_version', "2018-02-01") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] - polling = kwargs.pop('polling', True) # type: Union[bool, AsyncPollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType[None] - lro_delay = kwargs.pop( - 'polling_interval', - self._config.polling_interval - ) - cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] - if cont_token is None: - raw_result = await self._move_resources_initial( - source_resource_group_name=source_resource_group_name, - parameters=parameters, - api_version=api_version, - content_type=content_type, - cls=lambda x,y,z: x, - **kwargs - ) - kwargs.pop('error_map', None) - def get_long_running_output(pipeline_response): - if cls: - return cls(pipeline_response, None, {}) + @overload + async def begin_move_resources( + self, source_resource_group_name: str, parameters: IO, *, content_type: str = "application/json", **kwargs: Any + ) -> AsyncLROPoller[None]: + """Moves resources from one resource group to another resource group. + The resources to move must be in the same source resource group. The target resource group may + be in a different subscription. When moving resources, both the source group and the target + group are locked for the duration of the operation. Write and delete operations are blocked on + the groups until the move completes. - if polling is True: polling_method = AsyncARMPolling(lro_delay, **kwargs) - elif polling is False: polling_method = AsyncNoPolling() - else: polling_method = polling - if cont_token: - return AsyncLROPoller.from_continuation_token( - polling_method=polling_method, - continuation_token=cont_token, - client=self._client, - deserialization_callback=get_long_running_output - ) - return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) + :param source_resource_group_name: The name of the resource group containing the resources to + move. Required. + :type source_resource_group_name: str + :param parameters: Parameters for moving resources. Required. + :type parameters: IO + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be AsyncARMPolling. Pass in False for + this operation to not poll, or pass in your own initialized polling object for a personal + polling strategy. + :paramtype polling: bool or ~azure.core.polling.AsyncPollingMethod + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of AsyncLROPoller that returns either None or the result of cls(response) + :rtype: ~azure.core.polling.AsyncLROPoller[None] + :raises ~azure.core.exceptions.HttpResponseError: + """ - begin_move_resources.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{sourceResourceGroupName}/moveResources"} # type: ignore + @distributed_trace_async + async def begin_move_resources( + self, source_resource_group_name: str, parameters: Union[_models.ResourcesMoveInfo, IO], **kwargs: Any + ) -> AsyncLROPoller[None]: + """Moves resources from one resource group to another resource group. + + The resources to move must be in the same source resource group. The target resource group may + be in a different subscription. When moving resources, both the source group and the target + group are locked for the duration of the operation. Write and delete operations are blocked on + the groups until the move completes. + + :param source_resource_group_name: The name of the resource group containing the resources to + move. Required. + :type source_resource_group_name: str + :param parameters: Parameters for moving resources. Is either a model type or a IO type. + Required. + :type parameters: ~azure.mgmt.resource.resources.v2018_02_01.models.ResourcesMoveInfo or IO + :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. + Default value is None. + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be AsyncARMPolling. Pass in False for + this operation to not poll, or pass in your own initialized polling object for a personal + polling strategy. + :paramtype polling: bool or ~azure.core.polling.AsyncPollingMethod + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of AsyncLROPoller that returns either None or the result of cls(response) + :rtype: ~azure.core.polling.AsyncLROPoller[None] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _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", "2018-02-01")) # type: str + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[None] + polling = kwargs.pop("polling", True) # type: Union[bool, AsyncPollingMethod] + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token = kwargs.pop("continuation_token", None) # type: Optional[str] + if cont_token is None: + raw_result = await self._move_resources_initial( # type: ignore + source_resource_group_name=source_resource_group_name, + parameters=parameters, + api_version=api_version, + content_type=content_type, + cls=lambda x, y, z: x, + headers=_headers, + params=_params, + **kwargs + ) + kwargs.pop("error_map", None) + + def get_long_running_output(pipeline_response): # pylint: disable=inconsistent-return-statements + if cls: + return cls(pipeline_response, None, {}) + + if polling is True: + polling_method = cast(AsyncPollingMethod, AsyncARMPolling(lro_delay, **kwargs)) # type: AsyncPollingMethod + elif polling is False: + polling_method = cast(AsyncPollingMethod, AsyncNoPolling()) + else: + polling_method = polling + if cont_token: + return AsyncLROPoller.from_continuation_token( + polling_method=polling_method, + continuation_token=cont_token, + client=self._client, + deserialization_callback=get_long_running_output, + ) + return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) + + begin_move_resources.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{sourceResourceGroupName}/moveResources"} # type: ignore async def _validate_move_resources_initial( # pylint: disable=inconsistent-return-statements - self, - source_resource_group_name: str, - parameters: "_models.ResourcesMoveInfo", - **kwargs: Any + self, source_resource_group_name: str, parameters: Union[_models.ResourcesMoveInfo, IO], **kwargs: Any ) -> None: - cls = kwargs.pop('cls', None) # type: ClsType[None] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', "2018-02-01") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + api_version = kwargs.pop("api_version", _params.pop("api-version", "2018-02-01")) # type: str + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[None] - _json = self._serialize.body(parameters, 'ResourcesMoveInfo') + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(parameters, (IO, bytes)): + _content = parameters + else: + _json = self._serialize.body(parameters, "ResourcesMoveInfo") - request = build_resources_validate_move_resources_request_initial( + request = build_resources_validate_move_resources_request( source_resource_group_name=source_resource_group_name, subscription_id=self._config.subscription_id, api_version=api_version, content_type=content_type, json=_json, - template_url=self._validate_move_resources_initial.metadata['url'], + content=_content, + template_url=self._validate_move_resources_initial.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [202, 204, 409]: @@ -1277,14 +1608,15 @@ async def _validate_move_resources_initial( # pylint: disable=inconsistent-retu if cls: return cls(pipeline_response, None, {}) - _validate_move_resources_initial.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{sourceResourceGroupName}/validateMoveResources"} # type: ignore - + _validate_move_resources_initial.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{sourceResourceGroupName}/validateMoveResources"} # type: ignore - @distributed_trace_async - async def begin_validate_move_resources( # pylint: disable=inconsistent-return-statements + @overload + async def begin_validate_move_resources( self, source_resource_group_name: str, - parameters: "_models.ResourcesMoveInfo", + parameters: _models.ResourcesMoveInfo, + *, + content_type: str = "application/json", **kwargs: Any ) -> AsyncLROPoller[None]: """Validates whether resources can be moved from one resource group to another resource group. @@ -1297,10 +1629,47 @@ async def begin_validate_move_resources( # pylint: disable=inconsistent-return- operation. :param source_resource_group_name: The name of the resource group containing the resources to - validate for move. + validate for move. Required. :type source_resource_group_name: str - :param parameters: Parameters for moving resources. + :param parameters: Parameters for moving resources. Required. :type parameters: ~azure.mgmt.resource.resources.v2018_02_01.models.ResourcesMoveInfo + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be AsyncARMPolling. Pass in False for + this operation to not poll, or pass in your own initialized polling object for a personal + polling strategy. + :paramtype polling: bool or ~azure.core.polling.AsyncPollingMethod + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of AsyncLROPoller that returns either None or the result of cls(response) + :rtype: ~azure.core.polling.AsyncLROPoller[None] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + async def begin_validate_move_resources( + self, source_resource_group_name: str, parameters: IO, *, content_type: str = "application/json", **kwargs: Any + ) -> AsyncLROPoller[None]: + """Validates whether resources can be moved from one resource group to another resource group. + + This operation checks whether the specified resources can be moved to the target. The resources + to move must be in the same source resource group. The target resource group may be in a + different subscription. If validation succeeds, it returns HTTP response code 204 (no content). + If validation fails, it returns HTTP response code 409 (Conflict) with an error message. + Retrieve the URL in the Location header value to check the result of the long-running + operation. + + :param source_resource_group_name: The name of the resource group containing the resources to + validate for move. Required. + :type source_resource_group_name: str + :param parameters: Parameters for moving resources. Required. + :type parameters: IO + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: str :keyword callable cls: A custom type or function that will be passed the direct response :keyword str continuation_token: A continuation token to restart a poller from a saved state. :keyword polling: By default, your polling method will be AsyncARMPolling. Pass in False for @@ -1311,55 +1680,90 @@ async def begin_validate_move_resources( # pylint: disable=inconsistent-return- Retry-After header is present. :return: An instance of AsyncLROPoller that returns either None or the result of cls(response) :rtype: ~azure.core.polling.AsyncLROPoller[None] - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - api_version = kwargs.pop('api_version', "2018-02-01") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] - polling = kwargs.pop('polling', True) # type: Union[bool, AsyncPollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType[None] - lro_delay = kwargs.pop( - 'polling_interval', - self._config.polling_interval - ) - cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] + + @distributed_trace_async + async def begin_validate_move_resources( + self, source_resource_group_name: str, parameters: Union[_models.ResourcesMoveInfo, IO], **kwargs: Any + ) -> AsyncLROPoller[None]: + """Validates whether resources can be moved from one resource group to another resource group. + + This operation checks whether the specified resources can be moved to the target. The resources + to move must be in the same source resource group. The target resource group may be in a + different subscription. If validation succeeds, it returns HTTP response code 204 (no content). + If validation fails, it returns HTTP response code 409 (Conflict) with an error message. + Retrieve the URL in the Location header value to check the result of the long-running + operation. + + :param source_resource_group_name: The name of the resource group containing the resources to + validate for move. Required. + :type source_resource_group_name: str + :param parameters: Parameters for moving resources. Is either a model type or a IO type. + Required. + :type parameters: ~azure.mgmt.resource.resources.v2018_02_01.models.ResourcesMoveInfo or IO + :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. + Default value is None. + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be AsyncARMPolling. Pass in False for + this operation to not poll, or pass in your own initialized polling object for a personal + polling strategy. + :paramtype polling: bool or ~azure.core.polling.AsyncPollingMethod + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of AsyncLROPoller that returns either None or the result of cls(response) + :rtype: ~azure.core.polling.AsyncLROPoller[None] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _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", "2018-02-01")) # type: str + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[None] + polling = kwargs.pop("polling", True) # type: Union[bool, AsyncPollingMethod] + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token = kwargs.pop("continuation_token", None) # type: Optional[str] if cont_token is None: - raw_result = await self._validate_move_resources_initial( + raw_result = await self._validate_move_resources_initial( # type: ignore source_resource_group_name=source_resource_group_name, parameters=parameters, api_version=api_version, content_type=content_type, - cls=lambda x,y,z: x, + cls=lambda x, y, z: x, + headers=_headers, + params=_params, **kwargs ) - kwargs.pop('error_map', None) + kwargs.pop("error_map", None) - def get_long_running_output(pipeline_response): + def get_long_running_output(pipeline_response): # pylint: disable=inconsistent-return-statements if cls: return cls(pipeline_response, None, {}) - - if polling is True: polling_method = AsyncARMPolling(lro_delay, **kwargs) - elif polling is False: polling_method = AsyncNoPolling() - else: polling_method = polling + if polling is True: + polling_method = cast(AsyncPollingMethod, AsyncARMPolling(lro_delay, **kwargs)) # type: AsyncPollingMethod + elif polling is False: + polling_method = cast(AsyncPollingMethod, AsyncNoPolling()) + else: + polling_method = polling if cont_token: return AsyncLROPoller.from_continuation_token( polling_method=polling_method, continuation_token=cont_token, client=self._client, - deserialization_callback=get_long_running_output + deserialization_callback=get_long_running_output, ) return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) - begin_validate_move_resources.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{sourceResourceGroupName}/validateMoveResources"} # type: ignore + begin_validate_move_resources.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{sourceResourceGroupName}/validateMoveResources"} # type: ignore @distributed_trace def list( - self, - filter: Optional[str] = None, - expand: Optional[str] = None, - top: Optional[int] = None, - **kwargs: Any - ) -> AsyncIterable["_models.ResourceListResult"]: + self, filter: Optional[str] = None, expand: Optional[str] = None, top: Optional[int] = None, **kwargs: Any + ) -> AsyncIterable["_models.GenericResourceExpanded"]: """Get all the resources in a subscription. :param filter: The filter to apply on the operation. Default value is None. @@ -1370,40 +1774,50 @@ def list( value is None. :type top: int :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either ResourceListResult or the result of cls(response) + :return: An iterator like instance of either GenericResourceExpanded or the result of + cls(response) :rtype: - ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.resource.resources.v2018_02_01.models.ResourceListResult] - :raises: ~azure.core.exceptions.HttpResponseError + ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.resource.resources.v2018_02_01.models.GenericResourceExpanded] + :raises ~azure.core.exceptions.HttpResponseError: """ - api_version = kwargs.pop('api_version', "2018-02-01") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2018-02-01")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[_models.ResourceListResult] - cls = kwargs.pop('cls', None) # type: ClsType["_models.ResourceListResult"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) + def prepare_request(next_link=None): if not next_link: - + request = build_resources_list_request( subscription_id=self._config.subscription_id, - api_version=api_version, filter=filter, expand=expand, top=top, - template_url=self.list.metadata['url'], + 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.url = self._client.format_url(request.url) # type: ignore else: - - request = build_resources_list_request( - subscription_id=self._config.subscription_id, - template_url=next_link, - ) + # make call to next link with the client's api-version + _parsed_next_link = urlparse(next_link) + _next_request_params = case_insensitive_dict(parse_qs(_parsed_next_link.query)) + _next_request_params["api-version"] = self._config.api_version + request = HttpRequest("GET", urljoin(next_link, _parsed_next_link.path), params=_next_request_params) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore request.method = "GET" return request @@ -1417,10 +1831,8 @@ async def extract_data(pipeline_response): async def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) response = pipeline_response.http_response @@ -1430,11 +1842,9 @@ async def get_next(next_link=None): return pipeline_response + return AsyncItemPaged(get_next, extract_data) - return AsyncItemPaged( - get_next, extract_data - ) - list.metadata = {'url': "/subscriptions/{subscriptionId}/resources"} # type: ignore + list.metadata = {"url": "/subscriptions/{subscriptionId}/resources"} # type: ignore @distributed_trace_async async def check_existence( @@ -1450,30 +1860,36 @@ async def check_existence( """Checks whether a resource exists. :param resource_group_name: The name of the resource group containing the resource to check. - The name is case insensitive. + The name is case insensitive. Required. :type resource_group_name: str - :param resource_provider_namespace: The resource provider of the resource to check. + :param resource_provider_namespace: The resource provider of the resource to check. Required. :type resource_provider_namespace: str - :param parent_resource_path: The parent resource identity. + :param parent_resource_path: The parent resource identity. Required. :type parent_resource_path: str - :param resource_type: The resource type. + :param resource_type: The resource type. Required. :type resource_type: str - :param resource_name: The name of the resource to check whether it exists. + :param resource_name: The name of the resource to check whether it exists. Required. :type resource_name: str - :param api_version: The API version to use for the operation. + :param api_version: The API version to use for the operation. Required. :type api_version: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: bool, or the result of cls(response) + :return: bool or the result of cls(response) :rtype: bool - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType[None] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = kwargs.pop("params", {}) or {} + + cls = kwargs.pop("cls", None) # type: ClsType[None] - request = build_resources_check_existence_request( resource_group_name=resource_group_name, resource_provider_namespace=resource_provider_namespace, @@ -1482,16 +1898,17 @@ async def check_existence( resource_name=resource_name, subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.check_existence.metadata['url'], + template_url=self.check_existence.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [204, 404]: @@ -1502,8 +1919,7 @@ async def check_existence( return cls(pipeline_response, None, {}) return 200 <= response.status_code <= 299 - check_existence.metadata = {'url': "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{parentResourcePath}/{resourceType}/{resourceName}"} # type: ignore - + check_existence.metadata = {"url": "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{parentResourcePath}/{resourceType}/{resourceName}"} # type: ignore async def _delete_initial( # pylint: disable=inconsistent-return-statements self, @@ -1515,14 +1931,20 @@ async def _delete_initial( # pylint: disable=inconsistent-return-statements api_version: str, **kwargs: Any ) -> None: - cls = kwargs.pop('cls', None) # type: ClsType[None] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) - - request = build_resources_delete_request_initial( + _headers = kwargs.pop("headers", {}) or {} + _params = kwargs.pop("params", {}) or {} + + cls = kwargs.pop("cls", None) # type: ClsType[None] + + request = build_resources_delete_request( resource_group_name=resource_group_name, resource_provider_namespace=resource_provider_namespace, parent_resource_path=parent_resource_path, @@ -1530,16 +1952,17 @@ async def _delete_initial( # pylint: disable=inconsistent-return-statements resource_name=resource_name, subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self._delete_initial.metadata['url'], + template_url=self._delete_initial.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200, 202, 204]: @@ -1549,11 +1972,10 @@ 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/{resourceProviderNamespace}/{parentResourcePath}/{resourceType}/{resourceName}"} # type: ignore - + _delete_initial.metadata = {"url": "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{parentResourcePath}/{resourceType}/{resourceName}"} # type: ignore @distributed_trace_async - async def begin_delete( # pylint: disable=inconsistent-return-statements + async def begin_delete( self, resource_group_name: str, resource_provider_namespace: str, @@ -1566,17 +1988,17 @@ async def begin_delete( # pylint: disable=inconsistent-return-statements """Deletes a resource. :param resource_group_name: The name of the resource group that contains the resource to - delete. The name is case insensitive. + delete. The name is case insensitive. Required. :type resource_group_name: str - :param resource_provider_namespace: The namespace of the resource provider. + :param resource_provider_namespace: The namespace of the resource provider. Required. :type resource_provider_namespace: str - :param parent_resource_path: The parent resource identity. + :param parent_resource_path: The parent resource identity. Required. :type parent_resource_path: str - :param resource_type: The resource type. + :param resource_type: The resource type. Required. :type resource_type: str - :param resource_name: The name of the resource to delete. + :param resource_name: The name of the resource to delete. Required. :type resource_name: str - :param api_version: The API version to use for the operation. + :param api_version: The API version to use for the operation. Required. :type api_version: str :keyword callable cls: A custom type or function that will be passed the direct response :keyword str continuation_token: A continuation token to restart a poller from a saved state. @@ -1588,46 +2010,50 @@ async def begin_delete( # pylint: disable=inconsistent-return-statements Retry-After header is present. :return: An instance of AsyncLROPoller that returns either None or the result of cls(response) :rtype: ~azure.core.polling.AsyncLROPoller[None] - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - polling = kwargs.pop('polling', True) # type: Union[bool, AsyncPollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType[None] - lro_delay = kwargs.pop( - 'polling_interval', - self._config.polling_interval - ) - cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] + _headers = kwargs.pop("headers", {}) or {} + _params = kwargs.pop("params", {}) or {} + + cls = kwargs.pop("cls", None) # type: ClsType[None] + polling = kwargs.pop("polling", True) # type: Union[bool, AsyncPollingMethod] + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token = kwargs.pop("continuation_token", None) # type: Optional[str] if cont_token is None: - raw_result = await self._delete_initial( + raw_result = await self._delete_initial( # type: ignore resource_group_name=resource_group_name, resource_provider_namespace=resource_provider_namespace, parent_resource_path=parent_resource_path, resource_type=resource_type, resource_name=resource_name, api_version=api_version, - cls=lambda x,y,z: x, + cls=lambda x, y, z: x, + headers=_headers, + params=_params, **kwargs ) - kwargs.pop('error_map', None) + kwargs.pop("error_map", None) - def get_long_running_output(pipeline_response): + def get_long_running_output(pipeline_response): # pylint: disable=inconsistent-return-statements if cls: return cls(pipeline_response, None, {}) - - if polling is True: polling_method = AsyncARMPolling(lro_delay, **kwargs) - elif polling is False: polling_method = AsyncNoPolling() - else: polling_method = polling + if polling is True: + polling_method = cast(AsyncPollingMethod, AsyncARMPolling(lro_delay, **kwargs)) # type: AsyncPollingMethod + elif polling is False: + polling_method = cast(AsyncPollingMethod, AsyncNoPolling()) + else: + polling_method = polling if cont_token: return AsyncLROPoller.from_continuation_token( polling_method=polling_method, continuation_token=cont_token, client=self._client, - deserialization_callback=get_long_running_output + deserialization_callback=get_long_running_output, ) return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) - begin_delete.metadata = {'url': "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{parentResourcePath}/{resourceType}/{resourceName}"} # type: ignore + begin_delete.metadata = {"url": "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{parentResourcePath}/{resourceType}/{resourceName}"} # type: ignore async def _create_or_update_initial( self, @@ -1637,39 +2063,53 @@ async def _create_or_update_initial( resource_type: str, resource_name: str, api_version: str, - parameters: "_models.GenericResource", + parameters: Union[_models.GenericResource, IO], **kwargs: Any - ) -> Optional["_models.GenericResource"]: - cls = kwargs.pop('cls', None) # type: ClsType[Optional["_models.GenericResource"]] + ) -> Optional[_models.GenericResource]: error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = kwargs.pop("params", {}) or {} - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[Optional[_models.GenericResource]] - _json = self._serialize.body(parameters, 'GenericResource') + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(parameters, (IO, bytes)): + _content = parameters + else: + _json = self._serialize.body(parameters, "GenericResource") - request = build_resources_create_or_update_request_initial( + request = build_resources_create_or_update_request( resource_group_name=resource_group_name, resource_provider_namespace=resource_provider_namespace, parent_resource_path=parent_resource_path, resource_type=resource_type, resource_name=resource_name, subscription_id=self._config.subscription_id, - content_type=content_type, api_version=api_version, + content_type=content_type, json=_json, - template_url=self._create_or_update_initial.metadata['url'], + content=_content, + template_url=self._create_or_update_initial.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200, 201, 202]: @@ -1678,18 +2118,115 @@ async def _create_or_update_initial( deserialized = None if response.status_code == 200: - deserialized = self._deserialize('GenericResource', pipeline_response) + deserialized = self._deserialize("GenericResource", pipeline_response) if response.status_code == 201: - deserialized = self._deserialize('GenericResource', pipeline_response) + deserialized = self._deserialize("GenericResource", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - _create_or_update_initial.metadata = {'url': "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{parentResourcePath}/{resourceType}/{resourceName}"} # type: ignore + _create_or_update_initial.metadata = {"url": "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{parentResourcePath}/{resourceType}/{resourceName}"} # type: ignore + @overload + async def begin_create_or_update( + self, + resource_group_name: str, + resource_provider_namespace: str, + parent_resource_path: str, + resource_type: str, + resource_name: str, + api_version: str, + parameters: _models.GenericResource, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> AsyncLROPoller[_models.GenericResource]: + """Creates a resource. + + :param resource_group_name: The name of the resource group for the resource. The name is case + insensitive. Required. + :type resource_group_name: str + :param resource_provider_namespace: The namespace of the resource provider. Required. + :type resource_provider_namespace: str + :param parent_resource_path: The parent resource identity. Required. + :type parent_resource_path: str + :param resource_type: The resource type of the resource to create. Required. + :type resource_type: str + :param resource_name: The name of the resource to create. Required. + :type resource_name: str + :param api_version: The API version to use for the operation. Required. + :type api_version: str + :param parameters: Parameters for creating or updating the resource. Required. + :type parameters: ~azure.mgmt.resource.resources.v2018_02_01.models.GenericResource + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be AsyncARMPolling. Pass in False for + this operation to not poll, or pass in your own initialized polling object for a personal + polling strategy. + :paramtype polling: bool or ~azure.core.polling.AsyncPollingMethod + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of AsyncLROPoller that returns either GenericResource or the result of + cls(response) + :rtype: + ~azure.core.polling.AsyncLROPoller[~azure.mgmt.resource.resources.v2018_02_01.models.GenericResource] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + async def begin_create_or_update( + self, + resource_group_name: str, + resource_provider_namespace: str, + parent_resource_path: str, + resource_type: str, + resource_name: str, + api_version: str, + parameters: IO, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> AsyncLROPoller[_models.GenericResource]: + """Creates a resource. + + :param resource_group_name: The name of the resource group for the resource. The name is case + insensitive. Required. + :type resource_group_name: str + :param resource_provider_namespace: The namespace of the resource provider. Required. + :type resource_provider_namespace: str + :param parent_resource_path: The parent resource identity. Required. + :type parent_resource_path: str + :param resource_type: The resource type of the resource to create. Required. + :type resource_type: str + :param resource_name: The name of the resource to create. Required. + :type resource_name: str + :param api_version: The API version to use for the operation. Required. + :type api_version: str + :param parameters: Parameters for creating or updating the resource. Required. + :type parameters: IO + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be AsyncARMPolling. Pass in False for + this operation to not poll, or pass in your own initialized polling object for a personal + polling strategy. + :paramtype polling: bool or ~azure.core.polling.AsyncPollingMethod + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of AsyncLROPoller that returns either GenericResource or the result of + cls(response) + :rtype: + ~azure.core.polling.AsyncLROPoller[~azure.mgmt.resource.resources.v2018_02_01.models.GenericResource] + :raises ~azure.core.exceptions.HttpResponseError: + """ @distributed_trace_async async def begin_create_or_update( @@ -1700,26 +2237,30 @@ async def begin_create_or_update( resource_type: str, resource_name: str, api_version: str, - parameters: "_models.GenericResource", + parameters: Union[_models.GenericResource, IO], **kwargs: Any - ) -> AsyncLROPoller["_models.GenericResource"]: + ) -> AsyncLROPoller[_models.GenericResource]: """Creates a resource. :param resource_group_name: The name of the resource group for the resource. The name is case - insensitive. + insensitive. Required. :type resource_group_name: str - :param resource_provider_namespace: The namespace of the resource provider. + :param resource_provider_namespace: The namespace of the resource provider. Required. :type resource_provider_namespace: str - :param parent_resource_path: The parent resource identity. + :param parent_resource_path: The parent resource identity. Required. :type parent_resource_path: str - :param resource_type: The resource type of the resource to create. + :param resource_type: The resource type of the resource to create. Required. :type resource_type: str - :param resource_name: The name of the resource to create. + :param resource_name: The name of the resource to create. Required. :type resource_name: str - :param api_version: The API version to use for the operation. + :param api_version: The API version to use for the operation. Required. :type api_version: str - :param parameters: Parameters for creating or updating the resource. - :type parameters: ~azure.mgmt.resource.resources.v2018_02_01.models.GenericResource + :param parameters: Parameters for creating or updating the resource. Is either a model type or + a IO type. Required. + :type parameters: ~azure.mgmt.resource.resources.v2018_02_01.models.GenericResource or IO + :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. + Default value is None. + :paramtype content_type: str :keyword callable cls: A custom type or function that will be passed the direct response :keyword str continuation_token: A continuation token to restart a poller from a saved state. :keyword polling: By default, your polling method will be AsyncARMPolling. Pass in False for @@ -1732,18 +2273,18 @@ async def begin_create_or_update( cls(response) :rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.resource.resources.v2018_02_01.models.GenericResource] - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] - polling = kwargs.pop('polling', True) # type: Union[bool, AsyncPollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType["_models.GenericResource"] - lro_delay = kwargs.pop( - 'polling_interval', - self._config.polling_interval - ) - cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = kwargs.pop("params", {}) or {} + + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.GenericResource] + polling = kwargs.pop("polling", True) # type: Union[bool, AsyncPollingMethod] + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token = kwargs.pop("continuation_token", None) # type: Optional[str] if cont_token is None: - raw_result = await self._create_or_update_initial( + raw_result = await self._create_or_update_initial( # type: ignore resource_group_name=resource_group_name, resource_provider_namespace=resource_provider_namespace, parent_resource_path=parent_resource_path, @@ -1752,32 +2293,35 @@ async def begin_create_or_update( api_version=api_version, parameters=parameters, content_type=content_type, - cls=lambda x,y,z: x, + cls=lambda x, y, z: x, + headers=_headers, + params=_params, **kwargs ) - kwargs.pop('error_map', None) + kwargs.pop("error_map", None) def get_long_running_output(pipeline_response): - response = pipeline_response.http_response - deserialized = self._deserialize('GenericResource', pipeline_response) + deserialized = self._deserialize("GenericResource", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - - if polling is True: polling_method = AsyncARMPolling(lro_delay, **kwargs) - elif polling is False: polling_method = AsyncNoPolling() - else: polling_method = polling + if polling is True: + polling_method = cast(AsyncPollingMethod, AsyncARMPolling(lro_delay, **kwargs)) # type: AsyncPollingMethod + elif polling is False: + polling_method = cast(AsyncPollingMethod, AsyncNoPolling()) + else: + polling_method = polling if cont_token: return AsyncLROPoller.from_continuation_token( polling_method=polling_method, continuation_token=cont_token, client=self._client, - deserialization_callback=get_long_running_output + deserialization_callback=get_long_running_output, ) return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) - begin_create_or_update.metadata = {'url': "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{parentResourcePath}/{resourceType}/{resourceName}"} # type: ignore + begin_create_or_update.metadata = {"url": "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{parentResourcePath}/{resourceType}/{resourceName}"} # type: ignore async def _update_initial( self, @@ -1787,39 +2331,53 @@ async def _update_initial( resource_type: str, resource_name: str, api_version: str, - parameters: "_models.GenericResource", + parameters: Union[_models.GenericResource, IO], **kwargs: Any - ) -> Optional["_models.GenericResource"]: - cls = kwargs.pop('cls', None) # type: ClsType[Optional["_models.GenericResource"]] + ) -> Optional[_models.GenericResource]: error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = kwargs.pop("params", {}) or {} - _json = self._serialize.body(parameters, 'GenericResource') + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[Optional[_models.GenericResource]] - request = build_resources_update_request_initial( + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(parameters, (IO, bytes)): + _content = parameters + else: + _json = self._serialize.body(parameters, "GenericResource") + + request = build_resources_update_request( resource_group_name=resource_group_name, resource_provider_namespace=resource_provider_namespace, parent_resource_path=parent_resource_path, resource_type=resource_type, resource_name=resource_name, subscription_id=self._config.subscription_id, - content_type=content_type, api_version=api_version, + content_type=content_type, json=_json, - template_url=self._update_initial.metadata['url'], + content=_content, + template_url=self._update_initial.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200, 202]: @@ -1828,15 +2386,112 @@ async def _update_initial( deserialized = None if response.status_code == 200: - deserialized = self._deserialize('GenericResource', pipeline_response) + deserialized = self._deserialize("GenericResource", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - _update_initial.metadata = {'url': "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{parentResourcePath}/{resourceType}/{resourceName}"} # type: ignore + _update_initial.metadata = {"url": "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{parentResourcePath}/{resourceType}/{resourceName}"} # type: ignore + @overload + async def begin_update( + self, + resource_group_name: str, + resource_provider_namespace: str, + parent_resource_path: str, + resource_type: str, + resource_name: str, + api_version: str, + parameters: _models.GenericResource, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> AsyncLROPoller[_models.GenericResource]: + """Updates a resource. + + :param resource_group_name: The name of the resource group for the resource. The name is case + insensitive. Required. + :type resource_group_name: str + :param resource_provider_namespace: The namespace of the resource provider. Required. + :type resource_provider_namespace: str + :param parent_resource_path: The parent resource identity. Required. + :type parent_resource_path: str + :param resource_type: The resource type of the resource to update. Required. + :type resource_type: str + :param resource_name: The name of the resource to update. Required. + :type resource_name: str + :param api_version: The API version to use for the operation. Required. + :type api_version: str + :param parameters: Parameters for updating the resource. Required. + :type parameters: ~azure.mgmt.resource.resources.v2018_02_01.models.GenericResource + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be AsyncARMPolling. Pass in False for + this operation to not poll, or pass in your own initialized polling object for a personal + polling strategy. + :paramtype polling: bool or ~azure.core.polling.AsyncPollingMethod + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of AsyncLROPoller that returns either GenericResource or the result of + cls(response) + :rtype: + ~azure.core.polling.AsyncLROPoller[~azure.mgmt.resource.resources.v2018_02_01.models.GenericResource] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + async def begin_update( + self, + resource_group_name: str, + resource_provider_namespace: str, + parent_resource_path: str, + resource_type: str, + resource_name: str, + api_version: str, + parameters: IO, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> AsyncLROPoller[_models.GenericResource]: + """Updates a resource. + + :param resource_group_name: The name of the resource group for the resource. The name is case + insensitive. Required. + :type resource_group_name: str + :param resource_provider_namespace: The namespace of the resource provider. Required. + :type resource_provider_namespace: str + :param parent_resource_path: The parent resource identity. Required. + :type parent_resource_path: str + :param resource_type: The resource type of the resource to update. Required. + :type resource_type: str + :param resource_name: The name of the resource to update. Required. + :type resource_name: str + :param api_version: The API version to use for the operation. Required. + :type api_version: str + :param parameters: Parameters for updating the resource. Required. + :type parameters: IO + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be AsyncARMPolling. Pass in False for + this operation to not poll, or pass in your own initialized polling object for a personal + polling strategy. + :paramtype polling: bool or ~azure.core.polling.AsyncPollingMethod + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of AsyncLROPoller that returns either GenericResource or the result of + cls(response) + :rtype: + ~azure.core.polling.AsyncLROPoller[~azure.mgmt.resource.resources.v2018_02_01.models.GenericResource] + :raises ~azure.core.exceptions.HttpResponseError: + """ @distributed_trace_async async def begin_update( @@ -1847,26 +2502,30 @@ async def begin_update( resource_type: str, resource_name: str, api_version: str, - parameters: "_models.GenericResource", + parameters: Union[_models.GenericResource, IO], **kwargs: Any - ) -> AsyncLROPoller["_models.GenericResource"]: + ) -> AsyncLROPoller[_models.GenericResource]: """Updates a resource. :param resource_group_name: The name of the resource group for the resource. The name is case - insensitive. + insensitive. Required. :type resource_group_name: str - :param resource_provider_namespace: The namespace of the resource provider. + :param resource_provider_namespace: The namespace of the resource provider. Required. :type resource_provider_namespace: str - :param parent_resource_path: The parent resource identity. + :param parent_resource_path: The parent resource identity. Required. :type parent_resource_path: str - :param resource_type: The resource type of the resource to update. + :param resource_type: The resource type of the resource to update. Required. :type resource_type: str - :param resource_name: The name of the resource to update. + :param resource_name: The name of the resource to update. Required. :type resource_name: str - :param api_version: The API version to use for the operation. + :param api_version: The API version to use for the operation. Required. :type api_version: str - :param parameters: Parameters for updating the resource. - :type parameters: ~azure.mgmt.resource.resources.v2018_02_01.models.GenericResource + :param parameters: Parameters for updating the resource. Is either a model type or a IO type. + Required. + :type parameters: ~azure.mgmt.resource.resources.v2018_02_01.models.GenericResource or IO + :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. + Default value is None. + :paramtype content_type: str :keyword callable cls: A custom type or function that will be passed the direct response :keyword str continuation_token: A continuation token to restart a poller from a saved state. :keyword polling: By default, your polling method will be AsyncARMPolling. Pass in False for @@ -1879,18 +2538,18 @@ async def begin_update( cls(response) :rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.resource.resources.v2018_02_01.models.GenericResource] - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] - polling = kwargs.pop('polling', True) # type: Union[bool, AsyncPollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType["_models.GenericResource"] - lro_delay = kwargs.pop( - 'polling_interval', - self._config.polling_interval - ) - cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = kwargs.pop("params", {}) or {} + + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.GenericResource] + polling = kwargs.pop("polling", True) # type: Union[bool, AsyncPollingMethod] + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token = kwargs.pop("continuation_token", None) # type: Optional[str] if cont_token is None: - raw_result = await self._update_initial( + raw_result = await self._update_initial( # type: ignore resource_group_name=resource_group_name, resource_provider_namespace=resource_provider_namespace, parent_resource_path=parent_resource_path, @@ -1899,32 +2558,35 @@ async def begin_update( api_version=api_version, parameters=parameters, content_type=content_type, - cls=lambda x,y,z: x, + cls=lambda x, y, z: x, + headers=_headers, + params=_params, **kwargs ) - kwargs.pop('error_map', None) + kwargs.pop("error_map", None) def get_long_running_output(pipeline_response): - response = pipeline_response.http_response - deserialized = self._deserialize('GenericResource', pipeline_response) + deserialized = self._deserialize("GenericResource", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - - if polling is True: polling_method = AsyncARMPolling(lro_delay, **kwargs) - elif polling is False: polling_method = AsyncNoPolling() - else: polling_method = polling + if polling is True: + polling_method = cast(AsyncPollingMethod, AsyncARMPolling(lro_delay, **kwargs)) # type: AsyncPollingMethod + elif polling is False: + polling_method = cast(AsyncPollingMethod, AsyncNoPolling()) + else: + polling_method = polling if cont_token: return AsyncLROPoller.from_continuation_token( polling_method=polling_method, continuation_token=cont_token, client=self._client, - deserialization_callback=get_long_running_output + deserialization_callback=get_long_running_output, ) return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) - begin_update.metadata = {'url': "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{parentResourcePath}/{resourceType}/{resourceName}"} # type: ignore + begin_update.metadata = {"url": "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{parentResourcePath}/{resourceType}/{resourceName}"} # type: ignore @distributed_trace_async async def get( @@ -1936,34 +2598,40 @@ async def get( resource_name: str, api_version: str, **kwargs: Any - ) -> "_models.GenericResource": + ) -> _models.GenericResource: """Gets a resource. :param resource_group_name: The name of the resource group containing the resource to get. The - name is case insensitive. + name is case insensitive. Required. :type resource_group_name: str - :param resource_provider_namespace: The namespace of the resource provider. + :param resource_provider_namespace: The namespace of the resource provider. Required. :type resource_provider_namespace: str - :param parent_resource_path: The parent resource identity. + :param parent_resource_path: The parent resource identity. Required. :type parent_resource_path: str - :param resource_type: The resource type of the resource. + :param resource_type: The resource type of the resource. Required. :type resource_type: str - :param resource_name: The name of the resource to get. + :param resource_name: The name of the resource to get. Required. :type resource_name: str - :param api_version: The API version to use for the operation. + :param api_version: The API version to use for the operation. Required. :type api_version: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: GenericResource, or the result of cls(response) + :return: GenericResource or the result of cls(response) :rtype: ~azure.mgmt.resource.resources.v2018_02_01.models.GenericResource - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.GenericResource"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = kwargs.pop("params", {}) or {} + + cls = kwargs.pop("cls", None) # type: ClsType[_models.GenericResource] - request = build_resources_get_request( resource_group_name=resource_group_name, resource_provider_namespace=resource_provider_namespace, @@ -1972,72 +2640,75 @@ async def get( resource_name=resource_name, subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.get.metadata['url'], + template_url=self.get.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) - deserialized = self._deserialize('GenericResource', pipeline_response) + deserialized = self._deserialize("GenericResource", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - get.metadata = {'url': "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{parentResourcePath}/{resourceType}/{resourceName}"} # type: ignore - + get.metadata = {"url": "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{parentResourcePath}/{resourceType}/{resourceName}"} # type: ignore @distributed_trace_async - async def check_existence_by_id( - self, - resource_id: str, - api_version: str, - **kwargs: Any - ) -> bool: + async def check_existence_by_id(self, resource_id: str, api_version: str, **kwargs: Any) -> bool: """Checks by ID whether a resource exists. :param resource_id: The fully qualified ID of the resource, including the resource name and resource type. Use the format, /subscriptions/{guid}/resourceGroups/{resource-group-name}/{resource-provider-namespace}/{resource-type}/{resource-name}. + Required. :type resource_id: str - :param api_version: The API version to use for the operation. + :param api_version: The API version to use for the operation. Required. :type api_version: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: bool, or the result of cls(response) + :return: bool or the result of cls(response) :rtype: bool - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType[None] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = kwargs.pop("params", {}) or {} + + cls = kwargs.pop("cls", None) # type: ClsType[None] - request = build_resources_check_existence_by_id_request( resource_id=resource_id, api_version=api_version, - template_url=self.check_existence_by_id.metadata['url'], + template_url=self.check_existence_by_id.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [204, 404]: @@ -2048,35 +2719,38 @@ async def check_existence_by_id( return cls(pipeline_response, None, {}) return 200 <= response.status_code <= 299 - check_existence_by_id.metadata = {'url': "/{resourceId}"} # type: ignore - + check_existence_by_id.metadata = {"url": "/{resourceId}"} # type: ignore async def _delete_by_id_initial( # pylint: disable=inconsistent-return-statements - self, - resource_id: str, - api_version: str, - **kwargs: Any + self, resource_id: str, api_version: str, **kwargs: Any ) -> None: - cls = kwargs.pop('cls', None) # type: ClsType[None] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = kwargs.pop("params", {}) or {} + + cls = kwargs.pop("cls", None) # type: ClsType[None] - - request = build_resources_delete_by_id_request_initial( + request = build_resources_delete_by_id_request( resource_id=resource_id, api_version=api_version, - template_url=self._delete_by_id_initial.metadata['url'], + template_url=self._delete_by_id_initial.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200, 202, 204]: @@ -2086,23 +2760,18 @@ async def _delete_by_id_initial( # pylint: disable=inconsistent-return-statemen if cls: return cls(pipeline_response, None, {}) - _delete_by_id_initial.metadata = {'url': "/{resourceId}"} # type: ignore - + _delete_by_id_initial.metadata = {"url": "/{resourceId}"} # type: ignore @distributed_trace_async - async def begin_delete_by_id( # pylint: disable=inconsistent-return-statements - self, - resource_id: str, - api_version: str, - **kwargs: Any - ) -> AsyncLROPoller[None]: + async def begin_delete_by_id(self, resource_id: str, api_version: str, **kwargs: Any) -> AsyncLROPoller[None]: """Deletes a resource by ID. :param resource_id: The fully qualified ID of the resource, including the resource name and resource type. Use the format, /subscriptions/{guid}/resourceGroups/{resource-group-name}/{resource-provider-namespace}/{resource-type}/{resource-name}. + Required. :type resource_id: str - :param api_version: The API version to use for the operation. + :param api_version: The API version to use for the operation. Required. :type api_version: str :keyword callable cls: A custom type or function that will be passed the direct response :keyword str continuation_token: A continuation token to restart a poller from a saved state. @@ -2114,75 +2783,89 @@ async def begin_delete_by_id( # pylint: disable=inconsistent-return-statements Retry-After header is present. :return: An instance of AsyncLROPoller that returns either None or the result of cls(response) :rtype: ~azure.core.polling.AsyncLROPoller[None] - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - polling = kwargs.pop('polling', True) # type: Union[bool, AsyncPollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType[None] - lro_delay = kwargs.pop( - 'polling_interval', - self._config.polling_interval - ) - cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] + _headers = kwargs.pop("headers", {}) or {} + _params = kwargs.pop("params", {}) or {} + + cls = kwargs.pop("cls", None) # type: ClsType[None] + polling = kwargs.pop("polling", True) # type: Union[bool, AsyncPollingMethod] + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token = kwargs.pop("continuation_token", None) # type: Optional[str] if cont_token is None: - raw_result = await self._delete_by_id_initial( + raw_result = await self._delete_by_id_initial( # type: ignore resource_id=resource_id, api_version=api_version, - cls=lambda x,y,z: x, + cls=lambda x, y, z: x, + headers=_headers, + params=_params, **kwargs ) - kwargs.pop('error_map', None) + kwargs.pop("error_map", None) - def get_long_running_output(pipeline_response): + def get_long_running_output(pipeline_response): # pylint: disable=inconsistent-return-statements if cls: return cls(pipeline_response, None, {}) - - if polling is True: polling_method = AsyncARMPolling(lro_delay, **kwargs) - elif polling is False: polling_method = AsyncNoPolling() - else: polling_method = polling + if polling is True: + polling_method = cast(AsyncPollingMethod, AsyncARMPolling(lro_delay, **kwargs)) # type: AsyncPollingMethod + elif polling is False: + polling_method = cast(AsyncPollingMethod, AsyncNoPolling()) + else: + polling_method = polling if cont_token: return AsyncLROPoller.from_continuation_token( polling_method=polling_method, continuation_token=cont_token, client=self._client, - deserialization_callback=get_long_running_output + deserialization_callback=get_long_running_output, ) return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) - begin_delete_by_id.metadata = {'url': "/{resourceId}"} # type: ignore + begin_delete_by_id.metadata = {"url": "/{resourceId}"} # type: ignore async def _create_or_update_by_id_initial( - self, - resource_id: str, - api_version: str, - parameters: "_models.GenericResource", - **kwargs: Any - ) -> Optional["_models.GenericResource"]: - cls = kwargs.pop('cls', None) # type: ClsType[Optional["_models.GenericResource"]] + self, resource_id: str, api_version: str, parameters: Union[_models.GenericResource, IO], **kwargs: Any + ) -> Optional[_models.GenericResource]: error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = kwargs.pop("params", {}) or {} - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[Optional[_models.GenericResource]] - _json = self._serialize.body(parameters, 'GenericResource') + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(parameters, (IO, bytes)): + _content = parameters + else: + _json = self._serialize.body(parameters, "GenericResource") - request = build_resources_create_or_update_by_id_request_initial( + request = build_resources_create_or_update_by_id_request( resource_id=resource_id, - content_type=content_type, api_version=api_version, + content_type=content_type, json=_json, - template_url=self._create_or_update_by_id_initial.metadata['url'], + content=_content, + template_url=self._create_or_update_by_id_initial.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200, 201, 202]: @@ -2191,37 +2874,42 @@ async def _create_or_update_by_id_initial( deserialized = None if response.status_code == 200: - deserialized = self._deserialize('GenericResource', pipeline_response) + deserialized = self._deserialize("GenericResource", pipeline_response) if response.status_code == 201: - deserialized = self._deserialize('GenericResource', pipeline_response) + deserialized = self._deserialize("GenericResource", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - _create_or_update_by_id_initial.metadata = {'url': "/{resourceId}"} # type: ignore - + _create_or_update_by_id_initial.metadata = {"url": "/{resourceId}"} # type: ignore - @distributed_trace_async + @overload async def begin_create_or_update_by_id( self, resource_id: str, api_version: str, - parameters: "_models.GenericResource", + parameters: _models.GenericResource, + *, + content_type: str = "application/json", **kwargs: Any - ) -> AsyncLROPoller["_models.GenericResource"]: + ) -> AsyncLROPoller[_models.GenericResource]: """Create a resource by ID. :param resource_id: The fully qualified ID of the resource, including the resource name and resource type. Use the format, /subscriptions/{guid}/resourceGroups/{resource-group-name}/{resource-provider-namespace}/{resource-type}/{resource-name}. + Required. :type resource_id: str - :param api_version: The API version to use for the operation. + :param api_version: The API version to use for the operation. Required. :type api_version: str - :param parameters: Create or update resource parameters. + :param parameters: Create or update resource parameters. Required. :type parameters: ~azure.mgmt.resource.resources.v2018_02_01.models.GenericResource + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str :keyword callable cls: A custom type or function that will be passed the direct response :keyword str continuation_token: A continuation token to restart a poller from a saved state. :keyword polling: By default, your polling method will be AsyncARMPolling. Pass in False for @@ -2234,81 +2922,167 @@ async def begin_create_or_update_by_id( cls(response) :rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.resource.resources.v2018_02_01.models.GenericResource] - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] - polling = kwargs.pop('polling', True) # type: Union[bool, AsyncPollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType["_models.GenericResource"] - lro_delay = kwargs.pop( - 'polling_interval', - self._config.polling_interval - ) - cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] + + @overload + async def begin_create_or_update_by_id( + self, + resource_id: str, + api_version: str, + parameters: IO, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> AsyncLROPoller[_models.GenericResource]: + """Create a resource by ID. + + :param resource_id: The fully qualified ID of the resource, including the resource name and + resource type. Use the format, + /subscriptions/{guid}/resourceGroups/{resource-group-name}/{resource-provider-namespace}/{resource-type}/{resource-name}. + Required. + :type resource_id: str + :param api_version: The API version to use for the operation. Required. + :type api_version: str + :param parameters: Create or update resource parameters. Required. + :type parameters: IO + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be AsyncARMPolling. Pass in False for + this operation to not poll, or pass in your own initialized polling object for a personal + polling strategy. + :paramtype polling: bool or ~azure.core.polling.AsyncPollingMethod + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of AsyncLROPoller that returns either GenericResource or the result of + cls(response) + :rtype: + ~azure.core.polling.AsyncLROPoller[~azure.mgmt.resource.resources.v2018_02_01.models.GenericResource] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace_async + async def begin_create_or_update_by_id( + self, resource_id: str, api_version: str, parameters: Union[_models.GenericResource, IO], **kwargs: Any + ) -> AsyncLROPoller[_models.GenericResource]: + """Create a resource by ID. + + :param resource_id: The fully qualified ID of the resource, including the resource name and + resource type. Use the format, + /subscriptions/{guid}/resourceGroups/{resource-group-name}/{resource-provider-namespace}/{resource-type}/{resource-name}. + Required. + :type resource_id: str + :param api_version: The API version to use for the operation. Required. + :type api_version: str + :param parameters: Create or update resource parameters. Is either a model type or a IO type. + Required. + :type parameters: ~azure.mgmt.resource.resources.v2018_02_01.models.GenericResource or IO + :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. + Default value is None. + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be AsyncARMPolling. Pass in False for + this operation to not poll, or pass in your own initialized polling object for a personal + polling strategy. + :paramtype polling: bool or ~azure.core.polling.AsyncPollingMethod + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of AsyncLROPoller that returns either GenericResource or the result of + cls(response) + :rtype: + ~azure.core.polling.AsyncLROPoller[~azure.mgmt.resource.resources.v2018_02_01.models.GenericResource] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = kwargs.pop("params", {}) or {} + + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.GenericResource] + polling = kwargs.pop("polling", True) # type: Union[bool, AsyncPollingMethod] + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token = kwargs.pop("continuation_token", None) # type: Optional[str] if cont_token is None: - raw_result = await self._create_or_update_by_id_initial( + raw_result = await self._create_or_update_by_id_initial( # type: ignore resource_id=resource_id, api_version=api_version, parameters=parameters, content_type=content_type, - cls=lambda x,y,z: x, + cls=lambda x, y, z: x, + headers=_headers, + params=_params, **kwargs ) - kwargs.pop('error_map', None) + kwargs.pop("error_map", None) def get_long_running_output(pipeline_response): - response = pipeline_response.http_response - deserialized = self._deserialize('GenericResource', pipeline_response) + deserialized = self._deserialize("GenericResource", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - - if polling is True: polling_method = AsyncARMPolling(lro_delay, **kwargs) - elif polling is False: polling_method = AsyncNoPolling() - else: polling_method = polling + if polling is True: + polling_method = cast(AsyncPollingMethod, AsyncARMPolling(lro_delay, **kwargs)) # type: AsyncPollingMethod + elif polling is False: + polling_method = cast(AsyncPollingMethod, AsyncNoPolling()) + else: + polling_method = polling if cont_token: return AsyncLROPoller.from_continuation_token( polling_method=polling_method, continuation_token=cont_token, client=self._client, - deserialization_callback=get_long_running_output + deserialization_callback=get_long_running_output, ) return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) - begin_create_or_update_by_id.metadata = {'url': "/{resourceId}"} # type: ignore + begin_create_or_update_by_id.metadata = {"url": "/{resourceId}"} # type: ignore async def _update_by_id_initial( - self, - resource_id: str, - api_version: str, - parameters: "_models.GenericResource", - **kwargs: Any - ) -> Optional["_models.GenericResource"]: - cls = kwargs.pop('cls', None) # type: ClsType[Optional["_models.GenericResource"]] + self, resource_id: str, api_version: str, parameters: Union[_models.GenericResource, IO], **kwargs: Any + ) -> Optional[_models.GenericResource]: error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = kwargs.pop("params", {}) or {} - _json = self._serialize.body(parameters, 'GenericResource') + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[Optional[_models.GenericResource]] - request = build_resources_update_by_id_request_initial( + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(parameters, (IO, bytes)): + _content = parameters + else: + _json = self._serialize.body(parameters, "GenericResource") + + request = build_resources_update_by_id_request( resource_id=resource_id, - content_type=content_type, api_version=api_version, + content_type=content_type, json=_json, - template_url=self._update_by_id_initial.metadata['url'], + content=_content, + template_url=self._update_by_id_initial.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200, 202]: @@ -2317,34 +3091,111 @@ async def _update_by_id_initial( deserialized = None if response.status_code == 200: - deserialized = self._deserialize('GenericResource', pipeline_response) + deserialized = self._deserialize("GenericResource", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - _update_by_id_initial.metadata = {'url': "/{resourceId}"} # type: ignore + _update_by_id_initial.metadata = {"url": "/{resourceId}"} # type: ignore - - @distributed_trace_async + @overload async def begin_update_by_id( self, resource_id: str, api_version: str, - parameters: "_models.GenericResource", + parameters: _models.GenericResource, + *, + content_type: str = "application/json", **kwargs: Any - ) -> AsyncLROPoller["_models.GenericResource"]: + ) -> AsyncLROPoller[_models.GenericResource]: """Updates a resource by ID. :param resource_id: The fully qualified ID of the resource, including the resource name and resource type. Use the format, /subscriptions/{guid}/resourceGroups/{resource-group-name}/{resource-provider-namespace}/{resource-type}/{resource-name}. + Required. :type resource_id: str - :param api_version: The API version to use for the operation. + :param api_version: The API version to use for the operation. Required. :type api_version: str - :param parameters: Update resource parameters. + :param parameters: Update resource parameters. Required. :type parameters: ~azure.mgmt.resource.resources.v2018_02_01.models.GenericResource + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be AsyncARMPolling. Pass in False for + this operation to not poll, or pass in your own initialized polling object for a personal + polling strategy. + :paramtype polling: bool or ~azure.core.polling.AsyncPollingMethod + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of AsyncLROPoller that returns either GenericResource or the result of + cls(response) + :rtype: + ~azure.core.polling.AsyncLROPoller[~azure.mgmt.resource.resources.v2018_02_01.models.GenericResource] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + async def begin_update_by_id( + self, + resource_id: str, + api_version: str, + parameters: IO, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> AsyncLROPoller[_models.GenericResource]: + """Updates a resource by ID. + + :param resource_id: The fully qualified ID of the resource, including the resource name and + resource type. Use the format, + /subscriptions/{guid}/resourceGroups/{resource-group-name}/{resource-provider-namespace}/{resource-type}/{resource-name}. + Required. + :type resource_id: str + :param api_version: The API version to use for the operation. Required. + :type api_version: str + :param parameters: Update resource parameters. Required. + :type parameters: IO + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be AsyncARMPolling. Pass in False for + this operation to not poll, or pass in your own initialized polling object for a personal + polling strategy. + :paramtype polling: bool or ~azure.core.polling.AsyncPollingMethod + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of AsyncLROPoller that returns either GenericResource or the result of + cls(response) + :rtype: + ~azure.core.polling.AsyncLROPoller[~azure.mgmt.resource.resources.v2018_02_01.models.GenericResource] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace_async + async def begin_update_by_id( + self, resource_id: str, api_version: str, parameters: Union[_models.GenericResource, IO], **kwargs: Any + ) -> AsyncLROPoller[_models.GenericResource]: + """Updates a resource by ID. + + :param resource_id: The fully qualified ID of the resource, including the resource name and + resource type. Use the format, + /subscriptions/{guid}/resourceGroups/{resource-group-name}/{resource-provider-namespace}/{resource-type}/{resource-name}. + Required. + :type resource_id: str + :param api_version: The API version to use for the operation. Required. + :type api_version: str + :param parameters: Update resource parameters. Is either a model type or a IO type. Required. + :type parameters: ~azure.mgmt.resource.resources.v2018_02_01.models.GenericResource or IO + :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. + Default value is None. + :paramtype content_type: str :keyword callable cls: A custom type or function that will be passed the direct response :keyword str continuation_token: A continuation token to restart a poller from a saved state. :keyword polling: By default, your polling method will be AsyncARMPolling. Pass in False for @@ -2357,165 +3208,171 @@ async def begin_update_by_id( cls(response) :rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.resource.resources.v2018_02_01.models.GenericResource] - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] - polling = kwargs.pop('polling', True) # type: Union[bool, AsyncPollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType["_models.GenericResource"] - lro_delay = kwargs.pop( - 'polling_interval', - self._config.polling_interval - ) - cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = kwargs.pop("params", {}) or {} + + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.GenericResource] + polling = kwargs.pop("polling", True) # type: Union[bool, AsyncPollingMethod] + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token = kwargs.pop("continuation_token", None) # type: Optional[str] if cont_token is None: - raw_result = await self._update_by_id_initial( + raw_result = await self._update_by_id_initial( # type: ignore resource_id=resource_id, api_version=api_version, parameters=parameters, content_type=content_type, - cls=lambda x,y,z: x, + cls=lambda x, y, z: x, + headers=_headers, + params=_params, **kwargs ) - kwargs.pop('error_map', None) + kwargs.pop("error_map", None) def get_long_running_output(pipeline_response): - response = pipeline_response.http_response - deserialized = self._deserialize('GenericResource', pipeline_response) + deserialized = self._deserialize("GenericResource", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - - if polling is True: polling_method = AsyncARMPolling(lro_delay, **kwargs) - elif polling is False: polling_method = AsyncNoPolling() - else: polling_method = polling + if polling is True: + polling_method = cast(AsyncPollingMethod, AsyncARMPolling(lro_delay, **kwargs)) # type: AsyncPollingMethod + elif polling is False: + polling_method = cast(AsyncPollingMethod, AsyncNoPolling()) + else: + polling_method = polling if cont_token: return AsyncLROPoller.from_continuation_token( polling_method=polling_method, continuation_token=cont_token, client=self._client, - deserialization_callback=get_long_running_output + deserialization_callback=get_long_running_output, ) return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) - begin_update_by_id.metadata = {'url': "/{resourceId}"} # type: ignore + begin_update_by_id.metadata = {"url": "/{resourceId}"} # type: ignore @distributed_trace_async - async def get_by_id( - self, - resource_id: str, - api_version: str, - **kwargs: Any - ) -> "_models.GenericResource": + async def get_by_id(self, resource_id: str, api_version: str, **kwargs: Any) -> _models.GenericResource: """Gets a resource by ID. :param resource_id: The fully qualified ID of the resource, including the resource name and resource type. Use the format, /subscriptions/{guid}/resourceGroups/{resource-group-name}/{resource-provider-namespace}/{resource-type}/{resource-name}. + Required. :type resource_id: str - :param api_version: The API version to use for the operation. + :param api_version: The API version to use for the operation. Required. :type api_version: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: GenericResource, or the result of cls(response) + :return: GenericResource or the result of cls(response) :rtype: ~azure.mgmt.resource.resources.v2018_02_01.models.GenericResource - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.GenericResource"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = kwargs.pop("params", {}) or {} + + cls = kwargs.pop("cls", None) # type: ClsType[_models.GenericResource] - request = build_resources_get_by_id_request( resource_id=resource_id, api_version=api_version, - template_url=self.get_by_id.metadata['url'], + template_url=self.get_by_id.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) - deserialized = self._deserialize('GenericResource', pipeline_response) + deserialized = self._deserialize("GenericResource", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - get_by_id.metadata = {'url': "/{resourceId}"} # type: ignore + get_by_id.metadata = {"url": "/{resourceId}"} # type: ignore -class ResourceGroupsOperations: - """ResourceGroupsOperations async operations. - You should not instantiate this class directly. Instead, you should create a Client instance that - instantiates it for you and attaches it as an attribute. +class ResourceGroupsOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. - :ivar models: Alias to model classes used in this operation group. - :type models: ~azure.mgmt.resource.resources.v2018_02_01.models - :param client: Client for service requests. - :param config: Configuration of service client. - :param serializer: An object model serializer. - :param deserializer: An object model deserializer. + Instead, you should access the following operations through + :class:`~azure.mgmt.resource.resources.v2018_02_01.aio.ResourceManagementClient`'s + :attr:`resource_groups` attribute. """ models = _models - def __init__(self, client, config, serializer, deserializer) -> None: - self._client = client - self._serialize = serializer - self._deserialize = deserializer - self._config = config + def __init__(self, *args, **kwargs) -> None: + input_args = list(args) + self._client = input_args.pop(0) if input_args else kwargs.pop("client") + self._config = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") @distributed_trace_async - async def check_existence( - self, - resource_group_name: str, - **kwargs: Any - ) -> bool: + async def check_existence(self, resource_group_name: str, **kwargs: Any) -> bool: """Checks whether a resource group exists. :param resource_group_name: The name of the resource group to check. The name is case - insensitive. + insensitive. Required. :type resource_group_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: bool, or the result of cls(response) + :return: bool or the result of cls(response) :rtype: bool - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType[None] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + 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', "2018-02-01") # type: str + api_version = kwargs.pop("api_version", _params.pop("api-version", "2018-02-01")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[None] - request = build_resource_groups_check_existence_request( resource_group_name=resource_group_name, subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.check_existence.metadata['url'], + template_url=self.check_existence.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [204, 404]: @@ -2526,37 +3383,92 @@ async def check_existence( return cls(pipeline_response, None, {}) return 200 <= response.status_code <= 299 - check_existence.metadata = {'url': "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}"} # type: ignore - + check_existence.metadata = {"url": "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}"} # type: ignore - @distributed_trace_async + @overload async def create_or_update( self, resource_group_name: str, - parameters: "_models.ResourceGroup", + parameters: _models.ResourceGroup, + *, + content_type: str = "application/json", **kwargs: Any - ) -> "_models.ResourceGroup": + ) -> _models.ResourceGroup: """Creates or updates a resource group. - :param resource_group_name: The name of the resource group to create or update. + :param resource_group_name: The name of the resource group to create or update. Required. :type resource_group_name: str - :param parameters: Parameters supplied to the create or update a resource group. + :param parameters: Parameters supplied to the create or update a resource group. Required. :type parameters: ~azure.mgmt.resource.resources.v2018_02_01.models.ResourceGroup + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: ResourceGroup or the result of cls(response) + :rtype: ~azure.mgmt.resource.resources.v2018_02_01.models.ResourceGroup + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + async def create_or_update( + self, resource_group_name: str, parameters: IO, *, content_type: str = "application/json", **kwargs: Any + ) -> _models.ResourceGroup: + """Creates or updates a resource group. + + :param resource_group_name: The name of the resource group to create or update. Required. + :type resource_group_name: str + :param parameters: Parameters supplied to the create or update a resource group. Required. + :type parameters: IO + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: ResourceGroup or the result of cls(response) + :rtype: ~azure.mgmt.resource.resources.v2018_02_01.models.ResourceGroup + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace_async + async def create_or_update( + self, resource_group_name: str, parameters: Union[_models.ResourceGroup, IO], **kwargs: Any + ) -> _models.ResourceGroup: + """Creates or updates a resource group. + + :param resource_group_name: The name of the resource group to create or update. Required. + :type resource_group_name: str + :param parameters: Parameters supplied to the create or update a resource group. Is either a + model type or a IO type. Required. + :type parameters: ~azure.mgmt.resource.resources.v2018_02_01.models.ResourceGroup or IO + :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. + Default value is None. + :paramtype content_type: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: ResourceGroup, or the result of cls(response) + :return: ResourceGroup or the result of cls(response) :rtype: ~azure.mgmt.resource.resources.v2018_02_01.models.ResourceGroup - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.ResourceGroup"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', "2018-02-01") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + api_version = kwargs.pop("api_version", _params.pop("api-version", "2018-02-01")) # type: str + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.ResourceGroup] - _json = self._serialize.body(parameters, 'ResourceGroup') + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(parameters, (IO, bytes)): + _content = parameters + else: + _json = self._serialize.body(parameters, "ResourceGroup") request = build_resource_groups_create_or_update_request( resource_group_name=resource_group_name, @@ -2564,16 +3476,18 @@ async def create_or_update( api_version=api_version, content_type=content_type, json=_json, - template_url=self.create_or_update.metadata['url'], + content=_content, + template_url=self.create_or_update.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200, 201]: @@ -2581,47 +3495,50 @@ async def create_or_update( raise HttpResponseError(response=response, error_format=ARMErrorFormat) if response.status_code == 200: - deserialized = self._deserialize('ResourceGroup', pipeline_response) + deserialized = self._deserialize("ResourceGroup", pipeline_response) if response.status_code == 201: - deserialized = self._deserialize('ResourceGroup', pipeline_response) + deserialized = self._deserialize("ResourceGroup", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - create_or_update.metadata = {'url': "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}"} # type: ignore - + create_or_update.metadata = {"url": "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}"} # type: ignore async def _delete_initial( # pylint: disable=inconsistent-return-statements - self, - resource_group_name: str, - **kwargs: Any + self, resource_group_name: str, **kwargs: Any ) -> None: - cls = kwargs.pop('cls', None) # type: ClsType[None] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + 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', "2018-02-01") # type: str + api_version = kwargs.pop("api_version", _params.pop("api-version", "2018-02-01")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[None] - - request = build_resource_groups_delete_request_initial( + request = build_resource_groups_delete_request( resource_group_name=resource_group_name, subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self._delete_initial.metadata['url'], + template_url=self._delete_initial.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200, 202]: @@ -2631,22 +3548,17 @@ async def _delete_initial( # pylint: disable=inconsistent-return-statements if cls: return cls(pipeline_response, None, {}) - _delete_initial.metadata = {'url': "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}"} # type: ignore - + _delete_initial.metadata = {"url": "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}"} # type: ignore @distributed_trace_async - async def begin_delete( # pylint: disable=inconsistent-return-statements - self, - resource_group_name: str, - **kwargs: Any - ) -> AsyncLROPoller[None]: + async def begin_delete(self, resource_group_name: str, **kwargs: Any) -> AsyncLROPoller[None]: """Deletes a resource group. When you delete a resource group, all of its resources are also deleted. Deleting a resource group deletes all of its template deployments and currently stored operations. :param resource_group_name: The name of the resource group to delete. The name is case - insensitive. + insensitive. Required. :type resource_group_name: str :keyword callable cls: A custom type or function that will be passed the direct response :keyword str continuation_token: A continuation token to restart a poller from a saved state. @@ -2658,106 +3570,113 @@ async def begin_delete( # pylint: disable=inconsistent-return-statements Retry-After header is present. :return: An instance of AsyncLROPoller that returns either None or the result of cls(response) :rtype: ~azure.core.polling.AsyncLROPoller[None] - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - api_version = kwargs.pop('api_version', "2018-02-01") # type: str - polling = kwargs.pop('polling', True) # type: Union[bool, AsyncPollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType[None] - lro_delay = kwargs.pop( - 'polling_interval', - self._config.polling_interval - ) - cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2018-02-01")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[None] + polling = kwargs.pop("polling", True) # type: Union[bool, AsyncPollingMethod] + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token = kwargs.pop("continuation_token", None) # type: Optional[str] if cont_token is None: - raw_result = await self._delete_initial( + raw_result = await self._delete_initial( # type: ignore resource_group_name=resource_group_name, api_version=api_version, - cls=lambda x,y,z: x, + cls=lambda x, y, z: x, + headers=_headers, + params=_params, **kwargs ) - kwargs.pop('error_map', None) + kwargs.pop("error_map", None) - def get_long_running_output(pipeline_response): + def get_long_running_output(pipeline_response): # pylint: disable=inconsistent-return-statements if cls: return cls(pipeline_response, None, {}) - - if polling is True: polling_method = AsyncARMPolling(lro_delay, **kwargs) - elif polling is False: polling_method = AsyncNoPolling() - else: polling_method = polling + if polling is True: + polling_method = cast(AsyncPollingMethod, AsyncARMPolling(lro_delay, **kwargs)) # type: AsyncPollingMethod + elif polling is False: + polling_method = cast(AsyncPollingMethod, AsyncNoPolling()) + else: + polling_method = polling if cont_token: return AsyncLROPoller.from_continuation_token( polling_method=polling_method, continuation_token=cont_token, client=self._client, - deserialization_callback=get_long_running_output + deserialization_callback=get_long_running_output, ) return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) - begin_delete.metadata = {'url': "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}"} # type: ignore + begin_delete.metadata = {"url": "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}"} # type: ignore @distributed_trace_async - async def get( - self, - resource_group_name: str, - **kwargs: Any - ) -> "_models.ResourceGroup": + async def get(self, resource_group_name: str, **kwargs: Any) -> _models.ResourceGroup: """Gets a resource group. :param resource_group_name: The name of the resource group to get. The name is case - insensitive. + insensitive. Required. :type resource_group_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: ResourceGroup, or the result of cls(response) + :return: ResourceGroup or the result of cls(response) :rtype: ~azure.mgmt.resource.resources.v2018_02_01.models.ResourceGroup - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.ResourceGroup"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) - api_version = kwargs.pop('api_version', "2018-02-01") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2018-02-01")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[_models.ResourceGroup] - request = build_resource_groups_get_request( resource_group_name=resource_group_name, subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.get.metadata['url'], + template_url=self.get.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) - deserialized = self._deserialize('ResourceGroup', pipeline_response) + deserialized = self._deserialize("ResourceGroup", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - get.metadata = {'url': "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}"} # type: ignore + get.metadata = {"url": "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}"} # type: ignore - - @distributed_trace_async + @overload async def update( self, resource_group_name: str, - parameters: "_models.ResourceGroupPatchable", + parameters: _models.ResourceGroupPatchable, + *, + content_type: str = "application/json", **kwargs: Any - ) -> "_models.ResourceGroup": + ) -> _models.ResourceGroup: """Updates a resource group. Resource groups can be updated through a simple PATCH operation to a group address. The format @@ -2765,25 +3684,90 @@ async def update( the current value is retained. :param resource_group_name: The name of the resource group to update. The name is case - insensitive. + insensitive. Required. :type resource_group_name: str - :param parameters: Parameters supplied to update a resource group. + :param parameters: Parameters supplied to update a resource group. Required. :type parameters: ~azure.mgmt.resource.resources.v2018_02_01.models.ResourceGroupPatchable + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: ResourceGroup or the result of cls(response) + :rtype: ~azure.mgmt.resource.resources.v2018_02_01.models.ResourceGroup + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + async def update( + self, resource_group_name: str, parameters: IO, *, content_type: str = "application/json", **kwargs: Any + ) -> _models.ResourceGroup: + """Updates a resource group. + + Resource groups can be updated through a simple PATCH operation to a group address. The format + of the request is the same as that for creating a resource group. If a field is unspecified, + the current value is retained. + + :param resource_group_name: The name of the resource group to update. The name is case + insensitive. Required. + :type resource_group_name: str + :param parameters: Parameters supplied to update a resource group. Required. + :type parameters: IO + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: ResourceGroup or the result of cls(response) + :rtype: ~azure.mgmt.resource.resources.v2018_02_01.models.ResourceGroup + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace_async + async def update( + self, resource_group_name: str, parameters: Union[_models.ResourceGroupPatchable, IO], **kwargs: Any + ) -> _models.ResourceGroup: + """Updates a resource group. + + Resource groups can be updated through a simple PATCH operation to a group address. The format + of the request is the same as that for creating a resource group. If a field is unspecified, + the current value is retained. + + :param resource_group_name: The name of the resource group to update. The name is case + insensitive. Required. + :type resource_group_name: str + :param parameters: Parameters supplied to update a resource group. Is either a model type or a + IO type. Required. + :type parameters: ~azure.mgmt.resource.resources.v2018_02_01.models.ResourceGroupPatchable or + IO + :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. + Default value is None. + :paramtype content_type: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: ResourceGroup, or the result of cls(response) + :return: ResourceGroup or the result of cls(response) :rtype: ~azure.mgmt.resource.resources.v2018_02_01.models.ResourceGroup - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.ResourceGroup"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) - api_version = kwargs.pop('api_version', "2018-02-01") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - _json = self._serialize.body(parameters, 'ResourceGroupPatchable') + api_version = kwargs.pop("api_version", _params.pop("api-version", "2018-02-01")) # type: str + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.ResourceGroup] + + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(parameters, (IO, bytes)): + _content = parameters + else: + _json = self._serialize.body(parameters, "ResourceGroupPatchable") request = build_resource_groups_update_request( resource_group_name=resource_group_name, @@ -2791,60 +3775,117 @@ async def update( api_version=api_version, content_type=content_type, json=_json, - template_url=self.update.metadata['url'], + content=_content, + template_url=self.update.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) - deserialized = self._deserialize('ResourceGroup', pipeline_response) + deserialized = self._deserialize("ResourceGroup", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - update.metadata = {'url': "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}"} # type: ignore + update.metadata = {"url": "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}"} # type: ignore - - @distributed_trace_async + @overload async def export_template( self, resource_group_name: str, - parameters: "_models.ExportTemplateRequest", + parameters: _models.ExportTemplateRequest, + *, + content_type: str = "application/json", **kwargs: Any - ) -> "_models.ResourceGroupExportResult": + ) -> _models.ResourceGroupExportResult: """Captures the specified resource group as a template. - :param resource_group_name: The name of the resource group to export as a template. + :param resource_group_name: The name of the resource group to export as a template. Required. :type resource_group_name: str - :param parameters: Parameters for exporting the template. + :param parameters: Parameters for exporting the template. Required. :type parameters: ~azure.mgmt.resource.resources.v2018_02_01.models.ExportTemplateRequest + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: ResourceGroupExportResult or the result of cls(response) + :rtype: ~azure.mgmt.resource.resources.v2018_02_01.models.ResourceGroupExportResult + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + async def export_template( + self, resource_group_name: str, parameters: IO, *, content_type: str = "application/json", **kwargs: Any + ) -> _models.ResourceGroupExportResult: + """Captures the specified resource group as a template. + + :param resource_group_name: The name of the resource group to export as a template. Required. + :type resource_group_name: str + :param parameters: Parameters for exporting the template. Required. + :type parameters: IO + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: ResourceGroupExportResult or the result of cls(response) + :rtype: ~azure.mgmt.resource.resources.v2018_02_01.models.ResourceGroupExportResult + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace_async + async def export_template( + self, resource_group_name: str, parameters: Union[_models.ExportTemplateRequest, IO], **kwargs: Any + ) -> _models.ResourceGroupExportResult: + """Captures the specified resource group as a template. + + :param resource_group_name: The name of the resource group to export as a template. Required. + :type resource_group_name: str + :param parameters: Parameters for exporting the template. Is either a model type or a IO type. + Required. + :type parameters: ~azure.mgmt.resource.resources.v2018_02_01.models.ExportTemplateRequest or IO + :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. + Default value is None. + :paramtype content_type: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: ResourceGroupExportResult, or the result of cls(response) + :return: ResourceGroupExportResult or the result of cls(response) :rtype: ~azure.mgmt.resource.resources.v2018_02_01.models.ResourceGroupExportResult - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.ResourceGroupExportResult"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) - api_version = kwargs.pop('api_version', "2018-02-01") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - _json = self._serialize.body(parameters, 'ExportTemplateRequest') + api_version = kwargs.pop("api_version", _params.pop("api-version", "2018-02-01")) # type: str + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.ResourceGroupExportResult] + + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(parameters, (IO, bytes)): + _content = parameters + else: + _json = self._serialize.body(parameters, "ExportTemplateRequest") request = build_resource_groups_export_template_request( resource_group_name=resource_group_name, @@ -2852,39 +3893,37 @@ async def export_template( api_version=api_version, content_type=content_type, json=_json, - template_url=self.export_template.metadata['url'], + content=_content, + template_url=self.export_template.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) - deserialized = self._deserialize('ResourceGroupExportResult', pipeline_response) + deserialized = self._deserialize("ResourceGroupExportResult", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - export_template.metadata = {'url': "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/exportTemplate"} # type: ignore - + export_template.metadata = {"url": "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/exportTemplate"} # type: ignore @distributed_trace def list( - self, - filter: Optional[str] = None, - top: Optional[int] = None, - **kwargs: Any - ) -> AsyncIterable["_models.ResourceGroupListResult"]: + self, filter: Optional[str] = None, top: Optional[int] = None, **kwargs: Any + ) -> AsyncIterable["_models.ResourceGroup"]: """Gets all the resource groups for a subscription. :param filter: The filter to apply on the operation. Default value is None. @@ -2893,40 +3932,48 @@ def list( Default value is None. :type top: int :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either ResourceGroupListResult or the result of - cls(response) + :return: An iterator like instance of either ResourceGroup or the result of cls(response) :rtype: - ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.resource.resources.v2018_02_01.models.ResourceGroupListResult] - :raises: ~azure.core.exceptions.HttpResponseError + ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.resource.resources.v2018_02_01.models.ResourceGroup] + :raises ~azure.core.exceptions.HttpResponseError: """ - api_version = kwargs.pop('api_version', "2018-02-01") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2018-02-01")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[_models.ResourceGroupListResult] - cls = kwargs.pop('cls', None) # type: ClsType["_models.ResourceGroupListResult"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) + def prepare_request(next_link=None): if not next_link: - + request = build_resource_groups_list_request( subscription_id=self._config.subscription_id, - api_version=api_version, filter=filter, top=top, - template_url=self.list.metadata['url'], + 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.url = self._client.format_url(request.url) # type: ignore else: - - request = build_resource_groups_list_request( - subscription_id=self._config.subscription_id, - template_url=next_link, - ) + # make call to next link with the client's api-version + _parsed_next_link = urlparse(next_link) + _next_request_params = case_insensitive_dict(parse_qs(_parsed_next_link.query)) + _next_request_params["api-version"] = self._config.api_version + request = HttpRequest("GET", urljoin(next_link, _parsed_next_link.path), params=_next_request_params) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore request.method = "GET" return request @@ -2940,10 +3987,8 @@ async def extract_data(pipeline_response): async def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) response = pipeline_response.http_response @@ -2953,75 +3998,75 @@ async def get_next(next_link=None): return pipeline_response + return AsyncItemPaged(get_next, extract_data) + + list.metadata = {"url": "/subscriptions/{subscriptionId}/resourcegroups"} # type: ignore - return AsyncItemPaged( - get_next, extract_data - ) - list.metadata = {'url': "/subscriptions/{subscriptionId}/resourcegroups"} # type: ignore -class TagsOperations: - """TagsOperations async operations. - You should not instantiate this class directly. Instead, you should create a Client instance that - instantiates it for you and attaches it as an attribute. +class TagsOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. - :ivar models: Alias to model classes used in this operation group. - :type models: ~azure.mgmt.resource.resources.v2018_02_01.models - :param client: Client for service requests. - :param config: Configuration of service client. - :param serializer: An object model serializer. - :param deserializer: An object model deserializer. + Instead, you should access the following operations through + :class:`~azure.mgmt.resource.resources.v2018_02_01.aio.ResourceManagementClient`'s + :attr:`tags` attribute. """ models = _models - def __init__(self, client, config, serializer, deserializer) -> None: - self._client = client - self._serialize = serializer - self._deserialize = deserializer - self._config = config + def __init__(self, *args, **kwargs) -> None: + input_args = list(args) + self._client = input_args.pop(0) if input_args else kwargs.pop("client") + self._config = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") @distributed_trace_async async def delete_value( # pylint: disable=inconsistent-return-statements - self, - tag_name: str, - tag_value: str, - **kwargs: Any + self, tag_name: str, tag_value: str, **kwargs: Any ) -> None: """Deletes a tag value. - :param tag_name: The name of the tag. + :param tag_name: The name of the tag. Required. :type tag_name: str - :param tag_value: The value of the tag to delete. + :param tag_value: The value of the tag to delete. Required. :type tag_value: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: None, or the result of cls(response) + :return: None or the result of cls(response) :rtype: None - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType[None] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) - api_version = kwargs.pop('api_version', "2018-02-01") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2018-02-01")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[None] - request = build_tags_delete_value_request( tag_name=tag_name, tag_value=tag_value, subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.delete_value.metadata['url'], + template_url=self.delete_value.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200, 204]: @@ -3031,51 +4076,51 @@ async def delete_value( # pylint: disable=inconsistent-return-statements if cls: return cls(pipeline_response, None, {}) - delete_value.metadata = {'url': "/subscriptions/{subscriptionId}/tagNames/{tagName}/tagValues/{tagValue}"} # type: ignore - + delete_value.metadata = {"url": "/subscriptions/{subscriptionId}/tagNames/{tagName}/tagValues/{tagValue}"} # type: ignore @distributed_trace_async - async def create_or_update_value( - self, - tag_name: str, - tag_value: str, - **kwargs: Any - ) -> "_models.TagValue": + async def create_or_update_value(self, tag_name: str, tag_value: str, **kwargs: Any) -> _models.TagValue: """Creates a tag value. The name of the tag must already exist. - :param tag_name: The name of the tag. + :param tag_name: The name of the tag. Required. :type tag_name: str - :param tag_value: The value of the tag to create. + :param tag_value: The value of the tag to create. Required. :type tag_value: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: TagValue, or the result of cls(response) + :return: TagValue or the result of cls(response) :rtype: ~azure.mgmt.resource.resources.v2018_02_01.models.TagValue - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.TagValue"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + 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', "2018-02-01") # type: str + api_version = kwargs.pop("api_version", _params.pop("api-version", "2018-02-01")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[_models.TagValue] - request = build_tags_create_or_update_value_request( tag_name=tag_name, tag_value=tag_value, subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.create_or_update_value.metadata['url'], + template_url=self.create_or_update_value.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200, 201]: @@ -3083,61 +4128,62 @@ async def create_or_update_value( raise HttpResponseError(response=response, error_format=ARMErrorFormat) if response.status_code == 200: - deserialized = self._deserialize('TagValue', pipeline_response) + deserialized = self._deserialize("TagValue", pipeline_response) if response.status_code == 201: - deserialized = self._deserialize('TagValue', pipeline_response) + deserialized = self._deserialize("TagValue", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - create_or_update_value.metadata = {'url': "/subscriptions/{subscriptionId}/tagNames/{tagName}/tagValues/{tagValue}"} # type: ignore - + create_or_update_value.metadata = {"url": "/subscriptions/{subscriptionId}/tagNames/{tagName}/tagValues/{tagValue}"} # type: ignore @distributed_trace_async - async def create_or_update( - self, - tag_name: str, - **kwargs: Any - ) -> "_models.TagDetails": + async def create_or_update(self, tag_name: str, **kwargs: Any) -> _models.TagDetails: """Creates a tag in the subscription. The tag name can have a maximum of 512 characters and is case insensitive. Tag names created by Azure have prefixes of microsoft, azure, or windows. You cannot create tags with one of these prefixes. - :param tag_name: The name of the tag to create. + :param tag_name: The name of the tag to create. Required. :type tag_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: TagDetails, or the result of cls(response) + :return: TagDetails or the result of cls(response) :rtype: ~azure.mgmt.resource.resources.v2018_02_01.models.TagDetails - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.TagDetails"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + 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', "2018-02-01") # type: str + api_version = kwargs.pop("api_version", _params.pop("api-version", "2018-02-01")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[_models.TagDetails] - request = build_tags_create_or_update_request( tag_name=tag_name, subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.create_or_update.metadata['url'], + template_url=self.create_or_update.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200, 201]: @@ -3145,59 +4191,60 @@ async def create_or_update( raise HttpResponseError(response=response, error_format=ARMErrorFormat) if response.status_code == 200: - deserialized = self._deserialize('TagDetails', pipeline_response) + deserialized = self._deserialize("TagDetails", pipeline_response) if response.status_code == 201: - deserialized = self._deserialize('TagDetails', pipeline_response) + deserialized = self._deserialize("TagDetails", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - create_or_update.metadata = {'url': "/subscriptions/{subscriptionId}/tagNames/{tagName}"} # type: ignore - + create_or_update.metadata = {"url": "/subscriptions/{subscriptionId}/tagNames/{tagName}"} # type: ignore @distributed_trace_async - async def delete( # pylint: disable=inconsistent-return-statements - self, - tag_name: str, - **kwargs: Any - ) -> None: + async def delete(self, tag_name: str, **kwargs: Any) -> None: # pylint: disable=inconsistent-return-statements """Deletes a tag from the subscription. You must remove all values from a resource tag before you can delete it. - :param tag_name: The name of the tag. + :param tag_name: The name of the tag. Required. :type tag_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: None, or the result of cls(response) + :return: None or the result of cls(response) :rtype: None - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType[None] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + 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', "2018-02-01") # type: str + api_version = kwargs.pop("api_version", _params.pop("api-version", "2018-02-01")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[None] - request = build_tags_delete_request( tag_name=tag_name, subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.delete.metadata['url'], + template_url=self.delete.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200, 204]: @@ -3207,48 +4254,53 @@ async def delete( # pylint: disable=inconsistent-return-statements if cls: return cls(pipeline_response, None, {}) - delete.metadata = {'url': "/subscriptions/{subscriptionId}/tagNames/{tagName}"} # type: ignore - + delete.metadata = {"url": "/subscriptions/{subscriptionId}/tagNames/{tagName}"} # type: ignore @distributed_trace - def list( - self, - **kwargs: Any - ) -> AsyncIterable["_models.TagsListResult"]: + def list(self, **kwargs: Any) -> AsyncIterable["_models.TagDetails"]: """Gets the names and values of all resource tags that are defined in a subscription. :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either TagsListResult or the result of cls(response) + :return: An iterator like instance of either TagDetails or the result of cls(response) :rtype: - ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.resource.resources.v2018_02_01.models.TagsListResult] - :raises: ~azure.core.exceptions.HttpResponseError + ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.resource.resources.v2018_02_01.models.TagDetails] + :raises ~azure.core.exceptions.HttpResponseError: """ - api_version = kwargs.pop('api_version', "2018-02-01") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2018-02-01")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[_models.TagsListResult] - cls = kwargs.pop('cls', None) # type: ClsType["_models.TagsListResult"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) + def prepare_request(next_link=None): if not next_link: - + request = build_tags_list_request( subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.list.metadata['url'], + template_url=self.list.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore else: - - request = build_tags_list_request( - subscription_id=self._config.subscription_id, - template_url=next_link, - ) + # make call to next link with the client's api-version + _parsed_next_link = urlparse(next_link) + _next_request_params = case_insensitive_dict(parse_qs(_parsed_next_link.query)) + _next_request_params["api-version"] = self._config.api_version + request = HttpRequest("GET", urljoin(next_link, _parsed_next_link.path), params=_next_request_params) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore request.method = "GET" return request @@ -3262,10 +4314,8 @@ async def extract_data(pipeline_response): async def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) response = pipeline_response.http_response @@ -3275,149 +4325,151 @@ async def get_next(next_link=None): return pipeline_response + return AsyncItemPaged(get_next, extract_data) - return AsyncItemPaged( - get_next, extract_data - ) - list.metadata = {'url': "/subscriptions/{subscriptionId}/tagNames"} # type: ignore -class DeploymentOperationsOperations: - """DeploymentOperationsOperations async operations. + list.metadata = {"url": "/subscriptions/{subscriptionId}/tagNames"} # type: ignore - You should not instantiate this class directly. Instead, you should create a Client instance that - instantiates it for you and attaches it as an attribute. - :ivar models: Alias to model classes used in this operation group. - :type models: ~azure.mgmt.resource.resources.v2018_02_01.models - :param client: Client for service requests. - :param config: Configuration of service client. - :param serializer: An object model serializer. - :param deserializer: An object model deserializer. +class DeploymentOperationsOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. + + Instead, you should access the following operations through + :class:`~azure.mgmt.resource.resources.v2018_02_01.aio.ResourceManagementClient`'s + :attr:`deployment_operations` attribute. """ models = _models - def __init__(self, client, config, serializer, deserializer) -> None: - self._client = client - self._serialize = serializer - self._deserialize = deserializer - self._config = config + def __init__(self, *args, **kwargs) -> None: + input_args = list(args) + self._client = input_args.pop(0) if input_args else kwargs.pop("client") + self._config = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") @distributed_trace_async async def get( - self, - resource_group_name: str, - deployment_name: str, - operation_id: str, - **kwargs: Any - ) -> "_models.DeploymentOperation": + self, resource_group_name: str, deployment_name: str, operation_id: str, **kwargs: Any + ) -> _models.DeploymentOperation: """Gets a deployments operation. :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. :type resource_group_name: str - :param deployment_name: The name of the deployment. + :param deployment_name: The name of the deployment. Required. :type deployment_name: str - :param operation_id: The ID of the operation to get. + :param operation_id: The ID of the operation to get. Required. :type operation_id: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: DeploymentOperation, or the result of cls(response) + :return: DeploymentOperation or the result of cls(response) :rtype: ~azure.mgmt.resource.resources.v2018_02_01.models.DeploymentOperation - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.DeploymentOperation"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + 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', "2018-02-01") # type: str + api_version = kwargs.pop("api_version", _params.pop("api-version", "2018-02-01")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[_models.DeploymentOperation] - request = build_deployment_operations_get_request( resource_group_name=resource_group_name, deployment_name=deployment_name, operation_id=operation_id, subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.get.metadata['url'], + template_url=self.get.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) - deserialized = self._deserialize('DeploymentOperation', pipeline_response) + deserialized = self._deserialize("DeploymentOperation", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - get.metadata = {'url': "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/deployments/{deploymentName}/operations/{operationId}"} # type: ignore - + get.metadata = {"url": "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/deployments/{deploymentName}/operations/{operationId}"} # type: ignore @distributed_trace def list( - self, - resource_group_name: str, - deployment_name: str, - top: Optional[int] = None, - **kwargs: Any - ) -> AsyncIterable["_models.DeploymentOperationsListResult"]: + self, resource_group_name: str, deployment_name: str, top: Optional[int] = None, **kwargs: Any + ) -> AsyncIterable["_models.DeploymentOperation"]: """Gets all deployments operations for a deployment. :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. :type resource_group_name: str - :param deployment_name: The name of the deployment with the operation to get. + :param deployment_name: The name of the deployment with the operation to get. Required. :type deployment_name: str :param top: The number of results to return. Default value is None. :type top: int :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either DeploymentOperationsListResult or the result of - cls(response) + :return: An iterator like instance of either DeploymentOperation or the result of cls(response) :rtype: - ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.resource.resources.v2018_02_01.models.DeploymentOperationsListResult] - :raises: ~azure.core.exceptions.HttpResponseError + ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.resource.resources.v2018_02_01.models.DeploymentOperation] + :raises ~azure.core.exceptions.HttpResponseError: """ - api_version = kwargs.pop('api_version', "2018-02-01") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2018-02-01")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[_models.DeploymentOperationsListResult] - cls = kwargs.pop('cls', None) # type: ClsType["_models.DeploymentOperationsListResult"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) + def prepare_request(next_link=None): if not next_link: - + request = build_deployment_operations_list_request( resource_group_name=resource_group_name, deployment_name=deployment_name, subscription_id=self._config.subscription_id, - api_version=api_version, top=top, - template_url=self.list.metadata['url'], + 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.url = self._client.format_url(request.url) # type: ignore else: - - request = build_deployment_operations_list_request( - resource_group_name=resource_group_name, - deployment_name=deployment_name, - subscription_id=self._config.subscription_id, - template_url=next_link, - ) + # make call to next link with the client's api-version + _parsed_next_link = urlparse(next_link) + _next_request_params = case_insensitive_dict(parse_qs(_parsed_next_link.query)) + _next_request_params["api-version"] = self._config.api_version + request = HttpRequest("GET", urljoin(next_link, _parsed_next_link.path), params=_next_request_params) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore request.method = "GET" return request @@ -3431,10 +4483,8 @@ async def extract_data(pipeline_response): async def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) response = pipeline_response.http_response @@ -3444,8 +4494,6 @@ async def get_next(next_link=None): return pipeline_response + return AsyncItemPaged(get_next, extract_data) - return AsyncItemPaged( - get_next, extract_data - ) - list.metadata = {'url': "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/deployments/{deploymentName}/operations"} # type: ignore + list.metadata = {"url": "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/deployments/{deploymentName}/operations"} # type: ignore diff --git a/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/resources/v2018_02_01/aio/operations/_patch.py b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/resources/v2018_02_01/aio/operations/_patch.py new file mode 100644 index 0000000000000..f7dd32510333d --- /dev/null +++ b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/resources/v2018_02_01/aio/operations/_patch.py @@ -0,0 +1,20 @@ +# ------------------------------------ +# Copyright (c) Microsoft Corporation. +# Licensed under the MIT License. +# ------------------------------------ +"""Customize generated code here. + +Follow our quickstart for examples: https://aka.ms/azsdk/python/dpcodegen/python/customize +""" +from typing import List + +__all__: List[str] = [] # Add all objects you want publicly available to users at this package level + + +def patch_sdk(): + """Do not remove from this file. + + `patch_sdk` is a last resort escape hatch that allows you to do customizations + you can't accomplish using the techniques described in + https://aka.ms/azsdk/python/dpcodegen/python/customize + """ diff --git a/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/resources/v2018_02_01/models/__init__.py b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/resources/v2018_02_01/models/__init__.py index 11d52fec7050d..5ccf24e5f912e 100644 --- a/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/resources/v2018_02_01/models/__init__.py +++ b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/resources/v2018_02_01/models/__init__.py @@ -59,67 +59,69 @@ from ._models_py3 import TemplateLink from ._models_py3 import ZoneMapping - -from ._resource_management_client_enums import ( - DeploymentMode, - OnErrorDeploymentType, - ResourceIdentityType, -) +from ._resource_management_client_enums import DeploymentMode +from ._resource_management_client_enums import OnErrorDeploymentType +from ._resource_management_client_enums import ResourceIdentityType +from ._patch import __all__ as _patch_all +from ._patch import * # type: ignore # pylint: disable=unused-wildcard-import +from ._patch import patch_sdk as _patch_sdk __all__ = [ - 'AliasPathType', - 'AliasType', - 'BasicDependency', - 'DebugSetting', - 'Dependency', - 'Deployment', - 'DeploymentExportResult', - 'DeploymentExtended', - 'DeploymentExtendedFilter', - 'DeploymentListResult', - 'DeploymentOperation', - 'DeploymentOperationProperties', - 'DeploymentOperationsListResult', - 'DeploymentProperties', - 'DeploymentPropertiesExtended', - 'DeploymentValidateResult', - 'ErrorAdditionalInfo', - 'ErrorResponse', - 'ExportTemplateRequest', - 'GenericResource', - 'GenericResourceExpanded', - 'GenericResourceFilter', - 'HttpMessage', - 'Identity', - 'OnErrorDeployment', - 'OnErrorDeploymentExtended', - 'ParametersLink', - 'Plan', - 'Provider', - 'ProviderListResult', - 'ProviderResourceType', - 'Resource', - 'ResourceGroup', - 'ResourceGroupExportResult', - 'ResourceGroupFilter', - 'ResourceGroupListResult', - 'ResourceGroupPatchable', - 'ResourceGroupProperties', - 'ResourceListResult', - 'ResourceManagementErrorWithDetails', - 'ResourceProviderOperationDisplayProperties', - 'ResourcesMoveInfo', - 'Sku', - 'SubResource', - 'TagCount', - 'TagDetails', - 'TagValue', - 'TagsListResult', - 'TargetResource', - 'TemplateHashResult', - 'TemplateLink', - 'ZoneMapping', - 'DeploymentMode', - 'OnErrorDeploymentType', - 'ResourceIdentityType', + "AliasPathType", + "AliasType", + "BasicDependency", + "DebugSetting", + "Dependency", + "Deployment", + "DeploymentExportResult", + "DeploymentExtended", + "DeploymentExtendedFilter", + "DeploymentListResult", + "DeploymentOperation", + "DeploymentOperationProperties", + "DeploymentOperationsListResult", + "DeploymentProperties", + "DeploymentPropertiesExtended", + "DeploymentValidateResult", + "ErrorAdditionalInfo", + "ErrorResponse", + "ExportTemplateRequest", + "GenericResource", + "GenericResourceExpanded", + "GenericResourceFilter", + "HttpMessage", + "Identity", + "OnErrorDeployment", + "OnErrorDeploymentExtended", + "ParametersLink", + "Plan", + "Provider", + "ProviderListResult", + "ProviderResourceType", + "Resource", + "ResourceGroup", + "ResourceGroupExportResult", + "ResourceGroupFilter", + "ResourceGroupListResult", + "ResourceGroupPatchable", + "ResourceGroupProperties", + "ResourceListResult", + "ResourceManagementErrorWithDetails", + "ResourceProviderOperationDisplayProperties", + "ResourcesMoveInfo", + "Sku", + "SubResource", + "TagCount", + "TagDetails", + "TagValue", + "TagsListResult", + "TargetResource", + "TemplateHashResult", + "TemplateLink", + "ZoneMapping", + "DeploymentMode", + "OnErrorDeploymentType", + "ResourceIdentityType", ] +__all__.extend([p for p in _patch_all if p not in __all__]) +_patch_sdk() diff --git a/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/resources/v2018_02_01/models/_models_py3.py b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/resources/v2018_02_01/models/_models_py3.py index 5309c43d79c72..98d7ae2f37351 100644 --- a/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/resources/v2018_02_01/models/_models_py3.py +++ b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/resources/v2018_02_01/models/_models_py3.py @@ -1,4 +1,5 @@ # coding=utf-8 +# pylint: disable=too-many-lines # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. # Licensed under the MIT License. See License.txt in the project root for license information. @@ -6,14 +7,22 @@ # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -from typing import Any, Dict, List, Optional, Union +import sys +from typing import Any, Dict, List, Optional, TYPE_CHECKING, Union -import msrest.serialization +from ... import _serialization -from ._resource_management_client_enums import * +if TYPE_CHECKING: + # pylint: disable=unused-import,ungrouped-imports + from .. import models as _models +if sys.version_info >= (3, 9): + from collections.abc import MutableMapping +else: + from typing import MutableMapping # type: ignore # pylint: disable=ungrouped-imports +JSON = MutableMapping[str, Any] # pylint: disable=unsubscriptable-object -class AliasPathType(msrest.serialization.Model): +class AliasPathType(_serialization.Model): """The type of the paths for alias. :ivar path: The path of an alias. @@ -23,29 +32,23 @@ class AliasPathType(msrest.serialization.Model): """ _attribute_map = { - 'path': {'key': 'path', 'type': 'str'}, - 'api_versions': {'key': 'apiVersions', 'type': '[str]'}, + "path": {"key": "path", "type": "str"}, + "api_versions": {"key": "apiVersions", "type": "[str]"}, } - def __init__( - self, - *, - path: Optional[str] = None, - api_versions: Optional[List[str]] = None, - **kwargs - ): + def __init__(self, *, path: Optional[str] = None, api_versions: Optional[List[str]] = None, **kwargs): """ :keyword path: The path of an alias. :paramtype path: str :keyword api_versions: The API versions. :paramtype api_versions: list[str] """ - super(AliasPathType, self).__init__(**kwargs) + super().__init__(**kwargs) self.path = path self.api_versions = api_versions -class AliasType(msrest.serialization.Model): +class AliasType(_serialization.Model): """The alias type. :ivar name: The alias name. @@ -55,29 +58,23 @@ class AliasType(msrest.serialization.Model): """ _attribute_map = { - 'name': {'key': 'name', 'type': 'str'}, - 'paths': {'key': 'paths', 'type': '[AliasPathType]'}, + "name": {"key": "name", "type": "str"}, + "paths": {"key": "paths", "type": "[AliasPathType]"}, } - def __init__( - self, - *, - name: Optional[str] = None, - paths: Optional[List["AliasPathType"]] = None, - **kwargs - ): + def __init__(self, *, name: Optional[str] = None, paths: Optional[List["_models.AliasPathType"]] = None, **kwargs): """ :keyword name: The alias name. :paramtype name: str :keyword paths: The paths for an alias. :paramtype paths: list[~azure.mgmt.resource.resources.v2018_02_01.models.AliasPathType] """ - super(AliasType, self).__init__(**kwargs) + super().__init__(**kwargs) self.name = name self.paths = paths -class BasicDependency(msrest.serialization.Model): +class BasicDependency(_serialization.Model): """Deployment dependency information. :ivar id: The ID of the dependency. @@ -89,15 +86,15 @@ class BasicDependency(msrest.serialization.Model): """ _attribute_map = { - 'id': {'key': 'id', 'type': 'str'}, - 'resource_type': {'key': 'resourceType', 'type': 'str'}, - 'resource_name': {'key': 'resourceName', 'type': 'str'}, + "id": {"key": "id", "type": "str"}, + "resource_type": {"key": "resourceType", "type": "str"}, + "resource_name": {"key": "resourceName", "type": "str"}, } def __init__( self, *, - id: Optional[str] = None, + id: Optional[str] = None, # pylint: disable=redefined-builtin resource_type: Optional[str] = None, resource_name: Optional[str] = None, **kwargs @@ -110,13 +107,13 @@ def __init__( :keyword resource_name: The dependency resource name. :paramtype resource_name: str """ - super(BasicDependency, self).__init__(**kwargs) + super().__init__(**kwargs) self.id = id self.resource_type = resource_type self.resource_name = resource_name -class DebugSetting(msrest.serialization.Model): +class DebugSetting(_serialization.Model): """DebugSetting. :ivar detail_level: Specifies the type of information to log for debugging. The permitted @@ -129,15 +126,10 @@ class DebugSetting(msrest.serialization.Model): """ _attribute_map = { - 'detail_level': {'key': 'detailLevel', 'type': 'str'}, + "detail_level": {"key": "detailLevel", "type": "str"}, } - def __init__( - self, - *, - detail_level: Optional[str] = None, - **kwargs - ): + def __init__(self, *, detail_level: Optional[str] = None, **kwargs): """ :keyword detail_level: Specifies the type of information to log for debugging. The permitted values are none, requestContent, responseContent, or both requestContent and responseContent @@ -147,11 +139,11 @@ def __init__( deployment operations. :paramtype detail_level: str """ - super(DebugSetting, self).__init__(**kwargs) + super().__init__(**kwargs) self.detail_level = detail_level -class Dependency(msrest.serialization.Model): +class Dependency(_serialization.Model): """Deployment dependency information. :ivar depends_on: The list of dependencies. @@ -165,17 +157,17 @@ class Dependency(msrest.serialization.Model): """ _attribute_map = { - 'depends_on': {'key': 'dependsOn', 'type': '[BasicDependency]'}, - 'id': {'key': 'id', 'type': 'str'}, - 'resource_type': {'key': 'resourceType', 'type': 'str'}, - 'resource_name': {'key': 'resourceName', 'type': 'str'}, + "depends_on": {"key": "dependsOn", "type": "[BasicDependency]"}, + "id": {"key": "id", "type": "str"}, + "resource_type": {"key": "resourceType", "type": "str"}, + "resource_name": {"key": "resourceName", "type": "str"}, } def __init__( self, *, - depends_on: Optional[List["BasicDependency"]] = None, - id: Optional[str] = None, + depends_on: Optional[List["_models.BasicDependency"]] = None, + id: Optional[str] = None, # pylint: disable=redefined-builtin resource_type: Optional[str] = None, resource_name: Optional[str] = None, **kwargs @@ -190,70 +182,60 @@ def __init__( :keyword resource_name: The dependency resource name. :paramtype resource_name: str """ - super(Dependency, self).__init__(**kwargs) + super().__init__(**kwargs) self.depends_on = depends_on self.id = id self.resource_type = resource_type self.resource_name = resource_name -class Deployment(msrest.serialization.Model): +class Deployment(_serialization.Model): """Deployment operation parameters. All required parameters must be populated in order to send to Azure. - :ivar properties: Required. The deployment properties. + :ivar properties: The deployment properties. Required. :vartype properties: ~azure.mgmt.resource.resources.v2018_02_01.models.DeploymentProperties """ _validation = { - 'properties': {'required': True}, + "properties": {"required": True}, } _attribute_map = { - 'properties': {'key': 'properties', 'type': 'DeploymentProperties'}, + "properties": {"key": "properties", "type": "DeploymentProperties"}, } - def __init__( - self, - *, - properties: "DeploymentProperties", - **kwargs - ): + def __init__(self, *, properties: "_models.DeploymentProperties", **kwargs): """ - :keyword properties: Required. The deployment properties. + :keyword properties: The deployment properties. Required. :paramtype properties: ~azure.mgmt.resource.resources.v2018_02_01.models.DeploymentProperties """ - super(Deployment, self).__init__(**kwargs) + super().__init__(**kwargs) self.properties = properties -class DeploymentExportResult(msrest.serialization.Model): +class DeploymentExportResult(_serialization.Model): """The deployment export result. :ivar template: The template content. - :vartype template: any + :vartype template: JSON """ _attribute_map = { - 'template': {'key': 'template', 'type': 'object'}, + "template": {"key": "template", "type": "object"}, } - def __init__( - self, - *, - template: Optional[Any] = None, - **kwargs - ): + def __init__(self, *, template: Optional[JSON] = None, **kwargs): """ :keyword template: The template content. - :paramtype template: any + :paramtype template: JSON """ - super(DeploymentExportResult, self).__init__(**kwargs) + super().__init__(**kwargs) self.template = template -class DeploymentExtended(msrest.serialization.Model): +class DeploymentExtended(_serialization.Model): """Deployment information. Variables are only populated by the server, and will be ignored when sending a request. @@ -262,7 +244,7 @@ class DeploymentExtended(msrest.serialization.Model): :ivar id: The ID of the deployment. :vartype id: str - :ivar name: Required. The name of the deployment. + :ivar name: The name of the deployment. Required. :vartype name: str :ivar properties: Deployment properties. :vartype properties: @@ -270,37 +252,31 @@ class DeploymentExtended(msrest.serialization.Model): """ _validation = { - 'id': {'readonly': True}, - 'name': {'required': True}, + "id": {"readonly": True}, + "name": {"required": True}, } _attribute_map = { - 'id': {'key': 'id', 'type': 'str'}, - 'name': {'key': 'name', 'type': 'str'}, - 'properties': {'key': 'properties', 'type': 'DeploymentPropertiesExtended'}, + "id": {"key": "id", "type": "str"}, + "name": {"key": "name", "type": "str"}, + "properties": {"key": "properties", "type": "DeploymentPropertiesExtended"}, } - def __init__( - self, - *, - name: str, - properties: Optional["DeploymentPropertiesExtended"] = None, - **kwargs - ): + def __init__(self, *, name: str, properties: Optional["_models.DeploymentPropertiesExtended"] = None, **kwargs): """ - :keyword name: Required. The name of the deployment. + :keyword name: The name of the deployment. Required. :paramtype name: str :keyword properties: Deployment properties. :paramtype properties: ~azure.mgmt.resource.resources.v2018_02_01.models.DeploymentPropertiesExtended """ - super(DeploymentExtended, self).__init__(**kwargs) + super().__init__(**kwargs) self.id = None self.name = name self.properties = properties -class DeploymentExtendedFilter(msrest.serialization.Model): +class DeploymentExtendedFilter(_serialization.Model): """Deployment filter. :ivar provisioning_state: The provisioning state. @@ -308,24 +284,19 @@ class DeploymentExtendedFilter(msrest.serialization.Model): """ _attribute_map = { - 'provisioning_state': {'key': 'provisioningState', 'type': 'str'}, + "provisioning_state": {"key": "provisioningState", "type": "str"}, } - def __init__( - self, - *, - provisioning_state: Optional[str] = None, - **kwargs - ): + def __init__(self, *, provisioning_state: Optional[str] = None, **kwargs): """ :keyword provisioning_state: The provisioning state. :paramtype provisioning_state: str """ - super(DeploymentExtendedFilter, self).__init__(**kwargs) + super().__init__(**kwargs) self.provisioning_state = provisioning_state -class DeploymentListResult(msrest.serialization.Model): +class DeploymentListResult(_serialization.Model): """List of deployments. Variables are only populated by the server, and will be ignored when sending a request. @@ -337,30 +308,25 @@ class DeploymentListResult(msrest.serialization.Model): """ _validation = { - 'next_link': {'readonly': True}, + "next_link": {"readonly": True}, } _attribute_map = { - 'value': {'key': 'value', 'type': '[DeploymentExtended]'}, - 'next_link': {'key': 'nextLink', 'type': 'str'}, + "value": {"key": "value", "type": "[DeploymentExtended]"}, + "next_link": {"key": "nextLink", "type": "str"}, } - def __init__( - self, - *, - value: Optional[List["DeploymentExtended"]] = None, - **kwargs - ): + def __init__(self, *, value: Optional[List["_models.DeploymentExtended"]] = None, **kwargs): """ :keyword value: An array of deployments. :paramtype value: list[~azure.mgmt.resource.resources.v2018_02_01.models.DeploymentExtended] """ - super(DeploymentListResult, self).__init__(**kwargs) + super().__init__(**kwargs) self.value = value self.next_link = None -class DeploymentOperation(msrest.serialization.Model): +class DeploymentOperation(_serialization.Model): """Deployment operation information. Variables are only populated by the server, and will be ignored when sending a request. @@ -375,34 +341,29 @@ class DeploymentOperation(msrest.serialization.Model): """ _validation = { - 'id': {'readonly': True}, - 'operation_id': {'readonly': True}, + "id": {"readonly": True}, + "operation_id": {"readonly": True}, } _attribute_map = { - 'id': {'key': 'id', 'type': 'str'}, - 'operation_id': {'key': 'operationId', 'type': 'str'}, - 'properties': {'key': 'properties', 'type': 'DeploymentOperationProperties'}, + "id": {"key": "id", "type": "str"}, + "operation_id": {"key": "operationId", "type": "str"}, + "properties": {"key": "properties", "type": "DeploymentOperationProperties"}, } - def __init__( - self, - *, - properties: Optional["DeploymentOperationProperties"] = None, - **kwargs - ): + def __init__(self, *, properties: Optional["_models.DeploymentOperationProperties"] = None, **kwargs): """ :keyword properties: Deployment properties. :paramtype properties: ~azure.mgmt.resource.resources.v2018_02_01.models.DeploymentOperationProperties """ - super(DeploymentOperation, self).__init__(**kwargs) + super().__init__(**kwargs) self.id = None self.operation_id = None self.properties = properties -class DeploymentOperationProperties(msrest.serialization.Model): +class DeploymentOperationProperties(_serialization.Model): """Deployment operation properties. Variables are only populated by the server, and will be ignored when sending a request. @@ -416,7 +377,7 @@ class DeploymentOperationProperties(msrest.serialization.Model): :ivar status_code: Operation status code. :vartype status_code: str :ivar status_message: Operation status message. - :vartype status_message: any + :vartype status_message: JSON :ivar target_resource: The target resource. :vartype target_resource: ~azure.mgmt.resource.resources.v2018_02_01.models.TargetResource :ivar request: The HTTP request message. @@ -426,34 +387,30 @@ class DeploymentOperationProperties(msrest.serialization.Model): """ _validation = { - 'provisioning_state': {'readonly': True}, - 'timestamp': {'readonly': True}, - 'service_request_id': {'readonly': True}, - 'status_code': {'readonly': True}, - 'status_message': {'readonly': True}, - 'target_resource': {'readonly': True}, - 'request': {'readonly': True}, - 'response': {'readonly': True}, + "provisioning_state": {"readonly": True}, + "timestamp": {"readonly": True}, + "service_request_id": {"readonly": True}, + "status_code": {"readonly": True}, + "status_message": {"readonly": True}, + "target_resource": {"readonly": True}, + "request": {"readonly": True}, + "response": {"readonly": True}, } _attribute_map = { - 'provisioning_state': {'key': 'provisioningState', 'type': 'str'}, - 'timestamp': {'key': 'timestamp', 'type': 'iso-8601'}, - 'service_request_id': {'key': 'serviceRequestId', 'type': 'str'}, - 'status_code': {'key': 'statusCode', 'type': 'str'}, - 'status_message': {'key': 'statusMessage', 'type': 'object'}, - 'target_resource': {'key': 'targetResource', 'type': 'TargetResource'}, - 'request': {'key': 'request', 'type': 'HttpMessage'}, - 'response': {'key': 'response', 'type': 'HttpMessage'}, - } - - def __init__( - self, - **kwargs - ): - """ - """ - super(DeploymentOperationProperties, self).__init__(**kwargs) + "provisioning_state": {"key": "provisioningState", "type": "str"}, + "timestamp": {"key": "timestamp", "type": "iso-8601"}, + "service_request_id": {"key": "serviceRequestId", "type": "str"}, + "status_code": {"key": "statusCode", "type": "str"}, + "status_message": {"key": "statusMessage", "type": "object"}, + "target_resource": {"key": "targetResource", "type": "TargetResource"}, + "request": {"key": "request", "type": "HttpMessage"}, + "response": {"key": "response", "type": "HttpMessage"}, + } + + def __init__(self, **kwargs): + """ """ + super().__init__(**kwargs) self.provisioning_state = None self.timestamp = None self.service_request_id = None @@ -464,7 +421,7 @@ def __init__( self.response = None -class DeploymentOperationsListResult(msrest.serialization.Model): +class DeploymentOperationsListResult(_serialization.Model): """List of deployment operations. Variables are only populated by the server, and will be ignored when sending a request. @@ -476,30 +433,25 @@ class DeploymentOperationsListResult(msrest.serialization.Model): """ _validation = { - 'next_link': {'readonly': True}, + "next_link": {"readonly": True}, } _attribute_map = { - 'value': {'key': 'value', 'type': '[DeploymentOperation]'}, - 'next_link': {'key': 'nextLink', 'type': 'str'}, + "value": {"key": "value", "type": "[DeploymentOperation]"}, + "next_link": {"key": "nextLink", "type": "str"}, } - def __init__( - self, - *, - value: Optional[List["DeploymentOperation"]] = None, - **kwargs - ): + def __init__(self, *, value: Optional[List["_models.DeploymentOperation"]] = None, **kwargs): """ :keyword value: An array of deployment operations. :paramtype value: list[~azure.mgmt.resource.resources.v2018_02_01.models.DeploymentOperation] """ - super(DeploymentOperationsListResult, self).__init__(**kwargs) + super().__init__(**kwargs) self.value = value self.next_link = None -class DeploymentProperties(msrest.serialization.Model): +class DeploymentProperties(_serialization.Model): """Deployment properties. All required parameters must be populated in order to send to Azure. @@ -508,7 +460,7 @@ class DeploymentProperties(msrest.serialization.Model): syntax directly in the request rather than link to an existing template. It can be a JObject or well-formed JSON string. Use either the templateLink property or the template property, but not both. - :vartype template: any + :vartype template: JSON :ivar template_link: The URI of the template. Use either the templateLink property or the template property, but not both. :vartype template_link: ~azure.mgmt.resource.resources.v2018_02_01.models.TemplateLink @@ -516,17 +468,17 @@ class DeploymentProperties(msrest.serialization.Model): You use this element when you want to provide the parameter values directly in the request rather than link to an existing parameter file. Use either the parametersLink property or the parameters property, but not both. It can be a JObject or a well formed JSON string. - :vartype parameters: any + :vartype parameters: JSON :ivar parameters_link: The URI of parameters file. You use this element to link to an existing parameters file. Use either the parametersLink property or the parameters property, but not both. :vartype parameters_link: ~azure.mgmt.resource.resources.v2018_02_01.models.ParametersLink - :ivar mode: Required. The mode that is used to deploy resources. This value can be either - Incremental or Complete. In Incremental mode, resources are deployed without deleting existing - resources that are not included in the template. In Complete mode, resources are deployed and - existing resources in the resource group that are not included in the template are deleted. Be - careful when using Complete mode as you may unintentionally delete resources. Possible values - include: "Incremental", "Complete". + :ivar mode: The mode that is used to deploy resources. This value can be either Incremental or + Complete. In Incremental mode, resources are deployed without deleting existing resources that + are not included in the template. In Complete mode, resources are deployed and existing + resources in the resource group that are not included in the template are deleted. Be careful + when using Complete mode as you may unintentionally delete resources. Required. Known values + are: "Incremental" and "Complete". :vartype mode: str or ~azure.mgmt.resource.resources.v2018_02_01.models.DeploymentMode :ivar debug_setting: The debug setting of the deployment. :vartype debug_setting: ~azure.mgmt.resource.resources.v2018_02_01.models.DebugSetting @@ -536,29 +488,29 @@ class DeploymentProperties(msrest.serialization.Model): """ _validation = { - 'mode': {'required': True}, + "mode": {"required": True}, } _attribute_map = { - 'template': {'key': 'template', 'type': 'object'}, - 'template_link': {'key': 'templateLink', 'type': 'TemplateLink'}, - 'parameters': {'key': 'parameters', 'type': 'object'}, - 'parameters_link': {'key': 'parametersLink', 'type': 'ParametersLink'}, - 'mode': {'key': 'mode', 'type': 'str'}, - 'debug_setting': {'key': 'debugSetting', 'type': 'DebugSetting'}, - 'on_error_deployment': {'key': 'onErrorDeployment', 'type': 'OnErrorDeployment'}, + "template": {"key": "template", "type": "object"}, + "template_link": {"key": "templateLink", "type": "TemplateLink"}, + "parameters": {"key": "parameters", "type": "object"}, + "parameters_link": {"key": "parametersLink", "type": "ParametersLink"}, + "mode": {"key": "mode", "type": "str"}, + "debug_setting": {"key": "debugSetting", "type": "DebugSetting"}, + "on_error_deployment": {"key": "onErrorDeployment", "type": "OnErrorDeployment"}, } def __init__( self, *, - mode: Union[str, "DeploymentMode"], - template: Optional[Any] = None, - template_link: Optional["TemplateLink"] = None, - parameters: Optional[Any] = None, - parameters_link: Optional["ParametersLink"] = None, - debug_setting: Optional["DebugSetting"] = None, - on_error_deployment: Optional["OnErrorDeployment"] = None, + mode: Union[str, "_models.DeploymentMode"], + template: Optional[JSON] = None, + template_link: Optional["_models.TemplateLink"] = None, + parameters: Optional[JSON] = None, + parameters_link: Optional["_models.ParametersLink"] = None, + debug_setting: Optional["_models.DebugSetting"] = None, + on_error_deployment: Optional["_models.OnErrorDeployment"] = None, **kwargs ): """ @@ -566,7 +518,7 @@ def __init__( template syntax directly in the request rather than link to an existing template. It can be a JObject or well-formed JSON string. Use either the templateLink property or the template property, but not both. - :paramtype template: any + :paramtype template: JSON :keyword template_link: The URI of the template. Use either the templateLink property or the template property, but not both. :paramtype template_link: ~azure.mgmt.resource.resources.v2018_02_01.models.TemplateLink @@ -574,17 +526,17 @@ def __init__( template. You use this element when you want to provide the parameter values directly in the request rather than link to an existing parameter file. Use either the parametersLink property or the parameters property, but not both. It can be a JObject or a well formed JSON string. - :paramtype parameters: any + :paramtype parameters: JSON :keyword parameters_link: The URI of parameters file. You use this element to link to an existing parameters file. Use either the parametersLink property or the parameters property, but not both. :paramtype parameters_link: ~azure.mgmt.resource.resources.v2018_02_01.models.ParametersLink - :keyword mode: Required. The mode that is used to deploy resources. This value can be either - Incremental or Complete. In Incremental mode, resources are deployed without deleting existing - resources that are not included in the template. In Complete mode, resources are deployed and - existing resources in the resource group that are not included in the template are deleted. Be - careful when using Complete mode as you may unintentionally delete resources. Possible values - include: "Incremental", "Complete". + :keyword mode: The mode that is used to deploy resources. This value can be either Incremental + or Complete. In Incremental mode, resources are deployed without deleting existing resources + that are not included in the template. In Complete mode, resources are deployed and existing + resources in the resource group that are not included in the template are deleted. Be careful + when using Complete mode as you may unintentionally delete resources. Required. Known values + are: "Incremental" and "Complete". :paramtype mode: str or ~azure.mgmt.resource.resources.v2018_02_01.models.DeploymentMode :keyword debug_setting: The debug setting of the deployment. :paramtype debug_setting: ~azure.mgmt.resource.resources.v2018_02_01.models.DebugSetting @@ -592,7 +544,7 @@ def __init__( :paramtype on_error_deployment: ~azure.mgmt.resource.resources.v2018_02_01.models.OnErrorDeployment """ - super(DeploymentProperties, self).__init__(**kwargs) + super().__init__(**kwargs) self.template = template self.template_link = template_link self.parameters = parameters @@ -602,7 +554,7 @@ def __init__( self.on_error_deployment = on_error_deployment -class DeploymentPropertiesExtended(msrest.serialization.Model): +class DeploymentPropertiesExtended(_serialization.Model): # pylint: disable=too-many-instance-attributes """Deployment properties with additional details. Variables are only populated by the server, and will be ignored when sending a request. @@ -614,23 +566,23 @@ class DeploymentPropertiesExtended(msrest.serialization.Model): :ivar timestamp: The timestamp of the template deployment. :vartype timestamp: ~datetime.datetime :ivar outputs: Key/value pairs that represent deployment output. - :vartype outputs: any + :vartype outputs: JSON :ivar providers: The list of resource providers needed for the deployment. :vartype providers: list[~azure.mgmt.resource.resources.v2018_02_01.models.Provider] :ivar dependencies: The list of deployment dependencies. :vartype dependencies: list[~azure.mgmt.resource.resources.v2018_02_01.models.Dependency] :ivar template: The template content. Use only one of Template or TemplateLink. - :vartype template: any + :vartype template: JSON :ivar template_link: The URI referencing the template. Use only one of Template or TemplateLink. :vartype template_link: ~azure.mgmt.resource.resources.v2018_02_01.models.TemplateLink :ivar parameters: Deployment parameters. Use only one of Parameters or ParametersLink. - :vartype parameters: any + :vartype parameters: JSON :ivar parameters_link: The URI referencing the parameters. Use only one of Parameters or ParametersLink. :vartype parameters_link: ~azure.mgmt.resource.resources.v2018_02_01.models.ParametersLink - :ivar mode: The deployment mode. Possible values are Incremental and Complete. Possible values - include: "Incremental", "Complete". + :ivar mode: The deployment mode. Possible values are Incremental and Complete. Known values + are: "Incremental" and "Complete". :vartype mode: str or ~azure.mgmt.resource.resources.v2018_02_01.models.DeploymentMode :ivar debug_setting: The debug setting of the deployment. :vartype debug_setting: ~azure.mgmt.resource.resources.v2018_02_01.models.DebugSetting @@ -642,63 +594,63 @@ class DeploymentPropertiesExtended(msrest.serialization.Model): """ _validation = { - 'provisioning_state': {'readonly': True}, - 'correlation_id': {'readonly': True}, - 'timestamp': {'readonly': True}, - 'error': {'readonly': True}, + "provisioning_state": {"readonly": True}, + "correlation_id": {"readonly": True}, + "timestamp": {"readonly": True}, + "error": {"readonly": True}, } _attribute_map = { - 'provisioning_state': {'key': 'provisioningState', 'type': 'str'}, - 'correlation_id': {'key': 'correlationId', 'type': 'str'}, - 'timestamp': {'key': 'timestamp', 'type': 'iso-8601'}, - 'outputs': {'key': 'outputs', 'type': 'object'}, - 'providers': {'key': 'providers', 'type': '[Provider]'}, - 'dependencies': {'key': 'dependencies', 'type': '[Dependency]'}, - 'template': {'key': 'template', 'type': 'object'}, - 'template_link': {'key': 'templateLink', 'type': 'TemplateLink'}, - 'parameters': {'key': 'parameters', 'type': 'object'}, - 'parameters_link': {'key': 'parametersLink', 'type': 'ParametersLink'}, - 'mode': {'key': 'mode', 'type': 'str'}, - 'debug_setting': {'key': 'debugSetting', 'type': 'DebugSetting'}, - 'on_error_deployment': {'key': 'onErrorDeployment', 'type': 'OnErrorDeploymentExtended'}, - 'error': {'key': 'error', 'type': 'ErrorResponse'}, + "provisioning_state": {"key": "provisioningState", "type": "str"}, + "correlation_id": {"key": "correlationId", "type": "str"}, + "timestamp": {"key": "timestamp", "type": "iso-8601"}, + "outputs": {"key": "outputs", "type": "object"}, + "providers": {"key": "providers", "type": "[Provider]"}, + "dependencies": {"key": "dependencies", "type": "[Dependency]"}, + "template": {"key": "template", "type": "object"}, + "template_link": {"key": "templateLink", "type": "TemplateLink"}, + "parameters": {"key": "parameters", "type": "object"}, + "parameters_link": {"key": "parametersLink", "type": "ParametersLink"}, + "mode": {"key": "mode", "type": "str"}, + "debug_setting": {"key": "debugSetting", "type": "DebugSetting"}, + "on_error_deployment": {"key": "onErrorDeployment", "type": "OnErrorDeploymentExtended"}, + "error": {"key": "error", "type": "ErrorResponse"}, } def __init__( self, *, - outputs: Optional[Any] = None, - providers: Optional[List["Provider"]] = None, - dependencies: Optional[List["Dependency"]] = None, - template: Optional[Any] = None, - template_link: Optional["TemplateLink"] = None, - parameters: Optional[Any] = None, - parameters_link: Optional["ParametersLink"] = None, - mode: Optional[Union[str, "DeploymentMode"]] = None, - debug_setting: Optional["DebugSetting"] = None, - on_error_deployment: Optional["OnErrorDeploymentExtended"] = None, + outputs: Optional[JSON] = None, + providers: Optional[List["_models.Provider"]] = None, + dependencies: Optional[List["_models.Dependency"]] = None, + template: Optional[JSON] = None, + template_link: Optional["_models.TemplateLink"] = None, + parameters: Optional[JSON] = None, + parameters_link: Optional["_models.ParametersLink"] = None, + mode: Optional[Union[str, "_models.DeploymentMode"]] = None, + debug_setting: Optional["_models.DebugSetting"] = None, + on_error_deployment: Optional["_models.OnErrorDeploymentExtended"] = None, **kwargs ): """ :keyword outputs: Key/value pairs that represent deployment output. - :paramtype outputs: any + :paramtype outputs: JSON :keyword providers: The list of resource providers needed for the deployment. :paramtype providers: list[~azure.mgmt.resource.resources.v2018_02_01.models.Provider] :keyword dependencies: The list of deployment dependencies. :paramtype dependencies: list[~azure.mgmt.resource.resources.v2018_02_01.models.Dependency] :keyword template: The template content. Use only one of Template or TemplateLink. - :paramtype template: any + :paramtype template: JSON :keyword template_link: The URI referencing the template. Use only one of Template or TemplateLink. :paramtype template_link: ~azure.mgmt.resource.resources.v2018_02_01.models.TemplateLink :keyword parameters: Deployment parameters. Use only one of Parameters or ParametersLink. - :paramtype parameters: any + :paramtype parameters: JSON :keyword parameters_link: The URI referencing the parameters. Use only one of Parameters or ParametersLink. :paramtype parameters_link: ~azure.mgmt.resource.resources.v2018_02_01.models.ParametersLink - :keyword mode: The deployment mode. Possible values are Incremental and Complete. Possible - values include: "Incremental", "Complete". + :keyword mode: The deployment mode. Possible values are Incremental and Complete. Known values + are: "Incremental" and "Complete". :paramtype mode: str or ~azure.mgmt.resource.resources.v2018_02_01.models.DeploymentMode :keyword debug_setting: The debug setting of the deployment. :paramtype debug_setting: ~azure.mgmt.resource.resources.v2018_02_01.models.DebugSetting @@ -706,7 +658,7 @@ def __init__( :paramtype on_error_deployment: ~azure.mgmt.resource.resources.v2018_02_01.models.OnErrorDeploymentExtended """ - super(DeploymentPropertiesExtended, self).__init__(**kwargs) + super().__init__(**kwargs) self.provisioning_state = None self.correlation_id = None self.timestamp = None @@ -723,7 +675,7 @@ def __init__( self.error = None -class DeploymentValidateResult(msrest.serialization.Model): +class DeploymentValidateResult(_serialization.Model): """Information from validate template deployment response. :ivar error: Validation error. @@ -735,15 +687,15 @@ class DeploymentValidateResult(msrest.serialization.Model): """ _attribute_map = { - 'error': {'key': 'error', 'type': 'ResourceManagementErrorWithDetails'}, - 'properties': {'key': 'properties', 'type': 'DeploymentPropertiesExtended'}, + "error": {"key": "error", "type": "ResourceManagementErrorWithDetails"}, + "properties": {"key": "properties", "type": "DeploymentPropertiesExtended"}, } def __init__( self, *, - error: Optional["ResourceManagementErrorWithDetails"] = None, - properties: Optional["DeploymentPropertiesExtended"] = None, + error: Optional["_models.ResourceManagementErrorWithDetails"] = None, + properties: Optional["_models.DeploymentPropertiesExtended"] = None, **kwargs ): """ @@ -754,12 +706,12 @@ def __init__( :paramtype properties: ~azure.mgmt.resource.resources.v2018_02_01.models.DeploymentPropertiesExtended """ - super(DeploymentValidateResult, self).__init__(**kwargs) + super().__init__(**kwargs) self.error = error self.properties = properties -class ErrorAdditionalInfo(msrest.serialization.Model): +class ErrorAdditionalInfo(_serialization.Model): """The resource management error additional info. Variables are only populated by the server, and will be ignored when sending a request. @@ -767,31 +719,27 @@ class ErrorAdditionalInfo(msrest.serialization.Model): :ivar type: The additional info type. :vartype type: str :ivar info: The additional info. - :vartype info: any + :vartype info: JSON """ _validation = { - 'type': {'readonly': True}, - 'info': {'readonly': True}, + "type": {"readonly": True}, + "info": {"readonly": True}, } _attribute_map = { - 'type': {'key': 'type', 'type': 'str'}, - 'info': {'key': 'info', 'type': 'object'}, + "type": {"key": "type", "type": "str"}, + "info": {"key": "info", "type": "object"}, } - def __init__( - self, - **kwargs - ): - """ - """ - super(ErrorAdditionalInfo, self).__init__(**kwargs) + def __init__(self, **kwargs): + """ """ + super().__init__(**kwargs) self.type = None self.info = None -class ErrorResponse(msrest.serialization.Model): +class ErrorResponse(_serialization.Model): """Common error response for all Azure Resource Manager APIs to return error details for failed operations. (This also follows the OData error response format.). Variables are only populated by the server, and will be ignored when sending a request. @@ -810,28 +758,24 @@ class ErrorResponse(msrest.serialization.Model): """ _validation = { - 'code': {'readonly': True}, - 'message': {'readonly': True}, - 'target': {'readonly': True}, - 'details': {'readonly': True}, - 'additional_info': {'readonly': True}, + "code": {"readonly": True}, + "message": {"readonly": True}, + "target": {"readonly": True}, + "details": {"readonly": True}, + "additional_info": {"readonly": True}, } _attribute_map = { - 'code': {'key': 'code', 'type': 'str'}, - 'message': {'key': 'message', 'type': 'str'}, - 'target': {'key': 'target', 'type': 'str'}, - 'details': {'key': 'details', 'type': '[ErrorResponse]'}, - 'additional_info': {'key': 'additionalInfo', 'type': '[ErrorAdditionalInfo]'}, + "code": {"key": "code", "type": "str"}, + "message": {"key": "message", "type": "str"}, + "target": {"key": "target", "type": "str"}, + "details": {"key": "details", "type": "[ErrorResponse]"}, + "additional_info": {"key": "additionalInfo", "type": "[ErrorAdditionalInfo]"}, } - def __init__( - self, - **kwargs - ): - """ - """ - super(ErrorResponse, self).__init__(**kwargs) + def __init__(self, **kwargs): + """ """ + super().__init__(**kwargs) self.code = None self.message = None self.target = None @@ -839,7 +783,7 @@ def __init__( self.additional_info = None -class ExportTemplateRequest(msrest.serialization.Model): +class ExportTemplateRequest(_serialization.Model): """Export resource group template request parameters. :ivar resources: The IDs of the resources to filter the export by. To export all resources, @@ -852,17 +796,11 @@ class ExportTemplateRequest(msrest.serialization.Model): """ _attribute_map = { - 'resources': {'key': 'resources', 'type': '[str]'}, - 'options': {'key': 'options', 'type': 'str'}, + "resources": {"key": "resources", "type": "[str]"}, + "options": {"key": "options", "type": "str"}, } - def __init__( - self, - *, - resources: Optional[List[str]] = None, - options: Optional[str] = None, - **kwargs - ): + def __init__(self, *, resources: Optional[List[str]] = None, options: Optional[str] = None, **kwargs): """ :keyword resources: The IDs of the resources to filter the export by. To export all resources, supply an array with single entry '*'. @@ -872,12 +810,12 @@ def __init__( 'SkipResourceNameParameterization', 'SkipAllParameterization'. :paramtype options: str """ - super(ExportTemplateRequest, self).__init__(**kwargs) + super().__init__(**kwargs) self.resources = resources self.options = options -class Resource(msrest.serialization.Model): +class Resource(_serialization.Model): """Resource. Variables are only populated by the server, and will be ignored when sending a request. @@ -890,38 +828,32 @@ class Resource(msrest.serialization.Model): :vartype type: str :ivar location: Resource location. :vartype location: str - :ivar tags: A set of tags. Resource tags. + :ivar tags: Resource tags. :vartype tags: dict[str, str] """ _validation = { - 'id': {'readonly': True}, - 'name': {'readonly': True}, - 'type': {'readonly': True}, + "id": {"readonly": True}, + "name": {"readonly": True}, + "type": {"readonly": True}, } _attribute_map = { - 'id': {'key': 'id', 'type': 'str'}, - 'name': {'key': 'name', 'type': 'str'}, - 'type': {'key': 'type', 'type': 'str'}, - 'location': {'key': 'location', 'type': 'str'}, - 'tags': {'key': 'tags', 'type': '{str}'}, + "id": {"key": "id", "type": "str"}, + "name": {"key": "name", "type": "str"}, + "type": {"key": "type", "type": "str"}, + "location": {"key": "location", "type": "str"}, + "tags": {"key": "tags", "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): """ :keyword location: Resource location. :paramtype location: str - :keyword tags: A set of tags. Resource tags. + :keyword tags: Resource tags. :paramtype tags: dict[str, str] """ - super(Resource, self).__init__(**kwargs) + super().__init__(**kwargs) self.id = None self.name = None self.type = None @@ -929,7 +861,7 @@ def __init__( self.tags = tags -class GenericResource(Resource): +class GenericResource(Resource): # pylint: disable=too-many-instance-attributes """Resource information. Variables are only populated by the server, and will be ignored when sending a request. @@ -942,12 +874,12 @@ class GenericResource(Resource): :vartype type: str :ivar location: Resource location. :vartype location: str - :ivar tags: A set of tags. Resource tags. + :ivar tags: Resource tags. :vartype tags: dict[str, str] :ivar plan: The plan of the resource. :vartype plan: ~azure.mgmt.resource.resources.v2018_02_01.models.Plan :ivar properties: The resource properties. - :vartype properties: any + :vartype properties: JSON :ivar kind: The kind of the resource. :vartype kind: str :ivar managed_by: ID of the resource that manages this resource. @@ -959,24 +891,24 @@ class GenericResource(Resource): """ _validation = { - 'id': {'readonly': True}, - 'name': {'readonly': True}, - 'type': {'readonly': True}, - 'kind': {'pattern': r'^[-\w\._,\(\)]+$'}, + "id": {"readonly": True}, + "name": {"readonly": True}, + "type": {"readonly": True}, + "kind": {"pattern": r"^[-\w\._,\(\)]+$"}, } _attribute_map = { - 'id': {'key': 'id', 'type': 'str'}, - 'name': {'key': 'name', 'type': 'str'}, - 'type': {'key': 'type', 'type': 'str'}, - 'location': {'key': 'location', 'type': 'str'}, - 'tags': {'key': 'tags', 'type': '{str}'}, - 'plan': {'key': 'plan', 'type': 'Plan'}, - 'properties': {'key': 'properties', 'type': 'object'}, - 'kind': {'key': 'kind', 'type': 'str'}, - 'managed_by': {'key': 'managedBy', 'type': 'str'}, - 'sku': {'key': 'sku', 'type': 'Sku'}, - 'identity': {'key': 'identity', 'type': 'Identity'}, + "id": {"key": "id", "type": "str"}, + "name": {"key": "name", "type": "str"}, + "type": {"key": "type", "type": "str"}, + "location": {"key": "location", "type": "str"}, + "tags": {"key": "tags", "type": "{str}"}, + "plan": {"key": "plan", "type": "Plan"}, + "properties": {"key": "properties", "type": "object"}, + "kind": {"key": "kind", "type": "str"}, + "managed_by": {"key": "managedBy", "type": "str"}, + "sku": {"key": "sku", "type": "Sku"}, + "identity": {"key": "identity", "type": "Identity"}, } def __init__( @@ -984,23 +916,23 @@ def __init__( *, location: Optional[str] = None, tags: Optional[Dict[str, str]] = None, - plan: Optional["Plan"] = None, - properties: Optional[Any] = None, + plan: Optional["_models.Plan"] = None, + properties: Optional[JSON] = None, kind: Optional[str] = None, managed_by: Optional[str] = None, - sku: Optional["Sku"] = None, - identity: Optional["Identity"] = None, + sku: Optional["_models.Sku"] = None, + identity: Optional["_models.Identity"] = None, **kwargs ): """ :keyword location: Resource location. :paramtype location: str - :keyword tags: A set of tags. Resource tags. + :keyword tags: Resource tags. :paramtype tags: dict[str, str] :keyword plan: The plan of the resource. :paramtype plan: ~azure.mgmt.resource.resources.v2018_02_01.models.Plan :keyword properties: The resource properties. - :paramtype properties: any + :paramtype properties: JSON :keyword kind: The kind of the resource. :paramtype kind: str :keyword managed_by: ID of the resource that manages this resource. @@ -1010,7 +942,7 @@ def __init__( :keyword identity: The identity of the resource. :paramtype identity: ~azure.mgmt.resource.resources.v2018_02_01.models.Identity """ - super(GenericResource, self).__init__(location=location, tags=tags, **kwargs) + super().__init__(location=location, tags=tags, **kwargs) self.plan = plan self.properties = properties self.kind = kind @@ -1019,7 +951,7 @@ def __init__( self.identity = identity -class GenericResourceExpanded(GenericResource): +class GenericResourceExpanded(GenericResource): # pylint: disable=too-many-instance-attributes """Resource information. Variables are only populated by the server, and will be ignored when sending a request. @@ -1032,12 +964,12 @@ class GenericResourceExpanded(GenericResource): :vartype type: str :ivar location: Resource location. :vartype location: str - :ivar tags: A set of tags. Resource tags. + :ivar tags: Resource tags. :vartype tags: dict[str, str] :ivar plan: The plan of the resource. :vartype plan: ~azure.mgmt.resource.resources.v2018_02_01.models.Plan :ivar properties: The resource properties. - :vartype properties: any + :vartype properties: JSON :ivar kind: The kind of the resource. :vartype kind: str :ivar managed_by: ID of the resource that manages this resource. @@ -1058,30 +990,30 @@ class GenericResourceExpanded(GenericResource): """ _validation = { - 'id': {'readonly': True}, - 'name': {'readonly': True}, - 'type': {'readonly': True}, - 'kind': {'pattern': r'^[-\w\._,\(\)]+$'}, - 'created_time': {'readonly': True}, - 'changed_time': {'readonly': True}, - 'provisioning_state': {'readonly': True}, + "id": {"readonly": True}, + "name": {"readonly": True}, + "type": {"readonly": True}, + "kind": {"pattern": r"^[-\w\._,\(\)]+$"}, + "created_time": {"readonly": True}, + "changed_time": {"readonly": True}, + "provisioning_state": {"readonly": True}, } _attribute_map = { - 'id': {'key': 'id', 'type': 'str'}, - 'name': {'key': 'name', 'type': 'str'}, - 'type': {'key': 'type', 'type': 'str'}, - 'location': {'key': 'location', 'type': 'str'}, - 'tags': {'key': 'tags', 'type': '{str}'}, - 'plan': {'key': 'plan', 'type': 'Plan'}, - 'properties': {'key': 'properties', 'type': 'object'}, - 'kind': {'key': 'kind', 'type': 'str'}, - 'managed_by': {'key': 'managedBy', 'type': 'str'}, - 'sku': {'key': 'sku', 'type': 'Sku'}, - 'identity': {'key': 'identity', 'type': 'Identity'}, - 'created_time': {'key': 'createdTime', 'type': 'iso-8601'}, - 'changed_time': {'key': 'changedTime', 'type': 'iso-8601'}, - 'provisioning_state': {'key': 'provisioningState', 'type': 'str'}, + "id": {"key": "id", "type": "str"}, + "name": {"key": "name", "type": "str"}, + "type": {"key": "type", "type": "str"}, + "location": {"key": "location", "type": "str"}, + "tags": {"key": "tags", "type": "{str}"}, + "plan": {"key": "plan", "type": "Plan"}, + "properties": {"key": "properties", "type": "object"}, + "kind": {"key": "kind", "type": "str"}, + "managed_by": {"key": "managedBy", "type": "str"}, + "sku": {"key": "sku", "type": "Sku"}, + "identity": {"key": "identity", "type": "Identity"}, + "created_time": {"key": "createdTime", "type": "iso-8601"}, + "changed_time": {"key": "changedTime", "type": "iso-8601"}, + "provisioning_state": {"key": "provisioningState", "type": "str"}, } def __init__( @@ -1089,23 +1021,23 @@ def __init__( *, location: Optional[str] = None, tags: Optional[Dict[str, str]] = None, - plan: Optional["Plan"] = None, - properties: Optional[Any] = None, + plan: Optional["_models.Plan"] = None, + properties: Optional[JSON] = None, kind: Optional[str] = None, managed_by: Optional[str] = None, - sku: Optional["Sku"] = None, - identity: Optional["Identity"] = None, + sku: Optional["_models.Sku"] = None, + identity: Optional["_models.Identity"] = None, **kwargs ): """ :keyword location: Resource location. :paramtype location: str - :keyword tags: A set of tags. Resource tags. + :keyword tags: Resource tags. :paramtype tags: dict[str, str] :keyword plan: The plan of the resource. :paramtype plan: ~azure.mgmt.resource.resources.v2018_02_01.models.Plan :keyword properties: The resource properties. - :paramtype properties: any + :paramtype properties: JSON :keyword kind: The kind of the resource. :paramtype kind: str :keyword managed_by: ID of the resource that manages this resource. @@ -1115,13 +1047,23 @@ def __init__( :keyword identity: The identity of the resource. :paramtype identity: ~azure.mgmt.resource.resources.v2018_02_01.models.Identity """ - super(GenericResourceExpanded, self).__init__(location=location, tags=tags, plan=plan, properties=properties, kind=kind, managed_by=managed_by, sku=sku, identity=identity, **kwargs) + super().__init__( + location=location, + tags=tags, + plan=plan, + properties=properties, + kind=kind, + managed_by=managed_by, + sku=sku, + identity=identity, + **kwargs + ) self.created_time = None self.changed_time = None self.provisioning_state = None -class GenericResourceFilter(msrest.serialization.Model): +class GenericResourceFilter(_serialization.Model): """Resource filter. :ivar resource_type: The resource type. @@ -1133,9 +1075,9 @@ class GenericResourceFilter(msrest.serialization.Model): """ _attribute_map = { - 'resource_type': {'key': 'resourceType', 'type': 'str'}, - 'tagname': {'key': 'tagname', 'type': 'str'}, - 'tagvalue': {'key': 'tagvalue', 'type': 'str'}, + "resource_type": {"key": "resourceType", "type": "str"}, + "tagname": {"key": "tagname", "type": "str"}, + "tagvalue": {"key": "tagvalue", "type": "str"}, } def __init__( @@ -1154,38 +1096,33 @@ def __init__( :keyword tagvalue: The tag value. :paramtype tagvalue: str """ - super(GenericResourceFilter, self).__init__(**kwargs) + super().__init__(**kwargs) self.resource_type = resource_type self.tagname = tagname self.tagvalue = tagvalue -class HttpMessage(msrest.serialization.Model): +class HttpMessage(_serialization.Model): """HTTP message. :ivar content: HTTP message content. - :vartype content: any + :vartype content: JSON """ _attribute_map = { - 'content': {'key': 'content', 'type': 'object'}, + "content": {"key": "content", "type": "object"}, } - def __init__( - self, - *, - content: Optional[Any] = None, - **kwargs - ): + def __init__(self, *, content: Optional[JSON] = None, **kwargs): """ :keyword content: HTTP message content. - :paramtype content: any + :paramtype content: JSON """ - super(HttpMessage, self).__init__(**kwargs) + super().__init__(**kwargs) self.content = content -class Identity(msrest.serialization.Model): +class Identity(_serialization.Model): """Identity for the resource. Variables are only populated by the server, and will be ignored when sending a request. @@ -1194,74 +1131,69 @@ class Identity(msrest.serialization.Model): :vartype principal_id: str :ivar tenant_id: The tenant ID of resource. :vartype tenant_id: str - :ivar type: The identity type. Possible values include: "SystemAssigned", "UserAssigned", - "SystemAssigned, UserAssigned", "None". + :ivar type: The identity type. Known values are: "SystemAssigned", "UserAssigned", + "SystemAssigned, UserAssigned", and "None". :vartype type: str or ~azure.mgmt.resource.resources.v2018_02_01.models.ResourceIdentityType """ _validation = { - 'principal_id': {'readonly': True}, - 'tenant_id': {'readonly': True}, + "principal_id": {"readonly": True}, + "tenant_id": {"readonly": True}, } _attribute_map = { - 'principal_id': {'key': 'principalId', 'type': 'str'}, - 'tenant_id': {'key': 'tenantId', 'type': 'str'}, - 'type': {'key': 'type', 'type': 'str'}, + "principal_id": {"key": "principalId", "type": "str"}, + "tenant_id": {"key": "tenantId", "type": "str"}, + "type": {"key": "type", "type": "str"}, } - def __init__( - self, - *, - type: Optional[Union[str, "ResourceIdentityType"]] = None, - **kwargs - ): + def __init__(self, *, type: Optional[Union[str, "_models.ResourceIdentityType"]] = None, **kwargs): """ - :keyword type: The identity type. Possible values include: "SystemAssigned", "UserAssigned", - "SystemAssigned, UserAssigned", "None". + :keyword type: The identity type. Known values are: "SystemAssigned", "UserAssigned", + "SystemAssigned, UserAssigned", and "None". :paramtype type: str or ~azure.mgmt.resource.resources.v2018_02_01.models.ResourceIdentityType """ - super(Identity, self).__init__(**kwargs) + super().__init__(**kwargs) self.principal_id = None self.tenant_id = None self.type = type -class OnErrorDeployment(msrest.serialization.Model): +class OnErrorDeployment(_serialization.Model): """Deployment on error behavior. :ivar type: The deployment on error behavior type. Possible values are LastSuccessful and - SpecificDeployment. Possible values include: "LastSuccessful", "SpecificDeployment". + SpecificDeployment. Known values are: "LastSuccessful" and "SpecificDeployment". :vartype type: str or ~azure.mgmt.resource.resources.v2018_02_01.models.OnErrorDeploymentType :ivar deployment_name: The deployment to be used on error case. :vartype deployment_name: str """ _attribute_map = { - 'type': {'key': 'type', 'type': 'str'}, - 'deployment_name': {'key': 'deploymentName', 'type': 'str'}, + "type": {"key": "type", "type": "str"}, + "deployment_name": {"key": "deploymentName", "type": "str"}, } def __init__( self, *, - type: Optional[Union[str, "OnErrorDeploymentType"]] = None, + type: Optional[Union[str, "_models.OnErrorDeploymentType"]] = None, deployment_name: Optional[str] = None, **kwargs ): """ :keyword type: The deployment on error behavior type. Possible values are LastSuccessful and - SpecificDeployment. Possible values include: "LastSuccessful", "SpecificDeployment". + SpecificDeployment. Known values are: "LastSuccessful" and "SpecificDeployment". :paramtype type: str or ~azure.mgmt.resource.resources.v2018_02_01.models.OnErrorDeploymentType :keyword deployment_name: The deployment to be used on error case. :paramtype deployment_name: str """ - super(OnErrorDeployment, self).__init__(**kwargs) + super().__init__(**kwargs) self.type = type self.deployment_name = deployment_name -class OnErrorDeploymentExtended(msrest.serialization.Model): +class OnErrorDeploymentExtended(_serialization.Model): """Deployment on error behavior with additional details. Variables are only populated by the server, and will be ignored when sending a request. @@ -1269,81 +1201,75 @@ class OnErrorDeploymentExtended(msrest.serialization.Model): :ivar provisioning_state: The state of the provisioning for the on error deployment. :vartype provisioning_state: str :ivar type: The deployment on error behavior type. Possible values are LastSuccessful and - SpecificDeployment. Possible values include: "LastSuccessful", "SpecificDeployment". + SpecificDeployment. Known values are: "LastSuccessful" and "SpecificDeployment". :vartype type: str or ~azure.mgmt.resource.resources.v2018_02_01.models.OnErrorDeploymentType :ivar deployment_name: The deployment to be used on error case. :vartype deployment_name: str """ _validation = { - 'provisioning_state': {'readonly': True}, + "provisioning_state": {"readonly": True}, } _attribute_map = { - 'provisioning_state': {'key': 'provisioningState', 'type': 'str'}, - 'type': {'key': 'type', 'type': 'str'}, - 'deployment_name': {'key': 'deploymentName', 'type': 'str'}, + "provisioning_state": {"key": "provisioningState", "type": "str"}, + "type": {"key": "type", "type": "str"}, + "deployment_name": {"key": "deploymentName", "type": "str"}, } def __init__( self, *, - type: Optional[Union[str, "OnErrorDeploymentType"]] = None, + type: Optional[Union[str, "_models.OnErrorDeploymentType"]] = None, deployment_name: Optional[str] = None, **kwargs ): """ :keyword type: The deployment on error behavior type. Possible values are LastSuccessful and - SpecificDeployment. Possible values include: "LastSuccessful", "SpecificDeployment". + SpecificDeployment. Known values are: "LastSuccessful" and "SpecificDeployment". :paramtype type: str or ~azure.mgmt.resource.resources.v2018_02_01.models.OnErrorDeploymentType :keyword deployment_name: The deployment to be used on error case. :paramtype deployment_name: str """ - super(OnErrorDeploymentExtended, self).__init__(**kwargs) + super().__init__(**kwargs) self.provisioning_state = None self.type = type self.deployment_name = deployment_name -class ParametersLink(msrest.serialization.Model): +class ParametersLink(_serialization.Model): """Entity representing the reference to the deployment parameters. All required parameters must be populated in order to send to Azure. - :ivar uri: Required. The URI of the parameters file. + :ivar uri: The URI of the parameters file. Required. :vartype uri: str :ivar content_version: If included, must match the ContentVersion in the template. :vartype content_version: str """ _validation = { - 'uri': {'required': True}, + "uri": {"required": True}, } _attribute_map = { - 'uri': {'key': 'uri', 'type': 'str'}, - 'content_version': {'key': 'contentVersion', 'type': 'str'}, + "uri": {"key": "uri", "type": "str"}, + "content_version": {"key": "contentVersion", "type": "str"}, } - def __init__( - self, - *, - uri: str, - content_version: Optional[str] = None, - **kwargs - ): + def __init__(self, *, uri: str, content_version: Optional[str] = None, **kwargs): """ - :keyword uri: Required. The URI of the parameters file. + :keyword uri: The URI of the parameters file. Required. :paramtype uri: str :keyword content_version: If included, must match the ContentVersion in the template. :paramtype content_version: str """ - super(ParametersLink, self).__init__(**kwargs) + super().__init__(**kwargs) self.uri = uri self.content_version = content_version -class Plan(msrest.serialization.Model): +class Plan(_serialization.Model): """Plan for the resource. :ivar name: The plan ID. @@ -1359,11 +1285,11 @@ class Plan(msrest.serialization.Model): """ _attribute_map = { - 'name': {'key': 'name', 'type': 'str'}, - 'publisher': {'key': 'publisher', 'type': 'str'}, - 'product': {'key': 'product', 'type': 'str'}, - 'promotion_code': {'key': 'promotionCode', 'type': 'str'}, - 'version': {'key': 'version', 'type': 'str'}, + "name": {"key": "name", "type": "str"}, + "publisher": {"key": "publisher", "type": "str"}, + "product": {"key": "product", "type": "str"}, + "promotion_code": {"key": "promotionCode", "type": "str"}, + "version": {"key": "version", "type": "str"}, } def __init__( @@ -1388,7 +1314,7 @@ def __init__( :keyword version: The plan's version. :paramtype version: str """ - super(Plan, self).__init__(**kwargs) + super().__init__(**kwargs) self.name = name self.publisher = publisher self.product = product @@ -1396,7 +1322,7 @@ def __init__( self.version = version -class Provider(msrest.serialization.Model): +class Provider(_serialization.Model): """Resource provider information. Variables are only populated by the server, and will be ignored when sending a request. @@ -1413,36 +1339,31 @@ class Provider(msrest.serialization.Model): """ _validation = { - 'id': {'readonly': True}, - 'registration_state': {'readonly': True}, - 'resource_types': {'readonly': True}, + "id": {"readonly": True}, + "registration_state": {"readonly": True}, + "resource_types": {"readonly": True}, } _attribute_map = { - 'id': {'key': 'id', 'type': 'str'}, - 'namespace': {'key': 'namespace', 'type': 'str'}, - 'registration_state': {'key': 'registrationState', 'type': 'str'}, - 'resource_types': {'key': 'resourceTypes', 'type': '[ProviderResourceType]'}, + "id": {"key": "id", "type": "str"}, + "namespace": {"key": "namespace", "type": "str"}, + "registration_state": {"key": "registrationState", "type": "str"}, + "resource_types": {"key": "resourceTypes", "type": "[ProviderResourceType]"}, } - def __init__( - self, - *, - namespace: Optional[str] = None, - **kwargs - ): + def __init__(self, *, namespace: Optional[str] = None, **kwargs): """ :keyword namespace: The namespace of the resource provider. :paramtype namespace: str """ - super(Provider, self).__init__(**kwargs) + super().__init__(**kwargs) self.id = None self.namespace = namespace self.registration_state = None self.resource_types = None -class ProviderListResult(msrest.serialization.Model): +class ProviderListResult(_serialization.Model): """List of resource providers. Variables are only populated by the server, and will be ignored when sending a request. @@ -1454,30 +1375,25 @@ class ProviderListResult(msrest.serialization.Model): """ _validation = { - 'next_link': {'readonly': True}, + "next_link": {"readonly": True}, } _attribute_map = { - 'value': {'key': 'value', 'type': '[Provider]'}, - 'next_link': {'key': 'nextLink', 'type': 'str'}, + "value": {"key": "value", "type": "[Provider]"}, + "next_link": {"key": "nextLink", "type": "str"}, } - def __init__( - self, - *, - value: Optional[List["Provider"]] = None, - **kwargs - ): + def __init__(self, *, value: Optional[List["_models.Provider"]] = None, **kwargs): """ :keyword value: An array of resource providers. :paramtype value: list[~azure.mgmt.resource.resources.v2018_02_01.models.Provider] """ - super(ProviderListResult, self).__init__(**kwargs) + super().__init__(**kwargs) self.value = value self.next_link = None -class ProviderResourceType(msrest.serialization.Model): +class ProviderResourceType(_serialization.Model): """Resource type managed by the resource provider. :ivar resource_type: The resource type. @@ -1495,12 +1411,12 @@ class ProviderResourceType(msrest.serialization.Model): """ _attribute_map = { - 'resource_type': {'key': 'resourceType', 'type': 'str'}, - 'locations': {'key': 'locations', 'type': '[str]'}, - 'aliases': {'key': 'aliases', 'type': '[AliasType]'}, - 'api_versions': {'key': 'apiVersions', 'type': '[str]'}, - 'zone_mappings': {'key': 'zoneMappings', 'type': '[ZoneMapping]'}, - 'properties': {'key': 'properties', 'type': '{str}'}, + "resource_type": {"key": "resourceType", "type": "str"}, + "locations": {"key": "locations", "type": "[str]"}, + "aliases": {"key": "aliases", "type": "[AliasType]"}, + "api_versions": {"key": "apiVersions", "type": "[str]"}, + "zone_mappings": {"key": "zoneMappings", "type": "[ZoneMapping]"}, + "properties": {"key": "properties", "type": "{str}"}, } def __init__( @@ -1508,9 +1424,9 @@ def __init__( *, resource_type: Optional[str] = None, locations: Optional[List[str]] = None, - aliases: Optional[List["AliasType"]] = None, + aliases: Optional[List["_models.AliasType"]] = None, api_versions: Optional[List[str]] = None, - zone_mappings: Optional[List["ZoneMapping"]] = None, + zone_mappings: Optional[List["_models.ZoneMapping"]] = None, properties: Optional[Dict[str, str]] = None, **kwargs ): @@ -1528,7 +1444,7 @@ def __init__( :keyword properties: The properties. :paramtype properties: dict[str, str] """ - super(ProviderResourceType, self).__init__(**kwargs) + super().__init__(**kwargs) self.resource_type = resource_type self.locations = locations self.aliases = aliases @@ -1537,7 +1453,7 @@ def __init__( self.properties = properties -class ResourceGroup(msrest.serialization.Model): +class ResourceGroup(_serialization.Model): """Resource group information. Variables are only populated by the server, and will be ignored when sending a request. @@ -1550,27 +1466,27 @@ class ResourceGroup(msrest.serialization.Model): :vartype name: str :ivar properties: The resource group properties. :vartype properties: ~azure.mgmt.resource.resources.v2018_02_01.models.ResourceGroupProperties - :ivar location: Required. The location of the resource group. It cannot be changed after the - resource group has been created. It must be one of the supported Azure locations. + :ivar location: The location of the resource group. It cannot be changed after the resource + group has been created. It must be one of the supported Azure locations. Required. :vartype location: str :ivar managed_by: The ID of the resource that manages this resource group. :vartype managed_by: str - :ivar tags: A set of tags. The tags attached to the resource group. + :ivar tags: The tags attached to the resource group. :vartype tags: dict[str, str] """ _validation = { - 'id': {'readonly': True}, - 'location': {'required': True}, + "id": {"readonly": True}, + "location": {"required": True}, } _attribute_map = { - 'id': {'key': 'id', 'type': 'str'}, - 'name': {'key': 'name', 'type': 'str'}, - 'properties': {'key': 'properties', 'type': 'ResourceGroupProperties'}, - 'location': {'key': 'location', 'type': 'str'}, - 'managed_by': {'key': 'managedBy', 'type': 'str'}, - 'tags': {'key': 'tags', 'type': '{str}'}, + "id": {"key": "id", "type": "str"}, + "name": {"key": "name", "type": "str"}, + "properties": {"key": "properties", "type": "ResourceGroupProperties"}, + "location": {"key": "location", "type": "str"}, + "managed_by": {"key": "managedBy", "type": "str"}, + "tags": {"key": "tags", "type": "{str}"}, } def __init__( @@ -1578,7 +1494,7 @@ def __init__( *, location: str, name: Optional[str] = None, - properties: Optional["ResourceGroupProperties"] = None, + properties: Optional["_models.ResourceGroupProperties"] = None, managed_by: Optional[str] = None, tags: Optional[Dict[str, str]] = None, **kwargs @@ -1589,15 +1505,15 @@ def __init__( :keyword properties: The resource group properties. :paramtype properties: ~azure.mgmt.resource.resources.v2018_02_01.models.ResourceGroupProperties - :keyword location: Required. The location of the resource group. It cannot be changed after the - resource group has been created. It must be one of the supported Azure locations. + :keyword location: The location of the resource group. It cannot be changed after the resource + group has been created. It must be one of the supported Azure locations. Required. :paramtype location: str :keyword managed_by: The ID of the resource that manages this resource group. :paramtype managed_by: str - :keyword tags: A set of tags. The tags attached to the resource group. + :keyword tags: The tags attached to the resource group. :paramtype tags: dict[str, str] """ - super(ResourceGroup, self).__init__(**kwargs) + super().__init__(**kwargs) self.id = None self.name = name self.properties = properties @@ -1606,41 +1522,41 @@ def __init__( self.tags = tags -class ResourceGroupExportResult(msrest.serialization.Model): +class ResourceGroupExportResult(_serialization.Model): """Resource group export result. :ivar template: The template content. - :vartype template: any + :vartype template: JSON :ivar error: The error. :vartype error: ~azure.mgmt.resource.resources.v2018_02_01.models.ResourceManagementErrorWithDetails """ _attribute_map = { - 'template': {'key': 'template', 'type': 'object'}, - 'error': {'key': 'error', 'type': 'ResourceManagementErrorWithDetails'}, + "template": {"key": "template", "type": "object"}, + "error": {"key": "error", "type": "ResourceManagementErrorWithDetails"}, } def __init__( self, *, - template: Optional[Any] = None, - error: Optional["ResourceManagementErrorWithDetails"] = None, + template: Optional[JSON] = None, + error: Optional["_models.ResourceManagementErrorWithDetails"] = None, **kwargs ): """ :keyword template: The template content. - :paramtype template: any + :paramtype template: JSON :keyword error: The error. :paramtype error: ~azure.mgmt.resource.resources.v2018_02_01.models.ResourceManagementErrorWithDetails """ - super(ResourceGroupExportResult, self).__init__(**kwargs) + super().__init__(**kwargs) self.template = template self.error = error -class ResourceGroupFilter(msrest.serialization.Model): +class ResourceGroupFilter(_serialization.Model): """Resource group filter. :ivar tag_name: The tag name. @@ -1650,29 +1566,23 @@ class ResourceGroupFilter(msrest.serialization.Model): """ _attribute_map = { - 'tag_name': {'key': 'tagName', 'type': 'str'}, - 'tag_value': {'key': 'tagValue', 'type': 'str'}, + "tag_name": {"key": "tagName", "type": "str"}, + "tag_value": {"key": "tagValue", "type": "str"}, } - def __init__( - self, - *, - tag_name: Optional[str] = None, - tag_value: Optional[str] = None, - **kwargs - ): + def __init__(self, *, tag_name: Optional[str] = None, tag_value: Optional[str] = None, **kwargs): """ :keyword tag_name: The tag name. :paramtype tag_name: str :keyword tag_value: The tag value. :paramtype tag_value: str """ - super(ResourceGroupFilter, self).__init__(**kwargs) + super().__init__(**kwargs) self.tag_name = tag_name self.tag_value = tag_value -class ResourceGroupListResult(msrest.serialization.Model): +class ResourceGroupListResult(_serialization.Model): """List of resource groups. Variables are only populated by the server, and will be ignored when sending a request. @@ -1684,30 +1594,25 @@ class ResourceGroupListResult(msrest.serialization.Model): """ _validation = { - 'next_link': {'readonly': True}, + "next_link": {"readonly": True}, } _attribute_map = { - 'value': {'key': 'value', 'type': '[ResourceGroup]'}, - 'next_link': {'key': 'nextLink', 'type': 'str'}, + "value": {"key": "value", "type": "[ResourceGroup]"}, + "next_link": {"key": "nextLink", "type": "str"}, } - def __init__( - self, - *, - value: Optional[List["ResourceGroup"]] = None, - **kwargs - ): + def __init__(self, *, value: Optional[List["_models.ResourceGroup"]] = None, **kwargs): """ :keyword value: An array of resource groups. :paramtype value: list[~azure.mgmt.resource.resources.v2018_02_01.models.ResourceGroup] """ - super(ResourceGroupListResult, self).__init__(**kwargs) + super().__init__(**kwargs) self.value = value self.next_link = None -class ResourceGroupPatchable(msrest.serialization.Model): +class ResourceGroupPatchable(_serialization.Model): """Resource group information. :ivar name: The name of the resource group. @@ -1716,22 +1621,22 @@ class ResourceGroupPatchable(msrest.serialization.Model): :vartype properties: ~azure.mgmt.resource.resources.v2018_02_01.models.ResourceGroupProperties :ivar managed_by: The ID of the resource that manages this resource group. :vartype managed_by: str - :ivar tags: A set of tags. The tags attached to the resource group. + :ivar tags: The tags attached to the resource group. :vartype tags: dict[str, str] """ _attribute_map = { - 'name': {'key': 'name', 'type': 'str'}, - 'properties': {'key': 'properties', 'type': 'ResourceGroupProperties'}, - 'managed_by': {'key': 'managedBy', 'type': 'str'}, - 'tags': {'key': 'tags', 'type': '{str}'}, + "name": {"key": "name", "type": "str"}, + "properties": {"key": "properties", "type": "ResourceGroupProperties"}, + "managed_by": {"key": "managedBy", "type": "str"}, + "tags": {"key": "tags", "type": "{str}"}, } def __init__( self, *, name: Optional[str] = None, - properties: Optional["ResourceGroupProperties"] = None, + properties: Optional["_models.ResourceGroupProperties"] = None, managed_by: Optional[str] = None, tags: Optional[Dict[str, str]] = None, **kwargs @@ -1744,17 +1649,17 @@ def __init__( ~azure.mgmt.resource.resources.v2018_02_01.models.ResourceGroupProperties :keyword managed_by: The ID of the resource that manages this resource group. :paramtype managed_by: str - :keyword tags: A set of tags. The tags attached to the resource group. + :keyword tags: The tags attached to the resource group. :paramtype tags: dict[str, str] """ - super(ResourceGroupPatchable, self).__init__(**kwargs) + super().__init__(**kwargs) self.name = name self.properties = properties self.managed_by = managed_by self.tags = tags -class ResourceGroupProperties(msrest.serialization.Model): +class ResourceGroupProperties(_serialization.Model): """The resource group properties. Variables are only populated by the server, and will be ignored when sending a request. @@ -1764,24 +1669,20 @@ class ResourceGroupProperties(msrest.serialization.Model): """ _validation = { - 'provisioning_state': {'readonly': True}, + "provisioning_state": {"readonly": True}, } _attribute_map = { - 'provisioning_state': {'key': 'provisioningState', 'type': 'str'}, + "provisioning_state": {"key": "provisioningState", "type": "str"}, } - def __init__( - self, - **kwargs - ): - """ - """ - super(ResourceGroupProperties, self).__init__(**kwargs) + def __init__(self, **kwargs): + """ """ + super().__init__(**kwargs) self.provisioning_state = None -class ResourceListResult(msrest.serialization.Model): +class ResourceListResult(_serialization.Model): """List of resource groups. Variables are only populated by the server, and will be ignored when sending a request. @@ -1793,31 +1694,26 @@ class ResourceListResult(msrest.serialization.Model): """ _validation = { - 'next_link': {'readonly': True}, + "next_link": {"readonly": True}, } _attribute_map = { - 'value': {'key': 'value', 'type': '[GenericResourceExpanded]'}, - 'next_link': {'key': 'nextLink', 'type': 'str'}, + "value": {"key": "value", "type": "[GenericResourceExpanded]"}, + "next_link": {"key": "nextLink", "type": "str"}, } - def __init__( - self, - *, - value: Optional[List["GenericResourceExpanded"]] = None, - **kwargs - ): + def __init__(self, *, value: Optional[List["_models.GenericResourceExpanded"]] = None, **kwargs): """ :keyword value: An array of resources. :paramtype value: list[~azure.mgmt.resource.resources.v2018_02_01.models.GenericResourceExpanded] """ - super(ResourceListResult, self).__init__(**kwargs) + super().__init__(**kwargs) self.value = value self.next_link = None -class ResourceManagementErrorWithDetails(msrest.serialization.Model): +class ResourceManagementErrorWithDetails(_serialization.Model): """The detailed error message of resource management. Variables are only populated by the server, and will be ignored when sending a request. @@ -1834,33 +1730,29 @@ class ResourceManagementErrorWithDetails(msrest.serialization.Model): """ _validation = { - 'code': {'readonly': True}, - 'message': {'readonly': True}, - 'target': {'readonly': True}, - 'details': {'readonly': True}, + "code": {"readonly": True}, + "message": {"readonly": True}, + "target": {"readonly": True}, + "details": {"readonly": True}, } _attribute_map = { - 'code': {'key': 'code', 'type': 'str'}, - 'message': {'key': 'message', 'type': 'str'}, - 'target': {'key': 'target', 'type': 'str'}, - 'details': {'key': 'details', 'type': '[ResourceManagementErrorWithDetails]'}, + "code": {"key": "code", "type": "str"}, + "message": {"key": "message", "type": "str"}, + "target": {"key": "target", "type": "str"}, + "details": {"key": "details", "type": "[ResourceManagementErrorWithDetails]"}, } - def __init__( - self, - **kwargs - ): - """ - """ - super(ResourceManagementErrorWithDetails, self).__init__(**kwargs) + def __init__(self, **kwargs): + """ """ + super().__init__(**kwargs) self.code = None self.message = None self.target = None self.details = None -class ResourceProviderOperationDisplayProperties(msrest.serialization.Model): +class ResourceProviderOperationDisplayProperties(_serialization.Model): """Resource provider operation's display properties. :ivar publisher: Operation description. @@ -1876,11 +1768,11 @@ class ResourceProviderOperationDisplayProperties(msrest.serialization.Model): """ _attribute_map = { - 'publisher': {'key': 'publisher', 'type': 'str'}, - 'provider': {'key': 'provider', 'type': 'str'}, - 'resource': {'key': 'resource', 'type': 'str'}, - 'operation': {'key': 'operation', 'type': 'str'}, - 'description': {'key': 'description', 'type': 'str'}, + "publisher": {"key": "publisher", "type": "str"}, + "provider": {"key": "provider", "type": "str"}, + "resource": {"key": "resource", "type": "str"}, + "operation": {"key": "operation", "type": "str"}, + "description": {"key": "description", "type": "str"}, } def __init__( @@ -1905,7 +1797,7 @@ def __init__( :keyword description: Operation description. :paramtype description: str """ - super(ResourceProviderOperationDisplayProperties, self).__init__(**kwargs) + super().__init__(**kwargs) self.publisher = publisher self.provider = provider self.resource = resource @@ -1913,7 +1805,7 @@ def __init__( self.description = description -class ResourcesMoveInfo(msrest.serialization.Model): +class ResourcesMoveInfo(_serialization.Model): """Parameters of move resources. :ivar resources: The IDs of the resources. @@ -1923,29 +1815,23 @@ class ResourcesMoveInfo(msrest.serialization.Model): """ _attribute_map = { - 'resources': {'key': 'resources', 'type': '[str]'}, - 'target_resource_group': {'key': 'targetResourceGroup', 'type': 'str'}, + "resources": {"key": "resources", "type": "[str]"}, + "target_resource_group": {"key": "targetResourceGroup", "type": "str"}, } - def __init__( - self, - *, - resources: Optional[List[str]] = None, - target_resource_group: Optional[str] = None, - **kwargs - ): + def __init__(self, *, resources: Optional[List[str]] = None, target_resource_group: Optional[str] = None, **kwargs): """ :keyword resources: The IDs of the resources. :paramtype resources: list[str] :keyword target_resource_group: The target resource group. :paramtype target_resource_group: str """ - super(ResourcesMoveInfo, self).__init__(**kwargs) + super().__init__(**kwargs) self.resources = resources self.target_resource_group = target_resource_group -class Sku(msrest.serialization.Model): +class Sku(_serialization.Model): """SKU for the resource. :ivar name: The SKU name. @@ -1963,12 +1849,12 @@ class Sku(msrest.serialization.Model): """ _attribute_map = { - 'name': {'key': 'name', 'type': 'str'}, - 'tier': {'key': 'tier', 'type': 'str'}, - 'size': {'key': 'size', 'type': 'str'}, - 'family': {'key': 'family', 'type': 'str'}, - 'model': {'key': 'model', 'type': 'str'}, - 'capacity': {'key': 'capacity', 'type': 'int'}, + "name": {"key": "name", "type": "str"}, + "tier": {"key": "tier", "type": "str"}, + "size": {"key": "size", "type": "str"}, + "family": {"key": "family", "type": "str"}, + "model": {"key": "model", "type": "str"}, + "capacity": {"key": "capacity", "type": "int"}, } def __init__( @@ -1996,7 +1882,7 @@ def __init__( :keyword capacity: The SKU capacity. :paramtype capacity: int """ - super(Sku, self).__init__(**kwargs) + super().__init__(**kwargs) self.name = name self.tier = tier self.size = size @@ -2005,7 +1891,7 @@ def __init__( self.capacity = capacity -class SubResource(msrest.serialization.Model): +class SubResource(_serialization.Model): """Sub-resource. :ivar id: Resource ID. @@ -2013,24 +1899,19 @@ class SubResource(msrest.serialization.Model): """ _attribute_map = { - 'id': {'key': 'id', 'type': 'str'}, + "id": {"key": "id", "type": "str"}, } - def __init__( - self, - *, - id: Optional[str] = None, - **kwargs - ): + def __init__(self, *, id: Optional[str] = None, **kwargs): # pylint: disable=redefined-builtin """ :keyword id: Resource ID. :paramtype id: str """ - super(SubResource, self).__init__(**kwargs) + super().__init__(**kwargs) self.id = id -class TagCount(msrest.serialization.Model): +class TagCount(_serialization.Model): """Tag count. :ivar type: Type of count. @@ -2040,29 +1921,23 @@ class TagCount(msrest.serialization.Model): """ _attribute_map = { - 'type': {'key': 'type', 'type': 'str'}, - 'value': {'key': 'value', 'type': 'int'}, + "type": {"key": "type", "type": "str"}, + "value": {"key": "value", "type": "int"}, } - def __init__( - self, - *, - type: Optional[str] = None, - value: Optional[int] = None, - **kwargs - ): + def __init__(self, *, type: Optional[str] = None, value: Optional[int] = None, **kwargs): """ :keyword type: Type of count. :paramtype type: str :keyword value: Value of count. :paramtype value: int """ - super(TagCount, self).__init__(**kwargs) + super().__init__(**kwargs) self.type = type self.value = value -class TagDetails(msrest.serialization.Model): +class TagDetails(_serialization.Model): """Tag details. Variables are only populated by the server, and will be ignored when sending a request. @@ -2079,22 +1954,22 @@ class TagDetails(msrest.serialization.Model): """ _validation = { - 'id': {'readonly': True}, + "id": {"readonly": True}, } _attribute_map = { - 'id': {'key': 'id', 'type': 'str'}, - 'tag_name': {'key': 'tagName', 'type': 'str'}, - 'count': {'key': 'count', 'type': 'TagCount'}, - 'values': {'key': 'values', 'type': '[TagValue]'}, + "id": {"key": "id", "type": "str"}, + "tag_name": {"key": "tagName", "type": "str"}, + "count": {"key": "count", "type": "TagCount"}, + "values": {"key": "values", "type": "[TagValue]"}, } def __init__( self, *, tag_name: Optional[str] = None, - count: Optional["TagCount"] = None, - values: Optional[List["TagValue"]] = None, + count: Optional["_models.TagCount"] = None, + values: Optional[List["_models.TagValue"]] = None, **kwargs ): """ @@ -2106,14 +1981,14 @@ def __init__( :keyword values: The list of tag values. :paramtype values: list[~azure.mgmt.resource.resources.v2018_02_01.models.TagValue] """ - super(TagDetails, self).__init__(**kwargs) + super().__init__(**kwargs) self.id = None self.tag_name = tag_name self.count = count self.values = values -class TagsListResult(msrest.serialization.Model): +class TagsListResult(_serialization.Model): """List of subscription tags. Variables are only populated by the server, and will be ignored when sending a request. @@ -2125,30 +2000,25 @@ class TagsListResult(msrest.serialization.Model): """ _validation = { - 'next_link': {'readonly': True}, + "next_link": {"readonly": True}, } _attribute_map = { - 'value': {'key': 'value', 'type': '[TagDetails]'}, - 'next_link': {'key': 'nextLink', 'type': 'str'}, + "value": {"key": "value", "type": "[TagDetails]"}, + "next_link": {"key": "nextLink", "type": "str"}, } - def __init__( - self, - *, - value: Optional[List["TagDetails"]] = None, - **kwargs - ): + def __init__(self, *, value: Optional[List["_models.TagDetails"]] = None, **kwargs): """ :keyword value: An array of tags. :paramtype value: list[~azure.mgmt.resource.resources.v2018_02_01.models.TagDetails] """ - super(TagsListResult, self).__init__(**kwargs) + super().__init__(**kwargs) self.value = value self.next_link = None -class TagValue(msrest.serialization.Model): +class TagValue(_serialization.Model): """Tag information. Variables are only populated by the server, and will be ignored when sending a request. @@ -2162,35 +2032,29 @@ class TagValue(msrest.serialization.Model): """ _validation = { - 'id': {'readonly': True}, + "id": {"readonly": True}, } _attribute_map = { - 'id': {'key': 'id', 'type': 'str'}, - 'tag_value': {'key': 'tagValue', 'type': 'str'}, - 'count': {'key': 'count', 'type': 'TagCount'}, + "id": {"key": "id", "type": "str"}, + "tag_value": {"key": "tagValue", "type": "str"}, + "count": {"key": "count", "type": "TagCount"}, } - def __init__( - self, - *, - tag_value: Optional[str] = None, - count: Optional["TagCount"] = None, - **kwargs - ): + def __init__(self, *, tag_value: Optional[str] = None, count: Optional["_models.TagCount"] = None, **kwargs): """ :keyword tag_value: The tag value. :paramtype tag_value: str :keyword count: The tag value count. :paramtype count: ~azure.mgmt.resource.resources.v2018_02_01.models.TagCount """ - super(TagValue, self).__init__(**kwargs) + super().__init__(**kwargs) self.id = None self.tag_value = tag_value self.count = count -class TargetResource(msrest.serialization.Model): +class TargetResource(_serialization.Model): """Target resource. :ivar id: The ID of the resource. @@ -2202,15 +2066,15 @@ class TargetResource(msrest.serialization.Model): """ _attribute_map = { - 'id': {'key': 'id', 'type': 'str'}, - 'resource_name': {'key': 'resourceName', 'type': 'str'}, - 'resource_type': {'key': 'resourceType', 'type': 'str'}, + "id": {"key": "id", "type": "str"}, + "resource_name": {"key": "resourceName", "type": "str"}, + "resource_type": {"key": "resourceType", "type": "str"}, } def __init__( self, *, - id: Optional[str] = None, + id: Optional[str] = None, # pylint: disable=redefined-builtin resource_name: Optional[str] = None, resource_type: Optional[str] = None, **kwargs @@ -2223,13 +2087,13 @@ def __init__( :keyword resource_type: The type of the resource. :paramtype resource_type: str """ - super(TargetResource, self).__init__(**kwargs) + super().__init__(**kwargs) self.id = id self.resource_name = resource_name self.resource_type = resource_type -class TemplateHashResult(msrest.serialization.Model): +class TemplateHashResult(_serialization.Model): """Result of the request to calculate template hash. It contains a string of minified template and its hash. :ivar minified_template: The minified template string. @@ -2239,67 +2103,55 @@ class TemplateHashResult(msrest.serialization.Model): """ _attribute_map = { - 'minified_template': {'key': 'minifiedTemplate', 'type': 'str'}, - 'template_hash': {'key': 'templateHash', 'type': 'str'}, + "minified_template": {"key": "minifiedTemplate", "type": "str"}, + "template_hash": {"key": "templateHash", "type": "str"}, } - def __init__( - self, - *, - minified_template: Optional[str] = None, - template_hash: Optional[str] = None, - **kwargs - ): + def __init__(self, *, minified_template: Optional[str] = None, template_hash: Optional[str] = None, **kwargs): """ :keyword minified_template: The minified template string. :paramtype minified_template: str :keyword template_hash: The template hash. :paramtype template_hash: str """ - super(TemplateHashResult, self).__init__(**kwargs) + super().__init__(**kwargs) self.minified_template = minified_template self.template_hash = template_hash -class TemplateLink(msrest.serialization.Model): +class TemplateLink(_serialization.Model): """Entity representing the reference to the template. All required parameters must be populated in order to send to Azure. - :ivar uri: Required. The URI of the template to deploy. + :ivar uri: The URI of the template to deploy. Required. :vartype uri: str :ivar content_version: If included, must match the ContentVersion in the template. :vartype content_version: str """ _validation = { - 'uri': {'required': True}, + "uri": {"required": True}, } _attribute_map = { - 'uri': {'key': 'uri', 'type': 'str'}, - 'content_version': {'key': 'contentVersion', 'type': 'str'}, + "uri": {"key": "uri", "type": "str"}, + "content_version": {"key": "contentVersion", "type": "str"}, } - def __init__( - self, - *, - uri: str, - content_version: Optional[str] = None, - **kwargs - ): + def __init__(self, *, uri: str, content_version: Optional[str] = None, **kwargs): """ - :keyword uri: Required. The URI of the template to deploy. + :keyword uri: The URI of the template to deploy. Required. :paramtype uri: str :keyword content_version: If included, must match the ContentVersion in the template. :paramtype content_version: str """ - super(TemplateLink, self).__init__(**kwargs) + super().__init__(**kwargs) self.uri = uri self.content_version = content_version -class ZoneMapping(msrest.serialization.Model): +class ZoneMapping(_serialization.Model): """ZoneMapping. :ivar location: The location of the zone mapping. @@ -2309,23 +2161,17 @@ class ZoneMapping(msrest.serialization.Model): """ _attribute_map = { - 'location': {'key': 'location', 'type': 'str'}, - 'zones': {'key': 'zones', 'type': '[str]'}, + "location": {"key": "location", "type": "str"}, + "zones": {"key": "zones", "type": "[str]"}, } - def __init__( - self, - *, - location: Optional[str] = None, - zones: Optional[List[str]] = None, - **kwargs - ): + def __init__(self, *, location: Optional[str] = None, zones: Optional[List[str]] = None, **kwargs): """ :keyword location: The location of the zone mapping. :paramtype location: str :keyword zones: :paramtype zones: list[str] """ - super(ZoneMapping, self).__init__(**kwargs) + super().__init__(**kwargs) self.location = location self.zones = zones diff --git a/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/resources/v2018_02_01/models/_patch.py b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/resources/v2018_02_01/models/_patch.py new file mode 100644 index 0000000000000..f7dd32510333d --- /dev/null +++ b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/resources/v2018_02_01/models/_patch.py @@ -0,0 +1,20 @@ +# ------------------------------------ +# Copyright (c) Microsoft Corporation. +# Licensed under the MIT License. +# ------------------------------------ +"""Customize generated code here. + +Follow our quickstart for examples: https://aka.ms/azsdk/python/dpcodegen/python/customize +""" +from typing import List + +__all__: List[str] = [] # Add all objects you want publicly available to users at this package level + + +def patch_sdk(): + """Do not remove from this file. + + `patch_sdk` is a last resort escape hatch that allows you to do customizations + you can't accomplish using the techniques described in + https://aka.ms/azsdk/python/dpcodegen/python/customize + """ diff --git a/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/resources/v2018_02_01/models/_resource_management_client_enums.py b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/resources/v2018_02_01/models/_resource_management_client_enums.py index 02799db402bcc..612a5242cd9bd 100644 --- a/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/resources/v2018_02_01/models/_resource_management_client_enums.py +++ b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/resources/v2018_02_01/models/_resource_management_client_enums.py @@ -7,11 +7,10 @@ # -------------------------------------------------------------------------- from enum import Enum -from six import with_metaclass from azure.core import CaseInsensitiveEnumMeta -class DeploymentMode(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): +class DeploymentMode(str, Enum, metaclass=CaseInsensitiveEnumMeta): """The mode that is used to deploy resources. This value can be either Incremental or Complete. In Incremental mode, resources are deployed without deleting existing resources that are not included in the template. In Complete mode, resources are deployed and existing resources in @@ -22,7 +21,8 @@ class DeploymentMode(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): INCREMENTAL = "Incremental" COMPLETE = "Complete" -class OnErrorDeploymentType(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): + +class OnErrorDeploymentType(str, Enum, metaclass=CaseInsensitiveEnumMeta): """The deployment on error behavior type. Possible values are LastSuccessful and SpecificDeployment. """ @@ -30,9 +30,9 @@ class OnErrorDeploymentType(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): LAST_SUCCESSFUL = "LastSuccessful" SPECIFIC_DEPLOYMENT = "SpecificDeployment" -class ResourceIdentityType(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): - """The identity type. - """ + +class ResourceIdentityType(str, Enum, metaclass=CaseInsensitiveEnumMeta): + """The identity type.""" SYSTEM_ASSIGNED = "SystemAssigned" USER_ASSIGNED = "UserAssigned" diff --git a/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/resources/v2018_02_01/operations/__init__.py b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/resources/v2018_02_01/operations/__init__.py index 45c6c8515ee40..25795ec366414 100644 --- a/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/resources/v2018_02_01/operations/__init__.py +++ b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/resources/v2018_02_01/operations/__init__.py @@ -13,11 +13,17 @@ from ._operations import TagsOperations from ._operations import DeploymentOperationsOperations +from ._patch import __all__ as _patch_all +from ._patch import * # type: ignore # pylint: disable=unused-wildcard-import +from ._patch import patch_sdk as _patch_sdk + __all__ = [ - 'DeploymentsOperations', - 'ProvidersOperations', - 'ResourcesOperations', - 'ResourceGroupsOperations', - 'TagsOperations', - 'DeploymentOperationsOperations', + "DeploymentsOperations", + "ProvidersOperations", + "ResourcesOperations", + "ResourceGroupsOperations", + "TagsOperations", + "DeploymentOperationsOperations", ] +__all__.extend([p for p in _patch_all if p not in __all__]) +_patch_sdk() diff --git a/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/resources/v2018_02_01/operations/_operations.py b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/resources/v2018_02_01/operations/_operations.py index 89060dc981d10..31c615743d594 100644 --- a/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/resources/v2018_02_01/operations/_operations.py +++ b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/resources/v2018_02_01/operations/_operations.py @@ -6,277 +6,275 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -from typing import Any, Callable, Dict, Iterable, Optional, TypeVar, Union - -from msrest import Serializer - -from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error +import sys +from typing import Any, Callable, Dict, IO, Iterable, Optional, TypeVar, Union, cast, overload +from urllib.parse import parse_qs, urljoin, urlparse + +from azure.core.exceptions import ( + ClientAuthenticationError, + HttpResponseError, + ResourceExistsError, + ResourceNotFoundError, + ResourceNotModifiedError, + map_error, +) from azure.core.paging import ItemPaged from azure.core.pipeline import PipelineResponse from azure.core.pipeline.transport import HttpResponse from azure.core.polling import LROPoller, NoPolling, PollingMethod from azure.core.rest import HttpRequest from azure.core.tracing.decorator import distributed_trace +from azure.core.utils import case_insensitive_dict from azure.mgmt.core.exceptions import ARMErrorFormat from azure.mgmt.core.polling.arm_polling import ARMPolling from .. import models as _models +from ..._serialization import Serializer from .._vendor import _convert_request, _format_url_section -T = TypeVar('T') -JSONType = Any + +if sys.version_info >= (3, 9): + from collections.abc import MutableMapping +else: + from typing import MutableMapping # type: ignore # pylint: disable=ungrouped-imports +JSON = MutableMapping[str, Any] # pylint: disable=unsubscriptable-object +T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] _SERIALIZER = Serializer() _SERIALIZER.client_side_validation = False -def build_deployments_delete_request_initial( - resource_group_name: str, - deployment_name: str, - subscription_id: str, - **kwargs: Any + +def build_deployments_delete_request( + resource_group_name: str, deployment_name: str, subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2018-02-01") # type: str + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + api_version = kwargs.pop("api_version", _params.pop("api-version", "2018-02-01")) # type: str # Construct URL - _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/Microsoft.Resources/deployments/{deploymentName}") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/Microsoft.Resources/deployments/{deploymentName}", + ) # pylint: disable=line-too-long path_format_arguments = { - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._\(\)]+$'), - "deploymentName": _SERIALIZER.url("deployment_name", deployment_name, 'str', max_length=64, min_length=1, pattern=r'^[-\w\._\(\)]+$'), - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), + "resourceGroupName": _SERIALIZER.url( + "resource_group_name", resource_group_name, "str", max_length=90, min_length=1, pattern=r"^[-\w\._\(\)]+$" + ), + "deploymentName": _SERIALIZER.url( + "deployment_name", deployment_name, "str", max_length=64, min_length=1, pattern=r"^[-\w\._\(\)]+$" + ), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), } _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') - - return HttpRequest( - method="DELETE", - url=_url, - params=_query_parameters, - **kwargs - ) + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") + + return HttpRequest(method="DELETE", url=_url, params=_params, **kwargs) def build_deployments_check_existence_request( - resource_group_name: str, - deployment_name: str, - subscription_id: str, - **kwargs: Any + resource_group_name: str, deployment_name: str, subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2018-02-01") # type: str + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + api_version = kwargs.pop("api_version", _params.pop("api-version", "2018-02-01")) # type: str # Construct URL - _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/Microsoft.Resources/deployments/{deploymentName}") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/Microsoft.Resources/deployments/{deploymentName}", + ) # pylint: disable=line-too-long path_format_arguments = { - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._\(\)]+$'), - "deploymentName": _SERIALIZER.url("deployment_name", deployment_name, 'str', max_length=64, min_length=1, pattern=r'^[-\w\._\(\)]+$'), - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), + "resourceGroupName": _SERIALIZER.url( + "resource_group_name", resource_group_name, "str", max_length=90, min_length=1, pattern=r"^[-\w\._\(\)]+$" + ), + "deploymentName": _SERIALIZER.url( + "deployment_name", deployment_name, "str", max_length=64, min_length=1, pattern=r"^[-\w\._\(\)]+$" + ), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), } _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') - - return HttpRequest( - method="HEAD", - url=_url, - params=_query_parameters, - **kwargs - ) + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") + return HttpRequest(method="HEAD", url=_url, params=_params, **kwargs) -def build_deployments_create_or_update_request_initial( - resource_group_name: str, - deployment_name: str, - subscription_id: str, - *, - json: JSONType = None, - content: Any = None, - **kwargs: Any + +def build_deployments_create_or_update_request( + resource_group_name: str, deployment_name: str, subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2018-02-01") # type: str - content_type = kwargs.pop('content_type', None) # type: Optional[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", "2018-02-01")) # type: str + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + accept = _headers.pop("Accept", "application/json") - accept = "application/json" # Construct URL - _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/Microsoft.Resources/deployments/{deploymentName}") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/Microsoft.Resources/deployments/{deploymentName}", + ) # pylint: disable=line-too-long path_format_arguments = { - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._\(\)]+$'), - "deploymentName": _SERIALIZER.url("deployment_name", deployment_name, 'str', max_length=64, min_length=1, pattern=r'^[-\w\._\(\)]+$'), - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), + "resourceGroupName": _SERIALIZER.url( + "resource_group_name", resource_group_name, "str", max_length=90, min_length=1, pattern=r"^[-\w\._\(\)]+$" + ), + "deploymentName": _SERIALIZER.url( + "deployment_name", deployment_name, "str", max_length=64, min_length=1, pattern=r"^[-\w\._\(\)]+$" + ), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), } _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] if content_type is not None: - _header_parameters['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') - _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') - - return HttpRequest( - method="PUT", - url=_url, - params=_query_parameters, - headers=_header_parameters, - json=json, - content=content, - **kwargs - ) + _headers["Content-Type"] = _SERIALIZER.header("content_type", content_type, "str") + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="PUT", url=_url, params=_params, headers=_headers, **kwargs) def build_deployments_get_request( - resource_group_name: str, - deployment_name: str, - subscription_id: str, - **kwargs: Any + resource_group_name: str, deployment_name: str, subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2018-02-01") # type: 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", "2018-02-01")) # type: str + accept = _headers.pop("Accept", "application/json") - accept = "application/json" # Construct URL - _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/Microsoft.Resources/deployments/{deploymentName}") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/Microsoft.Resources/deployments/{deploymentName}", + ) # pylint: disable=line-too-long path_format_arguments = { - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._\(\)]+$'), - "deploymentName": _SERIALIZER.url("deployment_name", deployment_name, 'str', max_length=64, min_length=1, pattern=r'^[-\w\._\(\)]+$'), - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), + "resourceGroupName": _SERIALIZER.url( + "resource_group_name", resource_group_name, "str", max_length=90, min_length=1, pattern=r"^[-\w\._\(\)]+$" + ), + "deploymentName": _SERIALIZER.url( + "deployment_name", deployment_name, "str", max_length=64, min_length=1, pattern=r"^[-\w\._\(\)]+$" + ), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), } _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') - - return HttpRequest( - method="GET", - url=_url, - params=_query_parameters, - headers=_header_parameters, - **kwargs - ) + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) def build_deployments_cancel_request( - resource_group_name: str, - deployment_name: str, - subscription_id: str, - **kwargs: Any + resource_group_name: str, deployment_name: str, subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2018-02-01") # type: str + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + api_version = kwargs.pop("api_version", _params.pop("api-version", "2018-02-01")) # type: str # Construct URL - _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/Microsoft.Resources/deployments/{deploymentName}/cancel") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/Microsoft.Resources/deployments/{deploymentName}/cancel", + ) # pylint: disable=line-too-long path_format_arguments = { - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._\(\)]+$'), - "deploymentName": _SERIALIZER.url("deployment_name", deployment_name, 'str', max_length=64, min_length=1, pattern=r'^[-\w\._\(\)]+$'), - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), + "resourceGroupName": _SERIALIZER.url( + "resource_group_name", resource_group_name, "str", max_length=90, min_length=1, pattern=r"^[-\w\._\(\)]+$" + ), + "deploymentName": _SERIALIZER.url( + "deployment_name", deployment_name, "str", max_length=64, min_length=1, pattern=r"^[-\w\._\(\)]+$" + ), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), } _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') - - return HttpRequest( - method="POST", - url=_url, - params=_query_parameters, - **kwargs - ) + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") + + return HttpRequest(method="POST", url=_url, params=_params, **kwargs) def build_deployments_validate_request( - resource_group_name: str, - deployment_name: str, - subscription_id: str, - *, - json: JSONType = None, - content: Any = None, - **kwargs: Any + resource_group_name: str, deployment_name: str, subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2018-02-01") # type: str - content_type = kwargs.pop('content_type', None) # type: Optional[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", "2018-02-01")) # type: str + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + accept = _headers.pop("Accept", "application/json") - accept = "application/json" # Construct URL - _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/Microsoft.Resources/deployments/{deploymentName}/validate") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/Microsoft.Resources/deployments/{deploymentName}/validate", + ) # pylint: disable=line-too-long path_format_arguments = { - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._\(\)]+$'), - "deploymentName": _SERIALIZER.url("deployment_name", deployment_name, 'str', max_length=64, min_length=1, pattern=r'^[-\w\._\(\)]+$'), - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), + "resourceGroupName": _SERIALIZER.url( + "resource_group_name", resource_group_name, "str", max_length=90, min_length=1, pattern=r"^[-\w\._\(\)]+$" + ), + "deploymentName": _SERIALIZER.url( + "deployment_name", deployment_name, "str", max_length=64, min_length=1, pattern=r"^[-\w\._\(\)]+$" + ), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), } _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] if content_type is not None: - _header_parameters['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') - _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') - - return HttpRequest( - method="POST", - url=_url, - params=_query_parameters, - headers=_header_parameters, - json=json, - content=content, - **kwargs - ) + _headers["Content-Type"] = _SERIALIZER.header("content_type", content_type, "str") + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="POST", url=_url, params=_params, headers=_headers, **kwargs) def build_deployments_export_template_request( - resource_group_name: str, - deployment_name: str, - subscription_id: str, - **kwargs: Any + resource_group_name: str, deployment_name: str, subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2018-02-01") # type: 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", "2018-02-01")) # type: str + accept = _headers.pop("Accept", "application/json") - accept = "application/json" # Construct URL - _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/Microsoft.Resources/deployments/{deploymentName}/exportTemplate") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/Microsoft.Resources/deployments/{deploymentName}/exportTemplate", + ) # pylint: disable=line-too-long path_format_arguments = { - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._\(\)]+$'), - "deploymentName": _SERIALIZER.url("deployment_name", deployment_name, 'str', max_length=64, min_length=1, pattern=r'^[-\w\._\(\)]+$'), - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), + "resourceGroupName": _SERIALIZER.url( + "resource_group_name", resource_group_name, "str", max_length=90, min_length=1, pattern=r"^[-\w\._\(\)]+$" + ), + "deploymentName": _SERIALIZER.url( + "deployment_name", deployment_name, "str", max_length=64, min_length=1, pattern=r"^[-\w\._\(\)]+$" + ), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), } _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') - - return HttpRequest( - method="POST", - url=_url, - params=_query_parameters, - headers=_header_parameters, - **kwargs - ) + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="POST", url=_url, params=_params, headers=_headers, **kwargs) def build_deployments_list_by_resource_group_request( @@ -287,216 +285,174 @@ def build_deployments_list_by_resource_group_request( top: Optional[int] = None, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2018-02-01") # type: 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", "2018-02-01")) # type: str + accept = _headers.pop("Accept", "application/json") - accept = "application/json" # Construct URL - _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/Microsoft.Resources/deployments/") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/Microsoft.Resources/deployments/", + ) # pylint: disable=line-too-long path_format_arguments = { - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._\(\)]+$'), - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), + "resourceGroupName": _SERIALIZER.url( + "resource_group_name", resource_group_name, "str", max_length=90, min_length=1, pattern=r"^[-\w\._\(\)]+$" + ), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), } _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] if filter is not None: - _query_parameters['$filter'] = _SERIALIZER.query("filter", filter, 'str') + _params["$filter"] = _SERIALIZER.query("filter", filter, "str") if top is not None: - _query_parameters['$top'] = _SERIALIZER.query("top", top, 'int') - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["$top"] = _SERIALIZER.query("top", top, "int") + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') - - return HttpRequest( - method="GET", - url=_url, - params=_query_parameters, - headers=_header_parameters, - **kwargs - ) + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) -def build_deployments_calculate_template_hash_request( - *, - json: JSONType = None, - content: Any = None, - **kwargs: Any -) -> HttpRequest: - api_version = kwargs.pop('api_version', "2018-02-01") # type: str - content_type = kwargs.pop('content_type', None) # type: Optional[str] - accept = "application/json" +def build_deployments_calculate_template_hash_request(*, json: JSON, **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", "2018-02-01")) # type: str + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + accept = _headers.pop("Accept", "application/json") + # Construct URL _url = kwargs.pop("template_url", "/providers/Microsoft.Resources/calculateTemplateHash") # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] if content_type is not None: - _header_parameters['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') - _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') - - return HttpRequest( - method="POST", - url=_url, - params=_query_parameters, - headers=_header_parameters, - json=json, - content=content, - **kwargs - ) + _headers["Content-Type"] = _SERIALIZER.header("content_type", content_type, "str") + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="POST", url=_url, params=_params, headers=_headers, json=json, **kwargs) def build_providers_unregister_request( - resource_provider_namespace: str, - subscription_id: str, - **kwargs: Any + resource_provider_namespace: str, subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2018-02-01") # type: 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", "2018-02-01")) # type: str + accept = _headers.pop("Accept", "application/json") - accept = "application/json" # Construct URL - _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/providers/{resourceProviderNamespace}/unregister") + _url = kwargs.pop( + "template_url", "/subscriptions/{subscriptionId}/providers/{resourceProviderNamespace}/unregister" + ) path_format_arguments = { - "resourceProviderNamespace": _SERIALIZER.url("resource_provider_namespace", resource_provider_namespace, 'str'), - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), + "resourceProviderNamespace": _SERIALIZER.url("resource_provider_namespace", resource_provider_namespace, "str"), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), } _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') - - return HttpRequest( - method="POST", - url=_url, - params=_query_parameters, - headers=_header_parameters, - **kwargs - ) + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="POST", url=_url, params=_params, headers=_headers, **kwargs) def build_providers_register_request( - resource_provider_namespace: str, - subscription_id: str, - **kwargs: Any + resource_provider_namespace: str, subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2018-02-01") # type: 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", "2018-02-01")) # type: str + accept = _headers.pop("Accept", "application/json") - accept = "application/json" # Construct URL _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/providers/{resourceProviderNamespace}/register") path_format_arguments = { - "resourceProviderNamespace": _SERIALIZER.url("resource_provider_namespace", resource_provider_namespace, 'str'), - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), + "resourceProviderNamespace": _SERIALIZER.url("resource_provider_namespace", resource_provider_namespace, "str"), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), } _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') - - return HttpRequest( - method="POST", - url=_url, - params=_query_parameters, - headers=_header_parameters, - **kwargs - ) + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="POST", url=_url, params=_params, headers=_headers, **kwargs) def build_providers_list_request( - subscription_id: str, - *, - top: Optional[int] = None, - expand: Optional[str] = None, - **kwargs: Any + subscription_id: str, *, top: Optional[int] = None, expand: Optional[str] = None, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2018-02-01") # type: 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", "2018-02-01")) # type: str + accept = _headers.pop("Accept", "application/json") - accept = "application/json" # Construct URL _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/providers") path_format_arguments = { - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), } _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] if top is not None: - _query_parameters['$top'] = _SERIALIZER.query("top", top, 'int') + _params["$top"] = _SERIALIZER.query("top", top, "int") if expand is not None: - _query_parameters['$expand'] = _SERIALIZER.query("expand", expand, 'str') - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["$expand"] = _SERIALIZER.query("expand", expand, "str") + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') - - return HttpRequest( - method="GET", - url=_url, - params=_query_parameters, - headers=_header_parameters, - **kwargs - ) + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) def build_providers_get_request( - resource_provider_namespace: str, - subscription_id: str, - *, - expand: Optional[str] = None, - **kwargs: Any + resource_provider_namespace: str, subscription_id: str, *, expand: Optional[str] = None, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2018-02-01") # type: 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", "2018-02-01")) # type: str + accept = _headers.pop("Accept", "application/json") - accept = "application/json" # Construct URL _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/providers/{resourceProviderNamespace}") path_format_arguments = { - "resourceProviderNamespace": _SERIALIZER.url("resource_provider_namespace", resource_provider_namespace, 'str'), - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), + "resourceProviderNamespace": _SERIALIZER.url("resource_provider_namespace", resource_provider_namespace, "str"), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), } _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] if expand is not None: - _query_parameters['$expand'] = _SERIALIZER.query("expand", expand, 'str') - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["$expand"] = _SERIALIZER.query("expand", expand, "str") + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') - - return HttpRequest( - method="GET", - url=_url, - params=_query_parameters, - headers=_header_parameters, - **kwargs - ) + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) def build_resources_list_by_resource_group_request( @@ -508,119 +464,108 @@ def build_resources_list_by_resource_group_request( top: Optional[int] = None, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2018-02-01") # type: 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", "2018-02-01")) # type: str + accept = _headers.pop("Accept", "application/json") - accept = "application/json" # Construct URL _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/resources") path_format_arguments = { - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._\(\)]+$'), - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), + "resourceGroupName": _SERIALIZER.url( + "resource_group_name", resource_group_name, "str", max_length=90, min_length=1, pattern=r"^[-\w\._\(\)]+$" + ), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), } _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] if filter is not None: - _query_parameters['$filter'] = _SERIALIZER.query("filter", filter, 'str') + _params["$filter"] = _SERIALIZER.query("filter", filter, "str") if expand is not None: - _query_parameters['$expand'] = _SERIALIZER.query("expand", expand, 'str') + _params["$expand"] = _SERIALIZER.query("expand", expand, "str") if top is not None: - _query_parameters['$top'] = _SERIALIZER.query("top", top, 'int') - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["$top"] = _SERIALIZER.query("top", top, "int") + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') - - return HttpRequest( - method="GET", - url=_url, - params=_query_parameters, - headers=_header_parameters, - **kwargs - ) + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) -def build_resources_move_resources_request_initial( - source_resource_group_name: str, - subscription_id: str, - *, - json: JSONType = None, - content: Any = None, - **kwargs: Any + +def build_resources_move_resources_request( + source_resource_group_name: str, subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2018-02-01") # type: str - content_type = kwargs.pop('content_type', None) # type: Optional[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", "2018-02-01")) # type: str + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] # Construct URL - _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{sourceResourceGroupName}/moveResources") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", "/subscriptions/{subscriptionId}/resourceGroups/{sourceResourceGroupName}/moveResources" + ) # pylint: disable=line-too-long path_format_arguments = { - "sourceResourceGroupName": _SERIALIZER.url("source_resource_group_name", source_resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._\(\)]+$'), - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), + "sourceResourceGroupName": _SERIALIZER.url( + "source_resource_group_name", + source_resource_group_name, + "str", + max_length=90, + min_length=1, + pattern=r"^[-\w\._\(\)]+$", + ), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), } _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] if content_type is not None: - _header_parameters['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') - - return HttpRequest( - method="POST", - url=_url, - params=_query_parameters, - headers=_header_parameters, - json=json, - content=content, - **kwargs - ) + _headers["Content-Type"] = _SERIALIZER.header("content_type", content_type, "str") + return HttpRequest(method="POST", url=_url, params=_params, headers=_headers, **kwargs) -def build_resources_validate_move_resources_request_initial( - source_resource_group_name: str, - subscription_id: str, - *, - json: JSONType = None, - content: Any = None, - **kwargs: Any + +def build_resources_validate_move_resources_request( + source_resource_group_name: str, subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2018-02-01") # type: str - content_type = kwargs.pop('content_type', None) # type: Optional[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", "2018-02-01")) # type: str + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] # Construct URL - _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{sourceResourceGroupName}/validateMoveResources") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", "/subscriptions/{subscriptionId}/resourceGroups/{sourceResourceGroupName}/validateMoveResources" + ) # pylint: disable=line-too-long path_format_arguments = { - "sourceResourceGroupName": _SERIALIZER.url("source_resource_group_name", source_resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._\(\)]+$'), - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), + "sourceResourceGroupName": _SERIALIZER.url( + "source_resource_group_name", + source_resource_group_name, + "str", + max_length=90, + min_length=1, + pattern=r"^[-\w\._\(\)]+$", + ), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), } _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] if content_type is not None: - _header_parameters['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') - - return HttpRequest( - method="POST", - url=_url, - params=_query_parameters, - headers=_header_parameters, - json=json, - content=content, - **kwargs - ) + _headers["Content-Type"] = _SERIALIZER.header("content_type", content_type, "str") + + return HttpRequest(method="POST", url=_url, params=_params, headers=_headers, **kwargs) def build_resources_list_request( @@ -631,38 +576,33 @@ def build_resources_list_request( top: Optional[int] = None, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2018-02-01") # type: 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", "2018-02-01")) # type: str + accept = _headers.pop("Accept", "application/json") - accept = "application/json" # Construct URL _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resources") path_format_arguments = { - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), } _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] if filter is not None: - _query_parameters['$filter'] = _SERIALIZER.query("filter", filter, 'str') + _params["$filter"] = _SERIALIZER.query("filter", filter, "str") if expand is not None: - _query_parameters['$expand'] = _SERIALIZER.query("expand", expand, 'str') + _params["$expand"] = _SERIALIZER.query("expand", expand, "str") if top is not None: - _query_parameters['$top'] = _SERIALIZER.query("top", top, 'int') - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["$top"] = _SERIALIZER.query("top", top, "int") + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') - - return HttpRequest( - method="GET", - url=_url, - params=_query_parameters, - headers=_header_parameters, - **kwargs - ) + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) def build_resources_check_existence_request( @@ -676,32 +616,33 @@ def build_resources_check_existence_request( api_version: str, **kwargs: Any ) -> HttpRequest: + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + # Construct URL - _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{parentResourcePath}/{resourceType}/{resourceName}") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{parentResourcePath}/{resourceType}/{resourceName}", + ) # pylint: disable=line-too-long path_format_arguments = { - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._\(\)]+$'), - "resourceProviderNamespace": _SERIALIZER.url("resource_provider_namespace", resource_provider_namespace, 'str'), - "parentResourcePath": _SERIALIZER.url("parent_resource_path", parent_resource_path, 'str', skip_quote=True), - "resourceType": _SERIALIZER.url("resource_type", resource_type, 'str', skip_quote=True), - "resourceName": _SERIALIZER.url("resource_name", resource_name, 'str'), - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), + "resourceGroupName": _SERIALIZER.url( + "resource_group_name", resource_group_name, "str", max_length=90, min_length=1, pattern=r"^[-\w\._\(\)]+$" + ), + "resourceProviderNamespace": _SERIALIZER.url("resource_provider_namespace", resource_provider_namespace, "str"), + "parentResourcePath": _SERIALIZER.url("parent_resource_path", parent_resource_path, "str", skip_quote=True), + "resourceType": _SERIALIZER.url("resource_type", resource_type, "str", skip_quote=True), + "resourceName": _SERIALIZER.url("resource_name", resource_name, "str"), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), } _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') - - return HttpRequest( - method="HEAD", - url=_url, - params=_query_parameters, - **kwargs - ) + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") + + return HttpRequest(method="HEAD", url=_url, params=_params, **kwargs) -def build_resources_delete_request_initial( +def build_resources_delete_request( resource_group_name: str, resource_provider_namespace: str, parent_resource_path: str, @@ -712,32 +653,33 @@ def build_resources_delete_request_initial( api_version: str, **kwargs: Any ) -> HttpRequest: + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + # Construct URL - _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{parentResourcePath}/{resourceType}/{resourceName}") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{parentResourcePath}/{resourceType}/{resourceName}", + ) # pylint: disable=line-too-long path_format_arguments = { - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._\(\)]+$'), - "resourceProviderNamespace": _SERIALIZER.url("resource_provider_namespace", resource_provider_namespace, 'str'), - "parentResourcePath": _SERIALIZER.url("parent_resource_path", parent_resource_path, 'str', skip_quote=True), - "resourceType": _SERIALIZER.url("resource_type", resource_type, 'str', skip_quote=True), - "resourceName": _SERIALIZER.url("resource_name", resource_name, 'str'), - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), + "resourceGroupName": _SERIALIZER.url( + "resource_group_name", resource_group_name, "str", max_length=90, min_length=1, pattern=r"^[-\w\._\(\)]+$" + ), + "resourceProviderNamespace": _SERIALIZER.url("resource_provider_namespace", resource_provider_namespace, "str"), + "parentResourcePath": _SERIALIZER.url("parent_resource_path", parent_resource_path, "str", skip_quote=True), + "resourceType": _SERIALIZER.url("resource_type", resource_type, "str", skip_quote=True), + "resourceName": _SERIALIZER.url("resource_name", resource_name, "str"), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), } _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') - - return HttpRequest( - method="DELETE", - url=_url, - params=_query_parameters, - **kwargs - ) + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") + return HttpRequest(method="DELETE", url=_url, params=_params, **kwargs) -def build_resources_create_or_update_request_initial( + +def build_resources_create_or_update_request( resource_group_name: str, resource_provider_namespace: str, parent_resource_path: str, @@ -746,48 +688,44 @@ def build_resources_create_or_update_request_initial( subscription_id: str, *, api_version: str, - json: JSONType = None, - content: Any = None, **kwargs: Any ) -> HttpRequest: - content_type = kwargs.pop('content_type', None) # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + accept = _headers.pop("Accept", "application/json") - accept = "application/json" # Construct URL - _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{parentResourcePath}/{resourceType}/{resourceName}") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{parentResourcePath}/{resourceType}/{resourceName}", + ) # pylint: disable=line-too-long path_format_arguments = { - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._\(\)]+$'), - "resourceProviderNamespace": _SERIALIZER.url("resource_provider_namespace", resource_provider_namespace, 'str'), - "parentResourcePath": _SERIALIZER.url("parent_resource_path", parent_resource_path, 'str', skip_quote=True), - "resourceType": _SERIALIZER.url("resource_type", resource_type, 'str', skip_quote=True), - "resourceName": _SERIALIZER.url("resource_name", resource_name, 'str'), - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), + "resourceGroupName": _SERIALIZER.url( + "resource_group_name", resource_group_name, "str", max_length=90, min_length=1, pattern=r"^[-\w\._\(\)]+$" + ), + "resourceProviderNamespace": _SERIALIZER.url("resource_provider_namespace", resource_provider_namespace, "str"), + "parentResourcePath": _SERIALIZER.url("parent_resource_path", parent_resource_path, "str", skip_quote=True), + "resourceType": _SERIALIZER.url("resource_type", resource_type, "str", skip_quote=True), + "resourceName": _SERIALIZER.url("resource_name", resource_name, "str"), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), } _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] if content_type is not None: - _header_parameters['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') - _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') - - return HttpRequest( - method="PUT", - url=_url, - params=_query_parameters, - headers=_header_parameters, - json=json, - content=content, - **kwargs - ) + _headers["Content-Type"] = _SERIALIZER.header("content_type", content_type, "str") + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="PUT", url=_url, params=_params, headers=_headers, **kwargs) -def build_resources_update_request_initial( +def build_resources_update_request( resource_group_name: str, resource_provider_namespace: str, parent_resource_path: str, @@ -796,45 +734,41 @@ def build_resources_update_request_initial( subscription_id: str, *, api_version: str, - json: JSONType = None, - content: Any = None, **kwargs: Any ) -> HttpRequest: - content_type = kwargs.pop('content_type', None) # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + accept = _headers.pop("Accept", "application/json") - accept = "application/json" # Construct URL - _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{parentResourcePath}/{resourceType}/{resourceName}") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{parentResourcePath}/{resourceType}/{resourceName}", + ) # pylint: disable=line-too-long path_format_arguments = { - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._\(\)]+$'), - "resourceProviderNamespace": _SERIALIZER.url("resource_provider_namespace", resource_provider_namespace, 'str'), - "parentResourcePath": _SERIALIZER.url("parent_resource_path", parent_resource_path, 'str', skip_quote=True), - "resourceType": _SERIALIZER.url("resource_type", resource_type, 'str', skip_quote=True), - "resourceName": _SERIALIZER.url("resource_name", resource_name, 'str'), - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), + "resourceGroupName": _SERIALIZER.url( + "resource_group_name", resource_group_name, "str", max_length=90, min_length=1, pattern=r"^[-\w\._\(\)]+$" + ), + "resourceProviderNamespace": _SERIALIZER.url("resource_provider_namespace", resource_provider_namespace, "str"), + "parentResourcePath": _SERIALIZER.url("parent_resource_path", parent_resource_path, "str", skip_quote=True), + "resourceType": _SERIALIZER.url("resource_type", resource_type, "str", skip_quote=True), + "resourceName": _SERIALIZER.url("resource_name", resource_name, "str"), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), } _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] if content_type is not None: - _header_parameters['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') - _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') - - return HttpRequest( - method="PATCH", - url=_url, - params=_query_parameters, - headers=_header_parameters, - json=json, - content=content, - **kwargs - ) + _headers["Content-Type"] = _SERIALIZER.header("content_type", content_type, "str") + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="PATCH", url=_url, params=_params, headers=_headers, **kwargs) def build_resources_get_request( @@ -848,745 +782,585 @@ def build_resources_get_request( api_version: str, **kwargs: Any ) -> HttpRequest: - accept = "application/json" + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + accept = _headers.pop("Accept", "application/json") + # Construct URL - _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{parentResourcePath}/{resourceType}/{resourceName}") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{parentResourcePath}/{resourceType}/{resourceName}", + ) # pylint: disable=line-too-long path_format_arguments = { - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._\(\)]+$'), - "resourceProviderNamespace": _SERIALIZER.url("resource_provider_namespace", resource_provider_namespace, 'str'), - "parentResourcePath": _SERIALIZER.url("parent_resource_path", parent_resource_path, 'str', skip_quote=True), - "resourceType": _SERIALIZER.url("resource_type", resource_type, 'str', skip_quote=True), - "resourceName": _SERIALIZER.url("resource_name", resource_name, 'str'), - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), + "resourceGroupName": _SERIALIZER.url( + "resource_group_name", resource_group_name, "str", max_length=90, min_length=1, pattern=r"^[-\w\._\(\)]+$" + ), + "resourceProviderNamespace": _SERIALIZER.url("resource_provider_namespace", resource_provider_namespace, "str"), + "parentResourcePath": _SERIALIZER.url("parent_resource_path", parent_resource_path, "str", skip_quote=True), + "resourceType": _SERIALIZER.url("resource_type", resource_type, "str", skip_quote=True), + "resourceName": _SERIALIZER.url("resource_name", resource_name, "str"), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), } _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') - - return HttpRequest( - method="GET", - url=_url, - params=_query_parameters, - headers=_header_parameters, - **kwargs - ) + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) + + +def build_resources_check_existence_by_id_request(resource_id: str, *, api_version: str, **kwargs: Any) -> HttpRequest: + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) -def build_resources_check_existence_by_id_request( - resource_id: str, - *, - api_version: str, - **kwargs: Any -) -> HttpRequest: # Construct URL _url = kwargs.pop("template_url", "/{resourceId}") path_format_arguments = { - "resourceId": _SERIALIZER.url("resource_id", resource_id, 'str', skip_quote=True), + "resourceId": _SERIALIZER.url("resource_id", resource_id, "str", skip_quote=True), } _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') - - return HttpRequest( - method="HEAD", - url=_url, - params=_query_parameters, - **kwargs - ) + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") + return HttpRequest(method="HEAD", url=_url, params=_params, **kwargs) + + +def build_resources_delete_by_id_request(resource_id: str, *, api_version: str, **kwargs: Any) -> HttpRequest: + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) -def build_resources_delete_by_id_request_initial( - resource_id: str, - *, - api_version: str, - **kwargs: Any -) -> HttpRequest: # Construct URL _url = kwargs.pop("template_url", "/{resourceId}") path_format_arguments = { - "resourceId": _SERIALIZER.url("resource_id", resource_id, 'str', skip_quote=True), + "resourceId": _SERIALIZER.url("resource_id", resource_id, "str", skip_quote=True), } _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') - - return HttpRequest( - method="DELETE", - url=_url, - params=_query_parameters, - **kwargs - ) + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") + return HttpRequest(method="DELETE", url=_url, params=_params, **kwargs) -def build_resources_create_or_update_by_id_request_initial( - resource_id: str, - *, - api_version: str, - json: JSONType = None, - content: Any = None, - **kwargs: Any -) -> HttpRequest: - content_type = kwargs.pop('content_type', None) # type: Optional[str] - accept = "application/json" +def build_resources_create_or_update_by_id_request(resource_id: str, *, api_version: str, **kwargs: Any) -> HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + accept = _headers.pop("Accept", "application/json") + # Construct URL _url = kwargs.pop("template_url", "/{resourceId}") path_format_arguments = { - "resourceId": _SERIALIZER.url("resource_id", resource_id, 'str', skip_quote=True), + "resourceId": _SERIALIZER.url("resource_id", resource_id, "str", skip_quote=True), } _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] if content_type is not None: - _header_parameters['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') - _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') - - return HttpRequest( - method="PUT", - url=_url, - params=_query_parameters, - headers=_header_parameters, - json=json, - content=content, - **kwargs - ) + _headers["Content-Type"] = _SERIALIZER.header("content_type", content_type, "str") + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + return HttpRequest(method="PUT", url=_url, params=_params, headers=_headers, **kwargs) -def build_resources_update_by_id_request_initial( - resource_id: str, - *, - api_version: str, - json: JSONType = None, - content: Any = None, - **kwargs: Any -) -> HttpRequest: - content_type = kwargs.pop('content_type', None) # type: Optional[str] - accept = "application/json" +def build_resources_update_by_id_request(resource_id: str, *, api_version: str, **kwargs: Any) -> HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + accept = _headers.pop("Accept", "application/json") + # Construct URL _url = kwargs.pop("template_url", "/{resourceId}") path_format_arguments = { - "resourceId": _SERIALIZER.url("resource_id", resource_id, 'str', skip_quote=True), + "resourceId": _SERIALIZER.url("resource_id", resource_id, "str", skip_quote=True), } _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] if content_type is not None: - _header_parameters['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') - _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') - - return HttpRequest( - method="PATCH", - url=_url, - params=_query_parameters, - headers=_header_parameters, - json=json, - content=content, - **kwargs - ) + _headers["Content-Type"] = _SERIALIZER.header("content_type", content_type, "str") + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + return HttpRequest(method="PATCH", url=_url, params=_params, headers=_headers, **kwargs) + + +def build_resources_get_by_id_request(resource_id: str, *, api_version: str, **kwargs: Any) -> HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + accept = _headers.pop("Accept", "application/json") -def build_resources_get_by_id_request( - resource_id: str, - *, - api_version: str, - **kwargs: Any -) -> HttpRequest: - accept = "application/json" # Construct URL _url = kwargs.pop("template_url", "/{resourceId}") path_format_arguments = { - "resourceId": _SERIALIZER.url("resource_id", resource_id, 'str', skip_quote=True), + "resourceId": _SERIALIZER.url("resource_id", resource_id, "str", skip_quote=True), } _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') - - return HttpRequest( - method="GET", - url=_url, - params=_query_parameters, - headers=_header_parameters, - **kwargs - ) + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) def build_resource_groups_check_existence_request( - resource_group_name: str, - subscription_id: str, - **kwargs: Any + resource_group_name: str, subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2018-02-01") # type: str + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + api_version = kwargs.pop("api_version", _params.pop("api-version", "2018-02-01")) # type: str # Construct URL _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}") path_format_arguments = { - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._\(\)]+$'), - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), + "resourceGroupName": _SERIALIZER.url( + "resource_group_name", resource_group_name, "str", max_length=90, min_length=1, pattern=r"^[-\w\._\(\)]+$" + ), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), } _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') - - return HttpRequest( - method="HEAD", - url=_url, - params=_query_parameters, - **kwargs - ) + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") + + return HttpRequest(method="HEAD", url=_url, params=_params, **kwargs) def build_resource_groups_create_or_update_request( - resource_group_name: str, - subscription_id: str, - *, - json: JSONType = None, - content: Any = None, - **kwargs: Any + resource_group_name: str, subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2018-02-01") # type: str - content_type = kwargs.pop('content_type', None) # type: Optional[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", "2018-02-01")) # type: str + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + accept = _headers.pop("Accept", "application/json") - accept = "application/json" # Construct URL _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}") path_format_arguments = { - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._\(\)]+$'), - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), + "resourceGroupName": _SERIALIZER.url( + "resource_group_name", resource_group_name, "str", max_length=90, min_length=1, pattern=r"^[-\w\._\(\)]+$" + ), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), } _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] if content_type is not None: - _header_parameters['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') - _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') - - return HttpRequest( - method="PUT", - url=_url, - params=_query_parameters, - headers=_header_parameters, - json=json, - content=content, - **kwargs - ) + _headers["Content-Type"] = _SERIALIZER.header("content_type", content_type, "str") + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + return HttpRequest(method="PUT", url=_url, params=_params, headers=_headers, **kwargs) -def build_resource_groups_delete_request_initial( - resource_group_name: str, - subscription_id: str, - **kwargs: Any -) -> HttpRequest: - api_version = kwargs.pop('api_version', "2018-02-01") # type: str +def build_resource_groups_delete_request(resource_group_name: str, subscription_id: str, **kwargs: Any) -> HttpRequest: + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2018-02-01")) # type: str # Construct URL _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}") path_format_arguments = { - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._\(\)]+$'), - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), + "resourceGroupName": _SERIALIZER.url( + "resource_group_name", resource_group_name, "str", max_length=90, min_length=1, pattern=r"^[-\w\._\(\)]+$" + ), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), } _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') - - return HttpRequest( - method="DELETE", - url=_url, - params=_query_parameters, - **kwargs - ) + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") + return HttpRequest(method="DELETE", url=_url, params=_params, **kwargs) -def build_resource_groups_get_request( - resource_group_name: str, - subscription_id: str, - **kwargs: Any -) -> HttpRequest: - api_version = kwargs.pop('api_version', "2018-02-01") # type: str - accept = "application/json" +def build_resource_groups_get_request(resource_group_name: str, subscription_id: str, **kwargs: Any) -> HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2018-02-01")) # type: str + accept = _headers.pop("Accept", "application/json") + # Construct URL _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}") path_format_arguments = { - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._\(\)]+$'), - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), + "resourceGroupName": _SERIALIZER.url( + "resource_group_name", resource_group_name, "str", max_length=90, min_length=1, pattern=r"^[-\w\._\(\)]+$" + ), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), } _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') - - return HttpRequest( - method="GET", - url=_url, - params=_query_parameters, - headers=_header_parameters, - **kwargs - ) + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) -def build_resource_groups_update_request( - resource_group_name: str, - subscription_id: str, - *, - json: JSONType = None, - content: Any = None, - **kwargs: Any -) -> HttpRequest: - api_version = kwargs.pop('api_version', "2018-02-01") # type: str - content_type = kwargs.pop('content_type', None) # type: Optional[str] - accept = "application/json" +def build_resource_groups_update_request(resource_group_name: str, subscription_id: str, **kwargs: Any) -> HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2018-02-01")) # type: str + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + accept = _headers.pop("Accept", "application/json") + # Construct URL _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}") path_format_arguments = { - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._\(\)]+$'), - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), + "resourceGroupName": _SERIALIZER.url( + "resource_group_name", resource_group_name, "str", max_length=90, min_length=1, pattern=r"^[-\w\._\(\)]+$" + ), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), } _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] if content_type is not None: - _header_parameters['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') - _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') - - return HttpRequest( - method="PATCH", - url=_url, - params=_query_parameters, - headers=_header_parameters, - json=json, - content=content, - **kwargs - ) + _headers["Content-Type"] = _SERIALIZER.header("content_type", content_type, "str") + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="PATCH", url=_url, params=_params, headers=_headers, **kwargs) def build_resource_groups_export_template_request( - resource_group_name: str, - subscription_id: str, - *, - json: JSONType = None, - content: Any = None, - **kwargs: Any + resource_group_name: str, subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2018-02-01") # type: str - content_type = kwargs.pop('content_type', None) # type: Optional[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", "2018-02-01")) # type: str + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + accept = _headers.pop("Accept", "application/json") - accept = "application/json" # Construct URL - _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/exportTemplate") + _url = kwargs.pop( + "template_url", "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/exportTemplate" + ) path_format_arguments = { - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._\(\)]+$'), - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), + "resourceGroupName": _SERIALIZER.url( + "resource_group_name", resource_group_name, "str", max_length=90, min_length=1, pattern=r"^[-\w\._\(\)]+$" + ), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), } _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] if content_type is not None: - _header_parameters['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') - _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') - - return HttpRequest( - method="POST", - url=_url, - params=_query_parameters, - headers=_header_parameters, - json=json, - content=content, - **kwargs - ) + _headers["Content-Type"] = _SERIALIZER.header("content_type", content_type, "str") + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="POST", url=_url, params=_params, headers=_headers, **kwargs) def build_resource_groups_list_request( - subscription_id: str, - *, - filter: Optional[str] = None, - top: Optional[int] = None, - **kwargs: Any + subscription_id: str, *, filter: Optional[str] = None, top: Optional[int] = None, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2018-02-01") # type: 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", "2018-02-01")) # type: str + accept = _headers.pop("Accept", "application/json") - accept = "application/json" # Construct URL _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourcegroups") path_format_arguments = { - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), } _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] if filter is not None: - _query_parameters['$filter'] = _SERIALIZER.query("filter", filter, 'str') + _params["$filter"] = _SERIALIZER.query("filter", filter, "str") if top is not None: - _query_parameters['$top'] = _SERIALIZER.query("top", top, 'int') - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["$top"] = _SERIALIZER.query("top", top, "int") + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') - - return HttpRequest( - method="GET", - url=_url, - params=_query_parameters, - headers=_header_parameters, - **kwargs - ) + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) -def build_tags_delete_value_request( - tag_name: str, - tag_value: str, - subscription_id: str, - **kwargs: Any -) -> HttpRequest: - api_version = kwargs.pop('api_version', "2018-02-01") # type: str +def build_tags_delete_value_request(tag_name: str, tag_value: str, subscription_id: str, **kwargs: Any) -> HttpRequest: + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2018-02-01")) # type: str # Construct URL _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/tagNames/{tagName}/tagValues/{tagValue}") path_format_arguments = { - "tagName": _SERIALIZER.url("tag_name", tag_name, 'str'), - "tagValue": _SERIALIZER.url("tag_value", tag_value, 'str'), - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), + "tagName": _SERIALIZER.url("tag_name", tag_name, "str"), + "tagValue": _SERIALIZER.url("tag_value", tag_value, "str"), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), } _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') - - return HttpRequest( - method="DELETE", - url=_url, - params=_query_parameters, - **kwargs - ) + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") + + return HttpRequest(method="DELETE", url=_url, params=_params, **kwargs) def build_tags_create_or_update_value_request( - tag_name: str, - tag_value: str, - subscription_id: str, - **kwargs: Any + tag_name: str, tag_value: str, subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2018-02-01") # type: 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", "2018-02-01")) # type: str + accept = _headers.pop("Accept", "application/json") - accept = "application/json" # Construct URL _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/tagNames/{tagName}/tagValues/{tagValue}") path_format_arguments = { - "tagName": _SERIALIZER.url("tag_name", tag_name, 'str'), - "tagValue": _SERIALIZER.url("tag_value", tag_value, 'str'), - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), + "tagName": _SERIALIZER.url("tag_name", tag_name, "str"), + "tagValue": _SERIALIZER.url("tag_value", tag_value, "str"), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), } _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') - - return HttpRequest( - method="PUT", - url=_url, - params=_query_parameters, - headers=_header_parameters, - **kwargs - ) + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + return HttpRequest(method="PUT", url=_url, params=_params, headers=_headers, **kwargs) -def build_tags_create_or_update_request( - tag_name: str, - subscription_id: str, - **kwargs: Any -) -> HttpRequest: - api_version = kwargs.pop('api_version', "2018-02-01") # type: str - accept = "application/json" +def build_tags_create_or_update_request(tag_name: str, subscription_id: str, **kwargs: Any) -> HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2018-02-01")) # type: str + accept = _headers.pop("Accept", "application/json") + # Construct URL _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/tagNames/{tagName}") path_format_arguments = { - "tagName": _SERIALIZER.url("tag_name", tag_name, 'str'), - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), + "tagName": _SERIALIZER.url("tag_name", tag_name, "str"), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), } _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') - - return HttpRequest( - method="PUT", - url=_url, - params=_query_parameters, - headers=_header_parameters, - **kwargs - ) + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + return HttpRequest(method="PUT", url=_url, params=_params, headers=_headers, **kwargs) -def build_tags_delete_request( - tag_name: str, - subscription_id: str, - **kwargs: Any -) -> HttpRequest: - api_version = kwargs.pop('api_version', "2018-02-01") # type: str +def build_tags_delete_request(tag_name: str, subscription_id: str, **kwargs: Any) -> HttpRequest: + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2018-02-01")) # type: str # Construct URL _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/tagNames/{tagName}") path_format_arguments = { - "tagName": _SERIALIZER.url("tag_name", tag_name, 'str'), - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), + "tagName": _SERIALIZER.url("tag_name", tag_name, "str"), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), } _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') - - return HttpRequest( - method="DELETE", - url=_url, - params=_query_parameters, - **kwargs - ) + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") + return HttpRequest(method="DELETE", url=_url, params=_params, **kwargs) -def build_tags_list_request( - subscription_id: str, - **kwargs: Any -) -> HttpRequest: - api_version = kwargs.pop('api_version', "2018-02-01") # type: str - accept = "application/json" +def build_tags_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", "2018-02-01")) # type: str + accept = _headers.pop("Accept", "application/json") + # Construct URL _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/tagNames") path_format_arguments = { - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), } _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') - - return HttpRequest( - method="GET", - url=_url, - params=_query_parameters, - headers=_header_parameters, - **kwargs - ) + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) def build_deployment_operations_get_request( - resource_group_name: str, - deployment_name: str, - operation_id: str, - subscription_id: str, - **kwargs: Any + resource_group_name: str, deployment_name: str, operation_id: str, subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2018-02-01") # type: 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", "2018-02-01")) # type: str + accept = _headers.pop("Accept", "application/json") - accept = "application/json" # Construct URL - _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/deployments/{deploymentName}/operations/{operationId}") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/deployments/{deploymentName}/operations/{operationId}", + ) # pylint: disable=line-too-long path_format_arguments = { - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._\(\)]+$'), - "deploymentName": _SERIALIZER.url("deployment_name", deployment_name, 'str', max_length=64, min_length=1, pattern=r'^[-\w\._\(\)]+$'), - "operationId": _SERIALIZER.url("operation_id", operation_id, 'str'), - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), + "resourceGroupName": _SERIALIZER.url( + "resource_group_name", resource_group_name, "str", max_length=90, min_length=1, pattern=r"^[-\w\._\(\)]+$" + ), + "deploymentName": _SERIALIZER.url( + "deployment_name", deployment_name, "str", max_length=64, min_length=1, pattern=r"^[-\w\._\(\)]+$" + ), + "operationId": _SERIALIZER.url("operation_id", operation_id, "str"), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), } _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') - - return HttpRequest( - method="GET", - url=_url, - params=_query_parameters, - headers=_header_parameters, - **kwargs - ) + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) def build_deployment_operations_list_request( - resource_group_name: str, - deployment_name: str, - subscription_id: str, - *, - top: Optional[int] = None, - **kwargs: Any + resource_group_name: str, deployment_name: str, subscription_id: str, *, top: Optional[int] = None, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2018-02-01") # type: 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", "2018-02-01")) # type: str + accept = _headers.pop("Accept", "application/json") - accept = "application/json" # Construct URL - _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/deployments/{deploymentName}/operations") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/deployments/{deploymentName}/operations", + ) # pylint: disable=line-too-long path_format_arguments = { - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._\(\)]+$'), - "deploymentName": _SERIALIZER.url("deployment_name", deployment_name, 'str', max_length=64, min_length=1, pattern=r'^[-\w\._\(\)]+$'), - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), + "resourceGroupName": _SERIALIZER.url( + "resource_group_name", resource_group_name, "str", max_length=90, min_length=1, pattern=r"^[-\w\._\(\)]+$" + ), + "deploymentName": _SERIALIZER.url( + "deployment_name", deployment_name, "str", max_length=64, min_length=1, pattern=r"^[-\w\._\(\)]+$" + ), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), } _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] if top is not None: - _query_parameters['$top'] = _SERIALIZER.query("top", top, 'int') - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["$top"] = _SERIALIZER.query("top", top, "int") + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') - - return HttpRequest( - method="GET", - url=_url, - params=_query_parameters, - headers=_header_parameters, - **kwargs - ) + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") -class DeploymentsOperations(object): - """DeploymentsOperations operations. + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) - You should not instantiate this class directly. Instead, you should create a Client instance that - instantiates it for you and attaches it as an attribute. - :ivar models: Alias to model classes used in this operation group. - :type models: ~azure.mgmt.resource.resources.v2018_02_01.models - :param client: Client for service requests. - :param config: Configuration of service client. - :param serializer: An object model serializer. - :param deserializer: An object model deserializer. +class DeploymentsOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. + + Instead, you should access the following operations through + :class:`~azure.mgmt.resource.resources.v2018_02_01.ResourceManagementClient`'s + :attr:`deployments` attribute. """ models = _models - def __init__(self, client, config, serializer, deserializer): - self._client = client - self._serialize = serializer - self._deserialize = deserializer - self._config = config + def __init__(self, *args, **kwargs): + input_args = list(args) + self._client = input_args.pop(0) if input_args else kwargs.pop("client") + self._config = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") def _delete_initial( # pylint: disable=inconsistent-return-statements - self, - resource_group_name: str, - deployment_name: str, - **kwargs: Any + self, resource_group_name: str, deployment_name: str, **kwargs: Any ) -> None: - cls = kwargs.pop('cls', None) # type: ClsType[None] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) - api_version = kwargs.pop('api_version', "2018-02-01") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - request = build_deployments_delete_request_initial( + api_version = kwargs.pop("api_version", _params.pop("api-version", "2018-02-01")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[None] + + request = build_deployments_delete_request( resource_group_name=resource_group_name, deployment_name=deployment_name, subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self._delete_initial.metadata['url'], + template_url=self._delete_initial.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [202, 204]: @@ -1596,16 +1370,10 @@ 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.Resources/deployments/{deploymentName}"} # type: ignore - + _delete_initial.metadata = {"url": "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/Microsoft.Resources/deployments/{deploymentName}"} # type: ignore @distributed_trace - def begin_delete( # pylint: disable=inconsistent-return-statements - self, - resource_group_name: str, - deployment_name: str, - **kwargs: Any - ) -> LROPoller[None]: + def begin_delete(self, resource_group_name: str, deployment_name: str, **kwargs: Any) -> LROPoller[None]: """Deletes a deployment from the deployment history. A template deployment that is currently running cannot be deleted. Deleting a template @@ -1618,9 +1386,9 @@ def begin_delete( # pylint: disable=inconsistent-return-statements asynchronous request failed, the URI in the Location header returns an error-level status code. :param resource_group_name: The name of the resource group with the deployment to delete. The - name is case insensitive. + name is case insensitive. Required. :type resource_group_name: str - :param deployment_name: The name of the deployment to delete. + :param deployment_name: The name of the deployment to delete. Required. :type deployment_name: str :keyword callable cls: A custom type or function that will be passed the direct response :keyword str continuation_token: A continuation token to restart a poller from a saved state. @@ -1632,88 +1400,93 @@ def begin_delete( # pylint: disable=inconsistent-return-statements Retry-After header is present. :return: An instance of LROPoller that returns either None or the result of cls(response) :rtype: ~azure.core.polling.LROPoller[None] - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - api_version = kwargs.pop('api_version', "2018-02-01") # type: str - polling = kwargs.pop('polling', True) # type: Union[bool, PollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType[None] - lro_delay = kwargs.pop( - 'polling_interval', - self._config.polling_interval - ) - cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2018-02-01")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[None] + polling = kwargs.pop("polling", True) # type: Union[bool, PollingMethod] + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token = kwargs.pop("continuation_token", None) # type: Optional[str] if cont_token is None: - raw_result = self._delete_initial( + raw_result = self._delete_initial( # type: ignore resource_group_name=resource_group_name, deployment_name=deployment_name, api_version=api_version, - cls=lambda x,y,z: x, + cls=lambda x, y, z: x, + headers=_headers, + params=_params, **kwargs ) - kwargs.pop('error_map', None) + kwargs.pop("error_map", None) - def get_long_running_output(pipeline_response): + def get_long_running_output(pipeline_response): # pylint: disable=inconsistent-return-statements if cls: return cls(pipeline_response, None, {}) - - if polling is True: polling_method = ARMPolling(lro_delay, **kwargs) - elif polling is False: polling_method = NoPolling() - else: polling_method = polling + if polling is True: + polling_method = cast(PollingMethod, ARMPolling(lro_delay, **kwargs)) # type: PollingMethod + elif polling is False: + polling_method = cast(PollingMethod, NoPolling()) + else: + polling_method = polling if cont_token: return LROPoller.from_continuation_token( polling_method=polling_method, continuation_token=cont_token, client=self._client, - deserialization_callback=get_long_running_output + deserialization_callback=get_long_running_output, ) return LROPoller(self._client, raw_result, get_long_running_output, polling_method) - begin_delete.metadata = {'url': "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/Microsoft.Resources/deployments/{deploymentName}"} # type: ignore + begin_delete.metadata = {"url": "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/Microsoft.Resources/deployments/{deploymentName}"} # type: ignore @distributed_trace - def check_existence( - self, - resource_group_name: str, - deployment_name: str, - **kwargs: Any - ) -> bool: + def check_existence(self, resource_group_name: str, deployment_name: str, **kwargs: Any) -> bool: """Checks whether the deployment exists. :param resource_group_name: The name of the resource group with the deployment to check. The - name is case insensitive. + name is case insensitive. Required. :type resource_group_name: str - :param deployment_name: The name of the deployment to check. + :param deployment_name: The name of the deployment to check. Required. :type deployment_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: bool, or the result of cls(response) + :return: bool or the result of cls(response) :rtype: bool - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType[None] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + 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', "2018-02-01") # type: str + api_version = kwargs.pop("api_version", _params.pop("api-version", "2018-02-01")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[None] - request = build_deployments_check_existence_request( resource_group_name=resource_group_name, deployment_name=deployment_name, subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.check_existence.metadata['url'], + template_url=self.check_existence.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [204, 404]: @@ -1724,44 +1497,53 @@ def check_existence( return cls(pipeline_response, None, {}) return 200 <= response.status_code <= 299 - check_existence.metadata = {'url': "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/Microsoft.Resources/deployments/{deploymentName}"} # type: ignore - + check_existence.metadata = {"url": "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/Microsoft.Resources/deployments/{deploymentName}"} # type: ignore def _create_or_update_initial( - self, - resource_group_name: str, - deployment_name: str, - parameters: "_models.Deployment", - **kwargs: Any - ) -> "_models.DeploymentExtended": - cls = kwargs.pop('cls', None) # type: ClsType["_models.DeploymentExtended"] + self, resource_group_name: str, deployment_name: str, parameters: Union[_models.Deployment, IO], **kwargs: Any + ) -> _models.DeploymentExtended: error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) - api_version = kwargs.pop('api_version', "2018-02-01") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - _json = self._serialize.body(parameters, 'Deployment') + api_version = kwargs.pop("api_version", _params.pop("api-version", "2018-02-01")) # type: str + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.DeploymentExtended] - request = build_deployments_create_or_update_request_initial( + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(parameters, (IO, bytes)): + _content = parameters + else: + _json = self._serialize.body(parameters, "Deployment") + + request = build_deployments_create_or_update_request( resource_group_name=resource_group_name, deployment_name=deployment_name, subscription_id=self._config.subscription_id, api_version=api_version, content_type=content_type, json=_json, - template_url=self._create_or_update_initial.metadata['url'], + content=_content, + template_url=self._create_or_update_initial.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200, 201]: @@ -1769,38 +1551,42 @@ def _create_or_update_initial( raise HttpResponseError(response=response, error_format=ARMErrorFormat) if response.status_code == 200: - deserialized = self._deserialize('DeploymentExtended', pipeline_response) + deserialized = self._deserialize("DeploymentExtended", pipeline_response) if response.status_code == 201: - deserialized = self._deserialize('DeploymentExtended', pipeline_response) + deserialized = self._deserialize("DeploymentExtended", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - _create_or_update_initial.metadata = {'url': "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/Microsoft.Resources/deployments/{deploymentName}"} # type: ignore + _create_or_update_initial.metadata = {"url": "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/Microsoft.Resources/deployments/{deploymentName}"} # type: ignore - - @distributed_trace + @overload def begin_create_or_update( self, resource_group_name: str, deployment_name: str, - parameters: "_models.Deployment", + parameters: _models.Deployment, + *, + content_type: str = "application/json", **kwargs: Any - ) -> LROPoller["_models.DeploymentExtended"]: + ) -> LROPoller[_models.DeploymentExtended]: """Deploys resources to a resource group. You can provide the template and parameters directly in the request or link to JSON files. :param resource_group_name: The name of the resource group to deploy the resources to. The name - is case insensitive. The resource group must already exist. + is case insensitive. The resource group must already exist. Required. :type resource_group_name: str - :param deployment_name: The name of the deployment. + :param deployment_name: The name of the deployment. Required. :type deployment_name: str - :param parameters: Additional parameters supplied to the operation. + :param parameters: Additional parameters supplied to the operation. Required. :type parameters: ~azure.mgmt.resource.resources.v2018_02_01.models.Deployment + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str :keyword callable cls: A custom type or function that will be passed the direct response :keyword str continuation_token: A continuation token to restart a poller from a saved state. :keyword polling: By default, your polling method will be ARMPolling. Pass in False for this @@ -1813,115 +1599,189 @@ def begin_create_or_update( cls(response) :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.resource.resources.v2018_02_01.models.DeploymentExtended] - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - api_version = kwargs.pop('api_version', "2018-02-01") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] - polling = kwargs.pop('polling', True) # type: Union[bool, PollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType["_models.DeploymentExtended"] - lro_delay = kwargs.pop( - 'polling_interval', - self._config.polling_interval - ) - cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] + + @overload + def begin_create_or_update( + self, + resource_group_name: str, + deployment_name: str, + parameters: IO, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> LROPoller[_models.DeploymentExtended]: + """Deploys resources to a resource group. + + You can provide the template and parameters directly in the request or link to JSON files. + + :param resource_group_name: The name of the resource group to deploy the resources to. The name + is case insensitive. The resource group must already exist. Required. + :type resource_group_name: str + :param deployment_name: The name of the deployment. Required. + :type deployment_name: str + :param parameters: Additional parameters supplied to the operation. Required. + :type parameters: IO + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be ARMPolling. Pass in False for this + operation to not poll, or pass in your own initialized polling object for a personal polling + strategy. + :paramtype polling: bool or ~azure.core.polling.PollingMethod + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of LROPoller that returns either DeploymentExtended or the result of + cls(response) + :rtype: + ~azure.core.polling.LROPoller[~azure.mgmt.resource.resources.v2018_02_01.models.DeploymentExtended] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace + def begin_create_or_update( + self, resource_group_name: str, deployment_name: str, parameters: Union[_models.Deployment, IO], **kwargs: Any + ) -> LROPoller[_models.DeploymentExtended]: + """Deploys resources to a resource group. + + You can provide the template and parameters directly in the request or link to JSON files. + + :param resource_group_name: The name of the resource group to deploy the resources to. The name + is case insensitive. The resource group must already exist. Required. + :type resource_group_name: str + :param deployment_name: The name of the deployment. Required. + :type deployment_name: str + :param parameters: Additional parameters supplied to the operation. Is either a model type or a + IO type. Required. + :type parameters: ~azure.mgmt.resource.resources.v2018_02_01.models.Deployment or IO + :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. + Default value is None. + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be ARMPolling. Pass in False for this + operation to not poll, or pass in your own initialized polling object for a personal polling + strategy. + :paramtype polling: bool or ~azure.core.polling.PollingMethod + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of LROPoller that returns either DeploymentExtended or the result of + cls(response) + :rtype: + ~azure.core.polling.LROPoller[~azure.mgmt.resource.resources.v2018_02_01.models.DeploymentExtended] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _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", "2018-02-01")) # type: str + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.DeploymentExtended] + polling = kwargs.pop("polling", True) # type: Union[bool, PollingMethod] + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token = kwargs.pop("continuation_token", None) # type: Optional[str] if cont_token is None: - raw_result = self._create_or_update_initial( + raw_result = self._create_or_update_initial( # type: ignore resource_group_name=resource_group_name, deployment_name=deployment_name, parameters=parameters, api_version=api_version, content_type=content_type, - cls=lambda x,y,z: x, + cls=lambda x, y, z: x, + headers=_headers, + params=_params, **kwargs ) - kwargs.pop('error_map', None) + kwargs.pop("error_map", None) def get_long_running_output(pipeline_response): - response = pipeline_response.http_response - deserialized = self._deserialize('DeploymentExtended', pipeline_response) + deserialized = self._deserialize("DeploymentExtended", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - - if polling is True: polling_method = ARMPolling(lro_delay, **kwargs) - elif polling is False: polling_method = NoPolling() - else: polling_method = polling + if polling is True: + polling_method = cast(PollingMethod, ARMPolling(lro_delay, **kwargs)) # type: PollingMethod + elif polling is False: + polling_method = cast(PollingMethod, NoPolling()) + else: + polling_method = polling if cont_token: return LROPoller.from_continuation_token( polling_method=polling_method, continuation_token=cont_token, client=self._client, - deserialization_callback=get_long_running_output + deserialization_callback=get_long_running_output, ) return LROPoller(self._client, raw_result, get_long_running_output, polling_method) - begin_create_or_update.metadata = {'url': "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/Microsoft.Resources/deployments/{deploymentName}"} # type: ignore + begin_create_or_update.metadata = {"url": "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/Microsoft.Resources/deployments/{deploymentName}"} # type: ignore @distributed_trace - def get( - self, - resource_group_name: str, - deployment_name: str, - **kwargs: Any - ) -> "_models.DeploymentExtended": + def get(self, resource_group_name: str, deployment_name: str, **kwargs: Any) -> _models.DeploymentExtended: """Gets a deployment. :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. :type resource_group_name: str - :param deployment_name: The name of the deployment to get. + :param deployment_name: The name of the deployment to get. Required. :type deployment_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: DeploymentExtended, or the result of cls(response) + :return: DeploymentExtended or the result of cls(response) :rtype: ~azure.mgmt.resource.resources.v2018_02_01.models.DeploymentExtended - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.DeploymentExtended"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) - api_version = kwargs.pop('api_version', "2018-02-01") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2018-02-01")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[_models.DeploymentExtended] - request = build_deployments_get_request( resource_group_name=resource_group_name, deployment_name=deployment_name, subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.get.metadata['url'], + template_url=self.get.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) - deserialized = self._deserialize('DeploymentExtended', pipeline_response) + deserialized = self._deserialize("DeploymentExtended", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - get.metadata = {'url': "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/Microsoft.Resources/deployments/{deploymentName}"} # type: ignore - + get.metadata = {"url": "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/Microsoft.Resources/deployments/{deploymentName}"} # type: ignore @distributed_trace def cancel( # pylint: disable=inconsistent-return-statements - self, - resource_group_name: str, - deployment_name: str, - **kwargs: Any + self, resource_group_name: str, deployment_name: str, **kwargs: Any ) -> None: """Cancels a currently running template deployment. @@ -1931,38 +1791,45 @@ def cancel( # pylint: disable=inconsistent-return-statements partially deployed. :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. :type resource_group_name: str - :param deployment_name: The name of the deployment to cancel. + :param deployment_name: The name of the deployment to cancel. Required. :type deployment_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: None, or the result of cls(response) + :return: None or the result of cls(response) :rtype: None - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType[None] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + 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', "2018-02-01") # type: str + api_version = kwargs.pop("api_version", _params.pop("api-version", "2018-02-01")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[None] - request = build_deployments_cancel_request( resource_group_name=resource_group_name, deployment_name=deployment_name, subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.cancel.metadata['url'], + template_url=self.cancel.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [204]: @@ -1972,42 +1839,110 @@ def cancel( # pylint: disable=inconsistent-return-statements if cls: return cls(pipeline_response, None, {}) - cancel.metadata = {'url': "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/Microsoft.Resources/deployments/{deploymentName}/cancel"} # type: ignore - + cancel.metadata = {"url": "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/Microsoft.Resources/deployments/{deploymentName}/cancel"} # type: ignore - @distributed_trace + @overload def validate( self, resource_group_name: str, deployment_name: str, - parameters: "_models.Deployment", + parameters: _models.Deployment, + *, + content_type: str = "application/json", **kwargs: Any - ) -> "_models.DeploymentValidateResult": + ) -> _models.DeploymentValidateResult: """Validates whether the specified template is syntactically correct and will be accepted by Azure Resource Manager.. :param resource_group_name: The name of the resource group the template will be deployed to. - The name is case insensitive. + The name is case insensitive. Required. :type resource_group_name: str - :param deployment_name: The name of the deployment. + :param deployment_name: The name of the deployment. Required. :type deployment_name: str - :param parameters: Parameters to validate. + :param parameters: Parameters to validate. Required. :type parameters: ~azure.mgmt.resource.resources.v2018_02_01.models.Deployment + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: DeploymentValidateResult or the result of cls(response) + :rtype: ~azure.mgmt.resource.resources.v2018_02_01.models.DeploymentValidateResult + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + def validate( + self, + resource_group_name: str, + deployment_name: str, + parameters: IO, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.DeploymentValidateResult: + """Validates whether the specified template is syntactically correct and will be accepted by Azure + Resource Manager.. + + :param resource_group_name: The name of the resource group the template will be deployed to. + The name is case insensitive. Required. + :type resource_group_name: str + :param deployment_name: The name of the deployment. Required. + :type deployment_name: str + :param parameters: Parameters to validate. Required. + :type parameters: IO + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: DeploymentValidateResult or the result of cls(response) + :rtype: ~azure.mgmt.resource.resources.v2018_02_01.models.DeploymentValidateResult + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace + def validate( + self, resource_group_name: str, deployment_name: str, parameters: Union[_models.Deployment, IO], **kwargs: Any + ) -> _models.DeploymentValidateResult: + """Validates whether the specified template is syntactically correct and will be accepted by Azure + Resource Manager.. + + :param resource_group_name: The name of the resource group the template will be deployed to. + The name is case insensitive. Required. + :type resource_group_name: str + :param deployment_name: The name of the deployment. Required. + :type deployment_name: str + :param parameters: Parameters to validate. Is either a model type or a IO type. Required. + :type parameters: ~azure.mgmt.resource.resources.v2018_02_01.models.Deployment or IO + :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. + Default value is None. + :paramtype content_type: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: DeploymentValidateResult, or the result of cls(response) + :return: DeploymentValidateResult or the result of cls(response) :rtype: ~azure.mgmt.resource.resources.v2018_02_01.models.DeploymentValidateResult - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.DeploymentValidateResult"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', "2018-02-01") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + api_version = kwargs.pop("api_version", _params.pop("api-version", "2018-02-01")) # type: str + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.DeploymentValidateResult] - _json = self._serialize.body(parameters, 'Deployment') + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(parameters, (IO, bytes)): + _content = parameters + else: + _json = self._serialize.body(parameters, "Deployment") request = build_deployments_validate_request( resource_group_name=resource_group_name, @@ -2016,16 +1951,18 @@ def validate( api_version=api_version, content_type=content_type, json=_json, - template_url=self.validate.metadata['url'], + content=_content, + template_url=self.validate.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200, 400]: @@ -2033,89 +1970,87 @@ def validate( raise HttpResponseError(response=response, error_format=ARMErrorFormat) if response.status_code == 200: - deserialized = self._deserialize('DeploymentValidateResult', pipeline_response) + deserialized = self._deserialize("DeploymentValidateResult", pipeline_response) if response.status_code == 400: - deserialized = self._deserialize('DeploymentValidateResult', pipeline_response) + deserialized = self._deserialize("DeploymentValidateResult", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - validate.metadata = {'url': "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/Microsoft.Resources/deployments/{deploymentName}/validate"} # type: ignore - + validate.metadata = {"url": "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/Microsoft.Resources/deployments/{deploymentName}/validate"} # type: ignore @distributed_trace def export_template( - self, - resource_group_name: str, - deployment_name: str, - **kwargs: Any - ) -> "_models.DeploymentExportResult": + self, resource_group_name: str, deployment_name: str, **kwargs: Any + ) -> _models.DeploymentExportResult: """Exports the template used for specified deployment. :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. :type resource_group_name: str - :param deployment_name: The name of the deployment from which to get the template. + :param deployment_name: The name of the deployment from which to get the template. Required. :type deployment_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: DeploymentExportResult, or the result of cls(response) + :return: DeploymentExportResult or the result of cls(response) :rtype: ~azure.mgmt.resource.resources.v2018_02_01.models.DeploymentExportResult - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.DeploymentExportResult"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) - api_version = kwargs.pop('api_version', "2018-02-01") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2018-02-01")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[_models.DeploymentExportResult] - request = build_deployments_export_template_request( resource_group_name=resource_group_name, deployment_name=deployment_name, subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.export_template.metadata['url'], + template_url=self.export_template.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) - deserialized = self._deserialize('DeploymentExportResult', pipeline_response) + deserialized = self._deserialize("DeploymentExportResult", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - export_template.metadata = {'url': "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/Microsoft.Resources/deployments/{deploymentName}/exportTemplate"} # type: ignore - + export_template.metadata = {"url": "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/Microsoft.Resources/deployments/{deploymentName}/exportTemplate"} # type: ignore @distributed_trace def list_by_resource_group( - self, - resource_group_name: str, - filter: Optional[str] = None, - top: Optional[int] = None, - **kwargs: Any - ) -> Iterable["_models.DeploymentListResult"]: + self, resource_group_name: str, filter: Optional[str] = None, top: Optional[int] = None, **kwargs: Any + ) -> Iterable["_models.DeploymentExtended"]: """Get all the deployments for a resource group. :param resource_group_name: The name of the resource group with the deployments to get. The - name is case insensitive. + name is case insensitive. Required. :type resource_group_name: str :param filter: The filter to apply on the operation. For example, you can use $filter=provisioningState eq '{state}'. Default value is None. @@ -2124,42 +2059,49 @@ def list_by_resource_group( value is None. :type top: int :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either DeploymentListResult or the result of - cls(response) + :return: An iterator like instance of either DeploymentExtended or the result of cls(response) :rtype: - ~azure.core.paging.ItemPaged[~azure.mgmt.resource.resources.v2018_02_01.models.DeploymentListResult] - :raises: ~azure.core.exceptions.HttpResponseError + ~azure.core.paging.ItemPaged[~azure.mgmt.resource.resources.v2018_02_01.models.DeploymentExtended] + :raises ~azure.core.exceptions.HttpResponseError: """ - api_version = kwargs.pop('api_version', "2018-02-01") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2018-02-01")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[_models.DeploymentListResult] - cls = kwargs.pop('cls', None) # type: ClsType["_models.DeploymentListResult"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) + def prepare_request(next_link=None): if not next_link: - + request = build_deployments_list_by_resource_group_request( resource_group_name=resource_group_name, subscription_id=self._config.subscription_id, - api_version=api_version, filter=filter, top=top, - template_url=self.list_by_resource_group.metadata['url'], + 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.url = self._client.format_url(request.url) # type: ignore else: - - request = build_deployments_list_by_resource_group_request( - resource_group_name=resource_group_name, - subscription_id=self._config.subscription_id, - template_url=next_link, - ) + # make call to next link with the client's api-version + _parsed_next_link = urlparse(next_link) + _next_request_params = case_insensitive_dict(parse_qs(_parsed_next_link.query)) + _next_request_params["api-version"] = self._config.api_version + request = HttpRequest("GET", urljoin(next_link, _parsed_next_link.path), params=_next_request_params) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore request.method = "GET" return request @@ -2173,10 +2115,8 @@ def extract_data(pipeline_response): def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) response = pipeline_response.http_response @@ -2186,204 +2126,204 @@ def get_next(next_link=None): return pipeline_response + return ItemPaged(get_next, extract_data) - return ItemPaged( - get_next, extract_data - ) - list_by_resource_group.metadata = {'url': "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/Microsoft.Resources/deployments/"} # type: ignore + list_by_resource_group.metadata = {"url": "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/Microsoft.Resources/deployments/"} # type: ignore @distributed_trace - def calculate_template_hash( - self, - template: Any, - **kwargs: Any - ) -> "_models.TemplateHashResult": + def calculate_template_hash(self, template: JSON, **kwargs: Any) -> _models.TemplateHashResult: """Calculate the hash of the given template. - :param template: The template provided to calculate hash. - :type template: any + :param template: The template provided to calculate hash. Required. + :type template: JSON :keyword callable cls: A custom type or function that will be passed the direct response - :return: TemplateHashResult, or the result of cls(response) + :return: TemplateHashResult or the result of cls(response) :rtype: ~azure.mgmt.resource.resources.v2018_02_01.models.TemplateHashResult - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.TemplateHashResult"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) - api_version = kwargs.pop('api_version', "2018-02-01") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - _json = self._serialize.body(template, 'object') + api_version = kwargs.pop("api_version", _params.pop("api-version", "2018-02-01")) # type: str + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", "application/json")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[_models.TemplateHashResult] + + _json = self._serialize.body(template, "object") request = build_deployments_calculate_template_hash_request( api_version=api_version, content_type=content_type, json=_json, - template_url=self.calculate_template_hash.metadata['url'], + template_url=self.calculate_template_hash.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) - deserialized = self._deserialize('TemplateHashResult', pipeline_response) + deserialized = self._deserialize("TemplateHashResult", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - calculate_template_hash.metadata = {'url': "/providers/Microsoft.Resources/calculateTemplateHash"} # type: ignore + calculate_template_hash.metadata = {"url": "/providers/Microsoft.Resources/calculateTemplateHash"} # type: ignore -class ProvidersOperations(object): - """ProvidersOperations operations. - You should not instantiate this class directly. Instead, you should create a Client instance that - instantiates it for you and attaches it as an attribute. +class ProvidersOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. - :ivar models: Alias to model classes used in this operation group. - :type models: ~azure.mgmt.resource.resources.v2018_02_01.models - :param client: Client for service requests. - :param config: Configuration of service client. - :param serializer: An object model serializer. - :param deserializer: An object model deserializer. + Instead, you should access the following operations through + :class:`~azure.mgmt.resource.resources.v2018_02_01.ResourceManagementClient`'s + :attr:`providers` attribute. """ models = _models - def __init__(self, client, config, serializer, deserializer): - self._client = client - self._serialize = serializer - self._deserialize = deserializer - self._config = config + def __init__(self, *args, **kwargs): + input_args = list(args) + self._client = input_args.pop(0) if input_args else kwargs.pop("client") + self._config = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") @distributed_trace - def unregister( - self, - resource_provider_namespace: str, - **kwargs: Any - ) -> "_models.Provider": + def unregister(self, resource_provider_namespace: str, **kwargs: Any) -> _models.Provider: """Unregisters a subscription from a resource provider. :param resource_provider_namespace: The namespace of the resource provider to unregister. + Required. :type resource_provider_namespace: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: Provider, or the result of cls(response) + :return: Provider or the result of cls(response) :rtype: ~azure.mgmt.resource.resources.v2018_02_01.models.Provider - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.Provider"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) - api_version = kwargs.pop('api_version', "2018-02-01") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2018-02-01")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[_models.Provider] - request = build_providers_unregister_request( resource_provider_namespace=resource_provider_namespace, subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.unregister.metadata['url'], + template_url=self.unregister.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) - deserialized = self._deserialize('Provider', pipeline_response) + deserialized = self._deserialize("Provider", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - unregister.metadata = {'url': "/subscriptions/{subscriptionId}/providers/{resourceProviderNamespace}/unregister"} # type: ignore - + unregister.metadata = {"url": "/subscriptions/{subscriptionId}/providers/{resourceProviderNamespace}/unregister"} # type: ignore @distributed_trace - def register( - self, - resource_provider_namespace: str, - **kwargs: Any - ) -> "_models.Provider": + def register(self, resource_provider_namespace: str, **kwargs: Any) -> _models.Provider: """Registers a subscription with a resource provider. :param resource_provider_namespace: The namespace of the resource provider to register. + Required. :type resource_provider_namespace: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: Provider, or the result of cls(response) + :return: Provider or the result of cls(response) :rtype: ~azure.mgmt.resource.resources.v2018_02_01.models.Provider - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.Provider"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) - api_version = kwargs.pop('api_version', "2018-02-01") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2018-02-01")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[_models.Provider] - request = build_providers_register_request( resource_provider_namespace=resource_provider_namespace, subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.register.metadata['url'], + template_url=self.register.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) - deserialized = self._deserialize('Provider', pipeline_response) + deserialized = self._deserialize("Provider", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - register.metadata = {'url': "/subscriptions/{subscriptionId}/providers/{resourceProviderNamespace}/register"} # type: ignore - + register.metadata = {"url": "/subscriptions/{subscriptionId}/providers/{resourceProviderNamespace}/register"} # type: ignore @distributed_trace def list( - self, - top: Optional[int] = None, - expand: Optional[str] = None, - **kwargs: Any - ) -> Iterable["_models.ProviderListResult"]: + self, top: Optional[int] = None, expand: Optional[str] = None, **kwargs: Any + ) -> Iterable["_models.Provider"]: """Gets all resource providers for a subscription. :param top: The number of results to return. If null is passed returns all deployments. Default @@ -2394,39 +2334,48 @@ def list( response, use $expand=resourceTypes/aliases. Default value is None. :type expand: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either ProviderListResult or the result of cls(response) + :return: An iterator like instance of either Provider or the result of cls(response) :rtype: - ~azure.core.paging.ItemPaged[~azure.mgmt.resource.resources.v2018_02_01.models.ProviderListResult] - :raises: ~azure.core.exceptions.HttpResponseError + ~azure.core.paging.ItemPaged[~azure.mgmt.resource.resources.v2018_02_01.models.Provider] + :raises ~azure.core.exceptions.HttpResponseError: """ - api_version = kwargs.pop('api_version', "2018-02-01") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2018-02-01")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[_models.ProviderListResult] - cls = kwargs.pop('cls', None) # type: ClsType["_models.ProviderListResult"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) + def prepare_request(next_link=None): if not next_link: - + request = build_providers_list_request( subscription_id=self._config.subscription_id, - api_version=api_version, top=top, expand=expand, - template_url=self.list.metadata['url'], + 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.url = self._client.format_url(request.url) # type: ignore else: - - request = build_providers_list_request( - subscription_id=self._config.subscription_id, - template_url=next_link, - ) + # make call to next link with the client's api-version + _parsed_next_link = urlparse(next_link) + _next_request_params = case_insensitive_dict(parse_qs(_parsed_next_link.query)) + _next_request_params["api-version"] = self._config.api_version + request = HttpRequest("GET", urljoin(next_link, _parsed_next_link.path), params=_next_request_params) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore request.method = "GET" return request @@ -2440,10 +2389,8 @@ def extract_data(pipeline_response): def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) response = pipeline_response.http_response @@ -2453,91 +2400,88 @@ def get_next(next_link=None): return pipeline_response + return ItemPaged(get_next, extract_data) - return ItemPaged( - get_next, extract_data - ) - list.metadata = {'url': "/subscriptions/{subscriptionId}/providers"} # type: ignore + list.metadata = {"url": "/subscriptions/{subscriptionId}/providers"} # type: ignore @distributed_trace - def get( - self, - resource_provider_namespace: str, - expand: Optional[str] = None, - **kwargs: Any - ) -> "_models.Provider": + def get(self, resource_provider_namespace: str, expand: Optional[str] = None, **kwargs: Any) -> _models.Provider: """Gets the specified resource provider. - :param resource_provider_namespace: The namespace of the resource provider. + :param resource_provider_namespace: The namespace of the resource provider. Required. :type resource_provider_namespace: str :param expand: The $expand query parameter. For example, to include property aliases in response, use $expand=resourceTypes/aliases. Default value is None. :type expand: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: Provider, or the result of cls(response) + :return: Provider or the result of cls(response) :rtype: ~azure.mgmt.resource.resources.v2018_02_01.models.Provider - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.Provider"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) - api_version = kwargs.pop('api_version', "2018-02-01") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2018-02-01")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[_models.Provider] - request = build_providers_get_request( resource_provider_namespace=resource_provider_namespace, subscription_id=self._config.subscription_id, - api_version=api_version, expand=expand, - template_url=self.get.metadata['url'], + api_version=api_version, + template_url=self.get.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) - deserialized = self._deserialize('Provider', pipeline_response) + deserialized = self._deserialize("Provider", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - get.metadata = {'url': "/subscriptions/{subscriptionId}/providers/{resourceProviderNamespace}"} # type: ignore + get.metadata = {"url": "/subscriptions/{subscriptionId}/providers/{resourceProviderNamespace}"} # type: ignore -class ResourcesOperations(object): # pylint: disable=too-many-public-methods - """ResourcesOperations operations. - You should not instantiate this class directly. Instead, you should create a Client instance that - instantiates it for you and attaches it as an attribute. +class ResourcesOperations: # pylint: disable=too-many-public-methods + """ + .. warning:: + **DO NOT** instantiate this class directly. - :ivar models: Alias to model classes used in this operation group. - :type models: ~azure.mgmt.resource.resources.v2018_02_01.models - :param client: Client for service requests. - :param config: Configuration of service client. - :param serializer: An object model serializer. - :param deserializer: An object model deserializer. + Instead, you should access the following operations through + :class:`~azure.mgmt.resource.resources.v2018_02_01.ResourceManagementClient`'s + :attr:`resources` attribute. """ models = _models - def __init__(self, client, config, serializer, deserializer): - self._client = client - self._serialize = serializer - self._deserialize = deserializer - self._config = config + def __init__(self, *args, **kwargs): + input_args = list(args) + self._client = input_args.pop(0) if input_args else kwargs.pop("client") + self._config = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") @distributed_trace def list_by_resource_group( @@ -2547,10 +2491,10 @@ def list_by_resource_group( expand: Optional[str] = None, top: Optional[int] = None, **kwargs: Any - ) -> Iterable["_models.ResourceListResult"]: + ) -> Iterable["_models.GenericResourceExpanded"]: """Get all the resources for a resource group. - :param resource_group_name: The resource group with the resources to get. + :param resource_group_name: The resource group with the resources to get. Required. :type resource_group_name: str :param filter: The filter to apply on the operation. Default value is None. :type filter: str @@ -2562,42 +2506,51 @@ def list_by_resource_group( value is None. :type top: int :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either ResourceListResult or the result of cls(response) + :return: An iterator like instance of either GenericResourceExpanded or the result of + cls(response) :rtype: - ~azure.core.paging.ItemPaged[~azure.mgmt.resource.resources.v2018_02_01.models.ResourceListResult] - :raises: ~azure.core.exceptions.HttpResponseError + ~azure.core.paging.ItemPaged[~azure.mgmt.resource.resources.v2018_02_01.models.GenericResourceExpanded] + :raises ~azure.core.exceptions.HttpResponseError: """ - api_version = kwargs.pop('api_version', "2018-02-01") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2018-02-01")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[_models.ResourceListResult] - cls = kwargs.pop('cls', None) # type: ClsType["_models.ResourceListResult"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) + def prepare_request(next_link=None): if not next_link: - + request = build_resources_list_by_resource_group_request( resource_group_name=resource_group_name, subscription_id=self._config.subscription_id, - api_version=api_version, filter=filter, expand=expand, top=top, - template_url=self.list_by_resource_group.metadata['url'], + 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.url = self._client.format_url(request.url) # type: ignore else: - - request = build_resources_list_by_resource_group_request( - resource_group_name=resource_group_name, - subscription_id=self._config.subscription_id, - template_url=next_link, - ) + # make call to next link with the client's api-version + _parsed_next_link = urlparse(next_link) + _next_request_params = case_insensitive_dict(parse_qs(_parsed_next_link.query)) + _next_request_params["api-version"] = self._config.api_version + request = HttpRequest("GET", urljoin(next_link, _parsed_next_link.path), params=_next_request_params) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore request.method = "GET" return request @@ -2611,10 +2564,8 @@ def extract_data(pipeline_response): def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) response = pipeline_response.http_response @@ -2624,45 +2575,54 @@ def get_next(next_link=None): return pipeline_response + return ItemPaged(get_next, extract_data) - return ItemPaged( - get_next, extract_data - ) - list_by_resource_group.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/resources"} # type: ignore + list_by_resource_group.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/resources"} # type: ignore def _move_resources_initial( # pylint: disable=inconsistent-return-statements - self, - source_resource_group_name: str, - parameters: "_models.ResourcesMoveInfo", - **kwargs: Any + self, source_resource_group_name: str, parameters: Union[_models.ResourcesMoveInfo, IO], **kwargs: Any ) -> None: - cls = kwargs.pop('cls', None) # type: ClsType[None] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) - api_version = kwargs.pop('api_version', "2018-02-01") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - _json = self._serialize.body(parameters, 'ResourcesMoveInfo') + api_version = kwargs.pop("api_version", _params.pop("api-version", "2018-02-01")) # type: str + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[None] - request = build_resources_move_resources_request_initial( + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(parameters, (IO, bytes)): + _content = parameters + else: + _json = self._serialize.body(parameters, "ResourcesMoveInfo") + + request = build_resources_move_resources_request( source_resource_group_name=source_resource_group_name, subscription_id=self._config.subscription_id, api_version=api_version, content_type=content_type, json=_json, - template_url=self._move_resources_initial.metadata['url'], + content=_content, + template_url=self._move_resources_initial.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [202, 204]: @@ -2672,14 +2632,15 @@ def _move_resources_initial( # pylint: disable=inconsistent-return-statements if cls: return cls(pipeline_response, None, {}) - _move_resources_initial.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{sourceResourceGroupName}/moveResources"} # type: ignore + _move_resources_initial.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{sourceResourceGroupName}/moveResources"} # type: ignore - - @distributed_trace - def begin_move_resources( # pylint: disable=inconsistent-return-statements + @overload + def begin_move_resources( self, source_resource_group_name: str, - parameters: "_models.ResourcesMoveInfo", + parameters: _models.ResourcesMoveInfo, + *, + content_type: str = "application/json", **kwargs: Any ) -> LROPoller[None]: """Moves resources from one resource group to another resource group. @@ -2690,10 +2651,13 @@ def begin_move_resources( # pylint: disable=inconsistent-return-statements the groups until the move completes. :param source_resource_group_name: The name of the resource group containing the resources to - move. + move. Required. :type source_resource_group_name: str - :param parameters: Parameters for moving resources. + :param parameters: Parameters for moving resources. Required. :type parameters: ~azure.mgmt.resource.resources.v2018_02_01.models.ResourcesMoveInfo + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str :keyword callable cls: A custom type or function that will be passed the direct response :keyword str continuation_token: A continuation token to restart a poller from a saved state. :keyword polling: By default, your polling method will be ARMPolling. Pass in False for this @@ -2704,80 +2668,160 @@ def begin_move_resources( # pylint: disable=inconsistent-return-statements Retry-After header is present. :return: An instance of LROPoller that returns either None or the result of cls(response) :rtype: ~azure.core.polling.LROPoller[None] - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - api_version = kwargs.pop('api_version', "2018-02-01") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] - polling = kwargs.pop('polling', True) # type: Union[bool, PollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType[None] - lro_delay = kwargs.pop( - 'polling_interval', - self._config.polling_interval - ) - cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] + + @overload + def begin_move_resources( + self, source_resource_group_name: str, parameters: IO, *, content_type: str = "application/json", **kwargs: Any + ) -> LROPoller[None]: + """Moves resources from one resource group to another resource group. + + The resources to move must be in the same source resource group. The target resource group may + be in a different subscription. When moving resources, both the source group and the target + group are locked for the duration of the operation. Write and delete operations are blocked on + the groups until the move completes. + + :param source_resource_group_name: The name of the resource group containing the resources to + move. Required. + :type source_resource_group_name: str + :param parameters: Parameters for moving resources. Required. + :type parameters: IO + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be ARMPolling. Pass in False for this + operation to not poll, or pass in your own initialized polling object for a personal polling + strategy. + :paramtype polling: bool or ~azure.core.polling.PollingMethod + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of LROPoller that returns either None or the result of cls(response) + :rtype: ~azure.core.polling.LROPoller[None] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace + def begin_move_resources( + self, source_resource_group_name: str, parameters: Union[_models.ResourcesMoveInfo, IO], **kwargs: Any + ) -> LROPoller[None]: + """Moves resources from one resource group to another resource group. + + The resources to move must be in the same source resource group. The target resource group may + be in a different subscription. When moving resources, both the source group and the target + group are locked for the duration of the operation. Write and delete operations are blocked on + the groups until the move completes. + + :param source_resource_group_name: The name of the resource group containing the resources to + move. Required. + :type source_resource_group_name: str + :param parameters: Parameters for moving resources. Is either a model type or a IO type. + Required. + :type parameters: ~azure.mgmt.resource.resources.v2018_02_01.models.ResourcesMoveInfo or IO + :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. + Default value is None. + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be ARMPolling. Pass in False for this + operation to not poll, or pass in your own initialized polling object for a personal polling + strategy. + :paramtype polling: bool or ~azure.core.polling.PollingMethod + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of LROPoller that returns either None or the result of cls(response) + :rtype: ~azure.core.polling.LROPoller[None] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _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", "2018-02-01")) # type: str + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[None] + polling = kwargs.pop("polling", True) # type: Union[bool, PollingMethod] + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token = kwargs.pop("continuation_token", None) # type: Optional[str] if cont_token is None: - raw_result = self._move_resources_initial( + raw_result = self._move_resources_initial( # type: ignore source_resource_group_name=source_resource_group_name, parameters=parameters, api_version=api_version, content_type=content_type, - cls=lambda x,y,z: x, + cls=lambda x, y, z: x, + headers=_headers, + params=_params, **kwargs ) - kwargs.pop('error_map', None) + kwargs.pop("error_map", None) - def get_long_running_output(pipeline_response): + def get_long_running_output(pipeline_response): # pylint: disable=inconsistent-return-statements if cls: return cls(pipeline_response, None, {}) - - if polling is True: polling_method = ARMPolling(lro_delay, **kwargs) - elif polling is False: polling_method = NoPolling() - else: polling_method = polling + if polling is True: + polling_method = cast(PollingMethod, ARMPolling(lro_delay, **kwargs)) # type: PollingMethod + elif polling is False: + polling_method = cast(PollingMethod, NoPolling()) + else: + polling_method = polling if cont_token: return LROPoller.from_continuation_token( polling_method=polling_method, continuation_token=cont_token, client=self._client, - deserialization_callback=get_long_running_output + deserialization_callback=get_long_running_output, ) return LROPoller(self._client, raw_result, get_long_running_output, polling_method) - begin_move_resources.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{sourceResourceGroupName}/moveResources"} # type: ignore + begin_move_resources.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{sourceResourceGroupName}/moveResources"} # type: ignore def _validate_move_resources_initial( # pylint: disable=inconsistent-return-statements - self, - source_resource_group_name: str, - parameters: "_models.ResourcesMoveInfo", - **kwargs: Any + self, source_resource_group_name: str, parameters: Union[_models.ResourcesMoveInfo, IO], **kwargs: Any ) -> None: - cls = kwargs.pop('cls', None) # type: ClsType[None] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) - api_version = kwargs.pop('api_version', "2018-02-01") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - _json = self._serialize.body(parameters, 'ResourcesMoveInfo') + api_version = kwargs.pop("api_version", _params.pop("api-version", "2018-02-01")) # type: str + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[None] - request = build_resources_validate_move_resources_request_initial( + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(parameters, (IO, bytes)): + _content = parameters + else: + _json = self._serialize.body(parameters, "ResourcesMoveInfo") + + request = build_resources_validate_move_resources_request( source_resource_group_name=source_resource_group_name, subscription_id=self._config.subscription_id, api_version=api_version, content_type=content_type, json=_json, - template_url=self._validate_move_resources_initial.metadata['url'], + content=_content, + template_url=self._validate_move_resources_initial.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [202, 204, 409]: @@ -2787,14 +2831,15 @@ def _validate_move_resources_initial( # pylint: disable=inconsistent-return-sta if cls: return cls(pipeline_response, None, {}) - _validate_move_resources_initial.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{sourceResourceGroupName}/validateMoveResources"} # type: ignore + _validate_move_resources_initial.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{sourceResourceGroupName}/validateMoveResources"} # type: ignore - - @distributed_trace - def begin_validate_move_resources( # pylint: disable=inconsistent-return-statements + @overload + def begin_validate_move_resources( self, source_resource_group_name: str, - parameters: "_models.ResourcesMoveInfo", + parameters: _models.ResourcesMoveInfo, + *, + content_type: str = "application/json", **kwargs: Any ) -> LROPoller[None]: """Validates whether resources can be moved from one resource group to another resource group. @@ -2807,10 +2852,13 @@ def begin_validate_move_resources( # pylint: disable=inconsistent-return-statem operation. :param source_resource_group_name: The name of the resource group containing the resources to - validate for move. + validate for move. Required. :type source_resource_group_name: str - :param parameters: Parameters for moving resources. + :param parameters: Parameters for moving resources. Required. :type parameters: ~azure.mgmt.resource.resources.v2018_02_01.models.ResourcesMoveInfo + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str :keyword callable cls: A custom type or function that will be passed the direct response :keyword str continuation_token: A continuation token to restart a poller from a saved state. :keyword polling: By default, your polling method will be ARMPolling. Pass in False for this @@ -2821,55 +2869,124 @@ def begin_validate_move_resources( # pylint: disable=inconsistent-return-statem Retry-After header is present. :return: An instance of LROPoller that returns either None or the result of cls(response) :rtype: ~azure.core.polling.LROPoller[None] - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - api_version = kwargs.pop('api_version', "2018-02-01") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] - polling = kwargs.pop('polling', True) # type: Union[bool, PollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType[None] - lro_delay = kwargs.pop( - 'polling_interval', - self._config.polling_interval - ) - cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] + + @overload + def begin_validate_move_resources( + self, source_resource_group_name: str, parameters: IO, *, content_type: str = "application/json", **kwargs: Any + ) -> LROPoller[None]: + """Validates whether resources can be moved from one resource group to another resource group. + + This operation checks whether the specified resources can be moved to the target. The resources + to move must be in the same source resource group. The target resource group may be in a + different subscription. If validation succeeds, it returns HTTP response code 204 (no content). + If validation fails, it returns HTTP response code 409 (Conflict) with an error message. + Retrieve the URL in the Location header value to check the result of the long-running + operation. + + :param source_resource_group_name: The name of the resource group containing the resources to + validate for move. Required. + :type source_resource_group_name: str + :param parameters: Parameters for moving resources. Required. + :type parameters: IO + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be ARMPolling. Pass in False for this + operation to not poll, or pass in your own initialized polling object for a personal polling + strategy. + :paramtype polling: bool or ~azure.core.polling.PollingMethod + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of LROPoller that returns either None or the result of cls(response) + :rtype: ~azure.core.polling.LROPoller[None] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace + def begin_validate_move_resources( + self, source_resource_group_name: str, parameters: Union[_models.ResourcesMoveInfo, IO], **kwargs: Any + ) -> LROPoller[None]: + """Validates whether resources can be moved from one resource group to another resource group. + + This operation checks whether the specified resources can be moved to the target. The resources + to move must be in the same source resource group. The target resource group may be in a + different subscription. If validation succeeds, it returns HTTP response code 204 (no content). + If validation fails, it returns HTTP response code 409 (Conflict) with an error message. + Retrieve the URL in the Location header value to check the result of the long-running + operation. + + :param source_resource_group_name: The name of the resource group containing the resources to + validate for move. Required. + :type source_resource_group_name: str + :param parameters: Parameters for moving resources. Is either a model type or a IO type. + Required. + :type parameters: ~azure.mgmt.resource.resources.v2018_02_01.models.ResourcesMoveInfo or IO + :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. + Default value is None. + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be ARMPolling. Pass in False for this + operation to not poll, or pass in your own initialized polling object for a personal polling + strategy. + :paramtype polling: bool or ~azure.core.polling.PollingMethod + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of LROPoller that returns either None or the result of cls(response) + :rtype: ~azure.core.polling.LROPoller[None] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _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", "2018-02-01")) # type: str + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[None] + polling = kwargs.pop("polling", True) # type: Union[bool, PollingMethod] + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token = kwargs.pop("continuation_token", None) # type: Optional[str] if cont_token is None: - raw_result = self._validate_move_resources_initial( + raw_result = self._validate_move_resources_initial( # type: ignore source_resource_group_name=source_resource_group_name, parameters=parameters, api_version=api_version, content_type=content_type, - cls=lambda x,y,z: x, + cls=lambda x, y, z: x, + headers=_headers, + params=_params, **kwargs ) - kwargs.pop('error_map', None) + kwargs.pop("error_map", None) - def get_long_running_output(pipeline_response): + def get_long_running_output(pipeline_response): # pylint: disable=inconsistent-return-statements if cls: return cls(pipeline_response, None, {}) - - if polling is True: polling_method = ARMPolling(lro_delay, **kwargs) - elif polling is False: polling_method = NoPolling() - else: polling_method = polling + if polling is True: + polling_method = cast(PollingMethod, ARMPolling(lro_delay, **kwargs)) # type: PollingMethod + elif polling is False: + polling_method = cast(PollingMethod, NoPolling()) + else: + polling_method = polling if cont_token: return LROPoller.from_continuation_token( polling_method=polling_method, continuation_token=cont_token, client=self._client, - deserialization_callback=get_long_running_output + deserialization_callback=get_long_running_output, ) return LROPoller(self._client, raw_result, get_long_running_output, polling_method) - begin_validate_move_resources.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{sourceResourceGroupName}/validateMoveResources"} # type: ignore + begin_validate_move_resources.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{sourceResourceGroupName}/validateMoveResources"} # type: ignore @distributed_trace def list( - self, - filter: Optional[str] = None, - expand: Optional[str] = None, - top: Optional[int] = None, - **kwargs: Any - ) -> Iterable["_models.ResourceListResult"]: + self, filter: Optional[str] = None, expand: Optional[str] = None, top: Optional[int] = None, **kwargs: Any + ) -> Iterable["_models.GenericResourceExpanded"]: """Get all the resources in a subscription. :param filter: The filter to apply on the operation. Default value is None. @@ -2880,40 +2997,50 @@ def list( value is None. :type top: int :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either ResourceListResult or the result of cls(response) + :return: An iterator like instance of either GenericResourceExpanded or the result of + cls(response) :rtype: - ~azure.core.paging.ItemPaged[~azure.mgmt.resource.resources.v2018_02_01.models.ResourceListResult] - :raises: ~azure.core.exceptions.HttpResponseError + ~azure.core.paging.ItemPaged[~azure.mgmt.resource.resources.v2018_02_01.models.GenericResourceExpanded] + :raises ~azure.core.exceptions.HttpResponseError: """ - api_version = kwargs.pop('api_version', "2018-02-01") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2018-02-01")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[_models.ResourceListResult] - cls = kwargs.pop('cls', None) # type: ClsType["_models.ResourceListResult"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) + def prepare_request(next_link=None): if not next_link: - + request = build_resources_list_request( subscription_id=self._config.subscription_id, - api_version=api_version, filter=filter, expand=expand, top=top, - template_url=self.list.metadata['url'], + 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.url = self._client.format_url(request.url) # type: ignore else: - - request = build_resources_list_request( - subscription_id=self._config.subscription_id, - template_url=next_link, - ) + # make call to next link with the client's api-version + _parsed_next_link = urlparse(next_link) + _next_request_params = case_insensitive_dict(parse_qs(_parsed_next_link.query)) + _next_request_params["api-version"] = self._config.api_version + request = HttpRequest("GET", urljoin(next_link, _parsed_next_link.path), params=_next_request_params) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore request.method = "GET" return request @@ -2927,10 +3054,8 @@ def extract_data(pipeline_response): def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) response = pipeline_response.http_response @@ -2940,11 +3065,9 @@ def get_next(next_link=None): return pipeline_response + return ItemPaged(get_next, extract_data) - return ItemPaged( - get_next, extract_data - ) - list.metadata = {'url': "/subscriptions/{subscriptionId}/resources"} # type: ignore + list.metadata = {"url": "/subscriptions/{subscriptionId}/resources"} # type: ignore @distributed_trace def check_existence( @@ -2960,30 +3083,36 @@ def check_existence( """Checks whether a resource exists. :param resource_group_name: The name of the resource group containing the resource to check. - The name is case insensitive. + The name is case insensitive. Required. :type resource_group_name: str - :param resource_provider_namespace: The resource provider of the resource to check. + :param resource_provider_namespace: The resource provider of the resource to check. Required. :type resource_provider_namespace: str - :param parent_resource_path: The parent resource identity. + :param parent_resource_path: The parent resource identity. Required. :type parent_resource_path: str - :param resource_type: The resource type. + :param resource_type: The resource type. Required. :type resource_type: str - :param resource_name: The name of the resource to check whether it exists. + :param resource_name: The name of the resource to check whether it exists. Required. :type resource_name: str - :param api_version: The API version to use for the operation. + :param api_version: The API version to use for the operation. Required. :type api_version: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: bool, or the result of cls(response) + :return: bool or the result of cls(response) :rtype: bool - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType[None] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = kwargs.pop("params", {}) or {} + + cls = kwargs.pop("cls", None) # type: ClsType[None] - request = build_resources_check_existence_request( resource_group_name=resource_group_name, resource_provider_namespace=resource_provider_namespace, @@ -2992,16 +3121,17 @@ def check_existence( resource_name=resource_name, subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.check_existence.metadata['url'], + template_url=self.check_existence.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [204, 404]: @@ -3012,8 +3142,7 @@ def check_existence( return cls(pipeline_response, None, {}) return 200 <= response.status_code <= 299 - check_existence.metadata = {'url': "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{parentResourcePath}/{resourceType}/{resourceName}"} # type: ignore - + check_existence.metadata = {"url": "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{parentResourcePath}/{resourceType}/{resourceName}"} # type: ignore def _delete_initial( # pylint: disable=inconsistent-return-statements self, @@ -3025,14 +3154,20 @@ def _delete_initial( # pylint: disable=inconsistent-return-statements api_version: str, **kwargs: Any ) -> None: - cls = kwargs.pop('cls', None) # type: ClsType[None] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = kwargs.pop("params", {}) or {} - - request = build_resources_delete_request_initial( + cls = kwargs.pop("cls", None) # type: ClsType[None] + + request = build_resources_delete_request( resource_group_name=resource_group_name, resource_provider_namespace=resource_provider_namespace, parent_resource_path=parent_resource_path, @@ -3040,16 +3175,17 @@ def _delete_initial( # pylint: disable=inconsistent-return-statements resource_name=resource_name, subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self._delete_initial.metadata['url'], + template_url=self._delete_initial.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200, 202, 204]: @@ -3059,11 +3195,10 @@ def _delete_initial( # pylint: disable=inconsistent-return-statements if cls: return cls(pipeline_response, None, {}) - _delete_initial.metadata = {'url': "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{parentResourcePath}/{resourceType}/{resourceName}"} # type: ignore - + _delete_initial.metadata = {"url": "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{parentResourcePath}/{resourceType}/{resourceName}"} # type: ignore @distributed_trace - def begin_delete( # pylint: disable=inconsistent-return-statements + def begin_delete( self, resource_group_name: str, resource_provider_namespace: str, @@ -3076,17 +3211,17 @@ def begin_delete( # pylint: disable=inconsistent-return-statements """Deletes a resource. :param resource_group_name: The name of the resource group that contains the resource to - delete. The name is case insensitive. + delete. The name is case insensitive. Required. :type resource_group_name: str - :param resource_provider_namespace: The namespace of the resource provider. + :param resource_provider_namespace: The namespace of the resource provider. Required. :type resource_provider_namespace: str - :param parent_resource_path: The parent resource identity. + :param parent_resource_path: The parent resource identity. Required. :type parent_resource_path: str - :param resource_type: The resource type. + :param resource_type: The resource type. Required. :type resource_type: str - :param resource_name: The name of the resource to delete. + :param resource_name: The name of the resource to delete. Required. :type resource_name: str - :param api_version: The API version to use for the operation. + :param api_version: The API version to use for the operation. Required. :type api_version: str :keyword callable cls: A custom type or function that will be passed the direct response :keyword str continuation_token: A continuation token to restart a poller from a saved state. @@ -3098,46 +3233,50 @@ def begin_delete( # pylint: disable=inconsistent-return-statements Retry-After header is present. :return: An instance of LROPoller that returns either None or the result of cls(response) :rtype: ~azure.core.polling.LROPoller[None] - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - polling = kwargs.pop('polling', True) # type: Union[bool, PollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType[None] - lro_delay = kwargs.pop( - 'polling_interval', - self._config.polling_interval - ) - cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] + _headers = kwargs.pop("headers", {}) or {} + _params = kwargs.pop("params", {}) or {} + + cls = kwargs.pop("cls", None) # type: ClsType[None] + polling = kwargs.pop("polling", True) # type: Union[bool, PollingMethod] + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token = kwargs.pop("continuation_token", None) # type: Optional[str] if cont_token is None: - raw_result = self._delete_initial( + raw_result = self._delete_initial( # type: ignore resource_group_name=resource_group_name, resource_provider_namespace=resource_provider_namespace, parent_resource_path=parent_resource_path, resource_type=resource_type, resource_name=resource_name, api_version=api_version, - cls=lambda x,y,z: x, + cls=lambda x, y, z: x, + headers=_headers, + params=_params, **kwargs ) - kwargs.pop('error_map', None) + kwargs.pop("error_map", None) - def get_long_running_output(pipeline_response): + def get_long_running_output(pipeline_response): # pylint: disable=inconsistent-return-statements if cls: return cls(pipeline_response, None, {}) - - if polling is True: polling_method = ARMPolling(lro_delay, **kwargs) - elif polling is False: polling_method = NoPolling() - else: polling_method = polling + if polling is True: + polling_method = cast(PollingMethod, ARMPolling(lro_delay, **kwargs)) # type: PollingMethod + elif polling is False: + polling_method = cast(PollingMethod, NoPolling()) + else: + polling_method = polling if cont_token: return LROPoller.from_continuation_token( polling_method=polling_method, continuation_token=cont_token, client=self._client, - deserialization_callback=get_long_running_output + deserialization_callback=get_long_running_output, ) return LROPoller(self._client, raw_result, get_long_running_output, polling_method) - begin_delete.metadata = {'url': "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{parentResourcePath}/{resourceType}/{resourceName}"} # type: ignore + begin_delete.metadata = {"url": "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{parentResourcePath}/{resourceType}/{resourceName}"} # type: ignore def _create_or_update_initial( self, @@ -3147,39 +3286,53 @@ def _create_or_update_initial( resource_type: str, resource_name: str, api_version: str, - parameters: "_models.GenericResource", + parameters: Union[_models.GenericResource, IO], **kwargs: Any - ) -> Optional["_models.GenericResource"]: - cls = kwargs.pop('cls', None) # type: ClsType[Optional["_models.GenericResource"]] + ) -> Optional[_models.GenericResource]: error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = kwargs.pop("params", {}) or {} - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[Optional[_models.GenericResource]] - _json = self._serialize.body(parameters, 'GenericResource') + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(parameters, (IO, bytes)): + _content = parameters + else: + _json = self._serialize.body(parameters, "GenericResource") - request = build_resources_create_or_update_request_initial( + request = build_resources_create_or_update_request( resource_group_name=resource_group_name, resource_provider_namespace=resource_provider_namespace, parent_resource_path=parent_resource_path, resource_type=resource_type, resource_name=resource_name, subscription_id=self._config.subscription_id, - content_type=content_type, api_version=api_version, + content_type=content_type, json=_json, - template_url=self._create_or_update_initial.metadata['url'], + content=_content, + template_url=self._create_or_update_initial.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200, 201, 202]: @@ -3188,18 +3341,115 @@ def _create_or_update_initial( deserialized = None if response.status_code == 200: - deserialized = self._deserialize('GenericResource', pipeline_response) + deserialized = self._deserialize("GenericResource", pipeline_response) if response.status_code == 201: - deserialized = self._deserialize('GenericResource', pipeline_response) + deserialized = self._deserialize("GenericResource", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - _create_or_update_initial.metadata = {'url': "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{parentResourcePath}/{resourceType}/{resourceName}"} # type: ignore + _create_or_update_initial.metadata = {"url": "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{parentResourcePath}/{resourceType}/{resourceName}"} # type: ignore + + @overload + def begin_create_or_update( + self, + resource_group_name: str, + resource_provider_namespace: str, + parent_resource_path: str, + resource_type: str, + resource_name: str, + api_version: str, + parameters: _models.GenericResource, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> LROPoller[_models.GenericResource]: + """Creates a resource. + + :param resource_group_name: The name of the resource group for the resource. The name is case + insensitive. Required. + :type resource_group_name: str + :param resource_provider_namespace: The namespace of the resource provider. Required. + :type resource_provider_namespace: str + :param parent_resource_path: The parent resource identity. Required. + :type parent_resource_path: str + :param resource_type: The resource type of the resource to create. Required. + :type resource_type: str + :param resource_name: The name of the resource to create. Required. + :type resource_name: str + :param api_version: The API version to use for the operation. Required. + :type api_version: str + :param parameters: Parameters for creating or updating the resource. Required. + :type parameters: ~azure.mgmt.resource.resources.v2018_02_01.models.GenericResource + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be ARMPolling. Pass in False for this + operation to not poll, or pass in your own initialized polling object for a personal polling + strategy. + :paramtype polling: bool or ~azure.core.polling.PollingMethod + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of LROPoller that returns either GenericResource or the result of + cls(response) + :rtype: + ~azure.core.polling.LROPoller[~azure.mgmt.resource.resources.v2018_02_01.models.GenericResource] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + def begin_create_or_update( + self, + resource_group_name: str, + resource_provider_namespace: str, + parent_resource_path: str, + resource_type: str, + resource_name: str, + api_version: str, + parameters: IO, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> LROPoller[_models.GenericResource]: + """Creates a resource. + :param resource_group_name: The name of the resource group for the resource. The name is case + insensitive. Required. + :type resource_group_name: str + :param resource_provider_namespace: The namespace of the resource provider. Required. + :type resource_provider_namespace: str + :param parent_resource_path: The parent resource identity. Required. + :type parent_resource_path: str + :param resource_type: The resource type of the resource to create. Required. + :type resource_type: str + :param resource_name: The name of the resource to create. Required. + :type resource_name: str + :param api_version: The API version to use for the operation. Required. + :type api_version: str + :param parameters: Parameters for creating or updating the resource. Required. + :type parameters: IO + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be ARMPolling. Pass in False for this + operation to not poll, or pass in your own initialized polling object for a personal polling + strategy. + :paramtype polling: bool or ~azure.core.polling.PollingMethod + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of LROPoller that returns either GenericResource or the result of + cls(response) + :rtype: + ~azure.core.polling.LROPoller[~azure.mgmt.resource.resources.v2018_02_01.models.GenericResource] + :raises ~azure.core.exceptions.HttpResponseError: + """ @distributed_trace def begin_create_or_update( @@ -3210,26 +3460,30 @@ def begin_create_or_update( resource_type: str, resource_name: str, api_version: str, - parameters: "_models.GenericResource", + parameters: Union[_models.GenericResource, IO], **kwargs: Any - ) -> LROPoller["_models.GenericResource"]: + ) -> LROPoller[_models.GenericResource]: """Creates a resource. :param resource_group_name: The name of the resource group for the resource. The name is case - insensitive. + insensitive. Required. :type resource_group_name: str - :param resource_provider_namespace: The namespace of the resource provider. + :param resource_provider_namespace: The namespace of the resource provider. Required. :type resource_provider_namespace: str - :param parent_resource_path: The parent resource identity. + :param parent_resource_path: The parent resource identity. Required. :type parent_resource_path: str - :param resource_type: The resource type of the resource to create. + :param resource_type: The resource type of the resource to create. Required. :type resource_type: str - :param resource_name: The name of the resource to create. + :param resource_name: The name of the resource to create. Required. :type resource_name: str - :param api_version: The API version to use for the operation. + :param api_version: The API version to use for the operation. Required. :type api_version: str - :param parameters: Parameters for creating or updating the resource. - :type parameters: ~azure.mgmt.resource.resources.v2018_02_01.models.GenericResource + :param parameters: Parameters for creating or updating the resource. Is either a model type or + a IO type. Required. + :type parameters: ~azure.mgmt.resource.resources.v2018_02_01.models.GenericResource or IO + :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. + Default value is None. + :paramtype content_type: str :keyword callable cls: A custom type or function that will be passed the direct response :keyword str continuation_token: A continuation token to restart a poller from a saved state. :keyword polling: By default, your polling method will be ARMPolling. Pass in False for this @@ -3242,18 +3496,18 @@ def begin_create_or_update( cls(response) :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.resource.resources.v2018_02_01.models.GenericResource] - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] - polling = kwargs.pop('polling', True) # type: Union[bool, PollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType["_models.GenericResource"] - lro_delay = kwargs.pop( - 'polling_interval', - self._config.polling_interval - ) - cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = kwargs.pop("params", {}) or {} + + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.GenericResource] + polling = kwargs.pop("polling", True) # type: Union[bool, PollingMethod] + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token = kwargs.pop("continuation_token", None) # type: Optional[str] if cont_token is None: - raw_result = self._create_or_update_initial( + raw_result = self._create_or_update_initial( # type: ignore resource_group_name=resource_group_name, resource_provider_namespace=resource_provider_namespace, parent_resource_path=parent_resource_path, @@ -3262,32 +3516,35 @@ def begin_create_or_update( api_version=api_version, parameters=parameters, content_type=content_type, - cls=lambda x,y,z: x, + cls=lambda x, y, z: x, + headers=_headers, + params=_params, **kwargs ) - kwargs.pop('error_map', None) + kwargs.pop("error_map", None) def get_long_running_output(pipeline_response): - response = pipeline_response.http_response - deserialized = self._deserialize('GenericResource', pipeline_response) + deserialized = self._deserialize("GenericResource", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - - if polling is True: polling_method = ARMPolling(lro_delay, **kwargs) - elif polling is False: polling_method = NoPolling() - else: polling_method = polling + if polling is True: + polling_method = cast(PollingMethod, ARMPolling(lro_delay, **kwargs)) # type: PollingMethod + elif polling is False: + polling_method = cast(PollingMethod, NoPolling()) + else: + polling_method = polling if cont_token: return LROPoller.from_continuation_token( polling_method=polling_method, continuation_token=cont_token, client=self._client, - deserialization_callback=get_long_running_output + deserialization_callback=get_long_running_output, ) return LROPoller(self._client, raw_result, get_long_running_output, polling_method) - begin_create_or_update.metadata = {'url': "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{parentResourcePath}/{resourceType}/{resourceName}"} # type: ignore + begin_create_or_update.metadata = {"url": "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{parentResourcePath}/{resourceType}/{resourceName}"} # type: ignore def _update_initial( self, @@ -3297,39 +3554,53 @@ def _update_initial( resource_type: str, resource_name: str, api_version: str, - parameters: "_models.GenericResource", + parameters: Union[_models.GenericResource, IO], **kwargs: Any - ) -> Optional["_models.GenericResource"]: - cls = kwargs.pop('cls', None) # type: ClsType[Optional["_models.GenericResource"]] + ) -> Optional[_models.GenericResource]: error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = kwargs.pop("params", {}) or {} - _json = self._serialize.body(parameters, 'GenericResource') + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[Optional[_models.GenericResource]] - request = build_resources_update_request_initial( + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(parameters, (IO, bytes)): + _content = parameters + else: + _json = self._serialize.body(parameters, "GenericResource") + + request = build_resources_update_request( resource_group_name=resource_group_name, resource_provider_namespace=resource_provider_namespace, parent_resource_path=parent_resource_path, resource_type=resource_type, resource_name=resource_name, subscription_id=self._config.subscription_id, - content_type=content_type, api_version=api_version, + content_type=content_type, json=_json, - template_url=self._update_initial.metadata['url'], + content=_content, + template_url=self._update_initial.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200, 202]: @@ -3338,15 +3609,112 @@ def _update_initial( deserialized = None if response.status_code == 200: - deserialized = self._deserialize('GenericResource', pipeline_response) + deserialized = self._deserialize("GenericResource", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - _update_initial.metadata = {'url': "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{parentResourcePath}/{resourceType}/{resourceName}"} # type: ignore + _update_initial.metadata = {"url": "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{parentResourcePath}/{resourceType}/{resourceName}"} # type: ignore + + @overload + def begin_update( + self, + resource_group_name: str, + resource_provider_namespace: str, + parent_resource_path: str, + resource_type: str, + resource_name: str, + api_version: str, + parameters: _models.GenericResource, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> LROPoller[_models.GenericResource]: + """Updates a resource. + :param resource_group_name: The name of the resource group for the resource. The name is case + insensitive. Required. + :type resource_group_name: str + :param resource_provider_namespace: The namespace of the resource provider. Required. + :type resource_provider_namespace: str + :param parent_resource_path: The parent resource identity. Required. + :type parent_resource_path: str + :param resource_type: The resource type of the resource to update. Required. + :type resource_type: str + :param resource_name: The name of the resource to update. Required. + :type resource_name: str + :param api_version: The API version to use for the operation. Required. + :type api_version: str + :param parameters: Parameters for updating the resource. Required. + :type parameters: ~azure.mgmt.resource.resources.v2018_02_01.models.GenericResource + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be ARMPolling. Pass in False for this + operation to not poll, or pass in your own initialized polling object for a personal polling + strategy. + :paramtype polling: bool or ~azure.core.polling.PollingMethod + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of LROPoller that returns either GenericResource or the result of + cls(response) + :rtype: + ~azure.core.polling.LROPoller[~azure.mgmt.resource.resources.v2018_02_01.models.GenericResource] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + def begin_update( + self, + resource_group_name: str, + resource_provider_namespace: str, + parent_resource_path: str, + resource_type: str, + resource_name: str, + api_version: str, + parameters: IO, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> LROPoller[_models.GenericResource]: + """Updates a resource. + + :param resource_group_name: The name of the resource group for the resource. The name is case + insensitive. Required. + :type resource_group_name: str + :param resource_provider_namespace: The namespace of the resource provider. Required. + :type resource_provider_namespace: str + :param parent_resource_path: The parent resource identity. Required. + :type parent_resource_path: str + :param resource_type: The resource type of the resource to update. Required. + :type resource_type: str + :param resource_name: The name of the resource to update. Required. + :type resource_name: str + :param api_version: The API version to use for the operation. Required. + :type api_version: str + :param parameters: Parameters for updating the resource. Required. + :type parameters: IO + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be ARMPolling. Pass in False for this + operation to not poll, or pass in your own initialized polling object for a personal polling + strategy. + :paramtype polling: bool or ~azure.core.polling.PollingMethod + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of LROPoller that returns either GenericResource or the result of + cls(response) + :rtype: + ~azure.core.polling.LROPoller[~azure.mgmt.resource.resources.v2018_02_01.models.GenericResource] + :raises ~azure.core.exceptions.HttpResponseError: + """ @distributed_trace def begin_update( @@ -3357,26 +3725,30 @@ def begin_update( resource_type: str, resource_name: str, api_version: str, - parameters: "_models.GenericResource", + parameters: Union[_models.GenericResource, IO], **kwargs: Any - ) -> LROPoller["_models.GenericResource"]: + ) -> LROPoller[_models.GenericResource]: """Updates a resource. :param resource_group_name: The name of the resource group for the resource. The name is case - insensitive. + insensitive. Required. :type resource_group_name: str - :param resource_provider_namespace: The namespace of the resource provider. + :param resource_provider_namespace: The namespace of the resource provider. Required. :type resource_provider_namespace: str - :param parent_resource_path: The parent resource identity. + :param parent_resource_path: The parent resource identity. Required. :type parent_resource_path: str - :param resource_type: The resource type of the resource to update. + :param resource_type: The resource type of the resource to update. Required. :type resource_type: str - :param resource_name: The name of the resource to update. + :param resource_name: The name of the resource to update. Required. :type resource_name: str - :param api_version: The API version to use for the operation. + :param api_version: The API version to use for the operation. Required. :type api_version: str - :param parameters: Parameters for updating the resource. - :type parameters: ~azure.mgmt.resource.resources.v2018_02_01.models.GenericResource + :param parameters: Parameters for updating the resource. Is either a model type or a IO type. + Required. + :type parameters: ~azure.mgmt.resource.resources.v2018_02_01.models.GenericResource or IO + :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. + Default value is None. + :paramtype content_type: str :keyword callable cls: A custom type or function that will be passed the direct response :keyword str continuation_token: A continuation token to restart a poller from a saved state. :keyword polling: By default, your polling method will be ARMPolling. Pass in False for this @@ -3389,18 +3761,18 @@ def begin_update( cls(response) :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.resource.resources.v2018_02_01.models.GenericResource] - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] - polling = kwargs.pop('polling', True) # type: Union[bool, PollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType["_models.GenericResource"] - lro_delay = kwargs.pop( - 'polling_interval', - self._config.polling_interval - ) - cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = kwargs.pop("params", {}) or {} + + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.GenericResource] + polling = kwargs.pop("polling", True) # type: Union[bool, PollingMethod] + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token = kwargs.pop("continuation_token", None) # type: Optional[str] if cont_token is None: - raw_result = self._update_initial( + raw_result = self._update_initial( # type: ignore resource_group_name=resource_group_name, resource_provider_namespace=resource_provider_namespace, parent_resource_path=parent_resource_path, @@ -3409,32 +3781,35 @@ def begin_update( api_version=api_version, parameters=parameters, content_type=content_type, - cls=lambda x,y,z: x, + cls=lambda x, y, z: x, + headers=_headers, + params=_params, **kwargs ) - kwargs.pop('error_map', None) + kwargs.pop("error_map", None) def get_long_running_output(pipeline_response): - response = pipeline_response.http_response - deserialized = self._deserialize('GenericResource', pipeline_response) + deserialized = self._deserialize("GenericResource", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - - if polling is True: polling_method = ARMPolling(lro_delay, **kwargs) - elif polling is False: polling_method = NoPolling() - else: polling_method = polling + if polling is True: + polling_method = cast(PollingMethod, ARMPolling(lro_delay, **kwargs)) # type: PollingMethod + elif polling is False: + polling_method = cast(PollingMethod, NoPolling()) + else: + polling_method = polling if cont_token: return LROPoller.from_continuation_token( polling_method=polling_method, continuation_token=cont_token, client=self._client, - deserialization_callback=get_long_running_output + deserialization_callback=get_long_running_output, ) return LROPoller(self._client, raw_result, get_long_running_output, polling_method) - begin_update.metadata = {'url': "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{parentResourcePath}/{resourceType}/{resourceName}"} # type: ignore + begin_update.metadata = {"url": "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{parentResourcePath}/{resourceType}/{resourceName}"} # type: ignore @distributed_trace def get( @@ -3446,34 +3821,40 @@ def get( resource_name: str, api_version: str, **kwargs: Any - ) -> "_models.GenericResource": + ) -> _models.GenericResource: """Gets a resource. :param resource_group_name: The name of the resource group containing the resource to get. The - name is case insensitive. + name is case insensitive. Required. :type resource_group_name: str - :param resource_provider_namespace: The namespace of the resource provider. + :param resource_provider_namespace: The namespace of the resource provider. Required. :type resource_provider_namespace: str - :param parent_resource_path: The parent resource identity. + :param parent_resource_path: The parent resource identity. Required. :type parent_resource_path: str - :param resource_type: The resource type of the resource. + :param resource_type: The resource type of the resource. Required. :type resource_type: str - :param resource_name: The name of the resource to get. + :param resource_name: The name of the resource to get. Required. :type resource_name: str - :param api_version: The API version to use for the operation. + :param api_version: The API version to use for the operation. Required. :type api_version: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: GenericResource, or the result of cls(response) + :return: GenericResource or the result of cls(response) :rtype: ~azure.mgmt.resource.resources.v2018_02_01.models.GenericResource - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.GenericResource"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = kwargs.pop("params", {}) or {} + + cls = kwargs.pop("cls", None) # type: ClsType[_models.GenericResource] - request = build_resources_get_request( resource_group_name=resource_group_name, resource_provider_namespace=resource_provider_namespace, @@ -3482,72 +3863,75 @@ def get( resource_name=resource_name, subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.get.metadata['url'], + template_url=self.get.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) - deserialized = self._deserialize('GenericResource', pipeline_response) + deserialized = self._deserialize("GenericResource", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - get.metadata = {'url': "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{parentResourcePath}/{resourceType}/{resourceName}"} # type: ignore - + get.metadata = {"url": "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{parentResourcePath}/{resourceType}/{resourceName}"} # type: ignore @distributed_trace - def check_existence_by_id( - self, - resource_id: str, - api_version: str, - **kwargs: Any - ) -> bool: + def check_existence_by_id(self, resource_id: str, api_version: str, **kwargs: Any) -> bool: """Checks by ID whether a resource exists. :param resource_id: The fully qualified ID of the resource, including the resource name and resource type. Use the format, /subscriptions/{guid}/resourceGroups/{resource-group-name}/{resource-provider-namespace}/{resource-type}/{resource-name}. + Required. :type resource_id: str - :param api_version: The API version to use for the operation. + :param api_version: The API version to use for the operation. Required. :type api_version: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: bool, or the result of cls(response) + :return: bool or the result of cls(response) :rtype: bool - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType[None] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = kwargs.pop("params", {}) or {} + + cls = kwargs.pop("cls", None) # type: ClsType[None] - request = build_resources_check_existence_by_id_request( resource_id=resource_id, api_version=api_version, - template_url=self.check_existence_by_id.metadata['url'], + template_url=self.check_existence_by_id.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [204, 404]: @@ -3558,35 +3942,38 @@ def check_existence_by_id( return cls(pipeline_response, None, {}) return 200 <= response.status_code <= 299 - check_existence_by_id.metadata = {'url': "/{resourceId}"} # type: ignore - + check_existence_by_id.metadata = {"url": "/{resourceId}"} # type: ignore def _delete_by_id_initial( # pylint: disable=inconsistent-return-statements - self, - resource_id: str, - api_version: str, - **kwargs: Any + self, resource_id: str, api_version: str, **kwargs: Any ) -> None: - cls = kwargs.pop('cls', None) # type: ClsType[None] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = kwargs.pop("params", {}) or {} - - request = build_resources_delete_by_id_request_initial( + cls = kwargs.pop("cls", None) # type: ClsType[None] + + request = build_resources_delete_by_id_request( resource_id=resource_id, api_version=api_version, - template_url=self._delete_by_id_initial.metadata['url'], + template_url=self._delete_by_id_initial.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200, 202, 204]: @@ -3596,23 +3983,18 @@ def _delete_by_id_initial( # pylint: disable=inconsistent-return-statements if cls: return cls(pipeline_response, None, {}) - _delete_by_id_initial.metadata = {'url': "/{resourceId}"} # type: ignore - + _delete_by_id_initial.metadata = {"url": "/{resourceId}"} # type: ignore @distributed_trace - def begin_delete_by_id( # pylint: disable=inconsistent-return-statements - self, - resource_id: str, - api_version: str, - **kwargs: Any - ) -> LROPoller[None]: + def begin_delete_by_id(self, resource_id: str, api_version: str, **kwargs: Any) -> LROPoller[None]: """Deletes a resource by ID. :param resource_id: The fully qualified ID of the resource, including the resource name and resource type. Use the format, /subscriptions/{guid}/resourceGroups/{resource-group-name}/{resource-provider-namespace}/{resource-type}/{resource-name}. + Required. :type resource_id: str - :param api_version: The API version to use for the operation. + :param api_version: The API version to use for the operation. Required. :type api_version: str :keyword callable cls: A custom type or function that will be passed the direct response :keyword str continuation_token: A continuation token to restart a poller from a saved state. @@ -3624,75 +4006,89 @@ def begin_delete_by_id( # pylint: disable=inconsistent-return-statements Retry-After header is present. :return: An instance of LROPoller that returns either None or the result of cls(response) :rtype: ~azure.core.polling.LROPoller[None] - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - polling = kwargs.pop('polling', True) # type: Union[bool, PollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType[None] - lro_delay = kwargs.pop( - 'polling_interval', - self._config.polling_interval - ) - cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] + _headers = kwargs.pop("headers", {}) or {} + _params = kwargs.pop("params", {}) or {} + + cls = kwargs.pop("cls", None) # type: ClsType[None] + polling = kwargs.pop("polling", True) # type: Union[bool, PollingMethod] + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token = kwargs.pop("continuation_token", None) # type: Optional[str] if cont_token is None: - raw_result = self._delete_by_id_initial( + raw_result = self._delete_by_id_initial( # type: ignore resource_id=resource_id, api_version=api_version, - cls=lambda x,y,z: x, + cls=lambda x, y, z: x, + headers=_headers, + params=_params, **kwargs ) - kwargs.pop('error_map', None) + kwargs.pop("error_map", None) - def get_long_running_output(pipeline_response): + def get_long_running_output(pipeline_response): # pylint: disable=inconsistent-return-statements if cls: return cls(pipeline_response, None, {}) - - if polling is True: polling_method = ARMPolling(lro_delay, **kwargs) - elif polling is False: polling_method = NoPolling() - else: polling_method = polling + if polling is True: + polling_method = cast(PollingMethod, ARMPolling(lro_delay, **kwargs)) # type: PollingMethod + elif polling is False: + polling_method = cast(PollingMethod, NoPolling()) + else: + polling_method = polling if cont_token: return LROPoller.from_continuation_token( polling_method=polling_method, continuation_token=cont_token, client=self._client, - deserialization_callback=get_long_running_output + deserialization_callback=get_long_running_output, ) return LROPoller(self._client, raw_result, get_long_running_output, polling_method) - begin_delete_by_id.metadata = {'url': "/{resourceId}"} # type: ignore + begin_delete_by_id.metadata = {"url": "/{resourceId}"} # type: ignore def _create_or_update_by_id_initial( - self, - resource_id: str, - api_version: str, - parameters: "_models.GenericResource", - **kwargs: Any - ) -> Optional["_models.GenericResource"]: - cls = kwargs.pop('cls', None) # type: ClsType[Optional["_models.GenericResource"]] + self, resource_id: str, api_version: str, parameters: Union[_models.GenericResource, IO], **kwargs: Any + ) -> Optional[_models.GenericResource]: error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = kwargs.pop("params", {}) or {} - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[Optional[_models.GenericResource]] - _json = self._serialize.body(parameters, 'GenericResource') + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(parameters, (IO, bytes)): + _content = parameters + else: + _json = self._serialize.body(parameters, "GenericResource") - request = build_resources_create_or_update_by_id_request_initial( + request = build_resources_create_or_update_by_id_request( resource_id=resource_id, - content_type=content_type, api_version=api_version, + content_type=content_type, json=_json, - template_url=self._create_or_update_by_id_initial.metadata['url'], + content=_content, + template_url=self._create_or_update_by_id_initial.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200, 201, 202]: @@ -3701,37 +4097,42 @@ def _create_or_update_by_id_initial( deserialized = None if response.status_code == 200: - deserialized = self._deserialize('GenericResource', pipeline_response) + deserialized = self._deserialize("GenericResource", pipeline_response) if response.status_code == 201: - deserialized = self._deserialize('GenericResource', pipeline_response) + deserialized = self._deserialize("GenericResource", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - _create_or_update_by_id_initial.metadata = {'url': "/{resourceId}"} # type: ignore + _create_or_update_by_id_initial.metadata = {"url": "/{resourceId}"} # type: ignore - - @distributed_trace + @overload def begin_create_or_update_by_id( self, resource_id: str, api_version: str, - parameters: "_models.GenericResource", + parameters: _models.GenericResource, + *, + content_type: str = "application/json", **kwargs: Any - ) -> LROPoller["_models.GenericResource"]: + ) -> LROPoller[_models.GenericResource]: """Create a resource by ID. :param resource_id: The fully qualified ID of the resource, including the resource name and resource type. Use the format, /subscriptions/{guid}/resourceGroups/{resource-group-name}/{resource-provider-namespace}/{resource-type}/{resource-name}. + Required. :type resource_id: str - :param api_version: The API version to use for the operation. + :param api_version: The API version to use for the operation. Required. :type api_version: str - :param parameters: Create or update resource parameters. + :param parameters: Create or update resource parameters. Required. :type parameters: ~azure.mgmt.resource.resources.v2018_02_01.models.GenericResource + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str :keyword callable cls: A custom type or function that will be passed the direct response :keyword str continuation_token: A continuation token to restart a poller from a saved state. :keyword polling: By default, your polling method will be ARMPolling. Pass in False for this @@ -3744,81 +4145,167 @@ def begin_create_or_update_by_id( cls(response) :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.resource.resources.v2018_02_01.models.GenericResource] - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] - polling = kwargs.pop('polling', True) # type: Union[bool, PollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType["_models.GenericResource"] - lro_delay = kwargs.pop( - 'polling_interval', - self._config.polling_interval - ) - cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] + + @overload + def begin_create_or_update_by_id( + self, + resource_id: str, + api_version: str, + parameters: IO, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> LROPoller[_models.GenericResource]: + """Create a resource by ID. + + :param resource_id: The fully qualified ID of the resource, including the resource name and + resource type. Use the format, + /subscriptions/{guid}/resourceGroups/{resource-group-name}/{resource-provider-namespace}/{resource-type}/{resource-name}. + Required. + :type resource_id: str + :param api_version: The API version to use for the operation. Required. + :type api_version: str + :param parameters: Create or update resource parameters. Required. + :type parameters: IO + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be ARMPolling. Pass in False for this + operation to not poll, or pass in your own initialized polling object for a personal polling + strategy. + :paramtype polling: bool or ~azure.core.polling.PollingMethod + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of LROPoller that returns either GenericResource or the result of + cls(response) + :rtype: + ~azure.core.polling.LROPoller[~azure.mgmt.resource.resources.v2018_02_01.models.GenericResource] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace + def begin_create_or_update_by_id( + self, resource_id: str, api_version: str, parameters: Union[_models.GenericResource, IO], **kwargs: Any + ) -> LROPoller[_models.GenericResource]: + """Create a resource by ID. + + :param resource_id: The fully qualified ID of the resource, including the resource name and + resource type. Use the format, + /subscriptions/{guid}/resourceGroups/{resource-group-name}/{resource-provider-namespace}/{resource-type}/{resource-name}. + Required. + :type resource_id: str + :param api_version: The API version to use for the operation. Required. + :type api_version: str + :param parameters: Create or update resource parameters. Is either a model type or a IO type. + Required. + :type parameters: ~azure.mgmt.resource.resources.v2018_02_01.models.GenericResource or IO + :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. + Default value is None. + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be ARMPolling. Pass in False for this + operation to not poll, or pass in your own initialized polling object for a personal polling + strategy. + :paramtype polling: bool or ~azure.core.polling.PollingMethod + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of LROPoller that returns either GenericResource or the result of + cls(response) + :rtype: + ~azure.core.polling.LROPoller[~azure.mgmt.resource.resources.v2018_02_01.models.GenericResource] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = kwargs.pop("params", {}) or {} + + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.GenericResource] + polling = kwargs.pop("polling", True) # type: Union[bool, PollingMethod] + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token = kwargs.pop("continuation_token", None) # type: Optional[str] if cont_token is None: - raw_result = self._create_or_update_by_id_initial( + raw_result = self._create_or_update_by_id_initial( # type: ignore resource_id=resource_id, api_version=api_version, parameters=parameters, content_type=content_type, - cls=lambda x,y,z: x, + cls=lambda x, y, z: x, + headers=_headers, + params=_params, **kwargs ) - kwargs.pop('error_map', None) + kwargs.pop("error_map", None) def get_long_running_output(pipeline_response): - response = pipeline_response.http_response - deserialized = self._deserialize('GenericResource', pipeline_response) + deserialized = self._deserialize("GenericResource", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - - if polling is True: polling_method = ARMPolling(lro_delay, **kwargs) - elif polling is False: polling_method = NoPolling() - else: polling_method = polling + if polling is True: + polling_method = cast(PollingMethod, ARMPolling(lro_delay, **kwargs)) # type: PollingMethod + elif polling is False: + polling_method = cast(PollingMethod, NoPolling()) + else: + polling_method = polling if cont_token: return LROPoller.from_continuation_token( polling_method=polling_method, continuation_token=cont_token, client=self._client, - deserialization_callback=get_long_running_output + deserialization_callback=get_long_running_output, ) return LROPoller(self._client, raw_result, get_long_running_output, polling_method) - begin_create_or_update_by_id.metadata = {'url': "/{resourceId}"} # type: ignore + begin_create_or_update_by_id.metadata = {"url": "/{resourceId}"} # type: ignore def _update_by_id_initial( - self, - resource_id: str, - api_version: str, - parameters: "_models.GenericResource", - **kwargs: Any - ) -> Optional["_models.GenericResource"]: - cls = kwargs.pop('cls', None) # type: ClsType[Optional["_models.GenericResource"]] + self, resource_id: str, api_version: str, parameters: Union[_models.GenericResource, IO], **kwargs: Any + ) -> Optional[_models.GenericResource]: error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = kwargs.pop("params", {}) or {} - _json = self._serialize.body(parameters, 'GenericResource') + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[Optional[_models.GenericResource]] - request = build_resources_update_by_id_request_initial( + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(parameters, (IO, bytes)): + _content = parameters + else: + _json = self._serialize.body(parameters, "GenericResource") + + request = build_resources_update_by_id_request( resource_id=resource_id, - content_type=content_type, api_version=api_version, + content_type=content_type, json=_json, - template_url=self._update_by_id_initial.metadata['url'], + content=_content, + template_url=self._update_by_id_initial.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200, 202]: @@ -3827,34 +4314,39 @@ def _update_by_id_initial( deserialized = None if response.status_code == 200: - deserialized = self._deserialize('GenericResource', pipeline_response) + deserialized = self._deserialize("GenericResource", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - _update_by_id_initial.metadata = {'url': "/{resourceId}"} # type: ignore + _update_by_id_initial.metadata = {"url": "/{resourceId}"} # type: ignore - - @distributed_trace + @overload def begin_update_by_id( self, resource_id: str, api_version: str, - parameters: "_models.GenericResource", + parameters: _models.GenericResource, + *, + content_type: str = "application/json", **kwargs: Any - ) -> LROPoller["_models.GenericResource"]: + ) -> LROPoller[_models.GenericResource]: """Updates a resource by ID. :param resource_id: The fully qualified ID of the resource, including the resource name and resource type. Use the format, /subscriptions/{guid}/resourceGroups/{resource-group-name}/{resource-provider-namespace}/{resource-type}/{resource-name}. + Required. :type resource_id: str - :param api_version: The API version to use for the operation. + :param api_version: The API version to use for the operation. Required. :type api_version: str - :param parameters: Update resource parameters. + :param parameters: Update resource parameters. Required. :type parameters: ~azure.mgmt.resource.resources.v2018_02_01.models.GenericResource + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str :keyword callable cls: A custom type or function that will be passed the direct response :keyword str continuation_token: A continuation token to restart a poller from a saved state. :keyword polling: By default, your polling method will be ARMPolling. Pass in False for this @@ -3867,165 +4359,243 @@ def begin_update_by_id( cls(response) :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.resource.resources.v2018_02_01.models.GenericResource] - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] - polling = kwargs.pop('polling', True) # type: Union[bool, PollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType["_models.GenericResource"] - lro_delay = kwargs.pop( - 'polling_interval', - self._config.polling_interval - ) - cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] + + @overload + def begin_update_by_id( + self, + resource_id: str, + api_version: str, + parameters: IO, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> LROPoller[_models.GenericResource]: + """Updates a resource by ID. + + :param resource_id: The fully qualified ID of the resource, including the resource name and + resource type. Use the format, + /subscriptions/{guid}/resourceGroups/{resource-group-name}/{resource-provider-namespace}/{resource-type}/{resource-name}. + Required. + :type resource_id: str + :param api_version: The API version to use for the operation. Required. + :type api_version: str + :param parameters: Update resource parameters. Required. + :type parameters: IO + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be ARMPolling. Pass in False for this + operation to not poll, or pass in your own initialized polling object for a personal polling + strategy. + :paramtype polling: bool or ~azure.core.polling.PollingMethod + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of LROPoller that returns either GenericResource or the result of + cls(response) + :rtype: + ~azure.core.polling.LROPoller[~azure.mgmt.resource.resources.v2018_02_01.models.GenericResource] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace + def begin_update_by_id( + self, resource_id: str, api_version: str, parameters: Union[_models.GenericResource, IO], **kwargs: Any + ) -> LROPoller[_models.GenericResource]: + """Updates a resource by ID. + + :param resource_id: The fully qualified ID of the resource, including the resource name and + resource type. Use the format, + /subscriptions/{guid}/resourceGroups/{resource-group-name}/{resource-provider-namespace}/{resource-type}/{resource-name}. + Required. + :type resource_id: str + :param api_version: The API version to use for the operation. Required. + :type api_version: str + :param parameters: Update resource parameters. Is either a model type or a IO type. Required. + :type parameters: ~azure.mgmt.resource.resources.v2018_02_01.models.GenericResource or IO + :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. + Default value is None. + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be ARMPolling. Pass in False for this + operation to not poll, or pass in your own initialized polling object for a personal polling + strategy. + :paramtype polling: bool or ~azure.core.polling.PollingMethod + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of LROPoller that returns either GenericResource or the result of + cls(response) + :rtype: + ~azure.core.polling.LROPoller[~azure.mgmt.resource.resources.v2018_02_01.models.GenericResource] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = kwargs.pop("params", {}) or {} + + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.GenericResource] + polling = kwargs.pop("polling", True) # type: Union[bool, PollingMethod] + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token = kwargs.pop("continuation_token", None) # type: Optional[str] if cont_token is None: - raw_result = self._update_by_id_initial( + raw_result = self._update_by_id_initial( # type: ignore resource_id=resource_id, api_version=api_version, parameters=parameters, content_type=content_type, - cls=lambda x,y,z: x, + cls=lambda x, y, z: x, + headers=_headers, + params=_params, **kwargs ) - kwargs.pop('error_map', None) + kwargs.pop("error_map", None) def get_long_running_output(pipeline_response): - response = pipeline_response.http_response - deserialized = self._deserialize('GenericResource', pipeline_response) + deserialized = self._deserialize("GenericResource", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - - if polling is True: polling_method = ARMPolling(lro_delay, **kwargs) - elif polling is False: polling_method = NoPolling() - else: polling_method = polling + if polling is True: + polling_method = cast(PollingMethod, ARMPolling(lro_delay, **kwargs)) # type: PollingMethod + elif polling is False: + polling_method = cast(PollingMethod, NoPolling()) + else: + polling_method = polling if cont_token: return LROPoller.from_continuation_token( polling_method=polling_method, continuation_token=cont_token, client=self._client, - deserialization_callback=get_long_running_output + deserialization_callback=get_long_running_output, ) return LROPoller(self._client, raw_result, get_long_running_output, polling_method) - begin_update_by_id.metadata = {'url': "/{resourceId}"} # type: ignore + begin_update_by_id.metadata = {"url": "/{resourceId}"} # type: ignore @distributed_trace - def get_by_id( - self, - resource_id: str, - api_version: str, - **kwargs: Any - ) -> "_models.GenericResource": + def get_by_id(self, resource_id: str, api_version: str, **kwargs: Any) -> _models.GenericResource: """Gets a resource by ID. :param resource_id: The fully qualified ID of the resource, including the resource name and resource type. Use the format, /subscriptions/{guid}/resourceGroups/{resource-group-name}/{resource-provider-namespace}/{resource-type}/{resource-name}. + Required. :type resource_id: str - :param api_version: The API version to use for the operation. + :param api_version: The API version to use for the operation. Required. :type api_version: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: GenericResource, or the result of cls(response) + :return: GenericResource or the result of cls(response) :rtype: ~azure.mgmt.resource.resources.v2018_02_01.models.GenericResource - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.GenericResource"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = kwargs.pop("params", {}) or {} + + cls = kwargs.pop("cls", None) # type: ClsType[_models.GenericResource] - request = build_resources_get_by_id_request( resource_id=resource_id, api_version=api_version, - template_url=self.get_by_id.metadata['url'], + template_url=self.get_by_id.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) - deserialized = self._deserialize('GenericResource', pipeline_response) + deserialized = self._deserialize("GenericResource", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - get_by_id.metadata = {'url': "/{resourceId}"} # type: ignore + get_by_id.metadata = {"url": "/{resourceId}"} # type: ignore -class ResourceGroupsOperations(object): - """ResourceGroupsOperations operations. - You should not instantiate this class directly. Instead, you should create a Client instance that - instantiates it for you and attaches it as an attribute. +class ResourceGroupsOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. - :ivar models: Alias to model classes used in this operation group. - :type models: ~azure.mgmt.resource.resources.v2018_02_01.models - :param client: Client for service requests. - :param config: Configuration of service client. - :param serializer: An object model serializer. - :param deserializer: An object model deserializer. + Instead, you should access the following operations through + :class:`~azure.mgmt.resource.resources.v2018_02_01.ResourceManagementClient`'s + :attr:`resource_groups` attribute. """ models = _models - def __init__(self, client, config, serializer, deserializer): - self._client = client - self._serialize = serializer - self._deserialize = deserializer - self._config = config + def __init__(self, *args, **kwargs): + input_args = list(args) + self._client = input_args.pop(0) if input_args else kwargs.pop("client") + self._config = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") @distributed_trace - def check_existence( - self, - resource_group_name: str, - **kwargs: Any - ) -> bool: + def check_existence(self, resource_group_name: str, **kwargs: Any) -> bool: """Checks whether a resource group exists. :param resource_group_name: The name of the resource group to check. The name is case - insensitive. + insensitive. Required. :type resource_group_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: bool, or the result of cls(response) + :return: bool or the result of cls(response) :rtype: bool - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType[None] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) - api_version = kwargs.pop('api_version', "2018-02-01") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2018-02-01")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[None] - request = build_resource_groups_check_existence_request( resource_group_name=resource_group_name, subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.check_existence.metadata['url'], + template_url=self.check_existence.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [204, 404]: @@ -4036,37 +4606,92 @@ def check_existence( return cls(pipeline_response, None, {}) return 200 <= response.status_code <= 299 - check_existence.metadata = {'url': "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}"} # type: ignore + check_existence.metadata = {"url": "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}"} # type: ignore - - @distributed_trace + @overload def create_or_update( self, resource_group_name: str, - parameters: "_models.ResourceGroup", + parameters: _models.ResourceGroup, + *, + content_type: str = "application/json", **kwargs: Any - ) -> "_models.ResourceGroup": + ) -> _models.ResourceGroup: """Creates or updates a resource group. - :param resource_group_name: The name of the resource group to create or update. + :param resource_group_name: The name of the resource group to create or update. Required. :type resource_group_name: str - :param parameters: Parameters supplied to the create or update a resource group. + :param parameters: Parameters supplied to the create or update a resource group. Required. :type parameters: ~azure.mgmt.resource.resources.v2018_02_01.models.ResourceGroup + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: ResourceGroup or the result of cls(response) + :rtype: ~azure.mgmt.resource.resources.v2018_02_01.models.ResourceGroup + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + def create_or_update( + self, resource_group_name: str, parameters: IO, *, content_type: str = "application/json", **kwargs: Any + ) -> _models.ResourceGroup: + """Creates or updates a resource group. + + :param resource_group_name: The name of the resource group to create or update. Required. + :type resource_group_name: str + :param parameters: Parameters supplied to the create or update a resource group. Required. + :type parameters: IO + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: ResourceGroup or the result of cls(response) + :rtype: ~azure.mgmt.resource.resources.v2018_02_01.models.ResourceGroup + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace + def create_or_update( + self, resource_group_name: str, parameters: Union[_models.ResourceGroup, IO], **kwargs: Any + ) -> _models.ResourceGroup: + """Creates or updates a resource group. + + :param resource_group_name: The name of the resource group to create or update. Required. + :type resource_group_name: str + :param parameters: Parameters supplied to the create or update a resource group. Is either a + model type or a IO type. Required. + :type parameters: ~azure.mgmt.resource.resources.v2018_02_01.models.ResourceGroup or IO + :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. + Default value is None. + :paramtype content_type: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: ResourceGroup, or the result of cls(response) + :return: ResourceGroup or the result of cls(response) :rtype: ~azure.mgmt.resource.resources.v2018_02_01.models.ResourceGroup - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.ResourceGroup"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) - api_version = kwargs.pop('api_version', "2018-02-01") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - _json = self._serialize.body(parameters, 'ResourceGroup') + api_version = kwargs.pop("api_version", _params.pop("api-version", "2018-02-01")) # type: str + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.ResourceGroup] + + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(parameters, (IO, bytes)): + _content = parameters + else: + _json = self._serialize.body(parameters, "ResourceGroup") request = build_resource_groups_create_or_update_request( resource_group_name=resource_group_name, @@ -4074,16 +4699,18 @@ def create_or_update( api_version=api_version, content_type=content_type, json=_json, - template_url=self.create_or_update.metadata['url'], + content=_content, + template_url=self.create_or_update.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200, 201]: @@ -4091,47 +4718,50 @@ def create_or_update( raise HttpResponseError(response=response, error_format=ARMErrorFormat) if response.status_code == 200: - deserialized = self._deserialize('ResourceGroup', pipeline_response) + deserialized = self._deserialize("ResourceGroup", pipeline_response) if response.status_code == 201: - deserialized = self._deserialize('ResourceGroup', pipeline_response) + deserialized = self._deserialize("ResourceGroup", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - create_or_update.metadata = {'url': "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}"} # type: ignore - + create_or_update.metadata = {"url": "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}"} # type: ignore def _delete_initial( # pylint: disable=inconsistent-return-statements - self, - resource_group_name: str, - **kwargs: Any + self, resource_group_name: str, **kwargs: Any ) -> None: - cls = kwargs.pop('cls', None) # type: ClsType[None] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) - api_version = kwargs.pop('api_version', "2018-02-01") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - request = build_resource_groups_delete_request_initial( + api_version = kwargs.pop("api_version", _params.pop("api-version", "2018-02-01")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[None] + + request = build_resource_groups_delete_request( resource_group_name=resource_group_name, subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self._delete_initial.metadata['url'], + template_url=self._delete_initial.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200, 202]: @@ -4141,22 +4771,17 @@ def _delete_initial( # pylint: disable=inconsistent-return-statements if cls: return cls(pipeline_response, None, {}) - _delete_initial.metadata = {'url': "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}"} # type: ignore - + _delete_initial.metadata = {"url": "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}"} # type: ignore @distributed_trace - def begin_delete( # pylint: disable=inconsistent-return-statements - self, - resource_group_name: str, - **kwargs: Any - ) -> LROPoller[None]: + def begin_delete(self, resource_group_name: str, **kwargs: Any) -> LROPoller[None]: """Deletes a resource group. When you delete a resource group, all of its resources are also deleted. Deleting a resource group deletes all of its template deployments and currently stored operations. :param resource_group_name: The name of the resource group to delete. The name is case - insensitive. + insensitive. Required. :type resource_group_name: str :keyword callable cls: A custom type or function that will be passed the direct response :keyword str continuation_token: A continuation token to restart a poller from a saved state. @@ -4168,106 +4793,113 @@ def begin_delete( # pylint: disable=inconsistent-return-statements Retry-After header is present. :return: An instance of LROPoller that returns either None or the result of cls(response) :rtype: ~azure.core.polling.LROPoller[None] - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - api_version = kwargs.pop('api_version', "2018-02-01") # type: str - polling = kwargs.pop('polling', True) # type: Union[bool, PollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType[None] - lro_delay = kwargs.pop( - 'polling_interval', - self._config.polling_interval - ) - cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2018-02-01")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[None] + polling = kwargs.pop("polling", True) # type: Union[bool, PollingMethod] + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token = kwargs.pop("continuation_token", None) # type: Optional[str] if cont_token is None: - raw_result = self._delete_initial( + raw_result = self._delete_initial( # type: ignore resource_group_name=resource_group_name, api_version=api_version, - cls=lambda x,y,z: x, + cls=lambda x, y, z: x, + headers=_headers, + params=_params, **kwargs ) - kwargs.pop('error_map', None) + kwargs.pop("error_map", None) - def get_long_running_output(pipeline_response): + def get_long_running_output(pipeline_response): # pylint: disable=inconsistent-return-statements if cls: return cls(pipeline_response, None, {}) - - if polling is True: polling_method = ARMPolling(lro_delay, **kwargs) - elif polling is False: polling_method = NoPolling() - else: polling_method = polling + if polling is True: + polling_method = cast(PollingMethod, ARMPolling(lro_delay, **kwargs)) # type: PollingMethod + elif polling is False: + polling_method = cast(PollingMethod, NoPolling()) + else: + polling_method = polling if cont_token: return LROPoller.from_continuation_token( polling_method=polling_method, continuation_token=cont_token, client=self._client, - deserialization_callback=get_long_running_output + deserialization_callback=get_long_running_output, ) return LROPoller(self._client, raw_result, get_long_running_output, polling_method) - begin_delete.metadata = {'url': "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}"} # type: ignore + begin_delete.metadata = {"url": "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}"} # type: ignore @distributed_trace - def get( - self, - resource_group_name: str, - **kwargs: Any - ) -> "_models.ResourceGroup": + def get(self, resource_group_name: str, **kwargs: Any) -> _models.ResourceGroup: """Gets a resource group. :param resource_group_name: The name of the resource group to get. The name is case - insensitive. + insensitive. Required. :type resource_group_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: ResourceGroup, or the result of cls(response) + :return: ResourceGroup or the result of cls(response) :rtype: ~azure.mgmt.resource.resources.v2018_02_01.models.ResourceGroup - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.ResourceGroup"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) - api_version = kwargs.pop('api_version', "2018-02-01") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2018-02-01")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[_models.ResourceGroup] - request = build_resource_groups_get_request( resource_group_name=resource_group_name, subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.get.metadata['url'], + template_url=self.get.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) - deserialized = self._deserialize('ResourceGroup', pipeline_response) + deserialized = self._deserialize("ResourceGroup", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - get.metadata = {'url': "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}"} # type: ignore + get.metadata = {"url": "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}"} # type: ignore - - @distributed_trace + @overload def update( self, resource_group_name: str, - parameters: "_models.ResourceGroupPatchable", + parameters: _models.ResourceGroupPatchable, + *, + content_type: str = "application/json", **kwargs: Any - ) -> "_models.ResourceGroup": + ) -> _models.ResourceGroup: """Updates a resource group. Resource groups can be updated through a simple PATCH operation to a group address. The format @@ -4275,25 +4907,90 @@ def update( the current value is retained. :param resource_group_name: The name of the resource group to update. The name is case - insensitive. + insensitive. Required. :type resource_group_name: str - :param parameters: Parameters supplied to update a resource group. + :param parameters: Parameters supplied to update a resource group. Required. :type parameters: ~azure.mgmt.resource.resources.v2018_02_01.models.ResourceGroupPatchable + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: ResourceGroup or the result of cls(response) + :rtype: ~azure.mgmt.resource.resources.v2018_02_01.models.ResourceGroup + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + def update( + self, resource_group_name: str, parameters: IO, *, content_type: str = "application/json", **kwargs: Any + ) -> _models.ResourceGroup: + """Updates a resource group. + + Resource groups can be updated through a simple PATCH operation to a group address. The format + of the request is the same as that for creating a resource group. If a field is unspecified, + the current value is retained. + + :param resource_group_name: The name of the resource group to update. The name is case + insensitive. Required. + :type resource_group_name: str + :param parameters: Parameters supplied to update a resource group. Required. + :type parameters: IO + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: ResourceGroup or the result of cls(response) + :rtype: ~azure.mgmt.resource.resources.v2018_02_01.models.ResourceGroup + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace + def update( + self, resource_group_name: str, parameters: Union[_models.ResourceGroupPatchable, IO], **kwargs: Any + ) -> _models.ResourceGroup: + """Updates a resource group. + + Resource groups can be updated through a simple PATCH operation to a group address. The format + of the request is the same as that for creating a resource group. If a field is unspecified, + the current value is retained. + + :param resource_group_name: The name of the resource group to update. The name is case + insensitive. Required. + :type resource_group_name: str + :param parameters: Parameters supplied to update a resource group. Is either a model type or a + IO type. Required. + :type parameters: ~azure.mgmt.resource.resources.v2018_02_01.models.ResourceGroupPatchable or + IO + :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. + Default value is None. + :paramtype content_type: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: ResourceGroup, or the result of cls(response) + :return: ResourceGroup or the result of cls(response) :rtype: ~azure.mgmt.resource.resources.v2018_02_01.models.ResourceGroup - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.ResourceGroup"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) - api_version = kwargs.pop('api_version', "2018-02-01") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - _json = self._serialize.body(parameters, 'ResourceGroupPatchable') + api_version = kwargs.pop("api_version", _params.pop("api-version", "2018-02-01")) # type: str + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.ResourceGroup] + + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(parameters, (IO, bytes)): + _content = parameters + else: + _json = self._serialize.body(parameters, "ResourceGroupPatchable") request = build_resource_groups_update_request( resource_group_name=resource_group_name, @@ -4301,60 +4998,117 @@ def update( api_version=api_version, content_type=content_type, json=_json, - template_url=self.update.metadata['url'], + content=_content, + template_url=self.update.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) - deserialized = self._deserialize('ResourceGroup', pipeline_response) + deserialized = self._deserialize("ResourceGroup", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - update.metadata = {'url': "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}"} # type: ignore + update.metadata = {"url": "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}"} # type: ignore - - @distributed_trace + @overload def export_template( self, resource_group_name: str, - parameters: "_models.ExportTemplateRequest", + parameters: _models.ExportTemplateRequest, + *, + content_type: str = "application/json", **kwargs: Any - ) -> "_models.ResourceGroupExportResult": + ) -> _models.ResourceGroupExportResult: """Captures the specified resource group as a template. - :param resource_group_name: The name of the resource group to export as a template. + :param resource_group_name: The name of the resource group to export as a template. Required. :type resource_group_name: str - :param parameters: Parameters for exporting the template. + :param parameters: Parameters for exporting the template. Required. :type parameters: ~azure.mgmt.resource.resources.v2018_02_01.models.ExportTemplateRequest + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: ResourceGroupExportResult or the result of cls(response) + :rtype: ~azure.mgmt.resource.resources.v2018_02_01.models.ResourceGroupExportResult + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + def export_template( + self, resource_group_name: str, parameters: IO, *, content_type: str = "application/json", **kwargs: Any + ) -> _models.ResourceGroupExportResult: + """Captures the specified resource group as a template. + + :param resource_group_name: The name of the resource group to export as a template. Required. + :type resource_group_name: str + :param parameters: Parameters for exporting the template. Required. + :type parameters: IO + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: ResourceGroupExportResult or the result of cls(response) + :rtype: ~azure.mgmt.resource.resources.v2018_02_01.models.ResourceGroupExportResult + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace + def export_template( + self, resource_group_name: str, parameters: Union[_models.ExportTemplateRequest, IO], **kwargs: Any + ) -> _models.ResourceGroupExportResult: + """Captures the specified resource group as a template. + + :param resource_group_name: The name of the resource group to export as a template. Required. + :type resource_group_name: str + :param parameters: Parameters for exporting the template. Is either a model type or a IO type. + Required. + :type parameters: ~azure.mgmt.resource.resources.v2018_02_01.models.ExportTemplateRequest or IO + :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. + Default value is None. + :paramtype content_type: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: ResourceGroupExportResult, or the result of cls(response) + :return: ResourceGroupExportResult or the result of cls(response) :rtype: ~azure.mgmt.resource.resources.v2018_02_01.models.ResourceGroupExportResult - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.ResourceGroupExportResult"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) - api_version = kwargs.pop('api_version', "2018-02-01") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - _json = self._serialize.body(parameters, 'ExportTemplateRequest') + api_version = kwargs.pop("api_version", _params.pop("api-version", "2018-02-01")) # type: str + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.ResourceGroupExportResult] + + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(parameters, (IO, bytes)): + _content = parameters + else: + _json = self._serialize.body(parameters, "ExportTemplateRequest") request = build_resource_groups_export_template_request( resource_group_name=resource_group_name, @@ -4362,39 +5116,37 @@ def export_template( api_version=api_version, content_type=content_type, json=_json, - template_url=self.export_template.metadata['url'], + content=_content, + template_url=self.export_template.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) - deserialized = self._deserialize('ResourceGroupExportResult', pipeline_response) + deserialized = self._deserialize("ResourceGroupExportResult", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - export_template.metadata = {'url': "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/exportTemplate"} # type: ignore - + export_template.metadata = {"url": "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/exportTemplate"} # type: ignore @distributed_trace def list( - self, - filter: Optional[str] = None, - top: Optional[int] = None, - **kwargs: Any - ) -> Iterable["_models.ResourceGroupListResult"]: + self, filter: Optional[str] = None, top: Optional[int] = None, **kwargs: Any + ) -> Iterable["_models.ResourceGroup"]: """Gets all the resource groups for a subscription. :param filter: The filter to apply on the operation. Default value is None. @@ -4403,40 +5155,48 @@ def list( Default value is None. :type top: int :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either ResourceGroupListResult or the result of - cls(response) + :return: An iterator like instance of either ResourceGroup or the result of cls(response) :rtype: - ~azure.core.paging.ItemPaged[~azure.mgmt.resource.resources.v2018_02_01.models.ResourceGroupListResult] - :raises: ~azure.core.exceptions.HttpResponseError + ~azure.core.paging.ItemPaged[~azure.mgmt.resource.resources.v2018_02_01.models.ResourceGroup] + :raises ~azure.core.exceptions.HttpResponseError: """ - api_version = kwargs.pop('api_version', "2018-02-01") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2018-02-01")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[_models.ResourceGroupListResult] - cls = kwargs.pop('cls', None) # type: ClsType["_models.ResourceGroupListResult"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) + def prepare_request(next_link=None): if not next_link: - + request = build_resource_groups_list_request( subscription_id=self._config.subscription_id, - api_version=api_version, filter=filter, top=top, - template_url=self.list.metadata['url'], + 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.url = self._client.format_url(request.url) # type: ignore else: - - request = build_resource_groups_list_request( - subscription_id=self._config.subscription_id, - template_url=next_link, - ) + # make call to next link with the client's api-version + _parsed_next_link = urlparse(next_link) + _next_request_params = case_insensitive_dict(parse_qs(_parsed_next_link.query)) + _next_request_params["api-version"] = self._config.api_version + request = HttpRequest("GET", urljoin(next_link, _parsed_next_link.path), params=_next_request_params) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore request.method = "GET" return request @@ -4450,10 +5210,8 @@ def extract_data(pipeline_response): def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) response = pipeline_response.http_response @@ -4463,75 +5221,75 @@ def get_next(next_link=None): return pipeline_response + return ItemPaged(get_next, extract_data) - return ItemPaged( - get_next, extract_data - ) - list.metadata = {'url': "/subscriptions/{subscriptionId}/resourcegroups"} # type: ignore -class TagsOperations(object): - """TagsOperations operations. - - You should not instantiate this class directly. Instead, you should create a Client instance that - instantiates it for you and attaches it as an attribute. - - :ivar models: Alias to model classes used in this operation group. - :type models: ~azure.mgmt.resource.resources.v2018_02_01.models - :param client: Client for service requests. - :param config: Configuration of service client. - :param serializer: An object model serializer. - :param deserializer: An object model deserializer. + list.metadata = {"url": "/subscriptions/{subscriptionId}/resourcegroups"} # type: ignore + + +class TagsOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. + + Instead, you should access the following operations through + :class:`~azure.mgmt.resource.resources.v2018_02_01.ResourceManagementClient`'s + :attr:`tags` attribute. """ models = _models - def __init__(self, client, config, serializer, deserializer): - self._client = client - self._serialize = serializer - self._deserialize = deserializer - self._config = config + def __init__(self, *args, **kwargs): + input_args = list(args) + self._client = input_args.pop(0) if input_args else kwargs.pop("client") + self._config = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") @distributed_trace def delete_value( # pylint: disable=inconsistent-return-statements - self, - tag_name: str, - tag_value: str, - **kwargs: Any + self, tag_name: str, tag_value: str, **kwargs: Any ) -> None: """Deletes a tag value. - :param tag_name: The name of the tag. + :param tag_name: The name of the tag. Required. :type tag_name: str - :param tag_value: The value of the tag to delete. + :param tag_value: The value of the tag to delete. Required. :type tag_value: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: None, or the result of cls(response) + :return: None or the result of cls(response) :rtype: None - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType[None] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) - api_version = kwargs.pop('api_version', "2018-02-01") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2018-02-01")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[None] - request = build_tags_delete_value_request( tag_name=tag_name, tag_value=tag_value, subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.delete_value.metadata['url'], + template_url=self.delete_value.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200, 204]: @@ -4541,51 +5299,51 @@ def delete_value( # pylint: disable=inconsistent-return-statements if cls: return cls(pipeline_response, None, {}) - delete_value.metadata = {'url': "/subscriptions/{subscriptionId}/tagNames/{tagName}/tagValues/{tagValue}"} # type: ignore - + delete_value.metadata = {"url": "/subscriptions/{subscriptionId}/tagNames/{tagName}/tagValues/{tagValue}"} # type: ignore @distributed_trace - def create_or_update_value( - self, - tag_name: str, - tag_value: str, - **kwargs: Any - ) -> "_models.TagValue": + def create_or_update_value(self, tag_name: str, tag_value: str, **kwargs: Any) -> _models.TagValue: """Creates a tag value. The name of the tag must already exist. - :param tag_name: The name of the tag. + :param tag_name: The name of the tag. Required. :type tag_name: str - :param tag_value: The value of the tag to create. + :param tag_value: The value of the tag to create. Required. :type tag_value: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: TagValue, or the result of cls(response) + :return: TagValue or the result of cls(response) :rtype: ~azure.mgmt.resource.resources.v2018_02_01.models.TagValue - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.TagValue"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + 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', "2018-02-01") # type: str + api_version = kwargs.pop("api_version", _params.pop("api-version", "2018-02-01")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[_models.TagValue] - request = build_tags_create_or_update_value_request( tag_name=tag_name, tag_value=tag_value, subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.create_or_update_value.metadata['url'], + template_url=self.create_or_update_value.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200, 201]: @@ -4593,61 +5351,62 @@ def create_or_update_value( raise HttpResponseError(response=response, error_format=ARMErrorFormat) if response.status_code == 200: - deserialized = self._deserialize('TagValue', pipeline_response) + deserialized = self._deserialize("TagValue", pipeline_response) if response.status_code == 201: - deserialized = self._deserialize('TagValue', pipeline_response) + deserialized = self._deserialize("TagValue", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - create_or_update_value.metadata = {'url': "/subscriptions/{subscriptionId}/tagNames/{tagName}/tagValues/{tagValue}"} # type: ignore - + create_or_update_value.metadata = {"url": "/subscriptions/{subscriptionId}/tagNames/{tagName}/tagValues/{tagValue}"} # type: ignore @distributed_trace - def create_or_update( - self, - tag_name: str, - **kwargs: Any - ) -> "_models.TagDetails": + def create_or_update(self, tag_name: str, **kwargs: Any) -> _models.TagDetails: """Creates a tag in the subscription. The tag name can have a maximum of 512 characters and is case insensitive. Tag names created by Azure have prefixes of microsoft, azure, or windows. You cannot create tags with one of these prefixes. - :param tag_name: The name of the tag to create. + :param tag_name: The name of the tag to create. Required. :type tag_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: TagDetails, or the result of cls(response) + :return: TagDetails or the result of cls(response) :rtype: ~azure.mgmt.resource.resources.v2018_02_01.models.TagDetails - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.TagDetails"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + 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', "2018-02-01") # type: str + api_version = kwargs.pop("api_version", _params.pop("api-version", "2018-02-01")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[_models.TagDetails] - request = build_tags_create_or_update_request( tag_name=tag_name, subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.create_or_update.metadata['url'], + template_url=self.create_or_update.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200, 201]: @@ -4655,59 +5414,60 @@ def create_or_update( raise HttpResponseError(response=response, error_format=ARMErrorFormat) if response.status_code == 200: - deserialized = self._deserialize('TagDetails', pipeline_response) + deserialized = self._deserialize("TagDetails", pipeline_response) if response.status_code == 201: - deserialized = self._deserialize('TagDetails', pipeline_response) + deserialized = self._deserialize("TagDetails", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - create_or_update.metadata = {'url': "/subscriptions/{subscriptionId}/tagNames/{tagName}"} # type: ignore - + create_or_update.metadata = {"url": "/subscriptions/{subscriptionId}/tagNames/{tagName}"} # type: ignore @distributed_trace - def delete( # pylint: disable=inconsistent-return-statements - self, - tag_name: str, - **kwargs: Any - ) -> None: + def delete(self, tag_name: str, **kwargs: Any) -> None: # pylint: disable=inconsistent-return-statements """Deletes a tag from the subscription. You must remove all values from a resource tag before you can delete it. - :param tag_name: The name of the tag. + :param tag_name: The name of the tag. Required. :type tag_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: None, or the result of cls(response) + :return: None or the result of cls(response) :rtype: None - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType[None] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + 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', "2018-02-01") # type: str + api_version = kwargs.pop("api_version", _params.pop("api-version", "2018-02-01")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[None] - request = build_tags_delete_request( tag_name=tag_name, subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.delete.metadata['url'], + template_url=self.delete.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200, 204]: @@ -4717,48 +5477,53 @@ def delete( # pylint: disable=inconsistent-return-statements if cls: return cls(pipeline_response, None, {}) - delete.metadata = {'url': "/subscriptions/{subscriptionId}/tagNames/{tagName}"} # type: ignore - + delete.metadata = {"url": "/subscriptions/{subscriptionId}/tagNames/{tagName}"} # type: ignore @distributed_trace - def list( - self, - **kwargs: Any - ) -> Iterable["_models.TagsListResult"]: + def list(self, **kwargs: Any) -> Iterable["_models.TagDetails"]: """Gets the names and values of all resource tags that are defined in a subscription. :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either TagsListResult or the result of cls(response) + :return: An iterator like instance of either TagDetails or the result of cls(response) :rtype: - ~azure.core.paging.ItemPaged[~azure.mgmt.resource.resources.v2018_02_01.models.TagsListResult] - :raises: ~azure.core.exceptions.HttpResponseError + ~azure.core.paging.ItemPaged[~azure.mgmt.resource.resources.v2018_02_01.models.TagDetails] + :raises ~azure.core.exceptions.HttpResponseError: """ - api_version = kwargs.pop('api_version', "2018-02-01") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2018-02-01")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[_models.TagsListResult] - cls = kwargs.pop('cls', None) # type: ClsType["_models.TagsListResult"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) + def prepare_request(next_link=None): if not next_link: - + request = build_tags_list_request( subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.list.metadata['url'], + template_url=self.list.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore else: - - request = build_tags_list_request( - subscription_id=self._config.subscription_id, - template_url=next_link, - ) + # make call to next link with the client's api-version + _parsed_next_link = urlparse(next_link) + _next_request_params = case_insensitive_dict(parse_qs(_parsed_next_link.query)) + _next_request_params["api-version"] = self._config.api_version + request = HttpRequest("GET", urljoin(next_link, _parsed_next_link.path), params=_next_request_params) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore request.method = "GET" return request @@ -4772,10 +5537,8 @@ def extract_data(pipeline_response): def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) response = pipeline_response.http_response @@ -4785,149 +5548,151 @@ def get_next(next_link=None): return pipeline_response + return ItemPaged(get_next, extract_data) - return ItemPaged( - get_next, extract_data - ) - list.metadata = {'url': "/subscriptions/{subscriptionId}/tagNames"} # type: ignore -class DeploymentOperationsOperations(object): - """DeploymentOperationsOperations operations. - - You should not instantiate this class directly. Instead, you should create a Client instance that - instantiates it for you and attaches it as an attribute. - - :ivar models: Alias to model classes used in this operation group. - :type models: ~azure.mgmt.resource.resources.v2018_02_01.models - :param client: Client for service requests. - :param config: Configuration of service client. - :param serializer: An object model serializer. - :param deserializer: An object model deserializer. + list.metadata = {"url": "/subscriptions/{subscriptionId}/tagNames"} # type: ignore + + +class DeploymentOperationsOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. + + Instead, you should access the following operations through + :class:`~azure.mgmt.resource.resources.v2018_02_01.ResourceManagementClient`'s + :attr:`deployment_operations` attribute. """ models = _models - def __init__(self, client, config, serializer, deserializer): - self._client = client - self._serialize = serializer - self._deserialize = deserializer - self._config = config + def __init__(self, *args, **kwargs): + input_args = list(args) + self._client = input_args.pop(0) if input_args else kwargs.pop("client") + self._config = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") @distributed_trace def get( - self, - resource_group_name: str, - deployment_name: str, - operation_id: str, - **kwargs: Any - ) -> "_models.DeploymentOperation": + self, resource_group_name: str, deployment_name: str, operation_id: str, **kwargs: Any + ) -> _models.DeploymentOperation: """Gets a deployments operation. :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. :type resource_group_name: str - :param deployment_name: The name of the deployment. + :param deployment_name: The name of the deployment. Required. :type deployment_name: str - :param operation_id: The ID of the operation to get. + :param operation_id: The ID of the operation to get. Required. :type operation_id: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: DeploymentOperation, or the result of cls(response) + :return: DeploymentOperation or the result of cls(response) :rtype: ~azure.mgmt.resource.resources.v2018_02_01.models.DeploymentOperation - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.DeploymentOperation"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + 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', "2018-02-01") # type: str + api_version = kwargs.pop("api_version", _params.pop("api-version", "2018-02-01")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[_models.DeploymentOperation] - request = build_deployment_operations_get_request( resource_group_name=resource_group_name, deployment_name=deployment_name, operation_id=operation_id, subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.get.metadata['url'], + template_url=self.get.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) - deserialized = self._deserialize('DeploymentOperation', pipeline_response) + deserialized = self._deserialize("DeploymentOperation", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - get.metadata = {'url': "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/deployments/{deploymentName}/operations/{operationId}"} # type: ignore - + get.metadata = {"url": "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/deployments/{deploymentName}/operations/{operationId}"} # type: ignore @distributed_trace def list( - self, - resource_group_name: str, - deployment_name: str, - top: Optional[int] = None, - **kwargs: Any - ) -> Iterable["_models.DeploymentOperationsListResult"]: + self, resource_group_name: str, deployment_name: str, top: Optional[int] = None, **kwargs: Any + ) -> Iterable["_models.DeploymentOperation"]: """Gets all deployments operations for a deployment. :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. :type resource_group_name: str - :param deployment_name: The name of the deployment with the operation to get. + :param deployment_name: The name of the deployment with the operation to get. Required. :type deployment_name: str :param top: The number of results to return. Default value is None. :type top: int :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either DeploymentOperationsListResult or the result of - cls(response) + :return: An iterator like instance of either DeploymentOperation or the result of cls(response) :rtype: - ~azure.core.paging.ItemPaged[~azure.mgmt.resource.resources.v2018_02_01.models.DeploymentOperationsListResult] - :raises: ~azure.core.exceptions.HttpResponseError + ~azure.core.paging.ItemPaged[~azure.mgmt.resource.resources.v2018_02_01.models.DeploymentOperation] + :raises ~azure.core.exceptions.HttpResponseError: """ - api_version = kwargs.pop('api_version', "2018-02-01") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2018-02-01")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[_models.DeploymentOperationsListResult] - cls = kwargs.pop('cls', None) # type: ClsType["_models.DeploymentOperationsListResult"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) + def prepare_request(next_link=None): if not next_link: - + request = build_deployment_operations_list_request( resource_group_name=resource_group_name, deployment_name=deployment_name, subscription_id=self._config.subscription_id, - api_version=api_version, top=top, - template_url=self.list.metadata['url'], + 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.url = self._client.format_url(request.url) # type: ignore else: - - request = build_deployment_operations_list_request( - resource_group_name=resource_group_name, - deployment_name=deployment_name, - subscription_id=self._config.subscription_id, - template_url=next_link, - ) + # make call to next link with the client's api-version + _parsed_next_link = urlparse(next_link) + _next_request_params = case_insensitive_dict(parse_qs(_parsed_next_link.query)) + _next_request_params["api-version"] = self._config.api_version + request = HttpRequest("GET", urljoin(next_link, _parsed_next_link.path), params=_next_request_params) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore request.method = "GET" return request @@ -4941,10 +5706,8 @@ def extract_data(pipeline_response): def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) response = pipeline_response.http_response @@ -4954,8 +5717,6 @@ def get_next(next_link=None): return pipeline_response + return ItemPaged(get_next, extract_data) - return ItemPaged( - get_next, extract_data - ) - list.metadata = {'url': "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/deployments/{deploymentName}/operations"} # type: ignore + list.metadata = {"url": "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/deployments/{deploymentName}/operations"} # type: ignore diff --git a/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/resources/v2018_02_01/operations/_patch.py b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/resources/v2018_02_01/operations/_patch.py new file mode 100644 index 0000000000000..f7dd32510333d --- /dev/null +++ b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/resources/v2018_02_01/operations/_patch.py @@ -0,0 +1,20 @@ +# ------------------------------------ +# Copyright (c) Microsoft Corporation. +# Licensed under the MIT License. +# ------------------------------------ +"""Customize generated code here. + +Follow our quickstart for examples: https://aka.ms/azsdk/python/dpcodegen/python/customize +""" +from typing import List + +__all__: List[str] = [] # Add all objects you want publicly available to users at this package level + + +def patch_sdk(): + """Do not remove from this file. + + `patch_sdk` is a last resort escape hatch that allows you to do customizations + you can't accomplish using the techniques described in + https://aka.ms/azsdk/python/dpcodegen/python/customize + """ diff --git a/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/resources/v2018_05_01/__init__.py b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/resources/v2018_05_01/__init__.py index 449220069f2f2..2b201470d075e 100644 --- a/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/resources/v2018_05_01/__init__.py +++ b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/resources/v2018_05_01/__init__.py @@ -10,9 +10,15 @@ from ._version import VERSION __version__ = VERSION -__all__ = ['ResourceManagementClient'] -# `._patch.py` is used for handwritten extensions to the generated code -# Example: https://github.com/Azure/azure-sdk-for-python/blob/main/doc/dev/customize_code/how-to-patch-sdk-code.md -from ._patch import patch_sdk -patch_sdk() +try: + from ._patch import __all__ as _patch_all + from ._patch import * # type: ignore # pylint: disable=unused-wildcard-import +except ImportError: + _patch_all = [] +from ._patch import patch_sdk as _patch_sdk + +__all__ = ["ResourceManagementClient"] +__all__.extend([p for p in _patch_all if p not in __all__]) + +_patch_sdk() diff --git a/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/resources/v2018_05_01/_configuration.py b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/resources/v2018_05_01/_configuration.py index 51862f0b4fa68..f0af5d1244a7d 100644 --- a/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/resources/v2018_05_01/_configuration.py +++ b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/resources/v2018_05_01/_configuration.py @@ -25,23 +25,18 @@ class ResourceManagementClientConfiguration(Configuration): # pylint: disable=t Note that all parameters used to create this instance are saved as instance attributes. - :param credential: Credential needed for the client to connect to Azure. + :param credential: Credential needed for the client to connect to Azure. Required. :type credential: ~azure.core.credentials.TokenCredential - :param subscription_id: The ID of the target subscription. + :param subscription_id: The ID of the target subscription. Required. :type subscription_id: str :keyword api_version: Api Version. Default value is "2018-05-01". Note that overriding this default value may result in unsupported behavior. :paramtype api_version: str """ - def __init__( - self, - credential: "TokenCredential", - subscription_id: str, - **kwargs: Any - ) -> None: + def __init__(self, credential: "TokenCredential", subscription_id: str, **kwargs: Any) -> None: super(ResourceManagementClientConfiguration, self).__init__(**kwargs) - api_version = kwargs.pop('api_version', "2018-05-01") # type: str + api_version = kwargs.pop("api_version", "2018-05-01") # type: str if credential is None: raise ValueError("Parameter 'credential' must not be None.") @@ -51,23 +46,24 @@ def __init__( self.credential = credential self.subscription_id = subscription_id self.api_version = api_version - self.credential_scopes = kwargs.pop('credential_scopes', ['https://management.azure.com/.default']) - kwargs.setdefault('sdk_moniker', 'mgmt-resource/{}'.format(VERSION)) + self.credential_scopes = kwargs.pop("credential_scopes", ["https://management.azure.com/.default"]) + kwargs.setdefault("sdk_moniker", "mgmt-resource/{}".format(VERSION)) self._configure(**kwargs) def _configure( - self, - **kwargs # type: Any + self, **kwargs # type: Any ): # type: (...) -> 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) - self.logging_policy = kwargs.get('logging_policy') or policies.NetworkTraceLoggingPolicy(**kwargs) - self.http_logging_policy = kwargs.get('http_logging_policy') or ARMHttpLoggingPolicy(**kwargs) - self.retry_policy = kwargs.get('retry_policy') or policies.RetryPolicy(**kwargs) - self.custom_hook_policy = kwargs.get('custom_hook_policy') or policies.CustomHookPolicy(**kwargs) - self.redirect_policy = kwargs.get('redirect_policy') or policies.RedirectPolicy(**kwargs) - self.authentication_policy = kwargs.get('authentication_policy') + 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) + self.logging_policy = kwargs.get("logging_policy") or policies.NetworkTraceLoggingPolicy(**kwargs) + self.http_logging_policy = kwargs.get("http_logging_policy") or ARMHttpLoggingPolicy(**kwargs) + self.retry_policy = kwargs.get("retry_policy") or policies.RetryPolicy(**kwargs) + self.custom_hook_policy = kwargs.get("custom_hook_policy") or policies.CustomHookPolicy(**kwargs) + self.redirect_policy = kwargs.get("redirect_policy") or policies.RedirectPolicy(**kwargs) + self.authentication_policy = kwargs.get("authentication_policy") if self.credential and not self.authentication_policy: - self.authentication_policy = ARMChallengeAuthenticationPolicy(self.credential, *self.credential_scopes, **kwargs) + self.authentication_policy = ARMChallengeAuthenticationPolicy( + self.credential, *self.credential_scopes, **kwargs + ) diff --git a/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/resources/v2018_05_01/_metadata.json b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/resources/v2018_05_01/_metadata.json index 02716e05915bb..6ad4b43b5933b 100644 --- a/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/resources/v2018_05_01/_metadata.json +++ b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/resources/v2018_05_01/_metadata.json @@ -10,20 +10,20 @@ "azure_arm": true, "has_lro_operations": true, "client_side_validation": false, - "sync_imports": "{\"typing\": {\"azurecore\": {\"azure.core.credentials\": [\"TokenCredential\"]}}, \"regular\": {\"azurecore\": {\"azure.profiles\": [\"KnownProfiles\", \"ProfileDefinition\"], \"azure.profiles.multiapiclient\": [\"MultiApiClientMixin\"], \"azure.mgmt.core\": [\"ARMPipelineClient\"]}, \"local\": {\"._configuration\": [\"ResourceManagementClientConfiguration\"]}, \"thirdparty\": {\"msrest\": [\"Deserializer\", \"Serializer\"]}}, \"conditional\": {\"stdlib\": {\"typing\": [\"Any\", \"Optional\"]}}}", - "async_imports": "{\"typing\": {\"azurecore\": {\"azure.core.credentials_async\": [\"AsyncTokenCredential\"], \"azure.core.credentials\": [\"TokenCredential\"]}}, \"regular\": {\"azurecore\": {\"azure.profiles\": [\"KnownProfiles\", \"ProfileDefinition\"], \"azure.profiles.multiapiclient\": [\"MultiApiClientMixin\"], \"azure.mgmt.core\": [\"AsyncARMPipelineClient\"]}, \"local\": {\"._configuration\": [\"ResourceManagementClientConfiguration\"]}, \"thirdparty\": {\"msrest\": [\"Deserializer\", \"Serializer\"]}}, \"conditional\": {\"stdlib\": {\"typing\": [\"Any\", \"Optional\"]}}}" + "sync_imports": "{\"conditional\": {\"stdlib\": {\"typing\": [\"Any\", \"Optional\"]}}, \"regular\": {\"azurecore\": {\"azure.mgmt.core\": [\"ARMPipelineClient\"], \"azure.profiles\": [\"KnownProfiles\", \"ProfileDefinition\"], \"azure.profiles.multiapiclient\": [\"MultiApiClientMixin\"]}, \"local\": {\"._configuration\": [\"ResourceManagementClientConfiguration\"], \".._serialization\": [\"Deserializer\", \"Serializer\"]}}, \"typing\": {\"azurecore\": {\"azure.core.credentials\": [\"TokenCredential\"]}}}", + "async_imports": "{\"conditional\": {\"stdlib\": {\"typing\": [\"Any\", \"Optional\"]}}, \"regular\": {\"azurecore\": {\"azure.mgmt.core\": [\"AsyncARMPipelineClient\"], \"azure.profiles\": [\"KnownProfiles\", \"ProfileDefinition\"], \"azure.profiles.multiapiclient\": [\"MultiApiClientMixin\"]}, \"local\": {\"._configuration\": [\"ResourceManagementClientConfiguration\"], \"..._serialization\": [\"Deserializer\", \"Serializer\"]}}, \"typing\": {\"azurecore\": {\"azure.core.credentials_async\": [\"AsyncTokenCredential\"]}}}" }, "global_parameters": { "sync": { "credential": { - "signature": "credential, # type: \"TokenCredential\"", - "description": "Credential needed for the client to connect to Azure.", + "signature": "credential: \"TokenCredential\",", + "description": "Credential needed for the client to connect to Azure. Required.", "docstring_type": "~azure.core.credentials.TokenCredential", "required": true }, "subscription_id": { - "signature": "subscription_id, # type: str", - "description": "The ID of the target subscription.", + "signature": "subscription_id: str,", + "description": "The ID of the target subscription. Required.", "docstring_type": "str", "required": true } @@ -31,13 +31,13 @@ "async": { "credential": { "signature": "credential: \"AsyncTokenCredential\",", - "description": "Credential needed for the client to connect to Azure.", + "description": "Credential needed for the client to connect to Azure. Required.", "docstring_type": "~azure.core.credentials_async.AsyncTokenCredential", "required": true }, "subscription_id": { "signature": "subscription_id: str,", - "description": "The ID of the target subscription.", + "description": "The ID of the target subscription. Required.", "docstring_type": "str", "required": true } @@ -54,7 +54,7 @@ "required": false }, "base_url": { - "signature": "base_url=\"https://management.azure.com\", # type: str", + "signature": "base_url: str = \"https://management.azure.com\",", "description": "Service URL", "docstring_type": "str", "required": false diff --git a/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/resources/v2018_05_01/_patch.py b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/resources/v2018_05_01/_patch.py index 74e48ecd07cf3..f99e77fef9861 100644 --- a/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/resources/v2018_05_01/_patch.py +++ b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/resources/v2018_05_01/_patch.py @@ -28,4 +28,4 @@ # This file is used for handwritten extensions to the generated code. Example: # https://github.com/Azure/azure-sdk-for-python/blob/main/doc/dev/customize_code/how-to-patch-sdk-code.md def patch_sdk(): - pass \ No newline at end of file + pass diff --git a/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/resources/v2018_05_01/_resource_management_client.py b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/resources/v2018_05_01/_resource_management_client.py index c44cb7db39264..38594a88737c3 100644 --- a/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/resources/v2018_05_01/_resource_management_client.py +++ b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/resources/v2018_05_01/_resource_management_client.py @@ -9,20 +9,28 @@ from copy import deepcopy from typing import Any, TYPE_CHECKING -from msrest import Deserializer, Serializer - from azure.core.rest import HttpRequest, HttpResponse from azure.mgmt.core import ARMPipelineClient from . import models +from .._serialization import Deserializer, Serializer from ._configuration import ResourceManagementClientConfiguration -from .operations import DeploymentOperationsOperations, DeploymentsOperations, Operations, ProvidersOperations, ResourceGroupsOperations, ResourcesOperations, TagsOperations +from .operations import ( + DeploymentOperationsOperations, + DeploymentsOperations, + Operations, + ProvidersOperations, + ResourceGroupsOperations, + ResourcesOperations, + TagsOperations, +) if TYPE_CHECKING: # pylint: disable=unused-import,ungrouped-imports from azure.core.credentials import TokenCredential -class ResourceManagementClient: # pylint: disable=too-many-instance-attributes + +class ResourceManagementClient: # pylint: disable=client-accepts-api-version-keyword,too-many-instance-attributes """Provides operations for working with resources and resource groups. :ivar operations: Operations operations @@ -42,9 +50,9 @@ class ResourceManagementClient: # pylint: disable=too-many-instance-attribute :ivar deployment_operations: DeploymentOperationsOperations operations :vartype deployment_operations: azure.mgmt.resource.resources.v2018_05_01.operations.DeploymentOperationsOperations - :param credential: Credential needed for the client to connect to Azure. + :param credential: Credential needed for the client to connect to Azure. Required. :type credential: ~azure.core.credentials.TokenCredential - :param subscription_id: The ID of the target subscription. + :param subscription_id: The ID of the target subscription. Required. :type subscription_id: str :param base_url: Service URL. Default value is "https://management.azure.com". :type base_url: str @@ -62,7 +70,9 @@ def __init__( base_url: str = "https://management.azure.com", **kwargs: Any ) -> None: - self._config = ResourceManagementClientConfiguration(credential=credential, subscription_id=subscription_id, **kwargs) + self._config = ResourceManagementClientConfiguration( + credential=credential, subscription_id=subscription_id, **kwargs + ) self._client = ARMPipelineClient(base_url=base_url, config=self._config, **kwargs) client_models = {k: v for k, v in models.__dict__.items() if isinstance(v, type)} @@ -75,14 +85,11 @@ def __init__( self.resources = ResourcesOperations(self._client, self._config, self._serialize, self._deserialize) self.resource_groups = ResourceGroupsOperations(self._client, self._config, self._serialize, self._deserialize) self.tags = TagsOperations(self._client, self._config, self._serialize, self._deserialize) - self.deployment_operations = DeploymentOperationsOperations(self._client, self._config, self._serialize, self._deserialize) - + self.deployment_operations = DeploymentOperationsOperations( + self._client, self._config, self._serialize, self._deserialize + ) - def _send_request( - self, - request: HttpRequest, - **kwargs: Any - ) -> HttpResponse: + def _send_request(self, request: HttpRequest, **kwargs: Any) -> HttpResponse: """Runs the network request through the client's chained policies. >>> from azure.core.rest import HttpRequest @@ -91,7 +98,7 @@ def _send_request( >>> response = client._send_request(request) - For more information on this code flow, see https://aka.ms/azsdk/python/protocol/quickstart + For more information on this code flow, see https://aka.ms/azsdk/dpcodegen/python/send_request :param request: The network request you want to make. Required. :type request: ~azure.core.rest.HttpRequest diff --git a/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/resources/v2018_05_01/_vendor.py b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/resources/v2018_05_01/_vendor.py index 138f663c53a4e..9aad73fc743e7 100644 --- a/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/resources/v2018_05_01/_vendor.py +++ b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/resources/v2018_05_01/_vendor.py @@ -7,6 +7,7 @@ from azure.core.pipeline.transport import HttpRequest + def _convert_request(request, files=None): data = request.content if not files else None request = HttpRequest(method=request.method, url=request.url, headers=request.headers, data=data) @@ -14,6 +15,7 @@ def _convert_request(request, files=None): request.set_formdata_body(files) return request + def _format_url_section(template, **kwargs): components = template.split("/") while components: @@ -21,7 +23,5 @@ def _format_url_section(template, **kwargs): 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 - ] + components = [c for c in formatted_components if "{}".format(key.args[0]) not in c] template = "/".join(components) diff --git a/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/resources/v2018_05_01/_version.py b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/resources/v2018_05_01/_version.py index a012ac01c480c..e5754a47ce68f 100644 --- a/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/resources/v2018_05_01/_version.py +++ b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/resources/v2018_05_01/_version.py @@ -6,4 +6,4 @@ # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -VERSION = "21.1.0" +VERSION = "1.0.0b1" diff --git a/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/resources/v2018_05_01/aio/__init__.py b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/resources/v2018_05_01/aio/__init__.py index c6c3cf64a37a6..98d6782c2530c 100644 --- a/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/resources/v2018_05_01/aio/__init__.py +++ b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/resources/v2018_05_01/aio/__init__.py @@ -7,9 +7,15 @@ # -------------------------------------------------------------------------- from ._resource_management_client import ResourceManagementClient -__all__ = ['ResourceManagementClient'] -# `._patch.py` is used for handwritten extensions to the generated code -# Example: https://github.com/Azure/azure-sdk-for-python/blob/main/doc/dev/customize_code/how-to-patch-sdk-code.md -from ._patch import patch_sdk -patch_sdk() +try: + from ._patch import __all__ as _patch_all + from ._patch import * # type: ignore # pylint: disable=unused-wildcard-import +except ImportError: + _patch_all = [] +from ._patch import patch_sdk as _patch_sdk + +__all__ = ["ResourceManagementClient"] +__all__.extend([p for p in _patch_all if p not in __all__]) + +_patch_sdk() diff --git a/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/resources/v2018_05_01/aio/_configuration.py b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/resources/v2018_05_01/aio/_configuration.py index e43766d84a6a6..f6b04935c9136 100644 --- a/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/resources/v2018_05_01/aio/_configuration.py +++ b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/resources/v2018_05_01/aio/_configuration.py @@ -25,23 +25,18 @@ class ResourceManagementClientConfiguration(Configuration): # pylint: disable=t Note that all parameters used to create this instance are saved as instance attributes. - :param credential: Credential needed for the client to connect to Azure. + :param credential: Credential needed for the client to connect to Azure. Required. :type credential: ~azure.core.credentials_async.AsyncTokenCredential - :param subscription_id: The ID of the target subscription. + :param subscription_id: The ID of the target subscription. Required. :type subscription_id: str :keyword api_version: Api Version. Default value is "2018-05-01". Note that overriding this default value may result in unsupported behavior. :paramtype api_version: str """ - def __init__( - self, - credential: "AsyncTokenCredential", - subscription_id: str, - **kwargs: Any - ) -> None: + def __init__(self, credential: "AsyncTokenCredential", subscription_id: str, **kwargs: Any) -> None: super(ResourceManagementClientConfiguration, self).__init__(**kwargs) - api_version = kwargs.pop('api_version', "2018-05-01") # type: str + api_version = kwargs.pop("api_version", "2018-05-01") # type: str if credential is None: raise ValueError("Parameter 'credential' must not be None.") @@ -51,22 +46,21 @@ def __init__( self.credential = credential self.subscription_id = subscription_id self.api_version = api_version - self.credential_scopes = kwargs.pop('credential_scopes', ['https://management.azure.com/.default']) - kwargs.setdefault('sdk_moniker', 'mgmt-resource/{}'.format(VERSION)) + self.credential_scopes = kwargs.pop("credential_scopes", ["https://management.azure.com/.default"]) + kwargs.setdefault("sdk_moniker", "mgmt-resource/{}".format(VERSION)) self._configure(**kwargs) - 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) - self.logging_policy = kwargs.get('logging_policy') or policies.NetworkTraceLoggingPolicy(**kwargs) - self.http_logging_policy = kwargs.get('http_logging_policy') or ARMHttpLoggingPolicy(**kwargs) - self.retry_policy = kwargs.get('retry_policy') or policies.AsyncRetryPolicy(**kwargs) - self.custom_hook_policy = kwargs.get('custom_hook_policy') or policies.CustomHookPolicy(**kwargs) - self.redirect_policy = kwargs.get('redirect_policy') or policies.AsyncRedirectPolicy(**kwargs) - self.authentication_policy = kwargs.get('authentication_policy') + 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) + self.logging_policy = kwargs.get("logging_policy") or policies.NetworkTraceLoggingPolicy(**kwargs) + self.http_logging_policy = kwargs.get("http_logging_policy") or ARMHttpLoggingPolicy(**kwargs) + self.retry_policy = kwargs.get("retry_policy") or policies.AsyncRetryPolicy(**kwargs) + self.custom_hook_policy = kwargs.get("custom_hook_policy") or policies.CustomHookPolicy(**kwargs) + self.redirect_policy = kwargs.get("redirect_policy") or policies.AsyncRedirectPolicy(**kwargs) + self.authentication_policy = kwargs.get("authentication_policy") if self.credential and not self.authentication_policy: - self.authentication_policy = AsyncARMChallengeAuthenticationPolicy(self.credential, *self.credential_scopes, **kwargs) + self.authentication_policy = AsyncARMChallengeAuthenticationPolicy( + self.credential, *self.credential_scopes, **kwargs + ) diff --git a/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/resources/v2018_05_01/aio/_patch.py b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/resources/v2018_05_01/aio/_patch.py index 74e48ecd07cf3..f99e77fef9861 100644 --- a/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/resources/v2018_05_01/aio/_patch.py +++ b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/resources/v2018_05_01/aio/_patch.py @@ -28,4 +28,4 @@ # This file is used for handwritten extensions to the generated code. Example: # https://github.com/Azure/azure-sdk-for-python/blob/main/doc/dev/customize_code/how-to-patch-sdk-code.md def patch_sdk(): - pass \ No newline at end of file + pass diff --git a/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/resources/v2018_05_01/aio/_resource_management_client.py b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/resources/v2018_05_01/aio/_resource_management_client.py index e947a84c1ab67..cc34198ba337e 100644 --- a/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/resources/v2018_05_01/aio/_resource_management_client.py +++ b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/resources/v2018_05_01/aio/_resource_management_client.py @@ -9,20 +9,28 @@ from copy import deepcopy from typing import Any, Awaitable, TYPE_CHECKING -from msrest import Deserializer, Serializer - from azure.core.rest import AsyncHttpResponse, HttpRequest from azure.mgmt.core import AsyncARMPipelineClient from .. import models +from ..._serialization import Deserializer, Serializer from ._configuration import ResourceManagementClientConfiguration -from .operations import DeploymentOperationsOperations, DeploymentsOperations, Operations, ProvidersOperations, ResourceGroupsOperations, ResourcesOperations, TagsOperations +from .operations import ( + DeploymentOperationsOperations, + DeploymentsOperations, + Operations, + ProvidersOperations, + ResourceGroupsOperations, + ResourcesOperations, + TagsOperations, +) if TYPE_CHECKING: # pylint: disable=unused-import,ungrouped-imports from azure.core.credentials_async import AsyncTokenCredential -class ResourceManagementClient: # pylint: disable=too-many-instance-attributes + +class ResourceManagementClient: # pylint: disable=client-accepts-api-version-keyword,too-many-instance-attributes """Provides operations for working with resources and resource groups. :ivar operations: Operations operations @@ -44,9 +52,9 @@ class ResourceManagementClient: # pylint: disable=too-many-instance-attribute :ivar deployment_operations: DeploymentOperationsOperations operations :vartype deployment_operations: azure.mgmt.resource.resources.v2018_05_01.aio.operations.DeploymentOperationsOperations - :param credential: Credential needed for the client to connect to Azure. + :param credential: Credential needed for the client to connect to Azure. Required. :type credential: ~azure.core.credentials_async.AsyncTokenCredential - :param subscription_id: The ID of the target subscription. + :param subscription_id: The ID of the target subscription. Required. :type subscription_id: str :param base_url: Service URL. Default value is "https://management.azure.com". :type base_url: str @@ -64,7 +72,9 @@ def __init__( base_url: str = "https://management.azure.com", **kwargs: Any ) -> None: - self._config = ResourceManagementClientConfiguration(credential=credential, subscription_id=subscription_id, **kwargs) + self._config = ResourceManagementClientConfiguration( + credential=credential, subscription_id=subscription_id, **kwargs + ) self._client = AsyncARMPipelineClient(base_url=base_url, config=self._config, **kwargs) client_models = {k: v for k, v in models.__dict__.items() if isinstance(v, type)} @@ -77,14 +87,11 @@ def __init__( self.resources = ResourcesOperations(self._client, self._config, self._serialize, self._deserialize) self.resource_groups = ResourceGroupsOperations(self._client, self._config, self._serialize, self._deserialize) self.tags = TagsOperations(self._client, self._config, self._serialize, self._deserialize) - self.deployment_operations = DeploymentOperationsOperations(self._client, self._config, self._serialize, self._deserialize) - + self.deployment_operations = DeploymentOperationsOperations( + self._client, self._config, self._serialize, self._deserialize + ) - def _send_request( - self, - request: HttpRequest, - **kwargs: Any - ) -> Awaitable[AsyncHttpResponse]: + def _send_request(self, request: HttpRequest, **kwargs: Any) -> Awaitable[AsyncHttpResponse]: """Runs the network request through the client's chained policies. >>> from azure.core.rest import HttpRequest @@ -93,7 +100,7 @@ def _send_request( >>> response = await client._send_request(request) - For more information on this code flow, see https://aka.ms/azsdk/python/protocol/quickstart + For more information on this code flow, see https://aka.ms/azsdk/dpcodegen/python/send_request :param request: The network request you want to make. Required. :type request: ~azure.core.rest.HttpRequest diff --git a/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/resources/v2018_05_01/aio/operations/__init__.py b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/resources/v2018_05_01/aio/operations/__init__.py index 53876d82bf5d7..804fee65e3137 100644 --- a/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/resources/v2018_05_01/aio/operations/__init__.py +++ b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/resources/v2018_05_01/aio/operations/__init__.py @@ -14,12 +14,18 @@ from ._operations import TagsOperations from ._operations import DeploymentOperationsOperations +from ._patch import __all__ as _patch_all +from ._patch import * # type: ignore # pylint: disable=unused-wildcard-import +from ._patch import patch_sdk as _patch_sdk + __all__ = [ - 'Operations', - 'DeploymentsOperations', - 'ProvidersOperations', - 'ResourcesOperations', - 'ResourceGroupsOperations', - 'TagsOperations', - 'DeploymentOperationsOperations', + "Operations", + "DeploymentsOperations", + "ProvidersOperations", + "ResourcesOperations", + "ResourceGroupsOperations", + "TagsOperations", + "DeploymentOperationsOperations", ] +__all__.extend([p for p in _patch_all if p not in __all__]) +_patch_sdk() diff --git a/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/resources/v2018_05_01/aio/operations/_operations.py b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/resources/v2018_05_01/aio/operations/_operations.py index 768b36f7d2ab9..df17439af711a 100644 --- a/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/resources/v2018_05_01/aio/operations/_operations.py +++ b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/resources/v2018_05_01/aio/operations/_operations.py @@ -6,84 +6,158 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -from typing import Any, AsyncIterable, Callable, Dict, Optional, TypeVar, Union +import sys +from typing import Any, AsyncIterable, Callable, Dict, IO, Optional, TypeVar, Union, cast, overload +from urllib.parse import parse_qs, urljoin, urlparse from azure.core.async_paging import AsyncItemPaged, AsyncList -from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error +from azure.core.exceptions import ( + ClientAuthenticationError, + HttpResponseError, + ResourceExistsError, + ResourceNotFoundError, + ResourceNotModifiedError, + map_error, +) from azure.core.pipeline import PipelineResponse from azure.core.pipeline.transport import AsyncHttpResponse from azure.core.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 from azure.mgmt.core.polling.async_arm_polling import AsyncARMPolling from ... import models as _models from ..._vendor import _convert_request -from ...operations._operations import build_deployment_operations_get_at_subscription_scope_request, build_deployment_operations_get_request, build_deployment_operations_list_at_subscription_scope_request, build_deployment_operations_list_request, build_deployments_calculate_template_hash_request, build_deployments_cancel_at_subscription_scope_request, build_deployments_cancel_request, build_deployments_check_existence_at_subscription_scope_request, build_deployments_check_existence_request, build_deployments_create_or_update_at_subscription_scope_request_initial, build_deployments_create_or_update_request_initial, build_deployments_delete_at_subscription_scope_request_initial, build_deployments_delete_request_initial, build_deployments_export_template_at_subscription_scope_request, build_deployments_export_template_request, build_deployments_get_at_subscription_scope_request, build_deployments_get_request, build_deployments_list_at_subscription_scope_request, build_deployments_list_by_resource_group_request, build_deployments_validate_at_subscription_scope_request, build_deployments_validate_request, build_operations_list_request, build_providers_get_request, build_providers_list_request, build_providers_register_request, build_providers_unregister_request, build_resource_groups_check_existence_request, build_resource_groups_create_or_update_request, build_resource_groups_delete_request_initial, build_resource_groups_export_template_request, build_resource_groups_get_request, build_resource_groups_list_request, build_resource_groups_update_request, build_resources_check_existence_by_id_request, build_resources_check_existence_request, build_resources_create_or_update_by_id_request_initial, build_resources_create_or_update_request_initial, build_resources_delete_by_id_request_initial, build_resources_delete_request_initial, build_resources_get_by_id_request, build_resources_get_request, build_resources_list_by_resource_group_request, build_resources_list_request, build_resources_move_resources_request_initial, build_resources_update_by_id_request_initial, build_resources_update_request_initial, build_resources_validate_move_resources_request_initial, build_tags_create_or_update_request, build_tags_create_or_update_value_request, build_tags_delete_request, build_tags_delete_value_request, build_tags_list_request -T = TypeVar('T') +from ...operations._operations import ( + build_deployment_operations_get_at_subscription_scope_request, + build_deployment_operations_get_request, + build_deployment_operations_list_at_subscription_scope_request, + build_deployment_operations_list_request, + build_deployments_calculate_template_hash_request, + build_deployments_cancel_at_subscription_scope_request, + build_deployments_cancel_request, + build_deployments_check_existence_at_subscription_scope_request, + build_deployments_check_existence_request, + build_deployments_create_or_update_at_subscription_scope_request, + build_deployments_create_or_update_request, + build_deployments_delete_at_subscription_scope_request, + build_deployments_delete_request, + build_deployments_export_template_at_subscription_scope_request, + build_deployments_export_template_request, + build_deployments_get_at_subscription_scope_request, + build_deployments_get_request, + build_deployments_list_at_subscription_scope_request, + build_deployments_list_by_resource_group_request, + build_deployments_validate_at_subscription_scope_request, + build_deployments_validate_request, + build_operations_list_request, + build_providers_get_request, + build_providers_list_request, + build_providers_register_request, + build_providers_unregister_request, + build_resource_groups_check_existence_request, + build_resource_groups_create_or_update_request, + build_resource_groups_delete_request, + build_resource_groups_export_template_request, + build_resource_groups_get_request, + build_resource_groups_list_request, + build_resource_groups_update_request, + build_resources_check_existence_by_id_request, + build_resources_check_existence_request, + build_resources_create_or_update_by_id_request, + build_resources_create_or_update_request, + build_resources_delete_by_id_request, + build_resources_delete_request, + build_resources_get_by_id_request, + build_resources_get_request, + build_resources_list_by_resource_group_request, + build_resources_list_request, + build_resources_move_resources_request, + build_resources_update_by_id_request, + build_resources_update_request, + build_resources_validate_move_resources_request, + build_tags_create_or_update_request, + build_tags_create_or_update_value_request, + build_tags_delete_request, + build_tags_delete_value_request, + build_tags_list_request, +) + +T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] +if sys.version_info >= (3, 9): + from collections.abc import MutableMapping +else: + from typing import MutableMapping # type: ignore # pylint: disable=ungrouped-imports +JSON = MutableMapping[str, Any] # pylint: disable=unsubscriptable-object -class Operations: - """Operations async operations. - You should not instantiate this class directly. Instead, you should create a Client instance that - instantiates it for you and attaches it as an attribute. +class Operations: + """ + .. warning:: + **DO NOT** instantiate this class directly. - :ivar models: Alias to model classes used in this operation group. - :type models: ~azure.mgmt.resource.resources.v2018_05_01.models - :param client: Client for service requests. - :param config: Configuration of service client. - :param serializer: An object model serializer. - :param deserializer: An object model deserializer. + Instead, you should access the following operations through + :class:`~azure.mgmt.resource.resources.v2018_05_01.aio.ResourceManagementClient`'s + :attr:`operations` attribute. """ models = _models - def __init__(self, client, config, serializer, deserializer) -> None: - self._client = client - self._serialize = serializer - self._deserialize = deserializer - self._config = config + def __init__(self, *args, **kwargs) -> None: + input_args = list(args) + self._client = input_args.pop(0) if input_args else kwargs.pop("client") + self._config = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") @distributed_trace - def list( - self, - **kwargs: Any - ) -> AsyncIterable["_models.OperationListResult"]: + def list(self, **kwargs: Any) -> AsyncIterable["_models.Operation"]: """Lists all of the available Microsoft.Resources REST API operations. :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either OperationListResult or the result of cls(response) + :return: An iterator like instance of either Operation or the result of cls(response) :rtype: - ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.resource.resources.v2018_05_01.models.OperationListResult] - :raises: ~azure.core.exceptions.HttpResponseError + ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.resource.resources.v2018_05_01.models.Operation] + :raises ~azure.core.exceptions.HttpResponseError: """ - api_version = kwargs.pop('api_version', "2018-05-01") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2018-05-01")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[_models.OperationListResult] - cls = kwargs.pop('cls', None) # type: ClsType["_models.OperationListResult"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) + def prepare_request(next_link=None): if not next_link: - + request = build_operations_list_request( api_version=api_version, - template_url=self.list.metadata['url'], + template_url=self.list.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore else: - - request = build_operations_list_request( - template_url=next_link, - ) + # make call to next link with the client's api-version + _parsed_next_link = urlparse(next_link) + _next_request_params = case_insensitive_dict(parse_qs(_parsed_next_link.query)) + _next_request_params["api-version"] = self._config.api_version + request = HttpRequest("GET", urljoin(next_link, _parsed_next_link.path), params=_next_request_params) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore request.method = "GET" return request @@ -97,10 +171,8 @@ async def extract_data(pipeline_response): async def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) response = pipeline_response.http_response @@ -110,61 +182,62 @@ async def get_next(next_link=None): return pipeline_response + return AsyncItemPaged(get_next, extract_data) - return AsyncItemPaged( - get_next, extract_data - ) - list.metadata = {'url': "/providers/Microsoft.Resources/operations"} # type: ignore -class DeploymentsOperations: # pylint: disable=too-many-public-methods - """DeploymentsOperations async operations. + list.metadata = {"url": "/providers/Microsoft.Resources/operations"} # type: ignore - You should not instantiate this class directly. Instead, you should create a Client instance that - instantiates it for you and attaches it as an attribute. - :ivar models: Alias to model classes used in this operation group. - :type models: ~azure.mgmt.resource.resources.v2018_05_01.models - :param client: Client for service requests. - :param config: Configuration of service client. - :param serializer: An object model serializer. - :param deserializer: An object model deserializer. +class DeploymentsOperations: # pylint: disable=too-many-public-methods + """ + .. warning:: + **DO NOT** instantiate this class directly. + + Instead, you should access the following operations through + :class:`~azure.mgmt.resource.resources.v2018_05_01.aio.ResourceManagementClient`'s + :attr:`deployments` attribute. """ models = _models - def __init__(self, client, config, serializer, deserializer) -> None: - self._client = client - self._serialize = serializer - self._deserialize = deserializer - self._config = config + def __init__(self, *args, **kwargs) -> None: + input_args = list(args) + self._client = input_args.pop(0) if input_args else kwargs.pop("client") + self._config = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") async def _delete_at_subscription_scope_initial( # pylint: disable=inconsistent-return-statements - self, - deployment_name: str, - **kwargs: Any + self, deployment_name: str, **kwargs: Any ) -> None: - cls = kwargs.pop('cls', None) # type: ClsType[None] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) - api_version = kwargs.pop('api_version', "2018-05-01") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - request = build_deployments_delete_at_subscription_scope_request_initial( + api_version = kwargs.pop("api_version", _params.pop("api-version", "2018-05-01")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[None] + + request = build_deployments_delete_at_subscription_scope_request( deployment_name=deployment_name, subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self._delete_at_subscription_scope_initial.metadata['url'], + template_url=self._delete_at_subscription_scope_initial.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [202, 204]: @@ -174,15 +247,10 @@ async def _delete_at_subscription_scope_initial( # pylint: disable=inconsistent if cls: return cls(pipeline_response, None, {}) - _delete_at_subscription_scope_initial.metadata = {'url': "/subscriptions/{subscriptionId}/providers/Microsoft.Resources/deployments/{deploymentName}"} # type: ignore - + _delete_at_subscription_scope_initial.metadata = {"url": "/subscriptions/{subscriptionId}/providers/Microsoft.Resources/deployments/{deploymentName}"} # type: ignore @distributed_trace_async - async def begin_delete_at_subscription_scope( # pylint: disable=inconsistent-return-statements - self, - deployment_name: str, - **kwargs: Any - ) -> AsyncLROPoller[None]: + async def begin_delete_at_subscription_scope(self, deployment_name: str, **kwargs: Any) -> AsyncLROPoller[None]: """Deletes a deployment from the deployment history. A template deployment that is currently running cannot be deleted. Deleting a template @@ -193,7 +261,7 @@ async def begin_delete_at_subscription_scope( # pylint: disable=inconsistent-re process finishes, the URI in the Location header returns a status of 204 on success. If the asynchronous request failed, the URI in the Location header returns an error-level status code. - :param deployment_name: The name of the deployment to delete. + :param deployment_name: The name of the deployment to delete. Required. :type deployment_name: str :keyword callable cls: A custom type or function that will be passed the direct response :keyword str continuation_token: A continuation token to restart a poller from a saved state. @@ -205,82 +273,88 @@ async def begin_delete_at_subscription_scope( # pylint: disable=inconsistent-re Retry-After header is present. :return: An instance of AsyncLROPoller that returns either None or the result of cls(response) :rtype: ~azure.core.polling.AsyncLROPoller[None] - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - api_version = kwargs.pop('api_version', "2018-05-01") # type: str - polling = kwargs.pop('polling', True) # type: Union[bool, AsyncPollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType[None] - lro_delay = kwargs.pop( - 'polling_interval', - self._config.polling_interval - ) - cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2018-05-01")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[None] + polling = kwargs.pop("polling", True) # type: Union[bool, AsyncPollingMethod] + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token = kwargs.pop("continuation_token", None) # type: Optional[str] if cont_token is None: - raw_result = await self._delete_at_subscription_scope_initial( + raw_result = await self._delete_at_subscription_scope_initial( # type: ignore deployment_name=deployment_name, api_version=api_version, - cls=lambda x,y,z: x, + cls=lambda x, y, z: x, + headers=_headers, + params=_params, **kwargs ) - kwargs.pop('error_map', None) + kwargs.pop("error_map", None) - def get_long_running_output(pipeline_response): + def get_long_running_output(pipeline_response): # pylint: disable=inconsistent-return-statements if cls: return cls(pipeline_response, None, {}) - - if polling is True: polling_method = AsyncARMPolling(lro_delay, **kwargs) - elif polling is False: polling_method = AsyncNoPolling() - else: polling_method = polling + if polling is True: + polling_method = cast(AsyncPollingMethod, AsyncARMPolling(lro_delay, **kwargs)) # type: AsyncPollingMethod + elif polling is False: + polling_method = cast(AsyncPollingMethod, AsyncNoPolling()) + else: + polling_method = polling if cont_token: return AsyncLROPoller.from_continuation_token( polling_method=polling_method, continuation_token=cont_token, client=self._client, - deserialization_callback=get_long_running_output + deserialization_callback=get_long_running_output, ) return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) - begin_delete_at_subscription_scope.metadata = {'url': "/subscriptions/{subscriptionId}/providers/Microsoft.Resources/deployments/{deploymentName}"} # type: ignore + begin_delete_at_subscription_scope.metadata = {"url": "/subscriptions/{subscriptionId}/providers/Microsoft.Resources/deployments/{deploymentName}"} # type: ignore @distributed_trace_async - async def check_existence_at_subscription_scope( - self, - deployment_name: str, - **kwargs: Any - ) -> bool: + async def check_existence_at_subscription_scope(self, deployment_name: str, **kwargs: Any) -> bool: """Checks whether the deployment exists. - :param deployment_name: The name of the deployment to check. + :param deployment_name: The name of the deployment to check. Required. :type deployment_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: bool, or the result of cls(response) + :return: bool or the result of cls(response) :rtype: bool - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType[None] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) - api_version = kwargs.pop('api_version', "2018-05-01") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2018-05-01")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[None] - request = build_deployments_check_existence_at_subscription_scope_request( deployment_name=deployment_name, subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.check_existence_at_subscription_scope.metadata['url'], + template_url=self.check_existence_at_subscription_scope.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [204, 404]: @@ -291,42 +365,52 @@ async def check_existence_at_subscription_scope( return cls(pipeline_response, None, {}) return 200 <= response.status_code <= 299 - check_existence_at_subscription_scope.metadata = {'url': "/subscriptions/{subscriptionId}/providers/Microsoft.Resources/deployments/{deploymentName}"} # type: ignore - + check_existence_at_subscription_scope.metadata = {"url": "/subscriptions/{subscriptionId}/providers/Microsoft.Resources/deployments/{deploymentName}"} # type: ignore async def _create_or_update_at_subscription_scope_initial( - self, - deployment_name: str, - parameters: "_models.Deployment", - **kwargs: Any - ) -> "_models.DeploymentExtended": - cls = kwargs.pop('cls', None) # type: ClsType["_models.DeploymentExtended"] + self, deployment_name: str, parameters: Union[_models.Deployment, IO], **kwargs: Any + ) -> _models.DeploymentExtended: error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) - api_version = kwargs.pop('api_version', "2018-05-01") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - _json = self._serialize.body(parameters, 'Deployment') + api_version = kwargs.pop("api_version", _params.pop("api-version", "2018-05-01")) # type: str + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.DeploymentExtended] - request = build_deployments_create_or_update_at_subscription_scope_request_initial( + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(parameters, (IO, bytes)): + _content = parameters + else: + _json = self._serialize.body(parameters, "Deployment") + + request = build_deployments_create_or_update_at_subscription_scope_request( deployment_name=deployment_name, subscription_id=self._config.subscription_id, api_version=api_version, content_type=content_type, json=_json, - template_url=self._create_or_update_at_subscription_scope_initial.metadata['url'], + content=_content, + template_url=self._create_or_update_at_subscription_scope_initial.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200, 201]: @@ -334,34 +418,38 @@ async def _create_or_update_at_subscription_scope_initial( raise HttpResponseError(response=response, error_format=ARMErrorFormat) if response.status_code == 200: - deserialized = self._deserialize('DeploymentExtended', pipeline_response) + deserialized = self._deserialize("DeploymentExtended", pipeline_response) if response.status_code == 201: - deserialized = self._deserialize('DeploymentExtended', pipeline_response) + deserialized = self._deserialize("DeploymentExtended", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - _create_or_update_at_subscription_scope_initial.metadata = {'url': "/subscriptions/{subscriptionId}/providers/Microsoft.Resources/deployments/{deploymentName}"} # type: ignore + _create_or_update_at_subscription_scope_initial.metadata = {"url": "/subscriptions/{subscriptionId}/providers/Microsoft.Resources/deployments/{deploymentName}"} # type: ignore - - @distributed_trace_async + @overload async def begin_create_or_update_at_subscription_scope( self, deployment_name: str, - parameters: "_models.Deployment", + parameters: _models.Deployment, + *, + content_type: str = "application/json", **kwargs: Any - ) -> AsyncLROPoller["_models.DeploymentExtended"]: + ) -> AsyncLROPoller[_models.DeploymentExtended]: """Deploys resources at subscription scope. You can provide the template and parameters directly in the request or link to JSON files. - :param deployment_name: The name of the deployment. + :param deployment_name: The name of the deployment. Required. :type deployment_name: str - :param parameters: Additional parameters supplied to the operation. + :param parameters: Additional parameters supplied to the operation. Required. :type parameters: ~azure.mgmt.resource.resources.v2018_05_01.models.Deployment + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str :keyword callable cls: A custom type or function that will be passed the direct response :keyword str continuation_token: A continuation token to restart a poller from a saved state. :keyword polling: By default, your polling method will be AsyncARMPolling. Pass in False for @@ -374,109 +462,172 @@ async def begin_create_or_update_at_subscription_scope( cls(response) :rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.resource.resources.v2018_05_01.models.DeploymentExtended] - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - api_version = kwargs.pop('api_version', "2018-05-01") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] - polling = kwargs.pop('polling', True) # type: Union[bool, AsyncPollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType["_models.DeploymentExtended"] - lro_delay = kwargs.pop( - 'polling_interval', - self._config.polling_interval - ) - cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] + + @overload + async def begin_create_or_update_at_subscription_scope( + self, deployment_name: str, parameters: IO, *, content_type: str = "application/json", **kwargs: Any + ) -> AsyncLROPoller[_models.DeploymentExtended]: + """Deploys resources at subscription scope. + + You can provide the template and parameters directly in the request or link to JSON files. + + :param deployment_name: The name of the deployment. Required. + :type deployment_name: str + :param parameters: Additional parameters supplied to the operation. Required. + :type parameters: IO + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be AsyncARMPolling. Pass in False for + this operation to not poll, or pass in your own initialized polling object for a personal + polling strategy. + :paramtype polling: bool or ~azure.core.polling.AsyncPollingMethod + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of AsyncLROPoller that returns either DeploymentExtended or the result of + cls(response) + :rtype: + ~azure.core.polling.AsyncLROPoller[~azure.mgmt.resource.resources.v2018_05_01.models.DeploymentExtended] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace_async + async def begin_create_or_update_at_subscription_scope( + self, deployment_name: str, parameters: Union[_models.Deployment, IO], **kwargs: Any + ) -> AsyncLROPoller[_models.DeploymentExtended]: + """Deploys resources at subscription scope. + + You can provide the template and parameters directly in the request or link to JSON files. + + :param deployment_name: The name of the deployment. Required. + :type deployment_name: str + :param parameters: Additional parameters supplied to the operation. Is either a model type or a + IO type. Required. + :type parameters: ~azure.mgmt.resource.resources.v2018_05_01.models.Deployment or IO + :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. + Default value is None. + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be AsyncARMPolling. Pass in False for + this operation to not poll, or pass in your own initialized polling object for a personal + polling strategy. + :paramtype polling: bool or ~azure.core.polling.AsyncPollingMethod + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of AsyncLROPoller that returns either DeploymentExtended or the result of + cls(response) + :rtype: + ~azure.core.polling.AsyncLROPoller[~azure.mgmt.resource.resources.v2018_05_01.models.DeploymentExtended] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _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", "2018-05-01")) # type: str + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.DeploymentExtended] + polling = kwargs.pop("polling", True) # type: Union[bool, AsyncPollingMethod] + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token = kwargs.pop("continuation_token", None) # type: Optional[str] if cont_token is None: - raw_result = await self._create_or_update_at_subscription_scope_initial( + raw_result = await self._create_or_update_at_subscription_scope_initial( # type: ignore deployment_name=deployment_name, parameters=parameters, api_version=api_version, content_type=content_type, - cls=lambda x,y,z: x, + cls=lambda x, y, z: x, + headers=_headers, + params=_params, **kwargs ) - kwargs.pop('error_map', None) + kwargs.pop("error_map", None) def get_long_running_output(pipeline_response): - response = pipeline_response.http_response - deserialized = self._deserialize('DeploymentExtended', pipeline_response) + deserialized = self._deserialize("DeploymentExtended", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - - if polling is True: polling_method = AsyncARMPolling(lro_delay, **kwargs) - elif polling is False: polling_method = AsyncNoPolling() - else: polling_method = polling + if polling is True: + polling_method = cast(AsyncPollingMethod, AsyncARMPolling(lro_delay, **kwargs)) # type: AsyncPollingMethod + elif polling is False: + polling_method = cast(AsyncPollingMethod, AsyncNoPolling()) + else: + polling_method = polling if cont_token: return AsyncLROPoller.from_continuation_token( polling_method=polling_method, continuation_token=cont_token, client=self._client, - deserialization_callback=get_long_running_output + deserialization_callback=get_long_running_output, ) return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) - begin_create_or_update_at_subscription_scope.metadata = {'url': "/subscriptions/{subscriptionId}/providers/Microsoft.Resources/deployments/{deploymentName}"} # type: ignore + begin_create_or_update_at_subscription_scope.metadata = {"url": "/subscriptions/{subscriptionId}/providers/Microsoft.Resources/deployments/{deploymentName}"} # type: ignore @distributed_trace_async - async def get_at_subscription_scope( - self, - deployment_name: str, - **kwargs: Any - ) -> "_models.DeploymentExtended": + async def get_at_subscription_scope(self, deployment_name: str, **kwargs: Any) -> _models.DeploymentExtended: """Gets a deployment. - :param deployment_name: The name of the deployment to get. + :param deployment_name: The name of the deployment to get. Required. :type deployment_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: DeploymentExtended, or the result of cls(response) + :return: DeploymentExtended or the result of cls(response) :rtype: ~azure.mgmt.resource.resources.v2018_05_01.models.DeploymentExtended - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.DeploymentExtended"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + 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', "2018-05-01") # type: str + api_version = kwargs.pop("api_version", _params.pop("api-version", "2018-05-01")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[_models.DeploymentExtended] - request = build_deployments_get_at_subscription_scope_request( deployment_name=deployment_name, subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.get_at_subscription_scope.metadata['url'], + template_url=self.get_at_subscription_scope.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) - deserialized = self._deserialize('DeploymentExtended', pipeline_response) + deserialized = self._deserialize("DeploymentExtended", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - get_at_subscription_scope.metadata = {'url': "/subscriptions/{subscriptionId}/providers/Microsoft.Resources/deployments/{deploymentName}"} # type: ignore - + get_at_subscription_scope.metadata = {"url": "/subscriptions/{subscriptionId}/providers/Microsoft.Resources/deployments/{deploymentName}"} # type: ignore @distributed_trace_async async def cancel_at_subscription_scope( # pylint: disable=inconsistent-return-statements - self, - deployment_name: str, - **kwargs: Any + self, deployment_name: str, **kwargs: Any ) -> None: """Cancels a currently running template deployment. @@ -485,36 +636,42 @@ async def cancel_at_subscription_scope( # pylint: disable=inconsistent-return-s deployment stops the currently running template deployment and leaves the resources partially deployed. - :param deployment_name: The name of the deployment to cancel. + :param deployment_name: The name of the deployment to cancel. Required. :type deployment_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: None, or the result of cls(response) + :return: None or the result of cls(response) :rtype: None - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType[None] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + 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', "2018-05-01") # type: str + api_version = kwargs.pop("api_version", _params.pop("api-version", "2018-05-01")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[None] - request = build_deployments_cancel_at_subscription_scope_request( deployment_name=deployment_name, subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.cancel_at_subscription_scope.metadata['url'], + template_url=self.cancel_at_subscription_scope.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [204]: @@ -524,38 +681,94 @@ async def cancel_at_subscription_scope( # pylint: disable=inconsistent-return-s if cls: return cls(pipeline_response, None, {}) - cancel_at_subscription_scope.metadata = {'url': "/subscriptions/{subscriptionId}/providers/Microsoft.Resources/deployments/{deploymentName}/cancel"} # type: ignore - + cancel_at_subscription_scope.metadata = {"url": "/subscriptions/{subscriptionId}/providers/Microsoft.Resources/deployments/{deploymentName}/cancel"} # type: ignore - @distributed_trace_async + @overload async def validate_at_subscription_scope( self, deployment_name: str, - parameters: "_models.Deployment", + parameters: _models.Deployment, + *, + content_type: str = "application/json", **kwargs: Any - ) -> "_models.DeploymentValidateResult": + ) -> _models.DeploymentValidateResult: """Validates whether the specified template is syntactically correct and will be accepted by Azure Resource Manager.. - :param deployment_name: The name of the deployment. + :param deployment_name: The name of the deployment. Required. :type deployment_name: str - :param parameters: Parameters to validate. + :param parameters: Parameters to validate. Required. :type parameters: ~azure.mgmt.resource.resources.v2018_05_01.models.Deployment + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: DeploymentValidateResult or the result of cls(response) + :rtype: ~azure.mgmt.resource.resources.v2018_05_01.models.DeploymentValidateResult + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + async def validate_at_subscription_scope( + self, deployment_name: str, parameters: IO, *, content_type: str = "application/json", **kwargs: Any + ) -> _models.DeploymentValidateResult: + """Validates whether the specified template is syntactically correct and will be accepted by Azure + Resource Manager.. + + :param deployment_name: The name of the deployment. Required. + :type deployment_name: str + :param parameters: Parameters to validate. Required. + :type parameters: IO + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: DeploymentValidateResult, or the result of cls(response) + :return: DeploymentValidateResult or the result of cls(response) :rtype: ~azure.mgmt.resource.resources.v2018_05_01.models.DeploymentValidateResult - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace_async + async def validate_at_subscription_scope( + self, deployment_name: str, parameters: Union[_models.Deployment, IO], **kwargs: Any + ) -> _models.DeploymentValidateResult: + """Validates whether the specified template is syntactically correct and will be accepted by Azure + Resource Manager.. + + :param deployment_name: The name of the deployment. Required. + :type deployment_name: str + :param parameters: Parameters to validate. Is either a model type or a IO type. Required. + :type parameters: ~azure.mgmt.resource.resources.v2018_05_01.models.Deployment or IO + :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. + Default value is None. + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: DeploymentValidateResult or the result of cls(response) + :rtype: ~azure.mgmt.resource.resources.v2018_05_01.models.DeploymentValidateResult + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.DeploymentValidateResult"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', "2018-05-01") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + api_version = kwargs.pop("api_version", _params.pop("api-version", "2018-05-01")) # type: str + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.DeploymentValidateResult] - _json = self._serialize.body(parameters, 'Deployment') + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(parameters, (IO, bytes)): + _content = parameters + else: + _json = self._serialize.body(parameters, "Deployment") request = build_deployments_validate_at_subscription_scope_request( deployment_name=deployment_name, @@ -563,16 +776,18 @@ async def validate_at_subscription_scope( api_version=api_version, content_type=content_type, json=_json, - template_url=self.validate_at_subscription_scope.metadata['url'], + content=_content, + template_url=self.validate_at_subscription_scope.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200, 400]: @@ -580,80 +795,79 @@ async def validate_at_subscription_scope( raise HttpResponseError(response=response, error_format=ARMErrorFormat) if response.status_code == 200: - deserialized = self._deserialize('DeploymentValidateResult', pipeline_response) + deserialized = self._deserialize("DeploymentValidateResult", pipeline_response) if response.status_code == 400: - deserialized = self._deserialize('DeploymentValidateResult', pipeline_response) + deserialized = self._deserialize("DeploymentValidateResult", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - validate_at_subscription_scope.metadata = {'url': "/subscriptions/{subscriptionId}/providers/Microsoft.Resources/deployments/{deploymentName}/validate"} # type: ignore - + validate_at_subscription_scope.metadata = {"url": "/subscriptions/{subscriptionId}/providers/Microsoft.Resources/deployments/{deploymentName}/validate"} # type: ignore @distributed_trace_async async def export_template_at_subscription_scope( - self, - deployment_name: str, - **kwargs: Any - ) -> "_models.DeploymentExportResult": + self, deployment_name: str, **kwargs: Any + ) -> _models.DeploymentExportResult: """Exports the template used for specified deployment. - :param deployment_name: The name of the deployment from which to get the template. + :param deployment_name: The name of the deployment from which to get the template. Required. :type deployment_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: DeploymentExportResult, or the result of cls(response) + :return: DeploymentExportResult or the result of cls(response) :rtype: ~azure.mgmt.resource.resources.v2018_05_01.models.DeploymentExportResult - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.DeploymentExportResult"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + 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', "2018-05-01") # type: str + api_version = kwargs.pop("api_version", _params.pop("api-version", "2018-05-01")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[_models.DeploymentExportResult] - request = build_deployments_export_template_at_subscription_scope_request( deployment_name=deployment_name, subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.export_template_at_subscription_scope.metadata['url'], + template_url=self.export_template_at_subscription_scope.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) - deserialized = self._deserialize('DeploymentExportResult', pipeline_response) + deserialized = self._deserialize("DeploymentExportResult", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - export_template_at_subscription_scope.metadata = {'url': "/subscriptions/{subscriptionId}/providers/Microsoft.Resources/deployments/{deploymentName}/exportTemplate"} # type: ignore - + export_template_at_subscription_scope.metadata = {"url": "/subscriptions/{subscriptionId}/providers/Microsoft.Resources/deployments/{deploymentName}/exportTemplate"} # type: ignore @distributed_trace def list_at_subscription_scope( - self, - filter: Optional[str] = None, - top: Optional[int] = None, - **kwargs: Any - ) -> AsyncIterable["_models.DeploymentListResult"]: + self, filter: Optional[str] = None, top: Optional[int] = None, **kwargs: Any + ) -> AsyncIterable["_models.DeploymentExtended"]: """Get all the deployments for a subscription. :param filter: The filter to apply on the operation. For example, you can use @@ -663,40 +877,48 @@ def list_at_subscription_scope( value is None. :type top: int :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either DeploymentListResult or the result of - cls(response) + :return: An iterator like instance of either DeploymentExtended or the result of cls(response) :rtype: - ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.resource.resources.v2018_05_01.models.DeploymentListResult] - :raises: ~azure.core.exceptions.HttpResponseError + ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.resource.resources.v2018_05_01.models.DeploymentExtended] + :raises ~azure.core.exceptions.HttpResponseError: """ - api_version = kwargs.pop('api_version', "2018-05-01") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2018-05-01")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[_models.DeploymentListResult] - cls = kwargs.pop('cls', None) # type: ClsType["_models.DeploymentListResult"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) + def prepare_request(next_link=None): if not next_link: - + request = build_deployments_list_at_subscription_scope_request( subscription_id=self._config.subscription_id, - api_version=api_version, filter=filter, top=top, - template_url=self.list_at_subscription_scope.metadata['url'], + api_version=api_version, + template_url=self.list_at_subscription_scope.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore else: - - request = build_deployments_list_at_subscription_scope_request( - subscription_id=self._config.subscription_id, - template_url=next_link, - ) + # make call to next link with the client's api-version + _parsed_next_link = urlparse(next_link) + _next_request_params = case_insensitive_dict(parse_qs(_parsed_next_link.query)) + _next_request_params["api-version"] = self._config.api_version + request = HttpRequest("GET", urljoin(next_link, _parsed_next_link.path), params=_next_request_params) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore request.method = "GET" return request @@ -710,10 +932,8 @@ async def extract_data(pipeline_response): async def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) response = pipeline_response.http_response @@ -723,42 +943,43 @@ async def get_next(next_link=None): return pipeline_response + return AsyncItemPaged(get_next, extract_data) - return AsyncItemPaged( - get_next, extract_data - ) - list_at_subscription_scope.metadata = {'url': "/subscriptions/{subscriptionId}/providers/Microsoft.Resources/deployments/"} # type: ignore + list_at_subscription_scope.metadata = {"url": "/subscriptions/{subscriptionId}/providers/Microsoft.Resources/deployments/"} # type: ignore async def _delete_initial( # pylint: disable=inconsistent-return-statements - self, - resource_group_name: str, - deployment_name: str, - **kwargs: Any + self, resource_group_name: str, deployment_name: str, **kwargs: Any ) -> None: - cls = kwargs.pop('cls', None) # type: ClsType[None] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + 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', "2018-05-01") # type: str + api_version = kwargs.pop("api_version", _params.pop("api-version", "2018-05-01")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[None] - - request = build_deployments_delete_request_initial( + request = build_deployments_delete_request( resource_group_name=resource_group_name, deployment_name=deployment_name, subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self._delete_initial.metadata['url'], + template_url=self._delete_initial.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [202, 204]: @@ -768,16 +989,10 @@ 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.Resources/deployments/{deploymentName}"} # type: ignore - + _delete_initial.metadata = {"url": "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/Microsoft.Resources/deployments/{deploymentName}"} # type: ignore @distributed_trace_async - async def begin_delete( # pylint: disable=inconsistent-return-statements - self, - resource_group_name: str, - deployment_name: str, - **kwargs: Any - ) -> AsyncLROPoller[None]: + async def begin_delete(self, resource_group_name: str, deployment_name: str, **kwargs: Any) -> AsyncLROPoller[None]: """Deletes a deployment from the deployment history. A template deployment that is currently running cannot be deleted. Deleting a template @@ -790,9 +1005,9 @@ async def begin_delete( # pylint: disable=inconsistent-return-statements asynchronous request failed, the URI in the Location header returns an error-level status code. :param resource_group_name: The name of the resource group with the deployment to delete. The - name is case insensitive. + name is case insensitive. Required. :type resource_group_name: str - :param deployment_name: The name of the deployment to delete. + :param deployment_name: The name of the deployment to delete. Required. :type deployment_name: str :keyword callable cls: A custom type or function that will be passed the direct response :keyword str continuation_token: A continuation token to restart a poller from a saved state. @@ -804,88 +1019,93 @@ async def begin_delete( # pylint: disable=inconsistent-return-statements Retry-After header is present. :return: An instance of AsyncLROPoller that returns either None or the result of cls(response) :rtype: ~azure.core.polling.AsyncLROPoller[None] - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - api_version = kwargs.pop('api_version', "2018-05-01") # type: str - polling = kwargs.pop('polling', True) # type: Union[bool, AsyncPollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType[None] - lro_delay = kwargs.pop( - 'polling_interval', - self._config.polling_interval - ) - cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2018-05-01")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[None] + polling = kwargs.pop("polling", True) # type: Union[bool, AsyncPollingMethod] + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token = kwargs.pop("continuation_token", None) # type: Optional[str] if cont_token is None: - raw_result = await self._delete_initial( + raw_result = await self._delete_initial( # type: ignore resource_group_name=resource_group_name, deployment_name=deployment_name, api_version=api_version, - cls=lambda x,y,z: x, + cls=lambda x, y, z: x, + headers=_headers, + params=_params, **kwargs ) - kwargs.pop('error_map', None) + kwargs.pop("error_map", None) - def get_long_running_output(pipeline_response): + def get_long_running_output(pipeline_response): # pylint: disable=inconsistent-return-statements if cls: return cls(pipeline_response, None, {}) - - if polling is True: polling_method = AsyncARMPolling(lro_delay, **kwargs) - elif polling is False: polling_method = AsyncNoPolling() - else: polling_method = polling + if polling is True: + polling_method = cast(AsyncPollingMethod, AsyncARMPolling(lro_delay, **kwargs)) # type: AsyncPollingMethod + elif polling is False: + polling_method = cast(AsyncPollingMethod, AsyncNoPolling()) + else: + polling_method = polling if cont_token: return AsyncLROPoller.from_continuation_token( polling_method=polling_method, continuation_token=cont_token, client=self._client, - deserialization_callback=get_long_running_output + deserialization_callback=get_long_running_output, ) return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) - begin_delete.metadata = {'url': "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/Microsoft.Resources/deployments/{deploymentName}"} # type: ignore + begin_delete.metadata = {"url": "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/Microsoft.Resources/deployments/{deploymentName}"} # type: ignore @distributed_trace_async - async def check_existence( - self, - resource_group_name: str, - deployment_name: str, - **kwargs: Any - ) -> bool: + async def check_existence(self, resource_group_name: str, deployment_name: str, **kwargs: Any) -> bool: """Checks whether the deployment exists. :param resource_group_name: The name of the resource group with the deployment to check. The - name is case insensitive. + name is case insensitive. Required. :type resource_group_name: str - :param deployment_name: The name of the deployment to check. + :param deployment_name: The name of the deployment to check. Required. :type deployment_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: bool, or the result of cls(response) + :return: bool or the result of cls(response) :rtype: bool - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType[None] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) - api_version = kwargs.pop('api_version', "2018-05-01") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2018-05-01")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[None] - request = build_deployments_check_existence_request( resource_group_name=resource_group_name, deployment_name=deployment_name, subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.check_existence.metadata['url'], + template_url=self.check_existence.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [204, 404]: @@ -896,44 +1116,53 @@ async def check_existence( return cls(pipeline_response, None, {}) return 200 <= response.status_code <= 299 - check_existence.metadata = {'url': "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/Microsoft.Resources/deployments/{deploymentName}"} # type: ignore - + check_existence.metadata = {"url": "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/Microsoft.Resources/deployments/{deploymentName}"} # type: ignore async def _create_or_update_initial( - self, - resource_group_name: str, - deployment_name: str, - parameters: "_models.Deployment", - **kwargs: Any - ) -> "_models.DeploymentExtended": - cls = kwargs.pop('cls', None) # type: ClsType["_models.DeploymentExtended"] + self, resource_group_name: str, deployment_name: str, parameters: Union[_models.Deployment, IO], **kwargs: Any + ) -> _models.DeploymentExtended: error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', "2018-05-01") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + api_version = kwargs.pop("api_version", _params.pop("api-version", "2018-05-01")) # type: str + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.DeploymentExtended] - _json = self._serialize.body(parameters, 'Deployment') + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(parameters, (IO, bytes)): + _content = parameters + else: + _json = self._serialize.body(parameters, "Deployment") - request = build_deployments_create_or_update_request_initial( + request = build_deployments_create_or_update_request( resource_group_name=resource_group_name, deployment_name=deployment_name, subscription_id=self._config.subscription_id, api_version=api_version, content_type=content_type, json=_json, - template_url=self._create_or_update_initial.metadata['url'], + content=_content, + template_url=self._create_or_update_initial.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200, 201]: @@ -941,38 +1170,42 @@ async def _create_or_update_initial( raise HttpResponseError(response=response, error_format=ARMErrorFormat) if response.status_code == 200: - deserialized = self._deserialize('DeploymentExtended', pipeline_response) + deserialized = self._deserialize("DeploymentExtended", pipeline_response) if response.status_code == 201: - deserialized = self._deserialize('DeploymentExtended', pipeline_response) + deserialized = self._deserialize("DeploymentExtended", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - _create_or_update_initial.metadata = {'url': "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/Microsoft.Resources/deployments/{deploymentName}"} # type: ignore - + _create_or_update_initial.metadata = {"url": "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/Microsoft.Resources/deployments/{deploymentName}"} # type: ignore - @distributed_trace_async + @overload async def begin_create_or_update( self, resource_group_name: str, deployment_name: str, - parameters: "_models.Deployment", + parameters: _models.Deployment, + *, + content_type: str = "application/json", **kwargs: Any - ) -> AsyncLROPoller["_models.DeploymentExtended"]: + ) -> AsyncLROPoller[_models.DeploymentExtended]: """Deploys resources to a resource group. You can provide the template and parameters directly in the request or link to JSON files. :param resource_group_name: The name of the resource group to deploy the resources to. The name - is case insensitive. The resource group must already exist. + is case insensitive. The resource group must already exist. Required. :type resource_group_name: str - :param deployment_name: The name of the deployment. + :param deployment_name: The name of the deployment. Required. :type deployment_name: str - :param parameters: Additional parameters supplied to the operation. + :param parameters: Additional parameters supplied to the operation. Required. :type parameters: ~azure.mgmt.resource.resources.v2018_05_01.models.Deployment + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str :keyword callable cls: A custom type or function that will be passed the direct response :keyword str continuation_token: A continuation token to restart a poller from a saved state. :keyword polling: By default, your polling method will be AsyncARMPolling. Pass in False for @@ -985,115 +1218,189 @@ async def begin_create_or_update( cls(response) :rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.resource.resources.v2018_05_01.models.DeploymentExtended] - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - api_version = kwargs.pop('api_version', "2018-05-01") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] - polling = kwargs.pop('polling', True) # type: Union[bool, AsyncPollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType["_models.DeploymentExtended"] - lro_delay = kwargs.pop( - 'polling_interval', - self._config.polling_interval - ) - cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] + + @overload + async def begin_create_or_update( + self, + resource_group_name: str, + deployment_name: str, + parameters: IO, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> AsyncLROPoller[_models.DeploymentExtended]: + """Deploys resources to a resource group. + + You can provide the template and parameters directly in the request or link to JSON files. + + :param resource_group_name: The name of the resource group to deploy the resources to. The name + is case insensitive. The resource group must already exist. Required. + :type resource_group_name: str + :param deployment_name: The name of the deployment. Required. + :type deployment_name: str + :param parameters: Additional parameters supplied to the operation. Required. + :type parameters: IO + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be AsyncARMPolling. Pass in False for + this operation to not poll, or pass in your own initialized polling object for a personal + polling strategy. + :paramtype polling: bool or ~azure.core.polling.AsyncPollingMethod + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of AsyncLROPoller that returns either DeploymentExtended or the result of + cls(response) + :rtype: + ~azure.core.polling.AsyncLROPoller[~azure.mgmt.resource.resources.v2018_05_01.models.DeploymentExtended] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace_async + async def begin_create_or_update( + self, resource_group_name: str, deployment_name: str, parameters: Union[_models.Deployment, IO], **kwargs: Any + ) -> AsyncLROPoller[_models.DeploymentExtended]: + """Deploys resources to a resource group. + + You can provide the template and parameters directly in the request or link to JSON files. + + :param resource_group_name: The name of the resource group to deploy the resources to. The name + is case insensitive. The resource group must already exist. Required. + :type resource_group_name: str + :param deployment_name: The name of the deployment. Required. + :type deployment_name: str + :param parameters: Additional parameters supplied to the operation. Is either a model type or a + IO type. Required. + :type parameters: ~azure.mgmt.resource.resources.v2018_05_01.models.Deployment or IO + :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. + Default value is None. + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be AsyncARMPolling. Pass in False for + this operation to not poll, or pass in your own initialized polling object for a personal + polling strategy. + :paramtype polling: bool or ~azure.core.polling.AsyncPollingMethod + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of AsyncLROPoller that returns either DeploymentExtended or the result of + cls(response) + :rtype: + ~azure.core.polling.AsyncLROPoller[~azure.mgmt.resource.resources.v2018_05_01.models.DeploymentExtended] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _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", "2018-05-01")) # type: str + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.DeploymentExtended] + polling = kwargs.pop("polling", True) # type: Union[bool, AsyncPollingMethod] + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token = kwargs.pop("continuation_token", None) # type: Optional[str] if cont_token is None: - raw_result = await self._create_or_update_initial( + raw_result = await self._create_or_update_initial( # type: ignore resource_group_name=resource_group_name, deployment_name=deployment_name, parameters=parameters, api_version=api_version, content_type=content_type, - cls=lambda x,y,z: x, + cls=lambda x, y, z: x, + headers=_headers, + params=_params, **kwargs ) - kwargs.pop('error_map', None) + kwargs.pop("error_map", None) def get_long_running_output(pipeline_response): - response = pipeline_response.http_response - deserialized = self._deserialize('DeploymentExtended', pipeline_response) + deserialized = self._deserialize("DeploymentExtended", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - - if polling is True: polling_method = AsyncARMPolling(lro_delay, **kwargs) - elif polling is False: polling_method = AsyncNoPolling() - else: polling_method = polling + if polling is True: + polling_method = cast(AsyncPollingMethod, AsyncARMPolling(lro_delay, **kwargs)) # type: AsyncPollingMethod + elif polling is False: + polling_method = cast(AsyncPollingMethod, AsyncNoPolling()) + else: + polling_method = polling if cont_token: return AsyncLROPoller.from_continuation_token( polling_method=polling_method, continuation_token=cont_token, client=self._client, - deserialization_callback=get_long_running_output + deserialization_callback=get_long_running_output, ) return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) - begin_create_or_update.metadata = {'url': "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/Microsoft.Resources/deployments/{deploymentName}"} # type: ignore + begin_create_or_update.metadata = {"url": "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/Microsoft.Resources/deployments/{deploymentName}"} # type: ignore @distributed_trace_async - async def get( - self, - resource_group_name: str, - deployment_name: str, - **kwargs: Any - ) -> "_models.DeploymentExtended": + async def get(self, resource_group_name: str, deployment_name: str, **kwargs: Any) -> _models.DeploymentExtended: """Gets a deployment. :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. :type resource_group_name: str - :param deployment_name: The name of the deployment to get. + :param deployment_name: The name of the deployment to get. Required. :type deployment_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: DeploymentExtended, or the result of cls(response) + :return: DeploymentExtended or the result of cls(response) :rtype: ~azure.mgmt.resource.resources.v2018_05_01.models.DeploymentExtended - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.DeploymentExtended"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + 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', "2018-05-01") # type: str + api_version = kwargs.pop("api_version", _params.pop("api-version", "2018-05-01")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[_models.DeploymentExtended] - request = build_deployments_get_request( resource_group_name=resource_group_name, deployment_name=deployment_name, subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.get.metadata['url'], + template_url=self.get.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) - deserialized = self._deserialize('DeploymentExtended', pipeline_response) + deserialized = self._deserialize("DeploymentExtended", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - get.metadata = {'url': "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/Microsoft.Resources/deployments/{deploymentName}"} # type: ignore - + get.metadata = {"url": "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/Microsoft.Resources/deployments/{deploymentName}"} # type: ignore @distributed_trace_async async def cancel( # pylint: disable=inconsistent-return-statements - self, - resource_group_name: str, - deployment_name: str, - **kwargs: Any + self, resource_group_name: str, deployment_name: str, **kwargs: Any ) -> None: """Cancels a currently running template deployment. @@ -1103,38 +1410,45 @@ async def cancel( # pylint: disable=inconsistent-return-statements partially deployed. :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. :type resource_group_name: str - :param deployment_name: The name of the deployment to cancel. + :param deployment_name: The name of the deployment to cancel. Required. :type deployment_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: None, or the result of cls(response) + :return: None or the result of cls(response) :rtype: None - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType[None] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) - api_version = kwargs.pop('api_version', "2018-05-01") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2018-05-01")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[None] - request = build_deployments_cancel_request( resource_group_name=resource_group_name, deployment_name=deployment_name, subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.cancel.metadata['url'], + template_url=self.cancel.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [204]: @@ -1144,60 +1458,130 @@ async def cancel( # pylint: disable=inconsistent-return-statements if cls: return cls(pipeline_response, None, {}) - cancel.metadata = {'url': "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/Microsoft.Resources/deployments/{deploymentName}/cancel"} # type: ignore + cancel.metadata = {"url": "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/Microsoft.Resources/deployments/{deploymentName}/cancel"} # type: ignore - - @distributed_trace_async + @overload async def validate( self, resource_group_name: str, deployment_name: str, - parameters: "_models.Deployment", + parameters: _models.Deployment, + *, + content_type: str = "application/json", **kwargs: Any - ) -> "_models.DeploymentValidateResult": + ) -> _models.DeploymentValidateResult: """Validates whether the specified template is syntactically correct and will be accepted by Azure Resource Manager.. :param resource_group_name: The name of the resource group the template will be deployed to. - The name is case insensitive. + The name is case insensitive. Required. :type resource_group_name: str - :param deployment_name: The name of the deployment. + :param deployment_name: The name of the deployment. Required. :type deployment_name: str - :param parameters: Parameters to validate. + :param parameters: Parameters to validate. Required. :type parameters: ~azure.mgmt.resource.resources.v2018_05_01.models.Deployment + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: DeploymentValidateResult, or the result of cls(response) + :return: DeploymentValidateResult or the result of cls(response) :rtype: ~azure.mgmt.resource.resources.v2018_05_01.models.DeploymentValidateResult - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.DeploymentValidateResult"] - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {})) - - api_version = kwargs.pop('api_version', "2018-05-01") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] - - _json = self._serialize.body(parameters, 'Deployment') - request = build_deployments_validate_request( - resource_group_name=resource_group_name, - deployment_name=deployment_name, - subscription_id=self._config.subscription_id, + @overload + async def validate( + self, + resource_group_name: str, + deployment_name: str, + parameters: IO, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.DeploymentValidateResult: + """Validates whether the specified template is syntactically correct and will be accepted by Azure + Resource Manager.. + + :param resource_group_name: The name of the resource group the template will be deployed to. + The name is case insensitive. Required. + :type resource_group_name: str + :param deployment_name: The name of the deployment. Required. + :type deployment_name: str + :param parameters: Parameters to validate. Required. + :type parameters: IO + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: DeploymentValidateResult or the result of cls(response) + :rtype: ~azure.mgmt.resource.resources.v2018_05_01.models.DeploymentValidateResult + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace_async + async def validate( + self, resource_group_name: str, deployment_name: str, parameters: Union[_models.Deployment, IO], **kwargs: Any + ) -> _models.DeploymentValidateResult: + """Validates whether the specified template is syntactically correct and will be accepted by Azure + Resource Manager.. + + :param resource_group_name: The name of the resource group the template will be deployed to. + The name is case insensitive. Required. + :type resource_group_name: str + :param deployment_name: The name of the deployment. Required. + :type deployment_name: str + :param parameters: Parameters to validate. Is either a model type or a IO type. Required. + :type parameters: ~azure.mgmt.resource.resources.v2018_05_01.models.Deployment or IO + :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. + Default value is None. + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: DeploymentValidateResult or the result of cls(response) + :rtype: ~azure.mgmt.resource.resources.v2018_05_01.models.DeploymentValidateResult + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2018-05-01")) # type: str + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.DeploymentValidateResult] + + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(parameters, (IO, bytes)): + _content = parameters + else: + _json = self._serialize.body(parameters, "Deployment") + + request = build_deployments_validate_request( + resource_group_name=resource_group_name, + deployment_name=deployment_name, + subscription_id=self._config.subscription_id, api_version=api_version, content_type=content_type, json=_json, - template_url=self.validate.metadata['url'], + content=_content, + template_url=self.validate.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200, 400]: @@ -1205,89 +1589,87 @@ async def validate( raise HttpResponseError(response=response, error_format=ARMErrorFormat) if response.status_code == 200: - deserialized = self._deserialize('DeploymentValidateResult', pipeline_response) + deserialized = self._deserialize("DeploymentValidateResult", pipeline_response) if response.status_code == 400: - deserialized = self._deserialize('DeploymentValidateResult', pipeline_response) + deserialized = self._deserialize("DeploymentValidateResult", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - validate.metadata = {'url': "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/Microsoft.Resources/deployments/{deploymentName}/validate"} # type: ignore - + validate.metadata = {"url": "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/Microsoft.Resources/deployments/{deploymentName}/validate"} # type: ignore @distributed_trace_async async def export_template( - self, - resource_group_name: str, - deployment_name: str, - **kwargs: Any - ) -> "_models.DeploymentExportResult": + self, resource_group_name: str, deployment_name: str, **kwargs: Any + ) -> _models.DeploymentExportResult: """Exports the template used for specified deployment. :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. :type resource_group_name: str - :param deployment_name: The name of the deployment from which to get the template. + :param deployment_name: The name of the deployment from which to get the template. Required. :type deployment_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: DeploymentExportResult, or the result of cls(response) + :return: DeploymentExportResult or the result of cls(response) :rtype: ~azure.mgmt.resource.resources.v2018_05_01.models.DeploymentExportResult - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.DeploymentExportResult"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + 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', "2018-05-01") # type: str + api_version = kwargs.pop("api_version", _params.pop("api-version", "2018-05-01")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[_models.DeploymentExportResult] - request = build_deployments_export_template_request( resource_group_name=resource_group_name, deployment_name=deployment_name, subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.export_template.metadata['url'], + template_url=self.export_template.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) - deserialized = self._deserialize('DeploymentExportResult', pipeline_response) + deserialized = self._deserialize("DeploymentExportResult", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - export_template.metadata = {'url': "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/Microsoft.Resources/deployments/{deploymentName}/exportTemplate"} # type: ignore - + export_template.metadata = {"url": "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/Microsoft.Resources/deployments/{deploymentName}/exportTemplate"} # type: ignore @distributed_trace def list_by_resource_group( - self, - resource_group_name: str, - filter: Optional[str] = None, - top: Optional[int] = None, - **kwargs: Any - ) -> AsyncIterable["_models.DeploymentListResult"]: + self, resource_group_name: str, filter: Optional[str] = None, top: Optional[int] = None, **kwargs: Any + ) -> AsyncIterable["_models.DeploymentExtended"]: """Get all the deployments for a resource group. :param resource_group_name: The name of the resource group with the deployments to get. The - name is case insensitive. + name is case insensitive. Required. :type resource_group_name: str :param filter: The filter to apply on the operation. For example, you can use $filter=provisioningState eq '{state}'. Default value is None. @@ -1296,42 +1678,49 @@ def list_by_resource_group( value is None. :type top: int :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either DeploymentListResult or the result of - cls(response) + :return: An iterator like instance of either DeploymentExtended or the result of cls(response) :rtype: - ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.resource.resources.v2018_05_01.models.DeploymentListResult] - :raises: ~azure.core.exceptions.HttpResponseError + ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.resource.resources.v2018_05_01.models.DeploymentExtended] + :raises ~azure.core.exceptions.HttpResponseError: """ - api_version = kwargs.pop('api_version', "2018-05-01") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2018-05-01")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[_models.DeploymentListResult] - cls = kwargs.pop('cls', None) # type: ClsType["_models.DeploymentListResult"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) + def prepare_request(next_link=None): if not next_link: - + request = build_deployments_list_by_resource_group_request( resource_group_name=resource_group_name, subscription_id=self._config.subscription_id, - api_version=api_version, filter=filter, top=top, - template_url=self.list_by_resource_group.metadata['url'], + 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.url = self._client.format_url(request.url) # type: ignore else: - - request = build_deployments_list_by_resource_group_request( - resource_group_name=resource_group_name, - subscription_id=self._config.subscription_id, - template_url=next_link, - ) + # make call to next link with the client's api-version + _parsed_next_link = urlparse(next_link) + _next_request_params = case_insensitive_dict(parse_qs(_parsed_next_link.query)) + _next_request_params["api-version"] = self._config.api_version + request = HttpRequest("GET", urljoin(next_link, _parsed_next_link.path), params=_next_request_params) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore request.method = "GET" return request @@ -1345,10 +1734,8 @@ async def extract_data(pipeline_response): async def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) response = pipeline_response.http_response @@ -1358,204 +1745,204 @@ async def get_next(next_link=None): return pipeline_response + return AsyncItemPaged(get_next, extract_data) - return AsyncItemPaged( - get_next, extract_data - ) - list_by_resource_group.metadata = {'url': "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/Microsoft.Resources/deployments/"} # type: ignore + list_by_resource_group.metadata = {"url": "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/Microsoft.Resources/deployments/"} # type: ignore @distributed_trace_async - async def calculate_template_hash( - self, - template: Any, - **kwargs: Any - ) -> "_models.TemplateHashResult": + async def calculate_template_hash(self, template: JSON, **kwargs: Any) -> _models.TemplateHashResult: """Calculate the hash of the given template. - :param template: The template provided to calculate hash. - :type template: any + :param template: The template provided to calculate hash. Required. + :type template: JSON :keyword callable cls: A custom type or function that will be passed the direct response - :return: TemplateHashResult, or the result of cls(response) + :return: TemplateHashResult or the result of cls(response) :rtype: ~azure.mgmt.resource.resources.v2018_05_01.models.TemplateHashResult - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.TemplateHashResult"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', "2018-05-01") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + api_version = kwargs.pop("api_version", _params.pop("api-version", "2018-05-01")) # type: str + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", "application/json")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[_models.TemplateHashResult] - _json = self._serialize.body(template, 'object') + _json = self._serialize.body(template, "object") request = build_deployments_calculate_template_hash_request( api_version=api_version, content_type=content_type, json=_json, - template_url=self.calculate_template_hash.metadata['url'], + template_url=self.calculate_template_hash.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) - deserialized = self._deserialize('TemplateHashResult', pipeline_response) + deserialized = self._deserialize("TemplateHashResult", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - calculate_template_hash.metadata = {'url': "/providers/Microsoft.Resources/calculateTemplateHash"} # type: ignore + calculate_template_hash.metadata = {"url": "/providers/Microsoft.Resources/calculateTemplateHash"} # type: ignore -class ProvidersOperations: - """ProvidersOperations async operations. - You should not instantiate this class directly. Instead, you should create a Client instance that - instantiates it for you and attaches it as an attribute. +class ProvidersOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. - :ivar models: Alias to model classes used in this operation group. - :type models: ~azure.mgmt.resource.resources.v2018_05_01.models - :param client: Client for service requests. - :param config: Configuration of service client. - :param serializer: An object model serializer. - :param deserializer: An object model deserializer. + Instead, you should access the following operations through + :class:`~azure.mgmt.resource.resources.v2018_05_01.aio.ResourceManagementClient`'s + :attr:`providers` attribute. """ models = _models - def __init__(self, client, config, serializer, deserializer) -> None: - self._client = client - self._serialize = serializer - self._deserialize = deserializer - self._config = config + def __init__(self, *args, **kwargs) -> None: + input_args = list(args) + self._client = input_args.pop(0) if input_args else kwargs.pop("client") + self._config = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") @distributed_trace_async - async def unregister( - self, - resource_provider_namespace: str, - **kwargs: Any - ) -> "_models.Provider": + async def unregister(self, resource_provider_namespace: str, **kwargs: Any) -> _models.Provider: """Unregisters a subscription from a resource provider. :param resource_provider_namespace: The namespace of the resource provider to unregister. + Required. :type resource_provider_namespace: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: Provider, or the result of cls(response) + :return: Provider or the result of cls(response) :rtype: ~azure.mgmt.resource.resources.v2018_05_01.models.Provider - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.Provider"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + 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', "2018-05-01") # type: str + api_version = kwargs.pop("api_version", _params.pop("api-version", "2018-05-01")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[_models.Provider] - request = build_providers_unregister_request( resource_provider_namespace=resource_provider_namespace, subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.unregister.metadata['url'], + template_url=self.unregister.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) - deserialized = self._deserialize('Provider', pipeline_response) + deserialized = self._deserialize("Provider", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - unregister.metadata = {'url': "/subscriptions/{subscriptionId}/providers/{resourceProviderNamespace}/unregister"} # type: ignore - + unregister.metadata = {"url": "/subscriptions/{subscriptionId}/providers/{resourceProviderNamespace}/unregister"} # type: ignore @distributed_trace_async - async def register( - self, - resource_provider_namespace: str, - **kwargs: Any - ) -> "_models.Provider": + async def register(self, resource_provider_namespace: str, **kwargs: Any) -> _models.Provider: """Registers a subscription with a resource provider. :param resource_provider_namespace: The namespace of the resource provider to register. + Required. :type resource_provider_namespace: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: Provider, or the result of cls(response) + :return: Provider or the result of cls(response) :rtype: ~azure.mgmt.resource.resources.v2018_05_01.models.Provider - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.Provider"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + 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', "2018-05-01") # type: str + api_version = kwargs.pop("api_version", _params.pop("api-version", "2018-05-01")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[_models.Provider] - request = build_providers_register_request( resource_provider_namespace=resource_provider_namespace, subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.register.metadata['url'], + template_url=self.register.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) - deserialized = self._deserialize('Provider', pipeline_response) + deserialized = self._deserialize("Provider", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - register.metadata = {'url': "/subscriptions/{subscriptionId}/providers/{resourceProviderNamespace}/register"} # type: ignore - + register.metadata = {"url": "/subscriptions/{subscriptionId}/providers/{resourceProviderNamespace}/register"} # type: ignore @distributed_trace def list( - self, - top: Optional[int] = None, - expand: Optional[str] = None, - **kwargs: Any - ) -> AsyncIterable["_models.ProviderListResult"]: + self, top: Optional[int] = None, expand: Optional[str] = None, **kwargs: Any + ) -> AsyncIterable["_models.Provider"]: """Gets all resource providers for a subscription. :param top: The number of results to return. If null is passed returns all deployments. Default @@ -1566,39 +1953,48 @@ def list( response, use $expand=resourceTypes/aliases. Default value is None. :type expand: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either ProviderListResult or the result of cls(response) + :return: An iterator like instance of either Provider or the result of cls(response) :rtype: - ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.resource.resources.v2018_05_01.models.ProviderListResult] - :raises: ~azure.core.exceptions.HttpResponseError + ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.resource.resources.v2018_05_01.models.Provider] + :raises ~azure.core.exceptions.HttpResponseError: """ - api_version = kwargs.pop('api_version', "2018-05-01") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2018-05-01")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[_models.ProviderListResult] - cls = kwargs.pop('cls', None) # type: ClsType["_models.ProviderListResult"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) + def prepare_request(next_link=None): if not next_link: - + request = build_providers_list_request( subscription_id=self._config.subscription_id, - api_version=api_version, top=top, expand=expand, - template_url=self.list.metadata['url'], + 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.url = self._client.format_url(request.url) # type: ignore else: - - request = build_providers_list_request( - subscription_id=self._config.subscription_id, - template_url=next_link, - ) + # make call to next link with the client's api-version + _parsed_next_link = urlparse(next_link) + _next_request_params = case_insensitive_dict(parse_qs(_parsed_next_link.query)) + _next_request_params["api-version"] = self._config.api_version + request = HttpRequest("GET", urljoin(next_link, _parsed_next_link.path), params=_next_request_params) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore request.method = "GET" return request @@ -1612,10 +2008,8 @@ async def extract_data(pipeline_response): async def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) response = pipeline_response.http_response @@ -1625,91 +2019,90 @@ async def get_next(next_link=None): return pipeline_response + return AsyncItemPaged(get_next, extract_data) - return AsyncItemPaged( - get_next, extract_data - ) - list.metadata = {'url': "/subscriptions/{subscriptionId}/providers"} # type: ignore + list.metadata = {"url": "/subscriptions/{subscriptionId}/providers"} # type: ignore @distributed_trace_async async def get( - self, - resource_provider_namespace: str, - expand: Optional[str] = None, - **kwargs: Any - ) -> "_models.Provider": + self, resource_provider_namespace: str, expand: Optional[str] = None, **kwargs: Any + ) -> _models.Provider: """Gets the specified resource provider. - :param resource_provider_namespace: The namespace of the resource provider. + :param resource_provider_namespace: The namespace of the resource provider. Required. :type resource_provider_namespace: str :param expand: The $expand query parameter. For example, to include property aliases in response, use $expand=resourceTypes/aliases. Default value is None. :type expand: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: Provider, or the result of cls(response) + :return: Provider or the result of cls(response) :rtype: ~azure.mgmt.resource.resources.v2018_05_01.models.Provider - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.Provider"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) - api_version = kwargs.pop('api_version', "2018-05-01") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2018-05-01")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[_models.Provider] - request = build_providers_get_request( resource_provider_namespace=resource_provider_namespace, subscription_id=self._config.subscription_id, - api_version=api_version, expand=expand, - template_url=self.get.metadata['url'], + api_version=api_version, + template_url=self.get.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) - deserialized = self._deserialize('Provider', pipeline_response) + deserialized = self._deserialize("Provider", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - get.metadata = {'url': "/subscriptions/{subscriptionId}/providers/{resourceProviderNamespace}"} # type: ignore + get.metadata = {"url": "/subscriptions/{subscriptionId}/providers/{resourceProviderNamespace}"} # type: ignore -class ResourcesOperations: # pylint: disable=too-many-public-methods - """ResourcesOperations async operations. - You should not instantiate this class directly. Instead, you should create a Client instance that - instantiates it for you and attaches it as an attribute. +class ResourcesOperations: # pylint: disable=too-many-public-methods + """ + .. warning:: + **DO NOT** instantiate this class directly. - :ivar models: Alias to model classes used in this operation group. - :type models: ~azure.mgmt.resource.resources.v2018_05_01.models - :param client: Client for service requests. - :param config: Configuration of service client. - :param serializer: An object model serializer. - :param deserializer: An object model deserializer. + Instead, you should access the following operations through + :class:`~azure.mgmt.resource.resources.v2018_05_01.aio.ResourceManagementClient`'s + :attr:`resources` attribute. """ models = _models - def __init__(self, client, config, serializer, deserializer) -> None: - self._client = client - self._serialize = serializer - self._deserialize = deserializer - self._config = config + def __init__(self, *args, **kwargs) -> None: + input_args = list(args) + self._client = input_args.pop(0) if input_args else kwargs.pop("client") + self._config = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") @distributed_trace def list_by_resource_group( @@ -1719,10 +2112,10 @@ def list_by_resource_group( expand: Optional[str] = None, top: Optional[int] = None, **kwargs: Any - ) -> AsyncIterable["_models.ResourceListResult"]: + ) -> AsyncIterable["_models.GenericResourceExpanded"]: """Get all the resources for a resource group. - :param resource_group_name: The resource group with the resources to get. + :param resource_group_name: The resource group with the resources to get. Required. :type resource_group_name: str :param filter: The filter to apply on the operation.:code:`
`:code:`
`The properties you can use for eq (equals) or ne (not equals) are: location, resourceType, name, resourceGroup, @@ -1747,42 +2140,51 @@ def list_by_resource_group( value is None. :type top: int :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either ResourceListResult or the result of cls(response) + :return: An iterator like instance of either GenericResourceExpanded or the result of + cls(response) :rtype: - ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.resource.resources.v2018_05_01.models.ResourceListResult] - :raises: ~azure.core.exceptions.HttpResponseError + ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.resource.resources.v2018_05_01.models.GenericResourceExpanded] + :raises ~azure.core.exceptions.HttpResponseError: """ - api_version = kwargs.pop('api_version', "2018-05-01") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2018-05-01")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[_models.ResourceListResult] - cls = kwargs.pop('cls', None) # type: ClsType["_models.ResourceListResult"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) + def prepare_request(next_link=None): if not next_link: - + request = build_resources_list_by_resource_group_request( resource_group_name=resource_group_name, subscription_id=self._config.subscription_id, - api_version=api_version, filter=filter, expand=expand, top=top, - template_url=self.list_by_resource_group.metadata['url'], + 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.url = self._client.format_url(request.url) # type: ignore else: - - request = build_resources_list_by_resource_group_request( - resource_group_name=resource_group_name, - subscription_id=self._config.subscription_id, - template_url=next_link, - ) + # make call to next link with the client's api-version + _parsed_next_link = urlparse(next_link) + _next_request_params = case_insensitive_dict(parse_qs(_parsed_next_link.query)) + _next_request_params["api-version"] = self._config.api_version + request = HttpRequest("GET", urljoin(next_link, _parsed_next_link.path), params=_next_request_params) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore request.method = "GET" return request @@ -1796,10 +2198,8 @@ async def extract_data(pipeline_response): async def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) response = pipeline_response.http_response @@ -1809,45 +2209,54 @@ async def get_next(next_link=None): return pipeline_response + return AsyncItemPaged(get_next, extract_data) - return AsyncItemPaged( - get_next, extract_data - ) - list_by_resource_group.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/resources"} # type: ignore + list_by_resource_group.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/resources"} # type: ignore async def _move_resources_initial( # pylint: disable=inconsistent-return-statements - self, - source_resource_group_name: str, - parameters: "_models.ResourcesMoveInfo", - **kwargs: Any + self, source_resource_group_name: str, parameters: Union[_models.ResourcesMoveInfo, IO], **kwargs: Any ) -> None: - cls = kwargs.pop('cls', None) # type: ClsType[None] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) - api_version = kwargs.pop('api_version', "2018-05-01") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - _json = self._serialize.body(parameters, 'ResourcesMoveInfo') + api_version = kwargs.pop("api_version", _params.pop("api-version", "2018-05-01")) # type: str + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[None] - request = build_resources_move_resources_request_initial( + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(parameters, (IO, bytes)): + _content = parameters + else: + _json = self._serialize.body(parameters, "ResourcesMoveInfo") + + request = build_resources_move_resources_request( source_resource_group_name=source_resource_group_name, subscription_id=self._config.subscription_id, api_version=api_version, content_type=content_type, json=_json, - template_url=self._move_resources_initial.metadata['url'], + content=_content, + template_url=self._move_resources_initial.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [202, 204]: @@ -1857,14 +2266,15 @@ async def _move_resources_initial( # pylint: disable=inconsistent-return-statem if cls: return cls(pipeline_response, None, {}) - _move_resources_initial.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{sourceResourceGroupName}/moveResources"} # type: ignore + _move_resources_initial.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{sourceResourceGroupName}/moveResources"} # type: ignore - - @distributed_trace_async - async def begin_move_resources( # pylint: disable=inconsistent-return-statements + @overload + async def begin_move_resources( self, source_resource_group_name: str, - parameters: "_models.ResourcesMoveInfo", + parameters: _models.ResourcesMoveInfo, + *, + content_type: str = "application/json", **kwargs: Any ) -> AsyncLROPoller[None]: """Moves resources from one resource group to another resource group. @@ -1875,10 +2285,13 @@ async def begin_move_resources( # pylint: disable=inconsistent-return-statement the groups until the move completes. :param source_resource_group_name: The name of the resource group containing the resources to - move. + move. Required. :type source_resource_group_name: str - :param parameters: Parameters for moving resources. + :param parameters: Parameters for moving resources. Required. :type parameters: ~azure.mgmt.resource.resources.v2018_05_01.models.ResourcesMoveInfo + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str :keyword callable cls: A custom type or function that will be passed the direct response :keyword str continuation_token: A continuation token to restart a poller from a saved state. :keyword polling: By default, your polling method will be AsyncARMPolling. Pass in False for @@ -1889,80 +2302,160 @@ async def begin_move_resources( # pylint: disable=inconsistent-return-statement Retry-After header is present. :return: An instance of AsyncLROPoller that returns either None or the result of cls(response) :rtype: ~azure.core.polling.AsyncLROPoller[None] - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - api_version = kwargs.pop('api_version', "2018-05-01") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] - polling = kwargs.pop('polling', True) # type: Union[bool, AsyncPollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType[None] - lro_delay = kwargs.pop( - 'polling_interval', - self._config.polling_interval - ) - cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] + + @overload + async def begin_move_resources( + self, source_resource_group_name: str, parameters: IO, *, content_type: str = "application/json", **kwargs: Any + ) -> AsyncLROPoller[None]: + """Moves resources from one resource group to another resource group. + + The resources to move must be in the same source resource group. The target resource group may + be in a different subscription. When moving resources, both the source group and the target + group are locked for the duration of the operation. Write and delete operations are blocked on + the groups until the move completes. + + :param source_resource_group_name: The name of the resource group containing the resources to + move. Required. + :type source_resource_group_name: str + :param parameters: Parameters for moving resources. Required. + :type parameters: IO + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be AsyncARMPolling. Pass in False for + this operation to not poll, or pass in your own initialized polling object for a personal + polling strategy. + :paramtype polling: bool or ~azure.core.polling.AsyncPollingMethod + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of AsyncLROPoller that returns either None or the result of cls(response) + :rtype: ~azure.core.polling.AsyncLROPoller[None] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace_async + async def begin_move_resources( + self, source_resource_group_name: str, parameters: Union[_models.ResourcesMoveInfo, IO], **kwargs: Any + ) -> AsyncLROPoller[None]: + """Moves resources from one resource group to another resource group. + + The resources to move must be in the same source resource group. The target resource group may + be in a different subscription. When moving resources, both the source group and the target + group are locked for the duration of the operation. Write and delete operations are blocked on + the groups until the move completes. + + :param source_resource_group_name: The name of the resource group containing the resources to + move. Required. + :type source_resource_group_name: str + :param parameters: Parameters for moving resources. Is either a model type or a IO type. + Required. + :type parameters: ~azure.mgmt.resource.resources.v2018_05_01.models.ResourcesMoveInfo or IO + :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. + Default value is None. + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be AsyncARMPolling. Pass in False for + this operation to not poll, or pass in your own initialized polling object for a personal + polling strategy. + :paramtype polling: bool or ~azure.core.polling.AsyncPollingMethod + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of AsyncLROPoller that returns either None or the result of cls(response) + :rtype: ~azure.core.polling.AsyncLROPoller[None] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _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", "2018-05-01")) # type: str + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[None] + polling = kwargs.pop("polling", True) # type: Union[bool, AsyncPollingMethod] + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token = kwargs.pop("continuation_token", None) # type: Optional[str] if cont_token is None: - raw_result = await self._move_resources_initial( + raw_result = await self._move_resources_initial( # type: ignore source_resource_group_name=source_resource_group_name, parameters=parameters, api_version=api_version, content_type=content_type, - cls=lambda x,y,z: x, + cls=lambda x, y, z: x, + headers=_headers, + params=_params, **kwargs ) - kwargs.pop('error_map', None) + kwargs.pop("error_map", None) - def get_long_running_output(pipeline_response): + def get_long_running_output(pipeline_response): # pylint: disable=inconsistent-return-statements if cls: return cls(pipeline_response, None, {}) - - if polling is True: polling_method = AsyncARMPolling(lro_delay, **kwargs) - elif polling is False: polling_method = AsyncNoPolling() - else: polling_method = polling + if polling is True: + polling_method = cast(AsyncPollingMethod, AsyncARMPolling(lro_delay, **kwargs)) # type: AsyncPollingMethod + elif polling is False: + polling_method = cast(AsyncPollingMethod, AsyncNoPolling()) + else: + polling_method = polling if cont_token: return AsyncLROPoller.from_continuation_token( polling_method=polling_method, continuation_token=cont_token, client=self._client, - deserialization_callback=get_long_running_output + deserialization_callback=get_long_running_output, ) return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) - begin_move_resources.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{sourceResourceGroupName}/moveResources"} # type: ignore + begin_move_resources.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{sourceResourceGroupName}/moveResources"} # type: ignore async def _validate_move_resources_initial( # pylint: disable=inconsistent-return-statements - self, - source_resource_group_name: str, - parameters: "_models.ResourcesMoveInfo", - **kwargs: Any + self, source_resource_group_name: str, parameters: Union[_models.ResourcesMoveInfo, IO], **kwargs: Any ) -> None: - cls = kwargs.pop('cls', None) # type: ClsType[None] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) - api_version = kwargs.pop('api_version', "2018-05-01") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - _json = self._serialize.body(parameters, 'ResourcesMoveInfo') + api_version = kwargs.pop("api_version", _params.pop("api-version", "2018-05-01")) # type: str + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[None] - request = build_resources_validate_move_resources_request_initial( + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(parameters, (IO, bytes)): + _content = parameters + else: + _json = self._serialize.body(parameters, "ResourcesMoveInfo") + + request = build_resources_validate_move_resources_request( source_resource_group_name=source_resource_group_name, subscription_id=self._config.subscription_id, api_version=api_version, content_type=content_type, json=_json, - template_url=self._validate_move_resources_initial.metadata['url'], + content=_content, + template_url=self._validate_move_resources_initial.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [202, 204, 409]: @@ -1972,14 +2465,15 @@ async def _validate_move_resources_initial( # pylint: disable=inconsistent-retu if cls: return cls(pipeline_response, None, {}) - _validate_move_resources_initial.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{sourceResourceGroupName}/validateMoveResources"} # type: ignore + _validate_move_resources_initial.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{sourceResourceGroupName}/validateMoveResources"} # type: ignore - - @distributed_trace_async - async def begin_validate_move_resources( # pylint: disable=inconsistent-return-statements + @overload + async def begin_validate_move_resources( self, source_resource_group_name: str, - parameters: "_models.ResourcesMoveInfo", + parameters: _models.ResourcesMoveInfo, + *, + content_type: str = "application/json", **kwargs: Any ) -> AsyncLROPoller[None]: """Validates whether resources can be moved from one resource group to another resource group. @@ -1992,10 +2486,13 @@ async def begin_validate_move_resources( # pylint: disable=inconsistent-return- operation. :param source_resource_group_name: The name of the resource group containing the resources to - validate for move. + validate for move. Required. :type source_resource_group_name: str - :param parameters: Parameters for moving resources. + :param parameters: Parameters for moving resources. Required. :type parameters: ~azure.mgmt.resource.resources.v2018_05_01.models.ResourcesMoveInfo + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str :keyword callable cls: A custom type or function that will be passed the direct response :keyword str continuation_token: A continuation token to restart a poller from a saved state. :keyword polling: By default, your polling method will be AsyncARMPolling. Pass in False for @@ -2006,55 +2503,124 @@ async def begin_validate_move_resources( # pylint: disable=inconsistent-return- Retry-After header is present. :return: An instance of AsyncLROPoller that returns either None or the result of cls(response) :rtype: ~azure.core.polling.AsyncLROPoller[None] - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - api_version = kwargs.pop('api_version', "2018-05-01") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] - polling = kwargs.pop('polling', True) # type: Union[bool, AsyncPollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType[None] - lro_delay = kwargs.pop( - 'polling_interval', - self._config.polling_interval - ) - cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] + + @overload + async def begin_validate_move_resources( + self, source_resource_group_name: str, parameters: IO, *, content_type: str = "application/json", **kwargs: Any + ) -> AsyncLROPoller[None]: + """Validates whether resources can be moved from one resource group to another resource group. + + This operation checks whether the specified resources can be moved to the target. The resources + to move must be in the same source resource group. The target resource group may be in a + different subscription. If validation succeeds, it returns HTTP response code 204 (no content). + If validation fails, it returns HTTP response code 409 (Conflict) with an error message. + Retrieve the URL in the Location header value to check the result of the long-running + operation. + + :param source_resource_group_name: The name of the resource group containing the resources to + validate for move. Required. + :type source_resource_group_name: str + :param parameters: Parameters for moving resources. Required. + :type parameters: IO + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be AsyncARMPolling. Pass in False for + this operation to not poll, or pass in your own initialized polling object for a personal + polling strategy. + :paramtype polling: bool or ~azure.core.polling.AsyncPollingMethod + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of AsyncLROPoller that returns either None or the result of cls(response) + :rtype: ~azure.core.polling.AsyncLROPoller[None] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace_async + async def begin_validate_move_resources( + self, source_resource_group_name: str, parameters: Union[_models.ResourcesMoveInfo, IO], **kwargs: Any + ) -> AsyncLROPoller[None]: + """Validates whether resources can be moved from one resource group to another resource group. + + This operation checks whether the specified resources can be moved to the target. The resources + to move must be in the same source resource group. The target resource group may be in a + different subscription. If validation succeeds, it returns HTTP response code 204 (no content). + If validation fails, it returns HTTP response code 409 (Conflict) with an error message. + Retrieve the URL in the Location header value to check the result of the long-running + operation. + + :param source_resource_group_name: The name of the resource group containing the resources to + validate for move. Required. + :type source_resource_group_name: str + :param parameters: Parameters for moving resources. Is either a model type or a IO type. + Required. + :type parameters: ~azure.mgmt.resource.resources.v2018_05_01.models.ResourcesMoveInfo or IO + :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. + Default value is None. + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be AsyncARMPolling. Pass in False for + this operation to not poll, or pass in your own initialized polling object for a personal + polling strategy. + :paramtype polling: bool or ~azure.core.polling.AsyncPollingMethod + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of AsyncLROPoller that returns either None or the result of cls(response) + :rtype: ~azure.core.polling.AsyncLROPoller[None] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _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", "2018-05-01")) # type: str + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[None] + polling = kwargs.pop("polling", True) # type: Union[bool, AsyncPollingMethod] + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token = kwargs.pop("continuation_token", None) # type: Optional[str] if cont_token is None: - raw_result = await self._validate_move_resources_initial( + raw_result = await self._validate_move_resources_initial( # type: ignore source_resource_group_name=source_resource_group_name, parameters=parameters, api_version=api_version, content_type=content_type, - cls=lambda x,y,z: x, + cls=lambda x, y, z: x, + headers=_headers, + params=_params, **kwargs ) - kwargs.pop('error_map', None) + kwargs.pop("error_map", None) - def get_long_running_output(pipeline_response): + def get_long_running_output(pipeline_response): # pylint: disable=inconsistent-return-statements if cls: return cls(pipeline_response, None, {}) - - if polling is True: polling_method = AsyncARMPolling(lro_delay, **kwargs) - elif polling is False: polling_method = AsyncNoPolling() - else: polling_method = polling + if polling is True: + polling_method = cast(AsyncPollingMethod, AsyncARMPolling(lro_delay, **kwargs)) # type: AsyncPollingMethod + elif polling is False: + polling_method = cast(AsyncPollingMethod, AsyncNoPolling()) + else: + polling_method = polling if cont_token: return AsyncLROPoller.from_continuation_token( polling_method=polling_method, continuation_token=cont_token, client=self._client, - deserialization_callback=get_long_running_output + deserialization_callback=get_long_running_output, ) return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) - begin_validate_move_resources.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{sourceResourceGroupName}/validateMoveResources"} # type: ignore + begin_validate_move_resources.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{sourceResourceGroupName}/validateMoveResources"} # type: ignore @distributed_trace def list( - self, - filter: Optional[str] = None, - expand: Optional[str] = None, - top: Optional[int] = None, - **kwargs: Any - ) -> AsyncIterable["_models.ResourceListResult"]: + self, filter: Optional[str] = None, expand: Optional[str] = None, top: Optional[int] = None, **kwargs: Any + ) -> AsyncIterable["_models.GenericResourceExpanded"]: """Get all the resources in a subscription. :param filter: The filter to apply on the operation.:code:`
`:code:`
`The properties you @@ -2080,40 +2646,50 @@ def list( value is None. :type top: int :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either ResourceListResult or the result of cls(response) + :return: An iterator like instance of either GenericResourceExpanded or the result of + cls(response) :rtype: - ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.resource.resources.v2018_05_01.models.ResourceListResult] - :raises: ~azure.core.exceptions.HttpResponseError + ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.resource.resources.v2018_05_01.models.GenericResourceExpanded] + :raises ~azure.core.exceptions.HttpResponseError: """ - api_version = kwargs.pop('api_version', "2018-05-01") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2018-05-01")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[_models.ResourceListResult] - cls = kwargs.pop('cls', None) # type: ClsType["_models.ResourceListResult"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) + def prepare_request(next_link=None): if not next_link: - + request = build_resources_list_request( subscription_id=self._config.subscription_id, - api_version=api_version, filter=filter, expand=expand, top=top, - template_url=self.list.metadata['url'], + 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.url = self._client.format_url(request.url) # type: ignore else: - - request = build_resources_list_request( - subscription_id=self._config.subscription_id, - template_url=next_link, - ) + # make call to next link with the client's api-version + _parsed_next_link = urlparse(next_link) + _next_request_params = case_insensitive_dict(parse_qs(_parsed_next_link.query)) + _next_request_params["api-version"] = self._config.api_version + request = HttpRequest("GET", urljoin(next_link, _parsed_next_link.path), params=_next_request_params) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore request.method = "GET" return request @@ -2127,10 +2703,8 @@ async def extract_data(pipeline_response): async def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) response = pipeline_response.http_response @@ -2140,11 +2714,9 @@ async def get_next(next_link=None): return pipeline_response + return AsyncItemPaged(get_next, extract_data) - return AsyncItemPaged( - get_next, extract_data - ) - list.metadata = {'url': "/subscriptions/{subscriptionId}/resources"} # type: ignore + list.metadata = {"url": "/subscriptions/{subscriptionId}/resources"} # type: ignore @distributed_trace_async async def check_existence( @@ -2160,30 +2732,36 @@ async def check_existence( """Checks whether a resource exists. :param resource_group_name: The name of the resource group containing the resource to check. - The name is case insensitive. + The name is case insensitive. Required. :type resource_group_name: str - :param resource_provider_namespace: The resource provider of the resource to check. + :param resource_provider_namespace: The resource provider of the resource to check. Required. :type resource_provider_namespace: str - :param parent_resource_path: The parent resource identity. + :param parent_resource_path: The parent resource identity. Required. :type parent_resource_path: str - :param resource_type: The resource type. + :param resource_type: The resource type. Required. :type resource_type: str - :param resource_name: The name of the resource to check whether it exists. + :param resource_name: The name of the resource to check whether it exists. Required. :type resource_name: str - :param api_version: The API version to use for the operation. + :param api_version: The API version to use for the operation. Required. :type api_version: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: bool, or the result of cls(response) + :return: bool or the result of cls(response) :rtype: bool - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType[None] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = kwargs.pop("params", {}) or {} + + cls = kwargs.pop("cls", None) # type: ClsType[None] - request = build_resources_check_existence_request( resource_group_name=resource_group_name, resource_provider_namespace=resource_provider_namespace, @@ -2192,16 +2770,17 @@ async def check_existence( resource_name=resource_name, subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.check_existence.metadata['url'], + template_url=self.check_existence.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [204, 404]: @@ -2212,8 +2791,7 @@ async def check_existence( return cls(pipeline_response, None, {}) return 200 <= response.status_code <= 299 - check_existence.metadata = {'url': "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{parentResourcePath}/{resourceType}/{resourceName}"} # type: ignore - + check_existence.metadata = {"url": "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{parentResourcePath}/{resourceType}/{resourceName}"} # type: ignore async def _delete_initial( # pylint: disable=inconsistent-return-statements self, @@ -2225,31 +2803,38 @@ async def _delete_initial( # pylint: disable=inconsistent-return-statements api_version: str, **kwargs: Any ) -> None: - cls = kwargs.pop('cls', None) # type: ClsType[None] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) - - request = build_resources_delete_request_initial( - resource_group_name=resource_group_name, + _headers = kwargs.pop("headers", {}) or {} + _params = kwargs.pop("params", {}) or {} + + cls = kwargs.pop("cls", None) # type: ClsType[None] + + request = build_resources_delete_request( + resource_group_name=resource_group_name, resource_provider_namespace=resource_provider_namespace, parent_resource_path=parent_resource_path, resource_type=resource_type, resource_name=resource_name, subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self._delete_initial.metadata['url'], + template_url=self._delete_initial.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200, 202, 204]: @@ -2259,11 +2844,10 @@ 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/{resourceProviderNamespace}/{parentResourcePath}/{resourceType}/{resourceName}"} # type: ignore - + _delete_initial.metadata = {"url": "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{parentResourcePath}/{resourceType}/{resourceName}"} # type: ignore @distributed_trace_async - async def begin_delete( # pylint: disable=inconsistent-return-statements + async def begin_delete( self, resource_group_name: str, resource_provider_namespace: str, @@ -2276,17 +2860,17 @@ async def begin_delete( # pylint: disable=inconsistent-return-statements """Deletes a resource. :param resource_group_name: The name of the resource group that contains the resource to - delete. The name is case insensitive. + delete. The name is case insensitive. Required. :type resource_group_name: str - :param resource_provider_namespace: The namespace of the resource provider. + :param resource_provider_namespace: The namespace of the resource provider. Required. :type resource_provider_namespace: str - :param parent_resource_path: The parent resource identity. + :param parent_resource_path: The parent resource identity. Required. :type parent_resource_path: str - :param resource_type: The resource type. + :param resource_type: The resource type. Required. :type resource_type: str - :param resource_name: The name of the resource to delete. + :param resource_name: The name of the resource to delete. Required. :type resource_name: str - :param api_version: The API version to use for the operation. + :param api_version: The API version to use for the operation. Required. :type api_version: str :keyword callable cls: A custom type or function that will be passed the direct response :keyword str continuation_token: A continuation token to restart a poller from a saved state. @@ -2298,46 +2882,50 @@ async def begin_delete( # pylint: disable=inconsistent-return-statements Retry-After header is present. :return: An instance of AsyncLROPoller that returns either None or the result of cls(response) :rtype: ~azure.core.polling.AsyncLROPoller[None] - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - polling = kwargs.pop('polling', True) # type: Union[bool, AsyncPollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType[None] - lro_delay = kwargs.pop( - 'polling_interval', - self._config.polling_interval - ) - cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] + _headers = kwargs.pop("headers", {}) or {} + _params = kwargs.pop("params", {}) or {} + + cls = kwargs.pop("cls", None) # type: ClsType[None] + polling = kwargs.pop("polling", True) # type: Union[bool, AsyncPollingMethod] + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token = kwargs.pop("continuation_token", None) # type: Optional[str] if cont_token is None: - raw_result = await self._delete_initial( + raw_result = await self._delete_initial( # type: ignore resource_group_name=resource_group_name, resource_provider_namespace=resource_provider_namespace, parent_resource_path=parent_resource_path, resource_type=resource_type, resource_name=resource_name, api_version=api_version, - cls=lambda x,y,z: x, + cls=lambda x, y, z: x, + headers=_headers, + params=_params, **kwargs ) - kwargs.pop('error_map', None) + kwargs.pop("error_map", None) - def get_long_running_output(pipeline_response): + def get_long_running_output(pipeline_response): # pylint: disable=inconsistent-return-statements if cls: return cls(pipeline_response, None, {}) - - if polling is True: polling_method = AsyncARMPolling(lro_delay, **kwargs) - elif polling is False: polling_method = AsyncNoPolling() - else: polling_method = polling + if polling is True: + polling_method = cast(AsyncPollingMethod, AsyncARMPolling(lro_delay, **kwargs)) # type: AsyncPollingMethod + elif polling is False: + polling_method = cast(AsyncPollingMethod, AsyncNoPolling()) + else: + polling_method = polling if cont_token: return AsyncLROPoller.from_continuation_token( polling_method=polling_method, continuation_token=cont_token, client=self._client, - deserialization_callback=get_long_running_output + deserialization_callback=get_long_running_output, ) return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) - begin_delete.metadata = {'url': "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{parentResourcePath}/{resourceType}/{resourceName}"} # type: ignore + begin_delete.metadata = {"url": "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{parentResourcePath}/{resourceType}/{resourceName}"} # type: ignore async def _create_or_update_initial( self, @@ -2347,39 +2935,53 @@ async def _create_or_update_initial( resource_type: str, resource_name: str, api_version: str, - parameters: "_models.GenericResource", + parameters: Union[_models.GenericResource, IO], **kwargs: Any - ) -> Optional["_models.GenericResource"]: - cls = kwargs.pop('cls', None) # type: ClsType[Optional["_models.GenericResource"]] + ) -> Optional[_models.GenericResource]: error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = kwargs.pop("params", {}) or {} - _json = self._serialize.body(parameters, 'GenericResource') + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[Optional[_models.GenericResource]] - request = build_resources_create_or_update_request_initial( + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(parameters, (IO, bytes)): + _content = parameters + else: + _json = self._serialize.body(parameters, "GenericResource") + + request = build_resources_create_or_update_request( resource_group_name=resource_group_name, resource_provider_namespace=resource_provider_namespace, parent_resource_path=parent_resource_path, resource_type=resource_type, resource_name=resource_name, subscription_id=self._config.subscription_id, - content_type=content_type, api_version=api_version, + content_type=content_type, json=_json, - template_url=self._create_or_update_initial.metadata['url'], + content=_content, + template_url=self._create_or_update_initial.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200, 201, 202]: @@ -2388,18 +2990,115 @@ async def _create_or_update_initial( deserialized = None if response.status_code == 200: - deserialized = self._deserialize('GenericResource', pipeline_response) + deserialized = self._deserialize("GenericResource", pipeline_response) if response.status_code == 201: - deserialized = self._deserialize('GenericResource', pipeline_response) + deserialized = self._deserialize("GenericResource", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - _create_or_update_initial.metadata = {'url': "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{parentResourcePath}/{resourceType}/{resourceName}"} # type: ignore + _create_or_update_initial.metadata = {"url": "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{parentResourcePath}/{resourceType}/{resourceName}"} # type: ignore + @overload + async def begin_create_or_update( + self, + resource_group_name: str, + resource_provider_namespace: str, + parent_resource_path: str, + resource_type: str, + resource_name: str, + api_version: str, + parameters: _models.GenericResource, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> AsyncLROPoller[_models.GenericResource]: + """Creates a resource. + + :param resource_group_name: The name of the resource group for the resource. The name is case + insensitive. Required. + :type resource_group_name: str + :param resource_provider_namespace: The namespace of the resource provider. Required. + :type resource_provider_namespace: str + :param parent_resource_path: The parent resource identity. Required. + :type parent_resource_path: str + :param resource_type: The resource type of the resource to create. Required. + :type resource_type: str + :param resource_name: The name of the resource to create. Required. + :type resource_name: str + :param api_version: The API version to use for the operation. Required. + :type api_version: str + :param parameters: Parameters for creating or updating the resource. Required. + :type parameters: ~azure.mgmt.resource.resources.v2018_05_01.models.GenericResource + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be AsyncARMPolling. Pass in False for + this operation to not poll, or pass in your own initialized polling object for a personal + polling strategy. + :paramtype polling: bool or ~azure.core.polling.AsyncPollingMethod + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of AsyncLROPoller that returns either GenericResource or the result of + cls(response) + :rtype: + ~azure.core.polling.AsyncLROPoller[~azure.mgmt.resource.resources.v2018_05_01.models.GenericResource] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + async def begin_create_or_update( + self, + resource_group_name: str, + resource_provider_namespace: str, + parent_resource_path: str, + resource_type: str, + resource_name: str, + api_version: str, + parameters: IO, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> AsyncLROPoller[_models.GenericResource]: + """Creates a resource. + + :param resource_group_name: The name of the resource group for the resource. The name is case + insensitive. Required. + :type resource_group_name: str + :param resource_provider_namespace: The namespace of the resource provider. Required. + :type resource_provider_namespace: str + :param parent_resource_path: The parent resource identity. Required. + :type parent_resource_path: str + :param resource_type: The resource type of the resource to create. Required. + :type resource_type: str + :param resource_name: The name of the resource to create. Required. + :type resource_name: str + :param api_version: The API version to use for the operation. Required. + :type api_version: str + :param parameters: Parameters for creating or updating the resource. Required. + :type parameters: IO + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be AsyncARMPolling. Pass in False for + this operation to not poll, or pass in your own initialized polling object for a personal + polling strategy. + :paramtype polling: bool or ~azure.core.polling.AsyncPollingMethod + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of AsyncLROPoller that returns either GenericResource or the result of + cls(response) + :rtype: + ~azure.core.polling.AsyncLROPoller[~azure.mgmt.resource.resources.v2018_05_01.models.GenericResource] + :raises ~azure.core.exceptions.HttpResponseError: + """ @distributed_trace_async async def begin_create_or_update( @@ -2410,26 +3109,30 @@ async def begin_create_or_update( resource_type: str, resource_name: str, api_version: str, - parameters: "_models.GenericResource", + parameters: Union[_models.GenericResource, IO], **kwargs: Any - ) -> AsyncLROPoller["_models.GenericResource"]: + ) -> AsyncLROPoller[_models.GenericResource]: """Creates a resource. :param resource_group_name: The name of the resource group for the resource. The name is case - insensitive. + insensitive. Required. :type resource_group_name: str - :param resource_provider_namespace: The namespace of the resource provider. + :param resource_provider_namespace: The namespace of the resource provider. Required. :type resource_provider_namespace: str - :param parent_resource_path: The parent resource identity. + :param parent_resource_path: The parent resource identity. Required. :type parent_resource_path: str - :param resource_type: The resource type of the resource to create. + :param resource_type: The resource type of the resource to create. Required. :type resource_type: str - :param resource_name: The name of the resource to create. + :param resource_name: The name of the resource to create. Required. :type resource_name: str - :param api_version: The API version to use for the operation. + :param api_version: The API version to use for the operation. Required. :type api_version: str - :param parameters: Parameters for creating or updating the resource. - :type parameters: ~azure.mgmt.resource.resources.v2018_05_01.models.GenericResource + :param parameters: Parameters for creating or updating the resource. Is either a model type or + a IO type. Required. + :type parameters: ~azure.mgmt.resource.resources.v2018_05_01.models.GenericResource or IO + :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. + Default value is None. + :paramtype content_type: str :keyword callable cls: A custom type or function that will be passed the direct response :keyword str continuation_token: A continuation token to restart a poller from a saved state. :keyword polling: By default, your polling method will be AsyncARMPolling. Pass in False for @@ -2442,18 +3145,18 @@ async def begin_create_or_update( cls(response) :rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.resource.resources.v2018_05_01.models.GenericResource] - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] - polling = kwargs.pop('polling', True) # type: Union[bool, AsyncPollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType["_models.GenericResource"] - lro_delay = kwargs.pop( - 'polling_interval', - self._config.polling_interval - ) - cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = kwargs.pop("params", {}) or {} + + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.GenericResource] + polling = kwargs.pop("polling", True) # type: Union[bool, AsyncPollingMethod] + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token = kwargs.pop("continuation_token", None) # type: Optional[str] if cont_token is None: - raw_result = await self._create_or_update_initial( + raw_result = await self._create_or_update_initial( # type: ignore resource_group_name=resource_group_name, resource_provider_namespace=resource_provider_namespace, parent_resource_path=parent_resource_path, @@ -2462,32 +3165,35 @@ async def begin_create_or_update( api_version=api_version, parameters=parameters, content_type=content_type, - cls=lambda x,y,z: x, + cls=lambda x, y, z: x, + headers=_headers, + params=_params, **kwargs ) - kwargs.pop('error_map', None) + kwargs.pop("error_map", None) def get_long_running_output(pipeline_response): - response = pipeline_response.http_response - deserialized = self._deserialize('GenericResource', pipeline_response) + deserialized = self._deserialize("GenericResource", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - - if polling is True: polling_method = AsyncARMPolling(lro_delay, **kwargs) - elif polling is False: polling_method = AsyncNoPolling() - else: polling_method = polling + if polling is True: + polling_method = cast(AsyncPollingMethod, AsyncARMPolling(lro_delay, **kwargs)) # type: AsyncPollingMethod + elif polling is False: + polling_method = cast(AsyncPollingMethod, AsyncNoPolling()) + else: + polling_method = polling if cont_token: return AsyncLROPoller.from_continuation_token( polling_method=polling_method, continuation_token=cont_token, client=self._client, - deserialization_callback=get_long_running_output + deserialization_callback=get_long_running_output, ) return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) - begin_create_or_update.metadata = {'url': "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{parentResourcePath}/{resourceType}/{resourceName}"} # type: ignore + begin_create_or_update.metadata = {"url": "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{parentResourcePath}/{resourceType}/{resourceName}"} # type: ignore async def _update_initial( self, @@ -2497,39 +3203,53 @@ async def _update_initial( resource_type: str, resource_name: str, api_version: str, - parameters: "_models.GenericResource", + parameters: Union[_models.GenericResource, IO], **kwargs: Any - ) -> Optional["_models.GenericResource"]: - cls = kwargs.pop('cls', None) # type: ClsType[Optional["_models.GenericResource"]] + ) -> Optional[_models.GenericResource]: error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = kwargs.pop("params", {}) or {} - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[Optional[_models.GenericResource]] - _json = self._serialize.body(parameters, 'GenericResource') + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(parameters, (IO, bytes)): + _content = parameters + else: + _json = self._serialize.body(parameters, "GenericResource") - request = build_resources_update_request_initial( + request = build_resources_update_request( resource_group_name=resource_group_name, resource_provider_namespace=resource_provider_namespace, parent_resource_path=parent_resource_path, resource_type=resource_type, resource_name=resource_name, subscription_id=self._config.subscription_id, - content_type=content_type, api_version=api_version, + content_type=content_type, json=_json, - template_url=self._update_initial.metadata['url'], + content=_content, + template_url=self._update_initial.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200, 202]: @@ -2538,15 +3258,112 @@ async def _update_initial( deserialized = None if response.status_code == 200: - deserialized = self._deserialize('GenericResource', pipeline_response) + deserialized = self._deserialize("GenericResource", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - _update_initial.metadata = {'url': "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{parentResourcePath}/{resourceType}/{resourceName}"} # type: ignore + _update_initial.metadata = {"url": "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{parentResourcePath}/{resourceType}/{resourceName}"} # type: ignore + @overload + async def begin_update( + self, + resource_group_name: str, + resource_provider_namespace: str, + parent_resource_path: str, + resource_type: str, + resource_name: str, + api_version: str, + parameters: _models.GenericResource, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> AsyncLROPoller[_models.GenericResource]: + """Updates a resource. + + :param resource_group_name: The name of the resource group for the resource. The name is case + insensitive. Required. + :type resource_group_name: str + :param resource_provider_namespace: The namespace of the resource provider. Required. + :type resource_provider_namespace: str + :param parent_resource_path: The parent resource identity. Required. + :type parent_resource_path: str + :param resource_type: The resource type of the resource to update. Required. + :type resource_type: str + :param resource_name: The name of the resource to update. Required. + :type resource_name: str + :param api_version: The API version to use for the operation. Required. + :type api_version: str + :param parameters: Parameters for updating the resource. Required. + :type parameters: ~azure.mgmt.resource.resources.v2018_05_01.models.GenericResource + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be AsyncARMPolling. Pass in False for + this operation to not poll, or pass in your own initialized polling object for a personal + polling strategy. + :paramtype polling: bool or ~azure.core.polling.AsyncPollingMethod + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of AsyncLROPoller that returns either GenericResource or the result of + cls(response) + :rtype: + ~azure.core.polling.AsyncLROPoller[~azure.mgmt.resource.resources.v2018_05_01.models.GenericResource] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + async def begin_update( + self, + resource_group_name: str, + resource_provider_namespace: str, + parent_resource_path: str, + resource_type: str, + resource_name: str, + api_version: str, + parameters: IO, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> AsyncLROPoller[_models.GenericResource]: + """Updates a resource. + + :param resource_group_name: The name of the resource group for the resource. The name is case + insensitive. Required. + :type resource_group_name: str + :param resource_provider_namespace: The namespace of the resource provider. Required. + :type resource_provider_namespace: str + :param parent_resource_path: The parent resource identity. Required. + :type parent_resource_path: str + :param resource_type: The resource type of the resource to update. Required. + :type resource_type: str + :param resource_name: The name of the resource to update. Required. + :type resource_name: str + :param api_version: The API version to use for the operation. Required. + :type api_version: str + :param parameters: Parameters for updating the resource. Required. + :type parameters: IO + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be AsyncARMPolling. Pass in False for + this operation to not poll, or pass in your own initialized polling object for a personal + polling strategy. + :paramtype polling: bool or ~azure.core.polling.AsyncPollingMethod + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of AsyncLROPoller that returns either GenericResource or the result of + cls(response) + :rtype: + ~azure.core.polling.AsyncLROPoller[~azure.mgmt.resource.resources.v2018_05_01.models.GenericResource] + :raises ~azure.core.exceptions.HttpResponseError: + """ @distributed_trace_async async def begin_update( @@ -2557,26 +3374,30 @@ async def begin_update( resource_type: str, resource_name: str, api_version: str, - parameters: "_models.GenericResource", + parameters: Union[_models.GenericResource, IO], **kwargs: Any - ) -> AsyncLROPoller["_models.GenericResource"]: + ) -> AsyncLROPoller[_models.GenericResource]: """Updates a resource. :param resource_group_name: The name of the resource group for the resource. The name is case - insensitive. + insensitive. Required. :type resource_group_name: str - :param resource_provider_namespace: The namespace of the resource provider. + :param resource_provider_namespace: The namespace of the resource provider. Required. :type resource_provider_namespace: str - :param parent_resource_path: The parent resource identity. + :param parent_resource_path: The parent resource identity. Required. :type parent_resource_path: str - :param resource_type: The resource type of the resource to update. + :param resource_type: The resource type of the resource to update. Required. :type resource_type: str - :param resource_name: The name of the resource to update. + :param resource_name: The name of the resource to update. Required. :type resource_name: str - :param api_version: The API version to use for the operation. + :param api_version: The API version to use for the operation. Required. :type api_version: str - :param parameters: Parameters for updating the resource. - :type parameters: ~azure.mgmt.resource.resources.v2018_05_01.models.GenericResource + :param parameters: Parameters for updating the resource. Is either a model type or a IO type. + Required. + :type parameters: ~azure.mgmt.resource.resources.v2018_05_01.models.GenericResource or IO + :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. + Default value is None. + :paramtype content_type: str :keyword callable cls: A custom type or function that will be passed the direct response :keyword str continuation_token: A continuation token to restart a poller from a saved state. :keyword polling: By default, your polling method will be AsyncARMPolling. Pass in False for @@ -2589,18 +3410,18 @@ async def begin_update( cls(response) :rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.resource.resources.v2018_05_01.models.GenericResource] - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] - polling = kwargs.pop('polling', True) # type: Union[bool, AsyncPollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType["_models.GenericResource"] - lro_delay = kwargs.pop( - 'polling_interval', - self._config.polling_interval - ) - cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = kwargs.pop("params", {}) or {} + + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.GenericResource] + polling = kwargs.pop("polling", True) # type: Union[bool, AsyncPollingMethod] + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token = kwargs.pop("continuation_token", None) # type: Optional[str] if cont_token is None: - raw_result = await self._update_initial( + raw_result = await self._update_initial( # type: ignore resource_group_name=resource_group_name, resource_provider_namespace=resource_provider_namespace, parent_resource_path=parent_resource_path, @@ -2609,32 +3430,35 @@ async def begin_update( api_version=api_version, parameters=parameters, content_type=content_type, - cls=lambda x,y,z: x, + cls=lambda x, y, z: x, + headers=_headers, + params=_params, **kwargs ) - kwargs.pop('error_map', None) + kwargs.pop("error_map", None) def get_long_running_output(pipeline_response): - response = pipeline_response.http_response - deserialized = self._deserialize('GenericResource', pipeline_response) + deserialized = self._deserialize("GenericResource", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - - if polling is True: polling_method = AsyncARMPolling(lro_delay, **kwargs) - elif polling is False: polling_method = AsyncNoPolling() - else: polling_method = polling + if polling is True: + polling_method = cast(AsyncPollingMethod, AsyncARMPolling(lro_delay, **kwargs)) # type: AsyncPollingMethod + elif polling is False: + polling_method = cast(AsyncPollingMethod, AsyncNoPolling()) + else: + polling_method = polling if cont_token: return AsyncLROPoller.from_continuation_token( polling_method=polling_method, continuation_token=cont_token, client=self._client, - deserialization_callback=get_long_running_output + deserialization_callback=get_long_running_output, ) return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) - begin_update.metadata = {'url': "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{parentResourcePath}/{resourceType}/{resourceName}"} # type: ignore + begin_update.metadata = {"url": "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{parentResourcePath}/{resourceType}/{resourceName}"} # type: ignore @distributed_trace_async async def get( @@ -2646,34 +3470,40 @@ async def get( resource_name: str, api_version: str, **kwargs: Any - ) -> "_models.GenericResource": + ) -> _models.GenericResource: """Gets a resource. :param resource_group_name: The name of the resource group containing the resource to get. The - name is case insensitive. + name is case insensitive. Required. :type resource_group_name: str - :param resource_provider_namespace: The namespace of the resource provider. + :param resource_provider_namespace: The namespace of the resource provider. Required. :type resource_provider_namespace: str - :param parent_resource_path: The parent resource identity. + :param parent_resource_path: The parent resource identity. Required. :type parent_resource_path: str - :param resource_type: The resource type of the resource. + :param resource_type: The resource type of the resource. Required. :type resource_type: str - :param resource_name: The name of the resource to get. + :param resource_name: The name of the resource to get. Required. :type resource_name: str - :param api_version: The API version to use for the operation. + :param api_version: The API version to use for the operation. Required. :type api_version: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: GenericResource, or the result of cls(response) + :return: GenericResource or the result of cls(response) :rtype: ~azure.mgmt.resource.resources.v2018_05_01.models.GenericResource - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.GenericResource"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = kwargs.pop("params", {}) or {} + + cls = kwargs.pop("cls", None) # type: ClsType[_models.GenericResource] - request = build_resources_get_request( resource_group_name=resource_group_name, resource_provider_namespace=resource_provider_namespace, @@ -2682,72 +3512,75 @@ async def get( resource_name=resource_name, subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.get.metadata['url'], + template_url=self.get.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) - deserialized = self._deserialize('GenericResource', pipeline_response) + deserialized = self._deserialize("GenericResource", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - get.metadata = {'url': "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{parentResourcePath}/{resourceType}/{resourceName}"} # type: ignore - + get.metadata = {"url": "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{parentResourcePath}/{resourceType}/{resourceName}"} # type: ignore @distributed_trace_async - async def check_existence_by_id( - self, - resource_id: str, - api_version: str, - **kwargs: Any - ) -> bool: + async def check_existence_by_id(self, resource_id: str, api_version: str, **kwargs: Any) -> bool: """Checks by ID whether a resource exists. :param resource_id: The fully qualified ID of the resource, including the resource name and resource type. Use the format, /subscriptions/{guid}/resourceGroups/{resource-group-name}/{resource-provider-namespace}/{resource-type}/{resource-name}. + Required. :type resource_id: str - :param api_version: The API version to use for the operation. + :param api_version: The API version to use for the operation. Required. :type api_version: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: bool, or the result of cls(response) + :return: bool or the result of cls(response) :rtype: bool - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType[None] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = kwargs.pop("params", {}) or {} + + cls = kwargs.pop("cls", None) # type: ClsType[None] - request = build_resources_check_existence_by_id_request( resource_id=resource_id, api_version=api_version, - template_url=self.check_existence_by_id.metadata['url'], + template_url=self.check_existence_by_id.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [204, 404]: @@ -2758,35 +3591,38 @@ async def check_existence_by_id( return cls(pipeline_response, None, {}) return 200 <= response.status_code <= 299 - check_existence_by_id.metadata = {'url': "/{resourceId}"} # type: ignore - + check_existence_by_id.metadata = {"url": "/{resourceId}"} # type: ignore async def _delete_by_id_initial( # pylint: disable=inconsistent-return-statements - self, - resource_id: str, - api_version: str, - **kwargs: Any + self, resource_id: str, api_version: str, **kwargs: Any ) -> None: - cls = kwargs.pop('cls', None) # type: ClsType[None] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = kwargs.pop("params", {}) or {} - - request = build_resources_delete_by_id_request_initial( + cls = kwargs.pop("cls", None) # type: ClsType[None] + + request = build_resources_delete_by_id_request( resource_id=resource_id, api_version=api_version, - template_url=self._delete_by_id_initial.metadata['url'], + template_url=self._delete_by_id_initial.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200, 202, 204]: @@ -2796,23 +3632,18 @@ async def _delete_by_id_initial( # pylint: disable=inconsistent-return-statemen if cls: return cls(pipeline_response, None, {}) - _delete_by_id_initial.metadata = {'url': "/{resourceId}"} # type: ignore - + _delete_by_id_initial.metadata = {"url": "/{resourceId}"} # type: ignore @distributed_trace_async - async def begin_delete_by_id( # pylint: disable=inconsistent-return-statements - self, - resource_id: str, - api_version: str, - **kwargs: Any - ) -> AsyncLROPoller[None]: + async def begin_delete_by_id(self, resource_id: str, api_version: str, **kwargs: Any) -> AsyncLROPoller[None]: """Deletes a resource by ID. :param resource_id: The fully qualified ID of the resource, including the resource name and resource type. Use the format, /subscriptions/{guid}/resourceGroups/{resource-group-name}/{resource-provider-namespace}/{resource-type}/{resource-name}. + Required. :type resource_id: str - :param api_version: The API version to use for the operation. + :param api_version: The API version to use for the operation. Required. :type api_version: str :keyword callable cls: A custom type or function that will be passed the direct response :keyword str continuation_token: A continuation token to restart a poller from a saved state. @@ -2824,75 +3655,89 @@ async def begin_delete_by_id( # pylint: disable=inconsistent-return-statements Retry-After header is present. :return: An instance of AsyncLROPoller that returns either None or the result of cls(response) :rtype: ~azure.core.polling.AsyncLROPoller[None] - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - polling = kwargs.pop('polling', True) # type: Union[bool, AsyncPollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType[None] - lro_delay = kwargs.pop( - 'polling_interval', - self._config.polling_interval - ) - cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] + _headers = kwargs.pop("headers", {}) or {} + _params = kwargs.pop("params", {}) or {} + + cls = kwargs.pop("cls", None) # type: ClsType[None] + polling = kwargs.pop("polling", True) # type: Union[bool, AsyncPollingMethod] + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token = kwargs.pop("continuation_token", None) # type: Optional[str] if cont_token is None: - raw_result = await self._delete_by_id_initial( + raw_result = await self._delete_by_id_initial( # type: ignore resource_id=resource_id, api_version=api_version, - cls=lambda x,y,z: x, + cls=lambda x, y, z: x, + headers=_headers, + params=_params, **kwargs ) - kwargs.pop('error_map', None) + kwargs.pop("error_map", None) - def get_long_running_output(pipeline_response): + def get_long_running_output(pipeline_response): # pylint: disable=inconsistent-return-statements if cls: return cls(pipeline_response, None, {}) - - if polling is True: polling_method = AsyncARMPolling(lro_delay, **kwargs) - elif polling is False: polling_method = AsyncNoPolling() - else: polling_method = polling + if polling is True: + polling_method = cast(AsyncPollingMethod, AsyncARMPolling(lro_delay, **kwargs)) # type: AsyncPollingMethod + elif polling is False: + polling_method = cast(AsyncPollingMethod, AsyncNoPolling()) + else: + polling_method = polling if cont_token: return AsyncLROPoller.from_continuation_token( polling_method=polling_method, continuation_token=cont_token, client=self._client, - deserialization_callback=get_long_running_output + deserialization_callback=get_long_running_output, ) return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) - begin_delete_by_id.metadata = {'url': "/{resourceId}"} # type: ignore + begin_delete_by_id.metadata = {"url": "/{resourceId}"} # type: ignore async def _create_or_update_by_id_initial( - self, - resource_id: str, - api_version: str, - parameters: "_models.GenericResource", - **kwargs: Any - ) -> Optional["_models.GenericResource"]: - cls = kwargs.pop('cls', None) # type: ClsType[Optional["_models.GenericResource"]] + self, resource_id: str, api_version: str, parameters: Union[_models.GenericResource, IO], **kwargs: Any + ) -> Optional[_models.GenericResource]: error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = kwargs.pop("params", {}) or {} - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[Optional[_models.GenericResource]] - _json = self._serialize.body(parameters, 'GenericResource') + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(parameters, (IO, bytes)): + _content = parameters + else: + _json = self._serialize.body(parameters, "GenericResource") - request = build_resources_create_or_update_by_id_request_initial( + request = build_resources_create_or_update_by_id_request( resource_id=resource_id, - content_type=content_type, api_version=api_version, + content_type=content_type, json=_json, - template_url=self._create_or_update_by_id_initial.metadata['url'], + content=_content, + template_url=self._create_or_update_by_id_initial.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200, 201, 202]: @@ -2901,37 +3746,42 @@ async def _create_or_update_by_id_initial( deserialized = None if response.status_code == 200: - deserialized = self._deserialize('GenericResource', pipeline_response) + deserialized = self._deserialize("GenericResource", pipeline_response) if response.status_code == 201: - deserialized = self._deserialize('GenericResource', pipeline_response) + deserialized = self._deserialize("GenericResource", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - _create_or_update_by_id_initial.metadata = {'url': "/{resourceId}"} # type: ignore + _create_or_update_by_id_initial.metadata = {"url": "/{resourceId}"} # type: ignore - - @distributed_trace_async + @overload async def begin_create_or_update_by_id( self, resource_id: str, api_version: str, - parameters: "_models.GenericResource", + parameters: _models.GenericResource, + *, + content_type: str = "application/json", **kwargs: Any - ) -> AsyncLROPoller["_models.GenericResource"]: + ) -> AsyncLROPoller[_models.GenericResource]: """Create a resource by ID. :param resource_id: The fully qualified ID of the resource, including the resource name and resource type. Use the format, /subscriptions/{guid}/resourceGroups/{resource-group-name}/{resource-provider-namespace}/{resource-type}/{resource-name}. + Required. :type resource_id: str - :param api_version: The API version to use for the operation. + :param api_version: The API version to use for the operation. Required. :type api_version: str - :param parameters: Create or update resource parameters. + :param parameters: Create or update resource parameters. Required. :type parameters: ~azure.mgmt.resource.resources.v2018_05_01.models.GenericResource + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str :keyword callable cls: A custom type or function that will be passed the direct response :keyword str continuation_token: A continuation token to restart a poller from a saved state. :keyword polling: By default, your polling method will be AsyncARMPolling. Pass in False for @@ -2944,81 +3794,167 @@ async def begin_create_or_update_by_id( cls(response) :rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.resource.resources.v2018_05_01.models.GenericResource] - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] - polling = kwargs.pop('polling', True) # type: Union[bool, AsyncPollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType["_models.GenericResource"] - lro_delay = kwargs.pop( - 'polling_interval', - self._config.polling_interval - ) - cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] + + @overload + async def begin_create_or_update_by_id( + self, + resource_id: str, + api_version: str, + parameters: IO, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> AsyncLROPoller[_models.GenericResource]: + """Create a resource by ID. + + :param resource_id: The fully qualified ID of the resource, including the resource name and + resource type. Use the format, + /subscriptions/{guid}/resourceGroups/{resource-group-name}/{resource-provider-namespace}/{resource-type}/{resource-name}. + Required. + :type resource_id: str + :param api_version: The API version to use for the operation. Required. + :type api_version: str + :param parameters: Create or update resource parameters. Required. + :type parameters: IO + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be AsyncARMPolling. Pass in False for + this operation to not poll, or pass in your own initialized polling object for a personal + polling strategy. + :paramtype polling: bool or ~azure.core.polling.AsyncPollingMethod + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of AsyncLROPoller that returns either GenericResource or the result of + cls(response) + :rtype: + ~azure.core.polling.AsyncLROPoller[~azure.mgmt.resource.resources.v2018_05_01.models.GenericResource] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace_async + async def begin_create_or_update_by_id( + self, resource_id: str, api_version: str, parameters: Union[_models.GenericResource, IO], **kwargs: Any + ) -> AsyncLROPoller[_models.GenericResource]: + """Create a resource by ID. + + :param resource_id: The fully qualified ID of the resource, including the resource name and + resource type. Use the format, + /subscriptions/{guid}/resourceGroups/{resource-group-name}/{resource-provider-namespace}/{resource-type}/{resource-name}. + Required. + :type resource_id: str + :param api_version: The API version to use for the operation. Required. + :type api_version: str + :param parameters: Create or update resource parameters. Is either a model type or a IO type. + Required. + :type parameters: ~azure.mgmt.resource.resources.v2018_05_01.models.GenericResource or IO + :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. + Default value is None. + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be AsyncARMPolling. Pass in False for + this operation to not poll, or pass in your own initialized polling object for a personal + polling strategy. + :paramtype polling: bool or ~azure.core.polling.AsyncPollingMethod + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of AsyncLROPoller that returns either GenericResource or the result of + cls(response) + :rtype: + ~azure.core.polling.AsyncLROPoller[~azure.mgmt.resource.resources.v2018_05_01.models.GenericResource] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = kwargs.pop("params", {}) or {} + + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.GenericResource] + polling = kwargs.pop("polling", True) # type: Union[bool, AsyncPollingMethod] + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token = kwargs.pop("continuation_token", None) # type: Optional[str] if cont_token is None: - raw_result = await self._create_or_update_by_id_initial( + raw_result = await self._create_or_update_by_id_initial( # type: ignore resource_id=resource_id, api_version=api_version, parameters=parameters, content_type=content_type, - cls=lambda x,y,z: x, + cls=lambda x, y, z: x, + headers=_headers, + params=_params, **kwargs ) - kwargs.pop('error_map', None) + kwargs.pop("error_map", None) def get_long_running_output(pipeline_response): - response = pipeline_response.http_response - deserialized = self._deserialize('GenericResource', pipeline_response) + deserialized = self._deserialize("GenericResource", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - - if polling is True: polling_method = AsyncARMPolling(lro_delay, **kwargs) - elif polling is False: polling_method = AsyncNoPolling() - else: polling_method = polling + if polling is True: + polling_method = cast(AsyncPollingMethod, AsyncARMPolling(lro_delay, **kwargs)) # type: AsyncPollingMethod + elif polling is False: + polling_method = cast(AsyncPollingMethod, AsyncNoPolling()) + else: + polling_method = polling if cont_token: return AsyncLROPoller.from_continuation_token( polling_method=polling_method, continuation_token=cont_token, client=self._client, - deserialization_callback=get_long_running_output + deserialization_callback=get_long_running_output, ) return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) - begin_create_or_update_by_id.metadata = {'url': "/{resourceId}"} # type: ignore + begin_create_or_update_by_id.metadata = {"url": "/{resourceId}"} # type: ignore async def _update_by_id_initial( - self, - resource_id: str, - api_version: str, - parameters: "_models.GenericResource", - **kwargs: Any - ) -> Optional["_models.GenericResource"]: - cls = kwargs.pop('cls', None) # type: ClsType[Optional["_models.GenericResource"]] + self, resource_id: str, api_version: str, parameters: Union[_models.GenericResource, IO], **kwargs: Any + ) -> Optional[_models.GenericResource]: error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = kwargs.pop("params", {}) or {} - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[Optional[_models.GenericResource]] - _json = self._serialize.body(parameters, 'GenericResource') + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(parameters, (IO, bytes)): + _content = parameters + else: + _json = self._serialize.body(parameters, "GenericResource") - request = build_resources_update_by_id_request_initial( + request = build_resources_update_by_id_request( resource_id=resource_id, - content_type=content_type, api_version=api_version, + content_type=content_type, json=_json, - template_url=self._update_by_id_initial.metadata['url'], + content=_content, + template_url=self._update_by_id_initial.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200, 202]: @@ -3027,34 +3963,78 @@ async def _update_by_id_initial( deserialized = None if response.status_code == 200: - deserialized = self._deserialize('GenericResource', pipeline_response) + deserialized = self._deserialize("GenericResource", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - _update_by_id_initial.metadata = {'url': "/{resourceId}"} # type: ignore + _update_by_id_initial.metadata = {"url": "/{resourceId}"} # type: ignore + + @overload + async def begin_update_by_id( + self, + resource_id: str, + api_version: str, + parameters: _models.GenericResource, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> AsyncLROPoller[_models.GenericResource]: + """Updates a resource by ID. + :param resource_id: The fully qualified ID of the resource, including the resource name and + resource type. Use the format, + /subscriptions/{guid}/resourceGroups/{resource-group-name}/{resource-provider-namespace}/{resource-type}/{resource-name}. + Required. + :type resource_id: str + :param api_version: The API version to use for the operation. Required. + :type api_version: str + :param parameters: Update resource parameters. Required. + :type parameters: ~azure.mgmt.resource.resources.v2018_05_01.models.GenericResource + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be AsyncARMPolling. Pass in False for + this operation to not poll, or pass in your own initialized polling object for a personal + polling strategy. + :paramtype polling: bool or ~azure.core.polling.AsyncPollingMethod + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of AsyncLROPoller that returns either GenericResource or the result of + cls(response) + :rtype: + ~azure.core.polling.AsyncLROPoller[~azure.mgmt.resource.resources.v2018_05_01.models.GenericResource] + :raises ~azure.core.exceptions.HttpResponseError: + """ - @distributed_trace_async + @overload async def begin_update_by_id( self, resource_id: str, api_version: str, - parameters: "_models.GenericResource", + parameters: IO, + *, + content_type: str = "application/json", **kwargs: Any - ) -> AsyncLROPoller["_models.GenericResource"]: + ) -> AsyncLROPoller[_models.GenericResource]: """Updates a resource by ID. :param resource_id: The fully qualified ID of the resource, including the resource name and resource type. Use the format, /subscriptions/{guid}/resourceGroups/{resource-group-name}/{resource-provider-namespace}/{resource-type}/{resource-name}. + Required. :type resource_id: str - :param api_version: The API version to use for the operation. + :param api_version: The API version to use for the operation. Required. :type api_version: str - :param parameters: Update resource parameters. - :type parameters: ~azure.mgmt.resource.resources.v2018_05_01.models.GenericResource + :param parameters: Update resource parameters. Required. + :type parameters: IO + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: str :keyword callable cls: A custom type or function that will be passed the direct response :keyword str continuation_token: A continuation token to restart a poller from a saved state. :keyword polling: By default, your polling method will be AsyncARMPolling. Pass in False for @@ -3067,165 +4047,204 @@ async def begin_update_by_id( cls(response) :rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.resource.resources.v2018_05_01.models.GenericResource] - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] - polling = kwargs.pop('polling', True) # type: Union[bool, AsyncPollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType["_models.GenericResource"] - lro_delay = kwargs.pop( - 'polling_interval', - self._config.polling_interval - ) - cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] + + @distributed_trace_async + async def begin_update_by_id( + self, resource_id: str, api_version: str, parameters: Union[_models.GenericResource, IO], **kwargs: Any + ) -> AsyncLROPoller[_models.GenericResource]: + """Updates a resource by ID. + + :param resource_id: The fully qualified ID of the resource, including the resource name and + resource type. Use the format, + /subscriptions/{guid}/resourceGroups/{resource-group-name}/{resource-provider-namespace}/{resource-type}/{resource-name}. + Required. + :type resource_id: str + :param api_version: The API version to use for the operation. Required. + :type api_version: str + :param parameters: Update resource parameters. Is either a model type or a IO type. Required. + :type parameters: ~azure.mgmt.resource.resources.v2018_05_01.models.GenericResource or IO + :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. + Default value is None. + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be AsyncARMPolling. Pass in False for + this operation to not poll, or pass in your own initialized polling object for a personal + polling strategy. + :paramtype polling: bool or ~azure.core.polling.AsyncPollingMethod + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of AsyncLROPoller that returns either GenericResource or the result of + cls(response) + :rtype: + ~azure.core.polling.AsyncLROPoller[~azure.mgmt.resource.resources.v2018_05_01.models.GenericResource] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = kwargs.pop("params", {}) or {} + + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.GenericResource] + polling = kwargs.pop("polling", True) # type: Union[bool, AsyncPollingMethod] + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token = kwargs.pop("continuation_token", None) # type: Optional[str] if cont_token is None: - raw_result = await self._update_by_id_initial( + raw_result = await self._update_by_id_initial( # type: ignore resource_id=resource_id, api_version=api_version, parameters=parameters, content_type=content_type, - cls=lambda x,y,z: x, + cls=lambda x, y, z: x, + headers=_headers, + params=_params, **kwargs ) - kwargs.pop('error_map', None) + kwargs.pop("error_map", None) def get_long_running_output(pipeline_response): - response = pipeline_response.http_response - deserialized = self._deserialize('GenericResource', pipeline_response) + deserialized = self._deserialize("GenericResource", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - - if polling is True: polling_method = AsyncARMPolling(lro_delay, **kwargs) - elif polling is False: polling_method = AsyncNoPolling() - else: polling_method = polling + if polling is True: + polling_method = cast(AsyncPollingMethod, AsyncARMPolling(lro_delay, **kwargs)) # type: AsyncPollingMethod + elif polling is False: + polling_method = cast(AsyncPollingMethod, AsyncNoPolling()) + else: + polling_method = polling if cont_token: return AsyncLROPoller.from_continuation_token( polling_method=polling_method, continuation_token=cont_token, client=self._client, - deserialization_callback=get_long_running_output + deserialization_callback=get_long_running_output, ) return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) - begin_update_by_id.metadata = {'url': "/{resourceId}"} # type: ignore + begin_update_by_id.metadata = {"url": "/{resourceId}"} # type: ignore @distributed_trace_async - async def get_by_id( - self, - resource_id: str, - api_version: str, - **kwargs: Any - ) -> "_models.GenericResource": + async def get_by_id(self, resource_id: str, api_version: str, **kwargs: Any) -> _models.GenericResource: """Gets a resource by ID. :param resource_id: The fully qualified ID of the resource, including the resource name and resource type. Use the format, /subscriptions/{guid}/resourceGroups/{resource-group-name}/{resource-provider-namespace}/{resource-type}/{resource-name}. + Required. :type resource_id: str - :param api_version: The API version to use for the operation. + :param api_version: The API version to use for the operation. Required. :type api_version: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: GenericResource, or the result of cls(response) + :return: GenericResource or the result of cls(response) :rtype: ~azure.mgmt.resource.resources.v2018_05_01.models.GenericResource - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.GenericResource"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = kwargs.pop("params", {}) or {} + + cls = kwargs.pop("cls", None) # type: ClsType[_models.GenericResource] - request = build_resources_get_by_id_request( resource_id=resource_id, api_version=api_version, - template_url=self.get_by_id.metadata['url'], + template_url=self.get_by_id.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) - deserialized = self._deserialize('GenericResource', pipeline_response) + deserialized = self._deserialize("GenericResource", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - get_by_id.metadata = {'url': "/{resourceId}"} # type: ignore + get_by_id.metadata = {"url": "/{resourceId}"} # type: ignore -class ResourceGroupsOperations: - """ResourceGroupsOperations async operations. - You should not instantiate this class directly. Instead, you should create a Client instance that - instantiates it for you and attaches it as an attribute. +class ResourceGroupsOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. - :ivar models: Alias to model classes used in this operation group. - :type models: ~azure.mgmt.resource.resources.v2018_05_01.models - :param client: Client for service requests. - :param config: Configuration of service client. - :param serializer: An object model serializer. - :param deserializer: An object model deserializer. + Instead, you should access the following operations through + :class:`~azure.mgmt.resource.resources.v2018_05_01.aio.ResourceManagementClient`'s + :attr:`resource_groups` attribute. """ models = _models - def __init__(self, client, config, serializer, deserializer) -> None: - self._client = client - self._serialize = serializer - self._deserialize = deserializer - self._config = config + def __init__(self, *args, **kwargs) -> None: + input_args = list(args) + self._client = input_args.pop(0) if input_args else kwargs.pop("client") + self._config = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") @distributed_trace_async - async def check_existence( - self, - resource_group_name: str, - **kwargs: Any - ) -> bool: + async def check_existence(self, resource_group_name: str, **kwargs: Any) -> bool: """Checks whether a resource group exists. :param resource_group_name: The name of the resource group to check. The name is case - insensitive. + insensitive. Required. :type resource_group_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: bool, or the result of cls(response) + :return: bool or the result of cls(response) :rtype: bool - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType[None] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) - api_version = kwargs.pop('api_version', "2018-05-01") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2018-05-01")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[None] - request = build_resource_groups_check_existence_request( resource_group_name=resource_group_name, subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.check_existence.metadata['url'], + template_url=self.check_existence.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [204, 404]: @@ -3236,39 +4255,98 @@ async def check_existence( return cls(pipeline_response, None, {}) return 200 <= response.status_code <= 299 - check_existence.metadata = {'url': "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}"} # type: ignore + check_existence.metadata = {"url": "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}"} # type: ignore - - @distributed_trace_async + @overload async def create_or_update( self, resource_group_name: str, - parameters: "_models.ResourceGroup", + parameters: _models.ResourceGroup, + *, + content_type: str = "application/json", **kwargs: Any - ) -> "_models.ResourceGroup": + ) -> _models.ResourceGroup: """Creates or updates a resource group. :param resource_group_name: The name of the resource group to create or update. Can include alphanumeric, underscore, parentheses, hyphen, period (except at end), and Unicode characters - that match the allowed characters. + that match the allowed characters. Required. :type resource_group_name: str - :param parameters: Parameters supplied to the create or update a resource group. + :param parameters: Parameters supplied to the create or update a resource group. Required. :type parameters: ~azure.mgmt.resource.resources.v2018_05_01.models.ResourceGroup + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: ResourceGroup or the result of cls(response) + :rtype: ~azure.mgmt.resource.resources.v2018_05_01.models.ResourceGroup + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + async def create_or_update( + self, resource_group_name: str, parameters: IO, *, content_type: str = "application/json", **kwargs: Any + ) -> _models.ResourceGroup: + """Creates or updates a resource group. + + :param resource_group_name: The name of the resource group to create or update. Can include + alphanumeric, underscore, parentheses, hyphen, period (except at end), and Unicode characters + that match the allowed characters. Required. + :type resource_group_name: str + :param parameters: Parameters supplied to the create or update a resource group. Required. + :type parameters: IO + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: ResourceGroup, or the result of cls(response) + :return: ResourceGroup or the result of cls(response) :rtype: ~azure.mgmt.resource.resources.v2018_05_01.models.ResourceGroup - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace_async + async def create_or_update( + self, resource_group_name: str, parameters: Union[_models.ResourceGroup, IO], **kwargs: Any + ) -> _models.ResourceGroup: + """Creates or updates a resource group. + + :param resource_group_name: The name of the resource group to create or update. Can include + alphanumeric, underscore, parentheses, hyphen, period (except at end), and Unicode characters + that match the allowed characters. Required. + :type resource_group_name: str + :param parameters: Parameters supplied to the create or update a resource group. Is either a + model type or a IO type. Required. + :type parameters: ~azure.mgmt.resource.resources.v2018_05_01.models.ResourceGroup or IO + :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. + Default value is None. + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: ResourceGroup or the result of cls(response) + :rtype: ~azure.mgmt.resource.resources.v2018_05_01.models.ResourceGroup + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.ResourceGroup"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) - api_version = kwargs.pop('api_version', "2018-05-01") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - _json = self._serialize.body(parameters, 'ResourceGroup') + api_version = kwargs.pop("api_version", _params.pop("api-version", "2018-05-01")) # type: str + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.ResourceGroup] + + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(parameters, (IO, bytes)): + _content = parameters + else: + _json = self._serialize.body(parameters, "ResourceGroup") request = build_resource_groups_create_or_update_request( resource_group_name=resource_group_name, @@ -3276,16 +4354,18 @@ async def create_or_update( api_version=api_version, content_type=content_type, json=_json, - template_url=self.create_or_update.metadata['url'], + content=_content, + template_url=self.create_or_update.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200, 201]: @@ -3293,47 +4373,50 @@ async def create_or_update( raise HttpResponseError(response=response, error_format=ARMErrorFormat) if response.status_code == 200: - deserialized = self._deserialize('ResourceGroup', pipeline_response) + deserialized = self._deserialize("ResourceGroup", pipeline_response) if response.status_code == 201: - deserialized = self._deserialize('ResourceGroup', pipeline_response) + deserialized = self._deserialize("ResourceGroup", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - create_or_update.metadata = {'url': "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}"} # type: ignore - + create_or_update.metadata = {"url": "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}"} # type: ignore async def _delete_initial( # pylint: disable=inconsistent-return-statements - self, - resource_group_name: str, - **kwargs: Any + self, resource_group_name: str, **kwargs: Any ) -> None: - cls = kwargs.pop('cls', None) # type: ClsType[None] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) - api_version = kwargs.pop('api_version', "2018-05-01") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - request = build_resource_groups_delete_request_initial( + api_version = kwargs.pop("api_version", _params.pop("api-version", "2018-05-01")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[None] + + request = build_resource_groups_delete_request( resource_group_name=resource_group_name, subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self._delete_initial.metadata['url'], + template_url=self._delete_initial.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200, 202]: @@ -3343,22 +4426,17 @@ async def _delete_initial( # pylint: disable=inconsistent-return-statements if cls: return cls(pipeline_response, None, {}) - _delete_initial.metadata = {'url': "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}"} # type: ignore - + _delete_initial.metadata = {"url": "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}"} # type: ignore @distributed_trace_async - async def begin_delete( # pylint: disable=inconsistent-return-statements - self, - resource_group_name: str, - **kwargs: Any - ) -> AsyncLROPoller[None]: + async def begin_delete(self, resource_group_name: str, **kwargs: Any) -> AsyncLROPoller[None]: """Deletes a resource group. When you delete a resource group, all of its resources are also deleted. Deleting a resource group deletes all of its template deployments and currently stored operations. :param resource_group_name: The name of the resource group to delete. The name is case - insensitive. + insensitive. Required. :type resource_group_name: str :keyword callable cls: A custom type or function that will be passed the direct response :keyword str continuation_token: A continuation token to restart a poller from a saved state. @@ -3370,106 +4448,113 @@ async def begin_delete( # pylint: disable=inconsistent-return-statements Retry-After header is present. :return: An instance of AsyncLROPoller that returns either None or the result of cls(response) :rtype: ~azure.core.polling.AsyncLROPoller[None] - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - api_version = kwargs.pop('api_version', "2018-05-01") # type: str - polling = kwargs.pop('polling', True) # type: Union[bool, AsyncPollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType[None] - lro_delay = kwargs.pop( - 'polling_interval', - self._config.polling_interval - ) - cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2018-05-01")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[None] + polling = kwargs.pop("polling", True) # type: Union[bool, AsyncPollingMethod] + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token = kwargs.pop("continuation_token", None) # type: Optional[str] if cont_token is None: - raw_result = await self._delete_initial( + raw_result = await self._delete_initial( # type: ignore resource_group_name=resource_group_name, api_version=api_version, - cls=lambda x,y,z: x, + cls=lambda x, y, z: x, + headers=_headers, + params=_params, **kwargs ) - kwargs.pop('error_map', None) + kwargs.pop("error_map", None) - def get_long_running_output(pipeline_response): + def get_long_running_output(pipeline_response): # pylint: disable=inconsistent-return-statements if cls: return cls(pipeline_response, None, {}) - - if polling is True: polling_method = AsyncARMPolling(lro_delay, **kwargs) - elif polling is False: polling_method = AsyncNoPolling() - else: polling_method = polling + if polling is True: + polling_method = cast(AsyncPollingMethod, AsyncARMPolling(lro_delay, **kwargs)) # type: AsyncPollingMethod + elif polling is False: + polling_method = cast(AsyncPollingMethod, AsyncNoPolling()) + else: + polling_method = polling if cont_token: return AsyncLROPoller.from_continuation_token( polling_method=polling_method, continuation_token=cont_token, client=self._client, - deserialization_callback=get_long_running_output + deserialization_callback=get_long_running_output, ) return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) - begin_delete.metadata = {'url': "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}"} # type: ignore + begin_delete.metadata = {"url": "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}"} # type: ignore @distributed_trace_async - async def get( - self, - resource_group_name: str, - **kwargs: Any - ) -> "_models.ResourceGroup": + async def get(self, resource_group_name: str, **kwargs: Any) -> _models.ResourceGroup: """Gets a resource group. :param resource_group_name: The name of the resource group to get. The name is case - insensitive. + insensitive. Required. :type resource_group_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: ResourceGroup, or the result of cls(response) + :return: ResourceGroup or the result of cls(response) :rtype: ~azure.mgmt.resource.resources.v2018_05_01.models.ResourceGroup - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.ResourceGroup"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) - api_version = kwargs.pop('api_version', "2018-05-01") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2018-05-01")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[_models.ResourceGroup] - request = build_resource_groups_get_request( resource_group_name=resource_group_name, subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.get.metadata['url'], + template_url=self.get.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) - deserialized = self._deserialize('ResourceGroup', pipeline_response) + deserialized = self._deserialize("ResourceGroup", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - get.metadata = {'url': "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}"} # type: ignore + get.metadata = {"url": "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}"} # type: ignore - - @distributed_trace_async + @overload async def update( self, resource_group_name: str, - parameters: "_models.ResourceGroupPatchable", + parameters: _models.ResourceGroupPatchable, + *, + content_type: str = "application/json", **kwargs: Any - ) -> "_models.ResourceGroup": + ) -> _models.ResourceGroup: """Updates a resource group. Resource groups can be updated through a simple PATCH operation to a group address. The format @@ -3477,25 +4562,90 @@ async def update( the current value is retained. :param resource_group_name: The name of the resource group to update. The name is case - insensitive. + insensitive. Required. :type resource_group_name: str - :param parameters: Parameters supplied to update a resource group. + :param parameters: Parameters supplied to update a resource group. Required. :type parameters: ~azure.mgmt.resource.resources.v2018_05_01.models.ResourceGroupPatchable + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: ResourceGroup or the result of cls(response) + :rtype: ~azure.mgmt.resource.resources.v2018_05_01.models.ResourceGroup + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + async def update( + self, resource_group_name: str, parameters: IO, *, content_type: str = "application/json", **kwargs: Any + ) -> _models.ResourceGroup: + """Updates a resource group. + + Resource groups can be updated through a simple PATCH operation to a group address. The format + of the request is the same as that for creating a resource group. If a field is unspecified, + the current value is retained. + + :param resource_group_name: The name of the resource group to update. The name is case + insensitive. Required. + :type resource_group_name: str + :param parameters: Parameters supplied to update a resource group. Required. + :type parameters: IO + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: ResourceGroup or the result of cls(response) + :rtype: ~azure.mgmt.resource.resources.v2018_05_01.models.ResourceGroup + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace_async + async def update( + self, resource_group_name: str, parameters: Union[_models.ResourceGroupPatchable, IO], **kwargs: Any + ) -> _models.ResourceGroup: + """Updates a resource group. + + Resource groups can be updated through a simple PATCH operation to a group address. The format + of the request is the same as that for creating a resource group. If a field is unspecified, + the current value is retained. + + :param resource_group_name: The name of the resource group to update. The name is case + insensitive. Required. + :type resource_group_name: str + :param parameters: Parameters supplied to update a resource group. Is either a model type or a + IO type. Required. + :type parameters: ~azure.mgmt.resource.resources.v2018_05_01.models.ResourceGroupPatchable or + IO + :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. + Default value is None. + :paramtype content_type: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: ResourceGroup, or the result of cls(response) + :return: ResourceGroup or the result of cls(response) :rtype: ~azure.mgmt.resource.resources.v2018_05_01.models.ResourceGroup - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.ResourceGroup"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) - api_version = kwargs.pop('api_version', "2018-05-01") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - _json = self._serialize.body(parameters, 'ResourceGroupPatchable') + api_version = kwargs.pop("api_version", _params.pop("api-version", "2018-05-01")) # type: str + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.ResourceGroup] + + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(parameters, (IO, bytes)): + _content = parameters + else: + _json = self._serialize.body(parameters, "ResourceGroupPatchable") request = build_resource_groups_update_request( resource_group_name=resource_group_name, @@ -3503,60 +4653,117 @@ async def update( api_version=api_version, content_type=content_type, json=_json, - template_url=self.update.metadata['url'], + content=_content, + template_url=self.update.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) - deserialized = self._deserialize('ResourceGroup', pipeline_response) + deserialized = self._deserialize("ResourceGroup", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - update.metadata = {'url': "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}"} # type: ignore + update.metadata = {"url": "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}"} # type: ignore - - @distributed_trace_async + @overload async def export_template( self, resource_group_name: str, - parameters: "_models.ExportTemplateRequest", + parameters: _models.ExportTemplateRequest, + *, + content_type: str = "application/json", **kwargs: Any - ) -> "_models.ResourceGroupExportResult": + ) -> _models.ResourceGroupExportResult: """Captures the specified resource group as a template. - :param resource_group_name: The name of the resource group to export as a template. + :param resource_group_name: The name of the resource group to export as a template. Required. :type resource_group_name: str - :param parameters: Parameters for exporting the template. + :param parameters: Parameters for exporting the template. Required. :type parameters: ~azure.mgmt.resource.resources.v2018_05_01.models.ExportTemplateRequest + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: ResourceGroupExportResult or the result of cls(response) + :rtype: ~azure.mgmt.resource.resources.v2018_05_01.models.ResourceGroupExportResult + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + async def export_template( + self, resource_group_name: str, parameters: IO, *, content_type: str = "application/json", **kwargs: Any + ) -> _models.ResourceGroupExportResult: + """Captures the specified resource group as a template. + + :param resource_group_name: The name of the resource group to export as a template. Required. + :type resource_group_name: str + :param parameters: Parameters for exporting the template. Required. + :type parameters: IO + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: ResourceGroupExportResult or the result of cls(response) + :rtype: ~azure.mgmt.resource.resources.v2018_05_01.models.ResourceGroupExportResult + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace_async + async def export_template( + self, resource_group_name: str, parameters: Union[_models.ExportTemplateRequest, IO], **kwargs: Any + ) -> _models.ResourceGroupExportResult: + """Captures the specified resource group as a template. + + :param resource_group_name: The name of the resource group to export as a template. Required. + :type resource_group_name: str + :param parameters: Parameters for exporting the template. Is either a model type or a IO type. + Required. + :type parameters: ~azure.mgmt.resource.resources.v2018_05_01.models.ExportTemplateRequest or IO + :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. + Default value is None. + :paramtype content_type: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: ResourceGroupExportResult, or the result of cls(response) + :return: ResourceGroupExportResult or the result of cls(response) :rtype: ~azure.mgmt.resource.resources.v2018_05_01.models.ResourceGroupExportResult - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.ResourceGroupExportResult"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) - api_version = kwargs.pop('api_version', "2018-05-01") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - _json = self._serialize.body(parameters, 'ExportTemplateRequest') + api_version = kwargs.pop("api_version", _params.pop("api-version", "2018-05-01")) # type: str + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.ResourceGroupExportResult] + + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(parameters, (IO, bytes)): + _content = parameters + else: + _json = self._serialize.body(parameters, "ExportTemplateRequest") request = build_resource_groups_export_template_request( resource_group_name=resource_group_name, @@ -3564,39 +4771,37 @@ async def export_template( api_version=api_version, content_type=content_type, json=_json, - template_url=self.export_template.metadata['url'], + content=_content, + template_url=self.export_template.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) - deserialized = self._deserialize('ResourceGroupExportResult', pipeline_response) + deserialized = self._deserialize("ResourceGroupExportResult", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - export_template.metadata = {'url': "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/exportTemplate"} # type: ignore - + export_template.metadata = {"url": "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/exportTemplate"} # type: ignore @distributed_trace def list( - self, - filter: Optional[str] = None, - top: Optional[int] = None, - **kwargs: Any - ) -> AsyncIterable["_models.ResourceGroupListResult"]: + self, filter: Optional[str] = None, top: Optional[int] = None, **kwargs: Any + ) -> AsyncIterable["_models.ResourceGroup"]: """Gets all the resource groups for a subscription. :param filter: The filter to apply on the operation.:code:`
`:code:`
`You can filter by @@ -3607,40 +4812,48 @@ def list( Default value is None. :type top: int :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either ResourceGroupListResult or the result of - cls(response) + :return: An iterator like instance of either ResourceGroup or the result of cls(response) :rtype: - ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.resource.resources.v2018_05_01.models.ResourceGroupListResult] - :raises: ~azure.core.exceptions.HttpResponseError + ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.resource.resources.v2018_05_01.models.ResourceGroup] + :raises ~azure.core.exceptions.HttpResponseError: """ - api_version = kwargs.pop('api_version', "2018-05-01") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2018-05-01")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[_models.ResourceGroupListResult] - cls = kwargs.pop('cls', None) # type: ClsType["_models.ResourceGroupListResult"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) + def prepare_request(next_link=None): if not next_link: - + request = build_resource_groups_list_request( subscription_id=self._config.subscription_id, - api_version=api_version, filter=filter, top=top, - template_url=self.list.metadata['url'], + 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.url = self._client.format_url(request.url) # type: ignore else: - - request = build_resource_groups_list_request( - subscription_id=self._config.subscription_id, - template_url=next_link, - ) + # make call to next link with the client's api-version + _parsed_next_link = urlparse(next_link) + _next_request_params = case_insensitive_dict(parse_qs(_parsed_next_link.query)) + _next_request_params["api-version"] = self._config.api_version + request = HttpRequest("GET", urljoin(next_link, _parsed_next_link.path), params=_next_request_params) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore request.method = "GET" return request @@ -3654,10 +4867,8 @@ async def extract_data(pipeline_response): async def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) response = pipeline_response.http_response @@ -3667,75 +4878,75 @@ async def get_next(next_link=None): return pipeline_response + return AsyncItemPaged(get_next, extract_data) + + list.metadata = {"url": "/subscriptions/{subscriptionId}/resourcegroups"} # type: ignore - return AsyncItemPaged( - get_next, extract_data - ) - list.metadata = {'url': "/subscriptions/{subscriptionId}/resourcegroups"} # type: ignore -class TagsOperations: - """TagsOperations async operations. - You should not instantiate this class directly. Instead, you should create a Client instance that - instantiates it for you and attaches it as an attribute. +class TagsOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. - :ivar models: Alias to model classes used in this operation group. - :type models: ~azure.mgmt.resource.resources.v2018_05_01.models - :param client: Client for service requests. - :param config: Configuration of service client. - :param serializer: An object model serializer. - :param deserializer: An object model deserializer. + Instead, you should access the following operations through + :class:`~azure.mgmt.resource.resources.v2018_05_01.aio.ResourceManagementClient`'s + :attr:`tags` attribute. """ models = _models - def __init__(self, client, config, serializer, deserializer) -> None: - self._client = client - self._serialize = serializer - self._deserialize = deserializer - self._config = config + def __init__(self, *args, **kwargs) -> None: + input_args = list(args) + self._client = input_args.pop(0) if input_args else kwargs.pop("client") + self._config = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") @distributed_trace_async async def delete_value( # pylint: disable=inconsistent-return-statements - self, - tag_name: str, - tag_value: str, - **kwargs: Any + self, tag_name: str, tag_value: str, **kwargs: Any ) -> None: """Deletes a tag value. - :param tag_name: The name of the tag. + :param tag_name: The name of the tag. Required. :type tag_name: str - :param tag_value: The value of the tag to delete. + :param tag_value: The value of the tag to delete. Required. :type tag_value: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: None, or the result of cls(response) + :return: None or the result of cls(response) :rtype: None - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType[None] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) - api_version = kwargs.pop('api_version', "2018-05-01") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2018-05-01")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[None] - request = build_tags_delete_value_request( tag_name=tag_name, tag_value=tag_value, subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.delete_value.metadata['url'], + template_url=self.delete_value.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200, 204]: @@ -3745,51 +4956,51 @@ async def delete_value( # pylint: disable=inconsistent-return-statements if cls: return cls(pipeline_response, None, {}) - delete_value.metadata = {'url': "/subscriptions/{subscriptionId}/tagNames/{tagName}/tagValues/{tagValue}"} # type: ignore - + delete_value.metadata = {"url": "/subscriptions/{subscriptionId}/tagNames/{tagName}/tagValues/{tagValue}"} # type: ignore @distributed_trace_async - async def create_or_update_value( - self, - tag_name: str, - tag_value: str, - **kwargs: Any - ) -> "_models.TagValue": + async def create_or_update_value(self, tag_name: str, tag_value: str, **kwargs: Any) -> _models.TagValue: """Creates a tag value. The name of the tag must already exist. - :param tag_name: The name of the tag. + :param tag_name: The name of the tag. Required. :type tag_name: str - :param tag_value: The value of the tag to create. + :param tag_value: The value of the tag to create. Required. :type tag_value: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: TagValue, or the result of cls(response) + :return: TagValue or the result of cls(response) :rtype: ~azure.mgmt.resource.resources.v2018_05_01.models.TagValue - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.TagValue"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + 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', "2018-05-01") # type: str + api_version = kwargs.pop("api_version", _params.pop("api-version", "2018-05-01")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[_models.TagValue] - request = build_tags_create_or_update_value_request( tag_name=tag_name, tag_value=tag_value, subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.create_or_update_value.metadata['url'], + template_url=self.create_or_update_value.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200, 201]: @@ -3797,61 +5008,62 @@ async def create_or_update_value( raise HttpResponseError(response=response, error_format=ARMErrorFormat) if response.status_code == 200: - deserialized = self._deserialize('TagValue', pipeline_response) + deserialized = self._deserialize("TagValue", pipeline_response) if response.status_code == 201: - deserialized = self._deserialize('TagValue', pipeline_response) + deserialized = self._deserialize("TagValue", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - create_or_update_value.metadata = {'url': "/subscriptions/{subscriptionId}/tagNames/{tagName}/tagValues/{tagValue}"} # type: ignore - + create_or_update_value.metadata = {"url": "/subscriptions/{subscriptionId}/tagNames/{tagName}/tagValues/{tagValue}"} # type: ignore @distributed_trace_async - async def create_or_update( - self, - tag_name: str, - **kwargs: Any - ) -> "_models.TagDetails": + async def create_or_update(self, tag_name: str, **kwargs: Any) -> _models.TagDetails: """Creates a tag in the subscription. The tag name can have a maximum of 512 characters and is case insensitive. Tag names created by Azure have prefixes of microsoft, azure, or windows. You cannot create tags with one of these prefixes. - :param tag_name: The name of the tag to create. + :param tag_name: The name of the tag to create. Required. :type tag_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: TagDetails, or the result of cls(response) + :return: TagDetails or the result of cls(response) :rtype: ~azure.mgmt.resource.resources.v2018_05_01.models.TagDetails - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.TagDetails"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + 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', "2018-05-01") # type: str + api_version = kwargs.pop("api_version", _params.pop("api-version", "2018-05-01")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[_models.TagDetails] - request = build_tags_create_or_update_request( tag_name=tag_name, subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.create_or_update.metadata['url'], + template_url=self.create_or_update.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200, 201]: @@ -3859,59 +5071,60 @@ async def create_or_update( raise HttpResponseError(response=response, error_format=ARMErrorFormat) if response.status_code == 200: - deserialized = self._deserialize('TagDetails', pipeline_response) + deserialized = self._deserialize("TagDetails", pipeline_response) if response.status_code == 201: - deserialized = self._deserialize('TagDetails', pipeline_response) + deserialized = self._deserialize("TagDetails", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - create_or_update.metadata = {'url': "/subscriptions/{subscriptionId}/tagNames/{tagName}"} # type: ignore - + create_or_update.metadata = {"url": "/subscriptions/{subscriptionId}/tagNames/{tagName}"} # type: ignore @distributed_trace_async - async def delete( # pylint: disable=inconsistent-return-statements - self, - tag_name: str, - **kwargs: Any - ) -> None: + async def delete(self, tag_name: str, **kwargs: Any) -> None: # pylint: disable=inconsistent-return-statements """Deletes a tag from the subscription. You must remove all values from a resource tag before you can delete it. - :param tag_name: The name of the tag. + :param tag_name: The name of the tag. Required. :type tag_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: None, or the result of cls(response) + :return: None or the result of cls(response) :rtype: None - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType[None] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + 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', "2018-05-01") # type: str + api_version = kwargs.pop("api_version", _params.pop("api-version", "2018-05-01")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[None] - request = build_tags_delete_request( tag_name=tag_name, subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.delete.metadata['url'], + template_url=self.delete.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200, 204]: @@ -3921,48 +5134,53 @@ async def delete( # pylint: disable=inconsistent-return-statements if cls: return cls(pipeline_response, None, {}) - delete.metadata = {'url': "/subscriptions/{subscriptionId}/tagNames/{tagName}"} # type: ignore - + delete.metadata = {"url": "/subscriptions/{subscriptionId}/tagNames/{tagName}"} # type: ignore @distributed_trace - def list( - self, - **kwargs: Any - ) -> AsyncIterable["_models.TagsListResult"]: + def list(self, **kwargs: Any) -> AsyncIterable["_models.TagDetails"]: """Gets the names and values of all resource tags that are defined in a subscription. :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either TagsListResult or the result of cls(response) + :return: An iterator like instance of either TagDetails or the result of cls(response) :rtype: - ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.resource.resources.v2018_05_01.models.TagsListResult] - :raises: ~azure.core.exceptions.HttpResponseError + ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.resource.resources.v2018_05_01.models.TagDetails] + :raises ~azure.core.exceptions.HttpResponseError: """ - api_version = kwargs.pop('api_version', "2018-05-01") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2018-05-01")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[_models.TagsListResult] - cls = kwargs.pop('cls', None) # type: ClsType["_models.TagsListResult"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) + def prepare_request(next_link=None): if not next_link: - + request = build_tags_list_request( subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.list.metadata['url'], + template_url=self.list.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore else: - - request = build_tags_list_request( - subscription_id=self._config.subscription_id, - template_url=next_link, - ) + # make call to next link with the client's api-version + _parsed_next_link = urlparse(next_link) + _next_request_params = case_insensitive_dict(parse_qs(_parsed_next_link.query)) + _next_request_params["api-version"] = self._config.api_version + request = HttpRequest("GET", urljoin(next_link, _parsed_next_link.path), params=_next_request_params) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore request.method = "GET" return request @@ -3976,10 +5194,8 @@ async def extract_data(pipeline_response): async def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) response = pipeline_response.http_response @@ -3989,140 +5205,143 @@ async def get_next(next_link=None): return pipeline_response + return AsyncItemPaged(get_next, extract_data) - return AsyncItemPaged( - get_next, extract_data - ) - list.metadata = {'url': "/subscriptions/{subscriptionId}/tagNames"} # type: ignore -class DeploymentOperationsOperations: - """DeploymentOperationsOperations async operations. + list.metadata = {"url": "/subscriptions/{subscriptionId}/tagNames"} # type: ignore - You should not instantiate this class directly. Instead, you should create a Client instance that - instantiates it for you and attaches it as an attribute. - :ivar models: Alias to model classes used in this operation group. - :type models: ~azure.mgmt.resource.resources.v2018_05_01.models - :param client: Client for service requests. - :param config: Configuration of service client. - :param serializer: An object model serializer. - :param deserializer: An object model deserializer. +class DeploymentOperationsOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. + + Instead, you should access the following operations through + :class:`~azure.mgmt.resource.resources.v2018_05_01.aio.ResourceManagementClient`'s + :attr:`deployment_operations` attribute. """ models = _models - def __init__(self, client, config, serializer, deserializer) -> None: - self._client = client - self._serialize = serializer - self._deserialize = deserializer - self._config = config + def __init__(self, *args, **kwargs) -> None: + input_args = list(args) + self._client = input_args.pop(0) if input_args else kwargs.pop("client") + self._config = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") @distributed_trace_async async def get_at_subscription_scope( - self, - deployment_name: str, - operation_id: str, - **kwargs: Any - ) -> "_models.DeploymentOperation": + self, deployment_name: str, operation_id: str, **kwargs: Any + ) -> _models.DeploymentOperation: """Gets a deployments operation. - :param deployment_name: The name of the deployment. + :param deployment_name: The name of the deployment. Required. :type deployment_name: str - :param operation_id: The ID of the operation to get. + :param operation_id: The ID of the operation to get. Required. :type operation_id: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: DeploymentOperation, or the result of cls(response) + :return: DeploymentOperation or the result of cls(response) :rtype: ~azure.mgmt.resource.resources.v2018_05_01.models.DeploymentOperation - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.DeploymentOperation"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) - api_version = kwargs.pop('api_version', "2018-05-01") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2018-05-01")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[_models.DeploymentOperation] - request = build_deployment_operations_get_at_subscription_scope_request( deployment_name=deployment_name, operation_id=operation_id, subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.get_at_subscription_scope.metadata['url'], + template_url=self.get_at_subscription_scope.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) - deserialized = self._deserialize('DeploymentOperation', pipeline_response) + deserialized = self._deserialize("DeploymentOperation", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - get_at_subscription_scope.metadata = {'url': "/subscriptions/{subscriptionId}/providers/Microsoft.Resources/deployments/{deploymentName}/operations/{operationId}"} # type: ignore - + get_at_subscription_scope.metadata = {"url": "/subscriptions/{subscriptionId}/providers/Microsoft.Resources/deployments/{deploymentName}/operations/{operationId}"} # type: ignore @distributed_trace def list_at_subscription_scope( - self, - deployment_name: str, - top: Optional[int] = None, - **kwargs: Any - ) -> AsyncIterable["_models.DeploymentOperationsListResult"]: + self, deployment_name: str, top: Optional[int] = None, **kwargs: Any + ) -> AsyncIterable["_models.DeploymentOperation"]: """Gets all deployments operations for a deployment. - :param deployment_name: The name of the deployment with the operation to get. + :param deployment_name: The name of the deployment with the operation to get. Required. :type deployment_name: str :param top: The number of results to return. Default value is None. :type top: int :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either DeploymentOperationsListResult or the result of - cls(response) + :return: An iterator like instance of either DeploymentOperation or the result of cls(response) :rtype: - ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.resource.resources.v2018_05_01.models.DeploymentOperationsListResult] - :raises: ~azure.core.exceptions.HttpResponseError + ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.resource.resources.v2018_05_01.models.DeploymentOperation] + :raises ~azure.core.exceptions.HttpResponseError: """ - api_version = kwargs.pop('api_version', "2018-05-01") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2018-05-01")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[_models.DeploymentOperationsListResult] - cls = kwargs.pop('cls', None) # type: ClsType["_models.DeploymentOperationsListResult"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) + def prepare_request(next_link=None): if not next_link: - + request = build_deployment_operations_list_at_subscription_scope_request( deployment_name=deployment_name, subscription_id=self._config.subscription_id, - api_version=api_version, top=top, - template_url=self.list_at_subscription_scope.metadata['url'], + api_version=api_version, + template_url=self.list_at_subscription_scope.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore else: - - request = build_deployment_operations_list_at_subscription_scope_request( - deployment_name=deployment_name, - subscription_id=self._config.subscription_id, - template_url=next_link, - ) + # make call to next link with the client's api-version + _parsed_next_link = urlparse(next_link) + _next_request_params = case_insensitive_dict(parse_qs(_parsed_next_link.query)) + _next_request_params["api-version"] = self._config.api_version + request = HttpRequest("GET", urljoin(next_link, _parsed_next_link.path), params=_next_request_params) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore request.method = "GET" return request @@ -4136,10 +5355,8 @@ async def extract_data(pipeline_response): async def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) response = pipeline_response.http_response @@ -4149,128 +5366,131 @@ async def get_next(next_link=None): return pipeline_response + return AsyncItemPaged(get_next, extract_data) - return AsyncItemPaged( - get_next, extract_data - ) - list_at_subscription_scope.metadata = {'url': "/subscriptions/{subscriptionId}/providers/Microsoft.Resources/deployments/{deploymentName}/operations"} # type: ignore + list_at_subscription_scope.metadata = {"url": "/subscriptions/{subscriptionId}/providers/Microsoft.Resources/deployments/{deploymentName}/operations"} # type: ignore @distributed_trace_async async def get( - self, - resource_group_name: str, - deployment_name: str, - operation_id: str, - **kwargs: Any - ) -> "_models.DeploymentOperation": + self, resource_group_name: str, deployment_name: str, operation_id: str, **kwargs: Any + ) -> _models.DeploymentOperation: """Gets a deployments operation. :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. :type resource_group_name: str - :param deployment_name: The name of the deployment. + :param deployment_name: The name of the deployment. Required. :type deployment_name: str - :param operation_id: The ID of the operation to get. + :param operation_id: The ID of the operation to get. Required. :type operation_id: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: DeploymentOperation, or the result of cls(response) + :return: DeploymentOperation or the result of cls(response) :rtype: ~azure.mgmt.resource.resources.v2018_05_01.models.DeploymentOperation - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.DeploymentOperation"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + 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', "2018-05-01") # type: str + api_version = kwargs.pop("api_version", _params.pop("api-version", "2018-05-01")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[_models.DeploymentOperation] - request = build_deployment_operations_get_request( resource_group_name=resource_group_name, deployment_name=deployment_name, operation_id=operation_id, subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.get.metadata['url'], + template_url=self.get.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) - deserialized = self._deserialize('DeploymentOperation', pipeline_response) + deserialized = self._deserialize("DeploymentOperation", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - get.metadata = {'url': "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/deployments/{deploymentName}/operations/{operationId}"} # type: ignore - + get.metadata = {"url": "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/deployments/{deploymentName}/operations/{operationId}"} # type: ignore @distributed_trace def list( - self, - resource_group_name: str, - deployment_name: str, - top: Optional[int] = None, - **kwargs: Any - ) -> AsyncIterable["_models.DeploymentOperationsListResult"]: + self, resource_group_name: str, deployment_name: str, top: Optional[int] = None, **kwargs: Any + ) -> AsyncIterable["_models.DeploymentOperation"]: """Gets all deployments operations for a deployment. :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. :type resource_group_name: str - :param deployment_name: The name of the deployment with the operation to get. + :param deployment_name: The name of the deployment with the operation to get. Required. :type deployment_name: str :param top: The number of results to return. Default value is None. :type top: int :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either DeploymentOperationsListResult or the result of - cls(response) + :return: An iterator like instance of either DeploymentOperation or the result of cls(response) :rtype: - ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.resource.resources.v2018_05_01.models.DeploymentOperationsListResult] - :raises: ~azure.core.exceptions.HttpResponseError + ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.resource.resources.v2018_05_01.models.DeploymentOperation] + :raises ~azure.core.exceptions.HttpResponseError: """ - api_version = kwargs.pop('api_version', "2018-05-01") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2018-05-01")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[_models.DeploymentOperationsListResult] - cls = kwargs.pop('cls', None) # type: ClsType["_models.DeploymentOperationsListResult"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) + def prepare_request(next_link=None): if not next_link: - + request = build_deployment_operations_list_request( resource_group_name=resource_group_name, deployment_name=deployment_name, subscription_id=self._config.subscription_id, - api_version=api_version, top=top, - template_url=self.list.metadata['url'], + 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.url = self._client.format_url(request.url) # type: ignore else: - - request = build_deployment_operations_list_request( - resource_group_name=resource_group_name, - deployment_name=deployment_name, - subscription_id=self._config.subscription_id, - template_url=next_link, - ) + # make call to next link with the client's api-version + _parsed_next_link = urlparse(next_link) + _next_request_params = case_insensitive_dict(parse_qs(_parsed_next_link.query)) + _next_request_params["api-version"] = self._config.api_version + request = HttpRequest("GET", urljoin(next_link, _parsed_next_link.path), params=_next_request_params) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore request.method = "GET" return request @@ -4284,10 +5504,8 @@ async def extract_data(pipeline_response): async def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) response = pipeline_response.http_response @@ -4297,8 +5515,6 @@ async def get_next(next_link=None): return pipeline_response + return AsyncItemPaged(get_next, extract_data) - return AsyncItemPaged( - get_next, extract_data - ) - list.metadata = {'url': "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/deployments/{deploymentName}/operations"} # type: ignore + list.metadata = {"url": "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/deployments/{deploymentName}/operations"} # type: ignore diff --git a/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/resources/v2018_05_01/aio/operations/_patch.py b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/resources/v2018_05_01/aio/operations/_patch.py new file mode 100644 index 0000000000000..f7dd32510333d --- /dev/null +++ b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/resources/v2018_05_01/aio/operations/_patch.py @@ -0,0 +1,20 @@ +# ------------------------------------ +# Copyright (c) Microsoft Corporation. +# Licensed under the MIT License. +# ------------------------------------ +"""Customize generated code here. + +Follow our quickstart for examples: https://aka.ms/azsdk/python/dpcodegen/python/customize +""" +from typing import List + +__all__: List[str] = [] # Add all objects you want publicly available to users at this package level + + +def patch_sdk(): + """Do not remove from this file. + + `patch_sdk` is a last resort escape hatch that allows you to do customizations + you can't accomplish using the techniques described in + https://aka.ms/azsdk/python/dpcodegen/python/customize + """ diff --git a/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/resources/v2018_05_01/models/__init__.py b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/resources/v2018_05_01/models/__init__.py index ce87b190b8862..39249f144291f 100644 --- a/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/resources/v2018_05_01/models/__init__.py +++ b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/resources/v2018_05_01/models/__init__.py @@ -63,71 +63,73 @@ from ._models_py3 import TemplateLink from ._models_py3 import ZoneMapping - -from ._resource_management_client_enums import ( - DeploymentMode, - OnErrorDeploymentType, - ResourceIdentityType, -) +from ._resource_management_client_enums import DeploymentMode +from ._resource_management_client_enums import OnErrorDeploymentType +from ._resource_management_client_enums import ResourceIdentityType +from ._patch import __all__ as _patch_all +from ._patch import * # type: ignore # pylint: disable=unused-wildcard-import +from ._patch import patch_sdk as _patch_sdk __all__ = [ - 'AliasPathType', - 'AliasType', - 'BasicDependency', - 'ComponentsSgqdofSchemasIdentityPropertiesUserassignedidentitiesAdditionalproperties', - 'DebugSetting', - 'Dependency', - 'Deployment', - 'DeploymentExportResult', - 'DeploymentExtended', - 'DeploymentExtendedFilter', - 'DeploymentListResult', - 'DeploymentOperation', - 'DeploymentOperationProperties', - 'DeploymentOperationsListResult', - 'DeploymentProperties', - 'DeploymentPropertiesExtended', - 'DeploymentValidateResult', - 'ErrorAdditionalInfo', - 'ErrorResponse', - 'ExportTemplateRequest', - 'GenericResource', - 'GenericResourceExpanded', - 'GenericResourceFilter', - 'HttpMessage', - 'Identity', - 'OnErrorDeployment', - 'OnErrorDeploymentExtended', - 'Operation', - 'OperationDisplay', - 'OperationListResult', - 'ParametersLink', - 'Plan', - 'Provider', - 'ProviderListResult', - 'ProviderResourceType', - 'Resource', - 'ResourceGroup', - 'ResourceGroupExportResult', - 'ResourceGroupFilter', - 'ResourceGroupListResult', - 'ResourceGroupPatchable', - 'ResourceGroupProperties', - 'ResourceListResult', - 'ResourceManagementErrorWithDetails', - 'ResourceProviderOperationDisplayProperties', - 'ResourcesMoveInfo', - 'Sku', - 'SubResource', - 'TagCount', - 'TagDetails', - 'TagValue', - 'TagsListResult', - 'TargetResource', - 'TemplateHashResult', - 'TemplateLink', - 'ZoneMapping', - 'DeploymentMode', - 'OnErrorDeploymentType', - 'ResourceIdentityType', + "AliasPathType", + "AliasType", + "BasicDependency", + "ComponentsSgqdofSchemasIdentityPropertiesUserassignedidentitiesAdditionalproperties", + "DebugSetting", + "Dependency", + "Deployment", + "DeploymentExportResult", + "DeploymentExtended", + "DeploymentExtendedFilter", + "DeploymentListResult", + "DeploymentOperation", + "DeploymentOperationProperties", + "DeploymentOperationsListResult", + "DeploymentProperties", + "DeploymentPropertiesExtended", + "DeploymentValidateResult", + "ErrorAdditionalInfo", + "ErrorResponse", + "ExportTemplateRequest", + "GenericResource", + "GenericResourceExpanded", + "GenericResourceFilter", + "HttpMessage", + "Identity", + "OnErrorDeployment", + "OnErrorDeploymentExtended", + "Operation", + "OperationDisplay", + "OperationListResult", + "ParametersLink", + "Plan", + "Provider", + "ProviderListResult", + "ProviderResourceType", + "Resource", + "ResourceGroup", + "ResourceGroupExportResult", + "ResourceGroupFilter", + "ResourceGroupListResult", + "ResourceGroupPatchable", + "ResourceGroupProperties", + "ResourceListResult", + "ResourceManagementErrorWithDetails", + "ResourceProviderOperationDisplayProperties", + "ResourcesMoveInfo", + "Sku", + "SubResource", + "TagCount", + "TagDetails", + "TagValue", + "TagsListResult", + "TargetResource", + "TemplateHashResult", + "TemplateLink", + "ZoneMapping", + "DeploymentMode", + "OnErrorDeploymentType", + "ResourceIdentityType", ] +__all__.extend([p for p in _patch_all if p not in __all__]) +_patch_sdk() diff --git a/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/resources/v2018_05_01/models/_models_py3.py b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/resources/v2018_05_01/models/_models_py3.py index 001793e31d1a5..1b6ae743e213d 100644 --- a/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/resources/v2018_05_01/models/_models_py3.py +++ b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/resources/v2018_05_01/models/_models_py3.py @@ -1,4 +1,5 @@ # coding=utf-8 +# pylint: disable=too-many-lines # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. # Licensed under the MIT License. See License.txt in the project root for license information. @@ -6,14 +7,22 @@ # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -from typing import Any, Dict, List, Optional, Union +import sys +from typing import Any, Dict, List, Optional, TYPE_CHECKING, Union -import msrest.serialization +from ... import _serialization -from ._resource_management_client_enums import * +if TYPE_CHECKING: + # pylint: disable=unused-import,ungrouped-imports + from .. import models as _models +if sys.version_info >= (3, 9): + from collections.abc import MutableMapping +else: + from typing import MutableMapping # type: ignore # pylint: disable=ungrouped-imports +JSON = MutableMapping[str, Any] # pylint: disable=unsubscriptable-object -class AliasPathType(msrest.serialization.Model): +class AliasPathType(_serialization.Model): """The type of the paths for alias. :ivar path: The path of an alias. @@ -23,29 +32,23 @@ class AliasPathType(msrest.serialization.Model): """ _attribute_map = { - 'path': {'key': 'path', 'type': 'str'}, - 'api_versions': {'key': 'apiVersions', 'type': '[str]'}, + "path": {"key": "path", "type": "str"}, + "api_versions": {"key": "apiVersions", "type": "[str]"}, } - def __init__( - self, - *, - path: Optional[str] = None, - api_versions: Optional[List[str]] = None, - **kwargs - ): + def __init__(self, *, path: Optional[str] = None, api_versions: Optional[List[str]] = None, **kwargs): """ :keyword path: The path of an alias. :paramtype path: str :keyword api_versions: The API versions. :paramtype api_versions: list[str] """ - super(AliasPathType, self).__init__(**kwargs) + super().__init__(**kwargs) self.path = path self.api_versions = api_versions -class AliasType(msrest.serialization.Model): +class AliasType(_serialization.Model): """The alias type. :ivar name: The alias name. @@ -55,29 +58,23 @@ class AliasType(msrest.serialization.Model): """ _attribute_map = { - 'name': {'key': 'name', 'type': 'str'}, - 'paths': {'key': 'paths', 'type': '[AliasPathType]'}, + "name": {"key": "name", "type": "str"}, + "paths": {"key": "paths", "type": "[AliasPathType]"}, } - def __init__( - self, - *, - name: Optional[str] = None, - paths: Optional[List["AliasPathType"]] = None, - **kwargs - ): + def __init__(self, *, name: Optional[str] = None, paths: Optional[List["_models.AliasPathType"]] = None, **kwargs): """ :keyword name: The alias name. :paramtype name: str :keyword paths: The paths for an alias. :paramtype paths: list[~azure.mgmt.resource.resources.v2018_05_01.models.AliasPathType] """ - super(AliasType, self).__init__(**kwargs) + super().__init__(**kwargs) self.name = name self.paths = paths -class BasicDependency(msrest.serialization.Model): +class BasicDependency(_serialization.Model): """Deployment dependency information. :ivar id: The ID of the dependency. @@ -89,15 +86,15 @@ class BasicDependency(msrest.serialization.Model): """ _attribute_map = { - 'id': {'key': 'id', 'type': 'str'}, - 'resource_type': {'key': 'resourceType', 'type': 'str'}, - 'resource_name': {'key': 'resourceName', 'type': 'str'}, + "id": {"key": "id", "type": "str"}, + "resource_type": {"key": "resourceType", "type": "str"}, + "resource_name": {"key": "resourceName", "type": "str"}, } def __init__( self, *, - id: Optional[str] = None, + id: Optional[str] = None, # pylint: disable=redefined-builtin resource_type: Optional[str] = None, resource_name: Optional[str] = None, **kwargs @@ -110,13 +107,13 @@ def __init__( :keyword resource_name: The dependency resource name. :paramtype resource_name: str """ - super(BasicDependency, self).__init__(**kwargs) + super().__init__(**kwargs) self.id = id self.resource_type = resource_type self.resource_name = resource_name -class ComponentsSgqdofSchemasIdentityPropertiesUserassignedidentitiesAdditionalproperties(msrest.serialization.Model): +class ComponentsSgqdofSchemasIdentityPropertiesUserassignedidentitiesAdditionalproperties(_serialization.Model): """ComponentsSgqdofSchemasIdentityPropertiesUserassignedidentitiesAdditionalproperties. Variables are only populated by the server, and will be ignored when sending a request. @@ -128,27 +125,23 @@ class ComponentsSgqdofSchemasIdentityPropertiesUserassignedidentitiesAdditionalp """ _validation = { - 'principal_id': {'readonly': True}, - 'client_id': {'readonly': True}, + "principal_id": {"readonly": True}, + "client_id": {"readonly": True}, } _attribute_map = { - 'principal_id': {'key': 'principalId', 'type': 'str'}, - 'client_id': {'key': 'clientId', 'type': 'str'}, + "principal_id": {"key": "principalId", "type": "str"}, + "client_id": {"key": "clientId", "type": "str"}, } - def __init__( - self, - **kwargs - ): - """ - """ - super(ComponentsSgqdofSchemasIdentityPropertiesUserassignedidentitiesAdditionalproperties, self).__init__(**kwargs) + def __init__(self, **kwargs): + """ """ + super().__init__(**kwargs) self.principal_id = None self.client_id = None -class DebugSetting(msrest.serialization.Model): +class DebugSetting(_serialization.Model): """DebugSetting. :ivar detail_level: Specifies the type of information to log for debugging. The permitted @@ -161,15 +154,10 @@ class DebugSetting(msrest.serialization.Model): """ _attribute_map = { - 'detail_level': {'key': 'detailLevel', 'type': 'str'}, + "detail_level": {"key": "detailLevel", "type": "str"}, } - def __init__( - self, - *, - detail_level: Optional[str] = None, - **kwargs - ): + def __init__(self, *, detail_level: Optional[str] = None, **kwargs): """ :keyword detail_level: Specifies the type of information to log for debugging. The permitted values are none, requestContent, responseContent, or both requestContent and responseContent @@ -179,11 +167,11 @@ def __init__( deployment operations. :paramtype detail_level: str """ - super(DebugSetting, self).__init__(**kwargs) + super().__init__(**kwargs) self.detail_level = detail_level -class Dependency(msrest.serialization.Model): +class Dependency(_serialization.Model): """Deployment dependency information. :ivar depends_on: The list of dependencies. @@ -197,17 +185,17 @@ class Dependency(msrest.serialization.Model): """ _attribute_map = { - 'depends_on': {'key': 'dependsOn', 'type': '[BasicDependency]'}, - 'id': {'key': 'id', 'type': 'str'}, - 'resource_type': {'key': 'resourceType', 'type': 'str'}, - 'resource_name': {'key': 'resourceName', 'type': 'str'}, + "depends_on": {"key": "dependsOn", "type": "[BasicDependency]"}, + "id": {"key": "id", "type": "str"}, + "resource_type": {"key": "resourceType", "type": "str"}, + "resource_name": {"key": "resourceName", "type": "str"}, } def __init__( self, *, - depends_on: Optional[List["BasicDependency"]] = None, - id: Optional[str] = None, + depends_on: Optional[List["_models.BasicDependency"]] = None, + id: Optional[str] = None, # pylint: disable=redefined-builtin resource_type: Optional[str] = None, resource_name: Optional[str] = None, **kwargs @@ -222,77 +210,66 @@ def __init__( :keyword resource_name: The dependency resource name. :paramtype resource_name: str """ - super(Dependency, self).__init__(**kwargs) + super().__init__(**kwargs) self.depends_on = depends_on self.id = id self.resource_type = resource_type self.resource_name = resource_name -class Deployment(msrest.serialization.Model): +class Deployment(_serialization.Model): """Deployment operation parameters. All required parameters must be populated in order to send to Azure. :ivar location: The location to store the deployment data. :vartype location: str - :ivar properties: Required. The deployment properties. + :ivar properties: The deployment properties. Required. :vartype properties: ~azure.mgmt.resource.resources.v2018_05_01.models.DeploymentProperties """ _validation = { - 'properties': {'required': True}, + "properties": {"required": True}, } _attribute_map = { - 'location': {'key': 'location', 'type': 'str'}, - 'properties': {'key': 'properties', 'type': 'DeploymentProperties'}, + "location": {"key": "location", "type": "str"}, + "properties": {"key": "properties", "type": "DeploymentProperties"}, } - def __init__( - self, - *, - properties: "DeploymentProperties", - location: Optional[str] = None, - **kwargs - ): + def __init__(self, *, properties: "_models.DeploymentProperties", location: Optional[str] = None, **kwargs): """ :keyword location: The location to store the deployment data. :paramtype location: str - :keyword properties: Required. The deployment properties. + :keyword properties: The deployment properties. Required. :paramtype properties: ~azure.mgmt.resource.resources.v2018_05_01.models.DeploymentProperties """ - super(Deployment, self).__init__(**kwargs) + super().__init__(**kwargs) self.location = location self.properties = properties -class DeploymentExportResult(msrest.serialization.Model): +class DeploymentExportResult(_serialization.Model): """The deployment export result. :ivar template: The template content. - :vartype template: any + :vartype template: JSON """ _attribute_map = { - 'template': {'key': 'template', 'type': 'object'}, + "template": {"key": "template", "type": "object"}, } - def __init__( - self, - *, - template: Optional[Any] = None, - **kwargs - ): + def __init__(self, *, template: Optional[JSON] = None, **kwargs): """ :keyword template: The template content. - :paramtype template: any + :paramtype template: JSON """ - super(DeploymentExportResult, self).__init__(**kwargs) + super().__init__(**kwargs) self.template = template -class DeploymentExtended(msrest.serialization.Model): +class DeploymentExtended(_serialization.Model): """Deployment information. Variables are only populated by the server, and will be ignored when sending a request. @@ -311,24 +288,24 @@ class DeploymentExtended(msrest.serialization.Model): """ _validation = { - 'id': {'readonly': True}, - 'name': {'readonly': True}, - 'type': {'readonly': True}, + "id": {"readonly": True}, + "name": {"readonly": True}, + "type": {"readonly": True}, } _attribute_map = { - 'id': {'key': 'id', 'type': 'str'}, - 'name': {'key': 'name', 'type': 'str'}, - 'type': {'key': 'type', 'type': 'str'}, - 'location': {'key': 'location', 'type': 'str'}, - 'properties': {'key': 'properties', 'type': 'DeploymentPropertiesExtended'}, + "id": {"key": "id", "type": "str"}, + "name": {"key": "name", "type": "str"}, + "type": {"key": "type", "type": "str"}, + "location": {"key": "location", "type": "str"}, + "properties": {"key": "properties", "type": "DeploymentPropertiesExtended"}, } def __init__( self, *, location: Optional[str] = None, - properties: Optional["DeploymentPropertiesExtended"] = None, + properties: Optional["_models.DeploymentPropertiesExtended"] = None, **kwargs ): """ @@ -338,7 +315,7 @@ def __init__( :paramtype properties: ~azure.mgmt.resource.resources.v2018_05_01.models.DeploymentPropertiesExtended """ - super(DeploymentExtended, self).__init__(**kwargs) + super().__init__(**kwargs) self.id = None self.name = None self.type = None @@ -346,7 +323,7 @@ def __init__( self.properties = properties -class DeploymentExtendedFilter(msrest.serialization.Model): +class DeploymentExtendedFilter(_serialization.Model): """Deployment filter. :ivar provisioning_state: The provisioning state. @@ -354,24 +331,19 @@ class DeploymentExtendedFilter(msrest.serialization.Model): """ _attribute_map = { - 'provisioning_state': {'key': 'provisioningState', 'type': 'str'}, + "provisioning_state": {"key": "provisioningState", "type": "str"}, } - def __init__( - self, - *, - provisioning_state: Optional[str] = None, - **kwargs - ): + def __init__(self, *, provisioning_state: Optional[str] = None, **kwargs): """ :keyword provisioning_state: The provisioning state. :paramtype provisioning_state: str """ - super(DeploymentExtendedFilter, self).__init__(**kwargs) + super().__init__(**kwargs) self.provisioning_state = provisioning_state -class DeploymentListResult(msrest.serialization.Model): +class DeploymentListResult(_serialization.Model): """List of deployments. Variables are only populated by the server, and will be ignored when sending a request. @@ -383,30 +355,25 @@ class DeploymentListResult(msrest.serialization.Model): """ _validation = { - 'next_link': {'readonly': True}, + "next_link": {"readonly": True}, } _attribute_map = { - 'value': {'key': 'value', 'type': '[DeploymentExtended]'}, - 'next_link': {'key': 'nextLink', 'type': 'str'}, + "value": {"key": "value", "type": "[DeploymentExtended]"}, + "next_link": {"key": "nextLink", "type": "str"}, } - def __init__( - self, - *, - value: Optional[List["DeploymentExtended"]] = None, - **kwargs - ): + def __init__(self, *, value: Optional[List["_models.DeploymentExtended"]] = None, **kwargs): """ :keyword value: An array of deployments. :paramtype value: list[~azure.mgmt.resource.resources.v2018_05_01.models.DeploymentExtended] """ - super(DeploymentListResult, self).__init__(**kwargs) + super().__init__(**kwargs) self.value = value self.next_link = None -class DeploymentOperation(msrest.serialization.Model): +class DeploymentOperation(_serialization.Model): """Deployment operation information. Variables are only populated by the server, and will be ignored when sending a request. @@ -421,34 +388,29 @@ class DeploymentOperation(msrest.serialization.Model): """ _validation = { - 'id': {'readonly': True}, - 'operation_id': {'readonly': True}, + "id": {"readonly": True}, + "operation_id": {"readonly": True}, } _attribute_map = { - 'id': {'key': 'id', 'type': 'str'}, - 'operation_id': {'key': 'operationId', 'type': 'str'}, - 'properties': {'key': 'properties', 'type': 'DeploymentOperationProperties'}, + "id": {"key": "id", "type": "str"}, + "operation_id": {"key": "operationId", "type": "str"}, + "properties": {"key": "properties", "type": "DeploymentOperationProperties"}, } - def __init__( - self, - *, - properties: Optional["DeploymentOperationProperties"] = None, - **kwargs - ): + def __init__(self, *, properties: Optional["_models.DeploymentOperationProperties"] = None, **kwargs): """ :keyword properties: Deployment properties. :paramtype properties: ~azure.mgmt.resource.resources.v2018_05_01.models.DeploymentOperationProperties """ - super(DeploymentOperation, self).__init__(**kwargs) + super().__init__(**kwargs) self.id = None self.operation_id = None self.properties = properties -class DeploymentOperationProperties(msrest.serialization.Model): +class DeploymentOperationProperties(_serialization.Model): """Deployment operation properties. Variables are only populated by the server, and will be ignored when sending a request. @@ -462,7 +424,7 @@ class DeploymentOperationProperties(msrest.serialization.Model): :ivar status_code: Operation status code. :vartype status_code: str :ivar status_message: Operation status message. - :vartype status_message: any + :vartype status_message: JSON :ivar target_resource: The target resource. :vartype target_resource: ~azure.mgmt.resource.resources.v2018_05_01.models.TargetResource :ivar request: The HTTP request message. @@ -472,34 +434,30 @@ class DeploymentOperationProperties(msrest.serialization.Model): """ _validation = { - 'provisioning_state': {'readonly': True}, - 'timestamp': {'readonly': True}, - 'service_request_id': {'readonly': True}, - 'status_code': {'readonly': True}, - 'status_message': {'readonly': True}, - 'target_resource': {'readonly': True}, - 'request': {'readonly': True}, - 'response': {'readonly': True}, + "provisioning_state": {"readonly": True}, + "timestamp": {"readonly": True}, + "service_request_id": {"readonly": True}, + "status_code": {"readonly": True}, + "status_message": {"readonly": True}, + "target_resource": {"readonly": True}, + "request": {"readonly": True}, + "response": {"readonly": True}, } _attribute_map = { - 'provisioning_state': {'key': 'provisioningState', 'type': 'str'}, - 'timestamp': {'key': 'timestamp', 'type': 'iso-8601'}, - 'service_request_id': {'key': 'serviceRequestId', 'type': 'str'}, - 'status_code': {'key': 'statusCode', 'type': 'str'}, - 'status_message': {'key': 'statusMessage', 'type': 'object'}, - 'target_resource': {'key': 'targetResource', 'type': 'TargetResource'}, - 'request': {'key': 'request', 'type': 'HttpMessage'}, - 'response': {'key': 'response', 'type': 'HttpMessage'}, - } - - def __init__( - self, - **kwargs - ): - """ - """ - super(DeploymentOperationProperties, self).__init__(**kwargs) + "provisioning_state": {"key": "provisioningState", "type": "str"}, + "timestamp": {"key": "timestamp", "type": "iso-8601"}, + "service_request_id": {"key": "serviceRequestId", "type": "str"}, + "status_code": {"key": "statusCode", "type": "str"}, + "status_message": {"key": "statusMessage", "type": "object"}, + "target_resource": {"key": "targetResource", "type": "TargetResource"}, + "request": {"key": "request", "type": "HttpMessage"}, + "response": {"key": "response", "type": "HttpMessage"}, + } + + def __init__(self, **kwargs): + """ """ + super().__init__(**kwargs) self.provisioning_state = None self.timestamp = None self.service_request_id = None @@ -510,7 +468,7 @@ def __init__( self.response = None -class DeploymentOperationsListResult(msrest.serialization.Model): +class DeploymentOperationsListResult(_serialization.Model): """List of deployment operations. Variables are only populated by the server, and will be ignored when sending a request. @@ -522,30 +480,25 @@ class DeploymentOperationsListResult(msrest.serialization.Model): """ _validation = { - 'next_link': {'readonly': True}, + "next_link": {"readonly": True}, } _attribute_map = { - 'value': {'key': 'value', 'type': '[DeploymentOperation]'}, - 'next_link': {'key': 'nextLink', 'type': 'str'}, + "value": {"key": "value", "type": "[DeploymentOperation]"}, + "next_link": {"key": "nextLink", "type": "str"}, } - def __init__( - self, - *, - value: Optional[List["DeploymentOperation"]] = None, - **kwargs - ): + def __init__(self, *, value: Optional[List["_models.DeploymentOperation"]] = None, **kwargs): """ :keyword value: An array of deployment operations. :paramtype value: list[~azure.mgmt.resource.resources.v2018_05_01.models.DeploymentOperation] """ - super(DeploymentOperationsListResult, self).__init__(**kwargs) + super().__init__(**kwargs) self.value = value self.next_link = None -class DeploymentProperties(msrest.serialization.Model): +class DeploymentProperties(_serialization.Model): """Deployment properties. All required parameters must be populated in order to send to Azure. @@ -554,7 +507,7 @@ class DeploymentProperties(msrest.serialization.Model): syntax directly in the request rather than link to an existing template. It can be a JObject or well-formed JSON string. Use either the templateLink property or the template property, but not both. - :vartype template: any + :vartype template: JSON :ivar template_link: The URI of the template. Use either the templateLink property or the template property, but not both. :vartype template_link: ~azure.mgmt.resource.resources.v2018_05_01.models.TemplateLink @@ -562,17 +515,17 @@ class DeploymentProperties(msrest.serialization.Model): You use this element when you want to provide the parameter values directly in the request rather than link to an existing parameter file. Use either the parametersLink property or the parameters property, but not both. It can be a JObject or a well formed JSON string. - :vartype parameters: any + :vartype parameters: JSON :ivar parameters_link: The URI of parameters file. You use this element to link to an existing parameters file. Use either the parametersLink property or the parameters property, but not both. :vartype parameters_link: ~azure.mgmt.resource.resources.v2018_05_01.models.ParametersLink - :ivar mode: Required. The mode that is used to deploy resources. This value can be either - Incremental or Complete. In Incremental mode, resources are deployed without deleting existing - resources that are not included in the template. In Complete mode, resources are deployed and - existing resources in the resource group that are not included in the template are deleted. Be - careful when using Complete mode as you may unintentionally delete resources. Possible values - include: "Incremental", "Complete". + :ivar mode: The mode that is used to deploy resources. This value can be either Incremental or + Complete. In Incremental mode, resources are deployed without deleting existing resources that + are not included in the template. In Complete mode, resources are deployed and existing + resources in the resource group that are not included in the template are deleted. Be careful + when using Complete mode as you may unintentionally delete resources. Required. Known values + are: "Incremental" and "Complete". :vartype mode: str or ~azure.mgmt.resource.resources.v2018_05_01.models.DeploymentMode :ivar debug_setting: The debug setting of the deployment. :vartype debug_setting: ~azure.mgmt.resource.resources.v2018_05_01.models.DebugSetting @@ -582,29 +535,29 @@ class DeploymentProperties(msrest.serialization.Model): """ _validation = { - 'mode': {'required': True}, + "mode": {"required": True}, } _attribute_map = { - 'template': {'key': 'template', 'type': 'object'}, - 'template_link': {'key': 'templateLink', 'type': 'TemplateLink'}, - 'parameters': {'key': 'parameters', 'type': 'object'}, - 'parameters_link': {'key': 'parametersLink', 'type': 'ParametersLink'}, - 'mode': {'key': 'mode', 'type': 'str'}, - 'debug_setting': {'key': 'debugSetting', 'type': 'DebugSetting'}, - 'on_error_deployment': {'key': 'onErrorDeployment', 'type': 'OnErrorDeployment'}, + "template": {"key": "template", "type": "object"}, + "template_link": {"key": "templateLink", "type": "TemplateLink"}, + "parameters": {"key": "parameters", "type": "object"}, + "parameters_link": {"key": "parametersLink", "type": "ParametersLink"}, + "mode": {"key": "mode", "type": "str"}, + "debug_setting": {"key": "debugSetting", "type": "DebugSetting"}, + "on_error_deployment": {"key": "onErrorDeployment", "type": "OnErrorDeployment"}, } def __init__( self, *, - mode: Union[str, "DeploymentMode"], - template: Optional[Any] = None, - template_link: Optional["TemplateLink"] = None, - parameters: Optional[Any] = None, - parameters_link: Optional["ParametersLink"] = None, - debug_setting: Optional["DebugSetting"] = None, - on_error_deployment: Optional["OnErrorDeployment"] = None, + mode: Union[str, "_models.DeploymentMode"], + template: Optional[JSON] = None, + template_link: Optional["_models.TemplateLink"] = None, + parameters: Optional[JSON] = None, + parameters_link: Optional["_models.ParametersLink"] = None, + debug_setting: Optional["_models.DebugSetting"] = None, + on_error_deployment: Optional["_models.OnErrorDeployment"] = None, **kwargs ): """ @@ -612,7 +565,7 @@ def __init__( template syntax directly in the request rather than link to an existing template. It can be a JObject or well-formed JSON string. Use either the templateLink property or the template property, but not both. - :paramtype template: any + :paramtype template: JSON :keyword template_link: The URI of the template. Use either the templateLink property or the template property, but not both. :paramtype template_link: ~azure.mgmt.resource.resources.v2018_05_01.models.TemplateLink @@ -620,17 +573,17 @@ def __init__( template. You use this element when you want to provide the parameter values directly in the request rather than link to an existing parameter file. Use either the parametersLink property or the parameters property, but not both. It can be a JObject or a well formed JSON string. - :paramtype parameters: any + :paramtype parameters: JSON :keyword parameters_link: The URI of parameters file. You use this element to link to an existing parameters file. Use either the parametersLink property or the parameters property, but not both. :paramtype parameters_link: ~azure.mgmt.resource.resources.v2018_05_01.models.ParametersLink - :keyword mode: Required. The mode that is used to deploy resources. This value can be either - Incremental or Complete. In Incremental mode, resources are deployed without deleting existing - resources that are not included in the template. In Complete mode, resources are deployed and - existing resources in the resource group that are not included in the template are deleted. Be - careful when using Complete mode as you may unintentionally delete resources. Possible values - include: "Incremental", "Complete". + :keyword mode: The mode that is used to deploy resources. This value can be either Incremental + or Complete. In Incremental mode, resources are deployed without deleting existing resources + that are not included in the template. In Complete mode, resources are deployed and existing + resources in the resource group that are not included in the template are deleted. Be careful + when using Complete mode as you may unintentionally delete resources. Required. Known values + are: "Incremental" and "Complete". :paramtype mode: str or ~azure.mgmt.resource.resources.v2018_05_01.models.DeploymentMode :keyword debug_setting: The debug setting of the deployment. :paramtype debug_setting: ~azure.mgmt.resource.resources.v2018_05_01.models.DebugSetting @@ -638,7 +591,7 @@ def __init__( :paramtype on_error_deployment: ~azure.mgmt.resource.resources.v2018_05_01.models.OnErrorDeployment """ - super(DeploymentProperties, self).__init__(**kwargs) + super().__init__(**kwargs) self.template = template self.template_link = template_link self.parameters = parameters @@ -648,7 +601,7 @@ def __init__( self.on_error_deployment = on_error_deployment -class DeploymentPropertiesExtended(msrest.serialization.Model): +class DeploymentPropertiesExtended(_serialization.Model): # pylint: disable=too-many-instance-attributes """Deployment properties with additional details. Variables are only populated by the server, and will be ignored when sending a request. @@ -660,23 +613,23 @@ class DeploymentPropertiesExtended(msrest.serialization.Model): :ivar timestamp: The timestamp of the template deployment. :vartype timestamp: ~datetime.datetime :ivar outputs: Key/value pairs that represent deployment output. - :vartype outputs: any + :vartype outputs: JSON :ivar providers: The list of resource providers needed for the deployment. :vartype providers: list[~azure.mgmt.resource.resources.v2018_05_01.models.Provider] :ivar dependencies: The list of deployment dependencies. :vartype dependencies: list[~azure.mgmt.resource.resources.v2018_05_01.models.Dependency] :ivar template: The template content. Use only one of Template or TemplateLink. - :vartype template: any + :vartype template: JSON :ivar template_link: The URI referencing the template. Use only one of Template or TemplateLink. :vartype template_link: ~azure.mgmt.resource.resources.v2018_05_01.models.TemplateLink :ivar parameters: Deployment parameters. Use only one of Parameters or ParametersLink. - :vartype parameters: any + :vartype parameters: JSON :ivar parameters_link: The URI referencing the parameters. Use only one of Parameters or ParametersLink. :vartype parameters_link: ~azure.mgmt.resource.resources.v2018_05_01.models.ParametersLink - :ivar mode: The deployment mode. Possible values are Incremental and Complete. Possible values - include: "Incremental", "Complete". + :ivar mode: The deployment mode. Possible values are Incremental and Complete. Known values + are: "Incremental" and "Complete". :vartype mode: str or ~azure.mgmt.resource.resources.v2018_05_01.models.DeploymentMode :ivar debug_setting: The debug setting of the deployment. :vartype debug_setting: ~azure.mgmt.resource.resources.v2018_05_01.models.DebugSetting @@ -688,63 +641,63 @@ class DeploymentPropertiesExtended(msrest.serialization.Model): """ _validation = { - 'provisioning_state': {'readonly': True}, - 'correlation_id': {'readonly': True}, - 'timestamp': {'readonly': True}, - 'error': {'readonly': True}, + "provisioning_state": {"readonly": True}, + "correlation_id": {"readonly": True}, + "timestamp": {"readonly": True}, + "error": {"readonly": True}, } _attribute_map = { - 'provisioning_state': {'key': 'provisioningState', 'type': 'str'}, - 'correlation_id': {'key': 'correlationId', 'type': 'str'}, - 'timestamp': {'key': 'timestamp', 'type': 'iso-8601'}, - 'outputs': {'key': 'outputs', 'type': 'object'}, - 'providers': {'key': 'providers', 'type': '[Provider]'}, - 'dependencies': {'key': 'dependencies', 'type': '[Dependency]'}, - 'template': {'key': 'template', 'type': 'object'}, - 'template_link': {'key': 'templateLink', 'type': 'TemplateLink'}, - 'parameters': {'key': 'parameters', 'type': 'object'}, - 'parameters_link': {'key': 'parametersLink', 'type': 'ParametersLink'}, - 'mode': {'key': 'mode', 'type': 'str'}, - 'debug_setting': {'key': 'debugSetting', 'type': 'DebugSetting'}, - 'on_error_deployment': {'key': 'onErrorDeployment', 'type': 'OnErrorDeploymentExtended'}, - 'error': {'key': 'error', 'type': 'ErrorResponse'}, + "provisioning_state": {"key": "provisioningState", "type": "str"}, + "correlation_id": {"key": "correlationId", "type": "str"}, + "timestamp": {"key": "timestamp", "type": "iso-8601"}, + "outputs": {"key": "outputs", "type": "object"}, + "providers": {"key": "providers", "type": "[Provider]"}, + "dependencies": {"key": "dependencies", "type": "[Dependency]"}, + "template": {"key": "template", "type": "object"}, + "template_link": {"key": "templateLink", "type": "TemplateLink"}, + "parameters": {"key": "parameters", "type": "object"}, + "parameters_link": {"key": "parametersLink", "type": "ParametersLink"}, + "mode": {"key": "mode", "type": "str"}, + "debug_setting": {"key": "debugSetting", "type": "DebugSetting"}, + "on_error_deployment": {"key": "onErrorDeployment", "type": "OnErrorDeploymentExtended"}, + "error": {"key": "error", "type": "ErrorResponse"}, } def __init__( self, *, - outputs: Optional[Any] = None, - providers: Optional[List["Provider"]] = None, - dependencies: Optional[List["Dependency"]] = None, - template: Optional[Any] = None, - template_link: Optional["TemplateLink"] = None, - parameters: Optional[Any] = None, - parameters_link: Optional["ParametersLink"] = None, - mode: Optional[Union[str, "DeploymentMode"]] = None, - debug_setting: Optional["DebugSetting"] = None, - on_error_deployment: Optional["OnErrorDeploymentExtended"] = None, + outputs: Optional[JSON] = None, + providers: Optional[List["_models.Provider"]] = None, + dependencies: Optional[List["_models.Dependency"]] = None, + template: Optional[JSON] = None, + template_link: Optional["_models.TemplateLink"] = None, + parameters: Optional[JSON] = None, + parameters_link: Optional["_models.ParametersLink"] = None, + mode: Optional[Union[str, "_models.DeploymentMode"]] = None, + debug_setting: Optional["_models.DebugSetting"] = None, + on_error_deployment: Optional["_models.OnErrorDeploymentExtended"] = None, **kwargs ): """ :keyword outputs: Key/value pairs that represent deployment output. - :paramtype outputs: any + :paramtype outputs: JSON :keyword providers: The list of resource providers needed for the deployment. :paramtype providers: list[~azure.mgmt.resource.resources.v2018_05_01.models.Provider] :keyword dependencies: The list of deployment dependencies. :paramtype dependencies: list[~azure.mgmt.resource.resources.v2018_05_01.models.Dependency] :keyword template: The template content. Use only one of Template or TemplateLink. - :paramtype template: any + :paramtype template: JSON :keyword template_link: The URI referencing the template. Use only one of Template or TemplateLink. :paramtype template_link: ~azure.mgmt.resource.resources.v2018_05_01.models.TemplateLink :keyword parameters: Deployment parameters. Use only one of Parameters or ParametersLink. - :paramtype parameters: any + :paramtype parameters: JSON :keyword parameters_link: The URI referencing the parameters. Use only one of Parameters or ParametersLink. :paramtype parameters_link: ~azure.mgmt.resource.resources.v2018_05_01.models.ParametersLink - :keyword mode: The deployment mode. Possible values are Incremental and Complete. Possible - values include: "Incremental", "Complete". + :keyword mode: The deployment mode. Possible values are Incremental and Complete. Known values + are: "Incremental" and "Complete". :paramtype mode: str or ~azure.mgmt.resource.resources.v2018_05_01.models.DeploymentMode :keyword debug_setting: The debug setting of the deployment. :paramtype debug_setting: ~azure.mgmt.resource.resources.v2018_05_01.models.DebugSetting @@ -752,7 +705,7 @@ def __init__( :paramtype on_error_deployment: ~azure.mgmt.resource.resources.v2018_05_01.models.OnErrorDeploymentExtended """ - super(DeploymentPropertiesExtended, self).__init__(**kwargs) + super().__init__(**kwargs) self.provisioning_state = None self.correlation_id = None self.timestamp = None @@ -769,7 +722,7 @@ def __init__( self.error = None -class DeploymentValidateResult(msrest.serialization.Model): +class DeploymentValidateResult(_serialization.Model): """Information from validate template deployment response. :ivar error: Validation error. @@ -781,15 +734,15 @@ class DeploymentValidateResult(msrest.serialization.Model): """ _attribute_map = { - 'error': {'key': 'error', 'type': 'ResourceManagementErrorWithDetails'}, - 'properties': {'key': 'properties', 'type': 'DeploymentPropertiesExtended'}, + "error": {"key": "error", "type": "ResourceManagementErrorWithDetails"}, + "properties": {"key": "properties", "type": "DeploymentPropertiesExtended"}, } def __init__( self, *, - error: Optional["ResourceManagementErrorWithDetails"] = None, - properties: Optional["DeploymentPropertiesExtended"] = None, + error: Optional["_models.ResourceManagementErrorWithDetails"] = None, + properties: Optional["_models.DeploymentPropertiesExtended"] = None, **kwargs ): """ @@ -800,12 +753,12 @@ def __init__( :paramtype properties: ~azure.mgmt.resource.resources.v2018_05_01.models.DeploymentPropertiesExtended """ - super(DeploymentValidateResult, self).__init__(**kwargs) + super().__init__(**kwargs) self.error = error self.properties = properties -class ErrorAdditionalInfo(msrest.serialization.Model): +class ErrorAdditionalInfo(_serialization.Model): """The resource management error additional info. Variables are only populated by the server, and will be ignored when sending a request. @@ -813,31 +766,27 @@ class ErrorAdditionalInfo(msrest.serialization.Model): :ivar type: The additional info type. :vartype type: str :ivar info: The additional info. - :vartype info: any + :vartype info: JSON """ _validation = { - 'type': {'readonly': True}, - 'info': {'readonly': True}, + "type": {"readonly": True}, + "info": {"readonly": True}, } _attribute_map = { - 'type': {'key': 'type', 'type': 'str'}, - 'info': {'key': 'info', 'type': 'object'}, + "type": {"key": "type", "type": "str"}, + "info": {"key": "info", "type": "object"}, } - def __init__( - self, - **kwargs - ): - """ - """ - super(ErrorAdditionalInfo, self).__init__(**kwargs) + def __init__(self, **kwargs): + """ """ + super().__init__(**kwargs) self.type = None self.info = None -class ErrorResponse(msrest.serialization.Model): +class ErrorResponse(_serialization.Model): """Common error response for all Azure Resource Manager APIs to return error details for failed operations. (This also follows the OData error response format.). Variables are only populated by the server, and will be ignored when sending a request. @@ -856,28 +805,24 @@ class ErrorResponse(msrest.serialization.Model): """ _validation = { - 'code': {'readonly': True}, - 'message': {'readonly': True}, - 'target': {'readonly': True}, - 'details': {'readonly': True}, - 'additional_info': {'readonly': True}, + "code": {"readonly": True}, + "message": {"readonly": True}, + "target": {"readonly": True}, + "details": {"readonly": True}, + "additional_info": {"readonly": True}, } _attribute_map = { - 'code': {'key': 'code', 'type': 'str'}, - 'message': {'key': 'message', 'type': 'str'}, - 'target': {'key': 'target', 'type': 'str'}, - 'details': {'key': 'details', 'type': '[ErrorResponse]'}, - 'additional_info': {'key': 'additionalInfo', 'type': '[ErrorAdditionalInfo]'}, + "code": {"key": "code", "type": "str"}, + "message": {"key": "message", "type": "str"}, + "target": {"key": "target", "type": "str"}, + "details": {"key": "details", "type": "[ErrorResponse]"}, + "additional_info": {"key": "additionalInfo", "type": "[ErrorAdditionalInfo]"}, } - def __init__( - self, - **kwargs - ): - """ - """ - super(ErrorResponse, self).__init__(**kwargs) + def __init__(self, **kwargs): + """ """ + super().__init__(**kwargs) self.code = None self.message = None self.target = None @@ -885,7 +830,7 @@ def __init__( self.additional_info = None -class ExportTemplateRequest(msrest.serialization.Model): +class ExportTemplateRequest(_serialization.Model): """Export resource group template request parameters. :ivar resources: The IDs of the resources to filter the export by. To export all resources, @@ -898,17 +843,11 @@ class ExportTemplateRequest(msrest.serialization.Model): """ _attribute_map = { - 'resources': {'key': 'resources', 'type': '[str]'}, - 'options': {'key': 'options', 'type': 'str'}, + "resources": {"key": "resources", "type": "[str]"}, + "options": {"key": "options", "type": "str"}, } - def __init__( - self, - *, - resources: Optional[List[str]] = None, - options: Optional[str] = None, - **kwargs - ): + def __init__(self, *, resources: Optional[List[str]] = None, options: Optional[str] = None, **kwargs): """ :keyword resources: The IDs of the resources to filter the export by. To export all resources, supply an array with single entry '*'. @@ -918,12 +857,12 @@ def __init__( 'SkipResourceNameParameterization', 'SkipAllParameterization'. :paramtype options: str """ - super(ExportTemplateRequest, self).__init__(**kwargs) + super().__init__(**kwargs) self.resources = resources self.options = options -class Resource(msrest.serialization.Model): +class Resource(_serialization.Model): """Specified resource. Variables are only populated by the server, and will be ignored when sending a request. @@ -936,38 +875,32 @@ class Resource(msrest.serialization.Model): :vartype type: str :ivar location: Resource location. :vartype location: str - :ivar tags: A set of tags. Resource tags. + :ivar tags: Resource tags. :vartype tags: dict[str, str] """ _validation = { - 'id': {'readonly': True}, - 'name': {'readonly': True}, - 'type': {'readonly': True}, + "id": {"readonly": True}, + "name": {"readonly": True}, + "type": {"readonly": True}, } _attribute_map = { - 'id': {'key': 'id', 'type': 'str'}, - 'name': {'key': 'name', 'type': 'str'}, - 'type': {'key': 'type', 'type': 'str'}, - 'location': {'key': 'location', 'type': 'str'}, - 'tags': {'key': 'tags', 'type': '{str}'}, + "id": {"key": "id", "type": "str"}, + "name": {"key": "name", "type": "str"}, + "type": {"key": "type", "type": "str"}, + "location": {"key": "location", "type": "str"}, + "tags": {"key": "tags", "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): """ :keyword location: Resource location. :paramtype location: str - :keyword tags: A set of tags. Resource tags. + :keyword tags: Resource tags. :paramtype tags: dict[str, str] """ - super(Resource, self).__init__(**kwargs) + super().__init__(**kwargs) self.id = None self.name = None self.type = None @@ -975,7 +908,7 @@ def __init__( self.tags = tags -class GenericResource(Resource): +class GenericResource(Resource): # pylint: disable=too-many-instance-attributes """Resource information. Variables are only populated by the server, and will be ignored when sending a request. @@ -988,12 +921,12 @@ class GenericResource(Resource): :vartype type: str :ivar location: Resource location. :vartype location: str - :ivar tags: A set of tags. Resource tags. + :ivar tags: Resource tags. :vartype tags: dict[str, str] :ivar plan: The plan of the resource. :vartype plan: ~azure.mgmt.resource.resources.v2018_05_01.models.Plan :ivar properties: The resource properties. - :vartype properties: any + :vartype properties: JSON :ivar kind: The kind of the resource. :vartype kind: str :ivar managed_by: ID of the resource that manages this resource. @@ -1005,24 +938,24 @@ class GenericResource(Resource): """ _validation = { - 'id': {'readonly': True}, - 'name': {'readonly': True}, - 'type': {'readonly': True}, - 'kind': {'pattern': r'^[-\w\._,\(\)]+$'}, + "id": {"readonly": True}, + "name": {"readonly": True}, + "type": {"readonly": True}, + "kind": {"pattern": r"^[-\w\._,\(\)]+$"}, } _attribute_map = { - 'id': {'key': 'id', 'type': 'str'}, - 'name': {'key': 'name', 'type': 'str'}, - 'type': {'key': 'type', 'type': 'str'}, - 'location': {'key': 'location', 'type': 'str'}, - 'tags': {'key': 'tags', 'type': '{str}'}, - 'plan': {'key': 'plan', 'type': 'Plan'}, - 'properties': {'key': 'properties', 'type': 'object'}, - 'kind': {'key': 'kind', 'type': 'str'}, - 'managed_by': {'key': 'managedBy', 'type': 'str'}, - 'sku': {'key': 'sku', 'type': 'Sku'}, - 'identity': {'key': 'identity', 'type': 'Identity'}, + "id": {"key": "id", "type": "str"}, + "name": {"key": "name", "type": "str"}, + "type": {"key": "type", "type": "str"}, + "location": {"key": "location", "type": "str"}, + "tags": {"key": "tags", "type": "{str}"}, + "plan": {"key": "plan", "type": "Plan"}, + "properties": {"key": "properties", "type": "object"}, + "kind": {"key": "kind", "type": "str"}, + "managed_by": {"key": "managedBy", "type": "str"}, + "sku": {"key": "sku", "type": "Sku"}, + "identity": {"key": "identity", "type": "Identity"}, } def __init__( @@ -1030,23 +963,23 @@ def __init__( *, location: Optional[str] = None, tags: Optional[Dict[str, str]] = None, - plan: Optional["Plan"] = None, - properties: Optional[Any] = None, + plan: Optional["_models.Plan"] = None, + properties: Optional[JSON] = None, kind: Optional[str] = None, managed_by: Optional[str] = None, - sku: Optional["Sku"] = None, - identity: Optional["Identity"] = None, + sku: Optional["_models.Sku"] = None, + identity: Optional["_models.Identity"] = None, **kwargs ): """ :keyword location: Resource location. :paramtype location: str - :keyword tags: A set of tags. Resource tags. + :keyword tags: Resource tags. :paramtype tags: dict[str, str] :keyword plan: The plan of the resource. :paramtype plan: ~azure.mgmt.resource.resources.v2018_05_01.models.Plan :keyword properties: The resource properties. - :paramtype properties: any + :paramtype properties: JSON :keyword kind: The kind of the resource. :paramtype kind: str :keyword managed_by: ID of the resource that manages this resource. @@ -1056,7 +989,7 @@ def __init__( :keyword identity: The identity of the resource. :paramtype identity: ~azure.mgmt.resource.resources.v2018_05_01.models.Identity """ - super(GenericResource, self).__init__(location=location, tags=tags, **kwargs) + super().__init__(location=location, tags=tags, **kwargs) self.plan = plan self.properties = properties self.kind = kind @@ -1065,7 +998,7 @@ def __init__( self.identity = identity -class GenericResourceExpanded(GenericResource): +class GenericResourceExpanded(GenericResource): # pylint: disable=too-many-instance-attributes """Resource information. Variables are only populated by the server, and will be ignored when sending a request. @@ -1078,12 +1011,12 @@ class GenericResourceExpanded(GenericResource): :vartype type: str :ivar location: Resource location. :vartype location: str - :ivar tags: A set of tags. Resource tags. + :ivar tags: Resource tags. :vartype tags: dict[str, str] :ivar plan: The plan of the resource. :vartype plan: ~azure.mgmt.resource.resources.v2018_05_01.models.Plan :ivar properties: The resource properties. - :vartype properties: any + :vartype properties: JSON :ivar kind: The kind of the resource. :vartype kind: str :ivar managed_by: ID of the resource that manages this resource. @@ -1104,30 +1037,30 @@ class GenericResourceExpanded(GenericResource): """ _validation = { - 'id': {'readonly': True}, - 'name': {'readonly': True}, - 'type': {'readonly': True}, - 'kind': {'pattern': r'^[-\w\._,\(\)]+$'}, - 'created_time': {'readonly': True}, - 'changed_time': {'readonly': True}, - 'provisioning_state': {'readonly': True}, + "id": {"readonly": True}, + "name": {"readonly": True}, + "type": {"readonly": True}, + "kind": {"pattern": r"^[-\w\._,\(\)]+$"}, + "created_time": {"readonly": True}, + "changed_time": {"readonly": True}, + "provisioning_state": {"readonly": True}, } _attribute_map = { - 'id': {'key': 'id', 'type': 'str'}, - 'name': {'key': 'name', 'type': 'str'}, - 'type': {'key': 'type', 'type': 'str'}, - 'location': {'key': 'location', 'type': 'str'}, - 'tags': {'key': 'tags', 'type': '{str}'}, - 'plan': {'key': 'plan', 'type': 'Plan'}, - 'properties': {'key': 'properties', 'type': 'object'}, - 'kind': {'key': 'kind', 'type': 'str'}, - 'managed_by': {'key': 'managedBy', 'type': 'str'}, - 'sku': {'key': 'sku', 'type': 'Sku'}, - 'identity': {'key': 'identity', 'type': 'Identity'}, - 'created_time': {'key': 'createdTime', 'type': 'iso-8601'}, - 'changed_time': {'key': 'changedTime', 'type': 'iso-8601'}, - 'provisioning_state': {'key': 'provisioningState', 'type': 'str'}, + "id": {"key": "id", "type": "str"}, + "name": {"key": "name", "type": "str"}, + "type": {"key": "type", "type": "str"}, + "location": {"key": "location", "type": "str"}, + "tags": {"key": "tags", "type": "{str}"}, + "plan": {"key": "plan", "type": "Plan"}, + "properties": {"key": "properties", "type": "object"}, + "kind": {"key": "kind", "type": "str"}, + "managed_by": {"key": "managedBy", "type": "str"}, + "sku": {"key": "sku", "type": "Sku"}, + "identity": {"key": "identity", "type": "Identity"}, + "created_time": {"key": "createdTime", "type": "iso-8601"}, + "changed_time": {"key": "changedTime", "type": "iso-8601"}, + "provisioning_state": {"key": "provisioningState", "type": "str"}, } def __init__( @@ -1135,23 +1068,23 @@ def __init__( *, location: Optional[str] = None, tags: Optional[Dict[str, str]] = None, - plan: Optional["Plan"] = None, - properties: Optional[Any] = None, + plan: Optional["_models.Plan"] = None, + properties: Optional[JSON] = None, kind: Optional[str] = None, managed_by: Optional[str] = None, - sku: Optional["Sku"] = None, - identity: Optional["Identity"] = None, + sku: Optional["_models.Sku"] = None, + identity: Optional["_models.Identity"] = None, **kwargs ): """ :keyword location: Resource location. :paramtype location: str - :keyword tags: A set of tags. Resource tags. + :keyword tags: Resource tags. :paramtype tags: dict[str, str] :keyword plan: The plan of the resource. :paramtype plan: ~azure.mgmt.resource.resources.v2018_05_01.models.Plan :keyword properties: The resource properties. - :paramtype properties: any + :paramtype properties: JSON :keyword kind: The kind of the resource. :paramtype kind: str :keyword managed_by: ID of the resource that manages this resource. @@ -1161,13 +1094,23 @@ def __init__( :keyword identity: The identity of the resource. :paramtype identity: ~azure.mgmt.resource.resources.v2018_05_01.models.Identity """ - super(GenericResourceExpanded, self).__init__(location=location, tags=tags, plan=plan, properties=properties, kind=kind, managed_by=managed_by, sku=sku, identity=identity, **kwargs) + super().__init__( + location=location, + tags=tags, + plan=plan, + properties=properties, + kind=kind, + managed_by=managed_by, + sku=sku, + identity=identity, + **kwargs + ) self.created_time = None self.changed_time = None self.provisioning_state = None -class GenericResourceFilter(msrest.serialization.Model): +class GenericResourceFilter(_serialization.Model): """Resource filter. :ivar resource_type: The resource type. @@ -1179,9 +1122,9 @@ class GenericResourceFilter(msrest.serialization.Model): """ _attribute_map = { - 'resource_type': {'key': 'resourceType', 'type': 'str'}, - 'tagname': {'key': 'tagname', 'type': 'str'}, - 'tagvalue': {'key': 'tagvalue', 'type': 'str'}, + "resource_type": {"key": "resourceType", "type": "str"}, + "tagname": {"key": "tagname", "type": "str"}, + "tagvalue": {"key": "tagvalue", "type": "str"}, } def __init__( @@ -1200,38 +1143,33 @@ def __init__( :keyword tagvalue: The tag value. :paramtype tagvalue: str """ - super(GenericResourceFilter, self).__init__(**kwargs) + super().__init__(**kwargs) self.resource_type = resource_type self.tagname = tagname self.tagvalue = tagvalue -class HttpMessage(msrest.serialization.Model): +class HttpMessage(_serialization.Model): """HTTP message. :ivar content: HTTP message content. - :vartype content: any + :vartype content: JSON """ _attribute_map = { - 'content': {'key': 'content', 'type': 'object'}, + "content": {"key": "content", "type": "object"}, } - def __init__( - self, - *, - content: Optional[Any] = None, - **kwargs - ): + def __init__(self, *, content: Optional[JSON] = None, **kwargs): """ :keyword content: HTTP message content. - :paramtype content: any + :paramtype content: JSON """ - super(HttpMessage, self).__init__(**kwargs) + super().__init__(**kwargs) self.content = content -class Identity(msrest.serialization.Model): +class Identity(_serialization.Model): """Identity for the resource. Variables are only populated by the server, and will be ignored when sending a request. @@ -1240,8 +1178,8 @@ class Identity(msrest.serialization.Model): :vartype principal_id: str :ivar tenant_id: The tenant ID of resource. :vartype tenant_id: str - :ivar type: The identity type. Possible values include: "SystemAssigned", "UserAssigned", - "SystemAssigned, UserAssigned", "None". + :ivar type: The identity type. Known values are: "SystemAssigned", "UserAssigned", + "SystemAssigned, UserAssigned", and "None". :vartype type: str or ~azure.mgmt.resource.resources.v2018_05_01.models.ResourceIdentityType :ivar user_assigned_identities: The list of user identities associated with the resource. The user identity dictionary key references will be ARM resource ids in the form: @@ -1251,27 +1189,32 @@ class Identity(msrest.serialization.Model): """ _validation = { - 'principal_id': {'readonly': True}, - 'tenant_id': {'readonly': True}, + "principal_id": {"readonly": True}, + "tenant_id": {"readonly": True}, } _attribute_map = { - 'principal_id': {'key': 'principalId', 'type': 'str'}, - 'tenant_id': {'key': 'tenantId', 'type': 'str'}, - 'type': {'key': 'type', 'type': 'str'}, - 'user_assigned_identities': {'key': 'userAssignedIdentities', 'type': '{ComponentsSgqdofSchemasIdentityPropertiesUserassignedidentitiesAdditionalproperties}'}, + "principal_id": {"key": "principalId", "type": "str"}, + "tenant_id": {"key": "tenantId", "type": "str"}, + "type": {"key": "type", "type": "str"}, + "user_assigned_identities": { + "key": "userAssignedIdentities", + "type": "{ComponentsSgqdofSchemasIdentityPropertiesUserassignedidentitiesAdditionalproperties}", + }, } def __init__( self, *, - type: Optional[Union[str, "ResourceIdentityType"]] = None, - user_assigned_identities: Optional[Dict[str, "ComponentsSgqdofSchemasIdentityPropertiesUserassignedidentitiesAdditionalproperties"]] = None, + type: Optional[Union[str, "_models.ResourceIdentityType"]] = None, + user_assigned_identities: Optional[ + Dict[str, "_models.ComponentsSgqdofSchemasIdentityPropertiesUserassignedidentitiesAdditionalproperties"] + ] = None, **kwargs ): """ - :keyword type: The identity type. Possible values include: "SystemAssigned", "UserAssigned", - "SystemAssigned, UserAssigned", "None". + :keyword type: The identity type. Known values are: "SystemAssigned", "UserAssigned", + "SystemAssigned, UserAssigned", and "None". :paramtype type: str or ~azure.mgmt.resource.resources.v2018_05_01.models.ResourceIdentityType :keyword user_assigned_identities: The list of user identities associated with the resource. The user identity dictionary key references will be ARM resource ids in the form: @@ -1279,48 +1222,48 @@ def __init__( :paramtype user_assigned_identities: dict[str, ~azure.mgmt.resource.resources.v2018_05_01.models.ComponentsSgqdofSchemasIdentityPropertiesUserassignedidentitiesAdditionalproperties] """ - super(Identity, self).__init__(**kwargs) + super().__init__(**kwargs) self.principal_id = None self.tenant_id = None self.type = type self.user_assigned_identities = user_assigned_identities -class OnErrorDeployment(msrest.serialization.Model): +class OnErrorDeployment(_serialization.Model): """Deployment on error behavior. :ivar type: The deployment on error behavior type. Possible values are LastSuccessful and - SpecificDeployment. Possible values include: "LastSuccessful", "SpecificDeployment". + SpecificDeployment. Known values are: "LastSuccessful" and "SpecificDeployment". :vartype type: str or ~azure.mgmt.resource.resources.v2018_05_01.models.OnErrorDeploymentType :ivar deployment_name: The deployment to be used on error case. :vartype deployment_name: str """ _attribute_map = { - 'type': {'key': 'type', 'type': 'str'}, - 'deployment_name': {'key': 'deploymentName', 'type': 'str'}, + "type": {"key": "type", "type": "str"}, + "deployment_name": {"key": "deploymentName", "type": "str"}, } def __init__( self, *, - type: Optional[Union[str, "OnErrorDeploymentType"]] = None, + type: Optional[Union[str, "_models.OnErrorDeploymentType"]] = None, deployment_name: Optional[str] = None, **kwargs ): """ :keyword type: The deployment on error behavior type. Possible values are LastSuccessful and - SpecificDeployment. Possible values include: "LastSuccessful", "SpecificDeployment". + SpecificDeployment. Known values are: "LastSuccessful" and "SpecificDeployment". :paramtype type: str or ~azure.mgmt.resource.resources.v2018_05_01.models.OnErrorDeploymentType :keyword deployment_name: The deployment to be used on error case. :paramtype deployment_name: str """ - super(OnErrorDeployment, self).__init__(**kwargs) + super().__init__(**kwargs) self.type = type self.deployment_name = deployment_name -class OnErrorDeploymentExtended(msrest.serialization.Model): +class OnErrorDeploymentExtended(_serialization.Model): """Deployment on error behavior with additional details. Variables are only populated by the server, and will be ignored when sending a request. @@ -1328,43 +1271,43 @@ class OnErrorDeploymentExtended(msrest.serialization.Model): :ivar provisioning_state: The state of the provisioning for the on error deployment. :vartype provisioning_state: str :ivar type: The deployment on error behavior type. Possible values are LastSuccessful and - SpecificDeployment. Possible values include: "LastSuccessful", "SpecificDeployment". + SpecificDeployment. Known values are: "LastSuccessful" and "SpecificDeployment". :vartype type: str or ~azure.mgmt.resource.resources.v2018_05_01.models.OnErrorDeploymentType :ivar deployment_name: The deployment to be used on error case. :vartype deployment_name: str """ _validation = { - 'provisioning_state': {'readonly': True}, + "provisioning_state": {"readonly": True}, } _attribute_map = { - 'provisioning_state': {'key': 'provisioningState', 'type': 'str'}, - 'type': {'key': 'type', 'type': 'str'}, - 'deployment_name': {'key': 'deploymentName', 'type': 'str'}, + "provisioning_state": {"key": "provisioningState", "type": "str"}, + "type": {"key": "type", "type": "str"}, + "deployment_name": {"key": "deploymentName", "type": "str"}, } def __init__( self, *, - type: Optional[Union[str, "OnErrorDeploymentType"]] = None, + type: Optional[Union[str, "_models.OnErrorDeploymentType"]] = None, deployment_name: Optional[str] = None, **kwargs ): """ :keyword type: The deployment on error behavior type. Possible values are LastSuccessful and - SpecificDeployment. Possible values include: "LastSuccessful", "SpecificDeployment". + SpecificDeployment. Known values are: "LastSuccessful" and "SpecificDeployment". :paramtype type: str or ~azure.mgmt.resource.resources.v2018_05_01.models.OnErrorDeploymentType :keyword deployment_name: The deployment to be used on error case. :paramtype deployment_name: str """ - super(OnErrorDeploymentExtended, self).__init__(**kwargs) + super().__init__(**kwargs) self.provisioning_state = None self.type = type self.deployment_name = deployment_name -class Operation(msrest.serialization.Model): +class Operation(_serialization.Model): """Microsoft.Resources operation. :ivar name: Operation name: {provider}/{resource}/{operation}. @@ -1374,29 +1317,23 @@ class Operation(msrest.serialization.Model): """ _attribute_map = { - 'name': {'key': 'name', 'type': 'str'}, - 'display': {'key': 'display', 'type': 'OperationDisplay'}, + "name": {"key": "name", "type": "str"}, + "display": {"key": "display", "type": "OperationDisplay"}, } - def __init__( - self, - *, - name: Optional[str] = None, - display: Optional["OperationDisplay"] = None, - **kwargs - ): + def __init__(self, *, name: Optional[str] = None, display: Optional["_models.OperationDisplay"] = None, **kwargs): """ :keyword name: Operation name: {provider}/{resource}/{operation}. :paramtype name: str :keyword display: The object that represents the operation. :paramtype display: ~azure.mgmt.resource.resources.v2018_05_01.models.OperationDisplay """ - super(Operation, self).__init__(**kwargs) + super().__init__(**kwargs) self.name = name self.display = display -class OperationDisplay(msrest.serialization.Model): +class OperationDisplay(_serialization.Model): """The object that represents the operation. :ivar provider: Service provider: Microsoft.Resources. @@ -1410,10 +1347,10 @@ class OperationDisplay(msrest.serialization.Model): """ _attribute_map = { - 'provider': {'key': 'provider', 'type': 'str'}, - 'resource': {'key': 'resource', 'type': 'str'}, - 'operation': {'key': 'operation', 'type': 'str'}, - 'description': {'key': 'description', 'type': 'str'}, + "provider": {"key": "provider", "type": "str"}, + "resource": {"key": "resource", "type": "str"}, + "operation": {"key": "operation", "type": "str"}, + "description": {"key": "description", "type": "str"}, } def __init__( @@ -1435,14 +1372,14 @@ def __init__( :keyword description: Description of the operation. :paramtype description: str """ - super(OperationDisplay, self).__init__(**kwargs) + super().__init__(**kwargs) self.provider = provider self.resource = resource self.operation = operation self.description = description -class OperationListResult(msrest.serialization.Model): +class OperationListResult(_serialization.Model): """Result of the request to list Microsoft.Resources operations. It contains a list of operations and a URL link to get the next set of results. :ivar value: List of Microsoft.Resources operations. @@ -1452,67 +1389,55 @@ class OperationListResult(msrest.serialization.Model): """ _attribute_map = { - 'value': {'key': 'value', 'type': '[Operation]'}, - 'next_link': {'key': 'nextLink', 'type': 'str'}, + "value": {"key": "value", "type": "[Operation]"}, + "next_link": {"key": "nextLink", "type": "str"}, } - def __init__( - self, - *, - value: Optional[List["Operation"]] = None, - next_link: Optional[str] = None, - **kwargs - ): + def __init__(self, *, value: Optional[List["_models.Operation"]] = None, next_link: Optional[str] = None, **kwargs): """ :keyword value: List of Microsoft.Resources operations. :paramtype value: list[~azure.mgmt.resource.resources.v2018_05_01.models.Operation] :keyword next_link: URL to get the next set of operation list results if there are any. :paramtype next_link: str """ - super(OperationListResult, self).__init__(**kwargs) + super().__init__(**kwargs) self.value = value self.next_link = next_link -class ParametersLink(msrest.serialization.Model): +class ParametersLink(_serialization.Model): """Entity representing the reference to the deployment parameters. All required parameters must be populated in order to send to Azure. - :ivar uri: Required. The URI of the parameters file. + :ivar uri: The URI of the parameters file. Required. :vartype uri: str :ivar content_version: If included, must match the ContentVersion in the template. :vartype content_version: str """ _validation = { - 'uri': {'required': True}, + "uri": {"required": True}, } _attribute_map = { - 'uri': {'key': 'uri', 'type': 'str'}, - 'content_version': {'key': 'contentVersion', 'type': 'str'}, + "uri": {"key": "uri", "type": "str"}, + "content_version": {"key": "contentVersion", "type": "str"}, } - def __init__( - self, - *, - uri: str, - content_version: Optional[str] = None, - **kwargs - ): + def __init__(self, *, uri: str, content_version: Optional[str] = None, **kwargs): """ - :keyword uri: Required. The URI of the parameters file. + :keyword uri: The URI of the parameters file. Required. :paramtype uri: str :keyword content_version: If included, must match the ContentVersion in the template. :paramtype content_version: str """ - super(ParametersLink, self).__init__(**kwargs) + super().__init__(**kwargs) self.uri = uri self.content_version = content_version -class Plan(msrest.serialization.Model): +class Plan(_serialization.Model): """Plan for the resource. :ivar name: The plan ID. @@ -1528,11 +1453,11 @@ class Plan(msrest.serialization.Model): """ _attribute_map = { - 'name': {'key': 'name', 'type': 'str'}, - 'publisher': {'key': 'publisher', 'type': 'str'}, - 'product': {'key': 'product', 'type': 'str'}, - 'promotion_code': {'key': 'promotionCode', 'type': 'str'}, - 'version': {'key': 'version', 'type': 'str'}, + "name": {"key": "name", "type": "str"}, + "publisher": {"key": "publisher", "type": "str"}, + "product": {"key": "product", "type": "str"}, + "promotion_code": {"key": "promotionCode", "type": "str"}, + "version": {"key": "version", "type": "str"}, } def __init__( @@ -1557,7 +1482,7 @@ def __init__( :keyword version: The plan's version. :paramtype version: str """ - super(Plan, self).__init__(**kwargs) + super().__init__(**kwargs) self.name = name self.publisher = publisher self.product = product @@ -1565,7 +1490,7 @@ def __init__( self.version = version -class Provider(msrest.serialization.Model): +class Provider(_serialization.Model): """Resource provider information. Variables are only populated by the server, and will be ignored when sending a request. @@ -1582,36 +1507,31 @@ class Provider(msrest.serialization.Model): """ _validation = { - 'id': {'readonly': True}, - 'registration_state': {'readonly': True}, - 'resource_types': {'readonly': True}, + "id": {"readonly": True}, + "registration_state": {"readonly": True}, + "resource_types": {"readonly": True}, } _attribute_map = { - 'id': {'key': 'id', 'type': 'str'}, - 'namespace': {'key': 'namespace', 'type': 'str'}, - 'registration_state': {'key': 'registrationState', 'type': 'str'}, - 'resource_types': {'key': 'resourceTypes', 'type': '[ProviderResourceType]'}, + "id": {"key": "id", "type": "str"}, + "namespace": {"key": "namespace", "type": "str"}, + "registration_state": {"key": "registrationState", "type": "str"}, + "resource_types": {"key": "resourceTypes", "type": "[ProviderResourceType]"}, } - def __init__( - self, - *, - namespace: Optional[str] = None, - **kwargs - ): + def __init__(self, *, namespace: Optional[str] = None, **kwargs): """ :keyword namespace: The namespace of the resource provider. :paramtype namespace: str """ - super(Provider, self).__init__(**kwargs) + super().__init__(**kwargs) self.id = None self.namespace = namespace self.registration_state = None self.resource_types = None -class ProviderListResult(msrest.serialization.Model): +class ProviderListResult(_serialization.Model): """List of resource providers. Variables are only populated by the server, and will be ignored when sending a request. @@ -1623,30 +1543,25 @@ class ProviderListResult(msrest.serialization.Model): """ _validation = { - 'next_link': {'readonly': True}, + "next_link": {"readonly": True}, } _attribute_map = { - 'value': {'key': 'value', 'type': '[Provider]'}, - 'next_link': {'key': 'nextLink', 'type': 'str'}, + "value": {"key": "value", "type": "[Provider]"}, + "next_link": {"key": "nextLink", "type": "str"}, } - def __init__( - self, - *, - value: Optional[List["Provider"]] = None, - **kwargs - ): + def __init__(self, *, value: Optional[List["_models.Provider"]] = None, **kwargs): """ :keyword value: An array of resource providers. :paramtype value: list[~azure.mgmt.resource.resources.v2018_05_01.models.Provider] """ - super(ProviderListResult, self).__init__(**kwargs) + super().__init__(**kwargs) self.value = value self.next_link = None -class ProviderResourceType(msrest.serialization.Model): +class ProviderResourceType(_serialization.Model): """Resource type managed by the resource provider. :ivar resource_type: The resource type. @@ -1664,12 +1579,12 @@ class ProviderResourceType(msrest.serialization.Model): """ _attribute_map = { - 'resource_type': {'key': 'resourceType', 'type': 'str'}, - 'locations': {'key': 'locations', 'type': '[str]'}, - 'aliases': {'key': 'aliases', 'type': '[AliasType]'}, - 'api_versions': {'key': 'apiVersions', 'type': '[str]'}, - 'zone_mappings': {'key': 'zoneMappings', 'type': '[ZoneMapping]'}, - 'properties': {'key': 'properties', 'type': '{str}'}, + "resource_type": {"key": "resourceType", "type": "str"}, + "locations": {"key": "locations", "type": "[str]"}, + "aliases": {"key": "aliases", "type": "[AliasType]"}, + "api_versions": {"key": "apiVersions", "type": "[str]"}, + "zone_mappings": {"key": "zoneMappings", "type": "[ZoneMapping]"}, + "properties": {"key": "properties", "type": "{str}"}, } def __init__( @@ -1677,9 +1592,9 @@ def __init__( *, resource_type: Optional[str] = None, locations: Optional[List[str]] = None, - aliases: Optional[List["AliasType"]] = None, + aliases: Optional[List["_models.AliasType"]] = None, api_versions: Optional[List[str]] = None, - zone_mappings: Optional[List["ZoneMapping"]] = None, + zone_mappings: Optional[List["_models.ZoneMapping"]] = None, properties: Optional[Dict[str, str]] = None, **kwargs ): @@ -1697,7 +1612,7 @@ def __init__( :keyword properties: The properties. :paramtype properties: dict[str, str] """ - super(ProviderResourceType, self).__init__(**kwargs) + super().__init__(**kwargs) self.resource_type = resource_type self.locations = locations self.aliases = aliases @@ -1706,7 +1621,7 @@ def __init__( self.properties = properties -class ResourceGroup(msrest.serialization.Model): +class ResourceGroup(_serialization.Model): """Resource group information. Variables are only populated by the server, and will be ignored when sending a request. @@ -1721,37 +1636,37 @@ class ResourceGroup(msrest.serialization.Model): :vartype type: str :ivar properties: The resource group properties. :vartype properties: ~azure.mgmt.resource.resources.v2018_05_01.models.ResourceGroupProperties - :ivar location: Required. The location of the resource group. It cannot be changed after the - resource group has been created. It must be one of the supported Azure locations. + :ivar location: The location of the resource group. It cannot be changed after the resource + group has been created. It must be one of the supported Azure locations. Required. :vartype location: str :ivar managed_by: The ID of the resource that manages this resource group. :vartype managed_by: str - :ivar tags: A set of tags. The tags attached to the resource group. + :ivar tags: The tags attached to the resource group. :vartype tags: dict[str, str] """ _validation = { - 'id': {'readonly': True}, - 'name': {'readonly': True}, - 'type': {'readonly': True}, - 'location': {'required': True}, + "id": {"readonly": True}, + "name": {"readonly": True}, + "type": {"readonly": True}, + "location": {"required": True}, } _attribute_map = { - 'id': {'key': 'id', 'type': 'str'}, - 'name': {'key': 'name', 'type': 'str'}, - 'type': {'key': 'type', 'type': 'str'}, - 'properties': {'key': 'properties', 'type': 'ResourceGroupProperties'}, - 'location': {'key': 'location', 'type': 'str'}, - 'managed_by': {'key': 'managedBy', 'type': 'str'}, - 'tags': {'key': 'tags', 'type': '{str}'}, + "id": {"key": "id", "type": "str"}, + "name": {"key": "name", "type": "str"}, + "type": {"key": "type", "type": "str"}, + "properties": {"key": "properties", "type": "ResourceGroupProperties"}, + "location": {"key": "location", "type": "str"}, + "managed_by": {"key": "managedBy", "type": "str"}, + "tags": {"key": "tags", "type": "{str}"}, } def __init__( self, *, location: str, - properties: Optional["ResourceGroupProperties"] = None, + properties: Optional["_models.ResourceGroupProperties"] = None, managed_by: Optional[str] = None, tags: Optional[Dict[str, str]] = None, **kwargs @@ -1760,15 +1675,15 @@ def __init__( :keyword properties: The resource group properties. :paramtype properties: ~azure.mgmt.resource.resources.v2018_05_01.models.ResourceGroupProperties - :keyword location: Required. The location of the resource group. It cannot be changed after the - resource group has been created. It must be one of the supported Azure locations. + :keyword location: The location of the resource group. It cannot be changed after the resource + group has been created. It must be one of the supported Azure locations. Required. :paramtype location: str :keyword managed_by: The ID of the resource that manages this resource group. :paramtype managed_by: str - :keyword tags: A set of tags. The tags attached to the resource group. + :keyword tags: The tags attached to the resource group. :paramtype tags: dict[str, str] """ - super(ResourceGroup, self).__init__(**kwargs) + super().__init__(**kwargs) self.id = None self.name = None self.type = None @@ -1778,41 +1693,41 @@ def __init__( self.tags = tags -class ResourceGroupExportResult(msrest.serialization.Model): +class ResourceGroupExportResult(_serialization.Model): """Resource group export result. :ivar template: The template content. - :vartype template: any + :vartype template: JSON :ivar error: The error. :vartype error: ~azure.mgmt.resource.resources.v2018_05_01.models.ResourceManagementErrorWithDetails """ _attribute_map = { - 'template': {'key': 'template', 'type': 'object'}, - 'error': {'key': 'error', 'type': 'ResourceManagementErrorWithDetails'}, + "template": {"key": "template", "type": "object"}, + "error": {"key": "error", "type": "ResourceManagementErrorWithDetails"}, } def __init__( self, *, - template: Optional[Any] = None, - error: Optional["ResourceManagementErrorWithDetails"] = None, + template: Optional[JSON] = None, + error: Optional["_models.ResourceManagementErrorWithDetails"] = None, **kwargs ): """ :keyword template: The template content. - :paramtype template: any + :paramtype template: JSON :keyword error: The error. :paramtype error: ~azure.mgmt.resource.resources.v2018_05_01.models.ResourceManagementErrorWithDetails """ - super(ResourceGroupExportResult, self).__init__(**kwargs) + super().__init__(**kwargs) self.template = template self.error = error -class ResourceGroupFilter(msrest.serialization.Model): +class ResourceGroupFilter(_serialization.Model): """Resource group filter. :ivar tag_name: The tag name. @@ -1822,29 +1737,23 @@ class ResourceGroupFilter(msrest.serialization.Model): """ _attribute_map = { - 'tag_name': {'key': 'tagName', 'type': 'str'}, - 'tag_value': {'key': 'tagValue', 'type': 'str'}, + "tag_name": {"key": "tagName", "type": "str"}, + "tag_value": {"key": "tagValue", "type": "str"}, } - def __init__( - self, - *, - tag_name: Optional[str] = None, - tag_value: Optional[str] = None, - **kwargs - ): + def __init__(self, *, tag_name: Optional[str] = None, tag_value: Optional[str] = None, **kwargs): """ :keyword tag_name: The tag name. :paramtype tag_name: str :keyword tag_value: The tag value. :paramtype tag_value: str """ - super(ResourceGroupFilter, self).__init__(**kwargs) + super().__init__(**kwargs) self.tag_name = tag_name self.tag_value = tag_value -class ResourceGroupListResult(msrest.serialization.Model): +class ResourceGroupListResult(_serialization.Model): """List of resource groups. Variables are only populated by the server, and will be ignored when sending a request. @@ -1856,30 +1765,25 @@ class ResourceGroupListResult(msrest.serialization.Model): """ _validation = { - 'next_link': {'readonly': True}, + "next_link": {"readonly": True}, } _attribute_map = { - 'value': {'key': 'value', 'type': '[ResourceGroup]'}, - 'next_link': {'key': 'nextLink', 'type': 'str'}, + "value": {"key": "value", "type": "[ResourceGroup]"}, + "next_link": {"key": "nextLink", "type": "str"}, } - def __init__( - self, - *, - value: Optional[List["ResourceGroup"]] = None, - **kwargs - ): + def __init__(self, *, value: Optional[List["_models.ResourceGroup"]] = None, **kwargs): """ :keyword value: An array of resource groups. :paramtype value: list[~azure.mgmt.resource.resources.v2018_05_01.models.ResourceGroup] """ - super(ResourceGroupListResult, self).__init__(**kwargs) + super().__init__(**kwargs) self.value = value self.next_link = None -class ResourceGroupPatchable(msrest.serialization.Model): +class ResourceGroupPatchable(_serialization.Model): """Resource group information. :ivar name: The name of the resource group. @@ -1888,22 +1792,22 @@ class ResourceGroupPatchable(msrest.serialization.Model): :vartype properties: ~azure.mgmt.resource.resources.v2018_05_01.models.ResourceGroupProperties :ivar managed_by: The ID of the resource that manages this resource group. :vartype managed_by: str - :ivar tags: A set of tags. The tags attached to the resource group. + :ivar tags: The tags attached to the resource group. :vartype tags: dict[str, str] """ _attribute_map = { - 'name': {'key': 'name', 'type': 'str'}, - 'properties': {'key': 'properties', 'type': 'ResourceGroupProperties'}, - 'managed_by': {'key': 'managedBy', 'type': 'str'}, - 'tags': {'key': 'tags', 'type': '{str}'}, + "name": {"key": "name", "type": "str"}, + "properties": {"key": "properties", "type": "ResourceGroupProperties"}, + "managed_by": {"key": "managedBy", "type": "str"}, + "tags": {"key": "tags", "type": "{str}"}, } def __init__( self, *, name: Optional[str] = None, - properties: Optional["ResourceGroupProperties"] = None, + properties: Optional["_models.ResourceGroupProperties"] = None, managed_by: Optional[str] = None, tags: Optional[Dict[str, str]] = None, **kwargs @@ -1916,17 +1820,17 @@ def __init__( ~azure.mgmt.resource.resources.v2018_05_01.models.ResourceGroupProperties :keyword managed_by: The ID of the resource that manages this resource group. :paramtype managed_by: str - :keyword tags: A set of tags. The tags attached to the resource group. + :keyword tags: The tags attached to the resource group. :paramtype tags: dict[str, str] """ - super(ResourceGroupPatchable, self).__init__(**kwargs) + super().__init__(**kwargs) self.name = name self.properties = properties self.managed_by = managed_by self.tags = tags -class ResourceGroupProperties(msrest.serialization.Model): +class ResourceGroupProperties(_serialization.Model): """The resource group properties. Variables are only populated by the server, and will be ignored when sending a request. @@ -1936,24 +1840,20 @@ class ResourceGroupProperties(msrest.serialization.Model): """ _validation = { - 'provisioning_state': {'readonly': True}, + "provisioning_state": {"readonly": True}, } _attribute_map = { - 'provisioning_state': {'key': 'provisioningState', 'type': 'str'}, + "provisioning_state": {"key": "provisioningState", "type": "str"}, } - def __init__( - self, - **kwargs - ): - """ - """ - super(ResourceGroupProperties, self).__init__(**kwargs) + def __init__(self, **kwargs): + """ """ + super().__init__(**kwargs) self.provisioning_state = None -class ResourceListResult(msrest.serialization.Model): +class ResourceListResult(_serialization.Model): """List of resource groups. Variables are only populated by the server, and will be ignored when sending a request. @@ -1965,31 +1865,26 @@ class ResourceListResult(msrest.serialization.Model): """ _validation = { - 'next_link': {'readonly': True}, + "next_link": {"readonly": True}, } _attribute_map = { - 'value': {'key': 'value', 'type': '[GenericResourceExpanded]'}, - 'next_link': {'key': 'nextLink', 'type': 'str'}, + "value": {"key": "value", "type": "[GenericResourceExpanded]"}, + "next_link": {"key": "nextLink", "type": "str"}, } - def __init__( - self, - *, - value: Optional[List["GenericResourceExpanded"]] = None, - **kwargs - ): + def __init__(self, *, value: Optional[List["_models.GenericResourceExpanded"]] = None, **kwargs): """ :keyword value: An array of resources. :paramtype value: list[~azure.mgmt.resource.resources.v2018_05_01.models.GenericResourceExpanded] """ - super(ResourceListResult, self).__init__(**kwargs) + super().__init__(**kwargs) self.value = value self.next_link = None -class ResourceManagementErrorWithDetails(msrest.serialization.Model): +class ResourceManagementErrorWithDetails(_serialization.Model): """The detailed error message of resource management. Variables are only populated by the server, and will be ignored when sending a request. @@ -2006,33 +1901,29 @@ class ResourceManagementErrorWithDetails(msrest.serialization.Model): """ _validation = { - 'code': {'readonly': True}, - 'message': {'readonly': True}, - 'target': {'readonly': True}, - 'details': {'readonly': True}, + "code": {"readonly": True}, + "message": {"readonly": True}, + "target": {"readonly": True}, + "details": {"readonly": True}, } _attribute_map = { - 'code': {'key': 'code', 'type': 'str'}, - 'message': {'key': 'message', 'type': 'str'}, - 'target': {'key': 'target', 'type': 'str'}, - 'details': {'key': 'details', 'type': '[ResourceManagementErrorWithDetails]'}, + "code": {"key": "code", "type": "str"}, + "message": {"key": "message", "type": "str"}, + "target": {"key": "target", "type": "str"}, + "details": {"key": "details", "type": "[ResourceManagementErrorWithDetails]"}, } - def __init__( - self, - **kwargs - ): - """ - """ - super(ResourceManagementErrorWithDetails, self).__init__(**kwargs) + def __init__(self, **kwargs): + """ """ + super().__init__(**kwargs) self.code = None self.message = None self.target = None self.details = None -class ResourceProviderOperationDisplayProperties(msrest.serialization.Model): +class ResourceProviderOperationDisplayProperties(_serialization.Model): """Resource provider operation's display properties. :ivar publisher: Operation description. @@ -2048,11 +1939,11 @@ class ResourceProviderOperationDisplayProperties(msrest.serialization.Model): """ _attribute_map = { - 'publisher': {'key': 'publisher', 'type': 'str'}, - 'provider': {'key': 'provider', 'type': 'str'}, - 'resource': {'key': 'resource', 'type': 'str'}, - 'operation': {'key': 'operation', 'type': 'str'}, - 'description': {'key': 'description', 'type': 'str'}, + "publisher": {"key": "publisher", "type": "str"}, + "provider": {"key": "provider", "type": "str"}, + "resource": {"key": "resource", "type": "str"}, + "operation": {"key": "operation", "type": "str"}, + "description": {"key": "description", "type": "str"}, } def __init__( @@ -2077,7 +1968,7 @@ def __init__( :keyword description: Operation description. :paramtype description: str """ - super(ResourceProviderOperationDisplayProperties, self).__init__(**kwargs) + super().__init__(**kwargs) self.publisher = publisher self.provider = provider self.resource = resource @@ -2085,7 +1976,7 @@ def __init__( self.description = description -class ResourcesMoveInfo(msrest.serialization.Model): +class ResourcesMoveInfo(_serialization.Model): """Parameters of move resources. :ivar resources: The IDs of the resources. @@ -2095,29 +1986,23 @@ class ResourcesMoveInfo(msrest.serialization.Model): """ _attribute_map = { - 'resources': {'key': 'resources', 'type': '[str]'}, - 'target_resource_group': {'key': 'targetResourceGroup', 'type': 'str'}, + "resources": {"key": "resources", "type": "[str]"}, + "target_resource_group": {"key": "targetResourceGroup", "type": "str"}, } - def __init__( - self, - *, - resources: Optional[List[str]] = None, - target_resource_group: Optional[str] = None, - **kwargs - ): + def __init__(self, *, resources: Optional[List[str]] = None, target_resource_group: Optional[str] = None, **kwargs): """ :keyword resources: The IDs of the resources. :paramtype resources: list[str] :keyword target_resource_group: The target resource group. :paramtype target_resource_group: str """ - super(ResourcesMoveInfo, self).__init__(**kwargs) + super().__init__(**kwargs) self.resources = resources self.target_resource_group = target_resource_group -class Sku(msrest.serialization.Model): +class Sku(_serialization.Model): """SKU for the resource. :ivar name: The SKU name. @@ -2135,12 +2020,12 @@ class Sku(msrest.serialization.Model): """ _attribute_map = { - 'name': {'key': 'name', 'type': 'str'}, - 'tier': {'key': 'tier', 'type': 'str'}, - 'size': {'key': 'size', 'type': 'str'}, - 'family': {'key': 'family', 'type': 'str'}, - 'model': {'key': 'model', 'type': 'str'}, - 'capacity': {'key': 'capacity', 'type': 'int'}, + "name": {"key": "name", "type": "str"}, + "tier": {"key": "tier", "type": "str"}, + "size": {"key": "size", "type": "str"}, + "family": {"key": "family", "type": "str"}, + "model": {"key": "model", "type": "str"}, + "capacity": {"key": "capacity", "type": "int"}, } def __init__( @@ -2168,7 +2053,7 @@ def __init__( :keyword capacity: The SKU capacity. :paramtype capacity: int """ - super(Sku, self).__init__(**kwargs) + super().__init__(**kwargs) self.name = name self.tier = tier self.size = size @@ -2177,7 +2062,7 @@ def __init__( self.capacity = capacity -class SubResource(msrest.serialization.Model): +class SubResource(_serialization.Model): """Sub-resource. :ivar id: Resource ID. @@ -2185,24 +2070,19 @@ class SubResource(msrest.serialization.Model): """ _attribute_map = { - 'id': {'key': 'id', 'type': 'str'}, + "id": {"key": "id", "type": "str"}, } - def __init__( - self, - *, - id: Optional[str] = None, - **kwargs - ): + def __init__(self, *, id: Optional[str] = None, **kwargs): # pylint: disable=redefined-builtin """ :keyword id: Resource ID. :paramtype id: str """ - super(SubResource, self).__init__(**kwargs) + super().__init__(**kwargs) self.id = id -class TagCount(msrest.serialization.Model): +class TagCount(_serialization.Model): """Tag count. :ivar type: Type of count. @@ -2212,29 +2092,23 @@ class TagCount(msrest.serialization.Model): """ _attribute_map = { - 'type': {'key': 'type', 'type': 'str'}, - 'value': {'key': 'value', 'type': 'int'}, + "type": {"key": "type", "type": "str"}, + "value": {"key": "value", "type": "int"}, } - def __init__( - self, - *, - type: Optional[str] = None, - value: Optional[int] = None, - **kwargs - ): + def __init__(self, *, type: Optional[str] = None, value: Optional[int] = None, **kwargs): """ :keyword type: Type of count. :paramtype type: str :keyword value: Value of count. :paramtype value: int """ - super(TagCount, self).__init__(**kwargs) + super().__init__(**kwargs) self.type = type self.value = value -class TagDetails(msrest.serialization.Model): +class TagDetails(_serialization.Model): """Tag details. Variables are only populated by the server, and will be ignored when sending a request. @@ -2251,22 +2125,22 @@ class TagDetails(msrest.serialization.Model): """ _validation = { - 'id': {'readonly': True}, + "id": {"readonly": True}, } _attribute_map = { - 'id': {'key': 'id', 'type': 'str'}, - 'tag_name': {'key': 'tagName', 'type': 'str'}, - 'count': {'key': 'count', 'type': 'TagCount'}, - 'values': {'key': 'values', 'type': '[TagValue]'}, + "id": {"key": "id", "type": "str"}, + "tag_name": {"key": "tagName", "type": "str"}, + "count": {"key": "count", "type": "TagCount"}, + "values": {"key": "values", "type": "[TagValue]"}, } def __init__( self, *, tag_name: Optional[str] = None, - count: Optional["TagCount"] = None, - values: Optional[List["TagValue"]] = None, + count: Optional["_models.TagCount"] = None, + values: Optional[List["_models.TagValue"]] = None, **kwargs ): """ @@ -2278,14 +2152,14 @@ def __init__( :keyword values: The list of tag values. :paramtype values: list[~azure.mgmt.resource.resources.v2018_05_01.models.TagValue] """ - super(TagDetails, self).__init__(**kwargs) + super().__init__(**kwargs) self.id = None self.tag_name = tag_name self.count = count self.values = values -class TagsListResult(msrest.serialization.Model): +class TagsListResult(_serialization.Model): """List of subscription tags. Variables are only populated by the server, and will be ignored when sending a request. @@ -2297,30 +2171,25 @@ class TagsListResult(msrest.serialization.Model): """ _validation = { - 'next_link': {'readonly': True}, + "next_link": {"readonly": True}, } _attribute_map = { - 'value': {'key': 'value', 'type': '[TagDetails]'}, - 'next_link': {'key': 'nextLink', 'type': 'str'}, + "value": {"key": "value", "type": "[TagDetails]"}, + "next_link": {"key": "nextLink", "type": "str"}, } - def __init__( - self, - *, - value: Optional[List["TagDetails"]] = None, - **kwargs - ): + def __init__(self, *, value: Optional[List["_models.TagDetails"]] = None, **kwargs): """ :keyword value: An array of tags. :paramtype value: list[~azure.mgmt.resource.resources.v2018_05_01.models.TagDetails] """ - super(TagsListResult, self).__init__(**kwargs) + super().__init__(**kwargs) self.value = value self.next_link = None -class TagValue(msrest.serialization.Model): +class TagValue(_serialization.Model): """Tag information. Variables are only populated by the server, and will be ignored when sending a request. @@ -2334,35 +2203,29 @@ class TagValue(msrest.serialization.Model): """ _validation = { - 'id': {'readonly': True}, + "id": {"readonly": True}, } _attribute_map = { - 'id': {'key': 'id', 'type': 'str'}, - 'tag_value': {'key': 'tagValue', 'type': 'str'}, - 'count': {'key': 'count', 'type': 'TagCount'}, + "id": {"key": "id", "type": "str"}, + "tag_value": {"key": "tagValue", "type": "str"}, + "count": {"key": "count", "type": "TagCount"}, } - def __init__( - self, - *, - tag_value: Optional[str] = None, - count: Optional["TagCount"] = None, - **kwargs - ): + def __init__(self, *, tag_value: Optional[str] = None, count: Optional["_models.TagCount"] = None, **kwargs): """ :keyword tag_value: The tag value. :paramtype tag_value: str :keyword count: The tag value count. :paramtype count: ~azure.mgmt.resource.resources.v2018_05_01.models.TagCount """ - super(TagValue, self).__init__(**kwargs) + super().__init__(**kwargs) self.id = None self.tag_value = tag_value self.count = count -class TargetResource(msrest.serialization.Model): +class TargetResource(_serialization.Model): """Target resource. :ivar id: The ID of the resource. @@ -2374,15 +2237,15 @@ class TargetResource(msrest.serialization.Model): """ _attribute_map = { - 'id': {'key': 'id', 'type': 'str'}, - 'resource_name': {'key': 'resourceName', 'type': 'str'}, - 'resource_type': {'key': 'resourceType', 'type': 'str'}, + "id": {"key": "id", "type": "str"}, + "resource_name": {"key": "resourceName", "type": "str"}, + "resource_type": {"key": "resourceType", "type": "str"}, } def __init__( self, *, - id: Optional[str] = None, + id: Optional[str] = None, # pylint: disable=redefined-builtin resource_name: Optional[str] = None, resource_type: Optional[str] = None, **kwargs @@ -2395,13 +2258,13 @@ def __init__( :keyword resource_type: The type of the resource. :paramtype resource_type: str """ - super(TargetResource, self).__init__(**kwargs) + super().__init__(**kwargs) self.id = id self.resource_name = resource_name self.resource_type = resource_type -class TemplateHashResult(msrest.serialization.Model): +class TemplateHashResult(_serialization.Model): """Result of the request to calculate template hash. It contains a string of minified template and its hash. :ivar minified_template: The minified template string. @@ -2411,67 +2274,55 @@ class TemplateHashResult(msrest.serialization.Model): """ _attribute_map = { - 'minified_template': {'key': 'minifiedTemplate', 'type': 'str'}, - 'template_hash': {'key': 'templateHash', 'type': 'str'}, + "minified_template": {"key": "minifiedTemplate", "type": "str"}, + "template_hash": {"key": "templateHash", "type": "str"}, } - def __init__( - self, - *, - minified_template: Optional[str] = None, - template_hash: Optional[str] = None, - **kwargs - ): + def __init__(self, *, minified_template: Optional[str] = None, template_hash: Optional[str] = None, **kwargs): """ :keyword minified_template: The minified template string. :paramtype minified_template: str :keyword template_hash: The template hash. :paramtype template_hash: str """ - super(TemplateHashResult, self).__init__(**kwargs) + super().__init__(**kwargs) self.minified_template = minified_template self.template_hash = template_hash -class TemplateLink(msrest.serialization.Model): +class TemplateLink(_serialization.Model): """Entity representing the reference to the template. All required parameters must be populated in order to send to Azure. - :ivar uri: Required. The URI of the template to deploy. + :ivar uri: The URI of the template to deploy. Required. :vartype uri: str :ivar content_version: If included, must match the ContentVersion in the template. :vartype content_version: str """ _validation = { - 'uri': {'required': True}, + "uri": {"required": True}, } _attribute_map = { - 'uri': {'key': 'uri', 'type': 'str'}, - 'content_version': {'key': 'contentVersion', 'type': 'str'}, + "uri": {"key": "uri", "type": "str"}, + "content_version": {"key": "contentVersion", "type": "str"}, } - def __init__( - self, - *, - uri: str, - content_version: Optional[str] = None, - **kwargs - ): + def __init__(self, *, uri: str, content_version: Optional[str] = None, **kwargs): """ - :keyword uri: Required. The URI of the template to deploy. + :keyword uri: The URI of the template to deploy. Required. :paramtype uri: str :keyword content_version: If included, must match the ContentVersion in the template. :paramtype content_version: str """ - super(TemplateLink, self).__init__(**kwargs) + super().__init__(**kwargs) self.uri = uri self.content_version = content_version -class ZoneMapping(msrest.serialization.Model): +class ZoneMapping(_serialization.Model): """ZoneMapping. :ivar location: The location of the zone mapping. @@ -2481,23 +2332,17 @@ class ZoneMapping(msrest.serialization.Model): """ _attribute_map = { - 'location': {'key': 'location', 'type': 'str'}, - 'zones': {'key': 'zones', 'type': '[str]'}, + "location": {"key": "location", "type": "str"}, + "zones": {"key": "zones", "type": "[str]"}, } - def __init__( - self, - *, - location: Optional[str] = None, - zones: Optional[List[str]] = None, - **kwargs - ): + def __init__(self, *, location: Optional[str] = None, zones: Optional[List[str]] = None, **kwargs): """ :keyword location: The location of the zone mapping. :paramtype location: str :keyword zones: :paramtype zones: list[str] """ - super(ZoneMapping, self).__init__(**kwargs) + super().__init__(**kwargs) self.location = location self.zones = zones diff --git a/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/resources/v2018_05_01/models/_patch.py b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/resources/v2018_05_01/models/_patch.py new file mode 100644 index 0000000000000..f7dd32510333d --- /dev/null +++ b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/resources/v2018_05_01/models/_patch.py @@ -0,0 +1,20 @@ +# ------------------------------------ +# Copyright (c) Microsoft Corporation. +# Licensed under the MIT License. +# ------------------------------------ +"""Customize generated code here. + +Follow our quickstart for examples: https://aka.ms/azsdk/python/dpcodegen/python/customize +""" +from typing import List + +__all__: List[str] = [] # Add all objects you want publicly available to users at this package level + + +def patch_sdk(): + """Do not remove from this file. + + `patch_sdk` is a last resort escape hatch that allows you to do customizations + you can't accomplish using the techniques described in + https://aka.ms/azsdk/python/dpcodegen/python/customize + """ diff --git a/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/resources/v2018_05_01/models/_resource_management_client_enums.py b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/resources/v2018_05_01/models/_resource_management_client_enums.py index 02799db402bcc..612a5242cd9bd 100644 --- a/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/resources/v2018_05_01/models/_resource_management_client_enums.py +++ b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/resources/v2018_05_01/models/_resource_management_client_enums.py @@ -7,11 +7,10 @@ # -------------------------------------------------------------------------- from enum import Enum -from six import with_metaclass from azure.core import CaseInsensitiveEnumMeta -class DeploymentMode(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): +class DeploymentMode(str, Enum, metaclass=CaseInsensitiveEnumMeta): """The mode that is used to deploy resources. This value can be either Incremental or Complete. In Incremental mode, resources are deployed without deleting existing resources that are not included in the template. In Complete mode, resources are deployed and existing resources in @@ -22,7 +21,8 @@ class DeploymentMode(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): INCREMENTAL = "Incremental" COMPLETE = "Complete" -class OnErrorDeploymentType(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): + +class OnErrorDeploymentType(str, Enum, metaclass=CaseInsensitiveEnumMeta): """The deployment on error behavior type. Possible values are LastSuccessful and SpecificDeployment. """ @@ -30,9 +30,9 @@ class OnErrorDeploymentType(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): LAST_SUCCESSFUL = "LastSuccessful" SPECIFIC_DEPLOYMENT = "SpecificDeployment" -class ResourceIdentityType(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): - """The identity type. - """ + +class ResourceIdentityType(str, Enum, metaclass=CaseInsensitiveEnumMeta): + """The identity type.""" SYSTEM_ASSIGNED = "SystemAssigned" USER_ASSIGNED = "UserAssigned" diff --git a/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/resources/v2018_05_01/operations/__init__.py b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/resources/v2018_05_01/operations/__init__.py index 53876d82bf5d7..804fee65e3137 100644 --- a/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/resources/v2018_05_01/operations/__init__.py +++ b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/resources/v2018_05_01/operations/__init__.py @@ -14,12 +14,18 @@ from ._operations import TagsOperations from ._operations import DeploymentOperationsOperations +from ._patch import __all__ as _patch_all +from ._patch import * # type: ignore # pylint: disable=unused-wildcard-import +from ._patch import patch_sdk as _patch_sdk + __all__ = [ - 'Operations', - 'DeploymentsOperations', - 'ProvidersOperations', - 'ResourcesOperations', - 'ResourceGroupsOperations', - 'TagsOperations', - 'DeploymentOperationsOperations', + "Operations", + "DeploymentsOperations", + "ProvidersOperations", + "ResourcesOperations", + "ResourceGroupsOperations", + "TagsOperations", + "DeploymentOperationsOperations", ] +__all__.extend([p for p in _patch_all if p not in __all__]) +_patch_sdk() diff --git a/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/resources/v2018_05_01/operations/_operations.py b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/resources/v2018_05_01/operations/_operations.py index cc8c013cd65b4..a8901556a4894 100644 --- a/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/resources/v2018_05_01/operations/_operations.py +++ b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/resources/v2018_05_01/operations/_operations.py @@ -6,578 +6,532 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -from typing import Any, Callable, Dict, Iterable, Optional, TypeVar, Union - -from msrest import Serializer - -from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error +import sys +from typing import Any, Callable, Dict, IO, Iterable, Optional, TypeVar, Union, cast, overload +from urllib.parse import parse_qs, urljoin, urlparse + +from azure.core.exceptions import ( + ClientAuthenticationError, + HttpResponseError, + ResourceExistsError, + ResourceNotFoundError, + ResourceNotModifiedError, + map_error, +) from azure.core.paging import ItemPaged from azure.core.pipeline import PipelineResponse from azure.core.pipeline.transport import HttpResponse from azure.core.polling import LROPoller, NoPolling, PollingMethod from azure.core.rest import HttpRequest from azure.core.tracing.decorator import distributed_trace +from azure.core.utils import case_insensitive_dict from azure.mgmt.core.exceptions import ARMErrorFormat from azure.mgmt.core.polling.arm_polling import ARMPolling from .. import models as _models +from ..._serialization import Serializer from .._vendor import _convert_request, _format_url_section -T = TypeVar('T') + +T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] -JSONType = Any +if sys.version_info >= (3, 9): + from collections.abc import MutableMapping +else: + from typing import MutableMapping # type: ignore # pylint: disable=ungrouped-imports +JSON = MutableMapping[str, Any] # pylint: disable=unsubscriptable-object _SERIALIZER = Serializer() _SERIALIZER.client_side_validation = False -def build_operations_list_request( - **kwargs: Any -) -> HttpRequest: - api_version = kwargs.pop('api_version', "2018-05-01") # type: str - accept = "application/json" +def build_operations_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", "2018-05-01")) # type: str + accept = _headers.pop("Accept", "application/json") + # Construct URL _url = kwargs.pop("template_url", "/providers/Microsoft.Resources/operations") # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') - - return HttpRequest( - method="GET", - url=_url, - params=_query_parameters, - headers=_header_parameters, - **kwargs - ) + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) -def build_deployments_delete_at_subscription_scope_request_initial( - deployment_name: str, - subscription_id: str, - **kwargs: Any + +def build_deployments_delete_at_subscription_scope_request( + deployment_name: str, subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2018-05-01") # type: str + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + api_version = kwargs.pop("api_version", _params.pop("api-version", "2018-05-01")) # type: str # Construct URL - _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/providers/Microsoft.Resources/deployments/{deploymentName}") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", "/subscriptions/{subscriptionId}/providers/Microsoft.Resources/deployments/{deploymentName}" + ) # pylint: disable=line-too-long path_format_arguments = { - "deploymentName": _SERIALIZER.url("deployment_name", deployment_name, 'str', max_length=64, min_length=1, pattern=r'^[-\w\._\(\)]+$'), - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), + "deploymentName": _SERIALIZER.url( + "deployment_name", deployment_name, "str", max_length=64, min_length=1, pattern=r"^[-\w\._\(\)]+$" + ), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), } _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') - - return HttpRequest( - method="DELETE", - url=_url, - params=_query_parameters, - **kwargs - ) + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") + + return HttpRequest(method="DELETE", url=_url, params=_params, **kwargs) def build_deployments_check_existence_at_subscription_scope_request( - deployment_name: str, - subscription_id: str, - **kwargs: Any + deployment_name: str, subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2018-05-01") # type: str + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + api_version = kwargs.pop("api_version", _params.pop("api-version", "2018-05-01")) # type: str # Construct URL - _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/providers/Microsoft.Resources/deployments/{deploymentName}") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", "/subscriptions/{subscriptionId}/providers/Microsoft.Resources/deployments/{deploymentName}" + ) # pylint: disable=line-too-long path_format_arguments = { - "deploymentName": _SERIALIZER.url("deployment_name", deployment_name, 'str', max_length=64, min_length=1, pattern=r'^[-\w\._\(\)]+$'), - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), + "deploymentName": _SERIALIZER.url( + "deployment_name", deployment_name, "str", max_length=64, min_length=1, pattern=r"^[-\w\._\(\)]+$" + ), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), } _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') - - return HttpRequest( - method="HEAD", - url=_url, - params=_query_parameters, - **kwargs - ) + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") + return HttpRequest(method="HEAD", url=_url, params=_params, **kwargs) -def build_deployments_create_or_update_at_subscription_scope_request_initial( - deployment_name: str, - subscription_id: str, - *, - json: JSONType = None, - content: Any = None, - **kwargs: Any + +def build_deployments_create_or_update_at_subscription_scope_request( + deployment_name: str, subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2018-05-01") # type: str - content_type = kwargs.pop('content_type', None) # type: Optional[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", "2018-05-01")) # type: str + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + accept = _headers.pop("Accept", "application/json") - accept = "application/json" # Construct URL - _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/providers/Microsoft.Resources/deployments/{deploymentName}") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", "/subscriptions/{subscriptionId}/providers/Microsoft.Resources/deployments/{deploymentName}" + ) # pylint: disable=line-too-long path_format_arguments = { - "deploymentName": _SERIALIZER.url("deployment_name", deployment_name, 'str', max_length=64, min_length=1, pattern=r'^[-\w\._\(\)]+$'), - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), + "deploymentName": _SERIALIZER.url( + "deployment_name", deployment_name, "str", max_length=64, min_length=1, pattern=r"^[-\w\._\(\)]+$" + ), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), } _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] if content_type is not None: - _header_parameters['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') - _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') - - return HttpRequest( - method="PUT", - url=_url, - params=_query_parameters, - headers=_header_parameters, - json=json, - content=content, - **kwargs - ) + _headers["Content-Type"] = _SERIALIZER.header("content_type", content_type, "str") + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="PUT", url=_url, params=_params, headers=_headers, **kwargs) def build_deployments_get_at_subscription_scope_request( - deployment_name: str, - subscription_id: str, - **kwargs: Any + deployment_name: str, subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2018-05-01") # type: 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", "2018-05-01")) # type: str + accept = _headers.pop("Accept", "application/json") - accept = "application/json" # Construct URL - _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/providers/Microsoft.Resources/deployments/{deploymentName}") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", "/subscriptions/{subscriptionId}/providers/Microsoft.Resources/deployments/{deploymentName}" + ) # pylint: disable=line-too-long path_format_arguments = { - "deploymentName": _SERIALIZER.url("deployment_name", deployment_name, 'str', max_length=64, min_length=1, pattern=r'^[-\w\._\(\)]+$'), - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), + "deploymentName": _SERIALIZER.url( + "deployment_name", deployment_name, "str", max_length=64, min_length=1, pattern=r"^[-\w\._\(\)]+$" + ), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), } _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') - - return HttpRequest( - method="GET", - url=_url, - params=_query_parameters, - headers=_header_parameters, - **kwargs - ) + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) def build_deployments_cancel_at_subscription_scope_request( - deployment_name: str, - subscription_id: str, - **kwargs: Any + deployment_name: str, subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2018-05-01") # type: str + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + api_version = kwargs.pop("api_version", _params.pop("api-version", "2018-05-01")) # type: str # Construct URL - _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/providers/Microsoft.Resources/deployments/{deploymentName}/cancel") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/providers/Microsoft.Resources/deployments/{deploymentName}/cancel", + ) # pylint: disable=line-too-long path_format_arguments = { - "deploymentName": _SERIALIZER.url("deployment_name", deployment_name, 'str', max_length=64, min_length=1, pattern=r'^[-\w\._\(\)]+$'), - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), + "deploymentName": _SERIALIZER.url( + "deployment_name", deployment_name, "str", max_length=64, min_length=1, pattern=r"^[-\w\._\(\)]+$" + ), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), } _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') - - return HttpRequest( - method="POST", - url=_url, - params=_query_parameters, - **kwargs - ) + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") + + return HttpRequest(method="POST", url=_url, params=_params, **kwargs) def build_deployments_validate_at_subscription_scope_request( - deployment_name: str, - subscription_id: str, - *, - json: JSONType = None, - content: Any = None, - **kwargs: Any + deployment_name: str, subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2018-05-01") # type: str - content_type = kwargs.pop('content_type', None) # type: Optional[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", "2018-05-01")) # type: str + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + accept = _headers.pop("Accept", "application/json") - accept = "application/json" # Construct URL - _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/providers/Microsoft.Resources/deployments/{deploymentName}/validate") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/providers/Microsoft.Resources/deployments/{deploymentName}/validate", + ) # pylint: disable=line-too-long path_format_arguments = { - "deploymentName": _SERIALIZER.url("deployment_name", deployment_name, 'str', max_length=64, min_length=1, pattern=r'^[-\w\._\(\)]+$'), - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), + "deploymentName": _SERIALIZER.url( + "deployment_name", deployment_name, "str", max_length=64, min_length=1, pattern=r"^[-\w\._\(\)]+$" + ), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), } _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] if content_type is not None: - _header_parameters['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') - _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') - - return HttpRequest( - method="POST", - url=_url, - params=_query_parameters, - headers=_header_parameters, - json=json, - content=content, - **kwargs - ) + _headers["Content-Type"] = _SERIALIZER.header("content_type", content_type, "str") + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="POST", url=_url, params=_params, headers=_headers, **kwargs) def build_deployments_export_template_at_subscription_scope_request( - deployment_name: str, - subscription_id: str, - **kwargs: Any + deployment_name: str, subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2018-05-01") # type: 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", "2018-05-01")) # type: str + accept = _headers.pop("Accept", "application/json") - accept = "application/json" # Construct URL - _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/providers/Microsoft.Resources/deployments/{deploymentName}/exportTemplate") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/providers/Microsoft.Resources/deployments/{deploymentName}/exportTemplate", + ) # pylint: disable=line-too-long path_format_arguments = { - "deploymentName": _SERIALIZER.url("deployment_name", deployment_name, 'str', max_length=64, min_length=1, pattern=r'^[-\w\._\(\)]+$'), - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), + "deploymentName": _SERIALIZER.url( + "deployment_name", deployment_name, "str", max_length=64, min_length=1, pattern=r"^[-\w\._\(\)]+$" + ), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), } _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') - - return HttpRequest( - method="POST", - url=_url, - params=_query_parameters, - headers=_header_parameters, - **kwargs - ) + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="POST", url=_url, params=_params, headers=_headers, **kwargs) def build_deployments_list_at_subscription_scope_request( - subscription_id: str, - *, - filter: Optional[str] = None, - top: Optional[int] = None, - **kwargs: Any + subscription_id: str, *, filter: Optional[str] = None, top: Optional[int] = None, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2018-05-01") # type: 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", "2018-05-01")) # type: str + accept = _headers.pop("Accept", "application/json") - accept = "application/json" # Construct URL _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/providers/Microsoft.Resources/deployments/") path_format_arguments = { - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), } _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] if filter is not None: - _query_parameters['$filter'] = _SERIALIZER.query("filter", filter, 'str') + _params["$filter"] = _SERIALIZER.query("filter", filter, "str") if top is not None: - _query_parameters['$top'] = _SERIALIZER.query("top", top, 'int') - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["$top"] = _SERIALIZER.query("top", top, "int") + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') - - return HttpRequest( - method="GET", - url=_url, - params=_query_parameters, - headers=_header_parameters, - **kwargs - ) + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) -def build_deployments_delete_request_initial( - resource_group_name: str, - deployment_name: str, - subscription_id: str, - **kwargs: Any + +def build_deployments_delete_request( + resource_group_name: str, deployment_name: str, subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2018-05-01") # type: str + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + api_version = kwargs.pop("api_version", _params.pop("api-version", "2018-05-01")) # type: str # Construct URL - _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/Microsoft.Resources/deployments/{deploymentName}") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/Microsoft.Resources/deployments/{deploymentName}", + ) # pylint: disable=line-too-long path_format_arguments = { - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._\(\)]+$'), - "deploymentName": _SERIALIZER.url("deployment_name", deployment_name, 'str', max_length=64, min_length=1, pattern=r'^[-\w\._\(\)]+$'), - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), + "resourceGroupName": _SERIALIZER.url( + "resource_group_name", resource_group_name, "str", max_length=90, min_length=1, pattern=r"^[-\w\._\(\)]+$" + ), + "deploymentName": _SERIALIZER.url( + "deployment_name", deployment_name, "str", max_length=64, min_length=1, pattern=r"^[-\w\._\(\)]+$" + ), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), } _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') - - return HttpRequest( - method="DELETE", - url=_url, - params=_query_parameters, - **kwargs - ) + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") + + return HttpRequest(method="DELETE", url=_url, params=_params, **kwargs) def build_deployments_check_existence_request( - resource_group_name: str, - deployment_name: str, - subscription_id: str, - **kwargs: Any + resource_group_name: str, deployment_name: str, subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2018-05-01") # type: str + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + api_version = kwargs.pop("api_version", _params.pop("api-version", "2018-05-01")) # type: str # Construct URL - _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/Microsoft.Resources/deployments/{deploymentName}") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/Microsoft.Resources/deployments/{deploymentName}", + ) # pylint: disable=line-too-long path_format_arguments = { - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._\(\)]+$'), - "deploymentName": _SERIALIZER.url("deployment_name", deployment_name, 'str', max_length=64, min_length=1, pattern=r'^[-\w\._\(\)]+$'), - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), + "resourceGroupName": _SERIALIZER.url( + "resource_group_name", resource_group_name, "str", max_length=90, min_length=1, pattern=r"^[-\w\._\(\)]+$" + ), + "deploymentName": _SERIALIZER.url( + "deployment_name", deployment_name, "str", max_length=64, min_length=1, pattern=r"^[-\w\._\(\)]+$" + ), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), } _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') - - return HttpRequest( - method="HEAD", - url=_url, - params=_query_parameters, - **kwargs - ) + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") + return HttpRequest(method="HEAD", url=_url, params=_params, **kwargs) -def build_deployments_create_or_update_request_initial( - resource_group_name: str, - deployment_name: str, - subscription_id: str, - *, - json: JSONType = None, - content: Any = None, - **kwargs: Any + +def build_deployments_create_or_update_request( + resource_group_name: str, deployment_name: str, subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2018-05-01") # type: str - content_type = kwargs.pop('content_type', None) # type: Optional[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", "2018-05-01")) # type: str + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + accept = _headers.pop("Accept", "application/json") - accept = "application/json" # Construct URL - _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/Microsoft.Resources/deployments/{deploymentName}") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/Microsoft.Resources/deployments/{deploymentName}", + ) # pylint: disable=line-too-long path_format_arguments = { - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._\(\)]+$'), - "deploymentName": _SERIALIZER.url("deployment_name", deployment_name, 'str', max_length=64, min_length=1, pattern=r'^[-\w\._\(\)]+$'), - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), + "resourceGroupName": _SERIALIZER.url( + "resource_group_name", resource_group_name, "str", max_length=90, min_length=1, pattern=r"^[-\w\._\(\)]+$" + ), + "deploymentName": _SERIALIZER.url( + "deployment_name", deployment_name, "str", max_length=64, min_length=1, pattern=r"^[-\w\._\(\)]+$" + ), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), } _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] if content_type is not None: - _header_parameters['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') - _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') - - return HttpRequest( - method="PUT", - url=_url, - params=_query_parameters, - headers=_header_parameters, - json=json, - content=content, - **kwargs - ) + _headers["Content-Type"] = _SERIALIZER.header("content_type", content_type, "str") + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="PUT", url=_url, params=_params, headers=_headers, **kwargs) def build_deployments_get_request( - resource_group_name: str, - deployment_name: str, - subscription_id: str, - **kwargs: Any + resource_group_name: str, deployment_name: str, subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2018-05-01") # type: 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", "2018-05-01")) # type: str + accept = _headers.pop("Accept", "application/json") - accept = "application/json" # Construct URL - _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/Microsoft.Resources/deployments/{deploymentName}") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/Microsoft.Resources/deployments/{deploymentName}", + ) # pylint: disable=line-too-long path_format_arguments = { - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._\(\)]+$'), - "deploymentName": _SERIALIZER.url("deployment_name", deployment_name, 'str', max_length=64, min_length=1, pattern=r'^[-\w\._\(\)]+$'), - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), + "resourceGroupName": _SERIALIZER.url( + "resource_group_name", resource_group_name, "str", max_length=90, min_length=1, pattern=r"^[-\w\._\(\)]+$" + ), + "deploymentName": _SERIALIZER.url( + "deployment_name", deployment_name, "str", max_length=64, min_length=1, pattern=r"^[-\w\._\(\)]+$" + ), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), } _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') - - return HttpRequest( - method="GET", - url=_url, - params=_query_parameters, - headers=_header_parameters, - **kwargs - ) + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) def build_deployments_cancel_request( - resource_group_name: str, - deployment_name: str, - subscription_id: str, - **kwargs: Any + resource_group_name: str, deployment_name: str, subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2018-05-01") # type: str + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + api_version = kwargs.pop("api_version", _params.pop("api-version", "2018-05-01")) # type: str # Construct URL - _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/Microsoft.Resources/deployments/{deploymentName}/cancel") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/Microsoft.Resources/deployments/{deploymentName}/cancel", + ) # pylint: disable=line-too-long path_format_arguments = { - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._\(\)]+$'), - "deploymentName": _SERIALIZER.url("deployment_name", deployment_name, 'str', max_length=64, min_length=1, pattern=r'^[-\w\._\(\)]+$'), - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), + "resourceGroupName": _SERIALIZER.url( + "resource_group_name", resource_group_name, "str", max_length=90, min_length=1, pattern=r"^[-\w\._\(\)]+$" + ), + "deploymentName": _SERIALIZER.url( + "deployment_name", deployment_name, "str", max_length=64, min_length=1, pattern=r"^[-\w\._\(\)]+$" + ), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), } _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') - - return HttpRequest( - method="POST", - url=_url, - params=_query_parameters, - **kwargs - ) + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") + + return HttpRequest(method="POST", url=_url, params=_params, **kwargs) def build_deployments_validate_request( - resource_group_name: str, - deployment_name: str, - subscription_id: str, - *, - json: JSONType = None, - content: Any = None, - **kwargs: Any + resource_group_name: str, deployment_name: str, subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2018-05-01") # type: str - content_type = kwargs.pop('content_type', None) # type: Optional[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", "2018-05-01")) # type: str + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + accept = _headers.pop("Accept", "application/json") - accept = "application/json" # Construct URL - _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/Microsoft.Resources/deployments/{deploymentName}/validate") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/Microsoft.Resources/deployments/{deploymentName}/validate", + ) # pylint: disable=line-too-long path_format_arguments = { - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._\(\)]+$'), - "deploymentName": _SERIALIZER.url("deployment_name", deployment_name, 'str', max_length=64, min_length=1, pattern=r'^[-\w\._\(\)]+$'), - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), + "resourceGroupName": _SERIALIZER.url( + "resource_group_name", resource_group_name, "str", max_length=90, min_length=1, pattern=r"^[-\w\._\(\)]+$" + ), + "deploymentName": _SERIALIZER.url( + "deployment_name", deployment_name, "str", max_length=64, min_length=1, pattern=r"^[-\w\._\(\)]+$" + ), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), } _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] if content_type is not None: - _header_parameters['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') - _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') - - return HttpRequest( - method="POST", - url=_url, - params=_query_parameters, - headers=_header_parameters, - json=json, - content=content, - **kwargs - ) + _headers["Content-Type"] = _SERIALIZER.header("content_type", content_type, "str") + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="POST", url=_url, params=_params, headers=_headers, **kwargs) def build_deployments_export_template_request( - resource_group_name: str, - deployment_name: str, - subscription_id: str, - **kwargs: Any + resource_group_name: str, deployment_name: str, subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2018-05-01") # type: 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", "2018-05-01")) # type: str + accept = _headers.pop("Accept", "application/json") - accept = "application/json" # Construct URL - _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/Microsoft.Resources/deployments/{deploymentName}/exportTemplate") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/Microsoft.Resources/deployments/{deploymentName}/exportTemplate", + ) # pylint: disable=line-too-long path_format_arguments = { - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._\(\)]+$'), - "deploymentName": _SERIALIZER.url("deployment_name", deployment_name, 'str', max_length=64, min_length=1, pattern=r'^[-\w\._\(\)]+$'), - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), + "resourceGroupName": _SERIALIZER.url( + "resource_group_name", resource_group_name, "str", max_length=90, min_length=1, pattern=r"^[-\w\._\(\)]+$" + ), + "deploymentName": _SERIALIZER.url( + "deployment_name", deployment_name, "str", max_length=64, min_length=1, pattern=r"^[-\w\._\(\)]+$" + ), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), } _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') - - return HttpRequest( - method="POST", - url=_url, - params=_query_parameters, - headers=_header_parameters, - **kwargs - ) + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="POST", url=_url, params=_params, headers=_headers, **kwargs) def build_deployments_list_by_resource_group_request( @@ -588,216 +542,174 @@ def build_deployments_list_by_resource_group_request( top: Optional[int] = None, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2018-05-01") # type: 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", "2018-05-01")) # type: str + accept = _headers.pop("Accept", "application/json") - accept = "application/json" # Construct URL - _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/Microsoft.Resources/deployments/") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/Microsoft.Resources/deployments/", + ) # pylint: disable=line-too-long path_format_arguments = { - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._\(\)]+$'), - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), + "resourceGroupName": _SERIALIZER.url( + "resource_group_name", resource_group_name, "str", max_length=90, min_length=1, pattern=r"^[-\w\._\(\)]+$" + ), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), } _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] if filter is not None: - _query_parameters['$filter'] = _SERIALIZER.query("filter", filter, 'str') + _params["$filter"] = _SERIALIZER.query("filter", filter, "str") if top is not None: - _query_parameters['$top'] = _SERIALIZER.query("top", top, 'int') - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["$top"] = _SERIALIZER.query("top", top, "int") + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') - - return HttpRequest( - method="GET", - url=_url, - params=_query_parameters, - headers=_header_parameters, - **kwargs - ) + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) -def build_deployments_calculate_template_hash_request( - *, - json: JSONType = None, - content: Any = None, - **kwargs: Any -) -> HttpRequest: - api_version = kwargs.pop('api_version', "2018-05-01") # type: str - content_type = kwargs.pop('content_type', None) # type: Optional[str] - accept = "application/json" +def build_deployments_calculate_template_hash_request(*, json: JSON, **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", "2018-05-01")) # type: str + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + accept = _headers.pop("Accept", "application/json") + # Construct URL _url = kwargs.pop("template_url", "/providers/Microsoft.Resources/calculateTemplateHash") # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] if content_type is not None: - _header_parameters['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') - _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') - - return HttpRequest( - method="POST", - url=_url, - params=_query_parameters, - headers=_header_parameters, - json=json, - content=content, - **kwargs - ) + _headers["Content-Type"] = _SERIALIZER.header("content_type", content_type, "str") + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="POST", url=_url, params=_params, headers=_headers, json=json, **kwargs) def build_providers_unregister_request( - resource_provider_namespace: str, - subscription_id: str, - **kwargs: Any + resource_provider_namespace: str, subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2018-05-01") # type: 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", "2018-05-01")) # type: str + accept = _headers.pop("Accept", "application/json") - accept = "application/json" # Construct URL - _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/providers/{resourceProviderNamespace}/unregister") + _url = kwargs.pop( + "template_url", "/subscriptions/{subscriptionId}/providers/{resourceProviderNamespace}/unregister" + ) path_format_arguments = { - "resourceProviderNamespace": _SERIALIZER.url("resource_provider_namespace", resource_provider_namespace, 'str'), - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), + "resourceProviderNamespace": _SERIALIZER.url("resource_provider_namespace", resource_provider_namespace, "str"), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), } _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') - - return HttpRequest( - method="POST", - url=_url, - params=_query_parameters, - headers=_header_parameters, - **kwargs - ) + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="POST", url=_url, params=_params, headers=_headers, **kwargs) def build_providers_register_request( - resource_provider_namespace: str, - subscription_id: str, - **kwargs: Any + resource_provider_namespace: str, subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2018-05-01") # type: 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", "2018-05-01")) # type: str + accept = _headers.pop("Accept", "application/json") - accept = "application/json" # Construct URL _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/providers/{resourceProviderNamespace}/register") path_format_arguments = { - "resourceProviderNamespace": _SERIALIZER.url("resource_provider_namespace", resource_provider_namespace, 'str'), - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), + "resourceProviderNamespace": _SERIALIZER.url("resource_provider_namespace", resource_provider_namespace, "str"), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), } _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') - - return HttpRequest( - method="POST", - url=_url, - params=_query_parameters, - headers=_header_parameters, - **kwargs - ) + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="POST", url=_url, params=_params, headers=_headers, **kwargs) def build_providers_list_request( - subscription_id: str, - *, - top: Optional[int] = None, - expand: Optional[str] = None, - **kwargs: Any + subscription_id: str, *, top: Optional[int] = None, expand: Optional[str] = None, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2018-05-01") # type: 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", "2018-05-01")) # type: str + accept = _headers.pop("Accept", "application/json") - accept = "application/json" # Construct URL _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/providers") path_format_arguments = { - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), } _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] if top is not None: - _query_parameters['$top'] = _SERIALIZER.query("top", top, 'int') + _params["$top"] = _SERIALIZER.query("top", top, "int") if expand is not None: - _query_parameters['$expand'] = _SERIALIZER.query("expand", expand, 'str') - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["$expand"] = _SERIALIZER.query("expand", expand, "str") + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') - - return HttpRequest( - method="GET", - url=_url, - params=_query_parameters, - headers=_header_parameters, - **kwargs - ) + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) def build_providers_get_request( - resource_provider_namespace: str, - subscription_id: str, - *, - expand: Optional[str] = None, - **kwargs: Any + resource_provider_namespace: str, subscription_id: str, *, expand: Optional[str] = None, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2018-05-01") # type: 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", "2018-05-01")) # type: str + accept = _headers.pop("Accept", "application/json") - accept = "application/json" # Construct URL _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/providers/{resourceProviderNamespace}") path_format_arguments = { - "resourceProviderNamespace": _SERIALIZER.url("resource_provider_namespace", resource_provider_namespace, 'str'), - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), + "resourceProviderNamespace": _SERIALIZER.url("resource_provider_namespace", resource_provider_namespace, "str"), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), } _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] if expand is not None: - _query_parameters['$expand'] = _SERIALIZER.query("expand", expand, 'str') - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["$expand"] = _SERIALIZER.query("expand", expand, "str") + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') - - return HttpRequest( - method="GET", - url=_url, - params=_query_parameters, - headers=_header_parameters, - **kwargs - ) + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) def build_resources_list_by_resource_group_request( @@ -809,119 +721,108 @@ def build_resources_list_by_resource_group_request( top: Optional[int] = None, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2018-05-01") # type: 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", "2018-05-01")) # type: str + accept = _headers.pop("Accept", "application/json") - accept = "application/json" # Construct URL _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/resources") path_format_arguments = { - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._\(\)]+$'), - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), + "resourceGroupName": _SERIALIZER.url( + "resource_group_name", resource_group_name, "str", max_length=90, min_length=1, pattern=r"^[-\w\._\(\)]+$" + ), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), } _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] if filter is not None: - _query_parameters['$filter'] = _SERIALIZER.query("filter", filter, 'str') + _params["$filter"] = _SERIALIZER.query("filter", filter, "str") if expand is not None: - _query_parameters['$expand'] = _SERIALIZER.query("expand", expand, 'str') + _params["$expand"] = _SERIALIZER.query("expand", expand, "str") if top is not None: - _query_parameters['$top'] = _SERIALIZER.query("top", top, 'int') - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["$top"] = _SERIALIZER.query("top", top, "int") + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') - - return HttpRequest( - method="GET", - url=_url, - params=_query_parameters, - headers=_header_parameters, - **kwargs - ) + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) -def build_resources_move_resources_request_initial( - source_resource_group_name: str, - subscription_id: str, - *, - json: JSONType = None, - content: Any = None, - **kwargs: Any + +def build_resources_move_resources_request( + source_resource_group_name: str, subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2018-05-01") # type: str - content_type = kwargs.pop('content_type', None) # type: Optional[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", "2018-05-01")) # type: str + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] # Construct URL - _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{sourceResourceGroupName}/moveResources") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", "/subscriptions/{subscriptionId}/resourceGroups/{sourceResourceGroupName}/moveResources" + ) # pylint: disable=line-too-long path_format_arguments = { - "sourceResourceGroupName": _SERIALIZER.url("source_resource_group_name", source_resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._\(\)]+$'), - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), + "sourceResourceGroupName": _SERIALIZER.url( + "source_resource_group_name", + source_resource_group_name, + "str", + max_length=90, + min_length=1, + pattern=r"^[-\w\._\(\)]+$", + ), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), } _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] if content_type is not None: - _header_parameters['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') - - return HttpRequest( - method="POST", - url=_url, - params=_query_parameters, - headers=_header_parameters, - json=json, - content=content, - **kwargs - ) + _headers["Content-Type"] = _SERIALIZER.header("content_type", content_type, "str") + return HttpRequest(method="POST", url=_url, params=_params, headers=_headers, **kwargs) -def build_resources_validate_move_resources_request_initial( - source_resource_group_name: str, - subscription_id: str, - *, - json: JSONType = None, - content: Any = None, - **kwargs: Any + +def build_resources_validate_move_resources_request( + source_resource_group_name: str, subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2018-05-01") # type: str - content_type = kwargs.pop('content_type', None) # type: Optional[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", "2018-05-01")) # type: str + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] # Construct URL - _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{sourceResourceGroupName}/validateMoveResources") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", "/subscriptions/{subscriptionId}/resourceGroups/{sourceResourceGroupName}/validateMoveResources" + ) # pylint: disable=line-too-long path_format_arguments = { - "sourceResourceGroupName": _SERIALIZER.url("source_resource_group_name", source_resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._\(\)]+$'), - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), + "sourceResourceGroupName": _SERIALIZER.url( + "source_resource_group_name", + source_resource_group_name, + "str", + max_length=90, + min_length=1, + pattern=r"^[-\w\._\(\)]+$", + ), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), } _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] if content_type is not None: - _header_parameters['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') - - return HttpRequest( - method="POST", - url=_url, - params=_query_parameters, - headers=_header_parameters, - json=json, - content=content, - **kwargs - ) + _headers["Content-Type"] = _SERIALIZER.header("content_type", content_type, "str") + + return HttpRequest(method="POST", url=_url, params=_params, headers=_headers, **kwargs) def build_resources_list_request( @@ -932,38 +833,33 @@ def build_resources_list_request( top: Optional[int] = None, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2018-05-01") # type: 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", "2018-05-01")) # type: str + accept = _headers.pop("Accept", "application/json") - accept = "application/json" # Construct URL _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resources") path_format_arguments = { - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), } _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] if filter is not None: - _query_parameters['$filter'] = _SERIALIZER.query("filter", filter, 'str') + _params["$filter"] = _SERIALIZER.query("filter", filter, "str") if expand is not None: - _query_parameters['$expand'] = _SERIALIZER.query("expand", expand, 'str') + _params["$expand"] = _SERIALIZER.query("expand", expand, "str") if top is not None: - _query_parameters['$top'] = _SERIALIZER.query("top", top, 'int') - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["$top"] = _SERIALIZER.query("top", top, "int") + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') - - return HttpRequest( - method="GET", - url=_url, - params=_query_parameters, - headers=_header_parameters, - **kwargs - ) + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) def build_resources_check_existence_request( @@ -977,32 +873,33 @@ def build_resources_check_existence_request( api_version: str, **kwargs: Any ) -> HttpRequest: + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + # Construct URL - _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{parentResourcePath}/{resourceType}/{resourceName}") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{parentResourcePath}/{resourceType}/{resourceName}", + ) # pylint: disable=line-too-long path_format_arguments = { - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._\(\)]+$'), - "resourceProviderNamespace": _SERIALIZER.url("resource_provider_namespace", resource_provider_namespace, 'str'), - "parentResourcePath": _SERIALIZER.url("parent_resource_path", parent_resource_path, 'str', skip_quote=True), - "resourceType": _SERIALIZER.url("resource_type", resource_type, 'str', skip_quote=True), - "resourceName": _SERIALIZER.url("resource_name", resource_name, 'str'), - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), + "resourceGroupName": _SERIALIZER.url( + "resource_group_name", resource_group_name, "str", max_length=90, min_length=1, pattern=r"^[-\w\._\(\)]+$" + ), + "resourceProviderNamespace": _SERIALIZER.url("resource_provider_namespace", resource_provider_namespace, "str"), + "parentResourcePath": _SERIALIZER.url("parent_resource_path", parent_resource_path, "str", skip_quote=True), + "resourceType": _SERIALIZER.url("resource_type", resource_type, "str", skip_quote=True), + "resourceName": _SERIALIZER.url("resource_name", resource_name, "str"), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), } _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') - - return HttpRequest( - method="HEAD", - url=_url, - params=_query_parameters, - **kwargs - ) + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") + return HttpRequest(method="HEAD", url=_url, params=_params, **kwargs) -def build_resources_delete_request_initial( + +def build_resources_delete_request( resource_group_name: str, resource_provider_namespace: str, parent_resource_path: str, @@ -1013,32 +910,33 @@ def build_resources_delete_request_initial( api_version: str, **kwargs: Any ) -> HttpRequest: + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + # Construct URL - _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{parentResourcePath}/{resourceType}/{resourceName}") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{parentResourcePath}/{resourceType}/{resourceName}", + ) # pylint: disable=line-too-long path_format_arguments = { - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._\(\)]+$'), - "resourceProviderNamespace": _SERIALIZER.url("resource_provider_namespace", resource_provider_namespace, 'str'), - "parentResourcePath": _SERIALIZER.url("parent_resource_path", parent_resource_path, 'str', skip_quote=True), - "resourceType": _SERIALIZER.url("resource_type", resource_type, 'str', skip_quote=True), - "resourceName": _SERIALIZER.url("resource_name", resource_name, 'str'), - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), + "resourceGroupName": _SERIALIZER.url( + "resource_group_name", resource_group_name, "str", max_length=90, min_length=1, pattern=r"^[-\w\._\(\)]+$" + ), + "resourceProviderNamespace": _SERIALIZER.url("resource_provider_namespace", resource_provider_namespace, "str"), + "parentResourcePath": _SERIALIZER.url("parent_resource_path", parent_resource_path, "str", skip_quote=True), + "resourceType": _SERIALIZER.url("resource_type", resource_type, "str", skip_quote=True), + "resourceName": _SERIALIZER.url("resource_name", resource_name, "str"), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), } _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') - - return HttpRequest( - method="DELETE", - url=_url, - params=_query_parameters, - **kwargs - ) + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") + + return HttpRequest(method="DELETE", url=_url, params=_params, **kwargs) -def build_resources_create_or_update_request_initial( +def build_resources_create_or_update_request( resource_group_name: str, resource_provider_namespace: str, parent_resource_path: str, @@ -1047,48 +945,44 @@ def build_resources_create_or_update_request_initial( subscription_id: str, *, api_version: str, - json: JSONType = None, - content: Any = None, **kwargs: Any ) -> HttpRequest: - content_type = kwargs.pop('content_type', None) # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + accept = _headers.pop("Accept", "application/json") - accept = "application/json" # Construct URL - _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{parentResourcePath}/{resourceType}/{resourceName}") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{parentResourcePath}/{resourceType}/{resourceName}", + ) # pylint: disable=line-too-long path_format_arguments = { - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._\(\)]+$'), - "resourceProviderNamespace": _SERIALIZER.url("resource_provider_namespace", resource_provider_namespace, 'str'), - "parentResourcePath": _SERIALIZER.url("parent_resource_path", parent_resource_path, 'str', skip_quote=True), - "resourceType": _SERIALIZER.url("resource_type", resource_type, 'str', skip_quote=True), - "resourceName": _SERIALIZER.url("resource_name", resource_name, 'str'), - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), + "resourceGroupName": _SERIALIZER.url( + "resource_group_name", resource_group_name, "str", max_length=90, min_length=1, pattern=r"^[-\w\._\(\)]+$" + ), + "resourceProviderNamespace": _SERIALIZER.url("resource_provider_namespace", resource_provider_namespace, "str"), + "parentResourcePath": _SERIALIZER.url("parent_resource_path", parent_resource_path, "str", skip_quote=True), + "resourceType": _SERIALIZER.url("resource_type", resource_type, "str", skip_quote=True), + "resourceName": _SERIALIZER.url("resource_name", resource_name, "str"), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), } _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] if content_type is not None: - _header_parameters['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') - _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') - - return HttpRequest( - method="PUT", - url=_url, - params=_query_parameters, - headers=_header_parameters, - json=json, - content=content, - **kwargs - ) + _headers["Content-Type"] = _SERIALIZER.header("content_type", content_type, "str") + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + return HttpRequest(method="PUT", url=_url, params=_params, headers=_headers, **kwargs) -def build_resources_update_request_initial( + +def build_resources_update_request( resource_group_name: str, resource_provider_namespace: str, parent_resource_path: str, @@ -1097,45 +991,41 @@ def build_resources_update_request_initial( subscription_id: str, *, api_version: str, - json: JSONType = None, - content: Any = None, **kwargs: Any ) -> HttpRequest: - content_type = kwargs.pop('content_type', None) # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + accept = _headers.pop("Accept", "application/json") - accept = "application/json" # Construct URL - _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{parentResourcePath}/{resourceType}/{resourceName}") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{parentResourcePath}/{resourceType}/{resourceName}", + ) # pylint: disable=line-too-long path_format_arguments = { - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._\(\)]+$'), - "resourceProviderNamespace": _SERIALIZER.url("resource_provider_namespace", resource_provider_namespace, 'str'), - "parentResourcePath": _SERIALIZER.url("parent_resource_path", parent_resource_path, 'str', skip_quote=True), - "resourceType": _SERIALIZER.url("resource_type", resource_type, 'str', skip_quote=True), - "resourceName": _SERIALIZER.url("resource_name", resource_name, 'str'), - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), + "resourceGroupName": _SERIALIZER.url( + "resource_group_name", resource_group_name, "str", max_length=90, min_length=1, pattern=r"^[-\w\._\(\)]+$" + ), + "resourceProviderNamespace": _SERIALIZER.url("resource_provider_namespace", resource_provider_namespace, "str"), + "parentResourcePath": _SERIALIZER.url("parent_resource_path", parent_resource_path, "str", skip_quote=True), + "resourceType": _SERIALIZER.url("resource_type", resource_type, "str", skip_quote=True), + "resourceName": _SERIALIZER.url("resource_name", resource_name, "str"), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), } _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] if content_type is not None: - _header_parameters['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') - _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') - - return HttpRequest( - method="PATCH", - url=_url, - params=_query_parameters, - headers=_header_parameters, - json=json, - content=content, - **kwargs - ) + _headers["Content-Type"] = _SERIALIZER.header("content_type", content_type, "str") + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="PATCH", url=_url, params=_params, headers=_headers, **kwargs) def build_resources_get_request( @@ -1149,826 +1039,663 @@ def build_resources_get_request( api_version: str, **kwargs: Any ) -> HttpRequest: - accept = "application/json" + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + accept = _headers.pop("Accept", "application/json") + # Construct URL - _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{parentResourcePath}/{resourceType}/{resourceName}") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{parentResourcePath}/{resourceType}/{resourceName}", + ) # pylint: disable=line-too-long path_format_arguments = { - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._\(\)]+$'), - "resourceProviderNamespace": _SERIALIZER.url("resource_provider_namespace", resource_provider_namespace, 'str'), - "parentResourcePath": _SERIALIZER.url("parent_resource_path", parent_resource_path, 'str', skip_quote=True), - "resourceType": _SERIALIZER.url("resource_type", resource_type, 'str', skip_quote=True), - "resourceName": _SERIALIZER.url("resource_name", resource_name, 'str'), - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), + "resourceGroupName": _SERIALIZER.url( + "resource_group_name", resource_group_name, "str", max_length=90, min_length=1, pattern=r"^[-\w\._\(\)]+$" + ), + "resourceProviderNamespace": _SERIALIZER.url("resource_provider_namespace", resource_provider_namespace, "str"), + "parentResourcePath": _SERIALIZER.url("parent_resource_path", parent_resource_path, "str", skip_quote=True), + "resourceType": _SERIALIZER.url("resource_type", resource_type, "str", skip_quote=True), + "resourceName": _SERIALIZER.url("resource_name", resource_name, "str"), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), } _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') - - return HttpRequest( - method="GET", - url=_url, - params=_query_parameters, - headers=_header_parameters, - **kwargs - ) + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) + + +def build_resources_check_existence_by_id_request(resource_id: str, *, api_version: str, **kwargs: Any) -> HttpRequest: + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) -def build_resources_check_existence_by_id_request( - resource_id: str, - *, - api_version: str, - **kwargs: Any -) -> HttpRequest: # Construct URL _url = kwargs.pop("template_url", "/{resourceId}") path_format_arguments = { - "resourceId": _SERIALIZER.url("resource_id", resource_id, 'str', skip_quote=True), + "resourceId": _SERIALIZER.url("resource_id", resource_id, "str", skip_quote=True), } _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') - - return HttpRequest( - method="HEAD", - url=_url, - params=_query_parameters, - **kwargs - ) + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") + return HttpRequest(method="HEAD", url=_url, params=_params, **kwargs) + + +def build_resources_delete_by_id_request(resource_id: str, *, api_version: str, **kwargs: Any) -> HttpRequest: + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) -def build_resources_delete_by_id_request_initial( - resource_id: str, - *, - api_version: str, - **kwargs: Any -) -> HttpRequest: # Construct URL _url = kwargs.pop("template_url", "/{resourceId}") path_format_arguments = { - "resourceId": _SERIALIZER.url("resource_id", resource_id, 'str', skip_quote=True), + "resourceId": _SERIALIZER.url("resource_id", resource_id, "str", skip_quote=True), } _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') - - return HttpRequest( - method="DELETE", - url=_url, - params=_query_parameters, - **kwargs - ) + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") + return HttpRequest(method="DELETE", url=_url, params=_params, **kwargs) -def build_resources_create_or_update_by_id_request_initial( - resource_id: str, - *, - api_version: str, - json: JSONType = None, - content: Any = None, - **kwargs: Any -) -> HttpRequest: - content_type = kwargs.pop('content_type', None) # type: Optional[str] - accept = "application/json" +def build_resources_create_or_update_by_id_request(resource_id: str, *, api_version: str, **kwargs: Any) -> HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + accept = _headers.pop("Accept", "application/json") + # Construct URL _url = kwargs.pop("template_url", "/{resourceId}") path_format_arguments = { - "resourceId": _SERIALIZER.url("resource_id", resource_id, 'str', skip_quote=True), + "resourceId": _SERIALIZER.url("resource_id", resource_id, "str", skip_quote=True), } _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] if content_type is not None: - _header_parameters['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') - _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') - - return HttpRequest( - method="PUT", - url=_url, - params=_query_parameters, - headers=_header_parameters, - json=json, - content=content, - **kwargs - ) + _headers["Content-Type"] = _SERIALIZER.header("content_type", content_type, "str") + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + return HttpRequest(method="PUT", url=_url, params=_params, headers=_headers, **kwargs) -def build_resources_update_by_id_request_initial( - resource_id: str, - *, - api_version: str, - json: JSONType = None, - content: Any = None, - **kwargs: Any -) -> HttpRequest: - content_type = kwargs.pop('content_type', None) # type: Optional[str] - accept = "application/json" +def build_resources_update_by_id_request(resource_id: str, *, api_version: str, **kwargs: Any) -> HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + accept = _headers.pop("Accept", "application/json") + # Construct URL _url = kwargs.pop("template_url", "/{resourceId}") path_format_arguments = { - "resourceId": _SERIALIZER.url("resource_id", resource_id, 'str', skip_quote=True), + "resourceId": _SERIALIZER.url("resource_id", resource_id, "str", skip_quote=True), } _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] if content_type is not None: - _header_parameters['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') - _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') - - return HttpRequest( - method="PATCH", - url=_url, - params=_query_parameters, - headers=_header_parameters, - json=json, - content=content, - **kwargs - ) + _headers["Content-Type"] = _SERIALIZER.header("content_type", content_type, "str") + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + return HttpRequest(method="PATCH", url=_url, params=_params, headers=_headers, **kwargs) + + +def build_resources_get_by_id_request(resource_id: str, *, api_version: str, **kwargs: Any) -> HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + accept = _headers.pop("Accept", "application/json") -def build_resources_get_by_id_request( - resource_id: str, - *, - api_version: str, - **kwargs: Any -) -> HttpRequest: - accept = "application/json" # Construct URL _url = kwargs.pop("template_url", "/{resourceId}") path_format_arguments = { - "resourceId": _SERIALIZER.url("resource_id", resource_id, 'str', skip_quote=True), + "resourceId": _SERIALIZER.url("resource_id", resource_id, "str", skip_quote=True), } _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') - - return HttpRequest( - method="GET", - url=_url, - params=_query_parameters, - headers=_header_parameters, - **kwargs - ) + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) def build_resource_groups_check_existence_request( - resource_group_name: str, - subscription_id: str, - **kwargs: Any + resource_group_name: str, subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2018-05-01") # type: str + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + api_version = kwargs.pop("api_version", _params.pop("api-version", "2018-05-01")) # type: str # Construct URL _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}") path_format_arguments = { - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._\(\)]+$'), - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), + "resourceGroupName": _SERIALIZER.url( + "resource_group_name", resource_group_name, "str", max_length=90, min_length=1, pattern=r"^[-\w\._\(\)]+$" + ), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), } _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') - - return HttpRequest( - method="HEAD", - url=_url, - params=_query_parameters, - **kwargs - ) + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") + + return HttpRequest(method="HEAD", url=_url, params=_params, **kwargs) def build_resource_groups_create_or_update_request( - resource_group_name: str, - subscription_id: str, - *, - json: JSONType = None, - content: Any = None, - **kwargs: Any + resource_group_name: str, subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2018-05-01") # type: str - content_type = kwargs.pop('content_type', None) # type: Optional[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", "2018-05-01")) # type: str + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + accept = _headers.pop("Accept", "application/json") - accept = "application/json" # Construct URL _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}") path_format_arguments = { - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._\(\)]+$'), - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), + "resourceGroupName": _SERIALIZER.url( + "resource_group_name", resource_group_name, "str", max_length=90, min_length=1, pattern=r"^[-\w\._\(\)]+$" + ), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), } _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] if content_type is not None: - _header_parameters['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') - _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') - - return HttpRequest( - method="PUT", - url=_url, - params=_query_parameters, - headers=_header_parameters, - json=json, - content=content, - **kwargs - ) + _headers["Content-Type"] = _SERIALIZER.header("content_type", content_type, "str") + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + return HttpRequest(method="PUT", url=_url, params=_params, headers=_headers, **kwargs) -def build_resource_groups_delete_request_initial( - resource_group_name: str, - subscription_id: str, - **kwargs: Any -) -> HttpRequest: - api_version = kwargs.pop('api_version', "2018-05-01") # type: str +def build_resource_groups_delete_request(resource_group_name: str, subscription_id: str, **kwargs: Any) -> HttpRequest: + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2018-05-01")) # type: str # Construct URL _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}") path_format_arguments = { - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._\(\)]+$'), - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), + "resourceGroupName": _SERIALIZER.url( + "resource_group_name", resource_group_name, "str", max_length=90, min_length=1, pattern=r"^[-\w\._\(\)]+$" + ), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), } _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') - - return HttpRequest( - method="DELETE", - url=_url, - params=_query_parameters, - **kwargs - ) + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") + return HttpRequest(method="DELETE", url=_url, params=_params, **kwargs) -def build_resource_groups_get_request( - resource_group_name: str, - subscription_id: str, - **kwargs: Any -) -> HttpRequest: - api_version = kwargs.pop('api_version', "2018-05-01") # type: str - accept = "application/json" +def build_resource_groups_get_request(resource_group_name: str, subscription_id: str, **kwargs: Any) -> HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2018-05-01")) # type: str + accept = _headers.pop("Accept", "application/json") + # Construct URL _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}") path_format_arguments = { - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._\(\)]+$'), - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), + "resourceGroupName": _SERIALIZER.url( + "resource_group_name", resource_group_name, "str", max_length=90, min_length=1, pattern=r"^[-\w\._\(\)]+$" + ), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), } _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') - - return HttpRequest( - method="GET", - url=_url, - params=_query_parameters, - headers=_header_parameters, - **kwargs - ) + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) -def build_resource_groups_update_request( - resource_group_name: str, - subscription_id: str, - *, - json: JSONType = None, - content: Any = None, - **kwargs: Any -) -> HttpRequest: - api_version = kwargs.pop('api_version', "2018-05-01") # type: str - content_type = kwargs.pop('content_type', None) # type: Optional[str] - accept = "application/json" +def build_resource_groups_update_request(resource_group_name: str, subscription_id: str, **kwargs: Any) -> HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2018-05-01")) # type: str + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + accept = _headers.pop("Accept", "application/json") + # Construct URL _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}") path_format_arguments = { - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._\(\)]+$'), - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), + "resourceGroupName": _SERIALIZER.url( + "resource_group_name", resource_group_name, "str", max_length=90, min_length=1, pattern=r"^[-\w\._\(\)]+$" + ), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), } _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] if content_type is not None: - _header_parameters['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') - _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') - - return HttpRequest( - method="PATCH", - url=_url, - params=_query_parameters, - headers=_header_parameters, - json=json, - content=content, - **kwargs - ) + _headers["Content-Type"] = _SERIALIZER.header("content_type", content_type, "str") + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="PATCH", url=_url, params=_params, headers=_headers, **kwargs) def build_resource_groups_export_template_request( - resource_group_name: str, - subscription_id: str, - *, - json: JSONType = None, - content: Any = None, - **kwargs: Any + resource_group_name: str, subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2018-05-01") # type: str - content_type = kwargs.pop('content_type', None) # type: Optional[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", "2018-05-01")) # type: str + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + accept = _headers.pop("Accept", "application/json") - accept = "application/json" # Construct URL - _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/exportTemplate") + _url = kwargs.pop( + "template_url", "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/exportTemplate" + ) path_format_arguments = { - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._\(\)]+$'), - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), + "resourceGroupName": _SERIALIZER.url( + "resource_group_name", resource_group_name, "str", max_length=90, min_length=1, pattern=r"^[-\w\._\(\)]+$" + ), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), } _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] if content_type is not None: - _header_parameters['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') - _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') - - return HttpRequest( - method="POST", - url=_url, - params=_query_parameters, - headers=_header_parameters, - json=json, - content=content, - **kwargs - ) + _headers["Content-Type"] = _SERIALIZER.header("content_type", content_type, "str") + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="POST", url=_url, params=_params, headers=_headers, **kwargs) def build_resource_groups_list_request( - subscription_id: str, - *, - filter: Optional[str] = None, - top: Optional[int] = None, - **kwargs: Any + subscription_id: str, *, filter: Optional[str] = None, top: Optional[int] = None, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2018-05-01") # type: 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", "2018-05-01")) # type: str + accept = _headers.pop("Accept", "application/json") - accept = "application/json" # Construct URL _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourcegroups") path_format_arguments = { - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), } _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] if filter is not None: - _query_parameters['$filter'] = _SERIALIZER.query("filter", filter, 'str') + _params["$filter"] = _SERIALIZER.query("filter", filter, "str") if top is not None: - _query_parameters['$top'] = _SERIALIZER.query("top", top, 'int') - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["$top"] = _SERIALIZER.query("top", top, "int") + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') - - return HttpRequest( - method="GET", - url=_url, - params=_query_parameters, - headers=_header_parameters, - **kwargs - ) + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) -def build_tags_delete_value_request( - tag_name: str, - tag_value: str, - subscription_id: str, - **kwargs: Any -) -> HttpRequest: - api_version = kwargs.pop('api_version', "2018-05-01") # type: str +def build_tags_delete_value_request(tag_name: str, tag_value: str, subscription_id: str, **kwargs: Any) -> HttpRequest: + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2018-05-01")) # type: str # Construct URL _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/tagNames/{tagName}/tagValues/{tagValue}") path_format_arguments = { - "tagName": _SERIALIZER.url("tag_name", tag_name, 'str'), - "tagValue": _SERIALIZER.url("tag_value", tag_value, 'str'), - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), + "tagName": _SERIALIZER.url("tag_name", tag_name, "str"), + "tagValue": _SERIALIZER.url("tag_value", tag_value, "str"), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), } _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') - - return HttpRequest( - method="DELETE", - url=_url, - params=_query_parameters, - **kwargs - ) + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") + + return HttpRequest(method="DELETE", url=_url, params=_params, **kwargs) def build_tags_create_or_update_value_request( - tag_name: str, - tag_value: str, - subscription_id: str, - **kwargs: Any + tag_name: str, tag_value: str, subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2018-05-01") # type: 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", "2018-05-01")) # type: str + accept = _headers.pop("Accept", "application/json") - accept = "application/json" # Construct URL _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/tagNames/{tagName}/tagValues/{tagValue}") path_format_arguments = { - "tagName": _SERIALIZER.url("tag_name", tag_name, 'str'), - "tagValue": _SERIALIZER.url("tag_value", tag_value, 'str'), - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), + "tagName": _SERIALIZER.url("tag_name", tag_name, "str"), + "tagValue": _SERIALIZER.url("tag_value", tag_value, "str"), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), } _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') - - return HttpRequest( - method="PUT", - url=_url, - params=_query_parameters, - headers=_header_parameters, - **kwargs - ) + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + return HttpRequest(method="PUT", url=_url, params=_params, headers=_headers, **kwargs) -def build_tags_create_or_update_request( - tag_name: str, - subscription_id: str, - **kwargs: Any -) -> HttpRequest: - api_version = kwargs.pop('api_version', "2018-05-01") # type: str - accept = "application/json" +def build_tags_create_or_update_request(tag_name: str, subscription_id: str, **kwargs: Any) -> HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2018-05-01")) # type: str + accept = _headers.pop("Accept", "application/json") + # Construct URL _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/tagNames/{tagName}") path_format_arguments = { - "tagName": _SERIALIZER.url("tag_name", tag_name, 'str'), - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), + "tagName": _SERIALIZER.url("tag_name", tag_name, "str"), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), } _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') - - return HttpRequest( - method="PUT", - url=_url, - params=_query_parameters, - headers=_header_parameters, - **kwargs - ) + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + return HttpRequest(method="PUT", url=_url, params=_params, headers=_headers, **kwargs) -def build_tags_delete_request( - tag_name: str, - subscription_id: str, - **kwargs: Any -) -> HttpRequest: - api_version = kwargs.pop('api_version', "2018-05-01") # type: str +def build_tags_delete_request(tag_name: str, subscription_id: str, **kwargs: Any) -> HttpRequest: + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2018-05-01")) # type: str # Construct URL _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/tagNames/{tagName}") path_format_arguments = { - "tagName": _SERIALIZER.url("tag_name", tag_name, 'str'), - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), + "tagName": _SERIALIZER.url("tag_name", tag_name, "str"), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), } _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') - - return HttpRequest( - method="DELETE", - url=_url, - params=_query_parameters, - **kwargs - ) + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") + return HttpRequest(method="DELETE", url=_url, params=_params, **kwargs) -def build_tags_list_request( - subscription_id: str, - **kwargs: Any -) -> HttpRequest: - api_version = kwargs.pop('api_version', "2018-05-01") # type: str - accept = "application/json" +def build_tags_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", "2018-05-01")) # type: str + accept = _headers.pop("Accept", "application/json") + # Construct URL _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/tagNames") path_format_arguments = { - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), } _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') - - return HttpRequest( - method="GET", - url=_url, - params=_query_parameters, - headers=_header_parameters, - **kwargs - ) + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) def build_deployment_operations_get_at_subscription_scope_request( - deployment_name: str, - operation_id: str, - subscription_id: str, - **kwargs: Any + deployment_name: str, operation_id: str, subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2018-05-01") # type: 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", "2018-05-01")) # type: str + accept = _headers.pop("Accept", "application/json") - accept = "application/json" # Construct URL - _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/providers/Microsoft.Resources/deployments/{deploymentName}/operations/{operationId}") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/providers/Microsoft.Resources/deployments/{deploymentName}/operations/{operationId}", + ) # pylint: disable=line-too-long path_format_arguments = { - "deploymentName": _SERIALIZER.url("deployment_name", deployment_name, 'str', max_length=64, min_length=1, pattern=r'^[-\w\._\(\)]+$'), - "operationId": _SERIALIZER.url("operation_id", operation_id, 'str'), - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), + "deploymentName": _SERIALIZER.url( + "deployment_name", deployment_name, "str", max_length=64, min_length=1, pattern=r"^[-\w\._\(\)]+$" + ), + "operationId": _SERIALIZER.url("operation_id", operation_id, "str"), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), } _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') - - return HttpRequest( - method="GET", - url=_url, - params=_query_parameters, - headers=_header_parameters, - **kwargs - ) + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) def build_deployment_operations_list_at_subscription_scope_request( - deployment_name: str, - subscription_id: str, - *, - top: Optional[int] = None, - **kwargs: Any + deployment_name: str, subscription_id: str, *, top: Optional[int] = None, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2018-05-01") # type: 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", "2018-05-01")) # type: str + accept = _headers.pop("Accept", "application/json") - accept = "application/json" # Construct URL - _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/providers/Microsoft.Resources/deployments/{deploymentName}/operations") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/providers/Microsoft.Resources/deployments/{deploymentName}/operations", + ) # pylint: disable=line-too-long path_format_arguments = { - "deploymentName": _SERIALIZER.url("deployment_name", deployment_name, 'str', max_length=64, min_length=1, pattern=r'^[-\w\._\(\)]+$'), - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), + "deploymentName": _SERIALIZER.url( + "deployment_name", deployment_name, "str", max_length=64, min_length=1, pattern=r"^[-\w\._\(\)]+$" + ), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), } _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] if top is not None: - _query_parameters['$top'] = _SERIALIZER.query("top", top, 'int') - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["$top"] = _SERIALIZER.query("top", top, "int") + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') - - return HttpRequest( - method="GET", - url=_url, - params=_query_parameters, - headers=_header_parameters, - **kwargs - ) + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) def build_deployment_operations_get_request( - resource_group_name: str, - deployment_name: str, - operation_id: str, - subscription_id: str, - **kwargs: Any + resource_group_name: str, deployment_name: str, operation_id: str, subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2018-05-01") # type: 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", "2018-05-01")) # type: str + accept = _headers.pop("Accept", "application/json") - accept = "application/json" # Construct URL - _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/deployments/{deploymentName}/operations/{operationId}") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/deployments/{deploymentName}/operations/{operationId}", + ) # pylint: disable=line-too-long path_format_arguments = { - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._\(\)]+$'), - "deploymentName": _SERIALIZER.url("deployment_name", deployment_name, 'str', max_length=64, min_length=1, pattern=r'^[-\w\._\(\)]+$'), - "operationId": _SERIALIZER.url("operation_id", operation_id, 'str'), - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), + "resourceGroupName": _SERIALIZER.url( + "resource_group_name", resource_group_name, "str", max_length=90, min_length=1, pattern=r"^[-\w\._\(\)]+$" + ), + "deploymentName": _SERIALIZER.url( + "deployment_name", deployment_name, "str", max_length=64, min_length=1, pattern=r"^[-\w\._\(\)]+$" + ), + "operationId": _SERIALIZER.url("operation_id", operation_id, "str"), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), } _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') - - return HttpRequest( - method="GET", - url=_url, - params=_query_parameters, - headers=_header_parameters, - **kwargs - ) + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) def build_deployment_operations_list_request( - resource_group_name: str, - deployment_name: str, - subscription_id: str, - *, - top: Optional[int] = None, - **kwargs: Any + resource_group_name: str, deployment_name: str, subscription_id: str, *, top: Optional[int] = None, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2018-05-01") # type: 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", "2018-05-01")) # type: str + accept = _headers.pop("Accept", "application/json") - accept = "application/json" # Construct URL - _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/deployments/{deploymentName}/operations") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/deployments/{deploymentName}/operations", + ) # pylint: disable=line-too-long path_format_arguments = { - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._\(\)]+$'), - "deploymentName": _SERIALIZER.url("deployment_name", deployment_name, 'str', max_length=64, min_length=1, pattern=r'^[-\w\._\(\)]+$'), - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), + "resourceGroupName": _SERIALIZER.url( + "resource_group_name", resource_group_name, "str", max_length=90, min_length=1, pattern=r"^[-\w\._\(\)]+$" + ), + "deploymentName": _SERIALIZER.url( + "deployment_name", deployment_name, "str", max_length=64, min_length=1, pattern=r"^[-\w\._\(\)]+$" + ), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), } _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] if top is not None: - _query_parameters['$top'] = _SERIALIZER.query("top", top, 'int') - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["$top"] = _SERIALIZER.query("top", top, "int") + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') - - return HttpRequest( - method="GET", - url=_url, - params=_query_parameters, - headers=_header_parameters, - **kwargs - ) + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) -class Operations(object): - """Operations operations. - You should not instantiate this class directly. Instead, you should create a Client instance that - instantiates it for you and attaches it as an attribute. +class Operations: + """ + .. warning:: + **DO NOT** instantiate this class directly. - :ivar models: Alias to model classes used in this operation group. - :type models: ~azure.mgmt.resource.resources.v2018_05_01.models - :param client: Client for service requests. - :param config: Configuration of service client. - :param serializer: An object model serializer. - :param deserializer: An object model deserializer. + Instead, you should access the following operations through + :class:`~azure.mgmt.resource.resources.v2018_05_01.ResourceManagementClient`'s + :attr:`operations` attribute. """ models = _models - def __init__(self, client, config, serializer, deserializer): - self._client = client - self._serialize = serializer - self._deserialize = deserializer - self._config = config + def __init__(self, *args, **kwargs): + input_args = list(args) + self._client = input_args.pop(0) if input_args else kwargs.pop("client") + self._config = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") @distributed_trace - def list( - self, - **kwargs: Any - ) -> Iterable["_models.OperationListResult"]: + def list(self, **kwargs: Any) -> Iterable["_models.Operation"]: """Lists all of the available Microsoft.Resources REST API operations. :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either OperationListResult or the result of cls(response) + :return: An iterator like instance of either Operation or the result of cls(response) :rtype: - ~azure.core.paging.ItemPaged[~azure.mgmt.resource.resources.v2018_05_01.models.OperationListResult] - :raises: ~azure.core.exceptions.HttpResponseError + ~azure.core.paging.ItemPaged[~azure.mgmt.resource.resources.v2018_05_01.models.Operation] + :raises ~azure.core.exceptions.HttpResponseError: """ - api_version = kwargs.pop('api_version', "2018-05-01") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2018-05-01")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[_models.OperationListResult] - cls = kwargs.pop('cls', None) # type: ClsType["_models.OperationListResult"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) + def prepare_request(next_link=None): if not next_link: - + request = build_operations_list_request( api_version=api_version, - template_url=self.list.metadata['url'], + template_url=self.list.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore else: - - request = build_operations_list_request( - template_url=next_link, - ) + # make call to next link with the client's api-version + _parsed_next_link = urlparse(next_link) + _next_request_params = case_insensitive_dict(parse_qs(_parsed_next_link.query)) + _next_request_params["api-version"] = self._config.api_version + request = HttpRequest("GET", urljoin(next_link, _parsed_next_link.path), params=_next_request_params) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore request.method = "GET" return request @@ -1982,10 +1709,8 @@ def extract_data(pipeline_response): def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) response = pipeline_response.http_response @@ -1995,61 +1720,62 @@ def get_next(next_link=None): return pipeline_response + return ItemPaged(get_next, extract_data) - return ItemPaged( - get_next, extract_data - ) - list.metadata = {'url': "/providers/Microsoft.Resources/operations"} # type: ignore -class DeploymentsOperations(object): # pylint: disable=too-many-public-methods - """DeploymentsOperations operations. - - You should not instantiate this class directly. Instead, you should create a Client instance that - instantiates it for you and attaches it as an attribute. - - :ivar models: Alias to model classes used in this operation group. - :type models: ~azure.mgmt.resource.resources.v2018_05_01.models - :param client: Client for service requests. - :param config: Configuration of service client. - :param serializer: An object model serializer. - :param deserializer: An object model deserializer. + list.metadata = {"url": "/providers/Microsoft.Resources/operations"} # type: ignore + + +class DeploymentsOperations: # pylint: disable=too-many-public-methods + """ + .. warning:: + **DO NOT** instantiate this class directly. + + Instead, you should access the following operations through + :class:`~azure.mgmt.resource.resources.v2018_05_01.ResourceManagementClient`'s + :attr:`deployments` attribute. """ models = _models - def __init__(self, client, config, serializer, deserializer): - self._client = client - self._serialize = serializer - self._deserialize = deserializer - self._config = config + def __init__(self, *args, **kwargs): + input_args = list(args) + self._client = input_args.pop(0) if input_args else kwargs.pop("client") + self._config = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") def _delete_at_subscription_scope_initial( # pylint: disable=inconsistent-return-statements - self, - deployment_name: str, - **kwargs: Any + self, deployment_name: str, **kwargs: Any ) -> None: - cls = kwargs.pop('cls', None) # type: ClsType[None] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) - api_version = kwargs.pop('api_version', "2018-05-01") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - request = build_deployments_delete_at_subscription_scope_request_initial( + api_version = kwargs.pop("api_version", _params.pop("api-version", "2018-05-01")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[None] + + request = build_deployments_delete_at_subscription_scope_request( deployment_name=deployment_name, subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self._delete_at_subscription_scope_initial.metadata['url'], + template_url=self._delete_at_subscription_scope_initial.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [202, 204]: @@ -2059,15 +1785,10 @@ def _delete_at_subscription_scope_initial( # pylint: disable=inconsistent-retur if cls: return cls(pipeline_response, None, {}) - _delete_at_subscription_scope_initial.metadata = {'url': "/subscriptions/{subscriptionId}/providers/Microsoft.Resources/deployments/{deploymentName}"} # type: ignore - + _delete_at_subscription_scope_initial.metadata = {"url": "/subscriptions/{subscriptionId}/providers/Microsoft.Resources/deployments/{deploymentName}"} # type: ignore @distributed_trace - def begin_delete_at_subscription_scope( # pylint: disable=inconsistent-return-statements - self, - deployment_name: str, - **kwargs: Any - ) -> LROPoller[None]: + def begin_delete_at_subscription_scope(self, deployment_name: str, **kwargs: Any) -> LROPoller[None]: """Deletes a deployment from the deployment history. A template deployment that is currently running cannot be deleted. Deleting a template @@ -2078,7 +1799,7 @@ def begin_delete_at_subscription_scope( # pylint: disable=inconsistent-return-s process finishes, the URI in the Location header returns a status of 204 on success. If the asynchronous request failed, the URI in the Location header returns an error-level status code. - :param deployment_name: The name of the deployment to delete. + :param deployment_name: The name of the deployment to delete. Required. :type deployment_name: str :keyword callable cls: A custom type or function that will be passed the direct response :keyword str continuation_token: A continuation token to restart a poller from a saved state. @@ -2090,82 +1811,88 @@ def begin_delete_at_subscription_scope( # pylint: disable=inconsistent-return-s Retry-After header is present. :return: An instance of LROPoller that returns either None or the result of cls(response) :rtype: ~azure.core.polling.LROPoller[None] - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - api_version = kwargs.pop('api_version', "2018-05-01") # type: str - polling = kwargs.pop('polling', True) # type: Union[bool, PollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType[None] - lro_delay = kwargs.pop( - 'polling_interval', - self._config.polling_interval - ) - cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2018-05-01")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[None] + polling = kwargs.pop("polling", True) # type: Union[bool, PollingMethod] + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token = kwargs.pop("continuation_token", None) # type: Optional[str] if cont_token is None: - raw_result = self._delete_at_subscription_scope_initial( + raw_result = self._delete_at_subscription_scope_initial( # type: ignore deployment_name=deployment_name, api_version=api_version, - cls=lambda x,y,z: x, + cls=lambda x, y, z: x, + headers=_headers, + params=_params, **kwargs ) - kwargs.pop('error_map', None) + kwargs.pop("error_map", None) - def get_long_running_output(pipeline_response): + def get_long_running_output(pipeline_response): # pylint: disable=inconsistent-return-statements if cls: return cls(pipeline_response, None, {}) - - if polling is True: polling_method = ARMPolling(lro_delay, **kwargs) - elif polling is False: polling_method = NoPolling() - else: polling_method = polling + if polling is True: + polling_method = cast(PollingMethod, ARMPolling(lro_delay, **kwargs)) # type: PollingMethod + elif polling is False: + polling_method = cast(PollingMethod, NoPolling()) + else: + polling_method = polling if cont_token: return LROPoller.from_continuation_token( polling_method=polling_method, continuation_token=cont_token, client=self._client, - deserialization_callback=get_long_running_output + deserialization_callback=get_long_running_output, ) return LROPoller(self._client, raw_result, get_long_running_output, polling_method) - begin_delete_at_subscription_scope.metadata = {'url': "/subscriptions/{subscriptionId}/providers/Microsoft.Resources/deployments/{deploymentName}"} # type: ignore + begin_delete_at_subscription_scope.metadata = {"url": "/subscriptions/{subscriptionId}/providers/Microsoft.Resources/deployments/{deploymentName}"} # type: ignore @distributed_trace - def check_existence_at_subscription_scope( - self, - deployment_name: str, - **kwargs: Any - ) -> bool: + def check_existence_at_subscription_scope(self, deployment_name: str, **kwargs: Any) -> bool: """Checks whether the deployment exists. - :param deployment_name: The name of the deployment to check. + :param deployment_name: The name of the deployment to check. Required. :type deployment_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: bool, or the result of cls(response) + :return: bool or the result of cls(response) :rtype: bool - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType[None] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) - api_version = kwargs.pop('api_version', "2018-05-01") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2018-05-01")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[None] - request = build_deployments_check_existence_at_subscription_scope_request( deployment_name=deployment_name, subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.check_existence_at_subscription_scope.metadata['url'], + template_url=self.check_existence_at_subscription_scope.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [204, 404]: @@ -2176,42 +1903,52 @@ def check_existence_at_subscription_scope( return cls(pipeline_response, None, {}) return 200 <= response.status_code <= 299 - check_existence_at_subscription_scope.metadata = {'url': "/subscriptions/{subscriptionId}/providers/Microsoft.Resources/deployments/{deploymentName}"} # type: ignore - + check_existence_at_subscription_scope.metadata = {"url": "/subscriptions/{subscriptionId}/providers/Microsoft.Resources/deployments/{deploymentName}"} # type: ignore def _create_or_update_at_subscription_scope_initial( - self, - deployment_name: str, - parameters: "_models.Deployment", - **kwargs: Any - ) -> "_models.DeploymentExtended": - cls = kwargs.pop('cls', None) # type: ClsType["_models.DeploymentExtended"] + self, deployment_name: str, parameters: Union[_models.Deployment, IO], **kwargs: Any + ) -> _models.DeploymentExtended: error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) - api_version = kwargs.pop('api_version', "2018-05-01") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - _json = self._serialize.body(parameters, 'Deployment') + api_version = kwargs.pop("api_version", _params.pop("api-version", "2018-05-01")) # type: str + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.DeploymentExtended] - request = build_deployments_create_or_update_at_subscription_scope_request_initial( + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(parameters, (IO, bytes)): + _content = parameters + else: + _json = self._serialize.body(parameters, "Deployment") + + request = build_deployments_create_or_update_at_subscription_scope_request( deployment_name=deployment_name, subscription_id=self._config.subscription_id, api_version=api_version, content_type=content_type, json=_json, - template_url=self._create_or_update_at_subscription_scope_initial.metadata['url'], + content=_content, + template_url=self._create_or_update_at_subscription_scope_initial.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200, 201]: @@ -2219,34 +1956,38 @@ def _create_or_update_at_subscription_scope_initial( raise HttpResponseError(response=response, error_format=ARMErrorFormat) if response.status_code == 200: - deserialized = self._deserialize('DeploymentExtended', pipeline_response) + deserialized = self._deserialize("DeploymentExtended", pipeline_response) if response.status_code == 201: - deserialized = self._deserialize('DeploymentExtended', pipeline_response) + deserialized = self._deserialize("DeploymentExtended", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - _create_or_update_at_subscription_scope_initial.metadata = {'url': "/subscriptions/{subscriptionId}/providers/Microsoft.Resources/deployments/{deploymentName}"} # type: ignore + _create_or_update_at_subscription_scope_initial.metadata = {"url": "/subscriptions/{subscriptionId}/providers/Microsoft.Resources/deployments/{deploymentName}"} # type: ignore - - @distributed_trace + @overload def begin_create_or_update_at_subscription_scope( self, deployment_name: str, - parameters: "_models.Deployment", + parameters: _models.Deployment, + *, + content_type: str = "application/json", **kwargs: Any - ) -> LROPoller["_models.DeploymentExtended"]: + ) -> LROPoller[_models.DeploymentExtended]: """Deploys resources at subscription scope. You can provide the template and parameters directly in the request or link to JSON files. - :param deployment_name: The name of the deployment. + :param deployment_name: The name of the deployment. Required. :type deployment_name: str - :param parameters: Additional parameters supplied to the operation. + :param parameters: Additional parameters supplied to the operation. Required. :type parameters: ~azure.mgmt.resource.resources.v2018_05_01.models.Deployment + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str :keyword callable cls: A custom type or function that will be passed the direct response :keyword str continuation_token: A continuation token to restart a poller from a saved state. :keyword polling: By default, your polling method will be ARMPolling. Pass in False for this @@ -2259,109 +2000,172 @@ def begin_create_or_update_at_subscription_scope( cls(response) :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.resource.resources.v2018_05_01.models.DeploymentExtended] - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - api_version = kwargs.pop('api_version', "2018-05-01") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] - polling = kwargs.pop('polling', True) # type: Union[bool, PollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType["_models.DeploymentExtended"] - lro_delay = kwargs.pop( - 'polling_interval', - self._config.polling_interval - ) - cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] + + @overload + def begin_create_or_update_at_subscription_scope( + self, deployment_name: str, parameters: IO, *, content_type: str = "application/json", **kwargs: Any + ) -> LROPoller[_models.DeploymentExtended]: + """Deploys resources at subscription scope. + + You can provide the template and parameters directly in the request or link to JSON files. + + :param deployment_name: The name of the deployment. Required. + :type deployment_name: str + :param parameters: Additional parameters supplied to the operation. Required. + :type parameters: IO + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be ARMPolling. Pass in False for this + operation to not poll, or pass in your own initialized polling object for a personal polling + strategy. + :paramtype polling: bool or ~azure.core.polling.PollingMethod + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of LROPoller that returns either DeploymentExtended or the result of + cls(response) + :rtype: + ~azure.core.polling.LROPoller[~azure.mgmt.resource.resources.v2018_05_01.models.DeploymentExtended] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace + def begin_create_or_update_at_subscription_scope( + self, deployment_name: str, parameters: Union[_models.Deployment, IO], **kwargs: Any + ) -> LROPoller[_models.DeploymentExtended]: + """Deploys resources at subscription scope. + + You can provide the template and parameters directly in the request or link to JSON files. + + :param deployment_name: The name of the deployment. Required. + :type deployment_name: str + :param parameters: Additional parameters supplied to the operation. Is either a model type or a + IO type. Required. + :type parameters: ~azure.mgmt.resource.resources.v2018_05_01.models.Deployment or IO + :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. + Default value is None. + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be ARMPolling. Pass in False for this + operation to not poll, or pass in your own initialized polling object for a personal polling + strategy. + :paramtype polling: bool or ~azure.core.polling.PollingMethod + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of LROPoller that returns either DeploymentExtended or the result of + cls(response) + :rtype: + ~azure.core.polling.LROPoller[~azure.mgmt.resource.resources.v2018_05_01.models.DeploymentExtended] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _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", "2018-05-01")) # type: str + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.DeploymentExtended] + polling = kwargs.pop("polling", True) # type: Union[bool, PollingMethod] + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token = kwargs.pop("continuation_token", None) # type: Optional[str] if cont_token is None: - raw_result = self._create_or_update_at_subscription_scope_initial( + raw_result = self._create_or_update_at_subscription_scope_initial( # type: ignore deployment_name=deployment_name, parameters=parameters, api_version=api_version, content_type=content_type, - cls=lambda x,y,z: x, + cls=lambda x, y, z: x, + headers=_headers, + params=_params, **kwargs ) - kwargs.pop('error_map', None) + kwargs.pop("error_map", None) def get_long_running_output(pipeline_response): - response = pipeline_response.http_response - deserialized = self._deserialize('DeploymentExtended', pipeline_response) + deserialized = self._deserialize("DeploymentExtended", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - - if polling is True: polling_method = ARMPolling(lro_delay, **kwargs) - elif polling is False: polling_method = NoPolling() - else: polling_method = polling + if polling is True: + polling_method = cast(PollingMethod, ARMPolling(lro_delay, **kwargs)) # type: PollingMethod + elif polling is False: + polling_method = cast(PollingMethod, NoPolling()) + else: + polling_method = polling if cont_token: return LROPoller.from_continuation_token( polling_method=polling_method, continuation_token=cont_token, client=self._client, - deserialization_callback=get_long_running_output + deserialization_callback=get_long_running_output, ) return LROPoller(self._client, raw_result, get_long_running_output, polling_method) - begin_create_or_update_at_subscription_scope.metadata = {'url': "/subscriptions/{subscriptionId}/providers/Microsoft.Resources/deployments/{deploymentName}"} # type: ignore + begin_create_or_update_at_subscription_scope.metadata = {"url": "/subscriptions/{subscriptionId}/providers/Microsoft.Resources/deployments/{deploymentName}"} # type: ignore @distributed_trace - def get_at_subscription_scope( - self, - deployment_name: str, - **kwargs: Any - ) -> "_models.DeploymentExtended": + def get_at_subscription_scope(self, deployment_name: str, **kwargs: Any) -> _models.DeploymentExtended: """Gets a deployment. - :param deployment_name: The name of the deployment to get. + :param deployment_name: The name of the deployment to get. Required. :type deployment_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: DeploymentExtended, or the result of cls(response) + :return: DeploymentExtended or the result of cls(response) :rtype: ~azure.mgmt.resource.resources.v2018_05_01.models.DeploymentExtended - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.DeploymentExtended"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + 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', "2018-05-01") # type: str + api_version = kwargs.pop("api_version", _params.pop("api-version", "2018-05-01")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[_models.DeploymentExtended] - request = build_deployments_get_at_subscription_scope_request( deployment_name=deployment_name, subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.get_at_subscription_scope.metadata['url'], + template_url=self.get_at_subscription_scope.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) - deserialized = self._deserialize('DeploymentExtended', pipeline_response) + deserialized = self._deserialize("DeploymentExtended", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - get_at_subscription_scope.metadata = {'url': "/subscriptions/{subscriptionId}/providers/Microsoft.Resources/deployments/{deploymentName}"} # type: ignore - + get_at_subscription_scope.metadata = {"url": "/subscriptions/{subscriptionId}/providers/Microsoft.Resources/deployments/{deploymentName}"} # type: ignore @distributed_trace def cancel_at_subscription_scope( # pylint: disable=inconsistent-return-statements - self, - deployment_name: str, - **kwargs: Any + self, deployment_name: str, **kwargs: Any ) -> None: """Cancels a currently running template deployment. @@ -2370,36 +2174,42 @@ def cancel_at_subscription_scope( # pylint: disable=inconsistent-return-stateme deployment stops the currently running template deployment and leaves the resources partially deployed. - :param deployment_name: The name of the deployment to cancel. + :param deployment_name: The name of the deployment to cancel. Required. :type deployment_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: None, or the result of cls(response) + :return: None or the result of cls(response) :rtype: None - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType[None] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + 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', "2018-05-01") # type: str + api_version = kwargs.pop("api_version", _params.pop("api-version", "2018-05-01")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[None] - request = build_deployments_cancel_at_subscription_scope_request( deployment_name=deployment_name, subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.cancel_at_subscription_scope.metadata['url'], + template_url=self.cancel_at_subscription_scope.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [204]: @@ -2409,38 +2219,94 @@ def cancel_at_subscription_scope( # pylint: disable=inconsistent-return-stateme if cls: return cls(pipeline_response, None, {}) - cancel_at_subscription_scope.metadata = {'url': "/subscriptions/{subscriptionId}/providers/Microsoft.Resources/deployments/{deploymentName}/cancel"} # type: ignore - + cancel_at_subscription_scope.metadata = {"url": "/subscriptions/{subscriptionId}/providers/Microsoft.Resources/deployments/{deploymentName}/cancel"} # type: ignore - @distributed_trace + @overload def validate_at_subscription_scope( self, deployment_name: str, - parameters: "_models.Deployment", + parameters: _models.Deployment, + *, + content_type: str = "application/json", **kwargs: Any - ) -> "_models.DeploymentValidateResult": + ) -> _models.DeploymentValidateResult: """Validates whether the specified template is syntactically correct and will be accepted by Azure Resource Manager.. - :param deployment_name: The name of the deployment. + :param deployment_name: The name of the deployment. Required. :type deployment_name: str - :param parameters: Parameters to validate. + :param parameters: Parameters to validate. Required. :type parameters: ~azure.mgmt.resource.resources.v2018_05_01.models.Deployment + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: DeploymentValidateResult or the result of cls(response) + :rtype: ~azure.mgmt.resource.resources.v2018_05_01.models.DeploymentValidateResult + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + def validate_at_subscription_scope( + self, deployment_name: str, parameters: IO, *, content_type: str = "application/json", **kwargs: Any + ) -> _models.DeploymentValidateResult: + """Validates whether the specified template is syntactically correct and will be accepted by Azure + Resource Manager.. + + :param deployment_name: The name of the deployment. Required. + :type deployment_name: str + :param parameters: Parameters to validate. Required. + :type parameters: IO + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: DeploymentValidateResult or the result of cls(response) + :rtype: ~azure.mgmt.resource.resources.v2018_05_01.models.DeploymentValidateResult + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace + def validate_at_subscription_scope( + self, deployment_name: str, parameters: Union[_models.Deployment, IO], **kwargs: Any + ) -> _models.DeploymentValidateResult: + """Validates whether the specified template is syntactically correct and will be accepted by Azure + Resource Manager.. + + :param deployment_name: The name of the deployment. Required. + :type deployment_name: str + :param parameters: Parameters to validate. Is either a model type or a IO type. Required. + :type parameters: ~azure.mgmt.resource.resources.v2018_05_01.models.Deployment or IO + :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. + Default value is None. + :paramtype content_type: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: DeploymentValidateResult, or the result of cls(response) + :return: DeploymentValidateResult or the result of cls(response) :rtype: ~azure.mgmt.resource.resources.v2018_05_01.models.DeploymentValidateResult - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.DeploymentValidateResult"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', "2018-05-01") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + api_version = kwargs.pop("api_version", _params.pop("api-version", "2018-05-01")) # type: str + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.DeploymentValidateResult] - _json = self._serialize.body(parameters, 'Deployment') + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(parameters, (IO, bytes)): + _content = parameters + else: + _json = self._serialize.body(parameters, "Deployment") request = build_deployments_validate_at_subscription_scope_request( deployment_name=deployment_name, @@ -2448,16 +2314,18 @@ def validate_at_subscription_scope( api_version=api_version, content_type=content_type, json=_json, - template_url=self.validate_at_subscription_scope.metadata['url'], + content=_content, + template_url=self.validate_at_subscription_scope.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200, 400]: @@ -2465,80 +2333,79 @@ def validate_at_subscription_scope( raise HttpResponseError(response=response, error_format=ARMErrorFormat) if response.status_code == 200: - deserialized = self._deserialize('DeploymentValidateResult', pipeline_response) + deserialized = self._deserialize("DeploymentValidateResult", pipeline_response) if response.status_code == 400: - deserialized = self._deserialize('DeploymentValidateResult', pipeline_response) + deserialized = self._deserialize("DeploymentValidateResult", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - validate_at_subscription_scope.metadata = {'url': "/subscriptions/{subscriptionId}/providers/Microsoft.Resources/deployments/{deploymentName}/validate"} # type: ignore - + validate_at_subscription_scope.metadata = {"url": "/subscriptions/{subscriptionId}/providers/Microsoft.Resources/deployments/{deploymentName}/validate"} # type: ignore @distributed_trace def export_template_at_subscription_scope( - self, - deployment_name: str, - **kwargs: Any - ) -> "_models.DeploymentExportResult": + self, deployment_name: str, **kwargs: Any + ) -> _models.DeploymentExportResult: """Exports the template used for specified deployment. - :param deployment_name: The name of the deployment from which to get the template. + :param deployment_name: The name of the deployment from which to get the template. Required. :type deployment_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: DeploymentExportResult, or the result of cls(response) + :return: DeploymentExportResult or the result of cls(response) :rtype: ~azure.mgmt.resource.resources.v2018_05_01.models.DeploymentExportResult - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.DeploymentExportResult"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + 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', "2018-05-01") # type: str + api_version = kwargs.pop("api_version", _params.pop("api-version", "2018-05-01")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[_models.DeploymentExportResult] - request = build_deployments_export_template_at_subscription_scope_request( deployment_name=deployment_name, subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.export_template_at_subscription_scope.metadata['url'], + template_url=self.export_template_at_subscription_scope.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) - deserialized = self._deserialize('DeploymentExportResult', pipeline_response) + deserialized = self._deserialize("DeploymentExportResult", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - export_template_at_subscription_scope.metadata = {'url': "/subscriptions/{subscriptionId}/providers/Microsoft.Resources/deployments/{deploymentName}/exportTemplate"} # type: ignore - + export_template_at_subscription_scope.metadata = {"url": "/subscriptions/{subscriptionId}/providers/Microsoft.Resources/deployments/{deploymentName}/exportTemplate"} # type: ignore @distributed_trace def list_at_subscription_scope( - self, - filter: Optional[str] = None, - top: Optional[int] = None, - **kwargs: Any - ) -> Iterable["_models.DeploymentListResult"]: + self, filter: Optional[str] = None, top: Optional[int] = None, **kwargs: Any + ) -> Iterable["_models.DeploymentExtended"]: """Get all the deployments for a subscription. :param filter: The filter to apply on the operation. For example, you can use @@ -2548,40 +2415,48 @@ def list_at_subscription_scope( value is None. :type top: int :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either DeploymentListResult or the result of - cls(response) + :return: An iterator like instance of either DeploymentExtended or the result of cls(response) :rtype: - ~azure.core.paging.ItemPaged[~azure.mgmt.resource.resources.v2018_05_01.models.DeploymentListResult] - :raises: ~azure.core.exceptions.HttpResponseError + ~azure.core.paging.ItemPaged[~azure.mgmt.resource.resources.v2018_05_01.models.DeploymentExtended] + :raises ~azure.core.exceptions.HttpResponseError: """ - api_version = kwargs.pop('api_version', "2018-05-01") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2018-05-01")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[_models.DeploymentListResult] - cls = kwargs.pop('cls', None) # type: ClsType["_models.DeploymentListResult"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) + def prepare_request(next_link=None): if not next_link: - + request = build_deployments_list_at_subscription_scope_request( subscription_id=self._config.subscription_id, - api_version=api_version, filter=filter, top=top, - template_url=self.list_at_subscription_scope.metadata['url'], + api_version=api_version, + template_url=self.list_at_subscription_scope.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore else: - - request = build_deployments_list_at_subscription_scope_request( - subscription_id=self._config.subscription_id, - template_url=next_link, - ) + # make call to next link with the client's api-version + _parsed_next_link = urlparse(next_link) + _next_request_params = case_insensitive_dict(parse_qs(_parsed_next_link.query)) + _next_request_params["api-version"] = self._config.api_version + request = HttpRequest("GET", urljoin(next_link, _parsed_next_link.path), params=_next_request_params) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore request.method = "GET" return request @@ -2595,10 +2470,8 @@ def extract_data(pipeline_response): def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) response = pipeline_response.http_response @@ -2608,42 +2481,43 @@ def get_next(next_link=None): return pipeline_response + return ItemPaged(get_next, extract_data) - return ItemPaged( - get_next, extract_data - ) - list_at_subscription_scope.metadata = {'url': "/subscriptions/{subscriptionId}/providers/Microsoft.Resources/deployments/"} # type: ignore + list_at_subscription_scope.metadata = {"url": "/subscriptions/{subscriptionId}/providers/Microsoft.Resources/deployments/"} # type: ignore def _delete_initial( # pylint: disable=inconsistent-return-statements - self, - resource_group_name: str, - deployment_name: str, - **kwargs: Any + self, resource_group_name: str, deployment_name: str, **kwargs: Any ) -> None: - cls = kwargs.pop('cls', None) # type: ClsType[None] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + 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', "2018-05-01") # type: str + api_version = kwargs.pop("api_version", _params.pop("api-version", "2018-05-01")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[None] - - request = build_deployments_delete_request_initial( + request = build_deployments_delete_request( resource_group_name=resource_group_name, deployment_name=deployment_name, subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self._delete_initial.metadata['url'], + template_url=self._delete_initial.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [202, 204]: @@ -2653,16 +2527,10 @@ 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.Resources/deployments/{deploymentName}"} # type: ignore - + _delete_initial.metadata = {"url": "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/Microsoft.Resources/deployments/{deploymentName}"} # type: ignore @distributed_trace - def begin_delete( # pylint: disable=inconsistent-return-statements - self, - resource_group_name: str, - deployment_name: str, - **kwargs: Any - ) -> LROPoller[None]: + def begin_delete(self, resource_group_name: str, deployment_name: str, **kwargs: Any) -> LROPoller[None]: """Deletes a deployment from the deployment history. A template deployment that is currently running cannot be deleted. Deleting a template @@ -2675,9 +2543,9 @@ def begin_delete( # pylint: disable=inconsistent-return-statements asynchronous request failed, the URI in the Location header returns an error-level status code. :param resource_group_name: The name of the resource group with the deployment to delete. The - name is case insensitive. + name is case insensitive. Required. :type resource_group_name: str - :param deployment_name: The name of the deployment to delete. + :param deployment_name: The name of the deployment to delete. Required. :type deployment_name: str :keyword callable cls: A custom type or function that will be passed the direct response :keyword str continuation_token: A continuation token to restart a poller from a saved state. @@ -2689,88 +2557,93 @@ def begin_delete( # pylint: disable=inconsistent-return-statements Retry-After header is present. :return: An instance of LROPoller that returns either None or the result of cls(response) :rtype: ~azure.core.polling.LROPoller[None] - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - api_version = kwargs.pop('api_version', "2018-05-01") # type: str - polling = kwargs.pop('polling', True) # type: Union[bool, PollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType[None] - lro_delay = kwargs.pop( - 'polling_interval', - self._config.polling_interval - ) - cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2018-05-01")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[None] + polling = kwargs.pop("polling", True) # type: Union[bool, PollingMethod] + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token = kwargs.pop("continuation_token", None) # type: Optional[str] if cont_token is None: - raw_result = self._delete_initial( + raw_result = self._delete_initial( # type: ignore resource_group_name=resource_group_name, deployment_name=deployment_name, api_version=api_version, - cls=lambda x,y,z: x, + cls=lambda x, y, z: x, + headers=_headers, + params=_params, **kwargs ) - kwargs.pop('error_map', None) + kwargs.pop("error_map", None) - def get_long_running_output(pipeline_response): + def get_long_running_output(pipeline_response): # pylint: disable=inconsistent-return-statements if cls: return cls(pipeline_response, None, {}) - - if polling is True: polling_method = ARMPolling(lro_delay, **kwargs) - elif polling is False: polling_method = NoPolling() - else: polling_method = polling + if polling is True: + polling_method = cast(PollingMethod, ARMPolling(lro_delay, **kwargs)) # type: PollingMethod + elif polling is False: + polling_method = cast(PollingMethod, NoPolling()) + else: + polling_method = polling if cont_token: return LROPoller.from_continuation_token( polling_method=polling_method, continuation_token=cont_token, client=self._client, - deserialization_callback=get_long_running_output + deserialization_callback=get_long_running_output, ) return LROPoller(self._client, raw_result, get_long_running_output, polling_method) - begin_delete.metadata = {'url': "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/Microsoft.Resources/deployments/{deploymentName}"} # type: ignore + begin_delete.metadata = {"url": "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/Microsoft.Resources/deployments/{deploymentName}"} # type: ignore @distributed_trace - def check_existence( - self, - resource_group_name: str, - deployment_name: str, - **kwargs: Any - ) -> bool: + def check_existence(self, resource_group_name: str, deployment_name: str, **kwargs: Any) -> bool: """Checks whether the deployment exists. :param resource_group_name: The name of the resource group with the deployment to check. The - name is case insensitive. + name is case insensitive. Required. :type resource_group_name: str - :param deployment_name: The name of the deployment to check. + :param deployment_name: The name of the deployment to check. Required. :type deployment_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: bool, or the result of cls(response) + :return: bool or the result of cls(response) :rtype: bool - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType[None] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) - api_version = kwargs.pop('api_version', "2018-05-01") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2018-05-01")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[None] - request = build_deployments_check_existence_request( resource_group_name=resource_group_name, deployment_name=deployment_name, subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.check_existence.metadata['url'], + template_url=self.check_existence.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [204, 404]: @@ -2781,44 +2654,53 @@ def check_existence( return cls(pipeline_response, None, {}) return 200 <= response.status_code <= 299 - check_existence.metadata = {'url': "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/Microsoft.Resources/deployments/{deploymentName}"} # type: ignore - + check_existence.metadata = {"url": "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/Microsoft.Resources/deployments/{deploymentName}"} # type: ignore def _create_or_update_initial( - self, - resource_group_name: str, - deployment_name: str, - parameters: "_models.Deployment", - **kwargs: Any - ) -> "_models.DeploymentExtended": - cls = kwargs.pop('cls', None) # type: ClsType["_models.DeploymentExtended"] + self, resource_group_name: str, deployment_name: str, parameters: Union[_models.Deployment, IO], **kwargs: Any + ) -> _models.DeploymentExtended: error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', "2018-05-01") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + api_version = kwargs.pop("api_version", _params.pop("api-version", "2018-05-01")) # type: str + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.DeploymentExtended] - _json = self._serialize.body(parameters, 'Deployment') + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(parameters, (IO, bytes)): + _content = parameters + else: + _json = self._serialize.body(parameters, "Deployment") - request = build_deployments_create_or_update_request_initial( + request = build_deployments_create_or_update_request( resource_group_name=resource_group_name, deployment_name=deployment_name, subscription_id=self._config.subscription_id, api_version=api_version, content_type=content_type, json=_json, - template_url=self._create_or_update_initial.metadata['url'], + content=_content, + template_url=self._create_or_update_initial.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200, 201]: @@ -2826,38 +2708,42 @@ def _create_or_update_initial( raise HttpResponseError(response=response, error_format=ARMErrorFormat) if response.status_code == 200: - deserialized = self._deserialize('DeploymentExtended', pipeline_response) + deserialized = self._deserialize("DeploymentExtended", pipeline_response) if response.status_code == 201: - deserialized = self._deserialize('DeploymentExtended', pipeline_response) + deserialized = self._deserialize("DeploymentExtended", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - _create_or_update_initial.metadata = {'url': "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/Microsoft.Resources/deployments/{deploymentName}"} # type: ignore - + _create_or_update_initial.metadata = {"url": "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/Microsoft.Resources/deployments/{deploymentName}"} # type: ignore - @distributed_trace + @overload def begin_create_or_update( self, resource_group_name: str, deployment_name: str, - parameters: "_models.Deployment", + parameters: _models.Deployment, + *, + content_type: str = "application/json", **kwargs: Any - ) -> LROPoller["_models.DeploymentExtended"]: + ) -> LROPoller[_models.DeploymentExtended]: """Deploys resources to a resource group. You can provide the template and parameters directly in the request or link to JSON files. :param resource_group_name: The name of the resource group to deploy the resources to. The name - is case insensitive. The resource group must already exist. + is case insensitive. The resource group must already exist. Required. :type resource_group_name: str - :param deployment_name: The name of the deployment. + :param deployment_name: The name of the deployment. Required. :type deployment_name: str - :param parameters: Additional parameters supplied to the operation. + :param parameters: Additional parameters supplied to the operation. Required. :type parameters: ~azure.mgmt.resource.resources.v2018_05_01.models.Deployment + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str :keyword callable cls: A custom type or function that will be passed the direct response :keyword str continuation_token: A continuation token to restart a poller from a saved state. :keyword polling: By default, your polling method will be ARMPolling. Pass in False for this @@ -2870,115 +2756,189 @@ def begin_create_or_update( cls(response) :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.resource.resources.v2018_05_01.models.DeploymentExtended] - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - api_version = kwargs.pop('api_version', "2018-05-01") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] - polling = kwargs.pop('polling', True) # type: Union[bool, PollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType["_models.DeploymentExtended"] - lro_delay = kwargs.pop( - 'polling_interval', - self._config.polling_interval - ) - cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] - if cont_token is None: - raw_result = self._create_or_update_initial( - resource_group_name=resource_group_name, - deployment_name=deployment_name, - parameters=parameters, - api_version=api_version, - content_type=content_type, - cls=lambda x,y,z: x, - **kwargs - ) - kwargs.pop('error_map', None) - - def get_long_running_output(pipeline_response): - response = pipeline_response.http_response - deserialized = self._deserialize('DeploymentExtended', pipeline_response) - if cls: - return cls(pipeline_response, deserialized, {}) - return deserialized - - - if polling is True: polling_method = ARMPolling(lro_delay, **kwargs) - elif polling is False: polling_method = NoPolling() - else: polling_method = polling - if cont_token: - return LROPoller.from_continuation_token( - polling_method=polling_method, - continuation_token=cont_token, - client=self._client, - deserialization_callback=get_long_running_output - ) - return LROPoller(self._client, raw_result, get_long_running_output, polling_method) - - begin_create_or_update.metadata = {'url': "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/Microsoft.Resources/deployments/{deploymentName}"} # type: ignore - @distributed_trace - def get( + @overload + def begin_create_or_update( self, resource_group_name: str, deployment_name: str, + parameters: IO, + *, + content_type: str = "application/json", **kwargs: Any - ) -> "_models.DeploymentExtended": - """Gets a deployment. + ) -> LROPoller[_models.DeploymentExtended]: + """Deploys resources to a resource group. - :param resource_group_name: The name of the resource group. The name is case insensitive. + You can provide the template and parameters directly in the request or link to JSON files. + + :param resource_group_name: The name of the resource group to deploy the resources to. The name + is case insensitive. The resource group must already exist. Required. :type resource_group_name: str - :param deployment_name: The name of the deployment to get. + :param deployment_name: The name of the deployment. Required. :type deployment_name: str + :param parameters: Additional parameters supplied to the operation. Required. + :type parameters: IO + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: DeploymentExtended, or the result of cls(response) - :rtype: ~azure.mgmt.resource.resources.v2018_05_01.models.DeploymentExtended - :raises: ~azure.core.exceptions.HttpResponseError + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be ARMPolling. Pass in False for this + operation to not poll, or pass in your own initialized polling object for a personal polling + strategy. + :paramtype polling: bool or ~azure.core.polling.PollingMethod + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of LROPoller that returns either DeploymentExtended or the result of + cls(response) + :rtype: + ~azure.core.polling.LROPoller[~azure.mgmt.resource.resources.v2018_05_01.models.DeploymentExtended] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace + def begin_create_or_update( + self, resource_group_name: str, deployment_name: str, parameters: Union[_models.Deployment, IO], **kwargs: Any + ) -> LROPoller[_models.DeploymentExtended]: + """Deploys resources to a resource group. + + You can provide the template and parameters directly in the request or link to JSON files. + + :param resource_group_name: The name of the resource group to deploy the resources to. The name + is case insensitive. The resource group must already exist. Required. + :type resource_group_name: str + :param deployment_name: The name of the deployment. Required. + :type deployment_name: str + :param parameters: Additional parameters supplied to the operation. Is either a model type or a + IO type. Required. + :type parameters: ~azure.mgmt.resource.resources.v2018_05_01.models.Deployment or IO + :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. + Default value is None. + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be ARMPolling. Pass in False for this + operation to not poll, or pass in your own initialized polling object for a personal polling + strategy. + :paramtype polling: bool or ~azure.core.polling.PollingMethod + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of LROPoller that returns either DeploymentExtended or the result of + cls(response) + :rtype: + ~azure.core.polling.LROPoller[~azure.mgmt.resource.resources.v2018_05_01.models.DeploymentExtended] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _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", "2018-05-01")) # type: str + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.DeploymentExtended] + polling = kwargs.pop("polling", True) # type: Union[bool, PollingMethod] + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token = kwargs.pop("continuation_token", None) # type: Optional[str] + if cont_token is None: + raw_result = self._create_or_update_initial( # type: ignore + resource_group_name=resource_group_name, + deployment_name=deployment_name, + parameters=parameters, + api_version=api_version, + content_type=content_type, + cls=lambda x, y, z: x, + headers=_headers, + params=_params, + **kwargs + ) + kwargs.pop("error_map", None) + + def get_long_running_output(pipeline_response): + deserialized = self._deserialize("DeploymentExtended", pipeline_response) + if cls: + return cls(pipeline_response, deserialized, {}) + return deserialized + + if polling is True: + polling_method = cast(PollingMethod, ARMPolling(lro_delay, **kwargs)) # type: PollingMethod + elif polling is False: + polling_method = cast(PollingMethod, NoPolling()) + else: + polling_method = polling + if cont_token: + return LROPoller.from_continuation_token( + polling_method=polling_method, + continuation_token=cont_token, + client=self._client, + deserialization_callback=get_long_running_output, + ) + return LROPoller(self._client, raw_result, get_long_running_output, polling_method) + + begin_create_or_update.metadata = {"url": "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/Microsoft.Resources/deployments/{deploymentName}"} # type: ignore + + @distributed_trace + def get(self, resource_group_name: str, deployment_name: str, **kwargs: Any) -> _models.DeploymentExtended: + """Gets a deployment. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param deployment_name: The name of the deployment to get. Required. + :type deployment_name: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: DeploymentExtended or the result of cls(response) + :rtype: ~azure.mgmt.resource.resources.v2018_05_01.models.DeploymentExtended + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.DeploymentExtended"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + 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', "2018-05-01") # type: str + api_version = kwargs.pop("api_version", _params.pop("api-version", "2018-05-01")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[_models.DeploymentExtended] - request = build_deployments_get_request( resource_group_name=resource_group_name, deployment_name=deployment_name, subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.get.metadata['url'], + template_url=self.get.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) - deserialized = self._deserialize('DeploymentExtended', pipeline_response) + deserialized = self._deserialize("DeploymentExtended", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - get.metadata = {'url': "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/Microsoft.Resources/deployments/{deploymentName}"} # type: ignore - + get.metadata = {"url": "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/Microsoft.Resources/deployments/{deploymentName}"} # type: ignore @distributed_trace def cancel( # pylint: disable=inconsistent-return-statements - self, - resource_group_name: str, - deployment_name: str, - **kwargs: Any + self, resource_group_name: str, deployment_name: str, **kwargs: Any ) -> None: """Cancels a currently running template deployment. @@ -2988,38 +2948,45 @@ def cancel( # pylint: disable=inconsistent-return-statements partially deployed. :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. :type resource_group_name: str - :param deployment_name: The name of the deployment to cancel. + :param deployment_name: The name of the deployment to cancel. Required. :type deployment_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: None, or the result of cls(response) + :return: None or the result of cls(response) :rtype: None - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType[None] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) - api_version = kwargs.pop('api_version', "2018-05-01") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2018-05-01")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[None] - request = build_deployments_cancel_request( resource_group_name=resource_group_name, deployment_name=deployment_name, subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.cancel.metadata['url'], + template_url=self.cancel.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [204]: @@ -3029,42 +2996,110 @@ def cancel( # pylint: disable=inconsistent-return-statements if cls: return cls(pipeline_response, None, {}) - cancel.metadata = {'url': "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/Microsoft.Resources/deployments/{deploymentName}/cancel"} # type: ignore + cancel.metadata = {"url": "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/Microsoft.Resources/deployments/{deploymentName}/cancel"} # type: ignore - - @distributed_trace + @overload def validate( self, resource_group_name: str, deployment_name: str, - parameters: "_models.Deployment", + parameters: _models.Deployment, + *, + content_type: str = "application/json", **kwargs: Any - ) -> "_models.DeploymentValidateResult": + ) -> _models.DeploymentValidateResult: """Validates whether the specified template is syntactically correct and will be accepted by Azure Resource Manager.. :param resource_group_name: The name of the resource group the template will be deployed to. - The name is case insensitive. + The name is case insensitive. Required. :type resource_group_name: str - :param deployment_name: The name of the deployment. + :param deployment_name: The name of the deployment. Required. :type deployment_name: str - :param parameters: Parameters to validate. + :param parameters: Parameters to validate. Required. :type parameters: ~azure.mgmt.resource.resources.v2018_05_01.models.Deployment + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: DeploymentValidateResult or the result of cls(response) + :rtype: ~azure.mgmt.resource.resources.v2018_05_01.models.DeploymentValidateResult + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + def validate( + self, + resource_group_name: str, + deployment_name: str, + parameters: IO, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.DeploymentValidateResult: + """Validates whether the specified template is syntactically correct and will be accepted by Azure + Resource Manager.. + + :param resource_group_name: The name of the resource group the template will be deployed to. + The name is case insensitive. Required. + :type resource_group_name: str + :param deployment_name: The name of the deployment. Required. + :type deployment_name: str + :param parameters: Parameters to validate. Required. + :type parameters: IO + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: DeploymentValidateResult or the result of cls(response) + :rtype: ~azure.mgmt.resource.resources.v2018_05_01.models.DeploymentValidateResult + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace + def validate( + self, resource_group_name: str, deployment_name: str, parameters: Union[_models.Deployment, IO], **kwargs: Any + ) -> _models.DeploymentValidateResult: + """Validates whether the specified template is syntactically correct and will be accepted by Azure + Resource Manager.. + + :param resource_group_name: The name of the resource group the template will be deployed to. + The name is case insensitive. Required. + :type resource_group_name: str + :param deployment_name: The name of the deployment. Required. + :type deployment_name: str + :param parameters: Parameters to validate. Is either a model type or a IO type. Required. + :type parameters: ~azure.mgmt.resource.resources.v2018_05_01.models.Deployment or IO + :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. + Default value is None. + :paramtype content_type: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: DeploymentValidateResult, or the result of cls(response) + :return: DeploymentValidateResult or the result of cls(response) :rtype: ~azure.mgmt.resource.resources.v2018_05_01.models.DeploymentValidateResult - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.DeploymentValidateResult"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) - api_version = kwargs.pop('api_version', "2018-05-01") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - _json = self._serialize.body(parameters, 'Deployment') + api_version = kwargs.pop("api_version", _params.pop("api-version", "2018-05-01")) # type: str + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.DeploymentValidateResult] + + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(parameters, (IO, bytes)): + _content = parameters + else: + _json = self._serialize.body(parameters, "Deployment") request = build_deployments_validate_request( resource_group_name=resource_group_name, @@ -3073,16 +3108,18 @@ def validate( api_version=api_version, content_type=content_type, json=_json, - template_url=self.validate.metadata['url'], + content=_content, + template_url=self.validate.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200, 400]: @@ -3090,89 +3127,87 @@ def validate( raise HttpResponseError(response=response, error_format=ARMErrorFormat) if response.status_code == 200: - deserialized = self._deserialize('DeploymentValidateResult', pipeline_response) + deserialized = self._deserialize("DeploymentValidateResult", pipeline_response) if response.status_code == 400: - deserialized = self._deserialize('DeploymentValidateResult', pipeline_response) + deserialized = self._deserialize("DeploymentValidateResult", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - validate.metadata = {'url': "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/Microsoft.Resources/deployments/{deploymentName}/validate"} # type: ignore - + validate.metadata = {"url": "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/Microsoft.Resources/deployments/{deploymentName}/validate"} # type: ignore @distributed_trace def export_template( - self, - resource_group_name: str, - deployment_name: str, - **kwargs: Any - ) -> "_models.DeploymentExportResult": + self, resource_group_name: str, deployment_name: str, **kwargs: Any + ) -> _models.DeploymentExportResult: """Exports the template used for specified deployment. :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. :type resource_group_name: str - :param deployment_name: The name of the deployment from which to get the template. + :param deployment_name: The name of the deployment from which to get the template. Required. :type deployment_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: DeploymentExportResult, or the result of cls(response) + :return: DeploymentExportResult or the result of cls(response) :rtype: ~azure.mgmt.resource.resources.v2018_05_01.models.DeploymentExportResult - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.DeploymentExportResult"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + 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', "2018-05-01") # type: str + api_version = kwargs.pop("api_version", _params.pop("api-version", "2018-05-01")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[_models.DeploymentExportResult] - request = build_deployments_export_template_request( resource_group_name=resource_group_name, deployment_name=deployment_name, subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.export_template.metadata['url'], + template_url=self.export_template.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) - deserialized = self._deserialize('DeploymentExportResult', pipeline_response) + deserialized = self._deserialize("DeploymentExportResult", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - export_template.metadata = {'url': "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/Microsoft.Resources/deployments/{deploymentName}/exportTemplate"} # type: ignore - + export_template.metadata = {"url": "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/Microsoft.Resources/deployments/{deploymentName}/exportTemplate"} # type: ignore @distributed_trace def list_by_resource_group( - self, - resource_group_name: str, - filter: Optional[str] = None, - top: Optional[int] = None, - **kwargs: Any - ) -> Iterable["_models.DeploymentListResult"]: + self, resource_group_name: str, filter: Optional[str] = None, top: Optional[int] = None, **kwargs: Any + ) -> Iterable["_models.DeploymentExtended"]: """Get all the deployments for a resource group. :param resource_group_name: The name of the resource group with the deployments to get. The - name is case insensitive. + name is case insensitive. Required. :type resource_group_name: str :param filter: The filter to apply on the operation. For example, you can use $filter=provisioningState eq '{state}'. Default value is None. @@ -3181,42 +3216,49 @@ def list_by_resource_group( value is None. :type top: int :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either DeploymentListResult or the result of - cls(response) + :return: An iterator like instance of either DeploymentExtended or the result of cls(response) :rtype: - ~azure.core.paging.ItemPaged[~azure.mgmt.resource.resources.v2018_05_01.models.DeploymentListResult] - :raises: ~azure.core.exceptions.HttpResponseError + ~azure.core.paging.ItemPaged[~azure.mgmt.resource.resources.v2018_05_01.models.DeploymentExtended] + :raises ~azure.core.exceptions.HttpResponseError: """ - api_version = kwargs.pop('api_version', "2018-05-01") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2018-05-01")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[_models.DeploymentListResult] - cls = kwargs.pop('cls', None) # type: ClsType["_models.DeploymentListResult"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) + def prepare_request(next_link=None): if not next_link: - + request = build_deployments_list_by_resource_group_request( resource_group_name=resource_group_name, subscription_id=self._config.subscription_id, - api_version=api_version, filter=filter, top=top, - template_url=self.list_by_resource_group.metadata['url'], + 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.url = self._client.format_url(request.url) # type: ignore else: - - request = build_deployments_list_by_resource_group_request( - resource_group_name=resource_group_name, - subscription_id=self._config.subscription_id, - template_url=next_link, - ) + # make call to next link with the client's api-version + _parsed_next_link = urlparse(next_link) + _next_request_params = case_insensitive_dict(parse_qs(_parsed_next_link.query)) + _next_request_params["api-version"] = self._config.api_version + request = HttpRequest("GET", urljoin(next_link, _parsed_next_link.path), params=_next_request_params) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore request.method = "GET" return request @@ -3230,10 +3272,8 @@ def extract_data(pipeline_response): def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) response = pipeline_response.http_response @@ -3243,204 +3283,204 @@ def get_next(next_link=None): return pipeline_response + return ItemPaged(get_next, extract_data) - return ItemPaged( - get_next, extract_data - ) - list_by_resource_group.metadata = {'url': "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/Microsoft.Resources/deployments/"} # type: ignore + list_by_resource_group.metadata = {"url": "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/Microsoft.Resources/deployments/"} # type: ignore @distributed_trace - def calculate_template_hash( - self, - template: Any, - **kwargs: Any - ) -> "_models.TemplateHashResult": + def calculate_template_hash(self, template: JSON, **kwargs: Any) -> _models.TemplateHashResult: """Calculate the hash of the given template. - :param template: The template provided to calculate hash. - :type template: any + :param template: The template provided to calculate hash. Required. + :type template: JSON :keyword callable cls: A custom type or function that will be passed the direct response - :return: TemplateHashResult, or the result of cls(response) + :return: TemplateHashResult or the result of cls(response) :rtype: ~azure.mgmt.resource.resources.v2018_05_01.models.TemplateHashResult - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.TemplateHashResult"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', "2018-05-01") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + api_version = kwargs.pop("api_version", _params.pop("api-version", "2018-05-01")) # type: str + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", "application/json")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[_models.TemplateHashResult] - _json = self._serialize.body(template, 'object') + _json = self._serialize.body(template, "object") request = build_deployments_calculate_template_hash_request( api_version=api_version, content_type=content_type, json=_json, - template_url=self.calculate_template_hash.metadata['url'], + template_url=self.calculate_template_hash.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) - deserialized = self._deserialize('TemplateHashResult', pipeline_response) + deserialized = self._deserialize("TemplateHashResult", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - calculate_template_hash.metadata = {'url': "/providers/Microsoft.Resources/calculateTemplateHash"} # type: ignore + calculate_template_hash.metadata = {"url": "/providers/Microsoft.Resources/calculateTemplateHash"} # type: ignore -class ProvidersOperations(object): - """ProvidersOperations operations. - You should not instantiate this class directly. Instead, you should create a Client instance that - instantiates it for you and attaches it as an attribute. +class ProvidersOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. - :ivar models: Alias to model classes used in this operation group. - :type models: ~azure.mgmt.resource.resources.v2018_05_01.models - :param client: Client for service requests. - :param config: Configuration of service client. - :param serializer: An object model serializer. - :param deserializer: An object model deserializer. + Instead, you should access the following operations through + :class:`~azure.mgmt.resource.resources.v2018_05_01.ResourceManagementClient`'s + :attr:`providers` attribute. """ models = _models - def __init__(self, client, config, serializer, deserializer): - self._client = client - self._serialize = serializer - self._deserialize = deserializer - self._config = config + def __init__(self, *args, **kwargs): + input_args = list(args) + self._client = input_args.pop(0) if input_args else kwargs.pop("client") + self._config = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") @distributed_trace - def unregister( - self, - resource_provider_namespace: str, - **kwargs: Any - ) -> "_models.Provider": + def unregister(self, resource_provider_namespace: str, **kwargs: Any) -> _models.Provider: """Unregisters a subscription from a resource provider. :param resource_provider_namespace: The namespace of the resource provider to unregister. + Required. :type resource_provider_namespace: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: Provider, or the result of cls(response) + :return: Provider or the result of cls(response) :rtype: ~azure.mgmt.resource.resources.v2018_05_01.models.Provider - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.Provider"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + 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', "2018-05-01") # type: str + api_version = kwargs.pop("api_version", _params.pop("api-version", "2018-05-01")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[_models.Provider] - request = build_providers_unregister_request( resource_provider_namespace=resource_provider_namespace, subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.unregister.metadata['url'], + template_url=self.unregister.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) - deserialized = self._deserialize('Provider', pipeline_response) + deserialized = self._deserialize("Provider", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - unregister.metadata = {'url': "/subscriptions/{subscriptionId}/providers/{resourceProviderNamespace}/unregister"} # type: ignore - + unregister.metadata = {"url": "/subscriptions/{subscriptionId}/providers/{resourceProviderNamespace}/unregister"} # type: ignore @distributed_trace - def register( - self, - resource_provider_namespace: str, - **kwargs: Any - ) -> "_models.Provider": + def register(self, resource_provider_namespace: str, **kwargs: Any) -> _models.Provider: """Registers a subscription with a resource provider. :param resource_provider_namespace: The namespace of the resource provider to register. + Required. :type resource_provider_namespace: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: Provider, or the result of cls(response) + :return: Provider or the result of cls(response) :rtype: ~azure.mgmt.resource.resources.v2018_05_01.models.Provider - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.Provider"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + 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', "2018-05-01") # type: str + api_version = kwargs.pop("api_version", _params.pop("api-version", "2018-05-01")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[_models.Provider] - request = build_providers_register_request( resource_provider_namespace=resource_provider_namespace, subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.register.metadata['url'], + template_url=self.register.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) - deserialized = self._deserialize('Provider', pipeline_response) + deserialized = self._deserialize("Provider", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - register.metadata = {'url': "/subscriptions/{subscriptionId}/providers/{resourceProviderNamespace}/register"} # type: ignore - + register.metadata = {"url": "/subscriptions/{subscriptionId}/providers/{resourceProviderNamespace}/register"} # type: ignore @distributed_trace def list( - self, - top: Optional[int] = None, - expand: Optional[str] = None, - **kwargs: Any - ) -> Iterable["_models.ProviderListResult"]: + self, top: Optional[int] = None, expand: Optional[str] = None, **kwargs: Any + ) -> Iterable["_models.Provider"]: """Gets all resource providers for a subscription. :param top: The number of results to return. If null is passed returns all deployments. Default @@ -3451,39 +3491,48 @@ def list( response, use $expand=resourceTypes/aliases. Default value is None. :type expand: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either ProviderListResult or the result of cls(response) + :return: An iterator like instance of either Provider or the result of cls(response) :rtype: - ~azure.core.paging.ItemPaged[~azure.mgmt.resource.resources.v2018_05_01.models.ProviderListResult] - :raises: ~azure.core.exceptions.HttpResponseError + ~azure.core.paging.ItemPaged[~azure.mgmt.resource.resources.v2018_05_01.models.Provider] + :raises ~azure.core.exceptions.HttpResponseError: """ - api_version = kwargs.pop('api_version', "2018-05-01") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2018-05-01")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[_models.ProviderListResult] - cls = kwargs.pop('cls', None) # type: ClsType["_models.ProviderListResult"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) + def prepare_request(next_link=None): if not next_link: - + request = build_providers_list_request( subscription_id=self._config.subscription_id, - api_version=api_version, top=top, expand=expand, - template_url=self.list.metadata['url'], + 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.url = self._client.format_url(request.url) # type: ignore else: - - request = build_providers_list_request( - subscription_id=self._config.subscription_id, - template_url=next_link, - ) + # make call to next link with the client's api-version + _parsed_next_link = urlparse(next_link) + _next_request_params = case_insensitive_dict(parse_qs(_parsed_next_link.query)) + _next_request_params["api-version"] = self._config.api_version + request = HttpRequest("GET", urljoin(next_link, _parsed_next_link.path), params=_next_request_params) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore request.method = "GET" return request @@ -3497,10 +3546,8 @@ def extract_data(pipeline_response): def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) response = pipeline_response.http_response @@ -3510,91 +3557,88 @@ def get_next(next_link=None): return pipeline_response + return ItemPaged(get_next, extract_data) - return ItemPaged( - get_next, extract_data - ) - list.metadata = {'url': "/subscriptions/{subscriptionId}/providers"} # type: ignore + list.metadata = {"url": "/subscriptions/{subscriptionId}/providers"} # type: ignore @distributed_trace - def get( - self, - resource_provider_namespace: str, - expand: Optional[str] = None, - **kwargs: Any - ) -> "_models.Provider": + def get(self, resource_provider_namespace: str, expand: Optional[str] = None, **kwargs: Any) -> _models.Provider: """Gets the specified resource provider. - :param resource_provider_namespace: The namespace of the resource provider. + :param resource_provider_namespace: The namespace of the resource provider. Required. :type resource_provider_namespace: str :param expand: The $expand query parameter. For example, to include property aliases in response, use $expand=resourceTypes/aliases. Default value is None. :type expand: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: Provider, or the result of cls(response) + :return: Provider or the result of cls(response) :rtype: ~azure.mgmt.resource.resources.v2018_05_01.models.Provider - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.Provider"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + 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', "2018-05-01") # type: str + api_version = kwargs.pop("api_version", _params.pop("api-version", "2018-05-01")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[_models.Provider] - request = build_providers_get_request( resource_provider_namespace=resource_provider_namespace, subscription_id=self._config.subscription_id, - api_version=api_version, expand=expand, - template_url=self.get.metadata['url'], + api_version=api_version, + template_url=self.get.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) - deserialized = self._deserialize('Provider', pipeline_response) + deserialized = self._deserialize("Provider", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - get.metadata = {'url': "/subscriptions/{subscriptionId}/providers/{resourceProviderNamespace}"} # type: ignore + get.metadata = {"url": "/subscriptions/{subscriptionId}/providers/{resourceProviderNamespace}"} # type: ignore -class ResourcesOperations(object): # pylint: disable=too-many-public-methods - """ResourcesOperations operations. - You should not instantiate this class directly. Instead, you should create a Client instance that - instantiates it for you and attaches it as an attribute. +class ResourcesOperations: # pylint: disable=too-many-public-methods + """ + .. warning:: + **DO NOT** instantiate this class directly. - :ivar models: Alias to model classes used in this operation group. - :type models: ~azure.mgmt.resource.resources.v2018_05_01.models - :param client: Client for service requests. - :param config: Configuration of service client. - :param serializer: An object model serializer. - :param deserializer: An object model deserializer. + Instead, you should access the following operations through + :class:`~azure.mgmt.resource.resources.v2018_05_01.ResourceManagementClient`'s + :attr:`resources` attribute. """ models = _models - def __init__(self, client, config, serializer, deserializer): - self._client = client - self._serialize = serializer - self._deserialize = deserializer - self._config = config + def __init__(self, *args, **kwargs): + input_args = list(args) + self._client = input_args.pop(0) if input_args else kwargs.pop("client") + self._config = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") @distributed_trace def list_by_resource_group( @@ -3604,10 +3648,10 @@ def list_by_resource_group( expand: Optional[str] = None, top: Optional[int] = None, **kwargs: Any - ) -> Iterable["_models.ResourceListResult"]: + ) -> Iterable["_models.GenericResourceExpanded"]: """Get all the resources for a resource group. - :param resource_group_name: The resource group with the resources to get. + :param resource_group_name: The resource group with the resources to get. Required. :type resource_group_name: str :param filter: The filter to apply on the operation.:code:`
`:code:`
`The properties you can use for eq (equals) or ne (not equals) are: location, resourceType, name, resourceGroup, @@ -3632,42 +3676,51 @@ def list_by_resource_group( value is None. :type top: int :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either ResourceListResult or the result of cls(response) + :return: An iterator like instance of either GenericResourceExpanded or the result of + cls(response) :rtype: - ~azure.core.paging.ItemPaged[~azure.mgmt.resource.resources.v2018_05_01.models.ResourceListResult] - :raises: ~azure.core.exceptions.HttpResponseError + ~azure.core.paging.ItemPaged[~azure.mgmt.resource.resources.v2018_05_01.models.GenericResourceExpanded] + :raises ~azure.core.exceptions.HttpResponseError: """ - api_version = kwargs.pop('api_version', "2018-05-01") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2018-05-01")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[_models.ResourceListResult] - cls = kwargs.pop('cls', None) # type: ClsType["_models.ResourceListResult"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) + def prepare_request(next_link=None): if not next_link: - + request = build_resources_list_by_resource_group_request( resource_group_name=resource_group_name, subscription_id=self._config.subscription_id, - api_version=api_version, filter=filter, expand=expand, top=top, - template_url=self.list_by_resource_group.metadata['url'], + 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.url = self._client.format_url(request.url) # type: ignore else: - - request = build_resources_list_by_resource_group_request( - resource_group_name=resource_group_name, - subscription_id=self._config.subscription_id, - template_url=next_link, - ) + # make call to next link with the client's api-version + _parsed_next_link = urlparse(next_link) + _next_request_params = case_insensitive_dict(parse_qs(_parsed_next_link.query)) + _next_request_params["api-version"] = self._config.api_version + request = HttpRequest("GET", urljoin(next_link, _parsed_next_link.path), params=_next_request_params) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore request.method = "GET" return request @@ -3681,10 +3734,8 @@ def extract_data(pipeline_response): def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) response = pipeline_response.http_response @@ -3694,45 +3745,54 @@ def get_next(next_link=None): return pipeline_response + return ItemPaged(get_next, extract_data) - return ItemPaged( - get_next, extract_data - ) - list_by_resource_group.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/resources"} # type: ignore + list_by_resource_group.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/resources"} # type: ignore def _move_resources_initial( # pylint: disable=inconsistent-return-statements - self, - source_resource_group_name: str, - parameters: "_models.ResourcesMoveInfo", - **kwargs: Any + self, source_resource_group_name: str, parameters: Union[_models.ResourcesMoveInfo, IO], **kwargs: Any ) -> None: - cls = kwargs.pop('cls', None) # type: ClsType[None] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', "2018-05-01") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + api_version = kwargs.pop("api_version", _params.pop("api-version", "2018-05-01")) # type: str + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[None] - _json = self._serialize.body(parameters, 'ResourcesMoveInfo') + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(parameters, (IO, bytes)): + _content = parameters + else: + _json = self._serialize.body(parameters, "ResourcesMoveInfo") - request = build_resources_move_resources_request_initial( + request = build_resources_move_resources_request( source_resource_group_name=source_resource_group_name, subscription_id=self._config.subscription_id, api_version=api_version, content_type=content_type, json=_json, - template_url=self._move_resources_initial.metadata['url'], + content=_content, + template_url=self._move_resources_initial.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [202, 204]: @@ -3742,14 +3802,15 @@ def _move_resources_initial( # pylint: disable=inconsistent-return-statements if cls: return cls(pipeline_response, None, {}) - _move_resources_initial.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{sourceResourceGroupName}/moveResources"} # type: ignore - + _move_resources_initial.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{sourceResourceGroupName}/moveResources"} # type: ignore - @distributed_trace - def begin_move_resources( # pylint: disable=inconsistent-return-statements + @overload + def begin_move_resources( self, source_resource_group_name: str, - parameters: "_models.ResourcesMoveInfo", + parameters: _models.ResourcesMoveInfo, + *, + content_type: str = "application/json", **kwargs: Any ) -> LROPoller[None]: """Moves resources from one resource group to another resource group. @@ -3760,10 +3821,13 @@ def begin_move_resources( # pylint: disable=inconsistent-return-statements the groups until the move completes. :param source_resource_group_name: The name of the resource group containing the resources to - move. + move. Required. :type source_resource_group_name: str - :param parameters: Parameters for moving resources. + :param parameters: Parameters for moving resources. Required. :type parameters: ~azure.mgmt.resource.resources.v2018_05_01.models.ResourcesMoveInfo + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str :keyword callable cls: A custom type or function that will be passed the direct response :keyword str continuation_token: A continuation token to restart a poller from a saved state. :keyword polling: By default, your polling method will be ARMPolling. Pass in False for this @@ -3774,80 +3838,160 @@ def begin_move_resources( # pylint: disable=inconsistent-return-statements Retry-After header is present. :return: An instance of LROPoller that returns either None or the result of cls(response) :rtype: ~azure.core.polling.LROPoller[None] - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - api_version = kwargs.pop('api_version', "2018-05-01") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] - polling = kwargs.pop('polling', True) # type: Union[bool, PollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType[None] - lro_delay = kwargs.pop( - 'polling_interval', - self._config.polling_interval - ) - cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] + + @overload + def begin_move_resources( + self, source_resource_group_name: str, parameters: IO, *, content_type: str = "application/json", **kwargs: Any + ) -> LROPoller[None]: + """Moves resources from one resource group to another resource group. + + The resources to move must be in the same source resource group. The target resource group may + be in a different subscription. When moving resources, both the source group and the target + group are locked for the duration of the operation. Write and delete operations are blocked on + the groups until the move completes. + + :param source_resource_group_name: The name of the resource group containing the resources to + move. Required. + :type source_resource_group_name: str + :param parameters: Parameters for moving resources. Required. + :type parameters: IO + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be ARMPolling. Pass in False for this + operation to not poll, or pass in your own initialized polling object for a personal polling + strategy. + :paramtype polling: bool or ~azure.core.polling.PollingMethod + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of LROPoller that returns either None or the result of cls(response) + :rtype: ~azure.core.polling.LROPoller[None] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace + def begin_move_resources( + self, source_resource_group_name: str, parameters: Union[_models.ResourcesMoveInfo, IO], **kwargs: Any + ) -> LROPoller[None]: + """Moves resources from one resource group to another resource group. + + The resources to move must be in the same source resource group. The target resource group may + be in a different subscription. When moving resources, both the source group and the target + group are locked for the duration of the operation. Write and delete operations are blocked on + the groups until the move completes. + + :param source_resource_group_name: The name of the resource group containing the resources to + move. Required. + :type source_resource_group_name: str + :param parameters: Parameters for moving resources. Is either a model type or a IO type. + Required. + :type parameters: ~azure.mgmt.resource.resources.v2018_05_01.models.ResourcesMoveInfo or IO + :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. + Default value is None. + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be ARMPolling. Pass in False for this + operation to not poll, or pass in your own initialized polling object for a personal polling + strategy. + :paramtype polling: bool or ~azure.core.polling.PollingMethod + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of LROPoller that returns either None or the result of cls(response) + :rtype: ~azure.core.polling.LROPoller[None] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _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", "2018-05-01")) # type: str + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[None] + polling = kwargs.pop("polling", True) # type: Union[bool, PollingMethod] + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token = kwargs.pop("continuation_token", None) # type: Optional[str] if cont_token is None: - raw_result = self._move_resources_initial( + raw_result = self._move_resources_initial( # type: ignore source_resource_group_name=source_resource_group_name, parameters=parameters, api_version=api_version, content_type=content_type, - cls=lambda x,y,z: x, + cls=lambda x, y, z: x, + headers=_headers, + params=_params, **kwargs ) - kwargs.pop('error_map', None) + kwargs.pop("error_map", None) - def get_long_running_output(pipeline_response): + def get_long_running_output(pipeline_response): # pylint: disable=inconsistent-return-statements if cls: return cls(pipeline_response, None, {}) - - if polling is True: polling_method = ARMPolling(lro_delay, **kwargs) - elif polling is False: polling_method = NoPolling() - else: polling_method = polling + if polling is True: + polling_method = cast(PollingMethod, ARMPolling(lro_delay, **kwargs)) # type: PollingMethod + elif polling is False: + polling_method = cast(PollingMethod, NoPolling()) + else: + polling_method = polling if cont_token: return LROPoller.from_continuation_token( polling_method=polling_method, continuation_token=cont_token, client=self._client, - deserialization_callback=get_long_running_output + deserialization_callback=get_long_running_output, ) return LROPoller(self._client, raw_result, get_long_running_output, polling_method) - begin_move_resources.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{sourceResourceGroupName}/moveResources"} # type: ignore + begin_move_resources.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{sourceResourceGroupName}/moveResources"} # type: ignore def _validate_move_resources_initial( # pylint: disable=inconsistent-return-statements - self, - source_resource_group_name: str, - parameters: "_models.ResourcesMoveInfo", - **kwargs: Any + self, source_resource_group_name: str, parameters: Union[_models.ResourcesMoveInfo, IO], **kwargs: Any ) -> None: - cls = kwargs.pop('cls', None) # type: ClsType[None] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', "2018-05-01") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + api_version = kwargs.pop("api_version", _params.pop("api-version", "2018-05-01")) # type: str + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[None] - _json = self._serialize.body(parameters, 'ResourcesMoveInfo') + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(parameters, (IO, bytes)): + _content = parameters + else: + _json = self._serialize.body(parameters, "ResourcesMoveInfo") - request = build_resources_validate_move_resources_request_initial( + request = build_resources_validate_move_resources_request( source_resource_group_name=source_resource_group_name, subscription_id=self._config.subscription_id, api_version=api_version, content_type=content_type, json=_json, - template_url=self._validate_move_resources_initial.metadata['url'], + content=_content, + template_url=self._validate_move_resources_initial.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [202, 204, 409]: @@ -3857,14 +4001,15 @@ def _validate_move_resources_initial( # pylint: disable=inconsistent-return-sta if cls: return cls(pipeline_response, None, {}) - _validate_move_resources_initial.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{sourceResourceGroupName}/validateMoveResources"} # type: ignore - + _validate_move_resources_initial.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{sourceResourceGroupName}/validateMoveResources"} # type: ignore - @distributed_trace - def begin_validate_move_resources( # pylint: disable=inconsistent-return-statements + @overload + def begin_validate_move_resources( self, source_resource_group_name: str, - parameters: "_models.ResourcesMoveInfo", + parameters: _models.ResourcesMoveInfo, + *, + content_type: str = "application/json", **kwargs: Any ) -> LROPoller[None]: """Validates whether resources can be moved from one resource group to another resource group. @@ -3877,10 +4022,13 @@ def begin_validate_move_resources( # pylint: disable=inconsistent-return-statem operation. :param source_resource_group_name: The name of the resource group containing the resources to - validate for move. + validate for move. Required. :type source_resource_group_name: str - :param parameters: Parameters for moving resources. + :param parameters: Parameters for moving resources. Required. :type parameters: ~azure.mgmt.resource.resources.v2018_05_01.models.ResourcesMoveInfo + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str :keyword callable cls: A custom type or function that will be passed the direct response :keyword str continuation_token: A continuation token to restart a poller from a saved state. :keyword polling: By default, your polling method will be ARMPolling. Pass in False for this @@ -3891,55 +4039,124 @@ def begin_validate_move_resources( # pylint: disable=inconsistent-return-statem Retry-After header is present. :return: An instance of LROPoller that returns either None or the result of cls(response) :rtype: ~azure.core.polling.LROPoller[None] - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - api_version = kwargs.pop('api_version', "2018-05-01") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] - polling = kwargs.pop('polling', True) # type: Union[bool, PollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType[None] - lro_delay = kwargs.pop( - 'polling_interval', - self._config.polling_interval - ) - cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] - if cont_token is None: - raw_result = self._validate_move_resources_initial( - source_resource_group_name=source_resource_group_name, - parameters=parameters, - api_version=api_version, - content_type=content_type, - cls=lambda x,y,z: x, - **kwargs + + @overload + def begin_validate_move_resources( + self, source_resource_group_name: str, parameters: IO, *, content_type: str = "application/json", **kwargs: Any + ) -> LROPoller[None]: + """Validates whether resources can be moved from one resource group to another resource group. + + This operation checks whether the specified resources can be moved to the target. The resources + to move must be in the same source resource group. The target resource group may be in a + different subscription. If validation succeeds, it returns HTTP response code 204 (no content). + If validation fails, it returns HTTP response code 409 (Conflict) with an error message. + Retrieve the URL in the Location header value to check the result of the long-running + operation. + + :param source_resource_group_name: The name of the resource group containing the resources to + validate for move. Required. + :type source_resource_group_name: str + :param parameters: Parameters for moving resources. Required. + :type parameters: IO + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be ARMPolling. Pass in False for this + operation to not poll, or pass in your own initialized polling object for a personal polling + strategy. + :paramtype polling: bool or ~azure.core.polling.PollingMethod + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of LROPoller that returns either None or the result of cls(response) + :rtype: ~azure.core.polling.LROPoller[None] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace + def begin_validate_move_resources( + self, source_resource_group_name: str, parameters: Union[_models.ResourcesMoveInfo, IO], **kwargs: Any + ) -> LROPoller[None]: + """Validates whether resources can be moved from one resource group to another resource group. + + This operation checks whether the specified resources can be moved to the target. The resources + to move must be in the same source resource group. The target resource group may be in a + different subscription. If validation succeeds, it returns HTTP response code 204 (no content). + If validation fails, it returns HTTP response code 409 (Conflict) with an error message. + Retrieve the URL in the Location header value to check the result of the long-running + operation. + + :param source_resource_group_name: The name of the resource group containing the resources to + validate for move. Required. + :type source_resource_group_name: str + :param parameters: Parameters for moving resources. Is either a model type or a IO type. + Required. + :type parameters: ~azure.mgmt.resource.resources.v2018_05_01.models.ResourcesMoveInfo or IO + :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. + Default value is None. + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be ARMPolling. Pass in False for this + operation to not poll, or pass in your own initialized polling object for a personal polling + strategy. + :paramtype polling: bool or ~azure.core.polling.PollingMethod + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of LROPoller that returns either None or the result of cls(response) + :rtype: ~azure.core.polling.LROPoller[None] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _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", "2018-05-01")) # type: str + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[None] + polling = kwargs.pop("polling", True) # type: Union[bool, PollingMethod] + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token = kwargs.pop("continuation_token", None) # type: Optional[str] + if cont_token is None: + raw_result = self._validate_move_resources_initial( # type: ignore + source_resource_group_name=source_resource_group_name, + parameters=parameters, + api_version=api_version, + content_type=content_type, + cls=lambda x, y, z: x, + headers=_headers, + params=_params, + **kwargs ) - kwargs.pop('error_map', None) + kwargs.pop("error_map", None) - def get_long_running_output(pipeline_response): + def get_long_running_output(pipeline_response): # pylint: disable=inconsistent-return-statements if cls: return cls(pipeline_response, None, {}) - - if polling is True: polling_method = ARMPolling(lro_delay, **kwargs) - elif polling is False: polling_method = NoPolling() - else: polling_method = polling + if polling is True: + polling_method = cast(PollingMethod, ARMPolling(lro_delay, **kwargs)) # type: PollingMethod + elif polling is False: + polling_method = cast(PollingMethod, NoPolling()) + else: + polling_method = polling if cont_token: return LROPoller.from_continuation_token( polling_method=polling_method, continuation_token=cont_token, client=self._client, - deserialization_callback=get_long_running_output + deserialization_callback=get_long_running_output, ) return LROPoller(self._client, raw_result, get_long_running_output, polling_method) - begin_validate_move_resources.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{sourceResourceGroupName}/validateMoveResources"} # type: ignore + begin_validate_move_resources.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{sourceResourceGroupName}/validateMoveResources"} # type: ignore @distributed_trace def list( - self, - filter: Optional[str] = None, - expand: Optional[str] = None, - top: Optional[int] = None, - **kwargs: Any - ) -> Iterable["_models.ResourceListResult"]: + self, filter: Optional[str] = None, expand: Optional[str] = None, top: Optional[int] = None, **kwargs: Any + ) -> Iterable["_models.GenericResourceExpanded"]: """Get all the resources in a subscription. :param filter: The filter to apply on the operation.:code:`
`:code:`
`The properties you @@ -3965,40 +4182,50 @@ def list( value is None. :type top: int :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either ResourceListResult or the result of cls(response) + :return: An iterator like instance of either GenericResourceExpanded or the result of + cls(response) :rtype: - ~azure.core.paging.ItemPaged[~azure.mgmt.resource.resources.v2018_05_01.models.ResourceListResult] - :raises: ~azure.core.exceptions.HttpResponseError + ~azure.core.paging.ItemPaged[~azure.mgmt.resource.resources.v2018_05_01.models.GenericResourceExpanded] + :raises ~azure.core.exceptions.HttpResponseError: """ - api_version = kwargs.pop('api_version', "2018-05-01") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2018-05-01")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[_models.ResourceListResult] - cls = kwargs.pop('cls', None) # type: ClsType["_models.ResourceListResult"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) + def prepare_request(next_link=None): if not next_link: - + request = build_resources_list_request( subscription_id=self._config.subscription_id, - api_version=api_version, filter=filter, expand=expand, top=top, - template_url=self.list.metadata['url'], + 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.url = self._client.format_url(request.url) # type: ignore else: - - request = build_resources_list_request( - subscription_id=self._config.subscription_id, - template_url=next_link, - ) + # make call to next link with the client's api-version + _parsed_next_link = urlparse(next_link) + _next_request_params = case_insensitive_dict(parse_qs(_parsed_next_link.query)) + _next_request_params["api-version"] = self._config.api_version + request = HttpRequest("GET", urljoin(next_link, _parsed_next_link.path), params=_next_request_params) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore request.method = "GET" return request @@ -4012,10 +4239,8 @@ def extract_data(pipeline_response): def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) response = pipeline_response.http_response @@ -4025,11 +4250,9 @@ def get_next(next_link=None): return pipeline_response + return ItemPaged(get_next, extract_data) - return ItemPaged( - get_next, extract_data - ) - list.metadata = {'url': "/subscriptions/{subscriptionId}/resources"} # type: ignore + list.metadata = {"url": "/subscriptions/{subscriptionId}/resources"} # type: ignore @distributed_trace def check_existence( @@ -4045,30 +4268,36 @@ def check_existence( """Checks whether a resource exists. :param resource_group_name: The name of the resource group containing the resource to check. - The name is case insensitive. + The name is case insensitive. Required. :type resource_group_name: str - :param resource_provider_namespace: The resource provider of the resource to check. + :param resource_provider_namespace: The resource provider of the resource to check. Required. :type resource_provider_namespace: str - :param parent_resource_path: The parent resource identity. + :param parent_resource_path: The parent resource identity. Required. :type parent_resource_path: str - :param resource_type: The resource type. + :param resource_type: The resource type. Required. :type resource_type: str - :param resource_name: The name of the resource to check whether it exists. + :param resource_name: The name of the resource to check whether it exists. Required. :type resource_name: str - :param api_version: The API version to use for the operation. + :param api_version: The API version to use for the operation. Required. :type api_version: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: bool, or the result of cls(response) + :return: bool or the result of cls(response) :rtype: bool - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType[None] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = kwargs.pop("params", {}) or {} + + cls = kwargs.pop("cls", None) # type: ClsType[None] - request = build_resources_check_existence_request( resource_group_name=resource_group_name, resource_provider_namespace=resource_provider_namespace, @@ -4077,16 +4306,17 @@ def check_existence( resource_name=resource_name, subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.check_existence.metadata['url'], + template_url=self.check_existence.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [204, 404]: @@ -4097,8 +4327,7 @@ def check_existence( return cls(pipeline_response, None, {}) return 200 <= response.status_code <= 299 - check_existence.metadata = {'url': "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{parentResourcePath}/{resourceType}/{resourceName}"} # type: ignore - + check_existence.metadata = {"url": "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{parentResourcePath}/{resourceType}/{resourceName}"} # type: ignore def _delete_initial( # pylint: disable=inconsistent-return-statements self, @@ -4110,14 +4339,20 @@ def _delete_initial( # pylint: disable=inconsistent-return-statements api_version: str, **kwargs: Any ) -> None: - cls = kwargs.pop('cls', None) # type: ClsType[None] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = kwargs.pop("params", {}) or {} + + cls = kwargs.pop("cls", None) # type: ClsType[None] - - request = build_resources_delete_request_initial( + request = build_resources_delete_request( resource_group_name=resource_group_name, resource_provider_namespace=resource_provider_namespace, parent_resource_path=parent_resource_path, @@ -4125,16 +4360,17 @@ def _delete_initial( # pylint: disable=inconsistent-return-statements resource_name=resource_name, subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self._delete_initial.metadata['url'], + template_url=self._delete_initial.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200, 202, 204]: @@ -4144,11 +4380,10 @@ def _delete_initial( # pylint: disable=inconsistent-return-statements if cls: return cls(pipeline_response, None, {}) - _delete_initial.metadata = {'url': "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{parentResourcePath}/{resourceType}/{resourceName}"} # type: ignore - + _delete_initial.metadata = {"url": "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{parentResourcePath}/{resourceType}/{resourceName}"} # type: ignore @distributed_trace - def begin_delete( # pylint: disable=inconsistent-return-statements + def begin_delete( self, resource_group_name: str, resource_provider_namespace: str, @@ -4161,17 +4396,17 @@ def begin_delete( # pylint: disable=inconsistent-return-statements """Deletes a resource. :param resource_group_name: The name of the resource group that contains the resource to - delete. The name is case insensitive. + delete. The name is case insensitive. Required. :type resource_group_name: str - :param resource_provider_namespace: The namespace of the resource provider. + :param resource_provider_namespace: The namespace of the resource provider. Required. :type resource_provider_namespace: str - :param parent_resource_path: The parent resource identity. + :param parent_resource_path: The parent resource identity. Required. :type parent_resource_path: str - :param resource_type: The resource type. + :param resource_type: The resource type. Required. :type resource_type: str - :param resource_name: The name of the resource to delete. + :param resource_name: The name of the resource to delete. Required. :type resource_name: str - :param api_version: The API version to use for the operation. + :param api_version: The API version to use for the operation. Required. :type api_version: str :keyword callable cls: A custom type or function that will be passed the direct response :keyword str continuation_token: A continuation token to restart a poller from a saved state. @@ -4183,46 +4418,50 @@ def begin_delete( # pylint: disable=inconsistent-return-statements Retry-After header is present. :return: An instance of LROPoller that returns either None or the result of cls(response) :rtype: ~azure.core.polling.LROPoller[None] - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - polling = kwargs.pop('polling', True) # type: Union[bool, PollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType[None] - lro_delay = kwargs.pop( - 'polling_interval', - self._config.polling_interval - ) - cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] + _headers = kwargs.pop("headers", {}) or {} + _params = kwargs.pop("params", {}) or {} + + cls = kwargs.pop("cls", None) # type: ClsType[None] + polling = kwargs.pop("polling", True) # type: Union[bool, PollingMethod] + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token = kwargs.pop("continuation_token", None) # type: Optional[str] if cont_token is None: - raw_result = self._delete_initial( + raw_result = self._delete_initial( # type: ignore resource_group_name=resource_group_name, resource_provider_namespace=resource_provider_namespace, parent_resource_path=parent_resource_path, resource_type=resource_type, resource_name=resource_name, api_version=api_version, - cls=lambda x,y,z: x, + cls=lambda x, y, z: x, + headers=_headers, + params=_params, **kwargs ) - kwargs.pop('error_map', None) + kwargs.pop("error_map", None) - def get_long_running_output(pipeline_response): + def get_long_running_output(pipeline_response): # pylint: disable=inconsistent-return-statements if cls: return cls(pipeline_response, None, {}) - - if polling is True: polling_method = ARMPolling(lro_delay, **kwargs) - elif polling is False: polling_method = NoPolling() - else: polling_method = polling + if polling is True: + polling_method = cast(PollingMethod, ARMPolling(lro_delay, **kwargs)) # type: PollingMethod + elif polling is False: + polling_method = cast(PollingMethod, NoPolling()) + else: + polling_method = polling if cont_token: return LROPoller.from_continuation_token( polling_method=polling_method, continuation_token=cont_token, client=self._client, - deserialization_callback=get_long_running_output + deserialization_callback=get_long_running_output, ) return LROPoller(self._client, raw_result, get_long_running_output, polling_method) - begin_delete.metadata = {'url': "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{parentResourcePath}/{resourceType}/{resourceName}"} # type: ignore + begin_delete.metadata = {"url": "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{parentResourcePath}/{resourceType}/{resourceName}"} # type: ignore def _create_or_update_initial( self, @@ -4232,39 +4471,53 @@ def _create_or_update_initial( resource_type: str, resource_name: str, api_version: str, - parameters: "_models.GenericResource", + parameters: Union[_models.GenericResource, IO], **kwargs: Any - ) -> Optional["_models.GenericResource"]: - cls = kwargs.pop('cls', None) # type: ClsType[Optional["_models.GenericResource"]] + ) -> Optional[_models.GenericResource]: error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = kwargs.pop("params", {}) or {} - _json = self._serialize.body(parameters, 'GenericResource') + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[Optional[_models.GenericResource]] - request = build_resources_create_or_update_request_initial( + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(parameters, (IO, bytes)): + _content = parameters + else: + _json = self._serialize.body(parameters, "GenericResource") + + request = build_resources_create_or_update_request( resource_group_name=resource_group_name, resource_provider_namespace=resource_provider_namespace, parent_resource_path=parent_resource_path, resource_type=resource_type, resource_name=resource_name, subscription_id=self._config.subscription_id, - content_type=content_type, api_version=api_version, + content_type=content_type, json=_json, - template_url=self._create_or_update_initial.metadata['url'], + content=_content, + template_url=self._create_or_update_initial.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200, 201, 202]: @@ -4273,18 +4526,115 @@ def _create_or_update_initial( deserialized = None if response.status_code == 200: - deserialized = self._deserialize('GenericResource', pipeline_response) + deserialized = self._deserialize("GenericResource", pipeline_response) if response.status_code == 201: - deserialized = self._deserialize('GenericResource', pipeline_response) + deserialized = self._deserialize("GenericResource", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - _create_or_update_initial.metadata = {'url': "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{parentResourcePath}/{resourceType}/{resourceName}"} # type: ignore + _create_or_update_initial.metadata = {"url": "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{parentResourcePath}/{resourceType}/{resourceName}"} # type: ignore + + @overload + def begin_create_or_update( + self, + resource_group_name: str, + resource_provider_namespace: str, + parent_resource_path: str, + resource_type: str, + resource_name: str, + api_version: str, + parameters: _models.GenericResource, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> LROPoller[_models.GenericResource]: + """Creates a resource. + + :param resource_group_name: The name of the resource group for the resource. The name is case + insensitive. Required. + :type resource_group_name: str + :param resource_provider_namespace: The namespace of the resource provider. Required. + :type resource_provider_namespace: str + :param parent_resource_path: The parent resource identity. Required. + :type parent_resource_path: str + :param resource_type: The resource type of the resource to create. Required. + :type resource_type: str + :param resource_name: The name of the resource to create. Required. + :type resource_name: str + :param api_version: The API version to use for the operation. Required. + :type api_version: str + :param parameters: Parameters for creating or updating the resource. Required. + :type parameters: ~azure.mgmt.resource.resources.v2018_05_01.models.GenericResource + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be ARMPolling. Pass in False for this + operation to not poll, or pass in your own initialized polling object for a personal polling + strategy. + :paramtype polling: bool or ~azure.core.polling.PollingMethod + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of LROPoller that returns either GenericResource or the result of + cls(response) + :rtype: + ~azure.core.polling.LROPoller[~azure.mgmt.resource.resources.v2018_05_01.models.GenericResource] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + def begin_create_or_update( + self, + resource_group_name: str, + resource_provider_namespace: str, + parent_resource_path: str, + resource_type: str, + resource_name: str, + api_version: str, + parameters: IO, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> LROPoller[_models.GenericResource]: + """Creates a resource. + :param resource_group_name: The name of the resource group for the resource. The name is case + insensitive. Required. + :type resource_group_name: str + :param resource_provider_namespace: The namespace of the resource provider. Required. + :type resource_provider_namespace: str + :param parent_resource_path: The parent resource identity. Required. + :type parent_resource_path: str + :param resource_type: The resource type of the resource to create. Required. + :type resource_type: str + :param resource_name: The name of the resource to create. Required. + :type resource_name: str + :param api_version: The API version to use for the operation. Required. + :type api_version: str + :param parameters: Parameters for creating or updating the resource. Required. + :type parameters: IO + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be ARMPolling. Pass in False for this + operation to not poll, or pass in your own initialized polling object for a personal polling + strategy. + :paramtype polling: bool or ~azure.core.polling.PollingMethod + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of LROPoller that returns either GenericResource or the result of + cls(response) + :rtype: + ~azure.core.polling.LROPoller[~azure.mgmt.resource.resources.v2018_05_01.models.GenericResource] + :raises ~azure.core.exceptions.HttpResponseError: + """ @distributed_trace def begin_create_or_update( @@ -4295,26 +4645,30 @@ def begin_create_or_update( resource_type: str, resource_name: str, api_version: str, - parameters: "_models.GenericResource", + parameters: Union[_models.GenericResource, IO], **kwargs: Any - ) -> LROPoller["_models.GenericResource"]: + ) -> LROPoller[_models.GenericResource]: """Creates a resource. :param resource_group_name: The name of the resource group for the resource. The name is case - insensitive. + insensitive. Required. :type resource_group_name: str - :param resource_provider_namespace: The namespace of the resource provider. + :param resource_provider_namespace: The namespace of the resource provider. Required. :type resource_provider_namespace: str - :param parent_resource_path: The parent resource identity. + :param parent_resource_path: The parent resource identity. Required. :type parent_resource_path: str - :param resource_type: The resource type of the resource to create. + :param resource_type: The resource type of the resource to create. Required. :type resource_type: str - :param resource_name: The name of the resource to create. + :param resource_name: The name of the resource to create. Required. :type resource_name: str - :param api_version: The API version to use for the operation. + :param api_version: The API version to use for the operation. Required. :type api_version: str - :param parameters: Parameters for creating or updating the resource. - :type parameters: ~azure.mgmt.resource.resources.v2018_05_01.models.GenericResource + :param parameters: Parameters for creating or updating the resource. Is either a model type or + a IO type. Required. + :type parameters: ~azure.mgmt.resource.resources.v2018_05_01.models.GenericResource or IO + :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. + Default value is None. + :paramtype content_type: str :keyword callable cls: A custom type or function that will be passed the direct response :keyword str continuation_token: A continuation token to restart a poller from a saved state. :keyword polling: By default, your polling method will be ARMPolling. Pass in False for this @@ -4327,18 +4681,18 @@ def begin_create_or_update( cls(response) :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.resource.resources.v2018_05_01.models.GenericResource] - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] - polling = kwargs.pop('polling', True) # type: Union[bool, PollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType["_models.GenericResource"] - lro_delay = kwargs.pop( - 'polling_interval', - self._config.polling_interval - ) - cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = kwargs.pop("params", {}) or {} + + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.GenericResource] + polling = kwargs.pop("polling", True) # type: Union[bool, PollingMethod] + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token = kwargs.pop("continuation_token", None) # type: Optional[str] if cont_token is None: - raw_result = self._create_or_update_initial( + raw_result = self._create_or_update_initial( # type: ignore resource_group_name=resource_group_name, resource_provider_namespace=resource_provider_namespace, parent_resource_path=parent_resource_path, @@ -4347,32 +4701,35 @@ def begin_create_or_update( api_version=api_version, parameters=parameters, content_type=content_type, - cls=lambda x,y,z: x, + cls=lambda x, y, z: x, + headers=_headers, + params=_params, **kwargs ) - kwargs.pop('error_map', None) + kwargs.pop("error_map", None) def get_long_running_output(pipeline_response): - response = pipeline_response.http_response - deserialized = self._deserialize('GenericResource', pipeline_response) + deserialized = self._deserialize("GenericResource", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - - if polling is True: polling_method = ARMPolling(lro_delay, **kwargs) - elif polling is False: polling_method = NoPolling() - else: polling_method = polling + if polling is True: + polling_method = cast(PollingMethod, ARMPolling(lro_delay, **kwargs)) # type: PollingMethod + elif polling is False: + polling_method = cast(PollingMethod, NoPolling()) + else: + polling_method = polling if cont_token: return LROPoller.from_continuation_token( polling_method=polling_method, continuation_token=cont_token, client=self._client, - deserialization_callback=get_long_running_output + deserialization_callback=get_long_running_output, ) return LROPoller(self._client, raw_result, get_long_running_output, polling_method) - begin_create_or_update.metadata = {'url': "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{parentResourcePath}/{resourceType}/{resourceName}"} # type: ignore + begin_create_or_update.metadata = {"url": "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{parentResourcePath}/{resourceType}/{resourceName}"} # type: ignore def _update_initial( self, @@ -4382,39 +4739,53 @@ def _update_initial( resource_type: str, resource_name: str, api_version: str, - parameters: "_models.GenericResource", + parameters: Union[_models.GenericResource, IO], **kwargs: Any - ) -> Optional["_models.GenericResource"]: - cls = kwargs.pop('cls', None) # type: ClsType[Optional["_models.GenericResource"]] + ) -> Optional[_models.GenericResource]: error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = kwargs.pop("params", {}) or {} - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[Optional[_models.GenericResource]] - _json = self._serialize.body(parameters, 'GenericResource') + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(parameters, (IO, bytes)): + _content = parameters + else: + _json = self._serialize.body(parameters, "GenericResource") - request = build_resources_update_request_initial( + request = build_resources_update_request( resource_group_name=resource_group_name, resource_provider_namespace=resource_provider_namespace, parent_resource_path=parent_resource_path, resource_type=resource_type, resource_name=resource_name, subscription_id=self._config.subscription_id, - content_type=content_type, api_version=api_version, + content_type=content_type, json=_json, - template_url=self._update_initial.metadata['url'], + content=_content, + template_url=self._update_initial.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200, 202]: @@ -4423,15 +4794,112 @@ def _update_initial( deserialized = None if response.status_code == 200: - deserialized = self._deserialize('GenericResource', pipeline_response) + deserialized = self._deserialize("GenericResource", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - _update_initial.metadata = {'url': "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{parentResourcePath}/{resourceType}/{resourceName}"} # type: ignore + _update_initial.metadata = {"url": "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{parentResourcePath}/{resourceType}/{resourceName}"} # type: ignore + @overload + def begin_update( + self, + resource_group_name: str, + resource_provider_namespace: str, + parent_resource_path: str, + resource_type: str, + resource_name: str, + api_version: str, + parameters: _models.GenericResource, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> LROPoller[_models.GenericResource]: + """Updates a resource. + + :param resource_group_name: The name of the resource group for the resource. The name is case + insensitive. Required. + :type resource_group_name: str + :param resource_provider_namespace: The namespace of the resource provider. Required. + :type resource_provider_namespace: str + :param parent_resource_path: The parent resource identity. Required. + :type parent_resource_path: str + :param resource_type: The resource type of the resource to update. Required. + :type resource_type: str + :param resource_name: The name of the resource to update. Required. + :type resource_name: str + :param api_version: The API version to use for the operation. Required. + :type api_version: str + :param parameters: Parameters for updating the resource. Required. + :type parameters: ~azure.mgmt.resource.resources.v2018_05_01.models.GenericResource + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be ARMPolling. Pass in False for this + operation to not poll, or pass in your own initialized polling object for a personal polling + strategy. + :paramtype polling: bool or ~azure.core.polling.PollingMethod + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of LROPoller that returns either GenericResource or the result of + cls(response) + :rtype: + ~azure.core.polling.LROPoller[~azure.mgmt.resource.resources.v2018_05_01.models.GenericResource] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + def begin_update( + self, + resource_group_name: str, + resource_provider_namespace: str, + parent_resource_path: str, + resource_type: str, + resource_name: str, + api_version: str, + parameters: IO, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> LROPoller[_models.GenericResource]: + """Updates a resource. + + :param resource_group_name: The name of the resource group for the resource. The name is case + insensitive. Required. + :type resource_group_name: str + :param resource_provider_namespace: The namespace of the resource provider. Required. + :type resource_provider_namespace: str + :param parent_resource_path: The parent resource identity. Required. + :type parent_resource_path: str + :param resource_type: The resource type of the resource to update. Required. + :type resource_type: str + :param resource_name: The name of the resource to update. Required. + :type resource_name: str + :param api_version: The API version to use for the operation. Required. + :type api_version: str + :param parameters: Parameters for updating the resource. Required. + :type parameters: IO + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be ARMPolling. Pass in False for this + operation to not poll, or pass in your own initialized polling object for a personal polling + strategy. + :paramtype polling: bool or ~azure.core.polling.PollingMethod + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of LROPoller that returns either GenericResource or the result of + cls(response) + :rtype: + ~azure.core.polling.LROPoller[~azure.mgmt.resource.resources.v2018_05_01.models.GenericResource] + :raises ~azure.core.exceptions.HttpResponseError: + """ @distributed_trace def begin_update( @@ -4442,26 +4910,30 @@ def begin_update( resource_type: str, resource_name: str, api_version: str, - parameters: "_models.GenericResource", + parameters: Union[_models.GenericResource, IO], **kwargs: Any - ) -> LROPoller["_models.GenericResource"]: + ) -> LROPoller[_models.GenericResource]: """Updates a resource. :param resource_group_name: The name of the resource group for the resource. The name is case - insensitive. + insensitive. Required. :type resource_group_name: str - :param resource_provider_namespace: The namespace of the resource provider. + :param resource_provider_namespace: The namespace of the resource provider. Required. :type resource_provider_namespace: str - :param parent_resource_path: The parent resource identity. + :param parent_resource_path: The parent resource identity. Required. :type parent_resource_path: str - :param resource_type: The resource type of the resource to update. + :param resource_type: The resource type of the resource to update. Required. :type resource_type: str - :param resource_name: The name of the resource to update. + :param resource_name: The name of the resource to update. Required. :type resource_name: str - :param api_version: The API version to use for the operation. + :param api_version: The API version to use for the operation. Required. :type api_version: str - :param parameters: Parameters for updating the resource. - :type parameters: ~azure.mgmt.resource.resources.v2018_05_01.models.GenericResource + :param parameters: Parameters for updating the resource. Is either a model type or a IO type. + Required. + :type parameters: ~azure.mgmt.resource.resources.v2018_05_01.models.GenericResource or IO + :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. + Default value is None. + :paramtype content_type: str :keyword callable cls: A custom type or function that will be passed the direct response :keyword str continuation_token: A continuation token to restart a poller from a saved state. :keyword polling: By default, your polling method will be ARMPolling. Pass in False for this @@ -4474,18 +4946,18 @@ def begin_update( cls(response) :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.resource.resources.v2018_05_01.models.GenericResource] - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] - polling = kwargs.pop('polling', True) # type: Union[bool, PollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType["_models.GenericResource"] - lro_delay = kwargs.pop( - 'polling_interval', - self._config.polling_interval - ) - cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = kwargs.pop("params", {}) or {} + + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.GenericResource] + polling = kwargs.pop("polling", True) # type: Union[bool, PollingMethod] + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token = kwargs.pop("continuation_token", None) # type: Optional[str] if cont_token is None: - raw_result = self._update_initial( + raw_result = self._update_initial( # type: ignore resource_group_name=resource_group_name, resource_provider_namespace=resource_provider_namespace, parent_resource_path=parent_resource_path, @@ -4494,32 +4966,35 @@ def begin_update( api_version=api_version, parameters=parameters, content_type=content_type, - cls=lambda x,y,z: x, + cls=lambda x, y, z: x, + headers=_headers, + params=_params, **kwargs ) - kwargs.pop('error_map', None) + kwargs.pop("error_map", None) def get_long_running_output(pipeline_response): - response = pipeline_response.http_response - deserialized = self._deserialize('GenericResource', pipeline_response) + deserialized = self._deserialize("GenericResource", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - - if polling is True: polling_method = ARMPolling(lro_delay, **kwargs) - elif polling is False: polling_method = NoPolling() - else: polling_method = polling + if polling is True: + polling_method = cast(PollingMethod, ARMPolling(lro_delay, **kwargs)) # type: PollingMethod + elif polling is False: + polling_method = cast(PollingMethod, NoPolling()) + else: + polling_method = polling if cont_token: return LROPoller.from_continuation_token( polling_method=polling_method, continuation_token=cont_token, client=self._client, - deserialization_callback=get_long_running_output + deserialization_callback=get_long_running_output, ) return LROPoller(self._client, raw_result, get_long_running_output, polling_method) - begin_update.metadata = {'url': "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{parentResourcePath}/{resourceType}/{resourceName}"} # type: ignore + begin_update.metadata = {"url": "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{parentResourcePath}/{resourceType}/{resourceName}"} # type: ignore @distributed_trace def get( @@ -4531,34 +5006,40 @@ def get( resource_name: str, api_version: str, **kwargs: Any - ) -> "_models.GenericResource": + ) -> _models.GenericResource: """Gets a resource. :param resource_group_name: The name of the resource group containing the resource to get. The - name is case insensitive. + name is case insensitive. Required. :type resource_group_name: str - :param resource_provider_namespace: The namespace of the resource provider. + :param resource_provider_namespace: The namespace of the resource provider. Required. :type resource_provider_namespace: str - :param parent_resource_path: The parent resource identity. + :param parent_resource_path: The parent resource identity. Required. :type parent_resource_path: str - :param resource_type: The resource type of the resource. + :param resource_type: The resource type of the resource. Required. :type resource_type: str - :param resource_name: The name of the resource to get. + :param resource_name: The name of the resource to get. Required. :type resource_name: str - :param api_version: The API version to use for the operation. + :param api_version: The API version to use for the operation. Required. :type api_version: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: GenericResource, or the result of cls(response) + :return: GenericResource or the result of cls(response) :rtype: ~azure.mgmt.resource.resources.v2018_05_01.models.GenericResource - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.GenericResource"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = kwargs.pop("params", {}) or {} + + cls = kwargs.pop("cls", None) # type: ClsType[_models.GenericResource] - request = build_resources_get_request( resource_group_name=resource_group_name, resource_provider_namespace=resource_provider_namespace, @@ -4567,72 +5048,75 @@ def get( resource_name=resource_name, subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.get.metadata['url'], + template_url=self.get.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) - deserialized = self._deserialize('GenericResource', pipeline_response) + deserialized = self._deserialize("GenericResource", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - get.metadata = {'url': "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{parentResourcePath}/{resourceType}/{resourceName}"} # type: ignore - + get.metadata = {"url": "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{parentResourcePath}/{resourceType}/{resourceName}"} # type: ignore @distributed_trace - def check_existence_by_id( - self, - resource_id: str, - api_version: str, - **kwargs: Any - ) -> bool: + def check_existence_by_id(self, resource_id: str, api_version: str, **kwargs: Any) -> bool: """Checks by ID whether a resource exists. :param resource_id: The fully qualified ID of the resource, including the resource name and resource type. Use the format, /subscriptions/{guid}/resourceGroups/{resource-group-name}/{resource-provider-namespace}/{resource-type}/{resource-name}. + Required. :type resource_id: str - :param api_version: The API version to use for the operation. + :param api_version: The API version to use for the operation. Required. :type api_version: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: bool, or the result of cls(response) + :return: bool or the result of cls(response) :rtype: bool - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType[None] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = kwargs.pop("params", {}) or {} + + cls = kwargs.pop("cls", None) # type: ClsType[None] - request = build_resources_check_existence_by_id_request( resource_id=resource_id, api_version=api_version, - template_url=self.check_existence_by_id.metadata['url'], + template_url=self.check_existence_by_id.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [204, 404]: @@ -4643,35 +5127,38 @@ def check_existence_by_id( return cls(pipeline_response, None, {}) return 200 <= response.status_code <= 299 - check_existence_by_id.metadata = {'url': "/{resourceId}"} # type: ignore - + check_existence_by_id.metadata = {"url": "/{resourceId}"} # type: ignore def _delete_by_id_initial( # pylint: disable=inconsistent-return-statements - self, - resource_id: str, - api_version: str, - **kwargs: Any + self, resource_id: str, api_version: str, **kwargs: Any ) -> None: - cls = kwargs.pop('cls', None) # type: ClsType[None] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = kwargs.pop("params", {}) or {} + + cls = kwargs.pop("cls", None) # type: ClsType[None] - - request = build_resources_delete_by_id_request_initial( + request = build_resources_delete_by_id_request( resource_id=resource_id, api_version=api_version, - template_url=self._delete_by_id_initial.metadata['url'], + template_url=self._delete_by_id_initial.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200, 202, 204]: @@ -4681,23 +5168,18 @@ def _delete_by_id_initial( # pylint: disable=inconsistent-return-statements if cls: return cls(pipeline_response, None, {}) - _delete_by_id_initial.metadata = {'url': "/{resourceId}"} # type: ignore - + _delete_by_id_initial.metadata = {"url": "/{resourceId}"} # type: ignore @distributed_trace - def begin_delete_by_id( # pylint: disable=inconsistent-return-statements - self, - resource_id: str, - api_version: str, - **kwargs: Any - ) -> LROPoller[None]: + def begin_delete_by_id(self, resource_id: str, api_version: str, **kwargs: Any) -> LROPoller[None]: """Deletes a resource by ID. :param resource_id: The fully qualified ID of the resource, including the resource name and resource type. Use the format, /subscriptions/{guid}/resourceGroups/{resource-group-name}/{resource-provider-namespace}/{resource-type}/{resource-name}. + Required. :type resource_id: str - :param api_version: The API version to use for the operation. + :param api_version: The API version to use for the operation. Required. :type api_version: str :keyword callable cls: A custom type or function that will be passed the direct response :keyword str continuation_token: A continuation token to restart a poller from a saved state. @@ -4709,75 +5191,89 @@ def begin_delete_by_id( # pylint: disable=inconsistent-return-statements Retry-After header is present. :return: An instance of LROPoller that returns either None or the result of cls(response) :rtype: ~azure.core.polling.LROPoller[None] - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - polling = kwargs.pop('polling', True) # type: Union[bool, PollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType[None] - lro_delay = kwargs.pop( - 'polling_interval', - self._config.polling_interval - ) - cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] + _headers = kwargs.pop("headers", {}) or {} + _params = kwargs.pop("params", {}) or {} + + cls = kwargs.pop("cls", None) # type: ClsType[None] + polling = kwargs.pop("polling", True) # type: Union[bool, PollingMethod] + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token = kwargs.pop("continuation_token", None) # type: Optional[str] if cont_token is None: - raw_result = self._delete_by_id_initial( + raw_result = self._delete_by_id_initial( # type: ignore resource_id=resource_id, api_version=api_version, - cls=lambda x,y,z: x, + cls=lambda x, y, z: x, + headers=_headers, + params=_params, **kwargs ) - kwargs.pop('error_map', None) + kwargs.pop("error_map", None) - def get_long_running_output(pipeline_response): + def get_long_running_output(pipeline_response): # pylint: disable=inconsistent-return-statements if cls: return cls(pipeline_response, None, {}) - - if polling is True: polling_method = ARMPolling(lro_delay, **kwargs) - elif polling is False: polling_method = NoPolling() - else: polling_method = polling + if polling is True: + polling_method = cast(PollingMethod, ARMPolling(lro_delay, **kwargs)) # type: PollingMethod + elif polling is False: + polling_method = cast(PollingMethod, NoPolling()) + else: + polling_method = polling if cont_token: return LROPoller.from_continuation_token( polling_method=polling_method, continuation_token=cont_token, client=self._client, - deserialization_callback=get_long_running_output + deserialization_callback=get_long_running_output, ) return LROPoller(self._client, raw_result, get_long_running_output, polling_method) - begin_delete_by_id.metadata = {'url': "/{resourceId}"} # type: ignore + begin_delete_by_id.metadata = {"url": "/{resourceId}"} # type: ignore def _create_or_update_by_id_initial( - self, - resource_id: str, - api_version: str, - parameters: "_models.GenericResource", - **kwargs: Any - ) -> Optional["_models.GenericResource"]: - cls = kwargs.pop('cls', None) # type: ClsType[Optional["_models.GenericResource"]] + self, resource_id: str, api_version: str, parameters: Union[_models.GenericResource, IO], **kwargs: Any + ) -> Optional[_models.GenericResource]: error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = kwargs.pop("params", {}) or {} - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[Optional[_models.GenericResource]] - _json = self._serialize.body(parameters, 'GenericResource') + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(parameters, (IO, bytes)): + _content = parameters + else: + _json = self._serialize.body(parameters, "GenericResource") - request = build_resources_create_or_update_by_id_request_initial( + request = build_resources_create_or_update_by_id_request( resource_id=resource_id, - content_type=content_type, api_version=api_version, + content_type=content_type, json=_json, - template_url=self._create_or_update_by_id_initial.metadata['url'], + content=_content, + template_url=self._create_or_update_by_id_initial.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200, 201, 202]: @@ -4786,37 +5282,42 @@ def _create_or_update_by_id_initial( deserialized = None if response.status_code == 200: - deserialized = self._deserialize('GenericResource', pipeline_response) + deserialized = self._deserialize("GenericResource", pipeline_response) if response.status_code == 201: - deserialized = self._deserialize('GenericResource', pipeline_response) + deserialized = self._deserialize("GenericResource", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - _create_or_update_by_id_initial.metadata = {'url': "/{resourceId}"} # type: ignore + _create_or_update_by_id_initial.metadata = {"url": "/{resourceId}"} # type: ignore - - @distributed_trace + @overload def begin_create_or_update_by_id( self, resource_id: str, api_version: str, - parameters: "_models.GenericResource", + parameters: _models.GenericResource, + *, + content_type: str = "application/json", **kwargs: Any - ) -> LROPoller["_models.GenericResource"]: + ) -> LROPoller[_models.GenericResource]: """Create a resource by ID. :param resource_id: The fully qualified ID of the resource, including the resource name and resource type. Use the format, /subscriptions/{guid}/resourceGroups/{resource-group-name}/{resource-provider-namespace}/{resource-type}/{resource-name}. + Required. :type resource_id: str - :param api_version: The API version to use for the operation. + :param api_version: The API version to use for the operation. Required. :type api_version: str - :param parameters: Create or update resource parameters. + :param parameters: Create or update resource parameters. Required. :type parameters: ~azure.mgmt.resource.resources.v2018_05_01.models.GenericResource + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str :keyword callable cls: A custom type or function that will be passed the direct response :keyword str continuation_token: A continuation token to restart a poller from a saved state. :keyword polling: By default, your polling method will be ARMPolling. Pass in False for this @@ -4829,81 +5330,167 @@ def begin_create_or_update_by_id( cls(response) :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.resource.resources.v2018_05_01.models.GenericResource] - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] - polling = kwargs.pop('polling', True) # type: Union[bool, PollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType["_models.GenericResource"] - lro_delay = kwargs.pop( - 'polling_interval', - self._config.polling_interval - ) - cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] + + @overload + def begin_create_or_update_by_id( + self, + resource_id: str, + api_version: str, + parameters: IO, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> LROPoller[_models.GenericResource]: + """Create a resource by ID. + + :param resource_id: The fully qualified ID of the resource, including the resource name and + resource type. Use the format, + /subscriptions/{guid}/resourceGroups/{resource-group-name}/{resource-provider-namespace}/{resource-type}/{resource-name}. + Required. + :type resource_id: str + :param api_version: The API version to use for the operation. Required. + :type api_version: str + :param parameters: Create or update resource parameters. Required. + :type parameters: IO + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be ARMPolling. Pass in False for this + operation to not poll, or pass in your own initialized polling object for a personal polling + strategy. + :paramtype polling: bool or ~azure.core.polling.PollingMethod + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of LROPoller that returns either GenericResource or the result of + cls(response) + :rtype: + ~azure.core.polling.LROPoller[~azure.mgmt.resource.resources.v2018_05_01.models.GenericResource] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace + def begin_create_or_update_by_id( + self, resource_id: str, api_version: str, parameters: Union[_models.GenericResource, IO], **kwargs: Any + ) -> LROPoller[_models.GenericResource]: + """Create a resource by ID. + + :param resource_id: The fully qualified ID of the resource, including the resource name and + resource type. Use the format, + /subscriptions/{guid}/resourceGroups/{resource-group-name}/{resource-provider-namespace}/{resource-type}/{resource-name}. + Required. + :type resource_id: str + :param api_version: The API version to use for the operation. Required. + :type api_version: str + :param parameters: Create or update resource parameters. Is either a model type or a IO type. + Required. + :type parameters: ~azure.mgmt.resource.resources.v2018_05_01.models.GenericResource or IO + :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. + Default value is None. + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be ARMPolling. Pass in False for this + operation to not poll, or pass in your own initialized polling object for a personal polling + strategy. + :paramtype polling: bool or ~azure.core.polling.PollingMethod + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of LROPoller that returns either GenericResource or the result of + cls(response) + :rtype: + ~azure.core.polling.LROPoller[~azure.mgmt.resource.resources.v2018_05_01.models.GenericResource] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = kwargs.pop("params", {}) or {} + + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.GenericResource] + polling = kwargs.pop("polling", True) # type: Union[bool, PollingMethod] + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token = kwargs.pop("continuation_token", None) # type: Optional[str] if cont_token is None: - raw_result = self._create_or_update_by_id_initial( + raw_result = self._create_or_update_by_id_initial( # type: ignore resource_id=resource_id, api_version=api_version, parameters=parameters, content_type=content_type, - cls=lambda x,y,z: x, + cls=lambda x, y, z: x, + headers=_headers, + params=_params, **kwargs ) - kwargs.pop('error_map', None) + kwargs.pop("error_map", None) def get_long_running_output(pipeline_response): - response = pipeline_response.http_response - deserialized = self._deserialize('GenericResource', pipeline_response) + deserialized = self._deserialize("GenericResource", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - - if polling is True: polling_method = ARMPolling(lro_delay, **kwargs) - elif polling is False: polling_method = NoPolling() - else: polling_method = polling + if polling is True: + polling_method = cast(PollingMethod, ARMPolling(lro_delay, **kwargs)) # type: PollingMethod + elif polling is False: + polling_method = cast(PollingMethod, NoPolling()) + else: + polling_method = polling if cont_token: return LROPoller.from_continuation_token( polling_method=polling_method, continuation_token=cont_token, client=self._client, - deserialization_callback=get_long_running_output + deserialization_callback=get_long_running_output, ) return LROPoller(self._client, raw_result, get_long_running_output, polling_method) - begin_create_or_update_by_id.metadata = {'url': "/{resourceId}"} # type: ignore + begin_create_or_update_by_id.metadata = {"url": "/{resourceId}"} # type: ignore def _update_by_id_initial( - self, - resource_id: str, - api_version: str, - parameters: "_models.GenericResource", - **kwargs: Any - ) -> Optional["_models.GenericResource"]: - cls = kwargs.pop('cls', None) # type: ClsType[Optional["_models.GenericResource"]] + self, resource_id: str, api_version: str, parameters: Union[_models.GenericResource, IO], **kwargs: Any + ) -> Optional[_models.GenericResource]: error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = kwargs.pop("params", {}) or {} - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[Optional[_models.GenericResource]] - _json = self._serialize.body(parameters, 'GenericResource') + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(parameters, (IO, bytes)): + _content = parameters + else: + _json = self._serialize.body(parameters, "GenericResource") - request = build_resources_update_by_id_request_initial( + request = build_resources_update_by_id_request( resource_id=resource_id, - content_type=content_type, api_version=api_version, + content_type=content_type, json=_json, - template_url=self._update_by_id_initial.metadata['url'], + content=_content, + template_url=self._update_by_id_initial.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200, 202]: @@ -4912,34 +5499,78 @@ def _update_by_id_initial( deserialized = None if response.status_code == 200: - deserialized = self._deserialize('GenericResource', pipeline_response) + deserialized = self._deserialize("GenericResource", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - _update_by_id_initial.metadata = {'url': "/{resourceId}"} # type: ignore + _update_by_id_initial.metadata = {"url": "/{resourceId}"} # type: ignore + @overload + def begin_update_by_id( + self, + resource_id: str, + api_version: str, + parameters: _models.GenericResource, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> LROPoller[_models.GenericResource]: + """Updates a resource by ID. + + :param resource_id: The fully qualified ID of the resource, including the resource name and + resource type. Use the format, + /subscriptions/{guid}/resourceGroups/{resource-group-name}/{resource-provider-namespace}/{resource-type}/{resource-name}. + Required. + :type resource_id: str + :param api_version: The API version to use for the operation. Required. + :type api_version: str + :param parameters: Update resource parameters. Required. + :type parameters: ~azure.mgmt.resource.resources.v2018_05_01.models.GenericResource + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be ARMPolling. Pass in False for this + operation to not poll, or pass in your own initialized polling object for a personal polling + strategy. + :paramtype polling: bool or ~azure.core.polling.PollingMethod + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of LROPoller that returns either GenericResource or the result of + cls(response) + :rtype: + ~azure.core.polling.LROPoller[~azure.mgmt.resource.resources.v2018_05_01.models.GenericResource] + :raises ~azure.core.exceptions.HttpResponseError: + """ - @distributed_trace + @overload def begin_update_by_id( self, resource_id: str, api_version: str, - parameters: "_models.GenericResource", + parameters: IO, + *, + content_type: str = "application/json", **kwargs: Any - ) -> LROPoller["_models.GenericResource"]: + ) -> LROPoller[_models.GenericResource]: """Updates a resource by ID. :param resource_id: The fully qualified ID of the resource, including the resource name and resource type. Use the format, /subscriptions/{guid}/resourceGroups/{resource-group-name}/{resource-provider-namespace}/{resource-type}/{resource-name}. + Required. :type resource_id: str - :param api_version: The API version to use for the operation. + :param api_version: The API version to use for the operation. Required. :type api_version: str - :param parameters: Update resource parameters. - :type parameters: ~azure.mgmt.resource.resources.v2018_05_01.models.GenericResource + :param parameters: Update resource parameters. Required. + :type parameters: IO + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: str :keyword callable cls: A custom type or function that will be passed the direct response :keyword str continuation_token: A continuation token to restart a poller from a saved state. :keyword polling: By default, your polling method will be ARMPolling. Pass in False for this @@ -4952,165 +5583,204 @@ def begin_update_by_id( cls(response) :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.resource.resources.v2018_05_01.models.GenericResource] - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] - polling = kwargs.pop('polling', True) # type: Union[bool, PollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType["_models.GenericResource"] - lro_delay = kwargs.pop( - 'polling_interval', - self._config.polling_interval - ) - cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] + + @distributed_trace + def begin_update_by_id( + self, resource_id: str, api_version: str, parameters: Union[_models.GenericResource, IO], **kwargs: Any + ) -> LROPoller[_models.GenericResource]: + """Updates a resource by ID. + + :param resource_id: The fully qualified ID of the resource, including the resource name and + resource type. Use the format, + /subscriptions/{guid}/resourceGroups/{resource-group-name}/{resource-provider-namespace}/{resource-type}/{resource-name}. + Required. + :type resource_id: str + :param api_version: The API version to use for the operation. Required. + :type api_version: str + :param parameters: Update resource parameters. Is either a model type or a IO type. Required. + :type parameters: ~azure.mgmt.resource.resources.v2018_05_01.models.GenericResource or IO + :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. + Default value is None. + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be ARMPolling. Pass in False for this + operation to not poll, or pass in your own initialized polling object for a personal polling + strategy. + :paramtype polling: bool or ~azure.core.polling.PollingMethod + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of LROPoller that returns either GenericResource or the result of + cls(response) + :rtype: + ~azure.core.polling.LROPoller[~azure.mgmt.resource.resources.v2018_05_01.models.GenericResource] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = kwargs.pop("params", {}) or {} + + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.GenericResource] + polling = kwargs.pop("polling", True) # type: Union[bool, PollingMethod] + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token = kwargs.pop("continuation_token", None) # type: Optional[str] if cont_token is None: - raw_result = self._update_by_id_initial( + raw_result = self._update_by_id_initial( # type: ignore resource_id=resource_id, api_version=api_version, parameters=parameters, content_type=content_type, - cls=lambda x,y,z: x, + cls=lambda x, y, z: x, + headers=_headers, + params=_params, **kwargs ) - kwargs.pop('error_map', None) + kwargs.pop("error_map", None) def get_long_running_output(pipeline_response): - response = pipeline_response.http_response - deserialized = self._deserialize('GenericResource', pipeline_response) + deserialized = self._deserialize("GenericResource", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - - if polling is True: polling_method = ARMPolling(lro_delay, **kwargs) - elif polling is False: polling_method = NoPolling() - else: polling_method = polling + if polling is True: + polling_method = cast(PollingMethod, ARMPolling(lro_delay, **kwargs)) # type: PollingMethod + elif polling is False: + polling_method = cast(PollingMethod, NoPolling()) + else: + polling_method = polling if cont_token: return LROPoller.from_continuation_token( polling_method=polling_method, continuation_token=cont_token, client=self._client, - deserialization_callback=get_long_running_output + deserialization_callback=get_long_running_output, ) return LROPoller(self._client, raw_result, get_long_running_output, polling_method) - begin_update_by_id.metadata = {'url': "/{resourceId}"} # type: ignore + begin_update_by_id.metadata = {"url": "/{resourceId}"} # type: ignore @distributed_trace - def get_by_id( - self, - resource_id: str, - api_version: str, - **kwargs: Any - ) -> "_models.GenericResource": + def get_by_id(self, resource_id: str, api_version: str, **kwargs: Any) -> _models.GenericResource: """Gets a resource by ID. :param resource_id: The fully qualified ID of the resource, including the resource name and resource type. Use the format, /subscriptions/{guid}/resourceGroups/{resource-group-name}/{resource-provider-namespace}/{resource-type}/{resource-name}. + Required. :type resource_id: str - :param api_version: The API version to use for the operation. + :param api_version: The API version to use for the operation. Required. :type api_version: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: GenericResource, or the result of cls(response) + :return: GenericResource or the result of cls(response) :rtype: ~azure.mgmt.resource.resources.v2018_05_01.models.GenericResource - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.GenericResource"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = kwargs.pop("params", {}) or {} + + cls = kwargs.pop("cls", None) # type: ClsType[_models.GenericResource] - request = build_resources_get_by_id_request( resource_id=resource_id, api_version=api_version, - template_url=self.get_by_id.metadata['url'], + template_url=self.get_by_id.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) - deserialized = self._deserialize('GenericResource', pipeline_response) + deserialized = self._deserialize("GenericResource", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - get_by_id.metadata = {'url': "/{resourceId}"} # type: ignore + get_by_id.metadata = {"url": "/{resourceId}"} # type: ignore -class ResourceGroupsOperations(object): - """ResourceGroupsOperations operations. - You should not instantiate this class directly. Instead, you should create a Client instance that - instantiates it for you and attaches it as an attribute. +class ResourceGroupsOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. - :ivar models: Alias to model classes used in this operation group. - :type models: ~azure.mgmt.resource.resources.v2018_05_01.models - :param client: Client for service requests. - :param config: Configuration of service client. - :param serializer: An object model serializer. - :param deserializer: An object model deserializer. + Instead, you should access the following operations through + :class:`~azure.mgmt.resource.resources.v2018_05_01.ResourceManagementClient`'s + :attr:`resource_groups` attribute. """ models = _models - def __init__(self, client, config, serializer, deserializer): - self._client = client - self._serialize = serializer - self._deserialize = deserializer - self._config = config + def __init__(self, *args, **kwargs): + input_args = list(args) + self._client = input_args.pop(0) if input_args else kwargs.pop("client") + self._config = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") @distributed_trace - def check_existence( - self, - resource_group_name: str, - **kwargs: Any - ) -> bool: + def check_existence(self, resource_group_name: str, **kwargs: Any) -> bool: """Checks whether a resource group exists. :param resource_group_name: The name of the resource group to check. The name is case - insensitive. + insensitive. Required. :type resource_group_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: bool, or the result of cls(response) + :return: bool or the result of cls(response) :rtype: bool - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType[None] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) - api_version = kwargs.pop('api_version', "2018-05-01") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2018-05-01")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[None] - request = build_resource_groups_check_existence_request( resource_group_name=resource_group_name, subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.check_existence.metadata['url'], + template_url=self.check_existence.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [204, 404]: @@ -5121,39 +5791,98 @@ def check_existence( return cls(pipeline_response, None, {}) return 200 <= response.status_code <= 299 - check_existence.metadata = {'url': "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}"} # type: ignore + check_existence.metadata = {"url": "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}"} # type: ignore - - @distributed_trace + @overload def create_or_update( self, resource_group_name: str, - parameters: "_models.ResourceGroup", + parameters: _models.ResourceGroup, + *, + content_type: str = "application/json", **kwargs: Any - ) -> "_models.ResourceGroup": + ) -> _models.ResourceGroup: """Creates or updates a resource group. :param resource_group_name: The name of the resource group to create or update. Can include alphanumeric, underscore, parentheses, hyphen, period (except at end), and Unicode characters - that match the allowed characters. + that match the allowed characters. Required. :type resource_group_name: str - :param parameters: Parameters supplied to the create or update a resource group. + :param parameters: Parameters supplied to the create or update a resource group. Required. :type parameters: ~azure.mgmt.resource.resources.v2018_05_01.models.ResourceGroup + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: ResourceGroup or the result of cls(response) + :rtype: ~azure.mgmt.resource.resources.v2018_05_01.models.ResourceGroup + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + def create_or_update( + self, resource_group_name: str, parameters: IO, *, content_type: str = "application/json", **kwargs: Any + ) -> _models.ResourceGroup: + """Creates or updates a resource group. + + :param resource_group_name: The name of the resource group to create or update. Can include + alphanumeric, underscore, parentheses, hyphen, period (except at end), and Unicode characters + that match the allowed characters. Required. + :type resource_group_name: str + :param parameters: Parameters supplied to the create or update a resource group. Required. + :type parameters: IO + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: ResourceGroup, or the result of cls(response) + :return: ResourceGroup or the result of cls(response) :rtype: ~azure.mgmt.resource.resources.v2018_05_01.models.ResourceGroup - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace + def create_or_update( + self, resource_group_name: str, parameters: Union[_models.ResourceGroup, IO], **kwargs: Any + ) -> _models.ResourceGroup: + """Creates or updates a resource group. + + :param resource_group_name: The name of the resource group to create or update. Can include + alphanumeric, underscore, parentheses, hyphen, period (except at end), and Unicode characters + that match the allowed characters. Required. + :type resource_group_name: str + :param parameters: Parameters supplied to the create or update a resource group. Is either a + model type or a IO type. Required. + :type parameters: ~azure.mgmt.resource.resources.v2018_05_01.models.ResourceGroup or IO + :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. + Default value is None. + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: ResourceGroup or the result of cls(response) + :rtype: ~azure.mgmt.resource.resources.v2018_05_01.models.ResourceGroup + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.ResourceGroup"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) - api_version = kwargs.pop('api_version', "2018-05-01") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - _json = self._serialize.body(parameters, 'ResourceGroup') + api_version = kwargs.pop("api_version", _params.pop("api-version", "2018-05-01")) # type: str + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.ResourceGroup] + + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(parameters, (IO, bytes)): + _content = parameters + else: + _json = self._serialize.body(parameters, "ResourceGroup") request = build_resource_groups_create_or_update_request( resource_group_name=resource_group_name, @@ -5161,16 +5890,18 @@ def create_or_update( api_version=api_version, content_type=content_type, json=_json, - template_url=self.create_or_update.metadata['url'], + content=_content, + template_url=self.create_or_update.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200, 201]: @@ -5178,47 +5909,50 @@ def create_or_update( raise HttpResponseError(response=response, error_format=ARMErrorFormat) if response.status_code == 200: - deserialized = self._deserialize('ResourceGroup', pipeline_response) + deserialized = self._deserialize("ResourceGroup", pipeline_response) if response.status_code == 201: - deserialized = self._deserialize('ResourceGroup', pipeline_response) + deserialized = self._deserialize("ResourceGroup", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - create_or_update.metadata = {'url': "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}"} # type: ignore - + create_or_update.metadata = {"url": "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}"} # type: ignore def _delete_initial( # pylint: disable=inconsistent-return-statements - self, - resource_group_name: str, - **kwargs: Any + self, resource_group_name: str, **kwargs: Any ) -> None: - cls = kwargs.pop('cls', None) # type: ClsType[None] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) - api_version = kwargs.pop('api_version', "2018-05-01") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - request = build_resource_groups_delete_request_initial( + api_version = kwargs.pop("api_version", _params.pop("api-version", "2018-05-01")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[None] + + request = build_resource_groups_delete_request( resource_group_name=resource_group_name, subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self._delete_initial.metadata['url'], + template_url=self._delete_initial.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200, 202]: @@ -5228,22 +5962,17 @@ def _delete_initial( # pylint: disable=inconsistent-return-statements if cls: return cls(pipeline_response, None, {}) - _delete_initial.metadata = {'url': "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}"} # type: ignore - + _delete_initial.metadata = {"url": "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}"} # type: ignore @distributed_trace - def begin_delete( # pylint: disable=inconsistent-return-statements - self, - resource_group_name: str, - **kwargs: Any - ) -> LROPoller[None]: + def begin_delete(self, resource_group_name: str, **kwargs: Any) -> LROPoller[None]: """Deletes a resource group. When you delete a resource group, all of its resources are also deleted. Deleting a resource group deletes all of its template deployments and currently stored operations. :param resource_group_name: The name of the resource group to delete. The name is case - insensitive. + insensitive. Required. :type resource_group_name: str :keyword callable cls: A custom type or function that will be passed the direct response :keyword str continuation_token: A continuation token to restart a poller from a saved state. @@ -5255,106 +5984,113 @@ def begin_delete( # pylint: disable=inconsistent-return-statements Retry-After header is present. :return: An instance of LROPoller that returns either None or the result of cls(response) :rtype: ~azure.core.polling.LROPoller[None] - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - api_version = kwargs.pop('api_version', "2018-05-01") # type: str - polling = kwargs.pop('polling', True) # type: Union[bool, PollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType[None] - lro_delay = kwargs.pop( - 'polling_interval', - self._config.polling_interval - ) - cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2018-05-01")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[None] + polling = kwargs.pop("polling", True) # type: Union[bool, PollingMethod] + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token = kwargs.pop("continuation_token", None) # type: Optional[str] if cont_token is None: - raw_result = self._delete_initial( + raw_result = self._delete_initial( # type: ignore resource_group_name=resource_group_name, api_version=api_version, - cls=lambda x,y,z: x, + cls=lambda x, y, z: x, + headers=_headers, + params=_params, **kwargs ) - kwargs.pop('error_map', None) + kwargs.pop("error_map", None) - def get_long_running_output(pipeline_response): + def get_long_running_output(pipeline_response): # pylint: disable=inconsistent-return-statements if cls: return cls(pipeline_response, None, {}) - - if polling is True: polling_method = ARMPolling(lro_delay, **kwargs) - elif polling is False: polling_method = NoPolling() - else: polling_method = polling + if polling is True: + polling_method = cast(PollingMethod, ARMPolling(lro_delay, **kwargs)) # type: PollingMethod + elif polling is False: + polling_method = cast(PollingMethod, NoPolling()) + else: + polling_method = polling if cont_token: return LROPoller.from_continuation_token( polling_method=polling_method, continuation_token=cont_token, client=self._client, - deserialization_callback=get_long_running_output + deserialization_callback=get_long_running_output, ) return LROPoller(self._client, raw_result, get_long_running_output, polling_method) - begin_delete.metadata = {'url': "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}"} # type: ignore + begin_delete.metadata = {"url": "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}"} # type: ignore @distributed_trace - def get( - self, - resource_group_name: str, - **kwargs: Any - ) -> "_models.ResourceGroup": + def get(self, resource_group_name: str, **kwargs: Any) -> _models.ResourceGroup: """Gets a resource group. :param resource_group_name: The name of the resource group to get. The name is case - insensitive. + insensitive. Required. :type resource_group_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: ResourceGroup, or the result of cls(response) + :return: ResourceGroup or the result of cls(response) :rtype: ~azure.mgmt.resource.resources.v2018_05_01.models.ResourceGroup - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.ResourceGroup"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) - api_version = kwargs.pop('api_version', "2018-05-01") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2018-05-01")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[_models.ResourceGroup] - request = build_resource_groups_get_request( resource_group_name=resource_group_name, subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.get.metadata['url'], + template_url=self.get.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) - deserialized = self._deserialize('ResourceGroup', pipeline_response) + deserialized = self._deserialize("ResourceGroup", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - get.metadata = {'url': "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}"} # type: ignore + get.metadata = {"url": "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}"} # type: ignore - - @distributed_trace + @overload def update( self, resource_group_name: str, - parameters: "_models.ResourceGroupPatchable", + parameters: _models.ResourceGroupPatchable, + *, + content_type: str = "application/json", **kwargs: Any - ) -> "_models.ResourceGroup": + ) -> _models.ResourceGroup: """Updates a resource group. Resource groups can be updated through a simple PATCH operation to a group address. The format @@ -5362,25 +6098,90 @@ def update( the current value is retained. :param resource_group_name: The name of the resource group to update. The name is case - insensitive. + insensitive. Required. :type resource_group_name: str - :param parameters: Parameters supplied to update a resource group. + :param parameters: Parameters supplied to update a resource group. Required. :type parameters: ~azure.mgmt.resource.resources.v2018_05_01.models.ResourceGroupPatchable + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: ResourceGroup or the result of cls(response) + :rtype: ~azure.mgmt.resource.resources.v2018_05_01.models.ResourceGroup + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + def update( + self, resource_group_name: str, parameters: IO, *, content_type: str = "application/json", **kwargs: Any + ) -> _models.ResourceGroup: + """Updates a resource group. + + Resource groups can be updated through a simple PATCH operation to a group address. The format + of the request is the same as that for creating a resource group. If a field is unspecified, + the current value is retained. + + :param resource_group_name: The name of the resource group to update. The name is case + insensitive. Required. + :type resource_group_name: str + :param parameters: Parameters supplied to update a resource group. Required. + :type parameters: IO + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: ResourceGroup or the result of cls(response) + :rtype: ~azure.mgmt.resource.resources.v2018_05_01.models.ResourceGroup + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace + def update( + self, resource_group_name: str, parameters: Union[_models.ResourceGroupPatchable, IO], **kwargs: Any + ) -> _models.ResourceGroup: + """Updates a resource group. + + Resource groups can be updated through a simple PATCH operation to a group address. The format + of the request is the same as that for creating a resource group. If a field is unspecified, + the current value is retained. + + :param resource_group_name: The name of the resource group to update. The name is case + insensitive. Required. + :type resource_group_name: str + :param parameters: Parameters supplied to update a resource group. Is either a model type or a + IO type. Required. + :type parameters: ~azure.mgmt.resource.resources.v2018_05_01.models.ResourceGroupPatchable or + IO + :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. + Default value is None. + :paramtype content_type: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: ResourceGroup, or the result of cls(response) + :return: ResourceGroup or the result of cls(response) :rtype: ~azure.mgmt.resource.resources.v2018_05_01.models.ResourceGroup - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.ResourceGroup"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) - api_version = kwargs.pop('api_version', "2018-05-01") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - _json = self._serialize.body(parameters, 'ResourceGroupPatchable') + api_version = kwargs.pop("api_version", _params.pop("api-version", "2018-05-01")) # type: str + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.ResourceGroup] + + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(parameters, (IO, bytes)): + _content = parameters + else: + _json = self._serialize.body(parameters, "ResourceGroupPatchable") request = build_resource_groups_update_request( resource_group_name=resource_group_name, @@ -5388,60 +6189,117 @@ def update( api_version=api_version, content_type=content_type, json=_json, - template_url=self.update.metadata['url'], + content=_content, + template_url=self.update.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) - deserialized = self._deserialize('ResourceGroup', pipeline_response) + deserialized = self._deserialize("ResourceGroup", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - update.metadata = {'url': "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}"} # type: ignore + update.metadata = {"url": "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}"} # type: ignore - - @distributed_trace + @overload def export_template( self, resource_group_name: str, - parameters: "_models.ExportTemplateRequest", + parameters: _models.ExportTemplateRequest, + *, + content_type: str = "application/json", **kwargs: Any - ) -> "_models.ResourceGroupExportResult": + ) -> _models.ResourceGroupExportResult: """Captures the specified resource group as a template. - :param resource_group_name: The name of the resource group to export as a template. + :param resource_group_name: The name of the resource group to export as a template. Required. :type resource_group_name: str - :param parameters: Parameters for exporting the template. + :param parameters: Parameters for exporting the template. Required. :type parameters: ~azure.mgmt.resource.resources.v2018_05_01.models.ExportTemplateRequest + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: ResourceGroupExportResult or the result of cls(response) + :rtype: ~azure.mgmt.resource.resources.v2018_05_01.models.ResourceGroupExportResult + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + def export_template( + self, resource_group_name: str, parameters: IO, *, content_type: str = "application/json", **kwargs: Any + ) -> _models.ResourceGroupExportResult: + """Captures the specified resource group as a template. + + :param resource_group_name: The name of the resource group to export as a template. Required. + :type resource_group_name: str + :param parameters: Parameters for exporting the template. Required. + :type parameters: IO + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: ResourceGroupExportResult or the result of cls(response) + :rtype: ~azure.mgmt.resource.resources.v2018_05_01.models.ResourceGroupExportResult + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace + def export_template( + self, resource_group_name: str, parameters: Union[_models.ExportTemplateRequest, IO], **kwargs: Any + ) -> _models.ResourceGroupExportResult: + """Captures the specified resource group as a template. + + :param resource_group_name: The name of the resource group to export as a template. Required. + :type resource_group_name: str + :param parameters: Parameters for exporting the template. Is either a model type or a IO type. + Required. + :type parameters: ~azure.mgmt.resource.resources.v2018_05_01.models.ExportTemplateRequest or IO + :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. + Default value is None. + :paramtype content_type: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: ResourceGroupExportResult, or the result of cls(response) + :return: ResourceGroupExportResult or the result of cls(response) :rtype: ~azure.mgmt.resource.resources.v2018_05_01.models.ResourceGroupExportResult - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.ResourceGroupExportResult"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) - api_version = kwargs.pop('api_version', "2018-05-01") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - _json = self._serialize.body(parameters, 'ExportTemplateRequest') + api_version = kwargs.pop("api_version", _params.pop("api-version", "2018-05-01")) # type: str + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.ResourceGroupExportResult] + + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(parameters, (IO, bytes)): + _content = parameters + else: + _json = self._serialize.body(parameters, "ExportTemplateRequest") request = build_resource_groups_export_template_request( resource_group_name=resource_group_name, @@ -5449,39 +6307,37 @@ def export_template( api_version=api_version, content_type=content_type, json=_json, - template_url=self.export_template.metadata['url'], + content=_content, + template_url=self.export_template.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) - deserialized = self._deserialize('ResourceGroupExportResult', pipeline_response) + deserialized = self._deserialize("ResourceGroupExportResult", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - export_template.metadata = {'url': "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/exportTemplate"} # type: ignore - + export_template.metadata = {"url": "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/exportTemplate"} # type: ignore @distributed_trace def list( - self, - filter: Optional[str] = None, - top: Optional[int] = None, - **kwargs: Any - ) -> Iterable["_models.ResourceGroupListResult"]: + self, filter: Optional[str] = None, top: Optional[int] = None, **kwargs: Any + ) -> Iterable["_models.ResourceGroup"]: """Gets all the resource groups for a subscription. :param filter: The filter to apply on the operation.:code:`
`:code:`
`You can filter by @@ -5492,40 +6348,48 @@ def list( Default value is None. :type top: int :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either ResourceGroupListResult or the result of - cls(response) + :return: An iterator like instance of either ResourceGroup or the result of cls(response) :rtype: - ~azure.core.paging.ItemPaged[~azure.mgmt.resource.resources.v2018_05_01.models.ResourceGroupListResult] - :raises: ~azure.core.exceptions.HttpResponseError + ~azure.core.paging.ItemPaged[~azure.mgmt.resource.resources.v2018_05_01.models.ResourceGroup] + :raises ~azure.core.exceptions.HttpResponseError: """ - api_version = kwargs.pop('api_version', "2018-05-01") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2018-05-01")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[_models.ResourceGroupListResult] - cls = kwargs.pop('cls', None) # type: ClsType["_models.ResourceGroupListResult"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) + def prepare_request(next_link=None): if not next_link: - + request = build_resource_groups_list_request( subscription_id=self._config.subscription_id, - api_version=api_version, filter=filter, top=top, - template_url=self.list.metadata['url'], + 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.url = self._client.format_url(request.url) # type: ignore else: - - request = build_resource_groups_list_request( - subscription_id=self._config.subscription_id, - template_url=next_link, - ) + # make call to next link with the client's api-version + _parsed_next_link = urlparse(next_link) + _next_request_params = case_insensitive_dict(parse_qs(_parsed_next_link.query)) + _next_request_params["api-version"] = self._config.api_version + request = HttpRequest("GET", urljoin(next_link, _parsed_next_link.path), params=_next_request_params) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore request.method = "GET" return request @@ -5539,10 +6403,8 @@ def extract_data(pipeline_response): def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) response = pipeline_response.http_response @@ -5552,75 +6414,75 @@ def get_next(next_link=None): return pipeline_response + return ItemPaged(get_next, extract_data) - return ItemPaged( - get_next, extract_data - ) - list.metadata = {'url': "/subscriptions/{subscriptionId}/resourcegroups"} # type: ignore -class TagsOperations(object): - """TagsOperations operations. - - You should not instantiate this class directly. Instead, you should create a Client instance that - instantiates it for you and attaches it as an attribute. - - :ivar models: Alias to model classes used in this operation group. - :type models: ~azure.mgmt.resource.resources.v2018_05_01.models - :param client: Client for service requests. - :param config: Configuration of service client. - :param serializer: An object model serializer. - :param deserializer: An object model deserializer. + list.metadata = {"url": "/subscriptions/{subscriptionId}/resourcegroups"} # type: ignore + + +class TagsOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. + + Instead, you should access the following operations through + :class:`~azure.mgmt.resource.resources.v2018_05_01.ResourceManagementClient`'s + :attr:`tags` attribute. """ models = _models - def __init__(self, client, config, serializer, deserializer): - self._client = client - self._serialize = serializer - self._deserialize = deserializer - self._config = config + def __init__(self, *args, **kwargs): + input_args = list(args) + self._client = input_args.pop(0) if input_args else kwargs.pop("client") + self._config = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") @distributed_trace def delete_value( # pylint: disable=inconsistent-return-statements - self, - tag_name: str, - tag_value: str, - **kwargs: Any + self, tag_name: str, tag_value: str, **kwargs: Any ) -> None: """Deletes a tag value. - :param tag_name: The name of the tag. + :param tag_name: The name of the tag. Required. :type tag_name: str - :param tag_value: The value of the tag to delete. + :param tag_value: The value of the tag to delete. Required. :type tag_value: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: None, or the result of cls(response) + :return: None or the result of cls(response) :rtype: None - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType[None] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) - api_version = kwargs.pop('api_version', "2018-05-01") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2018-05-01")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[None] - request = build_tags_delete_value_request( tag_name=tag_name, tag_value=tag_value, subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.delete_value.metadata['url'], + template_url=self.delete_value.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200, 204]: @@ -5630,51 +6492,51 @@ def delete_value( # pylint: disable=inconsistent-return-statements if cls: return cls(pipeline_response, None, {}) - delete_value.metadata = {'url': "/subscriptions/{subscriptionId}/tagNames/{tagName}/tagValues/{tagValue}"} # type: ignore - + delete_value.metadata = {"url": "/subscriptions/{subscriptionId}/tagNames/{tagName}/tagValues/{tagValue}"} # type: ignore @distributed_trace - def create_or_update_value( - self, - tag_name: str, - tag_value: str, - **kwargs: Any - ) -> "_models.TagValue": + def create_or_update_value(self, tag_name: str, tag_value: str, **kwargs: Any) -> _models.TagValue: """Creates a tag value. The name of the tag must already exist. - :param tag_name: The name of the tag. + :param tag_name: The name of the tag. Required. :type tag_name: str - :param tag_value: The value of the tag to create. + :param tag_value: The value of the tag to create. Required. :type tag_value: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: TagValue, or the result of cls(response) + :return: TagValue or the result of cls(response) :rtype: ~azure.mgmt.resource.resources.v2018_05_01.models.TagValue - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.TagValue"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + 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', "2018-05-01") # type: str + api_version = kwargs.pop("api_version", _params.pop("api-version", "2018-05-01")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[_models.TagValue] - request = build_tags_create_or_update_value_request( tag_name=tag_name, tag_value=tag_value, subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.create_or_update_value.metadata['url'], + template_url=self.create_or_update_value.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200, 201]: @@ -5682,61 +6544,62 @@ def create_or_update_value( raise HttpResponseError(response=response, error_format=ARMErrorFormat) if response.status_code == 200: - deserialized = self._deserialize('TagValue', pipeline_response) + deserialized = self._deserialize("TagValue", pipeline_response) if response.status_code == 201: - deserialized = self._deserialize('TagValue', pipeline_response) + deserialized = self._deserialize("TagValue", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - create_or_update_value.metadata = {'url': "/subscriptions/{subscriptionId}/tagNames/{tagName}/tagValues/{tagValue}"} # type: ignore - + create_or_update_value.metadata = {"url": "/subscriptions/{subscriptionId}/tagNames/{tagName}/tagValues/{tagValue}"} # type: ignore @distributed_trace - def create_or_update( - self, - tag_name: str, - **kwargs: Any - ) -> "_models.TagDetails": + def create_or_update(self, tag_name: str, **kwargs: Any) -> _models.TagDetails: """Creates a tag in the subscription. The tag name can have a maximum of 512 characters and is case insensitive. Tag names created by Azure have prefixes of microsoft, azure, or windows. You cannot create tags with one of these prefixes. - :param tag_name: The name of the tag to create. + :param tag_name: The name of the tag to create. Required. :type tag_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: TagDetails, or the result of cls(response) + :return: TagDetails or the result of cls(response) :rtype: ~azure.mgmt.resource.resources.v2018_05_01.models.TagDetails - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.TagDetails"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + 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', "2018-05-01") # type: str + api_version = kwargs.pop("api_version", _params.pop("api-version", "2018-05-01")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[_models.TagDetails] - request = build_tags_create_or_update_request( tag_name=tag_name, subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.create_or_update.metadata['url'], + template_url=self.create_or_update.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200, 201]: @@ -5744,59 +6607,60 @@ def create_or_update( raise HttpResponseError(response=response, error_format=ARMErrorFormat) if response.status_code == 200: - deserialized = self._deserialize('TagDetails', pipeline_response) + deserialized = self._deserialize("TagDetails", pipeline_response) if response.status_code == 201: - deserialized = self._deserialize('TagDetails', pipeline_response) + deserialized = self._deserialize("TagDetails", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - create_or_update.metadata = {'url': "/subscriptions/{subscriptionId}/tagNames/{tagName}"} # type: ignore - + create_or_update.metadata = {"url": "/subscriptions/{subscriptionId}/tagNames/{tagName}"} # type: ignore @distributed_trace - def delete( # pylint: disable=inconsistent-return-statements - self, - tag_name: str, - **kwargs: Any - ) -> None: + def delete(self, tag_name: str, **kwargs: Any) -> None: # pylint: disable=inconsistent-return-statements """Deletes a tag from the subscription. You must remove all values from a resource tag before you can delete it. - :param tag_name: The name of the tag. + :param tag_name: The name of the tag. Required. :type tag_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: None, or the result of cls(response) + :return: None or the result of cls(response) :rtype: None - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType[None] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + 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', "2018-05-01") # type: str + api_version = kwargs.pop("api_version", _params.pop("api-version", "2018-05-01")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[None] - request = build_tags_delete_request( tag_name=tag_name, subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.delete.metadata['url'], + template_url=self.delete.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200, 204]: @@ -5806,48 +6670,53 @@ def delete( # pylint: disable=inconsistent-return-statements if cls: return cls(pipeline_response, None, {}) - delete.metadata = {'url': "/subscriptions/{subscriptionId}/tagNames/{tagName}"} # type: ignore - + delete.metadata = {"url": "/subscriptions/{subscriptionId}/tagNames/{tagName}"} # type: ignore @distributed_trace - def list( - self, - **kwargs: Any - ) -> Iterable["_models.TagsListResult"]: + def list(self, **kwargs: Any) -> Iterable["_models.TagDetails"]: """Gets the names and values of all resource tags that are defined in a subscription. :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either TagsListResult or the result of cls(response) + :return: An iterator like instance of either TagDetails or the result of cls(response) :rtype: - ~azure.core.paging.ItemPaged[~azure.mgmt.resource.resources.v2018_05_01.models.TagsListResult] - :raises: ~azure.core.exceptions.HttpResponseError + ~azure.core.paging.ItemPaged[~azure.mgmt.resource.resources.v2018_05_01.models.TagDetails] + :raises ~azure.core.exceptions.HttpResponseError: """ - api_version = kwargs.pop('api_version', "2018-05-01") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2018-05-01")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[_models.TagsListResult] - cls = kwargs.pop('cls', None) # type: ClsType["_models.TagsListResult"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) + def prepare_request(next_link=None): if not next_link: - + request = build_tags_list_request( subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.list.metadata['url'], + template_url=self.list.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore else: - - request = build_tags_list_request( - subscription_id=self._config.subscription_id, - template_url=next_link, - ) + # make call to next link with the client's api-version + _parsed_next_link = urlparse(next_link) + _next_request_params = case_insensitive_dict(parse_qs(_parsed_next_link.query)) + _next_request_params["api-version"] = self._config.api_version + request = HttpRequest("GET", urljoin(next_link, _parsed_next_link.path), params=_next_request_params) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore request.method = "GET" return request @@ -5861,10 +6730,8 @@ def extract_data(pipeline_response): def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) response = pipeline_response.http_response @@ -5874,140 +6741,143 @@ def get_next(next_link=None): return pipeline_response + return ItemPaged(get_next, extract_data) - return ItemPaged( - get_next, extract_data - ) - list.metadata = {'url': "/subscriptions/{subscriptionId}/tagNames"} # type: ignore -class DeploymentOperationsOperations(object): - """DeploymentOperationsOperations operations. - - You should not instantiate this class directly. Instead, you should create a Client instance that - instantiates it for you and attaches it as an attribute. - - :ivar models: Alias to model classes used in this operation group. - :type models: ~azure.mgmt.resource.resources.v2018_05_01.models - :param client: Client for service requests. - :param config: Configuration of service client. - :param serializer: An object model serializer. - :param deserializer: An object model deserializer. + list.metadata = {"url": "/subscriptions/{subscriptionId}/tagNames"} # type: ignore + + +class DeploymentOperationsOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. + + Instead, you should access the following operations through + :class:`~azure.mgmt.resource.resources.v2018_05_01.ResourceManagementClient`'s + :attr:`deployment_operations` attribute. """ models = _models - def __init__(self, client, config, serializer, deserializer): - self._client = client - self._serialize = serializer - self._deserialize = deserializer - self._config = config + def __init__(self, *args, **kwargs): + input_args = list(args) + self._client = input_args.pop(0) if input_args else kwargs.pop("client") + self._config = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") @distributed_trace def get_at_subscription_scope( - self, - deployment_name: str, - operation_id: str, - **kwargs: Any - ) -> "_models.DeploymentOperation": + self, deployment_name: str, operation_id: str, **kwargs: Any + ) -> _models.DeploymentOperation: """Gets a deployments operation. - :param deployment_name: The name of the deployment. + :param deployment_name: The name of the deployment. Required. :type deployment_name: str - :param operation_id: The ID of the operation to get. + :param operation_id: The ID of the operation to get. Required. :type operation_id: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: DeploymentOperation, or the result of cls(response) + :return: DeploymentOperation or the result of cls(response) :rtype: ~azure.mgmt.resource.resources.v2018_05_01.models.DeploymentOperation - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.DeploymentOperation"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) - api_version = kwargs.pop('api_version', "2018-05-01") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2018-05-01")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[_models.DeploymentOperation] - request = build_deployment_operations_get_at_subscription_scope_request( deployment_name=deployment_name, operation_id=operation_id, subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.get_at_subscription_scope.metadata['url'], + template_url=self.get_at_subscription_scope.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) - deserialized = self._deserialize('DeploymentOperation', pipeline_response) + deserialized = self._deserialize("DeploymentOperation", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - get_at_subscription_scope.metadata = {'url': "/subscriptions/{subscriptionId}/providers/Microsoft.Resources/deployments/{deploymentName}/operations/{operationId}"} # type: ignore - + get_at_subscription_scope.metadata = {"url": "/subscriptions/{subscriptionId}/providers/Microsoft.Resources/deployments/{deploymentName}/operations/{operationId}"} # type: ignore @distributed_trace def list_at_subscription_scope( - self, - deployment_name: str, - top: Optional[int] = None, - **kwargs: Any - ) -> Iterable["_models.DeploymentOperationsListResult"]: + self, deployment_name: str, top: Optional[int] = None, **kwargs: Any + ) -> Iterable["_models.DeploymentOperation"]: """Gets all deployments operations for a deployment. - :param deployment_name: The name of the deployment with the operation to get. + :param deployment_name: The name of the deployment with the operation to get. Required. :type deployment_name: str :param top: The number of results to return. Default value is None. :type top: int :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either DeploymentOperationsListResult or the result of - cls(response) + :return: An iterator like instance of either DeploymentOperation or the result of cls(response) :rtype: - ~azure.core.paging.ItemPaged[~azure.mgmt.resource.resources.v2018_05_01.models.DeploymentOperationsListResult] - :raises: ~azure.core.exceptions.HttpResponseError + ~azure.core.paging.ItemPaged[~azure.mgmt.resource.resources.v2018_05_01.models.DeploymentOperation] + :raises ~azure.core.exceptions.HttpResponseError: """ - api_version = kwargs.pop('api_version', "2018-05-01") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2018-05-01")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[_models.DeploymentOperationsListResult] - cls = kwargs.pop('cls', None) # type: ClsType["_models.DeploymentOperationsListResult"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) + def prepare_request(next_link=None): if not next_link: - + request = build_deployment_operations_list_at_subscription_scope_request( deployment_name=deployment_name, subscription_id=self._config.subscription_id, - api_version=api_version, top=top, - template_url=self.list_at_subscription_scope.metadata['url'], + api_version=api_version, + template_url=self.list_at_subscription_scope.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore else: - - request = build_deployment_operations_list_at_subscription_scope_request( - deployment_name=deployment_name, - subscription_id=self._config.subscription_id, - template_url=next_link, - ) + # make call to next link with the client's api-version + _parsed_next_link = urlparse(next_link) + _next_request_params = case_insensitive_dict(parse_qs(_parsed_next_link.query)) + _next_request_params["api-version"] = self._config.api_version + request = HttpRequest("GET", urljoin(next_link, _parsed_next_link.path), params=_next_request_params) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore request.method = "GET" return request @@ -6021,10 +6891,8 @@ def extract_data(pipeline_response): def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) response = pipeline_response.http_response @@ -6034,128 +6902,131 @@ def get_next(next_link=None): return pipeline_response + return ItemPaged(get_next, extract_data) - return ItemPaged( - get_next, extract_data - ) - list_at_subscription_scope.metadata = {'url': "/subscriptions/{subscriptionId}/providers/Microsoft.Resources/deployments/{deploymentName}/operations"} # type: ignore + list_at_subscription_scope.metadata = {"url": "/subscriptions/{subscriptionId}/providers/Microsoft.Resources/deployments/{deploymentName}/operations"} # type: ignore @distributed_trace def get( - self, - resource_group_name: str, - deployment_name: str, - operation_id: str, - **kwargs: Any - ) -> "_models.DeploymentOperation": + self, resource_group_name: str, deployment_name: str, operation_id: str, **kwargs: Any + ) -> _models.DeploymentOperation: """Gets a deployments operation. :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. :type resource_group_name: str - :param deployment_name: The name of the deployment. + :param deployment_name: The name of the deployment. Required. :type deployment_name: str - :param operation_id: The ID of the operation to get. + :param operation_id: The ID of the operation to get. Required. :type operation_id: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: DeploymentOperation, or the result of cls(response) + :return: DeploymentOperation or the result of cls(response) :rtype: ~azure.mgmt.resource.resources.v2018_05_01.models.DeploymentOperation - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.DeploymentOperation"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + 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', "2018-05-01") # type: str + api_version = kwargs.pop("api_version", _params.pop("api-version", "2018-05-01")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[_models.DeploymentOperation] - request = build_deployment_operations_get_request( resource_group_name=resource_group_name, deployment_name=deployment_name, operation_id=operation_id, subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.get.metadata['url'], + template_url=self.get.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) - deserialized = self._deserialize('DeploymentOperation', pipeline_response) + deserialized = self._deserialize("DeploymentOperation", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - get.metadata = {'url': "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/deployments/{deploymentName}/operations/{operationId}"} # type: ignore - + get.metadata = {"url": "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/deployments/{deploymentName}/operations/{operationId}"} # type: ignore @distributed_trace def list( - self, - resource_group_name: str, - deployment_name: str, - top: Optional[int] = None, - **kwargs: Any - ) -> Iterable["_models.DeploymentOperationsListResult"]: + self, resource_group_name: str, deployment_name: str, top: Optional[int] = None, **kwargs: Any + ) -> Iterable["_models.DeploymentOperation"]: """Gets all deployments operations for a deployment. :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. :type resource_group_name: str - :param deployment_name: The name of the deployment with the operation to get. + :param deployment_name: The name of the deployment with the operation to get. Required. :type deployment_name: str :param top: The number of results to return. Default value is None. :type top: int :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either DeploymentOperationsListResult or the result of - cls(response) + :return: An iterator like instance of either DeploymentOperation or the result of cls(response) :rtype: - ~azure.core.paging.ItemPaged[~azure.mgmt.resource.resources.v2018_05_01.models.DeploymentOperationsListResult] - :raises: ~azure.core.exceptions.HttpResponseError + ~azure.core.paging.ItemPaged[~azure.mgmt.resource.resources.v2018_05_01.models.DeploymentOperation] + :raises ~azure.core.exceptions.HttpResponseError: """ - api_version = kwargs.pop('api_version', "2018-05-01") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2018-05-01")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[_models.DeploymentOperationsListResult] - cls = kwargs.pop('cls', None) # type: ClsType["_models.DeploymentOperationsListResult"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) + def prepare_request(next_link=None): if not next_link: - + request = build_deployment_operations_list_request( resource_group_name=resource_group_name, deployment_name=deployment_name, subscription_id=self._config.subscription_id, - api_version=api_version, top=top, - template_url=self.list.metadata['url'], + 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.url = self._client.format_url(request.url) # type: ignore else: - - request = build_deployment_operations_list_request( - resource_group_name=resource_group_name, - deployment_name=deployment_name, - subscription_id=self._config.subscription_id, - template_url=next_link, - ) + # make call to next link with the client's api-version + _parsed_next_link = urlparse(next_link) + _next_request_params = case_insensitive_dict(parse_qs(_parsed_next_link.query)) + _next_request_params["api-version"] = self._config.api_version + request = HttpRequest("GET", urljoin(next_link, _parsed_next_link.path), params=_next_request_params) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore request.method = "GET" return request @@ -6169,10 +7040,8 @@ def extract_data(pipeline_response): def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) response = pipeline_response.http_response @@ -6182,8 +7051,6 @@ def get_next(next_link=None): return pipeline_response + return ItemPaged(get_next, extract_data) - return ItemPaged( - get_next, extract_data - ) - list.metadata = {'url': "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/deployments/{deploymentName}/operations"} # type: ignore + list.metadata = {"url": "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/deployments/{deploymentName}/operations"} # type: ignore diff --git a/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/resources/v2018_05_01/operations/_patch.py b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/resources/v2018_05_01/operations/_patch.py new file mode 100644 index 0000000000000..f7dd32510333d --- /dev/null +++ b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/resources/v2018_05_01/operations/_patch.py @@ -0,0 +1,20 @@ +# ------------------------------------ +# Copyright (c) Microsoft Corporation. +# Licensed under the MIT License. +# ------------------------------------ +"""Customize generated code here. + +Follow our quickstart for examples: https://aka.ms/azsdk/python/dpcodegen/python/customize +""" +from typing import List + +__all__: List[str] = [] # Add all objects you want publicly available to users at this package level + + +def patch_sdk(): + """Do not remove from this file. + + `patch_sdk` is a last resort escape hatch that allows you to do customizations + you can't accomplish using the techniques described in + https://aka.ms/azsdk/python/dpcodegen/python/customize + """ diff --git a/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/resources/v2019_03_01/__init__.py b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/resources/v2019_03_01/__init__.py index 449220069f2f2..2b201470d075e 100644 --- a/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/resources/v2019_03_01/__init__.py +++ b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/resources/v2019_03_01/__init__.py @@ -10,9 +10,15 @@ from ._version import VERSION __version__ = VERSION -__all__ = ['ResourceManagementClient'] -# `._patch.py` is used for handwritten extensions to the generated code -# Example: https://github.com/Azure/azure-sdk-for-python/blob/main/doc/dev/customize_code/how-to-patch-sdk-code.md -from ._patch import patch_sdk -patch_sdk() +try: + from ._patch import __all__ as _patch_all + from ._patch import * # type: ignore # pylint: disable=unused-wildcard-import +except ImportError: + _patch_all = [] +from ._patch import patch_sdk as _patch_sdk + +__all__ = ["ResourceManagementClient"] +__all__.extend([p for p in _patch_all if p not in __all__]) + +_patch_sdk() diff --git a/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/resources/v2019_03_01/_configuration.py b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/resources/v2019_03_01/_configuration.py index 7ad7c19d760c5..0ed8cd1d63081 100644 --- a/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/resources/v2019_03_01/_configuration.py +++ b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/resources/v2019_03_01/_configuration.py @@ -25,23 +25,18 @@ class ResourceManagementClientConfiguration(Configuration): # pylint: disable=t Note that all parameters used to create this instance are saved as instance attributes. - :param credential: Credential needed for the client to connect to Azure. + :param credential: Credential needed for the client to connect to Azure. Required. :type credential: ~azure.core.credentials.TokenCredential - :param subscription_id: The ID of the target subscription. + :param subscription_id: The ID of the target subscription. Required. :type subscription_id: str :keyword api_version: Api Version. Default value is "2019-03-01". Note that overriding this default value may result in unsupported behavior. :paramtype api_version: str """ - def __init__( - self, - credential: "TokenCredential", - subscription_id: str, - **kwargs: Any - ) -> None: + def __init__(self, credential: "TokenCredential", subscription_id: str, **kwargs: Any) -> None: super(ResourceManagementClientConfiguration, self).__init__(**kwargs) - api_version = kwargs.pop('api_version', "2019-03-01") # type: str + api_version = kwargs.pop("api_version", "2019-03-01") # type: str if credential is None: raise ValueError("Parameter 'credential' must not be None.") @@ -51,23 +46,24 @@ def __init__( self.credential = credential self.subscription_id = subscription_id self.api_version = api_version - self.credential_scopes = kwargs.pop('credential_scopes', ['https://management.azure.com/.default']) - kwargs.setdefault('sdk_moniker', 'mgmt-resource/{}'.format(VERSION)) + self.credential_scopes = kwargs.pop("credential_scopes", ["https://management.azure.com/.default"]) + kwargs.setdefault("sdk_moniker", "mgmt-resource/{}".format(VERSION)) self._configure(**kwargs) def _configure( - self, - **kwargs # type: Any + self, **kwargs # type: Any ): # type: (...) -> 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) - self.logging_policy = kwargs.get('logging_policy') or policies.NetworkTraceLoggingPolicy(**kwargs) - self.http_logging_policy = kwargs.get('http_logging_policy') or ARMHttpLoggingPolicy(**kwargs) - self.retry_policy = kwargs.get('retry_policy') or policies.RetryPolicy(**kwargs) - self.custom_hook_policy = kwargs.get('custom_hook_policy') or policies.CustomHookPolicy(**kwargs) - self.redirect_policy = kwargs.get('redirect_policy') or policies.RedirectPolicy(**kwargs) - self.authentication_policy = kwargs.get('authentication_policy') + 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) + self.logging_policy = kwargs.get("logging_policy") or policies.NetworkTraceLoggingPolicy(**kwargs) + self.http_logging_policy = kwargs.get("http_logging_policy") or ARMHttpLoggingPolicy(**kwargs) + self.retry_policy = kwargs.get("retry_policy") or policies.RetryPolicy(**kwargs) + self.custom_hook_policy = kwargs.get("custom_hook_policy") or policies.CustomHookPolicy(**kwargs) + self.redirect_policy = kwargs.get("redirect_policy") or policies.RedirectPolicy(**kwargs) + self.authentication_policy = kwargs.get("authentication_policy") if self.credential and not self.authentication_policy: - self.authentication_policy = ARMChallengeAuthenticationPolicy(self.credential, *self.credential_scopes, **kwargs) + self.authentication_policy = ARMChallengeAuthenticationPolicy( + self.credential, *self.credential_scopes, **kwargs + ) diff --git a/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/resources/v2019_03_01/_metadata.json b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/resources/v2019_03_01/_metadata.json index 68d82c8e8dbb4..c37c4fd7caac1 100644 --- a/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/resources/v2019_03_01/_metadata.json +++ b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/resources/v2019_03_01/_metadata.json @@ -10,20 +10,20 @@ "azure_arm": true, "has_lro_operations": true, "client_side_validation": false, - "sync_imports": "{\"typing\": {\"azurecore\": {\"azure.core.credentials\": [\"TokenCredential\"]}}, \"regular\": {\"azurecore\": {\"azure.profiles\": [\"KnownProfiles\", \"ProfileDefinition\"], \"azure.profiles.multiapiclient\": [\"MultiApiClientMixin\"], \"azure.mgmt.core\": [\"ARMPipelineClient\"]}, \"local\": {\"._configuration\": [\"ResourceManagementClientConfiguration\"]}, \"thirdparty\": {\"msrest\": [\"Deserializer\", \"Serializer\"]}}, \"conditional\": {\"stdlib\": {\"typing\": [\"Any\", \"Optional\"]}}}", - "async_imports": "{\"typing\": {\"azurecore\": {\"azure.core.credentials_async\": [\"AsyncTokenCredential\"], \"azure.core.credentials\": [\"TokenCredential\"]}}, \"regular\": {\"azurecore\": {\"azure.profiles\": [\"KnownProfiles\", \"ProfileDefinition\"], \"azure.profiles.multiapiclient\": [\"MultiApiClientMixin\"], \"azure.mgmt.core\": [\"AsyncARMPipelineClient\"]}, \"local\": {\"._configuration\": [\"ResourceManagementClientConfiguration\"]}, \"thirdparty\": {\"msrest\": [\"Deserializer\", \"Serializer\"]}}, \"conditional\": {\"stdlib\": {\"typing\": [\"Any\", \"Optional\"]}}}" + "sync_imports": "{\"conditional\": {\"stdlib\": {\"typing\": [\"Any\", \"Optional\"]}}, \"regular\": {\"azurecore\": {\"azure.mgmt.core\": [\"ARMPipelineClient\"], \"azure.profiles\": [\"KnownProfiles\", \"ProfileDefinition\"], \"azure.profiles.multiapiclient\": [\"MultiApiClientMixin\"]}, \"local\": {\"._configuration\": [\"ResourceManagementClientConfiguration\"], \".._serialization\": [\"Deserializer\", \"Serializer\"]}}, \"typing\": {\"azurecore\": {\"azure.core.credentials\": [\"TokenCredential\"]}}}", + "async_imports": "{\"conditional\": {\"stdlib\": {\"typing\": [\"Any\", \"Optional\"]}}, \"regular\": {\"azurecore\": {\"azure.mgmt.core\": [\"AsyncARMPipelineClient\"], \"azure.profiles\": [\"KnownProfiles\", \"ProfileDefinition\"], \"azure.profiles.multiapiclient\": [\"MultiApiClientMixin\"]}, \"local\": {\"._configuration\": [\"ResourceManagementClientConfiguration\"], \"..._serialization\": [\"Deserializer\", \"Serializer\"]}}, \"typing\": {\"azurecore\": {\"azure.core.credentials_async\": [\"AsyncTokenCredential\"]}}}" }, "global_parameters": { "sync": { "credential": { - "signature": "credential, # type: \"TokenCredential\"", - "description": "Credential needed for the client to connect to Azure.", + "signature": "credential: \"TokenCredential\",", + "description": "Credential needed for the client to connect to Azure. Required.", "docstring_type": "~azure.core.credentials.TokenCredential", "required": true }, "subscription_id": { - "signature": "subscription_id, # type: str", - "description": "The ID of the target subscription.", + "signature": "subscription_id: str,", + "description": "The ID of the target subscription. Required.", "docstring_type": "str", "required": true } @@ -31,13 +31,13 @@ "async": { "credential": { "signature": "credential: \"AsyncTokenCredential\",", - "description": "Credential needed for the client to connect to Azure.", + "description": "Credential needed for the client to connect to Azure. Required.", "docstring_type": "~azure.core.credentials_async.AsyncTokenCredential", "required": true }, "subscription_id": { "signature": "subscription_id: str,", - "description": "The ID of the target subscription.", + "description": "The ID of the target subscription. Required.", "docstring_type": "str", "required": true } @@ -54,7 +54,7 @@ "required": false }, "base_url": { - "signature": "base_url=\"https://management.azure.com\", # type: str", + "signature": "base_url: str = \"https://management.azure.com\",", "description": "Service URL", "docstring_type": "str", "required": false diff --git a/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/resources/v2019_03_01/_patch.py b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/resources/v2019_03_01/_patch.py index 74e48ecd07cf3..f99e77fef9861 100644 --- a/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/resources/v2019_03_01/_patch.py +++ b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/resources/v2019_03_01/_patch.py @@ -28,4 +28,4 @@ # This file is used for handwritten extensions to the generated code. Example: # https://github.com/Azure/azure-sdk-for-python/blob/main/doc/dev/customize_code/how-to-patch-sdk-code.md def patch_sdk(): - pass \ No newline at end of file + pass diff --git a/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/resources/v2019_03_01/_resource_management_client.py b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/resources/v2019_03_01/_resource_management_client.py index 7f12e09f7acdf..05494b011d2d2 100644 --- a/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/resources/v2019_03_01/_resource_management_client.py +++ b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/resources/v2019_03_01/_resource_management_client.py @@ -9,20 +9,28 @@ from copy import deepcopy from typing import Any, TYPE_CHECKING -from msrest import Deserializer, Serializer - from azure.core.rest import HttpRequest, HttpResponse from azure.mgmt.core import ARMPipelineClient from . import models +from .._serialization import Deserializer, Serializer from ._configuration import ResourceManagementClientConfiguration -from .operations import DeploymentOperationsOperations, DeploymentsOperations, Operations, ProvidersOperations, ResourceGroupsOperations, ResourcesOperations, TagsOperations +from .operations import ( + DeploymentOperationsOperations, + DeploymentsOperations, + Operations, + ProvidersOperations, + ResourceGroupsOperations, + ResourcesOperations, + TagsOperations, +) if TYPE_CHECKING: # pylint: disable=unused-import,ungrouped-imports from azure.core.credentials import TokenCredential -class ResourceManagementClient: # pylint: disable=too-many-instance-attributes + +class ResourceManagementClient: # pylint: disable=client-accepts-api-version-keyword,too-many-instance-attributes """Provides operations for working with resources and resource groups. :ivar operations: Operations operations @@ -42,9 +50,9 @@ class ResourceManagementClient: # pylint: disable=too-many-instance-attribute :ivar deployment_operations: DeploymentOperationsOperations operations :vartype deployment_operations: azure.mgmt.resource.resources.v2019_03_01.operations.DeploymentOperationsOperations - :param credential: Credential needed for the client to connect to Azure. + :param credential: Credential needed for the client to connect to Azure. Required. :type credential: ~azure.core.credentials.TokenCredential - :param subscription_id: The ID of the target subscription. + :param subscription_id: The ID of the target subscription. Required. :type subscription_id: str :param base_url: Service URL. Default value is "https://management.azure.com". :type base_url: str @@ -62,7 +70,9 @@ def __init__( base_url: str = "https://management.azure.com", **kwargs: Any ) -> None: - self._config = ResourceManagementClientConfiguration(credential=credential, subscription_id=subscription_id, **kwargs) + self._config = ResourceManagementClientConfiguration( + credential=credential, subscription_id=subscription_id, **kwargs + ) self._client = ARMPipelineClient(base_url=base_url, config=self._config, **kwargs) client_models = {k: v for k, v in models.__dict__.items() if isinstance(v, type)} @@ -75,14 +85,11 @@ def __init__( self.resources = ResourcesOperations(self._client, self._config, self._serialize, self._deserialize) self.resource_groups = ResourceGroupsOperations(self._client, self._config, self._serialize, self._deserialize) self.tags = TagsOperations(self._client, self._config, self._serialize, self._deserialize) - self.deployment_operations = DeploymentOperationsOperations(self._client, self._config, self._serialize, self._deserialize) - + self.deployment_operations = DeploymentOperationsOperations( + self._client, self._config, self._serialize, self._deserialize + ) - def _send_request( - self, - request: HttpRequest, - **kwargs: Any - ) -> HttpResponse: + def _send_request(self, request: HttpRequest, **kwargs: Any) -> HttpResponse: """Runs the network request through the client's chained policies. >>> from azure.core.rest import HttpRequest @@ -91,7 +98,7 @@ def _send_request( >>> response = client._send_request(request) - For more information on this code flow, see https://aka.ms/azsdk/python/protocol/quickstart + For more information on this code flow, see https://aka.ms/azsdk/dpcodegen/python/send_request :param request: The network request you want to make. Required. :type request: ~azure.core.rest.HttpRequest diff --git a/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/resources/v2019_03_01/_vendor.py b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/resources/v2019_03_01/_vendor.py index 138f663c53a4e..9aad73fc743e7 100644 --- a/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/resources/v2019_03_01/_vendor.py +++ b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/resources/v2019_03_01/_vendor.py @@ -7,6 +7,7 @@ from azure.core.pipeline.transport import HttpRequest + def _convert_request(request, files=None): data = request.content if not files else None request = HttpRequest(method=request.method, url=request.url, headers=request.headers, data=data) @@ -14,6 +15,7 @@ def _convert_request(request, files=None): request.set_formdata_body(files) return request + def _format_url_section(template, **kwargs): components = template.split("/") while components: @@ -21,7 +23,5 @@ def _format_url_section(template, **kwargs): 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 - ] + components = [c for c in formatted_components if "{}".format(key.args[0]) not in c] template = "/".join(components) diff --git a/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/resources/v2019_03_01/_version.py b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/resources/v2019_03_01/_version.py index a012ac01c480c..e5754a47ce68f 100644 --- a/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/resources/v2019_03_01/_version.py +++ b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/resources/v2019_03_01/_version.py @@ -6,4 +6,4 @@ # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -VERSION = "21.1.0" +VERSION = "1.0.0b1" diff --git a/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/resources/v2019_03_01/aio/__init__.py b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/resources/v2019_03_01/aio/__init__.py index c6c3cf64a37a6..98d6782c2530c 100644 --- a/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/resources/v2019_03_01/aio/__init__.py +++ b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/resources/v2019_03_01/aio/__init__.py @@ -7,9 +7,15 @@ # -------------------------------------------------------------------------- from ._resource_management_client import ResourceManagementClient -__all__ = ['ResourceManagementClient'] -# `._patch.py` is used for handwritten extensions to the generated code -# Example: https://github.com/Azure/azure-sdk-for-python/blob/main/doc/dev/customize_code/how-to-patch-sdk-code.md -from ._patch import patch_sdk -patch_sdk() +try: + from ._patch import __all__ as _patch_all + from ._patch import * # type: ignore # pylint: disable=unused-wildcard-import +except ImportError: + _patch_all = [] +from ._patch import patch_sdk as _patch_sdk + +__all__ = ["ResourceManagementClient"] +__all__.extend([p for p in _patch_all if p not in __all__]) + +_patch_sdk() diff --git a/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/resources/v2019_03_01/aio/_configuration.py b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/resources/v2019_03_01/aio/_configuration.py index c1da7671d41a0..bf0d1678846bf 100644 --- a/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/resources/v2019_03_01/aio/_configuration.py +++ b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/resources/v2019_03_01/aio/_configuration.py @@ -25,23 +25,18 @@ class ResourceManagementClientConfiguration(Configuration): # pylint: disable=t Note that all parameters used to create this instance are saved as instance attributes. - :param credential: Credential needed for the client to connect to Azure. + :param credential: Credential needed for the client to connect to Azure. Required. :type credential: ~azure.core.credentials_async.AsyncTokenCredential - :param subscription_id: The ID of the target subscription. + :param subscription_id: The ID of the target subscription. Required. :type subscription_id: str :keyword api_version: Api Version. Default value is "2019-03-01". Note that overriding this default value may result in unsupported behavior. :paramtype api_version: str """ - def __init__( - self, - credential: "AsyncTokenCredential", - subscription_id: str, - **kwargs: Any - ) -> None: + def __init__(self, credential: "AsyncTokenCredential", subscription_id: str, **kwargs: Any) -> None: super(ResourceManagementClientConfiguration, self).__init__(**kwargs) - api_version = kwargs.pop('api_version', "2019-03-01") # type: str + api_version = kwargs.pop("api_version", "2019-03-01") # type: str if credential is None: raise ValueError("Parameter 'credential' must not be None.") @@ -51,22 +46,21 @@ def __init__( self.credential = credential self.subscription_id = subscription_id self.api_version = api_version - self.credential_scopes = kwargs.pop('credential_scopes', ['https://management.azure.com/.default']) - kwargs.setdefault('sdk_moniker', 'mgmt-resource/{}'.format(VERSION)) + self.credential_scopes = kwargs.pop("credential_scopes", ["https://management.azure.com/.default"]) + kwargs.setdefault("sdk_moniker", "mgmt-resource/{}".format(VERSION)) self._configure(**kwargs) - 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) - self.logging_policy = kwargs.get('logging_policy') or policies.NetworkTraceLoggingPolicy(**kwargs) - self.http_logging_policy = kwargs.get('http_logging_policy') or ARMHttpLoggingPolicy(**kwargs) - self.retry_policy = kwargs.get('retry_policy') or policies.AsyncRetryPolicy(**kwargs) - self.custom_hook_policy = kwargs.get('custom_hook_policy') or policies.CustomHookPolicy(**kwargs) - self.redirect_policy = kwargs.get('redirect_policy') or policies.AsyncRedirectPolicy(**kwargs) - self.authentication_policy = kwargs.get('authentication_policy') + 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) + self.logging_policy = kwargs.get("logging_policy") or policies.NetworkTraceLoggingPolicy(**kwargs) + self.http_logging_policy = kwargs.get("http_logging_policy") or ARMHttpLoggingPolicy(**kwargs) + self.retry_policy = kwargs.get("retry_policy") or policies.AsyncRetryPolicy(**kwargs) + self.custom_hook_policy = kwargs.get("custom_hook_policy") or policies.CustomHookPolicy(**kwargs) + self.redirect_policy = kwargs.get("redirect_policy") or policies.AsyncRedirectPolicy(**kwargs) + self.authentication_policy = kwargs.get("authentication_policy") if self.credential and not self.authentication_policy: - self.authentication_policy = AsyncARMChallengeAuthenticationPolicy(self.credential, *self.credential_scopes, **kwargs) + self.authentication_policy = AsyncARMChallengeAuthenticationPolicy( + self.credential, *self.credential_scopes, **kwargs + ) diff --git a/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/resources/v2019_03_01/aio/_patch.py b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/resources/v2019_03_01/aio/_patch.py index 74e48ecd07cf3..f99e77fef9861 100644 --- a/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/resources/v2019_03_01/aio/_patch.py +++ b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/resources/v2019_03_01/aio/_patch.py @@ -28,4 +28,4 @@ # This file is used for handwritten extensions to the generated code. Example: # https://github.com/Azure/azure-sdk-for-python/blob/main/doc/dev/customize_code/how-to-patch-sdk-code.md def patch_sdk(): - pass \ No newline at end of file + pass diff --git a/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/resources/v2019_03_01/aio/_resource_management_client.py b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/resources/v2019_03_01/aio/_resource_management_client.py index 5663564ffd8ce..18f1b40befe80 100644 --- a/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/resources/v2019_03_01/aio/_resource_management_client.py +++ b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/resources/v2019_03_01/aio/_resource_management_client.py @@ -9,20 +9,28 @@ from copy import deepcopy from typing import Any, Awaitable, TYPE_CHECKING -from msrest import Deserializer, Serializer - from azure.core.rest import AsyncHttpResponse, HttpRequest from azure.mgmt.core import AsyncARMPipelineClient from .. import models +from ..._serialization import Deserializer, Serializer from ._configuration import ResourceManagementClientConfiguration -from .operations import DeploymentOperationsOperations, DeploymentsOperations, Operations, ProvidersOperations, ResourceGroupsOperations, ResourcesOperations, TagsOperations +from .operations import ( + DeploymentOperationsOperations, + DeploymentsOperations, + Operations, + ProvidersOperations, + ResourceGroupsOperations, + ResourcesOperations, + TagsOperations, +) if TYPE_CHECKING: # pylint: disable=unused-import,ungrouped-imports from azure.core.credentials_async import AsyncTokenCredential -class ResourceManagementClient: # pylint: disable=too-many-instance-attributes + +class ResourceManagementClient: # pylint: disable=client-accepts-api-version-keyword,too-many-instance-attributes """Provides operations for working with resources and resource groups. :ivar operations: Operations operations @@ -44,9 +52,9 @@ class ResourceManagementClient: # pylint: disable=too-many-instance-attribute :ivar deployment_operations: DeploymentOperationsOperations operations :vartype deployment_operations: azure.mgmt.resource.resources.v2019_03_01.aio.operations.DeploymentOperationsOperations - :param credential: Credential needed for the client to connect to Azure. + :param credential: Credential needed for the client to connect to Azure. Required. :type credential: ~azure.core.credentials_async.AsyncTokenCredential - :param subscription_id: The ID of the target subscription. + :param subscription_id: The ID of the target subscription. Required. :type subscription_id: str :param base_url: Service URL. Default value is "https://management.azure.com". :type base_url: str @@ -64,7 +72,9 @@ def __init__( base_url: str = "https://management.azure.com", **kwargs: Any ) -> None: - self._config = ResourceManagementClientConfiguration(credential=credential, subscription_id=subscription_id, **kwargs) + self._config = ResourceManagementClientConfiguration( + credential=credential, subscription_id=subscription_id, **kwargs + ) self._client = AsyncARMPipelineClient(base_url=base_url, config=self._config, **kwargs) client_models = {k: v for k, v in models.__dict__.items() if isinstance(v, type)} @@ -77,14 +87,11 @@ def __init__( self.resources = ResourcesOperations(self._client, self._config, self._serialize, self._deserialize) self.resource_groups = ResourceGroupsOperations(self._client, self._config, self._serialize, self._deserialize) self.tags = TagsOperations(self._client, self._config, self._serialize, self._deserialize) - self.deployment_operations = DeploymentOperationsOperations(self._client, self._config, self._serialize, self._deserialize) - + self.deployment_operations = DeploymentOperationsOperations( + self._client, self._config, self._serialize, self._deserialize + ) - def _send_request( - self, - request: HttpRequest, - **kwargs: Any - ) -> Awaitable[AsyncHttpResponse]: + def _send_request(self, request: HttpRequest, **kwargs: Any) -> Awaitable[AsyncHttpResponse]: """Runs the network request through the client's chained policies. >>> from azure.core.rest import HttpRequest @@ -93,7 +100,7 @@ def _send_request( >>> response = await client._send_request(request) - For more information on this code flow, see https://aka.ms/azsdk/python/protocol/quickstart + For more information on this code flow, see https://aka.ms/azsdk/dpcodegen/python/send_request :param request: The network request you want to make. Required. :type request: ~azure.core.rest.HttpRequest diff --git a/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/resources/v2019_03_01/aio/operations/__init__.py b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/resources/v2019_03_01/aio/operations/__init__.py index 53876d82bf5d7..804fee65e3137 100644 --- a/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/resources/v2019_03_01/aio/operations/__init__.py +++ b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/resources/v2019_03_01/aio/operations/__init__.py @@ -14,12 +14,18 @@ from ._operations import TagsOperations from ._operations import DeploymentOperationsOperations +from ._patch import __all__ as _patch_all +from ._patch import * # type: ignore # pylint: disable=unused-wildcard-import +from ._patch import patch_sdk as _patch_sdk + __all__ = [ - 'Operations', - 'DeploymentsOperations', - 'ProvidersOperations', - 'ResourcesOperations', - 'ResourceGroupsOperations', - 'TagsOperations', - 'DeploymentOperationsOperations', + "Operations", + "DeploymentsOperations", + "ProvidersOperations", + "ResourcesOperations", + "ResourceGroupsOperations", + "TagsOperations", + "DeploymentOperationsOperations", ] +__all__.extend([p for p in _patch_all if p not in __all__]) +_patch_sdk() diff --git a/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/resources/v2019_03_01/aio/operations/_operations.py b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/resources/v2019_03_01/aio/operations/_operations.py index 5e814eea5525a..e7e4efd6eba94 100644 --- a/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/resources/v2019_03_01/aio/operations/_operations.py +++ b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/resources/v2019_03_01/aio/operations/_operations.py @@ -6,84 +6,158 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -from typing import Any, AsyncIterable, Callable, Dict, Optional, TypeVar, Union +import sys +from typing import Any, AsyncIterable, Callable, Dict, IO, Optional, TypeVar, Union, cast, overload +from urllib.parse import parse_qs, urljoin, urlparse from azure.core.async_paging import AsyncItemPaged, AsyncList -from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error +from azure.core.exceptions import ( + ClientAuthenticationError, + HttpResponseError, + ResourceExistsError, + ResourceNotFoundError, + ResourceNotModifiedError, + map_error, +) from azure.core.pipeline import PipelineResponse from azure.core.pipeline.transport import AsyncHttpResponse from azure.core.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 from azure.mgmt.core.polling.async_arm_polling import AsyncARMPolling from ... import models as _models from ..._vendor import _convert_request -from ...operations._operations import build_deployment_operations_get_at_subscription_scope_request, build_deployment_operations_get_request, build_deployment_operations_list_at_subscription_scope_request, build_deployment_operations_list_request, build_deployments_calculate_template_hash_request, build_deployments_cancel_at_subscription_scope_request, build_deployments_cancel_request, build_deployments_check_existence_at_subscription_scope_request, build_deployments_check_existence_request, build_deployments_create_or_update_at_subscription_scope_request_initial, build_deployments_create_or_update_request_initial, build_deployments_delete_at_subscription_scope_request_initial, build_deployments_delete_request_initial, build_deployments_export_template_at_subscription_scope_request, build_deployments_export_template_request, build_deployments_get_at_subscription_scope_request, build_deployments_get_request, build_deployments_list_at_subscription_scope_request, build_deployments_list_by_resource_group_request, build_deployments_validate_at_subscription_scope_request, build_deployments_validate_request, build_operations_list_request, build_providers_get_request, build_providers_list_request, build_providers_register_request, build_providers_unregister_request, build_resource_groups_check_existence_request, build_resource_groups_create_or_update_request, build_resource_groups_delete_request_initial, build_resource_groups_export_template_request, build_resource_groups_get_request, build_resource_groups_list_request, build_resource_groups_update_request, build_resources_check_existence_by_id_request, build_resources_check_existence_request, build_resources_create_or_update_by_id_request_initial, build_resources_create_or_update_request_initial, build_resources_delete_by_id_request_initial, build_resources_delete_request_initial, build_resources_get_by_id_request, build_resources_get_request, build_resources_list_by_resource_group_request, build_resources_list_request, build_resources_move_resources_request_initial, build_resources_update_by_id_request_initial, build_resources_update_request_initial, build_resources_validate_move_resources_request_initial, build_tags_create_or_update_request, build_tags_create_or_update_value_request, build_tags_delete_request, build_tags_delete_value_request, build_tags_list_request -T = TypeVar('T') +from ...operations._operations import ( + build_deployment_operations_get_at_subscription_scope_request, + build_deployment_operations_get_request, + build_deployment_operations_list_at_subscription_scope_request, + build_deployment_operations_list_request, + build_deployments_calculate_template_hash_request, + build_deployments_cancel_at_subscription_scope_request, + build_deployments_cancel_request, + build_deployments_check_existence_at_subscription_scope_request, + build_deployments_check_existence_request, + build_deployments_create_or_update_at_subscription_scope_request, + build_deployments_create_or_update_request, + build_deployments_delete_at_subscription_scope_request, + build_deployments_delete_request, + build_deployments_export_template_at_subscription_scope_request, + build_deployments_export_template_request, + build_deployments_get_at_subscription_scope_request, + build_deployments_get_request, + build_deployments_list_at_subscription_scope_request, + build_deployments_list_by_resource_group_request, + build_deployments_validate_at_subscription_scope_request, + build_deployments_validate_request, + build_operations_list_request, + build_providers_get_request, + build_providers_list_request, + build_providers_register_request, + build_providers_unregister_request, + build_resource_groups_check_existence_request, + build_resource_groups_create_or_update_request, + build_resource_groups_delete_request, + build_resource_groups_export_template_request, + build_resource_groups_get_request, + build_resource_groups_list_request, + build_resource_groups_update_request, + build_resources_check_existence_by_id_request, + build_resources_check_existence_request, + build_resources_create_or_update_by_id_request, + build_resources_create_or_update_request, + build_resources_delete_by_id_request, + build_resources_delete_request, + build_resources_get_by_id_request, + build_resources_get_request, + build_resources_list_by_resource_group_request, + build_resources_list_request, + build_resources_move_resources_request, + build_resources_update_by_id_request, + build_resources_update_request, + build_resources_validate_move_resources_request, + build_tags_create_or_update_request, + build_tags_create_or_update_value_request, + build_tags_delete_request, + build_tags_delete_value_request, + build_tags_list_request, +) + +T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] +if sys.version_info >= (3, 9): + from collections.abc import MutableMapping +else: + from typing import MutableMapping # type: ignore # pylint: disable=ungrouped-imports +JSON = MutableMapping[str, Any] # pylint: disable=unsubscriptable-object -class Operations: - """Operations async operations. - You should not instantiate this class directly. Instead, you should create a Client instance that - instantiates it for you and attaches it as an attribute. +class Operations: + """ + .. warning:: + **DO NOT** instantiate this class directly. - :ivar models: Alias to model classes used in this operation group. - :type models: ~azure.mgmt.resource.resources.v2019_03_01.models - :param client: Client for service requests. - :param config: Configuration of service client. - :param serializer: An object model serializer. - :param deserializer: An object model deserializer. + Instead, you should access the following operations through + :class:`~azure.mgmt.resource.resources.v2019_03_01.aio.ResourceManagementClient`'s + :attr:`operations` attribute. """ models = _models - def __init__(self, client, config, serializer, deserializer) -> None: - self._client = client - self._serialize = serializer - self._deserialize = deserializer - self._config = config + def __init__(self, *args, **kwargs) -> None: + input_args = list(args) + self._client = input_args.pop(0) if input_args else kwargs.pop("client") + self._config = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") @distributed_trace - def list( - self, - **kwargs: Any - ) -> AsyncIterable["_models.OperationListResult"]: + def list(self, **kwargs: Any) -> AsyncIterable["_models.Operation"]: """Lists all of the available Microsoft.Resources REST API operations. :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either OperationListResult or the result of cls(response) + :return: An iterator like instance of either Operation or the result of cls(response) :rtype: - ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.resource.resources.v2019_03_01.models.OperationListResult] - :raises: ~azure.core.exceptions.HttpResponseError + ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.resource.resources.v2019_03_01.models.Operation] + :raises ~azure.core.exceptions.HttpResponseError: """ - api_version = kwargs.pop('api_version', "2019-03-01") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2019-03-01")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[_models.OperationListResult] - cls = kwargs.pop('cls', None) # type: ClsType["_models.OperationListResult"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) + def prepare_request(next_link=None): if not next_link: - + request = build_operations_list_request( api_version=api_version, - template_url=self.list.metadata['url'], + template_url=self.list.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore else: - - request = build_operations_list_request( - template_url=next_link, - ) + # make call to next link with the client's api-version + _parsed_next_link = urlparse(next_link) + _next_request_params = case_insensitive_dict(parse_qs(_parsed_next_link.query)) + _next_request_params["api-version"] = self._config.api_version + request = HttpRequest("GET", urljoin(next_link, _parsed_next_link.path), params=_next_request_params) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore request.method = "GET" return request @@ -97,10 +171,8 @@ async def extract_data(pipeline_response): async def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) response = pipeline_response.http_response @@ -110,61 +182,62 @@ async def get_next(next_link=None): return pipeline_response + return AsyncItemPaged(get_next, extract_data) - return AsyncItemPaged( - get_next, extract_data - ) - list.metadata = {'url': "/providers/Microsoft.Resources/operations"} # type: ignore -class DeploymentsOperations: # pylint: disable=too-many-public-methods - """DeploymentsOperations async operations. + list.metadata = {"url": "/providers/Microsoft.Resources/operations"} # type: ignore - You should not instantiate this class directly. Instead, you should create a Client instance that - instantiates it for you and attaches it as an attribute. - :ivar models: Alias to model classes used in this operation group. - :type models: ~azure.mgmt.resource.resources.v2019_03_01.models - :param client: Client for service requests. - :param config: Configuration of service client. - :param serializer: An object model serializer. - :param deserializer: An object model deserializer. +class DeploymentsOperations: # pylint: disable=too-many-public-methods + """ + .. warning:: + **DO NOT** instantiate this class directly. + + Instead, you should access the following operations through + :class:`~azure.mgmt.resource.resources.v2019_03_01.aio.ResourceManagementClient`'s + :attr:`deployments` attribute. """ models = _models - def __init__(self, client, config, serializer, deserializer) -> None: - self._client = client - self._serialize = serializer - self._deserialize = deserializer - self._config = config + def __init__(self, *args, **kwargs) -> None: + input_args = list(args) + self._client = input_args.pop(0) if input_args else kwargs.pop("client") + self._config = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") async def _delete_at_subscription_scope_initial( # pylint: disable=inconsistent-return-statements - self, - deployment_name: str, - **kwargs: Any + self, deployment_name: str, **kwargs: Any ) -> None: - cls = kwargs.pop('cls', None) # type: ClsType[None] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) - api_version = kwargs.pop('api_version', "2019-03-01") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - request = build_deployments_delete_at_subscription_scope_request_initial( + api_version = kwargs.pop("api_version", _params.pop("api-version", "2019-03-01")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[None] + + request = build_deployments_delete_at_subscription_scope_request( deployment_name=deployment_name, subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self._delete_at_subscription_scope_initial.metadata['url'], + template_url=self._delete_at_subscription_scope_initial.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [202, 204]: @@ -174,15 +247,10 @@ async def _delete_at_subscription_scope_initial( # pylint: disable=inconsistent if cls: return cls(pipeline_response, None, {}) - _delete_at_subscription_scope_initial.metadata = {'url': "/subscriptions/{subscriptionId}/providers/Microsoft.Resources/deployments/{deploymentName}"} # type: ignore - + _delete_at_subscription_scope_initial.metadata = {"url": "/subscriptions/{subscriptionId}/providers/Microsoft.Resources/deployments/{deploymentName}"} # type: ignore @distributed_trace_async - async def begin_delete_at_subscription_scope( # pylint: disable=inconsistent-return-statements - self, - deployment_name: str, - **kwargs: Any - ) -> AsyncLROPoller[None]: + async def begin_delete_at_subscription_scope(self, deployment_name: str, **kwargs: Any) -> AsyncLROPoller[None]: """Deletes a deployment from the deployment history. A template deployment that is currently running cannot be deleted. Deleting a template @@ -193,7 +261,7 @@ async def begin_delete_at_subscription_scope( # pylint: disable=inconsistent-re process finishes, the URI in the Location header returns a status of 204 on success. If the asynchronous request failed, the URI in the Location header returns an error-level status code. - :param deployment_name: The name of the deployment to delete. + :param deployment_name: The name of the deployment to delete. Required. :type deployment_name: str :keyword callable cls: A custom type or function that will be passed the direct response :keyword str continuation_token: A continuation token to restart a poller from a saved state. @@ -205,82 +273,88 @@ async def begin_delete_at_subscription_scope( # pylint: disable=inconsistent-re Retry-After header is present. :return: An instance of AsyncLROPoller that returns either None or the result of cls(response) :rtype: ~azure.core.polling.AsyncLROPoller[None] - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - api_version = kwargs.pop('api_version', "2019-03-01") # type: str - polling = kwargs.pop('polling', True) # type: Union[bool, AsyncPollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType[None] - lro_delay = kwargs.pop( - 'polling_interval', - self._config.polling_interval - ) - cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2019-03-01")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[None] + polling = kwargs.pop("polling", True) # type: Union[bool, AsyncPollingMethod] + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token = kwargs.pop("continuation_token", None) # type: Optional[str] if cont_token is None: - raw_result = await self._delete_at_subscription_scope_initial( + raw_result = await self._delete_at_subscription_scope_initial( # type: ignore deployment_name=deployment_name, api_version=api_version, - cls=lambda x,y,z: x, + cls=lambda x, y, z: x, + headers=_headers, + params=_params, **kwargs ) - kwargs.pop('error_map', None) + kwargs.pop("error_map", None) - def get_long_running_output(pipeline_response): + def get_long_running_output(pipeline_response): # pylint: disable=inconsistent-return-statements if cls: return cls(pipeline_response, None, {}) - - if polling is True: polling_method = AsyncARMPolling(lro_delay, **kwargs) - elif polling is False: polling_method = AsyncNoPolling() - else: polling_method = polling + if polling is True: + polling_method = cast(AsyncPollingMethod, AsyncARMPolling(lro_delay, **kwargs)) # type: AsyncPollingMethod + elif polling is False: + polling_method = cast(AsyncPollingMethod, AsyncNoPolling()) + else: + polling_method = polling if cont_token: return AsyncLROPoller.from_continuation_token( polling_method=polling_method, continuation_token=cont_token, client=self._client, - deserialization_callback=get_long_running_output + deserialization_callback=get_long_running_output, ) return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) - begin_delete_at_subscription_scope.metadata = {'url': "/subscriptions/{subscriptionId}/providers/Microsoft.Resources/deployments/{deploymentName}"} # type: ignore + begin_delete_at_subscription_scope.metadata = {"url": "/subscriptions/{subscriptionId}/providers/Microsoft.Resources/deployments/{deploymentName}"} # type: ignore @distributed_trace_async - async def check_existence_at_subscription_scope( - self, - deployment_name: str, - **kwargs: Any - ) -> bool: + async def check_existence_at_subscription_scope(self, deployment_name: str, **kwargs: Any) -> bool: """Checks whether the deployment exists. - :param deployment_name: The name of the deployment to check. + :param deployment_name: The name of the deployment to check. Required. :type deployment_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: bool, or the result of cls(response) + :return: bool or the result of cls(response) :rtype: bool - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType[None] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) - api_version = kwargs.pop('api_version', "2019-03-01") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2019-03-01")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[None] - request = build_deployments_check_existence_at_subscription_scope_request( deployment_name=deployment_name, subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.check_existence_at_subscription_scope.metadata['url'], + template_url=self.check_existence_at_subscription_scope.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [204, 404]: @@ -291,42 +365,52 @@ async def check_existence_at_subscription_scope( return cls(pipeline_response, None, {}) return 200 <= response.status_code <= 299 - check_existence_at_subscription_scope.metadata = {'url': "/subscriptions/{subscriptionId}/providers/Microsoft.Resources/deployments/{deploymentName}"} # type: ignore - + check_existence_at_subscription_scope.metadata = {"url": "/subscriptions/{subscriptionId}/providers/Microsoft.Resources/deployments/{deploymentName}"} # type: ignore async def _create_or_update_at_subscription_scope_initial( - self, - deployment_name: str, - parameters: "_models.Deployment", - **kwargs: Any - ) -> "_models.DeploymentExtended": - cls = kwargs.pop('cls', None) # type: ClsType["_models.DeploymentExtended"] + self, deployment_name: str, parameters: Union[_models.Deployment, IO], **kwargs: Any + ) -> _models.DeploymentExtended: error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) - api_version = kwargs.pop('api_version', "2019-03-01") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - _json = self._serialize.body(parameters, 'Deployment') + api_version = kwargs.pop("api_version", _params.pop("api-version", "2019-03-01")) # type: str + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.DeploymentExtended] - request = build_deployments_create_or_update_at_subscription_scope_request_initial( + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(parameters, (IO, bytes)): + _content = parameters + else: + _json = self._serialize.body(parameters, "Deployment") + + request = build_deployments_create_or_update_at_subscription_scope_request( deployment_name=deployment_name, subscription_id=self._config.subscription_id, api_version=api_version, content_type=content_type, json=_json, - template_url=self._create_or_update_at_subscription_scope_initial.metadata['url'], + content=_content, + template_url=self._create_or_update_at_subscription_scope_initial.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200, 201]: @@ -334,34 +418,38 @@ async def _create_or_update_at_subscription_scope_initial( raise HttpResponseError(response=response, error_format=ARMErrorFormat) if response.status_code == 200: - deserialized = self._deserialize('DeploymentExtended', pipeline_response) + deserialized = self._deserialize("DeploymentExtended", pipeline_response) if response.status_code == 201: - deserialized = self._deserialize('DeploymentExtended', pipeline_response) + deserialized = self._deserialize("DeploymentExtended", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - _create_or_update_at_subscription_scope_initial.metadata = {'url': "/subscriptions/{subscriptionId}/providers/Microsoft.Resources/deployments/{deploymentName}"} # type: ignore + _create_or_update_at_subscription_scope_initial.metadata = {"url": "/subscriptions/{subscriptionId}/providers/Microsoft.Resources/deployments/{deploymentName}"} # type: ignore - - @distributed_trace_async + @overload async def begin_create_or_update_at_subscription_scope( self, deployment_name: str, - parameters: "_models.Deployment", + parameters: _models.Deployment, + *, + content_type: str = "application/json", **kwargs: Any - ) -> AsyncLROPoller["_models.DeploymentExtended"]: + ) -> AsyncLROPoller[_models.DeploymentExtended]: """Deploys resources at subscription scope. You can provide the template and parameters directly in the request or link to JSON files. - :param deployment_name: The name of the deployment. + :param deployment_name: The name of the deployment. Required. :type deployment_name: str - :param parameters: Additional parameters supplied to the operation. + :param parameters: Additional parameters supplied to the operation. Required. :type parameters: ~azure.mgmt.resource.resources.v2019_03_01.models.Deployment + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str :keyword callable cls: A custom type or function that will be passed the direct response :keyword str continuation_token: A continuation token to restart a poller from a saved state. :keyword polling: By default, your polling method will be AsyncARMPolling. Pass in False for @@ -374,109 +462,172 @@ async def begin_create_or_update_at_subscription_scope( cls(response) :rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.resource.resources.v2019_03_01.models.DeploymentExtended] - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - api_version = kwargs.pop('api_version', "2019-03-01") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] - polling = kwargs.pop('polling', True) # type: Union[bool, AsyncPollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType["_models.DeploymentExtended"] - lro_delay = kwargs.pop( - 'polling_interval', - self._config.polling_interval - ) - cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] + + @overload + async def begin_create_or_update_at_subscription_scope( + self, deployment_name: str, parameters: IO, *, content_type: str = "application/json", **kwargs: Any + ) -> AsyncLROPoller[_models.DeploymentExtended]: + """Deploys resources at subscription scope. + + You can provide the template and parameters directly in the request or link to JSON files. + + :param deployment_name: The name of the deployment. Required. + :type deployment_name: str + :param parameters: Additional parameters supplied to the operation. Required. + :type parameters: IO + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be AsyncARMPolling. Pass in False for + this operation to not poll, or pass in your own initialized polling object for a personal + polling strategy. + :paramtype polling: bool or ~azure.core.polling.AsyncPollingMethod + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of AsyncLROPoller that returns either DeploymentExtended or the result of + cls(response) + :rtype: + ~azure.core.polling.AsyncLROPoller[~azure.mgmt.resource.resources.v2019_03_01.models.DeploymentExtended] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace_async + async def begin_create_or_update_at_subscription_scope( + self, deployment_name: str, parameters: Union[_models.Deployment, IO], **kwargs: Any + ) -> AsyncLROPoller[_models.DeploymentExtended]: + """Deploys resources at subscription scope. + + You can provide the template and parameters directly in the request or link to JSON files. + + :param deployment_name: The name of the deployment. Required. + :type deployment_name: str + :param parameters: Additional parameters supplied to the operation. Is either a model type or a + IO type. Required. + :type parameters: ~azure.mgmt.resource.resources.v2019_03_01.models.Deployment or IO + :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. + Default value is None. + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be AsyncARMPolling. Pass in False for + this operation to not poll, or pass in your own initialized polling object for a personal + polling strategy. + :paramtype polling: bool or ~azure.core.polling.AsyncPollingMethod + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of AsyncLROPoller that returns either DeploymentExtended or the result of + cls(response) + :rtype: + ~azure.core.polling.AsyncLROPoller[~azure.mgmt.resource.resources.v2019_03_01.models.DeploymentExtended] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _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", "2019-03-01")) # type: str + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.DeploymentExtended] + polling = kwargs.pop("polling", True) # type: Union[bool, AsyncPollingMethod] + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token = kwargs.pop("continuation_token", None) # type: Optional[str] if cont_token is None: - raw_result = await self._create_or_update_at_subscription_scope_initial( + raw_result = await self._create_or_update_at_subscription_scope_initial( # type: ignore deployment_name=deployment_name, parameters=parameters, api_version=api_version, content_type=content_type, - cls=lambda x,y,z: x, + cls=lambda x, y, z: x, + headers=_headers, + params=_params, **kwargs ) - kwargs.pop('error_map', None) + kwargs.pop("error_map", None) def get_long_running_output(pipeline_response): - response = pipeline_response.http_response - deserialized = self._deserialize('DeploymentExtended', pipeline_response) + deserialized = self._deserialize("DeploymentExtended", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - - if polling is True: polling_method = AsyncARMPolling(lro_delay, **kwargs) - elif polling is False: polling_method = AsyncNoPolling() - else: polling_method = polling + if polling is True: + polling_method = cast(AsyncPollingMethod, AsyncARMPolling(lro_delay, **kwargs)) # type: AsyncPollingMethod + elif polling is False: + polling_method = cast(AsyncPollingMethod, AsyncNoPolling()) + else: + polling_method = polling if cont_token: return AsyncLROPoller.from_continuation_token( polling_method=polling_method, continuation_token=cont_token, client=self._client, - deserialization_callback=get_long_running_output + deserialization_callback=get_long_running_output, ) return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) - begin_create_or_update_at_subscription_scope.metadata = {'url': "/subscriptions/{subscriptionId}/providers/Microsoft.Resources/deployments/{deploymentName}"} # type: ignore + begin_create_or_update_at_subscription_scope.metadata = {"url": "/subscriptions/{subscriptionId}/providers/Microsoft.Resources/deployments/{deploymentName}"} # type: ignore @distributed_trace_async - async def get_at_subscription_scope( - self, - deployment_name: str, - **kwargs: Any - ) -> "_models.DeploymentExtended": + async def get_at_subscription_scope(self, deployment_name: str, **kwargs: Any) -> _models.DeploymentExtended: """Gets a deployment. - :param deployment_name: The name of the deployment to get. + :param deployment_name: The name of the deployment to get. Required. :type deployment_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: DeploymentExtended, or the result of cls(response) + :return: DeploymentExtended or the result of cls(response) :rtype: ~azure.mgmt.resource.resources.v2019_03_01.models.DeploymentExtended - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.DeploymentExtended"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + 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', "2019-03-01") # type: str + api_version = kwargs.pop("api_version", _params.pop("api-version", "2019-03-01")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[_models.DeploymentExtended] - request = build_deployments_get_at_subscription_scope_request( deployment_name=deployment_name, subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.get_at_subscription_scope.metadata['url'], + template_url=self.get_at_subscription_scope.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) - deserialized = self._deserialize('DeploymentExtended', pipeline_response) + deserialized = self._deserialize("DeploymentExtended", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - get_at_subscription_scope.metadata = {'url': "/subscriptions/{subscriptionId}/providers/Microsoft.Resources/deployments/{deploymentName}"} # type: ignore - + get_at_subscription_scope.metadata = {"url": "/subscriptions/{subscriptionId}/providers/Microsoft.Resources/deployments/{deploymentName}"} # type: ignore @distributed_trace_async async def cancel_at_subscription_scope( # pylint: disable=inconsistent-return-statements - self, - deployment_name: str, - **kwargs: Any + self, deployment_name: str, **kwargs: Any ) -> None: """Cancels a currently running template deployment. @@ -485,36 +636,42 @@ async def cancel_at_subscription_scope( # pylint: disable=inconsistent-return-s deployment stops the currently running template deployment and leaves the resources partially deployed. - :param deployment_name: The name of the deployment to cancel. + :param deployment_name: The name of the deployment to cancel. Required. :type deployment_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: None, or the result of cls(response) + :return: None or the result of cls(response) :rtype: None - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType[None] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + 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', "2019-03-01") # type: str + api_version = kwargs.pop("api_version", _params.pop("api-version", "2019-03-01")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[None] - request = build_deployments_cancel_at_subscription_scope_request( deployment_name=deployment_name, subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.cancel_at_subscription_scope.metadata['url'], + template_url=self.cancel_at_subscription_scope.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [204]: @@ -524,38 +681,94 @@ async def cancel_at_subscription_scope( # pylint: disable=inconsistent-return-s if cls: return cls(pipeline_response, None, {}) - cancel_at_subscription_scope.metadata = {'url': "/subscriptions/{subscriptionId}/providers/Microsoft.Resources/deployments/{deploymentName}/cancel"} # type: ignore - + cancel_at_subscription_scope.metadata = {"url": "/subscriptions/{subscriptionId}/providers/Microsoft.Resources/deployments/{deploymentName}/cancel"} # type: ignore - @distributed_trace_async + @overload async def validate_at_subscription_scope( self, deployment_name: str, - parameters: "_models.Deployment", + parameters: _models.Deployment, + *, + content_type: str = "application/json", **kwargs: Any - ) -> "_models.DeploymentValidateResult": + ) -> _models.DeploymentValidateResult: """Validates whether the specified template is syntactically correct and will be accepted by Azure Resource Manager.. - :param deployment_name: The name of the deployment. + :param deployment_name: The name of the deployment. Required. :type deployment_name: str - :param parameters: Parameters to validate. + :param parameters: Parameters to validate. Required. :type parameters: ~azure.mgmt.resource.resources.v2019_03_01.models.Deployment + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: DeploymentValidateResult or the result of cls(response) + :rtype: ~azure.mgmt.resource.resources.v2019_03_01.models.DeploymentValidateResult + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + async def validate_at_subscription_scope( + self, deployment_name: str, parameters: IO, *, content_type: str = "application/json", **kwargs: Any + ) -> _models.DeploymentValidateResult: + """Validates whether the specified template is syntactically correct and will be accepted by Azure + Resource Manager.. + + :param deployment_name: The name of the deployment. Required. + :type deployment_name: str + :param parameters: Parameters to validate. Required. + :type parameters: IO + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: DeploymentValidateResult, or the result of cls(response) + :return: DeploymentValidateResult or the result of cls(response) :rtype: ~azure.mgmt.resource.resources.v2019_03_01.models.DeploymentValidateResult - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace_async + async def validate_at_subscription_scope( + self, deployment_name: str, parameters: Union[_models.Deployment, IO], **kwargs: Any + ) -> _models.DeploymentValidateResult: + """Validates whether the specified template is syntactically correct and will be accepted by Azure + Resource Manager.. + + :param deployment_name: The name of the deployment. Required. + :type deployment_name: str + :param parameters: Parameters to validate. Is either a model type or a IO type. Required. + :type parameters: ~azure.mgmt.resource.resources.v2019_03_01.models.Deployment or IO + :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. + Default value is None. + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: DeploymentValidateResult or the result of cls(response) + :rtype: ~azure.mgmt.resource.resources.v2019_03_01.models.DeploymentValidateResult + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.DeploymentValidateResult"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', "2019-03-01") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + api_version = kwargs.pop("api_version", _params.pop("api-version", "2019-03-01")) # type: str + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.DeploymentValidateResult] - _json = self._serialize.body(parameters, 'Deployment') + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(parameters, (IO, bytes)): + _content = parameters + else: + _json = self._serialize.body(parameters, "Deployment") request = build_deployments_validate_at_subscription_scope_request( deployment_name=deployment_name, @@ -563,16 +776,18 @@ async def validate_at_subscription_scope( api_version=api_version, content_type=content_type, json=_json, - template_url=self.validate_at_subscription_scope.metadata['url'], + content=_content, + template_url=self.validate_at_subscription_scope.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200, 400]: @@ -580,80 +795,79 @@ async def validate_at_subscription_scope( raise HttpResponseError(response=response, error_format=ARMErrorFormat) if response.status_code == 200: - deserialized = self._deserialize('DeploymentValidateResult', pipeline_response) + deserialized = self._deserialize("DeploymentValidateResult", pipeline_response) if response.status_code == 400: - deserialized = self._deserialize('DeploymentValidateResult', pipeline_response) + deserialized = self._deserialize("DeploymentValidateResult", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - validate_at_subscription_scope.metadata = {'url': "/subscriptions/{subscriptionId}/providers/Microsoft.Resources/deployments/{deploymentName}/validate"} # type: ignore - + validate_at_subscription_scope.metadata = {"url": "/subscriptions/{subscriptionId}/providers/Microsoft.Resources/deployments/{deploymentName}/validate"} # type: ignore @distributed_trace_async async def export_template_at_subscription_scope( - self, - deployment_name: str, - **kwargs: Any - ) -> "_models.DeploymentExportResult": + self, deployment_name: str, **kwargs: Any + ) -> _models.DeploymentExportResult: """Exports the template used for specified deployment. - :param deployment_name: The name of the deployment from which to get the template. + :param deployment_name: The name of the deployment from which to get the template. Required. :type deployment_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: DeploymentExportResult, or the result of cls(response) + :return: DeploymentExportResult or the result of cls(response) :rtype: ~azure.mgmt.resource.resources.v2019_03_01.models.DeploymentExportResult - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.DeploymentExportResult"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + 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', "2019-03-01") # type: str + api_version = kwargs.pop("api_version", _params.pop("api-version", "2019-03-01")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[_models.DeploymentExportResult] - request = build_deployments_export_template_at_subscription_scope_request( deployment_name=deployment_name, subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.export_template_at_subscription_scope.metadata['url'], + template_url=self.export_template_at_subscription_scope.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) - deserialized = self._deserialize('DeploymentExportResult', pipeline_response) + deserialized = self._deserialize("DeploymentExportResult", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - export_template_at_subscription_scope.metadata = {'url': "/subscriptions/{subscriptionId}/providers/Microsoft.Resources/deployments/{deploymentName}/exportTemplate"} # type: ignore - + export_template_at_subscription_scope.metadata = {"url": "/subscriptions/{subscriptionId}/providers/Microsoft.Resources/deployments/{deploymentName}/exportTemplate"} # type: ignore @distributed_trace def list_at_subscription_scope( - self, - filter: Optional[str] = None, - top: Optional[int] = None, - **kwargs: Any - ) -> AsyncIterable["_models.DeploymentListResult"]: + self, filter: Optional[str] = None, top: Optional[int] = None, **kwargs: Any + ) -> AsyncIterable["_models.DeploymentExtended"]: """Get all the deployments for a subscription. :param filter: The filter to apply on the operation. For example, you can use @@ -663,40 +877,48 @@ def list_at_subscription_scope( value is None. :type top: int :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either DeploymentListResult or the result of - cls(response) + :return: An iterator like instance of either DeploymentExtended or the result of cls(response) :rtype: - ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.resource.resources.v2019_03_01.models.DeploymentListResult] - :raises: ~azure.core.exceptions.HttpResponseError + ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.resource.resources.v2019_03_01.models.DeploymentExtended] + :raises ~azure.core.exceptions.HttpResponseError: """ - api_version = kwargs.pop('api_version', "2019-03-01") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2019-03-01")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[_models.DeploymentListResult] - cls = kwargs.pop('cls', None) # type: ClsType["_models.DeploymentListResult"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) + def prepare_request(next_link=None): if not next_link: - + request = build_deployments_list_at_subscription_scope_request( subscription_id=self._config.subscription_id, - api_version=api_version, filter=filter, top=top, - template_url=self.list_at_subscription_scope.metadata['url'], + api_version=api_version, + template_url=self.list_at_subscription_scope.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore else: - - request = build_deployments_list_at_subscription_scope_request( - subscription_id=self._config.subscription_id, - template_url=next_link, - ) + # make call to next link with the client's api-version + _parsed_next_link = urlparse(next_link) + _next_request_params = case_insensitive_dict(parse_qs(_parsed_next_link.query)) + _next_request_params["api-version"] = self._config.api_version + request = HttpRequest("GET", urljoin(next_link, _parsed_next_link.path), params=_next_request_params) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore request.method = "GET" return request @@ -710,10 +932,8 @@ async def extract_data(pipeline_response): async def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) response = pipeline_response.http_response @@ -723,42 +943,43 @@ async def get_next(next_link=None): return pipeline_response + return AsyncItemPaged(get_next, extract_data) - return AsyncItemPaged( - get_next, extract_data - ) - list_at_subscription_scope.metadata = {'url': "/subscriptions/{subscriptionId}/providers/Microsoft.Resources/deployments/"} # type: ignore + list_at_subscription_scope.metadata = {"url": "/subscriptions/{subscriptionId}/providers/Microsoft.Resources/deployments/"} # type: ignore async def _delete_initial( # pylint: disable=inconsistent-return-statements - self, - resource_group_name: str, - deployment_name: str, - **kwargs: Any + self, resource_group_name: str, deployment_name: str, **kwargs: Any ) -> None: - cls = kwargs.pop('cls', None) # type: ClsType[None] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + 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', "2019-03-01") # type: str + api_version = kwargs.pop("api_version", _params.pop("api-version", "2019-03-01")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[None] - - request = build_deployments_delete_request_initial( + request = build_deployments_delete_request( resource_group_name=resource_group_name, deployment_name=deployment_name, subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self._delete_initial.metadata['url'], + template_url=self._delete_initial.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [202, 204]: @@ -768,16 +989,10 @@ 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.Resources/deployments/{deploymentName}"} # type: ignore - + _delete_initial.metadata = {"url": "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/Microsoft.Resources/deployments/{deploymentName}"} # type: ignore @distributed_trace_async - async def begin_delete( # pylint: disable=inconsistent-return-statements - self, - resource_group_name: str, - deployment_name: str, - **kwargs: Any - ) -> AsyncLROPoller[None]: + async def begin_delete(self, resource_group_name: str, deployment_name: str, **kwargs: Any) -> AsyncLROPoller[None]: """Deletes a deployment from the deployment history. A template deployment that is currently running cannot be deleted. Deleting a template @@ -790,9 +1005,9 @@ async def begin_delete( # pylint: disable=inconsistent-return-statements asynchronous request failed, the URI in the Location header returns an error-level status code. :param resource_group_name: The name of the resource group with the deployment to delete. The - name is case insensitive. + name is case insensitive. Required. :type resource_group_name: str - :param deployment_name: The name of the deployment to delete. + :param deployment_name: The name of the deployment to delete. Required. :type deployment_name: str :keyword callable cls: A custom type or function that will be passed the direct response :keyword str continuation_token: A continuation token to restart a poller from a saved state. @@ -804,88 +1019,93 @@ async def begin_delete( # pylint: disable=inconsistent-return-statements Retry-After header is present. :return: An instance of AsyncLROPoller that returns either None or the result of cls(response) :rtype: ~azure.core.polling.AsyncLROPoller[None] - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - api_version = kwargs.pop('api_version', "2019-03-01") # type: str - polling = kwargs.pop('polling', True) # type: Union[bool, AsyncPollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType[None] - lro_delay = kwargs.pop( - 'polling_interval', - self._config.polling_interval - ) - cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2019-03-01")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[None] + polling = kwargs.pop("polling", True) # type: Union[bool, AsyncPollingMethod] + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token = kwargs.pop("continuation_token", None) # type: Optional[str] if cont_token is None: - raw_result = await self._delete_initial( + raw_result = await self._delete_initial( # type: ignore resource_group_name=resource_group_name, deployment_name=deployment_name, api_version=api_version, - cls=lambda x,y,z: x, + cls=lambda x, y, z: x, + headers=_headers, + params=_params, **kwargs ) - kwargs.pop('error_map', None) + kwargs.pop("error_map", None) - def get_long_running_output(pipeline_response): + def get_long_running_output(pipeline_response): # pylint: disable=inconsistent-return-statements if cls: return cls(pipeline_response, None, {}) - - if polling is True: polling_method = AsyncARMPolling(lro_delay, **kwargs) - elif polling is False: polling_method = AsyncNoPolling() - else: polling_method = polling + if polling is True: + polling_method = cast(AsyncPollingMethod, AsyncARMPolling(lro_delay, **kwargs)) # type: AsyncPollingMethod + elif polling is False: + polling_method = cast(AsyncPollingMethod, AsyncNoPolling()) + else: + polling_method = polling if cont_token: return AsyncLROPoller.from_continuation_token( polling_method=polling_method, continuation_token=cont_token, client=self._client, - deserialization_callback=get_long_running_output + deserialization_callback=get_long_running_output, ) return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) - begin_delete.metadata = {'url': "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/Microsoft.Resources/deployments/{deploymentName}"} # type: ignore + begin_delete.metadata = {"url": "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/Microsoft.Resources/deployments/{deploymentName}"} # type: ignore @distributed_trace_async - async def check_existence( - self, - resource_group_name: str, - deployment_name: str, - **kwargs: Any - ) -> bool: + async def check_existence(self, resource_group_name: str, deployment_name: str, **kwargs: Any) -> bool: """Checks whether the deployment exists. :param resource_group_name: The name of the resource group with the deployment to check. The - name is case insensitive. + name is case insensitive. Required. :type resource_group_name: str - :param deployment_name: The name of the deployment to check. + :param deployment_name: The name of the deployment to check. Required. :type deployment_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: bool, or the result of cls(response) + :return: bool or the result of cls(response) :rtype: bool - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType[None] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) - api_version = kwargs.pop('api_version', "2019-03-01") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2019-03-01")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[None] - request = build_deployments_check_existence_request( resource_group_name=resource_group_name, deployment_name=deployment_name, subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.check_existence.metadata['url'], + template_url=self.check_existence.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [204, 404]: @@ -896,44 +1116,53 @@ async def check_existence( return cls(pipeline_response, None, {}) return 200 <= response.status_code <= 299 - check_existence.metadata = {'url': "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/Microsoft.Resources/deployments/{deploymentName}"} # type: ignore - + check_existence.metadata = {"url": "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/Microsoft.Resources/deployments/{deploymentName}"} # type: ignore async def _create_or_update_initial( - self, - resource_group_name: str, - deployment_name: str, - parameters: "_models.Deployment", - **kwargs: Any - ) -> "_models.DeploymentExtended": - cls = kwargs.pop('cls', None) # type: ClsType["_models.DeploymentExtended"] + self, resource_group_name: str, deployment_name: str, parameters: Union[_models.Deployment, IO], **kwargs: Any + ) -> _models.DeploymentExtended: error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', "2019-03-01") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + api_version = kwargs.pop("api_version", _params.pop("api-version", "2019-03-01")) # type: str + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.DeploymentExtended] - _json = self._serialize.body(parameters, 'Deployment') + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(parameters, (IO, bytes)): + _content = parameters + else: + _json = self._serialize.body(parameters, "Deployment") - request = build_deployments_create_or_update_request_initial( + request = build_deployments_create_or_update_request( resource_group_name=resource_group_name, deployment_name=deployment_name, subscription_id=self._config.subscription_id, api_version=api_version, content_type=content_type, json=_json, - template_url=self._create_or_update_initial.metadata['url'], + content=_content, + template_url=self._create_or_update_initial.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200, 201]: @@ -941,38 +1170,42 @@ async def _create_or_update_initial( raise HttpResponseError(response=response, error_format=ARMErrorFormat) if response.status_code == 200: - deserialized = self._deserialize('DeploymentExtended', pipeline_response) + deserialized = self._deserialize("DeploymentExtended", pipeline_response) if response.status_code == 201: - deserialized = self._deserialize('DeploymentExtended', pipeline_response) + deserialized = self._deserialize("DeploymentExtended", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - _create_or_update_initial.metadata = {'url': "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/Microsoft.Resources/deployments/{deploymentName}"} # type: ignore - + _create_or_update_initial.metadata = {"url": "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/Microsoft.Resources/deployments/{deploymentName}"} # type: ignore - @distributed_trace_async + @overload async def begin_create_or_update( self, resource_group_name: str, deployment_name: str, - parameters: "_models.Deployment", + parameters: _models.Deployment, + *, + content_type: str = "application/json", **kwargs: Any - ) -> AsyncLROPoller["_models.DeploymentExtended"]: + ) -> AsyncLROPoller[_models.DeploymentExtended]: """Deploys resources to a resource group. You can provide the template and parameters directly in the request or link to JSON files. :param resource_group_name: The name of the resource group to deploy the resources to. The name - is case insensitive. The resource group must already exist. + is case insensitive. The resource group must already exist. Required. :type resource_group_name: str - :param deployment_name: The name of the deployment. + :param deployment_name: The name of the deployment. Required. :type deployment_name: str - :param parameters: Additional parameters supplied to the operation. + :param parameters: Additional parameters supplied to the operation. Required. :type parameters: ~azure.mgmt.resource.resources.v2019_03_01.models.Deployment + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str :keyword callable cls: A custom type or function that will be passed the direct response :keyword str continuation_token: A continuation token to restart a poller from a saved state. :keyword polling: By default, your polling method will be AsyncARMPolling. Pass in False for @@ -985,115 +1218,189 @@ async def begin_create_or_update( cls(response) :rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.resource.resources.v2019_03_01.models.DeploymentExtended] - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - api_version = kwargs.pop('api_version', "2019-03-01") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] - polling = kwargs.pop('polling', True) # type: Union[bool, AsyncPollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType["_models.DeploymentExtended"] - lro_delay = kwargs.pop( - 'polling_interval', - self._config.polling_interval - ) - cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] + + @overload + async def begin_create_or_update( + self, + resource_group_name: str, + deployment_name: str, + parameters: IO, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> AsyncLROPoller[_models.DeploymentExtended]: + """Deploys resources to a resource group. + + You can provide the template and parameters directly in the request or link to JSON files. + + :param resource_group_name: The name of the resource group to deploy the resources to. The name + is case insensitive. The resource group must already exist. Required. + :type resource_group_name: str + :param deployment_name: The name of the deployment. Required. + :type deployment_name: str + :param parameters: Additional parameters supplied to the operation. Required. + :type parameters: IO + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be AsyncARMPolling. Pass in False for + this operation to not poll, or pass in your own initialized polling object for a personal + polling strategy. + :paramtype polling: bool or ~azure.core.polling.AsyncPollingMethod + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of AsyncLROPoller that returns either DeploymentExtended or the result of + cls(response) + :rtype: + ~azure.core.polling.AsyncLROPoller[~azure.mgmt.resource.resources.v2019_03_01.models.DeploymentExtended] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace_async + async def begin_create_or_update( + self, resource_group_name: str, deployment_name: str, parameters: Union[_models.Deployment, IO], **kwargs: Any + ) -> AsyncLROPoller[_models.DeploymentExtended]: + """Deploys resources to a resource group. + + You can provide the template and parameters directly in the request or link to JSON files. + + :param resource_group_name: The name of the resource group to deploy the resources to. The name + is case insensitive. The resource group must already exist. Required. + :type resource_group_name: str + :param deployment_name: The name of the deployment. Required. + :type deployment_name: str + :param parameters: Additional parameters supplied to the operation. Is either a model type or a + IO type. Required. + :type parameters: ~azure.mgmt.resource.resources.v2019_03_01.models.Deployment or IO + :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. + Default value is None. + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be AsyncARMPolling. Pass in False for + this operation to not poll, or pass in your own initialized polling object for a personal + polling strategy. + :paramtype polling: bool or ~azure.core.polling.AsyncPollingMethod + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of AsyncLROPoller that returns either DeploymentExtended or the result of + cls(response) + :rtype: + ~azure.core.polling.AsyncLROPoller[~azure.mgmt.resource.resources.v2019_03_01.models.DeploymentExtended] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _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", "2019-03-01")) # type: str + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.DeploymentExtended] + polling = kwargs.pop("polling", True) # type: Union[bool, AsyncPollingMethod] + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token = kwargs.pop("continuation_token", None) # type: Optional[str] if cont_token is None: - raw_result = await self._create_or_update_initial( + raw_result = await self._create_or_update_initial( # type: ignore resource_group_name=resource_group_name, deployment_name=deployment_name, parameters=parameters, api_version=api_version, content_type=content_type, - cls=lambda x,y,z: x, + cls=lambda x, y, z: x, + headers=_headers, + params=_params, **kwargs ) - kwargs.pop('error_map', None) + kwargs.pop("error_map", None) def get_long_running_output(pipeline_response): - response = pipeline_response.http_response - deserialized = self._deserialize('DeploymentExtended', pipeline_response) + deserialized = self._deserialize("DeploymentExtended", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - - if polling is True: polling_method = AsyncARMPolling(lro_delay, **kwargs) - elif polling is False: polling_method = AsyncNoPolling() - else: polling_method = polling + if polling is True: + polling_method = cast(AsyncPollingMethod, AsyncARMPolling(lro_delay, **kwargs)) # type: AsyncPollingMethod + elif polling is False: + polling_method = cast(AsyncPollingMethod, AsyncNoPolling()) + else: + polling_method = polling if cont_token: return AsyncLROPoller.from_continuation_token( polling_method=polling_method, continuation_token=cont_token, client=self._client, - deserialization_callback=get_long_running_output + deserialization_callback=get_long_running_output, ) return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) - begin_create_or_update.metadata = {'url': "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/Microsoft.Resources/deployments/{deploymentName}"} # type: ignore + begin_create_or_update.metadata = {"url": "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/Microsoft.Resources/deployments/{deploymentName}"} # type: ignore @distributed_trace_async - async def get( - self, - resource_group_name: str, - deployment_name: str, - **kwargs: Any - ) -> "_models.DeploymentExtended": + async def get(self, resource_group_name: str, deployment_name: str, **kwargs: Any) -> _models.DeploymentExtended: """Gets a deployment. :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. :type resource_group_name: str - :param deployment_name: The name of the deployment to get. + :param deployment_name: The name of the deployment to get. Required. :type deployment_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: DeploymentExtended, or the result of cls(response) + :return: DeploymentExtended or the result of cls(response) :rtype: ~azure.mgmt.resource.resources.v2019_03_01.models.DeploymentExtended - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.DeploymentExtended"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + 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', "2019-03-01") # type: str + api_version = kwargs.pop("api_version", _params.pop("api-version", "2019-03-01")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[_models.DeploymentExtended] - request = build_deployments_get_request( resource_group_name=resource_group_name, deployment_name=deployment_name, subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.get.metadata['url'], + template_url=self.get.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) - deserialized = self._deserialize('DeploymentExtended', pipeline_response) + deserialized = self._deserialize("DeploymentExtended", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - get.metadata = {'url': "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/Microsoft.Resources/deployments/{deploymentName}"} # type: ignore - + get.metadata = {"url": "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/Microsoft.Resources/deployments/{deploymentName}"} # type: ignore @distributed_trace_async async def cancel( # pylint: disable=inconsistent-return-statements - self, - resource_group_name: str, - deployment_name: str, - **kwargs: Any + self, resource_group_name: str, deployment_name: str, **kwargs: Any ) -> None: """Cancels a currently running template deployment. @@ -1103,38 +1410,45 @@ async def cancel( # pylint: disable=inconsistent-return-statements partially deployed. :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. :type resource_group_name: str - :param deployment_name: The name of the deployment to cancel. + :param deployment_name: The name of the deployment to cancel. Required. :type deployment_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: None, or the result of cls(response) + :return: None or the result of cls(response) :rtype: None - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType[None] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) - api_version = kwargs.pop('api_version', "2019-03-01") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2019-03-01")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[None] - request = build_deployments_cancel_request( resource_group_name=resource_group_name, deployment_name=deployment_name, subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.cancel.metadata['url'], + template_url=self.cancel.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [204]: @@ -1144,60 +1458,130 @@ async def cancel( # pylint: disable=inconsistent-return-statements if cls: return cls(pipeline_response, None, {}) - cancel.metadata = {'url': "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/Microsoft.Resources/deployments/{deploymentName}/cancel"} # type: ignore + cancel.metadata = {"url": "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/Microsoft.Resources/deployments/{deploymentName}/cancel"} # type: ignore - - @distributed_trace_async + @overload async def validate( self, resource_group_name: str, deployment_name: str, - parameters: "_models.Deployment", + parameters: _models.Deployment, + *, + content_type: str = "application/json", **kwargs: Any - ) -> "_models.DeploymentValidateResult": + ) -> _models.DeploymentValidateResult: """Validates whether the specified template is syntactically correct and will be accepted by Azure Resource Manager.. :param resource_group_name: The name of the resource group the template will be deployed to. - The name is case insensitive. + The name is case insensitive. Required. :type resource_group_name: str - :param deployment_name: The name of the deployment. + :param deployment_name: The name of the deployment. Required. :type deployment_name: str - :param parameters: Parameters to validate. + :param parameters: Parameters to validate. Required. :type parameters: ~azure.mgmt.resource.resources.v2019_03_01.models.Deployment + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: DeploymentValidateResult, or the result of cls(response) + :return: DeploymentValidateResult or the result of cls(response) :rtype: ~azure.mgmt.resource.resources.v2019_03_01.models.DeploymentValidateResult - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.DeploymentValidateResult"] - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {})) - - api_version = kwargs.pop('api_version', "2019-03-01") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] - - _json = self._serialize.body(parameters, 'Deployment') - request = build_deployments_validate_request( - resource_group_name=resource_group_name, - deployment_name=deployment_name, - subscription_id=self._config.subscription_id, + @overload + async def validate( + self, + resource_group_name: str, + deployment_name: str, + parameters: IO, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.DeploymentValidateResult: + """Validates whether the specified template is syntactically correct and will be accepted by Azure + Resource Manager.. + + :param resource_group_name: The name of the resource group the template will be deployed to. + The name is case insensitive. Required. + :type resource_group_name: str + :param deployment_name: The name of the deployment. Required. + :type deployment_name: str + :param parameters: Parameters to validate. Required. + :type parameters: IO + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: DeploymentValidateResult or the result of cls(response) + :rtype: ~azure.mgmt.resource.resources.v2019_03_01.models.DeploymentValidateResult + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace_async + async def validate( + self, resource_group_name: str, deployment_name: str, parameters: Union[_models.Deployment, IO], **kwargs: Any + ) -> _models.DeploymentValidateResult: + """Validates whether the specified template is syntactically correct and will be accepted by Azure + Resource Manager.. + + :param resource_group_name: The name of the resource group the template will be deployed to. + The name is case insensitive. Required. + :type resource_group_name: str + :param deployment_name: The name of the deployment. Required. + :type deployment_name: str + :param parameters: Parameters to validate. Is either a model type or a IO type. Required. + :type parameters: ~azure.mgmt.resource.resources.v2019_03_01.models.Deployment or IO + :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. + Default value is None. + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: DeploymentValidateResult or the result of cls(response) + :rtype: ~azure.mgmt.resource.resources.v2019_03_01.models.DeploymentValidateResult + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2019-03-01")) # type: str + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.DeploymentValidateResult] + + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(parameters, (IO, bytes)): + _content = parameters + else: + _json = self._serialize.body(parameters, "Deployment") + + request = build_deployments_validate_request( + resource_group_name=resource_group_name, + deployment_name=deployment_name, + subscription_id=self._config.subscription_id, api_version=api_version, content_type=content_type, json=_json, - template_url=self.validate.metadata['url'], + content=_content, + template_url=self.validate.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200, 400]: @@ -1205,89 +1589,87 @@ async def validate( raise HttpResponseError(response=response, error_format=ARMErrorFormat) if response.status_code == 200: - deserialized = self._deserialize('DeploymentValidateResult', pipeline_response) + deserialized = self._deserialize("DeploymentValidateResult", pipeline_response) if response.status_code == 400: - deserialized = self._deserialize('DeploymentValidateResult', pipeline_response) + deserialized = self._deserialize("DeploymentValidateResult", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - validate.metadata = {'url': "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/Microsoft.Resources/deployments/{deploymentName}/validate"} # type: ignore - + validate.metadata = {"url": "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/Microsoft.Resources/deployments/{deploymentName}/validate"} # type: ignore @distributed_trace_async async def export_template( - self, - resource_group_name: str, - deployment_name: str, - **kwargs: Any - ) -> "_models.DeploymentExportResult": + self, resource_group_name: str, deployment_name: str, **kwargs: Any + ) -> _models.DeploymentExportResult: """Exports the template used for specified deployment. :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. :type resource_group_name: str - :param deployment_name: The name of the deployment from which to get the template. + :param deployment_name: The name of the deployment from which to get the template. Required. :type deployment_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: DeploymentExportResult, or the result of cls(response) + :return: DeploymentExportResult or the result of cls(response) :rtype: ~azure.mgmt.resource.resources.v2019_03_01.models.DeploymentExportResult - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.DeploymentExportResult"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + 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', "2019-03-01") # type: str + api_version = kwargs.pop("api_version", _params.pop("api-version", "2019-03-01")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[_models.DeploymentExportResult] - request = build_deployments_export_template_request( resource_group_name=resource_group_name, deployment_name=deployment_name, subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.export_template.metadata['url'], + template_url=self.export_template.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) - deserialized = self._deserialize('DeploymentExportResult', pipeline_response) + deserialized = self._deserialize("DeploymentExportResult", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - export_template.metadata = {'url': "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/Microsoft.Resources/deployments/{deploymentName}/exportTemplate"} # type: ignore - + export_template.metadata = {"url": "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/Microsoft.Resources/deployments/{deploymentName}/exportTemplate"} # type: ignore @distributed_trace def list_by_resource_group( - self, - resource_group_name: str, - filter: Optional[str] = None, - top: Optional[int] = None, - **kwargs: Any - ) -> AsyncIterable["_models.DeploymentListResult"]: + self, resource_group_name: str, filter: Optional[str] = None, top: Optional[int] = None, **kwargs: Any + ) -> AsyncIterable["_models.DeploymentExtended"]: """Get all the deployments for a resource group. :param resource_group_name: The name of the resource group with the deployments to get. The - name is case insensitive. + name is case insensitive. Required. :type resource_group_name: str :param filter: The filter to apply on the operation. For example, you can use $filter=provisioningState eq '{state}'. Default value is None. @@ -1296,42 +1678,49 @@ def list_by_resource_group( value is None. :type top: int :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either DeploymentListResult or the result of - cls(response) + :return: An iterator like instance of either DeploymentExtended or the result of cls(response) :rtype: - ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.resource.resources.v2019_03_01.models.DeploymentListResult] - :raises: ~azure.core.exceptions.HttpResponseError + ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.resource.resources.v2019_03_01.models.DeploymentExtended] + :raises ~azure.core.exceptions.HttpResponseError: """ - api_version = kwargs.pop('api_version', "2019-03-01") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2019-03-01")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[_models.DeploymentListResult] - cls = kwargs.pop('cls', None) # type: ClsType["_models.DeploymentListResult"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) + def prepare_request(next_link=None): if not next_link: - + request = build_deployments_list_by_resource_group_request( resource_group_name=resource_group_name, subscription_id=self._config.subscription_id, - api_version=api_version, filter=filter, top=top, - template_url=self.list_by_resource_group.metadata['url'], + 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.url = self._client.format_url(request.url) # type: ignore else: - - request = build_deployments_list_by_resource_group_request( - resource_group_name=resource_group_name, - subscription_id=self._config.subscription_id, - template_url=next_link, - ) + # make call to next link with the client's api-version + _parsed_next_link = urlparse(next_link) + _next_request_params = case_insensitive_dict(parse_qs(_parsed_next_link.query)) + _next_request_params["api-version"] = self._config.api_version + request = HttpRequest("GET", urljoin(next_link, _parsed_next_link.path), params=_next_request_params) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore request.method = "GET" return request @@ -1345,10 +1734,8 @@ async def extract_data(pipeline_response): async def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) response = pipeline_response.http_response @@ -1358,204 +1745,204 @@ async def get_next(next_link=None): return pipeline_response + return AsyncItemPaged(get_next, extract_data) - return AsyncItemPaged( - get_next, extract_data - ) - list_by_resource_group.metadata = {'url': "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/Microsoft.Resources/deployments/"} # type: ignore + list_by_resource_group.metadata = {"url": "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/Microsoft.Resources/deployments/"} # type: ignore @distributed_trace_async - async def calculate_template_hash( - self, - template: Any, - **kwargs: Any - ) -> "_models.TemplateHashResult": + async def calculate_template_hash(self, template: JSON, **kwargs: Any) -> _models.TemplateHashResult: """Calculate the hash of the given template. - :param template: The template provided to calculate hash. - :type template: any + :param template: The template provided to calculate hash. Required. + :type template: JSON :keyword callable cls: A custom type or function that will be passed the direct response - :return: TemplateHashResult, or the result of cls(response) + :return: TemplateHashResult or the result of cls(response) :rtype: ~azure.mgmt.resource.resources.v2019_03_01.models.TemplateHashResult - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.TemplateHashResult"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', "2019-03-01") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + api_version = kwargs.pop("api_version", _params.pop("api-version", "2019-03-01")) # type: str + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", "application/json")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[_models.TemplateHashResult] - _json = self._serialize.body(template, 'object') + _json = self._serialize.body(template, "object") request = build_deployments_calculate_template_hash_request( api_version=api_version, content_type=content_type, json=_json, - template_url=self.calculate_template_hash.metadata['url'], + template_url=self.calculate_template_hash.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) - deserialized = self._deserialize('TemplateHashResult', pipeline_response) + deserialized = self._deserialize("TemplateHashResult", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - calculate_template_hash.metadata = {'url': "/providers/Microsoft.Resources/calculateTemplateHash"} # type: ignore + calculate_template_hash.metadata = {"url": "/providers/Microsoft.Resources/calculateTemplateHash"} # type: ignore -class ProvidersOperations: - """ProvidersOperations async operations. - You should not instantiate this class directly. Instead, you should create a Client instance that - instantiates it for you and attaches it as an attribute. +class ProvidersOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. - :ivar models: Alias to model classes used in this operation group. - :type models: ~azure.mgmt.resource.resources.v2019_03_01.models - :param client: Client for service requests. - :param config: Configuration of service client. - :param serializer: An object model serializer. - :param deserializer: An object model deserializer. + Instead, you should access the following operations through + :class:`~azure.mgmt.resource.resources.v2019_03_01.aio.ResourceManagementClient`'s + :attr:`providers` attribute. """ models = _models - def __init__(self, client, config, serializer, deserializer) -> None: - self._client = client - self._serialize = serializer - self._deserialize = deserializer - self._config = config + def __init__(self, *args, **kwargs) -> None: + input_args = list(args) + self._client = input_args.pop(0) if input_args else kwargs.pop("client") + self._config = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") @distributed_trace_async - async def unregister( - self, - resource_provider_namespace: str, - **kwargs: Any - ) -> "_models.Provider": + async def unregister(self, resource_provider_namespace: str, **kwargs: Any) -> _models.Provider: """Unregisters a subscription from a resource provider. :param resource_provider_namespace: The namespace of the resource provider to unregister. + Required. :type resource_provider_namespace: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: Provider, or the result of cls(response) + :return: Provider or the result of cls(response) :rtype: ~azure.mgmt.resource.resources.v2019_03_01.models.Provider - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.Provider"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + 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', "2019-03-01") # type: str + api_version = kwargs.pop("api_version", _params.pop("api-version", "2019-03-01")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[_models.Provider] - request = build_providers_unregister_request( resource_provider_namespace=resource_provider_namespace, subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.unregister.metadata['url'], + template_url=self.unregister.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) - deserialized = self._deserialize('Provider', pipeline_response) + deserialized = self._deserialize("Provider", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - unregister.metadata = {'url': "/subscriptions/{subscriptionId}/providers/{resourceProviderNamespace}/unregister"} # type: ignore - + unregister.metadata = {"url": "/subscriptions/{subscriptionId}/providers/{resourceProviderNamespace}/unregister"} # type: ignore @distributed_trace_async - async def register( - self, - resource_provider_namespace: str, - **kwargs: Any - ) -> "_models.Provider": + async def register(self, resource_provider_namespace: str, **kwargs: Any) -> _models.Provider: """Registers a subscription with a resource provider. :param resource_provider_namespace: The namespace of the resource provider to register. + Required. :type resource_provider_namespace: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: Provider, or the result of cls(response) + :return: Provider or the result of cls(response) :rtype: ~azure.mgmt.resource.resources.v2019_03_01.models.Provider - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.Provider"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + 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', "2019-03-01") # type: str + api_version = kwargs.pop("api_version", _params.pop("api-version", "2019-03-01")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[_models.Provider] - request = build_providers_register_request( resource_provider_namespace=resource_provider_namespace, subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.register.metadata['url'], + template_url=self.register.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) - deserialized = self._deserialize('Provider', pipeline_response) + deserialized = self._deserialize("Provider", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - register.metadata = {'url': "/subscriptions/{subscriptionId}/providers/{resourceProviderNamespace}/register"} # type: ignore - + register.metadata = {"url": "/subscriptions/{subscriptionId}/providers/{resourceProviderNamespace}/register"} # type: ignore @distributed_trace def list( - self, - top: Optional[int] = None, - expand: Optional[str] = None, - **kwargs: Any - ) -> AsyncIterable["_models.ProviderListResult"]: + self, top: Optional[int] = None, expand: Optional[str] = None, **kwargs: Any + ) -> AsyncIterable["_models.Provider"]: """Gets all resource providers for a subscription. :param top: The number of results to return. If null is passed returns all deployments. Default @@ -1566,39 +1953,48 @@ def list( response, use $expand=resourceTypes/aliases. Default value is None. :type expand: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either ProviderListResult or the result of cls(response) + :return: An iterator like instance of either Provider or the result of cls(response) :rtype: - ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.resource.resources.v2019_03_01.models.ProviderListResult] - :raises: ~azure.core.exceptions.HttpResponseError + ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.resource.resources.v2019_03_01.models.Provider] + :raises ~azure.core.exceptions.HttpResponseError: """ - api_version = kwargs.pop('api_version', "2019-03-01") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2019-03-01")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[_models.ProviderListResult] - cls = kwargs.pop('cls', None) # type: ClsType["_models.ProviderListResult"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) + def prepare_request(next_link=None): if not next_link: - + request = build_providers_list_request( subscription_id=self._config.subscription_id, - api_version=api_version, top=top, expand=expand, - template_url=self.list.metadata['url'], + 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.url = self._client.format_url(request.url) # type: ignore else: - - request = build_providers_list_request( - subscription_id=self._config.subscription_id, - template_url=next_link, - ) + # make call to next link with the client's api-version + _parsed_next_link = urlparse(next_link) + _next_request_params = case_insensitive_dict(parse_qs(_parsed_next_link.query)) + _next_request_params["api-version"] = self._config.api_version + request = HttpRequest("GET", urljoin(next_link, _parsed_next_link.path), params=_next_request_params) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore request.method = "GET" return request @@ -1612,10 +2008,8 @@ async def extract_data(pipeline_response): async def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) response = pipeline_response.http_response @@ -1625,91 +2019,90 @@ async def get_next(next_link=None): return pipeline_response + return AsyncItemPaged(get_next, extract_data) - return AsyncItemPaged( - get_next, extract_data - ) - list.metadata = {'url': "/subscriptions/{subscriptionId}/providers"} # type: ignore + list.metadata = {"url": "/subscriptions/{subscriptionId}/providers"} # type: ignore @distributed_trace_async async def get( - self, - resource_provider_namespace: str, - expand: Optional[str] = None, - **kwargs: Any - ) -> "_models.Provider": + self, resource_provider_namespace: str, expand: Optional[str] = None, **kwargs: Any + ) -> _models.Provider: """Gets the specified resource provider. - :param resource_provider_namespace: The namespace of the resource provider. + :param resource_provider_namespace: The namespace of the resource provider. Required. :type resource_provider_namespace: str :param expand: The $expand query parameter. For example, to include property aliases in response, use $expand=resourceTypes/aliases. Default value is None. :type expand: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: Provider, or the result of cls(response) + :return: Provider or the result of cls(response) :rtype: ~azure.mgmt.resource.resources.v2019_03_01.models.Provider - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.Provider"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) - api_version = kwargs.pop('api_version', "2019-03-01") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2019-03-01")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[_models.Provider] - request = build_providers_get_request( resource_provider_namespace=resource_provider_namespace, subscription_id=self._config.subscription_id, - api_version=api_version, expand=expand, - template_url=self.get.metadata['url'], + api_version=api_version, + template_url=self.get.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) - deserialized = self._deserialize('Provider', pipeline_response) + deserialized = self._deserialize("Provider", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - get.metadata = {'url': "/subscriptions/{subscriptionId}/providers/{resourceProviderNamespace}"} # type: ignore + get.metadata = {"url": "/subscriptions/{subscriptionId}/providers/{resourceProviderNamespace}"} # type: ignore -class ResourcesOperations: # pylint: disable=too-many-public-methods - """ResourcesOperations async operations. - You should not instantiate this class directly. Instead, you should create a Client instance that - instantiates it for you and attaches it as an attribute. +class ResourcesOperations: # pylint: disable=too-many-public-methods + """ + .. warning:: + **DO NOT** instantiate this class directly. - :ivar models: Alias to model classes used in this operation group. - :type models: ~azure.mgmt.resource.resources.v2019_03_01.models - :param client: Client for service requests. - :param config: Configuration of service client. - :param serializer: An object model serializer. - :param deserializer: An object model deserializer. + Instead, you should access the following operations through + :class:`~azure.mgmt.resource.resources.v2019_03_01.aio.ResourceManagementClient`'s + :attr:`resources` attribute. """ models = _models - def __init__(self, client, config, serializer, deserializer) -> None: - self._client = client - self._serialize = serializer - self._deserialize = deserializer - self._config = config + def __init__(self, *args, **kwargs) -> None: + input_args = list(args) + self._client = input_args.pop(0) if input_args else kwargs.pop("client") + self._config = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") @distributed_trace def list_by_resource_group( @@ -1719,10 +2112,10 @@ def list_by_resource_group( expand: Optional[str] = None, top: Optional[int] = None, **kwargs: Any - ) -> AsyncIterable["_models.ResourceListResult"]: + ) -> AsyncIterable["_models.GenericResourceExpanded"]: """Get all the resources for a resource group. - :param resource_group_name: The resource group with the resources to get. + :param resource_group_name: The resource group with the resources to get. Required. :type resource_group_name: str :param filter: The filter to apply on the operation.:code:`
`:code:`
`The properties you can use for eq (equals) or ne (not equals) are: location, resourceType, name, resourceGroup, @@ -1747,42 +2140,51 @@ def list_by_resource_group( value is None. :type top: int :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either ResourceListResult or the result of cls(response) + :return: An iterator like instance of either GenericResourceExpanded or the result of + cls(response) :rtype: - ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.resource.resources.v2019_03_01.models.ResourceListResult] - :raises: ~azure.core.exceptions.HttpResponseError + ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.resource.resources.v2019_03_01.models.GenericResourceExpanded] + :raises ~azure.core.exceptions.HttpResponseError: """ - api_version = kwargs.pop('api_version', "2019-03-01") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2019-03-01")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[_models.ResourceListResult] - cls = kwargs.pop('cls', None) # type: ClsType["_models.ResourceListResult"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) + def prepare_request(next_link=None): if not next_link: - + request = build_resources_list_by_resource_group_request( resource_group_name=resource_group_name, subscription_id=self._config.subscription_id, - api_version=api_version, filter=filter, expand=expand, top=top, - template_url=self.list_by_resource_group.metadata['url'], + 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.url = self._client.format_url(request.url) # type: ignore else: - - request = build_resources_list_by_resource_group_request( - resource_group_name=resource_group_name, - subscription_id=self._config.subscription_id, - template_url=next_link, - ) + # make call to next link with the client's api-version + _parsed_next_link = urlparse(next_link) + _next_request_params = case_insensitive_dict(parse_qs(_parsed_next_link.query)) + _next_request_params["api-version"] = self._config.api_version + request = HttpRequest("GET", urljoin(next_link, _parsed_next_link.path), params=_next_request_params) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore request.method = "GET" return request @@ -1796,10 +2198,8 @@ async def extract_data(pipeline_response): async def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) response = pipeline_response.http_response @@ -1809,45 +2209,54 @@ async def get_next(next_link=None): return pipeline_response + return AsyncItemPaged(get_next, extract_data) - return AsyncItemPaged( - get_next, extract_data - ) - list_by_resource_group.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/resources"} # type: ignore + list_by_resource_group.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/resources"} # type: ignore async def _move_resources_initial( # pylint: disable=inconsistent-return-statements - self, - source_resource_group_name: str, - parameters: "_models.ResourcesMoveInfo", - **kwargs: Any + self, source_resource_group_name: str, parameters: Union[_models.ResourcesMoveInfo, IO], **kwargs: Any ) -> None: - cls = kwargs.pop('cls', None) # type: ClsType[None] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) - api_version = kwargs.pop('api_version', "2019-03-01") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - _json = self._serialize.body(parameters, 'ResourcesMoveInfo') + api_version = kwargs.pop("api_version", _params.pop("api-version", "2019-03-01")) # type: str + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[None] - request = build_resources_move_resources_request_initial( + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(parameters, (IO, bytes)): + _content = parameters + else: + _json = self._serialize.body(parameters, "ResourcesMoveInfo") + + request = build_resources_move_resources_request( source_resource_group_name=source_resource_group_name, subscription_id=self._config.subscription_id, api_version=api_version, content_type=content_type, json=_json, - template_url=self._move_resources_initial.metadata['url'], + content=_content, + template_url=self._move_resources_initial.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [202, 204]: @@ -1857,14 +2266,15 @@ async def _move_resources_initial( # pylint: disable=inconsistent-return-statem if cls: return cls(pipeline_response, None, {}) - _move_resources_initial.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{sourceResourceGroupName}/moveResources"} # type: ignore + _move_resources_initial.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{sourceResourceGroupName}/moveResources"} # type: ignore - - @distributed_trace_async - async def begin_move_resources( # pylint: disable=inconsistent-return-statements + @overload + async def begin_move_resources( self, source_resource_group_name: str, - parameters: "_models.ResourcesMoveInfo", + parameters: _models.ResourcesMoveInfo, + *, + content_type: str = "application/json", **kwargs: Any ) -> AsyncLROPoller[None]: """Moves resources from one resource group to another resource group. @@ -1875,10 +2285,13 @@ async def begin_move_resources( # pylint: disable=inconsistent-return-statement the groups until the move completes. :param source_resource_group_name: The name of the resource group containing the resources to - move. + move. Required. :type source_resource_group_name: str - :param parameters: Parameters for moving resources. + :param parameters: Parameters for moving resources. Required. :type parameters: ~azure.mgmt.resource.resources.v2019_03_01.models.ResourcesMoveInfo + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str :keyword callable cls: A custom type or function that will be passed the direct response :keyword str continuation_token: A continuation token to restart a poller from a saved state. :keyword polling: By default, your polling method will be AsyncARMPolling. Pass in False for @@ -1889,80 +2302,160 @@ async def begin_move_resources( # pylint: disable=inconsistent-return-statement Retry-After header is present. :return: An instance of AsyncLROPoller that returns either None or the result of cls(response) :rtype: ~azure.core.polling.AsyncLROPoller[None] - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - api_version = kwargs.pop('api_version', "2019-03-01") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] - polling = kwargs.pop('polling', True) # type: Union[bool, AsyncPollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType[None] - lro_delay = kwargs.pop( - 'polling_interval', - self._config.polling_interval - ) - cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] + + @overload + async def begin_move_resources( + self, source_resource_group_name: str, parameters: IO, *, content_type: str = "application/json", **kwargs: Any + ) -> AsyncLROPoller[None]: + """Moves resources from one resource group to another resource group. + + The resources to move must be in the same source resource group. The target resource group may + be in a different subscription. When moving resources, both the source group and the target + group are locked for the duration of the operation. Write and delete operations are blocked on + the groups until the move completes. + + :param source_resource_group_name: The name of the resource group containing the resources to + move. Required. + :type source_resource_group_name: str + :param parameters: Parameters for moving resources. Required. + :type parameters: IO + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be AsyncARMPolling. Pass in False for + this operation to not poll, or pass in your own initialized polling object for a personal + polling strategy. + :paramtype polling: bool or ~azure.core.polling.AsyncPollingMethod + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of AsyncLROPoller that returns either None or the result of cls(response) + :rtype: ~azure.core.polling.AsyncLROPoller[None] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace_async + async def begin_move_resources( + self, source_resource_group_name: str, parameters: Union[_models.ResourcesMoveInfo, IO], **kwargs: Any + ) -> AsyncLROPoller[None]: + """Moves resources from one resource group to another resource group. + + The resources to move must be in the same source resource group. The target resource group may + be in a different subscription. When moving resources, both the source group and the target + group are locked for the duration of the operation. Write and delete operations are blocked on + the groups until the move completes. + + :param source_resource_group_name: The name of the resource group containing the resources to + move. Required. + :type source_resource_group_name: str + :param parameters: Parameters for moving resources. Is either a model type or a IO type. + Required. + :type parameters: ~azure.mgmt.resource.resources.v2019_03_01.models.ResourcesMoveInfo or IO + :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. + Default value is None. + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be AsyncARMPolling. Pass in False for + this operation to not poll, or pass in your own initialized polling object for a personal + polling strategy. + :paramtype polling: bool or ~azure.core.polling.AsyncPollingMethod + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of AsyncLROPoller that returns either None or the result of cls(response) + :rtype: ~azure.core.polling.AsyncLROPoller[None] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _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", "2019-03-01")) # type: str + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[None] + polling = kwargs.pop("polling", True) # type: Union[bool, AsyncPollingMethod] + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token = kwargs.pop("continuation_token", None) # type: Optional[str] if cont_token is None: - raw_result = await self._move_resources_initial( + raw_result = await self._move_resources_initial( # type: ignore source_resource_group_name=source_resource_group_name, parameters=parameters, api_version=api_version, content_type=content_type, - cls=lambda x,y,z: x, + cls=lambda x, y, z: x, + headers=_headers, + params=_params, **kwargs ) - kwargs.pop('error_map', None) + kwargs.pop("error_map", None) - def get_long_running_output(pipeline_response): + def get_long_running_output(pipeline_response): # pylint: disable=inconsistent-return-statements if cls: return cls(pipeline_response, None, {}) - - if polling is True: polling_method = AsyncARMPolling(lro_delay, **kwargs) - elif polling is False: polling_method = AsyncNoPolling() - else: polling_method = polling + if polling is True: + polling_method = cast(AsyncPollingMethod, AsyncARMPolling(lro_delay, **kwargs)) # type: AsyncPollingMethod + elif polling is False: + polling_method = cast(AsyncPollingMethod, AsyncNoPolling()) + else: + polling_method = polling if cont_token: return AsyncLROPoller.from_continuation_token( polling_method=polling_method, continuation_token=cont_token, client=self._client, - deserialization_callback=get_long_running_output + deserialization_callback=get_long_running_output, ) return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) - begin_move_resources.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{sourceResourceGroupName}/moveResources"} # type: ignore + begin_move_resources.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{sourceResourceGroupName}/moveResources"} # type: ignore async def _validate_move_resources_initial( # pylint: disable=inconsistent-return-statements - self, - source_resource_group_name: str, - parameters: "_models.ResourcesMoveInfo", - **kwargs: Any + self, source_resource_group_name: str, parameters: Union[_models.ResourcesMoveInfo, IO], **kwargs: Any ) -> None: - cls = kwargs.pop('cls', None) # type: ClsType[None] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) - api_version = kwargs.pop('api_version', "2019-03-01") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - _json = self._serialize.body(parameters, 'ResourcesMoveInfo') + api_version = kwargs.pop("api_version", _params.pop("api-version", "2019-03-01")) # type: str + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[None] - request = build_resources_validate_move_resources_request_initial( + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(parameters, (IO, bytes)): + _content = parameters + else: + _json = self._serialize.body(parameters, "ResourcesMoveInfo") + + request = build_resources_validate_move_resources_request( source_resource_group_name=source_resource_group_name, subscription_id=self._config.subscription_id, api_version=api_version, content_type=content_type, json=_json, - template_url=self._validate_move_resources_initial.metadata['url'], + content=_content, + template_url=self._validate_move_resources_initial.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [202, 204, 409]: @@ -1972,14 +2465,15 @@ async def _validate_move_resources_initial( # pylint: disable=inconsistent-retu if cls: return cls(pipeline_response, None, {}) - _validate_move_resources_initial.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{sourceResourceGroupName}/validateMoveResources"} # type: ignore + _validate_move_resources_initial.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{sourceResourceGroupName}/validateMoveResources"} # type: ignore - - @distributed_trace_async - async def begin_validate_move_resources( # pylint: disable=inconsistent-return-statements + @overload + async def begin_validate_move_resources( self, source_resource_group_name: str, - parameters: "_models.ResourcesMoveInfo", + parameters: _models.ResourcesMoveInfo, + *, + content_type: str = "application/json", **kwargs: Any ) -> AsyncLROPoller[None]: """Validates whether resources can be moved from one resource group to another resource group. @@ -1992,10 +2486,13 @@ async def begin_validate_move_resources( # pylint: disable=inconsistent-return- operation. :param source_resource_group_name: The name of the resource group containing the resources to - validate for move. + validate for move. Required. :type source_resource_group_name: str - :param parameters: Parameters for moving resources. + :param parameters: Parameters for moving resources. Required. :type parameters: ~azure.mgmt.resource.resources.v2019_03_01.models.ResourcesMoveInfo + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str :keyword callable cls: A custom type or function that will be passed the direct response :keyword str continuation_token: A continuation token to restart a poller from a saved state. :keyword polling: By default, your polling method will be AsyncARMPolling. Pass in False for @@ -2006,55 +2503,124 @@ async def begin_validate_move_resources( # pylint: disable=inconsistent-return- Retry-After header is present. :return: An instance of AsyncLROPoller that returns either None or the result of cls(response) :rtype: ~azure.core.polling.AsyncLROPoller[None] - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - api_version = kwargs.pop('api_version', "2019-03-01") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] - polling = kwargs.pop('polling', True) # type: Union[bool, AsyncPollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType[None] - lro_delay = kwargs.pop( - 'polling_interval', - self._config.polling_interval - ) - cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] + + @overload + async def begin_validate_move_resources( + self, source_resource_group_name: str, parameters: IO, *, content_type: str = "application/json", **kwargs: Any + ) -> AsyncLROPoller[None]: + """Validates whether resources can be moved from one resource group to another resource group. + + This operation checks whether the specified resources can be moved to the target. The resources + to move must be in the same source resource group. The target resource group may be in a + different subscription. If validation succeeds, it returns HTTP response code 204 (no content). + If validation fails, it returns HTTP response code 409 (Conflict) with an error message. + Retrieve the URL in the Location header value to check the result of the long-running + operation. + + :param source_resource_group_name: The name of the resource group containing the resources to + validate for move. Required. + :type source_resource_group_name: str + :param parameters: Parameters for moving resources. Required. + :type parameters: IO + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be AsyncARMPolling. Pass in False for + this operation to not poll, or pass in your own initialized polling object for a personal + polling strategy. + :paramtype polling: bool or ~azure.core.polling.AsyncPollingMethod + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of AsyncLROPoller that returns either None or the result of cls(response) + :rtype: ~azure.core.polling.AsyncLROPoller[None] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace_async + async def begin_validate_move_resources( + self, source_resource_group_name: str, parameters: Union[_models.ResourcesMoveInfo, IO], **kwargs: Any + ) -> AsyncLROPoller[None]: + """Validates whether resources can be moved from one resource group to another resource group. + + This operation checks whether the specified resources can be moved to the target. The resources + to move must be in the same source resource group. The target resource group may be in a + different subscription. If validation succeeds, it returns HTTP response code 204 (no content). + If validation fails, it returns HTTP response code 409 (Conflict) with an error message. + Retrieve the URL in the Location header value to check the result of the long-running + operation. + + :param source_resource_group_name: The name of the resource group containing the resources to + validate for move. Required. + :type source_resource_group_name: str + :param parameters: Parameters for moving resources. Is either a model type or a IO type. + Required. + :type parameters: ~azure.mgmt.resource.resources.v2019_03_01.models.ResourcesMoveInfo or IO + :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. + Default value is None. + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be AsyncARMPolling. Pass in False for + this operation to not poll, or pass in your own initialized polling object for a personal + polling strategy. + :paramtype polling: bool or ~azure.core.polling.AsyncPollingMethod + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of AsyncLROPoller that returns either None or the result of cls(response) + :rtype: ~azure.core.polling.AsyncLROPoller[None] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _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", "2019-03-01")) # type: str + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[None] + polling = kwargs.pop("polling", True) # type: Union[bool, AsyncPollingMethod] + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token = kwargs.pop("continuation_token", None) # type: Optional[str] if cont_token is None: - raw_result = await self._validate_move_resources_initial( + raw_result = await self._validate_move_resources_initial( # type: ignore source_resource_group_name=source_resource_group_name, parameters=parameters, api_version=api_version, content_type=content_type, - cls=lambda x,y,z: x, + cls=lambda x, y, z: x, + headers=_headers, + params=_params, **kwargs ) - kwargs.pop('error_map', None) + kwargs.pop("error_map", None) - def get_long_running_output(pipeline_response): + def get_long_running_output(pipeline_response): # pylint: disable=inconsistent-return-statements if cls: return cls(pipeline_response, None, {}) - - if polling is True: polling_method = AsyncARMPolling(lro_delay, **kwargs) - elif polling is False: polling_method = AsyncNoPolling() - else: polling_method = polling + if polling is True: + polling_method = cast(AsyncPollingMethod, AsyncARMPolling(lro_delay, **kwargs)) # type: AsyncPollingMethod + elif polling is False: + polling_method = cast(AsyncPollingMethod, AsyncNoPolling()) + else: + polling_method = polling if cont_token: return AsyncLROPoller.from_continuation_token( polling_method=polling_method, continuation_token=cont_token, client=self._client, - deserialization_callback=get_long_running_output + deserialization_callback=get_long_running_output, ) return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) - begin_validate_move_resources.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{sourceResourceGroupName}/validateMoveResources"} # type: ignore + begin_validate_move_resources.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{sourceResourceGroupName}/validateMoveResources"} # type: ignore @distributed_trace def list( - self, - filter: Optional[str] = None, - expand: Optional[str] = None, - top: Optional[int] = None, - **kwargs: Any - ) -> AsyncIterable["_models.ResourceListResult"]: + self, filter: Optional[str] = None, expand: Optional[str] = None, top: Optional[int] = None, **kwargs: Any + ) -> AsyncIterable["_models.GenericResourceExpanded"]: """Get all the resources in a subscription. :param filter: The filter to apply on the operation.:code:`
`:code:`
`The properties you @@ -2080,40 +2646,50 @@ def list( value is None. :type top: int :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either ResourceListResult or the result of cls(response) + :return: An iterator like instance of either GenericResourceExpanded or the result of + cls(response) :rtype: - ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.resource.resources.v2019_03_01.models.ResourceListResult] - :raises: ~azure.core.exceptions.HttpResponseError + ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.resource.resources.v2019_03_01.models.GenericResourceExpanded] + :raises ~azure.core.exceptions.HttpResponseError: """ - api_version = kwargs.pop('api_version', "2019-03-01") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2019-03-01")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[_models.ResourceListResult] - cls = kwargs.pop('cls', None) # type: ClsType["_models.ResourceListResult"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) + def prepare_request(next_link=None): if not next_link: - + request = build_resources_list_request( subscription_id=self._config.subscription_id, - api_version=api_version, filter=filter, expand=expand, top=top, - template_url=self.list.metadata['url'], + 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.url = self._client.format_url(request.url) # type: ignore else: - - request = build_resources_list_request( - subscription_id=self._config.subscription_id, - template_url=next_link, - ) + # make call to next link with the client's api-version + _parsed_next_link = urlparse(next_link) + _next_request_params = case_insensitive_dict(parse_qs(_parsed_next_link.query)) + _next_request_params["api-version"] = self._config.api_version + request = HttpRequest("GET", urljoin(next_link, _parsed_next_link.path), params=_next_request_params) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore request.method = "GET" return request @@ -2127,10 +2703,8 @@ async def extract_data(pipeline_response): async def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) response = pipeline_response.http_response @@ -2140,11 +2714,9 @@ async def get_next(next_link=None): return pipeline_response + return AsyncItemPaged(get_next, extract_data) - return AsyncItemPaged( - get_next, extract_data - ) - list.metadata = {'url': "/subscriptions/{subscriptionId}/resources"} # type: ignore + list.metadata = {"url": "/subscriptions/{subscriptionId}/resources"} # type: ignore @distributed_trace_async async def check_existence( @@ -2160,30 +2732,36 @@ async def check_existence( """Checks whether a resource exists. :param resource_group_name: The name of the resource group containing the resource to check. - The name is case insensitive. + The name is case insensitive. Required. :type resource_group_name: str - :param resource_provider_namespace: The resource provider of the resource to check. + :param resource_provider_namespace: The resource provider of the resource to check. Required. :type resource_provider_namespace: str - :param parent_resource_path: The parent resource identity. + :param parent_resource_path: The parent resource identity. Required. :type parent_resource_path: str - :param resource_type: The resource type. + :param resource_type: The resource type. Required. :type resource_type: str - :param resource_name: The name of the resource to check whether it exists. + :param resource_name: The name of the resource to check whether it exists. Required. :type resource_name: str - :param api_version: The API version to use for the operation. + :param api_version: The API version to use for the operation. Required. :type api_version: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: bool, or the result of cls(response) + :return: bool or the result of cls(response) :rtype: bool - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType[None] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = kwargs.pop("params", {}) or {} + + cls = kwargs.pop("cls", None) # type: ClsType[None] - request = build_resources_check_existence_request( resource_group_name=resource_group_name, resource_provider_namespace=resource_provider_namespace, @@ -2192,16 +2770,17 @@ async def check_existence( resource_name=resource_name, subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.check_existence.metadata['url'], + template_url=self.check_existence.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [204, 404]: @@ -2212,8 +2791,7 @@ async def check_existence( return cls(pipeline_response, None, {}) return 200 <= response.status_code <= 299 - check_existence.metadata = {'url': "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{parentResourcePath}/{resourceType}/{resourceName}"} # type: ignore - + check_existence.metadata = {"url": "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{parentResourcePath}/{resourceType}/{resourceName}"} # type: ignore async def _delete_initial( # pylint: disable=inconsistent-return-statements self, @@ -2225,31 +2803,38 @@ async def _delete_initial( # pylint: disable=inconsistent-return-statements api_version: str, **kwargs: Any ) -> None: - cls = kwargs.pop('cls', None) # type: ClsType[None] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) - - request = build_resources_delete_request_initial( - resource_group_name=resource_group_name, + _headers = kwargs.pop("headers", {}) or {} + _params = kwargs.pop("params", {}) or {} + + cls = kwargs.pop("cls", None) # type: ClsType[None] + + request = build_resources_delete_request( + resource_group_name=resource_group_name, resource_provider_namespace=resource_provider_namespace, parent_resource_path=parent_resource_path, resource_type=resource_type, resource_name=resource_name, subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self._delete_initial.metadata['url'], + template_url=self._delete_initial.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200, 202, 204]: @@ -2259,11 +2844,10 @@ 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/{resourceProviderNamespace}/{parentResourcePath}/{resourceType}/{resourceName}"} # type: ignore - + _delete_initial.metadata = {"url": "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{parentResourcePath}/{resourceType}/{resourceName}"} # type: ignore @distributed_trace_async - async def begin_delete( # pylint: disable=inconsistent-return-statements + async def begin_delete( self, resource_group_name: str, resource_provider_namespace: str, @@ -2276,17 +2860,17 @@ async def begin_delete( # pylint: disable=inconsistent-return-statements """Deletes a resource. :param resource_group_name: The name of the resource group that contains the resource to - delete. The name is case insensitive. + delete. The name is case insensitive. Required. :type resource_group_name: str - :param resource_provider_namespace: The namespace of the resource provider. + :param resource_provider_namespace: The namespace of the resource provider. Required. :type resource_provider_namespace: str - :param parent_resource_path: The parent resource identity. + :param parent_resource_path: The parent resource identity. Required. :type parent_resource_path: str - :param resource_type: The resource type. + :param resource_type: The resource type. Required. :type resource_type: str - :param resource_name: The name of the resource to delete. + :param resource_name: The name of the resource to delete. Required. :type resource_name: str - :param api_version: The API version to use for the operation. + :param api_version: The API version to use for the operation. Required. :type api_version: str :keyword callable cls: A custom type or function that will be passed the direct response :keyword str continuation_token: A continuation token to restart a poller from a saved state. @@ -2298,46 +2882,50 @@ async def begin_delete( # pylint: disable=inconsistent-return-statements Retry-After header is present. :return: An instance of AsyncLROPoller that returns either None or the result of cls(response) :rtype: ~azure.core.polling.AsyncLROPoller[None] - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - polling = kwargs.pop('polling', True) # type: Union[bool, AsyncPollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType[None] - lro_delay = kwargs.pop( - 'polling_interval', - self._config.polling_interval - ) - cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] + _headers = kwargs.pop("headers", {}) or {} + _params = kwargs.pop("params", {}) or {} + + cls = kwargs.pop("cls", None) # type: ClsType[None] + polling = kwargs.pop("polling", True) # type: Union[bool, AsyncPollingMethod] + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token = kwargs.pop("continuation_token", None) # type: Optional[str] if cont_token is None: - raw_result = await self._delete_initial( + raw_result = await self._delete_initial( # type: ignore resource_group_name=resource_group_name, resource_provider_namespace=resource_provider_namespace, parent_resource_path=parent_resource_path, resource_type=resource_type, resource_name=resource_name, api_version=api_version, - cls=lambda x,y,z: x, + cls=lambda x, y, z: x, + headers=_headers, + params=_params, **kwargs ) - kwargs.pop('error_map', None) + kwargs.pop("error_map", None) - def get_long_running_output(pipeline_response): + def get_long_running_output(pipeline_response): # pylint: disable=inconsistent-return-statements if cls: return cls(pipeline_response, None, {}) - - if polling is True: polling_method = AsyncARMPolling(lro_delay, **kwargs) - elif polling is False: polling_method = AsyncNoPolling() - else: polling_method = polling + if polling is True: + polling_method = cast(AsyncPollingMethod, AsyncARMPolling(lro_delay, **kwargs)) # type: AsyncPollingMethod + elif polling is False: + polling_method = cast(AsyncPollingMethod, AsyncNoPolling()) + else: + polling_method = polling if cont_token: return AsyncLROPoller.from_continuation_token( polling_method=polling_method, continuation_token=cont_token, client=self._client, - deserialization_callback=get_long_running_output + deserialization_callback=get_long_running_output, ) return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) - begin_delete.metadata = {'url': "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{parentResourcePath}/{resourceType}/{resourceName}"} # type: ignore + begin_delete.metadata = {"url": "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{parentResourcePath}/{resourceType}/{resourceName}"} # type: ignore async def _create_or_update_initial( self, @@ -2347,39 +2935,53 @@ async def _create_or_update_initial( resource_type: str, resource_name: str, api_version: str, - parameters: "_models.GenericResource", + parameters: Union[_models.GenericResource, IO], **kwargs: Any - ) -> Optional["_models.GenericResource"]: - cls = kwargs.pop('cls', None) # type: ClsType[Optional["_models.GenericResource"]] + ) -> Optional[_models.GenericResource]: error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = kwargs.pop("params", {}) or {} - _json = self._serialize.body(parameters, 'GenericResource') + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[Optional[_models.GenericResource]] - request = build_resources_create_or_update_request_initial( + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(parameters, (IO, bytes)): + _content = parameters + else: + _json = self._serialize.body(parameters, "GenericResource") + + request = build_resources_create_or_update_request( resource_group_name=resource_group_name, resource_provider_namespace=resource_provider_namespace, parent_resource_path=parent_resource_path, resource_type=resource_type, resource_name=resource_name, subscription_id=self._config.subscription_id, - content_type=content_type, api_version=api_version, + content_type=content_type, json=_json, - template_url=self._create_or_update_initial.metadata['url'], + content=_content, + template_url=self._create_or_update_initial.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200, 201, 202]: @@ -2388,18 +2990,115 @@ async def _create_or_update_initial( deserialized = None if response.status_code == 200: - deserialized = self._deserialize('GenericResource', pipeline_response) + deserialized = self._deserialize("GenericResource", pipeline_response) if response.status_code == 201: - deserialized = self._deserialize('GenericResource', pipeline_response) + deserialized = self._deserialize("GenericResource", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - _create_or_update_initial.metadata = {'url': "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{parentResourcePath}/{resourceType}/{resourceName}"} # type: ignore + _create_or_update_initial.metadata = {"url": "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{parentResourcePath}/{resourceType}/{resourceName}"} # type: ignore + @overload + async def begin_create_or_update( + self, + resource_group_name: str, + resource_provider_namespace: str, + parent_resource_path: str, + resource_type: str, + resource_name: str, + api_version: str, + parameters: _models.GenericResource, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> AsyncLROPoller[_models.GenericResource]: + """Creates a resource. + + :param resource_group_name: The name of the resource group for the resource. The name is case + insensitive. Required. + :type resource_group_name: str + :param resource_provider_namespace: The namespace of the resource provider. Required. + :type resource_provider_namespace: str + :param parent_resource_path: The parent resource identity. Required. + :type parent_resource_path: str + :param resource_type: The resource type of the resource to create. Required. + :type resource_type: str + :param resource_name: The name of the resource to create. Required. + :type resource_name: str + :param api_version: The API version to use for the operation. Required. + :type api_version: str + :param parameters: Parameters for creating or updating the resource. Required. + :type parameters: ~azure.mgmt.resource.resources.v2019_03_01.models.GenericResource + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be AsyncARMPolling. Pass in False for + this operation to not poll, or pass in your own initialized polling object for a personal + polling strategy. + :paramtype polling: bool or ~azure.core.polling.AsyncPollingMethod + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of AsyncLROPoller that returns either GenericResource or the result of + cls(response) + :rtype: + ~azure.core.polling.AsyncLROPoller[~azure.mgmt.resource.resources.v2019_03_01.models.GenericResource] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + async def begin_create_or_update( + self, + resource_group_name: str, + resource_provider_namespace: str, + parent_resource_path: str, + resource_type: str, + resource_name: str, + api_version: str, + parameters: IO, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> AsyncLROPoller[_models.GenericResource]: + """Creates a resource. + + :param resource_group_name: The name of the resource group for the resource. The name is case + insensitive. Required. + :type resource_group_name: str + :param resource_provider_namespace: The namespace of the resource provider. Required. + :type resource_provider_namespace: str + :param parent_resource_path: The parent resource identity. Required. + :type parent_resource_path: str + :param resource_type: The resource type of the resource to create. Required. + :type resource_type: str + :param resource_name: The name of the resource to create. Required. + :type resource_name: str + :param api_version: The API version to use for the operation. Required. + :type api_version: str + :param parameters: Parameters for creating or updating the resource. Required. + :type parameters: IO + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be AsyncARMPolling. Pass in False for + this operation to not poll, or pass in your own initialized polling object for a personal + polling strategy. + :paramtype polling: bool or ~azure.core.polling.AsyncPollingMethod + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of AsyncLROPoller that returns either GenericResource or the result of + cls(response) + :rtype: + ~azure.core.polling.AsyncLROPoller[~azure.mgmt.resource.resources.v2019_03_01.models.GenericResource] + :raises ~azure.core.exceptions.HttpResponseError: + """ @distributed_trace_async async def begin_create_or_update( @@ -2410,26 +3109,30 @@ async def begin_create_or_update( resource_type: str, resource_name: str, api_version: str, - parameters: "_models.GenericResource", + parameters: Union[_models.GenericResource, IO], **kwargs: Any - ) -> AsyncLROPoller["_models.GenericResource"]: + ) -> AsyncLROPoller[_models.GenericResource]: """Creates a resource. :param resource_group_name: The name of the resource group for the resource. The name is case - insensitive. + insensitive. Required. :type resource_group_name: str - :param resource_provider_namespace: The namespace of the resource provider. + :param resource_provider_namespace: The namespace of the resource provider. Required. :type resource_provider_namespace: str - :param parent_resource_path: The parent resource identity. + :param parent_resource_path: The parent resource identity. Required. :type parent_resource_path: str - :param resource_type: The resource type of the resource to create. + :param resource_type: The resource type of the resource to create. Required. :type resource_type: str - :param resource_name: The name of the resource to create. + :param resource_name: The name of the resource to create. Required. :type resource_name: str - :param api_version: The API version to use for the operation. + :param api_version: The API version to use for the operation. Required. :type api_version: str - :param parameters: Parameters for creating or updating the resource. - :type parameters: ~azure.mgmt.resource.resources.v2019_03_01.models.GenericResource + :param parameters: Parameters for creating or updating the resource. Is either a model type or + a IO type. Required. + :type parameters: ~azure.mgmt.resource.resources.v2019_03_01.models.GenericResource or IO + :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. + Default value is None. + :paramtype content_type: str :keyword callable cls: A custom type or function that will be passed the direct response :keyword str continuation_token: A continuation token to restart a poller from a saved state. :keyword polling: By default, your polling method will be AsyncARMPolling. Pass in False for @@ -2442,18 +3145,18 @@ async def begin_create_or_update( cls(response) :rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.resource.resources.v2019_03_01.models.GenericResource] - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] - polling = kwargs.pop('polling', True) # type: Union[bool, AsyncPollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType["_models.GenericResource"] - lro_delay = kwargs.pop( - 'polling_interval', - self._config.polling_interval - ) - cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = kwargs.pop("params", {}) or {} + + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.GenericResource] + polling = kwargs.pop("polling", True) # type: Union[bool, AsyncPollingMethod] + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token = kwargs.pop("continuation_token", None) # type: Optional[str] if cont_token is None: - raw_result = await self._create_or_update_initial( + raw_result = await self._create_or_update_initial( # type: ignore resource_group_name=resource_group_name, resource_provider_namespace=resource_provider_namespace, parent_resource_path=parent_resource_path, @@ -2462,32 +3165,35 @@ async def begin_create_or_update( api_version=api_version, parameters=parameters, content_type=content_type, - cls=lambda x,y,z: x, + cls=lambda x, y, z: x, + headers=_headers, + params=_params, **kwargs ) - kwargs.pop('error_map', None) + kwargs.pop("error_map", None) def get_long_running_output(pipeline_response): - response = pipeline_response.http_response - deserialized = self._deserialize('GenericResource', pipeline_response) + deserialized = self._deserialize("GenericResource", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - - if polling is True: polling_method = AsyncARMPolling(lro_delay, **kwargs) - elif polling is False: polling_method = AsyncNoPolling() - else: polling_method = polling + if polling is True: + polling_method = cast(AsyncPollingMethod, AsyncARMPolling(lro_delay, **kwargs)) # type: AsyncPollingMethod + elif polling is False: + polling_method = cast(AsyncPollingMethod, AsyncNoPolling()) + else: + polling_method = polling if cont_token: return AsyncLROPoller.from_continuation_token( polling_method=polling_method, continuation_token=cont_token, client=self._client, - deserialization_callback=get_long_running_output + deserialization_callback=get_long_running_output, ) return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) - begin_create_or_update.metadata = {'url': "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{parentResourcePath}/{resourceType}/{resourceName}"} # type: ignore + begin_create_or_update.metadata = {"url": "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{parentResourcePath}/{resourceType}/{resourceName}"} # type: ignore async def _update_initial( self, @@ -2497,39 +3203,53 @@ async def _update_initial( resource_type: str, resource_name: str, api_version: str, - parameters: "_models.GenericResource", + parameters: Union[_models.GenericResource, IO], **kwargs: Any - ) -> Optional["_models.GenericResource"]: - cls = kwargs.pop('cls', None) # type: ClsType[Optional["_models.GenericResource"]] + ) -> Optional[_models.GenericResource]: error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = kwargs.pop("params", {}) or {} - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[Optional[_models.GenericResource]] - _json = self._serialize.body(parameters, 'GenericResource') + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(parameters, (IO, bytes)): + _content = parameters + else: + _json = self._serialize.body(parameters, "GenericResource") - request = build_resources_update_request_initial( + request = build_resources_update_request( resource_group_name=resource_group_name, resource_provider_namespace=resource_provider_namespace, parent_resource_path=parent_resource_path, resource_type=resource_type, resource_name=resource_name, subscription_id=self._config.subscription_id, - content_type=content_type, api_version=api_version, + content_type=content_type, json=_json, - template_url=self._update_initial.metadata['url'], + content=_content, + template_url=self._update_initial.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200, 202]: @@ -2538,15 +3258,112 @@ async def _update_initial( deserialized = None if response.status_code == 200: - deserialized = self._deserialize('GenericResource', pipeline_response) + deserialized = self._deserialize("GenericResource", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - _update_initial.metadata = {'url': "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{parentResourcePath}/{resourceType}/{resourceName}"} # type: ignore + _update_initial.metadata = {"url": "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{parentResourcePath}/{resourceType}/{resourceName}"} # type: ignore + @overload + async def begin_update( + self, + resource_group_name: str, + resource_provider_namespace: str, + parent_resource_path: str, + resource_type: str, + resource_name: str, + api_version: str, + parameters: _models.GenericResource, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> AsyncLROPoller[_models.GenericResource]: + """Updates a resource. + + :param resource_group_name: The name of the resource group for the resource. The name is case + insensitive. Required. + :type resource_group_name: str + :param resource_provider_namespace: The namespace of the resource provider. Required. + :type resource_provider_namespace: str + :param parent_resource_path: The parent resource identity. Required. + :type parent_resource_path: str + :param resource_type: The resource type of the resource to update. Required. + :type resource_type: str + :param resource_name: The name of the resource to update. Required. + :type resource_name: str + :param api_version: The API version to use for the operation. Required. + :type api_version: str + :param parameters: Parameters for updating the resource. Required. + :type parameters: ~azure.mgmt.resource.resources.v2019_03_01.models.GenericResource + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be AsyncARMPolling. Pass in False for + this operation to not poll, or pass in your own initialized polling object for a personal + polling strategy. + :paramtype polling: bool or ~azure.core.polling.AsyncPollingMethod + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of AsyncLROPoller that returns either GenericResource or the result of + cls(response) + :rtype: + ~azure.core.polling.AsyncLROPoller[~azure.mgmt.resource.resources.v2019_03_01.models.GenericResource] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + async def begin_update( + self, + resource_group_name: str, + resource_provider_namespace: str, + parent_resource_path: str, + resource_type: str, + resource_name: str, + api_version: str, + parameters: IO, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> AsyncLROPoller[_models.GenericResource]: + """Updates a resource. + + :param resource_group_name: The name of the resource group for the resource. The name is case + insensitive. Required. + :type resource_group_name: str + :param resource_provider_namespace: The namespace of the resource provider. Required. + :type resource_provider_namespace: str + :param parent_resource_path: The parent resource identity. Required. + :type parent_resource_path: str + :param resource_type: The resource type of the resource to update. Required. + :type resource_type: str + :param resource_name: The name of the resource to update. Required. + :type resource_name: str + :param api_version: The API version to use for the operation. Required. + :type api_version: str + :param parameters: Parameters for updating the resource. Required. + :type parameters: IO + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be AsyncARMPolling. Pass in False for + this operation to not poll, or pass in your own initialized polling object for a personal + polling strategy. + :paramtype polling: bool or ~azure.core.polling.AsyncPollingMethod + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of AsyncLROPoller that returns either GenericResource or the result of + cls(response) + :rtype: + ~azure.core.polling.AsyncLROPoller[~azure.mgmt.resource.resources.v2019_03_01.models.GenericResource] + :raises ~azure.core.exceptions.HttpResponseError: + """ @distributed_trace_async async def begin_update( @@ -2557,26 +3374,30 @@ async def begin_update( resource_type: str, resource_name: str, api_version: str, - parameters: "_models.GenericResource", + parameters: Union[_models.GenericResource, IO], **kwargs: Any - ) -> AsyncLROPoller["_models.GenericResource"]: + ) -> AsyncLROPoller[_models.GenericResource]: """Updates a resource. :param resource_group_name: The name of the resource group for the resource. The name is case - insensitive. + insensitive. Required. :type resource_group_name: str - :param resource_provider_namespace: The namespace of the resource provider. + :param resource_provider_namespace: The namespace of the resource provider. Required. :type resource_provider_namespace: str - :param parent_resource_path: The parent resource identity. + :param parent_resource_path: The parent resource identity. Required. :type parent_resource_path: str - :param resource_type: The resource type of the resource to update. + :param resource_type: The resource type of the resource to update. Required. :type resource_type: str - :param resource_name: The name of the resource to update. + :param resource_name: The name of the resource to update. Required. :type resource_name: str - :param api_version: The API version to use for the operation. + :param api_version: The API version to use for the operation. Required. :type api_version: str - :param parameters: Parameters for updating the resource. - :type parameters: ~azure.mgmt.resource.resources.v2019_03_01.models.GenericResource + :param parameters: Parameters for updating the resource. Is either a model type or a IO type. + Required. + :type parameters: ~azure.mgmt.resource.resources.v2019_03_01.models.GenericResource or IO + :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. + Default value is None. + :paramtype content_type: str :keyword callable cls: A custom type or function that will be passed the direct response :keyword str continuation_token: A continuation token to restart a poller from a saved state. :keyword polling: By default, your polling method will be AsyncARMPolling. Pass in False for @@ -2589,18 +3410,18 @@ async def begin_update( cls(response) :rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.resource.resources.v2019_03_01.models.GenericResource] - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] - polling = kwargs.pop('polling', True) # type: Union[bool, AsyncPollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType["_models.GenericResource"] - lro_delay = kwargs.pop( - 'polling_interval', - self._config.polling_interval - ) - cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = kwargs.pop("params", {}) or {} + + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.GenericResource] + polling = kwargs.pop("polling", True) # type: Union[bool, AsyncPollingMethod] + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token = kwargs.pop("continuation_token", None) # type: Optional[str] if cont_token is None: - raw_result = await self._update_initial( + raw_result = await self._update_initial( # type: ignore resource_group_name=resource_group_name, resource_provider_namespace=resource_provider_namespace, parent_resource_path=parent_resource_path, @@ -2609,32 +3430,35 @@ async def begin_update( api_version=api_version, parameters=parameters, content_type=content_type, - cls=lambda x,y,z: x, + cls=lambda x, y, z: x, + headers=_headers, + params=_params, **kwargs ) - kwargs.pop('error_map', None) + kwargs.pop("error_map", None) def get_long_running_output(pipeline_response): - response = pipeline_response.http_response - deserialized = self._deserialize('GenericResource', pipeline_response) + deserialized = self._deserialize("GenericResource", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - - if polling is True: polling_method = AsyncARMPolling(lro_delay, **kwargs) - elif polling is False: polling_method = AsyncNoPolling() - else: polling_method = polling + if polling is True: + polling_method = cast(AsyncPollingMethod, AsyncARMPolling(lro_delay, **kwargs)) # type: AsyncPollingMethod + elif polling is False: + polling_method = cast(AsyncPollingMethod, AsyncNoPolling()) + else: + polling_method = polling if cont_token: return AsyncLROPoller.from_continuation_token( polling_method=polling_method, continuation_token=cont_token, client=self._client, - deserialization_callback=get_long_running_output + deserialization_callback=get_long_running_output, ) return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) - begin_update.metadata = {'url': "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{parentResourcePath}/{resourceType}/{resourceName}"} # type: ignore + begin_update.metadata = {"url": "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{parentResourcePath}/{resourceType}/{resourceName}"} # type: ignore @distributed_trace_async async def get( @@ -2646,34 +3470,40 @@ async def get( resource_name: str, api_version: str, **kwargs: Any - ) -> "_models.GenericResource": + ) -> _models.GenericResource: """Gets a resource. :param resource_group_name: The name of the resource group containing the resource to get. The - name is case insensitive. + name is case insensitive. Required. :type resource_group_name: str - :param resource_provider_namespace: The namespace of the resource provider. + :param resource_provider_namespace: The namespace of the resource provider. Required. :type resource_provider_namespace: str - :param parent_resource_path: The parent resource identity. + :param parent_resource_path: The parent resource identity. Required. :type parent_resource_path: str - :param resource_type: The resource type of the resource. + :param resource_type: The resource type of the resource. Required. :type resource_type: str - :param resource_name: The name of the resource to get. + :param resource_name: The name of the resource to get. Required. :type resource_name: str - :param api_version: The API version to use for the operation. + :param api_version: The API version to use for the operation. Required. :type api_version: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: GenericResource, or the result of cls(response) + :return: GenericResource or the result of cls(response) :rtype: ~azure.mgmt.resource.resources.v2019_03_01.models.GenericResource - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.GenericResource"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = kwargs.pop("params", {}) or {} + + cls = kwargs.pop("cls", None) # type: ClsType[_models.GenericResource] - request = build_resources_get_request( resource_group_name=resource_group_name, resource_provider_namespace=resource_provider_namespace, @@ -2682,72 +3512,75 @@ async def get( resource_name=resource_name, subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.get.metadata['url'], + template_url=self.get.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) - deserialized = self._deserialize('GenericResource', pipeline_response) + deserialized = self._deserialize("GenericResource", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - get.metadata = {'url': "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{parentResourcePath}/{resourceType}/{resourceName}"} # type: ignore - + get.metadata = {"url": "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{parentResourcePath}/{resourceType}/{resourceName}"} # type: ignore @distributed_trace_async - async def check_existence_by_id( - self, - resource_id: str, - api_version: str, - **kwargs: Any - ) -> bool: + async def check_existence_by_id(self, resource_id: str, api_version: str, **kwargs: Any) -> bool: """Checks by ID whether a resource exists. :param resource_id: The fully qualified ID of the resource, including the resource name and resource type. Use the format, /subscriptions/{guid}/resourceGroups/{resource-group-name}/{resource-provider-namespace}/{resource-type}/{resource-name}. + Required. :type resource_id: str - :param api_version: The API version to use for the operation. + :param api_version: The API version to use for the operation. Required. :type api_version: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: bool, or the result of cls(response) + :return: bool or the result of cls(response) :rtype: bool - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType[None] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = kwargs.pop("params", {}) or {} + + cls = kwargs.pop("cls", None) # type: ClsType[None] - request = build_resources_check_existence_by_id_request( resource_id=resource_id, api_version=api_version, - template_url=self.check_existence_by_id.metadata['url'], + template_url=self.check_existence_by_id.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [204, 404]: @@ -2758,35 +3591,38 @@ async def check_existence_by_id( return cls(pipeline_response, None, {}) return 200 <= response.status_code <= 299 - check_existence_by_id.metadata = {'url': "/{resourceId}"} # type: ignore - + check_existence_by_id.metadata = {"url": "/{resourceId}"} # type: ignore async def _delete_by_id_initial( # pylint: disable=inconsistent-return-statements - self, - resource_id: str, - api_version: str, - **kwargs: Any + self, resource_id: str, api_version: str, **kwargs: Any ) -> None: - cls = kwargs.pop('cls', None) # type: ClsType[None] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = kwargs.pop("params", {}) or {} - - request = build_resources_delete_by_id_request_initial( + cls = kwargs.pop("cls", None) # type: ClsType[None] + + request = build_resources_delete_by_id_request( resource_id=resource_id, api_version=api_version, - template_url=self._delete_by_id_initial.metadata['url'], + template_url=self._delete_by_id_initial.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200, 202, 204]: @@ -2796,23 +3632,18 @@ async def _delete_by_id_initial( # pylint: disable=inconsistent-return-statemen if cls: return cls(pipeline_response, None, {}) - _delete_by_id_initial.metadata = {'url': "/{resourceId}"} # type: ignore - + _delete_by_id_initial.metadata = {"url": "/{resourceId}"} # type: ignore @distributed_trace_async - async def begin_delete_by_id( # pylint: disable=inconsistent-return-statements - self, - resource_id: str, - api_version: str, - **kwargs: Any - ) -> AsyncLROPoller[None]: + async def begin_delete_by_id(self, resource_id: str, api_version: str, **kwargs: Any) -> AsyncLROPoller[None]: """Deletes a resource by ID. :param resource_id: The fully qualified ID of the resource, including the resource name and resource type. Use the format, /subscriptions/{guid}/resourceGroups/{resource-group-name}/{resource-provider-namespace}/{resource-type}/{resource-name}. + Required. :type resource_id: str - :param api_version: The API version to use for the operation. + :param api_version: The API version to use for the operation. Required. :type api_version: str :keyword callable cls: A custom type or function that will be passed the direct response :keyword str continuation_token: A continuation token to restart a poller from a saved state. @@ -2824,75 +3655,89 @@ async def begin_delete_by_id( # pylint: disable=inconsistent-return-statements Retry-After header is present. :return: An instance of AsyncLROPoller that returns either None or the result of cls(response) :rtype: ~azure.core.polling.AsyncLROPoller[None] - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - polling = kwargs.pop('polling', True) # type: Union[bool, AsyncPollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType[None] - lro_delay = kwargs.pop( - 'polling_interval', - self._config.polling_interval - ) - cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] + _headers = kwargs.pop("headers", {}) or {} + _params = kwargs.pop("params", {}) or {} + + cls = kwargs.pop("cls", None) # type: ClsType[None] + polling = kwargs.pop("polling", True) # type: Union[bool, AsyncPollingMethod] + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token = kwargs.pop("continuation_token", None) # type: Optional[str] if cont_token is None: - raw_result = await self._delete_by_id_initial( + raw_result = await self._delete_by_id_initial( # type: ignore resource_id=resource_id, api_version=api_version, - cls=lambda x,y,z: x, + cls=lambda x, y, z: x, + headers=_headers, + params=_params, **kwargs ) - kwargs.pop('error_map', None) + kwargs.pop("error_map", None) - def get_long_running_output(pipeline_response): + def get_long_running_output(pipeline_response): # pylint: disable=inconsistent-return-statements if cls: return cls(pipeline_response, None, {}) - - if polling is True: polling_method = AsyncARMPolling(lro_delay, **kwargs) - elif polling is False: polling_method = AsyncNoPolling() - else: polling_method = polling + if polling is True: + polling_method = cast(AsyncPollingMethod, AsyncARMPolling(lro_delay, **kwargs)) # type: AsyncPollingMethod + elif polling is False: + polling_method = cast(AsyncPollingMethod, AsyncNoPolling()) + else: + polling_method = polling if cont_token: return AsyncLROPoller.from_continuation_token( polling_method=polling_method, continuation_token=cont_token, client=self._client, - deserialization_callback=get_long_running_output + deserialization_callback=get_long_running_output, ) return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) - begin_delete_by_id.metadata = {'url': "/{resourceId}"} # type: ignore + begin_delete_by_id.metadata = {"url": "/{resourceId}"} # type: ignore async def _create_or_update_by_id_initial( - self, - resource_id: str, - api_version: str, - parameters: "_models.GenericResource", - **kwargs: Any - ) -> Optional["_models.GenericResource"]: - cls = kwargs.pop('cls', None) # type: ClsType[Optional["_models.GenericResource"]] + self, resource_id: str, api_version: str, parameters: Union[_models.GenericResource, IO], **kwargs: Any + ) -> Optional[_models.GenericResource]: error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = kwargs.pop("params", {}) or {} - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[Optional[_models.GenericResource]] - _json = self._serialize.body(parameters, 'GenericResource') + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(parameters, (IO, bytes)): + _content = parameters + else: + _json = self._serialize.body(parameters, "GenericResource") - request = build_resources_create_or_update_by_id_request_initial( + request = build_resources_create_or_update_by_id_request( resource_id=resource_id, - content_type=content_type, api_version=api_version, + content_type=content_type, json=_json, - template_url=self._create_or_update_by_id_initial.metadata['url'], + content=_content, + template_url=self._create_or_update_by_id_initial.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200, 201, 202]: @@ -2901,37 +3746,42 @@ async def _create_or_update_by_id_initial( deserialized = None if response.status_code == 200: - deserialized = self._deserialize('GenericResource', pipeline_response) + deserialized = self._deserialize("GenericResource", pipeline_response) if response.status_code == 201: - deserialized = self._deserialize('GenericResource', pipeline_response) + deserialized = self._deserialize("GenericResource", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - _create_or_update_by_id_initial.metadata = {'url': "/{resourceId}"} # type: ignore + _create_or_update_by_id_initial.metadata = {"url": "/{resourceId}"} # type: ignore - - @distributed_trace_async + @overload async def begin_create_or_update_by_id( self, resource_id: str, api_version: str, - parameters: "_models.GenericResource", + parameters: _models.GenericResource, + *, + content_type: str = "application/json", **kwargs: Any - ) -> AsyncLROPoller["_models.GenericResource"]: + ) -> AsyncLROPoller[_models.GenericResource]: """Create a resource by ID. :param resource_id: The fully qualified ID of the resource, including the resource name and resource type. Use the format, /subscriptions/{guid}/resourceGroups/{resource-group-name}/{resource-provider-namespace}/{resource-type}/{resource-name}. + Required. :type resource_id: str - :param api_version: The API version to use for the operation. + :param api_version: The API version to use for the operation. Required. :type api_version: str - :param parameters: Create or update resource parameters. + :param parameters: Create or update resource parameters. Required. :type parameters: ~azure.mgmt.resource.resources.v2019_03_01.models.GenericResource + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str :keyword callable cls: A custom type or function that will be passed the direct response :keyword str continuation_token: A continuation token to restart a poller from a saved state. :keyword polling: By default, your polling method will be AsyncARMPolling. Pass in False for @@ -2944,81 +3794,167 @@ async def begin_create_or_update_by_id( cls(response) :rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.resource.resources.v2019_03_01.models.GenericResource] - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] - polling = kwargs.pop('polling', True) # type: Union[bool, AsyncPollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType["_models.GenericResource"] - lro_delay = kwargs.pop( - 'polling_interval', - self._config.polling_interval - ) - cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] + + @overload + async def begin_create_or_update_by_id( + self, + resource_id: str, + api_version: str, + parameters: IO, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> AsyncLROPoller[_models.GenericResource]: + """Create a resource by ID. + + :param resource_id: The fully qualified ID of the resource, including the resource name and + resource type. Use the format, + /subscriptions/{guid}/resourceGroups/{resource-group-name}/{resource-provider-namespace}/{resource-type}/{resource-name}. + Required. + :type resource_id: str + :param api_version: The API version to use for the operation. Required. + :type api_version: str + :param parameters: Create or update resource parameters. Required. + :type parameters: IO + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be AsyncARMPolling. Pass in False for + this operation to not poll, or pass in your own initialized polling object for a personal + polling strategy. + :paramtype polling: bool or ~azure.core.polling.AsyncPollingMethod + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of AsyncLROPoller that returns either GenericResource or the result of + cls(response) + :rtype: + ~azure.core.polling.AsyncLROPoller[~azure.mgmt.resource.resources.v2019_03_01.models.GenericResource] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace_async + async def begin_create_or_update_by_id( + self, resource_id: str, api_version: str, parameters: Union[_models.GenericResource, IO], **kwargs: Any + ) -> AsyncLROPoller[_models.GenericResource]: + """Create a resource by ID. + + :param resource_id: The fully qualified ID of the resource, including the resource name and + resource type. Use the format, + /subscriptions/{guid}/resourceGroups/{resource-group-name}/{resource-provider-namespace}/{resource-type}/{resource-name}. + Required. + :type resource_id: str + :param api_version: The API version to use for the operation. Required. + :type api_version: str + :param parameters: Create or update resource parameters. Is either a model type or a IO type. + Required. + :type parameters: ~azure.mgmt.resource.resources.v2019_03_01.models.GenericResource or IO + :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. + Default value is None. + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be AsyncARMPolling. Pass in False for + this operation to not poll, or pass in your own initialized polling object for a personal + polling strategy. + :paramtype polling: bool or ~azure.core.polling.AsyncPollingMethod + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of AsyncLROPoller that returns either GenericResource or the result of + cls(response) + :rtype: + ~azure.core.polling.AsyncLROPoller[~azure.mgmt.resource.resources.v2019_03_01.models.GenericResource] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = kwargs.pop("params", {}) or {} + + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.GenericResource] + polling = kwargs.pop("polling", True) # type: Union[bool, AsyncPollingMethod] + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token = kwargs.pop("continuation_token", None) # type: Optional[str] if cont_token is None: - raw_result = await self._create_or_update_by_id_initial( + raw_result = await self._create_or_update_by_id_initial( # type: ignore resource_id=resource_id, api_version=api_version, parameters=parameters, content_type=content_type, - cls=lambda x,y,z: x, + cls=lambda x, y, z: x, + headers=_headers, + params=_params, **kwargs ) - kwargs.pop('error_map', None) + kwargs.pop("error_map", None) def get_long_running_output(pipeline_response): - response = pipeline_response.http_response - deserialized = self._deserialize('GenericResource', pipeline_response) + deserialized = self._deserialize("GenericResource", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - - if polling is True: polling_method = AsyncARMPolling(lro_delay, **kwargs) - elif polling is False: polling_method = AsyncNoPolling() - else: polling_method = polling + if polling is True: + polling_method = cast(AsyncPollingMethod, AsyncARMPolling(lro_delay, **kwargs)) # type: AsyncPollingMethod + elif polling is False: + polling_method = cast(AsyncPollingMethod, AsyncNoPolling()) + else: + polling_method = polling if cont_token: return AsyncLROPoller.from_continuation_token( polling_method=polling_method, continuation_token=cont_token, client=self._client, - deserialization_callback=get_long_running_output + deserialization_callback=get_long_running_output, ) return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) - begin_create_or_update_by_id.metadata = {'url': "/{resourceId}"} # type: ignore + begin_create_or_update_by_id.metadata = {"url": "/{resourceId}"} # type: ignore async def _update_by_id_initial( - self, - resource_id: str, - api_version: str, - parameters: "_models.GenericResource", - **kwargs: Any - ) -> Optional["_models.GenericResource"]: - cls = kwargs.pop('cls', None) # type: ClsType[Optional["_models.GenericResource"]] + self, resource_id: str, api_version: str, parameters: Union[_models.GenericResource, IO], **kwargs: Any + ) -> Optional[_models.GenericResource]: error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = kwargs.pop("params", {}) or {} - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[Optional[_models.GenericResource]] - _json = self._serialize.body(parameters, 'GenericResource') + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(parameters, (IO, bytes)): + _content = parameters + else: + _json = self._serialize.body(parameters, "GenericResource") - request = build_resources_update_by_id_request_initial( + request = build_resources_update_by_id_request( resource_id=resource_id, - content_type=content_type, api_version=api_version, + content_type=content_type, json=_json, - template_url=self._update_by_id_initial.metadata['url'], + content=_content, + template_url=self._update_by_id_initial.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200, 202]: @@ -3027,34 +3963,78 @@ async def _update_by_id_initial( deserialized = None if response.status_code == 200: - deserialized = self._deserialize('GenericResource', pipeline_response) + deserialized = self._deserialize("GenericResource", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - _update_by_id_initial.metadata = {'url': "/{resourceId}"} # type: ignore + _update_by_id_initial.metadata = {"url": "/{resourceId}"} # type: ignore + + @overload + async def begin_update_by_id( + self, + resource_id: str, + api_version: str, + parameters: _models.GenericResource, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> AsyncLROPoller[_models.GenericResource]: + """Updates a resource by ID. + :param resource_id: The fully qualified ID of the resource, including the resource name and + resource type. Use the format, + /subscriptions/{guid}/resourceGroups/{resource-group-name}/{resource-provider-namespace}/{resource-type}/{resource-name}. + Required. + :type resource_id: str + :param api_version: The API version to use for the operation. Required. + :type api_version: str + :param parameters: Update resource parameters. Required. + :type parameters: ~azure.mgmt.resource.resources.v2019_03_01.models.GenericResource + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be AsyncARMPolling. Pass in False for + this operation to not poll, or pass in your own initialized polling object for a personal + polling strategy. + :paramtype polling: bool or ~azure.core.polling.AsyncPollingMethod + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of AsyncLROPoller that returns either GenericResource or the result of + cls(response) + :rtype: + ~azure.core.polling.AsyncLROPoller[~azure.mgmt.resource.resources.v2019_03_01.models.GenericResource] + :raises ~azure.core.exceptions.HttpResponseError: + """ - @distributed_trace_async + @overload async def begin_update_by_id( self, resource_id: str, api_version: str, - parameters: "_models.GenericResource", + parameters: IO, + *, + content_type: str = "application/json", **kwargs: Any - ) -> AsyncLROPoller["_models.GenericResource"]: + ) -> AsyncLROPoller[_models.GenericResource]: """Updates a resource by ID. :param resource_id: The fully qualified ID of the resource, including the resource name and resource type. Use the format, /subscriptions/{guid}/resourceGroups/{resource-group-name}/{resource-provider-namespace}/{resource-type}/{resource-name}. + Required. :type resource_id: str - :param api_version: The API version to use for the operation. + :param api_version: The API version to use for the operation. Required. :type api_version: str - :param parameters: Update resource parameters. - :type parameters: ~azure.mgmt.resource.resources.v2019_03_01.models.GenericResource + :param parameters: Update resource parameters. Required. + :type parameters: IO + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: str :keyword callable cls: A custom type or function that will be passed the direct response :keyword str continuation_token: A continuation token to restart a poller from a saved state. :keyword polling: By default, your polling method will be AsyncARMPolling. Pass in False for @@ -3067,165 +4047,204 @@ async def begin_update_by_id( cls(response) :rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.resource.resources.v2019_03_01.models.GenericResource] - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] - polling = kwargs.pop('polling', True) # type: Union[bool, AsyncPollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType["_models.GenericResource"] - lro_delay = kwargs.pop( - 'polling_interval', - self._config.polling_interval - ) - cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] + + @distributed_trace_async + async def begin_update_by_id( + self, resource_id: str, api_version: str, parameters: Union[_models.GenericResource, IO], **kwargs: Any + ) -> AsyncLROPoller[_models.GenericResource]: + """Updates a resource by ID. + + :param resource_id: The fully qualified ID of the resource, including the resource name and + resource type. Use the format, + /subscriptions/{guid}/resourceGroups/{resource-group-name}/{resource-provider-namespace}/{resource-type}/{resource-name}. + Required. + :type resource_id: str + :param api_version: The API version to use for the operation. Required. + :type api_version: str + :param parameters: Update resource parameters. Is either a model type or a IO type. Required. + :type parameters: ~azure.mgmt.resource.resources.v2019_03_01.models.GenericResource or IO + :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. + Default value is None. + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be AsyncARMPolling. Pass in False for + this operation to not poll, or pass in your own initialized polling object for a personal + polling strategy. + :paramtype polling: bool or ~azure.core.polling.AsyncPollingMethod + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of AsyncLROPoller that returns either GenericResource or the result of + cls(response) + :rtype: + ~azure.core.polling.AsyncLROPoller[~azure.mgmt.resource.resources.v2019_03_01.models.GenericResource] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = kwargs.pop("params", {}) or {} + + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.GenericResource] + polling = kwargs.pop("polling", True) # type: Union[bool, AsyncPollingMethod] + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token = kwargs.pop("continuation_token", None) # type: Optional[str] if cont_token is None: - raw_result = await self._update_by_id_initial( + raw_result = await self._update_by_id_initial( # type: ignore resource_id=resource_id, api_version=api_version, parameters=parameters, content_type=content_type, - cls=lambda x,y,z: x, + cls=lambda x, y, z: x, + headers=_headers, + params=_params, **kwargs ) - kwargs.pop('error_map', None) + kwargs.pop("error_map", None) def get_long_running_output(pipeline_response): - response = pipeline_response.http_response - deserialized = self._deserialize('GenericResource', pipeline_response) + deserialized = self._deserialize("GenericResource", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - - if polling is True: polling_method = AsyncARMPolling(lro_delay, **kwargs) - elif polling is False: polling_method = AsyncNoPolling() - else: polling_method = polling + if polling is True: + polling_method = cast(AsyncPollingMethod, AsyncARMPolling(lro_delay, **kwargs)) # type: AsyncPollingMethod + elif polling is False: + polling_method = cast(AsyncPollingMethod, AsyncNoPolling()) + else: + polling_method = polling if cont_token: return AsyncLROPoller.from_continuation_token( polling_method=polling_method, continuation_token=cont_token, client=self._client, - deserialization_callback=get_long_running_output + deserialization_callback=get_long_running_output, ) return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) - begin_update_by_id.metadata = {'url': "/{resourceId}"} # type: ignore + begin_update_by_id.metadata = {"url": "/{resourceId}"} # type: ignore @distributed_trace_async - async def get_by_id( - self, - resource_id: str, - api_version: str, - **kwargs: Any - ) -> "_models.GenericResource": + async def get_by_id(self, resource_id: str, api_version: str, **kwargs: Any) -> _models.GenericResource: """Gets a resource by ID. :param resource_id: The fully qualified ID of the resource, including the resource name and resource type. Use the format, /subscriptions/{guid}/resourceGroups/{resource-group-name}/{resource-provider-namespace}/{resource-type}/{resource-name}. + Required. :type resource_id: str - :param api_version: The API version to use for the operation. + :param api_version: The API version to use for the operation. Required. :type api_version: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: GenericResource, or the result of cls(response) + :return: GenericResource or the result of cls(response) :rtype: ~azure.mgmt.resource.resources.v2019_03_01.models.GenericResource - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.GenericResource"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = kwargs.pop("params", {}) or {} + + cls = kwargs.pop("cls", None) # type: ClsType[_models.GenericResource] - request = build_resources_get_by_id_request( resource_id=resource_id, api_version=api_version, - template_url=self.get_by_id.metadata['url'], + template_url=self.get_by_id.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) - deserialized = self._deserialize('GenericResource', pipeline_response) + deserialized = self._deserialize("GenericResource", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - get_by_id.metadata = {'url': "/{resourceId}"} # type: ignore + get_by_id.metadata = {"url": "/{resourceId}"} # type: ignore -class ResourceGroupsOperations: - """ResourceGroupsOperations async operations. - You should not instantiate this class directly. Instead, you should create a Client instance that - instantiates it for you and attaches it as an attribute. +class ResourceGroupsOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. - :ivar models: Alias to model classes used in this operation group. - :type models: ~azure.mgmt.resource.resources.v2019_03_01.models - :param client: Client for service requests. - :param config: Configuration of service client. - :param serializer: An object model serializer. - :param deserializer: An object model deserializer. + Instead, you should access the following operations through + :class:`~azure.mgmt.resource.resources.v2019_03_01.aio.ResourceManagementClient`'s + :attr:`resource_groups` attribute. """ models = _models - def __init__(self, client, config, serializer, deserializer) -> None: - self._client = client - self._serialize = serializer - self._deserialize = deserializer - self._config = config + def __init__(self, *args, **kwargs) -> None: + input_args = list(args) + self._client = input_args.pop(0) if input_args else kwargs.pop("client") + self._config = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") @distributed_trace_async - async def check_existence( - self, - resource_group_name: str, - **kwargs: Any - ) -> bool: + async def check_existence(self, resource_group_name: str, **kwargs: Any) -> bool: """Checks whether a resource group exists. :param resource_group_name: The name of the resource group to check. The name is case - insensitive. + insensitive. Required. :type resource_group_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: bool, or the result of cls(response) + :return: bool or the result of cls(response) :rtype: bool - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType[None] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) - api_version = kwargs.pop('api_version', "2019-03-01") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2019-03-01")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[None] - request = build_resource_groups_check_existence_request( resource_group_name=resource_group_name, subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.check_existence.metadata['url'], + template_url=self.check_existence.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [204, 404]: @@ -3236,39 +4255,98 @@ async def check_existence( return cls(pipeline_response, None, {}) return 200 <= response.status_code <= 299 - check_existence.metadata = {'url': "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}"} # type: ignore + check_existence.metadata = {"url": "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}"} # type: ignore - - @distributed_trace_async + @overload async def create_or_update( self, resource_group_name: str, - parameters: "_models.ResourceGroup", + parameters: _models.ResourceGroup, + *, + content_type: str = "application/json", **kwargs: Any - ) -> "_models.ResourceGroup": + ) -> _models.ResourceGroup: """Creates or updates a resource group. :param resource_group_name: The name of the resource group to create or update. Can include alphanumeric, underscore, parentheses, hyphen, period (except at end), and Unicode characters - that match the allowed characters. + that match the allowed characters. Required. :type resource_group_name: str - :param parameters: Parameters supplied to the create or update a resource group. + :param parameters: Parameters supplied to the create or update a resource group. Required. :type parameters: ~azure.mgmt.resource.resources.v2019_03_01.models.ResourceGroup + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: ResourceGroup or the result of cls(response) + :rtype: ~azure.mgmt.resource.resources.v2019_03_01.models.ResourceGroup + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + async def create_or_update( + self, resource_group_name: str, parameters: IO, *, content_type: str = "application/json", **kwargs: Any + ) -> _models.ResourceGroup: + """Creates or updates a resource group. + + :param resource_group_name: The name of the resource group to create or update. Can include + alphanumeric, underscore, parentheses, hyphen, period (except at end), and Unicode characters + that match the allowed characters. Required. + :type resource_group_name: str + :param parameters: Parameters supplied to the create or update a resource group. Required. + :type parameters: IO + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: ResourceGroup, or the result of cls(response) + :return: ResourceGroup or the result of cls(response) :rtype: ~azure.mgmt.resource.resources.v2019_03_01.models.ResourceGroup - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace_async + async def create_or_update( + self, resource_group_name: str, parameters: Union[_models.ResourceGroup, IO], **kwargs: Any + ) -> _models.ResourceGroup: + """Creates or updates a resource group. + + :param resource_group_name: The name of the resource group to create or update. Can include + alphanumeric, underscore, parentheses, hyphen, period (except at end), and Unicode characters + that match the allowed characters. Required. + :type resource_group_name: str + :param parameters: Parameters supplied to the create or update a resource group. Is either a + model type or a IO type. Required. + :type parameters: ~azure.mgmt.resource.resources.v2019_03_01.models.ResourceGroup or IO + :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. + Default value is None. + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: ResourceGroup or the result of cls(response) + :rtype: ~azure.mgmt.resource.resources.v2019_03_01.models.ResourceGroup + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.ResourceGroup"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) - api_version = kwargs.pop('api_version', "2019-03-01") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - _json = self._serialize.body(parameters, 'ResourceGroup') + api_version = kwargs.pop("api_version", _params.pop("api-version", "2019-03-01")) # type: str + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.ResourceGroup] + + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(parameters, (IO, bytes)): + _content = parameters + else: + _json = self._serialize.body(parameters, "ResourceGroup") request = build_resource_groups_create_or_update_request( resource_group_name=resource_group_name, @@ -3276,16 +4354,18 @@ async def create_or_update( api_version=api_version, content_type=content_type, json=_json, - template_url=self.create_or_update.metadata['url'], + content=_content, + template_url=self.create_or_update.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200, 201]: @@ -3293,47 +4373,50 @@ async def create_or_update( raise HttpResponseError(response=response, error_format=ARMErrorFormat) if response.status_code == 200: - deserialized = self._deserialize('ResourceGroup', pipeline_response) + deserialized = self._deserialize("ResourceGroup", pipeline_response) if response.status_code == 201: - deserialized = self._deserialize('ResourceGroup', pipeline_response) + deserialized = self._deserialize("ResourceGroup", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - create_or_update.metadata = {'url': "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}"} # type: ignore - + create_or_update.metadata = {"url": "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}"} # type: ignore async def _delete_initial( # pylint: disable=inconsistent-return-statements - self, - resource_group_name: str, - **kwargs: Any + self, resource_group_name: str, **kwargs: Any ) -> None: - cls = kwargs.pop('cls', None) # type: ClsType[None] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) - api_version = kwargs.pop('api_version', "2019-03-01") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - request = build_resource_groups_delete_request_initial( + api_version = kwargs.pop("api_version", _params.pop("api-version", "2019-03-01")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[None] + + request = build_resource_groups_delete_request( resource_group_name=resource_group_name, subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self._delete_initial.metadata['url'], + template_url=self._delete_initial.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200, 202]: @@ -3343,22 +4426,17 @@ async def _delete_initial( # pylint: disable=inconsistent-return-statements if cls: return cls(pipeline_response, None, {}) - _delete_initial.metadata = {'url': "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}"} # type: ignore - + _delete_initial.metadata = {"url": "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}"} # type: ignore @distributed_trace_async - async def begin_delete( # pylint: disable=inconsistent-return-statements - self, - resource_group_name: str, - **kwargs: Any - ) -> AsyncLROPoller[None]: + async def begin_delete(self, resource_group_name: str, **kwargs: Any) -> AsyncLROPoller[None]: """Deletes a resource group. When you delete a resource group, all of its resources are also deleted. Deleting a resource group deletes all of its template deployments and currently stored operations. :param resource_group_name: The name of the resource group to delete. The name is case - insensitive. + insensitive. Required. :type resource_group_name: str :keyword callable cls: A custom type or function that will be passed the direct response :keyword str continuation_token: A continuation token to restart a poller from a saved state. @@ -3370,106 +4448,113 @@ async def begin_delete( # pylint: disable=inconsistent-return-statements Retry-After header is present. :return: An instance of AsyncLROPoller that returns either None or the result of cls(response) :rtype: ~azure.core.polling.AsyncLROPoller[None] - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - api_version = kwargs.pop('api_version', "2019-03-01") # type: str - polling = kwargs.pop('polling', True) # type: Union[bool, AsyncPollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType[None] - lro_delay = kwargs.pop( - 'polling_interval', - self._config.polling_interval - ) - cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2019-03-01")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[None] + polling = kwargs.pop("polling", True) # type: Union[bool, AsyncPollingMethod] + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token = kwargs.pop("continuation_token", None) # type: Optional[str] if cont_token is None: - raw_result = await self._delete_initial( + raw_result = await self._delete_initial( # type: ignore resource_group_name=resource_group_name, api_version=api_version, - cls=lambda x,y,z: x, + cls=lambda x, y, z: x, + headers=_headers, + params=_params, **kwargs ) - kwargs.pop('error_map', None) + kwargs.pop("error_map", None) - def get_long_running_output(pipeline_response): + def get_long_running_output(pipeline_response): # pylint: disable=inconsistent-return-statements if cls: return cls(pipeline_response, None, {}) - - if polling is True: polling_method = AsyncARMPolling(lro_delay, **kwargs) - elif polling is False: polling_method = AsyncNoPolling() - else: polling_method = polling + if polling is True: + polling_method = cast(AsyncPollingMethod, AsyncARMPolling(lro_delay, **kwargs)) # type: AsyncPollingMethod + elif polling is False: + polling_method = cast(AsyncPollingMethod, AsyncNoPolling()) + else: + polling_method = polling if cont_token: return AsyncLROPoller.from_continuation_token( polling_method=polling_method, continuation_token=cont_token, client=self._client, - deserialization_callback=get_long_running_output + deserialization_callback=get_long_running_output, ) return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) - begin_delete.metadata = {'url': "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}"} # type: ignore + begin_delete.metadata = {"url": "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}"} # type: ignore @distributed_trace_async - async def get( - self, - resource_group_name: str, - **kwargs: Any - ) -> "_models.ResourceGroup": + async def get(self, resource_group_name: str, **kwargs: Any) -> _models.ResourceGroup: """Gets a resource group. :param resource_group_name: The name of the resource group to get. The name is case - insensitive. + insensitive. Required. :type resource_group_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: ResourceGroup, or the result of cls(response) + :return: ResourceGroup or the result of cls(response) :rtype: ~azure.mgmt.resource.resources.v2019_03_01.models.ResourceGroup - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.ResourceGroup"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) - api_version = kwargs.pop('api_version', "2019-03-01") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2019-03-01")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[_models.ResourceGroup] - request = build_resource_groups_get_request( resource_group_name=resource_group_name, subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.get.metadata['url'], + template_url=self.get.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) - deserialized = self._deserialize('ResourceGroup', pipeline_response) + deserialized = self._deserialize("ResourceGroup", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - get.metadata = {'url': "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}"} # type: ignore + get.metadata = {"url": "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}"} # type: ignore - - @distributed_trace_async + @overload async def update( self, resource_group_name: str, - parameters: "_models.ResourceGroupPatchable", + parameters: _models.ResourceGroupPatchable, + *, + content_type: str = "application/json", **kwargs: Any - ) -> "_models.ResourceGroup": + ) -> _models.ResourceGroup: """Updates a resource group. Resource groups can be updated through a simple PATCH operation to a group address. The format @@ -3477,25 +4562,90 @@ async def update( the current value is retained. :param resource_group_name: The name of the resource group to update. The name is case - insensitive. + insensitive. Required. :type resource_group_name: str - :param parameters: Parameters supplied to update a resource group. + :param parameters: Parameters supplied to update a resource group. Required. :type parameters: ~azure.mgmt.resource.resources.v2019_03_01.models.ResourceGroupPatchable + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: ResourceGroup or the result of cls(response) + :rtype: ~azure.mgmt.resource.resources.v2019_03_01.models.ResourceGroup + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + async def update( + self, resource_group_name: str, parameters: IO, *, content_type: str = "application/json", **kwargs: Any + ) -> _models.ResourceGroup: + """Updates a resource group. + + Resource groups can be updated through a simple PATCH operation to a group address. The format + of the request is the same as that for creating a resource group. If a field is unspecified, + the current value is retained. + + :param resource_group_name: The name of the resource group to update. The name is case + insensitive. Required. + :type resource_group_name: str + :param parameters: Parameters supplied to update a resource group. Required. + :type parameters: IO + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: ResourceGroup or the result of cls(response) + :rtype: ~azure.mgmt.resource.resources.v2019_03_01.models.ResourceGroup + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace_async + async def update( + self, resource_group_name: str, parameters: Union[_models.ResourceGroupPatchable, IO], **kwargs: Any + ) -> _models.ResourceGroup: + """Updates a resource group. + + Resource groups can be updated through a simple PATCH operation to a group address. The format + of the request is the same as that for creating a resource group. If a field is unspecified, + the current value is retained. + + :param resource_group_name: The name of the resource group to update. The name is case + insensitive. Required. + :type resource_group_name: str + :param parameters: Parameters supplied to update a resource group. Is either a model type or a + IO type. Required. + :type parameters: ~azure.mgmt.resource.resources.v2019_03_01.models.ResourceGroupPatchable or + IO + :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. + Default value is None. + :paramtype content_type: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: ResourceGroup, or the result of cls(response) + :return: ResourceGroup or the result of cls(response) :rtype: ~azure.mgmt.resource.resources.v2019_03_01.models.ResourceGroup - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.ResourceGroup"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) - api_version = kwargs.pop('api_version', "2019-03-01") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - _json = self._serialize.body(parameters, 'ResourceGroupPatchable') + api_version = kwargs.pop("api_version", _params.pop("api-version", "2019-03-01")) # type: str + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.ResourceGroup] + + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(parameters, (IO, bytes)): + _content = parameters + else: + _json = self._serialize.body(parameters, "ResourceGroupPatchable") request = build_resource_groups_update_request( resource_group_name=resource_group_name, @@ -3503,60 +4653,117 @@ async def update( api_version=api_version, content_type=content_type, json=_json, - template_url=self.update.metadata['url'], + content=_content, + template_url=self.update.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) - deserialized = self._deserialize('ResourceGroup', pipeline_response) + deserialized = self._deserialize("ResourceGroup", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - update.metadata = {'url': "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}"} # type: ignore + update.metadata = {"url": "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}"} # type: ignore - - @distributed_trace_async + @overload async def export_template( self, resource_group_name: str, - parameters: "_models.ExportTemplateRequest", + parameters: _models.ExportTemplateRequest, + *, + content_type: str = "application/json", **kwargs: Any - ) -> "_models.ResourceGroupExportResult": + ) -> _models.ResourceGroupExportResult: """Captures the specified resource group as a template. - :param resource_group_name: The name of the resource group to export as a template. + :param resource_group_name: The name of the resource group to export as a template. Required. :type resource_group_name: str - :param parameters: Parameters for exporting the template. + :param parameters: Parameters for exporting the template. Required. :type parameters: ~azure.mgmt.resource.resources.v2019_03_01.models.ExportTemplateRequest + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: ResourceGroupExportResult or the result of cls(response) + :rtype: ~azure.mgmt.resource.resources.v2019_03_01.models.ResourceGroupExportResult + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + async def export_template( + self, resource_group_name: str, parameters: IO, *, content_type: str = "application/json", **kwargs: Any + ) -> _models.ResourceGroupExportResult: + """Captures the specified resource group as a template. + + :param resource_group_name: The name of the resource group to export as a template. Required. + :type resource_group_name: str + :param parameters: Parameters for exporting the template. Required. + :type parameters: IO + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: ResourceGroupExportResult or the result of cls(response) + :rtype: ~azure.mgmt.resource.resources.v2019_03_01.models.ResourceGroupExportResult + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace_async + async def export_template( + self, resource_group_name: str, parameters: Union[_models.ExportTemplateRequest, IO], **kwargs: Any + ) -> _models.ResourceGroupExportResult: + """Captures the specified resource group as a template. + + :param resource_group_name: The name of the resource group to export as a template. Required. + :type resource_group_name: str + :param parameters: Parameters for exporting the template. Is either a model type or a IO type. + Required. + :type parameters: ~azure.mgmt.resource.resources.v2019_03_01.models.ExportTemplateRequest or IO + :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. + Default value is None. + :paramtype content_type: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: ResourceGroupExportResult, or the result of cls(response) + :return: ResourceGroupExportResult or the result of cls(response) :rtype: ~azure.mgmt.resource.resources.v2019_03_01.models.ResourceGroupExportResult - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.ResourceGroupExportResult"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) - api_version = kwargs.pop('api_version', "2019-03-01") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - _json = self._serialize.body(parameters, 'ExportTemplateRequest') + api_version = kwargs.pop("api_version", _params.pop("api-version", "2019-03-01")) # type: str + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.ResourceGroupExportResult] + + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(parameters, (IO, bytes)): + _content = parameters + else: + _json = self._serialize.body(parameters, "ExportTemplateRequest") request = build_resource_groups_export_template_request( resource_group_name=resource_group_name, @@ -3564,39 +4771,37 @@ async def export_template( api_version=api_version, content_type=content_type, json=_json, - template_url=self.export_template.metadata['url'], + content=_content, + template_url=self.export_template.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) - deserialized = self._deserialize('ResourceGroupExportResult', pipeline_response) + deserialized = self._deserialize("ResourceGroupExportResult", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - export_template.metadata = {'url': "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/exportTemplate"} # type: ignore - + export_template.metadata = {"url": "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/exportTemplate"} # type: ignore @distributed_trace def list( - self, - filter: Optional[str] = None, - top: Optional[int] = None, - **kwargs: Any - ) -> AsyncIterable["_models.ResourceGroupListResult"]: + self, filter: Optional[str] = None, top: Optional[int] = None, **kwargs: Any + ) -> AsyncIterable["_models.ResourceGroup"]: """Gets all the resource groups for a subscription. :param filter: The filter to apply on the operation.:code:`
`:code:`
`You can filter by @@ -3607,40 +4812,48 @@ def list( Default value is None. :type top: int :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either ResourceGroupListResult or the result of - cls(response) + :return: An iterator like instance of either ResourceGroup or the result of cls(response) :rtype: - ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.resource.resources.v2019_03_01.models.ResourceGroupListResult] - :raises: ~azure.core.exceptions.HttpResponseError + ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.resource.resources.v2019_03_01.models.ResourceGroup] + :raises ~azure.core.exceptions.HttpResponseError: """ - api_version = kwargs.pop('api_version', "2019-03-01") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2019-03-01")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[_models.ResourceGroupListResult] - cls = kwargs.pop('cls', None) # type: ClsType["_models.ResourceGroupListResult"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) + def prepare_request(next_link=None): if not next_link: - + request = build_resource_groups_list_request( subscription_id=self._config.subscription_id, - api_version=api_version, filter=filter, top=top, - template_url=self.list.metadata['url'], + 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.url = self._client.format_url(request.url) # type: ignore else: - - request = build_resource_groups_list_request( - subscription_id=self._config.subscription_id, - template_url=next_link, - ) + # make call to next link with the client's api-version + _parsed_next_link = urlparse(next_link) + _next_request_params = case_insensitive_dict(parse_qs(_parsed_next_link.query)) + _next_request_params["api-version"] = self._config.api_version + request = HttpRequest("GET", urljoin(next_link, _parsed_next_link.path), params=_next_request_params) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore request.method = "GET" return request @@ -3654,10 +4867,8 @@ async def extract_data(pipeline_response): async def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) response = pipeline_response.http_response @@ -3667,75 +4878,75 @@ async def get_next(next_link=None): return pipeline_response + return AsyncItemPaged(get_next, extract_data) + + list.metadata = {"url": "/subscriptions/{subscriptionId}/resourcegroups"} # type: ignore - return AsyncItemPaged( - get_next, extract_data - ) - list.metadata = {'url': "/subscriptions/{subscriptionId}/resourcegroups"} # type: ignore -class TagsOperations: - """TagsOperations async operations. - You should not instantiate this class directly. Instead, you should create a Client instance that - instantiates it for you and attaches it as an attribute. +class TagsOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. - :ivar models: Alias to model classes used in this operation group. - :type models: ~azure.mgmt.resource.resources.v2019_03_01.models - :param client: Client for service requests. - :param config: Configuration of service client. - :param serializer: An object model serializer. - :param deserializer: An object model deserializer. + Instead, you should access the following operations through + :class:`~azure.mgmt.resource.resources.v2019_03_01.aio.ResourceManagementClient`'s + :attr:`tags` attribute. """ models = _models - def __init__(self, client, config, serializer, deserializer) -> None: - self._client = client - self._serialize = serializer - self._deserialize = deserializer - self._config = config + def __init__(self, *args, **kwargs) -> None: + input_args = list(args) + self._client = input_args.pop(0) if input_args else kwargs.pop("client") + self._config = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") @distributed_trace_async async def delete_value( # pylint: disable=inconsistent-return-statements - self, - tag_name: str, - tag_value: str, - **kwargs: Any + self, tag_name: str, tag_value: str, **kwargs: Any ) -> None: """Deletes a tag value. - :param tag_name: The name of the tag. + :param tag_name: The name of the tag. Required. :type tag_name: str - :param tag_value: The value of the tag to delete. + :param tag_value: The value of the tag to delete. Required. :type tag_value: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: None, or the result of cls(response) + :return: None or the result of cls(response) :rtype: None - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType[None] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) - api_version = kwargs.pop('api_version', "2019-03-01") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2019-03-01")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[None] - request = build_tags_delete_value_request( tag_name=tag_name, tag_value=tag_value, subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.delete_value.metadata['url'], + template_url=self.delete_value.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200, 204]: @@ -3745,51 +4956,51 @@ async def delete_value( # pylint: disable=inconsistent-return-statements if cls: return cls(pipeline_response, None, {}) - delete_value.metadata = {'url': "/subscriptions/{subscriptionId}/tagNames/{tagName}/tagValues/{tagValue}"} # type: ignore - + delete_value.metadata = {"url": "/subscriptions/{subscriptionId}/tagNames/{tagName}/tagValues/{tagValue}"} # type: ignore @distributed_trace_async - async def create_or_update_value( - self, - tag_name: str, - tag_value: str, - **kwargs: Any - ) -> "_models.TagValue": + async def create_or_update_value(self, tag_name: str, tag_value: str, **kwargs: Any) -> _models.TagValue: """Creates a tag value. The name of the tag must already exist. - :param tag_name: The name of the tag. + :param tag_name: The name of the tag. Required. :type tag_name: str - :param tag_value: The value of the tag to create. + :param tag_value: The value of the tag to create. Required. :type tag_value: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: TagValue, or the result of cls(response) + :return: TagValue or the result of cls(response) :rtype: ~azure.mgmt.resource.resources.v2019_03_01.models.TagValue - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.TagValue"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + 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', "2019-03-01") # type: str + api_version = kwargs.pop("api_version", _params.pop("api-version", "2019-03-01")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[_models.TagValue] - request = build_tags_create_or_update_value_request( tag_name=tag_name, tag_value=tag_value, subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.create_or_update_value.metadata['url'], + template_url=self.create_or_update_value.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200, 201]: @@ -3797,61 +5008,62 @@ async def create_or_update_value( raise HttpResponseError(response=response, error_format=ARMErrorFormat) if response.status_code == 200: - deserialized = self._deserialize('TagValue', pipeline_response) + deserialized = self._deserialize("TagValue", pipeline_response) if response.status_code == 201: - deserialized = self._deserialize('TagValue', pipeline_response) + deserialized = self._deserialize("TagValue", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - create_or_update_value.metadata = {'url': "/subscriptions/{subscriptionId}/tagNames/{tagName}/tagValues/{tagValue}"} # type: ignore - + create_or_update_value.metadata = {"url": "/subscriptions/{subscriptionId}/tagNames/{tagName}/tagValues/{tagValue}"} # type: ignore @distributed_trace_async - async def create_or_update( - self, - tag_name: str, - **kwargs: Any - ) -> "_models.TagDetails": + async def create_or_update(self, tag_name: str, **kwargs: Any) -> _models.TagDetails: """Creates a tag in the subscription. The tag name can have a maximum of 512 characters and is case insensitive. Tag names created by Azure have prefixes of microsoft, azure, or windows. You cannot create tags with one of these prefixes. - :param tag_name: The name of the tag to create. + :param tag_name: The name of the tag to create. Required. :type tag_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: TagDetails, or the result of cls(response) + :return: TagDetails or the result of cls(response) :rtype: ~azure.mgmt.resource.resources.v2019_03_01.models.TagDetails - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.TagDetails"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + 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', "2019-03-01") # type: str + api_version = kwargs.pop("api_version", _params.pop("api-version", "2019-03-01")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[_models.TagDetails] - request = build_tags_create_or_update_request( tag_name=tag_name, subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.create_or_update.metadata['url'], + template_url=self.create_or_update.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200, 201]: @@ -3859,59 +5071,60 @@ async def create_or_update( raise HttpResponseError(response=response, error_format=ARMErrorFormat) if response.status_code == 200: - deserialized = self._deserialize('TagDetails', pipeline_response) + deserialized = self._deserialize("TagDetails", pipeline_response) if response.status_code == 201: - deserialized = self._deserialize('TagDetails', pipeline_response) + deserialized = self._deserialize("TagDetails", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - create_or_update.metadata = {'url': "/subscriptions/{subscriptionId}/tagNames/{tagName}"} # type: ignore - + create_or_update.metadata = {"url": "/subscriptions/{subscriptionId}/tagNames/{tagName}"} # type: ignore @distributed_trace_async - async def delete( # pylint: disable=inconsistent-return-statements - self, - tag_name: str, - **kwargs: Any - ) -> None: + async def delete(self, tag_name: str, **kwargs: Any) -> None: # pylint: disable=inconsistent-return-statements """Deletes a tag from the subscription. You must remove all values from a resource tag before you can delete it. - :param tag_name: The name of the tag. + :param tag_name: The name of the tag. Required. :type tag_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: None, or the result of cls(response) + :return: None or the result of cls(response) :rtype: None - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType[None] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + 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', "2019-03-01") # type: str + api_version = kwargs.pop("api_version", _params.pop("api-version", "2019-03-01")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[None] - request = build_tags_delete_request( tag_name=tag_name, subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.delete.metadata['url'], + template_url=self.delete.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200, 204]: @@ -3921,48 +5134,53 @@ async def delete( # pylint: disable=inconsistent-return-statements if cls: return cls(pipeline_response, None, {}) - delete.metadata = {'url': "/subscriptions/{subscriptionId}/tagNames/{tagName}"} # type: ignore - + delete.metadata = {"url": "/subscriptions/{subscriptionId}/tagNames/{tagName}"} # type: ignore @distributed_trace - def list( - self, - **kwargs: Any - ) -> AsyncIterable["_models.TagsListResult"]: + def list(self, **kwargs: Any) -> AsyncIterable["_models.TagDetails"]: """Gets the names and values of all resource tags that are defined in a subscription. :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either TagsListResult or the result of cls(response) + :return: An iterator like instance of either TagDetails or the result of cls(response) :rtype: - ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.resource.resources.v2019_03_01.models.TagsListResult] - :raises: ~azure.core.exceptions.HttpResponseError + ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.resource.resources.v2019_03_01.models.TagDetails] + :raises ~azure.core.exceptions.HttpResponseError: """ - api_version = kwargs.pop('api_version', "2019-03-01") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2019-03-01")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[_models.TagsListResult] - cls = kwargs.pop('cls', None) # type: ClsType["_models.TagsListResult"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) + def prepare_request(next_link=None): if not next_link: - + request = build_tags_list_request( subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.list.metadata['url'], + template_url=self.list.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore else: - - request = build_tags_list_request( - subscription_id=self._config.subscription_id, - template_url=next_link, - ) + # make call to next link with the client's api-version + _parsed_next_link = urlparse(next_link) + _next_request_params = case_insensitive_dict(parse_qs(_parsed_next_link.query)) + _next_request_params["api-version"] = self._config.api_version + request = HttpRequest("GET", urljoin(next_link, _parsed_next_link.path), params=_next_request_params) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore request.method = "GET" return request @@ -3976,10 +5194,8 @@ async def extract_data(pipeline_response): async def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) response = pipeline_response.http_response @@ -3989,140 +5205,143 @@ async def get_next(next_link=None): return pipeline_response + return AsyncItemPaged(get_next, extract_data) - return AsyncItemPaged( - get_next, extract_data - ) - list.metadata = {'url': "/subscriptions/{subscriptionId}/tagNames"} # type: ignore -class DeploymentOperationsOperations: - """DeploymentOperationsOperations async operations. + list.metadata = {"url": "/subscriptions/{subscriptionId}/tagNames"} # type: ignore - You should not instantiate this class directly. Instead, you should create a Client instance that - instantiates it for you and attaches it as an attribute. - :ivar models: Alias to model classes used in this operation group. - :type models: ~azure.mgmt.resource.resources.v2019_03_01.models - :param client: Client for service requests. - :param config: Configuration of service client. - :param serializer: An object model serializer. - :param deserializer: An object model deserializer. +class DeploymentOperationsOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. + + Instead, you should access the following operations through + :class:`~azure.mgmt.resource.resources.v2019_03_01.aio.ResourceManagementClient`'s + :attr:`deployment_operations` attribute. """ models = _models - def __init__(self, client, config, serializer, deserializer) -> None: - self._client = client - self._serialize = serializer - self._deserialize = deserializer - self._config = config + def __init__(self, *args, **kwargs) -> None: + input_args = list(args) + self._client = input_args.pop(0) if input_args else kwargs.pop("client") + self._config = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") @distributed_trace_async async def get_at_subscription_scope( - self, - deployment_name: str, - operation_id: str, - **kwargs: Any - ) -> "_models.DeploymentOperation": + self, deployment_name: str, operation_id: str, **kwargs: Any + ) -> _models.DeploymentOperation: """Gets a deployments operation. - :param deployment_name: The name of the deployment. + :param deployment_name: The name of the deployment. Required. :type deployment_name: str - :param operation_id: The ID of the operation to get. + :param operation_id: The ID of the operation to get. Required. :type operation_id: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: DeploymentOperation, or the result of cls(response) + :return: DeploymentOperation or the result of cls(response) :rtype: ~azure.mgmt.resource.resources.v2019_03_01.models.DeploymentOperation - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.DeploymentOperation"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) - api_version = kwargs.pop('api_version', "2019-03-01") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2019-03-01")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[_models.DeploymentOperation] - request = build_deployment_operations_get_at_subscription_scope_request( deployment_name=deployment_name, operation_id=operation_id, subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.get_at_subscription_scope.metadata['url'], + template_url=self.get_at_subscription_scope.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) - deserialized = self._deserialize('DeploymentOperation', pipeline_response) + deserialized = self._deserialize("DeploymentOperation", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - get_at_subscription_scope.metadata = {'url': "/subscriptions/{subscriptionId}/providers/Microsoft.Resources/deployments/{deploymentName}/operations/{operationId}"} # type: ignore - + get_at_subscription_scope.metadata = {"url": "/subscriptions/{subscriptionId}/providers/Microsoft.Resources/deployments/{deploymentName}/operations/{operationId}"} # type: ignore @distributed_trace def list_at_subscription_scope( - self, - deployment_name: str, - top: Optional[int] = None, - **kwargs: Any - ) -> AsyncIterable["_models.DeploymentOperationsListResult"]: + self, deployment_name: str, top: Optional[int] = None, **kwargs: Any + ) -> AsyncIterable["_models.DeploymentOperation"]: """Gets all deployments operations for a deployment. - :param deployment_name: The name of the deployment with the operation to get. + :param deployment_name: The name of the deployment with the operation to get. Required. :type deployment_name: str :param top: The number of results to return. Default value is None. :type top: int :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either DeploymentOperationsListResult or the result of - cls(response) + :return: An iterator like instance of either DeploymentOperation or the result of cls(response) :rtype: - ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.resource.resources.v2019_03_01.models.DeploymentOperationsListResult] - :raises: ~azure.core.exceptions.HttpResponseError + ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.resource.resources.v2019_03_01.models.DeploymentOperation] + :raises ~azure.core.exceptions.HttpResponseError: """ - api_version = kwargs.pop('api_version', "2019-03-01") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2019-03-01")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[_models.DeploymentOperationsListResult] - cls = kwargs.pop('cls', None) # type: ClsType["_models.DeploymentOperationsListResult"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) + def prepare_request(next_link=None): if not next_link: - + request = build_deployment_operations_list_at_subscription_scope_request( deployment_name=deployment_name, subscription_id=self._config.subscription_id, - api_version=api_version, top=top, - template_url=self.list_at_subscription_scope.metadata['url'], + api_version=api_version, + template_url=self.list_at_subscription_scope.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore else: - - request = build_deployment_operations_list_at_subscription_scope_request( - deployment_name=deployment_name, - subscription_id=self._config.subscription_id, - template_url=next_link, - ) + # make call to next link with the client's api-version + _parsed_next_link = urlparse(next_link) + _next_request_params = case_insensitive_dict(parse_qs(_parsed_next_link.query)) + _next_request_params["api-version"] = self._config.api_version + request = HttpRequest("GET", urljoin(next_link, _parsed_next_link.path), params=_next_request_params) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore request.method = "GET" return request @@ -4136,10 +5355,8 @@ async def extract_data(pipeline_response): async def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) response = pipeline_response.http_response @@ -4149,128 +5366,131 @@ async def get_next(next_link=None): return pipeline_response + return AsyncItemPaged(get_next, extract_data) - return AsyncItemPaged( - get_next, extract_data - ) - list_at_subscription_scope.metadata = {'url': "/subscriptions/{subscriptionId}/providers/Microsoft.Resources/deployments/{deploymentName}/operations"} # type: ignore + list_at_subscription_scope.metadata = {"url": "/subscriptions/{subscriptionId}/providers/Microsoft.Resources/deployments/{deploymentName}/operations"} # type: ignore @distributed_trace_async async def get( - self, - resource_group_name: str, - deployment_name: str, - operation_id: str, - **kwargs: Any - ) -> "_models.DeploymentOperation": + self, resource_group_name: str, deployment_name: str, operation_id: str, **kwargs: Any + ) -> _models.DeploymentOperation: """Gets a deployments operation. :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. :type resource_group_name: str - :param deployment_name: The name of the deployment. + :param deployment_name: The name of the deployment. Required. :type deployment_name: str - :param operation_id: The ID of the operation to get. + :param operation_id: The ID of the operation to get. Required. :type operation_id: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: DeploymentOperation, or the result of cls(response) + :return: DeploymentOperation or the result of cls(response) :rtype: ~azure.mgmt.resource.resources.v2019_03_01.models.DeploymentOperation - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.DeploymentOperation"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + 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', "2019-03-01") # type: str + api_version = kwargs.pop("api_version", _params.pop("api-version", "2019-03-01")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[_models.DeploymentOperation] - request = build_deployment_operations_get_request( resource_group_name=resource_group_name, deployment_name=deployment_name, operation_id=operation_id, subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.get.metadata['url'], + template_url=self.get.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) - deserialized = self._deserialize('DeploymentOperation', pipeline_response) + deserialized = self._deserialize("DeploymentOperation", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - get.metadata = {'url': "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/deployments/{deploymentName}/operations/{operationId}"} # type: ignore - + get.metadata = {"url": "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/deployments/{deploymentName}/operations/{operationId}"} # type: ignore @distributed_trace def list( - self, - resource_group_name: str, - deployment_name: str, - top: Optional[int] = None, - **kwargs: Any - ) -> AsyncIterable["_models.DeploymentOperationsListResult"]: + self, resource_group_name: str, deployment_name: str, top: Optional[int] = None, **kwargs: Any + ) -> AsyncIterable["_models.DeploymentOperation"]: """Gets all deployments operations for a deployment. :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. :type resource_group_name: str - :param deployment_name: The name of the deployment with the operation to get. + :param deployment_name: The name of the deployment with the operation to get. Required. :type deployment_name: str :param top: The number of results to return. Default value is None. :type top: int :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either DeploymentOperationsListResult or the result of - cls(response) + :return: An iterator like instance of either DeploymentOperation or the result of cls(response) :rtype: - ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.resource.resources.v2019_03_01.models.DeploymentOperationsListResult] - :raises: ~azure.core.exceptions.HttpResponseError + ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.resource.resources.v2019_03_01.models.DeploymentOperation] + :raises ~azure.core.exceptions.HttpResponseError: """ - api_version = kwargs.pop('api_version', "2019-03-01") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2019-03-01")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[_models.DeploymentOperationsListResult] - cls = kwargs.pop('cls', None) # type: ClsType["_models.DeploymentOperationsListResult"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) + def prepare_request(next_link=None): if not next_link: - + request = build_deployment_operations_list_request( resource_group_name=resource_group_name, deployment_name=deployment_name, subscription_id=self._config.subscription_id, - api_version=api_version, top=top, - template_url=self.list.metadata['url'], + 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.url = self._client.format_url(request.url) # type: ignore else: - - request = build_deployment_operations_list_request( - resource_group_name=resource_group_name, - deployment_name=deployment_name, - subscription_id=self._config.subscription_id, - template_url=next_link, - ) + # make call to next link with the client's api-version + _parsed_next_link = urlparse(next_link) + _next_request_params = case_insensitive_dict(parse_qs(_parsed_next_link.query)) + _next_request_params["api-version"] = self._config.api_version + request = HttpRequest("GET", urljoin(next_link, _parsed_next_link.path), params=_next_request_params) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore request.method = "GET" return request @@ -4284,10 +5504,8 @@ async def extract_data(pipeline_response): async def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) response = pipeline_response.http_response @@ -4297,8 +5515,6 @@ async def get_next(next_link=None): return pipeline_response + return AsyncItemPaged(get_next, extract_data) - return AsyncItemPaged( - get_next, extract_data - ) - list.metadata = {'url': "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/deployments/{deploymentName}/operations"} # type: ignore + list.metadata = {"url": "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/deployments/{deploymentName}/operations"} # type: ignore diff --git a/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/resources/v2019_03_01/aio/operations/_patch.py b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/resources/v2019_03_01/aio/operations/_patch.py new file mode 100644 index 0000000000000..f7dd32510333d --- /dev/null +++ b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/resources/v2019_03_01/aio/operations/_patch.py @@ -0,0 +1,20 @@ +# ------------------------------------ +# Copyright (c) Microsoft Corporation. +# Licensed under the MIT License. +# ------------------------------------ +"""Customize generated code here. + +Follow our quickstart for examples: https://aka.ms/azsdk/python/dpcodegen/python/customize +""" +from typing import List + +__all__: List[str] = [] # Add all objects you want publicly available to users at this package level + + +def patch_sdk(): + """Do not remove from this file. + + `patch_sdk` is a last resort escape hatch that allows you to do customizations + you can't accomplish using the techniques described in + https://aka.ms/azsdk/python/dpcodegen/python/customize + """ diff --git a/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/resources/v2019_03_01/models/__init__.py b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/resources/v2019_03_01/models/__init__.py index ce87b190b8862..39249f144291f 100644 --- a/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/resources/v2019_03_01/models/__init__.py +++ b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/resources/v2019_03_01/models/__init__.py @@ -63,71 +63,73 @@ from ._models_py3 import TemplateLink from ._models_py3 import ZoneMapping - -from ._resource_management_client_enums import ( - DeploymentMode, - OnErrorDeploymentType, - ResourceIdentityType, -) +from ._resource_management_client_enums import DeploymentMode +from ._resource_management_client_enums import OnErrorDeploymentType +from ._resource_management_client_enums import ResourceIdentityType +from ._patch import __all__ as _patch_all +from ._patch import * # type: ignore # pylint: disable=unused-wildcard-import +from ._patch import patch_sdk as _patch_sdk __all__ = [ - 'AliasPathType', - 'AliasType', - 'BasicDependency', - 'ComponentsSgqdofSchemasIdentityPropertiesUserassignedidentitiesAdditionalproperties', - 'DebugSetting', - 'Dependency', - 'Deployment', - 'DeploymentExportResult', - 'DeploymentExtended', - 'DeploymentExtendedFilter', - 'DeploymentListResult', - 'DeploymentOperation', - 'DeploymentOperationProperties', - 'DeploymentOperationsListResult', - 'DeploymentProperties', - 'DeploymentPropertiesExtended', - 'DeploymentValidateResult', - 'ErrorAdditionalInfo', - 'ErrorResponse', - 'ExportTemplateRequest', - 'GenericResource', - 'GenericResourceExpanded', - 'GenericResourceFilter', - 'HttpMessage', - 'Identity', - 'OnErrorDeployment', - 'OnErrorDeploymentExtended', - 'Operation', - 'OperationDisplay', - 'OperationListResult', - 'ParametersLink', - 'Plan', - 'Provider', - 'ProviderListResult', - 'ProviderResourceType', - 'Resource', - 'ResourceGroup', - 'ResourceGroupExportResult', - 'ResourceGroupFilter', - 'ResourceGroupListResult', - 'ResourceGroupPatchable', - 'ResourceGroupProperties', - 'ResourceListResult', - 'ResourceManagementErrorWithDetails', - 'ResourceProviderOperationDisplayProperties', - 'ResourcesMoveInfo', - 'Sku', - 'SubResource', - 'TagCount', - 'TagDetails', - 'TagValue', - 'TagsListResult', - 'TargetResource', - 'TemplateHashResult', - 'TemplateLink', - 'ZoneMapping', - 'DeploymentMode', - 'OnErrorDeploymentType', - 'ResourceIdentityType', + "AliasPathType", + "AliasType", + "BasicDependency", + "ComponentsSgqdofSchemasIdentityPropertiesUserassignedidentitiesAdditionalproperties", + "DebugSetting", + "Dependency", + "Deployment", + "DeploymentExportResult", + "DeploymentExtended", + "DeploymentExtendedFilter", + "DeploymentListResult", + "DeploymentOperation", + "DeploymentOperationProperties", + "DeploymentOperationsListResult", + "DeploymentProperties", + "DeploymentPropertiesExtended", + "DeploymentValidateResult", + "ErrorAdditionalInfo", + "ErrorResponse", + "ExportTemplateRequest", + "GenericResource", + "GenericResourceExpanded", + "GenericResourceFilter", + "HttpMessage", + "Identity", + "OnErrorDeployment", + "OnErrorDeploymentExtended", + "Operation", + "OperationDisplay", + "OperationListResult", + "ParametersLink", + "Plan", + "Provider", + "ProviderListResult", + "ProviderResourceType", + "Resource", + "ResourceGroup", + "ResourceGroupExportResult", + "ResourceGroupFilter", + "ResourceGroupListResult", + "ResourceGroupPatchable", + "ResourceGroupProperties", + "ResourceListResult", + "ResourceManagementErrorWithDetails", + "ResourceProviderOperationDisplayProperties", + "ResourcesMoveInfo", + "Sku", + "SubResource", + "TagCount", + "TagDetails", + "TagValue", + "TagsListResult", + "TargetResource", + "TemplateHashResult", + "TemplateLink", + "ZoneMapping", + "DeploymentMode", + "OnErrorDeploymentType", + "ResourceIdentityType", ] +__all__.extend([p for p in _patch_all if p not in __all__]) +_patch_sdk() diff --git a/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/resources/v2019_03_01/models/_models_py3.py b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/resources/v2019_03_01/models/_models_py3.py index 62f94c4492107..c2bb4fd2d1a1c 100644 --- a/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/resources/v2019_03_01/models/_models_py3.py +++ b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/resources/v2019_03_01/models/_models_py3.py @@ -1,4 +1,5 @@ # coding=utf-8 +# pylint: disable=too-many-lines # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. # Licensed under the MIT License. See License.txt in the project root for license information. @@ -6,14 +7,22 @@ # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -from typing import Any, Dict, List, Optional, Union +import sys +from typing import Any, Dict, List, Optional, TYPE_CHECKING, Union -import msrest.serialization +from ... import _serialization -from ._resource_management_client_enums import * +if TYPE_CHECKING: + # pylint: disable=unused-import,ungrouped-imports + from .. import models as _models +if sys.version_info >= (3, 9): + from collections.abc import MutableMapping +else: + from typing import MutableMapping # type: ignore # pylint: disable=ungrouped-imports +JSON = MutableMapping[str, Any] # pylint: disable=unsubscriptable-object -class AliasPathType(msrest.serialization.Model): +class AliasPathType(_serialization.Model): """The type of the paths for alias. :ivar path: The path of an alias. @@ -23,29 +32,23 @@ class AliasPathType(msrest.serialization.Model): """ _attribute_map = { - 'path': {'key': 'path', 'type': 'str'}, - 'api_versions': {'key': 'apiVersions', 'type': '[str]'}, + "path": {"key": "path", "type": "str"}, + "api_versions": {"key": "apiVersions", "type": "[str]"}, } - def __init__( - self, - *, - path: Optional[str] = None, - api_versions: Optional[List[str]] = None, - **kwargs - ): + def __init__(self, *, path: Optional[str] = None, api_versions: Optional[List[str]] = None, **kwargs): """ :keyword path: The path of an alias. :paramtype path: str :keyword api_versions: The API versions. :paramtype api_versions: list[str] """ - super(AliasPathType, self).__init__(**kwargs) + super().__init__(**kwargs) self.path = path self.api_versions = api_versions -class AliasType(msrest.serialization.Model): +class AliasType(_serialization.Model): """The alias type. :ivar name: The alias name. @@ -55,29 +58,23 @@ class AliasType(msrest.serialization.Model): """ _attribute_map = { - 'name': {'key': 'name', 'type': 'str'}, - 'paths': {'key': 'paths', 'type': '[AliasPathType]'}, + "name": {"key": "name", "type": "str"}, + "paths": {"key": "paths", "type": "[AliasPathType]"}, } - def __init__( - self, - *, - name: Optional[str] = None, - paths: Optional[List["AliasPathType"]] = None, - **kwargs - ): + def __init__(self, *, name: Optional[str] = None, paths: Optional[List["_models.AliasPathType"]] = None, **kwargs): """ :keyword name: The alias name. :paramtype name: str :keyword paths: The paths for an alias. :paramtype paths: list[~azure.mgmt.resource.resources.v2019_03_01.models.AliasPathType] """ - super(AliasType, self).__init__(**kwargs) + super().__init__(**kwargs) self.name = name self.paths = paths -class BasicDependency(msrest.serialization.Model): +class BasicDependency(_serialization.Model): """Deployment dependency information. :ivar id: The ID of the dependency. @@ -89,15 +86,15 @@ class BasicDependency(msrest.serialization.Model): """ _attribute_map = { - 'id': {'key': 'id', 'type': 'str'}, - 'resource_type': {'key': 'resourceType', 'type': 'str'}, - 'resource_name': {'key': 'resourceName', 'type': 'str'}, + "id": {"key": "id", "type": "str"}, + "resource_type": {"key": "resourceType", "type": "str"}, + "resource_name": {"key": "resourceName", "type": "str"}, } def __init__( self, *, - id: Optional[str] = None, + id: Optional[str] = None, # pylint: disable=redefined-builtin resource_type: Optional[str] = None, resource_name: Optional[str] = None, **kwargs @@ -110,13 +107,13 @@ def __init__( :keyword resource_name: The dependency resource name. :paramtype resource_name: str """ - super(BasicDependency, self).__init__(**kwargs) + super().__init__(**kwargs) self.id = id self.resource_type = resource_type self.resource_name = resource_name -class ComponentsSgqdofSchemasIdentityPropertiesUserassignedidentitiesAdditionalproperties(msrest.serialization.Model): +class ComponentsSgqdofSchemasIdentityPropertiesUserassignedidentitiesAdditionalproperties(_serialization.Model): """ComponentsSgqdofSchemasIdentityPropertiesUserassignedidentitiesAdditionalproperties. Variables are only populated by the server, and will be ignored when sending a request. @@ -128,27 +125,23 @@ class ComponentsSgqdofSchemasIdentityPropertiesUserassignedidentitiesAdditionalp """ _validation = { - 'principal_id': {'readonly': True}, - 'client_id': {'readonly': True}, + "principal_id": {"readonly": True}, + "client_id": {"readonly": True}, } _attribute_map = { - 'principal_id': {'key': 'principalId', 'type': 'str'}, - 'client_id': {'key': 'clientId', 'type': 'str'}, + "principal_id": {"key": "principalId", "type": "str"}, + "client_id": {"key": "clientId", "type": "str"}, } - def __init__( - self, - **kwargs - ): - """ - """ - super(ComponentsSgqdofSchemasIdentityPropertiesUserassignedidentitiesAdditionalproperties, self).__init__(**kwargs) + def __init__(self, **kwargs): + """ """ + super().__init__(**kwargs) self.principal_id = None self.client_id = None -class DebugSetting(msrest.serialization.Model): +class DebugSetting(_serialization.Model): """DebugSetting. :ivar detail_level: Specifies the type of information to log for debugging. The permitted @@ -161,15 +154,10 @@ class DebugSetting(msrest.serialization.Model): """ _attribute_map = { - 'detail_level': {'key': 'detailLevel', 'type': 'str'}, + "detail_level": {"key": "detailLevel", "type": "str"}, } - def __init__( - self, - *, - detail_level: Optional[str] = None, - **kwargs - ): + def __init__(self, *, detail_level: Optional[str] = None, **kwargs): """ :keyword detail_level: Specifies the type of information to log for debugging. The permitted values are none, requestContent, responseContent, or both requestContent and responseContent @@ -179,11 +167,11 @@ def __init__( deployment operations. :paramtype detail_level: str """ - super(DebugSetting, self).__init__(**kwargs) + super().__init__(**kwargs) self.detail_level = detail_level -class Dependency(msrest.serialization.Model): +class Dependency(_serialization.Model): """Deployment dependency information. :ivar depends_on: The list of dependencies. @@ -197,17 +185,17 @@ class Dependency(msrest.serialization.Model): """ _attribute_map = { - 'depends_on': {'key': 'dependsOn', 'type': '[BasicDependency]'}, - 'id': {'key': 'id', 'type': 'str'}, - 'resource_type': {'key': 'resourceType', 'type': 'str'}, - 'resource_name': {'key': 'resourceName', 'type': 'str'}, + "depends_on": {"key": "dependsOn", "type": "[BasicDependency]"}, + "id": {"key": "id", "type": "str"}, + "resource_type": {"key": "resourceType", "type": "str"}, + "resource_name": {"key": "resourceName", "type": "str"}, } def __init__( self, *, - depends_on: Optional[List["BasicDependency"]] = None, - id: Optional[str] = None, + depends_on: Optional[List["_models.BasicDependency"]] = None, + id: Optional[str] = None, # pylint: disable=redefined-builtin resource_type: Optional[str] = None, resource_name: Optional[str] = None, **kwargs @@ -222,77 +210,66 @@ def __init__( :keyword resource_name: The dependency resource name. :paramtype resource_name: str """ - super(Dependency, self).__init__(**kwargs) + super().__init__(**kwargs) self.depends_on = depends_on self.id = id self.resource_type = resource_type self.resource_name = resource_name -class Deployment(msrest.serialization.Model): +class Deployment(_serialization.Model): """Deployment operation parameters. All required parameters must be populated in order to send to Azure. :ivar location: The location to store the deployment data. :vartype location: str - :ivar properties: Required. The deployment properties. + :ivar properties: The deployment properties. Required. :vartype properties: ~azure.mgmt.resource.resources.v2019_03_01.models.DeploymentProperties """ _validation = { - 'properties': {'required': True}, + "properties": {"required": True}, } _attribute_map = { - 'location': {'key': 'location', 'type': 'str'}, - 'properties': {'key': 'properties', 'type': 'DeploymentProperties'}, + "location": {"key": "location", "type": "str"}, + "properties": {"key": "properties", "type": "DeploymentProperties"}, } - def __init__( - self, - *, - properties: "DeploymentProperties", - location: Optional[str] = None, - **kwargs - ): + def __init__(self, *, properties: "_models.DeploymentProperties", location: Optional[str] = None, **kwargs): """ :keyword location: The location to store the deployment data. :paramtype location: str - :keyword properties: Required. The deployment properties. + :keyword properties: The deployment properties. Required. :paramtype properties: ~azure.mgmt.resource.resources.v2019_03_01.models.DeploymentProperties """ - super(Deployment, self).__init__(**kwargs) + super().__init__(**kwargs) self.location = location self.properties = properties -class DeploymentExportResult(msrest.serialization.Model): +class DeploymentExportResult(_serialization.Model): """The deployment export result. :ivar template: The template content. - :vartype template: any + :vartype template: JSON """ _attribute_map = { - 'template': {'key': 'template', 'type': 'object'}, + "template": {"key": "template", "type": "object"}, } - def __init__( - self, - *, - template: Optional[Any] = None, - **kwargs - ): + def __init__(self, *, template: Optional[JSON] = None, **kwargs): """ :keyword template: The template content. - :paramtype template: any + :paramtype template: JSON """ - super(DeploymentExportResult, self).__init__(**kwargs) + super().__init__(**kwargs) self.template = template -class DeploymentExtended(msrest.serialization.Model): +class DeploymentExtended(_serialization.Model): """Deployment information. Variables are only populated by the server, and will be ignored when sending a request. @@ -311,24 +288,24 @@ class DeploymentExtended(msrest.serialization.Model): """ _validation = { - 'id': {'readonly': True}, - 'name': {'readonly': True}, - 'type': {'readonly': True}, + "id": {"readonly": True}, + "name": {"readonly": True}, + "type": {"readonly": True}, } _attribute_map = { - 'id': {'key': 'id', 'type': 'str'}, - 'name': {'key': 'name', 'type': 'str'}, - 'type': {'key': 'type', 'type': 'str'}, - 'location': {'key': 'location', 'type': 'str'}, - 'properties': {'key': 'properties', 'type': 'DeploymentPropertiesExtended'}, + "id": {"key": "id", "type": "str"}, + "name": {"key": "name", "type": "str"}, + "type": {"key": "type", "type": "str"}, + "location": {"key": "location", "type": "str"}, + "properties": {"key": "properties", "type": "DeploymentPropertiesExtended"}, } def __init__( self, *, location: Optional[str] = None, - properties: Optional["DeploymentPropertiesExtended"] = None, + properties: Optional["_models.DeploymentPropertiesExtended"] = None, **kwargs ): """ @@ -338,7 +315,7 @@ def __init__( :paramtype properties: ~azure.mgmt.resource.resources.v2019_03_01.models.DeploymentPropertiesExtended """ - super(DeploymentExtended, self).__init__(**kwargs) + super().__init__(**kwargs) self.id = None self.name = None self.type = None @@ -346,7 +323,7 @@ def __init__( self.properties = properties -class DeploymentExtendedFilter(msrest.serialization.Model): +class DeploymentExtendedFilter(_serialization.Model): """Deployment filter. :ivar provisioning_state: The provisioning state. @@ -354,24 +331,19 @@ class DeploymentExtendedFilter(msrest.serialization.Model): """ _attribute_map = { - 'provisioning_state': {'key': 'provisioningState', 'type': 'str'}, + "provisioning_state": {"key": "provisioningState", "type": "str"}, } - def __init__( - self, - *, - provisioning_state: Optional[str] = None, - **kwargs - ): + def __init__(self, *, provisioning_state: Optional[str] = None, **kwargs): """ :keyword provisioning_state: The provisioning state. :paramtype provisioning_state: str """ - super(DeploymentExtendedFilter, self).__init__(**kwargs) + super().__init__(**kwargs) self.provisioning_state = provisioning_state -class DeploymentListResult(msrest.serialization.Model): +class DeploymentListResult(_serialization.Model): """List of deployments. Variables are only populated by the server, and will be ignored when sending a request. @@ -383,30 +355,25 @@ class DeploymentListResult(msrest.serialization.Model): """ _validation = { - 'next_link': {'readonly': True}, + "next_link": {"readonly": True}, } _attribute_map = { - 'value': {'key': 'value', 'type': '[DeploymentExtended]'}, - 'next_link': {'key': 'nextLink', 'type': 'str'}, + "value": {"key": "value", "type": "[DeploymentExtended]"}, + "next_link": {"key": "nextLink", "type": "str"}, } - def __init__( - self, - *, - value: Optional[List["DeploymentExtended"]] = None, - **kwargs - ): + def __init__(self, *, value: Optional[List["_models.DeploymentExtended"]] = None, **kwargs): """ :keyword value: An array of deployments. :paramtype value: list[~azure.mgmt.resource.resources.v2019_03_01.models.DeploymentExtended] """ - super(DeploymentListResult, self).__init__(**kwargs) + super().__init__(**kwargs) self.value = value self.next_link = None -class DeploymentOperation(msrest.serialization.Model): +class DeploymentOperation(_serialization.Model): """Deployment operation information. Variables are only populated by the server, and will be ignored when sending a request. @@ -421,34 +388,29 @@ class DeploymentOperation(msrest.serialization.Model): """ _validation = { - 'id': {'readonly': True}, - 'operation_id': {'readonly': True}, + "id": {"readonly": True}, + "operation_id": {"readonly": True}, } _attribute_map = { - 'id': {'key': 'id', 'type': 'str'}, - 'operation_id': {'key': 'operationId', 'type': 'str'}, - 'properties': {'key': 'properties', 'type': 'DeploymentOperationProperties'}, + "id": {"key": "id", "type": "str"}, + "operation_id": {"key": "operationId", "type": "str"}, + "properties": {"key": "properties", "type": "DeploymentOperationProperties"}, } - def __init__( - self, - *, - properties: Optional["DeploymentOperationProperties"] = None, - **kwargs - ): + def __init__(self, *, properties: Optional["_models.DeploymentOperationProperties"] = None, **kwargs): """ :keyword properties: Deployment properties. :paramtype properties: ~azure.mgmt.resource.resources.v2019_03_01.models.DeploymentOperationProperties """ - super(DeploymentOperation, self).__init__(**kwargs) + super().__init__(**kwargs) self.id = None self.operation_id = None self.properties = properties -class DeploymentOperationProperties(msrest.serialization.Model): +class DeploymentOperationProperties(_serialization.Model): """Deployment operation properties. Variables are only populated by the server, and will be ignored when sending a request. @@ -462,7 +424,7 @@ class DeploymentOperationProperties(msrest.serialization.Model): :ivar status_code: Operation status code. :vartype status_code: str :ivar status_message: Operation status message. - :vartype status_message: any + :vartype status_message: JSON :ivar target_resource: The target resource. :vartype target_resource: ~azure.mgmt.resource.resources.v2019_03_01.models.TargetResource :ivar request: The HTTP request message. @@ -472,34 +434,30 @@ class DeploymentOperationProperties(msrest.serialization.Model): """ _validation = { - 'provisioning_state': {'readonly': True}, - 'timestamp': {'readonly': True}, - 'service_request_id': {'readonly': True}, - 'status_code': {'readonly': True}, - 'status_message': {'readonly': True}, - 'target_resource': {'readonly': True}, - 'request': {'readonly': True}, - 'response': {'readonly': True}, + "provisioning_state": {"readonly": True}, + "timestamp": {"readonly": True}, + "service_request_id": {"readonly": True}, + "status_code": {"readonly": True}, + "status_message": {"readonly": True}, + "target_resource": {"readonly": True}, + "request": {"readonly": True}, + "response": {"readonly": True}, } _attribute_map = { - 'provisioning_state': {'key': 'provisioningState', 'type': 'str'}, - 'timestamp': {'key': 'timestamp', 'type': 'iso-8601'}, - 'service_request_id': {'key': 'serviceRequestId', 'type': 'str'}, - 'status_code': {'key': 'statusCode', 'type': 'str'}, - 'status_message': {'key': 'statusMessage', 'type': 'object'}, - 'target_resource': {'key': 'targetResource', 'type': 'TargetResource'}, - 'request': {'key': 'request', 'type': 'HttpMessage'}, - 'response': {'key': 'response', 'type': 'HttpMessage'}, - } - - def __init__( - self, - **kwargs - ): - """ - """ - super(DeploymentOperationProperties, self).__init__(**kwargs) + "provisioning_state": {"key": "provisioningState", "type": "str"}, + "timestamp": {"key": "timestamp", "type": "iso-8601"}, + "service_request_id": {"key": "serviceRequestId", "type": "str"}, + "status_code": {"key": "statusCode", "type": "str"}, + "status_message": {"key": "statusMessage", "type": "object"}, + "target_resource": {"key": "targetResource", "type": "TargetResource"}, + "request": {"key": "request", "type": "HttpMessage"}, + "response": {"key": "response", "type": "HttpMessage"}, + } + + def __init__(self, **kwargs): + """ """ + super().__init__(**kwargs) self.provisioning_state = None self.timestamp = None self.service_request_id = None @@ -510,7 +468,7 @@ def __init__( self.response = None -class DeploymentOperationsListResult(msrest.serialization.Model): +class DeploymentOperationsListResult(_serialization.Model): """List of deployment operations. Variables are only populated by the server, and will be ignored when sending a request. @@ -522,30 +480,25 @@ class DeploymentOperationsListResult(msrest.serialization.Model): """ _validation = { - 'next_link': {'readonly': True}, + "next_link": {"readonly": True}, } _attribute_map = { - 'value': {'key': 'value', 'type': '[DeploymentOperation]'}, - 'next_link': {'key': 'nextLink', 'type': 'str'}, + "value": {"key": "value", "type": "[DeploymentOperation]"}, + "next_link": {"key": "nextLink", "type": "str"}, } - def __init__( - self, - *, - value: Optional[List["DeploymentOperation"]] = None, - **kwargs - ): + def __init__(self, *, value: Optional[List["_models.DeploymentOperation"]] = None, **kwargs): """ :keyword value: An array of deployment operations. :paramtype value: list[~azure.mgmt.resource.resources.v2019_03_01.models.DeploymentOperation] """ - super(DeploymentOperationsListResult, self).__init__(**kwargs) + super().__init__(**kwargs) self.value = value self.next_link = None -class DeploymentProperties(msrest.serialization.Model): +class DeploymentProperties(_serialization.Model): """Deployment properties. All required parameters must be populated in order to send to Azure. @@ -554,7 +507,7 @@ class DeploymentProperties(msrest.serialization.Model): syntax directly in the request rather than link to an existing template. It can be a JObject or well-formed JSON string. Use either the templateLink property or the template property, but not both. - :vartype template: any + :vartype template: JSON :ivar template_link: The URI of the template. Use either the templateLink property or the template property, but not both. :vartype template_link: ~azure.mgmt.resource.resources.v2019_03_01.models.TemplateLink @@ -562,17 +515,17 @@ class DeploymentProperties(msrest.serialization.Model): You use this element when you want to provide the parameter values directly in the request rather than link to an existing parameter file. Use either the parametersLink property or the parameters property, but not both. It can be a JObject or a well formed JSON string. - :vartype parameters: any + :vartype parameters: JSON :ivar parameters_link: The URI of parameters file. You use this element to link to an existing parameters file. Use either the parametersLink property or the parameters property, but not both. :vartype parameters_link: ~azure.mgmt.resource.resources.v2019_03_01.models.ParametersLink - :ivar mode: Required. The mode that is used to deploy resources. This value can be either - Incremental or Complete. In Incremental mode, resources are deployed without deleting existing - resources that are not included in the template. In Complete mode, resources are deployed and - existing resources in the resource group that are not included in the template are deleted. Be - careful when using Complete mode as you may unintentionally delete resources. Possible values - include: "Incremental", "Complete". + :ivar mode: The mode that is used to deploy resources. This value can be either Incremental or + Complete. In Incremental mode, resources are deployed without deleting existing resources that + are not included in the template. In Complete mode, resources are deployed and existing + resources in the resource group that are not included in the template are deleted. Be careful + when using Complete mode as you may unintentionally delete resources. Required. Known values + are: "Incremental" and "Complete". :vartype mode: str or ~azure.mgmt.resource.resources.v2019_03_01.models.DeploymentMode :ivar debug_setting: The debug setting of the deployment. :vartype debug_setting: ~azure.mgmt.resource.resources.v2019_03_01.models.DebugSetting @@ -582,29 +535,29 @@ class DeploymentProperties(msrest.serialization.Model): """ _validation = { - 'mode': {'required': True}, + "mode": {"required": True}, } _attribute_map = { - 'template': {'key': 'template', 'type': 'object'}, - 'template_link': {'key': 'templateLink', 'type': 'TemplateLink'}, - 'parameters': {'key': 'parameters', 'type': 'object'}, - 'parameters_link': {'key': 'parametersLink', 'type': 'ParametersLink'}, - 'mode': {'key': 'mode', 'type': 'str'}, - 'debug_setting': {'key': 'debugSetting', 'type': 'DebugSetting'}, - 'on_error_deployment': {'key': 'onErrorDeployment', 'type': 'OnErrorDeployment'}, + "template": {"key": "template", "type": "object"}, + "template_link": {"key": "templateLink", "type": "TemplateLink"}, + "parameters": {"key": "parameters", "type": "object"}, + "parameters_link": {"key": "parametersLink", "type": "ParametersLink"}, + "mode": {"key": "mode", "type": "str"}, + "debug_setting": {"key": "debugSetting", "type": "DebugSetting"}, + "on_error_deployment": {"key": "onErrorDeployment", "type": "OnErrorDeployment"}, } def __init__( self, *, - mode: Union[str, "DeploymentMode"], - template: Optional[Any] = None, - template_link: Optional["TemplateLink"] = None, - parameters: Optional[Any] = None, - parameters_link: Optional["ParametersLink"] = None, - debug_setting: Optional["DebugSetting"] = None, - on_error_deployment: Optional["OnErrorDeployment"] = None, + mode: Union[str, "_models.DeploymentMode"], + template: Optional[JSON] = None, + template_link: Optional["_models.TemplateLink"] = None, + parameters: Optional[JSON] = None, + parameters_link: Optional["_models.ParametersLink"] = None, + debug_setting: Optional["_models.DebugSetting"] = None, + on_error_deployment: Optional["_models.OnErrorDeployment"] = None, **kwargs ): """ @@ -612,7 +565,7 @@ def __init__( template syntax directly in the request rather than link to an existing template. It can be a JObject or well-formed JSON string. Use either the templateLink property or the template property, but not both. - :paramtype template: any + :paramtype template: JSON :keyword template_link: The URI of the template. Use either the templateLink property or the template property, but not both. :paramtype template_link: ~azure.mgmt.resource.resources.v2019_03_01.models.TemplateLink @@ -620,17 +573,17 @@ def __init__( template. You use this element when you want to provide the parameter values directly in the request rather than link to an existing parameter file. Use either the parametersLink property or the parameters property, but not both. It can be a JObject or a well formed JSON string. - :paramtype parameters: any + :paramtype parameters: JSON :keyword parameters_link: The URI of parameters file. You use this element to link to an existing parameters file. Use either the parametersLink property or the parameters property, but not both. :paramtype parameters_link: ~azure.mgmt.resource.resources.v2019_03_01.models.ParametersLink - :keyword mode: Required. The mode that is used to deploy resources. This value can be either - Incremental or Complete. In Incremental mode, resources are deployed without deleting existing - resources that are not included in the template. In Complete mode, resources are deployed and - existing resources in the resource group that are not included in the template are deleted. Be - careful when using Complete mode as you may unintentionally delete resources. Possible values - include: "Incremental", "Complete". + :keyword mode: The mode that is used to deploy resources. This value can be either Incremental + or Complete. In Incremental mode, resources are deployed without deleting existing resources + that are not included in the template. In Complete mode, resources are deployed and existing + resources in the resource group that are not included in the template are deleted. Be careful + when using Complete mode as you may unintentionally delete resources. Required. Known values + are: "Incremental" and "Complete". :paramtype mode: str or ~azure.mgmt.resource.resources.v2019_03_01.models.DeploymentMode :keyword debug_setting: The debug setting of the deployment. :paramtype debug_setting: ~azure.mgmt.resource.resources.v2019_03_01.models.DebugSetting @@ -638,7 +591,7 @@ def __init__( :paramtype on_error_deployment: ~azure.mgmt.resource.resources.v2019_03_01.models.OnErrorDeployment """ - super(DeploymentProperties, self).__init__(**kwargs) + super().__init__(**kwargs) self.template = template self.template_link = template_link self.parameters = parameters @@ -648,7 +601,7 @@ def __init__( self.on_error_deployment = on_error_deployment -class DeploymentPropertiesExtended(msrest.serialization.Model): +class DeploymentPropertiesExtended(_serialization.Model): # pylint: disable=too-many-instance-attributes """Deployment properties with additional details. Variables are only populated by the server, and will be ignored when sending a request. @@ -660,23 +613,23 @@ class DeploymentPropertiesExtended(msrest.serialization.Model): :ivar timestamp: The timestamp of the template deployment. :vartype timestamp: ~datetime.datetime :ivar outputs: Key/value pairs that represent deployment output. - :vartype outputs: any + :vartype outputs: JSON :ivar providers: The list of resource providers needed for the deployment. :vartype providers: list[~azure.mgmt.resource.resources.v2019_03_01.models.Provider] :ivar dependencies: The list of deployment dependencies. :vartype dependencies: list[~azure.mgmt.resource.resources.v2019_03_01.models.Dependency] :ivar template: The template content. Use only one of Template or TemplateLink. - :vartype template: any + :vartype template: JSON :ivar template_link: The URI referencing the template. Use only one of Template or TemplateLink. :vartype template_link: ~azure.mgmt.resource.resources.v2019_03_01.models.TemplateLink :ivar parameters: Deployment parameters. Use only one of Parameters or ParametersLink. - :vartype parameters: any + :vartype parameters: JSON :ivar parameters_link: The URI referencing the parameters. Use only one of Parameters or ParametersLink. :vartype parameters_link: ~azure.mgmt.resource.resources.v2019_03_01.models.ParametersLink - :ivar mode: The deployment mode. Possible values are Incremental and Complete. Possible values - include: "Incremental", "Complete". + :ivar mode: The deployment mode. Possible values are Incremental and Complete. Known values + are: "Incremental" and "Complete". :vartype mode: str or ~azure.mgmt.resource.resources.v2019_03_01.models.DeploymentMode :ivar debug_setting: The debug setting of the deployment. :vartype debug_setting: ~azure.mgmt.resource.resources.v2019_03_01.models.DebugSetting @@ -688,63 +641,63 @@ class DeploymentPropertiesExtended(msrest.serialization.Model): """ _validation = { - 'provisioning_state': {'readonly': True}, - 'correlation_id': {'readonly': True}, - 'timestamp': {'readonly': True}, - 'error': {'readonly': True}, + "provisioning_state": {"readonly": True}, + "correlation_id": {"readonly": True}, + "timestamp": {"readonly": True}, + "error": {"readonly": True}, } _attribute_map = { - 'provisioning_state': {'key': 'provisioningState', 'type': 'str'}, - 'correlation_id': {'key': 'correlationId', 'type': 'str'}, - 'timestamp': {'key': 'timestamp', 'type': 'iso-8601'}, - 'outputs': {'key': 'outputs', 'type': 'object'}, - 'providers': {'key': 'providers', 'type': '[Provider]'}, - 'dependencies': {'key': 'dependencies', 'type': '[Dependency]'}, - 'template': {'key': 'template', 'type': 'object'}, - 'template_link': {'key': 'templateLink', 'type': 'TemplateLink'}, - 'parameters': {'key': 'parameters', 'type': 'object'}, - 'parameters_link': {'key': 'parametersLink', 'type': 'ParametersLink'}, - 'mode': {'key': 'mode', 'type': 'str'}, - 'debug_setting': {'key': 'debugSetting', 'type': 'DebugSetting'}, - 'on_error_deployment': {'key': 'onErrorDeployment', 'type': 'OnErrorDeploymentExtended'}, - 'error': {'key': 'error', 'type': 'ErrorResponse'}, + "provisioning_state": {"key": "provisioningState", "type": "str"}, + "correlation_id": {"key": "correlationId", "type": "str"}, + "timestamp": {"key": "timestamp", "type": "iso-8601"}, + "outputs": {"key": "outputs", "type": "object"}, + "providers": {"key": "providers", "type": "[Provider]"}, + "dependencies": {"key": "dependencies", "type": "[Dependency]"}, + "template": {"key": "template", "type": "object"}, + "template_link": {"key": "templateLink", "type": "TemplateLink"}, + "parameters": {"key": "parameters", "type": "object"}, + "parameters_link": {"key": "parametersLink", "type": "ParametersLink"}, + "mode": {"key": "mode", "type": "str"}, + "debug_setting": {"key": "debugSetting", "type": "DebugSetting"}, + "on_error_deployment": {"key": "onErrorDeployment", "type": "OnErrorDeploymentExtended"}, + "error": {"key": "error", "type": "ErrorResponse"}, } def __init__( self, *, - outputs: Optional[Any] = None, - providers: Optional[List["Provider"]] = None, - dependencies: Optional[List["Dependency"]] = None, - template: Optional[Any] = None, - template_link: Optional["TemplateLink"] = None, - parameters: Optional[Any] = None, - parameters_link: Optional["ParametersLink"] = None, - mode: Optional[Union[str, "DeploymentMode"]] = None, - debug_setting: Optional["DebugSetting"] = None, - on_error_deployment: Optional["OnErrorDeploymentExtended"] = None, + outputs: Optional[JSON] = None, + providers: Optional[List["_models.Provider"]] = None, + dependencies: Optional[List["_models.Dependency"]] = None, + template: Optional[JSON] = None, + template_link: Optional["_models.TemplateLink"] = None, + parameters: Optional[JSON] = None, + parameters_link: Optional["_models.ParametersLink"] = None, + mode: Optional[Union[str, "_models.DeploymentMode"]] = None, + debug_setting: Optional["_models.DebugSetting"] = None, + on_error_deployment: Optional["_models.OnErrorDeploymentExtended"] = None, **kwargs ): """ :keyword outputs: Key/value pairs that represent deployment output. - :paramtype outputs: any + :paramtype outputs: JSON :keyword providers: The list of resource providers needed for the deployment. :paramtype providers: list[~azure.mgmt.resource.resources.v2019_03_01.models.Provider] :keyword dependencies: The list of deployment dependencies. :paramtype dependencies: list[~azure.mgmt.resource.resources.v2019_03_01.models.Dependency] :keyword template: The template content. Use only one of Template or TemplateLink. - :paramtype template: any + :paramtype template: JSON :keyword template_link: The URI referencing the template. Use only one of Template or TemplateLink. :paramtype template_link: ~azure.mgmt.resource.resources.v2019_03_01.models.TemplateLink :keyword parameters: Deployment parameters. Use only one of Parameters or ParametersLink. - :paramtype parameters: any + :paramtype parameters: JSON :keyword parameters_link: The URI referencing the parameters. Use only one of Parameters or ParametersLink. :paramtype parameters_link: ~azure.mgmt.resource.resources.v2019_03_01.models.ParametersLink - :keyword mode: The deployment mode. Possible values are Incremental and Complete. Possible - values include: "Incremental", "Complete". + :keyword mode: The deployment mode. Possible values are Incremental and Complete. Known values + are: "Incremental" and "Complete". :paramtype mode: str or ~azure.mgmt.resource.resources.v2019_03_01.models.DeploymentMode :keyword debug_setting: The debug setting of the deployment. :paramtype debug_setting: ~azure.mgmt.resource.resources.v2019_03_01.models.DebugSetting @@ -752,7 +705,7 @@ def __init__( :paramtype on_error_deployment: ~azure.mgmt.resource.resources.v2019_03_01.models.OnErrorDeploymentExtended """ - super(DeploymentPropertiesExtended, self).__init__(**kwargs) + super().__init__(**kwargs) self.provisioning_state = None self.correlation_id = None self.timestamp = None @@ -769,7 +722,7 @@ def __init__( self.error = None -class DeploymentValidateResult(msrest.serialization.Model): +class DeploymentValidateResult(_serialization.Model): """Information from validate template deployment response. :ivar error: Validation error. @@ -781,15 +734,15 @@ class DeploymentValidateResult(msrest.serialization.Model): """ _attribute_map = { - 'error': {'key': 'error', 'type': 'ResourceManagementErrorWithDetails'}, - 'properties': {'key': 'properties', 'type': 'DeploymentPropertiesExtended'}, + "error": {"key": "error", "type": "ResourceManagementErrorWithDetails"}, + "properties": {"key": "properties", "type": "DeploymentPropertiesExtended"}, } def __init__( self, *, - error: Optional["ResourceManagementErrorWithDetails"] = None, - properties: Optional["DeploymentPropertiesExtended"] = None, + error: Optional["_models.ResourceManagementErrorWithDetails"] = None, + properties: Optional["_models.DeploymentPropertiesExtended"] = None, **kwargs ): """ @@ -800,12 +753,12 @@ def __init__( :paramtype properties: ~azure.mgmt.resource.resources.v2019_03_01.models.DeploymentPropertiesExtended """ - super(DeploymentValidateResult, self).__init__(**kwargs) + super().__init__(**kwargs) self.error = error self.properties = properties -class ErrorAdditionalInfo(msrest.serialization.Model): +class ErrorAdditionalInfo(_serialization.Model): """The resource management error additional info. Variables are only populated by the server, and will be ignored when sending a request. @@ -813,31 +766,27 @@ class ErrorAdditionalInfo(msrest.serialization.Model): :ivar type: The additional info type. :vartype type: str :ivar info: The additional info. - :vartype info: any + :vartype info: JSON """ _validation = { - 'type': {'readonly': True}, - 'info': {'readonly': True}, + "type": {"readonly": True}, + "info": {"readonly": True}, } _attribute_map = { - 'type': {'key': 'type', 'type': 'str'}, - 'info': {'key': 'info', 'type': 'object'}, + "type": {"key": "type", "type": "str"}, + "info": {"key": "info", "type": "object"}, } - def __init__( - self, - **kwargs - ): - """ - """ - super(ErrorAdditionalInfo, self).__init__(**kwargs) + def __init__(self, **kwargs): + """ """ + super().__init__(**kwargs) self.type = None self.info = None -class ErrorResponse(msrest.serialization.Model): +class ErrorResponse(_serialization.Model): """Common error response for all Azure Resource Manager APIs to return error details for failed operations. (This also follows the OData error response format.). Variables are only populated by the server, and will be ignored when sending a request. @@ -856,28 +805,24 @@ class ErrorResponse(msrest.serialization.Model): """ _validation = { - 'code': {'readonly': True}, - 'message': {'readonly': True}, - 'target': {'readonly': True}, - 'details': {'readonly': True}, - 'additional_info': {'readonly': True}, + "code": {"readonly": True}, + "message": {"readonly": True}, + "target": {"readonly": True}, + "details": {"readonly": True}, + "additional_info": {"readonly": True}, } _attribute_map = { - 'code': {'key': 'code', 'type': 'str'}, - 'message': {'key': 'message', 'type': 'str'}, - 'target': {'key': 'target', 'type': 'str'}, - 'details': {'key': 'details', 'type': '[ErrorResponse]'}, - 'additional_info': {'key': 'additionalInfo', 'type': '[ErrorAdditionalInfo]'}, + "code": {"key": "code", "type": "str"}, + "message": {"key": "message", "type": "str"}, + "target": {"key": "target", "type": "str"}, + "details": {"key": "details", "type": "[ErrorResponse]"}, + "additional_info": {"key": "additionalInfo", "type": "[ErrorAdditionalInfo]"}, } - def __init__( - self, - **kwargs - ): - """ - """ - super(ErrorResponse, self).__init__(**kwargs) + def __init__(self, **kwargs): + """ """ + super().__init__(**kwargs) self.code = None self.message = None self.target = None @@ -885,7 +830,7 @@ def __init__( self.additional_info = None -class ExportTemplateRequest(msrest.serialization.Model): +class ExportTemplateRequest(_serialization.Model): """Export resource group template request parameters. :ivar resources: The IDs of the resources to filter the export by. To export all resources, @@ -898,17 +843,11 @@ class ExportTemplateRequest(msrest.serialization.Model): """ _attribute_map = { - 'resources': {'key': 'resources', 'type': '[str]'}, - 'options': {'key': 'options', 'type': 'str'}, + "resources": {"key": "resources", "type": "[str]"}, + "options": {"key": "options", "type": "str"}, } - def __init__( - self, - *, - resources: Optional[List[str]] = None, - options: Optional[str] = None, - **kwargs - ): + def __init__(self, *, resources: Optional[List[str]] = None, options: Optional[str] = None, **kwargs): """ :keyword resources: The IDs of the resources to filter the export by. To export all resources, supply an array with single entry '*'. @@ -918,12 +857,12 @@ def __init__( 'SkipResourceNameParameterization', 'SkipAllParameterization'. :paramtype options: str """ - super(ExportTemplateRequest, self).__init__(**kwargs) + super().__init__(**kwargs) self.resources = resources self.options = options -class Resource(msrest.serialization.Model): +class Resource(_serialization.Model): """Specified resource. Variables are only populated by the server, and will be ignored when sending a request. @@ -936,38 +875,32 @@ class Resource(msrest.serialization.Model): :vartype type: str :ivar location: Resource location. :vartype location: str - :ivar tags: A set of tags. Resource tags. + :ivar tags: Resource tags. :vartype tags: dict[str, str] """ _validation = { - 'id': {'readonly': True}, - 'name': {'readonly': True}, - 'type': {'readonly': True}, + "id": {"readonly": True}, + "name": {"readonly": True}, + "type": {"readonly": True}, } _attribute_map = { - 'id': {'key': 'id', 'type': 'str'}, - 'name': {'key': 'name', 'type': 'str'}, - 'type': {'key': 'type', 'type': 'str'}, - 'location': {'key': 'location', 'type': 'str'}, - 'tags': {'key': 'tags', 'type': '{str}'}, + "id": {"key": "id", "type": "str"}, + "name": {"key": "name", "type": "str"}, + "type": {"key": "type", "type": "str"}, + "location": {"key": "location", "type": "str"}, + "tags": {"key": "tags", "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): """ :keyword location: Resource location. :paramtype location: str - :keyword tags: A set of tags. Resource tags. + :keyword tags: Resource tags. :paramtype tags: dict[str, str] """ - super(Resource, self).__init__(**kwargs) + super().__init__(**kwargs) self.id = None self.name = None self.type = None @@ -975,7 +908,7 @@ def __init__( self.tags = tags -class GenericResource(Resource): +class GenericResource(Resource): # pylint: disable=too-many-instance-attributes """Resource information. Variables are only populated by the server, and will be ignored when sending a request. @@ -988,12 +921,12 @@ class GenericResource(Resource): :vartype type: str :ivar location: Resource location. :vartype location: str - :ivar tags: A set of tags. Resource tags. + :ivar tags: Resource tags. :vartype tags: dict[str, str] :ivar plan: The plan of the resource. :vartype plan: ~azure.mgmt.resource.resources.v2019_03_01.models.Plan :ivar properties: The resource properties. - :vartype properties: any + :vartype properties: JSON :ivar kind: The kind of the resource. :vartype kind: str :ivar managed_by: ID of the resource that manages this resource. @@ -1005,24 +938,24 @@ class GenericResource(Resource): """ _validation = { - 'id': {'readonly': True}, - 'name': {'readonly': True}, - 'type': {'readonly': True}, - 'kind': {'pattern': r'^[-\w\._,\(\)]+$'}, + "id": {"readonly": True}, + "name": {"readonly": True}, + "type": {"readonly": True}, + "kind": {"pattern": r"^[-\w\._,\(\)]+$"}, } _attribute_map = { - 'id': {'key': 'id', 'type': 'str'}, - 'name': {'key': 'name', 'type': 'str'}, - 'type': {'key': 'type', 'type': 'str'}, - 'location': {'key': 'location', 'type': 'str'}, - 'tags': {'key': 'tags', 'type': '{str}'}, - 'plan': {'key': 'plan', 'type': 'Plan'}, - 'properties': {'key': 'properties', 'type': 'object'}, - 'kind': {'key': 'kind', 'type': 'str'}, - 'managed_by': {'key': 'managedBy', 'type': 'str'}, - 'sku': {'key': 'sku', 'type': 'Sku'}, - 'identity': {'key': 'identity', 'type': 'Identity'}, + "id": {"key": "id", "type": "str"}, + "name": {"key": "name", "type": "str"}, + "type": {"key": "type", "type": "str"}, + "location": {"key": "location", "type": "str"}, + "tags": {"key": "tags", "type": "{str}"}, + "plan": {"key": "plan", "type": "Plan"}, + "properties": {"key": "properties", "type": "object"}, + "kind": {"key": "kind", "type": "str"}, + "managed_by": {"key": "managedBy", "type": "str"}, + "sku": {"key": "sku", "type": "Sku"}, + "identity": {"key": "identity", "type": "Identity"}, } def __init__( @@ -1030,23 +963,23 @@ def __init__( *, location: Optional[str] = None, tags: Optional[Dict[str, str]] = None, - plan: Optional["Plan"] = None, - properties: Optional[Any] = None, + plan: Optional["_models.Plan"] = None, + properties: Optional[JSON] = None, kind: Optional[str] = None, managed_by: Optional[str] = None, - sku: Optional["Sku"] = None, - identity: Optional["Identity"] = None, + sku: Optional["_models.Sku"] = None, + identity: Optional["_models.Identity"] = None, **kwargs ): """ :keyword location: Resource location. :paramtype location: str - :keyword tags: A set of tags. Resource tags. + :keyword tags: Resource tags. :paramtype tags: dict[str, str] :keyword plan: The plan of the resource. :paramtype plan: ~azure.mgmt.resource.resources.v2019_03_01.models.Plan :keyword properties: The resource properties. - :paramtype properties: any + :paramtype properties: JSON :keyword kind: The kind of the resource. :paramtype kind: str :keyword managed_by: ID of the resource that manages this resource. @@ -1056,7 +989,7 @@ def __init__( :keyword identity: The identity of the resource. :paramtype identity: ~azure.mgmt.resource.resources.v2019_03_01.models.Identity """ - super(GenericResource, self).__init__(location=location, tags=tags, **kwargs) + super().__init__(location=location, tags=tags, **kwargs) self.plan = plan self.properties = properties self.kind = kind @@ -1065,7 +998,7 @@ def __init__( self.identity = identity -class GenericResourceExpanded(GenericResource): +class GenericResourceExpanded(GenericResource): # pylint: disable=too-many-instance-attributes """Resource information. Variables are only populated by the server, and will be ignored when sending a request. @@ -1078,12 +1011,12 @@ class GenericResourceExpanded(GenericResource): :vartype type: str :ivar location: Resource location. :vartype location: str - :ivar tags: A set of tags. Resource tags. + :ivar tags: Resource tags. :vartype tags: dict[str, str] :ivar plan: The plan of the resource. :vartype plan: ~azure.mgmt.resource.resources.v2019_03_01.models.Plan :ivar properties: The resource properties. - :vartype properties: any + :vartype properties: JSON :ivar kind: The kind of the resource. :vartype kind: str :ivar managed_by: ID of the resource that manages this resource. @@ -1104,30 +1037,30 @@ class GenericResourceExpanded(GenericResource): """ _validation = { - 'id': {'readonly': True}, - 'name': {'readonly': True}, - 'type': {'readonly': True}, - 'kind': {'pattern': r'^[-\w\._,\(\)]+$'}, - 'created_time': {'readonly': True}, - 'changed_time': {'readonly': True}, - 'provisioning_state': {'readonly': True}, + "id": {"readonly": True}, + "name": {"readonly": True}, + "type": {"readonly": True}, + "kind": {"pattern": r"^[-\w\._,\(\)]+$"}, + "created_time": {"readonly": True}, + "changed_time": {"readonly": True}, + "provisioning_state": {"readonly": True}, } _attribute_map = { - 'id': {'key': 'id', 'type': 'str'}, - 'name': {'key': 'name', 'type': 'str'}, - 'type': {'key': 'type', 'type': 'str'}, - 'location': {'key': 'location', 'type': 'str'}, - 'tags': {'key': 'tags', 'type': '{str}'}, - 'plan': {'key': 'plan', 'type': 'Plan'}, - 'properties': {'key': 'properties', 'type': 'object'}, - 'kind': {'key': 'kind', 'type': 'str'}, - 'managed_by': {'key': 'managedBy', 'type': 'str'}, - 'sku': {'key': 'sku', 'type': 'Sku'}, - 'identity': {'key': 'identity', 'type': 'Identity'}, - 'created_time': {'key': 'createdTime', 'type': 'iso-8601'}, - 'changed_time': {'key': 'changedTime', 'type': 'iso-8601'}, - 'provisioning_state': {'key': 'provisioningState', 'type': 'str'}, + "id": {"key": "id", "type": "str"}, + "name": {"key": "name", "type": "str"}, + "type": {"key": "type", "type": "str"}, + "location": {"key": "location", "type": "str"}, + "tags": {"key": "tags", "type": "{str}"}, + "plan": {"key": "plan", "type": "Plan"}, + "properties": {"key": "properties", "type": "object"}, + "kind": {"key": "kind", "type": "str"}, + "managed_by": {"key": "managedBy", "type": "str"}, + "sku": {"key": "sku", "type": "Sku"}, + "identity": {"key": "identity", "type": "Identity"}, + "created_time": {"key": "createdTime", "type": "iso-8601"}, + "changed_time": {"key": "changedTime", "type": "iso-8601"}, + "provisioning_state": {"key": "provisioningState", "type": "str"}, } def __init__( @@ -1135,23 +1068,23 @@ def __init__( *, location: Optional[str] = None, tags: Optional[Dict[str, str]] = None, - plan: Optional["Plan"] = None, - properties: Optional[Any] = None, + plan: Optional["_models.Plan"] = None, + properties: Optional[JSON] = None, kind: Optional[str] = None, managed_by: Optional[str] = None, - sku: Optional["Sku"] = None, - identity: Optional["Identity"] = None, + sku: Optional["_models.Sku"] = None, + identity: Optional["_models.Identity"] = None, **kwargs ): """ :keyword location: Resource location. :paramtype location: str - :keyword tags: A set of tags. Resource tags. + :keyword tags: Resource tags. :paramtype tags: dict[str, str] :keyword plan: The plan of the resource. :paramtype plan: ~azure.mgmt.resource.resources.v2019_03_01.models.Plan :keyword properties: The resource properties. - :paramtype properties: any + :paramtype properties: JSON :keyword kind: The kind of the resource. :paramtype kind: str :keyword managed_by: ID of the resource that manages this resource. @@ -1161,13 +1094,23 @@ def __init__( :keyword identity: The identity of the resource. :paramtype identity: ~azure.mgmt.resource.resources.v2019_03_01.models.Identity """ - super(GenericResourceExpanded, self).__init__(location=location, tags=tags, plan=plan, properties=properties, kind=kind, managed_by=managed_by, sku=sku, identity=identity, **kwargs) + super().__init__( + location=location, + tags=tags, + plan=plan, + properties=properties, + kind=kind, + managed_by=managed_by, + sku=sku, + identity=identity, + **kwargs + ) self.created_time = None self.changed_time = None self.provisioning_state = None -class GenericResourceFilter(msrest.serialization.Model): +class GenericResourceFilter(_serialization.Model): """Resource filter. :ivar resource_type: The resource type. @@ -1179,9 +1122,9 @@ class GenericResourceFilter(msrest.serialization.Model): """ _attribute_map = { - 'resource_type': {'key': 'resourceType', 'type': 'str'}, - 'tagname': {'key': 'tagname', 'type': 'str'}, - 'tagvalue': {'key': 'tagvalue', 'type': 'str'}, + "resource_type": {"key": "resourceType", "type": "str"}, + "tagname": {"key": "tagname", "type": "str"}, + "tagvalue": {"key": "tagvalue", "type": "str"}, } def __init__( @@ -1200,38 +1143,33 @@ def __init__( :keyword tagvalue: The tag value. :paramtype tagvalue: str """ - super(GenericResourceFilter, self).__init__(**kwargs) + super().__init__(**kwargs) self.resource_type = resource_type self.tagname = tagname self.tagvalue = tagvalue -class HttpMessage(msrest.serialization.Model): +class HttpMessage(_serialization.Model): """HTTP message. :ivar content: HTTP message content. - :vartype content: any + :vartype content: JSON """ _attribute_map = { - 'content': {'key': 'content', 'type': 'object'}, + "content": {"key": "content", "type": "object"}, } - def __init__( - self, - *, - content: Optional[Any] = None, - **kwargs - ): + def __init__(self, *, content: Optional[JSON] = None, **kwargs): """ :keyword content: HTTP message content. - :paramtype content: any + :paramtype content: JSON """ - super(HttpMessage, self).__init__(**kwargs) + super().__init__(**kwargs) self.content = content -class Identity(msrest.serialization.Model): +class Identity(_serialization.Model): """Identity for the resource. Variables are only populated by the server, and will be ignored when sending a request. @@ -1240,8 +1178,8 @@ class Identity(msrest.serialization.Model): :vartype principal_id: str :ivar tenant_id: The tenant ID of resource. :vartype tenant_id: str - :ivar type: The identity type. Possible values include: "SystemAssigned", "UserAssigned", - "SystemAssigned, UserAssigned", "None". + :ivar type: The identity type. Known values are: "SystemAssigned", "UserAssigned", + "SystemAssigned, UserAssigned", and "None". :vartype type: str or ~azure.mgmt.resource.resources.v2019_03_01.models.ResourceIdentityType :ivar user_assigned_identities: The list of user identities associated with the resource. The user identity dictionary key references will be ARM resource ids in the form: @@ -1251,27 +1189,32 @@ class Identity(msrest.serialization.Model): """ _validation = { - 'principal_id': {'readonly': True}, - 'tenant_id': {'readonly': True}, + "principal_id": {"readonly": True}, + "tenant_id": {"readonly": True}, } _attribute_map = { - 'principal_id': {'key': 'principalId', 'type': 'str'}, - 'tenant_id': {'key': 'tenantId', 'type': 'str'}, - 'type': {'key': 'type', 'type': 'str'}, - 'user_assigned_identities': {'key': 'userAssignedIdentities', 'type': '{ComponentsSgqdofSchemasIdentityPropertiesUserassignedidentitiesAdditionalproperties}'}, + "principal_id": {"key": "principalId", "type": "str"}, + "tenant_id": {"key": "tenantId", "type": "str"}, + "type": {"key": "type", "type": "str"}, + "user_assigned_identities": { + "key": "userAssignedIdentities", + "type": "{ComponentsSgqdofSchemasIdentityPropertiesUserassignedidentitiesAdditionalproperties}", + }, } def __init__( self, *, - type: Optional[Union[str, "ResourceIdentityType"]] = None, - user_assigned_identities: Optional[Dict[str, "ComponentsSgqdofSchemasIdentityPropertiesUserassignedidentitiesAdditionalproperties"]] = None, + type: Optional[Union[str, "_models.ResourceIdentityType"]] = None, + user_assigned_identities: Optional[ + Dict[str, "_models.ComponentsSgqdofSchemasIdentityPropertiesUserassignedidentitiesAdditionalproperties"] + ] = None, **kwargs ): """ - :keyword type: The identity type. Possible values include: "SystemAssigned", "UserAssigned", - "SystemAssigned, UserAssigned", "None". + :keyword type: The identity type. Known values are: "SystemAssigned", "UserAssigned", + "SystemAssigned, UserAssigned", and "None". :paramtype type: str or ~azure.mgmt.resource.resources.v2019_03_01.models.ResourceIdentityType :keyword user_assigned_identities: The list of user identities associated with the resource. The user identity dictionary key references will be ARM resource ids in the form: @@ -1279,48 +1222,48 @@ def __init__( :paramtype user_assigned_identities: dict[str, ~azure.mgmt.resource.resources.v2019_03_01.models.ComponentsSgqdofSchemasIdentityPropertiesUserassignedidentitiesAdditionalproperties] """ - super(Identity, self).__init__(**kwargs) + super().__init__(**kwargs) self.principal_id = None self.tenant_id = None self.type = type self.user_assigned_identities = user_assigned_identities -class OnErrorDeployment(msrest.serialization.Model): +class OnErrorDeployment(_serialization.Model): """Deployment on error behavior. :ivar type: The deployment on error behavior type. Possible values are LastSuccessful and - SpecificDeployment. Possible values include: "LastSuccessful", "SpecificDeployment". + SpecificDeployment. Known values are: "LastSuccessful" and "SpecificDeployment". :vartype type: str or ~azure.mgmt.resource.resources.v2019_03_01.models.OnErrorDeploymentType :ivar deployment_name: The deployment to be used on error case. :vartype deployment_name: str """ _attribute_map = { - 'type': {'key': 'type', 'type': 'str'}, - 'deployment_name': {'key': 'deploymentName', 'type': 'str'}, + "type": {"key": "type", "type": "str"}, + "deployment_name": {"key": "deploymentName", "type": "str"}, } def __init__( self, *, - type: Optional[Union[str, "OnErrorDeploymentType"]] = None, + type: Optional[Union[str, "_models.OnErrorDeploymentType"]] = None, deployment_name: Optional[str] = None, **kwargs ): """ :keyword type: The deployment on error behavior type. Possible values are LastSuccessful and - SpecificDeployment. Possible values include: "LastSuccessful", "SpecificDeployment". + SpecificDeployment. Known values are: "LastSuccessful" and "SpecificDeployment". :paramtype type: str or ~azure.mgmt.resource.resources.v2019_03_01.models.OnErrorDeploymentType :keyword deployment_name: The deployment to be used on error case. :paramtype deployment_name: str """ - super(OnErrorDeployment, self).__init__(**kwargs) + super().__init__(**kwargs) self.type = type self.deployment_name = deployment_name -class OnErrorDeploymentExtended(msrest.serialization.Model): +class OnErrorDeploymentExtended(_serialization.Model): """Deployment on error behavior with additional details. Variables are only populated by the server, and will be ignored when sending a request. @@ -1328,43 +1271,43 @@ class OnErrorDeploymentExtended(msrest.serialization.Model): :ivar provisioning_state: The state of the provisioning for the on error deployment. :vartype provisioning_state: str :ivar type: The deployment on error behavior type. Possible values are LastSuccessful and - SpecificDeployment. Possible values include: "LastSuccessful", "SpecificDeployment". + SpecificDeployment. Known values are: "LastSuccessful" and "SpecificDeployment". :vartype type: str or ~azure.mgmt.resource.resources.v2019_03_01.models.OnErrorDeploymentType :ivar deployment_name: The deployment to be used on error case. :vartype deployment_name: str """ _validation = { - 'provisioning_state': {'readonly': True}, + "provisioning_state": {"readonly": True}, } _attribute_map = { - 'provisioning_state': {'key': 'provisioningState', 'type': 'str'}, - 'type': {'key': 'type', 'type': 'str'}, - 'deployment_name': {'key': 'deploymentName', 'type': 'str'}, + "provisioning_state": {"key": "provisioningState", "type": "str"}, + "type": {"key": "type", "type": "str"}, + "deployment_name": {"key": "deploymentName", "type": "str"}, } def __init__( self, *, - type: Optional[Union[str, "OnErrorDeploymentType"]] = None, + type: Optional[Union[str, "_models.OnErrorDeploymentType"]] = None, deployment_name: Optional[str] = None, **kwargs ): """ :keyword type: The deployment on error behavior type. Possible values are LastSuccessful and - SpecificDeployment. Possible values include: "LastSuccessful", "SpecificDeployment". + SpecificDeployment. Known values are: "LastSuccessful" and "SpecificDeployment". :paramtype type: str or ~azure.mgmt.resource.resources.v2019_03_01.models.OnErrorDeploymentType :keyword deployment_name: The deployment to be used on error case. :paramtype deployment_name: str """ - super(OnErrorDeploymentExtended, self).__init__(**kwargs) + super().__init__(**kwargs) self.provisioning_state = None self.type = type self.deployment_name = deployment_name -class Operation(msrest.serialization.Model): +class Operation(_serialization.Model): """Microsoft.Resources operation. :ivar name: Operation name: {provider}/{resource}/{operation}. @@ -1374,29 +1317,23 @@ class Operation(msrest.serialization.Model): """ _attribute_map = { - 'name': {'key': 'name', 'type': 'str'}, - 'display': {'key': 'display', 'type': 'OperationDisplay'}, + "name": {"key": "name", "type": "str"}, + "display": {"key": "display", "type": "OperationDisplay"}, } - def __init__( - self, - *, - name: Optional[str] = None, - display: Optional["OperationDisplay"] = None, - **kwargs - ): + def __init__(self, *, name: Optional[str] = None, display: Optional["_models.OperationDisplay"] = None, **kwargs): """ :keyword name: Operation name: {provider}/{resource}/{operation}. :paramtype name: str :keyword display: The object that represents the operation. :paramtype display: ~azure.mgmt.resource.resources.v2019_03_01.models.OperationDisplay """ - super(Operation, self).__init__(**kwargs) + super().__init__(**kwargs) self.name = name self.display = display -class OperationDisplay(msrest.serialization.Model): +class OperationDisplay(_serialization.Model): """The object that represents the operation. :ivar provider: Service provider: Microsoft.Resources. @@ -1410,10 +1347,10 @@ class OperationDisplay(msrest.serialization.Model): """ _attribute_map = { - 'provider': {'key': 'provider', 'type': 'str'}, - 'resource': {'key': 'resource', 'type': 'str'}, - 'operation': {'key': 'operation', 'type': 'str'}, - 'description': {'key': 'description', 'type': 'str'}, + "provider": {"key": "provider", "type": "str"}, + "resource": {"key": "resource", "type": "str"}, + "operation": {"key": "operation", "type": "str"}, + "description": {"key": "description", "type": "str"}, } def __init__( @@ -1435,14 +1372,14 @@ def __init__( :keyword description: Description of the operation. :paramtype description: str """ - super(OperationDisplay, self).__init__(**kwargs) + super().__init__(**kwargs) self.provider = provider self.resource = resource self.operation = operation self.description = description -class OperationListResult(msrest.serialization.Model): +class OperationListResult(_serialization.Model): """Result of the request to list Microsoft.Resources operations. It contains a list of operations and a URL link to get the next set of results. :ivar value: List of Microsoft.Resources operations. @@ -1452,67 +1389,55 @@ class OperationListResult(msrest.serialization.Model): """ _attribute_map = { - 'value': {'key': 'value', 'type': '[Operation]'}, - 'next_link': {'key': 'nextLink', 'type': 'str'}, + "value": {"key": "value", "type": "[Operation]"}, + "next_link": {"key": "nextLink", "type": "str"}, } - def __init__( - self, - *, - value: Optional[List["Operation"]] = None, - next_link: Optional[str] = None, - **kwargs - ): + def __init__(self, *, value: Optional[List["_models.Operation"]] = None, next_link: Optional[str] = None, **kwargs): """ :keyword value: List of Microsoft.Resources operations. :paramtype value: list[~azure.mgmt.resource.resources.v2019_03_01.models.Operation] :keyword next_link: URL to get the next set of operation list results if there are any. :paramtype next_link: str """ - super(OperationListResult, self).__init__(**kwargs) + super().__init__(**kwargs) self.value = value self.next_link = next_link -class ParametersLink(msrest.serialization.Model): +class ParametersLink(_serialization.Model): """Entity representing the reference to the deployment parameters. All required parameters must be populated in order to send to Azure. - :ivar uri: Required. The URI of the parameters file. + :ivar uri: The URI of the parameters file. Required. :vartype uri: str :ivar content_version: If included, must match the ContentVersion in the template. :vartype content_version: str """ _validation = { - 'uri': {'required': True}, + "uri": {"required": True}, } _attribute_map = { - 'uri': {'key': 'uri', 'type': 'str'}, - 'content_version': {'key': 'contentVersion', 'type': 'str'}, + "uri": {"key": "uri", "type": "str"}, + "content_version": {"key": "contentVersion", "type": "str"}, } - def __init__( - self, - *, - uri: str, - content_version: Optional[str] = None, - **kwargs - ): + def __init__(self, *, uri: str, content_version: Optional[str] = None, **kwargs): """ - :keyword uri: Required. The URI of the parameters file. + :keyword uri: The URI of the parameters file. Required. :paramtype uri: str :keyword content_version: If included, must match the ContentVersion in the template. :paramtype content_version: str """ - super(ParametersLink, self).__init__(**kwargs) + super().__init__(**kwargs) self.uri = uri self.content_version = content_version -class Plan(msrest.serialization.Model): +class Plan(_serialization.Model): """Plan for the resource. :ivar name: The plan ID. @@ -1528,11 +1453,11 @@ class Plan(msrest.serialization.Model): """ _attribute_map = { - 'name': {'key': 'name', 'type': 'str'}, - 'publisher': {'key': 'publisher', 'type': 'str'}, - 'product': {'key': 'product', 'type': 'str'}, - 'promotion_code': {'key': 'promotionCode', 'type': 'str'}, - 'version': {'key': 'version', 'type': 'str'}, + "name": {"key": "name", "type": "str"}, + "publisher": {"key": "publisher", "type": "str"}, + "product": {"key": "product", "type": "str"}, + "promotion_code": {"key": "promotionCode", "type": "str"}, + "version": {"key": "version", "type": "str"}, } def __init__( @@ -1557,7 +1482,7 @@ def __init__( :keyword version: The plan's version. :paramtype version: str """ - super(Plan, self).__init__(**kwargs) + super().__init__(**kwargs) self.name = name self.publisher = publisher self.product = product @@ -1565,7 +1490,7 @@ def __init__( self.version = version -class Provider(msrest.serialization.Model): +class Provider(_serialization.Model): """Resource provider information. Variables are only populated by the server, and will be ignored when sending a request. @@ -1584,31 +1509,26 @@ class Provider(msrest.serialization.Model): """ _validation = { - 'id': {'readonly': True}, - 'registration_state': {'readonly': True}, - 'registration_policy': {'readonly': True}, - 'resource_types': {'readonly': True}, + "id": {"readonly": True}, + "registration_state": {"readonly": True}, + "registration_policy": {"readonly": True}, + "resource_types": {"readonly": True}, } _attribute_map = { - 'id': {'key': 'id', 'type': 'str'}, - 'namespace': {'key': 'namespace', 'type': 'str'}, - 'registration_state': {'key': 'registrationState', 'type': 'str'}, - 'registration_policy': {'key': 'registrationPolicy', 'type': 'str'}, - 'resource_types': {'key': 'resourceTypes', 'type': '[ProviderResourceType]'}, + "id": {"key": "id", "type": "str"}, + "namespace": {"key": "namespace", "type": "str"}, + "registration_state": {"key": "registrationState", "type": "str"}, + "registration_policy": {"key": "registrationPolicy", "type": "str"}, + "resource_types": {"key": "resourceTypes", "type": "[ProviderResourceType]"}, } - def __init__( - self, - *, - namespace: Optional[str] = None, - **kwargs - ): + def __init__(self, *, namespace: Optional[str] = None, **kwargs): """ :keyword namespace: The namespace of the resource provider. :paramtype namespace: str """ - super(Provider, self).__init__(**kwargs) + super().__init__(**kwargs) self.id = None self.namespace = namespace self.registration_state = None @@ -1616,7 +1536,7 @@ def __init__( self.resource_types = None -class ProviderListResult(msrest.serialization.Model): +class ProviderListResult(_serialization.Model): """List of resource providers. Variables are only populated by the server, and will be ignored when sending a request. @@ -1628,30 +1548,25 @@ class ProviderListResult(msrest.serialization.Model): """ _validation = { - 'next_link': {'readonly': True}, + "next_link": {"readonly": True}, } _attribute_map = { - 'value': {'key': 'value', 'type': '[Provider]'}, - 'next_link': {'key': 'nextLink', 'type': 'str'}, + "value": {"key": "value", "type": "[Provider]"}, + "next_link": {"key": "nextLink", "type": "str"}, } - def __init__( - self, - *, - value: Optional[List["Provider"]] = None, - **kwargs - ): + def __init__(self, *, value: Optional[List["_models.Provider"]] = None, **kwargs): """ :keyword value: An array of resource providers. :paramtype value: list[~azure.mgmt.resource.resources.v2019_03_01.models.Provider] """ - super(ProviderListResult, self).__init__(**kwargs) + super().__init__(**kwargs) self.value = value self.next_link = None -class ProviderResourceType(msrest.serialization.Model): +class ProviderResourceType(_serialization.Model): """Resource type managed by the resource provider. :ivar resource_type: The resource type. @@ -1671,13 +1586,13 @@ class ProviderResourceType(msrest.serialization.Model): """ _attribute_map = { - 'resource_type': {'key': 'resourceType', 'type': 'str'}, - 'locations': {'key': 'locations', 'type': '[str]'}, - 'aliases': {'key': 'aliases', 'type': '[AliasType]'}, - 'api_versions': {'key': 'apiVersions', 'type': '[str]'}, - 'zone_mappings': {'key': 'zoneMappings', 'type': '[ZoneMapping]'}, - 'capabilities': {'key': 'capabilities', 'type': 'str'}, - 'properties': {'key': 'properties', 'type': '{str}'}, + "resource_type": {"key": "resourceType", "type": "str"}, + "locations": {"key": "locations", "type": "[str]"}, + "aliases": {"key": "aliases", "type": "[AliasType]"}, + "api_versions": {"key": "apiVersions", "type": "[str]"}, + "zone_mappings": {"key": "zoneMappings", "type": "[ZoneMapping]"}, + "capabilities": {"key": "capabilities", "type": "str"}, + "properties": {"key": "properties", "type": "{str}"}, } def __init__( @@ -1685,9 +1600,9 @@ def __init__( *, resource_type: Optional[str] = None, locations: Optional[List[str]] = None, - aliases: Optional[List["AliasType"]] = None, + aliases: Optional[List["_models.AliasType"]] = None, api_versions: Optional[List[str]] = None, - zone_mappings: Optional[List["ZoneMapping"]] = None, + zone_mappings: Optional[List["_models.ZoneMapping"]] = None, capabilities: Optional[str] = None, properties: Optional[Dict[str, str]] = None, **kwargs @@ -1708,7 +1623,7 @@ def __init__( :keyword properties: The properties. :paramtype properties: dict[str, str] """ - super(ProviderResourceType, self).__init__(**kwargs) + super().__init__(**kwargs) self.resource_type = resource_type self.locations = locations self.aliases = aliases @@ -1718,7 +1633,7 @@ def __init__( self.properties = properties -class ResourceGroup(msrest.serialization.Model): +class ResourceGroup(_serialization.Model): """Resource group information. Variables are only populated by the server, and will be ignored when sending a request. @@ -1733,37 +1648,37 @@ class ResourceGroup(msrest.serialization.Model): :vartype type: str :ivar properties: The resource group properties. :vartype properties: ~azure.mgmt.resource.resources.v2019_03_01.models.ResourceGroupProperties - :ivar location: Required. The location of the resource group. It cannot be changed after the - resource group has been created. It must be one of the supported Azure locations. + :ivar location: The location of the resource group. It cannot be changed after the resource + group has been created. It must be one of the supported Azure locations. Required. :vartype location: str :ivar managed_by: The ID of the resource that manages this resource group. :vartype managed_by: str - :ivar tags: A set of tags. The tags attached to the resource group. + :ivar tags: The tags attached to the resource group. :vartype tags: dict[str, str] """ _validation = { - 'id': {'readonly': True}, - 'name': {'readonly': True}, - 'type': {'readonly': True}, - 'location': {'required': True}, + "id": {"readonly": True}, + "name": {"readonly": True}, + "type": {"readonly": True}, + "location": {"required": True}, } _attribute_map = { - 'id': {'key': 'id', 'type': 'str'}, - 'name': {'key': 'name', 'type': 'str'}, - 'type': {'key': 'type', 'type': 'str'}, - 'properties': {'key': 'properties', 'type': 'ResourceGroupProperties'}, - 'location': {'key': 'location', 'type': 'str'}, - 'managed_by': {'key': 'managedBy', 'type': 'str'}, - 'tags': {'key': 'tags', 'type': '{str}'}, + "id": {"key": "id", "type": "str"}, + "name": {"key": "name", "type": "str"}, + "type": {"key": "type", "type": "str"}, + "properties": {"key": "properties", "type": "ResourceGroupProperties"}, + "location": {"key": "location", "type": "str"}, + "managed_by": {"key": "managedBy", "type": "str"}, + "tags": {"key": "tags", "type": "{str}"}, } def __init__( self, *, location: str, - properties: Optional["ResourceGroupProperties"] = None, + properties: Optional["_models.ResourceGroupProperties"] = None, managed_by: Optional[str] = None, tags: Optional[Dict[str, str]] = None, **kwargs @@ -1772,15 +1687,15 @@ def __init__( :keyword properties: The resource group properties. :paramtype properties: ~azure.mgmt.resource.resources.v2019_03_01.models.ResourceGroupProperties - :keyword location: Required. The location of the resource group. It cannot be changed after the - resource group has been created. It must be one of the supported Azure locations. + :keyword location: The location of the resource group. It cannot be changed after the resource + group has been created. It must be one of the supported Azure locations. Required. :paramtype location: str :keyword managed_by: The ID of the resource that manages this resource group. :paramtype managed_by: str - :keyword tags: A set of tags. The tags attached to the resource group. + :keyword tags: The tags attached to the resource group. :paramtype tags: dict[str, str] """ - super(ResourceGroup, self).__init__(**kwargs) + super().__init__(**kwargs) self.id = None self.name = None self.type = None @@ -1790,41 +1705,41 @@ def __init__( self.tags = tags -class ResourceGroupExportResult(msrest.serialization.Model): +class ResourceGroupExportResult(_serialization.Model): """Resource group export result. :ivar template: The template content. - :vartype template: any + :vartype template: JSON :ivar error: The error. :vartype error: ~azure.mgmt.resource.resources.v2019_03_01.models.ResourceManagementErrorWithDetails """ _attribute_map = { - 'template': {'key': 'template', 'type': 'object'}, - 'error': {'key': 'error', 'type': 'ResourceManagementErrorWithDetails'}, + "template": {"key": "template", "type": "object"}, + "error": {"key": "error", "type": "ResourceManagementErrorWithDetails"}, } def __init__( self, *, - template: Optional[Any] = None, - error: Optional["ResourceManagementErrorWithDetails"] = None, + template: Optional[JSON] = None, + error: Optional["_models.ResourceManagementErrorWithDetails"] = None, **kwargs ): """ :keyword template: The template content. - :paramtype template: any + :paramtype template: JSON :keyword error: The error. :paramtype error: ~azure.mgmt.resource.resources.v2019_03_01.models.ResourceManagementErrorWithDetails """ - super(ResourceGroupExportResult, self).__init__(**kwargs) + super().__init__(**kwargs) self.template = template self.error = error -class ResourceGroupFilter(msrest.serialization.Model): +class ResourceGroupFilter(_serialization.Model): """Resource group filter. :ivar tag_name: The tag name. @@ -1834,29 +1749,23 @@ class ResourceGroupFilter(msrest.serialization.Model): """ _attribute_map = { - 'tag_name': {'key': 'tagName', 'type': 'str'}, - 'tag_value': {'key': 'tagValue', 'type': 'str'}, + "tag_name": {"key": "tagName", "type": "str"}, + "tag_value": {"key": "tagValue", "type": "str"}, } - def __init__( - self, - *, - tag_name: Optional[str] = None, - tag_value: Optional[str] = None, - **kwargs - ): + def __init__(self, *, tag_name: Optional[str] = None, tag_value: Optional[str] = None, **kwargs): """ :keyword tag_name: The tag name. :paramtype tag_name: str :keyword tag_value: The tag value. :paramtype tag_value: str """ - super(ResourceGroupFilter, self).__init__(**kwargs) + super().__init__(**kwargs) self.tag_name = tag_name self.tag_value = tag_value -class ResourceGroupListResult(msrest.serialization.Model): +class ResourceGroupListResult(_serialization.Model): """List of resource groups. Variables are only populated by the server, and will be ignored when sending a request. @@ -1868,30 +1777,25 @@ class ResourceGroupListResult(msrest.serialization.Model): """ _validation = { - 'next_link': {'readonly': True}, + "next_link": {"readonly": True}, } _attribute_map = { - 'value': {'key': 'value', 'type': '[ResourceGroup]'}, - 'next_link': {'key': 'nextLink', 'type': 'str'}, + "value": {"key": "value", "type": "[ResourceGroup]"}, + "next_link": {"key": "nextLink", "type": "str"}, } - def __init__( - self, - *, - value: Optional[List["ResourceGroup"]] = None, - **kwargs - ): + def __init__(self, *, value: Optional[List["_models.ResourceGroup"]] = None, **kwargs): """ :keyword value: An array of resource groups. :paramtype value: list[~azure.mgmt.resource.resources.v2019_03_01.models.ResourceGroup] """ - super(ResourceGroupListResult, self).__init__(**kwargs) + super().__init__(**kwargs) self.value = value self.next_link = None -class ResourceGroupPatchable(msrest.serialization.Model): +class ResourceGroupPatchable(_serialization.Model): """Resource group information. :ivar name: The name of the resource group. @@ -1900,22 +1804,22 @@ class ResourceGroupPatchable(msrest.serialization.Model): :vartype properties: ~azure.mgmt.resource.resources.v2019_03_01.models.ResourceGroupProperties :ivar managed_by: The ID of the resource that manages this resource group. :vartype managed_by: str - :ivar tags: A set of tags. The tags attached to the resource group. + :ivar tags: The tags attached to the resource group. :vartype tags: dict[str, str] """ _attribute_map = { - 'name': {'key': 'name', 'type': 'str'}, - 'properties': {'key': 'properties', 'type': 'ResourceGroupProperties'}, - 'managed_by': {'key': 'managedBy', 'type': 'str'}, - 'tags': {'key': 'tags', 'type': '{str}'}, + "name": {"key": "name", "type": "str"}, + "properties": {"key": "properties", "type": "ResourceGroupProperties"}, + "managed_by": {"key": "managedBy", "type": "str"}, + "tags": {"key": "tags", "type": "{str}"}, } def __init__( self, *, name: Optional[str] = None, - properties: Optional["ResourceGroupProperties"] = None, + properties: Optional["_models.ResourceGroupProperties"] = None, managed_by: Optional[str] = None, tags: Optional[Dict[str, str]] = None, **kwargs @@ -1928,17 +1832,17 @@ def __init__( ~azure.mgmt.resource.resources.v2019_03_01.models.ResourceGroupProperties :keyword managed_by: The ID of the resource that manages this resource group. :paramtype managed_by: str - :keyword tags: A set of tags. The tags attached to the resource group. + :keyword tags: The tags attached to the resource group. :paramtype tags: dict[str, str] """ - super(ResourceGroupPatchable, self).__init__(**kwargs) + super().__init__(**kwargs) self.name = name self.properties = properties self.managed_by = managed_by self.tags = tags -class ResourceGroupProperties(msrest.serialization.Model): +class ResourceGroupProperties(_serialization.Model): """The resource group properties. Variables are only populated by the server, and will be ignored when sending a request. @@ -1948,24 +1852,20 @@ class ResourceGroupProperties(msrest.serialization.Model): """ _validation = { - 'provisioning_state': {'readonly': True}, + "provisioning_state": {"readonly": True}, } _attribute_map = { - 'provisioning_state': {'key': 'provisioningState', 'type': 'str'}, + "provisioning_state": {"key": "provisioningState", "type": "str"}, } - def __init__( - self, - **kwargs - ): - """ - """ - super(ResourceGroupProperties, self).__init__(**kwargs) + def __init__(self, **kwargs): + """ """ + super().__init__(**kwargs) self.provisioning_state = None -class ResourceListResult(msrest.serialization.Model): +class ResourceListResult(_serialization.Model): """List of resource groups. Variables are only populated by the server, and will be ignored when sending a request. @@ -1977,31 +1877,26 @@ class ResourceListResult(msrest.serialization.Model): """ _validation = { - 'next_link': {'readonly': True}, + "next_link": {"readonly": True}, } _attribute_map = { - 'value': {'key': 'value', 'type': '[GenericResourceExpanded]'}, - 'next_link': {'key': 'nextLink', 'type': 'str'}, + "value": {"key": "value", "type": "[GenericResourceExpanded]"}, + "next_link": {"key": "nextLink", "type": "str"}, } - def __init__( - self, - *, - value: Optional[List["GenericResourceExpanded"]] = None, - **kwargs - ): + def __init__(self, *, value: Optional[List["_models.GenericResourceExpanded"]] = None, **kwargs): """ :keyword value: An array of resources. :paramtype value: list[~azure.mgmt.resource.resources.v2019_03_01.models.GenericResourceExpanded] """ - super(ResourceListResult, self).__init__(**kwargs) + super().__init__(**kwargs) self.value = value self.next_link = None -class ResourceManagementErrorWithDetails(msrest.serialization.Model): +class ResourceManagementErrorWithDetails(_serialization.Model): """The detailed error message of resource management. Variables are only populated by the server, and will be ignored when sending a request. @@ -2018,33 +1913,29 @@ class ResourceManagementErrorWithDetails(msrest.serialization.Model): """ _validation = { - 'code': {'readonly': True}, - 'message': {'readonly': True}, - 'target': {'readonly': True}, - 'details': {'readonly': True}, + "code": {"readonly": True}, + "message": {"readonly": True}, + "target": {"readonly": True}, + "details": {"readonly": True}, } _attribute_map = { - 'code': {'key': 'code', 'type': 'str'}, - 'message': {'key': 'message', 'type': 'str'}, - 'target': {'key': 'target', 'type': 'str'}, - 'details': {'key': 'details', 'type': '[ResourceManagementErrorWithDetails]'}, + "code": {"key": "code", "type": "str"}, + "message": {"key": "message", "type": "str"}, + "target": {"key": "target", "type": "str"}, + "details": {"key": "details", "type": "[ResourceManagementErrorWithDetails]"}, } - def __init__( - self, - **kwargs - ): - """ - """ - super(ResourceManagementErrorWithDetails, self).__init__(**kwargs) + def __init__(self, **kwargs): + """ """ + super().__init__(**kwargs) self.code = None self.message = None self.target = None self.details = None -class ResourceProviderOperationDisplayProperties(msrest.serialization.Model): +class ResourceProviderOperationDisplayProperties(_serialization.Model): """Resource provider operation's display properties. :ivar publisher: Operation description. @@ -2060,11 +1951,11 @@ class ResourceProviderOperationDisplayProperties(msrest.serialization.Model): """ _attribute_map = { - 'publisher': {'key': 'publisher', 'type': 'str'}, - 'provider': {'key': 'provider', 'type': 'str'}, - 'resource': {'key': 'resource', 'type': 'str'}, - 'operation': {'key': 'operation', 'type': 'str'}, - 'description': {'key': 'description', 'type': 'str'}, + "publisher": {"key": "publisher", "type": "str"}, + "provider": {"key": "provider", "type": "str"}, + "resource": {"key": "resource", "type": "str"}, + "operation": {"key": "operation", "type": "str"}, + "description": {"key": "description", "type": "str"}, } def __init__( @@ -2089,7 +1980,7 @@ def __init__( :keyword description: Operation description. :paramtype description: str """ - super(ResourceProviderOperationDisplayProperties, self).__init__(**kwargs) + super().__init__(**kwargs) self.publisher = publisher self.provider = provider self.resource = resource @@ -2097,7 +1988,7 @@ def __init__( self.description = description -class ResourcesMoveInfo(msrest.serialization.Model): +class ResourcesMoveInfo(_serialization.Model): """Parameters of move resources. :ivar resources: The IDs of the resources. @@ -2107,29 +1998,23 @@ class ResourcesMoveInfo(msrest.serialization.Model): """ _attribute_map = { - 'resources': {'key': 'resources', 'type': '[str]'}, - 'target_resource_group': {'key': 'targetResourceGroup', 'type': 'str'}, + "resources": {"key": "resources", "type": "[str]"}, + "target_resource_group": {"key": "targetResourceGroup", "type": "str"}, } - def __init__( - self, - *, - resources: Optional[List[str]] = None, - target_resource_group: Optional[str] = None, - **kwargs - ): + def __init__(self, *, resources: Optional[List[str]] = None, target_resource_group: Optional[str] = None, **kwargs): """ :keyword resources: The IDs of the resources. :paramtype resources: list[str] :keyword target_resource_group: The target resource group. :paramtype target_resource_group: str """ - super(ResourcesMoveInfo, self).__init__(**kwargs) + super().__init__(**kwargs) self.resources = resources self.target_resource_group = target_resource_group -class Sku(msrest.serialization.Model): +class Sku(_serialization.Model): """SKU for the resource. :ivar name: The SKU name. @@ -2147,12 +2032,12 @@ class Sku(msrest.serialization.Model): """ _attribute_map = { - 'name': {'key': 'name', 'type': 'str'}, - 'tier': {'key': 'tier', 'type': 'str'}, - 'size': {'key': 'size', 'type': 'str'}, - 'family': {'key': 'family', 'type': 'str'}, - 'model': {'key': 'model', 'type': 'str'}, - 'capacity': {'key': 'capacity', 'type': 'int'}, + "name": {"key": "name", "type": "str"}, + "tier": {"key": "tier", "type": "str"}, + "size": {"key": "size", "type": "str"}, + "family": {"key": "family", "type": "str"}, + "model": {"key": "model", "type": "str"}, + "capacity": {"key": "capacity", "type": "int"}, } def __init__( @@ -2180,7 +2065,7 @@ def __init__( :keyword capacity: The SKU capacity. :paramtype capacity: int """ - super(Sku, self).__init__(**kwargs) + super().__init__(**kwargs) self.name = name self.tier = tier self.size = size @@ -2189,7 +2074,7 @@ def __init__( self.capacity = capacity -class SubResource(msrest.serialization.Model): +class SubResource(_serialization.Model): """Sub-resource. :ivar id: Resource ID. @@ -2197,24 +2082,19 @@ class SubResource(msrest.serialization.Model): """ _attribute_map = { - 'id': {'key': 'id', 'type': 'str'}, + "id": {"key": "id", "type": "str"}, } - def __init__( - self, - *, - id: Optional[str] = None, - **kwargs - ): + def __init__(self, *, id: Optional[str] = None, **kwargs): # pylint: disable=redefined-builtin """ :keyword id: Resource ID. :paramtype id: str """ - super(SubResource, self).__init__(**kwargs) + super().__init__(**kwargs) self.id = id -class TagCount(msrest.serialization.Model): +class TagCount(_serialization.Model): """Tag count. :ivar type: Type of count. @@ -2224,29 +2104,23 @@ class TagCount(msrest.serialization.Model): """ _attribute_map = { - 'type': {'key': 'type', 'type': 'str'}, - 'value': {'key': 'value', 'type': 'int'}, + "type": {"key": "type", "type": "str"}, + "value": {"key": "value", "type": "int"}, } - def __init__( - self, - *, - type: Optional[str] = None, - value: Optional[int] = None, - **kwargs - ): + def __init__(self, *, type: Optional[str] = None, value: Optional[int] = None, **kwargs): """ :keyword type: Type of count. :paramtype type: str :keyword value: Value of count. :paramtype value: int """ - super(TagCount, self).__init__(**kwargs) + super().__init__(**kwargs) self.type = type self.value = value -class TagDetails(msrest.serialization.Model): +class TagDetails(_serialization.Model): """Tag details. Variables are only populated by the server, and will be ignored when sending a request. @@ -2263,22 +2137,22 @@ class TagDetails(msrest.serialization.Model): """ _validation = { - 'id': {'readonly': True}, + "id": {"readonly": True}, } _attribute_map = { - 'id': {'key': 'id', 'type': 'str'}, - 'tag_name': {'key': 'tagName', 'type': 'str'}, - 'count': {'key': 'count', 'type': 'TagCount'}, - 'values': {'key': 'values', 'type': '[TagValue]'}, + "id": {"key": "id", "type": "str"}, + "tag_name": {"key": "tagName", "type": "str"}, + "count": {"key": "count", "type": "TagCount"}, + "values": {"key": "values", "type": "[TagValue]"}, } def __init__( self, *, tag_name: Optional[str] = None, - count: Optional["TagCount"] = None, - values: Optional[List["TagValue"]] = None, + count: Optional["_models.TagCount"] = None, + values: Optional[List["_models.TagValue"]] = None, **kwargs ): """ @@ -2290,14 +2164,14 @@ def __init__( :keyword values: The list of tag values. :paramtype values: list[~azure.mgmt.resource.resources.v2019_03_01.models.TagValue] """ - super(TagDetails, self).__init__(**kwargs) + super().__init__(**kwargs) self.id = None self.tag_name = tag_name self.count = count self.values = values -class TagsListResult(msrest.serialization.Model): +class TagsListResult(_serialization.Model): """List of subscription tags. Variables are only populated by the server, and will be ignored when sending a request. @@ -2309,30 +2183,25 @@ class TagsListResult(msrest.serialization.Model): """ _validation = { - 'next_link': {'readonly': True}, + "next_link": {"readonly": True}, } _attribute_map = { - 'value': {'key': 'value', 'type': '[TagDetails]'}, - 'next_link': {'key': 'nextLink', 'type': 'str'}, + "value": {"key": "value", "type": "[TagDetails]"}, + "next_link": {"key": "nextLink", "type": "str"}, } - def __init__( - self, - *, - value: Optional[List["TagDetails"]] = None, - **kwargs - ): + def __init__(self, *, value: Optional[List["_models.TagDetails"]] = None, **kwargs): """ :keyword value: An array of tags. :paramtype value: list[~azure.mgmt.resource.resources.v2019_03_01.models.TagDetails] """ - super(TagsListResult, self).__init__(**kwargs) + super().__init__(**kwargs) self.value = value self.next_link = None -class TagValue(msrest.serialization.Model): +class TagValue(_serialization.Model): """Tag information. Variables are only populated by the server, and will be ignored when sending a request. @@ -2346,35 +2215,29 @@ class TagValue(msrest.serialization.Model): """ _validation = { - 'id': {'readonly': True}, + "id": {"readonly": True}, } _attribute_map = { - 'id': {'key': 'id', 'type': 'str'}, - 'tag_value': {'key': 'tagValue', 'type': 'str'}, - 'count': {'key': 'count', 'type': 'TagCount'}, + "id": {"key": "id", "type": "str"}, + "tag_value": {"key": "tagValue", "type": "str"}, + "count": {"key": "count", "type": "TagCount"}, } - def __init__( - self, - *, - tag_value: Optional[str] = None, - count: Optional["TagCount"] = None, - **kwargs - ): + def __init__(self, *, tag_value: Optional[str] = None, count: Optional["_models.TagCount"] = None, **kwargs): """ :keyword tag_value: The tag value. :paramtype tag_value: str :keyword count: The tag value count. :paramtype count: ~azure.mgmt.resource.resources.v2019_03_01.models.TagCount """ - super(TagValue, self).__init__(**kwargs) + super().__init__(**kwargs) self.id = None self.tag_value = tag_value self.count = count -class TargetResource(msrest.serialization.Model): +class TargetResource(_serialization.Model): """Target resource. :ivar id: The ID of the resource. @@ -2386,15 +2249,15 @@ class TargetResource(msrest.serialization.Model): """ _attribute_map = { - 'id': {'key': 'id', 'type': 'str'}, - 'resource_name': {'key': 'resourceName', 'type': 'str'}, - 'resource_type': {'key': 'resourceType', 'type': 'str'}, + "id": {"key": "id", "type": "str"}, + "resource_name": {"key": "resourceName", "type": "str"}, + "resource_type": {"key": "resourceType", "type": "str"}, } def __init__( self, *, - id: Optional[str] = None, + id: Optional[str] = None, # pylint: disable=redefined-builtin resource_name: Optional[str] = None, resource_type: Optional[str] = None, **kwargs @@ -2407,13 +2270,13 @@ def __init__( :keyword resource_type: The type of the resource. :paramtype resource_type: str """ - super(TargetResource, self).__init__(**kwargs) + super().__init__(**kwargs) self.id = id self.resource_name = resource_name self.resource_type = resource_type -class TemplateHashResult(msrest.serialization.Model): +class TemplateHashResult(_serialization.Model): """Result of the request to calculate template hash. It contains a string of minified template and its hash. :ivar minified_template: The minified template string. @@ -2423,67 +2286,55 @@ class TemplateHashResult(msrest.serialization.Model): """ _attribute_map = { - 'minified_template': {'key': 'minifiedTemplate', 'type': 'str'}, - 'template_hash': {'key': 'templateHash', 'type': 'str'}, + "minified_template": {"key": "minifiedTemplate", "type": "str"}, + "template_hash": {"key": "templateHash", "type": "str"}, } - def __init__( - self, - *, - minified_template: Optional[str] = None, - template_hash: Optional[str] = None, - **kwargs - ): + def __init__(self, *, minified_template: Optional[str] = None, template_hash: Optional[str] = None, **kwargs): """ :keyword minified_template: The minified template string. :paramtype minified_template: str :keyword template_hash: The template hash. :paramtype template_hash: str """ - super(TemplateHashResult, self).__init__(**kwargs) + super().__init__(**kwargs) self.minified_template = minified_template self.template_hash = template_hash -class TemplateLink(msrest.serialization.Model): +class TemplateLink(_serialization.Model): """Entity representing the reference to the template. All required parameters must be populated in order to send to Azure. - :ivar uri: Required. The URI of the template to deploy. + :ivar uri: The URI of the template to deploy. Required. :vartype uri: str :ivar content_version: If included, must match the ContentVersion in the template. :vartype content_version: str """ _validation = { - 'uri': {'required': True}, + "uri": {"required": True}, } _attribute_map = { - 'uri': {'key': 'uri', 'type': 'str'}, - 'content_version': {'key': 'contentVersion', 'type': 'str'}, + "uri": {"key": "uri", "type": "str"}, + "content_version": {"key": "contentVersion", "type": "str"}, } - def __init__( - self, - *, - uri: str, - content_version: Optional[str] = None, - **kwargs - ): + def __init__(self, *, uri: str, content_version: Optional[str] = None, **kwargs): """ - :keyword uri: Required. The URI of the template to deploy. + :keyword uri: The URI of the template to deploy. Required. :paramtype uri: str :keyword content_version: If included, must match the ContentVersion in the template. :paramtype content_version: str """ - super(TemplateLink, self).__init__(**kwargs) + super().__init__(**kwargs) self.uri = uri self.content_version = content_version -class ZoneMapping(msrest.serialization.Model): +class ZoneMapping(_serialization.Model): """ZoneMapping. :ivar location: The location of the zone mapping. @@ -2493,23 +2344,17 @@ class ZoneMapping(msrest.serialization.Model): """ _attribute_map = { - 'location': {'key': 'location', 'type': 'str'}, - 'zones': {'key': 'zones', 'type': '[str]'}, + "location": {"key": "location", "type": "str"}, + "zones": {"key": "zones", "type": "[str]"}, } - def __init__( - self, - *, - location: Optional[str] = None, - zones: Optional[List[str]] = None, - **kwargs - ): + def __init__(self, *, location: Optional[str] = None, zones: Optional[List[str]] = None, **kwargs): """ :keyword location: The location of the zone mapping. :paramtype location: str :keyword zones: :paramtype zones: list[str] """ - super(ZoneMapping, self).__init__(**kwargs) + super().__init__(**kwargs) self.location = location self.zones = zones diff --git a/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/resources/v2019_03_01/models/_patch.py b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/resources/v2019_03_01/models/_patch.py new file mode 100644 index 0000000000000..f7dd32510333d --- /dev/null +++ b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/resources/v2019_03_01/models/_patch.py @@ -0,0 +1,20 @@ +# ------------------------------------ +# Copyright (c) Microsoft Corporation. +# Licensed under the MIT License. +# ------------------------------------ +"""Customize generated code here. + +Follow our quickstart for examples: https://aka.ms/azsdk/python/dpcodegen/python/customize +""" +from typing import List + +__all__: List[str] = [] # Add all objects you want publicly available to users at this package level + + +def patch_sdk(): + """Do not remove from this file. + + `patch_sdk` is a last resort escape hatch that allows you to do customizations + you can't accomplish using the techniques described in + https://aka.ms/azsdk/python/dpcodegen/python/customize + """ diff --git a/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/resources/v2019_03_01/models/_resource_management_client_enums.py b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/resources/v2019_03_01/models/_resource_management_client_enums.py index 02799db402bcc..612a5242cd9bd 100644 --- a/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/resources/v2019_03_01/models/_resource_management_client_enums.py +++ b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/resources/v2019_03_01/models/_resource_management_client_enums.py @@ -7,11 +7,10 @@ # -------------------------------------------------------------------------- from enum import Enum -from six import with_metaclass from azure.core import CaseInsensitiveEnumMeta -class DeploymentMode(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): +class DeploymentMode(str, Enum, metaclass=CaseInsensitiveEnumMeta): """The mode that is used to deploy resources. This value can be either Incremental or Complete. In Incremental mode, resources are deployed without deleting existing resources that are not included in the template. In Complete mode, resources are deployed and existing resources in @@ -22,7 +21,8 @@ class DeploymentMode(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): INCREMENTAL = "Incremental" COMPLETE = "Complete" -class OnErrorDeploymentType(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): + +class OnErrorDeploymentType(str, Enum, metaclass=CaseInsensitiveEnumMeta): """The deployment on error behavior type. Possible values are LastSuccessful and SpecificDeployment. """ @@ -30,9 +30,9 @@ class OnErrorDeploymentType(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): LAST_SUCCESSFUL = "LastSuccessful" SPECIFIC_DEPLOYMENT = "SpecificDeployment" -class ResourceIdentityType(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): - """The identity type. - """ + +class ResourceIdentityType(str, Enum, metaclass=CaseInsensitiveEnumMeta): + """The identity type.""" SYSTEM_ASSIGNED = "SystemAssigned" USER_ASSIGNED = "UserAssigned" diff --git a/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/resources/v2019_03_01/operations/__init__.py b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/resources/v2019_03_01/operations/__init__.py index 53876d82bf5d7..804fee65e3137 100644 --- a/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/resources/v2019_03_01/operations/__init__.py +++ b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/resources/v2019_03_01/operations/__init__.py @@ -14,12 +14,18 @@ from ._operations import TagsOperations from ._operations import DeploymentOperationsOperations +from ._patch import __all__ as _patch_all +from ._patch import * # type: ignore # pylint: disable=unused-wildcard-import +from ._patch import patch_sdk as _patch_sdk + __all__ = [ - 'Operations', - 'DeploymentsOperations', - 'ProvidersOperations', - 'ResourcesOperations', - 'ResourceGroupsOperations', - 'TagsOperations', - 'DeploymentOperationsOperations', + "Operations", + "DeploymentsOperations", + "ProvidersOperations", + "ResourcesOperations", + "ResourceGroupsOperations", + "TagsOperations", + "DeploymentOperationsOperations", ] +__all__.extend([p for p in _patch_all if p not in __all__]) +_patch_sdk() diff --git a/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/resources/v2019_03_01/operations/_operations.py b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/resources/v2019_03_01/operations/_operations.py index a614f0aa80737..609992773216d 100644 --- a/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/resources/v2019_03_01/operations/_operations.py +++ b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/resources/v2019_03_01/operations/_operations.py @@ -6,578 +6,532 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -from typing import Any, Callable, Dict, Iterable, Optional, TypeVar, Union - -from msrest import Serializer - -from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error +import sys +from typing import Any, Callable, Dict, IO, Iterable, Optional, TypeVar, Union, cast, overload +from urllib.parse import parse_qs, urljoin, urlparse + +from azure.core.exceptions import ( + ClientAuthenticationError, + HttpResponseError, + ResourceExistsError, + ResourceNotFoundError, + ResourceNotModifiedError, + map_error, +) from azure.core.paging import ItemPaged from azure.core.pipeline import PipelineResponse from azure.core.pipeline.transport import HttpResponse from azure.core.polling import LROPoller, NoPolling, PollingMethod from azure.core.rest import HttpRequest from azure.core.tracing.decorator import distributed_trace +from azure.core.utils import case_insensitive_dict from azure.mgmt.core.exceptions import ARMErrorFormat from azure.mgmt.core.polling.arm_polling import ARMPolling from .. import models as _models +from ..._serialization import Serializer from .._vendor import _convert_request, _format_url_section -T = TypeVar('T') + +T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] -JSONType = Any +if sys.version_info >= (3, 9): + from collections.abc import MutableMapping +else: + from typing import MutableMapping # type: ignore # pylint: disable=ungrouped-imports +JSON = MutableMapping[str, Any] # pylint: disable=unsubscriptable-object _SERIALIZER = Serializer() _SERIALIZER.client_side_validation = False -def build_operations_list_request( - **kwargs: Any -) -> HttpRequest: - api_version = kwargs.pop('api_version', "2019-03-01") # type: str - accept = "application/json" +def build_operations_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", "2019-03-01")) # type: str + accept = _headers.pop("Accept", "application/json") + # Construct URL _url = kwargs.pop("template_url", "/providers/Microsoft.Resources/operations") # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') - - return HttpRequest( - method="GET", - url=_url, - params=_query_parameters, - headers=_header_parameters, - **kwargs - ) + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) -def build_deployments_delete_at_subscription_scope_request_initial( - deployment_name: str, - subscription_id: str, - **kwargs: Any + +def build_deployments_delete_at_subscription_scope_request( + deployment_name: str, subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2019-03-01") # type: str + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + api_version = kwargs.pop("api_version", _params.pop("api-version", "2019-03-01")) # type: str # Construct URL - _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/providers/Microsoft.Resources/deployments/{deploymentName}") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", "/subscriptions/{subscriptionId}/providers/Microsoft.Resources/deployments/{deploymentName}" + ) # pylint: disable=line-too-long path_format_arguments = { - "deploymentName": _SERIALIZER.url("deployment_name", deployment_name, 'str', max_length=64, min_length=1, pattern=r'^[-\w\._\(\)]+$'), - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), + "deploymentName": _SERIALIZER.url( + "deployment_name", deployment_name, "str", max_length=64, min_length=1, pattern=r"^[-\w\._\(\)]+$" + ), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), } _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') - - return HttpRequest( - method="DELETE", - url=_url, - params=_query_parameters, - **kwargs - ) + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") + + return HttpRequest(method="DELETE", url=_url, params=_params, **kwargs) def build_deployments_check_existence_at_subscription_scope_request( - deployment_name: str, - subscription_id: str, - **kwargs: Any + deployment_name: str, subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2019-03-01") # type: str + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + api_version = kwargs.pop("api_version", _params.pop("api-version", "2019-03-01")) # type: str # Construct URL - _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/providers/Microsoft.Resources/deployments/{deploymentName}") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", "/subscriptions/{subscriptionId}/providers/Microsoft.Resources/deployments/{deploymentName}" + ) # pylint: disable=line-too-long path_format_arguments = { - "deploymentName": _SERIALIZER.url("deployment_name", deployment_name, 'str', max_length=64, min_length=1, pattern=r'^[-\w\._\(\)]+$'), - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), + "deploymentName": _SERIALIZER.url( + "deployment_name", deployment_name, "str", max_length=64, min_length=1, pattern=r"^[-\w\._\(\)]+$" + ), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), } _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') - - return HttpRequest( - method="HEAD", - url=_url, - params=_query_parameters, - **kwargs - ) + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") + return HttpRequest(method="HEAD", url=_url, params=_params, **kwargs) -def build_deployments_create_or_update_at_subscription_scope_request_initial( - deployment_name: str, - subscription_id: str, - *, - json: JSONType = None, - content: Any = None, - **kwargs: Any + +def build_deployments_create_or_update_at_subscription_scope_request( + deployment_name: str, subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2019-03-01") # type: str - content_type = kwargs.pop('content_type', None) # type: Optional[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", "2019-03-01")) # type: str + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + accept = _headers.pop("Accept", "application/json") - accept = "application/json" # Construct URL - _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/providers/Microsoft.Resources/deployments/{deploymentName}") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", "/subscriptions/{subscriptionId}/providers/Microsoft.Resources/deployments/{deploymentName}" + ) # pylint: disable=line-too-long path_format_arguments = { - "deploymentName": _SERIALIZER.url("deployment_name", deployment_name, 'str', max_length=64, min_length=1, pattern=r'^[-\w\._\(\)]+$'), - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), + "deploymentName": _SERIALIZER.url( + "deployment_name", deployment_name, "str", max_length=64, min_length=1, pattern=r"^[-\w\._\(\)]+$" + ), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), } _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] if content_type is not None: - _header_parameters['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') - _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') - - return HttpRequest( - method="PUT", - url=_url, - params=_query_parameters, - headers=_header_parameters, - json=json, - content=content, - **kwargs - ) + _headers["Content-Type"] = _SERIALIZER.header("content_type", content_type, "str") + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="PUT", url=_url, params=_params, headers=_headers, **kwargs) def build_deployments_get_at_subscription_scope_request( - deployment_name: str, - subscription_id: str, - **kwargs: Any + deployment_name: str, subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2019-03-01") # type: 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", "2019-03-01")) # type: str + accept = _headers.pop("Accept", "application/json") - accept = "application/json" # Construct URL - _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/providers/Microsoft.Resources/deployments/{deploymentName}") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", "/subscriptions/{subscriptionId}/providers/Microsoft.Resources/deployments/{deploymentName}" + ) # pylint: disable=line-too-long path_format_arguments = { - "deploymentName": _SERIALIZER.url("deployment_name", deployment_name, 'str', max_length=64, min_length=1, pattern=r'^[-\w\._\(\)]+$'), - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), + "deploymentName": _SERIALIZER.url( + "deployment_name", deployment_name, "str", max_length=64, min_length=1, pattern=r"^[-\w\._\(\)]+$" + ), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), } _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') - - return HttpRequest( - method="GET", - url=_url, - params=_query_parameters, - headers=_header_parameters, - **kwargs - ) + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) def build_deployments_cancel_at_subscription_scope_request( - deployment_name: str, - subscription_id: str, - **kwargs: Any + deployment_name: str, subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2019-03-01") # type: str + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + api_version = kwargs.pop("api_version", _params.pop("api-version", "2019-03-01")) # type: str # Construct URL - _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/providers/Microsoft.Resources/deployments/{deploymentName}/cancel") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/providers/Microsoft.Resources/deployments/{deploymentName}/cancel", + ) # pylint: disable=line-too-long path_format_arguments = { - "deploymentName": _SERIALIZER.url("deployment_name", deployment_name, 'str', max_length=64, min_length=1, pattern=r'^[-\w\._\(\)]+$'), - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), + "deploymentName": _SERIALIZER.url( + "deployment_name", deployment_name, "str", max_length=64, min_length=1, pattern=r"^[-\w\._\(\)]+$" + ), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), } _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') - - return HttpRequest( - method="POST", - url=_url, - params=_query_parameters, - **kwargs - ) + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") + + return HttpRequest(method="POST", url=_url, params=_params, **kwargs) def build_deployments_validate_at_subscription_scope_request( - deployment_name: str, - subscription_id: str, - *, - json: JSONType = None, - content: Any = None, - **kwargs: Any + deployment_name: str, subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2019-03-01") # type: str - content_type = kwargs.pop('content_type', None) # type: Optional[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", "2019-03-01")) # type: str + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + accept = _headers.pop("Accept", "application/json") - accept = "application/json" # Construct URL - _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/providers/Microsoft.Resources/deployments/{deploymentName}/validate") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/providers/Microsoft.Resources/deployments/{deploymentName}/validate", + ) # pylint: disable=line-too-long path_format_arguments = { - "deploymentName": _SERIALIZER.url("deployment_name", deployment_name, 'str', max_length=64, min_length=1, pattern=r'^[-\w\._\(\)]+$'), - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), + "deploymentName": _SERIALIZER.url( + "deployment_name", deployment_name, "str", max_length=64, min_length=1, pattern=r"^[-\w\._\(\)]+$" + ), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), } _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] if content_type is not None: - _header_parameters['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') - _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') - - return HttpRequest( - method="POST", - url=_url, - params=_query_parameters, - headers=_header_parameters, - json=json, - content=content, - **kwargs - ) + _headers["Content-Type"] = _SERIALIZER.header("content_type", content_type, "str") + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="POST", url=_url, params=_params, headers=_headers, **kwargs) def build_deployments_export_template_at_subscription_scope_request( - deployment_name: str, - subscription_id: str, - **kwargs: Any + deployment_name: str, subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2019-03-01") # type: 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", "2019-03-01")) # type: str + accept = _headers.pop("Accept", "application/json") - accept = "application/json" # Construct URL - _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/providers/Microsoft.Resources/deployments/{deploymentName}/exportTemplate") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/providers/Microsoft.Resources/deployments/{deploymentName}/exportTemplate", + ) # pylint: disable=line-too-long path_format_arguments = { - "deploymentName": _SERIALIZER.url("deployment_name", deployment_name, 'str', max_length=64, min_length=1, pattern=r'^[-\w\._\(\)]+$'), - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), + "deploymentName": _SERIALIZER.url( + "deployment_name", deployment_name, "str", max_length=64, min_length=1, pattern=r"^[-\w\._\(\)]+$" + ), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), } _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') - - return HttpRequest( - method="POST", - url=_url, - params=_query_parameters, - headers=_header_parameters, - **kwargs - ) + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="POST", url=_url, params=_params, headers=_headers, **kwargs) def build_deployments_list_at_subscription_scope_request( - subscription_id: str, - *, - filter: Optional[str] = None, - top: Optional[int] = None, - **kwargs: Any + subscription_id: str, *, filter: Optional[str] = None, top: Optional[int] = None, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2019-03-01") # type: 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", "2019-03-01")) # type: str + accept = _headers.pop("Accept", "application/json") - accept = "application/json" # Construct URL _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/providers/Microsoft.Resources/deployments/") path_format_arguments = { - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), } _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] if filter is not None: - _query_parameters['$filter'] = _SERIALIZER.query("filter", filter, 'str') + _params["$filter"] = _SERIALIZER.query("filter", filter, "str") if top is not None: - _query_parameters['$top'] = _SERIALIZER.query("top", top, 'int') - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["$top"] = _SERIALIZER.query("top", top, "int") + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') - - return HttpRequest( - method="GET", - url=_url, - params=_query_parameters, - headers=_header_parameters, - **kwargs - ) + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) -def build_deployments_delete_request_initial( - resource_group_name: str, - deployment_name: str, - subscription_id: str, - **kwargs: Any + +def build_deployments_delete_request( + resource_group_name: str, deployment_name: str, subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2019-03-01") # type: str + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + api_version = kwargs.pop("api_version", _params.pop("api-version", "2019-03-01")) # type: str # Construct URL - _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/Microsoft.Resources/deployments/{deploymentName}") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/Microsoft.Resources/deployments/{deploymentName}", + ) # pylint: disable=line-too-long path_format_arguments = { - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._\(\)]+$'), - "deploymentName": _SERIALIZER.url("deployment_name", deployment_name, 'str', max_length=64, min_length=1, pattern=r'^[-\w\._\(\)]+$'), - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), + "resourceGroupName": _SERIALIZER.url( + "resource_group_name", resource_group_name, "str", max_length=90, min_length=1, pattern=r"^[-\w\._\(\)]+$" + ), + "deploymentName": _SERIALIZER.url( + "deployment_name", deployment_name, "str", max_length=64, min_length=1, pattern=r"^[-\w\._\(\)]+$" + ), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), } _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') - - return HttpRequest( - method="DELETE", - url=_url, - params=_query_parameters, - **kwargs - ) + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") + + return HttpRequest(method="DELETE", url=_url, params=_params, **kwargs) def build_deployments_check_existence_request( - resource_group_name: str, - deployment_name: str, - subscription_id: str, - **kwargs: Any + resource_group_name: str, deployment_name: str, subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2019-03-01") # type: str + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + api_version = kwargs.pop("api_version", _params.pop("api-version", "2019-03-01")) # type: str # Construct URL - _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/Microsoft.Resources/deployments/{deploymentName}") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/Microsoft.Resources/deployments/{deploymentName}", + ) # pylint: disable=line-too-long path_format_arguments = { - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._\(\)]+$'), - "deploymentName": _SERIALIZER.url("deployment_name", deployment_name, 'str', max_length=64, min_length=1, pattern=r'^[-\w\._\(\)]+$'), - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), + "resourceGroupName": _SERIALIZER.url( + "resource_group_name", resource_group_name, "str", max_length=90, min_length=1, pattern=r"^[-\w\._\(\)]+$" + ), + "deploymentName": _SERIALIZER.url( + "deployment_name", deployment_name, "str", max_length=64, min_length=1, pattern=r"^[-\w\._\(\)]+$" + ), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), } _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') - - return HttpRequest( - method="HEAD", - url=_url, - params=_query_parameters, - **kwargs - ) + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") + return HttpRequest(method="HEAD", url=_url, params=_params, **kwargs) -def build_deployments_create_or_update_request_initial( - resource_group_name: str, - deployment_name: str, - subscription_id: str, - *, - json: JSONType = None, - content: Any = None, - **kwargs: Any + +def build_deployments_create_or_update_request( + resource_group_name: str, deployment_name: str, subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2019-03-01") # type: str - content_type = kwargs.pop('content_type', None) # type: Optional[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", "2019-03-01")) # type: str + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + accept = _headers.pop("Accept", "application/json") - accept = "application/json" # Construct URL - _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/Microsoft.Resources/deployments/{deploymentName}") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/Microsoft.Resources/deployments/{deploymentName}", + ) # pylint: disable=line-too-long path_format_arguments = { - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._\(\)]+$'), - "deploymentName": _SERIALIZER.url("deployment_name", deployment_name, 'str', max_length=64, min_length=1, pattern=r'^[-\w\._\(\)]+$'), - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), + "resourceGroupName": _SERIALIZER.url( + "resource_group_name", resource_group_name, "str", max_length=90, min_length=1, pattern=r"^[-\w\._\(\)]+$" + ), + "deploymentName": _SERIALIZER.url( + "deployment_name", deployment_name, "str", max_length=64, min_length=1, pattern=r"^[-\w\._\(\)]+$" + ), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), } _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] if content_type is not None: - _header_parameters['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') - _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') - - return HttpRequest( - method="PUT", - url=_url, - params=_query_parameters, - headers=_header_parameters, - json=json, - content=content, - **kwargs - ) + _headers["Content-Type"] = _SERIALIZER.header("content_type", content_type, "str") + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="PUT", url=_url, params=_params, headers=_headers, **kwargs) def build_deployments_get_request( - resource_group_name: str, - deployment_name: str, - subscription_id: str, - **kwargs: Any + resource_group_name: str, deployment_name: str, subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2019-03-01") # type: 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", "2019-03-01")) # type: str + accept = _headers.pop("Accept", "application/json") - accept = "application/json" # Construct URL - _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/Microsoft.Resources/deployments/{deploymentName}") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/Microsoft.Resources/deployments/{deploymentName}", + ) # pylint: disable=line-too-long path_format_arguments = { - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._\(\)]+$'), - "deploymentName": _SERIALIZER.url("deployment_name", deployment_name, 'str', max_length=64, min_length=1, pattern=r'^[-\w\._\(\)]+$'), - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), + "resourceGroupName": _SERIALIZER.url( + "resource_group_name", resource_group_name, "str", max_length=90, min_length=1, pattern=r"^[-\w\._\(\)]+$" + ), + "deploymentName": _SERIALIZER.url( + "deployment_name", deployment_name, "str", max_length=64, min_length=1, pattern=r"^[-\w\._\(\)]+$" + ), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), } _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') - - return HttpRequest( - method="GET", - url=_url, - params=_query_parameters, - headers=_header_parameters, - **kwargs - ) + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) def build_deployments_cancel_request( - resource_group_name: str, - deployment_name: str, - subscription_id: str, - **kwargs: Any + resource_group_name: str, deployment_name: str, subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2019-03-01") # type: str + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + api_version = kwargs.pop("api_version", _params.pop("api-version", "2019-03-01")) # type: str # Construct URL - _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/Microsoft.Resources/deployments/{deploymentName}/cancel") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/Microsoft.Resources/deployments/{deploymentName}/cancel", + ) # pylint: disable=line-too-long path_format_arguments = { - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._\(\)]+$'), - "deploymentName": _SERIALIZER.url("deployment_name", deployment_name, 'str', max_length=64, min_length=1, pattern=r'^[-\w\._\(\)]+$'), - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), + "resourceGroupName": _SERIALIZER.url( + "resource_group_name", resource_group_name, "str", max_length=90, min_length=1, pattern=r"^[-\w\._\(\)]+$" + ), + "deploymentName": _SERIALIZER.url( + "deployment_name", deployment_name, "str", max_length=64, min_length=1, pattern=r"^[-\w\._\(\)]+$" + ), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), } _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') - - return HttpRequest( - method="POST", - url=_url, - params=_query_parameters, - **kwargs - ) + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") + + return HttpRequest(method="POST", url=_url, params=_params, **kwargs) def build_deployments_validate_request( - resource_group_name: str, - deployment_name: str, - subscription_id: str, - *, - json: JSONType = None, - content: Any = None, - **kwargs: Any + resource_group_name: str, deployment_name: str, subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2019-03-01") # type: str - content_type = kwargs.pop('content_type', None) # type: Optional[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", "2019-03-01")) # type: str + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + accept = _headers.pop("Accept", "application/json") - accept = "application/json" # Construct URL - _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/Microsoft.Resources/deployments/{deploymentName}/validate") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/Microsoft.Resources/deployments/{deploymentName}/validate", + ) # pylint: disable=line-too-long path_format_arguments = { - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._\(\)]+$'), - "deploymentName": _SERIALIZER.url("deployment_name", deployment_name, 'str', max_length=64, min_length=1, pattern=r'^[-\w\._\(\)]+$'), - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), + "resourceGroupName": _SERIALIZER.url( + "resource_group_name", resource_group_name, "str", max_length=90, min_length=1, pattern=r"^[-\w\._\(\)]+$" + ), + "deploymentName": _SERIALIZER.url( + "deployment_name", deployment_name, "str", max_length=64, min_length=1, pattern=r"^[-\w\._\(\)]+$" + ), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), } _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] if content_type is not None: - _header_parameters['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') - _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') - - return HttpRequest( - method="POST", - url=_url, - params=_query_parameters, - headers=_header_parameters, - json=json, - content=content, - **kwargs - ) + _headers["Content-Type"] = _SERIALIZER.header("content_type", content_type, "str") + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="POST", url=_url, params=_params, headers=_headers, **kwargs) def build_deployments_export_template_request( - resource_group_name: str, - deployment_name: str, - subscription_id: str, - **kwargs: Any + resource_group_name: str, deployment_name: str, subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2019-03-01") # type: 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", "2019-03-01")) # type: str + accept = _headers.pop("Accept", "application/json") - accept = "application/json" # Construct URL - _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/Microsoft.Resources/deployments/{deploymentName}/exportTemplate") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/Microsoft.Resources/deployments/{deploymentName}/exportTemplate", + ) # pylint: disable=line-too-long path_format_arguments = { - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._\(\)]+$'), - "deploymentName": _SERIALIZER.url("deployment_name", deployment_name, 'str', max_length=64, min_length=1, pattern=r'^[-\w\._\(\)]+$'), - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), + "resourceGroupName": _SERIALIZER.url( + "resource_group_name", resource_group_name, "str", max_length=90, min_length=1, pattern=r"^[-\w\._\(\)]+$" + ), + "deploymentName": _SERIALIZER.url( + "deployment_name", deployment_name, "str", max_length=64, min_length=1, pattern=r"^[-\w\._\(\)]+$" + ), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), } _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') - - return HttpRequest( - method="POST", - url=_url, - params=_query_parameters, - headers=_header_parameters, - **kwargs - ) + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="POST", url=_url, params=_params, headers=_headers, **kwargs) def build_deployments_list_by_resource_group_request( @@ -588,216 +542,174 @@ def build_deployments_list_by_resource_group_request( top: Optional[int] = None, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2019-03-01") # type: 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", "2019-03-01")) # type: str + accept = _headers.pop("Accept", "application/json") - accept = "application/json" # Construct URL - _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/Microsoft.Resources/deployments/") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/Microsoft.Resources/deployments/", + ) # pylint: disable=line-too-long path_format_arguments = { - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._\(\)]+$'), - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), + "resourceGroupName": _SERIALIZER.url( + "resource_group_name", resource_group_name, "str", max_length=90, min_length=1, pattern=r"^[-\w\._\(\)]+$" + ), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), } _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] if filter is not None: - _query_parameters['$filter'] = _SERIALIZER.query("filter", filter, 'str') + _params["$filter"] = _SERIALIZER.query("filter", filter, "str") if top is not None: - _query_parameters['$top'] = _SERIALIZER.query("top", top, 'int') - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["$top"] = _SERIALIZER.query("top", top, "int") + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') - - return HttpRequest( - method="GET", - url=_url, - params=_query_parameters, - headers=_header_parameters, - **kwargs - ) + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) -def build_deployments_calculate_template_hash_request( - *, - json: JSONType = None, - content: Any = None, - **kwargs: Any -) -> HttpRequest: - api_version = kwargs.pop('api_version', "2019-03-01") # type: str - content_type = kwargs.pop('content_type', None) # type: Optional[str] - accept = "application/json" +def build_deployments_calculate_template_hash_request(*, json: JSON, **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", "2019-03-01")) # type: str + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + accept = _headers.pop("Accept", "application/json") + # Construct URL _url = kwargs.pop("template_url", "/providers/Microsoft.Resources/calculateTemplateHash") # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] if content_type is not None: - _header_parameters['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') - _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') - - return HttpRequest( - method="POST", - url=_url, - params=_query_parameters, - headers=_header_parameters, - json=json, - content=content, - **kwargs - ) + _headers["Content-Type"] = _SERIALIZER.header("content_type", content_type, "str") + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="POST", url=_url, params=_params, headers=_headers, json=json, **kwargs) def build_providers_unregister_request( - resource_provider_namespace: str, - subscription_id: str, - **kwargs: Any + resource_provider_namespace: str, subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2019-03-01") # type: 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", "2019-03-01")) # type: str + accept = _headers.pop("Accept", "application/json") - accept = "application/json" # Construct URL - _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/providers/{resourceProviderNamespace}/unregister") + _url = kwargs.pop( + "template_url", "/subscriptions/{subscriptionId}/providers/{resourceProviderNamespace}/unregister" + ) path_format_arguments = { - "resourceProviderNamespace": _SERIALIZER.url("resource_provider_namespace", resource_provider_namespace, 'str'), - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), + "resourceProviderNamespace": _SERIALIZER.url("resource_provider_namespace", resource_provider_namespace, "str"), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), } _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') - - return HttpRequest( - method="POST", - url=_url, - params=_query_parameters, - headers=_header_parameters, - **kwargs - ) + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="POST", url=_url, params=_params, headers=_headers, **kwargs) def build_providers_register_request( - resource_provider_namespace: str, - subscription_id: str, - **kwargs: Any + resource_provider_namespace: str, subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2019-03-01") # type: 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", "2019-03-01")) # type: str + accept = _headers.pop("Accept", "application/json") - accept = "application/json" # Construct URL _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/providers/{resourceProviderNamespace}/register") path_format_arguments = { - "resourceProviderNamespace": _SERIALIZER.url("resource_provider_namespace", resource_provider_namespace, 'str'), - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), + "resourceProviderNamespace": _SERIALIZER.url("resource_provider_namespace", resource_provider_namespace, "str"), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), } _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') - - return HttpRequest( - method="POST", - url=_url, - params=_query_parameters, - headers=_header_parameters, - **kwargs - ) + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="POST", url=_url, params=_params, headers=_headers, **kwargs) def build_providers_list_request( - subscription_id: str, - *, - top: Optional[int] = None, - expand: Optional[str] = None, - **kwargs: Any + subscription_id: str, *, top: Optional[int] = None, expand: Optional[str] = None, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2019-03-01") # type: 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", "2019-03-01")) # type: str + accept = _headers.pop("Accept", "application/json") - accept = "application/json" # Construct URL _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/providers") path_format_arguments = { - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), } _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] if top is not None: - _query_parameters['$top'] = _SERIALIZER.query("top", top, 'int') + _params["$top"] = _SERIALIZER.query("top", top, "int") if expand is not None: - _query_parameters['$expand'] = _SERIALIZER.query("expand", expand, 'str') - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["$expand"] = _SERIALIZER.query("expand", expand, "str") + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') - - return HttpRequest( - method="GET", - url=_url, - params=_query_parameters, - headers=_header_parameters, - **kwargs - ) + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) def build_providers_get_request( - resource_provider_namespace: str, - subscription_id: str, - *, - expand: Optional[str] = None, - **kwargs: Any + resource_provider_namespace: str, subscription_id: str, *, expand: Optional[str] = None, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2019-03-01") # type: 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", "2019-03-01")) # type: str + accept = _headers.pop("Accept", "application/json") - accept = "application/json" # Construct URL _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/providers/{resourceProviderNamespace}") path_format_arguments = { - "resourceProviderNamespace": _SERIALIZER.url("resource_provider_namespace", resource_provider_namespace, 'str'), - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), + "resourceProviderNamespace": _SERIALIZER.url("resource_provider_namespace", resource_provider_namespace, "str"), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), } _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] if expand is not None: - _query_parameters['$expand'] = _SERIALIZER.query("expand", expand, 'str') - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["$expand"] = _SERIALIZER.query("expand", expand, "str") + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') - - return HttpRequest( - method="GET", - url=_url, - params=_query_parameters, - headers=_header_parameters, - **kwargs - ) + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) def build_resources_list_by_resource_group_request( @@ -809,119 +721,108 @@ def build_resources_list_by_resource_group_request( top: Optional[int] = None, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2019-03-01") # type: 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", "2019-03-01")) # type: str + accept = _headers.pop("Accept", "application/json") - accept = "application/json" # Construct URL _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/resources") path_format_arguments = { - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._\(\)]+$'), - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), + "resourceGroupName": _SERIALIZER.url( + "resource_group_name", resource_group_name, "str", max_length=90, min_length=1, pattern=r"^[-\w\._\(\)]+$" + ), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), } _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] if filter is not None: - _query_parameters['$filter'] = _SERIALIZER.query("filter", filter, 'str') + _params["$filter"] = _SERIALIZER.query("filter", filter, "str") if expand is not None: - _query_parameters['$expand'] = _SERIALIZER.query("expand", expand, 'str') + _params["$expand"] = _SERIALIZER.query("expand", expand, "str") if top is not None: - _query_parameters['$top'] = _SERIALIZER.query("top", top, 'int') - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["$top"] = _SERIALIZER.query("top", top, "int") + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') - - return HttpRequest( - method="GET", - url=_url, - params=_query_parameters, - headers=_header_parameters, - **kwargs - ) + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) -def build_resources_move_resources_request_initial( - source_resource_group_name: str, - subscription_id: str, - *, - json: JSONType = None, - content: Any = None, - **kwargs: Any + +def build_resources_move_resources_request( + source_resource_group_name: str, subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2019-03-01") # type: str - content_type = kwargs.pop('content_type', None) # type: Optional[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", "2019-03-01")) # type: str + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] # Construct URL - _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{sourceResourceGroupName}/moveResources") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", "/subscriptions/{subscriptionId}/resourceGroups/{sourceResourceGroupName}/moveResources" + ) # pylint: disable=line-too-long path_format_arguments = { - "sourceResourceGroupName": _SERIALIZER.url("source_resource_group_name", source_resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._\(\)]+$'), - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), + "sourceResourceGroupName": _SERIALIZER.url( + "source_resource_group_name", + source_resource_group_name, + "str", + max_length=90, + min_length=1, + pattern=r"^[-\w\._\(\)]+$", + ), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), } _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] if content_type is not None: - _header_parameters['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') - - return HttpRequest( - method="POST", - url=_url, - params=_query_parameters, - headers=_header_parameters, - json=json, - content=content, - **kwargs - ) + _headers["Content-Type"] = _SERIALIZER.header("content_type", content_type, "str") + return HttpRequest(method="POST", url=_url, params=_params, headers=_headers, **kwargs) -def build_resources_validate_move_resources_request_initial( - source_resource_group_name: str, - subscription_id: str, - *, - json: JSONType = None, - content: Any = None, - **kwargs: Any + +def build_resources_validate_move_resources_request( + source_resource_group_name: str, subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2019-03-01") # type: str - content_type = kwargs.pop('content_type', None) # type: Optional[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", "2019-03-01")) # type: str + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] # Construct URL - _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{sourceResourceGroupName}/validateMoveResources") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", "/subscriptions/{subscriptionId}/resourceGroups/{sourceResourceGroupName}/validateMoveResources" + ) # pylint: disable=line-too-long path_format_arguments = { - "sourceResourceGroupName": _SERIALIZER.url("source_resource_group_name", source_resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._\(\)]+$'), - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), + "sourceResourceGroupName": _SERIALIZER.url( + "source_resource_group_name", + source_resource_group_name, + "str", + max_length=90, + min_length=1, + pattern=r"^[-\w\._\(\)]+$", + ), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), } _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] if content_type is not None: - _header_parameters['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') - - return HttpRequest( - method="POST", - url=_url, - params=_query_parameters, - headers=_header_parameters, - json=json, - content=content, - **kwargs - ) + _headers["Content-Type"] = _SERIALIZER.header("content_type", content_type, "str") + + return HttpRequest(method="POST", url=_url, params=_params, headers=_headers, **kwargs) def build_resources_list_request( @@ -932,38 +833,33 @@ def build_resources_list_request( top: Optional[int] = None, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2019-03-01") # type: 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", "2019-03-01")) # type: str + accept = _headers.pop("Accept", "application/json") - accept = "application/json" # Construct URL _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resources") path_format_arguments = { - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), } _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] if filter is not None: - _query_parameters['$filter'] = _SERIALIZER.query("filter", filter, 'str') + _params["$filter"] = _SERIALIZER.query("filter", filter, "str") if expand is not None: - _query_parameters['$expand'] = _SERIALIZER.query("expand", expand, 'str') + _params["$expand"] = _SERIALIZER.query("expand", expand, "str") if top is not None: - _query_parameters['$top'] = _SERIALIZER.query("top", top, 'int') - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["$top"] = _SERIALIZER.query("top", top, "int") + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') - - return HttpRequest( - method="GET", - url=_url, - params=_query_parameters, - headers=_header_parameters, - **kwargs - ) + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) def build_resources_check_existence_request( @@ -977,32 +873,33 @@ def build_resources_check_existence_request( api_version: str, **kwargs: Any ) -> HttpRequest: + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + # Construct URL - _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{parentResourcePath}/{resourceType}/{resourceName}") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{parentResourcePath}/{resourceType}/{resourceName}", + ) # pylint: disable=line-too-long path_format_arguments = { - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._\(\)]+$'), - "resourceProviderNamespace": _SERIALIZER.url("resource_provider_namespace", resource_provider_namespace, 'str'), - "parentResourcePath": _SERIALIZER.url("parent_resource_path", parent_resource_path, 'str', skip_quote=True), - "resourceType": _SERIALIZER.url("resource_type", resource_type, 'str', skip_quote=True), - "resourceName": _SERIALIZER.url("resource_name", resource_name, 'str'), - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), + "resourceGroupName": _SERIALIZER.url( + "resource_group_name", resource_group_name, "str", max_length=90, min_length=1, pattern=r"^[-\w\._\(\)]+$" + ), + "resourceProviderNamespace": _SERIALIZER.url("resource_provider_namespace", resource_provider_namespace, "str"), + "parentResourcePath": _SERIALIZER.url("parent_resource_path", parent_resource_path, "str", skip_quote=True), + "resourceType": _SERIALIZER.url("resource_type", resource_type, "str", skip_quote=True), + "resourceName": _SERIALIZER.url("resource_name", resource_name, "str"), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), } _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') - - return HttpRequest( - method="HEAD", - url=_url, - params=_query_parameters, - **kwargs - ) + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") + return HttpRequest(method="HEAD", url=_url, params=_params, **kwargs) -def build_resources_delete_request_initial( + +def build_resources_delete_request( resource_group_name: str, resource_provider_namespace: str, parent_resource_path: str, @@ -1013,32 +910,33 @@ def build_resources_delete_request_initial( api_version: str, **kwargs: Any ) -> HttpRequest: + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + # Construct URL - _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{parentResourcePath}/{resourceType}/{resourceName}") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{parentResourcePath}/{resourceType}/{resourceName}", + ) # pylint: disable=line-too-long path_format_arguments = { - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._\(\)]+$'), - "resourceProviderNamespace": _SERIALIZER.url("resource_provider_namespace", resource_provider_namespace, 'str'), - "parentResourcePath": _SERIALIZER.url("parent_resource_path", parent_resource_path, 'str', skip_quote=True), - "resourceType": _SERIALIZER.url("resource_type", resource_type, 'str', skip_quote=True), - "resourceName": _SERIALIZER.url("resource_name", resource_name, 'str'), - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), + "resourceGroupName": _SERIALIZER.url( + "resource_group_name", resource_group_name, "str", max_length=90, min_length=1, pattern=r"^[-\w\._\(\)]+$" + ), + "resourceProviderNamespace": _SERIALIZER.url("resource_provider_namespace", resource_provider_namespace, "str"), + "parentResourcePath": _SERIALIZER.url("parent_resource_path", parent_resource_path, "str", skip_quote=True), + "resourceType": _SERIALIZER.url("resource_type", resource_type, "str", skip_quote=True), + "resourceName": _SERIALIZER.url("resource_name", resource_name, "str"), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), } _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') - - return HttpRequest( - method="DELETE", - url=_url, - params=_query_parameters, - **kwargs - ) + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") + + return HttpRequest(method="DELETE", url=_url, params=_params, **kwargs) -def build_resources_create_or_update_request_initial( +def build_resources_create_or_update_request( resource_group_name: str, resource_provider_namespace: str, parent_resource_path: str, @@ -1047,48 +945,44 @@ def build_resources_create_or_update_request_initial( subscription_id: str, *, api_version: str, - json: JSONType = None, - content: Any = None, **kwargs: Any ) -> HttpRequest: - content_type = kwargs.pop('content_type', None) # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + accept = _headers.pop("Accept", "application/json") - accept = "application/json" # Construct URL - _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{parentResourcePath}/{resourceType}/{resourceName}") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{parentResourcePath}/{resourceType}/{resourceName}", + ) # pylint: disable=line-too-long path_format_arguments = { - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._\(\)]+$'), - "resourceProviderNamespace": _SERIALIZER.url("resource_provider_namespace", resource_provider_namespace, 'str'), - "parentResourcePath": _SERIALIZER.url("parent_resource_path", parent_resource_path, 'str', skip_quote=True), - "resourceType": _SERIALIZER.url("resource_type", resource_type, 'str', skip_quote=True), - "resourceName": _SERIALIZER.url("resource_name", resource_name, 'str'), - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), + "resourceGroupName": _SERIALIZER.url( + "resource_group_name", resource_group_name, "str", max_length=90, min_length=1, pattern=r"^[-\w\._\(\)]+$" + ), + "resourceProviderNamespace": _SERIALIZER.url("resource_provider_namespace", resource_provider_namespace, "str"), + "parentResourcePath": _SERIALIZER.url("parent_resource_path", parent_resource_path, "str", skip_quote=True), + "resourceType": _SERIALIZER.url("resource_type", resource_type, "str", skip_quote=True), + "resourceName": _SERIALIZER.url("resource_name", resource_name, "str"), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), } _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] if content_type is not None: - _header_parameters['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') - _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') - - return HttpRequest( - method="PUT", - url=_url, - params=_query_parameters, - headers=_header_parameters, - json=json, - content=content, - **kwargs - ) + _headers["Content-Type"] = _SERIALIZER.header("content_type", content_type, "str") + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + return HttpRequest(method="PUT", url=_url, params=_params, headers=_headers, **kwargs) -def build_resources_update_request_initial( + +def build_resources_update_request( resource_group_name: str, resource_provider_namespace: str, parent_resource_path: str, @@ -1097,45 +991,41 @@ def build_resources_update_request_initial( subscription_id: str, *, api_version: str, - json: JSONType = None, - content: Any = None, **kwargs: Any ) -> HttpRequest: - content_type = kwargs.pop('content_type', None) # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + accept = _headers.pop("Accept", "application/json") - accept = "application/json" # Construct URL - _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{parentResourcePath}/{resourceType}/{resourceName}") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{parentResourcePath}/{resourceType}/{resourceName}", + ) # pylint: disable=line-too-long path_format_arguments = { - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._\(\)]+$'), - "resourceProviderNamespace": _SERIALIZER.url("resource_provider_namespace", resource_provider_namespace, 'str'), - "parentResourcePath": _SERIALIZER.url("parent_resource_path", parent_resource_path, 'str', skip_quote=True), - "resourceType": _SERIALIZER.url("resource_type", resource_type, 'str', skip_quote=True), - "resourceName": _SERIALIZER.url("resource_name", resource_name, 'str'), - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), + "resourceGroupName": _SERIALIZER.url( + "resource_group_name", resource_group_name, "str", max_length=90, min_length=1, pattern=r"^[-\w\._\(\)]+$" + ), + "resourceProviderNamespace": _SERIALIZER.url("resource_provider_namespace", resource_provider_namespace, "str"), + "parentResourcePath": _SERIALIZER.url("parent_resource_path", parent_resource_path, "str", skip_quote=True), + "resourceType": _SERIALIZER.url("resource_type", resource_type, "str", skip_quote=True), + "resourceName": _SERIALIZER.url("resource_name", resource_name, "str"), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), } _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] if content_type is not None: - _header_parameters['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') - _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') - - return HttpRequest( - method="PATCH", - url=_url, - params=_query_parameters, - headers=_header_parameters, - json=json, - content=content, - **kwargs - ) + _headers["Content-Type"] = _SERIALIZER.header("content_type", content_type, "str") + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="PATCH", url=_url, params=_params, headers=_headers, **kwargs) def build_resources_get_request( @@ -1149,826 +1039,663 @@ def build_resources_get_request( api_version: str, **kwargs: Any ) -> HttpRequest: - accept = "application/json" + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + accept = _headers.pop("Accept", "application/json") + # Construct URL - _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{parentResourcePath}/{resourceType}/{resourceName}") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{parentResourcePath}/{resourceType}/{resourceName}", + ) # pylint: disable=line-too-long path_format_arguments = { - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._\(\)]+$'), - "resourceProviderNamespace": _SERIALIZER.url("resource_provider_namespace", resource_provider_namespace, 'str'), - "parentResourcePath": _SERIALIZER.url("parent_resource_path", parent_resource_path, 'str', skip_quote=True), - "resourceType": _SERIALIZER.url("resource_type", resource_type, 'str', skip_quote=True), - "resourceName": _SERIALIZER.url("resource_name", resource_name, 'str'), - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), + "resourceGroupName": _SERIALIZER.url( + "resource_group_name", resource_group_name, "str", max_length=90, min_length=1, pattern=r"^[-\w\._\(\)]+$" + ), + "resourceProviderNamespace": _SERIALIZER.url("resource_provider_namespace", resource_provider_namespace, "str"), + "parentResourcePath": _SERIALIZER.url("parent_resource_path", parent_resource_path, "str", skip_quote=True), + "resourceType": _SERIALIZER.url("resource_type", resource_type, "str", skip_quote=True), + "resourceName": _SERIALIZER.url("resource_name", resource_name, "str"), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), } _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') - - return HttpRequest( - method="GET", - url=_url, - params=_query_parameters, - headers=_header_parameters, - **kwargs - ) + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) + + +def build_resources_check_existence_by_id_request(resource_id: str, *, api_version: str, **kwargs: Any) -> HttpRequest: + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) -def build_resources_check_existence_by_id_request( - resource_id: str, - *, - api_version: str, - **kwargs: Any -) -> HttpRequest: # Construct URL _url = kwargs.pop("template_url", "/{resourceId}") path_format_arguments = { - "resourceId": _SERIALIZER.url("resource_id", resource_id, 'str', skip_quote=True), + "resourceId": _SERIALIZER.url("resource_id", resource_id, "str", skip_quote=True), } _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') - - return HttpRequest( - method="HEAD", - url=_url, - params=_query_parameters, - **kwargs - ) + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") + return HttpRequest(method="HEAD", url=_url, params=_params, **kwargs) + + +def build_resources_delete_by_id_request(resource_id: str, *, api_version: str, **kwargs: Any) -> HttpRequest: + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) -def build_resources_delete_by_id_request_initial( - resource_id: str, - *, - api_version: str, - **kwargs: Any -) -> HttpRequest: # Construct URL _url = kwargs.pop("template_url", "/{resourceId}") path_format_arguments = { - "resourceId": _SERIALIZER.url("resource_id", resource_id, 'str', skip_quote=True), + "resourceId": _SERIALIZER.url("resource_id", resource_id, "str", skip_quote=True), } _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') - - return HttpRequest( - method="DELETE", - url=_url, - params=_query_parameters, - **kwargs - ) + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") + return HttpRequest(method="DELETE", url=_url, params=_params, **kwargs) -def build_resources_create_or_update_by_id_request_initial( - resource_id: str, - *, - api_version: str, - json: JSONType = None, - content: Any = None, - **kwargs: Any -) -> HttpRequest: - content_type = kwargs.pop('content_type', None) # type: Optional[str] - accept = "application/json" +def build_resources_create_or_update_by_id_request(resource_id: str, *, api_version: str, **kwargs: Any) -> HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + accept = _headers.pop("Accept", "application/json") + # Construct URL _url = kwargs.pop("template_url", "/{resourceId}") path_format_arguments = { - "resourceId": _SERIALIZER.url("resource_id", resource_id, 'str', skip_quote=True), + "resourceId": _SERIALIZER.url("resource_id", resource_id, "str", skip_quote=True), } _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] if content_type is not None: - _header_parameters['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') - _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') - - return HttpRequest( - method="PUT", - url=_url, - params=_query_parameters, - headers=_header_parameters, - json=json, - content=content, - **kwargs - ) + _headers["Content-Type"] = _SERIALIZER.header("content_type", content_type, "str") + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + return HttpRequest(method="PUT", url=_url, params=_params, headers=_headers, **kwargs) -def build_resources_update_by_id_request_initial( - resource_id: str, - *, - api_version: str, - json: JSONType = None, - content: Any = None, - **kwargs: Any -) -> HttpRequest: - content_type = kwargs.pop('content_type', None) # type: Optional[str] - accept = "application/json" +def build_resources_update_by_id_request(resource_id: str, *, api_version: str, **kwargs: Any) -> HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + accept = _headers.pop("Accept", "application/json") + # Construct URL _url = kwargs.pop("template_url", "/{resourceId}") path_format_arguments = { - "resourceId": _SERIALIZER.url("resource_id", resource_id, 'str', skip_quote=True), + "resourceId": _SERIALIZER.url("resource_id", resource_id, "str", skip_quote=True), } _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] if content_type is not None: - _header_parameters['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') - _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') - - return HttpRequest( - method="PATCH", - url=_url, - params=_query_parameters, - headers=_header_parameters, - json=json, - content=content, - **kwargs - ) + _headers["Content-Type"] = _SERIALIZER.header("content_type", content_type, "str") + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + return HttpRequest(method="PATCH", url=_url, params=_params, headers=_headers, **kwargs) + + +def build_resources_get_by_id_request(resource_id: str, *, api_version: str, **kwargs: Any) -> HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + accept = _headers.pop("Accept", "application/json") -def build_resources_get_by_id_request( - resource_id: str, - *, - api_version: str, - **kwargs: Any -) -> HttpRequest: - accept = "application/json" # Construct URL _url = kwargs.pop("template_url", "/{resourceId}") path_format_arguments = { - "resourceId": _SERIALIZER.url("resource_id", resource_id, 'str', skip_quote=True), + "resourceId": _SERIALIZER.url("resource_id", resource_id, "str", skip_quote=True), } _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') - - return HttpRequest( - method="GET", - url=_url, - params=_query_parameters, - headers=_header_parameters, - **kwargs - ) + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) def build_resource_groups_check_existence_request( - resource_group_name: str, - subscription_id: str, - **kwargs: Any + resource_group_name: str, subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2019-03-01") # type: str + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + api_version = kwargs.pop("api_version", _params.pop("api-version", "2019-03-01")) # type: str # Construct URL _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}") path_format_arguments = { - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._\(\)]+$'), - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), + "resourceGroupName": _SERIALIZER.url( + "resource_group_name", resource_group_name, "str", max_length=90, min_length=1, pattern=r"^[-\w\._\(\)]+$" + ), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), } _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') - - return HttpRequest( - method="HEAD", - url=_url, - params=_query_parameters, - **kwargs - ) + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") + + return HttpRequest(method="HEAD", url=_url, params=_params, **kwargs) def build_resource_groups_create_or_update_request( - resource_group_name: str, - subscription_id: str, - *, - json: JSONType = None, - content: Any = None, - **kwargs: Any + resource_group_name: str, subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2019-03-01") # type: str - content_type = kwargs.pop('content_type', None) # type: Optional[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", "2019-03-01")) # type: str + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + accept = _headers.pop("Accept", "application/json") - accept = "application/json" # Construct URL _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}") path_format_arguments = { - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._\(\)]+$'), - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), + "resourceGroupName": _SERIALIZER.url( + "resource_group_name", resource_group_name, "str", max_length=90, min_length=1, pattern=r"^[-\w\._\(\)]+$" + ), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), } _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] if content_type is not None: - _header_parameters['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') - _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') - - return HttpRequest( - method="PUT", - url=_url, - params=_query_parameters, - headers=_header_parameters, - json=json, - content=content, - **kwargs - ) + _headers["Content-Type"] = _SERIALIZER.header("content_type", content_type, "str") + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + return HttpRequest(method="PUT", url=_url, params=_params, headers=_headers, **kwargs) -def build_resource_groups_delete_request_initial( - resource_group_name: str, - subscription_id: str, - **kwargs: Any -) -> HttpRequest: - api_version = kwargs.pop('api_version', "2019-03-01") # type: str +def build_resource_groups_delete_request(resource_group_name: str, subscription_id: str, **kwargs: Any) -> HttpRequest: + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2019-03-01")) # type: str # Construct URL _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}") path_format_arguments = { - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._\(\)]+$'), - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), + "resourceGroupName": _SERIALIZER.url( + "resource_group_name", resource_group_name, "str", max_length=90, min_length=1, pattern=r"^[-\w\._\(\)]+$" + ), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), } _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') - - return HttpRequest( - method="DELETE", - url=_url, - params=_query_parameters, - **kwargs - ) + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") + return HttpRequest(method="DELETE", url=_url, params=_params, **kwargs) -def build_resource_groups_get_request( - resource_group_name: str, - subscription_id: str, - **kwargs: Any -) -> HttpRequest: - api_version = kwargs.pop('api_version', "2019-03-01") # type: str - accept = "application/json" +def build_resource_groups_get_request(resource_group_name: str, subscription_id: str, **kwargs: Any) -> HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2019-03-01")) # type: str + accept = _headers.pop("Accept", "application/json") + # Construct URL _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}") path_format_arguments = { - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._\(\)]+$'), - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), + "resourceGroupName": _SERIALIZER.url( + "resource_group_name", resource_group_name, "str", max_length=90, min_length=1, pattern=r"^[-\w\._\(\)]+$" + ), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), } _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') - - return HttpRequest( - method="GET", - url=_url, - params=_query_parameters, - headers=_header_parameters, - **kwargs - ) + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) -def build_resource_groups_update_request( - resource_group_name: str, - subscription_id: str, - *, - json: JSONType = None, - content: Any = None, - **kwargs: Any -) -> HttpRequest: - api_version = kwargs.pop('api_version', "2019-03-01") # type: str - content_type = kwargs.pop('content_type', None) # type: Optional[str] - accept = "application/json" +def build_resource_groups_update_request(resource_group_name: str, subscription_id: str, **kwargs: Any) -> HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2019-03-01")) # type: str + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + accept = _headers.pop("Accept", "application/json") + # Construct URL _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}") path_format_arguments = { - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._\(\)]+$'), - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), + "resourceGroupName": _SERIALIZER.url( + "resource_group_name", resource_group_name, "str", max_length=90, min_length=1, pattern=r"^[-\w\._\(\)]+$" + ), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), } _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] if content_type is not None: - _header_parameters['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') - _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') - - return HttpRequest( - method="PATCH", - url=_url, - params=_query_parameters, - headers=_header_parameters, - json=json, - content=content, - **kwargs - ) + _headers["Content-Type"] = _SERIALIZER.header("content_type", content_type, "str") + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="PATCH", url=_url, params=_params, headers=_headers, **kwargs) def build_resource_groups_export_template_request( - resource_group_name: str, - subscription_id: str, - *, - json: JSONType = None, - content: Any = None, - **kwargs: Any + resource_group_name: str, subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2019-03-01") # type: str - content_type = kwargs.pop('content_type', None) # type: Optional[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", "2019-03-01")) # type: str + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + accept = _headers.pop("Accept", "application/json") - accept = "application/json" # Construct URL - _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/exportTemplate") + _url = kwargs.pop( + "template_url", "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/exportTemplate" + ) path_format_arguments = { - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._\(\)]+$'), - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), + "resourceGroupName": _SERIALIZER.url( + "resource_group_name", resource_group_name, "str", max_length=90, min_length=1, pattern=r"^[-\w\._\(\)]+$" + ), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), } _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] if content_type is not None: - _header_parameters['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') - _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') - - return HttpRequest( - method="POST", - url=_url, - params=_query_parameters, - headers=_header_parameters, - json=json, - content=content, - **kwargs - ) + _headers["Content-Type"] = _SERIALIZER.header("content_type", content_type, "str") + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="POST", url=_url, params=_params, headers=_headers, **kwargs) def build_resource_groups_list_request( - subscription_id: str, - *, - filter: Optional[str] = None, - top: Optional[int] = None, - **kwargs: Any + subscription_id: str, *, filter: Optional[str] = None, top: Optional[int] = None, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2019-03-01") # type: 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", "2019-03-01")) # type: str + accept = _headers.pop("Accept", "application/json") - accept = "application/json" # Construct URL _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourcegroups") path_format_arguments = { - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), } _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] if filter is not None: - _query_parameters['$filter'] = _SERIALIZER.query("filter", filter, 'str') + _params["$filter"] = _SERIALIZER.query("filter", filter, "str") if top is not None: - _query_parameters['$top'] = _SERIALIZER.query("top", top, 'int') - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["$top"] = _SERIALIZER.query("top", top, "int") + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') - - return HttpRequest( - method="GET", - url=_url, - params=_query_parameters, - headers=_header_parameters, - **kwargs - ) + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) -def build_tags_delete_value_request( - tag_name: str, - tag_value: str, - subscription_id: str, - **kwargs: Any -) -> HttpRequest: - api_version = kwargs.pop('api_version', "2019-03-01") # type: str +def build_tags_delete_value_request(tag_name: str, tag_value: str, subscription_id: str, **kwargs: Any) -> HttpRequest: + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2019-03-01")) # type: str # Construct URL _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/tagNames/{tagName}/tagValues/{tagValue}") path_format_arguments = { - "tagName": _SERIALIZER.url("tag_name", tag_name, 'str'), - "tagValue": _SERIALIZER.url("tag_value", tag_value, 'str'), - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), + "tagName": _SERIALIZER.url("tag_name", tag_name, "str"), + "tagValue": _SERIALIZER.url("tag_value", tag_value, "str"), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), } _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') - - return HttpRequest( - method="DELETE", - url=_url, - params=_query_parameters, - **kwargs - ) + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") + + return HttpRequest(method="DELETE", url=_url, params=_params, **kwargs) def build_tags_create_or_update_value_request( - tag_name: str, - tag_value: str, - subscription_id: str, - **kwargs: Any + tag_name: str, tag_value: str, subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2019-03-01") # type: 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", "2019-03-01")) # type: str + accept = _headers.pop("Accept", "application/json") - accept = "application/json" # Construct URL _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/tagNames/{tagName}/tagValues/{tagValue}") path_format_arguments = { - "tagName": _SERIALIZER.url("tag_name", tag_name, 'str'), - "tagValue": _SERIALIZER.url("tag_value", tag_value, 'str'), - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), + "tagName": _SERIALIZER.url("tag_name", tag_name, "str"), + "tagValue": _SERIALIZER.url("tag_value", tag_value, "str"), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), } _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') - - return HttpRequest( - method="PUT", - url=_url, - params=_query_parameters, - headers=_header_parameters, - **kwargs - ) + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + return HttpRequest(method="PUT", url=_url, params=_params, headers=_headers, **kwargs) -def build_tags_create_or_update_request( - tag_name: str, - subscription_id: str, - **kwargs: Any -) -> HttpRequest: - api_version = kwargs.pop('api_version', "2019-03-01") # type: str - accept = "application/json" +def build_tags_create_or_update_request(tag_name: str, subscription_id: str, **kwargs: Any) -> HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2019-03-01")) # type: str + accept = _headers.pop("Accept", "application/json") + # Construct URL _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/tagNames/{tagName}") path_format_arguments = { - "tagName": _SERIALIZER.url("tag_name", tag_name, 'str'), - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), + "tagName": _SERIALIZER.url("tag_name", tag_name, "str"), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), } _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') - - return HttpRequest( - method="PUT", - url=_url, - params=_query_parameters, - headers=_header_parameters, - **kwargs - ) + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + return HttpRequest(method="PUT", url=_url, params=_params, headers=_headers, **kwargs) -def build_tags_delete_request( - tag_name: str, - subscription_id: str, - **kwargs: Any -) -> HttpRequest: - api_version = kwargs.pop('api_version', "2019-03-01") # type: str +def build_tags_delete_request(tag_name: str, subscription_id: str, **kwargs: Any) -> HttpRequest: + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2019-03-01")) # type: str # Construct URL _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/tagNames/{tagName}") path_format_arguments = { - "tagName": _SERIALIZER.url("tag_name", tag_name, 'str'), - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), + "tagName": _SERIALIZER.url("tag_name", tag_name, "str"), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), } _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') - - return HttpRequest( - method="DELETE", - url=_url, - params=_query_parameters, - **kwargs - ) + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") + return HttpRequest(method="DELETE", url=_url, params=_params, **kwargs) -def build_tags_list_request( - subscription_id: str, - **kwargs: Any -) -> HttpRequest: - api_version = kwargs.pop('api_version', "2019-03-01") # type: str - accept = "application/json" +def build_tags_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", "2019-03-01")) # type: str + accept = _headers.pop("Accept", "application/json") + # Construct URL _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/tagNames") path_format_arguments = { - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), } _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') - - return HttpRequest( - method="GET", - url=_url, - params=_query_parameters, - headers=_header_parameters, - **kwargs - ) + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) def build_deployment_operations_get_at_subscription_scope_request( - deployment_name: str, - operation_id: str, - subscription_id: str, - **kwargs: Any + deployment_name: str, operation_id: str, subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2019-03-01") # type: 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", "2019-03-01")) # type: str + accept = _headers.pop("Accept", "application/json") - accept = "application/json" # Construct URL - _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/providers/Microsoft.Resources/deployments/{deploymentName}/operations/{operationId}") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/providers/Microsoft.Resources/deployments/{deploymentName}/operations/{operationId}", + ) # pylint: disable=line-too-long path_format_arguments = { - "deploymentName": _SERIALIZER.url("deployment_name", deployment_name, 'str', max_length=64, min_length=1, pattern=r'^[-\w\._\(\)]+$'), - "operationId": _SERIALIZER.url("operation_id", operation_id, 'str'), - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), + "deploymentName": _SERIALIZER.url( + "deployment_name", deployment_name, "str", max_length=64, min_length=1, pattern=r"^[-\w\._\(\)]+$" + ), + "operationId": _SERIALIZER.url("operation_id", operation_id, "str"), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), } _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') - - return HttpRequest( - method="GET", - url=_url, - params=_query_parameters, - headers=_header_parameters, - **kwargs - ) + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) def build_deployment_operations_list_at_subscription_scope_request( - deployment_name: str, - subscription_id: str, - *, - top: Optional[int] = None, - **kwargs: Any + deployment_name: str, subscription_id: str, *, top: Optional[int] = None, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2019-03-01") # type: 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", "2019-03-01")) # type: str + accept = _headers.pop("Accept", "application/json") - accept = "application/json" # Construct URL - _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/providers/Microsoft.Resources/deployments/{deploymentName}/operations") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/providers/Microsoft.Resources/deployments/{deploymentName}/operations", + ) # pylint: disable=line-too-long path_format_arguments = { - "deploymentName": _SERIALIZER.url("deployment_name", deployment_name, 'str', max_length=64, min_length=1, pattern=r'^[-\w\._\(\)]+$'), - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), + "deploymentName": _SERIALIZER.url( + "deployment_name", deployment_name, "str", max_length=64, min_length=1, pattern=r"^[-\w\._\(\)]+$" + ), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), } _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] if top is not None: - _query_parameters['$top'] = _SERIALIZER.query("top", top, 'int') - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["$top"] = _SERIALIZER.query("top", top, "int") + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') - - return HttpRequest( - method="GET", - url=_url, - params=_query_parameters, - headers=_header_parameters, - **kwargs - ) + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) def build_deployment_operations_get_request( - resource_group_name: str, - deployment_name: str, - operation_id: str, - subscription_id: str, - **kwargs: Any + resource_group_name: str, deployment_name: str, operation_id: str, subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2019-03-01") # type: 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", "2019-03-01")) # type: str + accept = _headers.pop("Accept", "application/json") - accept = "application/json" # Construct URL - _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/deployments/{deploymentName}/operations/{operationId}") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/deployments/{deploymentName}/operations/{operationId}", + ) # pylint: disable=line-too-long path_format_arguments = { - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._\(\)]+$'), - "deploymentName": _SERIALIZER.url("deployment_name", deployment_name, 'str', max_length=64, min_length=1, pattern=r'^[-\w\._\(\)]+$'), - "operationId": _SERIALIZER.url("operation_id", operation_id, 'str'), - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), + "resourceGroupName": _SERIALIZER.url( + "resource_group_name", resource_group_name, "str", max_length=90, min_length=1, pattern=r"^[-\w\._\(\)]+$" + ), + "deploymentName": _SERIALIZER.url( + "deployment_name", deployment_name, "str", max_length=64, min_length=1, pattern=r"^[-\w\._\(\)]+$" + ), + "operationId": _SERIALIZER.url("operation_id", operation_id, "str"), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), } _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') - - return HttpRequest( - method="GET", - url=_url, - params=_query_parameters, - headers=_header_parameters, - **kwargs - ) + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) def build_deployment_operations_list_request( - resource_group_name: str, - deployment_name: str, - subscription_id: str, - *, - top: Optional[int] = None, - **kwargs: Any + resource_group_name: str, deployment_name: str, subscription_id: str, *, top: Optional[int] = None, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2019-03-01") # type: 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", "2019-03-01")) # type: str + accept = _headers.pop("Accept", "application/json") - accept = "application/json" # Construct URL - _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/deployments/{deploymentName}/operations") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/deployments/{deploymentName}/operations", + ) # pylint: disable=line-too-long path_format_arguments = { - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._\(\)]+$'), - "deploymentName": _SERIALIZER.url("deployment_name", deployment_name, 'str', max_length=64, min_length=1, pattern=r'^[-\w\._\(\)]+$'), - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), + "resourceGroupName": _SERIALIZER.url( + "resource_group_name", resource_group_name, "str", max_length=90, min_length=1, pattern=r"^[-\w\._\(\)]+$" + ), + "deploymentName": _SERIALIZER.url( + "deployment_name", deployment_name, "str", max_length=64, min_length=1, pattern=r"^[-\w\._\(\)]+$" + ), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), } _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] if top is not None: - _query_parameters['$top'] = _SERIALIZER.query("top", top, 'int') - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["$top"] = _SERIALIZER.query("top", top, "int") + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') - - return HttpRequest( - method="GET", - url=_url, - params=_query_parameters, - headers=_header_parameters, - **kwargs - ) + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) -class Operations(object): - """Operations operations. - You should not instantiate this class directly. Instead, you should create a Client instance that - instantiates it for you and attaches it as an attribute. +class Operations: + """ + .. warning:: + **DO NOT** instantiate this class directly. - :ivar models: Alias to model classes used in this operation group. - :type models: ~azure.mgmt.resource.resources.v2019_03_01.models - :param client: Client for service requests. - :param config: Configuration of service client. - :param serializer: An object model serializer. - :param deserializer: An object model deserializer. + Instead, you should access the following operations through + :class:`~azure.mgmt.resource.resources.v2019_03_01.ResourceManagementClient`'s + :attr:`operations` attribute. """ models = _models - def __init__(self, client, config, serializer, deserializer): - self._client = client - self._serialize = serializer - self._deserialize = deserializer - self._config = config + def __init__(self, *args, **kwargs): + input_args = list(args) + self._client = input_args.pop(0) if input_args else kwargs.pop("client") + self._config = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") @distributed_trace - def list( - self, - **kwargs: Any - ) -> Iterable["_models.OperationListResult"]: + def list(self, **kwargs: Any) -> Iterable["_models.Operation"]: """Lists all of the available Microsoft.Resources REST API operations. :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either OperationListResult or the result of cls(response) + :return: An iterator like instance of either Operation or the result of cls(response) :rtype: - ~azure.core.paging.ItemPaged[~azure.mgmt.resource.resources.v2019_03_01.models.OperationListResult] - :raises: ~azure.core.exceptions.HttpResponseError + ~azure.core.paging.ItemPaged[~azure.mgmt.resource.resources.v2019_03_01.models.Operation] + :raises ~azure.core.exceptions.HttpResponseError: """ - api_version = kwargs.pop('api_version', "2019-03-01") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2019-03-01")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[_models.OperationListResult] - cls = kwargs.pop('cls', None) # type: ClsType["_models.OperationListResult"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) + def prepare_request(next_link=None): if not next_link: - + request = build_operations_list_request( api_version=api_version, - template_url=self.list.metadata['url'], + template_url=self.list.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore else: - - request = build_operations_list_request( - template_url=next_link, - ) + # make call to next link with the client's api-version + _parsed_next_link = urlparse(next_link) + _next_request_params = case_insensitive_dict(parse_qs(_parsed_next_link.query)) + _next_request_params["api-version"] = self._config.api_version + request = HttpRequest("GET", urljoin(next_link, _parsed_next_link.path), params=_next_request_params) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore request.method = "GET" return request @@ -1982,10 +1709,8 @@ def extract_data(pipeline_response): def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) response = pipeline_response.http_response @@ -1995,61 +1720,62 @@ def get_next(next_link=None): return pipeline_response + return ItemPaged(get_next, extract_data) - return ItemPaged( - get_next, extract_data - ) - list.metadata = {'url': "/providers/Microsoft.Resources/operations"} # type: ignore -class DeploymentsOperations(object): # pylint: disable=too-many-public-methods - """DeploymentsOperations operations. - - You should not instantiate this class directly. Instead, you should create a Client instance that - instantiates it for you and attaches it as an attribute. - - :ivar models: Alias to model classes used in this operation group. - :type models: ~azure.mgmt.resource.resources.v2019_03_01.models - :param client: Client for service requests. - :param config: Configuration of service client. - :param serializer: An object model serializer. - :param deserializer: An object model deserializer. + list.metadata = {"url": "/providers/Microsoft.Resources/operations"} # type: ignore + + +class DeploymentsOperations: # pylint: disable=too-many-public-methods + """ + .. warning:: + **DO NOT** instantiate this class directly. + + Instead, you should access the following operations through + :class:`~azure.mgmt.resource.resources.v2019_03_01.ResourceManagementClient`'s + :attr:`deployments` attribute. """ models = _models - def __init__(self, client, config, serializer, deserializer): - self._client = client - self._serialize = serializer - self._deserialize = deserializer - self._config = config + def __init__(self, *args, **kwargs): + input_args = list(args) + self._client = input_args.pop(0) if input_args else kwargs.pop("client") + self._config = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") def _delete_at_subscription_scope_initial( # pylint: disable=inconsistent-return-statements - self, - deployment_name: str, - **kwargs: Any + self, deployment_name: str, **kwargs: Any ) -> None: - cls = kwargs.pop('cls', None) # type: ClsType[None] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) - api_version = kwargs.pop('api_version', "2019-03-01") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - request = build_deployments_delete_at_subscription_scope_request_initial( + api_version = kwargs.pop("api_version", _params.pop("api-version", "2019-03-01")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[None] + + request = build_deployments_delete_at_subscription_scope_request( deployment_name=deployment_name, subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self._delete_at_subscription_scope_initial.metadata['url'], + template_url=self._delete_at_subscription_scope_initial.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [202, 204]: @@ -2059,15 +1785,10 @@ def _delete_at_subscription_scope_initial( # pylint: disable=inconsistent-retur if cls: return cls(pipeline_response, None, {}) - _delete_at_subscription_scope_initial.metadata = {'url': "/subscriptions/{subscriptionId}/providers/Microsoft.Resources/deployments/{deploymentName}"} # type: ignore - + _delete_at_subscription_scope_initial.metadata = {"url": "/subscriptions/{subscriptionId}/providers/Microsoft.Resources/deployments/{deploymentName}"} # type: ignore @distributed_trace - def begin_delete_at_subscription_scope( # pylint: disable=inconsistent-return-statements - self, - deployment_name: str, - **kwargs: Any - ) -> LROPoller[None]: + def begin_delete_at_subscription_scope(self, deployment_name: str, **kwargs: Any) -> LROPoller[None]: """Deletes a deployment from the deployment history. A template deployment that is currently running cannot be deleted. Deleting a template @@ -2078,7 +1799,7 @@ def begin_delete_at_subscription_scope( # pylint: disable=inconsistent-return-s process finishes, the URI in the Location header returns a status of 204 on success. If the asynchronous request failed, the URI in the Location header returns an error-level status code. - :param deployment_name: The name of the deployment to delete. + :param deployment_name: The name of the deployment to delete. Required. :type deployment_name: str :keyword callable cls: A custom type or function that will be passed the direct response :keyword str continuation_token: A continuation token to restart a poller from a saved state. @@ -2090,82 +1811,88 @@ def begin_delete_at_subscription_scope( # pylint: disable=inconsistent-return-s Retry-After header is present. :return: An instance of LROPoller that returns either None or the result of cls(response) :rtype: ~azure.core.polling.LROPoller[None] - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - api_version = kwargs.pop('api_version', "2019-03-01") # type: str - polling = kwargs.pop('polling', True) # type: Union[bool, PollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType[None] - lro_delay = kwargs.pop( - 'polling_interval', - self._config.polling_interval - ) - cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2019-03-01")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[None] + polling = kwargs.pop("polling", True) # type: Union[bool, PollingMethod] + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token = kwargs.pop("continuation_token", None) # type: Optional[str] if cont_token is None: - raw_result = self._delete_at_subscription_scope_initial( + raw_result = self._delete_at_subscription_scope_initial( # type: ignore deployment_name=deployment_name, api_version=api_version, - cls=lambda x,y,z: x, + cls=lambda x, y, z: x, + headers=_headers, + params=_params, **kwargs ) - kwargs.pop('error_map', None) + kwargs.pop("error_map", None) - def get_long_running_output(pipeline_response): + def get_long_running_output(pipeline_response): # pylint: disable=inconsistent-return-statements if cls: return cls(pipeline_response, None, {}) - - if polling is True: polling_method = ARMPolling(lro_delay, **kwargs) - elif polling is False: polling_method = NoPolling() - else: polling_method = polling + if polling is True: + polling_method = cast(PollingMethod, ARMPolling(lro_delay, **kwargs)) # type: PollingMethod + elif polling is False: + polling_method = cast(PollingMethod, NoPolling()) + else: + polling_method = polling if cont_token: return LROPoller.from_continuation_token( polling_method=polling_method, continuation_token=cont_token, client=self._client, - deserialization_callback=get_long_running_output + deserialization_callback=get_long_running_output, ) return LROPoller(self._client, raw_result, get_long_running_output, polling_method) - begin_delete_at_subscription_scope.metadata = {'url': "/subscriptions/{subscriptionId}/providers/Microsoft.Resources/deployments/{deploymentName}"} # type: ignore + begin_delete_at_subscription_scope.metadata = {"url": "/subscriptions/{subscriptionId}/providers/Microsoft.Resources/deployments/{deploymentName}"} # type: ignore @distributed_trace - def check_existence_at_subscription_scope( - self, - deployment_name: str, - **kwargs: Any - ) -> bool: + def check_existence_at_subscription_scope(self, deployment_name: str, **kwargs: Any) -> bool: """Checks whether the deployment exists. - :param deployment_name: The name of the deployment to check. + :param deployment_name: The name of the deployment to check. Required. :type deployment_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: bool, or the result of cls(response) + :return: bool or the result of cls(response) :rtype: bool - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType[None] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) - api_version = kwargs.pop('api_version', "2019-03-01") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2019-03-01")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[None] - request = build_deployments_check_existence_at_subscription_scope_request( deployment_name=deployment_name, subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.check_existence_at_subscription_scope.metadata['url'], + template_url=self.check_existence_at_subscription_scope.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [204, 404]: @@ -2176,42 +1903,52 @@ def check_existence_at_subscription_scope( return cls(pipeline_response, None, {}) return 200 <= response.status_code <= 299 - check_existence_at_subscription_scope.metadata = {'url': "/subscriptions/{subscriptionId}/providers/Microsoft.Resources/deployments/{deploymentName}"} # type: ignore - + check_existence_at_subscription_scope.metadata = {"url": "/subscriptions/{subscriptionId}/providers/Microsoft.Resources/deployments/{deploymentName}"} # type: ignore def _create_or_update_at_subscription_scope_initial( - self, - deployment_name: str, - parameters: "_models.Deployment", - **kwargs: Any - ) -> "_models.DeploymentExtended": - cls = kwargs.pop('cls', None) # type: ClsType["_models.DeploymentExtended"] + self, deployment_name: str, parameters: Union[_models.Deployment, IO], **kwargs: Any + ) -> _models.DeploymentExtended: error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) - api_version = kwargs.pop('api_version', "2019-03-01") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - _json = self._serialize.body(parameters, 'Deployment') + api_version = kwargs.pop("api_version", _params.pop("api-version", "2019-03-01")) # type: str + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.DeploymentExtended] - request = build_deployments_create_or_update_at_subscription_scope_request_initial( + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(parameters, (IO, bytes)): + _content = parameters + else: + _json = self._serialize.body(parameters, "Deployment") + + request = build_deployments_create_or_update_at_subscription_scope_request( deployment_name=deployment_name, subscription_id=self._config.subscription_id, api_version=api_version, content_type=content_type, json=_json, - template_url=self._create_or_update_at_subscription_scope_initial.metadata['url'], + content=_content, + template_url=self._create_or_update_at_subscription_scope_initial.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200, 201]: @@ -2219,34 +1956,38 @@ def _create_or_update_at_subscription_scope_initial( raise HttpResponseError(response=response, error_format=ARMErrorFormat) if response.status_code == 200: - deserialized = self._deserialize('DeploymentExtended', pipeline_response) + deserialized = self._deserialize("DeploymentExtended", pipeline_response) if response.status_code == 201: - deserialized = self._deserialize('DeploymentExtended', pipeline_response) + deserialized = self._deserialize("DeploymentExtended", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - _create_or_update_at_subscription_scope_initial.metadata = {'url': "/subscriptions/{subscriptionId}/providers/Microsoft.Resources/deployments/{deploymentName}"} # type: ignore + _create_or_update_at_subscription_scope_initial.metadata = {"url": "/subscriptions/{subscriptionId}/providers/Microsoft.Resources/deployments/{deploymentName}"} # type: ignore - - @distributed_trace + @overload def begin_create_or_update_at_subscription_scope( self, deployment_name: str, - parameters: "_models.Deployment", + parameters: _models.Deployment, + *, + content_type: str = "application/json", **kwargs: Any - ) -> LROPoller["_models.DeploymentExtended"]: + ) -> LROPoller[_models.DeploymentExtended]: """Deploys resources at subscription scope. You can provide the template and parameters directly in the request or link to JSON files. - :param deployment_name: The name of the deployment. + :param deployment_name: The name of the deployment. Required. :type deployment_name: str - :param parameters: Additional parameters supplied to the operation. + :param parameters: Additional parameters supplied to the operation. Required. :type parameters: ~azure.mgmt.resource.resources.v2019_03_01.models.Deployment + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str :keyword callable cls: A custom type or function that will be passed the direct response :keyword str continuation_token: A continuation token to restart a poller from a saved state. :keyword polling: By default, your polling method will be ARMPolling. Pass in False for this @@ -2259,109 +2000,172 @@ def begin_create_or_update_at_subscription_scope( cls(response) :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.resource.resources.v2019_03_01.models.DeploymentExtended] - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - api_version = kwargs.pop('api_version', "2019-03-01") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] - polling = kwargs.pop('polling', True) # type: Union[bool, PollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType["_models.DeploymentExtended"] - lro_delay = kwargs.pop( - 'polling_interval', - self._config.polling_interval - ) - cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] + + @overload + def begin_create_or_update_at_subscription_scope( + self, deployment_name: str, parameters: IO, *, content_type: str = "application/json", **kwargs: Any + ) -> LROPoller[_models.DeploymentExtended]: + """Deploys resources at subscription scope. + + You can provide the template and parameters directly in the request or link to JSON files. + + :param deployment_name: The name of the deployment. Required. + :type deployment_name: str + :param parameters: Additional parameters supplied to the operation. Required. + :type parameters: IO + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be ARMPolling. Pass in False for this + operation to not poll, or pass in your own initialized polling object for a personal polling + strategy. + :paramtype polling: bool or ~azure.core.polling.PollingMethod + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of LROPoller that returns either DeploymentExtended or the result of + cls(response) + :rtype: + ~azure.core.polling.LROPoller[~azure.mgmt.resource.resources.v2019_03_01.models.DeploymentExtended] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace + def begin_create_or_update_at_subscription_scope( + self, deployment_name: str, parameters: Union[_models.Deployment, IO], **kwargs: Any + ) -> LROPoller[_models.DeploymentExtended]: + """Deploys resources at subscription scope. + + You can provide the template and parameters directly in the request or link to JSON files. + + :param deployment_name: The name of the deployment. Required. + :type deployment_name: str + :param parameters: Additional parameters supplied to the operation. Is either a model type or a + IO type. Required. + :type parameters: ~azure.mgmt.resource.resources.v2019_03_01.models.Deployment or IO + :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. + Default value is None. + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be ARMPolling. Pass in False for this + operation to not poll, or pass in your own initialized polling object for a personal polling + strategy. + :paramtype polling: bool or ~azure.core.polling.PollingMethod + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of LROPoller that returns either DeploymentExtended or the result of + cls(response) + :rtype: + ~azure.core.polling.LROPoller[~azure.mgmt.resource.resources.v2019_03_01.models.DeploymentExtended] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _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", "2019-03-01")) # type: str + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.DeploymentExtended] + polling = kwargs.pop("polling", True) # type: Union[bool, PollingMethod] + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token = kwargs.pop("continuation_token", None) # type: Optional[str] if cont_token is None: - raw_result = self._create_or_update_at_subscription_scope_initial( + raw_result = self._create_or_update_at_subscription_scope_initial( # type: ignore deployment_name=deployment_name, parameters=parameters, api_version=api_version, content_type=content_type, - cls=lambda x,y,z: x, + cls=lambda x, y, z: x, + headers=_headers, + params=_params, **kwargs ) - kwargs.pop('error_map', None) + kwargs.pop("error_map", None) def get_long_running_output(pipeline_response): - response = pipeline_response.http_response - deserialized = self._deserialize('DeploymentExtended', pipeline_response) + deserialized = self._deserialize("DeploymentExtended", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - - if polling is True: polling_method = ARMPolling(lro_delay, **kwargs) - elif polling is False: polling_method = NoPolling() - else: polling_method = polling + if polling is True: + polling_method = cast(PollingMethod, ARMPolling(lro_delay, **kwargs)) # type: PollingMethod + elif polling is False: + polling_method = cast(PollingMethod, NoPolling()) + else: + polling_method = polling if cont_token: return LROPoller.from_continuation_token( polling_method=polling_method, continuation_token=cont_token, client=self._client, - deserialization_callback=get_long_running_output + deserialization_callback=get_long_running_output, ) return LROPoller(self._client, raw_result, get_long_running_output, polling_method) - begin_create_or_update_at_subscription_scope.metadata = {'url': "/subscriptions/{subscriptionId}/providers/Microsoft.Resources/deployments/{deploymentName}"} # type: ignore + begin_create_or_update_at_subscription_scope.metadata = {"url": "/subscriptions/{subscriptionId}/providers/Microsoft.Resources/deployments/{deploymentName}"} # type: ignore @distributed_trace - def get_at_subscription_scope( - self, - deployment_name: str, - **kwargs: Any - ) -> "_models.DeploymentExtended": + def get_at_subscription_scope(self, deployment_name: str, **kwargs: Any) -> _models.DeploymentExtended: """Gets a deployment. - :param deployment_name: The name of the deployment to get. + :param deployment_name: The name of the deployment to get. Required. :type deployment_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: DeploymentExtended, or the result of cls(response) + :return: DeploymentExtended or the result of cls(response) :rtype: ~azure.mgmt.resource.resources.v2019_03_01.models.DeploymentExtended - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.DeploymentExtended"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + 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', "2019-03-01") # type: str + api_version = kwargs.pop("api_version", _params.pop("api-version", "2019-03-01")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[_models.DeploymentExtended] - request = build_deployments_get_at_subscription_scope_request( deployment_name=deployment_name, subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.get_at_subscription_scope.metadata['url'], + template_url=self.get_at_subscription_scope.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) - deserialized = self._deserialize('DeploymentExtended', pipeline_response) + deserialized = self._deserialize("DeploymentExtended", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - get_at_subscription_scope.metadata = {'url': "/subscriptions/{subscriptionId}/providers/Microsoft.Resources/deployments/{deploymentName}"} # type: ignore - + get_at_subscription_scope.metadata = {"url": "/subscriptions/{subscriptionId}/providers/Microsoft.Resources/deployments/{deploymentName}"} # type: ignore @distributed_trace def cancel_at_subscription_scope( # pylint: disable=inconsistent-return-statements - self, - deployment_name: str, - **kwargs: Any + self, deployment_name: str, **kwargs: Any ) -> None: """Cancels a currently running template deployment. @@ -2370,36 +2174,42 @@ def cancel_at_subscription_scope( # pylint: disable=inconsistent-return-stateme deployment stops the currently running template deployment and leaves the resources partially deployed. - :param deployment_name: The name of the deployment to cancel. + :param deployment_name: The name of the deployment to cancel. Required. :type deployment_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: None, or the result of cls(response) + :return: None or the result of cls(response) :rtype: None - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType[None] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + 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', "2019-03-01") # type: str + api_version = kwargs.pop("api_version", _params.pop("api-version", "2019-03-01")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[None] - request = build_deployments_cancel_at_subscription_scope_request( deployment_name=deployment_name, subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.cancel_at_subscription_scope.metadata['url'], + template_url=self.cancel_at_subscription_scope.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [204]: @@ -2409,38 +2219,94 @@ def cancel_at_subscription_scope( # pylint: disable=inconsistent-return-stateme if cls: return cls(pipeline_response, None, {}) - cancel_at_subscription_scope.metadata = {'url': "/subscriptions/{subscriptionId}/providers/Microsoft.Resources/deployments/{deploymentName}/cancel"} # type: ignore - + cancel_at_subscription_scope.metadata = {"url": "/subscriptions/{subscriptionId}/providers/Microsoft.Resources/deployments/{deploymentName}/cancel"} # type: ignore - @distributed_trace + @overload def validate_at_subscription_scope( self, deployment_name: str, - parameters: "_models.Deployment", + parameters: _models.Deployment, + *, + content_type: str = "application/json", **kwargs: Any - ) -> "_models.DeploymentValidateResult": + ) -> _models.DeploymentValidateResult: """Validates whether the specified template is syntactically correct and will be accepted by Azure Resource Manager.. - :param deployment_name: The name of the deployment. + :param deployment_name: The name of the deployment. Required. :type deployment_name: str - :param parameters: Parameters to validate. + :param parameters: Parameters to validate. Required. :type parameters: ~azure.mgmt.resource.resources.v2019_03_01.models.Deployment + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: DeploymentValidateResult or the result of cls(response) + :rtype: ~azure.mgmt.resource.resources.v2019_03_01.models.DeploymentValidateResult + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + def validate_at_subscription_scope( + self, deployment_name: str, parameters: IO, *, content_type: str = "application/json", **kwargs: Any + ) -> _models.DeploymentValidateResult: + """Validates whether the specified template is syntactically correct and will be accepted by Azure + Resource Manager.. + + :param deployment_name: The name of the deployment. Required. + :type deployment_name: str + :param parameters: Parameters to validate. Required. + :type parameters: IO + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: DeploymentValidateResult or the result of cls(response) + :rtype: ~azure.mgmt.resource.resources.v2019_03_01.models.DeploymentValidateResult + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace + def validate_at_subscription_scope( + self, deployment_name: str, parameters: Union[_models.Deployment, IO], **kwargs: Any + ) -> _models.DeploymentValidateResult: + """Validates whether the specified template is syntactically correct and will be accepted by Azure + Resource Manager.. + + :param deployment_name: The name of the deployment. Required. + :type deployment_name: str + :param parameters: Parameters to validate. Is either a model type or a IO type. Required. + :type parameters: ~azure.mgmt.resource.resources.v2019_03_01.models.Deployment or IO + :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. + Default value is None. + :paramtype content_type: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: DeploymentValidateResult, or the result of cls(response) + :return: DeploymentValidateResult or the result of cls(response) :rtype: ~azure.mgmt.resource.resources.v2019_03_01.models.DeploymentValidateResult - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.DeploymentValidateResult"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', "2019-03-01") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + api_version = kwargs.pop("api_version", _params.pop("api-version", "2019-03-01")) # type: str + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.DeploymentValidateResult] - _json = self._serialize.body(parameters, 'Deployment') + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(parameters, (IO, bytes)): + _content = parameters + else: + _json = self._serialize.body(parameters, "Deployment") request = build_deployments_validate_at_subscription_scope_request( deployment_name=deployment_name, @@ -2448,16 +2314,18 @@ def validate_at_subscription_scope( api_version=api_version, content_type=content_type, json=_json, - template_url=self.validate_at_subscription_scope.metadata['url'], + content=_content, + template_url=self.validate_at_subscription_scope.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200, 400]: @@ -2465,80 +2333,79 @@ def validate_at_subscription_scope( raise HttpResponseError(response=response, error_format=ARMErrorFormat) if response.status_code == 200: - deserialized = self._deserialize('DeploymentValidateResult', pipeline_response) + deserialized = self._deserialize("DeploymentValidateResult", pipeline_response) if response.status_code == 400: - deserialized = self._deserialize('DeploymentValidateResult', pipeline_response) + deserialized = self._deserialize("DeploymentValidateResult", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - validate_at_subscription_scope.metadata = {'url': "/subscriptions/{subscriptionId}/providers/Microsoft.Resources/deployments/{deploymentName}/validate"} # type: ignore - + validate_at_subscription_scope.metadata = {"url": "/subscriptions/{subscriptionId}/providers/Microsoft.Resources/deployments/{deploymentName}/validate"} # type: ignore @distributed_trace def export_template_at_subscription_scope( - self, - deployment_name: str, - **kwargs: Any - ) -> "_models.DeploymentExportResult": + self, deployment_name: str, **kwargs: Any + ) -> _models.DeploymentExportResult: """Exports the template used for specified deployment. - :param deployment_name: The name of the deployment from which to get the template. + :param deployment_name: The name of the deployment from which to get the template. Required. :type deployment_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: DeploymentExportResult, or the result of cls(response) + :return: DeploymentExportResult or the result of cls(response) :rtype: ~azure.mgmt.resource.resources.v2019_03_01.models.DeploymentExportResult - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.DeploymentExportResult"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + 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', "2019-03-01") # type: str + api_version = kwargs.pop("api_version", _params.pop("api-version", "2019-03-01")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[_models.DeploymentExportResult] - request = build_deployments_export_template_at_subscription_scope_request( deployment_name=deployment_name, subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.export_template_at_subscription_scope.metadata['url'], + template_url=self.export_template_at_subscription_scope.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) - deserialized = self._deserialize('DeploymentExportResult', pipeline_response) + deserialized = self._deserialize("DeploymentExportResult", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - export_template_at_subscription_scope.metadata = {'url': "/subscriptions/{subscriptionId}/providers/Microsoft.Resources/deployments/{deploymentName}/exportTemplate"} # type: ignore - + export_template_at_subscription_scope.metadata = {"url": "/subscriptions/{subscriptionId}/providers/Microsoft.Resources/deployments/{deploymentName}/exportTemplate"} # type: ignore @distributed_trace def list_at_subscription_scope( - self, - filter: Optional[str] = None, - top: Optional[int] = None, - **kwargs: Any - ) -> Iterable["_models.DeploymentListResult"]: + self, filter: Optional[str] = None, top: Optional[int] = None, **kwargs: Any + ) -> Iterable["_models.DeploymentExtended"]: """Get all the deployments for a subscription. :param filter: The filter to apply on the operation. For example, you can use @@ -2548,40 +2415,48 @@ def list_at_subscription_scope( value is None. :type top: int :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either DeploymentListResult or the result of - cls(response) + :return: An iterator like instance of either DeploymentExtended or the result of cls(response) :rtype: - ~azure.core.paging.ItemPaged[~azure.mgmt.resource.resources.v2019_03_01.models.DeploymentListResult] - :raises: ~azure.core.exceptions.HttpResponseError + ~azure.core.paging.ItemPaged[~azure.mgmt.resource.resources.v2019_03_01.models.DeploymentExtended] + :raises ~azure.core.exceptions.HttpResponseError: """ - api_version = kwargs.pop('api_version', "2019-03-01") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2019-03-01")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[_models.DeploymentListResult] - cls = kwargs.pop('cls', None) # type: ClsType["_models.DeploymentListResult"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) + def prepare_request(next_link=None): if not next_link: - + request = build_deployments_list_at_subscription_scope_request( subscription_id=self._config.subscription_id, - api_version=api_version, filter=filter, top=top, - template_url=self.list_at_subscription_scope.metadata['url'], + api_version=api_version, + template_url=self.list_at_subscription_scope.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore else: - - request = build_deployments_list_at_subscription_scope_request( - subscription_id=self._config.subscription_id, - template_url=next_link, - ) + # make call to next link with the client's api-version + _parsed_next_link = urlparse(next_link) + _next_request_params = case_insensitive_dict(parse_qs(_parsed_next_link.query)) + _next_request_params["api-version"] = self._config.api_version + request = HttpRequest("GET", urljoin(next_link, _parsed_next_link.path), params=_next_request_params) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore request.method = "GET" return request @@ -2595,10 +2470,8 @@ def extract_data(pipeline_response): def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) response = pipeline_response.http_response @@ -2608,42 +2481,43 @@ def get_next(next_link=None): return pipeline_response + return ItemPaged(get_next, extract_data) - return ItemPaged( - get_next, extract_data - ) - list_at_subscription_scope.metadata = {'url': "/subscriptions/{subscriptionId}/providers/Microsoft.Resources/deployments/"} # type: ignore + list_at_subscription_scope.metadata = {"url": "/subscriptions/{subscriptionId}/providers/Microsoft.Resources/deployments/"} # type: ignore def _delete_initial( # pylint: disable=inconsistent-return-statements - self, - resource_group_name: str, - deployment_name: str, - **kwargs: Any + self, resource_group_name: str, deployment_name: str, **kwargs: Any ) -> None: - cls = kwargs.pop('cls', None) # type: ClsType[None] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + 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', "2019-03-01") # type: str + api_version = kwargs.pop("api_version", _params.pop("api-version", "2019-03-01")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[None] - - request = build_deployments_delete_request_initial( + request = build_deployments_delete_request( resource_group_name=resource_group_name, deployment_name=deployment_name, subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self._delete_initial.metadata['url'], + template_url=self._delete_initial.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [202, 204]: @@ -2653,16 +2527,10 @@ 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.Resources/deployments/{deploymentName}"} # type: ignore - + _delete_initial.metadata = {"url": "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/Microsoft.Resources/deployments/{deploymentName}"} # type: ignore @distributed_trace - def begin_delete( # pylint: disable=inconsistent-return-statements - self, - resource_group_name: str, - deployment_name: str, - **kwargs: Any - ) -> LROPoller[None]: + def begin_delete(self, resource_group_name: str, deployment_name: str, **kwargs: Any) -> LROPoller[None]: """Deletes a deployment from the deployment history. A template deployment that is currently running cannot be deleted. Deleting a template @@ -2675,9 +2543,9 @@ def begin_delete( # pylint: disable=inconsistent-return-statements asynchronous request failed, the URI in the Location header returns an error-level status code. :param resource_group_name: The name of the resource group with the deployment to delete. The - name is case insensitive. + name is case insensitive. Required. :type resource_group_name: str - :param deployment_name: The name of the deployment to delete. + :param deployment_name: The name of the deployment to delete. Required. :type deployment_name: str :keyword callable cls: A custom type or function that will be passed the direct response :keyword str continuation_token: A continuation token to restart a poller from a saved state. @@ -2689,88 +2557,93 @@ def begin_delete( # pylint: disable=inconsistent-return-statements Retry-After header is present. :return: An instance of LROPoller that returns either None or the result of cls(response) :rtype: ~azure.core.polling.LROPoller[None] - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - api_version = kwargs.pop('api_version', "2019-03-01") # type: str - polling = kwargs.pop('polling', True) # type: Union[bool, PollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType[None] - lro_delay = kwargs.pop( - 'polling_interval', - self._config.polling_interval - ) - cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2019-03-01")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[None] + polling = kwargs.pop("polling", True) # type: Union[bool, PollingMethod] + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token = kwargs.pop("continuation_token", None) # type: Optional[str] if cont_token is None: - raw_result = self._delete_initial( + raw_result = self._delete_initial( # type: ignore resource_group_name=resource_group_name, deployment_name=deployment_name, api_version=api_version, - cls=lambda x,y,z: x, + cls=lambda x, y, z: x, + headers=_headers, + params=_params, **kwargs ) - kwargs.pop('error_map', None) + kwargs.pop("error_map", None) - def get_long_running_output(pipeline_response): + def get_long_running_output(pipeline_response): # pylint: disable=inconsistent-return-statements if cls: return cls(pipeline_response, None, {}) - - if polling is True: polling_method = ARMPolling(lro_delay, **kwargs) - elif polling is False: polling_method = NoPolling() - else: polling_method = polling + if polling is True: + polling_method = cast(PollingMethod, ARMPolling(lro_delay, **kwargs)) # type: PollingMethod + elif polling is False: + polling_method = cast(PollingMethod, NoPolling()) + else: + polling_method = polling if cont_token: return LROPoller.from_continuation_token( polling_method=polling_method, continuation_token=cont_token, client=self._client, - deserialization_callback=get_long_running_output + deserialization_callback=get_long_running_output, ) return LROPoller(self._client, raw_result, get_long_running_output, polling_method) - begin_delete.metadata = {'url': "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/Microsoft.Resources/deployments/{deploymentName}"} # type: ignore + begin_delete.metadata = {"url": "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/Microsoft.Resources/deployments/{deploymentName}"} # type: ignore @distributed_trace - def check_existence( - self, - resource_group_name: str, - deployment_name: str, - **kwargs: Any - ) -> bool: + def check_existence(self, resource_group_name: str, deployment_name: str, **kwargs: Any) -> bool: """Checks whether the deployment exists. :param resource_group_name: The name of the resource group with the deployment to check. The - name is case insensitive. + name is case insensitive. Required. :type resource_group_name: str - :param deployment_name: The name of the deployment to check. + :param deployment_name: The name of the deployment to check. Required. :type deployment_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: bool, or the result of cls(response) + :return: bool or the result of cls(response) :rtype: bool - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType[None] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) - api_version = kwargs.pop('api_version', "2019-03-01") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2019-03-01")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[None] - request = build_deployments_check_existence_request( resource_group_name=resource_group_name, deployment_name=deployment_name, subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.check_existence.metadata['url'], + template_url=self.check_existence.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [204, 404]: @@ -2781,44 +2654,53 @@ def check_existence( return cls(pipeline_response, None, {}) return 200 <= response.status_code <= 299 - check_existence.metadata = {'url': "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/Microsoft.Resources/deployments/{deploymentName}"} # type: ignore - + check_existence.metadata = {"url": "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/Microsoft.Resources/deployments/{deploymentName}"} # type: ignore def _create_or_update_initial( - self, - resource_group_name: str, - deployment_name: str, - parameters: "_models.Deployment", - **kwargs: Any - ) -> "_models.DeploymentExtended": - cls = kwargs.pop('cls', None) # type: ClsType["_models.DeploymentExtended"] + self, resource_group_name: str, deployment_name: str, parameters: Union[_models.Deployment, IO], **kwargs: Any + ) -> _models.DeploymentExtended: error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', "2019-03-01") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + api_version = kwargs.pop("api_version", _params.pop("api-version", "2019-03-01")) # type: str + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.DeploymentExtended] - _json = self._serialize.body(parameters, 'Deployment') + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(parameters, (IO, bytes)): + _content = parameters + else: + _json = self._serialize.body(parameters, "Deployment") - request = build_deployments_create_or_update_request_initial( + request = build_deployments_create_or_update_request( resource_group_name=resource_group_name, deployment_name=deployment_name, subscription_id=self._config.subscription_id, api_version=api_version, content_type=content_type, json=_json, - template_url=self._create_or_update_initial.metadata['url'], + content=_content, + template_url=self._create_or_update_initial.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200, 201]: @@ -2826,38 +2708,42 @@ def _create_or_update_initial( raise HttpResponseError(response=response, error_format=ARMErrorFormat) if response.status_code == 200: - deserialized = self._deserialize('DeploymentExtended', pipeline_response) + deserialized = self._deserialize("DeploymentExtended", pipeline_response) if response.status_code == 201: - deserialized = self._deserialize('DeploymentExtended', pipeline_response) + deserialized = self._deserialize("DeploymentExtended", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - _create_or_update_initial.metadata = {'url': "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/Microsoft.Resources/deployments/{deploymentName}"} # type: ignore - + _create_or_update_initial.metadata = {"url": "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/Microsoft.Resources/deployments/{deploymentName}"} # type: ignore - @distributed_trace + @overload def begin_create_or_update( self, resource_group_name: str, deployment_name: str, - parameters: "_models.Deployment", + parameters: _models.Deployment, + *, + content_type: str = "application/json", **kwargs: Any - ) -> LROPoller["_models.DeploymentExtended"]: + ) -> LROPoller[_models.DeploymentExtended]: """Deploys resources to a resource group. You can provide the template and parameters directly in the request or link to JSON files. :param resource_group_name: The name of the resource group to deploy the resources to. The name - is case insensitive. The resource group must already exist. + is case insensitive. The resource group must already exist. Required. :type resource_group_name: str - :param deployment_name: The name of the deployment. + :param deployment_name: The name of the deployment. Required. :type deployment_name: str - :param parameters: Additional parameters supplied to the operation. + :param parameters: Additional parameters supplied to the operation. Required. :type parameters: ~azure.mgmt.resource.resources.v2019_03_01.models.Deployment + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str :keyword callable cls: A custom type or function that will be passed the direct response :keyword str continuation_token: A continuation token to restart a poller from a saved state. :keyword polling: By default, your polling method will be ARMPolling. Pass in False for this @@ -2870,115 +2756,189 @@ def begin_create_or_update( cls(response) :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.resource.resources.v2019_03_01.models.DeploymentExtended] - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - api_version = kwargs.pop('api_version', "2019-03-01") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] - polling = kwargs.pop('polling', True) # type: Union[bool, PollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType["_models.DeploymentExtended"] - lro_delay = kwargs.pop( - 'polling_interval', - self._config.polling_interval - ) - cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] - if cont_token is None: - raw_result = self._create_or_update_initial( - resource_group_name=resource_group_name, - deployment_name=deployment_name, - parameters=parameters, - api_version=api_version, - content_type=content_type, - cls=lambda x,y,z: x, - **kwargs - ) - kwargs.pop('error_map', None) - - def get_long_running_output(pipeline_response): - response = pipeline_response.http_response - deserialized = self._deserialize('DeploymentExtended', pipeline_response) - if cls: - return cls(pipeline_response, deserialized, {}) - return deserialized - - - if polling is True: polling_method = ARMPolling(lro_delay, **kwargs) - elif polling is False: polling_method = NoPolling() - else: polling_method = polling - if cont_token: - return LROPoller.from_continuation_token( - polling_method=polling_method, - continuation_token=cont_token, - client=self._client, - deserialization_callback=get_long_running_output - ) - return LROPoller(self._client, raw_result, get_long_running_output, polling_method) - - begin_create_or_update.metadata = {'url': "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/Microsoft.Resources/deployments/{deploymentName}"} # type: ignore - @distributed_trace - def get( + @overload + def begin_create_or_update( self, resource_group_name: str, deployment_name: str, + parameters: IO, + *, + content_type: str = "application/json", **kwargs: Any - ) -> "_models.DeploymentExtended": - """Gets a deployment. + ) -> LROPoller[_models.DeploymentExtended]: + """Deploys resources to a resource group. - :param resource_group_name: The name of the resource group. The name is case insensitive. + You can provide the template and parameters directly in the request or link to JSON files. + + :param resource_group_name: The name of the resource group to deploy the resources to. The name + is case insensitive. The resource group must already exist. Required. :type resource_group_name: str - :param deployment_name: The name of the deployment to get. + :param deployment_name: The name of the deployment. Required. :type deployment_name: str + :param parameters: Additional parameters supplied to the operation. Required. + :type parameters: IO + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: DeploymentExtended, or the result of cls(response) - :rtype: ~azure.mgmt.resource.resources.v2019_03_01.models.DeploymentExtended - :raises: ~azure.core.exceptions.HttpResponseError + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be ARMPolling. Pass in False for this + operation to not poll, or pass in your own initialized polling object for a personal polling + strategy. + :paramtype polling: bool or ~azure.core.polling.PollingMethod + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of LROPoller that returns either DeploymentExtended or the result of + cls(response) + :rtype: + ~azure.core.polling.LROPoller[~azure.mgmt.resource.resources.v2019_03_01.models.DeploymentExtended] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace + def begin_create_or_update( + self, resource_group_name: str, deployment_name: str, parameters: Union[_models.Deployment, IO], **kwargs: Any + ) -> LROPoller[_models.DeploymentExtended]: + """Deploys resources to a resource group. + + You can provide the template and parameters directly in the request or link to JSON files. + + :param resource_group_name: The name of the resource group to deploy the resources to. The name + is case insensitive. The resource group must already exist. Required. + :type resource_group_name: str + :param deployment_name: The name of the deployment. Required. + :type deployment_name: str + :param parameters: Additional parameters supplied to the operation. Is either a model type or a + IO type. Required. + :type parameters: ~azure.mgmt.resource.resources.v2019_03_01.models.Deployment or IO + :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. + Default value is None. + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be ARMPolling. Pass in False for this + operation to not poll, or pass in your own initialized polling object for a personal polling + strategy. + :paramtype polling: bool or ~azure.core.polling.PollingMethod + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of LROPoller that returns either DeploymentExtended or the result of + cls(response) + :rtype: + ~azure.core.polling.LROPoller[~azure.mgmt.resource.resources.v2019_03_01.models.DeploymentExtended] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _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", "2019-03-01")) # type: str + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.DeploymentExtended] + polling = kwargs.pop("polling", True) # type: Union[bool, PollingMethod] + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token = kwargs.pop("continuation_token", None) # type: Optional[str] + if cont_token is None: + raw_result = self._create_or_update_initial( # type: ignore + resource_group_name=resource_group_name, + deployment_name=deployment_name, + parameters=parameters, + api_version=api_version, + content_type=content_type, + cls=lambda x, y, z: x, + headers=_headers, + params=_params, + **kwargs + ) + kwargs.pop("error_map", None) + + def get_long_running_output(pipeline_response): + deserialized = self._deserialize("DeploymentExtended", pipeline_response) + if cls: + return cls(pipeline_response, deserialized, {}) + return deserialized + + if polling is True: + polling_method = cast(PollingMethod, ARMPolling(lro_delay, **kwargs)) # type: PollingMethod + elif polling is False: + polling_method = cast(PollingMethod, NoPolling()) + else: + polling_method = polling + if cont_token: + return LROPoller.from_continuation_token( + polling_method=polling_method, + continuation_token=cont_token, + client=self._client, + deserialization_callback=get_long_running_output, + ) + return LROPoller(self._client, raw_result, get_long_running_output, polling_method) + + begin_create_or_update.metadata = {"url": "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/Microsoft.Resources/deployments/{deploymentName}"} # type: ignore + + @distributed_trace + def get(self, resource_group_name: str, deployment_name: str, **kwargs: Any) -> _models.DeploymentExtended: + """Gets a deployment. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param deployment_name: The name of the deployment to get. Required. + :type deployment_name: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: DeploymentExtended or the result of cls(response) + :rtype: ~azure.mgmt.resource.resources.v2019_03_01.models.DeploymentExtended + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.DeploymentExtended"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + 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', "2019-03-01") # type: str + api_version = kwargs.pop("api_version", _params.pop("api-version", "2019-03-01")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[_models.DeploymentExtended] - request = build_deployments_get_request( resource_group_name=resource_group_name, deployment_name=deployment_name, subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.get.metadata['url'], + template_url=self.get.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) - deserialized = self._deserialize('DeploymentExtended', pipeline_response) + deserialized = self._deserialize("DeploymentExtended", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - get.metadata = {'url': "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/Microsoft.Resources/deployments/{deploymentName}"} # type: ignore - + get.metadata = {"url": "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/Microsoft.Resources/deployments/{deploymentName}"} # type: ignore @distributed_trace def cancel( # pylint: disable=inconsistent-return-statements - self, - resource_group_name: str, - deployment_name: str, - **kwargs: Any + self, resource_group_name: str, deployment_name: str, **kwargs: Any ) -> None: """Cancels a currently running template deployment. @@ -2988,38 +2948,45 @@ def cancel( # pylint: disable=inconsistent-return-statements partially deployed. :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. :type resource_group_name: str - :param deployment_name: The name of the deployment to cancel. + :param deployment_name: The name of the deployment to cancel. Required. :type deployment_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: None, or the result of cls(response) + :return: None or the result of cls(response) :rtype: None - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType[None] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) - api_version = kwargs.pop('api_version', "2019-03-01") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2019-03-01")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[None] - request = build_deployments_cancel_request( resource_group_name=resource_group_name, deployment_name=deployment_name, subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.cancel.metadata['url'], + template_url=self.cancel.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [204]: @@ -3029,42 +2996,110 @@ def cancel( # pylint: disable=inconsistent-return-statements if cls: return cls(pipeline_response, None, {}) - cancel.metadata = {'url': "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/Microsoft.Resources/deployments/{deploymentName}/cancel"} # type: ignore + cancel.metadata = {"url": "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/Microsoft.Resources/deployments/{deploymentName}/cancel"} # type: ignore - - @distributed_trace + @overload def validate( self, resource_group_name: str, deployment_name: str, - parameters: "_models.Deployment", + parameters: _models.Deployment, + *, + content_type: str = "application/json", **kwargs: Any - ) -> "_models.DeploymentValidateResult": + ) -> _models.DeploymentValidateResult: """Validates whether the specified template is syntactically correct and will be accepted by Azure Resource Manager.. :param resource_group_name: The name of the resource group the template will be deployed to. - The name is case insensitive. + The name is case insensitive. Required. :type resource_group_name: str - :param deployment_name: The name of the deployment. + :param deployment_name: The name of the deployment. Required. :type deployment_name: str - :param parameters: Parameters to validate. + :param parameters: Parameters to validate. Required. :type parameters: ~azure.mgmt.resource.resources.v2019_03_01.models.Deployment + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: DeploymentValidateResult or the result of cls(response) + :rtype: ~azure.mgmt.resource.resources.v2019_03_01.models.DeploymentValidateResult + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + def validate( + self, + resource_group_name: str, + deployment_name: str, + parameters: IO, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.DeploymentValidateResult: + """Validates whether the specified template is syntactically correct and will be accepted by Azure + Resource Manager.. + + :param resource_group_name: The name of the resource group the template will be deployed to. + The name is case insensitive. Required. + :type resource_group_name: str + :param deployment_name: The name of the deployment. Required. + :type deployment_name: str + :param parameters: Parameters to validate. Required. + :type parameters: IO + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: DeploymentValidateResult or the result of cls(response) + :rtype: ~azure.mgmt.resource.resources.v2019_03_01.models.DeploymentValidateResult + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace + def validate( + self, resource_group_name: str, deployment_name: str, parameters: Union[_models.Deployment, IO], **kwargs: Any + ) -> _models.DeploymentValidateResult: + """Validates whether the specified template is syntactically correct and will be accepted by Azure + Resource Manager.. + + :param resource_group_name: The name of the resource group the template will be deployed to. + The name is case insensitive. Required. + :type resource_group_name: str + :param deployment_name: The name of the deployment. Required. + :type deployment_name: str + :param parameters: Parameters to validate. Is either a model type or a IO type. Required. + :type parameters: ~azure.mgmt.resource.resources.v2019_03_01.models.Deployment or IO + :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. + Default value is None. + :paramtype content_type: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: DeploymentValidateResult, or the result of cls(response) + :return: DeploymentValidateResult or the result of cls(response) :rtype: ~azure.mgmt.resource.resources.v2019_03_01.models.DeploymentValidateResult - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.DeploymentValidateResult"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) - api_version = kwargs.pop('api_version', "2019-03-01") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - _json = self._serialize.body(parameters, 'Deployment') + api_version = kwargs.pop("api_version", _params.pop("api-version", "2019-03-01")) # type: str + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.DeploymentValidateResult] + + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(parameters, (IO, bytes)): + _content = parameters + else: + _json = self._serialize.body(parameters, "Deployment") request = build_deployments_validate_request( resource_group_name=resource_group_name, @@ -3073,16 +3108,18 @@ def validate( api_version=api_version, content_type=content_type, json=_json, - template_url=self.validate.metadata['url'], + content=_content, + template_url=self.validate.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200, 400]: @@ -3090,89 +3127,87 @@ def validate( raise HttpResponseError(response=response, error_format=ARMErrorFormat) if response.status_code == 200: - deserialized = self._deserialize('DeploymentValidateResult', pipeline_response) + deserialized = self._deserialize("DeploymentValidateResult", pipeline_response) if response.status_code == 400: - deserialized = self._deserialize('DeploymentValidateResult', pipeline_response) + deserialized = self._deserialize("DeploymentValidateResult", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - validate.metadata = {'url': "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/Microsoft.Resources/deployments/{deploymentName}/validate"} # type: ignore - + validate.metadata = {"url": "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/Microsoft.Resources/deployments/{deploymentName}/validate"} # type: ignore @distributed_trace def export_template( - self, - resource_group_name: str, - deployment_name: str, - **kwargs: Any - ) -> "_models.DeploymentExportResult": + self, resource_group_name: str, deployment_name: str, **kwargs: Any + ) -> _models.DeploymentExportResult: """Exports the template used for specified deployment. :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. :type resource_group_name: str - :param deployment_name: The name of the deployment from which to get the template. + :param deployment_name: The name of the deployment from which to get the template. Required. :type deployment_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: DeploymentExportResult, or the result of cls(response) + :return: DeploymentExportResult or the result of cls(response) :rtype: ~azure.mgmt.resource.resources.v2019_03_01.models.DeploymentExportResult - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.DeploymentExportResult"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + 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', "2019-03-01") # type: str + api_version = kwargs.pop("api_version", _params.pop("api-version", "2019-03-01")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[_models.DeploymentExportResult] - request = build_deployments_export_template_request( resource_group_name=resource_group_name, deployment_name=deployment_name, subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.export_template.metadata['url'], + template_url=self.export_template.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) - deserialized = self._deserialize('DeploymentExportResult', pipeline_response) + deserialized = self._deserialize("DeploymentExportResult", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - export_template.metadata = {'url': "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/Microsoft.Resources/deployments/{deploymentName}/exportTemplate"} # type: ignore - + export_template.metadata = {"url": "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/Microsoft.Resources/deployments/{deploymentName}/exportTemplate"} # type: ignore @distributed_trace def list_by_resource_group( - self, - resource_group_name: str, - filter: Optional[str] = None, - top: Optional[int] = None, - **kwargs: Any - ) -> Iterable["_models.DeploymentListResult"]: + self, resource_group_name: str, filter: Optional[str] = None, top: Optional[int] = None, **kwargs: Any + ) -> Iterable["_models.DeploymentExtended"]: """Get all the deployments for a resource group. :param resource_group_name: The name of the resource group with the deployments to get. The - name is case insensitive. + name is case insensitive. Required. :type resource_group_name: str :param filter: The filter to apply on the operation. For example, you can use $filter=provisioningState eq '{state}'. Default value is None. @@ -3181,42 +3216,49 @@ def list_by_resource_group( value is None. :type top: int :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either DeploymentListResult or the result of - cls(response) + :return: An iterator like instance of either DeploymentExtended or the result of cls(response) :rtype: - ~azure.core.paging.ItemPaged[~azure.mgmt.resource.resources.v2019_03_01.models.DeploymentListResult] - :raises: ~azure.core.exceptions.HttpResponseError + ~azure.core.paging.ItemPaged[~azure.mgmt.resource.resources.v2019_03_01.models.DeploymentExtended] + :raises ~azure.core.exceptions.HttpResponseError: """ - api_version = kwargs.pop('api_version', "2019-03-01") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2019-03-01")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[_models.DeploymentListResult] - cls = kwargs.pop('cls', None) # type: ClsType["_models.DeploymentListResult"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) + def prepare_request(next_link=None): if not next_link: - + request = build_deployments_list_by_resource_group_request( resource_group_name=resource_group_name, subscription_id=self._config.subscription_id, - api_version=api_version, filter=filter, top=top, - template_url=self.list_by_resource_group.metadata['url'], + 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.url = self._client.format_url(request.url) # type: ignore else: - - request = build_deployments_list_by_resource_group_request( - resource_group_name=resource_group_name, - subscription_id=self._config.subscription_id, - template_url=next_link, - ) + # make call to next link with the client's api-version + _parsed_next_link = urlparse(next_link) + _next_request_params = case_insensitive_dict(parse_qs(_parsed_next_link.query)) + _next_request_params["api-version"] = self._config.api_version + request = HttpRequest("GET", urljoin(next_link, _parsed_next_link.path), params=_next_request_params) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore request.method = "GET" return request @@ -3230,10 +3272,8 @@ def extract_data(pipeline_response): def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) response = pipeline_response.http_response @@ -3243,204 +3283,204 @@ def get_next(next_link=None): return pipeline_response + return ItemPaged(get_next, extract_data) - return ItemPaged( - get_next, extract_data - ) - list_by_resource_group.metadata = {'url': "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/Microsoft.Resources/deployments/"} # type: ignore + list_by_resource_group.metadata = {"url": "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/Microsoft.Resources/deployments/"} # type: ignore @distributed_trace - def calculate_template_hash( - self, - template: Any, - **kwargs: Any - ) -> "_models.TemplateHashResult": + def calculate_template_hash(self, template: JSON, **kwargs: Any) -> _models.TemplateHashResult: """Calculate the hash of the given template. - :param template: The template provided to calculate hash. - :type template: any + :param template: The template provided to calculate hash. Required. + :type template: JSON :keyword callable cls: A custom type or function that will be passed the direct response - :return: TemplateHashResult, or the result of cls(response) + :return: TemplateHashResult or the result of cls(response) :rtype: ~azure.mgmt.resource.resources.v2019_03_01.models.TemplateHashResult - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.TemplateHashResult"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', "2019-03-01") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + api_version = kwargs.pop("api_version", _params.pop("api-version", "2019-03-01")) # type: str + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", "application/json")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[_models.TemplateHashResult] - _json = self._serialize.body(template, 'object') + _json = self._serialize.body(template, "object") request = build_deployments_calculate_template_hash_request( api_version=api_version, content_type=content_type, json=_json, - template_url=self.calculate_template_hash.metadata['url'], + template_url=self.calculate_template_hash.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) - deserialized = self._deserialize('TemplateHashResult', pipeline_response) + deserialized = self._deserialize("TemplateHashResult", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - calculate_template_hash.metadata = {'url': "/providers/Microsoft.Resources/calculateTemplateHash"} # type: ignore + calculate_template_hash.metadata = {"url": "/providers/Microsoft.Resources/calculateTemplateHash"} # type: ignore -class ProvidersOperations(object): - """ProvidersOperations operations. - You should not instantiate this class directly. Instead, you should create a Client instance that - instantiates it for you and attaches it as an attribute. +class ProvidersOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. - :ivar models: Alias to model classes used in this operation group. - :type models: ~azure.mgmt.resource.resources.v2019_03_01.models - :param client: Client for service requests. - :param config: Configuration of service client. - :param serializer: An object model serializer. - :param deserializer: An object model deserializer. + Instead, you should access the following operations through + :class:`~azure.mgmt.resource.resources.v2019_03_01.ResourceManagementClient`'s + :attr:`providers` attribute. """ models = _models - def __init__(self, client, config, serializer, deserializer): - self._client = client - self._serialize = serializer - self._deserialize = deserializer - self._config = config + def __init__(self, *args, **kwargs): + input_args = list(args) + self._client = input_args.pop(0) if input_args else kwargs.pop("client") + self._config = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") @distributed_trace - def unregister( - self, - resource_provider_namespace: str, - **kwargs: Any - ) -> "_models.Provider": + def unregister(self, resource_provider_namespace: str, **kwargs: Any) -> _models.Provider: """Unregisters a subscription from a resource provider. :param resource_provider_namespace: The namespace of the resource provider to unregister. + Required. :type resource_provider_namespace: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: Provider, or the result of cls(response) + :return: Provider or the result of cls(response) :rtype: ~azure.mgmt.resource.resources.v2019_03_01.models.Provider - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.Provider"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + 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', "2019-03-01") # type: str + api_version = kwargs.pop("api_version", _params.pop("api-version", "2019-03-01")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[_models.Provider] - request = build_providers_unregister_request( resource_provider_namespace=resource_provider_namespace, subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.unregister.metadata['url'], + template_url=self.unregister.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) - deserialized = self._deserialize('Provider', pipeline_response) + deserialized = self._deserialize("Provider", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - unregister.metadata = {'url': "/subscriptions/{subscriptionId}/providers/{resourceProviderNamespace}/unregister"} # type: ignore - + unregister.metadata = {"url": "/subscriptions/{subscriptionId}/providers/{resourceProviderNamespace}/unregister"} # type: ignore @distributed_trace - def register( - self, - resource_provider_namespace: str, - **kwargs: Any - ) -> "_models.Provider": + def register(self, resource_provider_namespace: str, **kwargs: Any) -> _models.Provider: """Registers a subscription with a resource provider. :param resource_provider_namespace: The namespace of the resource provider to register. + Required. :type resource_provider_namespace: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: Provider, or the result of cls(response) + :return: Provider or the result of cls(response) :rtype: ~azure.mgmt.resource.resources.v2019_03_01.models.Provider - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.Provider"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + 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', "2019-03-01") # type: str + api_version = kwargs.pop("api_version", _params.pop("api-version", "2019-03-01")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[_models.Provider] - request = build_providers_register_request( resource_provider_namespace=resource_provider_namespace, subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.register.metadata['url'], + template_url=self.register.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) - deserialized = self._deserialize('Provider', pipeline_response) + deserialized = self._deserialize("Provider", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - register.metadata = {'url': "/subscriptions/{subscriptionId}/providers/{resourceProviderNamespace}/register"} # type: ignore - + register.metadata = {"url": "/subscriptions/{subscriptionId}/providers/{resourceProviderNamespace}/register"} # type: ignore @distributed_trace def list( - self, - top: Optional[int] = None, - expand: Optional[str] = None, - **kwargs: Any - ) -> Iterable["_models.ProviderListResult"]: + self, top: Optional[int] = None, expand: Optional[str] = None, **kwargs: Any + ) -> Iterable["_models.Provider"]: """Gets all resource providers for a subscription. :param top: The number of results to return. If null is passed returns all deployments. Default @@ -3451,39 +3491,48 @@ def list( response, use $expand=resourceTypes/aliases. Default value is None. :type expand: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either ProviderListResult or the result of cls(response) + :return: An iterator like instance of either Provider or the result of cls(response) :rtype: - ~azure.core.paging.ItemPaged[~azure.mgmt.resource.resources.v2019_03_01.models.ProviderListResult] - :raises: ~azure.core.exceptions.HttpResponseError + ~azure.core.paging.ItemPaged[~azure.mgmt.resource.resources.v2019_03_01.models.Provider] + :raises ~azure.core.exceptions.HttpResponseError: """ - api_version = kwargs.pop('api_version', "2019-03-01") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2019-03-01")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[_models.ProviderListResult] - cls = kwargs.pop('cls', None) # type: ClsType["_models.ProviderListResult"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) + def prepare_request(next_link=None): if not next_link: - + request = build_providers_list_request( subscription_id=self._config.subscription_id, - api_version=api_version, top=top, expand=expand, - template_url=self.list.metadata['url'], + 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.url = self._client.format_url(request.url) # type: ignore else: - - request = build_providers_list_request( - subscription_id=self._config.subscription_id, - template_url=next_link, - ) + # make call to next link with the client's api-version + _parsed_next_link = urlparse(next_link) + _next_request_params = case_insensitive_dict(parse_qs(_parsed_next_link.query)) + _next_request_params["api-version"] = self._config.api_version + request = HttpRequest("GET", urljoin(next_link, _parsed_next_link.path), params=_next_request_params) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore request.method = "GET" return request @@ -3497,10 +3546,8 @@ def extract_data(pipeline_response): def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) response = pipeline_response.http_response @@ -3510,91 +3557,88 @@ def get_next(next_link=None): return pipeline_response + return ItemPaged(get_next, extract_data) - return ItemPaged( - get_next, extract_data - ) - list.metadata = {'url': "/subscriptions/{subscriptionId}/providers"} # type: ignore + list.metadata = {"url": "/subscriptions/{subscriptionId}/providers"} # type: ignore @distributed_trace - def get( - self, - resource_provider_namespace: str, - expand: Optional[str] = None, - **kwargs: Any - ) -> "_models.Provider": + def get(self, resource_provider_namespace: str, expand: Optional[str] = None, **kwargs: Any) -> _models.Provider: """Gets the specified resource provider. - :param resource_provider_namespace: The namespace of the resource provider. + :param resource_provider_namespace: The namespace of the resource provider. Required. :type resource_provider_namespace: str :param expand: The $expand query parameter. For example, to include property aliases in response, use $expand=resourceTypes/aliases. Default value is None. :type expand: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: Provider, or the result of cls(response) + :return: Provider or the result of cls(response) :rtype: ~azure.mgmt.resource.resources.v2019_03_01.models.Provider - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.Provider"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + 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', "2019-03-01") # type: str + api_version = kwargs.pop("api_version", _params.pop("api-version", "2019-03-01")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[_models.Provider] - request = build_providers_get_request( resource_provider_namespace=resource_provider_namespace, subscription_id=self._config.subscription_id, - api_version=api_version, expand=expand, - template_url=self.get.metadata['url'], + api_version=api_version, + template_url=self.get.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) - deserialized = self._deserialize('Provider', pipeline_response) + deserialized = self._deserialize("Provider", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - get.metadata = {'url': "/subscriptions/{subscriptionId}/providers/{resourceProviderNamespace}"} # type: ignore + get.metadata = {"url": "/subscriptions/{subscriptionId}/providers/{resourceProviderNamespace}"} # type: ignore -class ResourcesOperations(object): # pylint: disable=too-many-public-methods - """ResourcesOperations operations. - You should not instantiate this class directly. Instead, you should create a Client instance that - instantiates it for you and attaches it as an attribute. +class ResourcesOperations: # pylint: disable=too-many-public-methods + """ + .. warning:: + **DO NOT** instantiate this class directly. - :ivar models: Alias to model classes used in this operation group. - :type models: ~azure.mgmt.resource.resources.v2019_03_01.models - :param client: Client for service requests. - :param config: Configuration of service client. - :param serializer: An object model serializer. - :param deserializer: An object model deserializer. + Instead, you should access the following operations through + :class:`~azure.mgmt.resource.resources.v2019_03_01.ResourceManagementClient`'s + :attr:`resources` attribute. """ models = _models - def __init__(self, client, config, serializer, deserializer): - self._client = client - self._serialize = serializer - self._deserialize = deserializer - self._config = config + def __init__(self, *args, **kwargs): + input_args = list(args) + self._client = input_args.pop(0) if input_args else kwargs.pop("client") + self._config = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") @distributed_trace def list_by_resource_group( @@ -3604,10 +3648,10 @@ def list_by_resource_group( expand: Optional[str] = None, top: Optional[int] = None, **kwargs: Any - ) -> Iterable["_models.ResourceListResult"]: + ) -> Iterable["_models.GenericResourceExpanded"]: """Get all the resources for a resource group. - :param resource_group_name: The resource group with the resources to get. + :param resource_group_name: The resource group with the resources to get. Required. :type resource_group_name: str :param filter: The filter to apply on the operation.:code:`
`:code:`
`The properties you can use for eq (equals) or ne (not equals) are: location, resourceType, name, resourceGroup, @@ -3632,42 +3676,51 @@ def list_by_resource_group( value is None. :type top: int :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either ResourceListResult or the result of cls(response) + :return: An iterator like instance of either GenericResourceExpanded or the result of + cls(response) :rtype: - ~azure.core.paging.ItemPaged[~azure.mgmt.resource.resources.v2019_03_01.models.ResourceListResult] - :raises: ~azure.core.exceptions.HttpResponseError + ~azure.core.paging.ItemPaged[~azure.mgmt.resource.resources.v2019_03_01.models.GenericResourceExpanded] + :raises ~azure.core.exceptions.HttpResponseError: """ - api_version = kwargs.pop('api_version', "2019-03-01") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2019-03-01")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[_models.ResourceListResult] - cls = kwargs.pop('cls', None) # type: ClsType["_models.ResourceListResult"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) + def prepare_request(next_link=None): if not next_link: - + request = build_resources_list_by_resource_group_request( resource_group_name=resource_group_name, subscription_id=self._config.subscription_id, - api_version=api_version, filter=filter, expand=expand, top=top, - template_url=self.list_by_resource_group.metadata['url'], + 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.url = self._client.format_url(request.url) # type: ignore else: - - request = build_resources_list_by_resource_group_request( - resource_group_name=resource_group_name, - subscription_id=self._config.subscription_id, - template_url=next_link, - ) + # make call to next link with the client's api-version + _parsed_next_link = urlparse(next_link) + _next_request_params = case_insensitive_dict(parse_qs(_parsed_next_link.query)) + _next_request_params["api-version"] = self._config.api_version + request = HttpRequest("GET", urljoin(next_link, _parsed_next_link.path), params=_next_request_params) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore request.method = "GET" return request @@ -3681,10 +3734,8 @@ def extract_data(pipeline_response): def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) response = pipeline_response.http_response @@ -3694,45 +3745,54 @@ def get_next(next_link=None): return pipeline_response + return ItemPaged(get_next, extract_data) - return ItemPaged( - get_next, extract_data - ) - list_by_resource_group.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/resources"} # type: ignore + list_by_resource_group.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/resources"} # type: ignore def _move_resources_initial( # pylint: disable=inconsistent-return-statements - self, - source_resource_group_name: str, - parameters: "_models.ResourcesMoveInfo", - **kwargs: Any + self, source_resource_group_name: str, parameters: Union[_models.ResourcesMoveInfo, IO], **kwargs: Any ) -> None: - cls = kwargs.pop('cls', None) # type: ClsType[None] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', "2019-03-01") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + api_version = kwargs.pop("api_version", _params.pop("api-version", "2019-03-01")) # type: str + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[None] - _json = self._serialize.body(parameters, 'ResourcesMoveInfo') + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(parameters, (IO, bytes)): + _content = parameters + else: + _json = self._serialize.body(parameters, "ResourcesMoveInfo") - request = build_resources_move_resources_request_initial( + request = build_resources_move_resources_request( source_resource_group_name=source_resource_group_name, subscription_id=self._config.subscription_id, api_version=api_version, content_type=content_type, json=_json, - template_url=self._move_resources_initial.metadata['url'], + content=_content, + template_url=self._move_resources_initial.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [202, 204]: @@ -3742,14 +3802,15 @@ def _move_resources_initial( # pylint: disable=inconsistent-return-statements if cls: return cls(pipeline_response, None, {}) - _move_resources_initial.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{sourceResourceGroupName}/moveResources"} # type: ignore - + _move_resources_initial.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{sourceResourceGroupName}/moveResources"} # type: ignore - @distributed_trace - def begin_move_resources( # pylint: disable=inconsistent-return-statements + @overload + def begin_move_resources( self, source_resource_group_name: str, - parameters: "_models.ResourcesMoveInfo", + parameters: _models.ResourcesMoveInfo, + *, + content_type: str = "application/json", **kwargs: Any ) -> LROPoller[None]: """Moves resources from one resource group to another resource group. @@ -3760,10 +3821,13 @@ def begin_move_resources( # pylint: disable=inconsistent-return-statements the groups until the move completes. :param source_resource_group_name: The name of the resource group containing the resources to - move. + move. Required. :type source_resource_group_name: str - :param parameters: Parameters for moving resources. + :param parameters: Parameters for moving resources. Required. :type parameters: ~azure.mgmt.resource.resources.v2019_03_01.models.ResourcesMoveInfo + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str :keyword callable cls: A custom type or function that will be passed the direct response :keyword str continuation_token: A continuation token to restart a poller from a saved state. :keyword polling: By default, your polling method will be ARMPolling. Pass in False for this @@ -3774,80 +3838,160 @@ def begin_move_resources( # pylint: disable=inconsistent-return-statements Retry-After header is present. :return: An instance of LROPoller that returns either None or the result of cls(response) :rtype: ~azure.core.polling.LROPoller[None] - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - api_version = kwargs.pop('api_version', "2019-03-01") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] - polling = kwargs.pop('polling', True) # type: Union[bool, PollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType[None] - lro_delay = kwargs.pop( - 'polling_interval', - self._config.polling_interval - ) - cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] + + @overload + def begin_move_resources( + self, source_resource_group_name: str, parameters: IO, *, content_type: str = "application/json", **kwargs: Any + ) -> LROPoller[None]: + """Moves resources from one resource group to another resource group. + + The resources to move must be in the same source resource group. The target resource group may + be in a different subscription. When moving resources, both the source group and the target + group are locked for the duration of the operation. Write and delete operations are blocked on + the groups until the move completes. + + :param source_resource_group_name: The name of the resource group containing the resources to + move. Required. + :type source_resource_group_name: str + :param parameters: Parameters for moving resources. Required. + :type parameters: IO + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be ARMPolling. Pass in False for this + operation to not poll, or pass in your own initialized polling object for a personal polling + strategy. + :paramtype polling: bool or ~azure.core.polling.PollingMethod + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of LROPoller that returns either None or the result of cls(response) + :rtype: ~azure.core.polling.LROPoller[None] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace + def begin_move_resources( + self, source_resource_group_name: str, parameters: Union[_models.ResourcesMoveInfo, IO], **kwargs: Any + ) -> LROPoller[None]: + """Moves resources from one resource group to another resource group. + + The resources to move must be in the same source resource group. The target resource group may + be in a different subscription. When moving resources, both the source group and the target + group are locked for the duration of the operation. Write and delete operations are blocked on + the groups until the move completes. + + :param source_resource_group_name: The name of the resource group containing the resources to + move. Required. + :type source_resource_group_name: str + :param parameters: Parameters for moving resources. Is either a model type or a IO type. + Required. + :type parameters: ~azure.mgmt.resource.resources.v2019_03_01.models.ResourcesMoveInfo or IO + :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. + Default value is None. + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be ARMPolling. Pass in False for this + operation to not poll, or pass in your own initialized polling object for a personal polling + strategy. + :paramtype polling: bool or ~azure.core.polling.PollingMethod + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of LROPoller that returns either None or the result of cls(response) + :rtype: ~azure.core.polling.LROPoller[None] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _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", "2019-03-01")) # type: str + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[None] + polling = kwargs.pop("polling", True) # type: Union[bool, PollingMethod] + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token = kwargs.pop("continuation_token", None) # type: Optional[str] if cont_token is None: - raw_result = self._move_resources_initial( + raw_result = self._move_resources_initial( # type: ignore source_resource_group_name=source_resource_group_name, parameters=parameters, api_version=api_version, content_type=content_type, - cls=lambda x,y,z: x, + cls=lambda x, y, z: x, + headers=_headers, + params=_params, **kwargs ) - kwargs.pop('error_map', None) + kwargs.pop("error_map", None) - def get_long_running_output(pipeline_response): + def get_long_running_output(pipeline_response): # pylint: disable=inconsistent-return-statements if cls: return cls(pipeline_response, None, {}) - - if polling is True: polling_method = ARMPolling(lro_delay, **kwargs) - elif polling is False: polling_method = NoPolling() - else: polling_method = polling + if polling is True: + polling_method = cast(PollingMethod, ARMPolling(lro_delay, **kwargs)) # type: PollingMethod + elif polling is False: + polling_method = cast(PollingMethod, NoPolling()) + else: + polling_method = polling if cont_token: return LROPoller.from_continuation_token( polling_method=polling_method, continuation_token=cont_token, client=self._client, - deserialization_callback=get_long_running_output + deserialization_callback=get_long_running_output, ) return LROPoller(self._client, raw_result, get_long_running_output, polling_method) - begin_move_resources.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{sourceResourceGroupName}/moveResources"} # type: ignore + begin_move_resources.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{sourceResourceGroupName}/moveResources"} # type: ignore def _validate_move_resources_initial( # pylint: disable=inconsistent-return-statements - self, - source_resource_group_name: str, - parameters: "_models.ResourcesMoveInfo", - **kwargs: Any + self, source_resource_group_name: str, parameters: Union[_models.ResourcesMoveInfo, IO], **kwargs: Any ) -> None: - cls = kwargs.pop('cls', None) # type: ClsType[None] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', "2019-03-01") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + api_version = kwargs.pop("api_version", _params.pop("api-version", "2019-03-01")) # type: str + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[None] - _json = self._serialize.body(parameters, 'ResourcesMoveInfo') + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(parameters, (IO, bytes)): + _content = parameters + else: + _json = self._serialize.body(parameters, "ResourcesMoveInfo") - request = build_resources_validate_move_resources_request_initial( + request = build_resources_validate_move_resources_request( source_resource_group_name=source_resource_group_name, subscription_id=self._config.subscription_id, api_version=api_version, content_type=content_type, json=_json, - template_url=self._validate_move_resources_initial.metadata['url'], + content=_content, + template_url=self._validate_move_resources_initial.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [202, 204, 409]: @@ -3857,14 +4001,15 @@ def _validate_move_resources_initial( # pylint: disable=inconsistent-return-sta if cls: return cls(pipeline_response, None, {}) - _validate_move_resources_initial.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{sourceResourceGroupName}/validateMoveResources"} # type: ignore - + _validate_move_resources_initial.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{sourceResourceGroupName}/validateMoveResources"} # type: ignore - @distributed_trace - def begin_validate_move_resources( # pylint: disable=inconsistent-return-statements + @overload + def begin_validate_move_resources( self, source_resource_group_name: str, - parameters: "_models.ResourcesMoveInfo", + parameters: _models.ResourcesMoveInfo, + *, + content_type: str = "application/json", **kwargs: Any ) -> LROPoller[None]: """Validates whether resources can be moved from one resource group to another resource group. @@ -3877,10 +4022,13 @@ def begin_validate_move_resources( # pylint: disable=inconsistent-return-statem operation. :param source_resource_group_name: The name of the resource group containing the resources to - validate for move. + validate for move. Required. :type source_resource_group_name: str - :param parameters: Parameters for moving resources. + :param parameters: Parameters for moving resources. Required. :type parameters: ~azure.mgmt.resource.resources.v2019_03_01.models.ResourcesMoveInfo + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str :keyword callable cls: A custom type or function that will be passed the direct response :keyword str continuation_token: A continuation token to restart a poller from a saved state. :keyword polling: By default, your polling method will be ARMPolling. Pass in False for this @@ -3891,55 +4039,124 @@ def begin_validate_move_resources( # pylint: disable=inconsistent-return-statem Retry-After header is present. :return: An instance of LROPoller that returns either None or the result of cls(response) :rtype: ~azure.core.polling.LROPoller[None] - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - api_version = kwargs.pop('api_version', "2019-03-01") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] - polling = kwargs.pop('polling', True) # type: Union[bool, PollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType[None] - lro_delay = kwargs.pop( - 'polling_interval', - self._config.polling_interval - ) - cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] - if cont_token is None: - raw_result = self._validate_move_resources_initial( - source_resource_group_name=source_resource_group_name, - parameters=parameters, - api_version=api_version, - content_type=content_type, - cls=lambda x,y,z: x, - **kwargs + + @overload + def begin_validate_move_resources( + self, source_resource_group_name: str, parameters: IO, *, content_type: str = "application/json", **kwargs: Any + ) -> LROPoller[None]: + """Validates whether resources can be moved from one resource group to another resource group. + + This operation checks whether the specified resources can be moved to the target. The resources + to move must be in the same source resource group. The target resource group may be in a + different subscription. If validation succeeds, it returns HTTP response code 204 (no content). + If validation fails, it returns HTTP response code 409 (Conflict) with an error message. + Retrieve the URL in the Location header value to check the result of the long-running + operation. + + :param source_resource_group_name: The name of the resource group containing the resources to + validate for move. Required. + :type source_resource_group_name: str + :param parameters: Parameters for moving resources. Required. + :type parameters: IO + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be ARMPolling. Pass in False for this + operation to not poll, or pass in your own initialized polling object for a personal polling + strategy. + :paramtype polling: bool or ~azure.core.polling.PollingMethod + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of LROPoller that returns either None or the result of cls(response) + :rtype: ~azure.core.polling.LROPoller[None] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace + def begin_validate_move_resources( + self, source_resource_group_name: str, parameters: Union[_models.ResourcesMoveInfo, IO], **kwargs: Any + ) -> LROPoller[None]: + """Validates whether resources can be moved from one resource group to another resource group. + + This operation checks whether the specified resources can be moved to the target. The resources + to move must be in the same source resource group. The target resource group may be in a + different subscription. If validation succeeds, it returns HTTP response code 204 (no content). + If validation fails, it returns HTTP response code 409 (Conflict) with an error message. + Retrieve the URL in the Location header value to check the result of the long-running + operation. + + :param source_resource_group_name: The name of the resource group containing the resources to + validate for move. Required. + :type source_resource_group_name: str + :param parameters: Parameters for moving resources. Is either a model type or a IO type. + Required. + :type parameters: ~azure.mgmt.resource.resources.v2019_03_01.models.ResourcesMoveInfo or IO + :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. + Default value is None. + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be ARMPolling. Pass in False for this + operation to not poll, or pass in your own initialized polling object for a personal polling + strategy. + :paramtype polling: bool or ~azure.core.polling.PollingMethod + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of LROPoller that returns either None or the result of cls(response) + :rtype: ~azure.core.polling.LROPoller[None] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _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", "2019-03-01")) # type: str + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[None] + polling = kwargs.pop("polling", True) # type: Union[bool, PollingMethod] + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token = kwargs.pop("continuation_token", None) # type: Optional[str] + if cont_token is None: + raw_result = self._validate_move_resources_initial( # type: ignore + source_resource_group_name=source_resource_group_name, + parameters=parameters, + api_version=api_version, + content_type=content_type, + cls=lambda x, y, z: x, + headers=_headers, + params=_params, + **kwargs ) - kwargs.pop('error_map', None) + kwargs.pop("error_map", None) - def get_long_running_output(pipeline_response): + def get_long_running_output(pipeline_response): # pylint: disable=inconsistent-return-statements if cls: return cls(pipeline_response, None, {}) - - if polling is True: polling_method = ARMPolling(lro_delay, **kwargs) - elif polling is False: polling_method = NoPolling() - else: polling_method = polling + if polling is True: + polling_method = cast(PollingMethod, ARMPolling(lro_delay, **kwargs)) # type: PollingMethod + elif polling is False: + polling_method = cast(PollingMethod, NoPolling()) + else: + polling_method = polling if cont_token: return LROPoller.from_continuation_token( polling_method=polling_method, continuation_token=cont_token, client=self._client, - deserialization_callback=get_long_running_output + deserialization_callback=get_long_running_output, ) return LROPoller(self._client, raw_result, get_long_running_output, polling_method) - begin_validate_move_resources.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{sourceResourceGroupName}/validateMoveResources"} # type: ignore + begin_validate_move_resources.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{sourceResourceGroupName}/validateMoveResources"} # type: ignore @distributed_trace def list( - self, - filter: Optional[str] = None, - expand: Optional[str] = None, - top: Optional[int] = None, - **kwargs: Any - ) -> Iterable["_models.ResourceListResult"]: + self, filter: Optional[str] = None, expand: Optional[str] = None, top: Optional[int] = None, **kwargs: Any + ) -> Iterable["_models.GenericResourceExpanded"]: """Get all the resources in a subscription. :param filter: The filter to apply on the operation.:code:`
`:code:`
`The properties you @@ -3965,40 +4182,50 @@ def list( value is None. :type top: int :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either ResourceListResult or the result of cls(response) + :return: An iterator like instance of either GenericResourceExpanded or the result of + cls(response) :rtype: - ~azure.core.paging.ItemPaged[~azure.mgmt.resource.resources.v2019_03_01.models.ResourceListResult] - :raises: ~azure.core.exceptions.HttpResponseError + ~azure.core.paging.ItemPaged[~azure.mgmt.resource.resources.v2019_03_01.models.GenericResourceExpanded] + :raises ~azure.core.exceptions.HttpResponseError: """ - api_version = kwargs.pop('api_version', "2019-03-01") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2019-03-01")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[_models.ResourceListResult] - cls = kwargs.pop('cls', None) # type: ClsType["_models.ResourceListResult"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) + def prepare_request(next_link=None): if not next_link: - + request = build_resources_list_request( subscription_id=self._config.subscription_id, - api_version=api_version, filter=filter, expand=expand, top=top, - template_url=self.list.metadata['url'], + 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.url = self._client.format_url(request.url) # type: ignore else: - - request = build_resources_list_request( - subscription_id=self._config.subscription_id, - template_url=next_link, - ) + # make call to next link with the client's api-version + _parsed_next_link = urlparse(next_link) + _next_request_params = case_insensitive_dict(parse_qs(_parsed_next_link.query)) + _next_request_params["api-version"] = self._config.api_version + request = HttpRequest("GET", urljoin(next_link, _parsed_next_link.path), params=_next_request_params) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore request.method = "GET" return request @@ -4012,10 +4239,8 @@ def extract_data(pipeline_response): def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) response = pipeline_response.http_response @@ -4025,11 +4250,9 @@ def get_next(next_link=None): return pipeline_response + return ItemPaged(get_next, extract_data) - return ItemPaged( - get_next, extract_data - ) - list.metadata = {'url': "/subscriptions/{subscriptionId}/resources"} # type: ignore + list.metadata = {"url": "/subscriptions/{subscriptionId}/resources"} # type: ignore @distributed_trace def check_existence( @@ -4045,30 +4268,36 @@ def check_existence( """Checks whether a resource exists. :param resource_group_name: The name of the resource group containing the resource to check. - The name is case insensitive. + The name is case insensitive. Required. :type resource_group_name: str - :param resource_provider_namespace: The resource provider of the resource to check. + :param resource_provider_namespace: The resource provider of the resource to check. Required. :type resource_provider_namespace: str - :param parent_resource_path: The parent resource identity. + :param parent_resource_path: The parent resource identity. Required. :type parent_resource_path: str - :param resource_type: The resource type. + :param resource_type: The resource type. Required. :type resource_type: str - :param resource_name: The name of the resource to check whether it exists. + :param resource_name: The name of the resource to check whether it exists. Required. :type resource_name: str - :param api_version: The API version to use for the operation. + :param api_version: The API version to use for the operation. Required. :type api_version: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: bool, or the result of cls(response) + :return: bool or the result of cls(response) :rtype: bool - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType[None] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = kwargs.pop("params", {}) or {} + + cls = kwargs.pop("cls", None) # type: ClsType[None] - request = build_resources_check_existence_request( resource_group_name=resource_group_name, resource_provider_namespace=resource_provider_namespace, @@ -4077,16 +4306,17 @@ def check_existence( resource_name=resource_name, subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.check_existence.metadata['url'], + template_url=self.check_existence.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [204, 404]: @@ -4097,8 +4327,7 @@ def check_existence( return cls(pipeline_response, None, {}) return 200 <= response.status_code <= 299 - check_existence.metadata = {'url': "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{parentResourcePath}/{resourceType}/{resourceName}"} # type: ignore - + check_existence.metadata = {"url": "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{parentResourcePath}/{resourceType}/{resourceName}"} # type: ignore def _delete_initial( # pylint: disable=inconsistent-return-statements self, @@ -4110,14 +4339,20 @@ def _delete_initial( # pylint: disable=inconsistent-return-statements api_version: str, **kwargs: Any ) -> None: - cls = kwargs.pop('cls', None) # type: ClsType[None] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = kwargs.pop("params", {}) or {} + + cls = kwargs.pop("cls", None) # type: ClsType[None] - - request = build_resources_delete_request_initial( + request = build_resources_delete_request( resource_group_name=resource_group_name, resource_provider_namespace=resource_provider_namespace, parent_resource_path=parent_resource_path, @@ -4125,16 +4360,17 @@ def _delete_initial( # pylint: disable=inconsistent-return-statements resource_name=resource_name, subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self._delete_initial.metadata['url'], + template_url=self._delete_initial.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200, 202, 204]: @@ -4144,11 +4380,10 @@ def _delete_initial( # pylint: disable=inconsistent-return-statements if cls: return cls(pipeline_response, None, {}) - _delete_initial.metadata = {'url': "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{parentResourcePath}/{resourceType}/{resourceName}"} # type: ignore - + _delete_initial.metadata = {"url": "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{parentResourcePath}/{resourceType}/{resourceName}"} # type: ignore @distributed_trace - def begin_delete( # pylint: disable=inconsistent-return-statements + def begin_delete( self, resource_group_name: str, resource_provider_namespace: str, @@ -4161,17 +4396,17 @@ def begin_delete( # pylint: disable=inconsistent-return-statements """Deletes a resource. :param resource_group_name: The name of the resource group that contains the resource to - delete. The name is case insensitive. + delete. The name is case insensitive. Required. :type resource_group_name: str - :param resource_provider_namespace: The namespace of the resource provider. + :param resource_provider_namespace: The namespace of the resource provider. Required. :type resource_provider_namespace: str - :param parent_resource_path: The parent resource identity. + :param parent_resource_path: The parent resource identity. Required. :type parent_resource_path: str - :param resource_type: The resource type. + :param resource_type: The resource type. Required. :type resource_type: str - :param resource_name: The name of the resource to delete. + :param resource_name: The name of the resource to delete. Required. :type resource_name: str - :param api_version: The API version to use for the operation. + :param api_version: The API version to use for the operation. Required. :type api_version: str :keyword callable cls: A custom type or function that will be passed the direct response :keyword str continuation_token: A continuation token to restart a poller from a saved state. @@ -4183,46 +4418,50 @@ def begin_delete( # pylint: disable=inconsistent-return-statements Retry-After header is present. :return: An instance of LROPoller that returns either None or the result of cls(response) :rtype: ~azure.core.polling.LROPoller[None] - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - polling = kwargs.pop('polling', True) # type: Union[bool, PollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType[None] - lro_delay = kwargs.pop( - 'polling_interval', - self._config.polling_interval - ) - cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] + _headers = kwargs.pop("headers", {}) or {} + _params = kwargs.pop("params", {}) or {} + + cls = kwargs.pop("cls", None) # type: ClsType[None] + polling = kwargs.pop("polling", True) # type: Union[bool, PollingMethod] + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token = kwargs.pop("continuation_token", None) # type: Optional[str] if cont_token is None: - raw_result = self._delete_initial( + raw_result = self._delete_initial( # type: ignore resource_group_name=resource_group_name, resource_provider_namespace=resource_provider_namespace, parent_resource_path=parent_resource_path, resource_type=resource_type, resource_name=resource_name, api_version=api_version, - cls=lambda x,y,z: x, + cls=lambda x, y, z: x, + headers=_headers, + params=_params, **kwargs ) - kwargs.pop('error_map', None) + kwargs.pop("error_map", None) - def get_long_running_output(pipeline_response): + def get_long_running_output(pipeline_response): # pylint: disable=inconsistent-return-statements if cls: return cls(pipeline_response, None, {}) - - if polling is True: polling_method = ARMPolling(lro_delay, **kwargs) - elif polling is False: polling_method = NoPolling() - else: polling_method = polling + if polling is True: + polling_method = cast(PollingMethod, ARMPolling(lro_delay, **kwargs)) # type: PollingMethod + elif polling is False: + polling_method = cast(PollingMethod, NoPolling()) + else: + polling_method = polling if cont_token: return LROPoller.from_continuation_token( polling_method=polling_method, continuation_token=cont_token, client=self._client, - deserialization_callback=get_long_running_output + deserialization_callback=get_long_running_output, ) return LROPoller(self._client, raw_result, get_long_running_output, polling_method) - begin_delete.metadata = {'url': "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{parentResourcePath}/{resourceType}/{resourceName}"} # type: ignore + begin_delete.metadata = {"url": "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{parentResourcePath}/{resourceType}/{resourceName}"} # type: ignore def _create_or_update_initial( self, @@ -4232,39 +4471,53 @@ def _create_or_update_initial( resource_type: str, resource_name: str, api_version: str, - parameters: "_models.GenericResource", + parameters: Union[_models.GenericResource, IO], **kwargs: Any - ) -> Optional["_models.GenericResource"]: - cls = kwargs.pop('cls', None) # type: ClsType[Optional["_models.GenericResource"]] + ) -> Optional[_models.GenericResource]: error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = kwargs.pop("params", {}) or {} - _json = self._serialize.body(parameters, 'GenericResource') + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[Optional[_models.GenericResource]] - request = build_resources_create_or_update_request_initial( + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(parameters, (IO, bytes)): + _content = parameters + else: + _json = self._serialize.body(parameters, "GenericResource") + + request = build_resources_create_or_update_request( resource_group_name=resource_group_name, resource_provider_namespace=resource_provider_namespace, parent_resource_path=parent_resource_path, resource_type=resource_type, resource_name=resource_name, subscription_id=self._config.subscription_id, - content_type=content_type, api_version=api_version, + content_type=content_type, json=_json, - template_url=self._create_or_update_initial.metadata['url'], + content=_content, + template_url=self._create_or_update_initial.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200, 201, 202]: @@ -4273,18 +4526,115 @@ def _create_or_update_initial( deserialized = None if response.status_code == 200: - deserialized = self._deserialize('GenericResource', pipeline_response) + deserialized = self._deserialize("GenericResource", pipeline_response) if response.status_code == 201: - deserialized = self._deserialize('GenericResource', pipeline_response) + deserialized = self._deserialize("GenericResource", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - _create_or_update_initial.metadata = {'url': "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{parentResourcePath}/{resourceType}/{resourceName}"} # type: ignore + _create_or_update_initial.metadata = {"url": "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{parentResourcePath}/{resourceType}/{resourceName}"} # type: ignore + + @overload + def begin_create_or_update( + self, + resource_group_name: str, + resource_provider_namespace: str, + parent_resource_path: str, + resource_type: str, + resource_name: str, + api_version: str, + parameters: _models.GenericResource, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> LROPoller[_models.GenericResource]: + """Creates a resource. + + :param resource_group_name: The name of the resource group for the resource. The name is case + insensitive. Required. + :type resource_group_name: str + :param resource_provider_namespace: The namespace of the resource provider. Required. + :type resource_provider_namespace: str + :param parent_resource_path: The parent resource identity. Required. + :type parent_resource_path: str + :param resource_type: The resource type of the resource to create. Required. + :type resource_type: str + :param resource_name: The name of the resource to create. Required. + :type resource_name: str + :param api_version: The API version to use for the operation. Required. + :type api_version: str + :param parameters: Parameters for creating or updating the resource. Required. + :type parameters: ~azure.mgmt.resource.resources.v2019_03_01.models.GenericResource + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be ARMPolling. Pass in False for this + operation to not poll, or pass in your own initialized polling object for a personal polling + strategy. + :paramtype polling: bool or ~azure.core.polling.PollingMethod + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of LROPoller that returns either GenericResource or the result of + cls(response) + :rtype: + ~azure.core.polling.LROPoller[~azure.mgmt.resource.resources.v2019_03_01.models.GenericResource] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + def begin_create_or_update( + self, + resource_group_name: str, + resource_provider_namespace: str, + parent_resource_path: str, + resource_type: str, + resource_name: str, + api_version: str, + parameters: IO, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> LROPoller[_models.GenericResource]: + """Creates a resource. + :param resource_group_name: The name of the resource group for the resource. The name is case + insensitive. Required. + :type resource_group_name: str + :param resource_provider_namespace: The namespace of the resource provider. Required. + :type resource_provider_namespace: str + :param parent_resource_path: The parent resource identity. Required. + :type parent_resource_path: str + :param resource_type: The resource type of the resource to create. Required. + :type resource_type: str + :param resource_name: The name of the resource to create. Required. + :type resource_name: str + :param api_version: The API version to use for the operation. Required. + :type api_version: str + :param parameters: Parameters for creating or updating the resource. Required. + :type parameters: IO + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be ARMPolling. Pass in False for this + operation to not poll, or pass in your own initialized polling object for a personal polling + strategy. + :paramtype polling: bool or ~azure.core.polling.PollingMethod + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of LROPoller that returns either GenericResource or the result of + cls(response) + :rtype: + ~azure.core.polling.LROPoller[~azure.mgmt.resource.resources.v2019_03_01.models.GenericResource] + :raises ~azure.core.exceptions.HttpResponseError: + """ @distributed_trace def begin_create_or_update( @@ -4295,26 +4645,30 @@ def begin_create_or_update( resource_type: str, resource_name: str, api_version: str, - parameters: "_models.GenericResource", + parameters: Union[_models.GenericResource, IO], **kwargs: Any - ) -> LROPoller["_models.GenericResource"]: + ) -> LROPoller[_models.GenericResource]: """Creates a resource. :param resource_group_name: The name of the resource group for the resource. The name is case - insensitive. + insensitive. Required. :type resource_group_name: str - :param resource_provider_namespace: The namespace of the resource provider. + :param resource_provider_namespace: The namespace of the resource provider. Required. :type resource_provider_namespace: str - :param parent_resource_path: The parent resource identity. + :param parent_resource_path: The parent resource identity. Required. :type parent_resource_path: str - :param resource_type: The resource type of the resource to create. + :param resource_type: The resource type of the resource to create. Required. :type resource_type: str - :param resource_name: The name of the resource to create. + :param resource_name: The name of the resource to create. Required. :type resource_name: str - :param api_version: The API version to use for the operation. + :param api_version: The API version to use for the operation. Required. :type api_version: str - :param parameters: Parameters for creating or updating the resource. - :type parameters: ~azure.mgmt.resource.resources.v2019_03_01.models.GenericResource + :param parameters: Parameters for creating or updating the resource. Is either a model type or + a IO type. Required. + :type parameters: ~azure.mgmt.resource.resources.v2019_03_01.models.GenericResource or IO + :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. + Default value is None. + :paramtype content_type: str :keyword callable cls: A custom type or function that will be passed the direct response :keyword str continuation_token: A continuation token to restart a poller from a saved state. :keyword polling: By default, your polling method will be ARMPolling. Pass in False for this @@ -4327,18 +4681,18 @@ def begin_create_or_update( cls(response) :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.resource.resources.v2019_03_01.models.GenericResource] - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] - polling = kwargs.pop('polling', True) # type: Union[bool, PollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType["_models.GenericResource"] - lro_delay = kwargs.pop( - 'polling_interval', - self._config.polling_interval - ) - cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = kwargs.pop("params", {}) or {} + + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.GenericResource] + polling = kwargs.pop("polling", True) # type: Union[bool, PollingMethod] + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token = kwargs.pop("continuation_token", None) # type: Optional[str] if cont_token is None: - raw_result = self._create_or_update_initial( + raw_result = self._create_or_update_initial( # type: ignore resource_group_name=resource_group_name, resource_provider_namespace=resource_provider_namespace, parent_resource_path=parent_resource_path, @@ -4347,32 +4701,35 @@ def begin_create_or_update( api_version=api_version, parameters=parameters, content_type=content_type, - cls=lambda x,y,z: x, + cls=lambda x, y, z: x, + headers=_headers, + params=_params, **kwargs ) - kwargs.pop('error_map', None) + kwargs.pop("error_map", None) def get_long_running_output(pipeline_response): - response = pipeline_response.http_response - deserialized = self._deserialize('GenericResource', pipeline_response) + deserialized = self._deserialize("GenericResource", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - - if polling is True: polling_method = ARMPolling(lro_delay, **kwargs) - elif polling is False: polling_method = NoPolling() - else: polling_method = polling + if polling is True: + polling_method = cast(PollingMethod, ARMPolling(lro_delay, **kwargs)) # type: PollingMethod + elif polling is False: + polling_method = cast(PollingMethod, NoPolling()) + else: + polling_method = polling if cont_token: return LROPoller.from_continuation_token( polling_method=polling_method, continuation_token=cont_token, client=self._client, - deserialization_callback=get_long_running_output + deserialization_callback=get_long_running_output, ) return LROPoller(self._client, raw_result, get_long_running_output, polling_method) - begin_create_or_update.metadata = {'url': "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{parentResourcePath}/{resourceType}/{resourceName}"} # type: ignore + begin_create_or_update.metadata = {"url": "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{parentResourcePath}/{resourceType}/{resourceName}"} # type: ignore def _update_initial( self, @@ -4382,39 +4739,53 @@ def _update_initial( resource_type: str, resource_name: str, api_version: str, - parameters: "_models.GenericResource", + parameters: Union[_models.GenericResource, IO], **kwargs: Any - ) -> Optional["_models.GenericResource"]: - cls = kwargs.pop('cls', None) # type: ClsType[Optional["_models.GenericResource"]] + ) -> Optional[_models.GenericResource]: error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = kwargs.pop("params", {}) or {} - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[Optional[_models.GenericResource]] - _json = self._serialize.body(parameters, 'GenericResource') + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(parameters, (IO, bytes)): + _content = parameters + else: + _json = self._serialize.body(parameters, "GenericResource") - request = build_resources_update_request_initial( + request = build_resources_update_request( resource_group_name=resource_group_name, resource_provider_namespace=resource_provider_namespace, parent_resource_path=parent_resource_path, resource_type=resource_type, resource_name=resource_name, subscription_id=self._config.subscription_id, - content_type=content_type, api_version=api_version, + content_type=content_type, json=_json, - template_url=self._update_initial.metadata['url'], + content=_content, + template_url=self._update_initial.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200, 202]: @@ -4423,15 +4794,112 @@ def _update_initial( deserialized = None if response.status_code == 200: - deserialized = self._deserialize('GenericResource', pipeline_response) + deserialized = self._deserialize("GenericResource", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - _update_initial.metadata = {'url': "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{parentResourcePath}/{resourceType}/{resourceName}"} # type: ignore + _update_initial.metadata = {"url": "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{parentResourcePath}/{resourceType}/{resourceName}"} # type: ignore + @overload + def begin_update( + self, + resource_group_name: str, + resource_provider_namespace: str, + parent_resource_path: str, + resource_type: str, + resource_name: str, + api_version: str, + parameters: _models.GenericResource, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> LROPoller[_models.GenericResource]: + """Updates a resource. + + :param resource_group_name: The name of the resource group for the resource. The name is case + insensitive. Required. + :type resource_group_name: str + :param resource_provider_namespace: The namespace of the resource provider. Required. + :type resource_provider_namespace: str + :param parent_resource_path: The parent resource identity. Required. + :type parent_resource_path: str + :param resource_type: The resource type of the resource to update. Required. + :type resource_type: str + :param resource_name: The name of the resource to update. Required. + :type resource_name: str + :param api_version: The API version to use for the operation. Required. + :type api_version: str + :param parameters: Parameters for updating the resource. Required. + :type parameters: ~azure.mgmt.resource.resources.v2019_03_01.models.GenericResource + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be ARMPolling. Pass in False for this + operation to not poll, or pass in your own initialized polling object for a personal polling + strategy. + :paramtype polling: bool or ~azure.core.polling.PollingMethod + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of LROPoller that returns either GenericResource or the result of + cls(response) + :rtype: + ~azure.core.polling.LROPoller[~azure.mgmt.resource.resources.v2019_03_01.models.GenericResource] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + def begin_update( + self, + resource_group_name: str, + resource_provider_namespace: str, + parent_resource_path: str, + resource_type: str, + resource_name: str, + api_version: str, + parameters: IO, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> LROPoller[_models.GenericResource]: + """Updates a resource. + + :param resource_group_name: The name of the resource group for the resource. The name is case + insensitive. Required. + :type resource_group_name: str + :param resource_provider_namespace: The namespace of the resource provider. Required. + :type resource_provider_namespace: str + :param parent_resource_path: The parent resource identity. Required. + :type parent_resource_path: str + :param resource_type: The resource type of the resource to update. Required. + :type resource_type: str + :param resource_name: The name of the resource to update. Required. + :type resource_name: str + :param api_version: The API version to use for the operation. Required. + :type api_version: str + :param parameters: Parameters for updating the resource. Required. + :type parameters: IO + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be ARMPolling. Pass in False for this + operation to not poll, or pass in your own initialized polling object for a personal polling + strategy. + :paramtype polling: bool or ~azure.core.polling.PollingMethod + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of LROPoller that returns either GenericResource or the result of + cls(response) + :rtype: + ~azure.core.polling.LROPoller[~azure.mgmt.resource.resources.v2019_03_01.models.GenericResource] + :raises ~azure.core.exceptions.HttpResponseError: + """ @distributed_trace def begin_update( @@ -4442,26 +4910,30 @@ def begin_update( resource_type: str, resource_name: str, api_version: str, - parameters: "_models.GenericResource", + parameters: Union[_models.GenericResource, IO], **kwargs: Any - ) -> LROPoller["_models.GenericResource"]: + ) -> LROPoller[_models.GenericResource]: """Updates a resource. :param resource_group_name: The name of the resource group for the resource. The name is case - insensitive. + insensitive. Required. :type resource_group_name: str - :param resource_provider_namespace: The namespace of the resource provider. + :param resource_provider_namespace: The namespace of the resource provider. Required. :type resource_provider_namespace: str - :param parent_resource_path: The parent resource identity. + :param parent_resource_path: The parent resource identity. Required. :type parent_resource_path: str - :param resource_type: The resource type of the resource to update. + :param resource_type: The resource type of the resource to update. Required. :type resource_type: str - :param resource_name: The name of the resource to update. + :param resource_name: The name of the resource to update. Required. :type resource_name: str - :param api_version: The API version to use for the operation. + :param api_version: The API version to use for the operation. Required. :type api_version: str - :param parameters: Parameters for updating the resource. - :type parameters: ~azure.mgmt.resource.resources.v2019_03_01.models.GenericResource + :param parameters: Parameters for updating the resource. Is either a model type or a IO type. + Required. + :type parameters: ~azure.mgmt.resource.resources.v2019_03_01.models.GenericResource or IO + :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. + Default value is None. + :paramtype content_type: str :keyword callable cls: A custom type or function that will be passed the direct response :keyword str continuation_token: A continuation token to restart a poller from a saved state. :keyword polling: By default, your polling method will be ARMPolling. Pass in False for this @@ -4474,18 +4946,18 @@ def begin_update( cls(response) :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.resource.resources.v2019_03_01.models.GenericResource] - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] - polling = kwargs.pop('polling', True) # type: Union[bool, PollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType["_models.GenericResource"] - lro_delay = kwargs.pop( - 'polling_interval', - self._config.polling_interval - ) - cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = kwargs.pop("params", {}) or {} + + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.GenericResource] + polling = kwargs.pop("polling", True) # type: Union[bool, PollingMethod] + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token = kwargs.pop("continuation_token", None) # type: Optional[str] if cont_token is None: - raw_result = self._update_initial( + raw_result = self._update_initial( # type: ignore resource_group_name=resource_group_name, resource_provider_namespace=resource_provider_namespace, parent_resource_path=parent_resource_path, @@ -4494,32 +4966,35 @@ def begin_update( api_version=api_version, parameters=parameters, content_type=content_type, - cls=lambda x,y,z: x, + cls=lambda x, y, z: x, + headers=_headers, + params=_params, **kwargs ) - kwargs.pop('error_map', None) + kwargs.pop("error_map", None) def get_long_running_output(pipeline_response): - response = pipeline_response.http_response - deserialized = self._deserialize('GenericResource', pipeline_response) + deserialized = self._deserialize("GenericResource", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - - if polling is True: polling_method = ARMPolling(lro_delay, **kwargs) - elif polling is False: polling_method = NoPolling() - else: polling_method = polling + if polling is True: + polling_method = cast(PollingMethod, ARMPolling(lro_delay, **kwargs)) # type: PollingMethod + elif polling is False: + polling_method = cast(PollingMethod, NoPolling()) + else: + polling_method = polling if cont_token: return LROPoller.from_continuation_token( polling_method=polling_method, continuation_token=cont_token, client=self._client, - deserialization_callback=get_long_running_output + deserialization_callback=get_long_running_output, ) return LROPoller(self._client, raw_result, get_long_running_output, polling_method) - begin_update.metadata = {'url': "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{parentResourcePath}/{resourceType}/{resourceName}"} # type: ignore + begin_update.metadata = {"url": "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{parentResourcePath}/{resourceType}/{resourceName}"} # type: ignore @distributed_trace def get( @@ -4531,34 +5006,40 @@ def get( resource_name: str, api_version: str, **kwargs: Any - ) -> "_models.GenericResource": + ) -> _models.GenericResource: """Gets a resource. :param resource_group_name: The name of the resource group containing the resource to get. The - name is case insensitive. + name is case insensitive. Required. :type resource_group_name: str - :param resource_provider_namespace: The namespace of the resource provider. + :param resource_provider_namespace: The namespace of the resource provider. Required. :type resource_provider_namespace: str - :param parent_resource_path: The parent resource identity. + :param parent_resource_path: The parent resource identity. Required. :type parent_resource_path: str - :param resource_type: The resource type of the resource. + :param resource_type: The resource type of the resource. Required. :type resource_type: str - :param resource_name: The name of the resource to get. + :param resource_name: The name of the resource to get. Required. :type resource_name: str - :param api_version: The API version to use for the operation. + :param api_version: The API version to use for the operation. Required. :type api_version: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: GenericResource, or the result of cls(response) + :return: GenericResource or the result of cls(response) :rtype: ~azure.mgmt.resource.resources.v2019_03_01.models.GenericResource - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.GenericResource"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = kwargs.pop("params", {}) or {} + + cls = kwargs.pop("cls", None) # type: ClsType[_models.GenericResource] - request = build_resources_get_request( resource_group_name=resource_group_name, resource_provider_namespace=resource_provider_namespace, @@ -4567,72 +5048,75 @@ def get( resource_name=resource_name, subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.get.metadata['url'], + template_url=self.get.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) - deserialized = self._deserialize('GenericResource', pipeline_response) + deserialized = self._deserialize("GenericResource", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - get.metadata = {'url': "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{parentResourcePath}/{resourceType}/{resourceName}"} # type: ignore - + get.metadata = {"url": "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{parentResourcePath}/{resourceType}/{resourceName}"} # type: ignore @distributed_trace - def check_existence_by_id( - self, - resource_id: str, - api_version: str, - **kwargs: Any - ) -> bool: + def check_existence_by_id(self, resource_id: str, api_version: str, **kwargs: Any) -> bool: """Checks by ID whether a resource exists. :param resource_id: The fully qualified ID of the resource, including the resource name and resource type. Use the format, /subscriptions/{guid}/resourceGroups/{resource-group-name}/{resource-provider-namespace}/{resource-type}/{resource-name}. + Required. :type resource_id: str - :param api_version: The API version to use for the operation. + :param api_version: The API version to use for the operation. Required. :type api_version: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: bool, or the result of cls(response) + :return: bool or the result of cls(response) :rtype: bool - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType[None] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = kwargs.pop("params", {}) or {} + + cls = kwargs.pop("cls", None) # type: ClsType[None] - request = build_resources_check_existence_by_id_request( resource_id=resource_id, api_version=api_version, - template_url=self.check_existence_by_id.metadata['url'], + template_url=self.check_existence_by_id.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [204, 404]: @@ -4643,35 +5127,38 @@ def check_existence_by_id( return cls(pipeline_response, None, {}) return 200 <= response.status_code <= 299 - check_existence_by_id.metadata = {'url': "/{resourceId}"} # type: ignore - + check_existence_by_id.metadata = {"url": "/{resourceId}"} # type: ignore def _delete_by_id_initial( # pylint: disable=inconsistent-return-statements - self, - resource_id: str, - api_version: str, - **kwargs: Any + self, resource_id: str, api_version: str, **kwargs: Any ) -> None: - cls = kwargs.pop('cls', None) # type: ClsType[None] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = kwargs.pop("params", {}) or {} + + cls = kwargs.pop("cls", None) # type: ClsType[None] - - request = build_resources_delete_by_id_request_initial( + request = build_resources_delete_by_id_request( resource_id=resource_id, api_version=api_version, - template_url=self._delete_by_id_initial.metadata['url'], + template_url=self._delete_by_id_initial.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200, 202, 204]: @@ -4681,23 +5168,18 @@ def _delete_by_id_initial( # pylint: disable=inconsistent-return-statements if cls: return cls(pipeline_response, None, {}) - _delete_by_id_initial.metadata = {'url': "/{resourceId}"} # type: ignore - + _delete_by_id_initial.metadata = {"url": "/{resourceId}"} # type: ignore @distributed_trace - def begin_delete_by_id( # pylint: disable=inconsistent-return-statements - self, - resource_id: str, - api_version: str, - **kwargs: Any - ) -> LROPoller[None]: + def begin_delete_by_id(self, resource_id: str, api_version: str, **kwargs: Any) -> LROPoller[None]: """Deletes a resource by ID. :param resource_id: The fully qualified ID of the resource, including the resource name and resource type. Use the format, /subscriptions/{guid}/resourceGroups/{resource-group-name}/{resource-provider-namespace}/{resource-type}/{resource-name}. + Required. :type resource_id: str - :param api_version: The API version to use for the operation. + :param api_version: The API version to use for the operation. Required. :type api_version: str :keyword callable cls: A custom type or function that will be passed the direct response :keyword str continuation_token: A continuation token to restart a poller from a saved state. @@ -4709,75 +5191,89 @@ def begin_delete_by_id( # pylint: disable=inconsistent-return-statements Retry-After header is present. :return: An instance of LROPoller that returns either None or the result of cls(response) :rtype: ~azure.core.polling.LROPoller[None] - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - polling = kwargs.pop('polling', True) # type: Union[bool, PollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType[None] - lro_delay = kwargs.pop( - 'polling_interval', - self._config.polling_interval - ) - cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] + _headers = kwargs.pop("headers", {}) or {} + _params = kwargs.pop("params", {}) or {} + + cls = kwargs.pop("cls", None) # type: ClsType[None] + polling = kwargs.pop("polling", True) # type: Union[bool, PollingMethod] + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token = kwargs.pop("continuation_token", None) # type: Optional[str] if cont_token is None: - raw_result = self._delete_by_id_initial( + raw_result = self._delete_by_id_initial( # type: ignore resource_id=resource_id, api_version=api_version, - cls=lambda x,y,z: x, + cls=lambda x, y, z: x, + headers=_headers, + params=_params, **kwargs ) - kwargs.pop('error_map', None) + kwargs.pop("error_map", None) - def get_long_running_output(pipeline_response): + def get_long_running_output(pipeline_response): # pylint: disable=inconsistent-return-statements if cls: return cls(pipeline_response, None, {}) - - if polling is True: polling_method = ARMPolling(lro_delay, **kwargs) - elif polling is False: polling_method = NoPolling() - else: polling_method = polling + if polling is True: + polling_method = cast(PollingMethod, ARMPolling(lro_delay, **kwargs)) # type: PollingMethod + elif polling is False: + polling_method = cast(PollingMethod, NoPolling()) + else: + polling_method = polling if cont_token: return LROPoller.from_continuation_token( polling_method=polling_method, continuation_token=cont_token, client=self._client, - deserialization_callback=get_long_running_output + deserialization_callback=get_long_running_output, ) return LROPoller(self._client, raw_result, get_long_running_output, polling_method) - begin_delete_by_id.metadata = {'url': "/{resourceId}"} # type: ignore + begin_delete_by_id.metadata = {"url": "/{resourceId}"} # type: ignore def _create_or_update_by_id_initial( - self, - resource_id: str, - api_version: str, - parameters: "_models.GenericResource", - **kwargs: Any - ) -> Optional["_models.GenericResource"]: - cls = kwargs.pop('cls', None) # type: ClsType[Optional["_models.GenericResource"]] + self, resource_id: str, api_version: str, parameters: Union[_models.GenericResource, IO], **kwargs: Any + ) -> Optional[_models.GenericResource]: error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = kwargs.pop("params", {}) or {} - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[Optional[_models.GenericResource]] - _json = self._serialize.body(parameters, 'GenericResource') + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(parameters, (IO, bytes)): + _content = parameters + else: + _json = self._serialize.body(parameters, "GenericResource") - request = build_resources_create_or_update_by_id_request_initial( + request = build_resources_create_or_update_by_id_request( resource_id=resource_id, - content_type=content_type, api_version=api_version, + content_type=content_type, json=_json, - template_url=self._create_or_update_by_id_initial.metadata['url'], + content=_content, + template_url=self._create_or_update_by_id_initial.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200, 201, 202]: @@ -4786,37 +5282,42 @@ def _create_or_update_by_id_initial( deserialized = None if response.status_code == 200: - deserialized = self._deserialize('GenericResource', pipeline_response) + deserialized = self._deserialize("GenericResource", pipeline_response) if response.status_code == 201: - deserialized = self._deserialize('GenericResource', pipeline_response) + deserialized = self._deserialize("GenericResource", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - _create_or_update_by_id_initial.metadata = {'url': "/{resourceId}"} # type: ignore + _create_or_update_by_id_initial.metadata = {"url": "/{resourceId}"} # type: ignore - - @distributed_trace + @overload def begin_create_or_update_by_id( self, resource_id: str, api_version: str, - parameters: "_models.GenericResource", + parameters: _models.GenericResource, + *, + content_type: str = "application/json", **kwargs: Any - ) -> LROPoller["_models.GenericResource"]: + ) -> LROPoller[_models.GenericResource]: """Create a resource by ID. :param resource_id: The fully qualified ID of the resource, including the resource name and resource type. Use the format, /subscriptions/{guid}/resourceGroups/{resource-group-name}/{resource-provider-namespace}/{resource-type}/{resource-name}. + Required. :type resource_id: str - :param api_version: The API version to use for the operation. + :param api_version: The API version to use for the operation. Required. :type api_version: str - :param parameters: Create or update resource parameters. + :param parameters: Create or update resource parameters. Required. :type parameters: ~azure.mgmt.resource.resources.v2019_03_01.models.GenericResource + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str :keyword callable cls: A custom type or function that will be passed the direct response :keyword str continuation_token: A continuation token to restart a poller from a saved state. :keyword polling: By default, your polling method will be ARMPolling. Pass in False for this @@ -4829,81 +5330,167 @@ def begin_create_or_update_by_id( cls(response) :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.resource.resources.v2019_03_01.models.GenericResource] - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] - polling = kwargs.pop('polling', True) # type: Union[bool, PollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType["_models.GenericResource"] - lro_delay = kwargs.pop( - 'polling_interval', - self._config.polling_interval - ) - cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] + + @overload + def begin_create_or_update_by_id( + self, + resource_id: str, + api_version: str, + parameters: IO, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> LROPoller[_models.GenericResource]: + """Create a resource by ID. + + :param resource_id: The fully qualified ID of the resource, including the resource name and + resource type. Use the format, + /subscriptions/{guid}/resourceGroups/{resource-group-name}/{resource-provider-namespace}/{resource-type}/{resource-name}. + Required. + :type resource_id: str + :param api_version: The API version to use for the operation. Required. + :type api_version: str + :param parameters: Create or update resource parameters. Required. + :type parameters: IO + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be ARMPolling. Pass in False for this + operation to not poll, or pass in your own initialized polling object for a personal polling + strategy. + :paramtype polling: bool or ~azure.core.polling.PollingMethod + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of LROPoller that returns either GenericResource or the result of + cls(response) + :rtype: + ~azure.core.polling.LROPoller[~azure.mgmt.resource.resources.v2019_03_01.models.GenericResource] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace + def begin_create_or_update_by_id( + self, resource_id: str, api_version: str, parameters: Union[_models.GenericResource, IO], **kwargs: Any + ) -> LROPoller[_models.GenericResource]: + """Create a resource by ID. + + :param resource_id: The fully qualified ID of the resource, including the resource name and + resource type. Use the format, + /subscriptions/{guid}/resourceGroups/{resource-group-name}/{resource-provider-namespace}/{resource-type}/{resource-name}. + Required. + :type resource_id: str + :param api_version: The API version to use for the operation. Required. + :type api_version: str + :param parameters: Create or update resource parameters. Is either a model type or a IO type. + Required. + :type parameters: ~azure.mgmt.resource.resources.v2019_03_01.models.GenericResource or IO + :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. + Default value is None. + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be ARMPolling. Pass in False for this + operation to not poll, or pass in your own initialized polling object for a personal polling + strategy. + :paramtype polling: bool or ~azure.core.polling.PollingMethod + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of LROPoller that returns either GenericResource or the result of + cls(response) + :rtype: + ~azure.core.polling.LROPoller[~azure.mgmt.resource.resources.v2019_03_01.models.GenericResource] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = kwargs.pop("params", {}) or {} + + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.GenericResource] + polling = kwargs.pop("polling", True) # type: Union[bool, PollingMethod] + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token = kwargs.pop("continuation_token", None) # type: Optional[str] if cont_token is None: - raw_result = self._create_or_update_by_id_initial( + raw_result = self._create_or_update_by_id_initial( # type: ignore resource_id=resource_id, api_version=api_version, parameters=parameters, content_type=content_type, - cls=lambda x,y,z: x, + cls=lambda x, y, z: x, + headers=_headers, + params=_params, **kwargs ) - kwargs.pop('error_map', None) + kwargs.pop("error_map", None) def get_long_running_output(pipeline_response): - response = pipeline_response.http_response - deserialized = self._deserialize('GenericResource', pipeline_response) + deserialized = self._deserialize("GenericResource", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - - if polling is True: polling_method = ARMPolling(lro_delay, **kwargs) - elif polling is False: polling_method = NoPolling() - else: polling_method = polling + if polling is True: + polling_method = cast(PollingMethod, ARMPolling(lro_delay, **kwargs)) # type: PollingMethod + elif polling is False: + polling_method = cast(PollingMethod, NoPolling()) + else: + polling_method = polling if cont_token: return LROPoller.from_continuation_token( polling_method=polling_method, continuation_token=cont_token, client=self._client, - deserialization_callback=get_long_running_output + deserialization_callback=get_long_running_output, ) return LROPoller(self._client, raw_result, get_long_running_output, polling_method) - begin_create_or_update_by_id.metadata = {'url': "/{resourceId}"} # type: ignore + begin_create_or_update_by_id.metadata = {"url": "/{resourceId}"} # type: ignore def _update_by_id_initial( - self, - resource_id: str, - api_version: str, - parameters: "_models.GenericResource", - **kwargs: Any - ) -> Optional["_models.GenericResource"]: - cls = kwargs.pop('cls', None) # type: ClsType[Optional["_models.GenericResource"]] + self, resource_id: str, api_version: str, parameters: Union[_models.GenericResource, IO], **kwargs: Any + ) -> Optional[_models.GenericResource]: error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = kwargs.pop("params", {}) or {} - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[Optional[_models.GenericResource]] - _json = self._serialize.body(parameters, 'GenericResource') + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(parameters, (IO, bytes)): + _content = parameters + else: + _json = self._serialize.body(parameters, "GenericResource") - request = build_resources_update_by_id_request_initial( + request = build_resources_update_by_id_request( resource_id=resource_id, - content_type=content_type, api_version=api_version, + content_type=content_type, json=_json, - template_url=self._update_by_id_initial.metadata['url'], + content=_content, + template_url=self._update_by_id_initial.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200, 202]: @@ -4912,34 +5499,78 @@ def _update_by_id_initial( deserialized = None if response.status_code == 200: - deserialized = self._deserialize('GenericResource', pipeline_response) + deserialized = self._deserialize("GenericResource", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - _update_by_id_initial.metadata = {'url': "/{resourceId}"} # type: ignore + _update_by_id_initial.metadata = {"url": "/{resourceId}"} # type: ignore + @overload + def begin_update_by_id( + self, + resource_id: str, + api_version: str, + parameters: _models.GenericResource, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> LROPoller[_models.GenericResource]: + """Updates a resource by ID. + + :param resource_id: The fully qualified ID of the resource, including the resource name and + resource type. Use the format, + /subscriptions/{guid}/resourceGroups/{resource-group-name}/{resource-provider-namespace}/{resource-type}/{resource-name}. + Required. + :type resource_id: str + :param api_version: The API version to use for the operation. Required. + :type api_version: str + :param parameters: Update resource parameters. Required. + :type parameters: ~azure.mgmt.resource.resources.v2019_03_01.models.GenericResource + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be ARMPolling. Pass in False for this + operation to not poll, or pass in your own initialized polling object for a personal polling + strategy. + :paramtype polling: bool or ~azure.core.polling.PollingMethod + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of LROPoller that returns either GenericResource or the result of + cls(response) + :rtype: + ~azure.core.polling.LROPoller[~azure.mgmt.resource.resources.v2019_03_01.models.GenericResource] + :raises ~azure.core.exceptions.HttpResponseError: + """ - @distributed_trace + @overload def begin_update_by_id( self, resource_id: str, api_version: str, - parameters: "_models.GenericResource", + parameters: IO, + *, + content_type: str = "application/json", **kwargs: Any - ) -> LROPoller["_models.GenericResource"]: + ) -> LROPoller[_models.GenericResource]: """Updates a resource by ID. :param resource_id: The fully qualified ID of the resource, including the resource name and resource type. Use the format, /subscriptions/{guid}/resourceGroups/{resource-group-name}/{resource-provider-namespace}/{resource-type}/{resource-name}. + Required. :type resource_id: str - :param api_version: The API version to use for the operation. + :param api_version: The API version to use for the operation. Required. :type api_version: str - :param parameters: Update resource parameters. - :type parameters: ~azure.mgmt.resource.resources.v2019_03_01.models.GenericResource + :param parameters: Update resource parameters. Required. + :type parameters: IO + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: str :keyword callable cls: A custom type or function that will be passed the direct response :keyword str continuation_token: A continuation token to restart a poller from a saved state. :keyword polling: By default, your polling method will be ARMPolling. Pass in False for this @@ -4952,165 +5583,204 @@ def begin_update_by_id( cls(response) :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.resource.resources.v2019_03_01.models.GenericResource] - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] - polling = kwargs.pop('polling', True) # type: Union[bool, PollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType["_models.GenericResource"] - lro_delay = kwargs.pop( - 'polling_interval', - self._config.polling_interval - ) - cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] + + @distributed_trace + def begin_update_by_id( + self, resource_id: str, api_version: str, parameters: Union[_models.GenericResource, IO], **kwargs: Any + ) -> LROPoller[_models.GenericResource]: + """Updates a resource by ID. + + :param resource_id: The fully qualified ID of the resource, including the resource name and + resource type. Use the format, + /subscriptions/{guid}/resourceGroups/{resource-group-name}/{resource-provider-namespace}/{resource-type}/{resource-name}. + Required. + :type resource_id: str + :param api_version: The API version to use for the operation. Required. + :type api_version: str + :param parameters: Update resource parameters. Is either a model type or a IO type. Required. + :type parameters: ~azure.mgmt.resource.resources.v2019_03_01.models.GenericResource or IO + :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. + Default value is None. + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be ARMPolling. Pass in False for this + operation to not poll, or pass in your own initialized polling object for a personal polling + strategy. + :paramtype polling: bool or ~azure.core.polling.PollingMethod + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of LROPoller that returns either GenericResource or the result of + cls(response) + :rtype: + ~azure.core.polling.LROPoller[~azure.mgmt.resource.resources.v2019_03_01.models.GenericResource] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = kwargs.pop("params", {}) or {} + + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.GenericResource] + polling = kwargs.pop("polling", True) # type: Union[bool, PollingMethod] + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token = kwargs.pop("continuation_token", None) # type: Optional[str] if cont_token is None: - raw_result = self._update_by_id_initial( + raw_result = self._update_by_id_initial( # type: ignore resource_id=resource_id, api_version=api_version, parameters=parameters, content_type=content_type, - cls=lambda x,y,z: x, + cls=lambda x, y, z: x, + headers=_headers, + params=_params, **kwargs ) - kwargs.pop('error_map', None) + kwargs.pop("error_map", None) def get_long_running_output(pipeline_response): - response = pipeline_response.http_response - deserialized = self._deserialize('GenericResource', pipeline_response) + deserialized = self._deserialize("GenericResource", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - - if polling is True: polling_method = ARMPolling(lro_delay, **kwargs) - elif polling is False: polling_method = NoPolling() - else: polling_method = polling + if polling is True: + polling_method = cast(PollingMethod, ARMPolling(lro_delay, **kwargs)) # type: PollingMethod + elif polling is False: + polling_method = cast(PollingMethod, NoPolling()) + else: + polling_method = polling if cont_token: return LROPoller.from_continuation_token( polling_method=polling_method, continuation_token=cont_token, client=self._client, - deserialization_callback=get_long_running_output + deserialization_callback=get_long_running_output, ) return LROPoller(self._client, raw_result, get_long_running_output, polling_method) - begin_update_by_id.metadata = {'url': "/{resourceId}"} # type: ignore + begin_update_by_id.metadata = {"url": "/{resourceId}"} # type: ignore @distributed_trace - def get_by_id( - self, - resource_id: str, - api_version: str, - **kwargs: Any - ) -> "_models.GenericResource": + def get_by_id(self, resource_id: str, api_version: str, **kwargs: Any) -> _models.GenericResource: """Gets a resource by ID. :param resource_id: The fully qualified ID of the resource, including the resource name and resource type. Use the format, /subscriptions/{guid}/resourceGroups/{resource-group-name}/{resource-provider-namespace}/{resource-type}/{resource-name}. + Required. :type resource_id: str - :param api_version: The API version to use for the operation. + :param api_version: The API version to use for the operation. Required. :type api_version: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: GenericResource, or the result of cls(response) + :return: GenericResource or the result of cls(response) :rtype: ~azure.mgmt.resource.resources.v2019_03_01.models.GenericResource - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.GenericResource"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = kwargs.pop("params", {}) or {} + + cls = kwargs.pop("cls", None) # type: ClsType[_models.GenericResource] - request = build_resources_get_by_id_request( resource_id=resource_id, api_version=api_version, - template_url=self.get_by_id.metadata['url'], + template_url=self.get_by_id.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) - deserialized = self._deserialize('GenericResource', pipeline_response) + deserialized = self._deserialize("GenericResource", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - get_by_id.metadata = {'url': "/{resourceId}"} # type: ignore + get_by_id.metadata = {"url": "/{resourceId}"} # type: ignore -class ResourceGroupsOperations(object): - """ResourceGroupsOperations operations. - You should not instantiate this class directly. Instead, you should create a Client instance that - instantiates it for you and attaches it as an attribute. +class ResourceGroupsOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. - :ivar models: Alias to model classes used in this operation group. - :type models: ~azure.mgmt.resource.resources.v2019_03_01.models - :param client: Client for service requests. - :param config: Configuration of service client. - :param serializer: An object model serializer. - :param deserializer: An object model deserializer. + Instead, you should access the following operations through + :class:`~azure.mgmt.resource.resources.v2019_03_01.ResourceManagementClient`'s + :attr:`resource_groups` attribute. """ models = _models - def __init__(self, client, config, serializer, deserializer): - self._client = client - self._serialize = serializer - self._deserialize = deserializer - self._config = config + def __init__(self, *args, **kwargs): + input_args = list(args) + self._client = input_args.pop(0) if input_args else kwargs.pop("client") + self._config = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") @distributed_trace - def check_existence( - self, - resource_group_name: str, - **kwargs: Any - ) -> bool: + def check_existence(self, resource_group_name: str, **kwargs: Any) -> bool: """Checks whether a resource group exists. :param resource_group_name: The name of the resource group to check. The name is case - insensitive. + insensitive. Required. :type resource_group_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: bool, or the result of cls(response) + :return: bool or the result of cls(response) :rtype: bool - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType[None] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) - api_version = kwargs.pop('api_version', "2019-03-01") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2019-03-01")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[None] - request = build_resource_groups_check_existence_request( resource_group_name=resource_group_name, subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.check_existence.metadata['url'], + template_url=self.check_existence.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [204, 404]: @@ -5121,39 +5791,98 @@ def check_existence( return cls(pipeline_response, None, {}) return 200 <= response.status_code <= 299 - check_existence.metadata = {'url': "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}"} # type: ignore + check_existence.metadata = {"url": "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}"} # type: ignore - - @distributed_trace + @overload def create_or_update( self, resource_group_name: str, - parameters: "_models.ResourceGroup", + parameters: _models.ResourceGroup, + *, + content_type: str = "application/json", **kwargs: Any - ) -> "_models.ResourceGroup": + ) -> _models.ResourceGroup: """Creates or updates a resource group. :param resource_group_name: The name of the resource group to create or update. Can include alphanumeric, underscore, parentheses, hyphen, period (except at end), and Unicode characters - that match the allowed characters. + that match the allowed characters. Required. :type resource_group_name: str - :param parameters: Parameters supplied to the create or update a resource group. + :param parameters: Parameters supplied to the create or update a resource group. Required. :type parameters: ~azure.mgmt.resource.resources.v2019_03_01.models.ResourceGroup + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: ResourceGroup or the result of cls(response) + :rtype: ~azure.mgmt.resource.resources.v2019_03_01.models.ResourceGroup + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + def create_or_update( + self, resource_group_name: str, parameters: IO, *, content_type: str = "application/json", **kwargs: Any + ) -> _models.ResourceGroup: + """Creates or updates a resource group. + + :param resource_group_name: The name of the resource group to create or update. Can include + alphanumeric, underscore, parentheses, hyphen, period (except at end), and Unicode characters + that match the allowed characters. Required. + :type resource_group_name: str + :param parameters: Parameters supplied to the create or update a resource group. Required. + :type parameters: IO + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: ResourceGroup, or the result of cls(response) + :return: ResourceGroup or the result of cls(response) :rtype: ~azure.mgmt.resource.resources.v2019_03_01.models.ResourceGroup - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace + def create_or_update( + self, resource_group_name: str, parameters: Union[_models.ResourceGroup, IO], **kwargs: Any + ) -> _models.ResourceGroup: + """Creates or updates a resource group. + + :param resource_group_name: The name of the resource group to create or update. Can include + alphanumeric, underscore, parentheses, hyphen, period (except at end), and Unicode characters + that match the allowed characters. Required. + :type resource_group_name: str + :param parameters: Parameters supplied to the create or update a resource group. Is either a + model type or a IO type. Required. + :type parameters: ~azure.mgmt.resource.resources.v2019_03_01.models.ResourceGroup or IO + :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. + Default value is None. + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: ResourceGroup or the result of cls(response) + :rtype: ~azure.mgmt.resource.resources.v2019_03_01.models.ResourceGroup + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.ResourceGroup"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) - api_version = kwargs.pop('api_version', "2019-03-01") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - _json = self._serialize.body(parameters, 'ResourceGroup') + api_version = kwargs.pop("api_version", _params.pop("api-version", "2019-03-01")) # type: str + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.ResourceGroup] + + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(parameters, (IO, bytes)): + _content = parameters + else: + _json = self._serialize.body(parameters, "ResourceGroup") request = build_resource_groups_create_or_update_request( resource_group_name=resource_group_name, @@ -5161,16 +5890,18 @@ def create_or_update( api_version=api_version, content_type=content_type, json=_json, - template_url=self.create_or_update.metadata['url'], + content=_content, + template_url=self.create_or_update.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200, 201]: @@ -5178,47 +5909,50 @@ def create_or_update( raise HttpResponseError(response=response, error_format=ARMErrorFormat) if response.status_code == 200: - deserialized = self._deserialize('ResourceGroup', pipeline_response) + deserialized = self._deserialize("ResourceGroup", pipeline_response) if response.status_code == 201: - deserialized = self._deserialize('ResourceGroup', pipeline_response) + deserialized = self._deserialize("ResourceGroup", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - create_or_update.metadata = {'url': "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}"} # type: ignore - + create_or_update.metadata = {"url": "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}"} # type: ignore def _delete_initial( # pylint: disable=inconsistent-return-statements - self, - resource_group_name: str, - **kwargs: Any + self, resource_group_name: str, **kwargs: Any ) -> None: - cls = kwargs.pop('cls', None) # type: ClsType[None] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) - api_version = kwargs.pop('api_version', "2019-03-01") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - request = build_resource_groups_delete_request_initial( + api_version = kwargs.pop("api_version", _params.pop("api-version", "2019-03-01")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[None] + + request = build_resource_groups_delete_request( resource_group_name=resource_group_name, subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self._delete_initial.metadata['url'], + template_url=self._delete_initial.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200, 202]: @@ -5228,22 +5962,17 @@ def _delete_initial( # pylint: disable=inconsistent-return-statements if cls: return cls(pipeline_response, None, {}) - _delete_initial.metadata = {'url': "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}"} # type: ignore - + _delete_initial.metadata = {"url": "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}"} # type: ignore @distributed_trace - def begin_delete( # pylint: disable=inconsistent-return-statements - self, - resource_group_name: str, - **kwargs: Any - ) -> LROPoller[None]: + def begin_delete(self, resource_group_name: str, **kwargs: Any) -> LROPoller[None]: """Deletes a resource group. When you delete a resource group, all of its resources are also deleted. Deleting a resource group deletes all of its template deployments and currently stored operations. :param resource_group_name: The name of the resource group to delete. The name is case - insensitive. + insensitive. Required. :type resource_group_name: str :keyword callable cls: A custom type or function that will be passed the direct response :keyword str continuation_token: A continuation token to restart a poller from a saved state. @@ -5255,106 +5984,113 @@ def begin_delete( # pylint: disable=inconsistent-return-statements Retry-After header is present. :return: An instance of LROPoller that returns either None or the result of cls(response) :rtype: ~azure.core.polling.LROPoller[None] - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - api_version = kwargs.pop('api_version', "2019-03-01") # type: str - polling = kwargs.pop('polling', True) # type: Union[bool, PollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType[None] - lro_delay = kwargs.pop( - 'polling_interval', - self._config.polling_interval - ) - cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2019-03-01")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[None] + polling = kwargs.pop("polling", True) # type: Union[bool, PollingMethod] + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token = kwargs.pop("continuation_token", None) # type: Optional[str] if cont_token is None: - raw_result = self._delete_initial( + raw_result = self._delete_initial( # type: ignore resource_group_name=resource_group_name, api_version=api_version, - cls=lambda x,y,z: x, + cls=lambda x, y, z: x, + headers=_headers, + params=_params, **kwargs ) - kwargs.pop('error_map', None) + kwargs.pop("error_map", None) - def get_long_running_output(pipeline_response): + def get_long_running_output(pipeline_response): # pylint: disable=inconsistent-return-statements if cls: return cls(pipeline_response, None, {}) - - if polling is True: polling_method = ARMPolling(lro_delay, **kwargs) - elif polling is False: polling_method = NoPolling() - else: polling_method = polling + if polling is True: + polling_method = cast(PollingMethod, ARMPolling(lro_delay, **kwargs)) # type: PollingMethod + elif polling is False: + polling_method = cast(PollingMethod, NoPolling()) + else: + polling_method = polling if cont_token: return LROPoller.from_continuation_token( polling_method=polling_method, continuation_token=cont_token, client=self._client, - deserialization_callback=get_long_running_output + deserialization_callback=get_long_running_output, ) return LROPoller(self._client, raw_result, get_long_running_output, polling_method) - begin_delete.metadata = {'url': "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}"} # type: ignore + begin_delete.metadata = {"url": "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}"} # type: ignore @distributed_trace - def get( - self, - resource_group_name: str, - **kwargs: Any - ) -> "_models.ResourceGroup": + def get(self, resource_group_name: str, **kwargs: Any) -> _models.ResourceGroup: """Gets a resource group. :param resource_group_name: The name of the resource group to get. The name is case - insensitive. + insensitive. Required. :type resource_group_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: ResourceGroup, or the result of cls(response) + :return: ResourceGroup or the result of cls(response) :rtype: ~azure.mgmt.resource.resources.v2019_03_01.models.ResourceGroup - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.ResourceGroup"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) - api_version = kwargs.pop('api_version', "2019-03-01") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2019-03-01")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[_models.ResourceGroup] - request = build_resource_groups_get_request( resource_group_name=resource_group_name, subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.get.metadata['url'], + template_url=self.get.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) - deserialized = self._deserialize('ResourceGroup', pipeline_response) + deserialized = self._deserialize("ResourceGroup", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - get.metadata = {'url': "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}"} # type: ignore + get.metadata = {"url": "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}"} # type: ignore - - @distributed_trace + @overload def update( self, resource_group_name: str, - parameters: "_models.ResourceGroupPatchable", + parameters: _models.ResourceGroupPatchable, + *, + content_type: str = "application/json", **kwargs: Any - ) -> "_models.ResourceGroup": + ) -> _models.ResourceGroup: """Updates a resource group. Resource groups can be updated through a simple PATCH operation to a group address. The format @@ -5362,25 +6098,90 @@ def update( the current value is retained. :param resource_group_name: The name of the resource group to update. The name is case - insensitive. + insensitive. Required. :type resource_group_name: str - :param parameters: Parameters supplied to update a resource group. + :param parameters: Parameters supplied to update a resource group. Required. :type parameters: ~azure.mgmt.resource.resources.v2019_03_01.models.ResourceGroupPatchable + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: ResourceGroup or the result of cls(response) + :rtype: ~azure.mgmt.resource.resources.v2019_03_01.models.ResourceGroup + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + def update( + self, resource_group_name: str, parameters: IO, *, content_type: str = "application/json", **kwargs: Any + ) -> _models.ResourceGroup: + """Updates a resource group. + + Resource groups can be updated through a simple PATCH operation to a group address. The format + of the request is the same as that for creating a resource group. If a field is unspecified, + the current value is retained. + + :param resource_group_name: The name of the resource group to update. The name is case + insensitive. Required. + :type resource_group_name: str + :param parameters: Parameters supplied to update a resource group. Required. + :type parameters: IO + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: ResourceGroup or the result of cls(response) + :rtype: ~azure.mgmt.resource.resources.v2019_03_01.models.ResourceGroup + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace + def update( + self, resource_group_name: str, parameters: Union[_models.ResourceGroupPatchable, IO], **kwargs: Any + ) -> _models.ResourceGroup: + """Updates a resource group. + + Resource groups can be updated through a simple PATCH operation to a group address. The format + of the request is the same as that for creating a resource group. If a field is unspecified, + the current value is retained. + + :param resource_group_name: The name of the resource group to update. The name is case + insensitive. Required. + :type resource_group_name: str + :param parameters: Parameters supplied to update a resource group. Is either a model type or a + IO type. Required. + :type parameters: ~azure.mgmt.resource.resources.v2019_03_01.models.ResourceGroupPatchable or + IO + :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. + Default value is None. + :paramtype content_type: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: ResourceGroup, or the result of cls(response) + :return: ResourceGroup or the result of cls(response) :rtype: ~azure.mgmt.resource.resources.v2019_03_01.models.ResourceGroup - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.ResourceGroup"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) - api_version = kwargs.pop('api_version', "2019-03-01") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - _json = self._serialize.body(parameters, 'ResourceGroupPatchable') + api_version = kwargs.pop("api_version", _params.pop("api-version", "2019-03-01")) # type: str + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.ResourceGroup] + + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(parameters, (IO, bytes)): + _content = parameters + else: + _json = self._serialize.body(parameters, "ResourceGroupPatchable") request = build_resource_groups_update_request( resource_group_name=resource_group_name, @@ -5388,60 +6189,117 @@ def update( api_version=api_version, content_type=content_type, json=_json, - template_url=self.update.metadata['url'], + content=_content, + template_url=self.update.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) - deserialized = self._deserialize('ResourceGroup', pipeline_response) + deserialized = self._deserialize("ResourceGroup", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - update.metadata = {'url': "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}"} # type: ignore + update.metadata = {"url": "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}"} # type: ignore - - @distributed_trace + @overload def export_template( self, resource_group_name: str, - parameters: "_models.ExportTemplateRequest", + parameters: _models.ExportTemplateRequest, + *, + content_type: str = "application/json", **kwargs: Any - ) -> "_models.ResourceGroupExportResult": + ) -> _models.ResourceGroupExportResult: """Captures the specified resource group as a template. - :param resource_group_name: The name of the resource group to export as a template. + :param resource_group_name: The name of the resource group to export as a template. Required. :type resource_group_name: str - :param parameters: Parameters for exporting the template. + :param parameters: Parameters for exporting the template. Required. :type parameters: ~azure.mgmt.resource.resources.v2019_03_01.models.ExportTemplateRequest + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: ResourceGroupExportResult or the result of cls(response) + :rtype: ~azure.mgmt.resource.resources.v2019_03_01.models.ResourceGroupExportResult + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + def export_template( + self, resource_group_name: str, parameters: IO, *, content_type: str = "application/json", **kwargs: Any + ) -> _models.ResourceGroupExportResult: + """Captures the specified resource group as a template. + + :param resource_group_name: The name of the resource group to export as a template. Required. + :type resource_group_name: str + :param parameters: Parameters for exporting the template. Required. + :type parameters: IO + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: ResourceGroupExportResult or the result of cls(response) + :rtype: ~azure.mgmt.resource.resources.v2019_03_01.models.ResourceGroupExportResult + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace + def export_template( + self, resource_group_name: str, parameters: Union[_models.ExportTemplateRequest, IO], **kwargs: Any + ) -> _models.ResourceGroupExportResult: + """Captures the specified resource group as a template. + + :param resource_group_name: The name of the resource group to export as a template. Required. + :type resource_group_name: str + :param parameters: Parameters for exporting the template. Is either a model type or a IO type. + Required. + :type parameters: ~azure.mgmt.resource.resources.v2019_03_01.models.ExportTemplateRequest or IO + :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. + Default value is None. + :paramtype content_type: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: ResourceGroupExportResult, or the result of cls(response) + :return: ResourceGroupExportResult or the result of cls(response) :rtype: ~azure.mgmt.resource.resources.v2019_03_01.models.ResourceGroupExportResult - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.ResourceGroupExportResult"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) - api_version = kwargs.pop('api_version', "2019-03-01") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - _json = self._serialize.body(parameters, 'ExportTemplateRequest') + api_version = kwargs.pop("api_version", _params.pop("api-version", "2019-03-01")) # type: str + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.ResourceGroupExportResult] + + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(parameters, (IO, bytes)): + _content = parameters + else: + _json = self._serialize.body(parameters, "ExportTemplateRequest") request = build_resource_groups_export_template_request( resource_group_name=resource_group_name, @@ -5449,39 +6307,37 @@ def export_template( api_version=api_version, content_type=content_type, json=_json, - template_url=self.export_template.metadata['url'], + content=_content, + template_url=self.export_template.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) - deserialized = self._deserialize('ResourceGroupExportResult', pipeline_response) + deserialized = self._deserialize("ResourceGroupExportResult", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - export_template.metadata = {'url': "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/exportTemplate"} # type: ignore - + export_template.metadata = {"url": "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/exportTemplate"} # type: ignore @distributed_trace def list( - self, - filter: Optional[str] = None, - top: Optional[int] = None, - **kwargs: Any - ) -> Iterable["_models.ResourceGroupListResult"]: + self, filter: Optional[str] = None, top: Optional[int] = None, **kwargs: Any + ) -> Iterable["_models.ResourceGroup"]: """Gets all the resource groups for a subscription. :param filter: The filter to apply on the operation.:code:`
`:code:`
`You can filter by @@ -5492,40 +6348,48 @@ def list( Default value is None. :type top: int :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either ResourceGroupListResult or the result of - cls(response) + :return: An iterator like instance of either ResourceGroup or the result of cls(response) :rtype: - ~azure.core.paging.ItemPaged[~azure.mgmt.resource.resources.v2019_03_01.models.ResourceGroupListResult] - :raises: ~azure.core.exceptions.HttpResponseError + ~azure.core.paging.ItemPaged[~azure.mgmt.resource.resources.v2019_03_01.models.ResourceGroup] + :raises ~azure.core.exceptions.HttpResponseError: """ - api_version = kwargs.pop('api_version', "2019-03-01") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2019-03-01")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[_models.ResourceGroupListResult] - cls = kwargs.pop('cls', None) # type: ClsType["_models.ResourceGroupListResult"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) + def prepare_request(next_link=None): if not next_link: - + request = build_resource_groups_list_request( subscription_id=self._config.subscription_id, - api_version=api_version, filter=filter, top=top, - template_url=self.list.metadata['url'], + 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.url = self._client.format_url(request.url) # type: ignore else: - - request = build_resource_groups_list_request( - subscription_id=self._config.subscription_id, - template_url=next_link, - ) + # make call to next link with the client's api-version + _parsed_next_link = urlparse(next_link) + _next_request_params = case_insensitive_dict(parse_qs(_parsed_next_link.query)) + _next_request_params["api-version"] = self._config.api_version + request = HttpRequest("GET", urljoin(next_link, _parsed_next_link.path), params=_next_request_params) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore request.method = "GET" return request @@ -5539,10 +6403,8 @@ def extract_data(pipeline_response): def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) response = pipeline_response.http_response @@ -5552,75 +6414,75 @@ def get_next(next_link=None): return pipeline_response + return ItemPaged(get_next, extract_data) - return ItemPaged( - get_next, extract_data - ) - list.metadata = {'url': "/subscriptions/{subscriptionId}/resourcegroups"} # type: ignore -class TagsOperations(object): - """TagsOperations operations. - - You should not instantiate this class directly. Instead, you should create a Client instance that - instantiates it for you and attaches it as an attribute. - - :ivar models: Alias to model classes used in this operation group. - :type models: ~azure.mgmt.resource.resources.v2019_03_01.models - :param client: Client for service requests. - :param config: Configuration of service client. - :param serializer: An object model serializer. - :param deserializer: An object model deserializer. + list.metadata = {"url": "/subscriptions/{subscriptionId}/resourcegroups"} # type: ignore + + +class TagsOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. + + Instead, you should access the following operations through + :class:`~azure.mgmt.resource.resources.v2019_03_01.ResourceManagementClient`'s + :attr:`tags` attribute. """ models = _models - def __init__(self, client, config, serializer, deserializer): - self._client = client - self._serialize = serializer - self._deserialize = deserializer - self._config = config + def __init__(self, *args, **kwargs): + input_args = list(args) + self._client = input_args.pop(0) if input_args else kwargs.pop("client") + self._config = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") @distributed_trace def delete_value( # pylint: disable=inconsistent-return-statements - self, - tag_name: str, - tag_value: str, - **kwargs: Any + self, tag_name: str, tag_value: str, **kwargs: Any ) -> None: """Deletes a tag value. - :param tag_name: The name of the tag. + :param tag_name: The name of the tag. Required. :type tag_name: str - :param tag_value: The value of the tag to delete. + :param tag_value: The value of the tag to delete. Required. :type tag_value: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: None, or the result of cls(response) + :return: None or the result of cls(response) :rtype: None - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType[None] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) - api_version = kwargs.pop('api_version', "2019-03-01") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2019-03-01")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[None] - request = build_tags_delete_value_request( tag_name=tag_name, tag_value=tag_value, subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.delete_value.metadata['url'], + template_url=self.delete_value.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200, 204]: @@ -5630,51 +6492,51 @@ def delete_value( # pylint: disable=inconsistent-return-statements if cls: return cls(pipeline_response, None, {}) - delete_value.metadata = {'url': "/subscriptions/{subscriptionId}/tagNames/{tagName}/tagValues/{tagValue}"} # type: ignore - + delete_value.metadata = {"url": "/subscriptions/{subscriptionId}/tagNames/{tagName}/tagValues/{tagValue}"} # type: ignore @distributed_trace - def create_or_update_value( - self, - tag_name: str, - tag_value: str, - **kwargs: Any - ) -> "_models.TagValue": + def create_or_update_value(self, tag_name: str, tag_value: str, **kwargs: Any) -> _models.TagValue: """Creates a tag value. The name of the tag must already exist. - :param tag_name: The name of the tag. + :param tag_name: The name of the tag. Required. :type tag_name: str - :param tag_value: The value of the tag to create. + :param tag_value: The value of the tag to create. Required. :type tag_value: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: TagValue, or the result of cls(response) + :return: TagValue or the result of cls(response) :rtype: ~azure.mgmt.resource.resources.v2019_03_01.models.TagValue - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.TagValue"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + 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', "2019-03-01") # type: str + api_version = kwargs.pop("api_version", _params.pop("api-version", "2019-03-01")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[_models.TagValue] - request = build_tags_create_or_update_value_request( tag_name=tag_name, tag_value=tag_value, subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.create_or_update_value.metadata['url'], + template_url=self.create_or_update_value.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200, 201]: @@ -5682,61 +6544,62 @@ def create_or_update_value( raise HttpResponseError(response=response, error_format=ARMErrorFormat) if response.status_code == 200: - deserialized = self._deserialize('TagValue', pipeline_response) + deserialized = self._deserialize("TagValue", pipeline_response) if response.status_code == 201: - deserialized = self._deserialize('TagValue', pipeline_response) + deserialized = self._deserialize("TagValue", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - create_or_update_value.metadata = {'url': "/subscriptions/{subscriptionId}/tagNames/{tagName}/tagValues/{tagValue}"} # type: ignore - + create_or_update_value.metadata = {"url": "/subscriptions/{subscriptionId}/tagNames/{tagName}/tagValues/{tagValue}"} # type: ignore @distributed_trace - def create_or_update( - self, - tag_name: str, - **kwargs: Any - ) -> "_models.TagDetails": + def create_or_update(self, tag_name: str, **kwargs: Any) -> _models.TagDetails: """Creates a tag in the subscription. The tag name can have a maximum of 512 characters and is case insensitive. Tag names created by Azure have prefixes of microsoft, azure, or windows. You cannot create tags with one of these prefixes. - :param tag_name: The name of the tag to create. + :param tag_name: The name of the tag to create. Required. :type tag_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: TagDetails, or the result of cls(response) + :return: TagDetails or the result of cls(response) :rtype: ~azure.mgmt.resource.resources.v2019_03_01.models.TagDetails - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.TagDetails"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + 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', "2019-03-01") # type: str + api_version = kwargs.pop("api_version", _params.pop("api-version", "2019-03-01")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[_models.TagDetails] - request = build_tags_create_or_update_request( tag_name=tag_name, subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.create_or_update.metadata['url'], + template_url=self.create_or_update.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200, 201]: @@ -5744,59 +6607,60 @@ def create_or_update( raise HttpResponseError(response=response, error_format=ARMErrorFormat) if response.status_code == 200: - deserialized = self._deserialize('TagDetails', pipeline_response) + deserialized = self._deserialize("TagDetails", pipeline_response) if response.status_code == 201: - deserialized = self._deserialize('TagDetails', pipeline_response) + deserialized = self._deserialize("TagDetails", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - create_or_update.metadata = {'url': "/subscriptions/{subscriptionId}/tagNames/{tagName}"} # type: ignore - + create_or_update.metadata = {"url": "/subscriptions/{subscriptionId}/tagNames/{tagName}"} # type: ignore @distributed_trace - def delete( # pylint: disable=inconsistent-return-statements - self, - tag_name: str, - **kwargs: Any - ) -> None: + def delete(self, tag_name: str, **kwargs: Any) -> None: # pylint: disable=inconsistent-return-statements """Deletes a tag from the subscription. You must remove all values from a resource tag before you can delete it. - :param tag_name: The name of the tag. + :param tag_name: The name of the tag. Required. :type tag_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: None, or the result of cls(response) + :return: None or the result of cls(response) :rtype: None - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType[None] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + 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', "2019-03-01") # type: str + api_version = kwargs.pop("api_version", _params.pop("api-version", "2019-03-01")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[None] - request = build_tags_delete_request( tag_name=tag_name, subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.delete.metadata['url'], + template_url=self.delete.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200, 204]: @@ -5806,48 +6670,53 @@ def delete( # pylint: disable=inconsistent-return-statements if cls: return cls(pipeline_response, None, {}) - delete.metadata = {'url': "/subscriptions/{subscriptionId}/tagNames/{tagName}"} # type: ignore - + delete.metadata = {"url": "/subscriptions/{subscriptionId}/tagNames/{tagName}"} # type: ignore @distributed_trace - def list( - self, - **kwargs: Any - ) -> Iterable["_models.TagsListResult"]: + def list(self, **kwargs: Any) -> Iterable["_models.TagDetails"]: """Gets the names and values of all resource tags that are defined in a subscription. :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either TagsListResult or the result of cls(response) + :return: An iterator like instance of either TagDetails or the result of cls(response) :rtype: - ~azure.core.paging.ItemPaged[~azure.mgmt.resource.resources.v2019_03_01.models.TagsListResult] - :raises: ~azure.core.exceptions.HttpResponseError + ~azure.core.paging.ItemPaged[~azure.mgmt.resource.resources.v2019_03_01.models.TagDetails] + :raises ~azure.core.exceptions.HttpResponseError: """ - api_version = kwargs.pop('api_version', "2019-03-01") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2019-03-01")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[_models.TagsListResult] - cls = kwargs.pop('cls', None) # type: ClsType["_models.TagsListResult"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) + def prepare_request(next_link=None): if not next_link: - + request = build_tags_list_request( subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.list.metadata['url'], + template_url=self.list.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore else: - - request = build_tags_list_request( - subscription_id=self._config.subscription_id, - template_url=next_link, - ) + # make call to next link with the client's api-version + _parsed_next_link = urlparse(next_link) + _next_request_params = case_insensitive_dict(parse_qs(_parsed_next_link.query)) + _next_request_params["api-version"] = self._config.api_version + request = HttpRequest("GET", urljoin(next_link, _parsed_next_link.path), params=_next_request_params) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore request.method = "GET" return request @@ -5861,10 +6730,8 @@ def extract_data(pipeline_response): def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) response = pipeline_response.http_response @@ -5874,140 +6741,143 @@ def get_next(next_link=None): return pipeline_response + return ItemPaged(get_next, extract_data) - return ItemPaged( - get_next, extract_data - ) - list.metadata = {'url': "/subscriptions/{subscriptionId}/tagNames"} # type: ignore -class DeploymentOperationsOperations(object): - """DeploymentOperationsOperations operations. - - You should not instantiate this class directly. Instead, you should create a Client instance that - instantiates it for you and attaches it as an attribute. - - :ivar models: Alias to model classes used in this operation group. - :type models: ~azure.mgmt.resource.resources.v2019_03_01.models - :param client: Client for service requests. - :param config: Configuration of service client. - :param serializer: An object model serializer. - :param deserializer: An object model deserializer. + list.metadata = {"url": "/subscriptions/{subscriptionId}/tagNames"} # type: ignore + + +class DeploymentOperationsOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. + + Instead, you should access the following operations through + :class:`~azure.mgmt.resource.resources.v2019_03_01.ResourceManagementClient`'s + :attr:`deployment_operations` attribute. """ models = _models - def __init__(self, client, config, serializer, deserializer): - self._client = client - self._serialize = serializer - self._deserialize = deserializer - self._config = config + def __init__(self, *args, **kwargs): + input_args = list(args) + self._client = input_args.pop(0) if input_args else kwargs.pop("client") + self._config = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") @distributed_trace def get_at_subscription_scope( - self, - deployment_name: str, - operation_id: str, - **kwargs: Any - ) -> "_models.DeploymentOperation": + self, deployment_name: str, operation_id: str, **kwargs: Any + ) -> _models.DeploymentOperation: """Gets a deployments operation. - :param deployment_name: The name of the deployment. + :param deployment_name: The name of the deployment. Required. :type deployment_name: str - :param operation_id: The ID of the operation to get. + :param operation_id: The ID of the operation to get. Required. :type operation_id: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: DeploymentOperation, or the result of cls(response) + :return: DeploymentOperation or the result of cls(response) :rtype: ~azure.mgmt.resource.resources.v2019_03_01.models.DeploymentOperation - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.DeploymentOperation"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) - api_version = kwargs.pop('api_version', "2019-03-01") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2019-03-01")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[_models.DeploymentOperation] - request = build_deployment_operations_get_at_subscription_scope_request( deployment_name=deployment_name, operation_id=operation_id, subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.get_at_subscription_scope.metadata['url'], + template_url=self.get_at_subscription_scope.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) - deserialized = self._deserialize('DeploymentOperation', pipeline_response) + deserialized = self._deserialize("DeploymentOperation", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - get_at_subscription_scope.metadata = {'url': "/subscriptions/{subscriptionId}/providers/Microsoft.Resources/deployments/{deploymentName}/operations/{operationId}"} # type: ignore - + get_at_subscription_scope.metadata = {"url": "/subscriptions/{subscriptionId}/providers/Microsoft.Resources/deployments/{deploymentName}/operations/{operationId}"} # type: ignore @distributed_trace def list_at_subscription_scope( - self, - deployment_name: str, - top: Optional[int] = None, - **kwargs: Any - ) -> Iterable["_models.DeploymentOperationsListResult"]: + self, deployment_name: str, top: Optional[int] = None, **kwargs: Any + ) -> Iterable["_models.DeploymentOperation"]: """Gets all deployments operations for a deployment. - :param deployment_name: The name of the deployment with the operation to get. + :param deployment_name: The name of the deployment with the operation to get. Required. :type deployment_name: str :param top: The number of results to return. Default value is None. :type top: int :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either DeploymentOperationsListResult or the result of - cls(response) + :return: An iterator like instance of either DeploymentOperation or the result of cls(response) :rtype: - ~azure.core.paging.ItemPaged[~azure.mgmt.resource.resources.v2019_03_01.models.DeploymentOperationsListResult] - :raises: ~azure.core.exceptions.HttpResponseError + ~azure.core.paging.ItemPaged[~azure.mgmt.resource.resources.v2019_03_01.models.DeploymentOperation] + :raises ~azure.core.exceptions.HttpResponseError: """ - api_version = kwargs.pop('api_version', "2019-03-01") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2019-03-01")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[_models.DeploymentOperationsListResult] - cls = kwargs.pop('cls', None) # type: ClsType["_models.DeploymentOperationsListResult"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) + def prepare_request(next_link=None): if not next_link: - + request = build_deployment_operations_list_at_subscription_scope_request( deployment_name=deployment_name, subscription_id=self._config.subscription_id, - api_version=api_version, top=top, - template_url=self.list_at_subscription_scope.metadata['url'], + api_version=api_version, + template_url=self.list_at_subscription_scope.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore else: - - request = build_deployment_operations_list_at_subscription_scope_request( - deployment_name=deployment_name, - subscription_id=self._config.subscription_id, - template_url=next_link, - ) + # make call to next link with the client's api-version + _parsed_next_link = urlparse(next_link) + _next_request_params = case_insensitive_dict(parse_qs(_parsed_next_link.query)) + _next_request_params["api-version"] = self._config.api_version + request = HttpRequest("GET", urljoin(next_link, _parsed_next_link.path), params=_next_request_params) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore request.method = "GET" return request @@ -6021,10 +6891,8 @@ def extract_data(pipeline_response): def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) response = pipeline_response.http_response @@ -6034,128 +6902,131 @@ def get_next(next_link=None): return pipeline_response + return ItemPaged(get_next, extract_data) - return ItemPaged( - get_next, extract_data - ) - list_at_subscription_scope.metadata = {'url': "/subscriptions/{subscriptionId}/providers/Microsoft.Resources/deployments/{deploymentName}/operations"} # type: ignore + list_at_subscription_scope.metadata = {"url": "/subscriptions/{subscriptionId}/providers/Microsoft.Resources/deployments/{deploymentName}/operations"} # type: ignore @distributed_trace def get( - self, - resource_group_name: str, - deployment_name: str, - operation_id: str, - **kwargs: Any - ) -> "_models.DeploymentOperation": + self, resource_group_name: str, deployment_name: str, operation_id: str, **kwargs: Any + ) -> _models.DeploymentOperation: """Gets a deployments operation. :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. :type resource_group_name: str - :param deployment_name: The name of the deployment. + :param deployment_name: The name of the deployment. Required. :type deployment_name: str - :param operation_id: The ID of the operation to get. + :param operation_id: The ID of the operation to get. Required. :type operation_id: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: DeploymentOperation, or the result of cls(response) + :return: DeploymentOperation or the result of cls(response) :rtype: ~azure.mgmt.resource.resources.v2019_03_01.models.DeploymentOperation - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.DeploymentOperation"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + 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', "2019-03-01") # type: str + api_version = kwargs.pop("api_version", _params.pop("api-version", "2019-03-01")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[_models.DeploymentOperation] - request = build_deployment_operations_get_request( resource_group_name=resource_group_name, deployment_name=deployment_name, operation_id=operation_id, subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.get.metadata['url'], + template_url=self.get.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) - deserialized = self._deserialize('DeploymentOperation', pipeline_response) + deserialized = self._deserialize("DeploymentOperation", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - get.metadata = {'url': "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/deployments/{deploymentName}/operations/{operationId}"} # type: ignore - + get.metadata = {"url": "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/deployments/{deploymentName}/operations/{operationId}"} # type: ignore @distributed_trace def list( - self, - resource_group_name: str, - deployment_name: str, - top: Optional[int] = None, - **kwargs: Any - ) -> Iterable["_models.DeploymentOperationsListResult"]: + self, resource_group_name: str, deployment_name: str, top: Optional[int] = None, **kwargs: Any + ) -> Iterable["_models.DeploymentOperation"]: """Gets all deployments operations for a deployment. :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. :type resource_group_name: str - :param deployment_name: The name of the deployment with the operation to get. + :param deployment_name: The name of the deployment with the operation to get. Required. :type deployment_name: str :param top: The number of results to return. Default value is None. :type top: int :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either DeploymentOperationsListResult or the result of - cls(response) + :return: An iterator like instance of either DeploymentOperation or the result of cls(response) :rtype: - ~azure.core.paging.ItemPaged[~azure.mgmt.resource.resources.v2019_03_01.models.DeploymentOperationsListResult] - :raises: ~azure.core.exceptions.HttpResponseError + ~azure.core.paging.ItemPaged[~azure.mgmt.resource.resources.v2019_03_01.models.DeploymentOperation] + :raises ~azure.core.exceptions.HttpResponseError: """ - api_version = kwargs.pop('api_version', "2019-03-01") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2019-03-01")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[_models.DeploymentOperationsListResult] - cls = kwargs.pop('cls', None) # type: ClsType["_models.DeploymentOperationsListResult"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) + def prepare_request(next_link=None): if not next_link: - + request = build_deployment_operations_list_request( resource_group_name=resource_group_name, deployment_name=deployment_name, subscription_id=self._config.subscription_id, - api_version=api_version, top=top, - template_url=self.list.metadata['url'], + 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.url = self._client.format_url(request.url) # type: ignore else: - - request = build_deployment_operations_list_request( - resource_group_name=resource_group_name, - deployment_name=deployment_name, - subscription_id=self._config.subscription_id, - template_url=next_link, - ) + # make call to next link with the client's api-version + _parsed_next_link = urlparse(next_link) + _next_request_params = case_insensitive_dict(parse_qs(_parsed_next_link.query)) + _next_request_params["api-version"] = self._config.api_version + request = HttpRequest("GET", urljoin(next_link, _parsed_next_link.path), params=_next_request_params) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore request.method = "GET" return request @@ -6169,10 +7040,8 @@ def extract_data(pipeline_response): def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) response = pipeline_response.http_response @@ -6182,8 +7051,6 @@ def get_next(next_link=None): return pipeline_response + return ItemPaged(get_next, extract_data) - return ItemPaged( - get_next, extract_data - ) - list.metadata = {'url': "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/deployments/{deploymentName}/operations"} # type: ignore + list.metadata = {"url": "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/deployments/{deploymentName}/operations"} # type: ignore diff --git a/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/resources/v2019_03_01/operations/_patch.py b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/resources/v2019_03_01/operations/_patch.py new file mode 100644 index 0000000000000..f7dd32510333d --- /dev/null +++ b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/resources/v2019_03_01/operations/_patch.py @@ -0,0 +1,20 @@ +# ------------------------------------ +# Copyright (c) Microsoft Corporation. +# Licensed under the MIT License. +# ------------------------------------ +"""Customize generated code here. + +Follow our quickstart for examples: https://aka.ms/azsdk/python/dpcodegen/python/customize +""" +from typing import List + +__all__: List[str] = [] # Add all objects you want publicly available to users at this package level + + +def patch_sdk(): + """Do not remove from this file. + + `patch_sdk` is a last resort escape hatch that allows you to do customizations + you can't accomplish using the techniques described in + https://aka.ms/azsdk/python/dpcodegen/python/customize + """ diff --git a/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/resources/v2019_05_01/__init__.py b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/resources/v2019_05_01/__init__.py index 449220069f2f2..2b201470d075e 100644 --- a/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/resources/v2019_05_01/__init__.py +++ b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/resources/v2019_05_01/__init__.py @@ -10,9 +10,15 @@ from ._version import VERSION __version__ = VERSION -__all__ = ['ResourceManagementClient'] -# `._patch.py` is used for handwritten extensions to the generated code -# Example: https://github.com/Azure/azure-sdk-for-python/blob/main/doc/dev/customize_code/how-to-patch-sdk-code.md -from ._patch import patch_sdk -patch_sdk() +try: + from ._patch import __all__ as _patch_all + from ._patch import * # type: ignore # pylint: disable=unused-wildcard-import +except ImportError: + _patch_all = [] +from ._patch import patch_sdk as _patch_sdk + +__all__ = ["ResourceManagementClient"] +__all__.extend([p for p in _patch_all if p not in __all__]) + +_patch_sdk() diff --git a/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/resources/v2019_05_01/_configuration.py b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/resources/v2019_05_01/_configuration.py index cc9b40c44504b..2b73226babe1c 100644 --- a/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/resources/v2019_05_01/_configuration.py +++ b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/resources/v2019_05_01/_configuration.py @@ -25,23 +25,18 @@ class ResourceManagementClientConfiguration(Configuration): # pylint: disable=t Note that all parameters used to create this instance are saved as instance attributes. - :param credential: Credential needed for the client to connect to Azure. + :param credential: Credential needed for the client to connect to Azure. Required. :type credential: ~azure.core.credentials.TokenCredential - :param subscription_id: The ID of the target subscription. + :param subscription_id: The ID of the target subscription. Required. :type subscription_id: str :keyword api_version: Api Version. Default value is "2019-05-01". Note that overriding this default value may result in unsupported behavior. :paramtype api_version: str """ - def __init__( - self, - credential: "TokenCredential", - subscription_id: str, - **kwargs: Any - ) -> None: + def __init__(self, credential: "TokenCredential", subscription_id: str, **kwargs: Any) -> None: super(ResourceManagementClientConfiguration, self).__init__(**kwargs) - api_version = kwargs.pop('api_version', "2019-05-01") # type: str + api_version = kwargs.pop("api_version", "2019-05-01") # type: str if credential is None: raise ValueError("Parameter 'credential' must not be None.") @@ -51,23 +46,24 @@ def __init__( self.credential = credential self.subscription_id = subscription_id self.api_version = api_version - self.credential_scopes = kwargs.pop('credential_scopes', ['https://management.azure.com/.default']) - kwargs.setdefault('sdk_moniker', 'mgmt-resource/{}'.format(VERSION)) + self.credential_scopes = kwargs.pop("credential_scopes", ["https://management.azure.com/.default"]) + kwargs.setdefault("sdk_moniker", "mgmt-resource/{}".format(VERSION)) self._configure(**kwargs) def _configure( - self, - **kwargs # type: Any + self, **kwargs # type: Any ): # type: (...) -> 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) - self.logging_policy = kwargs.get('logging_policy') or policies.NetworkTraceLoggingPolicy(**kwargs) - self.http_logging_policy = kwargs.get('http_logging_policy') or ARMHttpLoggingPolicy(**kwargs) - self.retry_policy = kwargs.get('retry_policy') or policies.RetryPolicy(**kwargs) - self.custom_hook_policy = kwargs.get('custom_hook_policy') or policies.CustomHookPolicy(**kwargs) - self.redirect_policy = kwargs.get('redirect_policy') or policies.RedirectPolicy(**kwargs) - self.authentication_policy = kwargs.get('authentication_policy') + 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) + self.logging_policy = kwargs.get("logging_policy") or policies.NetworkTraceLoggingPolicy(**kwargs) + self.http_logging_policy = kwargs.get("http_logging_policy") or ARMHttpLoggingPolicy(**kwargs) + self.retry_policy = kwargs.get("retry_policy") or policies.RetryPolicy(**kwargs) + self.custom_hook_policy = kwargs.get("custom_hook_policy") or policies.CustomHookPolicy(**kwargs) + self.redirect_policy = kwargs.get("redirect_policy") or policies.RedirectPolicy(**kwargs) + self.authentication_policy = kwargs.get("authentication_policy") if self.credential and not self.authentication_policy: - self.authentication_policy = ARMChallengeAuthenticationPolicy(self.credential, *self.credential_scopes, **kwargs) + self.authentication_policy = ARMChallengeAuthenticationPolicy( + self.credential, *self.credential_scopes, **kwargs + ) diff --git a/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/resources/v2019_05_01/_metadata.json b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/resources/v2019_05_01/_metadata.json index 53de53f42c231..5af462d227eb5 100644 --- a/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/resources/v2019_05_01/_metadata.json +++ b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/resources/v2019_05_01/_metadata.json @@ -10,20 +10,20 @@ "azure_arm": true, "has_lro_operations": true, "client_side_validation": false, - "sync_imports": "{\"typing\": {\"azurecore\": {\"azure.core.credentials\": [\"TokenCredential\"]}}, \"regular\": {\"azurecore\": {\"azure.profiles\": [\"KnownProfiles\", \"ProfileDefinition\"], \"azure.profiles.multiapiclient\": [\"MultiApiClientMixin\"], \"azure.mgmt.core\": [\"ARMPipelineClient\"]}, \"local\": {\"._configuration\": [\"ResourceManagementClientConfiguration\"]}, \"thirdparty\": {\"msrest\": [\"Deserializer\", \"Serializer\"]}}, \"conditional\": {\"stdlib\": {\"typing\": [\"Any\", \"Optional\"]}}}", - "async_imports": "{\"typing\": {\"azurecore\": {\"azure.core.credentials_async\": [\"AsyncTokenCredential\"], \"azure.core.credentials\": [\"TokenCredential\"]}}, \"regular\": {\"azurecore\": {\"azure.profiles\": [\"KnownProfiles\", \"ProfileDefinition\"], \"azure.profiles.multiapiclient\": [\"MultiApiClientMixin\"], \"azure.mgmt.core\": [\"AsyncARMPipelineClient\"]}, \"local\": {\"._configuration\": [\"ResourceManagementClientConfiguration\"]}, \"thirdparty\": {\"msrest\": [\"Deserializer\", \"Serializer\"]}}, \"conditional\": {\"stdlib\": {\"typing\": [\"Any\", \"Optional\"]}}}" + "sync_imports": "{\"conditional\": {\"stdlib\": {\"typing\": [\"Any\", \"Optional\"]}}, \"regular\": {\"azurecore\": {\"azure.mgmt.core\": [\"ARMPipelineClient\"], \"azure.profiles\": [\"KnownProfiles\", \"ProfileDefinition\"], \"azure.profiles.multiapiclient\": [\"MultiApiClientMixin\"]}, \"local\": {\"._configuration\": [\"ResourceManagementClientConfiguration\"], \".._serialization\": [\"Deserializer\", \"Serializer\"]}}, \"typing\": {\"azurecore\": {\"azure.core.credentials\": [\"TokenCredential\"]}}}", + "async_imports": "{\"conditional\": {\"stdlib\": {\"typing\": [\"Any\", \"Optional\"]}}, \"regular\": {\"azurecore\": {\"azure.mgmt.core\": [\"AsyncARMPipelineClient\"], \"azure.profiles\": [\"KnownProfiles\", \"ProfileDefinition\"], \"azure.profiles.multiapiclient\": [\"MultiApiClientMixin\"]}, \"local\": {\"._configuration\": [\"ResourceManagementClientConfiguration\"], \"..._serialization\": [\"Deserializer\", \"Serializer\"]}}, \"typing\": {\"azurecore\": {\"azure.core.credentials_async\": [\"AsyncTokenCredential\"]}}}" }, "global_parameters": { "sync": { "credential": { - "signature": "credential, # type: \"TokenCredential\"", - "description": "Credential needed for the client to connect to Azure.", + "signature": "credential: \"TokenCredential\",", + "description": "Credential needed for the client to connect to Azure. Required.", "docstring_type": "~azure.core.credentials.TokenCredential", "required": true }, "subscription_id": { - "signature": "subscription_id, # type: str", - "description": "The ID of the target subscription.", + "signature": "subscription_id: str,", + "description": "The ID of the target subscription. Required.", "docstring_type": "str", "required": true } @@ -31,13 +31,13 @@ "async": { "credential": { "signature": "credential: \"AsyncTokenCredential\",", - "description": "Credential needed for the client to connect to Azure.", + "description": "Credential needed for the client to connect to Azure. Required.", "docstring_type": "~azure.core.credentials_async.AsyncTokenCredential", "required": true }, "subscription_id": { "signature": "subscription_id: str,", - "description": "The ID of the target subscription.", + "description": "The ID of the target subscription. Required.", "docstring_type": "str", "required": true } @@ -54,7 +54,7 @@ "required": false }, "base_url": { - "signature": "base_url=\"https://management.azure.com\", # type: str", + "signature": "base_url: str = \"https://management.azure.com\",", "description": "Service URL", "docstring_type": "str", "required": false diff --git a/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/resources/v2019_05_01/_patch.py b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/resources/v2019_05_01/_patch.py index 74e48ecd07cf3..f99e77fef9861 100644 --- a/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/resources/v2019_05_01/_patch.py +++ b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/resources/v2019_05_01/_patch.py @@ -28,4 +28,4 @@ # This file is used for handwritten extensions to the generated code. Example: # https://github.com/Azure/azure-sdk-for-python/blob/main/doc/dev/customize_code/how-to-patch-sdk-code.md def patch_sdk(): - pass \ No newline at end of file + pass diff --git a/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/resources/v2019_05_01/_resource_management_client.py b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/resources/v2019_05_01/_resource_management_client.py index 15167eb9f3794..f9f1fe21682fd 100644 --- a/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/resources/v2019_05_01/_resource_management_client.py +++ b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/resources/v2019_05_01/_resource_management_client.py @@ -9,20 +9,28 @@ from copy import deepcopy from typing import Any, TYPE_CHECKING -from msrest import Deserializer, Serializer - from azure.core.rest import HttpRequest, HttpResponse from azure.mgmt.core import ARMPipelineClient from . import models +from .._serialization import Deserializer, Serializer from ._configuration import ResourceManagementClientConfiguration -from .operations import DeploymentOperationsOperations, DeploymentsOperations, Operations, ProvidersOperations, ResourceGroupsOperations, ResourcesOperations, TagsOperations +from .operations import ( + DeploymentOperationsOperations, + DeploymentsOperations, + Operations, + ProvidersOperations, + ResourceGroupsOperations, + ResourcesOperations, + TagsOperations, +) if TYPE_CHECKING: # pylint: disable=unused-import,ungrouped-imports from azure.core.credentials import TokenCredential -class ResourceManagementClient: # pylint: disable=too-many-instance-attributes + +class ResourceManagementClient: # pylint: disable=client-accepts-api-version-keyword,too-many-instance-attributes """Provides operations for working with resources and resource groups. :ivar operations: Operations operations @@ -42,9 +50,9 @@ class ResourceManagementClient: # pylint: disable=too-many-instance-attribute :ivar deployment_operations: DeploymentOperationsOperations operations :vartype deployment_operations: azure.mgmt.resource.resources.v2019_05_01.operations.DeploymentOperationsOperations - :param credential: Credential needed for the client to connect to Azure. + :param credential: Credential needed for the client to connect to Azure. Required. :type credential: ~azure.core.credentials.TokenCredential - :param subscription_id: The ID of the target subscription. + :param subscription_id: The ID of the target subscription. Required. :type subscription_id: str :param base_url: Service URL. Default value is "https://management.azure.com". :type base_url: str @@ -62,7 +70,9 @@ def __init__( base_url: str = "https://management.azure.com", **kwargs: Any ) -> None: - self._config = ResourceManagementClientConfiguration(credential=credential, subscription_id=subscription_id, **kwargs) + self._config = ResourceManagementClientConfiguration( + credential=credential, subscription_id=subscription_id, **kwargs + ) self._client = ARMPipelineClient(base_url=base_url, config=self._config, **kwargs) client_models = {k: v for k, v in models.__dict__.items() if isinstance(v, type)} @@ -75,14 +85,11 @@ def __init__( self.resources = ResourcesOperations(self._client, self._config, self._serialize, self._deserialize) self.resource_groups = ResourceGroupsOperations(self._client, self._config, self._serialize, self._deserialize) self.tags = TagsOperations(self._client, self._config, self._serialize, self._deserialize) - self.deployment_operations = DeploymentOperationsOperations(self._client, self._config, self._serialize, self._deserialize) - + self.deployment_operations = DeploymentOperationsOperations( + self._client, self._config, self._serialize, self._deserialize + ) - def _send_request( - self, - request: HttpRequest, - **kwargs: Any - ) -> HttpResponse: + def _send_request(self, request: HttpRequest, **kwargs: Any) -> HttpResponse: """Runs the network request through the client's chained policies. >>> from azure.core.rest import HttpRequest @@ -91,7 +98,7 @@ def _send_request( >>> response = client._send_request(request) - For more information on this code flow, see https://aka.ms/azsdk/python/protocol/quickstart + For more information on this code flow, see https://aka.ms/azsdk/dpcodegen/python/send_request :param request: The network request you want to make. Required. :type request: ~azure.core.rest.HttpRequest diff --git a/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/resources/v2019_05_01/_vendor.py b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/resources/v2019_05_01/_vendor.py index 138f663c53a4e..9aad73fc743e7 100644 --- a/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/resources/v2019_05_01/_vendor.py +++ b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/resources/v2019_05_01/_vendor.py @@ -7,6 +7,7 @@ from azure.core.pipeline.transport import HttpRequest + def _convert_request(request, files=None): data = request.content if not files else None request = HttpRequest(method=request.method, url=request.url, headers=request.headers, data=data) @@ -14,6 +15,7 @@ def _convert_request(request, files=None): request.set_formdata_body(files) return request + def _format_url_section(template, **kwargs): components = template.split("/") while components: @@ -21,7 +23,5 @@ def _format_url_section(template, **kwargs): 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 - ] + components = [c for c in formatted_components if "{}".format(key.args[0]) not in c] template = "/".join(components) diff --git a/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/resources/v2019_05_01/_version.py b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/resources/v2019_05_01/_version.py index a012ac01c480c..e5754a47ce68f 100644 --- a/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/resources/v2019_05_01/_version.py +++ b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/resources/v2019_05_01/_version.py @@ -6,4 +6,4 @@ # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -VERSION = "21.1.0" +VERSION = "1.0.0b1" diff --git a/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/resources/v2019_05_01/aio/__init__.py b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/resources/v2019_05_01/aio/__init__.py index c6c3cf64a37a6..98d6782c2530c 100644 --- a/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/resources/v2019_05_01/aio/__init__.py +++ b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/resources/v2019_05_01/aio/__init__.py @@ -7,9 +7,15 @@ # -------------------------------------------------------------------------- from ._resource_management_client import ResourceManagementClient -__all__ = ['ResourceManagementClient'] -# `._patch.py` is used for handwritten extensions to the generated code -# Example: https://github.com/Azure/azure-sdk-for-python/blob/main/doc/dev/customize_code/how-to-patch-sdk-code.md -from ._patch import patch_sdk -patch_sdk() +try: + from ._patch import __all__ as _patch_all + from ._patch import * # type: ignore # pylint: disable=unused-wildcard-import +except ImportError: + _patch_all = [] +from ._patch import patch_sdk as _patch_sdk + +__all__ = ["ResourceManagementClient"] +__all__.extend([p for p in _patch_all if p not in __all__]) + +_patch_sdk() diff --git a/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/resources/v2019_05_01/aio/_configuration.py b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/resources/v2019_05_01/aio/_configuration.py index cad3a5559454a..11093b232c39a 100644 --- a/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/resources/v2019_05_01/aio/_configuration.py +++ b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/resources/v2019_05_01/aio/_configuration.py @@ -25,23 +25,18 @@ class ResourceManagementClientConfiguration(Configuration): # pylint: disable=t Note that all parameters used to create this instance are saved as instance attributes. - :param credential: Credential needed for the client to connect to Azure. + :param credential: Credential needed for the client to connect to Azure. Required. :type credential: ~azure.core.credentials_async.AsyncTokenCredential - :param subscription_id: The ID of the target subscription. + :param subscription_id: The ID of the target subscription. Required. :type subscription_id: str :keyword api_version: Api Version. Default value is "2019-05-01". Note that overriding this default value may result in unsupported behavior. :paramtype api_version: str """ - def __init__( - self, - credential: "AsyncTokenCredential", - subscription_id: str, - **kwargs: Any - ) -> None: + def __init__(self, credential: "AsyncTokenCredential", subscription_id: str, **kwargs: Any) -> None: super(ResourceManagementClientConfiguration, self).__init__(**kwargs) - api_version = kwargs.pop('api_version', "2019-05-01") # type: str + api_version = kwargs.pop("api_version", "2019-05-01") # type: str if credential is None: raise ValueError("Parameter 'credential' must not be None.") @@ -51,22 +46,21 @@ def __init__( self.credential = credential self.subscription_id = subscription_id self.api_version = api_version - self.credential_scopes = kwargs.pop('credential_scopes', ['https://management.azure.com/.default']) - kwargs.setdefault('sdk_moniker', 'mgmt-resource/{}'.format(VERSION)) + self.credential_scopes = kwargs.pop("credential_scopes", ["https://management.azure.com/.default"]) + kwargs.setdefault("sdk_moniker", "mgmt-resource/{}".format(VERSION)) self._configure(**kwargs) - 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) - self.logging_policy = kwargs.get('logging_policy') or policies.NetworkTraceLoggingPolicy(**kwargs) - self.http_logging_policy = kwargs.get('http_logging_policy') or ARMHttpLoggingPolicy(**kwargs) - self.retry_policy = kwargs.get('retry_policy') or policies.AsyncRetryPolicy(**kwargs) - self.custom_hook_policy = kwargs.get('custom_hook_policy') or policies.CustomHookPolicy(**kwargs) - self.redirect_policy = kwargs.get('redirect_policy') or policies.AsyncRedirectPolicy(**kwargs) - self.authentication_policy = kwargs.get('authentication_policy') + 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) + self.logging_policy = kwargs.get("logging_policy") or policies.NetworkTraceLoggingPolicy(**kwargs) + self.http_logging_policy = kwargs.get("http_logging_policy") or ARMHttpLoggingPolicy(**kwargs) + self.retry_policy = kwargs.get("retry_policy") or policies.AsyncRetryPolicy(**kwargs) + self.custom_hook_policy = kwargs.get("custom_hook_policy") or policies.CustomHookPolicy(**kwargs) + self.redirect_policy = kwargs.get("redirect_policy") or policies.AsyncRedirectPolicy(**kwargs) + self.authentication_policy = kwargs.get("authentication_policy") if self.credential and not self.authentication_policy: - self.authentication_policy = AsyncARMChallengeAuthenticationPolicy(self.credential, *self.credential_scopes, **kwargs) + self.authentication_policy = AsyncARMChallengeAuthenticationPolicy( + self.credential, *self.credential_scopes, **kwargs + ) diff --git a/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/resources/v2019_05_01/aio/_patch.py b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/resources/v2019_05_01/aio/_patch.py index 74e48ecd07cf3..f99e77fef9861 100644 --- a/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/resources/v2019_05_01/aio/_patch.py +++ b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/resources/v2019_05_01/aio/_patch.py @@ -28,4 +28,4 @@ # This file is used for handwritten extensions to the generated code. Example: # https://github.com/Azure/azure-sdk-for-python/blob/main/doc/dev/customize_code/how-to-patch-sdk-code.md def patch_sdk(): - pass \ No newline at end of file + pass diff --git a/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/resources/v2019_05_01/aio/_resource_management_client.py b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/resources/v2019_05_01/aio/_resource_management_client.py index c974849c71d49..39be8894143bd 100644 --- a/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/resources/v2019_05_01/aio/_resource_management_client.py +++ b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/resources/v2019_05_01/aio/_resource_management_client.py @@ -9,20 +9,28 @@ from copy import deepcopy from typing import Any, Awaitable, TYPE_CHECKING -from msrest import Deserializer, Serializer - from azure.core.rest import AsyncHttpResponse, HttpRequest from azure.mgmt.core import AsyncARMPipelineClient from .. import models +from ..._serialization import Deserializer, Serializer from ._configuration import ResourceManagementClientConfiguration -from .operations import DeploymentOperationsOperations, DeploymentsOperations, Operations, ProvidersOperations, ResourceGroupsOperations, ResourcesOperations, TagsOperations +from .operations import ( + DeploymentOperationsOperations, + DeploymentsOperations, + Operations, + ProvidersOperations, + ResourceGroupsOperations, + ResourcesOperations, + TagsOperations, +) if TYPE_CHECKING: # pylint: disable=unused-import,ungrouped-imports from azure.core.credentials_async import AsyncTokenCredential -class ResourceManagementClient: # pylint: disable=too-many-instance-attributes + +class ResourceManagementClient: # pylint: disable=client-accepts-api-version-keyword,too-many-instance-attributes """Provides operations for working with resources and resource groups. :ivar operations: Operations operations @@ -44,9 +52,9 @@ class ResourceManagementClient: # pylint: disable=too-many-instance-attribute :ivar deployment_operations: DeploymentOperationsOperations operations :vartype deployment_operations: azure.mgmt.resource.resources.v2019_05_01.aio.operations.DeploymentOperationsOperations - :param credential: Credential needed for the client to connect to Azure. + :param credential: Credential needed for the client to connect to Azure. Required. :type credential: ~azure.core.credentials_async.AsyncTokenCredential - :param subscription_id: The ID of the target subscription. + :param subscription_id: The ID of the target subscription. Required. :type subscription_id: str :param base_url: Service URL. Default value is "https://management.azure.com". :type base_url: str @@ -64,7 +72,9 @@ def __init__( base_url: str = "https://management.azure.com", **kwargs: Any ) -> None: - self._config = ResourceManagementClientConfiguration(credential=credential, subscription_id=subscription_id, **kwargs) + self._config = ResourceManagementClientConfiguration( + credential=credential, subscription_id=subscription_id, **kwargs + ) self._client = AsyncARMPipelineClient(base_url=base_url, config=self._config, **kwargs) client_models = {k: v for k, v in models.__dict__.items() if isinstance(v, type)} @@ -77,14 +87,11 @@ def __init__( self.resources = ResourcesOperations(self._client, self._config, self._serialize, self._deserialize) self.resource_groups = ResourceGroupsOperations(self._client, self._config, self._serialize, self._deserialize) self.tags = TagsOperations(self._client, self._config, self._serialize, self._deserialize) - self.deployment_operations = DeploymentOperationsOperations(self._client, self._config, self._serialize, self._deserialize) - + self.deployment_operations = DeploymentOperationsOperations( + self._client, self._config, self._serialize, self._deserialize + ) - def _send_request( - self, - request: HttpRequest, - **kwargs: Any - ) -> Awaitable[AsyncHttpResponse]: + def _send_request(self, request: HttpRequest, **kwargs: Any) -> Awaitable[AsyncHttpResponse]: """Runs the network request through the client's chained policies. >>> from azure.core.rest import HttpRequest @@ -93,7 +100,7 @@ def _send_request( >>> response = await client._send_request(request) - For more information on this code flow, see https://aka.ms/azsdk/python/protocol/quickstart + For more information on this code flow, see https://aka.ms/azsdk/dpcodegen/python/send_request :param request: The network request you want to make. Required. :type request: ~azure.core.rest.HttpRequest diff --git a/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/resources/v2019_05_01/aio/operations/__init__.py b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/resources/v2019_05_01/aio/operations/__init__.py index 53876d82bf5d7..804fee65e3137 100644 --- a/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/resources/v2019_05_01/aio/operations/__init__.py +++ b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/resources/v2019_05_01/aio/operations/__init__.py @@ -14,12 +14,18 @@ from ._operations import TagsOperations from ._operations import DeploymentOperationsOperations +from ._patch import __all__ as _patch_all +from ._patch import * # type: ignore # pylint: disable=unused-wildcard-import +from ._patch import patch_sdk as _patch_sdk + __all__ = [ - 'Operations', - 'DeploymentsOperations', - 'ProvidersOperations', - 'ResourcesOperations', - 'ResourceGroupsOperations', - 'TagsOperations', - 'DeploymentOperationsOperations', + "Operations", + "DeploymentsOperations", + "ProvidersOperations", + "ResourcesOperations", + "ResourceGroupsOperations", + "TagsOperations", + "DeploymentOperationsOperations", ] +__all__.extend([p for p in _patch_all if p not in __all__]) +_patch_sdk() diff --git a/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/resources/v2019_05_01/aio/operations/_operations.py b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/resources/v2019_05_01/aio/operations/_operations.py index 2ddb13df68946..516c7dd71b609 100644 --- a/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/resources/v2019_05_01/aio/operations/_operations.py +++ b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/resources/v2019_05_01/aio/operations/_operations.py @@ -6,84 +6,168 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -from typing import Any, AsyncIterable, Callable, Dict, Optional, TypeVar, Union +import sys +from typing import Any, AsyncIterable, Callable, Dict, IO, Optional, TypeVar, Union, cast, overload +from urllib.parse import parse_qs, urljoin, urlparse from azure.core.async_paging import AsyncItemPaged, AsyncList -from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error +from azure.core.exceptions import ( + ClientAuthenticationError, + HttpResponseError, + ResourceExistsError, + ResourceNotFoundError, + ResourceNotModifiedError, + map_error, +) from azure.core.pipeline import PipelineResponse from azure.core.pipeline.transport import AsyncHttpResponse from azure.core.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 from azure.mgmt.core.polling.async_arm_polling import AsyncARMPolling from ... import models as _models from ..._vendor import _convert_request -from ...operations._operations import build_deployment_operations_get_at_management_group_scope_request, build_deployment_operations_get_at_subscription_scope_request, build_deployment_operations_get_request, build_deployment_operations_list_at_management_group_scope_request, build_deployment_operations_list_at_subscription_scope_request, build_deployment_operations_list_request, build_deployments_calculate_template_hash_request, build_deployments_cancel_at_management_group_scope_request, build_deployments_cancel_at_subscription_scope_request, build_deployments_cancel_request, build_deployments_check_existence_at_management_group_scope_request, build_deployments_check_existence_at_subscription_scope_request, build_deployments_check_existence_request, build_deployments_create_or_update_at_management_group_scope_request_initial, build_deployments_create_or_update_at_subscription_scope_request_initial, build_deployments_create_or_update_request_initial, build_deployments_delete_at_management_group_scope_request_initial, build_deployments_delete_at_subscription_scope_request_initial, build_deployments_delete_request_initial, build_deployments_export_template_at_management_group_scope_request, build_deployments_export_template_at_subscription_scope_request, build_deployments_export_template_request, build_deployments_get_at_management_group_scope_request, build_deployments_get_at_subscription_scope_request, build_deployments_get_request, build_deployments_list_at_management_group_scope_request, build_deployments_list_at_subscription_scope_request, build_deployments_list_by_resource_group_request, build_deployments_validate_at_management_group_scope_request, build_deployments_validate_at_subscription_scope_request, build_deployments_validate_request, build_operations_list_request, build_providers_get_request, build_providers_list_request, build_providers_register_request, build_providers_unregister_request, build_resource_groups_check_existence_request, build_resource_groups_create_or_update_request, build_resource_groups_delete_request_initial, build_resource_groups_export_template_request, build_resource_groups_get_request, build_resource_groups_list_request, build_resource_groups_update_request, build_resources_check_existence_by_id_request, build_resources_check_existence_request, build_resources_create_or_update_by_id_request_initial, build_resources_create_or_update_request_initial, build_resources_delete_by_id_request_initial, build_resources_delete_request_initial, build_resources_get_by_id_request, build_resources_get_request, build_resources_list_by_resource_group_request, build_resources_list_request, build_resources_move_resources_request_initial, build_resources_update_by_id_request_initial, build_resources_update_request_initial, build_resources_validate_move_resources_request_initial, build_tags_create_or_update_request, build_tags_create_or_update_value_request, build_tags_delete_request, build_tags_delete_value_request, build_tags_list_request -T = TypeVar('T') +from ...operations._operations import ( + build_deployment_operations_get_at_management_group_scope_request, + build_deployment_operations_get_at_subscription_scope_request, + build_deployment_operations_get_request, + build_deployment_operations_list_at_management_group_scope_request, + build_deployment_operations_list_at_subscription_scope_request, + build_deployment_operations_list_request, + build_deployments_calculate_template_hash_request, + build_deployments_cancel_at_management_group_scope_request, + build_deployments_cancel_at_subscription_scope_request, + build_deployments_cancel_request, + build_deployments_check_existence_at_management_group_scope_request, + build_deployments_check_existence_at_subscription_scope_request, + build_deployments_check_existence_request, + build_deployments_create_or_update_at_management_group_scope_request, + build_deployments_create_or_update_at_subscription_scope_request, + build_deployments_create_or_update_request, + build_deployments_delete_at_management_group_scope_request, + build_deployments_delete_at_subscription_scope_request, + build_deployments_delete_request, + build_deployments_export_template_at_management_group_scope_request, + build_deployments_export_template_at_subscription_scope_request, + build_deployments_export_template_request, + build_deployments_get_at_management_group_scope_request, + build_deployments_get_at_subscription_scope_request, + build_deployments_get_request, + build_deployments_list_at_management_group_scope_request, + build_deployments_list_at_subscription_scope_request, + build_deployments_list_by_resource_group_request, + build_deployments_validate_at_management_group_scope_request, + build_deployments_validate_at_subscription_scope_request, + build_deployments_validate_request, + build_operations_list_request, + build_providers_get_request, + build_providers_list_request, + build_providers_register_request, + build_providers_unregister_request, + build_resource_groups_check_existence_request, + build_resource_groups_create_or_update_request, + build_resource_groups_delete_request, + build_resource_groups_export_template_request, + build_resource_groups_get_request, + build_resource_groups_list_request, + build_resource_groups_update_request, + build_resources_check_existence_by_id_request, + build_resources_check_existence_request, + build_resources_create_or_update_by_id_request, + build_resources_create_or_update_request, + build_resources_delete_by_id_request, + build_resources_delete_request, + build_resources_get_by_id_request, + build_resources_get_request, + build_resources_list_by_resource_group_request, + build_resources_list_request, + build_resources_move_resources_request, + build_resources_update_by_id_request, + build_resources_update_request, + build_resources_validate_move_resources_request, + build_tags_create_or_update_request, + build_tags_create_or_update_value_request, + build_tags_delete_request, + build_tags_delete_value_request, + build_tags_list_request, +) + +T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] +if sys.version_info >= (3, 9): + from collections.abc import MutableMapping +else: + from typing import MutableMapping # type: ignore # pylint: disable=ungrouped-imports +JSON = MutableMapping[str, Any] # pylint: disable=unsubscriptable-object -class Operations: - """Operations async operations. - You should not instantiate this class directly. Instead, you should create a Client instance that - instantiates it for you and attaches it as an attribute. +class Operations: + """ + .. warning:: + **DO NOT** instantiate this class directly. - :ivar models: Alias to model classes used in this operation group. - :type models: ~azure.mgmt.resource.resources.v2019_05_01.models - :param client: Client for service requests. - :param config: Configuration of service client. - :param serializer: An object model serializer. - :param deserializer: An object model deserializer. + Instead, you should access the following operations through + :class:`~azure.mgmt.resource.resources.v2019_05_01.aio.ResourceManagementClient`'s + :attr:`operations` attribute. """ models = _models - def __init__(self, client, config, serializer, deserializer) -> None: - self._client = client - self._serialize = serializer - self._deserialize = deserializer - self._config = config + def __init__(self, *args, **kwargs) -> None: + input_args = list(args) + self._client = input_args.pop(0) if input_args else kwargs.pop("client") + self._config = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") @distributed_trace - def list( - self, - **kwargs: Any - ) -> AsyncIterable["_models.OperationListResult"]: + def list(self, **kwargs: Any) -> AsyncIterable["_models.Operation"]: """Lists all of the available Microsoft.Resources REST API operations. :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either OperationListResult or the result of cls(response) + :return: An iterator like instance of either Operation or the result of cls(response) :rtype: - ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.resource.resources.v2019_05_01.models.OperationListResult] - :raises: ~azure.core.exceptions.HttpResponseError + ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.resource.resources.v2019_05_01.models.Operation] + :raises ~azure.core.exceptions.HttpResponseError: """ - api_version = kwargs.pop('api_version', "2019-05-01") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2019-05-01")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[_models.OperationListResult] - cls = kwargs.pop('cls', None) # type: ClsType["_models.OperationListResult"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) + def prepare_request(next_link=None): if not next_link: - + request = build_operations_list_request( api_version=api_version, - template_url=self.list.metadata['url'], + template_url=self.list.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore else: - - request = build_operations_list_request( - template_url=next_link, - ) + # make call to next link with the client's api-version + _parsed_next_link = urlparse(next_link) + _next_request_params = case_insensitive_dict(parse_qs(_parsed_next_link.query)) + _next_request_params["api-version"] = self._config.api_version + request = HttpRequest("GET", urljoin(next_link, _parsed_next_link.path), params=_next_request_params) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore request.method = "GET" return request @@ -97,10 +181,8 @@ async def extract_data(pipeline_response): async def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) response = pipeline_response.http_response @@ -110,62 +192,62 @@ async def get_next(next_link=None): return pipeline_response + return AsyncItemPaged(get_next, extract_data) - return AsyncItemPaged( - get_next, extract_data - ) - list.metadata = {'url': "/providers/Microsoft.Resources/operations"} # type: ignore -class DeploymentsOperations: # pylint: disable=too-many-public-methods - """DeploymentsOperations async operations. + list.metadata = {"url": "/providers/Microsoft.Resources/operations"} # type: ignore - You should not instantiate this class directly. Instead, you should create a Client instance that - instantiates it for you and attaches it as an attribute. - :ivar models: Alias to model classes used in this operation group. - :type models: ~azure.mgmt.resource.resources.v2019_05_01.models - :param client: Client for service requests. - :param config: Configuration of service client. - :param serializer: An object model serializer. - :param deserializer: An object model deserializer. +class DeploymentsOperations: # pylint: disable=too-many-public-methods + """ + .. warning:: + **DO NOT** instantiate this class directly. + + Instead, you should access the following operations through + :class:`~azure.mgmt.resource.resources.v2019_05_01.aio.ResourceManagementClient`'s + :attr:`deployments` attribute. """ models = _models - def __init__(self, client, config, serializer, deserializer) -> None: - self._client = client - self._serialize = serializer - self._deserialize = deserializer - self._config = config + def __init__(self, *args, **kwargs) -> None: + input_args = list(args) + self._client = input_args.pop(0) if input_args else kwargs.pop("client") + self._config = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") async def _delete_at_management_group_scope_initial( # pylint: disable=inconsistent-return-statements - self, - group_id: str, - deployment_name: str, - **kwargs: Any + self, group_id: str, deployment_name: str, **kwargs: Any ) -> None: - cls = kwargs.pop('cls', None) # type: ClsType[None] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + 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', "2019-05-01") # type: str + api_version = kwargs.pop("api_version", _params.pop("api-version", "2019-05-01")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[None] - - request = build_deployments_delete_at_management_group_scope_request_initial( + request = build_deployments_delete_at_management_group_scope_request( group_id=group_id, deployment_name=deployment_name, api_version=api_version, - template_url=self._delete_at_management_group_scope_initial.metadata['url'], + template_url=self._delete_at_management_group_scope_initial.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [202, 204]: @@ -175,15 +257,11 @@ async def _delete_at_management_group_scope_initial( # pylint: disable=inconsis if cls: return cls(pipeline_response, None, {}) - _delete_at_management_group_scope_initial.metadata = {'url': "/providers/Microsoft.Management/managementGroups/{groupId}/providers/Microsoft.Resources/deployments/{deploymentName}"} # type: ignore - + _delete_at_management_group_scope_initial.metadata = {"url": "/providers/Microsoft.Management/managementGroups/{groupId}/providers/Microsoft.Resources/deployments/{deploymentName}"} # type: ignore @distributed_trace_async - async def begin_delete_at_management_group_scope( # pylint: disable=inconsistent-return-statements - self, - group_id: str, - deployment_name: str, - **kwargs: Any + async def begin_delete_at_management_group_scope( + self, group_id: str, deployment_name: str, **kwargs: Any ) -> AsyncLROPoller[None]: """Deletes a deployment from the deployment history. @@ -195,9 +273,9 @@ async def begin_delete_at_management_group_scope( # pylint: disable=inconsisten process finishes, the URI in the Location header returns a status of 204 on success. If the asynchronous request failed, the URI in the Location header returns an error-level status code. - :param group_id: The management group ID. + :param group_id: The management group ID. Required. :type group_id: str - :param deployment_name: The name of the deployment. + :param deployment_name: The name of the deployment. Required. :type deployment_name: str :keyword callable cls: A custom type or function that will be passed the direct response :keyword str continuation_token: A continuation token to restart a poller from a saved state. @@ -209,86 +287,93 @@ async def begin_delete_at_management_group_scope( # pylint: disable=inconsisten Retry-After header is present. :return: An instance of AsyncLROPoller that returns either None or the result of cls(response) :rtype: ~azure.core.polling.AsyncLROPoller[None] - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - api_version = kwargs.pop('api_version', "2019-05-01") # type: str - polling = kwargs.pop('polling', True) # type: Union[bool, AsyncPollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType[None] - lro_delay = kwargs.pop( - 'polling_interval', - self._config.polling_interval - ) - cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2019-05-01")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[None] + polling = kwargs.pop("polling", True) # type: Union[bool, AsyncPollingMethod] + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token = kwargs.pop("continuation_token", None) # type: Optional[str] if cont_token is None: - raw_result = await self._delete_at_management_group_scope_initial( + raw_result = await self._delete_at_management_group_scope_initial( # type: ignore group_id=group_id, deployment_name=deployment_name, api_version=api_version, - cls=lambda x,y,z: x, + cls=lambda x, y, z: x, + headers=_headers, + params=_params, **kwargs ) - kwargs.pop('error_map', None) + kwargs.pop("error_map", None) - def get_long_running_output(pipeline_response): + def get_long_running_output(pipeline_response): # pylint: disable=inconsistent-return-statements if cls: return cls(pipeline_response, None, {}) - - if polling is True: polling_method = AsyncARMPolling(lro_delay, **kwargs) - elif polling is False: polling_method = AsyncNoPolling() - else: polling_method = polling + if polling is True: + polling_method = cast(AsyncPollingMethod, AsyncARMPolling(lro_delay, **kwargs)) # type: AsyncPollingMethod + elif polling is False: + polling_method = cast(AsyncPollingMethod, AsyncNoPolling()) + else: + polling_method = polling if cont_token: return AsyncLROPoller.from_continuation_token( polling_method=polling_method, continuation_token=cont_token, client=self._client, - deserialization_callback=get_long_running_output + deserialization_callback=get_long_running_output, ) return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) - begin_delete_at_management_group_scope.metadata = {'url': "/providers/Microsoft.Management/managementGroups/{groupId}/providers/Microsoft.Resources/deployments/{deploymentName}"} # type: ignore + begin_delete_at_management_group_scope.metadata = {"url": "/providers/Microsoft.Management/managementGroups/{groupId}/providers/Microsoft.Resources/deployments/{deploymentName}"} # type: ignore @distributed_trace_async async def check_existence_at_management_group_scope( - self, - group_id: str, - deployment_name: str, - **kwargs: Any + self, group_id: str, deployment_name: str, **kwargs: Any ) -> bool: """Checks whether the deployment exists. - :param group_id: The management group ID. + :param group_id: The management group ID. Required. :type group_id: str - :param deployment_name: The name of the deployment. + :param deployment_name: The name of the deployment. Required. :type deployment_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: bool, or the result of cls(response) + :return: bool or the result of cls(response) :rtype: bool - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType[None] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + 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', "2019-05-01") # type: str + api_version = kwargs.pop("api_version", _params.pop("api-version", "2019-05-01")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[None] - request = build_deployments_check_existence_at_management_group_scope_request( group_id=group_id, deployment_name=deployment_name, api_version=api_version, - template_url=self.check_existence_at_management_group_scope.metadata['url'], + template_url=self.check_existence_at_management_group_scope.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [204, 404]: @@ -299,43 +384,52 @@ async def check_existence_at_management_group_scope( return cls(pipeline_response, None, {}) return 200 <= response.status_code <= 299 - check_existence_at_management_group_scope.metadata = {'url': "/providers/Microsoft.Management/managementGroups/{groupId}/providers/Microsoft.Resources/deployments/{deploymentName}"} # type: ignore - + check_existence_at_management_group_scope.metadata = {"url": "/providers/Microsoft.Management/managementGroups/{groupId}/providers/Microsoft.Resources/deployments/{deploymentName}"} # type: ignore async def _create_or_update_at_management_group_scope_initial( - self, - group_id: str, - deployment_name: str, - parameters: "_models.Deployment", - **kwargs: Any - ) -> "_models.DeploymentExtended": - cls = kwargs.pop('cls', None) # type: ClsType["_models.DeploymentExtended"] + self, group_id: str, deployment_name: str, parameters: Union[_models.Deployment, IO], **kwargs: Any + ) -> _models.DeploymentExtended: error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) - api_version = kwargs.pop('api_version', "2019-05-01") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - _json = self._serialize.body(parameters, 'Deployment') + api_version = kwargs.pop("api_version", _params.pop("api-version", "2019-05-01")) # type: str + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.DeploymentExtended] - request = build_deployments_create_or_update_at_management_group_scope_request_initial( + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(parameters, (IO, bytes)): + _content = parameters + else: + _json = self._serialize.body(parameters, "Deployment") + + request = build_deployments_create_or_update_at_management_group_scope_request( group_id=group_id, deployment_name=deployment_name, api_version=api_version, content_type=content_type, json=_json, - template_url=self._create_or_update_at_management_group_scope_initial.metadata['url'], + content=_content, + template_url=self._create_or_update_at_management_group_scope_initial.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200, 201]: @@ -343,37 +437,41 @@ async def _create_or_update_at_management_group_scope_initial( raise HttpResponseError(response=response, error_format=ARMErrorFormat) if response.status_code == 200: - deserialized = self._deserialize('DeploymentExtended', pipeline_response) + deserialized = self._deserialize("DeploymentExtended", pipeline_response) if response.status_code == 201: - deserialized = self._deserialize('DeploymentExtended', pipeline_response) + deserialized = self._deserialize("DeploymentExtended", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - _create_or_update_at_management_group_scope_initial.metadata = {'url': "/providers/Microsoft.Management/managementGroups/{groupId}/providers/Microsoft.Resources/deployments/{deploymentName}"} # type: ignore + _create_or_update_at_management_group_scope_initial.metadata = {"url": "/providers/Microsoft.Management/managementGroups/{groupId}/providers/Microsoft.Resources/deployments/{deploymentName}"} # type: ignore - - @distributed_trace_async + @overload async def begin_create_or_update_at_management_group_scope( self, group_id: str, deployment_name: str, - parameters: "_models.Deployment", + parameters: _models.Deployment, + *, + content_type: str = "application/json", **kwargs: Any - ) -> AsyncLROPoller["_models.DeploymentExtended"]: + ) -> AsyncLROPoller[_models.DeploymentExtended]: """Deploys resources at management group scope. You can provide the template and parameters directly in the request or link to JSON files. - :param group_id: The management group ID. + :param group_id: The management group ID. Required. :type group_id: str - :param deployment_name: The name of the deployment. + :param deployment_name: The name of the deployment. Required. :type deployment_name: str - :param parameters: Additional parameters supplied to the operation. + :param parameters: Additional parameters supplied to the operation. Required. :type parameters: ~azure.mgmt.resource.resources.v2019_05_01.models.Deployment + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str :keyword callable cls: A custom type or function that will be passed the direct response :keyword str continuation_token: A continuation token to restart a poller from a saved state. :keyword polling: By default, your polling method will be AsyncARMPolling. Pass in False for @@ -386,114 +484,187 @@ async def begin_create_or_update_at_management_group_scope( cls(response) :rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.resource.resources.v2019_05_01.models.DeploymentExtended] - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - api_version = kwargs.pop('api_version', "2019-05-01") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] - polling = kwargs.pop('polling', True) # type: Union[bool, AsyncPollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType["_models.DeploymentExtended"] - lro_delay = kwargs.pop( - 'polling_interval', - self._config.polling_interval - ) - cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] + + @overload + async def begin_create_or_update_at_management_group_scope( + self, + group_id: str, + deployment_name: str, + parameters: IO, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> AsyncLROPoller[_models.DeploymentExtended]: + """Deploys resources at management group scope. + + You can provide the template and parameters directly in the request or link to JSON files. + + :param group_id: The management group ID. Required. + :type group_id: str + :param deployment_name: The name of the deployment. Required. + :type deployment_name: str + :param parameters: Additional parameters supplied to the operation. Required. + :type parameters: IO + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be AsyncARMPolling. Pass in False for + this operation to not poll, or pass in your own initialized polling object for a personal + polling strategy. + :paramtype polling: bool or ~azure.core.polling.AsyncPollingMethod + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of AsyncLROPoller that returns either DeploymentExtended or the result of + cls(response) + :rtype: + ~azure.core.polling.AsyncLROPoller[~azure.mgmt.resource.resources.v2019_05_01.models.DeploymentExtended] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace_async + async def begin_create_or_update_at_management_group_scope( + self, group_id: str, deployment_name: str, parameters: Union[_models.Deployment, IO], **kwargs: Any + ) -> AsyncLROPoller[_models.DeploymentExtended]: + """Deploys resources at management group scope. + + You can provide the template and parameters directly in the request or link to JSON files. + + :param group_id: The management group ID. Required. + :type group_id: str + :param deployment_name: The name of the deployment. Required. + :type deployment_name: str + :param parameters: Additional parameters supplied to the operation. Is either a model type or a + IO type. Required. + :type parameters: ~azure.mgmt.resource.resources.v2019_05_01.models.Deployment or IO + :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. + Default value is None. + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be AsyncARMPolling. Pass in False for + this operation to not poll, or pass in your own initialized polling object for a personal + polling strategy. + :paramtype polling: bool or ~azure.core.polling.AsyncPollingMethod + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of AsyncLROPoller that returns either DeploymentExtended or the result of + cls(response) + :rtype: + ~azure.core.polling.AsyncLROPoller[~azure.mgmt.resource.resources.v2019_05_01.models.DeploymentExtended] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _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", "2019-05-01")) # type: str + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.DeploymentExtended] + polling = kwargs.pop("polling", True) # type: Union[bool, AsyncPollingMethod] + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token = kwargs.pop("continuation_token", None) # type: Optional[str] if cont_token is None: - raw_result = await self._create_or_update_at_management_group_scope_initial( + raw_result = await self._create_or_update_at_management_group_scope_initial( # type: ignore group_id=group_id, deployment_name=deployment_name, parameters=parameters, api_version=api_version, content_type=content_type, - cls=lambda x,y,z: x, + cls=lambda x, y, z: x, + headers=_headers, + params=_params, **kwargs ) - kwargs.pop('error_map', None) + kwargs.pop("error_map", None) def get_long_running_output(pipeline_response): - response = pipeline_response.http_response - deserialized = self._deserialize('DeploymentExtended', pipeline_response) + deserialized = self._deserialize("DeploymentExtended", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - - if polling is True: polling_method = AsyncARMPolling(lro_delay, **kwargs) - elif polling is False: polling_method = AsyncNoPolling() - else: polling_method = polling + if polling is True: + polling_method = cast(AsyncPollingMethod, AsyncARMPolling(lro_delay, **kwargs)) # type: AsyncPollingMethod + elif polling is False: + polling_method = cast(AsyncPollingMethod, AsyncNoPolling()) + else: + polling_method = polling if cont_token: return AsyncLROPoller.from_continuation_token( polling_method=polling_method, continuation_token=cont_token, client=self._client, - deserialization_callback=get_long_running_output + deserialization_callback=get_long_running_output, ) return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) - begin_create_or_update_at_management_group_scope.metadata = {'url': "/providers/Microsoft.Management/managementGroups/{groupId}/providers/Microsoft.Resources/deployments/{deploymentName}"} # type: ignore + begin_create_or_update_at_management_group_scope.metadata = {"url": "/providers/Microsoft.Management/managementGroups/{groupId}/providers/Microsoft.Resources/deployments/{deploymentName}"} # type: ignore @distributed_trace_async async def get_at_management_group_scope( - self, - group_id: str, - deployment_name: str, - **kwargs: Any - ) -> "_models.DeploymentExtended": + self, group_id: str, deployment_name: str, **kwargs: Any + ) -> _models.DeploymentExtended: """Gets a deployment. - :param group_id: The management group ID. + :param group_id: The management group ID. Required. :type group_id: str - :param deployment_name: The name of the deployment. + :param deployment_name: The name of the deployment. Required. :type deployment_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: DeploymentExtended, or the result of cls(response) + :return: DeploymentExtended or the result of cls(response) :rtype: ~azure.mgmt.resource.resources.v2019_05_01.models.DeploymentExtended - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.DeploymentExtended"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + 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', "2019-05-01") # type: str + api_version = kwargs.pop("api_version", _params.pop("api-version", "2019-05-01")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[_models.DeploymentExtended] - request = build_deployments_get_at_management_group_scope_request( group_id=group_id, deployment_name=deployment_name, api_version=api_version, - template_url=self.get_at_management_group_scope.metadata['url'], + template_url=self.get_at_management_group_scope.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) - deserialized = self._deserialize('DeploymentExtended', pipeline_response) + deserialized = self._deserialize("DeploymentExtended", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - get_at_management_group_scope.metadata = {'url': "/providers/Microsoft.Management/managementGroups/{groupId}/providers/Microsoft.Resources/deployments/{deploymentName}"} # type: ignore - + get_at_management_group_scope.metadata = {"url": "/providers/Microsoft.Management/managementGroups/{groupId}/providers/Microsoft.Resources/deployments/{deploymentName}"} # type: ignore @distributed_trace_async async def cancel_at_management_group_scope( # pylint: disable=inconsistent-return-statements - self, - group_id: str, - deployment_name: str, - **kwargs: Any + self, group_id: str, deployment_name: str, **kwargs: Any ) -> None: """Cancels a currently running template deployment. @@ -502,38 +673,44 @@ async def cancel_at_management_group_scope( # pylint: disable=inconsistent-retu deployment stops the currently running template deployment and leaves the resources partially deployed. - :param group_id: The management group ID. + :param group_id: The management group ID. Required. :type group_id: str - :param deployment_name: The name of the deployment. + :param deployment_name: The name of the deployment. Required. :type deployment_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: None, or the result of cls(response) + :return: None or the result of cls(response) :rtype: None - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType[None] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) - api_version = kwargs.pop('api_version', "2019-05-01") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2019-05-01")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[None] - request = build_deployments_cancel_at_management_group_scope_request( group_id=group_id, deployment_name=deployment_name, api_version=api_version, - template_url=self.cancel_at_management_group_scope.metadata['url'], + template_url=self.cancel_at_management_group_scope.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [204]: @@ -543,41 +720,107 @@ async def cancel_at_management_group_scope( # pylint: disable=inconsistent-retu if cls: return cls(pipeline_response, None, {}) - cancel_at_management_group_scope.metadata = {'url': "/providers/Microsoft.Management/managementGroups/{groupId}/providers/Microsoft.Resources/deployments/{deploymentName}/cancel"} # type: ignore + cancel_at_management_group_scope.metadata = {"url": "/providers/Microsoft.Management/managementGroups/{groupId}/providers/Microsoft.Resources/deployments/{deploymentName}/cancel"} # type: ignore - - @distributed_trace_async + @overload async def validate_at_management_group_scope( self, group_id: str, deployment_name: str, - parameters: "_models.Deployment", + parameters: _models.Deployment, + *, + content_type: str = "application/json", **kwargs: Any - ) -> "_models.DeploymentValidateResult": + ) -> _models.DeploymentValidateResult: """Validates whether the specified template is syntactically correct and will be accepted by Azure Resource Manager.. - :param group_id: The management group ID. + :param group_id: The management group ID. Required. :type group_id: str - :param deployment_name: The name of the deployment. + :param deployment_name: The name of the deployment. Required. :type deployment_name: str - :param parameters: Parameters to validate. + :param parameters: Parameters to validate. Required. :type parameters: ~azure.mgmt.resource.resources.v2019_05_01.models.Deployment + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: DeploymentValidateResult or the result of cls(response) + :rtype: ~azure.mgmt.resource.resources.v2019_05_01.models.DeploymentValidateResult + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + async def validate_at_management_group_scope( + self, + group_id: str, + deployment_name: str, + parameters: IO, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.DeploymentValidateResult: + """Validates whether the specified template is syntactically correct and will be accepted by Azure + Resource Manager.. + + :param group_id: The management group ID. Required. + :type group_id: str + :param deployment_name: The name of the deployment. Required. + :type deployment_name: str + :param parameters: Parameters to validate. Required. + :type parameters: IO + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: DeploymentValidateResult or the result of cls(response) + :rtype: ~azure.mgmt.resource.resources.v2019_05_01.models.DeploymentValidateResult + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace_async + async def validate_at_management_group_scope( + self, group_id: str, deployment_name: str, parameters: Union[_models.Deployment, IO], **kwargs: Any + ) -> _models.DeploymentValidateResult: + """Validates whether the specified template is syntactically correct and will be accepted by Azure + Resource Manager.. + + :param group_id: The management group ID. Required. + :type group_id: str + :param deployment_name: The name of the deployment. Required. + :type deployment_name: str + :param parameters: Parameters to validate. Is either a model type or a IO type. Required. + :type parameters: ~azure.mgmt.resource.resources.v2019_05_01.models.Deployment or IO + :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. + Default value is None. + :paramtype content_type: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: DeploymentValidateResult, or the result of cls(response) + :return: DeploymentValidateResult or the result of cls(response) :rtype: ~azure.mgmt.resource.resources.v2019_05_01.models.DeploymentValidateResult - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.DeploymentValidateResult"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) - api_version = kwargs.pop('api_version', "2019-05-01") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - _json = self._serialize.body(parameters, 'Deployment') + api_version = kwargs.pop("api_version", _params.pop("api-version", "2019-05-01")) # type: str + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.DeploymentValidateResult] + + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(parameters, (IO, bytes)): + _content = parameters + else: + _json = self._serialize.body(parameters, "Deployment") request = build_deployments_validate_at_management_group_scope_request( group_id=group_id, @@ -585,16 +828,18 @@ async def validate_at_management_group_scope( api_version=api_version, content_type=content_type, json=_json, - template_url=self.validate_at_management_group_scope.metadata['url'], + content=_content, + template_url=self.validate_at_management_group_scope.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200, 400]: @@ -602,87 +847,84 @@ async def validate_at_management_group_scope( raise HttpResponseError(response=response, error_format=ARMErrorFormat) if response.status_code == 200: - deserialized = self._deserialize('DeploymentValidateResult', pipeline_response) + deserialized = self._deserialize("DeploymentValidateResult", pipeline_response) if response.status_code == 400: - deserialized = self._deserialize('DeploymentValidateResult', pipeline_response) + deserialized = self._deserialize("DeploymentValidateResult", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - validate_at_management_group_scope.metadata = {'url': "/providers/Microsoft.Management/managementGroups/{groupId}/providers/Microsoft.Resources/deployments/{deploymentName}/validate"} # type: ignore - + validate_at_management_group_scope.metadata = {"url": "/providers/Microsoft.Management/managementGroups/{groupId}/providers/Microsoft.Resources/deployments/{deploymentName}/validate"} # type: ignore @distributed_trace_async async def export_template_at_management_group_scope( - self, - group_id: str, - deployment_name: str, - **kwargs: Any - ) -> "_models.DeploymentExportResult": + self, group_id: str, deployment_name: str, **kwargs: Any + ) -> _models.DeploymentExportResult: """Exports the template used for specified deployment. - :param group_id: The management group ID. + :param group_id: The management group ID. Required. :type group_id: str - :param deployment_name: The name of the deployment. + :param deployment_name: The name of the deployment. Required. :type deployment_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: DeploymentExportResult, or the result of cls(response) + :return: DeploymentExportResult or the result of cls(response) :rtype: ~azure.mgmt.resource.resources.v2019_05_01.models.DeploymentExportResult - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.DeploymentExportResult"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + 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', "2019-05-01") # type: str + api_version = kwargs.pop("api_version", _params.pop("api-version", "2019-05-01")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[_models.DeploymentExportResult] - request = build_deployments_export_template_at_management_group_scope_request( group_id=group_id, deployment_name=deployment_name, api_version=api_version, - template_url=self.export_template_at_management_group_scope.metadata['url'], + template_url=self.export_template_at_management_group_scope.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) - deserialized = self._deserialize('DeploymentExportResult', pipeline_response) + deserialized = self._deserialize("DeploymentExportResult", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - export_template_at_management_group_scope.metadata = {'url': "/providers/Microsoft.Management/managementGroups/{groupId}/providers/Microsoft.Resources/deployments/{deploymentName}/exportTemplate"} # type: ignore - + export_template_at_management_group_scope.metadata = {"url": "/providers/Microsoft.Management/managementGroups/{groupId}/providers/Microsoft.Resources/deployments/{deploymentName}/exportTemplate"} # type: ignore @distributed_trace def list_at_management_group_scope( - self, - group_id: str, - filter: Optional[str] = None, - top: Optional[int] = None, - **kwargs: Any - ) -> AsyncIterable["_models.DeploymentListResult"]: + self, group_id: str, filter: Optional[str] = None, top: Optional[int] = None, **kwargs: Any + ) -> AsyncIterable["_models.DeploymentExtended"]: """Get all the deployments for a management group. - :param group_id: The management group ID. + :param group_id: The management group ID. Required. :type group_id: str :param filter: The filter to apply on the operation. For example, you can use $filter=provisioningState eq '{state}'. Default value is None. @@ -691,40 +933,48 @@ def list_at_management_group_scope( value is None. :type top: int :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either DeploymentListResult or the result of - cls(response) + :return: An iterator like instance of either DeploymentExtended or the result of cls(response) :rtype: - ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.resource.resources.v2019_05_01.models.DeploymentListResult] - :raises: ~azure.core.exceptions.HttpResponseError + ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.resource.resources.v2019_05_01.models.DeploymentExtended] + :raises ~azure.core.exceptions.HttpResponseError: """ - api_version = kwargs.pop('api_version', "2019-05-01") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2019-05-01")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[_models.DeploymentListResult] - cls = kwargs.pop('cls', None) # type: ClsType["_models.DeploymentListResult"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) + def prepare_request(next_link=None): if not next_link: - + request = build_deployments_list_at_management_group_scope_request( group_id=group_id, - api_version=api_version, filter=filter, top=top, - template_url=self.list_at_management_group_scope.metadata['url'], + api_version=api_version, + template_url=self.list_at_management_group_scope.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore else: - - request = build_deployments_list_at_management_group_scope_request( - group_id=group_id, - template_url=next_link, - ) + # make call to next link with the client's api-version + _parsed_next_link = urlparse(next_link) + _next_request_params = case_insensitive_dict(parse_qs(_parsed_next_link.query)) + _next_request_params["api-version"] = self._config.api_version + request = HttpRequest("GET", urljoin(next_link, _parsed_next_link.path), params=_next_request_params) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore request.method = "GET" return request @@ -738,10 +988,8 @@ async def extract_data(pipeline_response): async def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) response = pipeline_response.http_response @@ -751,40 +999,42 @@ async def get_next(next_link=None): return pipeline_response + return AsyncItemPaged(get_next, extract_data) - return AsyncItemPaged( - get_next, extract_data - ) - list_at_management_group_scope.metadata = {'url': "/providers/Microsoft.Management/managementGroups/{groupId}/providers/Microsoft.Resources/deployments/"} # type: ignore + list_at_management_group_scope.metadata = {"url": "/providers/Microsoft.Management/managementGroups/{groupId}/providers/Microsoft.Resources/deployments/"} # type: ignore async def _delete_at_subscription_scope_initial( # pylint: disable=inconsistent-return-statements - self, - deployment_name: str, - **kwargs: Any + self, deployment_name: str, **kwargs: Any ) -> None: - cls = kwargs.pop('cls', None) # type: ClsType[None] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + 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', "2019-05-01") # type: str + api_version = kwargs.pop("api_version", _params.pop("api-version", "2019-05-01")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[None] - - request = build_deployments_delete_at_subscription_scope_request_initial( + request = build_deployments_delete_at_subscription_scope_request( deployment_name=deployment_name, subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self._delete_at_subscription_scope_initial.metadata['url'], + template_url=self._delete_at_subscription_scope_initial.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [202, 204]: @@ -794,15 +1044,10 @@ async def _delete_at_subscription_scope_initial( # pylint: disable=inconsistent if cls: return cls(pipeline_response, None, {}) - _delete_at_subscription_scope_initial.metadata = {'url': "/subscriptions/{subscriptionId}/providers/Microsoft.Resources/deployments/{deploymentName}"} # type: ignore - + _delete_at_subscription_scope_initial.metadata = {"url": "/subscriptions/{subscriptionId}/providers/Microsoft.Resources/deployments/{deploymentName}"} # type: ignore @distributed_trace_async - async def begin_delete_at_subscription_scope( # pylint: disable=inconsistent-return-statements - self, - deployment_name: str, - **kwargs: Any - ) -> AsyncLROPoller[None]: + async def begin_delete_at_subscription_scope(self, deployment_name: str, **kwargs: Any) -> AsyncLROPoller[None]: """Deletes a deployment from the deployment history. A template deployment that is currently running cannot be deleted. Deleting a template @@ -813,7 +1058,7 @@ async def begin_delete_at_subscription_scope( # pylint: disable=inconsistent-re process finishes, the URI in the Location header returns a status of 204 on success. If the asynchronous request failed, the URI in the Location header returns an error-level status code. - :param deployment_name: The name of the deployment. + :param deployment_name: The name of the deployment. Required. :type deployment_name: str :keyword callable cls: A custom type or function that will be passed the direct response :keyword str continuation_token: A continuation token to restart a poller from a saved state. @@ -825,82 +1070,88 @@ async def begin_delete_at_subscription_scope( # pylint: disable=inconsistent-re Retry-After header is present. :return: An instance of AsyncLROPoller that returns either None or the result of cls(response) :rtype: ~azure.core.polling.AsyncLROPoller[None] - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - api_version = kwargs.pop('api_version', "2019-05-01") # type: str - polling = kwargs.pop('polling', True) # type: Union[bool, AsyncPollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType[None] - lro_delay = kwargs.pop( - 'polling_interval', - self._config.polling_interval - ) - cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2019-05-01")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[None] + polling = kwargs.pop("polling", True) # type: Union[bool, AsyncPollingMethod] + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token = kwargs.pop("continuation_token", None) # type: Optional[str] if cont_token is None: - raw_result = await self._delete_at_subscription_scope_initial( + raw_result = await self._delete_at_subscription_scope_initial( # type: ignore deployment_name=deployment_name, api_version=api_version, - cls=lambda x,y,z: x, + cls=lambda x, y, z: x, + headers=_headers, + params=_params, **kwargs ) - kwargs.pop('error_map', None) + kwargs.pop("error_map", None) - def get_long_running_output(pipeline_response): + def get_long_running_output(pipeline_response): # pylint: disable=inconsistent-return-statements if cls: return cls(pipeline_response, None, {}) - - if polling is True: polling_method = AsyncARMPolling(lro_delay, **kwargs) - elif polling is False: polling_method = AsyncNoPolling() - else: polling_method = polling + if polling is True: + polling_method = cast(AsyncPollingMethod, AsyncARMPolling(lro_delay, **kwargs)) # type: AsyncPollingMethod + elif polling is False: + polling_method = cast(AsyncPollingMethod, AsyncNoPolling()) + else: + polling_method = polling if cont_token: return AsyncLROPoller.from_continuation_token( polling_method=polling_method, continuation_token=cont_token, client=self._client, - deserialization_callback=get_long_running_output + deserialization_callback=get_long_running_output, ) return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) - begin_delete_at_subscription_scope.metadata = {'url': "/subscriptions/{subscriptionId}/providers/Microsoft.Resources/deployments/{deploymentName}"} # type: ignore + begin_delete_at_subscription_scope.metadata = {"url": "/subscriptions/{subscriptionId}/providers/Microsoft.Resources/deployments/{deploymentName}"} # type: ignore @distributed_trace_async - async def check_existence_at_subscription_scope( - self, - deployment_name: str, - **kwargs: Any - ) -> bool: + async def check_existence_at_subscription_scope(self, deployment_name: str, **kwargs: Any) -> bool: """Checks whether the deployment exists. - :param deployment_name: The name of the deployment. + :param deployment_name: The name of the deployment. Required. :type deployment_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: bool, or the result of cls(response) + :return: bool or the result of cls(response) :rtype: bool - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType[None] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + 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', "2019-05-01") # type: str + api_version = kwargs.pop("api_version", _params.pop("api-version", "2019-05-01")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[None] - request = build_deployments_check_existence_at_subscription_scope_request( deployment_name=deployment_name, subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.check_existence_at_subscription_scope.metadata['url'], + template_url=self.check_existence_at_subscription_scope.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [204, 404]: @@ -911,42 +1162,52 @@ async def check_existence_at_subscription_scope( return cls(pipeline_response, None, {}) return 200 <= response.status_code <= 299 - check_existence_at_subscription_scope.metadata = {'url': "/subscriptions/{subscriptionId}/providers/Microsoft.Resources/deployments/{deploymentName}"} # type: ignore - + check_existence_at_subscription_scope.metadata = {"url": "/subscriptions/{subscriptionId}/providers/Microsoft.Resources/deployments/{deploymentName}"} # type: ignore async def _create_or_update_at_subscription_scope_initial( - self, - deployment_name: str, - parameters: "_models.Deployment", - **kwargs: Any - ) -> "_models.DeploymentExtended": - cls = kwargs.pop('cls', None) # type: ClsType["_models.DeploymentExtended"] + self, deployment_name: str, parameters: Union[_models.Deployment, IO], **kwargs: Any + ) -> _models.DeploymentExtended: error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', "2019-05-01") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + api_version = kwargs.pop("api_version", _params.pop("api-version", "2019-05-01")) # type: str + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.DeploymentExtended] - _json = self._serialize.body(parameters, 'Deployment') + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(parameters, (IO, bytes)): + _content = parameters + else: + _json = self._serialize.body(parameters, "Deployment") - request = build_deployments_create_or_update_at_subscription_scope_request_initial( + request = build_deployments_create_or_update_at_subscription_scope_request( deployment_name=deployment_name, subscription_id=self._config.subscription_id, api_version=api_version, content_type=content_type, json=_json, - template_url=self._create_or_update_at_subscription_scope_initial.metadata['url'], + content=_content, + template_url=self._create_or_update_at_subscription_scope_initial.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200, 201]: @@ -954,34 +1215,38 @@ async def _create_or_update_at_subscription_scope_initial( raise HttpResponseError(response=response, error_format=ARMErrorFormat) if response.status_code == 200: - deserialized = self._deserialize('DeploymentExtended', pipeline_response) + deserialized = self._deserialize("DeploymentExtended", pipeline_response) if response.status_code == 201: - deserialized = self._deserialize('DeploymentExtended', pipeline_response) + deserialized = self._deserialize("DeploymentExtended", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - _create_or_update_at_subscription_scope_initial.metadata = {'url': "/subscriptions/{subscriptionId}/providers/Microsoft.Resources/deployments/{deploymentName}"} # type: ignore - + _create_or_update_at_subscription_scope_initial.metadata = {"url": "/subscriptions/{subscriptionId}/providers/Microsoft.Resources/deployments/{deploymentName}"} # type: ignore - @distributed_trace_async + @overload async def begin_create_or_update_at_subscription_scope( self, deployment_name: str, - parameters: "_models.Deployment", + parameters: _models.Deployment, + *, + content_type: str = "application/json", **kwargs: Any - ) -> AsyncLROPoller["_models.DeploymentExtended"]: + ) -> AsyncLROPoller[_models.DeploymentExtended]: """Deploys resources at subscription scope. You can provide the template and parameters directly in the request or link to JSON files. - :param deployment_name: The name of the deployment. + :param deployment_name: The name of the deployment. Required. :type deployment_name: str - :param parameters: Additional parameters supplied to the operation. + :param parameters: Additional parameters supplied to the operation. Required. :type parameters: ~azure.mgmt.resource.resources.v2019_05_01.models.Deployment + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str :keyword callable cls: A custom type or function that will be passed the direct response :keyword str continuation_token: A continuation token to restart a poller from a saved state. :keyword polling: By default, your polling method will be AsyncARMPolling. Pass in False for @@ -994,109 +1259,172 @@ async def begin_create_or_update_at_subscription_scope( cls(response) :rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.resource.resources.v2019_05_01.models.DeploymentExtended] - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - api_version = kwargs.pop('api_version', "2019-05-01") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] - polling = kwargs.pop('polling', True) # type: Union[bool, AsyncPollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType["_models.DeploymentExtended"] - lro_delay = kwargs.pop( - 'polling_interval', - self._config.polling_interval - ) - cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] + + @overload + async def begin_create_or_update_at_subscription_scope( + self, deployment_name: str, parameters: IO, *, content_type: str = "application/json", **kwargs: Any + ) -> AsyncLROPoller[_models.DeploymentExtended]: + """Deploys resources at subscription scope. + + You can provide the template and parameters directly in the request or link to JSON files. + + :param deployment_name: The name of the deployment. Required. + :type deployment_name: str + :param parameters: Additional parameters supplied to the operation. Required. + :type parameters: IO + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be AsyncARMPolling. Pass in False for + this operation to not poll, or pass in your own initialized polling object for a personal + polling strategy. + :paramtype polling: bool or ~azure.core.polling.AsyncPollingMethod + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of AsyncLROPoller that returns either DeploymentExtended or the result of + cls(response) + :rtype: + ~azure.core.polling.AsyncLROPoller[~azure.mgmt.resource.resources.v2019_05_01.models.DeploymentExtended] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace_async + async def begin_create_or_update_at_subscription_scope( + self, deployment_name: str, parameters: Union[_models.Deployment, IO], **kwargs: Any + ) -> AsyncLROPoller[_models.DeploymentExtended]: + """Deploys resources at subscription scope. + + You can provide the template and parameters directly in the request or link to JSON files. + + :param deployment_name: The name of the deployment. Required. + :type deployment_name: str + :param parameters: Additional parameters supplied to the operation. Is either a model type or a + IO type. Required. + :type parameters: ~azure.mgmt.resource.resources.v2019_05_01.models.Deployment or IO + :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. + Default value is None. + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be AsyncARMPolling. Pass in False for + this operation to not poll, or pass in your own initialized polling object for a personal + polling strategy. + :paramtype polling: bool or ~azure.core.polling.AsyncPollingMethod + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of AsyncLROPoller that returns either DeploymentExtended or the result of + cls(response) + :rtype: + ~azure.core.polling.AsyncLROPoller[~azure.mgmt.resource.resources.v2019_05_01.models.DeploymentExtended] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _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", "2019-05-01")) # type: str + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.DeploymentExtended] + polling = kwargs.pop("polling", True) # type: Union[bool, AsyncPollingMethod] + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token = kwargs.pop("continuation_token", None) # type: Optional[str] if cont_token is None: - raw_result = await self._create_or_update_at_subscription_scope_initial( + raw_result = await self._create_or_update_at_subscription_scope_initial( # type: ignore deployment_name=deployment_name, parameters=parameters, api_version=api_version, content_type=content_type, - cls=lambda x,y,z: x, + cls=lambda x, y, z: x, + headers=_headers, + params=_params, **kwargs ) - kwargs.pop('error_map', None) + kwargs.pop("error_map", None) def get_long_running_output(pipeline_response): - response = pipeline_response.http_response - deserialized = self._deserialize('DeploymentExtended', pipeline_response) + deserialized = self._deserialize("DeploymentExtended", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - - if polling is True: polling_method = AsyncARMPolling(lro_delay, **kwargs) - elif polling is False: polling_method = AsyncNoPolling() - else: polling_method = polling + if polling is True: + polling_method = cast(AsyncPollingMethod, AsyncARMPolling(lro_delay, **kwargs)) # type: AsyncPollingMethod + elif polling is False: + polling_method = cast(AsyncPollingMethod, AsyncNoPolling()) + else: + polling_method = polling if cont_token: return AsyncLROPoller.from_continuation_token( polling_method=polling_method, continuation_token=cont_token, client=self._client, - deserialization_callback=get_long_running_output + deserialization_callback=get_long_running_output, ) return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) - begin_create_or_update_at_subscription_scope.metadata = {'url': "/subscriptions/{subscriptionId}/providers/Microsoft.Resources/deployments/{deploymentName}"} # type: ignore + begin_create_or_update_at_subscription_scope.metadata = {"url": "/subscriptions/{subscriptionId}/providers/Microsoft.Resources/deployments/{deploymentName}"} # type: ignore @distributed_trace_async - async def get_at_subscription_scope( - self, - deployment_name: str, - **kwargs: Any - ) -> "_models.DeploymentExtended": + async def get_at_subscription_scope(self, deployment_name: str, **kwargs: Any) -> _models.DeploymentExtended: """Gets a deployment. - :param deployment_name: The name of the deployment. + :param deployment_name: The name of the deployment. Required. :type deployment_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: DeploymentExtended, or the result of cls(response) + :return: DeploymentExtended or the result of cls(response) :rtype: ~azure.mgmt.resource.resources.v2019_05_01.models.DeploymentExtended - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.DeploymentExtended"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) - api_version = kwargs.pop('api_version', "2019-05-01") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2019-05-01")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[_models.DeploymentExtended] - request = build_deployments_get_at_subscription_scope_request( deployment_name=deployment_name, subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.get_at_subscription_scope.metadata['url'], + template_url=self.get_at_subscription_scope.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) - deserialized = self._deserialize('DeploymentExtended', pipeline_response) + deserialized = self._deserialize("DeploymentExtended", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - get_at_subscription_scope.metadata = {'url': "/subscriptions/{subscriptionId}/providers/Microsoft.Resources/deployments/{deploymentName}"} # type: ignore - + get_at_subscription_scope.metadata = {"url": "/subscriptions/{subscriptionId}/providers/Microsoft.Resources/deployments/{deploymentName}"} # type: ignore @distributed_trace_async async def cancel_at_subscription_scope( # pylint: disable=inconsistent-return-statements - self, - deployment_name: str, - **kwargs: Any + self, deployment_name: str, **kwargs: Any ) -> None: """Cancels a currently running template deployment. @@ -1105,36 +1433,42 @@ async def cancel_at_subscription_scope( # pylint: disable=inconsistent-return-s deployment stops the currently running template deployment and leaves the resources partially deployed. - :param deployment_name: The name of the deployment. + :param deployment_name: The name of the deployment. Required. :type deployment_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: None, or the result of cls(response) + :return: None or the result of cls(response) :rtype: None - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType[None] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) - api_version = kwargs.pop('api_version', "2019-05-01") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2019-05-01")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[None] - request = build_deployments_cancel_at_subscription_scope_request( deployment_name=deployment_name, subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.cancel_at_subscription_scope.metadata['url'], + template_url=self.cancel_at_subscription_scope.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [204]: @@ -1144,38 +1478,94 @@ async def cancel_at_subscription_scope( # pylint: disable=inconsistent-return-s if cls: return cls(pipeline_response, None, {}) - cancel_at_subscription_scope.metadata = {'url': "/subscriptions/{subscriptionId}/providers/Microsoft.Resources/deployments/{deploymentName}/cancel"} # type: ignore + cancel_at_subscription_scope.metadata = {"url": "/subscriptions/{subscriptionId}/providers/Microsoft.Resources/deployments/{deploymentName}/cancel"} # type: ignore - - @distributed_trace_async + @overload async def validate_at_subscription_scope( self, deployment_name: str, - parameters: "_models.Deployment", + parameters: _models.Deployment, + *, + content_type: str = "application/json", **kwargs: Any - ) -> "_models.DeploymentValidateResult": + ) -> _models.DeploymentValidateResult: """Validates whether the specified template is syntactically correct and will be accepted by Azure Resource Manager.. - :param deployment_name: The name of the deployment. + :param deployment_name: The name of the deployment. Required. :type deployment_name: str - :param parameters: Parameters to validate. + :param parameters: Parameters to validate. Required. :type parameters: ~azure.mgmt.resource.resources.v2019_05_01.models.Deployment + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: DeploymentValidateResult, or the result of cls(response) + :return: DeploymentValidateResult or the result of cls(response) :rtype: ~azure.mgmt.resource.resources.v2019_05_01.models.DeploymentValidateResult - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.DeploymentValidateResult"] - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {})) - api_version = kwargs.pop('api_version', "2019-05-01") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] - - _json = self._serialize.body(parameters, 'Deployment') + @overload + async def validate_at_subscription_scope( + self, deployment_name: str, parameters: IO, *, content_type: str = "application/json", **kwargs: Any + ) -> _models.DeploymentValidateResult: + """Validates whether the specified template is syntactically correct and will be accepted by Azure + Resource Manager.. + + :param deployment_name: The name of the deployment. Required. + :type deployment_name: str + :param parameters: Parameters to validate. Required. + :type parameters: IO + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: DeploymentValidateResult or the result of cls(response) + :rtype: ~azure.mgmt.resource.resources.v2019_05_01.models.DeploymentValidateResult + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace_async + async def validate_at_subscription_scope( + self, deployment_name: str, parameters: Union[_models.Deployment, IO], **kwargs: Any + ) -> _models.DeploymentValidateResult: + """Validates whether the specified template is syntactically correct and will be accepted by Azure + Resource Manager.. + + :param deployment_name: The name of the deployment. Required. + :type deployment_name: str + :param parameters: Parameters to validate. Is either a model type or a IO type. Required. + :type parameters: ~azure.mgmt.resource.resources.v2019_05_01.models.Deployment or IO + :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. + Default value is None. + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: DeploymentValidateResult or the result of cls(response) + :rtype: ~azure.mgmt.resource.resources.v2019_05_01.models.DeploymentValidateResult + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2019-05-01")) # type: str + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.DeploymentValidateResult] + + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(parameters, (IO, bytes)): + _content = parameters + else: + _json = self._serialize.body(parameters, "Deployment") request = build_deployments_validate_at_subscription_scope_request( deployment_name=deployment_name, @@ -1183,16 +1573,18 @@ async def validate_at_subscription_scope( api_version=api_version, content_type=content_type, json=_json, - template_url=self.validate_at_subscription_scope.metadata['url'], + content=_content, + template_url=self.validate_at_subscription_scope.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200, 400]: @@ -1200,80 +1592,79 @@ async def validate_at_subscription_scope( raise HttpResponseError(response=response, error_format=ARMErrorFormat) if response.status_code == 200: - deserialized = self._deserialize('DeploymentValidateResult', pipeline_response) + deserialized = self._deserialize("DeploymentValidateResult", pipeline_response) if response.status_code == 400: - deserialized = self._deserialize('DeploymentValidateResult', pipeline_response) + deserialized = self._deserialize("DeploymentValidateResult", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - validate_at_subscription_scope.metadata = {'url': "/subscriptions/{subscriptionId}/providers/Microsoft.Resources/deployments/{deploymentName}/validate"} # type: ignore - + validate_at_subscription_scope.metadata = {"url": "/subscriptions/{subscriptionId}/providers/Microsoft.Resources/deployments/{deploymentName}/validate"} # type: ignore @distributed_trace_async async def export_template_at_subscription_scope( - self, - deployment_name: str, - **kwargs: Any - ) -> "_models.DeploymentExportResult": + self, deployment_name: str, **kwargs: Any + ) -> _models.DeploymentExportResult: """Exports the template used for specified deployment. - :param deployment_name: The name of the deployment. + :param deployment_name: The name of the deployment. Required. :type deployment_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: DeploymentExportResult, or the result of cls(response) + :return: DeploymentExportResult or the result of cls(response) :rtype: ~azure.mgmt.resource.resources.v2019_05_01.models.DeploymentExportResult - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.DeploymentExportResult"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) - api_version = kwargs.pop('api_version', "2019-05-01") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2019-05-01")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[_models.DeploymentExportResult] - request = build_deployments_export_template_at_subscription_scope_request( deployment_name=deployment_name, subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.export_template_at_subscription_scope.metadata['url'], + template_url=self.export_template_at_subscription_scope.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) - deserialized = self._deserialize('DeploymentExportResult', pipeline_response) + deserialized = self._deserialize("DeploymentExportResult", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - export_template_at_subscription_scope.metadata = {'url': "/subscriptions/{subscriptionId}/providers/Microsoft.Resources/deployments/{deploymentName}/exportTemplate"} # type: ignore - + export_template_at_subscription_scope.metadata = {"url": "/subscriptions/{subscriptionId}/providers/Microsoft.Resources/deployments/{deploymentName}/exportTemplate"} # type: ignore @distributed_trace def list_at_subscription_scope( - self, - filter: Optional[str] = None, - top: Optional[int] = None, - **kwargs: Any - ) -> AsyncIterable["_models.DeploymentListResult"]: + self, filter: Optional[str] = None, top: Optional[int] = None, **kwargs: Any + ) -> AsyncIterable["_models.DeploymentExtended"]: """Get all the deployments for a subscription. :param filter: The filter to apply on the operation. For example, you can use @@ -1283,40 +1674,48 @@ def list_at_subscription_scope( value is None. :type top: int :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either DeploymentListResult or the result of - cls(response) + :return: An iterator like instance of either DeploymentExtended or the result of cls(response) :rtype: - ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.resource.resources.v2019_05_01.models.DeploymentListResult] - :raises: ~azure.core.exceptions.HttpResponseError + ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.resource.resources.v2019_05_01.models.DeploymentExtended] + :raises ~azure.core.exceptions.HttpResponseError: """ - api_version = kwargs.pop('api_version', "2019-05-01") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2019-05-01")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[_models.DeploymentListResult] - cls = kwargs.pop('cls', None) # type: ClsType["_models.DeploymentListResult"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) + def prepare_request(next_link=None): if not next_link: - + request = build_deployments_list_at_subscription_scope_request( subscription_id=self._config.subscription_id, - api_version=api_version, filter=filter, top=top, - template_url=self.list_at_subscription_scope.metadata['url'], + api_version=api_version, + template_url=self.list_at_subscription_scope.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore else: - - request = build_deployments_list_at_subscription_scope_request( - subscription_id=self._config.subscription_id, - template_url=next_link, - ) + # make call to next link with the client's api-version + _parsed_next_link = urlparse(next_link) + _next_request_params = case_insensitive_dict(parse_qs(_parsed_next_link.query)) + _next_request_params["api-version"] = self._config.api_version + request = HttpRequest("GET", urljoin(next_link, _parsed_next_link.path), params=_next_request_params) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore request.method = "GET" return request @@ -1330,10 +1729,8 @@ async def extract_data(pipeline_response): async def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) response = pipeline_response.http_response @@ -1343,42 +1740,43 @@ async def get_next(next_link=None): return pipeline_response + return AsyncItemPaged(get_next, extract_data) - return AsyncItemPaged( - get_next, extract_data - ) - list_at_subscription_scope.metadata = {'url': "/subscriptions/{subscriptionId}/providers/Microsoft.Resources/deployments/"} # type: ignore + list_at_subscription_scope.metadata = {"url": "/subscriptions/{subscriptionId}/providers/Microsoft.Resources/deployments/"} # type: ignore async def _delete_initial( # pylint: disable=inconsistent-return-statements - self, - resource_group_name: str, - deployment_name: str, - **kwargs: Any + self, resource_group_name: str, deployment_name: str, **kwargs: Any ) -> None: - cls = kwargs.pop('cls', None) # type: ClsType[None] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) - api_version = kwargs.pop('api_version', "2019-05-01") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - request = build_deployments_delete_request_initial( + api_version = kwargs.pop("api_version", _params.pop("api-version", "2019-05-01")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[None] + + request = build_deployments_delete_request( resource_group_name=resource_group_name, deployment_name=deployment_name, subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self._delete_initial.metadata['url'], + template_url=self._delete_initial.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [202, 204]: @@ -1388,16 +1786,10 @@ 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.Resources/deployments/{deploymentName}"} # type: ignore - + _delete_initial.metadata = {"url": "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/Microsoft.Resources/deployments/{deploymentName}"} # type: ignore @distributed_trace_async - async def begin_delete( # pylint: disable=inconsistent-return-statements - self, - resource_group_name: str, - deployment_name: str, - **kwargs: Any - ) -> AsyncLROPoller[None]: + async def begin_delete(self, resource_group_name: str, deployment_name: str, **kwargs: Any) -> AsyncLROPoller[None]: """Deletes a deployment from the deployment history. A template deployment that is currently running cannot be deleted. Deleting a template @@ -1410,9 +1802,9 @@ async def begin_delete( # pylint: disable=inconsistent-return-statements asynchronous request failed, the URI in the Location header returns an error-level status code. :param resource_group_name: The name of the resource group with the deployment to delete. The - name is case insensitive. + name is case insensitive. Required. :type resource_group_name: str - :param deployment_name: The name of the deployment. + :param deployment_name: The name of the deployment. Required. :type deployment_name: str :keyword callable cls: A custom type or function that will be passed the direct response :keyword str continuation_token: A continuation token to restart a poller from a saved state. @@ -1424,88 +1816,93 @@ async def begin_delete( # pylint: disable=inconsistent-return-statements Retry-After header is present. :return: An instance of AsyncLROPoller that returns either None or the result of cls(response) :rtype: ~azure.core.polling.AsyncLROPoller[None] - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - api_version = kwargs.pop('api_version', "2019-05-01") # type: str - polling = kwargs.pop('polling', True) # type: Union[bool, AsyncPollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType[None] - lro_delay = kwargs.pop( - 'polling_interval', - self._config.polling_interval - ) - cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2019-05-01")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[None] + polling = kwargs.pop("polling", True) # type: Union[bool, AsyncPollingMethod] + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token = kwargs.pop("continuation_token", None) # type: Optional[str] if cont_token is None: - raw_result = await self._delete_initial( + raw_result = await self._delete_initial( # type: ignore resource_group_name=resource_group_name, deployment_name=deployment_name, api_version=api_version, - cls=lambda x,y,z: x, + cls=lambda x, y, z: x, + headers=_headers, + params=_params, **kwargs ) - kwargs.pop('error_map', None) + kwargs.pop("error_map", None) - def get_long_running_output(pipeline_response): + def get_long_running_output(pipeline_response): # pylint: disable=inconsistent-return-statements if cls: return cls(pipeline_response, None, {}) - - if polling is True: polling_method = AsyncARMPolling(lro_delay, **kwargs) - elif polling is False: polling_method = AsyncNoPolling() - else: polling_method = polling + if polling is True: + polling_method = cast(AsyncPollingMethod, AsyncARMPolling(lro_delay, **kwargs)) # type: AsyncPollingMethod + elif polling is False: + polling_method = cast(AsyncPollingMethod, AsyncNoPolling()) + else: + polling_method = polling if cont_token: return AsyncLROPoller.from_continuation_token( polling_method=polling_method, continuation_token=cont_token, client=self._client, - deserialization_callback=get_long_running_output + deserialization_callback=get_long_running_output, ) return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) - begin_delete.metadata = {'url': "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/Microsoft.Resources/deployments/{deploymentName}"} # type: ignore + begin_delete.metadata = {"url": "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/Microsoft.Resources/deployments/{deploymentName}"} # type: ignore @distributed_trace_async - async def check_existence( - self, - resource_group_name: str, - deployment_name: str, - **kwargs: Any - ) -> bool: + async def check_existence(self, resource_group_name: str, deployment_name: str, **kwargs: Any) -> bool: """Checks whether the deployment exists. :param resource_group_name: The name of the resource group with the deployment to check. The - name is case insensitive. + name is case insensitive. Required. :type resource_group_name: str - :param deployment_name: The name of the deployment. + :param deployment_name: The name of the deployment. Required. :type deployment_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: bool, or the result of cls(response) + :return: bool or the result of cls(response) :rtype: bool - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType[None] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + 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', "2019-05-01") # type: str + api_version = kwargs.pop("api_version", _params.pop("api-version", "2019-05-01")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[None] - request = build_deployments_check_existence_request( resource_group_name=resource_group_name, deployment_name=deployment_name, subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.check_existence.metadata['url'], + template_url=self.check_existence.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [204, 404]: @@ -1516,44 +1913,53 @@ async def check_existence( return cls(pipeline_response, None, {}) return 200 <= response.status_code <= 299 - check_existence.metadata = {'url': "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/Microsoft.Resources/deployments/{deploymentName}"} # type: ignore - + check_existence.metadata = {"url": "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/Microsoft.Resources/deployments/{deploymentName}"} # type: ignore async def _create_or_update_initial( - self, - resource_group_name: str, - deployment_name: str, - parameters: "_models.Deployment", - **kwargs: Any - ) -> "_models.DeploymentExtended": - cls = kwargs.pop('cls', None) # type: ClsType["_models.DeploymentExtended"] + self, resource_group_name: str, deployment_name: str, parameters: Union[_models.Deployment, IO], **kwargs: Any + ) -> _models.DeploymentExtended: error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) - api_version = kwargs.pop('api_version', "2019-05-01") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - _json = self._serialize.body(parameters, 'Deployment') + api_version = kwargs.pop("api_version", _params.pop("api-version", "2019-05-01")) # type: str + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.DeploymentExtended] - request = build_deployments_create_or_update_request_initial( + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(parameters, (IO, bytes)): + _content = parameters + else: + _json = self._serialize.body(parameters, "Deployment") + + request = build_deployments_create_or_update_request( resource_group_name=resource_group_name, deployment_name=deployment_name, subscription_id=self._config.subscription_id, api_version=api_version, content_type=content_type, json=_json, - template_url=self._create_or_update_initial.metadata['url'], + content=_content, + template_url=self._create_or_update_initial.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200, 201]: @@ -1561,38 +1967,42 @@ async def _create_or_update_initial( raise HttpResponseError(response=response, error_format=ARMErrorFormat) if response.status_code == 200: - deserialized = self._deserialize('DeploymentExtended', pipeline_response) + deserialized = self._deserialize("DeploymentExtended", pipeline_response) if response.status_code == 201: - deserialized = self._deserialize('DeploymentExtended', pipeline_response) + deserialized = self._deserialize("DeploymentExtended", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - _create_or_update_initial.metadata = {'url': "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/Microsoft.Resources/deployments/{deploymentName}"} # type: ignore + _create_or_update_initial.metadata = {"url": "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/Microsoft.Resources/deployments/{deploymentName}"} # type: ignore - - @distributed_trace_async + @overload async def begin_create_or_update( self, resource_group_name: str, deployment_name: str, - parameters: "_models.Deployment", + parameters: _models.Deployment, + *, + content_type: str = "application/json", **kwargs: Any - ) -> AsyncLROPoller["_models.DeploymentExtended"]: + ) -> AsyncLROPoller[_models.DeploymentExtended]: """Deploys resources to a resource group. You can provide the template and parameters directly in the request or link to JSON files. :param resource_group_name: The name of the resource group to deploy the resources to. The name - is case insensitive. The resource group must already exist. + is case insensitive. The resource group must already exist. Required. :type resource_group_name: str - :param deployment_name: The name of the deployment. + :param deployment_name: The name of the deployment. Required. :type deployment_name: str - :param parameters: Additional parameters supplied to the operation. + :param parameters: Additional parameters supplied to the operation. Required. :type parameters: ~azure.mgmt.resource.resources.v2019_05_01.models.Deployment + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str :keyword callable cls: A custom type or function that will be passed the direct response :keyword str continuation_token: A continuation token to restart a poller from a saved state. :keyword polling: By default, your polling method will be AsyncARMPolling. Pass in False for @@ -1605,115 +2015,189 @@ async def begin_create_or_update( cls(response) :rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.resource.resources.v2019_05_01.models.DeploymentExtended] - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - api_version = kwargs.pop('api_version', "2019-05-01") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] - polling = kwargs.pop('polling', True) # type: Union[bool, AsyncPollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType["_models.DeploymentExtended"] - lro_delay = kwargs.pop( - 'polling_interval', - self._config.polling_interval - ) - cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] + + @overload + async def begin_create_or_update( + self, + resource_group_name: str, + deployment_name: str, + parameters: IO, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> AsyncLROPoller[_models.DeploymentExtended]: + """Deploys resources to a resource group. + + You can provide the template and parameters directly in the request or link to JSON files. + + :param resource_group_name: The name of the resource group to deploy the resources to. The name + is case insensitive. The resource group must already exist. Required. + :type resource_group_name: str + :param deployment_name: The name of the deployment. Required. + :type deployment_name: str + :param parameters: Additional parameters supplied to the operation. Required. + :type parameters: IO + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be AsyncARMPolling. Pass in False for + this operation to not poll, or pass in your own initialized polling object for a personal + polling strategy. + :paramtype polling: bool or ~azure.core.polling.AsyncPollingMethod + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of AsyncLROPoller that returns either DeploymentExtended or the result of + cls(response) + :rtype: + ~azure.core.polling.AsyncLROPoller[~azure.mgmt.resource.resources.v2019_05_01.models.DeploymentExtended] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace_async + async def begin_create_or_update( + self, resource_group_name: str, deployment_name: str, parameters: Union[_models.Deployment, IO], **kwargs: Any + ) -> AsyncLROPoller[_models.DeploymentExtended]: + """Deploys resources to a resource group. + + You can provide the template and parameters directly in the request or link to JSON files. + + :param resource_group_name: The name of the resource group to deploy the resources to. The name + is case insensitive. The resource group must already exist. Required. + :type resource_group_name: str + :param deployment_name: The name of the deployment. Required. + :type deployment_name: str + :param parameters: Additional parameters supplied to the operation. Is either a model type or a + IO type. Required. + :type parameters: ~azure.mgmt.resource.resources.v2019_05_01.models.Deployment or IO + :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. + Default value is None. + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be AsyncARMPolling. Pass in False for + this operation to not poll, or pass in your own initialized polling object for a personal + polling strategy. + :paramtype polling: bool or ~azure.core.polling.AsyncPollingMethod + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of AsyncLROPoller that returns either DeploymentExtended or the result of + cls(response) + :rtype: + ~azure.core.polling.AsyncLROPoller[~azure.mgmt.resource.resources.v2019_05_01.models.DeploymentExtended] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _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", "2019-05-01")) # type: str + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.DeploymentExtended] + polling = kwargs.pop("polling", True) # type: Union[bool, AsyncPollingMethod] + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token = kwargs.pop("continuation_token", None) # type: Optional[str] if cont_token is None: - raw_result = await self._create_or_update_initial( + raw_result = await self._create_or_update_initial( # type: ignore resource_group_name=resource_group_name, deployment_name=deployment_name, parameters=parameters, api_version=api_version, content_type=content_type, - cls=lambda x,y,z: x, + cls=lambda x, y, z: x, + headers=_headers, + params=_params, **kwargs ) - kwargs.pop('error_map', None) + kwargs.pop("error_map", None) def get_long_running_output(pipeline_response): - response = pipeline_response.http_response - deserialized = self._deserialize('DeploymentExtended', pipeline_response) + deserialized = self._deserialize("DeploymentExtended", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - - if polling is True: polling_method = AsyncARMPolling(lro_delay, **kwargs) - elif polling is False: polling_method = AsyncNoPolling() - else: polling_method = polling + if polling is True: + polling_method = cast(AsyncPollingMethod, AsyncARMPolling(lro_delay, **kwargs)) # type: AsyncPollingMethod + elif polling is False: + polling_method = cast(AsyncPollingMethod, AsyncNoPolling()) + else: + polling_method = polling if cont_token: return AsyncLROPoller.from_continuation_token( polling_method=polling_method, continuation_token=cont_token, client=self._client, - deserialization_callback=get_long_running_output + deserialization_callback=get_long_running_output, ) return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) - begin_create_or_update.metadata = {'url': "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/Microsoft.Resources/deployments/{deploymentName}"} # type: ignore + begin_create_or_update.metadata = {"url": "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/Microsoft.Resources/deployments/{deploymentName}"} # type: ignore @distributed_trace_async - async def get( - self, - resource_group_name: str, - deployment_name: str, - **kwargs: Any - ) -> "_models.DeploymentExtended": + async def get(self, resource_group_name: str, deployment_name: str, **kwargs: Any) -> _models.DeploymentExtended: """Gets a deployment. :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. :type resource_group_name: str - :param deployment_name: The name of the deployment. + :param deployment_name: The name of the deployment. Required. :type deployment_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: DeploymentExtended, or the result of cls(response) + :return: DeploymentExtended or the result of cls(response) :rtype: ~azure.mgmt.resource.resources.v2019_05_01.models.DeploymentExtended - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.DeploymentExtended"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) - api_version = kwargs.pop('api_version', "2019-05-01") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2019-05-01")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[_models.DeploymentExtended] - request = build_deployments_get_request( resource_group_name=resource_group_name, deployment_name=deployment_name, subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.get.metadata['url'], + template_url=self.get.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) - deserialized = self._deserialize('DeploymentExtended', pipeline_response) + deserialized = self._deserialize("DeploymentExtended", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - get.metadata = {'url': "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/Microsoft.Resources/deployments/{deploymentName}"} # type: ignore - + get.metadata = {"url": "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/Microsoft.Resources/deployments/{deploymentName}"} # type: ignore @distributed_trace_async async def cancel( # pylint: disable=inconsistent-return-statements - self, - resource_group_name: str, - deployment_name: str, - **kwargs: Any + self, resource_group_name: str, deployment_name: str, **kwargs: Any ) -> None: """Cancels a currently running template deployment. @@ -1723,38 +2207,45 @@ async def cancel( # pylint: disable=inconsistent-return-statements partially deployed. :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. :type resource_group_name: str - :param deployment_name: The name of the deployment. + :param deployment_name: The name of the deployment. Required. :type deployment_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: None, or the result of cls(response) + :return: None or the result of cls(response) :rtype: None - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType[None] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + 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', "2019-05-01") # type: str + api_version = kwargs.pop("api_version", _params.pop("api-version", "2019-05-01")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[None] - request = build_deployments_cancel_request( resource_group_name=resource_group_name, deployment_name=deployment_name, subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.cancel.metadata['url'], + template_url=self.cancel.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [204]: @@ -1764,42 +2255,110 @@ async def cancel( # pylint: disable=inconsistent-return-statements if cls: return cls(pipeline_response, None, {}) - cancel.metadata = {'url': "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/Microsoft.Resources/deployments/{deploymentName}/cancel"} # type: ignore - + cancel.metadata = {"url": "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/Microsoft.Resources/deployments/{deploymentName}/cancel"} # type: ignore - @distributed_trace_async + @overload async def validate( self, resource_group_name: str, deployment_name: str, - parameters: "_models.Deployment", + parameters: _models.Deployment, + *, + content_type: str = "application/json", **kwargs: Any - ) -> "_models.DeploymentValidateResult": + ) -> _models.DeploymentValidateResult: """Validates whether the specified template is syntactically correct and will be accepted by Azure Resource Manager.. :param resource_group_name: The name of the resource group the template will be deployed to. - The name is case insensitive. + The name is case insensitive. Required. :type resource_group_name: str - :param deployment_name: The name of the deployment. + :param deployment_name: The name of the deployment. Required. :type deployment_name: str - :param parameters: Parameters to validate. + :param parameters: Parameters to validate. Required. :type parameters: ~azure.mgmt.resource.resources.v2019_05_01.models.Deployment + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: DeploymentValidateResult or the result of cls(response) + :rtype: ~azure.mgmt.resource.resources.v2019_05_01.models.DeploymentValidateResult + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + async def validate( + self, + resource_group_name: str, + deployment_name: str, + parameters: IO, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.DeploymentValidateResult: + """Validates whether the specified template is syntactically correct and will be accepted by Azure + Resource Manager.. + + :param resource_group_name: The name of the resource group the template will be deployed to. + The name is case insensitive. Required. + :type resource_group_name: str + :param deployment_name: The name of the deployment. Required. + :type deployment_name: str + :param parameters: Parameters to validate. Required. + :type parameters: IO + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: DeploymentValidateResult, or the result of cls(response) + :return: DeploymentValidateResult or the result of cls(response) :rtype: ~azure.mgmt.resource.resources.v2019_05_01.models.DeploymentValidateResult - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace_async + async def validate( + self, resource_group_name: str, deployment_name: str, parameters: Union[_models.Deployment, IO], **kwargs: Any + ) -> _models.DeploymentValidateResult: + """Validates whether the specified template is syntactically correct and will be accepted by Azure + Resource Manager.. + + :param resource_group_name: The name of the resource group the template will be deployed to. + The name is case insensitive. Required. + :type resource_group_name: str + :param deployment_name: The name of the deployment. Required. + :type deployment_name: str + :param parameters: Parameters to validate. Is either a model type or a IO type. Required. + :type parameters: ~azure.mgmt.resource.resources.v2019_05_01.models.Deployment or IO + :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. + Default value is None. + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: DeploymentValidateResult or the result of cls(response) + :rtype: ~azure.mgmt.resource.resources.v2019_05_01.models.DeploymentValidateResult + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.DeploymentValidateResult"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', "2019-05-01") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + api_version = kwargs.pop("api_version", _params.pop("api-version", "2019-05-01")) # type: str + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.DeploymentValidateResult] - _json = self._serialize.body(parameters, 'Deployment') + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(parameters, (IO, bytes)): + _content = parameters + else: + _json = self._serialize.body(parameters, "Deployment") request = build_deployments_validate_request( resource_group_name=resource_group_name, @@ -1808,16 +2367,18 @@ async def validate( api_version=api_version, content_type=content_type, json=_json, - template_url=self.validate.metadata['url'], + content=_content, + template_url=self.validate.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200, 400]: @@ -1825,89 +2386,87 @@ async def validate( raise HttpResponseError(response=response, error_format=ARMErrorFormat) if response.status_code == 200: - deserialized = self._deserialize('DeploymentValidateResult', pipeline_response) + deserialized = self._deserialize("DeploymentValidateResult", pipeline_response) if response.status_code == 400: - deserialized = self._deserialize('DeploymentValidateResult', pipeline_response) + deserialized = self._deserialize("DeploymentValidateResult", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - validate.metadata = {'url': "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/Microsoft.Resources/deployments/{deploymentName}/validate"} # type: ignore - + validate.metadata = {"url": "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/Microsoft.Resources/deployments/{deploymentName}/validate"} # type: ignore @distributed_trace_async async def export_template( - self, - resource_group_name: str, - deployment_name: str, - **kwargs: Any - ) -> "_models.DeploymentExportResult": + self, resource_group_name: str, deployment_name: str, **kwargs: Any + ) -> _models.DeploymentExportResult: """Exports the template used for specified deployment. :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. :type resource_group_name: str - :param deployment_name: The name of the deployment. + :param deployment_name: The name of the deployment. Required. :type deployment_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: DeploymentExportResult, or the result of cls(response) + :return: DeploymentExportResult or the result of cls(response) :rtype: ~azure.mgmt.resource.resources.v2019_05_01.models.DeploymentExportResult - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.DeploymentExportResult"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) - api_version = kwargs.pop('api_version', "2019-05-01") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2019-05-01")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[_models.DeploymentExportResult] - request = build_deployments_export_template_request( resource_group_name=resource_group_name, deployment_name=deployment_name, subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.export_template.metadata['url'], + template_url=self.export_template.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) - deserialized = self._deserialize('DeploymentExportResult', pipeline_response) + deserialized = self._deserialize("DeploymentExportResult", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - export_template.metadata = {'url': "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/Microsoft.Resources/deployments/{deploymentName}/exportTemplate"} # type: ignore - + export_template.metadata = {"url": "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/Microsoft.Resources/deployments/{deploymentName}/exportTemplate"} # type: ignore @distributed_trace def list_by_resource_group( - self, - resource_group_name: str, - filter: Optional[str] = None, - top: Optional[int] = None, - **kwargs: Any - ) -> AsyncIterable["_models.DeploymentListResult"]: + self, resource_group_name: str, filter: Optional[str] = None, top: Optional[int] = None, **kwargs: Any + ) -> AsyncIterable["_models.DeploymentExtended"]: """Get all the deployments for a resource group. :param resource_group_name: The name of the resource group with the deployments to get. The - name is case insensitive. + name is case insensitive. Required. :type resource_group_name: str :param filter: The filter to apply on the operation. For example, you can use $filter=provisioningState eq '{state}'. Default value is None. @@ -1916,42 +2475,49 @@ def list_by_resource_group( value is None. :type top: int :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either DeploymentListResult or the result of - cls(response) + :return: An iterator like instance of either DeploymentExtended or the result of cls(response) :rtype: - ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.resource.resources.v2019_05_01.models.DeploymentListResult] - :raises: ~azure.core.exceptions.HttpResponseError + ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.resource.resources.v2019_05_01.models.DeploymentExtended] + :raises ~azure.core.exceptions.HttpResponseError: """ - api_version = kwargs.pop('api_version', "2019-05-01") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2019-05-01")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[_models.DeploymentListResult] - cls = kwargs.pop('cls', None) # type: ClsType["_models.DeploymentListResult"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) + def prepare_request(next_link=None): if not next_link: - + request = build_deployments_list_by_resource_group_request( resource_group_name=resource_group_name, subscription_id=self._config.subscription_id, - api_version=api_version, filter=filter, top=top, - template_url=self.list_by_resource_group.metadata['url'], + 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.url = self._client.format_url(request.url) # type: ignore else: - - request = build_deployments_list_by_resource_group_request( - resource_group_name=resource_group_name, - subscription_id=self._config.subscription_id, - template_url=next_link, - ) + # make call to next link with the client's api-version + _parsed_next_link = urlparse(next_link) + _next_request_params = case_insensitive_dict(parse_qs(_parsed_next_link.query)) + _next_request_params["api-version"] = self._config.api_version + request = HttpRequest("GET", urljoin(next_link, _parsed_next_link.path), params=_next_request_params) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore request.method = "GET" return request @@ -1965,10 +2531,8 @@ async def extract_data(pipeline_response): async def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) response = pipeline_response.http_response @@ -1978,204 +2542,204 @@ async def get_next(next_link=None): return pipeline_response + return AsyncItemPaged(get_next, extract_data) - return AsyncItemPaged( - get_next, extract_data - ) - list_by_resource_group.metadata = {'url': "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/Microsoft.Resources/deployments/"} # type: ignore + list_by_resource_group.metadata = {"url": "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/Microsoft.Resources/deployments/"} # type: ignore @distributed_trace_async - async def calculate_template_hash( - self, - template: Any, - **kwargs: Any - ) -> "_models.TemplateHashResult": + async def calculate_template_hash(self, template: JSON, **kwargs: Any) -> _models.TemplateHashResult: """Calculate the hash of the given template. - :param template: The template provided to calculate hash. - :type template: any + :param template: The template provided to calculate hash. Required. + :type template: JSON :keyword callable cls: A custom type or function that will be passed the direct response - :return: TemplateHashResult, or the result of cls(response) + :return: TemplateHashResult or the result of cls(response) :rtype: ~azure.mgmt.resource.resources.v2019_05_01.models.TemplateHashResult - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.TemplateHashResult"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) - api_version = kwargs.pop('api_version', "2019-05-01") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - _json = self._serialize.body(template, 'object') + api_version = kwargs.pop("api_version", _params.pop("api-version", "2019-05-01")) # type: str + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", "application/json")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[_models.TemplateHashResult] + + _json = self._serialize.body(template, "object") request = build_deployments_calculate_template_hash_request( api_version=api_version, content_type=content_type, json=_json, - template_url=self.calculate_template_hash.metadata['url'], + template_url=self.calculate_template_hash.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) - deserialized = self._deserialize('TemplateHashResult', pipeline_response) + deserialized = self._deserialize("TemplateHashResult", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - calculate_template_hash.metadata = {'url': "/providers/Microsoft.Resources/calculateTemplateHash"} # type: ignore + calculate_template_hash.metadata = {"url": "/providers/Microsoft.Resources/calculateTemplateHash"} # type: ignore -class ProvidersOperations: - """ProvidersOperations async operations. - You should not instantiate this class directly. Instead, you should create a Client instance that - instantiates it for you and attaches it as an attribute. +class ProvidersOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. - :ivar models: Alias to model classes used in this operation group. - :type models: ~azure.mgmt.resource.resources.v2019_05_01.models - :param client: Client for service requests. - :param config: Configuration of service client. - :param serializer: An object model serializer. - :param deserializer: An object model deserializer. + Instead, you should access the following operations through + :class:`~azure.mgmt.resource.resources.v2019_05_01.aio.ResourceManagementClient`'s + :attr:`providers` attribute. """ models = _models - def __init__(self, client, config, serializer, deserializer) -> None: - self._client = client - self._serialize = serializer - self._deserialize = deserializer - self._config = config + def __init__(self, *args, **kwargs) -> None: + input_args = list(args) + self._client = input_args.pop(0) if input_args else kwargs.pop("client") + self._config = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") @distributed_trace_async - async def unregister( - self, - resource_provider_namespace: str, - **kwargs: Any - ) -> "_models.Provider": + async def unregister(self, resource_provider_namespace: str, **kwargs: Any) -> _models.Provider: """Unregisters a subscription from a resource provider. :param resource_provider_namespace: The namespace of the resource provider to unregister. + Required. :type resource_provider_namespace: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: Provider, or the result of cls(response) + :return: Provider or the result of cls(response) :rtype: ~azure.mgmt.resource.resources.v2019_05_01.models.Provider - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.Provider"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) - api_version = kwargs.pop('api_version', "2019-05-01") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2019-05-01")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[_models.Provider] - request = build_providers_unregister_request( resource_provider_namespace=resource_provider_namespace, subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.unregister.metadata['url'], + template_url=self.unregister.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) - deserialized = self._deserialize('Provider', pipeline_response) + deserialized = self._deserialize("Provider", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - unregister.metadata = {'url': "/subscriptions/{subscriptionId}/providers/{resourceProviderNamespace}/unregister"} # type: ignore - + unregister.metadata = {"url": "/subscriptions/{subscriptionId}/providers/{resourceProviderNamespace}/unregister"} # type: ignore @distributed_trace_async - async def register( - self, - resource_provider_namespace: str, - **kwargs: Any - ) -> "_models.Provider": + async def register(self, resource_provider_namespace: str, **kwargs: Any) -> _models.Provider: """Registers a subscription with a resource provider. :param resource_provider_namespace: The namespace of the resource provider to register. + Required. :type resource_provider_namespace: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: Provider, or the result of cls(response) + :return: Provider or the result of cls(response) :rtype: ~azure.mgmt.resource.resources.v2019_05_01.models.Provider - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.Provider"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) - api_version = kwargs.pop('api_version', "2019-05-01") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2019-05-01")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[_models.Provider] - request = build_providers_register_request( resource_provider_namespace=resource_provider_namespace, subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.register.metadata['url'], + template_url=self.register.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) - deserialized = self._deserialize('Provider', pipeline_response) + deserialized = self._deserialize("Provider", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - register.metadata = {'url': "/subscriptions/{subscriptionId}/providers/{resourceProviderNamespace}/register"} # type: ignore - + register.metadata = {"url": "/subscriptions/{subscriptionId}/providers/{resourceProviderNamespace}/register"} # type: ignore @distributed_trace def list( - self, - top: Optional[int] = None, - expand: Optional[str] = None, - **kwargs: Any - ) -> AsyncIterable["_models.ProviderListResult"]: + self, top: Optional[int] = None, expand: Optional[str] = None, **kwargs: Any + ) -> AsyncIterable["_models.Provider"]: """Gets all resource providers for a subscription. :param top: The number of results to return. If null is passed returns all deployments. Default @@ -2186,39 +2750,48 @@ def list( response, use $expand=resourceTypes/aliases. Default value is None. :type expand: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either ProviderListResult or the result of cls(response) + :return: An iterator like instance of either Provider or the result of cls(response) :rtype: - ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.resource.resources.v2019_05_01.models.ProviderListResult] - :raises: ~azure.core.exceptions.HttpResponseError + ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.resource.resources.v2019_05_01.models.Provider] + :raises ~azure.core.exceptions.HttpResponseError: """ - api_version = kwargs.pop('api_version', "2019-05-01") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2019-05-01")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[_models.ProviderListResult] - cls = kwargs.pop('cls', None) # type: ClsType["_models.ProviderListResult"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) + def prepare_request(next_link=None): if not next_link: - + request = build_providers_list_request( subscription_id=self._config.subscription_id, - api_version=api_version, top=top, expand=expand, - template_url=self.list.metadata['url'], + 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.url = self._client.format_url(request.url) # type: ignore else: - - request = build_providers_list_request( - subscription_id=self._config.subscription_id, - template_url=next_link, - ) + # make call to next link with the client's api-version + _parsed_next_link = urlparse(next_link) + _next_request_params = case_insensitive_dict(parse_qs(_parsed_next_link.query)) + _next_request_params["api-version"] = self._config.api_version + request = HttpRequest("GET", urljoin(next_link, _parsed_next_link.path), params=_next_request_params) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore request.method = "GET" return request @@ -2232,10 +2805,8 @@ async def extract_data(pipeline_response): async def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) response = pipeline_response.http_response @@ -2245,91 +2816,90 @@ async def get_next(next_link=None): return pipeline_response + return AsyncItemPaged(get_next, extract_data) - return AsyncItemPaged( - get_next, extract_data - ) - list.metadata = {'url': "/subscriptions/{subscriptionId}/providers"} # type: ignore + list.metadata = {"url": "/subscriptions/{subscriptionId}/providers"} # type: ignore @distributed_trace_async async def get( - self, - resource_provider_namespace: str, - expand: Optional[str] = None, - **kwargs: Any - ) -> "_models.Provider": + self, resource_provider_namespace: str, expand: Optional[str] = None, **kwargs: Any + ) -> _models.Provider: """Gets the specified resource provider. - :param resource_provider_namespace: The namespace of the resource provider. + :param resource_provider_namespace: The namespace of the resource provider. Required. :type resource_provider_namespace: str :param expand: The $expand query parameter. For example, to include property aliases in response, use $expand=resourceTypes/aliases. Default value is None. :type expand: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: Provider, or the result of cls(response) + :return: Provider or the result of cls(response) :rtype: ~azure.mgmt.resource.resources.v2019_05_01.models.Provider - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.Provider"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + 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', "2019-05-01") # type: str + api_version = kwargs.pop("api_version", _params.pop("api-version", "2019-05-01")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[_models.Provider] - request = build_providers_get_request( resource_provider_namespace=resource_provider_namespace, subscription_id=self._config.subscription_id, - api_version=api_version, expand=expand, - template_url=self.get.metadata['url'], + api_version=api_version, + template_url=self.get.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) - deserialized = self._deserialize('Provider', pipeline_response) + deserialized = self._deserialize("Provider", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - get.metadata = {'url': "/subscriptions/{subscriptionId}/providers/{resourceProviderNamespace}"} # type: ignore + get.metadata = {"url": "/subscriptions/{subscriptionId}/providers/{resourceProviderNamespace}"} # type: ignore -class ResourcesOperations: # pylint: disable=too-many-public-methods - """ResourcesOperations async operations. - You should not instantiate this class directly. Instead, you should create a Client instance that - instantiates it for you and attaches it as an attribute. +class ResourcesOperations: # pylint: disable=too-many-public-methods + """ + .. warning:: + **DO NOT** instantiate this class directly. - :ivar models: Alias to model classes used in this operation group. - :type models: ~azure.mgmt.resource.resources.v2019_05_01.models - :param client: Client for service requests. - :param config: Configuration of service client. - :param serializer: An object model serializer. - :param deserializer: An object model deserializer. + Instead, you should access the following operations through + :class:`~azure.mgmt.resource.resources.v2019_05_01.aio.ResourceManagementClient`'s + :attr:`resources` attribute. """ models = _models - def __init__(self, client, config, serializer, deserializer) -> None: - self._client = client - self._serialize = serializer - self._deserialize = deserializer - self._config = config + def __init__(self, *args, **kwargs) -> None: + input_args = list(args) + self._client = input_args.pop(0) if input_args else kwargs.pop("client") + self._config = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") @distributed_trace def list_by_resource_group( @@ -2339,10 +2909,10 @@ def list_by_resource_group( expand: Optional[str] = None, top: Optional[int] = None, **kwargs: Any - ) -> AsyncIterable["_models.ResourceListResult"]: + ) -> AsyncIterable["_models.GenericResourceExpanded"]: """Get all the resources for a resource group. - :param resource_group_name: The resource group with the resources to get. + :param resource_group_name: The resource group with the resources to get. Required. :type resource_group_name: str :param filter: The filter to apply on the operation.:code:`
`:code:`
`The properties you can use for eq (equals) or ne (not equals) are: location, resourceType, name, resourceGroup, @@ -2367,42 +2937,51 @@ def list_by_resource_group( value is None. :type top: int :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either ResourceListResult or the result of cls(response) + :return: An iterator like instance of either GenericResourceExpanded or the result of + cls(response) :rtype: - ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.resource.resources.v2019_05_01.models.ResourceListResult] - :raises: ~azure.core.exceptions.HttpResponseError + ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.resource.resources.v2019_05_01.models.GenericResourceExpanded] + :raises ~azure.core.exceptions.HttpResponseError: """ - api_version = kwargs.pop('api_version', "2019-05-01") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2019-05-01")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[_models.ResourceListResult] - cls = kwargs.pop('cls', None) # type: ClsType["_models.ResourceListResult"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) + def prepare_request(next_link=None): if not next_link: - + request = build_resources_list_by_resource_group_request( resource_group_name=resource_group_name, subscription_id=self._config.subscription_id, - api_version=api_version, filter=filter, expand=expand, top=top, - template_url=self.list_by_resource_group.metadata['url'], + 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.url = self._client.format_url(request.url) # type: ignore else: - - request = build_resources_list_by_resource_group_request( - resource_group_name=resource_group_name, - subscription_id=self._config.subscription_id, - template_url=next_link, - ) + # make call to next link with the client's api-version + _parsed_next_link = urlparse(next_link) + _next_request_params = case_insensitive_dict(parse_qs(_parsed_next_link.query)) + _next_request_params["api-version"] = self._config.api_version + request = HttpRequest("GET", urljoin(next_link, _parsed_next_link.path), params=_next_request_params) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore request.method = "GET" return request @@ -2416,10 +2995,8 @@ async def extract_data(pipeline_response): async def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) response = pipeline_response.http_response @@ -2429,45 +3006,54 @@ async def get_next(next_link=None): return pipeline_response + return AsyncItemPaged(get_next, extract_data) - return AsyncItemPaged( - get_next, extract_data - ) - list_by_resource_group.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/resources"} # type: ignore + list_by_resource_group.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/resources"} # type: ignore async def _move_resources_initial( # pylint: disable=inconsistent-return-statements - self, - source_resource_group_name: str, - parameters: "_models.ResourcesMoveInfo", - **kwargs: Any + self, source_resource_group_name: str, parameters: Union[_models.ResourcesMoveInfo, IO], **kwargs: Any ) -> None: - cls = kwargs.pop('cls', None) # type: ClsType[None] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', "2019-05-01") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + api_version = kwargs.pop("api_version", _params.pop("api-version", "2019-05-01")) # type: str + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[None] - _json = self._serialize.body(parameters, 'ResourcesMoveInfo') + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(parameters, (IO, bytes)): + _content = parameters + else: + _json = self._serialize.body(parameters, "ResourcesMoveInfo") - request = build_resources_move_resources_request_initial( + request = build_resources_move_resources_request( source_resource_group_name=source_resource_group_name, subscription_id=self._config.subscription_id, api_version=api_version, content_type=content_type, json=_json, - template_url=self._move_resources_initial.metadata['url'], + content=_content, + template_url=self._move_resources_initial.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [202, 204]: @@ -2477,14 +3063,15 @@ async def _move_resources_initial( # pylint: disable=inconsistent-return-statem if cls: return cls(pipeline_response, None, {}) - _move_resources_initial.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{sourceResourceGroupName}/moveResources"} # type: ignore - + _move_resources_initial.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{sourceResourceGroupName}/moveResources"} # type: ignore - @distributed_trace_async - async def begin_move_resources( # pylint: disable=inconsistent-return-statements + @overload + async def begin_move_resources( self, source_resource_group_name: str, - parameters: "_models.ResourcesMoveInfo", + parameters: _models.ResourcesMoveInfo, + *, + content_type: str = "application/json", **kwargs: Any ) -> AsyncLROPoller[None]: """Moves resources from one resource group to another resource group. @@ -2495,10 +3082,13 @@ async def begin_move_resources( # pylint: disable=inconsistent-return-statement the groups until the move completes. :param source_resource_group_name: The name of the resource group containing the resources to - move. + move. Required. :type source_resource_group_name: str - :param parameters: Parameters for moving resources. + :param parameters: Parameters for moving resources. Required. :type parameters: ~azure.mgmt.resource.resources.v2019_05_01.models.ResourcesMoveInfo + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str :keyword callable cls: A custom type or function that will be passed the direct response :keyword str continuation_token: A continuation token to restart a poller from a saved state. :keyword polling: By default, your polling method will be AsyncARMPolling. Pass in False for @@ -2509,80 +3099,160 @@ async def begin_move_resources( # pylint: disable=inconsistent-return-statement Retry-After header is present. :return: An instance of AsyncLROPoller that returns either None or the result of cls(response) :rtype: ~azure.core.polling.AsyncLROPoller[None] - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - api_version = kwargs.pop('api_version', "2019-05-01") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] - polling = kwargs.pop('polling', True) # type: Union[bool, AsyncPollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType[None] - lro_delay = kwargs.pop( - 'polling_interval', - self._config.polling_interval - ) - cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] + + @overload + async def begin_move_resources( + self, source_resource_group_name: str, parameters: IO, *, content_type: str = "application/json", **kwargs: Any + ) -> AsyncLROPoller[None]: + """Moves resources from one resource group to another resource group. + + The resources to move must be in the same source resource group. The target resource group may + be in a different subscription. When moving resources, both the source group and the target + group are locked for the duration of the operation. Write and delete operations are blocked on + the groups until the move completes. + + :param source_resource_group_name: The name of the resource group containing the resources to + move. Required. + :type source_resource_group_name: str + :param parameters: Parameters for moving resources. Required. + :type parameters: IO + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be AsyncARMPolling. Pass in False for + this operation to not poll, or pass in your own initialized polling object for a personal + polling strategy. + :paramtype polling: bool or ~azure.core.polling.AsyncPollingMethod + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of AsyncLROPoller that returns either None or the result of cls(response) + :rtype: ~azure.core.polling.AsyncLROPoller[None] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace_async + async def begin_move_resources( + self, source_resource_group_name: str, parameters: Union[_models.ResourcesMoveInfo, IO], **kwargs: Any + ) -> AsyncLROPoller[None]: + """Moves resources from one resource group to another resource group. + + The resources to move must be in the same source resource group. The target resource group may + be in a different subscription. When moving resources, both the source group and the target + group are locked for the duration of the operation. Write and delete operations are blocked on + the groups until the move completes. + + :param source_resource_group_name: The name of the resource group containing the resources to + move. Required. + :type source_resource_group_name: str + :param parameters: Parameters for moving resources. Is either a model type or a IO type. + Required. + :type parameters: ~azure.mgmt.resource.resources.v2019_05_01.models.ResourcesMoveInfo or IO + :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. + Default value is None. + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be AsyncARMPolling. Pass in False for + this operation to not poll, or pass in your own initialized polling object for a personal + polling strategy. + :paramtype polling: bool or ~azure.core.polling.AsyncPollingMethod + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of AsyncLROPoller that returns either None or the result of cls(response) + :rtype: ~azure.core.polling.AsyncLROPoller[None] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _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", "2019-05-01")) # type: str + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[None] + polling = kwargs.pop("polling", True) # type: Union[bool, AsyncPollingMethod] + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token = kwargs.pop("continuation_token", None) # type: Optional[str] if cont_token is None: - raw_result = await self._move_resources_initial( + raw_result = await self._move_resources_initial( # type: ignore source_resource_group_name=source_resource_group_name, parameters=parameters, api_version=api_version, content_type=content_type, - cls=lambda x,y,z: x, + cls=lambda x, y, z: x, + headers=_headers, + params=_params, **kwargs ) - kwargs.pop('error_map', None) + kwargs.pop("error_map", None) - def get_long_running_output(pipeline_response): + def get_long_running_output(pipeline_response): # pylint: disable=inconsistent-return-statements if cls: return cls(pipeline_response, None, {}) - - if polling is True: polling_method = AsyncARMPolling(lro_delay, **kwargs) - elif polling is False: polling_method = AsyncNoPolling() - else: polling_method = polling + if polling is True: + polling_method = cast(AsyncPollingMethod, AsyncARMPolling(lro_delay, **kwargs)) # type: AsyncPollingMethod + elif polling is False: + polling_method = cast(AsyncPollingMethod, AsyncNoPolling()) + else: + polling_method = polling if cont_token: return AsyncLROPoller.from_continuation_token( polling_method=polling_method, continuation_token=cont_token, client=self._client, - deserialization_callback=get_long_running_output + deserialization_callback=get_long_running_output, ) return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) - begin_move_resources.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{sourceResourceGroupName}/moveResources"} # type: ignore + begin_move_resources.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{sourceResourceGroupName}/moveResources"} # type: ignore async def _validate_move_resources_initial( # pylint: disable=inconsistent-return-statements - self, - source_resource_group_name: str, - parameters: "_models.ResourcesMoveInfo", - **kwargs: Any + self, source_resource_group_name: str, parameters: Union[_models.ResourcesMoveInfo, IO], **kwargs: Any ) -> None: - cls = kwargs.pop('cls', None) # type: ClsType[None] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', "2019-05-01") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + api_version = kwargs.pop("api_version", _params.pop("api-version", "2019-05-01")) # type: str + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[None] - _json = self._serialize.body(parameters, 'ResourcesMoveInfo') + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(parameters, (IO, bytes)): + _content = parameters + else: + _json = self._serialize.body(parameters, "ResourcesMoveInfo") - request = build_resources_validate_move_resources_request_initial( + request = build_resources_validate_move_resources_request( source_resource_group_name=source_resource_group_name, subscription_id=self._config.subscription_id, api_version=api_version, content_type=content_type, json=_json, - template_url=self._validate_move_resources_initial.metadata['url'], + content=_content, + template_url=self._validate_move_resources_initial.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [202, 204, 409]: @@ -2592,14 +3262,15 @@ async def _validate_move_resources_initial( # pylint: disable=inconsistent-retu if cls: return cls(pipeline_response, None, {}) - _validate_move_resources_initial.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{sourceResourceGroupName}/validateMoveResources"} # type: ignore - + _validate_move_resources_initial.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{sourceResourceGroupName}/validateMoveResources"} # type: ignore - @distributed_trace_async - async def begin_validate_move_resources( # pylint: disable=inconsistent-return-statements + @overload + async def begin_validate_move_resources( self, source_resource_group_name: str, - parameters: "_models.ResourcesMoveInfo", + parameters: _models.ResourcesMoveInfo, + *, + content_type: str = "application/json", **kwargs: Any ) -> AsyncLROPoller[None]: """Validates whether resources can be moved from one resource group to another resource group. @@ -2612,10 +3283,13 @@ async def begin_validate_move_resources( # pylint: disable=inconsistent-return- operation. :param source_resource_group_name: The name of the resource group containing the resources to - validate for move. + validate for move. Required. :type source_resource_group_name: str - :param parameters: Parameters for moving resources. + :param parameters: Parameters for moving resources. Required. :type parameters: ~azure.mgmt.resource.resources.v2019_05_01.models.ResourcesMoveInfo + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str :keyword callable cls: A custom type or function that will be passed the direct response :keyword str continuation_token: A continuation token to restart a poller from a saved state. :keyword polling: By default, your polling method will be AsyncARMPolling. Pass in False for @@ -2626,55 +3300,124 @@ async def begin_validate_move_resources( # pylint: disable=inconsistent-return- Retry-After header is present. :return: An instance of AsyncLROPoller that returns either None or the result of cls(response) :rtype: ~azure.core.polling.AsyncLROPoller[None] - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - api_version = kwargs.pop('api_version', "2019-05-01") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] - polling = kwargs.pop('polling', True) # type: Union[bool, AsyncPollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType[None] - lro_delay = kwargs.pop( - 'polling_interval', - self._config.polling_interval - ) - cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] + + @overload + async def begin_validate_move_resources( + self, source_resource_group_name: str, parameters: IO, *, content_type: str = "application/json", **kwargs: Any + ) -> AsyncLROPoller[None]: + """Validates whether resources can be moved from one resource group to another resource group. + + This operation checks whether the specified resources can be moved to the target. The resources + to move must be in the same source resource group. The target resource group may be in a + different subscription. If validation succeeds, it returns HTTP response code 204 (no content). + If validation fails, it returns HTTP response code 409 (Conflict) with an error message. + Retrieve the URL in the Location header value to check the result of the long-running + operation. + + :param source_resource_group_name: The name of the resource group containing the resources to + validate for move. Required. + :type source_resource_group_name: str + :param parameters: Parameters for moving resources. Required. + :type parameters: IO + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be AsyncARMPolling. Pass in False for + this operation to not poll, or pass in your own initialized polling object for a personal + polling strategy. + :paramtype polling: bool or ~azure.core.polling.AsyncPollingMethod + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of AsyncLROPoller that returns either None or the result of cls(response) + :rtype: ~azure.core.polling.AsyncLROPoller[None] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace_async + async def begin_validate_move_resources( + self, source_resource_group_name: str, parameters: Union[_models.ResourcesMoveInfo, IO], **kwargs: Any + ) -> AsyncLROPoller[None]: + """Validates whether resources can be moved from one resource group to another resource group. + + This operation checks whether the specified resources can be moved to the target. The resources + to move must be in the same source resource group. The target resource group may be in a + different subscription. If validation succeeds, it returns HTTP response code 204 (no content). + If validation fails, it returns HTTP response code 409 (Conflict) with an error message. + Retrieve the URL in the Location header value to check the result of the long-running + operation. + + :param source_resource_group_name: The name of the resource group containing the resources to + validate for move. Required. + :type source_resource_group_name: str + :param parameters: Parameters for moving resources. Is either a model type or a IO type. + Required. + :type parameters: ~azure.mgmt.resource.resources.v2019_05_01.models.ResourcesMoveInfo or IO + :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. + Default value is None. + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be AsyncARMPolling. Pass in False for + this operation to not poll, or pass in your own initialized polling object for a personal + polling strategy. + :paramtype polling: bool or ~azure.core.polling.AsyncPollingMethod + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of AsyncLROPoller that returns either None or the result of cls(response) + :rtype: ~azure.core.polling.AsyncLROPoller[None] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _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", "2019-05-01")) # type: str + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[None] + polling = kwargs.pop("polling", True) # type: Union[bool, AsyncPollingMethod] + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token = kwargs.pop("continuation_token", None) # type: Optional[str] if cont_token is None: - raw_result = await self._validate_move_resources_initial( + raw_result = await self._validate_move_resources_initial( # type: ignore source_resource_group_name=source_resource_group_name, parameters=parameters, api_version=api_version, content_type=content_type, - cls=lambda x,y,z: x, + cls=lambda x, y, z: x, + headers=_headers, + params=_params, **kwargs ) - kwargs.pop('error_map', None) + kwargs.pop("error_map", None) - def get_long_running_output(pipeline_response): + def get_long_running_output(pipeline_response): # pylint: disable=inconsistent-return-statements if cls: return cls(pipeline_response, None, {}) - - if polling is True: polling_method = AsyncARMPolling(lro_delay, **kwargs) - elif polling is False: polling_method = AsyncNoPolling() - else: polling_method = polling + if polling is True: + polling_method = cast(AsyncPollingMethod, AsyncARMPolling(lro_delay, **kwargs)) # type: AsyncPollingMethod + elif polling is False: + polling_method = cast(AsyncPollingMethod, AsyncNoPolling()) + else: + polling_method = polling if cont_token: return AsyncLROPoller.from_continuation_token( polling_method=polling_method, continuation_token=cont_token, client=self._client, - deserialization_callback=get_long_running_output + deserialization_callback=get_long_running_output, ) return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) - begin_validate_move_resources.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{sourceResourceGroupName}/validateMoveResources"} # type: ignore + begin_validate_move_resources.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{sourceResourceGroupName}/validateMoveResources"} # type: ignore @distributed_trace def list( - self, - filter: Optional[str] = None, - expand: Optional[str] = None, - top: Optional[int] = None, - **kwargs: Any - ) -> AsyncIterable["_models.ResourceListResult"]: + self, filter: Optional[str] = None, expand: Optional[str] = None, top: Optional[int] = None, **kwargs: Any + ) -> AsyncIterable["_models.GenericResourceExpanded"]: """Get all the resources in a subscription. :param filter: The filter to apply on the operation.:code:`
`:code:`
`The properties you @@ -2700,40 +3443,50 @@ def list( value is None. :type top: int :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either ResourceListResult or the result of cls(response) + :return: An iterator like instance of either GenericResourceExpanded or the result of + cls(response) :rtype: - ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.resource.resources.v2019_05_01.models.ResourceListResult] - :raises: ~azure.core.exceptions.HttpResponseError + ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.resource.resources.v2019_05_01.models.GenericResourceExpanded] + :raises ~azure.core.exceptions.HttpResponseError: """ - api_version = kwargs.pop('api_version', "2019-05-01") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2019-05-01")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[_models.ResourceListResult] - cls = kwargs.pop('cls', None) # type: ClsType["_models.ResourceListResult"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) + def prepare_request(next_link=None): if not next_link: - + request = build_resources_list_request( subscription_id=self._config.subscription_id, - api_version=api_version, filter=filter, expand=expand, top=top, - template_url=self.list.metadata['url'], + 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.url = self._client.format_url(request.url) # type: ignore else: - - request = build_resources_list_request( - subscription_id=self._config.subscription_id, - template_url=next_link, - ) + # make call to next link with the client's api-version + _parsed_next_link = urlparse(next_link) + _next_request_params = case_insensitive_dict(parse_qs(_parsed_next_link.query)) + _next_request_params["api-version"] = self._config.api_version + request = HttpRequest("GET", urljoin(next_link, _parsed_next_link.path), params=_next_request_params) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore request.method = "GET" return request @@ -2747,10 +3500,8 @@ async def extract_data(pipeline_response): async def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) response = pipeline_response.http_response @@ -2760,11 +3511,9 @@ async def get_next(next_link=None): return pipeline_response + return AsyncItemPaged(get_next, extract_data) - return AsyncItemPaged( - get_next, extract_data - ) - list.metadata = {'url': "/subscriptions/{subscriptionId}/resources"} # type: ignore + list.metadata = {"url": "/subscriptions/{subscriptionId}/resources"} # type: ignore @distributed_trace_async async def check_existence( @@ -2780,30 +3529,36 @@ async def check_existence( """Checks whether a resource exists. :param resource_group_name: The name of the resource group containing the resource to check. - The name is case insensitive. + The name is case insensitive. Required. :type resource_group_name: str - :param resource_provider_namespace: The resource provider of the resource to check. + :param resource_provider_namespace: The resource provider of the resource to check. Required. :type resource_provider_namespace: str - :param parent_resource_path: The parent resource identity. + :param parent_resource_path: The parent resource identity. Required. :type parent_resource_path: str - :param resource_type: The resource type. + :param resource_type: The resource type. Required. :type resource_type: str - :param resource_name: The name of the resource to check whether it exists. + :param resource_name: The name of the resource to check whether it exists. Required. :type resource_name: str - :param api_version: The API version to use for the operation. + :param api_version: The API version to use for the operation. Required. :type api_version: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: bool, or the result of cls(response) + :return: bool or the result of cls(response) :rtype: bool - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType[None] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = kwargs.pop("params", {}) or {} + + cls = kwargs.pop("cls", None) # type: ClsType[None] - request = build_resources_check_existence_request( resource_group_name=resource_group_name, resource_provider_namespace=resource_provider_namespace, @@ -2812,16 +3567,17 @@ async def check_existence( resource_name=resource_name, subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.check_existence.metadata['url'], + template_url=self.check_existence.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [204, 404]: @@ -2832,8 +3588,7 @@ async def check_existence( return cls(pipeline_response, None, {}) return 200 <= response.status_code <= 299 - check_existence.metadata = {'url': "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{parentResourcePath}/{resourceType}/{resourceName}"} # type: ignore - + check_existence.metadata = {"url": "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{parentResourcePath}/{resourceType}/{resourceName}"} # type: ignore async def _delete_initial( # pylint: disable=inconsistent-return-statements self, @@ -2845,14 +3600,20 @@ async def _delete_initial( # pylint: disable=inconsistent-return-statements api_version: str, **kwargs: Any ) -> None: - cls = kwargs.pop('cls', None) # type: ClsType[None] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) - - request = build_resources_delete_request_initial( + _headers = kwargs.pop("headers", {}) or {} + _params = kwargs.pop("params", {}) or {} + + cls = kwargs.pop("cls", None) # type: ClsType[None] + + request = build_resources_delete_request( resource_group_name=resource_group_name, resource_provider_namespace=resource_provider_namespace, parent_resource_path=parent_resource_path, @@ -2860,16 +3621,17 @@ async def _delete_initial( # pylint: disable=inconsistent-return-statements resource_name=resource_name, subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self._delete_initial.metadata['url'], + template_url=self._delete_initial.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200, 202, 204]: @@ -2879,11 +3641,10 @@ 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/{resourceProviderNamespace}/{parentResourcePath}/{resourceType}/{resourceName}"} # type: ignore - + _delete_initial.metadata = {"url": "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{parentResourcePath}/{resourceType}/{resourceName}"} # type: ignore @distributed_trace_async - async def begin_delete( # pylint: disable=inconsistent-return-statements + async def begin_delete( self, resource_group_name: str, resource_provider_namespace: str, @@ -2896,17 +3657,17 @@ async def begin_delete( # pylint: disable=inconsistent-return-statements """Deletes a resource. :param resource_group_name: The name of the resource group that contains the resource to - delete. The name is case insensitive. + delete. The name is case insensitive. Required. :type resource_group_name: str - :param resource_provider_namespace: The namespace of the resource provider. + :param resource_provider_namespace: The namespace of the resource provider. Required. :type resource_provider_namespace: str - :param parent_resource_path: The parent resource identity. + :param parent_resource_path: The parent resource identity. Required. :type parent_resource_path: str - :param resource_type: The resource type. + :param resource_type: The resource type. Required. :type resource_type: str - :param resource_name: The name of the resource to delete. + :param resource_name: The name of the resource to delete. Required. :type resource_name: str - :param api_version: The API version to use for the operation. + :param api_version: The API version to use for the operation. Required. :type api_version: str :keyword callable cls: A custom type or function that will be passed the direct response :keyword str continuation_token: A continuation token to restart a poller from a saved state. @@ -2918,46 +3679,50 @@ async def begin_delete( # pylint: disable=inconsistent-return-statements Retry-After header is present. :return: An instance of AsyncLROPoller that returns either None or the result of cls(response) :rtype: ~azure.core.polling.AsyncLROPoller[None] - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - polling = kwargs.pop('polling', True) # type: Union[bool, AsyncPollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType[None] - lro_delay = kwargs.pop( - 'polling_interval', - self._config.polling_interval - ) - cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] + _headers = kwargs.pop("headers", {}) or {} + _params = kwargs.pop("params", {}) or {} + + cls = kwargs.pop("cls", None) # type: ClsType[None] + polling = kwargs.pop("polling", True) # type: Union[bool, AsyncPollingMethod] + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token = kwargs.pop("continuation_token", None) # type: Optional[str] if cont_token is None: - raw_result = await self._delete_initial( + raw_result = await self._delete_initial( # type: ignore resource_group_name=resource_group_name, resource_provider_namespace=resource_provider_namespace, parent_resource_path=parent_resource_path, resource_type=resource_type, resource_name=resource_name, api_version=api_version, - cls=lambda x,y,z: x, + cls=lambda x, y, z: x, + headers=_headers, + params=_params, **kwargs ) - kwargs.pop('error_map', None) + kwargs.pop("error_map", None) - def get_long_running_output(pipeline_response): + def get_long_running_output(pipeline_response): # pylint: disable=inconsistent-return-statements if cls: return cls(pipeline_response, None, {}) - - if polling is True: polling_method = AsyncARMPolling(lro_delay, **kwargs) - elif polling is False: polling_method = AsyncNoPolling() - else: polling_method = polling + if polling is True: + polling_method = cast(AsyncPollingMethod, AsyncARMPolling(lro_delay, **kwargs)) # type: AsyncPollingMethod + elif polling is False: + polling_method = cast(AsyncPollingMethod, AsyncNoPolling()) + else: + polling_method = polling if cont_token: return AsyncLROPoller.from_continuation_token( polling_method=polling_method, continuation_token=cont_token, client=self._client, - deserialization_callback=get_long_running_output + deserialization_callback=get_long_running_output, ) return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) - begin_delete.metadata = {'url': "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{parentResourcePath}/{resourceType}/{resourceName}"} # type: ignore + begin_delete.metadata = {"url": "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{parentResourcePath}/{resourceType}/{resourceName}"} # type: ignore async def _create_or_update_initial( self, @@ -2967,39 +3732,53 @@ async def _create_or_update_initial( resource_type: str, resource_name: str, api_version: str, - parameters: "_models.GenericResource", + parameters: Union[_models.GenericResource, IO], **kwargs: Any - ) -> Optional["_models.GenericResource"]: - cls = kwargs.pop('cls', None) # type: ClsType[Optional["_models.GenericResource"]] + ) -> Optional[_models.GenericResource]: error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = kwargs.pop("params", {}) or {} - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[Optional[_models.GenericResource]] - _json = self._serialize.body(parameters, 'GenericResource') + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(parameters, (IO, bytes)): + _content = parameters + else: + _json = self._serialize.body(parameters, "GenericResource") - request = build_resources_create_or_update_request_initial( + request = build_resources_create_or_update_request( resource_group_name=resource_group_name, resource_provider_namespace=resource_provider_namespace, parent_resource_path=parent_resource_path, resource_type=resource_type, resource_name=resource_name, subscription_id=self._config.subscription_id, - content_type=content_type, api_version=api_version, + content_type=content_type, json=_json, - template_url=self._create_or_update_initial.metadata['url'], + content=_content, + template_url=self._create_or_update_initial.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200, 201, 202]: @@ -3008,18 +3787,115 @@ async def _create_or_update_initial( deserialized = None if response.status_code == 200: - deserialized = self._deserialize('GenericResource', pipeline_response) + deserialized = self._deserialize("GenericResource", pipeline_response) if response.status_code == 201: - deserialized = self._deserialize('GenericResource', pipeline_response) + deserialized = self._deserialize("GenericResource", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - _create_or_update_initial.metadata = {'url': "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{parentResourcePath}/{resourceType}/{resourceName}"} # type: ignore + _create_or_update_initial.metadata = {"url": "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{parentResourcePath}/{resourceType}/{resourceName}"} # type: ignore + + @overload + async def begin_create_or_update( + self, + resource_group_name: str, + resource_provider_namespace: str, + parent_resource_path: str, + resource_type: str, + resource_name: str, + api_version: str, + parameters: _models.GenericResource, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> AsyncLROPoller[_models.GenericResource]: + """Creates a resource. + + :param resource_group_name: The name of the resource group for the resource. The name is case + insensitive. Required. + :type resource_group_name: str + :param resource_provider_namespace: The namespace of the resource provider. Required. + :type resource_provider_namespace: str + :param parent_resource_path: The parent resource identity. Required. + :type parent_resource_path: str + :param resource_type: The resource type of the resource to create. Required. + :type resource_type: str + :param resource_name: The name of the resource to create. Required. + :type resource_name: str + :param api_version: The API version to use for the operation. Required. + :type api_version: str + :param parameters: Parameters for creating or updating the resource. Required. + :type parameters: ~azure.mgmt.resource.resources.v2019_05_01.models.GenericResource + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be AsyncARMPolling. Pass in False for + this operation to not poll, or pass in your own initialized polling object for a personal + polling strategy. + :paramtype polling: bool or ~azure.core.polling.AsyncPollingMethod + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of AsyncLROPoller that returns either GenericResource or the result of + cls(response) + :rtype: + ~azure.core.polling.AsyncLROPoller[~azure.mgmt.resource.resources.v2019_05_01.models.GenericResource] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + async def begin_create_or_update( + self, + resource_group_name: str, + resource_provider_namespace: str, + parent_resource_path: str, + resource_type: str, + resource_name: str, + api_version: str, + parameters: IO, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> AsyncLROPoller[_models.GenericResource]: + """Creates a resource. + :param resource_group_name: The name of the resource group for the resource. The name is case + insensitive. Required. + :type resource_group_name: str + :param resource_provider_namespace: The namespace of the resource provider. Required. + :type resource_provider_namespace: str + :param parent_resource_path: The parent resource identity. Required. + :type parent_resource_path: str + :param resource_type: The resource type of the resource to create. Required. + :type resource_type: str + :param resource_name: The name of the resource to create. Required. + :type resource_name: str + :param api_version: The API version to use for the operation. Required. + :type api_version: str + :param parameters: Parameters for creating or updating the resource. Required. + :type parameters: IO + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be AsyncARMPolling. Pass in False for + this operation to not poll, or pass in your own initialized polling object for a personal + polling strategy. + :paramtype polling: bool or ~azure.core.polling.AsyncPollingMethod + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of AsyncLROPoller that returns either GenericResource or the result of + cls(response) + :rtype: + ~azure.core.polling.AsyncLROPoller[~azure.mgmt.resource.resources.v2019_05_01.models.GenericResource] + :raises ~azure.core.exceptions.HttpResponseError: + """ @distributed_trace_async async def begin_create_or_update( @@ -3030,26 +3906,30 @@ async def begin_create_or_update( resource_type: str, resource_name: str, api_version: str, - parameters: "_models.GenericResource", + parameters: Union[_models.GenericResource, IO], **kwargs: Any - ) -> AsyncLROPoller["_models.GenericResource"]: + ) -> AsyncLROPoller[_models.GenericResource]: """Creates a resource. :param resource_group_name: The name of the resource group for the resource. The name is case - insensitive. + insensitive. Required. :type resource_group_name: str - :param resource_provider_namespace: The namespace of the resource provider. + :param resource_provider_namespace: The namespace of the resource provider. Required. :type resource_provider_namespace: str - :param parent_resource_path: The parent resource identity. + :param parent_resource_path: The parent resource identity. Required. :type parent_resource_path: str - :param resource_type: The resource type of the resource to create. + :param resource_type: The resource type of the resource to create. Required. :type resource_type: str - :param resource_name: The name of the resource to create. + :param resource_name: The name of the resource to create. Required. :type resource_name: str - :param api_version: The API version to use for the operation. + :param api_version: The API version to use for the operation. Required. :type api_version: str - :param parameters: Parameters for creating or updating the resource. - :type parameters: ~azure.mgmt.resource.resources.v2019_05_01.models.GenericResource + :param parameters: Parameters for creating or updating the resource. Is either a model type or + a IO type. Required. + :type parameters: ~azure.mgmt.resource.resources.v2019_05_01.models.GenericResource or IO + :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. + Default value is None. + :paramtype content_type: str :keyword callable cls: A custom type or function that will be passed the direct response :keyword str continuation_token: A continuation token to restart a poller from a saved state. :keyword polling: By default, your polling method will be AsyncARMPolling. Pass in False for @@ -3062,18 +3942,18 @@ async def begin_create_or_update( cls(response) :rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.resource.resources.v2019_05_01.models.GenericResource] - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] - polling = kwargs.pop('polling', True) # type: Union[bool, AsyncPollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType["_models.GenericResource"] - lro_delay = kwargs.pop( - 'polling_interval', - self._config.polling_interval - ) - cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = kwargs.pop("params", {}) or {} + + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.GenericResource] + polling = kwargs.pop("polling", True) # type: Union[bool, AsyncPollingMethod] + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token = kwargs.pop("continuation_token", None) # type: Optional[str] if cont_token is None: - raw_result = await self._create_or_update_initial( + raw_result = await self._create_or_update_initial( # type: ignore resource_group_name=resource_group_name, resource_provider_namespace=resource_provider_namespace, parent_resource_path=parent_resource_path, @@ -3082,32 +3962,35 @@ async def begin_create_or_update( api_version=api_version, parameters=parameters, content_type=content_type, - cls=lambda x,y,z: x, + cls=lambda x, y, z: x, + headers=_headers, + params=_params, **kwargs ) - kwargs.pop('error_map', None) + kwargs.pop("error_map", None) def get_long_running_output(pipeline_response): - response = pipeline_response.http_response - deserialized = self._deserialize('GenericResource', pipeline_response) + deserialized = self._deserialize("GenericResource", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - - if polling is True: polling_method = AsyncARMPolling(lro_delay, **kwargs) - elif polling is False: polling_method = AsyncNoPolling() - else: polling_method = polling + if polling is True: + polling_method = cast(AsyncPollingMethod, AsyncARMPolling(lro_delay, **kwargs)) # type: AsyncPollingMethod + elif polling is False: + polling_method = cast(AsyncPollingMethod, AsyncNoPolling()) + else: + polling_method = polling if cont_token: return AsyncLROPoller.from_continuation_token( polling_method=polling_method, continuation_token=cont_token, client=self._client, - deserialization_callback=get_long_running_output + deserialization_callback=get_long_running_output, ) return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) - begin_create_or_update.metadata = {'url': "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{parentResourcePath}/{resourceType}/{resourceName}"} # type: ignore + begin_create_or_update.metadata = {"url": "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{parentResourcePath}/{resourceType}/{resourceName}"} # type: ignore async def _update_initial( self, @@ -3117,39 +4000,53 @@ async def _update_initial( resource_type: str, resource_name: str, api_version: str, - parameters: "_models.GenericResource", + parameters: Union[_models.GenericResource, IO], **kwargs: Any - ) -> Optional["_models.GenericResource"]: - cls = kwargs.pop('cls', None) # type: ClsType[Optional["_models.GenericResource"]] + ) -> Optional[_models.GenericResource]: error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = kwargs.pop("params", {}) or {} - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[Optional[_models.GenericResource]] - _json = self._serialize.body(parameters, 'GenericResource') + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(parameters, (IO, bytes)): + _content = parameters + else: + _json = self._serialize.body(parameters, "GenericResource") - request = build_resources_update_request_initial( + request = build_resources_update_request( resource_group_name=resource_group_name, resource_provider_namespace=resource_provider_namespace, parent_resource_path=parent_resource_path, resource_type=resource_type, resource_name=resource_name, subscription_id=self._config.subscription_id, - content_type=content_type, api_version=api_version, + content_type=content_type, json=_json, - template_url=self._update_initial.metadata['url'], + content=_content, + template_url=self._update_initial.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200, 202]: @@ -3158,15 +4055,112 @@ async def _update_initial( deserialized = None if response.status_code == 200: - deserialized = self._deserialize('GenericResource', pipeline_response) + deserialized = self._deserialize("GenericResource", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - _update_initial.metadata = {'url': "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{parentResourcePath}/{resourceType}/{resourceName}"} # type: ignore + _update_initial.metadata = {"url": "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{parentResourcePath}/{resourceType}/{resourceName}"} # type: ignore + @overload + async def begin_update( + self, + resource_group_name: str, + resource_provider_namespace: str, + parent_resource_path: str, + resource_type: str, + resource_name: str, + api_version: str, + parameters: _models.GenericResource, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> AsyncLROPoller[_models.GenericResource]: + """Updates a resource. + + :param resource_group_name: The name of the resource group for the resource. The name is case + insensitive. Required. + :type resource_group_name: str + :param resource_provider_namespace: The namespace of the resource provider. Required. + :type resource_provider_namespace: str + :param parent_resource_path: The parent resource identity. Required. + :type parent_resource_path: str + :param resource_type: The resource type of the resource to update. Required. + :type resource_type: str + :param resource_name: The name of the resource to update. Required. + :type resource_name: str + :param api_version: The API version to use for the operation. Required. + :type api_version: str + :param parameters: Parameters for updating the resource. Required. + :type parameters: ~azure.mgmt.resource.resources.v2019_05_01.models.GenericResource + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be AsyncARMPolling. Pass in False for + this operation to not poll, or pass in your own initialized polling object for a personal + polling strategy. + :paramtype polling: bool or ~azure.core.polling.AsyncPollingMethod + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of AsyncLROPoller that returns either GenericResource or the result of + cls(response) + :rtype: + ~azure.core.polling.AsyncLROPoller[~azure.mgmt.resource.resources.v2019_05_01.models.GenericResource] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + async def begin_update( + self, + resource_group_name: str, + resource_provider_namespace: str, + parent_resource_path: str, + resource_type: str, + resource_name: str, + api_version: str, + parameters: IO, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> AsyncLROPoller[_models.GenericResource]: + """Updates a resource. + + :param resource_group_name: The name of the resource group for the resource. The name is case + insensitive. Required. + :type resource_group_name: str + :param resource_provider_namespace: The namespace of the resource provider. Required. + :type resource_provider_namespace: str + :param parent_resource_path: The parent resource identity. Required. + :type parent_resource_path: str + :param resource_type: The resource type of the resource to update. Required. + :type resource_type: str + :param resource_name: The name of the resource to update. Required. + :type resource_name: str + :param api_version: The API version to use for the operation. Required. + :type api_version: str + :param parameters: Parameters for updating the resource. Required. + :type parameters: IO + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be AsyncARMPolling. Pass in False for + this operation to not poll, or pass in your own initialized polling object for a personal + polling strategy. + :paramtype polling: bool or ~azure.core.polling.AsyncPollingMethod + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of AsyncLROPoller that returns either GenericResource or the result of + cls(response) + :rtype: + ~azure.core.polling.AsyncLROPoller[~azure.mgmt.resource.resources.v2019_05_01.models.GenericResource] + :raises ~azure.core.exceptions.HttpResponseError: + """ @distributed_trace_async async def begin_update( @@ -3177,26 +4171,30 @@ async def begin_update( resource_type: str, resource_name: str, api_version: str, - parameters: "_models.GenericResource", + parameters: Union[_models.GenericResource, IO], **kwargs: Any - ) -> AsyncLROPoller["_models.GenericResource"]: + ) -> AsyncLROPoller[_models.GenericResource]: """Updates a resource. :param resource_group_name: The name of the resource group for the resource. The name is case - insensitive. + insensitive. Required. :type resource_group_name: str - :param resource_provider_namespace: The namespace of the resource provider. + :param resource_provider_namespace: The namespace of the resource provider. Required. :type resource_provider_namespace: str - :param parent_resource_path: The parent resource identity. + :param parent_resource_path: The parent resource identity. Required. :type parent_resource_path: str - :param resource_type: The resource type of the resource to update. + :param resource_type: The resource type of the resource to update. Required. :type resource_type: str - :param resource_name: The name of the resource to update. + :param resource_name: The name of the resource to update. Required. :type resource_name: str - :param api_version: The API version to use for the operation. + :param api_version: The API version to use for the operation. Required. :type api_version: str - :param parameters: Parameters for updating the resource. - :type parameters: ~azure.mgmt.resource.resources.v2019_05_01.models.GenericResource + :param parameters: Parameters for updating the resource. Is either a model type or a IO type. + Required. + :type parameters: ~azure.mgmt.resource.resources.v2019_05_01.models.GenericResource or IO + :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. + Default value is None. + :paramtype content_type: str :keyword callable cls: A custom type or function that will be passed the direct response :keyword str continuation_token: A continuation token to restart a poller from a saved state. :keyword polling: By default, your polling method will be AsyncARMPolling. Pass in False for @@ -3209,18 +4207,18 @@ async def begin_update( cls(response) :rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.resource.resources.v2019_05_01.models.GenericResource] - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] - polling = kwargs.pop('polling', True) # type: Union[bool, AsyncPollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType["_models.GenericResource"] - lro_delay = kwargs.pop( - 'polling_interval', - self._config.polling_interval - ) - cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = kwargs.pop("params", {}) or {} + + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.GenericResource] + polling = kwargs.pop("polling", True) # type: Union[bool, AsyncPollingMethod] + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token = kwargs.pop("continuation_token", None) # type: Optional[str] if cont_token is None: - raw_result = await self._update_initial( + raw_result = await self._update_initial( # type: ignore resource_group_name=resource_group_name, resource_provider_namespace=resource_provider_namespace, parent_resource_path=parent_resource_path, @@ -3229,32 +4227,35 @@ async def begin_update( api_version=api_version, parameters=parameters, content_type=content_type, - cls=lambda x,y,z: x, + cls=lambda x, y, z: x, + headers=_headers, + params=_params, **kwargs ) - kwargs.pop('error_map', None) + kwargs.pop("error_map", None) def get_long_running_output(pipeline_response): - response = pipeline_response.http_response - deserialized = self._deserialize('GenericResource', pipeline_response) + deserialized = self._deserialize("GenericResource", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - - if polling is True: polling_method = AsyncARMPolling(lro_delay, **kwargs) - elif polling is False: polling_method = AsyncNoPolling() - else: polling_method = polling + if polling is True: + polling_method = cast(AsyncPollingMethod, AsyncARMPolling(lro_delay, **kwargs)) # type: AsyncPollingMethod + elif polling is False: + polling_method = cast(AsyncPollingMethod, AsyncNoPolling()) + else: + polling_method = polling if cont_token: return AsyncLROPoller.from_continuation_token( polling_method=polling_method, continuation_token=cont_token, client=self._client, - deserialization_callback=get_long_running_output + deserialization_callback=get_long_running_output, ) return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) - begin_update.metadata = {'url': "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{parentResourcePath}/{resourceType}/{resourceName}"} # type: ignore + begin_update.metadata = {"url": "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{parentResourcePath}/{resourceType}/{resourceName}"} # type: ignore @distributed_trace_async async def get( @@ -3266,34 +4267,40 @@ async def get( resource_name: str, api_version: str, **kwargs: Any - ) -> "_models.GenericResource": + ) -> _models.GenericResource: """Gets a resource. :param resource_group_name: The name of the resource group containing the resource to get. The - name is case insensitive. + name is case insensitive. Required. :type resource_group_name: str - :param resource_provider_namespace: The namespace of the resource provider. + :param resource_provider_namespace: The namespace of the resource provider. Required. :type resource_provider_namespace: str - :param parent_resource_path: The parent resource identity. + :param parent_resource_path: The parent resource identity. Required. :type parent_resource_path: str - :param resource_type: The resource type of the resource. + :param resource_type: The resource type of the resource. Required. :type resource_type: str - :param resource_name: The name of the resource to get. + :param resource_name: The name of the resource to get. Required. :type resource_name: str - :param api_version: The API version to use for the operation. + :param api_version: The API version to use for the operation. Required. :type api_version: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: GenericResource, or the result of cls(response) + :return: GenericResource or the result of cls(response) :rtype: ~azure.mgmt.resource.resources.v2019_05_01.models.GenericResource - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.GenericResource"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = kwargs.pop("params", {}) or {} + + cls = kwargs.pop("cls", None) # type: ClsType[_models.GenericResource] - request = build_resources_get_request( resource_group_name=resource_group_name, resource_provider_namespace=resource_provider_namespace, @@ -3302,72 +4309,75 @@ async def get( resource_name=resource_name, subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.get.metadata['url'], + template_url=self.get.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) - deserialized = self._deserialize('GenericResource', pipeline_response) + deserialized = self._deserialize("GenericResource", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - get.metadata = {'url': "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{parentResourcePath}/{resourceType}/{resourceName}"} # type: ignore - + get.metadata = {"url": "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{parentResourcePath}/{resourceType}/{resourceName}"} # type: ignore @distributed_trace_async - async def check_existence_by_id( - self, - resource_id: str, - api_version: str, - **kwargs: Any - ) -> bool: + async def check_existence_by_id(self, resource_id: str, api_version: str, **kwargs: Any) -> bool: """Checks by ID whether a resource exists. :param resource_id: The fully qualified ID of the resource, including the resource name and resource type. Use the format, /subscriptions/{guid}/resourceGroups/{resource-group-name}/{resource-provider-namespace}/{resource-type}/{resource-name}. + Required. :type resource_id: str - :param api_version: The API version to use for the operation. + :param api_version: The API version to use for the operation. Required. :type api_version: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: bool, or the result of cls(response) + :return: bool or the result of cls(response) :rtype: bool - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType[None] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = kwargs.pop("params", {}) or {} + + cls = kwargs.pop("cls", None) # type: ClsType[None] - request = build_resources_check_existence_by_id_request( resource_id=resource_id, api_version=api_version, - template_url=self.check_existence_by_id.metadata['url'], + template_url=self.check_existence_by_id.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [204, 404]: @@ -3378,35 +4388,38 @@ async def check_existence_by_id( return cls(pipeline_response, None, {}) return 200 <= response.status_code <= 299 - check_existence_by_id.metadata = {'url': "/{resourceId}"} # type: ignore - + check_existence_by_id.metadata = {"url": "/{resourceId}"} # type: ignore async def _delete_by_id_initial( # pylint: disable=inconsistent-return-statements - self, - resource_id: str, - api_version: str, - **kwargs: Any + self, resource_id: str, api_version: str, **kwargs: Any ) -> None: - cls = kwargs.pop('cls', None) # type: ClsType[None] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = kwargs.pop("params", {}) or {} - - request = build_resources_delete_by_id_request_initial( + cls = kwargs.pop("cls", None) # type: ClsType[None] + + request = build_resources_delete_by_id_request( resource_id=resource_id, api_version=api_version, - template_url=self._delete_by_id_initial.metadata['url'], + template_url=self._delete_by_id_initial.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200, 202, 204]: @@ -3416,23 +4429,18 @@ async def _delete_by_id_initial( # pylint: disable=inconsistent-return-statemen if cls: return cls(pipeline_response, None, {}) - _delete_by_id_initial.metadata = {'url': "/{resourceId}"} # type: ignore - + _delete_by_id_initial.metadata = {"url": "/{resourceId}"} # type: ignore @distributed_trace_async - async def begin_delete_by_id( # pylint: disable=inconsistent-return-statements - self, - resource_id: str, - api_version: str, - **kwargs: Any - ) -> AsyncLROPoller[None]: + async def begin_delete_by_id(self, resource_id: str, api_version: str, **kwargs: Any) -> AsyncLROPoller[None]: """Deletes a resource by ID. :param resource_id: The fully qualified ID of the resource, including the resource name and resource type. Use the format, /subscriptions/{guid}/resourceGroups/{resource-group-name}/{resource-provider-namespace}/{resource-type}/{resource-name}. + Required. :type resource_id: str - :param api_version: The API version to use for the operation. + :param api_version: The API version to use for the operation. Required. :type api_version: str :keyword callable cls: A custom type or function that will be passed the direct response :keyword str continuation_token: A continuation token to restart a poller from a saved state. @@ -3444,75 +4452,89 @@ async def begin_delete_by_id( # pylint: disable=inconsistent-return-statements Retry-After header is present. :return: An instance of AsyncLROPoller that returns either None or the result of cls(response) :rtype: ~azure.core.polling.AsyncLROPoller[None] - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - polling = kwargs.pop('polling', True) # type: Union[bool, AsyncPollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType[None] - lro_delay = kwargs.pop( - 'polling_interval', - self._config.polling_interval - ) - cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] + _headers = kwargs.pop("headers", {}) or {} + _params = kwargs.pop("params", {}) or {} + + cls = kwargs.pop("cls", None) # type: ClsType[None] + polling = kwargs.pop("polling", True) # type: Union[bool, AsyncPollingMethod] + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token = kwargs.pop("continuation_token", None) # type: Optional[str] if cont_token is None: - raw_result = await self._delete_by_id_initial( + raw_result = await self._delete_by_id_initial( # type: ignore resource_id=resource_id, api_version=api_version, - cls=lambda x,y,z: x, + cls=lambda x, y, z: x, + headers=_headers, + params=_params, **kwargs ) - kwargs.pop('error_map', None) + kwargs.pop("error_map", None) - def get_long_running_output(pipeline_response): + def get_long_running_output(pipeline_response): # pylint: disable=inconsistent-return-statements if cls: return cls(pipeline_response, None, {}) - - if polling is True: polling_method = AsyncARMPolling(lro_delay, **kwargs) - elif polling is False: polling_method = AsyncNoPolling() - else: polling_method = polling + if polling is True: + polling_method = cast(AsyncPollingMethod, AsyncARMPolling(lro_delay, **kwargs)) # type: AsyncPollingMethod + elif polling is False: + polling_method = cast(AsyncPollingMethod, AsyncNoPolling()) + else: + polling_method = polling if cont_token: return AsyncLROPoller.from_continuation_token( polling_method=polling_method, continuation_token=cont_token, client=self._client, - deserialization_callback=get_long_running_output + deserialization_callback=get_long_running_output, ) return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) - begin_delete_by_id.metadata = {'url': "/{resourceId}"} # type: ignore + begin_delete_by_id.metadata = {"url": "/{resourceId}"} # type: ignore async def _create_or_update_by_id_initial( - self, - resource_id: str, - api_version: str, - parameters: "_models.GenericResource", - **kwargs: Any - ) -> Optional["_models.GenericResource"]: - cls = kwargs.pop('cls', None) # type: ClsType[Optional["_models.GenericResource"]] + self, resource_id: str, api_version: str, parameters: Union[_models.GenericResource, IO], **kwargs: Any + ) -> Optional[_models.GenericResource]: error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = kwargs.pop("params", {}) or {} - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[Optional[_models.GenericResource]] - _json = self._serialize.body(parameters, 'GenericResource') + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(parameters, (IO, bytes)): + _content = parameters + else: + _json = self._serialize.body(parameters, "GenericResource") - request = build_resources_create_or_update_by_id_request_initial( + request = build_resources_create_or_update_by_id_request( resource_id=resource_id, - content_type=content_type, api_version=api_version, + content_type=content_type, json=_json, - template_url=self._create_or_update_by_id_initial.metadata['url'], + content=_content, + template_url=self._create_or_update_by_id_initial.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200, 201, 202]: @@ -3521,37 +4543,42 @@ async def _create_or_update_by_id_initial( deserialized = None if response.status_code == 200: - deserialized = self._deserialize('GenericResource', pipeline_response) + deserialized = self._deserialize("GenericResource", pipeline_response) if response.status_code == 201: - deserialized = self._deserialize('GenericResource', pipeline_response) + deserialized = self._deserialize("GenericResource", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - _create_or_update_by_id_initial.metadata = {'url': "/{resourceId}"} # type: ignore + _create_or_update_by_id_initial.metadata = {"url": "/{resourceId}"} # type: ignore - - @distributed_trace_async + @overload async def begin_create_or_update_by_id( self, resource_id: str, api_version: str, - parameters: "_models.GenericResource", + parameters: _models.GenericResource, + *, + content_type: str = "application/json", **kwargs: Any - ) -> AsyncLROPoller["_models.GenericResource"]: + ) -> AsyncLROPoller[_models.GenericResource]: """Create a resource by ID. :param resource_id: The fully qualified ID of the resource, including the resource name and resource type. Use the format, /subscriptions/{guid}/resourceGroups/{resource-group-name}/{resource-provider-namespace}/{resource-type}/{resource-name}. + Required. :type resource_id: str - :param api_version: The API version to use for the operation. + :param api_version: The API version to use for the operation. Required. :type api_version: str - :param parameters: Create or update resource parameters. + :param parameters: Create or update resource parameters. Required. :type parameters: ~azure.mgmt.resource.resources.v2019_05_01.models.GenericResource + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str :keyword callable cls: A custom type or function that will be passed the direct response :keyword str continuation_token: A continuation token to restart a poller from a saved state. :keyword polling: By default, your polling method will be AsyncARMPolling. Pass in False for @@ -3564,81 +4591,167 @@ async def begin_create_or_update_by_id( cls(response) :rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.resource.resources.v2019_05_01.models.GenericResource] - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] - polling = kwargs.pop('polling', True) # type: Union[bool, AsyncPollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType["_models.GenericResource"] - lro_delay = kwargs.pop( - 'polling_interval', - self._config.polling_interval - ) - cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] + + @overload + async def begin_create_or_update_by_id( + self, + resource_id: str, + api_version: str, + parameters: IO, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> AsyncLROPoller[_models.GenericResource]: + """Create a resource by ID. + + :param resource_id: The fully qualified ID of the resource, including the resource name and + resource type. Use the format, + /subscriptions/{guid}/resourceGroups/{resource-group-name}/{resource-provider-namespace}/{resource-type}/{resource-name}. + Required. + :type resource_id: str + :param api_version: The API version to use for the operation. Required. + :type api_version: str + :param parameters: Create or update resource parameters. Required. + :type parameters: IO + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be AsyncARMPolling. Pass in False for + this operation to not poll, or pass in your own initialized polling object for a personal + polling strategy. + :paramtype polling: bool or ~azure.core.polling.AsyncPollingMethod + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of AsyncLROPoller that returns either GenericResource or the result of + cls(response) + :rtype: + ~azure.core.polling.AsyncLROPoller[~azure.mgmt.resource.resources.v2019_05_01.models.GenericResource] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace_async + async def begin_create_or_update_by_id( + self, resource_id: str, api_version: str, parameters: Union[_models.GenericResource, IO], **kwargs: Any + ) -> AsyncLROPoller[_models.GenericResource]: + """Create a resource by ID. + + :param resource_id: The fully qualified ID of the resource, including the resource name and + resource type. Use the format, + /subscriptions/{guid}/resourceGroups/{resource-group-name}/{resource-provider-namespace}/{resource-type}/{resource-name}. + Required. + :type resource_id: str + :param api_version: The API version to use for the operation. Required. + :type api_version: str + :param parameters: Create or update resource parameters. Is either a model type or a IO type. + Required. + :type parameters: ~azure.mgmt.resource.resources.v2019_05_01.models.GenericResource or IO + :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. + Default value is None. + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be AsyncARMPolling. Pass in False for + this operation to not poll, or pass in your own initialized polling object for a personal + polling strategy. + :paramtype polling: bool or ~azure.core.polling.AsyncPollingMethod + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of AsyncLROPoller that returns either GenericResource or the result of + cls(response) + :rtype: + ~azure.core.polling.AsyncLROPoller[~azure.mgmt.resource.resources.v2019_05_01.models.GenericResource] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = kwargs.pop("params", {}) or {} + + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.GenericResource] + polling = kwargs.pop("polling", True) # type: Union[bool, AsyncPollingMethod] + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token = kwargs.pop("continuation_token", None) # type: Optional[str] if cont_token is None: - raw_result = await self._create_or_update_by_id_initial( + raw_result = await self._create_or_update_by_id_initial( # type: ignore resource_id=resource_id, api_version=api_version, parameters=parameters, content_type=content_type, - cls=lambda x,y,z: x, + cls=lambda x, y, z: x, + headers=_headers, + params=_params, **kwargs ) - kwargs.pop('error_map', None) + kwargs.pop("error_map", None) def get_long_running_output(pipeline_response): - response = pipeline_response.http_response - deserialized = self._deserialize('GenericResource', pipeline_response) + deserialized = self._deserialize("GenericResource", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - - if polling is True: polling_method = AsyncARMPolling(lro_delay, **kwargs) - elif polling is False: polling_method = AsyncNoPolling() - else: polling_method = polling + if polling is True: + polling_method = cast(AsyncPollingMethod, AsyncARMPolling(lro_delay, **kwargs)) # type: AsyncPollingMethod + elif polling is False: + polling_method = cast(AsyncPollingMethod, AsyncNoPolling()) + else: + polling_method = polling if cont_token: return AsyncLROPoller.from_continuation_token( polling_method=polling_method, continuation_token=cont_token, client=self._client, - deserialization_callback=get_long_running_output + deserialization_callback=get_long_running_output, ) return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) - begin_create_or_update_by_id.metadata = {'url': "/{resourceId}"} # type: ignore + begin_create_or_update_by_id.metadata = {"url": "/{resourceId}"} # type: ignore async def _update_by_id_initial( - self, - resource_id: str, - api_version: str, - parameters: "_models.GenericResource", - **kwargs: Any - ) -> Optional["_models.GenericResource"]: - cls = kwargs.pop('cls', None) # type: ClsType[Optional["_models.GenericResource"]] + self, resource_id: str, api_version: str, parameters: Union[_models.GenericResource, IO], **kwargs: Any + ) -> Optional[_models.GenericResource]: error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = kwargs.pop("params", {}) or {} - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[Optional[_models.GenericResource]] - _json = self._serialize.body(parameters, 'GenericResource') + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(parameters, (IO, bytes)): + _content = parameters + else: + _json = self._serialize.body(parameters, "GenericResource") - request = build_resources_update_by_id_request_initial( + request = build_resources_update_by_id_request( resource_id=resource_id, - content_type=content_type, api_version=api_version, + content_type=content_type, json=_json, - template_url=self._update_by_id_initial.metadata['url'], + content=_content, + template_url=self._update_by_id_initial.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200, 202]: @@ -3647,34 +4760,111 @@ async def _update_by_id_initial( deserialized = None if response.status_code == 200: - deserialized = self._deserialize('GenericResource', pipeline_response) + deserialized = self._deserialize("GenericResource", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - _update_by_id_initial.metadata = {'url': "/{resourceId}"} # type: ignore + _update_by_id_initial.metadata = {"url": "/{resourceId}"} # type: ignore + + @overload + async def begin_update_by_id( + self, + resource_id: str, + api_version: str, + parameters: _models.GenericResource, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> AsyncLROPoller[_models.GenericResource]: + """Updates a resource by ID. + :param resource_id: The fully qualified ID of the resource, including the resource name and + resource type. Use the format, + /subscriptions/{guid}/resourceGroups/{resource-group-name}/{resource-provider-namespace}/{resource-type}/{resource-name}. + Required. + :type resource_id: str + :param api_version: The API version to use for the operation. Required. + :type api_version: str + :param parameters: Update resource parameters. Required. + :type parameters: ~azure.mgmt.resource.resources.v2019_05_01.models.GenericResource + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be AsyncARMPolling. Pass in False for + this operation to not poll, or pass in your own initialized polling object for a personal + polling strategy. + :paramtype polling: bool or ~azure.core.polling.AsyncPollingMethod + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of AsyncLROPoller that returns either GenericResource or the result of + cls(response) + :rtype: + ~azure.core.polling.AsyncLROPoller[~azure.mgmt.resource.resources.v2019_05_01.models.GenericResource] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + async def begin_update_by_id( + self, + resource_id: str, + api_version: str, + parameters: IO, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> AsyncLROPoller[_models.GenericResource]: + """Updates a resource by ID. + + :param resource_id: The fully qualified ID of the resource, including the resource name and + resource type. Use the format, + /subscriptions/{guid}/resourceGroups/{resource-group-name}/{resource-provider-namespace}/{resource-type}/{resource-name}. + Required. + :type resource_id: str + :param api_version: The API version to use for the operation. Required. + :type api_version: str + :param parameters: Update resource parameters. Required. + :type parameters: IO + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be AsyncARMPolling. Pass in False for + this operation to not poll, or pass in your own initialized polling object for a personal + polling strategy. + :paramtype polling: bool or ~azure.core.polling.AsyncPollingMethod + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of AsyncLROPoller that returns either GenericResource or the result of + cls(response) + :rtype: + ~azure.core.polling.AsyncLROPoller[~azure.mgmt.resource.resources.v2019_05_01.models.GenericResource] + :raises ~azure.core.exceptions.HttpResponseError: + """ @distributed_trace_async async def begin_update_by_id( - self, - resource_id: str, - api_version: str, - parameters: "_models.GenericResource", - **kwargs: Any - ) -> AsyncLROPoller["_models.GenericResource"]: + self, resource_id: str, api_version: str, parameters: Union[_models.GenericResource, IO], **kwargs: Any + ) -> AsyncLROPoller[_models.GenericResource]: """Updates a resource by ID. :param resource_id: The fully qualified ID of the resource, including the resource name and resource type. Use the format, /subscriptions/{guid}/resourceGroups/{resource-group-name}/{resource-provider-namespace}/{resource-type}/{resource-name}. + Required. :type resource_id: str - :param api_version: The API version to use for the operation. + :param api_version: The API version to use for the operation. Required. :type api_version: str - :param parameters: Update resource parameters. - :type parameters: ~azure.mgmt.resource.resources.v2019_05_01.models.GenericResource + :param parameters: Update resource parameters. Is either a model type or a IO type. Required. + :type parameters: ~azure.mgmt.resource.resources.v2019_05_01.models.GenericResource or IO + :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. + Default value is None. + :paramtype content_type: str :keyword callable cls: A custom type or function that will be passed the direct response :keyword str continuation_token: A continuation token to restart a poller from a saved state. :keyword polling: By default, your polling method will be AsyncARMPolling. Pass in False for @@ -3687,165 +4877,171 @@ async def begin_update_by_id( cls(response) :rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.resource.resources.v2019_05_01.models.GenericResource] - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] - polling = kwargs.pop('polling', True) # type: Union[bool, AsyncPollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType["_models.GenericResource"] - lro_delay = kwargs.pop( - 'polling_interval', - self._config.polling_interval - ) - cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = kwargs.pop("params", {}) or {} + + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.GenericResource] + polling = kwargs.pop("polling", True) # type: Union[bool, AsyncPollingMethod] + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token = kwargs.pop("continuation_token", None) # type: Optional[str] if cont_token is None: - raw_result = await self._update_by_id_initial( + raw_result = await self._update_by_id_initial( # type: ignore resource_id=resource_id, api_version=api_version, parameters=parameters, content_type=content_type, - cls=lambda x,y,z: x, + cls=lambda x, y, z: x, + headers=_headers, + params=_params, **kwargs ) - kwargs.pop('error_map', None) + kwargs.pop("error_map", None) def get_long_running_output(pipeline_response): - response = pipeline_response.http_response - deserialized = self._deserialize('GenericResource', pipeline_response) + deserialized = self._deserialize("GenericResource", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - - if polling is True: polling_method = AsyncARMPolling(lro_delay, **kwargs) - elif polling is False: polling_method = AsyncNoPolling() - else: polling_method = polling + if polling is True: + polling_method = cast(AsyncPollingMethod, AsyncARMPolling(lro_delay, **kwargs)) # type: AsyncPollingMethod + elif polling is False: + polling_method = cast(AsyncPollingMethod, AsyncNoPolling()) + else: + polling_method = polling if cont_token: return AsyncLROPoller.from_continuation_token( polling_method=polling_method, continuation_token=cont_token, client=self._client, - deserialization_callback=get_long_running_output + deserialization_callback=get_long_running_output, ) return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) - begin_update_by_id.metadata = {'url': "/{resourceId}"} # type: ignore + begin_update_by_id.metadata = {"url": "/{resourceId}"} # type: ignore @distributed_trace_async - async def get_by_id( - self, - resource_id: str, - api_version: str, - **kwargs: Any - ) -> "_models.GenericResource": + async def get_by_id(self, resource_id: str, api_version: str, **kwargs: Any) -> _models.GenericResource: """Gets a resource by ID. :param resource_id: The fully qualified ID of the resource, including the resource name and resource type. Use the format, /subscriptions/{guid}/resourceGroups/{resource-group-name}/{resource-provider-namespace}/{resource-type}/{resource-name}. + Required. :type resource_id: str - :param api_version: The API version to use for the operation. + :param api_version: The API version to use for the operation. Required. :type api_version: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: GenericResource, or the result of cls(response) + :return: GenericResource or the result of cls(response) :rtype: ~azure.mgmt.resource.resources.v2019_05_01.models.GenericResource - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.GenericResource"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = kwargs.pop("params", {}) or {} + + cls = kwargs.pop("cls", None) # type: ClsType[_models.GenericResource] - request = build_resources_get_by_id_request( resource_id=resource_id, api_version=api_version, - template_url=self.get_by_id.metadata['url'], + template_url=self.get_by_id.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) - deserialized = self._deserialize('GenericResource', pipeline_response) + deserialized = self._deserialize("GenericResource", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - get_by_id.metadata = {'url': "/{resourceId}"} # type: ignore + get_by_id.metadata = {"url": "/{resourceId}"} # type: ignore -class ResourceGroupsOperations: - """ResourceGroupsOperations async operations. - You should not instantiate this class directly. Instead, you should create a Client instance that - instantiates it for you and attaches it as an attribute. +class ResourceGroupsOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. - :ivar models: Alias to model classes used in this operation group. - :type models: ~azure.mgmt.resource.resources.v2019_05_01.models - :param client: Client for service requests. - :param config: Configuration of service client. - :param serializer: An object model serializer. - :param deserializer: An object model deserializer. + Instead, you should access the following operations through + :class:`~azure.mgmt.resource.resources.v2019_05_01.aio.ResourceManagementClient`'s + :attr:`resource_groups` attribute. """ models = _models - def __init__(self, client, config, serializer, deserializer) -> None: - self._client = client - self._serialize = serializer - self._deserialize = deserializer - self._config = config + def __init__(self, *args, **kwargs) -> None: + input_args = list(args) + self._client = input_args.pop(0) if input_args else kwargs.pop("client") + self._config = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") @distributed_trace_async - async def check_existence( - self, - resource_group_name: str, - **kwargs: Any - ) -> bool: + async def check_existence(self, resource_group_name: str, **kwargs: Any) -> bool: """Checks whether a resource group exists. :param resource_group_name: The name of the resource group to check. The name is case - insensitive. + insensitive. Required. :type resource_group_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: bool, or the result of cls(response) + :return: bool or the result of cls(response) :rtype: bool - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType[None] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) - api_version = kwargs.pop('api_version', "2019-05-01") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2019-05-01")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[None] - request = build_resource_groups_check_existence_request( resource_group_name=resource_group_name, subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.check_existence.metadata['url'], + template_url=self.check_existence.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [204, 404]: @@ -3856,39 +5052,98 @@ async def check_existence( return cls(pipeline_response, None, {}) return 200 <= response.status_code <= 299 - check_existence.metadata = {'url': "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}"} # type: ignore + check_existence.metadata = {"url": "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}"} # type: ignore - - @distributed_trace_async + @overload async def create_or_update( self, resource_group_name: str, - parameters: "_models.ResourceGroup", + parameters: _models.ResourceGroup, + *, + content_type: str = "application/json", **kwargs: Any - ) -> "_models.ResourceGroup": + ) -> _models.ResourceGroup: """Creates or updates a resource group. :param resource_group_name: The name of the resource group to create or update. Can include alphanumeric, underscore, parentheses, hyphen, period (except at end), and Unicode characters - that match the allowed characters. + that match the allowed characters. Required. :type resource_group_name: str - :param parameters: Parameters supplied to the create or update a resource group. + :param parameters: Parameters supplied to the create or update a resource group. Required. :type parameters: ~azure.mgmt.resource.resources.v2019_05_01.models.ResourceGroup + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: ResourceGroup or the result of cls(response) + :rtype: ~azure.mgmt.resource.resources.v2019_05_01.models.ResourceGroup + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + async def create_or_update( + self, resource_group_name: str, parameters: IO, *, content_type: str = "application/json", **kwargs: Any + ) -> _models.ResourceGroup: + """Creates or updates a resource group. + + :param resource_group_name: The name of the resource group to create or update. Can include + alphanumeric, underscore, parentheses, hyphen, period (except at end), and Unicode characters + that match the allowed characters. Required. + :type resource_group_name: str + :param parameters: Parameters supplied to the create or update a resource group. Required. + :type parameters: IO + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: ResourceGroup or the result of cls(response) + :rtype: ~azure.mgmt.resource.resources.v2019_05_01.models.ResourceGroup + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace_async + async def create_or_update( + self, resource_group_name: str, parameters: Union[_models.ResourceGroup, IO], **kwargs: Any + ) -> _models.ResourceGroup: + """Creates or updates a resource group. + + :param resource_group_name: The name of the resource group to create or update. Can include + alphanumeric, underscore, parentheses, hyphen, period (except at end), and Unicode characters + that match the allowed characters. Required. + :type resource_group_name: str + :param parameters: Parameters supplied to the create or update a resource group. Is either a + model type or a IO type. Required. + :type parameters: ~azure.mgmt.resource.resources.v2019_05_01.models.ResourceGroup or IO + :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. + Default value is None. + :paramtype content_type: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: ResourceGroup, or the result of cls(response) + :return: ResourceGroup or the result of cls(response) :rtype: ~azure.mgmt.resource.resources.v2019_05_01.models.ResourceGroup - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.ResourceGroup"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) - api_version = kwargs.pop('api_version', "2019-05-01") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - _json = self._serialize.body(parameters, 'ResourceGroup') + api_version = kwargs.pop("api_version", _params.pop("api-version", "2019-05-01")) # type: str + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.ResourceGroup] + + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(parameters, (IO, bytes)): + _content = parameters + else: + _json = self._serialize.body(parameters, "ResourceGroup") request = build_resource_groups_create_or_update_request( resource_group_name=resource_group_name, @@ -3896,16 +5151,18 @@ async def create_or_update( api_version=api_version, content_type=content_type, json=_json, - template_url=self.create_or_update.metadata['url'], + content=_content, + template_url=self.create_or_update.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200, 201]: @@ -3913,47 +5170,50 @@ async def create_or_update( raise HttpResponseError(response=response, error_format=ARMErrorFormat) if response.status_code == 200: - deserialized = self._deserialize('ResourceGroup', pipeline_response) + deserialized = self._deserialize("ResourceGroup", pipeline_response) if response.status_code == 201: - deserialized = self._deserialize('ResourceGroup', pipeline_response) + deserialized = self._deserialize("ResourceGroup", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - create_or_update.metadata = {'url': "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}"} # type: ignore - + create_or_update.metadata = {"url": "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}"} # type: ignore async def _delete_initial( # pylint: disable=inconsistent-return-statements - self, - resource_group_name: str, - **kwargs: Any + self, resource_group_name: str, **kwargs: Any ) -> None: - cls = kwargs.pop('cls', None) # type: ClsType[None] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) - api_version = kwargs.pop('api_version', "2019-05-01") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - request = build_resource_groups_delete_request_initial( + api_version = kwargs.pop("api_version", _params.pop("api-version", "2019-05-01")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[None] + + request = build_resource_groups_delete_request( resource_group_name=resource_group_name, subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self._delete_initial.metadata['url'], + template_url=self._delete_initial.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200, 202]: @@ -3963,22 +5223,17 @@ async def _delete_initial( # pylint: disable=inconsistent-return-statements if cls: return cls(pipeline_response, None, {}) - _delete_initial.metadata = {'url': "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}"} # type: ignore - + _delete_initial.metadata = {"url": "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}"} # type: ignore @distributed_trace_async - async def begin_delete( # pylint: disable=inconsistent-return-statements - self, - resource_group_name: str, - **kwargs: Any - ) -> AsyncLROPoller[None]: + async def begin_delete(self, resource_group_name: str, **kwargs: Any) -> AsyncLROPoller[None]: """Deletes a resource group. When you delete a resource group, all of its resources are also deleted. Deleting a resource group deletes all of its template deployments and currently stored operations. :param resource_group_name: The name of the resource group to delete. The name is case - insensitive. + insensitive. Required. :type resource_group_name: str :keyword callable cls: A custom type or function that will be passed the direct response :keyword str continuation_token: A continuation token to restart a poller from a saved state. @@ -3990,106 +5245,113 @@ async def begin_delete( # pylint: disable=inconsistent-return-statements Retry-After header is present. :return: An instance of AsyncLROPoller that returns either None or the result of cls(response) :rtype: ~azure.core.polling.AsyncLROPoller[None] - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - api_version = kwargs.pop('api_version', "2019-05-01") # type: str - polling = kwargs.pop('polling', True) # type: Union[bool, AsyncPollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType[None] - lro_delay = kwargs.pop( - 'polling_interval', - self._config.polling_interval - ) - cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2019-05-01")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[None] + polling = kwargs.pop("polling", True) # type: Union[bool, AsyncPollingMethod] + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token = kwargs.pop("continuation_token", None) # type: Optional[str] if cont_token is None: - raw_result = await self._delete_initial( + raw_result = await self._delete_initial( # type: ignore resource_group_name=resource_group_name, api_version=api_version, - cls=lambda x,y,z: x, + cls=lambda x, y, z: x, + headers=_headers, + params=_params, **kwargs ) - kwargs.pop('error_map', None) + kwargs.pop("error_map", None) - def get_long_running_output(pipeline_response): + def get_long_running_output(pipeline_response): # pylint: disable=inconsistent-return-statements if cls: return cls(pipeline_response, None, {}) - - if polling is True: polling_method = AsyncARMPolling(lro_delay, **kwargs) - elif polling is False: polling_method = AsyncNoPolling() - else: polling_method = polling + if polling is True: + polling_method = cast(AsyncPollingMethod, AsyncARMPolling(lro_delay, **kwargs)) # type: AsyncPollingMethod + elif polling is False: + polling_method = cast(AsyncPollingMethod, AsyncNoPolling()) + else: + polling_method = polling if cont_token: return AsyncLROPoller.from_continuation_token( polling_method=polling_method, continuation_token=cont_token, client=self._client, - deserialization_callback=get_long_running_output + deserialization_callback=get_long_running_output, ) return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) - begin_delete.metadata = {'url': "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}"} # type: ignore + begin_delete.metadata = {"url": "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}"} # type: ignore @distributed_trace_async - async def get( - self, - resource_group_name: str, - **kwargs: Any - ) -> "_models.ResourceGroup": + async def get(self, resource_group_name: str, **kwargs: Any) -> _models.ResourceGroup: """Gets a resource group. :param resource_group_name: The name of the resource group to get. The name is case - insensitive. + insensitive. Required. :type resource_group_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: ResourceGroup, or the result of cls(response) + :return: ResourceGroup or the result of cls(response) :rtype: ~azure.mgmt.resource.resources.v2019_05_01.models.ResourceGroup - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.ResourceGroup"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) - api_version = kwargs.pop('api_version', "2019-05-01") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2019-05-01")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[_models.ResourceGroup] - request = build_resource_groups_get_request( resource_group_name=resource_group_name, subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.get.metadata['url'], + template_url=self.get.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) - deserialized = self._deserialize('ResourceGroup', pipeline_response) + deserialized = self._deserialize("ResourceGroup", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - get.metadata = {'url': "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}"} # type: ignore + get.metadata = {"url": "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}"} # type: ignore - - @distributed_trace_async + @overload async def update( self, resource_group_name: str, - parameters: "_models.ResourceGroupPatchable", + parameters: _models.ResourceGroupPatchable, + *, + content_type: str = "application/json", **kwargs: Any - ) -> "_models.ResourceGroup": + ) -> _models.ResourceGroup: """Updates a resource group. Resource groups can be updated through a simple PATCH operation to a group address. The format @@ -4097,25 +5359,90 @@ async def update( the current value is retained. :param resource_group_name: The name of the resource group to update. The name is case - insensitive. + insensitive. Required. :type resource_group_name: str - :param parameters: Parameters supplied to update a resource group. + :param parameters: Parameters supplied to update a resource group. Required. :type parameters: ~azure.mgmt.resource.resources.v2019_05_01.models.ResourceGroupPatchable + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: ResourceGroup or the result of cls(response) + :rtype: ~azure.mgmt.resource.resources.v2019_05_01.models.ResourceGroup + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + async def update( + self, resource_group_name: str, parameters: IO, *, content_type: str = "application/json", **kwargs: Any + ) -> _models.ResourceGroup: + """Updates a resource group. + + Resource groups can be updated through a simple PATCH operation to a group address. The format + of the request is the same as that for creating a resource group. If a field is unspecified, + the current value is retained. + + :param resource_group_name: The name of the resource group to update. The name is case + insensitive. Required. + :type resource_group_name: str + :param parameters: Parameters supplied to update a resource group. Required. + :type parameters: IO + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: ResourceGroup or the result of cls(response) + :rtype: ~azure.mgmt.resource.resources.v2019_05_01.models.ResourceGroup + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace_async + async def update( + self, resource_group_name: str, parameters: Union[_models.ResourceGroupPatchable, IO], **kwargs: Any + ) -> _models.ResourceGroup: + """Updates a resource group. + + Resource groups can be updated through a simple PATCH operation to a group address. The format + of the request is the same as that for creating a resource group. If a field is unspecified, + the current value is retained. + + :param resource_group_name: The name of the resource group to update. The name is case + insensitive. Required. + :type resource_group_name: str + :param parameters: Parameters supplied to update a resource group. Is either a model type or a + IO type. Required. + :type parameters: ~azure.mgmt.resource.resources.v2019_05_01.models.ResourceGroupPatchable or + IO + :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. + Default value is None. + :paramtype content_type: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: ResourceGroup, or the result of cls(response) + :return: ResourceGroup or the result of cls(response) :rtype: ~azure.mgmt.resource.resources.v2019_05_01.models.ResourceGroup - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.ResourceGroup"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) - api_version = kwargs.pop('api_version', "2019-05-01") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - _json = self._serialize.body(parameters, 'ResourceGroupPatchable') + api_version = kwargs.pop("api_version", _params.pop("api-version", "2019-05-01")) # type: str + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.ResourceGroup] + + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(parameters, (IO, bytes)): + _content = parameters + else: + _json = self._serialize.body(parameters, "ResourceGroupPatchable") request = build_resource_groups_update_request( resource_group_name=resource_group_name, @@ -4123,60 +5450,117 @@ async def update( api_version=api_version, content_type=content_type, json=_json, - template_url=self.update.metadata['url'], + content=_content, + template_url=self.update.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) - deserialized = self._deserialize('ResourceGroup', pipeline_response) + deserialized = self._deserialize("ResourceGroup", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - update.metadata = {'url': "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}"} # type: ignore + update.metadata = {"url": "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}"} # type: ignore - - @distributed_trace_async + @overload async def export_template( self, resource_group_name: str, - parameters: "_models.ExportTemplateRequest", + parameters: _models.ExportTemplateRequest, + *, + content_type: str = "application/json", **kwargs: Any - ) -> "_models.ResourceGroupExportResult": + ) -> _models.ResourceGroupExportResult: """Captures the specified resource group as a template. - :param resource_group_name: The name of the resource group to export as a template. + :param resource_group_name: The name of the resource group to export as a template. Required. :type resource_group_name: str - :param parameters: Parameters for exporting the template. + :param parameters: Parameters for exporting the template. Required. :type parameters: ~azure.mgmt.resource.resources.v2019_05_01.models.ExportTemplateRequest + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: ResourceGroupExportResult or the result of cls(response) + :rtype: ~azure.mgmt.resource.resources.v2019_05_01.models.ResourceGroupExportResult + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + async def export_template( + self, resource_group_name: str, parameters: IO, *, content_type: str = "application/json", **kwargs: Any + ) -> _models.ResourceGroupExportResult: + """Captures the specified resource group as a template. + + :param resource_group_name: The name of the resource group to export as a template. Required. + :type resource_group_name: str + :param parameters: Parameters for exporting the template. Required. + :type parameters: IO + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: ResourceGroupExportResult or the result of cls(response) + :rtype: ~azure.mgmt.resource.resources.v2019_05_01.models.ResourceGroupExportResult + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace_async + async def export_template( + self, resource_group_name: str, parameters: Union[_models.ExportTemplateRequest, IO], **kwargs: Any + ) -> _models.ResourceGroupExportResult: + """Captures the specified resource group as a template. + + :param resource_group_name: The name of the resource group to export as a template. Required. + :type resource_group_name: str + :param parameters: Parameters for exporting the template. Is either a model type or a IO type. + Required. + :type parameters: ~azure.mgmt.resource.resources.v2019_05_01.models.ExportTemplateRequest or IO + :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. + Default value is None. + :paramtype content_type: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: ResourceGroupExportResult, or the result of cls(response) + :return: ResourceGroupExportResult or the result of cls(response) :rtype: ~azure.mgmt.resource.resources.v2019_05_01.models.ResourceGroupExportResult - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.ResourceGroupExportResult"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) - api_version = kwargs.pop('api_version', "2019-05-01") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - _json = self._serialize.body(parameters, 'ExportTemplateRequest') + api_version = kwargs.pop("api_version", _params.pop("api-version", "2019-05-01")) # type: str + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.ResourceGroupExportResult] + + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(parameters, (IO, bytes)): + _content = parameters + else: + _json = self._serialize.body(parameters, "ExportTemplateRequest") request = build_resource_groups_export_template_request( resource_group_name=resource_group_name, @@ -4184,39 +5568,37 @@ async def export_template( api_version=api_version, content_type=content_type, json=_json, - template_url=self.export_template.metadata['url'], + content=_content, + template_url=self.export_template.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) - deserialized = self._deserialize('ResourceGroupExportResult', pipeline_response) + deserialized = self._deserialize("ResourceGroupExportResult", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - export_template.metadata = {'url': "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/exportTemplate"} # type: ignore - + export_template.metadata = {"url": "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/exportTemplate"} # type: ignore @distributed_trace def list( - self, - filter: Optional[str] = None, - top: Optional[int] = None, - **kwargs: Any - ) -> AsyncIterable["_models.ResourceGroupListResult"]: + self, filter: Optional[str] = None, top: Optional[int] = None, **kwargs: Any + ) -> AsyncIterable["_models.ResourceGroup"]: """Gets all the resource groups for a subscription. :param filter: The filter to apply on the operation.:code:`
`:code:`
`You can filter by @@ -4227,40 +5609,48 @@ def list( Default value is None. :type top: int :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either ResourceGroupListResult or the result of - cls(response) + :return: An iterator like instance of either ResourceGroup or the result of cls(response) :rtype: - ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.resource.resources.v2019_05_01.models.ResourceGroupListResult] - :raises: ~azure.core.exceptions.HttpResponseError + ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.resource.resources.v2019_05_01.models.ResourceGroup] + :raises ~azure.core.exceptions.HttpResponseError: """ - api_version = kwargs.pop('api_version', "2019-05-01") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2019-05-01")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[_models.ResourceGroupListResult] - cls = kwargs.pop('cls', None) # type: ClsType["_models.ResourceGroupListResult"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) + def prepare_request(next_link=None): if not next_link: - + request = build_resource_groups_list_request( subscription_id=self._config.subscription_id, - api_version=api_version, filter=filter, top=top, - template_url=self.list.metadata['url'], + 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.url = self._client.format_url(request.url) # type: ignore else: - - request = build_resource_groups_list_request( - subscription_id=self._config.subscription_id, - template_url=next_link, - ) + # make call to next link with the client's api-version + _parsed_next_link = urlparse(next_link) + _next_request_params = case_insensitive_dict(parse_qs(_parsed_next_link.query)) + _next_request_params["api-version"] = self._config.api_version + request = HttpRequest("GET", urljoin(next_link, _parsed_next_link.path), params=_next_request_params) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore request.method = "GET" return request @@ -4274,10 +5664,8 @@ async def extract_data(pipeline_response): async def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) response = pipeline_response.http_response @@ -4287,75 +5675,75 @@ async def get_next(next_link=None): return pipeline_response + return AsyncItemPaged(get_next, extract_data) + + list.metadata = {"url": "/subscriptions/{subscriptionId}/resourcegroups"} # type: ignore - return AsyncItemPaged( - get_next, extract_data - ) - list.metadata = {'url': "/subscriptions/{subscriptionId}/resourcegroups"} # type: ignore -class TagsOperations: - """TagsOperations async operations. - You should not instantiate this class directly. Instead, you should create a Client instance that - instantiates it for you and attaches it as an attribute. +class TagsOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. - :ivar models: Alias to model classes used in this operation group. - :type models: ~azure.mgmt.resource.resources.v2019_05_01.models - :param client: Client for service requests. - :param config: Configuration of service client. - :param serializer: An object model serializer. - :param deserializer: An object model deserializer. + Instead, you should access the following operations through + :class:`~azure.mgmt.resource.resources.v2019_05_01.aio.ResourceManagementClient`'s + :attr:`tags` attribute. """ models = _models - def __init__(self, client, config, serializer, deserializer) -> None: - self._client = client - self._serialize = serializer - self._deserialize = deserializer - self._config = config + def __init__(self, *args, **kwargs) -> None: + input_args = list(args) + self._client = input_args.pop(0) if input_args else kwargs.pop("client") + self._config = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") @distributed_trace_async async def delete_value( # pylint: disable=inconsistent-return-statements - self, - tag_name: str, - tag_value: str, - **kwargs: Any + self, tag_name: str, tag_value: str, **kwargs: Any ) -> None: """Deletes a tag value. - :param tag_name: The name of the tag. + :param tag_name: The name of the tag. Required. :type tag_name: str - :param tag_value: The value of the tag to delete. + :param tag_value: The value of the tag to delete. Required. :type tag_value: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: None, or the result of cls(response) + :return: None or the result of cls(response) :rtype: None - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType[None] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) - api_version = kwargs.pop('api_version', "2019-05-01") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2019-05-01")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[None] - request = build_tags_delete_value_request( tag_name=tag_name, tag_value=tag_value, subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.delete_value.metadata['url'], + template_url=self.delete_value.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200, 204]: @@ -4365,51 +5753,51 @@ async def delete_value( # pylint: disable=inconsistent-return-statements if cls: return cls(pipeline_response, None, {}) - delete_value.metadata = {'url': "/subscriptions/{subscriptionId}/tagNames/{tagName}/tagValues/{tagValue}"} # type: ignore - + delete_value.metadata = {"url": "/subscriptions/{subscriptionId}/tagNames/{tagName}/tagValues/{tagValue}"} # type: ignore @distributed_trace_async - async def create_or_update_value( - self, - tag_name: str, - tag_value: str, - **kwargs: Any - ) -> "_models.TagValue": + async def create_or_update_value(self, tag_name: str, tag_value: str, **kwargs: Any) -> _models.TagValue: """Creates a tag value. The name of the tag must already exist. - :param tag_name: The name of the tag. + :param tag_name: The name of the tag. Required. :type tag_name: str - :param tag_value: The value of the tag to create. + :param tag_value: The value of the tag to create. Required. :type tag_value: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: TagValue, or the result of cls(response) + :return: TagValue or the result of cls(response) :rtype: ~azure.mgmt.resource.resources.v2019_05_01.models.TagValue - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.TagValue"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + 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', "2019-05-01") # type: str + api_version = kwargs.pop("api_version", _params.pop("api-version", "2019-05-01")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[_models.TagValue] - request = build_tags_create_or_update_value_request( tag_name=tag_name, tag_value=tag_value, subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.create_or_update_value.metadata['url'], + template_url=self.create_or_update_value.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200, 201]: @@ -4417,61 +5805,62 @@ async def create_or_update_value( raise HttpResponseError(response=response, error_format=ARMErrorFormat) if response.status_code == 200: - deserialized = self._deserialize('TagValue', pipeline_response) + deserialized = self._deserialize("TagValue", pipeline_response) if response.status_code == 201: - deserialized = self._deserialize('TagValue', pipeline_response) + deserialized = self._deserialize("TagValue", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - create_or_update_value.metadata = {'url': "/subscriptions/{subscriptionId}/tagNames/{tagName}/tagValues/{tagValue}"} # type: ignore - + create_or_update_value.metadata = {"url": "/subscriptions/{subscriptionId}/tagNames/{tagName}/tagValues/{tagValue}"} # type: ignore @distributed_trace_async - async def create_or_update( - self, - tag_name: str, - **kwargs: Any - ) -> "_models.TagDetails": + async def create_or_update(self, tag_name: str, **kwargs: Any) -> _models.TagDetails: """Creates a tag in the subscription. The tag name can have a maximum of 512 characters and is case insensitive. Tag names created by Azure have prefixes of microsoft, azure, or windows. You cannot create tags with one of these prefixes. - :param tag_name: The name of the tag to create. + :param tag_name: The name of the tag to create. Required. :type tag_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: TagDetails, or the result of cls(response) + :return: TagDetails or the result of cls(response) :rtype: ~azure.mgmt.resource.resources.v2019_05_01.models.TagDetails - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.TagDetails"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + 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', "2019-05-01") # type: str + api_version = kwargs.pop("api_version", _params.pop("api-version", "2019-05-01")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[_models.TagDetails] - request = build_tags_create_or_update_request( tag_name=tag_name, subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.create_or_update.metadata['url'], + template_url=self.create_or_update.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200, 201]: @@ -4479,59 +5868,60 @@ async def create_or_update( raise HttpResponseError(response=response, error_format=ARMErrorFormat) if response.status_code == 200: - deserialized = self._deserialize('TagDetails', pipeline_response) + deserialized = self._deserialize("TagDetails", pipeline_response) if response.status_code == 201: - deserialized = self._deserialize('TagDetails', pipeline_response) + deserialized = self._deserialize("TagDetails", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - create_or_update.metadata = {'url': "/subscriptions/{subscriptionId}/tagNames/{tagName}"} # type: ignore - + create_or_update.metadata = {"url": "/subscriptions/{subscriptionId}/tagNames/{tagName}"} # type: ignore @distributed_trace_async - async def delete( # pylint: disable=inconsistent-return-statements - self, - tag_name: str, - **kwargs: Any - ) -> None: + async def delete(self, tag_name: str, **kwargs: Any) -> None: # pylint: disable=inconsistent-return-statements """Deletes a tag from the subscription. You must remove all values from a resource tag before you can delete it. - :param tag_name: The name of the tag. + :param tag_name: The name of the tag. Required. :type tag_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: None, or the result of cls(response) + :return: None or the result of cls(response) :rtype: None - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType[None] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + 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', "2019-05-01") # type: str + api_version = kwargs.pop("api_version", _params.pop("api-version", "2019-05-01")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[None] - request = build_tags_delete_request( tag_name=tag_name, subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.delete.metadata['url'], + template_url=self.delete.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200, 204]: @@ -4541,48 +5931,53 @@ async def delete( # pylint: disable=inconsistent-return-statements if cls: return cls(pipeline_response, None, {}) - delete.metadata = {'url': "/subscriptions/{subscriptionId}/tagNames/{tagName}"} # type: ignore - + delete.metadata = {"url": "/subscriptions/{subscriptionId}/tagNames/{tagName}"} # type: ignore @distributed_trace - def list( - self, - **kwargs: Any - ) -> AsyncIterable["_models.TagsListResult"]: + def list(self, **kwargs: Any) -> AsyncIterable["_models.TagDetails"]: """Gets the names and values of all resource tags that are defined in a subscription. :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either TagsListResult or the result of cls(response) + :return: An iterator like instance of either TagDetails or the result of cls(response) :rtype: - ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.resource.resources.v2019_05_01.models.TagsListResult] - :raises: ~azure.core.exceptions.HttpResponseError + ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.resource.resources.v2019_05_01.models.TagDetails] + :raises ~azure.core.exceptions.HttpResponseError: """ - api_version = kwargs.pop('api_version', "2019-05-01") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2019-05-01")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[_models.TagsListResult] - cls = kwargs.pop('cls', None) # type: ClsType["_models.TagsListResult"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) + def prepare_request(next_link=None): if not next_link: - + request = build_tags_list_request( subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.list.metadata['url'], + template_url=self.list.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore else: - - request = build_tags_list_request( - subscription_id=self._config.subscription_id, - template_url=next_link, - ) + # make call to next link with the client's api-version + _parsed_next_link = urlparse(next_link) + _next_request_params = case_insensitive_dict(parse_qs(_parsed_next_link.query)) + _next_request_params["api-version"] = self._config.api_version + request = HttpRequest("GET", urljoin(next_link, _parsed_next_link.path), params=_next_request_params) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore request.method = "GET" return request @@ -4596,10 +5991,8 @@ async def extract_data(pipeline_response): async def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) response = pipeline_response.http_response @@ -4609,146 +6002,147 @@ async def get_next(next_link=None): return pipeline_response + return AsyncItemPaged(get_next, extract_data) - return AsyncItemPaged( - get_next, extract_data - ) - list.metadata = {'url': "/subscriptions/{subscriptionId}/tagNames"} # type: ignore -class DeploymentOperationsOperations: - """DeploymentOperationsOperations async operations. + list.metadata = {"url": "/subscriptions/{subscriptionId}/tagNames"} # type: ignore - You should not instantiate this class directly. Instead, you should create a Client instance that - instantiates it for you and attaches it as an attribute. - :ivar models: Alias to model classes used in this operation group. - :type models: ~azure.mgmt.resource.resources.v2019_05_01.models - :param client: Client for service requests. - :param config: Configuration of service client. - :param serializer: An object model serializer. - :param deserializer: An object model deserializer. +class DeploymentOperationsOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. + + Instead, you should access the following operations through + :class:`~azure.mgmt.resource.resources.v2019_05_01.aio.ResourceManagementClient`'s + :attr:`deployment_operations` attribute. """ models = _models - def __init__(self, client, config, serializer, deserializer) -> None: - self._client = client - self._serialize = serializer - self._deserialize = deserializer - self._config = config + def __init__(self, *args, **kwargs) -> None: + input_args = list(args) + self._client = input_args.pop(0) if input_args else kwargs.pop("client") + self._config = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") @distributed_trace_async async def get_at_management_group_scope( - self, - group_id: str, - deployment_name: str, - operation_id: str, - **kwargs: Any - ) -> "_models.DeploymentOperation": + self, group_id: str, deployment_name: str, operation_id: str, **kwargs: Any + ) -> _models.DeploymentOperation: """Gets a deployments operation. - :param group_id: The management group ID. + :param group_id: The management group ID. Required. :type group_id: str - :param deployment_name: The name of the deployment. + :param deployment_name: The name of the deployment. Required. :type deployment_name: str - :param operation_id: The ID of the operation to get. + :param operation_id: The ID of the operation to get. Required. :type operation_id: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: DeploymentOperation, or the result of cls(response) + :return: DeploymentOperation or the result of cls(response) :rtype: ~azure.mgmt.resource.resources.v2019_05_01.models.DeploymentOperation - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.DeploymentOperation"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + 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', "2019-05-01") # type: str + api_version = kwargs.pop("api_version", _params.pop("api-version", "2019-05-01")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[_models.DeploymentOperation] - request = build_deployment_operations_get_at_management_group_scope_request( group_id=group_id, deployment_name=deployment_name, operation_id=operation_id, api_version=api_version, - template_url=self.get_at_management_group_scope.metadata['url'], + template_url=self.get_at_management_group_scope.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) - deserialized = self._deserialize('DeploymentOperation', pipeline_response) + deserialized = self._deserialize("DeploymentOperation", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - get_at_management_group_scope.metadata = {'url': "/providers/Microsoft.Management/managementGroups/{groupId}/providers/Microsoft.Resources/deployments/{deploymentName}/operations/{operationId}"} # type: ignore - + get_at_management_group_scope.metadata = {"url": "/providers/Microsoft.Management/managementGroups/{groupId}/providers/Microsoft.Resources/deployments/{deploymentName}/operations/{operationId}"} # type: ignore @distributed_trace def list_at_management_group_scope( - self, - group_id: str, - deployment_name: str, - top: Optional[int] = None, - **kwargs: Any - ) -> AsyncIterable["_models.DeploymentOperationsListResult"]: + self, group_id: str, deployment_name: str, top: Optional[int] = None, **kwargs: Any + ) -> AsyncIterable["_models.DeploymentOperation"]: """Gets all deployments operations for a deployment. - :param group_id: The management group ID. + :param group_id: The management group ID. Required. :type group_id: str - :param deployment_name: The name of the deployment. + :param deployment_name: The name of the deployment. Required. :type deployment_name: str :param top: The number of results to return. Default value is None. :type top: int :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either DeploymentOperationsListResult or the result of - cls(response) + :return: An iterator like instance of either DeploymentOperation or the result of cls(response) :rtype: - ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.resource.resources.v2019_05_01.models.DeploymentOperationsListResult] - :raises: ~azure.core.exceptions.HttpResponseError + ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.resource.resources.v2019_05_01.models.DeploymentOperation] + :raises ~azure.core.exceptions.HttpResponseError: """ - api_version = kwargs.pop('api_version', "2019-05-01") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2019-05-01")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[_models.DeploymentOperationsListResult] - cls = kwargs.pop('cls', None) # type: ClsType["_models.DeploymentOperationsListResult"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) + def prepare_request(next_link=None): if not next_link: - + request = build_deployment_operations_list_at_management_group_scope_request( group_id=group_id, deployment_name=deployment_name, - api_version=api_version, top=top, - template_url=self.list_at_management_group_scope.metadata['url'], + api_version=api_version, + template_url=self.list_at_management_group_scope.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore else: - - request = build_deployment_operations_list_at_management_group_scope_request( - group_id=group_id, - deployment_name=deployment_name, - template_url=next_link, - ) + # make call to next link with the client's api-version + _parsed_next_link = urlparse(next_link) + _next_request_params = case_insensitive_dict(parse_qs(_parsed_next_link.query)) + _next_request_params["api-version"] = self._config.api_version + request = HttpRequest("GET", urljoin(next_link, _parsed_next_link.path), params=_next_request_params) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore request.method = "GET" return request @@ -4762,10 +6156,8 @@ async def extract_data(pipeline_response): async def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) response = pipeline_response.http_response @@ -4775,119 +6167,123 @@ async def get_next(next_link=None): return pipeline_response + return AsyncItemPaged(get_next, extract_data) - return AsyncItemPaged( - get_next, extract_data - ) - list_at_management_group_scope.metadata = {'url': "/providers/Microsoft.Management/managementGroups/{groupId}/providers/Microsoft.Resources/deployments/{deploymentName}/operations"} # type: ignore + list_at_management_group_scope.metadata = {"url": "/providers/Microsoft.Management/managementGroups/{groupId}/providers/Microsoft.Resources/deployments/{deploymentName}/operations"} # type: ignore @distributed_trace_async async def get_at_subscription_scope( - self, - deployment_name: str, - operation_id: str, - **kwargs: Any - ) -> "_models.DeploymentOperation": + self, deployment_name: str, operation_id: str, **kwargs: Any + ) -> _models.DeploymentOperation: """Gets a deployments operation. - :param deployment_name: The name of the deployment. + :param deployment_name: The name of the deployment. Required. :type deployment_name: str - :param operation_id: The ID of the operation to get. + :param operation_id: The ID of the operation to get. Required. :type operation_id: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: DeploymentOperation, or the result of cls(response) + :return: DeploymentOperation or the result of cls(response) :rtype: ~azure.mgmt.resource.resources.v2019_05_01.models.DeploymentOperation - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.DeploymentOperation"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) - api_version = kwargs.pop('api_version', "2019-05-01") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2019-05-01")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[_models.DeploymentOperation] - request = build_deployment_operations_get_at_subscription_scope_request( deployment_name=deployment_name, operation_id=operation_id, subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.get_at_subscription_scope.metadata['url'], + template_url=self.get_at_subscription_scope.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) - deserialized = self._deserialize('DeploymentOperation', pipeline_response) + deserialized = self._deserialize("DeploymentOperation", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - get_at_subscription_scope.metadata = {'url': "/subscriptions/{subscriptionId}/providers/Microsoft.Resources/deployments/{deploymentName}/operations/{operationId}"} # type: ignore - + get_at_subscription_scope.metadata = {"url": "/subscriptions/{subscriptionId}/providers/Microsoft.Resources/deployments/{deploymentName}/operations/{operationId}"} # type: ignore @distributed_trace def list_at_subscription_scope( - self, - deployment_name: str, - top: Optional[int] = None, - **kwargs: Any - ) -> AsyncIterable["_models.DeploymentOperationsListResult"]: + self, deployment_name: str, top: Optional[int] = None, **kwargs: Any + ) -> AsyncIterable["_models.DeploymentOperation"]: """Gets all deployments operations for a deployment. - :param deployment_name: The name of the deployment. + :param deployment_name: The name of the deployment. Required. :type deployment_name: str :param top: The number of results to return. Default value is None. :type top: int :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either DeploymentOperationsListResult or the result of - cls(response) + :return: An iterator like instance of either DeploymentOperation or the result of cls(response) :rtype: - ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.resource.resources.v2019_05_01.models.DeploymentOperationsListResult] - :raises: ~azure.core.exceptions.HttpResponseError + ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.resource.resources.v2019_05_01.models.DeploymentOperation] + :raises ~azure.core.exceptions.HttpResponseError: """ - api_version = kwargs.pop('api_version', "2019-05-01") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2019-05-01")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[_models.DeploymentOperationsListResult] - cls = kwargs.pop('cls', None) # type: ClsType["_models.DeploymentOperationsListResult"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) + def prepare_request(next_link=None): if not next_link: - + request = build_deployment_operations_list_at_subscription_scope_request( deployment_name=deployment_name, subscription_id=self._config.subscription_id, - api_version=api_version, top=top, - template_url=self.list_at_subscription_scope.metadata['url'], + api_version=api_version, + template_url=self.list_at_subscription_scope.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore else: - - request = build_deployment_operations_list_at_subscription_scope_request( - deployment_name=deployment_name, - subscription_id=self._config.subscription_id, - template_url=next_link, - ) + # make call to next link with the client's api-version + _parsed_next_link = urlparse(next_link) + _next_request_params = case_insensitive_dict(parse_qs(_parsed_next_link.query)) + _next_request_params["api-version"] = self._config.api_version + request = HttpRequest("GET", urljoin(next_link, _parsed_next_link.path), params=_next_request_params) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore request.method = "GET" return request @@ -4901,10 +6297,8 @@ async def extract_data(pipeline_response): async def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) response = pipeline_response.http_response @@ -4914,128 +6308,131 @@ async def get_next(next_link=None): return pipeline_response + return AsyncItemPaged(get_next, extract_data) - return AsyncItemPaged( - get_next, extract_data - ) - list_at_subscription_scope.metadata = {'url': "/subscriptions/{subscriptionId}/providers/Microsoft.Resources/deployments/{deploymentName}/operations"} # type: ignore + list_at_subscription_scope.metadata = {"url": "/subscriptions/{subscriptionId}/providers/Microsoft.Resources/deployments/{deploymentName}/operations"} # type: ignore @distributed_trace_async async def get( - self, - resource_group_name: str, - deployment_name: str, - operation_id: str, - **kwargs: Any - ) -> "_models.DeploymentOperation": + self, resource_group_name: str, deployment_name: str, operation_id: str, **kwargs: Any + ) -> _models.DeploymentOperation: """Gets a deployments operation. :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. :type resource_group_name: str - :param deployment_name: The name of the deployment. + :param deployment_name: The name of the deployment. Required. :type deployment_name: str - :param operation_id: The ID of the operation to get. + :param operation_id: The ID of the operation to get. Required. :type operation_id: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: DeploymentOperation, or the result of cls(response) + :return: DeploymentOperation or the result of cls(response) :rtype: ~azure.mgmt.resource.resources.v2019_05_01.models.DeploymentOperation - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.DeploymentOperation"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + 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', "2019-05-01") # type: str + api_version = kwargs.pop("api_version", _params.pop("api-version", "2019-05-01")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[_models.DeploymentOperation] - request = build_deployment_operations_get_request( resource_group_name=resource_group_name, deployment_name=deployment_name, operation_id=operation_id, subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.get.metadata['url'], + template_url=self.get.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) - deserialized = self._deserialize('DeploymentOperation', pipeline_response) + deserialized = self._deserialize("DeploymentOperation", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - get.metadata = {'url': "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/deployments/{deploymentName}/operations/{operationId}"} # type: ignore - + get.metadata = {"url": "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/deployments/{deploymentName}/operations/{operationId}"} # type: ignore @distributed_trace def list( - self, - resource_group_name: str, - deployment_name: str, - top: Optional[int] = None, - **kwargs: Any - ) -> AsyncIterable["_models.DeploymentOperationsListResult"]: + self, resource_group_name: str, deployment_name: str, top: Optional[int] = None, **kwargs: Any + ) -> AsyncIterable["_models.DeploymentOperation"]: """Gets all deployments operations for a deployment. :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. :type resource_group_name: str - :param deployment_name: The name of the deployment. + :param deployment_name: The name of the deployment. Required. :type deployment_name: str :param top: The number of results to return. Default value is None. :type top: int :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either DeploymentOperationsListResult or the result of - cls(response) + :return: An iterator like instance of either DeploymentOperation or the result of cls(response) :rtype: - ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.resource.resources.v2019_05_01.models.DeploymentOperationsListResult] - :raises: ~azure.core.exceptions.HttpResponseError + ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.resource.resources.v2019_05_01.models.DeploymentOperation] + :raises ~azure.core.exceptions.HttpResponseError: """ - api_version = kwargs.pop('api_version', "2019-05-01") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2019-05-01")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[_models.DeploymentOperationsListResult] - cls = kwargs.pop('cls', None) # type: ClsType["_models.DeploymentOperationsListResult"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) + def prepare_request(next_link=None): if not next_link: - + request = build_deployment_operations_list_request( resource_group_name=resource_group_name, deployment_name=deployment_name, subscription_id=self._config.subscription_id, - api_version=api_version, top=top, - template_url=self.list.metadata['url'], + 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.url = self._client.format_url(request.url) # type: ignore else: - - request = build_deployment_operations_list_request( - resource_group_name=resource_group_name, - deployment_name=deployment_name, - subscription_id=self._config.subscription_id, - template_url=next_link, - ) + # make call to next link with the client's api-version + _parsed_next_link = urlparse(next_link) + _next_request_params = case_insensitive_dict(parse_qs(_parsed_next_link.query)) + _next_request_params["api-version"] = self._config.api_version + request = HttpRequest("GET", urljoin(next_link, _parsed_next_link.path), params=_next_request_params) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore request.method = "GET" return request @@ -5049,10 +6446,8 @@ async def extract_data(pipeline_response): async def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) response = pipeline_response.http_response @@ -5062,8 +6457,6 @@ async def get_next(next_link=None): return pipeline_response + return AsyncItemPaged(get_next, extract_data) - return AsyncItemPaged( - get_next, extract_data - ) - list.metadata = {'url': "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/deployments/{deploymentName}/operations"} # type: ignore + list.metadata = {"url": "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/deployments/{deploymentName}/operations"} # type: ignore diff --git a/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/resources/v2019_05_01/aio/operations/_patch.py b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/resources/v2019_05_01/aio/operations/_patch.py new file mode 100644 index 0000000000000..f7dd32510333d --- /dev/null +++ b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/resources/v2019_05_01/aio/operations/_patch.py @@ -0,0 +1,20 @@ +# ------------------------------------ +# Copyright (c) Microsoft Corporation. +# Licensed under the MIT License. +# ------------------------------------ +"""Customize generated code here. + +Follow our quickstart for examples: https://aka.ms/azsdk/python/dpcodegen/python/customize +""" +from typing import List + +__all__: List[str] = [] # Add all objects you want publicly available to users at this package level + + +def patch_sdk(): + """Do not remove from this file. + + `patch_sdk` is a last resort escape hatch that allows you to do customizations + you can't accomplish using the techniques described in + https://aka.ms/azsdk/python/dpcodegen/python/customize + """ diff --git a/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/resources/v2019_05_01/models/__init__.py b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/resources/v2019_05_01/models/__init__.py index ce87b190b8862..39249f144291f 100644 --- a/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/resources/v2019_05_01/models/__init__.py +++ b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/resources/v2019_05_01/models/__init__.py @@ -63,71 +63,73 @@ from ._models_py3 import TemplateLink from ._models_py3 import ZoneMapping - -from ._resource_management_client_enums import ( - DeploymentMode, - OnErrorDeploymentType, - ResourceIdentityType, -) +from ._resource_management_client_enums import DeploymentMode +from ._resource_management_client_enums import OnErrorDeploymentType +from ._resource_management_client_enums import ResourceIdentityType +from ._patch import __all__ as _patch_all +from ._patch import * # type: ignore # pylint: disable=unused-wildcard-import +from ._patch import patch_sdk as _patch_sdk __all__ = [ - 'AliasPathType', - 'AliasType', - 'BasicDependency', - 'ComponentsSgqdofSchemasIdentityPropertiesUserassignedidentitiesAdditionalproperties', - 'DebugSetting', - 'Dependency', - 'Deployment', - 'DeploymentExportResult', - 'DeploymentExtended', - 'DeploymentExtendedFilter', - 'DeploymentListResult', - 'DeploymentOperation', - 'DeploymentOperationProperties', - 'DeploymentOperationsListResult', - 'DeploymentProperties', - 'DeploymentPropertiesExtended', - 'DeploymentValidateResult', - 'ErrorAdditionalInfo', - 'ErrorResponse', - 'ExportTemplateRequest', - 'GenericResource', - 'GenericResourceExpanded', - 'GenericResourceFilter', - 'HttpMessage', - 'Identity', - 'OnErrorDeployment', - 'OnErrorDeploymentExtended', - 'Operation', - 'OperationDisplay', - 'OperationListResult', - 'ParametersLink', - 'Plan', - 'Provider', - 'ProviderListResult', - 'ProviderResourceType', - 'Resource', - 'ResourceGroup', - 'ResourceGroupExportResult', - 'ResourceGroupFilter', - 'ResourceGroupListResult', - 'ResourceGroupPatchable', - 'ResourceGroupProperties', - 'ResourceListResult', - 'ResourceManagementErrorWithDetails', - 'ResourceProviderOperationDisplayProperties', - 'ResourcesMoveInfo', - 'Sku', - 'SubResource', - 'TagCount', - 'TagDetails', - 'TagValue', - 'TagsListResult', - 'TargetResource', - 'TemplateHashResult', - 'TemplateLink', - 'ZoneMapping', - 'DeploymentMode', - 'OnErrorDeploymentType', - 'ResourceIdentityType', + "AliasPathType", + "AliasType", + "BasicDependency", + "ComponentsSgqdofSchemasIdentityPropertiesUserassignedidentitiesAdditionalproperties", + "DebugSetting", + "Dependency", + "Deployment", + "DeploymentExportResult", + "DeploymentExtended", + "DeploymentExtendedFilter", + "DeploymentListResult", + "DeploymentOperation", + "DeploymentOperationProperties", + "DeploymentOperationsListResult", + "DeploymentProperties", + "DeploymentPropertiesExtended", + "DeploymentValidateResult", + "ErrorAdditionalInfo", + "ErrorResponse", + "ExportTemplateRequest", + "GenericResource", + "GenericResourceExpanded", + "GenericResourceFilter", + "HttpMessage", + "Identity", + "OnErrorDeployment", + "OnErrorDeploymentExtended", + "Operation", + "OperationDisplay", + "OperationListResult", + "ParametersLink", + "Plan", + "Provider", + "ProviderListResult", + "ProviderResourceType", + "Resource", + "ResourceGroup", + "ResourceGroupExportResult", + "ResourceGroupFilter", + "ResourceGroupListResult", + "ResourceGroupPatchable", + "ResourceGroupProperties", + "ResourceListResult", + "ResourceManagementErrorWithDetails", + "ResourceProviderOperationDisplayProperties", + "ResourcesMoveInfo", + "Sku", + "SubResource", + "TagCount", + "TagDetails", + "TagValue", + "TagsListResult", + "TargetResource", + "TemplateHashResult", + "TemplateLink", + "ZoneMapping", + "DeploymentMode", + "OnErrorDeploymentType", + "ResourceIdentityType", ] +__all__.extend([p for p in _patch_all if p not in __all__]) +_patch_sdk() diff --git a/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/resources/v2019_05_01/models/_models_py3.py b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/resources/v2019_05_01/models/_models_py3.py index 67e663f37b107..cc4b6bb13326a 100644 --- a/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/resources/v2019_05_01/models/_models_py3.py +++ b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/resources/v2019_05_01/models/_models_py3.py @@ -1,4 +1,5 @@ # coding=utf-8 +# pylint: disable=too-many-lines # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. # Licensed under the MIT License. See License.txt in the project root for license information. @@ -6,14 +7,22 @@ # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -from typing import Any, Dict, List, Optional, Union +import sys +from typing import Any, Dict, List, Optional, TYPE_CHECKING, Union -import msrest.serialization +from ... import _serialization -from ._resource_management_client_enums import * +if TYPE_CHECKING: + # pylint: disable=unused-import,ungrouped-imports + from .. import models as _models +if sys.version_info >= (3, 9): + from collections.abc import MutableMapping +else: + from typing import MutableMapping # type: ignore # pylint: disable=ungrouped-imports +JSON = MutableMapping[str, Any] # pylint: disable=unsubscriptable-object -class AliasPathType(msrest.serialization.Model): +class AliasPathType(_serialization.Model): """The type of the paths for alias. :ivar path: The path of an alias. @@ -23,29 +32,23 @@ class AliasPathType(msrest.serialization.Model): """ _attribute_map = { - 'path': {'key': 'path', 'type': 'str'}, - 'api_versions': {'key': 'apiVersions', 'type': '[str]'}, + "path": {"key": "path", "type": "str"}, + "api_versions": {"key": "apiVersions", "type": "[str]"}, } - def __init__( - self, - *, - path: Optional[str] = None, - api_versions: Optional[List[str]] = None, - **kwargs - ): + def __init__(self, *, path: Optional[str] = None, api_versions: Optional[List[str]] = None, **kwargs): """ :keyword path: The path of an alias. :paramtype path: str :keyword api_versions: The API versions. :paramtype api_versions: list[str] """ - super(AliasPathType, self).__init__(**kwargs) + super().__init__(**kwargs) self.path = path self.api_versions = api_versions -class AliasType(msrest.serialization.Model): +class AliasType(_serialization.Model): """The alias type. :ivar name: The alias name. @@ -55,29 +58,23 @@ class AliasType(msrest.serialization.Model): """ _attribute_map = { - 'name': {'key': 'name', 'type': 'str'}, - 'paths': {'key': 'paths', 'type': '[AliasPathType]'}, + "name": {"key": "name", "type": "str"}, + "paths": {"key": "paths", "type": "[AliasPathType]"}, } - def __init__( - self, - *, - name: Optional[str] = None, - paths: Optional[List["AliasPathType"]] = None, - **kwargs - ): + def __init__(self, *, name: Optional[str] = None, paths: Optional[List["_models.AliasPathType"]] = None, **kwargs): """ :keyword name: The alias name. :paramtype name: str :keyword paths: The paths for an alias. :paramtype paths: list[~azure.mgmt.resource.resources.v2019_05_01.models.AliasPathType] """ - super(AliasType, self).__init__(**kwargs) + super().__init__(**kwargs) self.name = name self.paths = paths -class BasicDependency(msrest.serialization.Model): +class BasicDependency(_serialization.Model): """Deployment dependency information. :ivar id: The ID of the dependency. @@ -89,15 +86,15 @@ class BasicDependency(msrest.serialization.Model): """ _attribute_map = { - 'id': {'key': 'id', 'type': 'str'}, - 'resource_type': {'key': 'resourceType', 'type': 'str'}, - 'resource_name': {'key': 'resourceName', 'type': 'str'}, + "id": {"key": "id", "type": "str"}, + "resource_type": {"key": "resourceType", "type": "str"}, + "resource_name": {"key": "resourceName", "type": "str"}, } def __init__( self, *, - id: Optional[str] = None, + id: Optional[str] = None, # pylint: disable=redefined-builtin resource_type: Optional[str] = None, resource_name: Optional[str] = None, **kwargs @@ -110,13 +107,13 @@ def __init__( :keyword resource_name: The dependency resource name. :paramtype resource_name: str """ - super(BasicDependency, self).__init__(**kwargs) + super().__init__(**kwargs) self.id = id self.resource_type = resource_type self.resource_name = resource_name -class ComponentsSgqdofSchemasIdentityPropertiesUserassignedidentitiesAdditionalproperties(msrest.serialization.Model): +class ComponentsSgqdofSchemasIdentityPropertiesUserassignedidentitiesAdditionalproperties(_serialization.Model): """ComponentsSgqdofSchemasIdentityPropertiesUserassignedidentitiesAdditionalproperties. Variables are only populated by the server, and will be ignored when sending a request. @@ -128,27 +125,23 @@ class ComponentsSgqdofSchemasIdentityPropertiesUserassignedidentitiesAdditionalp """ _validation = { - 'principal_id': {'readonly': True}, - 'client_id': {'readonly': True}, + "principal_id": {"readonly": True}, + "client_id": {"readonly": True}, } _attribute_map = { - 'principal_id': {'key': 'principalId', 'type': 'str'}, - 'client_id': {'key': 'clientId', 'type': 'str'}, + "principal_id": {"key": "principalId", "type": "str"}, + "client_id": {"key": "clientId", "type": "str"}, } - def __init__( - self, - **kwargs - ): - """ - """ - super(ComponentsSgqdofSchemasIdentityPropertiesUserassignedidentitiesAdditionalproperties, self).__init__(**kwargs) + def __init__(self, **kwargs): + """ """ + super().__init__(**kwargs) self.principal_id = None self.client_id = None -class DebugSetting(msrest.serialization.Model): +class DebugSetting(_serialization.Model): """The debug setting. :ivar detail_level: Specifies the type of information to log for debugging. The permitted @@ -161,15 +154,10 @@ class DebugSetting(msrest.serialization.Model): """ _attribute_map = { - 'detail_level': {'key': 'detailLevel', 'type': 'str'}, + "detail_level": {"key": "detailLevel", "type": "str"}, } - def __init__( - self, - *, - detail_level: Optional[str] = None, - **kwargs - ): + def __init__(self, *, detail_level: Optional[str] = None, **kwargs): """ :keyword detail_level: Specifies the type of information to log for debugging. The permitted values are none, requestContent, responseContent, or both requestContent and responseContent @@ -179,11 +167,11 @@ def __init__( deployment operations. :paramtype detail_level: str """ - super(DebugSetting, self).__init__(**kwargs) + super().__init__(**kwargs) self.detail_level = detail_level -class Dependency(msrest.serialization.Model): +class Dependency(_serialization.Model): """Deployment dependency information. :ivar depends_on: The list of dependencies. @@ -197,17 +185,17 @@ class Dependency(msrest.serialization.Model): """ _attribute_map = { - 'depends_on': {'key': 'dependsOn', 'type': '[BasicDependency]'}, - 'id': {'key': 'id', 'type': 'str'}, - 'resource_type': {'key': 'resourceType', 'type': 'str'}, - 'resource_name': {'key': 'resourceName', 'type': 'str'}, + "depends_on": {"key": "dependsOn", "type": "[BasicDependency]"}, + "id": {"key": "id", "type": "str"}, + "resource_type": {"key": "resourceType", "type": "str"}, + "resource_name": {"key": "resourceName", "type": "str"}, } def __init__( self, *, - depends_on: Optional[List["BasicDependency"]] = None, - id: Optional[str] = None, + depends_on: Optional[List["_models.BasicDependency"]] = None, + id: Optional[str] = None, # pylint: disable=redefined-builtin resource_type: Optional[str] = None, resource_name: Optional[str] = None, **kwargs @@ -222,77 +210,66 @@ def __init__( :keyword resource_name: The dependency resource name. :paramtype resource_name: str """ - super(Dependency, self).__init__(**kwargs) + super().__init__(**kwargs) self.depends_on = depends_on self.id = id self.resource_type = resource_type self.resource_name = resource_name -class Deployment(msrest.serialization.Model): +class Deployment(_serialization.Model): """Deployment operation parameters. All required parameters must be populated in order to send to Azure. :ivar location: The location to store the deployment data. :vartype location: str - :ivar properties: Required. The deployment properties. + :ivar properties: The deployment properties. Required. :vartype properties: ~azure.mgmt.resource.resources.v2019_05_01.models.DeploymentProperties """ _validation = { - 'properties': {'required': True}, + "properties": {"required": True}, } _attribute_map = { - 'location': {'key': 'location', 'type': 'str'}, - 'properties': {'key': 'properties', 'type': 'DeploymentProperties'}, + "location": {"key": "location", "type": "str"}, + "properties": {"key": "properties", "type": "DeploymentProperties"}, } - def __init__( - self, - *, - properties: "DeploymentProperties", - location: Optional[str] = None, - **kwargs - ): + def __init__(self, *, properties: "_models.DeploymentProperties", location: Optional[str] = None, **kwargs): """ :keyword location: The location to store the deployment data. :paramtype location: str - :keyword properties: Required. The deployment properties. + :keyword properties: The deployment properties. Required. :paramtype properties: ~azure.mgmt.resource.resources.v2019_05_01.models.DeploymentProperties """ - super(Deployment, self).__init__(**kwargs) + super().__init__(**kwargs) self.location = location self.properties = properties -class DeploymentExportResult(msrest.serialization.Model): +class DeploymentExportResult(_serialization.Model): """The deployment export result. :ivar template: The template content. - :vartype template: any + :vartype template: JSON """ _attribute_map = { - 'template': {'key': 'template', 'type': 'object'}, + "template": {"key": "template", "type": "object"}, } - def __init__( - self, - *, - template: Optional[Any] = None, - **kwargs - ): + def __init__(self, *, template: Optional[JSON] = None, **kwargs): """ :keyword template: The template content. - :paramtype template: any + :paramtype template: JSON """ - super(DeploymentExportResult, self).__init__(**kwargs) + super().__init__(**kwargs) self.template = template -class DeploymentExtended(msrest.serialization.Model): +class DeploymentExtended(_serialization.Model): """Deployment information. Variables are only populated by the server, and will be ignored when sending a request. @@ -311,24 +288,24 @@ class DeploymentExtended(msrest.serialization.Model): """ _validation = { - 'id': {'readonly': True}, - 'name': {'readonly': True}, - 'type': {'readonly': True}, + "id": {"readonly": True}, + "name": {"readonly": True}, + "type": {"readonly": True}, } _attribute_map = { - 'id': {'key': 'id', 'type': 'str'}, - 'name': {'key': 'name', 'type': 'str'}, - 'type': {'key': 'type', 'type': 'str'}, - 'location': {'key': 'location', 'type': 'str'}, - 'properties': {'key': 'properties', 'type': 'DeploymentPropertiesExtended'}, + "id": {"key": "id", "type": "str"}, + "name": {"key": "name", "type": "str"}, + "type": {"key": "type", "type": "str"}, + "location": {"key": "location", "type": "str"}, + "properties": {"key": "properties", "type": "DeploymentPropertiesExtended"}, } def __init__( self, *, location: Optional[str] = None, - properties: Optional["DeploymentPropertiesExtended"] = None, + properties: Optional["_models.DeploymentPropertiesExtended"] = None, **kwargs ): """ @@ -338,7 +315,7 @@ def __init__( :paramtype properties: ~azure.mgmt.resource.resources.v2019_05_01.models.DeploymentPropertiesExtended """ - super(DeploymentExtended, self).__init__(**kwargs) + super().__init__(**kwargs) self.id = None self.name = None self.type = None @@ -346,7 +323,7 @@ def __init__( self.properties = properties -class DeploymentExtendedFilter(msrest.serialization.Model): +class DeploymentExtendedFilter(_serialization.Model): """Deployment filter. :ivar provisioning_state: The provisioning state. @@ -354,24 +331,19 @@ class DeploymentExtendedFilter(msrest.serialization.Model): """ _attribute_map = { - 'provisioning_state': {'key': 'provisioningState', 'type': 'str'}, + "provisioning_state": {"key": "provisioningState", "type": "str"}, } - def __init__( - self, - *, - provisioning_state: Optional[str] = None, - **kwargs - ): + def __init__(self, *, provisioning_state: Optional[str] = None, **kwargs): """ :keyword provisioning_state: The provisioning state. :paramtype provisioning_state: str """ - super(DeploymentExtendedFilter, self).__init__(**kwargs) + super().__init__(**kwargs) self.provisioning_state = provisioning_state -class DeploymentListResult(msrest.serialization.Model): +class DeploymentListResult(_serialization.Model): """List of deployments. Variables are only populated by the server, and will be ignored when sending a request. @@ -383,30 +355,25 @@ class DeploymentListResult(msrest.serialization.Model): """ _validation = { - 'next_link': {'readonly': True}, + "next_link": {"readonly": True}, } _attribute_map = { - 'value': {'key': 'value', 'type': '[DeploymentExtended]'}, - 'next_link': {'key': 'nextLink', 'type': 'str'}, + "value": {"key": "value", "type": "[DeploymentExtended]"}, + "next_link": {"key": "nextLink", "type": "str"}, } - def __init__( - self, - *, - value: Optional[List["DeploymentExtended"]] = None, - **kwargs - ): + def __init__(self, *, value: Optional[List["_models.DeploymentExtended"]] = None, **kwargs): """ :keyword value: An array of deployments. :paramtype value: list[~azure.mgmt.resource.resources.v2019_05_01.models.DeploymentExtended] """ - super(DeploymentListResult, self).__init__(**kwargs) + super().__init__(**kwargs) self.value = value self.next_link = None -class DeploymentOperation(msrest.serialization.Model): +class DeploymentOperation(_serialization.Model): """Deployment operation information. Variables are only populated by the server, and will be ignored when sending a request. @@ -421,34 +388,29 @@ class DeploymentOperation(msrest.serialization.Model): """ _validation = { - 'id': {'readonly': True}, - 'operation_id': {'readonly': True}, + "id": {"readonly": True}, + "operation_id": {"readonly": True}, } _attribute_map = { - 'id': {'key': 'id', 'type': 'str'}, - 'operation_id': {'key': 'operationId', 'type': 'str'}, - 'properties': {'key': 'properties', 'type': 'DeploymentOperationProperties'}, + "id": {"key": "id", "type": "str"}, + "operation_id": {"key": "operationId", "type": "str"}, + "properties": {"key": "properties", "type": "DeploymentOperationProperties"}, } - def __init__( - self, - *, - properties: Optional["DeploymentOperationProperties"] = None, - **kwargs - ): + def __init__(self, *, properties: Optional["_models.DeploymentOperationProperties"] = None, **kwargs): """ :keyword properties: Deployment properties. :paramtype properties: ~azure.mgmt.resource.resources.v2019_05_01.models.DeploymentOperationProperties """ - super(DeploymentOperation, self).__init__(**kwargs) + super().__init__(**kwargs) self.id = None self.operation_id = None self.properties = properties -class DeploymentOperationProperties(msrest.serialization.Model): +class DeploymentOperationProperties(_serialization.Model): """Deployment operation properties. Variables are only populated by the server, and will be ignored when sending a request. @@ -464,7 +426,7 @@ class DeploymentOperationProperties(msrest.serialization.Model): :ivar status_code: Operation status code. :vartype status_code: str :ivar status_message: Operation status message. - :vartype status_message: any + :vartype status_message: JSON :ivar target_resource: The target resource. :vartype target_resource: ~azure.mgmt.resource.resources.v2019_05_01.models.TargetResource :ivar request: The HTTP request message. @@ -474,36 +436,32 @@ class DeploymentOperationProperties(msrest.serialization.Model): """ _validation = { - 'provisioning_state': {'readonly': True}, - 'timestamp': {'readonly': True}, - 'duration': {'readonly': True}, - 'service_request_id': {'readonly': True}, - 'status_code': {'readonly': True}, - 'status_message': {'readonly': True}, - 'target_resource': {'readonly': True}, - 'request': {'readonly': True}, - 'response': {'readonly': True}, + "provisioning_state": {"readonly": True}, + "timestamp": {"readonly": True}, + "duration": {"readonly": True}, + "service_request_id": {"readonly": True}, + "status_code": {"readonly": True}, + "status_message": {"readonly": True}, + "target_resource": {"readonly": True}, + "request": {"readonly": True}, + "response": {"readonly": True}, } _attribute_map = { - 'provisioning_state': {'key': 'provisioningState', 'type': 'str'}, - 'timestamp': {'key': 'timestamp', 'type': 'iso-8601'}, - 'duration': {'key': 'duration', 'type': 'str'}, - 'service_request_id': {'key': 'serviceRequestId', 'type': 'str'}, - 'status_code': {'key': 'statusCode', 'type': 'str'}, - 'status_message': {'key': 'statusMessage', 'type': 'object'}, - 'target_resource': {'key': 'targetResource', 'type': 'TargetResource'}, - 'request': {'key': 'request', 'type': 'HttpMessage'}, - 'response': {'key': 'response', 'type': 'HttpMessage'}, - } - - def __init__( - self, - **kwargs - ): - """ - """ - super(DeploymentOperationProperties, self).__init__(**kwargs) + "provisioning_state": {"key": "provisioningState", "type": "str"}, + "timestamp": {"key": "timestamp", "type": "iso-8601"}, + "duration": {"key": "duration", "type": "str"}, + "service_request_id": {"key": "serviceRequestId", "type": "str"}, + "status_code": {"key": "statusCode", "type": "str"}, + "status_message": {"key": "statusMessage", "type": "object"}, + "target_resource": {"key": "targetResource", "type": "TargetResource"}, + "request": {"key": "request", "type": "HttpMessage"}, + "response": {"key": "response", "type": "HttpMessage"}, + } + + def __init__(self, **kwargs): + """ """ + super().__init__(**kwargs) self.provisioning_state = None self.timestamp = None self.duration = None @@ -515,7 +473,7 @@ def __init__( self.response = None -class DeploymentOperationsListResult(msrest.serialization.Model): +class DeploymentOperationsListResult(_serialization.Model): """List of deployment operations. Variables are only populated by the server, and will be ignored when sending a request. @@ -527,30 +485,25 @@ class DeploymentOperationsListResult(msrest.serialization.Model): """ _validation = { - 'next_link': {'readonly': True}, + "next_link": {"readonly": True}, } _attribute_map = { - 'value': {'key': 'value', 'type': '[DeploymentOperation]'}, - 'next_link': {'key': 'nextLink', 'type': 'str'}, + "value": {"key": "value", "type": "[DeploymentOperation]"}, + "next_link": {"key": "nextLink", "type": "str"}, } - def __init__( - self, - *, - value: Optional[List["DeploymentOperation"]] = None, - **kwargs - ): + def __init__(self, *, value: Optional[List["_models.DeploymentOperation"]] = None, **kwargs): """ :keyword value: An array of deployment operations. :paramtype value: list[~azure.mgmt.resource.resources.v2019_05_01.models.DeploymentOperation] """ - super(DeploymentOperationsListResult, self).__init__(**kwargs) + super().__init__(**kwargs) self.value = value self.next_link = None -class DeploymentProperties(msrest.serialization.Model): +class DeploymentProperties(_serialization.Model): """Deployment properties. All required parameters must be populated in order to send to Azure. @@ -559,7 +512,7 @@ class DeploymentProperties(msrest.serialization.Model): syntax directly in the request rather than link to an existing template. It can be a JObject or well-formed JSON string. Use either the templateLink property or the template property, but not both. - :vartype template: any + :vartype template: JSON :ivar template_link: The URI of the template. Use either the templateLink property or the template property, but not both. :vartype template_link: ~azure.mgmt.resource.resources.v2019_05_01.models.TemplateLink @@ -567,17 +520,17 @@ class DeploymentProperties(msrest.serialization.Model): You use this element when you want to provide the parameter values directly in the request rather than link to an existing parameter file. Use either the parametersLink property or the parameters property, but not both. It can be a JObject or a well formed JSON string. - :vartype parameters: any + :vartype parameters: JSON :ivar parameters_link: The URI of parameters file. You use this element to link to an existing parameters file. Use either the parametersLink property or the parameters property, but not both. :vartype parameters_link: ~azure.mgmt.resource.resources.v2019_05_01.models.ParametersLink - :ivar mode: Required. The mode that is used to deploy resources. This value can be either - Incremental or Complete. In Incremental mode, resources are deployed without deleting existing - resources that are not included in the template. In Complete mode, resources are deployed and - existing resources in the resource group that are not included in the template are deleted. Be - careful when using Complete mode as you may unintentionally delete resources. Possible values - include: "Incremental", "Complete". + :ivar mode: The mode that is used to deploy resources. This value can be either Incremental or + Complete. In Incremental mode, resources are deployed without deleting existing resources that + are not included in the template. In Complete mode, resources are deployed and existing + resources in the resource group that are not included in the template are deleted. Be careful + when using Complete mode as you may unintentionally delete resources. Required. Known values + are: "Incremental" and "Complete". :vartype mode: str or ~azure.mgmt.resource.resources.v2019_05_01.models.DeploymentMode :ivar debug_setting: The debug setting of the deployment. :vartype debug_setting: ~azure.mgmt.resource.resources.v2019_05_01.models.DebugSetting @@ -587,29 +540,29 @@ class DeploymentProperties(msrest.serialization.Model): """ _validation = { - 'mode': {'required': True}, + "mode": {"required": True}, } _attribute_map = { - 'template': {'key': 'template', 'type': 'object'}, - 'template_link': {'key': 'templateLink', 'type': 'TemplateLink'}, - 'parameters': {'key': 'parameters', 'type': 'object'}, - 'parameters_link': {'key': 'parametersLink', 'type': 'ParametersLink'}, - 'mode': {'key': 'mode', 'type': 'str'}, - 'debug_setting': {'key': 'debugSetting', 'type': 'DebugSetting'}, - 'on_error_deployment': {'key': 'onErrorDeployment', 'type': 'OnErrorDeployment'}, + "template": {"key": "template", "type": "object"}, + "template_link": {"key": "templateLink", "type": "TemplateLink"}, + "parameters": {"key": "parameters", "type": "object"}, + "parameters_link": {"key": "parametersLink", "type": "ParametersLink"}, + "mode": {"key": "mode", "type": "str"}, + "debug_setting": {"key": "debugSetting", "type": "DebugSetting"}, + "on_error_deployment": {"key": "onErrorDeployment", "type": "OnErrorDeployment"}, } def __init__( self, *, - mode: Union[str, "DeploymentMode"], - template: Optional[Any] = None, - template_link: Optional["TemplateLink"] = None, - parameters: Optional[Any] = None, - parameters_link: Optional["ParametersLink"] = None, - debug_setting: Optional["DebugSetting"] = None, - on_error_deployment: Optional["OnErrorDeployment"] = None, + mode: Union[str, "_models.DeploymentMode"], + template: Optional[JSON] = None, + template_link: Optional["_models.TemplateLink"] = None, + parameters: Optional[JSON] = None, + parameters_link: Optional["_models.ParametersLink"] = None, + debug_setting: Optional["_models.DebugSetting"] = None, + on_error_deployment: Optional["_models.OnErrorDeployment"] = None, **kwargs ): """ @@ -617,7 +570,7 @@ def __init__( template syntax directly in the request rather than link to an existing template. It can be a JObject or well-formed JSON string. Use either the templateLink property or the template property, but not both. - :paramtype template: any + :paramtype template: JSON :keyword template_link: The URI of the template. Use either the templateLink property or the template property, but not both. :paramtype template_link: ~azure.mgmt.resource.resources.v2019_05_01.models.TemplateLink @@ -625,17 +578,17 @@ def __init__( template. You use this element when you want to provide the parameter values directly in the request rather than link to an existing parameter file. Use either the parametersLink property or the parameters property, but not both. It can be a JObject or a well formed JSON string. - :paramtype parameters: any + :paramtype parameters: JSON :keyword parameters_link: The URI of parameters file. You use this element to link to an existing parameters file. Use either the parametersLink property or the parameters property, but not both. :paramtype parameters_link: ~azure.mgmt.resource.resources.v2019_05_01.models.ParametersLink - :keyword mode: Required. The mode that is used to deploy resources. This value can be either - Incremental or Complete. In Incremental mode, resources are deployed without deleting existing - resources that are not included in the template. In Complete mode, resources are deployed and - existing resources in the resource group that are not included in the template are deleted. Be - careful when using Complete mode as you may unintentionally delete resources. Possible values - include: "Incremental", "Complete". + :keyword mode: The mode that is used to deploy resources. This value can be either Incremental + or Complete. In Incremental mode, resources are deployed without deleting existing resources + that are not included in the template. In Complete mode, resources are deployed and existing + resources in the resource group that are not included in the template are deleted. Be careful + when using Complete mode as you may unintentionally delete resources. Required. Known values + are: "Incremental" and "Complete". :paramtype mode: str or ~azure.mgmt.resource.resources.v2019_05_01.models.DeploymentMode :keyword debug_setting: The debug setting of the deployment. :paramtype debug_setting: ~azure.mgmt.resource.resources.v2019_05_01.models.DebugSetting @@ -643,7 +596,7 @@ def __init__( :paramtype on_error_deployment: ~azure.mgmt.resource.resources.v2019_05_01.models.OnErrorDeployment """ - super(DeploymentProperties, self).__init__(**kwargs) + super().__init__(**kwargs) self.template = template self.template_link = template_link self.parameters = parameters @@ -653,7 +606,7 @@ def __init__( self.on_error_deployment = on_error_deployment -class DeploymentPropertiesExtended(msrest.serialization.Model): +class DeploymentPropertiesExtended(_serialization.Model): # pylint: disable=too-many-instance-attributes """Deployment properties with additional details. Variables are only populated by the server, and will be ignored when sending a request. @@ -667,23 +620,23 @@ class DeploymentPropertiesExtended(msrest.serialization.Model): :ivar duration: The duration of the template deployment. :vartype duration: str :ivar outputs: Key/value pairs that represent deployment output. - :vartype outputs: any + :vartype outputs: JSON :ivar providers: The list of resource providers needed for the deployment. :vartype providers: list[~azure.mgmt.resource.resources.v2019_05_01.models.Provider] :ivar dependencies: The list of deployment dependencies. :vartype dependencies: list[~azure.mgmt.resource.resources.v2019_05_01.models.Dependency] :ivar template: The template content. Use only one of Template or TemplateLink. - :vartype template: any + :vartype template: JSON :ivar template_link: The URI referencing the template. Use only one of Template or TemplateLink. :vartype template_link: ~azure.mgmt.resource.resources.v2019_05_01.models.TemplateLink :ivar parameters: Deployment parameters. Use only one of Parameters or ParametersLink. - :vartype parameters: any + :vartype parameters: JSON :ivar parameters_link: The URI referencing the parameters. Use only one of Parameters or ParametersLink. :vartype parameters_link: ~azure.mgmt.resource.resources.v2019_05_01.models.ParametersLink - :ivar mode: The deployment mode. Possible values are Incremental and Complete. Possible values - include: "Incremental", "Complete". + :ivar mode: The deployment mode. Possible values are Incremental and Complete. Known values + are: "Incremental" and "Complete". :vartype mode: str or ~azure.mgmt.resource.resources.v2019_05_01.models.DeploymentMode :ivar debug_setting: The debug setting of the deployment. :vartype debug_setting: ~azure.mgmt.resource.resources.v2019_05_01.models.DebugSetting @@ -695,65 +648,65 @@ class DeploymentPropertiesExtended(msrest.serialization.Model): """ _validation = { - 'provisioning_state': {'readonly': True}, - 'correlation_id': {'readonly': True}, - 'timestamp': {'readonly': True}, - 'duration': {'readonly': True}, - 'error': {'readonly': True}, + "provisioning_state": {"readonly": True}, + "correlation_id": {"readonly": True}, + "timestamp": {"readonly": True}, + "duration": {"readonly": True}, + "error": {"readonly": True}, } _attribute_map = { - 'provisioning_state': {'key': 'provisioningState', 'type': 'str'}, - 'correlation_id': {'key': 'correlationId', 'type': 'str'}, - 'timestamp': {'key': 'timestamp', 'type': 'iso-8601'}, - 'duration': {'key': 'duration', 'type': 'str'}, - 'outputs': {'key': 'outputs', 'type': 'object'}, - 'providers': {'key': 'providers', 'type': '[Provider]'}, - 'dependencies': {'key': 'dependencies', 'type': '[Dependency]'}, - 'template': {'key': 'template', 'type': 'object'}, - 'template_link': {'key': 'templateLink', 'type': 'TemplateLink'}, - 'parameters': {'key': 'parameters', 'type': 'object'}, - 'parameters_link': {'key': 'parametersLink', 'type': 'ParametersLink'}, - 'mode': {'key': 'mode', 'type': 'str'}, - 'debug_setting': {'key': 'debugSetting', 'type': 'DebugSetting'}, - 'on_error_deployment': {'key': 'onErrorDeployment', 'type': 'OnErrorDeploymentExtended'}, - 'error': {'key': 'error', 'type': 'ErrorResponse'}, + "provisioning_state": {"key": "provisioningState", "type": "str"}, + "correlation_id": {"key": "correlationId", "type": "str"}, + "timestamp": {"key": "timestamp", "type": "iso-8601"}, + "duration": {"key": "duration", "type": "str"}, + "outputs": {"key": "outputs", "type": "object"}, + "providers": {"key": "providers", "type": "[Provider]"}, + "dependencies": {"key": "dependencies", "type": "[Dependency]"}, + "template": {"key": "template", "type": "object"}, + "template_link": {"key": "templateLink", "type": "TemplateLink"}, + "parameters": {"key": "parameters", "type": "object"}, + "parameters_link": {"key": "parametersLink", "type": "ParametersLink"}, + "mode": {"key": "mode", "type": "str"}, + "debug_setting": {"key": "debugSetting", "type": "DebugSetting"}, + "on_error_deployment": {"key": "onErrorDeployment", "type": "OnErrorDeploymentExtended"}, + "error": {"key": "error", "type": "ErrorResponse"}, } def __init__( self, *, - outputs: Optional[Any] = None, - providers: Optional[List["Provider"]] = None, - dependencies: Optional[List["Dependency"]] = None, - template: Optional[Any] = None, - template_link: Optional["TemplateLink"] = None, - parameters: Optional[Any] = None, - parameters_link: Optional["ParametersLink"] = None, - mode: Optional[Union[str, "DeploymentMode"]] = None, - debug_setting: Optional["DebugSetting"] = None, - on_error_deployment: Optional["OnErrorDeploymentExtended"] = None, + outputs: Optional[JSON] = None, + providers: Optional[List["_models.Provider"]] = None, + dependencies: Optional[List["_models.Dependency"]] = None, + template: Optional[JSON] = None, + template_link: Optional["_models.TemplateLink"] = None, + parameters: Optional[JSON] = None, + parameters_link: Optional["_models.ParametersLink"] = None, + mode: Optional[Union[str, "_models.DeploymentMode"]] = None, + debug_setting: Optional["_models.DebugSetting"] = None, + on_error_deployment: Optional["_models.OnErrorDeploymentExtended"] = None, **kwargs ): """ :keyword outputs: Key/value pairs that represent deployment output. - :paramtype outputs: any + :paramtype outputs: JSON :keyword providers: The list of resource providers needed for the deployment. :paramtype providers: list[~azure.mgmt.resource.resources.v2019_05_01.models.Provider] :keyword dependencies: The list of deployment dependencies. :paramtype dependencies: list[~azure.mgmt.resource.resources.v2019_05_01.models.Dependency] :keyword template: The template content. Use only one of Template or TemplateLink. - :paramtype template: any + :paramtype template: JSON :keyword template_link: The URI referencing the template. Use only one of Template or TemplateLink. :paramtype template_link: ~azure.mgmt.resource.resources.v2019_05_01.models.TemplateLink :keyword parameters: Deployment parameters. Use only one of Parameters or ParametersLink. - :paramtype parameters: any + :paramtype parameters: JSON :keyword parameters_link: The URI referencing the parameters. Use only one of Parameters or ParametersLink. :paramtype parameters_link: ~azure.mgmt.resource.resources.v2019_05_01.models.ParametersLink - :keyword mode: The deployment mode. Possible values are Incremental and Complete. Possible - values include: "Incremental", "Complete". + :keyword mode: The deployment mode. Possible values are Incremental and Complete. Known values + are: "Incremental" and "Complete". :paramtype mode: str or ~azure.mgmt.resource.resources.v2019_05_01.models.DeploymentMode :keyword debug_setting: The debug setting of the deployment. :paramtype debug_setting: ~azure.mgmt.resource.resources.v2019_05_01.models.DebugSetting @@ -761,7 +714,7 @@ def __init__( :paramtype on_error_deployment: ~azure.mgmt.resource.resources.v2019_05_01.models.OnErrorDeploymentExtended """ - super(DeploymentPropertiesExtended, self).__init__(**kwargs) + super().__init__(**kwargs) self.provisioning_state = None self.correlation_id = None self.timestamp = None @@ -779,7 +732,7 @@ def __init__( self.error = None -class DeploymentValidateResult(msrest.serialization.Model): +class DeploymentValidateResult(_serialization.Model): """Information from validate template deployment response. :ivar error: Validation error. @@ -791,15 +744,15 @@ class DeploymentValidateResult(msrest.serialization.Model): """ _attribute_map = { - 'error': {'key': 'error', 'type': 'ResourceManagementErrorWithDetails'}, - 'properties': {'key': 'properties', 'type': 'DeploymentPropertiesExtended'}, + "error": {"key": "error", "type": "ResourceManagementErrorWithDetails"}, + "properties": {"key": "properties", "type": "DeploymentPropertiesExtended"}, } def __init__( self, *, - error: Optional["ResourceManagementErrorWithDetails"] = None, - properties: Optional["DeploymentPropertiesExtended"] = None, + error: Optional["_models.ResourceManagementErrorWithDetails"] = None, + properties: Optional["_models.DeploymentPropertiesExtended"] = None, **kwargs ): """ @@ -810,12 +763,12 @@ def __init__( :paramtype properties: ~azure.mgmt.resource.resources.v2019_05_01.models.DeploymentPropertiesExtended """ - super(DeploymentValidateResult, self).__init__(**kwargs) + super().__init__(**kwargs) self.error = error self.properties = properties -class ErrorAdditionalInfo(msrest.serialization.Model): +class ErrorAdditionalInfo(_serialization.Model): """The resource management error additional info. Variables are only populated by the server, and will be ignored when sending a request. @@ -823,31 +776,27 @@ class ErrorAdditionalInfo(msrest.serialization.Model): :ivar type: The additional info type. :vartype type: str :ivar info: The additional info. - :vartype info: any + :vartype info: JSON """ _validation = { - 'type': {'readonly': True}, - 'info': {'readonly': True}, + "type": {"readonly": True}, + "info": {"readonly": True}, } _attribute_map = { - 'type': {'key': 'type', 'type': 'str'}, - 'info': {'key': 'info', 'type': 'object'}, + "type": {"key": "type", "type": "str"}, + "info": {"key": "info", "type": "object"}, } - def __init__( - self, - **kwargs - ): - """ - """ - super(ErrorAdditionalInfo, self).__init__(**kwargs) + def __init__(self, **kwargs): + """ """ + super().__init__(**kwargs) self.type = None self.info = None -class ErrorResponse(msrest.serialization.Model): +class ErrorResponse(_serialization.Model): """Common error response for all Azure Resource Manager APIs to return error details for failed operations. (This also follows the OData error response format.). Variables are only populated by the server, and will be ignored when sending a request. @@ -866,28 +815,24 @@ class ErrorResponse(msrest.serialization.Model): """ _validation = { - 'code': {'readonly': True}, - 'message': {'readonly': True}, - 'target': {'readonly': True}, - 'details': {'readonly': True}, - 'additional_info': {'readonly': True}, + "code": {"readonly": True}, + "message": {"readonly": True}, + "target": {"readonly": True}, + "details": {"readonly": True}, + "additional_info": {"readonly": True}, } _attribute_map = { - 'code': {'key': 'code', 'type': 'str'}, - 'message': {'key': 'message', 'type': 'str'}, - 'target': {'key': 'target', 'type': 'str'}, - 'details': {'key': 'details', 'type': '[ErrorResponse]'}, - 'additional_info': {'key': 'additionalInfo', 'type': '[ErrorAdditionalInfo]'}, + "code": {"key": "code", "type": "str"}, + "message": {"key": "message", "type": "str"}, + "target": {"key": "target", "type": "str"}, + "details": {"key": "details", "type": "[ErrorResponse]"}, + "additional_info": {"key": "additionalInfo", "type": "[ErrorAdditionalInfo]"}, } - def __init__( - self, - **kwargs - ): - """ - """ - super(ErrorResponse, self).__init__(**kwargs) + def __init__(self, **kwargs): + """ """ + super().__init__(**kwargs) self.code = None self.message = None self.target = None @@ -895,7 +840,7 @@ def __init__( self.additional_info = None -class ExportTemplateRequest(msrest.serialization.Model): +class ExportTemplateRequest(_serialization.Model): """Export resource group template request parameters. :ivar resources: The IDs of the resources to filter the export by. To export all resources, @@ -908,17 +853,11 @@ class ExportTemplateRequest(msrest.serialization.Model): """ _attribute_map = { - 'resources': {'key': 'resources', 'type': '[str]'}, - 'options': {'key': 'options', 'type': 'str'}, + "resources": {"key": "resources", "type": "[str]"}, + "options": {"key": "options", "type": "str"}, } - def __init__( - self, - *, - resources: Optional[List[str]] = None, - options: Optional[str] = None, - **kwargs - ): + def __init__(self, *, resources: Optional[List[str]] = None, options: Optional[str] = None, **kwargs): """ :keyword resources: The IDs of the resources to filter the export by. To export all resources, supply an array with single entry '*'. @@ -928,12 +867,12 @@ def __init__( 'SkipResourceNameParameterization', 'SkipAllParameterization'. :paramtype options: str """ - super(ExportTemplateRequest, self).__init__(**kwargs) + super().__init__(**kwargs) self.resources = resources self.options = options -class Resource(msrest.serialization.Model): +class Resource(_serialization.Model): """Specified resource. Variables are only populated by the server, and will be ignored when sending a request. @@ -946,38 +885,32 @@ class Resource(msrest.serialization.Model): :vartype type: str :ivar location: Resource location. :vartype location: str - :ivar tags: A set of tags. Resource tags. + :ivar tags: Resource tags. :vartype tags: dict[str, str] """ _validation = { - 'id': {'readonly': True}, - 'name': {'readonly': True}, - 'type': {'readonly': True}, + "id": {"readonly": True}, + "name": {"readonly": True}, + "type": {"readonly": True}, } _attribute_map = { - 'id': {'key': 'id', 'type': 'str'}, - 'name': {'key': 'name', 'type': 'str'}, - 'type': {'key': 'type', 'type': 'str'}, - 'location': {'key': 'location', 'type': 'str'}, - 'tags': {'key': 'tags', 'type': '{str}'}, + "id": {"key": "id", "type": "str"}, + "name": {"key": "name", "type": "str"}, + "type": {"key": "type", "type": "str"}, + "location": {"key": "location", "type": "str"}, + "tags": {"key": "tags", "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): """ :keyword location: Resource location. :paramtype location: str - :keyword tags: A set of tags. Resource tags. + :keyword tags: Resource tags. :paramtype tags: dict[str, str] """ - super(Resource, self).__init__(**kwargs) + super().__init__(**kwargs) self.id = None self.name = None self.type = None @@ -985,7 +918,7 @@ def __init__( self.tags = tags -class GenericResource(Resource): +class GenericResource(Resource): # pylint: disable=too-many-instance-attributes """Resource information. Variables are only populated by the server, and will be ignored when sending a request. @@ -998,12 +931,12 @@ class GenericResource(Resource): :vartype type: str :ivar location: Resource location. :vartype location: str - :ivar tags: A set of tags. Resource tags. + :ivar tags: Resource tags. :vartype tags: dict[str, str] :ivar plan: The plan of the resource. :vartype plan: ~azure.mgmt.resource.resources.v2019_05_01.models.Plan :ivar properties: The resource properties. - :vartype properties: any + :vartype properties: JSON :ivar kind: The kind of the resource. :vartype kind: str :ivar managed_by: ID of the resource that manages this resource. @@ -1015,24 +948,24 @@ class GenericResource(Resource): """ _validation = { - 'id': {'readonly': True}, - 'name': {'readonly': True}, - 'type': {'readonly': True}, - 'kind': {'pattern': r'^[-\w\._,\(\)]+$'}, + "id": {"readonly": True}, + "name": {"readonly": True}, + "type": {"readonly": True}, + "kind": {"pattern": r"^[-\w\._,\(\)]+$"}, } _attribute_map = { - 'id': {'key': 'id', 'type': 'str'}, - 'name': {'key': 'name', 'type': 'str'}, - 'type': {'key': 'type', 'type': 'str'}, - 'location': {'key': 'location', 'type': 'str'}, - 'tags': {'key': 'tags', 'type': '{str}'}, - 'plan': {'key': 'plan', 'type': 'Plan'}, - 'properties': {'key': 'properties', 'type': 'object'}, - 'kind': {'key': 'kind', 'type': 'str'}, - 'managed_by': {'key': 'managedBy', 'type': 'str'}, - 'sku': {'key': 'sku', 'type': 'Sku'}, - 'identity': {'key': 'identity', 'type': 'Identity'}, + "id": {"key": "id", "type": "str"}, + "name": {"key": "name", "type": "str"}, + "type": {"key": "type", "type": "str"}, + "location": {"key": "location", "type": "str"}, + "tags": {"key": "tags", "type": "{str}"}, + "plan": {"key": "plan", "type": "Plan"}, + "properties": {"key": "properties", "type": "object"}, + "kind": {"key": "kind", "type": "str"}, + "managed_by": {"key": "managedBy", "type": "str"}, + "sku": {"key": "sku", "type": "Sku"}, + "identity": {"key": "identity", "type": "Identity"}, } def __init__( @@ -1040,23 +973,23 @@ def __init__( *, location: Optional[str] = None, tags: Optional[Dict[str, str]] = None, - plan: Optional["Plan"] = None, - properties: Optional[Any] = None, + plan: Optional["_models.Plan"] = None, + properties: Optional[JSON] = None, kind: Optional[str] = None, managed_by: Optional[str] = None, - sku: Optional["Sku"] = None, - identity: Optional["Identity"] = None, + sku: Optional["_models.Sku"] = None, + identity: Optional["_models.Identity"] = None, **kwargs ): """ :keyword location: Resource location. :paramtype location: str - :keyword tags: A set of tags. Resource tags. + :keyword tags: Resource tags. :paramtype tags: dict[str, str] :keyword plan: The plan of the resource. :paramtype plan: ~azure.mgmt.resource.resources.v2019_05_01.models.Plan :keyword properties: The resource properties. - :paramtype properties: any + :paramtype properties: JSON :keyword kind: The kind of the resource. :paramtype kind: str :keyword managed_by: ID of the resource that manages this resource. @@ -1066,7 +999,7 @@ def __init__( :keyword identity: The identity of the resource. :paramtype identity: ~azure.mgmt.resource.resources.v2019_05_01.models.Identity """ - super(GenericResource, self).__init__(location=location, tags=tags, **kwargs) + super().__init__(location=location, tags=tags, **kwargs) self.plan = plan self.properties = properties self.kind = kind @@ -1075,7 +1008,7 @@ def __init__( self.identity = identity -class GenericResourceExpanded(GenericResource): +class GenericResourceExpanded(GenericResource): # pylint: disable=too-many-instance-attributes """Resource information. Variables are only populated by the server, and will be ignored when sending a request. @@ -1088,12 +1021,12 @@ class GenericResourceExpanded(GenericResource): :vartype type: str :ivar location: Resource location. :vartype location: str - :ivar tags: A set of tags. Resource tags. + :ivar tags: Resource tags. :vartype tags: dict[str, str] :ivar plan: The plan of the resource. :vartype plan: ~azure.mgmt.resource.resources.v2019_05_01.models.Plan :ivar properties: The resource properties. - :vartype properties: any + :vartype properties: JSON :ivar kind: The kind of the resource. :vartype kind: str :ivar managed_by: ID of the resource that manages this resource. @@ -1114,30 +1047,30 @@ class GenericResourceExpanded(GenericResource): """ _validation = { - 'id': {'readonly': True}, - 'name': {'readonly': True}, - 'type': {'readonly': True}, - 'kind': {'pattern': r'^[-\w\._,\(\)]+$'}, - 'created_time': {'readonly': True}, - 'changed_time': {'readonly': True}, - 'provisioning_state': {'readonly': True}, + "id": {"readonly": True}, + "name": {"readonly": True}, + "type": {"readonly": True}, + "kind": {"pattern": r"^[-\w\._,\(\)]+$"}, + "created_time": {"readonly": True}, + "changed_time": {"readonly": True}, + "provisioning_state": {"readonly": True}, } _attribute_map = { - 'id': {'key': 'id', 'type': 'str'}, - 'name': {'key': 'name', 'type': 'str'}, - 'type': {'key': 'type', 'type': 'str'}, - 'location': {'key': 'location', 'type': 'str'}, - 'tags': {'key': 'tags', 'type': '{str}'}, - 'plan': {'key': 'plan', 'type': 'Plan'}, - 'properties': {'key': 'properties', 'type': 'object'}, - 'kind': {'key': 'kind', 'type': 'str'}, - 'managed_by': {'key': 'managedBy', 'type': 'str'}, - 'sku': {'key': 'sku', 'type': 'Sku'}, - 'identity': {'key': 'identity', 'type': 'Identity'}, - 'created_time': {'key': 'createdTime', 'type': 'iso-8601'}, - 'changed_time': {'key': 'changedTime', 'type': 'iso-8601'}, - 'provisioning_state': {'key': 'provisioningState', 'type': 'str'}, + "id": {"key": "id", "type": "str"}, + "name": {"key": "name", "type": "str"}, + "type": {"key": "type", "type": "str"}, + "location": {"key": "location", "type": "str"}, + "tags": {"key": "tags", "type": "{str}"}, + "plan": {"key": "plan", "type": "Plan"}, + "properties": {"key": "properties", "type": "object"}, + "kind": {"key": "kind", "type": "str"}, + "managed_by": {"key": "managedBy", "type": "str"}, + "sku": {"key": "sku", "type": "Sku"}, + "identity": {"key": "identity", "type": "Identity"}, + "created_time": {"key": "createdTime", "type": "iso-8601"}, + "changed_time": {"key": "changedTime", "type": "iso-8601"}, + "provisioning_state": {"key": "provisioningState", "type": "str"}, } def __init__( @@ -1145,23 +1078,23 @@ def __init__( *, location: Optional[str] = None, tags: Optional[Dict[str, str]] = None, - plan: Optional["Plan"] = None, - properties: Optional[Any] = None, + plan: Optional["_models.Plan"] = None, + properties: Optional[JSON] = None, kind: Optional[str] = None, managed_by: Optional[str] = None, - sku: Optional["Sku"] = None, - identity: Optional["Identity"] = None, + sku: Optional["_models.Sku"] = None, + identity: Optional["_models.Identity"] = None, **kwargs ): """ :keyword location: Resource location. :paramtype location: str - :keyword tags: A set of tags. Resource tags. + :keyword tags: Resource tags. :paramtype tags: dict[str, str] :keyword plan: The plan of the resource. :paramtype plan: ~azure.mgmt.resource.resources.v2019_05_01.models.Plan :keyword properties: The resource properties. - :paramtype properties: any + :paramtype properties: JSON :keyword kind: The kind of the resource. :paramtype kind: str :keyword managed_by: ID of the resource that manages this resource. @@ -1171,13 +1104,23 @@ def __init__( :keyword identity: The identity of the resource. :paramtype identity: ~azure.mgmt.resource.resources.v2019_05_01.models.Identity """ - super(GenericResourceExpanded, self).__init__(location=location, tags=tags, plan=plan, properties=properties, kind=kind, managed_by=managed_by, sku=sku, identity=identity, **kwargs) + super().__init__( + location=location, + tags=tags, + plan=plan, + properties=properties, + kind=kind, + managed_by=managed_by, + sku=sku, + identity=identity, + **kwargs + ) self.created_time = None self.changed_time = None self.provisioning_state = None -class GenericResourceFilter(msrest.serialization.Model): +class GenericResourceFilter(_serialization.Model): """Resource filter. :ivar resource_type: The resource type. @@ -1189,9 +1132,9 @@ class GenericResourceFilter(msrest.serialization.Model): """ _attribute_map = { - 'resource_type': {'key': 'resourceType', 'type': 'str'}, - 'tagname': {'key': 'tagname', 'type': 'str'}, - 'tagvalue': {'key': 'tagvalue', 'type': 'str'}, + "resource_type": {"key": "resourceType", "type": "str"}, + "tagname": {"key": "tagname", "type": "str"}, + "tagvalue": {"key": "tagvalue", "type": "str"}, } def __init__( @@ -1210,38 +1153,33 @@ def __init__( :keyword tagvalue: The tag value. :paramtype tagvalue: str """ - super(GenericResourceFilter, self).__init__(**kwargs) + super().__init__(**kwargs) self.resource_type = resource_type self.tagname = tagname self.tagvalue = tagvalue -class HttpMessage(msrest.serialization.Model): +class HttpMessage(_serialization.Model): """HTTP message. :ivar content: HTTP message content. - :vartype content: any + :vartype content: JSON """ _attribute_map = { - 'content': {'key': 'content', 'type': 'object'}, + "content": {"key": "content", "type": "object"}, } - def __init__( - self, - *, - content: Optional[Any] = None, - **kwargs - ): + def __init__(self, *, content: Optional[JSON] = None, **kwargs): """ :keyword content: HTTP message content. - :paramtype content: any + :paramtype content: JSON """ - super(HttpMessage, self).__init__(**kwargs) + super().__init__(**kwargs) self.content = content -class Identity(msrest.serialization.Model): +class Identity(_serialization.Model): """Identity for the resource. Variables are only populated by the server, and will be ignored when sending a request. @@ -1250,8 +1188,8 @@ class Identity(msrest.serialization.Model): :vartype principal_id: str :ivar tenant_id: The tenant ID of resource. :vartype tenant_id: str - :ivar type: The identity type. Possible values include: "SystemAssigned", "UserAssigned", - "SystemAssigned, UserAssigned", "None". + :ivar type: The identity type. Known values are: "SystemAssigned", "UserAssigned", + "SystemAssigned, UserAssigned", and "None". :vartype type: str or ~azure.mgmt.resource.resources.v2019_05_01.models.ResourceIdentityType :ivar user_assigned_identities: The list of user identities associated with the resource. The user identity dictionary key references will be ARM resource ids in the form: @@ -1261,27 +1199,32 @@ class Identity(msrest.serialization.Model): """ _validation = { - 'principal_id': {'readonly': True}, - 'tenant_id': {'readonly': True}, + "principal_id": {"readonly": True}, + "tenant_id": {"readonly": True}, } _attribute_map = { - 'principal_id': {'key': 'principalId', 'type': 'str'}, - 'tenant_id': {'key': 'tenantId', 'type': 'str'}, - 'type': {'key': 'type', 'type': 'str'}, - 'user_assigned_identities': {'key': 'userAssignedIdentities', 'type': '{ComponentsSgqdofSchemasIdentityPropertiesUserassignedidentitiesAdditionalproperties}'}, + "principal_id": {"key": "principalId", "type": "str"}, + "tenant_id": {"key": "tenantId", "type": "str"}, + "type": {"key": "type", "type": "str"}, + "user_assigned_identities": { + "key": "userAssignedIdentities", + "type": "{ComponentsSgqdofSchemasIdentityPropertiesUserassignedidentitiesAdditionalproperties}", + }, } def __init__( self, *, - type: Optional[Union[str, "ResourceIdentityType"]] = None, - user_assigned_identities: Optional[Dict[str, "ComponentsSgqdofSchemasIdentityPropertiesUserassignedidentitiesAdditionalproperties"]] = None, + type: Optional[Union[str, "_models.ResourceIdentityType"]] = None, + user_assigned_identities: Optional[ + Dict[str, "_models.ComponentsSgqdofSchemasIdentityPropertiesUserassignedidentitiesAdditionalproperties"] + ] = None, **kwargs ): """ - :keyword type: The identity type. Possible values include: "SystemAssigned", "UserAssigned", - "SystemAssigned, UserAssigned", "None". + :keyword type: The identity type. Known values are: "SystemAssigned", "UserAssigned", + "SystemAssigned, UserAssigned", and "None". :paramtype type: str or ~azure.mgmt.resource.resources.v2019_05_01.models.ResourceIdentityType :keyword user_assigned_identities: The list of user identities associated with the resource. The user identity dictionary key references will be ARM resource ids in the form: @@ -1289,48 +1232,48 @@ def __init__( :paramtype user_assigned_identities: dict[str, ~azure.mgmt.resource.resources.v2019_05_01.models.ComponentsSgqdofSchemasIdentityPropertiesUserassignedidentitiesAdditionalproperties] """ - super(Identity, self).__init__(**kwargs) + super().__init__(**kwargs) self.principal_id = None self.tenant_id = None self.type = type self.user_assigned_identities = user_assigned_identities -class OnErrorDeployment(msrest.serialization.Model): +class OnErrorDeployment(_serialization.Model): """Deployment on error behavior. :ivar type: The deployment on error behavior type. Possible values are LastSuccessful and - SpecificDeployment. Possible values include: "LastSuccessful", "SpecificDeployment". + SpecificDeployment. Known values are: "LastSuccessful" and "SpecificDeployment". :vartype type: str or ~azure.mgmt.resource.resources.v2019_05_01.models.OnErrorDeploymentType :ivar deployment_name: The deployment to be used on error case. :vartype deployment_name: str """ _attribute_map = { - 'type': {'key': 'type', 'type': 'str'}, - 'deployment_name': {'key': 'deploymentName', 'type': 'str'}, + "type": {"key": "type", "type": "str"}, + "deployment_name": {"key": "deploymentName", "type": "str"}, } def __init__( self, *, - type: Optional[Union[str, "OnErrorDeploymentType"]] = None, + type: Optional[Union[str, "_models.OnErrorDeploymentType"]] = None, deployment_name: Optional[str] = None, **kwargs ): """ :keyword type: The deployment on error behavior type. Possible values are LastSuccessful and - SpecificDeployment. Possible values include: "LastSuccessful", "SpecificDeployment". + SpecificDeployment. Known values are: "LastSuccessful" and "SpecificDeployment". :paramtype type: str or ~azure.mgmt.resource.resources.v2019_05_01.models.OnErrorDeploymentType :keyword deployment_name: The deployment to be used on error case. :paramtype deployment_name: str """ - super(OnErrorDeployment, self).__init__(**kwargs) + super().__init__(**kwargs) self.type = type self.deployment_name = deployment_name -class OnErrorDeploymentExtended(msrest.serialization.Model): +class OnErrorDeploymentExtended(_serialization.Model): """Deployment on error behavior with additional details. Variables are only populated by the server, and will be ignored when sending a request. @@ -1338,43 +1281,43 @@ class OnErrorDeploymentExtended(msrest.serialization.Model): :ivar provisioning_state: The state of the provisioning for the on error deployment. :vartype provisioning_state: str :ivar type: The deployment on error behavior type. Possible values are LastSuccessful and - SpecificDeployment. Possible values include: "LastSuccessful", "SpecificDeployment". + SpecificDeployment. Known values are: "LastSuccessful" and "SpecificDeployment". :vartype type: str or ~azure.mgmt.resource.resources.v2019_05_01.models.OnErrorDeploymentType :ivar deployment_name: The deployment to be used on error case. :vartype deployment_name: str """ _validation = { - 'provisioning_state': {'readonly': True}, + "provisioning_state": {"readonly": True}, } _attribute_map = { - 'provisioning_state': {'key': 'provisioningState', 'type': 'str'}, - 'type': {'key': 'type', 'type': 'str'}, - 'deployment_name': {'key': 'deploymentName', 'type': 'str'}, + "provisioning_state": {"key": "provisioningState", "type": "str"}, + "type": {"key": "type", "type": "str"}, + "deployment_name": {"key": "deploymentName", "type": "str"}, } def __init__( self, *, - type: Optional[Union[str, "OnErrorDeploymentType"]] = None, + type: Optional[Union[str, "_models.OnErrorDeploymentType"]] = None, deployment_name: Optional[str] = None, **kwargs ): """ :keyword type: The deployment on error behavior type. Possible values are LastSuccessful and - SpecificDeployment. Possible values include: "LastSuccessful", "SpecificDeployment". + SpecificDeployment. Known values are: "LastSuccessful" and "SpecificDeployment". :paramtype type: str or ~azure.mgmt.resource.resources.v2019_05_01.models.OnErrorDeploymentType :keyword deployment_name: The deployment to be used on error case. :paramtype deployment_name: str """ - super(OnErrorDeploymentExtended, self).__init__(**kwargs) + super().__init__(**kwargs) self.provisioning_state = None self.type = type self.deployment_name = deployment_name -class Operation(msrest.serialization.Model): +class Operation(_serialization.Model): """Microsoft.Resources operation. :ivar name: Operation name: {provider}/{resource}/{operation}. @@ -1384,29 +1327,23 @@ class Operation(msrest.serialization.Model): """ _attribute_map = { - 'name': {'key': 'name', 'type': 'str'}, - 'display': {'key': 'display', 'type': 'OperationDisplay'}, + "name": {"key": "name", "type": "str"}, + "display": {"key": "display", "type": "OperationDisplay"}, } - def __init__( - self, - *, - name: Optional[str] = None, - display: Optional["OperationDisplay"] = None, - **kwargs - ): + def __init__(self, *, name: Optional[str] = None, display: Optional["_models.OperationDisplay"] = None, **kwargs): """ :keyword name: Operation name: {provider}/{resource}/{operation}. :paramtype name: str :keyword display: The object that represents the operation. :paramtype display: ~azure.mgmt.resource.resources.v2019_05_01.models.OperationDisplay """ - super(Operation, self).__init__(**kwargs) + super().__init__(**kwargs) self.name = name self.display = display -class OperationDisplay(msrest.serialization.Model): +class OperationDisplay(_serialization.Model): """The object that represents the operation. :ivar provider: Service provider: Microsoft.Resources. @@ -1420,10 +1357,10 @@ class OperationDisplay(msrest.serialization.Model): """ _attribute_map = { - 'provider': {'key': 'provider', 'type': 'str'}, - 'resource': {'key': 'resource', 'type': 'str'}, - 'operation': {'key': 'operation', 'type': 'str'}, - 'description': {'key': 'description', 'type': 'str'}, + "provider": {"key": "provider", "type": "str"}, + "resource": {"key": "resource", "type": "str"}, + "operation": {"key": "operation", "type": "str"}, + "description": {"key": "description", "type": "str"}, } def __init__( @@ -1445,14 +1382,14 @@ def __init__( :keyword description: Description of the operation. :paramtype description: str """ - super(OperationDisplay, self).__init__(**kwargs) + super().__init__(**kwargs) self.provider = provider self.resource = resource self.operation = operation self.description = description -class OperationListResult(msrest.serialization.Model): +class OperationListResult(_serialization.Model): """Result of the request to list Microsoft.Resources operations. It contains a list of operations and a URL link to get the next set of results. :ivar value: List of Microsoft.Resources operations. @@ -1462,67 +1399,55 @@ class OperationListResult(msrest.serialization.Model): """ _attribute_map = { - 'value': {'key': 'value', 'type': '[Operation]'}, - 'next_link': {'key': 'nextLink', 'type': 'str'}, + "value": {"key": "value", "type": "[Operation]"}, + "next_link": {"key": "nextLink", "type": "str"}, } - def __init__( - self, - *, - value: Optional[List["Operation"]] = None, - next_link: Optional[str] = None, - **kwargs - ): + def __init__(self, *, value: Optional[List["_models.Operation"]] = None, next_link: Optional[str] = None, **kwargs): """ :keyword value: List of Microsoft.Resources operations. :paramtype value: list[~azure.mgmt.resource.resources.v2019_05_01.models.Operation] :keyword next_link: URL to get the next set of operation list results if there are any. :paramtype next_link: str """ - super(OperationListResult, self).__init__(**kwargs) + super().__init__(**kwargs) self.value = value self.next_link = next_link -class ParametersLink(msrest.serialization.Model): +class ParametersLink(_serialization.Model): """Entity representing the reference to the deployment parameters. All required parameters must be populated in order to send to Azure. - :ivar uri: Required. The URI of the parameters file. + :ivar uri: The URI of the parameters file. Required. :vartype uri: str :ivar content_version: If included, must match the ContentVersion in the template. :vartype content_version: str """ _validation = { - 'uri': {'required': True}, + "uri": {"required": True}, } _attribute_map = { - 'uri': {'key': 'uri', 'type': 'str'}, - 'content_version': {'key': 'contentVersion', 'type': 'str'}, + "uri": {"key": "uri", "type": "str"}, + "content_version": {"key": "contentVersion", "type": "str"}, } - def __init__( - self, - *, - uri: str, - content_version: Optional[str] = None, - **kwargs - ): + def __init__(self, *, uri: str, content_version: Optional[str] = None, **kwargs): """ - :keyword uri: Required. The URI of the parameters file. + :keyword uri: The URI of the parameters file. Required. :paramtype uri: str :keyword content_version: If included, must match the ContentVersion in the template. :paramtype content_version: str """ - super(ParametersLink, self).__init__(**kwargs) + super().__init__(**kwargs) self.uri = uri self.content_version = content_version -class Plan(msrest.serialization.Model): +class Plan(_serialization.Model): """Plan for the resource. :ivar name: The plan ID. @@ -1538,11 +1463,11 @@ class Plan(msrest.serialization.Model): """ _attribute_map = { - 'name': {'key': 'name', 'type': 'str'}, - 'publisher': {'key': 'publisher', 'type': 'str'}, - 'product': {'key': 'product', 'type': 'str'}, - 'promotion_code': {'key': 'promotionCode', 'type': 'str'}, - 'version': {'key': 'version', 'type': 'str'}, + "name": {"key": "name", "type": "str"}, + "publisher": {"key": "publisher", "type": "str"}, + "product": {"key": "product", "type": "str"}, + "promotion_code": {"key": "promotionCode", "type": "str"}, + "version": {"key": "version", "type": "str"}, } def __init__( @@ -1567,7 +1492,7 @@ def __init__( :keyword version: The plan's version. :paramtype version: str """ - super(Plan, self).__init__(**kwargs) + super().__init__(**kwargs) self.name = name self.publisher = publisher self.product = product @@ -1575,7 +1500,7 @@ def __init__( self.version = version -class Provider(msrest.serialization.Model): +class Provider(_serialization.Model): """Resource provider information. Variables are only populated by the server, and will be ignored when sending a request. @@ -1594,31 +1519,26 @@ class Provider(msrest.serialization.Model): """ _validation = { - 'id': {'readonly': True}, - 'registration_state': {'readonly': True}, - 'registration_policy': {'readonly': True}, - 'resource_types': {'readonly': True}, + "id": {"readonly": True}, + "registration_state": {"readonly": True}, + "registration_policy": {"readonly": True}, + "resource_types": {"readonly": True}, } _attribute_map = { - 'id': {'key': 'id', 'type': 'str'}, - 'namespace': {'key': 'namespace', 'type': 'str'}, - 'registration_state': {'key': 'registrationState', 'type': 'str'}, - 'registration_policy': {'key': 'registrationPolicy', 'type': 'str'}, - 'resource_types': {'key': 'resourceTypes', 'type': '[ProviderResourceType]'}, + "id": {"key": "id", "type": "str"}, + "namespace": {"key": "namespace", "type": "str"}, + "registration_state": {"key": "registrationState", "type": "str"}, + "registration_policy": {"key": "registrationPolicy", "type": "str"}, + "resource_types": {"key": "resourceTypes", "type": "[ProviderResourceType]"}, } - def __init__( - self, - *, - namespace: Optional[str] = None, - **kwargs - ): + def __init__(self, *, namespace: Optional[str] = None, **kwargs): """ :keyword namespace: The namespace of the resource provider. :paramtype namespace: str """ - super(Provider, self).__init__(**kwargs) + super().__init__(**kwargs) self.id = None self.namespace = namespace self.registration_state = None @@ -1626,7 +1546,7 @@ def __init__( self.resource_types = None -class ProviderListResult(msrest.serialization.Model): +class ProviderListResult(_serialization.Model): """List of resource providers. Variables are only populated by the server, and will be ignored when sending a request. @@ -1638,30 +1558,25 @@ class ProviderListResult(msrest.serialization.Model): """ _validation = { - 'next_link': {'readonly': True}, + "next_link": {"readonly": True}, } _attribute_map = { - 'value': {'key': 'value', 'type': '[Provider]'}, - 'next_link': {'key': 'nextLink', 'type': 'str'}, + "value": {"key": "value", "type": "[Provider]"}, + "next_link": {"key": "nextLink", "type": "str"}, } - def __init__( - self, - *, - value: Optional[List["Provider"]] = None, - **kwargs - ): + def __init__(self, *, value: Optional[List["_models.Provider"]] = None, **kwargs): """ :keyword value: An array of resource providers. :paramtype value: list[~azure.mgmt.resource.resources.v2019_05_01.models.Provider] """ - super(ProviderListResult, self).__init__(**kwargs) + super().__init__(**kwargs) self.value = value self.next_link = None -class ProviderResourceType(msrest.serialization.Model): +class ProviderResourceType(_serialization.Model): """Resource type managed by the resource provider. :ivar resource_type: The resource type. @@ -1681,13 +1596,13 @@ class ProviderResourceType(msrest.serialization.Model): """ _attribute_map = { - 'resource_type': {'key': 'resourceType', 'type': 'str'}, - 'locations': {'key': 'locations', 'type': '[str]'}, - 'aliases': {'key': 'aliases', 'type': '[AliasType]'}, - 'api_versions': {'key': 'apiVersions', 'type': '[str]'}, - 'zone_mappings': {'key': 'zoneMappings', 'type': '[ZoneMapping]'}, - 'capabilities': {'key': 'capabilities', 'type': 'str'}, - 'properties': {'key': 'properties', 'type': '{str}'}, + "resource_type": {"key": "resourceType", "type": "str"}, + "locations": {"key": "locations", "type": "[str]"}, + "aliases": {"key": "aliases", "type": "[AliasType]"}, + "api_versions": {"key": "apiVersions", "type": "[str]"}, + "zone_mappings": {"key": "zoneMappings", "type": "[ZoneMapping]"}, + "capabilities": {"key": "capabilities", "type": "str"}, + "properties": {"key": "properties", "type": "{str}"}, } def __init__( @@ -1695,9 +1610,9 @@ def __init__( *, resource_type: Optional[str] = None, locations: Optional[List[str]] = None, - aliases: Optional[List["AliasType"]] = None, + aliases: Optional[List["_models.AliasType"]] = None, api_versions: Optional[List[str]] = None, - zone_mappings: Optional[List["ZoneMapping"]] = None, + zone_mappings: Optional[List["_models.ZoneMapping"]] = None, capabilities: Optional[str] = None, properties: Optional[Dict[str, str]] = None, **kwargs @@ -1718,7 +1633,7 @@ def __init__( :keyword properties: The properties. :paramtype properties: dict[str, str] """ - super(ProviderResourceType, self).__init__(**kwargs) + super().__init__(**kwargs) self.resource_type = resource_type self.locations = locations self.aliases = aliases @@ -1728,7 +1643,7 @@ def __init__( self.properties = properties -class ResourceGroup(msrest.serialization.Model): +class ResourceGroup(_serialization.Model): """Resource group information. Variables are only populated by the server, and will be ignored when sending a request. @@ -1743,37 +1658,37 @@ class ResourceGroup(msrest.serialization.Model): :vartype type: str :ivar properties: The resource group properties. :vartype properties: ~azure.mgmt.resource.resources.v2019_05_01.models.ResourceGroupProperties - :ivar location: Required. The location of the resource group. It cannot be changed after the - resource group has been created. It must be one of the supported Azure locations. + :ivar location: The location of the resource group. It cannot be changed after the resource + group has been created. It must be one of the supported Azure locations. Required. :vartype location: str :ivar managed_by: The ID of the resource that manages this resource group. :vartype managed_by: str - :ivar tags: A set of tags. The tags attached to the resource group. + :ivar tags: The tags attached to the resource group. :vartype tags: dict[str, str] """ _validation = { - 'id': {'readonly': True}, - 'name': {'readonly': True}, - 'type': {'readonly': True}, - 'location': {'required': True}, + "id": {"readonly": True}, + "name": {"readonly": True}, + "type": {"readonly": True}, + "location": {"required": True}, } _attribute_map = { - 'id': {'key': 'id', 'type': 'str'}, - 'name': {'key': 'name', 'type': 'str'}, - 'type': {'key': 'type', 'type': 'str'}, - 'properties': {'key': 'properties', 'type': 'ResourceGroupProperties'}, - 'location': {'key': 'location', 'type': 'str'}, - 'managed_by': {'key': 'managedBy', 'type': 'str'}, - 'tags': {'key': 'tags', 'type': '{str}'}, + "id": {"key": "id", "type": "str"}, + "name": {"key": "name", "type": "str"}, + "type": {"key": "type", "type": "str"}, + "properties": {"key": "properties", "type": "ResourceGroupProperties"}, + "location": {"key": "location", "type": "str"}, + "managed_by": {"key": "managedBy", "type": "str"}, + "tags": {"key": "tags", "type": "{str}"}, } def __init__( self, *, location: str, - properties: Optional["ResourceGroupProperties"] = None, + properties: Optional["_models.ResourceGroupProperties"] = None, managed_by: Optional[str] = None, tags: Optional[Dict[str, str]] = None, **kwargs @@ -1782,15 +1697,15 @@ def __init__( :keyword properties: The resource group properties. :paramtype properties: ~azure.mgmt.resource.resources.v2019_05_01.models.ResourceGroupProperties - :keyword location: Required. The location of the resource group. It cannot be changed after the - resource group has been created. It must be one of the supported Azure locations. + :keyword location: The location of the resource group. It cannot be changed after the resource + group has been created. It must be one of the supported Azure locations. Required. :paramtype location: str :keyword managed_by: The ID of the resource that manages this resource group. :paramtype managed_by: str - :keyword tags: A set of tags. The tags attached to the resource group. + :keyword tags: The tags attached to the resource group. :paramtype tags: dict[str, str] """ - super(ResourceGroup, self).__init__(**kwargs) + super().__init__(**kwargs) self.id = None self.name = None self.type = None @@ -1800,41 +1715,41 @@ def __init__( self.tags = tags -class ResourceGroupExportResult(msrest.serialization.Model): +class ResourceGroupExportResult(_serialization.Model): """Resource group export result. :ivar template: The template content. - :vartype template: any + :vartype template: JSON :ivar error: The error. :vartype error: ~azure.mgmt.resource.resources.v2019_05_01.models.ResourceManagementErrorWithDetails """ _attribute_map = { - 'template': {'key': 'template', 'type': 'object'}, - 'error': {'key': 'error', 'type': 'ResourceManagementErrorWithDetails'}, + "template": {"key": "template", "type": "object"}, + "error": {"key": "error", "type": "ResourceManagementErrorWithDetails"}, } def __init__( self, *, - template: Optional[Any] = None, - error: Optional["ResourceManagementErrorWithDetails"] = None, + template: Optional[JSON] = None, + error: Optional["_models.ResourceManagementErrorWithDetails"] = None, **kwargs ): """ :keyword template: The template content. - :paramtype template: any + :paramtype template: JSON :keyword error: The error. :paramtype error: ~azure.mgmt.resource.resources.v2019_05_01.models.ResourceManagementErrorWithDetails """ - super(ResourceGroupExportResult, self).__init__(**kwargs) + super().__init__(**kwargs) self.template = template self.error = error -class ResourceGroupFilter(msrest.serialization.Model): +class ResourceGroupFilter(_serialization.Model): """Resource group filter. :ivar tag_name: The tag name. @@ -1844,29 +1759,23 @@ class ResourceGroupFilter(msrest.serialization.Model): """ _attribute_map = { - 'tag_name': {'key': 'tagName', 'type': 'str'}, - 'tag_value': {'key': 'tagValue', 'type': 'str'}, + "tag_name": {"key": "tagName", "type": "str"}, + "tag_value": {"key": "tagValue", "type": "str"}, } - def __init__( - self, - *, - tag_name: Optional[str] = None, - tag_value: Optional[str] = None, - **kwargs - ): + def __init__(self, *, tag_name: Optional[str] = None, tag_value: Optional[str] = None, **kwargs): """ :keyword tag_name: The tag name. :paramtype tag_name: str :keyword tag_value: The tag value. :paramtype tag_value: str """ - super(ResourceGroupFilter, self).__init__(**kwargs) + super().__init__(**kwargs) self.tag_name = tag_name self.tag_value = tag_value -class ResourceGroupListResult(msrest.serialization.Model): +class ResourceGroupListResult(_serialization.Model): """List of resource groups. Variables are only populated by the server, and will be ignored when sending a request. @@ -1878,30 +1787,25 @@ class ResourceGroupListResult(msrest.serialization.Model): """ _validation = { - 'next_link': {'readonly': True}, + "next_link": {"readonly": True}, } _attribute_map = { - 'value': {'key': 'value', 'type': '[ResourceGroup]'}, - 'next_link': {'key': 'nextLink', 'type': 'str'}, + "value": {"key": "value", "type": "[ResourceGroup]"}, + "next_link": {"key": "nextLink", "type": "str"}, } - def __init__( - self, - *, - value: Optional[List["ResourceGroup"]] = None, - **kwargs - ): + def __init__(self, *, value: Optional[List["_models.ResourceGroup"]] = None, **kwargs): """ :keyword value: An array of resource groups. :paramtype value: list[~azure.mgmt.resource.resources.v2019_05_01.models.ResourceGroup] """ - super(ResourceGroupListResult, self).__init__(**kwargs) + super().__init__(**kwargs) self.value = value self.next_link = None -class ResourceGroupPatchable(msrest.serialization.Model): +class ResourceGroupPatchable(_serialization.Model): """Resource group information. :ivar name: The name of the resource group. @@ -1910,22 +1814,22 @@ class ResourceGroupPatchable(msrest.serialization.Model): :vartype properties: ~azure.mgmt.resource.resources.v2019_05_01.models.ResourceGroupProperties :ivar managed_by: The ID of the resource that manages this resource group. :vartype managed_by: str - :ivar tags: A set of tags. The tags attached to the resource group. + :ivar tags: The tags attached to the resource group. :vartype tags: dict[str, str] """ _attribute_map = { - 'name': {'key': 'name', 'type': 'str'}, - 'properties': {'key': 'properties', 'type': 'ResourceGroupProperties'}, - 'managed_by': {'key': 'managedBy', 'type': 'str'}, - 'tags': {'key': 'tags', 'type': '{str}'}, + "name": {"key": "name", "type": "str"}, + "properties": {"key": "properties", "type": "ResourceGroupProperties"}, + "managed_by": {"key": "managedBy", "type": "str"}, + "tags": {"key": "tags", "type": "{str}"}, } def __init__( self, *, name: Optional[str] = None, - properties: Optional["ResourceGroupProperties"] = None, + properties: Optional["_models.ResourceGroupProperties"] = None, managed_by: Optional[str] = None, tags: Optional[Dict[str, str]] = None, **kwargs @@ -1938,17 +1842,17 @@ def __init__( ~azure.mgmt.resource.resources.v2019_05_01.models.ResourceGroupProperties :keyword managed_by: The ID of the resource that manages this resource group. :paramtype managed_by: str - :keyword tags: A set of tags. The tags attached to the resource group. + :keyword tags: The tags attached to the resource group. :paramtype tags: dict[str, str] """ - super(ResourceGroupPatchable, self).__init__(**kwargs) + super().__init__(**kwargs) self.name = name self.properties = properties self.managed_by = managed_by self.tags = tags -class ResourceGroupProperties(msrest.serialization.Model): +class ResourceGroupProperties(_serialization.Model): """The resource group properties. Variables are only populated by the server, and will be ignored when sending a request. @@ -1958,24 +1862,20 @@ class ResourceGroupProperties(msrest.serialization.Model): """ _validation = { - 'provisioning_state': {'readonly': True}, + "provisioning_state": {"readonly": True}, } _attribute_map = { - 'provisioning_state': {'key': 'provisioningState', 'type': 'str'}, + "provisioning_state": {"key": "provisioningState", "type": "str"}, } - def __init__( - self, - **kwargs - ): - """ - """ - super(ResourceGroupProperties, self).__init__(**kwargs) + def __init__(self, **kwargs): + """ """ + super().__init__(**kwargs) self.provisioning_state = None -class ResourceListResult(msrest.serialization.Model): +class ResourceListResult(_serialization.Model): """List of resource groups. Variables are only populated by the server, and will be ignored when sending a request. @@ -1987,31 +1887,26 @@ class ResourceListResult(msrest.serialization.Model): """ _validation = { - 'next_link': {'readonly': True}, + "next_link": {"readonly": True}, } _attribute_map = { - 'value': {'key': 'value', 'type': '[GenericResourceExpanded]'}, - 'next_link': {'key': 'nextLink', 'type': 'str'}, + "value": {"key": "value", "type": "[GenericResourceExpanded]"}, + "next_link": {"key": "nextLink", "type": "str"}, } - def __init__( - self, - *, - value: Optional[List["GenericResourceExpanded"]] = None, - **kwargs - ): + def __init__(self, *, value: Optional[List["_models.GenericResourceExpanded"]] = None, **kwargs): """ :keyword value: An array of resources. :paramtype value: list[~azure.mgmt.resource.resources.v2019_05_01.models.GenericResourceExpanded] """ - super(ResourceListResult, self).__init__(**kwargs) + super().__init__(**kwargs) self.value = value self.next_link = None -class ResourceManagementErrorWithDetails(msrest.serialization.Model): +class ResourceManagementErrorWithDetails(_serialization.Model): """The detailed error message of resource management. Variables are only populated by the server, and will be ignored when sending a request. @@ -2028,33 +1923,29 @@ class ResourceManagementErrorWithDetails(msrest.serialization.Model): """ _validation = { - 'code': {'readonly': True}, - 'message': {'readonly': True}, - 'target': {'readonly': True}, - 'details': {'readonly': True}, + "code": {"readonly": True}, + "message": {"readonly": True}, + "target": {"readonly": True}, + "details": {"readonly": True}, } _attribute_map = { - 'code': {'key': 'code', 'type': 'str'}, - 'message': {'key': 'message', 'type': 'str'}, - 'target': {'key': 'target', 'type': 'str'}, - 'details': {'key': 'details', 'type': '[ResourceManagementErrorWithDetails]'}, + "code": {"key": "code", "type": "str"}, + "message": {"key": "message", "type": "str"}, + "target": {"key": "target", "type": "str"}, + "details": {"key": "details", "type": "[ResourceManagementErrorWithDetails]"}, } - def __init__( - self, - **kwargs - ): - """ - """ - super(ResourceManagementErrorWithDetails, self).__init__(**kwargs) + def __init__(self, **kwargs): + """ """ + super().__init__(**kwargs) self.code = None self.message = None self.target = None self.details = None -class ResourceProviderOperationDisplayProperties(msrest.serialization.Model): +class ResourceProviderOperationDisplayProperties(_serialization.Model): """Resource provider operation's display properties. :ivar publisher: Operation description. @@ -2070,11 +1961,11 @@ class ResourceProviderOperationDisplayProperties(msrest.serialization.Model): """ _attribute_map = { - 'publisher': {'key': 'publisher', 'type': 'str'}, - 'provider': {'key': 'provider', 'type': 'str'}, - 'resource': {'key': 'resource', 'type': 'str'}, - 'operation': {'key': 'operation', 'type': 'str'}, - 'description': {'key': 'description', 'type': 'str'}, + "publisher": {"key": "publisher", "type": "str"}, + "provider": {"key": "provider", "type": "str"}, + "resource": {"key": "resource", "type": "str"}, + "operation": {"key": "operation", "type": "str"}, + "description": {"key": "description", "type": "str"}, } def __init__( @@ -2099,7 +1990,7 @@ def __init__( :keyword description: Operation description. :paramtype description: str """ - super(ResourceProviderOperationDisplayProperties, self).__init__(**kwargs) + super().__init__(**kwargs) self.publisher = publisher self.provider = provider self.resource = resource @@ -2107,7 +1998,7 @@ def __init__( self.description = description -class ResourcesMoveInfo(msrest.serialization.Model): +class ResourcesMoveInfo(_serialization.Model): """Parameters of move resources. :ivar resources: The IDs of the resources. @@ -2117,29 +2008,23 @@ class ResourcesMoveInfo(msrest.serialization.Model): """ _attribute_map = { - 'resources': {'key': 'resources', 'type': '[str]'}, - 'target_resource_group': {'key': 'targetResourceGroup', 'type': 'str'}, + "resources": {"key": "resources", "type": "[str]"}, + "target_resource_group": {"key": "targetResourceGroup", "type": "str"}, } - def __init__( - self, - *, - resources: Optional[List[str]] = None, - target_resource_group: Optional[str] = None, - **kwargs - ): + def __init__(self, *, resources: Optional[List[str]] = None, target_resource_group: Optional[str] = None, **kwargs): """ :keyword resources: The IDs of the resources. :paramtype resources: list[str] :keyword target_resource_group: The target resource group. :paramtype target_resource_group: str """ - super(ResourcesMoveInfo, self).__init__(**kwargs) + super().__init__(**kwargs) self.resources = resources self.target_resource_group = target_resource_group -class Sku(msrest.serialization.Model): +class Sku(_serialization.Model): """SKU for the resource. :ivar name: The SKU name. @@ -2157,12 +2042,12 @@ class Sku(msrest.serialization.Model): """ _attribute_map = { - 'name': {'key': 'name', 'type': 'str'}, - 'tier': {'key': 'tier', 'type': 'str'}, - 'size': {'key': 'size', 'type': 'str'}, - 'family': {'key': 'family', 'type': 'str'}, - 'model': {'key': 'model', 'type': 'str'}, - 'capacity': {'key': 'capacity', 'type': 'int'}, + "name": {"key": "name", "type": "str"}, + "tier": {"key": "tier", "type": "str"}, + "size": {"key": "size", "type": "str"}, + "family": {"key": "family", "type": "str"}, + "model": {"key": "model", "type": "str"}, + "capacity": {"key": "capacity", "type": "int"}, } def __init__( @@ -2190,7 +2075,7 @@ def __init__( :keyword capacity: The SKU capacity. :paramtype capacity: int """ - super(Sku, self).__init__(**kwargs) + super().__init__(**kwargs) self.name = name self.tier = tier self.size = size @@ -2199,7 +2084,7 @@ def __init__( self.capacity = capacity -class SubResource(msrest.serialization.Model): +class SubResource(_serialization.Model): """Sub-resource. :ivar id: Resource ID. @@ -2207,24 +2092,19 @@ class SubResource(msrest.serialization.Model): """ _attribute_map = { - 'id': {'key': 'id', 'type': 'str'}, + "id": {"key": "id", "type": "str"}, } - def __init__( - self, - *, - id: Optional[str] = None, - **kwargs - ): + def __init__(self, *, id: Optional[str] = None, **kwargs): # pylint: disable=redefined-builtin """ :keyword id: Resource ID. :paramtype id: str """ - super(SubResource, self).__init__(**kwargs) + super().__init__(**kwargs) self.id = id -class TagCount(msrest.serialization.Model): +class TagCount(_serialization.Model): """Tag count. :ivar type: Type of count. @@ -2234,29 +2114,23 @@ class TagCount(msrest.serialization.Model): """ _attribute_map = { - 'type': {'key': 'type', 'type': 'str'}, - 'value': {'key': 'value', 'type': 'int'}, + "type": {"key": "type", "type": "str"}, + "value": {"key": "value", "type": "int"}, } - def __init__( - self, - *, - type: Optional[str] = None, - value: Optional[int] = None, - **kwargs - ): + def __init__(self, *, type: Optional[str] = None, value: Optional[int] = None, **kwargs): """ :keyword type: Type of count. :paramtype type: str :keyword value: Value of count. :paramtype value: int """ - super(TagCount, self).__init__(**kwargs) + super().__init__(**kwargs) self.type = type self.value = value -class TagDetails(msrest.serialization.Model): +class TagDetails(_serialization.Model): """Tag details. Variables are only populated by the server, and will be ignored when sending a request. @@ -2273,22 +2147,22 @@ class TagDetails(msrest.serialization.Model): """ _validation = { - 'id': {'readonly': True}, + "id": {"readonly": True}, } _attribute_map = { - 'id': {'key': 'id', 'type': 'str'}, - 'tag_name': {'key': 'tagName', 'type': 'str'}, - 'count': {'key': 'count', 'type': 'TagCount'}, - 'values': {'key': 'values', 'type': '[TagValue]'}, + "id": {"key": "id", "type": "str"}, + "tag_name": {"key": "tagName", "type": "str"}, + "count": {"key": "count", "type": "TagCount"}, + "values": {"key": "values", "type": "[TagValue]"}, } def __init__( self, *, tag_name: Optional[str] = None, - count: Optional["TagCount"] = None, - values: Optional[List["TagValue"]] = None, + count: Optional["_models.TagCount"] = None, + values: Optional[List["_models.TagValue"]] = None, **kwargs ): """ @@ -2300,14 +2174,14 @@ def __init__( :keyword values: The list of tag values. :paramtype values: list[~azure.mgmt.resource.resources.v2019_05_01.models.TagValue] """ - super(TagDetails, self).__init__(**kwargs) + super().__init__(**kwargs) self.id = None self.tag_name = tag_name self.count = count self.values = values -class TagsListResult(msrest.serialization.Model): +class TagsListResult(_serialization.Model): """List of subscription tags. Variables are only populated by the server, and will be ignored when sending a request. @@ -2319,30 +2193,25 @@ class TagsListResult(msrest.serialization.Model): """ _validation = { - 'next_link': {'readonly': True}, + "next_link": {"readonly": True}, } _attribute_map = { - 'value': {'key': 'value', 'type': '[TagDetails]'}, - 'next_link': {'key': 'nextLink', 'type': 'str'}, + "value": {"key": "value", "type": "[TagDetails]"}, + "next_link": {"key": "nextLink", "type": "str"}, } - def __init__( - self, - *, - value: Optional[List["TagDetails"]] = None, - **kwargs - ): + def __init__(self, *, value: Optional[List["_models.TagDetails"]] = None, **kwargs): """ :keyword value: An array of tags. :paramtype value: list[~azure.mgmt.resource.resources.v2019_05_01.models.TagDetails] """ - super(TagsListResult, self).__init__(**kwargs) + super().__init__(**kwargs) self.value = value self.next_link = None -class TagValue(msrest.serialization.Model): +class TagValue(_serialization.Model): """Tag information. Variables are only populated by the server, and will be ignored when sending a request. @@ -2356,35 +2225,29 @@ class TagValue(msrest.serialization.Model): """ _validation = { - 'id': {'readonly': True}, + "id": {"readonly": True}, } _attribute_map = { - 'id': {'key': 'id', 'type': 'str'}, - 'tag_value': {'key': 'tagValue', 'type': 'str'}, - 'count': {'key': 'count', 'type': 'TagCount'}, + "id": {"key": "id", "type": "str"}, + "tag_value": {"key": "tagValue", "type": "str"}, + "count": {"key": "count", "type": "TagCount"}, } - def __init__( - self, - *, - tag_value: Optional[str] = None, - count: Optional["TagCount"] = None, - **kwargs - ): + def __init__(self, *, tag_value: Optional[str] = None, count: Optional["_models.TagCount"] = None, **kwargs): """ :keyword tag_value: The tag value. :paramtype tag_value: str :keyword count: The tag value count. :paramtype count: ~azure.mgmt.resource.resources.v2019_05_01.models.TagCount """ - super(TagValue, self).__init__(**kwargs) + super().__init__(**kwargs) self.id = None self.tag_value = tag_value self.count = count -class TargetResource(msrest.serialization.Model): +class TargetResource(_serialization.Model): """Target resource. :ivar id: The ID of the resource. @@ -2396,15 +2259,15 @@ class TargetResource(msrest.serialization.Model): """ _attribute_map = { - 'id': {'key': 'id', 'type': 'str'}, - 'resource_name': {'key': 'resourceName', 'type': 'str'}, - 'resource_type': {'key': 'resourceType', 'type': 'str'}, + "id": {"key": "id", "type": "str"}, + "resource_name": {"key": "resourceName", "type": "str"}, + "resource_type": {"key": "resourceType", "type": "str"}, } def __init__( self, *, - id: Optional[str] = None, + id: Optional[str] = None, # pylint: disable=redefined-builtin resource_name: Optional[str] = None, resource_type: Optional[str] = None, **kwargs @@ -2417,13 +2280,13 @@ def __init__( :keyword resource_type: The type of the resource. :paramtype resource_type: str """ - super(TargetResource, self).__init__(**kwargs) + super().__init__(**kwargs) self.id = id self.resource_name = resource_name self.resource_type = resource_type -class TemplateHashResult(msrest.serialization.Model): +class TemplateHashResult(_serialization.Model): """Result of the request to calculate template hash. It contains a string of minified template and its hash. :ivar minified_template: The minified template string. @@ -2433,67 +2296,55 @@ class TemplateHashResult(msrest.serialization.Model): """ _attribute_map = { - 'minified_template': {'key': 'minifiedTemplate', 'type': 'str'}, - 'template_hash': {'key': 'templateHash', 'type': 'str'}, + "minified_template": {"key": "minifiedTemplate", "type": "str"}, + "template_hash": {"key": "templateHash", "type": "str"}, } - def __init__( - self, - *, - minified_template: Optional[str] = None, - template_hash: Optional[str] = None, - **kwargs - ): + def __init__(self, *, minified_template: Optional[str] = None, template_hash: Optional[str] = None, **kwargs): """ :keyword minified_template: The minified template string. :paramtype minified_template: str :keyword template_hash: The template hash. :paramtype template_hash: str """ - super(TemplateHashResult, self).__init__(**kwargs) + super().__init__(**kwargs) self.minified_template = minified_template self.template_hash = template_hash -class TemplateLink(msrest.serialization.Model): +class TemplateLink(_serialization.Model): """Entity representing the reference to the template. All required parameters must be populated in order to send to Azure. - :ivar uri: Required. The URI of the template to deploy. + :ivar uri: The URI of the template to deploy. Required. :vartype uri: str :ivar content_version: If included, must match the ContentVersion in the template. :vartype content_version: str """ _validation = { - 'uri': {'required': True}, + "uri": {"required": True}, } _attribute_map = { - 'uri': {'key': 'uri', 'type': 'str'}, - 'content_version': {'key': 'contentVersion', 'type': 'str'}, + "uri": {"key": "uri", "type": "str"}, + "content_version": {"key": "contentVersion", "type": "str"}, } - def __init__( - self, - *, - uri: str, - content_version: Optional[str] = None, - **kwargs - ): + def __init__(self, *, uri: str, content_version: Optional[str] = None, **kwargs): """ - :keyword uri: Required. The URI of the template to deploy. + :keyword uri: The URI of the template to deploy. Required. :paramtype uri: str :keyword content_version: If included, must match the ContentVersion in the template. :paramtype content_version: str """ - super(TemplateLink, self).__init__(**kwargs) + super().__init__(**kwargs) self.uri = uri self.content_version = content_version -class ZoneMapping(msrest.serialization.Model): +class ZoneMapping(_serialization.Model): """ZoneMapping. :ivar location: The location of the zone mapping. @@ -2503,23 +2354,17 @@ class ZoneMapping(msrest.serialization.Model): """ _attribute_map = { - 'location': {'key': 'location', 'type': 'str'}, - 'zones': {'key': 'zones', 'type': '[str]'}, + "location": {"key": "location", "type": "str"}, + "zones": {"key": "zones", "type": "[str]"}, } - def __init__( - self, - *, - location: Optional[str] = None, - zones: Optional[List[str]] = None, - **kwargs - ): + def __init__(self, *, location: Optional[str] = None, zones: Optional[List[str]] = None, **kwargs): """ :keyword location: The location of the zone mapping. :paramtype location: str :keyword zones: :paramtype zones: list[str] """ - super(ZoneMapping, self).__init__(**kwargs) + super().__init__(**kwargs) self.location = location self.zones = zones diff --git a/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/resources/v2019_05_01/models/_patch.py b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/resources/v2019_05_01/models/_patch.py new file mode 100644 index 0000000000000..f7dd32510333d --- /dev/null +++ b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/resources/v2019_05_01/models/_patch.py @@ -0,0 +1,20 @@ +# ------------------------------------ +# Copyright (c) Microsoft Corporation. +# Licensed under the MIT License. +# ------------------------------------ +"""Customize generated code here. + +Follow our quickstart for examples: https://aka.ms/azsdk/python/dpcodegen/python/customize +""" +from typing import List + +__all__: List[str] = [] # Add all objects you want publicly available to users at this package level + + +def patch_sdk(): + """Do not remove from this file. + + `patch_sdk` is a last resort escape hatch that allows you to do customizations + you can't accomplish using the techniques described in + https://aka.ms/azsdk/python/dpcodegen/python/customize + """ diff --git a/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/resources/v2019_05_01/models/_resource_management_client_enums.py b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/resources/v2019_05_01/models/_resource_management_client_enums.py index 02799db402bcc..612a5242cd9bd 100644 --- a/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/resources/v2019_05_01/models/_resource_management_client_enums.py +++ b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/resources/v2019_05_01/models/_resource_management_client_enums.py @@ -7,11 +7,10 @@ # -------------------------------------------------------------------------- from enum import Enum -from six import with_metaclass from azure.core import CaseInsensitiveEnumMeta -class DeploymentMode(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): +class DeploymentMode(str, Enum, metaclass=CaseInsensitiveEnumMeta): """The mode that is used to deploy resources. This value can be either Incremental or Complete. In Incremental mode, resources are deployed without deleting existing resources that are not included in the template. In Complete mode, resources are deployed and existing resources in @@ -22,7 +21,8 @@ class DeploymentMode(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): INCREMENTAL = "Incremental" COMPLETE = "Complete" -class OnErrorDeploymentType(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): + +class OnErrorDeploymentType(str, Enum, metaclass=CaseInsensitiveEnumMeta): """The deployment on error behavior type. Possible values are LastSuccessful and SpecificDeployment. """ @@ -30,9 +30,9 @@ class OnErrorDeploymentType(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): LAST_SUCCESSFUL = "LastSuccessful" SPECIFIC_DEPLOYMENT = "SpecificDeployment" -class ResourceIdentityType(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): - """The identity type. - """ + +class ResourceIdentityType(str, Enum, metaclass=CaseInsensitiveEnumMeta): + """The identity type.""" SYSTEM_ASSIGNED = "SystemAssigned" USER_ASSIGNED = "UserAssigned" diff --git a/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/resources/v2019_05_01/operations/__init__.py b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/resources/v2019_05_01/operations/__init__.py index 53876d82bf5d7..804fee65e3137 100644 --- a/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/resources/v2019_05_01/operations/__init__.py +++ b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/resources/v2019_05_01/operations/__init__.py @@ -14,12 +14,18 @@ from ._operations import TagsOperations from ._operations import DeploymentOperationsOperations +from ._patch import __all__ as _patch_all +from ._patch import * # type: ignore # pylint: disable=unused-wildcard-import +from ._patch import patch_sdk as _patch_sdk + __all__ = [ - 'Operations', - 'DeploymentsOperations', - 'ProvidersOperations', - 'ResourcesOperations', - 'ResourceGroupsOperations', - 'TagsOperations', - 'DeploymentOperationsOperations', + "Operations", + "DeploymentsOperations", + "ProvidersOperations", + "ResourcesOperations", + "ResourceGroupsOperations", + "TagsOperations", + "DeploymentOperationsOperations", ] +__all__.extend([p for p in _patch_all if p not in __all__]) +_patch_sdk() diff --git a/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/resources/v2019_05_01/operations/_operations.py b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/resources/v2019_05_01/operations/_operations.py index a25fce425dab9..b6060621c39cd 100644 --- a/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/resources/v2019_05_01/operations/_operations.py +++ b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/resources/v2019_05_01/operations/_operations.py @@ -6,853 +6,777 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -from typing import Any, Callable, Dict, Iterable, Optional, TypeVar, Union - -from msrest import Serializer - -from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error +import sys +from typing import Any, Callable, Dict, IO, Iterable, Optional, TypeVar, Union, cast, overload +from urllib.parse import parse_qs, urljoin, urlparse + +from azure.core.exceptions import ( + ClientAuthenticationError, + HttpResponseError, + ResourceExistsError, + ResourceNotFoundError, + ResourceNotModifiedError, + map_error, +) from azure.core.paging import ItemPaged from azure.core.pipeline import PipelineResponse from azure.core.pipeline.transport import HttpResponse from azure.core.polling import LROPoller, NoPolling, PollingMethod from azure.core.rest import HttpRequest from azure.core.tracing.decorator import distributed_trace +from azure.core.utils import case_insensitive_dict from azure.mgmt.core.exceptions import ARMErrorFormat from azure.mgmt.core.polling.arm_polling import ARMPolling from .. import models as _models +from ..._serialization import Serializer from .._vendor import _convert_request, _format_url_section -T = TypeVar('T') + +T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] -JSONType = Any +if sys.version_info >= (3, 9): + from collections.abc import MutableMapping +else: + from typing import MutableMapping # type: ignore # pylint: disable=ungrouped-imports +JSON = MutableMapping[str, Any] # pylint: disable=unsubscriptable-object _SERIALIZER = Serializer() _SERIALIZER.client_side_validation = False -def build_operations_list_request( - **kwargs: Any -) -> HttpRequest: - api_version = kwargs.pop('api_version', "2019-05-01") # type: str - accept = "application/json" +def build_operations_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", "2019-05-01")) # type: str + accept = _headers.pop("Accept", "application/json") + # Construct URL _url = kwargs.pop("template_url", "/providers/Microsoft.Resources/operations") # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') - - return HttpRequest( - method="GET", - url=_url, - params=_query_parameters, - headers=_header_parameters, - **kwargs - ) + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) -def build_deployments_delete_at_management_group_scope_request_initial( - group_id: str, - deployment_name: str, - **kwargs: Any + +def build_deployments_delete_at_management_group_scope_request( + group_id: str, deployment_name: str, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2019-05-01") # type: str + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + api_version = kwargs.pop("api_version", _params.pop("api-version", "2019-05-01")) # type: str # Construct URL - _url = kwargs.pop("template_url", "/providers/Microsoft.Management/managementGroups/{groupId}/providers/Microsoft.Resources/deployments/{deploymentName}") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", + "/providers/Microsoft.Management/managementGroups/{groupId}/providers/Microsoft.Resources/deployments/{deploymentName}", + ) # pylint: disable=line-too-long path_format_arguments = { - "groupId": _SERIALIZER.url("group_id", group_id, 'str', max_length=90, min_length=1), - "deploymentName": _SERIALIZER.url("deployment_name", deployment_name, 'str', max_length=64, min_length=1, pattern=r'^[-\w\._\(\)]+$'), + "groupId": _SERIALIZER.url("group_id", group_id, "str", max_length=90, min_length=1), + "deploymentName": _SERIALIZER.url( + "deployment_name", deployment_name, "str", max_length=64, min_length=1, pattern=r"^[-\w\._\(\)]+$" + ), } _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') - - return HttpRequest( - method="DELETE", - url=_url, - params=_query_parameters, - **kwargs - ) + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") + + return HttpRequest(method="DELETE", url=_url, params=_params, **kwargs) def build_deployments_check_existence_at_management_group_scope_request( - group_id: str, - deployment_name: str, - **kwargs: Any + group_id: str, deployment_name: str, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2019-05-01") # type: str + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + api_version = kwargs.pop("api_version", _params.pop("api-version", "2019-05-01")) # type: str # Construct URL - _url = kwargs.pop("template_url", "/providers/Microsoft.Management/managementGroups/{groupId}/providers/Microsoft.Resources/deployments/{deploymentName}") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", + "/providers/Microsoft.Management/managementGroups/{groupId}/providers/Microsoft.Resources/deployments/{deploymentName}", + ) # pylint: disable=line-too-long path_format_arguments = { - "groupId": _SERIALIZER.url("group_id", group_id, 'str', max_length=90, min_length=1), - "deploymentName": _SERIALIZER.url("deployment_name", deployment_name, 'str', max_length=64, min_length=1, pattern=r'^[-\w\._\(\)]+$'), + "groupId": _SERIALIZER.url("group_id", group_id, "str", max_length=90, min_length=1), + "deploymentName": _SERIALIZER.url( + "deployment_name", deployment_name, "str", max_length=64, min_length=1, pattern=r"^[-\w\._\(\)]+$" + ), } _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') - - return HttpRequest( - method="HEAD", - url=_url, - params=_query_parameters, - **kwargs - ) + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") + return HttpRequest(method="HEAD", url=_url, params=_params, **kwargs) -def build_deployments_create_or_update_at_management_group_scope_request_initial( - group_id: str, - deployment_name: str, - *, - json: JSONType = None, - content: Any = None, - **kwargs: Any + +def build_deployments_create_or_update_at_management_group_scope_request( + group_id: str, deployment_name: str, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2019-05-01") # type: str - content_type = kwargs.pop('content_type', None) # type: Optional[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", "2019-05-01")) # type: str + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + accept = _headers.pop("Accept", "application/json") - accept = "application/json" # Construct URL - _url = kwargs.pop("template_url", "/providers/Microsoft.Management/managementGroups/{groupId}/providers/Microsoft.Resources/deployments/{deploymentName}") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", + "/providers/Microsoft.Management/managementGroups/{groupId}/providers/Microsoft.Resources/deployments/{deploymentName}", + ) # pylint: disable=line-too-long path_format_arguments = { - "groupId": _SERIALIZER.url("group_id", group_id, 'str', max_length=90, min_length=1), - "deploymentName": _SERIALIZER.url("deployment_name", deployment_name, 'str', max_length=64, min_length=1, pattern=r'^[-\w\._\(\)]+$'), + "groupId": _SERIALIZER.url("group_id", group_id, "str", max_length=90, min_length=1), + "deploymentName": _SERIALIZER.url( + "deployment_name", deployment_name, "str", max_length=64, min_length=1, pattern=r"^[-\w\._\(\)]+$" + ), } _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] if content_type is not None: - _header_parameters['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') - _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') - - return HttpRequest( - method="PUT", - url=_url, - params=_query_parameters, - headers=_header_parameters, - json=json, - content=content, - **kwargs - ) + _headers["Content-Type"] = _SERIALIZER.header("content_type", content_type, "str") + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="PUT", url=_url, params=_params, headers=_headers, **kwargs) def build_deployments_get_at_management_group_scope_request( - group_id: str, - deployment_name: str, - **kwargs: Any + group_id: str, deployment_name: str, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2019-05-01") # type: 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", "2019-05-01")) # type: str + accept = _headers.pop("Accept", "application/json") - accept = "application/json" # Construct URL - _url = kwargs.pop("template_url", "/providers/Microsoft.Management/managementGroups/{groupId}/providers/Microsoft.Resources/deployments/{deploymentName}") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", + "/providers/Microsoft.Management/managementGroups/{groupId}/providers/Microsoft.Resources/deployments/{deploymentName}", + ) # pylint: disable=line-too-long path_format_arguments = { - "groupId": _SERIALIZER.url("group_id", group_id, 'str', max_length=90, min_length=1), - "deploymentName": _SERIALIZER.url("deployment_name", deployment_name, 'str', max_length=64, min_length=1, pattern=r'^[-\w\._\(\)]+$'), + "groupId": _SERIALIZER.url("group_id", group_id, "str", max_length=90, min_length=1), + "deploymentName": _SERIALIZER.url( + "deployment_name", deployment_name, "str", max_length=64, min_length=1, pattern=r"^[-\w\._\(\)]+$" + ), } _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') - - return HttpRequest( - method="GET", - url=_url, - params=_query_parameters, - headers=_header_parameters, - **kwargs - ) + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) def build_deployments_cancel_at_management_group_scope_request( - group_id: str, - deployment_name: str, - **kwargs: Any + group_id: str, deployment_name: str, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2019-05-01") # type: str + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + api_version = kwargs.pop("api_version", _params.pop("api-version", "2019-05-01")) # type: str # Construct URL - _url = kwargs.pop("template_url", "/providers/Microsoft.Management/managementGroups/{groupId}/providers/Microsoft.Resources/deployments/{deploymentName}/cancel") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", + "/providers/Microsoft.Management/managementGroups/{groupId}/providers/Microsoft.Resources/deployments/{deploymentName}/cancel", + ) # pylint: disable=line-too-long path_format_arguments = { - "groupId": _SERIALIZER.url("group_id", group_id, 'str', max_length=90, min_length=1), - "deploymentName": _SERIALIZER.url("deployment_name", deployment_name, 'str', max_length=64, min_length=1, pattern=r'^[-\w\._\(\)]+$'), + "groupId": _SERIALIZER.url("group_id", group_id, "str", max_length=90, min_length=1), + "deploymentName": _SERIALIZER.url( + "deployment_name", deployment_name, "str", max_length=64, min_length=1, pattern=r"^[-\w\._\(\)]+$" + ), } _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') - - return HttpRequest( - method="POST", - url=_url, - params=_query_parameters, - **kwargs - ) + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") + + return HttpRequest(method="POST", url=_url, params=_params, **kwargs) def build_deployments_validate_at_management_group_scope_request( - group_id: str, - deployment_name: str, - *, - json: JSONType = None, - content: Any = None, - **kwargs: Any + group_id: str, deployment_name: str, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2019-05-01") # type: str - content_type = kwargs.pop('content_type', None) # type: Optional[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", "2019-05-01")) # type: str + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + accept = _headers.pop("Accept", "application/json") - accept = "application/json" # Construct URL - _url = kwargs.pop("template_url", "/providers/Microsoft.Management/managementGroups/{groupId}/providers/Microsoft.Resources/deployments/{deploymentName}/validate") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", + "/providers/Microsoft.Management/managementGroups/{groupId}/providers/Microsoft.Resources/deployments/{deploymentName}/validate", + ) # pylint: disable=line-too-long path_format_arguments = { - "groupId": _SERIALIZER.url("group_id", group_id, 'str', max_length=90, min_length=1), - "deploymentName": _SERIALIZER.url("deployment_name", deployment_name, 'str', max_length=64, min_length=1, pattern=r'^[-\w\._\(\)]+$'), + "groupId": _SERIALIZER.url("group_id", group_id, "str", max_length=90, min_length=1), + "deploymentName": _SERIALIZER.url( + "deployment_name", deployment_name, "str", max_length=64, min_length=1, pattern=r"^[-\w\._\(\)]+$" + ), } _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] if content_type is not None: - _header_parameters['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') - _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') - - return HttpRequest( - method="POST", - url=_url, - params=_query_parameters, - headers=_header_parameters, - json=json, - content=content, - **kwargs - ) + _headers["Content-Type"] = _SERIALIZER.header("content_type", content_type, "str") + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="POST", url=_url, params=_params, headers=_headers, **kwargs) def build_deployments_export_template_at_management_group_scope_request( - group_id: str, - deployment_name: str, - **kwargs: Any + group_id: str, deployment_name: str, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2019-05-01") # type: 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", "2019-05-01")) # type: str + accept = _headers.pop("Accept", "application/json") - accept = "application/json" # Construct URL - _url = kwargs.pop("template_url", "/providers/Microsoft.Management/managementGroups/{groupId}/providers/Microsoft.Resources/deployments/{deploymentName}/exportTemplate") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", + "/providers/Microsoft.Management/managementGroups/{groupId}/providers/Microsoft.Resources/deployments/{deploymentName}/exportTemplate", + ) # pylint: disable=line-too-long path_format_arguments = { - "groupId": _SERIALIZER.url("group_id", group_id, 'str', max_length=90, min_length=1), - "deploymentName": _SERIALIZER.url("deployment_name", deployment_name, 'str', max_length=64, min_length=1, pattern=r'^[-\w\._\(\)]+$'), + "groupId": _SERIALIZER.url("group_id", group_id, "str", max_length=90, min_length=1), + "deploymentName": _SERIALIZER.url( + "deployment_name", deployment_name, "str", max_length=64, min_length=1, pattern=r"^[-\w\._\(\)]+$" + ), } _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') - - return HttpRequest( - method="POST", - url=_url, - params=_query_parameters, - headers=_header_parameters, - **kwargs - ) + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="POST", url=_url, params=_params, headers=_headers, **kwargs) def build_deployments_list_at_management_group_scope_request( - group_id: str, - *, - filter: Optional[str] = None, - top: Optional[int] = None, - **kwargs: Any + group_id: str, *, filter: Optional[str] = None, top: Optional[int] = None, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2019-05-01") # type: 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", "2019-05-01")) # type: str + accept = _headers.pop("Accept", "application/json") - accept = "application/json" # Construct URL - _url = kwargs.pop("template_url", "/providers/Microsoft.Management/managementGroups/{groupId}/providers/Microsoft.Resources/deployments/") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", + "/providers/Microsoft.Management/managementGroups/{groupId}/providers/Microsoft.Resources/deployments/", + ) # pylint: disable=line-too-long path_format_arguments = { - "groupId": _SERIALIZER.url("group_id", group_id, 'str', max_length=90, min_length=1), + "groupId": _SERIALIZER.url("group_id", group_id, "str", max_length=90, min_length=1), } _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] if filter is not None: - _query_parameters['$filter'] = _SERIALIZER.query("filter", filter, 'str') + _params["$filter"] = _SERIALIZER.query("filter", filter, "str") if top is not None: - _query_parameters['$top'] = _SERIALIZER.query("top", top, 'int') - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["$top"] = _SERIALIZER.query("top", top, "int") + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') - - return HttpRequest( - method="GET", - url=_url, - params=_query_parameters, - headers=_header_parameters, - **kwargs - ) + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) -def build_deployments_delete_at_subscription_scope_request_initial( - deployment_name: str, - subscription_id: str, - **kwargs: Any + +def build_deployments_delete_at_subscription_scope_request( + deployment_name: str, subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2019-05-01") # type: str + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + api_version = kwargs.pop("api_version", _params.pop("api-version", "2019-05-01")) # type: str # Construct URL - _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/providers/Microsoft.Resources/deployments/{deploymentName}") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", "/subscriptions/{subscriptionId}/providers/Microsoft.Resources/deployments/{deploymentName}" + ) # pylint: disable=line-too-long path_format_arguments = { - "deploymentName": _SERIALIZER.url("deployment_name", deployment_name, 'str', max_length=64, min_length=1, pattern=r'^[-\w\._\(\)]+$'), - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), + "deploymentName": _SERIALIZER.url( + "deployment_name", deployment_name, "str", max_length=64, min_length=1, pattern=r"^[-\w\._\(\)]+$" + ), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), } _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') - - return HttpRequest( - method="DELETE", - url=_url, - params=_query_parameters, - **kwargs - ) + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") + + return HttpRequest(method="DELETE", url=_url, params=_params, **kwargs) def build_deployments_check_existence_at_subscription_scope_request( - deployment_name: str, - subscription_id: str, - **kwargs: Any + deployment_name: str, subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2019-05-01") # type: str + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + api_version = kwargs.pop("api_version", _params.pop("api-version", "2019-05-01")) # type: str # Construct URL - _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/providers/Microsoft.Resources/deployments/{deploymentName}") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", "/subscriptions/{subscriptionId}/providers/Microsoft.Resources/deployments/{deploymentName}" + ) # pylint: disable=line-too-long path_format_arguments = { - "deploymentName": _SERIALIZER.url("deployment_name", deployment_name, 'str', max_length=64, min_length=1, pattern=r'^[-\w\._\(\)]+$'), - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), + "deploymentName": _SERIALIZER.url( + "deployment_name", deployment_name, "str", max_length=64, min_length=1, pattern=r"^[-\w\._\(\)]+$" + ), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), } _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') - - return HttpRequest( - method="HEAD", - url=_url, - params=_query_parameters, - **kwargs - ) + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") + return HttpRequest(method="HEAD", url=_url, params=_params, **kwargs) -def build_deployments_create_or_update_at_subscription_scope_request_initial( - deployment_name: str, - subscription_id: str, - *, - json: JSONType = None, - content: Any = None, - **kwargs: Any + +def build_deployments_create_or_update_at_subscription_scope_request( + deployment_name: str, subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2019-05-01") # type: str - content_type = kwargs.pop('content_type', None) # type: Optional[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", "2019-05-01")) # type: str + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + accept = _headers.pop("Accept", "application/json") - accept = "application/json" # Construct URL - _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/providers/Microsoft.Resources/deployments/{deploymentName}") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", "/subscriptions/{subscriptionId}/providers/Microsoft.Resources/deployments/{deploymentName}" + ) # pylint: disable=line-too-long path_format_arguments = { - "deploymentName": _SERIALIZER.url("deployment_name", deployment_name, 'str', max_length=64, min_length=1, pattern=r'^[-\w\._\(\)]+$'), - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), + "deploymentName": _SERIALIZER.url( + "deployment_name", deployment_name, "str", max_length=64, min_length=1, pattern=r"^[-\w\._\(\)]+$" + ), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), } _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] if content_type is not None: - _header_parameters['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') - _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') - - return HttpRequest( - method="PUT", - url=_url, - params=_query_parameters, - headers=_header_parameters, - json=json, - content=content, - **kwargs - ) + _headers["Content-Type"] = _SERIALIZER.header("content_type", content_type, "str") + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="PUT", url=_url, params=_params, headers=_headers, **kwargs) def build_deployments_get_at_subscription_scope_request( - deployment_name: str, - subscription_id: str, - **kwargs: Any + deployment_name: str, subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2019-05-01") # type: 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", "2019-05-01")) # type: str + accept = _headers.pop("Accept", "application/json") - accept = "application/json" # Construct URL - _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/providers/Microsoft.Resources/deployments/{deploymentName}") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", "/subscriptions/{subscriptionId}/providers/Microsoft.Resources/deployments/{deploymentName}" + ) # pylint: disable=line-too-long path_format_arguments = { - "deploymentName": _SERIALIZER.url("deployment_name", deployment_name, 'str', max_length=64, min_length=1, pattern=r'^[-\w\._\(\)]+$'), - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), + "deploymentName": _SERIALIZER.url( + "deployment_name", deployment_name, "str", max_length=64, min_length=1, pattern=r"^[-\w\._\(\)]+$" + ), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), } _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') - - return HttpRequest( - method="GET", - url=_url, - params=_query_parameters, - headers=_header_parameters, - **kwargs - ) + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) def build_deployments_cancel_at_subscription_scope_request( - deployment_name: str, - subscription_id: str, - **kwargs: Any + deployment_name: str, subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2019-05-01") # type: str + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + api_version = kwargs.pop("api_version", _params.pop("api-version", "2019-05-01")) # type: str # Construct URL - _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/providers/Microsoft.Resources/deployments/{deploymentName}/cancel") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/providers/Microsoft.Resources/deployments/{deploymentName}/cancel", + ) # pylint: disable=line-too-long path_format_arguments = { - "deploymentName": _SERIALIZER.url("deployment_name", deployment_name, 'str', max_length=64, min_length=1, pattern=r'^[-\w\._\(\)]+$'), - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), + "deploymentName": _SERIALIZER.url( + "deployment_name", deployment_name, "str", max_length=64, min_length=1, pattern=r"^[-\w\._\(\)]+$" + ), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), } _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') - - return HttpRequest( - method="POST", - url=_url, - params=_query_parameters, - **kwargs - ) + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") + + return HttpRequest(method="POST", url=_url, params=_params, **kwargs) def build_deployments_validate_at_subscription_scope_request( - deployment_name: str, - subscription_id: str, - *, - json: JSONType = None, - content: Any = None, - **kwargs: Any + deployment_name: str, subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2019-05-01") # type: str - content_type = kwargs.pop('content_type', None) # type: Optional[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", "2019-05-01")) # type: str + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + accept = _headers.pop("Accept", "application/json") - accept = "application/json" # Construct URL - _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/providers/Microsoft.Resources/deployments/{deploymentName}/validate") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/providers/Microsoft.Resources/deployments/{deploymentName}/validate", + ) # pylint: disable=line-too-long path_format_arguments = { - "deploymentName": _SERIALIZER.url("deployment_name", deployment_name, 'str', max_length=64, min_length=1, pattern=r'^[-\w\._\(\)]+$'), - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), + "deploymentName": _SERIALIZER.url( + "deployment_name", deployment_name, "str", max_length=64, min_length=1, pattern=r"^[-\w\._\(\)]+$" + ), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), } _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] if content_type is not None: - _header_parameters['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') - _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') - - return HttpRequest( - method="POST", - url=_url, - params=_query_parameters, - headers=_header_parameters, - json=json, - content=content, - **kwargs - ) + _headers["Content-Type"] = _SERIALIZER.header("content_type", content_type, "str") + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="POST", url=_url, params=_params, headers=_headers, **kwargs) def build_deployments_export_template_at_subscription_scope_request( - deployment_name: str, - subscription_id: str, - **kwargs: Any + deployment_name: str, subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2019-05-01") # type: 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", "2019-05-01")) # type: str + accept = _headers.pop("Accept", "application/json") - accept = "application/json" # Construct URL - _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/providers/Microsoft.Resources/deployments/{deploymentName}/exportTemplate") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/providers/Microsoft.Resources/deployments/{deploymentName}/exportTemplate", + ) # pylint: disable=line-too-long path_format_arguments = { - "deploymentName": _SERIALIZER.url("deployment_name", deployment_name, 'str', max_length=64, min_length=1, pattern=r'^[-\w\._\(\)]+$'), - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), + "deploymentName": _SERIALIZER.url( + "deployment_name", deployment_name, "str", max_length=64, min_length=1, pattern=r"^[-\w\._\(\)]+$" + ), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), } _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') - - return HttpRequest( - method="POST", - url=_url, - params=_query_parameters, - headers=_header_parameters, - **kwargs - ) + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="POST", url=_url, params=_params, headers=_headers, **kwargs) def build_deployments_list_at_subscription_scope_request( - subscription_id: str, - *, - filter: Optional[str] = None, - top: Optional[int] = None, - **kwargs: Any + subscription_id: str, *, filter: Optional[str] = None, top: Optional[int] = None, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2019-05-01") # type: 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", "2019-05-01")) # type: str + accept = _headers.pop("Accept", "application/json") - accept = "application/json" # Construct URL _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/providers/Microsoft.Resources/deployments/") path_format_arguments = { - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), } _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] if filter is not None: - _query_parameters['$filter'] = _SERIALIZER.query("filter", filter, 'str') + _params["$filter"] = _SERIALIZER.query("filter", filter, "str") if top is not None: - _query_parameters['$top'] = _SERIALIZER.query("top", top, 'int') - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["$top"] = _SERIALIZER.query("top", top, "int") + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') - - return HttpRequest( - method="GET", - url=_url, - params=_query_parameters, - headers=_header_parameters, - **kwargs - ) + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) -def build_deployments_delete_request_initial( - resource_group_name: str, - deployment_name: str, - subscription_id: str, - **kwargs: Any + +def build_deployments_delete_request( + resource_group_name: str, deployment_name: str, subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2019-05-01") # type: str + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + api_version = kwargs.pop("api_version", _params.pop("api-version", "2019-05-01")) # type: str # Construct URL - _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/Microsoft.Resources/deployments/{deploymentName}") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/Microsoft.Resources/deployments/{deploymentName}", + ) # pylint: disable=line-too-long path_format_arguments = { - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._\(\)]+$'), - "deploymentName": _SERIALIZER.url("deployment_name", deployment_name, 'str', max_length=64, min_length=1, pattern=r'^[-\w\._\(\)]+$'), - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), + "resourceGroupName": _SERIALIZER.url( + "resource_group_name", resource_group_name, "str", max_length=90, min_length=1, pattern=r"^[-\w\._\(\)]+$" + ), + "deploymentName": _SERIALIZER.url( + "deployment_name", deployment_name, "str", max_length=64, min_length=1, pattern=r"^[-\w\._\(\)]+$" + ), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), } _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') - - return HttpRequest( - method="DELETE", - url=_url, - params=_query_parameters, - **kwargs - ) + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") + + return HttpRequest(method="DELETE", url=_url, params=_params, **kwargs) def build_deployments_check_existence_request( - resource_group_name: str, - deployment_name: str, - subscription_id: str, - **kwargs: Any + resource_group_name: str, deployment_name: str, subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2019-05-01") # type: str + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + api_version = kwargs.pop("api_version", _params.pop("api-version", "2019-05-01")) # type: str # Construct URL - _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/Microsoft.Resources/deployments/{deploymentName}") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/Microsoft.Resources/deployments/{deploymentName}", + ) # pylint: disable=line-too-long path_format_arguments = { - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._\(\)]+$'), - "deploymentName": _SERIALIZER.url("deployment_name", deployment_name, 'str', max_length=64, min_length=1, pattern=r'^[-\w\._\(\)]+$'), - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), + "resourceGroupName": _SERIALIZER.url( + "resource_group_name", resource_group_name, "str", max_length=90, min_length=1, pattern=r"^[-\w\._\(\)]+$" + ), + "deploymentName": _SERIALIZER.url( + "deployment_name", deployment_name, "str", max_length=64, min_length=1, pattern=r"^[-\w\._\(\)]+$" + ), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), } _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') - - return HttpRequest( - method="HEAD", - url=_url, - params=_query_parameters, - **kwargs - ) + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") + return HttpRequest(method="HEAD", url=_url, params=_params, **kwargs) -def build_deployments_create_or_update_request_initial( - resource_group_name: str, - deployment_name: str, - subscription_id: str, - *, - json: JSONType = None, - content: Any = None, - **kwargs: Any + +def build_deployments_create_or_update_request( + resource_group_name: str, deployment_name: str, subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2019-05-01") # type: str - content_type = kwargs.pop('content_type', None) # type: Optional[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", "2019-05-01")) # type: str + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + accept = _headers.pop("Accept", "application/json") - accept = "application/json" # Construct URL - _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/Microsoft.Resources/deployments/{deploymentName}") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/Microsoft.Resources/deployments/{deploymentName}", + ) # pylint: disable=line-too-long path_format_arguments = { - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._\(\)]+$'), - "deploymentName": _SERIALIZER.url("deployment_name", deployment_name, 'str', max_length=64, min_length=1, pattern=r'^[-\w\._\(\)]+$'), - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), + "resourceGroupName": _SERIALIZER.url( + "resource_group_name", resource_group_name, "str", max_length=90, min_length=1, pattern=r"^[-\w\._\(\)]+$" + ), + "deploymentName": _SERIALIZER.url( + "deployment_name", deployment_name, "str", max_length=64, min_length=1, pattern=r"^[-\w\._\(\)]+$" + ), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), } _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] if content_type is not None: - _header_parameters['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') - _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') - - return HttpRequest( - method="PUT", - url=_url, - params=_query_parameters, - headers=_header_parameters, - json=json, - content=content, - **kwargs - ) + _headers["Content-Type"] = _SERIALIZER.header("content_type", content_type, "str") + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="PUT", url=_url, params=_params, headers=_headers, **kwargs) def build_deployments_get_request( - resource_group_name: str, - deployment_name: str, - subscription_id: str, - **kwargs: Any + resource_group_name: str, deployment_name: str, subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2019-05-01") # type: 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", "2019-05-01")) # type: str + accept = _headers.pop("Accept", "application/json") - accept = "application/json" # Construct URL - _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/Microsoft.Resources/deployments/{deploymentName}") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/Microsoft.Resources/deployments/{deploymentName}", + ) # pylint: disable=line-too-long path_format_arguments = { - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._\(\)]+$'), - "deploymentName": _SERIALIZER.url("deployment_name", deployment_name, 'str', max_length=64, min_length=1, pattern=r'^[-\w\._\(\)]+$'), - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), + "resourceGroupName": _SERIALIZER.url( + "resource_group_name", resource_group_name, "str", max_length=90, min_length=1, pattern=r"^[-\w\._\(\)]+$" + ), + "deploymentName": _SERIALIZER.url( + "deployment_name", deployment_name, "str", max_length=64, min_length=1, pattern=r"^[-\w\._\(\)]+$" + ), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), } _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') - - return HttpRequest( - method="GET", - url=_url, - params=_query_parameters, - headers=_header_parameters, - **kwargs - ) + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) def build_deployments_cancel_request( - resource_group_name: str, - deployment_name: str, - subscription_id: str, - **kwargs: Any + resource_group_name: str, deployment_name: str, subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2019-05-01") # type: str + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + api_version = kwargs.pop("api_version", _params.pop("api-version", "2019-05-01")) # type: str # Construct URL - _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/Microsoft.Resources/deployments/{deploymentName}/cancel") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/Microsoft.Resources/deployments/{deploymentName}/cancel", + ) # pylint: disable=line-too-long path_format_arguments = { - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._\(\)]+$'), - "deploymentName": _SERIALIZER.url("deployment_name", deployment_name, 'str', max_length=64, min_length=1, pattern=r'^[-\w\._\(\)]+$'), - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), + "resourceGroupName": _SERIALIZER.url( + "resource_group_name", resource_group_name, "str", max_length=90, min_length=1, pattern=r"^[-\w\._\(\)]+$" + ), + "deploymentName": _SERIALIZER.url( + "deployment_name", deployment_name, "str", max_length=64, min_length=1, pattern=r"^[-\w\._\(\)]+$" + ), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), } _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') - - return HttpRequest( - method="POST", - url=_url, - params=_query_parameters, - **kwargs - ) + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") + + return HttpRequest(method="POST", url=_url, params=_params, **kwargs) def build_deployments_validate_request( - resource_group_name: str, - deployment_name: str, - subscription_id: str, - *, - json: JSONType = None, - content: Any = None, - **kwargs: Any + resource_group_name: str, deployment_name: str, subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2019-05-01") # type: str - content_type = kwargs.pop('content_type', None) # type: Optional[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", "2019-05-01")) # type: str + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + accept = _headers.pop("Accept", "application/json") - accept = "application/json" # Construct URL - _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/Microsoft.Resources/deployments/{deploymentName}/validate") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/Microsoft.Resources/deployments/{deploymentName}/validate", + ) # pylint: disable=line-too-long path_format_arguments = { - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._\(\)]+$'), - "deploymentName": _SERIALIZER.url("deployment_name", deployment_name, 'str', max_length=64, min_length=1, pattern=r'^[-\w\._\(\)]+$'), - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), + "resourceGroupName": _SERIALIZER.url( + "resource_group_name", resource_group_name, "str", max_length=90, min_length=1, pattern=r"^[-\w\._\(\)]+$" + ), + "deploymentName": _SERIALIZER.url( + "deployment_name", deployment_name, "str", max_length=64, min_length=1, pattern=r"^[-\w\._\(\)]+$" + ), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), } _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] if content_type is not None: - _header_parameters['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') - _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') - - return HttpRequest( - method="POST", - url=_url, - params=_query_parameters, - headers=_header_parameters, - json=json, - content=content, - **kwargs - ) + _headers["Content-Type"] = _SERIALIZER.header("content_type", content_type, "str") + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="POST", url=_url, params=_params, headers=_headers, **kwargs) def build_deployments_export_template_request( - resource_group_name: str, - deployment_name: str, - subscription_id: str, - **kwargs: Any + resource_group_name: str, deployment_name: str, subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2019-05-01") # type: 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", "2019-05-01")) # type: str + accept = _headers.pop("Accept", "application/json") - accept = "application/json" # Construct URL - _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/Microsoft.Resources/deployments/{deploymentName}/exportTemplate") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/Microsoft.Resources/deployments/{deploymentName}/exportTemplate", + ) # pylint: disable=line-too-long path_format_arguments = { - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._\(\)]+$'), - "deploymentName": _SERIALIZER.url("deployment_name", deployment_name, 'str', max_length=64, min_length=1, pattern=r'^[-\w\._\(\)]+$'), - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), + "resourceGroupName": _SERIALIZER.url( + "resource_group_name", resource_group_name, "str", max_length=90, min_length=1, pattern=r"^[-\w\._\(\)]+$" + ), + "deploymentName": _SERIALIZER.url( + "deployment_name", deployment_name, "str", max_length=64, min_length=1, pattern=r"^[-\w\._\(\)]+$" + ), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), } _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') - - return HttpRequest( - method="POST", - url=_url, - params=_query_parameters, - headers=_header_parameters, - **kwargs - ) + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="POST", url=_url, params=_params, headers=_headers, **kwargs) def build_deployments_list_by_resource_group_request( @@ -863,216 +787,174 @@ def build_deployments_list_by_resource_group_request( top: Optional[int] = None, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2019-05-01") # type: 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", "2019-05-01")) # type: str + accept = _headers.pop("Accept", "application/json") - accept = "application/json" # Construct URL - _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/Microsoft.Resources/deployments/") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/Microsoft.Resources/deployments/", + ) # pylint: disable=line-too-long path_format_arguments = { - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._\(\)]+$'), - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), + "resourceGroupName": _SERIALIZER.url( + "resource_group_name", resource_group_name, "str", max_length=90, min_length=1, pattern=r"^[-\w\._\(\)]+$" + ), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), } _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] if filter is not None: - _query_parameters['$filter'] = _SERIALIZER.query("filter", filter, 'str') + _params["$filter"] = _SERIALIZER.query("filter", filter, "str") if top is not None: - _query_parameters['$top'] = _SERIALIZER.query("top", top, 'int') - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["$top"] = _SERIALIZER.query("top", top, "int") + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') - - return HttpRequest( - method="GET", - url=_url, - params=_query_parameters, - headers=_header_parameters, - **kwargs - ) + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) -def build_deployments_calculate_template_hash_request( - *, - json: JSONType = None, - content: Any = None, - **kwargs: Any -) -> HttpRequest: - api_version = kwargs.pop('api_version', "2019-05-01") # type: str - content_type = kwargs.pop('content_type', None) # type: Optional[str] - accept = "application/json" +def build_deployments_calculate_template_hash_request(*, json: JSON, **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", "2019-05-01")) # type: str + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + accept = _headers.pop("Accept", "application/json") + # Construct URL _url = kwargs.pop("template_url", "/providers/Microsoft.Resources/calculateTemplateHash") # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] if content_type is not None: - _header_parameters['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') - _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') - - return HttpRequest( - method="POST", - url=_url, - params=_query_parameters, - headers=_header_parameters, - json=json, - content=content, - **kwargs - ) + _headers["Content-Type"] = _SERIALIZER.header("content_type", content_type, "str") + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="POST", url=_url, params=_params, headers=_headers, json=json, **kwargs) def build_providers_unregister_request( - resource_provider_namespace: str, - subscription_id: str, - **kwargs: Any + resource_provider_namespace: str, subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2019-05-01") # type: 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", "2019-05-01")) # type: str + accept = _headers.pop("Accept", "application/json") - accept = "application/json" # Construct URL - _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/providers/{resourceProviderNamespace}/unregister") + _url = kwargs.pop( + "template_url", "/subscriptions/{subscriptionId}/providers/{resourceProviderNamespace}/unregister" + ) path_format_arguments = { - "resourceProviderNamespace": _SERIALIZER.url("resource_provider_namespace", resource_provider_namespace, 'str'), - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), + "resourceProviderNamespace": _SERIALIZER.url("resource_provider_namespace", resource_provider_namespace, "str"), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), } _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') - - return HttpRequest( - method="POST", - url=_url, - params=_query_parameters, - headers=_header_parameters, - **kwargs - ) + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="POST", url=_url, params=_params, headers=_headers, **kwargs) def build_providers_register_request( - resource_provider_namespace: str, - subscription_id: str, - **kwargs: Any + resource_provider_namespace: str, subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2019-05-01") # type: 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", "2019-05-01")) # type: str + accept = _headers.pop("Accept", "application/json") - accept = "application/json" # Construct URL _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/providers/{resourceProviderNamespace}/register") path_format_arguments = { - "resourceProviderNamespace": _SERIALIZER.url("resource_provider_namespace", resource_provider_namespace, 'str'), - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), + "resourceProviderNamespace": _SERIALIZER.url("resource_provider_namespace", resource_provider_namespace, "str"), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), } _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') - - return HttpRequest( - method="POST", - url=_url, - params=_query_parameters, - headers=_header_parameters, - **kwargs - ) + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="POST", url=_url, params=_params, headers=_headers, **kwargs) def build_providers_list_request( - subscription_id: str, - *, - top: Optional[int] = None, - expand: Optional[str] = None, - **kwargs: Any + subscription_id: str, *, top: Optional[int] = None, expand: Optional[str] = None, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2019-05-01") # type: 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", "2019-05-01")) # type: str + accept = _headers.pop("Accept", "application/json") - accept = "application/json" # Construct URL _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/providers") path_format_arguments = { - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), } _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] if top is not None: - _query_parameters['$top'] = _SERIALIZER.query("top", top, 'int') + _params["$top"] = _SERIALIZER.query("top", top, "int") if expand is not None: - _query_parameters['$expand'] = _SERIALIZER.query("expand", expand, 'str') - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["$expand"] = _SERIALIZER.query("expand", expand, "str") + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') - - return HttpRequest( - method="GET", - url=_url, - params=_query_parameters, - headers=_header_parameters, - **kwargs - ) + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) def build_providers_get_request( - resource_provider_namespace: str, - subscription_id: str, - *, - expand: Optional[str] = None, - **kwargs: Any + resource_provider_namespace: str, subscription_id: str, *, expand: Optional[str] = None, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2019-05-01") # type: 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", "2019-05-01")) # type: str + accept = _headers.pop("Accept", "application/json") - accept = "application/json" # Construct URL _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/providers/{resourceProviderNamespace}") path_format_arguments = { - "resourceProviderNamespace": _SERIALIZER.url("resource_provider_namespace", resource_provider_namespace, 'str'), - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), + "resourceProviderNamespace": _SERIALIZER.url("resource_provider_namespace", resource_provider_namespace, "str"), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), } _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] if expand is not None: - _query_parameters['$expand'] = _SERIALIZER.query("expand", expand, 'str') - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["$expand"] = _SERIALIZER.query("expand", expand, "str") + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') - - return HttpRequest( - method="GET", - url=_url, - params=_query_parameters, - headers=_header_parameters, - **kwargs - ) + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) def build_resources_list_by_resource_group_request( @@ -1084,119 +966,108 @@ def build_resources_list_by_resource_group_request( top: Optional[int] = None, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2019-05-01") # type: 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", "2019-05-01")) # type: str + accept = _headers.pop("Accept", "application/json") - accept = "application/json" # Construct URL _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/resources") path_format_arguments = { - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._\(\)]+$'), - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), + "resourceGroupName": _SERIALIZER.url( + "resource_group_name", resource_group_name, "str", max_length=90, min_length=1, pattern=r"^[-\w\._\(\)]+$" + ), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), } _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] if filter is not None: - _query_parameters['$filter'] = _SERIALIZER.query("filter", filter, 'str') + _params["$filter"] = _SERIALIZER.query("filter", filter, "str") if expand is not None: - _query_parameters['$expand'] = _SERIALIZER.query("expand", expand, 'str') + _params["$expand"] = _SERIALIZER.query("expand", expand, "str") if top is not None: - _query_parameters['$top'] = _SERIALIZER.query("top", top, 'int') - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["$top"] = _SERIALIZER.query("top", top, "int") + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') - - return HttpRequest( - method="GET", - url=_url, - params=_query_parameters, - headers=_header_parameters, - **kwargs - ) + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) -def build_resources_move_resources_request_initial( - source_resource_group_name: str, - subscription_id: str, - *, - json: JSONType = None, - content: Any = None, - **kwargs: Any + +def build_resources_move_resources_request( + source_resource_group_name: str, subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2019-05-01") # type: str - content_type = kwargs.pop('content_type', None) # type: Optional[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", "2019-05-01")) # type: str + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] # Construct URL - _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{sourceResourceGroupName}/moveResources") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", "/subscriptions/{subscriptionId}/resourceGroups/{sourceResourceGroupName}/moveResources" + ) # pylint: disable=line-too-long path_format_arguments = { - "sourceResourceGroupName": _SERIALIZER.url("source_resource_group_name", source_resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._\(\)]+$'), - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), + "sourceResourceGroupName": _SERIALIZER.url( + "source_resource_group_name", + source_resource_group_name, + "str", + max_length=90, + min_length=1, + pattern=r"^[-\w\._\(\)]+$", + ), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), } _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] if content_type is not None: - _header_parameters['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') - - return HttpRequest( - method="POST", - url=_url, - params=_query_parameters, - headers=_header_parameters, - json=json, - content=content, - **kwargs - ) + _headers["Content-Type"] = _SERIALIZER.header("content_type", content_type, "str") + return HttpRequest(method="POST", url=_url, params=_params, headers=_headers, **kwargs) -def build_resources_validate_move_resources_request_initial( - source_resource_group_name: str, - subscription_id: str, - *, - json: JSONType = None, - content: Any = None, - **kwargs: Any + +def build_resources_validate_move_resources_request( + source_resource_group_name: str, subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2019-05-01") # type: str - content_type = kwargs.pop('content_type', None) # type: Optional[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", "2019-05-01")) # type: str + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] # Construct URL - _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{sourceResourceGroupName}/validateMoveResources") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", "/subscriptions/{subscriptionId}/resourceGroups/{sourceResourceGroupName}/validateMoveResources" + ) # pylint: disable=line-too-long path_format_arguments = { - "sourceResourceGroupName": _SERIALIZER.url("source_resource_group_name", source_resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._\(\)]+$'), - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), + "sourceResourceGroupName": _SERIALIZER.url( + "source_resource_group_name", + source_resource_group_name, + "str", + max_length=90, + min_length=1, + pattern=r"^[-\w\._\(\)]+$", + ), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), } _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] if content_type is not None: - _header_parameters['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') - - return HttpRequest( - method="POST", - url=_url, - params=_query_parameters, - headers=_header_parameters, - json=json, - content=content, - **kwargs - ) + _headers["Content-Type"] = _SERIALIZER.header("content_type", content_type, "str") + + return HttpRequest(method="POST", url=_url, params=_params, headers=_headers, **kwargs) def build_resources_list_request( @@ -1207,38 +1078,33 @@ def build_resources_list_request( top: Optional[int] = None, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2019-05-01") # type: 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", "2019-05-01")) # type: str + accept = _headers.pop("Accept", "application/json") - accept = "application/json" # Construct URL _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resources") path_format_arguments = { - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), } _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] if filter is not None: - _query_parameters['$filter'] = _SERIALIZER.query("filter", filter, 'str') + _params["$filter"] = _SERIALIZER.query("filter", filter, "str") if expand is not None: - _query_parameters['$expand'] = _SERIALIZER.query("expand", expand, 'str') + _params["$expand"] = _SERIALIZER.query("expand", expand, "str") if top is not None: - _query_parameters['$top'] = _SERIALIZER.query("top", top, 'int') - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["$top"] = _SERIALIZER.query("top", top, "int") + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') - - return HttpRequest( - method="GET", - url=_url, - params=_query_parameters, - headers=_header_parameters, - **kwargs - ) + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) def build_resources_check_existence_request( @@ -1252,32 +1118,33 @@ def build_resources_check_existence_request( api_version: str, **kwargs: Any ) -> HttpRequest: + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + # Construct URL - _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{parentResourcePath}/{resourceType}/{resourceName}") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{parentResourcePath}/{resourceType}/{resourceName}", + ) # pylint: disable=line-too-long path_format_arguments = { - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._\(\)]+$'), - "resourceProviderNamespace": _SERIALIZER.url("resource_provider_namespace", resource_provider_namespace, 'str'), - "parentResourcePath": _SERIALIZER.url("parent_resource_path", parent_resource_path, 'str', skip_quote=True), - "resourceType": _SERIALIZER.url("resource_type", resource_type, 'str', skip_quote=True), - "resourceName": _SERIALIZER.url("resource_name", resource_name, 'str'), - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), + "resourceGroupName": _SERIALIZER.url( + "resource_group_name", resource_group_name, "str", max_length=90, min_length=1, pattern=r"^[-\w\._\(\)]+$" + ), + "resourceProviderNamespace": _SERIALIZER.url("resource_provider_namespace", resource_provider_namespace, "str"), + "parentResourcePath": _SERIALIZER.url("parent_resource_path", parent_resource_path, "str", skip_quote=True), + "resourceType": _SERIALIZER.url("resource_type", resource_type, "str", skip_quote=True), + "resourceName": _SERIALIZER.url("resource_name", resource_name, "str"), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), } _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') - - return HttpRequest( - method="HEAD", - url=_url, - params=_query_parameters, - **kwargs - ) + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") + return HttpRequest(method="HEAD", url=_url, params=_params, **kwargs) -def build_resources_delete_request_initial( + +def build_resources_delete_request( resource_group_name: str, resource_provider_namespace: str, parent_resource_path: str, @@ -1288,32 +1155,33 @@ def build_resources_delete_request_initial( api_version: str, **kwargs: Any ) -> HttpRequest: + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + # Construct URL - _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{parentResourcePath}/{resourceType}/{resourceName}") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{parentResourcePath}/{resourceType}/{resourceName}", + ) # pylint: disable=line-too-long path_format_arguments = { - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._\(\)]+$'), - "resourceProviderNamespace": _SERIALIZER.url("resource_provider_namespace", resource_provider_namespace, 'str'), - "parentResourcePath": _SERIALIZER.url("parent_resource_path", parent_resource_path, 'str', skip_quote=True), - "resourceType": _SERIALIZER.url("resource_type", resource_type, 'str', skip_quote=True), - "resourceName": _SERIALIZER.url("resource_name", resource_name, 'str'), - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), + "resourceGroupName": _SERIALIZER.url( + "resource_group_name", resource_group_name, "str", max_length=90, min_length=1, pattern=r"^[-\w\._\(\)]+$" + ), + "resourceProviderNamespace": _SERIALIZER.url("resource_provider_namespace", resource_provider_namespace, "str"), + "parentResourcePath": _SERIALIZER.url("parent_resource_path", parent_resource_path, "str", skip_quote=True), + "resourceType": _SERIALIZER.url("resource_type", resource_type, "str", skip_quote=True), + "resourceName": _SERIALIZER.url("resource_name", resource_name, "str"), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), } _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') - - return HttpRequest( - method="DELETE", - url=_url, - params=_query_parameters, - **kwargs - ) + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") + + return HttpRequest(method="DELETE", url=_url, params=_params, **kwargs) -def build_resources_create_or_update_request_initial( +def build_resources_create_or_update_request( resource_group_name: str, resource_provider_namespace: str, parent_resource_path: str, @@ -1322,48 +1190,44 @@ def build_resources_create_or_update_request_initial( subscription_id: str, *, api_version: str, - json: JSONType = None, - content: Any = None, **kwargs: Any ) -> HttpRequest: - content_type = kwargs.pop('content_type', None) # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + accept = _headers.pop("Accept", "application/json") - accept = "application/json" # Construct URL - _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{parentResourcePath}/{resourceType}/{resourceName}") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{parentResourcePath}/{resourceType}/{resourceName}", + ) # pylint: disable=line-too-long path_format_arguments = { - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._\(\)]+$'), - "resourceProviderNamespace": _SERIALIZER.url("resource_provider_namespace", resource_provider_namespace, 'str'), - "parentResourcePath": _SERIALIZER.url("parent_resource_path", parent_resource_path, 'str', skip_quote=True), - "resourceType": _SERIALIZER.url("resource_type", resource_type, 'str', skip_quote=True), - "resourceName": _SERIALIZER.url("resource_name", resource_name, 'str'), - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), + "resourceGroupName": _SERIALIZER.url( + "resource_group_name", resource_group_name, "str", max_length=90, min_length=1, pattern=r"^[-\w\._\(\)]+$" + ), + "resourceProviderNamespace": _SERIALIZER.url("resource_provider_namespace", resource_provider_namespace, "str"), + "parentResourcePath": _SERIALIZER.url("parent_resource_path", parent_resource_path, "str", skip_quote=True), + "resourceType": _SERIALIZER.url("resource_type", resource_type, "str", skip_quote=True), + "resourceName": _SERIALIZER.url("resource_name", resource_name, "str"), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), } _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] if content_type is not None: - _header_parameters['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') - _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') - - return HttpRequest( - method="PUT", - url=_url, - params=_query_parameters, - headers=_header_parameters, - json=json, - content=content, - **kwargs - ) + _headers["Content-Type"] = _SERIALIZER.header("content_type", content_type, "str") + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + return HttpRequest(method="PUT", url=_url, params=_params, headers=_headers, **kwargs) -def build_resources_update_request_initial( + +def build_resources_update_request( resource_group_name: str, resource_provider_namespace: str, parent_resource_path: str, @@ -1372,45 +1236,41 @@ def build_resources_update_request_initial( subscription_id: str, *, api_version: str, - json: JSONType = None, - content: Any = None, **kwargs: Any ) -> HttpRequest: - content_type = kwargs.pop('content_type', None) # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + accept = _headers.pop("Accept", "application/json") - accept = "application/json" # Construct URL - _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{parentResourcePath}/{resourceType}/{resourceName}") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{parentResourcePath}/{resourceType}/{resourceName}", + ) # pylint: disable=line-too-long path_format_arguments = { - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._\(\)]+$'), - "resourceProviderNamespace": _SERIALIZER.url("resource_provider_namespace", resource_provider_namespace, 'str'), - "parentResourcePath": _SERIALIZER.url("parent_resource_path", parent_resource_path, 'str', skip_quote=True), - "resourceType": _SERIALIZER.url("resource_type", resource_type, 'str', skip_quote=True), - "resourceName": _SERIALIZER.url("resource_name", resource_name, 'str'), - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), + "resourceGroupName": _SERIALIZER.url( + "resource_group_name", resource_group_name, "str", max_length=90, min_length=1, pattern=r"^[-\w\._\(\)]+$" + ), + "resourceProviderNamespace": _SERIALIZER.url("resource_provider_namespace", resource_provider_namespace, "str"), + "parentResourcePath": _SERIALIZER.url("parent_resource_path", parent_resource_path, "str", skip_quote=True), + "resourceType": _SERIALIZER.url("resource_type", resource_type, "str", skip_quote=True), + "resourceName": _SERIALIZER.url("resource_name", resource_name, "str"), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), } _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] if content_type is not None: - _header_parameters['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') - _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') - - return HttpRequest( - method="PATCH", - url=_url, - params=_query_parameters, - headers=_header_parameters, - json=json, - content=content, - **kwargs - ) + _headers["Content-Type"] = _SERIALIZER.header("content_type", content_type, "str") + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="PATCH", url=_url, params=_params, headers=_headers, **kwargs) def build_resources_get_request( @@ -1424,900 +1284,730 @@ def build_resources_get_request( api_version: str, **kwargs: Any ) -> HttpRequest: - accept = "application/json" + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + accept = _headers.pop("Accept", "application/json") + # Construct URL - _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{parentResourcePath}/{resourceType}/{resourceName}") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{parentResourcePath}/{resourceType}/{resourceName}", + ) # pylint: disable=line-too-long path_format_arguments = { - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._\(\)]+$'), - "resourceProviderNamespace": _SERIALIZER.url("resource_provider_namespace", resource_provider_namespace, 'str'), - "parentResourcePath": _SERIALIZER.url("parent_resource_path", parent_resource_path, 'str', skip_quote=True), - "resourceType": _SERIALIZER.url("resource_type", resource_type, 'str', skip_quote=True), - "resourceName": _SERIALIZER.url("resource_name", resource_name, 'str'), - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), + "resourceGroupName": _SERIALIZER.url( + "resource_group_name", resource_group_name, "str", max_length=90, min_length=1, pattern=r"^[-\w\._\(\)]+$" + ), + "resourceProviderNamespace": _SERIALIZER.url("resource_provider_namespace", resource_provider_namespace, "str"), + "parentResourcePath": _SERIALIZER.url("parent_resource_path", parent_resource_path, "str", skip_quote=True), + "resourceType": _SERIALIZER.url("resource_type", resource_type, "str", skip_quote=True), + "resourceName": _SERIALIZER.url("resource_name", resource_name, "str"), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), } _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') - - return HttpRequest( - method="GET", - url=_url, - params=_query_parameters, - headers=_header_parameters, - **kwargs - ) + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) + + +def build_resources_check_existence_by_id_request(resource_id: str, *, api_version: str, **kwargs: Any) -> HttpRequest: + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) -def build_resources_check_existence_by_id_request( - resource_id: str, - *, - api_version: str, - **kwargs: Any -) -> HttpRequest: # Construct URL _url = kwargs.pop("template_url", "/{resourceId}") path_format_arguments = { - "resourceId": _SERIALIZER.url("resource_id", resource_id, 'str', skip_quote=True), + "resourceId": _SERIALIZER.url("resource_id", resource_id, "str", skip_quote=True), } _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') - - return HttpRequest( - method="HEAD", - url=_url, - params=_query_parameters, - **kwargs - ) + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") + return HttpRequest(method="HEAD", url=_url, params=_params, **kwargs) + + +def build_resources_delete_by_id_request(resource_id: str, *, api_version: str, **kwargs: Any) -> HttpRequest: + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) -def build_resources_delete_by_id_request_initial( - resource_id: str, - *, - api_version: str, - **kwargs: Any -) -> HttpRequest: # Construct URL _url = kwargs.pop("template_url", "/{resourceId}") path_format_arguments = { - "resourceId": _SERIALIZER.url("resource_id", resource_id, 'str', skip_quote=True), + "resourceId": _SERIALIZER.url("resource_id", resource_id, "str", skip_quote=True), } _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') - - return HttpRequest( - method="DELETE", - url=_url, - params=_query_parameters, - **kwargs - ) + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") + return HttpRequest(method="DELETE", url=_url, params=_params, **kwargs) -def build_resources_create_or_update_by_id_request_initial( - resource_id: str, - *, - api_version: str, - json: JSONType = None, - content: Any = None, - **kwargs: Any -) -> HttpRequest: - content_type = kwargs.pop('content_type', None) # type: Optional[str] - accept = "application/json" +def build_resources_create_or_update_by_id_request(resource_id: str, *, api_version: str, **kwargs: Any) -> HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + accept = _headers.pop("Accept", "application/json") + # Construct URL _url = kwargs.pop("template_url", "/{resourceId}") path_format_arguments = { - "resourceId": _SERIALIZER.url("resource_id", resource_id, 'str', skip_quote=True), + "resourceId": _SERIALIZER.url("resource_id", resource_id, "str", skip_quote=True), } _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] if content_type is not None: - _header_parameters['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') - _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') - - return HttpRequest( - method="PUT", - url=_url, - params=_query_parameters, - headers=_header_parameters, - json=json, - content=content, - **kwargs - ) + _headers["Content-Type"] = _SERIALIZER.header("content_type", content_type, "str") + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + return HttpRequest(method="PUT", url=_url, params=_params, headers=_headers, **kwargs) -def build_resources_update_by_id_request_initial( - resource_id: str, - *, - api_version: str, - json: JSONType = None, - content: Any = None, - **kwargs: Any -) -> HttpRequest: - content_type = kwargs.pop('content_type', None) # type: Optional[str] - accept = "application/json" +def build_resources_update_by_id_request(resource_id: str, *, api_version: str, **kwargs: Any) -> HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + accept = _headers.pop("Accept", "application/json") + # Construct URL _url = kwargs.pop("template_url", "/{resourceId}") path_format_arguments = { - "resourceId": _SERIALIZER.url("resource_id", resource_id, 'str', skip_quote=True), + "resourceId": _SERIALIZER.url("resource_id", resource_id, "str", skip_quote=True), } _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] if content_type is not None: - _header_parameters['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') - _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') - - return HttpRequest( - method="PATCH", - url=_url, - params=_query_parameters, - headers=_header_parameters, - json=json, - content=content, - **kwargs - ) + _headers["Content-Type"] = _SERIALIZER.header("content_type", content_type, "str") + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + return HttpRequest(method="PATCH", url=_url, params=_params, headers=_headers, **kwargs) + + +def build_resources_get_by_id_request(resource_id: str, *, api_version: str, **kwargs: Any) -> HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + accept = _headers.pop("Accept", "application/json") -def build_resources_get_by_id_request( - resource_id: str, - *, - api_version: str, - **kwargs: Any -) -> HttpRequest: - accept = "application/json" # Construct URL _url = kwargs.pop("template_url", "/{resourceId}") path_format_arguments = { - "resourceId": _SERIALIZER.url("resource_id", resource_id, 'str', skip_quote=True), + "resourceId": _SERIALIZER.url("resource_id", resource_id, "str", skip_quote=True), } _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') - - return HttpRequest( - method="GET", - url=_url, - params=_query_parameters, - headers=_header_parameters, - **kwargs - ) + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) def build_resource_groups_check_existence_request( - resource_group_name: str, - subscription_id: str, - **kwargs: Any + resource_group_name: str, subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2019-05-01") # type: str + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + api_version = kwargs.pop("api_version", _params.pop("api-version", "2019-05-01")) # type: str # Construct URL _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}") path_format_arguments = { - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._\(\)]+$'), - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), + "resourceGroupName": _SERIALIZER.url( + "resource_group_name", resource_group_name, "str", max_length=90, min_length=1, pattern=r"^[-\w\._\(\)]+$" + ), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), } _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') - - return HttpRequest( - method="HEAD", - url=_url, - params=_query_parameters, - **kwargs - ) + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") + + return HttpRequest(method="HEAD", url=_url, params=_params, **kwargs) def build_resource_groups_create_or_update_request( - resource_group_name: str, - subscription_id: str, - *, - json: JSONType = None, - content: Any = None, - **kwargs: Any + resource_group_name: str, subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2019-05-01") # type: str - content_type = kwargs.pop('content_type', None) # type: Optional[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", "2019-05-01")) # type: str + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + accept = _headers.pop("Accept", "application/json") - accept = "application/json" # Construct URL _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}") path_format_arguments = { - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._\(\)]+$'), - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), + "resourceGroupName": _SERIALIZER.url( + "resource_group_name", resource_group_name, "str", max_length=90, min_length=1, pattern=r"^[-\w\._\(\)]+$" + ), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), } _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] if content_type is not None: - _header_parameters['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') - _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') - - return HttpRequest( - method="PUT", - url=_url, - params=_query_parameters, - headers=_header_parameters, - json=json, - content=content, - **kwargs - ) + _headers["Content-Type"] = _SERIALIZER.header("content_type", content_type, "str") + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + return HttpRequest(method="PUT", url=_url, params=_params, headers=_headers, **kwargs) -def build_resource_groups_delete_request_initial( - resource_group_name: str, - subscription_id: str, - **kwargs: Any -) -> HttpRequest: - api_version = kwargs.pop('api_version', "2019-05-01") # type: str +def build_resource_groups_delete_request(resource_group_name: str, subscription_id: str, **kwargs: Any) -> HttpRequest: + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2019-05-01")) # type: str # Construct URL _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}") path_format_arguments = { - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._\(\)]+$'), - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), + "resourceGroupName": _SERIALIZER.url( + "resource_group_name", resource_group_name, "str", max_length=90, min_length=1, pattern=r"^[-\w\._\(\)]+$" + ), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), } _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') - - return HttpRequest( - method="DELETE", - url=_url, - params=_query_parameters, - **kwargs - ) + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") + return HttpRequest(method="DELETE", url=_url, params=_params, **kwargs) -def build_resource_groups_get_request( - resource_group_name: str, - subscription_id: str, - **kwargs: Any -) -> HttpRequest: - api_version = kwargs.pop('api_version', "2019-05-01") # type: str - accept = "application/json" +def build_resource_groups_get_request(resource_group_name: str, subscription_id: str, **kwargs: Any) -> HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2019-05-01")) # type: str + accept = _headers.pop("Accept", "application/json") + # Construct URL _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}") path_format_arguments = { - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._\(\)]+$'), - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), + "resourceGroupName": _SERIALIZER.url( + "resource_group_name", resource_group_name, "str", max_length=90, min_length=1, pattern=r"^[-\w\._\(\)]+$" + ), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), } _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') - - return HttpRequest( - method="GET", - url=_url, - params=_query_parameters, - headers=_header_parameters, - **kwargs - ) + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) -def build_resource_groups_update_request( - resource_group_name: str, - subscription_id: str, - *, - json: JSONType = None, - content: Any = None, - **kwargs: Any -) -> HttpRequest: - api_version = kwargs.pop('api_version', "2019-05-01") # type: str - content_type = kwargs.pop('content_type', None) # type: Optional[str] - accept = "application/json" +def build_resource_groups_update_request(resource_group_name: str, subscription_id: str, **kwargs: Any) -> HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2019-05-01")) # type: str + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + accept = _headers.pop("Accept", "application/json") + # Construct URL _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}") path_format_arguments = { - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._\(\)]+$'), - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), + "resourceGroupName": _SERIALIZER.url( + "resource_group_name", resource_group_name, "str", max_length=90, min_length=1, pattern=r"^[-\w\._\(\)]+$" + ), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), } _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] if content_type is not None: - _header_parameters['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') - _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') - - return HttpRequest( - method="PATCH", - url=_url, - params=_query_parameters, - headers=_header_parameters, - json=json, - content=content, - **kwargs - ) + _headers["Content-Type"] = _SERIALIZER.header("content_type", content_type, "str") + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="PATCH", url=_url, params=_params, headers=_headers, **kwargs) def build_resource_groups_export_template_request( - resource_group_name: str, - subscription_id: str, - *, - json: JSONType = None, - content: Any = None, - **kwargs: Any + resource_group_name: str, subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2019-05-01") # type: str - content_type = kwargs.pop('content_type', None) # type: Optional[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", "2019-05-01")) # type: str + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + accept = _headers.pop("Accept", "application/json") - accept = "application/json" # Construct URL - _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/exportTemplate") + _url = kwargs.pop( + "template_url", "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/exportTemplate" + ) path_format_arguments = { - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._\(\)]+$'), - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), + "resourceGroupName": _SERIALIZER.url( + "resource_group_name", resource_group_name, "str", max_length=90, min_length=1, pattern=r"^[-\w\._\(\)]+$" + ), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), } _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] if content_type is not None: - _header_parameters['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') - _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') - - return HttpRequest( - method="POST", - url=_url, - params=_query_parameters, - headers=_header_parameters, - json=json, - content=content, - **kwargs - ) + _headers["Content-Type"] = _SERIALIZER.header("content_type", content_type, "str") + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="POST", url=_url, params=_params, headers=_headers, **kwargs) def build_resource_groups_list_request( - subscription_id: str, - *, - filter: Optional[str] = None, - top: Optional[int] = None, - **kwargs: Any + subscription_id: str, *, filter: Optional[str] = None, top: Optional[int] = None, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2019-05-01") # type: 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", "2019-05-01")) # type: str + accept = _headers.pop("Accept", "application/json") - accept = "application/json" # Construct URL _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourcegroups") path_format_arguments = { - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), } _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] if filter is not None: - _query_parameters['$filter'] = _SERIALIZER.query("filter", filter, 'str') + _params["$filter"] = _SERIALIZER.query("filter", filter, "str") if top is not None: - _query_parameters['$top'] = _SERIALIZER.query("top", top, 'int') - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["$top"] = _SERIALIZER.query("top", top, "int") + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') - - return HttpRequest( - method="GET", - url=_url, - params=_query_parameters, - headers=_header_parameters, - **kwargs - ) + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) -def build_tags_delete_value_request( - tag_name: str, - tag_value: str, - subscription_id: str, - **kwargs: Any -) -> HttpRequest: - api_version = kwargs.pop('api_version', "2019-05-01") # type: str +def build_tags_delete_value_request(tag_name: str, tag_value: str, subscription_id: str, **kwargs: Any) -> HttpRequest: + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2019-05-01")) # type: str # Construct URL _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/tagNames/{tagName}/tagValues/{tagValue}") path_format_arguments = { - "tagName": _SERIALIZER.url("tag_name", tag_name, 'str'), - "tagValue": _SERIALIZER.url("tag_value", tag_value, 'str'), - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), + "tagName": _SERIALIZER.url("tag_name", tag_name, "str"), + "tagValue": _SERIALIZER.url("tag_value", tag_value, "str"), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), } _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') - - return HttpRequest( - method="DELETE", - url=_url, - params=_query_parameters, - **kwargs - ) + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") + + return HttpRequest(method="DELETE", url=_url, params=_params, **kwargs) def build_tags_create_or_update_value_request( - tag_name: str, - tag_value: str, - subscription_id: str, - **kwargs: Any + tag_name: str, tag_value: str, subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2019-05-01") # type: 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", "2019-05-01")) # type: str + accept = _headers.pop("Accept", "application/json") - accept = "application/json" # Construct URL _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/tagNames/{tagName}/tagValues/{tagValue}") path_format_arguments = { - "tagName": _SERIALIZER.url("tag_name", tag_name, 'str'), - "tagValue": _SERIALIZER.url("tag_value", tag_value, 'str'), - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), + "tagName": _SERIALIZER.url("tag_name", tag_name, "str"), + "tagValue": _SERIALIZER.url("tag_value", tag_value, "str"), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), } _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') - - return HttpRequest( - method="PUT", - url=_url, - params=_query_parameters, - headers=_header_parameters, - **kwargs - ) + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + return HttpRequest(method="PUT", url=_url, params=_params, headers=_headers, **kwargs) -def build_tags_create_or_update_request( - tag_name: str, - subscription_id: str, - **kwargs: Any -) -> HttpRequest: - api_version = kwargs.pop('api_version', "2019-05-01") # type: str - accept = "application/json" +def build_tags_create_or_update_request(tag_name: str, subscription_id: str, **kwargs: Any) -> HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2019-05-01")) # type: str + accept = _headers.pop("Accept", "application/json") + # Construct URL _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/tagNames/{tagName}") path_format_arguments = { - "tagName": _SERIALIZER.url("tag_name", tag_name, 'str'), - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), + "tagName": _SERIALIZER.url("tag_name", tag_name, "str"), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), } _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') - - return HttpRequest( - method="PUT", - url=_url, - params=_query_parameters, - headers=_header_parameters, - **kwargs - ) + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + return HttpRequest(method="PUT", url=_url, params=_params, headers=_headers, **kwargs) -def build_tags_delete_request( - tag_name: str, - subscription_id: str, - **kwargs: Any -) -> HttpRequest: - api_version = kwargs.pop('api_version', "2019-05-01") # type: str +def build_tags_delete_request(tag_name: str, subscription_id: str, **kwargs: Any) -> HttpRequest: + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2019-05-01")) # type: str # Construct URL _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/tagNames/{tagName}") path_format_arguments = { - "tagName": _SERIALIZER.url("tag_name", tag_name, 'str'), - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), + "tagName": _SERIALIZER.url("tag_name", tag_name, "str"), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), } _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') - - return HttpRequest( - method="DELETE", - url=_url, - params=_query_parameters, - **kwargs - ) + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") + return HttpRequest(method="DELETE", url=_url, params=_params, **kwargs) -def build_tags_list_request( - subscription_id: str, - **kwargs: Any -) -> HttpRequest: - api_version = kwargs.pop('api_version', "2019-05-01") # type: str - accept = "application/json" +def build_tags_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", "2019-05-01")) # type: str + accept = _headers.pop("Accept", "application/json") + # Construct URL _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/tagNames") path_format_arguments = { - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), } _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') - - return HttpRequest( - method="GET", - url=_url, - params=_query_parameters, - headers=_header_parameters, - **kwargs - ) + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) def build_deployment_operations_get_at_management_group_scope_request( - group_id: str, - deployment_name: str, - operation_id: str, - **kwargs: Any + group_id: str, deployment_name: str, operation_id: str, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2019-05-01") # type: 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", "2019-05-01")) # type: str + accept = _headers.pop("Accept", "application/json") - accept = "application/json" # Construct URL - _url = kwargs.pop("template_url", "/providers/Microsoft.Management/managementGroups/{groupId}/providers/Microsoft.Resources/deployments/{deploymentName}/operations/{operationId}") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", + "/providers/Microsoft.Management/managementGroups/{groupId}/providers/Microsoft.Resources/deployments/{deploymentName}/operations/{operationId}", + ) # pylint: disable=line-too-long path_format_arguments = { - "groupId": _SERIALIZER.url("group_id", group_id, 'str', max_length=90, min_length=1), - "deploymentName": _SERIALIZER.url("deployment_name", deployment_name, 'str', max_length=64, min_length=1, pattern=r'^[-\w\._\(\)]+$'), - "operationId": _SERIALIZER.url("operation_id", operation_id, 'str'), + "groupId": _SERIALIZER.url("group_id", group_id, "str", max_length=90, min_length=1), + "deploymentName": _SERIALIZER.url( + "deployment_name", deployment_name, "str", max_length=64, min_length=1, pattern=r"^[-\w\._\(\)]+$" + ), + "operationId": _SERIALIZER.url("operation_id", operation_id, "str"), } _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') - - return HttpRequest( - method="GET", - url=_url, - params=_query_parameters, - headers=_header_parameters, - **kwargs - ) + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) def build_deployment_operations_list_at_management_group_scope_request( - group_id: str, - deployment_name: str, - *, - top: Optional[int] = None, - **kwargs: Any + group_id: str, deployment_name: str, *, top: Optional[int] = None, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2019-05-01") # type: 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", "2019-05-01")) # type: str + accept = _headers.pop("Accept", "application/json") - accept = "application/json" # Construct URL - _url = kwargs.pop("template_url", "/providers/Microsoft.Management/managementGroups/{groupId}/providers/Microsoft.Resources/deployments/{deploymentName}/operations") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", + "/providers/Microsoft.Management/managementGroups/{groupId}/providers/Microsoft.Resources/deployments/{deploymentName}/operations", + ) # pylint: disable=line-too-long path_format_arguments = { - "groupId": _SERIALIZER.url("group_id", group_id, 'str', max_length=90, min_length=1), - "deploymentName": _SERIALIZER.url("deployment_name", deployment_name, 'str', max_length=64, min_length=1, pattern=r'^[-\w\._\(\)]+$'), + "groupId": _SERIALIZER.url("group_id", group_id, "str", max_length=90, min_length=1), + "deploymentName": _SERIALIZER.url( + "deployment_name", deployment_name, "str", max_length=64, min_length=1, pattern=r"^[-\w\._\(\)]+$" + ), } _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] if top is not None: - _query_parameters['$top'] = _SERIALIZER.query("top", top, 'int') - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["$top"] = _SERIALIZER.query("top", top, "int") + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') - - return HttpRequest( - method="GET", - url=_url, - params=_query_parameters, - headers=_header_parameters, - **kwargs - ) + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) def build_deployment_operations_get_at_subscription_scope_request( - deployment_name: str, - operation_id: str, - subscription_id: str, - **kwargs: Any + deployment_name: str, operation_id: str, subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2019-05-01") # type: 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", "2019-05-01")) # type: str + accept = _headers.pop("Accept", "application/json") - accept = "application/json" # Construct URL - _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/providers/Microsoft.Resources/deployments/{deploymentName}/operations/{operationId}") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/providers/Microsoft.Resources/deployments/{deploymentName}/operations/{operationId}", + ) # pylint: disable=line-too-long path_format_arguments = { - "deploymentName": _SERIALIZER.url("deployment_name", deployment_name, 'str', max_length=64, min_length=1, pattern=r'^[-\w\._\(\)]+$'), - "operationId": _SERIALIZER.url("operation_id", operation_id, 'str'), - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), + "deploymentName": _SERIALIZER.url( + "deployment_name", deployment_name, "str", max_length=64, min_length=1, pattern=r"^[-\w\._\(\)]+$" + ), + "operationId": _SERIALIZER.url("operation_id", operation_id, "str"), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), } _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') - - return HttpRequest( - method="GET", - url=_url, - params=_query_parameters, - headers=_header_parameters, - **kwargs - ) + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) def build_deployment_operations_list_at_subscription_scope_request( - deployment_name: str, - subscription_id: str, - *, - top: Optional[int] = None, - **kwargs: Any + deployment_name: str, subscription_id: str, *, top: Optional[int] = None, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2019-05-01") # type: 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", "2019-05-01")) # type: str + accept = _headers.pop("Accept", "application/json") - accept = "application/json" # Construct URL - _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/providers/Microsoft.Resources/deployments/{deploymentName}/operations") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/providers/Microsoft.Resources/deployments/{deploymentName}/operations", + ) # pylint: disable=line-too-long path_format_arguments = { - "deploymentName": _SERIALIZER.url("deployment_name", deployment_name, 'str', max_length=64, min_length=1, pattern=r'^[-\w\._\(\)]+$'), - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), + "deploymentName": _SERIALIZER.url( + "deployment_name", deployment_name, "str", max_length=64, min_length=1, pattern=r"^[-\w\._\(\)]+$" + ), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), } _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] if top is not None: - _query_parameters['$top'] = _SERIALIZER.query("top", top, 'int') - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["$top"] = _SERIALIZER.query("top", top, "int") + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') - - return HttpRequest( - method="GET", - url=_url, - params=_query_parameters, - headers=_header_parameters, - **kwargs - ) + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) def build_deployment_operations_get_request( - resource_group_name: str, - deployment_name: str, - operation_id: str, - subscription_id: str, - **kwargs: Any + resource_group_name: str, deployment_name: str, operation_id: str, subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2019-05-01") # type: 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", "2019-05-01")) # type: str + accept = _headers.pop("Accept", "application/json") - accept = "application/json" # Construct URL - _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/deployments/{deploymentName}/operations/{operationId}") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/deployments/{deploymentName}/operations/{operationId}", + ) # pylint: disable=line-too-long path_format_arguments = { - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._\(\)]+$'), - "deploymentName": _SERIALIZER.url("deployment_name", deployment_name, 'str', max_length=64, min_length=1, pattern=r'^[-\w\._\(\)]+$'), - "operationId": _SERIALIZER.url("operation_id", operation_id, 'str'), - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), + "resourceGroupName": _SERIALIZER.url( + "resource_group_name", resource_group_name, "str", max_length=90, min_length=1, pattern=r"^[-\w\._\(\)]+$" + ), + "deploymentName": _SERIALIZER.url( + "deployment_name", deployment_name, "str", max_length=64, min_length=1, pattern=r"^[-\w\._\(\)]+$" + ), + "operationId": _SERIALIZER.url("operation_id", operation_id, "str"), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), } _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') - - return HttpRequest( - method="GET", - url=_url, - params=_query_parameters, - headers=_header_parameters, - **kwargs - ) + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) def build_deployment_operations_list_request( - resource_group_name: str, - deployment_name: str, - subscription_id: str, - *, - top: Optional[int] = None, - **kwargs: Any + resource_group_name: str, deployment_name: str, subscription_id: str, *, top: Optional[int] = None, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2019-05-01") # type: 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", "2019-05-01")) # type: str + accept = _headers.pop("Accept", "application/json") - accept = "application/json" # Construct URL - _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/deployments/{deploymentName}/operations") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/deployments/{deploymentName}/operations", + ) # pylint: disable=line-too-long path_format_arguments = { - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._\(\)]+$'), - "deploymentName": _SERIALIZER.url("deployment_name", deployment_name, 'str', max_length=64, min_length=1, pattern=r'^[-\w\._\(\)]+$'), - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), + "resourceGroupName": _SERIALIZER.url( + "resource_group_name", resource_group_name, "str", max_length=90, min_length=1, pattern=r"^[-\w\._\(\)]+$" + ), + "deploymentName": _SERIALIZER.url( + "deployment_name", deployment_name, "str", max_length=64, min_length=1, pattern=r"^[-\w\._\(\)]+$" + ), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), } _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] if top is not None: - _query_parameters['$top'] = _SERIALIZER.query("top", top, 'int') - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["$top"] = _SERIALIZER.query("top", top, "int") + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') - - return HttpRequest( - method="GET", - url=_url, - params=_query_parameters, - headers=_header_parameters, - **kwargs - ) + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) -class Operations(object): - """Operations operations. - You should not instantiate this class directly. Instead, you should create a Client instance that - instantiates it for you and attaches it as an attribute. +class Operations: + """ + .. warning:: + **DO NOT** instantiate this class directly. - :ivar models: Alias to model classes used in this operation group. - :type models: ~azure.mgmt.resource.resources.v2019_05_01.models - :param client: Client for service requests. - :param config: Configuration of service client. - :param serializer: An object model serializer. - :param deserializer: An object model deserializer. + Instead, you should access the following operations through + :class:`~azure.mgmt.resource.resources.v2019_05_01.ResourceManagementClient`'s + :attr:`operations` attribute. """ models = _models - def __init__(self, client, config, serializer, deserializer): - self._client = client - self._serialize = serializer - self._deserialize = deserializer - self._config = config + def __init__(self, *args, **kwargs): + input_args = list(args) + self._client = input_args.pop(0) if input_args else kwargs.pop("client") + self._config = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") @distributed_trace - def list( - self, - **kwargs: Any - ) -> Iterable["_models.OperationListResult"]: + def list(self, **kwargs: Any) -> Iterable["_models.Operation"]: """Lists all of the available Microsoft.Resources REST API operations. :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either OperationListResult or the result of cls(response) + :return: An iterator like instance of either Operation or the result of cls(response) :rtype: - ~azure.core.paging.ItemPaged[~azure.mgmt.resource.resources.v2019_05_01.models.OperationListResult] - :raises: ~azure.core.exceptions.HttpResponseError + ~azure.core.paging.ItemPaged[~azure.mgmt.resource.resources.v2019_05_01.models.Operation] + :raises ~azure.core.exceptions.HttpResponseError: """ - api_version = kwargs.pop('api_version', "2019-05-01") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2019-05-01")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[_models.OperationListResult] - cls = kwargs.pop('cls', None) # type: ClsType["_models.OperationListResult"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) + def prepare_request(next_link=None): if not next_link: - + request = build_operations_list_request( api_version=api_version, - template_url=self.list.metadata['url'], + template_url=self.list.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore else: - - request = build_operations_list_request( - template_url=next_link, - ) + # make call to next link with the client's api-version + _parsed_next_link = urlparse(next_link) + _next_request_params = case_insensitive_dict(parse_qs(_parsed_next_link.query)) + _next_request_params["api-version"] = self._config.api_version + request = HttpRequest("GET", urljoin(next_link, _parsed_next_link.path), params=_next_request_params) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore request.method = "GET" return request @@ -2331,10 +2021,8 @@ def extract_data(pipeline_response): def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) response = pipeline_response.http_response @@ -2344,62 +2032,62 @@ def get_next(next_link=None): return pipeline_response + return ItemPaged(get_next, extract_data) - return ItemPaged( - get_next, extract_data - ) - list.metadata = {'url': "/providers/Microsoft.Resources/operations"} # type: ignore -class DeploymentsOperations(object): # pylint: disable=too-many-public-methods - """DeploymentsOperations operations. - - You should not instantiate this class directly. Instead, you should create a Client instance that - instantiates it for you and attaches it as an attribute. - - :ivar models: Alias to model classes used in this operation group. - :type models: ~azure.mgmt.resource.resources.v2019_05_01.models - :param client: Client for service requests. - :param config: Configuration of service client. - :param serializer: An object model serializer. - :param deserializer: An object model deserializer. + list.metadata = {"url": "/providers/Microsoft.Resources/operations"} # type: ignore + + +class DeploymentsOperations: # pylint: disable=too-many-public-methods + """ + .. warning:: + **DO NOT** instantiate this class directly. + + Instead, you should access the following operations through + :class:`~azure.mgmt.resource.resources.v2019_05_01.ResourceManagementClient`'s + :attr:`deployments` attribute. """ models = _models - def __init__(self, client, config, serializer, deserializer): - self._client = client - self._serialize = serializer - self._deserialize = deserializer - self._config = config + def __init__(self, *args, **kwargs): + input_args = list(args) + self._client = input_args.pop(0) if input_args else kwargs.pop("client") + self._config = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") def _delete_at_management_group_scope_initial( # pylint: disable=inconsistent-return-statements - self, - group_id: str, - deployment_name: str, - **kwargs: Any + self, group_id: str, deployment_name: str, **kwargs: Any ) -> None: - cls = kwargs.pop('cls', None) # type: ClsType[None] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + 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', "2019-05-01") # type: str + api_version = kwargs.pop("api_version", _params.pop("api-version", "2019-05-01")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[None] - - request = build_deployments_delete_at_management_group_scope_request_initial( + request = build_deployments_delete_at_management_group_scope_request( group_id=group_id, deployment_name=deployment_name, api_version=api_version, - template_url=self._delete_at_management_group_scope_initial.metadata['url'], + template_url=self._delete_at_management_group_scope_initial.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [202, 204]: @@ -2409,15 +2097,11 @@ def _delete_at_management_group_scope_initial( # pylint: disable=inconsistent-r if cls: return cls(pipeline_response, None, {}) - _delete_at_management_group_scope_initial.metadata = {'url': "/providers/Microsoft.Management/managementGroups/{groupId}/providers/Microsoft.Resources/deployments/{deploymentName}"} # type: ignore - + _delete_at_management_group_scope_initial.metadata = {"url": "/providers/Microsoft.Management/managementGroups/{groupId}/providers/Microsoft.Resources/deployments/{deploymentName}"} # type: ignore @distributed_trace - def begin_delete_at_management_group_scope( # pylint: disable=inconsistent-return-statements - self, - group_id: str, - deployment_name: str, - **kwargs: Any + def begin_delete_at_management_group_scope( + self, group_id: str, deployment_name: str, **kwargs: Any ) -> LROPoller[None]: """Deletes a deployment from the deployment history. @@ -2429,9 +2113,9 @@ def begin_delete_at_management_group_scope( # pylint: disable=inconsistent-retu process finishes, the URI in the Location header returns a status of 204 on success. If the asynchronous request failed, the URI in the Location header returns an error-level status code. - :param group_id: The management group ID. + :param group_id: The management group ID. Required. :type group_id: str - :param deployment_name: The name of the deployment. + :param deployment_name: The name of the deployment. Required. :type deployment_name: str :keyword callable cls: A custom type or function that will be passed the direct response :keyword str continuation_token: A continuation token to restart a poller from a saved state. @@ -2443,86 +2127,91 @@ def begin_delete_at_management_group_scope( # pylint: disable=inconsistent-retu Retry-After header is present. :return: An instance of LROPoller that returns either None or the result of cls(response) :rtype: ~azure.core.polling.LROPoller[None] - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - api_version = kwargs.pop('api_version', "2019-05-01") # type: str - polling = kwargs.pop('polling', True) # type: Union[bool, PollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType[None] - lro_delay = kwargs.pop( - 'polling_interval', - self._config.polling_interval - ) - cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2019-05-01")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[None] + polling = kwargs.pop("polling", True) # type: Union[bool, PollingMethod] + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token = kwargs.pop("continuation_token", None) # type: Optional[str] if cont_token is None: - raw_result = self._delete_at_management_group_scope_initial( + raw_result = self._delete_at_management_group_scope_initial( # type: ignore group_id=group_id, deployment_name=deployment_name, api_version=api_version, - cls=lambda x,y,z: x, + cls=lambda x, y, z: x, + headers=_headers, + params=_params, **kwargs ) - kwargs.pop('error_map', None) + kwargs.pop("error_map", None) - def get_long_running_output(pipeline_response): + def get_long_running_output(pipeline_response): # pylint: disable=inconsistent-return-statements if cls: return cls(pipeline_response, None, {}) - - if polling is True: polling_method = ARMPolling(lro_delay, **kwargs) - elif polling is False: polling_method = NoPolling() - else: polling_method = polling + if polling is True: + polling_method = cast(PollingMethod, ARMPolling(lro_delay, **kwargs)) # type: PollingMethod + elif polling is False: + polling_method = cast(PollingMethod, NoPolling()) + else: + polling_method = polling if cont_token: return LROPoller.from_continuation_token( polling_method=polling_method, continuation_token=cont_token, client=self._client, - deserialization_callback=get_long_running_output + deserialization_callback=get_long_running_output, ) return LROPoller(self._client, raw_result, get_long_running_output, polling_method) - begin_delete_at_management_group_scope.metadata = {'url': "/providers/Microsoft.Management/managementGroups/{groupId}/providers/Microsoft.Resources/deployments/{deploymentName}"} # type: ignore + begin_delete_at_management_group_scope.metadata = {"url": "/providers/Microsoft.Management/managementGroups/{groupId}/providers/Microsoft.Resources/deployments/{deploymentName}"} # type: ignore @distributed_trace - def check_existence_at_management_group_scope( - self, - group_id: str, - deployment_name: str, - **kwargs: Any - ) -> bool: + def check_existence_at_management_group_scope(self, group_id: str, deployment_name: str, **kwargs: Any) -> bool: """Checks whether the deployment exists. - :param group_id: The management group ID. + :param group_id: The management group ID. Required. :type group_id: str - :param deployment_name: The name of the deployment. + :param deployment_name: The name of the deployment. Required. :type deployment_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: bool, or the result of cls(response) + :return: bool or the result of cls(response) :rtype: bool - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType[None] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) - api_version = kwargs.pop('api_version', "2019-05-01") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2019-05-01")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[None] - request = build_deployments_check_existence_at_management_group_scope_request( group_id=group_id, deployment_name=deployment_name, api_version=api_version, - template_url=self.check_existence_at_management_group_scope.metadata['url'], + template_url=self.check_existence_at_management_group_scope.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [204, 404]: @@ -2533,43 +2222,52 @@ def check_existence_at_management_group_scope( return cls(pipeline_response, None, {}) return 200 <= response.status_code <= 299 - check_existence_at_management_group_scope.metadata = {'url': "/providers/Microsoft.Management/managementGroups/{groupId}/providers/Microsoft.Resources/deployments/{deploymentName}"} # type: ignore - + check_existence_at_management_group_scope.metadata = {"url": "/providers/Microsoft.Management/managementGroups/{groupId}/providers/Microsoft.Resources/deployments/{deploymentName}"} # type: ignore def _create_or_update_at_management_group_scope_initial( - self, - group_id: str, - deployment_name: str, - parameters: "_models.Deployment", - **kwargs: Any - ) -> "_models.DeploymentExtended": - cls = kwargs.pop('cls', None) # type: ClsType["_models.DeploymentExtended"] + self, group_id: str, deployment_name: str, parameters: Union[_models.Deployment, IO], **kwargs: Any + ) -> _models.DeploymentExtended: error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', "2019-05-01") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + api_version = kwargs.pop("api_version", _params.pop("api-version", "2019-05-01")) # type: str + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.DeploymentExtended] - _json = self._serialize.body(parameters, 'Deployment') + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(parameters, (IO, bytes)): + _content = parameters + else: + _json = self._serialize.body(parameters, "Deployment") - request = build_deployments_create_or_update_at_management_group_scope_request_initial( + request = build_deployments_create_or_update_at_management_group_scope_request( group_id=group_id, deployment_name=deployment_name, api_version=api_version, content_type=content_type, json=_json, - template_url=self._create_or_update_at_management_group_scope_initial.metadata['url'], + content=_content, + template_url=self._create_or_update_at_management_group_scope_initial.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200, 201]: @@ -2577,37 +2275,41 @@ def _create_or_update_at_management_group_scope_initial( raise HttpResponseError(response=response, error_format=ARMErrorFormat) if response.status_code == 200: - deserialized = self._deserialize('DeploymentExtended', pipeline_response) + deserialized = self._deserialize("DeploymentExtended", pipeline_response) if response.status_code == 201: - deserialized = self._deserialize('DeploymentExtended', pipeline_response) + deserialized = self._deserialize("DeploymentExtended", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - _create_or_update_at_management_group_scope_initial.metadata = {'url': "/providers/Microsoft.Management/managementGroups/{groupId}/providers/Microsoft.Resources/deployments/{deploymentName}"} # type: ignore - + _create_or_update_at_management_group_scope_initial.metadata = {"url": "/providers/Microsoft.Management/managementGroups/{groupId}/providers/Microsoft.Resources/deployments/{deploymentName}"} # type: ignore - @distributed_trace + @overload def begin_create_or_update_at_management_group_scope( self, group_id: str, deployment_name: str, - parameters: "_models.Deployment", + parameters: _models.Deployment, + *, + content_type: str = "application/json", **kwargs: Any - ) -> LROPoller["_models.DeploymentExtended"]: + ) -> LROPoller[_models.DeploymentExtended]: """Deploys resources at management group scope. You can provide the template and parameters directly in the request or link to JSON files. - :param group_id: The management group ID. + :param group_id: The management group ID. Required. :type group_id: str - :param deployment_name: The name of the deployment. + :param deployment_name: The name of the deployment. Required. :type deployment_name: str - :param parameters: Additional parameters supplied to the operation. + :param parameters: Additional parameters supplied to the operation. Required. :type parameters: ~azure.mgmt.resource.resources.v2019_05_01.models.Deployment + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str :keyword callable cls: A custom type or function that will be passed the direct response :keyword str continuation_token: A continuation token to restart a poller from a saved state. :keyword polling: By default, your polling method will be ARMPolling. Pass in False for this @@ -2620,114 +2322,187 @@ def begin_create_or_update_at_management_group_scope( cls(response) :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.resource.resources.v2019_05_01.models.DeploymentExtended] - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - api_version = kwargs.pop('api_version', "2019-05-01") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] - polling = kwargs.pop('polling', True) # type: Union[bool, PollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType["_models.DeploymentExtended"] - lro_delay = kwargs.pop( - 'polling_interval', - self._config.polling_interval - ) - cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] + + @overload + def begin_create_or_update_at_management_group_scope( + self, + group_id: str, + deployment_name: str, + parameters: IO, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> LROPoller[_models.DeploymentExtended]: + """Deploys resources at management group scope. + + You can provide the template and parameters directly in the request or link to JSON files. + + :param group_id: The management group ID. Required. + :type group_id: str + :param deployment_name: The name of the deployment. Required. + :type deployment_name: str + :param parameters: Additional parameters supplied to the operation. Required. + :type parameters: IO + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be ARMPolling. Pass in False for this + operation to not poll, or pass in your own initialized polling object for a personal polling + strategy. + :paramtype polling: bool or ~azure.core.polling.PollingMethod + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of LROPoller that returns either DeploymentExtended or the result of + cls(response) + :rtype: + ~azure.core.polling.LROPoller[~azure.mgmt.resource.resources.v2019_05_01.models.DeploymentExtended] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace + def begin_create_or_update_at_management_group_scope( + self, group_id: str, deployment_name: str, parameters: Union[_models.Deployment, IO], **kwargs: Any + ) -> LROPoller[_models.DeploymentExtended]: + """Deploys resources at management group scope. + + You can provide the template and parameters directly in the request or link to JSON files. + + :param group_id: The management group ID. Required. + :type group_id: str + :param deployment_name: The name of the deployment. Required. + :type deployment_name: str + :param parameters: Additional parameters supplied to the operation. Is either a model type or a + IO type. Required. + :type parameters: ~azure.mgmt.resource.resources.v2019_05_01.models.Deployment or IO + :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. + Default value is None. + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be ARMPolling. Pass in False for this + operation to not poll, or pass in your own initialized polling object for a personal polling + strategy. + :paramtype polling: bool or ~azure.core.polling.PollingMethod + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of LROPoller that returns either DeploymentExtended or the result of + cls(response) + :rtype: + ~azure.core.polling.LROPoller[~azure.mgmt.resource.resources.v2019_05_01.models.DeploymentExtended] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _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", "2019-05-01")) # type: str + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.DeploymentExtended] + polling = kwargs.pop("polling", True) # type: Union[bool, PollingMethod] + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token = kwargs.pop("continuation_token", None) # type: Optional[str] if cont_token is None: - raw_result = self._create_or_update_at_management_group_scope_initial( + raw_result = self._create_or_update_at_management_group_scope_initial( # type: ignore group_id=group_id, deployment_name=deployment_name, parameters=parameters, api_version=api_version, content_type=content_type, - cls=lambda x,y,z: x, + cls=lambda x, y, z: x, + headers=_headers, + params=_params, **kwargs ) - kwargs.pop('error_map', None) + kwargs.pop("error_map", None) def get_long_running_output(pipeline_response): - response = pipeline_response.http_response - deserialized = self._deserialize('DeploymentExtended', pipeline_response) + deserialized = self._deserialize("DeploymentExtended", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - - if polling is True: polling_method = ARMPolling(lro_delay, **kwargs) - elif polling is False: polling_method = NoPolling() - else: polling_method = polling + if polling is True: + polling_method = cast(PollingMethod, ARMPolling(lro_delay, **kwargs)) # type: PollingMethod + elif polling is False: + polling_method = cast(PollingMethod, NoPolling()) + else: + polling_method = polling if cont_token: return LROPoller.from_continuation_token( polling_method=polling_method, continuation_token=cont_token, client=self._client, - deserialization_callback=get_long_running_output + deserialization_callback=get_long_running_output, ) return LROPoller(self._client, raw_result, get_long_running_output, polling_method) - begin_create_or_update_at_management_group_scope.metadata = {'url': "/providers/Microsoft.Management/managementGroups/{groupId}/providers/Microsoft.Resources/deployments/{deploymentName}"} # type: ignore + begin_create_or_update_at_management_group_scope.metadata = {"url": "/providers/Microsoft.Management/managementGroups/{groupId}/providers/Microsoft.Resources/deployments/{deploymentName}"} # type: ignore @distributed_trace def get_at_management_group_scope( - self, - group_id: str, - deployment_name: str, - **kwargs: Any - ) -> "_models.DeploymentExtended": + self, group_id: str, deployment_name: str, **kwargs: Any + ) -> _models.DeploymentExtended: """Gets a deployment. - :param group_id: The management group ID. + :param group_id: The management group ID. Required. :type group_id: str - :param deployment_name: The name of the deployment. + :param deployment_name: The name of the deployment. Required. :type deployment_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: DeploymentExtended, or the result of cls(response) + :return: DeploymentExtended or the result of cls(response) :rtype: ~azure.mgmt.resource.resources.v2019_05_01.models.DeploymentExtended - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.DeploymentExtended"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) - api_version = kwargs.pop('api_version', "2019-05-01") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2019-05-01")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[_models.DeploymentExtended] - request = build_deployments_get_at_management_group_scope_request( group_id=group_id, deployment_name=deployment_name, api_version=api_version, - template_url=self.get_at_management_group_scope.metadata['url'], + template_url=self.get_at_management_group_scope.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) - deserialized = self._deserialize('DeploymentExtended', pipeline_response) + deserialized = self._deserialize("DeploymentExtended", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - get_at_management_group_scope.metadata = {'url': "/providers/Microsoft.Management/managementGroups/{groupId}/providers/Microsoft.Resources/deployments/{deploymentName}"} # type: ignore - + get_at_management_group_scope.metadata = {"url": "/providers/Microsoft.Management/managementGroups/{groupId}/providers/Microsoft.Resources/deployments/{deploymentName}"} # type: ignore @distributed_trace def cancel_at_management_group_scope( # pylint: disable=inconsistent-return-statements - self, - group_id: str, - deployment_name: str, - **kwargs: Any + self, group_id: str, deployment_name: str, **kwargs: Any ) -> None: """Cancels a currently running template deployment. @@ -2736,38 +2511,44 @@ def cancel_at_management_group_scope( # pylint: disable=inconsistent-return-sta deployment stops the currently running template deployment and leaves the resources partially deployed. - :param group_id: The management group ID. + :param group_id: The management group ID. Required. :type group_id: str - :param deployment_name: The name of the deployment. + :param deployment_name: The name of the deployment. Required. :type deployment_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: None, or the result of cls(response) + :return: None or the result of cls(response) :rtype: None - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType[None] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + 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', "2019-05-01") # type: str + api_version = kwargs.pop("api_version", _params.pop("api-version", "2019-05-01")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[None] - request = build_deployments_cancel_at_management_group_scope_request( group_id=group_id, deployment_name=deployment_name, api_version=api_version, - template_url=self.cancel_at_management_group_scope.metadata['url'], + template_url=self.cancel_at_management_group_scope.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [204]: @@ -2777,41 +2558,107 @@ def cancel_at_management_group_scope( # pylint: disable=inconsistent-return-sta if cls: return cls(pipeline_response, None, {}) - cancel_at_management_group_scope.metadata = {'url': "/providers/Microsoft.Management/managementGroups/{groupId}/providers/Microsoft.Resources/deployments/{deploymentName}/cancel"} # type: ignore - + cancel_at_management_group_scope.metadata = {"url": "/providers/Microsoft.Management/managementGroups/{groupId}/providers/Microsoft.Resources/deployments/{deploymentName}/cancel"} # type: ignore - @distributed_trace + @overload def validate_at_management_group_scope( self, group_id: str, deployment_name: str, - parameters: "_models.Deployment", + parameters: _models.Deployment, + *, + content_type: str = "application/json", **kwargs: Any - ) -> "_models.DeploymentValidateResult": + ) -> _models.DeploymentValidateResult: """Validates whether the specified template is syntactically correct and will be accepted by Azure Resource Manager.. - :param group_id: The management group ID. + :param group_id: The management group ID. Required. :type group_id: str - :param deployment_name: The name of the deployment. + :param deployment_name: The name of the deployment. Required. :type deployment_name: str - :param parameters: Parameters to validate. + :param parameters: Parameters to validate. Required. :type parameters: ~azure.mgmt.resource.resources.v2019_05_01.models.Deployment + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: DeploymentValidateResult or the result of cls(response) + :rtype: ~azure.mgmt.resource.resources.v2019_05_01.models.DeploymentValidateResult + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + def validate_at_management_group_scope( + self, + group_id: str, + deployment_name: str, + parameters: IO, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.DeploymentValidateResult: + """Validates whether the specified template is syntactically correct and will be accepted by Azure + Resource Manager.. + + :param group_id: The management group ID. Required. + :type group_id: str + :param deployment_name: The name of the deployment. Required. + :type deployment_name: str + :param parameters: Parameters to validate. Required. + :type parameters: IO + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: DeploymentValidateResult or the result of cls(response) + :rtype: ~azure.mgmt.resource.resources.v2019_05_01.models.DeploymentValidateResult + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace + def validate_at_management_group_scope( + self, group_id: str, deployment_name: str, parameters: Union[_models.Deployment, IO], **kwargs: Any + ) -> _models.DeploymentValidateResult: + """Validates whether the specified template is syntactically correct and will be accepted by Azure + Resource Manager.. + + :param group_id: The management group ID. Required. + :type group_id: str + :param deployment_name: The name of the deployment. Required. + :type deployment_name: str + :param parameters: Parameters to validate. Is either a model type or a IO type. Required. + :type parameters: ~azure.mgmt.resource.resources.v2019_05_01.models.Deployment or IO + :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. + Default value is None. + :paramtype content_type: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: DeploymentValidateResult, or the result of cls(response) + :return: DeploymentValidateResult or the result of cls(response) :rtype: ~azure.mgmt.resource.resources.v2019_05_01.models.DeploymentValidateResult - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.DeploymentValidateResult"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', "2019-05-01") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + api_version = kwargs.pop("api_version", _params.pop("api-version", "2019-05-01")) # type: str + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.DeploymentValidateResult] - _json = self._serialize.body(parameters, 'Deployment') + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(parameters, (IO, bytes)): + _content = parameters + else: + _json = self._serialize.body(parameters, "Deployment") request = build_deployments_validate_at_management_group_scope_request( group_id=group_id, @@ -2819,16 +2666,18 @@ def validate_at_management_group_scope( api_version=api_version, content_type=content_type, json=_json, - template_url=self.validate_at_management_group_scope.metadata['url'], + content=_content, + template_url=self.validate_at_management_group_scope.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200, 400]: @@ -2836,87 +2685,84 @@ def validate_at_management_group_scope( raise HttpResponseError(response=response, error_format=ARMErrorFormat) if response.status_code == 200: - deserialized = self._deserialize('DeploymentValidateResult', pipeline_response) + deserialized = self._deserialize("DeploymentValidateResult", pipeline_response) if response.status_code == 400: - deserialized = self._deserialize('DeploymentValidateResult', pipeline_response) + deserialized = self._deserialize("DeploymentValidateResult", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - validate_at_management_group_scope.metadata = {'url': "/providers/Microsoft.Management/managementGroups/{groupId}/providers/Microsoft.Resources/deployments/{deploymentName}/validate"} # type: ignore - + validate_at_management_group_scope.metadata = {"url": "/providers/Microsoft.Management/managementGroups/{groupId}/providers/Microsoft.Resources/deployments/{deploymentName}/validate"} # type: ignore @distributed_trace def export_template_at_management_group_scope( - self, - group_id: str, - deployment_name: str, - **kwargs: Any - ) -> "_models.DeploymentExportResult": + self, group_id: str, deployment_name: str, **kwargs: Any + ) -> _models.DeploymentExportResult: """Exports the template used for specified deployment. - :param group_id: The management group ID. + :param group_id: The management group ID. Required. :type group_id: str - :param deployment_name: The name of the deployment. + :param deployment_name: The name of the deployment. Required. :type deployment_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: DeploymentExportResult, or the result of cls(response) + :return: DeploymentExportResult or the result of cls(response) :rtype: ~azure.mgmt.resource.resources.v2019_05_01.models.DeploymentExportResult - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.DeploymentExportResult"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) - api_version = kwargs.pop('api_version', "2019-05-01") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2019-05-01")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[_models.DeploymentExportResult] - request = build_deployments_export_template_at_management_group_scope_request( group_id=group_id, deployment_name=deployment_name, api_version=api_version, - template_url=self.export_template_at_management_group_scope.metadata['url'], + template_url=self.export_template_at_management_group_scope.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) - deserialized = self._deserialize('DeploymentExportResult', pipeline_response) + deserialized = self._deserialize("DeploymentExportResult", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - export_template_at_management_group_scope.metadata = {'url': "/providers/Microsoft.Management/managementGroups/{groupId}/providers/Microsoft.Resources/deployments/{deploymentName}/exportTemplate"} # type: ignore - + export_template_at_management_group_scope.metadata = {"url": "/providers/Microsoft.Management/managementGroups/{groupId}/providers/Microsoft.Resources/deployments/{deploymentName}/exportTemplate"} # type: ignore @distributed_trace def list_at_management_group_scope( - self, - group_id: str, - filter: Optional[str] = None, - top: Optional[int] = None, - **kwargs: Any - ) -> Iterable["_models.DeploymentListResult"]: + self, group_id: str, filter: Optional[str] = None, top: Optional[int] = None, **kwargs: Any + ) -> Iterable["_models.DeploymentExtended"]: """Get all the deployments for a management group. - :param group_id: The management group ID. + :param group_id: The management group ID. Required. :type group_id: str :param filter: The filter to apply on the operation. For example, you can use $filter=provisioningState eq '{state}'. Default value is None. @@ -2925,40 +2771,48 @@ def list_at_management_group_scope( value is None. :type top: int :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either DeploymentListResult or the result of - cls(response) + :return: An iterator like instance of either DeploymentExtended or the result of cls(response) :rtype: - ~azure.core.paging.ItemPaged[~azure.mgmt.resource.resources.v2019_05_01.models.DeploymentListResult] - :raises: ~azure.core.exceptions.HttpResponseError + ~azure.core.paging.ItemPaged[~azure.mgmt.resource.resources.v2019_05_01.models.DeploymentExtended] + :raises ~azure.core.exceptions.HttpResponseError: """ - api_version = kwargs.pop('api_version', "2019-05-01") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2019-05-01")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[_models.DeploymentListResult] - cls = kwargs.pop('cls', None) # type: ClsType["_models.DeploymentListResult"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) + def prepare_request(next_link=None): if not next_link: - + request = build_deployments_list_at_management_group_scope_request( group_id=group_id, - api_version=api_version, filter=filter, top=top, - template_url=self.list_at_management_group_scope.metadata['url'], + api_version=api_version, + template_url=self.list_at_management_group_scope.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore else: - - request = build_deployments_list_at_management_group_scope_request( - group_id=group_id, - template_url=next_link, - ) + # make call to next link with the client's api-version + _parsed_next_link = urlparse(next_link) + _next_request_params = case_insensitive_dict(parse_qs(_parsed_next_link.query)) + _next_request_params["api-version"] = self._config.api_version + request = HttpRequest("GET", urljoin(next_link, _parsed_next_link.path), params=_next_request_params) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore request.method = "GET" return request @@ -2972,10 +2826,8 @@ def extract_data(pipeline_response): def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) response = pipeline_response.http_response @@ -2985,40 +2837,42 @@ def get_next(next_link=None): return pipeline_response + return ItemPaged(get_next, extract_data) - return ItemPaged( - get_next, extract_data - ) - list_at_management_group_scope.metadata = {'url': "/providers/Microsoft.Management/managementGroups/{groupId}/providers/Microsoft.Resources/deployments/"} # type: ignore + list_at_management_group_scope.metadata = {"url": "/providers/Microsoft.Management/managementGroups/{groupId}/providers/Microsoft.Resources/deployments/"} # type: ignore def _delete_at_subscription_scope_initial( # pylint: disable=inconsistent-return-statements - self, - deployment_name: str, - **kwargs: Any + self, deployment_name: str, **kwargs: Any ) -> None: - cls = kwargs.pop('cls', None) # type: ClsType[None] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) - api_version = kwargs.pop('api_version', "2019-05-01") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - request = build_deployments_delete_at_subscription_scope_request_initial( + api_version = kwargs.pop("api_version", _params.pop("api-version", "2019-05-01")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[None] + + request = build_deployments_delete_at_subscription_scope_request( deployment_name=deployment_name, subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self._delete_at_subscription_scope_initial.metadata['url'], + template_url=self._delete_at_subscription_scope_initial.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [202, 204]: @@ -3028,15 +2882,10 @@ def _delete_at_subscription_scope_initial( # pylint: disable=inconsistent-retur if cls: return cls(pipeline_response, None, {}) - _delete_at_subscription_scope_initial.metadata = {'url': "/subscriptions/{subscriptionId}/providers/Microsoft.Resources/deployments/{deploymentName}"} # type: ignore - + _delete_at_subscription_scope_initial.metadata = {"url": "/subscriptions/{subscriptionId}/providers/Microsoft.Resources/deployments/{deploymentName}"} # type: ignore @distributed_trace - def begin_delete_at_subscription_scope( # pylint: disable=inconsistent-return-statements - self, - deployment_name: str, - **kwargs: Any - ) -> LROPoller[None]: + def begin_delete_at_subscription_scope(self, deployment_name: str, **kwargs: Any) -> LROPoller[None]: """Deletes a deployment from the deployment history. A template deployment that is currently running cannot be deleted. Deleting a template @@ -3047,7 +2896,7 @@ def begin_delete_at_subscription_scope( # pylint: disable=inconsistent-return-s process finishes, the URI in the Location header returns a status of 204 on success. If the asynchronous request failed, the URI in the Location header returns an error-level status code. - :param deployment_name: The name of the deployment. + :param deployment_name: The name of the deployment. Required. :type deployment_name: str :keyword callable cls: A custom type or function that will be passed the direct response :keyword str continuation_token: A continuation token to restart a poller from a saved state. @@ -3059,82 +2908,88 @@ def begin_delete_at_subscription_scope( # pylint: disable=inconsistent-return-s Retry-After header is present. :return: An instance of LROPoller that returns either None or the result of cls(response) :rtype: ~azure.core.polling.LROPoller[None] - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - api_version = kwargs.pop('api_version', "2019-05-01") # type: str - polling = kwargs.pop('polling', True) # type: Union[bool, PollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType[None] - lro_delay = kwargs.pop( - 'polling_interval', - self._config.polling_interval - ) - cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2019-05-01")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[None] + polling = kwargs.pop("polling", True) # type: Union[bool, PollingMethod] + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token = kwargs.pop("continuation_token", None) # type: Optional[str] if cont_token is None: - raw_result = self._delete_at_subscription_scope_initial( + raw_result = self._delete_at_subscription_scope_initial( # type: ignore deployment_name=deployment_name, api_version=api_version, - cls=lambda x,y,z: x, + cls=lambda x, y, z: x, + headers=_headers, + params=_params, **kwargs ) - kwargs.pop('error_map', None) + kwargs.pop("error_map", None) - def get_long_running_output(pipeline_response): + def get_long_running_output(pipeline_response): # pylint: disable=inconsistent-return-statements if cls: return cls(pipeline_response, None, {}) - - if polling is True: polling_method = ARMPolling(lro_delay, **kwargs) - elif polling is False: polling_method = NoPolling() - else: polling_method = polling + if polling is True: + polling_method = cast(PollingMethod, ARMPolling(lro_delay, **kwargs)) # type: PollingMethod + elif polling is False: + polling_method = cast(PollingMethod, NoPolling()) + else: + polling_method = polling if cont_token: return LROPoller.from_continuation_token( polling_method=polling_method, continuation_token=cont_token, client=self._client, - deserialization_callback=get_long_running_output + deserialization_callback=get_long_running_output, ) return LROPoller(self._client, raw_result, get_long_running_output, polling_method) - begin_delete_at_subscription_scope.metadata = {'url': "/subscriptions/{subscriptionId}/providers/Microsoft.Resources/deployments/{deploymentName}"} # type: ignore + begin_delete_at_subscription_scope.metadata = {"url": "/subscriptions/{subscriptionId}/providers/Microsoft.Resources/deployments/{deploymentName}"} # type: ignore @distributed_trace - def check_existence_at_subscription_scope( - self, - deployment_name: str, - **kwargs: Any - ) -> bool: + def check_existence_at_subscription_scope(self, deployment_name: str, **kwargs: Any) -> bool: """Checks whether the deployment exists. - :param deployment_name: The name of the deployment. + :param deployment_name: The name of the deployment. Required. :type deployment_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: bool, or the result of cls(response) + :return: bool or the result of cls(response) :rtype: bool - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType[None] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) - api_version = kwargs.pop('api_version', "2019-05-01") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2019-05-01")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[None] - request = build_deployments_check_existence_at_subscription_scope_request( deployment_name=deployment_name, subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.check_existence_at_subscription_scope.metadata['url'], + template_url=self.check_existence_at_subscription_scope.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [204, 404]: @@ -3145,42 +3000,52 @@ def check_existence_at_subscription_scope( return cls(pipeline_response, None, {}) return 200 <= response.status_code <= 299 - check_existence_at_subscription_scope.metadata = {'url': "/subscriptions/{subscriptionId}/providers/Microsoft.Resources/deployments/{deploymentName}"} # type: ignore - + check_existence_at_subscription_scope.metadata = {"url": "/subscriptions/{subscriptionId}/providers/Microsoft.Resources/deployments/{deploymentName}"} # type: ignore def _create_or_update_at_subscription_scope_initial( - self, - deployment_name: str, - parameters: "_models.Deployment", - **kwargs: Any - ) -> "_models.DeploymentExtended": - cls = kwargs.pop('cls', None) # type: ClsType["_models.DeploymentExtended"] + self, deployment_name: str, parameters: Union[_models.Deployment, IO], **kwargs: Any + ) -> _models.DeploymentExtended: error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) - api_version = kwargs.pop('api_version', "2019-05-01") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - _json = self._serialize.body(parameters, 'Deployment') + api_version = kwargs.pop("api_version", _params.pop("api-version", "2019-05-01")) # type: str + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.DeploymentExtended] - request = build_deployments_create_or_update_at_subscription_scope_request_initial( + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(parameters, (IO, bytes)): + _content = parameters + else: + _json = self._serialize.body(parameters, "Deployment") + + request = build_deployments_create_or_update_at_subscription_scope_request( deployment_name=deployment_name, subscription_id=self._config.subscription_id, api_version=api_version, content_type=content_type, json=_json, - template_url=self._create_or_update_at_subscription_scope_initial.metadata['url'], + content=_content, + template_url=self._create_or_update_at_subscription_scope_initial.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200, 201]: @@ -3188,34 +3053,38 @@ def _create_or_update_at_subscription_scope_initial( raise HttpResponseError(response=response, error_format=ARMErrorFormat) if response.status_code == 200: - deserialized = self._deserialize('DeploymentExtended', pipeline_response) + deserialized = self._deserialize("DeploymentExtended", pipeline_response) if response.status_code == 201: - deserialized = self._deserialize('DeploymentExtended', pipeline_response) + deserialized = self._deserialize("DeploymentExtended", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - _create_or_update_at_subscription_scope_initial.metadata = {'url': "/subscriptions/{subscriptionId}/providers/Microsoft.Resources/deployments/{deploymentName}"} # type: ignore + _create_or_update_at_subscription_scope_initial.metadata = {"url": "/subscriptions/{subscriptionId}/providers/Microsoft.Resources/deployments/{deploymentName}"} # type: ignore - - @distributed_trace + @overload def begin_create_or_update_at_subscription_scope( self, deployment_name: str, - parameters: "_models.Deployment", + parameters: _models.Deployment, + *, + content_type: str = "application/json", **kwargs: Any - ) -> LROPoller["_models.DeploymentExtended"]: + ) -> LROPoller[_models.DeploymentExtended]: """Deploys resources at subscription scope. You can provide the template and parameters directly in the request or link to JSON files. - :param deployment_name: The name of the deployment. + :param deployment_name: The name of the deployment. Required. :type deployment_name: str - :param parameters: Additional parameters supplied to the operation. + :param parameters: Additional parameters supplied to the operation. Required. :type parameters: ~azure.mgmt.resource.resources.v2019_05_01.models.Deployment + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str :keyword callable cls: A custom type or function that will be passed the direct response :keyword str continuation_token: A continuation token to restart a poller from a saved state. :keyword polling: By default, your polling method will be ARMPolling. Pass in False for this @@ -3228,109 +3097,172 @@ def begin_create_or_update_at_subscription_scope( cls(response) :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.resource.resources.v2019_05_01.models.DeploymentExtended] - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - api_version = kwargs.pop('api_version', "2019-05-01") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] - polling = kwargs.pop('polling', True) # type: Union[bool, PollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType["_models.DeploymentExtended"] - lro_delay = kwargs.pop( - 'polling_interval', - self._config.polling_interval - ) - cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] + + @overload + def begin_create_or_update_at_subscription_scope( + self, deployment_name: str, parameters: IO, *, content_type: str = "application/json", **kwargs: Any + ) -> LROPoller[_models.DeploymentExtended]: + """Deploys resources at subscription scope. + + You can provide the template and parameters directly in the request or link to JSON files. + + :param deployment_name: The name of the deployment. Required. + :type deployment_name: str + :param parameters: Additional parameters supplied to the operation. Required. + :type parameters: IO + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be ARMPolling. Pass in False for this + operation to not poll, or pass in your own initialized polling object for a personal polling + strategy. + :paramtype polling: bool or ~azure.core.polling.PollingMethod + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of LROPoller that returns either DeploymentExtended or the result of + cls(response) + :rtype: + ~azure.core.polling.LROPoller[~azure.mgmt.resource.resources.v2019_05_01.models.DeploymentExtended] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace + def begin_create_or_update_at_subscription_scope( + self, deployment_name: str, parameters: Union[_models.Deployment, IO], **kwargs: Any + ) -> LROPoller[_models.DeploymentExtended]: + """Deploys resources at subscription scope. + + You can provide the template and parameters directly in the request or link to JSON files. + + :param deployment_name: The name of the deployment. Required. + :type deployment_name: str + :param parameters: Additional parameters supplied to the operation. Is either a model type or a + IO type. Required. + :type parameters: ~azure.mgmt.resource.resources.v2019_05_01.models.Deployment or IO + :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. + Default value is None. + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be ARMPolling. Pass in False for this + operation to not poll, or pass in your own initialized polling object for a personal polling + strategy. + :paramtype polling: bool or ~azure.core.polling.PollingMethod + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of LROPoller that returns either DeploymentExtended or the result of + cls(response) + :rtype: + ~azure.core.polling.LROPoller[~azure.mgmt.resource.resources.v2019_05_01.models.DeploymentExtended] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _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", "2019-05-01")) # type: str + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.DeploymentExtended] + polling = kwargs.pop("polling", True) # type: Union[bool, PollingMethod] + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token = kwargs.pop("continuation_token", None) # type: Optional[str] if cont_token is None: - raw_result = self._create_or_update_at_subscription_scope_initial( + raw_result = self._create_or_update_at_subscription_scope_initial( # type: ignore deployment_name=deployment_name, parameters=parameters, api_version=api_version, content_type=content_type, - cls=lambda x,y,z: x, + cls=lambda x, y, z: x, + headers=_headers, + params=_params, **kwargs ) - kwargs.pop('error_map', None) + kwargs.pop("error_map", None) def get_long_running_output(pipeline_response): - response = pipeline_response.http_response - deserialized = self._deserialize('DeploymentExtended', pipeline_response) + deserialized = self._deserialize("DeploymentExtended", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - - if polling is True: polling_method = ARMPolling(lro_delay, **kwargs) - elif polling is False: polling_method = NoPolling() - else: polling_method = polling + if polling is True: + polling_method = cast(PollingMethod, ARMPolling(lro_delay, **kwargs)) # type: PollingMethod + elif polling is False: + polling_method = cast(PollingMethod, NoPolling()) + else: + polling_method = polling if cont_token: return LROPoller.from_continuation_token( polling_method=polling_method, continuation_token=cont_token, client=self._client, - deserialization_callback=get_long_running_output + deserialization_callback=get_long_running_output, ) return LROPoller(self._client, raw_result, get_long_running_output, polling_method) - begin_create_or_update_at_subscription_scope.metadata = {'url': "/subscriptions/{subscriptionId}/providers/Microsoft.Resources/deployments/{deploymentName}"} # type: ignore + begin_create_or_update_at_subscription_scope.metadata = {"url": "/subscriptions/{subscriptionId}/providers/Microsoft.Resources/deployments/{deploymentName}"} # type: ignore @distributed_trace - def get_at_subscription_scope( - self, - deployment_name: str, - **kwargs: Any - ) -> "_models.DeploymentExtended": + def get_at_subscription_scope(self, deployment_name: str, **kwargs: Any) -> _models.DeploymentExtended: """Gets a deployment. - :param deployment_name: The name of the deployment. + :param deployment_name: The name of the deployment. Required. :type deployment_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: DeploymentExtended, or the result of cls(response) + :return: DeploymentExtended or the result of cls(response) :rtype: ~azure.mgmt.resource.resources.v2019_05_01.models.DeploymentExtended - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.DeploymentExtended"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + 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', "2019-05-01") # type: str + api_version = kwargs.pop("api_version", _params.pop("api-version", "2019-05-01")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[_models.DeploymentExtended] - request = build_deployments_get_at_subscription_scope_request( deployment_name=deployment_name, subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.get_at_subscription_scope.metadata['url'], + template_url=self.get_at_subscription_scope.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) - deserialized = self._deserialize('DeploymentExtended', pipeline_response) + deserialized = self._deserialize("DeploymentExtended", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - get_at_subscription_scope.metadata = {'url': "/subscriptions/{subscriptionId}/providers/Microsoft.Resources/deployments/{deploymentName}"} # type: ignore - + get_at_subscription_scope.metadata = {"url": "/subscriptions/{subscriptionId}/providers/Microsoft.Resources/deployments/{deploymentName}"} # type: ignore @distributed_trace def cancel_at_subscription_scope( # pylint: disable=inconsistent-return-statements - self, - deployment_name: str, - **kwargs: Any + self, deployment_name: str, **kwargs: Any ) -> None: """Cancels a currently running template deployment. @@ -3339,36 +3271,42 @@ def cancel_at_subscription_scope( # pylint: disable=inconsistent-return-stateme deployment stops the currently running template deployment and leaves the resources partially deployed. - :param deployment_name: The name of the deployment. + :param deployment_name: The name of the deployment. Required. :type deployment_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: None, or the result of cls(response) + :return: None or the result of cls(response) :rtype: None - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType[None] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + 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', "2019-05-01") # type: str + api_version = kwargs.pop("api_version", _params.pop("api-version", "2019-05-01")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[None] - request = build_deployments_cancel_at_subscription_scope_request( deployment_name=deployment_name, subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.cancel_at_subscription_scope.metadata['url'], + template_url=self.cancel_at_subscription_scope.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [204]: @@ -3378,38 +3316,94 @@ def cancel_at_subscription_scope( # pylint: disable=inconsistent-return-stateme if cls: return cls(pipeline_response, None, {}) - cancel_at_subscription_scope.metadata = {'url': "/subscriptions/{subscriptionId}/providers/Microsoft.Resources/deployments/{deploymentName}/cancel"} # type: ignore - + cancel_at_subscription_scope.metadata = {"url": "/subscriptions/{subscriptionId}/providers/Microsoft.Resources/deployments/{deploymentName}/cancel"} # type: ignore - @distributed_trace + @overload def validate_at_subscription_scope( self, deployment_name: str, - parameters: "_models.Deployment", + parameters: _models.Deployment, + *, + content_type: str = "application/json", **kwargs: Any - ) -> "_models.DeploymentValidateResult": + ) -> _models.DeploymentValidateResult: """Validates whether the specified template is syntactically correct and will be accepted by Azure Resource Manager.. - :param deployment_name: The name of the deployment. + :param deployment_name: The name of the deployment. Required. :type deployment_name: str - :param parameters: Parameters to validate. + :param parameters: Parameters to validate. Required. :type parameters: ~azure.mgmt.resource.resources.v2019_05_01.models.Deployment + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: DeploymentValidateResult or the result of cls(response) + :rtype: ~azure.mgmt.resource.resources.v2019_05_01.models.DeploymentValidateResult + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + def validate_at_subscription_scope( + self, deployment_name: str, parameters: IO, *, content_type: str = "application/json", **kwargs: Any + ) -> _models.DeploymentValidateResult: + """Validates whether the specified template is syntactically correct and will be accepted by Azure + Resource Manager.. + + :param deployment_name: The name of the deployment. Required. + :type deployment_name: str + :param parameters: Parameters to validate. Required. + :type parameters: IO + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: DeploymentValidateResult or the result of cls(response) + :rtype: ~azure.mgmt.resource.resources.v2019_05_01.models.DeploymentValidateResult + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace + def validate_at_subscription_scope( + self, deployment_name: str, parameters: Union[_models.Deployment, IO], **kwargs: Any + ) -> _models.DeploymentValidateResult: + """Validates whether the specified template is syntactically correct and will be accepted by Azure + Resource Manager.. + + :param deployment_name: The name of the deployment. Required. + :type deployment_name: str + :param parameters: Parameters to validate. Is either a model type or a IO type. Required. + :type parameters: ~azure.mgmt.resource.resources.v2019_05_01.models.Deployment or IO + :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. + Default value is None. + :paramtype content_type: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: DeploymentValidateResult, or the result of cls(response) + :return: DeploymentValidateResult or the result of cls(response) :rtype: ~azure.mgmt.resource.resources.v2019_05_01.models.DeploymentValidateResult - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.DeploymentValidateResult"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', "2019-05-01") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + api_version = kwargs.pop("api_version", _params.pop("api-version", "2019-05-01")) # type: str + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.DeploymentValidateResult] - _json = self._serialize.body(parameters, 'Deployment') + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(parameters, (IO, bytes)): + _content = parameters + else: + _json = self._serialize.body(parameters, "Deployment") request = build_deployments_validate_at_subscription_scope_request( deployment_name=deployment_name, @@ -3417,16 +3411,18 @@ def validate_at_subscription_scope( api_version=api_version, content_type=content_type, json=_json, - template_url=self.validate_at_subscription_scope.metadata['url'], + content=_content, + template_url=self.validate_at_subscription_scope.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200, 400]: @@ -3434,80 +3430,79 @@ def validate_at_subscription_scope( raise HttpResponseError(response=response, error_format=ARMErrorFormat) if response.status_code == 200: - deserialized = self._deserialize('DeploymentValidateResult', pipeline_response) + deserialized = self._deserialize("DeploymentValidateResult", pipeline_response) if response.status_code == 400: - deserialized = self._deserialize('DeploymentValidateResult', pipeline_response) + deserialized = self._deserialize("DeploymentValidateResult", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - validate_at_subscription_scope.metadata = {'url': "/subscriptions/{subscriptionId}/providers/Microsoft.Resources/deployments/{deploymentName}/validate"} # type: ignore - + validate_at_subscription_scope.metadata = {"url": "/subscriptions/{subscriptionId}/providers/Microsoft.Resources/deployments/{deploymentName}/validate"} # type: ignore @distributed_trace def export_template_at_subscription_scope( - self, - deployment_name: str, - **kwargs: Any - ) -> "_models.DeploymentExportResult": + self, deployment_name: str, **kwargs: Any + ) -> _models.DeploymentExportResult: """Exports the template used for specified deployment. - :param deployment_name: The name of the deployment. + :param deployment_name: The name of the deployment. Required. :type deployment_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: DeploymentExportResult, or the result of cls(response) + :return: DeploymentExportResult or the result of cls(response) :rtype: ~azure.mgmt.resource.resources.v2019_05_01.models.DeploymentExportResult - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.DeploymentExportResult"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + 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', "2019-05-01") # type: str + api_version = kwargs.pop("api_version", _params.pop("api-version", "2019-05-01")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[_models.DeploymentExportResult] - request = build_deployments_export_template_at_subscription_scope_request( deployment_name=deployment_name, subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.export_template_at_subscription_scope.metadata['url'], + template_url=self.export_template_at_subscription_scope.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) - deserialized = self._deserialize('DeploymentExportResult', pipeline_response) + deserialized = self._deserialize("DeploymentExportResult", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - export_template_at_subscription_scope.metadata = {'url': "/subscriptions/{subscriptionId}/providers/Microsoft.Resources/deployments/{deploymentName}/exportTemplate"} # type: ignore - + export_template_at_subscription_scope.metadata = {"url": "/subscriptions/{subscriptionId}/providers/Microsoft.Resources/deployments/{deploymentName}/exportTemplate"} # type: ignore @distributed_trace def list_at_subscription_scope( - self, - filter: Optional[str] = None, - top: Optional[int] = None, - **kwargs: Any - ) -> Iterable["_models.DeploymentListResult"]: + self, filter: Optional[str] = None, top: Optional[int] = None, **kwargs: Any + ) -> Iterable["_models.DeploymentExtended"]: """Get all the deployments for a subscription. :param filter: The filter to apply on the operation. For example, you can use @@ -3517,40 +3512,48 @@ def list_at_subscription_scope( value is None. :type top: int :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either DeploymentListResult or the result of - cls(response) + :return: An iterator like instance of either DeploymentExtended or the result of cls(response) :rtype: - ~azure.core.paging.ItemPaged[~azure.mgmt.resource.resources.v2019_05_01.models.DeploymentListResult] - :raises: ~azure.core.exceptions.HttpResponseError + ~azure.core.paging.ItemPaged[~azure.mgmt.resource.resources.v2019_05_01.models.DeploymentExtended] + :raises ~azure.core.exceptions.HttpResponseError: """ - api_version = kwargs.pop('api_version', "2019-05-01") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2019-05-01")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[_models.DeploymentListResult] - cls = kwargs.pop('cls', None) # type: ClsType["_models.DeploymentListResult"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) + def prepare_request(next_link=None): if not next_link: - + request = build_deployments_list_at_subscription_scope_request( subscription_id=self._config.subscription_id, - api_version=api_version, filter=filter, top=top, - template_url=self.list_at_subscription_scope.metadata['url'], + api_version=api_version, + template_url=self.list_at_subscription_scope.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore else: - - request = build_deployments_list_at_subscription_scope_request( - subscription_id=self._config.subscription_id, - template_url=next_link, - ) + # make call to next link with the client's api-version + _parsed_next_link = urlparse(next_link) + _next_request_params = case_insensitive_dict(parse_qs(_parsed_next_link.query)) + _next_request_params["api-version"] = self._config.api_version + request = HttpRequest("GET", urljoin(next_link, _parsed_next_link.path), params=_next_request_params) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore request.method = "GET" return request @@ -3564,10 +3567,8 @@ def extract_data(pipeline_response): def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) response = pipeline_response.http_response @@ -3577,42 +3578,43 @@ def get_next(next_link=None): return pipeline_response + return ItemPaged(get_next, extract_data) - return ItemPaged( - get_next, extract_data - ) - list_at_subscription_scope.metadata = {'url': "/subscriptions/{subscriptionId}/providers/Microsoft.Resources/deployments/"} # type: ignore + list_at_subscription_scope.metadata = {"url": "/subscriptions/{subscriptionId}/providers/Microsoft.Resources/deployments/"} # type: ignore def _delete_initial( # pylint: disable=inconsistent-return-statements - self, - resource_group_name: str, - deployment_name: str, - **kwargs: Any + self, resource_group_name: str, deployment_name: str, **kwargs: Any ) -> None: - cls = kwargs.pop('cls', None) # type: ClsType[None] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + 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', "2019-05-01") # type: str + api_version = kwargs.pop("api_version", _params.pop("api-version", "2019-05-01")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[None] - - request = build_deployments_delete_request_initial( + request = build_deployments_delete_request( resource_group_name=resource_group_name, deployment_name=deployment_name, subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self._delete_initial.metadata['url'], + template_url=self._delete_initial.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [202, 204]: @@ -3622,16 +3624,10 @@ 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.Resources/deployments/{deploymentName}"} # type: ignore - + _delete_initial.metadata = {"url": "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/Microsoft.Resources/deployments/{deploymentName}"} # type: ignore @distributed_trace - def begin_delete( # pylint: disable=inconsistent-return-statements - self, - resource_group_name: str, - deployment_name: str, - **kwargs: Any - ) -> LROPoller[None]: + def begin_delete(self, resource_group_name: str, deployment_name: str, **kwargs: Any) -> LROPoller[None]: """Deletes a deployment from the deployment history. A template deployment that is currently running cannot be deleted. Deleting a template @@ -3644,9 +3640,9 @@ def begin_delete( # pylint: disable=inconsistent-return-statements asynchronous request failed, the URI in the Location header returns an error-level status code. :param resource_group_name: The name of the resource group with the deployment to delete. The - name is case insensitive. + name is case insensitive. Required. :type resource_group_name: str - :param deployment_name: The name of the deployment. + :param deployment_name: The name of the deployment. Required. :type deployment_name: str :keyword callable cls: A custom type or function that will be passed the direct response :keyword str continuation_token: A continuation token to restart a poller from a saved state. @@ -3658,88 +3654,93 @@ def begin_delete( # pylint: disable=inconsistent-return-statements Retry-After header is present. :return: An instance of LROPoller that returns either None or the result of cls(response) :rtype: ~azure.core.polling.LROPoller[None] - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - api_version = kwargs.pop('api_version', "2019-05-01") # type: str - polling = kwargs.pop('polling', True) # type: Union[bool, PollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType[None] - lro_delay = kwargs.pop( - 'polling_interval', - self._config.polling_interval - ) - cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2019-05-01")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[None] + polling = kwargs.pop("polling", True) # type: Union[bool, PollingMethod] + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token = kwargs.pop("continuation_token", None) # type: Optional[str] if cont_token is None: - raw_result = self._delete_initial( + raw_result = self._delete_initial( # type: ignore resource_group_name=resource_group_name, deployment_name=deployment_name, api_version=api_version, - cls=lambda x,y,z: x, + cls=lambda x, y, z: x, + headers=_headers, + params=_params, **kwargs ) - kwargs.pop('error_map', None) + kwargs.pop("error_map", None) - def get_long_running_output(pipeline_response): + def get_long_running_output(pipeline_response): # pylint: disable=inconsistent-return-statements if cls: return cls(pipeline_response, None, {}) - - if polling is True: polling_method = ARMPolling(lro_delay, **kwargs) - elif polling is False: polling_method = NoPolling() - else: polling_method = polling + if polling is True: + polling_method = cast(PollingMethod, ARMPolling(lro_delay, **kwargs)) # type: PollingMethod + elif polling is False: + polling_method = cast(PollingMethod, NoPolling()) + else: + polling_method = polling if cont_token: return LROPoller.from_continuation_token( polling_method=polling_method, continuation_token=cont_token, client=self._client, - deserialization_callback=get_long_running_output + deserialization_callback=get_long_running_output, ) return LROPoller(self._client, raw_result, get_long_running_output, polling_method) - begin_delete.metadata = {'url': "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/Microsoft.Resources/deployments/{deploymentName}"} # type: ignore + begin_delete.metadata = {"url": "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/Microsoft.Resources/deployments/{deploymentName}"} # type: ignore @distributed_trace - def check_existence( - self, - resource_group_name: str, - deployment_name: str, - **kwargs: Any - ) -> bool: + def check_existence(self, resource_group_name: str, deployment_name: str, **kwargs: Any) -> bool: """Checks whether the deployment exists. :param resource_group_name: The name of the resource group with the deployment to check. The - name is case insensitive. + name is case insensitive. Required. :type resource_group_name: str - :param deployment_name: The name of the deployment. + :param deployment_name: The name of the deployment. Required. :type deployment_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: bool, or the result of cls(response) + :return: bool or the result of cls(response) :rtype: bool - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType[None] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) - api_version = kwargs.pop('api_version', "2019-05-01") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2019-05-01")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[None] - request = build_deployments_check_existence_request( resource_group_name=resource_group_name, deployment_name=deployment_name, subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.check_existence.metadata['url'], + template_url=self.check_existence.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [204, 404]: @@ -3750,44 +3751,53 @@ def check_existence( return cls(pipeline_response, None, {}) return 200 <= response.status_code <= 299 - check_existence.metadata = {'url': "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/Microsoft.Resources/deployments/{deploymentName}"} # type: ignore - + check_existence.metadata = {"url": "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/Microsoft.Resources/deployments/{deploymentName}"} # type: ignore def _create_or_update_initial( - self, - resource_group_name: str, - deployment_name: str, - parameters: "_models.Deployment", - **kwargs: Any - ) -> "_models.DeploymentExtended": - cls = kwargs.pop('cls', None) # type: ClsType["_models.DeploymentExtended"] + self, resource_group_name: str, deployment_name: str, parameters: Union[_models.Deployment, IO], **kwargs: Any + ) -> _models.DeploymentExtended: error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', "2019-05-01") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + api_version = kwargs.pop("api_version", _params.pop("api-version", "2019-05-01")) # type: str + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.DeploymentExtended] - _json = self._serialize.body(parameters, 'Deployment') + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(parameters, (IO, bytes)): + _content = parameters + else: + _json = self._serialize.body(parameters, "Deployment") - request = build_deployments_create_or_update_request_initial( + request = build_deployments_create_or_update_request( resource_group_name=resource_group_name, deployment_name=deployment_name, subscription_id=self._config.subscription_id, api_version=api_version, content_type=content_type, json=_json, - template_url=self._create_or_update_initial.metadata['url'], + content=_content, + template_url=self._create_or_update_initial.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200, 201]: @@ -3795,38 +3805,42 @@ def _create_or_update_initial( raise HttpResponseError(response=response, error_format=ARMErrorFormat) if response.status_code == 200: - deserialized = self._deserialize('DeploymentExtended', pipeline_response) + deserialized = self._deserialize("DeploymentExtended", pipeline_response) if response.status_code == 201: - deserialized = self._deserialize('DeploymentExtended', pipeline_response) + deserialized = self._deserialize("DeploymentExtended", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - _create_or_update_initial.metadata = {'url': "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/Microsoft.Resources/deployments/{deploymentName}"} # type: ignore - + _create_or_update_initial.metadata = {"url": "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/Microsoft.Resources/deployments/{deploymentName}"} # type: ignore - @distributed_trace + @overload def begin_create_or_update( self, resource_group_name: str, deployment_name: str, - parameters: "_models.Deployment", + parameters: _models.Deployment, + *, + content_type: str = "application/json", **kwargs: Any - ) -> LROPoller["_models.DeploymentExtended"]: + ) -> LROPoller[_models.DeploymentExtended]: """Deploys resources to a resource group. You can provide the template and parameters directly in the request or link to JSON files. :param resource_group_name: The name of the resource group to deploy the resources to. The name - is case insensitive. The resource group must already exist. + is case insensitive. The resource group must already exist. Required. :type resource_group_name: str - :param deployment_name: The name of the deployment. + :param deployment_name: The name of the deployment. Required. :type deployment_name: str - :param parameters: Additional parameters supplied to the operation. + :param parameters: Additional parameters supplied to the operation. Required. :type parameters: ~azure.mgmt.resource.resources.v2019_05_01.models.Deployment + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str :keyword callable cls: A custom type or function that will be passed the direct response :keyword str continuation_token: A continuation token to restart a poller from a saved state. :keyword polling: By default, your polling method will be ARMPolling. Pass in False for this @@ -3839,115 +3853,189 @@ def begin_create_or_update( cls(response) :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.resource.resources.v2019_05_01.models.DeploymentExtended] - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - api_version = kwargs.pop('api_version', "2019-05-01") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] - polling = kwargs.pop('polling', True) # type: Union[bool, PollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType["_models.DeploymentExtended"] - lro_delay = kwargs.pop( - 'polling_interval', - self._config.polling_interval - ) - cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] + + @overload + def begin_create_or_update( + self, + resource_group_name: str, + deployment_name: str, + parameters: IO, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> LROPoller[_models.DeploymentExtended]: + """Deploys resources to a resource group. + + You can provide the template and parameters directly in the request or link to JSON files. + + :param resource_group_name: The name of the resource group to deploy the resources to. The name + is case insensitive. The resource group must already exist. Required. + :type resource_group_name: str + :param deployment_name: The name of the deployment. Required. + :type deployment_name: str + :param parameters: Additional parameters supplied to the operation. Required. + :type parameters: IO + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be ARMPolling. Pass in False for this + operation to not poll, or pass in your own initialized polling object for a personal polling + strategy. + :paramtype polling: bool or ~azure.core.polling.PollingMethod + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of LROPoller that returns either DeploymentExtended or the result of + cls(response) + :rtype: + ~azure.core.polling.LROPoller[~azure.mgmt.resource.resources.v2019_05_01.models.DeploymentExtended] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace + def begin_create_or_update( + self, resource_group_name: str, deployment_name: str, parameters: Union[_models.Deployment, IO], **kwargs: Any + ) -> LROPoller[_models.DeploymentExtended]: + """Deploys resources to a resource group. + + You can provide the template and parameters directly in the request or link to JSON files. + + :param resource_group_name: The name of the resource group to deploy the resources to. The name + is case insensitive. The resource group must already exist. Required. + :type resource_group_name: str + :param deployment_name: The name of the deployment. Required. + :type deployment_name: str + :param parameters: Additional parameters supplied to the operation. Is either a model type or a + IO type. Required. + :type parameters: ~azure.mgmt.resource.resources.v2019_05_01.models.Deployment or IO + :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. + Default value is None. + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be ARMPolling. Pass in False for this + operation to not poll, or pass in your own initialized polling object for a personal polling + strategy. + :paramtype polling: bool or ~azure.core.polling.PollingMethod + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of LROPoller that returns either DeploymentExtended or the result of + cls(response) + :rtype: + ~azure.core.polling.LROPoller[~azure.mgmt.resource.resources.v2019_05_01.models.DeploymentExtended] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _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", "2019-05-01")) # type: str + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.DeploymentExtended] + polling = kwargs.pop("polling", True) # type: Union[bool, PollingMethod] + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token = kwargs.pop("continuation_token", None) # type: Optional[str] if cont_token is None: - raw_result = self._create_or_update_initial( + raw_result = self._create_or_update_initial( # type: ignore resource_group_name=resource_group_name, deployment_name=deployment_name, parameters=parameters, api_version=api_version, content_type=content_type, - cls=lambda x,y,z: x, + cls=lambda x, y, z: x, + headers=_headers, + params=_params, **kwargs ) - kwargs.pop('error_map', None) + kwargs.pop("error_map", None) def get_long_running_output(pipeline_response): - response = pipeline_response.http_response - deserialized = self._deserialize('DeploymentExtended', pipeline_response) + deserialized = self._deserialize("DeploymentExtended", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - - if polling is True: polling_method = ARMPolling(lro_delay, **kwargs) - elif polling is False: polling_method = NoPolling() - else: polling_method = polling + if polling is True: + polling_method = cast(PollingMethod, ARMPolling(lro_delay, **kwargs)) # type: PollingMethod + elif polling is False: + polling_method = cast(PollingMethod, NoPolling()) + else: + polling_method = polling if cont_token: return LROPoller.from_continuation_token( polling_method=polling_method, continuation_token=cont_token, client=self._client, - deserialization_callback=get_long_running_output + deserialization_callback=get_long_running_output, ) return LROPoller(self._client, raw_result, get_long_running_output, polling_method) - begin_create_or_update.metadata = {'url': "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/Microsoft.Resources/deployments/{deploymentName}"} # type: ignore + begin_create_or_update.metadata = {"url": "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/Microsoft.Resources/deployments/{deploymentName}"} # type: ignore @distributed_trace - def get( - self, - resource_group_name: str, - deployment_name: str, - **kwargs: Any - ) -> "_models.DeploymentExtended": + def get(self, resource_group_name: str, deployment_name: str, **kwargs: Any) -> _models.DeploymentExtended: """Gets a deployment. :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. :type resource_group_name: str - :param deployment_name: The name of the deployment. + :param deployment_name: The name of the deployment. Required. :type deployment_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: DeploymentExtended, or the result of cls(response) + :return: DeploymentExtended or the result of cls(response) :rtype: ~azure.mgmt.resource.resources.v2019_05_01.models.DeploymentExtended - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.DeploymentExtended"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + 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', "2019-05-01") # type: str + api_version = kwargs.pop("api_version", _params.pop("api-version", "2019-05-01")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[_models.DeploymentExtended] - request = build_deployments_get_request( resource_group_name=resource_group_name, deployment_name=deployment_name, subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.get.metadata['url'], + template_url=self.get.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) - deserialized = self._deserialize('DeploymentExtended', pipeline_response) + deserialized = self._deserialize("DeploymentExtended", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - get.metadata = {'url': "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/Microsoft.Resources/deployments/{deploymentName}"} # type: ignore - + get.metadata = {"url": "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/Microsoft.Resources/deployments/{deploymentName}"} # type: ignore @distributed_trace def cancel( # pylint: disable=inconsistent-return-statements - self, - resource_group_name: str, - deployment_name: str, - **kwargs: Any + self, resource_group_name: str, deployment_name: str, **kwargs: Any ) -> None: """Cancels a currently running template deployment. @@ -3957,38 +4045,45 @@ def cancel( # pylint: disable=inconsistent-return-statements partially deployed. :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. :type resource_group_name: str - :param deployment_name: The name of the deployment. + :param deployment_name: The name of the deployment. Required. :type deployment_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: None, or the result of cls(response) + :return: None or the result of cls(response) :rtype: None - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType[None] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) - api_version = kwargs.pop('api_version', "2019-05-01") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2019-05-01")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[None] - request = build_deployments_cancel_request( resource_group_name=resource_group_name, deployment_name=deployment_name, subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.cancel.metadata['url'], + template_url=self.cancel.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [204]: @@ -3998,42 +4093,110 @@ def cancel( # pylint: disable=inconsistent-return-statements if cls: return cls(pipeline_response, None, {}) - cancel.metadata = {'url': "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/Microsoft.Resources/deployments/{deploymentName}/cancel"} # type: ignore + cancel.metadata = {"url": "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/Microsoft.Resources/deployments/{deploymentName}/cancel"} # type: ignore - - @distributed_trace + @overload def validate( self, resource_group_name: str, deployment_name: str, - parameters: "_models.Deployment", + parameters: _models.Deployment, + *, + content_type: str = "application/json", **kwargs: Any - ) -> "_models.DeploymentValidateResult": + ) -> _models.DeploymentValidateResult: """Validates whether the specified template is syntactically correct and will be accepted by Azure Resource Manager.. :param resource_group_name: The name of the resource group the template will be deployed to. - The name is case insensitive. + The name is case insensitive. Required. :type resource_group_name: str - :param deployment_name: The name of the deployment. + :param deployment_name: The name of the deployment. Required. :type deployment_name: str - :param parameters: Parameters to validate. + :param parameters: Parameters to validate. Required. :type parameters: ~azure.mgmt.resource.resources.v2019_05_01.models.Deployment + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: DeploymentValidateResult or the result of cls(response) + :rtype: ~azure.mgmt.resource.resources.v2019_05_01.models.DeploymentValidateResult + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + def validate( + self, + resource_group_name: str, + deployment_name: str, + parameters: IO, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.DeploymentValidateResult: + """Validates whether the specified template is syntactically correct and will be accepted by Azure + Resource Manager.. + + :param resource_group_name: The name of the resource group the template will be deployed to. + The name is case insensitive. Required. + :type resource_group_name: str + :param deployment_name: The name of the deployment. Required. + :type deployment_name: str + :param parameters: Parameters to validate. Required. + :type parameters: IO + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: DeploymentValidateResult or the result of cls(response) + :rtype: ~azure.mgmt.resource.resources.v2019_05_01.models.DeploymentValidateResult + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace + def validate( + self, resource_group_name: str, deployment_name: str, parameters: Union[_models.Deployment, IO], **kwargs: Any + ) -> _models.DeploymentValidateResult: + """Validates whether the specified template is syntactically correct and will be accepted by Azure + Resource Manager.. + + :param resource_group_name: The name of the resource group the template will be deployed to. + The name is case insensitive. Required. + :type resource_group_name: str + :param deployment_name: The name of the deployment. Required. + :type deployment_name: str + :param parameters: Parameters to validate. Is either a model type or a IO type. Required. + :type parameters: ~azure.mgmt.resource.resources.v2019_05_01.models.Deployment or IO + :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. + Default value is None. + :paramtype content_type: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: DeploymentValidateResult, or the result of cls(response) + :return: DeploymentValidateResult or the result of cls(response) :rtype: ~azure.mgmt.resource.resources.v2019_05_01.models.DeploymentValidateResult - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.DeploymentValidateResult"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) - api_version = kwargs.pop('api_version', "2019-05-01") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - _json = self._serialize.body(parameters, 'Deployment') + api_version = kwargs.pop("api_version", _params.pop("api-version", "2019-05-01")) # type: str + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.DeploymentValidateResult] + + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(parameters, (IO, bytes)): + _content = parameters + else: + _json = self._serialize.body(parameters, "Deployment") request = build_deployments_validate_request( resource_group_name=resource_group_name, @@ -4042,16 +4205,18 @@ def validate( api_version=api_version, content_type=content_type, json=_json, - template_url=self.validate.metadata['url'], + content=_content, + template_url=self.validate.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200, 400]: @@ -4059,89 +4224,87 @@ def validate( raise HttpResponseError(response=response, error_format=ARMErrorFormat) if response.status_code == 200: - deserialized = self._deserialize('DeploymentValidateResult', pipeline_response) + deserialized = self._deserialize("DeploymentValidateResult", pipeline_response) if response.status_code == 400: - deserialized = self._deserialize('DeploymentValidateResult', pipeline_response) + deserialized = self._deserialize("DeploymentValidateResult", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - validate.metadata = {'url': "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/Microsoft.Resources/deployments/{deploymentName}/validate"} # type: ignore - + validate.metadata = {"url": "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/Microsoft.Resources/deployments/{deploymentName}/validate"} # type: ignore @distributed_trace def export_template( - self, - resource_group_name: str, - deployment_name: str, - **kwargs: Any - ) -> "_models.DeploymentExportResult": + self, resource_group_name: str, deployment_name: str, **kwargs: Any + ) -> _models.DeploymentExportResult: """Exports the template used for specified deployment. :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. :type resource_group_name: str - :param deployment_name: The name of the deployment. + :param deployment_name: The name of the deployment. Required. :type deployment_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: DeploymentExportResult, or the result of cls(response) + :return: DeploymentExportResult or the result of cls(response) :rtype: ~azure.mgmt.resource.resources.v2019_05_01.models.DeploymentExportResult - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.DeploymentExportResult"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + 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', "2019-05-01") # type: str + api_version = kwargs.pop("api_version", _params.pop("api-version", "2019-05-01")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[_models.DeploymentExportResult] - request = build_deployments_export_template_request( resource_group_name=resource_group_name, deployment_name=deployment_name, subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.export_template.metadata['url'], + template_url=self.export_template.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) - deserialized = self._deserialize('DeploymentExportResult', pipeline_response) + deserialized = self._deserialize("DeploymentExportResult", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - export_template.metadata = {'url': "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/Microsoft.Resources/deployments/{deploymentName}/exportTemplate"} # type: ignore - + export_template.metadata = {"url": "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/Microsoft.Resources/deployments/{deploymentName}/exportTemplate"} # type: ignore @distributed_trace def list_by_resource_group( - self, - resource_group_name: str, - filter: Optional[str] = None, - top: Optional[int] = None, - **kwargs: Any - ) -> Iterable["_models.DeploymentListResult"]: + self, resource_group_name: str, filter: Optional[str] = None, top: Optional[int] = None, **kwargs: Any + ) -> Iterable["_models.DeploymentExtended"]: """Get all the deployments for a resource group. :param resource_group_name: The name of the resource group with the deployments to get. The - name is case insensitive. + name is case insensitive. Required. :type resource_group_name: str :param filter: The filter to apply on the operation. For example, you can use $filter=provisioningState eq '{state}'. Default value is None. @@ -4150,42 +4313,49 @@ def list_by_resource_group( value is None. :type top: int :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either DeploymentListResult or the result of - cls(response) + :return: An iterator like instance of either DeploymentExtended or the result of cls(response) :rtype: - ~azure.core.paging.ItemPaged[~azure.mgmt.resource.resources.v2019_05_01.models.DeploymentListResult] - :raises: ~azure.core.exceptions.HttpResponseError + ~azure.core.paging.ItemPaged[~azure.mgmt.resource.resources.v2019_05_01.models.DeploymentExtended] + :raises ~azure.core.exceptions.HttpResponseError: """ - api_version = kwargs.pop('api_version', "2019-05-01") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2019-05-01")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[_models.DeploymentListResult] - cls = kwargs.pop('cls', None) # type: ClsType["_models.DeploymentListResult"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) + def prepare_request(next_link=None): if not next_link: - + request = build_deployments_list_by_resource_group_request( resource_group_name=resource_group_name, subscription_id=self._config.subscription_id, - api_version=api_version, filter=filter, top=top, - template_url=self.list_by_resource_group.metadata['url'], + 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.url = self._client.format_url(request.url) # type: ignore else: - - request = build_deployments_list_by_resource_group_request( - resource_group_name=resource_group_name, - subscription_id=self._config.subscription_id, - template_url=next_link, - ) + # make call to next link with the client's api-version + _parsed_next_link = urlparse(next_link) + _next_request_params = case_insensitive_dict(parse_qs(_parsed_next_link.query)) + _next_request_params["api-version"] = self._config.api_version + request = HttpRequest("GET", urljoin(next_link, _parsed_next_link.path), params=_next_request_params) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore request.method = "GET" return request @@ -4199,10 +4369,8 @@ def extract_data(pipeline_response): def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) response = pipeline_response.http_response @@ -4212,204 +4380,204 @@ def get_next(next_link=None): return pipeline_response + return ItemPaged(get_next, extract_data) - return ItemPaged( - get_next, extract_data - ) - list_by_resource_group.metadata = {'url': "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/Microsoft.Resources/deployments/"} # type: ignore + list_by_resource_group.metadata = {"url": "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/Microsoft.Resources/deployments/"} # type: ignore @distributed_trace - def calculate_template_hash( - self, - template: Any, - **kwargs: Any - ) -> "_models.TemplateHashResult": + def calculate_template_hash(self, template: JSON, **kwargs: Any) -> _models.TemplateHashResult: """Calculate the hash of the given template. - :param template: The template provided to calculate hash. - :type template: any + :param template: The template provided to calculate hash. Required. + :type template: JSON :keyword callable cls: A custom type or function that will be passed the direct response - :return: TemplateHashResult, or the result of cls(response) + :return: TemplateHashResult or the result of cls(response) :rtype: ~azure.mgmt.resource.resources.v2019_05_01.models.TemplateHashResult - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.TemplateHashResult"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', "2019-05-01") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + api_version = kwargs.pop("api_version", _params.pop("api-version", "2019-05-01")) # type: str + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", "application/json")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[_models.TemplateHashResult] - _json = self._serialize.body(template, 'object') + _json = self._serialize.body(template, "object") request = build_deployments_calculate_template_hash_request( api_version=api_version, content_type=content_type, json=_json, - template_url=self.calculate_template_hash.metadata['url'], + template_url=self.calculate_template_hash.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) - deserialized = self._deserialize('TemplateHashResult', pipeline_response) + deserialized = self._deserialize("TemplateHashResult", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - calculate_template_hash.metadata = {'url': "/providers/Microsoft.Resources/calculateTemplateHash"} # type: ignore + calculate_template_hash.metadata = {"url": "/providers/Microsoft.Resources/calculateTemplateHash"} # type: ignore -class ProvidersOperations(object): - """ProvidersOperations operations. - You should not instantiate this class directly. Instead, you should create a Client instance that - instantiates it for you and attaches it as an attribute. +class ProvidersOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. - :ivar models: Alias to model classes used in this operation group. - :type models: ~azure.mgmt.resource.resources.v2019_05_01.models - :param client: Client for service requests. - :param config: Configuration of service client. - :param serializer: An object model serializer. - :param deserializer: An object model deserializer. + Instead, you should access the following operations through + :class:`~azure.mgmt.resource.resources.v2019_05_01.ResourceManagementClient`'s + :attr:`providers` attribute. """ models = _models - def __init__(self, client, config, serializer, deserializer): - self._client = client - self._serialize = serializer - self._deserialize = deserializer - self._config = config + def __init__(self, *args, **kwargs): + input_args = list(args) + self._client = input_args.pop(0) if input_args else kwargs.pop("client") + self._config = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") @distributed_trace - def unregister( - self, - resource_provider_namespace: str, - **kwargs: Any - ) -> "_models.Provider": + def unregister(self, resource_provider_namespace: str, **kwargs: Any) -> _models.Provider: """Unregisters a subscription from a resource provider. :param resource_provider_namespace: The namespace of the resource provider to unregister. + Required. :type resource_provider_namespace: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: Provider, or the result of cls(response) + :return: Provider or the result of cls(response) :rtype: ~azure.mgmt.resource.resources.v2019_05_01.models.Provider - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.Provider"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + 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', "2019-05-01") # type: str + api_version = kwargs.pop("api_version", _params.pop("api-version", "2019-05-01")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[_models.Provider] - request = build_providers_unregister_request( resource_provider_namespace=resource_provider_namespace, subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.unregister.metadata['url'], + template_url=self.unregister.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) - deserialized = self._deserialize('Provider', pipeline_response) + deserialized = self._deserialize("Provider", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - unregister.metadata = {'url': "/subscriptions/{subscriptionId}/providers/{resourceProviderNamespace}/unregister"} # type: ignore - + unregister.metadata = {"url": "/subscriptions/{subscriptionId}/providers/{resourceProviderNamespace}/unregister"} # type: ignore @distributed_trace - def register( - self, - resource_provider_namespace: str, - **kwargs: Any - ) -> "_models.Provider": + def register(self, resource_provider_namespace: str, **kwargs: Any) -> _models.Provider: """Registers a subscription with a resource provider. :param resource_provider_namespace: The namespace of the resource provider to register. + Required. :type resource_provider_namespace: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: Provider, or the result of cls(response) + :return: Provider or the result of cls(response) :rtype: ~azure.mgmt.resource.resources.v2019_05_01.models.Provider - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.Provider"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + 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', "2019-05-01") # type: str + api_version = kwargs.pop("api_version", _params.pop("api-version", "2019-05-01")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[_models.Provider] - request = build_providers_register_request( resource_provider_namespace=resource_provider_namespace, subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.register.metadata['url'], + template_url=self.register.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) - deserialized = self._deserialize('Provider', pipeline_response) + deserialized = self._deserialize("Provider", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - register.metadata = {'url': "/subscriptions/{subscriptionId}/providers/{resourceProviderNamespace}/register"} # type: ignore - + register.metadata = {"url": "/subscriptions/{subscriptionId}/providers/{resourceProviderNamespace}/register"} # type: ignore @distributed_trace def list( - self, - top: Optional[int] = None, - expand: Optional[str] = None, - **kwargs: Any - ) -> Iterable["_models.ProviderListResult"]: + self, top: Optional[int] = None, expand: Optional[str] = None, **kwargs: Any + ) -> Iterable["_models.Provider"]: """Gets all resource providers for a subscription. :param top: The number of results to return. If null is passed returns all deployments. Default @@ -4420,39 +4588,48 @@ def list( response, use $expand=resourceTypes/aliases. Default value is None. :type expand: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either ProviderListResult or the result of cls(response) + :return: An iterator like instance of either Provider or the result of cls(response) :rtype: - ~azure.core.paging.ItemPaged[~azure.mgmt.resource.resources.v2019_05_01.models.ProviderListResult] - :raises: ~azure.core.exceptions.HttpResponseError + ~azure.core.paging.ItemPaged[~azure.mgmt.resource.resources.v2019_05_01.models.Provider] + :raises ~azure.core.exceptions.HttpResponseError: """ - api_version = kwargs.pop('api_version', "2019-05-01") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2019-05-01")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[_models.ProviderListResult] - cls = kwargs.pop('cls', None) # type: ClsType["_models.ProviderListResult"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) + def prepare_request(next_link=None): if not next_link: - + request = build_providers_list_request( subscription_id=self._config.subscription_id, - api_version=api_version, top=top, expand=expand, - template_url=self.list.metadata['url'], + 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.url = self._client.format_url(request.url) # type: ignore else: - - request = build_providers_list_request( - subscription_id=self._config.subscription_id, - template_url=next_link, - ) + # make call to next link with the client's api-version + _parsed_next_link = urlparse(next_link) + _next_request_params = case_insensitive_dict(parse_qs(_parsed_next_link.query)) + _next_request_params["api-version"] = self._config.api_version + request = HttpRequest("GET", urljoin(next_link, _parsed_next_link.path), params=_next_request_params) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore request.method = "GET" return request @@ -4466,10 +4643,8 @@ def extract_data(pipeline_response): def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) response = pipeline_response.http_response @@ -4479,91 +4654,88 @@ def get_next(next_link=None): return pipeline_response + return ItemPaged(get_next, extract_data) - return ItemPaged( - get_next, extract_data - ) - list.metadata = {'url': "/subscriptions/{subscriptionId}/providers"} # type: ignore + list.metadata = {"url": "/subscriptions/{subscriptionId}/providers"} # type: ignore @distributed_trace - def get( - self, - resource_provider_namespace: str, - expand: Optional[str] = None, - **kwargs: Any - ) -> "_models.Provider": + def get(self, resource_provider_namespace: str, expand: Optional[str] = None, **kwargs: Any) -> _models.Provider: """Gets the specified resource provider. - :param resource_provider_namespace: The namespace of the resource provider. + :param resource_provider_namespace: The namespace of the resource provider. Required. :type resource_provider_namespace: str :param expand: The $expand query parameter. For example, to include property aliases in response, use $expand=resourceTypes/aliases. Default value is None. :type expand: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: Provider, or the result of cls(response) + :return: Provider or the result of cls(response) :rtype: ~azure.mgmt.resource.resources.v2019_05_01.models.Provider - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.Provider"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + 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', "2019-05-01") # type: str + api_version = kwargs.pop("api_version", _params.pop("api-version", "2019-05-01")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[_models.Provider] - request = build_providers_get_request( resource_provider_namespace=resource_provider_namespace, subscription_id=self._config.subscription_id, - api_version=api_version, expand=expand, - template_url=self.get.metadata['url'], + api_version=api_version, + template_url=self.get.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) - deserialized = self._deserialize('Provider', pipeline_response) + deserialized = self._deserialize("Provider", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - get.metadata = {'url': "/subscriptions/{subscriptionId}/providers/{resourceProviderNamespace}"} # type: ignore + get.metadata = {"url": "/subscriptions/{subscriptionId}/providers/{resourceProviderNamespace}"} # type: ignore -class ResourcesOperations(object): # pylint: disable=too-many-public-methods - """ResourcesOperations operations. - You should not instantiate this class directly. Instead, you should create a Client instance that - instantiates it for you and attaches it as an attribute. +class ResourcesOperations: # pylint: disable=too-many-public-methods + """ + .. warning:: + **DO NOT** instantiate this class directly. - :ivar models: Alias to model classes used in this operation group. - :type models: ~azure.mgmt.resource.resources.v2019_05_01.models - :param client: Client for service requests. - :param config: Configuration of service client. - :param serializer: An object model serializer. - :param deserializer: An object model deserializer. + Instead, you should access the following operations through + :class:`~azure.mgmt.resource.resources.v2019_05_01.ResourceManagementClient`'s + :attr:`resources` attribute. """ models = _models - def __init__(self, client, config, serializer, deserializer): - self._client = client - self._serialize = serializer - self._deserialize = deserializer - self._config = config + def __init__(self, *args, **kwargs): + input_args = list(args) + self._client = input_args.pop(0) if input_args else kwargs.pop("client") + self._config = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") @distributed_trace def list_by_resource_group( @@ -4573,10 +4745,10 @@ def list_by_resource_group( expand: Optional[str] = None, top: Optional[int] = None, **kwargs: Any - ) -> Iterable["_models.ResourceListResult"]: + ) -> Iterable["_models.GenericResourceExpanded"]: """Get all the resources for a resource group. - :param resource_group_name: The resource group with the resources to get. + :param resource_group_name: The resource group with the resources to get. Required. :type resource_group_name: str :param filter: The filter to apply on the operation.:code:`
`:code:`
`The properties you can use for eq (equals) or ne (not equals) are: location, resourceType, name, resourceGroup, @@ -4601,42 +4773,51 @@ def list_by_resource_group( value is None. :type top: int :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either ResourceListResult or the result of cls(response) + :return: An iterator like instance of either GenericResourceExpanded or the result of + cls(response) :rtype: - ~azure.core.paging.ItemPaged[~azure.mgmt.resource.resources.v2019_05_01.models.ResourceListResult] - :raises: ~azure.core.exceptions.HttpResponseError + ~azure.core.paging.ItemPaged[~azure.mgmt.resource.resources.v2019_05_01.models.GenericResourceExpanded] + :raises ~azure.core.exceptions.HttpResponseError: """ - api_version = kwargs.pop('api_version', "2019-05-01") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2019-05-01")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[_models.ResourceListResult] - cls = kwargs.pop('cls', None) # type: ClsType["_models.ResourceListResult"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) + def prepare_request(next_link=None): if not next_link: - + request = build_resources_list_by_resource_group_request( resource_group_name=resource_group_name, subscription_id=self._config.subscription_id, - api_version=api_version, filter=filter, expand=expand, top=top, - template_url=self.list_by_resource_group.metadata['url'], + 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.url = self._client.format_url(request.url) # type: ignore else: - - request = build_resources_list_by_resource_group_request( - resource_group_name=resource_group_name, - subscription_id=self._config.subscription_id, - template_url=next_link, - ) + # make call to next link with the client's api-version + _parsed_next_link = urlparse(next_link) + _next_request_params = case_insensitive_dict(parse_qs(_parsed_next_link.query)) + _next_request_params["api-version"] = self._config.api_version + request = HttpRequest("GET", urljoin(next_link, _parsed_next_link.path), params=_next_request_params) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore request.method = "GET" return request @@ -4650,10 +4831,8 @@ def extract_data(pipeline_response): def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) response = pipeline_response.http_response @@ -4663,45 +4842,54 @@ def get_next(next_link=None): return pipeline_response + return ItemPaged(get_next, extract_data) - return ItemPaged( - get_next, extract_data - ) - list_by_resource_group.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/resources"} # type: ignore + list_by_resource_group.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/resources"} # type: ignore def _move_resources_initial( # pylint: disable=inconsistent-return-statements - self, - source_resource_group_name: str, - parameters: "_models.ResourcesMoveInfo", - **kwargs: Any + self, source_resource_group_name: str, parameters: Union[_models.ResourcesMoveInfo, IO], **kwargs: Any ) -> None: - cls = kwargs.pop('cls', None) # type: ClsType[None] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', "2019-05-01") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + api_version = kwargs.pop("api_version", _params.pop("api-version", "2019-05-01")) # type: str + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[None] - _json = self._serialize.body(parameters, 'ResourcesMoveInfo') + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(parameters, (IO, bytes)): + _content = parameters + else: + _json = self._serialize.body(parameters, "ResourcesMoveInfo") - request = build_resources_move_resources_request_initial( + request = build_resources_move_resources_request( source_resource_group_name=source_resource_group_name, subscription_id=self._config.subscription_id, api_version=api_version, content_type=content_type, json=_json, - template_url=self._move_resources_initial.metadata['url'], + content=_content, + template_url=self._move_resources_initial.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [202, 204]: @@ -4711,14 +4899,15 @@ def _move_resources_initial( # pylint: disable=inconsistent-return-statements if cls: return cls(pipeline_response, None, {}) - _move_resources_initial.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{sourceResourceGroupName}/moveResources"} # type: ignore - + _move_resources_initial.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{sourceResourceGroupName}/moveResources"} # type: ignore - @distributed_trace - def begin_move_resources( # pylint: disable=inconsistent-return-statements + @overload + def begin_move_resources( self, source_resource_group_name: str, - parameters: "_models.ResourcesMoveInfo", + parameters: _models.ResourcesMoveInfo, + *, + content_type: str = "application/json", **kwargs: Any ) -> LROPoller[None]: """Moves resources from one resource group to another resource group. @@ -4729,10 +4918,13 @@ def begin_move_resources( # pylint: disable=inconsistent-return-statements the groups until the move completes. :param source_resource_group_name: The name of the resource group containing the resources to - move. + move. Required. :type source_resource_group_name: str - :param parameters: Parameters for moving resources. + :param parameters: Parameters for moving resources. Required. :type parameters: ~azure.mgmt.resource.resources.v2019_05_01.models.ResourcesMoveInfo + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str :keyword callable cls: A custom type or function that will be passed the direct response :keyword str continuation_token: A continuation token to restart a poller from a saved state. :keyword polling: By default, your polling method will be ARMPolling. Pass in False for this @@ -4743,80 +4935,160 @@ def begin_move_resources( # pylint: disable=inconsistent-return-statements Retry-After header is present. :return: An instance of LROPoller that returns either None or the result of cls(response) :rtype: ~azure.core.polling.LROPoller[None] - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - api_version = kwargs.pop('api_version', "2019-05-01") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] - polling = kwargs.pop('polling', True) # type: Union[bool, PollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType[None] - lro_delay = kwargs.pop( - 'polling_interval', - self._config.polling_interval - ) - cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] + + @overload + def begin_move_resources( + self, source_resource_group_name: str, parameters: IO, *, content_type: str = "application/json", **kwargs: Any + ) -> LROPoller[None]: + """Moves resources from one resource group to another resource group. + + The resources to move must be in the same source resource group. The target resource group may + be in a different subscription. When moving resources, both the source group and the target + group are locked for the duration of the operation. Write and delete operations are blocked on + the groups until the move completes. + + :param source_resource_group_name: The name of the resource group containing the resources to + move. Required. + :type source_resource_group_name: str + :param parameters: Parameters for moving resources. Required. + :type parameters: IO + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be ARMPolling. Pass in False for this + operation to not poll, or pass in your own initialized polling object for a personal polling + strategy. + :paramtype polling: bool or ~azure.core.polling.PollingMethod + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of LROPoller that returns either None or the result of cls(response) + :rtype: ~azure.core.polling.LROPoller[None] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace + def begin_move_resources( + self, source_resource_group_name: str, parameters: Union[_models.ResourcesMoveInfo, IO], **kwargs: Any + ) -> LROPoller[None]: + """Moves resources from one resource group to another resource group. + + The resources to move must be in the same source resource group. The target resource group may + be in a different subscription. When moving resources, both the source group and the target + group are locked for the duration of the operation. Write and delete operations are blocked on + the groups until the move completes. + + :param source_resource_group_name: The name of the resource group containing the resources to + move. Required. + :type source_resource_group_name: str + :param parameters: Parameters for moving resources. Is either a model type or a IO type. + Required. + :type parameters: ~azure.mgmt.resource.resources.v2019_05_01.models.ResourcesMoveInfo or IO + :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. + Default value is None. + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be ARMPolling. Pass in False for this + operation to not poll, or pass in your own initialized polling object for a personal polling + strategy. + :paramtype polling: bool or ~azure.core.polling.PollingMethod + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of LROPoller that returns either None or the result of cls(response) + :rtype: ~azure.core.polling.LROPoller[None] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _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", "2019-05-01")) # type: str + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[None] + polling = kwargs.pop("polling", True) # type: Union[bool, PollingMethod] + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token = kwargs.pop("continuation_token", None) # type: Optional[str] if cont_token is None: - raw_result = self._move_resources_initial( + raw_result = self._move_resources_initial( # type: ignore source_resource_group_name=source_resource_group_name, parameters=parameters, api_version=api_version, content_type=content_type, - cls=lambda x,y,z: x, + cls=lambda x, y, z: x, + headers=_headers, + params=_params, **kwargs ) - kwargs.pop('error_map', None) + kwargs.pop("error_map", None) - def get_long_running_output(pipeline_response): + def get_long_running_output(pipeline_response): # pylint: disable=inconsistent-return-statements if cls: return cls(pipeline_response, None, {}) - - if polling is True: polling_method = ARMPolling(lro_delay, **kwargs) - elif polling is False: polling_method = NoPolling() - else: polling_method = polling + if polling is True: + polling_method = cast(PollingMethod, ARMPolling(lro_delay, **kwargs)) # type: PollingMethod + elif polling is False: + polling_method = cast(PollingMethod, NoPolling()) + else: + polling_method = polling if cont_token: return LROPoller.from_continuation_token( polling_method=polling_method, continuation_token=cont_token, client=self._client, - deserialization_callback=get_long_running_output + deserialization_callback=get_long_running_output, ) return LROPoller(self._client, raw_result, get_long_running_output, polling_method) - begin_move_resources.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{sourceResourceGroupName}/moveResources"} # type: ignore + begin_move_resources.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{sourceResourceGroupName}/moveResources"} # type: ignore def _validate_move_resources_initial( # pylint: disable=inconsistent-return-statements - self, - source_resource_group_name: str, - parameters: "_models.ResourcesMoveInfo", - **kwargs: Any + self, source_resource_group_name: str, parameters: Union[_models.ResourcesMoveInfo, IO], **kwargs: Any ) -> None: - cls = kwargs.pop('cls', None) # type: ClsType[None] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', "2019-05-01") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + api_version = kwargs.pop("api_version", _params.pop("api-version", "2019-05-01")) # type: str + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[None] - _json = self._serialize.body(parameters, 'ResourcesMoveInfo') + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(parameters, (IO, bytes)): + _content = parameters + else: + _json = self._serialize.body(parameters, "ResourcesMoveInfo") - request = build_resources_validate_move_resources_request_initial( + request = build_resources_validate_move_resources_request( source_resource_group_name=source_resource_group_name, subscription_id=self._config.subscription_id, api_version=api_version, content_type=content_type, json=_json, - template_url=self._validate_move_resources_initial.metadata['url'], + content=_content, + template_url=self._validate_move_resources_initial.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [202, 204, 409]: @@ -4826,14 +5098,15 @@ def _validate_move_resources_initial( # pylint: disable=inconsistent-return-sta if cls: return cls(pipeline_response, None, {}) - _validate_move_resources_initial.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{sourceResourceGroupName}/validateMoveResources"} # type: ignore - + _validate_move_resources_initial.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{sourceResourceGroupName}/validateMoveResources"} # type: ignore - @distributed_trace - def begin_validate_move_resources( # pylint: disable=inconsistent-return-statements + @overload + def begin_validate_move_resources( self, source_resource_group_name: str, - parameters: "_models.ResourcesMoveInfo", + parameters: _models.ResourcesMoveInfo, + *, + content_type: str = "application/json", **kwargs: Any ) -> LROPoller[None]: """Validates whether resources can be moved from one resource group to another resource group. @@ -4846,10 +5119,13 @@ def begin_validate_move_resources( # pylint: disable=inconsistent-return-statem operation. :param source_resource_group_name: The name of the resource group containing the resources to - validate for move. + validate for move. Required. :type source_resource_group_name: str - :param parameters: Parameters for moving resources. + :param parameters: Parameters for moving resources. Required. :type parameters: ~azure.mgmt.resource.resources.v2019_05_01.models.ResourcesMoveInfo + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str :keyword callable cls: A custom type or function that will be passed the direct response :keyword str continuation_token: A continuation token to restart a poller from a saved state. :keyword polling: By default, your polling method will be ARMPolling. Pass in False for this @@ -4860,55 +5136,124 @@ def begin_validate_move_resources( # pylint: disable=inconsistent-return-statem Retry-After header is present. :return: An instance of LROPoller that returns either None or the result of cls(response) :rtype: ~azure.core.polling.LROPoller[None] - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - api_version = kwargs.pop('api_version', "2019-05-01") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] - polling = kwargs.pop('polling', True) # type: Union[bool, PollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType[None] - lro_delay = kwargs.pop( - 'polling_interval', - self._config.polling_interval - ) - cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] + + @overload + def begin_validate_move_resources( + self, source_resource_group_name: str, parameters: IO, *, content_type: str = "application/json", **kwargs: Any + ) -> LROPoller[None]: + """Validates whether resources can be moved from one resource group to another resource group. + + This operation checks whether the specified resources can be moved to the target. The resources + to move must be in the same source resource group. The target resource group may be in a + different subscription. If validation succeeds, it returns HTTP response code 204 (no content). + If validation fails, it returns HTTP response code 409 (Conflict) with an error message. + Retrieve the URL in the Location header value to check the result of the long-running + operation. + + :param source_resource_group_name: The name of the resource group containing the resources to + validate for move. Required. + :type source_resource_group_name: str + :param parameters: Parameters for moving resources. Required. + :type parameters: IO + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be ARMPolling. Pass in False for this + operation to not poll, or pass in your own initialized polling object for a personal polling + strategy. + :paramtype polling: bool or ~azure.core.polling.PollingMethod + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of LROPoller that returns either None or the result of cls(response) + :rtype: ~azure.core.polling.LROPoller[None] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace + def begin_validate_move_resources( + self, source_resource_group_name: str, parameters: Union[_models.ResourcesMoveInfo, IO], **kwargs: Any + ) -> LROPoller[None]: + """Validates whether resources can be moved from one resource group to another resource group. + + This operation checks whether the specified resources can be moved to the target. The resources + to move must be in the same source resource group. The target resource group may be in a + different subscription. If validation succeeds, it returns HTTP response code 204 (no content). + If validation fails, it returns HTTP response code 409 (Conflict) with an error message. + Retrieve the URL in the Location header value to check the result of the long-running + operation. + + :param source_resource_group_name: The name of the resource group containing the resources to + validate for move. Required. + :type source_resource_group_name: str + :param parameters: Parameters for moving resources. Is either a model type or a IO type. + Required. + :type parameters: ~azure.mgmt.resource.resources.v2019_05_01.models.ResourcesMoveInfo or IO + :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. + Default value is None. + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be ARMPolling. Pass in False for this + operation to not poll, or pass in your own initialized polling object for a personal polling + strategy. + :paramtype polling: bool or ~azure.core.polling.PollingMethod + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of LROPoller that returns either None or the result of cls(response) + :rtype: ~azure.core.polling.LROPoller[None] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _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", "2019-05-01")) # type: str + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[None] + polling = kwargs.pop("polling", True) # type: Union[bool, PollingMethod] + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token = kwargs.pop("continuation_token", None) # type: Optional[str] if cont_token is None: - raw_result = self._validate_move_resources_initial( + raw_result = self._validate_move_resources_initial( # type: ignore source_resource_group_name=source_resource_group_name, parameters=parameters, api_version=api_version, content_type=content_type, - cls=lambda x,y,z: x, + cls=lambda x, y, z: x, + headers=_headers, + params=_params, **kwargs ) - kwargs.pop('error_map', None) + kwargs.pop("error_map", None) - def get_long_running_output(pipeline_response): + def get_long_running_output(pipeline_response): # pylint: disable=inconsistent-return-statements if cls: return cls(pipeline_response, None, {}) - - if polling is True: polling_method = ARMPolling(lro_delay, **kwargs) - elif polling is False: polling_method = NoPolling() - else: polling_method = polling + if polling is True: + polling_method = cast(PollingMethod, ARMPolling(lro_delay, **kwargs)) # type: PollingMethod + elif polling is False: + polling_method = cast(PollingMethod, NoPolling()) + else: + polling_method = polling if cont_token: return LROPoller.from_continuation_token( polling_method=polling_method, continuation_token=cont_token, client=self._client, - deserialization_callback=get_long_running_output + deserialization_callback=get_long_running_output, ) return LROPoller(self._client, raw_result, get_long_running_output, polling_method) - begin_validate_move_resources.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{sourceResourceGroupName}/validateMoveResources"} # type: ignore + begin_validate_move_resources.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{sourceResourceGroupName}/validateMoveResources"} # type: ignore @distributed_trace def list( - self, - filter: Optional[str] = None, - expand: Optional[str] = None, - top: Optional[int] = None, - **kwargs: Any - ) -> Iterable["_models.ResourceListResult"]: + self, filter: Optional[str] = None, expand: Optional[str] = None, top: Optional[int] = None, **kwargs: Any + ) -> Iterable["_models.GenericResourceExpanded"]: """Get all the resources in a subscription. :param filter: The filter to apply on the operation.:code:`
`:code:`
`The properties you @@ -4934,40 +5279,50 @@ def list( value is None. :type top: int :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either ResourceListResult or the result of cls(response) + :return: An iterator like instance of either GenericResourceExpanded or the result of + cls(response) :rtype: - ~azure.core.paging.ItemPaged[~azure.mgmt.resource.resources.v2019_05_01.models.ResourceListResult] - :raises: ~azure.core.exceptions.HttpResponseError + ~azure.core.paging.ItemPaged[~azure.mgmt.resource.resources.v2019_05_01.models.GenericResourceExpanded] + :raises ~azure.core.exceptions.HttpResponseError: """ - api_version = kwargs.pop('api_version', "2019-05-01") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2019-05-01")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[_models.ResourceListResult] - cls = kwargs.pop('cls', None) # type: ClsType["_models.ResourceListResult"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) + def prepare_request(next_link=None): if not next_link: - + request = build_resources_list_request( subscription_id=self._config.subscription_id, - api_version=api_version, filter=filter, expand=expand, top=top, - template_url=self.list.metadata['url'], + 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.url = self._client.format_url(request.url) # type: ignore else: - - request = build_resources_list_request( - subscription_id=self._config.subscription_id, - template_url=next_link, - ) + # make call to next link with the client's api-version + _parsed_next_link = urlparse(next_link) + _next_request_params = case_insensitive_dict(parse_qs(_parsed_next_link.query)) + _next_request_params["api-version"] = self._config.api_version + request = HttpRequest("GET", urljoin(next_link, _parsed_next_link.path), params=_next_request_params) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore request.method = "GET" return request @@ -4981,10 +5336,8 @@ def extract_data(pipeline_response): def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) response = pipeline_response.http_response @@ -4994,11 +5347,9 @@ def get_next(next_link=None): return pipeline_response + return ItemPaged(get_next, extract_data) - return ItemPaged( - get_next, extract_data - ) - list.metadata = {'url': "/subscriptions/{subscriptionId}/resources"} # type: ignore + list.metadata = {"url": "/subscriptions/{subscriptionId}/resources"} # type: ignore @distributed_trace def check_existence( @@ -5014,30 +5365,36 @@ def check_existence( """Checks whether a resource exists. :param resource_group_name: The name of the resource group containing the resource to check. - The name is case insensitive. + The name is case insensitive. Required. :type resource_group_name: str - :param resource_provider_namespace: The resource provider of the resource to check. + :param resource_provider_namespace: The resource provider of the resource to check. Required. :type resource_provider_namespace: str - :param parent_resource_path: The parent resource identity. + :param parent_resource_path: The parent resource identity. Required. :type parent_resource_path: str - :param resource_type: The resource type. + :param resource_type: The resource type. Required. :type resource_type: str - :param resource_name: The name of the resource to check whether it exists. + :param resource_name: The name of the resource to check whether it exists. Required. :type resource_name: str - :param api_version: The API version to use for the operation. + :param api_version: The API version to use for the operation. Required. :type api_version: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: bool, or the result of cls(response) + :return: bool or the result of cls(response) :rtype: bool - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType[None] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = kwargs.pop("params", {}) or {} + + cls = kwargs.pop("cls", None) # type: ClsType[None] - request = build_resources_check_existence_request( resource_group_name=resource_group_name, resource_provider_namespace=resource_provider_namespace, @@ -5046,16 +5403,17 @@ def check_existence( resource_name=resource_name, subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.check_existence.metadata['url'], + template_url=self.check_existence.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [204, 404]: @@ -5066,8 +5424,7 @@ def check_existence( return cls(pipeline_response, None, {}) return 200 <= response.status_code <= 299 - check_existence.metadata = {'url': "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{parentResourcePath}/{resourceType}/{resourceName}"} # type: ignore - + check_existence.metadata = {"url": "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{parentResourcePath}/{resourceType}/{resourceName}"} # type: ignore def _delete_initial( # pylint: disable=inconsistent-return-statements self, @@ -5079,14 +5436,20 @@ def _delete_initial( # pylint: disable=inconsistent-return-statements api_version: str, **kwargs: Any ) -> None: - cls = kwargs.pop('cls', None) # type: ClsType[None] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = kwargs.pop("params", {}) or {} + + cls = kwargs.pop("cls", None) # type: ClsType[None] - - request = build_resources_delete_request_initial( + request = build_resources_delete_request( resource_group_name=resource_group_name, resource_provider_namespace=resource_provider_namespace, parent_resource_path=parent_resource_path, @@ -5094,16 +5457,17 @@ def _delete_initial( # pylint: disable=inconsistent-return-statements resource_name=resource_name, subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self._delete_initial.metadata['url'], + template_url=self._delete_initial.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200, 202, 204]: @@ -5113,11 +5477,10 @@ def _delete_initial( # pylint: disable=inconsistent-return-statements if cls: return cls(pipeline_response, None, {}) - _delete_initial.metadata = {'url': "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{parentResourcePath}/{resourceType}/{resourceName}"} # type: ignore - + _delete_initial.metadata = {"url": "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{parentResourcePath}/{resourceType}/{resourceName}"} # type: ignore @distributed_trace - def begin_delete( # pylint: disable=inconsistent-return-statements + def begin_delete( self, resource_group_name: str, resource_provider_namespace: str, @@ -5130,17 +5493,17 @@ def begin_delete( # pylint: disable=inconsistent-return-statements """Deletes a resource. :param resource_group_name: The name of the resource group that contains the resource to - delete. The name is case insensitive. + delete. The name is case insensitive. Required. :type resource_group_name: str - :param resource_provider_namespace: The namespace of the resource provider. + :param resource_provider_namespace: The namespace of the resource provider. Required. :type resource_provider_namespace: str - :param parent_resource_path: The parent resource identity. + :param parent_resource_path: The parent resource identity. Required. :type parent_resource_path: str - :param resource_type: The resource type. + :param resource_type: The resource type. Required. :type resource_type: str - :param resource_name: The name of the resource to delete. + :param resource_name: The name of the resource to delete. Required. :type resource_name: str - :param api_version: The API version to use for the operation. + :param api_version: The API version to use for the operation. Required. :type api_version: str :keyword callable cls: A custom type or function that will be passed the direct response :keyword str continuation_token: A continuation token to restart a poller from a saved state. @@ -5152,46 +5515,50 @@ def begin_delete( # pylint: disable=inconsistent-return-statements Retry-After header is present. :return: An instance of LROPoller that returns either None or the result of cls(response) :rtype: ~azure.core.polling.LROPoller[None] - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - polling = kwargs.pop('polling', True) # type: Union[bool, PollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType[None] - lro_delay = kwargs.pop( - 'polling_interval', - self._config.polling_interval - ) - cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] + _headers = kwargs.pop("headers", {}) or {} + _params = kwargs.pop("params", {}) or {} + + cls = kwargs.pop("cls", None) # type: ClsType[None] + polling = kwargs.pop("polling", True) # type: Union[bool, PollingMethod] + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token = kwargs.pop("continuation_token", None) # type: Optional[str] if cont_token is None: - raw_result = self._delete_initial( + raw_result = self._delete_initial( # type: ignore resource_group_name=resource_group_name, resource_provider_namespace=resource_provider_namespace, parent_resource_path=parent_resource_path, resource_type=resource_type, resource_name=resource_name, api_version=api_version, - cls=lambda x,y,z: x, + cls=lambda x, y, z: x, + headers=_headers, + params=_params, **kwargs ) - kwargs.pop('error_map', None) + kwargs.pop("error_map", None) - def get_long_running_output(pipeline_response): + def get_long_running_output(pipeline_response): # pylint: disable=inconsistent-return-statements if cls: return cls(pipeline_response, None, {}) - - if polling is True: polling_method = ARMPolling(lro_delay, **kwargs) - elif polling is False: polling_method = NoPolling() - else: polling_method = polling + if polling is True: + polling_method = cast(PollingMethod, ARMPolling(lro_delay, **kwargs)) # type: PollingMethod + elif polling is False: + polling_method = cast(PollingMethod, NoPolling()) + else: + polling_method = polling if cont_token: return LROPoller.from_continuation_token( polling_method=polling_method, continuation_token=cont_token, client=self._client, - deserialization_callback=get_long_running_output + deserialization_callback=get_long_running_output, ) return LROPoller(self._client, raw_result, get_long_running_output, polling_method) - begin_delete.metadata = {'url': "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{parentResourcePath}/{resourceType}/{resourceName}"} # type: ignore + begin_delete.metadata = {"url": "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{parentResourcePath}/{resourceType}/{resourceName}"} # type: ignore def _create_or_update_initial( self, @@ -5201,39 +5568,53 @@ def _create_or_update_initial( resource_type: str, resource_name: str, api_version: str, - parameters: "_models.GenericResource", + parameters: Union[_models.GenericResource, IO], **kwargs: Any - ) -> Optional["_models.GenericResource"]: - cls = kwargs.pop('cls', None) # type: ClsType[Optional["_models.GenericResource"]] + ) -> Optional[_models.GenericResource]: error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = kwargs.pop("params", {}) or {} - _json = self._serialize.body(parameters, 'GenericResource') + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[Optional[_models.GenericResource]] - request = build_resources_create_or_update_request_initial( + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(parameters, (IO, bytes)): + _content = parameters + else: + _json = self._serialize.body(parameters, "GenericResource") + + request = build_resources_create_or_update_request( resource_group_name=resource_group_name, resource_provider_namespace=resource_provider_namespace, parent_resource_path=parent_resource_path, resource_type=resource_type, resource_name=resource_name, subscription_id=self._config.subscription_id, - content_type=content_type, api_version=api_version, + content_type=content_type, json=_json, - template_url=self._create_or_update_initial.metadata['url'], + content=_content, + template_url=self._create_or_update_initial.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200, 201, 202]: @@ -5242,20 +5623,19 @@ def _create_or_update_initial( deserialized = None if response.status_code == 200: - deserialized = self._deserialize('GenericResource', pipeline_response) + deserialized = self._deserialize("GenericResource", pipeline_response) if response.status_code == 201: - deserialized = self._deserialize('GenericResource', pipeline_response) + deserialized = self._deserialize("GenericResource", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - _create_or_update_initial.metadata = {'url': "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{parentResourcePath}/{resourceType}/{resourceName}"} # type: ignore + _create_or_update_initial.metadata = {"url": "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{parentResourcePath}/{resourceType}/{resourceName}"} # type: ignore - - @distributed_trace + @overload def begin_create_or_update( self, resource_group_name: str, @@ -5264,26 +5644,31 @@ def begin_create_or_update( resource_type: str, resource_name: str, api_version: str, - parameters: "_models.GenericResource", + parameters: _models.GenericResource, + *, + content_type: str = "application/json", **kwargs: Any - ) -> LROPoller["_models.GenericResource"]: + ) -> LROPoller[_models.GenericResource]: """Creates a resource. :param resource_group_name: The name of the resource group for the resource. The name is case - insensitive. + insensitive. Required. :type resource_group_name: str - :param resource_provider_namespace: The namespace of the resource provider. + :param resource_provider_namespace: The namespace of the resource provider. Required. :type resource_provider_namespace: str - :param parent_resource_path: The parent resource identity. + :param parent_resource_path: The parent resource identity. Required. :type parent_resource_path: str - :param resource_type: The resource type of the resource to create. + :param resource_type: The resource type of the resource to create. Required. :type resource_type: str - :param resource_name: The name of the resource to create. + :param resource_name: The name of the resource to create. Required. :type resource_name: str - :param api_version: The API version to use for the operation. + :param api_version: The API version to use for the operation. Required. :type api_version: str - :param parameters: Parameters for creating or updating the resource. + :param parameters: Parameters for creating or updating the resource. Required. :type parameters: ~azure.mgmt.resource.resources.v2019_05_01.models.GenericResource + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str :keyword callable cls: A custom type or function that will be passed the direct response :keyword str continuation_token: A continuation token to restart a poller from a saved state. :keyword polling: By default, your polling method will be ARMPolling. Pass in False for this @@ -5296,52 +5681,152 @@ def begin_create_or_update( cls(response) :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.resource.resources.v2019_05_01.models.GenericResource] - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] - polling = kwargs.pop('polling', True) # type: Union[bool, PollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType["_models.GenericResource"] - lro_delay = kwargs.pop( - 'polling_interval', - self._config.polling_interval - ) - cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] - if cont_token is None: - raw_result = self._create_or_update_initial( - resource_group_name=resource_group_name, - resource_provider_namespace=resource_provider_namespace, - parent_resource_path=parent_resource_path, - resource_type=resource_type, - resource_name=resource_name, - api_version=api_version, - parameters=parameters, - content_type=content_type, - cls=lambda x,y,z: x, - **kwargs - ) - kwargs.pop('error_map', None) - - def get_long_running_output(pipeline_response): - response = pipeline_response.http_response - deserialized = self._deserialize('GenericResource', pipeline_response) - if cls: - return cls(pipeline_response, deserialized, {}) - return deserialized + @overload + def begin_create_or_update( + self, + resource_group_name: str, + resource_provider_namespace: str, + parent_resource_path: str, + resource_type: str, + resource_name: str, + api_version: str, + parameters: IO, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> LROPoller[_models.GenericResource]: + """Creates a resource. - if polling is True: polling_method = ARMPolling(lro_delay, **kwargs) - elif polling is False: polling_method = NoPolling() - else: polling_method = polling + :param resource_group_name: The name of the resource group for the resource. The name is case + insensitive. Required. + :type resource_group_name: str + :param resource_provider_namespace: The namespace of the resource provider. Required. + :type resource_provider_namespace: str + :param parent_resource_path: The parent resource identity. Required. + :type parent_resource_path: str + :param resource_type: The resource type of the resource to create. Required. + :type resource_type: str + :param resource_name: The name of the resource to create. Required. + :type resource_name: str + :param api_version: The API version to use for the operation. Required. + :type api_version: str + :param parameters: Parameters for creating or updating the resource. Required. + :type parameters: IO + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be ARMPolling. Pass in False for this + operation to not poll, or pass in your own initialized polling object for a personal polling + strategy. + :paramtype polling: bool or ~azure.core.polling.PollingMethod + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of LROPoller that returns either GenericResource or the result of + cls(response) + :rtype: + ~azure.core.polling.LROPoller[~azure.mgmt.resource.resources.v2019_05_01.models.GenericResource] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace + def begin_create_or_update( + self, + resource_group_name: str, + resource_provider_namespace: str, + parent_resource_path: str, + resource_type: str, + resource_name: str, + api_version: str, + parameters: Union[_models.GenericResource, IO], + **kwargs: Any + ) -> LROPoller[_models.GenericResource]: + """Creates a resource. + + :param resource_group_name: The name of the resource group for the resource. The name is case + insensitive. Required. + :type resource_group_name: str + :param resource_provider_namespace: The namespace of the resource provider. Required. + :type resource_provider_namespace: str + :param parent_resource_path: The parent resource identity. Required. + :type parent_resource_path: str + :param resource_type: The resource type of the resource to create. Required. + :type resource_type: str + :param resource_name: The name of the resource to create. Required. + :type resource_name: str + :param api_version: The API version to use for the operation. Required. + :type api_version: str + :param parameters: Parameters for creating or updating the resource. Is either a model type or + a IO type. Required. + :type parameters: ~azure.mgmt.resource.resources.v2019_05_01.models.GenericResource or IO + :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. + Default value is None. + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be ARMPolling. Pass in False for this + operation to not poll, or pass in your own initialized polling object for a personal polling + strategy. + :paramtype polling: bool or ~azure.core.polling.PollingMethod + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of LROPoller that returns either GenericResource or the result of + cls(response) + :rtype: + ~azure.core.polling.LROPoller[~azure.mgmt.resource.resources.v2019_05_01.models.GenericResource] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = kwargs.pop("params", {}) or {} + + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.GenericResource] + polling = kwargs.pop("polling", True) # type: Union[bool, PollingMethod] + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token = kwargs.pop("continuation_token", None) # type: Optional[str] + if cont_token is None: + raw_result = self._create_or_update_initial( # type: ignore + resource_group_name=resource_group_name, + resource_provider_namespace=resource_provider_namespace, + parent_resource_path=parent_resource_path, + resource_type=resource_type, + resource_name=resource_name, + api_version=api_version, + parameters=parameters, + content_type=content_type, + cls=lambda x, y, z: x, + headers=_headers, + params=_params, + **kwargs + ) + kwargs.pop("error_map", None) + + def get_long_running_output(pipeline_response): + deserialized = self._deserialize("GenericResource", pipeline_response) + if cls: + return cls(pipeline_response, deserialized, {}) + return deserialized + + if polling is True: + polling_method = cast(PollingMethod, ARMPolling(lro_delay, **kwargs)) # type: PollingMethod + elif polling is False: + polling_method = cast(PollingMethod, NoPolling()) + else: + polling_method = polling if cont_token: return LROPoller.from_continuation_token( polling_method=polling_method, continuation_token=cont_token, client=self._client, - deserialization_callback=get_long_running_output + deserialization_callback=get_long_running_output, ) return LROPoller(self._client, raw_result, get_long_running_output, polling_method) - begin_create_or_update.metadata = {'url': "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{parentResourcePath}/{resourceType}/{resourceName}"} # type: ignore + begin_create_or_update.metadata = {"url": "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{parentResourcePath}/{resourceType}/{resourceName}"} # type: ignore def _update_initial( self, @@ -5351,39 +5836,53 @@ def _update_initial( resource_type: str, resource_name: str, api_version: str, - parameters: "_models.GenericResource", + parameters: Union[_models.GenericResource, IO], **kwargs: Any - ) -> Optional["_models.GenericResource"]: - cls = kwargs.pop('cls', None) # type: ClsType[Optional["_models.GenericResource"]] + ) -> Optional[_models.GenericResource]: error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = kwargs.pop("params", {}) or {} - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[Optional[_models.GenericResource]] - _json = self._serialize.body(parameters, 'GenericResource') + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(parameters, (IO, bytes)): + _content = parameters + else: + _json = self._serialize.body(parameters, "GenericResource") - request = build_resources_update_request_initial( + request = build_resources_update_request( resource_group_name=resource_group_name, resource_provider_namespace=resource_provider_namespace, parent_resource_path=parent_resource_path, resource_type=resource_type, resource_name=resource_name, subscription_id=self._config.subscription_id, - content_type=content_type, api_version=api_version, + content_type=content_type, json=_json, - template_url=self._update_initial.metadata['url'], + content=_content, + template_url=self._update_initial.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200, 202]: @@ -5392,15 +5891,112 @@ def _update_initial( deserialized = None if response.status_code == 200: - deserialized = self._deserialize('GenericResource', pipeline_response) + deserialized = self._deserialize("GenericResource", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - _update_initial.metadata = {'url': "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{parentResourcePath}/{resourceType}/{resourceName}"} # type: ignore + _update_initial.metadata = {"url": "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{parentResourcePath}/{resourceType}/{resourceName}"} # type: ignore + @overload + def begin_update( + self, + resource_group_name: str, + resource_provider_namespace: str, + parent_resource_path: str, + resource_type: str, + resource_name: str, + api_version: str, + parameters: _models.GenericResource, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> LROPoller[_models.GenericResource]: + """Updates a resource. + + :param resource_group_name: The name of the resource group for the resource. The name is case + insensitive. Required. + :type resource_group_name: str + :param resource_provider_namespace: The namespace of the resource provider. Required. + :type resource_provider_namespace: str + :param parent_resource_path: The parent resource identity. Required. + :type parent_resource_path: str + :param resource_type: The resource type of the resource to update. Required. + :type resource_type: str + :param resource_name: The name of the resource to update. Required. + :type resource_name: str + :param api_version: The API version to use for the operation. Required. + :type api_version: str + :param parameters: Parameters for updating the resource. Required. + :type parameters: ~azure.mgmt.resource.resources.v2019_05_01.models.GenericResource + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be ARMPolling. Pass in False for this + operation to not poll, or pass in your own initialized polling object for a personal polling + strategy. + :paramtype polling: bool or ~azure.core.polling.PollingMethod + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of LROPoller that returns either GenericResource or the result of + cls(response) + :rtype: + ~azure.core.polling.LROPoller[~azure.mgmt.resource.resources.v2019_05_01.models.GenericResource] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + def begin_update( + self, + resource_group_name: str, + resource_provider_namespace: str, + parent_resource_path: str, + resource_type: str, + resource_name: str, + api_version: str, + parameters: IO, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> LROPoller[_models.GenericResource]: + """Updates a resource. + + :param resource_group_name: The name of the resource group for the resource. The name is case + insensitive. Required. + :type resource_group_name: str + :param resource_provider_namespace: The namespace of the resource provider. Required. + :type resource_provider_namespace: str + :param parent_resource_path: The parent resource identity. Required. + :type parent_resource_path: str + :param resource_type: The resource type of the resource to update. Required. + :type resource_type: str + :param resource_name: The name of the resource to update. Required. + :type resource_name: str + :param api_version: The API version to use for the operation. Required. + :type api_version: str + :param parameters: Parameters for updating the resource. Required. + :type parameters: IO + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be ARMPolling. Pass in False for this + operation to not poll, or pass in your own initialized polling object for a personal polling + strategy. + :paramtype polling: bool or ~azure.core.polling.PollingMethod + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of LROPoller that returns either GenericResource or the result of + cls(response) + :rtype: + ~azure.core.polling.LROPoller[~azure.mgmt.resource.resources.v2019_05_01.models.GenericResource] + :raises ~azure.core.exceptions.HttpResponseError: + """ @distributed_trace def begin_update( @@ -5411,26 +6007,30 @@ def begin_update( resource_type: str, resource_name: str, api_version: str, - parameters: "_models.GenericResource", + parameters: Union[_models.GenericResource, IO], **kwargs: Any - ) -> LROPoller["_models.GenericResource"]: + ) -> LROPoller[_models.GenericResource]: """Updates a resource. :param resource_group_name: The name of the resource group for the resource. The name is case - insensitive. + insensitive. Required. :type resource_group_name: str - :param resource_provider_namespace: The namespace of the resource provider. + :param resource_provider_namespace: The namespace of the resource provider. Required. :type resource_provider_namespace: str - :param parent_resource_path: The parent resource identity. + :param parent_resource_path: The parent resource identity. Required. :type parent_resource_path: str - :param resource_type: The resource type of the resource to update. + :param resource_type: The resource type of the resource to update. Required. :type resource_type: str - :param resource_name: The name of the resource to update. + :param resource_name: The name of the resource to update. Required. :type resource_name: str - :param api_version: The API version to use for the operation. + :param api_version: The API version to use for the operation. Required. :type api_version: str - :param parameters: Parameters for updating the resource. - :type parameters: ~azure.mgmt.resource.resources.v2019_05_01.models.GenericResource + :param parameters: Parameters for updating the resource. Is either a model type or a IO type. + Required. + :type parameters: ~azure.mgmt.resource.resources.v2019_05_01.models.GenericResource or IO + :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. + Default value is None. + :paramtype content_type: str :keyword callable cls: A custom type or function that will be passed the direct response :keyword str continuation_token: A continuation token to restart a poller from a saved state. :keyword polling: By default, your polling method will be ARMPolling. Pass in False for this @@ -5443,18 +6043,18 @@ def begin_update( cls(response) :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.resource.resources.v2019_05_01.models.GenericResource] - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] - polling = kwargs.pop('polling', True) # type: Union[bool, PollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType["_models.GenericResource"] - lro_delay = kwargs.pop( - 'polling_interval', - self._config.polling_interval - ) - cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = kwargs.pop("params", {}) or {} + + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.GenericResource] + polling = kwargs.pop("polling", True) # type: Union[bool, PollingMethod] + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token = kwargs.pop("continuation_token", None) # type: Optional[str] if cont_token is None: - raw_result = self._update_initial( + raw_result = self._update_initial( # type: ignore resource_group_name=resource_group_name, resource_provider_namespace=resource_provider_namespace, parent_resource_path=parent_resource_path, @@ -5463,32 +6063,35 @@ def begin_update( api_version=api_version, parameters=parameters, content_type=content_type, - cls=lambda x,y,z: x, + cls=lambda x, y, z: x, + headers=_headers, + params=_params, **kwargs ) - kwargs.pop('error_map', None) + kwargs.pop("error_map", None) def get_long_running_output(pipeline_response): - response = pipeline_response.http_response - deserialized = self._deserialize('GenericResource', pipeline_response) + deserialized = self._deserialize("GenericResource", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - - if polling is True: polling_method = ARMPolling(lro_delay, **kwargs) - elif polling is False: polling_method = NoPolling() - else: polling_method = polling + if polling is True: + polling_method = cast(PollingMethod, ARMPolling(lro_delay, **kwargs)) # type: PollingMethod + elif polling is False: + polling_method = cast(PollingMethod, NoPolling()) + else: + polling_method = polling if cont_token: return LROPoller.from_continuation_token( polling_method=polling_method, continuation_token=cont_token, client=self._client, - deserialization_callback=get_long_running_output + deserialization_callback=get_long_running_output, ) return LROPoller(self._client, raw_result, get_long_running_output, polling_method) - begin_update.metadata = {'url': "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{parentResourcePath}/{resourceType}/{resourceName}"} # type: ignore + begin_update.metadata = {"url": "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{parentResourcePath}/{resourceType}/{resourceName}"} # type: ignore @distributed_trace def get( @@ -5500,34 +6103,40 @@ def get( resource_name: str, api_version: str, **kwargs: Any - ) -> "_models.GenericResource": + ) -> _models.GenericResource: """Gets a resource. :param resource_group_name: The name of the resource group containing the resource to get. The - name is case insensitive. + name is case insensitive. Required. :type resource_group_name: str - :param resource_provider_namespace: The namespace of the resource provider. + :param resource_provider_namespace: The namespace of the resource provider. Required. :type resource_provider_namespace: str - :param parent_resource_path: The parent resource identity. + :param parent_resource_path: The parent resource identity. Required. :type parent_resource_path: str - :param resource_type: The resource type of the resource. + :param resource_type: The resource type of the resource. Required. :type resource_type: str - :param resource_name: The name of the resource to get. + :param resource_name: The name of the resource to get. Required. :type resource_name: str - :param api_version: The API version to use for the operation. + :param api_version: The API version to use for the operation. Required. :type api_version: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: GenericResource, or the result of cls(response) + :return: GenericResource or the result of cls(response) :rtype: ~azure.mgmt.resource.resources.v2019_05_01.models.GenericResource - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.GenericResource"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = kwargs.pop("params", {}) or {} + + cls = kwargs.pop("cls", None) # type: ClsType[_models.GenericResource] - request = build_resources_get_request( resource_group_name=resource_group_name, resource_provider_namespace=resource_provider_namespace, @@ -5536,72 +6145,75 @@ def get( resource_name=resource_name, subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.get.metadata['url'], + template_url=self.get.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) - deserialized = self._deserialize('GenericResource', pipeline_response) + deserialized = self._deserialize("GenericResource", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - get.metadata = {'url': "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{parentResourcePath}/{resourceType}/{resourceName}"} # type: ignore - + get.metadata = {"url": "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{parentResourcePath}/{resourceType}/{resourceName}"} # type: ignore @distributed_trace - def check_existence_by_id( - self, - resource_id: str, - api_version: str, - **kwargs: Any - ) -> bool: + def check_existence_by_id(self, resource_id: str, api_version: str, **kwargs: Any) -> bool: """Checks by ID whether a resource exists. :param resource_id: The fully qualified ID of the resource, including the resource name and resource type. Use the format, /subscriptions/{guid}/resourceGroups/{resource-group-name}/{resource-provider-namespace}/{resource-type}/{resource-name}. + Required. :type resource_id: str - :param api_version: The API version to use for the operation. + :param api_version: The API version to use for the operation. Required. :type api_version: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: bool, or the result of cls(response) + :return: bool or the result of cls(response) :rtype: bool - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType[None] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = kwargs.pop("params", {}) or {} + + cls = kwargs.pop("cls", None) # type: ClsType[None] - request = build_resources_check_existence_by_id_request( resource_id=resource_id, api_version=api_version, - template_url=self.check_existence_by_id.metadata['url'], + template_url=self.check_existence_by_id.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [204, 404]: @@ -5612,35 +6224,38 @@ def check_existence_by_id( return cls(pipeline_response, None, {}) return 200 <= response.status_code <= 299 - check_existence_by_id.metadata = {'url': "/{resourceId}"} # type: ignore - + check_existence_by_id.metadata = {"url": "/{resourceId}"} # type: ignore def _delete_by_id_initial( # pylint: disable=inconsistent-return-statements - self, - resource_id: str, - api_version: str, - **kwargs: Any + self, resource_id: str, api_version: str, **kwargs: Any ) -> None: - cls = kwargs.pop('cls', None) # type: ClsType[None] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = kwargs.pop("params", {}) or {} - - request = build_resources_delete_by_id_request_initial( + cls = kwargs.pop("cls", None) # type: ClsType[None] + + request = build_resources_delete_by_id_request( resource_id=resource_id, api_version=api_version, - template_url=self._delete_by_id_initial.metadata['url'], + template_url=self._delete_by_id_initial.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200, 202, 204]: @@ -5650,23 +6265,18 @@ def _delete_by_id_initial( # pylint: disable=inconsistent-return-statements if cls: return cls(pipeline_response, None, {}) - _delete_by_id_initial.metadata = {'url': "/{resourceId}"} # type: ignore - + _delete_by_id_initial.metadata = {"url": "/{resourceId}"} # type: ignore @distributed_trace - def begin_delete_by_id( # pylint: disable=inconsistent-return-statements - self, - resource_id: str, - api_version: str, - **kwargs: Any - ) -> LROPoller[None]: + def begin_delete_by_id(self, resource_id: str, api_version: str, **kwargs: Any) -> LROPoller[None]: """Deletes a resource by ID. :param resource_id: The fully qualified ID of the resource, including the resource name and resource type. Use the format, /subscriptions/{guid}/resourceGroups/{resource-group-name}/{resource-provider-namespace}/{resource-type}/{resource-name}. + Required. :type resource_id: str - :param api_version: The API version to use for the operation. + :param api_version: The API version to use for the operation. Required. :type api_version: str :keyword callable cls: A custom type or function that will be passed the direct response :keyword str continuation_token: A continuation token to restart a poller from a saved state. @@ -5678,75 +6288,89 @@ def begin_delete_by_id( # pylint: disable=inconsistent-return-statements Retry-After header is present. :return: An instance of LROPoller that returns either None or the result of cls(response) :rtype: ~azure.core.polling.LROPoller[None] - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - polling = kwargs.pop('polling', True) # type: Union[bool, PollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType[None] - lro_delay = kwargs.pop( - 'polling_interval', - self._config.polling_interval - ) - cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] + _headers = kwargs.pop("headers", {}) or {} + _params = kwargs.pop("params", {}) or {} + + cls = kwargs.pop("cls", None) # type: ClsType[None] + polling = kwargs.pop("polling", True) # type: Union[bool, PollingMethod] + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token = kwargs.pop("continuation_token", None) # type: Optional[str] if cont_token is None: - raw_result = self._delete_by_id_initial( + raw_result = self._delete_by_id_initial( # type: ignore resource_id=resource_id, api_version=api_version, - cls=lambda x,y,z: x, + cls=lambda x, y, z: x, + headers=_headers, + params=_params, **kwargs ) - kwargs.pop('error_map', None) + kwargs.pop("error_map", None) - def get_long_running_output(pipeline_response): + def get_long_running_output(pipeline_response): # pylint: disable=inconsistent-return-statements if cls: return cls(pipeline_response, None, {}) - - if polling is True: polling_method = ARMPolling(lro_delay, **kwargs) - elif polling is False: polling_method = NoPolling() - else: polling_method = polling + if polling is True: + polling_method = cast(PollingMethod, ARMPolling(lro_delay, **kwargs)) # type: PollingMethod + elif polling is False: + polling_method = cast(PollingMethod, NoPolling()) + else: + polling_method = polling if cont_token: return LROPoller.from_continuation_token( polling_method=polling_method, continuation_token=cont_token, client=self._client, - deserialization_callback=get_long_running_output + deserialization_callback=get_long_running_output, ) return LROPoller(self._client, raw_result, get_long_running_output, polling_method) - begin_delete_by_id.metadata = {'url': "/{resourceId}"} # type: ignore + begin_delete_by_id.metadata = {"url": "/{resourceId}"} # type: ignore def _create_or_update_by_id_initial( - self, - resource_id: str, - api_version: str, - parameters: "_models.GenericResource", - **kwargs: Any - ) -> Optional["_models.GenericResource"]: - cls = kwargs.pop('cls', None) # type: ClsType[Optional["_models.GenericResource"]] + self, resource_id: str, api_version: str, parameters: Union[_models.GenericResource, IO], **kwargs: Any + ) -> Optional[_models.GenericResource]: error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = kwargs.pop("params", {}) or {} - _json = self._serialize.body(parameters, 'GenericResource') + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[Optional[_models.GenericResource]] - request = build_resources_create_or_update_by_id_request_initial( + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(parameters, (IO, bytes)): + _content = parameters + else: + _json = self._serialize.body(parameters, "GenericResource") + + request = build_resources_create_or_update_by_id_request( resource_id=resource_id, - content_type=content_type, api_version=api_version, + content_type=content_type, json=_json, - template_url=self._create_or_update_by_id_initial.metadata['url'], + content=_content, + template_url=self._create_or_update_by_id_initial.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200, 201, 202]: @@ -5755,37 +6379,42 @@ def _create_or_update_by_id_initial( deserialized = None if response.status_code == 200: - deserialized = self._deserialize('GenericResource', pipeline_response) + deserialized = self._deserialize("GenericResource", pipeline_response) if response.status_code == 201: - deserialized = self._deserialize('GenericResource', pipeline_response) + deserialized = self._deserialize("GenericResource", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - _create_or_update_by_id_initial.metadata = {'url': "/{resourceId}"} # type: ignore + _create_or_update_by_id_initial.metadata = {"url": "/{resourceId}"} # type: ignore - - @distributed_trace + @overload def begin_create_or_update_by_id( self, resource_id: str, api_version: str, - parameters: "_models.GenericResource", + parameters: _models.GenericResource, + *, + content_type: str = "application/json", **kwargs: Any - ) -> LROPoller["_models.GenericResource"]: + ) -> LROPoller[_models.GenericResource]: """Create a resource by ID. :param resource_id: The fully qualified ID of the resource, including the resource name and resource type. Use the format, /subscriptions/{guid}/resourceGroups/{resource-group-name}/{resource-provider-namespace}/{resource-type}/{resource-name}. + Required. :type resource_id: str - :param api_version: The API version to use for the operation. + :param api_version: The API version to use for the operation. Required. :type api_version: str - :param parameters: Create or update resource parameters. + :param parameters: Create or update resource parameters. Required. :type parameters: ~azure.mgmt.resource.resources.v2019_05_01.models.GenericResource + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str :keyword callable cls: A custom type or function that will be passed the direct response :keyword str continuation_token: A continuation token to restart a poller from a saved state. :keyword polling: By default, your polling method will be ARMPolling. Pass in False for this @@ -5798,81 +6427,167 @@ def begin_create_or_update_by_id( cls(response) :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.resource.resources.v2019_05_01.models.GenericResource] - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] - polling = kwargs.pop('polling', True) # type: Union[bool, PollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType["_models.GenericResource"] - lro_delay = kwargs.pop( - 'polling_interval', - self._config.polling_interval - ) - cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] + + @overload + def begin_create_or_update_by_id( + self, + resource_id: str, + api_version: str, + parameters: IO, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> LROPoller[_models.GenericResource]: + """Create a resource by ID. + + :param resource_id: The fully qualified ID of the resource, including the resource name and + resource type. Use the format, + /subscriptions/{guid}/resourceGroups/{resource-group-name}/{resource-provider-namespace}/{resource-type}/{resource-name}. + Required. + :type resource_id: str + :param api_version: The API version to use for the operation. Required. + :type api_version: str + :param parameters: Create or update resource parameters. Required. + :type parameters: IO + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be ARMPolling. Pass in False for this + operation to not poll, or pass in your own initialized polling object for a personal polling + strategy. + :paramtype polling: bool or ~azure.core.polling.PollingMethod + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of LROPoller that returns either GenericResource or the result of + cls(response) + :rtype: + ~azure.core.polling.LROPoller[~azure.mgmt.resource.resources.v2019_05_01.models.GenericResource] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace + def begin_create_or_update_by_id( + self, resource_id: str, api_version: str, parameters: Union[_models.GenericResource, IO], **kwargs: Any + ) -> LROPoller[_models.GenericResource]: + """Create a resource by ID. + + :param resource_id: The fully qualified ID of the resource, including the resource name and + resource type. Use the format, + /subscriptions/{guid}/resourceGroups/{resource-group-name}/{resource-provider-namespace}/{resource-type}/{resource-name}. + Required. + :type resource_id: str + :param api_version: The API version to use for the operation. Required. + :type api_version: str + :param parameters: Create or update resource parameters. Is either a model type or a IO type. + Required. + :type parameters: ~azure.mgmt.resource.resources.v2019_05_01.models.GenericResource or IO + :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. + Default value is None. + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be ARMPolling. Pass in False for this + operation to not poll, or pass in your own initialized polling object for a personal polling + strategy. + :paramtype polling: bool or ~azure.core.polling.PollingMethod + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of LROPoller that returns either GenericResource or the result of + cls(response) + :rtype: + ~azure.core.polling.LROPoller[~azure.mgmt.resource.resources.v2019_05_01.models.GenericResource] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = kwargs.pop("params", {}) or {} + + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.GenericResource] + polling = kwargs.pop("polling", True) # type: Union[bool, PollingMethod] + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token = kwargs.pop("continuation_token", None) # type: Optional[str] if cont_token is None: - raw_result = self._create_or_update_by_id_initial( + raw_result = self._create_or_update_by_id_initial( # type: ignore resource_id=resource_id, api_version=api_version, parameters=parameters, content_type=content_type, - cls=lambda x,y,z: x, + cls=lambda x, y, z: x, + headers=_headers, + params=_params, **kwargs ) - kwargs.pop('error_map', None) + kwargs.pop("error_map", None) def get_long_running_output(pipeline_response): - response = pipeline_response.http_response - deserialized = self._deserialize('GenericResource', pipeline_response) + deserialized = self._deserialize("GenericResource", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - - if polling is True: polling_method = ARMPolling(lro_delay, **kwargs) - elif polling is False: polling_method = NoPolling() - else: polling_method = polling + if polling is True: + polling_method = cast(PollingMethod, ARMPolling(lro_delay, **kwargs)) # type: PollingMethod + elif polling is False: + polling_method = cast(PollingMethod, NoPolling()) + else: + polling_method = polling if cont_token: return LROPoller.from_continuation_token( polling_method=polling_method, continuation_token=cont_token, client=self._client, - deserialization_callback=get_long_running_output + deserialization_callback=get_long_running_output, ) return LROPoller(self._client, raw_result, get_long_running_output, polling_method) - begin_create_or_update_by_id.metadata = {'url': "/{resourceId}"} # type: ignore + begin_create_or_update_by_id.metadata = {"url": "/{resourceId}"} # type: ignore def _update_by_id_initial( - self, - resource_id: str, - api_version: str, - parameters: "_models.GenericResource", - **kwargs: Any - ) -> Optional["_models.GenericResource"]: - cls = kwargs.pop('cls', None) # type: ClsType[Optional["_models.GenericResource"]] + self, resource_id: str, api_version: str, parameters: Union[_models.GenericResource, IO], **kwargs: Any + ) -> Optional[_models.GenericResource]: error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = kwargs.pop("params", {}) or {} - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[Optional[_models.GenericResource]] - _json = self._serialize.body(parameters, 'GenericResource') + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(parameters, (IO, bytes)): + _content = parameters + else: + _json = self._serialize.body(parameters, "GenericResource") - request = build_resources_update_by_id_request_initial( + request = build_resources_update_by_id_request( resource_id=resource_id, - content_type=content_type, api_version=api_version, + content_type=content_type, json=_json, - template_url=self._update_by_id_initial.metadata['url'], + content=_content, + template_url=self._update_by_id_initial.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200, 202]: @@ -5881,34 +6596,111 @@ def _update_by_id_initial( deserialized = None if response.status_code == 200: - deserialized = self._deserialize('GenericResource', pipeline_response) + deserialized = self._deserialize("GenericResource", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - _update_by_id_initial.metadata = {'url': "/{resourceId}"} # type: ignore + _update_by_id_initial.metadata = {"url": "/{resourceId}"} # type: ignore + + @overload + def begin_update_by_id( + self, + resource_id: str, + api_version: str, + parameters: _models.GenericResource, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> LROPoller[_models.GenericResource]: + """Updates a resource by ID. + :param resource_id: The fully qualified ID of the resource, including the resource name and + resource type. Use the format, + /subscriptions/{guid}/resourceGroups/{resource-group-name}/{resource-provider-namespace}/{resource-type}/{resource-name}. + Required. + :type resource_id: str + :param api_version: The API version to use for the operation. Required. + :type api_version: str + :param parameters: Update resource parameters. Required. + :type parameters: ~azure.mgmt.resource.resources.v2019_05_01.models.GenericResource + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be ARMPolling. Pass in False for this + operation to not poll, or pass in your own initialized polling object for a personal polling + strategy. + :paramtype polling: bool or ~azure.core.polling.PollingMethod + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of LROPoller that returns either GenericResource or the result of + cls(response) + :rtype: + ~azure.core.polling.LROPoller[~azure.mgmt.resource.resources.v2019_05_01.models.GenericResource] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + def begin_update_by_id( + self, + resource_id: str, + api_version: str, + parameters: IO, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> LROPoller[_models.GenericResource]: + """Updates a resource by ID. + + :param resource_id: The fully qualified ID of the resource, including the resource name and + resource type. Use the format, + /subscriptions/{guid}/resourceGroups/{resource-group-name}/{resource-provider-namespace}/{resource-type}/{resource-name}. + Required. + :type resource_id: str + :param api_version: The API version to use for the operation. Required. + :type api_version: str + :param parameters: Update resource parameters. Required. + :type parameters: IO + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be ARMPolling. Pass in False for this + operation to not poll, or pass in your own initialized polling object for a personal polling + strategy. + :paramtype polling: bool or ~azure.core.polling.PollingMethod + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of LROPoller that returns either GenericResource or the result of + cls(response) + :rtype: + ~azure.core.polling.LROPoller[~azure.mgmt.resource.resources.v2019_05_01.models.GenericResource] + :raises ~azure.core.exceptions.HttpResponseError: + """ @distributed_trace def begin_update_by_id( - self, - resource_id: str, - api_version: str, - parameters: "_models.GenericResource", - **kwargs: Any - ) -> LROPoller["_models.GenericResource"]: + self, resource_id: str, api_version: str, parameters: Union[_models.GenericResource, IO], **kwargs: Any + ) -> LROPoller[_models.GenericResource]: """Updates a resource by ID. :param resource_id: The fully qualified ID of the resource, including the resource name and resource type. Use the format, /subscriptions/{guid}/resourceGroups/{resource-group-name}/{resource-provider-namespace}/{resource-type}/{resource-name}. + Required. :type resource_id: str - :param api_version: The API version to use for the operation. + :param api_version: The API version to use for the operation. Required. :type api_version: str - :param parameters: Update resource parameters. - :type parameters: ~azure.mgmt.resource.resources.v2019_05_01.models.GenericResource + :param parameters: Update resource parameters. Is either a model type or a IO type. Required. + :type parameters: ~azure.mgmt.resource.resources.v2019_05_01.models.GenericResource or IO + :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. + Default value is None. + :paramtype content_type: str :keyword callable cls: A custom type or function that will be passed the direct response :keyword str continuation_token: A continuation token to restart a poller from a saved state. :keyword polling: By default, your polling method will be ARMPolling. Pass in False for this @@ -5921,165 +6713,171 @@ def begin_update_by_id( cls(response) :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.resource.resources.v2019_05_01.models.GenericResource] - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] - polling = kwargs.pop('polling', True) # type: Union[bool, PollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType["_models.GenericResource"] - lro_delay = kwargs.pop( - 'polling_interval', - self._config.polling_interval - ) - cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = kwargs.pop("params", {}) or {} + + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.GenericResource] + polling = kwargs.pop("polling", True) # type: Union[bool, PollingMethod] + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token = kwargs.pop("continuation_token", None) # type: Optional[str] if cont_token is None: - raw_result = self._update_by_id_initial( + raw_result = self._update_by_id_initial( # type: ignore resource_id=resource_id, api_version=api_version, parameters=parameters, content_type=content_type, - cls=lambda x,y,z: x, + cls=lambda x, y, z: x, + headers=_headers, + params=_params, **kwargs ) - kwargs.pop('error_map', None) + kwargs.pop("error_map", None) def get_long_running_output(pipeline_response): - response = pipeline_response.http_response - deserialized = self._deserialize('GenericResource', pipeline_response) + deserialized = self._deserialize("GenericResource", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - - if polling is True: polling_method = ARMPolling(lro_delay, **kwargs) - elif polling is False: polling_method = NoPolling() - else: polling_method = polling + if polling is True: + polling_method = cast(PollingMethod, ARMPolling(lro_delay, **kwargs)) # type: PollingMethod + elif polling is False: + polling_method = cast(PollingMethod, NoPolling()) + else: + polling_method = polling if cont_token: return LROPoller.from_continuation_token( polling_method=polling_method, continuation_token=cont_token, client=self._client, - deserialization_callback=get_long_running_output + deserialization_callback=get_long_running_output, ) return LROPoller(self._client, raw_result, get_long_running_output, polling_method) - begin_update_by_id.metadata = {'url': "/{resourceId}"} # type: ignore + begin_update_by_id.metadata = {"url": "/{resourceId}"} # type: ignore @distributed_trace - def get_by_id( - self, - resource_id: str, - api_version: str, - **kwargs: Any - ) -> "_models.GenericResource": + def get_by_id(self, resource_id: str, api_version: str, **kwargs: Any) -> _models.GenericResource: """Gets a resource by ID. :param resource_id: The fully qualified ID of the resource, including the resource name and resource type. Use the format, /subscriptions/{guid}/resourceGroups/{resource-group-name}/{resource-provider-namespace}/{resource-type}/{resource-name}. + Required. :type resource_id: str - :param api_version: The API version to use for the operation. + :param api_version: The API version to use for the operation. Required. :type api_version: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: GenericResource, or the result of cls(response) + :return: GenericResource or the result of cls(response) :rtype: ~azure.mgmt.resource.resources.v2019_05_01.models.GenericResource - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.GenericResource"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = kwargs.pop("params", {}) or {} + + cls = kwargs.pop("cls", None) # type: ClsType[_models.GenericResource] - request = build_resources_get_by_id_request( resource_id=resource_id, api_version=api_version, - template_url=self.get_by_id.metadata['url'], + template_url=self.get_by_id.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) - deserialized = self._deserialize('GenericResource', pipeline_response) + deserialized = self._deserialize("GenericResource", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - get_by_id.metadata = {'url': "/{resourceId}"} # type: ignore + get_by_id.metadata = {"url": "/{resourceId}"} # type: ignore -class ResourceGroupsOperations(object): - """ResourceGroupsOperations operations. - You should not instantiate this class directly. Instead, you should create a Client instance that - instantiates it for you and attaches it as an attribute. +class ResourceGroupsOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. - :ivar models: Alias to model classes used in this operation group. - :type models: ~azure.mgmt.resource.resources.v2019_05_01.models - :param client: Client for service requests. - :param config: Configuration of service client. - :param serializer: An object model serializer. - :param deserializer: An object model deserializer. + Instead, you should access the following operations through + :class:`~azure.mgmt.resource.resources.v2019_05_01.ResourceManagementClient`'s + :attr:`resource_groups` attribute. """ models = _models - def __init__(self, client, config, serializer, deserializer): - self._client = client - self._serialize = serializer - self._deserialize = deserializer - self._config = config + def __init__(self, *args, **kwargs): + input_args = list(args) + self._client = input_args.pop(0) if input_args else kwargs.pop("client") + self._config = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") @distributed_trace - def check_existence( - self, - resource_group_name: str, - **kwargs: Any - ) -> bool: + def check_existence(self, resource_group_name: str, **kwargs: Any) -> bool: """Checks whether a resource group exists. :param resource_group_name: The name of the resource group to check. The name is case - insensitive. + insensitive. Required. :type resource_group_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: bool, or the result of cls(response) + :return: bool or the result of cls(response) :rtype: bool - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType[None] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) - api_version = kwargs.pop('api_version', "2019-05-01") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2019-05-01")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[None] - request = build_resource_groups_check_existence_request( resource_group_name=resource_group_name, subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.check_existence.metadata['url'], + template_url=self.check_existence.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [204, 404]: @@ -6090,39 +6888,98 @@ def check_existence( return cls(pipeline_response, None, {}) return 200 <= response.status_code <= 299 - check_existence.metadata = {'url': "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}"} # type: ignore + check_existence.metadata = {"url": "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}"} # type: ignore - - @distributed_trace + @overload def create_or_update( self, resource_group_name: str, - parameters: "_models.ResourceGroup", + parameters: _models.ResourceGroup, + *, + content_type: str = "application/json", **kwargs: Any - ) -> "_models.ResourceGroup": + ) -> _models.ResourceGroup: """Creates or updates a resource group. :param resource_group_name: The name of the resource group to create or update. Can include alphanumeric, underscore, parentheses, hyphen, period (except at end), and Unicode characters - that match the allowed characters. + that match the allowed characters. Required. :type resource_group_name: str - :param parameters: Parameters supplied to the create or update a resource group. + :param parameters: Parameters supplied to the create or update a resource group. Required. :type parameters: ~azure.mgmt.resource.resources.v2019_05_01.models.ResourceGroup + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: ResourceGroup or the result of cls(response) + :rtype: ~azure.mgmt.resource.resources.v2019_05_01.models.ResourceGroup + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + def create_or_update( + self, resource_group_name: str, parameters: IO, *, content_type: str = "application/json", **kwargs: Any + ) -> _models.ResourceGroup: + """Creates or updates a resource group. + + :param resource_group_name: The name of the resource group to create or update. Can include + alphanumeric, underscore, parentheses, hyphen, period (except at end), and Unicode characters + that match the allowed characters. Required. + :type resource_group_name: str + :param parameters: Parameters supplied to the create or update a resource group. Required. + :type parameters: IO + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: ResourceGroup or the result of cls(response) + :rtype: ~azure.mgmt.resource.resources.v2019_05_01.models.ResourceGroup + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace + def create_or_update( + self, resource_group_name: str, parameters: Union[_models.ResourceGroup, IO], **kwargs: Any + ) -> _models.ResourceGroup: + """Creates or updates a resource group. + + :param resource_group_name: The name of the resource group to create or update. Can include + alphanumeric, underscore, parentheses, hyphen, period (except at end), and Unicode characters + that match the allowed characters. Required. + :type resource_group_name: str + :param parameters: Parameters supplied to the create or update a resource group. Is either a + model type or a IO type. Required. + :type parameters: ~azure.mgmt.resource.resources.v2019_05_01.models.ResourceGroup or IO + :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. + Default value is None. + :paramtype content_type: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: ResourceGroup, or the result of cls(response) + :return: ResourceGroup or the result of cls(response) :rtype: ~azure.mgmt.resource.resources.v2019_05_01.models.ResourceGroup - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.ResourceGroup"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) - api_version = kwargs.pop('api_version', "2019-05-01") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - _json = self._serialize.body(parameters, 'ResourceGroup') + api_version = kwargs.pop("api_version", _params.pop("api-version", "2019-05-01")) # type: str + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.ResourceGroup] + + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(parameters, (IO, bytes)): + _content = parameters + else: + _json = self._serialize.body(parameters, "ResourceGroup") request = build_resource_groups_create_or_update_request( resource_group_name=resource_group_name, @@ -6130,16 +6987,18 @@ def create_or_update( api_version=api_version, content_type=content_type, json=_json, - template_url=self.create_or_update.metadata['url'], + content=_content, + template_url=self.create_or_update.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200, 201]: @@ -6147,47 +7006,50 @@ def create_or_update( raise HttpResponseError(response=response, error_format=ARMErrorFormat) if response.status_code == 200: - deserialized = self._deserialize('ResourceGroup', pipeline_response) + deserialized = self._deserialize("ResourceGroup", pipeline_response) if response.status_code == 201: - deserialized = self._deserialize('ResourceGroup', pipeline_response) + deserialized = self._deserialize("ResourceGroup", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - create_or_update.metadata = {'url': "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}"} # type: ignore - + create_or_update.metadata = {"url": "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}"} # type: ignore def _delete_initial( # pylint: disable=inconsistent-return-statements - self, - resource_group_name: str, - **kwargs: Any + self, resource_group_name: str, **kwargs: Any ) -> None: - cls = kwargs.pop('cls', None) # type: ClsType[None] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) - api_version = kwargs.pop('api_version', "2019-05-01") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - request = build_resource_groups_delete_request_initial( + api_version = kwargs.pop("api_version", _params.pop("api-version", "2019-05-01")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[None] + + request = build_resource_groups_delete_request( resource_group_name=resource_group_name, subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self._delete_initial.metadata['url'], + template_url=self._delete_initial.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200, 202]: @@ -6197,22 +7059,17 @@ def _delete_initial( # pylint: disable=inconsistent-return-statements if cls: return cls(pipeline_response, None, {}) - _delete_initial.metadata = {'url': "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}"} # type: ignore - + _delete_initial.metadata = {"url": "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}"} # type: ignore @distributed_trace - def begin_delete( # pylint: disable=inconsistent-return-statements - self, - resource_group_name: str, - **kwargs: Any - ) -> LROPoller[None]: + def begin_delete(self, resource_group_name: str, **kwargs: Any) -> LROPoller[None]: """Deletes a resource group. When you delete a resource group, all of its resources are also deleted. Deleting a resource group deletes all of its template deployments and currently stored operations. :param resource_group_name: The name of the resource group to delete. The name is case - insensitive. + insensitive. Required. :type resource_group_name: str :keyword callable cls: A custom type or function that will be passed the direct response :keyword str continuation_token: A continuation token to restart a poller from a saved state. @@ -6224,106 +7081,113 @@ def begin_delete( # pylint: disable=inconsistent-return-statements Retry-After header is present. :return: An instance of LROPoller that returns either None or the result of cls(response) :rtype: ~azure.core.polling.LROPoller[None] - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - api_version = kwargs.pop('api_version', "2019-05-01") # type: str - polling = kwargs.pop('polling', True) # type: Union[bool, PollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType[None] - lro_delay = kwargs.pop( - 'polling_interval', - self._config.polling_interval - ) - cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2019-05-01")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[None] + polling = kwargs.pop("polling", True) # type: Union[bool, PollingMethod] + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token = kwargs.pop("continuation_token", None) # type: Optional[str] if cont_token is None: - raw_result = self._delete_initial( + raw_result = self._delete_initial( # type: ignore resource_group_name=resource_group_name, api_version=api_version, - cls=lambda x,y,z: x, + cls=lambda x, y, z: x, + headers=_headers, + params=_params, **kwargs ) - kwargs.pop('error_map', None) + kwargs.pop("error_map", None) - def get_long_running_output(pipeline_response): + def get_long_running_output(pipeline_response): # pylint: disable=inconsistent-return-statements if cls: return cls(pipeline_response, None, {}) - - if polling is True: polling_method = ARMPolling(lro_delay, **kwargs) - elif polling is False: polling_method = NoPolling() - else: polling_method = polling + if polling is True: + polling_method = cast(PollingMethod, ARMPolling(lro_delay, **kwargs)) # type: PollingMethod + elif polling is False: + polling_method = cast(PollingMethod, NoPolling()) + else: + polling_method = polling if cont_token: return LROPoller.from_continuation_token( polling_method=polling_method, continuation_token=cont_token, client=self._client, - deserialization_callback=get_long_running_output + deserialization_callback=get_long_running_output, ) return LROPoller(self._client, raw_result, get_long_running_output, polling_method) - begin_delete.metadata = {'url': "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}"} # type: ignore + begin_delete.metadata = {"url": "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}"} # type: ignore @distributed_trace - def get( - self, - resource_group_name: str, - **kwargs: Any - ) -> "_models.ResourceGroup": + def get(self, resource_group_name: str, **kwargs: Any) -> _models.ResourceGroup: """Gets a resource group. :param resource_group_name: The name of the resource group to get. The name is case - insensitive. + insensitive. Required. :type resource_group_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: ResourceGroup, or the result of cls(response) + :return: ResourceGroup or the result of cls(response) :rtype: ~azure.mgmt.resource.resources.v2019_05_01.models.ResourceGroup - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.ResourceGroup"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) - api_version = kwargs.pop('api_version', "2019-05-01") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2019-05-01")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[_models.ResourceGroup] - request = build_resource_groups_get_request( resource_group_name=resource_group_name, subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.get.metadata['url'], + template_url=self.get.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) - deserialized = self._deserialize('ResourceGroup', pipeline_response) + deserialized = self._deserialize("ResourceGroup", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - get.metadata = {'url': "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}"} # type: ignore + get.metadata = {"url": "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}"} # type: ignore - - @distributed_trace + @overload def update( self, resource_group_name: str, - parameters: "_models.ResourceGroupPatchable", + parameters: _models.ResourceGroupPatchable, + *, + content_type: str = "application/json", **kwargs: Any - ) -> "_models.ResourceGroup": + ) -> _models.ResourceGroup: """Updates a resource group. Resource groups can be updated through a simple PATCH operation to a group address. The format @@ -6331,25 +7195,90 @@ def update( the current value is retained. :param resource_group_name: The name of the resource group to update. The name is case - insensitive. + insensitive. Required. :type resource_group_name: str - :param parameters: Parameters supplied to update a resource group. + :param parameters: Parameters supplied to update a resource group. Required. :type parameters: ~azure.mgmt.resource.resources.v2019_05_01.models.ResourceGroupPatchable + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: ResourceGroup or the result of cls(response) + :rtype: ~azure.mgmt.resource.resources.v2019_05_01.models.ResourceGroup + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + def update( + self, resource_group_name: str, parameters: IO, *, content_type: str = "application/json", **kwargs: Any + ) -> _models.ResourceGroup: + """Updates a resource group. + + Resource groups can be updated through a simple PATCH operation to a group address. The format + of the request is the same as that for creating a resource group. If a field is unspecified, + the current value is retained. + + :param resource_group_name: The name of the resource group to update. The name is case + insensitive. Required. + :type resource_group_name: str + :param parameters: Parameters supplied to update a resource group. Required. + :type parameters: IO + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: ResourceGroup or the result of cls(response) + :rtype: ~azure.mgmt.resource.resources.v2019_05_01.models.ResourceGroup + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace + def update( + self, resource_group_name: str, parameters: Union[_models.ResourceGroupPatchable, IO], **kwargs: Any + ) -> _models.ResourceGroup: + """Updates a resource group. + + Resource groups can be updated through a simple PATCH operation to a group address. The format + of the request is the same as that for creating a resource group. If a field is unspecified, + the current value is retained. + + :param resource_group_name: The name of the resource group to update. The name is case + insensitive. Required. + :type resource_group_name: str + :param parameters: Parameters supplied to update a resource group. Is either a model type or a + IO type. Required. + :type parameters: ~azure.mgmt.resource.resources.v2019_05_01.models.ResourceGroupPatchable or + IO + :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. + Default value is None. + :paramtype content_type: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: ResourceGroup, or the result of cls(response) + :return: ResourceGroup or the result of cls(response) :rtype: ~azure.mgmt.resource.resources.v2019_05_01.models.ResourceGroup - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.ResourceGroup"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) - api_version = kwargs.pop('api_version', "2019-05-01") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - _json = self._serialize.body(parameters, 'ResourceGroupPatchable') + api_version = kwargs.pop("api_version", _params.pop("api-version", "2019-05-01")) # type: str + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.ResourceGroup] + + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(parameters, (IO, bytes)): + _content = parameters + else: + _json = self._serialize.body(parameters, "ResourceGroupPatchable") request = build_resource_groups_update_request( resource_group_name=resource_group_name, @@ -6357,60 +7286,117 @@ def update( api_version=api_version, content_type=content_type, json=_json, - template_url=self.update.metadata['url'], + content=_content, + template_url=self.update.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) - deserialized = self._deserialize('ResourceGroup', pipeline_response) + deserialized = self._deserialize("ResourceGroup", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - update.metadata = {'url': "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}"} # type: ignore + update.metadata = {"url": "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}"} # type: ignore - - @distributed_trace + @overload def export_template( self, resource_group_name: str, - parameters: "_models.ExportTemplateRequest", + parameters: _models.ExportTemplateRequest, + *, + content_type: str = "application/json", **kwargs: Any - ) -> "_models.ResourceGroupExportResult": + ) -> _models.ResourceGroupExportResult: """Captures the specified resource group as a template. - :param resource_group_name: The name of the resource group to export as a template. + :param resource_group_name: The name of the resource group to export as a template. Required. :type resource_group_name: str - :param parameters: Parameters for exporting the template. + :param parameters: Parameters for exporting the template. Required. :type parameters: ~azure.mgmt.resource.resources.v2019_05_01.models.ExportTemplateRequest + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: ResourceGroupExportResult or the result of cls(response) + :rtype: ~azure.mgmt.resource.resources.v2019_05_01.models.ResourceGroupExportResult + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + def export_template( + self, resource_group_name: str, parameters: IO, *, content_type: str = "application/json", **kwargs: Any + ) -> _models.ResourceGroupExportResult: + """Captures the specified resource group as a template. + + :param resource_group_name: The name of the resource group to export as a template. Required. + :type resource_group_name: str + :param parameters: Parameters for exporting the template. Required. + :type parameters: IO + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: ResourceGroupExportResult or the result of cls(response) + :rtype: ~azure.mgmt.resource.resources.v2019_05_01.models.ResourceGroupExportResult + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace + def export_template( + self, resource_group_name: str, parameters: Union[_models.ExportTemplateRequest, IO], **kwargs: Any + ) -> _models.ResourceGroupExportResult: + """Captures the specified resource group as a template. + + :param resource_group_name: The name of the resource group to export as a template. Required. + :type resource_group_name: str + :param parameters: Parameters for exporting the template. Is either a model type or a IO type. + Required. + :type parameters: ~azure.mgmt.resource.resources.v2019_05_01.models.ExportTemplateRequest or IO + :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. + Default value is None. + :paramtype content_type: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: ResourceGroupExportResult, or the result of cls(response) + :return: ResourceGroupExportResult or the result of cls(response) :rtype: ~azure.mgmt.resource.resources.v2019_05_01.models.ResourceGroupExportResult - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.ResourceGroupExportResult"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) - api_version = kwargs.pop('api_version', "2019-05-01") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - _json = self._serialize.body(parameters, 'ExportTemplateRequest') + api_version = kwargs.pop("api_version", _params.pop("api-version", "2019-05-01")) # type: str + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.ResourceGroupExportResult] + + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(parameters, (IO, bytes)): + _content = parameters + else: + _json = self._serialize.body(parameters, "ExportTemplateRequest") request = build_resource_groups_export_template_request( resource_group_name=resource_group_name, @@ -6418,39 +7404,37 @@ def export_template( api_version=api_version, content_type=content_type, json=_json, - template_url=self.export_template.metadata['url'], + content=_content, + template_url=self.export_template.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) - deserialized = self._deserialize('ResourceGroupExportResult', pipeline_response) + deserialized = self._deserialize("ResourceGroupExportResult", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - export_template.metadata = {'url': "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/exportTemplate"} # type: ignore - + export_template.metadata = {"url": "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/exportTemplate"} # type: ignore @distributed_trace def list( - self, - filter: Optional[str] = None, - top: Optional[int] = None, - **kwargs: Any - ) -> Iterable["_models.ResourceGroupListResult"]: + self, filter: Optional[str] = None, top: Optional[int] = None, **kwargs: Any + ) -> Iterable["_models.ResourceGroup"]: """Gets all the resource groups for a subscription. :param filter: The filter to apply on the operation.:code:`
`:code:`
`You can filter by @@ -6461,40 +7445,48 @@ def list( Default value is None. :type top: int :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either ResourceGroupListResult or the result of - cls(response) + :return: An iterator like instance of either ResourceGroup or the result of cls(response) :rtype: - ~azure.core.paging.ItemPaged[~azure.mgmt.resource.resources.v2019_05_01.models.ResourceGroupListResult] - :raises: ~azure.core.exceptions.HttpResponseError + ~azure.core.paging.ItemPaged[~azure.mgmt.resource.resources.v2019_05_01.models.ResourceGroup] + :raises ~azure.core.exceptions.HttpResponseError: """ - api_version = kwargs.pop('api_version', "2019-05-01") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2019-05-01")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[_models.ResourceGroupListResult] - cls = kwargs.pop('cls', None) # type: ClsType["_models.ResourceGroupListResult"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) + def prepare_request(next_link=None): if not next_link: - + request = build_resource_groups_list_request( subscription_id=self._config.subscription_id, - api_version=api_version, filter=filter, top=top, - template_url=self.list.metadata['url'], + 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.url = self._client.format_url(request.url) # type: ignore else: - - request = build_resource_groups_list_request( - subscription_id=self._config.subscription_id, - template_url=next_link, - ) + # make call to next link with the client's api-version + _parsed_next_link = urlparse(next_link) + _next_request_params = case_insensitive_dict(parse_qs(_parsed_next_link.query)) + _next_request_params["api-version"] = self._config.api_version + request = HttpRequest("GET", urljoin(next_link, _parsed_next_link.path), params=_next_request_params) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore request.method = "GET" return request @@ -6508,10 +7500,8 @@ def extract_data(pipeline_response): def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) response = pipeline_response.http_response @@ -6521,75 +7511,75 @@ def get_next(next_link=None): return pipeline_response + return ItemPaged(get_next, extract_data) - return ItemPaged( - get_next, extract_data - ) - list.metadata = {'url': "/subscriptions/{subscriptionId}/resourcegroups"} # type: ignore -class TagsOperations(object): - """TagsOperations operations. - - You should not instantiate this class directly. Instead, you should create a Client instance that - instantiates it for you and attaches it as an attribute. - - :ivar models: Alias to model classes used in this operation group. - :type models: ~azure.mgmt.resource.resources.v2019_05_01.models - :param client: Client for service requests. - :param config: Configuration of service client. - :param serializer: An object model serializer. - :param deserializer: An object model deserializer. + list.metadata = {"url": "/subscriptions/{subscriptionId}/resourcegroups"} # type: ignore + + +class TagsOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. + + Instead, you should access the following operations through + :class:`~azure.mgmt.resource.resources.v2019_05_01.ResourceManagementClient`'s + :attr:`tags` attribute. """ models = _models - def __init__(self, client, config, serializer, deserializer): - self._client = client - self._serialize = serializer - self._deserialize = deserializer - self._config = config + def __init__(self, *args, **kwargs): + input_args = list(args) + self._client = input_args.pop(0) if input_args else kwargs.pop("client") + self._config = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") @distributed_trace def delete_value( # pylint: disable=inconsistent-return-statements - self, - tag_name: str, - tag_value: str, - **kwargs: Any + self, tag_name: str, tag_value: str, **kwargs: Any ) -> None: """Deletes a tag value. - :param tag_name: The name of the tag. + :param tag_name: The name of the tag. Required. :type tag_name: str - :param tag_value: The value of the tag to delete. + :param tag_value: The value of the tag to delete. Required. :type tag_value: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: None, or the result of cls(response) + :return: None or the result of cls(response) :rtype: None - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType[None] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) - api_version = kwargs.pop('api_version', "2019-05-01") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2019-05-01")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[None] - request = build_tags_delete_value_request( tag_name=tag_name, tag_value=tag_value, subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.delete_value.metadata['url'], + template_url=self.delete_value.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200, 204]: @@ -6599,51 +7589,51 @@ def delete_value( # pylint: disable=inconsistent-return-statements if cls: return cls(pipeline_response, None, {}) - delete_value.metadata = {'url': "/subscriptions/{subscriptionId}/tagNames/{tagName}/tagValues/{tagValue}"} # type: ignore - + delete_value.metadata = {"url": "/subscriptions/{subscriptionId}/tagNames/{tagName}/tagValues/{tagValue}"} # type: ignore @distributed_trace - def create_or_update_value( - self, - tag_name: str, - tag_value: str, - **kwargs: Any - ) -> "_models.TagValue": + def create_or_update_value(self, tag_name: str, tag_value: str, **kwargs: Any) -> _models.TagValue: """Creates a tag value. The name of the tag must already exist. - :param tag_name: The name of the tag. + :param tag_name: The name of the tag. Required. :type tag_name: str - :param tag_value: The value of the tag to create. + :param tag_value: The value of the tag to create. Required. :type tag_value: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: TagValue, or the result of cls(response) + :return: TagValue or the result of cls(response) :rtype: ~azure.mgmt.resource.resources.v2019_05_01.models.TagValue - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.TagValue"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + 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', "2019-05-01") # type: str + api_version = kwargs.pop("api_version", _params.pop("api-version", "2019-05-01")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[_models.TagValue] - request = build_tags_create_or_update_value_request( tag_name=tag_name, tag_value=tag_value, subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.create_or_update_value.metadata['url'], + template_url=self.create_or_update_value.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200, 201]: @@ -6651,61 +7641,62 @@ def create_or_update_value( raise HttpResponseError(response=response, error_format=ARMErrorFormat) if response.status_code == 200: - deserialized = self._deserialize('TagValue', pipeline_response) + deserialized = self._deserialize("TagValue", pipeline_response) if response.status_code == 201: - deserialized = self._deserialize('TagValue', pipeline_response) + deserialized = self._deserialize("TagValue", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - create_or_update_value.metadata = {'url': "/subscriptions/{subscriptionId}/tagNames/{tagName}/tagValues/{tagValue}"} # type: ignore - + create_or_update_value.metadata = {"url": "/subscriptions/{subscriptionId}/tagNames/{tagName}/tagValues/{tagValue}"} # type: ignore @distributed_trace - def create_or_update( - self, - tag_name: str, - **kwargs: Any - ) -> "_models.TagDetails": + def create_or_update(self, tag_name: str, **kwargs: Any) -> _models.TagDetails: """Creates a tag in the subscription. The tag name can have a maximum of 512 characters and is case insensitive. Tag names created by Azure have prefixes of microsoft, azure, or windows. You cannot create tags with one of these prefixes. - :param tag_name: The name of the tag to create. + :param tag_name: The name of the tag to create. Required. :type tag_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: TagDetails, or the result of cls(response) + :return: TagDetails or the result of cls(response) :rtype: ~azure.mgmt.resource.resources.v2019_05_01.models.TagDetails - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.TagDetails"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + 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', "2019-05-01") # type: str + api_version = kwargs.pop("api_version", _params.pop("api-version", "2019-05-01")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[_models.TagDetails] - request = build_tags_create_or_update_request( tag_name=tag_name, subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.create_or_update.metadata['url'], + template_url=self.create_or_update.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200, 201]: @@ -6713,59 +7704,60 @@ def create_or_update( raise HttpResponseError(response=response, error_format=ARMErrorFormat) if response.status_code == 200: - deserialized = self._deserialize('TagDetails', pipeline_response) + deserialized = self._deserialize("TagDetails", pipeline_response) if response.status_code == 201: - deserialized = self._deserialize('TagDetails', pipeline_response) + deserialized = self._deserialize("TagDetails", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - create_or_update.metadata = {'url': "/subscriptions/{subscriptionId}/tagNames/{tagName}"} # type: ignore - + create_or_update.metadata = {"url": "/subscriptions/{subscriptionId}/tagNames/{tagName}"} # type: ignore @distributed_trace - def delete( # pylint: disable=inconsistent-return-statements - self, - tag_name: str, - **kwargs: Any - ) -> None: + def delete(self, tag_name: str, **kwargs: Any) -> None: # pylint: disable=inconsistent-return-statements """Deletes a tag from the subscription. You must remove all values from a resource tag before you can delete it. - :param tag_name: The name of the tag. + :param tag_name: The name of the tag. Required. :type tag_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: None, or the result of cls(response) + :return: None or the result of cls(response) :rtype: None - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType[None] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + 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', "2019-05-01") # type: str + api_version = kwargs.pop("api_version", _params.pop("api-version", "2019-05-01")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[None] - request = build_tags_delete_request( tag_name=tag_name, subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.delete.metadata['url'], + template_url=self.delete.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200, 204]: @@ -6775,48 +7767,53 @@ def delete( # pylint: disable=inconsistent-return-statements if cls: return cls(pipeline_response, None, {}) - delete.metadata = {'url': "/subscriptions/{subscriptionId}/tagNames/{tagName}"} # type: ignore - + delete.metadata = {"url": "/subscriptions/{subscriptionId}/tagNames/{tagName}"} # type: ignore @distributed_trace - def list( - self, - **kwargs: Any - ) -> Iterable["_models.TagsListResult"]: + def list(self, **kwargs: Any) -> Iterable["_models.TagDetails"]: """Gets the names and values of all resource tags that are defined in a subscription. :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either TagsListResult or the result of cls(response) + :return: An iterator like instance of either TagDetails or the result of cls(response) :rtype: - ~azure.core.paging.ItemPaged[~azure.mgmt.resource.resources.v2019_05_01.models.TagsListResult] - :raises: ~azure.core.exceptions.HttpResponseError + ~azure.core.paging.ItemPaged[~azure.mgmt.resource.resources.v2019_05_01.models.TagDetails] + :raises ~azure.core.exceptions.HttpResponseError: """ - api_version = kwargs.pop('api_version', "2019-05-01") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2019-05-01")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[_models.TagsListResult] - cls = kwargs.pop('cls', None) # type: ClsType["_models.TagsListResult"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) + def prepare_request(next_link=None): if not next_link: - + request = build_tags_list_request( subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.list.metadata['url'], + template_url=self.list.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore else: - - request = build_tags_list_request( - subscription_id=self._config.subscription_id, - template_url=next_link, - ) + # make call to next link with the client's api-version + _parsed_next_link = urlparse(next_link) + _next_request_params = case_insensitive_dict(parse_qs(_parsed_next_link.query)) + _next_request_params["api-version"] = self._config.api_version + request = HttpRequest("GET", urljoin(next_link, _parsed_next_link.path), params=_next_request_params) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore request.method = "GET" return request @@ -6830,10 +7827,8 @@ def extract_data(pipeline_response): def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) response = pipeline_response.http_response @@ -6843,146 +7838,147 @@ def get_next(next_link=None): return pipeline_response + return ItemPaged(get_next, extract_data) - return ItemPaged( - get_next, extract_data - ) - list.metadata = {'url': "/subscriptions/{subscriptionId}/tagNames"} # type: ignore -class DeploymentOperationsOperations(object): - """DeploymentOperationsOperations operations. - - You should not instantiate this class directly. Instead, you should create a Client instance that - instantiates it for you and attaches it as an attribute. - - :ivar models: Alias to model classes used in this operation group. - :type models: ~azure.mgmt.resource.resources.v2019_05_01.models - :param client: Client for service requests. - :param config: Configuration of service client. - :param serializer: An object model serializer. - :param deserializer: An object model deserializer. + list.metadata = {"url": "/subscriptions/{subscriptionId}/tagNames"} # type: ignore + + +class DeploymentOperationsOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. + + Instead, you should access the following operations through + :class:`~azure.mgmt.resource.resources.v2019_05_01.ResourceManagementClient`'s + :attr:`deployment_operations` attribute. """ models = _models - def __init__(self, client, config, serializer, deserializer): - self._client = client - self._serialize = serializer - self._deserialize = deserializer - self._config = config + def __init__(self, *args, **kwargs): + input_args = list(args) + self._client = input_args.pop(0) if input_args else kwargs.pop("client") + self._config = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") @distributed_trace def get_at_management_group_scope( - self, - group_id: str, - deployment_name: str, - operation_id: str, - **kwargs: Any - ) -> "_models.DeploymentOperation": + self, group_id: str, deployment_name: str, operation_id: str, **kwargs: Any + ) -> _models.DeploymentOperation: """Gets a deployments operation. - :param group_id: The management group ID. + :param group_id: The management group ID. Required. :type group_id: str - :param deployment_name: The name of the deployment. + :param deployment_name: The name of the deployment. Required. :type deployment_name: str - :param operation_id: The ID of the operation to get. + :param operation_id: The ID of the operation to get. Required. :type operation_id: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: DeploymentOperation, or the result of cls(response) + :return: DeploymentOperation or the result of cls(response) :rtype: ~azure.mgmt.resource.resources.v2019_05_01.models.DeploymentOperation - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.DeploymentOperation"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + 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', "2019-05-01") # type: str + api_version = kwargs.pop("api_version", _params.pop("api-version", "2019-05-01")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[_models.DeploymentOperation] - request = build_deployment_operations_get_at_management_group_scope_request( group_id=group_id, deployment_name=deployment_name, operation_id=operation_id, api_version=api_version, - template_url=self.get_at_management_group_scope.metadata['url'], + template_url=self.get_at_management_group_scope.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) - deserialized = self._deserialize('DeploymentOperation', pipeline_response) + deserialized = self._deserialize("DeploymentOperation", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - get_at_management_group_scope.metadata = {'url': "/providers/Microsoft.Management/managementGroups/{groupId}/providers/Microsoft.Resources/deployments/{deploymentName}/operations/{operationId}"} # type: ignore - + get_at_management_group_scope.metadata = {"url": "/providers/Microsoft.Management/managementGroups/{groupId}/providers/Microsoft.Resources/deployments/{deploymentName}/operations/{operationId}"} # type: ignore @distributed_trace def list_at_management_group_scope( - self, - group_id: str, - deployment_name: str, - top: Optional[int] = None, - **kwargs: Any - ) -> Iterable["_models.DeploymentOperationsListResult"]: + self, group_id: str, deployment_name: str, top: Optional[int] = None, **kwargs: Any + ) -> Iterable["_models.DeploymentOperation"]: """Gets all deployments operations for a deployment. - :param group_id: The management group ID. + :param group_id: The management group ID. Required. :type group_id: str - :param deployment_name: The name of the deployment. + :param deployment_name: The name of the deployment. Required. :type deployment_name: str :param top: The number of results to return. Default value is None. :type top: int :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either DeploymentOperationsListResult or the result of - cls(response) + :return: An iterator like instance of either DeploymentOperation or the result of cls(response) :rtype: - ~azure.core.paging.ItemPaged[~azure.mgmt.resource.resources.v2019_05_01.models.DeploymentOperationsListResult] - :raises: ~azure.core.exceptions.HttpResponseError + ~azure.core.paging.ItemPaged[~azure.mgmt.resource.resources.v2019_05_01.models.DeploymentOperation] + :raises ~azure.core.exceptions.HttpResponseError: """ - api_version = kwargs.pop('api_version', "2019-05-01") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2019-05-01")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[_models.DeploymentOperationsListResult] - cls = kwargs.pop('cls', None) # type: ClsType["_models.DeploymentOperationsListResult"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) + def prepare_request(next_link=None): if not next_link: - + request = build_deployment_operations_list_at_management_group_scope_request( group_id=group_id, deployment_name=deployment_name, - api_version=api_version, top=top, - template_url=self.list_at_management_group_scope.metadata['url'], + api_version=api_version, + template_url=self.list_at_management_group_scope.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore else: - - request = build_deployment_operations_list_at_management_group_scope_request( - group_id=group_id, - deployment_name=deployment_name, - template_url=next_link, - ) + # make call to next link with the client's api-version + _parsed_next_link = urlparse(next_link) + _next_request_params = case_insensitive_dict(parse_qs(_parsed_next_link.query)) + _next_request_params["api-version"] = self._config.api_version + request = HttpRequest("GET", urljoin(next_link, _parsed_next_link.path), params=_next_request_params) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore request.method = "GET" return request @@ -6996,10 +7992,8 @@ def extract_data(pipeline_response): def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) response = pipeline_response.http_response @@ -7009,119 +8003,123 @@ def get_next(next_link=None): return pipeline_response + return ItemPaged(get_next, extract_data) - return ItemPaged( - get_next, extract_data - ) - list_at_management_group_scope.metadata = {'url': "/providers/Microsoft.Management/managementGroups/{groupId}/providers/Microsoft.Resources/deployments/{deploymentName}/operations"} # type: ignore + list_at_management_group_scope.metadata = {"url": "/providers/Microsoft.Management/managementGroups/{groupId}/providers/Microsoft.Resources/deployments/{deploymentName}/operations"} # type: ignore @distributed_trace def get_at_subscription_scope( - self, - deployment_name: str, - operation_id: str, - **kwargs: Any - ) -> "_models.DeploymentOperation": + self, deployment_name: str, operation_id: str, **kwargs: Any + ) -> _models.DeploymentOperation: """Gets a deployments operation. - :param deployment_name: The name of the deployment. + :param deployment_name: The name of the deployment. Required. :type deployment_name: str - :param operation_id: The ID of the operation to get. + :param operation_id: The ID of the operation to get. Required. :type operation_id: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: DeploymentOperation, or the result of cls(response) + :return: DeploymentOperation or the result of cls(response) :rtype: ~azure.mgmt.resource.resources.v2019_05_01.models.DeploymentOperation - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.DeploymentOperation"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) - api_version = kwargs.pop('api_version', "2019-05-01") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2019-05-01")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[_models.DeploymentOperation] - request = build_deployment_operations_get_at_subscription_scope_request( deployment_name=deployment_name, operation_id=operation_id, subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.get_at_subscription_scope.metadata['url'], + template_url=self.get_at_subscription_scope.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) - deserialized = self._deserialize('DeploymentOperation', pipeline_response) + deserialized = self._deserialize("DeploymentOperation", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - get_at_subscription_scope.metadata = {'url': "/subscriptions/{subscriptionId}/providers/Microsoft.Resources/deployments/{deploymentName}/operations/{operationId}"} # type: ignore - + get_at_subscription_scope.metadata = {"url": "/subscriptions/{subscriptionId}/providers/Microsoft.Resources/deployments/{deploymentName}/operations/{operationId}"} # type: ignore @distributed_trace def list_at_subscription_scope( - self, - deployment_name: str, - top: Optional[int] = None, - **kwargs: Any - ) -> Iterable["_models.DeploymentOperationsListResult"]: + self, deployment_name: str, top: Optional[int] = None, **kwargs: Any + ) -> Iterable["_models.DeploymentOperation"]: """Gets all deployments operations for a deployment. - :param deployment_name: The name of the deployment. + :param deployment_name: The name of the deployment. Required. :type deployment_name: str :param top: The number of results to return. Default value is None. :type top: int :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either DeploymentOperationsListResult or the result of - cls(response) + :return: An iterator like instance of either DeploymentOperation or the result of cls(response) :rtype: - ~azure.core.paging.ItemPaged[~azure.mgmt.resource.resources.v2019_05_01.models.DeploymentOperationsListResult] - :raises: ~azure.core.exceptions.HttpResponseError + ~azure.core.paging.ItemPaged[~azure.mgmt.resource.resources.v2019_05_01.models.DeploymentOperation] + :raises ~azure.core.exceptions.HttpResponseError: """ - api_version = kwargs.pop('api_version', "2019-05-01") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2019-05-01")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[_models.DeploymentOperationsListResult] - cls = kwargs.pop('cls', None) # type: ClsType["_models.DeploymentOperationsListResult"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) + def prepare_request(next_link=None): if not next_link: - + request = build_deployment_operations_list_at_subscription_scope_request( deployment_name=deployment_name, subscription_id=self._config.subscription_id, - api_version=api_version, top=top, - template_url=self.list_at_subscription_scope.metadata['url'], + api_version=api_version, + template_url=self.list_at_subscription_scope.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore else: - - request = build_deployment_operations_list_at_subscription_scope_request( - deployment_name=deployment_name, - subscription_id=self._config.subscription_id, - template_url=next_link, - ) + # make call to next link with the client's api-version + _parsed_next_link = urlparse(next_link) + _next_request_params = case_insensitive_dict(parse_qs(_parsed_next_link.query)) + _next_request_params["api-version"] = self._config.api_version + request = HttpRequest("GET", urljoin(next_link, _parsed_next_link.path), params=_next_request_params) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore request.method = "GET" return request @@ -7135,10 +8133,8 @@ def extract_data(pipeline_response): def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) response = pipeline_response.http_response @@ -7148,128 +8144,131 @@ def get_next(next_link=None): return pipeline_response + return ItemPaged(get_next, extract_data) - return ItemPaged( - get_next, extract_data - ) - list_at_subscription_scope.metadata = {'url': "/subscriptions/{subscriptionId}/providers/Microsoft.Resources/deployments/{deploymentName}/operations"} # type: ignore + list_at_subscription_scope.metadata = {"url": "/subscriptions/{subscriptionId}/providers/Microsoft.Resources/deployments/{deploymentName}/operations"} # type: ignore @distributed_trace def get( - self, - resource_group_name: str, - deployment_name: str, - operation_id: str, - **kwargs: Any - ) -> "_models.DeploymentOperation": + self, resource_group_name: str, deployment_name: str, operation_id: str, **kwargs: Any + ) -> _models.DeploymentOperation: """Gets a deployments operation. :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. :type resource_group_name: str - :param deployment_name: The name of the deployment. + :param deployment_name: The name of the deployment. Required. :type deployment_name: str - :param operation_id: The ID of the operation to get. + :param operation_id: The ID of the operation to get. Required. :type operation_id: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: DeploymentOperation, or the result of cls(response) + :return: DeploymentOperation or the result of cls(response) :rtype: ~azure.mgmt.resource.resources.v2019_05_01.models.DeploymentOperation - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.DeploymentOperation"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + 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', "2019-05-01") # type: str + api_version = kwargs.pop("api_version", _params.pop("api-version", "2019-05-01")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[_models.DeploymentOperation] - request = build_deployment_operations_get_request( resource_group_name=resource_group_name, deployment_name=deployment_name, operation_id=operation_id, subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.get.metadata['url'], + template_url=self.get.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) - deserialized = self._deserialize('DeploymentOperation', pipeline_response) + deserialized = self._deserialize("DeploymentOperation", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - get.metadata = {'url': "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/deployments/{deploymentName}/operations/{operationId}"} # type: ignore - + get.metadata = {"url": "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/deployments/{deploymentName}/operations/{operationId}"} # type: ignore @distributed_trace def list( - self, - resource_group_name: str, - deployment_name: str, - top: Optional[int] = None, - **kwargs: Any - ) -> Iterable["_models.DeploymentOperationsListResult"]: + self, resource_group_name: str, deployment_name: str, top: Optional[int] = None, **kwargs: Any + ) -> Iterable["_models.DeploymentOperation"]: """Gets all deployments operations for a deployment. :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. :type resource_group_name: str - :param deployment_name: The name of the deployment. + :param deployment_name: The name of the deployment. Required. :type deployment_name: str :param top: The number of results to return. Default value is None. :type top: int :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either DeploymentOperationsListResult or the result of - cls(response) + :return: An iterator like instance of either DeploymentOperation or the result of cls(response) :rtype: - ~azure.core.paging.ItemPaged[~azure.mgmt.resource.resources.v2019_05_01.models.DeploymentOperationsListResult] - :raises: ~azure.core.exceptions.HttpResponseError + ~azure.core.paging.ItemPaged[~azure.mgmt.resource.resources.v2019_05_01.models.DeploymentOperation] + :raises ~azure.core.exceptions.HttpResponseError: """ - api_version = kwargs.pop('api_version', "2019-05-01") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2019-05-01")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[_models.DeploymentOperationsListResult] - cls = kwargs.pop('cls', None) # type: ClsType["_models.DeploymentOperationsListResult"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) + def prepare_request(next_link=None): if not next_link: - + request = build_deployment_operations_list_request( resource_group_name=resource_group_name, deployment_name=deployment_name, subscription_id=self._config.subscription_id, - api_version=api_version, top=top, - template_url=self.list.metadata['url'], + 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.url = self._client.format_url(request.url) # type: ignore else: - - request = build_deployment_operations_list_request( - resource_group_name=resource_group_name, - deployment_name=deployment_name, - subscription_id=self._config.subscription_id, - template_url=next_link, - ) + # make call to next link with the client's api-version + _parsed_next_link = urlparse(next_link) + _next_request_params = case_insensitive_dict(parse_qs(_parsed_next_link.query)) + _next_request_params["api-version"] = self._config.api_version + request = HttpRequest("GET", urljoin(next_link, _parsed_next_link.path), params=_next_request_params) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore request.method = "GET" return request @@ -7283,10 +8282,8 @@ def extract_data(pipeline_response): def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) response = pipeline_response.http_response @@ -7296,8 +8293,6 @@ def get_next(next_link=None): return pipeline_response + return ItemPaged(get_next, extract_data) - return ItemPaged( - get_next, extract_data - ) - list.metadata = {'url': "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/deployments/{deploymentName}/operations"} # type: ignore + list.metadata = {"url": "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/deployments/{deploymentName}/operations"} # type: ignore diff --git a/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/resources/v2019_05_01/operations/_patch.py b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/resources/v2019_05_01/operations/_patch.py new file mode 100644 index 0000000000000..f7dd32510333d --- /dev/null +++ b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/resources/v2019_05_01/operations/_patch.py @@ -0,0 +1,20 @@ +# ------------------------------------ +# Copyright (c) Microsoft Corporation. +# Licensed under the MIT License. +# ------------------------------------ +"""Customize generated code here. + +Follow our quickstart for examples: https://aka.ms/azsdk/python/dpcodegen/python/customize +""" +from typing import List + +__all__: List[str] = [] # Add all objects you want publicly available to users at this package level + + +def patch_sdk(): + """Do not remove from this file. + + `patch_sdk` is a last resort escape hatch that allows you to do customizations + you can't accomplish using the techniques described in + https://aka.ms/azsdk/python/dpcodegen/python/customize + """ diff --git a/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/resources/v2019_05_10/__init__.py b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/resources/v2019_05_10/__init__.py index 449220069f2f2..2b201470d075e 100644 --- a/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/resources/v2019_05_10/__init__.py +++ b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/resources/v2019_05_10/__init__.py @@ -10,9 +10,15 @@ from ._version import VERSION __version__ = VERSION -__all__ = ['ResourceManagementClient'] -# `._patch.py` is used for handwritten extensions to the generated code -# Example: https://github.com/Azure/azure-sdk-for-python/blob/main/doc/dev/customize_code/how-to-patch-sdk-code.md -from ._patch import patch_sdk -patch_sdk() +try: + from ._patch import __all__ as _patch_all + from ._patch import * # type: ignore # pylint: disable=unused-wildcard-import +except ImportError: + _patch_all = [] +from ._patch import patch_sdk as _patch_sdk + +__all__ = ["ResourceManagementClient"] +__all__.extend([p for p in _patch_all if p not in __all__]) + +_patch_sdk() diff --git a/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/resources/v2019_05_10/_configuration.py b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/resources/v2019_05_10/_configuration.py index f003b9080f91a..f05d48be2dc2a 100644 --- a/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/resources/v2019_05_10/_configuration.py +++ b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/resources/v2019_05_10/_configuration.py @@ -25,23 +25,18 @@ class ResourceManagementClientConfiguration(Configuration): # pylint: disable=t Note that all parameters used to create this instance are saved as instance attributes. - :param credential: Credential needed for the client to connect to Azure. + :param credential: Credential needed for the client to connect to Azure. Required. :type credential: ~azure.core.credentials.TokenCredential - :param subscription_id: The ID of the target subscription. + :param subscription_id: The ID of the target subscription. Required. :type subscription_id: str :keyword api_version: Api Version. Default value is "2019-05-10". Note that overriding this default value may result in unsupported behavior. :paramtype api_version: str """ - def __init__( - self, - credential: "TokenCredential", - subscription_id: str, - **kwargs: Any - ) -> None: + def __init__(self, credential: "TokenCredential", subscription_id: str, **kwargs: Any) -> None: super(ResourceManagementClientConfiguration, self).__init__(**kwargs) - api_version = kwargs.pop('api_version', "2019-05-10") # type: str + api_version = kwargs.pop("api_version", "2019-05-10") # type: str if credential is None: raise ValueError("Parameter 'credential' must not be None.") @@ -51,23 +46,24 @@ def __init__( self.credential = credential self.subscription_id = subscription_id self.api_version = api_version - self.credential_scopes = kwargs.pop('credential_scopes', ['https://management.azure.com/.default']) - kwargs.setdefault('sdk_moniker', 'mgmt-resource/{}'.format(VERSION)) + self.credential_scopes = kwargs.pop("credential_scopes", ["https://management.azure.com/.default"]) + kwargs.setdefault("sdk_moniker", "mgmt-resource/{}".format(VERSION)) self._configure(**kwargs) def _configure( - self, - **kwargs # type: Any + self, **kwargs # type: Any ): # type: (...) -> 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) - self.logging_policy = kwargs.get('logging_policy') or policies.NetworkTraceLoggingPolicy(**kwargs) - self.http_logging_policy = kwargs.get('http_logging_policy') or ARMHttpLoggingPolicy(**kwargs) - self.retry_policy = kwargs.get('retry_policy') or policies.RetryPolicy(**kwargs) - self.custom_hook_policy = kwargs.get('custom_hook_policy') or policies.CustomHookPolicy(**kwargs) - self.redirect_policy = kwargs.get('redirect_policy') or policies.RedirectPolicy(**kwargs) - self.authentication_policy = kwargs.get('authentication_policy') + 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) + self.logging_policy = kwargs.get("logging_policy") or policies.NetworkTraceLoggingPolicy(**kwargs) + self.http_logging_policy = kwargs.get("http_logging_policy") or ARMHttpLoggingPolicy(**kwargs) + self.retry_policy = kwargs.get("retry_policy") or policies.RetryPolicy(**kwargs) + self.custom_hook_policy = kwargs.get("custom_hook_policy") or policies.CustomHookPolicy(**kwargs) + self.redirect_policy = kwargs.get("redirect_policy") or policies.RedirectPolicy(**kwargs) + self.authentication_policy = kwargs.get("authentication_policy") if self.credential and not self.authentication_policy: - self.authentication_policy = ARMChallengeAuthenticationPolicy(self.credential, *self.credential_scopes, **kwargs) + self.authentication_policy = ARMChallengeAuthenticationPolicy( + self.credential, *self.credential_scopes, **kwargs + ) diff --git a/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/resources/v2019_05_10/_metadata.json b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/resources/v2019_05_10/_metadata.json index 811d80a4fae82..63103d1b94f49 100644 --- a/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/resources/v2019_05_10/_metadata.json +++ b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/resources/v2019_05_10/_metadata.json @@ -10,20 +10,20 @@ "azure_arm": true, "has_lro_operations": true, "client_side_validation": false, - "sync_imports": "{\"typing\": {\"azurecore\": {\"azure.core.credentials\": [\"TokenCredential\"]}}, \"regular\": {\"azurecore\": {\"azure.profiles\": [\"KnownProfiles\", \"ProfileDefinition\"], \"azure.profiles.multiapiclient\": [\"MultiApiClientMixin\"], \"azure.mgmt.core\": [\"ARMPipelineClient\"]}, \"local\": {\"._configuration\": [\"ResourceManagementClientConfiguration\"]}, \"thirdparty\": {\"msrest\": [\"Deserializer\", \"Serializer\"]}}, \"conditional\": {\"stdlib\": {\"typing\": [\"Any\", \"Optional\"]}}}", - "async_imports": "{\"typing\": {\"azurecore\": {\"azure.core.credentials_async\": [\"AsyncTokenCredential\"], \"azure.core.credentials\": [\"TokenCredential\"]}}, \"regular\": {\"azurecore\": {\"azure.profiles\": [\"KnownProfiles\", \"ProfileDefinition\"], \"azure.profiles.multiapiclient\": [\"MultiApiClientMixin\"], \"azure.mgmt.core\": [\"AsyncARMPipelineClient\"]}, \"local\": {\"._configuration\": [\"ResourceManagementClientConfiguration\"]}, \"thirdparty\": {\"msrest\": [\"Deserializer\", \"Serializer\"]}}, \"conditional\": {\"stdlib\": {\"typing\": [\"Any\", \"Optional\"]}}}" + "sync_imports": "{\"conditional\": {\"stdlib\": {\"typing\": [\"Any\", \"Optional\"]}}, \"regular\": {\"azurecore\": {\"azure.mgmt.core\": [\"ARMPipelineClient\"], \"azure.profiles\": [\"KnownProfiles\", \"ProfileDefinition\"], \"azure.profiles.multiapiclient\": [\"MultiApiClientMixin\"]}, \"local\": {\"._configuration\": [\"ResourceManagementClientConfiguration\"], \".._serialization\": [\"Deserializer\", \"Serializer\"]}}, \"typing\": {\"azurecore\": {\"azure.core.credentials\": [\"TokenCredential\"]}}}", + "async_imports": "{\"conditional\": {\"stdlib\": {\"typing\": [\"Any\", \"Optional\"]}}, \"regular\": {\"azurecore\": {\"azure.mgmt.core\": [\"AsyncARMPipelineClient\"], \"azure.profiles\": [\"KnownProfiles\", \"ProfileDefinition\"], \"azure.profiles.multiapiclient\": [\"MultiApiClientMixin\"]}, \"local\": {\"._configuration\": [\"ResourceManagementClientConfiguration\"], \"..._serialization\": [\"Deserializer\", \"Serializer\"]}}, \"typing\": {\"azurecore\": {\"azure.core.credentials_async\": [\"AsyncTokenCredential\"]}}}" }, "global_parameters": { "sync": { "credential": { - "signature": "credential, # type: \"TokenCredential\"", - "description": "Credential needed for the client to connect to Azure.", + "signature": "credential: \"TokenCredential\",", + "description": "Credential needed for the client to connect to Azure. Required.", "docstring_type": "~azure.core.credentials.TokenCredential", "required": true }, "subscription_id": { - "signature": "subscription_id, # type: str", - "description": "The ID of the target subscription.", + "signature": "subscription_id: str,", + "description": "The ID of the target subscription. Required.", "docstring_type": "str", "required": true } @@ -31,13 +31,13 @@ "async": { "credential": { "signature": "credential: \"AsyncTokenCredential\",", - "description": "Credential needed for the client to connect to Azure.", + "description": "Credential needed for the client to connect to Azure. Required.", "docstring_type": "~azure.core.credentials_async.AsyncTokenCredential", "required": true }, "subscription_id": { "signature": "subscription_id: str,", - "description": "The ID of the target subscription.", + "description": "The ID of the target subscription. Required.", "docstring_type": "str", "required": true } @@ -54,7 +54,7 @@ "required": false }, "base_url": { - "signature": "base_url=\"https://management.azure.com\", # type: str", + "signature": "base_url: str = \"https://management.azure.com\",", "description": "Service URL", "docstring_type": "str", "required": false diff --git a/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/resources/v2019_05_10/_patch.py b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/resources/v2019_05_10/_patch.py index 74e48ecd07cf3..f99e77fef9861 100644 --- a/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/resources/v2019_05_10/_patch.py +++ b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/resources/v2019_05_10/_patch.py @@ -28,4 +28,4 @@ # This file is used for handwritten extensions to the generated code. Example: # https://github.com/Azure/azure-sdk-for-python/blob/main/doc/dev/customize_code/how-to-patch-sdk-code.md def patch_sdk(): - pass \ No newline at end of file + pass diff --git a/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/resources/v2019_05_10/_resource_management_client.py b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/resources/v2019_05_10/_resource_management_client.py index 6befea77be39c..e8712d17a64c3 100644 --- a/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/resources/v2019_05_10/_resource_management_client.py +++ b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/resources/v2019_05_10/_resource_management_client.py @@ -9,20 +9,28 @@ from copy import deepcopy from typing import Any, TYPE_CHECKING -from msrest import Deserializer, Serializer - from azure.core.rest import HttpRequest, HttpResponse from azure.mgmt.core import ARMPipelineClient from . import models +from .._serialization import Deserializer, Serializer from ._configuration import ResourceManagementClientConfiguration -from .operations import DeploymentOperationsOperations, DeploymentsOperations, Operations, ProvidersOperations, ResourceGroupsOperations, ResourcesOperations, TagsOperations +from .operations import ( + DeploymentOperationsOperations, + DeploymentsOperations, + Operations, + ProvidersOperations, + ResourceGroupsOperations, + ResourcesOperations, + TagsOperations, +) if TYPE_CHECKING: # pylint: disable=unused-import,ungrouped-imports from azure.core.credentials import TokenCredential -class ResourceManagementClient: # pylint: disable=too-many-instance-attributes + +class ResourceManagementClient: # pylint: disable=client-accepts-api-version-keyword,too-many-instance-attributes """Provides operations for working with resources and resource groups. :ivar operations: Operations operations @@ -42,9 +50,9 @@ class ResourceManagementClient: # pylint: disable=too-many-instance-attribute :ivar deployment_operations: DeploymentOperationsOperations operations :vartype deployment_operations: azure.mgmt.resource.resources.v2019_05_10.operations.DeploymentOperationsOperations - :param credential: Credential needed for the client to connect to Azure. + :param credential: Credential needed for the client to connect to Azure. Required. :type credential: ~azure.core.credentials.TokenCredential - :param subscription_id: The ID of the target subscription. + :param subscription_id: The ID of the target subscription. Required. :type subscription_id: str :param base_url: Service URL. Default value is "https://management.azure.com". :type base_url: str @@ -62,7 +70,9 @@ def __init__( base_url: str = "https://management.azure.com", **kwargs: Any ) -> None: - self._config = ResourceManagementClientConfiguration(credential=credential, subscription_id=subscription_id, **kwargs) + self._config = ResourceManagementClientConfiguration( + credential=credential, subscription_id=subscription_id, **kwargs + ) self._client = ARMPipelineClient(base_url=base_url, config=self._config, **kwargs) client_models = {k: v for k, v in models.__dict__.items() if isinstance(v, type)} @@ -75,14 +85,11 @@ def __init__( self.resources = ResourcesOperations(self._client, self._config, self._serialize, self._deserialize) self.resource_groups = ResourceGroupsOperations(self._client, self._config, self._serialize, self._deserialize) self.tags = TagsOperations(self._client, self._config, self._serialize, self._deserialize) - self.deployment_operations = DeploymentOperationsOperations(self._client, self._config, self._serialize, self._deserialize) - + self.deployment_operations = DeploymentOperationsOperations( + self._client, self._config, self._serialize, self._deserialize + ) - def _send_request( - self, - request: HttpRequest, - **kwargs: Any - ) -> HttpResponse: + def _send_request(self, request: HttpRequest, **kwargs: Any) -> HttpResponse: """Runs the network request through the client's chained policies. >>> from azure.core.rest import HttpRequest @@ -91,7 +98,7 @@ def _send_request( >>> response = client._send_request(request) - For more information on this code flow, see https://aka.ms/azsdk/python/protocol/quickstart + For more information on this code flow, see https://aka.ms/azsdk/dpcodegen/python/send_request :param request: The network request you want to make. Required. :type request: ~azure.core.rest.HttpRequest diff --git a/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/resources/v2019_05_10/_vendor.py b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/resources/v2019_05_10/_vendor.py index 138f663c53a4e..9aad73fc743e7 100644 --- a/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/resources/v2019_05_10/_vendor.py +++ b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/resources/v2019_05_10/_vendor.py @@ -7,6 +7,7 @@ from azure.core.pipeline.transport import HttpRequest + def _convert_request(request, files=None): data = request.content if not files else None request = HttpRequest(method=request.method, url=request.url, headers=request.headers, data=data) @@ -14,6 +15,7 @@ def _convert_request(request, files=None): request.set_formdata_body(files) return request + def _format_url_section(template, **kwargs): components = template.split("/") while components: @@ -21,7 +23,5 @@ def _format_url_section(template, **kwargs): 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 - ] + components = [c for c in formatted_components if "{}".format(key.args[0]) not in c] template = "/".join(components) diff --git a/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/resources/v2019_05_10/_version.py b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/resources/v2019_05_10/_version.py index a012ac01c480c..e5754a47ce68f 100644 --- a/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/resources/v2019_05_10/_version.py +++ b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/resources/v2019_05_10/_version.py @@ -6,4 +6,4 @@ # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -VERSION = "21.1.0" +VERSION = "1.0.0b1" diff --git a/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/resources/v2019_05_10/aio/__init__.py b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/resources/v2019_05_10/aio/__init__.py index c6c3cf64a37a6..98d6782c2530c 100644 --- a/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/resources/v2019_05_10/aio/__init__.py +++ b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/resources/v2019_05_10/aio/__init__.py @@ -7,9 +7,15 @@ # -------------------------------------------------------------------------- from ._resource_management_client import ResourceManagementClient -__all__ = ['ResourceManagementClient'] -# `._patch.py` is used for handwritten extensions to the generated code -# Example: https://github.com/Azure/azure-sdk-for-python/blob/main/doc/dev/customize_code/how-to-patch-sdk-code.md -from ._patch import patch_sdk -patch_sdk() +try: + from ._patch import __all__ as _patch_all + from ._patch import * # type: ignore # pylint: disable=unused-wildcard-import +except ImportError: + _patch_all = [] +from ._patch import patch_sdk as _patch_sdk + +__all__ = ["ResourceManagementClient"] +__all__.extend([p for p in _patch_all if p not in __all__]) + +_patch_sdk() diff --git a/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/resources/v2019_05_10/aio/_configuration.py b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/resources/v2019_05_10/aio/_configuration.py index a0adeed1b38b6..e4a185f275d29 100644 --- a/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/resources/v2019_05_10/aio/_configuration.py +++ b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/resources/v2019_05_10/aio/_configuration.py @@ -25,23 +25,18 @@ class ResourceManagementClientConfiguration(Configuration): # pylint: disable=t Note that all parameters used to create this instance are saved as instance attributes. - :param credential: Credential needed for the client to connect to Azure. + :param credential: Credential needed for the client to connect to Azure. Required. :type credential: ~azure.core.credentials_async.AsyncTokenCredential - :param subscription_id: The ID of the target subscription. + :param subscription_id: The ID of the target subscription. Required. :type subscription_id: str :keyword api_version: Api Version. Default value is "2019-05-10". Note that overriding this default value may result in unsupported behavior. :paramtype api_version: str """ - def __init__( - self, - credential: "AsyncTokenCredential", - subscription_id: str, - **kwargs: Any - ) -> None: + def __init__(self, credential: "AsyncTokenCredential", subscription_id: str, **kwargs: Any) -> None: super(ResourceManagementClientConfiguration, self).__init__(**kwargs) - api_version = kwargs.pop('api_version', "2019-05-10") # type: str + api_version = kwargs.pop("api_version", "2019-05-10") # type: str if credential is None: raise ValueError("Parameter 'credential' must not be None.") @@ -51,22 +46,21 @@ def __init__( self.credential = credential self.subscription_id = subscription_id self.api_version = api_version - self.credential_scopes = kwargs.pop('credential_scopes', ['https://management.azure.com/.default']) - kwargs.setdefault('sdk_moniker', 'mgmt-resource/{}'.format(VERSION)) + self.credential_scopes = kwargs.pop("credential_scopes", ["https://management.azure.com/.default"]) + kwargs.setdefault("sdk_moniker", "mgmt-resource/{}".format(VERSION)) self._configure(**kwargs) - 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) - self.logging_policy = kwargs.get('logging_policy') or policies.NetworkTraceLoggingPolicy(**kwargs) - self.http_logging_policy = kwargs.get('http_logging_policy') or ARMHttpLoggingPolicy(**kwargs) - self.retry_policy = kwargs.get('retry_policy') or policies.AsyncRetryPolicy(**kwargs) - self.custom_hook_policy = kwargs.get('custom_hook_policy') or policies.CustomHookPolicy(**kwargs) - self.redirect_policy = kwargs.get('redirect_policy') or policies.AsyncRedirectPolicy(**kwargs) - self.authentication_policy = kwargs.get('authentication_policy') + 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) + self.logging_policy = kwargs.get("logging_policy") or policies.NetworkTraceLoggingPolicy(**kwargs) + self.http_logging_policy = kwargs.get("http_logging_policy") or ARMHttpLoggingPolicy(**kwargs) + self.retry_policy = kwargs.get("retry_policy") or policies.AsyncRetryPolicy(**kwargs) + self.custom_hook_policy = kwargs.get("custom_hook_policy") or policies.CustomHookPolicy(**kwargs) + self.redirect_policy = kwargs.get("redirect_policy") or policies.AsyncRedirectPolicy(**kwargs) + self.authentication_policy = kwargs.get("authentication_policy") if self.credential and not self.authentication_policy: - self.authentication_policy = AsyncARMChallengeAuthenticationPolicy(self.credential, *self.credential_scopes, **kwargs) + self.authentication_policy = AsyncARMChallengeAuthenticationPolicy( + self.credential, *self.credential_scopes, **kwargs + ) diff --git a/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/resources/v2019_05_10/aio/_patch.py b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/resources/v2019_05_10/aio/_patch.py index 74e48ecd07cf3..f99e77fef9861 100644 --- a/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/resources/v2019_05_10/aio/_patch.py +++ b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/resources/v2019_05_10/aio/_patch.py @@ -28,4 +28,4 @@ # This file is used for handwritten extensions to the generated code. Example: # https://github.com/Azure/azure-sdk-for-python/blob/main/doc/dev/customize_code/how-to-patch-sdk-code.md def patch_sdk(): - pass \ No newline at end of file + pass diff --git a/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/resources/v2019_05_10/aio/_resource_management_client.py b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/resources/v2019_05_10/aio/_resource_management_client.py index 090e5ad335bf4..506f308d51b75 100644 --- a/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/resources/v2019_05_10/aio/_resource_management_client.py +++ b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/resources/v2019_05_10/aio/_resource_management_client.py @@ -9,20 +9,28 @@ from copy import deepcopy from typing import Any, Awaitable, TYPE_CHECKING -from msrest import Deserializer, Serializer - from azure.core.rest import AsyncHttpResponse, HttpRequest from azure.mgmt.core import AsyncARMPipelineClient from .. import models +from ..._serialization import Deserializer, Serializer from ._configuration import ResourceManagementClientConfiguration -from .operations import DeploymentOperationsOperations, DeploymentsOperations, Operations, ProvidersOperations, ResourceGroupsOperations, ResourcesOperations, TagsOperations +from .operations import ( + DeploymentOperationsOperations, + DeploymentsOperations, + Operations, + ProvidersOperations, + ResourceGroupsOperations, + ResourcesOperations, + TagsOperations, +) if TYPE_CHECKING: # pylint: disable=unused-import,ungrouped-imports from azure.core.credentials_async import AsyncTokenCredential -class ResourceManagementClient: # pylint: disable=too-many-instance-attributes + +class ResourceManagementClient: # pylint: disable=client-accepts-api-version-keyword,too-many-instance-attributes """Provides operations for working with resources and resource groups. :ivar operations: Operations operations @@ -44,9 +52,9 @@ class ResourceManagementClient: # pylint: disable=too-many-instance-attribute :ivar deployment_operations: DeploymentOperationsOperations operations :vartype deployment_operations: azure.mgmt.resource.resources.v2019_05_10.aio.operations.DeploymentOperationsOperations - :param credential: Credential needed for the client to connect to Azure. + :param credential: Credential needed for the client to connect to Azure. Required. :type credential: ~azure.core.credentials_async.AsyncTokenCredential - :param subscription_id: The ID of the target subscription. + :param subscription_id: The ID of the target subscription. Required. :type subscription_id: str :param base_url: Service URL. Default value is "https://management.azure.com". :type base_url: str @@ -64,7 +72,9 @@ def __init__( base_url: str = "https://management.azure.com", **kwargs: Any ) -> None: - self._config = ResourceManagementClientConfiguration(credential=credential, subscription_id=subscription_id, **kwargs) + self._config = ResourceManagementClientConfiguration( + credential=credential, subscription_id=subscription_id, **kwargs + ) self._client = AsyncARMPipelineClient(base_url=base_url, config=self._config, **kwargs) client_models = {k: v for k, v in models.__dict__.items() if isinstance(v, type)} @@ -77,14 +87,11 @@ def __init__( self.resources = ResourcesOperations(self._client, self._config, self._serialize, self._deserialize) self.resource_groups = ResourceGroupsOperations(self._client, self._config, self._serialize, self._deserialize) self.tags = TagsOperations(self._client, self._config, self._serialize, self._deserialize) - self.deployment_operations = DeploymentOperationsOperations(self._client, self._config, self._serialize, self._deserialize) - + self.deployment_operations = DeploymentOperationsOperations( + self._client, self._config, self._serialize, self._deserialize + ) - def _send_request( - self, - request: HttpRequest, - **kwargs: Any - ) -> Awaitable[AsyncHttpResponse]: + def _send_request(self, request: HttpRequest, **kwargs: Any) -> Awaitable[AsyncHttpResponse]: """Runs the network request through the client's chained policies. >>> from azure.core.rest import HttpRequest @@ -93,7 +100,7 @@ def _send_request( >>> response = await client._send_request(request) - For more information on this code flow, see https://aka.ms/azsdk/python/protocol/quickstart + For more information on this code flow, see https://aka.ms/azsdk/dpcodegen/python/send_request :param request: The network request you want to make. Required. :type request: ~azure.core.rest.HttpRequest diff --git a/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/resources/v2019_05_10/aio/operations/__init__.py b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/resources/v2019_05_10/aio/operations/__init__.py index 53876d82bf5d7..804fee65e3137 100644 --- a/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/resources/v2019_05_10/aio/operations/__init__.py +++ b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/resources/v2019_05_10/aio/operations/__init__.py @@ -14,12 +14,18 @@ from ._operations import TagsOperations from ._operations import DeploymentOperationsOperations +from ._patch import __all__ as _patch_all +from ._patch import * # type: ignore # pylint: disable=unused-wildcard-import +from ._patch import patch_sdk as _patch_sdk + __all__ = [ - 'Operations', - 'DeploymentsOperations', - 'ProvidersOperations', - 'ResourcesOperations', - 'ResourceGroupsOperations', - 'TagsOperations', - 'DeploymentOperationsOperations', + "Operations", + "DeploymentsOperations", + "ProvidersOperations", + "ResourcesOperations", + "ResourceGroupsOperations", + "TagsOperations", + "DeploymentOperationsOperations", ] +__all__.extend([p for p in _patch_all if p not in __all__]) +_patch_sdk() diff --git a/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/resources/v2019_05_10/aio/operations/_operations.py b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/resources/v2019_05_10/aio/operations/_operations.py index c9677f2ab23f9..0549955796cf3 100644 --- a/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/resources/v2019_05_10/aio/operations/_operations.py +++ b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/resources/v2019_05_10/aio/operations/_operations.py @@ -6,84 +6,170 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -from typing import Any, AsyncIterable, Callable, Dict, Optional, TypeVar, Union +import sys +from typing import Any, AsyncIterable, Callable, Dict, IO, Optional, TypeVar, Union, cast, overload +from urllib.parse import parse_qs, urljoin, urlparse from azure.core.async_paging import AsyncItemPaged, AsyncList -from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error +from azure.core.exceptions import ( + ClientAuthenticationError, + HttpResponseError, + ResourceExistsError, + ResourceNotFoundError, + ResourceNotModifiedError, + map_error, +) from azure.core.pipeline import PipelineResponse from azure.core.pipeline.transport import AsyncHttpResponse from azure.core.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 from azure.mgmt.core.polling.async_arm_polling import AsyncARMPolling from ... import models as _models from ..._vendor import _convert_request -from ...operations._operations import build_deployment_operations_get_at_management_group_scope_request, build_deployment_operations_get_at_subscription_scope_request, build_deployment_operations_get_request, build_deployment_operations_list_at_management_group_scope_request, build_deployment_operations_list_at_subscription_scope_request, build_deployment_operations_list_request, build_deployments_calculate_template_hash_request, build_deployments_cancel_at_management_group_scope_request, build_deployments_cancel_at_subscription_scope_request, build_deployments_cancel_request, build_deployments_check_existence_at_management_group_scope_request, build_deployments_check_existence_at_subscription_scope_request, build_deployments_check_existence_request, build_deployments_create_or_update_at_management_group_scope_request_initial, build_deployments_create_or_update_at_subscription_scope_request_initial, build_deployments_create_or_update_request_initial, build_deployments_delete_at_management_group_scope_request_initial, build_deployments_delete_at_subscription_scope_request_initial, build_deployments_delete_request_initial, build_deployments_export_template_at_management_group_scope_request, build_deployments_export_template_at_subscription_scope_request, build_deployments_export_template_request, build_deployments_get_at_management_group_scope_request, build_deployments_get_at_subscription_scope_request, build_deployments_get_request, build_deployments_list_at_management_group_scope_request, build_deployments_list_at_subscription_scope_request, build_deployments_list_by_resource_group_request, build_deployments_validate_at_management_group_scope_request, build_deployments_validate_at_subscription_scope_request, build_deployments_validate_request, build_operations_list_request, build_providers_get_at_tenant_scope_request, build_providers_get_request, build_providers_list_at_tenant_scope_request, build_providers_list_request, build_providers_register_request, build_providers_unregister_request, build_resource_groups_check_existence_request, build_resource_groups_create_or_update_request, build_resource_groups_delete_request_initial, build_resource_groups_export_template_request, build_resource_groups_get_request, build_resource_groups_list_request, build_resource_groups_update_request, build_resources_check_existence_by_id_request, build_resources_check_existence_request, build_resources_create_or_update_by_id_request_initial, build_resources_create_or_update_request_initial, build_resources_delete_by_id_request_initial, build_resources_delete_request_initial, build_resources_get_by_id_request, build_resources_get_request, build_resources_list_by_resource_group_request, build_resources_list_request, build_resources_move_resources_request_initial, build_resources_update_by_id_request_initial, build_resources_update_request_initial, build_resources_validate_move_resources_request_initial, build_tags_create_or_update_request, build_tags_create_or_update_value_request, build_tags_delete_request, build_tags_delete_value_request, build_tags_list_request -T = TypeVar('T') +from ...operations._operations import ( + build_deployment_operations_get_at_management_group_scope_request, + build_deployment_operations_get_at_subscription_scope_request, + build_deployment_operations_get_request, + build_deployment_operations_list_at_management_group_scope_request, + build_deployment_operations_list_at_subscription_scope_request, + build_deployment_operations_list_request, + build_deployments_calculate_template_hash_request, + build_deployments_cancel_at_management_group_scope_request, + build_deployments_cancel_at_subscription_scope_request, + build_deployments_cancel_request, + build_deployments_check_existence_at_management_group_scope_request, + build_deployments_check_existence_at_subscription_scope_request, + build_deployments_check_existence_request, + build_deployments_create_or_update_at_management_group_scope_request, + build_deployments_create_or_update_at_subscription_scope_request, + build_deployments_create_or_update_request, + build_deployments_delete_at_management_group_scope_request, + build_deployments_delete_at_subscription_scope_request, + build_deployments_delete_request, + build_deployments_export_template_at_management_group_scope_request, + build_deployments_export_template_at_subscription_scope_request, + build_deployments_export_template_request, + build_deployments_get_at_management_group_scope_request, + build_deployments_get_at_subscription_scope_request, + build_deployments_get_request, + build_deployments_list_at_management_group_scope_request, + build_deployments_list_at_subscription_scope_request, + build_deployments_list_by_resource_group_request, + build_deployments_validate_at_management_group_scope_request, + build_deployments_validate_at_subscription_scope_request, + build_deployments_validate_request, + build_operations_list_request, + build_providers_get_at_tenant_scope_request, + build_providers_get_request, + build_providers_list_at_tenant_scope_request, + build_providers_list_request, + build_providers_register_request, + build_providers_unregister_request, + build_resource_groups_check_existence_request, + build_resource_groups_create_or_update_request, + build_resource_groups_delete_request, + build_resource_groups_export_template_request, + build_resource_groups_get_request, + build_resource_groups_list_request, + build_resource_groups_update_request, + build_resources_check_existence_by_id_request, + build_resources_check_existence_request, + build_resources_create_or_update_by_id_request, + build_resources_create_or_update_request, + build_resources_delete_by_id_request, + build_resources_delete_request, + build_resources_get_by_id_request, + build_resources_get_request, + build_resources_list_by_resource_group_request, + build_resources_list_request, + build_resources_move_resources_request, + build_resources_update_by_id_request, + build_resources_update_request, + build_resources_validate_move_resources_request, + build_tags_create_or_update_request, + build_tags_create_or_update_value_request, + build_tags_delete_request, + build_tags_delete_value_request, + build_tags_list_request, +) + +T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] +if sys.version_info >= (3, 9): + from collections.abc import MutableMapping +else: + from typing import MutableMapping # type: ignore # pylint: disable=ungrouped-imports +JSON = MutableMapping[str, Any] # pylint: disable=unsubscriptable-object -class Operations: - """Operations async operations. - You should not instantiate this class directly. Instead, you should create a Client instance that - instantiates it for you and attaches it as an attribute. +class Operations: + """ + .. warning:: + **DO NOT** instantiate this class directly. - :ivar models: Alias to model classes used in this operation group. - :type models: ~azure.mgmt.resource.resources.v2019_05_10.models - :param client: Client for service requests. - :param config: Configuration of service client. - :param serializer: An object model serializer. - :param deserializer: An object model deserializer. + Instead, you should access the following operations through + :class:`~azure.mgmt.resource.resources.v2019_05_10.aio.ResourceManagementClient`'s + :attr:`operations` attribute. """ models = _models - def __init__(self, client, config, serializer, deserializer) -> None: - self._client = client - self._serialize = serializer - self._deserialize = deserializer - self._config = config + def __init__(self, *args, **kwargs) -> None: + input_args = list(args) + self._client = input_args.pop(0) if input_args else kwargs.pop("client") + self._config = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") @distributed_trace - def list( - self, - **kwargs: Any - ) -> AsyncIterable["_models.OperationListResult"]: + def list(self, **kwargs: Any) -> AsyncIterable["_models.Operation"]: """Lists all of the available Microsoft.Resources REST API operations. :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either OperationListResult or the result of cls(response) + :return: An iterator like instance of either Operation or the result of cls(response) :rtype: - ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.resource.resources.v2019_05_10.models.OperationListResult] - :raises: ~azure.core.exceptions.HttpResponseError + ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.resource.resources.v2019_05_10.models.Operation] + :raises ~azure.core.exceptions.HttpResponseError: """ - api_version = kwargs.pop('api_version', "2019-05-10") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2019-05-10")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[_models.OperationListResult] - cls = kwargs.pop('cls', None) # type: ClsType["_models.OperationListResult"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) + def prepare_request(next_link=None): if not next_link: - + request = build_operations_list_request( api_version=api_version, - template_url=self.list.metadata['url'], + template_url=self.list.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore else: - - request = build_operations_list_request( - template_url=next_link, - ) + # make call to next link with the client's api-version + _parsed_next_link = urlparse(next_link) + _next_request_params = case_insensitive_dict(parse_qs(_parsed_next_link.query)) + _next_request_params["api-version"] = self._config.api_version + request = HttpRequest("GET", urljoin(next_link, _parsed_next_link.path), params=_next_request_params) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore request.method = "GET" return request @@ -97,10 +183,8 @@ async def extract_data(pipeline_response): async def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) response = pipeline_response.http_response @@ -110,62 +194,62 @@ async def get_next(next_link=None): return pipeline_response + return AsyncItemPaged(get_next, extract_data) - return AsyncItemPaged( - get_next, extract_data - ) - list.metadata = {'url': "/providers/Microsoft.Resources/operations"} # type: ignore -class DeploymentsOperations: # pylint: disable=too-many-public-methods - """DeploymentsOperations async operations. + list.metadata = {"url": "/providers/Microsoft.Resources/operations"} # type: ignore - You should not instantiate this class directly. Instead, you should create a Client instance that - instantiates it for you and attaches it as an attribute. - :ivar models: Alias to model classes used in this operation group. - :type models: ~azure.mgmt.resource.resources.v2019_05_10.models - :param client: Client for service requests. - :param config: Configuration of service client. - :param serializer: An object model serializer. - :param deserializer: An object model deserializer. +class DeploymentsOperations: # pylint: disable=too-many-public-methods + """ + .. warning:: + **DO NOT** instantiate this class directly. + + Instead, you should access the following operations through + :class:`~azure.mgmt.resource.resources.v2019_05_10.aio.ResourceManagementClient`'s + :attr:`deployments` attribute. """ models = _models - def __init__(self, client, config, serializer, deserializer) -> None: - self._client = client - self._serialize = serializer - self._deserialize = deserializer - self._config = config + def __init__(self, *args, **kwargs) -> None: + input_args = list(args) + self._client = input_args.pop(0) if input_args else kwargs.pop("client") + self._config = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") async def _delete_at_management_group_scope_initial( # pylint: disable=inconsistent-return-statements - self, - group_id: str, - deployment_name: str, - **kwargs: Any + self, group_id: str, deployment_name: str, **kwargs: Any ) -> None: - cls = kwargs.pop('cls', None) # type: ClsType[None] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + 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', "2019-05-10") # type: str + api_version = kwargs.pop("api_version", _params.pop("api-version", "2019-05-10")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[None] - - request = build_deployments_delete_at_management_group_scope_request_initial( + request = build_deployments_delete_at_management_group_scope_request( group_id=group_id, deployment_name=deployment_name, api_version=api_version, - template_url=self._delete_at_management_group_scope_initial.metadata['url'], + template_url=self._delete_at_management_group_scope_initial.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [202, 204]: @@ -175,15 +259,11 @@ async def _delete_at_management_group_scope_initial( # pylint: disable=inconsis if cls: return cls(pipeline_response, None, {}) - _delete_at_management_group_scope_initial.metadata = {'url': "/providers/Microsoft.Management/managementGroups/{groupId}/providers/Microsoft.Resources/deployments/{deploymentName}"} # type: ignore - + _delete_at_management_group_scope_initial.metadata = {"url": "/providers/Microsoft.Management/managementGroups/{groupId}/providers/Microsoft.Resources/deployments/{deploymentName}"} # type: ignore @distributed_trace_async - async def begin_delete_at_management_group_scope( # pylint: disable=inconsistent-return-statements - self, - group_id: str, - deployment_name: str, - **kwargs: Any + async def begin_delete_at_management_group_scope( + self, group_id: str, deployment_name: str, **kwargs: Any ) -> AsyncLROPoller[None]: """Deletes a deployment from the deployment history. @@ -195,9 +275,9 @@ async def begin_delete_at_management_group_scope( # pylint: disable=inconsisten process finishes, the URI in the Location header returns a status of 204 on success. If the asynchronous request failed, the URI in the Location header returns an error-level status code. - :param group_id: The management group ID. + :param group_id: The management group ID. Required. :type group_id: str - :param deployment_name: The name of the deployment. + :param deployment_name: The name of the deployment. Required. :type deployment_name: str :keyword callable cls: A custom type or function that will be passed the direct response :keyword str continuation_token: A continuation token to restart a poller from a saved state. @@ -209,86 +289,93 @@ async def begin_delete_at_management_group_scope( # pylint: disable=inconsisten Retry-After header is present. :return: An instance of AsyncLROPoller that returns either None or the result of cls(response) :rtype: ~azure.core.polling.AsyncLROPoller[None] - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - api_version = kwargs.pop('api_version', "2019-05-10") # type: str - polling = kwargs.pop('polling', True) # type: Union[bool, AsyncPollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType[None] - lro_delay = kwargs.pop( - 'polling_interval', - self._config.polling_interval - ) - cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2019-05-10")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[None] + polling = kwargs.pop("polling", True) # type: Union[bool, AsyncPollingMethod] + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token = kwargs.pop("continuation_token", None) # type: Optional[str] if cont_token is None: - raw_result = await self._delete_at_management_group_scope_initial( + raw_result = await self._delete_at_management_group_scope_initial( # type: ignore group_id=group_id, deployment_name=deployment_name, api_version=api_version, - cls=lambda x,y,z: x, + cls=lambda x, y, z: x, + headers=_headers, + params=_params, **kwargs ) - kwargs.pop('error_map', None) + kwargs.pop("error_map", None) - def get_long_running_output(pipeline_response): + def get_long_running_output(pipeline_response): # pylint: disable=inconsistent-return-statements if cls: return cls(pipeline_response, None, {}) - - if polling is True: polling_method = AsyncARMPolling(lro_delay, **kwargs) - elif polling is False: polling_method = AsyncNoPolling() - else: polling_method = polling + if polling is True: + polling_method = cast(AsyncPollingMethod, AsyncARMPolling(lro_delay, **kwargs)) # type: AsyncPollingMethod + elif polling is False: + polling_method = cast(AsyncPollingMethod, AsyncNoPolling()) + else: + polling_method = polling if cont_token: return AsyncLROPoller.from_continuation_token( polling_method=polling_method, continuation_token=cont_token, client=self._client, - deserialization_callback=get_long_running_output + deserialization_callback=get_long_running_output, ) return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) - begin_delete_at_management_group_scope.metadata = {'url': "/providers/Microsoft.Management/managementGroups/{groupId}/providers/Microsoft.Resources/deployments/{deploymentName}"} # type: ignore + begin_delete_at_management_group_scope.metadata = {"url": "/providers/Microsoft.Management/managementGroups/{groupId}/providers/Microsoft.Resources/deployments/{deploymentName}"} # type: ignore @distributed_trace_async async def check_existence_at_management_group_scope( - self, - group_id: str, - deployment_name: str, - **kwargs: Any + self, group_id: str, deployment_name: str, **kwargs: Any ) -> bool: """Checks whether the deployment exists. - :param group_id: The management group ID. + :param group_id: The management group ID. Required. :type group_id: str - :param deployment_name: The name of the deployment. + :param deployment_name: The name of the deployment. Required. :type deployment_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: bool, or the result of cls(response) + :return: bool or the result of cls(response) :rtype: bool - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType[None] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + 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', "2019-05-10") # type: str + api_version = kwargs.pop("api_version", _params.pop("api-version", "2019-05-10")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[None] - request = build_deployments_check_existence_at_management_group_scope_request( group_id=group_id, deployment_name=deployment_name, api_version=api_version, - template_url=self.check_existence_at_management_group_scope.metadata['url'], + template_url=self.check_existence_at_management_group_scope.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [204, 404]: @@ -299,43 +386,52 @@ async def check_existence_at_management_group_scope( return cls(pipeline_response, None, {}) return 200 <= response.status_code <= 299 - check_existence_at_management_group_scope.metadata = {'url': "/providers/Microsoft.Management/managementGroups/{groupId}/providers/Microsoft.Resources/deployments/{deploymentName}"} # type: ignore - + check_existence_at_management_group_scope.metadata = {"url": "/providers/Microsoft.Management/managementGroups/{groupId}/providers/Microsoft.Resources/deployments/{deploymentName}"} # type: ignore async def _create_or_update_at_management_group_scope_initial( - self, - group_id: str, - deployment_name: str, - parameters: "_models.Deployment", - **kwargs: Any - ) -> "_models.DeploymentExtended": - cls = kwargs.pop('cls', None) # type: ClsType["_models.DeploymentExtended"] + self, group_id: str, deployment_name: str, parameters: Union[_models.Deployment, IO], **kwargs: Any + ) -> _models.DeploymentExtended: error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) - api_version = kwargs.pop('api_version', "2019-05-10") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - _json = self._serialize.body(parameters, 'Deployment') + api_version = kwargs.pop("api_version", _params.pop("api-version", "2019-05-10")) # type: str + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.DeploymentExtended] - request = build_deployments_create_or_update_at_management_group_scope_request_initial( + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(parameters, (IO, bytes)): + _content = parameters + else: + _json = self._serialize.body(parameters, "Deployment") + + request = build_deployments_create_or_update_at_management_group_scope_request( group_id=group_id, deployment_name=deployment_name, api_version=api_version, content_type=content_type, json=_json, - template_url=self._create_or_update_at_management_group_scope_initial.metadata['url'], + content=_content, + template_url=self._create_or_update_at_management_group_scope_initial.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200, 201]: @@ -343,37 +439,41 @@ async def _create_or_update_at_management_group_scope_initial( raise HttpResponseError(response=response, error_format=ARMErrorFormat) if response.status_code == 200: - deserialized = self._deserialize('DeploymentExtended', pipeline_response) + deserialized = self._deserialize("DeploymentExtended", pipeline_response) if response.status_code == 201: - deserialized = self._deserialize('DeploymentExtended', pipeline_response) + deserialized = self._deserialize("DeploymentExtended", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - _create_or_update_at_management_group_scope_initial.metadata = {'url': "/providers/Microsoft.Management/managementGroups/{groupId}/providers/Microsoft.Resources/deployments/{deploymentName}"} # type: ignore + _create_or_update_at_management_group_scope_initial.metadata = {"url": "/providers/Microsoft.Management/managementGroups/{groupId}/providers/Microsoft.Resources/deployments/{deploymentName}"} # type: ignore - - @distributed_trace_async + @overload async def begin_create_or_update_at_management_group_scope( self, group_id: str, deployment_name: str, - parameters: "_models.Deployment", + parameters: _models.Deployment, + *, + content_type: str = "application/json", **kwargs: Any - ) -> AsyncLROPoller["_models.DeploymentExtended"]: + ) -> AsyncLROPoller[_models.DeploymentExtended]: """Deploys resources at management group scope. You can provide the template and parameters directly in the request or link to JSON files. - :param group_id: The management group ID. + :param group_id: The management group ID. Required. :type group_id: str - :param deployment_name: The name of the deployment. + :param deployment_name: The name of the deployment. Required. :type deployment_name: str - :param parameters: Additional parameters supplied to the operation. + :param parameters: Additional parameters supplied to the operation. Required. :type parameters: ~azure.mgmt.resource.resources.v2019_05_10.models.Deployment + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str :keyword callable cls: A custom type or function that will be passed the direct response :keyword str continuation_token: A continuation token to restart a poller from a saved state. :keyword polling: By default, your polling method will be AsyncARMPolling. Pass in False for @@ -386,114 +486,187 @@ async def begin_create_or_update_at_management_group_scope( cls(response) :rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.resource.resources.v2019_05_10.models.DeploymentExtended] - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - api_version = kwargs.pop('api_version', "2019-05-10") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] - polling = kwargs.pop('polling', True) # type: Union[bool, AsyncPollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType["_models.DeploymentExtended"] - lro_delay = kwargs.pop( - 'polling_interval', - self._config.polling_interval - ) - cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] + + @overload + async def begin_create_or_update_at_management_group_scope( + self, + group_id: str, + deployment_name: str, + parameters: IO, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> AsyncLROPoller[_models.DeploymentExtended]: + """Deploys resources at management group scope. + + You can provide the template and parameters directly in the request or link to JSON files. + + :param group_id: The management group ID. Required. + :type group_id: str + :param deployment_name: The name of the deployment. Required. + :type deployment_name: str + :param parameters: Additional parameters supplied to the operation. Required. + :type parameters: IO + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be AsyncARMPolling. Pass in False for + this operation to not poll, or pass in your own initialized polling object for a personal + polling strategy. + :paramtype polling: bool or ~azure.core.polling.AsyncPollingMethod + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of AsyncLROPoller that returns either DeploymentExtended or the result of + cls(response) + :rtype: + ~azure.core.polling.AsyncLROPoller[~azure.mgmt.resource.resources.v2019_05_10.models.DeploymentExtended] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace_async + async def begin_create_or_update_at_management_group_scope( + self, group_id: str, deployment_name: str, parameters: Union[_models.Deployment, IO], **kwargs: Any + ) -> AsyncLROPoller[_models.DeploymentExtended]: + """Deploys resources at management group scope. + + You can provide the template and parameters directly in the request or link to JSON files. + + :param group_id: The management group ID. Required. + :type group_id: str + :param deployment_name: The name of the deployment. Required. + :type deployment_name: str + :param parameters: Additional parameters supplied to the operation. Is either a model type or a + IO type. Required. + :type parameters: ~azure.mgmt.resource.resources.v2019_05_10.models.Deployment or IO + :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. + Default value is None. + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be AsyncARMPolling. Pass in False for + this operation to not poll, or pass in your own initialized polling object for a personal + polling strategy. + :paramtype polling: bool or ~azure.core.polling.AsyncPollingMethod + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of AsyncLROPoller that returns either DeploymentExtended or the result of + cls(response) + :rtype: + ~azure.core.polling.AsyncLROPoller[~azure.mgmt.resource.resources.v2019_05_10.models.DeploymentExtended] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _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", "2019-05-10")) # type: str + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.DeploymentExtended] + polling = kwargs.pop("polling", True) # type: Union[bool, AsyncPollingMethod] + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token = kwargs.pop("continuation_token", None) # type: Optional[str] if cont_token is None: - raw_result = await self._create_or_update_at_management_group_scope_initial( + raw_result = await self._create_or_update_at_management_group_scope_initial( # type: ignore group_id=group_id, deployment_name=deployment_name, parameters=parameters, api_version=api_version, content_type=content_type, - cls=lambda x,y,z: x, + cls=lambda x, y, z: x, + headers=_headers, + params=_params, **kwargs ) - kwargs.pop('error_map', None) + kwargs.pop("error_map", None) def get_long_running_output(pipeline_response): - response = pipeline_response.http_response - deserialized = self._deserialize('DeploymentExtended', pipeline_response) + deserialized = self._deserialize("DeploymentExtended", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - - if polling is True: polling_method = AsyncARMPolling(lro_delay, **kwargs) - elif polling is False: polling_method = AsyncNoPolling() - else: polling_method = polling + if polling is True: + polling_method = cast(AsyncPollingMethod, AsyncARMPolling(lro_delay, **kwargs)) # type: AsyncPollingMethod + elif polling is False: + polling_method = cast(AsyncPollingMethod, AsyncNoPolling()) + else: + polling_method = polling if cont_token: return AsyncLROPoller.from_continuation_token( polling_method=polling_method, continuation_token=cont_token, client=self._client, - deserialization_callback=get_long_running_output + deserialization_callback=get_long_running_output, ) return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) - begin_create_or_update_at_management_group_scope.metadata = {'url': "/providers/Microsoft.Management/managementGroups/{groupId}/providers/Microsoft.Resources/deployments/{deploymentName}"} # type: ignore + begin_create_or_update_at_management_group_scope.metadata = {"url": "/providers/Microsoft.Management/managementGroups/{groupId}/providers/Microsoft.Resources/deployments/{deploymentName}"} # type: ignore @distributed_trace_async async def get_at_management_group_scope( - self, - group_id: str, - deployment_name: str, - **kwargs: Any - ) -> "_models.DeploymentExtended": + self, group_id: str, deployment_name: str, **kwargs: Any + ) -> _models.DeploymentExtended: """Gets a deployment. - :param group_id: The management group ID. + :param group_id: The management group ID. Required. :type group_id: str - :param deployment_name: The name of the deployment. + :param deployment_name: The name of the deployment. Required. :type deployment_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: DeploymentExtended, or the result of cls(response) + :return: DeploymentExtended or the result of cls(response) :rtype: ~azure.mgmt.resource.resources.v2019_05_10.models.DeploymentExtended - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.DeploymentExtended"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + 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', "2019-05-10") # type: str + api_version = kwargs.pop("api_version", _params.pop("api-version", "2019-05-10")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[_models.DeploymentExtended] - request = build_deployments_get_at_management_group_scope_request( group_id=group_id, deployment_name=deployment_name, api_version=api_version, - template_url=self.get_at_management_group_scope.metadata['url'], + template_url=self.get_at_management_group_scope.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) - deserialized = self._deserialize('DeploymentExtended', pipeline_response) + deserialized = self._deserialize("DeploymentExtended", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - get_at_management_group_scope.metadata = {'url': "/providers/Microsoft.Management/managementGroups/{groupId}/providers/Microsoft.Resources/deployments/{deploymentName}"} # type: ignore - + get_at_management_group_scope.metadata = {"url": "/providers/Microsoft.Management/managementGroups/{groupId}/providers/Microsoft.Resources/deployments/{deploymentName}"} # type: ignore @distributed_trace_async async def cancel_at_management_group_scope( # pylint: disable=inconsistent-return-statements - self, - group_id: str, - deployment_name: str, - **kwargs: Any + self, group_id: str, deployment_name: str, **kwargs: Any ) -> None: """Cancels a currently running template deployment. @@ -502,38 +675,44 @@ async def cancel_at_management_group_scope( # pylint: disable=inconsistent-retu deployment stops the currently running template deployment and leaves the resources partially deployed. - :param group_id: The management group ID. + :param group_id: The management group ID. Required. :type group_id: str - :param deployment_name: The name of the deployment. + :param deployment_name: The name of the deployment. Required. :type deployment_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: None, or the result of cls(response) + :return: None or the result of cls(response) :rtype: None - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType[None] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) - api_version = kwargs.pop('api_version', "2019-05-10") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2019-05-10")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[None] - request = build_deployments_cancel_at_management_group_scope_request( group_id=group_id, deployment_name=deployment_name, api_version=api_version, - template_url=self.cancel_at_management_group_scope.metadata['url'], + template_url=self.cancel_at_management_group_scope.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [204]: @@ -543,41 +722,107 @@ async def cancel_at_management_group_scope( # pylint: disable=inconsistent-retu if cls: return cls(pipeline_response, None, {}) - cancel_at_management_group_scope.metadata = {'url': "/providers/Microsoft.Management/managementGroups/{groupId}/providers/Microsoft.Resources/deployments/{deploymentName}/cancel"} # type: ignore + cancel_at_management_group_scope.metadata = {"url": "/providers/Microsoft.Management/managementGroups/{groupId}/providers/Microsoft.Resources/deployments/{deploymentName}/cancel"} # type: ignore - - @distributed_trace_async + @overload async def validate_at_management_group_scope( self, group_id: str, deployment_name: str, - parameters: "_models.Deployment", + parameters: _models.Deployment, + *, + content_type: str = "application/json", **kwargs: Any - ) -> "_models.DeploymentValidateResult": + ) -> _models.DeploymentValidateResult: """Validates whether the specified template is syntactically correct and will be accepted by Azure Resource Manager.. - :param group_id: The management group ID. + :param group_id: The management group ID. Required. :type group_id: str - :param deployment_name: The name of the deployment. + :param deployment_name: The name of the deployment. Required. :type deployment_name: str - :param parameters: Parameters to validate. + :param parameters: Parameters to validate. Required. :type parameters: ~azure.mgmt.resource.resources.v2019_05_10.models.Deployment + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: DeploymentValidateResult or the result of cls(response) + :rtype: ~azure.mgmt.resource.resources.v2019_05_10.models.DeploymentValidateResult + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + async def validate_at_management_group_scope( + self, + group_id: str, + deployment_name: str, + parameters: IO, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.DeploymentValidateResult: + """Validates whether the specified template is syntactically correct and will be accepted by Azure + Resource Manager.. + + :param group_id: The management group ID. Required. + :type group_id: str + :param deployment_name: The name of the deployment. Required. + :type deployment_name: str + :param parameters: Parameters to validate. Required. + :type parameters: IO + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: DeploymentValidateResult or the result of cls(response) + :rtype: ~azure.mgmt.resource.resources.v2019_05_10.models.DeploymentValidateResult + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace_async + async def validate_at_management_group_scope( + self, group_id: str, deployment_name: str, parameters: Union[_models.Deployment, IO], **kwargs: Any + ) -> _models.DeploymentValidateResult: + """Validates whether the specified template is syntactically correct and will be accepted by Azure + Resource Manager.. + + :param group_id: The management group ID. Required. + :type group_id: str + :param deployment_name: The name of the deployment. Required. + :type deployment_name: str + :param parameters: Parameters to validate. Is either a model type or a IO type. Required. + :type parameters: ~azure.mgmt.resource.resources.v2019_05_10.models.Deployment or IO + :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. + Default value is None. + :paramtype content_type: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: DeploymentValidateResult, or the result of cls(response) + :return: DeploymentValidateResult or the result of cls(response) :rtype: ~azure.mgmt.resource.resources.v2019_05_10.models.DeploymentValidateResult - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.DeploymentValidateResult"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) - api_version = kwargs.pop('api_version', "2019-05-10") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - _json = self._serialize.body(parameters, 'Deployment') + api_version = kwargs.pop("api_version", _params.pop("api-version", "2019-05-10")) # type: str + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.DeploymentValidateResult] + + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(parameters, (IO, bytes)): + _content = parameters + else: + _json = self._serialize.body(parameters, "Deployment") request = build_deployments_validate_at_management_group_scope_request( group_id=group_id, @@ -585,16 +830,18 @@ async def validate_at_management_group_scope( api_version=api_version, content_type=content_type, json=_json, - template_url=self.validate_at_management_group_scope.metadata['url'], + content=_content, + template_url=self.validate_at_management_group_scope.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200, 400]: @@ -602,87 +849,84 @@ async def validate_at_management_group_scope( raise HttpResponseError(response=response, error_format=ARMErrorFormat) if response.status_code == 200: - deserialized = self._deserialize('DeploymentValidateResult', pipeline_response) + deserialized = self._deserialize("DeploymentValidateResult", pipeline_response) if response.status_code == 400: - deserialized = self._deserialize('DeploymentValidateResult', pipeline_response) + deserialized = self._deserialize("DeploymentValidateResult", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - validate_at_management_group_scope.metadata = {'url': "/providers/Microsoft.Management/managementGroups/{groupId}/providers/Microsoft.Resources/deployments/{deploymentName}/validate"} # type: ignore - + validate_at_management_group_scope.metadata = {"url": "/providers/Microsoft.Management/managementGroups/{groupId}/providers/Microsoft.Resources/deployments/{deploymentName}/validate"} # type: ignore @distributed_trace_async async def export_template_at_management_group_scope( - self, - group_id: str, - deployment_name: str, - **kwargs: Any - ) -> "_models.DeploymentExportResult": + self, group_id: str, deployment_name: str, **kwargs: Any + ) -> _models.DeploymentExportResult: """Exports the template used for specified deployment. - :param group_id: The management group ID. + :param group_id: The management group ID. Required. :type group_id: str - :param deployment_name: The name of the deployment. + :param deployment_name: The name of the deployment. Required. :type deployment_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: DeploymentExportResult, or the result of cls(response) + :return: DeploymentExportResult or the result of cls(response) :rtype: ~azure.mgmt.resource.resources.v2019_05_10.models.DeploymentExportResult - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.DeploymentExportResult"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + 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', "2019-05-10") # type: str + api_version = kwargs.pop("api_version", _params.pop("api-version", "2019-05-10")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[_models.DeploymentExportResult] - request = build_deployments_export_template_at_management_group_scope_request( group_id=group_id, deployment_name=deployment_name, api_version=api_version, - template_url=self.export_template_at_management_group_scope.metadata['url'], + template_url=self.export_template_at_management_group_scope.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) - deserialized = self._deserialize('DeploymentExportResult', pipeline_response) + deserialized = self._deserialize("DeploymentExportResult", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - export_template_at_management_group_scope.metadata = {'url': "/providers/Microsoft.Management/managementGroups/{groupId}/providers/Microsoft.Resources/deployments/{deploymentName}/exportTemplate"} # type: ignore - + export_template_at_management_group_scope.metadata = {"url": "/providers/Microsoft.Management/managementGroups/{groupId}/providers/Microsoft.Resources/deployments/{deploymentName}/exportTemplate"} # type: ignore @distributed_trace def list_at_management_group_scope( - self, - group_id: str, - filter: Optional[str] = None, - top: Optional[int] = None, - **kwargs: Any - ) -> AsyncIterable["_models.DeploymentListResult"]: + self, group_id: str, filter: Optional[str] = None, top: Optional[int] = None, **kwargs: Any + ) -> AsyncIterable["_models.DeploymentExtended"]: """Get all the deployments for a management group. - :param group_id: The management group ID. + :param group_id: The management group ID. Required. :type group_id: str :param filter: The filter to apply on the operation. For example, you can use $filter=provisioningState eq '{state}'. Default value is None. @@ -691,40 +935,48 @@ def list_at_management_group_scope( value is None. :type top: int :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either DeploymentListResult or the result of - cls(response) + :return: An iterator like instance of either DeploymentExtended or the result of cls(response) :rtype: - ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.resource.resources.v2019_05_10.models.DeploymentListResult] - :raises: ~azure.core.exceptions.HttpResponseError + ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.resource.resources.v2019_05_10.models.DeploymentExtended] + :raises ~azure.core.exceptions.HttpResponseError: """ - api_version = kwargs.pop('api_version', "2019-05-10") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2019-05-10")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[_models.DeploymentListResult] - cls = kwargs.pop('cls', None) # type: ClsType["_models.DeploymentListResult"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) + def prepare_request(next_link=None): if not next_link: - + request = build_deployments_list_at_management_group_scope_request( group_id=group_id, - api_version=api_version, filter=filter, top=top, - template_url=self.list_at_management_group_scope.metadata['url'], + api_version=api_version, + template_url=self.list_at_management_group_scope.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore else: - - request = build_deployments_list_at_management_group_scope_request( - group_id=group_id, - template_url=next_link, - ) + # make call to next link with the client's api-version + _parsed_next_link = urlparse(next_link) + _next_request_params = case_insensitive_dict(parse_qs(_parsed_next_link.query)) + _next_request_params["api-version"] = self._config.api_version + request = HttpRequest("GET", urljoin(next_link, _parsed_next_link.path), params=_next_request_params) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore request.method = "GET" return request @@ -738,10 +990,8 @@ async def extract_data(pipeline_response): async def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) response = pipeline_response.http_response @@ -751,40 +1001,42 @@ async def get_next(next_link=None): return pipeline_response + return AsyncItemPaged(get_next, extract_data) - return AsyncItemPaged( - get_next, extract_data - ) - list_at_management_group_scope.metadata = {'url': "/providers/Microsoft.Management/managementGroups/{groupId}/providers/Microsoft.Resources/deployments/"} # type: ignore + list_at_management_group_scope.metadata = {"url": "/providers/Microsoft.Management/managementGroups/{groupId}/providers/Microsoft.Resources/deployments/"} # type: ignore async def _delete_at_subscription_scope_initial( # pylint: disable=inconsistent-return-statements - self, - deployment_name: str, - **kwargs: Any + self, deployment_name: str, **kwargs: Any ) -> None: - cls = kwargs.pop('cls', None) # type: ClsType[None] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + 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', "2019-05-10") # type: str + api_version = kwargs.pop("api_version", _params.pop("api-version", "2019-05-10")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[None] - - request = build_deployments_delete_at_subscription_scope_request_initial( + request = build_deployments_delete_at_subscription_scope_request( deployment_name=deployment_name, subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self._delete_at_subscription_scope_initial.metadata['url'], + template_url=self._delete_at_subscription_scope_initial.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [202, 204]: @@ -794,15 +1046,10 @@ async def _delete_at_subscription_scope_initial( # pylint: disable=inconsistent if cls: return cls(pipeline_response, None, {}) - _delete_at_subscription_scope_initial.metadata = {'url': "/subscriptions/{subscriptionId}/providers/Microsoft.Resources/deployments/{deploymentName}"} # type: ignore - + _delete_at_subscription_scope_initial.metadata = {"url": "/subscriptions/{subscriptionId}/providers/Microsoft.Resources/deployments/{deploymentName}"} # type: ignore @distributed_trace_async - async def begin_delete_at_subscription_scope( # pylint: disable=inconsistent-return-statements - self, - deployment_name: str, - **kwargs: Any - ) -> AsyncLROPoller[None]: + async def begin_delete_at_subscription_scope(self, deployment_name: str, **kwargs: Any) -> AsyncLROPoller[None]: """Deletes a deployment from the deployment history. A template deployment that is currently running cannot be deleted. Deleting a template @@ -813,7 +1060,7 @@ async def begin_delete_at_subscription_scope( # pylint: disable=inconsistent-re process finishes, the URI in the Location header returns a status of 204 on success. If the asynchronous request failed, the URI in the Location header returns an error-level status code. - :param deployment_name: The name of the deployment. + :param deployment_name: The name of the deployment. Required. :type deployment_name: str :keyword callable cls: A custom type or function that will be passed the direct response :keyword str continuation_token: A continuation token to restart a poller from a saved state. @@ -825,82 +1072,88 @@ async def begin_delete_at_subscription_scope( # pylint: disable=inconsistent-re Retry-After header is present. :return: An instance of AsyncLROPoller that returns either None or the result of cls(response) :rtype: ~azure.core.polling.AsyncLROPoller[None] - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - api_version = kwargs.pop('api_version', "2019-05-10") # type: str - polling = kwargs.pop('polling', True) # type: Union[bool, AsyncPollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType[None] - lro_delay = kwargs.pop( - 'polling_interval', - self._config.polling_interval - ) - cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2019-05-10")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[None] + polling = kwargs.pop("polling", True) # type: Union[bool, AsyncPollingMethod] + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token = kwargs.pop("continuation_token", None) # type: Optional[str] if cont_token is None: - raw_result = await self._delete_at_subscription_scope_initial( + raw_result = await self._delete_at_subscription_scope_initial( # type: ignore deployment_name=deployment_name, api_version=api_version, - cls=lambda x,y,z: x, + cls=lambda x, y, z: x, + headers=_headers, + params=_params, **kwargs ) - kwargs.pop('error_map', None) + kwargs.pop("error_map", None) - def get_long_running_output(pipeline_response): + def get_long_running_output(pipeline_response): # pylint: disable=inconsistent-return-statements if cls: return cls(pipeline_response, None, {}) - - if polling is True: polling_method = AsyncARMPolling(lro_delay, **kwargs) - elif polling is False: polling_method = AsyncNoPolling() - else: polling_method = polling + if polling is True: + polling_method = cast(AsyncPollingMethod, AsyncARMPolling(lro_delay, **kwargs)) # type: AsyncPollingMethod + elif polling is False: + polling_method = cast(AsyncPollingMethod, AsyncNoPolling()) + else: + polling_method = polling if cont_token: return AsyncLROPoller.from_continuation_token( polling_method=polling_method, continuation_token=cont_token, client=self._client, - deserialization_callback=get_long_running_output + deserialization_callback=get_long_running_output, ) return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) - begin_delete_at_subscription_scope.metadata = {'url': "/subscriptions/{subscriptionId}/providers/Microsoft.Resources/deployments/{deploymentName}"} # type: ignore + begin_delete_at_subscription_scope.metadata = {"url": "/subscriptions/{subscriptionId}/providers/Microsoft.Resources/deployments/{deploymentName}"} # type: ignore @distributed_trace_async - async def check_existence_at_subscription_scope( - self, - deployment_name: str, - **kwargs: Any - ) -> bool: + async def check_existence_at_subscription_scope(self, deployment_name: str, **kwargs: Any) -> bool: """Checks whether the deployment exists. - :param deployment_name: The name of the deployment. + :param deployment_name: The name of the deployment. Required. :type deployment_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: bool, or the result of cls(response) + :return: bool or the result of cls(response) :rtype: bool - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType[None] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + 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', "2019-05-10") # type: str + api_version = kwargs.pop("api_version", _params.pop("api-version", "2019-05-10")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[None] - request = build_deployments_check_existence_at_subscription_scope_request( deployment_name=deployment_name, subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.check_existence_at_subscription_scope.metadata['url'], + template_url=self.check_existence_at_subscription_scope.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [204, 404]: @@ -911,42 +1164,52 @@ async def check_existence_at_subscription_scope( return cls(pipeline_response, None, {}) return 200 <= response.status_code <= 299 - check_existence_at_subscription_scope.metadata = {'url': "/subscriptions/{subscriptionId}/providers/Microsoft.Resources/deployments/{deploymentName}"} # type: ignore - + check_existence_at_subscription_scope.metadata = {"url": "/subscriptions/{subscriptionId}/providers/Microsoft.Resources/deployments/{deploymentName}"} # type: ignore async def _create_or_update_at_subscription_scope_initial( - self, - deployment_name: str, - parameters: "_models.Deployment", - **kwargs: Any - ) -> "_models.DeploymentExtended": - cls = kwargs.pop('cls', None) # type: ClsType["_models.DeploymentExtended"] + self, deployment_name: str, parameters: Union[_models.Deployment, IO], **kwargs: Any + ) -> _models.DeploymentExtended: error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', "2019-05-10") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + api_version = kwargs.pop("api_version", _params.pop("api-version", "2019-05-10")) # type: str + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.DeploymentExtended] - _json = self._serialize.body(parameters, 'Deployment') + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(parameters, (IO, bytes)): + _content = parameters + else: + _json = self._serialize.body(parameters, "Deployment") - request = build_deployments_create_or_update_at_subscription_scope_request_initial( + request = build_deployments_create_or_update_at_subscription_scope_request( deployment_name=deployment_name, subscription_id=self._config.subscription_id, api_version=api_version, content_type=content_type, json=_json, - template_url=self._create_or_update_at_subscription_scope_initial.metadata['url'], + content=_content, + template_url=self._create_or_update_at_subscription_scope_initial.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200, 201]: @@ -954,34 +1217,38 @@ async def _create_or_update_at_subscription_scope_initial( raise HttpResponseError(response=response, error_format=ARMErrorFormat) if response.status_code == 200: - deserialized = self._deserialize('DeploymentExtended', pipeline_response) + deserialized = self._deserialize("DeploymentExtended", pipeline_response) if response.status_code == 201: - deserialized = self._deserialize('DeploymentExtended', pipeline_response) + deserialized = self._deserialize("DeploymentExtended", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - _create_or_update_at_subscription_scope_initial.metadata = {'url': "/subscriptions/{subscriptionId}/providers/Microsoft.Resources/deployments/{deploymentName}"} # type: ignore - + _create_or_update_at_subscription_scope_initial.metadata = {"url": "/subscriptions/{subscriptionId}/providers/Microsoft.Resources/deployments/{deploymentName}"} # type: ignore - @distributed_trace_async + @overload async def begin_create_or_update_at_subscription_scope( self, deployment_name: str, - parameters: "_models.Deployment", + parameters: _models.Deployment, + *, + content_type: str = "application/json", **kwargs: Any - ) -> AsyncLROPoller["_models.DeploymentExtended"]: + ) -> AsyncLROPoller[_models.DeploymentExtended]: """Deploys resources at subscription scope. You can provide the template and parameters directly in the request or link to JSON files. - :param deployment_name: The name of the deployment. + :param deployment_name: The name of the deployment. Required. :type deployment_name: str - :param parameters: Additional parameters supplied to the operation. + :param parameters: Additional parameters supplied to the operation. Required. :type parameters: ~azure.mgmt.resource.resources.v2019_05_10.models.Deployment + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str :keyword callable cls: A custom type or function that will be passed the direct response :keyword str continuation_token: A continuation token to restart a poller from a saved state. :keyword polling: By default, your polling method will be AsyncARMPolling. Pass in False for @@ -994,109 +1261,172 @@ async def begin_create_or_update_at_subscription_scope( cls(response) :rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.resource.resources.v2019_05_10.models.DeploymentExtended] - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - api_version = kwargs.pop('api_version', "2019-05-10") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] - polling = kwargs.pop('polling', True) # type: Union[bool, AsyncPollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType["_models.DeploymentExtended"] - lro_delay = kwargs.pop( - 'polling_interval', - self._config.polling_interval - ) - cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] + + @overload + async def begin_create_or_update_at_subscription_scope( + self, deployment_name: str, parameters: IO, *, content_type: str = "application/json", **kwargs: Any + ) -> AsyncLROPoller[_models.DeploymentExtended]: + """Deploys resources at subscription scope. + + You can provide the template and parameters directly in the request or link to JSON files. + + :param deployment_name: The name of the deployment. Required. + :type deployment_name: str + :param parameters: Additional parameters supplied to the operation. Required. + :type parameters: IO + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be AsyncARMPolling. Pass in False for + this operation to not poll, or pass in your own initialized polling object for a personal + polling strategy. + :paramtype polling: bool or ~azure.core.polling.AsyncPollingMethod + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of AsyncLROPoller that returns either DeploymentExtended or the result of + cls(response) + :rtype: + ~azure.core.polling.AsyncLROPoller[~azure.mgmt.resource.resources.v2019_05_10.models.DeploymentExtended] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace_async + async def begin_create_or_update_at_subscription_scope( + self, deployment_name: str, parameters: Union[_models.Deployment, IO], **kwargs: Any + ) -> AsyncLROPoller[_models.DeploymentExtended]: + """Deploys resources at subscription scope. + + You can provide the template and parameters directly in the request or link to JSON files. + + :param deployment_name: The name of the deployment. Required. + :type deployment_name: str + :param parameters: Additional parameters supplied to the operation. Is either a model type or a + IO type. Required. + :type parameters: ~azure.mgmt.resource.resources.v2019_05_10.models.Deployment or IO + :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. + Default value is None. + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be AsyncARMPolling. Pass in False for + this operation to not poll, or pass in your own initialized polling object for a personal + polling strategy. + :paramtype polling: bool or ~azure.core.polling.AsyncPollingMethod + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of AsyncLROPoller that returns either DeploymentExtended or the result of + cls(response) + :rtype: + ~azure.core.polling.AsyncLROPoller[~azure.mgmt.resource.resources.v2019_05_10.models.DeploymentExtended] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _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", "2019-05-10")) # type: str + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.DeploymentExtended] + polling = kwargs.pop("polling", True) # type: Union[bool, AsyncPollingMethod] + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token = kwargs.pop("continuation_token", None) # type: Optional[str] if cont_token is None: - raw_result = await self._create_or_update_at_subscription_scope_initial( + raw_result = await self._create_or_update_at_subscription_scope_initial( # type: ignore deployment_name=deployment_name, parameters=parameters, api_version=api_version, content_type=content_type, - cls=lambda x,y,z: x, + cls=lambda x, y, z: x, + headers=_headers, + params=_params, **kwargs ) - kwargs.pop('error_map', None) + kwargs.pop("error_map", None) def get_long_running_output(pipeline_response): - response = pipeline_response.http_response - deserialized = self._deserialize('DeploymentExtended', pipeline_response) + deserialized = self._deserialize("DeploymentExtended", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - - if polling is True: polling_method = AsyncARMPolling(lro_delay, **kwargs) - elif polling is False: polling_method = AsyncNoPolling() - else: polling_method = polling + if polling is True: + polling_method = cast(AsyncPollingMethod, AsyncARMPolling(lro_delay, **kwargs)) # type: AsyncPollingMethod + elif polling is False: + polling_method = cast(AsyncPollingMethod, AsyncNoPolling()) + else: + polling_method = polling if cont_token: return AsyncLROPoller.from_continuation_token( polling_method=polling_method, continuation_token=cont_token, client=self._client, - deserialization_callback=get_long_running_output + deserialization_callback=get_long_running_output, ) return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) - begin_create_or_update_at_subscription_scope.metadata = {'url': "/subscriptions/{subscriptionId}/providers/Microsoft.Resources/deployments/{deploymentName}"} # type: ignore + begin_create_or_update_at_subscription_scope.metadata = {"url": "/subscriptions/{subscriptionId}/providers/Microsoft.Resources/deployments/{deploymentName}"} # type: ignore @distributed_trace_async - async def get_at_subscription_scope( - self, - deployment_name: str, - **kwargs: Any - ) -> "_models.DeploymentExtended": + async def get_at_subscription_scope(self, deployment_name: str, **kwargs: Any) -> _models.DeploymentExtended: """Gets a deployment. - :param deployment_name: The name of the deployment. + :param deployment_name: The name of the deployment. Required. :type deployment_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: DeploymentExtended, or the result of cls(response) + :return: DeploymentExtended or the result of cls(response) :rtype: ~azure.mgmt.resource.resources.v2019_05_10.models.DeploymentExtended - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.DeploymentExtended"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) - api_version = kwargs.pop('api_version', "2019-05-10") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2019-05-10")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[_models.DeploymentExtended] - request = build_deployments_get_at_subscription_scope_request( deployment_name=deployment_name, subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.get_at_subscription_scope.metadata['url'], + template_url=self.get_at_subscription_scope.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) - deserialized = self._deserialize('DeploymentExtended', pipeline_response) + deserialized = self._deserialize("DeploymentExtended", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - get_at_subscription_scope.metadata = {'url': "/subscriptions/{subscriptionId}/providers/Microsoft.Resources/deployments/{deploymentName}"} # type: ignore - + get_at_subscription_scope.metadata = {"url": "/subscriptions/{subscriptionId}/providers/Microsoft.Resources/deployments/{deploymentName}"} # type: ignore @distributed_trace_async async def cancel_at_subscription_scope( # pylint: disable=inconsistent-return-statements - self, - deployment_name: str, - **kwargs: Any + self, deployment_name: str, **kwargs: Any ) -> None: """Cancels a currently running template deployment. @@ -1105,36 +1435,42 @@ async def cancel_at_subscription_scope( # pylint: disable=inconsistent-return-s deployment stops the currently running template deployment and leaves the resources partially deployed. - :param deployment_name: The name of the deployment. + :param deployment_name: The name of the deployment. Required. :type deployment_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: None, or the result of cls(response) + :return: None or the result of cls(response) :rtype: None - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType[None] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) - api_version = kwargs.pop('api_version', "2019-05-10") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2019-05-10")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[None] - request = build_deployments_cancel_at_subscription_scope_request( deployment_name=deployment_name, subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.cancel_at_subscription_scope.metadata['url'], + template_url=self.cancel_at_subscription_scope.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [204]: @@ -1144,38 +1480,94 @@ async def cancel_at_subscription_scope( # pylint: disable=inconsistent-return-s if cls: return cls(pipeline_response, None, {}) - cancel_at_subscription_scope.metadata = {'url': "/subscriptions/{subscriptionId}/providers/Microsoft.Resources/deployments/{deploymentName}/cancel"} # type: ignore + cancel_at_subscription_scope.metadata = {"url": "/subscriptions/{subscriptionId}/providers/Microsoft.Resources/deployments/{deploymentName}/cancel"} # type: ignore - - @distributed_trace_async + @overload async def validate_at_subscription_scope( self, deployment_name: str, - parameters: "_models.Deployment", + parameters: _models.Deployment, + *, + content_type: str = "application/json", **kwargs: Any - ) -> "_models.DeploymentValidateResult": + ) -> _models.DeploymentValidateResult: """Validates whether the specified template is syntactically correct and will be accepted by Azure Resource Manager.. - :param deployment_name: The name of the deployment. + :param deployment_name: The name of the deployment. Required. :type deployment_name: str - :param parameters: Parameters to validate. + :param parameters: Parameters to validate. Required. :type parameters: ~azure.mgmt.resource.resources.v2019_05_10.models.Deployment + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: DeploymentValidateResult, or the result of cls(response) + :return: DeploymentValidateResult or the result of cls(response) :rtype: ~azure.mgmt.resource.resources.v2019_05_10.models.DeploymentValidateResult - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.DeploymentValidateResult"] - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {})) - api_version = kwargs.pop('api_version', "2019-05-10") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] - - _json = self._serialize.body(parameters, 'Deployment') + @overload + async def validate_at_subscription_scope( + self, deployment_name: str, parameters: IO, *, content_type: str = "application/json", **kwargs: Any + ) -> _models.DeploymentValidateResult: + """Validates whether the specified template is syntactically correct and will be accepted by Azure + Resource Manager.. + + :param deployment_name: The name of the deployment. Required. + :type deployment_name: str + :param parameters: Parameters to validate. Required. + :type parameters: IO + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: DeploymentValidateResult or the result of cls(response) + :rtype: ~azure.mgmt.resource.resources.v2019_05_10.models.DeploymentValidateResult + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace_async + async def validate_at_subscription_scope( + self, deployment_name: str, parameters: Union[_models.Deployment, IO], **kwargs: Any + ) -> _models.DeploymentValidateResult: + """Validates whether the specified template is syntactically correct and will be accepted by Azure + Resource Manager.. + + :param deployment_name: The name of the deployment. Required. + :type deployment_name: str + :param parameters: Parameters to validate. Is either a model type or a IO type. Required. + :type parameters: ~azure.mgmt.resource.resources.v2019_05_10.models.Deployment or IO + :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. + Default value is None. + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: DeploymentValidateResult or the result of cls(response) + :rtype: ~azure.mgmt.resource.resources.v2019_05_10.models.DeploymentValidateResult + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2019-05-10")) # type: str + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.DeploymentValidateResult] + + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(parameters, (IO, bytes)): + _content = parameters + else: + _json = self._serialize.body(parameters, "Deployment") request = build_deployments_validate_at_subscription_scope_request( deployment_name=deployment_name, @@ -1183,16 +1575,18 @@ async def validate_at_subscription_scope( api_version=api_version, content_type=content_type, json=_json, - template_url=self.validate_at_subscription_scope.metadata['url'], + content=_content, + template_url=self.validate_at_subscription_scope.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200, 400]: @@ -1200,80 +1594,79 @@ async def validate_at_subscription_scope( raise HttpResponseError(response=response, error_format=ARMErrorFormat) if response.status_code == 200: - deserialized = self._deserialize('DeploymentValidateResult', pipeline_response) + deserialized = self._deserialize("DeploymentValidateResult", pipeline_response) if response.status_code == 400: - deserialized = self._deserialize('DeploymentValidateResult', pipeline_response) + deserialized = self._deserialize("DeploymentValidateResult", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - validate_at_subscription_scope.metadata = {'url': "/subscriptions/{subscriptionId}/providers/Microsoft.Resources/deployments/{deploymentName}/validate"} # type: ignore - + validate_at_subscription_scope.metadata = {"url": "/subscriptions/{subscriptionId}/providers/Microsoft.Resources/deployments/{deploymentName}/validate"} # type: ignore @distributed_trace_async async def export_template_at_subscription_scope( - self, - deployment_name: str, - **kwargs: Any - ) -> "_models.DeploymentExportResult": + self, deployment_name: str, **kwargs: Any + ) -> _models.DeploymentExportResult: """Exports the template used for specified deployment. - :param deployment_name: The name of the deployment. + :param deployment_name: The name of the deployment. Required. :type deployment_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: DeploymentExportResult, or the result of cls(response) + :return: DeploymentExportResult or the result of cls(response) :rtype: ~azure.mgmt.resource.resources.v2019_05_10.models.DeploymentExportResult - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.DeploymentExportResult"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) - api_version = kwargs.pop('api_version', "2019-05-10") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2019-05-10")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[_models.DeploymentExportResult] - request = build_deployments_export_template_at_subscription_scope_request( deployment_name=deployment_name, subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.export_template_at_subscription_scope.metadata['url'], + template_url=self.export_template_at_subscription_scope.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) - deserialized = self._deserialize('DeploymentExportResult', pipeline_response) + deserialized = self._deserialize("DeploymentExportResult", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - export_template_at_subscription_scope.metadata = {'url': "/subscriptions/{subscriptionId}/providers/Microsoft.Resources/deployments/{deploymentName}/exportTemplate"} # type: ignore - + export_template_at_subscription_scope.metadata = {"url": "/subscriptions/{subscriptionId}/providers/Microsoft.Resources/deployments/{deploymentName}/exportTemplate"} # type: ignore @distributed_trace def list_at_subscription_scope( - self, - filter: Optional[str] = None, - top: Optional[int] = None, - **kwargs: Any - ) -> AsyncIterable["_models.DeploymentListResult"]: + self, filter: Optional[str] = None, top: Optional[int] = None, **kwargs: Any + ) -> AsyncIterable["_models.DeploymentExtended"]: """Get all the deployments for a subscription. :param filter: The filter to apply on the operation. For example, you can use @@ -1283,40 +1676,48 @@ def list_at_subscription_scope( value is None. :type top: int :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either DeploymentListResult or the result of - cls(response) + :return: An iterator like instance of either DeploymentExtended or the result of cls(response) :rtype: - ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.resource.resources.v2019_05_10.models.DeploymentListResult] - :raises: ~azure.core.exceptions.HttpResponseError + ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.resource.resources.v2019_05_10.models.DeploymentExtended] + :raises ~azure.core.exceptions.HttpResponseError: """ - api_version = kwargs.pop('api_version', "2019-05-10") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2019-05-10")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[_models.DeploymentListResult] - cls = kwargs.pop('cls', None) # type: ClsType["_models.DeploymentListResult"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) + def prepare_request(next_link=None): if not next_link: - + request = build_deployments_list_at_subscription_scope_request( subscription_id=self._config.subscription_id, - api_version=api_version, filter=filter, top=top, - template_url=self.list_at_subscription_scope.metadata['url'], + api_version=api_version, + template_url=self.list_at_subscription_scope.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore else: - - request = build_deployments_list_at_subscription_scope_request( - subscription_id=self._config.subscription_id, - template_url=next_link, - ) + # make call to next link with the client's api-version + _parsed_next_link = urlparse(next_link) + _next_request_params = case_insensitive_dict(parse_qs(_parsed_next_link.query)) + _next_request_params["api-version"] = self._config.api_version + request = HttpRequest("GET", urljoin(next_link, _parsed_next_link.path), params=_next_request_params) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore request.method = "GET" return request @@ -1330,10 +1731,8 @@ async def extract_data(pipeline_response): async def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) response = pipeline_response.http_response @@ -1343,42 +1742,43 @@ async def get_next(next_link=None): return pipeline_response + return AsyncItemPaged(get_next, extract_data) - return AsyncItemPaged( - get_next, extract_data - ) - list_at_subscription_scope.metadata = {'url': "/subscriptions/{subscriptionId}/providers/Microsoft.Resources/deployments/"} # type: ignore + list_at_subscription_scope.metadata = {"url": "/subscriptions/{subscriptionId}/providers/Microsoft.Resources/deployments/"} # type: ignore async def _delete_initial( # pylint: disable=inconsistent-return-statements - self, - resource_group_name: str, - deployment_name: str, - **kwargs: Any + self, resource_group_name: str, deployment_name: str, **kwargs: Any ) -> None: - cls = kwargs.pop('cls', None) # type: ClsType[None] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) - api_version = kwargs.pop('api_version', "2019-05-10") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - request = build_deployments_delete_request_initial( + api_version = kwargs.pop("api_version", _params.pop("api-version", "2019-05-10")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[None] + + request = build_deployments_delete_request( resource_group_name=resource_group_name, deployment_name=deployment_name, subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self._delete_initial.metadata['url'], + template_url=self._delete_initial.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [202, 204]: @@ -1388,16 +1788,10 @@ 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.Resources/deployments/{deploymentName}"} # type: ignore - + _delete_initial.metadata = {"url": "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/Microsoft.Resources/deployments/{deploymentName}"} # type: ignore @distributed_trace_async - async def begin_delete( # pylint: disable=inconsistent-return-statements - self, - resource_group_name: str, - deployment_name: str, - **kwargs: Any - ) -> AsyncLROPoller[None]: + async def begin_delete(self, resource_group_name: str, deployment_name: str, **kwargs: Any) -> AsyncLROPoller[None]: """Deletes a deployment from the deployment history. A template deployment that is currently running cannot be deleted. Deleting a template @@ -1410,9 +1804,9 @@ async def begin_delete( # pylint: disable=inconsistent-return-statements asynchronous request failed, the URI in the Location header returns an error-level status code. :param resource_group_name: The name of the resource group with the deployment to delete. The - name is case insensitive. + name is case insensitive. Required. :type resource_group_name: str - :param deployment_name: The name of the deployment. + :param deployment_name: The name of the deployment. Required. :type deployment_name: str :keyword callable cls: A custom type or function that will be passed the direct response :keyword str continuation_token: A continuation token to restart a poller from a saved state. @@ -1424,88 +1818,93 @@ async def begin_delete( # pylint: disable=inconsistent-return-statements Retry-After header is present. :return: An instance of AsyncLROPoller that returns either None or the result of cls(response) :rtype: ~azure.core.polling.AsyncLROPoller[None] - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - api_version = kwargs.pop('api_version', "2019-05-10") # type: str - polling = kwargs.pop('polling', True) # type: Union[bool, AsyncPollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType[None] - lro_delay = kwargs.pop( - 'polling_interval', - self._config.polling_interval - ) - cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2019-05-10")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[None] + polling = kwargs.pop("polling", True) # type: Union[bool, AsyncPollingMethod] + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token = kwargs.pop("continuation_token", None) # type: Optional[str] if cont_token is None: - raw_result = await self._delete_initial( + raw_result = await self._delete_initial( # type: ignore resource_group_name=resource_group_name, deployment_name=deployment_name, api_version=api_version, - cls=lambda x,y,z: x, + cls=lambda x, y, z: x, + headers=_headers, + params=_params, **kwargs ) - kwargs.pop('error_map', None) + kwargs.pop("error_map", None) - def get_long_running_output(pipeline_response): + def get_long_running_output(pipeline_response): # pylint: disable=inconsistent-return-statements if cls: return cls(pipeline_response, None, {}) - - if polling is True: polling_method = AsyncARMPolling(lro_delay, **kwargs) - elif polling is False: polling_method = AsyncNoPolling() - else: polling_method = polling + if polling is True: + polling_method = cast(AsyncPollingMethod, AsyncARMPolling(lro_delay, **kwargs)) # type: AsyncPollingMethod + elif polling is False: + polling_method = cast(AsyncPollingMethod, AsyncNoPolling()) + else: + polling_method = polling if cont_token: return AsyncLROPoller.from_continuation_token( polling_method=polling_method, continuation_token=cont_token, client=self._client, - deserialization_callback=get_long_running_output + deserialization_callback=get_long_running_output, ) return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) - begin_delete.metadata = {'url': "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/Microsoft.Resources/deployments/{deploymentName}"} # type: ignore + begin_delete.metadata = {"url": "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/Microsoft.Resources/deployments/{deploymentName}"} # type: ignore @distributed_trace_async - async def check_existence( - self, - resource_group_name: str, - deployment_name: str, - **kwargs: Any - ) -> bool: + async def check_existence(self, resource_group_name: str, deployment_name: str, **kwargs: Any) -> bool: """Checks whether the deployment exists. :param resource_group_name: The name of the resource group with the deployment to check. The - name is case insensitive. + name is case insensitive. Required. :type resource_group_name: str - :param deployment_name: The name of the deployment. + :param deployment_name: The name of the deployment. Required. :type deployment_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: bool, or the result of cls(response) + :return: bool or the result of cls(response) :rtype: bool - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType[None] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + 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', "2019-05-10") # type: str + api_version = kwargs.pop("api_version", _params.pop("api-version", "2019-05-10")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[None] - request = build_deployments_check_existence_request( resource_group_name=resource_group_name, deployment_name=deployment_name, subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.check_existence.metadata['url'], + template_url=self.check_existence.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [204, 404]: @@ -1516,44 +1915,53 @@ async def check_existence( return cls(pipeline_response, None, {}) return 200 <= response.status_code <= 299 - check_existence.metadata = {'url': "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/Microsoft.Resources/deployments/{deploymentName}"} # type: ignore - + check_existence.metadata = {"url": "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/Microsoft.Resources/deployments/{deploymentName}"} # type: ignore async def _create_or_update_initial( - self, - resource_group_name: str, - deployment_name: str, - parameters: "_models.Deployment", - **kwargs: Any - ) -> "_models.DeploymentExtended": - cls = kwargs.pop('cls', None) # type: ClsType["_models.DeploymentExtended"] + self, resource_group_name: str, deployment_name: str, parameters: Union[_models.Deployment, IO], **kwargs: Any + ) -> _models.DeploymentExtended: error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) - api_version = kwargs.pop('api_version', "2019-05-10") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - _json = self._serialize.body(parameters, 'Deployment') + api_version = kwargs.pop("api_version", _params.pop("api-version", "2019-05-10")) # type: str + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.DeploymentExtended] - request = build_deployments_create_or_update_request_initial( + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(parameters, (IO, bytes)): + _content = parameters + else: + _json = self._serialize.body(parameters, "Deployment") + + request = build_deployments_create_or_update_request( resource_group_name=resource_group_name, deployment_name=deployment_name, subscription_id=self._config.subscription_id, api_version=api_version, content_type=content_type, json=_json, - template_url=self._create_or_update_initial.metadata['url'], + content=_content, + template_url=self._create_or_update_initial.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200, 201]: @@ -1561,38 +1969,42 @@ async def _create_or_update_initial( raise HttpResponseError(response=response, error_format=ARMErrorFormat) if response.status_code == 200: - deserialized = self._deserialize('DeploymentExtended', pipeline_response) + deserialized = self._deserialize("DeploymentExtended", pipeline_response) if response.status_code == 201: - deserialized = self._deserialize('DeploymentExtended', pipeline_response) + deserialized = self._deserialize("DeploymentExtended", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - _create_or_update_initial.metadata = {'url': "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/Microsoft.Resources/deployments/{deploymentName}"} # type: ignore + _create_or_update_initial.metadata = {"url": "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/Microsoft.Resources/deployments/{deploymentName}"} # type: ignore - - @distributed_trace_async + @overload async def begin_create_or_update( self, resource_group_name: str, deployment_name: str, - parameters: "_models.Deployment", + parameters: _models.Deployment, + *, + content_type: str = "application/json", **kwargs: Any - ) -> AsyncLROPoller["_models.DeploymentExtended"]: + ) -> AsyncLROPoller[_models.DeploymentExtended]: """Deploys resources to a resource group. You can provide the template and parameters directly in the request or link to JSON files. :param resource_group_name: The name of the resource group to deploy the resources to. The name - is case insensitive. The resource group must already exist. + is case insensitive. The resource group must already exist. Required. :type resource_group_name: str - :param deployment_name: The name of the deployment. + :param deployment_name: The name of the deployment. Required. :type deployment_name: str - :param parameters: Additional parameters supplied to the operation. + :param parameters: Additional parameters supplied to the operation. Required. :type parameters: ~azure.mgmt.resource.resources.v2019_05_10.models.Deployment + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str :keyword callable cls: A custom type or function that will be passed the direct response :keyword str continuation_token: A continuation token to restart a poller from a saved state. :keyword polling: By default, your polling method will be AsyncARMPolling. Pass in False for @@ -1605,115 +2017,189 @@ async def begin_create_or_update( cls(response) :rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.resource.resources.v2019_05_10.models.DeploymentExtended] - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - api_version = kwargs.pop('api_version', "2019-05-10") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] - polling = kwargs.pop('polling', True) # type: Union[bool, AsyncPollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType["_models.DeploymentExtended"] - lro_delay = kwargs.pop( - 'polling_interval', - self._config.polling_interval - ) - cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] + + @overload + async def begin_create_or_update( + self, + resource_group_name: str, + deployment_name: str, + parameters: IO, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> AsyncLROPoller[_models.DeploymentExtended]: + """Deploys resources to a resource group. + + You can provide the template and parameters directly in the request or link to JSON files. + + :param resource_group_name: The name of the resource group to deploy the resources to. The name + is case insensitive. The resource group must already exist. Required. + :type resource_group_name: str + :param deployment_name: The name of the deployment. Required. + :type deployment_name: str + :param parameters: Additional parameters supplied to the operation. Required. + :type parameters: IO + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be AsyncARMPolling. Pass in False for + this operation to not poll, or pass in your own initialized polling object for a personal + polling strategy. + :paramtype polling: bool or ~azure.core.polling.AsyncPollingMethod + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of AsyncLROPoller that returns either DeploymentExtended or the result of + cls(response) + :rtype: + ~azure.core.polling.AsyncLROPoller[~azure.mgmt.resource.resources.v2019_05_10.models.DeploymentExtended] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace_async + async def begin_create_or_update( + self, resource_group_name: str, deployment_name: str, parameters: Union[_models.Deployment, IO], **kwargs: Any + ) -> AsyncLROPoller[_models.DeploymentExtended]: + """Deploys resources to a resource group. + + You can provide the template and parameters directly in the request or link to JSON files. + + :param resource_group_name: The name of the resource group to deploy the resources to. The name + is case insensitive. The resource group must already exist. Required. + :type resource_group_name: str + :param deployment_name: The name of the deployment. Required. + :type deployment_name: str + :param parameters: Additional parameters supplied to the operation. Is either a model type or a + IO type. Required. + :type parameters: ~azure.mgmt.resource.resources.v2019_05_10.models.Deployment or IO + :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. + Default value is None. + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be AsyncARMPolling. Pass in False for + this operation to not poll, or pass in your own initialized polling object for a personal + polling strategy. + :paramtype polling: bool or ~azure.core.polling.AsyncPollingMethod + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of AsyncLROPoller that returns either DeploymentExtended or the result of + cls(response) + :rtype: + ~azure.core.polling.AsyncLROPoller[~azure.mgmt.resource.resources.v2019_05_10.models.DeploymentExtended] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _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", "2019-05-10")) # type: str + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.DeploymentExtended] + polling = kwargs.pop("polling", True) # type: Union[bool, AsyncPollingMethod] + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token = kwargs.pop("continuation_token", None) # type: Optional[str] if cont_token is None: - raw_result = await self._create_or_update_initial( + raw_result = await self._create_or_update_initial( # type: ignore resource_group_name=resource_group_name, deployment_name=deployment_name, parameters=parameters, api_version=api_version, content_type=content_type, - cls=lambda x,y,z: x, + cls=lambda x, y, z: x, + headers=_headers, + params=_params, **kwargs ) - kwargs.pop('error_map', None) + kwargs.pop("error_map", None) def get_long_running_output(pipeline_response): - response = pipeline_response.http_response - deserialized = self._deserialize('DeploymentExtended', pipeline_response) + deserialized = self._deserialize("DeploymentExtended", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - - if polling is True: polling_method = AsyncARMPolling(lro_delay, **kwargs) - elif polling is False: polling_method = AsyncNoPolling() - else: polling_method = polling + if polling is True: + polling_method = cast(AsyncPollingMethod, AsyncARMPolling(lro_delay, **kwargs)) # type: AsyncPollingMethod + elif polling is False: + polling_method = cast(AsyncPollingMethod, AsyncNoPolling()) + else: + polling_method = polling if cont_token: return AsyncLROPoller.from_continuation_token( polling_method=polling_method, continuation_token=cont_token, client=self._client, - deserialization_callback=get_long_running_output + deserialization_callback=get_long_running_output, ) return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) - begin_create_or_update.metadata = {'url': "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/Microsoft.Resources/deployments/{deploymentName}"} # type: ignore + begin_create_or_update.metadata = {"url": "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/Microsoft.Resources/deployments/{deploymentName}"} # type: ignore @distributed_trace_async - async def get( - self, - resource_group_name: str, - deployment_name: str, - **kwargs: Any - ) -> "_models.DeploymentExtended": + async def get(self, resource_group_name: str, deployment_name: str, **kwargs: Any) -> _models.DeploymentExtended: """Gets a deployment. :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. :type resource_group_name: str - :param deployment_name: The name of the deployment. + :param deployment_name: The name of the deployment. Required. :type deployment_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: DeploymentExtended, or the result of cls(response) + :return: DeploymentExtended or the result of cls(response) :rtype: ~azure.mgmt.resource.resources.v2019_05_10.models.DeploymentExtended - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.DeploymentExtended"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) - api_version = kwargs.pop('api_version', "2019-05-10") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2019-05-10")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[_models.DeploymentExtended] - request = build_deployments_get_request( resource_group_name=resource_group_name, deployment_name=deployment_name, subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.get.metadata['url'], + template_url=self.get.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) - deserialized = self._deserialize('DeploymentExtended', pipeline_response) + deserialized = self._deserialize("DeploymentExtended", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - get.metadata = {'url': "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/Microsoft.Resources/deployments/{deploymentName}"} # type: ignore - + get.metadata = {"url": "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/Microsoft.Resources/deployments/{deploymentName}"} # type: ignore @distributed_trace_async async def cancel( # pylint: disable=inconsistent-return-statements - self, - resource_group_name: str, - deployment_name: str, - **kwargs: Any + self, resource_group_name: str, deployment_name: str, **kwargs: Any ) -> None: """Cancels a currently running template deployment. @@ -1723,38 +2209,45 @@ async def cancel( # pylint: disable=inconsistent-return-statements partially deployed. :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. :type resource_group_name: str - :param deployment_name: The name of the deployment. + :param deployment_name: The name of the deployment. Required. :type deployment_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: None, or the result of cls(response) + :return: None or the result of cls(response) :rtype: None - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType[None] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + 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', "2019-05-10") # type: str + api_version = kwargs.pop("api_version", _params.pop("api-version", "2019-05-10")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[None] - request = build_deployments_cancel_request( resource_group_name=resource_group_name, deployment_name=deployment_name, subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.cancel.metadata['url'], + template_url=self.cancel.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [204]: @@ -1764,42 +2257,110 @@ async def cancel( # pylint: disable=inconsistent-return-statements if cls: return cls(pipeline_response, None, {}) - cancel.metadata = {'url': "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/Microsoft.Resources/deployments/{deploymentName}/cancel"} # type: ignore - + cancel.metadata = {"url": "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/Microsoft.Resources/deployments/{deploymentName}/cancel"} # type: ignore - @distributed_trace_async + @overload async def validate( self, resource_group_name: str, deployment_name: str, - parameters: "_models.Deployment", + parameters: _models.Deployment, + *, + content_type: str = "application/json", **kwargs: Any - ) -> "_models.DeploymentValidateResult": + ) -> _models.DeploymentValidateResult: """Validates whether the specified template is syntactically correct and will be accepted by Azure Resource Manager.. :param resource_group_name: The name of the resource group the template will be deployed to. - The name is case insensitive. + The name is case insensitive. Required. :type resource_group_name: str - :param deployment_name: The name of the deployment. + :param deployment_name: The name of the deployment. Required. :type deployment_name: str - :param parameters: Parameters to validate. + :param parameters: Parameters to validate. Required. :type parameters: ~azure.mgmt.resource.resources.v2019_05_10.models.Deployment + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: DeploymentValidateResult or the result of cls(response) + :rtype: ~azure.mgmt.resource.resources.v2019_05_10.models.DeploymentValidateResult + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + async def validate( + self, + resource_group_name: str, + deployment_name: str, + parameters: IO, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.DeploymentValidateResult: + """Validates whether the specified template is syntactically correct and will be accepted by Azure + Resource Manager.. + + :param resource_group_name: The name of the resource group the template will be deployed to. + The name is case insensitive. Required. + :type resource_group_name: str + :param deployment_name: The name of the deployment. Required. + :type deployment_name: str + :param parameters: Parameters to validate. Required. + :type parameters: IO + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: DeploymentValidateResult, or the result of cls(response) + :return: DeploymentValidateResult or the result of cls(response) :rtype: ~azure.mgmt.resource.resources.v2019_05_10.models.DeploymentValidateResult - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace_async + async def validate( + self, resource_group_name: str, deployment_name: str, parameters: Union[_models.Deployment, IO], **kwargs: Any + ) -> _models.DeploymentValidateResult: + """Validates whether the specified template is syntactically correct and will be accepted by Azure + Resource Manager.. + + :param resource_group_name: The name of the resource group the template will be deployed to. + The name is case insensitive. Required. + :type resource_group_name: str + :param deployment_name: The name of the deployment. Required. + :type deployment_name: str + :param parameters: Parameters to validate. Is either a model type or a IO type. Required. + :type parameters: ~azure.mgmt.resource.resources.v2019_05_10.models.Deployment or IO + :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. + Default value is None. + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: DeploymentValidateResult or the result of cls(response) + :rtype: ~azure.mgmt.resource.resources.v2019_05_10.models.DeploymentValidateResult + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.DeploymentValidateResult"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', "2019-05-10") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + api_version = kwargs.pop("api_version", _params.pop("api-version", "2019-05-10")) # type: str + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.DeploymentValidateResult] - _json = self._serialize.body(parameters, 'Deployment') + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(parameters, (IO, bytes)): + _content = parameters + else: + _json = self._serialize.body(parameters, "Deployment") request = build_deployments_validate_request( resource_group_name=resource_group_name, @@ -1808,16 +2369,18 @@ async def validate( api_version=api_version, content_type=content_type, json=_json, - template_url=self.validate.metadata['url'], + content=_content, + template_url=self.validate.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200, 400]: @@ -1825,89 +2388,87 @@ async def validate( raise HttpResponseError(response=response, error_format=ARMErrorFormat) if response.status_code == 200: - deserialized = self._deserialize('DeploymentValidateResult', pipeline_response) + deserialized = self._deserialize("DeploymentValidateResult", pipeline_response) if response.status_code == 400: - deserialized = self._deserialize('DeploymentValidateResult', pipeline_response) + deserialized = self._deserialize("DeploymentValidateResult", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - validate.metadata = {'url': "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/Microsoft.Resources/deployments/{deploymentName}/validate"} # type: ignore - + validate.metadata = {"url": "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/Microsoft.Resources/deployments/{deploymentName}/validate"} # type: ignore @distributed_trace_async async def export_template( - self, - resource_group_name: str, - deployment_name: str, - **kwargs: Any - ) -> "_models.DeploymentExportResult": + self, resource_group_name: str, deployment_name: str, **kwargs: Any + ) -> _models.DeploymentExportResult: """Exports the template used for specified deployment. :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. :type resource_group_name: str - :param deployment_name: The name of the deployment. + :param deployment_name: The name of the deployment. Required. :type deployment_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: DeploymentExportResult, or the result of cls(response) + :return: DeploymentExportResult or the result of cls(response) :rtype: ~azure.mgmt.resource.resources.v2019_05_10.models.DeploymentExportResult - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.DeploymentExportResult"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) - api_version = kwargs.pop('api_version', "2019-05-10") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2019-05-10")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[_models.DeploymentExportResult] - request = build_deployments_export_template_request( resource_group_name=resource_group_name, deployment_name=deployment_name, subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.export_template.metadata['url'], + template_url=self.export_template.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) - deserialized = self._deserialize('DeploymentExportResult', pipeline_response) + deserialized = self._deserialize("DeploymentExportResult", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - export_template.metadata = {'url': "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/Microsoft.Resources/deployments/{deploymentName}/exportTemplate"} # type: ignore - + export_template.metadata = {"url": "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/Microsoft.Resources/deployments/{deploymentName}/exportTemplate"} # type: ignore @distributed_trace def list_by_resource_group( - self, - resource_group_name: str, - filter: Optional[str] = None, - top: Optional[int] = None, - **kwargs: Any - ) -> AsyncIterable["_models.DeploymentListResult"]: + self, resource_group_name: str, filter: Optional[str] = None, top: Optional[int] = None, **kwargs: Any + ) -> AsyncIterable["_models.DeploymentExtended"]: """Get all the deployments for a resource group. :param resource_group_name: The name of the resource group with the deployments to get. The - name is case insensitive. + name is case insensitive. Required. :type resource_group_name: str :param filter: The filter to apply on the operation. For example, you can use $filter=provisioningState eq '{state}'. Default value is None. @@ -1916,42 +2477,49 @@ def list_by_resource_group( value is None. :type top: int :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either DeploymentListResult or the result of - cls(response) + :return: An iterator like instance of either DeploymentExtended or the result of cls(response) :rtype: - ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.resource.resources.v2019_05_10.models.DeploymentListResult] - :raises: ~azure.core.exceptions.HttpResponseError + ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.resource.resources.v2019_05_10.models.DeploymentExtended] + :raises ~azure.core.exceptions.HttpResponseError: """ - api_version = kwargs.pop('api_version', "2019-05-10") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2019-05-10")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[_models.DeploymentListResult] - cls = kwargs.pop('cls', None) # type: ClsType["_models.DeploymentListResult"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) + def prepare_request(next_link=None): if not next_link: - + request = build_deployments_list_by_resource_group_request( resource_group_name=resource_group_name, subscription_id=self._config.subscription_id, - api_version=api_version, filter=filter, top=top, - template_url=self.list_by_resource_group.metadata['url'], + 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.url = self._client.format_url(request.url) # type: ignore else: - - request = build_deployments_list_by_resource_group_request( - resource_group_name=resource_group_name, - subscription_id=self._config.subscription_id, - template_url=next_link, - ) + # make call to next link with the client's api-version + _parsed_next_link = urlparse(next_link) + _next_request_params = case_insensitive_dict(parse_qs(_parsed_next_link.query)) + _next_request_params["api-version"] = self._config.api_version + request = HttpRequest("GET", urljoin(next_link, _parsed_next_link.path), params=_next_request_params) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore request.method = "GET" return request @@ -1965,10 +2533,8 @@ async def extract_data(pipeline_response): async def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) response = pipeline_response.http_response @@ -1978,204 +2544,204 @@ async def get_next(next_link=None): return pipeline_response + return AsyncItemPaged(get_next, extract_data) - return AsyncItemPaged( - get_next, extract_data - ) - list_by_resource_group.metadata = {'url': "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/Microsoft.Resources/deployments/"} # type: ignore + list_by_resource_group.metadata = {"url": "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/Microsoft.Resources/deployments/"} # type: ignore @distributed_trace_async - async def calculate_template_hash( - self, - template: Any, - **kwargs: Any - ) -> "_models.TemplateHashResult": + async def calculate_template_hash(self, template: JSON, **kwargs: Any) -> _models.TemplateHashResult: """Calculate the hash of the given template. - :param template: The template provided to calculate hash. - :type template: any + :param template: The template provided to calculate hash. Required. + :type template: JSON :keyword callable cls: A custom type or function that will be passed the direct response - :return: TemplateHashResult, or the result of cls(response) + :return: TemplateHashResult or the result of cls(response) :rtype: ~azure.mgmt.resource.resources.v2019_05_10.models.TemplateHashResult - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.TemplateHashResult"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) - api_version = kwargs.pop('api_version', "2019-05-10") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - _json = self._serialize.body(template, 'object') + api_version = kwargs.pop("api_version", _params.pop("api-version", "2019-05-10")) # type: str + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", "application/json")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[_models.TemplateHashResult] + + _json = self._serialize.body(template, "object") request = build_deployments_calculate_template_hash_request( api_version=api_version, content_type=content_type, json=_json, - template_url=self.calculate_template_hash.metadata['url'], + template_url=self.calculate_template_hash.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) - deserialized = self._deserialize('TemplateHashResult', pipeline_response) + deserialized = self._deserialize("TemplateHashResult", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - calculate_template_hash.metadata = {'url': "/providers/Microsoft.Resources/calculateTemplateHash"} # type: ignore + calculate_template_hash.metadata = {"url": "/providers/Microsoft.Resources/calculateTemplateHash"} # type: ignore -class ProvidersOperations: - """ProvidersOperations async operations. - You should not instantiate this class directly. Instead, you should create a Client instance that - instantiates it for you and attaches it as an attribute. +class ProvidersOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. - :ivar models: Alias to model classes used in this operation group. - :type models: ~azure.mgmt.resource.resources.v2019_05_10.models - :param client: Client for service requests. - :param config: Configuration of service client. - :param serializer: An object model serializer. - :param deserializer: An object model deserializer. + Instead, you should access the following operations through + :class:`~azure.mgmt.resource.resources.v2019_05_10.aio.ResourceManagementClient`'s + :attr:`providers` attribute. """ models = _models - def __init__(self, client, config, serializer, deserializer) -> None: - self._client = client - self._serialize = serializer - self._deserialize = deserializer - self._config = config + def __init__(self, *args, **kwargs) -> None: + input_args = list(args) + self._client = input_args.pop(0) if input_args else kwargs.pop("client") + self._config = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") @distributed_trace_async - async def unregister( - self, - resource_provider_namespace: str, - **kwargs: Any - ) -> "_models.Provider": + async def unregister(self, resource_provider_namespace: str, **kwargs: Any) -> _models.Provider: """Unregisters a subscription from a resource provider. :param resource_provider_namespace: The namespace of the resource provider to unregister. + Required. :type resource_provider_namespace: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: Provider, or the result of cls(response) + :return: Provider or the result of cls(response) :rtype: ~azure.mgmt.resource.resources.v2019_05_10.models.Provider - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.Provider"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) - api_version = kwargs.pop('api_version', "2019-05-10") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2019-05-10")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[_models.Provider] - request = build_providers_unregister_request( resource_provider_namespace=resource_provider_namespace, subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.unregister.metadata['url'], + template_url=self.unregister.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) - deserialized = self._deserialize('Provider', pipeline_response) + deserialized = self._deserialize("Provider", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - unregister.metadata = {'url': "/subscriptions/{subscriptionId}/providers/{resourceProviderNamespace}/unregister"} # type: ignore - + unregister.metadata = {"url": "/subscriptions/{subscriptionId}/providers/{resourceProviderNamespace}/unregister"} # type: ignore @distributed_trace_async - async def register( - self, - resource_provider_namespace: str, - **kwargs: Any - ) -> "_models.Provider": + async def register(self, resource_provider_namespace: str, **kwargs: Any) -> _models.Provider: """Registers a subscription with a resource provider. :param resource_provider_namespace: The namespace of the resource provider to register. + Required. :type resource_provider_namespace: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: Provider, or the result of cls(response) + :return: Provider or the result of cls(response) :rtype: ~azure.mgmt.resource.resources.v2019_05_10.models.Provider - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.Provider"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) - api_version = kwargs.pop('api_version', "2019-05-10") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2019-05-10")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[_models.Provider] - request = build_providers_register_request( resource_provider_namespace=resource_provider_namespace, subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.register.metadata['url'], + template_url=self.register.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) - deserialized = self._deserialize('Provider', pipeline_response) + deserialized = self._deserialize("Provider", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - register.metadata = {'url': "/subscriptions/{subscriptionId}/providers/{resourceProviderNamespace}/register"} # type: ignore - + register.metadata = {"url": "/subscriptions/{subscriptionId}/providers/{resourceProviderNamespace}/register"} # type: ignore @distributed_trace def list( - self, - top: Optional[int] = None, - expand: Optional[str] = None, - **kwargs: Any - ) -> AsyncIterable["_models.ProviderListResult"]: + self, top: Optional[int] = None, expand: Optional[str] = None, **kwargs: Any + ) -> AsyncIterable["_models.Provider"]: """Gets all resource providers for a subscription. :param top: The number of results to return. If null is passed returns all deployments. Default @@ -2186,39 +2752,48 @@ def list( response, use $expand=resourceTypes/aliases. Default value is None. :type expand: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either ProviderListResult or the result of cls(response) + :return: An iterator like instance of either Provider or the result of cls(response) :rtype: - ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.resource.resources.v2019_05_10.models.ProviderListResult] - :raises: ~azure.core.exceptions.HttpResponseError + ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.resource.resources.v2019_05_10.models.Provider] + :raises ~azure.core.exceptions.HttpResponseError: """ - api_version = kwargs.pop('api_version', "2019-05-10") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2019-05-10")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[_models.ProviderListResult] - cls = kwargs.pop('cls', None) # type: ClsType["_models.ProviderListResult"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) + def prepare_request(next_link=None): if not next_link: - + request = build_providers_list_request( subscription_id=self._config.subscription_id, - api_version=api_version, top=top, expand=expand, - template_url=self.list.metadata['url'], + 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.url = self._client.format_url(request.url) # type: ignore else: - - request = build_providers_list_request( - subscription_id=self._config.subscription_id, - template_url=next_link, - ) + # make call to next link with the client's api-version + _parsed_next_link = urlparse(next_link) + _next_request_params = case_insensitive_dict(parse_qs(_parsed_next_link.query)) + _next_request_params["api-version"] = self._config.api_version + request = HttpRequest("GET", urljoin(next_link, _parsed_next_link.path), params=_next_request_params) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore request.method = "GET" return request @@ -2232,10 +2807,8 @@ async def extract_data(pipeline_response): async def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) response = pipeline_response.http_response @@ -2245,19 +2818,14 @@ async def get_next(next_link=None): return pipeline_response + return AsyncItemPaged(get_next, extract_data) - return AsyncItemPaged( - get_next, extract_data - ) - list.metadata = {'url': "/subscriptions/{subscriptionId}/providers"} # type: ignore + list.metadata = {"url": "/subscriptions/{subscriptionId}/providers"} # type: ignore @distributed_trace def list_at_tenant_scope( - self, - top: Optional[int] = None, - expand: Optional[str] = None, - **kwargs: Any - ) -> AsyncIterable["_models.ProviderListResult"]: + self, top: Optional[int] = None, expand: Optional[str] = None, **kwargs: Any + ) -> AsyncIterable["_models.Provider"]: """Gets all resource providers for the tenant. :param top: The number of results to return. If null is passed returns all providers. Default @@ -2268,37 +2836,47 @@ def list_at_tenant_scope( response, use $expand=resourceTypes/aliases. Default value is None. :type expand: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either ProviderListResult or the result of cls(response) + :return: An iterator like instance of either Provider or the result of cls(response) :rtype: - ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.resource.resources.v2019_05_10.models.ProviderListResult] - :raises: ~azure.core.exceptions.HttpResponseError + ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.resource.resources.v2019_05_10.models.Provider] + :raises ~azure.core.exceptions.HttpResponseError: """ - api_version = kwargs.pop('api_version', "2019-05-10") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2019-05-10")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[_models.ProviderListResult] - cls = kwargs.pop('cls', None) # type: ClsType["_models.ProviderListResult"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) + def prepare_request(next_link=None): if not next_link: - + request = build_providers_list_at_tenant_scope_request( - api_version=api_version, top=top, expand=expand, - template_url=self.list_at_tenant_scope.metadata['url'], + api_version=api_version, + template_url=self.list_at_tenant_scope.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore else: - - request = build_providers_list_at_tenant_scope_request( - template_url=next_link, - ) + # make call to next link with the client's api-version + _parsed_next_link = urlparse(next_link) + _next_request_params = case_insensitive_dict(parse_qs(_parsed_next_link.query)) + _next_request_params["api-version"] = self._config.api_version + request = HttpRequest("GET", urljoin(next_link, _parsed_next_link.path), params=_next_request_params) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore request.method = "GET" return request @@ -2312,10 +2890,8 @@ async def extract_data(pipeline_response): async def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) response = pipeline_response.http_response @@ -2325,149 +2901,150 @@ async def get_next(next_link=None): return pipeline_response + return AsyncItemPaged(get_next, extract_data) - return AsyncItemPaged( - get_next, extract_data - ) - list_at_tenant_scope.metadata = {'url': "/providers"} # type: ignore + list_at_tenant_scope.metadata = {"url": "/providers"} # type: ignore @distributed_trace_async async def get( - self, - resource_provider_namespace: str, - expand: Optional[str] = None, - **kwargs: Any - ) -> "_models.Provider": + self, resource_provider_namespace: str, expand: Optional[str] = None, **kwargs: Any + ) -> _models.Provider: """Gets the specified resource provider. - :param resource_provider_namespace: The namespace of the resource provider. + :param resource_provider_namespace: The namespace of the resource provider. Required. :type resource_provider_namespace: str :param expand: The $expand query parameter. For example, to include property aliases in response, use $expand=resourceTypes/aliases. Default value is None. :type expand: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: Provider, or the result of cls(response) + :return: Provider or the result of cls(response) :rtype: ~azure.mgmt.resource.resources.v2019_05_10.models.Provider - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.Provider"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) - api_version = kwargs.pop('api_version', "2019-05-10") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2019-05-10")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[_models.Provider] - request = build_providers_get_request( resource_provider_namespace=resource_provider_namespace, subscription_id=self._config.subscription_id, - api_version=api_version, expand=expand, - template_url=self.get.metadata['url'], + api_version=api_version, + template_url=self.get.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) - deserialized = self._deserialize('Provider', pipeline_response) + deserialized = self._deserialize("Provider", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - get.metadata = {'url': "/subscriptions/{subscriptionId}/providers/{resourceProviderNamespace}"} # type: ignore - + get.metadata = {"url": "/subscriptions/{subscriptionId}/providers/{resourceProviderNamespace}"} # type: ignore @distributed_trace_async async def get_at_tenant_scope( - self, - resource_provider_namespace: str, - expand: Optional[str] = None, - **kwargs: Any - ) -> "_models.Provider": + self, resource_provider_namespace: str, expand: Optional[str] = None, **kwargs: Any + ) -> _models.Provider: """Gets the specified resource provider at the tenant level. - :param resource_provider_namespace: The namespace of the resource provider. + :param resource_provider_namespace: The namespace of the resource provider. Required. :type resource_provider_namespace: str :param expand: The $expand query parameter. For example, to include property aliases in response, use $expand=resourceTypes/aliases. Default value is None. :type expand: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: Provider, or the result of cls(response) + :return: Provider or the result of cls(response) :rtype: ~azure.mgmt.resource.resources.v2019_05_10.models.Provider - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.Provider"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + 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', "2019-05-10") # type: str + api_version = kwargs.pop("api_version", _params.pop("api-version", "2019-05-10")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[_models.Provider] - request = build_providers_get_at_tenant_scope_request( resource_provider_namespace=resource_provider_namespace, - api_version=api_version, expand=expand, - template_url=self.get_at_tenant_scope.metadata['url'], + api_version=api_version, + template_url=self.get_at_tenant_scope.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) - deserialized = self._deserialize('Provider', pipeline_response) + deserialized = self._deserialize("Provider", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - get_at_tenant_scope.metadata = {'url': "/providers/{resourceProviderNamespace}"} # type: ignore + get_at_tenant_scope.metadata = {"url": "/providers/{resourceProviderNamespace}"} # type: ignore -class ResourcesOperations: # pylint: disable=too-many-public-methods - """ResourcesOperations async operations. - You should not instantiate this class directly. Instead, you should create a Client instance that - instantiates it for you and attaches it as an attribute. +class ResourcesOperations: # pylint: disable=too-many-public-methods + """ + .. warning:: + **DO NOT** instantiate this class directly. - :ivar models: Alias to model classes used in this operation group. - :type models: ~azure.mgmt.resource.resources.v2019_05_10.models - :param client: Client for service requests. - :param config: Configuration of service client. - :param serializer: An object model serializer. - :param deserializer: An object model deserializer. + Instead, you should access the following operations through + :class:`~azure.mgmt.resource.resources.v2019_05_10.aio.ResourceManagementClient`'s + :attr:`resources` attribute. """ models = _models - def __init__(self, client, config, serializer, deserializer) -> None: - self._client = client - self._serialize = serializer - self._deserialize = deserializer - self._config = config + def __init__(self, *args, **kwargs) -> None: + input_args = list(args) + self._client = input_args.pop(0) if input_args else kwargs.pop("client") + self._config = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") @distributed_trace def list_by_resource_group( @@ -2477,10 +3054,10 @@ def list_by_resource_group( expand: Optional[str] = None, top: Optional[int] = None, **kwargs: Any - ) -> AsyncIterable["_models.ResourceListResult"]: + ) -> AsyncIterable["_models.GenericResourceExpanded"]: """Get all the resources for a resource group. - :param resource_group_name: The resource group with the resources to get. + :param resource_group_name: The resource group with the resources to get. Required. :type resource_group_name: str :param filter: The filter to apply on the operation.:code:`
`:code:`
`The properties you can use for eq (equals) or ne (not equals) are: location, resourceType, name, resourceGroup, @@ -2505,42 +3082,51 @@ def list_by_resource_group( value is None. :type top: int :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either ResourceListResult or the result of cls(response) + :return: An iterator like instance of either GenericResourceExpanded or the result of + cls(response) :rtype: - ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.resource.resources.v2019_05_10.models.ResourceListResult] - :raises: ~azure.core.exceptions.HttpResponseError + ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.resource.resources.v2019_05_10.models.GenericResourceExpanded] + :raises ~azure.core.exceptions.HttpResponseError: """ - api_version = kwargs.pop('api_version', "2019-05-10") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2019-05-10")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[_models.ResourceListResult] - cls = kwargs.pop('cls', None) # type: ClsType["_models.ResourceListResult"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) + def prepare_request(next_link=None): if not next_link: - + request = build_resources_list_by_resource_group_request( resource_group_name=resource_group_name, subscription_id=self._config.subscription_id, - api_version=api_version, filter=filter, expand=expand, top=top, - template_url=self.list_by_resource_group.metadata['url'], + 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.url = self._client.format_url(request.url) # type: ignore else: - - request = build_resources_list_by_resource_group_request( - resource_group_name=resource_group_name, - subscription_id=self._config.subscription_id, - template_url=next_link, - ) + # make call to next link with the client's api-version + _parsed_next_link = urlparse(next_link) + _next_request_params = case_insensitive_dict(parse_qs(_parsed_next_link.query)) + _next_request_params["api-version"] = self._config.api_version + request = HttpRequest("GET", urljoin(next_link, _parsed_next_link.path), params=_next_request_params) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore request.method = "GET" return request @@ -2554,10 +3140,8 @@ async def extract_data(pipeline_response): async def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) response = pipeline_response.http_response @@ -2567,45 +3151,54 @@ async def get_next(next_link=None): return pipeline_response + return AsyncItemPaged(get_next, extract_data) - return AsyncItemPaged( - get_next, extract_data - ) - list_by_resource_group.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/resources"} # type: ignore + list_by_resource_group.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/resources"} # type: ignore async def _move_resources_initial( # pylint: disable=inconsistent-return-statements - self, - source_resource_group_name: str, - parameters: "_models.ResourcesMoveInfo", - **kwargs: Any + self, source_resource_group_name: str, parameters: Union[_models.ResourcesMoveInfo, IO], **kwargs: Any ) -> None: - cls = kwargs.pop('cls', None) # type: ClsType[None] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', "2019-05-10") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + api_version = kwargs.pop("api_version", _params.pop("api-version", "2019-05-10")) # type: str + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[None] - _json = self._serialize.body(parameters, 'ResourcesMoveInfo') + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(parameters, (IO, bytes)): + _content = parameters + else: + _json = self._serialize.body(parameters, "ResourcesMoveInfo") - request = build_resources_move_resources_request_initial( + request = build_resources_move_resources_request( source_resource_group_name=source_resource_group_name, subscription_id=self._config.subscription_id, api_version=api_version, content_type=content_type, json=_json, - template_url=self._move_resources_initial.metadata['url'], + content=_content, + template_url=self._move_resources_initial.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [202, 204]: @@ -2615,14 +3208,15 @@ async def _move_resources_initial( # pylint: disable=inconsistent-return-statem if cls: return cls(pipeline_response, None, {}) - _move_resources_initial.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{sourceResourceGroupName}/moveResources"} # type: ignore - + _move_resources_initial.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{sourceResourceGroupName}/moveResources"} # type: ignore - @distributed_trace_async - async def begin_move_resources( # pylint: disable=inconsistent-return-statements + @overload + async def begin_move_resources( self, source_resource_group_name: str, - parameters: "_models.ResourcesMoveInfo", + parameters: _models.ResourcesMoveInfo, + *, + content_type: str = "application/json", **kwargs: Any ) -> AsyncLROPoller[None]: """Moves resources from one resource group to another resource group. @@ -2633,10 +3227,13 @@ async def begin_move_resources( # pylint: disable=inconsistent-return-statement the groups until the move completes. :param source_resource_group_name: The name of the resource group containing the resources to - move. + move. Required. :type source_resource_group_name: str - :param parameters: Parameters for moving resources. + :param parameters: Parameters for moving resources. Required. :type parameters: ~azure.mgmt.resource.resources.v2019_05_10.models.ResourcesMoveInfo + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str :keyword callable cls: A custom type or function that will be passed the direct response :keyword str continuation_token: A continuation token to restart a poller from a saved state. :keyword polling: By default, your polling method will be AsyncARMPolling. Pass in False for @@ -2647,80 +3244,160 @@ async def begin_move_resources( # pylint: disable=inconsistent-return-statement Retry-After header is present. :return: An instance of AsyncLROPoller that returns either None or the result of cls(response) :rtype: ~azure.core.polling.AsyncLROPoller[None] - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - api_version = kwargs.pop('api_version', "2019-05-10") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] - polling = kwargs.pop('polling', True) # type: Union[bool, AsyncPollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType[None] - lro_delay = kwargs.pop( - 'polling_interval', - self._config.polling_interval - ) - cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] + + @overload + async def begin_move_resources( + self, source_resource_group_name: str, parameters: IO, *, content_type: str = "application/json", **kwargs: Any + ) -> AsyncLROPoller[None]: + """Moves resources from one resource group to another resource group. + + The resources to move must be in the same source resource group. The target resource group may + be in a different subscription. When moving resources, both the source group and the target + group are locked for the duration of the operation. Write and delete operations are blocked on + the groups until the move completes. + + :param source_resource_group_name: The name of the resource group containing the resources to + move. Required. + :type source_resource_group_name: str + :param parameters: Parameters for moving resources. Required. + :type parameters: IO + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be AsyncARMPolling. Pass in False for + this operation to not poll, or pass in your own initialized polling object for a personal + polling strategy. + :paramtype polling: bool or ~azure.core.polling.AsyncPollingMethod + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of AsyncLROPoller that returns either None or the result of cls(response) + :rtype: ~azure.core.polling.AsyncLROPoller[None] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace_async + async def begin_move_resources( + self, source_resource_group_name: str, parameters: Union[_models.ResourcesMoveInfo, IO], **kwargs: Any + ) -> AsyncLROPoller[None]: + """Moves resources from one resource group to another resource group. + + The resources to move must be in the same source resource group. The target resource group may + be in a different subscription. When moving resources, both the source group and the target + group are locked for the duration of the operation. Write and delete operations are blocked on + the groups until the move completes. + + :param source_resource_group_name: The name of the resource group containing the resources to + move. Required. + :type source_resource_group_name: str + :param parameters: Parameters for moving resources. Is either a model type or a IO type. + Required. + :type parameters: ~azure.mgmt.resource.resources.v2019_05_10.models.ResourcesMoveInfo or IO + :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. + Default value is None. + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be AsyncARMPolling. Pass in False for + this operation to not poll, or pass in your own initialized polling object for a personal + polling strategy. + :paramtype polling: bool or ~azure.core.polling.AsyncPollingMethod + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of AsyncLROPoller that returns either None or the result of cls(response) + :rtype: ~azure.core.polling.AsyncLROPoller[None] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _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", "2019-05-10")) # type: str + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[None] + polling = kwargs.pop("polling", True) # type: Union[bool, AsyncPollingMethod] + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token = kwargs.pop("continuation_token", None) # type: Optional[str] if cont_token is None: - raw_result = await self._move_resources_initial( + raw_result = await self._move_resources_initial( # type: ignore source_resource_group_name=source_resource_group_name, parameters=parameters, api_version=api_version, content_type=content_type, - cls=lambda x,y,z: x, + cls=lambda x, y, z: x, + headers=_headers, + params=_params, **kwargs ) - kwargs.pop('error_map', None) + kwargs.pop("error_map", None) - def get_long_running_output(pipeline_response): + def get_long_running_output(pipeline_response): # pylint: disable=inconsistent-return-statements if cls: return cls(pipeline_response, None, {}) - - if polling is True: polling_method = AsyncARMPolling(lro_delay, **kwargs) - elif polling is False: polling_method = AsyncNoPolling() - else: polling_method = polling + if polling is True: + polling_method = cast(AsyncPollingMethod, AsyncARMPolling(lro_delay, **kwargs)) # type: AsyncPollingMethod + elif polling is False: + polling_method = cast(AsyncPollingMethod, AsyncNoPolling()) + else: + polling_method = polling if cont_token: return AsyncLROPoller.from_continuation_token( polling_method=polling_method, continuation_token=cont_token, client=self._client, - deserialization_callback=get_long_running_output + deserialization_callback=get_long_running_output, ) return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) - begin_move_resources.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{sourceResourceGroupName}/moveResources"} # type: ignore + begin_move_resources.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{sourceResourceGroupName}/moveResources"} # type: ignore async def _validate_move_resources_initial( # pylint: disable=inconsistent-return-statements - self, - source_resource_group_name: str, - parameters: "_models.ResourcesMoveInfo", - **kwargs: Any + self, source_resource_group_name: str, parameters: Union[_models.ResourcesMoveInfo, IO], **kwargs: Any ) -> None: - cls = kwargs.pop('cls', None) # type: ClsType[None] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', "2019-05-10") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + api_version = kwargs.pop("api_version", _params.pop("api-version", "2019-05-10")) # type: str + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[None] - _json = self._serialize.body(parameters, 'ResourcesMoveInfo') + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(parameters, (IO, bytes)): + _content = parameters + else: + _json = self._serialize.body(parameters, "ResourcesMoveInfo") - request = build_resources_validate_move_resources_request_initial( + request = build_resources_validate_move_resources_request( source_resource_group_name=source_resource_group_name, subscription_id=self._config.subscription_id, api_version=api_version, content_type=content_type, json=_json, - template_url=self._validate_move_resources_initial.metadata['url'], + content=_content, + template_url=self._validate_move_resources_initial.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [202, 204, 409]: @@ -2730,14 +3407,15 @@ async def _validate_move_resources_initial( # pylint: disable=inconsistent-retu if cls: return cls(pipeline_response, None, {}) - _validate_move_resources_initial.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{sourceResourceGroupName}/validateMoveResources"} # type: ignore - + _validate_move_resources_initial.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{sourceResourceGroupName}/validateMoveResources"} # type: ignore - @distributed_trace_async - async def begin_validate_move_resources( # pylint: disable=inconsistent-return-statements + @overload + async def begin_validate_move_resources( self, source_resource_group_name: str, - parameters: "_models.ResourcesMoveInfo", + parameters: _models.ResourcesMoveInfo, + *, + content_type: str = "application/json", **kwargs: Any ) -> AsyncLROPoller[None]: """Validates whether resources can be moved from one resource group to another resource group. @@ -2750,10 +3428,13 @@ async def begin_validate_move_resources( # pylint: disable=inconsistent-return- operation. :param source_resource_group_name: The name of the resource group containing the resources to - validate for move. + validate for move. Required. :type source_resource_group_name: str - :param parameters: Parameters for moving resources. + :param parameters: Parameters for moving resources. Required. :type parameters: ~azure.mgmt.resource.resources.v2019_05_10.models.ResourcesMoveInfo + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str :keyword callable cls: A custom type or function that will be passed the direct response :keyword str continuation_token: A continuation token to restart a poller from a saved state. :keyword polling: By default, your polling method will be AsyncARMPolling. Pass in False for @@ -2764,55 +3445,124 @@ async def begin_validate_move_resources( # pylint: disable=inconsistent-return- Retry-After header is present. :return: An instance of AsyncLROPoller that returns either None or the result of cls(response) :rtype: ~azure.core.polling.AsyncLROPoller[None] - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - api_version = kwargs.pop('api_version', "2019-05-10") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] - polling = kwargs.pop('polling', True) # type: Union[bool, AsyncPollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType[None] - lro_delay = kwargs.pop( - 'polling_interval', - self._config.polling_interval - ) - cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] + + @overload + async def begin_validate_move_resources( + self, source_resource_group_name: str, parameters: IO, *, content_type: str = "application/json", **kwargs: Any + ) -> AsyncLROPoller[None]: + """Validates whether resources can be moved from one resource group to another resource group. + + This operation checks whether the specified resources can be moved to the target. The resources + to move must be in the same source resource group. The target resource group may be in a + different subscription. If validation succeeds, it returns HTTP response code 204 (no content). + If validation fails, it returns HTTP response code 409 (Conflict) with an error message. + Retrieve the URL in the Location header value to check the result of the long-running + operation. + + :param source_resource_group_name: The name of the resource group containing the resources to + validate for move. Required. + :type source_resource_group_name: str + :param parameters: Parameters for moving resources. Required. + :type parameters: IO + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be AsyncARMPolling. Pass in False for + this operation to not poll, or pass in your own initialized polling object for a personal + polling strategy. + :paramtype polling: bool or ~azure.core.polling.AsyncPollingMethod + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of AsyncLROPoller that returns either None or the result of cls(response) + :rtype: ~azure.core.polling.AsyncLROPoller[None] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace_async + async def begin_validate_move_resources( + self, source_resource_group_name: str, parameters: Union[_models.ResourcesMoveInfo, IO], **kwargs: Any + ) -> AsyncLROPoller[None]: + """Validates whether resources can be moved from one resource group to another resource group. + + This operation checks whether the specified resources can be moved to the target. The resources + to move must be in the same source resource group. The target resource group may be in a + different subscription. If validation succeeds, it returns HTTP response code 204 (no content). + If validation fails, it returns HTTP response code 409 (Conflict) with an error message. + Retrieve the URL in the Location header value to check the result of the long-running + operation. + + :param source_resource_group_name: The name of the resource group containing the resources to + validate for move. Required. + :type source_resource_group_name: str + :param parameters: Parameters for moving resources. Is either a model type or a IO type. + Required. + :type parameters: ~azure.mgmt.resource.resources.v2019_05_10.models.ResourcesMoveInfo or IO + :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. + Default value is None. + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be AsyncARMPolling. Pass in False for + this operation to not poll, or pass in your own initialized polling object for a personal + polling strategy. + :paramtype polling: bool or ~azure.core.polling.AsyncPollingMethod + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of AsyncLROPoller that returns either None or the result of cls(response) + :rtype: ~azure.core.polling.AsyncLROPoller[None] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _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", "2019-05-10")) # type: str + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[None] + polling = kwargs.pop("polling", True) # type: Union[bool, AsyncPollingMethod] + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token = kwargs.pop("continuation_token", None) # type: Optional[str] if cont_token is None: - raw_result = await self._validate_move_resources_initial( + raw_result = await self._validate_move_resources_initial( # type: ignore source_resource_group_name=source_resource_group_name, parameters=parameters, api_version=api_version, content_type=content_type, - cls=lambda x,y,z: x, + cls=lambda x, y, z: x, + headers=_headers, + params=_params, **kwargs ) - kwargs.pop('error_map', None) + kwargs.pop("error_map", None) - def get_long_running_output(pipeline_response): + def get_long_running_output(pipeline_response): # pylint: disable=inconsistent-return-statements if cls: return cls(pipeline_response, None, {}) - - if polling is True: polling_method = AsyncARMPolling(lro_delay, **kwargs) - elif polling is False: polling_method = AsyncNoPolling() - else: polling_method = polling + if polling is True: + polling_method = cast(AsyncPollingMethod, AsyncARMPolling(lro_delay, **kwargs)) # type: AsyncPollingMethod + elif polling is False: + polling_method = cast(AsyncPollingMethod, AsyncNoPolling()) + else: + polling_method = polling if cont_token: return AsyncLROPoller.from_continuation_token( polling_method=polling_method, continuation_token=cont_token, client=self._client, - deserialization_callback=get_long_running_output + deserialization_callback=get_long_running_output, ) return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) - begin_validate_move_resources.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{sourceResourceGroupName}/validateMoveResources"} # type: ignore + begin_validate_move_resources.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{sourceResourceGroupName}/validateMoveResources"} # type: ignore @distributed_trace def list( - self, - filter: Optional[str] = None, - expand: Optional[str] = None, - top: Optional[int] = None, - **kwargs: Any - ) -> AsyncIterable["_models.ResourceListResult"]: + self, filter: Optional[str] = None, expand: Optional[str] = None, top: Optional[int] = None, **kwargs: Any + ) -> AsyncIterable["_models.GenericResourceExpanded"]: """Get all the resources in a subscription. :param filter: The filter to apply on the operation.:code:`
`:code:`
`The properties you @@ -2838,40 +3588,50 @@ def list( value is None. :type top: int :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either ResourceListResult or the result of cls(response) + :return: An iterator like instance of either GenericResourceExpanded or the result of + cls(response) :rtype: - ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.resource.resources.v2019_05_10.models.ResourceListResult] - :raises: ~azure.core.exceptions.HttpResponseError + ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.resource.resources.v2019_05_10.models.GenericResourceExpanded] + :raises ~azure.core.exceptions.HttpResponseError: """ - api_version = kwargs.pop('api_version', "2019-05-10") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2019-05-10")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[_models.ResourceListResult] - cls = kwargs.pop('cls', None) # type: ClsType["_models.ResourceListResult"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) + def prepare_request(next_link=None): if not next_link: - + request = build_resources_list_request( subscription_id=self._config.subscription_id, - api_version=api_version, filter=filter, expand=expand, top=top, - template_url=self.list.metadata['url'], + 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.url = self._client.format_url(request.url) # type: ignore else: - - request = build_resources_list_request( - subscription_id=self._config.subscription_id, - template_url=next_link, - ) + # make call to next link with the client's api-version + _parsed_next_link = urlparse(next_link) + _next_request_params = case_insensitive_dict(parse_qs(_parsed_next_link.query)) + _next_request_params["api-version"] = self._config.api_version + request = HttpRequest("GET", urljoin(next_link, _parsed_next_link.path), params=_next_request_params) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore request.method = "GET" return request @@ -2885,10 +3645,8 @@ async def extract_data(pipeline_response): async def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) response = pipeline_response.http_response @@ -2898,11 +3656,9 @@ async def get_next(next_link=None): return pipeline_response + return AsyncItemPaged(get_next, extract_data) - return AsyncItemPaged( - get_next, extract_data - ) - list.metadata = {'url': "/subscriptions/{subscriptionId}/resources"} # type: ignore + list.metadata = {"url": "/subscriptions/{subscriptionId}/resources"} # type: ignore @distributed_trace_async async def check_existence( @@ -2918,30 +3674,36 @@ async def check_existence( """Checks whether a resource exists. :param resource_group_name: The name of the resource group containing the resource to check. - The name is case insensitive. + The name is case insensitive. Required. :type resource_group_name: str - :param resource_provider_namespace: The resource provider of the resource to check. + :param resource_provider_namespace: The resource provider of the resource to check. Required. :type resource_provider_namespace: str - :param parent_resource_path: The parent resource identity. + :param parent_resource_path: The parent resource identity. Required. :type parent_resource_path: str - :param resource_type: The resource type. + :param resource_type: The resource type. Required. :type resource_type: str - :param resource_name: The name of the resource to check whether it exists. + :param resource_name: The name of the resource to check whether it exists. Required. :type resource_name: str - :param api_version: The API version to use for the operation. + :param api_version: The API version to use for the operation. Required. :type api_version: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: bool, or the result of cls(response) + :return: bool or the result of cls(response) :rtype: bool - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType[None] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = kwargs.pop("params", {}) or {} + + cls = kwargs.pop("cls", None) # type: ClsType[None] - request = build_resources_check_existence_request( resource_group_name=resource_group_name, resource_provider_namespace=resource_provider_namespace, @@ -2950,16 +3712,17 @@ async def check_existence( resource_name=resource_name, subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.check_existence.metadata['url'], + template_url=self.check_existence.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [204, 404]: @@ -2970,8 +3733,7 @@ async def check_existence( return cls(pipeline_response, None, {}) return 200 <= response.status_code <= 299 - check_existence.metadata = {'url': "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{parentResourcePath}/{resourceType}/{resourceName}"} # type: ignore - + check_existence.metadata = {"url": "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{parentResourcePath}/{resourceType}/{resourceName}"} # type: ignore async def _delete_initial( # pylint: disable=inconsistent-return-statements self, @@ -2983,14 +3745,20 @@ async def _delete_initial( # pylint: disable=inconsistent-return-statements api_version: str, **kwargs: Any ) -> None: - cls = kwargs.pop('cls', None) # type: ClsType[None] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = kwargs.pop("params", {}) or {} + + cls = kwargs.pop("cls", None) # type: ClsType[None] - - request = build_resources_delete_request_initial( + request = build_resources_delete_request( resource_group_name=resource_group_name, resource_provider_namespace=resource_provider_namespace, parent_resource_path=parent_resource_path, @@ -2998,16 +3766,17 @@ async def _delete_initial( # pylint: disable=inconsistent-return-statements resource_name=resource_name, subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self._delete_initial.metadata['url'], + template_url=self._delete_initial.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200, 202, 204]: @@ -3017,11 +3786,10 @@ 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/{resourceProviderNamespace}/{parentResourcePath}/{resourceType}/{resourceName}"} # type: ignore - + _delete_initial.metadata = {"url": "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{parentResourcePath}/{resourceType}/{resourceName}"} # type: ignore @distributed_trace_async - async def begin_delete( # pylint: disable=inconsistent-return-statements + async def begin_delete( self, resource_group_name: str, resource_provider_namespace: str, @@ -3034,17 +3802,17 @@ async def begin_delete( # pylint: disable=inconsistent-return-statements """Deletes a resource. :param resource_group_name: The name of the resource group that contains the resource to - delete. The name is case insensitive. + delete. The name is case insensitive. Required. :type resource_group_name: str - :param resource_provider_namespace: The namespace of the resource provider. + :param resource_provider_namespace: The namespace of the resource provider. Required. :type resource_provider_namespace: str - :param parent_resource_path: The parent resource identity. + :param parent_resource_path: The parent resource identity. Required. :type parent_resource_path: str - :param resource_type: The resource type. + :param resource_type: The resource type. Required. :type resource_type: str - :param resource_name: The name of the resource to delete. + :param resource_name: The name of the resource to delete. Required. :type resource_name: str - :param api_version: The API version to use for the operation. + :param api_version: The API version to use for the operation. Required. :type api_version: str :keyword callable cls: A custom type or function that will be passed the direct response :keyword str continuation_token: A continuation token to restart a poller from a saved state. @@ -3056,46 +3824,50 @@ async def begin_delete( # pylint: disable=inconsistent-return-statements Retry-After header is present. :return: An instance of AsyncLROPoller that returns either None or the result of cls(response) :rtype: ~azure.core.polling.AsyncLROPoller[None] - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - polling = kwargs.pop('polling', True) # type: Union[bool, AsyncPollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType[None] - lro_delay = kwargs.pop( - 'polling_interval', - self._config.polling_interval - ) - cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] + _headers = kwargs.pop("headers", {}) or {} + _params = kwargs.pop("params", {}) or {} + + cls = kwargs.pop("cls", None) # type: ClsType[None] + polling = kwargs.pop("polling", True) # type: Union[bool, AsyncPollingMethod] + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token = kwargs.pop("continuation_token", None) # type: Optional[str] if cont_token is None: - raw_result = await self._delete_initial( + raw_result = await self._delete_initial( # type: ignore resource_group_name=resource_group_name, resource_provider_namespace=resource_provider_namespace, parent_resource_path=parent_resource_path, resource_type=resource_type, resource_name=resource_name, api_version=api_version, - cls=lambda x,y,z: x, + cls=lambda x, y, z: x, + headers=_headers, + params=_params, **kwargs ) - kwargs.pop('error_map', None) + kwargs.pop("error_map", None) - def get_long_running_output(pipeline_response): + def get_long_running_output(pipeline_response): # pylint: disable=inconsistent-return-statements if cls: return cls(pipeline_response, None, {}) - - if polling is True: polling_method = AsyncARMPolling(lro_delay, **kwargs) - elif polling is False: polling_method = AsyncNoPolling() - else: polling_method = polling + if polling is True: + polling_method = cast(AsyncPollingMethod, AsyncARMPolling(lro_delay, **kwargs)) # type: AsyncPollingMethod + elif polling is False: + polling_method = cast(AsyncPollingMethod, AsyncNoPolling()) + else: + polling_method = polling if cont_token: return AsyncLROPoller.from_continuation_token( polling_method=polling_method, continuation_token=cont_token, client=self._client, - deserialization_callback=get_long_running_output + deserialization_callback=get_long_running_output, ) return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) - begin_delete.metadata = {'url': "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{parentResourcePath}/{resourceType}/{resourceName}"} # type: ignore + begin_delete.metadata = {"url": "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{parentResourcePath}/{resourceType}/{resourceName}"} # type: ignore async def _create_or_update_initial( self, @@ -3105,39 +3877,53 @@ async def _create_or_update_initial( resource_type: str, resource_name: str, api_version: str, - parameters: "_models.GenericResource", + parameters: Union[_models.GenericResource, IO], **kwargs: Any - ) -> Optional["_models.GenericResource"]: - cls = kwargs.pop('cls', None) # type: ClsType[Optional["_models.GenericResource"]] + ) -> Optional[_models.GenericResource]: error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = kwargs.pop("params", {}) or {} - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[Optional[_models.GenericResource]] - _json = self._serialize.body(parameters, 'GenericResource') + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(parameters, (IO, bytes)): + _content = parameters + else: + _json = self._serialize.body(parameters, "GenericResource") - request = build_resources_create_or_update_request_initial( + request = build_resources_create_or_update_request( resource_group_name=resource_group_name, resource_provider_namespace=resource_provider_namespace, parent_resource_path=parent_resource_path, resource_type=resource_type, resource_name=resource_name, subscription_id=self._config.subscription_id, - content_type=content_type, api_version=api_version, + content_type=content_type, json=_json, - template_url=self._create_or_update_initial.metadata['url'], + content=_content, + template_url=self._create_or_update_initial.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200, 201, 202]: @@ -3146,18 +3932,115 @@ async def _create_or_update_initial( deserialized = None if response.status_code == 200: - deserialized = self._deserialize('GenericResource', pipeline_response) + deserialized = self._deserialize("GenericResource", pipeline_response) if response.status_code == 201: - deserialized = self._deserialize('GenericResource', pipeline_response) + deserialized = self._deserialize("GenericResource", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - _create_or_update_initial.metadata = {'url': "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{parentResourcePath}/{resourceType}/{resourceName}"} # type: ignore + _create_or_update_initial.metadata = {"url": "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{parentResourcePath}/{resourceType}/{resourceName}"} # type: ignore + + @overload + async def begin_create_or_update( + self, + resource_group_name: str, + resource_provider_namespace: str, + parent_resource_path: str, + resource_type: str, + resource_name: str, + api_version: str, + parameters: _models.GenericResource, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> AsyncLROPoller[_models.GenericResource]: + """Creates a resource. + + :param resource_group_name: The name of the resource group for the resource. The name is case + insensitive. Required. + :type resource_group_name: str + :param resource_provider_namespace: The namespace of the resource provider. Required. + :type resource_provider_namespace: str + :param parent_resource_path: The parent resource identity. Required. + :type parent_resource_path: str + :param resource_type: The resource type of the resource to create. Required. + :type resource_type: str + :param resource_name: The name of the resource to create. Required. + :type resource_name: str + :param api_version: The API version to use for the operation. Required. + :type api_version: str + :param parameters: Parameters for creating or updating the resource. Required. + :type parameters: ~azure.mgmt.resource.resources.v2019_05_10.models.GenericResource + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be AsyncARMPolling. Pass in False for + this operation to not poll, or pass in your own initialized polling object for a personal + polling strategy. + :paramtype polling: bool or ~azure.core.polling.AsyncPollingMethod + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of AsyncLROPoller that returns either GenericResource or the result of + cls(response) + :rtype: + ~azure.core.polling.AsyncLROPoller[~azure.mgmt.resource.resources.v2019_05_10.models.GenericResource] + :raises ~azure.core.exceptions.HttpResponseError: + """ + @overload + async def begin_create_or_update( + self, + resource_group_name: str, + resource_provider_namespace: str, + parent_resource_path: str, + resource_type: str, + resource_name: str, + api_version: str, + parameters: IO, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> AsyncLROPoller[_models.GenericResource]: + """Creates a resource. + + :param resource_group_name: The name of the resource group for the resource. The name is case + insensitive. Required. + :type resource_group_name: str + :param resource_provider_namespace: The namespace of the resource provider. Required. + :type resource_provider_namespace: str + :param parent_resource_path: The parent resource identity. Required. + :type parent_resource_path: str + :param resource_type: The resource type of the resource to create. Required. + :type resource_type: str + :param resource_name: The name of the resource to create. Required. + :type resource_name: str + :param api_version: The API version to use for the operation. Required. + :type api_version: str + :param parameters: Parameters for creating or updating the resource. Required. + :type parameters: IO + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be AsyncARMPolling. Pass in False for + this operation to not poll, or pass in your own initialized polling object for a personal + polling strategy. + :paramtype polling: bool or ~azure.core.polling.AsyncPollingMethod + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of AsyncLROPoller that returns either GenericResource or the result of + cls(response) + :rtype: + ~azure.core.polling.AsyncLROPoller[~azure.mgmt.resource.resources.v2019_05_10.models.GenericResource] + :raises ~azure.core.exceptions.HttpResponseError: + """ @distributed_trace_async async def begin_create_or_update( @@ -3168,26 +4051,30 @@ async def begin_create_or_update( resource_type: str, resource_name: str, api_version: str, - parameters: "_models.GenericResource", + parameters: Union[_models.GenericResource, IO], **kwargs: Any - ) -> AsyncLROPoller["_models.GenericResource"]: + ) -> AsyncLROPoller[_models.GenericResource]: """Creates a resource. :param resource_group_name: The name of the resource group for the resource. The name is case - insensitive. + insensitive. Required. :type resource_group_name: str - :param resource_provider_namespace: The namespace of the resource provider. + :param resource_provider_namespace: The namespace of the resource provider. Required. :type resource_provider_namespace: str - :param parent_resource_path: The parent resource identity. + :param parent_resource_path: The parent resource identity. Required. :type parent_resource_path: str - :param resource_type: The resource type of the resource to create. + :param resource_type: The resource type of the resource to create. Required. :type resource_type: str - :param resource_name: The name of the resource to create. + :param resource_name: The name of the resource to create. Required. :type resource_name: str - :param api_version: The API version to use for the operation. + :param api_version: The API version to use for the operation. Required. :type api_version: str - :param parameters: Parameters for creating or updating the resource. - :type parameters: ~azure.mgmt.resource.resources.v2019_05_10.models.GenericResource + :param parameters: Parameters for creating or updating the resource. Is either a model type or + a IO type. Required. + :type parameters: ~azure.mgmt.resource.resources.v2019_05_10.models.GenericResource or IO + :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. + Default value is None. + :paramtype content_type: str :keyword callable cls: A custom type or function that will be passed the direct response :keyword str continuation_token: A continuation token to restart a poller from a saved state. :keyword polling: By default, your polling method will be AsyncARMPolling. Pass in False for @@ -3200,18 +4087,18 @@ async def begin_create_or_update( cls(response) :rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.resource.resources.v2019_05_10.models.GenericResource] - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] - polling = kwargs.pop('polling', True) # type: Union[bool, AsyncPollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType["_models.GenericResource"] - lro_delay = kwargs.pop( - 'polling_interval', - self._config.polling_interval - ) - cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = kwargs.pop("params", {}) or {} + + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.GenericResource] + polling = kwargs.pop("polling", True) # type: Union[bool, AsyncPollingMethod] + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token = kwargs.pop("continuation_token", None) # type: Optional[str] if cont_token is None: - raw_result = await self._create_or_update_initial( + raw_result = await self._create_or_update_initial( # type: ignore resource_group_name=resource_group_name, resource_provider_namespace=resource_provider_namespace, parent_resource_path=parent_resource_path, @@ -3220,32 +4107,35 @@ async def begin_create_or_update( api_version=api_version, parameters=parameters, content_type=content_type, - cls=lambda x,y,z: x, + cls=lambda x, y, z: x, + headers=_headers, + params=_params, **kwargs ) - kwargs.pop('error_map', None) + kwargs.pop("error_map", None) def get_long_running_output(pipeline_response): - response = pipeline_response.http_response - deserialized = self._deserialize('GenericResource', pipeline_response) + deserialized = self._deserialize("GenericResource", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - - if polling is True: polling_method = AsyncARMPolling(lro_delay, **kwargs) - elif polling is False: polling_method = AsyncNoPolling() - else: polling_method = polling + if polling is True: + polling_method = cast(AsyncPollingMethod, AsyncARMPolling(lro_delay, **kwargs)) # type: AsyncPollingMethod + elif polling is False: + polling_method = cast(AsyncPollingMethod, AsyncNoPolling()) + else: + polling_method = polling if cont_token: return AsyncLROPoller.from_continuation_token( polling_method=polling_method, continuation_token=cont_token, client=self._client, - deserialization_callback=get_long_running_output + deserialization_callback=get_long_running_output, ) return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) - begin_create_or_update.metadata = {'url': "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{parentResourcePath}/{resourceType}/{resourceName}"} # type: ignore + begin_create_or_update.metadata = {"url": "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{parentResourcePath}/{resourceType}/{resourceName}"} # type: ignore async def _update_initial( self, @@ -3255,39 +4145,53 @@ async def _update_initial( resource_type: str, resource_name: str, api_version: str, - parameters: "_models.GenericResource", + parameters: Union[_models.GenericResource, IO], **kwargs: Any - ) -> Optional["_models.GenericResource"]: - cls = kwargs.pop('cls', None) # type: ClsType[Optional["_models.GenericResource"]] + ) -> Optional[_models.GenericResource]: error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = kwargs.pop("params", {}) or {} - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[Optional[_models.GenericResource]] - _json = self._serialize.body(parameters, 'GenericResource') + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(parameters, (IO, bytes)): + _content = parameters + else: + _json = self._serialize.body(parameters, "GenericResource") - request = build_resources_update_request_initial( + request = build_resources_update_request( resource_group_name=resource_group_name, resource_provider_namespace=resource_provider_namespace, parent_resource_path=parent_resource_path, resource_type=resource_type, resource_name=resource_name, subscription_id=self._config.subscription_id, - content_type=content_type, api_version=api_version, + content_type=content_type, json=_json, - template_url=self._update_initial.metadata['url'], + content=_content, + template_url=self._update_initial.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200, 202]: @@ -3296,15 +4200,112 @@ async def _update_initial( deserialized = None if response.status_code == 200: - deserialized = self._deserialize('GenericResource', pipeline_response) + deserialized = self._deserialize("GenericResource", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - _update_initial.metadata = {'url': "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{parentResourcePath}/{resourceType}/{resourceName}"} # type: ignore + _update_initial.metadata = {"url": "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{parentResourcePath}/{resourceType}/{resourceName}"} # type: ignore + + @overload + async def begin_update( + self, + resource_group_name: str, + resource_provider_namespace: str, + parent_resource_path: str, + resource_type: str, + resource_name: str, + api_version: str, + parameters: _models.GenericResource, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> AsyncLROPoller[_models.GenericResource]: + """Updates a resource. + + :param resource_group_name: The name of the resource group for the resource. The name is case + insensitive. Required. + :type resource_group_name: str + :param resource_provider_namespace: The namespace of the resource provider. Required. + :type resource_provider_namespace: str + :param parent_resource_path: The parent resource identity. Required. + :type parent_resource_path: str + :param resource_type: The resource type of the resource to update. Required. + :type resource_type: str + :param resource_name: The name of the resource to update. Required. + :type resource_name: str + :param api_version: The API version to use for the operation. Required. + :type api_version: str + :param parameters: Parameters for updating the resource. Required. + :type parameters: ~azure.mgmt.resource.resources.v2019_05_10.models.GenericResource + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be AsyncARMPolling. Pass in False for + this operation to not poll, or pass in your own initialized polling object for a personal + polling strategy. + :paramtype polling: bool or ~azure.core.polling.AsyncPollingMethod + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of AsyncLROPoller that returns either GenericResource or the result of + cls(response) + :rtype: + ~azure.core.polling.AsyncLROPoller[~azure.mgmt.resource.resources.v2019_05_10.models.GenericResource] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + async def begin_update( + self, + resource_group_name: str, + resource_provider_namespace: str, + parent_resource_path: str, + resource_type: str, + resource_name: str, + api_version: str, + parameters: IO, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> AsyncLROPoller[_models.GenericResource]: + """Updates a resource. + :param resource_group_name: The name of the resource group for the resource. The name is case + insensitive. Required. + :type resource_group_name: str + :param resource_provider_namespace: The namespace of the resource provider. Required. + :type resource_provider_namespace: str + :param parent_resource_path: The parent resource identity. Required. + :type parent_resource_path: str + :param resource_type: The resource type of the resource to update. Required. + :type resource_type: str + :param resource_name: The name of the resource to update. Required. + :type resource_name: str + :param api_version: The API version to use for the operation. Required. + :type api_version: str + :param parameters: Parameters for updating the resource. Required. + :type parameters: IO + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be AsyncARMPolling. Pass in False for + this operation to not poll, or pass in your own initialized polling object for a personal + polling strategy. + :paramtype polling: bool or ~azure.core.polling.AsyncPollingMethod + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of AsyncLROPoller that returns either GenericResource or the result of + cls(response) + :rtype: + ~azure.core.polling.AsyncLROPoller[~azure.mgmt.resource.resources.v2019_05_10.models.GenericResource] + :raises ~azure.core.exceptions.HttpResponseError: + """ @distributed_trace_async async def begin_update( @@ -3315,26 +4316,30 @@ async def begin_update( resource_type: str, resource_name: str, api_version: str, - parameters: "_models.GenericResource", + parameters: Union[_models.GenericResource, IO], **kwargs: Any - ) -> AsyncLROPoller["_models.GenericResource"]: + ) -> AsyncLROPoller[_models.GenericResource]: """Updates a resource. :param resource_group_name: The name of the resource group for the resource. The name is case - insensitive. + insensitive. Required. :type resource_group_name: str - :param resource_provider_namespace: The namespace of the resource provider. + :param resource_provider_namespace: The namespace of the resource provider. Required. :type resource_provider_namespace: str - :param parent_resource_path: The parent resource identity. + :param parent_resource_path: The parent resource identity. Required. :type parent_resource_path: str - :param resource_type: The resource type of the resource to update. + :param resource_type: The resource type of the resource to update. Required. :type resource_type: str - :param resource_name: The name of the resource to update. + :param resource_name: The name of the resource to update. Required. :type resource_name: str - :param api_version: The API version to use for the operation. + :param api_version: The API version to use for the operation. Required. :type api_version: str - :param parameters: Parameters for updating the resource. - :type parameters: ~azure.mgmt.resource.resources.v2019_05_10.models.GenericResource + :param parameters: Parameters for updating the resource. Is either a model type or a IO type. + Required. + :type parameters: ~azure.mgmt.resource.resources.v2019_05_10.models.GenericResource or IO + :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. + Default value is None. + :paramtype content_type: str :keyword callable cls: A custom type or function that will be passed the direct response :keyword str continuation_token: A continuation token to restart a poller from a saved state. :keyword polling: By default, your polling method will be AsyncARMPolling. Pass in False for @@ -3347,18 +4352,18 @@ async def begin_update( cls(response) :rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.resource.resources.v2019_05_10.models.GenericResource] - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] - polling = kwargs.pop('polling', True) # type: Union[bool, AsyncPollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType["_models.GenericResource"] - lro_delay = kwargs.pop( - 'polling_interval', - self._config.polling_interval - ) - cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = kwargs.pop("params", {}) or {} + + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.GenericResource] + polling = kwargs.pop("polling", True) # type: Union[bool, AsyncPollingMethod] + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token = kwargs.pop("continuation_token", None) # type: Optional[str] if cont_token is None: - raw_result = await self._update_initial( + raw_result = await self._update_initial( # type: ignore resource_group_name=resource_group_name, resource_provider_namespace=resource_provider_namespace, parent_resource_path=parent_resource_path, @@ -3367,32 +4372,35 @@ async def begin_update( api_version=api_version, parameters=parameters, content_type=content_type, - cls=lambda x,y,z: x, + cls=lambda x, y, z: x, + headers=_headers, + params=_params, **kwargs ) - kwargs.pop('error_map', None) + kwargs.pop("error_map", None) def get_long_running_output(pipeline_response): - response = pipeline_response.http_response - deserialized = self._deserialize('GenericResource', pipeline_response) + deserialized = self._deserialize("GenericResource", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - - if polling is True: polling_method = AsyncARMPolling(lro_delay, **kwargs) - elif polling is False: polling_method = AsyncNoPolling() - else: polling_method = polling + if polling is True: + polling_method = cast(AsyncPollingMethod, AsyncARMPolling(lro_delay, **kwargs)) # type: AsyncPollingMethod + elif polling is False: + polling_method = cast(AsyncPollingMethod, AsyncNoPolling()) + else: + polling_method = polling if cont_token: return AsyncLROPoller.from_continuation_token( polling_method=polling_method, continuation_token=cont_token, client=self._client, - deserialization_callback=get_long_running_output + deserialization_callback=get_long_running_output, ) return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) - begin_update.metadata = {'url': "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{parentResourcePath}/{resourceType}/{resourceName}"} # type: ignore + begin_update.metadata = {"url": "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{parentResourcePath}/{resourceType}/{resourceName}"} # type: ignore @distributed_trace_async async def get( @@ -3404,34 +4412,40 @@ async def get( resource_name: str, api_version: str, **kwargs: Any - ) -> "_models.GenericResource": + ) -> _models.GenericResource: """Gets a resource. :param resource_group_name: The name of the resource group containing the resource to get. The - name is case insensitive. + name is case insensitive. Required. :type resource_group_name: str - :param resource_provider_namespace: The namespace of the resource provider. + :param resource_provider_namespace: The namespace of the resource provider. Required. :type resource_provider_namespace: str - :param parent_resource_path: The parent resource identity. + :param parent_resource_path: The parent resource identity. Required. :type parent_resource_path: str - :param resource_type: The resource type of the resource. + :param resource_type: The resource type of the resource. Required. :type resource_type: str - :param resource_name: The name of the resource to get. + :param resource_name: The name of the resource to get. Required. :type resource_name: str - :param api_version: The API version to use for the operation. + :param api_version: The API version to use for the operation. Required. :type api_version: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: GenericResource, or the result of cls(response) + :return: GenericResource or the result of cls(response) :rtype: ~azure.mgmt.resource.resources.v2019_05_10.models.GenericResource - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.GenericResource"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = kwargs.pop("params", {}) or {} + + cls = kwargs.pop("cls", None) # type: ClsType[_models.GenericResource] - request = build_resources_get_request( resource_group_name=resource_group_name, resource_provider_namespace=resource_provider_namespace, @@ -3440,72 +4454,75 @@ async def get( resource_name=resource_name, subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.get.metadata['url'], + template_url=self.get.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) - deserialized = self._deserialize('GenericResource', pipeline_response) + deserialized = self._deserialize("GenericResource", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - get.metadata = {'url': "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{parentResourcePath}/{resourceType}/{resourceName}"} # type: ignore - + get.metadata = {"url": "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{parentResourcePath}/{resourceType}/{resourceName}"} # type: ignore @distributed_trace_async - async def check_existence_by_id( - self, - resource_id: str, - api_version: str, - **kwargs: Any - ) -> bool: + async def check_existence_by_id(self, resource_id: str, api_version: str, **kwargs: Any) -> bool: """Checks by ID whether a resource exists. :param resource_id: The fully qualified ID of the resource, including the resource name and resource type. Use the format, /subscriptions/{guid}/resourceGroups/{resource-group-name}/{resource-provider-namespace}/{resource-type}/{resource-name}. + Required. :type resource_id: str - :param api_version: The API version to use for the operation. + :param api_version: The API version to use for the operation. Required. :type api_version: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: bool, or the result of cls(response) + :return: bool or the result of cls(response) :rtype: bool - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType[None] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = kwargs.pop("params", {}) or {} + + cls = kwargs.pop("cls", None) # type: ClsType[None] - request = build_resources_check_existence_by_id_request( resource_id=resource_id, api_version=api_version, - template_url=self.check_existence_by_id.metadata['url'], + template_url=self.check_existence_by_id.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [204, 404]: @@ -3516,35 +4533,38 @@ async def check_existence_by_id( return cls(pipeline_response, None, {}) return 200 <= response.status_code <= 299 - check_existence_by_id.metadata = {'url': "/{resourceId}"} # type: ignore - + check_existence_by_id.metadata = {"url": "/{resourceId}"} # type: ignore async def _delete_by_id_initial( # pylint: disable=inconsistent-return-statements - self, - resource_id: str, - api_version: str, - **kwargs: Any + self, resource_id: str, api_version: str, **kwargs: Any ) -> None: - cls = kwargs.pop('cls', None) # type: ClsType[None] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = kwargs.pop("params", {}) or {} + + cls = kwargs.pop("cls", None) # type: ClsType[None] - - request = build_resources_delete_by_id_request_initial( + request = build_resources_delete_by_id_request( resource_id=resource_id, api_version=api_version, - template_url=self._delete_by_id_initial.metadata['url'], + template_url=self._delete_by_id_initial.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200, 202, 204]: @@ -3554,23 +4574,18 @@ async def _delete_by_id_initial( # pylint: disable=inconsistent-return-statemen if cls: return cls(pipeline_response, None, {}) - _delete_by_id_initial.metadata = {'url': "/{resourceId}"} # type: ignore - + _delete_by_id_initial.metadata = {"url": "/{resourceId}"} # type: ignore @distributed_trace_async - async def begin_delete_by_id( # pylint: disable=inconsistent-return-statements - self, - resource_id: str, - api_version: str, - **kwargs: Any - ) -> AsyncLROPoller[None]: + async def begin_delete_by_id(self, resource_id: str, api_version: str, **kwargs: Any) -> AsyncLROPoller[None]: """Deletes a resource by ID. :param resource_id: The fully qualified ID of the resource, including the resource name and resource type. Use the format, /subscriptions/{guid}/resourceGroups/{resource-group-name}/{resource-provider-namespace}/{resource-type}/{resource-name}. + Required. :type resource_id: str - :param api_version: The API version to use for the operation. + :param api_version: The API version to use for the operation. Required. :type api_version: str :keyword callable cls: A custom type or function that will be passed the direct response :keyword str continuation_token: A continuation token to restart a poller from a saved state. @@ -3582,75 +4597,89 @@ async def begin_delete_by_id( # pylint: disable=inconsistent-return-statements Retry-After header is present. :return: An instance of AsyncLROPoller that returns either None or the result of cls(response) :rtype: ~azure.core.polling.AsyncLROPoller[None] - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - polling = kwargs.pop('polling', True) # type: Union[bool, AsyncPollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType[None] - lro_delay = kwargs.pop( - 'polling_interval', - self._config.polling_interval - ) - cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] + _headers = kwargs.pop("headers", {}) or {} + _params = kwargs.pop("params", {}) or {} + + cls = kwargs.pop("cls", None) # type: ClsType[None] + polling = kwargs.pop("polling", True) # type: Union[bool, AsyncPollingMethod] + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token = kwargs.pop("continuation_token", None) # type: Optional[str] if cont_token is None: - raw_result = await self._delete_by_id_initial( + raw_result = await self._delete_by_id_initial( # type: ignore resource_id=resource_id, api_version=api_version, - cls=lambda x,y,z: x, + cls=lambda x, y, z: x, + headers=_headers, + params=_params, **kwargs ) - kwargs.pop('error_map', None) + kwargs.pop("error_map", None) - def get_long_running_output(pipeline_response): + def get_long_running_output(pipeline_response): # pylint: disable=inconsistent-return-statements if cls: return cls(pipeline_response, None, {}) - - if polling is True: polling_method = AsyncARMPolling(lro_delay, **kwargs) - elif polling is False: polling_method = AsyncNoPolling() - else: polling_method = polling + if polling is True: + polling_method = cast(AsyncPollingMethod, AsyncARMPolling(lro_delay, **kwargs)) # type: AsyncPollingMethod + elif polling is False: + polling_method = cast(AsyncPollingMethod, AsyncNoPolling()) + else: + polling_method = polling if cont_token: return AsyncLROPoller.from_continuation_token( polling_method=polling_method, continuation_token=cont_token, client=self._client, - deserialization_callback=get_long_running_output + deserialization_callback=get_long_running_output, ) return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) - begin_delete_by_id.metadata = {'url': "/{resourceId}"} # type: ignore + begin_delete_by_id.metadata = {"url": "/{resourceId}"} # type: ignore async def _create_or_update_by_id_initial( - self, - resource_id: str, - api_version: str, - parameters: "_models.GenericResource", - **kwargs: Any - ) -> Optional["_models.GenericResource"]: - cls = kwargs.pop('cls', None) # type: ClsType[Optional["_models.GenericResource"]] + self, resource_id: str, api_version: str, parameters: Union[_models.GenericResource, IO], **kwargs: Any + ) -> Optional[_models.GenericResource]: error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = kwargs.pop("params", {}) or {} - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[Optional[_models.GenericResource]] - _json = self._serialize.body(parameters, 'GenericResource') + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(parameters, (IO, bytes)): + _content = parameters + else: + _json = self._serialize.body(parameters, "GenericResource") - request = build_resources_create_or_update_by_id_request_initial( + request = build_resources_create_or_update_by_id_request( resource_id=resource_id, - content_type=content_type, api_version=api_version, + content_type=content_type, json=_json, - template_url=self._create_or_update_by_id_initial.metadata['url'], + content=_content, + template_url=self._create_or_update_by_id_initial.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200, 201, 202]: @@ -3659,37 +4688,42 @@ async def _create_or_update_by_id_initial( deserialized = None if response.status_code == 200: - deserialized = self._deserialize('GenericResource', pipeline_response) + deserialized = self._deserialize("GenericResource", pipeline_response) if response.status_code == 201: - deserialized = self._deserialize('GenericResource', pipeline_response) + deserialized = self._deserialize("GenericResource", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - _create_or_update_by_id_initial.metadata = {'url': "/{resourceId}"} # type: ignore + _create_or_update_by_id_initial.metadata = {"url": "/{resourceId}"} # type: ignore - - @distributed_trace_async + @overload async def begin_create_or_update_by_id( self, resource_id: str, api_version: str, - parameters: "_models.GenericResource", + parameters: _models.GenericResource, + *, + content_type: str = "application/json", **kwargs: Any - ) -> AsyncLROPoller["_models.GenericResource"]: + ) -> AsyncLROPoller[_models.GenericResource]: """Create a resource by ID. :param resource_id: The fully qualified ID of the resource, including the resource name and resource type. Use the format, /subscriptions/{guid}/resourceGroups/{resource-group-name}/{resource-provider-namespace}/{resource-type}/{resource-name}. + Required. :type resource_id: str - :param api_version: The API version to use for the operation. + :param api_version: The API version to use for the operation. Required. :type api_version: str - :param parameters: Create or update resource parameters. + :param parameters: Create or update resource parameters. Required. :type parameters: ~azure.mgmt.resource.resources.v2019_05_10.models.GenericResource + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str :keyword callable cls: A custom type or function that will be passed the direct response :keyword str continuation_token: A continuation token to restart a poller from a saved state. :keyword polling: By default, your polling method will be AsyncARMPolling. Pass in False for @@ -3702,81 +4736,167 @@ async def begin_create_or_update_by_id( cls(response) :rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.resource.resources.v2019_05_10.models.GenericResource] - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] - polling = kwargs.pop('polling', True) # type: Union[bool, AsyncPollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType["_models.GenericResource"] - lro_delay = kwargs.pop( - 'polling_interval', - self._config.polling_interval - ) - cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] + + @overload + async def begin_create_or_update_by_id( + self, + resource_id: str, + api_version: str, + parameters: IO, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> AsyncLROPoller[_models.GenericResource]: + """Create a resource by ID. + + :param resource_id: The fully qualified ID of the resource, including the resource name and + resource type. Use the format, + /subscriptions/{guid}/resourceGroups/{resource-group-name}/{resource-provider-namespace}/{resource-type}/{resource-name}. + Required. + :type resource_id: str + :param api_version: The API version to use for the operation. Required. + :type api_version: str + :param parameters: Create or update resource parameters. Required. + :type parameters: IO + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be AsyncARMPolling. Pass in False for + this operation to not poll, or pass in your own initialized polling object for a personal + polling strategy. + :paramtype polling: bool or ~azure.core.polling.AsyncPollingMethod + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of AsyncLROPoller that returns either GenericResource or the result of + cls(response) + :rtype: + ~azure.core.polling.AsyncLROPoller[~azure.mgmt.resource.resources.v2019_05_10.models.GenericResource] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace_async + async def begin_create_or_update_by_id( + self, resource_id: str, api_version: str, parameters: Union[_models.GenericResource, IO], **kwargs: Any + ) -> AsyncLROPoller[_models.GenericResource]: + """Create a resource by ID. + + :param resource_id: The fully qualified ID of the resource, including the resource name and + resource type. Use the format, + /subscriptions/{guid}/resourceGroups/{resource-group-name}/{resource-provider-namespace}/{resource-type}/{resource-name}. + Required. + :type resource_id: str + :param api_version: The API version to use for the operation. Required. + :type api_version: str + :param parameters: Create or update resource parameters. Is either a model type or a IO type. + Required. + :type parameters: ~azure.mgmt.resource.resources.v2019_05_10.models.GenericResource or IO + :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. + Default value is None. + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be AsyncARMPolling. Pass in False for + this operation to not poll, or pass in your own initialized polling object for a personal + polling strategy. + :paramtype polling: bool or ~azure.core.polling.AsyncPollingMethod + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of AsyncLROPoller that returns either GenericResource or the result of + cls(response) + :rtype: + ~azure.core.polling.AsyncLROPoller[~azure.mgmt.resource.resources.v2019_05_10.models.GenericResource] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = kwargs.pop("params", {}) or {} + + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.GenericResource] + polling = kwargs.pop("polling", True) # type: Union[bool, AsyncPollingMethod] + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token = kwargs.pop("continuation_token", None) # type: Optional[str] if cont_token is None: - raw_result = await self._create_or_update_by_id_initial( + raw_result = await self._create_or_update_by_id_initial( # type: ignore resource_id=resource_id, api_version=api_version, parameters=parameters, content_type=content_type, - cls=lambda x,y,z: x, + cls=lambda x, y, z: x, + headers=_headers, + params=_params, **kwargs ) - kwargs.pop('error_map', None) + kwargs.pop("error_map", None) def get_long_running_output(pipeline_response): - response = pipeline_response.http_response - deserialized = self._deserialize('GenericResource', pipeline_response) + deserialized = self._deserialize("GenericResource", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - - if polling is True: polling_method = AsyncARMPolling(lro_delay, **kwargs) - elif polling is False: polling_method = AsyncNoPolling() - else: polling_method = polling + if polling is True: + polling_method = cast(AsyncPollingMethod, AsyncARMPolling(lro_delay, **kwargs)) # type: AsyncPollingMethod + elif polling is False: + polling_method = cast(AsyncPollingMethod, AsyncNoPolling()) + else: + polling_method = polling if cont_token: return AsyncLROPoller.from_continuation_token( polling_method=polling_method, continuation_token=cont_token, client=self._client, - deserialization_callback=get_long_running_output + deserialization_callback=get_long_running_output, ) return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) - begin_create_or_update_by_id.metadata = {'url': "/{resourceId}"} # type: ignore + begin_create_or_update_by_id.metadata = {"url": "/{resourceId}"} # type: ignore async def _update_by_id_initial( - self, - resource_id: str, - api_version: str, - parameters: "_models.GenericResource", - **kwargs: Any - ) -> Optional["_models.GenericResource"]: - cls = kwargs.pop('cls', None) # type: ClsType[Optional["_models.GenericResource"]] + self, resource_id: str, api_version: str, parameters: Union[_models.GenericResource, IO], **kwargs: Any + ) -> Optional[_models.GenericResource]: error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = kwargs.pop("params", {}) or {} - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[Optional[_models.GenericResource]] - _json = self._serialize.body(parameters, 'GenericResource') + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(parameters, (IO, bytes)): + _content = parameters + else: + _json = self._serialize.body(parameters, "GenericResource") - request = build_resources_update_by_id_request_initial( + request = build_resources_update_by_id_request( resource_id=resource_id, - content_type=content_type, api_version=api_version, + content_type=content_type, json=_json, - template_url=self._update_by_id_initial.metadata['url'], + content=_content, + template_url=self._update_by_id_initial.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200, 202]: @@ -3785,34 +4905,111 @@ async def _update_by_id_initial( deserialized = None if response.status_code == 200: - deserialized = self._deserialize('GenericResource', pipeline_response) + deserialized = self._deserialize("GenericResource", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - _update_by_id_initial.metadata = {'url': "/{resourceId}"} # type: ignore + _update_by_id_initial.metadata = {"url": "/{resourceId}"} # type: ignore + @overload + async def begin_update_by_id( + self, + resource_id: str, + api_version: str, + parameters: _models.GenericResource, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> AsyncLROPoller[_models.GenericResource]: + """Updates a resource by ID. + + :param resource_id: The fully qualified ID of the resource, including the resource name and + resource type. Use the format, + /subscriptions/{guid}/resourceGroups/{resource-group-name}/{resource-provider-namespace}/{resource-type}/{resource-name}. + Required. + :type resource_id: str + :param api_version: The API version to use for the operation. Required. + :type api_version: str + :param parameters: Update resource parameters. Required. + :type parameters: ~azure.mgmt.resource.resources.v2019_05_10.models.GenericResource + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be AsyncARMPolling. Pass in False for + this operation to not poll, or pass in your own initialized polling object for a personal + polling strategy. + :paramtype polling: bool or ~azure.core.polling.AsyncPollingMethod + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of AsyncLROPoller that returns either GenericResource or the result of + cls(response) + :rtype: + ~azure.core.polling.AsyncLROPoller[~azure.mgmt.resource.resources.v2019_05_10.models.GenericResource] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + async def begin_update_by_id( + self, + resource_id: str, + api_version: str, + parameters: IO, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> AsyncLROPoller[_models.GenericResource]: + """Updates a resource by ID. + + :param resource_id: The fully qualified ID of the resource, including the resource name and + resource type. Use the format, + /subscriptions/{guid}/resourceGroups/{resource-group-name}/{resource-provider-namespace}/{resource-type}/{resource-name}. + Required. + :type resource_id: str + :param api_version: The API version to use for the operation. Required. + :type api_version: str + :param parameters: Update resource parameters. Required. + :type parameters: IO + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be AsyncARMPolling. Pass in False for + this operation to not poll, or pass in your own initialized polling object for a personal + polling strategy. + :paramtype polling: bool or ~azure.core.polling.AsyncPollingMethod + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of AsyncLROPoller that returns either GenericResource or the result of + cls(response) + :rtype: + ~azure.core.polling.AsyncLROPoller[~azure.mgmt.resource.resources.v2019_05_10.models.GenericResource] + :raises ~azure.core.exceptions.HttpResponseError: + """ @distributed_trace_async async def begin_update_by_id( - self, - resource_id: str, - api_version: str, - parameters: "_models.GenericResource", - **kwargs: Any - ) -> AsyncLROPoller["_models.GenericResource"]: + self, resource_id: str, api_version: str, parameters: Union[_models.GenericResource, IO], **kwargs: Any + ) -> AsyncLROPoller[_models.GenericResource]: """Updates a resource by ID. :param resource_id: The fully qualified ID of the resource, including the resource name and resource type. Use the format, /subscriptions/{guid}/resourceGroups/{resource-group-name}/{resource-provider-namespace}/{resource-type}/{resource-name}. + Required. :type resource_id: str - :param api_version: The API version to use for the operation. + :param api_version: The API version to use for the operation. Required. :type api_version: str - :param parameters: Update resource parameters. - :type parameters: ~azure.mgmt.resource.resources.v2019_05_10.models.GenericResource + :param parameters: Update resource parameters. Is either a model type or a IO type. Required. + :type parameters: ~azure.mgmt.resource.resources.v2019_05_10.models.GenericResource or IO + :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. + Default value is None. + :paramtype content_type: str :keyword callable cls: A custom type or function that will be passed the direct response :keyword str continuation_token: A continuation token to restart a poller from a saved state. :keyword polling: By default, your polling method will be AsyncARMPolling. Pass in False for @@ -3825,165 +5022,171 @@ async def begin_update_by_id( cls(response) :rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.resource.resources.v2019_05_10.models.GenericResource] - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] - polling = kwargs.pop('polling', True) # type: Union[bool, AsyncPollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType["_models.GenericResource"] - lro_delay = kwargs.pop( - 'polling_interval', - self._config.polling_interval - ) - cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = kwargs.pop("params", {}) or {} + + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.GenericResource] + polling = kwargs.pop("polling", True) # type: Union[bool, AsyncPollingMethod] + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token = kwargs.pop("continuation_token", None) # type: Optional[str] if cont_token is None: - raw_result = await self._update_by_id_initial( + raw_result = await self._update_by_id_initial( # type: ignore resource_id=resource_id, api_version=api_version, parameters=parameters, content_type=content_type, - cls=lambda x,y,z: x, + cls=lambda x, y, z: x, + headers=_headers, + params=_params, **kwargs ) - kwargs.pop('error_map', None) + kwargs.pop("error_map", None) def get_long_running_output(pipeline_response): - response = pipeline_response.http_response - deserialized = self._deserialize('GenericResource', pipeline_response) + deserialized = self._deserialize("GenericResource", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - - if polling is True: polling_method = AsyncARMPolling(lro_delay, **kwargs) - elif polling is False: polling_method = AsyncNoPolling() - else: polling_method = polling + if polling is True: + polling_method = cast(AsyncPollingMethod, AsyncARMPolling(lro_delay, **kwargs)) # type: AsyncPollingMethod + elif polling is False: + polling_method = cast(AsyncPollingMethod, AsyncNoPolling()) + else: + polling_method = polling if cont_token: return AsyncLROPoller.from_continuation_token( polling_method=polling_method, continuation_token=cont_token, client=self._client, - deserialization_callback=get_long_running_output + deserialization_callback=get_long_running_output, ) return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) - begin_update_by_id.metadata = {'url': "/{resourceId}"} # type: ignore + begin_update_by_id.metadata = {"url": "/{resourceId}"} # type: ignore @distributed_trace_async - async def get_by_id( - self, - resource_id: str, - api_version: str, - **kwargs: Any - ) -> "_models.GenericResource": + async def get_by_id(self, resource_id: str, api_version: str, **kwargs: Any) -> _models.GenericResource: """Gets a resource by ID. :param resource_id: The fully qualified ID of the resource, including the resource name and resource type. Use the format, /subscriptions/{guid}/resourceGroups/{resource-group-name}/{resource-provider-namespace}/{resource-type}/{resource-name}. + Required. :type resource_id: str - :param api_version: The API version to use for the operation. + :param api_version: The API version to use for the operation. Required. :type api_version: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: GenericResource, or the result of cls(response) + :return: GenericResource or the result of cls(response) :rtype: ~azure.mgmt.resource.resources.v2019_05_10.models.GenericResource - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.GenericResource"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = kwargs.pop("params", {}) or {} + + cls = kwargs.pop("cls", None) # type: ClsType[_models.GenericResource] - request = build_resources_get_by_id_request( resource_id=resource_id, api_version=api_version, - template_url=self.get_by_id.metadata['url'], + template_url=self.get_by_id.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) - deserialized = self._deserialize('GenericResource', pipeline_response) + deserialized = self._deserialize("GenericResource", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - get_by_id.metadata = {'url': "/{resourceId}"} # type: ignore + get_by_id.metadata = {"url": "/{resourceId}"} # type: ignore -class ResourceGroupsOperations: - """ResourceGroupsOperations async operations. - You should not instantiate this class directly. Instead, you should create a Client instance that - instantiates it for you and attaches it as an attribute. +class ResourceGroupsOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. - :ivar models: Alias to model classes used in this operation group. - :type models: ~azure.mgmt.resource.resources.v2019_05_10.models - :param client: Client for service requests. - :param config: Configuration of service client. - :param serializer: An object model serializer. - :param deserializer: An object model deserializer. + Instead, you should access the following operations through + :class:`~azure.mgmt.resource.resources.v2019_05_10.aio.ResourceManagementClient`'s + :attr:`resource_groups` attribute. """ models = _models - def __init__(self, client, config, serializer, deserializer) -> None: - self._client = client - self._serialize = serializer - self._deserialize = deserializer - self._config = config + def __init__(self, *args, **kwargs) -> None: + input_args = list(args) + self._client = input_args.pop(0) if input_args else kwargs.pop("client") + self._config = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") @distributed_trace_async - async def check_existence( - self, - resource_group_name: str, - **kwargs: Any - ) -> bool: + async def check_existence(self, resource_group_name: str, **kwargs: Any) -> bool: """Checks whether a resource group exists. :param resource_group_name: The name of the resource group to check. The name is case - insensitive. + insensitive. Required. :type resource_group_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: bool, or the result of cls(response) + :return: bool or the result of cls(response) :rtype: bool - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType[None] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) - api_version = kwargs.pop('api_version', "2019-05-10") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2019-05-10")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[None] - request = build_resource_groups_check_existence_request( resource_group_name=resource_group_name, subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.check_existence.metadata['url'], + template_url=self.check_existence.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [204, 404]: @@ -3994,39 +5197,98 @@ async def check_existence( return cls(pipeline_response, None, {}) return 200 <= response.status_code <= 299 - check_existence.metadata = {'url': "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}"} # type: ignore + check_existence.metadata = {"url": "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}"} # type: ignore - - @distributed_trace_async + @overload async def create_or_update( self, resource_group_name: str, - parameters: "_models.ResourceGroup", + parameters: _models.ResourceGroup, + *, + content_type: str = "application/json", **kwargs: Any - ) -> "_models.ResourceGroup": + ) -> _models.ResourceGroup: """Creates or updates a resource group. :param resource_group_name: The name of the resource group to create or update. Can include alphanumeric, underscore, parentheses, hyphen, period (except at end), and Unicode characters - that match the allowed characters. + that match the allowed characters. Required. :type resource_group_name: str - :param parameters: Parameters supplied to the create or update a resource group. + :param parameters: Parameters supplied to the create or update a resource group. Required. :type parameters: ~azure.mgmt.resource.resources.v2019_05_10.models.ResourceGroup + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: ResourceGroup or the result of cls(response) + :rtype: ~azure.mgmt.resource.resources.v2019_05_10.models.ResourceGroup + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + async def create_or_update( + self, resource_group_name: str, parameters: IO, *, content_type: str = "application/json", **kwargs: Any + ) -> _models.ResourceGroup: + """Creates or updates a resource group. + + :param resource_group_name: The name of the resource group to create or update. Can include + alphanumeric, underscore, parentheses, hyphen, period (except at end), and Unicode characters + that match the allowed characters. Required. + :type resource_group_name: str + :param parameters: Parameters supplied to the create or update a resource group. Required. + :type parameters: IO + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: ResourceGroup or the result of cls(response) + :rtype: ~azure.mgmt.resource.resources.v2019_05_10.models.ResourceGroup + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace_async + async def create_or_update( + self, resource_group_name: str, parameters: Union[_models.ResourceGroup, IO], **kwargs: Any + ) -> _models.ResourceGroup: + """Creates or updates a resource group. + + :param resource_group_name: The name of the resource group to create or update. Can include + alphanumeric, underscore, parentheses, hyphen, period (except at end), and Unicode characters + that match the allowed characters. Required. + :type resource_group_name: str + :param parameters: Parameters supplied to the create or update a resource group. Is either a + model type or a IO type. Required. + :type parameters: ~azure.mgmt.resource.resources.v2019_05_10.models.ResourceGroup or IO + :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. + Default value is None. + :paramtype content_type: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: ResourceGroup, or the result of cls(response) + :return: ResourceGroup or the result of cls(response) :rtype: ~azure.mgmt.resource.resources.v2019_05_10.models.ResourceGroup - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.ResourceGroup"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) - api_version = kwargs.pop('api_version', "2019-05-10") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - _json = self._serialize.body(parameters, 'ResourceGroup') + api_version = kwargs.pop("api_version", _params.pop("api-version", "2019-05-10")) # type: str + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.ResourceGroup] + + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(parameters, (IO, bytes)): + _content = parameters + else: + _json = self._serialize.body(parameters, "ResourceGroup") request = build_resource_groups_create_or_update_request( resource_group_name=resource_group_name, @@ -4034,16 +5296,18 @@ async def create_or_update( api_version=api_version, content_type=content_type, json=_json, - template_url=self.create_or_update.metadata['url'], + content=_content, + template_url=self.create_or_update.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200, 201]: @@ -4051,47 +5315,50 @@ async def create_or_update( raise HttpResponseError(response=response, error_format=ARMErrorFormat) if response.status_code == 200: - deserialized = self._deserialize('ResourceGroup', pipeline_response) + deserialized = self._deserialize("ResourceGroup", pipeline_response) if response.status_code == 201: - deserialized = self._deserialize('ResourceGroup', pipeline_response) + deserialized = self._deserialize("ResourceGroup", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - create_or_update.metadata = {'url': "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}"} # type: ignore - + create_or_update.metadata = {"url": "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}"} # type: ignore async def _delete_initial( # pylint: disable=inconsistent-return-statements - self, - resource_group_name: str, - **kwargs: Any + self, resource_group_name: str, **kwargs: Any ) -> None: - cls = kwargs.pop('cls', None) # type: ClsType[None] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) - api_version = kwargs.pop('api_version', "2019-05-10") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - request = build_resource_groups_delete_request_initial( + api_version = kwargs.pop("api_version", _params.pop("api-version", "2019-05-10")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[None] + + request = build_resource_groups_delete_request( resource_group_name=resource_group_name, subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self._delete_initial.metadata['url'], + template_url=self._delete_initial.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200, 202]: @@ -4101,22 +5368,17 @@ async def _delete_initial( # pylint: disable=inconsistent-return-statements if cls: return cls(pipeline_response, None, {}) - _delete_initial.metadata = {'url': "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}"} # type: ignore - + _delete_initial.metadata = {"url": "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}"} # type: ignore @distributed_trace_async - async def begin_delete( # pylint: disable=inconsistent-return-statements - self, - resource_group_name: str, - **kwargs: Any - ) -> AsyncLROPoller[None]: + async def begin_delete(self, resource_group_name: str, **kwargs: Any) -> AsyncLROPoller[None]: """Deletes a resource group. When you delete a resource group, all of its resources are also deleted. Deleting a resource group deletes all of its template deployments and currently stored operations. :param resource_group_name: The name of the resource group to delete. The name is case - insensitive. + insensitive. Required. :type resource_group_name: str :keyword callable cls: A custom type or function that will be passed the direct response :keyword str continuation_token: A continuation token to restart a poller from a saved state. @@ -4128,106 +5390,113 @@ async def begin_delete( # pylint: disable=inconsistent-return-statements Retry-After header is present. :return: An instance of AsyncLROPoller that returns either None or the result of cls(response) :rtype: ~azure.core.polling.AsyncLROPoller[None] - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - api_version = kwargs.pop('api_version', "2019-05-10") # type: str - polling = kwargs.pop('polling', True) # type: Union[bool, AsyncPollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType[None] - lro_delay = kwargs.pop( - 'polling_interval', - self._config.polling_interval - ) - cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2019-05-10")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[None] + polling = kwargs.pop("polling", True) # type: Union[bool, AsyncPollingMethod] + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token = kwargs.pop("continuation_token", None) # type: Optional[str] if cont_token is None: - raw_result = await self._delete_initial( + raw_result = await self._delete_initial( # type: ignore resource_group_name=resource_group_name, api_version=api_version, - cls=lambda x,y,z: x, + cls=lambda x, y, z: x, + headers=_headers, + params=_params, **kwargs ) - kwargs.pop('error_map', None) + kwargs.pop("error_map", None) - def get_long_running_output(pipeline_response): + def get_long_running_output(pipeline_response): # pylint: disable=inconsistent-return-statements if cls: return cls(pipeline_response, None, {}) - - if polling is True: polling_method = AsyncARMPolling(lro_delay, **kwargs) - elif polling is False: polling_method = AsyncNoPolling() - else: polling_method = polling + if polling is True: + polling_method = cast(AsyncPollingMethod, AsyncARMPolling(lro_delay, **kwargs)) # type: AsyncPollingMethod + elif polling is False: + polling_method = cast(AsyncPollingMethod, AsyncNoPolling()) + else: + polling_method = polling if cont_token: return AsyncLROPoller.from_continuation_token( polling_method=polling_method, continuation_token=cont_token, client=self._client, - deserialization_callback=get_long_running_output + deserialization_callback=get_long_running_output, ) return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) - begin_delete.metadata = {'url': "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}"} # type: ignore + begin_delete.metadata = {"url": "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}"} # type: ignore @distributed_trace_async - async def get( - self, - resource_group_name: str, - **kwargs: Any - ) -> "_models.ResourceGroup": + async def get(self, resource_group_name: str, **kwargs: Any) -> _models.ResourceGroup: """Gets a resource group. :param resource_group_name: The name of the resource group to get. The name is case - insensitive. + insensitive. Required. :type resource_group_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: ResourceGroup, or the result of cls(response) + :return: ResourceGroup or the result of cls(response) :rtype: ~azure.mgmt.resource.resources.v2019_05_10.models.ResourceGroup - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.ResourceGroup"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) - api_version = kwargs.pop('api_version', "2019-05-10") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2019-05-10")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[_models.ResourceGroup] - request = build_resource_groups_get_request( resource_group_name=resource_group_name, subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.get.metadata['url'], + template_url=self.get.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) - deserialized = self._deserialize('ResourceGroup', pipeline_response) + deserialized = self._deserialize("ResourceGroup", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - get.metadata = {'url': "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}"} # type: ignore + get.metadata = {"url": "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}"} # type: ignore - - @distributed_trace_async + @overload async def update( self, resource_group_name: str, - parameters: "_models.ResourceGroupPatchable", + parameters: _models.ResourceGroupPatchable, + *, + content_type: str = "application/json", **kwargs: Any - ) -> "_models.ResourceGroup": + ) -> _models.ResourceGroup: """Updates a resource group. Resource groups can be updated through a simple PATCH operation to a group address. The format @@ -4235,25 +5504,90 @@ async def update( the current value is retained. :param resource_group_name: The name of the resource group to update. The name is case - insensitive. + insensitive. Required. :type resource_group_name: str - :param parameters: Parameters supplied to update a resource group. + :param parameters: Parameters supplied to update a resource group. Required. :type parameters: ~azure.mgmt.resource.resources.v2019_05_10.models.ResourceGroupPatchable + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: ResourceGroup or the result of cls(response) + :rtype: ~azure.mgmt.resource.resources.v2019_05_10.models.ResourceGroup + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + async def update( + self, resource_group_name: str, parameters: IO, *, content_type: str = "application/json", **kwargs: Any + ) -> _models.ResourceGroup: + """Updates a resource group. + + Resource groups can be updated through a simple PATCH operation to a group address. The format + of the request is the same as that for creating a resource group. If a field is unspecified, + the current value is retained. + + :param resource_group_name: The name of the resource group to update. The name is case + insensitive. Required. + :type resource_group_name: str + :param parameters: Parameters supplied to update a resource group. Required. + :type parameters: IO + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: ResourceGroup or the result of cls(response) + :rtype: ~azure.mgmt.resource.resources.v2019_05_10.models.ResourceGroup + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace_async + async def update( + self, resource_group_name: str, parameters: Union[_models.ResourceGroupPatchable, IO], **kwargs: Any + ) -> _models.ResourceGroup: + """Updates a resource group. + + Resource groups can be updated through a simple PATCH operation to a group address. The format + of the request is the same as that for creating a resource group. If a field is unspecified, + the current value is retained. + + :param resource_group_name: The name of the resource group to update. The name is case + insensitive. Required. + :type resource_group_name: str + :param parameters: Parameters supplied to update a resource group. Is either a model type or a + IO type. Required. + :type parameters: ~azure.mgmt.resource.resources.v2019_05_10.models.ResourceGroupPatchable or + IO + :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. + Default value is None. + :paramtype content_type: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: ResourceGroup, or the result of cls(response) + :return: ResourceGroup or the result of cls(response) :rtype: ~azure.mgmt.resource.resources.v2019_05_10.models.ResourceGroup - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.ResourceGroup"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) - api_version = kwargs.pop('api_version', "2019-05-10") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - _json = self._serialize.body(parameters, 'ResourceGroupPatchable') + api_version = kwargs.pop("api_version", _params.pop("api-version", "2019-05-10")) # type: str + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.ResourceGroup] + + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(parameters, (IO, bytes)): + _content = parameters + else: + _json = self._serialize.body(parameters, "ResourceGroupPatchable") request = build_resource_groups_update_request( resource_group_name=resource_group_name, @@ -4261,60 +5595,117 @@ async def update( api_version=api_version, content_type=content_type, json=_json, - template_url=self.update.metadata['url'], + content=_content, + template_url=self.update.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) - deserialized = self._deserialize('ResourceGroup', pipeline_response) + deserialized = self._deserialize("ResourceGroup", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - update.metadata = {'url': "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}"} # type: ignore + update.metadata = {"url": "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}"} # type: ignore - - @distributed_trace_async + @overload async def export_template( self, resource_group_name: str, - parameters: "_models.ExportTemplateRequest", + parameters: _models.ExportTemplateRequest, + *, + content_type: str = "application/json", **kwargs: Any - ) -> "_models.ResourceGroupExportResult": + ) -> _models.ResourceGroupExportResult: """Captures the specified resource group as a template. - :param resource_group_name: The name of the resource group to export as a template. + :param resource_group_name: The name of the resource group to export as a template. Required. :type resource_group_name: str - :param parameters: Parameters for exporting the template. + :param parameters: Parameters for exporting the template. Required. :type parameters: ~azure.mgmt.resource.resources.v2019_05_10.models.ExportTemplateRequest + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: ResourceGroupExportResult or the result of cls(response) + :rtype: ~azure.mgmt.resource.resources.v2019_05_10.models.ResourceGroupExportResult + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + async def export_template( + self, resource_group_name: str, parameters: IO, *, content_type: str = "application/json", **kwargs: Any + ) -> _models.ResourceGroupExportResult: + """Captures the specified resource group as a template. + + :param resource_group_name: The name of the resource group to export as a template. Required. + :type resource_group_name: str + :param parameters: Parameters for exporting the template. Required. + :type parameters: IO + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: ResourceGroupExportResult or the result of cls(response) + :rtype: ~azure.mgmt.resource.resources.v2019_05_10.models.ResourceGroupExportResult + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace_async + async def export_template( + self, resource_group_name: str, parameters: Union[_models.ExportTemplateRequest, IO], **kwargs: Any + ) -> _models.ResourceGroupExportResult: + """Captures the specified resource group as a template. + + :param resource_group_name: The name of the resource group to export as a template. Required. + :type resource_group_name: str + :param parameters: Parameters for exporting the template. Is either a model type or a IO type. + Required. + :type parameters: ~azure.mgmt.resource.resources.v2019_05_10.models.ExportTemplateRequest or IO + :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. + Default value is None. + :paramtype content_type: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: ResourceGroupExportResult, or the result of cls(response) + :return: ResourceGroupExportResult or the result of cls(response) :rtype: ~azure.mgmt.resource.resources.v2019_05_10.models.ResourceGroupExportResult - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.ResourceGroupExportResult"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) - api_version = kwargs.pop('api_version', "2019-05-10") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - _json = self._serialize.body(parameters, 'ExportTemplateRequest') + api_version = kwargs.pop("api_version", _params.pop("api-version", "2019-05-10")) # type: str + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.ResourceGroupExportResult] + + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(parameters, (IO, bytes)): + _content = parameters + else: + _json = self._serialize.body(parameters, "ExportTemplateRequest") request = build_resource_groups_export_template_request( resource_group_name=resource_group_name, @@ -4322,39 +5713,37 @@ async def export_template( api_version=api_version, content_type=content_type, json=_json, - template_url=self.export_template.metadata['url'], + content=_content, + template_url=self.export_template.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) - deserialized = self._deserialize('ResourceGroupExportResult', pipeline_response) + deserialized = self._deserialize("ResourceGroupExportResult", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - export_template.metadata = {'url': "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/exportTemplate"} # type: ignore - + export_template.metadata = {"url": "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/exportTemplate"} # type: ignore @distributed_trace def list( - self, - filter: Optional[str] = None, - top: Optional[int] = None, - **kwargs: Any - ) -> AsyncIterable["_models.ResourceGroupListResult"]: + self, filter: Optional[str] = None, top: Optional[int] = None, **kwargs: Any + ) -> AsyncIterable["_models.ResourceGroup"]: """Gets all the resource groups for a subscription. :param filter: The filter to apply on the operation.:code:`
`:code:`
`You can filter by @@ -4365,40 +5754,48 @@ def list( Default value is None. :type top: int :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either ResourceGroupListResult or the result of - cls(response) + :return: An iterator like instance of either ResourceGroup or the result of cls(response) :rtype: - ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.resource.resources.v2019_05_10.models.ResourceGroupListResult] - :raises: ~azure.core.exceptions.HttpResponseError + ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.resource.resources.v2019_05_10.models.ResourceGroup] + :raises ~azure.core.exceptions.HttpResponseError: """ - api_version = kwargs.pop('api_version', "2019-05-10") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2019-05-10")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[_models.ResourceGroupListResult] - cls = kwargs.pop('cls', None) # type: ClsType["_models.ResourceGroupListResult"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) + def prepare_request(next_link=None): if not next_link: - + request = build_resource_groups_list_request( subscription_id=self._config.subscription_id, - api_version=api_version, filter=filter, top=top, - template_url=self.list.metadata['url'], + 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.url = self._client.format_url(request.url) # type: ignore else: - - request = build_resource_groups_list_request( - subscription_id=self._config.subscription_id, - template_url=next_link, - ) + # make call to next link with the client's api-version + _parsed_next_link = urlparse(next_link) + _next_request_params = case_insensitive_dict(parse_qs(_parsed_next_link.query)) + _next_request_params["api-version"] = self._config.api_version + request = HttpRequest("GET", urljoin(next_link, _parsed_next_link.path), params=_next_request_params) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore request.method = "GET" return request @@ -4412,10 +5809,8 @@ async def extract_data(pipeline_response): async def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) response = pipeline_response.http_response @@ -4425,75 +5820,75 @@ async def get_next(next_link=None): return pipeline_response + return AsyncItemPaged(get_next, extract_data) + + list.metadata = {"url": "/subscriptions/{subscriptionId}/resourcegroups"} # type: ignore - return AsyncItemPaged( - get_next, extract_data - ) - list.metadata = {'url': "/subscriptions/{subscriptionId}/resourcegroups"} # type: ignore -class TagsOperations: - """TagsOperations async operations. - You should not instantiate this class directly. Instead, you should create a Client instance that - instantiates it for you and attaches it as an attribute. +class TagsOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. - :ivar models: Alias to model classes used in this operation group. - :type models: ~azure.mgmt.resource.resources.v2019_05_10.models - :param client: Client for service requests. - :param config: Configuration of service client. - :param serializer: An object model serializer. - :param deserializer: An object model deserializer. + Instead, you should access the following operations through + :class:`~azure.mgmt.resource.resources.v2019_05_10.aio.ResourceManagementClient`'s + :attr:`tags` attribute. """ models = _models - def __init__(self, client, config, serializer, deserializer) -> None: - self._client = client - self._serialize = serializer - self._deserialize = deserializer - self._config = config + def __init__(self, *args, **kwargs) -> None: + input_args = list(args) + self._client = input_args.pop(0) if input_args else kwargs.pop("client") + self._config = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") @distributed_trace_async async def delete_value( # pylint: disable=inconsistent-return-statements - self, - tag_name: str, - tag_value: str, - **kwargs: Any + self, tag_name: str, tag_value: str, **kwargs: Any ) -> None: """Deletes a tag value. - :param tag_name: The name of the tag. + :param tag_name: The name of the tag. Required. :type tag_name: str - :param tag_value: The value of the tag to delete. + :param tag_value: The value of the tag to delete. Required. :type tag_value: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: None, or the result of cls(response) + :return: None or the result of cls(response) :rtype: None - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType[None] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) - api_version = kwargs.pop('api_version', "2019-05-10") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2019-05-10")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[None] - request = build_tags_delete_value_request( tag_name=tag_name, tag_value=tag_value, subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.delete_value.metadata['url'], + template_url=self.delete_value.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200, 204]: @@ -4503,51 +5898,51 @@ async def delete_value( # pylint: disable=inconsistent-return-statements if cls: return cls(pipeline_response, None, {}) - delete_value.metadata = {'url': "/subscriptions/{subscriptionId}/tagNames/{tagName}/tagValues/{tagValue}"} # type: ignore - + delete_value.metadata = {"url": "/subscriptions/{subscriptionId}/tagNames/{tagName}/tagValues/{tagValue}"} # type: ignore @distributed_trace_async - async def create_or_update_value( - self, - tag_name: str, - tag_value: str, - **kwargs: Any - ) -> "_models.TagValue": + async def create_or_update_value(self, tag_name: str, tag_value: str, **kwargs: Any) -> _models.TagValue: """Creates a tag value. The name of the tag must already exist. - :param tag_name: The name of the tag. + :param tag_name: The name of the tag. Required. :type tag_name: str - :param tag_value: The value of the tag to create. + :param tag_value: The value of the tag to create. Required. :type tag_value: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: TagValue, or the result of cls(response) + :return: TagValue or the result of cls(response) :rtype: ~azure.mgmt.resource.resources.v2019_05_10.models.TagValue - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.TagValue"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + 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', "2019-05-10") # type: str + api_version = kwargs.pop("api_version", _params.pop("api-version", "2019-05-10")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[_models.TagValue] - request = build_tags_create_or_update_value_request( tag_name=tag_name, tag_value=tag_value, subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.create_or_update_value.metadata['url'], + template_url=self.create_or_update_value.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200, 201]: @@ -4555,61 +5950,62 @@ async def create_or_update_value( raise HttpResponseError(response=response, error_format=ARMErrorFormat) if response.status_code == 200: - deserialized = self._deserialize('TagValue', pipeline_response) + deserialized = self._deserialize("TagValue", pipeline_response) if response.status_code == 201: - deserialized = self._deserialize('TagValue', pipeline_response) + deserialized = self._deserialize("TagValue", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - create_or_update_value.metadata = {'url': "/subscriptions/{subscriptionId}/tagNames/{tagName}/tagValues/{tagValue}"} # type: ignore - + create_or_update_value.metadata = {"url": "/subscriptions/{subscriptionId}/tagNames/{tagName}/tagValues/{tagValue}"} # type: ignore @distributed_trace_async - async def create_or_update( - self, - tag_name: str, - **kwargs: Any - ) -> "_models.TagDetails": + async def create_or_update(self, tag_name: str, **kwargs: Any) -> _models.TagDetails: """Creates a tag in the subscription. The tag name can have a maximum of 512 characters and is case insensitive. Tag names created by Azure have prefixes of microsoft, azure, or windows. You cannot create tags with one of these prefixes. - :param tag_name: The name of the tag to create. + :param tag_name: The name of the tag to create. Required. :type tag_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: TagDetails, or the result of cls(response) + :return: TagDetails or the result of cls(response) :rtype: ~azure.mgmt.resource.resources.v2019_05_10.models.TagDetails - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.TagDetails"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + 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', "2019-05-10") # type: str + api_version = kwargs.pop("api_version", _params.pop("api-version", "2019-05-10")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[_models.TagDetails] - request = build_tags_create_or_update_request( tag_name=tag_name, subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.create_or_update.metadata['url'], + template_url=self.create_or_update.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200, 201]: @@ -4617,59 +6013,60 @@ async def create_or_update( raise HttpResponseError(response=response, error_format=ARMErrorFormat) if response.status_code == 200: - deserialized = self._deserialize('TagDetails', pipeline_response) + deserialized = self._deserialize("TagDetails", pipeline_response) if response.status_code == 201: - deserialized = self._deserialize('TagDetails', pipeline_response) + deserialized = self._deserialize("TagDetails", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - create_or_update.metadata = {'url': "/subscriptions/{subscriptionId}/tagNames/{tagName}"} # type: ignore - + create_or_update.metadata = {"url": "/subscriptions/{subscriptionId}/tagNames/{tagName}"} # type: ignore @distributed_trace_async - async def delete( # pylint: disable=inconsistent-return-statements - self, - tag_name: str, - **kwargs: Any - ) -> None: + async def delete(self, tag_name: str, **kwargs: Any) -> None: # pylint: disable=inconsistent-return-statements """Deletes a tag from the subscription. You must remove all values from a resource tag before you can delete it. - :param tag_name: The name of the tag. + :param tag_name: The name of the tag. Required. :type tag_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: None, or the result of cls(response) + :return: None or the result of cls(response) :rtype: None - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType[None] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + 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', "2019-05-10") # type: str + api_version = kwargs.pop("api_version", _params.pop("api-version", "2019-05-10")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[None] - request = build_tags_delete_request( tag_name=tag_name, subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.delete.metadata['url'], + template_url=self.delete.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200, 204]: @@ -4679,48 +6076,53 @@ async def delete( # pylint: disable=inconsistent-return-statements if cls: return cls(pipeline_response, None, {}) - delete.metadata = {'url': "/subscriptions/{subscriptionId}/tagNames/{tagName}"} # type: ignore - + delete.metadata = {"url": "/subscriptions/{subscriptionId}/tagNames/{tagName}"} # type: ignore @distributed_trace - def list( - self, - **kwargs: Any - ) -> AsyncIterable["_models.TagsListResult"]: + def list(self, **kwargs: Any) -> AsyncIterable["_models.TagDetails"]: """Gets the names and values of all resource tags that are defined in a subscription. :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either TagsListResult or the result of cls(response) + :return: An iterator like instance of either TagDetails or the result of cls(response) :rtype: - ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.resource.resources.v2019_05_10.models.TagsListResult] - :raises: ~azure.core.exceptions.HttpResponseError + ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.resource.resources.v2019_05_10.models.TagDetails] + :raises ~azure.core.exceptions.HttpResponseError: """ - api_version = kwargs.pop('api_version', "2019-05-10") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2019-05-10")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[_models.TagsListResult] - cls = kwargs.pop('cls', None) # type: ClsType["_models.TagsListResult"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) + def prepare_request(next_link=None): if not next_link: - + request = build_tags_list_request( subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.list.metadata['url'], + template_url=self.list.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore else: - - request = build_tags_list_request( - subscription_id=self._config.subscription_id, - template_url=next_link, - ) + # make call to next link with the client's api-version + _parsed_next_link = urlparse(next_link) + _next_request_params = case_insensitive_dict(parse_qs(_parsed_next_link.query)) + _next_request_params["api-version"] = self._config.api_version + request = HttpRequest("GET", urljoin(next_link, _parsed_next_link.path), params=_next_request_params) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore request.method = "GET" return request @@ -4734,10 +6136,8 @@ async def extract_data(pipeline_response): async def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) response = pipeline_response.http_response @@ -4747,146 +6147,147 @@ async def get_next(next_link=None): return pipeline_response + return AsyncItemPaged(get_next, extract_data) - return AsyncItemPaged( - get_next, extract_data - ) - list.metadata = {'url': "/subscriptions/{subscriptionId}/tagNames"} # type: ignore -class DeploymentOperationsOperations: - """DeploymentOperationsOperations async operations. + list.metadata = {"url": "/subscriptions/{subscriptionId}/tagNames"} # type: ignore - You should not instantiate this class directly. Instead, you should create a Client instance that - instantiates it for you and attaches it as an attribute. - :ivar models: Alias to model classes used in this operation group. - :type models: ~azure.mgmt.resource.resources.v2019_05_10.models - :param client: Client for service requests. - :param config: Configuration of service client. - :param serializer: An object model serializer. - :param deserializer: An object model deserializer. +class DeploymentOperationsOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. + + Instead, you should access the following operations through + :class:`~azure.mgmt.resource.resources.v2019_05_10.aio.ResourceManagementClient`'s + :attr:`deployment_operations` attribute. """ models = _models - def __init__(self, client, config, serializer, deserializer) -> None: - self._client = client - self._serialize = serializer - self._deserialize = deserializer - self._config = config + def __init__(self, *args, **kwargs) -> None: + input_args = list(args) + self._client = input_args.pop(0) if input_args else kwargs.pop("client") + self._config = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") @distributed_trace_async async def get_at_management_group_scope( - self, - group_id: str, - deployment_name: str, - operation_id: str, - **kwargs: Any - ) -> "_models.DeploymentOperation": + self, group_id: str, deployment_name: str, operation_id: str, **kwargs: Any + ) -> _models.DeploymentOperation: """Gets a deployments operation. - :param group_id: The management group ID. + :param group_id: The management group ID. Required. :type group_id: str - :param deployment_name: The name of the deployment. + :param deployment_name: The name of the deployment. Required. :type deployment_name: str - :param operation_id: The ID of the operation to get. + :param operation_id: The ID of the operation to get. Required. :type operation_id: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: DeploymentOperation, or the result of cls(response) + :return: DeploymentOperation or the result of cls(response) :rtype: ~azure.mgmt.resource.resources.v2019_05_10.models.DeploymentOperation - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.DeploymentOperation"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + 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', "2019-05-10") # type: str + api_version = kwargs.pop("api_version", _params.pop("api-version", "2019-05-10")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[_models.DeploymentOperation] - request = build_deployment_operations_get_at_management_group_scope_request( group_id=group_id, deployment_name=deployment_name, operation_id=operation_id, api_version=api_version, - template_url=self.get_at_management_group_scope.metadata['url'], + template_url=self.get_at_management_group_scope.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) - deserialized = self._deserialize('DeploymentOperation', pipeline_response) + deserialized = self._deserialize("DeploymentOperation", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - get_at_management_group_scope.metadata = {'url': "/providers/Microsoft.Management/managementGroups/{groupId}/providers/Microsoft.Resources/deployments/{deploymentName}/operations/{operationId}"} # type: ignore - + get_at_management_group_scope.metadata = {"url": "/providers/Microsoft.Management/managementGroups/{groupId}/providers/Microsoft.Resources/deployments/{deploymentName}/operations/{operationId}"} # type: ignore @distributed_trace def list_at_management_group_scope( - self, - group_id: str, - deployment_name: str, - top: Optional[int] = None, - **kwargs: Any - ) -> AsyncIterable["_models.DeploymentOperationsListResult"]: + self, group_id: str, deployment_name: str, top: Optional[int] = None, **kwargs: Any + ) -> AsyncIterable["_models.DeploymentOperation"]: """Gets all deployments operations for a deployment. - :param group_id: The management group ID. + :param group_id: The management group ID. Required. :type group_id: str - :param deployment_name: The name of the deployment. + :param deployment_name: The name of the deployment. Required. :type deployment_name: str :param top: The number of results to return. Default value is None. :type top: int :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either DeploymentOperationsListResult or the result of - cls(response) + :return: An iterator like instance of either DeploymentOperation or the result of cls(response) :rtype: - ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.resource.resources.v2019_05_10.models.DeploymentOperationsListResult] - :raises: ~azure.core.exceptions.HttpResponseError + ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.resource.resources.v2019_05_10.models.DeploymentOperation] + :raises ~azure.core.exceptions.HttpResponseError: """ - api_version = kwargs.pop('api_version', "2019-05-10") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2019-05-10")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[_models.DeploymentOperationsListResult] - cls = kwargs.pop('cls', None) # type: ClsType["_models.DeploymentOperationsListResult"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) + def prepare_request(next_link=None): if not next_link: - + request = build_deployment_operations_list_at_management_group_scope_request( group_id=group_id, deployment_name=deployment_name, - api_version=api_version, top=top, - template_url=self.list_at_management_group_scope.metadata['url'], + api_version=api_version, + template_url=self.list_at_management_group_scope.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore else: - - request = build_deployment_operations_list_at_management_group_scope_request( - group_id=group_id, - deployment_name=deployment_name, - template_url=next_link, - ) + # make call to next link with the client's api-version + _parsed_next_link = urlparse(next_link) + _next_request_params = case_insensitive_dict(parse_qs(_parsed_next_link.query)) + _next_request_params["api-version"] = self._config.api_version + request = HttpRequest("GET", urljoin(next_link, _parsed_next_link.path), params=_next_request_params) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore request.method = "GET" return request @@ -4900,10 +6301,8 @@ async def extract_data(pipeline_response): async def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) response = pipeline_response.http_response @@ -4913,119 +6312,123 @@ async def get_next(next_link=None): return pipeline_response + return AsyncItemPaged(get_next, extract_data) - return AsyncItemPaged( - get_next, extract_data - ) - list_at_management_group_scope.metadata = {'url': "/providers/Microsoft.Management/managementGroups/{groupId}/providers/Microsoft.Resources/deployments/{deploymentName}/operations"} # type: ignore + list_at_management_group_scope.metadata = {"url": "/providers/Microsoft.Management/managementGroups/{groupId}/providers/Microsoft.Resources/deployments/{deploymentName}/operations"} # type: ignore @distributed_trace_async async def get_at_subscription_scope( - self, - deployment_name: str, - operation_id: str, - **kwargs: Any - ) -> "_models.DeploymentOperation": + self, deployment_name: str, operation_id: str, **kwargs: Any + ) -> _models.DeploymentOperation: """Gets a deployments operation. - :param deployment_name: The name of the deployment. + :param deployment_name: The name of the deployment. Required. :type deployment_name: str - :param operation_id: The ID of the operation to get. + :param operation_id: The ID of the operation to get. Required. :type operation_id: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: DeploymentOperation, or the result of cls(response) + :return: DeploymentOperation or the result of cls(response) :rtype: ~azure.mgmt.resource.resources.v2019_05_10.models.DeploymentOperation - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.DeploymentOperation"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) - api_version = kwargs.pop('api_version', "2019-05-10") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2019-05-10")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[_models.DeploymentOperation] - request = build_deployment_operations_get_at_subscription_scope_request( deployment_name=deployment_name, operation_id=operation_id, subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.get_at_subscription_scope.metadata['url'], + template_url=self.get_at_subscription_scope.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) - deserialized = self._deserialize('DeploymentOperation', pipeline_response) + deserialized = self._deserialize("DeploymentOperation", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - get_at_subscription_scope.metadata = {'url': "/subscriptions/{subscriptionId}/providers/Microsoft.Resources/deployments/{deploymentName}/operations/{operationId}"} # type: ignore - + get_at_subscription_scope.metadata = {"url": "/subscriptions/{subscriptionId}/providers/Microsoft.Resources/deployments/{deploymentName}/operations/{operationId}"} # type: ignore @distributed_trace def list_at_subscription_scope( - self, - deployment_name: str, - top: Optional[int] = None, - **kwargs: Any - ) -> AsyncIterable["_models.DeploymentOperationsListResult"]: + self, deployment_name: str, top: Optional[int] = None, **kwargs: Any + ) -> AsyncIterable["_models.DeploymentOperation"]: """Gets all deployments operations for a deployment. - :param deployment_name: The name of the deployment. + :param deployment_name: The name of the deployment. Required. :type deployment_name: str :param top: The number of results to return. Default value is None. :type top: int :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either DeploymentOperationsListResult or the result of - cls(response) + :return: An iterator like instance of either DeploymentOperation or the result of cls(response) :rtype: - ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.resource.resources.v2019_05_10.models.DeploymentOperationsListResult] - :raises: ~azure.core.exceptions.HttpResponseError + ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.resource.resources.v2019_05_10.models.DeploymentOperation] + :raises ~azure.core.exceptions.HttpResponseError: """ - api_version = kwargs.pop('api_version', "2019-05-10") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2019-05-10")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[_models.DeploymentOperationsListResult] - cls = kwargs.pop('cls', None) # type: ClsType["_models.DeploymentOperationsListResult"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) + def prepare_request(next_link=None): if not next_link: - + request = build_deployment_operations_list_at_subscription_scope_request( deployment_name=deployment_name, subscription_id=self._config.subscription_id, - api_version=api_version, top=top, - template_url=self.list_at_subscription_scope.metadata['url'], + api_version=api_version, + template_url=self.list_at_subscription_scope.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore else: - - request = build_deployment_operations_list_at_subscription_scope_request( - deployment_name=deployment_name, - subscription_id=self._config.subscription_id, - template_url=next_link, - ) + # make call to next link with the client's api-version + _parsed_next_link = urlparse(next_link) + _next_request_params = case_insensitive_dict(parse_qs(_parsed_next_link.query)) + _next_request_params["api-version"] = self._config.api_version + request = HttpRequest("GET", urljoin(next_link, _parsed_next_link.path), params=_next_request_params) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore request.method = "GET" return request @@ -5039,10 +6442,8 @@ async def extract_data(pipeline_response): async def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) response = pipeline_response.http_response @@ -5052,128 +6453,131 @@ async def get_next(next_link=None): return pipeline_response + return AsyncItemPaged(get_next, extract_data) - return AsyncItemPaged( - get_next, extract_data - ) - list_at_subscription_scope.metadata = {'url': "/subscriptions/{subscriptionId}/providers/Microsoft.Resources/deployments/{deploymentName}/operations"} # type: ignore + list_at_subscription_scope.metadata = {"url": "/subscriptions/{subscriptionId}/providers/Microsoft.Resources/deployments/{deploymentName}/operations"} # type: ignore @distributed_trace_async async def get( - self, - resource_group_name: str, - deployment_name: str, - operation_id: str, - **kwargs: Any - ) -> "_models.DeploymentOperation": + self, resource_group_name: str, deployment_name: str, operation_id: str, **kwargs: Any + ) -> _models.DeploymentOperation: """Gets a deployments operation. :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. :type resource_group_name: str - :param deployment_name: The name of the deployment. + :param deployment_name: The name of the deployment. Required. :type deployment_name: str - :param operation_id: The ID of the operation to get. + :param operation_id: The ID of the operation to get. Required. :type operation_id: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: DeploymentOperation, or the result of cls(response) + :return: DeploymentOperation or the result of cls(response) :rtype: ~azure.mgmt.resource.resources.v2019_05_10.models.DeploymentOperation - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.DeploymentOperation"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + 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', "2019-05-10") # type: str + api_version = kwargs.pop("api_version", _params.pop("api-version", "2019-05-10")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[_models.DeploymentOperation] - request = build_deployment_operations_get_request( resource_group_name=resource_group_name, deployment_name=deployment_name, operation_id=operation_id, subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.get.metadata['url'], + template_url=self.get.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) - deserialized = self._deserialize('DeploymentOperation', pipeline_response) + deserialized = self._deserialize("DeploymentOperation", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - get.metadata = {'url': "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/deployments/{deploymentName}/operations/{operationId}"} # type: ignore - + get.metadata = {"url": "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/deployments/{deploymentName}/operations/{operationId}"} # type: ignore @distributed_trace def list( - self, - resource_group_name: str, - deployment_name: str, - top: Optional[int] = None, - **kwargs: Any - ) -> AsyncIterable["_models.DeploymentOperationsListResult"]: + self, resource_group_name: str, deployment_name: str, top: Optional[int] = None, **kwargs: Any + ) -> AsyncIterable["_models.DeploymentOperation"]: """Gets all deployments operations for a deployment. :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. :type resource_group_name: str - :param deployment_name: The name of the deployment. + :param deployment_name: The name of the deployment. Required. :type deployment_name: str :param top: The number of results to return. Default value is None. :type top: int :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either DeploymentOperationsListResult or the result of - cls(response) + :return: An iterator like instance of either DeploymentOperation or the result of cls(response) :rtype: - ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.resource.resources.v2019_05_10.models.DeploymentOperationsListResult] - :raises: ~azure.core.exceptions.HttpResponseError + ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.resource.resources.v2019_05_10.models.DeploymentOperation] + :raises ~azure.core.exceptions.HttpResponseError: """ - api_version = kwargs.pop('api_version', "2019-05-10") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2019-05-10")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[_models.DeploymentOperationsListResult] - cls = kwargs.pop('cls', None) # type: ClsType["_models.DeploymentOperationsListResult"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) + def prepare_request(next_link=None): if not next_link: - + request = build_deployment_operations_list_request( resource_group_name=resource_group_name, deployment_name=deployment_name, subscription_id=self._config.subscription_id, - api_version=api_version, top=top, - template_url=self.list.metadata['url'], + 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.url = self._client.format_url(request.url) # type: ignore else: - - request = build_deployment_operations_list_request( - resource_group_name=resource_group_name, - deployment_name=deployment_name, - subscription_id=self._config.subscription_id, - template_url=next_link, - ) + # make call to next link with the client's api-version + _parsed_next_link = urlparse(next_link) + _next_request_params = case_insensitive_dict(parse_qs(_parsed_next_link.query)) + _next_request_params["api-version"] = self._config.api_version + request = HttpRequest("GET", urljoin(next_link, _parsed_next_link.path), params=_next_request_params) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore request.method = "GET" return request @@ -5187,10 +6591,8 @@ async def extract_data(pipeline_response): async def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) response = pipeline_response.http_response @@ -5200,8 +6602,6 @@ async def get_next(next_link=None): return pipeline_response + return AsyncItemPaged(get_next, extract_data) - return AsyncItemPaged( - get_next, extract_data - ) - list.metadata = {'url': "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/deployments/{deploymentName}/operations"} # type: ignore + list.metadata = {"url": "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/deployments/{deploymentName}/operations"} # type: ignore diff --git a/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/resources/v2019_05_10/aio/operations/_patch.py b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/resources/v2019_05_10/aio/operations/_patch.py new file mode 100644 index 0000000000000..f7dd32510333d --- /dev/null +++ b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/resources/v2019_05_10/aio/operations/_patch.py @@ -0,0 +1,20 @@ +# ------------------------------------ +# Copyright (c) Microsoft Corporation. +# Licensed under the MIT License. +# ------------------------------------ +"""Customize generated code here. + +Follow our quickstart for examples: https://aka.ms/azsdk/python/dpcodegen/python/customize +""" +from typing import List + +__all__: List[str] = [] # Add all objects you want publicly available to users at this package level + + +def patch_sdk(): + """Do not remove from this file. + + `patch_sdk` is a last resort escape hatch that allows you to do customizations + you can't accomplish using the techniques described in + https://aka.ms/azsdk/python/dpcodegen/python/customize + """ diff --git a/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/resources/v2019_05_10/models/__init__.py b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/resources/v2019_05_10/models/__init__.py index ce87b190b8862..39249f144291f 100644 --- a/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/resources/v2019_05_10/models/__init__.py +++ b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/resources/v2019_05_10/models/__init__.py @@ -63,71 +63,73 @@ from ._models_py3 import TemplateLink from ._models_py3 import ZoneMapping - -from ._resource_management_client_enums import ( - DeploymentMode, - OnErrorDeploymentType, - ResourceIdentityType, -) +from ._resource_management_client_enums import DeploymentMode +from ._resource_management_client_enums import OnErrorDeploymentType +from ._resource_management_client_enums import ResourceIdentityType +from ._patch import __all__ as _patch_all +from ._patch import * # type: ignore # pylint: disable=unused-wildcard-import +from ._patch import patch_sdk as _patch_sdk __all__ = [ - 'AliasPathType', - 'AliasType', - 'BasicDependency', - 'ComponentsSgqdofSchemasIdentityPropertiesUserassignedidentitiesAdditionalproperties', - 'DebugSetting', - 'Dependency', - 'Deployment', - 'DeploymentExportResult', - 'DeploymentExtended', - 'DeploymentExtendedFilter', - 'DeploymentListResult', - 'DeploymentOperation', - 'DeploymentOperationProperties', - 'DeploymentOperationsListResult', - 'DeploymentProperties', - 'DeploymentPropertiesExtended', - 'DeploymentValidateResult', - 'ErrorAdditionalInfo', - 'ErrorResponse', - 'ExportTemplateRequest', - 'GenericResource', - 'GenericResourceExpanded', - 'GenericResourceFilter', - 'HttpMessage', - 'Identity', - 'OnErrorDeployment', - 'OnErrorDeploymentExtended', - 'Operation', - 'OperationDisplay', - 'OperationListResult', - 'ParametersLink', - 'Plan', - 'Provider', - 'ProviderListResult', - 'ProviderResourceType', - 'Resource', - 'ResourceGroup', - 'ResourceGroupExportResult', - 'ResourceGroupFilter', - 'ResourceGroupListResult', - 'ResourceGroupPatchable', - 'ResourceGroupProperties', - 'ResourceListResult', - 'ResourceManagementErrorWithDetails', - 'ResourceProviderOperationDisplayProperties', - 'ResourcesMoveInfo', - 'Sku', - 'SubResource', - 'TagCount', - 'TagDetails', - 'TagValue', - 'TagsListResult', - 'TargetResource', - 'TemplateHashResult', - 'TemplateLink', - 'ZoneMapping', - 'DeploymentMode', - 'OnErrorDeploymentType', - 'ResourceIdentityType', + "AliasPathType", + "AliasType", + "BasicDependency", + "ComponentsSgqdofSchemasIdentityPropertiesUserassignedidentitiesAdditionalproperties", + "DebugSetting", + "Dependency", + "Deployment", + "DeploymentExportResult", + "DeploymentExtended", + "DeploymentExtendedFilter", + "DeploymentListResult", + "DeploymentOperation", + "DeploymentOperationProperties", + "DeploymentOperationsListResult", + "DeploymentProperties", + "DeploymentPropertiesExtended", + "DeploymentValidateResult", + "ErrorAdditionalInfo", + "ErrorResponse", + "ExportTemplateRequest", + "GenericResource", + "GenericResourceExpanded", + "GenericResourceFilter", + "HttpMessage", + "Identity", + "OnErrorDeployment", + "OnErrorDeploymentExtended", + "Operation", + "OperationDisplay", + "OperationListResult", + "ParametersLink", + "Plan", + "Provider", + "ProviderListResult", + "ProviderResourceType", + "Resource", + "ResourceGroup", + "ResourceGroupExportResult", + "ResourceGroupFilter", + "ResourceGroupListResult", + "ResourceGroupPatchable", + "ResourceGroupProperties", + "ResourceListResult", + "ResourceManagementErrorWithDetails", + "ResourceProviderOperationDisplayProperties", + "ResourcesMoveInfo", + "Sku", + "SubResource", + "TagCount", + "TagDetails", + "TagValue", + "TagsListResult", + "TargetResource", + "TemplateHashResult", + "TemplateLink", + "ZoneMapping", + "DeploymentMode", + "OnErrorDeploymentType", + "ResourceIdentityType", ] +__all__.extend([p for p in _patch_all if p not in __all__]) +_patch_sdk() diff --git a/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/resources/v2019_05_10/models/_models_py3.py b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/resources/v2019_05_10/models/_models_py3.py index c3a28529444b7..7cea3b96dbbec 100644 --- a/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/resources/v2019_05_10/models/_models_py3.py +++ b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/resources/v2019_05_10/models/_models_py3.py @@ -1,4 +1,5 @@ # coding=utf-8 +# pylint: disable=too-many-lines # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. # Licensed under the MIT License. See License.txt in the project root for license information. @@ -6,14 +7,22 @@ # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -from typing import Any, Dict, List, Optional, Union +import sys +from typing import Any, Dict, List, Optional, TYPE_CHECKING, Union -import msrest.serialization +from ... import _serialization -from ._resource_management_client_enums import * +if TYPE_CHECKING: + # pylint: disable=unused-import,ungrouped-imports + from .. import models as _models +if sys.version_info >= (3, 9): + from collections.abc import MutableMapping +else: + from typing import MutableMapping # type: ignore # pylint: disable=ungrouped-imports +JSON = MutableMapping[str, Any] # pylint: disable=unsubscriptable-object -class AliasPathType(msrest.serialization.Model): +class AliasPathType(_serialization.Model): """The type of the paths for alias. :ivar path: The path of an alias. @@ -23,29 +32,23 @@ class AliasPathType(msrest.serialization.Model): """ _attribute_map = { - 'path': {'key': 'path', 'type': 'str'}, - 'api_versions': {'key': 'apiVersions', 'type': '[str]'}, + "path": {"key": "path", "type": "str"}, + "api_versions": {"key": "apiVersions", "type": "[str]"}, } - def __init__( - self, - *, - path: Optional[str] = None, - api_versions: Optional[List[str]] = None, - **kwargs - ): + def __init__(self, *, path: Optional[str] = None, api_versions: Optional[List[str]] = None, **kwargs): """ :keyword path: The path of an alias. :paramtype path: str :keyword api_versions: The API versions. :paramtype api_versions: list[str] """ - super(AliasPathType, self).__init__(**kwargs) + super().__init__(**kwargs) self.path = path self.api_versions = api_versions -class AliasType(msrest.serialization.Model): +class AliasType(_serialization.Model): """The alias type. :ivar name: The alias name. @@ -55,29 +58,23 @@ class AliasType(msrest.serialization.Model): """ _attribute_map = { - 'name': {'key': 'name', 'type': 'str'}, - 'paths': {'key': 'paths', 'type': '[AliasPathType]'}, + "name": {"key": "name", "type": "str"}, + "paths": {"key": "paths", "type": "[AliasPathType]"}, } - def __init__( - self, - *, - name: Optional[str] = None, - paths: Optional[List["AliasPathType"]] = None, - **kwargs - ): + def __init__(self, *, name: Optional[str] = None, paths: Optional[List["_models.AliasPathType"]] = None, **kwargs): """ :keyword name: The alias name. :paramtype name: str :keyword paths: The paths for an alias. :paramtype paths: list[~azure.mgmt.resource.resources.v2019_05_10.models.AliasPathType] """ - super(AliasType, self).__init__(**kwargs) + super().__init__(**kwargs) self.name = name self.paths = paths -class BasicDependency(msrest.serialization.Model): +class BasicDependency(_serialization.Model): """Deployment dependency information. :ivar id: The ID of the dependency. @@ -89,15 +86,15 @@ class BasicDependency(msrest.serialization.Model): """ _attribute_map = { - 'id': {'key': 'id', 'type': 'str'}, - 'resource_type': {'key': 'resourceType', 'type': 'str'}, - 'resource_name': {'key': 'resourceName', 'type': 'str'}, + "id": {"key": "id", "type": "str"}, + "resource_type": {"key": "resourceType", "type": "str"}, + "resource_name": {"key": "resourceName", "type": "str"}, } def __init__( self, *, - id: Optional[str] = None, + id: Optional[str] = None, # pylint: disable=redefined-builtin resource_type: Optional[str] = None, resource_name: Optional[str] = None, **kwargs @@ -110,13 +107,13 @@ def __init__( :keyword resource_name: The dependency resource name. :paramtype resource_name: str """ - super(BasicDependency, self).__init__(**kwargs) + super().__init__(**kwargs) self.id = id self.resource_type = resource_type self.resource_name = resource_name -class ComponentsSgqdofSchemasIdentityPropertiesUserassignedidentitiesAdditionalproperties(msrest.serialization.Model): +class ComponentsSgqdofSchemasIdentityPropertiesUserassignedidentitiesAdditionalproperties(_serialization.Model): """ComponentsSgqdofSchemasIdentityPropertiesUserassignedidentitiesAdditionalproperties. Variables are only populated by the server, and will be ignored when sending a request. @@ -128,27 +125,23 @@ class ComponentsSgqdofSchemasIdentityPropertiesUserassignedidentitiesAdditionalp """ _validation = { - 'principal_id': {'readonly': True}, - 'client_id': {'readonly': True}, + "principal_id": {"readonly": True}, + "client_id": {"readonly": True}, } _attribute_map = { - 'principal_id': {'key': 'principalId', 'type': 'str'}, - 'client_id': {'key': 'clientId', 'type': 'str'}, + "principal_id": {"key": "principalId", "type": "str"}, + "client_id": {"key": "clientId", "type": "str"}, } - def __init__( - self, - **kwargs - ): - """ - """ - super(ComponentsSgqdofSchemasIdentityPropertiesUserassignedidentitiesAdditionalproperties, self).__init__(**kwargs) + def __init__(self, **kwargs): + """ """ + super().__init__(**kwargs) self.principal_id = None self.client_id = None -class DebugSetting(msrest.serialization.Model): +class DebugSetting(_serialization.Model): """The debug setting. :ivar detail_level: Specifies the type of information to log for debugging. The permitted @@ -161,15 +154,10 @@ class DebugSetting(msrest.serialization.Model): """ _attribute_map = { - 'detail_level': {'key': 'detailLevel', 'type': 'str'}, + "detail_level": {"key": "detailLevel", "type": "str"}, } - def __init__( - self, - *, - detail_level: Optional[str] = None, - **kwargs - ): + def __init__(self, *, detail_level: Optional[str] = None, **kwargs): """ :keyword detail_level: Specifies the type of information to log for debugging. The permitted values are none, requestContent, responseContent, or both requestContent and responseContent @@ -179,11 +167,11 @@ def __init__( deployment operations. :paramtype detail_level: str """ - super(DebugSetting, self).__init__(**kwargs) + super().__init__(**kwargs) self.detail_level = detail_level -class Dependency(msrest.serialization.Model): +class Dependency(_serialization.Model): """Deployment dependency information. :ivar depends_on: The list of dependencies. @@ -197,17 +185,17 @@ class Dependency(msrest.serialization.Model): """ _attribute_map = { - 'depends_on': {'key': 'dependsOn', 'type': '[BasicDependency]'}, - 'id': {'key': 'id', 'type': 'str'}, - 'resource_type': {'key': 'resourceType', 'type': 'str'}, - 'resource_name': {'key': 'resourceName', 'type': 'str'}, + "depends_on": {"key": "dependsOn", "type": "[BasicDependency]"}, + "id": {"key": "id", "type": "str"}, + "resource_type": {"key": "resourceType", "type": "str"}, + "resource_name": {"key": "resourceName", "type": "str"}, } def __init__( self, *, - depends_on: Optional[List["BasicDependency"]] = None, - id: Optional[str] = None, + depends_on: Optional[List["_models.BasicDependency"]] = None, + id: Optional[str] = None, # pylint: disable=redefined-builtin resource_type: Optional[str] = None, resource_name: Optional[str] = None, **kwargs @@ -222,77 +210,66 @@ def __init__( :keyword resource_name: The dependency resource name. :paramtype resource_name: str """ - super(Dependency, self).__init__(**kwargs) + super().__init__(**kwargs) self.depends_on = depends_on self.id = id self.resource_type = resource_type self.resource_name = resource_name -class Deployment(msrest.serialization.Model): +class Deployment(_serialization.Model): """Deployment operation parameters. All required parameters must be populated in order to send to Azure. :ivar location: The location to store the deployment data. :vartype location: str - :ivar properties: Required. The deployment properties. + :ivar properties: The deployment properties. Required. :vartype properties: ~azure.mgmt.resource.resources.v2019_05_10.models.DeploymentProperties """ _validation = { - 'properties': {'required': True}, + "properties": {"required": True}, } _attribute_map = { - 'location': {'key': 'location', 'type': 'str'}, - 'properties': {'key': 'properties', 'type': 'DeploymentProperties'}, + "location": {"key": "location", "type": "str"}, + "properties": {"key": "properties", "type": "DeploymentProperties"}, } - def __init__( - self, - *, - properties: "DeploymentProperties", - location: Optional[str] = None, - **kwargs - ): + def __init__(self, *, properties: "_models.DeploymentProperties", location: Optional[str] = None, **kwargs): """ :keyword location: The location to store the deployment data. :paramtype location: str - :keyword properties: Required. The deployment properties. + :keyword properties: The deployment properties. Required. :paramtype properties: ~azure.mgmt.resource.resources.v2019_05_10.models.DeploymentProperties """ - super(Deployment, self).__init__(**kwargs) + super().__init__(**kwargs) self.location = location self.properties = properties -class DeploymentExportResult(msrest.serialization.Model): +class DeploymentExportResult(_serialization.Model): """The deployment export result. :ivar template: The template content. - :vartype template: any + :vartype template: JSON """ _attribute_map = { - 'template': {'key': 'template', 'type': 'object'}, + "template": {"key": "template", "type": "object"}, } - def __init__( - self, - *, - template: Optional[Any] = None, - **kwargs - ): + def __init__(self, *, template: Optional[JSON] = None, **kwargs): """ :keyword template: The template content. - :paramtype template: any + :paramtype template: JSON """ - super(DeploymentExportResult, self).__init__(**kwargs) + super().__init__(**kwargs) self.template = template -class DeploymentExtended(msrest.serialization.Model): +class DeploymentExtended(_serialization.Model): """Deployment information. Variables are only populated by the server, and will be ignored when sending a request. @@ -311,24 +288,24 @@ class DeploymentExtended(msrest.serialization.Model): """ _validation = { - 'id': {'readonly': True}, - 'name': {'readonly': True}, - 'type': {'readonly': True}, + "id": {"readonly": True}, + "name": {"readonly": True}, + "type": {"readonly": True}, } _attribute_map = { - 'id': {'key': 'id', 'type': 'str'}, - 'name': {'key': 'name', 'type': 'str'}, - 'type': {'key': 'type', 'type': 'str'}, - 'location': {'key': 'location', 'type': 'str'}, - 'properties': {'key': 'properties', 'type': 'DeploymentPropertiesExtended'}, + "id": {"key": "id", "type": "str"}, + "name": {"key": "name", "type": "str"}, + "type": {"key": "type", "type": "str"}, + "location": {"key": "location", "type": "str"}, + "properties": {"key": "properties", "type": "DeploymentPropertiesExtended"}, } def __init__( self, *, location: Optional[str] = None, - properties: Optional["DeploymentPropertiesExtended"] = None, + properties: Optional["_models.DeploymentPropertiesExtended"] = None, **kwargs ): """ @@ -338,7 +315,7 @@ def __init__( :paramtype properties: ~azure.mgmt.resource.resources.v2019_05_10.models.DeploymentPropertiesExtended """ - super(DeploymentExtended, self).__init__(**kwargs) + super().__init__(**kwargs) self.id = None self.name = None self.type = None @@ -346,7 +323,7 @@ def __init__( self.properties = properties -class DeploymentExtendedFilter(msrest.serialization.Model): +class DeploymentExtendedFilter(_serialization.Model): """Deployment filter. :ivar provisioning_state: The provisioning state. @@ -354,24 +331,19 @@ class DeploymentExtendedFilter(msrest.serialization.Model): """ _attribute_map = { - 'provisioning_state': {'key': 'provisioningState', 'type': 'str'}, + "provisioning_state": {"key": "provisioningState", "type": "str"}, } - def __init__( - self, - *, - provisioning_state: Optional[str] = None, - **kwargs - ): + def __init__(self, *, provisioning_state: Optional[str] = None, **kwargs): """ :keyword provisioning_state: The provisioning state. :paramtype provisioning_state: str """ - super(DeploymentExtendedFilter, self).__init__(**kwargs) + super().__init__(**kwargs) self.provisioning_state = provisioning_state -class DeploymentListResult(msrest.serialization.Model): +class DeploymentListResult(_serialization.Model): """List of deployments. Variables are only populated by the server, and will be ignored when sending a request. @@ -383,30 +355,25 @@ class DeploymentListResult(msrest.serialization.Model): """ _validation = { - 'next_link': {'readonly': True}, + "next_link": {"readonly": True}, } _attribute_map = { - 'value': {'key': 'value', 'type': '[DeploymentExtended]'}, - 'next_link': {'key': 'nextLink', 'type': 'str'}, + "value": {"key": "value", "type": "[DeploymentExtended]"}, + "next_link": {"key": "nextLink", "type": "str"}, } - def __init__( - self, - *, - value: Optional[List["DeploymentExtended"]] = None, - **kwargs - ): + def __init__(self, *, value: Optional[List["_models.DeploymentExtended"]] = None, **kwargs): """ :keyword value: An array of deployments. :paramtype value: list[~azure.mgmt.resource.resources.v2019_05_10.models.DeploymentExtended] """ - super(DeploymentListResult, self).__init__(**kwargs) + super().__init__(**kwargs) self.value = value self.next_link = None -class DeploymentOperation(msrest.serialization.Model): +class DeploymentOperation(_serialization.Model): """Deployment operation information. Variables are only populated by the server, and will be ignored when sending a request. @@ -421,34 +388,29 @@ class DeploymentOperation(msrest.serialization.Model): """ _validation = { - 'id': {'readonly': True}, - 'operation_id': {'readonly': True}, + "id": {"readonly": True}, + "operation_id": {"readonly": True}, } _attribute_map = { - 'id': {'key': 'id', 'type': 'str'}, - 'operation_id': {'key': 'operationId', 'type': 'str'}, - 'properties': {'key': 'properties', 'type': 'DeploymentOperationProperties'}, + "id": {"key": "id", "type": "str"}, + "operation_id": {"key": "operationId", "type": "str"}, + "properties": {"key": "properties", "type": "DeploymentOperationProperties"}, } - def __init__( - self, - *, - properties: Optional["DeploymentOperationProperties"] = None, - **kwargs - ): + def __init__(self, *, properties: Optional["_models.DeploymentOperationProperties"] = None, **kwargs): """ :keyword properties: Deployment properties. :paramtype properties: ~azure.mgmt.resource.resources.v2019_05_10.models.DeploymentOperationProperties """ - super(DeploymentOperation, self).__init__(**kwargs) + super().__init__(**kwargs) self.id = None self.operation_id = None self.properties = properties -class DeploymentOperationProperties(msrest.serialization.Model): +class DeploymentOperationProperties(_serialization.Model): """Deployment operation properties. Variables are only populated by the server, and will be ignored when sending a request. @@ -464,7 +426,7 @@ class DeploymentOperationProperties(msrest.serialization.Model): :ivar status_code: Operation status code. :vartype status_code: str :ivar status_message: Operation status message. - :vartype status_message: any + :vartype status_message: JSON :ivar target_resource: The target resource. :vartype target_resource: ~azure.mgmt.resource.resources.v2019_05_10.models.TargetResource :ivar request: The HTTP request message. @@ -474,36 +436,32 @@ class DeploymentOperationProperties(msrest.serialization.Model): """ _validation = { - 'provisioning_state': {'readonly': True}, - 'timestamp': {'readonly': True}, - 'duration': {'readonly': True}, - 'service_request_id': {'readonly': True}, - 'status_code': {'readonly': True}, - 'status_message': {'readonly': True}, - 'target_resource': {'readonly': True}, - 'request': {'readonly': True}, - 'response': {'readonly': True}, + "provisioning_state": {"readonly": True}, + "timestamp": {"readonly": True}, + "duration": {"readonly": True}, + "service_request_id": {"readonly": True}, + "status_code": {"readonly": True}, + "status_message": {"readonly": True}, + "target_resource": {"readonly": True}, + "request": {"readonly": True}, + "response": {"readonly": True}, } _attribute_map = { - 'provisioning_state': {'key': 'provisioningState', 'type': 'str'}, - 'timestamp': {'key': 'timestamp', 'type': 'iso-8601'}, - 'duration': {'key': 'duration', 'type': 'str'}, - 'service_request_id': {'key': 'serviceRequestId', 'type': 'str'}, - 'status_code': {'key': 'statusCode', 'type': 'str'}, - 'status_message': {'key': 'statusMessage', 'type': 'object'}, - 'target_resource': {'key': 'targetResource', 'type': 'TargetResource'}, - 'request': {'key': 'request', 'type': 'HttpMessage'}, - 'response': {'key': 'response', 'type': 'HttpMessage'}, - } - - def __init__( - self, - **kwargs - ): - """ - """ - super(DeploymentOperationProperties, self).__init__(**kwargs) + "provisioning_state": {"key": "provisioningState", "type": "str"}, + "timestamp": {"key": "timestamp", "type": "iso-8601"}, + "duration": {"key": "duration", "type": "str"}, + "service_request_id": {"key": "serviceRequestId", "type": "str"}, + "status_code": {"key": "statusCode", "type": "str"}, + "status_message": {"key": "statusMessage", "type": "object"}, + "target_resource": {"key": "targetResource", "type": "TargetResource"}, + "request": {"key": "request", "type": "HttpMessage"}, + "response": {"key": "response", "type": "HttpMessage"}, + } + + def __init__(self, **kwargs): + """ """ + super().__init__(**kwargs) self.provisioning_state = None self.timestamp = None self.duration = None @@ -515,7 +473,7 @@ def __init__( self.response = None -class DeploymentOperationsListResult(msrest.serialization.Model): +class DeploymentOperationsListResult(_serialization.Model): """List of deployment operations. Variables are only populated by the server, and will be ignored when sending a request. @@ -527,30 +485,25 @@ class DeploymentOperationsListResult(msrest.serialization.Model): """ _validation = { - 'next_link': {'readonly': True}, + "next_link": {"readonly": True}, } _attribute_map = { - 'value': {'key': 'value', 'type': '[DeploymentOperation]'}, - 'next_link': {'key': 'nextLink', 'type': 'str'}, + "value": {"key": "value", "type": "[DeploymentOperation]"}, + "next_link": {"key": "nextLink", "type": "str"}, } - def __init__( - self, - *, - value: Optional[List["DeploymentOperation"]] = None, - **kwargs - ): + def __init__(self, *, value: Optional[List["_models.DeploymentOperation"]] = None, **kwargs): """ :keyword value: An array of deployment operations. :paramtype value: list[~azure.mgmt.resource.resources.v2019_05_10.models.DeploymentOperation] """ - super(DeploymentOperationsListResult, self).__init__(**kwargs) + super().__init__(**kwargs) self.value = value self.next_link = None -class DeploymentProperties(msrest.serialization.Model): +class DeploymentProperties(_serialization.Model): """Deployment properties. All required parameters must be populated in order to send to Azure. @@ -559,7 +512,7 @@ class DeploymentProperties(msrest.serialization.Model): syntax directly in the request rather than link to an existing template. It can be a JObject or well-formed JSON string. Use either the templateLink property or the template property, but not both. - :vartype template: any + :vartype template: JSON :ivar template_link: The URI of the template. Use either the templateLink property or the template property, but not both. :vartype template_link: ~azure.mgmt.resource.resources.v2019_05_10.models.TemplateLink @@ -567,17 +520,17 @@ class DeploymentProperties(msrest.serialization.Model): You use this element when you want to provide the parameter values directly in the request rather than link to an existing parameter file. Use either the parametersLink property or the parameters property, but not both. It can be a JObject or a well formed JSON string. - :vartype parameters: any + :vartype parameters: JSON :ivar parameters_link: The URI of parameters file. You use this element to link to an existing parameters file. Use either the parametersLink property or the parameters property, but not both. :vartype parameters_link: ~azure.mgmt.resource.resources.v2019_05_10.models.ParametersLink - :ivar mode: Required. The mode that is used to deploy resources. This value can be either - Incremental or Complete. In Incremental mode, resources are deployed without deleting existing - resources that are not included in the template. In Complete mode, resources are deployed and - existing resources in the resource group that are not included in the template are deleted. Be - careful when using Complete mode as you may unintentionally delete resources. Possible values - include: "Incremental", "Complete". + :ivar mode: The mode that is used to deploy resources. This value can be either Incremental or + Complete. In Incremental mode, resources are deployed without deleting existing resources that + are not included in the template. In Complete mode, resources are deployed and existing + resources in the resource group that are not included in the template are deleted. Be careful + when using Complete mode as you may unintentionally delete resources. Required. Known values + are: "Incremental" and "Complete". :vartype mode: str or ~azure.mgmt.resource.resources.v2019_05_10.models.DeploymentMode :ivar debug_setting: The debug setting of the deployment. :vartype debug_setting: ~azure.mgmt.resource.resources.v2019_05_10.models.DebugSetting @@ -587,29 +540,29 @@ class DeploymentProperties(msrest.serialization.Model): """ _validation = { - 'mode': {'required': True}, + "mode": {"required": True}, } _attribute_map = { - 'template': {'key': 'template', 'type': 'object'}, - 'template_link': {'key': 'templateLink', 'type': 'TemplateLink'}, - 'parameters': {'key': 'parameters', 'type': 'object'}, - 'parameters_link': {'key': 'parametersLink', 'type': 'ParametersLink'}, - 'mode': {'key': 'mode', 'type': 'str'}, - 'debug_setting': {'key': 'debugSetting', 'type': 'DebugSetting'}, - 'on_error_deployment': {'key': 'onErrorDeployment', 'type': 'OnErrorDeployment'}, + "template": {"key": "template", "type": "object"}, + "template_link": {"key": "templateLink", "type": "TemplateLink"}, + "parameters": {"key": "parameters", "type": "object"}, + "parameters_link": {"key": "parametersLink", "type": "ParametersLink"}, + "mode": {"key": "mode", "type": "str"}, + "debug_setting": {"key": "debugSetting", "type": "DebugSetting"}, + "on_error_deployment": {"key": "onErrorDeployment", "type": "OnErrorDeployment"}, } def __init__( self, *, - mode: Union[str, "DeploymentMode"], - template: Optional[Any] = None, - template_link: Optional["TemplateLink"] = None, - parameters: Optional[Any] = None, - parameters_link: Optional["ParametersLink"] = None, - debug_setting: Optional["DebugSetting"] = None, - on_error_deployment: Optional["OnErrorDeployment"] = None, + mode: Union[str, "_models.DeploymentMode"], + template: Optional[JSON] = None, + template_link: Optional["_models.TemplateLink"] = None, + parameters: Optional[JSON] = None, + parameters_link: Optional["_models.ParametersLink"] = None, + debug_setting: Optional["_models.DebugSetting"] = None, + on_error_deployment: Optional["_models.OnErrorDeployment"] = None, **kwargs ): """ @@ -617,7 +570,7 @@ def __init__( template syntax directly in the request rather than link to an existing template. It can be a JObject or well-formed JSON string. Use either the templateLink property or the template property, but not both. - :paramtype template: any + :paramtype template: JSON :keyword template_link: The URI of the template. Use either the templateLink property or the template property, but not both. :paramtype template_link: ~azure.mgmt.resource.resources.v2019_05_10.models.TemplateLink @@ -625,17 +578,17 @@ def __init__( template. You use this element when you want to provide the parameter values directly in the request rather than link to an existing parameter file. Use either the parametersLink property or the parameters property, but not both. It can be a JObject or a well formed JSON string. - :paramtype parameters: any + :paramtype parameters: JSON :keyword parameters_link: The URI of parameters file. You use this element to link to an existing parameters file. Use either the parametersLink property or the parameters property, but not both. :paramtype parameters_link: ~azure.mgmt.resource.resources.v2019_05_10.models.ParametersLink - :keyword mode: Required. The mode that is used to deploy resources. This value can be either - Incremental or Complete. In Incremental mode, resources are deployed without deleting existing - resources that are not included in the template. In Complete mode, resources are deployed and - existing resources in the resource group that are not included in the template are deleted. Be - careful when using Complete mode as you may unintentionally delete resources. Possible values - include: "Incremental", "Complete". + :keyword mode: The mode that is used to deploy resources. This value can be either Incremental + or Complete. In Incremental mode, resources are deployed without deleting existing resources + that are not included in the template. In Complete mode, resources are deployed and existing + resources in the resource group that are not included in the template are deleted. Be careful + when using Complete mode as you may unintentionally delete resources. Required. Known values + are: "Incremental" and "Complete". :paramtype mode: str or ~azure.mgmt.resource.resources.v2019_05_10.models.DeploymentMode :keyword debug_setting: The debug setting of the deployment. :paramtype debug_setting: ~azure.mgmt.resource.resources.v2019_05_10.models.DebugSetting @@ -643,7 +596,7 @@ def __init__( :paramtype on_error_deployment: ~azure.mgmt.resource.resources.v2019_05_10.models.OnErrorDeployment """ - super(DeploymentProperties, self).__init__(**kwargs) + super().__init__(**kwargs) self.template = template self.template_link = template_link self.parameters = parameters @@ -653,7 +606,7 @@ def __init__( self.on_error_deployment = on_error_deployment -class DeploymentPropertiesExtended(msrest.serialization.Model): +class DeploymentPropertiesExtended(_serialization.Model): # pylint: disable=too-many-instance-attributes """Deployment properties with additional details. Variables are only populated by the server, and will be ignored when sending a request. @@ -667,23 +620,23 @@ class DeploymentPropertiesExtended(msrest.serialization.Model): :ivar duration: The duration of the template deployment. :vartype duration: str :ivar outputs: Key/value pairs that represent deployment output. - :vartype outputs: any + :vartype outputs: JSON :ivar providers: The list of resource providers needed for the deployment. :vartype providers: list[~azure.mgmt.resource.resources.v2019_05_10.models.Provider] :ivar dependencies: The list of deployment dependencies. :vartype dependencies: list[~azure.mgmt.resource.resources.v2019_05_10.models.Dependency] :ivar template: The template content. Use only one of Template or TemplateLink. - :vartype template: any + :vartype template: JSON :ivar template_link: The URI referencing the template. Use only one of Template or TemplateLink. :vartype template_link: ~azure.mgmt.resource.resources.v2019_05_10.models.TemplateLink :ivar parameters: Deployment parameters. Use only one of Parameters or ParametersLink. - :vartype parameters: any + :vartype parameters: JSON :ivar parameters_link: The URI referencing the parameters. Use only one of Parameters or ParametersLink. :vartype parameters_link: ~azure.mgmt.resource.resources.v2019_05_10.models.ParametersLink - :ivar mode: The deployment mode. Possible values are Incremental and Complete. Possible values - include: "Incremental", "Complete". + :ivar mode: The deployment mode. Possible values are Incremental and Complete. Known values + are: "Incremental" and "Complete". :vartype mode: str or ~azure.mgmt.resource.resources.v2019_05_10.models.DeploymentMode :ivar debug_setting: The debug setting of the deployment. :vartype debug_setting: ~azure.mgmt.resource.resources.v2019_05_10.models.DebugSetting @@ -695,65 +648,65 @@ class DeploymentPropertiesExtended(msrest.serialization.Model): """ _validation = { - 'provisioning_state': {'readonly': True}, - 'correlation_id': {'readonly': True}, - 'timestamp': {'readonly': True}, - 'duration': {'readonly': True}, - 'error': {'readonly': True}, + "provisioning_state": {"readonly": True}, + "correlation_id": {"readonly": True}, + "timestamp": {"readonly": True}, + "duration": {"readonly": True}, + "error": {"readonly": True}, } _attribute_map = { - 'provisioning_state': {'key': 'provisioningState', 'type': 'str'}, - 'correlation_id': {'key': 'correlationId', 'type': 'str'}, - 'timestamp': {'key': 'timestamp', 'type': 'iso-8601'}, - 'duration': {'key': 'duration', 'type': 'str'}, - 'outputs': {'key': 'outputs', 'type': 'object'}, - 'providers': {'key': 'providers', 'type': '[Provider]'}, - 'dependencies': {'key': 'dependencies', 'type': '[Dependency]'}, - 'template': {'key': 'template', 'type': 'object'}, - 'template_link': {'key': 'templateLink', 'type': 'TemplateLink'}, - 'parameters': {'key': 'parameters', 'type': 'object'}, - 'parameters_link': {'key': 'parametersLink', 'type': 'ParametersLink'}, - 'mode': {'key': 'mode', 'type': 'str'}, - 'debug_setting': {'key': 'debugSetting', 'type': 'DebugSetting'}, - 'on_error_deployment': {'key': 'onErrorDeployment', 'type': 'OnErrorDeploymentExtended'}, - 'error': {'key': 'error', 'type': 'ErrorResponse'}, + "provisioning_state": {"key": "provisioningState", "type": "str"}, + "correlation_id": {"key": "correlationId", "type": "str"}, + "timestamp": {"key": "timestamp", "type": "iso-8601"}, + "duration": {"key": "duration", "type": "str"}, + "outputs": {"key": "outputs", "type": "object"}, + "providers": {"key": "providers", "type": "[Provider]"}, + "dependencies": {"key": "dependencies", "type": "[Dependency]"}, + "template": {"key": "template", "type": "object"}, + "template_link": {"key": "templateLink", "type": "TemplateLink"}, + "parameters": {"key": "parameters", "type": "object"}, + "parameters_link": {"key": "parametersLink", "type": "ParametersLink"}, + "mode": {"key": "mode", "type": "str"}, + "debug_setting": {"key": "debugSetting", "type": "DebugSetting"}, + "on_error_deployment": {"key": "onErrorDeployment", "type": "OnErrorDeploymentExtended"}, + "error": {"key": "error", "type": "ErrorResponse"}, } def __init__( self, *, - outputs: Optional[Any] = None, - providers: Optional[List["Provider"]] = None, - dependencies: Optional[List["Dependency"]] = None, - template: Optional[Any] = None, - template_link: Optional["TemplateLink"] = None, - parameters: Optional[Any] = None, - parameters_link: Optional["ParametersLink"] = None, - mode: Optional[Union[str, "DeploymentMode"]] = None, - debug_setting: Optional["DebugSetting"] = None, - on_error_deployment: Optional["OnErrorDeploymentExtended"] = None, + outputs: Optional[JSON] = None, + providers: Optional[List["_models.Provider"]] = None, + dependencies: Optional[List["_models.Dependency"]] = None, + template: Optional[JSON] = None, + template_link: Optional["_models.TemplateLink"] = None, + parameters: Optional[JSON] = None, + parameters_link: Optional["_models.ParametersLink"] = None, + mode: Optional[Union[str, "_models.DeploymentMode"]] = None, + debug_setting: Optional["_models.DebugSetting"] = None, + on_error_deployment: Optional["_models.OnErrorDeploymentExtended"] = None, **kwargs ): """ :keyword outputs: Key/value pairs that represent deployment output. - :paramtype outputs: any + :paramtype outputs: JSON :keyword providers: The list of resource providers needed for the deployment. :paramtype providers: list[~azure.mgmt.resource.resources.v2019_05_10.models.Provider] :keyword dependencies: The list of deployment dependencies. :paramtype dependencies: list[~azure.mgmt.resource.resources.v2019_05_10.models.Dependency] :keyword template: The template content. Use only one of Template or TemplateLink. - :paramtype template: any + :paramtype template: JSON :keyword template_link: The URI referencing the template. Use only one of Template or TemplateLink. :paramtype template_link: ~azure.mgmt.resource.resources.v2019_05_10.models.TemplateLink :keyword parameters: Deployment parameters. Use only one of Parameters or ParametersLink. - :paramtype parameters: any + :paramtype parameters: JSON :keyword parameters_link: The URI referencing the parameters. Use only one of Parameters or ParametersLink. :paramtype parameters_link: ~azure.mgmt.resource.resources.v2019_05_10.models.ParametersLink - :keyword mode: The deployment mode. Possible values are Incremental and Complete. Possible - values include: "Incremental", "Complete". + :keyword mode: The deployment mode. Possible values are Incremental and Complete. Known values + are: "Incremental" and "Complete". :paramtype mode: str or ~azure.mgmt.resource.resources.v2019_05_10.models.DeploymentMode :keyword debug_setting: The debug setting of the deployment. :paramtype debug_setting: ~azure.mgmt.resource.resources.v2019_05_10.models.DebugSetting @@ -761,7 +714,7 @@ def __init__( :paramtype on_error_deployment: ~azure.mgmt.resource.resources.v2019_05_10.models.OnErrorDeploymentExtended """ - super(DeploymentPropertiesExtended, self).__init__(**kwargs) + super().__init__(**kwargs) self.provisioning_state = None self.correlation_id = None self.timestamp = None @@ -779,7 +732,7 @@ def __init__( self.error = None -class DeploymentValidateResult(msrest.serialization.Model): +class DeploymentValidateResult(_serialization.Model): """Information from validate template deployment response. :ivar error: Validation error. @@ -791,15 +744,15 @@ class DeploymentValidateResult(msrest.serialization.Model): """ _attribute_map = { - 'error': {'key': 'error', 'type': 'ResourceManagementErrorWithDetails'}, - 'properties': {'key': 'properties', 'type': 'DeploymentPropertiesExtended'}, + "error": {"key": "error", "type": "ResourceManagementErrorWithDetails"}, + "properties": {"key": "properties", "type": "DeploymentPropertiesExtended"}, } def __init__( self, *, - error: Optional["ResourceManagementErrorWithDetails"] = None, - properties: Optional["DeploymentPropertiesExtended"] = None, + error: Optional["_models.ResourceManagementErrorWithDetails"] = None, + properties: Optional["_models.DeploymentPropertiesExtended"] = None, **kwargs ): """ @@ -810,12 +763,12 @@ def __init__( :paramtype properties: ~azure.mgmt.resource.resources.v2019_05_10.models.DeploymentPropertiesExtended """ - super(DeploymentValidateResult, self).__init__(**kwargs) + super().__init__(**kwargs) self.error = error self.properties = properties -class ErrorAdditionalInfo(msrest.serialization.Model): +class ErrorAdditionalInfo(_serialization.Model): """The resource management error additional info. Variables are only populated by the server, and will be ignored when sending a request. @@ -823,31 +776,27 @@ class ErrorAdditionalInfo(msrest.serialization.Model): :ivar type: The additional info type. :vartype type: str :ivar info: The additional info. - :vartype info: any + :vartype info: JSON """ _validation = { - 'type': {'readonly': True}, - 'info': {'readonly': True}, + "type": {"readonly": True}, + "info": {"readonly": True}, } _attribute_map = { - 'type': {'key': 'type', 'type': 'str'}, - 'info': {'key': 'info', 'type': 'object'}, + "type": {"key": "type", "type": "str"}, + "info": {"key": "info", "type": "object"}, } - def __init__( - self, - **kwargs - ): - """ - """ - super(ErrorAdditionalInfo, self).__init__(**kwargs) + def __init__(self, **kwargs): + """ """ + super().__init__(**kwargs) self.type = None self.info = None -class ErrorResponse(msrest.serialization.Model): +class ErrorResponse(_serialization.Model): """Common error response for all Azure Resource Manager APIs to return error details for failed operations. (This also follows the OData error response format.). Variables are only populated by the server, and will be ignored when sending a request. @@ -866,28 +815,24 @@ class ErrorResponse(msrest.serialization.Model): """ _validation = { - 'code': {'readonly': True}, - 'message': {'readonly': True}, - 'target': {'readonly': True}, - 'details': {'readonly': True}, - 'additional_info': {'readonly': True}, + "code": {"readonly": True}, + "message": {"readonly": True}, + "target": {"readonly": True}, + "details": {"readonly": True}, + "additional_info": {"readonly": True}, } _attribute_map = { - 'code': {'key': 'code', 'type': 'str'}, - 'message': {'key': 'message', 'type': 'str'}, - 'target': {'key': 'target', 'type': 'str'}, - 'details': {'key': 'details', 'type': '[ErrorResponse]'}, - 'additional_info': {'key': 'additionalInfo', 'type': '[ErrorAdditionalInfo]'}, + "code": {"key": "code", "type": "str"}, + "message": {"key": "message", "type": "str"}, + "target": {"key": "target", "type": "str"}, + "details": {"key": "details", "type": "[ErrorResponse]"}, + "additional_info": {"key": "additionalInfo", "type": "[ErrorAdditionalInfo]"}, } - def __init__( - self, - **kwargs - ): - """ - """ - super(ErrorResponse, self).__init__(**kwargs) + def __init__(self, **kwargs): + """ """ + super().__init__(**kwargs) self.code = None self.message = None self.target = None @@ -895,7 +840,7 @@ def __init__( self.additional_info = None -class ExportTemplateRequest(msrest.serialization.Model): +class ExportTemplateRequest(_serialization.Model): """Export resource group template request parameters. :ivar resources: The IDs of the resources to filter the export by. To export all resources, @@ -908,17 +853,11 @@ class ExportTemplateRequest(msrest.serialization.Model): """ _attribute_map = { - 'resources': {'key': 'resources', 'type': '[str]'}, - 'options': {'key': 'options', 'type': 'str'}, + "resources": {"key": "resources", "type": "[str]"}, + "options": {"key": "options", "type": "str"}, } - def __init__( - self, - *, - resources: Optional[List[str]] = None, - options: Optional[str] = None, - **kwargs - ): + def __init__(self, *, resources: Optional[List[str]] = None, options: Optional[str] = None, **kwargs): """ :keyword resources: The IDs of the resources to filter the export by. To export all resources, supply an array with single entry '*'. @@ -928,12 +867,12 @@ def __init__( 'SkipResourceNameParameterization', 'SkipAllParameterization'. :paramtype options: str """ - super(ExportTemplateRequest, self).__init__(**kwargs) + super().__init__(**kwargs) self.resources = resources self.options = options -class Resource(msrest.serialization.Model): +class Resource(_serialization.Model): """Specified resource. Variables are only populated by the server, and will be ignored when sending a request. @@ -946,38 +885,32 @@ class Resource(msrest.serialization.Model): :vartype type: str :ivar location: Resource location. :vartype location: str - :ivar tags: A set of tags. Resource tags. + :ivar tags: Resource tags. :vartype tags: dict[str, str] """ _validation = { - 'id': {'readonly': True}, - 'name': {'readonly': True}, - 'type': {'readonly': True}, + "id": {"readonly": True}, + "name": {"readonly": True}, + "type": {"readonly": True}, } _attribute_map = { - 'id': {'key': 'id', 'type': 'str'}, - 'name': {'key': 'name', 'type': 'str'}, - 'type': {'key': 'type', 'type': 'str'}, - 'location': {'key': 'location', 'type': 'str'}, - 'tags': {'key': 'tags', 'type': '{str}'}, + "id": {"key": "id", "type": "str"}, + "name": {"key": "name", "type": "str"}, + "type": {"key": "type", "type": "str"}, + "location": {"key": "location", "type": "str"}, + "tags": {"key": "tags", "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): """ :keyword location: Resource location. :paramtype location: str - :keyword tags: A set of tags. Resource tags. + :keyword tags: Resource tags. :paramtype tags: dict[str, str] """ - super(Resource, self).__init__(**kwargs) + super().__init__(**kwargs) self.id = None self.name = None self.type = None @@ -985,7 +918,7 @@ def __init__( self.tags = tags -class GenericResource(Resource): +class GenericResource(Resource): # pylint: disable=too-many-instance-attributes """Resource information. Variables are only populated by the server, and will be ignored when sending a request. @@ -998,12 +931,12 @@ class GenericResource(Resource): :vartype type: str :ivar location: Resource location. :vartype location: str - :ivar tags: A set of tags. Resource tags. + :ivar tags: Resource tags. :vartype tags: dict[str, str] :ivar plan: The plan of the resource. :vartype plan: ~azure.mgmt.resource.resources.v2019_05_10.models.Plan :ivar properties: The resource properties. - :vartype properties: any + :vartype properties: JSON :ivar kind: The kind of the resource. :vartype kind: str :ivar managed_by: ID of the resource that manages this resource. @@ -1015,24 +948,24 @@ class GenericResource(Resource): """ _validation = { - 'id': {'readonly': True}, - 'name': {'readonly': True}, - 'type': {'readonly': True}, - 'kind': {'pattern': r'^[-\w\._,\(\)]+$'}, + "id": {"readonly": True}, + "name": {"readonly": True}, + "type": {"readonly": True}, + "kind": {"pattern": r"^[-\w\._,\(\)]+$"}, } _attribute_map = { - 'id': {'key': 'id', 'type': 'str'}, - 'name': {'key': 'name', 'type': 'str'}, - 'type': {'key': 'type', 'type': 'str'}, - 'location': {'key': 'location', 'type': 'str'}, - 'tags': {'key': 'tags', 'type': '{str}'}, - 'plan': {'key': 'plan', 'type': 'Plan'}, - 'properties': {'key': 'properties', 'type': 'object'}, - 'kind': {'key': 'kind', 'type': 'str'}, - 'managed_by': {'key': 'managedBy', 'type': 'str'}, - 'sku': {'key': 'sku', 'type': 'Sku'}, - 'identity': {'key': 'identity', 'type': 'Identity'}, + "id": {"key": "id", "type": "str"}, + "name": {"key": "name", "type": "str"}, + "type": {"key": "type", "type": "str"}, + "location": {"key": "location", "type": "str"}, + "tags": {"key": "tags", "type": "{str}"}, + "plan": {"key": "plan", "type": "Plan"}, + "properties": {"key": "properties", "type": "object"}, + "kind": {"key": "kind", "type": "str"}, + "managed_by": {"key": "managedBy", "type": "str"}, + "sku": {"key": "sku", "type": "Sku"}, + "identity": {"key": "identity", "type": "Identity"}, } def __init__( @@ -1040,23 +973,23 @@ def __init__( *, location: Optional[str] = None, tags: Optional[Dict[str, str]] = None, - plan: Optional["Plan"] = None, - properties: Optional[Any] = None, + plan: Optional["_models.Plan"] = None, + properties: Optional[JSON] = None, kind: Optional[str] = None, managed_by: Optional[str] = None, - sku: Optional["Sku"] = None, - identity: Optional["Identity"] = None, + sku: Optional["_models.Sku"] = None, + identity: Optional["_models.Identity"] = None, **kwargs ): """ :keyword location: Resource location. :paramtype location: str - :keyword tags: A set of tags. Resource tags. + :keyword tags: Resource tags. :paramtype tags: dict[str, str] :keyword plan: The plan of the resource. :paramtype plan: ~azure.mgmt.resource.resources.v2019_05_10.models.Plan :keyword properties: The resource properties. - :paramtype properties: any + :paramtype properties: JSON :keyword kind: The kind of the resource. :paramtype kind: str :keyword managed_by: ID of the resource that manages this resource. @@ -1066,7 +999,7 @@ def __init__( :keyword identity: The identity of the resource. :paramtype identity: ~azure.mgmt.resource.resources.v2019_05_10.models.Identity """ - super(GenericResource, self).__init__(location=location, tags=tags, **kwargs) + super().__init__(location=location, tags=tags, **kwargs) self.plan = plan self.properties = properties self.kind = kind @@ -1075,7 +1008,7 @@ def __init__( self.identity = identity -class GenericResourceExpanded(GenericResource): +class GenericResourceExpanded(GenericResource): # pylint: disable=too-many-instance-attributes """Resource information. Variables are only populated by the server, and will be ignored when sending a request. @@ -1088,12 +1021,12 @@ class GenericResourceExpanded(GenericResource): :vartype type: str :ivar location: Resource location. :vartype location: str - :ivar tags: A set of tags. Resource tags. + :ivar tags: Resource tags. :vartype tags: dict[str, str] :ivar plan: The plan of the resource. :vartype plan: ~azure.mgmt.resource.resources.v2019_05_10.models.Plan :ivar properties: The resource properties. - :vartype properties: any + :vartype properties: JSON :ivar kind: The kind of the resource. :vartype kind: str :ivar managed_by: ID of the resource that manages this resource. @@ -1114,30 +1047,30 @@ class GenericResourceExpanded(GenericResource): """ _validation = { - 'id': {'readonly': True}, - 'name': {'readonly': True}, - 'type': {'readonly': True}, - 'kind': {'pattern': r'^[-\w\._,\(\)]+$'}, - 'created_time': {'readonly': True}, - 'changed_time': {'readonly': True}, - 'provisioning_state': {'readonly': True}, + "id": {"readonly": True}, + "name": {"readonly": True}, + "type": {"readonly": True}, + "kind": {"pattern": r"^[-\w\._,\(\)]+$"}, + "created_time": {"readonly": True}, + "changed_time": {"readonly": True}, + "provisioning_state": {"readonly": True}, } _attribute_map = { - 'id': {'key': 'id', 'type': 'str'}, - 'name': {'key': 'name', 'type': 'str'}, - 'type': {'key': 'type', 'type': 'str'}, - 'location': {'key': 'location', 'type': 'str'}, - 'tags': {'key': 'tags', 'type': '{str}'}, - 'plan': {'key': 'plan', 'type': 'Plan'}, - 'properties': {'key': 'properties', 'type': 'object'}, - 'kind': {'key': 'kind', 'type': 'str'}, - 'managed_by': {'key': 'managedBy', 'type': 'str'}, - 'sku': {'key': 'sku', 'type': 'Sku'}, - 'identity': {'key': 'identity', 'type': 'Identity'}, - 'created_time': {'key': 'createdTime', 'type': 'iso-8601'}, - 'changed_time': {'key': 'changedTime', 'type': 'iso-8601'}, - 'provisioning_state': {'key': 'provisioningState', 'type': 'str'}, + "id": {"key": "id", "type": "str"}, + "name": {"key": "name", "type": "str"}, + "type": {"key": "type", "type": "str"}, + "location": {"key": "location", "type": "str"}, + "tags": {"key": "tags", "type": "{str}"}, + "plan": {"key": "plan", "type": "Plan"}, + "properties": {"key": "properties", "type": "object"}, + "kind": {"key": "kind", "type": "str"}, + "managed_by": {"key": "managedBy", "type": "str"}, + "sku": {"key": "sku", "type": "Sku"}, + "identity": {"key": "identity", "type": "Identity"}, + "created_time": {"key": "createdTime", "type": "iso-8601"}, + "changed_time": {"key": "changedTime", "type": "iso-8601"}, + "provisioning_state": {"key": "provisioningState", "type": "str"}, } def __init__( @@ -1145,23 +1078,23 @@ def __init__( *, location: Optional[str] = None, tags: Optional[Dict[str, str]] = None, - plan: Optional["Plan"] = None, - properties: Optional[Any] = None, + plan: Optional["_models.Plan"] = None, + properties: Optional[JSON] = None, kind: Optional[str] = None, managed_by: Optional[str] = None, - sku: Optional["Sku"] = None, - identity: Optional["Identity"] = None, + sku: Optional["_models.Sku"] = None, + identity: Optional["_models.Identity"] = None, **kwargs ): """ :keyword location: Resource location. :paramtype location: str - :keyword tags: A set of tags. Resource tags. + :keyword tags: Resource tags. :paramtype tags: dict[str, str] :keyword plan: The plan of the resource. :paramtype plan: ~azure.mgmt.resource.resources.v2019_05_10.models.Plan :keyword properties: The resource properties. - :paramtype properties: any + :paramtype properties: JSON :keyword kind: The kind of the resource. :paramtype kind: str :keyword managed_by: ID of the resource that manages this resource. @@ -1171,13 +1104,23 @@ def __init__( :keyword identity: The identity of the resource. :paramtype identity: ~azure.mgmt.resource.resources.v2019_05_10.models.Identity """ - super(GenericResourceExpanded, self).__init__(location=location, tags=tags, plan=plan, properties=properties, kind=kind, managed_by=managed_by, sku=sku, identity=identity, **kwargs) + super().__init__( + location=location, + tags=tags, + plan=plan, + properties=properties, + kind=kind, + managed_by=managed_by, + sku=sku, + identity=identity, + **kwargs + ) self.created_time = None self.changed_time = None self.provisioning_state = None -class GenericResourceFilter(msrest.serialization.Model): +class GenericResourceFilter(_serialization.Model): """Resource filter. :ivar resource_type: The resource type. @@ -1189,9 +1132,9 @@ class GenericResourceFilter(msrest.serialization.Model): """ _attribute_map = { - 'resource_type': {'key': 'resourceType', 'type': 'str'}, - 'tagname': {'key': 'tagname', 'type': 'str'}, - 'tagvalue': {'key': 'tagvalue', 'type': 'str'}, + "resource_type": {"key": "resourceType", "type": "str"}, + "tagname": {"key": "tagname", "type": "str"}, + "tagvalue": {"key": "tagvalue", "type": "str"}, } def __init__( @@ -1210,38 +1153,33 @@ def __init__( :keyword tagvalue: The tag value. :paramtype tagvalue: str """ - super(GenericResourceFilter, self).__init__(**kwargs) + super().__init__(**kwargs) self.resource_type = resource_type self.tagname = tagname self.tagvalue = tagvalue -class HttpMessage(msrest.serialization.Model): +class HttpMessage(_serialization.Model): """HTTP message. :ivar content: HTTP message content. - :vartype content: any + :vartype content: JSON """ _attribute_map = { - 'content': {'key': 'content', 'type': 'object'}, + "content": {"key": "content", "type": "object"}, } - def __init__( - self, - *, - content: Optional[Any] = None, - **kwargs - ): + def __init__(self, *, content: Optional[JSON] = None, **kwargs): """ :keyword content: HTTP message content. - :paramtype content: any + :paramtype content: JSON """ - super(HttpMessage, self).__init__(**kwargs) + super().__init__(**kwargs) self.content = content -class Identity(msrest.serialization.Model): +class Identity(_serialization.Model): """Identity for the resource. Variables are only populated by the server, and will be ignored when sending a request. @@ -1250,8 +1188,8 @@ class Identity(msrest.serialization.Model): :vartype principal_id: str :ivar tenant_id: The tenant ID of resource. :vartype tenant_id: str - :ivar type: The identity type. Possible values include: "SystemAssigned", "UserAssigned", - "SystemAssigned, UserAssigned", "None". + :ivar type: The identity type. Known values are: "SystemAssigned", "UserAssigned", + "SystemAssigned, UserAssigned", and "None". :vartype type: str or ~azure.mgmt.resource.resources.v2019_05_10.models.ResourceIdentityType :ivar user_assigned_identities: The list of user identities associated with the resource. The user identity dictionary key references will be ARM resource ids in the form: @@ -1261,27 +1199,32 @@ class Identity(msrest.serialization.Model): """ _validation = { - 'principal_id': {'readonly': True}, - 'tenant_id': {'readonly': True}, + "principal_id": {"readonly": True}, + "tenant_id": {"readonly": True}, } _attribute_map = { - 'principal_id': {'key': 'principalId', 'type': 'str'}, - 'tenant_id': {'key': 'tenantId', 'type': 'str'}, - 'type': {'key': 'type', 'type': 'str'}, - 'user_assigned_identities': {'key': 'userAssignedIdentities', 'type': '{ComponentsSgqdofSchemasIdentityPropertiesUserassignedidentitiesAdditionalproperties}'}, + "principal_id": {"key": "principalId", "type": "str"}, + "tenant_id": {"key": "tenantId", "type": "str"}, + "type": {"key": "type", "type": "str"}, + "user_assigned_identities": { + "key": "userAssignedIdentities", + "type": "{ComponentsSgqdofSchemasIdentityPropertiesUserassignedidentitiesAdditionalproperties}", + }, } def __init__( self, *, - type: Optional[Union[str, "ResourceIdentityType"]] = None, - user_assigned_identities: Optional[Dict[str, "ComponentsSgqdofSchemasIdentityPropertiesUserassignedidentitiesAdditionalproperties"]] = None, + type: Optional[Union[str, "_models.ResourceIdentityType"]] = None, + user_assigned_identities: Optional[ + Dict[str, "_models.ComponentsSgqdofSchemasIdentityPropertiesUserassignedidentitiesAdditionalproperties"] + ] = None, **kwargs ): """ - :keyword type: The identity type. Possible values include: "SystemAssigned", "UserAssigned", - "SystemAssigned, UserAssigned", "None". + :keyword type: The identity type. Known values are: "SystemAssigned", "UserAssigned", + "SystemAssigned, UserAssigned", and "None". :paramtype type: str or ~azure.mgmt.resource.resources.v2019_05_10.models.ResourceIdentityType :keyword user_assigned_identities: The list of user identities associated with the resource. The user identity dictionary key references will be ARM resource ids in the form: @@ -1289,48 +1232,48 @@ def __init__( :paramtype user_assigned_identities: dict[str, ~azure.mgmt.resource.resources.v2019_05_10.models.ComponentsSgqdofSchemasIdentityPropertiesUserassignedidentitiesAdditionalproperties] """ - super(Identity, self).__init__(**kwargs) + super().__init__(**kwargs) self.principal_id = None self.tenant_id = None self.type = type self.user_assigned_identities = user_assigned_identities -class OnErrorDeployment(msrest.serialization.Model): +class OnErrorDeployment(_serialization.Model): """Deployment on error behavior. :ivar type: The deployment on error behavior type. Possible values are LastSuccessful and - SpecificDeployment. Possible values include: "LastSuccessful", "SpecificDeployment". + SpecificDeployment. Known values are: "LastSuccessful" and "SpecificDeployment". :vartype type: str or ~azure.mgmt.resource.resources.v2019_05_10.models.OnErrorDeploymentType :ivar deployment_name: The deployment to be used on error case. :vartype deployment_name: str """ _attribute_map = { - 'type': {'key': 'type', 'type': 'str'}, - 'deployment_name': {'key': 'deploymentName', 'type': 'str'}, + "type": {"key": "type", "type": "str"}, + "deployment_name": {"key": "deploymentName", "type": "str"}, } def __init__( self, *, - type: Optional[Union[str, "OnErrorDeploymentType"]] = None, + type: Optional[Union[str, "_models.OnErrorDeploymentType"]] = None, deployment_name: Optional[str] = None, **kwargs ): """ :keyword type: The deployment on error behavior type. Possible values are LastSuccessful and - SpecificDeployment. Possible values include: "LastSuccessful", "SpecificDeployment". + SpecificDeployment. Known values are: "LastSuccessful" and "SpecificDeployment". :paramtype type: str or ~azure.mgmt.resource.resources.v2019_05_10.models.OnErrorDeploymentType :keyword deployment_name: The deployment to be used on error case. :paramtype deployment_name: str """ - super(OnErrorDeployment, self).__init__(**kwargs) + super().__init__(**kwargs) self.type = type self.deployment_name = deployment_name -class OnErrorDeploymentExtended(msrest.serialization.Model): +class OnErrorDeploymentExtended(_serialization.Model): """Deployment on error behavior with additional details. Variables are only populated by the server, and will be ignored when sending a request. @@ -1338,43 +1281,43 @@ class OnErrorDeploymentExtended(msrest.serialization.Model): :ivar provisioning_state: The state of the provisioning for the on error deployment. :vartype provisioning_state: str :ivar type: The deployment on error behavior type. Possible values are LastSuccessful and - SpecificDeployment. Possible values include: "LastSuccessful", "SpecificDeployment". + SpecificDeployment. Known values are: "LastSuccessful" and "SpecificDeployment". :vartype type: str or ~azure.mgmt.resource.resources.v2019_05_10.models.OnErrorDeploymentType :ivar deployment_name: The deployment to be used on error case. :vartype deployment_name: str """ _validation = { - 'provisioning_state': {'readonly': True}, + "provisioning_state": {"readonly": True}, } _attribute_map = { - 'provisioning_state': {'key': 'provisioningState', 'type': 'str'}, - 'type': {'key': 'type', 'type': 'str'}, - 'deployment_name': {'key': 'deploymentName', 'type': 'str'}, + "provisioning_state": {"key": "provisioningState", "type": "str"}, + "type": {"key": "type", "type": "str"}, + "deployment_name": {"key": "deploymentName", "type": "str"}, } def __init__( self, *, - type: Optional[Union[str, "OnErrorDeploymentType"]] = None, + type: Optional[Union[str, "_models.OnErrorDeploymentType"]] = None, deployment_name: Optional[str] = None, **kwargs ): """ :keyword type: The deployment on error behavior type. Possible values are LastSuccessful and - SpecificDeployment. Possible values include: "LastSuccessful", "SpecificDeployment". + SpecificDeployment. Known values are: "LastSuccessful" and "SpecificDeployment". :paramtype type: str or ~azure.mgmt.resource.resources.v2019_05_10.models.OnErrorDeploymentType :keyword deployment_name: The deployment to be used on error case. :paramtype deployment_name: str """ - super(OnErrorDeploymentExtended, self).__init__(**kwargs) + super().__init__(**kwargs) self.provisioning_state = None self.type = type self.deployment_name = deployment_name -class Operation(msrest.serialization.Model): +class Operation(_serialization.Model): """Microsoft.Resources operation. :ivar name: Operation name: {provider}/{resource}/{operation}. @@ -1384,29 +1327,23 @@ class Operation(msrest.serialization.Model): """ _attribute_map = { - 'name': {'key': 'name', 'type': 'str'}, - 'display': {'key': 'display', 'type': 'OperationDisplay'}, + "name": {"key": "name", "type": "str"}, + "display": {"key": "display", "type": "OperationDisplay"}, } - def __init__( - self, - *, - name: Optional[str] = None, - display: Optional["OperationDisplay"] = None, - **kwargs - ): + def __init__(self, *, name: Optional[str] = None, display: Optional["_models.OperationDisplay"] = None, **kwargs): """ :keyword name: Operation name: {provider}/{resource}/{operation}. :paramtype name: str :keyword display: The object that represents the operation. :paramtype display: ~azure.mgmt.resource.resources.v2019_05_10.models.OperationDisplay """ - super(Operation, self).__init__(**kwargs) + super().__init__(**kwargs) self.name = name self.display = display -class OperationDisplay(msrest.serialization.Model): +class OperationDisplay(_serialization.Model): """The object that represents the operation. :ivar provider: Service provider: Microsoft.Resources. @@ -1420,10 +1357,10 @@ class OperationDisplay(msrest.serialization.Model): """ _attribute_map = { - 'provider': {'key': 'provider', 'type': 'str'}, - 'resource': {'key': 'resource', 'type': 'str'}, - 'operation': {'key': 'operation', 'type': 'str'}, - 'description': {'key': 'description', 'type': 'str'}, + "provider": {"key": "provider", "type": "str"}, + "resource": {"key": "resource", "type": "str"}, + "operation": {"key": "operation", "type": "str"}, + "description": {"key": "description", "type": "str"}, } def __init__( @@ -1445,14 +1382,14 @@ def __init__( :keyword description: Description of the operation. :paramtype description: str """ - super(OperationDisplay, self).__init__(**kwargs) + super().__init__(**kwargs) self.provider = provider self.resource = resource self.operation = operation self.description = description -class OperationListResult(msrest.serialization.Model): +class OperationListResult(_serialization.Model): """Result of the request to list Microsoft.Resources operations. It contains a list of operations and a URL link to get the next set of results. :ivar value: List of Microsoft.Resources operations. @@ -1462,67 +1399,55 @@ class OperationListResult(msrest.serialization.Model): """ _attribute_map = { - 'value': {'key': 'value', 'type': '[Operation]'}, - 'next_link': {'key': 'nextLink', 'type': 'str'}, + "value": {"key": "value", "type": "[Operation]"}, + "next_link": {"key": "nextLink", "type": "str"}, } - def __init__( - self, - *, - value: Optional[List["Operation"]] = None, - next_link: Optional[str] = None, - **kwargs - ): + def __init__(self, *, value: Optional[List["_models.Operation"]] = None, next_link: Optional[str] = None, **kwargs): """ :keyword value: List of Microsoft.Resources operations. :paramtype value: list[~azure.mgmt.resource.resources.v2019_05_10.models.Operation] :keyword next_link: URL to get the next set of operation list results if there are any. :paramtype next_link: str """ - super(OperationListResult, self).__init__(**kwargs) + super().__init__(**kwargs) self.value = value self.next_link = next_link -class ParametersLink(msrest.serialization.Model): +class ParametersLink(_serialization.Model): """Entity representing the reference to the deployment parameters. All required parameters must be populated in order to send to Azure. - :ivar uri: Required. The URI of the parameters file. + :ivar uri: The URI of the parameters file. Required. :vartype uri: str :ivar content_version: If included, must match the ContentVersion in the template. :vartype content_version: str """ _validation = { - 'uri': {'required': True}, + "uri": {"required": True}, } _attribute_map = { - 'uri': {'key': 'uri', 'type': 'str'}, - 'content_version': {'key': 'contentVersion', 'type': 'str'}, + "uri": {"key": "uri", "type": "str"}, + "content_version": {"key": "contentVersion", "type": "str"}, } - def __init__( - self, - *, - uri: str, - content_version: Optional[str] = None, - **kwargs - ): + def __init__(self, *, uri: str, content_version: Optional[str] = None, **kwargs): """ - :keyword uri: Required. The URI of the parameters file. + :keyword uri: The URI of the parameters file. Required. :paramtype uri: str :keyword content_version: If included, must match the ContentVersion in the template. :paramtype content_version: str """ - super(ParametersLink, self).__init__(**kwargs) + super().__init__(**kwargs) self.uri = uri self.content_version = content_version -class Plan(msrest.serialization.Model): +class Plan(_serialization.Model): """Plan for the resource. :ivar name: The plan ID. @@ -1538,11 +1463,11 @@ class Plan(msrest.serialization.Model): """ _attribute_map = { - 'name': {'key': 'name', 'type': 'str'}, - 'publisher': {'key': 'publisher', 'type': 'str'}, - 'product': {'key': 'product', 'type': 'str'}, - 'promotion_code': {'key': 'promotionCode', 'type': 'str'}, - 'version': {'key': 'version', 'type': 'str'}, + "name": {"key": "name", "type": "str"}, + "publisher": {"key": "publisher", "type": "str"}, + "product": {"key": "product", "type": "str"}, + "promotion_code": {"key": "promotionCode", "type": "str"}, + "version": {"key": "version", "type": "str"}, } def __init__( @@ -1567,7 +1492,7 @@ def __init__( :keyword version: The plan's version. :paramtype version: str """ - super(Plan, self).__init__(**kwargs) + super().__init__(**kwargs) self.name = name self.publisher = publisher self.product = product @@ -1575,7 +1500,7 @@ def __init__( self.version = version -class Provider(msrest.serialization.Model): +class Provider(_serialization.Model): """Resource provider information. Variables are only populated by the server, and will be ignored when sending a request. @@ -1594,31 +1519,26 @@ class Provider(msrest.serialization.Model): """ _validation = { - 'id': {'readonly': True}, - 'registration_state': {'readonly': True}, - 'registration_policy': {'readonly': True}, - 'resource_types': {'readonly': True}, + "id": {"readonly": True}, + "registration_state": {"readonly": True}, + "registration_policy": {"readonly": True}, + "resource_types": {"readonly": True}, } _attribute_map = { - 'id': {'key': 'id', 'type': 'str'}, - 'namespace': {'key': 'namespace', 'type': 'str'}, - 'registration_state': {'key': 'registrationState', 'type': 'str'}, - 'registration_policy': {'key': 'registrationPolicy', 'type': 'str'}, - 'resource_types': {'key': 'resourceTypes', 'type': '[ProviderResourceType]'}, + "id": {"key": "id", "type": "str"}, + "namespace": {"key": "namespace", "type": "str"}, + "registration_state": {"key": "registrationState", "type": "str"}, + "registration_policy": {"key": "registrationPolicy", "type": "str"}, + "resource_types": {"key": "resourceTypes", "type": "[ProviderResourceType]"}, } - def __init__( - self, - *, - namespace: Optional[str] = None, - **kwargs - ): + def __init__(self, *, namespace: Optional[str] = None, **kwargs): """ :keyword namespace: The namespace of the resource provider. :paramtype namespace: str """ - super(Provider, self).__init__(**kwargs) + super().__init__(**kwargs) self.id = None self.namespace = namespace self.registration_state = None @@ -1626,7 +1546,7 @@ def __init__( self.resource_types = None -class ProviderListResult(msrest.serialization.Model): +class ProviderListResult(_serialization.Model): """List of resource providers. Variables are only populated by the server, and will be ignored when sending a request. @@ -1638,30 +1558,25 @@ class ProviderListResult(msrest.serialization.Model): """ _validation = { - 'next_link': {'readonly': True}, + "next_link": {"readonly": True}, } _attribute_map = { - 'value': {'key': 'value', 'type': '[Provider]'}, - 'next_link': {'key': 'nextLink', 'type': 'str'}, + "value": {"key": "value", "type": "[Provider]"}, + "next_link": {"key": "nextLink", "type": "str"}, } - def __init__( - self, - *, - value: Optional[List["Provider"]] = None, - **kwargs - ): + def __init__(self, *, value: Optional[List["_models.Provider"]] = None, **kwargs): """ :keyword value: An array of resource providers. :paramtype value: list[~azure.mgmt.resource.resources.v2019_05_10.models.Provider] """ - super(ProviderListResult, self).__init__(**kwargs) + super().__init__(**kwargs) self.value = value self.next_link = None -class ProviderResourceType(msrest.serialization.Model): +class ProviderResourceType(_serialization.Model): """Resource type managed by the resource provider. :ivar resource_type: The resource type. @@ -1681,13 +1596,13 @@ class ProviderResourceType(msrest.serialization.Model): """ _attribute_map = { - 'resource_type': {'key': 'resourceType', 'type': 'str'}, - 'locations': {'key': 'locations', 'type': '[str]'}, - 'aliases': {'key': 'aliases', 'type': '[AliasType]'}, - 'api_versions': {'key': 'apiVersions', 'type': '[str]'}, - 'zone_mappings': {'key': 'zoneMappings', 'type': '[ZoneMapping]'}, - 'capabilities': {'key': 'capabilities', 'type': 'str'}, - 'properties': {'key': 'properties', 'type': '{str}'}, + "resource_type": {"key": "resourceType", "type": "str"}, + "locations": {"key": "locations", "type": "[str]"}, + "aliases": {"key": "aliases", "type": "[AliasType]"}, + "api_versions": {"key": "apiVersions", "type": "[str]"}, + "zone_mappings": {"key": "zoneMappings", "type": "[ZoneMapping]"}, + "capabilities": {"key": "capabilities", "type": "str"}, + "properties": {"key": "properties", "type": "{str}"}, } def __init__( @@ -1695,9 +1610,9 @@ def __init__( *, resource_type: Optional[str] = None, locations: Optional[List[str]] = None, - aliases: Optional[List["AliasType"]] = None, + aliases: Optional[List["_models.AliasType"]] = None, api_versions: Optional[List[str]] = None, - zone_mappings: Optional[List["ZoneMapping"]] = None, + zone_mappings: Optional[List["_models.ZoneMapping"]] = None, capabilities: Optional[str] = None, properties: Optional[Dict[str, str]] = None, **kwargs @@ -1718,7 +1633,7 @@ def __init__( :keyword properties: The properties. :paramtype properties: dict[str, str] """ - super(ProviderResourceType, self).__init__(**kwargs) + super().__init__(**kwargs) self.resource_type = resource_type self.locations = locations self.aliases = aliases @@ -1728,7 +1643,7 @@ def __init__( self.properties = properties -class ResourceGroup(msrest.serialization.Model): +class ResourceGroup(_serialization.Model): """Resource group information. Variables are only populated by the server, and will be ignored when sending a request. @@ -1743,37 +1658,37 @@ class ResourceGroup(msrest.serialization.Model): :vartype type: str :ivar properties: The resource group properties. :vartype properties: ~azure.mgmt.resource.resources.v2019_05_10.models.ResourceGroupProperties - :ivar location: Required. The location of the resource group. It cannot be changed after the - resource group has been created. It must be one of the supported Azure locations. + :ivar location: The location of the resource group. It cannot be changed after the resource + group has been created. It must be one of the supported Azure locations. Required. :vartype location: str :ivar managed_by: The ID of the resource that manages this resource group. :vartype managed_by: str - :ivar tags: A set of tags. The tags attached to the resource group. + :ivar tags: The tags attached to the resource group. :vartype tags: dict[str, str] """ _validation = { - 'id': {'readonly': True}, - 'name': {'readonly': True}, - 'type': {'readonly': True}, - 'location': {'required': True}, + "id": {"readonly": True}, + "name": {"readonly": True}, + "type": {"readonly": True}, + "location": {"required": True}, } _attribute_map = { - 'id': {'key': 'id', 'type': 'str'}, - 'name': {'key': 'name', 'type': 'str'}, - 'type': {'key': 'type', 'type': 'str'}, - 'properties': {'key': 'properties', 'type': 'ResourceGroupProperties'}, - 'location': {'key': 'location', 'type': 'str'}, - 'managed_by': {'key': 'managedBy', 'type': 'str'}, - 'tags': {'key': 'tags', 'type': '{str}'}, + "id": {"key": "id", "type": "str"}, + "name": {"key": "name", "type": "str"}, + "type": {"key": "type", "type": "str"}, + "properties": {"key": "properties", "type": "ResourceGroupProperties"}, + "location": {"key": "location", "type": "str"}, + "managed_by": {"key": "managedBy", "type": "str"}, + "tags": {"key": "tags", "type": "{str}"}, } def __init__( self, *, location: str, - properties: Optional["ResourceGroupProperties"] = None, + properties: Optional["_models.ResourceGroupProperties"] = None, managed_by: Optional[str] = None, tags: Optional[Dict[str, str]] = None, **kwargs @@ -1782,15 +1697,15 @@ def __init__( :keyword properties: The resource group properties. :paramtype properties: ~azure.mgmt.resource.resources.v2019_05_10.models.ResourceGroupProperties - :keyword location: Required. The location of the resource group. It cannot be changed after the - resource group has been created. It must be one of the supported Azure locations. + :keyword location: The location of the resource group. It cannot be changed after the resource + group has been created. It must be one of the supported Azure locations. Required. :paramtype location: str :keyword managed_by: The ID of the resource that manages this resource group. :paramtype managed_by: str - :keyword tags: A set of tags. The tags attached to the resource group. + :keyword tags: The tags attached to the resource group. :paramtype tags: dict[str, str] """ - super(ResourceGroup, self).__init__(**kwargs) + super().__init__(**kwargs) self.id = None self.name = None self.type = None @@ -1800,41 +1715,41 @@ def __init__( self.tags = tags -class ResourceGroupExportResult(msrest.serialization.Model): +class ResourceGroupExportResult(_serialization.Model): """Resource group export result. :ivar template: The template content. - :vartype template: any + :vartype template: JSON :ivar error: The error. :vartype error: ~azure.mgmt.resource.resources.v2019_05_10.models.ResourceManagementErrorWithDetails """ _attribute_map = { - 'template': {'key': 'template', 'type': 'object'}, - 'error': {'key': 'error', 'type': 'ResourceManagementErrorWithDetails'}, + "template": {"key": "template", "type": "object"}, + "error": {"key": "error", "type": "ResourceManagementErrorWithDetails"}, } def __init__( self, *, - template: Optional[Any] = None, - error: Optional["ResourceManagementErrorWithDetails"] = None, + template: Optional[JSON] = None, + error: Optional["_models.ResourceManagementErrorWithDetails"] = None, **kwargs ): """ :keyword template: The template content. - :paramtype template: any + :paramtype template: JSON :keyword error: The error. :paramtype error: ~azure.mgmt.resource.resources.v2019_05_10.models.ResourceManagementErrorWithDetails """ - super(ResourceGroupExportResult, self).__init__(**kwargs) + super().__init__(**kwargs) self.template = template self.error = error -class ResourceGroupFilter(msrest.serialization.Model): +class ResourceGroupFilter(_serialization.Model): """Resource group filter. :ivar tag_name: The tag name. @@ -1844,29 +1759,23 @@ class ResourceGroupFilter(msrest.serialization.Model): """ _attribute_map = { - 'tag_name': {'key': 'tagName', 'type': 'str'}, - 'tag_value': {'key': 'tagValue', 'type': 'str'}, + "tag_name": {"key": "tagName", "type": "str"}, + "tag_value": {"key": "tagValue", "type": "str"}, } - def __init__( - self, - *, - tag_name: Optional[str] = None, - tag_value: Optional[str] = None, - **kwargs - ): + def __init__(self, *, tag_name: Optional[str] = None, tag_value: Optional[str] = None, **kwargs): """ :keyword tag_name: The tag name. :paramtype tag_name: str :keyword tag_value: The tag value. :paramtype tag_value: str """ - super(ResourceGroupFilter, self).__init__(**kwargs) + super().__init__(**kwargs) self.tag_name = tag_name self.tag_value = tag_value -class ResourceGroupListResult(msrest.serialization.Model): +class ResourceGroupListResult(_serialization.Model): """List of resource groups. Variables are only populated by the server, and will be ignored when sending a request. @@ -1878,30 +1787,25 @@ class ResourceGroupListResult(msrest.serialization.Model): """ _validation = { - 'next_link': {'readonly': True}, + "next_link": {"readonly": True}, } _attribute_map = { - 'value': {'key': 'value', 'type': '[ResourceGroup]'}, - 'next_link': {'key': 'nextLink', 'type': 'str'}, + "value": {"key": "value", "type": "[ResourceGroup]"}, + "next_link": {"key": "nextLink", "type": "str"}, } - def __init__( - self, - *, - value: Optional[List["ResourceGroup"]] = None, - **kwargs - ): + def __init__(self, *, value: Optional[List["_models.ResourceGroup"]] = None, **kwargs): """ :keyword value: An array of resource groups. :paramtype value: list[~azure.mgmt.resource.resources.v2019_05_10.models.ResourceGroup] """ - super(ResourceGroupListResult, self).__init__(**kwargs) + super().__init__(**kwargs) self.value = value self.next_link = None -class ResourceGroupPatchable(msrest.serialization.Model): +class ResourceGroupPatchable(_serialization.Model): """Resource group information. :ivar name: The name of the resource group. @@ -1910,22 +1814,22 @@ class ResourceGroupPatchable(msrest.serialization.Model): :vartype properties: ~azure.mgmt.resource.resources.v2019_05_10.models.ResourceGroupProperties :ivar managed_by: The ID of the resource that manages this resource group. :vartype managed_by: str - :ivar tags: A set of tags. The tags attached to the resource group. + :ivar tags: The tags attached to the resource group. :vartype tags: dict[str, str] """ _attribute_map = { - 'name': {'key': 'name', 'type': 'str'}, - 'properties': {'key': 'properties', 'type': 'ResourceGroupProperties'}, - 'managed_by': {'key': 'managedBy', 'type': 'str'}, - 'tags': {'key': 'tags', 'type': '{str}'}, + "name": {"key": "name", "type": "str"}, + "properties": {"key": "properties", "type": "ResourceGroupProperties"}, + "managed_by": {"key": "managedBy", "type": "str"}, + "tags": {"key": "tags", "type": "{str}"}, } def __init__( self, *, name: Optional[str] = None, - properties: Optional["ResourceGroupProperties"] = None, + properties: Optional["_models.ResourceGroupProperties"] = None, managed_by: Optional[str] = None, tags: Optional[Dict[str, str]] = None, **kwargs @@ -1938,17 +1842,17 @@ def __init__( ~azure.mgmt.resource.resources.v2019_05_10.models.ResourceGroupProperties :keyword managed_by: The ID of the resource that manages this resource group. :paramtype managed_by: str - :keyword tags: A set of tags. The tags attached to the resource group. + :keyword tags: The tags attached to the resource group. :paramtype tags: dict[str, str] """ - super(ResourceGroupPatchable, self).__init__(**kwargs) + super().__init__(**kwargs) self.name = name self.properties = properties self.managed_by = managed_by self.tags = tags -class ResourceGroupProperties(msrest.serialization.Model): +class ResourceGroupProperties(_serialization.Model): """The resource group properties. Variables are only populated by the server, and will be ignored when sending a request. @@ -1958,24 +1862,20 @@ class ResourceGroupProperties(msrest.serialization.Model): """ _validation = { - 'provisioning_state': {'readonly': True}, + "provisioning_state": {"readonly": True}, } _attribute_map = { - 'provisioning_state': {'key': 'provisioningState', 'type': 'str'}, + "provisioning_state": {"key": "provisioningState", "type": "str"}, } - def __init__( - self, - **kwargs - ): - """ - """ - super(ResourceGroupProperties, self).__init__(**kwargs) + def __init__(self, **kwargs): + """ """ + super().__init__(**kwargs) self.provisioning_state = None -class ResourceListResult(msrest.serialization.Model): +class ResourceListResult(_serialization.Model): """List of resource groups. Variables are only populated by the server, and will be ignored when sending a request. @@ -1987,31 +1887,26 @@ class ResourceListResult(msrest.serialization.Model): """ _validation = { - 'next_link': {'readonly': True}, + "next_link": {"readonly": True}, } _attribute_map = { - 'value': {'key': 'value', 'type': '[GenericResourceExpanded]'}, - 'next_link': {'key': 'nextLink', 'type': 'str'}, + "value": {"key": "value", "type": "[GenericResourceExpanded]"}, + "next_link": {"key": "nextLink", "type": "str"}, } - def __init__( - self, - *, - value: Optional[List["GenericResourceExpanded"]] = None, - **kwargs - ): + def __init__(self, *, value: Optional[List["_models.GenericResourceExpanded"]] = None, **kwargs): """ :keyword value: An array of resources. :paramtype value: list[~azure.mgmt.resource.resources.v2019_05_10.models.GenericResourceExpanded] """ - super(ResourceListResult, self).__init__(**kwargs) + super().__init__(**kwargs) self.value = value self.next_link = None -class ResourceManagementErrorWithDetails(msrest.serialization.Model): +class ResourceManagementErrorWithDetails(_serialization.Model): """The detailed error message of resource management. Variables are only populated by the server, and will be ignored when sending a request. @@ -2028,33 +1923,29 @@ class ResourceManagementErrorWithDetails(msrest.serialization.Model): """ _validation = { - 'code': {'readonly': True}, - 'message': {'readonly': True}, - 'target': {'readonly': True}, - 'details': {'readonly': True}, + "code": {"readonly": True}, + "message": {"readonly": True}, + "target": {"readonly": True}, + "details": {"readonly": True}, } _attribute_map = { - 'code': {'key': 'code', 'type': 'str'}, - 'message': {'key': 'message', 'type': 'str'}, - 'target': {'key': 'target', 'type': 'str'}, - 'details': {'key': 'details', 'type': '[ResourceManagementErrorWithDetails]'}, + "code": {"key": "code", "type": "str"}, + "message": {"key": "message", "type": "str"}, + "target": {"key": "target", "type": "str"}, + "details": {"key": "details", "type": "[ResourceManagementErrorWithDetails]"}, } - def __init__( - self, - **kwargs - ): - """ - """ - super(ResourceManagementErrorWithDetails, self).__init__(**kwargs) + def __init__(self, **kwargs): + """ """ + super().__init__(**kwargs) self.code = None self.message = None self.target = None self.details = None -class ResourceProviderOperationDisplayProperties(msrest.serialization.Model): +class ResourceProviderOperationDisplayProperties(_serialization.Model): """Resource provider operation's display properties. :ivar publisher: Operation description. @@ -2070,11 +1961,11 @@ class ResourceProviderOperationDisplayProperties(msrest.serialization.Model): """ _attribute_map = { - 'publisher': {'key': 'publisher', 'type': 'str'}, - 'provider': {'key': 'provider', 'type': 'str'}, - 'resource': {'key': 'resource', 'type': 'str'}, - 'operation': {'key': 'operation', 'type': 'str'}, - 'description': {'key': 'description', 'type': 'str'}, + "publisher": {"key": "publisher", "type": "str"}, + "provider": {"key": "provider", "type": "str"}, + "resource": {"key": "resource", "type": "str"}, + "operation": {"key": "operation", "type": "str"}, + "description": {"key": "description", "type": "str"}, } def __init__( @@ -2099,7 +1990,7 @@ def __init__( :keyword description: Operation description. :paramtype description: str """ - super(ResourceProviderOperationDisplayProperties, self).__init__(**kwargs) + super().__init__(**kwargs) self.publisher = publisher self.provider = provider self.resource = resource @@ -2107,7 +1998,7 @@ def __init__( self.description = description -class ResourcesMoveInfo(msrest.serialization.Model): +class ResourcesMoveInfo(_serialization.Model): """Parameters of move resources. :ivar resources: The IDs of the resources. @@ -2117,29 +2008,23 @@ class ResourcesMoveInfo(msrest.serialization.Model): """ _attribute_map = { - 'resources': {'key': 'resources', 'type': '[str]'}, - 'target_resource_group': {'key': 'targetResourceGroup', 'type': 'str'}, + "resources": {"key": "resources", "type": "[str]"}, + "target_resource_group": {"key": "targetResourceGroup", "type": "str"}, } - def __init__( - self, - *, - resources: Optional[List[str]] = None, - target_resource_group: Optional[str] = None, - **kwargs - ): + def __init__(self, *, resources: Optional[List[str]] = None, target_resource_group: Optional[str] = None, **kwargs): """ :keyword resources: The IDs of the resources. :paramtype resources: list[str] :keyword target_resource_group: The target resource group. :paramtype target_resource_group: str """ - super(ResourcesMoveInfo, self).__init__(**kwargs) + super().__init__(**kwargs) self.resources = resources self.target_resource_group = target_resource_group -class Sku(msrest.serialization.Model): +class Sku(_serialization.Model): """SKU for the resource. :ivar name: The SKU name. @@ -2157,12 +2042,12 @@ class Sku(msrest.serialization.Model): """ _attribute_map = { - 'name': {'key': 'name', 'type': 'str'}, - 'tier': {'key': 'tier', 'type': 'str'}, - 'size': {'key': 'size', 'type': 'str'}, - 'family': {'key': 'family', 'type': 'str'}, - 'model': {'key': 'model', 'type': 'str'}, - 'capacity': {'key': 'capacity', 'type': 'int'}, + "name": {"key": "name", "type": "str"}, + "tier": {"key": "tier", "type": "str"}, + "size": {"key": "size", "type": "str"}, + "family": {"key": "family", "type": "str"}, + "model": {"key": "model", "type": "str"}, + "capacity": {"key": "capacity", "type": "int"}, } def __init__( @@ -2190,7 +2075,7 @@ def __init__( :keyword capacity: The SKU capacity. :paramtype capacity: int """ - super(Sku, self).__init__(**kwargs) + super().__init__(**kwargs) self.name = name self.tier = tier self.size = size @@ -2199,7 +2084,7 @@ def __init__( self.capacity = capacity -class SubResource(msrest.serialization.Model): +class SubResource(_serialization.Model): """Sub-resource. :ivar id: Resource ID. @@ -2207,24 +2092,19 @@ class SubResource(msrest.serialization.Model): """ _attribute_map = { - 'id': {'key': 'id', 'type': 'str'}, + "id": {"key": "id", "type": "str"}, } - def __init__( - self, - *, - id: Optional[str] = None, - **kwargs - ): + def __init__(self, *, id: Optional[str] = None, **kwargs): # pylint: disable=redefined-builtin """ :keyword id: Resource ID. :paramtype id: str """ - super(SubResource, self).__init__(**kwargs) + super().__init__(**kwargs) self.id = id -class TagCount(msrest.serialization.Model): +class TagCount(_serialization.Model): """Tag count. :ivar type: Type of count. @@ -2234,29 +2114,23 @@ class TagCount(msrest.serialization.Model): """ _attribute_map = { - 'type': {'key': 'type', 'type': 'str'}, - 'value': {'key': 'value', 'type': 'int'}, + "type": {"key": "type", "type": "str"}, + "value": {"key": "value", "type": "int"}, } - def __init__( - self, - *, - type: Optional[str] = None, - value: Optional[int] = None, - **kwargs - ): + def __init__(self, *, type: Optional[str] = None, value: Optional[int] = None, **kwargs): """ :keyword type: Type of count. :paramtype type: str :keyword value: Value of count. :paramtype value: int """ - super(TagCount, self).__init__(**kwargs) + super().__init__(**kwargs) self.type = type self.value = value -class TagDetails(msrest.serialization.Model): +class TagDetails(_serialization.Model): """Tag details. Variables are only populated by the server, and will be ignored when sending a request. @@ -2273,22 +2147,22 @@ class TagDetails(msrest.serialization.Model): """ _validation = { - 'id': {'readonly': True}, + "id": {"readonly": True}, } _attribute_map = { - 'id': {'key': 'id', 'type': 'str'}, - 'tag_name': {'key': 'tagName', 'type': 'str'}, - 'count': {'key': 'count', 'type': 'TagCount'}, - 'values': {'key': 'values', 'type': '[TagValue]'}, + "id": {"key": "id", "type": "str"}, + "tag_name": {"key": "tagName", "type": "str"}, + "count": {"key": "count", "type": "TagCount"}, + "values": {"key": "values", "type": "[TagValue]"}, } def __init__( self, *, tag_name: Optional[str] = None, - count: Optional["TagCount"] = None, - values: Optional[List["TagValue"]] = None, + count: Optional["_models.TagCount"] = None, + values: Optional[List["_models.TagValue"]] = None, **kwargs ): """ @@ -2300,14 +2174,14 @@ def __init__( :keyword values: The list of tag values. :paramtype values: list[~azure.mgmt.resource.resources.v2019_05_10.models.TagValue] """ - super(TagDetails, self).__init__(**kwargs) + super().__init__(**kwargs) self.id = None self.tag_name = tag_name self.count = count self.values = values -class TagsListResult(msrest.serialization.Model): +class TagsListResult(_serialization.Model): """List of subscription tags. Variables are only populated by the server, and will be ignored when sending a request. @@ -2319,30 +2193,25 @@ class TagsListResult(msrest.serialization.Model): """ _validation = { - 'next_link': {'readonly': True}, + "next_link": {"readonly": True}, } _attribute_map = { - 'value': {'key': 'value', 'type': '[TagDetails]'}, - 'next_link': {'key': 'nextLink', 'type': 'str'}, + "value": {"key": "value", "type": "[TagDetails]"}, + "next_link": {"key": "nextLink", "type": "str"}, } - def __init__( - self, - *, - value: Optional[List["TagDetails"]] = None, - **kwargs - ): + def __init__(self, *, value: Optional[List["_models.TagDetails"]] = None, **kwargs): """ :keyword value: An array of tags. :paramtype value: list[~azure.mgmt.resource.resources.v2019_05_10.models.TagDetails] """ - super(TagsListResult, self).__init__(**kwargs) + super().__init__(**kwargs) self.value = value self.next_link = None -class TagValue(msrest.serialization.Model): +class TagValue(_serialization.Model): """Tag information. Variables are only populated by the server, and will be ignored when sending a request. @@ -2356,35 +2225,29 @@ class TagValue(msrest.serialization.Model): """ _validation = { - 'id': {'readonly': True}, + "id": {"readonly": True}, } _attribute_map = { - 'id': {'key': 'id', 'type': 'str'}, - 'tag_value': {'key': 'tagValue', 'type': 'str'}, - 'count': {'key': 'count', 'type': 'TagCount'}, + "id": {"key": "id", "type": "str"}, + "tag_value": {"key": "tagValue", "type": "str"}, + "count": {"key": "count", "type": "TagCount"}, } - def __init__( - self, - *, - tag_value: Optional[str] = None, - count: Optional["TagCount"] = None, - **kwargs - ): + def __init__(self, *, tag_value: Optional[str] = None, count: Optional["_models.TagCount"] = None, **kwargs): """ :keyword tag_value: The tag value. :paramtype tag_value: str :keyword count: The tag value count. :paramtype count: ~azure.mgmt.resource.resources.v2019_05_10.models.TagCount """ - super(TagValue, self).__init__(**kwargs) + super().__init__(**kwargs) self.id = None self.tag_value = tag_value self.count = count -class TargetResource(msrest.serialization.Model): +class TargetResource(_serialization.Model): """Target resource. :ivar id: The ID of the resource. @@ -2396,15 +2259,15 @@ class TargetResource(msrest.serialization.Model): """ _attribute_map = { - 'id': {'key': 'id', 'type': 'str'}, - 'resource_name': {'key': 'resourceName', 'type': 'str'}, - 'resource_type': {'key': 'resourceType', 'type': 'str'}, + "id": {"key": "id", "type": "str"}, + "resource_name": {"key": "resourceName", "type": "str"}, + "resource_type": {"key": "resourceType", "type": "str"}, } def __init__( self, *, - id: Optional[str] = None, + id: Optional[str] = None, # pylint: disable=redefined-builtin resource_name: Optional[str] = None, resource_type: Optional[str] = None, **kwargs @@ -2417,13 +2280,13 @@ def __init__( :keyword resource_type: The type of the resource. :paramtype resource_type: str """ - super(TargetResource, self).__init__(**kwargs) + super().__init__(**kwargs) self.id = id self.resource_name = resource_name self.resource_type = resource_type -class TemplateHashResult(msrest.serialization.Model): +class TemplateHashResult(_serialization.Model): """Result of the request to calculate template hash. It contains a string of minified template and its hash. :ivar minified_template: The minified template string. @@ -2433,67 +2296,55 @@ class TemplateHashResult(msrest.serialization.Model): """ _attribute_map = { - 'minified_template': {'key': 'minifiedTemplate', 'type': 'str'}, - 'template_hash': {'key': 'templateHash', 'type': 'str'}, + "minified_template": {"key": "minifiedTemplate", "type": "str"}, + "template_hash": {"key": "templateHash", "type": "str"}, } - def __init__( - self, - *, - minified_template: Optional[str] = None, - template_hash: Optional[str] = None, - **kwargs - ): + def __init__(self, *, minified_template: Optional[str] = None, template_hash: Optional[str] = None, **kwargs): """ :keyword minified_template: The minified template string. :paramtype minified_template: str :keyword template_hash: The template hash. :paramtype template_hash: str """ - super(TemplateHashResult, self).__init__(**kwargs) + super().__init__(**kwargs) self.minified_template = minified_template self.template_hash = template_hash -class TemplateLink(msrest.serialization.Model): +class TemplateLink(_serialization.Model): """Entity representing the reference to the template. All required parameters must be populated in order to send to Azure. - :ivar uri: Required. The URI of the template to deploy. + :ivar uri: The URI of the template to deploy. Required. :vartype uri: str :ivar content_version: If included, must match the ContentVersion in the template. :vartype content_version: str """ _validation = { - 'uri': {'required': True}, + "uri": {"required": True}, } _attribute_map = { - 'uri': {'key': 'uri', 'type': 'str'}, - 'content_version': {'key': 'contentVersion', 'type': 'str'}, + "uri": {"key": "uri", "type": "str"}, + "content_version": {"key": "contentVersion", "type": "str"}, } - def __init__( - self, - *, - uri: str, - content_version: Optional[str] = None, - **kwargs - ): + def __init__(self, *, uri: str, content_version: Optional[str] = None, **kwargs): """ - :keyword uri: Required. The URI of the template to deploy. + :keyword uri: The URI of the template to deploy. Required. :paramtype uri: str :keyword content_version: If included, must match the ContentVersion in the template. :paramtype content_version: str """ - super(TemplateLink, self).__init__(**kwargs) + super().__init__(**kwargs) self.uri = uri self.content_version = content_version -class ZoneMapping(msrest.serialization.Model): +class ZoneMapping(_serialization.Model): """ZoneMapping. :ivar location: The location of the zone mapping. @@ -2503,23 +2354,17 @@ class ZoneMapping(msrest.serialization.Model): """ _attribute_map = { - 'location': {'key': 'location', 'type': 'str'}, - 'zones': {'key': 'zones', 'type': '[str]'}, + "location": {"key": "location", "type": "str"}, + "zones": {"key": "zones", "type": "[str]"}, } - def __init__( - self, - *, - location: Optional[str] = None, - zones: Optional[List[str]] = None, - **kwargs - ): + def __init__(self, *, location: Optional[str] = None, zones: Optional[List[str]] = None, **kwargs): """ :keyword location: The location of the zone mapping. :paramtype location: str :keyword zones: :paramtype zones: list[str] """ - super(ZoneMapping, self).__init__(**kwargs) + super().__init__(**kwargs) self.location = location self.zones = zones diff --git a/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/resources/v2019_05_10/models/_patch.py b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/resources/v2019_05_10/models/_patch.py new file mode 100644 index 0000000000000..f7dd32510333d --- /dev/null +++ b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/resources/v2019_05_10/models/_patch.py @@ -0,0 +1,20 @@ +# ------------------------------------ +# Copyright (c) Microsoft Corporation. +# Licensed under the MIT License. +# ------------------------------------ +"""Customize generated code here. + +Follow our quickstart for examples: https://aka.ms/azsdk/python/dpcodegen/python/customize +""" +from typing import List + +__all__: List[str] = [] # Add all objects you want publicly available to users at this package level + + +def patch_sdk(): + """Do not remove from this file. + + `patch_sdk` is a last resort escape hatch that allows you to do customizations + you can't accomplish using the techniques described in + https://aka.ms/azsdk/python/dpcodegen/python/customize + """ diff --git a/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/resources/v2019_05_10/models/_resource_management_client_enums.py b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/resources/v2019_05_10/models/_resource_management_client_enums.py index 02799db402bcc..612a5242cd9bd 100644 --- a/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/resources/v2019_05_10/models/_resource_management_client_enums.py +++ b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/resources/v2019_05_10/models/_resource_management_client_enums.py @@ -7,11 +7,10 @@ # -------------------------------------------------------------------------- from enum import Enum -from six import with_metaclass from azure.core import CaseInsensitiveEnumMeta -class DeploymentMode(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): +class DeploymentMode(str, Enum, metaclass=CaseInsensitiveEnumMeta): """The mode that is used to deploy resources. This value can be either Incremental or Complete. In Incremental mode, resources are deployed without deleting existing resources that are not included in the template. In Complete mode, resources are deployed and existing resources in @@ -22,7 +21,8 @@ class DeploymentMode(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): INCREMENTAL = "Incremental" COMPLETE = "Complete" -class OnErrorDeploymentType(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): + +class OnErrorDeploymentType(str, Enum, metaclass=CaseInsensitiveEnumMeta): """The deployment on error behavior type. Possible values are LastSuccessful and SpecificDeployment. """ @@ -30,9 +30,9 @@ class OnErrorDeploymentType(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): LAST_SUCCESSFUL = "LastSuccessful" SPECIFIC_DEPLOYMENT = "SpecificDeployment" -class ResourceIdentityType(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): - """The identity type. - """ + +class ResourceIdentityType(str, Enum, metaclass=CaseInsensitiveEnumMeta): + """The identity type.""" SYSTEM_ASSIGNED = "SystemAssigned" USER_ASSIGNED = "UserAssigned" diff --git a/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/resources/v2019_05_10/operations/__init__.py b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/resources/v2019_05_10/operations/__init__.py index 53876d82bf5d7..804fee65e3137 100644 --- a/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/resources/v2019_05_10/operations/__init__.py +++ b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/resources/v2019_05_10/operations/__init__.py @@ -14,12 +14,18 @@ from ._operations import TagsOperations from ._operations import DeploymentOperationsOperations +from ._patch import __all__ as _patch_all +from ._patch import * # type: ignore # pylint: disable=unused-wildcard-import +from ._patch import patch_sdk as _patch_sdk + __all__ = [ - 'Operations', - 'DeploymentsOperations', - 'ProvidersOperations', - 'ResourcesOperations', - 'ResourceGroupsOperations', - 'TagsOperations', - 'DeploymentOperationsOperations', + "Operations", + "DeploymentsOperations", + "ProvidersOperations", + "ResourcesOperations", + "ResourceGroupsOperations", + "TagsOperations", + "DeploymentOperationsOperations", ] +__all__.extend([p for p in _patch_all if p not in __all__]) +_patch_sdk() diff --git a/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/resources/v2019_05_10/operations/_operations.py b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/resources/v2019_05_10/operations/_operations.py index 8d8aaf2b1c5c7..c8ff985c381e5 100644 --- a/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/resources/v2019_05_10/operations/_operations.py +++ b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/resources/v2019_05_10/operations/_operations.py @@ -6,853 +6,777 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -from typing import Any, Callable, Dict, Iterable, Optional, TypeVar, Union - -from msrest import Serializer - -from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error +import sys +from typing import Any, Callable, Dict, IO, Iterable, Optional, TypeVar, Union, cast, overload +from urllib.parse import parse_qs, urljoin, urlparse + +from azure.core.exceptions import ( + ClientAuthenticationError, + HttpResponseError, + ResourceExistsError, + ResourceNotFoundError, + ResourceNotModifiedError, + map_error, +) from azure.core.paging import ItemPaged from azure.core.pipeline import PipelineResponse from azure.core.pipeline.transport import HttpResponse from azure.core.polling import LROPoller, NoPolling, PollingMethod from azure.core.rest import HttpRequest from azure.core.tracing.decorator import distributed_trace +from azure.core.utils import case_insensitive_dict from azure.mgmt.core.exceptions import ARMErrorFormat from azure.mgmt.core.polling.arm_polling import ARMPolling from .. import models as _models +from ..._serialization import Serializer from .._vendor import _convert_request, _format_url_section -T = TypeVar('T') + +T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] -JSONType = Any +if sys.version_info >= (3, 9): + from collections.abc import MutableMapping +else: + from typing import MutableMapping # type: ignore # pylint: disable=ungrouped-imports +JSON = MutableMapping[str, Any] # pylint: disable=unsubscriptable-object _SERIALIZER = Serializer() _SERIALIZER.client_side_validation = False -def build_operations_list_request( - **kwargs: Any -) -> HttpRequest: - api_version = kwargs.pop('api_version', "2019-05-10") # type: str - accept = "application/json" +def build_operations_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", "2019-05-10")) # type: str + accept = _headers.pop("Accept", "application/json") + # Construct URL _url = kwargs.pop("template_url", "/providers/Microsoft.Resources/operations") # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') - - return HttpRequest( - method="GET", - url=_url, - params=_query_parameters, - headers=_header_parameters, - **kwargs - ) + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) -def build_deployments_delete_at_management_group_scope_request_initial( - group_id: str, - deployment_name: str, - **kwargs: Any + +def build_deployments_delete_at_management_group_scope_request( + group_id: str, deployment_name: str, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2019-05-10") # type: str + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + api_version = kwargs.pop("api_version", _params.pop("api-version", "2019-05-10")) # type: str # Construct URL - _url = kwargs.pop("template_url", "/providers/Microsoft.Management/managementGroups/{groupId}/providers/Microsoft.Resources/deployments/{deploymentName}") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", + "/providers/Microsoft.Management/managementGroups/{groupId}/providers/Microsoft.Resources/deployments/{deploymentName}", + ) # pylint: disable=line-too-long path_format_arguments = { - "groupId": _SERIALIZER.url("group_id", group_id, 'str', max_length=90, min_length=1), - "deploymentName": _SERIALIZER.url("deployment_name", deployment_name, 'str', max_length=64, min_length=1, pattern=r'^[-\w\._\(\)]+$'), + "groupId": _SERIALIZER.url("group_id", group_id, "str", max_length=90, min_length=1), + "deploymentName": _SERIALIZER.url( + "deployment_name", deployment_name, "str", max_length=64, min_length=1, pattern=r"^[-\w\._\(\)]+$" + ), } _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') - - return HttpRequest( - method="DELETE", - url=_url, - params=_query_parameters, - **kwargs - ) + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") + + return HttpRequest(method="DELETE", url=_url, params=_params, **kwargs) def build_deployments_check_existence_at_management_group_scope_request( - group_id: str, - deployment_name: str, - **kwargs: Any + group_id: str, deployment_name: str, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2019-05-10") # type: str + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + api_version = kwargs.pop("api_version", _params.pop("api-version", "2019-05-10")) # type: str # Construct URL - _url = kwargs.pop("template_url", "/providers/Microsoft.Management/managementGroups/{groupId}/providers/Microsoft.Resources/deployments/{deploymentName}") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", + "/providers/Microsoft.Management/managementGroups/{groupId}/providers/Microsoft.Resources/deployments/{deploymentName}", + ) # pylint: disable=line-too-long path_format_arguments = { - "groupId": _SERIALIZER.url("group_id", group_id, 'str', max_length=90, min_length=1), - "deploymentName": _SERIALIZER.url("deployment_name", deployment_name, 'str', max_length=64, min_length=1, pattern=r'^[-\w\._\(\)]+$'), + "groupId": _SERIALIZER.url("group_id", group_id, "str", max_length=90, min_length=1), + "deploymentName": _SERIALIZER.url( + "deployment_name", deployment_name, "str", max_length=64, min_length=1, pattern=r"^[-\w\._\(\)]+$" + ), } _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') - - return HttpRequest( - method="HEAD", - url=_url, - params=_query_parameters, - **kwargs - ) + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") + return HttpRequest(method="HEAD", url=_url, params=_params, **kwargs) -def build_deployments_create_or_update_at_management_group_scope_request_initial( - group_id: str, - deployment_name: str, - *, - json: JSONType = None, - content: Any = None, - **kwargs: Any + +def build_deployments_create_or_update_at_management_group_scope_request( + group_id: str, deployment_name: str, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2019-05-10") # type: str - content_type = kwargs.pop('content_type', None) # type: Optional[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", "2019-05-10")) # type: str + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + accept = _headers.pop("Accept", "application/json") - accept = "application/json" # Construct URL - _url = kwargs.pop("template_url", "/providers/Microsoft.Management/managementGroups/{groupId}/providers/Microsoft.Resources/deployments/{deploymentName}") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", + "/providers/Microsoft.Management/managementGroups/{groupId}/providers/Microsoft.Resources/deployments/{deploymentName}", + ) # pylint: disable=line-too-long path_format_arguments = { - "groupId": _SERIALIZER.url("group_id", group_id, 'str', max_length=90, min_length=1), - "deploymentName": _SERIALIZER.url("deployment_name", deployment_name, 'str', max_length=64, min_length=1, pattern=r'^[-\w\._\(\)]+$'), + "groupId": _SERIALIZER.url("group_id", group_id, "str", max_length=90, min_length=1), + "deploymentName": _SERIALIZER.url( + "deployment_name", deployment_name, "str", max_length=64, min_length=1, pattern=r"^[-\w\._\(\)]+$" + ), } _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] if content_type is not None: - _header_parameters['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') - _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') - - return HttpRequest( - method="PUT", - url=_url, - params=_query_parameters, - headers=_header_parameters, - json=json, - content=content, - **kwargs - ) + _headers["Content-Type"] = _SERIALIZER.header("content_type", content_type, "str") + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="PUT", url=_url, params=_params, headers=_headers, **kwargs) def build_deployments_get_at_management_group_scope_request( - group_id: str, - deployment_name: str, - **kwargs: Any + group_id: str, deployment_name: str, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2019-05-10") # type: 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", "2019-05-10")) # type: str + accept = _headers.pop("Accept", "application/json") - accept = "application/json" # Construct URL - _url = kwargs.pop("template_url", "/providers/Microsoft.Management/managementGroups/{groupId}/providers/Microsoft.Resources/deployments/{deploymentName}") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", + "/providers/Microsoft.Management/managementGroups/{groupId}/providers/Microsoft.Resources/deployments/{deploymentName}", + ) # pylint: disable=line-too-long path_format_arguments = { - "groupId": _SERIALIZER.url("group_id", group_id, 'str', max_length=90, min_length=1), - "deploymentName": _SERIALIZER.url("deployment_name", deployment_name, 'str', max_length=64, min_length=1, pattern=r'^[-\w\._\(\)]+$'), + "groupId": _SERIALIZER.url("group_id", group_id, "str", max_length=90, min_length=1), + "deploymentName": _SERIALIZER.url( + "deployment_name", deployment_name, "str", max_length=64, min_length=1, pattern=r"^[-\w\._\(\)]+$" + ), } _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') - - return HttpRequest( - method="GET", - url=_url, - params=_query_parameters, - headers=_header_parameters, - **kwargs - ) + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) def build_deployments_cancel_at_management_group_scope_request( - group_id: str, - deployment_name: str, - **kwargs: Any + group_id: str, deployment_name: str, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2019-05-10") # type: str + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + api_version = kwargs.pop("api_version", _params.pop("api-version", "2019-05-10")) # type: str # Construct URL - _url = kwargs.pop("template_url", "/providers/Microsoft.Management/managementGroups/{groupId}/providers/Microsoft.Resources/deployments/{deploymentName}/cancel") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", + "/providers/Microsoft.Management/managementGroups/{groupId}/providers/Microsoft.Resources/deployments/{deploymentName}/cancel", + ) # pylint: disable=line-too-long path_format_arguments = { - "groupId": _SERIALIZER.url("group_id", group_id, 'str', max_length=90, min_length=1), - "deploymentName": _SERIALIZER.url("deployment_name", deployment_name, 'str', max_length=64, min_length=1, pattern=r'^[-\w\._\(\)]+$'), + "groupId": _SERIALIZER.url("group_id", group_id, "str", max_length=90, min_length=1), + "deploymentName": _SERIALIZER.url( + "deployment_name", deployment_name, "str", max_length=64, min_length=1, pattern=r"^[-\w\._\(\)]+$" + ), } _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') - - return HttpRequest( - method="POST", - url=_url, - params=_query_parameters, - **kwargs - ) + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") + + return HttpRequest(method="POST", url=_url, params=_params, **kwargs) def build_deployments_validate_at_management_group_scope_request( - group_id: str, - deployment_name: str, - *, - json: JSONType = None, - content: Any = None, - **kwargs: Any + group_id: str, deployment_name: str, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2019-05-10") # type: str - content_type = kwargs.pop('content_type', None) # type: Optional[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", "2019-05-10")) # type: str + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + accept = _headers.pop("Accept", "application/json") - accept = "application/json" # Construct URL - _url = kwargs.pop("template_url", "/providers/Microsoft.Management/managementGroups/{groupId}/providers/Microsoft.Resources/deployments/{deploymentName}/validate") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", + "/providers/Microsoft.Management/managementGroups/{groupId}/providers/Microsoft.Resources/deployments/{deploymentName}/validate", + ) # pylint: disable=line-too-long path_format_arguments = { - "groupId": _SERIALIZER.url("group_id", group_id, 'str', max_length=90, min_length=1), - "deploymentName": _SERIALIZER.url("deployment_name", deployment_name, 'str', max_length=64, min_length=1, pattern=r'^[-\w\._\(\)]+$'), + "groupId": _SERIALIZER.url("group_id", group_id, "str", max_length=90, min_length=1), + "deploymentName": _SERIALIZER.url( + "deployment_name", deployment_name, "str", max_length=64, min_length=1, pattern=r"^[-\w\._\(\)]+$" + ), } _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] if content_type is not None: - _header_parameters['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') - _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') - - return HttpRequest( - method="POST", - url=_url, - params=_query_parameters, - headers=_header_parameters, - json=json, - content=content, - **kwargs - ) + _headers["Content-Type"] = _SERIALIZER.header("content_type", content_type, "str") + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="POST", url=_url, params=_params, headers=_headers, **kwargs) def build_deployments_export_template_at_management_group_scope_request( - group_id: str, - deployment_name: str, - **kwargs: Any + group_id: str, deployment_name: str, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2019-05-10") # type: 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", "2019-05-10")) # type: str + accept = _headers.pop("Accept", "application/json") - accept = "application/json" # Construct URL - _url = kwargs.pop("template_url", "/providers/Microsoft.Management/managementGroups/{groupId}/providers/Microsoft.Resources/deployments/{deploymentName}/exportTemplate") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", + "/providers/Microsoft.Management/managementGroups/{groupId}/providers/Microsoft.Resources/deployments/{deploymentName}/exportTemplate", + ) # pylint: disable=line-too-long path_format_arguments = { - "groupId": _SERIALIZER.url("group_id", group_id, 'str', max_length=90, min_length=1), - "deploymentName": _SERIALIZER.url("deployment_name", deployment_name, 'str', max_length=64, min_length=1, pattern=r'^[-\w\._\(\)]+$'), + "groupId": _SERIALIZER.url("group_id", group_id, "str", max_length=90, min_length=1), + "deploymentName": _SERIALIZER.url( + "deployment_name", deployment_name, "str", max_length=64, min_length=1, pattern=r"^[-\w\._\(\)]+$" + ), } _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') - - return HttpRequest( - method="POST", - url=_url, - params=_query_parameters, - headers=_header_parameters, - **kwargs - ) + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="POST", url=_url, params=_params, headers=_headers, **kwargs) def build_deployments_list_at_management_group_scope_request( - group_id: str, - *, - filter: Optional[str] = None, - top: Optional[int] = None, - **kwargs: Any + group_id: str, *, filter: Optional[str] = None, top: Optional[int] = None, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2019-05-10") # type: 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", "2019-05-10")) # type: str + accept = _headers.pop("Accept", "application/json") - accept = "application/json" # Construct URL - _url = kwargs.pop("template_url", "/providers/Microsoft.Management/managementGroups/{groupId}/providers/Microsoft.Resources/deployments/") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", + "/providers/Microsoft.Management/managementGroups/{groupId}/providers/Microsoft.Resources/deployments/", + ) # pylint: disable=line-too-long path_format_arguments = { - "groupId": _SERIALIZER.url("group_id", group_id, 'str', max_length=90, min_length=1), + "groupId": _SERIALIZER.url("group_id", group_id, "str", max_length=90, min_length=1), } _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] if filter is not None: - _query_parameters['$filter'] = _SERIALIZER.query("filter", filter, 'str') + _params["$filter"] = _SERIALIZER.query("filter", filter, "str") if top is not None: - _query_parameters['$top'] = _SERIALIZER.query("top", top, 'int') - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["$top"] = _SERIALIZER.query("top", top, "int") + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') - - return HttpRequest( - method="GET", - url=_url, - params=_query_parameters, - headers=_header_parameters, - **kwargs - ) + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) -def build_deployments_delete_at_subscription_scope_request_initial( - deployment_name: str, - subscription_id: str, - **kwargs: Any + +def build_deployments_delete_at_subscription_scope_request( + deployment_name: str, subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2019-05-10") # type: str + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + api_version = kwargs.pop("api_version", _params.pop("api-version", "2019-05-10")) # type: str # Construct URL - _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/providers/Microsoft.Resources/deployments/{deploymentName}") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", "/subscriptions/{subscriptionId}/providers/Microsoft.Resources/deployments/{deploymentName}" + ) # pylint: disable=line-too-long path_format_arguments = { - "deploymentName": _SERIALIZER.url("deployment_name", deployment_name, 'str', max_length=64, min_length=1, pattern=r'^[-\w\._\(\)]+$'), - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), + "deploymentName": _SERIALIZER.url( + "deployment_name", deployment_name, "str", max_length=64, min_length=1, pattern=r"^[-\w\._\(\)]+$" + ), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), } _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') - - return HttpRequest( - method="DELETE", - url=_url, - params=_query_parameters, - **kwargs - ) + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") + + return HttpRequest(method="DELETE", url=_url, params=_params, **kwargs) def build_deployments_check_existence_at_subscription_scope_request( - deployment_name: str, - subscription_id: str, - **kwargs: Any + deployment_name: str, subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2019-05-10") # type: str + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + api_version = kwargs.pop("api_version", _params.pop("api-version", "2019-05-10")) # type: str # Construct URL - _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/providers/Microsoft.Resources/deployments/{deploymentName}") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", "/subscriptions/{subscriptionId}/providers/Microsoft.Resources/deployments/{deploymentName}" + ) # pylint: disable=line-too-long path_format_arguments = { - "deploymentName": _SERIALIZER.url("deployment_name", deployment_name, 'str', max_length=64, min_length=1, pattern=r'^[-\w\._\(\)]+$'), - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), + "deploymentName": _SERIALIZER.url( + "deployment_name", deployment_name, "str", max_length=64, min_length=1, pattern=r"^[-\w\._\(\)]+$" + ), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), } _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') - - return HttpRequest( - method="HEAD", - url=_url, - params=_query_parameters, - **kwargs - ) + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") + return HttpRequest(method="HEAD", url=_url, params=_params, **kwargs) -def build_deployments_create_or_update_at_subscription_scope_request_initial( - deployment_name: str, - subscription_id: str, - *, - json: JSONType = None, - content: Any = None, - **kwargs: Any + +def build_deployments_create_or_update_at_subscription_scope_request( + deployment_name: str, subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2019-05-10") # type: str - content_type = kwargs.pop('content_type', None) # type: Optional[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", "2019-05-10")) # type: str + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + accept = _headers.pop("Accept", "application/json") - accept = "application/json" # Construct URL - _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/providers/Microsoft.Resources/deployments/{deploymentName}") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", "/subscriptions/{subscriptionId}/providers/Microsoft.Resources/deployments/{deploymentName}" + ) # pylint: disable=line-too-long path_format_arguments = { - "deploymentName": _SERIALIZER.url("deployment_name", deployment_name, 'str', max_length=64, min_length=1, pattern=r'^[-\w\._\(\)]+$'), - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), + "deploymentName": _SERIALIZER.url( + "deployment_name", deployment_name, "str", max_length=64, min_length=1, pattern=r"^[-\w\._\(\)]+$" + ), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), } _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] if content_type is not None: - _header_parameters['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') - _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') - - return HttpRequest( - method="PUT", - url=_url, - params=_query_parameters, - headers=_header_parameters, - json=json, - content=content, - **kwargs - ) + _headers["Content-Type"] = _SERIALIZER.header("content_type", content_type, "str") + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="PUT", url=_url, params=_params, headers=_headers, **kwargs) def build_deployments_get_at_subscription_scope_request( - deployment_name: str, - subscription_id: str, - **kwargs: Any + deployment_name: str, subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2019-05-10") # type: 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", "2019-05-10")) # type: str + accept = _headers.pop("Accept", "application/json") - accept = "application/json" # Construct URL - _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/providers/Microsoft.Resources/deployments/{deploymentName}") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", "/subscriptions/{subscriptionId}/providers/Microsoft.Resources/deployments/{deploymentName}" + ) # pylint: disable=line-too-long path_format_arguments = { - "deploymentName": _SERIALIZER.url("deployment_name", deployment_name, 'str', max_length=64, min_length=1, pattern=r'^[-\w\._\(\)]+$'), - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), + "deploymentName": _SERIALIZER.url( + "deployment_name", deployment_name, "str", max_length=64, min_length=1, pattern=r"^[-\w\._\(\)]+$" + ), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), } _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') - - return HttpRequest( - method="GET", - url=_url, - params=_query_parameters, - headers=_header_parameters, - **kwargs - ) + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) def build_deployments_cancel_at_subscription_scope_request( - deployment_name: str, - subscription_id: str, - **kwargs: Any + deployment_name: str, subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2019-05-10") # type: str + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + api_version = kwargs.pop("api_version", _params.pop("api-version", "2019-05-10")) # type: str # Construct URL - _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/providers/Microsoft.Resources/deployments/{deploymentName}/cancel") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/providers/Microsoft.Resources/deployments/{deploymentName}/cancel", + ) # pylint: disable=line-too-long path_format_arguments = { - "deploymentName": _SERIALIZER.url("deployment_name", deployment_name, 'str', max_length=64, min_length=1, pattern=r'^[-\w\._\(\)]+$'), - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), + "deploymentName": _SERIALIZER.url( + "deployment_name", deployment_name, "str", max_length=64, min_length=1, pattern=r"^[-\w\._\(\)]+$" + ), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), } _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') - - return HttpRequest( - method="POST", - url=_url, - params=_query_parameters, - **kwargs - ) + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") + + return HttpRequest(method="POST", url=_url, params=_params, **kwargs) def build_deployments_validate_at_subscription_scope_request( - deployment_name: str, - subscription_id: str, - *, - json: JSONType = None, - content: Any = None, - **kwargs: Any + deployment_name: str, subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2019-05-10") # type: str - content_type = kwargs.pop('content_type', None) # type: Optional[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", "2019-05-10")) # type: str + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + accept = _headers.pop("Accept", "application/json") - accept = "application/json" # Construct URL - _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/providers/Microsoft.Resources/deployments/{deploymentName}/validate") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/providers/Microsoft.Resources/deployments/{deploymentName}/validate", + ) # pylint: disable=line-too-long path_format_arguments = { - "deploymentName": _SERIALIZER.url("deployment_name", deployment_name, 'str', max_length=64, min_length=1, pattern=r'^[-\w\._\(\)]+$'), - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), + "deploymentName": _SERIALIZER.url( + "deployment_name", deployment_name, "str", max_length=64, min_length=1, pattern=r"^[-\w\._\(\)]+$" + ), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), } _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] if content_type is not None: - _header_parameters['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') - _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') - - return HttpRequest( - method="POST", - url=_url, - params=_query_parameters, - headers=_header_parameters, - json=json, - content=content, - **kwargs - ) + _headers["Content-Type"] = _SERIALIZER.header("content_type", content_type, "str") + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="POST", url=_url, params=_params, headers=_headers, **kwargs) def build_deployments_export_template_at_subscription_scope_request( - deployment_name: str, - subscription_id: str, - **kwargs: Any + deployment_name: str, subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2019-05-10") # type: 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", "2019-05-10")) # type: str + accept = _headers.pop("Accept", "application/json") - accept = "application/json" # Construct URL - _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/providers/Microsoft.Resources/deployments/{deploymentName}/exportTemplate") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/providers/Microsoft.Resources/deployments/{deploymentName}/exportTemplate", + ) # pylint: disable=line-too-long path_format_arguments = { - "deploymentName": _SERIALIZER.url("deployment_name", deployment_name, 'str', max_length=64, min_length=1, pattern=r'^[-\w\._\(\)]+$'), - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), + "deploymentName": _SERIALIZER.url( + "deployment_name", deployment_name, "str", max_length=64, min_length=1, pattern=r"^[-\w\._\(\)]+$" + ), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), } _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') - - return HttpRequest( - method="POST", - url=_url, - params=_query_parameters, - headers=_header_parameters, - **kwargs - ) + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="POST", url=_url, params=_params, headers=_headers, **kwargs) def build_deployments_list_at_subscription_scope_request( - subscription_id: str, - *, - filter: Optional[str] = None, - top: Optional[int] = None, - **kwargs: Any + subscription_id: str, *, filter: Optional[str] = None, top: Optional[int] = None, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2019-05-10") # type: 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", "2019-05-10")) # type: str + accept = _headers.pop("Accept", "application/json") - accept = "application/json" # Construct URL _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/providers/Microsoft.Resources/deployments/") path_format_arguments = { - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), } _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] if filter is not None: - _query_parameters['$filter'] = _SERIALIZER.query("filter", filter, 'str') + _params["$filter"] = _SERIALIZER.query("filter", filter, "str") if top is not None: - _query_parameters['$top'] = _SERIALIZER.query("top", top, 'int') - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["$top"] = _SERIALIZER.query("top", top, "int") + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') - - return HttpRequest( - method="GET", - url=_url, - params=_query_parameters, - headers=_header_parameters, - **kwargs - ) + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) -def build_deployments_delete_request_initial( - resource_group_name: str, - deployment_name: str, - subscription_id: str, - **kwargs: Any + +def build_deployments_delete_request( + resource_group_name: str, deployment_name: str, subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2019-05-10") # type: str + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + api_version = kwargs.pop("api_version", _params.pop("api-version", "2019-05-10")) # type: str # Construct URL - _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/Microsoft.Resources/deployments/{deploymentName}") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/Microsoft.Resources/deployments/{deploymentName}", + ) # pylint: disable=line-too-long path_format_arguments = { - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._\(\)]+$'), - "deploymentName": _SERIALIZER.url("deployment_name", deployment_name, 'str', max_length=64, min_length=1, pattern=r'^[-\w\._\(\)]+$'), - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), + "resourceGroupName": _SERIALIZER.url( + "resource_group_name", resource_group_name, "str", max_length=90, min_length=1, pattern=r"^[-\w\._\(\)]+$" + ), + "deploymentName": _SERIALIZER.url( + "deployment_name", deployment_name, "str", max_length=64, min_length=1, pattern=r"^[-\w\._\(\)]+$" + ), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), } _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') - - return HttpRequest( - method="DELETE", - url=_url, - params=_query_parameters, - **kwargs - ) + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") + + return HttpRequest(method="DELETE", url=_url, params=_params, **kwargs) def build_deployments_check_existence_request( - resource_group_name: str, - deployment_name: str, - subscription_id: str, - **kwargs: Any + resource_group_name: str, deployment_name: str, subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2019-05-10") # type: str + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + api_version = kwargs.pop("api_version", _params.pop("api-version", "2019-05-10")) # type: str # Construct URL - _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/Microsoft.Resources/deployments/{deploymentName}") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/Microsoft.Resources/deployments/{deploymentName}", + ) # pylint: disable=line-too-long path_format_arguments = { - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._\(\)]+$'), - "deploymentName": _SERIALIZER.url("deployment_name", deployment_name, 'str', max_length=64, min_length=1, pattern=r'^[-\w\._\(\)]+$'), - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), + "resourceGroupName": _SERIALIZER.url( + "resource_group_name", resource_group_name, "str", max_length=90, min_length=1, pattern=r"^[-\w\._\(\)]+$" + ), + "deploymentName": _SERIALIZER.url( + "deployment_name", deployment_name, "str", max_length=64, min_length=1, pattern=r"^[-\w\._\(\)]+$" + ), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), } _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') - - return HttpRequest( - method="HEAD", - url=_url, - params=_query_parameters, - **kwargs - ) + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") + return HttpRequest(method="HEAD", url=_url, params=_params, **kwargs) -def build_deployments_create_or_update_request_initial( - resource_group_name: str, - deployment_name: str, - subscription_id: str, - *, - json: JSONType = None, - content: Any = None, - **kwargs: Any + +def build_deployments_create_or_update_request( + resource_group_name: str, deployment_name: str, subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2019-05-10") # type: str - content_type = kwargs.pop('content_type', None) # type: Optional[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", "2019-05-10")) # type: str + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + accept = _headers.pop("Accept", "application/json") - accept = "application/json" # Construct URL - _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/Microsoft.Resources/deployments/{deploymentName}") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/Microsoft.Resources/deployments/{deploymentName}", + ) # pylint: disable=line-too-long path_format_arguments = { - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._\(\)]+$'), - "deploymentName": _SERIALIZER.url("deployment_name", deployment_name, 'str', max_length=64, min_length=1, pattern=r'^[-\w\._\(\)]+$'), - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), + "resourceGroupName": _SERIALIZER.url( + "resource_group_name", resource_group_name, "str", max_length=90, min_length=1, pattern=r"^[-\w\._\(\)]+$" + ), + "deploymentName": _SERIALIZER.url( + "deployment_name", deployment_name, "str", max_length=64, min_length=1, pattern=r"^[-\w\._\(\)]+$" + ), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), } _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] if content_type is not None: - _header_parameters['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') - _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') - - return HttpRequest( - method="PUT", - url=_url, - params=_query_parameters, - headers=_header_parameters, - json=json, - content=content, - **kwargs - ) + _headers["Content-Type"] = _SERIALIZER.header("content_type", content_type, "str") + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="PUT", url=_url, params=_params, headers=_headers, **kwargs) def build_deployments_get_request( - resource_group_name: str, - deployment_name: str, - subscription_id: str, - **kwargs: Any + resource_group_name: str, deployment_name: str, subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2019-05-10") # type: 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", "2019-05-10")) # type: str + accept = _headers.pop("Accept", "application/json") - accept = "application/json" # Construct URL - _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/Microsoft.Resources/deployments/{deploymentName}") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/Microsoft.Resources/deployments/{deploymentName}", + ) # pylint: disable=line-too-long path_format_arguments = { - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._\(\)]+$'), - "deploymentName": _SERIALIZER.url("deployment_name", deployment_name, 'str', max_length=64, min_length=1, pattern=r'^[-\w\._\(\)]+$'), - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), + "resourceGroupName": _SERIALIZER.url( + "resource_group_name", resource_group_name, "str", max_length=90, min_length=1, pattern=r"^[-\w\._\(\)]+$" + ), + "deploymentName": _SERIALIZER.url( + "deployment_name", deployment_name, "str", max_length=64, min_length=1, pattern=r"^[-\w\._\(\)]+$" + ), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), } _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') - - return HttpRequest( - method="GET", - url=_url, - params=_query_parameters, - headers=_header_parameters, - **kwargs - ) + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) def build_deployments_cancel_request( - resource_group_name: str, - deployment_name: str, - subscription_id: str, - **kwargs: Any + resource_group_name: str, deployment_name: str, subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2019-05-10") # type: str + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + api_version = kwargs.pop("api_version", _params.pop("api-version", "2019-05-10")) # type: str # Construct URL - _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/Microsoft.Resources/deployments/{deploymentName}/cancel") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/Microsoft.Resources/deployments/{deploymentName}/cancel", + ) # pylint: disable=line-too-long path_format_arguments = { - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._\(\)]+$'), - "deploymentName": _SERIALIZER.url("deployment_name", deployment_name, 'str', max_length=64, min_length=1, pattern=r'^[-\w\._\(\)]+$'), - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), + "resourceGroupName": _SERIALIZER.url( + "resource_group_name", resource_group_name, "str", max_length=90, min_length=1, pattern=r"^[-\w\._\(\)]+$" + ), + "deploymentName": _SERIALIZER.url( + "deployment_name", deployment_name, "str", max_length=64, min_length=1, pattern=r"^[-\w\._\(\)]+$" + ), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), } _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') - - return HttpRequest( - method="POST", - url=_url, - params=_query_parameters, - **kwargs - ) + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") + + return HttpRequest(method="POST", url=_url, params=_params, **kwargs) def build_deployments_validate_request( - resource_group_name: str, - deployment_name: str, - subscription_id: str, - *, - json: JSONType = None, - content: Any = None, - **kwargs: Any + resource_group_name: str, deployment_name: str, subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2019-05-10") # type: str - content_type = kwargs.pop('content_type', None) # type: Optional[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", "2019-05-10")) # type: str + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + accept = _headers.pop("Accept", "application/json") - accept = "application/json" # Construct URL - _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/Microsoft.Resources/deployments/{deploymentName}/validate") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/Microsoft.Resources/deployments/{deploymentName}/validate", + ) # pylint: disable=line-too-long path_format_arguments = { - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._\(\)]+$'), - "deploymentName": _SERIALIZER.url("deployment_name", deployment_name, 'str', max_length=64, min_length=1, pattern=r'^[-\w\._\(\)]+$'), - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), + "resourceGroupName": _SERIALIZER.url( + "resource_group_name", resource_group_name, "str", max_length=90, min_length=1, pattern=r"^[-\w\._\(\)]+$" + ), + "deploymentName": _SERIALIZER.url( + "deployment_name", deployment_name, "str", max_length=64, min_length=1, pattern=r"^[-\w\._\(\)]+$" + ), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), } _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] if content_type is not None: - _header_parameters['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') - _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') - - return HttpRequest( - method="POST", - url=_url, - params=_query_parameters, - headers=_header_parameters, - json=json, - content=content, - **kwargs - ) + _headers["Content-Type"] = _SERIALIZER.header("content_type", content_type, "str") + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="POST", url=_url, params=_params, headers=_headers, **kwargs) def build_deployments_export_template_request( - resource_group_name: str, - deployment_name: str, - subscription_id: str, - **kwargs: Any + resource_group_name: str, deployment_name: str, subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2019-05-10") # type: 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", "2019-05-10")) # type: str + accept = _headers.pop("Accept", "application/json") - accept = "application/json" # Construct URL - _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/Microsoft.Resources/deployments/{deploymentName}/exportTemplate") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/Microsoft.Resources/deployments/{deploymentName}/exportTemplate", + ) # pylint: disable=line-too-long path_format_arguments = { - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._\(\)]+$'), - "deploymentName": _SERIALIZER.url("deployment_name", deployment_name, 'str', max_length=64, min_length=1, pattern=r'^[-\w\._\(\)]+$'), - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), + "resourceGroupName": _SERIALIZER.url( + "resource_group_name", resource_group_name, "str", max_length=90, min_length=1, pattern=r"^[-\w\._\(\)]+$" + ), + "deploymentName": _SERIALIZER.url( + "deployment_name", deployment_name, "str", max_length=64, min_length=1, pattern=r"^[-\w\._\(\)]+$" + ), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), } _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') - - return HttpRequest( - method="POST", - url=_url, - params=_query_parameters, - headers=_header_parameters, - **kwargs - ) + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="POST", url=_url, params=_params, headers=_headers, **kwargs) def build_deployments_list_by_resource_group_request( @@ -863,285 +787,227 @@ def build_deployments_list_by_resource_group_request( top: Optional[int] = None, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2019-05-10") # type: 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", "2019-05-10")) # type: str + accept = _headers.pop("Accept", "application/json") - accept = "application/json" # Construct URL - _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/Microsoft.Resources/deployments/") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/Microsoft.Resources/deployments/", + ) # pylint: disable=line-too-long path_format_arguments = { - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._\(\)]+$'), - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), + "resourceGroupName": _SERIALIZER.url( + "resource_group_name", resource_group_name, "str", max_length=90, min_length=1, pattern=r"^[-\w\._\(\)]+$" + ), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), } _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] if filter is not None: - _query_parameters['$filter'] = _SERIALIZER.query("filter", filter, 'str') + _params["$filter"] = _SERIALIZER.query("filter", filter, "str") if top is not None: - _query_parameters['$top'] = _SERIALIZER.query("top", top, 'int') - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["$top"] = _SERIALIZER.query("top", top, "int") + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') - - return HttpRequest( - method="GET", - url=_url, - params=_query_parameters, - headers=_header_parameters, - **kwargs - ) + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) -def build_deployments_calculate_template_hash_request( - *, - json: JSONType = None, - content: Any = None, - **kwargs: Any -) -> HttpRequest: - api_version = kwargs.pop('api_version', "2019-05-10") # type: str - content_type = kwargs.pop('content_type', None) # type: Optional[str] - accept = "application/json" +def build_deployments_calculate_template_hash_request(*, json: JSON, **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", "2019-05-10")) # type: str + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + accept = _headers.pop("Accept", "application/json") + # Construct URL _url = kwargs.pop("template_url", "/providers/Microsoft.Resources/calculateTemplateHash") # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] if content_type is not None: - _header_parameters['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') - _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') - - return HttpRequest( - method="POST", - url=_url, - params=_query_parameters, - headers=_header_parameters, - json=json, - content=content, - **kwargs - ) + _headers["Content-Type"] = _SERIALIZER.header("content_type", content_type, "str") + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="POST", url=_url, params=_params, headers=_headers, json=json, **kwargs) def build_providers_unregister_request( - resource_provider_namespace: str, - subscription_id: str, - **kwargs: Any + resource_provider_namespace: str, subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2019-05-10") # type: 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", "2019-05-10")) # type: str + accept = _headers.pop("Accept", "application/json") - accept = "application/json" # Construct URL - _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/providers/{resourceProviderNamespace}/unregister") + _url = kwargs.pop( + "template_url", "/subscriptions/{subscriptionId}/providers/{resourceProviderNamespace}/unregister" + ) path_format_arguments = { - "resourceProviderNamespace": _SERIALIZER.url("resource_provider_namespace", resource_provider_namespace, 'str'), - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), + "resourceProviderNamespace": _SERIALIZER.url("resource_provider_namespace", resource_provider_namespace, "str"), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), } _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') - - return HttpRequest( - method="POST", - url=_url, - params=_query_parameters, - headers=_header_parameters, - **kwargs - ) + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="POST", url=_url, params=_params, headers=_headers, **kwargs) def build_providers_register_request( - resource_provider_namespace: str, - subscription_id: str, - **kwargs: Any + resource_provider_namespace: str, subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2019-05-10") # type: 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", "2019-05-10")) # type: str + accept = _headers.pop("Accept", "application/json") - accept = "application/json" # Construct URL _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/providers/{resourceProviderNamespace}/register") path_format_arguments = { - "resourceProviderNamespace": _SERIALIZER.url("resource_provider_namespace", resource_provider_namespace, 'str'), - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), + "resourceProviderNamespace": _SERIALIZER.url("resource_provider_namespace", resource_provider_namespace, "str"), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), } _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') - - return HttpRequest( - method="POST", - url=_url, - params=_query_parameters, - headers=_header_parameters, - **kwargs - ) + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="POST", url=_url, params=_params, headers=_headers, **kwargs) def build_providers_list_request( - subscription_id: str, - *, - top: Optional[int] = None, - expand: Optional[str] = None, - **kwargs: Any + subscription_id: str, *, top: Optional[int] = None, expand: Optional[str] = None, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2019-05-10") # type: 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", "2019-05-10")) # type: str + accept = _headers.pop("Accept", "application/json") - accept = "application/json" # Construct URL _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/providers") path_format_arguments = { - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), } _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] if top is not None: - _query_parameters['$top'] = _SERIALIZER.query("top", top, 'int') + _params["$top"] = _SERIALIZER.query("top", top, "int") if expand is not None: - _query_parameters['$expand'] = _SERIALIZER.query("expand", expand, 'str') - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["$expand"] = _SERIALIZER.query("expand", expand, "str") + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') - - return HttpRequest( - method="GET", - url=_url, - params=_query_parameters, - headers=_header_parameters, - **kwargs - ) + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) def build_providers_list_at_tenant_scope_request( - *, - top: Optional[int] = None, - expand: Optional[str] = None, - **kwargs: Any + *, top: Optional[int] = None, expand: Optional[str] = None, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2019-05-10") # type: 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", "2019-05-10")) # type: str + accept = _headers.pop("Accept", "application/json") - accept = "application/json" # Construct URL _url = kwargs.pop("template_url", "/providers") # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] if top is not None: - _query_parameters['$top'] = _SERIALIZER.query("top", top, 'int') + _params["$top"] = _SERIALIZER.query("top", top, "int") if expand is not None: - _query_parameters['$expand'] = _SERIALIZER.query("expand", expand, 'str') - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["$expand"] = _SERIALIZER.query("expand", expand, "str") + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') - - return HttpRequest( - method="GET", - url=_url, - params=_query_parameters, - headers=_header_parameters, - **kwargs - ) + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) def build_providers_get_request( - resource_provider_namespace: str, - subscription_id: str, - *, - expand: Optional[str] = None, - **kwargs: Any + resource_provider_namespace: str, subscription_id: str, *, expand: Optional[str] = None, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2019-05-10") # type: 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", "2019-05-10")) # type: str + accept = _headers.pop("Accept", "application/json") - accept = "application/json" # Construct URL _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/providers/{resourceProviderNamespace}") path_format_arguments = { - "resourceProviderNamespace": _SERIALIZER.url("resource_provider_namespace", resource_provider_namespace, 'str'), - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), + "resourceProviderNamespace": _SERIALIZER.url("resource_provider_namespace", resource_provider_namespace, "str"), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), } _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] if expand is not None: - _query_parameters['$expand'] = _SERIALIZER.query("expand", expand, 'str') - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["$expand"] = _SERIALIZER.query("expand", expand, "str") + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') - - return HttpRequest( - method="GET", - url=_url, - params=_query_parameters, - headers=_header_parameters, - **kwargs - ) + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) def build_providers_get_at_tenant_scope_request( - resource_provider_namespace: str, - *, - expand: Optional[str] = None, - **kwargs: Any + resource_provider_namespace: str, *, expand: Optional[str] = None, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2019-05-10") # type: 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", "2019-05-10")) # type: str + accept = _headers.pop("Accept", "application/json") - accept = "application/json" # Construct URL _url = kwargs.pop("template_url", "/providers/{resourceProviderNamespace}") path_format_arguments = { - "resourceProviderNamespace": _SERIALIZER.url("resource_provider_namespace", resource_provider_namespace, 'str'), + "resourceProviderNamespace": _SERIALIZER.url("resource_provider_namespace", resource_provider_namespace, "str"), } _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] if expand is not None: - _query_parameters['$expand'] = _SERIALIZER.query("expand", expand, 'str') - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["$expand"] = _SERIALIZER.query("expand", expand, "str") + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') - - return HttpRequest( - method="GET", - url=_url, - params=_query_parameters, - headers=_header_parameters, - **kwargs - ) + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) def build_resources_list_by_resource_group_request( @@ -1153,119 +1019,108 @@ def build_resources_list_by_resource_group_request( top: Optional[int] = None, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2019-05-10") # type: 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", "2019-05-10")) # type: str + accept = _headers.pop("Accept", "application/json") - accept = "application/json" # Construct URL _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/resources") path_format_arguments = { - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._\(\)]+$'), - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), + "resourceGroupName": _SERIALIZER.url( + "resource_group_name", resource_group_name, "str", max_length=90, min_length=1, pattern=r"^[-\w\._\(\)]+$" + ), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), } _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] if filter is not None: - _query_parameters['$filter'] = _SERIALIZER.query("filter", filter, 'str') + _params["$filter"] = _SERIALIZER.query("filter", filter, "str") if expand is not None: - _query_parameters['$expand'] = _SERIALIZER.query("expand", expand, 'str') + _params["$expand"] = _SERIALIZER.query("expand", expand, "str") if top is not None: - _query_parameters['$top'] = _SERIALIZER.query("top", top, 'int') - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["$top"] = _SERIALIZER.query("top", top, "int") + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') - - return HttpRequest( - method="GET", - url=_url, - params=_query_parameters, - headers=_header_parameters, - **kwargs - ) + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) -def build_resources_move_resources_request_initial( - source_resource_group_name: str, - subscription_id: str, - *, - json: JSONType = None, - content: Any = None, - **kwargs: Any + +def build_resources_move_resources_request( + source_resource_group_name: str, subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2019-05-10") # type: str - content_type = kwargs.pop('content_type', None) # type: Optional[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", "2019-05-10")) # type: str + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] # Construct URL - _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{sourceResourceGroupName}/moveResources") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", "/subscriptions/{subscriptionId}/resourceGroups/{sourceResourceGroupName}/moveResources" + ) # pylint: disable=line-too-long path_format_arguments = { - "sourceResourceGroupName": _SERIALIZER.url("source_resource_group_name", source_resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._\(\)]+$'), - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), + "sourceResourceGroupName": _SERIALIZER.url( + "source_resource_group_name", + source_resource_group_name, + "str", + max_length=90, + min_length=1, + pattern=r"^[-\w\._\(\)]+$", + ), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), } _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] if content_type is not None: - _header_parameters['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') - - return HttpRequest( - method="POST", - url=_url, - params=_query_parameters, - headers=_header_parameters, - json=json, - content=content, - **kwargs - ) + _headers["Content-Type"] = _SERIALIZER.header("content_type", content_type, "str") + return HttpRequest(method="POST", url=_url, params=_params, headers=_headers, **kwargs) -def build_resources_validate_move_resources_request_initial( - source_resource_group_name: str, - subscription_id: str, - *, - json: JSONType = None, - content: Any = None, - **kwargs: Any + +def build_resources_validate_move_resources_request( + source_resource_group_name: str, subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2019-05-10") # type: str - content_type = kwargs.pop('content_type', None) # type: Optional[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", "2019-05-10")) # type: str + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] # Construct URL - _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{sourceResourceGroupName}/validateMoveResources") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", "/subscriptions/{subscriptionId}/resourceGroups/{sourceResourceGroupName}/validateMoveResources" + ) # pylint: disable=line-too-long path_format_arguments = { - "sourceResourceGroupName": _SERIALIZER.url("source_resource_group_name", source_resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._\(\)]+$'), - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), + "sourceResourceGroupName": _SERIALIZER.url( + "source_resource_group_name", + source_resource_group_name, + "str", + max_length=90, + min_length=1, + pattern=r"^[-\w\._\(\)]+$", + ), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), } _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] if content_type is not None: - _header_parameters['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') - - return HttpRequest( - method="POST", - url=_url, - params=_query_parameters, - headers=_header_parameters, - json=json, - content=content, - **kwargs - ) + _headers["Content-Type"] = _SERIALIZER.header("content_type", content_type, "str") + + return HttpRequest(method="POST", url=_url, params=_params, headers=_headers, **kwargs) def build_resources_list_request( @@ -1276,38 +1131,33 @@ def build_resources_list_request( top: Optional[int] = None, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2019-05-10") # type: 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", "2019-05-10")) # type: str + accept = _headers.pop("Accept", "application/json") - accept = "application/json" # Construct URL _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resources") path_format_arguments = { - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), } _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] if filter is not None: - _query_parameters['$filter'] = _SERIALIZER.query("filter", filter, 'str') + _params["$filter"] = _SERIALIZER.query("filter", filter, "str") if expand is not None: - _query_parameters['$expand'] = _SERIALIZER.query("expand", expand, 'str') + _params["$expand"] = _SERIALIZER.query("expand", expand, "str") if top is not None: - _query_parameters['$top'] = _SERIALIZER.query("top", top, 'int') - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["$top"] = _SERIALIZER.query("top", top, "int") + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') - - return HttpRequest( - method="GET", - url=_url, - params=_query_parameters, - headers=_header_parameters, - **kwargs - ) + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) def build_resources_check_existence_request( @@ -1321,32 +1171,33 @@ def build_resources_check_existence_request( api_version: str, **kwargs: Any ) -> HttpRequest: + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + # Construct URL - _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{parentResourcePath}/{resourceType}/{resourceName}") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{parentResourcePath}/{resourceType}/{resourceName}", + ) # pylint: disable=line-too-long path_format_arguments = { - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._\(\)]+$'), - "resourceProviderNamespace": _SERIALIZER.url("resource_provider_namespace", resource_provider_namespace, 'str'), - "parentResourcePath": _SERIALIZER.url("parent_resource_path", parent_resource_path, 'str', skip_quote=True), - "resourceType": _SERIALIZER.url("resource_type", resource_type, 'str', skip_quote=True), - "resourceName": _SERIALIZER.url("resource_name", resource_name, 'str'), - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), + "resourceGroupName": _SERIALIZER.url( + "resource_group_name", resource_group_name, "str", max_length=90, min_length=1, pattern=r"^[-\w\._\(\)]+$" + ), + "resourceProviderNamespace": _SERIALIZER.url("resource_provider_namespace", resource_provider_namespace, "str"), + "parentResourcePath": _SERIALIZER.url("parent_resource_path", parent_resource_path, "str", skip_quote=True), + "resourceType": _SERIALIZER.url("resource_type", resource_type, "str", skip_quote=True), + "resourceName": _SERIALIZER.url("resource_name", resource_name, "str"), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), } _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') - - return HttpRequest( - method="HEAD", - url=_url, - params=_query_parameters, - **kwargs - ) + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") + return HttpRequest(method="HEAD", url=_url, params=_params, **kwargs) -def build_resources_delete_request_initial( + +def build_resources_delete_request( resource_group_name: str, resource_provider_namespace: str, parent_resource_path: str, @@ -1357,32 +1208,33 @@ def build_resources_delete_request_initial( api_version: str, **kwargs: Any ) -> HttpRequest: + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + # Construct URL - _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{parentResourcePath}/{resourceType}/{resourceName}") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{parentResourcePath}/{resourceType}/{resourceName}", + ) # pylint: disable=line-too-long path_format_arguments = { - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._\(\)]+$'), - "resourceProviderNamespace": _SERIALIZER.url("resource_provider_namespace", resource_provider_namespace, 'str'), - "parentResourcePath": _SERIALIZER.url("parent_resource_path", parent_resource_path, 'str', skip_quote=True), - "resourceType": _SERIALIZER.url("resource_type", resource_type, 'str', skip_quote=True), - "resourceName": _SERIALIZER.url("resource_name", resource_name, 'str'), - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), + "resourceGroupName": _SERIALIZER.url( + "resource_group_name", resource_group_name, "str", max_length=90, min_length=1, pattern=r"^[-\w\._\(\)]+$" + ), + "resourceProviderNamespace": _SERIALIZER.url("resource_provider_namespace", resource_provider_namespace, "str"), + "parentResourcePath": _SERIALIZER.url("parent_resource_path", parent_resource_path, "str", skip_quote=True), + "resourceType": _SERIALIZER.url("resource_type", resource_type, "str", skip_quote=True), + "resourceName": _SERIALIZER.url("resource_name", resource_name, "str"), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), } _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') - - return HttpRequest( - method="DELETE", - url=_url, - params=_query_parameters, - **kwargs - ) + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") + + return HttpRequest(method="DELETE", url=_url, params=_params, **kwargs) -def build_resources_create_or_update_request_initial( +def build_resources_create_or_update_request( resource_group_name: str, resource_provider_namespace: str, parent_resource_path: str, @@ -1391,48 +1243,44 @@ def build_resources_create_or_update_request_initial( subscription_id: str, *, api_version: str, - json: JSONType = None, - content: Any = None, **kwargs: Any ) -> HttpRequest: - content_type = kwargs.pop('content_type', None) # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + accept = _headers.pop("Accept", "application/json") - accept = "application/json" # Construct URL - _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{parentResourcePath}/{resourceType}/{resourceName}") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{parentResourcePath}/{resourceType}/{resourceName}", + ) # pylint: disable=line-too-long path_format_arguments = { - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._\(\)]+$'), - "resourceProviderNamespace": _SERIALIZER.url("resource_provider_namespace", resource_provider_namespace, 'str'), - "parentResourcePath": _SERIALIZER.url("parent_resource_path", parent_resource_path, 'str', skip_quote=True), - "resourceType": _SERIALIZER.url("resource_type", resource_type, 'str', skip_quote=True), - "resourceName": _SERIALIZER.url("resource_name", resource_name, 'str'), - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), + "resourceGroupName": _SERIALIZER.url( + "resource_group_name", resource_group_name, "str", max_length=90, min_length=1, pattern=r"^[-\w\._\(\)]+$" + ), + "resourceProviderNamespace": _SERIALIZER.url("resource_provider_namespace", resource_provider_namespace, "str"), + "parentResourcePath": _SERIALIZER.url("parent_resource_path", parent_resource_path, "str", skip_quote=True), + "resourceType": _SERIALIZER.url("resource_type", resource_type, "str", skip_quote=True), + "resourceName": _SERIALIZER.url("resource_name", resource_name, "str"), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), } _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] if content_type is not None: - _header_parameters['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') - _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') - - return HttpRequest( - method="PUT", - url=_url, - params=_query_parameters, - headers=_header_parameters, - json=json, - content=content, - **kwargs - ) + _headers["Content-Type"] = _SERIALIZER.header("content_type", content_type, "str") + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + return HttpRequest(method="PUT", url=_url, params=_params, headers=_headers, **kwargs) -def build_resources_update_request_initial( + +def build_resources_update_request( resource_group_name: str, resource_provider_namespace: str, parent_resource_path: str, @@ -1441,45 +1289,41 @@ def build_resources_update_request_initial( subscription_id: str, *, api_version: str, - json: JSONType = None, - content: Any = None, **kwargs: Any ) -> HttpRequest: - content_type = kwargs.pop('content_type', None) # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + accept = _headers.pop("Accept", "application/json") - accept = "application/json" # Construct URL - _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{parentResourcePath}/{resourceType}/{resourceName}") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{parentResourcePath}/{resourceType}/{resourceName}", + ) # pylint: disable=line-too-long path_format_arguments = { - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._\(\)]+$'), - "resourceProviderNamespace": _SERIALIZER.url("resource_provider_namespace", resource_provider_namespace, 'str'), - "parentResourcePath": _SERIALIZER.url("parent_resource_path", parent_resource_path, 'str', skip_quote=True), - "resourceType": _SERIALIZER.url("resource_type", resource_type, 'str', skip_quote=True), - "resourceName": _SERIALIZER.url("resource_name", resource_name, 'str'), - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), + "resourceGroupName": _SERIALIZER.url( + "resource_group_name", resource_group_name, "str", max_length=90, min_length=1, pattern=r"^[-\w\._\(\)]+$" + ), + "resourceProviderNamespace": _SERIALIZER.url("resource_provider_namespace", resource_provider_namespace, "str"), + "parentResourcePath": _SERIALIZER.url("parent_resource_path", parent_resource_path, "str", skip_quote=True), + "resourceType": _SERIALIZER.url("resource_type", resource_type, "str", skip_quote=True), + "resourceName": _SERIALIZER.url("resource_name", resource_name, "str"), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), } _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] if content_type is not None: - _header_parameters['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') - _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') - - return HttpRequest( - method="PATCH", - url=_url, - params=_query_parameters, - headers=_header_parameters, - json=json, - content=content, - **kwargs - ) + _headers["Content-Type"] = _SERIALIZER.header("content_type", content_type, "str") + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="PATCH", url=_url, params=_params, headers=_headers, **kwargs) def build_resources_get_request( @@ -1493,900 +1337,730 @@ def build_resources_get_request( api_version: str, **kwargs: Any ) -> HttpRequest: - accept = "application/json" + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + accept = _headers.pop("Accept", "application/json") + # Construct URL - _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{parentResourcePath}/{resourceType}/{resourceName}") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{parentResourcePath}/{resourceType}/{resourceName}", + ) # pylint: disable=line-too-long path_format_arguments = { - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._\(\)]+$'), - "resourceProviderNamespace": _SERIALIZER.url("resource_provider_namespace", resource_provider_namespace, 'str'), - "parentResourcePath": _SERIALIZER.url("parent_resource_path", parent_resource_path, 'str', skip_quote=True), - "resourceType": _SERIALIZER.url("resource_type", resource_type, 'str', skip_quote=True), - "resourceName": _SERIALIZER.url("resource_name", resource_name, 'str'), - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), + "resourceGroupName": _SERIALIZER.url( + "resource_group_name", resource_group_name, "str", max_length=90, min_length=1, pattern=r"^[-\w\._\(\)]+$" + ), + "resourceProviderNamespace": _SERIALIZER.url("resource_provider_namespace", resource_provider_namespace, "str"), + "parentResourcePath": _SERIALIZER.url("parent_resource_path", parent_resource_path, "str", skip_quote=True), + "resourceType": _SERIALIZER.url("resource_type", resource_type, "str", skip_quote=True), + "resourceName": _SERIALIZER.url("resource_name", resource_name, "str"), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), } _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') - - return HttpRequest( - method="GET", - url=_url, - params=_query_parameters, - headers=_header_parameters, - **kwargs - ) + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) + + +def build_resources_check_existence_by_id_request(resource_id: str, *, api_version: str, **kwargs: Any) -> HttpRequest: + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) -def build_resources_check_existence_by_id_request( - resource_id: str, - *, - api_version: str, - **kwargs: Any -) -> HttpRequest: # Construct URL _url = kwargs.pop("template_url", "/{resourceId}") path_format_arguments = { - "resourceId": _SERIALIZER.url("resource_id", resource_id, 'str', skip_quote=True), + "resourceId": _SERIALIZER.url("resource_id", resource_id, "str", skip_quote=True), } _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') - - return HttpRequest( - method="HEAD", - url=_url, - params=_query_parameters, - **kwargs - ) + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") + return HttpRequest(method="HEAD", url=_url, params=_params, **kwargs) + + +def build_resources_delete_by_id_request(resource_id: str, *, api_version: str, **kwargs: Any) -> HttpRequest: + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) -def build_resources_delete_by_id_request_initial( - resource_id: str, - *, - api_version: str, - **kwargs: Any -) -> HttpRequest: # Construct URL _url = kwargs.pop("template_url", "/{resourceId}") path_format_arguments = { - "resourceId": _SERIALIZER.url("resource_id", resource_id, 'str', skip_quote=True), + "resourceId": _SERIALIZER.url("resource_id", resource_id, "str", skip_quote=True), } _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') - - return HttpRequest( - method="DELETE", - url=_url, - params=_query_parameters, - **kwargs - ) + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") + return HttpRequest(method="DELETE", url=_url, params=_params, **kwargs) -def build_resources_create_or_update_by_id_request_initial( - resource_id: str, - *, - api_version: str, - json: JSONType = None, - content: Any = None, - **kwargs: Any -) -> HttpRequest: - content_type = kwargs.pop('content_type', None) # type: Optional[str] - accept = "application/json" +def build_resources_create_or_update_by_id_request(resource_id: str, *, api_version: str, **kwargs: Any) -> HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + accept = _headers.pop("Accept", "application/json") + # Construct URL _url = kwargs.pop("template_url", "/{resourceId}") path_format_arguments = { - "resourceId": _SERIALIZER.url("resource_id", resource_id, 'str', skip_quote=True), + "resourceId": _SERIALIZER.url("resource_id", resource_id, "str", skip_quote=True), } _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] if content_type is not None: - _header_parameters['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') - _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') - - return HttpRequest( - method="PUT", - url=_url, - params=_query_parameters, - headers=_header_parameters, - json=json, - content=content, - **kwargs - ) + _headers["Content-Type"] = _SERIALIZER.header("content_type", content_type, "str") + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + return HttpRequest(method="PUT", url=_url, params=_params, headers=_headers, **kwargs) -def build_resources_update_by_id_request_initial( - resource_id: str, - *, - api_version: str, - json: JSONType = None, - content: Any = None, - **kwargs: Any -) -> HttpRequest: - content_type = kwargs.pop('content_type', None) # type: Optional[str] - accept = "application/json" +def build_resources_update_by_id_request(resource_id: str, *, api_version: str, **kwargs: Any) -> HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + accept = _headers.pop("Accept", "application/json") + # Construct URL _url = kwargs.pop("template_url", "/{resourceId}") path_format_arguments = { - "resourceId": _SERIALIZER.url("resource_id", resource_id, 'str', skip_quote=True), + "resourceId": _SERIALIZER.url("resource_id", resource_id, "str", skip_quote=True), } _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] if content_type is not None: - _header_parameters['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') - _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') - - return HttpRequest( - method="PATCH", - url=_url, - params=_query_parameters, - headers=_header_parameters, - json=json, - content=content, - **kwargs - ) + _headers["Content-Type"] = _SERIALIZER.header("content_type", content_type, "str") + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + return HttpRequest(method="PATCH", url=_url, params=_params, headers=_headers, **kwargs) + + +def build_resources_get_by_id_request(resource_id: str, *, api_version: str, **kwargs: Any) -> HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + accept = _headers.pop("Accept", "application/json") -def build_resources_get_by_id_request( - resource_id: str, - *, - api_version: str, - **kwargs: Any -) -> HttpRequest: - accept = "application/json" # Construct URL _url = kwargs.pop("template_url", "/{resourceId}") path_format_arguments = { - "resourceId": _SERIALIZER.url("resource_id", resource_id, 'str', skip_quote=True), + "resourceId": _SERIALIZER.url("resource_id", resource_id, "str", skip_quote=True), } _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') - - return HttpRequest( - method="GET", - url=_url, - params=_query_parameters, - headers=_header_parameters, - **kwargs - ) + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) def build_resource_groups_check_existence_request( - resource_group_name: str, - subscription_id: str, - **kwargs: Any + resource_group_name: str, subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2019-05-10") # type: str + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + api_version = kwargs.pop("api_version", _params.pop("api-version", "2019-05-10")) # type: str # Construct URL _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}") path_format_arguments = { - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._\(\)]+$'), - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), + "resourceGroupName": _SERIALIZER.url( + "resource_group_name", resource_group_name, "str", max_length=90, min_length=1, pattern=r"^[-\w\._\(\)]+$" + ), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), } _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') - - return HttpRequest( - method="HEAD", - url=_url, - params=_query_parameters, - **kwargs - ) + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") + + return HttpRequest(method="HEAD", url=_url, params=_params, **kwargs) def build_resource_groups_create_or_update_request( - resource_group_name: str, - subscription_id: str, - *, - json: JSONType = None, - content: Any = None, - **kwargs: Any + resource_group_name: str, subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2019-05-10") # type: str - content_type = kwargs.pop('content_type', None) # type: Optional[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", "2019-05-10")) # type: str + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + accept = _headers.pop("Accept", "application/json") - accept = "application/json" # Construct URL _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}") path_format_arguments = { - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._\(\)]+$'), - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), + "resourceGroupName": _SERIALIZER.url( + "resource_group_name", resource_group_name, "str", max_length=90, min_length=1, pattern=r"^[-\w\._\(\)]+$" + ), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), } _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] if content_type is not None: - _header_parameters['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') - _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') - - return HttpRequest( - method="PUT", - url=_url, - params=_query_parameters, - headers=_header_parameters, - json=json, - content=content, - **kwargs - ) + _headers["Content-Type"] = _SERIALIZER.header("content_type", content_type, "str") + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + return HttpRequest(method="PUT", url=_url, params=_params, headers=_headers, **kwargs) -def build_resource_groups_delete_request_initial( - resource_group_name: str, - subscription_id: str, - **kwargs: Any -) -> HttpRequest: - api_version = kwargs.pop('api_version', "2019-05-10") # type: str +def build_resource_groups_delete_request(resource_group_name: str, subscription_id: str, **kwargs: Any) -> HttpRequest: + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2019-05-10")) # type: str # Construct URL _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}") path_format_arguments = { - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._\(\)]+$'), - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), + "resourceGroupName": _SERIALIZER.url( + "resource_group_name", resource_group_name, "str", max_length=90, min_length=1, pattern=r"^[-\w\._\(\)]+$" + ), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), } _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') - - return HttpRequest( - method="DELETE", - url=_url, - params=_query_parameters, - **kwargs - ) + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") + return HttpRequest(method="DELETE", url=_url, params=_params, **kwargs) -def build_resource_groups_get_request( - resource_group_name: str, - subscription_id: str, - **kwargs: Any -) -> HttpRequest: - api_version = kwargs.pop('api_version', "2019-05-10") # type: str - accept = "application/json" +def build_resource_groups_get_request(resource_group_name: str, subscription_id: str, **kwargs: Any) -> HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2019-05-10")) # type: str + accept = _headers.pop("Accept", "application/json") + # Construct URL _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}") path_format_arguments = { - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._\(\)]+$'), - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), + "resourceGroupName": _SERIALIZER.url( + "resource_group_name", resource_group_name, "str", max_length=90, min_length=1, pattern=r"^[-\w\._\(\)]+$" + ), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), } _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') - - return HttpRequest( - method="GET", - url=_url, - params=_query_parameters, - headers=_header_parameters, - **kwargs - ) + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) -def build_resource_groups_update_request( - resource_group_name: str, - subscription_id: str, - *, - json: JSONType = None, - content: Any = None, - **kwargs: Any -) -> HttpRequest: - api_version = kwargs.pop('api_version', "2019-05-10") # type: str - content_type = kwargs.pop('content_type', None) # type: Optional[str] - accept = "application/json" +def build_resource_groups_update_request(resource_group_name: str, subscription_id: str, **kwargs: Any) -> HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2019-05-10")) # type: str + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + accept = _headers.pop("Accept", "application/json") + # Construct URL _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}") path_format_arguments = { - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._\(\)]+$'), - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), + "resourceGroupName": _SERIALIZER.url( + "resource_group_name", resource_group_name, "str", max_length=90, min_length=1, pattern=r"^[-\w\._\(\)]+$" + ), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), } _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] if content_type is not None: - _header_parameters['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') - _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') - - return HttpRequest( - method="PATCH", - url=_url, - params=_query_parameters, - headers=_header_parameters, - json=json, - content=content, - **kwargs - ) + _headers["Content-Type"] = _SERIALIZER.header("content_type", content_type, "str") + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="PATCH", url=_url, params=_params, headers=_headers, **kwargs) def build_resource_groups_export_template_request( - resource_group_name: str, - subscription_id: str, - *, - json: JSONType = None, - content: Any = None, - **kwargs: Any + resource_group_name: str, subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2019-05-10") # type: str - content_type = kwargs.pop('content_type', None) # type: Optional[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", "2019-05-10")) # type: str + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + accept = _headers.pop("Accept", "application/json") - accept = "application/json" # Construct URL - _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/exportTemplate") + _url = kwargs.pop( + "template_url", "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/exportTemplate" + ) path_format_arguments = { - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._\(\)]+$'), - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), + "resourceGroupName": _SERIALIZER.url( + "resource_group_name", resource_group_name, "str", max_length=90, min_length=1, pattern=r"^[-\w\._\(\)]+$" + ), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), } _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] if content_type is not None: - _header_parameters['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') - _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') - - return HttpRequest( - method="POST", - url=_url, - params=_query_parameters, - headers=_header_parameters, - json=json, - content=content, - **kwargs - ) + _headers["Content-Type"] = _SERIALIZER.header("content_type", content_type, "str") + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="POST", url=_url, params=_params, headers=_headers, **kwargs) def build_resource_groups_list_request( - subscription_id: str, - *, - filter: Optional[str] = None, - top: Optional[int] = None, - **kwargs: Any + subscription_id: str, *, filter: Optional[str] = None, top: Optional[int] = None, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2019-05-10") # type: 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", "2019-05-10")) # type: str + accept = _headers.pop("Accept", "application/json") - accept = "application/json" # Construct URL _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourcegroups") path_format_arguments = { - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), } _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] if filter is not None: - _query_parameters['$filter'] = _SERIALIZER.query("filter", filter, 'str') + _params["$filter"] = _SERIALIZER.query("filter", filter, "str") if top is not None: - _query_parameters['$top'] = _SERIALIZER.query("top", top, 'int') - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["$top"] = _SERIALIZER.query("top", top, "int") + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') - - return HttpRequest( - method="GET", - url=_url, - params=_query_parameters, - headers=_header_parameters, - **kwargs - ) + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) -def build_tags_delete_value_request( - tag_name: str, - tag_value: str, - subscription_id: str, - **kwargs: Any -) -> HttpRequest: - api_version = kwargs.pop('api_version', "2019-05-10") # type: str +def build_tags_delete_value_request(tag_name: str, tag_value: str, subscription_id: str, **kwargs: Any) -> HttpRequest: + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2019-05-10")) # type: str # Construct URL _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/tagNames/{tagName}/tagValues/{tagValue}") path_format_arguments = { - "tagName": _SERIALIZER.url("tag_name", tag_name, 'str'), - "tagValue": _SERIALIZER.url("tag_value", tag_value, 'str'), - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), + "tagName": _SERIALIZER.url("tag_name", tag_name, "str"), + "tagValue": _SERIALIZER.url("tag_value", tag_value, "str"), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), } _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') - - return HttpRequest( - method="DELETE", - url=_url, - params=_query_parameters, - **kwargs - ) + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") + + return HttpRequest(method="DELETE", url=_url, params=_params, **kwargs) def build_tags_create_or_update_value_request( - tag_name: str, - tag_value: str, - subscription_id: str, - **kwargs: Any + tag_name: str, tag_value: str, subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2019-05-10") # type: 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", "2019-05-10")) # type: str + accept = _headers.pop("Accept", "application/json") - accept = "application/json" # Construct URL _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/tagNames/{tagName}/tagValues/{tagValue}") path_format_arguments = { - "tagName": _SERIALIZER.url("tag_name", tag_name, 'str'), - "tagValue": _SERIALIZER.url("tag_value", tag_value, 'str'), - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), + "tagName": _SERIALIZER.url("tag_name", tag_name, "str"), + "tagValue": _SERIALIZER.url("tag_value", tag_value, "str"), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), } _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') - - return HttpRequest( - method="PUT", - url=_url, - params=_query_parameters, - headers=_header_parameters, - **kwargs - ) + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + return HttpRequest(method="PUT", url=_url, params=_params, headers=_headers, **kwargs) -def build_tags_create_or_update_request( - tag_name: str, - subscription_id: str, - **kwargs: Any -) -> HttpRequest: - api_version = kwargs.pop('api_version', "2019-05-10") # type: str - accept = "application/json" +def build_tags_create_or_update_request(tag_name: str, subscription_id: str, **kwargs: Any) -> HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2019-05-10")) # type: str + accept = _headers.pop("Accept", "application/json") + # Construct URL _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/tagNames/{tagName}") path_format_arguments = { - "tagName": _SERIALIZER.url("tag_name", tag_name, 'str'), - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), + "tagName": _SERIALIZER.url("tag_name", tag_name, "str"), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), } _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') - - return HttpRequest( - method="PUT", - url=_url, - params=_query_parameters, - headers=_header_parameters, - **kwargs - ) + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + return HttpRequest(method="PUT", url=_url, params=_params, headers=_headers, **kwargs) -def build_tags_delete_request( - tag_name: str, - subscription_id: str, - **kwargs: Any -) -> HttpRequest: - api_version = kwargs.pop('api_version', "2019-05-10") # type: str +def build_tags_delete_request(tag_name: str, subscription_id: str, **kwargs: Any) -> HttpRequest: + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2019-05-10")) # type: str # Construct URL _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/tagNames/{tagName}") path_format_arguments = { - "tagName": _SERIALIZER.url("tag_name", tag_name, 'str'), - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), + "tagName": _SERIALIZER.url("tag_name", tag_name, "str"), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), } _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') - - return HttpRequest( - method="DELETE", - url=_url, - params=_query_parameters, - **kwargs - ) + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") + return HttpRequest(method="DELETE", url=_url, params=_params, **kwargs) -def build_tags_list_request( - subscription_id: str, - **kwargs: Any -) -> HttpRequest: - api_version = kwargs.pop('api_version', "2019-05-10") # type: str - accept = "application/json" +def build_tags_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", "2019-05-10")) # type: str + accept = _headers.pop("Accept", "application/json") + # Construct URL _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/tagNames") path_format_arguments = { - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), } _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') - - return HttpRequest( - method="GET", - url=_url, - params=_query_parameters, - headers=_header_parameters, - **kwargs - ) + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) def build_deployment_operations_get_at_management_group_scope_request( - group_id: str, - deployment_name: str, - operation_id: str, - **kwargs: Any + group_id: str, deployment_name: str, operation_id: str, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2019-05-10") # type: 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", "2019-05-10")) # type: str + accept = _headers.pop("Accept", "application/json") - accept = "application/json" # Construct URL - _url = kwargs.pop("template_url", "/providers/Microsoft.Management/managementGroups/{groupId}/providers/Microsoft.Resources/deployments/{deploymentName}/operations/{operationId}") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", + "/providers/Microsoft.Management/managementGroups/{groupId}/providers/Microsoft.Resources/deployments/{deploymentName}/operations/{operationId}", + ) # pylint: disable=line-too-long path_format_arguments = { - "groupId": _SERIALIZER.url("group_id", group_id, 'str', max_length=90, min_length=1), - "deploymentName": _SERIALIZER.url("deployment_name", deployment_name, 'str', max_length=64, min_length=1, pattern=r'^[-\w\._\(\)]+$'), - "operationId": _SERIALIZER.url("operation_id", operation_id, 'str'), + "groupId": _SERIALIZER.url("group_id", group_id, "str", max_length=90, min_length=1), + "deploymentName": _SERIALIZER.url( + "deployment_name", deployment_name, "str", max_length=64, min_length=1, pattern=r"^[-\w\._\(\)]+$" + ), + "operationId": _SERIALIZER.url("operation_id", operation_id, "str"), } _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') - - return HttpRequest( - method="GET", - url=_url, - params=_query_parameters, - headers=_header_parameters, - **kwargs - ) + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) def build_deployment_operations_list_at_management_group_scope_request( - group_id: str, - deployment_name: str, - *, - top: Optional[int] = None, - **kwargs: Any + group_id: str, deployment_name: str, *, top: Optional[int] = None, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2019-05-10") # type: 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", "2019-05-10")) # type: str + accept = _headers.pop("Accept", "application/json") - accept = "application/json" # Construct URL - _url = kwargs.pop("template_url", "/providers/Microsoft.Management/managementGroups/{groupId}/providers/Microsoft.Resources/deployments/{deploymentName}/operations") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", + "/providers/Microsoft.Management/managementGroups/{groupId}/providers/Microsoft.Resources/deployments/{deploymentName}/operations", + ) # pylint: disable=line-too-long path_format_arguments = { - "groupId": _SERIALIZER.url("group_id", group_id, 'str', max_length=90, min_length=1), - "deploymentName": _SERIALIZER.url("deployment_name", deployment_name, 'str', max_length=64, min_length=1, pattern=r'^[-\w\._\(\)]+$'), + "groupId": _SERIALIZER.url("group_id", group_id, "str", max_length=90, min_length=1), + "deploymentName": _SERIALIZER.url( + "deployment_name", deployment_name, "str", max_length=64, min_length=1, pattern=r"^[-\w\._\(\)]+$" + ), } _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] if top is not None: - _query_parameters['$top'] = _SERIALIZER.query("top", top, 'int') - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["$top"] = _SERIALIZER.query("top", top, "int") + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') - - return HttpRequest( - method="GET", - url=_url, - params=_query_parameters, - headers=_header_parameters, - **kwargs - ) + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) def build_deployment_operations_get_at_subscription_scope_request( - deployment_name: str, - operation_id: str, - subscription_id: str, - **kwargs: Any + deployment_name: str, operation_id: str, subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2019-05-10") # type: 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", "2019-05-10")) # type: str + accept = _headers.pop("Accept", "application/json") - accept = "application/json" # Construct URL - _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/providers/Microsoft.Resources/deployments/{deploymentName}/operations/{operationId}") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/providers/Microsoft.Resources/deployments/{deploymentName}/operations/{operationId}", + ) # pylint: disable=line-too-long path_format_arguments = { - "deploymentName": _SERIALIZER.url("deployment_name", deployment_name, 'str', max_length=64, min_length=1, pattern=r'^[-\w\._\(\)]+$'), - "operationId": _SERIALIZER.url("operation_id", operation_id, 'str'), - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), + "deploymentName": _SERIALIZER.url( + "deployment_name", deployment_name, "str", max_length=64, min_length=1, pattern=r"^[-\w\._\(\)]+$" + ), + "operationId": _SERIALIZER.url("operation_id", operation_id, "str"), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), } _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') - - return HttpRequest( - method="GET", - url=_url, - params=_query_parameters, - headers=_header_parameters, - **kwargs - ) + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) def build_deployment_operations_list_at_subscription_scope_request( - deployment_name: str, - subscription_id: str, - *, - top: Optional[int] = None, - **kwargs: Any + deployment_name: str, subscription_id: str, *, top: Optional[int] = None, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2019-05-10") # type: 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", "2019-05-10")) # type: str + accept = _headers.pop("Accept", "application/json") - accept = "application/json" # Construct URL - _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/providers/Microsoft.Resources/deployments/{deploymentName}/operations") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/providers/Microsoft.Resources/deployments/{deploymentName}/operations", + ) # pylint: disable=line-too-long path_format_arguments = { - "deploymentName": _SERIALIZER.url("deployment_name", deployment_name, 'str', max_length=64, min_length=1, pattern=r'^[-\w\._\(\)]+$'), - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), + "deploymentName": _SERIALIZER.url( + "deployment_name", deployment_name, "str", max_length=64, min_length=1, pattern=r"^[-\w\._\(\)]+$" + ), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), } _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] if top is not None: - _query_parameters['$top'] = _SERIALIZER.query("top", top, 'int') - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["$top"] = _SERIALIZER.query("top", top, "int") + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') - - return HttpRequest( - method="GET", - url=_url, - params=_query_parameters, - headers=_header_parameters, - **kwargs - ) + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) def build_deployment_operations_get_request( - resource_group_name: str, - deployment_name: str, - operation_id: str, - subscription_id: str, - **kwargs: Any + resource_group_name: str, deployment_name: str, operation_id: str, subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2019-05-10") # type: 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", "2019-05-10")) # type: str + accept = _headers.pop("Accept", "application/json") - accept = "application/json" # Construct URL - _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/deployments/{deploymentName}/operations/{operationId}") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/deployments/{deploymentName}/operations/{operationId}", + ) # pylint: disable=line-too-long path_format_arguments = { - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._\(\)]+$'), - "deploymentName": _SERIALIZER.url("deployment_name", deployment_name, 'str', max_length=64, min_length=1, pattern=r'^[-\w\._\(\)]+$'), - "operationId": _SERIALIZER.url("operation_id", operation_id, 'str'), - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), + "resourceGroupName": _SERIALIZER.url( + "resource_group_name", resource_group_name, "str", max_length=90, min_length=1, pattern=r"^[-\w\._\(\)]+$" + ), + "deploymentName": _SERIALIZER.url( + "deployment_name", deployment_name, "str", max_length=64, min_length=1, pattern=r"^[-\w\._\(\)]+$" + ), + "operationId": _SERIALIZER.url("operation_id", operation_id, "str"), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), } _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') - - return HttpRequest( - method="GET", - url=_url, - params=_query_parameters, - headers=_header_parameters, - **kwargs - ) + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) def build_deployment_operations_list_request( - resource_group_name: str, - deployment_name: str, - subscription_id: str, - *, - top: Optional[int] = None, - **kwargs: Any + resource_group_name: str, deployment_name: str, subscription_id: str, *, top: Optional[int] = None, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2019-05-10") # type: 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", "2019-05-10")) # type: str + accept = _headers.pop("Accept", "application/json") - accept = "application/json" # Construct URL - _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/deployments/{deploymentName}/operations") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/deployments/{deploymentName}/operations", + ) # pylint: disable=line-too-long path_format_arguments = { - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._\(\)]+$'), - "deploymentName": _SERIALIZER.url("deployment_name", deployment_name, 'str', max_length=64, min_length=1, pattern=r'^[-\w\._\(\)]+$'), - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), + "resourceGroupName": _SERIALIZER.url( + "resource_group_name", resource_group_name, "str", max_length=90, min_length=1, pattern=r"^[-\w\._\(\)]+$" + ), + "deploymentName": _SERIALIZER.url( + "deployment_name", deployment_name, "str", max_length=64, min_length=1, pattern=r"^[-\w\._\(\)]+$" + ), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), } _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] if top is not None: - _query_parameters['$top'] = _SERIALIZER.query("top", top, 'int') - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["$top"] = _SERIALIZER.query("top", top, "int") + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') - - return HttpRequest( - method="GET", - url=_url, - params=_query_parameters, - headers=_header_parameters, - **kwargs - ) + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) -class Operations(object): - """Operations operations. - You should not instantiate this class directly. Instead, you should create a Client instance that - instantiates it for you and attaches it as an attribute. +class Operations: + """ + .. warning:: + **DO NOT** instantiate this class directly. - :ivar models: Alias to model classes used in this operation group. - :type models: ~azure.mgmt.resource.resources.v2019_05_10.models - :param client: Client for service requests. - :param config: Configuration of service client. - :param serializer: An object model serializer. - :param deserializer: An object model deserializer. + Instead, you should access the following operations through + :class:`~azure.mgmt.resource.resources.v2019_05_10.ResourceManagementClient`'s + :attr:`operations` attribute. """ models = _models - def __init__(self, client, config, serializer, deserializer): - self._client = client - self._serialize = serializer - self._deserialize = deserializer - self._config = config + def __init__(self, *args, **kwargs): + input_args = list(args) + self._client = input_args.pop(0) if input_args else kwargs.pop("client") + self._config = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") @distributed_trace - def list( - self, - **kwargs: Any - ) -> Iterable["_models.OperationListResult"]: + def list(self, **kwargs: Any) -> Iterable["_models.Operation"]: """Lists all of the available Microsoft.Resources REST API operations. :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either OperationListResult or the result of cls(response) + :return: An iterator like instance of either Operation or the result of cls(response) :rtype: - ~azure.core.paging.ItemPaged[~azure.mgmt.resource.resources.v2019_05_10.models.OperationListResult] - :raises: ~azure.core.exceptions.HttpResponseError + ~azure.core.paging.ItemPaged[~azure.mgmt.resource.resources.v2019_05_10.models.Operation] + :raises ~azure.core.exceptions.HttpResponseError: """ - api_version = kwargs.pop('api_version', "2019-05-10") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2019-05-10")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[_models.OperationListResult] - cls = kwargs.pop('cls', None) # type: ClsType["_models.OperationListResult"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) + def prepare_request(next_link=None): if not next_link: - + request = build_operations_list_request( api_version=api_version, - template_url=self.list.metadata['url'], + template_url=self.list.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore else: - - request = build_operations_list_request( - template_url=next_link, - ) + # make call to next link with the client's api-version + _parsed_next_link = urlparse(next_link) + _next_request_params = case_insensitive_dict(parse_qs(_parsed_next_link.query)) + _next_request_params["api-version"] = self._config.api_version + request = HttpRequest("GET", urljoin(next_link, _parsed_next_link.path), params=_next_request_params) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore request.method = "GET" return request @@ -2400,10 +2074,8 @@ def extract_data(pipeline_response): def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) response = pipeline_response.http_response @@ -2413,62 +2085,62 @@ def get_next(next_link=None): return pipeline_response + return ItemPaged(get_next, extract_data) - return ItemPaged( - get_next, extract_data - ) - list.metadata = {'url': "/providers/Microsoft.Resources/operations"} # type: ignore -class DeploymentsOperations(object): # pylint: disable=too-many-public-methods - """DeploymentsOperations operations. - - You should not instantiate this class directly. Instead, you should create a Client instance that - instantiates it for you and attaches it as an attribute. - - :ivar models: Alias to model classes used in this operation group. - :type models: ~azure.mgmt.resource.resources.v2019_05_10.models - :param client: Client for service requests. - :param config: Configuration of service client. - :param serializer: An object model serializer. - :param deserializer: An object model deserializer. + list.metadata = {"url": "/providers/Microsoft.Resources/operations"} # type: ignore + + +class DeploymentsOperations: # pylint: disable=too-many-public-methods + """ + .. warning:: + **DO NOT** instantiate this class directly. + + Instead, you should access the following operations through + :class:`~azure.mgmt.resource.resources.v2019_05_10.ResourceManagementClient`'s + :attr:`deployments` attribute. """ models = _models - def __init__(self, client, config, serializer, deserializer): - self._client = client - self._serialize = serializer - self._deserialize = deserializer - self._config = config + def __init__(self, *args, **kwargs): + input_args = list(args) + self._client = input_args.pop(0) if input_args else kwargs.pop("client") + self._config = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") def _delete_at_management_group_scope_initial( # pylint: disable=inconsistent-return-statements - self, - group_id: str, - deployment_name: str, - **kwargs: Any + self, group_id: str, deployment_name: str, **kwargs: Any ) -> None: - cls = kwargs.pop('cls', None) # type: ClsType[None] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + 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', "2019-05-10") # type: str + api_version = kwargs.pop("api_version", _params.pop("api-version", "2019-05-10")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[None] - - request = build_deployments_delete_at_management_group_scope_request_initial( + request = build_deployments_delete_at_management_group_scope_request( group_id=group_id, deployment_name=deployment_name, api_version=api_version, - template_url=self._delete_at_management_group_scope_initial.metadata['url'], + template_url=self._delete_at_management_group_scope_initial.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [202, 204]: @@ -2478,15 +2150,11 @@ def _delete_at_management_group_scope_initial( # pylint: disable=inconsistent-r if cls: return cls(pipeline_response, None, {}) - _delete_at_management_group_scope_initial.metadata = {'url': "/providers/Microsoft.Management/managementGroups/{groupId}/providers/Microsoft.Resources/deployments/{deploymentName}"} # type: ignore - + _delete_at_management_group_scope_initial.metadata = {"url": "/providers/Microsoft.Management/managementGroups/{groupId}/providers/Microsoft.Resources/deployments/{deploymentName}"} # type: ignore @distributed_trace - def begin_delete_at_management_group_scope( # pylint: disable=inconsistent-return-statements - self, - group_id: str, - deployment_name: str, - **kwargs: Any + def begin_delete_at_management_group_scope( + self, group_id: str, deployment_name: str, **kwargs: Any ) -> LROPoller[None]: """Deletes a deployment from the deployment history. @@ -2498,9 +2166,9 @@ def begin_delete_at_management_group_scope( # pylint: disable=inconsistent-retu process finishes, the URI in the Location header returns a status of 204 on success. If the asynchronous request failed, the URI in the Location header returns an error-level status code. - :param group_id: The management group ID. + :param group_id: The management group ID. Required. :type group_id: str - :param deployment_name: The name of the deployment. + :param deployment_name: The name of the deployment. Required. :type deployment_name: str :keyword callable cls: A custom type or function that will be passed the direct response :keyword str continuation_token: A continuation token to restart a poller from a saved state. @@ -2512,86 +2180,91 @@ def begin_delete_at_management_group_scope( # pylint: disable=inconsistent-retu Retry-After header is present. :return: An instance of LROPoller that returns either None or the result of cls(response) :rtype: ~azure.core.polling.LROPoller[None] - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - api_version = kwargs.pop('api_version', "2019-05-10") # type: str - polling = kwargs.pop('polling', True) # type: Union[bool, PollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType[None] - lro_delay = kwargs.pop( - 'polling_interval', - self._config.polling_interval - ) - cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2019-05-10")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[None] + polling = kwargs.pop("polling", True) # type: Union[bool, PollingMethod] + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token = kwargs.pop("continuation_token", None) # type: Optional[str] if cont_token is None: - raw_result = self._delete_at_management_group_scope_initial( + raw_result = self._delete_at_management_group_scope_initial( # type: ignore group_id=group_id, deployment_name=deployment_name, api_version=api_version, - cls=lambda x,y,z: x, + cls=lambda x, y, z: x, + headers=_headers, + params=_params, **kwargs ) - kwargs.pop('error_map', None) + kwargs.pop("error_map", None) - def get_long_running_output(pipeline_response): + def get_long_running_output(pipeline_response): # pylint: disable=inconsistent-return-statements if cls: return cls(pipeline_response, None, {}) - - if polling is True: polling_method = ARMPolling(lro_delay, **kwargs) - elif polling is False: polling_method = NoPolling() - else: polling_method = polling + if polling is True: + polling_method = cast(PollingMethod, ARMPolling(lro_delay, **kwargs)) # type: PollingMethod + elif polling is False: + polling_method = cast(PollingMethod, NoPolling()) + else: + polling_method = polling if cont_token: return LROPoller.from_continuation_token( polling_method=polling_method, continuation_token=cont_token, client=self._client, - deserialization_callback=get_long_running_output + deserialization_callback=get_long_running_output, ) return LROPoller(self._client, raw_result, get_long_running_output, polling_method) - begin_delete_at_management_group_scope.metadata = {'url': "/providers/Microsoft.Management/managementGroups/{groupId}/providers/Microsoft.Resources/deployments/{deploymentName}"} # type: ignore + begin_delete_at_management_group_scope.metadata = {"url": "/providers/Microsoft.Management/managementGroups/{groupId}/providers/Microsoft.Resources/deployments/{deploymentName}"} # type: ignore @distributed_trace - def check_existence_at_management_group_scope( - self, - group_id: str, - deployment_name: str, - **kwargs: Any - ) -> bool: + def check_existence_at_management_group_scope(self, group_id: str, deployment_name: str, **kwargs: Any) -> bool: """Checks whether the deployment exists. - :param group_id: The management group ID. + :param group_id: The management group ID. Required. :type group_id: str - :param deployment_name: The name of the deployment. + :param deployment_name: The name of the deployment. Required. :type deployment_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: bool, or the result of cls(response) + :return: bool or the result of cls(response) :rtype: bool - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType[None] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) - api_version = kwargs.pop('api_version', "2019-05-10") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2019-05-10")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[None] - request = build_deployments_check_existence_at_management_group_scope_request( group_id=group_id, deployment_name=deployment_name, api_version=api_version, - template_url=self.check_existence_at_management_group_scope.metadata['url'], + template_url=self.check_existence_at_management_group_scope.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [204, 404]: @@ -2602,43 +2275,52 @@ def check_existence_at_management_group_scope( return cls(pipeline_response, None, {}) return 200 <= response.status_code <= 299 - check_existence_at_management_group_scope.metadata = {'url': "/providers/Microsoft.Management/managementGroups/{groupId}/providers/Microsoft.Resources/deployments/{deploymentName}"} # type: ignore - + check_existence_at_management_group_scope.metadata = {"url": "/providers/Microsoft.Management/managementGroups/{groupId}/providers/Microsoft.Resources/deployments/{deploymentName}"} # type: ignore def _create_or_update_at_management_group_scope_initial( - self, - group_id: str, - deployment_name: str, - parameters: "_models.Deployment", - **kwargs: Any - ) -> "_models.DeploymentExtended": - cls = kwargs.pop('cls', None) # type: ClsType["_models.DeploymentExtended"] + self, group_id: str, deployment_name: str, parameters: Union[_models.Deployment, IO], **kwargs: Any + ) -> _models.DeploymentExtended: error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', "2019-05-10") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + api_version = kwargs.pop("api_version", _params.pop("api-version", "2019-05-10")) # type: str + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.DeploymentExtended] - _json = self._serialize.body(parameters, 'Deployment') + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(parameters, (IO, bytes)): + _content = parameters + else: + _json = self._serialize.body(parameters, "Deployment") - request = build_deployments_create_or_update_at_management_group_scope_request_initial( + request = build_deployments_create_or_update_at_management_group_scope_request( group_id=group_id, deployment_name=deployment_name, api_version=api_version, content_type=content_type, json=_json, - template_url=self._create_or_update_at_management_group_scope_initial.metadata['url'], + content=_content, + template_url=self._create_or_update_at_management_group_scope_initial.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200, 201]: @@ -2646,37 +2328,41 @@ def _create_or_update_at_management_group_scope_initial( raise HttpResponseError(response=response, error_format=ARMErrorFormat) if response.status_code == 200: - deserialized = self._deserialize('DeploymentExtended', pipeline_response) + deserialized = self._deserialize("DeploymentExtended", pipeline_response) if response.status_code == 201: - deserialized = self._deserialize('DeploymentExtended', pipeline_response) + deserialized = self._deserialize("DeploymentExtended", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - _create_or_update_at_management_group_scope_initial.metadata = {'url': "/providers/Microsoft.Management/managementGroups/{groupId}/providers/Microsoft.Resources/deployments/{deploymentName}"} # type: ignore - + _create_or_update_at_management_group_scope_initial.metadata = {"url": "/providers/Microsoft.Management/managementGroups/{groupId}/providers/Microsoft.Resources/deployments/{deploymentName}"} # type: ignore - @distributed_trace + @overload def begin_create_or_update_at_management_group_scope( self, group_id: str, deployment_name: str, - parameters: "_models.Deployment", + parameters: _models.Deployment, + *, + content_type: str = "application/json", **kwargs: Any - ) -> LROPoller["_models.DeploymentExtended"]: + ) -> LROPoller[_models.DeploymentExtended]: """Deploys resources at management group scope. You can provide the template and parameters directly in the request or link to JSON files. - :param group_id: The management group ID. + :param group_id: The management group ID. Required. :type group_id: str - :param deployment_name: The name of the deployment. + :param deployment_name: The name of the deployment. Required. :type deployment_name: str - :param parameters: Additional parameters supplied to the operation. + :param parameters: Additional parameters supplied to the operation. Required. :type parameters: ~azure.mgmt.resource.resources.v2019_05_10.models.Deployment + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str :keyword callable cls: A custom type or function that will be passed the direct response :keyword str continuation_token: A continuation token to restart a poller from a saved state. :keyword polling: By default, your polling method will be ARMPolling. Pass in False for this @@ -2689,114 +2375,187 @@ def begin_create_or_update_at_management_group_scope( cls(response) :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.resource.resources.v2019_05_10.models.DeploymentExtended] - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - api_version = kwargs.pop('api_version', "2019-05-10") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] - polling = kwargs.pop('polling', True) # type: Union[bool, PollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType["_models.DeploymentExtended"] - lro_delay = kwargs.pop( - 'polling_interval', - self._config.polling_interval - ) - cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] + + @overload + def begin_create_or_update_at_management_group_scope( + self, + group_id: str, + deployment_name: str, + parameters: IO, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> LROPoller[_models.DeploymentExtended]: + """Deploys resources at management group scope. + + You can provide the template and parameters directly in the request or link to JSON files. + + :param group_id: The management group ID. Required. + :type group_id: str + :param deployment_name: The name of the deployment. Required. + :type deployment_name: str + :param parameters: Additional parameters supplied to the operation. Required. + :type parameters: IO + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be ARMPolling. Pass in False for this + operation to not poll, or pass in your own initialized polling object for a personal polling + strategy. + :paramtype polling: bool or ~azure.core.polling.PollingMethod + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of LROPoller that returns either DeploymentExtended or the result of + cls(response) + :rtype: + ~azure.core.polling.LROPoller[~azure.mgmt.resource.resources.v2019_05_10.models.DeploymentExtended] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace + def begin_create_or_update_at_management_group_scope( + self, group_id: str, deployment_name: str, parameters: Union[_models.Deployment, IO], **kwargs: Any + ) -> LROPoller[_models.DeploymentExtended]: + """Deploys resources at management group scope. + + You can provide the template and parameters directly in the request or link to JSON files. + + :param group_id: The management group ID. Required. + :type group_id: str + :param deployment_name: The name of the deployment. Required. + :type deployment_name: str + :param parameters: Additional parameters supplied to the operation. Is either a model type or a + IO type. Required. + :type parameters: ~azure.mgmt.resource.resources.v2019_05_10.models.Deployment or IO + :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. + Default value is None. + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be ARMPolling. Pass in False for this + operation to not poll, or pass in your own initialized polling object for a personal polling + strategy. + :paramtype polling: bool or ~azure.core.polling.PollingMethod + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of LROPoller that returns either DeploymentExtended or the result of + cls(response) + :rtype: + ~azure.core.polling.LROPoller[~azure.mgmt.resource.resources.v2019_05_10.models.DeploymentExtended] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _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", "2019-05-10")) # type: str + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.DeploymentExtended] + polling = kwargs.pop("polling", True) # type: Union[bool, PollingMethod] + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token = kwargs.pop("continuation_token", None) # type: Optional[str] if cont_token is None: - raw_result = self._create_or_update_at_management_group_scope_initial( + raw_result = self._create_or_update_at_management_group_scope_initial( # type: ignore group_id=group_id, deployment_name=deployment_name, parameters=parameters, api_version=api_version, content_type=content_type, - cls=lambda x,y,z: x, + cls=lambda x, y, z: x, + headers=_headers, + params=_params, **kwargs ) - kwargs.pop('error_map', None) + kwargs.pop("error_map", None) def get_long_running_output(pipeline_response): - response = pipeline_response.http_response - deserialized = self._deserialize('DeploymentExtended', pipeline_response) + deserialized = self._deserialize("DeploymentExtended", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - - if polling is True: polling_method = ARMPolling(lro_delay, **kwargs) - elif polling is False: polling_method = NoPolling() - else: polling_method = polling + if polling is True: + polling_method = cast(PollingMethod, ARMPolling(lro_delay, **kwargs)) # type: PollingMethod + elif polling is False: + polling_method = cast(PollingMethod, NoPolling()) + else: + polling_method = polling if cont_token: return LROPoller.from_continuation_token( polling_method=polling_method, continuation_token=cont_token, client=self._client, - deserialization_callback=get_long_running_output + deserialization_callback=get_long_running_output, ) return LROPoller(self._client, raw_result, get_long_running_output, polling_method) - begin_create_or_update_at_management_group_scope.metadata = {'url': "/providers/Microsoft.Management/managementGroups/{groupId}/providers/Microsoft.Resources/deployments/{deploymentName}"} # type: ignore + begin_create_or_update_at_management_group_scope.metadata = {"url": "/providers/Microsoft.Management/managementGroups/{groupId}/providers/Microsoft.Resources/deployments/{deploymentName}"} # type: ignore @distributed_trace def get_at_management_group_scope( - self, - group_id: str, - deployment_name: str, - **kwargs: Any - ) -> "_models.DeploymentExtended": + self, group_id: str, deployment_name: str, **kwargs: Any + ) -> _models.DeploymentExtended: """Gets a deployment. - :param group_id: The management group ID. + :param group_id: The management group ID. Required. :type group_id: str - :param deployment_name: The name of the deployment. + :param deployment_name: The name of the deployment. Required. :type deployment_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: DeploymentExtended, or the result of cls(response) + :return: DeploymentExtended or the result of cls(response) :rtype: ~azure.mgmt.resource.resources.v2019_05_10.models.DeploymentExtended - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.DeploymentExtended"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) - api_version = kwargs.pop('api_version', "2019-05-10") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2019-05-10")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[_models.DeploymentExtended] - request = build_deployments_get_at_management_group_scope_request( group_id=group_id, deployment_name=deployment_name, api_version=api_version, - template_url=self.get_at_management_group_scope.metadata['url'], + template_url=self.get_at_management_group_scope.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) - deserialized = self._deserialize('DeploymentExtended', pipeline_response) + deserialized = self._deserialize("DeploymentExtended", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - get_at_management_group_scope.metadata = {'url': "/providers/Microsoft.Management/managementGroups/{groupId}/providers/Microsoft.Resources/deployments/{deploymentName}"} # type: ignore - + get_at_management_group_scope.metadata = {"url": "/providers/Microsoft.Management/managementGroups/{groupId}/providers/Microsoft.Resources/deployments/{deploymentName}"} # type: ignore @distributed_trace def cancel_at_management_group_scope( # pylint: disable=inconsistent-return-statements - self, - group_id: str, - deployment_name: str, - **kwargs: Any + self, group_id: str, deployment_name: str, **kwargs: Any ) -> None: """Cancels a currently running template deployment. @@ -2805,38 +2564,44 @@ def cancel_at_management_group_scope( # pylint: disable=inconsistent-return-sta deployment stops the currently running template deployment and leaves the resources partially deployed. - :param group_id: The management group ID. + :param group_id: The management group ID. Required. :type group_id: str - :param deployment_name: The name of the deployment. + :param deployment_name: The name of the deployment. Required. :type deployment_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: None, or the result of cls(response) + :return: None or the result of cls(response) :rtype: None - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType[None] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + 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', "2019-05-10") # type: str + api_version = kwargs.pop("api_version", _params.pop("api-version", "2019-05-10")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[None] - request = build_deployments_cancel_at_management_group_scope_request( group_id=group_id, deployment_name=deployment_name, api_version=api_version, - template_url=self.cancel_at_management_group_scope.metadata['url'], + template_url=self.cancel_at_management_group_scope.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [204]: @@ -2846,41 +2611,107 @@ def cancel_at_management_group_scope( # pylint: disable=inconsistent-return-sta if cls: return cls(pipeline_response, None, {}) - cancel_at_management_group_scope.metadata = {'url': "/providers/Microsoft.Management/managementGroups/{groupId}/providers/Microsoft.Resources/deployments/{deploymentName}/cancel"} # type: ignore - + cancel_at_management_group_scope.metadata = {"url": "/providers/Microsoft.Management/managementGroups/{groupId}/providers/Microsoft.Resources/deployments/{deploymentName}/cancel"} # type: ignore - @distributed_trace + @overload def validate_at_management_group_scope( self, group_id: str, deployment_name: str, - parameters: "_models.Deployment", + parameters: _models.Deployment, + *, + content_type: str = "application/json", **kwargs: Any - ) -> "_models.DeploymentValidateResult": + ) -> _models.DeploymentValidateResult: """Validates whether the specified template is syntactically correct and will be accepted by Azure Resource Manager.. - :param group_id: The management group ID. + :param group_id: The management group ID. Required. :type group_id: str - :param deployment_name: The name of the deployment. + :param deployment_name: The name of the deployment. Required. :type deployment_name: str - :param parameters: Parameters to validate. + :param parameters: Parameters to validate. Required. :type parameters: ~azure.mgmt.resource.resources.v2019_05_10.models.Deployment + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: DeploymentValidateResult or the result of cls(response) + :rtype: ~azure.mgmt.resource.resources.v2019_05_10.models.DeploymentValidateResult + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + def validate_at_management_group_scope( + self, + group_id: str, + deployment_name: str, + parameters: IO, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.DeploymentValidateResult: + """Validates whether the specified template is syntactically correct and will be accepted by Azure + Resource Manager.. + + :param group_id: The management group ID. Required. + :type group_id: str + :param deployment_name: The name of the deployment. Required. + :type deployment_name: str + :param parameters: Parameters to validate. Required. + :type parameters: IO + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: DeploymentValidateResult or the result of cls(response) + :rtype: ~azure.mgmt.resource.resources.v2019_05_10.models.DeploymentValidateResult + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace + def validate_at_management_group_scope( + self, group_id: str, deployment_name: str, parameters: Union[_models.Deployment, IO], **kwargs: Any + ) -> _models.DeploymentValidateResult: + """Validates whether the specified template is syntactically correct and will be accepted by Azure + Resource Manager.. + + :param group_id: The management group ID. Required. + :type group_id: str + :param deployment_name: The name of the deployment. Required. + :type deployment_name: str + :param parameters: Parameters to validate. Is either a model type or a IO type. Required. + :type parameters: ~azure.mgmt.resource.resources.v2019_05_10.models.Deployment or IO + :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. + Default value is None. + :paramtype content_type: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: DeploymentValidateResult, or the result of cls(response) + :return: DeploymentValidateResult or the result of cls(response) :rtype: ~azure.mgmt.resource.resources.v2019_05_10.models.DeploymentValidateResult - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.DeploymentValidateResult"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', "2019-05-10") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + api_version = kwargs.pop("api_version", _params.pop("api-version", "2019-05-10")) # type: str + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.DeploymentValidateResult] - _json = self._serialize.body(parameters, 'Deployment') + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(parameters, (IO, bytes)): + _content = parameters + else: + _json = self._serialize.body(parameters, "Deployment") request = build_deployments_validate_at_management_group_scope_request( group_id=group_id, @@ -2888,16 +2719,18 @@ def validate_at_management_group_scope( api_version=api_version, content_type=content_type, json=_json, - template_url=self.validate_at_management_group_scope.metadata['url'], + content=_content, + template_url=self.validate_at_management_group_scope.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200, 400]: @@ -2905,87 +2738,84 @@ def validate_at_management_group_scope( raise HttpResponseError(response=response, error_format=ARMErrorFormat) if response.status_code == 200: - deserialized = self._deserialize('DeploymentValidateResult', pipeline_response) + deserialized = self._deserialize("DeploymentValidateResult", pipeline_response) if response.status_code == 400: - deserialized = self._deserialize('DeploymentValidateResult', pipeline_response) + deserialized = self._deserialize("DeploymentValidateResult", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - validate_at_management_group_scope.metadata = {'url': "/providers/Microsoft.Management/managementGroups/{groupId}/providers/Microsoft.Resources/deployments/{deploymentName}/validate"} # type: ignore - + validate_at_management_group_scope.metadata = {"url": "/providers/Microsoft.Management/managementGroups/{groupId}/providers/Microsoft.Resources/deployments/{deploymentName}/validate"} # type: ignore @distributed_trace def export_template_at_management_group_scope( - self, - group_id: str, - deployment_name: str, - **kwargs: Any - ) -> "_models.DeploymentExportResult": + self, group_id: str, deployment_name: str, **kwargs: Any + ) -> _models.DeploymentExportResult: """Exports the template used for specified deployment. - :param group_id: The management group ID. + :param group_id: The management group ID. Required. :type group_id: str - :param deployment_name: The name of the deployment. + :param deployment_name: The name of the deployment. Required. :type deployment_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: DeploymentExportResult, or the result of cls(response) + :return: DeploymentExportResult or the result of cls(response) :rtype: ~azure.mgmt.resource.resources.v2019_05_10.models.DeploymentExportResult - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.DeploymentExportResult"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) - api_version = kwargs.pop('api_version', "2019-05-10") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2019-05-10")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[_models.DeploymentExportResult] - request = build_deployments_export_template_at_management_group_scope_request( group_id=group_id, deployment_name=deployment_name, api_version=api_version, - template_url=self.export_template_at_management_group_scope.metadata['url'], + template_url=self.export_template_at_management_group_scope.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) - deserialized = self._deserialize('DeploymentExportResult', pipeline_response) + deserialized = self._deserialize("DeploymentExportResult", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - export_template_at_management_group_scope.metadata = {'url': "/providers/Microsoft.Management/managementGroups/{groupId}/providers/Microsoft.Resources/deployments/{deploymentName}/exportTemplate"} # type: ignore - + export_template_at_management_group_scope.metadata = {"url": "/providers/Microsoft.Management/managementGroups/{groupId}/providers/Microsoft.Resources/deployments/{deploymentName}/exportTemplate"} # type: ignore @distributed_trace def list_at_management_group_scope( - self, - group_id: str, - filter: Optional[str] = None, - top: Optional[int] = None, - **kwargs: Any - ) -> Iterable["_models.DeploymentListResult"]: + self, group_id: str, filter: Optional[str] = None, top: Optional[int] = None, **kwargs: Any + ) -> Iterable["_models.DeploymentExtended"]: """Get all the deployments for a management group. - :param group_id: The management group ID. + :param group_id: The management group ID. Required. :type group_id: str :param filter: The filter to apply on the operation. For example, you can use $filter=provisioningState eq '{state}'. Default value is None. @@ -2994,40 +2824,48 @@ def list_at_management_group_scope( value is None. :type top: int :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either DeploymentListResult or the result of - cls(response) + :return: An iterator like instance of either DeploymentExtended or the result of cls(response) :rtype: - ~azure.core.paging.ItemPaged[~azure.mgmt.resource.resources.v2019_05_10.models.DeploymentListResult] - :raises: ~azure.core.exceptions.HttpResponseError + ~azure.core.paging.ItemPaged[~azure.mgmt.resource.resources.v2019_05_10.models.DeploymentExtended] + :raises ~azure.core.exceptions.HttpResponseError: """ - api_version = kwargs.pop('api_version', "2019-05-10") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2019-05-10")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[_models.DeploymentListResult] - cls = kwargs.pop('cls', None) # type: ClsType["_models.DeploymentListResult"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) + def prepare_request(next_link=None): if not next_link: - + request = build_deployments_list_at_management_group_scope_request( group_id=group_id, - api_version=api_version, filter=filter, top=top, - template_url=self.list_at_management_group_scope.metadata['url'], + api_version=api_version, + template_url=self.list_at_management_group_scope.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore else: - - request = build_deployments_list_at_management_group_scope_request( - group_id=group_id, - template_url=next_link, - ) + # make call to next link with the client's api-version + _parsed_next_link = urlparse(next_link) + _next_request_params = case_insensitive_dict(parse_qs(_parsed_next_link.query)) + _next_request_params["api-version"] = self._config.api_version + request = HttpRequest("GET", urljoin(next_link, _parsed_next_link.path), params=_next_request_params) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore request.method = "GET" return request @@ -3041,10 +2879,8 @@ def extract_data(pipeline_response): def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) response = pipeline_response.http_response @@ -3054,40 +2890,42 @@ def get_next(next_link=None): return pipeline_response + return ItemPaged(get_next, extract_data) - return ItemPaged( - get_next, extract_data - ) - list_at_management_group_scope.metadata = {'url': "/providers/Microsoft.Management/managementGroups/{groupId}/providers/Microsoft.Resources/deployments/"} # type: ignore + list_at_management_group_scope.metadata = {"url": "/providers/Microsoft.Management/managementGroups/{groupId}/providers/Microsoft.Resources/deployments/"} # type: ignore def _delete_at_subscription_scope_initial( # pylint: disable=inconsistent-return-statements - self, - deployment_name: str, - **kwargs: Any + self, deployment_name: str, **kwargs: Any ) -> None: - cls = kwargs.pop('cls', None) # type: ClsType[None] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) - api_version = kwargs.pop('api_version', "2019-05-10") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - request = build_deployments_delete_at_subscription_scope_request_initial( + api_version = kwargs.pop("api_version", _params.pop("api-version", "2019-05-10")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[None] + + request = build_deployments_delete_at_subscription_scope_request( deployment_name=deployment_name, subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self._delete_at_subscription_scope_initial.metadata['url'], + template_url=self._delete_at_subscription_scope_initial.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [202, 204]: @@ -3097,15 +2935,10 @@ def _delete_at_subscription_scope_initial( # pylint: disable=inconsistent-retur if cls: return cls(pipeline_response, None, {}) - _delete_at_subscription_scope_initial.metadata = {'url': "/subscriptions/{subscriptionId}/providers/Microsoft.Resources/deployments/{deploymentName}"} # type: ignore - + _delete_at_subscription_scope_initial.metadata = {"url": "/subscriptions/{subscriptionId}/providers/Microsoft.Resources/deployments/{deploymentName}"} # type: ignore @distributed_trace - def begin_delete_at_subscription_scope( # pylint: disable=inconsistent-return-statements - self, - deployment_name: str, - **kwargs: Any - ) -> LROPoller[None]: + def begin_delete_at_subscription_scope(self, deployment_name: str, **kwargs: Any) -> LROPoller[None]: """Deletes a deployment from the deployment history. A template deployment that is currently running cannot be deleted. Deleting a template @@ -3116,7 +2949,7 @@ def begin_delete_at_subscription_scope( # pylint: disable=inconsistent-return-s process finishes, the URI in the Location header returns a status of 204 on success. If the asynchronous request failed, the URI in the Location header returns an error-level status code. - :param deployment_name: The name of the deployment. + :param deployment_name: The name of the deployment. Required. :type deployment_name: str :keyword callable cls: A custom type or function that will be passed the direct response :keyword str continuation_token: A continuation token to restart a poller from a saved state. @@ -3128,82 +2961,88 @@ def begin_delete_at_subscription_scope( # pylint: disable=inconsistent-return-s Retry-After header is present. :return: An instance of LROPoller that returns either None or the result of cls(response) :rtype: ~azure.core.polling.LROPoller[None] - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - api_version = kwargs.pop('api_version', "2019-05-10") # type: str - polling = kwargs.pop('polling', True) # type: Union[bool, PollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType[None] - lro_delay = kwargs.pop( - 'polling_interval', - self._config.polling_interval - ) - cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2019-05-10")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[None] + polling = kwargs.pop("polling", True) # type: Union[bool, PollingMethod] + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token = kwargs.pop("continuation_token", None) # type: Optional[str] if cont_token is None: - raw_result = self._delete_at_subscription_scope_initial( + raw_result = self._delete_at_subscription_scope_initial( # type: ignore deployment_name=deployment_name, api_version=api_version, - cls=lambda x,y,z: x, + cls=lambda x, y, z: x, + headers=_headers, + params=_params, **kwargs ) - kwargs.pop('error_map', None) + kwargs.pop("error_map", None) - def get_long_running_output(pipeline_response): + def get_long_running_output(pipeline_response): # pylint: disable=inconsistent-return-statements if cls: return cls(pipeline_response, None, {}) - - if polling is True: polling_method = ARMPolling(lro_delay, **kwargs) - elif polling is False: polling_method = NoPolling() - else: polling_method = polling + if polling is True: + polling_method = cast(PollingMethod, ARMPolling(lro_delay, **kwargs)) # type: PollingMethod + elif polling is False: + polling_method = cast(PollingMethod, NoPolling()) + else: + polling_method = polling if cont_token: return LROPoller.from_continuation_token( polling_method=polling_method, continuation_token=cont_token, client=self._client, - deserialization_callback=get_long_running_output + deserialization_callback=get_long_running_output, ) return LROPoller(self._client, raw_result, get_long_running_output, polling_method) - begin_delete_at_subscription_scope.metadata = {'url': "/subscriptions/{subscriptionId}/providers/Microsoft.Resources/deployments/{deploymentName}"} # type: ignore + begin_delete_at_subscription_scope.metadata = {"url": "/subscriptions/{subscriptionId}/providers/Microsoft.Resources/deployments/{deploymentName}"} # type: ignore @distributed_trace - def check_existence_at_subscription_scope( - self, - deployment_name: str, - **kwargs: Any - ) -> bool: + def check_existence_at_subscription_scope(self, deployment_name: str, **kwargs: Any) -> bool: """Checks whether the deployment exists. - :param deployment_name: The name of the deployment. + :param deployment_name: The name of the deployment. Required. :type deployment_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: bool, or the result of cls(response) + :return: bool or the result of cls(response) :rtype: bool - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType[None] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) - api_version = kwargs.pop('api_version', "2019-05-10") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2019-05-10")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[None] - request = build_deployments_check_existence_at_subscription_scope_request( deployment_name=deployment_name, subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.check_existence_at_subscription_scope.metadata['url'], + template_url=self.check_existence_at_subscription_scope.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [204, 404]: @@ -3214,42 +3053,52 @@ def check_existence_at_subscription_scope( return cls(pipeline_response, None, {}) return 200 <= response.status_code <= 299 - check_existence_at_subscription_scope.metadata = {'url': "/subscriptions/{subscriptionId}/providers/Microsoft.Resources/deployments/{deploymentName}"} # type: ignore - + check_existence_at_subscription_scope.metadata = {"url": "/subscriptions/{subscriptionId}/providers/Microsoft.Resources/deployments/{deploymentName}"} # type: ignore def _create_or_update_at_subscription_scope_initial( - self, - deployment_name: str, - parameters: "_models.Deployment", - **kwargs: Any - ) -> "_models.DeploymentExtended": - cls = kwargs.pop('cls', None) # type: ClsType["_models.DeploymentExtended"] + self, deployment_name: str, parameters: Union[_models.Deployment, IO], **kwargs: Any + ) -> _models.DeploymentExtended: error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) - api_version = kwargs.pop('api_version', "2019-05-10") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - _json = self._serialize.body(parameters, 'Deployment') + api_version = kwargs.pop("api_version", _params.pop("api-version", "2019-05-10")) # type: str + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.DeploymentExtended] - request = build_deployments_create_or_update_at_subscription_scope_request_initial( + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(parameters, (IO, bytes)): + _content = parameters + else: + _json = self._serialize.body(parameters, "Deployment") + + request = build_deployments_create_or_update_at_subscription_scope_request( deployment_name=deployment_name, subscription_id=self._config.subscription_id, api_version=api_version, content_type=content_type, json=_json, - template_url=self._create_or_update_at_subscription_scope_initial.metadata['url'], + content=_content, + template_url=self._create_or_update_at_subscription_scope_initial.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200, 201]: @@ -3257,34 +3106,38 @@ def _create_or_update_at_subscription_scope_initial( raise HttpResponseError(response=response, error_format=ARMErrorFormat) if response.status_code == 200: - deserialized = self._deserialize('DeploymentExtended', pipeline_response) + deserialized = self._deserialize("DeploymentExtended", pipeline_response) if response.status_code == 201: - deserialized = self._deserialize('DeploymentExtended', pipeline_response) + deserialized = self._deserialize("DeploymentExtended", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - _create_or_update_at_subscription_scope_initial.metadata = {'url': "/subscriptions/{subscriptionId}/providers/Microsoft.Resources/deployments/{deploymentName}"} # type: ignore + _create_or_update_at_subscription_scope_initial.metadata = {"url": "/subscriptions/{subscriptionId}/providers/Microsoft.Resources/deployments/{deploymentName}"} # type: ignore - - @distributed_trace + @overload def begin_create_or_update_at_subscription_scope( self, deployment_name: str, - parameters: "_models.Deployment", + parameters: _models.Deployment, + *, + content_type: str = "application/json", **kwargs: Any - ) -> LROPoller["_models.DeploymentExtended"]: + ) -> LROPoller[_models.DeploymentExtended]: """Deploys resources at subscription scope. You can provide the template and parameters directly in the request or link to JSON files. - :param deployment_name: The name of the deployment. + :param deployment_name: The name of the deployment. Required. :type deployment_name: str - :param parameters: Additional parameters supplied to the operation. + :param parameters: Additional parameters supplied to the operation. Required. :type parameters: ~azure.mgmt.resource.resources.v2019_05_10.models.Deployment + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str :keyword callable cls: A custom type or function that will be passed the direct response :keyword str continuation_token: A continuation token to restart a poller from a saved state. :keyword polling: By default, your polling method will be ARMPolling. Pass in False for this @@ -3297,109 +3150,172 @@ def begin_create_or_update_at_subscription_scope( cls(response) :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.resource.resources.v2019_05_10.models.DeploymentExtended] - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - api_version = kwargs.pop('api_version', "2019-05-10") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] - polling = kwargs.pop('polling', True) # type: Union[bool, PollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType["_models.DeploymentExtended"] - lro_delay = kwargs.pop( - 'polling_interval', - self._config.polling_interval - ) - cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] + + @overload + def begin_create_or_update_at_subscription_scope( + self, deployment_name: str, parameters: IO, *, content_type: str = "application/json", **kwargs: Any + ) -> LROPoller[_models.DeploymentExtended]: + """Deploys resources at subscription scope. + + You can provide the template and parameters directly in the request or link to JSON files. + + :param deployment_name: The name of the deployment. Required. + :type deployment_name: str + :param parameters: Additional parameters supplied to the operation. Required. + :type parameters: IO + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be ARMPolling. Pass in False for this + operation to not poll, or pass in your own initialized polling object for a personal polling + strategy. + :paramtype polling: bool or ~azure.core.polling.PollingMethod + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of LROPoller that returns either DeploymentExtended or the result of + cls(response) + :rtype: + ~azure.core.polling.LROPoller[~azure.mgmt.resource.resources.v2019_05_10.models.DeploymentExtended] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace + def begin_create_or_update_at_subscription_scope( + self, deployment_name: str, parameters: Union[_models.Deployment, IO], **kwargs: Any + ) -> LROPoller[_models.DeploymentExtended]: + """Deploys resources at subscription scope. + + You can provide the template and parameters directly in the request or link to JSON files. + + :param deployment_name: The name of the deployment. Required. + :type deployment_name: str + :param parameters: Additional parameters supplied to the operation. Is either a model type or a + IO type. Required. + :type parameters: ~azure.mgmt.resource.resources.v2019_05_10.models.Deployment or IO + :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. + Default value is None. + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be ARMPolling. Pass in False for this + operation to not poll, or pass in your own initialized polling object for a personal polling + strategy. + :paramtype polling: bool or ~azure.core.polling.PollingMethod + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of LROPoller that returns either DeploymentExtended or the result of + cls(response) + :rtype: + ~azure.core.polling.LROPoller[~azure.mgmt.resource.resources.v2019_05_10.models.DeploymentExtended] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _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", "2019-05-10")) # type: str + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.DeploymentExtended] + polling = kwargs.pop("polling", True) # type: Union[bool, PollingMethod] + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token = kwargs.pop("continuation_token", None) # type: Optional[str] if cont_token is None: - raw_result = self._create_or_update_at_subscription_scope_initial( + raw_result = self._create_or_update_at_subscription_scope_initial( # type: ignore deployment_name=deployment_name, parameters=parameters, api_version=api_version, content_type=content_type, - cls=lambda x,y,z: x, + cls=lambda x, y, z: x, + headers=_headers, + params=_params, **kwargs ) - kwargs.pop('error_map', None) + kwargs.pop("error_map", None) def get_long_running_output(pipeline_response): - response = pipeline_response.http_response - deserialized = self._deserialize('DeploymentExtended', pipeline_response) + deserialized = self._deserialize("DeploymentExtended", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - - if polling is True: polling_method = ARMPolling(lro_delay, **kwargs) - elif polling is False: polling_method = NoPolling() - else: polling_method = polling + if polling is True: + polling_method = cast(PollingMethod, ARMPolling(lro_delay, **kwargs)) # type: PollingMethod + elif polling is False: + polling_method = cast(PollingMethod, NoPolling()) + else: + polling_method = polling if cont_token: return LROPoller.from_continuation_token( polling_method=polling_method, continuation_token=cont_token, client=self._client, - deserialization_callback=get_long_running_output + deserialization_callback=get_long_running_output, ) return LROPoller(self._client, raw_result, get_long_running_output, polling_method) - begin_create_or_update_at_subscription_scope.metadata = {'url': "/subscriptions/{subscriptionId}/providers/Microsoft.Resources/deployments/{deploymentName}"} # type: ignore + begin_create_or_update_at_subscription_scope.metadata = {"url": "/subscriptions/{subscriptionId}/providers/Microsoft.Resources/deployments/{deploymentName}"} # type: ignore @distributed_trace - def get_at_subscription_scope( - self, - deployment_name: str, - **kwargs: Any - ) -> "_models.DeploymentExtended": + def get_at_subscription_scope(self, deployment_name: str, **kwargs: Any) -> _models.DeploymentExtended: """Gets a deployment. - :param deployment_name: The name of the deployment. + :param deployment_name: The name of the deployment. Required. :type deployment_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: DeploymentExtended, or the result of cls(response) + :return: DeploymentExtended or the result of cls(response) :rtype: ~azure.mgmt.resource.resources.v2019_05_10.models.DeploymentExtended - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.DeploymentExtended"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + 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', "2019-05-10") # type: str + api_version = kwargs.pop("api_version", _params.pop("api-version", "2019-05-10")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[_models.DeploymentExtended] - request = build_deployments_get_at_subscription_scope_request( deployment_name=deployment_name, subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.get_at_subscription_scope.metadata['url'], + template_url=self.get_at_subscription_scope.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) - deserialized = self._deserialize('DeploymentExtended', pipeline_response) + deserialized = self._deserialize("DeploymentExtended", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - get_at_subscription_scope.metadata = {'url': "/subscriptions/{subscriptionId}/providers/Microsoft.Resources/deployments/{deploymentName}"} # type: ignore - + get_at_subscription_scope.metadata = {"url": "/subscriptions/{subscriptionId}/providers/Microsoft.Resources/deployments/{deploymentName}"} # type: ignore @distributed_trace def cancel_at_subscription_scope( # pylint: disable=inconsistent-return-statements - self, - deployment_name: str, - **kwargs: Any + self, deployment_name: str, **kwargs: Any ) -> None: """Cancels a currently running template deployment. @@ -3408,36 +3324,42 @@ def cancel_at_subscription_scope( # pylint: disable=inconsistent-return-stateme deployment stops the currently running template deployment and leaves the resources partially deployed. - :param deployment_name: The name of the deployment. + :param deployment_name: The name of the deployment. Required. :type deployment_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: None, or the result of cls(response) + :return: None or the result of cls(response) :rtype: None - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType[None] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + 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', "2019-05-10") # type: str + api_version = kwargs.pop("api_version", _params.pop("api-version", "2019-05-10")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[None] - request = build_deployments_cancel_at_subscription_scope_request( deployment_name=deployment_name, subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.cancel_at_subscription_scope.metadata['url'], + template_url=self.cancel_at_subscription_scope.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [204]: @@ -3447,38 +3369,94 @@ def cancel_at_subscription_scope( # pylint: disable=inconsistent-return-stateme if cls: return cls(pipeline_response, None, {}) - cancel_at_subscription_scope.metadata = {'url': "/subscriptions/{subscriptionId}/providers/Microsoft.Resources/deployments/{deploymentName}/cancel"} # type: ignore - + cancel_at_subscription_scope.metadata = {"url": "/subscriptions/{subscriptionId}/providers/Microsoft.Resources/deployments/{deploymentName}/cancel"} # type: ignore - @distributed_trace + @overload def validate_at_subscription_scope( self, deployment_name: str, - parameters: "_models.Deployment", + parameters: _models.Deployment, + *, + content_type: str = "application/json", **kwargs: Any - ) -> "_models.DeploymentValidateResult": + ) -> _models.DeploymentValidateResult: """Validates whether the specified template is syntactically correct and will be accepted by Azure Resource Manager.. - :param deployment_name: The name of the deployment. + :param deployment_name: The name of the deployment. Required. :type deployment_name: str - :param parameters: Parameters to validate. + :param parameters: Parameters to validate. Required. :type parameters: ~azure.mgmt.resource.resources.v2019_05_10.models.Deployment + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: DeploymentValidateResult or the result of cls(response) + :rtype: ~azure.mgmt.resource.resources.v2019_05_10.models.DeploymentValidateResult + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + def validate_at_subscription_scope( + self, deployment_name: str, parameters: IO, *, content_type: str = "application/json", **kwargs: Any + ) -> _models.DeploymentValidateResult: + """Validates whether the specified template is syntactically correct and will be accepted by Azure + Resource Manager.. + + :param deployment_name: The name of the deployment. Required. + :type deployment_name: str + :param parameters: Parameters to validate. Required. + :type parameters: IO + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: DeploymentValidateResult or the result of cls(response) + :rtype: ~azure.mgmt.resource.resources.v2019_05_10.models.DeploymentValidateResult + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace + def validate_at_subscription_scope( + self, deployment_name: str, parameters: Union[_models.Deployment, IO], **kwargs: Any + ) -> _models.DeploymentValidateResult: + """Validates whether the specified template is syntactically correct and will be accepted by Azure + Resource Manager.. + + :param deployment_name: The name of the deployment. Required. + :type deployment_name: str + :param parameters: Parameters to validate. Is either a model type or a IO type. Required. + :type parameters: ~azure.mgmt.resource.resources.v2019_05_10.models.Deployment or IO + :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. + Default value is None. + :paramtype content_type: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: DeploymentValidateResult, or the result of cls(response) + :return: DeploymentValidateResult or the result of cls(response) :rtype: ~azure.mgmt.resource.resources.v2019_05_10.models.DeploymentValidateResult - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.DeploymentValidateResult"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', "2019-05-10") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + api_version = kwargs.pop("api_version", _params.pop("api-version", "2019-05-10")) # type: str + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.DeploymentValidateResult] - _json = self._serialize.body(parameters, 'Deployment') + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(parameters, (IO, bytes)): + _content = parameters + else: + _json = self._serialize.body(parameters, "Deployment") request = build_deployments_validate_at_subscription_scope_request( deployment_name=deployment_name, @@ -3486,16 +3464,18 @@ def validate_at_subscription_scope( api_version=api_version, content_type=content_type, json=_json, - template_url=self.validate_at_subscription_scope.metadata['url'], + content=_content, + template_url=self.validate_at_subscription_scope.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200, 400]: @@ -3503,80 +3483,79 @@ def validate_at_subscription_scope( raise HttpResponseError(response=response, error_format=ARMErrorFormat) if response.status_code == 200: - deserialized = self._deserialize('DeploymentValidateResult', pipeline_response) + deserialized = self._deserialize("DeploymentValidateResult", pipeline_response) if response.status_code == 400: - deserialized = self._deserialize('DeploymentValidateResult', pipeline_response) + deserialized = self._deserialize("DeploymentValidateResult", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - validate_at_subscription_scope.metadata = {'url': "/subscriptions/{subscriptionId}/providers/Microsoft.Resources/deployments/{deploymentName}/validate"} # type: ignore - + validate_at_subscription_scope.metadata = {"url": "/subscriptions/{subscriptionId}/providers/Microsoft.Resources/deployments/{deploymentName}/validate"} # type: ignore @distributed_trace def export_template_at_subscription_scope( - self, - deployment_name: str, - **kwargs: Any - ) -> "_models.DeploymentExportResult": + self, deployment_name: str, **kwargs: Any + ) -> _models.DeploymentExportResult: """Exports the template used for specified deployment. - :param deployment_name: The name of the deployment. + :param deployment_name: The name of the deployment. Required. :type deployment_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: DeploymentExportResult, or the result of cls(response) + :return: DeploymentExportResult or the result of cls(response) :rtype: ~azure.mgmt.resource.resources.v2019_05_10.models.DeploymentExportResult - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.DeploymentExportResult"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + 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', "2019-05-10") # type: str + api_version = kwargs.pop("api_version", _params.pop("api-version", "2019-05-10")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[_models.DeploymentExportResult] - request = build_deployments_export_template_at_subscription_scope_request( deployment_name=deployment_name, subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.export_template_at_subscription_scope.metadata['url'], + template_url=self.export_template_at_subscription_scope.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) - deserialized = self._deserialize('DeploymentExportResult', pipeline_response) + deserialized = self._deserialize("DeploymentExportResult", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - export_template_at_subscription_scope.metadata = {'url': "/subscriptions/{subscriptionId}/providers/Microsoft.Resources/deployments/{deploymentName}/exportTemplate"} # type: ignore - + export_template_at_subscription_scope.metadata = {"url": "/subscriptions/{subscriptionId}/providers/Microsoft.Resources/deployments/{deploymentName}/exportTemplate"} # type: ignore @distributed_trace def list_at_subscription_scope( - self, - filter: Optional[str] = None, - top: Optional[int] = None, - **kwargs: Any - ) -> Iterable["_models.DeploymentListResult"]: + self, filter: Optional[str] = None, top: Optional[int] = None, **kwargs: Any + ) -> Iterable["_models.DeploymentExtended"]: """Get all the deployments for a subscription. :param filter: The filter to apply on the operation. For example, you can use @@ -3586,40 +3565,48 @@ def list_at_subscription_scope( value is None. :type top: int :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either DeploymentListResult or the result of - cls(response) + :return: An iterator like instance of either DeploymentExtended or the result of cls(response) :rtype: - ~azure.core.paging.ItemPaged[~azure.mgmt.resource.resources.v2019_05_10.models.DeploymentListResult] - :raises: ~azure.core.exceptions.HttpResponseError + ~azure.core.paging.ItemPaged[~azure.mgmt.resource.resources.v2019_05_10.models.DeploymentExtended] + :raises ~azure.core.exceptions.HttpResponseError: """ - api_version = kwargs.pop('api_version', "2019-05-10") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2019-05-10")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[_models.DeploymentListResult] - cls = kwargs.pop('cls', None) # type: ClsType["_models.DeploymentListResult"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) + def prepare_request(next_link=None): if not next_link: - + request = build_deployments_list_at_subscription_scope_request( subscription_id=self._config.subscription_id, - api_version=api_version, filter=filter, top=top, - template_url=self.list_at_subscription_scope.metadata['url'], + api_version=api_version, + template_url=self.list_at_subscription_scope.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore else: - - request = build_deployments_list_at_subscription_scope_request( - subscription_id=self._config.subscription_id, - template_url=next_link, - ) + # make call to next link with the client's api-version + _parsed_next_link = urlparse(next_link) + _next_request_params = case_insensitive_dict(parse_qs(_parsed_next_link.query)) + _next_request_params["api-version"] = self._config.api_version + request = HttpRequest("GET", urljoin(next_link, _parsed_next_link.path), params=_next_request_params) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore request.method = "GET" return request @@ -3633,10 +3620,8 @@ def extract_data(pipeline_response): def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) response = pipeline_response.http_response @@ -3646,42 +3631,43 @@ def get_next(next_link=None): return pipeline_response + return ItemPaged(get_next, extract_data) - return ItemPaged( - get_next, extract_data - ) - list_at_subscription_scope.metadata = {'url': "/subscriptions/{subscriptionId}/providers/Microsoft.Resources/deployments/"} # type: ignore + list_at_subscription_scope.metadata = {"url": "/subscriptions/{subscriptionId}/providers/Microsoft.Resources/deployments/"} # type: ignore def _delete_initial( # pylint: disable=inconsistent-return-statements - self, - resource_group_name: str, - deployment_name: str, - **kwargs: Any + self, resource_group_name: str, deployment_name: str, **kwargs: Any ) -> None: - cls = kwargs.pop('cls', None) # type: ClsType[None] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + 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', "2019-05-10") # type: str + api_version = kwargs.pop("api_version", _params.pop("api-version", "2019-05-10")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[None] - - request = build_deployments_delete_request_initial( + request = build_deployments_delete_request( resource_group_name=resource_group_name, deployment_name=deployment_name, subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self._delete_initial.metadata['url'], + template_url=self._delete_initial.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [202, 204]: @@ -3691,16 +3677,10 @@ 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.Resources/deployments/{deploymentName}"} # type: ignore - + _delete_initial.metadata = {"url": "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/Microsoft.Resources/deployments/{deploymentName}"} # type: ignore @distributed_trace - def begin_delete( # pylint: disable=inconsistent-return-statements - self, - resource_group_name: str, - deployment_name: str, - **kwargs: Any - ) -> LROPoller[None]: + def begin_delete(self, resource_group_name: str, deployment_name: str, **kwargs: Any) -> LROPoller[None]: """Deletes a deployment from the deployment history. A template deployment that is currently running cannot be deleted. Deleting a template @@ -3713,9 +3693,9 @@ def begin_delete( # pylint: disable=inconsistent-return-statements asynchronous request failed, the URI in the Location header returns an error-level status code. :param resource_group_name: The name of the resource group with the deployment to delete. The - name is case insensitive. + name is case insensitive. Required. :type resource_group_name: str - :param deployment_name: The name of the deployment. + :param deployment_name: The name of the deployment. Required. :type deployment_name: str :keyword callable cls: A custom type or function that will be passed the direct response :keyword str continuation_token: A continuation token to restart a poller from a saved state. @@ -3727,88 +3707,93 @@ def begin_delete( # pylint: disable=inconsistent-return-statements Retry-After header is present. :return: An instance of LROPoller that returns either None or the result of cls(response) :rtype: ~azure.core.polling.LROPoller[None] - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - api_version = kwargs.pop('api_version', "2019-05-10") # type: str - polling = kwargs.pop('polling', True) # type: Union[bool, PollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType[None] - lro_delay = kwargs.pop( - 'polling_interval', - self._config.polling_interval - ) - cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2019-05-10")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[None] + polling = kwargs.pop("polling", True) # type: Union[bool, PollingMethod] + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token = kwargs.pop("continuation_token", None) # type: Optional[str] if cont_token is None: - raw_result = self._delete_initial( + raw_result = self._delete_initial( # type: ignore resource_group_name=resource_group_name, deployment_name=deployment_name, api_version=api_version, - cls=lambda x,y,z: x, + cls=lambda x, y, z: x, + headers=_headers, + params=_params, **kwargs ) - kwargs.pop('error_map', None) + kwargs.pop("error_map", None) - def get_long_running_output(pipeline_response): + def get_long_running_output(pipeline_response): # pylint: disable=inconsistent-return-statements if cls: return cls(pipeline_response, None, {}) - - if polling is True: polling_method = ARMPolling(lro_delay, **kwargs) - elif polling is False: polling_method = NoPolling() - else: polling_method = polling + if polling is True: + polling_method = cast(PollingMethod, ARMPolling(lro_delay, **kwargs)) # type: PollingMethod + elif polling is False: + polling_method = cast(PollingMethod, NoPolling()) + else: + polling_method = polling if cont_token: return LROPoller.from_continuation_token( polling_method=polling_method, continuation_token=cont_token, client=self._client, - deserialization_callback=get_long_running_output + deserialization_callback=get_long_running_output, ) return LROPoller(self._client, raw_result, get_long_running_output, polling_method) - begin_delete.metadata = {'url': "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/Microsoft.Resources/deployments/{deploymentName}"} # type: ignore + begin_delete.metadata = {"url": "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/Microsoft.Resources/deployments/{deploymentName}"} # type: ignore @distributed_trace - def check_existence( - self, - resource_group_name: str, - deployment_name: str, - **kwargs: Any - ) -> bool: + def check_existence(self, resource_group_name: str, deployment_name: str, **kwargs: Any) -> bool: """Checks whether the deployment exists. :param resource_group_name: The name of the resource group with the deployment to check. The - name is case insensitive. + name is case insensitive. Required. :type resource_group_name: str - :param deployment_name: The name of the deployment. + :param deployment_name: The name of the deployment. Required. :type deployment_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: bool, or the result of cls(response) + :return: bool or the result of cls(response) :rtype: bool - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType[None] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) - api_version = kwargs.pop('api_version', "2019-05-10") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2019-05-10")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[None] - request = build_deployments_check_existence_request( resource_group_name=resource_group_name, deployment_name=deployment_name, subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.check_existence.metadata['url'], + template_url=self.check_existence.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [204, 404]: @@ -3819,44 +3804,53 @@ def check_existence( return cls(pipeline_response, None, {}) return 200 <= response.status_code <= 299 - check_existence.metadata = {'url': "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/Microsoft.Resources/deployments/{deploymentName}"} # type: ignore - + check_existence.metadata = {"url": "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/Microsoft.Resources/deployments/{deploymentName}"} # type: ignore def _create_or_update_initial( - self, - resource_group_name: str, - deployment_name: str, - parameters: "_models.Deployment", - **kwargs: Any - ) -> "_models.DeploymentExtended": - cls = kwargs.pop('cls', None) # type: ClsType["_models.DeploymentExtended"] + self, resource_group_name: str, deployment_name: str, parameters: Union[_models.Deployment, IO], **kwargs: Any + ) -> _models.DeploymentExtended: error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', "2019-05-10") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + api_version = kwargs.pop("api_version", _params.pop("api-version", "2019-05-10")) # type: str + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.DeploymentExtended] - _json = self._serialize.body(parameters, 'Deployment') + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(parameters, (IO, bytes)): + _content = parameters + else: + _json = self._serialize.body(parameters, "Deployment") - request = build_deployments_create_or_update_request_initial( + request = build_deployments_create_or_update_request( resource_group_name=resource_group_name, deployment_name=deployment_name, subscription_id=self._config.subscription_id, api_version=api_version, content_type=content_type, json=_json, - template_url=self._create_or_update_initial.metadata['url'], + content=_content, + template_url=self._create_or_update_initial.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200, 201]: @@ -3864,38 +3858,42 @@ def _create_or_update_initial( raise HttpResponseError(response=response, error_format=ARMErrorFormat) if response.status_code == 200: - deserialized = self._deserialize('DeploymentExtended', pipeline_response) + deserialized = self._deserialize("DeploymentExtended", pipeline_response) if response.status_code == 201: - deserialized = self._deserialize('DeploymentExtended', pipeline_response) + deserialized = self._deserialize("DeploymentExtended", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - _create_or_update_initial.metadata = {'url': "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/Microsoft.Resources/deployments/{deploymentName}"} # type: ignore - + _create_or_update_initial.metadata = {"url": "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/Microsoft.Resources/deployments/{deploymentName}"} # type: ignore - @distributed_trace + @overload def begin_create_or_update( self, resource_group_name: str, deployment_name: str, - parameters: "_models.Deployment", + parameters: _models.Deployment, + *, + content_type: str = "application/json", **kwargs: Any - ) -> LROPoller["_models.DeploymentExtended"]: + ) -> LROPoller[_models.DeploymentExtended]: """Deploys resources to a resource group. You can provide the template and parameters directly in the request or link to JSON files. :param resource_group_name: The name of the resource group to deploy the resources to. The name - is case insensitive. The resource group must already exist. + is case insensitive. The resource group must already exist. Required. :type resource_group_name: str - :param deployment_name: The name of the deployment. + :param deployment_name: The name of the deployment. Required. :type deployment_name: str - :param parameters: Additional parameters supplied to the operation. + :param parameters: Additional parameters supplied to the operation. Required. :type parameters: ~azure.mgmt.resource.resources.v2019_05_10.models.Deployment + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str :keyword callable cls: A custom type or function that will be passed the direct response :keyword str continuation_token: A continuation token to restart a poller from a saved state. :keyword polling: By default, your polling method will be ARMPolling. Pass in False for this @@ -3908,115 +3906,189 @@ def begin_create_or_update( cls(response) :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.resource.resources.v2019_05_10.models.DeploymentExtended] - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - api_version = kwargs.pop('api_version', "2019-05-10") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] - polling = kwargs.pop('polling', True) # type: Union[bool, PollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType["_models.DeploymentExtended"] - lro_delay = kwargs.pop( - 'polling_interval', - self._config.polling_interval - ) - cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] + + @overload + def begin_create_or_update( + self, + resource_group_name: str, + deployment_name: str, + parameters: IO, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> LROPoller[_models.DeploymentExtended]: + """Deploys resources to a resource group. + + You can provide the template and parameters directly in the request or link to JSON files. + + :param resource_group_name: The name of the resource group to deploy the resources to. The name + is case insensitive. The resource group must already exist. Required. + :type resource_group_name: str + :param deployment_name: The name of the deployment. Required. + :type deployment_name: str + :param parameters: Additional parameters supplied to the operation. Required. + :type parameters: IO + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be ARMPolling. Pass in False for this + operation to not poll, or pass in your own initialized polling object for a personal polling + strategy. + :paramtype polling: bool or ~azure.core.polling.PollingMethod + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of LROPoller that returns either DeploymentExtended or the result of + cls(response) + :rtype: + ~azure.core.polling.LROPoller[~azure.mgmt.resource.resources.v2019_05_10.models.DeploymentExtended] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace + def begin_create_or_update( + self, resource_group_name: str, deployment_name: str, parameters: Union[_models.Deployment, IO], **kwargs: Any + ) -> LROPoller[_models.DeploymentExtended]: + """Deploys resources to a resource group. + + You can provide the template and parameters directly in the request or link to JSON files. + + :param resource_group_name: The name of the resource group to deploy the resources to. The name + is case insensitive. The resource group must already exist. Required. + :type resource_group_name: str + :param deployment_name: The name of the deployment. Required. + :type deployment_name: str + :param parameters: Additional parameters supplied to the operation. Is either a model type or a + IO type. Required. + :type parameters: ~azure.mgmt.resource.resources.v2019_05_10.models.Deployment or IO + :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. + Default value is None. + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be ARMPolling. Pass in False for this + operation to not poll, or pass in your own initialized polling object for a personal polling + strategy. + :paramtype polling: bool or ~azure.core.polling.PollingMethod + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of LROPoller that returns either DeploymentExtended or the result of + cls(response) + :rtype: + ~azure.core.polling.LROPoller[~azure.mgmt.resource.resources.v2019_05_10.models.DeploymentExtended] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _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", "2019-05-10")) # type: str + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.DeploymentExtended] + polling = kwargs.pop("polling", True) # type: Union[bool, PollingMethod] + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token = kwargs.pop("continuation_token", None) # type: Optional[str] if cont_token is None: - raw_result = self._create_or_update_initial( + raw_result = self._create_or_update_initial( # type: ignore resource_group_name=resource_group_name, deployment_name=deployment_name, parameters=parameters, api_version=api_version, content_type=content_type, - cls=lambda x,y,z: x, + cls=lambda x, y, z: x, + headers=_headers, + params=_params, **kwargs ) - kwargs.pop('error_map', None) + kwargs.pop("error_map", None) def get_long_running_output(pipeline_response): - response = pipeline_response.http_response - deserialized = self._deserialize('DeploymentExtended', pipeline_response) + deserialized = self._deserialize("DeploymentExtended", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - - if polling is True: polling_method = ARMPolling(lro_delay, **kwargs) - elif polling is False: polling_method = NoPolling() - else: polling_method = polling + if polling is True: + polling_method = cast(PollingMethod, ARMPolling(lro_delay, **kwargs)) # type: PollingMethod + elif polling is False: + polling_method = cast(PollingMethod, NoPolling()) + else: + polling_method = polling if cont_token: return LROPoller.from_continuation_token( polling_method=polling_method, continuation_token=cont_token, client=self._client, - deserialization_callback=get_long_running_output + deserialization_callback=get_long_running_output, ) return LROPoller(self._client, raw_result, get_long_running_output, polling_method) - begin_create_or_update.metadata = {'url': "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/Microsoft.Resources/deployments/{deploymentName}"} # type: ignore + begin_create_or_update.metadata = {"url": "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/Microsoft.Resources/deployments/{deploymentName}"} # type: ignore @distributed_trace - def get( - self, - resource_group_name: str, - deployment_name: str, - **kwargs: Any - ) -> "_models.DeploymentExtended": + def get(self, resource_group_name: str, deployment_name: str, **kwargs: Any) -> _models.DeploymentExtended: """Gets a deployment. :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. :type resource_group_name: str - :param deployment_name: The name of the deployment. + :param deployment_name: The name of the deployment. Required. :type deployment_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: DeploymentExtended, or the result of cls(response) + :return: DeploymentExtended or the result of cls(response) :rtype: ~azure.mgmt.resource.resources.v2019_05_10.models.DeploymentExtended - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.DeploymentExtended"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + 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', "2019-05-10") # type: str + api_version = kwargs.pop("api_version", _params.pop("api-version", "2019-05-10")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[_models.DeploymentExtended] - request = build_deployments_get_request( resource_group_name=resource_group_name, deployment_name=deployment_name, subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.get.metadata['url'], + template_url=self.get.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) - deserialized = self._deserialize('DeploymentExtended', pipeline_response) + deserialized = self._deserialize("DeploymentExtended", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - get.metadata = {'url': "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/Microsoft.Resources/deployments/{deploymentName}"} # type: ignore - + get.metadata = {"url": "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/Microsoft.Resources/deployments/{deploymentName}"} # type: ignore @distributed_trace def cancel( # pylint: disable=inconsistent-return-statements - self, - resource_group_name: str, - deployment_name: str, - **kwargs: Any + self, resource_group_name: str, deployment_name: str, **kwargs: Any ) -> None: """Cancels a currently running template deployment. @@ -4026,38 +4098,45 @@ def cancel( # pylint: disable=inconsistent-return-statements partially deployed. :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. :type resource_group_name: str - :param deployment_name: The name of the deployment. + :param deployment_name: The name of the deployment. Required. :type deployment_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: None, or the result of cls(response) + :return: None or the result of cls(response) :rtype: None - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType[None] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) - api_version = kwargs.pop('api_version', "2019-05-10") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2019-05-10")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[None] - request = build_deployments_cancel_request( resource_group_name=resource_group_name, deployment_name=deployment_name, subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.cancel.metadata['url'], + template_url=self.cancel.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [204]: @@ -4067,60 +4146,130 @@ def cancel( # pylint: disable=inconsistent-return-statements if cls: return cls(pipeline_response, None, {}) - cancel.metadata = {'url': "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/Microsoft.Resources/deployments/{deploymentName}/cancel"} # type: ignore + cancel.metadata = {"url": "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/Microsoft.Resources/deployments/{deploymentName}/cancel"} # type: ignore - - @distributed_trace + @overload def validate( self, resource_group_name: str, deployment_name: str, - parameters: "_models.Deployment", + parameters: _models.Deployment, + *, + content_type: str = "application/json", **kwargs: Any - ) -> "_models.DeploymentValidateResult": + ) -> _models.DeploymentValidateResult: """Validates whether the specified template is syntactically correct and will be accepted by Azure Resource Manager.. :param resource_group_name: The name of the resource group the template will be deployed to. - The name is case insensitive. + The name is case insensitive. Required. :type resource_group_name: str - :param deployment_name: The name of the deployment. + :param deployment_name: The name of the deployment. Required. :type deployment_name: str - :param parameters: Parameters to validate. + :param parameters: Parameters to validate. Required. :type parameters: ~azure.mgmt.resource.resources.v2019_05_10.models.Deployment + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: DeploymentValidateResult, or the result of cls(response) + :return: DeploymentValidateResult or the result of cls(response) :rtype: ~azure.mgmt.resource.resources.v2019_05_10.models.DeploymentValidateResult - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.DeploymentValidateResult"] - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {})) - api_version = kwargs.pop('api_version', "2019-05-10") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + @overload + def validate( + self, + resource_group_name: str, + deployment_name: str, + parameters: IO, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.DeploymentValidateResult: + """Validates whether the specified template is syntactically correct and will be accepted by Azure + Resource Manager.. - _json = self._serialize.body(parameters, 'Deployment') + :param resource_group_name: The name of the resource group the template will be deployed to. + The name is case insensitive. Required. + :type resource_group_name: str + :param deployment_name: The name of the deployment. Required. + :type deployment_name: str + :param parameters: Parameters to validate. Required. + :type parameters: IO + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: DeploymentValidateResult or the result of cls(response) + :rtype: ~azure.mgmt.resource.resources.v2019_05_10.models.DeploymentValidateResult + :raises ~azure.core.exceptions.HttpResponseError: + """ - request = build_deployments_validate_request( + @distributed_trace + def validate( + self, resource_group_name: str, deployment_name: str, parameters: Union[_models.Deployment, IO], **kwargs: Any + ) -> _models.DeploymentValidateResult: + """Validates whether the specified template is syntactically correct and will be accepted by Azure + Resource Manager.. + + :param resource_group_name: The name of the resource group the template will be deployed to. + The name is case insensitive. Required. + :type resource_group_name: str + :param deployment_name: The name of the deployment. Required. + :type deployment_name: str + :param parameters: Parameters to validate. Is either a model type or a IO type. Required. + :type parameters: ~azure.mgmt.resource.resources.v2019_05_10.models.Deployment or IO + :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. + Default value is None. + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: DeploymentValidateResult or the result of cls(response) + :rtype: ~azure.mgmt.resource.resources.v2019_05_10.models.DeploymentValidateResult + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2019-05-10")) # type: str + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.DeploymentValidateResult] + + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(parameters, (IO, bytes)): + _content = parameters + else: + _json = self._serialize.body(parameters, "Deployment") + + request = build_deployments_validate_request( resource_group_name=resource_group_name, deployment_name=deployment_name, subscription_id=self._config.subscription_id, api_version=api_version, content_type=content_type, json=_json, - template_url=self.validate.metadata['url'], + content=_content, + template_url=self.validate.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200, 400]: @@ -4128,89 +4277,87 @@ def validate( raise HttpResponseError(response=response, error_format=ARMErrorFormat) if response.status_code == 200: - deserialized = self._deserialize('DeploymentValidateResult', pipeline_response) + deserialized = self._deserialize("DeploymentValidateResult", pipeline_response) if response.status_code == 400: - deserialized = self._deserialize('DeploymentValidateResult', pipeline_response) + deserialized = self._deserialize("DeploymentValidateResult", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - validate.metadata = {'url': "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/Microsoft.Resources/deployments/{deploymentName}/validate"} # type: ignore - + validate.metadata = {"url": "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/Microsoft.Resources/deployments/{deploymentName}/validate"} # type: ignore @distributed_trace def export_template( - self, - resource_group_name: str, - deployment_name: str, - **kwargs: Any - ) -> "_models.DeploymentExportResult": + self, resource_group_name: str, deployment_name: str, **kwargs: Any + ) -> _models.DeploymentExportResult: """Exports the template used for specified deployment. :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. :type resource_group_name: str - :param deployment_name: The name of the deployment. + :param deployment_name: The name of the deployment. Required. :type deployment_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: DeploymentExportResult, or the result of cls(response) + :return: DeploymentExportResult or the result of cls(response) :rtype: ~azure.mgmt.resource.resources.v2019_05_10.models.DeploymentExportResult - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.DeploymentExportResult"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + 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', "2019-05-10") # type: str + api_version = kwargs.pop("api_version", _params.pop("api-version", "2019-05-10")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[_models.DeploymentExportResult] - request = build_deployments_export_template_request( resource_group_name=resource_group_name, deployment_name=deployment_name, subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.export_template.metadata['url'], + template_url=self.export_template.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) - deserialized = self._deserialize('DeploymentExportResult', pipeline_response) + deserialized = self._deserialize("DeploymentExportResult", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - export_template.metadata = {'url': "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/Microsoft.Resources/deployments/{deploymentName}/exportTemplate"} # type: ignore - + export_template.metadata = {"url": "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/Microsoft.Resources/deployments/{deploymentName}/exportTemplate"} # type: ignore @distributed_trace def list_by_resource_group( - self, - resource_group_name: str, - filter: Optional[str] = None, - top: Optional[int] = None, - **kwargs: Any - ) -> Iterable["_models.DeploymentListResult"]: + self, resource_group_name: str, filter: Optional[str] = None, top: Optional[int] = None, **kwargs: Any + ) -> Iterable["_models.DeploymentExtended"]: """Get all the deployments for a resource group. :param resource_group_name: The name of the resource group with the deployments to get. The - name is case insensitive. + name is case insensitive. Required. :type resource_group_name: str :param filter: The filter to apply on the operation. For example, you can use $filter=provisioningState eq '{state}'. Default value is None. @@ -4219,42 +4366,49 @@ def list_by_resource_group( value is None. :type top: int :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either DeploymentListResult or the result of - cls(response) + :return: An iterator like instance of either DeploymentExtended or the result of cls(response) :rtype: - ~azure.core.paging.ItemPaged[~azure.mgmt.resource.resources.v2019_05_10.models.DeploymentListResult] - :raises: ~azure.core.exceptions.HttpResponseError + ~azure.core.paging.ItemPaged[~azure.mgmt.resource.resources.v2019_05_10.models.DeploymentExtended] + :raises ~azure.core.exceptions.HttpResponseError: """ - api_version = kwargs.pop('api_version', "2019-05-10") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2019-05-10")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[_models.DeploymentListResult] - cls = kwargs.pop('cls', None) # type: ClsType["_models.DeploymentListResult"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) + def prepare_request(next_link=None): if not next_link: - + request = build_deployments_list_by_resource_group_request( resource_group_name=resource_group_name, subscription_id=self._config.subscription_id, - api_version=api_version, filter=filter, top=top, - template_url=self.list_by_resource_group.metadata['url'], + 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.url = self._client.format_url(request.url) # type: ignore else: - - request = build_deployments_list_by_resource_group_request( - resource_group_name=resource_group_name, - subscription_id=self._config.subscription_id, - template_url=next_link, - ) + # make call to next link with the client's api-version + _parsed_next_link = urlparse(next_link) + _next_request_params = case_insensitive_dict(parse_qs(_parsed_next_link.query)) + _next_request_params["api-version"] = self._config.api_version + request = HttpRequest("GET", urljoin(next_link, _parsed_next_link.path), params=_next_request_params) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore request.method = "GET" return request @@ -4268,10 +4422,8 @@ def extract_data(pipeline_response): def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) response = pipeline_response.http_response @@ -4281,204 +4433,204 @@ def get_next(next_link=None): return pipeline_response + return ItemPaged(get_next, extract_data) - return ItemPaged( - get_next, extract_data - ) - list_by_resource_group.metadata = {'url': "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/Microsoft.Resources/deployments/"} # type: ignore + list_by_resource_group.metadata = {"url": "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/Microsoft.Resources/deployments/"} # type: ignore @distributed_trace - def calculate_template_hash( - self, - template: Any, - **kwargs: Any - ) -> "_models.TemplateHashResult": + def calculate_template_hash(self, template: JSON, **kwargs: Any) -> _models.TemplateHashResult: """Calculate the hash of the given template. - :param template: The template provided to calculate hash. - :type template: any + :param template: The template provided to calculate hash. Required. + :type template: JSON :keyword callable cls: A custom type or function that will be passed the direct response - :return: TemplateHashResult, or the result of cls(response) + :return: TemplateHashResult or the result of cls(response) :rtype: ~azure.mgmt.resource.resources.v2019_05_10.models.TemplateHashResult - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.TemplateHashResult"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', "2019-05-10") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + api_version = kwargs.pop("api_version", _params.pop("api-version", "2019-05-10")) # type: str + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", "application/json")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[_models.TemplateHashResult] - _json = self._serialize.body(template, 'object') + _json = self._serialize.body(template, "object") request = build_deployments_calculate_template_hash_request( api_version=api_version, content_type=content_type, json=_json, - template_url=self.calculate_template_hash.metadata['url'], + template_url=self.calculate_template_hash.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) - deserialized = self._deserialize('TemplateHashResult', pipeline_response) + deserialized = self._deserialize("TemplateHashResult", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - calculate_template_hash.metadata = {'url': "/providers/Microsoft.Resources/calculateTemplateHash"} # type: ignore + calculate_template_hash.metadata = {"url": "/providers/Microsoft.Resources/calculateTemplateHash"} # type: ignore -class ProvidersOperations(object): - """ProvidersOperations operations. - You should not instantiate this class directly. Instead, you should create a Client instance that - instantiates it for you and attaches it as an attribute. +class ProvidersOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. - :ivar models: Alias to model classes used in this operation group. - :type models: ~azure.mgmt.resource.resources.v2019_05_10.models - :param client: Client for service requests. - :param config: Configuration of service client. - :param serializer: An object model serializer. - :param deserializer: An object model deserializer. + Instead, you should access the following operations through + :class:`~azure.mgmt.resource.resources.v2019_05_10.ResourceManagementClient`'s + :attr:`providers` attribute. """ models = _models - def __init__(self, client, config, serializer, deserializer): - self._client = client - self._serialize = serializer - self._deserialize = deserializer - self._config = config + def __init__(self, *args, **kwargs): + input_args = list(args) + self._client = input_args.pop(0) if input_args else kwargs.pop("client") + self._config = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") @distributed_trace - def unregister( - self, - resource_provider_namespace: str, - **kwargs: Any - ) -> "_models.Provider": + def unregister(self, resource_provider_namespace: str, **kwargs: Any) -> _models.Provider: """Unregisters a subscription from a resource provider. :param resource_provider_namespace: The namespace of the resource provider to unregister. + Required. :type resource_provider_namespace: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: Provider, or the result of cls(response) + :return: Provider or the result of cls(response) :rtype: ~azure.mgmt.resource.resources.v2019_05_10.models.Provider - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.Provider"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + 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', "2019-05-10") # type: str + api_version = kwargs.pop("api_version", _params.pop("api-version", "2019-05-10")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[_models.Provider] - request = build_providers_unregister_request( resource_provider_namespace=resource_provider_namespace, subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.unregister.metadata['url'], + template_url=self.unregister.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) - deserialized = self._deserialize('Provider', pipeline_response) + deserialized = self._deserialize("Provider", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - unregister.metadata = {'url': "/subscriptions/{subscriptionId}/providers/{resourceProviderNamespace}/unregister"} # type: ignore - + unregister.metadata = {"url": "/subscriptions/{subscriptionId}/providers/{resourceProviderNamespace}/unregister"} # type: ignore @distributed_trace - def register( - self, - resource_provider_namespace: str, - **kwargs: Any - ) -> "_models.Provider": + def register(self, resource_provider_namespace: str, **kwargs: Any) -> _models.Provider: """Registers a subscription with a resource provider. :param resource_provider_namespace: The namespace of the resource provider to register. + Required. :type resource_provider_namespace: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: Provider, or the result of cls(response) + :return: Provider or the result of cls(response) :rtype: ~azure.mgmt.resource.resources.v2019_05_10.models.Provider - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.Provider"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + 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', "2019-05-10") # type: str + api_version = kwargs.pop("api_version", _params.pop("api-version", "2019-05-10")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[_models.Provider] - request = build_providers_register_request( resource_provider_namespace=resource_provider_namespace, subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.register.metadata['url'], + template_url=self.register.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) - deserialized = self._deserialize('Provider', pipeline_response) + deserialized = self._deserialize("Provider", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - register.metadata = {'url': "/subscriptions/{subscriptionId}/providers/{resourceProviderNamespace}/register"} # type: ignore - + register.metadata = {"url": "/subscriptions/{subscriptionId}/providers/{resourceProviderNamespace}/register"} # type: ignore @distributed_trace def list( - self, - top: Optional[int] = None, - expand: Optional[str] = None, - **kwargs: Any - ) -> Iterable["_models.ProviderListResult"]: + self, top: Optional[int] = None, expand: Optional[str] = None, **kwargs: Any + ) -> Iterable["_models.Provider"]: """Gets all resource providers for a subscription. :param top: The number of results to return. If null is passed returns all deployments. Default @@ -4489,39 +4641,48 @@ def list( response, use $expand=resourceTypes/aliases. Default value is None. :type expand: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either ProviderListResult or the result of cls(response) + :return: An iterator like instance of either Provider or the result of cls(response) :rtype: - ~azure.core.paging.ItemPaged[~azure.mgmt.resource.resources.v2019_05_10.models.ProviderListResult] - :raises: ~azure.core.exceptions.HttpResponseError + ~azure.core.paging.ItemPaged[~azure.mgmt.resource.resources.v2019_05_10.models.Provider] + :raises ~azure.core.exceptions.HttpResponseError: """ - api_version = kwargs.pop('api_version', "2019-05-10") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2019-05-10")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[_models.ProviderListResult] - cls = kwargs.pop('cls', None) # type: ClsType["_models.ProviderListResult"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) + def prepare_request(next_link=None): if not next_link: - + request = build_providers_list_request( subscription_id=self._config.subscription_id, - api_version=api_version, top=top, expand=expand, - template_url=self.list.metadata['url'], + 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.url = self._client.format_url(request.url) # type: ignore else: - - request = build_providers_list_request( - subscription_id=self._config.subscription_id, - template_url=next_link, - ) + # make call to next link with the client's api-version + _parsed_next_link = urlparse(next_link) + _next_request_params = case_insensitive_dict(parse_qs(_parsed_next_link.query)) + _next_request_params["api-version"] = self._config.api_version + request = HttpRequest("GET", urljoin(next_link, _parsed_next_link.path), params=_next_request_params) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore request.method = "GET" return request @@ -4535,10 +4696,8 @@ def extract_data(pipeline_response): def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) response = pipeline_response.http_response @@ -4548,19 +4707,14 @@ def get_next(next_link=None): return pipeline_response + return ItemPaged(get_next, extract_data) - return ItemPaged( - get_next, extract_data - ) - list.metadata = {'url': "/subscriptions/{subscriptionId}/providers"} # type: ignore + list.metadata = {"url": "/subscriptions/{subscriptionId}/providers"} # type: ignore @distributed_trace def list_at_tenant_scope( - self, - top: Optional[int] = None, - expand: Optional[str] = None, - **kwargs: Any - ) -> Iterable["_models.ProviderListResult"]: + self, top: Optional[int] = None, expand: Optional[str] = None, **kwargs: Any + ) -> Iterable["_models.Provider"]: """Gets all resource providers for the tenant. :param top: The number of results to return. If null is passed returns all providers. Default @@ -4571,37 +4725,47 @@ def list_at_tenant_scope( response, use $expand=resourceTypes/aliases. Default value is None. :type expand: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either ProviderListResult or the result of cls(response) + :return: An iterator like instance of either Provider or the result of cls(response) :rtype: - ~azure.core.paging.ItemPaged[~azure.mgmt.resource.resources.v2019_05_10.models.ProviderListResult] - :raises: ~azure.core.exceptions.HttpResponseError + ~azure.core.paging.ItemPaged[~azure.mgmt.resource.resources.v2019_05_10.models.Provider] + :raises ~azure.core.exceptions.HttpResponseError: """ - api_version = kwargs.pop('api_version', "2019-05-10") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2019-05-10")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[_models.ProviderListResult] - cls = kwargs.pop('cls', None) # type: ClsType["_models.ProviderListResult"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) + def prepare_request(next_link=None): if not next_link: - + request = build_providers_list_at_tenant_scope_request( - api_version=api_version, top=top, expand=expand, - template_url=self.list_at_tenant_scope.metadata['url'], + api_version=api_version, + template_url=self.list_at_tenant_scope.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore else: - - request = build_providers_list_at_tenant_scope_request( - template_url=next_link, - ) + # make call to next link with the client's api-version + _parsed_next_link = urlparse(next_link) + _next_request_params = case_insensitive_dict(parse_qs(_parsed_next_link.query)) + _next_request_params["api-version"] = self._config.api_version + request = HttpRequest("GET", urljoin(next_link, _parsed_next_link.path), params=_next_request_params) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore request.method = "GET" return request @@ -4615,10 +4779,8 @@ def extract_data(pipeline_response): def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) response = pipeline_response.http_response @@ -4628,149 +4790,148 @@ def get_next(next_link=None): return pipeline_response + return ItemPaged(get_next, extract_data) - return ItemPaged( - get_next, extract_data - ) - list_at_tenant_scope.metadata = {'url': "/providers"} # type: ignore + list_at_tenant_scope.metadata = {"url": "/providers"} # type: ignore @distributed_trace - def get( - self, - resource_provider_namespace: str, - expand: Optional[str] = None, - **kwargs: Any - ) -> "_models.Provider": + def get(self, resource_provider_namespace: str, expand: Optional[str] = None, **kwargs: Any) -> _models.Provider: """Gets the specified resource provider. - :param resource_provider_namespace: The namespace of the resource provider. + :param resource_provider_namespace: The namespace of the resource provider. Required. :type resource_provider_namespace: str :param expand: The $expand query parameter. For example, to include property aliases in response, use $expand=resourceTypes/aliases. Default value is None. :type expand: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: Provider, or the result of cls(response) + :return: Provider or the result of cls(response) :rtype: ~azure.mgmt.resource.resources.v2019_05_10.models.Provider - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.Provider"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) - api_version = kwargs.pop('api_version', "2019-05-10") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2019-05-10")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[_models.Provider] - request = build_providers_get_request( resource_provider_namespace=resource_provider_namespace, subscription_id=self._config.subscription_id, - api_version=api_version, expand=expand, - template_url=self.get.metadata['url'], + api_version=api_version, + template_url=self.get.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) - deserialized = self._deserialize('Provider', pipeline_response) + deserialized = self._deserialize("Provider", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - get.metadata = {'url': "/subscriptions/{subscriptionId}/providers/{resourceProviderNamespace}"} # type: ignore - + get.metadata = {"url": "/subscriptions/{subscriptionId}/providers/{resourceProviderNamespace}"} # type: ignore @distributed_trace def get_at_tenant_scope( - self, - resource_provider_namespace: str, - expand: Optional[str] = None, - **kwargs: Any - ) -> "_models.Provider": + self, resource_provider_namespace: str, expand: Optional[str] = None, **kwargs: Any + ) -> _models.Provider: """Gets the specified resource provider at the tenant level. - :param resource_provider_namespace: The namespace of the resource provider. + :param resource_provider_namespace: The namespace of the resource provider. Required. :type resource_provider_namespace: str :param expand: The $expand query parameter. For example, to include property aliases in response, use $expand=resourceTypes/aliases. Default value is None. :type expand: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: Provider, or the result of cls(response) + :return: Provider or the result of cls(response) :rtype: ~azure.mgmt.resource.resources.v2019_05_10.models.Provider - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.Provider"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + 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', "2019-05-10") # type: str + api_version = kwargs.pop("api_version", _params.pop("api-version", "2019-05-10")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[_models.Provider] - request = build_providers_get_at_tenant_scope_request( resource_provider_namespace=resource_provider_namespace, - api_version=api_version, expand=expand, - template_url=self.get_at_tenant_scope.metadata['url'], + api_version=api_version, + template_url=self.get_at_tenant_scope.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) - deserialized = self._deserialize('Provider', pipeline_response) + deserialized = self._deserialize("Provider", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - get_at_tenant_scope.metadata = {'url': "/providers/{resourceProviderNamespace}"} # type: ignore + get_at_tenant_scope.metadata = {"url": "/providers/{resourceProviderNamespace}"} # type: ignore -class ResourcesOperations(object): # pylint: disable=too-many-public-methods - """ResourcesOperations operations. - You should not instantiate this class directly. Instead, you should create a Client instance that - instantiates it for you and attaches it as an attribute. +class ResourcesOperations: # pylint: disable=too-many-public-methods + """ + .. warning:: + **DO NOT** instantiate this class directly. - :ivar models: Alias to model classes used in this operation group. - :type models: ~azure.mgmt.resource.resources.v2019_05_10.models - :param client: Client for service requests. - :param config: Configuration of service client. - :param serializer: An object model serializer. - :param deserializer: An object model deserializer. + Instead, you should access the following operations through + :class:`~azure.mgmt.resource.resources.v2019_05_10.ResourceManagementClient`'s + :attr:`resources` attribute. """ models = _models - def __init__(self, client, config, serializer, deserializer): - self._client = client - self._serialize = serializer - self._deserialize = deserializer - self._config = config + def __init__(self, *args, **kwargs): + input_args = list(args) + self._client = input_args.pop(0) if input_args else kwargs.pop("client") + self._config = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") @distributed_trace def list_by_resource_group( @@ -4780,10 +4941,10 @@ def list_by_resource_group( expand: Optional[str] = None, top: Optional[int] = None, **kwargs: Any - ) -> Iterable["_models.ResourceListResult"]: + ) -> Iterable["_models.GenericResourceExpanded"]: """Get all the resources for a resource group. - :param resource_group_name: The resource group with the resources to get. + :param resource_group_name: The resource group with the resources to get. Required. :type resource_group_name: str :param filter: The filter to apply on the operation.:code:`
`:code:`
`The properties you can use for eq (equals) or ne (not equals) are: location, resourceType, name, resourceGroup, @@ -4808,42 +4969,51 @@ def list_by_resource_group( value is None. :type top: int :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either ResourceListResult or the result of cls(response) + :return: An iterator like instance of either GenericResourceExpanded or the result of + cls(response) :rtype: - ~azure.core.paging.ItemPaged[~azure.mgmt.resource.resources.v2019_05_10.models.ResourceListResult] - :raises: ~azure.core.exceptions.HttpResponseError + ~azure.core.paging.ItemPaged[~azure.mgmt.resource.resources.v2019_05_10.models.GenericResourceExpanded] + :raises ~azure.core.exceptions.HttpResponseError: """ - api_version = kwargs.pop('api_version', "2019-05-10") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2019-05-10")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[_models.ResourceListResult] - cls = kwargs.pop('cls', None) # type: ClsType["_models.ResourceListResult"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) + def prepare_request(next_link=None): if not next_link: - + request = build_resources_list_by_resource_group_request( resource_group_name=resource_group_name, subscription_id=self._config.subscription_id, - api_version=api_version, filter=filter, expand=expand, top=top, - template_url=self.list_by_resource_group.metadata['url'], + 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.url = self._client.format_url(request.url) # type: ignore else: - - request = build_resources_list_by_resource_group_request( - resource_group_name=resource_group_name, - subscription_id=self._config.subscription_id, - template_url=next_link, - ) + # make call to next link with the client's api-version + _parsed_next_link = urlparse(next_link) + _next_request_params = case_insensitive_dict(parse_qs(_parsed_next_link.query)) + _next_request_params["api-version"] = self._config.api_version + request = HttpRequest("GET", urljoin(next_link, _parsed_next_link.path), params=_next_request_params) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore request.method = "GET" return request @@ -4857,10 +5027,8 @@ def extract_data(pipeline_response): def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) response = pipeline_response.http_response @@ -4870,45 +5038,54 @@ def get_next(next_link=None): return pipeline_response + return ItemPaged(get_next, extract_data) - return ItemPaged( - get_next, extract_data - ) - list_by_resource_group.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/resources"} # type: ignore + list_by_resource_group.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/resources"} # type: ignore def _move_resources_initial( # pylint: disable=inconsistent-return-statements - self, - source_resource_group_name: str, - parameters: "_models.ResourcesMoveInfo", - **kwargs: Any + self, source_resource_group_name: str, parameters: Union[_models.ResourcesMoveInfo, IO], **kwargs: Any ) -> None: - cls = kwargs.pop('cls', None) # type: ClsType[None] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', "2019-05-10") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + api_version = kwargs.pop("api_version", _params.pop("api-version", "2019-05-10")) # type: str + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[None] - _json = self._serialize.body(parameters, 'ResourcesMoveInfo') + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(parameters, (IO, bytes)): + _content = parameters + else: + _json = self._serialize.body(parameters, "ResourcesMoveInfo") - request = build_resources_move_resources_request_initial( + request = build_resources_move_resources_request( source_resource_group_name=source_resource_group_name, subscription_id=self._config.subscription_id, api_version=api_version, content_type=content_type, json=_json, - template_url=self._move_resources_initial.metadata['url'], + content=_content, + template_url=self._move_resources_initial.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [202, 204]: @@ -4918,14 +5095,15 @@ def _move_resources_initial( # pylint: disable=inconsistent-return-statements if cls: return cls(pipeline_response, None, {}) - _move_resources_initial.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{sourceResourceGroupName}/moveResources"} # type: ignore - + _move_resources_initial.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{sourceResourceGroupName}/moveResources"} # type: ignore - @distributed_trace - def begin_move_resources( # pylint: disable=inconsistent-return-statements + @overload + def begin_move_resources( self, source_resource_group_name: str, - parameters: "_models.ResourcesMoveInfo", + parameters: _models.ResourcesMoveInfo, + *, + content_type: str = "application/json", **kwargs: Any ) -> LROPoller[None]: """Moves resources from one resource group to another resource group. @@ -4936,10 +5114,13 @@ def begin_move_resources( # pylint: disable=inconsistent-return-statements the groups until the move completes. :param source_resource_group_name: The name of the resource group containing the resources to - move. + move. Required. :type source_resource_group_name: str - :param parameters: Parameters for moving resources. + :param parameters: Parameters for moving resources. Required. :type parameters: ~azure.mgmt.resource.resources.v2019_05_10.models.ResourcesMoveInfo + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str :keyword callable cls: A custom type or function that will be passed the direct response :keyword str continuation_token: A continuation token to restart a poller from a saved state. :keyword polling: By default, your polling method will be ARMPolling. Pass in False for this @@ -4950,80 +5131,160 @@ def begin_move_resources( # pylint: disable=inconsistent-return-statements Retry-After header is present. :return: An instance of LROPoller that returns either None or the result of cls(response) :rtype: ~azure.core.polling.LROPoller[None] - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - api_version = kwargs.pop('api_version', "2019-05-10") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] - polling = kwargs.pop('polling', True) # type: Union[bool, PollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType[None] - lro_delay = kwargs.pop( - 'polling_interval', - self._config.polling_interval - ) - cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] + + @overload + def begin_move_resources( + self, source_resource_group_name: str, parameters: IO, *, content_type: str = "application/json", **kwargs: Any + ) -> LROPoller[None]: + """Moves resources from one resource group to another resource group. + + The resources to move must be in the same source resource group. The target resource group may + be in a different subscription. When moving resources, both the source group and the target + group are locked for the duration of the operation. Write and delete operations are blocked on + the groups until the move completes. + + :param source_resource_group_name: The name of the resource group containing the resources to + move. Required. + :type source_resource_group_name: str + :param parameters: Parameters for moving resources. Required. + :type parameters: IO + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be ARMPolling. Pass in False for this + operation to not poll, or pass in your own initialized polling object for a personal polling + strategy. + :paramtype polling: bool or ~azure.core.polling.PollingMethod + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of LROPoller that returns either None or the result of cls(response) + :rtype: ~azure.core.polling.LROPoller[None] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace + def begin_move_resources( + self, source_resource_group_name: str, parameters: Union[_models.ResourcesMoveInfo, IO], **kwargs: Any + ) -> LROPoller[None]: + """Moves resources from one resource group to another resource group. + + The resources to move must be in the same source resource group. The target resource group may + be in a different subscription. When moving resources, both the source group and the target + group are locked for the duration of the operation. Write and delete operations are blocked on + the groups until the move completes. + + :param source_resource_group_name: The name of the resource group containing the resources to + move. Required. + :type source_resource_group_name: str + :param parameters: Parameters for moving resources. Is either a model type or a IO type. + Required. + :type parameters: ~azure.mgmt.resource.resources.v2019_05_10.models.ResourcesMoveInfo or IO + :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. + Default value is None. + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be ARMPolling. Pass in False for this + operation to not poll, or pass in your own initialized polling object for a personal polling + strategy. + :paramtype polling: bool or ~azure.core.polling.PollingMethod + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of LROPoller that returns either None or the result of cls(response) + :rtype: ~azure.core.polling.LROPoller[None] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _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", "2019-05-10")) # type: str + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[None] + polling = kwargs.pop("polling", True) # type: Union[bool, PollingMethod] + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token = kwargs.pop("continuation_token", None) # type: Optional[str] if cont_token is None: - raw_result = self._move_resources_initial( + raw_result = self._move_resources_initial( # type: ignore source_resource_group_name=source_resource_group_name, parameters=parameters, api_version=api_version, content_type=content_type, - cls=lambda x,y,z: x, + cls=lambda x, y, z: x, + headers=_headers, + params=_params, **kwargs ) - kwargs.pop('error_map', None) + kwargs.pop("error_map", None) - def get_long_running_output(pipeline_response): + def get_long_running_output(pipeline_response): # pylint: disable=inconsistent-return-statements if cls: return cls(pipeline_response, None, {}) - - if polling is True: polling_method = ARMPolling(lro_delay, **kwargs) - elif polling is False: polling_method = NoPolling() - else: polling_method = polling + if polling is True: + polling_method = cast(PollingMethod, ARMPolling(lro_delay, **kwargs)) # type: PollingMethod + elif polling is False: + polling_method = cast(PollingMethod, NoPolling()) + else: + polling_method = polling if cont_token: return LROPoller.from_continuation_token( polling_method=polling_method, continuation_token=cont_token, client=self._client, - deserialization_callback=get_long_running_output + deserialization_callback=get_long_running_output, ) return LROPoller(self._client, raw_result, get_long_running_output, polling_method) - begin_move_resources.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{sourceResourceGroupName}/moveResources"} # type: ignore + begin_move_resources.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{sourceResourceGroupName}/moveResources"} # type: ignore def _validate_move_resources_initial( # pylint: disable=inconsistent-return-statements - self, - source_resource_group_name: str, - parameters: "_models.ResourcesMoveInfo", - **kwargs: Any + self, source_resource_group_name: str, parameters: Union[_models.ResourcesMoveInfo, IO], **kwargs: Any ) -> None: - cls = kwargs.pop('cls', None) # type: ClsType[None] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', "2019-05-10") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + api_version = kwargs.pop("api_version", _params.pop("api-version", "2019-05-10")) # type: str + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[None] - _json = self._serialize.body(parameters, 'ResourcesMoveInfo') + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(parameters, (IO, bytes)): + _content = parameters + else: + _json = self._serialize.body(parameters, "ResourcesMoveInfo") - request = build_resources_validate_move_resources_request_initial( + request = build_resources_validate_move_resources_request( source_resource_group_name=source_resource_group_name, subscription_id=self._config.subscription_id, api_version=api_version, content_type=content_type, json=_json, - template_url=self._validate_move_resources_initial.metadata['url'], + content=_content, + template_url=self._validate_move_resources_initial.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [202, 204, 409]: @@ -5033,14 +5294,15 @@ def _validate_move_resources_initial( # pylint: disable=inconsistent-return-sta if cls: return cls(pipeline_response, None, {}) - _validate_move_resources_initial.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{sourceResourceGroupName}/validateMoveResources"} # type: ignore - + _validate_move_resources_initial.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{sourceResourceGroupName}/validateMoveResources"} # type: ignore - @distributed_trace - def begin_validate_move_resources( # pylint: disable=inconsistent-return-statements + @overload + def begin_validate_move_resources( self, source_resource_group_name: str, - parameters: "_models.ResourcesMoveInfo", + parameters: _models.ResourcesMoveInfo, + *, + content_type: str = "application/json", **kwargs: Any ) -> LROPoller[None]: """Validates whether resources can be moved from one resource group to another resource group. @@ -5053,10 +5315,13 @@ def begin_validate_move_resources( # pylint: disable=inconsistent-return-statem operation. :param source_resource_group_name: The name of the resource group containing the resources to - validate for move. + validate for move. Required. :type source_resource_group_name: str - :param parameters: Parameters for moving resources. + :param parameters: Parameters for moving resources. Required. :type parameters: ~azure.mgmt.resource.resources.v2019_05_10.models.ResourcesMoveInfo + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str :keyword callable cls: A custom type or function that will be passed the direct response :keyword str continuation_token: A continuation token to restart a poller from a saved state. :keyword polling: By default, your polling method will be ARMPolling. Pass in False for this @@ -5067,55 +5332,124 @@ def begin_validate_move_resources( # pylint: disable=inconsistent-return-statem Retry-After header is present. :return: An instance of LROPoller that returns either None or the result of cls(response) :rtype: ~azure.core.polling.LROPoller[None] - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - api_version = kwargs.pop('api_version', "2019-05-10") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] - polling = kwargs.pop('polling', True) # type: Union[bool, PollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType[None] - lro_delay = kwargs.pop( - 'polling_interval', - self._config.polling_interval - ) - cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] + + @overload + def begin_validate_move_resources( + self, source_resource_group_name: str, parameters: IO, *, content_type: str = "application/json", **kwargs: Any + ) -> LROPoller[None]: + """Validates whether resources can be moved from one resource group to another resource group. + + This operation checks whether the specified resources can be moved to the target. The resources + to move must be in the same source resource group. The target resource group may be in a + different subscription. If validation succeeds, it returns HTTP response code 204 (no content). + If validation fails, it returns HTTP response code 409 (Conflict) with an error message. + Retrieve the URL in the Location header value to check the result of the long-running + operation. + + :param source_resource_group_name: The name of the resource group containing the resources to + validate for move. Required. + :type source_resource_group_name: str + :param parameters: Parameters for moving resources. Required. + :type parameters: IO + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be ARMPolling. Pass in False for this + operation to not poll, or pass in your own initialized polling object for a personal polling + strategy. + :paramtype polling: bool or ~azure.core.polling.PollingMethod + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of LROPoller that returns either None or the result of cls(response) + :rtype: ~azure.core.polling.LROPoller[None] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace + def begin_validate_move_resources( + self, source_resource_group_name: str, parameters: Union[_models.ResourcesMoveInfo, IO], **kwargs: Any + ) -> LROPoller[None]: + """Validates whether resources can be moved from one resource group to another resource group. + + This operation checks whether the specified resources can be moved to the target. The resources + to move must be in the same source resource group. The target resource group may be in a + different subscription. If validation succeeds, it returns HTTP response code 204 (no content). + If validation fails, it returns HTTP response code 409 (Conflict) with an error message. + Retrieve the URL in the Location header value to check the result of the long-running + operation. + + :param source_resource_group_name: The name of the resource group containing the resources to + validate for move. Required. + :type source_resource_group_name: str + :param parameters: Parameters for moving resources. Is either a model type or a IO type. + Required. + :type parameters: ~azure.mgmt.resource.resources.v2019_05_10.models.ResourcesMoveInfo or IO + :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. + Default value is None. + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be ARMPolling. Pass in False for this + operation to not poll, or pass in your own initialized polling object for a personal polling + strategy. + :paramtype polling: bool or ~azure.core.polling.PollingMethod + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of LROPoller that returns either None or the result of cls(response) + :rtype: ~azure.core.polling.LROPoller[None] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _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", "2019-05-10")) # type: str + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[None] + polling = kwargs.pop("polling", True) # type: Union[bool, PollingMethod] + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token = kwargs.pop("continuation_token", None) # type: Optional[str] if cont_token is None: - raw_result = self._validate_move_resources_initial( + raw_result = self._validate_move_resources_initial( # type: ignore source_resource_group_name=source_resource_group_name, parameters=parameters, api_version=api_version, content_type=content_type, - cls=lambda x,y,z: x, + cls=lambda x, y, z: x, + headers=_headers, + params=_params, **kwargs ) - kwargs.pop('error_map', None) + kwargs.pop("error_map", None) - def get_long_running_output(pipeline_response): + def get_long_running_output(pipeline_response): # pylint: disable=inconsistent-return-statements if cls: return cls(pipeline_response, None, {}) - - if polling is True: polling_method = ARMPolling(lro_delay, **kwargs) - elif polling is False: polling_method = NoPolling() - else: polling_method = polling + if polling is True: + polling_method = cast(PollingMethod, ARMPolling(lro_delay, **kwargs)) # type: PollingMethod + elif polling is False: + polling_method = cast(PollingMethod, NoPolling()) + else: + polling_method = polling if cont_token: return LROPoller.from_continuation_token( polling_method=polling_method, continuation_token=cont_token, client=self._client, - deserialization_callback=get_long_running_output + deserialization_callback=get_long_running_output, ) return LROPoller(self._client, raw_result, get_long_running_output, polling_method) - begin_validate_move_resources.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{sourceResourceGroupName}/validateMoveResources"} # type: ignore + begin_validate_move_resources.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{sourceResourceGroupName}/validateMoveResources"} # type: ignore @distributed_trace def list( - self, - filter: Optional[str] = None, - expand: Optional[str] = None, - top: Optional[int] = None, - **kwargs: Any - ) -> Iterable["_models.ResourceListResult"]: + self, filter: Optional[str] = None, expand: Optional[str] = None, top: Optional[int] = None, **kwargs: Any + ) -> Iterable["_models.GenericResourceExpanded"]: """Get all the resources in a subscription. :param filter: The filter to apply on the operation.:code:`
`:code:`
`The properties you @@ -5141,40 +5475,50 @@ def list( value is None. :type top: int :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either ResourceListResult or the result of cls(response) + :return: An iterator like instance of either GenericResourceExpanded or the result of + cls(response) :rtype: - ~azure.core.paging.ItemPaged[~azure.mgmt.resource.resources.v2019_05_10.models.ResourceListResult] - :raises: ~azure.core.exceptions.HttpResponseError + ~azure.core.paging.ItemPaged[~azure.mgmt.resource.resources.v2019_05_10.models.GenericResourceExpanded] + :raises ~azure.core.exceptions.HttpResponseError: """ - api_version = kwargs.pop('api_version', "2019-05-10") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2019-05-10")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[_models.ResourceListResult] - cls = kwargs.pop('cls', None) # type: ClsType["_models.ResourceListResult"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) + def prepare_request(next_link=None): if not next_link: - + request = build_resources_list_request( subscription_id=self._config.subscription_id, - api_version=api_version, filter=filter, expand=expand, top=top, - template_url=self.list.metadata['url'], + 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.url = self._client.format_url(request.url) # type: ignore else: - - request = build_resources_list_request( - subscription_id=self._config.subscription_id, - template_url=next_link, - ) + # make call to next link with the client's api-version + _parsed_next_link = urlparse(next_link) + _next_request_params = case_insensitive_dict(parse_qs(_parsed_next_link.query)) + _next_request_params["api-version"] = self._config.api_version + request = HttpRequest("GET", urljoin(next_link, _parsed_next_link.path), params=_next_request_params) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore request.method = "GET" return request @@ -5188,10 +5532,8 @@ def extract_data(pipeline_response): def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) response = pipeline_response.http_response @@ -5201,11 +5543,9 @@ def get_next(next_link=None): return pipeline_response + return ItemPaged(get_next, extract_data) - return ItemPaged( - get_next, extract_data - ) - list.metadata = {'url': "/subscriptions/{subscriptionId}/resources"} # type: ignore + list.metadata = {"url": "/subscriptions/{subscriptionId}/resources"} # type: ignore @distributed_trace def check_existence( @@ -5221,30 +5561,36 @@ def check_existence( """Checks whether a resource exists. :param resource_group_name: The name of the resource group containing the resource to check. - The name is case insensitive. + The name is case insensitive. Required. :type resource_group_name: str - :param resource_provider_namespace: The resource provider of the resource to check. + :param resource_provider_namespace: The resource provider of the resource to check. Required. :type resource_provider_namespace: str - :param parent_resource_path: The parent resource identity. + :param parent_resource_path: The parent resource identity. Required. :type parent_resource_path: str - :param resource_type: The resource type. + :param resource_type: The resource type. Required. :type resource_type: str - :param resource_name: The name of the resource to check whether it exists. + :param resource_name: The name of the resource to check whether it exists. Required. :type resource_name: str - :param api_version: The API version to use for the operation. + :param api_version: The API version to use for the operation. Required. :type api_version: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: bool, or the result of cls(response) + :return: bool or the result of cls(response) :rtype: bool - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType[None] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = kwargs.pop("params", {}) or {} + + cls = kwargs.pop("cls", None) # type: ClsType[None] - request = build_resources_check_existence_request( resource_group_name=resource_group_name, resource_provider_namespace=resource_provider_namespace, @@ -5253,16 +5599,17 @@ def check_existence( resource_name=resource_name, subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.check_existence.metadata['url'], + template_url=self.check_existence.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [204, 404]: @@ -5273,8 +5620,7 @@ def check_existence( return cls(pipeline_response, None, {}) return 200 <= response.status_code <= 299 - check_existence.metadata = {'url': "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{parentResourcePath}/{resourceType}/{resourceName}"} # type: ignore - + check_existence.metadata = {"url": "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{parentResourcePath}/{resourceType}/{resourceName}"} # type: ignore def _delete_initial( # pylint: disable=inconsistent-return-statements self, @@ -5286,14 +5632,20 @@ def _delete_initial( # pylint: disable=inconsistent-return-statements api_version: str, **kwargs: Any ) -> None: - cls = kwargs.pop('cls', None) # type: ClsType[None] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) - - request = build_resources_delete_request_initial( + _headers = kwargs.pop("headers", {}) or {} + _params = kwargs.pop("params", {}) or {} + + cls = kwargs.pop("cls", None) # type: ClsType[None] + + request = build_resources_delete_request( resource_group_name=resource_group_name, resource_provider_namespace=resource_provider_namespace, parent_resource_path=parent_resource_path, @@ -5301,16 +5653,17 @@ def _delete_initial( # pylint: disable=inconsistent-return-statements resource_name=resource_name, subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self._delete_initial.metadata['url'], + template_url=self._delete_initial.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200, 202, 204]: @@ -5320,11 +5673,10 @@ def _delete_initial( # pylint: disable=inconsistent-return-statements if cls: return cls(pipeline_response, None, {}) - _delete_initial.metadata = {'url': "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{parentResourcePath}/{resourceType}/{resourceName}"} # type: ignore - + _delete_initial.metadata = {"url": "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{parentResourcePath}/{resourceType}/{resourceName}"} # type: ignore @distributed_trace - def begin_delete( # pylint: disable=inconsistent-return-statements + def begin_delete( self, resource_group_name: str, resource_provider_namespace: str, @@ -5337,17 +5689,17 @@ def begin_delete( # pylint: disable=inconsistent-return-statements """Deletes a resource. :param resource_group_name: The name of the resource group that contains the resource to - delete. The name is case insensitive. + delete. The name is case insensitive. Required. :type resource_group_name: str - :param resource_provider_namespace: The namespace of the resource provider. + :param resource_provider_namespace: The namespace of the resource provider. Required. :type resource_provider_namespace: str - :param parent_resource_path: The parent resource identity. + :param parent_resource_path: The parent resource identity. Required. :type parent_resource_path: str - :param resource_type: The resource type. + :param resource_type: The resource type. Required. :type resource_type: str - :param resource_name: The name of the resource to delete. + :param resource_name: The name of the resource to delete. Required. :type resource_name: str - :param api_version: The API version to use for the operation. + :param api_version: The API version to use for the operation. Required. :type api_version: str :keyword callable cls: A custom type or function that will be passed the direct response :keyword str continuation_token: A continuation token to restart a poller from a saved state. @@ -5359,46 +5711,50 @@ def begin_delete( # pylint: disable=inconsistent-return-statements Retry-After header is present. :return: An instance of LROPoller that returns either None or the result of cls(response) :rtype: ~azure.core.polling.LROPoller[None] - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - polling = kwargs.pop('polling', True) # type: Union[bool, PollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType[None] - lro_delay = kwargs.pop( - 'polling_interval', - self._config.polling_interval - ) - cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] + _headers = kwargs.pop("headers", {}) or {} + _params = kwargs.pop("params", {}) or {} + + cls = kwargs.pop("cls", None) # type: ClsType[None] + polling = kwargs.pop("polling", True) # type: Union[bool, PollingMethod] + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token = kwargs.pop("continuation_token", None) # type: Optional[str] if cont_token is None: - raw_result = self._delete_initial( + raw_result = self._delete_initial( # type: ignore resource_group_name=resource_group_name, resource_provider_namespace=resource_provider_namespace, parent_resource_path=parent_resource_path, resource_type=resource_type, resource_name=resource_name, api_version=api_version, - cls=lambda x,y,z: x, + cls=lambda x, y, z: x, + headers=_headers, + params=_params, **kwargs ) - kwargs.pop('error_map', None) + kwargs.pop("error_map", None) - def get_long_running_output(pipeline_response): + def get_long_running_output(pipeline_response): # pylint: disable=inconsistent-return-statements if cls: return cls(pipeline_response, None, {}) - - if polling is True: polling_method = ARMPolling(lro_delay, **kwargs) - elif polling is False: polling_method = NoPolling() - else: polling_method = polling + if polling is True: + polling_method = cast(PollingMethod, ARMPolling(lro_delay, **kwargs)) # type: PollingMethod + elif polling is False: + polling_method = cast(PollingMethod, NoPolling()) + else: + polling_method = polling if cont_token: return LROPoller.from_continuation_token( polling_method=polling_method, continuation_token=cont_token, client=self._client, - deserialization_callback=get_long_running_output + deserialization_callback=get_long_running_output, ) return LROPoller(self._client, raw_result, get_long_running_output, polling_method) - begin_delete.metadata = {'url': "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{parentResourcePath}/{resourceType}/{resourceName}"} # type: ignore + begin_delete.metadata = {"url": "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{parentResourcePath}/{resourceType}/{resourceName}"} # type: ignore def _create_or_update_initial( self, @@ -5408,39 +5764,53 @@ def _create_or_update_initial( resource_type: str, resource_name: str, api_version: str, - parameters: "_models.GenericResource", + parameters: Union[_models.GenericResource, IO], **kwargs: Any - ) -> Optional["_models.GenericResource"]: - cls = kwargs.pop('cls', None) # type: ClsType[Optional["_models.GenericResource"]] + ) -> Optional[_models.GenericResource]: error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = kwargs.pop("params", {}) or {} - _json = self._serialize.body(parameters, 'GenericResource') + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[Optional[_models.GenericResource]] - request = build_resources_create_or_update_request_initial( + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(parameters, (IO, bytes)): + _content = parameters + else: + _json = self._serialize.body(parameters, "GenericResource") + + request = build_resources_create_or_update_request( resource_group_name=resource_group_name, resource_provider_namespace=resource_provider_namespace, parent_resource_path=parent_resource_path, resource_type=resource_type, resource_name=resource_name, subscription_id=self._config.subscription_id, - content_type=content_type, api_version=api_version, + content_type=content_type, json=_json, - template_url=self._create_or_update_initial.metadata['url'], + content=_content, + template_url=self._create_or_update_initial.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200, 201, 202]: @@ -5449,18 +5819,115 @@ def _create_or_update_initial( deserialized = None if response.status_code == 200: - deserialized = self._deserialize('GenericResource', pipeline_response) + deserialized = self._deserialize("GenericResource", pipeline_response) if response.status_code == 201: - deserialized = self._deserialize('GenericResource', pipeline_response) + deserialized = self._deserialize("GenericResource", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - _create_or_update_initial.metadata = {'url': "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{parentResourcePath}/{resourceType}/{resourceName}"} # type: ignore + _create_or_update_initial.metadata = {"url": "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{parentResourcePath}/{resourceType}/{resourceName}"} # type: ignore + + @overload + def begin_create_or_update( + self, + resource_group_name: str, + resource_provider_namespace: str, + parent_resource_path: str, + resource_type: str, + resource_name: str, + api_version: str, + parameters: _models.GenericResource, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> LROPoller[_models.GenericResource]: + """Creates a resource. + + :param resource_group_name: The name of the resource group for the resource. The name is case + insensitive. Required. + :type resource_group_name: str + :param resource_provider_namespace: The namespace of the resource provider. Required. + :type resource_provider_namespace: str + :param parent_resource_path: The parent resource identity. Required. + :type parent_resource_path: str + :param resource_type: The resource type of the resource to create. Required. + :type resource_type: str + :param resource_name: The name of the resource to create. Required. + :type resource_name: str + :param api_version: The API version to use for the operation. Required. + :type api_version: str + :param parameters: Parameters for creating or updating the resource. Required. + :type parameters: ~azure.mgmt.resource.resources.v2019_05_10.models.GenericResource + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be ARMPolling. Pass in False for this + operation to not poll, or pass in your own initialized polling object for a personal polling + strategy. + :paramtype polling: bool or ~azure.core.polling.PollingMethod + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of LROPoller that returns either GenericResource or the result of + cls(response) + :rtype: + ~azure.core.polling.LROPoller[~azure.mgmt.resource.resources.v2019_05_10.models.GenericResource] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + def begin_create_or_update( + self, + resource_group_name: str, + resource_provider_namespace: str, + parent_resource_path: str, + resource_type: str, + resource_name: str, + api_version: str, + parameters: IO, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> LROPoller[_models.GenericResource]: + """Creates a resource. + :param resource_group_name: The name of the resource group for the resource. The name is case + insensitive. Required. + :type resource_group_name: str + :param resource_provider_namespace: The namespace of the resource provider. Required. + :type resource_provider_namespace: str + :param parent_resource_path: The parent resource identity. Required. + :type parent_resource_path: str + :param resource_type: The resource type of the resource to create. Required. + :type resource_type: str + :param resource_name: The name of the resource to create. Required. + :type resource_name: str + :param api_version: The API version to use for the operation. Required. + :type api_version: str + :param parameters: Parameters for creating or updating the resource. Required. + :type parameters: IO + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be ARMPolling. Pass in False for this + operation to not poll, or pass in your own initialized polling object for a personal polling + strategy. + :paramtype polling: bool or ~azure.core.polling.PollingMethod + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of LROPoller that returns either GenericResource or the result of + cls(response) + :rtype: + ~azure.core.polling.LROPoller[~azure.mgmt.resource.resources.v2019_05_10.models.GenericResource] + :raises ~azure.core.exceptions.HttpResponseError: + """ @distributed_trace def begin_create_or_update( @@ -5471,26 +5938,30 @@ def begin_create_or_update( resource_type: str, resource_name: str, api_version: str, - parameters: "_models.GenericResource", + parameters: Union[_models.GenericResource, IO], **kwargs: Any - ) -> LROPoller["_models.GenericResource"]: + ) -> LROPoller[_models.GenericResource]: """Creates a resource. :param resource_group_name: The name of the resource group for the resource. The name is case - insensitive. + insensitive. Required. :type resource_group_name: str - :param resource_provider_namespace: The namespace of the resource provider. + :param resource_provider_namespace: The namespace of the resource provider. Required. :type resource_provider_namespace: str - :param parent_resource_path: The parent resource identity. + :param parent_resource_path: The parent resource identity. Required. :type parent_resource_path: str - :param resource_type: The resource type of the resource to create. + :param resource_type: The resource type of the resource to create. Required. :type resource_type: str - :param resource_name: The name of the resource to create. + :param resource_name: The name of the resource to create. Required. :type resource_name: str - :param api_version: The API version to use for the operation. + :param api_version: The API version to use for the operation. Required. :type api_version: str - :param parameters: Parameters for creating or updating the resource. - :type parameters: ~azure.mgmt.resource.resources.v2019_05_10.models.GenericResource + :param parameters: Parameters for creating or updating the resource. Is either a model type or + a IO type. Required. + :type parameters: ~azure.mgmt.resource.resources.v2019_05_10.models.GenericResource or IO + :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. + Default value is None. + :paramtype content_type: str :keyword callable cls: A custom type or function that will be passed the direct response :keyword str continuation_token: A continuation token to restart a poller from a saved state. :keyword polling: By default, your polling method will be ARMPolling. Pass in False for this @@ -5503,18 +5974,18 @@ def begin_create_or_update( cls(response) :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.resource.resources.v2019_05_10.models.GenericResource] - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] - polling = kwargs.pop('polling', True) # type: Union[bool, PollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType["_models.GenericResource"] - lro_delay = kwargs.pop( - 'polling_interval', - self._config.polling_interval - ) - cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = kwargs.pop("params", {}) or {} + + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.GenericResource] + polling = kwargs.pop("polling", True) # type: Union[bool, PollingMethod] + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token = kwargs.pop("continuation_token", None) # type: Optional[str] if cont_token is None: - raw_result = self._create_or_update_initial( + raw_result = self._create_or_update_initial( # type: ignore resource_group_name=resource_group_name, resource_provider_namespace=resource_provider_namespace, parent_resource_path=parent_resource_path, @@ -5523,32 +5994,35 @@ def begin_create_or_update( api_version=api_version, parameters=parameters, content_type=content_type, - cls=lambda x,y,z: x, + cls=lambda x, y, z: x, + headers=_headers, + params=_params, **kwargs ) - kwargs.pop('error_map', None) + kwargs.pop("error_map", None) def get_long_running_output(pipeline_response): - response = pipeline_response.http_response - deserialized = self._deserialize('GenericResource', pipeline_response) + deserialized = self._deserialize("GenericResource", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - - if polling is True: polling_method = ARMPolling(lro_delay, **kwargs) - elif polling is False: polling_method = NoPolling() - else: polling_method = polling + if polling is True: + polling_method = cast(PollingMethod, ARMPolling(lro_delay, **kwargs)) # type: PollingMethod + elif polling is False: + polling_method = cast(PollingMethod, NoPolling()) + else: + polling_method = polling if cont_token: return LROPoller.from_continuation_token( polling_method=polling_method, continuation_token=cont_token, client=self._client, - deserialization_callback=get_long_running_output + deserialization_callback=get_long_running_output, ) return LROPoller(self._client, raw_result, get_long_running_output, polling_method) - begin_create_or_update.metadata = {'url': "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{parentResourcePath}/{resourceType}/{resourceName}"} # type: ignore + begin_create_or_update.metadata = {"url": "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{parentResourcePath}/{resourceType}/{resourceName}"} # type: ignore def _update_initial( self, @@ -5558,39 +6032,53 @@ def _update_initial( resource_type: str, resource_name: str, api_version: str, - parameters: "_models.GenericResource", + parameters: Union[_models.GenericResource, IO], **kwargs: Any - ) -> Optional["_models.GenericResource"]: - cls = kwargs.pop('cls', None) # type: ClsType[Optional["_models.GenericResource"]] + ) -> Optional[_models.GenericResource]: error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = kwargs.pop("params", {}) or {} - _json = self._serialize.body(parameters, 'GenericResource') + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[Optional[_models.GenericResource]] - request = build_resources_update_request_initial( + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(parameters, (IO, bytes)): + _content = parameters + else: + _json = self._serialize.body(parameters, "GenericResource") + + request = build_resources_update_request( resource_group_name=resource_group_name, resource_provider_namespace=resource_provider_namespace, parent_resource_path=parent_resource_path, resource_type=resource_type, resource_name=resource_name, subscription_id=self._config.subscription_id, - content_type=content_type, api_version=api_version, + content_type=content_type, json=_json, - template_url=self._update_initial.metadata['url'], + content=_content, + template_url=self._update_initial.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200, 202]: @@ -5599,15 +6087,112 @@ def _update_initial( deserialized = None if response.status_code == 200: - deserialized = self._deserialize('GenericResource', pipeline_response) + deserialized = self._deserialize("GenericResource", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - _update_initial.metadata = {'url': "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{parentResourcePath}/{resourceType}/{resourceName}"} # type: ignore + _update_initial.metadata = {"url": "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{parentResourcePath}/{resourceType}/{resourceName}"} # type: ignore + + @overload + def begin_update( + self, + resource_group_name: str, + resource_provider_namespace: str, + parent_resource_path: str, + resource_type: str, + resource_name: str, + api_version: str, + parameters: _models.GenericResource, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> LROPoller[_models.GenericResource]: + """Updates a resource. + + :param resource_group_name: The name of the resource group for the resource. The name is case + insensitive. Required. + :type resource_group_name: str + :param resource_provider_namespace: The namespace of the resource provider. Required. + :type resource_provider_namespace: str + :param parent_resource_path: The parent resource identity. Required. + :type parent_resource_path: str + :param resource_type: The resource type of the resource to update. Required. + :type resource_type: str + :param resource_name: The name of the resource to update. Required. + :type resource_name: str + :param api_version: The API version to use for the operation. Required. + :type api_version: str + :param parameters: Parameters for updating the resource. Required. + :type parameters: ~azure.mgmt.resource.resources.v2019_05_10.models.GenericResource + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be ARMPolling. Pass in False for this + operation to not poll, or pass in your own initialized polling object for a personal polling + strategy. + :paramtype polling: bool or ~azure.core.polling.PollingMethod + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of LROPoller that returns either GenericResource or the result of + cls(response) + :rtype: + ~azure.core.polling.LROPoller[~azure.mgmt.resource.resources.v2019_05_10.models.GenericResource] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + def begin_update( + self, + resource_group_name: str, + resource_provider_namespace: str, + parent_resource_path: str, + resource_type: str, + resource_name: str, + api_version: str, + parameters: IO, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> LROPoller[_models.GenericResource]: + """Updates a resource. + :param resource_group_name: The name of the resource group for the resource. The name is case + insensitive. Required. + :type resource_group_name: str + :param resource_provider_namespace: The namespace of the resource provider. Required. + :type resource_provider_namespace: str + :param parent_resource_path: The parent resource identity. Required. + :type parent_resource_path: str + :param resource_type: The resource type of the resource to update. Required. + :type resource_type: str + :param resource_name: The name of the resource to update. Required. + :type resource_name: str + :param api_version: The API version to use for the operation. Required. + :type api_version: str + :param parameters: Parameters for updating the resource. Required. + :type parameters: IO + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be ARMPolling. Pass in False for this + operation to not poll, or pass in your own initialized polling object for a personal polling + strategy. + :paramtype polling: bool or ~azure.core.polling.PollingMethod + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of LROPoller that returns either GenericResource or the result of + cls(response) + :rtype: + ~azure.core.polling.LROPoller[~azure.mgmt.resource.resources.v2019_05_10.models.GenericResource] + :raises ~azure.core.exceptions.HttpResponseError: + """ @distributed_trace def begin_update( @@ -5618,26 +6203,30 @@ def begin_update( resource_type: str, resource_name: str, api_version: str, - parameters: "_models.GenericResource", + parameters: Union[_models.GenericResource, IO], **kwargs: Any - ) -> LROPoller["_models.GenericResource"]: + ) -> LROPoller[_models.GenericResource]: """Updates a resource. :param resource_group_name: The name of the resource group for the resource. The name is case - insensitive. + insensitive. Required. :type resource_group_name: str - :param resource_provider_namespace: The namespace of the resource provider. + :param resource_provider_namespace: The namespace of the resource provider. Required. :type resource_provider_namespace: str - :param parent_resource_path: The parent resource identity. + :param parent_resource_path: The parent resource identity. Required. :type parent_resource_path: str - :param resource_type: The resource type of the resource to update. + :param resource_type: The resource type of the resource to update. Required. :type resource_type: str - :param resource_name: The name of the resource to update. + :param resource_name: The name of the resource to update. Required. :type resource_name: str - :param api_version: The API version to use for the operation. + :param api_version: The API version to use for the operation. Required. :type api_version: str - :param parameters: Parameters for updating the resource. - :type parameters: ~azure.mgmt.resource.resources.v2019_05_10.models.GenericResource + :param parameters: Parameters for updating the resource. Is either a model type or a IO type. + Required. + :type parameters: ~azure.mgmt.resource.resources.v2019_05_10.models.GenericResource or IO + :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. + Default value is None. + :paramtype content_type: str :keyword callable cls: A custom type or function that will be passed the direct response :keyword str continuation_token: A continuation token to restart a poller from a saved state. :keyword polling: By default, your polling method will be ARMPolling. Pass in False for this @@ -5650,18 +6239,18 @@ def begin_update( cls(response) :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.resource.resources.v2019_05_10.models.GenericResource] - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] - polling = kwargs.pop('polling', True) # type: Union[bool, PollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType["_models.GenericResource"] - lro_delay = kwargs.pop( - 'polling_interval', - self._config.polling_interval - ) - cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = kwargs.pop("params", {}) or {} + + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.GenericResource] + polling = kwargs.pop("polling", True) # type: Union[bool, PollingMethod] + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token = kwargs.pop("continuation_token", None) # type: Optional[str] if cont_token is None: - raw_result = self._update_initial( + raw_result = self._update_initial( # type: ignore resource_group_name=resource_group_name, resource_provider_namespace=resource_provider_namespace, parent_resource_path=parent_resource_path, @@ -5670,32 +6259,35 @@ def begin_update( api_version=api_version, parameters=parameters, content_type=content_type, - cls=lambda x,y,z: x, + cls=lambda x, y, z: x, + headers=_headers, + params=_params, **kwargs ) - kwargs.pop('error_map', None) + kwargs.pop("error_map", None) def get_long_running_output(pipeline_response): - response = pipeline_response.http_response - deserialized = self._deserialize('GenericResource', pipeline_response) + deserialized = self._deserialize("GenericResource", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - - if polling is True: polling_method = ARMPolling(lro_delay, **kwargs) - elif polling is False: polling_method = NoPolling() - else: polling_method = polling + if polling is True: + polling_method = cast(PollingMethod, ARMPolling(lro_delay, **kwargs)) # type: PollingMethod + elif polling is False: + polling_method = cast(PollingMethod, NoPolling()) + else: + polling_method = polling if cont_token: return LROPoller.from_continuation_token( polling_method=polling_method, continuation_token=cont_token, client=self._client, - deserialization_callback=get_long_running_output + deserialization_callback=get_long_running_output, ) return LROPoller(self._client, raw_result, get_long_running_output, polling_method) - begin_update.metadata = {'url': "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{parentResourcePath}/{resourceType}/{resourceName}"} # type: ignore + begin_update.metadata = {"url": "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{parentResourcePath}/{resourceType}/{resourceName}"} # type: ignore @distributed_trace def get( @@ -5707,34 +6299,40 @@ def get( resource_name: str, api_version: str, **kwargs: Any - ) -> "_models.GenericResource": + ) -> _models.GenericResource: """Gets a resource. :param resource_group_name: The name of the resource group containing the resource to get. The - name is case insensitive. + name is case insensitive. Required. :type resource_group_name: str - :param resource_provider_namespace: The namespace of the resource provider. + :param resource_provider_namespace: The namespace of the resource provider. Required. :type resource_provider_namespace: str - :param parent_resource_path: The parent resource identity. + :param parent_resource_path: The parent resource identity. Required. :type parent_resource_path: str - :param resource_type: The resource type of the resource. + :param resource_type: The resource type of the resource. Required. :type resource_type: str - :param resource_name: The name of the resource to get. + :param resource_name: The name of the resource to get. Required. :type resource_name: str - :param api_version: The API version to use for the operation. + :param api_version: The API version to use for the operation. Required. :type api_version: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: GenericResource, or the result of cls(response) + :return: GenericResource or the result of cls(response) :rtype: ~azure.mgmt.resource.resources.v2019_05_10.models.GenericResource - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.GenericResource"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = kwargs.pop("params", {}) or {} + + cls = kwargs.pop("cls", None) # type: ClsType[_models.GenericResource] - request = build_resources_get_request( resource_group_name=resource_group_name, resource_provider_namespace=resource_provider_namespace, @@ -5743,72 +6341,75 @@ def get( resource_name=resource_name, subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.get.metadata['url'], + template_url=self.get.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) - deserialized = self._deserialize('GenericResource', pipeline_response) + deserialized = self._deserialize("GenericResource", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - get.metadata = {'url': "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{parentResourcePath}/{resourceType}/{resourceName}"} # type: ignore - + get.metadata = {"url": "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{parentResourcePath}/{resourceType}/{resourceName}"} # type: ignore @distributed_trace - def check_existence_by_id( - self, - resource_id: str, - api_version: str, - **kwargs: Any - ) -> bool: + def check_existence_by_id(self, resource_id: str, api_version: str, **kwargs: Any) -> bool: """Checks by ID whether a resource exists. :param resource_id: The fully qualified ID of the resource, including the resource name and resource type. Use the format, /subscriptions/{guid}/resourceGroups/{resource-group-name}/{resource-provider-namespace}/{resource-type}/{resource-name}. + Required. :type resource_id: str - :param api_version: The API version to use for the operation. + :param api_version: The API version to use for the operation. Required. :type api_version: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: bool, or the result of cls(response) + :return: bool or the result of cls(response) :rtype: bool - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType[None] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = kwargs.pop("params", {}) or {} + + cls = kwargs.pop("cls", None) # type: ClsType[None] - request = build_resources_check_existence_by_id_request( resource_id=resource_id, api_version=api_version, - template_url=self.check_existence_by_id.metadata['url'], + template_url=self.check_existence_by_id.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [204, 404]: @@ -5819,35 +6420,38 @@ def check_existence_by_id( return cls(pipeline_response, None, {}) return 200 <= response.status_code <= 299 - check_existence_by_id.metadata = {'url': "/{resourceId}"} # type: ignore - + check_existence_by_id.metadata = {"url": "/{resourceId}"} # type: ignore def _delete_by_id_initial( # pylint: disable=inconsistent-return-statements - self, - resource_id: str, - api_version: str, - **kwargs: Any + self, resource_id: str, api_version: str, **kwargs: Any ) -> None: - cls = kwargs.pop('cls', None) # type: ClsType[None] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) - - request = build_resources_delete_by_id_request_initial( + _headers = kwargs.pop("headers", {}) or {} + _params = kwargs.pop("params", {}) or {} + + cls = kwargs.pop("cls", None) # type: ClsType[None] + + request = build_resources_delete_by_id_request( resource_id=resource_id, api_version=api_version, - template_url=self._delete_by_id_initial.metadata['url'], + template_url=self._delete_by_id_initial.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200, 202, 204]: @@ -5857,23 +6461,18 @@ def _delete_by_id_initial( # pylint: disable=inconsistent-return-statements if cls: return cls(pipeline_response, None, {}) - _delete_by_id_initial.metadata = {'url': "/{resourceId}"} # type: ignore - + _delete_by_id_initial.metadata = {"url": "/{resourceId}"} # type: ignore @distributed_trace - def begin_delete_by_id( # pylint: disable=inconsistent-return-statements - self, - resource_id: str, - api_version: str, - **kwargs: Any - ) -> LROPoller[None]: + def begin_delete_by_id(self, resource_id: str, api_version: str, **kwargs: Any) -> LROPoller[None]: """Deletes a resource by ID. :param resource_id: The fully qualified ID of the resource, including the resource name and resource type. Use the format, /subscriptions/{guid}/resourceGroups/{resource-group-name}/{resource-provider-namespace}/{resource-type}/{resource-name}. + Required. :type resource_id: str - :param api_version: The API version to use for the operation. + :param api_version: The API version to use for the operation. Required. :type api_version: str :keyword callable cls: A custom type or function that will be passed the direct response :keyword str continuation_token: A continuation token to restart a poller from a saved state. @@ -5885,75 +6484,89 @@ def begin_delete_by_id( # pylint: disable=inconsistent-return-statements Retry-After header is present. :return: An instance of LROPoller that returns either None or the result of cls(response) :rtype: ~azure.core.polling.LROPoller[None] - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - polling = kwargs.pop('polling', True) # type: Union[bool, PollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType[None] - lro_delay = kwargs.pop( - 'polling_interval', - self._config.polling_interval - ) - cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] + _headers = kwargs.pop("headers", {}) or {} + _params = kwargs.pop("params", {}) or {} + + cls = kwargs.pop("cls", None) # type: ClsType[None] + polling = kwargs.pop("polling", True) # type: Union[bool, PollingMethod] + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token = kwargs.pop("continuation_token", None) # type: Optional[str] if cont_token is None: - raw_result = self._delete_by_id_initial( + raw_result = self._delete_by_id_initial( # type: ignore resource_id=resource_id, api_version=api_version, - cls=lambda x,y,z: x, + cls=lambda x, y, z: x, + headers=_headers, + params=_params, **kwargs ) - kwargs.pop('error_map', None) + kwargs.pop("error_map", None) - def get_long_running_output(pipeline_response): + def get_long_running_output(pipeline_response): # pylint: disable=inconsistent-return-statements if cls: return cls(pipeline_response, None, {}) - - if polling is True: polling_method = ARMPolling(lro_delay, **kwargs) - elif polling is False: polling_method = NoPolling() - else: polling_method = polling + if polling is True: + polling_method = cast(PollingMethod, ARMPolling(lro_delay, **kwargs)) # type: PollingMethod + elif polling is False: + polling_method = cast(PollingMethod, NoPolling()) + else: + polling_method = polling if cont_token: return LROPoller.from_continuation_token( polling_method=polling_method, continuation_token=cont_token, client=self._client, - deserialization_callback=get_long_running_output + deserialization_callback=get_long_running_output, ) return LROPoller(self._client, raw_result, get_long_running_output, polling_method) - begin_delete_by_id.metadata = {'url': "/{resourceId}"} # type: ignore + begin_delete_by_id.metadata = {"url": "/{resourceId}"} # type: ignore def _create_or_update_by_id_initial( - self, - resource_id: str, - api_version: str, - parameters: "_models.GenericResource", - **kwargs: Any - ) -> Optional["_models.GenericResource"]: - cls = kwargs.pop('cls', None) # type: ClsType[Optional["_models.GenericResource"]] + self, resource_id: str, api_version: str, parameters: Union[_models.GenericResource, IO], **kwargs: Any + ) -> Optional[_models.GenericResource]: error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = kwargs.pop("params", {}) or {} - _json = self._serialize.body(parameters, 'GenericResource') + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[Optional[_models.GenericResource]] - request = build_resources_create_or_update_by_id_request_initial( + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(parameters, (IO, bytes)): + _content = parameters + else: + _json = self._serialize.body(parameters, "GenericResource") + + request = build_resources_create_or_update_by_id_request( resource_id=resource_id, - content_type=content_type, api_version=api_version, + content_type=content_type, json=_json, - template_url=self._create_or_update_by_id_initial.metadata['url'], + content=_content, + template_url=self._create_or_update_by_id_initial.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200, 201, 202]: @@ -5962,37 +6575,42 @@ def _create_or_update_by_id_initial( deserialized = None if response.status_code == 200: - deserialized = self._deserialize('GenericResource', pipeline_response) + deserialized = self._deserialize("GenericResource", pipeline_response) if response.status_code == 201: - deserialized = self._deserialize('GenericResource', pipeline_response) + deserialized = self._deserialize("GenericResource", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - _create_or_update_by_id_initial.metadata = {'url': "/{resourceId}"} # type: ignore - + _create_or_update_by_id_initial.metadata = {"url": "/{resourceId}"} # type: ignore - @distributed_trace + @overload def begin_create_or_update_by_id( self, resource_id: str, api_version: str, - parameters: "_models.GenericResource", + parameters: _models.GenericResource, + *, + content_type: str = "application/json", **kwargs: Any - ) -> LROPoller["_models.GenericResource"]: + ) -> LROPoller[_models.GenericResource]: """Create a resource by ID. :param resource_id: The fully qualified ID of the resource, including the resource name and resource type. Use the format, /subscriptions/{guid}/resourceGroups/{resource-group-name}/{resource-provider-namespace}/{resource-type}/{resource-name}. + Required. :type resource_id: str - :param api_version: The API version to use for the operation. + :param api_version: The API version to use for the operation. Required. :type api_version: str - :param parameters: Create or update resource parameters. + :param parameters: Create or update resource parameters. Required. :type parameters: ~azure.mgmt.resource.resources.v2019_05_10.models.GenericResource + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str :keyword callable cls: A custom type or function that will be passed the direct response :keyword str continuation_token: A continuation token to restart a poller from a saved state. :keyword polling: By default, your polling method will be ARMPolling. Pass in False for this @@ -6005,81 +6623,167 @@ def begin_create_or_update_by_id( cls(response) :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.resource.resources.v2019_05_10.models.GenericResource] - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] - polling = kwargs.pop('polling', True) # type: Union[bool, PollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType["_models.GenericResource"] - lro_delay = kwargs.pop( - 'polling_interval', - self._config.polling_interval - ) - cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] + + @overload + def begin_create_or_update_by_id( + self, + resource_id: str, + api_version: str, + parameters: IO, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> LROPoller[_models.GenericResource]: + """Create a resource by ID. + + :param resource_id: The fully qualified ID of the resource, including the resource name and + resource type. Use the format, + /subscriptions/{guid}/resourceGroups/{resource-group-name}/{resource-provider-namespace}/{resource-type}/{resource-name}. + Required. + :type resource_id: str + :param api_version: The API version to use for the operation. Required. + :type api_version: str + :param parameters: Create or update resource parameters. Required. + :type parameters: IO + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be ARMPolling. Pass in False for this + operation to not poll, or pass in your own initialized polling object for a personal polling + strategy. + :paramtype polling: bool or ~azure.core.polling.PollingMethod + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of LROPoller that returns either GenericResource or the result of + cls(response) + :rtype: + ~azure.core.polling.LROPoller[~azure.mgmt.resource.resources.v2019_05_10.models.GenericResource] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace + def begin_create_or_update_by_id( + self, resource_id: str, api_version: str, parameters: Union[_models.GenericResource, IO], **kwargs: Any + ) -> LROPoller[_models.GenericResource]: + """Create a resource by ID. + + :param resource_id: The fully qualified ID of the resource, including the resource name and + resource type. Use the format, + /subscriptions/{guid}/resourceGroups/{resource-group-name}/{resource-provider-namespace}/{resource-type}/{resource-name}. + Required. + :type resource_id: str + :param api_version: The API version to use for the operation. Required. + :type api_version: str + :param parameters: Create or update resource parameters. Is either a model type or a IO type. + Required. + :type parameters: ~azure.mgmt.resource.resources.v2019_05_10.models.GenericResource or IO + :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. + Default value is None. + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be ARMPolling. Pass in False for this + operation to not poll, or pass in your own initialized polling object for a personal polling + strategy. + :paramtype polling: bool or ~azure.core.polling.PollingMethod + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of LROPoller that returns either GenericResource or the result of + cls(response) + :rtype: + ~azure.core.polling.LROPoller[~azure.mgmt.resource.resources.v2019_05_10.models.GenericResource] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = kwargs.pop("params", {}) or {} + + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.GenericResource] + polling = kwargs.pop("polling", True) # type: Union[bool, PollingMethod] + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token = kwargs.pop("continuation_token", None) # type: Optional[str] if cont_token is None: - raw_result = self._create_or_update_by_id_initial( + raw_result = self._create_or_update_by_id_initial( # type: ignore resource_id=resource_id, api_version=api_version, parameters=parameters, content_type=content_type, - cls=lambda x,y,z: x, + cls=lambda x, y, z: x, + headers=_headers, + params=_params, **kwargs ) - kwargs.pop('error_map', None) + kwargs.pop("error_map", None) def get_long_running_output(pipeline_response): - response = pipeline_response.http_response - deserialized = self._deserialize('GenericResource', pipeline_response) + deserialized = self._deserialize("GenericResource", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - - if polling is True: polling_method = ARMPolling(lro_delay, **kwargs) - elif polling is False: polling_method = NoPolling() - else: polling_method = polling + if polling is True: + polling_method = cast(PollingMethod, ARMPolling(lro_delay, **kwargs)) # type: PollingMethod + elif polling is False: + polling_method = cast(PollingMethod, NoPolling()) + else: + polling_method = polling if cont_token: return LROPoller.from_continuation_token( polling_method=polling_method, continuation_token=cont_token, client=self._client, - deserialization_callback=get_long_running_output + deserialization_callback=get_long_running_output, ) return LROPoller(self._client, raw_result, get_long_running_output, polling_method) - begin_create_or_update_by_id.metadata = {'url': "/{resourceId}"} # type: ignore + begin_create_or_update_by_id.metadata = {"url": "/{resourceId}"} # type: ignore def _update_by_id_initial( - self, - resource_id: str, - api_version: str, - parameters: "_models.GenericResource", - **kwargs: Any - ) -> Optional["_models.GenericResource"]: - cls = kwargs.pop('cls', None) # type: ClsType[Optional["_models.GenericResource"]] + self, resource_id: str, api_version: str, parameters: Union[_models.GenericResource, IO], **kwargs: Any + ) -> Optional[_models.GenericResource]: error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = kwargs.pop("params", {}) or {} - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[Optional[_models.GenericResource]] - _json = self._serialize.body(parameters, 'GenericResource') + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(parameters, (IO, bytes)): + _content = parameters + else: + _json = self._serialize.body(parameters, "GenericResource") - request = build_resources_update_by_id_request_initial( + request = build_resources_update_by_id_request( resource_id=resource_id, - content_type=content_type, api_version=api_version, + content_type=content_type, json=_json, - template_url=self._update_by_id_initial.metadata['url'], + content=_content, + template_url=self._update_by_id_initial.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200, 202]: @@ -6088,34 +6792,111 @@ def _update_by_id_initial( deserialized = None if response.status_code == 200: - deserialized = self._deserialize('GenericResource', pipeline_response) + deserialized = self._deserialize("GenericResource", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - _update_by_id_initial.metadata = {'url': "/{resourceId}"} # type: ignore + _update_by_id_initial.metadata = {"url": "/{resourceId}"} # type: ignore + @overload + def begin_update_by_id( + self, + resource_id: str, + api_version: str, + parameters: _models.GenericResource, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> LROPoller[_models.GenericResource]: + """Updates a resource by ID. + + :param resource_id: The fully qualified ID of the resource, including the resource name and + resource type. Use the format, + /subscriptions/{guid}/resourceGroups/{resource-group-name}/{resource-provider-namespace}/{resource-type}/{resource-name}. + Required. + :type resource_id: str + :param api_version: The API version to use for the operation. Required. + :type api_version: str + :param parameters: Update resource parameters. Required. + :type parameters: ~azure.mgmt.resource.resources.v2019_05_10.models.GenericResource + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be ARMPolling. Pass in False for this + operation to not poll, or pass in your own initialized polling object for a personal polling + strategy. + :paramtype polling: bool or ~azure.core.polling.PollingMethod + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of LROPoller that returns either GenericResource or the result of + cls(response) + :rtype: + ~azure.core.polling.LROPoller[~azure.mgmt.resource.resources.v2019_05_10.models.GenericResource] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + def begin_update_by_id( + self, + resource_id: str, + api_version: str, + parameters: IO, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> LROPoller[_models.GenericResource]: + """Updates a resource by ID. + + :param resource_id: The fully qualified ID of the resource, including the resource name and + resource type. Use the format, + /subscriptions/{guid}/resourceGroups/{resource-group-name}/{resource-provider-namespace}/{resource-type}/{resource-name}. + Required. + :type resource_id: str + :param api_version: The API version to use for the operation. Required. + :type api_version: str + :param parameters: Update resource parameters. Required. + :type parameters: IO + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be ARMPolling. Pass in False for this + operation to not poll, or pass in your own initialized polling object for a personal polling + strategy. + :paramtype polling: bool or ~azure.core.polling.PollingMethod + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of LROPoller that returns either GenericResource or the result of + cls(response) + :rtype: + ~azure.core.polling.LROPoller[~azure.mgmt.resource.resources.v2019_05_10.models.GenericResource] + :raises ~azure.core.exceptions.HttpResponseError: + """ @distributed_trace def begin_update_by_id( - self, - resource_id: str, - api_version: str, - parameters: "_models.GenericResource", - **kwargs: Any - ) -> LROPoller["_models.GenericResource"]: + self, resource_id: str, api_version: str, parameters: Union[_models.GenericResource, IO], **kwargs: Any + ) -> LROPoller[_models.GenericResource]: """Updates a resource by ID. :param resource_id: The fully qualified ID of the resource, including the resource name and resource type. Use the format, /subscriptions/{guid}/resourceGroups/{resource-group-name}/{resource-provider-namespace}/{resource-type}/{resource-name}. + Required. :type resource_id: str - :param api_version: The API version to use for the operation. + :param api_version: The API version to use for the operation. Required. :type api_version: str - :param parameters: Update resource parameters. - :type parameters: ~azure.mgmt.resource.resources.v2019_05_10.models.GenericResource + :param parameters: Update resource parameters. Is either a model type or a IO type. Required. + :type parameters: ~azure.mgmt.resource.resources.v2019_05_10.models.GenericResource or IO + :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. + Default value is None. + :paramtype content_type: str :keyword callable cls: A custom type or function that will be passed the direct response :keyword str continuation_token: A continuation token to restart a poller from a saved state. :keyword polling: By default, your polling method will be ARMPolling. Pass in False for this @@ -6128,165 +6909,171 @@ def begin_update_by_id( cls(response) :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.resource.resources.v2019_05_10.models.GenericResource] - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] - polling = kwargs.pop('polling', True) # type: Union[bool, PollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType["_models.GenericResource"] - lro_delay = kwargs.pop( - 'polling_interval', - self._config.polling_interval - ) - cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = kwargs.pop("params", {}) or {} + + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.GenericResource] + polling = kwargs.pop("polling", True) # type: Union[bool, PollingMethod] + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token = kwargs.pop("continuation_token", None) # type: Optional[str] if cont_token is None: - raw_result = self._update_by_id_initial( + raw_result = self._update_by_id_initial( # type: ignore resource_id=resource_id, api_version=api_version, parameters=parameters, content_type=content_type, - cls=lambda x,y,z: x, + cls=lambda x, y, z: x, + headers=_headers, + params=_params, **kwargs ) - kwargs.pop('error_map', None) + kwargs.pop("error_map", None) def get_long_running_output(pipeline_response): - response = pipeline_response.http_response - deserialized = self._deserialize('GenericResource', pipeline_response) + deserialized = self._deserialize("GenericResource", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - - if polling is True: polling_method = ARMPolling(lro_delay, **kwargs) - elif polling is False: polling_method = NoPolling() - else: polling_method = polling + if polling is True: + polling_method = cast(PollingMethod, ARMPolling(lro_delay, **kwargs)) # type: PollingMethod + elif polling is False: + polling_method = cast(PollingMethod, NoPolling()) + else: + polling_method = polling if cont_token: return LROPoller.from_continuation_token( polling_method=polling_method, continuation_token=cont_token, client=self._client, - deserialization_callback=get_long_running_output + deserialization_callback=get_long_running_output, ) return LROPoller(self._client, raw_result, get_long_running_output, polling_method) - begin_update_by_id.metadata = {'url': "/{resourceId}"} # type: ignore + begin_update_by_id.metadata = {"url": "/{resourceId}"} # type: ignore @distributed_trace - def get_by_id( - self, - resource_id: str, - api_version: str, - **kwargs: Any - ) -> "_models.GenericResource": + def get_by_id(self, resource_id: str, api_version: str, **kwargs: Any) -> _models.GenericResource: """Gets a resource by ID. :param resource_id: The fully qualified ID of the resource, including the resource name and resource type. Use the format, /subscriptions/{guid}/resourceGroups/{resource-group-name}/{resource-provider-namespace}/{resource-type}/{resource-name}. + Required. :type resource_id: str - :param api_version: The API version to use for the operation. + :param api_version: The API version to use for the operation. Required. :type api_version: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: GenericResource, or the result of cls(response) + :return: GenericResource or the result of cls(response) :rtype: ~azure.mgmt.resource.resources.v2019_05_10.models.GenericResource - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.GenericResource"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = kwargs.pop("params", {}) or {} + + cls = kwargs.pop("cls", None) # type: ClsType[_models.GenericResource] - request = build_resources_get_by_id_request( resource_id=resource_id, api_version=api_version, - template_url=self.get_by_id.metadata['url'], + template_url=self.get_by_id.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) - deserialized = self._deserialize('GenericResource', pipeline_response) + deserialized = self._deserialize("GenericResource", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - get_by_id.metadata = {'url': "/{resourceId}"} # type: ignore + get_by_id.metadata = {"url": "/{resourceId}"} # type: ignore -class ResourceGroupsOperations(object): - """ResourceGroupsOperations operations. - You should not instantiate this class directly. Instead, you should create a Client instance that - instantiates it for you and attaches it as an attribute. +class ResourceGroupsOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. - :ivar models: Alias to model classes used in this operation group. - :type models: ~azure.mgmt.resource.resources.v2019_05_10.models - :param client: Client for service requests. - :param config: Configuration of service client. - :param serializer: An object model serializer. - :param deserializer: An object model deserializer. + Instead, you should access the following operations through + :class:`~azure.mgmt.resource.resources.v2019_05_10.ResourceManagementClient`'s + :attr:`resource_groups` attribute. """ models = _models - def __init__(self, client, config, serializer, deserializer): - self._client = client - self._serialize = serializer - self._deserialize = deserializer - self._config = config + def __init__(self, *args, **kwargs): + input_args = list(args) + self._client = input_args.pop(0) if input_args else kwargs.pop("client") + self._config = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") @distributed_trace - def check_existence( - self, - resource_group_name: str, - **kwargs: Any - ) -> bool: + def check_existence(self, resource_group_name: str, **kwargs: Any) -> bool: """Checks whether a resource group exists. :param resource_group_name: The name of the resource group to check. The name is case - insensitive. + insensitive. Required. :type resource_group_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: bool, or the result of cls(response) + :return: bool or the result of cls(response) :rtype: bool - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType[None] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) - api_version = kwargs.pop('api_version', "2019-05-10") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2019-05-10")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[None] - request = build_resource_groups_check_existence_request( resource_group_name=resource_group_name, subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.check_existence.metadata['url'], + template_url=self.check_existence.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [204, 404]: @@ -6297,39 +7084,98 @@ def check_existence( return cls(pipeline_response, None, {}) return 200 <= response.status_code <= 299 - check_existence.metadata = {'url': "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}"} # type: ignore + check_existence.metadata = {"url": "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}"} # type: ignore - - @distributed_trace + @overload def create_or_update( self, resource_group_name: str, - parameters: "_models.ResourceGroup", + parameters: _models.ResourceGroup, + *, + content_type: str = "application/json", **kwargs: Any - ) -> "_models.ResourceGroup": + ) -> _models.ResourceGroup: """Creates or updates a resource group. :param resource_group_name: The name of the resource group to create or update. Can include alphanumeric, underscore, parentheses, hyphen, period (except at end), and Unicode characters - that match the allowed characters. + that match the allowed characters. Required. :type resource_group_name: str - :param parameters: Parameters supplied to the create or update a resource group. + :param parameters: Parameters supplied to the create or update a resource group. Required. :type parameters: ~azure.mgmt.resource.resources.v2019_05_10.models.ResourceGroup + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: ResourceGroup or the result of cls(response) + :rtype: ~azure.mgmt.resource.resources.v2019_05_10.models.ResourceGroup + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + def create_or_update( + self, resource_group_name: str, parameters: IO, *, content_type: str = "application/json", **kwargs: Any + ) -> _models.ResourceGroup: + """Creates or updates a resource group. + + :param resource_group_name: The name of the resource group to create or update. Can include + alphanumeric, underscore, parentheses, hyphen, period (except at end), and Unicode characters + that match the allowed characters. Required. + :type resource_group_name: str + :param parameters: Parameters supplied to the create or update a resource group. Required. + :type parameters: IO + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: ResourceGroup or the result of cls(response) + :rtype: ~azure.mgmt.resource.resources.v2019_05_10.models.ResourceGroup + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace + def create_or_update( + self, resource_group_name: str, parameters: Union[_models.ResourceGroup, IO], **kwargs: Any + ) -> _models.ResourceGroup: + """Creates or updates a resource group. + + :param resource_group_name: The name of the resource group to create or update. Can include + alphanumeric, underscore, parentheses, hyphen, period (except at end), and Unicode characters + that match the allowed characters. Required. + :type resource_group_name: str + :param parameters: Parameters supplied to the create or update a resource group. Is either a + model type or a IO type. Required. + :type parameters: ~azure.mgmt.resource.resources.v2019_05_10.models.ResourceGroup or IO + :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. + Default value is None. + :paramtype content_type: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: ResourceGroup, or the result of cls(response) + :return: ResourceGroup or the result of cls(response) :rtype: ~azure.mgmt.resource.resources.v2019_05_10.models.ResourceGroup - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.ResourceGroup"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) - api_version = kwargs.pop('api_version', "2019-05-10") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - _json = self._serialize.body(parameters, 'ResourceGroup') + api_version = kwargs.pop("api_version", _params.pop("api-version", "2019-05-10")) # type: str + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.ResourceGroup] + + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(parameters, (IO, bytes)): + _content = parameters + else: + _json = self._serialize.body(parameters, "ResourceGroup") request = build_resource_groups_create_or_update_request( resource_group_name=resource_group_name, @@ -6337,16 +7183,18 @@ def create_or_update( api_version=api_version, content_type=content_type, json=_json, - template_url=self.create_or_update.metadata['url'], + content=_content, + template_url=self.create_or_update.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200, 201]: @@ -6354,47 +7202,50 @@ def create_or_update( raise HttpResponseError(response=response, error_format=ARMErrorFormat) if response.status_code == 200: - deserialized = self._deserialize('ResourceGroup', pipeline_response) + deserialized = self._deserialize("ResourceGroup", pipeline_response) if response.status_code == 201: - deserialized = self._deserialize('ResourceGroup', pipeline_response) + deserialized = self._deserialize("ResourceGroup", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - create_or_update.metadata = {'url': "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}"} # type: ignore - + create_or_update.metadata = {"url": "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}"} # type: ignore def _delete_initial( # pylint: disable=inconsistent-return-statements - self, - resource_group_name: str, - **kwargs: Any + self, resource_group_name: str, **kwargs: Any ) -> None: - cls = kwargs.pop('cls', None) # type: ClsType[None] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) - api_version = kwargs.pop('api_version', "2019-05-10") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - request = build_resource_groups_delete_request_initial( + api_version = kwargs.pop("api_version", _params.pop("api-version", "2019-05-10")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[None] + + request = build_resource_groups_delete_request( resource_group_name=resource_group_name, subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self._delete_initial.metadata['url'], + template_url=self._delete_initial.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200, 202]: @@ -6404,22 +7255,17 @@ def _delete_initial( # pylint: disable=inconsistent-return-statements if cls: return cls(pipeline_response, None, {}) - _delete_initial.metadata = {'url': "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}"} # type: ignore - + _delete_initial.metadata = {"url": "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}"} # type: ignore @distributed_trace - def begin_delete( # pylint: disable=inconsistent-return-statements - self, - resource_group_name: str, - **kwargs: Any - ) -> LROPoller[None]: + def begin_delete(self, resource_group_name: str, **kwargs: Any) -> LROPoller[None]: """Deletes a resource group. When you delete a resource group, all of its resources are also deleted. Deleting a resource group deletes all of its template deployments and currently stored operations. :param resource_group_name: The name of the resource group to delete. The name is case - insensitive. + insensitive. Required. :type resource_group_name: str :keyword callable cls: A custom type or function that will be passed the direct response :keyword str continuation_token: A continuation token to restart a poller from a saved state. @@ -6431,106 +7277,113 @@ def begin_delete( # pylint: disable=inconsistent-return-statements Retry-After header is present. :return: An instance of LROPoller that returns either None or the result of cls(response) :rtype: ~azure.core.polling.LROPoller[None] - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - api_version = kwargs.pop('api_version', "2019-05-10") # type: str - polling = kwargs.pop('polling', True) # type: Union[bool, PollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType[None] - lro_delay = kwargs.pop( - 'polling_interval', - self._config.polling_interval - ) - cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2019-05-10")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[None] + polling = kwargs.pop("polling", True) # type: Union[bool, PollingMethod] + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token = kwargs.pop("continuation_token", None) # type: Optional[str] if cont_token is None: - raw_result = self._delete_initial( + raw_result = self._delete_initial( # type: ignore resource_group_name=resource_group_name, api_version=api_version, - cls=lambda x,y,z: x, + cls=lambda x, y, z: x, + headers=_headers, + params=_params, **kwargs ) - kwargs.pop('error_map', None) + kwargs.pop("error_map", None) - def get_long_running_output(pipeline_response): + def get_long_running_output(pipeline_response): # pylint: disable=inconsistent-return-statements if cls: return cls(pipeline_response, None, {}) - - if polling is True: polling_method = ARMPolling(lro_delay, **kwargs) - elif polling is False: polling_method = NoPolling() - else: polling_method = polling + if polling is True: + polling_method = cast(PollingMethod, ARMPolling(lro_delay, **kwargs)) # type: PollingMethod + elif polling is False: + polling_method = cast(PollingMethod, NoPolling()) + else: + polling_method = polling if cont_token: return LROPoller.from_continuation_token( polling_method=polling_method, continuation_token=cont_token, client=self._client, - deserialization_callback=get_long_running_output + deserialization_callback=get_long_running_output, ) return LROPoller(self._client, raw_result, get_long_running_output, polling_method) - begin_delete.metadata = {'url': "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}"} # type: ignore + begin_delete.metadata = {"url": "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}"} # type: ignore @distributed_trace - def get( - self, - resource_group_name: str, - **kwargs: Any - ) -> "_models.ResourceGroup": + def get(self, resource_group_name: str, **kwargs: Any) -> _models.ResourceGroup: """Gets a resource group. :param resource_group_name: The name of the resource group to get. The name is case - insensitive. + insensitive. Required. :type resource_group_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: ResourceGroup, or the result of cls(response) + :return: ResourceGroup or the result of cls(response) :rtype: ~azure.mgmt.resource.resources.v2019_05_10.models.ResourceGroup - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.ResourceGroup"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) - api_version = kwargs.pop('api_version', "2019-05-10") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2019-05-10")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[_models.ResourceGroup] - request = build_resource_groups_get_request( resource_group_name=resource_group_name, subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.get.metadata['url'], + template_url=self.get.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) - deserialized = self._deserialize('ResourceGroup', pipeline_response) + deserialized = self._deserialize("ResourceGroup", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - get.metadata = {'url': "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}"} # type: ignore + get.metadata = {"url": "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}"} # type: ignore - - @distributed_trace + @overload def update( self, resource_group_name: str, - parameters: "_models.ResourceGroupPatchable", + parameters: _models.ResourceGroupPatchable, + *, + content_type: str = "application/json", **kwargs: Any - ) -> "_models.ResourceGroup": + ) -> _models.ResourceGroup: """Updates a resource group. Resource groups can be updated through a simple PATCH operation to a group address. The format @@ -6538,25 +7391,90 @@ def update( the current value is retained. :param resource_group_name: The name of the resource group to update. The name is case - insensitive. + insensitive. Required. :type resource_group_name: str - :param parameters: Parameters supplied to update a resource group. + :param parameters: Parameters supplied to update a resource group. Required. :type parameters: ~azure.mgmt.resource.resources.v2019_05_10.models.ResourceGroupPatchable + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: ResourceGroup or the result of cls(response) + :rtype: ~azure.mgmt.resource.resources.v2019_05_10.models.ResourceGroup + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + def update( + self, resource_group_name: str, parameters: IO, *, content_type: str = "application/json", **kwargs: Any + ) -> _models.ResourceGroup: + """Updates a resource group. + + Resource groups can be updated through a simple PATCH operation to a group address. The format + of the request is the same as that for creating a resource group. If a field is unspecified, + the current value is retained. + + :param resource_group_name: The name of the resource group to update. The name is case + insensitive. Required. + :type resource_group_name: str + :param parameters: Parameters supplied to update a resource group. Required. + :type parameters: IO + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: ResourceGroup or the result of cls(response) + :rtype: ~azure.mgmt.resource.resources.v2019_05_10.models.ResourceGroup + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace + def update( + self, resource_group_name: str, parameters: Union[_models.ResourceGroupPatchable, IO], **kwargs: Any + ) -> _models.ResourceGroup: + """Updates a resource group. + + Resource groups can be updated through a simple PATCH operation to a group address. The format + of the request is the same as that for creating a resource group. If a field is unspecified, + the current value is retained. + + :param resource_group_name: The name of the resource group to update. The name is case + insensitive. Required. + :type resource_group_name: str + :param parameters: Parameters supplied to update a resource group. Is either a model type or a + IO type. Required. + :type parameters: ~azure.mgmt.resource.resources.v2019_05_10.models.ResourceGroupPatchable or + IO + :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. + Default value is None. + :paramtype content_type: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: ResourceGroup, or the result of cls(response) + :return: ResourceGroup or the result of cls(response) :rtype: ~azure.mgmt.resource.resources.v2019_05_10.models.ResourceGroup - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.ResourceGroup"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) - api_version = kwargs.pop('api_version', "2019-05-10") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - _json = self._serialize.body(parameters, 'ResourceGroupPatchable') + api_version = kwargs.pop("api_version", _params.pop("api-version", "2019-05-10")) # type: str + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.ResourceGroup] + + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(parameters, (IO, bytes)): + _content = parameters + else: + _json = self._serialize.body(parameters, "ResourceGroupPatchable") request = build_resource_groups_update_request( resource_group_name=resource_group_name, @@ -6564,60 +7482,117 @@ def update( api_version=api_version, content_type=content_type, json=_json, - template_url=self.update.metadata['url'], + content=_content, + template_url=self.update.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) - deserialized = self._deserialize('ResourceGroup', pipeline_response) + deserialized = self._deserialize("ResourceGroup", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - update.metadata = {'url': "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}"} # type: ignore + update.metadata = {"url": "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}"} # type: ignore - - @distributed_trace + @overload def export_template( self, resource_group_name: str, - parameters: "_models.ExportTemplateRequest", + parameters: _models.ExportTemplateRequest, + *, + content_type: str = "application/json", **kwargs: Any - ) -> "_models.ResourceGroupExportResult": + ) -> _models.ResourceGroupExportResult: """Captures the specified resource group as a template. - :param resource_group_name: The name of the resource group to export as a template. + :param resource_group_name: The name of the resource group to export as a template. Required. :type resource_group_name: str - :param parameters: Parameters for exporting the template. + :param parameters: Parameters for exporting the template. Required. :type parameters: ~azure.mgmt.resource.resources.v2019_05_10.models.ExportTemplateRequest + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: ResourceGroupExportResult or the result of cls(response) + :rtype: ~azure.mgmt.resource.resources.v2019_05_10.models.ResourceGroupExportResult + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + def export_template( + self, resource_group_name: str, parameters: IO, *, content_type: str = "application/json", **kwargs: Any + ) -> _models.ResourceGroupExportResult: + """Captures the specified resource group as a template. + + :param resource_group_name: The name of the resource group to export as a template. Required. + :type resource_group_name: str + :param parameters: Parameters for exporting the template. Required. + :type parameters: IO + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: ResourceGroupExportResult or the result of cls(response) + :rtype: ~azure.mgmt.resource.resources.v2019_05_10.models.ResourceGroupExportResult + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace + def export_template( + self, resource_group_name: str, parameters: Union[_models.ExportTemplateRequest, IO], **kwargs: Any + ) -> _models.ResourceGroupExportResult: + """Captures the specified resource group as a template. + + :param resource_group_name: The name of the resource group to export as a template. Required. + :type resource_group_name: str + :param parameters: Parameters for exporting the template. Is either a model type or a IO type. + Required. + :type parameters: ~azure.mgmt.resource.resources.v2019_05_10.models.ExportTemplateRequest or IO + :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. + Default value is None. + :paramtype content_type: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: ResourceGroupExportResult, or the result of cls(response) + :return: ResourceGroupExportResult or the result of cls(response) :rtype: ~azure.mgmt.resource.resources.v2019_05_10.models.ResourceGroupExportResult - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.ResourceGroupExportResult"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) - api_version = kwargs.pop('api_version', "2019-05-10") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - _json = self._serialize.body(parameters, 'ExportTemplateRequest') + api_version = kwargs.pop("api_version", _params.pop("api-version", "2019-05-10")) # type: str + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.ResourceGroupExportResult] + + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(parameters, (IO, bytes)): + _content = parameters + else: + _json = self._serialize.body(parameters, "ExportTemplateRequest") request = build_resource_groups_export_template_request( resource_group_name=resource_group_name, @@ -6625,39 +7600,37 @@ def export_template( api_version=api_version, content_type=content_type, json=_json, - template_url=self.export_template.metadata['url'], + content=_content, + template_url=self.export_template.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) - deserialized = self._deserialize('ResourceGroupExportResult', pipeline_response) + deserialized = self._deserialize("ResourceGroupExportResult", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - export_template.metadata = {'url': "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/exportTemplate"} # type: ignore - + export_template.metadata = {"url": "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/exportTemplate"} # type: ignore @distributed_trace def list( - self, - filter: Optional[str] = None, - top: Optional[int] = None, - **kwargs: Any - ) -> Iterable["_models.ResourceGroupListResult"]: + self, filter: Optional[str] = None, top: Optional[int] = None, **kwargs: Any + ) -> Iterable["_models.ResourceGroup"]: """Gets all the resource groups for a subscription. :param filter: The filter to apply on the operation.:code:`
`:code:`
`You can filter by @@ -6668,40 +7641,48 @@ def list( Default value is None. :type top: int :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either ResourceGroupListResult or the result of - cls(response) + :return: An iterator like instance of either ResourceGroup or the result of cls(response) :rtype: - ~azure.core.paging.ItemPaged[~azure.mgmt.resource.resources.v2019_05_10.models.ResourceGroupListResult] - :raises: ~azure.core.exceptions.HttpResponseError + ~azure.core.paging.ItemPaged[~azure.mgmt.resource.resources.v2019_05_10.models.ResourceGroup] + :raises ~azure.core.exceptions.HttpResponseError: """ - api_version = kwargs.pop('api_version', "2019-05-10") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2019-05-10")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[_models.ResourceGroupListResult] - cls = kwargs.pop('cls', None) # type: ClsType["_models.ResourceGroupListResult"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) + def prepare_request(next_link=None): if not next_link: - + request = build_resource_groups_list_request( subscription_id=self._config.subscription_id, - api_version=api_version, filter=filter, top=top, - template_url=self.list.metadata['url'], + 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.url = self._client.format_url(request.url) # type: ignore else: - - request = build_resource_groups_list_request( - subscription_id=self._config.subscription_id, - template_url=next_link, - ) + # make call to next link with the client's api-version + _parsed_next_link = urlparse(next_link) + _next_request_params = case_insensitive_dict(parse_qs(_parsed_next_link.query)) + _next_request_params["api-version"] = self._config.api_version + request = HttpRequest("GET", urljoin(next_link, _parsed_next_link.path), params=_next_request_params) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore request.method = "GET" return request @@ -6715,10 +7696,8 @@ def extract_data(pipeline_response): def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) response = pipeline_response.http_response @@ -6728,75 +7707,75 @@ def get_next(next_link=None): return pipeline_response + return ItemPaged(get_next, extract_data) - return ItemPaged( - get_next, extract_data - ) - list.metadata = {'url': "/subscriptions/{subscriptionId}/resourcegroups"} # type: ignore -class TagsOperations(object): - """TagsOperations operations. - - You should not instantiate this class directly. Instead, you should create a Client instance that - instantiates it for you and attaches it as an attribute. - - :ivar models: Alias to model classes used in this operation group. - :type models: ~azure.mgmt.resource.resources.v2019_05_10.models - :param client: Client for service requests. - :param config: Configuration of service client. - :param serializer: An object model serializer. - :param deserializer: An object model deserializer. + list.metadata = {"url": "/subscriptions/{subscriptionId}/resourcegroups"} # type: ignore + + +class TagsOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. + + Instead, you should access the following operations through + :class:`~azure.mgmt.resource.resources.v2019_05_10.ResourceManagementClient`'s + :attr:`tags` attribute. """ models = _models - def __init__(self, client, config, serializer, deserializer): - self._client = client - self._serialize = serializer - self._deserialize = deserializer - self._config = config + def __init__(self, *args, **kwargs): + input_args = list(args) + self._client = input_args.pop(0) if input_args else kwargs.pop("client") + self._config = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") @distributed_trace def delete_value( # pylint: disable=inconsistent-return-statements - self, - tag_name: str, - tag_value: str, - **kwargs: Any + self, tag_name: str, tag_value: str, **kwargs: Any ) -> None: """Deletes a tag value. - :param tag_name: The name of the tag. + :param tag_name: The name of the tag. Required. :type tag_name: str - :param tag_value: The value of the tag to delete. + :param tag_value: The value of the tag to delete. Required. :type tag_value: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: None, or the result of cls(response) + :return: None or the result of cls(response) :rtype: None - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType[None] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) - api_version = kwargs.pop('api_version', "2019-05-10") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2019-05-10")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[None] - request = build_tags_delete_value_request( tag_name=tag_name, tag_value=tag_value, subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.delete_value.metadata['url'], + template_url=self.delete_value.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200, 204]: @@ -6806,51 +7785,51 @@ def delete_value( # pylint: disable=inconsistent-return-statements if cls: return cls(pipeline_response, None, {}) - delete_value.metadata = {'url': "/subscriptions/{subscriptionId}/tagNames/{tagName}/tagValues/{tagValue}"} # type: ignore - + delete_value.metadata = {"url": "/subscriptions/{subscriptionId}/tagNames/{tagName}/tagValues/{tagValue}"} # type: ignore @distributed_trace - def create_or_update_value( - self, - tag_name: str, - tag_value: str, - **kwargs: Any - ) -> "_models.TagValue": + def create_or_update_value(self, tag_name: str, tag_value: str, **kwargs: Any) -> _models.TagValue: """Creates a tag value. The name of the tag must already exist. - :param tag_name: The name of the tag. + :param tag_name: The name of the tag. Required. :type tag_name: str - :param tag_value: The value of the tag to create. + :param tag_value: The value of the tag to create. Required. :type tag_value: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: TagValue, or the result of cls(response) + :return: TagValue or the result of cls(response) :rtype: ~azure.mgmt.resource.resources.v2019_05_10.models.TagValue - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.TagValue"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + 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', "2019-05-10") # type: str + api_version = kwargs.pop("api_version", _params.pop("api-version", "2019-05-10")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[_models.TagValue] - request = build_tags_create_or_update_value_request( tag_name=tag_name, tag_value=tag_value, subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.create_or_update_value.metadata['url'], + template_url=self.create_or_update_value.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200, 201]: @@ -6858,61 +7837,62 @@ def create_or_update_value( raise HttpResponseError(response=response, error_format=ARMErrorFormat) if response.status_code == 200: - deserialized = self._deserialize('TagValue', pipeline_response) + deserialized = self._deserialize("TagValue", pipeline_response) if response.status_code == 201: - deserialized = self._deserialize('TagValue', pipeline_response) + deserialized = self._deserialize("TagValue", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - create_or_update_value.metadata = {'url': "/subscriptions/{subscriptionId}/tagNames/{tagName}/tagValues/{tagValue}"} # type: ignore - + create_or_update_value.metadata = {"url": "/subscriptions/{subscriptionId}/tagNames/{tagName}/tagValues/{tagValue}"} # type: ignore @distributed_trace - def create_or_update( - self, - tag_name: str, - **kwargs: Any - ) -> "_models.TagDetails": + def create_or_update(self, tag_name: str, **kwargs: Any) -> _models.TagDetails: """Creates a tag in the subscription. The tag name can have a maximum of 512 characters and is case insensitive. Tag names created by Azure have prefixes of microsoft, azure, or windows. You cannot create tags with one of these prefixes. - :param tag_name: The name of the tag to create. + :param tag_name: The name of the tag to create. Required. :type tag_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: TagDetails, or the result of cls(response) + :return: TagDetails or the result of cls(response) :rtype: ~azure.mgmt.resource.resources.v2019_05_10.models.TagDetails - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.TagDetails"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + 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', "2019-05-10") # type: str + api_version = kwargs.pop("api_version", _params.pop("api-version", "2019-05-10")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[_models.TagDetails] - request = build_tags_create_or_update_request( tag_name=tag_name, subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.create_or_update.metadata['url'], + template_url=self.create_or_update.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200, 201]: @@ -6920,59 +7900,60 @@ def create_or_update( raise HttpResponseError(response=response, error_format=ARMErrorFormat) if response.status_code == 200: - deserialized = self._deserialize('TagDetails', pipeline_response) + deserialized = self._deserialize("TagDetails", pipeline_response) if response.status_code == 201: - deserialized = self._deserialize('TagDetails', pipeline_response) + deserialized = self._deserialize("TagDetails", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - create_or_update.metadata = {'url': "/subscriptions/{subscriptionId}/tagNames/{tagName}"} # type: ignore - + create_or_update.metadata = {"url": "/subscriptions/{subscriptionId}/tagNames/{tagName}"} # type: ignore @distributed_trace - def delete( # pylint: disable=inconsistent-return-statements - self, - tag_name: str, - **kwargs: Any - ) -> None: + def delete(self, tag_name: str, **kwargs: Any) -> None: # pylint: disable=inconsistent-return-statements """Deletes a tag from the subscription. You must remove all values from a resource tag before you can delete it. - :param tag_name: The name of the tag. + :param tag_name: The name of the tag. Required. :type tag_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: None, or the result of cls(response) + :return: None or the result of cls(response) :rtype: None - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType[None] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + 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', "2019-05-10") # type: str + api_version = kwargs.pop("api_version", _params.pop("api-version", "2019-05-10")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[None] - request = build_tags_delete_request( tag_name=tag_name, subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.delete.metadata['url'], + template_url=self.delete.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200, 204]: @@ -6982,48 +7963,53 @@ def delete( # pylint: disable=inconsistent-return-statements if cls: return cls(pipeline_response, None, {}) - delete.metadata = {'url': "/subscriptions/{subscriptionId}/tagNames/{tagName}"} # type: ignore - + delete.metadata = {"url": "/subscriptions/{subscriptionId}/tagNames/{tagName}"} # type: ignore @distributed_trace - def list( - self, - **kwargs: Any - ) -> Iterable["_models.TagsListResult"]: + def list(self, **kwargs: Any) -> Iterable["_models.TagDetails"]: """Gets the names and values of all resource tags that are defined in a subscription. :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either TagsListResult or the result of cls(response) + :return: An iterator like instance of either TagDetails or the result of cls(response) :rtype: - ~azure.core.paging.ItemPaged[~azure.mgmt.resource.resources.v2019_05_10.models.TagsListResult] - :raises: ~azure.core.exceptions.HttpResponseError + ~azure.core.paging.ItemPaged[~azure.mgmt.resource.resources.v2019_05_10.models.TagDetails] + :raises ~azure.core.exceptions.HttpResponseError: """ - api_version = kwargs.pop('api_version', "2019-05-10") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2019-05-10")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[_models.TagsListResult] - cls = kwargs.pop('cls', None) # type: ClsType["_models.TagsListResult"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) + def prepare_request(next_link=None): if not next_link: - + request = build_tags_list_request( subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.list.metadata['url'], + template_url=self.list.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore else: - - request = build_tags_list_request( - subscription_id=self._config.subscription_id, - template_url=next_link, - ) + # make call to next link with the client's api-version + _parsed_next_link = urlparse(next_link) + _next_request_params = case_insensitive_dict(parse_qs(_parsed_next_link.query)) + _next_request_params["api-version"] = self._config.api_version + request = HttpRequest("GET", urljoin(next_link, _parsed_next_link.path), params=_next_request_params) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore request.method = "GET" return request @@ -7037,10 +8023,8 @@ def extract_data(pipeline_response): def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) response = pipeline_response.http_response @@ -7050,146 +8034,147 @@ def get_next(next_link=None): return pipeline_response + return ItemPaged(get_next, extract_data) - return ItemPaged( - get_next, extract_data - ) - list.metadata = {'url': "/subscriptions/{subscriptionId}/tagNames"} # type: ignore -class DeploymentOperationsOperations(object): - """DeploymentOperationsOperations operations. - - You should not instantiate this class directly. Instead, you should create a Client instance that - instantiates it for you and attaches it as an attribute. - - :ivar models: Alias to model classes used in this operation group. - :type models: ~azure.mgmt.resource.resources.v2019_05_10.models - :param client: Client for service requests. - :param config: Configuration of service client. - :param serializer: An object model serializer. - :param deserializer: An object model deserializer. + list.metadata = {"url": "/subscriptions/{subscriptionId}/tagNames"} # type: ignore + + +class DeploymentOperationsOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. + + Instead, you should access the following operations through + :class:`~azure.mgmt.resource.resources.v2019_05_10.ResourceManagementClient`'s + :attr:`deployment_operations` attribute. """ models = _models - def __init__(self, client, config, serializer, deserializer): - self._client = client - self._serialize = serializer - self._deserialize = deserializer - self._config = config + def __init__(self, *args, **kwargs): + input_args = list(args) + self._client = input_args.pop(0) if input_args else kwargs.pop("client") + self._config = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") @distributed_trace def get_at_management_group_scope( - self, - group_id: str, - deployment_name: str, - operation_id: str, - **kwargs: Any - ) -> "_models.DeploymentOperation": + self, group_id: str, deployment_name: str, operation_id: str, **kwargs: Any + ) -> _models.DeploymentOperation: """Gets a deployments operation. - :param group_id: The management group ID. + :param group_id: The management group ID. Required. :type group_id: str - :param deployment_name: The name of the deployment. + :param deployment_name: The name of the deployment. Required. :type deployment_name: str - :param operation_id: The ID of the operation to get. + :param operation_id: The ID of the operation to get. Required. :type operation_id: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: DeploymentOperation, or the result of cls(response) + :return: DeploymentOperation or the result of cls(response) :rtype: ~azure.mgmt.resource.resources.v2019_05_10.models.DeploymentOperation - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.DeploymentOperation"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + 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', "2019-05-10") # type: str + api_version = kwargs.pop("api_version", _params.pop("api-version", "2019-05-10")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[_models.DeploymentOperation] - request = build_deployment_operations_get_at_management_group_scope_request( group_id=group_id, deployment_name=deployment_name, operation_id=operation_id, api_version=api_version, - template_url=self.get_at_management_group_scope.metadata['url'], + template_url=self.get_at_management_group_scope.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) - deserialized = self._deserialize('DeploymentOperation', pipeline_response) + deserialized = self._deserialize("DeploymentOperation", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - get_at_management_group_scope.metadata = {'url': "/providers/Microsoft.Management/managementGroups/{groupId}/providers/Microsoft.Resources/deployments/{deploymentName}/operations/{operationId}"} # type: ignore - + get_at_management_group_scope.metadata = {"url": "/providers/Microsoft.Management/managementGroups/{groupId}/providers/Microsoft.Resources/deployments/{deploymentName}/operations/{operationId}"} # type: ignore @distributed_trace def list_at_management_group_scope( - self, - group_id: str, - deployment_name: str, - top: Optional[int] = None, - **kwargs: Any - ) -> Iterable["_models.DeploymentOperationsListResult"]: + self, group_id: str, deployment_name: str, top: Optional[int] = None, **kwargs: Any + ) -> Iterable["_models.DeploymentOperation"]: """Gets all deployments operations for a deployment. - :param group_id: The management group ID. + :param group_id: The management group ID. Required. :type group_id: str - :param deployment_name: The name of the deployment. + :param deployment_name: The name of the deployment. Required. :type deployment_name: str :param top: The number of results to return. Default value is None. :type top: int :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either DeploymentOperationsListResult or the result of - cls(response) + :return: An iterator like instance of either DeploymentOperation or the result of cls(response) :rtype: - ~azure.core.paging.ItemPaged[~azure.mgmt.resource.resources.v2019_05_10.models.DeploymentOperationsListResult] - :raises: ~azure.core.exceptions.HttpResponseError + ~azure.core.paging.ItemPaged[~azure.mgmt.resource.resources.v2019_05_10.models.DeploymentOperation] + :raises ~azure.core.exceptions.HttpResponseError: """ - api_version = kwargs.pop('api_version', "2019-05-10") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2019-05-10")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[_models.DeploymentOperationsListResult] - cls = kwargs.pop('cls', None) # type: ClsType["_models.DeploymentOperationsListResult"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) + def prepare_request(next_link=None): if not next_link: - + request = build_deployment_operations_list_at_management_group_scope_request( group_id=group_id, deployment_name=deployment_name, - api_version=api_version, top=top, - template_url=self.list_at_management_group_scope.metadata['url'], + api_version=api_version, + template_url=self.list_at_management_group_scope.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore else: - - request = build_deployment_operations_list_at_management_group_scope_request( - group_id=group_id, - deployment_name=deployment_name, - template_url=next_link, - ) + # make call to next link with the client's api-version + _parsed_next_link = urlparse(next_link) + _next_request_params = case_insensitive_dict(parse_qs(_parsed_next_link.query)) + _next_request_params["api-version"] = self._config.api_version + request = HttpRequest("GET", urljoin(next_link, _parsed_next_link.path), params=_next_request_params) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore request.method = "GET" return request @@ -7203,10 +8188,8 @@ def extract_data(pipeline_response): def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) response = pipeline_response.http_response @@ -7216,119 +8199,123 @@ def get_next(next_link=None): return pipeline_response + return ItemPaged(get_next, extract_data) - return ItemPaged( - get_next, extract_data - ) - list_at_management_group_scope.metadata = {'url': "/providers/Microsoft.Management/managementGroups/{groupId}/providers/Microsoft.Resources/deployments/{deploymentName}/operations"} # type: ignore + list_at_management_group_scope.metadata = {"url": "/providers/Microsoft.Management/managementGroups/{groupId}/providers/Microsoft.Resources/deployments/{deploymentName}/operations"} # type: ignore @distributed_trace def get_at_subscription_scope( - self, - deployment_name: str, - operation_id: str, - **kwargs: Any - ) -> "_models.DeploymentOperation": + self, deployment_name: str, operation_id: str, **kwargs: Any + ) -> _models.DeploymentOperation: """Gets a deployments operation. - :param deployment_name: The name of the deployment. + :param deployment_name: The name of the deployment. Required. :type deployment_name: str - :param operation_id: The ID of the operation to get. + :param operation_id: The ID of the operation to get. Required. :type operation_id: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: DeploymentOperation, or the result of cls(response) + :return: DeploymentOperation or the result of cls(response) :rtype: ~azure.mgmt.resource.resources.v2019_05_10.models.DeploymentOperation - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.DeploymentOperation"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) - api_version = kwargs.pop('api_version', "2019-05-10") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2019-05-10")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[_models.DeploymentOperation] - request = build_deployment_operations_get_at_subscription_scope_request( deployment_name=deployment_name, operation_id=operation_id, subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.get_at_subscription_scope.metadata['url'], + template_url=self.get_at_subscription_scope.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) - deserialized = self._deserialize('DeploymentOperation', pipeline_response) + deserialized = self._deserialize("DeploymentOperation", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - get_at_subscription_scope.metadata = {'url': "/subscriptions/{subscriptionId}/providers/Microsoft.Resources/deployments/{deploymentName}/operations/{operationId}"} # type: ignore - + get_at_subscription_scope.metadata = {"url": "/subscriptions/{subscriptionId}/providers/Microsoft.Resources/deployments/{deploymentName}/operations/{operationId}"} # type: ignore @distributed_trace def list_at_subscription_scope( - self, - deployment_name: str, - top: Optional[int] = None, - **kwargs: Any - ) -> Iterable["_models.DeploymentOperationsListResult"]: + self, deployment_name: str, top: Optional[int] = None, **kwargs: Any + ) -> Iterable["_models.DeploymentOperation"]: """Gets all deployments operations for a deployment. - :param deployment_name: The name of the deployment. + :param deployment_name: The name of the deployment. Required. :type deployment_name: str :param top: The number of results to return. Default value is None. :type top: int :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either DeploymentOperationsListResult or the result of - cls(response) + :return: An iterator like instance of either DeploymentOperation or the result of cls(response) :rtype: - ~azure.core.paging.ItemPaged[~azure.mgmt.resource.resources.v2019_05_10.models.DeploymentOperationsListResult] - :raises: ~azure.core.exceptions.HttpResponseError + ~azure.core.paging.ItemPaged[~azure.mgmt.resource.resources.v2019_05_10.models.DeploymentOperation] + :raises ~azure.core.exceptions.HttpResponseError: """ - api_version = kwargs.pop('api_version', "2019-05-10") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2019-05-10")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[_models.DeploymentOperationsListResult] - cls = kwargs.pop('cls', None) # type: ClsType["_models.DeploymentOperationsListResult"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) + def prepare_request(next_link=None): if not next_link: - + request = build_deployment_operations_list_at_subscription_scope_request( deployment_name=deployment_name, subscription_id=self._config.subscription_id, - api_version=api_version, top=top, - template_url=self.list_at_subscription_scope.metadata['url'], + api_version=api_version, + template_url=self.list_at_subscription_scope.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore else: - - request = build_deployment_operations_list_at_subscription_scope_request( - deployment_name=deployment_name, - subscription_id=self._config.subscription_id, - template_url=next_link, - ) + # make call to next link with the client's api-version + _parsed_next_link = urlparse(next_link) + _next_request_params = case_insensitive_dict(parse_qs(_parsed_next_link.query)) + _next_request_params["api-version"] = self._config.api_version + request = HttpRequest("GET", urljoin(next_link, _parsed_next_link.path), params=_next_request_params) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore request.method = "GET" return request @@ -7342,10 +8329,8 @@ def extract_data(pipeline_response): def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) response = pipeline_response.http_response @@ -7355,128 +8340,131 @@ def get_next(next_link=None): return pipeline_response + return ItemPaged(get_next, extract_data) - return ItemPaged( - get_next, extract_data - ) - list_at_subscription_scope.metadata = {'url': "/subscriptions/{subscriptionId}/providers/Microsoft.Resources/deployments/{deploymentName}/operations"} # type: ignore + list_at_subscription_scope.metadata = {"url": "/subscriptions/{subscriptionId}/providers/Microsoft.Resources/deployments/{deploymentName}/operations"} # type: ignore @distributed_trace def get( - self, - resource_group_name: str, - deployment_name: str, - operation_id: str, - **kwargs: Any - ) -> "_models.DeploymentOperation": + self, resource_group_name: str, deployment_name: str, operation_id: str, **kwargs: Any + ) -> _models.DeploymentOperation: """Gets a deployments operation. :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. :type resource_group_name: str - :param deployment_name: The name of the deployment. + :param deployment_name: The name of the deployment. Required. :type deployment_name: str - :param operation_id: The ID of the operation to get. + :param operation_id: The ID of the operation to get. Required. :type operation_id: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: DeploymentOperation, or the result of cls(response) + :return: DeploymentOperation or the result of cls(response) :rtype: ~azure.mgmt.resource.resources.v2019_05_10.models.DeploymentOperation - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.DeploymentOperation"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + 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', "2019-05-10") # type: str + api_version = kwargs.pop("api_version", _params.pop("api-version", "2019-05-10")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[_models.DeploymentOperation] - request = build_deployment_operations_get_request( resource_group_name=resource_group_name, deployment_name=deployment_name, operation_id=operation_id, subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.get.metadata['url'], + template_url=self.get.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) - deserialized = self._deserialize('DeploymentOperation', pipeline_response) + deserialized = self._deserialize("DeploymentOperation", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - get.metadata = {'url': "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/deployments/{deploymentName}/operations/{operationId}"} # type: ignore - + get.metadata = {"url": "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/deployments/{deploymentName}/operations/{operationId}"} # type: ignore @distributed_trace def list( - self, - resource_group_name: str, - deployment_name: str, - top: Optional[int] = None, - **kwargs: Any - ) -> Iterable["_models.DeploymentOperationsListResult"]: + self, resource_group_name: str, deployment_name: str, top: Optional[int] = None, **kwargs: Any + ) -> Iterable["_models.DeploymentOperation"]: """Gets all deployments operations for a deployment. :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. :type resource_group_name: str - :param deployment_name: The name of the deployment. + :param deployment_name: The name of the deployment. Required. :type deployment_name: str :param top: The number of results to return. Default value is None. :type top: int :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either DeploymentOperationsListResult or the result of - cls(response) + :return: An iterator like instance of either DeploymentOperation or the result of cls(response) :rtype: - ~azure.core.paging.ItemPaged[~azure.mgmt.resource.resources.v2019_05_10.models.DeploymentOperationsListResult] - :raises: ~azure.core.exceptions.HttpResponseError + ~azure.core.paging.ItemPaged[~azure.mgmt.resource.resources.v2019_05_10.models.DeploymentOperation] + :raises ~azure.core.exceptions.HttpResponseError: """ - api_version = kwargs.pop('api_version', "2019-05-10") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2019-05-10")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[_models.DeploymentOperationsListResult] - cls = kwargs.pop('cls', None) # type: ClsType["_models.DeploymentOperationsListResult"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) + def prepare_request(next_link=None): if not next_link: - + request = build_deployment_operations_list_request( resource_group_name=resource_group_name, deployment_name=deployment_name, subscription_id=self._config.subscription_id, - api_version=api_version, top=top, - template_url=self.list.metadata['url'], + 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.url = self._client.format_url(request.url) # type: ignore else: - - request = build_deployment_operations_list_request( - resource_group_name=resource_group_name, - deployment_name=deployment_name, - subscription_id=self._config.subscription_id, - template_url=next_link, - ) + # make call to next link with the client's api-version + _parsed_next_link = urlparse(next_link) + _next_request_params = case_insensitive_dict(parse_qs(_parsed_next_link.query)) + _next_request_params["api-version"] = self._config.api_version + request = HttpRequest("GET", urljoin(next_link, _parsed_next_link.path), params=_next_request_params) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore request.method = "GET" return request @@ -7490,10 +8478,8 @@ def extract_data(pipeline_response): def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) response = pipeline_response.http_response @@ -7503,8 +8489,6 @@ def get_next(next_link=None): return pipeline_response + return ItemPaged(get_next, extract_data) - return ItemPaged( - get_next, extract_data - ) - list.metadata = {'url': "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/deployments/{deploymentName}/operations"} # type: ignore + list.metadata = {"url": "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/deployments/{deploymentName}/operations"} # type: ignore diff --git a/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/resources/v2019_05_10/operations/_patch.py b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/resources/v2019_05_10/operations/_patch.py new file mode 100644 index 0000000000000..f7dd32510333d --- /dev/null +++ b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/resources/v2019_05_10/operations/_patch.py @@ -0,0 +1,20 @@ +# ------------------------------------ +# Copyright (c) Microsoft Corporation. +# Licensed under the MIT License. +# ------------------------------------ +"""Customize generated code here. + +Follow our quickstart for examples: https://aka.ms/azsdk/python/dpcodegen/python/customize +""" +from typing import List + +__all__: List[str] = [] # Add all objects you want publicly available to users at this package level + + +def patch_sdk(): + """Do not remove from this file. + + `patch_sdk` is a last resort escape hatch that allows you to do customizations + you can't accomplish using the techniques described in + https://aka.ms/azsdk/python/dpcodegen/python/customize + """ diff --git a/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/resources/v2019_07_01/__init__.py b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/resources/v2019_07_01/__init__.py index 449220069f2f2..2b201470d075e 100644 --- a/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/resources/v2019_07_01/__init__.py +++ b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/resources/v2019_07_01/__init__.py @@ -10,9 +10,15 @@ from ._version import VERSION __version__ = VERSION -__all__ = ['ResourceManagementClient'] -# `._patch.py` is used for handwritten extensions to the generated code -# Example: https://github.com/Azure/azure-sdk-for-python/blob/main/doc/dev/customize_code/how-to-patch-sdk-code.md -from ._patch import patch_sdk -patch_sdk() +try: + from ._patch import __all__ as _patch_all + from ._patch import * # type: ignore # pylint: disable=unused-wildcard-import +except ImportError: + _patch_all = [] +from ._patch import patch_sdk as _patch_sdk + +__all__ = ["ResourceManagementClient"] +__all__.extend([p for p in _patch_all if p not in __all__]) + +_patch_sdk() diff --git a/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/resources/v2019_07_01/_configuration.py b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/resources/v2019_07_01/_configuration.py index f904593d9f993..218388070179e 100644 --- a/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/resources/v2019_07_01/_configuration.py +++ b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/resources/v2019_07_01/_configuration.py @@ -25,23 +25,18 @@ class ResourceManagementClientConfiguration(Configuration): # pylint: disable=t Note that all parameters used to create this instance are saved as instance attributes. - :param credential: Credential needed for the client to connect to Azure. + :param credential: Credential needed for the client to connect to Azure. Required. :type credential: ~azure.core.credentials.TokenCredential - :param subscription_id: The ID of the target subscription. + :param subscription_id: The ID of the target subscription. Required. :type subscription_id: str :keyword api_version: Api Version. Default value is "2019-07-01". Note that overriding this default value may result in unsupported behavior. :paramtype api_version: str """ - def __init__( - self, - credential: "TokenCredential", - subscription_id: str, - **kwargs: Any - ) -> None: + def __init__(self, credential: "TokenCredential", subscription_id: str, **kwargs: Any) -> None: super(ResourceManagementClientConfiguration, self).__init__(**kwargs) - api_version = kwargs.pop('api_version', "2019-07-01") # type: str + api_version = kwargs.pop("api_version", "2019-07-01") # type: str if credential is None: raise ValueError("Parameter 'credential' must not be None.") @@ -51,23 +46,24 @@ def __init__( self.credential = credential self.subscription_id = subscription_id self.api_version = api_version - self.credential_scopes = kwargs.pop('credential_scopes', ['https://management.azure.com/.default']) - kwargs.setdefault('sdk_moniker', 'mgmt-resource/{}'.format(VERSION)) + self.credential_scopes = kwargs.pop("credential_scopes", ["https://management.azure.com/.default"]) + kwargs.setdefault("sdk_moniker", "mgmt-resource/{}".format(VERSION)) self._configure(**kwargs) def _configure( - self, - **kwargs # type: Any + self, **kwargs # type: Any ): # type: (...) -> 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) - self.logging_policy = kwargs.get('logging_policy') or policies.NetworkTraceLoggingPolicy(**kwargs) - self.http_logging_policy = kwargs.get('http_logging_policy') or ARMHttpLoggingPolicy(**kwargs) - self.retry_policy = kwargs.get('retry_policy') or policies.RetryPolicy(**kwargs) - self.custom_hook_policy = kwargs.get('custom_hook_policy') or policies.CustomHookPolicy(**kwargs) - self.redirect_policy = kwargs.get('redirect_policy') or policies.RedirectPolicy(**kwargs) - self.authentication_policy = kwargs.get('authentication_policy') + 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) + self.logging_policy = kwargs.get("logging_policy") or policies.NetworkTraceLoggingPolicy(**kwargs) + self.http_logging_policy = kwargs.get("http_logging_policy") or ARMHttpLoggingPolicy(**kwargs) + self.retry_policy = kwargs.get("retry_policy") or policies.RetryPolicy(**kwargs) + self.custom_hook_policy = kwargs.get("custom_hook_policy") or policies.CustomHookPolicy(**kwargs) + self.redirect_policy = kwargs.get("redirect_policy") or policies.RedirectPolicy(**kwargs) + self.authentication_policy = kwargs.get("authentication_policy") if self.credential and not self.authentication_policy: - self.authentication_policy = ARMChallengeAuthenticationPolicy(self.credential, *self.credential_scopes, **kwargs) + self.authentication_policy = ARMChallengeAuthenticationPolicy( + self.credential, *self.credential_scopes, **kwargs + ) diff --git a/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/resources/v2019_07_01/_metadata.json b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/resources/v2019_07_01/_metadata.json index fa2fdc4be7dc4..70ddb250d129f 100644 --- a/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/resources/v2019_07_01/_metadata.json +++ b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/resources/v2019_07_01/_metadata.json @@ -10,20 +10,20 @@ "azure_arm": true, "has_lro_operations": true, "client_side_validation": false, - "sync_imports": "{\"typing\": {\"azurecore\": {\"azure.core.credentials\": [\"TokenCredential\"]}}, \"regular\": {\"azurecore\": {\"azure.profiles\": [\"KnownProfiles\", \"ProfileDefinition\"], \"azure.profiles.multiapiclient\": [\"MultiApiClientMixin\"], \"azure.mgmt.core\": [\"ARMPipelineClient\"]}, \"local\": {\"._configuration\": [\"ResourceManagementClientConfiguration\"]}, \"thirdparty\": {\"msrest\": [\"Deserializer\", \"Serializer\"]}}, \"conditional\": {\"stdlib\": {\"typing\": [\"Any\", \"Optional\"]}}}", - "async_imports": "{\"typing\": {\"azurecore\": {\"azure.core.credentials_async\": [\"AsyncTokenCredential\"], \"azure.core.credentials\": [\"TokenCredential\"]}}, \"regular\": {\"azurecore\": {\"azure.profiles\": [\"KnownProfiles\", \"ProfileDefinition\"], \"azure.profiles.multiapiclient\": [\"MultiApiClientMixin\"], \"azure.mgmt.core\": [\"AsyncARMPipelineClient\"]}, \"local\": {\"._configuration\": [\"ResourceManagementClientConfiguration\"]}, \"thirdparty\": {\"msrest\": [\"Deserializer\", \"Serializer\"]}}, \"conditional\": {\"stdlib\": {\"typing\": [\"Any\", \"Optional\"]}}}" + "sync_imports": "{\"conditional\": {\"stdlib\": {\"typing\": [\"Any\", \"Optional\"]}}, \"regular\": {\"azurecore\": {\"azure.mgmt.core\": [\"ARMPipelineClient\"], \"azure.profiles\": [\"KnownProfiles\", \"ProfileDefinition\"], \"azure.profiles.multiapiclient\": [\"MultiApiClientMixin\"]}, \"local\": {\"._configuration\": [\"ResourceManagementClientConfiguration\"], \".._serialization\": [\"Deserializer\", \"Serializer\"]}}, \"typing\": {\"azurecore\": {\"azure.core.credentials\": [\"TokenCredential\"]}}}", + "async_imports": "{\"conditional\": {\"stdlib\": {\"typing\": [\"Any\", \"Optional\"]}}, \"regular\": {\"azurecore\": {\"azure.mgmt.core\": [\"AsyncARMPipelineClient\"], \"azure.profiles\": [\"KnownProfiles\", \"ProfileDefinition\"], \"azure.profiles.multiapiclient\": [\"MultiApiClientMixin\"]}, \"local\": {\"._configuration\": [\"ResourceManagementClientConfiguration\"], \"..._serialization\": [\"Deserializer\", \"Serializer\"]}}, \"typing\": {\"azurecore\": {\"azure.core.credentials_async\": [\"AsyncTokenCredential\"]}}}" }, "global_parameters": { "sync": { "credential": { - "signature": "credential, # type: \"TokenCredential\"", - "description": "Credential needed for the client to connect to Azure.", + "signature": "credential: \"TokenCredential\",", + "description": "Credential needed for the client to connect to Azure. Required.", "docstring_type": "~azure.core.credentials.TokenCredential", "required": true }, "subscription_id": { - "signature": "subscription_id, # type: str", - "description": "The ID of the target subscription.", + "signature": "subscription_id: str,", + "description": "The ID of the target subscription. Required.", "docstring_type": "str", "required": true } @@ -31,13 +31,13 @@ "async": { "credential": { "signature": "credential: \"AsyncTokenCredential\",", - "description": "Credential needed for the client to connect to Azure.", + "description": "Credential needed for the client to connect to Azure. Required.", "docstring_type": "~azure.core.credentials_async.AsyncTokenCredential", "required": true }, "subscription_id": { "signature": "subscription_id: str,", - "description": "The ID of the target subscription.", + "description": "The ID of the target subscription. Required.", "docstring_type": "str", "required": true } @@ -54,7 +54,7 @@ "required": false }, "base_url": { - "signature": "base_url=\"https://management.azure.com\", # type: str", + "signature": "base_url: str = \"https://management.azure.com\",", "description": "Service URL", "docstring_type": "str", "required": false diff --git a/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/resources/v2019_07_01/_patch.py b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/resources/v2019_07_01/_patch.py index 74e48ecd07cf3..f99e77fef9861 100644 --- a/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/resources/v2019_07_01/_patch.py +++ b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/resources/v2019_07_01/_patch.py @@ -28,4 +28,4 @@ # This file is used for handwritten extensions to the generated code. Example: # https://github.com/Azure/azure-sdk-for-python/blob/main/doc/dev/customize_code/how-to-patch-sdk-code.md def patch_sdk(): - pass \ No newline at end of file + pass diff --git a/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/resources/v2019_07_01/_resource_management_client.py b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/resources/v2019_07_01/_resource_management_client.py index 20ad2375ce885..b915c5a6954d0 100644 --- a/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/resources/v2019_07_01/_resource_management_client.py +++ b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/resources/v2019_07_01/_resource_management_client.py @@ -9,20 +9,28 @@ from copy import deepcopy from typing import Any, TYPE_CHECKING -from msrest import Deserializer, Serializer - from azure.core.rest import HttpRequest, HttpResponse from azure.mgmt.core import ARMPipelineClient from . import models +from .._serialization import Deserializer, Serializer from ._configuration import ResourceManagementClientConfiguration -from .operations import DeploymentOperationsOperations, DeploymentsOperations, Operations, ProvidersOperations, ResourceGroupsOperations, ResourcesOperations, TagsOperations +from .operations import ( + DeploymentOperationsOperations, + DeploymentsOperations, + Operations, + ProvidersOperations, + ResourceGroupsOperations, + ResourcesOperations, + TagsOperations, +) if TYPE_CHECKING: # pylint: disable=unused-import,ungrouped-imports from azure.core.credentials import TokenCredential -class ResourceManagementClient: # pylint: disable=too-many-instance-attributes + +class ResourceManagementClient: # pylint: disable=client-accepts-api-version-keyword,too-many-instance-attributes """Provides operations for working with resources and resource groups. :ivar operations: Operations operations @@ -42,9 +50,9 @@ class ResourceManagementClient: # pylint: disable=too-many-instance-attribute :ivar deployment_operations: DeploymentOperationsOperations operations :vartype deployment_operations: azure.mgmt.resource.resources.v2019_07_01.operations.DeploymentOperationsOperations - :param credential: Credential needed for the client to connect to Azure. + :param credential: Credential needed for the client to connect to Azure. Required. :type credential: ~azure.core.credentials.TokenCredential - :param subscription_id: The ID of the target subscription. + :param subscription_id: The ID of the target subscription. Required. :type subscription_id: str :param base_url: Service URL. Default value is "https://management.azure.com". :type base_url: str @@ -62,7 +70,9 @@ def __init__( base_url: str = "https://management.azure.com", **kwargs: Any ) -> None: - self._config = ResourceManagementClientConfiguration(credential=credential, subscription_id=subscription_id, **kwargs) + self._config = ResourceManagementClientConfiguration( + credential=credential, subscription_id=subscription_id, **kwargs + ) self._client = ARMPipelineClient(base_url=base_url, config=self._config, **kwargs) client_models = {k: v for k, v in models.__dict__.items() if isinstance(v, type)} @@ -75,14 +85,11 @@ def __init__( self.resources = ResourcesOperations(self._client, self._config, self._serialize, self._deserialize) self.resource_groups = ResourceGroupsOperations(self._client, self._config, self._serialize, self._deserialize) self.tags = TagsOperations(self._client, self._config, self._serialize, self._deserialize) - self.deployment_operations = DeploymentOperationsOperations(self._client, self._config, self._serialize, self._deserialize) - + self.deployment_operations = DeploymentOperationsOperations( + self._client, self._config, self._serialize, self._deserialize + ) - def _send_request( - self, - request: HttpRequest, - **kwargs: Any - ) -> HttpResponse: + def _send_request(self, request: HttpRequest, **kwargs: Any) -> HttpResponse: """Runs the network request through the client's chained policies. >>> from azure.core.rest import HttpRequest @@ -91,7 +98,7 @@ def _send_request( >>> response = client._send_request(request) - For more information on this code flow, see https://aka.ms/azsdk/python/protocol/quickstart + For more information on this code flow, see https://aka.ms/azsdk/dpcodegen/python/send_request :param request: The network request you want to make. Required. :type request: ~azure.core.rest.HttpRequest diff --git a/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/resources/v2019_07_01/_vendor.py b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/resources/v2019_07_01/_vendor.py index 138f663c53a4e..9aad73fc743e7 100644 --- a/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/resources/v2019_07_01/_vendor.py +++ b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/resources/v2019_07_01/_vendor.py @@ -7,6 +7,7 @@ from azure.core.pipeline.transport import HttpRequest + def _convert_request(request, files=None): data = request.content if not files else None request = HttpRequest(method=request.method, url=request.url, headers=request.headers, data=data) @@ -14,6 +15,7 @@ def _convert_request(request, files=None): request.set_formdata_body(files) return request + def _format_url_section(template, **kwargs): components = template.split("/") while components: @@ -21,7 +23,5 @@ def _format_url_section(template, **kwargs): 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 - ] + components = [c for c in formatted_components if "{}".format(key.args[0]) not in c] template = "/".join(components) diff --git a/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/resources/v2019_07_01/_version.py b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/resources/v2019_07_01/_version.py index a012ac01c480c..e5754a47ce68f 100644 --- a/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/resources/v2019_07_01/_version.py +++ b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/resources/v2019_07_01/_version.py @@ -6,4 +6,4 @@ # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -VERSION = "21.1.0" +VERSION = "1.0.0b1" diff --git a/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/resources/v2019_07_01/aio/__init__.py b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/resources/v2019_07_01/aio/__init__.py index c6c3cf64a37a6..98d6782c2530c 100644 --- a/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/resources/v2019_07_01/aio/__init__.py +++ b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/resources/v2019_07_01/aio/__init__.py @@ -7,9 +7,15 @@ # -------------------------------------------------------------------------- from ._resource_management_client import ResourceManagementClient -__all__ = ['ResourceManagementClient'] -# `._patch.py` is used for handwritten extensions to the generated code -# Example: https://github.com/Azure/azure-sdk-for-python/blob/main/doc/dev/customize_code/how-to-patch-sdk-code.md -from ._patch import patch_sdk -patch_sdk() +try: + from ._patch import __all__ as _patch_all + from ._patch import * # type: ignore # pylint: disable=unused-wildcard-import +except ImportError: + _patch_all = [] +from ._patch import patch_sdk as _patch_sdk + +__all__ = ["ResourceManagementClient"] +__all__.extend([p for p in _patch_all if p not in __all__]) + +_patch_sdk() diff --git a/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/resources/v2019_07_01/aio/_configuration.py b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/resources/v2019_07_01/aio/_configuration.py index 3df44a9f0555f..0ce9b8ce2b9f0 100644 --- a/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/resources/v2019_07_01/aio/_configuration.py +++ b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/resources/v2019_07_01/aio/_configuration.py @@ -25,23 +25,18 @@ class ResourceManagementClientConfiguration(Configuration): # pylint: disable=t Note that all parameters used to create this instance are saved as instance attributes. - :param credential: Credential needed for the client to connect to Azure. + :param credential: Credential needed for the client to connect to Azure. Required. :type credential: ~azure.core.credentials_async.AsyncTokenCredential - :param subscription_id: The ID of the target subscription. + :param subscription_id: The ID of the target subscription. Required. :type subscription_id: str :keyword api_version: Api Version. Default value is "2019-07-01". Note that overriding this default value may result in unsupported behavior. :paramtype api_version: str """ - def __init__( - self, - credential: "AsyncTokenCredential", - subscription_id: str, - **kwargs: Any - ) -> None: + def __init__(self, credential: "AsyncTokenCredential", subscription_id: str, **kwargs: Any) -> None: super(ResourceManagementClientConfiguration, self).__init__(**kwargs) - api_version = kwargs.pop('api_version', "2019-07-01") # type: str + api_version = kwargs.pop("api_version", "2019-07-01") # type: str if credential is None: raise ValueError("Parameter 'credential' must not be None.") @@ -51,22 +46,21 @@ def __init__( self.credential = credential self.subscription_id = subscription_id self.api_version = api_version - self.credential_scopes = kwargs.pop('credential_scopes', ['https://management.azure.com/.default']) - kwargs.setdefault('sdk_moniker', 'mgmt-resource/{}'.format(VERSION)) + self.credential_scopes = kwargs.pop("credential_scopes", ["https://management.azure.com/.default"]) + kwargs.setdefault("sdk_moniker", "mgmt-resource/{}".format(VERSION)) self._configure(**kwargs) - 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) - self.logging_policy = kwargs.get('logging_policy') or policies.NetworkTraceLoggingPolicy(**kwargs) - self.http_logging_policy = kwargs.get('http_logging_policy') or ARMHttpLoggingPolicy(**kwargs) - self.retry_policy = kwargs.get('retry_policy') or policies.AsyncRetryPolicy(**kwargs) - self.custom_hook_policy = kwargs.get('custom_hook_policy') or policies.CustomHookPolicy(**kwargs) - self.redirect_policy = kwargs.get('redirect_policy') or policies.AsyncRedirectPolicy(**kwargs) - self.authentication_policy = kwargs.get('authentication_policy') + 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) + self.logging_policy = kwargs.get("logging_policy") or policies.NetworkTraceLoggingPolicy(**kwargs) + self.http_logging_policy = kwargs.get("http_logging_policy") or ARMHttpLoggingPolicy(**kwargs) + self.retry_policy = kwargs.get("retry_policy") or policies.AsyncRetryPolicy(**kwargs) + self.custom_hook_policy = kwargs.get("custom_hook_policy") or policies.CustomHookPolicy(**kwargs) + self.redirect_policy = kwargs.get("redirect_policy") or policies.AsyncRedirectPolicy(**kwargs) + self.authentication_policy = kwargs.get("authentication_policy") if self.credential and not self.authentication_policy: - self.authentication_policy = AsyncARMChallengeAuthenticationPolicy(self.credential, *self.credential_scopes, **kwargs) + self.authentication_policy = AsyncARMChallengeAuthenticationPolicy( + self.credential, *self.credential_scopes, **kwargs + ) diff --git a/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/resources/v2019_07_01/aio/_patch.py b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/resources/v2019_07_01/aio/_patch.py index 74e48ecd07cf3..f99e77fef9861 100644 --- a/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/resources/v2019_07_01/aio/_patch.py +++ b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/resources/v2019_07_01/aio/_patch.py @@ -28,4 +28,4 @@ # This file is used for handwritten extensions to the generated code. Example: # https://github.com/Azure/azure-sdk-for-python/blob/main/doc/dev/customize_code/how-to-patch-sdk-code.md def patch_sdk(): - pass \ No newline at end of file + pass diff --git a/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/resources/v2019_07_01/aio/_resource_management_client.py b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/resources/v2019_07_01/aio/_resource_management_client.py index 46bbac547eee6..f344ed4ebf2de 100644 --- a/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/resources/v2019_07_01/aio/_resource_management_client.py +++ b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/resources/v2019_07_01/aio/_resource_management_client.py @@ -9,20 +9,28 @@ from copy import deepcopy from typing import Any, Awaitable, TYPE_CHECKING -from msrest import Deserializer, Serializer - from azure.core.rest import AsyncHttpResponse, HttpRequest from azure.mgmt.core import AsyncARMPipelineClient from .. import models +from ..._serialization import Deserializer, Serializer from ._configuration import ResourceManagementClientConfiguration -from .operations import DeploymentOperationsOperations, DeploymentsOperations, Operations, ProvidersOperations, ResourceGroupsOperations, ResourcesOperations, TagsOperations +from .operations import ( + DeploymentOperationsOperations, + DeploymentsOperations, + Operations, + ProvidersOperations, + ResourceGroupsOperations, + ResourcesOperations, + TagsOperations, +) if TYPE_CHECKING: # pylint: disable=unused-import,ungrouped-imports from azure.core.credentials_async import AsyncTokenCredential -class ResourceManagementClient: # pylint: disable=too-many-instance-attributes + +class ResourceManagementClient: # pylint: disable=client-accepts-api-version-keyword,too-many-instance-attributes """Provides operations for working with resources and resource groups. :ivar operations: Operations operations @@ -44,9 +52,9 @@ class ResourceManagementClient: # pylint: disable=too-many-instance-attribute :ivar deployment_operations: DeploymentOperationsOperations operations :vartype deployment_operations: azure.mgmt.resource.resources.v2019_07_01.aio.operations.DeploymentOperationsOperations - :param credential: Credential needed for the client to connect to Azure. + :param credential: Credential needed for the client to connect to Azure. Required. :type credential: ~azure.core.credentials_async.AsyncTokenCredential - :param subscription_id: The ID of the target subscription. + :param subscription_id: The ID of the target subscription. Required. :type subscription_id: str :param base_url: Service URL. Default value is "https://management.azure.com". :type base_url: str @@ -64,7 +72,9 @@ def __init__( base_url: str = "https://management.azure.com", **kwargs: Any ) -> None: - self._config = ResourceManagementClientConfiguration(credential=credential, subscription_id=subscription_id, **kwargs) + self._config = ResourceManagementClientConfiguration( + credential=credential, subscription_id=subscription_id, **kwargs + ) self._client = AsyncARMPipelineClient(base_url=base_url, config=self._config, **kwargs) client_models = {k: v for k, v in models.__dict__.items() if isinstance(v, type)} @@ -77,14 +87,11 @@ def __init__( self.resources = ResourcesOperations(self._client, self._config, self._serialize, self._deserialize) self.resource_groups = ResourceGroupsOperations(self._client, self._config, self._serialize, self._deserialize) self.tags = TagsOperations(self._client, self._config, self._serialize, self._deserialize) - self.deployment_operations = DeploymentOperationsOperations(self._client, self._config, self._serialize, self._deserialize) - + self.deployment_operations = DeploymentOperationsOperations( + self._client, self._config, self._serialize, self._deserialize + ) - def _send_request( - self, - request: HttpRequest, - **kwargs: Any - ) -> Awaitable[AsyncHttpResponse]: + def _send_request(self, request: HttpRequest, **kwargs: Any) -> Awaitable[AsyncHttpResponse]: """Runs the network request through the client's chained policies. >>> from azure.core.rest import HttpRequest @@ -93,7 +100,7 @@ def _send_request( >>> response = await client._send_request(request) - For more information on this code flow, see https://aka.ms/azsdk/python/protocol/quickstart + For more information on this code flow, see https://aka.ms/azsdk/dpcodegen/python/send_request :param request: The network request you want to make. Required. :type request: ~azure.core.rest.HttpRequest diff --git a/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/resources/v2019_07_01/aio/operations/__init__.py b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/resources/v2019_07_01/aio/operations/__init__.py index 53876d82bf5d7..804fee65e3137 100644 --- a/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/resources/v2019_07_01/aio/operations/__init__.py +++ b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/resources/v2019_07_01/aio/operations/__init__.py @@ -14,12 +14,18 @@ from ._operations import TagsOperations from ._operations import DeploymentOperationsOperations +from ._patch import __all__ as _patch_all +from ._patch import * # type: ignore # pylint: disable=unused-wildcard-import +from ._patch import patch_sdk as _patch_sdk + __all__ = [ - 'Operations', - 'DeploymentsOperations', - 'ProvidersOperations', - 'ResourcesOperations', - 'ResourceGroupsOperations', - 'TagsOperations', - 'DeploymentOperationsOperations', + "Operations", + "DeploymentsOperations", + "ProvidersOperations", + "ResourcesOperations", + "ResourceGroupsOperations", + "TagsOperations", + "DeploymentOperationsOperations", ] +__all__.extend([p for p in _patch_all if p not in __all__]) +_patch_sdk() diff --git a/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/resources/v2019_07_01/aio/operations/_operations.py b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/resources/v2019_07_01/aio/operations/_operations.py index 6202829479edf..4568195238fb2 100644 --- a/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/resources/v2019_07_01/aio/operations/_operations.py +++ b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/resources/v2019_07_01/aio/operations/_operations.py @@ -6,84 +6,192 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -from typing import Any, AsyncIterable, Callable, Dict, Optional, TypeVar, Union +import sys +from typing import Any, AsyncIterable, Callable, Dict, IO, Optional, TypeVar, Union, cast, overload +from urllib.parse import parse_qs, urljoin, urlparse from azure.core.async_paging import AsyncItemPaged, AsyncList -from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error +from azure.core.exceptions import ( + ClientAuthenticationError, + HttpResponseError, + ResourceExistsError, + ResourceNotFoundError, + ResourceNotModifiedError, + map_error, +) from azure.core.pipeline import PipelineResponse from azure.core.pipeline.transport import AsyncHttpResponse from azure.core.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 from azure.mgmt.core.polling.async_arm_polling import AsyncARMPolling from ... import models as _models from ..._vendor import _convert_request -from ...operations._operations import build_deployment_operations_get_at_management_group_scope_request, build_deployment_operations_get_at_scope_request, build_deployment_operations_get_at_subscription_scope_request, build_deployment_operations_get_at_tenant_scope_request, build_deployment_operations_get_request, build_deployment_operations_list_at_management_group_scope_request, build_deployment_operations_list_at_scope_request, build_deployment_operations_list_at_subscription_scope_request, build_deployment_operations_list_at_tenant_scope_request, build_deployment_operations_list_request, build_deployments_calculate_template_hash_request, build_deployments_cancel_at_management_group_scope_request, build_deployments_cancel_at_scope_request, build_deployments_cancel_at_subscription_scope_request, build_deployments_cancel_at_tenant_scope_request, build_deployments_cancel_request, build_deployments_check_existence_at_management_group_scope_request, build_deployments_check_existence_at_scope_request, build_deployments_check_existence_at_subscription_scope_request, build_deployments_check_existence_at_tenant_scope_request, build_deployments_check_existence_request, build_deployments_create_or_update_at_management_group_scope_request_initial, build_deployments_create_or_update_at_scope_request_initial, build_deployments_create_or_update_at_subscription_scope_request_initial, build_deployments_create_or_update_at_tenant_scope_request_initial, build_deployments_create_or_update_request_initial, build_deployments_delete_at_management_group_scope_request_initial, build_deployments_delete_at_scope_request_initial, build_deployments_delete_at_subscription_scope_request_initial, build_deployments_delete_at_tenant_scope_request_initial, build_deployments_delete_request_initial, build_deployments_export_template_at_management_group_scope_request, build_deployments_export_template_at_scope_request, build_deployments_export_template_at_subscription_scope_request, build_deployments_export_template_at_tenant_scope_request, build_deployments_export_template_request, build_deployments_get_at_management_group_scope_request, build_deployments_get_at_scope_request, build_deployments_get_at_subscription_scope_request, build_deployments_get_at_tenant_scope_request, build_deployments_get_request, build_deployments_list_at_management_group_scope_request, build_deployments_list_at_scope_request, build_deployments_list_at_subscription_scope_request, build_deployments_list_at_tenant_scope_request, build_deployments_list_by_resource_group_request, build_deployments_validate_at_management_group_scope_request, build_deployments_validate_at_scope_request, build_deployments_validate_at_subscription_scope_request, build_deployments_validate_at_tenant_scope_request, build_deployments_validate_request, build_deployments_what_if_at_subscription_scope_request_initial, build_deployments_what_if_request_initial, build_operations_list_request, build_providers_get_at_tenant_scope_request, build_providers_get_request, build_providers_list_at_tenant_scope_request, build_providers_list_request, build_providers_register_request, build_providers_unregister_request, build_resource_groups_check_existence_request, build_resource_groups_create_or_update_request, build_resource_groups_delete_request_initial, build_resource_groups_export_template_request, build_resource_groups_get_request, build_resource_groups_list_request, build_resource_groups_update_request, build_resources_check_existence_by_id_request, build_resources_check_existence_request, build_resources_create_or_update_by_id_request_initial, build_resources_create_or_update_request_initial, build_resources_delete_by_id_request_initial, build_resources_delete_request_initial, build_resources_get_by_id_request, build_resources_get_request, build_resources_list_by_resource_group_request, build_resources_list_request, build_resources_move_resources_request_initial, build_resources_update_by_id_request_initial, build_resources_update_request_initial, build_resources_validate_move_resources_request_initial, build_tags_create_or_update_request, build_tags_create_or_update_value_request, build_tags_delete_request, build_tags_delete_value_request, build_tags_list_request -T = TypeVar('T') +from ...operations._operations import ( + build_deployment_operations_get_at_management_group_scope_request, + build_deployment_operations_get_at_scope_request, + build_deployment_operations_get_at_subscription_scope_request, + build_deployment_operations_get_at_tenant_scope_request, + build_deployment_operations_get_request, + build_deployment_operations_list_at_management_group_scope_request, + build_deployment_operations_list_at_scope_request, + build_deployment_operations_list_at_subscription_scope_request, + build_deployment_operations_list_at_tenant_scope_request, + build_deployment_operations_list_request, + build_deployments_calculate_template_hash_request, + build_deployments_cancel_at_management_group_scope_request, + build_deployments_cancel_at_scope_request, + build_deployments_cancel_at_subscription_scope_request, + build_deployments_cancel_at_tenant_scope_request, + build_deployments_cancel_request, + build_deployments_check_existence_at_management_group_scope_request, + build_deployments_check_existence_at_scope_request, + build_deployments_check_existence_at_subscription_scope_request, + build_deployments_check_existence_at_tenant_scope_request, + build_deployments_check_existence_request, + build_deployments_create_or_update_at_management_group_scope_request, + build_deployments_create_or_update_at_scope_request, + build_deployments_create_or_update_at_subscription_scope_request, + build_deployments_create_or_update_at_tenant_scope_request, + build_deployments_create_or_update_request, + build_deployments_delete_at_management_group_scope_request, + build_deployments_delete_at_scope_request, + build_deployments_delete_at_subscription_scope_request, + build_deployments_delete_at_tenant_scope_request, + build_deployments_delete_request, + build_deployments_export_template_at_management_group_scope_request, + build_deployments_export_template_at_scope_request, + build_deployments_export_template_at_subscription_scope_request, + build_deployments_export_template_at_tenant_scope_request, + build_deployments_export_template_request, + build_deployments_get_at_management_group_scope_request, + build_deployments_get_at_scope_request, + build_deployments_get_at_subscription_scope_request, + build_deployments_get_at_tenant_scope_request, + build_deployments_get_request, + build_deployments_list_at_management_group_scope_request, + build_deployments_list_at_scope_request, + build_deployments_list_at_subscription_scope_request, + build_deployments_list_at_tenant_scope_request, + build_deployments_list_by_resource_group_request, + build_deployments_validate_at_management_group_scope_request, + build_deployments_validate_at_scope_request, + build_deployments_validate_at_subscription_scope_request, + build_deployments_validate_at_tenant_scope_request, + build_deployments_validate_request, + build_deployments_what_if_at_subscription_scope_request, + build_deployments_what_if_request, + build_operations_list_request, + build_providers_get_at_tenant_scope_request, + build_providers_get_request, + build_providers_list_at_tenant_scope_request, + build_providers_list_request, + build_providers_register_request, + build_providers_unregister_request, + build_resource_groups_check_existence_request, + build_resource_groups_create_or_update_request, + build_resource_groups_delete_request, + build_resource_groups_export_template_request, + build_resource_groups_get_request, + build_resource_groups_list_request, + build_resource_groups_update_request, + build_resources_check_existence_by_id_request, + build_resources_check_existence_request, + build_resources_create_or_update_by_id_request, + build_resources_create_or_update_request, + build_resources_delete_by_id_request, + build_resources_delete_request, + build_resources_get_by_id_request, + build_resources_get_request, + build_resources_list_by_resource_group_request, + build_resources_list_request, + build_resources_move_resources_request, + build_resources_update_by_id_request, + build_resources_update_request, + build_resources_validate_move_resources_request, + build_tags_create_or_update_request, + build_tags_create_or_update_value_request, + build_tags_delete_request, + build_tags_delete_value_request, + build_tags_list_request, +) + +T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] +if sys.version_info >= (3, 9): + from collections.abc import MutableMapping +else: + from typing import MutableMapping # type: ignore # pylint: disable=ungrouped-imports +JSON = MutableMapping[str, Any] # pylint: disable=unsubscriptable-object -class Operations: - """Operations async operations. - You should not instantiate this class directly. Instead, you should create a Client instance that - instantiates it for you and attaches it as an attribute. +class Operations: + """ + .. warning:: + **DO NOT** instantiate this class directly. - :ivar models: Alias to model classes used in this operation group. - :type models: ~azure.mgmt.resource.resources.v2019_07_01.models - :param client: Client for service requests. - :param config: Configuration of service client. - :param serializer: An object model serializer. - :param deserializer: An object model deserializer. + Instead, you should access the following operations through + :class:`~azure.mgmt.resource.resources.v2019_07_01.aio.ResourceManagementClient`'s + :attr:`operations` attribute. """ models = _models - def __init__(self, client, config, serializer, deserializer) -> None: - self._client = client - self._serialize = serializer - self._deserialize = deserializer - self._config = config + def __init__(self, *args, **kwargs) -> None: + input_args = list(args) + self._client = input_args.pop(0) if input_args else kwargs.pop("client") + self._config = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") @distributed_trace - def list( - self, - **kwargs: Any - ) -> AsyncIterable["_models.OperationListResult"]: + def list(self, **kwargs: Any) -> AsyncIterable["_models.Operation"]: """Lists all of the available Microsoft.Resources REST API operations. :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either OperationListResult or the result of cls(response) + :return: An iterator like instance of either Operation or the result of cls(response) :rtype: - ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.resource.resources.v2019_07_01.models.OperationListResult] - :raises: ~azure.core.exceptions.HttpResponseError + ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.resource.resources.v2019_07_01.models.Operation] + :raises ~azure.core.exceptions.HttpResponseError: """ - api_version = kwargs.pop('api_version', "2019-07-01") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2019-07-01")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[_models.OperationListResult] - cls = kwargs.pop('cls', None) # type: ClsType["_models.OperationListResult"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) + def prepare_request(next_link=None): if not next_link: - + request = build_operations_list_request( api_version=api_version, - template_url=self.list.metadata['url'], + template_url=self.list.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore else: - - request = build_operations_list_request( - template_url=next_link, - ) + # make call to next link with the client's api-version + _parsed_next_link = urlparse(next_link) + _next_request_params = case_insensitive_dict(parse_qs(_parsed_next_link.query)) + _next_request_params["api-version"] = self._config.api_version + request = HttpRequest("GET", urljoin(next_link, _parsed_next_link.path), params=_next_request_params) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore request.method = "GET" return request @@ -97,10 +205,8 @@ async def extract_data(pipeline_response): async def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) response = pipeline_response.http_response @@ -110,62 +216,62 @@ async def get_next(next_link=None): return pipeline_response + return AsyncItemPaged(get_next, extract_data) - return AsyncItemPaged( - get_next, extract_data - ) - list.metadata = {'url': "/providers/Microsoft.Resources/operations"} # type: ignore -class DeploymentsOperations: # pylint: disable=too-many-public-methods - """DeploymentsOperations async operations. + list.metadata = {"url": "/providers/Microsoft.Resources/operations"} # type: ignore - You should not instantiate this class directly. Instead, you should create a Client instance that - instantiates it for you and attaches it as an attribute. - :ivar models: Alias to model classes used in this operation group. - :type models: ~azure.mgmt.resource.resources.v2019_07_01.models - :param client: Client for service requests. - :param config: Configuration of service client. - :param serializer: An object model serializer. - :param deserializer: An object model deserializer. +class DeploymentsOperations: # pylint: disable=too-many-public-methods + """ + .. warning:: + **DO NOT** instantiate this class directly. + + Instead, you should access the following operations through + :class:`~azure.mgmt.resource.resources.v2019_07_01.aio.ResourceManagementClient`'s + :attr:`deployments` attribute. """ models = _models - def __init__(self, client, config, serializer, deserializer) -> None: - self._client = client - self._serialize = serializer - self._deserialize = deserializer - self._config = config + def __init__(self, *args, **kwargs) -> None: + input_args = list(args) + self._client = input_args.pop(0) if input_args else kwargs.pop("client") + self._config = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") async def _delete_at_scope_initial( # pylint: disable=inconsistent-return-statements - self, - scope: str, - deployment_name: str, - **kwargs: Any + self, scope: str, deployment_name: str, **kwargs: Any ) -> None: - cls = kwargs.pop('cls', None) # type: ClsType[None] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + 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', "2019-07-01") # type: str + api_version = kwargs.pop("api_version", _params.pop("api-version", "2019-07-01")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[None] - - request = build_deployments_delete_at_scope_request_initial( + request = build_deployments_delete_at_scope_request( scope=scope, deployment_name=deployment_name, api_version=api_version, - template_url=self._delete_at_scope_initial.metadata['url'], + template_url=self._delete_at_scope_initial.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [202, 204]: @@ -175,16 +281,10 @@ async def _delete_at_scope_initial( # pylint: disable=inconsistent-return-state if cls: return cls(pipeline_response, None, {}) - _delete_at_scope_initial.metadata = {'url': "/{scope}/providers/Microsoft.Resources/deployments/{deploymentName}"} # type: ignore - + _delete_at_scope_initial.metadata = {"url": "/{scope}/providers/Microsoft.Resources/deployments/{deploymentName}"} # type: ignore @distributed_trace_async - async def begin_delete_at_scope( # pylint: disable=inconsistent-return-statements - self, - scope: str, - deployment_name: str, - **kwargs: Any - ) -> AsyncLROPoller[None]: + async def begin_delete_at_scope(self, scope: str, deployment_name: str, **kwargs: Any) -> AsyncLROPoller[None]: """Deletes a deployment from the deployment history. A template deployment that is currently running cannot be deleted. Deleting a template @@ -195,9 +295,9 @@ async def begin_delete_at_scope( # pylint: disable=inconsistent-return-statemen process finishes, the URI in the Location header returns a status of 204 on success. If the asynchronous request failed, the URI in the Location header returns an error-level status code. - :param scope: The scope of a deployment. + :param scope: The scope of a deployment. Required. :type scope: str - :param deployment_name: The name of the deployment. + :param deployment_name: The name of the deployment. Required. :type deployment_name: str :keyword callable cls: A custom type or function that will be passed the direct response :keyword str continuation_token: A continuation token to restart a poller from a saved state. @@ -209,86 +309,91 @@ async def begin_delete_at_scope( # pylint: disable=inconsistent-return-statemen Retry-After header is present. :return: An instance of AsyncLROPoller that returns either None or the result of cls(response) :rtype: ~azure.core.polling.AsyncLROPoller[None] - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - api_version = kwargs.pop('api_version', "2019-07-01") # type: str - polling = kwargs.pop('polling', True) # type: Union[bool, AsyncPollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType[None] - lro_delay = kwargs.pop( - 'polling_interval', - self._config.polling_interval - ) - cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2019-07-01")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[None] + polling = kwargs.pop("polling", True) # type: Union[bool, AsyncPollingMethod] + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token = kwargs.pop("continuation_token", None) # type: Optional[str] if cont_token is None: - raw_result = await self._delete_at_scope_initial( + raw_result = await self._delete_at_scope_initial( # type: ignore scope=scope, deployment_name=deployment_name, api_version=api_version, - cls=lambda x,y,z: x, + cls=lambda x, y, z: x, + headers=_headers, + params=_params, **kwargs ) - kwargs.pop('error_map', None) + kwargs.pop("error_map", None) - def get_long_running_output(pipeline_response): + def get_long_running_output(pipeline_response): # pylint: disable=inconsistent-return-statements if cls: return cls(pipeline_response, None, {}) - - if polling is True: polling_method = AsyncARMPolling(lro_delay, **kwargs) - elif polling is False: polling_method = AsyncNoPolling() - else: polling_method = polling + if polling is True: + polling_method = cast(AsyncPollingMethod, AsyncARMPolling(lro_delay, **kwargs)) # type: AsyncPollingMethod + elif polling is False: + polling_method = cast(AsyncPollingMethod, AsyncNoPolling()) + else: + polling_method = polling if cont_token: return AsyncLROPoller.from_continuation_token( polling_method=polling_method, continuation_token=cont_token, client=self._client, - deserialization_callback=get_long_running_output + deserialization_callback=get_long_running_output, ) return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) - begin_delete_at_scope.metadata = {'url': "/{scope}/providers/Microsoft.Resources/deployments/{deploymentName}"} # type: ignore + begin_delete_at_scope.metadata = {"url": "/{scope}/providers/Microsoft.Resources/deployments/{deploymentName}"} # type: ignore @distributed_trace_async - async def check_existence_at_scope( - self, - scope: str, - deployment_name: str, - **kwargs: Any - ) -> bool: + async def check_existence_at_scope(self, scope: str, deployment_name: str, **kwargs: Any) -> bool: """Checks whether the deployment exists. - :param scope: The scope of a deployment. + :param scope: The scope of a deployment. Required. :type scope: str - :param deployment_name: The name of the deployment. + :param deployment_name: The name of the deployment. Required. :type deployment_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: bool, or the result of cls(response) + :return: bool or the result of cls(response) :rtype: bool - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType[None] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + 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', "2019-07-01") # type: str + api_version = kwargs.pop("api_version", _params.pop("api-version", "2019-07-01")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[None] - request = build_deployments_check_existence_at_scope_request( scope=scope, deployment_name=deployment_name, api_version=api_version, - template_url=self.check_existence_at_scope.metadata['url'], + template_url=self.check_existence_at_scope.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [204, 404]: @@ -299,43 +404,52 @@ async def check_existence_at_scope( return cls(pipeline_response, None, {}) return 200 <= response.status_code <= 299 - check_existence_at_scope.metadata = {'url': "/{scope}/providers/Microsoft.Resources/deployments/{deploymentName}"} # type: ignore - + check_existence_at_scope.metadata = {"url": "/{scope}/providers/Microsoft.Resources/deployments/{deploymentName}"} # type: ignore async def _create_or_update_at_scope_initial( - self, - scope: str, - deployment_name: str, - parameters: "_models.Deployment", - **kwargs: Any - ) -> "_models.DeploymentExtended": - cls = kwargs.pop('cls', None) # type: ClsType["_models.DeploymentExtended"] + self, scope: str, deployment_name: str, parameters: Union[_models.Deployment, IO], **kwargs: Any + ) -> _models.DeploymentExtended: error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) - api_version = kwargs.pop('api_version', "2019-07-01") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - _json = self._serialize.body(parameters, 'Deployment') + api_version = kwargs.pop("api_version", _params.pop("api-version", "2019-07-01")) # type: str + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.DeploymentExtended] - request = build_deployments_create_or_update_at_scope_request_initial( + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(parameters, (IO, bytes)): + _content = parameters + else: + _json = self._serialize.body(parameters, "Deployment") + + request = build_deployments_create_or_update_at_scope_request( scope=scope, deployment_name=deployment_name, api_version=api_version, content_type=content_type, json=_json, - template_url=self._create_or_update_at_scope_initial.metadata['url'], + content=_content, + template_url=self._create_or_update_at_scope_initial.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200, 201]: @@ -343,37 +457,41 @@ async def _create_or_update_at_scope_initial( raise HttpResponseError(response=response, error_format=ARMErrorFormat) if response.status_code == 200: - deserialized = self._deserialize('DeploymentExtended', pipeline_response) + deserialized = self._deserialize("DeploymentExtended", pipeline_response) if response.status_code == 201: - deserialized = self._deserialize('DeploymentExtended', pipeline_response) + deserialized = self._deserialize("DeploymentExtended", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - _create_or_update_at_scope_initial.metadata = {'url': "/{scope}/providers/Microsoft.Resources/deployments/{deploymentName}"} # type: ignore + _create_or_update_at_scope_initial.metadata = {"url": "/{scope}/providers/Microsoft.Resources/deployments/{deploymentName}"} # type: ignore - - @distributed_trace_async + @overload async def begin_create_or_update_at_scope( self, scope: str, deployment_name: str, - parameters: "_models.Deployment", + parameters: _models.Deployment, + *, + content_type: str = "application/json", **kwargs: Any - ) -> AsyncLROPoller["_models.DeploymentExtended"]: + ) -> AsyncLROPoller[_models.DeploymentExtended]: """Deploys resources at a given scope. You can provide the template and parameters directly in the request or link to JSON files. - :param scope: The scope of a deployment. + :param scope: The scope of a deployment. Required. :type scope: str - :param deployment_name: The name of the deployment. + :param deployment_name: The name of the deployment. Required. :type deployment_name: str - :param parameters: Additional parameters supplied to the operation. + :param parameters: Additional parameters supplied to the operation. Required. :type parameters: ~azure.mgmt.resource.resources.v2019_07_01.models.Deployment + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str :keyword callable cls: A custom type or function that will be passed the direct response :keyword str continuation_token: A continuation token to restart a poller from a saved state. :keyword polling: By default, your polling method will be AsyncARMPolling. Pass in False for @@ -386,114 +504,179 @@ async def begin_create_or_update_at_scope( cls(response) :rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.resource.resources.v2019_07_01.models.DeploymentExtended] - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - api_version = kwargs.pop('api_version', "2019-07-01") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] - polling = kwargs.pop('polling', True) # type: Union[bool, AsyncPollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType["_models.DeploymentExtended"] - lro_delay = kwargs.pop( - 'polling_interval', - self._config.polling_interval - ) - cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] + + @overload + async def begin_create_or_update_at_scope( + self, scope: str, deployment_name: str, parameters: IO, *, content_type: str = "application/json", **kwargs: Any + ) -> AsyncLROPoller[_models.DeploymentExtended]: + """Deploys resources at a given scope. + + You can provide the template and parameters directly in the request or link to JSON files. + + :param scope: The scope of a deployment. Required. + :type scope: str + :param deployment_name: The name of the deployment. Required. + :type deployment_name: str + :param parameters: Additional parameters supplied to the operation. Required. + :type parameters: IO + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be AsyncARMPolling. Pass in False for + this operation to not poll, or pass in your own initialized polling object for a personal + polling strategy. + :paramtype polling: bool or ~azure.core.polling.AsyncPollingMethod + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of AsyncLROPoller that returns either DeploymentExtended or the result of + cls(response) + :rtype: + ~azure.core.polling.AsyncLROPoller[~azure.mgmt.resource.resources.v2019_07_01.models.DeploymentExtended] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace_async + async def begin_create_or_update_at_scope( + self, scope: str, deployment_name: str, parameters: Union[_models.Deployment, IO], **kwargs: Any + ) -> AsyncLROPoller[_models.DeploymentExtended]: + """Deploys resources at a given scope. + + You can provide the template and parameters directly in the request or link to JSON files. + + :param scope: The scope of a deployment. Required. + :type scope: str + :param deployment_name: The name of the deployment. Required. + :type deployment_name: str + :param parameters: Additional parameters supplied to the operation. Is either a model type or a + IO type. Required. + :type parameters: ~azure.mgmt.resource.resources.v2019_07_01.models.Deployment or IO + :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. + Default value is None. + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be AsyncARMPolling. Pass in False for + this operation to not poll, or pass in your own initialized polling object for a personal + polling strategy. + :paramtype polling: bool or ~azure.core.polling.AsyncPollingMethod + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of AsyncLROPoller that returns either DeploymentExtended or the result of + cls(response) + :rtype: + ~azure.core.polling.AsyncLROPoller[~azure.mgmt.resource.resources.v2019_07_01.models.DeploymentExtended] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _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", "2019-07-01")) # type: str + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.DeploymentExtended] + polling = kwargs.pop("polling", True) # type: Union[bool, AsyncPollingMethod] + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token = kwargs.pop("continuation_token", None) # type: Optional[str] if cont_token is None: - raw_result = await self._create_or_update_at_scope_initial( + raw_result = await self._create_or_update_at_scope_initial( # type: ignore scope=scope, deployment_name=deployment_name, parameters=parameters, api_version=api_version, content_type=content_type, - cls=lambda x,y,z: x, + cls=lambda x, y, z: x, + headers=_headers, + params=_params, **kwargs ) - kwargs.pop('error_map', None) + kwargs.pop("error_map", None) def get_long_running_output(pipeline_response): - response = pipeline_response.http_response - deserialized = self._deserialize('DeploymentExtended', pipeline_response) + deserialized = self._deserialize("DeploymentExtended", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - - if polling is True: polling_method = AsyncARMPolling(lro_delay, **kwargs) - elif polling is False: polling_method = AsyncNoPolling() - else: polling_method = polling + if polling is True: + polling_method = cast(AsyncPollingMethod, AsyncARMPolling(lro_delay, **kwargs)) # type: AsyncPollingMethod + elif polling is False: + polling_method = cast(AsyncPollingMethod, AsyncNoPolling()) + else: + polling_method = polling if cont_token: return AsyncLROPoller.from_continuation_token( polling_method=polling_method, continuation_token=cont_token, client=self._client, - deserialization_callback=get_long_running_output + deserialization_callback=get_long_running_output, ) return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) - begin_create_or_update_at_scope.metadata = {'url': "/{scope}/providers/Microsoft.Resources/deployments/{deploymentName}"} # type: ignore + begin_create_or_update_at_scope.metadata = {"url": "/{scope}/providers/Microsoft.Resources/deployments/{deploymentName}"} # type: ignore @distributed_trace_async - async def get_at_scope( - self, - scope: str, - deployment_name: str, - **kwargs: Any - ) -> "_models.DeploymentExtended": + async def get_at_scope(self, scope: str, deployment_name: str, **kwargs: Any) -> _models.DeploymentExtended: """Gets a deployment. - :param scope: The scope of a deployment. + :param scope: The scope of a deployment. Required. :type scope: str - :param deployment_name: The name of the deployment. + :param deployment_name: The name of the deployment. Required. :type deployment_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: DeploymentExtended, or the result of cls(response) + :return: DeploymentExtended or the result of cls(response) :rtype: ~azure.mgmt.resource.resources.v2019_07_01.models.DeploymentExtended - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.DeploymentExtended"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) - api_version = kwargs.pop('api_version', "2019-07-01") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2019-07-01")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[_models.DeploymentExtended] - request = build_deployments_get_at_scope_request( scope=scope, deployment_name=deployment_name, api_version=api_version, - template_url=self.get_at_scope.metadata['url'], + template_url=self.get_at_scope.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) - deserialized = self._deserialize('DeploymentExtended', pipeline_response) + deserialized = self._deserialize("DeploymentExtended", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - get_at_scope.metadata = {'url': "/{scope}/providers/Microsoft.Resources/deployments/{deploymentName}"} # type: ignore - + get_at_scope.metadata = {"url": "/{scope}/providers/Microsoft.Resources/deployments/{deploymentName}"} # type: ignore @distributed_trace_async async def cancel_at_scope( # pylint: disable=inconsistent-return-statements - self, - scope: str, - deployment_name: str, - **kwargs: Any + self, scope: str, deployment_name: str, **kwargs: Any ) -> None: """Cancels a currently running template deployment. @@ -502,38 +685,44 @@ async def cancel_at_scope( # pylint: disable=inconsistent-return-statements deployment stops the currently running template deployment and leaves the resources partially deployed. - :param scope: The scope of a deployment. + :param scope: The scope of a deployment. Required. :type scope: str - :param deployment_name: The name of the deployment. + :param deployment_name: The name of the deployment. Required. :type deployment_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: None, or the result of cls(response) + :return: None or the result of cls(response) :rtype: None - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType[None] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + 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', "2019-07-01") # type: str + api_version = kwargs.pop("api_version", _params.pop("api-version", "2019-07-01")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[None] - request = build_deployments_cancel_at_scope_request( scope=scope, deployment_name=deployment_name, api_version=api_version, - template_url=self.cancel_at_scope.metadata['url'], + template_url=self.cancel_at_scope.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [204]: @@ -543,41 +732,101 @@ async def cancel_at_scope( # pylint: disable=inconsistent-return-statements if cls: return cls(pipeline_response, None, {}) - cancel_at_scope.metadata = {'url': "/{scope}/providers/Microsoft.Resources/deployments/{deploymentName}/cancel"} # type: ignore - + cancel_at_scope.metadata = {"url": "/{scope}/providers/Microsoft.Resources/deployments/{deploymentName}/cancel"} # type: ignore - @distributed_trace_async + @overload async def validate_at_scope( self, scope: str, deployment_name: str, - parameters: "_models.Deployment", + parameters: _models.Deployment, + *, + content_type: str = "application/json", **kwargs: Any - ) -> "_models.DeploymentValidateResult": + ) -> _models.DeploymentValidateResult: """Validates whether the specified template is syntactically correct and will be accepted by Azure Resource Manager.. - :param scope: The scope of a deployment. + :param scope: The scope of a deployment. Required. :type scope: str - :param deployment_name: The name of the deployment. + :param deployment_name: The name of the deployment. Required. :type deployment_name: str - :param parameters: Parameters to validate. + :param parameters: Parameters to validate. Required. :type parameters: ~azure.mgmt.resource.resources.v2019_07_01.models.Deployment + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: DeploymentValidateResult or the result of cls(response) + :rtype: ~azure.mgmt.resource.resources.v2019_07_01.models.DeploymentValidateResult + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + async def validate_at_scope( + self, scope: str, deployment_name: str, parameters: IO, *, content_type: str = "application/json", **kwargs: Any + ) -> _models.DeploymentValidateResult: + """Validates whether the specified template is syntactically correct and will be accepted by Azure + Resource Manager.. + + :param scope: The scope of a deployment. Required. + :type scope: str + :param deployment_name: The name of the deployment. Required. + :type deployment_name: str + :param parameters: Parameters to validate. Required. + :type parameters: IO + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: DeploymentValidateResult or the result of cls(response) + :rtype: ~azure.mgmt.resource.resources.v2019_07_01.models.DeploymentValidateResult + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace_async + async def validate_at_scope( + self, scope: str, deployment_name: str, parameters: Union[_models.Deployment, IO], **kwargs: Any + ) -> _models.DeploymentValidateResult: + """Validates whether the specified template is syntactically correct and will be accepted by Azure + Resource Manager.. + + :param scope: The scope of a deployment. Required. + :type scope: str + :param deployment_name: The name of the deployment. Required. + :type deployment_name: str + :param parameters: Parameters to validate. Is either a model type or a IO type. Required. + :type parameters: ~azure.mgmt.resource.resources.v2019_07_01.models.Deployment or IO + :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. + Default value is None. + :paramtype content_type: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: DeploymentValidateResult, or the result of cls(response) + :return: DeploymentValidateResult or the result of cls(response) :rtype: ~azure.mgmt.resource.resources.v2019_07_01.models.DeploymentValidateResult - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.DeploymentValidateResult"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', "2019-07-01") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + api_version = kwargs.pop("api_version", _params.pop("api-version", "2019-07-01")) # type: str + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.DeploymentValidateResult] - _json = self._serialize.body(parameters, 'Deployment') + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(parameters, (IO, bytes)): + _content = parameters + else: + _json = self._serialize.body(parameters, "Deployment") request = build_deployments_validate_at_scope_request( scope=scope, @@ -585,16 +834,18 @@ async def validate_at_scope( api_version=api_version, content_type=content_type, json=_json, - template_url=self.validate_at_scope.metadata['url'], + content=_content, + template_url=self.validate_at_scope.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200, 400]: @@ -602,87 +853,84 @@ async def validate_at_scope( raise HttpResponseError(response=response, error_format=ARMErrorFormat) if response.status_code == 200: - deserialized = self._deserialize('DeploymentValidateResult', pipeline_response) + deserialized = self._deserialize("DeploymentValidateResult", pipeline_response) if response.status_code == 400: - deserialized = self._deserialize('DeploymentValidateResult', pipeline_response) + deserialized = self._deserialize("DeploymentValidateResult", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - validate_at_scope.metadata = {'url': "/{scope}/providers/Microsoft.Resources/deployments/{deploymentName}/validate"} # type: ignore - + validate_at_scope.metadata = {"url": "/{scope}/providers/Microsoft.Resources/deployments/{deploymentName}/validate"} # type: ignore @distributed_trace_async async def export_template_at_scope( - self, - scope: str, - deployment_name: str, - **kwargs: Any - ) -> "_models.DeploymentExportResult": + self, scope: str, deployment_name: str, **kwargs: Any + ) -> _models.DeploymentExportResult: """Exports the template used for specified deployment. - :param scope: The scope of a deployment. + :param scope: The scope of a deployment. Required. :type scope: str - :param deployment_name: The name of the deployment. + :param deployment_name: The name of the deployment. Required. :type deployment_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: DeploymentExportResult, or the result of cls(response) + :return: DeploymentExportResult or the result of cls(response) :rtype: ~azure.mgmt.resource.resources.v2019_07_01.models.DeploymentExportResult - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.DeploymentExportResult"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) - api_version = kwargs.pop('api_version', "2019-07-01") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2019-07-01")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[_models.DeploymentExportResult] - request = build_deployments_export_template_at_scope_request( scope=scope, deployment_name=deployment_name, api_version=api_version, - template_url=self.export_template_at_scope.metadata['url'], + template_url=self.export_template_at_scope.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) - deserialized = self._deserialize('DeploymentExportResult', pipeline_response) + deserialized = self._deserialize("DeploymentExportResult", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - export_template_at_scope.metadata = {'url': "/{scope}/providers/Microsoft.Resources/deployments/{deploymentName}/exportTemplate"} # type: ignore - + export_template_at_scope.metadata = {"url": "/{scope}/providers/Microsoft.Resources/deployments/{deploymentName}/exportTemplate"} # type: ignore @distributed_trace def list_at_scope( - self, - scope: str, - filter: Optional[str] = None, - top: Optional[int] = None, - **kwargs: Any - ) -> AsyncIterable["_models.DeploymentListResult"]: + self, scope: str, filter: Optional[str] = None, top: Optional[int] = None, **kwargs: Any + ) -> AsyncIterable["_models.DeploymentExtended"]: """Get all the deployments at the given scope. - :param scope: The scope of a deployment. + :param scope: The scope of a deployment. Required. :type scope: str :param filter: The filter to apply on the operation. For example, you can use $filter=provisioningState eq '{state}'. Default value is None. @@ -691,40 +939,48 @@ def list_at_scope( value is None. :type top: int :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either DeploymentListResult or the result of - cls(response) + :return: An iterator like instance of either DeploymentExtended or the result of cls(response) :rtype: - ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.resource.resources.v2019_07_01.models.DeploymentListResult] - :raises: ~azure.core.exceptions.HttpResponseError + ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.resource.resources.v2019_07_01.models.DeploymentExtended] + :raises ~azure.core.exceptions.HttpResponseError: """ - api_version = kwargs.pop('api_version', "2019-07-01") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2019-07-01")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[_models.DeploymentListResult] - cls = kwargs.pop('cls', None) # type: ClsType["_models.DeploymentListResult"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) + def prepare_request(next_link=None): if not next_link: - + request = build_deployments_list_at_scope_request( scope=scope, - api_version=api_version, filter=filter, top=top, - template_url=self.list_at_scope.metadata['url'], + api_version=api_version, + template_url=self.list_at_scope.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore else: - - request = build_deployments_list_at_scope_request( - scope=scope, - template_url=next_link, - ) + # make call to next link with the client's api-version + _parsed_next_link = urlparse(next_link) + _next_request_params = case_insensitive_dict(parse_qs(_parsed_next_link.query)) + _next_request_params["api-version"] = self._config.api_version + request = HttpRequest("GET", urljoin(next_link, _parsed_next_link.path), params=_next_request_params) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore request.method = "GET" return request @@ -738,10 +994,8 @@ async def extract_data(pipeline_response): async def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) response = pipeline_response.http_response @@ -751,39 +1005,41 @@ async def get_next(next_link=None): return pipeline_response + return AsyncItemPaged(get_next, extract_data) - return AsyncItemPaged( - get_next, extract_data - ) - list_at_scope.metadata = {'url': "/{scope}/providers/Microsoft.Resources/deployments/"} # type: ignore + list_at_scope.metadata = {"url": "/{scope}/providers/Microsoft.Resources/deployments/"} # type: ignore async def _delete_at_tenant_scope_initial( # pylint: disable=inconsistent-return-statements - self, - deployment_name: str, - **kwargs: Any + self, deployment_name: str, **kwargs: Any ) -> None: - cls = kwargs.pop('cls', None) # type: ClsType[None] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) - api_version = kwargs.pop('api_version', "2019-07-01") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - request = build_deployments_delete_at_tenant_scope_request_initial( + api_version = kwargs.pop("api_version", _params.pop("api-version", "2019-07-01")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[None] + + request = build_deployments_delete_at_tenant_scope_request( deployment_name=deployment_name, api_version=api_version, - template_url=self._delete_at_tenant_scope_initial.metadata['url'], + template_url=self._delete_at_tenant_scope_initial.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [202, 204]: @@ -793,15 +1049,10 @@ async def _delete_at_tenant_scope_initial( # pylint: disable=inconsistent-retur if cls: return cls(pipeline_response, None, {}) - _delete_at_tenant_scope_initial.metadata = {'url': "/providers/Microsoft.Resources/deployments/{deploymentName}"} # type: ignore - + _delete_at_tenant_scope_initial.metadata = {"url": "/providers/Microsoft.Resources/deployments/{deploymentName}"} # type: ignore @distributed_trace_async - async def begin_delete_at_tenant_scope( # pylint: disable=inconsistent-return-statements - self, - deployment_name: str, - **kwargs: Any - ) -> AsyncLROPoller[None]: + async def begin_delete_at_tenant_scope(self, deployment_name: str, **kwargs: Any) -> AsyncLROPoller[None]: """Deletes a deployment from the deployment history. A template deployment that is currently running cannot be deleted. Deleting a template @@ -812,7 +1063,7 @@ async def begin_delete_at_tenant_scope( # pylint: disable=inconsistent-return-s process finishes, the URI in the Location header returns a status of 204 on success. If the asynchronous request failed, the URI in the Location header returns an error-level status code. - :param deployment_name: The name of the deployment. + :param deployment_name: The name of the deployment. Required. :type deployment_name: str :keyword callable cls: A custom type or function that will be passed the direct response :keyword str continuation_token: A continuation token to restart a poller from a saved state. @@ -824,81 +1075,87 @@ async def begin_delete_at_tenant_scope( # pylint: disable=inconsistent-return-s Retry-After header is present. :return: An instance of AsyncLROPoller that returns either None or the result of cls(response) :rtype: ~azure.core.polling.AsyncLROPoller[None] - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - api_version = kwargs.pop('api_version', "2019-07-01") # type: str - polling = kwargs.pop('polling', True) # type: Union[bool, AsyncPollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType[None] - lro_delay = kwargs.pop( - 'polling_interval', - self._config.polling_interval - ) - cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2019-07-01")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[None] + polling = kwargs.pop("polling", True) # type: Union[bool, AsyncPollingMethod] + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token = kwargs.pop("continuation_token", None) # type: Optional[str] if cont_token is None: - raw_result = await self._delete_at_tenant_scope_initial( + raw_result = await self._delete_at_tenant_scope_initial( # type: ignore deployment_name=deployment_name, api_version=api_version, - cls=lambda x,y,z: x, + cls=lambda x, y, z: x, + headers=_headers, + params=_params, **kwargs ) - kwargs.pop('error_map', None) + kwargs.pop("error_map", None) - def get_long_running_output(pipeline_response): + def get_long_running_output(pipeline_response): # pylint: disable=inconsistent-return-statements if cls: return cls(pipeline_response, None, {}) - - if polling is True: polling_method = AsyncARMPolling(lro_delay, **kwargs) - elif polling is False: polling_method = AsyncNoPolling() - else: polling_method = polling + if polling is True: + polling_method = cast(AsyncPollingMethod, AsyncARMPolling(lro_delay, **kwargs)) # type: AsyncPollingMethod + elif polling is False: + polling_method = cast(AsyncPollingMethod, AsyncNoPolling()) + else: + polling_method = polling if cont_token: return AsyncLROPoller.from_continuation_token( polling_method=polling_method, continuation_token=cont_token, client=self._client, - deserialization_callback=get_long_running_output + deserialization_callback=get_long_running_output, ) return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) - begin_delete_at_tenant_scope.metadata = {'url': "/providers/Microsoft.Resources/deployments/{deploymentName}"} # type: ignore + begin_delete_at_tenant_scope.metadata = {"url": "/providers/Microsoft.Resources/deployments/{deploymentName}"} # type: ignore @distributed_trace_async - async def check_existence_at_tenant_scope( - self, - deployment_name: str, - **kwargs: Any - ) -> bool: + async def check_existence_at_tenant_scope(self, deployment_name: str, **kwargs: Any) -> bool: """Checks whether the deployment exists. - :param deployment_name: The name of the deployment. + :param deployment_name: The name of the deployment. Required. :type deployment_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: bool, or the result of cls(response) + :return: bool or the result of cls(response) :rtype: bool - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType[None] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) - api_version = kwargs.pop('api_version', "2019-07-01") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2019-07-01")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[None] - request = build_deployments_check_existence_at_tenant_scope_request( deployment_name=deployment_name, api_version=api_version, - template_url=self.check_existence_at_tenant_scope.metadata['url'], + template_url=self.check_existence_at_tenant_scope.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [204, 404]: @@ -909,41 +1166,51 @@ async def check_existence_at_tenant_scope( return cls(pipeline_response, None, {}) return 200 <= response.status_code <= 299 - check_existence_at_tenant_scope.metadata = {'url': "/providers/Microsoft.Resources/deployments/{deploymentName}"} # type: ignore - + check_existence_at_tenant_scope.metadata = {"url": "/providers/Microsoft.Resources/deployments/{deploymentName}"} # type: ignore async def _create_or_update_at_tenant_scope_initial( - self, - deployment_name: str, - parameters: "_models.Deployment", - **kwargs: Any - ) -> "_models.DeploymentExtended": - cls = kwargs.pop('cls', None) # type: ClsType["_models.DeploymentExtended"] + self, deployment_name: str, parameters: Union[_models.Deployment, IO], **kwargs: Any + ) -> _models.DeploymentExtended: error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) - api_version = kwargs.pop('api_version', "2019-07-01") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - _json = self._serialize.body(parameters, 'Deployment') + api_version = kwargs.pop("api_version", _params.pop("api-version", "2019-07-01")) # type: str + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.DeploymentExtended] - request = build_deployments_create_or_update_at_tenant_scope_request_initial( + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(parameters, (IO, bytes)): + _content = parameters + else: + _json = self._serialize.body(parameters, "Deployment") + + request = build_deployments_create_or_update_at_tenant_scope_request( deployment_name=deployment_name, api_version=api_version, content_type=content_type, json=_json, - template_url=self._create_or_update_at_tenant_scope_initial.metadata['url'], + content=_content, + template_url=self._create_or_update_at_tenant_scope_initial.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200, 201]: @@ -951,34 +1218,38 @@ async def _create_or_update_at_tenant_scope_initial( raise HttpResponseError(response=response, error_format=ARMErrorFormat) if response.status_code == 200: - deserialized = self._deserialize('DeploymentExtended', pipeline_response) + deserialized = self._deserialize("DeploymentExtended", pipeline_response) if response.status_code == 201: - deserialized = self._deserialize('DeploymentExtended', pipeline_response) + deserialized = self._deserialize("DeploymentExtended", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - _create_or_update_at_tenant_scope_initial.metadata = {'url': "/providers/Microsoft.Resources/deployments/{deploymentName}"} # type: ignore + _create_or_update_at_tenant_scope_initial.metadata = {"url": "/providers/Microsoft.Resources/deployments/{deploymentName}"} # type: ignore - - @distributed_trace_async + @overload async def begin_create_or_update_at_tenant_scope( self, deployment_name: str, - parameters: "_models.Deployment", + parameters: _models.Deployment, + *, + content_type: str = "application/json", **kwargs: Any - ) -> AsyncLROPoller["_models.DeploymentExtended"]: + ) -> AsyncLROPoller[_models.DeploymentExtended]: """Deploys resources at tenant scope. You can provide the template and parameters directly in the request or link to JSON files. - :param deployment_name: The name of the deployment. + :param deployment_name: The name of the deployment. Required. :type deployment_name: str - :param parameters: Additional parameters supplied to the operation. + :param parameters: Additional parameters supplied to the operation. Required. :type parameters: ~azure.mgmt.resource.resources.v2019_07_01.models.Deployment + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str :keyword callable cls: A custom type or function that will be passed the direct response :keyword str continuation_token: A continuation token to restart a poller from a saved state. :keyword polling: By default, your polling method will be AsyncARMPolling. Pass in False for @@ -991,108 +1262,171 @@ async def begin_create_or_update_at_tenant_scope( cls(response) :rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.resource.resources.v2019_07_01.models.DeploymentExtended] - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - api_version = kwargs.pop('api_version', "2019-07-01") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] - polling = kwargs.pop('polling', True) # type: Union[bool, AsyncPollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType["_models.DeploymentExtended"] - lro_delay = kwargs.pop( - 'polling_interval', - self._config.polling_interval - ) - cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] + + @overload + async def begin_create_or_update_at_tenant_scope( + self, deployment_name: str, parameters: IO, *, content_type: str = "application/json", **kwargs: Any + ) -> AsyncLROPoller[_models.DeploymentExtended]: + """Deploys resources at tenant scope. + + You can provide the template and parameters directly in the request or link to JSON files. + + :param deployment_name: The name of the deployment. Required. + :type deployment_name: str + :param parameters: Additional parameters supplied to the operation. Required. + :type parameters: IO + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be AsyncARMPolling. Pass in False for + this operation to not poll, or pass in your own initialized polling object for a personal + polling strategy. + :paramtype polling: bool or ~azure.core.polling.AsyncPollingMethod + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of AsyncLROPoller that returns either DeploymentExtended or the result of + cls(response) + :rtype: + ~azure.core.polling.AsyncLROPoller[~azure.mgmt.resource.resources.v2019_07_01.models.DeploymentExtended] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace_async + async def begin_create_or_update_at_tenant_scope( + self, deployment_name: str, parameters: Union[_models.Deployment, IO], **kwargs: Any + ) -> AsyncLROPoller[_models.DeploymentExtended]: + """Deploys resources at tenant scope. + + You can provide the template and parameters directly in the request or link to JSON files. + + :param deployment_name: The name of the deployment. Required. + :type deployment_name: str + :param parameters: Additional parameters supplied to the operation. Is either a model type or a + IO type. Required. + :type parameters: ~azure.mgmt.resource.resources.v2019_07_01.models.Deployment or IO + :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. + Default value is None. + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be AsyncARMPolling. Pass in False for + this operation to not poll, or pass in your own initialized polling object for a personal + polling strategy. + :paramtype polling: bool or ~azure.core.polling.AsyncPollingMethod + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of AsyncLROPoller that returns either DeploymentExtended or the result of + cls(response) + :rtype: + ~azure.core.polling.AsyncLROPoller[~azure.mgmt.resource.resources.v2019_07_01.models.DeploymentExtended] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _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", "2019-07-01")) # type: str + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.DeploymentExtended] + polling = kwargs.pop("polling", True) # type: Union[bool, AsyncPollingMethod] + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token = kwargs.pop("continuation_token", None) # type: Optional[str] if cont_token is None: - raw_result = await self._create_or_update_at_tenant_scope_initial( + raw_result = await self._create_or_update_at_tenant_scope_initial( # type: ignore deployment_name=deployment_name, parameters=parameters, api_version=api_version, content_type=content_type, - cls=lambda x,y,z: x, + cls=lambda x, y, z: x, + headers=_headers, + params=_params, **kwargs ) - kwargs.pop('error_map', None) + kwargs.pop("error_map", None) def get_long_running_output(pipeline_response): - response = pipeline_response.http_response - deserialized = self._deserialize('DeploymentExtended', pipeline_response) + deserialized = self._deserialize("DeploymentExtended", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - - if polling is True: polling_method = AsyncARMPolling(lro_delay, **kwargs) - elif polling is False: polling_method = AsyncNoPolling() - else: polling_method = polling + if polling is True: + polling_method = cast(AsyncPollingMethod, AsyncARMPolling(lro_delay, **kwargs)) # type: AsyncPollingMethod + elif polling is False: + polling_method = cast(AsyncPollingMethod, AsyncNoPolling()) + else: + polling_method = polling if cont_token: return AsyncLROPoller.from_continuation_token( polling_method=polling_method, continuation_token=cont_token, client=self._client, - deserialization_callback=get_long_running_output + deserialization_callback=get_long_running_output, ) return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) - begin_create_or_update_at_tenant_scope.metadata = {'url': "/providers/Microsoft.Resources/deployments/{deploymentName}"} # type: ignore + begin_create_or_update_at_tenant_scope.metadata = {"url": "/providers/Microsoft.Resources/deployments/{deploymentName}"} # type: ignore @distributed_trace_async - async def get_at_tenant_scope( - self, - deployment_name: str, - **kwargs: Any - ) -> "_models.DeploymentExtended": + async def get_at_tenant_scope(self, deployment_name: str, **kwargs: Any) -> _models.DeploymentExtended: """Gets a deployment. - :param deployment_name: The name of the deployment. + :param deployment_name: The name of the deployment. Required. :type deployment_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: DeploymentExtended, or the result of cls(response) + :return: DeploymentExtended or the result of cls(response) :rtype: ~azure.mgmt.resource.resources.v2019_07_01.models.DeploymentExtended - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.DeploymentExtended"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + 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', "2019-07-01") # type: str + api_version = kwargs.pop("api_version", _params.pop("api-version", "2019-07-01")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[_models.DeploymentExtended] - request = build_deployments_get_at_tenant_scope_request( deployment_name=deployment_name, api_version=api_version, - template_url=self.get_at_tenant_scope.metadata['url'], + template_url=self.get_at_tenant_scope.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) - deserialized = self._deserialize('DeploymentExtended', pipeline_response) + deserialized = self._deserialize("DeploymentExtended", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - get_at_tenant_scope.metadata = {'url': "/providers/Microsoft.Resources/deployments/{deploymentName}"} # type: ignore - + get_at_tenant_scope.metadata = {"url": "/providers/Microsoft.Resources/deployments/{deploymentName}"} # type: ignore @distributed_trace_async async def cancel_at_tenant_scope( # pylint: disable=inconsistent-return-statements - self, - deployment_name: str, - **kwargs: Any + self, deployment_name: str, **kwargs: Any ) -> None: """Cancels a currently running template deployment. @@ -1101,35 +1435,41 @@ async def cancel_at_tenant_scope( # pylint: disable=inconsistent-return-stateme deployment stops the currently running template deployment and leaves the resources partially deployed. - :param deployment_name: The name of the deployment. + :param deployment_name: The name of the deployment. Required. :type deployment_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: None, or the result of cls(response) + :return: None or the result of cls(response) :rtype: None - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType[None] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + 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', "2019-07-01") # type: str + api_version = kwargs.pop("api_version", _params.pop("api-version", "2019-07-01")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[None] - request = build_deployments_cancel_at_tenant_scope_request( deployment_name=deployment_name, api_version=api_version, - template_url=self.cancel_at_tenant_scope.metadata['url'], + template_url=self.cancel_at_tenant_scope.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [204]: @@ -1139,54 +1479,112 @@ async def cancel_at_tenant_scope( # pylint: disable=inconsistent-return-stateme if cls: return cls(pipeline_response, None, {}) - cancel_at_tenant_scope.metadata = {'url': "/providers/Microsoft.Resources/deployments/{deploymentName}/cancel"} # type: ignore - + cancel_at_tenant_scope.metadata = {"url": "/providers/Microsoft.Resources/deployments/{deploymentName}/cancel"} # type: ignore - @distributed_trace_async + @overload async def validate_at_tenant_scope( self, deployment_name: str, - parameters: "_models.Deployment", + parameters: _models.Deployment, + *, + content_type: str = "application/json", **kwargs: Any - ) -> "_models.DeploymentValidateResult": + ) -> _models.DeploymentValidateResult: """Validates whether the specified template is syntactically correct and will be accepted by Azure Resource Manager.. - :param deployment_name: The name of the deployment. + :param deployment_name: The name of the deployment. Required. :type deployment_name: str - :param parameters: Parameters to validate. + :param parameters: Parameters to validate. Required. :type parameters: ~azure.mgmt.resource.resources.v2019_07_01.models.Deployment + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: DeploymentValidateResult, or the result of cls(response) + :return: DeploymentValidateResult or the result of cls(response) :rtype: ~azure.mgmt.resource.resources.v2019_07_01.models.DeploymentValidateResult - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.DeploymentValidateResult"] - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {})) - api_version = kwargs.pop('api_version', "2019-07-01") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + @overload + async def validate_at_tenant_scope( + self, deployment_name: str, parameters: IO, *, content_type: str = "application/json", **kwargs: Any + ) -> _models.DeploymentValidateResult: + """Validates whether the specified template is syntactically correct and will be accepted by Azure + Resource Manager.. - _json = self._serialize.body(parameters, 'Deployment') + :param deployment_name: The name of the deployment. Required. + :type deployment_name: str + :param parameters: Parameters to validate. Required. + :type parameters: IO + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: DeploymentValidateResult or the result of cls(response) + :rtype: ~azure.mgmt.resource.resources.v2019_07_01.models.DeploymentValidateResult + :raises ~azure.core.exceptions.HttpResponseError: + """ - request = build_deployments_validate_at_tenant_scope_request( - deployment_name=deployment_name, + @distributed_trace_async + async def validate_at_tenant_scope( + self, deployment_name: str, parameters: Union[_models.Deployment, IO], **kwargs: Any + ) -> _models.DeploymentValidateResult: + """Validates whether the specified template is syntactically correct and will be accepted by Azure + Resource Manager.. + + :param deployment_name: The name of the deployment. Required. + :type deployment_name: str + :param parameters: Parameters to validate. Is either a model type or a IO type. Required. + :type parameters: ~azure.mgmt.resource.resources.v2019_07_01.models.Deployment or IO + :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. + Default value is None. + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: DeploymentValidateResult or the result of cls(response) + :rtype: ~azure.mgmt.resource.resources.v2019_07_01.models.DeploymentValidateResult + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2019-07-01")) # type: str + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.DeploymentValidateResult] + + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(parameters, (IO, bytes)): + _content = parameters + else: + _json = self._serialize.body(parameters, "Deployment") + + request = build_deployments_validate_at_tenant_scope_request( + deployment_name=deployment_name, api_version=api_version, content_type=content_type, json=_json, - template_url=self.validate_at_tenant_scope.metadata['url'], + content=_content, + template_url=self.validate_at_tenant_scope.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200, 400]: @@ -1194,79 +1592,78 @@ async def validate_at_tenant_scope( raise HttpResponseError(response=response, error_format=ARMErrorFormat) if response.status_code == 200: - deserialized = self._deserialize('DeploymentValidateResult', pipeline_response) + deserialized = self._deserialize("DeploymentValidateResult", pipeline_response) if response.status_code == 400: - deserialized = self._deserialize('DeploymentValidateResult', pipeline_response) + deserialized = self._deserialize("DeploymentValidateResult", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - validate_at_tenant_scope.metadata = {'url': "/providers/Microsoft.Resources/deployments/{deploymentName}/validate"} # type: ignore - + validate_at_tenant_scope.metadata = {"url": "/providers/Microsoft.Resources/deployments/{deploymentName}/validate"} # type: ignore @distributed_trace_async async def export_template_at_tenant_scope( - self, - deployment_name: str, - **kwargs: Any - ) -> "_models.DeploymentExportResult": + self, deployment_name: str, **kwargs: Any + ) -> _models.DeploymentExportResult: """Exports the template used for specified deployment. - :param deployment_name: The name of the deployment. + :param deployment_name: The name of the deployment. Required. :type deployment_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: DeploymentExportResult, or the result of cls(response) + :return: DeploymentExportResult or the result of cls(response) :rtype: ~azure.mgmt.resource.resources.v2019_07_01.models.DeploymentExportResult - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.DeploymentExportResult"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + 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', "2019-07-01") # type: str + api_version = kwargs.pop("api_version", _params.pop("api-version", "2019-07-01")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[_models.DeploymentExportResult] - request = build_deployments_export_template_at_tenant_scope_request( deployment_name=deployment_name, api_version=api_version, - template_url=self.export_template_at_tenant_scope.metadata['url'], + template_url=self.export_template_at_tenant_scope.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) - deserialized = self._deserialize('DeploymentExportResult', pipeline_response) + deserialized = self._deserialize("DeploymentExportResult", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - export_template_at_tenant_scope.metadata = {'url': "/providers/Microsoft.Resources/deployments/{deploymentName}/exportTemplate"} # type: ignore - + export_template_at_tenant_scope.metadata = {"url": "/providers/Microsoft.Resources/deployments/{deploymentName}/exportTemplate"} # type: ignore @distributed_trace def list_at_tenant_scope( - self, - filter: Optional[str] = None, - top: Optional[int] = None, - **kwargs: Any - ) -> AsyncIterable["_models.DeploymentListResult"]: + self, filter: Optional[str] = None, top: Optional[int] = None, **kwargs: Any + ) -> AsyncIterable["_models.DeploymentExtended"]: """Get all the deployments at the tenant scope. :param filter: The filter to apply on the operation. For example, you can use @@ -1276,38 +1673,47 @@ def list_at_tenant_scope( value is None. :type top: int :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either DeploymentListResult or the result of - cls(response) + :return: An iterator like instance of either DeploymentExtended or the result of cls(response) :rtype: - ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.resource.resources.v2019_07_01.models.DeploymentListResult] - :raises: ~azure.core.exceptions.HttpResponseError + ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.resource.resources.v2019_07_01.models.DeploymentExtended] + :raises ~azure.core.exceptions.HttpResponseError: """ - api_version = kwargs.pop('api_version', "2019-07-01") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2019-07-01")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[_models.DeploymentListResult] - cls = kwargs.pop('cls', None) # type: ClsType["_models.DeploymentListResult"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) + def prepare_request(next_link=None): if not next_link: - + request = build_deployments_list_at_tenant_scope_request( - api_version=api_version, filter=filter, top=top, - template_url=self.list_at_tenant_scope.metadata['url'], + api_version=api_version, + template_url=self.list_at_tenant_scope.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore else: - - request = build_deployments_list_at_tenant_scope_request( - template_url=next_link, - ) + # make call to next link with the client's api-version + _parsed_next_link = urlparse(next_link) + _next_request_params = case_insensitive_dict(parse_qs(_parsed_next_link.query)) + _next_request_params["api-version"] = self._config.api_version + request = HttpRequest("GET", urljoin(next_link, _parsed_next_link.path), params=_next_request_params) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore request.method = "GET" return request @@ -1321,10 +1727,8 @@ async def extract_data(pipeline_response): async def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) response = pipeline_response.http_response @@ -1334,41 +1738,42 @@ async def get_next(next_link=None): return pipeline_response + return AsyncItemPaged(get_next, extract_data) - return AsyncItemPaged( - get_next, extract_data - ) - list_at_tenant_scope.metadata = {'url': "/providers/Microsoft.Resources/deployments/"} # type: ignore + list_at_tenant_scope.metadata = {"url": "/providers/Microsoft.Resources/deployments/"} # type: ignore async def _delete_at_management_group_scope_initial( # pylint: disable=inconsistent-return-statements - self, - group_id: str, - deployment_name: str, - **kwargs: Any + self, group_id: str, deployment_name: str, **kwargs: Any ) -> None: - cls = kwargs.pop('cls', None) # type: ClsType[None] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) - api_version = kwargs.pop('api_version', "2019-07-01") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - request = build_deployments_delete_at_management_group_scope_request_initial( + api_version = kwargs.pop("api_version", _params.pop("api-version", "2019-07-01")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[None] + + request = build_deployments_delete_at_management_group_scope_request( group_id=group_id, deployment_name=deployment_name, api_version=api_version, - template_url=self._delete_at_management_group_scope_initial.metadata['url'], + template_url=self._delete_at_management_group_scope_initial.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [202, 204]: @@ -1378,15 +1783,11 @@ async def _delete_at_management_group_scope_initial( # pylint: disable=inconsis if cls: return cls(pipeline_response, None, {}) - _delete_at_management_group_scope_initial.metadata = {'url': "/providers/Microsoft.Management/managementGroups/{groupId}/providers/Microsoft.Resources/deployments/{deploymentName}"} # type: ignore - + _delete_at_management_group_scope_initial.metadata = {"url": "/providers/Microsoft.Management/managementGroups/{groupId}/providers/Microsoft.Resources/deployments/{deploymentName}"} # type: ignore @distributed_trace_async - async def begin_delete_at_management_group_scope( # pylint: disable=inconsistent-return-statements - self, - group_id: str, - deployment_name: str, - **kwargs: Any + async def begin_delete_at_management_group_scope( + self, group_id: str, deployment_name: str, **kwargs: Any ) -> AsyncLROPoller[None]: """Deletes a deployment from the deployment history. @@ -1398,9 +1799,9 @@ async def begin_delete_at_management_group_scope( # pylint: disable=inconsisten process finishes, the URI in the Location header returns a status of 204 on success. If the asynchronous request failed, the URI in the Location header returns an error-level status code. - :param group_id: The management group ID. + :param group_id: The management group ID. Required. :type group_id: str - :param deployment_name: The name of the deployment. + :param deployment_name: The name of the deployment. Required. :type deployment_name: str :keyword callable cls: A custom type or function that will be passed the direct response :keyword str continuation_token: A continuation token to restart a poller from a saved state. @@ -1412,86 +1813,93 @@ async def begin_delete_at_management_group_scope( # pylint: disable=inconsisten Retry-After header is present. :return: An instance of AsyncLROPoller that returns either None or the result of cls(response) :rtype: ~azure.core.polling.AsyncLROPoller[None] - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - api_version = kwargs.pop('api_version', "2019-07-01") # type: str - polling = kwargs.pop('polling', True) # type: Union[bool, AsyncPollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType[None] - lro_delay = kwargs.pop( - 'polling_interval', - self._config.polling_interval - ) - cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2019-07-01")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[None] + polling = kwargs.pop("polling", True) # type: Union[bool, AsyncPollingMethod] + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token = kwargs.pop("continuation_token", None) # type: Optional[str] if cont_token is None: - raw_result = await self._delete_at_management_group_scope_initial( + raw_result = await self._delete_at_management_group_scope_initial( # type: ignore group_id=group_id, deployment_name=deployment_name, api_version=api_version, - cls=lambda x,y,z: x, + cls=lambda x, y, z: x, + headers=_headers, + params=_params, **kwargs ) - kwargs.pop('error_map', None) + kwargs.pop("error_map", None) - def get_long_running_output(pipeline_response): + def get_long_running_output(pipeline_response): # pylint: disable=inconsistent-return-statements if cls: return cls(pipeline_response, None, {}) - - if polling is True: polling_method = AsyncARMPolling(lro_delay, **kwargs) - elif polling is False: polling_method = AsyncNoPolling() - else: polling_method = polling + if polling is True: + polling_method = cast(AsyncPollingMethod, AsyncARMPolling(lro_delay, **kwargs)) # type: AsyncPollingMethod + elif polling is False: + polling_method = cast(AsyncPollingMethod, AsyncNoPolling()) + else: + polling_method = polling if cont_token: return AsyncLROPoller.from_continuation_token( polling_method=polling_method, continuation_token=cont_token, client=self._client, - deserialization_callback=get_long_running_output + deserialization_callback=get_long_running_output, ) return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) - begin_delete_at_management_group_scope.metadata = {'url': "/providers/Microsoft.Management/managementGroups/{groupId}/providers/Microsoft.Resources/deployments/{deploymentName}"} # type: ignore + begin_delete_at_management_group_scope.metadata = {"url": "/providers/Microsoft.Management/managementGroups/{groupId}/providers/Microsoft.Resources/deployments/{deploymentName}"} # type: ignore @distributed_trace_async async def check_existence_at_management_group_scope( - self, - group_id: str, - deployment_name: str, - **kwargs: Any + self, group_id: str, deployment_name: str, **kwargs: Any ) -> bool: """Checks whether the deployment exists. - :param group_id: The management group ID. + :param group_id: The management group ID. Required. :type group_id: str - :param deployment_name: The name of the deployment. + :param deployment_name: The name of the deployment. Required. :type deployment_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: bool, or the result of cls(response) + :return: bool or the result of cls(response) :rtype: bool - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType[None] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) - api_version = kwargs.pop('api_version', "2019-07-01") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2019-07-01")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[None] - request = build_deployments_check_existence_at_management_group_scope_request( group_id=group_id, deployment_name=deployment_name, api_version=api_version, - template_url=self.check_existence_at_management_group_scope.metadata['url'], + template_url=self.check_existence_at_management_group_scope.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [204, 404]: @@ -1502,43 +1910,52 @@ async def check_existence_at_management_group_scope( return cls(pipeline_response, None, {}) return 200 <= response.status_code <= 299 - check_existence_at_management_group_scope.metadata = {'url': "/providers/Microsoft.Management/managementGroups/{groupId}/providers/Microsoft.Resources/deployments/{deploymentName}"} # type: ignore - + check_existence_at_management_group_scope.metadata = {"url": "/providers/Microsoft.Management/managementGroups/{groupId}/providers/Microsoft.Resources/deployments/{deploymentName}"} # type: ignore async def _create_or_update_at_management_group_scope_initial( - self, - group_id: str, - deployment_name: str, - parameters: "_models.Deployment", - **kwargs: Any - ) -> "_models.DeploymentExtended": - cls = kwargs.pop('cls', None) # type: ClsType["_models.DeploymentExtended"] + self, group_id: str, deployment_name: str, parameters: Union[_models.Deployment, IO], **kwargs: Any + ) -> _models.DeploymentExtended: error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', "2019-07-01") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + api_version = kwargs.pop("api_version", _params.pop("api-version", "2019-07-01")) # type: str + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.DeploymentExtended] - _json = self._serialize.body(parameters, 'Deployment') + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(parameters, (IO, bytes)): + _content = parameters + else: + _json = self._serialize.body(parameters, "Deployment") - request = build_deployments_create_or_update_at_management_group_scope_request_initial( + request = build_deployments_create_or_update_at_management_group_scope_request( group_id=group_id, deployment_name=deployment_name, api_version=api_version, content_type=content_type, json=_json, - template_url=self._create_or_update_at_management_group_scope_initial.metadata['url'], + content=_content, + template_url=self._create_or_update_at_management_group_scope_initial.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200, 201]: @@ -1546,37 +1963,41 @@ async def _create_or_update_at_management_group_scope_initial( raise HttpResponseError(response=response, error_format=ARMErrorFormat) if response.status_code == 200: - deserialized = self._deserialize('DeploymentExtended', pipeline_response) + deserialized = self._deserialize("DeploymentExtended", pipeline_response) if response.status_code == 201: - deserialized = self._deserialize('DeploymentExtended', pipeline_response) + deserialized = self._deserialize("DeploymentExtended", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - _create_or_update_at_management_group_scope_initial.metadata = {'url': "/providers/Microsoft.Management/managementGroups/{groupId}/providers/Microsoft.Resources/deployments/{deploymentName}"} # type: ignore - + _create_or_update_at_management_group_scope_initial.metadata = {"url": "/providers/Microsoft.Management/managementGroups/{groupId}/providers/Microsoft.Resources/deployments/{deploymentName}"} # type: ignore - @distributed_trace_async + @overload async def begin_create_or_update_at_management_group_scope( self, group_id: str, deployment_name: str, - parameters: "_models.Deployment", + parameters: _models.Deployment, + *, + content_type: str = "application/json", **kwargs: Any - ) -> AsyncLROPoller["_models.DeploymentExtended"]: + ) -> AsyncLROPoller[_models.DeploymentExtended]: """Deploys resources at management group scope. You can provide the template and parameters directly in the request or link to JSON files. - :param group_id: The management group ID. + :param group_id: The management group ID. Required. :type group_id: str - :param deployment_name: The name of the deployment. + :param deployment_name: The name of the deployment. Required. :type deployment_name: str - :param parameters: Additional parameters supplied to the operation. + :param parameters: Additional parameters supplied to the operation. Required. :type parameters: ~azure.mgmt.resource.resources.v2019_07_01.models.Deployment + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str :keyword callable cls: A custom type or function that will be passed the direct response :keyword str continuation_token: A continuation token to restart a poller from a saved state. :keyword polling: By default, your polling method will be AsyncARMPolling. Pass in False for @@ -1589,114 +2010,187 @@ async def begin_create_or_update_at_management_group_scope( cls(response) :rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.resource.resources.v2019_07_01.models.DeploymentExtended] - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - api_version = kwargs.pop('api_version', "2019-07-01") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] - polling = kwargs.pop('polling', True) # type: Union[bool, AsyncPollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType["_models.DeploymentExtended"] - lro_delay = kwargs.pop( - 'polling_interval', - self._config.polling_interval - ) - cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] + + @overload + async def begin_create_or_update_at_management_group_scope( + self, + group_id: str, + deployment_name: str, + parameters: IO, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> AsyncLROPoller[_models.DeploymentExtended]: + """Deploys resources at management group scope. + + You can provide the template and parameters directly in the request or link to JSON files. + + :param group_id: The management group ID. Required. + :type group_id: str + :param deployment_name: The name of the deployment. Required. + :type deployment_name: str + :param parameters: Additional parameters supplied to the operation. Required. + :type parameters: IO + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be AsyncARMPolling. Pass in False for + this operation to not poll, or pass in your own initialized polling object for a personal + polling strategy. + :paramtype polling: bool or ~azure.core.polling.AsyncPollingMethod + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of AsyncLROPoller that returns either DeploymentExtended or the result of + cls(response) + :rtype: + ~azure.core.polling.AsyncLROPoller[~azure.mgmt.resource.resources.v2019_07_01.models.DeploymentExtended] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace_async + async def begin_create_or_update_at_management_group_scope( + self, group_id: str, deployment_name: str, parameters: Union[_models.Deployment, IO], **kwargs: Any + ) -> AsyncLROPoller[_models.DeploymentExtended]: + """Deploys resources at management group scope. + + You can provide the template and parameters directly in the request or link to JSON files. + + :param group_id: The management group ID. Required. + :type group_id: str + :param deployment_name: The name of the deployment. Required. + :type deployment_name: str + :param parameters: Additional parameters supplied to the operation. Is either a model type or a + IO type. Required. + :type parameters: ~azure.mgmt.resource.resources.v2019_07_01.models.Deployment or IO + :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. + Default value is None. + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be AsyncARMPolling. Pass in False for + this operation to not poll, or pass in your own initialized polling object for a personal + polling strategy. + :paramtype polling: bool or ~azure.core.polling.AsyncPollingMethod + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of AsyncLROPoller that returns either DeploymentExtended or the result of + cls(response) + :rtype: + ~azure.core.polling.AsyncLROPoller[~azure.mgmt.resource.resources.v2019_07_01.models.DeploymentExtended] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _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", "2019-07-01")) # type: str + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.DeploymentExtended] + polling = kwargs.pop("polling", True) # type: Union[bool, AsyncPollingMethod] + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token = kwargs.pop("continuation_token", None) # type: Optional[str] if cont_token is None: - raw_result = await self._create_or_update_at_management_group_scope_initial( + raw_result = await self._create_or_update_at_management_group_scope_initial( # type: ignore group_id=group_id, deployment_name=deployment_name, parameters=parameters, api_version=api_version, content_type=content_type, - cls=lambda x,y,z: x, + cls=lambda x, y, z: x, + headers=_headers, + params=_params, **kwargs ) - kwargs.pop('error_map', None) + kwargs.pop("error_map", None) def get_long_running_output(pipeline_response): - response = pipeline_response.http_response - deserialized = self._deserialize('DeploymentExtended', pipeline_response) + deserialized = self._deserialize("DeploymentExtended", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - - if polling is True: polling_method = AsyncARMPolling(lro_delay, **kwargs) - elif polling is False: polling_method = AsyncNoPolling() - else: polling_method = polling + if polling is True: + polling_method = cast(AsyncPollingMethod, AsyncARMPolling(lro_delay, **kwargs)) # type: AsyncPollingMethod + elif polling is False: + polling_method = cast(AsyncPollingMethod, AsyncNoPolling()) + else: + polling_method = polling if cont_token: return AsyncLROPoller.from_continuation_token( polling_method=polling_method, continuation_token=cont_token, client=self._client, - deserialization_callback=get_long_running_output + deserialization_callback=get_long_running_output, ) return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) - begin_create_or_update_at_management_group_scope.metadata = {'url': "/providers/Microsoft.Management/managementGroups/{groupId}/providers/Microsoft.Resources/deployments/{deploymentName}"} # type: ignore + begin_create_or_update_at_management_group_scope.metadata = {"url": "/providers/Microsoft.Management/managementGroups/{groupId}/providers/Microsoft.Resources/deployments/{deploymentName}"} # type: ignore @distributed_trace_async async def get_at_management_group_scope( - self, - group_id: str, - deployment_name: str, - **kwargs: Any - ) -> "_models.DeploymentExtended": + self, group_id: str, deployment_name: str, **kwargs: Any + ) -> _models.DeploymentExtended: """Gets a deployment. - :param group_id: The management group ID. + :param group_id: The management group ID. Required. :type group_id: str - :param deployment_name: The name of the deployment. + :param deployment_name: The name of the deployment. Required. :type deployment_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: DeploymentExtended, or the result of cls(response) + :return: DeploymentExtended or the result of cls(response) :rtype: ~azure.mgmt.resource.resources.v2019_07_01.models.DeploymentExtended - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.DeploymentExtended"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) - api_version = kwargs.pop('api_version', "2019-07-01") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2019-07-01")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[_models.DeploymentExtended] - request = build_deployments_get_at_management_group_scope_request( group_id=group_id, deployment_name=deployment_name, api_version=api_version, - template_url=self.get_at_management_group_scope.metadata['url'], + template_url=self.get_at_management_group_scope.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) - deserialized = self._deserialize('DeploymentExtended', pipeline_response) + deserialized = self._deserialize("DeploymentExtended", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - get_at_management_group_scope.metadata = {'url': "/providers/Microsoft.Management/managementGroups/{groupId}/providers/Microsoft.Resources/deployments/{deploymentName}"} # type: ignore - + get_at_management_group_scope.metadata = {"url": "/providers/Microsoft.Management/managementGroups/{groupId}/providers/Microsoft.Resources/deployments/{deploymentName}"} # type: ignore @distributed_trace_async async def cancel_at_management_group_scope( # pylint: disable=inconsistent-return-statements - self, - group_id: str, - deployment_name: str, - **kwargs: Any + self, group_id: str, deployment_name: str, **kwargs: Any ) -> None: """Cancels a currently running template deployment. @@ -1705,38 +2199,44 @@ async def cancel_at_management_group_scope( # pylint: disable=inconsistent-retu deployment stops the currently running template deployment and leaves the resources partially deployed. - :param group_id: The management group ID. + :param group_id: The management group ID. Required. :type group_id: str - :param deployment_name: The name of the deployment. + :param deployment_name: The name of the deployment. Required. :type deployment_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: None, or the result of cls(response) + :return: None or the result of cls(response) :rtype: None - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType[None] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + 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', "2019-07-01") # type: str + api_version = kwargs.pop("api_version", _params.pop("api-version", "2019-07-01")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[None] - request = build_deployments_cancel_at_management_group_scope_request( group_id=group_id, deployment_name=deployment_name, api_version=api_version, - template_url=self.cancel_at_management_group_scope.metadata['url'], + template_url=self.cancel_at_management_group_scope.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [204]: @@ -1746,41 +2246,107 @@ async def cancel_at_management_group_scope( # pylint: disable=inconsistent-retu if cls: return cls(pipeline_response, None, {}) - cancel_at_management_group_scope.metadata = {'url': "/providers/Microsoft.Management/managementGroups/{groupId}/providers/Microsoft.Resources/deployments/{deploymentName}/cancel"} # type: ignore - + cancel_at_management_group_scope.metadata = {"url": "/providers/Microsoft.Management/managementGroups/{groupId}/providers/Microsoft.Resources/deployments/{deploymentName}/cancel"} # type: ignore - @distributed_trace_async + @overload async def validate_at_management_group_scope( self, group_id: str, deployment_name: str, - parameters: "_models.Deployment", + parameters: _models.Deployment, + *, + content_type: str = "application/json", **kwargs: Any - ) -> "_models.DeploymentValidateResult": + ) -> _models.DeploymentValidateResult: """Validates whether the specified template is syntactically correct and will be accepted by Azure Resource Manager.. - :param group_id: The management group ID. + :param group_id: The management group ID. Required. :type group_id: str - :param deployment_name: The name of the deployment. + :param deployment_name: The name of the deployment. Required. :type deployment_name: str - :param parameters: Parameters to validate. + :param parameters: Parameters to validate. Required. :type parameters: ~azure.mgmt.resource.resources.v2019_07_01.models.Deployment + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: DeploymentValidateResult or the result of cls(response) + :rtype: ~azure.mgmt.resource.resources.v2019_07_01.models.DeploymentValidateResult + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + async def validate_at_management_group_scope( + self, + group_id: str, + deployment_name: str, + parameters: IO, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.DeploymentValidateResult: + """Validates whether the specified template is syntactically correct and will be accepted by Azure + Resource Manager.. + + :param group_id: The management group ID. Required. + :type group_id: str + :param deployment_name: The name of the deployment. Required. + :type deployment_name: str + :param parameters: Parameters to validate. Required. + :type parameters: IO + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: DeploymentValidateResult or the result of cls(response) + :rtype: ~azure.mgmt.resource.resources.v2019_07_01.models.DeploymentValidateResult + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace_async + async def validate_at_management_group_scope( + self, group_id: str, deployment_name: str, parameters: Union[_models.Deployment, IO], **kwargs: Any + ) -> _models.DeploymentValidateResult: + """Validates whether the specified template is syntactically correct and will be accepted by Azure + Resource Manager.. + + :param group_id: The management group ID. Required. + :type group_id: str + :param deployment_name: The name of the deployment. Required. + :type deployment_name: str + :param parameters: Parameters to validate. Is either a model type or a IO type. Required. + :type parameters: ~azure.mgmt.resource.resources.v2019_07_01.models.Deployment or IO + :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. + Default value is None. + :paramtype content_type: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: DeploymentValidateResult, or the result of cls(response) + :return: DeploymentValidateResult or the result of cls(response) :rtype: ~azure.mgmt.resource.resources.v2019_07_01.models.DeploymentValidateResult - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.DeploymentValidateResult"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', "2019-07-01") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + api_version = kwargs.pop("api_version", _params.pop("api-version", "2019-07-01")) # type: str + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.DeploymentValidateResult] - _json = self._serialize.body(parameters, 'Deployment') + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(parameters, (IO, bytes)): + _content = parameters + else: + _json = self._serialize.body(parameters, "Deployment") request = build_deployments_validate_at_management_group_scope_request( group_id=group_id, @@ -1788,16 +2354,18 @@ async def validate_at_management_group_scope( api_version=api_version, content_type=content_type, json=_json, - template_url=self.validate_at_management_group_scope.metadata['url'], + content=_content, + template_url=self.validate_at_management_group_scope.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200, 400]: @@ -1805,87 +2373,84 @@ async def validate_at_management_group_scope( raise HttpResponseError(response=response, error_format=ARMErrorFormat) if response.status_code == 200: - deserialized = self._deserialize('DeploymentValidateResult', pipeline_response) + deserialized = self._deserialize("DeploymentValidateResult", pipeline_response) if response.status_code == 400: - deserialized = self._deserialize('DeploymentValidateResult', pipeline_response) + deserialized = self._deserialize("DeploymentValidateResult", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - validate_at_management_group_scope.metadata = {'url': "/providers/Microsoft.Management/managementGroups/{groupId}/providers/Microsoft.Resources/deployments/{deploymentName}/validate"} # type: ignore - + validate_at_management_group_scope.metadata = {"url": "/providers/Microsoft.Management/managementGroups/{groupId}/providers/Microsoft.Resources/deployments/{deploymentName}/validate"} # type: ignore @distributed_trace_async async def export_template_at_management_group_scope( - self, - group_id: str, - deployment_name: str, - **kwargs: Any - ) -> "_models.DeploymentExportResult": + self, group_id: str, deployment_name: str, **kwargs: Any + ) -> _models.DeploymentExportResult: """Exports the template used for specified deployment. - :param group_id: The management group ID. + :param group_id: The management group ID. Required. :type group_id: str - :param deployment_name: The name of the deployment. + :param deployment_name: The name of the deployment. Required. :type deployment_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: DeploymentExportResult, or the result of cls(response) + :return: DeploymentExportResult or the result of cls(response) :rtype: ~azure.mgmt.resource.resources.v2019_07_01.models.DeploymentExportResult - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.DeploymentExportResult"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) - api_version = kwargs.pop('api_version', "2019-07-01") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2019-07-01")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[_models.DeploymentExportResult] - request = build_deployments_export_template_at_management_group_scope_request( group_id=group_id, deployment_name=deployment_name, api_version=api_version, - template_url=self.export_template_at_management_group_scope.metadata['url'], + template_url=self.export_template_at_management_group_scope.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) - deserialized = self._deserialize('DeploymentExportResult', pipeline_response) + deserialized = self._deserialize("DeploymentExportResult", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - export_template_at_management_group_scope.metadata = {'url': "/providers/Microsoft.Management/managementGroups/{groupId}/providers/Microsoft.Resources/deployments/{deploymentName}/exportTemplate"} # type: ignore - + export_template_at_management_group_scope.metadata = {"url": "/providers/Microsoft.Management/managementGroups/{groupId}/providers/Microsoft.Resources/deployments/{deploymentName}/exportTemplate"} # type: ignore @distributed_trace def list_at_management_group_scope( - self, - group_id: str, - filter: Optional[str] = None, - top: Optional[int] = None, - **kwargs: Any - ) -> AsyncIterable["_models.DeploymentListResult"]: + self, group_id: str, filter: Optional[str] = None, top: Optional[int] = None, **kwargs: Any + ) -> AsyncIterable["_models.DeploymentExtended"]: """Get all the deployments for a management group. - :param group_id: The management group ID. + :param group_id: The management group ID. Required. :type group_id: str :param filter: The filter to apply on the operation. For example, you can use $filter=provisioningState eq '{state}'. Default value is None. @@ -1894,40 +2459,48 @@ def list_at_management_group_scope( value is None. :type top: int :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either DeploymentListResult or the result of - cls(response) + :return: An iterator like instance of either DeploymentExtended or the result of cls(response) :rtype: - ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.resource.resources.v2019_07_01.models.DeploymentListResult] - :raises: ~azure.core.exceptions.HttpResponseError + ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.resource.resources.v2019_07_01.models.DeploymentExtended] + :raises ~azure.core.exceptions.HttpResponseError: """ - api_version = kwargs.pop('api_version', "2019-07-01") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2019-07-01")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[_models.DeploymentListResult] - cls = kwargs.pop('cls', None) # type: ClsType["_models.DeploymentListResult"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) + def prepare_request(next_link=None): if not next_link: - + request = build_deployments_list_at_management_group_scope_request( group_id=group_id, - api_version=api_version, filter=filter, top=top, - template_url=self.list_at_management_group_scope.metadata['url'], + api_version=api_version, + template_url=self.list_at_management_group_scope.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore else: - - request = build_deployments_list_at_management_group_scope_request( - group_id=group_id, - template_url=next_link, - ) + # make call to next link with the client's api-version + _parsed_next_link = urlparse(next_link) + _next_request_params = case_insensitive_dict(parse_qs(_parsed_next_link.query)) + _next_request_params["api-version"] = self._config.api_version + request = HttpRequest("GET", urljoin(next_link, _parsed_next_link.path), params=_next_request_params) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore request.method = "GET" return request @@ -1941,10 +2514,8 @@ async def extract_data(pipeline_response): async def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) response = pipeline_response.http_response @@ -1954,40 +2525,42 @@ async def get_next(next_link=None): return pipeline_response + return AsyncItemPaged(get_next, extract_data) - return AsyncItemPaged( - get_next, extract_data - ) - list_at_management_group_scope.metadata = {'url': "/providers/Microsoft.Management/managementGroups/{groupId}/providers/Microsoft.Resources/deployments/"} # type: ignore + list_at_management_group_scope.metadata = {"url": "/providers/Microsoft.Management/managementGroups/{groupId}/providers/Microsoft.Resources/deployments/"} # type: ignore async def _delete_at_subscription_scope_initial( # pylint: disable=inconsistent-return-statements - self, - deployment_name: str, - **kwargs: Any + self, deployment_name: str, **kwargs: Any ) -> None: - cls = kwargs.pop('cls', None) # type: ClsType[None] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) - api_version = kwargs.pop('api_version', "2019-07-01") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - request = build_deployments_delete_at_subscription_scope_request_initial( + api_version = kwargs.pop("api_version", _params.pop("api-version", "2019-07-01")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[None] + + request = build_deployments_delete_at_subscription_scope_request( deployment_name=deployment_name, subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self._delete_at_subscription_scope_initial.metadata['url'], + template_url=self._delete_at_subscription_scope_initial.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [202, 204]: @@ -1997,15 +2570,10 @@ async def _delete_at_subscription_scope_initial( # pylint: disable=inconsistent if cls: return cls(pipeline_response, None, {}) - _delete_at_subscription_scope_initial.metadata = {'url': "/subscriptions/{subscriptionId}/providers/Microsoft.Resources/deployments/{deploymentName}"} # type: ignore - + _delete_at_subscription_scope_initial.metadata = {"url": "/subscriptions/{subscriptionId}/providers/Microsoft.Resources/deployments/{deploymentName}"} # type: ignore @distributed_trace_async - async def begin_delete_at_subscription_scope( # pylint: disable=inconsistent-return-statements - self, - deployment_name: str, - **kwargs: Any - ) -> AsyncLROPoller[None]: + async def begin_delete_at_subscription_scope(self, deployment_name: str, **kwargs: Any) -> AsyncLROPoller[None]: """Deletes a deployment from the deployment history. A template deployment that is currently running cannot be deleted. Deleting a template @@ -2016,7 +2584,7 @@ async def begin_delete_at_subscription_scope( # pylint: disable=inconsistent-re process finishes, the URI in the Location header returns a status of 204 on success. If the asynchronous request failed, the URI in the Location header returns an error-level status code. - :param deployment_name: The name of the deployment. + :param deployment_name: The name of the deployment. Required. :type deployment_name: str :keyword callable cls: A custom type or function that will be passed the direct response :keyword str continuation_token: A continuation token to restart a poller from a saved state. @@ -2028,82 +2596,88 @@ async def begin_delete_at_subscription_scope( # pylint: disable=inconsistent-re Retry-After header is present. :return: An instance of AsyncLROPoller that returns either None or the result of cls(response) :rtype: ~azure.core.polling.AsyncLROPoller[None] - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - api_version = kwargs.pop('api_version', "2019-07-01") # type: str - polling = kwargs.pop('polling', True) # type: Union[bool, AsyncPollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType[None] - lro_delay = kwargs.pop( - 'polling_interval', - self._config.polling_interval - ) - cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2019-07-01")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[None] + polling = kwargs.pop("polling", True) # type: Union[bool, AsyncPollingMethod] + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token = kwargs.pop("continuation_token", None) # type: Optional[str] if cont_token is None: - raw_result = await self._delete_at_subscription_scope_initial( + raw_result = await self._delete_at_subscription_scope_initial( # type: ignore deployment_name=deployment_name, api_version=api_version, - cls=lambda x,y,z: x, + cls=lambda x, y, z: x, + headers=_headers, + params=_params, **kwargs ) - kwargs.pop('error_map', None) + kwargs.pop("error_map", None) - def get_long_running_output(pipeline_response): + def get_long_running_output(pipeline_response): # pylint: disable=inconsistent-return-statements if cls: return cls(pipeline_response, None, {}) - - if polling is True: polling_method = AsyncARMPolling(lro_delay, **kwargs) - elif polling is False: polling_method = AsyncNoPolling() - else: polling_method = polling + if polling is True: + polling_method = cast(AsyncPollingMethod, AsyncARMPolling(lro_delay, **kwargs)) # type: AsyncPollingMethod + elif polling is False: + polling_method = cast(AsyncPollingMethod, AsyncNoPolling()) + else: + polling_method = polling if cont_token: return AsyncLROPoller.from_continuation_token( polling_method=polling_method, continuation_token=cont_token, client=self._client, - deserialization_callback=get_long_running_output + deserialization_callback=get_long_running_output, ) return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) - begin_delete_at_subscription_scope.metadata = {'url': "/subscriptions/{subscriptionId}/providers/Microsoft.Resources/deployments/{deploymentName}"} # type: ignore + begin_delete_at_subscription_scope.metadata = {"url": "/subscriptions/{subscriptionId}/providers/Microsoft.Resources/deployments/{deploymentName}"} # type: ignore @distributed_trace_async - async def check_existence_at_subscription_scope( - self, - deployment_name: str, - **kwargs: Any - ) -> bool: + async def check_existence_at_subscription_scope(self, deployment_name: str, **kwargs: Any) -> bool: """Checks whether the deployment exists. - :param deployment_name: The name of the deployment. + :param deployment_name: The name of the deployment. Required. :type deployment_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: bool, or the result of cls(response) + :return: bool or the result of cls(response) :rtype: bool - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType[None] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) - api_version = kwargs.pop('api_version', "2019-07-01") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2019-07-01")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[None] - request = build_deployments_check_existence_at_subscription_scope_request( deployment_name=deployment_name, subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.check_existence_at_subscription_scope.metadata['url'], + template_url=self.check_existence_at_subscription_scope.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [204, 404]: @@ -2114,42 +2688,52 @@ async def check_existence_at_subscription_scope( return cls(pipeline_response, None, {}) return 200 <= response.status_code <= 299 - check_existence_at_subscription_scope.metadata = {'url': "/subscriptions/{subscriptionId}/providers/Microsoft.Resources/deployments/{deploymentName}"} # type: ignore - + check_existence_at_subscription_scope.metadata = {"url": "/subscriptions/{subscriptionId}/providers/Microsoft.Resources/deployments/{deploymentName}"} # type: ignore async def _create_or_update_at_subscription_scope_initial( - self, - deployment_name: str, - parameters: "_models.Deployment", - **kwargs: Any - ) -> "_models.DeploymentExtended": - cls = kwargs.pop('cls', None) # type: ClsType["_models.DeploymentExtended"] + self, deployment_name: str, parameters: Union[_models.Deployment, IO], **kwargs: Any + ) -> _models.DeploymentExtended: error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) - api_version = kwargs.pop('api_version', "2019-07-01") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - _json = self._serialize.body(parameters, 'Deployment') + api_version = kwargs.pop("api_version", _params.pop("api-version", "2019-07-01")) # type: str + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.DeploymentExtended] - request = build_deployments_create_or_update_at_subscription_scope_request_initial( + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(parameters, (IO, bytes)): + _content = parameters + else: + _json = self._serialize.body(parameters, "Deployment") + + request = build_deployments_create_or_update_at_subscription_scope_request( deployment_name=deployment_name, subscription_id=self._config.subscription_id, api_version=api_version, content_type=content_type, json=_json, - template_url=self._create_or_update_at_subscription_scope_initial.metadata['url'], + content=_content, + template_url=self._create_or_update_at_subscription_scope_initial.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200, 201]: @@ -2157,34 +2741,38 @@ async def _create_or_update_at_subscription_scope_initial( raise HttpResponseError(response=response, error_format=ARMErrorFormat) if response.status_code == 200: - deserialized = self._deserialize('DeploymentExtended', pipeline_response) + deserialized = self._deserialize("DeploymentExtended", pipeline_response) if response.status_code == 201: - deserialized = self._deserialize('DeploymentExtended', pipeline_response) + deserialized = self._deserialize("DeploymentExtended", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - _create_or_update_at_subscription_scope_initial.metadata = {'url': "/subscriptions/{subscriptionId}/providers/Microsoft.Resources/deployments/{deploymentName}"} # type: ignore + _create_or_update_at_subscription_scope_initial.metadata = {"url": "/subscriptions/{subscriptionId}/providers/Microsoft.Resources/deployments/{deploymentName}"} # type: ignore - - @distributed_trace_async + @overload async def begin_create_or_update_at_subscription_scope( self, deployment_name: str, - parameters: "_models.Deployment", + parameters: _models.Deployment, + *, + content_type: str = "application/json", **kwargs: Any - ) -> AsyncLROPoller["_models.DeploymentExtended"]: + ) -> AsyncLROPoller[_models.DeploymentExtended]: """Deploys resources at subscription scope. You can provide the template and parameters directly in the request or link to JSON files. - :param deployment_name: The name of the deployment. + :param deployment_name: The name of the deployment. Required. :type deployment_name: str - :param parameters: Additional parameters supplied to the operation. + :param parameters: Additional parameters supplied to the operation. Required. :type parameters: ~azure.mgmt.resource.resources.v2019_07_01.models.Deployment + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str :keyword callable cls: A custom type or function that will be passed the direct response :keyword str continuation_token: A continuation token to restart a poller from a saved state. :keyword polling: By default, your polling method will be AsyncARMPolling. Pass in False for @@ -2197,109 +2785,172 @@ async def begin_create_or_update_at_subscription_scope( cls(response) :rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.resource.resources.v2019_07_01.models.DeploymentExtended] - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - api_version = kwargs.pop('api_version', "2019-07-01") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] - polling = kwargs.pop('polling', True) # type: Union[bool, AsyncPollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType["_models.DeploymentExtended"] - lro_delay = kwargs.pop( - 'polling_interval', - self._config.polling_interval - ) - cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] - if cont_token is None: - raw_result = await self._create_or_update_at_subscription_scope_initial( - deployment_name=deployment_name, - parameters=parameters, - api_version=api_version, - content_type=content_type, - cls=lambda x,y,z: x, - **kwargs - ) - kwargs.pop('error_map', None) - - def get_long_running_output(pipeline_response): - response = pipeline_response.http_response - deserialized = self._deserialize('DeploymentExtended', pipeline_response) - if cls: - return cls(pipeline_response, deserialized, {}) - return deserialized - - - if polling is True: polling_method = AsyncARMPolling(lro_delay, **kwargs) - elif polling is False: polling_method = AsyncNoPolling() - else: polling_method = polling - if cont_token: - return AsyncLROPoller.from_continuation_token( - polling_method=polling_method, - continuation_token=cont_token, - client=self._client, - deserialization_callback=get_long_running_output - ) - return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) - begin_create_or_update_at_subscription_scope.metadata = {'url': "/subscriptions/{subscriptionId}/providers/Microsoft.Resources/deployments/{deploymentName}"} # type: ignore + @overload + async def begin_create_or_update_at_subscription_scope( + self, deployment_name: str, parameters: IO, *, content_type: str = "application/json", **kwargs: Any + ) -> AsyncLROPoller[_models.DeploymentExtended]: + """Deploys resources at subscription scope. - @distributed_trace_async - async def get_at_subscription_scope( - self, - deployment_name: str, - **kwargs: Any - ) -> "_models.DeploymentExtended": - """Gets a deployment. + You can provide the template and parameters directly in the request or link to JSON files. - :param deployment_name: The name of the deployment. + :param deployment_name: The name of the deployment. Required. :type deployment_name: str + :param parameters: Additional parameters supplied to the operation. Required. + :type parameters: IO + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: DeploymentExtended, or the result of cls(response) - :rtype: ~azure.mgmt.resource.resources.v2019_07_01.models.DeploymentExtended - :raises: ~azure.core.exceptions.HttpResponseError - """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.DeploymentExtended"] - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {})) - - api_version = kwargs.pop('api_version', "2019-07-01") # type: str - - - request = build_deployments_get_at_subscription_scope_request( - deployment_name=deployment_name, - subscription_id=self._config.subscription_id, - api_version=api_version, - template_url=self.get_at_subscription_scope.metadata['url'], + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be AsyncARMPolling. Pass in False for + this operation to not poll, or pass in your own initialized polling object for a personal + polling strategy. + :paramtype polling: bool or ~azure.core.polling.AsyncPollingMethod + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of AsyncLROPoller that returns either DeploymentExtended or the result of + cls(response) + :rtype: + ~azure.core.polling.AsyncLROPoller[~azure.mgmt.resource.resources.v2019_07_01.models.DeploymentExtended] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace_async + async def begin_create_or_update_at_subscription_scope( + self, deployment_name: str, parameters: Union[_models.Deployment, IO], **kwargs: Any + ) -> AsyncLROPoller[_models.DeploymentExtended]: + """Deploys resources at subscription scope. + + You can provide the template and parameters directly in the request or link to JSON files. + + :param deployment_name: The name of the deployment. Required. + :type deployment_name: str + :param parameters: Additional parameters supplied to the operation. Is either a model type or a + IO type. Required. + :type parameters: ~azure.mgmt.resource.resources.v2019_07_01.models.Deployment or IO + :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. + Default value is None. + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be AsyncARMPolling. Pass in False for + this operation to not poll, or pass in your own initialized polling object for a personal + polling strategy. + :paramtype polling: bool or ~azure.core.polling.AsyncPollingMethod + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of AsyncLROPoller that returns either DeploymentExtended or the result of + cls(response) + :rtype: + ~azure.core.polling.AsyncLROPoller[~azure.mgmt.resource.resources.v2019_07_01.models.DeploymentExtended] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _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", "2019-07-01")) # type: str + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.DeploymentExtended] + polling = kwargs.pop("polling", True) # type: Union[bool, AsyncPollingMethod] + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token = kwargs.pop("continuation_token", None) # type: Optional[str] + if cont_token is None: + raw_result = await self._create_or_update_at_subscription_scope_initial( # type: ignore + deployment_name=deployment_name, + parameters=parameters, + api_version=api_version, + content_type=content_type, + cls=lambda x, y, z: x, + headers=_headers, + params=_params, + **kwargs + ) + kwargs.pop("error_map", None) + + def get_long_running_output(pipeline_response): + deserialized = self._deserialize("DeploymentExtended", pipeline_response) + if cls: + return cls(pipeline_response, deserialized, {}) + return deserialized + + if polling is True: + polling_method = cast(AsyncPollingMethod, AsyncARMPolling(lro_delay, **kwargs)) # type: AsyncPollingMethod + elif polling is False: + polling_method = cast(AsyncPollingMethod, AsyncNoPolling()) + else: + polling_method = polling + if cont_token: + return AsyncLROPoller.from_continuation_token( + polling_method=polling_method, + continuation_token=cont_token, + client=self._client, + deserialization_callback=get_long_running_output, + ) + return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) + + begin_create_or_update_at_subscription_scope.metadata = {"url": "/subscriptions/{subscriptionId}/providers/Microsoft.Resources/deployments/{deploymentName}"} # type: ignore + + @distributed_trace_async + async def get_at_subscription_scope(self, deployment_name: str, **kwargs: Any) -> _models.DeploymentExtended: + """Gets a deployment. + + :param deployment_name: The name of the deployment. Required. + :type deployment_name: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: DeploymentExtended or the result of cls(response) + :rtype: ~azure.mgmt.resource.resources.v2019_07_01.models.DeploymentExtended + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2019-07-01")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[_models.DeploymentExtended] + + request = build_deployments_get_at_subscription_scope_request( + deployment_name=deployment_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + template_url=self.get_at_subscription_scope.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) - deserialized = self._deserialize('DeploymentExtended', pipeline_response) + deserialized = self._deserialize("DeploymentExtended", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - get_at_subscription_scope.metadata = {'url': "/subscriptions/{subscriptionId}/providers/Microsoft.Resources/deployments/{deploymentName}"} # type: ignore - + get_at_subscription_scope.metadata = {"url": "/subscriptions/{subscriptionId}/providers/Microsoft.Resources/deployments/{deploymentName}"} # type: ignore @distributed_trace_async async def cancel_at_subscription_scope( # pylint: disable=inconsistent-return-statements - self, - deployment_name: str, - **kwargs: Any + self, deployment_name: str, **kwargs: Any ) -> None: """Cancels a currently running template deployment. @@ -2308,36 +2959,42 @@ async def cancel_at_subscription_scope( # pylint: disable=inconsistent-return-s deployment stops the currently running template deployment and leaves the resources partially deployed. - :param deployment_name: The name of the deployment. + :param deployment_name: The name of the deployment. Required. :type deployment_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: None, or the result of cls(response) + :return: None or the result of cls(response) :rtype: None - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType[None] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + 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', "2019-07-01") # type: str + api_version = kwargs.pop("api_version", _params.pop("api-version", "2019-07-01")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[None] - request = build_deployments_cancel_at_subscription_scope_request( deployment_name=deployment_name, subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.cancel_at_subscription_scope.metadata['url'], + template_url=self.cancel_at_subscription_scope.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [204]: @@ -2347,38 +3004,94 @@ async def cancel_at_subscription_scope( # pylint: disable=inconsistent-return-s if cls: return cls(pipeline_response, None, {}) - cancel_at_subscription_scope.metadata = {'url': "/subscriptions/{subscriptionId}/providers/Microsoft.Resources/deployments/{deploymentName}/cancel"} # type: ignore - + cancel_at_subscription_scope.metadata = {"url": "/subscriptions/{subscriptionId}/providers/Microsoft.Resources/deployments/{deploymentName}/cancel"} # type: ignore - @distributed_trace_async + @overload async def validate_at_subscription_scope( self, deployment_name: str, - parameters: "_models.Deployment", + parameters: _models.Deployment, + *, + content_type: str = "application/json", **kwargs: Any - ) -> "_models.DeploymentValidateResult": + ) -> _models.DeploymentValidateResult: """Validates whether the specified template is syntactically correct and will be accepted by Azure Resource Manager.. - :param deployment_name: The name of the deployment. + :param deployment_name: The name of the deployment. Required. :type deployment_name: str - :param parameters: Parameters to validate. + :param parameters: Parameters to validate. Required. :type parameters: ~azure.mgmt.resource.resources.v2019_07_01.models.Deployment + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: DeploymentValidateResult or the result of cls(response) + :rtype: ~azure.mgmt.resource.resources.v2019_07_01.models.DeploymentValidateResult + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + async def validate_at_subscription_scope( + self, deployment_name: str, parameters: IO, *, content_type: str = "application/json", **kwargs: Any + ) -> _models.DeploymentValidateResult: + """Validates whether the specified template is syntactically correct and will be accepted by Azure + Resource Manager.. + + :param deployment_name: The name of the deployment. Required. + :type deployment_name: str + :param parameters: Parameters to validate. Required. + :type parameters: IO + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: DeploymentValidateResult or the result of cls(response) + :rtype: ~azure.mgmt.resource.resources.v2019_07_01.models.DeploymentValidateResult + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace_async + async def validate_at_subscription_scope( + self, deployment_name: str, parameters: Union[_models.Deployment, IO], **kwargs: Any + ) -> _models.DeploymentValidateResult: + """Validates whether the specified template is syntactically correct and will be accepted by Azure + Resource Manager.. + + :param deployment_name: The name of the deployment. Required. + :type deployment_name: str + :param parameters: Parameters to validate. Is either a model type or a IO type. Required. + :type parameters: ~azure.mgmt.resource.resources.v2019_07_01.models.Deployment or IO + :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. + Default value is None. + :paramtype content_type: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: DeploymentValidateResult, or the result of cls(response) + :return: DeploymentValidateResult or the result of cls(response) :rtype: ~azure.mgmt.resource.resources.v2019_07_01.models.DeploymentValidateResult - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.DeploymentValidateResult"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', "2019-07-01") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + api_version = kwargs.pop("api_version", _params.pop("api-version", "2019-07-01")) # type: str + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.DeploymentValidateResult] - _json = self._serialize.body(parameters, 'Deployment') + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(parameters, (IO, bytes)): + _content = parameters + else: + _json = self._serialize.body(parameters, "Deployment") request = build_deployments_validate_at_subscription_scope_request( deployment_name=deployment_name, @@ -2386,16 +3099,18 @@ async def validate_at_subscription_scope( api_version=api_version, content_type=content_type, json=_json, - template_url=self.validate_at_subscription_scope.metadata['url'], + content=_content, + template_url=self.validate_at_subscription_scope.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200, 400]: @@ -2403,52 +3118,62 @@ async def validate_at_subscription_scope( raise HttpResponseError(response=response, error_format=ARMErrorFormat) if response.status_code == 200: - deserialized = self._deserialize('DeploymentValidateResult', pipeline_response) + deserialized = self._deserialize("DeploymentValidateResult", pipeline_response) if response.status_code == 400: - deserialized = self._deserialize('DeploymentValidateResult', pipeline_response) + deserialized = self._deserialize("DeploymentValidateResult", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - validate_at_subscription_scope.metadata = {'url': "/subscriptions/{subscriptionId}/providers/Microsoft.Resources/deployments/{deploymentName}/validate"} # type: ignore - + validate_at_subscription_scope.metadata = {"url": "/subscriptions/{subscriptionId}/providers/Microsoft.Resources/deployments/{deploymentName}/validate"} # type: ignore async def _what_if_at_subscription_scope_initial( - self, - deployment_name: str, - parameters: "_models.DeploymentWhatIf", - **kwargs: Any - ) -> Optional["_models.WhatIfOperationResult"]: - cls = kwargs.pop('cls', None) # type: ClsType[Optional["_models.WhatIfOperationResult"]] + self, deployment_name: str, parameters: Union[_models.DeploymentWhatIf, IO], **kwargs: Any + ) -> Optional[_models.WhatIfOperationResult]: error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', "2019-07-01") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + api_version = kwargs.pop("api_version", _params.pop("api-version", "2019-07-01")) # type: str + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[Optional[_models.WhatIfOperationResult]] - _json = self._serialize.body(parameters, 'DeploymentWhatIf') + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(parameters, (IO, bytes)): + _content = parameters + else: + _json = self._serialize.body(parameters, "DeploymentWhatIf") - request = build_deployments_what_if_at_subscription_scope_request_initial( + request = build_deployments_what_if_at_subscription_scope_request( deployment_name=deployment_name, subscription_id=self._config.subscription_id, api_version=api_version, content_type=content_type, json=_json, - template_url=self._what_if_at_subscription_scope_initial.metadata['url'], + content=_content, + template_url=self._what_if_at_subscription_scope_initial.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200, 202]: @@ -2458,35 +3183,38 @@ async def _what_if_at_subscription_scope_initial( deserialized = None response_headers = {} if response.status_code == 200: - deserialized = self._deserialize('WhatIfOperationResult', pipeline_response) + deserialized = self._deserialize("WhatIfOperationResult", pipeline_response) if response.status_code == 202: - response_headers['Location']=self._deserialize('str', response.headers.get('Location')) - response_headers['Retry-After']=self._deserialize('str', response.headers.get('Retry-After')) - + response_headers["Location"] = self._deserialize("str", response.headers.get("Location")) + response_headers["Retry-After"] = self._deserialize("str", response.headers.get("Retry-After")) if cls: return cls(pipeline_response, deserialized, response_headers) return deserialized - _what_if_at_subscription_scope_initial.metadata = {'url': "/subscriptions/{subscriptionId}/providers/Microsoft.Resources/deployments/{deploymentName}/whatIf"} # type: ignore - + _what_if_at_subscription_scope_initial.metadata = {"url": "/subscriptions/{subscriptionId}/providers/Microsoft.Resources/deployments/{deploymentName}/whatIf"} # type: ignore - @distributed_trace_async + @overload async def begin_what_if_at_subscription_scope( self, deployment_name: str, - parameters: "_models.DeploymentWhatIf", + parameters: _models.DeploymentWhatIf, + *, + content_type: str = "application/json", **kwargs: Any - ) -> AsyncLROPoller["_models.WhatIfOperationResult"]: + ) -> AsyncLROPoller[_models.WhatIfOperationResult]: """Returns changes that will be made by the deployment if executed at the scope of the subscription. - :param deployment_name: The name of the deployment. + :param deployment_name: The name of the deployment. Required. :type deployment_name: str - :param parameters: Parameters to What If. + :param parameters: Parameters to What If. Required. :type parameters: ~azure.mgmt.resource.resources.v2019_07_01.models.DeploymentWhatIf + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str :keyword callable cls: A custom type or function that will be passed the direct response :keyword str continuation_token: A continuation token to restart a poller from a saved state. :keyword polling: By default, your polling method will be AsyncARMPolling. Pass in False for @@ -2499,111 +3227,174 @@ async def begin_what_if_at_subscription_scope( of cls(response) :rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.resource.resources.v2019_07_01.models.WhatIfOperationResult] - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - api_version = kwargs.pop('api_version', "2019-07-01") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] - polling = kwargs.pop('polling', True) # type: Union[bool, AsyncPollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType["_models.WhatIfOperationResult"] - lro_delay = kwargs.pop( - 'polling_interval', - self._config.polling_interval - ) - cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] + + @overload + async def begin_what_if_at_subscription_scope( + self, deployment_name: str, parameters: IO, *, content_type: str = "application/json", **kwargs: Any + ) -> AsyncLROPoller[_models.WhatIfOperationResult]: + """Returns changes that will be made by the deployment if executed at the scope of the + subscription. + + :param deployment_name: The name of the deployment. Required. + :type deployment_name: str + :param parameters: Parameters to What If. Required. + :type parameters: IO + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be AsyncARMPolling. Pass in False for + this operation to not poll, or pass in your own initialized polling object for a personal + polling strategy. + :paramtype polling: bool or ~azure.core.polling.AsyncPollingMethod + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of AsyncLROPoller that returns either WhatIfOperationResult or the result + of cls(response) + :rtype: + ~azure.core.polling.AsyncLROPoller[~azure.mgmt.resource.resources.v2019_07_01.models.WhatIfOperationResult] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace_async + async def begin_what_if_at_subscription_scope( + self, deployment_name: str, parameters: Union[_models.DeploymentWhatIf, IO], **kwargs: Any + ) -> AsyncLROPoller[_models.WhatIfOperationResult]: + """Returns changes that will be made by the deployment if executed at the scope of the + subscription. + + :param deployment_name: The name of the deployment. Required. + :type deployment_name: str + :param parameters: Parameters to What If. Is either a model type or a IO type. Required. + :type parameters: ~azure.mgmt.resource.resources.v2019_07_01.models.DeploymentWhatIf or IO + :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. + Default value is None. + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be AsyncARMPolling. Pass in False for + this operation to not poll, or pass in your own initialized polling object for a personal + polling strategy. + :paramtype polling: bool or ~azure.core.polling.AsyncPollingMethod + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of AsyncLROPoller that returns either WhatIfOperationResult or the result + of cls(response) + :rtype: + ~azure.core.polling.AsyncLROPoller[~azure.mgmt.resource.resources.v2019_07_01.models.WhatIfOperationResult] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _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", "2019-07-01")) # type: str + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.WhatIfOperationResult] + polling = kwargs.pop("polling", True) # type: Union[bool, AsyncPollingMethod] + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token = kwargs.pop("continuation_token", None) # type: Optional[str] if cont_token is None: - raw_result = await self._what_if_at_subscription_scope_initial( + raw_result = await self._what_if_at_subscription_scope_initial( # type: ignore deployment_name=deployment_name, parameters=parameters, api_version=api_version, content_type=content_type, - cls=lambda x,y,z: x, + cls=lambda x, y, z: x, + headers=_headers, + params=_params, **kwargs ) - kwargs.pop('error_map', None) + kwargs.pop("error_map", None) def get_long_running_output(pipeline_response): - response = pipeline_response.http_response - deserialized = self._deserialize('WhatIfOperationResult', pipeline_response) + deserialized = self._deserialize("WhatIfOperationResult", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - - if polling is True: polling_method = AsyncARMPolling(lro_delay, lro_options={'final-state-via': 'location'}, **kwargs) - elif polling is False: polling_method = AsyncNoPolling() - else: polling_method = polling + if polling is True: + polling_method = cast( + AsyncPollingMethod, AsyncARMPolling(lro_delay, lro_options={"final-state-via": "location"}, **kwargs) + ) # type: AsyncPollingMethod + elif polling is False: + polling_method = cast(AsyncPollingMethod, AsyncNoPolling()) + else: + polling_method = polling if cont_token: return AsyncLROPoller.from_continuation_token( polling_method=polling_method, continuation_token=cont_token, client=self._client, - deserialization_callback=get_long_running_output + deserialization_callback=get_long_running_output, ) return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) - begin_what_if_at_subscription_scope.metadata = {'url': "/subscriptions/{subscriptionId}/providers/Microsoft.Resources/deployments/{deploymentName}/whatIf"} # type: ignore + begin_what_if_at_subscription_scope.metadata = {"url": "/subscriptions/{subscriptionId}/providers/Microsoft.Resources/deployments/{deploymentName}/whatIf"} # type: ignore @distributed_trace_async async def export_template_at_subscription_scope( - self, - deployment_name: str, - **kwargs: Any - ) -> "_models.DeploymentExportResult": + self, deployment_name: str, **kwargs: Any + ) -> _models.DeploymentExportResult: """Exports the template used for specified deployment. - :param deployment_name: The name of the deployment. + :param deployment_name: The name of the deployment. Required. :type deployment_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: DeploymentExportResult, or the result of cls(response) + :return: DeploymentExportResult or the result of cls(response) :rtype: ~azure.mgmt.resource.resources.v2019_07_01.models.DeploymentExportResult - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.DeploymentExportResult"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + 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', "2019-07-01") # type: str + api_version = kwargs.pop("api_version", _params.pop("api-version", "2019-07-01")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[_models.DeploymentExportResult] - request = build_deployments_export_template_at_subscription_scope_request( deployment_name=deployment_name, subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.export_template_at_subscription_scope.metadata['url'], + template_url=self.export_template_at_subscription_scope.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) - deserialized = self._deserialize('DeploymentExportResult', pipeline_response) + deserialized = self._deserialize("DeploymentExportResult", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - export_template_at_subscription_scope.metadata = {'url': "/subscriptions/{subscriptionId}/providers/Microsoft.Resources/deployments/{deploymentName}/exportTemplate"} # type: ignore - + export_template_at_subscription_scope.metadata = {"url": "/subscriptions/{subscriptionId}/providers/Microsoft.Resources/deployments/{deploymentName}/exportTemplate"} # type: ignore @distributed_trace def list_at_subscription_scope( - self, - filter: Optional[str] = None, - top: Optional[int] = None, - **kwargs: Any - ) -> AsyncIterable["_models.DeploymentListResult"]: + self, filter: Optional[str] = None, top: Optional[int] = None, **kwargs: Any + ) -> AsyncIterable["_models.DeploymentExtended"]: """Get all the deployments for a subscription. :param filter: The filter to apply on the operation. For example, you can use @@ -2613,40 +3404,48 @@ def list_at_subscription_scope( value is None. :type top: int :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either DeploymentListResult or the result of - cls(response) + :return: An iterator like instance of either DeploymentExtended or the result of cls(response) :rtype: - ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.resource.resources.v2019_07_01.models.DeploymentListResult] - :raises: ~azure.core.exceptions.HttpResponseError + ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.resource.resources.v2019_07_01.models.DeploymentExtended] + :raises ~azure.core.exceptions.HttpResponseError: """ - api_version = kwargs.pop('api_version', "2019-07-01") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2019-07-01")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[_models.DeploymentListResult] - cls = kwargs.pop('cls', None) # type: ClsType["_models.DeploymentListResult"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) + def prepare_request(next_link=None): if not next_link: - + request = build_deployments_list_at_subscription_scope_request( subscription_id=self._config.subscription_id, - api_version=api_version, filter=filter, top=top, - template_url=self.list_at_subscription_scope.metadata['url'], + api_version=api_version, + template_url=self.list_at_subscription_scope.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore else: - - request = build_deployments_list_at_subscription_scope_request( - subscription_id=self._config.subscription_id, - template_url=next_link, - ) + # make call to next link with the client's api-version + _parsed_next_link = urlparse(next_link) + _next_request_params = case_insensitive_dict(parse_qs(_parsed_next_link.query)) + _next_request_params["api-version"] = self._config.api_version + request = HttpRequest("GET", urljoin(next_link, _parsed_next_link.path), params=_next_request_params) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore request.method = "GET" return request @@ -2660,10 +3459,8 @@ async def extract_data(pipeline_response): async def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) response = pipeline_response.http_response @@ -2673,42 +3470,43 @@ async def get_next(next_link=None): return pipeline_response + return AsyncItemPaged(get_next, extract_data) - return AsyncItemPaged( - get_next, extract_data - ) - list_at_subscription_scope.metadata = {'url': "/subscriptions/{subscriptionId}/providers/Microsoft.Resources/deployments/"} # type: ignore + list_at_subscription_scope.metadata = {"url": "/subscriptions/{subscriptionId}/providers/Microsoft.Resources/deployments/"} # type: ignore async def _delete_initial( # pylint: disable=inconsistent-return-statements - self, - resource_group_name: str, - deployment_name: str, - **kwargs: Any + self, resource_group_name: str, deployment_name: str, **kwargs: Any ) -> None: - cls = kwargs.pop('cls', None) # type: ClsType[None] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + 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', "2019-07-01") # type: str + api_version = kwargs.pop("api_version", _params.pop("api-version", "2019-07-01")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[None] - - request = build_deployments_delete_request_initial( + request = build_deployments_delete_request( resource_group_name=resource_group_name, deployment_name=deployment_name, subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self._delete_initial.metadata['url'], + template_url=self._delete_initial.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [202, 204]: @@ -2718,16 +3516,10 @@ 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.Resources/deployments/{deploymentName}"} # type: ignore - + _delete_initial.metadata = {"url": "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/Microsoft.Resources/deployments/{deploymentName}"} # type: ignore @distributed_trace_async - async def begin_delete( # pylint: disable=inconsistent-return-statements - self, - resource_group_name: str, - deployment_name: str, - **kwargs: Any - ) -> AsyncLROPoller[None]: + async def begin_delete(self, resource_group_name: str, deployment_name: str, **kwargs: Any) -> AsyncLROPoller[None]: """Deletes a deployment from the deployment history. A template deployment that is currently running cannot be deleted. Deleting a template @@ -2740,9 +3532,9 @@ async def begin_delete( # pylint: disable=inconsistent-return-statements asynchronous request failed, the URI in the Location header returns an error-level status code. :param resource_group_name: The name of the resource group with the deployment to delete. The - name is case insensitive. + name is case insensitive. Required. :type resource_group_name: str - :param deployment_name: The name of the deployment. + :param deployment_name: The name of the deployment. Required. :type deployment_name: str :keyword callable cls: A custom type or function that will be passed the direct response :keyword str continuation_token: A continuation token to restart a poller from a saved state. @@ -2754,88 +3546,93 @@ async def begin_delete( # pylint: disable=inconsistent-return-statements Retry-After header is present. :return: An instance of AsyncLROPoller that returns either None or the result of cls(response) :rtype: ~azure.core.polling.AsyncLROPoller[None] - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - api_version = kwargs.pop('api_version', "2019-07-01") # type: str - polling = kwargs.pop('polling', True) # type: Union[bool, AsyncPollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType[None] - lro_delay = kwargs.pop( - 'polling_interval', - self._config.polling_interval - ) - cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2019-07-01")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[None] + polling = kwargs.pop("polling", True) # type: Union[bool, AsyncPollingMethod] + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token = kwargs.pop("continuation_token", None) # type: Optional[str] if cont_token is None: - raw_result = await self._delete_initial( + raw_result = await self._delete_initial( # type: ignore resource_group_name=resource_group_name, deployment_name=deployment_name, api_version=api_version, - cls=lambda x,y,z: x, + cls=lambda x, y, z: x, + headers=_headers, + params=_params, **kwargs ) - kwargs.pop('error_map', None) + kwargs.pop("error_map", None) - def get_long_running_output(pipeline_response): + def get_long_running_output(pipeline_response): # pylint: disable=inconsistent-return-statements if cls: return cls(pipeline_response, None, {}) - - if polling is True: polling_method = AsyncARMPolling(lro_delay, **kwargs) - elif polling is False: polling_method = AsyncNoPolling() - else: polling_method = polling + if polling is True: + polling_method = cast(AsyncPollingMethod, AsyncARMPolling(lro_delay, **kwargs)) # type: AsyncPollingMethod + elif polling is False: + polling_method = cast(AsyncPollingMethod, AsyncNoPolling()) + else: + polling_method = polling if cont_token: return AsyncLROPoller.from_continuation_token( polling_method=polling_method, continuation_token=cont_token, client=self._client, - deserialization_callback=get_long_running_output + deserialization_callback=get_long_running_output, ) return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) - begin_delete.metadata = {'url': "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/Microsoft.Resources/deployments/{deploymentName}"} # type: ignore + begin_delete.metadata = {"url": "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/Microsoft.Resources/deployments/{deploymentName}"} # type: ignore @distributed_trace_async - async def check_existence( - self, - resource_group_name: str, - deployment_name: str, - **kwargs: Any - ) -> bool: + async def check_existence(self, resource_group_name: str, deployment_name: str, **kwargs: Any) -> bool: """Checks whether the deployment exists. :param resource_group_name: The name of the resource group with the deployment to check. The - name is case insensitive. + name is case insensitive. Required. :type resource_group_name: str - :param deployment_name: The name of the deployment. + :param deployment_name: The name of the deployment. Required. :type deployment_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: bool, or the result of cls(response) + :return: bool or the result of cls(response) :rtype: bool - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType[None] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) - api_version = kwargs.pop('api_version', "2019-07-01") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2019-07-01")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[None] - request = build_deployments_check_existence_request( resource_group_name=resource_group_name, deployment_name=deployment_name, subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.check_existence.metadata['url'], + template_url=self.check_existence.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [204, 404]: @@ -2846,44 +3643,53 @@ async def check_existence( return cls(pipeline_response, None, {}) return 200 <= response.status_code <= 299 - check_existence.metadata = {'url': "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/Microsoft.Resources/deployments/{deploymentName}"} # type: ignore - + check_existence.metadata = {"url": "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/Microsoft.Resources/deployments/{deploymentName}"} # type: ignore async def _create_or_update_initial( - self, - resource_group_name: str, - deployment_name: str, - parameters: "_models.Deployment", - **kwargs: Any - ) -> "_models.DeploymentExtended": - cls = kwargs.pop('cls', None) # type: ClsType["_models.DeploymentExtended"] + self, resource_group_name: str, deployment_name: str, parameters: Union[_models.Deployment, IO], **kwargs: Any + ) -> _models.DeploymentExtended: error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', "2019-07-01") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + api_version = kwargs.pop("api_version", _params.pop("api-version", "2019-07-01")) # type: str + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.DeploymentExtended] - _json = self._serialize.body(parameters, 'Deployment') + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(parameters, (IO, bytes)): + _content = parameters + else: + _json = self._serialize.body(parameters, "Deployment") - request = build_deployments_create_or_update_request_initial( + request = build_deployments_create_or_update_request( resource_group_name=resource_group_name, deployment_name=deployment_name, subscription_id=self._config.subscription_id, api_version=api_version, content_type=content_type, json=_json, - template_url=self._create_or_update_initial.metadata['url'], + content=_content, + template_url=self._create_or_update_initial.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200, 201]: @@ -2891,38 +3697,42 @@ async def _create_or_update_initial( raise HttpResponseError(response=response, error_format=ARMErrorFormat) if response.status_code == 200: - deserialized = self._deserialize('DeploymentExtended', pipeline_response) + deserialized = self._deserialize("DeploymentExtended", pipeline_response) if response.status_code == 201: - deserialized = self._deserialize('DeploymentExtended', pipeline_response) + deserialized = self._deserialize("DeploymentExtended", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - _create_or_update_initial.metadata = {'url': "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/Microsoft.Resources/deployments/{deploymentName}"} # type: ignore - + _create_or_update_initial.metadata = {"url": "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/Microsoft.Resources/deployments/{deploymentName}"} # type: ignore - @distributed_trace_async + @overload async def begin_create_or_update( self, resource_group_name: str, deployment_name: str, - parameters: "_models.Deployment", + parameters: _models.Deployment, + *, + content_type: str = "application/json", **kwargs: Any - ) -> AsyncLROPoller["_models.DeploymentExtended"]: + ) -> AsyncLROPoller[_models.DeploymentExtended]: """Deploys resources to a resource group. You can provide the template and parameters directly in the request or link to JSON files. :param resource_group_name: The name of the resource group to deploy the resources to. The name - is case insensitive. The resource group must already exist. + is case insensitive. The resource group must already exist. Required. :type resource_group_name: str - :param deployment_name: The name of the deployment. + :param deployment_name: The name of the deployment. Required. :type deployment_name: str - :param parameters: Additional parameters supplied to the operation. + :param parameters: Additional parameters supplied to the operation. Required. :type parameters: ~azure.mgmt.resource.resources.v2019_07_01.models.Deployment + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str :keyword callable cls: A custom type or function that will be passed the direct response :keyword str continuation_token: A continuation token to restart a poller from a saved state. :keyword polling: By default, your polling method will be AsyncARMPolling. Pass in False for @@ -2935,115 +3745,189 @@ async def begin_create_or_update( cls(response) :rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.resource.resources.v2019_07_01.models.DeploymentExtended] - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - api_version = kwargs.pop('api_version', "2019-07-01") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] - polling = kwargs.pop('polling', True) # type: Union[bool, AsyncPollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType["_models.DeploymentExtended"] - lro_delay = kwargs.pop( - 'polling_interval', - self._config.polling_interval - ) - cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] - if cont_token is None: - raw_result = await self._create_or_update_initial( - resource_group_name=resource_group_name, - deployment_name=deployment_name, - parameters=parameters, - api_version=api_version, - content_type=content_type, - cls=lambda x,y,z: x, - **kwargs - ) - kwargs.pop('error_map', None) - - def get_long_running_output(pipeline_response): - response = pipeline_response.http_response - deserialized = self._deserialize('DeploymentExtended', pipeline_response) - if cls: - return cls(pipeline_response, deserialized, {}) - return deserialized - - - if polling is True: polling_method = AsyncARMPolling(lro_delay, **kwargs) - elif polling is False: polling_method = AsyncNoPolling() - else: polling_method = polling - if cont_token: - return AsyncLROPoller.from_continuation_token( - polling_method=polling_method, - continuation_token=cont_token, - client=self._client, - deserialization_callback=get_long_running_output - ) - return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) - - begin_create_or_update.metadata = {'url': "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/Microsoft.Resources/deployments/{deploymentName}"} # type: ignore - @distributed_trace_async - async def get( + @overload + async def begin_create_or_update( self, resource_group_name: str, deployment_name: str, + parameters: IO, + *, + content_type: str = "application/json", **kwargs: Any - ) -> "_models.DeploymentExtended": - """Gets a deployment. + ) -> AsyncLROPoller[_models.DeploymentExtended]: + """Deploys resources to a resource group. - :param resource_group_name: The name of the resource group. The name is case insensitive. + You can provide the template and parameters directly in the request or link to JSON files. + + :param resource_group_name: The name of the resource group to deploy the resources to. The name + is case insensitive. The resource group must already exist. Required. :type resource_group_name: str - :param deployment_name: The name of the deployment. + :param deployment_name: The name of the deployment. Required. :type deployment_name: str + :param parameters: Additional parameters supplied to the operation. Required. + :type parameters: IO + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: DeploymentExtended, or the result of cls(response) - :rtype: ~azure.mgmt.resource.resources.v2019_07_01.models.DeploymentExtended - :raises: ~azure.core.exceptions.HttpResponseError + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be AsyncARMPolling. Pass in False for + this operation to not poll, or pass in your own initialized polling object for a personal + polling strategy. + :paramtype polling: bool or ~azure.core.polling.AsyncPollingMethod + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of AsyncLROPoller that returns either DeploymentExtended or the result of + cls(response) + :rtype: + ~azure.core.polling.AsyncLROPoller[~azure.mgmt.resource.resources.v2019_07_01.models.DeploymentExtended] + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.DeploymentExtended"] - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {})) - - api_version = kwargs.pop('api_version', "2019-07-01") # type: str - + @distributed_trace_async + async def begin_create_or_update( + self, resource_group_name: str, deployment_name: str, parameters: Union[_models.Deployment, IO], **kwargs: Any + ) -> AsyncLROPoller[_models.DeploymentExtended]: + """Deploys resources to a resource group. + + You can provide the template and parameters directly in the request or link to JSON files. + + :param resource_group_name: The name of the resource group to deploy the resources to. The name + is case insensitive. The resource group must already exist. Required. + :type resource_group_name: str + :param deployment_name: The name of the deployment. Required. + :type deployment_name: str + :param parameters: Additional parameters supplied to the operation. Is either a model type or a + IO type. Required. + :type parameters: ~azure.mgmt.resource.resources.v2019_07_01.models.Deployment or IO + :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. + Default value is None. + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be AsyncARMPolling. Pass in False for + this operation to not poll, or pass in your own initialized polling object for a personal + polling strategy. + :paramtype polling: bool or ~azure.core.polling.AsyncPollingMethod + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of AsyncLROPoller that returns either DeploymentExtended or the result of + cls(response) + :rtype: + ~azure.core.polling.AsyncLROPoller[~azure.mgmt.resource.resources.v2019_07_01.models.DeploymentExtended] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _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", "2019-07-01")) # type: str + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.DeploymentExtended] + polling = kwargs.pop("polling", True) # type: Union[bool, AsyncPollingMethod] + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token = kwargs.pop("continuation_token", None) # type: Optional[str] + if cont_token is None: + raw_result = await self._create_or_update_initial( # type: ignore + resource_group_name=resource_group_name, + deployment_name=deployment_name, + parameters=parameters, + api_version=api_version, + content_type=content_type, + cls=lambda x, y, z: x, + headers=_headers, + params=_params, + **kwargs + ) + kwargs.pop("error_map", None) + + def get_long_running_output(pipeline_response): + deserialized = self._deserialize("DeploymentExtended", pipeline_response) + if cls: + return cls(pipeline_response, deserialized, {}) + return deserialized + + if polling is True: + polling_method = cast(AsyncPollingMethod, AsyncARMPolling(lro_delay, **kwargs)) # type: AsyncPollingMethod + elif polling is False: + polling_method = cast(AsyncPollingMethod, AsyncNoPolling()) + else: + polling_method = polling + if cont_token: + return AsyncLROPoller.from_continuation_token( + polling_method=polling_method, + continuation_token=cont_token, + client=self._client, + deserialization_callback=get_long_running_output, + ) + return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) + + begin_create_or_update.metadata = {"url": "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/Microsoft.Resources/deployments/{deploymentName}"} # type: ignore + + @distributed_trace_async + async def get(self, resource_group_name: str, deployment_name: str, **kwargs: Any) -> _models.DeploymentExtended: + """Gets a deployment. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param deployment_name: The name of the deployment. Required. + :type deployment_name: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: DeploymentExtended or the result of cls(response) + :rtype: ~azure.mgmt.resource.resources.v2019_07_01.models.DeploymentExtended + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2019-07-01")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[_models.DeploymentExtended] + request = build_deployments_get_request( resource_group_name=resource_group_name, deployment_name=deployment_name, subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.get.metadata['url'], + template_url=self.get.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) - deserialized = self._deserialize('DeploymentExtended', pipeline_response) + deserialized = self._deserialize("DeploymentExtended", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - get.metadata = {'url': "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/Microsoft.Resources/deployments/{deploymentName}"} # type: ignore - + get.metadata = {"url": "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/Microsoft.Resources/deployments/{deploymentName}"} # type: ignore @distributed_trace_async async def cancel( # pylint: disable=inconsistent-return-statements - self, - resource_group_name: str, - deployment_name: str, - **kwargs: Any + self, resource_group_name: str, deployment_name: str, **kwargs: Any ) -> None: """Cancels a currently running template deployment. @@ -3053,38 +3937,45 @@ async def cancel( # pylint: disable=inconsistent-return-statements partially deployed. :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. :type resource_group_name: str - :param deployment_name: The name of the deployment. + :param deployment_name: The name of the deployment. Required. :type deployment_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: None, or the result of cls(response) + :return: None or the result of cls(response) :rtype: None - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType[None] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) - api_version = kwargs.pop('api_version', "2019-07-01") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2019-07-01")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[None] - request = build_deployments_cancel_request( resource_group_name=resource_group_name, deployment_name=deployment_name, subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.cancel.metadata['url'], + template_url=self.cancel.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [204]: @@ -3094,42 +3985,110 @@ async def cancel( # pylint: disable=inconsistent-return-statements if cls: return cls(pipeline_response, None, {}) - cancel.metadata = {'url': "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/Microsoft.Resources/deployments/{deploymentName}/cancel"} # type: ignore + cancel.metadata = {"url": "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/Microsoft.Resources/deployments/{deploymentName}/cancel"} # type: ignore - - @distributed_trace_async + @overload async def validate( self, resource_group_name: str, deployment_name: str, - parameters: "_models.Deployment", + parameters: _models.Deployment, + *, + content_type: str = "application/json", **kwargs: Any - ) -> "_models.DeploymentValidateResult": + ) -> _models.DeploymentValidateResult: """Validates whether the specified template is syntactically correct and will be accepted by Azure Resource Manager.. :param resource_group_name: The name of the resource group the template will be deployed to. - The name is case insensitive. + The name is case insensitive. Required. :type resource_group_name: str - :param deployment_name: The name of the deployment. + :param deployment_name: The name of the deployment. Required. :type deployment_name: str - :param parameters: Parameters to validate. + :param parameters: Parameters to validate. Required. :type parameters: ~azure.mgmt.resource.resources.v2019_07_01.models.Deployment + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: DeploymentValidateResult or the result of cls(response) + :rtype: ~azure.mgmt.resource.resources.v2019_07_01.models.DeploymentValidateResult + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + async def validate( + self, + resource_group_name: str, + deployment_name: str, + parameters: IO, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.DeploymentValidateResult: + """Validates whether the specified template is syntactically correct and will be accepted by Azure + Resource Manager.. + + :param resource_group_name: The name of the resource group the template will be deployed to. + The name is case insensitive. Required. + :type resource_group_name: str + :param deployment_name: The name of the deployment. Required. + :type deployment_name: str + :param parameters: Parameters to validate. Required. + :type parameters: IO + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: DeploymentValidateResult or the result of cls(response) + :rtype: ~azure.mgmt.resource.resources.v2019_07_01.models.DeploymentValidateResult + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace_async + async def validate( + self, resource_group_name: str, deployment_name: str, parameters: Union[_models.Deployment, IO], **kwargs: Any + ) -> _models.DeploymentValidateResult: + """Validates whether the specified template is syntactically correct and will be accepted by Azure + Resource Manager.. + + :param resource_group_name: The name of the resource group the template will be deployed to. + The name is case insensitive. Required. + :type resource_group_name: str + :param deployment_name: The name of the deployment. Required. + :type deployment_name: str + :param parameters: Parameters to validate. Is either a model type or a IO type. Required. + :type parameters: ~azure.mgmt.resource.resources.v2019_07_01.models.Deployment or IO + :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. + Default value is None. + :paramtype content_type: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: DeploymentValidateResult, or the result of cls(response) + :return: DeploymentValidateResult or the result of cls(response) :rtype: ~azure.mgmt.resource.resources.v2019_07_01.models.DeploymentValidateResult - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.DeploymentValidateResult"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) - api_version = kwargs.pop('api_version', "2019-07-01") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - _json = self._serialize.body(parameters, 'Deployment') + api_version = kwargs.pop("api_version", _params.pop("api-version", "2019-07-01")) # type: str + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.DeploymentValidateResult] + + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(parameters, (IO, bytes)): + _content = parameters + else: + _json = self._serialize.body(parameters, "Deployment") request = build_deployments_validate_request( resource_group_name=resource_group_name, @@ -3138,16 +4097,18 @@ async def validate( api_version=api_version, content_type=content_type, json=_json, - template_url=self.validate.metadata['url'], + content=_content, + template_url=self.validate.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200, 400]: @@ -3155,54 +4116,67 @@ async def validate( raise HttpResponseError(response=response, error_format=ARMErrorFormat) if response.status_code == 200: - deserialized = self._deserialize('DeploymentValidateResult', pipeline_response) + deserialized = self._deserialize("DeploymentValidateResult", pipeline_response) if response.status_code == 400: - deserialized = self._deserialize('DeploymentValidateResult', pipeline_response) + deserialized = self._deserialize("DeploymentValidateResult", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - validate.metadata = {'url': "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/Microsoft.Resources/deployments/{deploymentName}/validate"} # type: ignore - + validate.metadata = {"url": "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/Microsoft.Resources/deployments/{deploymentName}/validate"} # type: ignore async def _what_if_initial( self, resource_group_name: str, deployment_name: str, - parameters: "_models.DeploymentWhatIf", + parameters: Union[_models.DeploymentWhatIf, IO], **kwargs: Any - ) -> Optional["_models.WhatIfOperationResult"]: - cls = kwargs.pop('cls', None) # type: ClsType[Optional["_models.WhatIfOperationResult"]] + ) -> Optional[_models.WhatIfOperationResult]: error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', "2019-07-01") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + api_version = kwargs.pop("api_version", _params.pop("api-version", "2019-07-01")) # type: str + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[Optional[_models.WhatIfOperationResult]] - _json = self._serialize.body(parameters, 'DeploymentWhatIf') + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(parameters, (IO, bytes)): + _content = parameters + else: + _json = self._serialize.body(parameters, "DeploymentWhatIf") - request = build_deployments_what_if_request_initial( + request = build_deployments_what_if_request( resource_group_name=resource_group_name, deployment_name=deployment_name, subscription_id=self._config.subscription_id, api_version=api_version, content_type=content_type, json=_json, - template_url=self._what_if_initial.metadata['url'], + content=_content, + template_url=self._what_if_initial.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200, 202]: @@ -3212,39 +4186,116 @@ async def _what_if_initial( deserialized = None response_headers = {} if response.status_code == 200: - deserialized = self._deserialize('WhatIfOperationResult', pipeline_response) + deserialized = self._deserialize("WhatIfOperationResult", pipeline_response) if response.status_code == 202: - response_headers['Location']=self._deserialize('str', response.headers.get('Location')) - response_headers['Retry-After']=self._deserialize('str', response.headers.get('Retry-After')) - + response_headers["Location"] = self._deserialize("str", response.headers.get("Location")) + response_headers["Retry-After"] = self._deserialize("str", response.headers.get("Retry-After")) if cls: return cls(pipeline_response, deserialized, response_headers) return deserialized - _what_if_initial.metadata = {'url': "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/Microsoft.Resources/deployments/{deploymentName}/whatIf"} # type: ignore + _what_if_initial.metadata = {"url": "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/Microsoft.Resources/deployments/{deploymentName}/whatIf"} # type: ignore + + @overload + async def begin_what_if( + self, + resource_group_name: str, + deployment_name: str, + parameters: _models.DeploymentWhatIf, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> AsyncLROPoller[_models.WhatIfOperationResult]: + """Returns changes that will be made by the deployment if executed at the scope of the resource + group. + + :param resource_group_name: The name of the resource group the template will be deployed to. + The name is case insensitive. Required. + :type resource_group_name: str + :param deployment_name: The name of the deployment. Required. + :type deployment_name: str + :param parameters: Parameters to validate. Required. + :type parameters: ~azure.mgmt.resource.resources.v2019_07_01.models.DeploymentWhatIf + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be AsyncARMPolling. Pass in False for + this operation to not poll, or pass in your own initialized polling object for a personal + polling strategy. + :paramtype polling: bool or ~azure.core.polling.AsyncPollingMethod + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of AsyncLROPoller that returns either WhatIfOperationResult or the result + of cls(response) + :rtype: + ~azure.core.polling.AsyncLROPoller[~azure.mgmt.resource.resources.v2019_07_01.models.WhatIfOperationResult] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + async def begin_what_if( + self, + resource_group_name: str, + deployment_name: str, + parameters: IO, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> AsyncLROPoller[_models.WhatIfOperationResult]: + """Returns changes that will be made by the deployment if executed at the scope of the resource + group. + :param resource_group_name: The name of the resource group the template will be deployed to. + The name is case insensitive. Required. + :type resource_group_name: str + :param deployment_name: The name of the deployment. Required. + :type deployment_name: str + :param parameters: Parameters to validate. Required. + :type parameters: IO + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be AsyncARMPolling. Pass in False for + this operation to not poll, or pass in your own initialized polling object for a personal + polling strategy. + :paramtype polling: bool or ~azure.core.polling.AsyncPollingMethod + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of AsyncLROPoller that returns either WhatIfOperationResult or the result + of cls(response) + :rtype: + ~azure.core.polling.AsyncLROPoller[~azure.mgmt.resource.resources.v2019_07_01.models.WhatIfOperationResult] + :raises ~azure.core.exceptions.HttpResponseError: + """ @distributed_trace_async async def begin_what_if( self, resource_group_name: str, deployment_name: str, - parameters: "_models.DeploymentWhatIf", + parameters: Union[_models.DeploymentWhatIf, IO], **kwargs: Any - ) -> AsyncLROPoller["_models.WhatIfOperationResult"]: + ) -> AsyncLROPoller[_models.WhatIfOperationResult]: """Returns changes that will be made by the deployment if executed at the scope of the resource group. :param resource_group_name: The name of the resource group the template will be deployed to. - The name is case insensitive. + The name is case insensitive. Required. :type resource_group_name: str - :param deployment_name: The name of the deployment. + :param deployment_name: The name of the deployment. Required. :type deployment_name: str - :param parameters: Parameters to validate. - :type parameters: ~azure.mgmt.resource.resources.v2019_07_01.models.DeploymentWhatIf + :param parameters: Parameters to validate. Is either a model type or a IO type. Required. + :type parameters: ~azure.mgmt.resource.resources.v2019_07_01.models.DeploymentWhatIf or IO + :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. + Default value is None. + :paramtype content_type: str :keyword callable cls: A custom type or function that will be passed the direct response :keyword str continuation_token: A continuation token to restart a poller from a saved state. :keyword polling: By default, your polling method will be AsyncARMPolling. Pass in False for @@ -3257,121 +4308,125 @@ async def begin_what_if( of cls(response) :rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.resource.resources.v2019_07_01.models.WhatIfOperationResult] - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - api_version = kwargs.pop('api_version', "2019-07-01") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] - polling = kwargs.pop('polling', True) # type: Union[bool, AsyncPollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType["_models.WhatIfOperationResult"] - lro_delay = kwargs.pop( - 'polling_interval', - self._config.polling_interval - ) - cont_token = kwargs.pop('continuation_token', None) # type: Optional[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", "2019-07-01")) # type: str + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.WhatIfOperationResult] + polling = kwargs.pop("polling", True) # type: Union[bool, AsyncPollingMethod] + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token = kwargs.pop("continuation_token", None) # type: Optional[str] if cont_token is None: - raw_result = await self._what_if_initial( + raw_result = await self._what_if_initial( # type: ignore resource_group_name=resource_group_name, deployment_name=deployment_name, parameters=parameters, api_version=api_version, content_type=content_type, - cls=lambda x,y,z: x, + cls=lambda x, y, z: x, + headers=_headers, + params=_params, **kwargs ) - kwargs.pop('error_map', None) + kwargs.pop("error_map", None) def get_long_running_output(pipeline_response): - response = pipeline_response.http_response - deserialized = self._deserialize('WhatIfOperationResult', pipeline_response) + deserialized = self._deserialize("WhatIfOperationResult", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - - if polling is True: polling_method = AsyncARMPolling(lro_delay, lro_options={'final-state-via': 'location'}, **kwargs) - elif polling is False: polling_method = AsyncNoPolling() - else: polling_method = polling + if polling is True: + polling_method = cast( + AsyncPollingMethod, AsyncARMPolling(lro_delay, lro_options={"final-state-via": "location"}, **kwargs) + ) # type: AsyncPollingMethod + elif polling is False: + polling_method = cast(AsyncPollingMethod, AsyncNoPolling()) + else: + polling_method = polling if cont_token: return AsyncLROPoller.from_continuation_token( polling_method=polling_method, continuation_token=cont_token, client=self._client, - deserialization_callback=get_long_running_output + deserialization_callback=get_long_running_output, ) return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) - begin_what_if.metadata = {'url': "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/Microsoft.Resources/deployments/{deploymentName}/whatIf"} # type: ignore + begin_what_if.metadata = {"url": "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/Microsoft.Resources/deployments/{deploymentName}/whatIf"} # type: ignore @distributed_trace_async async def export_template( - self, - resource_group_name: str, - deployment_name: str, - **kwargs: Any - ) -> "_models.DeploymentExportResult": + self, resource_group_name: str, deployment_name: str, **kwargs: Any + ) -> _models.DeploymentExportResult: """Exports the template used for specified deployment. :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. :type resource_group_name: str - :param deployment_name: The name of the deployment. + :param deployment_name: The name of the deployment. Required. :type deployment_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: DeploymentExportResult, or the result of cls(response) + :return: DeploymentExportResult or the result of cls(response) :rtype: ~azure.mgmt.resource.resources.v2019_07_01.models.DeploymentExportResult - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.DeploymentExportResult"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) - api_version = kwargs.pop('api_version', "2019-07-01") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2019-07-01")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[_models.DeploymentExportResult] - request = build_deployments_export_template_request( resource_group_name=resource_group_name, deployment_name=deployment_name, subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.export_template.metadata['url'], + template_url=self.export_template.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) - deserialized = self._deserialize('DeploymentExportResult', pipeline_response) + deserialized = self._deserialize("DeploymentExportResult", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - export_template.metadata = {'url': "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/Microsoft.Resources/deployments/{deploymentName}/exportTemplate"} # type: ignore - + export_template.metadata = {"url": "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/Microsoft.Resources/deployments/{deploymentName}/exportTemplate"} # type: ignore @distributed_trace def list_by_resource_group( - self, - resource_group_name: str, - filter: Optional[str] = None, - top: Optional[int] = None, - **kwargs: Any - ) -> AsyncIterable["_models.DeploymentListResult"]: + self, resource_group_name: str, filter: Optional[str] = None, top: Optional[int] = None, **kwargs: Any + ) -> AsyncIterable["_models.DeploymentExtended"]: """Get all the deployments for a resource group. :param resource_group_name: The name of the resource group with the deployments to get. The - name is case insensitive. + name is case insensitive. Required. :type resource_group_name: str :param filter: The filter to apply on the operation. For example, you can use $filter=provisioningState eq '{state}'. Default value is None. @@ -3380,42 +4435,49 @@ def list_by_resource_group( value is None. :type top: int :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either DeploymentListResult or the result of - cls(response) + :return: An iterator like instance of either DeploymentExtended or the result of cls(response) :rtype: - ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.resource.resources.v2019_07_01.models.DeploymentListResult] - :raises: ~azure.core.exceptions.HttpResponseError + ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.resource.resources.v2019_07_01.models.DeploymentExtended] + :raises ~azure.core.exceptions.HttpResponseError: """ - api_version = kwargs.pop('api_version', "2019-07-01") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2019-07-01")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[_models.DeploymentListResult] - cls = kwargs.pop('cls', None) # type: ClsType["_models.DeploymentListResult"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) + def prepare_request(next_link=None): if not next_link: - + request = build_deployments_list_by_resource_group_request( resource_group_name=resource_group_name, subscription_id=self._config.subscription_id, - api_version=api_version, filter=filter, top=top, - template_url=self.list_by_resource_group.metadata['url'], + 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.url = self._client.format_url(request.url) # type: ignore else: - - request = build_deployments_list_by_resource_group_request( - resource_group_name=resource_group_name, - subscription_id=self._config.subscription_id, - template_url=next_link, - ) + # make call to next link with the client's api-version + _parsed_next_link = urlparse(next_link) + _next_request_params = case_insensitive_dict(parse_qs(_parsed_next_link.query)) + _next_request_params["api-version"] = self._config.api_version + request = HttpRequest("GET", urljoin(next_link, _parsed_next_link.path), params=_next_request_params) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore request.method = "GET" return request @@ -3429,10 +4491,8 @@ async def extract_data(pipeline_response): async def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) response = pipeline_response.http_response @@ -3442,204 +4502,204 @@ async def get_next(next_link=None): return pipeline_response + return AsyncItemPaged(get_next, extract_data) - return AsyncItemPaged( - get_next, extract_data - ) - list_by_resource_group.metadata = {'url': "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/Microsoft.Resources/deployments/"} # type: ignore + list_by_resource_group.metadata = {"url": "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/Microsoft.Resources/deployments/"} # type: ignore @distributed_trace_async - async def calculate_template_hash( - self, - template: Any, - **kwargs: Any - ) -> "_models.TemplateHashResult": + async def calculate_template_hash(self, template: JSON, **kwargs: Any) -> _models.TemplateHashResult: """Calculate the hash of the given template. - :param template: The template provided to calculate hash. - :type template: any + :param template: The template provided to calculate hash. Required. + :type template: JSON :keyword callable cls: A custom type or function that will be passed the direct response - :return: TemplateHashResult, or the result of cls(response) + :return: TemplateHashResult or the result of cls(response) :rtype: ~azure.mgmt.resource.resources.v2019_07_01.models.TemplateHashResult - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.TemplateHashResult"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) - api_version = kwargs.pop('api_version', "2019-07-01") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - _json = self._serialize.body(template, 'object') + api_version = kwargs.pop("api_version", _params.pop("api-version", "2019-07-01")) # type: str + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", "application/json")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[_models.TemplateHashResult] + + _json = self._serialize.body(template, "object") request = build_deployments_calculate_template_hash_request( api_version=api_version, content_type=content_type, json=_json, - template_url=self.calculate_template_hash.metadata['url'], + template_url=self.calculate_template_hash.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) - deserialized = self._deserialize('TemplateHashResult', pipeline_response) + deserialized = self._deserialize("TemplateHashResult", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - calculate_template_hash.metadata = {'url': "/providers/Microsoft.Resources/calculateTemplateHash"} # type: ignore + calculate_template_hash.metadata = {"url": "/providers/Microsoft.Resources/calculateTemplateHash"} # type: ignore -class ProvidersOperations: - """ProvidersOperations async operations. - You should not instantiate this class directly. Instead, you should create a Client instance that - instantiates it for you and attaches it as an attribute. +class ProvidersOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. - :ivar models: Alias to model classes used in this operation group. - :type models: ~azure.mgmt.resource.resources.v2019_07_01.models - :param client: Client for service requests. - :param config: Configuration of service client. - :param serializer: An object model serializer. - :param deserializer: An object model deserializer. + Instead, you should access the following operations through + :class:`~azure.mgmt.resource.resources.v2019_07_01.aio.ResourceManagementClient`'s + :attr:`providers` attribute. """ models = _models - def __init__(self, client, config, serializer, deserializer) -> None: - self._client = client - self._serialize = serializer - self._deserialize = deserializer - self._config = config + def __init__(self, *args, **kwargs) -> None: + input_args = list(args) + self._client = input_args.pop(0) if input_args else kwargs.pop("client") + self._config = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") @distributed_trace_async - async def unregister( - self, - resource_provider_namespace: str, - **kwargs: Any - ) -> "_models.Provider": + async def unregister(self, resource_provider_namespace: str, **kwargs: Any) -> _models.Provider: """Unregisters a subscription from a resource provider. :param resource_provider_namespace: The namespace of the resource provider to unregister. + Required. :type resource_provider_namespace: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: Provider, or the result of cls(response) + :return: Provider or the result of cls(response) :rtype: ~azure.mgmt.resource.resources.v2019_07_01.models.Provider - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.Provider"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) - api_version = kwargs.pop('api_version', "2019-07-01") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2019-07-01")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[_models.Provider] - request = build_providers_unregister_request( resource_provider_namespace=resource_provider_namespace, subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.unregister.metadata['url'], + template_url=self.unregister.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) - deserialized = self._deserialize('Provider', pipeline_response) + deserialized = self._deserialize("Provider", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - unregister.metadata = {'url': "/subscriptions/{subscriptionId}/providers/{resourceProviderNamespace}/unregister"} # type: ignore - + unregister.metadata = {"url": "/subscriptions/{subscriptionId}/providers/{resourceProviderNamespace}/unregister"} # type: ignore @distributed_trace_async - async def register( - self, - resource_provider_namespace: str, - **kwargs: Any - ) -> "_models.Provider": + async def register(self, resource_provider_namespace: str, **kwargs: Any) -> _models.Provider: """Registers a subscription with a resource provider. :param resource_provider_namespace: The namespace of the resource provider to register. + Required. :type resource_provider_namespace: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: Provider, or the result of cls(response) + :return: Provider or the result of cls(response) :rtype: ~azure.mgmt.resource.resources.v2019_07_01.models.Provider - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.Provider"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) - api_version = kwargs.pop('api_version', "2019-07-01") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2019-07-01")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[_models.Provider] - request = build_providers_register_request( resource_provider_namespace=resource_provider_namespace, subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.register.metadata['url'], + template_url=self.register.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) - deserialized = self._deserialize('Provider', pipeline_response) + deserialized = self._deserialize("Provider", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - register.metadata = {'url': "/subscriptions/{subscriptionId}/providers/{resourceProviderNamespace}/register"} # type: ignore - + register.metadata = {"url": "/subscriptions/{subscriptionId}/providers/{resourceProviderNamespace}/register"} # type: ignore @distributed_trace def list( - self, - top: Optional[int] = None, - expand: Optional[str] = None, - **kwargs: Any - ) -> AsyncIterable["_models.ProviderListResult"]: + self, top: Optional[int] = None, expand: Optional[str] = None, **kwargs: Any + ) -> AsyncIterable["_models.Provider"]: """Gets all resource providers for a subscription. :param top: The number of results to return. If null is passed returns all deployments. Default @@ -3650,39 +4710,48 @@ def list( response, use $expand=resourceTypes/aliases. Default value is None. :type expand: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either ProviderListResult or the result of cls(response) + :return: An iterator like instance of either Provider or the result of cls(response) :rtype: - ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.resource.resources.v2019_07_01.models.ProviderListResult] - :raises: ~azure.core.exceptions.HttpResponseError + ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.resource.resources.v2019_07_01.models.Provider] + :raises ~azure.core.exceptions.HttpResponseError: """ - api_version = kwargs.pop('api_version', "2019-07-01") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2019-07-01")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[_models.ProviderListResult] - cls = kwargs.pop('cls', None) # type: ClsType["_models.ProviderListResult"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) + def prepare_request(next_link=None): if not next_link: - + request = build_providers_list_request( subscription_id=self._config.subscription_id, - api_version=api_version, top=top, expand=expand, - template_url=self.list.metadata['url'], + 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.url = self._client.format_url(request.url) # type: ignore else: - - request = build_providers_list_request( - subscription_id=self._config.subscription_id, - template_url=next_link, - ) + # make call to next link with the client's api-version + _parsed_next_link = urlparse(next_link) + _next_request_params = case_insensitive_dict(parse_qs(_parsed_next_link.query)) + _next_request_params["api-version"] = self._config.api_version + request = HttpRequest("GET", urljoin(next_link, _parsed_next_link.path), params=_next_request_params) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore request.method = "GET" return request @@ -3696,10 +4765,8 @@ async def extract_data(pipeline_response): async def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) response = pipeline_response.http_response @@ -3709,19 +4776,14 @@ async def get_next(next_link=None): return pipeline_response + return AsyncItemPaged(get_next, extract_data) - return AsyncItemPaged( - get_next, extract_data - ) - list.metadata = {'url': "/subscriptions/{subscriptionId}/providers"} # type: ignore + list.metadata = {"url": "/subscriptions/{subscriptionId}/providers"} # type: ignore @distributed_trace def list_at_tenant_scope( - self, - top: Optional[int] = None, - expand: Optional[str] = None, - **kwargs: Any - ) -> AsyncIterable["_models.ProviderListResult"]: + self, top: Optional[int] = None, expand: Optional[str] = None, **kwargs: Any + ) -> AsyncIterable["_models.Provider"]: """Gets all resource providers for the tenant. :param top: The number of results to return. If null is passed returns all providers. Default @@ -3732,37 +4794,47 @@ def list_at_tenant_scope( response, use $expand=resourceTypes/aliases. Default value is None. :type expand: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either ProviderListResult or the result of cls(response) + :return: An iterator like instance of either Provider or the result of cls(response) :rtype: - ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.resource.resources.v2019_07_01.models.ProviderListResult] - :raises: ~azure.core.exceptions.HttpResponseError + ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.resource.resources.v2019_07_01.models.Provider] + :raises ~azure.core.exceptions.HttpResponseError: """ - api_version = kwargs.pop('api_version', "2019-07-01") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2019-07-01")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[_models.ProviderListResult] - cls = kwargs.pop('cls', None) # type: ClsType["_models.ProviderListResult"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) + def prepare_request(next_link=None): if not next_link: - + request = build_providers_list_at_tenant_scope_request( - api_version=api_version, top=top, expand=expand, - template_url=self.list_at_tenant_scope.metadata['url'], + api_version=api_version, + template_url=self.list_at_tenant_scope.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore else: - - request = build_providers_list_at_tenant_scope_request( - template_url=next_link, - ) + # make call to next link with the client's api-version + _parsed_next_link = urlparse(next_link) + _next_request_params = case_insensitive_dict(parse_qs(_parsed_next_link.query)) + _next_request_params["api-version"] = self._config.api_version + request = HttpRequest("GET", urljoin(next_link, _parsed_next_link.path), params=_next_request_params) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore request.method = "GET" return request @@ -3776,10 +4848,8 @@ async def extract_data(pipeline_response): async def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) response = pipeline_response.http_response @@ -3789,149 +4859,150 @@ async def get_next(next_link=None): return pipeline_response + return AsyncItemPaged(get_next, extract_data) - return AsyncItemPaged( - get_next, extract_data - ) - list_at_tenant_scope.metadata = {'url': "/providers"} # type: ignore + list_at_tenant_scope.metadata = {"url": "/providers"} # type: ignore @distributed_trace_async async def get( - self, - resource_provider_namespace: str, - expand: Optional[str] = None, - **kwargs: Any - ) -> "_models.Provider": + self, resource_provider_namespace: str, expand: Optional[str] = None, **kwargs: Any + ) -> _models.Provider: """Gets the specified resource provider. - :param resource_provider_namespace: The namespace of the resource provider. + :param resource_provider_namespace: The namespace of the resource provider. Required. :type resource_provider_namespace: str :param expand: The $expand query parameter. For example, to include property aliases in response, use $expand=resourceTypes/aliases. Default value is None. :type expand: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: Provider, or the result of cls(response) + :return: Provider or the result of cls(response) :rtype: ~azure.mgmt.resource.resources.v2019_07_01.models.Provider - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.Provider"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) - api_version = kwargs.pop('api_version', "2019-07-01") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2019-07-01")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[_models.Provider] - request = build_providers_get_request( resource_provider_namespace=resource_provider_namespace, subscription_id=self._config.subscription_id, - api_version=api_version, expand=expand, - template_url=self.get.metadata['url'], + api_version=api_version, + template_url=self.get.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) - deserialized = self._deserialize('Provider', pipeline_response) + deserialized = self._deserialize("Provider", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - get.metadata = {'url': "/subscriptions/{subscriptionId}/providers/{resourceProviderNamespace}"} # type: ignore - + get.metadata = {"url": "/subscriptions/{subscriptionId}/providers/{resourceProviderNamespace}"} # type: ignore @distributed_trace_async async def get_at_tenant_scope( - self, - resource_provider_namespace: str, - expand: Optional[str] = None, - **kwargs: Any - ) -> "_models.Provider": + self, resource_provider_namespace: str, expand: Optional[str] = None, **kwargs: Any + ) -> _models.Provider: """Gets the specified resource provider at the tenant level. - :param resource_provider_namespace: The namespace of the resource provider. + :param resource_provider_namespace: The namespace of the resource provider. Required. :type resource_provider_namespace: str :param expand: The $expand query parameter. For example, to include property aliases in response, use $expand=resourceTypes/aliases. Default value is None. :type expand: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: Provider, or the result of cls(response) + :return: Provider or the result of cls(response) :rtype: ~azure.mgmt.resource.resources.v2019_07_01.models.Provider - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.Provider"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + 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', "2019-07-01") # type: str + api_version = kwargs.pop("api_version", _params.pop("api-version", "2019-07-01")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[_models.Provider] - request = build_providers_get_at_tenant_scope_request( resource_provider_namespace=resource_provider_namespace, - api_version=api_version, expand=expand, - template_url=self.get_at_tenant_scope.metadata['url'], + api_version=api_version, + template_url=self.get_at_tenant_scope.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) - deserialized = self._deserialize('Provider', pipeline_response) + deserialized = self._deserialize("Provider", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - get_at_tenant_scope.metadata = {'url': "/providers/{resourceProviderNamespace}"} # type: ignore + get_at_tenant_scope.metadata = {"url": "/providers/{resourceProviderNamespace}"} # type: ignore -class ResourcesOperations: # pylint: disable=too-many-public-methods - """ResourcesOperations async operations. - You should not instantiate this class directly. Instead, you should create a Client instance that - instantiates it for you and attaches it as an attribute. +class ResourcesOperations: # pylint: disable=too-many-public-methods + """ + .. warning:: + **DO NOT** instantiate this class directly. - :ivar models: Alias to model classes used in this operation group. - :type models: ~azure.mgmt.resource.resources.v2019_07_01.models - :param client: Client for service requests. - :param config: Configuration of service client. - :param serializer: An object model serializer. - :param deserializer: An object model deserializer. + Instead, you should access the following operations through + :class:`~azure.mgmt.resource.resources.v2019_07_01.aio.ResourceManagementClient`'s + :attr:`resources` attribute. """ models = _models - def __init__(self, client, config, serializer, deserializer) -> None: - self._client = client - self._serialize = serializer - self._deserialize = deserializer - self._config = config + def __init__(self, *args, **kwargs) -> None: + input_args = list(args) + self._client = input_args.pop(0) if input_args else kwargs.pop("client") + self._config = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") @distributed_trace def list_by_resource_group( @@ -3941,10 +5012,10 @@ def list_by_resource_group( expand: Optional[str] = None, top: Optional[int] = None, **kwargs: Any - ) -> AsyncIterable["_models.ResourceListResult"]: + ) -> AsyncIterable["_models.GenericResourceExpanded"]: """Get all the resources for a resource group. - :param resource_group_name: The resource group with the resources to get. + :param resource_group_name: The resource group with the resources to get. Required. :type resource_group_name: str :param filter: The filter to apply on the operation.:code:`
`:code:`
`The properties you can use for eq (equals) or ne (not equals) are: location, resourceType, name, resourceGroup, @@ -3969,42 +5040,51 @@ def list_by_resource_group( value is None. :type top: int :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either ResourceListResult or the result of cls(response) + :return: An iterator like instance of either GenericResourceExpanded or the result of + cls(response) :rtype: - ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.resource.resources.v2019_07_01.models.ResourceListResult] - :raises: ~azure.core.exceptions.HttpResponseError + ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.resource.resources.v2019_07_01.models.GenericResourceExpanded] + :raises ~azure.core.exceptions.HttpResponseError: """ - api_version = kwargs.pop('api_version', "2019-07-01") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2019-07-01")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[_models.ResourceListResult] - cls = kwargs.pop('cls', None) # type: ClsType["_models.ResourceListResult"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) + def prepare_request(next_link=None): if not next_link: - + request = build_resources_list_by_resource_group_request( resource_group_name=resource_group_name, subscription_id=self._config.subscription_id, - api_version=api_version, filter=filter, expand=expand, top=top, - template_url=self.list_by_resource_group.metadata['url'], + 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.url = self._client.format_url(request.url) # type: ignore else: - - request = build_resources_list_by_resource_group_request( - resource_group_name=resource_group_name, - subscription_id=self._config.subscription_id, - template_url=next_link, - ) + # make call to next link with the client's api-version + _parsed_next_link = urlparse(next_link) + _next_request_params = case_insensitive_dict(parse_qs(_parsed_next_link.query)) + _next_request_params["api-version"] = self._config.api_version + request = HttpRequest("GET", urljoin(next_link, _parsed_next_link.path), params=_next_request_params) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore request.method = "GET" return request @@ -4018,10 +5098,8 @@ async def extract_data(pipeline_response): async def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) response = pipeline_response.http_response @@ -4031,45 +5109,54 @@ async def get_next(next_link=None): return pipeline_response + return AsyncItemPaged(get_next, extract_data) - return AsyncItemPaged( - get_next, extract_data - ) - list_by_resource_group.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/resources"} # type: ignore + list_by_resource_group.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/resources"} # type: ignore async def _move_resources_initial( # pylint: disable=inconsistent-return-statements - self, - source_resource_group_name: str, - parameters: "_models.ResourcesMoveInfo", - **kwargs: Any + self, source_resource_group_name: str, parameters: Union[_models.ResourcesMoveInfo, IO], **kwargs: Any ) -> None: - cls = kwargs.pop('cls', None) # type: ClsType[None] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', "2019-07-01") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + api_version = kwargs.pop("api_version", _params.pop("api-version", "2019-07-01")) # type: str + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[None] - _json = self._serialize.body(parameters, 'ResourcesMoveInfo') + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(parameters, (IO, bytes)): + _content = parameters + else: + _json = self._serialize.body(parameters, "ResourcesMoveInfo") - request = build_resources_move_resources_request_initial( + request = build_resources_move_resources_request( source_resource_group_name=source_resource_group_name, subscription_id=self._config.subscription_id, api_version=api_version, content_type=content_type, json=_json, - template_url=self._move_resources_initial.metadata['url'], + content=_content, + template_url=self._move_resources_initial.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [202, 204]: @@ -4079,14 +5166,15 @@ async def _move_resources_initial( # pylint: disable=inconsistent-return-statem if cls: return cls(pipeline_response, None, {}) - _move_resources_initial.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{sourceResourceGroupName}/moveResources"} # type: ignore - + _move_resources_initial.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{sourceResourceGroupName}/moveResources"} # type: ignore - @distributed_trace_async - async def begin_move_resources( # pylint: disable=inconsistent-return-statements + @overload + async def begin_move_resources( self, source_resource_group_name: str, - parameters: "_models.ResourcesMoveInfo", + parameters: _models.ResourcesMoveInfo, + *, + content_type: str = "application/json", **kwargs: Any ) -> AsyncLROPoller[None]: """Moves resources from one resource group to another resource group. @@ -4097,10 +5185,13 @@ async def begin_move_resources( # pylint: disable=inconsistent-return-statement the groups until the move completes. :param source_resource_group_name: The name of the resource group containing the resources to - move. + move. Required. :type source_resource_group_name: str - :param parameters: Parameters for moving resources. + :param parameters: Parameters for moving resources. Required. :type parameters: ~azure.mgmt.resource.resources.v2019_07_01.models.ResourcesMoveInfo + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str :keyword callable cls: A custom type or function that will be passed the direct response :keyword str continuation_token: A continuation token to restart a poller from a saved state. :keyword polling: By default, your polling method will be AsyncARMPolling. Pass in False for @@ -4111,80 +5202,160 @@ async def begin_move_resources( # pylint: disable=inconsistent-return-statement Retry-After header is present. :return: An instance of AsyncLROPoller that returns either None or the result of cls(response) :rtype: ~azure.core.polling.AsyncLROPoller[None] - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - api_version = kwargs.pop('api_version', "2019-07-01") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] - polling = kwargs.pop('polling', True) # type: Union[bool, AsyncPollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType[None] - lro_delay = kwargs.pop( - 'polling_interval', - self._config.polling_interval - ) - cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] + + @overload + async def begin_move_resources( + self, source_resource_group_name: str, parameters: IO, *, content_type: str = "application/json", **kwargs: Any + ) -> AsyncLROPoller[None]: + """Moves resources from one resource group to another resource group. + + The resources to move must be in the same source resource group. The target resource group may + be in a different subscription. When moving resources, both the source group and the target + group are locked for the duration of the operation. Write and delete operations are blocked on + the groups until the move completes. + + :param source_resource_group_name: The name of the resource group containing the resources to + move. Required. + :type source_resource_group_name: str + :param parameters: Parameters for moving resources. Required. + :type parameters: IO + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be AsyncARMPolling. Pass in False for + this operation to not poll, or pass in your own initialized polling object for a personal + polling strategy. + :paramtype polling: bool or ~azure.core.polling.AsyncPollingMethod + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of AsyncLROPoller that returns either None or the result of cls(response) + :rtype: ~azure.core.polling.AsyncLROPoller[None] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace_async + async def begin_move_resources( + self, source_resource_group_name: str, parameters: Union[_models.ResourcesMoveInfo, IO], **kwargs: Any + ) -> AsyncLROPoller[None]: + """Moves resources from one resource group to another resource group. + + The resources to move must be in the same source resource group. The target resource group may + be in a different subscription. When moving resources, both the source group and the target + group are locked for the duration of the operation. Write and delete operations are blocked on + the groups until the move completes. + + :param source_resource_group_name: The name of the resource group containing the resources to + move. Required. + :type source_resource_group_name: str + :param parameters: Parameters for moving resources. Is either a model type or a IO type. + Required. + :type parameters: ~azure.mgmt.resource.resources.v2019_07_01.models.ResourcesMoveInfo or IO + :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. + Default value is None. + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be AsyncARMPolling. Pass in False for + this operation to not poll, or pass in your own initialized polling object for a personal + polling strategy. + :paramtype polling: bool or ~azure.core.polling.AsyncPollingMethod + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of AsyncLROPoller that returns either None or the result of cls(response) + :rtype: ~azure.core.polling.AsyncLROPoller[None] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _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", "2019-07-01")) # type: str + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[None] + polling = kwargs.pop("polling", True) # type: Union[bool, AsyncPollingMethod] + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token = kwargs.pop("continuation_token", None) # type: Optional[str] if cont_token is None: - raw_result = await self._move_resources_initial( + raw_result = await self._move_resources_initial( # type: ignore source_resource_group_name=source_resource_group_name, parameters=parameters, api_version=api_version, content_type=content_type, - cls=lambda x,y,z: x, + cls=lambda x, y, z: x, + headers=_headers, + params=_params, **kwargs ) - kwargs.pop('error_map', None) + kwargs.pop("error_map", None) - def get_long_running_output(pipeline_response): + def get_long_running_output(pipeline_response): # pylint: disable=inconsistent-return-statements if cls: return cls(pipeline_response, None, {}) - - if polling is True: polling_method = AsyncARMPolling(lro_delay, **kwargs) - elif polling is False: polling_method = AsyncNoPolling() - else: polling_method = polling + if polling is True: + polling_method = cast(AsyncPollingMethod, AsyncARMPolling(lro_delay, **kwargs)) # type: AsyncPollingMethod + elif polling is False: + polling_method = cast(AsyncPollingMethod, AsyncNoPolling()) + else: + polling_method = polling if cont_token: return AsyncLROPoller.from_continuation_token( polling_method=polling_method, continuation_token=cont_token, client=self._client, - deserialization_callback=get_long_running_output + deserialization_callback=get_long_running_output, ) return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) - begin_move_resources.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{sourceResourceGroupName}/moveResources"} # type: ignore + begin_move_resources.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{sourceResourceGroupName}/moveResources"} # type: ignore async def _validate_move_resources_initial( # pylint: disable=inconsistent-return-statements - self, - source_resource_group_name: str, - parameters: "_models.ResourcesMoveInfo", - **kwargs: Any + self, source_resource_group_name: str, parameters: Union[_models.ResourcesMoveInfo, IO], **kwargs: Any ) -> None: - cls = kwargs.pop('cls', None) # type: ClsType[None] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) - api_version = kwargs.pop('api_version', "2019-07-01") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - _json = self._serialize.body(parameters, 'ResourcesMoveInfo') + api_version = kwargs.pop("api_version", _params.pop("api-version", "2019-07-01")) # type: str + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[None] - request = build_resources_validate_move_resources_request_initial( + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(parameters, (IO, bytes)): + _content = parameters + else: + _json = self._serialize.body(parameters, "ResourcesMoveInfo") + + request = build_resources_validate_move_resources_request( source_resource_group_name=source_resource_group_name, subscription_id=self._config.subscription_id, api_version=api_version, content_type=content_type, json=_json, - template_url=self._validate_move_resources_initial.metadata['url'], + content=_content, + template_url=self._validate_move_resources_initial.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [202, 204]: @@ -4194,14 +5365,15 @@ async def _validate_move_resources_initial( # pylint: disable=inconsistent-retu if cls: return cls(pipeline_response, None, {}) - _validate_move_resources_initial.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{sourceResourceGroupName}/validateMoveResources"} # type: ignore + _validate_move_resources_initial.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{sourceResourceGroupName}/validateMoveResources"} # type: ignore - - @distributed_trace_async - async def begin_validate_move_resources( # pylint: disable=inconsistent-return-statements + @overload + async def begin_validate_move_resources( self, source_resource_group_name: str, - parameters: "_models.ResourcesMoveInfo", + parameters: _models.ResourcesMoveInfo, + *, + content_type: str = "application/json", **kwargs: Any ) -> AsyncLROPoller[None]: """Validates whether resources can be moved from one resource group to another resource group. @@ -4214,10 +5386,13 @@ async def begin_validate_move_resources( # pylint: disable=inconsistent-return- operation. :param source_resource_group_name: The name of the resource group containing the resources to - validate for move. + validate for move. Required. :type source_resource_group_name: str - :param parameters: Parameters for moving resources. + :param parameters: Parameters for moving resources. Required. :type parameters: ~azure.mgmt.resource.resources.v2019_07_01.models.ResourcesMoveInfo + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str :keyword callable cls: A custom type or function that will be passed the direct response :keyword str continuation_token: A continuation token to restart a poller from a saved state. :keyword polling: By default, your polling method will be AsyncARMPolling. Pass in False for @@ -4228,55 +5403,124 @@ async def begin_validate_move_resources( # pylint: disable=inconsistent-return- Retry-After header is present. :return: An instance of AsyncLROPoller that returns either None or the result of cls(response) :rtype: ~azure.core.polling.AsyncLROPoller[None] - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - api_version = kwargs.pop('api_version', "2019-07-01") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] - polling = kwargs.pop('polling', True) # type: Union[bool, AsyncPollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType[None] - lro_delay = kwargs.pop( - 'polling_interval', - self._config.polling_interval - ) - cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] + + @overload + async def begin_validate_move_resources( + self, source_resource_group_name: str, parameters: IO, *, content_type: str = "application/json", **kwargs: Any + ) -> AsyncLROPoller[None]: + """Validates whether resources can be moved from one resource group to another resource group. + + This operation checks whether the specified resources can be moved to the target. The resources + to move must be in the same source resource group. The target resource group may be in a + different subscription. If validation succeeds, it returns HTTP response code 204 (no content). + If validation fails, it returns HTTP response code 409 (Conflict) with an error message. + Retrieve the URL in the Location header value to check the result of the long-running + operation. + + :param source_resource_group_name: The name of the resource group containing the resources to + validate for move. Required. + :type source_resource_group_name: str + :param parameters: Parameters for moving resources. Required. + :type parameters: IO + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be AsyncARMPolling. Pass in False for + this operation to not poll, or pass in your own initialized polling object for a personal + polling strategy. + :paramtype polling: bool or ~azure.core.polling.AsyncPollingMethod + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of AsyncLROPoller that returns either None or the result of cls(response) + :rtype: ~azure.core.polling.AsyncLROPoller[None] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace_async + async def begin_validate_move_resources( + self, source_resource_group_name: str, parameters: Union[_models.ResourcesMoveInfo, IO], **kwargs: Any + ) -> AsyncLROPoller[None]: + """Validates whether resources can be moved from one resource group to another resource group. + + This operation checks whether the specified resources can be moved to the target. The resources + to move must be in the same source resource group. The target resource group may be in a + different subscription. If validation succeeds, it returns HTTP response code 204 (no content). + If validation fails, it returns HTTP response code 409 (Conflict) with an error message. + Retrieve the URL in the Location header value to check the result of the long-running + operation. + + :param source_resource_group_name: The name of the resource group containing the resources to + validate for move. Required. + :type source_resource_group_name: str + :param parameters: Parameters for moving resources. Is either a model type or a IO type. + Required. + :type parameters: ~azure.mgmt.resource.resources.v2019_07_01.models.ResourcesMoveInfo or IO + :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. + Default value is None. + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be AsyncARMPolling. Pass in False for + this operation to not poll, or pass in your own initialized polling object for a personal + polling strategy. + :paramtype polling: bool or ~azure.core.polling.AsyncPollingMethod + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of AsyncLROPoller that returns either None or the result of cls(response) + :rtype: ~azure.core.polling.AsyncLROPoller[None] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _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", "2019-07-01")) # type: str + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[None] + polling = kwargs.pop("polling", True) # type: Union[bool, AsyncPollingMethod] + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token = kwargs.pop("continuation_token", None) # type: Optional[str] if cont_token is None: - raw_result = await self._validate_move_resources_initial( + raw_result = await self._validate_move_resources_initial( # type: ignore source_resource_group_name=source_resource_group_name, parameters=parameters, api_version=api_version, content_type=content_type, - cls=lambda x,y,z: x, + cls=lambda x, y, z: x, + headers=_headers, + params=_params, **kwargs ) - kwargs.pop('error_map', None) + kwargs.pop("error_map", None) - def get_long_running_output(pipeline_response): + def get_long_running_output(pipeline_response): # pylint: disable=inconsistent-return-statements if cls: return cls(pipeline_response, None, {}) - - if polling is True: polling_method = AsyncARMPolling(lro_delay, **kwargs) - elif polling is False: polling_method = AsyncNoPolling() - else: polling_method = polling + if polling is True: + polling_method = cast(AsyncPollingMethod, AsyncARMPolling(lro_delay, **kwargs)) # type: AsyncPollingMethod + elif polling is False: + polling_method = cast(AsyncPollingMethod, AsyncNoPolling()) + else: + polling_method = polling if cont_token: return AsyncLROPoller.from_continuation_token( polling_method=polling_method, continuation_token=cont_token, client=self._client, - deserialization_callback=get_long_running_output + deserialization_callback=get_long_running_output, ) return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) - begin_validate_move_resources.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{sourceResourceGroupName}/validateMoveResources"} # type: ignore + begin_validate_move_resources.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{sourceResourceGroupName}/validateMoveResources"} # type: ignore @distributed_trace def list( - self, - filter: Optional[str] = None, - expand: Optional[str] = None, - top: Optional[int] = None, - **kwargs: Any - ) -> AsyncIterable["_models.ResourceListResult"]: + self, filter: Optional[str] = None, expand: Optional[str] = None, top: Optional[int] = None, **kwargs: Any + ) -> AsyncIterable["_models.GenericResourceExpanded"]: """Get all the resources in a subscription. :param filter: The filter to apply on the operation.:code:`
`:code:`
`The properties you @@ -4302,40 +5546,50 @@ def list( value is None. :type top: int :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either ResourceListResult or the result of cls(response) + :return: An iterator like instance of either GenericResourceExpanded or the result of + cls(response) :rtype: - ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.resource.resources.v2019_07_01.models.ResourceListResult] - :raises: ~azure.core.exceptions.HttpResponseError + ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.resource.resources.v2019_07_01.models.GenericResourceExpanded] + :raises ~azure.core.exceptions.HttpResponseError: """ - api_version = kwargs.pop('api_version', "2019-07-01") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2019-07-01")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[_models.ResourceListResult] - cls = kwargs.pop('cls', None) # type: ClsType["_models.ResourceListResult"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) + def prepare_request(next_link=None): if not next_link: - + request = build_resources_list_request( subscription_id=self._config.subscription_id, - api_version=api_version, filter=filter, expand=expand, top=top, - template_url=self.list.metadata['url'], + 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.url = self._client.format_url(request.url) # type: ignore else: - - request = build_resources_list_request( - subscription_id=self._config.subscription_id, - template_url=next_link, - ) + # make call to next link with the client's api-version + _parsed_next_link = urlparse(next_link) + _next_request_params = case_insensitive_dict(parse_qs(_parsed_next_link.query)) + _next_request_params["api-version"] = self._config.api_version + request = HttpRequest("GET", urljoin(next_link, _parsed_next_link.path), params=_next_request_params) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore request.method = "GET" return request @@ -4349,10 +5603,8 @@ async def extract_data(pipeline_response): async def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) response = pipeline_response.http_response @@ -4362,11 +5614,9 @@ async def get_next(next_link=None): return pipeline_response + return AsyncItemPaged(get_next, extract_data) - return AsyncItemPaged( - get_next, extract_data - ) - list.metadata = {'url': "/subscriptions/{subscriptionId}/resources"} # type: ignore + list.metadata = {"url": "/subscriptions/{subscriptionId}/resources"} # type: ignore @distributed_trace_async async def check_existence( @@ -4382,30 +5632,36 @@ async def check_existence( """Checks whether a resource exists. :param resource_group_name: The name of the resource group containing the resource to check. - The name is case insensitive. + The name is case insensitive. Required. :type resource_group_name: str - :param resource_provider_namespace: The resource provider of the resource to check. + :param resource_provider_namespace: The resource provider of the resource to check. Required. :type resource_provider_namespace: str - :param parent_resource_path: The parent resource identity. + :param parent_resource_path: The parent resource identity. Required. :type parent_resource_path: str - :param resource_type: The resource type. + :param resource_type: The resource type. Required. :type resource_type: str - :param resource_name: The name of the resource to check whether it exists. + :param resource_name: The name of the resource to check whether it exists. Required. :type resource_name: str - :param api_version: The API version to use for the operation. + :param api_version: The API version to use for the operation. Required. :type api_version: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: bool, or the result of cls(response) + :return: bool or the result of cls(response) :rtype: bool - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType[None] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = kwargs.pop("params", {}) or {} + + cls = kwargs.pop("cls", None) # type: ClsType[None] - request = build_resources_check_existence_request( resource_group_name=resource_group_name, resource_provider_namespace=resource_provider_namespace, @@ -4414,16 +5670,17 @@ async def check_existence( resource_name=resource_name, subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.check_existence.metadata['url'], + template_url=self.check_existence.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [204, 404]: @@ -4434,8 +5691,7 @@ async def check_existence( return cls(pipeline_response, None, {}) return 200 <= response.status_code <= 299 - check_existence.metadata = {'url': "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{parentResourcePath}/{resourceType}/{resourceName}"} # type: ignore - + check_existence.metadata = {"url": "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{parentResourcePath}/{resourceType}/{resourceName}"} # type: ignore async def _delete_initial( # pylint: disable=inconsistent-return-statements self, @@ -4447,14 +5703,20 @@ async def _delete_initial( # pylint: disable=inconsistent-return-statements api_version: str, **kwargs: Any ) -> None: - cls = kwargs.pop('cls', None) # type: ClsType[None] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = kwargs.pop("params", {}) or {} + + cls = kwargs.pop("cls", None) # type: ClsType[None] - - request = build_resources_delete_request_initial( + request = build_resources_delete_request( resource_group_name=resource_group_name, resource_provider_namespace=resource_provider_namespace, parent_resource_path=parent_resource_path, @@ -4462,16 +5724,17 @@ async def _delete_initial( # pylint: disable=inconsistent-return-statements resource_name=resource_name, subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self._delete_initial.metadata['url'], + template_url=self._delete_initial.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200, 202, 204]: @@ -4481,11 +5744,10 @@ 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/{resourceProviderNamespace}/{parentResourcePath}/{resourceType}/{resourceName}"} # type: ignore - + _delete_initial.metadata = {"url": "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{parentResourcePath}/{resourceType}/{resourceName}"} # type: ignore @distributed_trace_async - async def begin_delete( # pylint: disable=inconsistent-return-statements + async def begin_delete( self, resource_group_name: str, resource_provider_namespace: str, @@ -4498,17 +5760,17 @@ async def begin_delete( # pylint: disable=inconsistent-return-statements """Deletes a resource. :param resource_group_name: The name of the resource group that contains the resource to - delete. The name is case insensitive. + delete. The name is case insensitive. Required. :type resource_group_name: str - :param resource_provider_namespace: The namespace of the resource provider. + :param resource_provider_namespace: The namespace of the resource provider. Required. :type resource_provider_namespace: str - :param parent_resource_path: The parent resource identity. + :param parent_resource_path: The parent resource identity. Required. :type parent_resource_path: str - :param resource_type: The resource type. + :param resource_type: The resource type. Required. :type resource_type: str - :param resource_name: The name of the resource to delete. + :param resource_name: The name of the resource to delete. Required. :type resource_name: str - :param api_version: The API version to use for the operation. + :param api_version: The API version to use for the operation. Required. :type api_version: str :keyword callable cls: A custom type or function that will be passed the direct response :keyword str continuation_token: A continuation token to restart a poller from a saved state. @@ -4520,46 +5782,50 @@ async def begin_delete( # pylint: disable=inconsistent-return-statements Retry-After header is present. :return: An instance of AsyncLROPoller that returns either None or the result of cls(response) :rtype: ~azure.core.polling.AsyncLROPoller[None] - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - polling = kwargs.pop('polling', True) # type: Union[bool, AsyncPollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType[None] - lro_delay = kwargs.pop( - 'polling_interval', - self._config.polling_interval - ) - cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] + _headers = kwargs.pop("headers", {}) or {} + _params = kwargs.pop("params", {}) or {} + + cls = kwargs.pop("cls", None) # type: ClsType[None] + polling = kwargs.pop("polling", True) # type: Union[bool, AsyncPollingMethod] + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token = kwargs.pop("continuation_token", None) # type: Optional[str] if cont_token is None: - raw_result = await self._delete_initial( + raw_result = await self._delete_initial( # type: ignore resource_group_name=resource_group_name, resource_provider_namespace=resource_provider_namespace, parent_resource_path=parent_resource_path, resource_type=resource_type, resource_name=resource_name, api_version=api_version, - cls=lambda x,y,z: x, + cls=lambda x, y, z: x, + headers=_headers, + params=_params, **kwargs ) - kwargs.pop('error_map', None) + kwargs.pop("error_map", None) - def get_long_running_output(pipeline_response): + def get_long_running_output(pipeline_response): # pylint: disable=inconsistent-return-statements if cls: return cls(pipeline_response, None, {}) - - if polling is True: polling_method = AsyncARMPolling(lro_delay, **kwargs) - elif polling is False: polling_method = AsyncNoPolling() - else: polling_method = polling + if polling is True: + polling_method = cast(AsyncPollingMethod, AsyncARMPolling(lro_delay, **kwargs)) # type: AsyncPollingMethod + elif polling is False: + polling_method = cast(AsyncPollingMethod, AsyncNoPolling()) + else: + polling_method = polling if cont_token: return AsyncLROPoller.from_continuation_token( polling_method=polling_method, continuation_token=cont_token, client=self._client, - deserialization_callback=get_long_running_output + deserialization_callback=get_long_running_output, ) return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) - begin_delete.metadata = {'url': "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{parentResourcePath}/{resourceType}/{resourceName}"} # type: ignore + begin_delete.metadata = {"url": "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{parentResourcePath}/{resourceType}/{resourceName}"} # type: ignore async def _create_or_update_initial( self, @@ -4569,39 +5835,53 @@ async def _create_or_update_initial( resource_type: str, resource_name: str, api_version: str, - parameters: "_models.GenericResource", + parameters: Union[_models.GenericResource, IO], **kwargs: Any - ) -> Optional["_models.GenericResource"]: - cls = kwargs.pop('cls', None) # type: ClsType[Optional["_models.GenericResource"]] + ) -> Optional[_models.GenericResource]: error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = kwargs.pop("params", {}) or {} - _json = self._serialize.body(parameters, 'GenericResource') + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[Optional[_models.GenericResource]] - request = build_resources_create_or_update_request_initial( + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(parameters, (IO, bytes)): + _content = parameters + else: + _json = self._serialize.body(parameters, "GenericResource") + + request = build_resources_create_or_update_request( resource_group_name=resource_group_name, resource_provider_namespace=resource_provider_namespace, parent_resource_path=parent_resource_path, resource_type=resource_type, resource_name=resource_name, subscription_id=self._config.subscription_id, - content_type=content_type, api_version=api_version, + content_type=content_type, json=_json, - template_url=self._create_or_update_initial.metadata['url'], + content=_content, + template_url=self._create_or_update_initial.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200, 201, 202]: @@ -4610,18 +5890,115 @@ async def _create_or_update_initial( deserialized = None if response.status_code == 200: - deserialized = self._deserialize('GenericResource', pipeline_response) + deserialized = self._deserialize("GenericResource", pipeline_response) if response.status_code == 201: - deserialized = self._deserialize('GenericResource', pipeline_response) + deserialized = self._deserialize("GenericResource", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - _create_or_update_initial.metadata = {'url': "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{parentResourcePath}/{resourceType}/{resourceName}"} # type: ignore + _create_or_update_initial.metadata = {"url": "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{parentResourcePath}/{resourceType}/{resourceName}"} # type: ignore + + @overload + async def begin_create_or_update( + self, + resource_group_name: str, + resource_provider_namespace: str, + parent_resource_path: str, + resource_type: str, + resource_name: str, + api_version: str, + parameters: _models.GenericResource, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> AsyncLROPoller[_models.GenericResource]: + """Creates a resource. + + :param resource_group_name: The name of the resource group for the resource. The name is case + insensitive. Required. + :type resource_group_name: str + :param resource_provider_namespace: The namespace of the resource provider. Required. + :type resource_provider_namespace: str + :param parent_resource_path: The parent resource identity. Required. + :type parent_resource_path: str + :param resource_type: The resource type of the resource to create. Required. + :type resource_type: str + :param resource_name: The name of the resource to create. Required. + :type resource_name: str + :param api_version: The API version to use for the operation. Required. + :type api_version: str + :param parameters: Parameters for creating or updating the resource. Required. + :type parameters: ~azure.mgmt.resource.resources.v2019_07_01.models.GenericResource + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be AsyncARMPolling. Pass in False for + this operation to not poll, or pass in your own initialized polling object for a personal + polling strategy. + :paramtype polling: bool or ~azure.core.polling.AsyncPollingMethod + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of AsyncLROPoller that returns either GenericResource or the result of + cls(response) + :rtype: + ~azure.core.polling.AsyncLROPoller[~azure.mgmt.resource.resources.v2019_07_01.models.GenericResource] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + async def begin_create_or_update( + self, + resource_group_name: str, + resource_provider_namespace: str, + parent_resource_path: str, + resource_type: str, + resource_name: str, + api_version: str, + parameters: IO, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> AsyncLROPoller[_models.GenericResource]: + """Creates a resource. + :param resource_group_name: The name of the resource group for the resource. The name is case + insensitive. Required. + :type resource_group_name: str + :param resource_provider_namespace: The namespace of the resource provider. Required. + :type resource_provider_namespace: str + :param parent_resource_path: The parent resource identity. Required. + :type parent_resource_path: str + :param resource_type: The resource type of the resource to create. Required. + :type resource_type: str + :param resource_name: The name of the resource to create. Required. + :type resource_name: str + :param api_version: The API version to use for the operation. Required. + :type api_version: str + :param parameters: Parameters for creating or updating the resource. Required. + :type parameters: IO + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be AsyncARMPolling. Pass in False for + this operation to not poll, or pass in your own initialized polling object for a personal + polling strategy. + :paramtype polling: bool or ~azure.core.polling.AsyncPollingMethod + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of AsyncLROPoller that returns either GenericResource or the result of + cls(response) + :rtype: + ~azure.core.polling.AsyncLROPoller[~azure.mgmt.resource.resources.v2019_07_01.models.GenericResource] + :raises ~azure.core.exceptions.HttpResponseError: + """ @distributed_trace_async async def begin_create_or_update( @@ -4632,26 +6009,30 @@ async def begin_create_or_update( resource_type: str, resource_name: str, api_version: str, - parameters: "_models.GenericResource", + parameters: Union[_models.GenericResource, IO], **kwargs: Any - ) -> AsyncLROPoller["_models.GenericResource"]: + ) -> AsyncLROPoller[_models.GenericResource]: """Creates a resource. :param resource_group_name: The name of the resource group for the resource. The name is case - insensitive. + insensitive. Required. :type resource_group_name: str - :param resource_provider_namespace: The namespace of the resource provider. + :param resource_provider_namespace: The namespace of the resource provider. Required. :type resource_provider_namespace: str - :param parent_resource_path: The parent resource identity. + :param parent_resource_path: The parent resource identity. Required. :type parent_resource_path: str - :param resource_type: The resource type of the resource to create. + :param resource_type: The resource type of the resource to create. Required. :type resource_type: str - :param resource_name: The name of the resource to create. + :param resource_name: The name of the resource to create. Required. :type resource_name: str - :param api_version: The API version to use for the operation. + :param api_version: The API version to use for the operation. Required. :type api_version: str - :param parameters: Parameters for creating or updating the resource. - :type parameters: ~azure.mgmt.resource.resources.v2019_07_01.models.GenericResource + :param parameters: Parameters for creating or updating the resource. Is either a model type or + a IO type. Required. + :type parameters: ~azure.mgmt.resource.resources.v2019_07_01.models.GenericResource or IO + :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. + Default value is None. + :paramtype content_type: str :keyword callable cls: A custom type or function that will be passed the direct response :keyword str continuation_token: A continuation token to restart a poller from a saved state. :keyword polling: By default, your polling method will be AsyncARMPolling. Pass in False for @@ -4664,18 +6045,18 @@ async def begin_create_or_update( cls(response) :rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.resource.resources.v2019_07_01.models.GenericResource] - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] - polling = kwargs.pop('polling', True) # type: Union[bool, AsyncPollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType["_models.GenericResource"] - lro_delay = kwargs.pop( - 'polling_interval', - self._config.polling_interval - ) - cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = kwargs.pop("params", {}) or {} + + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.GenericResource] + polling = kwargs.pop("polling", True) # type: Union[bool, AsyncPollingMethod] + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token = kwargs.pop("continuation_token", None) # type: Optional[str] if cont_token is None: - raw_result = await self._create_or_update_initial( + raw_result = await self._create_or_update_initial( # type: ignore resource_group_name=resource_group_name, resource_provider_namespace=resource_provider_namespace, parent_resource_path=parent_resource_path, @@ -4684,34 +6065,159 @@ async def begin_create_or_update( api_version=api_version, parameters=parameters, content_type=content_type, - cls=lambda x,y,z: x, + cls=lambda x, y, z: x, + headers=_headers, + params=_params, **kwargs ) - kwargs.pop('error_map', None) + kwargs.pop("error_map", None) def get_long_running_output(pipeline_response): - response = pipeline_response.http_response - deserialized = self._deserialize('GenericResource', pipeline_response) + deserialized = self._deserialize("GenericResource", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - - if polling is True: polling_method = AsyncARMPolling(lro_delay, **kwargs) - elif polling is False: polling_method = AsyncNoPolling() - else: polling_method = polling + if polling is True: + polling_method = cast(AsyncPollingMethod, AsyncARMPolling(lro_delay, **kwargs)) # type: AsyncPollingMethod + elif polling is False: + polling_method = cast(AsyncPollingMethod, AsyncNoPolling()) + else: + polling_method = polling if cont_token: return AsyncLROPoller.from_continuation_token( polling_method=polling_method, continuation_token=cont_token, client=self._client, - deserialization_callback=get_long_running_output + deserialization_callback=get_long_running_output, ) return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) - begin_create_or_update.metadata = {'url': "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{parentResourcePath}/{resourceType}/{resourceName}"} # type: ignore + begin_create_or_update.metadata = {"url": "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{parentResourcePath}/{resourceType}/{resourceName}"} # type: ignore + + async def _update_initial( + self, + resource_group_name: str, + resource_provider_namespace: str, + parent_resource_path: str, + resource_type: str, + resource_name: str, + api_version: str, + parameters: Union[_models.GenericResource, IO], + **kwargs: Any + ) -> Optional[_models.GenericResource]: + error_map = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = kwargs.pop("params", {}) or {} + + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[Optional[_models.GenericResource]] + + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(parameters, (IO, bytes)): + _content = parameters + else: + _json = self._serialize.body(parameters, "GenericResource") + + request = build_resources_update_request( + resource_group_name=resource_group_name, + resource_provider_namespace=resource_provider_namespace, + parent_resource_path=parent_resource_path, + resource_type=resource_type, + resource_name=resource_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + content_type=content_type, + json=_json, + content=_content, + template_url=self._update_initial.metadata["url"], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore + + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [200, 202]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + deserialized = None + if response.status_code == 200: + deserialized = self._deserialize("GenericResource", pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + + _update_initial.metadata = {"url": "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{parentResourcePath}/{resourceType}/{resourceName}"} # type: ignore + + @overload + async def begin_update( + self, + resource_group_name: str, + resource_provider_namespace: str, + parent_resource_path: str, + resource_type: str, + resource_name: str, + api_version: str, + parameters: _models.GenericResource, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> AsyncLROPoller[_models.GenericResource]: + """Updates a resource. + + :param resource_group_name: The name of the resource group for the resource. The name is case + insensitive. Required. + :type resource_group_name: str + :param resource_provider_namespace: The namespace of the resource provider. Required. + :type resource_provider_namespace: str + :param parent_resource_path: The parent resource identity. Required. + :type parent_resource_path: str + :param resource_type: The resource type of the resource to update. Required. + :type resource_type: str + :param resource_name: The name of the resource to update. Required. + :type resource_name: str + :param api_version: The API version to use for the operation. Required. + :type api_version: str + :param parameters: Parameters for updating the resource. Required. + :type parameters: ~azure.mgmt.resource.resources.v2019_07_01.models.GenericResource + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be AsyncARMPolling. Pass in False for + this operation to not poll, or pass in your own initialized polling object for a personal + polling strategy. + :paramtype polling: bool or ~azure.core.polling.AsyncPollingMethod + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of AsyncLROPoller that returns either GenericResource or the result of + cls(response) + :rtype: + ~azure.core.polling.AsyncLROPoller[~azure.mgmt.resource.resources.v2019_07_01.models.GenericResource] + :raises ~azure.core.exceptions.HttpResponseError: + """ - async def _update_initial( + @overload + async def begin_update( self, resource_group_name: str, resource_provider_namespace: str, @@ -4719,56 +6225,45 @@ async def _update_initial( resource_type: str, resource_name: str, api_version: str, - parameters: "_models.GenericResource", + parameters: IO, + *, + content_type: str = "application/json", **kwargs: Any - ) -> Optional["_models.GenericResource"]: - cls = kwargs.pop('cls', None) # type: ClsType[Optional["_models.GenericResource"]] - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {})) - - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] - - _json = self._serialize.body(parameters, 'GenericResource') - - request = build_resources_update_request_initial( - resource_group_name=resource_group_name, - resource_provider_namespace=resource_provider_namespace, - parent_resource_path=parent_resource_path, - resource_type=resource_type, - resource_name=resource_name, - subscription_id=self._config.subscription_id, - content_type=content_type, - api_version=api_version, - json=_json, - template_url=self._update_initial.metadata['url'], - ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) - - pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs - ) - response = pipeline_response.http_response - - if response.status_code not in [200, 202]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - raise HttpResponseError(response=response, error_format=ARMErrorFormat) - - deserialized = None - if response.status_code == 200: - deserialized = self._deserialize('GenericResource', pipeline_response) - - if cls: - return cls(pipeline_response, deserialized, {}) - - return deserialized - - _update_initial.metadata = {'url': "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{parentResourcePath}/{resourceType}/{resourceName}"} # type: ignore + ) -> AsyncLROPoller[_models.GenericResource]: + """Updates a resource. + :param resource_group_name: The name of the resource group for the resource. The name is case + insensitive. Required. + :type resource_group_name: str + :param resource_provider_namespace: The namespace of the resource provider. Required. + :type resource_provider_namespace: str + :param parent_resource_path: The parent resource identity. Required. + :type parent_resource_path: str + :param resource_type: The resource type of the resource to update. Required. + :type resource_type: str + :param resource_name: The name of the resource to update. Required. + :type resource_name: str + :param api_version: The API version to use for the operation. Required. + :type api_version: str + :param parameters: Parameters for updating the resource. Required. + :type parameters: IO + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be AsyncARMPolling. Pass in False for + this operation to not poll, or pass in your own initialized polling object for a personal + polling strategy. + :paramtype polling: bool or ~azure.core.polling.AsyncPollingMethod + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of AsyncLROPoller that returns either GenericResource or the result of + cls(response) + :rtype: + ~azure.core.polling.AsyncLROPoller[~azure.mgmt.resource.resources.v2019_07_01.models.GenericResource] + :raises ~azure.core.exceptions.HttpResponseError: + """ @distributed_trace_async async def begin_update( @@ -4779,26 +6274,30 @@ async def begin_update( resource_type: str, resource_name: str, api_version: str, - parameters: "_models.GenericResource", + parameters: Union[_models.GenericResource, IO], **kwargs: Any - ) -> AsyncLROPoller["_models.GenericResource"]: + ) -> AsyncLROPoller[_models.GenericResource]: """Updates a resource. :param resource_group_name: The name of the resource group for the resource. The name is case - insensitive. + insensitive. Required. :type resource_group_name: str - :param resource_provider_namespace: The namespace of the resource provider. + :param resource_provider_namespace: The namespace of the resource provider. Required. :type resource_provider_namespace: str - :param parent_resource_path: The parent resource identity. + :param parent_resource_path: The parent resource identity. Required. :type parent_resource_path: str - :param resource_type: The resource type of the resource to update. + :param resource_type: The resource type of the resource to update. Required. :type resource_type: str - :param resource_name: The name of the resource to update. + :param resource_name: The name of the resource to update. Required. :type resource_name: str - :param api_version: The API version to use for the operation. + :param api_version: The API version to use for the operation. Required. :type api_version: str - :param parameters: Parameters for updating the resource. - :type parameters: ~azure.mgmt.resource.resources.v2019_07_01.models.GenericResource + :param parameters: Parameters for updating the resource. Is either a model type or a IO type. + Required. + :type parameters: ~azure.mgmt.resource.resources.v2019_07_01.models.GenericResource or IO + :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. + Default value is None. + :paramtype content_type: str :keyword callable cls: A custom type or function that will be passed the direct response :keyword str continuation_token: A continuation token to restart a poller from a saved state. :keyword polling: By default, your polling method will be AsyncARMPolling. Pass in False for @@ -4811,18 +6310,18 @@ async def begin_update( cls(response) :rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.resource.resources.v2019_07_01.models.GenericResource] - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] - polling = kwargs.pop('polling', True) # type: Union[bool, AsyncPollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType["_models.GenericResource"] - lro_delay = kwargs.pop( - 'polling_interval', - self._config.polling_interval - ) - cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = kwargs.pop("params", {}) or {} + + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.GenericResource] + polling = kwargs.pop("polling", True) # type: Union[bool, AsyncPollingMethod] + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token = kwargs.pop("continuation_token", None) # type: Optional[str] if cont_token is None: - raw_result = await self._update_initial( + raw_result = await self._update_initial( # type: ignore resource_group_name=resource_group_name, resource_provider_namespace=resource_provider_namespace, parent_resource_path=parent_resource_path, @@ -4831,32 +6330,35 @@ async def begin_update( api_version=api_version, parameters=parameters, content_type=content_type, - cls=lambda x,y,z: x, + cls=lambda x, y, z: x, + headers=_headers, + params=_params, **kwargs ) - kwargs.pop('error_map', None) + kwargs.pop("error_map", None) def get_long_running_output(pipeline_response): - response = pipeline_response.http_response - deserialized = self._deserialize('GenericResource', pipeline_response) + deserialized = self._deserialize("GenericResource", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - - if polling is True: polling_method = AsyncARMPolling(lro_delay, **kwargs) - elif polling is False: polling_method = AsyncNoPolling() - else: polling_method = polling + if polling is True: + polling_method = cast(AsyncPollingMethod, AsyncARMPolling(lro_delay, **kwargs)) # type: AsyncPollingMethod + elif polling is False: + polling_method = cast(AsyncPollingMethod, AsyncNoPolling()) + else: + polling_method = polling if cont_token: return AsyncLROPoller.from_continuation_token( polling_method=polling_method, continuation_token=cont_token, client=self._client, - deserialization_callback=get_long_running_output + deserialization_callback=get_long_running_output, ) return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) - begin_update.metadata = {'url': "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{parentResourcePath}/{resourceType}/{resourceName}"} # type: ignore + begin_update.metadata = {"url": "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{parentResourcePath}/{resourceType}/{resourceName}"} # type: ignore @distributed_trace_async async def get( @@ -4868,34 +6370,40 @@ async def get( resource_name: str, api_version: str, **kwargs: Any - ) -> "_models.GenericResource": + ) -> _models.GenericResource: """Gets a resource. :param resource_group_name: The name of the resource group containing the resource to get. The - name is case insensitive. + name is case insensitive. Required. :type resource_group_name: str - :param resource_provider_namespace: The namespace of the resource provider. + :param resource_provider_namespace: The namespace of the resource provider. Required. :type resource_provider_namespace: str - :param parent_resource_path: The parent resource identity. + :param parent_resource_path: The parent resource identity. Required. :type parent_resource_path: str - :param resource_type: The resource type of the resource. + :param resource_type: The resource type of the resource. Required. :type resource_type: str - :param resource_name: The name of the resource to get. + :param resource_name: The name of the resource to get. Required. :type resource_name: str - :param api_version: The API version to use for the operation. + :param api_version: The API version to use for the operation. Required. :type api_version: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: GenericResource, or the result of cls(response) + :return: GenericResource or the result of cls(response) :rtype: ~azure.mgmt.resource.resources.v2019_07_01.models.GenericResource - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.GenericResource"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = kwargs.pop("params", {}) or {} + + cls = kwargs.pop("cls", None) # type: ClsType[_models.GenericResource] - request = build_resources_get_request( resource_group_name=resource_group_name, resource_provider_namespace=resource_provider_namespace, @@ -4904,72 +6412,75 @@ async def get( resource_name=resource_name, subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.get.metadata['url'], + template_url=self.get.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) - deserialized = self._deserialize('GenericResource', pipeline_response) + deserialized = self._deserialize("GenericResource", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - get.metadata = {'url': "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{parentResourcePath}/{resourceType}/{resourceName}"} # type: ignore - + get.metadata = {"url": "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{parentResourcePath}/{resourceType}/{resourceName}"} # type: ignore @distributed_trace_async - async def check_existence_by_id( - self, - resource_id: str, - api_version: str, - **kwargs: Any - ) -> bool: + async def check_existence_by_id(self, resource_id: str, api_version: str, **kwargs: Any) -> bool: """Checks by ID whether a resource exists. :param resource_id: The fully qualified ID of the resource, including the resource name and resource type. Use the format, /subscriptions/{guid}/resourceGroups/{resource-group-name}/{resource-provider-namespace}/{resource-type}/{resource-name}. + Required. :type resource_id: str - :param api_version: The API version to use for the operation. + :param api_version: The API version to use for the operation. Required. :type api_version: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: bool, or the result of cls(response) + :return: bool or the result of cls(response) :rtype: bool - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType[None] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = kwargs.pop("params", {}) or {} + + cls = kwargs.pop("cls", None) # type: ClsType[None] - request = build_resources_check_existence_by_id_request( resource_id=resource_id, api_version=api_version, - template_url=self.check_existence_by_id.metadata['url'], + template_url=self.check_existence_by_id.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [204, 404]: @@ -4980,35 +6491,38 @@ async def check_existence_by_id( return cls(pipeline_response, None, {}) return 200 <= response.status_code <= 299 - check_existence_by_id.metadata = {'url': "/{resourceId}"} # type: ignore - + check_existence_by_id.metadata = {"url": "/{resourceId}"} # type: ignore async def _delete_by_id_initial( # pylint: disable=inconsistent-return-statements - self, - resource_id: str, - api_version: str, - **kwargs: Any + self, resource_id: str, api_version: str, **kwargs: Any ) -> None: - cls = kwargs.pop('cls', None) # type: ClsType[None] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = kwargs.pop("params", {}) or {} - - request = build_resources_delete_by_id_request_initial( + cls = kwargs.pop("cls", None) # type: ClsType[None] + + request = build_resources_delete_by_id_request( resource_id=resource_id, api_version=api_version, - template_url=self._delete_by_id_initial.metadata['url'], + template_url=self._delete_by_id_initial.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200, 202, 204]: @@ -5018,23 +6532,18 @@ async def _delete_by_id_initial( # pylint: disable=inconsistent-return-statemen if cls: return cls(pipeline_response, None, {}) - _delete_by_id_initial.metadata = {'url': "/{resourceId}"} # type: ignore - + _delete_by_id_initial.metadata = {"url": "/{resourceId}"} # type: ignore @distributed_trace_async - async def begin_delete_by_id( # pylint: disable=inconsistent-return-statements - self, - resource_id: str, - api_version: str, - **kwargs: Any - ) -> AsyncLROPoller[None]: + async def begin_delete_by_id(self, resource_id: str, api_version: str, **kwargs: Any) -> AsyncLROPoller[None]: """Deletes a resource by ID. :param resource_id: The fully qualified ID of the resource, including the resource name and resource type. Use the format, /subscriptions/{guid}/resourceGroups/{resource-group-name}/{resource-provider-namespace}/{resource-type}/{resource-name}. + Required. :type resource_id: str - :param api_version: The API version to use for the operation. + :param api_version: The API version to use for the operation. Required. :type api_version: str :keyword callable cls: A custom type or function that will be passed the direct response :keyword str continuation_token: A continuation token to restart a poller from a saved state. @@ -5046,75 +6555,89 @@ async def begin_delete_by_id( # pylint: disable=inconsistent-return-statements Retry-After header is present. :return: An instance of AsyncLROPoller that returns either None or the result of cls(response) :rtype: ~azure.core.polling.AsyncLROPoller[None] - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - polling = kwargs.pop('polling', True) # type: Union[bool, AsyncPollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType[None] - lro_delay = kwargs.pop( - 'polling_interval', - self._config.polling_interval - ) - cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] + _headers = kwargs.pop("headers", {}) or {} + _params = kwargs.pop("params", {}) or {} + + cls = kwargs.pop("cls", None) # type: ClsType[None] + polling = kwargs.pop("polling", True) # type: Union[bool, AsyncPollingMethod] + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token = kwargs.pop("continuation_token", None) # type: Optional[str] if cont_token is None: - raw_result = await self._delete_by_id_initial( + raw_result = await self._delete_by_id_initial( # type: ignore resource_id=resource_id, api_version=api_version, - cls=lambda x,y,z: x, + cls=lambda x, y, z: x, + headers=_headers, + params=_params, **kwargs ) - kwargs.pop('error_map', None) + kwargs.pop("error_map", None) - def get_long_running_output(pipeline_response): + def get_long_running_output(pipeline_response): # pylint: disable=inconsistent-return-statements if cls: return cls(pipeline_response, None, {}) - - if polling is True: polling_method = AsyncARMPolling(lro_delay, **kwargs) - elif polling is False: polling_method = AsyncNoPolling() - else: polling_method = polling + if polling is True: + polling_method = cast(AsyncPollingMethod, AsyncARMPolling(lro_delay, **kwargs)) # type: AsyncPollingMethod + elif polling is False: + polling_method = cast(AsyncPollingMethod, AsyncNoPolling()) + else: + polling_method = polling if cont_token: return AsyncLROPoller.from_continuation_token( polling_method=polling_method, continuation_token=cont_token, client=self._client, - deserialization_callback=get_long_running_output + deserialization_callback=get_long_running_output, ) return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) - begin_delete_by_id.metadata = {'url': "/{resourceId}"} # type: ignore + begin_delete_by_id.metadata = {"url": "/{resourceId}"} # type: ignore async def _create_or_update_by_id_initial( - self, - resource_id: str, - api_version: str, - parameters: "_models.GenericResource", - **kwargs: Any - ) -> Optional["_models.GenericResource"]: - cls = kwargs.pop('cls', None) # type: ClsType[Optional["_models.GenericResource"]] + self, resource_id: str, api_version: str, parameters: Union[_models.GenericResource, IO], **kwargs: Any + ) -> Optional[_models.GenericResource]: error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = kwargs.pop("params", {}) or {} - _json = self._serialize.body(parameters, 'GenericResource') + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[Optional[_models.GenericResource]] - request = build_resources_create_or_update_by_id_request_initial( + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(parameters, (IO, bytes)): + _content = parameters + else: + _json = self._serialize.body(parameters, "GenericResource") + + request = build_resources_create_or_update_by_id_request( resource_id=resource_id, - content_type=content_type, api_version=api_version, + content_type=content_type, json=_json, - template_url=self._create_or_update_by_id_initial.metadata['url'], + content=_content, + template_url=self._create_or_update_by_id_initial.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200, 201, 202]: @@ -5123,37 +6646,42 @@ async def _create_or_update_by_id_initial( deserialized = None if response.status_code == 200: - deserialized = self._deserialize('GenericResource', pipeline_response) + deserialized = self._deserialize("GenericResource", pipeline_response) if response.status_code == 201: - deserialized = self._deserialize('GenericResource', pipeline_response) + deserialized = self._deserialize("GenericResource", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - _create_or_update_by_id_initial.metadata = {'url': "/{resourceId}"} # type: ignore + _create_or_update_by_id_initial.metadata = {"url": "/{resourceId}"} # type: ignore - - @distributed_trace_async + @overload async def begin_create_or_update_by_id( self, resource_id: str, api_version: str, - parameters: "_models.GenericResource", + parameters: _models.GenericResource, + *, + content_type: str = "application/json", **kwargs: Any - ) -> AsyncLROPoller["_models.GenericResource"]: + ) -> AsyncLROPoller[_models.GenericResource]: """Create a resource by ID. :param resource_id: The fully qualified ID of the resource, including the resource name and resource type. Use the format, /subscriptions/{guid}/resourceGroups/{resource-group-name}/{resource-provider-namespace}/{resource-type}/{resource-name}. + Required. :type resource_id: str - :param api_version: The API version to use for the operation. + :param api_version: The API version to use for the operation. Required. :type api_version: str - :param parameters: Create or update resource parameters. + :param parameters: Create or update resource parameters. Required. :type parameters: ~azure.mgmt.resource.resources.v2019_07_01.models.GenericResource + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str :keyword callable cls: A custom type or function that will be passed the direct response :keyword str continuation_token: A continuation token to restart a poller from a saved state. :keyword polling: By default, your polling method will be AsyncARMPolling. Pass in False for @@ -5166,81 +6694,167 @@ async def begin_create_or_update_by_id( cls(response) :rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.resource.resources.v2019_07_01.models.GenericResource] - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] - polling = kwargs.pop('polling', True) # type: Union[bool, AsyncPollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType["_models.GenericResource"] - lro_delay = kwargs.pop( - 'polling_interval', - self._config.polling_interval - ) - cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] + + @overload + async def begin_create_or_update_by_id( + self, + resource_id: str, + api_version: str, + parameters: IO, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> AsyncLROPoller[_models.GenericResource]: + """Create a resource by ID. + + :param resource_id: The fully qualified ID of the resource, including the resource name and + resource type. Use the format, + /subscriptions/{guid}/resourceGroups/{resource-group-name}/{resource-provider-namespace}/{resource-type}/{resource-name}. + Required. + :type resource_id: str + :param api_version: The API version to use for the operation. Required. + :type api_version: str + :param parameters: Create or update resource parameters. Required. + :type parameters: IO + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be AsyncARMPolling. Pass in False for + this operation to not poll, or pass in your own initialized polling object for a personal + polling strategy. + :paramtype polling: bool or ~azure.core.polling.AsyncPollingMethod + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of AsyncLROPoller that returns either GenericResource or the result of + cls(response) + :rtype: + ~azure.core.polling.AsyncLROPoller[~azure.mgmt.resource.resources.v2019_07_01.models.GenericResource] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace_async + async def begin_create_or_update_by_id( + self, resource_id: str, api_version: str, parameters: Union[_models.GenericResource, IO], **kwargs: Any + ) -> AsyncLROPoller[_models.GenericResource]: + """Create a resource by ID. + + :param resource_id: The fully qualified ID of the resource, including the resource name and + resource type. Use the format, + /subscriptions/{guid}/resourceGroups/{resource-group-name}/{resource-provider-namespace}/{resource-type}/{resource-name}. + Required. + :type resource_id: str + :param api_version: The API version to use for the operation. Required. + :type api_version: str + :param parameters: Create or update resource parameters. Is either a model type or a IO type. + Required. + :type parameters: ~azure.mgmt.resource.resources.v2019_07_01.models.GenericResource or IO + :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. + Default value is None. + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be AsyncARMPolling. Pass in False for + this operation to not poll, or pass in your own initialized polling object for a personal + polling strategy. + :paramtype polling: bool or ~azure.core.polling.AsyncPollingMethod + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of AsyncLROPoller that returns either GenericResource or the result of + cls(response) + :rtype: + ~azure.core.polling.AsyncLROPoller[~azure.mgmt.resource.resources.v2019_07_01.models.GenericResource] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = kwargs.pop("params", {}) or {} + + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.GenericResource] + polling = kwargs.pop("polling", True) # type: Union[bool, AsyncPollingMethod] + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token = kwargs.pop("continuation_token", None) # type: Optional[str] if cont_token is None: - raw_result = await self._create_or_update_by_id_initial( + raw_result = await self._create_or_update_by_id_initial( # type: ignore resource_id=resource_id, api_version=api_version, parameters=parameters, content_type=content_type, - cls=lambda x,y,z: x, + cls=lambda x, y, z: x, + headers=_headers, + params=_params, **kwargs ) - kwargs.pop('error_map', None) + kwargs.pop("error_map", None) def get_long_running_output(pipeline_response): - response = pipeline_response.http_response - deserialized = self._deserialize('GenericResource', pipeline_response) + deserialized = self._deserialize("GenericResource", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - - if polling is True: polling_method = AsyncARMPolling(lro_delay, **kwargs) - elif polling is False: polling_method = AsyncNoPolling() - else: polling_method = polling + if polling is True: + polling_method = cast(AsyncPollingMethod, AsyncARMPolling(lro_delay, **kwargs)) # type: AsyncPollingMethod + elif polling is False: + polling_method = cast(AsyncPollingMethod, AsyncNoPolling()) + else: + polling_method = polling if cont_token: return AsyncLROPoller.from_continuation_token( polling_method=polling_method, continuation_token=cont_token, client=self._client, - deserialization_callback=get_long_running_output + deserialization_callback=get_long_running_output, ) return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) - begin_create_or_update_by_id.metadata = {'url': "/{resourceId}"} # type: ignore + begin_create_or_update_by_id.metadata = {"url": "/{resourceId}"} # type: ignore async def _update_by_id_initial( - self, - resource_id: str, - api_version: str, - parameters: "_models.GenericResource", - **kwargs: Any - ) -> Optional["_models.GenericResource"]: - cls = kwargs.pop('cls', None) # type: ClsType[Optional["_models.GenericResource"]] + self, resource_id: str, api_version: str, parameters: Union[_models.GenericResource, IO], **kwargs: Any + ) -> Optional[_models.GenericResource]: error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = kwargs.pop("params", {}) or {} - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[Optional[_models.GenericResource]] - _json = self._serialize.body(parameters, 'GenericResource') + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(parameters, (IO, bytes)): + _content = parameters + else: + _json = self._serialize.body(parameters, "GenericResource") - request = build_resources_update_by_id_request_initial( + request = build_resources_update_by_id_request( resource_id=resource_id, - content_type=content_type, api_version=api_version, + content_type=content_type, json=_json, - template_url=self._update_by_id_initial.metadata['url'], + content=_content, + template_url=self._update_by_id_initial.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200, 202]: @@ -5249,34 +6863,39 @@ async def _update_by_id_initial( deserialized = None if response.status_code == 200: - deserialized = self._deserialize('GenericResource', pipeline_response) + deserialized = self._deserialize("GenericResource", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - _update_by_id_initial.metadata = {'url': "/{resourceId}"} # type: ignore - + _update_by_id_initial.metadata = {"url": "/{resourceId}"} # type: ignore - @distributed_trace_async + @overload async def begin_update_by_id( self, resource_id: str, api_version: str, - parameters: "_models.GenericResource", + parameters: _models.GenericResource, + *, + content_type: str = "application/json", **kwargs: Any - ) -> AsyncLROPoller["_models.GenericResource"]: + ) -> AsyncLROPoller[_models.GenericResource]: """Updates a resource by ID. :param resource_id: The fully qualified ID of the resource, including the resource name and resource type. Use the format, /subscriptions/{guid}/resourceGroups/{resource-group-name}/{resource-provider-namespace}/{resource-type}/{resource-name}. + Required. :type resource_id: str - :param api_version: The API version to use for the operation. + :param api_version: The API version to use for the operation. Required. :type api_version: str - :param parameters: Update resource parameters. + :param parameters: Update resource parameters. Required. :type parameters: ~azure.mgmt.resource.resources.v2019_07_01.models.GenericResource + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str :keyword callable cls: A custom type or function that will be passed the direct response :keyword str continuation_token: A continuation token to restart a poller from a saved state. :keyword polling: By default, your polling method will be AsyncARMPolling. Pass in False for @@ -5289,165 +6908,243 @@ async def begin_update_by_id( cls(response) :rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.resource.resources.v2019_07_01.models.GenericResource] - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] - polling = kwargs.pop('polling', True) # type: Union[bool, AsyncPollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType["_models.GenericResource"] - lro_delay = kwargs.pop( - 'polling_interval', - self._config.polling_interval - ) - cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] + + @overload + async def begin_update_by_id( + self, + resource_id: str, + api_version: str, + parameters: IO, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> AsyncLROPoller[_models.GenericResource]: + """Updates a resource by ID. + + :param resource_id: The fully qualified ID of the resource, including the resource name and + resource type. Use the format, + /subscriptions/{guid}/resourceGroups/{resource-group-name}/{resource-provider-namespace}/{resource-type}/{resource-name}. + Required. + :type resource_id: str + :param api_version: The API version to use for the operation. Required. + :type api_version: str + :param parameters: Update resource parameters. Required. + :type parameters: IO + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be AsyncARMPolling. Pass in False for + this operation to not poll, or pass in your own initialized polling object for a personal + polling strategy. + :paramtype polling: bool or ~azure.core.polling.AsyncPollingMethod + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of AsyncLROPoller that returns either GenericResource or the result of + cls(response) + :rtype: + ~azure.core.polling.AsyncLROPoller[~azure.mgmt.resource.resources.v2019_07_01.models.GenericResource] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace_async + async def begin_update_by_id( + self, resource_id: str, api_version: str, parameters: Union[_models.GenericResource, IO], **kwargs: Any + ) -> AsyncLROPoller[_models.GenericResource]: + """Updates a resource by ID. + + :param resource_id: The fully qualified ID of the resource, including the resource name and + resource type. Use the format, + /subscriptions/{guid}/resourceGroups/{resource-group-name}/{resource-provider-namespace}/{resource-type}/{resource-name}. + Required. + :type resource_id: str + :param api_version: The API version to use for the operation. Required. + :type api_version: str + :param parameters: Update resource parameters. Is either a model type or a IO type. Required. + :type parameters: ~azure.mgmt.resource.resources.v2019_07_01.models.GenericResource or IO + :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. + Default value is None. + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be AsyncARMPolling. Pass in False for + this operation to not poll, or pass in your own initialized polling object for a personal + polling strategy. + :paramtype polling: bool or ~azure.core.polling.AsyncPollingMethod + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of AsyncLROPoller that returns either GenericResource or the result of + cls(response) + :rtype: + ~azure.core.polling.AsyncLROPoller[~azure.mgmt.resource.resources.v2019_07_01.models.GenericResource] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = kwargs.pop("params", {}) or {} + + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.GenericResource] + polling = kwargs.pop("polling", True) # type: Union[bool, AsyncPollingMethod] + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token = kwargs.pop("continuation_token", None) # type: Optional[str] if cont_token is None: - raw_result = await self._update_by_id_initial( + raw_result = await self._update_by_id_initial( # type: ignore resource_id=resource_id, api_version=api_version, parameters=parameters, content_type=content_type, - cls=lambda x,y,z: x, + cls=lambda x, y, z: x, + headers=_headers, + params=_params, **kwargs ) - kwargs.pop('error_map', None) + kwargs.pop("error_map", None) def get_long_running_output(pipeline_response): - response = pipeline_response.http_response - deserialized = self._deserialize('GenericResource', pipeline_response) + deserialized = self._deserialize("GenericResource", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - - if polling is True: polling_method = AsyncARMPolling(lro_delay, **kwargs) - elif polling is False: polling_method = AsyncNoPolling() - else: polling_method = polling + if polling is True: + polling_method = cast(AsyncPollingMethod, AsyncARMPolling(lro_delay, **kwargs)) # type: AsyncPollingMethod + elif polling is False: + polling_method = cast(AsyncPollingMethod, AsyncNoPolling()) + else: + polling_method = polling if cont_token: return AsyncLROPoller.from_continuation_token( polling_method=polling_method, continuation_token=cont_token, client=self._client, - deserialization_callback=get_long_running_output + deserialization_callback=get_long_running_output, ) return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) - begin_update_by_id.metadata = {'url': "/{resourceId}"} # type: ignore + begin_update_by_id.metadata = {"url": "/{resourceId}"} # type: ignore @distributed_trace_async - async def get_by_id( - self, - resource_id: str, - api_version: str, - **kwargs: Any - ) -> "_models.GenericResource": + async def get_by_id(self, resource_id: str, api_version: str, **kwargs: Any) -> _models.GenericResource: """Gets a resource by ID. :param resource_id: The fully qualified ID of the resource, including the resource name and resource type. Use the format, /subscriptions/{guid}/resourceGroups/{resource-group-name}/{resource-provider-namespace}/{resource-type}/{resource-name}. + Required. :type resource_id: str - :param api_version: The API version to use for the operation. + :param api_version: The API version to use for the operation. Required. :type api_version: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: GenericResource, or the result of cls(response) + :return: GenericResource or the result of cls(response) :rtype: ~azure.mgmt.resource.resources.v2019_07_01.models.GenericResource - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.GenericResource"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = kwargs.pop("params", {}) or {} + + cls = kwargs.pop("cls", None) # type: ClsType[_models.GenericResource] - request = build_resources_get_by_id_request( resource_id=resource_id, api_version=api_version, - template_url=self.get_by_id.metadata['url'], + template_url=self.get_by_id.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) - deserialized = self._deserialize('GenericResource', pipeline_response) + deserialized = self._deserialize("GenericResource", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - get_by_id.metadata = {'url': "/{resourceId}"} # type: ignore + get_by_id.metadata = {"url": "/{resourceId}"} # type: ignore -class ResourceGroupsOperations: - """ResourceGroupsOperations async operations. - You should not instantiate this class directly. Instead, you should create a Client instance that - instantiates it for you and attaches it as an attribute. +class ResourceGroupsOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. - :ivar models: Alias to model classes used in this operation group. - :type models: ~azure.mgmt.resource.resources.v2019_07_01.models - :param client: Client for service requests. - :param config: Configuration of service client. - :param serializer: An object model serializer. - :param deserializer: An object model deserializer. + Instead, you should access the following operations through + :class:`~azure.mgmt.resource.resources.v2019_07_01.aio.ResourceManagementClient`'s + :attr:`resource_groups` attribute. """ models = _models - def __init__(self, client, config, serializer, deserializer) -> None: - self._client = client - self._serialize = serializer - self._deserialize = deserializer - self._config = config + def __init__(self, *args, **kwargs) -> None: + input_args = list(args) + self._client = input_args.pop(0) if input_args else kwargs.pop("client") + self._config = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") @distributed_trace_async - async def check_existence( - self, - resource_group_name: str, - **kwargs: Any - ) -> bool: + async def check_existence(self, resource_group_name: str, **kwargs: Any) -> bool: """Checks whether a resource group exists. :param resource_group_name: The name of the resource group to check. The name is case - insensitive. + insensitive. Required. :type resource_group_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: bool, or the result of cls(response) + :return: bool or the result of cls(response) :rtype: bool - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType[None] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + 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', "2019-07-01") # type: str + api_version = kwargs.pop("api_version", _params.pop("api-version", "2019-07-01")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[None] - request = build_resource_groups_check_existence_request( resource_group_name=resource_group_name, subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.check_existence.metadata['url'], + template_url=self.check_existence.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [204, 404]: @@ -5458,39 +7155,98 @@ async def check_existence( return cls(pipeline_response, None, {}) return 200 <= response.status_code <= 299 - check_existence.metadata = {'url': "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}"} # type: ignore + check_existence.metadata = {"url": "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}"} # type: ignore + + @overload + async def create_or_update( + self, + resource_group_name: str, + parameters: _models.ResourceGroup, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.ResourceGroup: + """Creates or updates a resource group. + + :param resource_group_name: The name of the resource group to create or update. Can include + alphanumeric, underscore, parentheses, hyphen, period (except at end), and Unicode characters + that match the allowed characters. Required. + :type resource_group_name: str + :param parameters: Parameters supplied to the create or update a resource group. Required. + :type parameters: ~azure.mgmt.resource.resources.v2019_07_01.models.ResourceGroup + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: ResourceGroup or the result of cls(response) + :rtype: ~azure.mgmt.resource.resources.v2019_07_01.models.ResourceGroup + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + async def create_or_update( + self, resource_group_name: str, parameters: IO, *, content_type: str = "application/json", **kwargs: Any + ) -> _models.ResourceGroup: + """Creates or updates a resource group. + :param resource_group_name: The name of the resource group to create or update. Can include + alphanumeric, underscore, parentheses, hyphen, period (except at end), and Unicode characters + that match the allowed characters. Required. + :type resource_group_name: str + :param parameters: Parameters supplied to the create or update a resource group. Required. + :type parameters: IO + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: ResourceGroup or the result of cls(response) + :rtype: ~azure.mgmt.resource.resources.v2019_07_01.models.ResourceGroup + :raises ~azure.core.exceptions.HttpResponseError: + """ @distributed_trace_async async def create_or_update( - self, - resource_group_name: str, - parameters: "_models.ResourceGroup", - **kwargs: Any - ) -> "_models.ResourceGroup": + self, resource_group_name: str, parameters: Union[_models.ResourceGroup, IO], **kwargs: Any + ) -> _models.ResourceGroup: """Creates or updates a resource group. :param resource_group_name: The name of the resource group to create or update. Can include alphanumeric, underscore, parentheses, hyphen, period (except at end), and Unicode characters - that match the allowed characters. + that match the allowed characters. Required. :type resource_group_name: str - :param parameters: Parameters supplied to the create or update a resource group. - :type parameters: ~azure.mgmt.resource.resources.v2019_07_01.models.ResourceGroup + :param parameters: Parameters supplied to the create or update a resource group. Is either a + model type or a IO type. Required. + :type parameters: ~azure.mgmt.resource.resources.v2019_07_01.models.ResourceGroup or IO + :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. + Default value is None. + :paramtype content_type: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: ResourceGroup, or the result of cls(response) + :return: ResourceGroup or the result of cls(response) :rtype: ~azure.mgmt.resource.resources.v2019_07_01.models.ResourceGroup - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.ResourceGroup"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', "2019-07-01") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + api_version = kwargs.pop("api_version", _params.pop("api-version", "2019-07-01")) # type: str + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.ResourceGroup] - _json = self._serialize.body(parameters, 'ResourceGroup') + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(parameters, (IO, bytes)): + _content = parameters + else: + _json = self._serialize.body(parameters, "ResourceGroup") request = build_resource_groups_create_or_update_request( resource_group_name=resource_group_name, @@ -5498,16 +7254,18 @@ async def create_or_update( api_version=api_version, content_type=content_type, json=_json, - template_url=self.create_or_update.metadata['url'], + content=_content, + template_url=self.create_or_update.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200, 201]: @@ -5515,47 +7273,50 @@ async def create_or_update( raise HttpResponseError(response=response, error_format=ARMErrorFormat) if response.status_code == 200: - deserialized = self._deserialize('ResourceGroup', pipeline_response) + deserialized = self._deserialize("ResourceGroup", pipeline_response) if response.status_code == 201: - deserialized = self._deserialize('ResourceGroup', pipeline_response) + deserialized = self._deserialize("ResourceGroup", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - create_or_update.metadata = {'url': "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}"} # type: ignore - + create_or_update.metadata = {"url": "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}"} # type: ignore async def _delete_initial( # pylint: disable=inconsistent-return-statements - self, - resource_group_name: str, - **kwargs: Any + self, resource_group_name: str, **kwargs: Any ) -> None: - cls = kwargs.pop('cls', None) # type: ClsType[None] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + 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', "2019-07-01") # type: str + api_version = kwargs.pop("api_version", _params.pop("api-version", "2019-07-01")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[None] - - request = build_resource_groups_delete_request_initial( + request = build_resource_groups_delete_request( resource_group_name=resource_group_name, subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self._delete_initial.metadata['url'], + template_url=self._delete_initial.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200, 202]: @@ -5565,22 +7326,17 @@ async def _delete_initial( # pylint: disable=inconsistent-return-statements if cls: return cls(pipeline_response, None, {}) - _delete_initial.metadata = {'url': "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}"} # type: ignore - + _delete_initial.metadata = {"url": "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}"} # type: ignore @distributed_trace_async - async def begin_delete( # pylint: disable=inconsistent-return-statements - self, - resource_group_name: str, - **kwargs: Any - ) -> AsyncLROPoller[None]: + async def begin_delete(self, resource_group_name: str, **kwargs: Any) -> AsyncLROPoller[None]: """Deletes a resource group. When you delete a resource group, all of its resources are also deleted. Deleting a resource group deletes all of its template deployments and currently stored operations. :param resource_group_name: The name of the resource group to delete. The name is case - insensitive. + insensitive. Required. :type resource_group_name: str :keyword callable cls: A custom type or function that will be passed the direct response :keyword str continuation_token: A continuation token to restart a poller from a saved state. @@ -5592,106 +7348,113 @@ async def begin_delete( # pylint: disable=inconsistent-return-statements Retry-After header is present. :return: An instance of AsyncLROPoller that returns either None or the result of cls(response) :rtype: ~azure.core.polling.AsyncLROPoller[None] - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - api_version = kwargs.pop('api_version', "2019-07-01") # type: str - polling = kwargs.pop('polling', True) # type: Union[bool, AsyncPollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType[None] - lro_delay = kwargs.pop( - 'polling_interval', - self._config.polling_interval - ) - cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2019-07-01")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[None] + polling = kwargs.pop("polling", True) # type: Union[bool, AsyncPollingMethod] + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token = kwargs.pop("continuation_token", None) # type: Optional[str] if cont_token is None: - raw_result = await self._delete_initial( + raw_result = await self._delete_initial( # type: ignore resource_group_name=resource_group_name, api_version=api_version, - cls=lambda x,y,z: x, + cls=lambda x, y, z: x, + headers=_headers, + params=_params, **kwargs ) - kwargs.pop('error_map', None) + kwargs.pop("error_map", None) - def get_long_running_output(pipeline_response): + def get_long_running_output(pipeline_response): # pylint: disable=inconsistent-return-statements if cls: return cls(pipeline_response, None, {}) - - if polling is True: polling_method = AsyncARMPolling(lro_delay, **kwargs) - elif polling is False: polling_method = AsyncNoPolling() - else: polling_method = polling + if polling is True: + polling_method = cast(AsyncPollingMethod, AsyncARMPolling(lro_delay, **kwargs)) # type: AsyncPollingMethod + elif polling is False: + polling_method = cast(AsyncPollingMethod, AsyncNoPolling()) + else: + polling_method = polling if cont_token: return AsyncLROPoller.from_continuation_token( polling_method=polling_method, continuation_token=cont_token, client=self._client, - deserialization_callback=get_long_running_output + deserialization_callback=get_long_running_output, ) return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) - begin_delete.metadata = {'url': "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}"} # type: ignore + begin_delete.metadata = {"url": "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}"} # type: ignore @distributed_trace_async - async def get( - self, - resource_group_name: str, - **kwargs: Any - ) -> "_models.ResourceGroup": + async def get(self, resource_group_name: str, **kwargs: Any) -> _models.ResourceGroup: """Gets a resource group. :param resource_group_name: The name of the resource group to get. The name is case - insensitive. + insensitive. Required. :type resource_group_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: ResourceGroup, or the result of cls(response) + :return: ResourceGroup or the result of cls(response) :rtype: ~azure.mgmt.resource.resources.v2019_07_01.models.ResourceGroup - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.ResourceGroup"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + 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', "2019-07-01") # type: str + api_version = kwargs.pop("api_version", _params.pop("api-version", "2019-07-01")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[_models.ResourceGroup] - request = build_resource_groups_get_request( resource_group_name=resource_group_name, subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.get.metadata['url'], + template_url=self.get.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) - deserialized = self._deserialize('ResourceGroup', pipeline_response) + deserialized = self._deserialize("ResourceGroup", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - get.metadata = {'url': "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}"} # type: ignore - + get.metadata = {"url": "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}"} # type: ignore - @distributed_trace_async + @overload async def update( self, resource_group_name: str, - parameters: "_models.ResourceGroupPatchable", + parameters: _models.ResourceGroupPatchable, + *, + content_type: str = "application/json", **kwargs: Any - ) -> "_models.ResourceGroup": + ) -> _models.ResourceGroup: """Updates a resource group. Resource groups can be updated through a simple PATCH operation to a group address. The format @@ -5699,25 +7462,90 @@ async def update( the current value is retained. :param resource_group_name: The name of the resource group to update. The name is case - insensitive. + insensitive. Required. :type resource_group_name: str - :param parameters: Parameters supplied to update a resource group. + :param parameters: Parameters supplied to update a resource group. Required. :type parameters: ~azure.mgmt.resource.resources.v2019_07_01.models.ResourceGroupPatchable + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: ResourceGroup or the result of cls(response) + :rtype: ~azure.mgmt.resource.resources.v2019_07_01.models.ResourceGroup + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + async def update( + self, resource_group_name: str, parameters: IO, *, content_type: str = "application/json", **kwargs: Any + ) -> _models.ResourceGroup: + """Updates a resource group. + + Resource groups can be updated through a simple PATCH operation to a group address. The format + of the request is the same as that for creating a resource group. If a field is unspecified, + the current value is retained. + + :param resource_group_name: The name of the resource group to update. The name is case + insensitive. Required. + :type resource_group_name: str + :param parameters: Parameters supplied to update a resource group. Required. + :type parameters: IO + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: ResourceGroup or the result of cls(response) + :rtype: ~azure.mgmt.resource.resources.v2019_07_01.models.ResourceGroup + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace_async + async def update( + self, resource_group_name: str, parameters: Union[_models.ResourceGroupPatchable, IO], **kwargs: Any + ) -> _models.ResourceGroup: + """Updates a resource group. + + Resource groups can be updated through a simple PATCH operation to a group address. The format + of the request is the same as that for creating a resource group. If a field is unspecified, + the current value is retained. + + :param resource_group_name: The name of the resource group to update. The name is case + insensitive. Required. + :type resource_group_name: str + :param parameters: Parameters supplied to update a resource group. Is either a model type or a + IO type. Required. + :type parameters: ~azure.mgmt.resource.resources.v2019_07_01.models.ResourceGroupPatchable or + IO + :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. + Default value is None. + :paramtype content_type: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: ResourceGroup, or the result of cls(response) + :return: ResourceGroup or the result of cls(response) :rtype: ~azure.mgmt.resource.resources.v2019_07_01.models.ResourceGroup - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.ResourceGroup"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', "2019-07-01") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + api_version = kwargs.pop("api_version", _params.pop("api-version", "2019-07-01")) # type: str + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.ResourceGroup] - _json = self._serialize.body(parameters, 'ResourceGroupPatchable') + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(parameters, (IO, bytes)): + _content = parameters + else: + _json = self._serialize.body(parameters, "ResourceGroupPatchable") request = build_resource_groups_update_request( resource_group_name=resource_group_name, @@ -5725,60 +7553,117 @@ async def update( api_version=api_version, content_type=content_type, json=_json, - template_url=self.update.metadata['url'], + content=_content, + template_url=self.update.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) - deserialized = self._deserialize('ResourceGroup', pipeline_response) + deserialized = self._deserialize("ResourceGroup", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - update.metadata = {'url': "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}"} # type: ignore - + update.metadata = {"url": "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}"} # type: ignore - @distributed_trace_async + @overload async def export_template( self, resource_group_name: str, - parameters: "_models.ExportTemplateRequest", + parameters: _models.ExportTemplateRequest, + *, + content_type: str = "application/json", **kwargs: Any - ) -> "_models.ResourceGroupExportResult": + ) -> _models.ResourceGroupExportResult: """Captures the specified resource group as a template. - :param resource_group_name: The name of the resource group to export as a template. + :param resource_group_name: The name of the resource group to export as a template. Required. :type resource_group_name: str - :param parameters: Parameters for exporting the template. + :param parameters: Parameters for exporting the template. Required. :type parameters: ~azure.mgmt.resource.resources.v2019_07_01.models.ExportTemplateRequest + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: ResourceGroupExportResult or the result of cls(response) + :rtype: ~azure.mgmt.resource.resources.v2019_07_01.models.ResourceGroupExportResult + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + async def export_template( + self, resource_group_name: str, parameters: IO, *, content_type: str = "application/json", **kwargs: Any + ) -> _models.ResourceGroupExportResult: + """Captures the specified resource group as a template. + + :param resource_group_name: The name of the resource group to export as a template. Required. + :type resource_group_name: str + :param parameters: Parameters for exporting the template. Required. + :type parameters: IO + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: ResourceGroupExportResult or the result of cls(response) + :rtype: ~azure.mgmt.resource.resources.v2019_07_01.models.ResourceGroupExportResult + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace_async + async def export_template( + self, resource_group_name: str, parameters: Union[_models.ExportTemplateRequest, IO], **kwargs: Any + ) -> _models.ResourceGroupExportResult: + """Captures the specified resource group as a template. + + :param resource_group_name: The name of the resource group to export as a template. Required. + :type resource_group_name: str + :param parameters: Parameters for exporting the template. Is either a model type or a IO type. + Required. + :type parameters: ~azure.mgmt.resource.resources.v2019_07_01.models.ExportTemplateRequest or IO + :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. + Default value is None. + :paramtype content_type: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: ResourceGroupExportResult, or the result of cls(response) + :return: ResourceGroupExportResult or the result of cls(response) :rtype: ~azure.mgmt.resource.resources.v2019_07_01.models.ResourceGroupExportResult - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.ResourceGroupExportResult"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', "2019-07-01") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + api_version = kwargs.pop("api_version", _params.pop("api-version", "2019-07-01")) # type: str + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.ResourceGroupExportResult] - _json = self._serialize.body(parameters, 'ExportTemplateRequest') + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(parameters, (IO, bytes)): + _content = parameters + else: + _json = self._serialize.body(parameters, "ExportTemplateRequest") request = build_resource_groups_export_template_request( resource_group_name=resource_group_name, @@ -5786,39 +7671,37 @@ async def export_template( api_version=api_version, content_type=content_type, json=_json, - template_url=self.export_template.metadata['url'], + content=_content, + template_url=self.export_template.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) - deserialized = self._deserialize('ResourceGroupExportResult', pipeline_response) + deserialized = self._deserialize("ResourceGroupExportResult", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - export_template.metadata = {'url': "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/exportTemplate"} # type: ignore - + export_template.metadata = {"url": "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/exportTemplate"} # type: ignore @distributed_trace def list( - self, - filter: Optional[str] = None, - top: Optional[int] = None, - **kwargs: Any - ) -> AsyncIterable["_models.ResourceGroupListResult"]: + self, filter: Optional[str] = None, top: Optional[int] = None, **kwargs: Any + ) -> AsyncIterable["_models.ResourceGroup"]: """Gets all the resource groups for a subscription. :param filter: The filter to apply on the operation.:code:`
`:code:`
`You can filter by @@ -5829,40 +7712,48 @@ def list( Default value is None. :type top: int :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either ResourceGroupListResult or the result of - cls(response) + :return: An iterator like instance of either ResourceGroup or the result of cls(response) :rtype: - ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.resource.resources.v2019_07_01.models.ResourceGroupListResult] - :raises: ~azure.core.exceptions.HttpResponseError + ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.resource.resources.v2019_07_01.models.ResourceGroup] + :raises ~azure.core.exceptions.HttpResponseError: """ - api_version = kwargs.pop('api_version', "2019-07-01") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2019-07-01")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[_models.ResourceGroupListResult] - cls = kwargs.pop('cls', None) # type: ClsType["_models.ResourceGroupListResult"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) + def prepare_request(next_link=None): if not next_link: - + request = build_resource_groups_list_request( subscription_id=self._config.subscription_id, - api_version=api_version, filter=filter, top=top, - template_url=self.list.metadata['url'], + 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.url = self._client.format_url(request.url) # type: ignore else: - - request = build_resource_groups_list_request( - subscription_id=self._config.subscription_id, - template_url=next_link, - ) + # make call to next link with the client's api-version + _parsed_next_link = urlparse(next_link) + _next_request_params = case_insensitive_dict(parse_qs(_parsed_next_link.query)) + _next_request_params["api-version"] = self._config.api_version + request = HttpRequest("GET", urljoin(next_link, _parsed_next_link.path), params=_next_request_params) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore request.method = "GET" return request @@ -5876,10 +7767,8 @@ async def extract_data(pipeline_response): async def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) response = pipeline_response.http_response @@ -5889,75 +7778,75 @@ async def get_next(next_link=None): return pipeline_response + return AsyncItemPaged(get_next, extract_data) - return AsyncItemPaged( - get_next, extract_data - ) - list.metadata = {'url': "/subscriptions/{subscriptionId}/resourcegroups"} # type: ignore -class TagsOperations: - """TagsOperations async operations. + list.metadata = {"url": "/subscriptions/{subscriptionId}/resourcegroups"} # type: ignore - You should not instantiate this class directly. Instead, you should create a Client instance that - instantiates it for you and attaches it as an attribute. - :ivar models: Alias to model classes used in this operation group. - :type models: ~azure.mgmt.resource.resources.v2019_07_01.models - :param client: Client for service requests. - :param config: Configuration of service client. - :param serializer: An object model serializer. - :param deserializer: An object model deserializer. +class TagsOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. + + Instead, you should access the following operations through + :class:`~azure.mgmt.resource.resources.v2019_07_01.aio.ResourceManagementClient`'s + :attr:`tags` attribute. """ models = _models - def __init__(self, client, config, serializer, deserializer) -> None: - self._client = client - self._serialize = serializer - self._deserialize = deserializer - self._config = config + def __init__(self, *args, **kwargs) -> None: + input_args = list(args) + self._client = input_args.pop(0) if input_args else kwargs.pop("client") + self._config = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") @distributed_trace_async async def delete_value( # pylint: disable=inconsistent-return-statements - self, - tag_name: str, - tag_value: str, - **kwargs: Any + self, tag_name: str, tag_value: str, **kwargs: Any ) -> None: """Deletes a tag value. - :param tag_name: The name of the tag. + :param tag_name: The name of the tag. Required. :type tag_name: str - :param tag_value: The value of the tag to delete. + :param tag_value: The value of the tag to delete. Required. :type tag_value: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: None, or the result of cls(response) + :return: None or the result of cls(response) :rtype: None - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType[None] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + 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', "2019-07-01") # type: str + api_version = kwargs.pop("api_version", _params.pop("api-version", "2019-07-01")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[None] - request = build_tags_delete_value_request( tag_name=tag_name, tag_value=tag_value, subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.delete_value.metadata['url'], + template_url=self.delete_value.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200, 204]: @@ -5967,51 +7856,51 @@ async def delete_value( # pylint: disable=inconsistent-return-statements if cls: return cls(pipeline_response, None, {}) - delete_value.metadata = {'url': "/subscriptions/{subscriptionId}/tagNames/{tagName}/tagValues/{tagValue}"} # type: ignore - + delete_value.metadata = {"url": "/subscriptions/{subscriptionId}/tagNames/{tagName}/tagValues/{tagValue}"} # type: ignore @distributed_trace_async - async def create_or_update_value( - self, - tag_name: str, - tag_value: str, - **kwargs: Any - ) -> "_models.TagValue": + async def create_or_update_value(self, tag_name: str, tag_value: str, **kwargs: Any) -> _models.TagValue: """Creates a tag value. The name of the tag must already exist. - :param tag_name: The name of the tag. + :param tag_name: The name of the tag. Required. :type tag_name: str - :param tag_value: The value of the tag to create. + :param tag_value: The value of the tag to create. Required. :type tag_value: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: TagValue, or the result of cls(response) + :return: TagValue or the result of cls(response) :rtype: ~azure.mgmt.resource.resources.v2019_07_01.models.TagValue - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.TagValue"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) - api_version = kwargs.pop('api_version', "2019-07-01") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2019-07-01")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[_models.TagValue] - request = build_tags_create_or_update_value_request( tag_name=tag_name, tag_value=tag_value, subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.create_or_update_value.metadata['url'], + template_url=self.create_or_update_value.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200, 201]: @@ -6019,61 +7908,62 @@ async def create_or_update_value( raise HttpResponseError(response=response, error_format=ARMErrorFormat) if response.status_code == 200: - deserialized = self._deserialize('TagValue', pipeline_response) + deserialized = self._deserialize("TagValue", pipeline_response) if response.status_code == 201: - deserialized = self._deserialize('TagValue', pipeline_response) + deserialized = self._deserialize("TagValue", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - create_or_update_value.metadata = {'url': "/subscriptions/{subscriptionId}/tagNames/{tagName}/tagValues/{tagValue}"} # type: ignore - + create_or_update_value.metadata = {"url": "/subscriptions/{subscriptionId}/tagNames/{tagName}/tagValues/{tagValue}"} # type: ignore @distributed_trace_async - async def create_or_update( - self, - tag_name: str, - **kwargs: Any - ) -> "_models.TagDetails": + async def create_or_update(self, tag_name: str, **kwargs: Any) -> _models.TagDetails: """Creates a tag in the subscription. The tag name can have a maximum of 512 characters and is case insensitive. Tag names created by Azure have prefixes of microsoft, azure, or windows. You cannot create tags with one of these prefixes. - :param tag_name: The name of the tag to create. + :param tag_name: The name of the tag to create. Required. :type tag_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: TagDetails, or the result of cls(response) + :return: TagDetails or the result of cls(response) :rtype: ~azure.mgmt.resource.resources.v2019_07_01.models.TagDetails - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.TagDetails"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) - api_version = kwargs.pop('api_version', "2019-07-01") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2019-07-01")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[_models.TagDetails] - request = build_tags_create_or_update_request( tag_name=tag_name, subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.create_or_update.metadata['url'], + template_url=self.create_or_update.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200, 201]: @@ -6081,59 +7971,60 @@ async def create_or_update( raise HttpResponseError(response=response, error_format=ARMErrorFormat) if response.status_code == 200: - deserialized = self._deserialize('TagDetails', pipeline_response) + deserialized = self._deserialize("TagDetails", pipeline_response) if response.status_code == 201: - deserialized = self._deserialize('TagDetails', pipeline_response) + deserialized = self._deserialize("TagDetails", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - create_or_update.metadata = {'url': "/subscriptions/{subscriptionId}/tagNames/{tagName}"} # type: ignore - + create_or_update.metadata = {"url": "/subscriptions/{subscriptionId}/tagNames/{tagName}"} # type: ignore @distributed_trace_async - async def delete( # pylint: disable=inconsistent-return-statements - self, - tag_name: str, - **kwargs: Any - ) -> None: + async def delete(self, tag_name: str, **kwargs: Any) -> None: # pylint: disable=inconsistent-return-statements """Deletes a tag from the subscription. You must remove all values from a resource tag before you can delete it. - :param tag_name: The name of the tag. + :param tag_name: The name of the tag. Required. :type tag_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: None, or the result of cls(response) + :return: None or the result of cls(response) :rtype: None - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType[None] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) - api_version = kwargs.pop('api_version', "2019-07-01") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2019-07-01")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[None] - request = build_tags_delete_request( tag_name=tag_name, subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.delete.metadata['url'], + template_url=self.delete.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200, 204]: @@ -6143,48 +8034,53 @@ async def delete( # pylint: disable=inconsistent-return-statements if cls: return cls(pipeline_response, None, {}) - delete.metadata = {'url': "/subscriptions/{subscriptionId}/tagNames/{tagName}"} # type: ignore - + delete.metadata = {"url": "/subscriptions/{subscriptionId}/tagNames/{tagName}"} # type: ignore @distributed_trace - def list( - self, - **kwargs: Any - ) -> AsyncIterable["_models.TagsListResult"]: + def list(self, **kwargs: Any) -> AsyncIterable["_models.TagDetails"]: """Gets the names and values of all resource tags that are defined in a subscription. :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either TagsListResult or the result of cls(response) + :return: An iterator like instance of either TagDetails or the result of cls(response) :rtype: - ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.resource.resources.v2019_07_01.models.TagsListResult] - :raises: ~azure.core.exceptions.HttpResponseError + ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.resource.resources.v2019_07_01.models.TagDetails] + :raises ~azure.core.exceptions.HttpResponseError: """ - api_version = kwargs.pop('api_version', "2019-07-01") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2019-07-01")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[_models.TagsListResult] - cls = kwargs.pop('cls', None) # type: ClsType["_models.TagsListResult"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) + def prepare_request(next_link=None): if not next_link: - + request = build_tags_list_request( subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.list.metadata['url'], + template_url=self.list.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore else: - - request = build_tags_list_request( - subscription_id=self._config.subscription_id, - template_url=next_link, - ) + # make call to next link with the client's api-version + _parsed_next_link = urlparse(next_link) + _next_request_params = case_insensitive_dict(parse_qs(_parsed_next_link.query)) + _next_request_params["api-version"] = self._config.api_version + request = HttpRequest("GET", urljoin(next_link, _parsed_next_link.path), params=_next_request_params) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore request.method = "GET" return request @@ -6198,10 +8094,8 @@ async def extract_data(pipeline_response): async def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) response = pipeline_response.http_response @@ -6211,146 +8105,147 @@ async def get_next(next_link=None): return pipeline_response + return AsyncItemPaged(get_next, extract_data) + + list.metadata = {"url": "/subscriptions/{subscriptionId}/tagNames"} # type: ignore - return AsyncItemPaged( - get_next, extract_data - ) - list.metadata = {'url': "/subscriptions/{subscriptionId}/tagNames"} # type: ignore -class DeploymentOperationsOperations: - """DeploymentOperationsOperations async operations. - You should not instantiate this class directly. Instead, you should create a Client instance that - instantiates it for you and attaches it as an attribute. +class DeploymentOperationsOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. - :ivar models: Alias to model classes used in this operation group. - :type models: ~azure.mgmt.resource.resources.v2019_07_01.models - :param client: Client for service requests. - :param config: Configuration of service client. - :param serializer: An object model serializer. - :param deserializer: An object model deserializer. + Instead, you should access the following operations through + :class:`~azure.mgmt.resource.resources.v2019_07_01.aio.ResourceManagementClient`'s + :attr:`deployment_operations` attribute. """ models = _models - def __init__(self, client, config, serializer, deserializer) -> None: - self._client = client - self._serialize = serializer - self._deserialize = deserializer - self._config = config + def __init__(self, *args, **kwargs) -> None: + input_args = list(args) + self._client = input_args.pop(0) if input_args else kwargs.pop("client") + self._config = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") @distributed_trace_async async def get_at_scope( - self, - scope: str, - deployment_name: str, - operation_id: str, - **kwargs: Any - ) -> "_models.DeploymentOperation": + self, scope: str, deployment_name: str, operation_id: str, **kwargs: Any + ) -> _models.DeploymentOperation: """Gets a deployments operation. - :param scope: The scope of a deployment. + :param scope: The scope of a deployment. Required. :type scope: str - :param deployment_name: The name of the deployment. + :param deployment_name: The name of the deployment. Required. :type deployment_name: str - :param operation_id: The ID of the operation to get. + :param operation_id: The ID of the operation to get. Required. :type operation_id: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: DeploymentOperation, or the result of cls(response) + :return: DeploymentOperation or the result of cls(response) :rtype: ~azure.mgmt.resource.resources.v2019_07_01.models.DeploymentOperation - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.DeploymentOperation"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) - api_version = kwargs.pop('api_version', "2019-07-01") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2019-07-01")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[_models.DeploymentOperation] - request = build_deployment_operations_get_at_scope_request( scope=scope, deployment_name=deployment_name, operation_id=operation_id, api_version=api_version, - template_url=self.get_at_scope.metadata['url'], + template_url=self.get_at_scope.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) - deserialized = self._deserialize('DeploymentOperation', pipeline_response) + deserialized = self._deserialize("DeploymentOperation", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - get_at_scope.metadata = {'url': "/{scope}/providers/Microsoft.Resources/deployments/{deploymentName}/operations/{operationId}"} # type: ignore - + get_at_scope.metadata = {"url": "/{scope}/providers/Microsoft.Resources/deployments/{deploymentName}/operations/{operationId}"} # type: ignore @distributed_trace def list_at_scope( - self, - scope: str, - deployment_name: str, - top: Optional[int] = None, - **kwargs: Any - ) -> AsyncIterable["_models.DeploymentOperationsListResult"]: + self, scope: str, deployment_name: str, top: Optional[int] = None, **kwargs: Any + ) -> AsyncIterable["_models.DeploymentOperation"]: """Gets all deployments operations for a deployment. - :param scope: The scope of a deployment. + :param scope: The scope of a deployment. Required. :type scope: str - :param deployment_name: The name of the deployment. + :param deployment_name: The name of the deployment. Required. :type deployment_name: str :param top: The number of results to return. Default value is None. :type top: int :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either DeploymentOperationsListResult or the result of - cls(response) + :return: An iterator like instance of either DeploymentOperation or the result of cls(response) :rtype: - ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.resource.resources.v2019_07_01.models.DeploymentOperationsListResult] - :raises: ~azure.core.exceptions.HttpResponseError + ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.resource.resources.v2019_07_01.models.DeploymentOperation] + :raises ~azure.core.exceptions.HttpResponseError: """ - api_version = kwargs.pop('api_version', "2019-07-01") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2019-07-01")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[_models.DeploymentOperationsListResult] - cls = kwargs.pop('cls', None) # type: ClsType["_models.DeploymentOperationsListResult"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) + def prepare_request(next_link=None): if not next_link: - + request = build_deployment_operations_list_at_scope_request( scope=scope, deployment_name=deployment_name, - api_version=api_version, top=top, - template_url=self.list_at_scope.metadata['url'], + api_version=api_version, + template_url=self.list_at_scope.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore else: - - request = build_deployment_operations_list_at_scope_request( - scope=scope, - deployment_name=deployment_name, - template_url=next_link, - ) + # make call to next link with the client's api-version + _parsed_next_link = urlparse(next_link) + _next_request_params = case_insensitive_dict(parse_qs(_parsed_next_link.query)) + _next_request_params["api-version"] = self._config.api_version + request = HttpRequest("GET", urljoin(next_link, _parsed_next_link.path), params=_next_request_params) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore request.method = "GET" return request @@ -6364,10 +8259,8 @@ async def extract_data(pipeline_response): async def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) response = pipeline_response.http_response @@ -6377,116 +8270,121 @@ async def get_next(next_link=None): return pipeline_response + return AsyncItemPaged(get_next, extract_data) - return AsyncItemPaged( - get_next, extract_data - ) - list_at_scope.metadata = {'url': "/{scope}/providers/Microsoft.Resources/deployments/{deploymentName}/operations"} # type: ignore + list_at_scope.metadata = {"url": "/{scope}/providers/Microsoft.Resources/deployments/{deploymentName}/operations"} # type: ignore @distributed_trace_async async def get_at_tenant_scope( - self, - deployment_name: str, - operation_id: str, - **kwargs: Any - ) -> "_models.DeploymentOperation": + self, deployment_name: str, operation_id: str, **kwargs: Any + ) -> _models.DeploymentOperation: """Gets a deployments operation. - :param deployment_name: The name of the deployment. + :param deployment_name: The name of the deployment. Required. :type deployment_name: str - :param operation_id: The ID of the operation to get. + :param operation_id: The ID of the operation to get. Required. :type operation_id: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: DeploymentOperation, or the result of cls(response) + :return: DeploymentOperation or the result of cls(response) :rtype: ~azure.mgmt.resource.resources.v2019_07_01.models.DeploymentOperation - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.DeploymentOperation"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + 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', "2019-07-01") # type: str + api_version = kwargs.pop("api_version", _params.pop("api-version", "2019-07-01")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[_models.DeploymentOperation] - request = build_deployment_operations_get_at_tenant_scope_request( deployment_name=deployment_name, operation_id=operation_id, api_version=api_version, - template_url=self.get_at_tenant_scope.metadata['url'], + template_url=self.get_at_tenant_scope.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) - deserialized = self._deserialize('DeploymentOperation', pipeline_response) + deserialized = self._deserialize("DeploymentOperation", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - get_at_tenant_scope.metadata = {'url': "/providers/Microsoft.Resources/deployments/{deploymentName}/operations/{operationId}"} # type: ignore - + get_at_tenant_scope.metadata = {"url": "/providers/Microsoft.Resources/deployments/{deploymentName}/operations/{operationId}"} # type: ignore @distributed_trace def list_at_tenant_scope( - self, - deployment_name: str, - top: Optional[int] = None, - **kwargs: Any - ) -> AsyncIterable["_models.DeploymentOperationsListResult"]: + self, deployment_name: str, top: Optional[int] = None, **kwargs: Any + ) -> AsyncIterable["_models.DeploymentOperation"]: """Gets all deployments operations for a deployment. - :param deployment_name: The name of the deployment. + :param deployment_name: The name of the deployment. Required. :type deployment_name: str :param top: The number of results to return. Default value is None. :type top: int :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either DeploymentOperationsListResult or the result of - cls(response) + :return: An iterator like instance of either DeploymentOperation or the result of cls(response) :rtype: - ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.resource.resources.v2019_07_01.models.DeploymentOperationsListResult] - :raises: ~azure.core.exceptions.HttpResponseError + ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.resource.resources.v2019_07_01.models.DeploymentOperation] + :raises ~azure.core.exceptions.HttpResponseError: """ - api_version = kwargs.pop('api_version', "2019-07-01") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2019-07-01")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[_models.DeploymentOperationsListResult] - cls = kwargs.pop('cls', None) # type: ClsType["_models.DeploymentOperationsListResult"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) + def prepare_request(next_link=None): if not next_link: - + request = build_deployment_operations_list_at_tenant_scope_request( deployment_name=deployment_name, - api_version=api_version, top=top, - template_url=self.list_at_tenant_scope.metadata['url'], + api_version=api_version, + template_url=self.list_at_tenant_scope.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore else: - - request = build_deployment_operations_list_at_tenant_scope_request( - deployment_name=deployment_name, - template_url=next_link, - ) + # make call to next link with the client's api-version + _parsed_next_link = urlparse(next_link) + _next_request_params = case_insensitive_dict(parse_qs(_parsed_next_link.query)) + _next_request_params["api-version"] = self._config.api_version + request = HttpRequest("GET", urljoin(next_link, _parsed_next_link.path), params=_next_request_params) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore request.method = "GET" return request @@ -6500,10 +8398,8 @@ async def extract_data(pipeline_response): async def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) response = pipeline_response.http_response @@ -6513,125 +8409,127 @@ async def get_next(next_link=None): return pipeline_response + return AsyncItemPaged(get_next, extract_data) - return AsyncItemPaged( - get_next, extract_data - ) - list_at_tenant_scope.metadata = {'url': "/providers/Microsoft.Resources/deployments/{deploymentName}/operations"} # type: ignore + list_at_tenant_scope.metadata = {"url": "/providers/Microsoft.Resources/deployments/{deploymentName}/operations"} # type: ignore @distributed_trace_async async def get_at_management_group_scope( - self, - group_id: str, - deployment_name: str, - operation_id: str, - **kwargs: Any - ) -> "_models.DeploymentOperation": + self, group_id: str, deployment_name: str, operation_id: str, **kwargs: Any + ) -> _models.DeploymentOperation: """Gets a deployments operation. - :param group_id: The management group ID. + :param group_id: The management group ID. Required. :type group_id: str - :param deployment_name: The name of the deployment. + :param deployment_name: The name of the deployment. Required. :type deployment_name: str - :param operation_id: The ID of the operation to get. + :param operation_id: The ID of the operation to get. Required. :type operation_id: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: DeploymentOperation, or the result of cls(response) + :return: DeploymentOperation or the result of cls(response) :rtype: ~azure.mgmt.resource.resources.v2019_07_01.models.DeploymentOperation - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.DeploymentOperation"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + 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', "2019-07-01") # type: str + api_version = kwargs.pop("api_version", _params.pop("api-version", "2019-07-01")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[_models.DeploymentOperation] - request = build_deployment_operations_get_at_management_group_scope_request( group_id=group_id, deployment_name=deployment_name, operation_id=operation_id, api_version=api_version, - template_url=self.get_at_management_group_scope.metadata['url'], + template_url=self.get_at_management_group_scope.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) - deserialized = self._deserialize('DeploymentOperation', pipeline_response) + deserialized = self._deserialize("DeploymentOperation", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - get_at_management_group_scope.metadata = {'url': "/providers/Microsoft.Management/managementGroups/{groupId}/providers/Microsoft.Resources/deployments/{deploymentName}/operations/{operationId}"} # type: ignore - + get_at_management_group_scope.metadata = {"url": "/providers/Microsoft.Management/managementGroups/{groupId}/providers/Microsoft.Resources/deployments/{deploymentName}/operations/{operationId}"} # type: ignore @distributed_trace def list_at_management_group_scope( - self, - group_id: str, - deployment_name: str, - top: Optional[int] = None, - **kwargs: Any - ) -> AsyncIterable["_models.DeploymentOperationsListResult"]: + self, group_id: str, deployment_name: str, top: Optional[int] = None, **kwargs: Any + ) -> AsyncIterable["_models.DeploymentOperation"]: """Gets all deployments operations for a deployment. - :param group_id: The management group ID. + :param group_id: The management group ID. Required. :type group_id: str - :param deployment_name: The name of the deployment. + :param deployment_name: The name of the deployment. Required. :type deployment_name: str :param top: The number of results to return. Default value is None. :type top: int :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either DeploymentOperationsListResult or the result of - cls(response) + :return: An iterator like instance of either DeploymentOperation or the result of cls(response) :rtype: - ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.resource.resources.v2019_07_01.models.DeploymentOperationsListResult] - :raises: ~azure.core.exceptions.HttpResponseError + ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.resource.resources.v2019_07_01.models.DeploymentOperation] + :raises ~azure.core.exceptions.HttpResponseError: """ - api_version = kwargs.pop('api_version', "2019-07-01") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2019-07-01")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[_models.DeploymentOperationsListResult] - cls = kwargs.pop('cls', None) # type: ClsType["_models.DeploymentOperationsListResult"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) + def prepare_request(next_link=None): if not next_link: - + request = build_deployment_operations_list_at_management_group_scope_request( group_id=group_id, deployment_name=deployment_name, - api_version=api_version, top=top, - template_url=self.list_at_management_group_scope.metadata['url'], + api_version=api_version, + template_url=self.list_at_management_group_scope.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore else: - - request = build_deployment_operations_list_at_management_group_scope_request( - group_id=group_id, - deployment_name=deployment_name, - template_url=next_link, - ) + # make call to next link with the client's api-version + _parsed_next_link = urlparse(next_link) + _next_request_params = case_insensitive_dict(parse_qs(_parsed_next_link.query)) + _next_request_params["api-version"] = self._config.api_version + request = HttpRequest("GET", urljoin(next_link, _parsed_next_link.path), params=_next_request_params) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore request.method = "GET" return request @@ -6645,10 +8543,8 @@ async def extract_data(pipeline_response): async def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) response = pipeline_response.http_response @@ -6658,119 +8554,123 @@ async def get_next(next_link=None): return pipeline_response + return AsyncItemPaged(get_next, extract_data) - return AsyncItemPaged( - get_next, extract_data - ) - list_at_management_group_scope.metadata = {'url': "/providers/Microsoft.Management/managementGroups/{groupId}/providers/Microsoft.Resources/deployments/{deploymentName}/operations"} # type: ignore + list_at_management_group_scope.metadata = {"url": "/providers/Microsoft.Management/managementGroups/{groupId}/providers/Microsoft.Resources/deployments/{deploymentName}/operations"} # type: ignore @distributed_trace_async async def get_at_subscription_scope( - self, - deployment_name: str, - operation_id: str, - **kwargs: Any - ) -> "_models.DeploymentOperation": + self, deployment_name: str, operation_id: str, **kwargs: Any + ) -> _models.DeploymentOperation: """Gets a deployments operation. - :param deployment_name: The name of the deployment. + :param deployment_name: The name of the deployment. Required. :type deployment_name: str - :param operation_id: The ID of the operation to get. + :param operation_id: The ID of the operation to get. Required. :type operation_id: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: DeploymentOperation, or the result of cls(response) + :return: DeploymentOperation or the result of cls(response) :rtype: ~azure.mgmt.resource.resources.v2019_07_01.models.DeploymentOperation - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.DeploymentOperation"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) - api_version = kwargs.pop('api_version', "2019-07-01") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2019-07-01")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[_models.DeploymentOperation] - request = build_deployment_operations_get_at_subscription_scope_request( deployment_name=deployment_name, operation_id=operation_id, subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.get_at_subscription_scope.metadata['url'], + template_url=self.get_at_subscription_scope.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) - deserialized = self._deserialize('DeploymentOperation', pipeline_response) + deserialized = self._deserialize("DeploymentOperation", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - get_at_subscription_scope.metadata = {'url': "/subscriptions/{subscriptionId}/providers/Microsoft.Resources/deployments/{deploymentName}/operations/{operationId}"} # type: ignore - + get_at_subscription_scope.metadata = {"url": "/subscriptions/{subscriptionId}/providers/Microsoft.Resources/deployments/{deploymentName}/operations/{operationId}"} # type: ignore @distributed_trace def list_at_subscription_scope( - self, - deployment_name: str, - top: Optional[int] = None, - **kwargs: Any - ) -> AsyncIterable["_models.DeploymentOperationsListResult"]: + self, deployment_name: str, top: Optional[int] = None, **kwargs: Any + ) -> AsyncIterable["_models.DeploymentOperation"]: """Gets all deployments operations for a deployment. - :param deployment_name: The name of the deployment. + :param deployment_name: The name of the deployment. Required. :type deployment_name: str :param top: The number of results to return. Default value is None. :type top: int :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either DeploymentOperationsListResult or the result of - cls(response) + :return: An iterator like instance of either DeploymentOperation or the result of cls(response) :rtype: - ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.resource.resources.v2019_07_01.models.DeploymentOperationsListResult] - :raises: ~azure.core.exceptions.HttpResponseError + ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.resource.resources.v2019_07_01.models.DeploymentOperation] + :raises ~azure.core.exceptions.HttpResponseError: """ - api_version = kwargs.pop('api_version', "2019-07-01") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2019-07-01")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[_models.DeploymentOperationsListResult] - cls = kwargs.pop('cls', None) # type: ClsType["_models.DeploymentOperationsListResult"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) + def prepare_request(next_link=None): if not next_link: - + request = build_deployment_operations_list_at_subscription_scope_request( deployment_name=deployment_name, subscription_id=self._config.subscription_id, - api_version=api_version, top=top, - template_url=self.list_at_subscription_scope.metadata['url'], + api_version=api_version, + template_url=self.list_at_subscription_scope.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore else: - - request = build_deployment_operations_list_at_subscription_scope_request( - deployment_name=deployment_name, - subscription_id=self._config.subscription_id, - template_url=next_link, - ) + # make call to next link with the client's api-version + _parsed_next_link = urlparse(next_link) + _next_request_params = case_insensitive_dict(parse_qs(_parsed_next_link.query)) + _next_request_params["api-version"] = self._config.api_version + request = HttpRequest("GET", urljoin(next_link, _parsed_next_link.path), params=_next_request_params) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore request.method = "GET" return request @@ -6784,10 +8684,8 @@ async def extract_data(pipeline_response): async def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) response = pipeline_response.http_response @@ -6797,128 +8695,131 @@ async def get_next(next_link=None): return pipeline_response + return AsyncItemPaged(get_next, extract_data) - return AsyncItemPaged( - get_next, extract_data - ) - list_at_subscription_scope.metadata = {'url': "/subscriptions/{subscriptionId}/providers/Microsoft.Resources/deployments/{deploymentName}/operations"} # type: ignore + list_at_subscription_scope.metadata = {"url": "/subscriptions/{subscriptionId}/providers/Microsoft.Resources/deployments/{deploymentName}/operations"} # type: ignore @distributed_trace_async async def get( - self, - resource_group_name: str, - deployment_name: str, - operation_id: str, - **kwargs: Any - ) -> "_models.DeploymentOperation": + self, resource_group_name: str, deployment_name: str, operation_id: str, **kwargs: Any + ) -> _models.DeploymentOperation: """Gets a deployments operation. :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. :type resource_group_name: str - :param deployment_name: The name of the deployment. + :param deployment_name: The name of the deployment. Required. :type deployment_name: str - :param operation_id: The ID of the operation to get. + :param operation_id: The ID of the operation to get. Required. :type operation_id: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: DeploymentOperation, or the result of cls(response) + :return: DeploymentOperation or the result of cls(response) :rtype: ~azure.mgmt.resource.resources.v2019_07_01.models.DeploymentOperation - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.DeploymentOperation"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + 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', "2019-07-01") # type: str + api_version = kwargs.pop("api_version", _params.pop("api-version", "2019-07-01")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[_models.DeploymentOperation] - request = build_deployment_operations_get_request( resource_group_name=resource_group_name, deployment_name=deployment_name, operation_id=operation_id, subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.get.metadata['url'], + template_url=self.get.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) - deserialized = self._deserialize('DeploymentOperation', pipeline_response) + deserialized = self._deserialize("DeploymentOperation", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - get.metadata = {'url': "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/deployments/{deploymentName}/operations/{operationId}"} # type: ignore - + get.metadata = {"url": "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/deployments/{deploymentName}/operations/{operationId}"} # type: ignore @distributed_trace def list( - self, - resource_group_name: str, - deployment_name: str, - top: Optional[int] = None, - **kwargs: Any - ) -> AsyncIterable["_models.DeploymentOperationsListResult"]: + self, resource_group_name: str, deployment_name: str, top: Optional[int] = None, **kwargs: Any + ) -> AsyncIterable["_models.DeploymentOperation"]: """Gets all deployments operations for a deployment. :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. :type resource_group_name: str - :param deployment_name: The name of the deployment. + :param deployment_name: The name of the deployment. Required. :type deployment_name: str :param top: The number of results to return. Default value is None. :type top: int :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either DeploymentOperationsListResult or the result of - cls(response) + :return: An iterator like instance of either DeploymentOperation or the result of cls(response) :rtype: - ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.resource.resources.v2019_07_01.models.DeploymentOperationsListResult] - :raises: ~azure.core.exceptions.HttpResponseError + ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.resource.resources.v2019_07_01.models.DeploymentOperation] + :raises ~azure.core.exceptions.HttpResponseError: """ - api_version = kwargs.pop('api_version', "2019-07-01") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2019-07-01")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[_models.DeploymentOperationsListResult] - cls = kwargs.pop('cls', None) # type: ClsType["_models.DeploymentOperationsListResult"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) + def prepare_request(next_link=None): if not next_link: - + request = build_deployment_operations_list_request( resource_group_name=resource_group_name, deployment_name=deployment_name, subscription_id=self._config.subscription_id, - api_version=api_version, top=top, - template_url=self.list.metadata['url'], + 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.url = self._client.format_url(request.url) # type: ignore else: - - request = build_deployment_operations_list_request( - resource_group_name=resource_group_name, - deployment_name=deployment_name, - subscription_id=self._config.subscription_id, - template_url=next_link, - ) + # make call to next link with the client's api-version + _parsed_next_link = urlparse(next_link) + _next_request_params = case_insensitive_dict(parse_qs(_parsed_next_link.query)) + _next_request_params["api-version"] = self._config.api_version + request = HttpRequest("GET", urljoin(next_link, _parsed_next_link.path), params=_next_request_params) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore request.method = "GET" return request @@ -6932,10 +8833,8 @@ async def extract_data(pipeline_response): async def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) response = pipeline_response.http_response @@ -6945,8 +8844,6 @@ async def get_next(next_link=None): return pipeline_response + return AsyncItemPaged(get_next, extract_data) - return AsyncItemPaged( - get_next, extract_data - ) - list.metadata = {'url': "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/deployments/{deploymentName}/operations"} # type: ignore + list.metadata = {"url": "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/deployments/{deploymentName}/operations"} # type: ignore diff --git a/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/resources/v2019_07_01/aio/operations/_patch.py b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/resources/v2019_07_01/aio/operations/_patch.py new file mode 100644 index 0000000000000..f7dd32510333d --- /dev/null +++ b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/resources/v2019_07_01/aio/operations/_patch.py @@ -0,0 +1,20 @@ +# ------------------------------------ +# Copyright (c) Microsoft Corporation. +# Licensed under the MIT License. +# ------------------------------------ +"""Customize generated code here. + +Follow our quickstart for examples: https://aka.ms/azsdk/python/dpcodegen/python/customize +""" +from typing import List + +__all__: List[str] = [] # Add all objects you want publicly available to users at this package level + + +def patch_sdk(): + """Do not remove from this file. + + `patch_sdk` is a last resort escape hatch that allows you to do customizations + you can't accomplish using the techniques described in + https://aka.ms/azsdk/python/dpcodegen/python/customize + """ diff --git a/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/resources/v2019_07_01/models/__init__.py b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/resources/v2019_07_01/models/__init__.py index 48b5c2f213c05..827767bc3e474 100644 --- a/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/resources/v2019_07_01/models/__init__.py +++ b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/resources/v2019_07_01/models/__init__.py @@ -68,82 +68,84 @@ from ._models_py3 import WhatIfPropertyChange from ._models_py3 import ZoneMapping - -from ._resource_management_client_enums import ( - ChangeType, - DeploymentMode, - OnErrorDeploymentType, - PropertyChangeType, - ResourceIdentityType, - WhatIfResultFormat, -) +from ._resource_management_client_enums import ChangeType +from ._resource_management_client_enums import DeploymentMode +from ._resource_management_client_enums import OnErrorDeploymentType +from ._resource_management_client_enums import PropertyChangeType +from ._resource_management_client_enums import ResourceIdentityType +from ._resource_management_client_enums import WhatIfResultFormat +from ._patch import __all__ as _patch_all +from ._patch import * # type: ignore # pylint: disable=unused-wildcard-import +from ._patch import patch_sdk as _patch_sdk __all__ = [ - 'AliasPathType', - 'AliasType', - 'BasicDependency', - 'ComponentsSgqdofSchemasIdentityPropertiesUserassignedidentitiesAdditionalproperties', - 'DebugSetting', - 'Dependency', - 'Deployment', - 'DeploymentExportResult', - 'DeploymentExtended', - 'DeploymentExtendedFilter', - 'DeploymentListResult', - 'DeploymentOperation', - 'DeploymentOperationProperties', - 'DeploymentOperationsListResult', - 'DeploymentProperties', - 'DeploymentPropertiesExtended', - 'DeploymentValidateResult', - 'DeploymentWhatIf', - 'DeploymentWhatIfProperties', - 'DeploymentWhatIfSettings', - 'ErrorAdditionalInfo', - 'ErrorResponse', - 'ExportTemplateRequest', - 'GenericResource', - 'GenericResourceExpanded', - 'GenericResourceFilter', - 'HttpMessage', - 'Identity', - 'OnErrorDeployment', - 'OnErrorDeploymentExtended', - 'Operation', - 'OperationDisplay', - 'OperationListResult', - 'ParametersLink', - 'Plan', - 'Provider', - 'ProviderListResult', - 'ProviderResourceType', - 'Resource', - 'ResourceGroup', - 'ResourceGroupExportResult', - 'ResourceGroupFilter', - 'ResourceGroupListResult', - 'ResourceGroupPatchable', - 'ResourceGroupProperties', - 'ResourceListResult', - 'ResourceProviderOperationDisplayProperties', - 'ResourcesMoveInfo', - 'Sku', - 'SubResource', - 'TagCount', - 'TagDetails', - 'TagValue', - 'TagsListResult', - 'TargetResource', - 'TemplateHashResult', - 'TemplateLink', - 'WhatIfChange', - 'WhatIfOperationResult', - 'WhatIfPropertyChange', - 'ZoneMapping', - 'ChangeType', - 'DeploymentMode', - 'OnErrorDeploymentType', - 'PropertyChangeType', - 'ResourceIdentityType', - 'WhatIfResultFormat', + "AliasPathType", + "AliasType", + "BasicDependency", + "ComponentsSgqdofSchemasIdentityPropertiesUserassignedidentitiesAdditionalproperties", + "DebugSetting", + "Dependency", + "Deployment", + "DeploymentExportResult", + "DeploymentExtended", + "DeploymentExtendedFilter", + "DeploymentListResult", + "DeploymentOperation", + "DeploymentOperationProperties", + "DeploymentOperationsListResult", + "DeploymentProperties", + "DeploymentPropertiesExtended", + "DeploymentValidateResult", + "DeploymentWhatIf", + "DeploymentWhatIfProperties", + "DeploymentWhatIfSettings", + "ErrorAdditionalInfo", + "ErrorResponse", + "ExportTemplateRequest", + "GenericResource", + "GenericResourceExpanded", + "GenericResourceFilter", + "HttpMessage", + "Identity", + "OnErrorDeployment", + "OnErrorDeploymentExtended", + "Operation", + "OperationDisplay", + "OperationListResult", + "ParametersLink", + "Plan", + "Provider", + "ProviderListResult", + "ProviderResourceType", + "Resource", + "ResourceGroup", + "ResourceGroupExportResult", + "ResourceGroupFilter", + "ResourceGroupListResult", + "ResourceGroupPatchable", + "ResourceGroupProperties", + "ResourceListResult", + "ResourceProviderOperationDisplayProperties", + "ResourcesMoveInfo", + "Sku", + "SubResource", + "TagCount", + "TagDetails", + "TagValue", + "TagsListResult", + "TargetResource", + "TemplateHashResult", + "TemplateLink", + "WhatIfChange", + "WhatIfOperationResult", + "WhatIfPropertyChange", + "ZoneMapping", + "ChangeType", + "DeploymentMode", + "OnErrorDeploymentType", + "PropertyChangeType", + "ResourceIdentityType", + "WhatIfResultFormat", ] +__all__.extend([p for p in _patch_all if p not in __all__]) +_patch_sdk() diff --git a/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/resources/v2019_07_01/models/_models_py3.py b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/resources/v2019_07_01/models/_models_py3.py index dcb5b99b48e74..f0176c7c58ac4 100644 --- a/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/resources/v2019_07_01/models/_models_py3.py +++ b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/resources/v2019_07_01/models/_models_py3.py @@ -1,4 +1,5 @@ # coding=utf-8 +# pylint: disable=too-many-lines # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. # Licensed under the MIT License. See License.txt in the project root for license information. @@ -6,14 +7,22 @@ # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -from typing import Any, Dict, List, Optional, Union +import sys +from typing import Any, Dict, List, Optional, TYPE_CHECKING, Union -import msrest.serialization +from ... import _serialization -from ._resource_management_client_enums import * +if TYPE_CHECKING: + # pylint: disable=unused-import,ungrouped-imports + from .. import models as _models +if sys.version_info >= (3, 9): + from collections.abc import MutableMapping +else: + from typing import MutableMapping # type: ignore # pylint: disable=ungrouped-imports +JSON = MutableMapping[str, Any] # pylint: disable=unsubscriptable-object -class AliasPathType(msrest.serialization.Model): +class AliasPathType(_serialization.Model): """The type of the paths for alias. :ivar path: The path of an alias. @@ -23,29 +32,23 @@ class AliasPathType(msrest.serialization.Model): """ _attribute_map = { - 'path': {'key': 'path', 'type': 'str'}, - 'api_versions': {'key': 'apiVersions', 'type': '[str]'}, + "path": {"key": "path", "type": "str"}, + "api_versions": {"key": "apiVersions", "type": "[str]"}, } - def __init__( - self, - *, - path: Optional[str] = None, - api_versions: Optional[List[str]] = None, - **kwargs - ): + def __init__(self, *, path: Optional[str] = None, api_versions: Optional[List[str]] = None, **kwargs): """ :keyword path: The path of an alias. :paramtype path: str :keyword api_versions: The API versions. :paramtype api_versions: list[str] """ - super(AliasPathType, self).__init__(**kwargs) + super().__init__(**kwargs) self.path = path self.api_versions = api_versions -class AliasType(msrest.serialization.Model): +class AliasType(_serialization.Model): """The alias type. :ivar name: The alias name. @@ -55,29 +58,23 @@ class AliasType(msrest.serialization.Model): """ _attribute_map = { - 'name': {'key': 'name', 'type': 'str'}, - 'paths': {'key': 'paths', 'type': '[AliasPathType]'}, + "name": {"key": "name", "type": "str"}, + "paths": {"key": "paths", "type": "[AliasPathType]"}, } - def __init__( - self, - *, - name: Optional[str] = None, - paths: Optional[List["AliasPathType"]] = None, - **kwargs - ): + def __init__(self, *, name: Optional[str] = None, paths: Optional[List["_models.AliasPathType"]] = None, **kwargs): """ :keyword name: The alias name. :paramtype name: str :keyword paths: The paths for an alias. :paramtype paths: list[~azure.mgmt.resource.resources.v2019_07_01.models.AliasPathType] """ - super(AliasType, self).__init__(**kwargs) + super().__init__(**kwargs) self.name = name self.paths = paths -class BasicDependency(msrest.serialization.Model): +class BasicDependency(_serialization.Model): """Deployment dependency information. :ivar id: The ID of the dependency. @@ -89,15 +86,15 @@ class BasicDependency(msrest.serialization.Model): """ _attribute_map = { - 'id': {'key': 'id', 'type': 'str'}, - 'resource_type': {'key': 'resourceType', 'type': 'str'}, - 'resource_name': {'key': 'resourceName', 'type': 'str'}, + "id": {"key": "id", "type": "str"}, + "resource_type": {"key": "resourceType", "type": "str"}, + "resource_name": {"key": "resourceName", "type": "str"}, } def __init__( self, *, - id: Optional[str] = None, + id: Optional[str] = None, # pylint: disable=redefined-builtin resource_type: Optional[str] = None, resource_name: Optional[str] = None, **kwargs @@ -110,13 +107,13 @@ def __init__( :keyword resource_name: The dependency resource name. :paramtype resource_name: str """ - super(BasicDependency, self).__init__(**kwargs) + super().__init__(**kwargs) self.id = id self.resource_type = resource_type self.resource_name = resource_name -class ComponentsSgqdofSchemasIdentityPropertiesUserassignedidentitiesAdditionalproperties(msrest.serialization.Model): +class ComponentsSgqdofSchemasIdentityPropertiesUserassignedidentitiesAdditionalproperties(_serialization.Model): """ComponentsSgqdofSchemasIdentityPropertiesUserassignedidentitiesAdditionalproperties. Variables are only populated by the server, and will be ignored when sending a request. @@ -128,27 +125,23 @@ class ComponentsSgqdofSchemasIdentityPropertiesUserassignedidentitiesAdditionalp """ _validation = { - 'principal_id': {'readonly': True}, - 'client_id': {'readonly': True}, + "principal_id": {"readonly": True}, + "client_id": {"readonly": True}, } _attribute_map = { - 'principal_id': {'key': 'principalId', 'type': 'str'}, - 'client_id': {'key': 'clientId', 'type': 'str'}, + "principal_id": {"key": "principalId", "type": "str"}, + "client_id": {"key": "clientId", "type": "str"}, } - def __init__( - self, - **kwargs - ): - """ - """ - super(ComponentsSgqdofSchemasIdentityPropertiesUserassignedidentitiesAdditionalproperties, self).__init__(**kwargs) + def __init__(self, **kwargs): + """ """ + super().__init__(**kwargs) self.principal_id = None self.client_id = None -class DebugSetting(msrest.serialization.Model): +class DebugSetting(_serialization.Model): """The debug setting. :ivar detail_level: Specifies the type of information to log for debugging. The permitted @@ -161,15 +154,10 @@ class DebugSetting(msrest.serialization.Model): """ _attribute_map = { - 'detail_level': {'key': 'detailLevel', 'type': 'str'}, + "detail_level": {"key": "detailLevel", "type": "str"}, } - def __init__( - self, - *, - detail_level: Optional[str] = None, - **kwargs - ): + def __init__(self, *, detail_level: Optional[str] = None, **kwargs): """ :keyword detail_level: Specifies the type of information to log for debugging. The permitted values are none, requestContent, responseContent, or both requestContent and responseContent @@ -179,11 +167,11 @@ def __init__( deployment operations. :paramtype detail_level: str """ - super(DebugSetting, self).__init__(**kwargs) + super().__init__(**kwargs) self.detail_level = detail_level -class Dependency(msrest.serialization.Model): +class Dependency(_serialization.Model): """Deployment dependency information. :ivar depends_on: The list of dependencies. @@ -197,17 +185,17 @@ class Dependency(msrest.serialization.Model): """ _attribute_map = { - 'depends_on': {'key': 'dependsOn', 'type': '[BasicDependency]'}, - 'id': {'key': 'id', 'type': 'str'}, - 'resource_type': {'key': 'resourceType', 'type': 'str'}, - 'resource_name': {'key': 'resourceName', 'type': 'str'}, + "depends_on": {"key": "dependsOn", "type": "[BasicDependency]"}, + "id": {"key": "id", "type": "str"}, + "resource_type": {"key": "resourceType", "type": "str"}, + "resource_name": {"key": "resourceName", "type": "str"}, } def __init__( self, *, - depends_on: Optional[List["BasicDependency"]] = None, - id: Optional[str] = None, + depends_on: Optional[List["_models.BasicDependency"]] = None, + id: Optional[str] = None, # pylint: disable=redefined-builtin resource_type: Optional[str] = None, resource_name: Optional[str] = None, **kwargs @@ -222,77 +210,66 @@ def __init__( :keyword resource_name: The dependency resource name. :paramtype resource_name: str """ - super(Dependency, self).__init__(**kwargs) + super().__init__(**kwargs) self.depends_on = depends_on self.id = id self.resource_type = resource_type self.resource_name = resource_name -class Deployment(msrest.serialization.Model): +class Deployment(_serialization.Model): """Deployment operation parameters. All required parameters must be populated in order to send to Azure. :ivar location: The location to store the deployment data. :vartype location: str - :ivar properties: Required. The deployment properties. + :ivar properties: The deployment properties. Required. :vartype properties: ~azure.mgmt.resource.resources.v2019_07_01.models.DeploymentProperties """ _validation = { - 'properties': {'required': True}, + "properties": {"required": True}, } _attribute_map = { - 'location': {'key': 'location', 'type': 'str'}, - 'properties': {'key': 'properties', 'type': 'DeploymentProperties'}, + "location": {"key": "location", "type": "str"}, + "properties": {"key": "properties", "type": "DeploymentProperties"}, } - def __init__( - self, - *, - properties: "DeploymentProperties", - location: Optional[str] = None, - **kwargs - ): + def __init__(self, *, properties: "_models.DeploymentProperties", location: Optional[str] = None, **kwargs): """ :keyword location: The location to store the deployment data. :paramtype location: str - :keyword properties: Required. The deployment properties. + :keyword properties: The deployment properties. Required. :paramtype properties: ~azure.mgmt.resource.resources.v2019_07_01.models.DeploymentProperties """ - super(Deployment, self).__init__(**kwargs) + super().__init__(**kwargs) self.location = location self.properties = properties -class DeploymentExportResult(msrest.serialization.Model): +class DeploymentExportResult(_serialization.Model): """The deployment export result. :ivar template: The template content. - :vartype template: any + :vartype template: JSON """ _attribute_map = { - 'template': {'key': 'template', 'type': 'object'}, + "template": {"key": "template", "type": "object"}, } - def __init__( - self, - *, - template: Optional[Any] = None, - **kwargs - ): + def __init__(self, *, template: Optional[JSON] = None, **kwargs): """ :keyword template: The template content. - :paramtype template: any + :paramtype template: JSON """ - super(DeploymentExportResult, self).__init__(**kwargs) + super().__init__(**kwargs) self.template = template -class DeploymentExtended(msrest.serialization.Model): +class DeploymentExtended(_serialization.Model): """Deployment information. Variables are only populated by the server, and will be ignored when sending a request. @@ -311,24 +288,24 @@ class DeploymentExtended(msrest.serialization.Model): """ _validation = { - 'id': {'readonly': True}, - 'name': {'readonly': True}, - 'type': {'readonly': True}, + "id": {"readonly": True}, + "name": {"readonly": True}, + "type": {"readonly": True}, } _attribute_map = { - 'id': {'key': 'id', 'type': 'str'}, - 'name': {'key': 'name', 'type': 'str'}, - 'type': {'key': 'type', 'type': 'str'}, - 'location': {'key': 'location', 'type': 'str'}, - 'properties': {'key': 'properties', 'type': 'DeploymentPropertiesExtended'}, + "id": {"key": "id", "type": "str"}, + "name": {"key": "name", "type": "str"}, + "type": {"key": "type", "type": "str"}, + "location": {"key": "location", "type": "str"}, + "properties": {"key": "properties", "type": "DeploymentPropertiesExtended"}, } def __init__( self, *, location: Optional[str] = None, - properties: Optional["DeploymentPropertiesExtended"] = None, + properties: Optional["_models.DeploymentPropertiesExtended"] = None, **kwargs ): """ @@ -338,7 +315,7 @@ def __init__( :paramtype properties: ~azure.mgmt.resource.resources.v2019_07_01.models.DeploymentPropertiesExtended """ - super(DeploymentExtended, self).__init__(**kwargs) + super().__init__(**kwargs) self.id = None self.name = None self.type = None @@ -346,7 +323,7 @@ def __init__( self.properties = properties -class DeploymentExtendedFilter(msrest.serialization.Model): +class DeploymentExtendedFilter(_serialization.Model): """Deployment filter. :ivar provisioning_state: The provisioning state. @@ -354,24 +331,19 @@ class DeploymentExtendedFilter(msrest.serialization.Model): """ _attribute_map = { - 'provisioning_state': {'key': 'provisioningState', 'type': 'str'}, + "provisioning_state": {"key": "provisioningState", "type": "str"}, } - def __init__( - self, - *, - provisioning_state: Optional[str] = None, - **kwargs - ): + def __init__(self, *, provisioning_state: Optional[str] = None, **kwargs): """ :keyword provisioning_state: The provisioning state. :paramtype provisioning_state: str """ - super(DeploymentExtendedFilter, self).__init__(**kwargs) + super().__init__(**kwargs) self.provisioning_state = provisioning_state -class DeploymentListResult(msrest.serialization.Model): +class DeploymentListResult(_serialization.Model): """List of deployments. Variables are only populated by the server, and will be ignored when sending a request. @@ -383,30 +355,25 @@ class DeploymentListResult(msrest.serialization.Model): """ _validation = { - 'next_link': {'readonly': True}, + "next_link": {"readonly": True}, } _attribute_map = { - 'value': {'key': 'value', 'type': '[DeploymentExtended]'}, - 'next_link': {'key': 'nextLink', 'type': 'str'}, + "value": {"key": "value", "type": "[DeploymentExtended]"}, + "next_link": {"key": "nextLink", "type": "str"}, } - def __init__( - self, - *, - value: Optional[List["DeploymentExtended"]] = None, - **kwargs - ): + def __init__(self, *, value: Optional[List["_models.DeploymentExtended"]] = None, **kwargs): """ :keyword value: An array of deployments. :paramtype value: list[~azure.mgmt.resource.resources.v2019_07_01.models.DeploymentExtended] """ - super(DeploymentListResult, self).__init__(**kwargs) + super().__init__(**kwargs) self.value = value self.next_link = None -class DeploymentOperation(msrest.serialization.Model): +class DeploymentOperation(_serialization.Model): """Deployment operation information. Variables are only populated by the server, and will be ignored when sending a request. @@ -421,34 +388,29 @@ class DeploymentOperation(msrest.serialization.Model): """ _validation = { - 'id': {'readonly': True}, - 'operation_id': {'readonly': True}, + "id": {"readonly": True}, + "operation_id": {"readonly": True}, } _attribute_map = { - 'id': {'key': 'id', 'type': 'str'}, - 'operation_id': {'key': 'operationId', 'type': 'str'}, - 'properties': {'key': 'properties', 'type': 'DeploymentOperationProperties'}, + "id": {"key": "id", "type": "str"}, + "operation_id": {"key": "operationId", "type": "str"}, + "properties": {"key": "properties", "type": "DeploymentOperationProperties"}, } - def __init__( - self, - *, - properties: Optional["DeploymentOperationProperties"] = None, - **kwargs - ): + def __init__(self, *, properties: Optional["_models.DeploymentOperationProperties"] = None, **kwargs): """ :keyword properties: Deployment properties. :paramtype properties: ~azure.mgmt.resource.resources.v2019_07_01.models.DeploymentOperationProperties """ - super(DeploymentOperation, self).__init__(**kwargs) + super().__init__(**kwargs) self.id = None self.operation_id = None self.properties = properties -class DeploymentOperationProperties(msrest.serialization.Model): +class DeploymentOperationProperties(_serialization.Model): """Deployment operation properties. Variables are only populated by the server, and will be ignored when sending a request. @@ -464,7 +426,7 @@ class DeploymentOperationProperties(msrest.serialization.Model): :ivar status_code: Operation status code. :vartype status_code: str :ivar status_message: Operation status message. - :vartype status_message: any + :vartype status_message: JSON :ivar target_resource: The target resource. :vartype target_resource: ~azure.mgmt.resource.resources.v2019_07_01.models.TargetResource :ivar request: The HTTP request message. @@ -474,36 +436,32 @@ class DeploymentOperationProperties(msrest.serialization.Model): """ _validation = { - 'provisioning_state': {'readonly': True}, - 'timestamp': {'readonly': True}, - 'duration': {'readonly': True}, - 'service_request_id': {'readonly': True}, - 'status_code': {'readonly': True}, - 'status_message': {'readonly': True}, - 'target_resource': {'readonly': True}, - 'request': {'readonly': True}, - 'response': {'readonly': True}, + "provisioning_state": {"readonly": True}, + "timestamp": {"readonly": True}, + "duration": {"readonly": True}, + "service_request_id": {"readonly": True}, + "status_code": {"readonly": True}, + "status_message": {"readonly": True}, + "target_resource": {"readonly": True}, + "request": {"readonly": True}, + "response": {"readonly": True}, } _attribute_map = { - 'provisioning_state': {'key': 'provisioningState', 'type': 'str'}, - 'timestamp': {'key': 'timestamp', 'type': 'iso-8601'}, - 'duration': {'key': 'duration', 'type': 'str'}, - 'service_request_id': {'key': 'serviceRequestId', 'type': 'str'}, - 'status_code': {'key': 'statusCode', 'type': 'str'}, - 'status_message': {'key': 'statusMessage', 'type': 'object'}, - 'target_resource': {'key': 'targetResource', 'type': 'TargetResource'}, - 'request': {'key': 'request', 'type': 'HttpMessage'}, - 'response': {'key': 'response', 'type': 'HttpMessage'}, - } - - def __init__( - self, - **kwargs - ): - """ - """ - super(DeploymentOperationProperties, self).__init__(**kwargs) + "provisioning_state": {"key": "provisioningState", "type": "str"}, + "timestamp": {"key": "timestamp", "type": "iso-8601"}, + "duration": {"key": "duration", "type": "str"}, + "service_request_id": {"key": "serviceRequestId", "type": "str"}, + "status_code": {"key": "statusCode", "type": "str"}, + "status_message": {"key": "statusMessage", "type": "object"}, + "target_resource": {"key": "targetResource", "type": "TargetResource"}, + "request": {"key": "request", "type": "HttpMessage"}, + "response": {"key": "response", "type": "HttpMessage"}, + } + + def __init__(self, **kwargs): + """ """ + super().__init__(**kwargs) self.provisioning_state = None self.timestamp = None self.duration = None @@ -515,7 +473,7 @@ def __init__( self.response = None -class DeploymentOperationsListResult(msrest.serialization.Model): +class DeploymentOperationsListResult(_serialization.Model): """List of deployment operations. Variables are only populated by the server, and will be ignored when sending a request. @@ -527,30 +485,25 @@ class DeploymentOperationsListResult(msrest.serialization.Model): """ _validation = { - 'next_link': {'readonly': True}, + "next_link": {"readonly": True}, } _attribute_map = { - 'value': {'key': 'value', 'type': '[DeploymentOperation]'}, - 'next_link': {'key': 'nextLink', 'type': 'str'}, + "value": {"key": "value", "type": "[DeploymentOperation]"}, + "next_link": {"key": "nextLink", "type": "str"}, } - def __init__( - self, - *, - value: Optional[List["DeploymentOperation"]] = None, - **kwargs - ): + def __init__(self, *, value: Optional[List["_models.DeploymentOperation"]] = None, **kwargs): """ :keyword value: An array of deployment operations. :paramtype value: list[~azure.mgmt.resource.resources.v2019_07_01.models.DeploymentOperation] """ - super(DeploymentOperationsListResult, self).__init__(**kwargs) + super().__init__(**kwargs) self.value = value self.next_link = None -class DeploymentProperties(msrest.serialization.Model): +class DeploymentProperties(_serialization.Model): """Deployment properties. All required parameters must be populated in order to send to Azure. @@ -559,7 +512,7 @@ class DeploymentProperties(msrest.serialization.Model): syntax directly in the request rather than link to an existing template. It can be a JObject or well-formed JSON string. Use either the templateLink property or the template property, but not both. - :vartype template: any + :vartype template: JSON :ivar template_link: The URI of the template. Use either the templateLink property or the template property, but not both. :vartype template_link: ~azure.mgmt.resource.resources.v2019_07_01.models.TemplateLink @@ -567,17 +520,17 @@ class DeploymentProperties(msrest.serialization.Model): You use this element when you want to provide the parameter values directly in the request rather than link to an existing parameter file. Use either the parametersLink property or the parameters property, but not both. It can be a JObject or a well formed JSON string. - :vartype parameters: any + :vartype parameters: JSON :ivar parameters_link: The URI of parameters file. You use this element to link to an existing parameters file. Use either the parametersLink property or the parameters property, but not both. :vartype parameters_link: ~azure.mgmt.resource.resources.v2019_07_01.models.ParametersLink - :ivar mode: Required. The mode that is used to deploy resources. This value can be either - Incremental or Complete. In Incremental mode, resources are deployed without deleting existing - resources that are not included in the template. In Complete mode, resources are deployed and - existing resources in the resource group that are not included in the template are deleted. Be - careful when using Complete mode as you may unintentionally delete resources. Possible values - include: "Incremental", "Complete". + :ivar mode: The mode that is used to deploy resources. This value can be either Incremental or + Complete. In Incremental mode, resources are deployed without deleting existing resources that + are not included in the template. In Complete mode, resources are deployed and existing + resources in the resource group that are not included in the template are deleted. Be careful + when using Complete mode as you may unintentionally delete resources. Required. Known values + are: "Incremental" and "Complete". :vartype mode: str or ~azure.mgmt.resource.resources.v2019_07_01.models.DeploymentMode :ivar debug_setting: The debug setting of the deployment. :vartype debug_setting: ~azure.mgmt.resource.resources.v2019_07_01.models.DebugSetting @@ -587,29 +540,29 @@ class DeploymentProperties(msrest.serialization.Model): """ _validation = { - 'mode': {'required': True}, + "mode": {"required": True}, } _attribute_map = { - 'template': {'key': 'template', 'type': 'object'}, - 'template_link': {'key': 'templateLink', 'type': 'TemplateLink'}, - 'parameters': {'key': 'parameters', 'type': 'object'}, - 'parameters_link': {'key': 'parametersLink', 'type': 'ParametersLink'}, - 'mode': {'key': 'mode', 'type': 'str'}, - 'debug_setting': {'key': 'debugSetting', 'type': 'DebugSetting'}, - 'on_error_deployment': {'key': 'onErrorDeployment', 'type': 'OnErrorDeployment'}, + "template": {"key": "template", "type": "object"}, + "template_link": {"key": "templateLink", "type": "TemplateLink"}, + "parameters": {"key": "parameters", "type": "object"}, + "parameters_link": {"key": "parametersLink", "type": "ParametersLink"}, + "mode": {"key": "mode", "type": "str"}, + "debug_setting": {"key": "debugSetting", "type": "DebugSetting"}, + "on_error_deployment": {"key": "onErrorDeployment", "type": "OnErrorDeployment"}, } def __init__( self, *, - mode: Union[str, "DeploymentMode"], - template: Optional[Any] = None, - template_link: Optional["TemplateLink"] = None, - parameters: Optional[Any] = None, - parameters_link: Optional["ParametersLink"] = None, - debug_setting: Optional["DebugSetting"] = None, - on_error_deployment: Optional["OnErrorDeployment"] = None, + mode: Union[str, "_models.DeploymentMode"], + template: Optional[JSON] = None, + template_link: Optional["_models.TemplateLink"] = None, + parameters: Optional[JSON] = None, + parameters_link: Optional["_models.ParametersLink"] = None, + debug_setting: Optional["_models.DebugSetting"] = None, + on_error_deployment: Optional["_models.OnErrorDeployment"] = None, **kwargs ): """ @@ -617,7 +570,7 @@ def __init__( template syntax directly in the request rather than link to an existing template. It can be a JObject or well-formed JSON string. Use either the templateLink property or the template property, but not both. - :paramtype template: any + :paramtype template: JSON :keyword template_link: The URI of the template. Use either the templateLink property or the template property, but not both. :paramtype template_link: ~azure.mgmt.resource.resources.v2019_07_01.models.TemplateLink @@ -625,17 +578,17 @@ def __init__( template. You use this element when you want to provide the parameter values directly in the request rather than link to an existing parameter file. Use either the parametersLink property or the parameters property, but not both. It can be a JObject or a well formed JSON string. - :paramtype parameters: any + :paramtype parameters: JSON :keyword parameters_link: The URI of parameters file. You use this element to link to an existing parameters file. Use either the parametersLink property or the parameters property, but not both. :paramtype parameters_link: ~azure.mgmt.resource.resources.v2019_07_01.models.ParametersLink - :keyword mode: Required. The mode that is used to deploy resources. This value can be either - Incremental or Complete. In Incremental mode, resources are deployed without deleting existing - resources that are not included in the template. In Complete mode, resources are deployed and - existing resources in the resource group that are not included in the template are deleted. Be - careful when using Complete mode as you may unintentionally delete resources. Possible values - include: "Incremental", "Complete". + :keyword mode: The mode that is used to deploy resources. This value can be either Incremental + or Complete. In Incremental mode, resources are deployed without deleting existing resources + that are not included in the template. In Complete mode, resources are deployed and existing + resources in the resource group that are not included in the template are deleted. Be careful + when using Complete mode as you may unintentionally delete resources. Required. Known values + are: "Incremental" and "Complete". :paramtype mode: str or ~azure.mgmt.resource.resources.v2019_07_01.models.DeploymentMode :keyword debug_setting: The debug setting of the deployment. :paramtype debug_setting: ~azure.mgmt.resource.resources.v2019_07_01.models.DebugSetting @@ -643,7 +596,7 @@ def __init__( :paramtype on_error_deployment: ~azure.mgmt.resource.resources.v2019_07_01.models.OnErrorDeployment """ - super(DeploymentProperties, self).__init__(**kwargs) + super().__init__(**kwargs) self.template = template self.template_link = template_link self.parameters = parameters @@ -653,7 +606,7 @@ def __init__( self.on_error_deployment = on_error_deployment -class DeploymentPropertiesExtended(msrest.serialization.Model): +class DeploymentPropertiesExtended(_serialization.Model): # pylint: disable=too-many-instance-attributes """Deployment properties with additional details. Variables are only populated by the server, and will be ignored when sending a request. @@ -667,23 +620,23 @@ class DeploymentPropertiesExtended(msrest.serialization.Model): :ivar duration: The duration of the template deployment. :vartype duration: str :ivar outputs: Key/value pairs that represent deployment output. - :vartype outputs: any + :vartype outputs: JSON :ivar providers: The list of resource providers needed for the deployment. :vartype providers: list[~azure.mgmt.resource.resources.v2019_07_01.models.Provider] :ivar dependencies: The list of deployment dependencies. :vartype dependencies: list[~azure.mgmt.resource.resources.v2019_07_01.models.Dependency] :ivar template: The template content. Use only one of Template or TemplateLink. - :vartype template: any + :vartype template: JSON :ivar template_link: The URI referencing the template. Use only one of Template or TemplateLink. :vartype template_link: ~azure.mgmt.resource.resources.v2019_07_01.models.TemplateLink :ivar parameters: Deployment parameters. Use only one of Parameters or ParametersLink. - :vartype parameters: any + :vartype parameters: JSON :ivar parameters_link: The URI referencing the parameters. Use only one of Parameters or ParametersLink. :vartype parameters_link: ~azure.mgmt.resource.resources.v2019_07_01.models.ParametersLink - :ivar mode: The deployment mode. Possible values are Incremental and Complete. Possible values - include: "Incremental", "Complete". + :ivar mode: The deployment mode. Possible values are Incremental and Complete. Known values + are: "Incremental" and "Complete". :vartype mode: str or ~azure.mgmt.resource.resources.v2019_07_01.models.DeploymentMode :ivar debug_setting: The debug setting of the deployment. :vartype debug_setting: ~azure.mgmt.resource.resources.v2019_07_01.models.DebugSetting @@ -695,65 +648,65 @@ class DeploymentPropertiesExtended(msrest.serialization.Model): """ _validation = { - 'provisioning_state': {'readonly': True}, - 'correlation_id': {'readonly': True}, - 'timestamp': {'readonly': True}, - 'duration': {'readonly': True}, - 'error': {'readonly': True}, + "provisioning_state": {"readonly": True}, + "correlation_id": {"readonly": True}, + "timestamp": {"readonly": True}, + "duration": {"readonly": True}, + "error": {"readonly": True}, } _attribute_map = { - 'provisioning_state': {'key': 'provisioningState', 'type': 'str'}, - 'correlation_id': {'key': 'correlationId', 'type': 'str'}, - 'timestamp': {'key': 'timestamp', 'type': 'iso-8601'}, - 'duration': {'key': 'duration', 'type': 'str'}, - 'outputs': {'key': 'outputs', 'type': 'object'}, - 'providers': {'key': 'providers', 'type': '[Provider]'}, - 'dependencies': {'key': 'dependencies', 'type': '[Dependency]'}, - 'template': {'key': 'template', 'type': 'object'}, - 'template_link': {'key': 'templateLink', 'type': 'TemplateLink'}, - 'parameters': {'key': 'parameters', 'type': 'object'}, - 'parameters_link': {'key': 'parametersLink', 'type': 'ParametersLink'}, - 'mode': {'key': 'mode', 'type': 'str'}, - 'debug_setting': {'key': 'debugSetting', 'type': 'DebugSetting'}, - 'on_error_deployment': {'key': 'onErrorDeployment', 'type': 'OnErrorDeploymentExtended'}, - 'error': {'key': 'error', 'type': 'ErrorResponse'}, + "provisioning_state": {"key": "provisioningState", "type": "str"}, + "correlation_id": {"key": "correlationId", "type": "str"}, + "timestamp": {"key": "timestamp", "type": "iso-8601"}, + "duration": {"key": "duration", "type": "str"}, + "outputs": {"key": "outputs", "type": "object"}, + "providers": {"key": "providers", "type": "[Provider]"}, + "dependencies": {"key": "dependencies", "type": "[Dependency]"}, + "template": {"key": "template", "type": "object"}, + "template_link": {"key": "templateLink", "type": "TemplateLink"}, + "parameters": {"key": "parameters", "type": "object"}, + "parameters_link": {"key": "parametersLink", "type": "ParametersLink"}, + "mode": {"key": "mode", "type": "str"}, + "debug_setting": {"key": "debugSetting", "type": "DebugSetting"}, + "on_error_deployment": {"key": "onErrorDeployment", "type": "OnErrorDeploymentExtended"}, + "error": {"key": "error", "type": "ErrorResponse"}, } def __init__( self, *, - outputs: Optional[Any] = None, - providers: Optional[List["Provider"]] = None, - dependencies: Optional[List["Dependency"]] = None, - template: Optional[Any] = None, - template_link: Optional["TemplateLink"] = None, - parameters: Optional[Any] = None, - parameters_link: Optional["ParametersLink"] = None, - mode: Optional[Union[str, "DeploymentMode"]] = None, - debug_setting: Optional["DebugSetting"] = None, - on_error_deployment: Optional["OnErrorDeploymentExtended"] = None, + outputs: Optional[JSON] = None, + providers: Optional[List["_models.Provider"]] = None, + dependencies: Optional[List["_models.Dependency"]] = None, + template: Optional[JSON] = None, + template_link: Optional["_models.TemplateLink"] = None, + parameters: Optional[JSON] = None, + parameters_link: Optional["_models.ParametersLink"] = None, + mode: Optional[Union[str, "_models.DeploymentMode"]] = None, + debug_setting: Optional["_models.DebugSetting"] = None, + on_error_deployment: Optional["_models.OnErrorDeploymentExtended"] = None, **kwargs ): """ :keyword outputs: Key/value pairs that represent deployment output. - :paramtype outputs: any + :paramtype outputs: JSON :keyword providers: The list of resource providers needed for the deployment. :paramtype providers: list[~azure.mgmt.resource.resources.v2019_07_01.models.Provider] :keyword dependencies: The list of deployment dependencies. :paramtype dependencies: list[~azure.mgmt.resource.resources.v2019_07_01.models.Dependency] :keyword template: The template content. Use only one of Template or TemplateLink. - :paramtype template: any + :paramtype template: JSON :keyword template_link: The URI referencing the template. Use only one of Template or TemplateLink. :paramtype template_link: ~azure.mgmt.resource.resources.v2019_07_01.models.TemplateLink :keyword parameters: Deployment parameters. Use only one of Parameters or ParametersLink. - :paramtype parameters: any + :paramtype parameters: JSON :keyword parameters_link: The URI referencing the parameters. Use only one of Parameters or ParametersLink. :paramtype parameters_link: ~azure.mgmt.resource.resources.v2019_07_01.models.ParametersLink - :keyword mode: The deployment mode. Possible values are Incremental and Complete. Possible - values include: "Incremental", "Complete". + :keyword mode: The deployment mode. Possible values are Incremental and Complete. Known values + are: "Incremental" and "Complete". :paramtype mode: str or ~azure.mgmt.resource.resources.v2019_07_01.models.DeploymentMode :keyword debug_setting: The debug setting of the deployment. :paramtype debug_setting: ~azure.mgmt.resource.resources.v2019_07_01.models.DebugSetting @@ -761,7 +714,7 @@ def __init__( :paramtype on_error_deployment: ~azure.mgmt.resource.resources.v2019_07_01.models.OnErrorDeploymentExtended """ - super(DeploymentPropertiesExtended, self).__init__(**kwargs) + super().__init__(**kwargs) self.provisioning_state = None self.correlation_id = None self.timestamp = None @@ -779,7 +732,7 @@ def __init__( self.error = None -class DeploymentValidateResult(msrest.serialization.Model): +class DeploymentValidateResult(_serialization.Model): """Information from validate template deployment response. :ivar error: The deployment validation error. @@ -790,15 +743,15 @@ class DeploymentValidateResult(msrest.serialization.Model): """ _attribute_map = { - 'error': {'key': 'error', 'type': 'ErrorResponse'}, - 'properties': {'key': 'properties', 'type': 'DeploymentPropertiesExtended'}, + "error": {"key": "error", "type": "ErrorResponse"}, + "properties": {"key": "properties", "type": "DeploymentPropertiesExtended"}, } def __init__( self, *, - error: Optional["ErrorResponse"] = None, - properties: Optional["DeploymentPropertiesExtended"] = None, + error: Optional["_models.ErrorResponse"] = None, + properties: Optional["_models.DeploymentPropertiesExtended"] = None, **kwargs ): """ @@ -808,47 +761,41 @@ def __init__( :paramtype properties: ~azure.mgmt.resource.resources.v2019_07_01.models.DeploymentPropertiesExtended """ - super(DeploymentValidateResult, self).__init__(**kwargs) + super().__init__(**kwargs) self.error = error self.properties = properties -class DeploymentWhatIf(msrest.serialization.Model): +class DeploymentWhatIf(_serialization.Model): """Deployment What-if operation parameters. All required parameters must be populated in order to send to Azure. :ivar location: The location to store the deployment data. :vartype location: str - :ivar properties: Required. The deployment properties. + :ivar properties: The deployment properties. Required. :vartype properties: ~azure.mgmt.resource.resources.v2019_07_01.models.DeploymentWhatIfProperties """ _validation = { - 'properties': {'required': True}, + "properties": {"required": True}, } _attribute_map = { - 'location': {'key': 'location', 'type': 'str'}, - 'properties': {'key': 'properties', 'type': 'DeploymentWhatIfProperties'}, + "location": {"key": "location", "type": "str"}, + "properties": {"key": "properties", "type": "DeploymentWhatIfProperties"}, } - def __init__( - self, - *, - properties: "DeploymentWhatIfProperties", - location: Optional[str] = None, - **kwargs - ): + def __init__(self, *, properties: "_models.DeploymentWhatIfProperties", location: Optional[str] = None, **kwargs): """ :keyword location: The location to store the deployment data. :paramtype location: str - :keyword properties: Required. The deployment properties. + :keyword properties: The deployment properties. Required. :paramtype properties: ~azure.mgmt.resource.resources.v2019_07_01.models.DeploymentWhatIfProperties """ - super(DeploymentWhatIf, self).__init__(**kwargs) + super().__init__(**kwargs) self.location = location self.properties = properties @@ -862,7 +809,7 @@ class DeploymentWhatIfProperties(DeploymentProperties): syntax directly in the request rather than link to an existing template. It can be a JObject or well-formed JSON string. Use either the templateLink property or the template property, but not both. - :vartype template: any + :vartype template: JSON :ivar template_link: The URI of the template. Use either the templateLink property or the template property, but not both. :vartype template_link: ~azure.mgmt.resource.resources.v2019_07_01.models.TemplateLink @@ -870,17 +817,17 @@ class DeploymentWhatIfProperties(DeploymentProperties): You use this element when you want to provide the parameter values directly in the request rather than link to an existing parameter file. Use either the parametersLink property or the parameters property, but not both. It can be a JObject or a well formed JSON string. - :vartype parameters: any + :vartype parameters: JSON :ivar parameters_link: The URI of parameters file. You use this element to link to an existing parameters file. Use either the parametersLink property or the parameters property, but not both. :vartype parameters_link: ~azure.mgmt.resource.resources.v2019_07_01.models.ParametersLink - :ivar mode: Required. The mode that is used to deploy resources. This value can be either - Incremental or Complete. In Incremental mode, resources are deployed without deleting existing - resources that are not included in the template. In Complete mode, resources are deployed and - existing resources in the resource group that are not included in the template are deleted. Be - careful when using Complete mode as you may unintentionally delete resources. Possible values - include: "Incremental", "Complete". + :ivar mode: The mode that is used to deploy resources. This value can be either Incremental or + Complete. In Incremental mode, resources are deployed without deleting existing resources that + are not included in the template. In Complete mode, resources are deployed and existing + resources in the resource group that are not included in the template are deleted. Be careful + when using Complete mode as you may unintentionally delete resources. Required. Known values + are: "Incremental" and "Complete". :vartype mode: str or ~azure.mgmt.resource.resources.v2019_07_01.models.DeploymentMode :ivar debug_setting: The debug setting of the deployment. :vartype debug_setting: ~azure.mgmt.resource.resources.v2019_07_01.models.DebugSetting @@ -893,31 +840,31 @@ class DeploymentWhatIfProperties(DeploymentProperties): """ _validation = { - 'mode': {'required': True}, + "mode": {"required": True}, } _attribute_map = { - 'template': {'key': 'template', 'type': 'object'}, - 'template_link': {'key': 'templateLink', 'type': 'TemplateLink'}, - 'parameters': {'key': 'parameters', 'type': 'object'}, - 'parameters_link': {'key': 'parametersLink', 'type': 'ParametersLink'}, - 'mode': {'key': 'mode', 'type': 'str'}, - 'debug_setting': {'key': 'debugSetting', 'type': 'DebugSetting'}, - 'on_error_deployment': {'key': 'onErrorDeployment', 'type': 'OnErrorDeployment'}, - 'what_if_settings': {'key': 'whatIfSettings', 'type': 'DeploymentWhatIfSettings'}, + "template": {"key": "template", "type": "object"}, + "template_link": {"key": "templateLink", "type": "TemplateLink"}, + "parameters": {"key": "parameters", "type": "object"}, + "parameters_link": {"key": "parametersLink", "type": "ParametersLink"}, + "mode": {"key": "mode", "type": "str"}, + "debug_setting": {"key": "debugSetting", "type": "DebugSetting"}, + "on_error_deployment": {"key": "onErrorDeployment", "type": "OnErrorDeployment"}, + "what_if_settings": {"key": "whatIfSettings", "type": "DeploymentWhatIfSettings"}, } def __init__( self, *, - mode: Union[str, "DeploymentMode"], - template: Optional[Any] = None, - template_link: Optional["TemplateLink"] = None, - parameters: Optional[Any] = None, - parameters_link: Optional["ParametersLink"] = None, - debug_setting: Optional["DebugSetting"] = None, - on_error_deployment: Optional["OnErrorDeployment"] = None, - what_if_settings: Optional["DeploymentWhatIfSettings"] = None, + mode: Union[str, "_models.DeploymentMode"], + template: Optional[JSON] = None, + template_link: Optional["_models.TemplateLink"] = None, + parameters: Optional[JSON] = None, + parameters_link: Optional["_models.ParametersLink"] = None, + debug_setting: Optional["_models.DebugSetting"] = None, + on_error_deployment: Optional["_models.OnErrorDeployment"] = None, + what_if_settings: Optional["_models.DeploymentWhatIfSettings"] = None, **kwargs ): """ @@ -925,7 +872,7 @@ def __init__( template syntax directly in the request rather than link to an existing template. It can be a JObject or well-formed JSON string. Use either the templateLink property or the template property, but not both. - :paramtype template: any + :paramtype template: JSON :keyword template_link: The URI of the template. Use either the templateLink property or the template property, but not both. :paramtype template_link: ~azure.mgmt.resource.resources.v2019_07_01.models.TemplateLink @@ -933,17 +880,17 @@ def __init__( template. You use this element when you want to provide the parameter values directly in the request rather than link to an existing parameter file. Use either the parametersLink property or the parameters property, but not both. It can be a JObject or a well formed JSON string. - :paramtype parameters: any + :paramtype parameters: JSON :keyword parameters_link: The URI of parameters file. You use this element to link to an existing parameters file. Use either the parametersLink property or the parameters property, but not both. :paramtype parameters_link: ~azure.mgmt.resource.resources.v2019_07_01.models.ParametersLink - :keyword mode: Required. The mode that is used to deploy resources. This value can be either - Incremental or Complete. In Incremental mode, resources are deployed without deleting existing - resources that are not included in the template. In Complete mode, resources are deployed and - existing resources in the resource group that are not included in the template are deleted. Be - careful when using Complete mode as you may unintentionally delete resources. Possible values - include: "Incremental", "Complete". + :keyword mode: The mode that is used to deploy resources. This value can be either Incremental + or Complete. In Incremental mode, resources are deployed without deleting existing resources + that are not included in the template. In Complete mode, resources are deployed and existing + resources in the resource group that are not included in the template are deleted. Be careful + when using Complete mode as you may unintentionally delete resources. Required. Known values + are: "Incremental" and "Complete". :paramtype mode: str or ~azure.mgmt.resource.resources.v2019_07_01.models.DeploymentMode :keyword debug_setting: The debug setting of the deployment. :paramtype debug_setting: ~azure.mgmt.resource.resources.v2019_07_01.models.DebugSetting @@ -954,40 +901,44 @@ def __init__( :paramtype what_if_settings: ~azure.mgmt.resource.resources.v2019_07_01.models.DeploymentWhatIfSettings """ - super(DeploymentWhatIfProperties, self).__init__(template=template, template_link=template_link, parameters=parameters, parameters_link=parameters_link, mode=mode, debug_setting=debug_setting, on_error_deployment=on_error_deployment, **kwargs) + super().__init__( + template=template, + template_link=template_link, + parameters=parameters, + parameters_link=parameters_link, + mode=mode, + debug_setting=debug_setting, + on_error_deployment=on_error_deployment, + **kwargs + ) self.what_if_settings = what_if_settings -class DeploymentWhatIfSettings(msrest.serialization.Model): +class DeploymentWhatIfSettings(_serialization.Model): """Deployment What-If operation settings. - :ivar result_format: The format of the What-If results. Possible values include: - "ResourceIdOnly", "FullResourcePayloads". + :ivar result_format: The format of the What-If results. Known values are: "ResourceIdOnly" and + "FullResourcePayloads". :vartype result_format: str or ~azure.mgmt.resource.resources.v2019_07_01.models.WhatIfResultFormat """ _attribute_map = { - 'result_format': {'key': 'resultFormat', 'type': 'str'}, + "result_format": {"key": "resultFormat", "type": "str"}, } - def __init__( - self, - *, - result_format: Optional[Union[str, "WhatIfResultFormat"]] = None, - **kwargs - ): + def __init__(self, *, result_format: Optional[Union[str, "_models.WhatIfResultFormat"]] = None, **kwargs): """ - :keyword result_format: The format of the What-If results. Possible values include: - "ResourceIdOnly", "FullResourcePayloads". + :keyword result_format: The format of the What-If results. Known values are: "ResourceIdOnly" + and "FullResourcePayloads". :paramtype result_format: str or ~azure.mgmt.resource.resources.v2019_07_01.models.WhatIfResultFormat """ - super(DeploymentWhatIfSettings, self).__init__(**kwargs) + super().__init__(**kwargs) self.result_format = result_format -class ErrorAdditionalInfo(msrest.serialization.Model): +class ErrorAdditionalInfo(_serialization.Model): """The resource management error additional info. Variables are only populated by the server, and will be ignored when sending a request. @@ -995,31 +946,27 @@ class ErrorAdditionalInfo(msrest.serialization.Model): :ivar type: The additional info type. :vartype type: str :ivar info: The additional info. - :vartype info: any + :vartype info: JSON """ _validation = { - 'type': {'readonly': True}, - 'info': {'readonly': True}, + "type": {"readonly": True}, + "info": {"readonly": True}, } _attribute_map = { - 'type': {'key': 'type', 'type': 'str'}, - 'info': {'key': 'info', 'type': 'object'}, + "type": {"key": "type", "type": "str"}, + "info": {"key": "info", "type": "object"}, } - def __init__( - self, - **kwargs - ): - """ - """ - super(ErrorAdditionalInfo, self).__init__(**kwargs) + def __init__(self, **kwargs): + """ """ + super().__init__(**kwargs) self.type = None self.info = None -class ErrorResponse(msrest.serialization.Model): +class ErrorResponse(_serialization.Model): """Common error response for all Azure Resource Manager APIs to return error details for failed operations. (This also follows the OData error response format.). Variables are only populated by the server, and will be ignored when sending a request. @@ -1038,28 +985,24 @@ class ErrorResponse(msrest.serialization.Model): """ _validation = { - 'code': {'readonly': True}, - 'message': {'readonly': True}, - 'target': {'readonly': True}, - 'details': {'readonly': True}, - 'additional_info': {'readonly': True}, + "code": {"readonly": True}, + "message": {"readonly": True}, + "target": {"readonly": True}, + "details": {"readonly": True}, + "additional_info": {"readonly": True}, } _attribute_map = { - 'code': {'key': 'code', 'type': 'str'}, - 'message': {'key': 'message', 'type': 'str'}, - 'target': {'key': 'target', 'type': 'str'}, - 'details': {'key': 'details', 'type': '[ErrorResponse]'}, - 'additional_info': {'key': 'additionalInfo', 'type': '[ErrorAdditionalInfo]'}, + "code": {"key": "code", "type": "str"}, + "message": {"key": "message", "type": "str"}, + "target": {"key": "target", "type": "str"}, + "details": {"key": "details", "type": "[ErrorResponse]"}, + "additional_info": {"key": "additionalInfo", "type": "[ErrorAdditionalInfo]"}, } - def __init__( - self, - **kwargs - ): - """ - """ - super(ErrorResponse, self).__init__(**kwargs) + def __init__(self, **kwargs): + """ """ + super().__init__(**kwargs) self.code = None self.message = None self.target = None @@ -1067,7 +1010,7 @@ def __init__( self.additional_info = None -class ExportTemplateRequest(msrest.serialization.Model): +class ExportTemplateRequest(_serialization.Model): """Export resource group template request parameters. :ivar resources: The IDs of the resources to filter the export by. To export all resources, @@ -1080,17 +1023,11 @@ class ExportTemplateRequest(msrest.serialization.Model): """ _attribute_map = { - 'resources': {'key': 'resources', 'type': '[str]'}, - 'options': {'key': 'options', 'type': 'str'}, + "resources": {"key": "resources", "type": "[str]"}, + "options": {"key": "options", "type": "str"}, } - def __init__( - self, - *, - resources: Optional[List[str]] = None, - options: Optional[str] = None, - **kwargs - ): + def __init__(self, *, resources: Optional[List[str]] = None, options: Optional[str] = None, **kwargs): """ :keyword resources: The IDs of the resources to filter the export by. To export all resources, supply an array with single entry '*'. @@ -1100,12 +1037,12 @@ def __init__( 'SkipResourceNameParameterization', 'SkipAllParameterization'. :paramtype options: str """ - super(ExportTemplateRequest, self).__init__(**kwargs) + super().__init__(**kwargs) self.resources = resources self.options = options -class Resource(msrest.serialization.Model): +class Resource(_serialization.Model): """Specified resource. Variables are only populated by the server, and will be ignored when sending a request. @@ -1118,38 +1055,32 @@ class Resource(msrest.serialization.Model): :vartype type: str :ivar location: Resource location. :vartype location: str - :ivar tags: A set of tags. Resource tags. + :ivar tags: Resource tags. :vartype tags: dict[str, str] """ _validation = { - 'id': {'readonly': True}, - 'name': {'readonly': True}, - 'type': {'readonly': True}, + "id": {"readonly": True}, + "name": {"readonly": True}, + "type": {"readonly": True}, } _attribute_map = { - 'id': {'key': 'id', 'type': 'str'}, - 'name': {'key': 'name', 'type': 'str'}, - 'type': {'key': 'type', 'type': 'str'}, - 'location': {'key': 'location', 'type': 'str'}, - 'tags': {'key': 'tags', 'type': '{str}'}, + "id": {"key": "id", "type": "str"}, + "name": {"key": "name", "type": "str"}, + "type": {"key": "type", "type": "str"}, + "location": {"key": "location", "type": "str"}, + "tags": {"key": "tags", "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): """ :keyword location: Resource location. :paramtype location: str - :keyword tags: A set of tags. Resource tags. + :keyword tags: Resource tags. :paramtype tags: dict[str, str] """ - super(Resource, self).__init__(**kwargs) + super().__init__(**kwargs) self.id = None self.name = None self.type = None @@ -1157,7 +1088,7 @@ def __init__( self.tags = tags -class GenericResource(Resource): +class GenericResource(Resource): # pylint: disable=too-many-instance-attributes """Resource information. Variables are only populated by the server, and will be ignored when sending a request. @@ -1170,12 +1101,12 @@ class GenericResource(Resource): :vartype type: str :ivar location: Resource location. :vartype location: str - :ivar tags: A set of tags. Resource tags. + :ivar tags: Resource tags. :vartype tags: dict[str, str] :ivar plan: The plan of the resource. :vartype plan: ~azure.mgmt.resource.resources.v2019_07_01.models.Plan :ivar properties: The resource properties. - :vartype properties: any + :vartype properties: JSON :ivar kind: The kind of the resource. :vartype kind: str :ivar managed_by: ID of the resource that manages this resource. @@ -1187,24 +1118,24 @@ class GenericResource(Resource): """ _validation = { - 'id': {'readonly': True}, - 'name': {'readonly': True}, - 'type': {'readonly': True}, - 'kind': {'pattern': r'^[-\w\._,\(\)]+$'}, + "id": {"readonly": True}, + "name": {"readonly": True}, + "type": {"readonly": True}, + "kind": {"pattern": r"^[-\w\._,\(\)]+$"}, } _attribute_map = { - 'id': {'key': 'id', 'type': 'str'}, - 'name': {'key': 'name', 'type': 'str'}, - 'type': {'key': 'type', 'type': 'str'}, - 'location': {'key': 'location', 'type': 'str'}, - 'tags': {'key': 'tags', 'type': '{str}'}, - 'plan': {'key': 'plan', 'type': 'Plan'}, - 'properties': {'key': 'properties', 'type': 'object'}, - 'kind': {'key': 'kind', 'type': 'str'}, - 'managed_by': {'key': 'managedBy', 'type': 'str'}, - 'sku': {'key': 'sku', 'type': 'Sku'}, - 'identity': {'key': 'identity', 'type': 'Identity'}, + "id": {"key": "id", "type": "str"}, + "name": {"key": "name", "type": "str"}, + "type": {"key": "type", "type": "str"}, + "location": {"key": "location", "type": "str"}, + "tags": {"key": "tags", "type": "{str}"}, + "plan": {"key": "plan", "type": "Plan"}, + "properties": {"key": "properties", "type": "object"}, + "kind": {"key": "kind", "type": "str"}, + "managed_by": {"key": "managedBy", "type": "str"}, + "sku": {"key": "sku", "type": "Sku"}, + "identity": {"key": "identity", "type": "Identity"}, } def __init__( @@ -1212,23 +1143,23 @@ def __init__( *, location: Optional[str] = None, tags: Optional[Dict[str, str]] = None, - plan: Optional["Plan"] = None, - properties: Optional[Any] = None, + plan: Optional["_models.Plan"] = None, + properties: Optional[JSON] = None, kind: Optional[str] = None, managed_by: Optional[str] = None, - sku: Optional["Sku"] = None, - identity: Optional["Identity"] = None, + sku: Optional["_models.Sku"] = None, + identity: Optional["_models.Identity"] = None, **kwargs ): """ :keyword location: Resource location. :paramtype location: str - :keyword tags: A set of tags. Resource tags. + :keyword tags: Resource tags. :paramtype tags: dict[str, str] :keyword plan: The plan of the resource. :paramtype plan: ~azure.mgmt.resource.resources.v2019_07_01.models.Plan :keyword properties: The resource properties. - :paramtype properties: any + :paramtype properties: JSON :keyword kind: The kind of the resource. :paramtype kind: str :keyword managed_by: ID of the resource that manages this resource. @@ -1238,7 +1169,7 @@ def __init__( :keyword identity: The identity of the resource. :paramtype identity: ~azure.mgmt.resource.resources.v2019_07_01.models.Identity """ - super(GenericResource, self).__init__(location=location, tags=tags, **kwargs) + super().__init__(location=location, tags=tags, **kwargs) self.plan = plan self.properties = properties self.kind = kind @@ -1247,7 +1178,7 @@ def __init__( self.identity = identity -class GenericResourceExpanded(GenericResource): +class GenericResourceExpanded(GenericResource): # pylint: disable=too-many-instance-attributes """Resource information. Variables are only populated by the server, and will be ignored when sending a request. @@ -1260,12 +1191,12 @@ class GenericResourceExpanded(GenericResource): :vartype type: str :ivar location: Resource location. :vartype location: str - :ivar tags: A set of tags. Resource tags. + :ivar tags: Resource tags. :vartype tags: dict[str, str] :ivar plan: The plan of the resource. :vartype plan: ~azure.mgmt.resource.resources.v2019_07_01.models.Plan :ivar properties: The resource properties. - :vartype properties: any + :vartype properties: JSON :ivar kind: The kind of the resource. :vartype kind: str :ivar managed_by: ID of the resource that manages this resource. @@ -1286,30 +1217,30 @@ class GenericResourceExpanded(GenericResource): """ _validation = { - 'id': {'readonly': True}, - 'name': {'readonly': True}, - 'type': {'readonly': True}, - 'kind': {'pattern': r'^[-\w\._,\(\)]+$'}, - 'created_time': {'readonly': True}, - 'changed_time': {'readonly': True}, - 'provisioning_state': {'readonly': True}, + "id": {"readonly": True}, + "name": {"readonly": True}, + "type": {"readonly": True}, + "kind": {"pattern": r"^[-\w\._,\(\)]+$"}, + "created_time": {"readonly": True}, + "changed_time": {"readonly": True}, + "provisioning_state": {"readonly": True}, } _attribute_map = { - 'id': {'key': 'id', 'type': 'str'}, - 'name': {'key': 'name', 'type': 'str'}, - 'type': {'key': 'type', 'type': 'str'}, - 'location': {'key': 'location', 'type': 'str'}, - 'tags': {'key': 'tags', 'type': '{str}'}, - 'plan': {'key': 'plan', 'type': 'Plan'}, - 'properties': {'key': 'properties', 'type': 'object'}, - 'kind': {'key': 'kind', 'type': 'str'}, - 'managed_by': {'key': 'managedBy', 'type': 'str'}, - 'sku': {'key': 'sku', 'type': 'Sku'}, - 'identity': {'key': 'identity', 'type': 'Identity'}, - 'created_time': {'key': 'createdTime', 'type': 'iso-8601'}, - 'changed_time': {'key': 'changedTime', 'type': 'iso-8601'}, - 'provisioning_state': {'key': 'provisioningState', 'type': 'str'}, + "id": {"key": "id", "type": "str"}, + "name": {"key": "name", "type": "str"}, + "type": {"key": "type", "type": "str"}, + "location": {"key": "location", "type": "str"}, + "tags": {"key": "tags", "type": "{str}"}, + "plan": {"key": "plan", "type": "Plan"}, + "properties": {"key": "properties", "type": "object"}, + "kind": {"key": "kind", "type": "str"}, + "managed_by": {"key": "managedBy", "type": "str"}, + "sku": {"key": "sku", "type": "Sku"}, + "identity": {"key": "identity", "type": "Identity"}, + "created_time": {"key": "createdTime", "type": "iso-8601"}, + "changed_time": {"key": "changedTime", "type": "iso-8601"}, + "provisioning_state": {"key": "provisioningState", "type": "str"}, } def __init__( @@ -1317,23 +1248,23 @@ def __init__( *, location: Optional[str] = None, tags: Optional[Dict[str, str]] = None, - plan: Optional["Plan"] = None, - properties: Optional[Any] = None, + plan: Optional["_models.Plan"] = None, + properties: Optional[JSON] = None, kind: Optional[str] = None, managed_by: Optional[str] = None, - sku: Optional["Sku"] = None, - identity: Optional["Identity"] = None, + sku: Optional["_models.Sku"] = None, + identity: Optional["_models.Identity"] = None, **kwargs ): """ :keyword location: Resource location. :paramtype location: str - :keyword tags: A set of tags. Resource tags. + :keyword tags: Resource tags. :paramtype tags: dict[str, str] :keyword plan: The plan of the resource. :paramtype plan: ~azure.mgmt.resource.resources.v2019_07_01.models.Plan :keyword properties: The resource properties. - :paramtype properties: any + :paramtype properties: JSON :keyword kind: The kind of the resource. :paramtype kind: str :keyword managed_by: ID of the resource that manages this resource. @@ -1343,13 +1274,23 @@ def __init__( :keyword identity: The identity of the resource. :paramtype identity: ~azure.mgmt.resource.resources.v2019_07_01.models.Identity """ - super(GenericResourceExpanded, self).__init__(location=location, tags=tags, plan=plan, properties=properties, kind=kind, managed_by=managed_by, sku=sku, identity=identity, **kwargs) + super().__init__( + location=location, + tags=tags, + plan=plan, + properties=properties, + kind=kind, + managed_by=managed_by, + sku=sku, + identity=identity, + **kwargs + ) self.created_time = None self.changed_time = None self.provisioning_state = None -class GenericResourceFilter(msrest.serialization.Model): +class GenericResourceFilter(_serialization.Model): """Resource filter. :ivar resource_type: The resource type. @@ -1361,9 +1302,9 @@ class GenericResourceFilter(msrest.serialization.Model): """ _attribute_map = { - 'resource_type': {'key': 'resourceType', 'type': 'str'}, - 'tagname': {'key': 'tagname', 'type': 'str'}, - 'tagvalue': {'key': 'tagvalue', 'type': 'str'}, + "resource_type": {"key": "resourceType", "type": "str"}, + "tagname": {"key": "tagname", "type": "str"}, + "tagvalue": {"key": "tagvalue", "type": "str"}, } def __init__( @@ -1382,38 +1323,33 @@ def __init__( :keyword tagvalue: The tag value. :paramtype tagvalue: str """ - super(GenericResourceFilter, self).__init__(**kwargs) + super().__init__(**kwargs) self.resource_type = resource_type self.tagname = tagname self.tagvalue = tagvalue -class HttpMessage(msrest.serialization.Model): +class HttpMessage(_serialization.Model): """HTTP message. :ivar content: HTTP message content. - :vartype content: any + :vartype content: JSON """ _attribute_map = { - 'content': {'key': 'content', 'type': 'object'}, + "content": {"key": "content", "type": "object"}, } - def __init__( - self, - *, - content: Optional[Any] = None, - **kwargs - ): + def __init__(self, *, content: Optional[JSON] = None, **kwargs): """ :keyword content: HTTP message content. - :paramtype content: any + :paramtype content: JSON """ - super(HttpMessage, self).__init__(**kwargs) + super().__init__(**kwargs) self.content = content -class Identity(msrest.serialization.Model): +class Identity(_serialization.Model): """Identity for the resource. Variables are only populated by the server, and will be ignored when sending a request. @@ -1422,8 +1358,8 @@ class Identity(msrest.serialization.Model): :vartype principal_id: str :ivar tenant_id: The tenant ID of resource. :vartype tenant_id: str - :ivar type: The identity type. Possible values include: "SystemAssigned", "UserAssigned", - "SystemAssigned, UserAssigned", "None". + :ivar type: The identity type. Known values are: "SystemAssigned", "UserAssigned", + "SystemAssigned, UserAssigned", and "None". :vartype type: str or ~azure.mgmt.resource.resources.v2019_07_01.models.ResourceIdentityType :ivar user_assigned_identities: The list of user identities associated with the resource. The user identity dictionary key references will be ARM resource ids in the form: @@ -1433,27 +1369,32 @@ class Identity(msrest.serialization.Model): """ _validation = { - 'principal_id': {'readonly': True}, - 'tenant_id': {'readonly': True}, + "principal_id": {"readonly": True}, + "tenant_id": {"readonly": True}, } _attribute_map = { - 'principal_id': {'key': 'principalId', 'type': 'str'}, - 'tenant_id': {'key': 'tenantId', 'type': 'str'}, - 'type': {'key': 'type', 'type': 'str'}, - 'user_assigned_identities': {'key': 'userAssignedIdentities', 'type': '{ComponentsSgqdofSchemasIdentityPropertiesUserassignedidentitiesAdditionalproperties}'}, + "principal_id": {"key": "principalId", "type": "str"}, + "tenant_id": {"key": "tenantId", "type": "str"}, + "type": {"key": "type", "type": "str"}, + "user_assigned_identities": { + "key": "userAssignedIdentities", + "type": "{ComponentsSgqdofSchemasIdentityPropertiesUserassignedidentitiesAdditionalproperties}", + }, } def __init__( self, *, - type: Optional[Union[str, "ResourceIdentityType"]] = None, - user_assigned_identities: Optional[Dict[str, "ComponentsSgqdofSchemasIdentityPropertiesUserassignedidentitiesAdditionalproperties"]] = None, + type: Optional[Union[str, "_models.ResourceIdentityType"]] = None, + user_assigned_identities: Optional[ + Dict[str, "_models.ComponentsSgqdofSchemasIdentityPropertiesUserassignedidentitiesAdditionalproperties"] + ] = None, **kwargs ): """ - :keyword type: The identity type. Possible values include: "SystemAssigned", "UserAssigned", - "SystemAssigned, UserAssigned", "None". + :keyword type: The identity type. Known values are: "SystemAssigned", "UserAssigned", + "SystemAssigned, UserAssigned", and "None". :paramtype type: str or ~azure.mgmt.resource.resources.v2019_07_01.models.ResourceIdentityType :keyword user_assigned_identities: The list of user identities associated with the resource. The user identity dictionary key references will be ARM resource ids in the form: @@ -1461,48 +1402,48 @@ def __init__( :paramtype user_assigned_identities: dict[str, ~azure.mgmt.resource.resources.v2019_07_01.models.ComponentsSgqdofSchemasIdentityPropertiesUserassignedidentitiesAdditionalproperties] """ - super(Identity, self).__init__(**kwargs) + super().__init__(**kwargs) self.principal_id = None self.tenant_id = None self.type = type self.user_assigned_identities = user_assigned_identities -class OnErrorDeployment(msrest.serialization.Model): +class OnErrorDeployment(_serialization.Model): """Deployment on error behavior. :ivar type: The deployment on error behavior type. Possible values are LastSuccessful and - SpecificDeployment. Possible values include: "LastSuccessful", "SpecificDeployment". + SpecificDeployment. Known values are: "LastSuccessful" and "SpecificDeployment". :vartype type: str or ~azure.mgmt.resource.resources.v2019_07_01.models.OnErrorDeploymentType :ivar deployment_name: The deployment to be used on error case. :vartype deployment_name: str """ _attribute_map = { - 'type': {'key': 'type', 'type': 'str'}, - 'deployment_name': {'key': 'deploymentName', 'type': 'str'}, + "type": {"key": "type", "type": "str"}, + "deployment_name": {"key": "deploymentName", "type": "str"}, } def __init__( self, *, - type: Optional[Union[str, "OnErrorDeploymentType"]] = None, + type: Optional[Union[str, "_models.OnErrorDeploymentType"]] = None, deployment_name: Optional[str] = None, **kwargs ): """ :keyword type: The deployment on error behavior type. Possible values are LastSuccessful and - SpecificDeployment. Possible values include: "LastSuccessful", "SpecificDeployment". + SpecificDeployment. Known values are: "LastSuccessful" and "SpecificDeployment". :paramtype type: str or ~azure.mgmt.resource.resources.v2019_07_01.models.OnErrorDeploymentType :keyword deployment_name: The deployment to be used on error case. :paramtype deployment_name: str """ - super(OnErrorDeployment, self).__init__(**kwargs) + super().__init__(**kwargs) self.type = type self.deployment_name = deployment_name -class OnErrorDeploymentExtended(msrest.serialization.Model): +class OnErrorDeploymentExtended(_serialization.Model): """Deployment on error behavior with additional details. Variables are only populated by the server, and will be ignored when sending a request. @@ -1510,43 +1451,43 @@ class OnErrorDeploymentExtended(msrest.serialization.Model): :ivar provisioning_state: The state of the provisioning for the on error deployment. :vartype provisioning_state: str :ivar type: The deployment on error behavior type. Possible values are LastSuccessful and - SpecificDeployment. Possible values include: "LastSuccessful", "SpecificDeployment". + SpecificDeployment. Known values are: "LastSuccessful" and "SpecificDeployment". :vartype type: str or ~azure.mgmt.resource.resources.v2019_07_01.models.OnErrorDeploymentType :ivar deployment_name: The deployment to be used on error case. :vartype deployment_name: str """ _validation = { - 'provisioning_state': {'readonly': True}, + "provisioning_state": {"readonly": True}, } _attribute_map = { - 'provisioning_state': {'key': 'provisioningState', 'type': 'str'}, - 'type': {'key': 'type', 'type': 'str'}, - 'deployment_name': {'key': 'deploymentName', 'type': 'str'}, + "provisioning_state": {"key": "provisioningState", "type": "str"}, + "type": {"key": "type", "type": "str"}, + "deployment_name": {"key": "deploymentName", "type": "str"}, } def __init__( self, *, - type: Optional[Union[str, "OnErrorDeploymentType"]] = None, + type: Optional[Union[str, "_models.OnErrorDeploymentType"]] = None, deployment_name: Optional[str] = None, **kwargs ): """ :keyword type: The deployment on error behavior type. Possible values are LastSuccessful and - SpecificDeployment. Possible values include: "LastSuccessful", "SpecificDeployment". + SpecificDeployment. Known values are: "LastSuccessful" and "SpecificDeployment". :paramtype type: str or ~azure.mgmt.resource.resources.v2019_07_01.models.OnErrorDeploymentType :keyword deployment_name: The deployment to be used on error case. :paramtype deployment_name: str """ - super(OnErrorDeploymentExtended, self).__init__(**kwargs) + super().__init__(**kwargs) self.provisioning_state = None self.type = type self.deployment_name = deployment_name -class Operation(msrest.serialization.Model): +class Operation(_serialization.Model): """Microsoft.Resources operation. :ivar name: Operation name: {provider}/{resource}/{operation}. @@ -1556,29 +1497,23 @@ class Operation(msrest.serialization.Model): """ _attribute_map = { - 'name': {'key': 'name', 'type': 'str'}, - 'display': {'key': 'display', 'type': 'OperationDisplay'}, + "name": {"key": "name", "type": "str"}, + "display": {"key": "display", "type": "OperationDisplay"}, } - def __init__( - self, - *, - name: Optional[str] = None, - display: Optional["OperationDisplay"] = None, - **kwargs - ): + def __init__(self, *, name: Optional[str] = None, display: Optional["_models.OperationDisplay"] = None, **kwargs): """ :keyword name: Operation name: {provider}/{resource}/{operation}. :paramtype name: str :keyword display: The object that represents the operation. :paramtype display: ~azure.mgmt.resource.resources.v2019_07_01.models.OperationDisplay """ - super(Operation, self).__init__(**kwargs) + super().__init__(**kwargs) self.name = name self.display = display -class OperationDisplay(msrest.serialization.Model): +class OperationDisplay(_serialization.Model): """The object that represents the operation. :ivar provider: Service provider: Microsoft.Resources. @@ -1592,10 +1527,10 @@ class OperationDisplay(msrest.serialization.Model): """ _attribute_map = { - 'provider': {'key': 'provider', 'type': 'str'}, - 'resource': {'key': 'resource', 'type': 'str'}, - 'operation': {'key': 'operation', 'type': 'str'}, - 'description': {'key': 'description', 'type': 'str'}, + "provider": {"key": "provider", "type": "str"}, + "resource": {"key": "resource", "type": "str"}, + "operation": {"key": "operation", "type": "str"}, + "description": {"key": "description", "type": "str"}, } def __init__( @@ -1617,14 +1552,14 @@ def __init__( :keyword description: Description of the operation. :paramtype description: str """ - super(OperationDisplay, self).__init__(**kwargs) + super().__init__(**kwargs) self.provider = provider self.resource = resource self.operation = operation self.description = description -class OperationListResult(msrest.serialization.Model): +class OperationListResult(_serialization.Model): """Result of the request to list Microsoft.Resources operations. It contains a list of operations and a URL link to get the next set of results. :ivar value: List of Microsoft.Resources operations. @@ -1634,67 +1569,55 @@ class OperationListResult(msrest.serialization.Model): """ _attribute_map = { - 'value': {'key': 'value', 'type': '[Operation]'}, - 'next_link': {'key': 'nextLink', 'type': 'str'}, + "value": {"key": "value", "type": "[Operation]"}, + "next_link": {"key": "nextLink", "type": "str"}, } - def __init__( - self, - *, - value: Optional[List["Operation"]] = None, - next_link: Optional[str] = None, - **kwargs - ): + def __init__(self, *, value: Optional[List["_models.Operation"]] = None, next_link: Optional[str] = None, **kwargs): """ :keyword value: List of Microsoft.Resources operations. :paramtype value: list[~azure.mgmt.resource.resources.v2019_07_01.models.Operation] :keyword next_link: URL to get the next set of operation list results if there are any. :paramtype next_link: str """ - super(OperationListResult, self).__init__(**kwargs) + super().__init__(**kwargs) self.value = value self.next_link = next_link -class ParametersLink(msrest.serialization.Model): +class ParametersLink(_serialization.Model): """Entity representing the reference to the deployment parameters. All required parameters must be populated in order to send to Azure. - :ivar uri: Required. The URI of the parameters file. + :ivar uri: The URI of the parameters file. Required. :vartype uri: str :ivar content_version: If included, must match the ContentVersion in the template. :vartype content_version: str """ _validation = { - 'uri': {'required': True}, + "uri": {"required": True}, } _attribute_map = { - 'uri': {'key': 'uri', 'type': 'str'}, - 'content_version': {'key': 'contentVersion', 'type': 'str'}, + "uri": {"key": "uri", "type": "str"}, + "content_version": {"key": "contentVersion", "type": "str"}, } - def __init__( - self, - *, - uri: str, - content_version: Optional[str] = None, - **kwargs - ): + def __init__(self, *, uri: str, content_version: Optional[str] = None, **kwargs): """ - :keyword uri: Required. The URI of the parameters file. + :keyword uri: The URI of the parameters file. Required. :paramtype uri: str :keyword content_version: If included, must match the ContentVersion in the template. :paramtype content_version: str """ - super(ParametersLink, self).__init__(**kwargs) + super().__init__(**kwargs) self.uri = uri self.content_version = content_version -class Plan(msrest.serialization.Model): +class Plan(_serialization.Model): """Plan for the resource. :ivar name: The plan ID. @@ -1710,11 +1633,11 @@ class Plan(msrest.serialization.Model): """ _attribute_map = { - 'name': {'key': 'name', 'type': 'str'}, - 'publisher': {'key': 'publisher', 'type': 'str'}, - 'product': {'key': 'product', 'type': 'str'}, - 'promotion_code': {'key': 'promotionCode', 'type': 'str'}, - 'version': {'key': 'version', 'type': 'str'}, + "name": {"key": "name", "type": "str"}, + "publisher": {"key": "publisher", "type": "str"}, + "product": {"key": "product", "type": "str"}, + "promotion_code": {"key": "promotionCode", "type": "str"}, + "version": {"key": "version", "type": "str"}, } def __init__( @@ -1739,7 +1662,7 @@ def __init__( :keyword version: The plan's version. :paramtype version: str """ - super(Plan, self).__init__(**kwargs) + super().__init__(**kwargs) self.name = name self.publisher = publisher self.product = product @@ -1747,7 +1670,7 @@ def __init__( self.version = version -class Provider(msrest.serialization.Model): +class Provider(_serialization.Model): """Resource provider information. Variables are only populated by the server, and will be ignored when sending a request. @@ -1766,31 +1689,26 @@ class Provider(msrest.serialization.Model): """ _validation = { - 'id': {'readonly': True}, - 'registration_state': {'readonly': True}, - 'registration_policy': {'readonly': True}, - 'resource_types': {'readonly': True}, + "id": {"readonly": True}, + "registration_state": {"readonly": True}, + "registration_policy": {"readonly": True}, + "resource_types": {"readonly": True}, } _attribute_map = { - 'id': {'key': 'id', 'type': 'str'}, - 'namespace': {'key': 'namespace', 'type': 'str'}, - 'registration_state': {'key': 'registrationState', 'type': 'str'}, - 'registration_policy': {'key': 'registrationPolicy', 'type': 'str'}, - 'resource_types': {'key': 'resourceTypes', 'type': '[ProviderResourceType]'}, + "id": {"key": "id", "type": "str"}, + "namespace": {"key": "namespace", "type": "str"}, + "registration_state": {"key": "registrationState", "type": "str"}, + "registration_policy": {"key": "registrationPolicy", "type": "str"}, + "resource_types": {"key": "resourceTypes", "type": "[ProviderResourceType]"}, } - def __init__( - self, - *, - namespace: Optional[str] = None, - **kwargs - ): + def __init__(self, *, namespace: Optional[str] = None, **kwargs): """ :keyword namespace: The namespace of the resource provider. :paramtype namespace: str """ - super(Provider, self).__init__(**kwargs) + super().__init__(**kwargs) self.id = None self.namespace = namespace self.registration_state = None @@ -1798,7 +1716,7 @@ def __init__( self.resource_types = None -class ProviderListResult(msrest.serialization.Model): +class ProviderListResult(_serialization.Model): """List of resource providers. Variables are only populated by the server, and will be ignored when sending a request. @@ -1810,30 +1728,25 @@ class ProviderListResult(msrest.serialization.Model): """ _validation = { - 'next_link': {'readonly': True}, + "next_link": {"readonly": True}, } _attribute_map = { - 'value': {'key': 'value', 'type': '[Provider]'}, - 'next_link': {'key': 'nextLink', 'type': 'str'}, + "value": {"key": "value", "type": "[Provider]"}, + "next_link": {"key": "nextLink", "type": "str"}, } - def __init__( - self, - *, - value: Optional[List["Provider"]] = None, - **kwargs - ): + def __init__(self, *, value: Optional[List["_models.Provider"]] = None, **kwargs): """ :keyword value: An array of resource providers. :paramtype value: list[~azure.mgmt.resource.resources.v2019_07_01.models.Provider] """ - super(ProviderListResult, self).__init__(**kwargs) + super().__init__(**kwargs) self.value = value self.next_link = None -class ProviderResourceType(msrest.serialization.Model): +class ProviderResourceType(_serialization.Model): """Resource type managed by the resource provider. :ivar resource_type: The resource type. @@ -1853,13 +1766,13 @@ class ProviderResourceType(msrest.serialization.Model): """ _attribute_map = { - 'resource_type': {'key': 'resourceType', 'type': 'str'}, - 'locations': {'key': 'locations', 'type': '[str]'}, - 'aliases': {'key': 'aliases', 'type': '[AliasType]'}, - 'api_versions': {'key': 'apiVersions', 'type': '[str]'}, - 'zone_mappings': {'key': 'zoneMappings', 'type': '[ZoneMapping]'}, - 'capabilities': {'key': 'capabilities', 'type': 'str'}, - 'properties': {'key': 'properties', 'type': '{str}'}, + "resource_type": {"key": "resourceType", "type": "str"}, + "locations": {"key": "locations", "type": "[str]"}, + "aliases": {"key": "aliases", "type": "[AliasType]"}, + "api_versions": {"key": "apiVersions", "type": "[str]"}, + "zone_mappings": {"key": "zoneMappings", "type": "[ZoneMapping]"}, + "capabilities": {"key": "capabilities", "type": "str"}, + "properties": {"key": "properties", "type": "{str}"}, } def __init__( @@ -1867,9 +1780,9 @@ def __init__( *, resource_type: Optional[str] = None, locations: Optional[List[str]] = None, - aliases: Optional[List["AliasType"]] = None, + aliases: Optional[List["_models.AliasType"]] = None, api_versions: Optional[List[str]] = None, - zone_mappings: Optional[List["ZoneMapping"]] = None, + zone_mappings: Optional[List["_models.ZoneMapping"]] = None, capabilities: Optional[str] = None, properties: Optional[Dict[str, str]] = None, **kwargs @@ -1890,7 +1803,7 @@ def __init__( :keyword properties: The properties. :paramtype properties: dict[str, str] """ - super(ProviderResourceType, self).__init__(**kwargs) + super().__init__(**kwargs) self.resource_type = resource_type self.locations = locations self.aliases = aliases @@ -1900,7 +1813,7 @@ def __init__( self.properties = properties -class ResourceGroup(msrest.serialization.Model): +class ResourceGroup(_serialization.Model): """Resource group information. Variables are only populated by the server, and will be ignored when sending a request. @@ -1915,37 +1828,37 @@ class ResourceGroup(msrest.serialization.Model): :vartype type: str :ivar properties: The resource group properties. :vartype properties: ~azure.mgmt.resource.resources.v2019_07_01.models.ResourceGroupProperties - :ivar location: Required. The location of the resource group. It cannot be changed after the - resource group has been created. It must be one of the supported Azure locations. + :ivar location: The location of the resource group. It cannot be changed after the resource + group has been created. It must be one of the supported Azure locations. Required. :vartype location: str :ivar managed_by: The ID of the resource that manages this resource group. :vartype managed_by: str - :ivar tags: A set of tags. The tags attached to the resource group. + :ivar tags: The tags attached to the resource group. :vartype tags: dict[str, str] """ _validation = { - 'id': {'readonly': True}, - 'name': {'readonly': True}, - 'type': {'readonly': True}, - 'location': {'required': True}, + "id": {"readonly": True}, + "name": {"readonly": True}, + "type": {"readonly": True}, + "location": {"required": True}, } _attribute_map = { - 'id': {'key': 'id', 'type': 'str'}, - 'name': {'key': 'name', 'type': 'str'}, - 'type': {'key': 'type', 'type': 'str'}, - 'properties': {'key': 'properties', 'type': 'ResourceGroupProperties'}, - 'location': {'key': 'location', 'type': 'str'}, - 'managed_by': {'key': 'managedBy', 'type': 'str'}, - 'tags': {'key': 'tags', 'type': '{str}'}, + "id": {"key": "id", "type": "str"}, + "name": {"key": "name", "type": "str"}, + "type": {"key": "type", "type": "str"}, + "properties": {"key": "properties", "type": "ResourceGroupProperties"}, + "location": {"key": "location", "type": "str"}, + "managed_by": {"key": "managedBy", "type": "str"}, + "tags": {"key": "tags", "type": "{str}"}, } def __init__( self, *, location: str, - properties: Optional["ResourceGroupProperties"] = None, + properties: Optional["_models.ResourceGroupProperties"] = None, managed_by: Optional[str] = None, tags: Optional[Dict[str, str]] = None, **kwargs @@ -1954,15 +1867,15 @@ def __init__( :keyword properties: The resource group properties. :paramtype properties: ~azure.mgmt.resource.resources.v2019_07_01.models.ResourceGroupProperties - :keyword location: Required. The location of the resource group. It cannot be changed after the - resource group has been created. It must be one of the supported Azure locations. + :keyword location: The location of the resource group. It cannot be changed after the resource + group has been created. It must be one of the supported Azure locations. Required. :paramtype location: str :keyword managed_by: The ID of the resource that manages this resource group. :paramtype managed_by: str - :keyword tags: A set of tags. The tags attached to the resource group. + :keyword tags: The tags attached to the resource group. :paramtype tags: dict[str, str] """ - super(ResourceGroup, self).__init__(**kwargs) + super().__init__(**kwargs) self.id = None self.name = None self.type = None @@ -1972,39 +1885,33 @@ def __init__( self.tags = tags -class ResourceGroupExportResult(msrest.serialization.Model): +class ResourceGroupExportResult(_serialization.Model): """Resource group export result. :ivar template: The template content. - :vartype template: any + :vartype template: JSON :ivar error: The template export error. :vartype error: ~azure.mgmt.resource.resources.v2019_07_01.models.ErrorResponse """ _attribute_map = { - 'template': {'key': 'template', 'type': 'object'}, - 'error': {'key': 'error', 'type': 'ErrorResponse'}, + "template": {"key": "template", "type": "object"}, + "error": {"key": "error", "type": "ErrorResponse"}, } - def __init__( - self, - *, - template: Optional[Any] = None, - error: Optional["ErrorResponse"] = None, - **kwargs - ): + def __init__(self, *, template: Optional[JSON] = None, error: Optional["_models.ErrorResponse"] = None, **kwargs): """ :keyword template: The template content. - :paramtype template: any + :paramtype template: JSON :keyword error: The template export error. :paramtype error: ~azure.mgmt.resource.resources.v2019_07_01.models.ErrorResponse """ - super(ResourceGroupExportResult, self).__init__(**kwargs) + super().__init__(**kwargs) self.template = template self.error = error -class ResourceGroupFilter(msrest.serialization.Model): +class ResourceGroupFilter(_serialization.Model): """Resource group filter. :ivar tag_name: The tag name. @@ -2014,29 +1921,23 @@ class ResourceGroupFilter(msrest.serialization.Model): """ _attribute_map = { - 'tag_name': {'key': 'tagName', 'type': 'str'}, - 'tag_value': {'key': 'tagValue', 'type': 'str'}, + "tag_name": {"key": "tagName", "type": "str"}, + "tag_value": {"key": "tagValue", "type": "str"}, } - def __init__( - self, - *, - tag_name: Optional[str] = None, - tag_value: Optional[str] = None, - **kwargs - ): + def __init__(self, *, tag_name: Optional[str] = None, tag_value: Optional[str] = None, **kwargs): """ :keyword tag_name: The tag name. :paramtype tag_name: str :keyword tag_value: The tag value. :paramtype tag_value: str """ - super(ResourceGroupFilter, self).__init__(**kwargs) + super().__init__(**kwargs) self.tag_name = tag_name self.tag_value = tag_value -class ResourceGroupListResult(msrest.serialization.Model): +class ResourceGroupListResult(_serialization.Model): """List of resource groups. Variables are only populated by the server, and will be ignored when sending a request. @@ -2048,30 +1949,25 @@ class ResourceGroupListResult(msrest.serialization.Model): """ _validation = { - 'next_link': {'readonly': True}, + "next_link": {"readonly": True}, } _attribute_map = { - 'value': {'key': 'value', 'type': '[ResourceGroup]'}, - 'next_link': {'key': 'nextLink', 'type': 'str'}, + "value": {"key": "value", "type": "[ResourceGroup]"}, + "next_link": {"key": "nextLink", "type": "str"}, } - def __init__( - self, - *, - value: Optional[List["ResourceGroup"]] = None, - **kwargs - ): + def __init__(self, *, value: Optional[List["_models.ResourceGroup"]] = None, **kwargs): """ :keyword value: An array of resource groups. :paramtype value: list[~azure.mgmt.resource.resources.v2019_07_01.models.ResourceGroup] """ - super(ResourceGroupListResult, self).__init__(**kwargs) + super().__init__(**kwargs) self.value = value self.next_link = None -class ResourceGroupPatchable(msrest.serialization.Model): +class ResourceGroupPatchable(_serialization.Model): """Resource group information. :ivar name: The name of the resource group. @@ -2080,22 +1976,22 @@ class ResourceGroupPatchable(msrest.serialization.Model): :vartype properties: ~azure.mgmt.resource.resources.v2019_07_01.models.ResourceGroupProperties :ivar managed_by: The ID of the resource that manages this resource group. :vartype managed_by: str - :ivar tags: A set of tags. The tags attached to the resource group. + :ivar tags: The tags attached to the resource group. :vartype tags: dict[str, str] """ _attribute_map = { - 'name': {'key': 'name', 'type': 'str'}, - 'properties': {'key': 'properties', 'type': 'ResourceGroupProperties'}, - 'managed_by': {'key': 'managedBy', 'type': 'str'}, - 'tags': {'key': 'tags', 'type': '{str}'}, + "name": {"key": "name", "type": "str"}, + "properties": {"key": "properties", "type": "ResourceGroupProperties"}, + "managed_by": {"key": "managedBy", "type": "str"}, + "tags": {"key": "tags", "type": "{str}"}, } def __init__( self, *, name: Optional[str] = None, - properties: Optional["ResourceGroupProperties"] = None, + properties: Optional["_models.ResourceGroupProperties"] = None, managed_by: Optional[str] = None, tags: Optional[Dict[str, str]] = None, **kwargs @@ -2108,17 +2004,17 @@ def __init__( ~azure.mgmt.resource.resources.v2019_07_01.models.ResourceGroupProperties :keyword managed_by: The ID of the resource that manages this resource group. :paramtype managed_by: str - :keyword tags: A set of tags. The tags attached to the resource group. + :keyword tags: The tags attached to the resource group. :paramtype tags: dict[str, str] """ - super(ResourceGroupPatchable, self).__init__(**kwargs) + super().__init__(**kwargs) self.name = name self.properties = properties self.managed_by = managed_by self.tags = tags -class ResourceGroupProperties(msrest.serialization.Model): +class ResourceGroupProperties(_serialization.Model): """The resource group properties. Variables are only populated by the server, and will be ignored when sending a request. @@ -2128,24 +2024,20 @@ class ResourceGroupProperties(msrest.serialization.Model): """ _validation = { - 'provisioning_state': {'readonly': True}, + "provisioning_state": {"readonly": True}, } _attribute_map = { - 'provisioning_state': {'key': 'provisioningState', 'type': 'str'}, + "provisioning_state": {"key": "provisioningState", "type": "str"}, } - def __init__( - self, - **kwargs - ): - """ - """ - super(ResourceGroupProperties, self).__init__(**kwargs) + def __init__(self, **kwargs): + """ """ + super().__init__(**kwargs) self.provisioning_state = None -class ResourceListResult(msrest.serialization.Model): +class ResourceListResult(_serialization.Model): """List of resource groups. Variables are only populated by the server, and will be ignored when sending a request. @@ -2157,31 +2049,26 @@ class ResourceListResult(msrest.serialization.Model): """ _validation = { - 'next_link': {'readonly': True}, + "next_link": {"readonly": True}, } _attribute_map = { - 'value': {'key': 'value', 'type': '[GenericResourceExpanded]'}, - 'next_link': {'key': 'nextLink', 'type': 'str'}, + "value": {"key": "value", "type": "[GenericResourceExpanded]"}, + "next_link": {"key": "nextLink", "type": "str"}, } - def __init__( - self, - *, - value: Optional[List["GenericResourceExpanded"]] = None, - **kwargs - ): + def __init__(self, *, value: Optional[List["_models.GenericResourceExpanded"]] = None, **kwargs): """ :keyword value: An array of resources. :paramtype value: list[~azure.mgmt.resource.resources.v2019_07_01.models.GenericResourceExpanded] """ - super(ResourceListResult, self).__init__(**kwargs) + super().__init__(**kwargs) self.value = value self.next_link = None -class ResourceProviderOperationDisplayProperties(msrest.serialization.Model): +class ResourceProviderOperationDisplayProperties(_serialization.Model): """Resource provider operation's display properties. :ivar publisher: Operation description. @@ -2197,11 +2084,11 @@ class ResourceProviderOperationDisplayProperties(msrest.serialization.Model): """ _attribute_map = { - 'publisher': {'key': 'publisher', 'type': 'str'}, - 'provider': {'key': 'provider', 'type': 'str'}, - 'resource': {'key': 'resource', 'type': 'str'}, - 'operation': {'key': 'operation', 'type': 'str'}, - 'description': {'key': 'description', 'type': 'str'}, + "publisher": {"key": "publisher", "type": "str"}, + "provider": {"key": "provider", "type": "str"}, + "resource": {"key": "resource", "type": "str"}, + "operation": {"key": "operation", "type": "str"}, + "description": {"key": "description", "type": "str"}, } def __init__( @@ -2226,7 +2113,7 @@ def __init__( :keyword description: Operation description. :paramtype description: str """ - super(ResourceProviderOperationDisplayProperties, self).__init__(**kwargs) + super().__init__(**kwargs) self.publisher = publisher self.provider = provider self.resource = resource @@ -2234,7 +2121,7 @@ def __init__( self.description = description -class ResourcesMoveInfo(msrest.serialization.Model): +class ResourcesMoveInfo(_serialization.Model): """Parameters of move resources. :ivar resources: The IDs of the resources. @@ -2244,29 +2131,23 @@ class ResourcesMoveInfo(msrest.serialization.Model): """ _attribute_map = { - 'resources': {'key': 'resources', 'type': '[str]'}, - 'target_resource_group': {'key': 'targetResourceGroup', 'type': 'str'}, + "resources": {"key": "resources", "type": "[str]"}, + "target_resource_group": {"key": "targetResourceGroup", "type": "str"}, } - def __init__( - self, - *, - resources: Optional[List[str]] = None, - target_resource_group: Optional[str] = None, - **kwargs - ): + def __init__(self, *, resources: Optional[List[str]] = None, target_resource_group: Optional[str] = None, **kwargs): """ :keyword resources: The IDs of the resources. :paramtype resources: list[str] :keyword target_resource_group: The target resource group. :paramtype target_resource_group: str """ - super(ResourcesMoveInfo, self).__init__(**kwargs) + super().__init__(**kwargs) self.resources = resources self.target_resource_group = target_resource_group -class Sku(msrest.serialization.Model): +class Sku(_serialization.Model): """SKU for the resource. :ivar name: The SKU name. @@ -2284,12 +2165,12 @@ class Sku(msrest.serialization.Model): """ _attribute_map = { - 'name': {'key': 'name', 'type': 'str'}, - 'tier': {'key': 'tier', 'type': 'str'}, - 'size': {'key': 'size', 'type': 'str'}, - 'family': {'key': 'family', 'type': 'str'}, - 'model': {'key': 'model', 'type': 'str'}, - 'capacity': {'key': 'capacity', 'type': 'int'}, + "name": {"key": "name", "type": "str"}, + "tier": {"key": "tier", "type": "str"}, + "size": {"key": "size", "type": "str"}, + "family": {"key": "family", "type": "str"}, + "model": {"key": "model", "type": "str"}, + "capacity": {"key": "capacity", "type": "int"}, } def __init__( @@ -2317,7 +2198,7 @@ def __init__( :keyword capacity: The SKU capacity. :paramtype capacity: int """ - super(Sku, self).__init__(**kwargs) + super().__init__(**kwargs) self.name = name self.tier = tier self.size = size @@ -2326,7 +2207,7 @@ def __init__( self.capacity = capacity -class SubResource(msrest.serialization.Model): +class SubResource(_serialization.Model): """Sub-resource. :ivar id: Resource ID. @@ -2334,24 +2215,19 @@ class SubResource(msrest.serialization.Model): """ _attribute_map = { - 'id': {'key': 'id', 'type': 'str'}, + "id": {"key": "id", "type": "str"}, } - def __init__( - self, - *, - id: Optional[str] = None, - **kwargs - ): + def __init__(self, *, id: Optional[str] = None, **kwargs): # pylint: disable=redefined-builtin """ :keyword id: Resource ID. :paramtype id: str """ - super(SubResource, self).__init__(**kwargs) + super().__init__(**kwargs) self.id = id -class TagCount(msrest.serialization.Model): +class TagCount(_serialization.Model): """Tag count. :ivar type: Type of count. @@ -2361,29 +2237,23 @@ class TagCount(msrest.serialization.Model): """ _attribute_map = { - 'type': {'key': 'type', 'type': 'str'}, - 'value': {'key': 'value', 'type': 'int'}, + "type": {"key": "type", "type": "str"}, + "value": {"key": "value", "type": "int"}, } - def __init__( - self, - *, - type: Optional[str] = None, - value: Optional[int] = None, - **kwargs - ): + def __init__(self, *, type: Optional[str] = None, value: Optional[int] = None, **kwargs): """ :keyword type: Type of count. :paramtype type: str :keyword value: Value of count. :paramtype value: int """ - super(TagCount, self).__init__(**kwargs) + super().__init__(**kwargs) self.type = type self.value = value -class TagDetails(msrest.serialization.Model): +class TagDetails(_serialization.Model): """Tag details. Variables are only populated by the server, and will be ignored when sending a request. @@ -2400,22 +2270,22 @@ class TagDetails(msrest.serialization.Model): """ _validation = { - 'id': {'readonly': True}, + "id": {"readonly": True}, } _attribute_map = { - 'id': {'key': 'id', 'type': 'str'}, - 'tag_name': {'key': 'tagName', 'type': 'str'}, - 'count': {'key': 'count', 'type': 'TagCount'}, - 'values': {'key': 'values', 'type': '[TagValue]'}, + "id": {"key": "id", "type": "str"}, + "tag_name": {"key": "tagName", "type": "str"}, + "count": {"key": "count", "type": "TagCount"}, + "values": {"key": "values", "type": "[TagValue]"}, } def __init__( self, *, tag_name: Optional[str] = None, - count: Optional["TagCount"] = None, - values: Optional[List["TagValue"]] = None, + count: Optional["_models.TagCount"] = None, + values: Optional[List["_models.TagValue"]] = None, **kwargs ): """ @@ -2427,14 +2297,14 @@ def __init__( :keyword values: The list of tag values. :paramtype values: list[~azure.mgmt.resource.resources.v2019_07_01.models.TagValue] """ - super(TagDetails, self).__init__(**kwargs) + super().__init__(**kwargs) self.id = None self.tag_name = tag_name self.count = count self.values = values -class TagsListResult(msrest.serialization.Model): +class TagsListResult(_serialization.Model): """List of subscription tags. Variables are only populated by the server, and will be ignored when sending a request. @@ -2446,30 +2316,25 @@ class TagsListResult(msrest.serialization.Model): """ _validation = { - 'next_link': {'readonly': True}, + "next_link": {"readonly": True}, } _attribute_map = { - 'value': {'key': 'value', 'type': '[TagDetails]'}, - 'next_link': {'key': 'nextLink', 'type': 'str'}, + "value": {"key": "value", "type": "[TagDetails]"}, + "next_link": {"key": "nextLink", "type": "str"}, } - def __init__( - self, - *, - value: Optional[List["TagDetails"]] = None, - **kwargs - ): + def __init__(self, *, value: Optional[List["_models.TagDetails"]] = None, **kwargs): """ :keyword value: An array of tags. :paramtype value: list[~azure.mgmt.resource.resources.v2019_07_01.models.TagDetails] """ - super(TagsListResult, self).__init__(**kwargs) + super().__init__(**kwargs) self.value = value self.next_link = None -class TagValue(msrest.serialization.Model): +class TagValue(_serialization.Model): """Tag information. Variables are only populated by the server, and will be ignored when sending a request. @@ -2483,35 +2348,29 @@ class TagValue(msrest.serialization.Model): """ _validation = { - 'id': {'readonly': True}, + "id": {"readonly": True}, } _attribute_map = { - 'id': {'key': 'id', 'type': 'str'}, - 'tag_value': {'key': 'tagValue', 'type': 'str'}, - 'count': {'key': 'count', 'type': 'TagCount'}, + "id": {"key": "id", "type": "str"}, + "tag_value": {"key": "tagValue", "type": "str"}, + "count": {"key": "count", "type": "TagCount"}, } - def __init__( - self, - *, - tag_value: Optional[str] = None, - count: Optional["TagCount"] = None, - **kwargs - ): + def __init__(self, *, tag_value: Optional[str] = None, count: Optional["_models.TagCount"] = None, **kwargs): """ :keyword tag_value: The tag value. :paramtype tag_value: str :keyword count: The tag value count. :paramtype count: ~azure.mgmt.resource.resources.v2019_07_01.models.TagCount """ - super(TagValue, self).__init__(**kwargs) + super().__init__(**kwargs) self.id = None self.tag_value = tag_value self.count = count -class TargetResource(msrest.serialization.Model): +class TargetResource(_serialization.Model): """Target resource. :ivar id: The ID of the resource. @@ -2523,15 +2382,15 @@ class TargetResource(msrest.serialization.Model): """ _attribute_map = { - 'id': {'key': 'id', 'type': 'str'}, - 'resource_name': {'key': 'resourceName', 'type': 'str'}, - 'resource_type': {'key': 'resourceType', 'type': 'str'}, + "id": {"key": "id", "type": "str"}, + "resource_name": {"key": "resourceName", "type": "str"}, + "resource_type": {"key": "resourceType", "type": "str"}, } def __init__( self, *, - id: Optional[str] = None, + id: Optional[str] = None, # pylint: disable=redefined-builtin resource_name: Optional[str] = None, resource_type: Optional[str] = None, **kwargs @@ -2544,13 +2403,13 @@ def __init__( :keyword resource_type: The type of the resource. :paramtype resource_type: str """ - super(TargetResource, self).__init__(**kwargs) + super().__init__(**kwargs) self.id = id self.resource_name = resource_name self.resource_type = resource_type -class TemplateHashResult(msrest.serialization.Model): +class TemplateHashResult(_serialization.Model): """Result of the request to calculate template hash. It contains a string of minified template and its hash. :ivar minified_template: The minified template string. @@ -2560,123 +2419,111 @@ class TemplateHashResult(msrest.serialization.Model): """ _attribute_map = { - 'minified_template': {'key': 'minifiedTemplate', 'type': 'str'}, - 'template_hash': {'key': 'templateHash', 'type': 'str'}, + "minified_template": {"key": "minifiedTemplate", "type": "str"}, + "template_hash": {"key": "templateHash", "type": "str"}, } - def __init__( - self, - *, - minified_template: Optional[str] = None, - template_hash: Optional[str] = None, - **kwargs - ): + def __init__(self, *, minified_template: Optional[str] = None, template_hash: Optional[str] = None, **kwargs): """ :keyword minified_template: The minified template string. :paramtype minified_template: str :keyword template_hash: The template hash. :paramtype template_hash: str """ - super(TemplateHashResult, self).__init__(**kwargs) + super().__init__(**kwargs) self.minified_template = minified_template self.template_hash = template_hash -class TemplateLink(msrest.serialization.Model): +class TemplateLink(_serialization.Model): """Entity representing the reference to the template. All required parameters must be populated in order to send to Azure. - :ivar uri: Required. The URI of the template to deploy. + :ivar uri: The URI of the template to deploy. Required. :vartype uri: str :ivar content_version: If included, must match the ContentVersion in the template. :vartype content_version: str """ _validation = { - 'uri': {'required': True}, + "uri": {"required": True}, } _attribute_map = { - 'uri': {'key': 'uri', 'type': 'str'}, - 'content_version': {'key': 'contentVersion', 'type': 'str'}, + "uri": {"key": "uri", "type": "str"}, + "content_version": {"key": "contentVersion", "type": "str"}, } - def __init__( - self, - *, - uri: str, - content_version: Optional[str] = None, - **kwargs - ): + def __init__(self, *, uri: str, content_version: Optional[str] = None, **kwargs): """ - :keyword uri: Required. The URI of the template to deploy. + :keyword uri: The URI of the template to deploy. Required. :paramtype uri: str :keyword content_version: If included, must match the ContentVersion in the template. :paramtype content_version: str """ - super(TemplateLink, self).__init__(**kwargs) + super().__init__(**kwargs) self.uri = uri self.content_version = content_version -class WhatIfChange(msrest.serialization.Model): +class WhatIfChange(_serialization.Model): """Information about a single resource change predicted by What-If operation. All required parameters must be populated in order to send to Azure. - :ivar resource_id: Required. Resource ID. + :ivar resource_id: Resource ID. Required. :vartype resource_id: str - :ivar change_type: Required. Type of change that will be made to the resource when the - deployment is executed. Possible values include: "Create", "Delete", "Ignore", "Deploy", - "NoChange", "Modify". + :ivar change_type: Type of change that will be made to the resource when the deployment is + executed. Required. Known values are: "Create", "Delete", "Ignore", "Deploy", "NoChange", and + "Modify". :vartype change_type: str or ~azure.mgmt.resource.resources.v2019_07_01.models.ChangeType :ivar before: The snapshot of the resource before the deployment is executed. - :vartype before: any + :vartype before: JSON :ivar after: The predicted snapshot of the resource after the deployment is executed. - :vartype after: any + :vartype after: JSON :ivar delta: The predicted changes to resource properties. :vartype delta: list[~azure.mgmt.resource.resources.v2019_07_01.models.WhatIfPropertyChange] """ _validation = { - 'resource_id': {'required': True}, - 'change_type': {'required': True}, + "resource_id": {"required": True}, + "change_type": {"required": True}, } _attribute_map = { - 'resource_id': {'key': 'resourceId', 'type': 'str'}, - 'change_type': {'key': 'changeType', 'type': 'str'}, - 'before': {'key': 'before', 'type': 'object'}, - 'after': {'key': 'after', 'type': 'object'}, - 'delta': {'key': 'delta', 'type': '[WhatIfPropertyChange]'}, + "resource_id": {"key": "resourceId", "type": "str"}, + "change_type": {"key": "changeType", "type": "str"}, + "before": {"key": "before", "type": "object"}, + "after": {"key": "after", "type": "object"}, + "delta": {"key": "delta", "type": "[WhatIfPropertyChange]"}, } def __init__( self, *, resource_id: str, - change_type: Union[str, "ChangeType"], - before: Optional[Any] = None, - after: Optional[Any] = None, - delta: Optional[List["WhatIfPropertyChange"]] = None, + change_type: Union[str, "_models.ChangeType"], + before: Optional[JSON] = None, + after: Optional[JSON] = None, + delta: Optional[List["_models.WhatIfPropertyChange"]] = None, **kwargs ): """ - :keyword resource_id: Required. Resource ID. + :keyword resource_id: Resource ID. Required. :paramtype resource_id: str - :keyword change_type: Required. Type of change that will be made to the resource when the - deployment is executed. Possible values include: "Create", "Delete", "Ignore", "Deploy", - "NoChange", "Modify". + :keyword change_type: Type of change that will be made to the resource when the deployment is + executed. Required. Known values are: "Create", "Delete", "Ignore", "Deploy", "NoChange", and + "Modify". :paramtype change_type: str or ~azure.mgmt.resource.resources.v2019_07_01.models.ChangeType :keyword before: The snapshot of the resource before the deployment is executed. - :paramtype before: any + :paramtype before: JSON :keyword after: The predicted snapshot of the resource after the deployment is executed. - :paramtype after: any + :paramtype after: JSON :keyword delta: The predicted changes to resource properties. :paramtype delta: list[~azure.mgmt.resource.resources.v2019_07_01.models.WhatIfPropertyChange] """ - super(WhatIfChange, self).__init__(**kwargs) + super().__init__(**kwargs) self.resource_id = resource_id self.change_type = change_type self.before = before @@ -2684,7 +2531,7 @@ def __init__( self.delta = delta -class WhatIfOperationResult(msrest.serialization.Model): +class WhatIfOperationResult(_serialization.Model): """Result of the What-If operation. Contains a list of predicted changes and a URL link to get to the next set of results. :ivar status: Status of the What-If operation. @@ -2696,17 +2543,17 @@ class WhatIfOperationResult(msrest.serialization.Model): """ _attribute_map = { - 'status': {'key': 'status', 'type': 'str'}, - 'error': {'key': 'error', 'type': 'ErrorResponse'}, - 'changes': {'key': 'properties.changes', 'type': '[WhatIfChange]'}, + "status": {"key": "status", "type": "str"}, + "error": {"key": "error", "type": "ErrorResponse"}, + "changes": {"key": "properties.changes", "type": "[WhatIfChange]"}, } def __init__( self, *, status: Optional[str] = None, - error: Optional["ErrorResponse"] = None, - changes: Optional[List["WhatIfChange"]] = None, + error: Optional["_models.ErrorResponse"] = None, + changes: Optional[List["_models.WhatIfChange"]] = None, **kwargs ): """ @@ -2717,70 +2564,70 @@ def __init__( :keyword changes: List of resource changes predicted by What-If operation. :paramtype changes: list[~azure.mgmt.resource.resources.v2019_07_01.models.WhatIfChange] """ - super(WhatIfOperationResult, self).__init__(**kwargs) + super().__init__(**kwargs) self.status = status self.error = error self.changes = changes -class WhatIfPropertyChange(msrest.serialization.Model): +class WhatIfPropertyChange(_serialization.Model): """The predicted change to the resource property. All required parameters must be populated in order to send to Azure. - :ivar path: Required. The path of the property. + :ivar path: The path of the property. Required. :vartype path: str - :ivar property_change_type: Required. The type of property change. Possible values include: - "Create", "Delete", "Modify", "Array". + :ivar property_change_type: The type of property change. Required. Known values are: "Create", + "Delete", "Modify", and "Array". :vartype property_change_type: str or ~azure.mgmt.resource.resources.v2019_07_01.models.PropertyChangeType :ivar before: The value of the property before the deployment is executed. - :vartype before: any + :vartype before: JSON :ivar after: The value of the property after the deployment is executed. - :vartype after: any + :vartype after: JSON :ivar children: Nested property changes. :vartype children: list[~azure.mgmt.resource.resources.v2019_07_01.models.WhatIfPropertyChange] """ _validation = { - 'path': {'required': True}, - 'property_change_type': {'required': True}, + "path": {"required": True}, + "property_change_type": {"required": True}, } _attribute_map = { - 'path': {'key': 'path', 'type': 'str'}, - 'property_change_type': {'key': 'propertyChangeType', 'type': 'str'}, - 'before': {'key': 'before', 'type': 'object'}, - 'after': {'key': 'after', 'type': 'object'}, - 'children': {'key': 'children', 'type': '[WhatIfPropertyChange]'}, + "path": {"key": "path", "type": "str"}, + "property_change_type": {"key": "propertyChangeType", "type": "str"}, + "before": {"key": "before", "type": "object"}, + "after": {"key": "after", "type": "object"}, + "children": {"key": "children", "type": "[WhatIfPropertyChange]"}, } def __init__( self, *, path: str, - property_change_type: Union[str, "PropertyChangeType"], - before: Optional[Any] = None, - after: Optional[Any] = None, - children: Optional[List["WhatIfPropertyChange"]] = None, + property_change_type: Union[str, "_models.PropertyChangeType"], + before: Optional[JSON] = None, + after: Optional[JSON] = None, + children: Optional[List["_models.WhatIfPropertyChange"]] = None, **kwargs ): """ - :keyword path: Required. The path of the property. + :keyword path: The path of the property. Required. :paramtype path: str - :keyword property_change_type: Required. The type of property change. Possible values include: - "Create", "Delete", "Modify", "Array". + :keyword property_change_type: The type of property change. Required. Known values are: + "Create", "Delete", "Modify", and "Array". :paramtype property_change_type: str or ~azure.mgmt.resource.resources.v2019_07_01.models.PropertyChangeType :keyword before: The value of the property before the deployment is executed. - :paramtype before: any + :paramtype before: JSON :keyword after: The value of the property after the deployment is executed. - :paramtype after: any + :paramtype after: JSON :keyword children: Nested property changes. :paramtype children: list[~azure.mgmt.resource.resources.v2019_07_01.models.WhatIfPropertyChange] """ - super(WhatIfPropertyChange, self).__init__(**kwargs) + super().__init__(**kwargs) self.path = path self.property_change_type = property_change_type self.before = before @@ -2788,7 +2635,7 @@ def __init__( self.children = children -class ZoneMapping(msrest.serialization.Model): +class ZoneMapping(_serialization.Model): """ZoneMapping. :ivar location: The location of the zone mapping. @@ -2798,23 +2645,17 @@ class ZoneMapping(msrest.serialization.Model): """ _attribute_map = { - 'location': {'key': 'location', 'type': 'str'}, - 'zones': {'key': 'zones', 'type': '[str]'}, + "location": {"key": "location", "type": "str"}, + "zones": {"key": "zones", "type": "[str]"}, } - def __init__( - self, - *, - location: Optional[str] = None, - zones: Optional[List[str]] = None, - **kwargs - ): + def __init__(self, *, location: Optional[str] = None, zones: Optional[List[str]] = None, **kwargs): """ :keyword location: The location of the zone mapping. :paramtype location: str :keyword zones: :paramtype zones: list[str] """ - super(ZoneMapping, self).__init__(**kwargs) + super().__init__(**kwargs) self.location = location self.zones = zones diff --git a/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/resources/v2019_07_01/models/_patch.py b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/resources/v2019_07_01/models/_patch.py new file mode 100644 index 0000000000000..f7dd32510333d --- /dev/null +++ b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/resources/v2019_07_01/models/_patch.py @@ -0,0 +1,20 @@ +# ------------------------------------ +# Copyright (c) Microsoft Corporation. +# Licensed under the MIT License. +# ------------------------------------ +"""Customize generated code here. + +Follow our quickstart for examples: https://aka.ms/azsdk/python/dpcodegen/python/customize +""" +from typing import List + +__all__: List[str] = [] # Add all objects you want publicly available to users at this package level + + +def patch_sdk(): + """Do not remove from this file. + + `patch_sdk` is a last resort escape hatch that allows you to do customizations + you can't accomplish using the techniques described in + https://aka.ms/azsdk/python/dpcodegen/python/customize + """ diff --git a/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/resources/v2019_07_01/models/_resource_management_client_enums.py b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/resources/v2019_07_01/models/_resource_management_client_enums.py index 137526fd26afc..9c3da29484b18 100644 --- a/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/resources/v2019_07_01/models/_resource_management_client_enums.py +++ b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/resources/v2019_07_01/models/_resource_management_client_enums.py @@ -7,13 +7,11 @@ # -------------------------------------------------------------------------- from enum import Enum -from six import with_metaclass from azure.core import CaseInsensitiveEnumMeta -class ChangeType(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): - """Type of change that will be made to the resource when the deployment is executed. - """ +class ChangeType(str, Enum, metaclass=CaseInsensitiveEnumMeta): + """Type of change that will be made to the resource when the deployment is executed.""" #: The resource does not exist in the current state but is present in the desired state. The #: resource will be created when the deployment is executed. @@ -34,7 +32,8 @@ class ChangeType(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): #: deployment is executed. The properties of the resource will change. MODIFY = "Modify" -class DeploymentMode(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): + +class DeploymentMode(str, Enum, metaclass=CaseInsensitiveEnumMeta): """The mode that is used to deploy resources. This value can be either Incremental or Complete. In Incremental mode, resources are deployed without deleting existing resources that are not included in the template. In Complete mode, resources are deployed and existing resources in @@ -45,7 +44,8 @@ class DeploymentMode(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): INCREMENTAL = "Incremental" COMPLETE = "Complete" -class OnErrorDeploymentType(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): + +class OnErrorDeploymentType(str, Enum, metaclass=CaseInsensitiveEnumMeta): """The deployment on error behavior type. Possible values are LastSuccessful and SpecificDeployment. """ @@ -53,9 +53,9 @@ class OnErrorDeploymentType(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): LAST_SUCCESSFUL = "LastSuccessful" SPECIFIC_DEPLOYMENT = "SpecificDeployment" -class PropertyChangeType(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): - """The type of property change. - """ + +class PropertyChangeType(str, Enum, metaclass=CaseInsensitiveEnumMeta): + """The type of property change.""" #: The property does not exist in the current state but is present in the desired state. The #: property will be created when the deployment is executed. @@ -69,18 +69,18 @@ class PropertyChangeType(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): #: The property is an array and contains nested changes. ARRAY = "Array" -class ResourceIdentityType(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): - """The identity type. - """ + +class ResourceIdentityType(str, Enum, metaclass=CaseInsensitiveEnumMeta): + """The identity type.""" SYSTEM_ASSIGNED = "SystemAssigned" USER_ASSIGNED = "UserAssigned" SYSTEM_ASSIGNED_USER_ASSIGNED = "SystemAssigned, UserAssigned" NONE = "None" -class WhatIfResultFormat(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): - """The format of the What-If results - """ + +class WhatIfResultFormat(str, Enum, metaclass=CaseInsensitiveEnumMeta): + """The format of the What-If results.""" RESOURCE_ID_ONLY = "ResourceIdOnly" FULL_RESOURCE_PAYLOADS = "FullResourcePayloads" diff --git a/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/resources/v2019_07_01/operations/__init__.py b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/resources/v2019_07_01/operations/__init__.py index 53876d82bf5d7..804fee65e3137 100644 --- a/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/resources/v2019_07_01/operations/__init__.py +++ b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/resources/v2019_07_01/operations/__init__.py @@ -14,12 +14,18 @@ from ._operations import TagsOperations from ._operations import DeploymentOperationsOperations +from ._patch import __all__ as _patch_all +from ._patch import * # type: ignore # pylint: disable=unused-wildcard-import +from ._patch import patch_sdk as _patch_sdk + __all__ = [ - 'Operations', - 'DeploymentsOperations', - 'ProvidersOperations', - 'ResourcesOperations', - 'ResourceGroupsOperations', - 'TagsOperations', - 'DeploymentOperationsOperations', + "Operations", + "DeploymentsOperations", + "ProvidersOperations", + "ResourcesOperations", + "ResourceGroupsOperations", + "TagsOperations", + "DeploymentOperationsOperations", ] +__all__.extend([p for p in _patch_all if p not in __all__]) +_patch_sdk() diff --git a/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/resources/v2019_07_01/operations/_operations.py b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/resources/v2019_07_01/operations/_operations.py index 2a6a284625531..e9b7e14bc97af 100644 --- a/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/resources/v2019_07_01/operations/_operations.py +++ b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/resources/v2019_07_01/operations/_operations.py @@ -6,1559 +6,1344 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -from typing import Any, Callable, Dict, Iterable, Optional, TypeVar, Union - -from msrest import Serializer - -from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error +import sys +from typing import Any, Callable, Dict, IO, Iterable, Optional, TypeVar, Union, cast, overload +from urllib.parse import parse_qs, urljoin, urlparse + +from azure.core.exceptions import ( + ClientAuthenticationError, + HttpResponseError, + ResourceExistsError, + ResourceNotFoundError, + ResourceNotModifiedError, + map_error, +) from azure.core.paging import ItemPaged from azure.core.pipeline import PipelineResponse from azure.core.pipeline.transport import HttpResponse from azure.core.polling import LROPoller, NoPolling, PollingMethod from azure.core.rest import HttpRequest from azure.core.tracing.decorator import distributed_trace +from azure.core.utils import case_insensitive_dict from azure.mgmt.core.exceptions import ARMErrorFormat from azure.mgmt.core.polling.arm_polling import ARMPolling from .. import models as _models +from ..._serialization import Serializer from .._vendor import _convert_request, _format_url_section -T = TypeVar('T') + +T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] -JSONType = Any +if sys.version_info >= (3, 9): + from collections.abc import MutableMapping +else: + from typing import MutableMapping # type: ignore # pylint: disable=ungrouped-imports +JSON = MutableMapping[str, Any] # pylint: disable=unsubscriptable-object _SERIALIZER = Serializer() _SERIALIZER.client_side_validation = False -def build_operations_list_request( - **kwargs: Any -) -> HttpRequest: - api_version = kwargs.pop('api_version', "2019-07-01") # type: str - accept = "application/json" +def build_operations_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", "2019-07-01")) # type: str + accept = _headers.pop("Accept", "application/json") + # Construct URL _url = kwargs.pop("template_url", "/providers/Microsoft.Resources/operations") # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') - - return HttpRequest( - method="GET", - url=_url, - params=_query_parameters, - headers=_header_parameters, - **kwargs - ) + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) -def build_deployments_delete_at_scope_request_initial( - scope: str, - deployment_name: str, - **kwargs: Any -) -> HttpRequest: - api_version = kwargs.pop('api_version', "2019-07-01") # type: str - accept = "application/json" +def build_deployments_delete_at_scope_request(scope: str, deployment_name: 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", "2019-07-01")) # type: str + accept = _headers.pop("Accept", "application/json") + # Construct URL _url = kwargs.pop("template_url", "/{scope}/providers/Microsoft.Resources/deployments/{deploymentName}") path_format_arguments = { - "scope": _SERIALIZER.url("scope", scope, 'str'), - "deploymentName": _SERIALIZER.url("deployment_name", deployment_name, 'str', max_length=64, min_length=1, pattern=r'^[-\w\._\(\)]+$'), + "scope": _SERIALIZER.url("scope", scope, "str"), + "deploymentName": _SERIALIZER.url( + "deployment_name", deployment_name, "str", max_length=64, min_length=1, pattern=r"^[-\w\._\(\)]+$" + ), } _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') - - return HttpRequest( - method="DELETE", - url=_url, - params=_query_parameters, - headers=_header_parameters, - **kwargs - ) + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + return HttpRequest(method="DELETE", url=_url, params=_params, headers=_headers, **kwargs) -def build_deployments_check_existence_at_scope_request( - scope: str, - deployment_name: str, - **kwargs: Any -) -> HttpRequest: - api_version = kwargs.pop('api_version', "2019-07-01") # type: str - accept = "application/json" +def build_deployments_check_existence_at_scope_request(scope: str, deployment_name: 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", "2019-07-01")) # type: str + accept = _headers.pop("Accept", "application/json") + # Construct URL _url = kwargs.pop("template_url", "/{scope}/providers/Microsoft.Resources/deployments/{deploymentName}") path_format_arguments = { - "scope": _SERIALIZER.url("scope", scope, 'str'), - "deploymentName": _SERIALIZER.url("deployment_name", deployment_name, 'str', max_length=64, min_length=1, pattern=r'^[-\w\._\(\)]+$'), + "scope": _SERIALIZER.url("scope", scope, "str"), + "deploymentName": _SERIALIZER.url( + "deployment_name", deployment_name, "str", max_length=64, min_length=1, pattern=r"^[-\w\._\(\)]+$" + ), } _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') - - return HttpRequest( - method="HEAD", - url=_url, - params=_query_parameters, - headers=_header_parameters, - **kwargs - ) + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + return HttpRequest(method="HEAD", url=_url, params=_params, headers=_headers, **kwargs) -def build_deployments_create_or_update_at_scope_request_initial( - scope: str, - deployment_name: str, - *, - json: JSONType = None, - content: Any = None, - **kwargs: Any -) -> HttpRequest: - api_version = kwargs.pop('api_version', "2019-07-01") # type: str - content_type = kwargs.pop('content_type', None) # type: Optional[str] - accept = "application/json" +def build_deployments_create_or_update_at_scope_request(scope: str, deployment_name: 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", "2019-07-01")) # type: str + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + accept = _headers.pop("Accept", "application/json") + # Construct URL _url = kwargs.pop("template_url", "/{scope}/providers/Microsoft.Resources/deployments/{deploymentName}") path_format_arguments = { - "scope": _SERIALIZER.url("scope", scope, 'str'), - "deploymentName": _SERIALIZER.url("deployment_name", deployment_name, 'str', max_length=64, min_length=1, pattern=r'^[-\w\._\(\)]+$'), + "scope": _SERIALIZER.url("scope", scope, "str"), + "deploymentName": _SERIALIZER.url( + "deployment_name", deployment_name, "str", max_length=64, min_length=1, pattern=r"^[-\w\._\(\)]+$" + ), } _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] if content_type is not None: - _header_parameters['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') - _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') - - return HttpRequest( - method="PUT", - url=_url, - params=_query_parameters, - headers=_header_parameters, - json=json, - content=content, - **kwargs - ) + _headers["Content-Type"] = _SERIALIZER.header("content_type", content_type, "str") + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + return HttpRequest(method="PUT", url=_url, params=_params, headers=_headers, **kwargs) -def build_deployments_get_at_scope_request( - scope: str, - deployment_name: str, - **kwargs: Any -) -> HttpRequest: - api_version = kwargs.pop('api_version', "2019-07-01") # type: str - accept = "application/json" +def build_deployments_get_at_scope_request(scope: str, deployment_name: 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", "2019-07-01")) # type: str + accept = _headers.pop("Accept", "application/json") + # Construct URL _url = kwargs.pop("template_url", "/{scope}/providers/Microsoft.Resources/deployments/{deploymentName}") path_format_arguments = { - "scope": _SERIALIZER.url("scope", scope, 'str'), - "deploymentName": _SERIALIZER.url("deployment_name", deployment_name, 'str', max_length=64, min_length=1, pattern=r'^[-\w\._\(\)]+$'), + "scope": _SERIALIZER.url("scope", scope, "str"), + "deploymentName": _SERIALIZER.url( + "deployment_name", deployment_name, "str", max_length=64, min_length=1, pattern=r"^[-\w\._\(\)]+$" + ), } _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') - - return HttpRequest( - method="GET", - url=_url, - params=_query_parameters, - headers=_header_parameters, - **kwargs - ) + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) -def build_deployments_cancel_at_scope_request( - scope: str, - deployment_name: str, - **kwargs: Any -) -> HttpRequest: - api_version = kwargs.pop('api_version', "2019-07-01") # type: str - accept = "application/json" +def build_deployments_cancel_at_scope_request(scope: str, deployment_name: 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", "2019-07-01")) # type: str + accept = _headers.pop("Accept", "application/json") + # Construct URL _url = kwargs.pop("template_url", "/{scope}/providers/Microsoft.Resources/deployments/{deploymentName}/cancel") path_format_arguments = { - "scope": _SERIALIZER.url("scope", scope, 'str'), - "deploymentName": _SERIALIZER.url("deployment_name", deployment_name, 'str', max_length=64, min_length=1, pattern=r'^[-\w\._\(\)]+$'), + "scope": _SERIALIZER.url("scope", scope, "str"), + "deploymentName": _SERIALIZER.url( + "deployment_name", deployment_name, "str", max_length=64, min_length=1, pattern=r"^[-\w\._\(\)]+$" + ), } _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') - - return HttpRequest( - method="POST", - url=_url, - params=_query_parameters, - headers=_header_parameters, - **kwargs - ) + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + return HttpRequest(method="POST", url=_url, params=_params, headers=_headers, **kwargs) -def build_deployments_validate_at_scope_request( - scope: str, - deployment_name: str, - *, - json: JSONType = None, - content: Any = None, - **kwargs: Any -) -> HttpRequest: - api_version = kwargs.pop('api_version', "2019-07-01") # type: str - content_type = kwargs.pop('content_type', None) # type: Optional[str] - accept = "application/json" +def build_deployments_validate_at_scope_request(scope: str, deployment_name: 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", "2019-07-01")) # type: str + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + accept = _headers.pop("Accept", "application/json") + # Construct URL _url = kwargs.pop("template_url", "/{scope}/providers/Microsoft.Resources/deployments/{deploymentName}/validate") path_format_arguments = { - "scope": _SERIALIZER.url("scope", scope, 'str'), - "deploymentName": _SERIALIZER.url("deployment_name", deployment_name, 'str', max_length=64, min_length=1, pattern=r'^[-\w\._\(\)]+$'), + "scope": _SERIALIZER.url("scope", scope, "str"), + "deploymentName": _SERIALIZER.url( + "deployment_name", deployment_name, "str", max_length=64, min_length=1, pattern=r"^[-\w\._\(\)]+$" + ), } _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] if content_type is not None: - _header_parameters['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') - _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') - - return HttpRequest( - method="POST", - url=_url, - params=_query_parameters, - headers=_header_parameters, - json=json, - content=content, - **kwargs - ) + _headers["Content-Type"] = _SERIALIZER.header("content_type", content_type, "str") + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + return HttpRequest(method="POST", url=_url, params=_params, headers=_headers, **kwargs) -def build_deployments_export_template_at_scope_request( - scope: str, - deployment_name: str, - **kwargs: Any -) -> HttpRequest: - api_version = kwargs.pop('api_version', "2019-07-01") # type: str - accept = "application/json" +def build_deployments_export_template_at_scope_request(scope: str, deployment_name: 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", "2019-07-01")) # type: str + accept = _headers.pop("Accept", "application/json") + # Construct URL - _url = kwargs.pop("template_url", "/{scope}/providers/Microsoft.Resources/deployments/{deploymentName}/exportTemplate") + _url = kwargs.pop( + "template_url", "/{scope}/providers/Microsoft.Resources/deployments/{deploymentName}/exportTemplate" + ) path_format_arguments = { - "scope": _SERIALIZER.url("scope", scope, 'str'), - "deploymentName": _SERIALIZER.url("deployment_name", deployment_name, 'str', max_length=64, min_length=1, pattern=r'^[-\w\._\(\)]+$'), + "scope": _SERIALIZER.url("scope", scope, "str"), + "deploymentName": _SERIALIZER.url( + "deployment_name", deployment_name, "str", max_length=64, min_length=1, pattern=r"^[-\w\._\(\)]+$" + ), } _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') - - return HttpRequest( - method="POST", - url=_url, - params=_query_parameters, - headers=_header_parameters, - **kwargs - ) + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="POST", url=_url, params=_params, headers=_headers, **kwargs) def build_deployments_list_at_scope_request( - scope: str, - *, - filter: Optional[str] = None, - top: Optional[int] = None, - **kwargs: Any + scope: str, *, filter: Optional[str] = None, top: Optional[int] = None, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2019-07-01") # type: 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", "2019-07-01")) # type: str + accept = _headers.pop("Accept", "application/json") - accept = "application/json" # Construct URL _url = kwargs.pop("template_url", "/{scope}/providers/Microsoft.Resources/deployments/") path_format_arguments = { - "scope": _SERIALIZER.url("scope", scope, 'str'), + "scope": _SERIALIZER.url("scope", scope, "str"), } _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] if filter is not None: - _query_parameters['$filter'] = _SERIALIZER.query("filter", filter, 'str') + _params["$filter"] = _SERIALIZER.query("filter", filter, "str") if top is not None: - _query_parameters['$top'] = _SERIALIZER.query("top", top, 'int') - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["$top"] = _SERIALIZER.query("top", top, "int") + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') - - return HttpRequest( - method="GET", - url=_url, - params=_query_parameters, - headers=_header_parameters, - **kwargs - ) + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) -def build_deployments_delete_at_tenant_scope_request_initial( - deployment_name: str, - **kwargs: Any -) -> HttpRequest: - api_version = kwargs.pop('api_version', "2019-07-01") # type: str - accept = "application/json" +def build_deployments_delete_at_tenant_scope_request(deployment_name: 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", "2019-07-01")) # type: str + accept = _headers.pop("Accept", "application/json") + # Construct URL _url = kwargs.pop("template_url", "/providers/Microsoft.Resources/deployments/{deploymentName}") path_format_arguments = { - "deploymentName": _SERIALIZER.url("deployment_name", deployment_name, 'str', max_length=64, min_length=1, pattern=r'^[-\w\._\(\)]+$'), + "deploymentName": _SERIALIZER.url( + "deployment_name", deployment_name, "str", max_length=64, min_length=1, pattern=r"^[-\w\._\(\)]+$" + ), } _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') - - return HttpRequest( - method="DELETE", - url=_url, - params=_query_parameters, - headers=_header_parameters, - **kwargs - ) + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + return HttpRequest(method="DELETE", url=_url, params=_params, headers=_headers, **kwargs) -def build_deployments_check_existence_at_tenant_scope_request( - deployment_name: str, - **kwargs: Any -) -> HttpRequest: - api_version = kwargs.pop('api_version', "2019-07-01") # type: str - accept = "application/json" +def build_deployments_check_existence_at_tenant_scope_request(deployment_name: 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", "2019-07-01")) # type: str + accept = _headers.pop("Accept", "application/json") + # Construct URL _url = kwargs.pop("template_url", "/providers/Microsoft.Resources/deployments/{deploymentName}") path_format_arguments = { - "deploymentName": _SERIALIZER.url("deployment_name", deployment_name, 'str', max_length=64, min_length=1, pattern=r'^[-\w\._\(\)]+$'), + "deploymentName": _SERIALIZER.url( + "deployment_name", deployment_name, "str", max_length=64, min_length=1, pattern=r"^[-\w\._\(\)]+$" + ), } _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') - - return HttpRequest( - method="HEAD", - url=_url, - params=_query_parameters, - headers=_header_parameters, - **kwargs - ) + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + return HttpRequest(method="HEAD", url=_url, params=_params, headers=_headers, **kwargs) -def build_deployments_create_or_update_at_tenant_scope_request_initial( - deployment_name: str, - *, - json: JSONType = None, - content: Any = None, - **kwargs: Any -) -> HttpRequest: - api_version = kwargs.pop('api_version', "2019-07-01") # type: str - content_type = kwargs.pop('content_type', None) # type: Optional[str] - accept = "application/json" +def build_deployments_create_or_update_at_tenant_scope_request(deployment_name: 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", "2019-07-01")) # type: str + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + accept = _headers.pop("Accept", "application/json") + # Construct URL _url = kwargs.pop("template_url", "/providers/Microsoft.Resources/deployments/{deploymentName}") path_format_arguments = { - "deploymentName": _SERIALIZER.url("deployment_name", deployment_name, 'str', max_length=64, min_length=1, pattern=r'^[-\w\._\(\)]+$'), + "deploymentName": _SERIALIZER.url( + "deployment_name", deployment_name, "str", max_length=64, min_length=1, pattern=r"^[-\w\._\(\)]+$" + ), } _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] if content_type is not None: - _header_parameters['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') - _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') - - return HttpRequest( - method="PUT", - url=_url, - params=_query_parameters, - headers=_header_parameters, - json=json, - content=content, - **kwargs - ) + _headers["Content-Type"] = _SERIALIZER.header("content_type", content_type, "str") + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + return HttpRequest(method="PUT", url=_url, params=_params, headers=_headers, **kwargs) -def build_deployments_get_at_tenant_scope_request( - deployment_name: str, - **kwargs: Any -) -> HttpRequest: - api_version = kwargs.pop('api_version', "2019-07-01") # type: str - accept = "application/json" +def build_deployments_get_at_tenant_scope_request(deployment_name: 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", "2019-07-01")) # type: str + accept = _headers.pop("Accept", "application/json") + # Construct URL _url = kwargs.pop("template_url", "/providers/Microsoft.Resources/deployments/{deploymentName}") path_format_arguments = { - "deploymentName": _SERIALIZER.url("deployment_name", deployment_name, 'str', max_length=64, min_length=1, pattern=r'^[-\w\._\(\)]+$'), + "deploymentName": _SERIALIZER.url( + "deployment_name", deployment_name, "str", max_length=64, min_length=1, pattern=r"^[-\w\._\(\)]+$" + ), } _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') - - return HttpRequest( - method="GET", - url=_url, - params=_query_parameters, - headers=_header_parameters, - **kwargs - ) + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) -def build_deployments_cancel_at_tenant_scope_request( - deployment_name: str, - **kwargs: Any -) -> HttpRequest: - api_version = kwargs.pop('api_version', "2019-07-01") # type: str - accept = "application/json" +def build_deployments_cancel_at_tenant_scope_request(deployment_name: 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", "2019-07-01")) # type: str + accept = _headers.pop("Accept", "application/json") + # Construct URL _url = kwargs.pop("template_url", "/providers/Microsoft.Resources/deployments/{deploymentName}/cancel") path_format_arguments = { - "deploymentName": _SERIALIZER.url("deployment_name", deployment_name, 'str', max_length=64, min_length=1, pattern=r'^[-\w\._\(\)]+$'), + "deploymentName": _SERIALIZER.url( + "deployment_name", deployment_name, "str", max_length=64, min_length=1, pattern=r"^[-\w\._\(\)]+$" + ), } _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') - - return HttpRequest( - method="POST", - url=_url, - params=_query_parameters, - headers=_header_parameters, - **kwargs - ) + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + return HttpRequest(method="POST", url=_url, params=_params, headers=_headers, **kwargs) -def build_deployments_validate_at_tenant_scope_request( - deployment_name: str, - *, - json: JSONType = None, - content: Any = None, - **kwargs: Any -) -> HttpRequest: - api_version = kwargs.pop('api_version', "2019-07-01") # type: str - content_type = kwargs.pop('content_type', None) # type: Optional[str] - accept = "application/json" +def build_deployments_validate_at_tenant_scope_request(deployment_name: 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", "2019-07-01")) # type: str + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + accept = _headers.pop("Accept", "application/json") + # Construct URL _url = kwargs.pop("template_url", "/providers/Microsoft.Resources/deployments/{deploymentName}/validate") path_format_arguments = { - "deploymentName": _SERIALIZER.url("deployment_name", deployment_name, 'str', max_length=64, min_length=1, pattern=r'^[-\w\._\(\)]+$'), + "deploymentName": _SERIALIZER.url( + "deployment_name", deployment_name, "str", max_length=64, min_length=1, pattern=r"^[-\w\._\(\)]+$" + ), } _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] if content_type is not None: - _header_parameters['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') - _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') - - return HttpRequest( - method="POST", - url=_url, - params=_query_parameters, - headers=_header_parameters, - json=json, - content=content, - **kwargs - ) + _headers["Content-Type"] = _SERIALIZER.header("content_type", content_type, "str") + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + return HttpRequest(method="POST", url=_url, params=_params, headers=_headers, **kwargs) -def build_deployments_export_template_at_tenant_scope_request( - deployment_name: str, - **kwargs: Any -) -> HttpRequest: - api_version = kwargs.pop('api_version', "2019-07-01") # type: str - accept = "application/json" +def build_deployments_export_template_at_tenant_scope_request(deployment_name: 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", "2019-07-01")) # type: str + accept = _headers.pop("Accept", "application/json") + # Construct URL _url = kwargs.pop("template_url", "/providers/Microsoft.Resources/deployments/{deploymentName}/exportTemplate") path_format_arguments = { - "deploymentName": _SERIALIZER.url("deployment_name", deployment_name, 'str', max_length=64, min_length=1, pattern=r'^[-\w\._\(\)]+$'), + "deploymentName": _SERIALIZER.url( + "deployment_name", deployment_name, "str", max_length=64, min_length=1, pattern=r"^[-\w\._\(\)]+$" + ), } _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') - - return HttpRequest( - method="POST", - url=_url, - params=_query_parameters, - headers=_header_parameters, - **kwargs - ) + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="POST", url=_url, params=_params, headers=_headers, **kwargs) def build_deployments_list_at_tenant_scope_request( - *, - filter: Optional[str] = None, - top: Optional[int] = None, - **kwargs: Any + *, filter: Optional[str] = None, top: Optional[int] = None, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2019-07-01") # type: 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", "2019-07-01")) # type: str + accept = _headers.pop("Accept", "application/json") - accept = "application/json" # Construct URL _url = kwargs.pop("template_url", "/providers/Microsoft.Resources/deployments/") # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] if filter is not None: - _query_parameters['$filter'] = _SERIALIZER.query("filter", filter, 'str') + _params["$filter"] = _SERIALIZER.query("filter", filter, "str") if top is not None: - _query_parameters['$top'] = _SERIALIZER.query("top", top, 'int') - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["$top"] = _SERIALIZER.query("top", top, "int") + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') - - return HttpRequest( - method="GET", - url=_url, - params=_query_parameters, - headers=_header_parameters, - **kwargs - ) + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) -def build_deployments_delete_at_management_group_scope_request_initial( - group_id: str, - deployment_name: str, - **kwargs: Any + +def build_deployments_delete_at_management_group_scope_request( + group_id: str, deployment_name: str, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2019-07-01") # type: 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", "2019-07-01")) # type: str + accept = _headers.pop("Accept", "application/json") - accept = "application/json" # Construct URL - _url = kwargs.pop("template_url", "/providers/Microsoft.Management/managementGroups/{groupId}/providers/Microsoft.Resources/deployments/{deploymentName}") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", + "/providers/Microsoft.Management/managementGroups/{groupId}/providers/Microsoft.Resources/deployments/{deploymentName}", + ) # pylint: disable=line-too-long path_format_arguments = { - "groupId": _SERIALIZER.url("group_id", group_id, 'str', max_length=90, min_length=1), - "deploymentName": _SERIALIZER.url("deployment_name", deployment_name, 'str', max_length=64, min_length=1, pattern=r'^[-\w\._\(\)]+$'), + "groupId": _SERIALIZER.url("group_id", group_id, "str", max_length=90, min_length=1), + "deploymentName": _SERIALIZER.url( + "deployment_name", deployment_name, "str", max_length=64, min_length=1, pattern=r"^[-\w\._\(\)]+$" + ), } _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') - - return HttpRequest( - method="DELETE", - url=_url, - params=_query_parameters, - headers=_header_parameters, - **kwargs - ) + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="DELETE", url=_url, params=_params, headers=_headers, **kwargs) def build_deployments_check_existence_at_management_group_scope_request( - group_id: str, - deployment_name: str, - **kwargs: Any + group_id: str, deployment_name: str, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2019-07-01") # type: 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", "2019-07-01")) # type: str + accept = _headers.pop("Accept", "application/json") - accept = "application/json" # Construct URL - _url = kwargs.pop("template_url", "/providers/Microsoft.Management/managementGroups/{groupId}/providers/Microsoft.Resources/deployments/{deploymentName}") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", + "/providers/Microsoft.Management/managementGroups/{groupId}/providers/Microsoft.Resources/deployments/{deploymentName}", + ) # pylint: disable=line-too-long path_format_arguments = { - "groupId": _SERIALIZER.url("group_id", group_id, 'str', max_length=90, min_length=1), - "deploymentName": _SERIALIZER.url("deployment_name", deployment_name, 'str', max_length=64, min_length=1, pattern=r'^[-\w\._\(\)]+$'), + "groupId": _SERIALIZER.url("group_id", group_id, "str", max_length=90, min_length=1), + "deploymentName": _SERIALIZER.url( + "deployment_name", deployment_name, "str", max_length=64, min_length=1, pattern=r"^[-\w\._\(\)]+$" + ), } _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') - - return HttpRequest( - method="HEAD", - url=_url, - params=_query_parameters, - headers=_header_parameters, - **kwargs - ) + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + return HttpRequest(method="HEAD", url=_url, params=_params, headers=_headers, **kwargs) -def build_deployments_create_or_update_at_management_group_scope_request_initial( - group_id: str, - deployment_name: str, - *, - json: JSONType = None, - content: Any = None, - **kwargs: Any + +def build_deployments_create_or_update_at_management_group_scope_request( + group_id: str, deployment_name: str, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2019-07-01") # type: str - content_type = kwargs.pop('content_type', None) # type: Optional[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", "2019-07-01")) # type: str + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + accept = _headers.pop("Accept", "application/json") - accept = "application/json" # Construct URL - _url = kwargs.pop("template_url", "/providers/Microsoft.Management/managementGroups/{groupId}/providers/Microsoft.Resources/deployments/{deploymentName}") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", + "/providers/Microsoft.Management/managementGroups/{groupId}/providers/Microsoft.Resources/deployments/{deploymentName}", + ) # pylint: disable=line-too-long path_format_arguments = { - "groupId": _SERIALIZER.url("group_id", group_id, 'str', max_length=90, min_length=1), - "deploymentName": _SERIALIZER.url("deployment_name", deployment_name, 'str', max_length=64, min_length=1, pattern=r'^[-\w\._\(\)]+$'), + "groupId": _SERIALIZER.url("group_id", group_id, "str", max_length=90, min_length=1), + "deploymentName": _SERIALIZER.url( + "deployment_name", deployment_name, "str", max_length=64, min_length=1, pattern=r"^[-\w\._\(\)]+$" + ), } _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] if content_type is not None: - _header_parameters['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') - _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') - - return HttpRequest( - method="PUT", - url=_url, - params=_query_parameters, - headers=_header_parameters, - json=json, - content=content, - **kwargs - ) + _headers["Content-Type"] = _SERIALIZER.header("content_type", content_type, "str") + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="PUT", url=_url, params=_params, headers=_headers, **kwargs) def build_deployments_get_at_management_group_scope_request( - group_id: str, - deployment_name: str, - **kwargs: Any + group_id: str, deployment_name: str, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2019-07-01") # type: 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", "2019-07-01")) # type: str + accept = _headers.pop("Accept", "application/json") - accept = "application/json" # Construct URL - _url = kwargs.pop("template_url", "/providers/Microsoft.Management/managementGroups/{groupId}/providers/Microsoft.Resources/deployments/{deploymentName}") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", + "/providers/Microsoft.Management/managementGroups/{groupId}/providers/Microsoft.Resources/deployments/{deploymentName}", + ) # pylint: disable=line-too-long path_format_arguments = { - "groupId": _SERIALIZER.url("group_id", group_id, 'str', max_length=90, min_length=1), - "deploymentName": _SERIALIZER.url("deployment_name", deployment_name, 'str', max_length=64, min_length=1, pattern=r'^[-\w\._\(\)]+$'), + "groupId": _SERIALIZER.url("group_id", group_id, "str", max_length=90, min_length=1), + "deploymentName": _SERIALIZER.url( + "deployment_name", deployment_name, "str", max_length=64, min_length=1, pattern=r"^[-\w\._\(\)]+$" + ), } _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') - - return HttpRequest( - method="GET", - url=_url, - params=_query_parameters, - headers=_header_parameters, - **kwargs - ) + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) def build_deployments_cancel_at_management_group_scope_request( - group_id: str, - deployment_name: str, - **kwargs: Any + group_id: str, deployment_name: str, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2019-07-01") # type: 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", "2019-07-01")) # type: str + accept = _headers.pop("Accept", "application/json") - accept = "application/json" # Construct URL - _url = kwargs.pop("template_url", "/providers/Microsoft.Management/managementGroups/{groupId}/providers/Microsoft.Resources/deployments/{deploymentName}/cancel") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", + "/providers/Microsoft.Management/managementGroups/{groupId}/providers/Microsoft.Resources/deployments/{deploymentName}/cancel", + ) # pylint: disable=line-too-long path_format_arguments = { - "groupId": _SERIALIZER.url("group_id", group_id, 'str', max_length=90, min_length=1), - "deploymentName": _SERIALIZER.url("deployment_name", deployment_name, 'str', max_length=64, min_length=1, pattern=r'^[-\w\._\(\)]+$'), + "groupId": _SERIALIZER.url("group_id", group_id, "str", max_length=90, min_length=1), + "deploymentName": _SERIALIZER.url( + "deployment_name", deployment_name, "str", max_length=64, min_length=1, pattern=r"^[-\w\._\(\)]+$" + ), } _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') - - return HttpRequest( - method="POST", - url=_url, - params=_query_parameters, - headers=_header_parameters, - **kwargs - ) + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="POST", url=_url, params=_params, headers=_headers, **kwargs) def build_deployments_validate_at_management_group_scope_request( - group_id: str, - deployment_name: str, - *, - json: JSONType = None, - content: Any = None, - **kwargs: Any + group_id: str, deployment_name: str, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2019-07-01") # type: str - content_type = kwargs.pop('content_type', None) # type: Optional[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", "2019-07-01")) # type: str + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + accept = _headers.pop("Accept", "application/json") - accept = "application/json" # Construct URL - _url = kwargs.pop("template_url", "/providers/Microsoft.Management/managementGroups/{groupId}/providers/Microsoft.Resources/deployments/{deploymentName}/validate") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", + "/providers/Microsoft.Management/managementGroups/{groupId}/providers/Microsoft.Resources/deployments/{deploymentName}/validate", + ) # pylint: disable=line-too-long path_format_arguments = { - "groupId": _SERIALIZER.url("group_id", group_id, 'str', max_length=90, min_length=1), - "deploymentName": _SERIALIZER.url("deployment_name", deployment_name, 'str', max_length=64, min_length=1, pattern=r'^[-\w\._\(\)]+$'), + "groupId": _SERIALIZER.url("group_id", group_id, "str", max_length=90, min_length=1), + "deploymentName": _SERIALIZER.url( + "deployment_name", deployment_name, "str", max_length=64, min_length=1, pattern=r"^[-\w\._\(\)]+$" + ), } _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] if content_type is not None: - _header_parameters['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') - _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') - - return HttpRequest( - method="POST", - url=_url, - params=_query_parameters, - headers=_header_parameters, - json=json, - content=content, - **kwargs - ) + _headers["Content-Type"] = _SERIALIZER.header("content_type", content_type, "str") + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="POST", url=_url, params=_params, headers=_headers, **kwargs) def build_deployments_export_template_at_management_group_scope_request( - group_id: str, - deployment_name: str, - **kwargs: Any + group_id: str, deployment_name: str, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2019-07-01") # type: 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", "2019-07-01")) # type: str + accept = _headers.pop("Accept", "application/json") - accept = "application/json" # Construct URL - _url = kwargs.pop("template_url", "/providers/Microsoft.Management/managementGroups/{groupId}/providers/Microsoft.Resources/deployments/{deploymentName}/exportTemplate") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", + "/providers/Microsoft.Management/managementGroups/{groupId}/providers/Microsoft.Resources/deployments/{deploymentName}/exportTemplate", + ) # pylint: disable=line-too-long path_format_arguments = { - "groupId": _SERIALIZER.url("group_id", group_id, 'str', max_length=90, min_length=1), - "deploymentName": _SERIALIZER.url("deployment_name", deployment_name, 'str', max_length=64, min_length=1, pattern=r'^[-\w\._\(\)]+$'), + "groupId": _SERIALIZER.url("group_id", group_id, "str", max_length=90, min_length=1), + "deploymentName": _SERIALIZER.url( + "deployment_name", deployment_name, "str", max_length=64, min_length=1, pattern=r"^[-\w\._\(\)]+$" + ), } _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') - - return HttpRequest( - method="POST", - url=_url, - params=_query_parameters, - headers=_header_parameters, - **kwargs - ) + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="POST", url=_url, params=_params, headers=_headers, **kwargs) def build_deployments_list_at_management_group_scope_request( - group_id: str, - *, - filter: Optional[str] = None, - top: Optional[int] = None, - **kwargs: Any + group_id: str, *, filter: Optional[str] = None, top: Optional[int] = None, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2019-07-01") # type: 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", "2019-07-01")) # type: str + accept = _headers.pop("Accept", "application/json") - accept = "application/json" # Construct URL - _url = kwargs.pop("template_url", "/providers/Microsoft.Management/managementGroups/{groupId}/providers/Microsoft.Resources/deployments/") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", + "/providers/Microsoft.Management/managementGroups/{groupId}/providers/Microsoft.Resources/deployments/", + ) # pylint: disable=line-too-long path_format_arguments = { - "groupId": _SERIALIZER.url("group_id", group_id, 'str', max_length=90, min_length=1), + "groupId": _SERIALIZER.url("group_id", group_id, "str", max_length=90, min_length=1), } _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] if filter is not None: - _query_parameters['$filter'] = _SERIALIZER.query("filter", filter, 'str') + _params["$filter"] = _SERIALIZER.query("filter", filter, "str") if top is not None: - _query_parameters['$top'] = _SERIALIZER.query("top", top, 'int') - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["$top"] = _SERIALIZER.query("top", top, "int") + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') - - return HttpRequest( - method="GET", - url=_url, - params=_query_parameters, - headers=_header_parameters, - **kwargs - ) + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) -def build_deployments_delete_at_subscription_scope_request_initial( - deployment_name: str, - subscription_id: str, - **kwargs: Any + +def build_deployments_delete_at_subscription_scope_request( + deployment_name: str, subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2019-07-01") # type: 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", "2019-07-01")) # type: str + accept = _headers.pop("Accept", "application/json") - accept = "application/json" # Construct URL - _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/providers/Microsoft.Resources/deployments/{deploymentName}") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", "/subscriptions/{subscriptionId}/providers/Microsoft.Resources/deployments/{deploymentName}" + ) # pylint: disable=line-too-long path_format_arguments = { - "deploymentName": _SERIALIZER.url("deployment_name", deployment_name, 'str', max_length=64, min_length=1, pattern=r'^[-\w\._\(\)]+$'), - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), + "deploymentName": _SERIALIZER.url( + "deployment_name", deployment_name, "str", max_length=64, min_length=1, pattern=r"^[-\w\._\(\)]+$" + ), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), } _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') - - return HttpRequest( - method="DELETE", - url=_url, - params=_query_parameters, - headers=_header_parameters, - **kwargs - ) + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="DELETE", url=_url, params=_params, headers=_headers, **kwargs) def build_deployments_check_existence_at_subscription_scope_request( - deployment_name: str, - subscription_id: str, - **kwargs: Any + deployment_name: str, subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2019-07-01") # type: 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", "2019-07-01")) # type: str + accept = _headers.pop("Accept", "application/json") - accept = "application/json" # Construct URL - _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/providers/Microsoft.Resources/deployments/{deploymentName}") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", "/subscriptions/{subscriptionId}/providers/Microsoft.Resources/deployments/{deploymentName}" + ) # pylint: disable=line-too-long path_format_arguments = { - "deploymentName": _SERIALIZER.url("deployment_name", deployment_name, 'str', max_length=64, min_length=1, pattern=r'^[-\w\._\(\)]+$'), - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), + "deploymentName": _SERIALIZER.url( + "deployment_name", deployment_name, "str", max_length=64, min_length=1, pattern=r"^[-\w\._\(\)]+$" + ), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), } _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') - - return HttpRequest( - method="HEAD", - url=_url, - params=_query_parameters, - headers=_header_parameters, - **kwargs - ) + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + return HttpRequest(method="HEAD", url=_url, params=_params, headers=_headers, **kwargs) -def build_deployments_create_or_update_at_subscription_scope_request_initial( - deployment_name: str, - subscription_id: str, - *, - json: JSONType = None, - content: Any = None, - **kwargs: Any + +def build_deployments_create_or_update_at_subscription_scope_request( + deployment_name: str, subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2019-07-01") # type: str - content_type = kwargs.pop('content_type', None) # type: Optional[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", "2019-07-01")) # type: str + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + accept = _headers.pop("Accept", "application/json") - accept = "application/json" # Construct URL - _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/providers/Microsoft.Resources/deployments/{deploymentName}") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", "/subscriptions/{subscriptionId}/providers/Microsoft.Resources/deployments/{deploymentName}" + ) # pylint: disable=line-too-long path_format_arguments = { - "deploymentName": _SERIALIZER.url("deployment_name", deployment_name, 'str', max_length=64, min_length=1, pattern=r'^[-\w\._\(\)]+$'), - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), + "deploymentName": _SERIALIZER.url( + "deployment_name", deployment_name, "str", max_length=64, min_length=1, pattern=r"^[-\w\._\(\)]+$" + ), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), } _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] if content_type is not None: - _header_parameters['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') - _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') - - return HttpRequest( - method="PUT", - url=_url, - params=_query_parameters, - headers=_header_parameters, - json=json, - content=content, - **kwargs - ) + _headers["Content-Type"] = _SERIALIZER.header("content_type", content_type, "str") + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="PUT", url=_url, params=_params, headers=_headers, **kwargs) def build_deployments_get_at_subscription_scope_request( - deployment_name: str, - subscription_id: str, - **kwargs: Any + deployment_name: str, subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2019-07-01") # type: 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", "2019-07-01")) # type: str + accept = _headers.pop("Accept", "application/json") - accept = "application/json" # Construct URL - _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/providers/Microsoft.Resources/deployments/{deploymentName}") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", "/subscriptions/{subscriptionId}/providers/Microsoft.Resources/deployments/{deploymentName}" + ) # pylint: disable=line-too-long path_format_arguments = { - "deploymentName": _SERIALIZER.url("deployment_name", deployment_name, 'str', max_length=64, min_length=1, pattern=r'^[-\w\._\(\)]+$'), - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), + "deploymentName": _SERIALIZER.url( + "deployment_name", deployment_name, "str", max_length=64, min_length=1, pattern=r"^[-\w\._\(\)]+$" + ), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), } _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') - - return HttpRequest( - method="GET", - url=_url, - params=_query_parameters, - headers=_header_parameters, - **kwargs - ) + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) def build_deployments_cancel_at_subscription_scope_request( - deployment_name: str, - subscription_id: str, - **kwargs: Any + deployment_name: str, subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2019-07-01") # type: 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", "2019-07-01")) # type: str + accept = _headers.pop("Accept", "application/json") - accept = "application/json" # Construct URL - _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/providers/Microsoft.Resources/deployments/{deploymentName}/cancel") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/providers/Microsoft.Resources/deployments/{deploymentName}/cancel", + ) # pylint: disable=line-too-long path_format_arguments = { - "deploymentName": _SERIALIZER.url("deployment_name", deployment_name, 'str', max_length=64, min_length=1, pattern=r'^[-\w\._\(\)]+$'), - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), + "deploymentName": _SERIALIZER.url( + "deployment_name", deployment_name, "str", max_length=64, min_length=1, pattern=r"^[-\w\._\(\)]+$" + ), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), } _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') - - return HttpRequest( - method="POST", - url=_url, - params=_query_parameters, - headers=_header_parameters, - **kwargs - ) + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="POST", url=_url, params=_params, headers=_headers, **kwargs) def build_deployments_validate_at_subscription_scope_request( - deployment_name: str, - subscription_id: str, - *, - json: JSONType = None, - content: Any = None, - **kwargs: Any + deployment_name: str, subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2019-07-01") # type: str - content_type = kwargs.pop('content_type', None) # type: Optional[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", "2019-07-01")) # type: str + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + accept = _headers.pop("Accept", "application/json") - accept = "application/json" # Construct URL - _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/providers/Microsoft.Resources/deployments/{deploymentName}/validate") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/providers/Microsoft.Resources/deployments/{deploymentName}/validate", + ) # pylint: disable=line-too-long path_format_arguments = { - "deploymentName": _SERIALIZER.url("deployment_name", deployment_name, 'str', max_length=64, min_length=1, pattern=r'^[-\w\._\(\)]+$'), - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), + "deploymentName": _SERIALIZER.url( + "deployment_name", deployment_name, "str", max_length=64, min_length=1, pattern=r"^[-\w\._\(\)]+$" + ), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), } _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] if content_type is not None: - _header_parameters['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') - _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') - - return HttpRequest( - method="POST", - url=_url, - params=_query_parameters, - headers=_header_parameters, - json=json, - content=content, - **kwargs - ) + _headers["Content-Type"] = _SERIALIZER.header("content_type", content_type, "str") + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + return HttpRequest(method="POST", url=_url, params=_params, headers=_headers, **kwargs) -def build_deployments_what_if_at_subscription_scope_request_initial( - deployment_name: str, - subscription_id: str, - *, - json: JSONType = None, - content: Any = None, - **kwargs: Any + +def build_deployments_what_if_at_subscription_scope_request( + deployment_name: str, subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2019-07-01") # type: str - content_type = kwargs.pop('content_type', None) # type: Optional[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", "2019-07-01")) # type: str + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + accept = _headers.pop("Accept", "application/json") - accept = "application/json" # Construct URL - _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/providers/Microsoft.Resources/deployments/{deploymentName}/whatIf") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/providers/Microsoft.Resources/deployments/{deploymentName}/whatIf", + ) # pylint: disable=line-too-long path_format_arguments = { - "deploymentName": _SERIALIZER.url("deployment_name", deployment_name, 'str', max_length=64, min_length=1, pattern=r'^[-\w\._\(\)]+$'), - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), + "deploymentName": _SERIALIZER.url( + "deployment_name", deployment_name, "str", max_length=64, min_length=1, pattern=r"^[-\w\._\(\)]+$" + ), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), } _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] if content_type is not None: - _header_parameters['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') - _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') - - return HttpRequest( - method="POST", - url=_url, - params=_query_parameters, - headers=_header_parameters, - json=json, - content=content, - **kwargs - ) + _headers["Content-Type"] = _SERIALIZER.header("content_type", content_type, "str") + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="POST", url=_url, params=_params, headers=_headers, **kwargs) def build_deployments_export_template_at_subscription_scope_request( - deployment_name: str, - subscription_id: str, - **kwargs: Any + deployment_name: str, subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2019-07-01") # type: 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", "2019-07-01")) # type: str + accept = _headers.pop("Accept", "application/json") - accept = "application/json" # Construct URL - _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/providers/Microsoft.Resources/deployments/{deploymentName}/exportTemplate") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/providers/Microsoft.Resources/deployments/{deploymentName}/exportTemplate", + ) # pylint: disable=line-too-long path_format_arguments = { - "deploymentName": _SERIALIZER.url("deployment_name", deployment_name, 'str', max_length=64, min_length=1, pattern=r'^[-\w\._\(\)]+$'), - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), + "deploymentName": _SERIALIZER.url( + "deployment_name", deployment_name, "str", max_length=64, min_length=1, pattern=r"^[-\w\._\(\)]+$" + ), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), } _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') - - return HttpRequest( - method="POST", - url=_url, - params=_query_parameters, - headers=_header_parameters, - **kwargs - ) + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="POST", url=_url, params=_params, headers=_headers, **kwargs) def build_deployments_list_at_subscription_scope_request( - subscription_id: str, - *, - filter: Optional[str] = None, - top: Optional[int] = None, - **kwargs: Any + subscription_id: str, *, filter: Optional[str] = None, top: Optional[int] = None, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2019-07-01") # type: 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", "2019-07-01")) # type: str + accept = _headers.pop("Accept", "application/json") - accept = "application/json" # Construct URL _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/providers/Microsoft.Resources/deployments/") path_format_arguments = { - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), } _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] if filter is not None: - _query_parameters['$filter'] = _SERIALIZER.query("filter", filter, 'str') + _params["$filter"] = _SERIALIZER.query("filter", filter, "str") if top is not None: - _query_parameters['$top'] = _SERIALIZER.query("top", top, 'int') - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["$top"] = _SERIALIZER.query("top", top, "int") + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') - - return HttpRequest( - method="GET", - url=_url, - params=_query_parameters, - headers=_header_parameters, - **kwargs - ) + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) -def build_deployments_delete_request_initial( - resource_group_name: str, - deployment_name: str, - subscription_id: str, - **kwargs: Any + +def build_deployments_delete_request( + resource_group_name: str, deployment_name: str, subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2019-07-01") # type: 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", "2019-07-01")) # type: str + accept = _headers.pop("Accept", "application/json") - accept = "application/json" # Construct URL - _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/Microsoft.Resources/deployments/{deploymentName}") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/Microsoft.Resources/deployments/{deploymentName}", + ) # pylint: disable=line-too-long path_format_arguments = { - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._\(\)]+$'), - "deploymentName": _SERIALIZER.url("deployment_name", deployment_name, 'str', max_length=64, min_length=1, pattern=r'^[-\w\._\(\)]+$'), - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), + "resourceGroupName": _SERIALIZER.url( + "resource_group_name", resource_group_name, "str", max_length=90, min_length=1, pattern=r"^[-\w\._\(\)]+$" + ), + "deploymentName": _SERIALIZER.url( + "deployment_name", deployment_name, "str", max_length=64, min_length=1, pattern=r"^[-\w\._\(\)]+$" + ), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), } _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') - - return HttpRequest( - method="DELETE", - url=_url, - params=_query_parameters, - headers=_header_parameters, - **kwargs - ) + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="DELETE", url=_url, params=_params, headers=_headers, **kwargs) def build_deployments_check_existence_request( - resource_group_name: str, - deployment_name: str, - subscription_id: str, - **kwargs: Any + resource_group_name: str, deployment_name: str, subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2019-07-01") # type: 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", "2019-07-01")) # type: str + accept = _headers.pop("Accept", "application/json") - accept = "application/json" # Construct URL - _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/Microsoft.Resources/deployments/{deploymentName}") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/Microsoft.Resources/deployments/{deploymentName}", + ) # pylint: disable=line-too-long path_format_arguments = { - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._\(\)]+$'), - "deploymentName": _SERIALIZER.url("deployment_name", deployment_name, 'str', max_length=64, min_length=1, pattern=r'^[-\w\._\(\)]+$'), - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), + "resourceGroupName": _SERIALIZER.url( + "resource_group_name", resource_group_name, "str", max_length=90, min_length=1, pattern=r"^[-\w\._\(\)]+$" + ), + "deploymentName": _SERIALIZER.url( + "deployment_name", deployment_name, "str", max_length=64, min_length=1, pattern=r"^[-\w\._\(\)]+$" + ), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), } _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') - - return HttpRequest( - method="HEAD", - url=_url, - params=_query_parameters, - headers=_header_parameters, - **kwargs - ) + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + return HttpRequest(method="HEAD", url=_url, params=_params, headers=_headers, **kwargs) -def build_deployments_create_or_update_request_initial( - resource_group_name: str, - deployment_name: str, - subscription_id: str, - *, - json: JSONType = None, - content: Any = None, - **kwargs: Any + +def build_deployments_create_or_update_request( + resource_group_name: str, deployment_name: str, subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2019-07-01") # type: str - content_type = kwargs.pop('content_type', None) # type: Optional[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", "2019-07-01")) # type: str + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + accept = _headers.pop("Accept", "application/json") - accept = "application/json" # Construct URL - _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/Microsoft.Resources/deployments/{deploymentName}") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/Microsoft.Resources/deployments/{deploymentName}", + ) # pylint: disable=line-too-long path_format_arguments = { - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._\(\)]+$'), - "deploymentName": _SERIALIZER.url("deployment_name", deployment_name, 'str', max_length=64, min_length=1, pattern=r'^[-\w\._\(\)]+$'), - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), + "resourceGroupName": _SERIALIZER.url( + "resource_group_name", resource_group_name, "str", max_length=90, min_length=1, pattern=r"^[-\w\._\(\)]+$" + ), + "deploymentName": _SERIALIZER.url( + "deployment_name", deployment_name, "str", max_length=64, min_length=1, pattern=r"^[-\w\._\(\)]+$" + ), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), } _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] if content_type is not None: - _header_parameters['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') - _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') - - return HttpRequest( - method="PUT", - url=_url, - params=_query_parameters, - headers=_header_parameters, - json=json, - content=content, - **kwargs - ) + _headers["Content-Type"] = _SERIALIZER.header("content_type", content_type, "str") + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="PUT", url=_url, params=_params, headers=_headers, **kwargs) def build_deployments_get_request( - resource_group_name: str, - deployment_name: str, - subscription_id: str, - **kwargs: Any + resource_group_name: str, deployment_name: str, subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2019-07-01") # type: 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", "2019-07-01")) # type: str + accept = _headers.pop("Accept", "application/json") - accept = "application/json" # Construct URL - _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/Microsoft.Resources/deployments/{deploymentName}") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/Microsoft.Resources/deployments/{deploymentName}", + ) # pylint: disable=line-too-long path_format_arguments = { - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._\(\)]+$'), - "deploymentName": _SERIALIZER.url("deployment_name", deployment_name, 'str', max_length=64, min_length=1, pattern=r'^[-\w\._\(\)]+$'), - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), + "resourceGroupName": _SERIALIZER.url( + "resource_group_name", resource_group_name, "str", max_length=90, min_length=1, pattern=r"^[-\w\._\(\)]+$" + ), + "deploymentName": _SERIALIZER.url( + "deployment_name", deployment_name, "str", max_length=64, min_length=1, pattern=r"^[-\w\._\(\)]+$" + ), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), } _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') - - return HttpRequest( - method="GET", - url=_url, - params=_query_parameters, - headers=_header_parameters, - **kwargs - ) + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) def build_deployments_cancel_request( - resource_group_name: str, - deployment_name: str, - subscription_id: str, - **kwargs: Any + resource_group_name: str, deployment_name: str, subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2019-07-01") # type: 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", "2019-07-01")) # type: str + accept = _headers.pop("Accept", "application/json") - accept = "application/json" # Construct URL - _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/Microsoft.Resources/deployments/{deploymentName}/cancel") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/Microsoft.Resources/deployments/{deploymentName}/cancel", + ) # pylint: disable=line-too-long path_format_arguments = { - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._\(\)]+$'), - "deploymentName": _SERIALIZER.url("deployment_name", deployment_name, 'str', max_length=64, min_length=1, pattern=r'^[-\w\._\(\)]+$'), - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), + "resourceGroupName": _SERIALIZER.url( + "resource_group_name", resource_group_name, "str", max_length=90, min_length=1, pattern=r"^[-\w\._\(\)]+$" + ), + "deploymentName": _SERIALIZER.url( + "deployment_name", deployment_name, "str", max_length=64, min_length=1, pattern=r"^[-\w\._\(\)]+$" + ), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), } _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') - - return HttpRequest( - method="POST", - url=_url, - params=_query_parameters, - headers=_header_parameters, - **kwargs - ) + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="POST", url=_url, params=_params, headers=_headers, **kwargs) def build_deployments_validate_request( - resource_group_name: str, - deployment_name: str, - subscription_id: str, - *, - json: JSONType = None, - content: Any = None, - **kwargs: Any + resource_group_name: str, deployment_name: str, subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2019-07-01") # type: str - content_type = kwargs.pop('content_type', None) # type: Optional[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", "2019-07-01")) # type: str + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + accept = _headers.pop("Accept", "application/json") - accept = "application/json" # Construct URL - _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/Microsoft.Resources/deployments/{deploymentName}/validate") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/Microsoft.Resources/deployments/{deploymentName}/validate", + ) # pylint: disable=line-too-long path_format_arguments = { - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._\(\)]+$'), - "deploymentName": _SERIALIZER.url("deployment_name", deployment_name, 'str', max_length=64, min_length=1, pattern=r'^[-\w\._\(\)]+$'), - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), + "resourceGroupName": _SERIALIZER.url( + "resource_group_name", resource_group_name, "str", max_length=90, min_length=1, pattern=r"^[-\w\._\(\)]+$" + ), + "deploymentName": _SERIALIZER.url( + "deployment_name", deployment_name, "str", max_length=64, min_length=1, pattern=r"^[-\w\._\(\)]+$" + ), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), } _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] if content_type is not None: - _header_parameters['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') - _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') - - return HttpRequest( - method="POST", - url=_url, - params=_query_parameters, - headers=_header_parameters, - json=json, - content=content, - **kwargs - ) + _headers["Content-Type"] = _SERIALIZER.header("content_type", content_type, "str") + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + return HttpRequest(method="POST", url=_url, params=_params, headers=_headers, **kwargs) -def build_deployments_what_if_request_initial( - resource_group_name: str, - deployment_name: str, - subscription_id: str, - *, - json: JSONType = None, - content: Any = None, - **kwargs: Any + +def build_deployments_what_if_request( + resource_group_name: str, deployment_name: str, subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2019-07-01") # type: str - content_type = kwargs.pop('content_type', None) # type: Optional[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", "2019-07-01")) # type: str + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + accept = _headers.pop("Accept", "application/json") - accept = "application/json" # Construct URL - _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/Microsoft.Resources/deployments/{deploymentName}/whatIf") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/Microsoft.Resources/deployments/{deploymentName}/whatIf", + ) # pylint: disable=line-too-long path_format_arguments = { - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._\(\)]+$'), - "deploymentName": _SERIALIZER.url("deployment_name", deployment_name, 'str', max_length=64, min_length=1, pattern=r'^[-\w\._\(\)]+$'), - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), + "resourceGroupName": _SERIALIZER.url( + "resource_group_name", resource_group_name, "str", max_length=90, min_length=1, pattern=r"^[-\w\._\(\)]+$" + ), + "deploymentName": _SERIALIZER.url( + "deployment_name", deployment_name, "str", max_length=64, min_length=1, pattern=r"^[-\w\._\(\)]+$" + ), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), } _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] if content_type is not None: - _header_parameters['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') - _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') - - return HttpRequest( - method="POST", - url=_url, - params=_query_parameters, - headers=_header_parameters, - json=json, - content=content, - **kwargs - ) + _headers["Content-Type"] = _SERIALIZER.header("content_type", content_type, "str") + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="POST", url=_url, params=_params, headers=_headers, **kwargs) def build_deployments_export_template_request( - resource_group_name: str, - deployment_name: str, - subscription_id: str, - **kwargs: Any + resource_group_name: str, deployment_name: str, subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2019-07-01") # type: 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", "2019-07-01")) # type: str + accept = _headers.pop("Accept", "application/json") - accept = "application/json" # Construct URL - _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/Microsoft.Resources/deployments/{deploymentName}/exportTemplate") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/Microsoft.Resources/deployments/{deploymentName}/exportTemplate", + ) # pylint: disable=line-too-long path_format_arguments = { - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._\(\)]+$'), - "deploymentName": _SERIALIZER.url("deployment_name", deployment_name, 'str', max_length=64, min_length=1, pattern=r'^[-\w\._\(\)]+$'), - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), + "resourceGroupName": _SERIALIZER.url( + "resource_group_name", resource_group_name, "str", max_length=90, min_length=1, pattern=r"^[-\w\._\(\)]+$" + ), + "deploymentName": _SERIALIZER.url( + "deployment_name", deployment_name, "str", max_length=64, min_length=1, pattern=r"^[-\w\._\(\)]+$" + ), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), } _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') - - return HttpRequest( - method="POST", - url=_url, - params=_query_parameters, - headers=_header_parameters, - **kwargs - ) + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="POST", url=_url, params=_params, headers=_headers, **kwargs) def build_deployments_list_by_resource_group_request( @@ -1569,285 +1354,227 @@ def build_deployments_list_by_resource_group_request( top: Optional[int] = None, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2019-07-01") # type: 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", "2019-07-01")) # type: str + accept = _headers.pop("Accept", "application/json") - accept = "application/json" # Construct URL - _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/Microsoft.Resources/deployments/") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/Microsoft.Resources/deployments/", + ) # pylint: disable=line-too-long path_format_arguments = { - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._\(\)]+$'), - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), + "resourceGroupName": _SERIALIZER.url( + "resource_group_name", resource_group_name, "str", max_length=90, min_length=1, pattern=r"^[-\w\._\(\)]+$" + ), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), } _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] if filter is not None: - _query_parameters['$filter'] = _SERIALIZER.query("filter", filter, 'str') + _params["$filter"] = _SERIALIZER.query("filter", filter, "str") if top is not None: - _query_parameters['$top'] = _SERIALIZER.query("top", top, 'int') - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["$top"] = _SERIALIZER.query("top", top, "int") + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') - - return HttpRequest( - method="GET", - url=_url, - params=_query_parameters, - headers=_header_parameters, - **kwargs - ) + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) -def build_deployments_calculate_template_hash_request( - *, - json: JSONType = None, - content: Any = None, - **kwargs: Any -) -> HttpRequest: - api_version = kwargs.pop('api_version', "2019-07-01") # type: str - content_type = kwargs.pop('content_type', None) # type: Optional[str] - accept = "application/json" +def build_deployments_calculate_template_hash_request(*, json: JSON, **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", "2019-07-01")) # type: str + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + accept = _headers.pop("Accept", "application/json") + # Construct URL _url = kwargs.pop("template_url", "/providers/Microsoft.Resources/calculateTemplateHash") # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] if content_type is not None: - _header_parameters['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') - _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') - - return HttpRequest( - method="POST", - url=_url, - params=_query_parameters, - headers=_header_parameters, - json=json, - content=content, - **kwargs - ) + _headers["Content-Type"] = _SERIALIZER.header("content_type", content_type, "str") + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="POST", url=_url, params=_params, headers=_headers, json=json, **kwargs) def build_providers_unregister_request( - resource_provider_namespace: str, - subscription_id: str, - **kwargs: Any + resource_provider_namespace: str, subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2019-07-01") # type: 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", "2019-07-01")) # type: str + accept = _headers.pop("Accept", "application/json") - accept = "application/json" # Construct URL - _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/providers/{resourceProviderNamespace}/unregister") + _url = kwargs.pop( + "template_url", "/subscriptions/{subscriptionId}/providers/{resourceProviderNamespace}/unregister" + ) path_format_arguments = { - "resourceProviderNamespace": _SERIALIZER.url("resource_provider_namespace", resource_provider_namespace, 'str'), - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), + "resourceProviderNamespace": _SERIALIZER.url("resource_provider_namespace", resource_provider_namespace, "str"), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), } _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') - - return HttpRequest( - method="POST", - url=_url, - params=_query_parameters, - headers=_header_parameters, - **kwargs - ) + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="POST", url=_url, params=_params, headers=_headers, **kwargs) def build_providers_register_request( - resource_provider_namespace: str, - subscription_id: str, - **kwargs: Any + resource_provider_namespace: str, subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2019-07-01") # type: 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", "2019-07-01")) # type: str + accept = _headers.pop("Accept", "application/json") - accept = "application/json" # Construct URL _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/providers/{resourceProviderNamespace}/register") path_format_arguments = { - "resourceProviderNamespace": _SERIALIZER.url("resource_provider_namespace", resource_provider_namespace, 'str'), - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), + "resourceProviderNamespace": _SERIALIZER.url("resource_provider_namespace", resource_provider_namespace, "str"), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), } _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') - - return HttpRequest( - method="POST", - url=_url, - params=_query_parameters, - headers=_header_parameters, - **kwargs - ) + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="POST", url=_url, params=_params, headers=_headers, **kwargs) def build_providers_list_request( - subscription_id: str, - *, - top: Optional[int] = None, - expand: Optional[str] = None, - **kwargs: Any + subscription_id: str, *, top: Optional[int] = None, expand: Optional[str] = None, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2019-07-01") # type: 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", "2019-07-01")) # type: str + accept = _headers.pop("Accept", "application/json") - accept = "application/json" # Construct URL _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/providers") path_format_arguments = { - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), } _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] if top is not None: - _query_parameters['$top'] = _SERIALIZER.query("top", top, 'int') + _params["$top"] = _SERIALIZER.query("top", top, "int") if expand is not None: - _query_parameters['$expand'] = _SERIALIZER.query("expand", expand, 'str') - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["$expand"] = _SERIALIZER.query("expand", expand, "str") + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') - - return HttpRequest( - method="GET", - url=_url, - params=_query_parameters, - headers=_header_parameters, - **kwargs - ) + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) def build_providers_list_at_tenant_scope_request( - *, - top: Optional[int] = None, - expand: Optional[str] = None, - **kwargs: Any + *, top: Optional[int] = None, expand: Optional[str] = None, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2019-07-01") # type: 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", "2019-07-01")) # type: str + accept = _headers.pop("Accept", "application/json") - accept = "application/json" # Construct URL _url = kwargs.pop("template_url", "/providers") # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] if top is not None: - _query_parameters['$top'] = _SERIALIZER.query("top", top, 'int') + _params["$top"] = _SERIALIZER.query("top", top, "int") if expand is not None: - _query_parameters['$expand'] = _SERIALIZER.query("expand", expand, 'str') - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["$expand"] = _SERIALIZER.query("expand", expand, "str") + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') - - return HttpRequest( - method="GET", - url=_url, - params=_query_parameters, - headers=_header_parameters, - **kwargs - ) + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) def build_providers_get_request( - resource_provider_namespace: str, - subscription_id: str, - *, - expand: Optional[str] = None, - **kwargs: Any + resource_provider_namespace: str, subscription_id: str, *, expand: Optional[str] = None, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2019-07-01") # type: 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", "2019-07-01")) # type: str + accept = _headers.pop("Accept", "application/json") - accept = "application/json" # Construct URL _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/providers/{resourceProviderNamespace}") path_format_arguments = { - "resourceProviderNamespace": _SERIALIZER.url("resource_provider_namespace", resource_provider_namespace, 'str'), - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), + "resourceProviderNamespace": _SERIALIZER.url("resource_provider_namespace", resource_provider_namespace, "str"), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), } _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] if expand is not None: - _query_parameters['$expand'] = _SERIALIZER.query("expand", expand, 'str') - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["$expand"] = _SERIALIZER.query("expand", expand, "str") + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') - - return HttpRequest( - method="GET", - url=_url, - params=_query_parameters, - headers=_header_parameters, - **kwargs - ) + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) def build_providers_get_at_tenant_scope_request( - resource_provider_namespace: str, - *, - expand: Optional[str] = None, - **kwargs: Any + resource_provider_namespace: str, *, expand: Optional[str] = None, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2019-07-01") # type: 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", "2019-07-01")) # type: str + accept = _headers.pop("Accept", "application/json") - accept = "application/json" # Construct URL _url = kwargs.pop("template_url", "/providers/{resourceProviderNamespace}") path_format_arguments = { - "resourceProviderNamespace": _SERIALIZER.url("resource_provider_namespace", resource_provider_namespace, 'str'), + "resourceProviderNamespace": _SERIALIZER.url("resource_provider_namespace", resource_provider_namespace, "str"), } _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] if expand is not None: - _query_parameters['$expand'] = _SERIALIZER.query("expand", expand, 'str') - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["$expand"] = _SERIALIZER.query("expand", expand, "str") + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') - - return HttpRequest( - method="GET", - url=_url, - params=_query_parameters, - headers=_header_parameters, - **kwargs - ) + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) def build_resources_list_by_resource_group_request( @@ -1859,123 +1586,114 @@ def build_resources_list_by_resource_group_request( top: Optional[int] = None, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2019-07-01") # type: 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", "2019-07-01")) # type: str + accept = _headers.pop("Accept", "application/json") - accept = "application/json" # Construct URL _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/resources") path_format_arguments = { - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._\(\)]+$'), - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), + "resourceGroupName": _SERIALIZER.url( + "resource_group_name", resource_group_name, "str", max_length=90, min_length=1, pattern=r"^[-\w\._\(\)]+$" + ), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), } _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] if filter is not None: - _query_parameters['$filter'] = _SERIALIZER.query("filter", filter, 'str') + _params["$filter"] = _SERIALIZER.query("filter", filter, "str") if expand is not None: - _query_parameters['$expand'] = _SERIALIZER.query("expand", expand, 'str') + _params["$expand"] = _SERIALIZER.query("expand", expand, "str") if top is not None: - _query_parameters['$top'] = _SERIALIZER.query("top", top, 'int') - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["$top"] = _SERIALIZER.query("top", top, "int") + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') - - return HttpRequest( - method="GET", - url=_url, - params=_query_parameters, - headers=_header_parameters, - **kwargs - ) + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) -def build_resources_move_resources_request_initial( - source_resource_group_name: str, - subscription_id: str, - *, - json: JSONType = None, - content: Any = None, - **kwargs: Any + +def build_resources_move_resources_request( + source_resource_group_name: str, subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2019-07-01") # type: str - content_type = kwargs.pop('content_type', None) # type: Optional[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", "2019-07-01")) # type: str + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + accept = _headers.pop("Accept", "application/json") - accept = "application/json" # Construct URL - _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{sourceResourceGroupName}/moveResources") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", "/subscriptions/{subscriptionId}/resourceGroups/{sourceResourceGroupName}/moveResources" + ) # pylint: disable=line-too-long path_format_arguments = { - "sourceResourceGroupName": _SERIALIZER.url("source_resource_group_name", source_resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._\(\)]+$'), - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), + "sourceResourceGroupName": _SERIALIZER.url( + "source_resource_group_name", + source_resource_group_name, + "str", + max_length=90, + min_length=1, + pattern=r"^[-\w\._\(\)]+$", + ), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), } _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] if content_type is not None: - _header_parameters['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') - _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') - - return HttpRequest( - method="POST", - url=_url, - params=_query_parameters, - headers=_header_parameters, - json=json, - content=content, - **kwargs - ) + _headers["Content-Type"] = _SERIALIZER.header("content_type", content_type, "str") + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + return HttpRequest(method="POST", url=_url, params=_params, headers=_headers, **kwargs) -def build_resources_validate_move_resources_request_initial( - source_resource_group_name: str, - subscription_id: str, - *, - json: JSONType = None, - content: Any = None, - **kwargs: Any + +def build_resources_validate_move_resources_request( + source_resource_group_name: str, subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2019-07-01") # type: str - content_type = kwargs.pop('content_type', None) # type: Optional[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", "2019-07-01")) # type: str + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + accept = _headers.pop("Accept", "application/json") - accept = "application/json" # Construct URL - _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{sourceResourceGroupName}/validateMoveResources") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", "/subscriptions/{subscriptionId}/resourceGroups/{sourceResourceGroupName}/validateMoveResources" + ) # pylint: disable=line-too-long path_format_arguments = { - "sourceResourceGroupName": _SERIALIZER.url("source_resource_group_name", source_resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._\(\)]+$'), - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), + "sourceResourceGroupName": _SERIALIZER.url( + "source_resource_group_name", + source_resource_group_name, + "str", + max_length=90, + min_length=1, + pattern=r"^[-\w\._\(\)]+$", + ), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), } _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] if content_type is not None: - _header_parameters['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') - _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') - - return HttpRequest( - method="POST", - url=_url, - params=_query_parameters, - headers=_header_parameters, - json=json, - content=content, - **kwargs - ) + _headers["Content-Type"] = _SERIALIZER.header("content_type", content_type, "str") + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="POST", url=_url, params=_params, headers=_headers, **kwargs) def build_resources_list_request( @@ -1986,38 +1704,33 @@ def build_resources_list_request( top: Optional[int] = None, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2019-07-01") # type: 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", "2019-07-01")) # type: str + accept = _headers.pop("Accept", "application/json") - accept = "application/json" # Construct URL _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resources") path_format_arguments = { - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), } _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] if filter is not None: - _query_parameters['$filter'] = _SERIALIZER.query("filter", filter, 'str') + _params["$filter"] = _SERIALIZER.query("filter", filter, "str") if expand is not None: - _query_parameters['$expand'] = _SERIALIZER.query("expand", expand, 'str') + _params["$expand"] = _SERIALIZER.query("expand", expand, "str") if top is not None: - _query_parameters['$top'] = _SERIALIZER.query("top", top, 'int') - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["$top"] = _SERIALIZER.query("top", top, "int") + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') - - return HttpRequest( - method="GET", - url=_url, - params=_query_parameters, - headers=_header_parameters, - **kwargs - ) + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) def build_resources_check_existence_request( @@ -2031,38 +1744,39 @@ def build_resources_check_existence_request( api_version: str, **kwargs: Any ) -> HttpRequest: - accept = "application/json" + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + accept = _headers.pop("Accept", "application/json") + # Construct URL - _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{parentResourcePath}/{resourceType}/{resourceName}") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{parentResourcePath}/{resourceType}/{resourceName}", + ) # pylint: disable=line-too-long path_format_arguments = { - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._\(\)]+$'), - "resourceProviderNamespace": _SERIALIZER.url("resource_provider_namespace", resource_provider_namespace, 'str'), - "parentResourcePath": _SERIALIZER.url("parent_resource_path", parent_resource_path, 'str', skip_quote=True), - "resourceType": _SERIALIZER.url("resource_type", resource_type, 'str', skip_quote=True), - "resourceName": _SERIALIZER.url("resource_name", resource_name, 'str'), - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), + "resourceGroupName": _SERIALIZER.url( + "resource_group_name", resource_group_name, "str", max_length=90, min_length=1, pattern=r"^[-\w\._\(\)]+$" + ), + "resourceProviderNamespace": _SERIALIZER.url("resource_provider_namespace", resource_provider_namespace, "str"), + "parentResourcePath": _SERIALIZER.url("parent_resource_path", parent_resource_path, "str", skip_quote=True), + "resourceType": _SERIALIZER.url("resource_type", resource_type, "str", skip_quote=True), + "resourceName": _SERIALIZER.url("resource_name", resource_name, "str"), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), } _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') - - return HttpRequest( - method="HEAD", - url=_url, - params=_query_parameters, - headers=_header_parameters, - **kwargs - ) + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + return HttpRequest(method="HEAD", url=_url, params=_params, headers=_headers, **kwargs) -def build_resources_delete_request_initial( + +def build_resources_delete_request( resource_group_name: str, resource_provider_namespace: str, parent_resource_path: str, @@ -2073,38 +1787,39 @@ def build_resources_delete_request_initial( api_version: str, **kwargs: Any ) -> HttpRequest: - accept = "application/json" + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + accept = _headers.pop("Accept", "application/json") + # Construct URL - _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{parentResourcePath}/{resourceType}/{resourceName}") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{parentResourcePath}/{resourceType}/{resourceName}", + ) # pylint: disable=line-too-long path_format_arguments = { - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._\(\)]+$'), - "resourceProviderNamespace": _SERIALIZER.url("resource_provider_namespace", resource_provider_namespace, 'str'), - "parentResourcePath": _SERIALIZER.url("parent_resource_path", parent_resource_path, 'str', skip_quote=True), - "resourceType": _SERIALIZER.url("resource_type", resource_type, 'str', skip_quote=True), - "resourceName": _SERIALIZER.url("resource_name", resource_name, 'str'), - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), + "resourceGroupName": _SERIALIZER.url( + "resource_group_name", resource_group_name, "str", max_length=90, min_length=1, pattern=r"^[-\w\._\(\)]+$" + ), + "resourceProviderNamespace": _SERIALIZER.url("resource_provider_namespace", resource_provider_namespace, "str"), + "parentResourcePath": _SERIALIZER.url("parent_resource_path", parent_resource_path, "str", skip_quote=True), + "resourceType": _SERIALIZER.url("resource_type", resource_type, "str", skip_quote=True), + "resourceName": _SERIALIZER.url("resource_name", resource_name, "str"), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), } _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') - - return HttpRequest( - method="DELETE", - url=_url, - params=_query_parameters, - headers=_header_parameters, - **kwargs - ) + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + return HttpRequest(method="DELETE", url=_url, params=_params, headers=_headers, **kwargs) -def build_resources_create_or_update_request_initial( + +def build_resources_create_or_update_request( resource_group_name: str, resource_provider_namespace: str, parent_resource_path: str, @@ -2113,48 +1828,44 @@ def build_resources_create_or_update_request_initial( subscription_id: str, *, api_version: str, - json: JSONType = None, - content: Any = None, **kwargs: Any ) -> HttpRequest: - content_type = kwargs.pop('content_type', None) # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + accept = _headers.pop("Accept", "application/json") - accept = "application/json" # Construct URL - _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{parentResourcePath}/{resourceType}/{resourceName}") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{parentResourcePath}/{resourceType}/{resourceName}", + ) # pylint: disable=line-too-long path_format_arguments = { - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._\(\)]+$'), - "resourceProviderNamespace": _SERIALIZER.url("resource_provider_namespace", resource_provider_namespace, 'str'), - "parentResourcePath": _SERIALIZER.url("parent_resource_path", parent_resource_path, 'str', skip_quote=True), - "resourceType": _SERIALIZER.url("resource_type", resource_type, 'str', skip_quote=True), - "resourceName": _SERIALIZER.url("resource_name", resource_name, 'str'), - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), + "resourceGroupName": _SERIALIZER.url( + "resource_group_name", resource_group_name, "str", max_length=90, min_length=1, pattern=r"^[-\w\._\(\)]+$" + ), + "resourceProviderNamespace": _SERIALIZER.url("resource_provider_namespace", resource_provider_namespace, "str"), + "parentResourcePath": _SERIALIZER.url("parent_resource_path", parent_resource_path, "str", skip_quote=True), + "resourceType": _SERIALIZER.url("resource_type", resource_type, "str", skip_quote=True), + "resourceName": _SERIALIZER.url("resource_name", resource_name, "str"), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), } _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] if content_type is not None: - _header_parameters['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') - _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') - - return HttpRequest( - method="PUT", - url=_url, - params=_query_parameters, - headers=_header_parameters, - json=json, - content=content, - **kwargs - ) + _headers["Content-Type"] = _SERIALIZER.header("content_type", content_type, "str") + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="PUT", url=_url, params=_params, headers=_headers, **kwargs) -def build_resources_update_request_initial( +def build_resources_update_request( resource_group_name: str, resource_provider_namespace: str, parent_resource_path: str, @@ -2163,45 +1874,41 @@ def build_resources_update_request_initial( subscription_id: str, *, api_version: str, - json: JSONType = None, - content: Any = None, **kwargs: Any ) -> HttpRequest: - content_type = kwargs.pop('content_type', None) # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + accept = _headers.pop("Accept", "application/json") - accept = "application/json" # Construct URL - _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{parentResourcePath}/{resourceType}/{resourceName}") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{parentResourcePath}/{resourceType}/{resourceName}", + ) # pylint: disable=line-too-long path_format_arguments = { - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._\(\)]+$'), - "resourceProviderNamespace": _SERIALIZER.url("resource_provider_namespace", resource_provider_namespace, 'str'), - "parentResourcePath": _SERIALIZER.url("parent_resource_path", parent_resource_path, 'str', skip_quote=True), - "resourceType": _SERIALIZER.url("resource_type", resource_type, 'str', skip_quote=True), - "resourceName": _SERIALIZER.url("resource_name", resource_name, 'str'), - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), + "resourceGroupName": _SERIALIZER.url( + "resource_group_name", resource_group_name, "str", max_length=90, min_length=1, pattern=r"^[-\w\._\(\)]+$" + ), + "resourceProviderNamespace": _SERIALIZER.url("resource_provider_namespace", resource_provider_namespace, "str"), + "parentResourcePath": _SERIALIZER.url("parent_resource_path", parent_resource_path, "str", skip_quote=True), + "resourceType": _SERIALIZER.url("resource_type", resource_type, "str", skip_quote=True), + "resourceName": _SERIALIZER.url("resource_name", resource_name, "str"), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), } _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] if content_type is not None: - _header_parameters['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') - _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') - - return HttpRequest( - method="PATCH", - url=_url, - params=_query_parameters, - headers=_header_parameters, - json=json, - content=content, - **kwargs - ) + _headers["Content-Type"] = _SERIALIZER.header("content_type", content_type, "str") + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="PATCH", url=_url, params=_params, headers=_headers, **kwargs) def build_resources_get_request( @@ -2215,1080 +1922,890 @@ def build_resources_get_request( api_version: str, **kwargs: Any ) -> HttpRequest: - accept = "application/json" + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + accept = _headers.pop("Accept", "application/json") + # Construct URL - _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{parentResourcePath}/{resourceType}/{resourceName}") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{parentResourcePath}/{resourceType}/{resourceName}", + ) # pylint: disable=line-too-long path_format_arguments = { - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._\(\)]+$'), - "resourceProviderNamespace": _SERIALIZER.url("resource_provider_namespace", resource_provider_namespace, 'str'), - "parentResourcePath": _SERIALIZER.url("parent_resource_path", parent_resource_path, 'str', skip_quote=True), - "resourceType": _SERIALIZER.url("resource_type", resource_type, 'str', skip_quote=True), - "resourceName": _SERIALIZER.url("resource_name", resource_name, 'str'), - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), + "resourceGroupName": _SERIALIZER.url( + "resource_group_name", resource_group_name, "str", max_length=90, min_length=1, pattern=r"^[-\w\._\(\)]+$" + ), + "resourceProviderNamespace": _SERIALIZER.url("resource_provider_namespace", resource_provider_namespace, "str"), + "parentResourcePath": _SERIALIZER.url("parent_resource_path", parent_resource_path, "str", skip_quote=True), + "resourceType": _SERIALIZER.url("resource_type", resource_type, "str", skip_quote=True), + "resourceName": _SERIALIZER.url("resource_name", resource_name, "str"), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), } _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') - - return HttpRequest( - method="GET", - url=_url, - params=_query_parameters, - headers=_header_parameters, - **kwargs - ) + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) + + +def build_resources_check_existence_by_id_request(resource_id: str, *, api_version: str, **kwargs: Any) -> HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + accept = _headers.pop("Accept", "application/json") -def build_resources_check_existence_by_id_request( - resource_id: str, - *, - api_version: str, - **kwargs: Any -) -> HttpRequest: - accept = "application/json" # Construct URL _url = kwargs.pop("template_url", "/{resourceId}") path_format_arguments = { - "resourceId": _SERIALIZER.url("resource_id", resource_id, 'str', skip_quote=True), + "resourceId": _SERIALIZER.url("resource_id", resource_id, "str", skip_quote=True), } _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') - - return HttpRequest( - method="HEAD", - url=_url, - params=_query_parameters, - headers=_header_parameters, - **kwargs - ) + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + return HttpRequest(method="HEAD", url=_url, params=_params, headers=_headers, **kwargs) + + +def build_resources_delete_by_id_request(resource_id: str, *, api_version: str, **kwargs: Any) -> HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + accept = _headers.pop("Accept", "application/json") -def build_resources_delete_by_id_request_initial( - resource_id: str, - *, - api_version: str, - **kwargs: Any -) -> HttpRequest: - accept = "application/json" # Construct URL _url = kwargs.pop("template_url", "/{resourceId}") path_format_arguments = { - "resourceId": _SERIALIZER.url("resource_id", resource_id, 'str', skip_quote=True), + "resourceId": _SERIALIZER.url("resource_id", resource_id, "str", skip_quote=True), } _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') - - return HttpRequest( - method="DELETE", - url=_url, - params=_query_parameters, - headers=_header_parameters, - **kwargs - ) + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + return HttpRequest(method="DELETE", url=_url, params=_params, headers=_headers, **kwargs) -def build_resources_create_or_update_by_id_request_initial( - resource_id: str, - *, - api_version: str, - json: JSONType = None, - content: Any = None, - **kwargs: Any -) -> HttpRequest: - content_type = kwargs.pop('content_type', None) # type: Optional[str] - accept = "application/json" +def build_resources_create_or_update_by_id_request(resource_id: str, *, api_version: str, **kwargs: Any) -> HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + accept = _headers.pop("Accept", "application/json") + # Construct URL _url = kwargs.pop("template_url", "/{resourceId}") path_format_arguments = { - "resourceId": _SERIALIZER.url("resource_id", resource_id, 'str', skip_quote=True), + "resourceId": _SERIALIZER.url("resource_id", resource_id, "str", skip_quote=True), } _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] if content_type is not None: - _header_parameters['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') - _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') - - return HttpRequest( - method="PUT", - url=_url, - params=_query_parameters, - headers=_header_parameters, - json=json, - content=content, - **kwargs - ) + _headers["Content-Type"] = _SERIALIZER.header("content_type", content_type, "str") + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + return HttpRequest(method="PUT", url=_url, params=_params, headers=_headers, **kwargs) -def build_resources_update_by_id_request_initial( - resource_id: str, - *, - api_version: str, - json: JSONType = None, - content: Any = None, - **kwargs: Any -) -> HttpRequest: - content_type = kwargs.pop('content_type', None) # type: Optional[str] - accept = "application/json" +def build_resources_update_by_id_request(resource_id: str, *, api_version: str, **kwargs: Any) -> HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + accept = _headers.pop("Accept", "application/json") + # Construct URL _url = kwargs.pop("template_url", "/{resourceId}") path_format_arguments = { - "resourceId": _SERIALIZER.url("resource_id", resource_id, 'str', skip_quote=True), + "resourceId": _SERIALIZER.url("resource_id", resource_id, "str", skip_quote=True), } _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] if content_type is not None: - _header_parameters['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') - _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') - - return HttpRequest( - method="PATCH", - url=_url, - params=_query_parameters, - headers=_header_parameters, - json=json, - content=content, - **kwargs - ) + _headers["Content-Type"] = _SERIALIZER.header("content_type", content_type, "str") + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + return HttpRequest(method="PATCH", url=_url, params=_params, headers=_headers, **kwargs) + + +def build_resources_get_by_id_request(resource_id: str, *, api_version: str, **kwargs: Any) -> HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + accept = _headers.pop("Accept", "application/json") -def build_resources_get_by_id_request( - resource_id: str, - *, - api_version: str, - **kwargs: Any -) -> HttpRequest: - accept = "application/json" # Construct URL _url = kwargs.pop("template_url", "/{resourceId}") path_format_arguments = { - "resourceId": _SERIALIZER.url("resource_id", resource_id, 'str', skip_quote=True), + "resourceId": _SERIALIZER.url("resource_id", resource_id, "str", skip_quote=True), } _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') - - return HttpRequest( - method="GET", - url=_url, - params=_query_parameters, - headers=_header_parameters, - **kwargs - ) + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) def build_resource_groups_check_existence_request( - resource_group_name: str, - subscription_id: str, - **kwargs: Any + resource_group_name: str, subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2019-07-01") # type: 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", "2019-07-01")) # type: str + accept = _headers.pop("Accept", "application/json") - accept = "application/json" # Construct URL _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}") path_format_arguments = { - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._\(\)]+$'), - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), + "resourceGroupName": _SERIALIZER.url( + "resource_group_name", resource_group_name, "str", max_length=90, min_length=1, pattern=r"^[-\w\._\(\)]+$" + ), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), } _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') - - return HttpRequest( - method="HEAD", - url=_url, - params=_query_parameters, - headers=_header_parameters, - **kwargs - ) + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="HEAD", url=_url, params=_params, headers=_headers, **kwargs) def build_resource_groups_create_or_update_request( - resource_group_name: str, - subscription_id: str, - *, - json: JSONType = None, - content: Any = None, - **kwargs: Any + resource_group_name: str, subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2019-07-01") # type: str - content_type = kwargs.pop('content_type', None) # type: Optional[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", "2019-07-01")) # type: str + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + accept = _headers.pop("Accept", "application/json") - accept = "application/json" # Construct URL _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}") path_format_arguments = { - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._\(\)]+$'), - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), + "resourceGroupName": _SERIALIZER.url( + "resource_group_name", resource_group_name, "str", max_length=90, min_length=1, pattern=r"^[-\w\._\(\)]+$" + ), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), } _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] if content_type is not None: - _header_parameters['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') - _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') - - return HttpRequest( - method="PUT", - url=_url, - params=_query_parameters, - headers=_header_parameters, - json=json, - content=content, - **kwargs - ) + _headers["Content-Type"] = _SERIALIZER.header("content_type", content_type, "str") + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + return HttpRequest(method="PUT", url=_url, params=_params, headers=_headers, **kwargs) -def build_resource_groups_delete_request_initial( - resource_group_name: str, - subscription_id: str, - **kwargs: Any -) -> HttpRequest: - api_version = kwargs.pop('api_version', "2019-07-01") # type: str - accept = "application/json" +def build_resource_groups_delete_request(resource_group_name: str, subscription_id: str, **kwargs: Any) -> HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2019-07-01")) # type: str + accept = _headers.pop("Accept", "application/json") + # Construct URL _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}") path_format_arguments = { - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._\(\)]+$'), - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), + "resourceGroupName": _SERIALIZER.url( + "resource_group_name", resource_group_name, "str", max_length=90, min_length=1, pattern=r"^[-\w\._\(\)]+$" + ), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), } _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') - - return HttpRequest( - method="DELETE", - url=_url, - params=_query_parameters, - headers=_header_parameters, - **kwargs - ) + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + return HttpRequest(method="DELETE", url=_url, params=_params, headers=_headers, **kwargs) -def build_resource_groups_get_request( - resource_group_name: str, - subscription_id: str, - **kwargs: Any -) -> HttpRequest: - api_version = kwargs.pop('api_version', "2019-07-01") # type: str - accept = "application/json" +def build_resource_groups_get_request(resource_group_name: str, subscription_id: str, **kwargs: Any) -> HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2019-07-01")) # type: str + accept = _headers.pop("Accept", "application/json") + # Construct URL _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}") path_format_arguments = { - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._\(\)]+$'), - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), + "resourceGroupName": _SERIALIZER.url( + "resource_group_name", resource_group_name, "str", max_length=90, min_length=1, pattern=r"^[-\w\._\(\)]+$" + ), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), } _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') - - return HttpRequest( - method="GET", - url=_url, - params=_query_parameters, - headers=_header_parameters, - **kwargs - ) + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) -def build_resource_groups_update_request( - resource_group_name: str, - subscription_id: str, - *, - json: JSONType = None, - content: Any = None, - **kwargs: Any -) -> HttpRequest: - api_version = kwargs.pop('api_version', "2019-07-01") # type: str - content_type = kwargs.pop('content_type', None) # type: Optional[str] - accept = "application/json" +def build_resource_groups_update_request(resource_group_name: str, subscription_id: str, **kwargs: Any) -> HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2019-07-01")) # type: str + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + accept = _headers.pop("Accept", "application/json") + # Construct URL _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}") path_format_arguments = { - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._\(\)]+$'), - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), + "resourceGroupName": _SERIALIZER.url( + "resource_group_name", resource_group_name, "str", max_length=90, min_length=1, pattern=r"^[-\w\._\(\)]+$" + ), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), } _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] if content_type is not None: - _header_parameters['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') - _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') - - return HttpRequest( - method="PATCH", - url=_url, - params=_query_parameters, - headers=_header_parameters, - json=json, - content=content, - **kwargs - ) + _headers["Content-Type"] = _SERIALIZER.header("content_type", content_type, "str") + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="PATCH", url=_url, params=_params, headers=_headers, **kwargs) def build_resource_groups_export_template_request( - resource_group_name: str, - subscription_id: str, - *, - json: JSONType = None, - content: Any = None, - **kwargs: Any + resource_group_name: str, subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2019-07-01") # type: str - content_type = kwargs.pop('content_type', None) # type: Optional[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", "2019-07-01")) # type: str + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + accept = _headers.pop("Accept", "application/json") - accept = "application/json" # Construct URL - _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/exportTemplate") + _url = kwargs.pop( + "template_url", "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/exportTemplate" + ) path_format_arguments = { - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._\(\)]+$'), - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), + "resourceGroupName": _SERIALIZER.url( + "resource_group_name", resource_group_name, "str", max_length=90, min_length=1, pattern=r"^[-\w\._\(\)]+$" + ), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), } _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] if content_type is not None: - _header_parameters['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') - _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') - - return HttpRequest( - method="POST", - url=_url, - params=_query_parameters, - headers=_header_parameters, - json=json, - content=content, - **kwargs - ) + _headers["Content-Type"] = _SERIALIZER.header("content_type", content_type, "str") + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="POST", url=_url, params=_params, headers=_headers, **kwargs) def build_resource_groups_list_request( - subscription_id: str, - *, - filter: Optional[str] = None, - top: Optional[int] = None, - **kwargs: Any + subscription_id: str, *, filter: Optional[str] = None, top: Optional[int] = None, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2019-07-01") # type: 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", "2019-07-01")) # type: str + accept = _headers.pop("Accept", "application/json") - accept = "application/json" # Construct URL _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourcegroups") path_format_arguments = { - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), } _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] if filter is not None: - _query_parameters['$filter'] = _SERIALIZER.query("filter", filter, 'str') + _params["$filter"] = _SERIALIZER.query("filter", filter, "str") if top is not None: - _query_parameters['$top'] = _SERIALIZER.query("top", top, 'int') - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["$top"] = _SERIALIZER.query("top", top, "int") + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') - - return HttpRequest( - method="GET", - url=_url, - params=_query_parameters, - headers=_header_parameters, - **kwargs - ) + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) -def build_tags_delete_value_request( - tag_name: str, - tag_value: str, - subscription_id: str, - **kwargs: Any -) -> HttpRequest: - api_version = kwargs.pop('api_version', "2019-07-01") # type: str - accept = "application/json" +def build_tags_delete_value_request(tag_name: str, tag_value: str, subscription_id: str, **kwargs: Any) -> HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2019-07-01")) # type: str + accept = _headers.pop("Accept", "application/json") + # Construct URL _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/tagNames/{tagName}/tagValues/{tagValue}") path_format_arguments = { - "tagName": _SERIALIZER.url("tag_name", tag_name, 'str'), - "tagValue": _SERIALIZER.url("tag_value", tag_value, 'str'), - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), + "tagName": _SERIALIZER.url("tag_name", tag_name, "str"), + "tagValue": _SERIALIZER.url("tag_value", tag_value, "str"), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), } _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') - - return HttpRequest( - method="DELETE", - url=_url, - params=_query_parameters, - headers=_header_parameters, - **kwargs - ) + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="DELETE", url=_url, params=_params, headers=_headers, **kwargs) def build_tags_create_or_update_value_request( - tag_name: str, - tag_value: str, - subscription_id: str, - **kwargs: Any + tag_name: str, tag_value: str, subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2019-07-01") # type: 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", "2019-07-01")) # type: str + accept = _headers.pop("Accept", "application/json") - accept = "application/json" # Construct URL _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/tagNames/{tagName}/tagValues/{tagValue}") path_format_arguments = { - "tagName": _SERIALIZER.url("tag_name", tag_name, 'str'), - "tagValue": _SERIALIZER.url("tag_value", tag_value, 'str'), - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), + "tagName": _SERIALIZER.url("tag_name", tag_name, "str"), + "tagValue": _SERIALIZER.url("tag_value", tag_value, "str"), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), } _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') - - return HttpRequest( - method="PUT", - url=_url, - params=_query_parameters, - headers=_header_parameters, - **kwargs - ) + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + return HttpRequest(method="PUT", url=_url, params=_params, headers=_headers, **kwargs) -def build_tags_create_or_update_request( - tag_name: str, - subscription_id: str, - **kwargs: Any -) -> HttpRequest: - api_version = kwargs.pop('api_version', "2019-07-01") # type: str - accept = "application/json" +def build_tags_create_or_update_request(tag_name: str, subscription_id: str, **kwargs: Any) -> HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2019-07-01")) # type: str + accept = _headers.pop("Accept", "application/json") + # Construct URL _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/tagNames/{tagName}") path_format_arguments = { - "tagName": _SERIALIZER.url("tag_name", tag_name, 'str'), - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), + "tagName": _SERIALIZER.url("tag_name", tag_name, "str"), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), } _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') - - return HttpRequest( - method="PUT", - url=_url, - params=_query_parameters, - headers=_header_parameters, - **kwargs - ) + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + return HttpRequest(method="PUT", url=_url, params=_params, headers=_headers, **kwargs) -def build_tags_delete_request( - tag_name: str, - subscription_id: str, - **kwargs: Any -) -> HttpRequest: - api_version = kwargs.pop('api_version', "2019-07-01") # type: str - accept = "application/json" +def build_tags_delete_request(tag_name: str, subscription_id: str, **kwargs: Any) -> HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2019-07-01")) # type: str + accept = _headers.pop("Accept", "application/json") + # Construct URL _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/tagNames/{tagName}") path_format_arguments = { - "tagName": _SERIALIZER.url("tag_name", tag_name, 'str'), - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), + "tagName": _SERIALIZER.url("tag_name", tag_name, "str"), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), } _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') - - return HttpRequest( - method="DELETE", - url=_url, - params=_query_parameters, - headers=_header_parameters, - **kwargs - ) + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + return HttpRequest(method="DELETE", url=_url, params=_params, headers=_headers, **kwargs) -def build_tags_list_request( - subscription_id: str, - **kwargs: Any -) -> HttpRequest: - api_version = kwargs.pop('api_version', "2019-07-01") # type: str - accept = "application/json" +def build_tags_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", "2019-07-01")) # type: str + accept = _headers.pop("Accept", "application/json") + # Construct URL _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/tagNames") path_format_arguments = { - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), } _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') - - return HttpRequest( - method="GET", - url=_url, - params=_query_parameters, - headers=_header_parameters, - **kwargs - ) + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) def build_deployment_operations_get_at_scope_request( - scope: str, - deployment_name: str, - operation_id: str, - **kwargs: Any + scope: str, deployment_name: str, operation_id: str, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2019-07-01") # type: 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", "2019-07-01")) # type: str + accept = _headers.pop("Accept", "application/json") - accept = "application/json" # Construct URL - _url = kwargs.pop("template_url", "/{scope}/providers/Microsoft.Resources/deployments/{deploymentName}/operations/{operationId}") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", "/{scope}/providers/Microsoft.Resources/deployments/{deploymentName}/operations/{operationId}" + ) # pylint: disable=line-too-long path_format_arguments = { - "scope": _SERIALIZER.url("scope", scope, 'str'), - "deploymentName": _SERIALIZER.url("deployment_name", deployment_name, 'str', max_length=64, min_length=1, pattern=r'^[-\w\._\(\)]+$'), - "operationId": _SERIALIZER.url("operation_id", operation_id, 'str'), + "scope": _SERIALIZER.url("scope", scope, "str"), + "deploymentName": _SERIALIZER.url( + "deployment_name", deployment_name, "str", max_length=64, min_length=1, pattern=r"^[-\w\._\(\)]+$" + ), + "operationId": _SERIALIZER.url("operation_id", operation_id, "str"), } _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') - - return HttpRequest( - method="GET", - url=_url, - params=_query_parameters, - headers=_header_parameters, - **kwargs - ) + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) def build_deployment_operations_list_at_scope_request( - scope: str, - deployment_name: str, - *, - top: Optional[int] = None, - **kwargs: Any + scope: str, deployment_name: str, *, top: Optional[int] = None, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2019-07-01") # type: 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", "2019-07-01")) # type: str + accept = _headers.pop("Accept", "application/json") - accept = "application/json" # Construct URL _url = kwargs.pop("template_url", "/{scope}/providers/Microsoft.Resources/deployments/{deploymentName}/operations") path_format_arguments = { - "scope": _SERIALIZER.url("scope", scope, 'str'), - "deploymentName": _SERIALIZER.url("deployment_name", deployment_name, 'str', max_length=64, min_length=1, pattern=r'^[-\w\._\(\)]+$'), + "scope": _SERIALIZER.url("scope", scope, "str"), + "deploymentName": _SERIALIZER.url( + "deployment_name", deployment_name, "str", max_length=64, min_length=1, pattern=r"^[-\w\._\(\)]+$" + ), } _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] if top is not None: - _query_parameters['$top'] = _SERIALIZER.query("top", top, 'int') - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["$top"] = _SERIALIZER.query("top", top, "int") + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') - - return HttpRequest( - method="GET", - url=_url, - params=_query_parameters, - headers=_header_parameters, - **kwargs - ) + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) def build_deployment_operations_get_at_tenant_scope_request( - deployment_name: str, - operation_id: str, - **kwargs: Any + deployment_name: str, operation_id: str, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2019-07-01") # type: 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", "2019-07-01")) # type: str + accept = _headers.pop("Accept", "application/json") - accept = "application/json" # Construct URL - _url = kwargs.pop("template_url", "/providers/Microsoft.Resources/deployments/{deploymentName}/operations/{operationId}") + _url = kwargs.pop( + "template_url", "/providers/Microsoft.Resources/deployments/{deploymentName}/operations/{operationId}" + ) path_format_arguments = { - "deploymentName": _SERIALIZER.url("deployment_name", deployment_name, 'str', max_length=64, min_length=1, pattern=r'^[-\w\._\(\)]+$'), - "operationId": _SERIALIZER.url("operation_id", operation_id, 'str'), + "deploymentName": _SERIALIZER.url( + "deployment_name", deployment_name, "str", max_length=64, min_length=1, pattern=r"^[-\w\._\(\)]+$" + ), + "operationId": _SERIALIZER.url("operation_id", operation_id, "str"), } _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') - - return HttpRequest( - method="GET", - url=_url, - params=_query_parameters, - headers=_header_parameters, - **kwargs - ) + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) def build_deployment_operations_list_at_tenant_scope_request( - deployment_name: str, - *, - top: Optional[int] = None, - **kwargs: Any + deployment_name: str, *, top: Optional[int] = None, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2019-07-01") # type: 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", "2019-07-01")) # type: str + accept = _headers.pop("Accept", "application/json") - accept = "application/json" # Construct URL _url = kwargs.pop("template_url", "/providers/Microsoft.Resources/deployments/{deploymentName}/operations") path_format_arguments = { - "deploymentName": _SERIALIZER.url("deployment_name", deployment_name, 'str', max_length=64, min_length=1, pattern=r'^[-\w\._\(\)]+$'), + "deploymentName": _SERIALIZER.url( + "deployment_name", deployment_name, "str", max_length=64, min_length=1, pattern=r"^[-\w\._\(\)]+$" + ), } _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] if top is not None: - _query_parameters['$top'] = _SERIALIZER.query("top", top, 'int') - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["$top"] = _SERIALIZER.query("top", top, "int") + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') - - return HttpRequest( - method="GET", - url=_url, - params=_query_parameters, - headers=_header_parameters, - **kwargs - ) + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) def build_deployment_operations_get_at_management_group_scope_request( - group_id: str, - deployment_name: str, - operation_id: str, - **kwargs: Any + group_id: str, deployment_name: str, operation_id: str, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2019-07-01") # type: 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", "2019-07-01")) # type: str + accept = _headers.pop("Accept", "application/json") - accept = "application/json" # Construct URL - _url = kwargs.pop("template_url", "/providers/Microsoft.Management/managementGroups/{groupId}/providers/Microsoft.Resources/deployments/{deploymentName}/operations/{operationId}") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", + "/providers/Microsoft.Management/managementGroups/{groupId}/providers/Microsoft.Resources/deployments/{deploymentName}/operations/{operationId}", + ) # pylint: disable=line-too-long path_format_arguments = { - "groupId": _SERIALIZER.url("group_id", group_id, 'str', max_length=90, min_length=1), - "deploymentName": _SERIALIZER.url("deployment_name", deployment_name, 'str', max_length=64, min_length=1, pattern=r'^[-\w\._\(\)]+$'), - "operationId": _SERIALIZER.url("operation_id", operation_id, 'str'), + "groupId": _SERIALIZER.url("group_id", group_id, "str", max_length=90, min_length=1), + "deploymentName": _SERIALIZER.url( + "deployment_name", deployment_name, "str", max_length=64, min_length=1, pattern=r"^[-\w\._\(\)]+$" + ), + "operationId": _SERIALIZER.url("operation_id", operation_id, "str"), } _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') - - return HttpRequest( - method="GET", - url=_url, - params=_query_parameters, - headers=_header_parameters, - **kwargs - ) + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) def build_deployment_operations_list_at_management_group_scope_request( - group_id: str, - deployment_name: str, - *, - top: Optional[int] = None, - **kwargs: Any + group_id: str, deployment_name: str, *, top: Optional[int] = None, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2019-07-01") # type: 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", "2019-07-01")) # type: str + accept = _headers.pop("Accept", "application/json") - accept = "application/json" # Construct URL - _url = kwargs.pop("template_url", "/providers/Microsoft.Management/managementGroups/{groupId}/providers/Microsoft.Resources/deployments/{deploymentName}/operations") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", + "/providers/Microsoft.Management/managementGroups/{groupId}/providers/Microsoft.Resources/deployments/{deploymentName}/operations", + ) # pylint: disable=line-too-long path_format_arguments = { - "groupId": _SERIALIZER.url("group_id", group_id, 'str', max_length=90, min_length=1), - "deploymentName": _SERIALIZER.url("deployment_name", deployment_name, 'str', max_length=64, min_length=1, pattern=r'^[-\w\._\(\)]+$'), + "groupId": _SERIALIZER.url("group_id", group_id, "str", max_length=90, min_length=1), + "deploymentName": _SERIALIZER.url( + "deployment_name", deployment_name, "str", max_length=64, min_length=1, pattern=r"^[-\w\._\(\)]+$" + ), } _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] if top is not None: - _query_parameters['$top'] = _SERIALIZER.query("top", top, 'int') - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["$top"] = _SERIALIZER.query("top", top, "int") + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') - - return HttpRequest( - method="GET", - url=_url, - params=_query_parameters, - headers=_header_parameters, - **kwargs - ) + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) def build_deployment_operations_get_at_subscription_scope_request( - deployment_name: str, - operation_id: str, - subscription_id: str, - **kwargs: Any + deployment_name: str, operation_id: str, subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2019-07-01") # type: 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", "2019-07-01")) # type: str + accept = _headers.pop("Accept", "application/json") - accept = "application/json" # Construct URL - _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/providers/Microsoft.Resources/deployments/{deploymentName}/operations/{operationId}") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/providers/Microsoft.Resources/deployments/{deploymentName}/operations/{operationId}", + ) # pylint: disable=line-too-long path_format_arguments = { - "deploymentName": _SERIALIZER.url("deployment_name", deployment_name, 'str', max_length=64, min_length=1, pattern=r'^[-\w\._\(\)]+$'), - "operationId": _SERIALIZER.url("operation_id", operation_id, 'str'), - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), + "deploymentName": _SERIALIZER.url( + "deployment_name", deployment_name, "str", max_length=64, min_length=1, pattern=r"^[-\w\._\(\)]+$" + ), + "operationId": _SERIALIZER.url("operation_id", operation_id, "str"), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), } _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') - - return HttpRequest( - method="GET", - url=_url, - params=_query_parameters, - headers=_header_parameters, - **kwargs - ) + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) def build_deployment_operations_list_at_subscription_scope_request( - deployment_name: str, - subscription_id: str, - *, - top: Optional[int] = None, - **kwargs: Any + deployment_name: str, subscription_id: str, *, top: Optional[int] = None, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2019-07-01") # type: 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", "2019-07-01")) # type: str + accept = _headers.pop("Accept", "application/json") - accept = "application/json" # Construct URL - _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/providers/Microsoft.Resources/deployments/{deploymentName}/operations") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/providers/Microsoft.Resources/deployments/{deploymentName}/operations", + ) # pylint: disable=line-too-long path_format_arguments = { - "deploymentName": _SERIALIZER.url("deployment_name", deployment_name, 'str', max_length=64, min_length=1, pattern=r'^[-\w\._\(\)]+$'), - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), + "deploymentName": _SERIALIZER.url( + "deployment_name", deployment_name, "str", max_length=64, min_length=1, pattern=r"^[-\w\._\(\)]+$" + ), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), } _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] if top is not None: - _query_parameters['$top'] = _SERIALIZER.query("top", top, 'int') - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["$top"] = _SERIALIZER.query("top", top, "int") + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') - - return HttpRequest( - method="GET", - url=_url, - params=_query_parameters, - headers=_header_parameters, - **kwargs - ) + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) def build_deployment_operations_get_request( - resource_group_name: str, - deployment_name: str, - operation_id: str, - subscription_id: str, - **kwargs: Any + resource_group_name: str, deployment_name: str, operation_id: str, subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2019-07-01") # type: 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", "2019-07-01")) # type: str + accept = _headers.pop("Accept", "application/json") - accept = "application/json" # Construct URL - _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/deployments/{deploymentName}/operations/{operationId}") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/deployments/{deploymentName}/operations/{operationId}", + ) # pylint: disable=line-too-long path_format_arguments = { - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._\(\)]+$'), - "deploymentName": _SERIALIZER.url("deployment_name", deployment_name, 'str', max_length=64, min_length=1, pattern=r'^[-\w\._\(\)]+$'), - "operationId": _SERIALIZER.url("operation_id", operation_id, 'str'), - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), + "resourceGroupName": _SERIALIZER.url( + "resource_group_name", resource_group_name, "str", max_length=90, min_length=1, pattern=r"^[-\w\._\(\)]+$" + ), + "deploymentName": _SERIALIZER.url( + "deployment_name", deployment_name, "str", max_length=64, min_length=1, pattern=r"^[-\w\._\(\)]+$" + ), + "operationId": _SERIALIZER.url("operation_id", operation_id, "str"), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), } _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') - - return HttpRequest( - method="GET", - url=_url, - params=_query_parameters, - headers=_header_parameters, - **kwargs - ) + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) def build_deployment_operations_list_request( - resource_group_name: str, - deployment_name: str, - subscription_id: str, - *, - top: Optional[int] = None, - **kwargs: Any + resource_group_name: str, deployment_name: str, subscription_id: str, *, top: Optional[int] = None, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2019-07-01") # type: 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", "2019-07-01")) # type: str + accept = _headers.pop("Accept", "application/json") - accept = "application/json" # Construct URL - _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/deployments/{deploymentName}/operations") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/deployments/{deploymentName}/operations", + ) # pylint: disable=line-too-long path_format_arguments = { - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._\(\)]+$'), - "deploymentName": _SERIALIZER.url("deployment_name", deployment_name, 'str', max_length=64, min_length=1, pattern=r'^[-\w\._\(\)]+$'), - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), + "resourceGroupName": _SERIALIZER.url( + "resource_group_name", resource_group_name, "str", max_length=90, min_length=1, pattern=r"^[-\w\._\(\)]+$" + ), + "deploymentName": _SERIALIZER.url( + "deployment_name", deployment_name, "str", max_length=64, min_length=1, pattern=r"^[-\w\._\(\)]+$" + ), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), } _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] if top is not None: - _query_parameters['$top'] = _SERIALIZER.query("top", top, 'int') - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["$top"] = _SERIALIZER.query("top", top, "int") + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') - - return HttpRequest( - method="GET", - url=_url, - params=_query_parameters, - headers=_header_parameters, - **kwargs - ) + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) -class Operations(object): - """Operations operations. - You should not instantiate this class directly. Instead, you should create a Client instance that - instantiates it for you and attaches it as an attribute. +class Operations: + """ + .. warning:: + **DO NOT** instantiate this class directly. - :ivar models: Alias to model classes used in this operation group. - :type models: ~azure.mgmt.resource.resources.v2019_07_01.models - :param client: Client for service requests. - :param config: Configuration of service client. - :param serializer: An object model serializer. - :param deserializer: An object model deserializer. + Instead, you should access the following operations through + :class:`~azure.mgmt.resource.resources.v2019_07_01.ResourceManagementClient`'s + :attr:`operations` attribute. """ models = _models - def __init__(self, client, config, serializer, deserializer): - self._client = client - self._serialize = serializer - self._deserialize = deserializer - self._config = config + def __init__(self, *args, **kwargs): + input_args = list(args) + self._client = input_args.pop(0) if input_args else kwargs.pop("client") + self._config = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") @distributed_trace - def list( - self, - **kwargs: Any - ) -> Iterable["_models.OperationListResult"]: + def list(self, **kwargs: Any) -> Iterable["_models.Operation"]: """Lists all of the available Microsoft.Resources REST API operations. :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either OperationListResult or the result of cls(response) + :return: An iterator like instance of either Operation or the result of cls(response) :rtype: - ~azure.core.paging.ItemPaged[~azure.mgmt.resource.resources.v2019_07_01.models.OperationListResult] - :raises: ~azure.core.exceptions.HttpResponseError + ~azure.core.paging.ItemPaged[~azure.mgmt.resource.resources.v2019_07_01.models.Operation] + :raises ~azure.core.exceptions.HttpResponseError: """ - api_version = kwargs.pop('api_version', "2019-07-01") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2019-07-01")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[_models.OperationListResult] - cls = kwargs.pop('cls', None) # type: ClsType["_models.OperationListResult"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) + def prepare_request(next_link=None): if not next_link: - + request = build_operations_list_request( api_version=api_version, - template_url=self.list.metadata['url'], + template_url=self.list.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore else: - - request = build_operations_list_request( - template_url=next_link, - ) + # make call to next link with the client's api-version + _parsed_next_link = urlparse(next_link) + _next_request_params = case_insensitive_dict(parse_qs(_parsed_next_link.query)) + _next_request_params["api-version"] = self._config.api_version + request = HttpRequest("GET", urljoin(next_link, _parsed_next_link.path), params=_next_request_params) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore request.method = "GET" return request @@ -3302,10 +2819,8 @@ def extract_data(pipeline_response): def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) response = pipeline_response.http_response @@ -3315,62 +2830,62 @@ def get_next(next_link=None): return pipeline_response + return ItemPaged(get_next, extract_data) - return ItemPaged( - get_next, extract_data - ) - list.metadata = {'url': "/providers/Microsoft.Resources/operations"} # type: ignore -class DeploymentsOperations(object): # pylint: disable=too-many-public-methods - """DeploymentsOperations operations. + list.metadata = {"url": "/providers/Microsoft.Resources/operations"} # type: ignore - You should not instantiate this class directly. Instead, you should create a Client instance that - instantiates it for you and attaches it as an attribute. - :ivar models: Alias to model classes used in this operation group. - :type models: ~azure.mgmt.resource.resources.v2019_07_01.models - :param client: Client for service requests. - :param config: Configuration of service client. - :param serializer: An object model serializer. - :param deserializer: An object model deserializer. +class DeploymentsOperations: # pylint: disable=too-many-public-methods """ + .. warning:: + **DO NOT** instantiate this class directly. - models = _models + Instead, you should access the following operations through + :class:`~azure.mgmt.resource.resources.v2019_07_01.ResourceManagementClient`'s + :attr:`deployments` attribute. + """ + + models = _models - def __init__(self, client, config, serializer, deserializer): - self._client = client - self._serialize = serializer - self._deserialize = deserializer - self._config = config + def __init__(self, *args, **kwargs): + input_args = list(args) + self._client = input_args.pop(0) if input_args else kwargs.pop("client") + self._config = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") def _delete_at_scope_initial( # pylint: disable=inconsistent-return-statements - self, - scope: str, - deployment_name: str, - **kwargs: Any + self, scope: str, deployment_name: str, **kwargs: Any ) -> None: - cls = kwargs.pop('cls', None) # type: ClsType[None] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + 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', "2019-07-01") # type: str + api_version = kwargs.pop("api_version", _params.pop("api-version", "2019-07-01")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[None] - - request = build_deployments_delete_at_scope_request_initial( + request = build_deployments_delete_at_scope_request( scope=scope, deployment_name=deployment_name, api_version=api_version, - template_url=self._delete_at_scope_initial.metadata['url'], + template_url=self._delete_at_scope_initial.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [202, 204]: @@ -3380,16 +2895,10 @@ def _delete_at_scope_initial( # pylint: disable=inconsistent-return-statements if cls: return cls(pipeline_response, None, {}) - _delete_at_scope_initial.metadata = {'url': "/{scope}/providers/Microsoft.Resources/deployments/{deploymentName}"} # type: ignore - + _delete_at_scope_initial.metadata = {"url": "/{scope}/providers/Microsoft.Resources/deployments/{deploymentName}"} # type: ignore @distributed_trace - def begin_delete_at_scope( # pylint: disable=inconsistent-return-statements - self, - scope: str, - deployment_name: str, - **kwargs: Any - ) -> LROPoller[None]: + def begin_delete_at_scope(self, scope: str, deployment_name: str, **kwargs: Any) -> LROPoller[None]: """Deletes a deployment from the deployment history. A template deployment that is currently running cannot be deleted. Deleting a template @@ -3400,9 +2909,9 @@ def begin_delete_at_scope( # pylint: disable=inconsistent-return-statements process finishes, the URI in the Location header returns a status of 204 on success. If the asynchronous request failed, the URI in the Location header returns an error-level status code. - :param scope: The scope of a deployment. + :param scope: The scope of a deployment. Required. :type scope: str - :param deployment_name: The name of the deployment. + :param deployment_name: The name of the deployment. Required. :type deployment_name: str :keyword callable cls: A custom type or function that will be passed the direct response :keyword str continuation_token: A continuation token to restart a poller from a saved state. @@ -3414,86 +2923,91 @@ def begin_delete_at_scope( # pylint: disable=inconsistent-return-statements Retry-After header is present. :return: An instance of LROPoller that returns either None or the result of cls(response) :rtype: ~azure.core.polling.LROPoller[None] - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - api_version = kwargs.pop('api_version', "2019-07-01") # type: str - polling = kwargs.pop('polling', True) # type: Union[bool, PollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType[None] - lro_delay = kwargs.pop( - 'polling_interval', - self._config.polling_interval - ) - cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2019-07-01")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[None] + polling = kwargs.pop("polling", True) # type: Union[bool, PollingMethod] + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token = kwargs.pop("continuation_token", None) # type: Optional[str] if cont_token is None: - raw_result = self._delete_at_scope_initial( + raw_result = self._delete_at_scope_initial( # type: ignore scope=scope, deployment_name=deployment_name, api_version=api_version, - cls=lambda x,y,z: x, + cls=lambda x, y, z: x, + headers=_headers, + params=_params, **kwargs ) - kwargs.pop('error_map', None) + kwargs.pop("error_map", None) - def get_long_running_output(pipeline_response): + def get_long_running_output(pipeline_response): # pylint: disable=inconsistent-return-statements if cls: return cls(pipeline_response, None, {}) - - if polling is True: polling_method = ARMPolling(lro_delay, **kwargs) - elif polling is False: polling_method = NoPolling() - else: polling_method = polling + if polling is True: + polling_method = cast(PollingMethod, ARMPolling(lro_delay, **kwargs)) # type: PollingMethod + elif polling is False: + polling_method = cast(PollingMethod, NoPolling()) + else: + polling_method = polling if cont_token: return LROPoller.from_continuation_token( polling_method=polling_method, continuation_token=cont_token, client=self._client, - deserialization_callback=get_long_running_output + deserialization_callback=get_long_running_output, ) return LROPoller(self._client, raw_result, get_long_running_output, polling_method) - begin_delete_at_scope.metadata = {'url': "/{scope}/providers/Microsoft.Resources/deployments/{deploymentName}"} # type: ignore + begin_delete_at_scope.metadata = {"url": "/{scope}/providers/Microsoft.Resources/deployments/{deploymentName}"} # type: ignore @distributed_trace - def check_existence_at_scope( - self, - scope: str, - deployment_name: str, - **kwargs: Any - ) -> bool: + def check_existence_at_scope(self, scope: str, deployment_name: str, **kwargs: Any) -> bool: """Checks whether the deployment exists. - :param scope: The scope of a deployment. + :param scope: The scope of a deployment. Required. :type scope: str - :param deployment_name: The name of the deployment. + :param deployment_name: The name of the deployment. Required. :type deployment_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: bool, or the result of cls(response) + :return: bool or the result of cls(response) :rtype: bool - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType[None] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + 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', "2019-07-01") # type: str + api_version = kwargs.pop("api_version", _params.pop("api-version", "2019-07-01")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[None] - request = build_deployments_check_existence_at_scope_request( scope=scope, deployment_name=deployment_name, api_version=api_version, - template_url=self.check_existence_at_scope.metadata['url'], + template_url=self.check_existence_at_scope.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [204, 404]: @@ -3504,43 +3018,52 @@ def check_existence_at_scope( return cls(pipeline_response, None, {}) return 200 <= response.status_code <= 299 - check_existence_at_scope.metadata = {'url': "/{scope}/providers/Microsoft.Resources/deployments/{deploymentName}"} # type: ignore - + check_existence_at_scope.metadata = {"url": "/{scope}/providers/Microsoft.Resources/deployments/{deploymentName}"} # type: ignore def _create_or_update_at_scope_initial( - self, - scope: str, - deployment_name: str, - parameters: "_models.Deployment", - **kwargs: Any - ) -> "_models.DeploymentExtended": - cls = kwargs.pop('cls', None) # type: ClsType["_models.DeploymentExtended"] + self, scope: str, deployment_name: str, parameters: Union[_models.Deployment, IO], **kwargs: Any + ) -> _models.DeploymentExtended: error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) - api_version = kwargs.pop('api_version', "2019-07-01") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - _json = self._serialize.body(parameters, 'Deployment') + api_version = kwargs.pop("api_version", _params.pop("api-version", "2019-07-01")) # type: str + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.DeploymentExtended] - request = build_deployments_create_or_update_at_scope_request_initial( + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(parameters, (IO, bytes)): + _content = parameters + else: + _json = self._serialize.body(parameters, "Deployment") + + request = build_deployments_create_or_update_at_scope_request( scope=scope, deployment_name=deployment_name, api_version=api_version, content_type=content_type, json=_json, - template_url=self._create_or_update_at_scope_initial.metadata['url'], + content=_content, + template_url=self._create_or_update_at_scope_initial.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200, 201]: @@ -3548,37 +3071,41 @@ def _create_or_update_at_scope_initial( raise HttpResponseError(response=response, error_format=ARMErrorFormat) if response.status_code == 200: - deserialized = self._deserialize('DeploymentExtended', pipeline_response) + deserialized = self._deserialize("DeploymentExtended", pipeline_response) if response.status_code == 201: - deserialized = self._deserialize('DeploymentExtended', pipeline_response) + deserialized = self._deserialize("DeploymentExtended", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - _create_or_update_at_scope_initial.metadata = {'url': "/{scope}/providers/Microsoft.Resources/deployments/{deploymentName}"} # type: ignore + _create_or_update_at_scope_initial.metadata = {"url": "/{scope}/providers/Microsoft.Resources/deployments/{deploymentName}"} # type: ignore - - @distributed_trace + @overload def begin_create_or_update_at_scope( self, scope: str, deployment_name: str, - parameters: "_models.Deployment", + parameters: _models.Deployment, + *, + content_type: str = "application/json", **kwargs: Any - ) -> LROPoller["_models.DeploymentExtended"]: + ) -> LROPoller[_models.DeploymentExtended]: """Deploys resources at a given scope. You can provide the template and parameters directly in the request or link to JSON files. - :param scope: The scope of a deployment. + :param scope: The scope of a deployment. Required. :type scope: str - :param deployment_name: The name of the deployment. + :param deployment_name: The name of the deployment. Required. :type deployment_name: str - :param parameters: Additional parameters supplied to the operation. + :param parameters: Additional parameters supplied to the operation. Required. :type parameters: ~azure.mgmt.resource.resources.v2019_07_01.models.Deployment + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str :keyword callable cls: A custom type or function that will be passed the direct response :keyword str continuation_token: A continuation token to restart a poller from a saved state. :keyword polling: By default, your polling method will be ARMPolling. Pass in False for this @@ -3591,114 +3118,179 @@ def begin_create_or_update_at_scope( cls(response) :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.resource.resources.v2019_07_01.models.DeploymentExtended] - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - api_version = kwargs.pop('api_version', "2019-07-01") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] - polling = kwargs.pop('polling', True) # type: Union[bool, PollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType["_models.DeploymentExtended"] - lro_delay = kwargs.pop( - 'polling_interval', - self._config.polling_interval - ) - cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] + + @overload + def begin_create_or_update_at_scope( + self, scope: str, deployment_name: str, parameters: IO, *, content_type: str = "application/json", **kwargs: Any + ) -> LROPoller[_models.DeploymentExtended]: + """Deploys resources at a given scope. + + You can provide the template and parameters directly in the request or link to JSON files. + + :param scope: The scope of a deployment. Required. + :type scope: str + :param deployment_name: The name of the deployment. Required. + :type deployment_name: str + :param parameters: Additional parameters supplied to the operation. Required. + :type parameters: IO + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be ARMPolling. Pass in False for this + operation to not poll, or pass in your own initialized polling object for a personal polling + strategy. + :paramtype polling: bool or ~azure.core.polling.PollingMethod + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of LROPoller that returns either DeploymentExtended or the result of + cls(response) + :rtype: + ~azure.core.polling.LROPoller[~azure.mgmt.resource.resources.v2019_07_01.models.DeploymentExtended] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace + def begin_create_or_update_at_scope( + self, scope: str, deployment_name: str, parameters: Union[_models.Deployment, IO], **kwargs: Any + ) -> LROPoller[_models.DeploymentExtended]: + """Deploys resources at a given scope. + + You can provide the template and parameters directly in the request or link to JSON files. + + :param scope: The scope of a deployment. Required. + :type scope: str + :param deployment_name: The name of the deployment. Required. + :type deployment_name: str + :param parameters: Additional parameters supplied to the operation. Is either a model type or a + IO type. Required. + :type parameters: ~azure.mgmt.resource.resources.v2019_07_01.models.Deployment or IO + :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. + Default value is None. + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be ARMPolling. Pass in False for this + operation to not poll, or pass in your own initialized polling object for a personal polling + strategy. + :paramtype polling: bool or ~azure.core.polling.PollingMethod + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of LROPoller that returns either DeploymentExtended or the result of + cls(response) + :rtype: + ~azure.core.polling.LROPoller[~azure.mgmt.resource.resources.v2019_07_01.models.DeploymentExtended] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _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", "2019-07-01")) # type: str + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.DeploymentExtended] + polling = kwargs.pop("polling", True) # type: Union[bool, PollingMethod] + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token = kwargs.pop("continuation_token", None) # type: Optional[str] if cont_token is None: - raw_result = self._create_or_update_at_scope_initial( + raw_result = self._create_or_update_at_scope_initial( # type: ignore scope=scope, deployment_name=deployment_name, parameters=parameters, api_version=api_version, content_type=content_type, - cls=lambda x,y,z: x, + cls=lambda x, y, z: x, + headers=_headers, + params=_params, **kwargs ) - kwargs.pop('error_map', None) + kwargs.pop("error_map", None) def get_long_running_output(pipeline_response): - response = pipeline_response.http_response - deserialized = self._deserialize('DeploymentExtended', pipeline_response) + deserialized = self._deserialize("DeploymentExtended", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - - if polling is True: polling_method = ARMPolling(lro_delay, **kwargs) - elif polling is False: polling_method = NoPolling() - else: polling_method = polling + if polling is True: + polling_method = cast(PollingMethod, ARMPolling(lro_delay, **kwargs)) # type: PollingMethod + elif polling is False: + polling_method = cast(PollingMethod, NoPolling()) + else: + polling_method = polling if cont_token: return LROPoller.from_continuation_token( polling_method=polling_method, continuation_token=cont_token, client=self._client, - deserialization_callback=get_long_running_output + deserialization_callback=get_long_running_output, ) return LROPoller(self._client, raw_result, get_long_running_output, polling_method) - begin_create_or_update_at_scope.metadata = {'url': "/{scope}/providers/Microsoft.Resources/deployments/{deploymentName}"} # type: ignore + begin_create_or_update_at_scope.metadata = {"url": "/{scope}/providers/Microsoft.Resources/deployments/{deploymentName}"} # type: ignore @distributed_trace - def get_at_scope( - self, - scope: str, - deployment_name: str, - **kwargs: Any - ) -> "_models.DeploymentExtended": + def get_at_scope(self, scope: str, deployment_name: str, **kwargs: Any) -> _models.DeploymentExtended: """Gets a deployment. - :param scope: The scope of a deployment. + :param scope: The scope of a deployment. Required. :type scope: str - :param deployment_name: The name of the deployment. + :param deployment_name: The name of the deployment. Required. :type deployment_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: DeploymentExtended, or the result of cls(response) + :return: DeploymentExtended or the result of cls(response) :rtype: ~azure.mgmt.resource.resources.v2019_07_01.models.DeploymentExtended - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.DeploymentExtended"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) - api_version = kwargs.pop('api_version', "2019-07-01") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2019-07-01")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[_models.DeploymentExtended] - request = build_deployments_get_at_scope_request( scope=scope, deployment_name=deployment_name, api_version=api_version, - template_url=self.get_at_scope.metadata['url'], + template_url=self.get_at_scope.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) - deserialized = self._deserialize('DeploymentExtended', pipeline_response) + deserialized = self._deserialize("DeploymentExtended", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - get_at_scope.metadata = {'url': "/{scope}/providers/Microsoft.Resources/deployments/{deploymentName}"} # type: ignore - + get_at_scope.metadata = {"url": "/{scope}/providers/Microsoft.Resources/deployments/{deploymentName}"} # type: ignore @distributed_trace def cancel_at_scope( # pylint: disable=inconsistent-return-statements - self, - scope: str, - deployment_name: str, - **kwargs: Any + self, scope: str, deployment_name: str, **kwargs: Any ) -> None: """Cancels a currently running template deployment. @@ -3707,38 +3299,44 @@ def cancel_at_scope( # pylint: disable=inconsistent-return-statements deployment stops the currently running template deployment and leaves the resources partially deployed. - :param scope: The scope of a deployment. + :param scope: The scope of a deployment. Required. :type scope: str - :param deployment_name: The name of the deployment. + :param deployment_name: The name of the deployment. Required. :type deployment_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: None, or the result of cls(response) + :return: None or the result of cls(response) :rtype: None - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType[None] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + 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', "2019-07-01") # type: str + api_version = kwargs.pop("api_version", _params.pop("api-version", "2019-07-01")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[None] - request = build_deployments_cancel_at_scope_request( scope=scope, deployment_name=deployment_name, api_version=api_version, - template_url=self.cancel_at_scope.metadata['url'], + template_url=self.cancel_at_scope.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [204]: @@ -3748,41 +3346,101 @@ def cancel_at_scope( # pylint: disable=inconsistent-return-statements if cls: return cls(pipeline_response, None, {}) - cancel_at_scope.metadata = {'url': "/{scope}/providers/Microsoft.Resources/deployments/{deploymentName}/cancel"} # type: ignore - + cancel_at_scope.metadata = {"url": "/{scope}/providers/Microsoft.Resources/deployments/{deploymentName}/cancel"} # type: ignore - @distributed_trace + @overload def validate_at_scope( self, scope: str, deployment_name: str, - parameters: "_models.Deployment", + parameters: _models.Deployment, + *, + content_type: str = "application/json", **kwargs: Any - ) -> "_models.DeploymentValidateResult": + ) -> _models.DeploymentValidateResult: """Validates whether the specified template is syntactically correct and will be accepted by Azure Resource Manager.. - :param scope: The scope of a deployment. + :param scope: The scope of a deployment. Required. :type scope: str - :param deployment_name: The name of the deployment. + :param deployment_name: The name of the deployment. Required. :type deployment_name: str - :param parameters: Parameters to validate. + :param parameters: Parameters to validate. Required. :type parameters: ~azure.mgmt.resource.resources.v2019_07_01.models.Deployment + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: DeploymentValidateResult or the result of cls(response) + :rtype: ~azure.mgmt.resource.resources.v2019_07_01.models.DeploymentValidateResult + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + def validate_at_scope( + self, scope: str, deployment_name: str, parameters: IO, *, content_type: str = "application/json", **kwargs: Any + ) -> _models.DeploymentValidateResult: + """Validates whether the specified template is syntactically correct and will be accepted by Azure + Resource Manager.. + + :param scope: The scope of a deployment. Required. + :type scope: str + :param deployment_name: The name of the deployment. Required. + :type deployment_name: str + :param parameters: Parameters to validate. Required. + :type parameters: IO + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: DeploymentValidateResult or the result of cls(response) + :rtype: ~azure.mgmt.resource.resources.v2019_07_01.models.DeploymentValidateResult + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace + def validate_at_scope( + self, scope: str, deployment_name: str, parameters: Union[_models.Deployment, IO], **kwargs: Any + ) -> _models.DeploymentValidateResult: + """Validates whether the specified template is syntactically correct and will be accepted by Azure + Resource Manager.. + + :param scope: The scope of a deployment. Required. + :type scope: str + :param deployment_name: The name of the deployment. Required. + :type deployment_name: str + :param parameters: Parameters to validate. Is either a model type or a IO type. Required. + :type parameters: ~azure.mgmt.resource.resources.v2019_07_01.models.Deployment or IO + :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. + Default value is None. + :paramtype content_type: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: DeploymentValidateResult, or the result of cls(response) + :return: DeploymentValidateResult or the result of cls(response) :rtype: ~azure.mgmt.resource.resources.v2019_07_01.models.DeploymentValidateResult - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.DeploymentValidateResult"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', "2019-07-01") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + api_version = kwargs.pop("api_version", _params.pop("api-version", "2019-07-01")) # type: str + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.DeploymentValidateResult] - _json = self._serialize.body(parameters, 'Deployment') + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(parameters, (IO, bytes)): + _content = parameters + else: + _json = self._serialize.body(parameters, "Deployment") request = build_deployments_validate_at_scope_request( scope=scope, @@ -3790,16 +3448,18 @@ def validate_at_scope( api_version=api_version, content_type=content_type, json=_json, - template_url=self.validate_at_scope.metadata['url'], + content=_content, + template_url=self.validate_at_scope.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200, 400]: @@ -3807,87 +3467,84 @@ def validate_at_scope( raise HttpResponseError(response=response, error_format=ARMErrorFormat) if response.status_code == 200: - deserialized = self._deserialize('DeploymentValidateResult', pipeline_response) + deserialized = self._deserialize("DeploymentValidateResult", pipeline_response) if response.status_code == 400: - deserialized = self._deserialize('DeploymentValidateResult', pipeline_response) + deserialized = self._deserialize("DeploymentValidateResult", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - validate_at_scope.metadata = {'url': "/{scope}/providers/Microsoft.Resources/deployments/{deploymentName}/validate"} # type: ignore - + validate_at_scope.metadata = {"url": "/{scope}/providers/Microsoft.Resources/deployments/{deploymentName}/validate"} # type: ignore @distributed_trace def export_template_at_scope( - self, - scope: str, - deployment_name: str, - **kwargs: Any - ) -> "_models.DeploymentExportResult": + self, scope: str, deployment_name: str, **kwargs: Any + ) -> _models.DeploymentExportResult: """Exports the template used for specified deployment. - :param scope: The scope of a deployment. + :param scope: The scope of a deployment. Required. :type scope: str - :param deployment_name: The name of the deployment. + :param deployment_name: The name of the deployment. Required. :type deployment_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: DeploymentExportResult, or the result of cls(response) + :return: DeploymentExportResult or the result of cls(response) :rtype: ~azure.mgmt.resource.resources.v2019_07_01.models.DeploymentExportResult - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.DeploymentExportResult"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) - api_version = kwargs.pop('api_version', "2019-07-01") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2019-07-01")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[_models.DeploymentExportResult] - request = build_deployments_export_template_at_scope_request( scope=scope, deployment_name=deployment_name, api_version=api_version, - template_url=self.export_template_at_scope.metadata['url'], + template_url=self.export_template_at_scope.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) - deserialized = self._deserialize('DeploymentExportResult', pipeline_response) + deserialized = self._deserialize("DeploymentExportResult", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - export_template_at_scope.metadata = {'url': "/{scope}/providers/Microsoft.Resources/deployments/{deploymentName}/exportTemplate"} # type: ignore - + export_template_at_scope.metadata = {"url": "/{scope}/providers/Microsoft.Resources/deployments/{deploymentName}/exportTemplate"} # type: ignore @distributed_trace def list_at_scope( - self, - scope: str, - filter: Optional[str] = None, - top: Optional[int] = None, - **kwargs: Any - ) -> Iterable["_models.DeploymentListResult"]: + self, scope: str, filter: Optional[str] = None, top: Optional[int] = None, **kwargs: Any + ) -> Iterable["_models.DeploymentExtended"]: """Get all the deployments at the given scope. - :param scope: The scope of a deployment. + :param scope: The scope of a deployment. Required. :type scope: str :param filter: The filter to apply on the operation. For example, you can use $filter=provisioningState eq '{state}'. Default value is None. @@ -3896,40 +3553,48 @@ def list_at_scope( value is None. :type top: int :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either DeploymentListResult or the result of - cls(response) + :return: An iterator like instance of either DeploymentExtended or the result of cls(response) :rtype: - ~azure.core.paging.ItemPaged[~azure.mgmt.resource.resources.v2019_07_01.models.DeploymentListResult] - :raises: ~azure.core.exceptions.HttpResponseError + ~azure.core.paging.ItemPaged[~azure.mgmt.resource.resources.v2019_07_01.models.DeploymentExtended] + :raises ~azure.core.exceptions.HttpResponseError: """ - api_version = kwargs.pop('api_version', "2019-07-01") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2019-07-01")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[_models.DeploymentListResult] - cls = kwargs.pop('cls', None) # type: ClsType["_models.DeploymentListResult"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) + def prepare_request(next_link=None): if not next_link: - + request = build_deployments_list_at_scope_request( scope=scope, - api_version=api_version, filter=filter, top=top, - template_url=self.list_at_scope.metadata['url'], + api_version=api_version, + template_url=self.list_at_scope.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore else: - - request = build_deployments_list_at_scope_request( - scope=scope, - template_url=next_link, - ) + # make call to next link with the client's api-version + _parsed_next_link = urlparse(next_link) + _next_request_params = case_insensitive_dict(parse_qs(_parsed_next_link.query)) + _next_request_params["api-version"] = self._config.api_version + request = HttpRequest("GET", urljoin(next_link, _parsed_next_link.path), params=_next_request_params) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore request.method = "GET" return request @@ -3943,10 +3608,8 @@ def extract_data(pipeline_response): def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) response = pipeline_response.http_response @@ -3956,39 +3619,41 @@ def get_next(next_link=None): return pipeline_response + return ItemPaged(get_next, extract_data) - return ItemPaged( - get_next, extract_data - ) - list_at_scope.metadata = {'url': "/{scope}/providers/Microsoft.Resources/deployments/"} # type: ignore + list_at_scope.metadata = {"url": "/{scope}/providers/Microsoft.Resources/deployments/"} # type: ignore def _delete_at_tenant_scope_initial( # pylint: disable=inconsistent-return-statements - self, - deployment_name: str, - **kwargs: Any + self, deployment_name: str, **kwargs: Any ) -> None: - cls = kwargs.pop('cls', None) # type: ClsType[None] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) - api_version = kwargs.pop('api_version', "2019-07-01") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - request = build_deployments_delete_at_tenant_scope_request_initial( + api_version = kwargs.pop("api_version", _params.pop("api-version", "2019-07-01")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[None] + + request = build_deployments_delete_at_tenant_scope_request( deployment_name=deployment_name, api_version=api_version, - template_url=self._delete_at_tenant_scope_initial.metadata['url'], + template_url=self._delete_at_tenant_scope_initial.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [202, 204]: @@ -3998,15 +3663,10 @@ def _delete_at_tenant_scope_initial( # pylint: disable=inconsistent-return-stat if cls: return cls(pipeline_response, None, {}) - _delete_at_tenant_scope_initial.metadata = {'url': "/providers/Microsoft.Resources/deployments/{deploymentName}"} # type: ignore - + _delete_at_tenant_scope_initial.metadata = {"url": "/providers/Microsoft.Resources/deployments/{deploymentName}"} # type: ignore @distributed_trace - def begin_delete_at_tenant_scope( # pylint: disable=inconsistent-return-statements - self, - deployment_name: str, - **kwargs: Any - ) -> LROPoller[None]: + def begin_delete_at_tenant_scope(self, deployment_name: str, **kwargs: Any) -> LROPoller[None]: """Deletes a deployment from the deployment history. A template deployment that is currently running cannot be deleted. Deleting a template @@ -4017,7 +3677,7 @@ def begin_delete_at_tenant_scope( # pylint: disable=inconsistent-return-stateme process finishes, the URI in the Location header returns a status of 204 on success. If the asynchronous request failed, the URI in the Location header returns an error-level status code. - :param deployment_name: The name of the deployment. + :param deployment_name: The name of the deployment. Required. :type deployment_name: str :keyword callable cls: A custom type or function that will be passed the direct response :keyword str continuation_token: A continuation token to restart a poller from a saved state. @@ -4029,81 +3689,87 @@ def begin_delete_at_tenant_scope( # pylint: disable=inconsistent-return-stateme Retry-After header is present. :return: An instance of LROPoller that returns either None or the result of cls(response) :rtype: ~azure.core.polling.LROPoller[None] - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - api_version = kwargs.pop('api_version', "2019-07-01") # type: str - polling = kwargs.pop('polling', True) # type: Union[bool, PollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType[None] - lro_delay = kwargs.pop( - 'polling_interval', - self._config.polling_interval - ) - cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2019-07-01")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[None] + polling = kwargs.pop("polling", True) # type: Union[bool, PollingMethod] + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token = kwargs.pop("continuation_token", None) # type: Optional[str] if cont_token is None: - raw_result = self._delete_at_tenant_scope_initial( + raw_result = self._delete_at_tenant_scope_initial( # type: ignore deployment_name=deployment_name, api_version=api_version, - cls=lambda x,y,z: x, + cls=lambda x, y, z: x, + headers=_headers, + params=_params, **kwargs ) - kwargs.pop('error_map', None) + kwargs.pop("error_map", None) - def get_long_running_output(pipeline_response): + def get_long_running_output(pipeline_response): # pylint: disable=inconsistent-return-statements if cls: return cls(pipeline_response, None, {}) - - if polling is True: polling_method = ARMPolling(lro_delay, **kwargs) - elif polling is False: polling_method = NoPolling() - else: polling_method = polling + if polling is True: + polling_method = cast(PollingMethod, ARMPolling(lro_delay, **kwargs)) # type: PollingMethod + elif polling is False: + polling_method = cast(PollingMethod, NoPolling()) + else: + polling_method = polling if cont_token: return LROPoller.from_continuation_token( polling_method=polling_method, continuation_token=cont_token, client=self._client, - deserialization_callback=get_long_running_output + deserialization_callback=get_long_running_output, ) return LROPoller(self._client, raw_result, get_long_running_output, polling_method) - begin_delete_at_tenant_scope.metadata = {'url': "/providers/Microsoft.Resources/deployments/{deploymentName}"} # type: ignore + begin_delete_at_tenant_scope.metadata = {"url": "/providers/Microsoft.Resources/deployments/{deploymentName}"} # type: ignore @distributed_trace - def check_existence_at_tenant_scope( - self, - deployment_name: str, - **kwargs: Any - ) -> bool: + def check_existence_at_tenant_scope(self, deployment_name: str, **kwargs: Any) -> bool: """Checks whether the deployment exists. - :param deployment_name: The name of the deployment. + :param deployment_name: The name of the deployment. Required. :type deployment_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: bool, or the result of cls(response) + :return: bool or the result of cls(response) :rtype: bool - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType[None] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) - api_version = kwargs.pop('api_version', "2019-07-01") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2019-07-01")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[None] - request = build_deployments_check_existence_at_tenant_scope_request( deployment_name=deployment_name, api_version=api_version, - template_url=self.check_existence_at_tenant_scope.metadata['url'], + template_url=self.check_existence_at_tenant_scope.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [204, 404]: @@ -4114,41 +3780,51 @@ def check_existence_at_tenant_scope( return cls(pipeline_response, None, {}) return 200 <= response.status_code <= 299 - check_existence_at_tenant_scope.metadata = {'url': "/providers/Microsoft.Resources/deployments/{deploymentName}"} # type: ignore - + check_existence_at_tenant_scope.metadata = {"url": "/providers/Microsoft.Resources/deployments/{deploymentName}"} # type: ignore def _create_or_update_at_tenant_scope_initial( - self, - deployment_name: str, - parameters: "_models.Deployment", - **kwargs: Any - ) -> "_models.DeploymentExtended": - cls = kwargs.pop('cls', None) # type: ClsType["_models.DeploymentExtended"] + self, deployment_name: str, parameters: Union[_models.Deployment, IO], **kwargs: Any + ) -> _models.DeploymentExtended: error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) - api_version = kwargs.pop('api_version', "2019-07-01") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - _json = self._serialize.body(parameters, 'Deployment') + api_version = kwargs.pop("api_version", _params.pop("api-version", "2019-07-01")) # type: str + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.DeploymentExtended] - request = build_deployments_create_or_update_at_tenant_scope_request_initial( + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(parameters, (IO, bytes)): + _content = parameters + else: + _json = self._serialize.body(parameters, "Deployment") + + request = build_deployments_create_or_update_at_tenant_scope_request( deployment_name=deployment_name, api_version=api_version, content_type=content_type, json=_json, - template_url=self._create_or_update_at_tenant_scope_initial.metadata['url'], + content=_content, + template_url=self._create_or_update_at_tenant_scope_initial.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200, 201]: @@ -4156,34 +3832,38 @@ def _create_or_update_at_tenant_scope_initial( raise HttpResponseError(response=response, error_format=ARMErrorFormat) if response.status_code == 200: - deserialized = self._deserialize('DeploymentExtended', pipeline_response) + deserialized = self._deserialize("DeploymentExtended", pipeline_response) if response.status_code == 201: - deserialized = self._deserialize('DeploymentExtended', pipeline_response) + deserialized = self._deserialize("DeploymentExtended", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - _create_or_update_at_tenant_scope_initial.metadata = {'url': "/providers/Microsoft.Resources/deployments/{deploymentName}"} # type: ignore + _create_or_update_at_tenant_scope_initial.metadata = {"url": "/providers/Microsoft.Resources/deployments/{deploymentName}"} # type: ignore - - @distributed_trace + @overload def begin_create_or_update_at_tenant_scope( self, deployment_name: str, - parameters: "_models.Deployment", + parameters: _models.Deployment, + *, + content_type: str = "application/json", **kwargs: Any - ) -> LROPoller["_models.DeploymentExtended"]: + ) -> LROPoller[_models.DeploymentExtended]: """Deploys resources at tenant scope. You can provide the template and parameters directly in the request or link to JSON files. - :param deployment_name: The name of the deployment. + :param deployment_name: The name of the deployment. Required. :type deployment_name: str - :param parameters: Additional parameters supplied to the operation. + :param parameters: Additional parameters supplied to the operation. Required. :type parameters: ~azure.mgmt.resource.resources.v2019_07_01.models.Deployment + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str :keyword callable cls: A custom type or function that will be passed the direct response :keyword str continuation_token: A continuation token to restart a poller from a saved state. :keyword polling: By default, your polling method will be ARMPolling. Pass in False for this @@ -4196,108 +3876,171 @@ def begin_create_or_update_at_tenant_scope( cls(response) :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.resource.resources.v2019_07_01.models.DeploymentExtended] - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - api_version = kwargs.pop('api_version', "2019-07-01") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] - polling = kwargs.pop('polling', True) # type: Union[bool, PollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType["_models.DeploymentExtended"] - lro_delay = kwargs.pop( - 'polling_interval', - self._config.polling_interval - ) - cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] + + @overload + def begin_create_or_update_at_tenant_scope( + self, deployment_name: str, parameters: IO, *, content_type: str = "application/json", **kwargs: Any + ) -> LROPoller[_models.DeploymentExtended]: + """Deploys resources at tenant scope. + + You can provide the template and parameters directly in the request or link to JSON files. + + :param deployment_name: The name of the deployment. Required. + :type deployment_name: str + :param parameters: Additional parameters supplied to the operation. Required. + :type parameters: IO + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be ARMPolling. Pass in False for this + operation to not poll, or pass in your own initialized polling object for a personal polling + strategy. + :paramtype polling: bool or ~azure.core.polling.PollingMethod + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of LROPoller that returns either DeploymentExtended or the result of + cls(response) + :rtype: + ~azure.core.polling.LROPoller[~azure.mgmt.resource.resources.v2019_07_01.models.DeploymentExtended] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace + def begin_create_or_update_at_tenant_scope( + self, deployment_name: str, parameters: Union[_models.Deployment, IO], **kwargs: Any + ) -> LROPoller[_models.DeploymentExtended]: + """Deploys resources at tenant scope. + + You can provide the template and parameters directly in the request or link to JSON files. + + :param deployment_name: The name of the deployment. Required. + :type deployment_name: str + :param parameters: Additional parameters supplied to the operation. Is either a model type or a + IO type. Required. + :type parameters: ~azure.mgmt.resource.resources.v2019_07_01.models.Deployment or IO + :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. + Default value is None. + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be ARMPolling. Pass in False for this + operation to not poll, or pass in your own initialized polling object for a personal polling + strategy. + :paramtype polling: bool or ~azure.core.polling.PollingMethod + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of LROPoller that returns either DeploymentExtended or the result of + cls(response) + :rtype: + ~azure.core.polling.LROPoller[~azure.mgmt.resource.resources.v2019_07_01.models.DeploymentExtended] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _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", "2019-07-01")) # type: str + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.DeploymentExtended] + polling = kwargs.pop("polling", True) # type: Union[bool, PollingMethod] + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token = kwargs.pop("continuation_token", None) # type: Optional[str] if cont_token is None: - raw_result = self._create_or_update_at_tenant_scope_initial( + raw_result = self._create_or_update_at_tenant_scope_initial( # type: ignore deployment_name=deployment_name, parameters=parameters, api_version=api_version, content_type=content_type, - cls=lambda x,y,z: x, + cls=lambda x, y, z: x, + headers=_headers, + params=_params, **kwargs ) - kwargs.pop('error_map', None) + kwargs.pop("error_map", None) def get_long_running_output(pipeline_response): - response = pipeline_response.http_response - deserialized = self._deserialize('DeploymentExtended', pipeline_response) + deserialized = self._deserialize("DeploymentExtended", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - - if polling is True: polling_method = ARMPolling(lro_delay, **kwargs) - elif polling is False: polling_method = NoPolling() - else: polling_method = polling + if polling is True: + polling_method = cast(PollingMethod, ARMPolling(lro_delay, **kwargs)) # type: PollingMethod + elif polling is False: + polling_method = cast(PollingMethod, NoPolling()) + else: + polling_method = polling if cont_token: return LROPoller.from_continuation_token( polling_method=polling_method, continuation_token=cont_token, client=self._client, - deserialization_callback=get_long_running_output + deserialization_callback=get_long_running_output, ) return LROPoller(self._client, raw_result, get_long_running_output, polling_method) - begin_create_or_update_at_tenant_scope.metadata = {'url': "/providers/Microsoft.Resources/deployments/{deploymentName}"} # type: ignore + begin_create_or_update_at_tenant_scope.metadata = {"url": "/providers/Microsoft.Resources/deployments/{deploymentName}"} # type: ignore @distributed_trace - def get_at_tenant_scope( - self, - deployment_name: str, - **kwargs: Any - ) -> "_models.DeploymentExtended": + def get_at_tenant_scope(self, deployment_name: str, **kwargs: Any) -> _models.DeploymentExtended: """Gets a deployment. - :param deployment_name: The name of the deployment. + :param deployment_name: The name of the deployment. Required. :type deployment_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: DeploymentExtended, or the result of cls(response) + :return: DeploymentExtended or the result of cls(response) :rtype: ~azure.mgmt.resource.resources.v2019_07_01.models.DeploymentExtended - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.DeploymentExtended"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + 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', "2019-07-01") # type: str + api_version = kwargs.pop("api_version", _params.pop("api-version", "2019-07-01")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[_models.DeploymentExtended] - request = build_deployments_get_at_tenant_scope_request( deployment_name=deployment_name, api_version=api_version, - template_url=self.get_at_tenant_scope.metadata['url'], + template_url=self.get_at_tenant_scope.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) - deserialized = self._deserialize('DeploymentExtended', pipeline_response) + deserialized = self._deserialize("DeploymentExtended", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - get_at_tenant_scope.metadata = {'url': "/providers/Microsoft.Resources/deployments/{deploymentName}"} # type: ignore - + get_at_tenant_scope.metadata = {"url": "/providers/Microsoft.Resources/deployments/{deploymentName}"} # type: ignore @distributed_trace def cancel_at_tenant_scope( # pylint: disable=inconsistent-return-statements - self, - deployment_name: str, - **kwargs: Any + self, deployment_name: str, **kwargs: Any ) -> None: """Cancels a currently running template deployment. @@ -4306,35 +4049,41 @@ def cancel_at_tenant_scope( # pylint: disable=inconsistent-return-statements deployment stops the currently running template deployment and leaves the resources partially deployed. - :param deployment_name: The name of the deployment. + :param deployment_name: The name of the deployment. Required. :type deployment_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: None, or the result of cls(response) + :return: None or the result of cls(response) :rtype: None - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType[None] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + 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', "2019-07-01") # type: str + api_version = kwargs.pop("api_version", _params.pop("api-version", "2019-07-01")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[None] - request = build_deployments_cancel_at_tenant_scope_request( deployment_name=deployment_name, api_version=api_version, - template_url=self.cancel_at_tenant_scope.metadata['url'], + template_url=self.cancel_at_tenant_scope.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [204]: @@ -4344,54 +4093,112 @@ def cancel_at_tenant_scope( # pylint: disable=inconsistent-return-statements if cls: return cls(pipeline_response, None, {}) - cancel_at_tenant_scope.metadata = {'url': "/providers/Microsoft.Resources/deployments/{deploymentName}/cancel"} # type: ignore - + cancel_at_tenant_scope.metadata = {"url": "/providers/Microsoft.Resources/deployments/{deploymentName}/cancel"} # type: ignore - @distributed_trace + @overload def validate_at_tenant_scope( self, deployment_name: str, - parameters: "_models.Deployment", + parameters: _models.Deployment, + *, + content_type: str = "application/json", **kwargs: Any - ) -> "_models.DeploymentValidateResult": + ) -> _models.DeploymentValidateResult: """Validates whether the specified template is syntactically correct and will be accepted by Azure Resource Manager.. - :param deployment_name: The name of the deployment. + :param deployment_name: The name of the deployment. Required. :type deployment_name: str - :param parameters: Parameters to validate. + :param parameters: Parameters to validate. Required. :type parameters: ~azure.mgmt.resource.resources.v2019_07_01.models.Deployment + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: DeploymentValidateResult or the result of cls(response) + :rtype: ~azure.mgmt.resource.resources.v2019_07_01.models.DeploymentValidateResult + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + def validate_at_tenant_scope( + self, deployment_name: str, parameters: IO, *, content_type: str = "application/json", **kwargs: Any + ) -> _models.DeploymentValidateResult: + """Validates whether the specified template is syntactically correct and will be accepted by Azure + Resource Manager.. + + :param deployment_name: The name of the deployment. Required. + :type deployment_name: str + :param parameters: Parameters to validate. Required. + :type parameters: IO + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: DeploymentValidateResult, or the result of cls(response) + :return: DeploymentValidateResult or the result of cls(response) :rtype: ~azure.mgmt.resource.resources.v2019_07_01.models.DeploymentValidateResult - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace + def validate_at_tenant_scope( + self, deployment_name: str, parameters: Union[_models.Deployment, IO], **kwargs: Any + ) -> _models.DeploymentValidateResult: + """Validates whether the specified template is syntactically correct and will be accepted by Azure + Resource Manager.. + + :param deployment_name: The name of the deployment. Required. + :type deployment_name: str + :param parameters: Parameters to validate. Is either a model type or a IO type. Required. + :type parameters: ~azure.mgmt.resource.resources.v2019_07_01.models.Deployment or IO + :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. + Default value is None. + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: DeploymentValidateResult or the result of cls(response) + :rtype: ~azure.mgmt.resource.resources.v2019_07_01.models.DeploymentValidateResult + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.DeploymentValidateResult"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', "2019-07-01") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + api_version = kwargs.pop("api_version", _params.pop("api-version", "2019-07-01")) # type: str + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.DeploymentValidateResult] - _json = self._serialize.body(parameters, 'Deployment') + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(parameters, (IO, bytes)): + _content = parameters + else: + _json = self._serialize.body(parameters, "Deployment") request = build_deployments_validate_at_tenant_scope_request( deployment_name=deployment_name, api_version=api_version, content_type=content_type, json=_json, - template_url=self.validate_at_tenant_scope.metadata['url'], + content=_content, + template_url=self.validate_at_tenant_scope.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200, 400]: @@ -4399,79 +4206,76 @@ def validate_at_tenant_scope( raise HttpResponseError(response=response, error_format=ARMErrorFormat) if response.status_code == 200: - deserialized = self._deserialize('DeploymentValidateResult', pipeline_response) + deserialized = self._deserialize("DeploymentValidateResult", pipeline_response) if response.status_code == 400: - deserialized = self._deserialize('DeploymentValidateResult', pipeline_response) + deserialized = self._deserialize("DeploymentValidateResult", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - validate_at_tenant_scope.metadata = {'url': "/providers/Microsoft.Resources/deployments/{deploymentName}/validate"} # type: ignore - + validate_at_tenant_scope.metadata = {"url": "/providers/Microsoft.Resources/deployments/{deploymentName}/validate"} # type: ignore @distributed_trace - def export_template_at_tenant_scope( - self, - deployment_name: str, - **kwargs: Any - ) -> "_models.DeploymentExportResult": + def export_template_at_tenant_scope(self, deployment_name: str, **kwargs: Any) -> _models.DeploymentExportResult: """Exports the template used for specified deployment. - :param deployment_name: The name of the deployment. + :param deployment_name: The name of the deployment. Required. :type deployment_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: DeploymentExportResult, or the result of cls(response) + :return: DeploymentExportResult or the result of cls(response) :rtype: ~azure.mgmt.resource.resources.v2019_07_01.models.DeploymentExportResult - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.DeploymentExportResult"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + 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', "2019-07-01") # type: str + api_version = kwargs.pop("api_version", _params.pop("api-version", "2019-07-01")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[_models.DeploymentExportResult] - request = build_deployments_export_template_at_tenant_scope_request( deployment_name=deployment_name, api_version=api_version, - template_url=self.export_template_at_tenant_scope.metadata['url'], + template_url=self.export_template_at_tenant_scope.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) - deserialized = self._deserialize('DeploymentExportResult', pipeline_response) + deserialized = self._deserialize("DeploymentExportResult", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - export_template_at_tenant_scope.metadata = {'url': "/providers/Microsoft.Resources/deployments/{deploymentName}/exportTemplate"} # type: ignore - + export_template_at_tenant_scope.metadata = {"url": "/providers/Microsoft.Resources/deployments/{deploymentName}/exportTemplate"} # type: ignore @distributed_trace def list_at_tenant_scope( - self, - filter: Optional[str] = None, - top: Optional[int] = None, - **kwargs: Any - ) -> Iterable["_models.DeploymentListResult"]: + self, filter: Optional[str] = None, top: Optional[int] = None, **kwargs: Any + ) -> Iterable["_models.DeploymentExtended"]: """Get all the deployments at the tenant scope. :param filter: The filter to apply on the operation. For example, you can use @@ -4481,38 +4285,47 @@ def list_at_tenant_scope( value is None. :type top: int :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either DeploymentListResult or the result of - cls(response) + :return: An iterator like instance of either DeploymentExtended or the result of cls(response) :rtype: - ~azure.core.paging.ItemPaged[~azure.mgmt.resource.resources.v2019_07_01.models.DeploymentListResult] - :raises: ~azure.core.exceptions.HttpResponseError + ~azure.core.paging.ItemPaged[~azure.mgmt.resource.resources.v2019_07_01.models.DeploymentExtended] + :raises ~azure.core.exceptions.HttpResponseError: """ - api_version = kwargs.pop('api_version', "2019-07-01") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2019-07-01")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[_models.DeploymentListResult] - cls = kwargs.pop('cls', None) # type: ClsType["_models.DeploymentListResult"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) + def prepare_request(next_link=None): if not next_link: - + request = build_deployments_list_at_tenant_scope_request( - api_version=api_version, filter=filter, top=top, - template_url=self.list_at_tenant_scope.metadata['url'], + api_version=api_version, + template_url=self.list_at_tenant_scope.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore else: - - request = build_deployments_list_at_tenant_scope_request( - template_url=next_link, - ) + # make call to next link with the client's api-version + _parsed_next_link = urlparse(next_link) + _next_request_params = case_insensitive_dict(parse_qs(_parsed_next_link.query)) + _next_request_params["api-version"] = self._config.api_version + request = HttpRequest("GET", urljoin(next_link, _parsed_next_link.path), params=_next_request_params) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore request.method = "GET" return request @@ -4526,10 +4339,8 @@ def extract_data(pipeline_response): def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) response = pipeline_response.http_response @@ -4539,41 +4350,42 @@ def get_next(next_link=None): return pipeline_response + return ItemPaged(get_next, extract_data) - return ItemPaged( - get_next, extract_data - ) - list_at_tenant_scope.metadata = {'url': "/providers/Microsoft.Resources/deployments/"} # type: ignore + list_at_tenant_scope.metadata = {"url": "/providers/Microsoft.Resources/deployments/"} # type: ignore def _delete_at_management_group_scope_initial( # pylint: disable=inconsistent-return-statements - self, - group_id: str, - deployment_name: str, - **kwargs: Any + self, group_id: str, deployment_name: str, **kwargs: Any ) -> None: - cls = kwargs.pop('cls', None) # type: ClsType[None] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) - api_version = kwargs.pop('api_version', "2019-07-01") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - request = build_deployments_delete_at_management_group_scope_request_initial( + api_version = kwargs.pop("api_version", _params.pop("api-version", "2019-07-01")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[None] + + request = build_deployments_delete_at_management_group_scope_request( group_id=group_id, deployment_name=deployment_name, api_version=api_version, - template_url=self._delete_at_management_group_scope_initial.metadata['url'], + template_url=self._delete_at_management_group_scope_initial.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [202, 204]: @@ -4583,15 +4395,11 @@ def _delete_at_management_group_scope_initial( # pylint: disable=inconsistent-r if cls: return cls(pipeline_response, None, {}) - _delete_at_management_group_scope_initial.metadata = {'url': "/providers/Microsoft.Management/managementGroups/{groupId}/providers/Microsoft.Resources/deployments/{deploymentName}"} # type: ignore - + _delete_at_management_group_scope_initial.metadata = {"url": "/providers/Microsoft.Management/managementGroups/{groupId}/providers/Microsoft.Resources/deployments/{deploymentName}"} # type: ignore @distributed_trace - def begin_delete_at_management_group_scope( # pylint: disable=inconsistent-return-statements - self, - group_id: str, - deployment_name: str, - **kwargs: Any + def begin_delete_at_management_group_scope( + self, group_id: str, deployment_name: str, **kwargs: Any ) -> LROPoller[None]: """Deletes a deployment from the deployment history. @@ -4603,9 +4411,9 @@ def begin_delete_at_management_group_scope( # pylint: disable=inconsistent-retu process finishes, the URI in the Location header returns a status of 204 on success. If the asynchronous request failed, the URI in the Location header returns an error-level status code. - :param group_id: The management group ID. + :param group_id: The management group ID. Required. :type group_id: str - :param deployment_name: The name of the deployment. + :param deployment_name: The name of the deployment. Required. :type deployment_name: str :keyword callable cls: A custom type or function that will be passed the direct response :keyword str continuation_token: A continuation token to restart a poller from a saved state. @@ -4617,86 +4425,91 @@ def begin_delete_at_management_group_scope( # pylint: disable=inconsistent-retu Retry-After header is present. :return: An instance of LROPoller that returns either None or the result of cls(response) :rtype: ~azure.core.polling.LROPoller[None] - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - api_version = kwargs.pop('api_version', "2019-07-01") # type: str - polling = kwargs.pop('polling', True) # type: Union[bool, PollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType[None] - lro_delay = kwargs.pop( - 'polling_interval', - self._config.polling_interval - ) - cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2019-07-01")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[None] + polling = kwargs.pop("polling", True) # type: Union[bool, PollingMethod] + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token = kwargs.pop("continuation_token", None) # type: Optional[str] if cont_token is None: - raw_result = self._delete_at_management_group_scope_initial( + raw_result = self._delete_at_management_group_scope_initial( # type: ignore group_id=group_id, deployment_name=deployment_name, api_version=api_version, - cls=lambda x,y,z: x, + cls=lambda x, y, z: x, + headers=_headers, + params=_params, **kwargs ) - kwargs.pop('error_map', None) + kwargs.pop("error_map", None) - def get_long_running_output(pipeline_response): + def get_long_running_output(pipeline_response): # pylint: disable=inconsistent-return-statements if cls: return cls(pipeline_response, None, {}) - - if polling is True: polling_method = ARMPolling(lro_delay, **kwargs) - elif polling is False: polling_method = NoPolling() - else: polling_method = polling + if polling is True: + polling_method = cast(PollingMethod, ARMPolling(lro_delay, **kwargs)) # type: PollingMethod + elif polling is False: + polling_method = cast(PollingMethod, NoPolling()) + else: + polling_method = polling if cont_token: return LROPoller.from_continuation_token( polling_method=polling_method, continuation_token=cont_token, client=self._client, - deserialization_callback=get_long_running_output + deserialization_callback=get_long_running_output, ) return LROPoller(self._client, raw_result, get_long_running_output, polling_method) - begin_delete_at_management_group_scope.metadata = {'url': "/providers/Microsoft.Management/managementGroups/{groupId}/providers/Microsoft.Resources/deployments/{deploymentName}"} # type: ignore + begin_delete_at_management_group_scope.metadata = {"url": "/providers/Microsoft.Management/managementGroups/{groupId}/providers/Microsoft.Resources/deployments/{deploymentName}"} # type: ignore @distributed_trace - def check_existence_at_management_group_scope( - self, - group_id: str, - deployment_name: str, - **kwargs: Any - ) -> bool: + def check_existence_at_management_group_scope(self, group_id: str, deployment_name: str, **kwargs: Any) -> bool: """Checks whether the deployment exists. - :param group_id: The management group ID. + :param group_id: The management group ID. Required. :type group_id: str - :param deployment_name: The name of the deployment. + :param deployment_name: The name of the deployment. Required. :type deployment_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: bool, or the result of cls(response) + :return: bool or the result of cls(response) :rtype: bool - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType[None] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + 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', "2019-07-01") # type: str + api_version = kwargs.pop("api_version", _params.pop("api-version", "2019-07-01")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[None] - request = build_deployments_check_existence_at_management_group_scope_request( group_id=group_id, deployment_name=deployment_name, api_version=api_version, - template_url=self.check_existence_at_management_group_scope.metadata['url'], + template_url=self.check_existence_at_management_group_scope.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [204, 404]: @@ -4707,43 +4520,52 @@ def check_existence_at_management_group_scope( return cls(pipeline_response, None, {}) return 200 <= response.status_code <= 299 - check_existence_at_management_group_scope.metadata = {'url': "/providers/Microsoft.Management/managementGroups/{groupId}/providers/Microsoft.Resources/deployments/{deploymentName}"} # type: ignore - + check_existence_at_management_group_scope.metadata = {"url": "/providers/Microsoft.Management/managementGroups/{groupId}/providers/Microsoft.Resources/deployments/{deploymentName}"} # type: ignore def _create_or_update_at_management_group_scope_initial( - self, - group_id: str, - deployment_name: str, - parameters: "_models.Deployment", - **kwargs: Any - ) -> "_models.DeploymentExtended": - cls = kwargs.pop('cls', None) # type: ClsType["_models.DeploymentExtended"] + self, group_id: str, deployment_name: str, parameters: Union[_models.Deployment, IO], **kwargs: Any + ) -> _models.DeploymentExtended: error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) - api_version = kwargs.pop('api_version', "2019-07-01") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - _json = self._serialize.body(parameters, 'Deployment') + api_version = kwargs.pop("api_version", _params.pop("api-version", "2019-07-01")) # type: str + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.DeploymentExtended] - request = build_deployments_create_or_update_at_management_group_scope_request_initial( + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(parameters, (IO, bytes)): + _content = parameters + else: + _json = self._serialize.body(parameters, "Deployment") + + request = build_deployments_create_or_update_at_management_group_scope_request( group_id=group_id, deployment_name=deployment_name, api_version=api_version, content_type=content_type, json=_json, - template_url=self._create_or_update_at_management_group_scope_initial.metadata['url'], + content=_content, + template_url=self._create_or_update_at_management_group_scope_initial.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200, 201]: @@ -4751,37 +4573,41 @@ def _create_or_update_at_management_group_scope_initial( raise HttpResponseError(response=response, error_format=ARMErrorFormat) if response.status_code == 200: - deserialized = self._deserialize('DeploymentExtended', pipeline_response) + deserialized = self._deserialize("DeploymentExtended", pipeline_response) if response.status_code == 201: - deserialized = self._deserialize('DeploymentExtended', pipeline_response) + deserialized = self._deserialize("DeploymentExtended", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - _create_or_update_at_management_group_scope_initial.metadata = {'url': "/providers/Microsoft.Management/managementGroups/{groupId}/providers/Microsoft.Resources/deployments/{deploymentName}"} # type: ignore + _create_or_update_at_management_group_scope_initial.metadata = {"url": "/providers/Microsoft.Management/managementGroups/{groupId}/providers/Microsoft.Resources/deployments/{deploymentName}"} # type: ignore - - @distributed_trace + @overload def begin_create_or_update_at_management_group_scope( self, group_id: str, deployment_name: str, - parameters: "_models.Deployment", + parameters: _models.Deployment, + *, + content_type: str = "application/json", **kwargs: Any - ) -> LROPoller["_models.DeploymentExtended"]: + ) -> LROPoller[_models.DeploymentExtended]: """Deploys resources at management group scope. You can provide the template and parameters directly in the request or link to JSON files. - :param group_id: The management group ID. + :param group_id: The management group ID. Required. :type group_id: str - :param deployment_name: The name of the deployment. + :param deployment_name: The name of the deployment. Required. :type deployment_name: str - :param parameters: Additional parameters supplied to the operation. + :param parameters: Additional parameters supplied to the operation. Required. :type parameters: ~azure.mgmt.resource.resources.v2019_07_01.models.Deployment + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str :keyword callable cls: A custom type or function that will be passed the direct response :keyword str continuation_token: A continuation token to restart a poller from a saved state. :keyword polling: By default, your polling method will be ARMPolling. Pass in False for this @@ -4794,114 +4620,187 @@ def begin_create_or_update_at_management_group_scope( cls(response) :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.resource.resources.v2019_07_01.models.DeploymentExtended] - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - api_version = kwargs.pop('api_version', "2019-07-01") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] - polling = kwargs.pop('polling', True) # type: Union[bool, PollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType["_models.DeploymentExtended"] - lro_delay = kwargs.pop( - 'polling_interval', - self._config.polling_interval - ) - cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] + + @overload + def begin_create_or_update_at_management_group_scope( + self, + group_id: str, + deployment_name: str, + parameters: IO, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> LROPoller[_models.DeploymentExtended]: + """Deploys resources at management group scope. + + You can provide the template and parameters directly in the request or link to JSON files. + + :param group_id: The management group ID. Required. + :type group_id: str + :param deployment_name: The name of the deployment. Required. + :type deployment_name: str + :param parameters: Additional parameters supplied to the operation. Required. + :type parameters: IO + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be ARMPolling. Pass in False for this + operation to not poll, or pass in your own initialized polling object for a personal polling + strategy. + :paramtype polling: bool or ~azure.core.polling.PollingMethod + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of LROPoller that returns either DeploymentExtended or the result of + cls(response) + :rtype: + ~azure.core.polling.LROPoller[~azure.mgmt.resource.resources.v2019_07_01.models.DeploymentExtended] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace + def begin_create_or_update_at_management_group_scope( + self, group_id: str, deployment_name: str, parameters: Union[_models.Deployment, IO], **kwargs: Any + ) -> LROPoller[_models.DeploymentExtended]: + """Deploys resources at management group scope. + + You can provide the template and parameters directly in the request or link to JSON files. + + :param group_id: The management group ID. Required. + :type group_id: str + :param deployment_name: The name of the deployment. Required. + :type deployment_name: str + :param parameters: Additional parameters supplied to the operation. Is either a model type or a + IO type. Required. + :type parameters: ~azure.mgmt.resource.resources.v2019_07_01.models.Deployment or IO + :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. + Default value is None. + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be ARMPolling. Pass in False for this + operation to not poll, or pass in your own initialized polling object for a personal polling + strategy. + :paramtype polling: bool or ~azure.core.polling.PollingMethod + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of LROPoller that returns either DeploymentExtended or the result of + cls(response) + :rtype: + ~azure.core.polling.LROPoller[~azure.mgmt.resource.resources.v2019_07_01.models.DeploymentExtended] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _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", "2019-07-01")) # type: str + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.DeploymentExtended] + polling = kwargs.pop("polling", True) # type: Union[bool, PollingMethod] + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token = kwargs.pop("continuation_token", None) # type: Optional[str] if cont_token is None: - raw_result = self._create_or_update_at_management_group_scope_initial( + raw_result = self._create_or_update_at_management_group_scope_initial( # type: ignore group_id=group_id, deployment_name=deployment_name, parameters=parameters, api_version=api_version, content_type=content_type, - cls=lambda x,y,z: x, + cls=lambda x, y, z: x, + headers=_headers, + params=_params, **kwargs ) - kwargs.pop('error_map', None) + kwargs.pop("error_map", None) def get_long_running_output(pipeline_response): - response = pipeline_response.http_response - deserialized = self._deserialize('DeploymentExtended', pipeline_response) + deserialized = self._deserialize("DeploymentExtended", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - - if polling is True: polling_method = ARMPolling(lro_delay, **kwargs) - elif polling is False: polling_method = NoPolling() - else: polling_method = polling + if polling is True: + polling_method = cast(PollingMethod, ARMPolling(lro_delay, **kwargs)) # type: PollingMethod + elif polling is False: + polling_method = cast(PollingMethod, NoPolling()) + else: + polling_method = polling if cont_token: return LROPoller.from_continuation_token( polling_method=polling_method, continuation_token=cont_token, client=self._client, - deserialization_callback=get_long_running_output + deserialization_callback=get_long_running_output, ) return LROPoller(self._client, raw_result, get_long_running_output, polling_method) - begin_create_or_update_at_management_group_scope.metadata = {'url': "/providers/Microsoft.Management/managementGroups/{groupId}/providers/Microsoft.Resources/deployments/{deploymentName}"} # type: ignore + begin_create_or_update_at_management_group_scope.metadata = {"url": "/providers/Microsoft.Management/managementGroups/{groupId}/providers/Microsoft.Resources/deployments/{deploymentName}"} # type: ignore @distributed_trace def get_at_management_group_scope( - self, - group_id: str, - deployment_name: str, - **kwargs: Any - ) -> "_models.DeploymentExtended": + self, group_id: str, deployment_name: str, **kwargs: Any + ) -> _models.DeploymentExtended: """Gets a deployment. - :param group_id: The management group ID. + :param group_id: The management group ID. Required. :type group_id: str - :param deployment_name: The name of the deployment. + :param deployment_name: The name of the deployment. Required. :type deployment_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: DeploymentExtended, or the result of cls(response) + :return: DeploymentExtended or the result of cls(response) :rtype: ~azure.mgmt.resource.resources.v2019_07_01.models.DeploymentExtended - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.DeploymentExtended"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + 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', "2019-07-01") # type: str + api_version = kwargs.pop("api_version", _params.pop("api-version", "2019-07-01")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[_models.DeploymentExtended] - request = build_deployments_get_at_management_group_scope_request( group_id=group_id, deployment_name=deployment_name, api_version=api_version, - template_url=self.get_at_management_group_scope.metadata['url'], + template_url=self.get_at_management_group_scope.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) - deserialized = self._deserialize('DeploymentExtended', pipeline_response) + deserialized = self._deserialize("DeploymentExtended", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - get_at_management_group_scope.metadata = {'url': "/providers/Microsoft.Management/managementGroups/{groupId}/providers/Microsoft.Resources/deployments/{deploymentName}"} # type: ignore - + get_at_management_group_scope.metadata = {"url": "/providers/Microsoft.Management/managementGroups/{groupId}/providers/Microsoft.Resources/deployments/{deploymentName}"} # type: ignore @distributed_trace def cancel_at_management_group_scope( # pylint: disable=inconsistent-return-statements - self, - group_id: str, - deployment_name: str, - **kwargs: Any + self, group_id: str, deployment_name: str, **kwargs: Any ) -> None: """Cancels a currently running template deployment. @@ -4910,38 +4809,44 @@ def cancel_at_management_group_scope( # pylint: disable=inconsistent-return-sta deployment stops the currently running template deployment and leaves the resources partially deployed. - :param group_id: The management group ID. + :param group_id: The management group ID. Required. :type group_id: str - :param deployment_name: The name of the deployment. + :param deployment_name: The name of the deployment. Required. :type deployment_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: None, or the result of cls(response) + :return: None or the result of cls(response) :rtype: None - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType[None] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) - api_version = kwargs.pop('api_version', "2019-07-01") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2019-07-01")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[None] - request = build_deployments_cancel_at_management_group_scope_request( group_id=group_id, deployment_name=deployment_name, api_version=api_version, - template_url=self.cancel_at_management_group_scope.metadata['url'], + template_url=self.cancel_at_management_group_scope.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [204]: @@ -4951,41 +4856,107 @@ def cancel_at_management_group_scope( # pylint: disable=inconsistent-return-sta if cls: return cls(pipeline_response, None, {}) - cancel_at_management_group_scope.metadata = {'url': "/providers/Microsoft.Management/managementGroups/{groupId}/providers/Microsoft.Resources/deployments/{deploymentName}/cancel"} # type: ignore + cancel_at_management_group_scope.metadata = {"url": "/providers/Microsoft.Management/managementGroups/{groupId}/providers/Microsoft.Resources/deployments/{deploymentName}/cancel"} # type: ignore - - @distributed_trace + @overload def validate_at_management_group_scope( self, group_id: str, deployment_name: str, - parameters: "_models.Deployment", + parameters: _models.Deployment, + *, + content_type: str = "application/json", **kwargs: Any - ) -> "_models.DeploymentValidateResult": + ) -> _models.DeploymentValidateResult: """Validates whether the specified template is syntactically correct and will be accepted by Azure Resource Manager.. - :param group_id: The management group ID. + :param group_id: The management group ID. Required. :type group_id: str - :param deployment_name: The name of the deployment. + :param deployment_name: The name of the deployment. Required. :type deployment_name: str - :param parameters: Parameters to validate. + :param parameters: Parameters to validate. Required. :type parameters: ~azure.mgmt.resource.resources.v2019_07_01.models.Deployment + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: DeploymentValidateResult or the result of cls(response) + :rtype: ~azure.mgmt.resource.resources.v2019_07_01.models.DeploymentValidateResult + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + def validate_at_management_group_scope( + self, + group_id: str, + deployment_name: str, + parameters: IO, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.DeploymentValidateResult: + """Validates whether the specified template is syntactically correct and will be accepted by Azure + Resource Manager.. + + :param group_id: The management group ID. Required. + :type group_id: str + :param deployment_name: The name of the deployment. Required. + :type deployment_name: str + :param parameters: Parameters to validate. Required. + :type parameters: IO + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: DeploymentValidateResult, or the result of cls(response) + :return: DeploymentValidateResult or the result of cls(response) :rtype: ~azure.mgmt.resource.resources.v2019_07_01.models.DeploymentValidateResult - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace + def validate_at_management_group_scope( + self, group_id: str, deployment_name: str, parameters: Union[_models.Deployment, IO], **kwargs: Any + ) -> _models.DeploymentValidateResult: + """Validates whether the specified template is syntactically correct and will be accepted by Azure + Resource Manager.. + + :param group_id: The management group ID. Required. + :type group_id: str + :param deployment_name: The name of the deployment. Required. + :type deployment_name: str + :param parameters: Parameters to validate. Is either a model type or a IO type. Required. + :type parameters: ~azure.mgmt.resource.resources.v2019_07_01.models.Deployment or IO + :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. + Default value is None. + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: DeploymentValidateResult or the result of cls(response) + :rtype: ~azure.mgmt.resource.resources.v2019_07_01.models.DeploymentValidateResult + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.DeploymentValidateResult"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) - api_version = kwargs.pop('api_version', "2019-07-01") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - _json = self._serialize.body(parameters, 'Deployment') + api_version = kwargs.pop("api_version", _params.pop("api-version", "2019-07-01")) # type: str + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.DeploymentValidateResult] + + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(parameters, (IO, bytes)): + _content = parameters + else: + _json = self._serialize.body(parameters, "Deployment") request = build_deployments_validate_at_management_group_scope_request( group_id=group_id, @@ -4993,16 +4964,18 @@ def validate_at_management_group_scope( api_version=api_version, content_type=content_type, json=_json, - template_url=self.validate_at_management_group_scope.metadata['url'], + content=_content, + template_url=self.validate_at_management_group_scope.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200, 400]: @@ -5010,87 +4983,84 @@ def validate_at_management_group_scope( raise HttpResponseError(response=response, error_format=ARMErrorFormat) if response.status_code == 200: - deserialized = self._deserialize('DeploymentValidateResult', pipeline_response) + deserialized = self._deserialize("DeploymentValidateResult", pipeline_response) if response.status_code == 400: - deserialized = self._deserialize('DeploymentValidateResult', pipeline_response) + deserialized = self._deserialize("DeploymentValidateResult", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - validate_at_management_group_scope.metadata = {'url': "/providers/Microsoft.Management/managementGroups/{groupId}/providers/Microsoft.Resources/deployments/{deploymentName}/validate"} # type: ignore - + validate_at_management_group_scope.metadata = {"url": "/providers/Microsoft.Management/managementGroups/{groupId}/providers/Microsoft.Resources/deployments/{deploymentName}/validate"} # type: ignore @distributed_trace def export_template_at_management_group_scope( - self, - group_id: str, - deployment_name: str, - **kwargs: Any - ) -> "_models.DeploymentExportResult": + self, group_id: str, deployment_name: str, **kwargs: Any + ) -> _models.DeploymentExportResult: """Exports the template used for specified deployment. - :param group_id: The management group ID. + :param group_id: The management group ID. Required. :type group_id: str - :param deployment_name: The name of the deployment. + :param deployment_name: The name of the deployment. Required. :type deployment_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: DeploymentExportResult, or the result of cls(response) + :return: DeploymentExportResult or the result of cls(response) :rtype: ~azure.mgmt.resource.resources.v2019_07_01.models.DeploymentExportResult - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.DeploymentExportResult"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + 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', "2019-07-01") # type: str + api_version = kwargs.pop("api_version", _params.pop("api-version", "2019-07-01")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[_models.DeploymentExportResult] - request = build_deployments_export_template_at_management_group_scope_request( group_id=group_id, deployment_name=deployment_name, api_version=api_version, - template_url=self.export_template_at_management_group_scope.metadata['url'], + template_url=self.export_template_at_management_group_scope.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) - deserialized = self._deserialize('DeploymentExportResult', pipeline_response) + deserialized = self._deserialize("DeploymentExportResult", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - export_template_at_management_group_scope.metadata = {'url': "/providers/Microsoft.Management/managementGroups/{groupId}/providers/Microsoft.Resources/deployments/{deploymentName}/exportTemplate"} # type: ignore - + export_template_at_management_group_scope.metadata = {"url": "/providers/Microsoft.Management/managementGroups/{groupId}/providers/Microsoft.Resources/deployments/{deploymentName}/exportTemplate"} # type: ignore @distributed_trace def list_at_management_group_scope( - self, - group_id: str, - filter: Optional[str] = None, - top: Optional[int] = None, - **kwargs: Any - ) -> Iterable["_models.DeploymentListResult"]: + self, group_id: str, filter: Optional[str] = None, top: Optional[int] = None, **kwargs: Any + ) -> Iterable["_models.DeploymentExtended"]: """Get all the deployments for a management group. - :param group_id: The management group ID. + :param group_id: The management group ID. Required. :type group_id: str :param filter: The filter to apply on the operation. For example, you can use $filter=provisioningState eq '{state}'. Default value is None. @@ -5099,40 +5069,48 @@ def list_at_management_group_scope( value is None. :type top: int :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either DeploymentListResult or the result of - cls(response) + :return: An iterator like instance of either DeploymentExtended or the result of cls(response) :rtype: - ~azure.core.paging.ItemPaged[~azure.mgmt.resource.resources.v2019_07_01.models.DeploymentListResult] - :raises: ~azure.core.exceptions.HttpResponseError + ~azure.core.paging.ItemPaged[~azure.mgmt.resource.resources.v2019_07_01.models.DeploymentExtended] + :raises ~azure.core.exceptions.HttpResponseError: """ - api_version = kwargs.pop('api_version', "2019-07-01") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2019-07-01")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[_models.DeploymentListResult] - cls = kwargs.pop('cls', None) # type: ClsType["_models.DeploymentListResult"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) + def prepare_request(next_link=None): if not next_link: - + request = build_deployments_list_at_management_group_scope_request( group_id=group_id, - api_version=api_version, filter=filter, top=top, - template_url=self.list_at_management_group_scope.metadata['url'], + api_version=api_version, + template_url=self.list_at_management_group_scope.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore else: - - request = build_deployments_list_at_management_group_scope_request( - group_id=group_id, - template_url=next_link, - ) + # make call to next link with the client's api-version + _parsed_next_link = urlparse(next_link) + _next_request_params = case_insensitive_dict(parse_qs(_parsed_next_link.query)) + _next_request_params["api-version"] = self._config.api_version + request = HttpRequest("GET", urljoin(next_link, _parsed_next_link.path), params=_next_request_params) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore request.method = "GET" return request @@ -5146,10 +5124,8 @@ def extract_data(pipeline_response): def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) response = pipeline_response.http_response @@ -5159,40 +5135,42 @@ def get_next(next_link=None): return pipeline_response + return ItemPaged(get_next, extract_data) - return ItemPaged( - get_next, extract_data - ) - list_at_management_group_scope.metadata = {'url': "/providers/Microsoft.Management/managementGroups/{groupId}/providers/Microsoft.Resources/deployments/"} # type: ignore + list_at_management_group_scope.metadata = {"url": "/providers/Microsoft.Management/managementGroups/{groupId}/providers/Microsoft.Resources/deployments/"} # type: ignore def _delete_at_subscription_scope_initial( # pylint: disable=inconsistent-return-statements - self, - deployment_name: str, - **kwargs: Any + self, deployment_name: str, **kwargs: Any ) -> None: - cls = kwargs.pop('cls', None) # type: ClsType[None] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + 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', "2019-07-01") # type: str + api_version = kwargs.pop("api_version", _params.pop("api-version", "2019-07-01")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[None] - - request = build_deployments_delete_at_subscription_scope_request_initial( + request = build_deployments_delete_at_subscription_scope_request( deployment_name=deployment_name, subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self._delete_at_subscription_scope_initial.metadata['url'], + template_url=self._delete_at_subscription_scope_initial.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [202, 204]: @@ -5202,15 +5180,10 @@ def _delete_at_subscription_scope_initial( # pylint: disable=inconsistent-retur if cls: return cls(pipeline_response, None, {}) - _delete_at_subscription_scope_initial.metadata = {'url': "/subscriptions/{subscriptionId}/providers/Microsoft.Resources/deployments/{deploymentName}"} # type: ignore - + _delete_at_subscription_scope_initial.metadata = {"url": "/subscriptions/{subscriptionId}/providers/Microsoft.Resources/deployments/{deploymentName}"} # type: ignore @distributed_trace - def begin_delete_at_subscription_scope( # pylint: disable=inconsistent-return-statements - self, - deployment_name: str, - **kwargs: Any - ) -> LROPoller[None]: + def begin_delete_at_subscription_scope(self, deployment_name: str, **kwargs: Any) -> LROPoller[None]: """Deletes a deployment from the deployment history. A template deployment that is currently running cannot be deleted. Deleting a template @@ -5221,7 +5194,7 @@ def begin_delete_at_subscription_scope( # pylint: disable=inconsistent-return-s process finishes, the URI in the Location header returns a status of 204 on success. If the asynchronous request failed, the URI in the Location header returns an error-level status code. - :param deployment_name: The name of the deployment. + :param deployment_name: The name of the deployment. Required. :type deployment_name: str :keyword callable cls: A custom type or function that will be passed the direct response :keyword str continuation_token: A continuation token to restart a poller from a saved state. @@ -5233,82 +5206,88 @@ def begin_delete_at_subscription_scope( # pylint: disable=inconsistent-return-s Retry-After header is present. :return: An instance of LROPoller that returns either None or the result of cls(response) :rtype: ~azure.core.polling.LROPoller[None] - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - api_version = kwargs.pop('api_version', "2019-07-01") # type: str - polling = kwargs.pop('polling', True) # type: Union[bool, PollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType[None] - lro_delay = kwargs.pop( - 'polling_interval', - self._config.polling_interval - ) - cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2019-07-01")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[None] + polling = kwargs.pop("polling", True) # type: Union[bool, PollingMethod] + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token = kwargs.pop("continuation_token", None) # type: Optional[str] if cont_token is None: - raw_result = self._delete_at_subscription_scope_initial( + raw_result = self._delete_at_subscription_scope_initial( # type: ignore deployment_name=deployment_name, api_version=api_version, - cls=lambda x,y,z: x, + cls=lambda x, y, z: x, + headers=_headers, + params=_params, **kwargs ) - kwargs.pop('error_map', None) + kwargs.pop("error_map", None) - def get_long_running_output(pipeline_response): + def get_long_running_output(pipeline_response): # pylint: disable=inconsistent-return-statements if cls: return cls(pipeline_response, None, {}) - - if polling is True: polling_method = ARMPolling(lro_delay, **kwargs) - elif polling is False: polling_method = NoPolling() - else: polling_method = polling + if polling is True: + polling_method = cast(PollingMethod, ARMPolling(lro_delay, **kwargs)) # type: PollingMethod + elif polling is False: + polling_method = cast(PollingMethod, NoPolling()) + else: + polling_method = polling if cont_token: return LROPoller.from_continuation_token( polling_method=polling_method, continuation_token=cont_token, client=self._client, - deserialization_callback=get_long_running_output + deserialization_callback=get_long_running_output, ) return LROPoller(self._client, raw_result, get_long_running_output, polling_method) - begin_delete_at_subscription_scope.metadata = {'url': "/subscriptions/{subscriptionId}/providers/Microsoft.Resources/deployments/{deploymentName}"} # type: ignore + begin_delete_at_subscription_scope.metadata = {"url": "/subscriptions/{subscriptionId}/providers/Microsoft.Resources/deployments/{deploymentName}"} # type: ignore @distributed_trace - def check_existence_at_subscription_scope( - self, - deployment_name: str, - **kwargs: Any - ) -> bool: + def check_existence_at_subscription_scope(self, deployment_name: str, **kwargs: Any) -> bool: """Checks whether the deployment exists. - :param deployment_name: The name of the deployment. + :param deployment_name: The name of the deployment. Required. :type deployment_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: bool, or the result of cls(response) + :return: bool or the result of cls(response) :rtype: bool - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType[None] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + 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', "2019-07-01") # type: str + api_version = kwargs.pop("api_version", _params.pop("api-version", "2019-07-01")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[None] - request = build_deployments_check_existence_at_subscription_scope_request( deployment_name=deployment_name, subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.check_existence_at_subscription_scope.metadata['url'], + template_url=self.check_existence_at_subscription_scope.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [204, 404]: @@ -5319,42 +5298,52 @@ def check_existence_at_subscription_scope( return cls(pipeline_response, None, {}) return 200 <= response.status_code <= 299 - check_existence_at_subscription_scope.metadata = {'url': "/subscriptions/{subscriptionId}/providers/Microsoft.Resources/deployments/{deploymentName}"} # type: ignore - + check_existence_at_subscription_scope.metadata = {"url": "/subscriptions/{subscriptionId}/providers/Microsoft.Resources/deployments/{deploymentName}"} # type: ignore def _create_or_update_at_subscription_scope_initial( - self, - deployment_name: str, - parameters: "_models.Deployment", - **kwargs: Any - ) -> "_models.DeploymentExtended": - cls = kwargs.pop('cls', None) # type: ClsType["_models.DeploymentExtended"] + self, deployment_name: str, parameters: Union[_models.Deployment, IO], **kwargs: Any + ) -> _models.DeploymentExtended: error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', "2019-07-01") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + api_version = kwargs.pop("api_version", _params.pop("api-version", "2019-07-01")) # type: str + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.DeploymentExtended] - _json = self._serialize.body(parameters, 'Deployment') + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(parameters, (IO, bytes)): + _content = parameters + else: + _json = self._serialize.body(parameters, "Deployment") - request = build_deployments_create_or_update_at_subscription_scope_request_initial( + request = build_deployments_create_or_update_at_subscription_scope_request( deployment_name=deployment_name, subscription_id=self._config.subscription_id, api_version=api_version, content_type=content_type, json=_json, - template_url=self._create_or_update_at_subscription_scope_initial.metadata['url'], + content=_content, + template_url=self._create_or_update_at_subscription_scope_initial.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200, 201]: @@ -5362,34 +5351,38 @@ def _create_or_update_at_subscription_scope_initial( raise HttpResponseError(response=response, error_format=ARMErrorFormat) if response.status_code == 200: - deserialized = self._deserialize('DeploymentExtended', pipeline_response) + deserialized = self._deserialize("DeploymentExtended", pipeline_response) if response.status_code == 201: - deserialized = self._deserialize('DeploymentExtended', pipeline_response) + deserialized = self._deserialize("DeploymentExtended", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - _create_or_update_at_subscription_scope_initial.metadata = {'url': "/subscriptions/{subscriptionId}/providers/Microsoft.Resources/deployments/{deploymentName}"} # type: ignore - + _create_or_update_at_subscription_scope_initial.metadata = {"url": "/subscriptions/{subscriptionId}/providers/Microsoft.Resources/deployments/{deploymentName}"} # type: ignore - @distributed_trace + @overload def begin_create_or_update_at_subscription_scope( self, deployment_name: str, - parameters: "_models.Deployment", + parameters: _models.Deployment, + *, + content_type: str = "application/json", **kwargs: Any - ) -> LROPoller["_models.DeploymentExtended"]: + ) -> LROPoller[_models.DeploymentExtended]: """Deploys resources at subscription scope. You can provide the template and parameters directly in the request or link to JSON files. - :param deployment_name: The name of the deployment. + :param deployment_name: The name of the deployment. Required. :type deployment_name: str - :param parameters: Additional parameters supplied to the operation. + :param parameters: Additional parameters supplied to the operation. Required. :type parameters: ~azure.mgmt.resource.resources.v2019_07_01.models.Deployment + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str :keyword callable cls: A custom type or function that will be passed the direct response :keyword str continuation_token: A continuation token to restart a poller from a saved state. :keyword polling: By default, your polling method will be ARMPolling. Pass in False for this @@ -5402,109 +5395,172 @@ def begin_create_or_update_at_subscription_scope( cls(response) :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.resource.resources.v2019_07_01.models.DeploymentExtended] - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - api_version = kwargs.pop('api_version', "2019-07-01") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] - polling = kwargs.pop('polling', True) # type: Union[bool, PollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType["_models.DeploymentExtended"] - lro_delay = kwargs.pop( - 'polling_interval', - self._config.polling_interval - ) - cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] + + @overload + def begin_create_or_update_at_subscription_scope( + self, deployment_name: str, parameters: IO, *, content_type: str = "application/json", **kwargs: Any + ) -> LROPoller[_models.DeploymentExtended]: + """Deploys resources at subscription scope. + + You can provide the template and parameters directly in the request or link to JSON files. + + :param deployment_name: The name of the deployment. Required. + :type deployment_name: str + :param parameters: Additional parameters supplied to the operation. Required. + :type parameters: IO + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be ARMPolling. Pass in False for this + operation to not poll, or pass in your own initialized polling object for a personal polling + strategy. + :paramtype polling: bool or ~azure.core.polling.PollingMethod + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of LROPoller that returns either DeploymentExtended or the result of + cls(response) + :rtype: + ~azure.core.polling.LROPoller[~azure.mgmt.resource.resources.v2019_07_01.models.DeploymentExtended] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace + def begin_create_or_update_at_subscription_scope( + self, deployment_name: str, parameters: Union[_models.Deployment, IO], **kwargs: Any + ) -> LROPoller[_models.DeploymentExtended]: + """Deploys resources at subscription scope. + + You can provide the template and parameters directly in the request or link to JSON files. + + :param deployment_name: The name of the deployment. Required. + :type deployment_name: str + :param parameters: Additional parameters supplied to the operation. Is either a model type or a + IO type. Required. + :type parameters: ~azure.mgmt.resource.resources.v2019_07_01.models.Deployment or IO + :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. + Default value is None. + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be ARMPolling. Pass in False for this + operation to not poll, or pass in your own initialized polling object for a personal polling + strategy. + :paramtype polling: bool or ~azure.core.polling.PollingMethod + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of LROPoller that returns either DeploymentExtended or the result of + cls(response) + :rtype: + ~azure.core.polling.LROPoller[~azure.mgmt.resource.resources.v2019_07_01.models.DeploymentExtended] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _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", "2019-07-01")) # type: str + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.DeploymentExtended] + polling = kwargs.pop("polling", True) # type: Union[bool, PollingMethod] + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token = kwargs.pop("continuation_token", None) # type: Optional[str] if cont_token is None: - raw_result = self._create_or_update_at_subscription_scope_initial( + raw_result = self._create_or_update_at_subscription_scope_initial( # type: ignore deployment_name=deployment_name, parameters=parameters, api_version=api_version, content_type=content_type, - cls=lambda x,y,z: x, + cls=lambda x, y, z: x, + headers=_headers, + params=_params, **kwargs ) - kwargs.pop('error_map', None) + kwargs.pop("error_map", None) def get_long_running_output(pipeline_response): - response = pipeline_response.http_response - deserialized = self._deserialize('DeploymentExtended', pipeline_response) + deserialized = self._deserialize("DeploymentExtended", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - - if polling is True: polling_method = ARMPolling(lro_delay, **kwargs) - elif polling is False: polling_method = NoPolling() - else: polling_method = polling + if polling is True: + polling_method = cast(PollingMethod, ARMPolling(lro_delay, **kwargs)) # type: PollingMethod + elif polling is False: + polling_method = cast(PollingMethod, NoPolling()) + else: + polling_method = polling if cont_token: return LROPoller.from_continuation_token( polling_method=polling_method, continuation_token=cont_token, client=self._client, - deserialization_callback=get_long_running_output + deserialization_callback=get_long_running_output, ) return LROPoller(self._client, raw_result, get_long_running_output, polling_method) - begin_create_or_update_at_subscription_scope.metadata = {'url': "/subscriptions/{subscriptionId}/providers/Microsoft.Resources/deployments/{deploymentName}"} # type: ignore + begin_create_or_update_at_subscription_scope.metadata = {"url": "/subscriptions/{subscriptionId}/providers/Microsoft.Resources/deployments/{deploymentName}"} # type: ignore @distributed_trace - def get_at_subscription_scope( - self, - deployment_name: str, - **kwargs: Any - ) -> "_models.DeploymentExtended": + def get_at_subscription_scope(self, deployment_name: str, **kwargs: Any) -> _models.DeploymentExtended: """Gets a deployment. - :param deployment_name: The name of the deployment. + :param deployment_name: The name of the deployment. Required. :type deployment_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: DeploymentExtended, or the result of cls(response) + :return: DeploymentExtended or the result of cls(response) :rtype: ~azure.mgmt.resource.resources.v2019_07_01.models.DeploymentExtended - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.DeploymentExtended"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) - api_version = kwargs.pop('api_version', "2019-07-01") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2019-07-01")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[_models.DeploymentExtended] - request = build_deployments_get_at_subscription_scope_request( deployment_name=deployment_name, subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.get_at_subscription_scope.metadata['url'], + template_url=self.get_at_subscription_scope.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) - deserialized = self._deserialize('DeploymentExtended', pipeline_response) + deserialized = self._deserialize("DeploymentExtended", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - get_at_subscription_scope.metadata = {'url': "/subscriptions/{subscriptionId}/providers/Microsoft.Resources/deployments/{deploymentName}"} # type: ignore - + get_at_subscription_scope.metadata = {"url": "/subscriptions/{subscriptionId}/providers/Microsoft.Resources/deployments/{deploymentName}"} # type: ignore @distributed_trace def cancel_at_subscription_scope( # pylint: disable=inconsistent-return-statements - self, - deployment_name: str, - **kwargs: Any + self, deployment_name: str, **kwargs: Any ) -> None: """Cancels a currently running template deployment. @@ -5513,36 +5569,42 @@ def cancel_at_subscription_scope( # pylint: disable=inconsistent-return-stateme deployment stops the currently running template deployment and leaves the resources partially deployed. - :param deployment_name: The name of the deployment. + :param deployment_name: The name of the deployment. Required. :type deployment_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: None, or the result of cls(response) + :return: None or the result of cls(response) :rtype: None - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType[None] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) - api_version = kwargs.pop('api_version', "2019-07-01") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2019-07-01")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[None] - request = build_deployments_cancel_at_subscription_scope_request( deployment_name=deployment_name, subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.cancel_at_subscription_scope.metadata['url'], + template_url=self.cancel_at_subscription_scope.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [204]: @@ -5552,38 +5614,94 @@ def cancel_at_subscription_scope( # pylint: disable=inconsistent-return-stateme if cls: return cls(pipeline_response, None, {}) - cancel_at_subscription_scope.metadata = {'url': "/subscriptions/{subscriptionId}/providers/Microsoft.Resources/deployments/{deploymentName}/cancel"} # type: ignore + cancel_at_subscription_scope.metadata = {"url": "/subscriptions/{subscriptionId}/providers/Microsoft.Resources/deployments/{deploymentName}/cancel"} # type: ignore - - @distributed_trace + @overload def validate_at_subscription_scope( self, deployment_name: str, - parameters: "_models.Deployment", + parameters: _models.Deployment, + *, + content_type: str = "application/json", **kwargs: Any - ) -> "_models.DeploymentValidateResult": + ) -> _models.DeploymentValidateResult: """Validates whether the specified template is syntactically correct and will be accepted by Azure Resource Manager.. - :param deployment_name: The name of the deployment. + :param deployment_name: The name of the deployment. Required. :type deployment_name: str - :param parameters: Parameters to validate. + :param parameters: Parameters to validate. Required. :type parameters: ~azure.mgmt.resource.resources.v2019_07_01.models.Deployment + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: DeploymentValidateResult, or the result of cls(response) + :return: DeploymentValidateResult or the result of cls(response) :rtype: ~azure.mgmt.resource.resources.v2019_07_01.models.DeploymentValidateResult - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.DeploymentValidateResult"] - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {})) - - api_version = kwargs.pop('api_version', "2019-07-01") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] - - _json = self._serialize.body(parameters, 'Deployment') + + @overload + def validate_at_subscription_scope( + self, deployment_name: str, parameters: IO, *, content_type: str = "application/json", **kwargs: Any + ) -> _models.DeploymentValidateResult: + """Validates whether the specified template is syntactically correct and will be accepted by Azure + Resource Manager.. + + :param deployment_name: The name of the deployment. Required. + :type deployment_name: str + :param parameters: Parameters to validate. Required. + :type parameters: IO + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: DeploymentValidateResult or the result of cls(response) + :rtype: ~azure.mgmt.resource.resources.v2019_07_01.models.DeploymentValidateResult + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace + def validate_at_subscription_scope( + self, deployment_name: str, parameters: Union[_models.Deployment, IO], **kwargs: Any + ) -> _models.DeploymentValidateResult: + """Validates whether the specified template is syntactically correct and will be accepted by Azure + Resource Manager.. + + :param deployment_name: The name of the deployment. Required. + :type deployment_name: str + :param parameters: Parameters to validate. Is either a model type or a IO type. Required. + :type parameters: ~azure.mgmt.resource.resources.v2019_07_01.models.Deployment or IO + :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. + Default value is None. + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: DeploymentValidateResult or the result of cls(response) + :rtype: ~azure.mgmt.resource.resources.v2019_07_01.models.DeploymentValidateResult + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2019-07-01")) # type: str + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.DeploymentValidateResult] + + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(parameters, (IO, bytes)): + _content = parameters + else: + _json = self._serialize.body(parameters, "Deployment") request = build_deployments_validate_at_subscription_scope_request( deployment_name=deployment_name, @@ -5591,16 +5709,18 @@ def validate_at_subscription_scope( api_version=api_version, content_type=content_type, json=_json, - template_url=self.validate_at_subscription_scope.metadata['url'], + content=_content, + template_url=self.validate_at_subscription_scope.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200, 400]: @@ -5608,52 +5728,62 @@ def validate_at_subscription_scope( raise HttpResponseError(response=response, error_format=ARMErrorFormat) if response.status_code == 200: - deserialized = self._deserialize('DeploymentValidateResult', pipeline_response) + deserialized = self._deserialize("DeploymentValidateResult", pipeline_response) if response.status_code == 400: - deserialized = self._deserialize('DeploymentValidateResult', pipeline_response) + deserialized = self._deserialize("DeploymentValidateResult", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - validate_at_subscription_scope.metadata = {'url': "/subscriptions/{subscriptionId}/providers/Microsoft.Resources/deployments/{deploymentName}/validate"} # type: ignore - + validate_at_subscription_scope.metadata = {"url": "/subscriptions/{subscriptionId}/providers/Microsoft.Resources/deployments/{deploymentName}/validate"} # type: ignore def _what_if_at_subscription_scope_initial( - self, - deployment_name: str, - parameters: "_models.DeploymentWhatIf", - **kwargs: Any - ) -> Optional["_models.WhatIfOperationResult"]: - cls = kwargs.pop('cls', None) # type: ClsType[Optional["_models.WhatIfOperationResult"]] + self, deployment_name: str, parameters: Union[_models.DeploymentWhatIf, IO], **kwargs: Any + ) -> Optional[_models.WhatIfOperationResult]: error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) - api_version = kwargs.pop('api_version', "2019-07-01") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - _json = self._serialize.body(parameters, 'DeploymentWhatIf') + api_version = kwargs.pop("api_version", _params.pop("api-version", "2019-07-01")) # type: str + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[Optional[_models.WhatIfOperationResult]] - request = build_deployments_what_if_at_subscription_scope_request_initial( + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(parameters, (IO, bytes)): + _content = parameters + else: + _json = self._serialize.body(parameters, "DeploymentWhatIf") + + request = build_deployments_what_if_at_subscription_scope_request( deployment_name=deployment_name, subscription_id=self._config.subscription_id, api_version=api_version, content_type=content_type, json=_json, - template_url=self._what_if_at_subscription_scope_initial.metadata['url'], + content=_content, + template_url=self._what_if_at_subscription_scope_initial.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200, 202]: @@ -5663,35 +5793,38 @@ def _what_if_at_subscription_scope_initial( deserialized = None response_headers = {} if response.status_code == 200: - deserialized = self._deserialize('WhatIfOperationResult', pipeline_response) + deserialized = self._deserialize("WhatIfOperationResult", pipeline_response) if response.status_code == 202: - response_headers['Location']=self._deserialize('str', response.headers.get('Location')) - response_headers['Retry-After']=self._deserialize('str', response.headers.get('Retry-After')) - + response_headers["Location"] = self._deserialize("str", response.headers.get("Location")) + response_headers["Retry-After"] = self._deserialize("str", response.headers.get("Retry-After")) if cls: return cls(pipeline_response, deserialized, response_headers) return deserialized - _what_if_at_subscription_scope_initial.metadata = {'url': "/subscriptions/{subscriptionId}/providers/Microsoft.Resources/deployments/{deploymentName}/whatIf"} # type: ignore + _what_if_at_subscription_scope_initial.metadata = {"url": "/subscriptions/{subscriptionId}/providers/Microsoft.Resources/deployments/{deploymentName}/whatIf"} # type: ignore - - @distributed_trace + @overload def begin_what_if_at_subscription_scope( self, deployment_name: str, - parameters: "_models.DeploymentWhatIf", + parameters: _models.DeploymentWhatIf, + *, + content_type: str = "application/json", **kwargs: Any - ) -> LROPoller["_models.WhatIfOperationResult"]: + ) -> LROPoller[_models.WhatIfOperationResult]: """Returns changes that will be made by the deployment if executed at the scope of the subscription. - :param deployment_name: The name of the deployment. + :param deployment_name: The name of the deployment. Required. :type deployment_name: str - :param parameters: Parameters to What If. + :param parameters: Parameters to What If. Required. :type parameters: ~azure.mgmt.resource.resources.v2019_07_01.models.DeploymentWhatIf + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str :keyword callable cls: A custom type or function that will be passed the direct response :keyword str continuation_token: A continuation token to restart a poller from a saved state. :keyword polling: By default, your polling method will be ARMPolling. Pass in False for this @@ -5704,111 +5837,174 @@ def begin_what_if_at_subscription_scope( cls(response) :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.resource.resources.v2019_07_01.models.WhatIfOperationResult] - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - api_version = kwargs.pop('api_version', "2019-07-01") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] - polling = kwargs.pop('polling', True) # type: Union[bool, PollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType["_models.WhatIfOperationResult"] - lro_delay = kwargs.pop( - 'polling_interval', - self._config.polling_interval - ) - cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] + + @overload + def begin_what_if_at_subscription_scope( + self, deployment_name: str, parameters: IO, *, content_type: str = "application/json", **kwargs: Any + ) -> LROPoller[_models.WhatIfOperationResult]: + """Returns changes that will be made by the deployment if executed at the scope of the + subscription. + + :param deployment_name: The name of the deployment. Required. + :type deployment_name: str + :param parameters: Parameters to What If. Required. + :type parameters: IO + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be ARMPolling. Pass in False for this + operation to not poll, or pass in your own initialized polling object for a personal polling + strategy. + :paramtype polling: bool or ~azure.core.polling.PollingMethod + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of LROPoller that returns either WhatIfOperationResult or the result of + cls(response) + :rtype: + ~azure.core.polling.LROPoller[~azure.mgmt.resource.resources.v2019_07_01.models.WhatIfOperationResult] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace + def begin_what_if_at_subscription_scope( + self, deployment_name: str, parameters: Union[_models.DeploymentWhatIf, IO], **kwargs: Any + ) -> LROPoller[_models.WhatIfOperationResult]: + """Returns changes that will be made by the deployment if executed at the scope of the + subscription. + + :param deployment_name: The name of the deployment. Required. + :type deployment_name: str + :param parameters: Parameters to What If. Is either a model type or a IO type. Required. + :type parameters: ~azure.mgmt.resource.resources.v2019_07_01.models.DeploymentWhatIf or IO + :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. + Default value is None. + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be ARMPolling. Pass in False for this + operation to not poll, or pass in your own initialized polling object for a personal polling + strategy. + :paramtype polling: bool or ~azure.core.polling.PollingMethod + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of LROPoller that returns either WhatIfOperationResult or the result of + cls(response) + :rtype: + ~azure.core.polling.LROPoller[~azure.mgmt.resource.resources.v2019_07_01.models.WhatIfOperationResult] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _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", "2019-07-01")) # type: str + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.WhatIfOperationResult] + polling = kwargs.pop("polling", True) # type: Union[bool, PollingMethod] + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token = kwargs.pop("continuation_token", None) # type: Optional[str] if cont_token is None: - raw_result = self._what_if_at_subscription_scope_initial( + raw_result = self._what_if_at_subscription_scope_initial( # type: ignore deployment_name=deployment_name, parameters=parameters, api_version=api_version, content_type=content_type, - cls=lambda x,y,z: x, + cls=lambda x, y, z: x, + headers=_headers, + params=_params, **kwargs ) - kwargs.pop('error_map', None) + kwargs.pop("error_map", None) def get_long_running_output(pipeline_response): - response = pipeline_response.http_response - deserialized = self._deserialize('WhatIfOperationResult', pipeline_response) + deserialized = self._deserialize("WhatIfOperationResult", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - - if polling is True: polling_method = ARMPolling(lro_delay, lro_options={'final-state-via': 'location'}, **kwargs) - elif polling is False: polling_method = NoPolling() - else: polling_method = polling + if polling is True: + polling_method = cast( + PollingMethod, ARMPolling(lro_delay, lro_options={"final-state-via": "location"}, **kwargs) + ) # type: PollingMethod + elif polling is False: + polling_method = cast(PollingMethod, NoPolling()) + else: + polling_method = polling if cont_token: return LROPoller.from_continuation_token( polling_method=polling_method, continuation_token=cont_token, client=self._client, - deserialization_callback=get_long_running_output + deserialization_callback=get_long_running_output, ) return LROPoller(self._client, raw_result, get_long_running_output, polling_method) - begin_what_if_at_subscription_scope.metadata = {'url': "/subscriptions/{subscriptionId}/providers/Microsoft.Resources/deployments/{deploymentName}/whatIf"} # type: ignore + begin_what_if_at_subscription_scope.metadata = {"url": "/subscriptions/{subscriptionId}/providers/Microsoft.Resources/deployments/{deploymentName}/whatIf"} # type: ignore @distributed_trace def export_template_at_subscription_scope( - self, - deployment_name: str, - **kwargs: Any - ) -> "_models.DeploymentExportResult": + self, deployment_name: str, **kwargs: Any + ) -> _models.DeploymentExportResult: """Exports the template used for specified deployment. - :param deployment_name: The name of the deployment. + :param deployment_name: The name of the deployment. Required. :type deployment_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: DeploymentExportResult, or the result of cls(response) + :return: DeploymentExportResult or the result of cls(response) :rtype: ~azure.mgmt.resource.resources.v2019_07_01.models.DeploymentExportResult - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.DeploymentExportResult"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) - api_version = kwargs.pop('api_version', "2019-07-01") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2019-07-01")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[_models.DeploymentExportResult] - request = build_deployments_export_template_at_subscription_scope_request( deployment_name=deployment_name, subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.export_template_at_subscription_scope.metadata['url'], + template_url=self.export_template_at_subscription_scope.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) - deserialized = self._deserialize('DeploymentExportResult', pipeline_response) + deserialized = self._deserialize("DeploymentExportResult", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - export_template_at_subscription_scope.metadata = {'url': "/subscriptions/{subscriptionId}/providers/Microsoft.Resources/deployments/{deploymentName}/exportTemplate"} # type: ignore - + export_template_at_subscription_scope.metadata = {"url": "/subscriptions/{subscriptionId}/providers/Microsoft.Resources/deployments/{deploymentName}/exportTemplate"} # type: ignore @distributed_trace def list_at_subscription_scope( - self, - filter: Optional[str] = None, - top: Optional[int] = None, - **kwargs: Any - ) -> Iterable["_models.DeploymentListResult"]: + self, filter: Optional[str] = None, top: Optional[int] = None, **kwargs: Any + ) -> Iterable["_models.DeploymentExtended"]: """Get all the deployments for a subscription. :param filter: The filter to apply on the operation. For example, you can use @@ -5818,40 +6014,48 @@ def list_at_subscription_scope( value is None. :type top: int :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either DeploymentListResult or the result of - cls(response) + :return: An iterator like instance of either DeploymentExtended or the result of cls(response) :rtype: - ~azure.core.paging.ItemPaged[~azure.mgmt.resource.resources.v2019_07_01.models.DeploymentListResult] - :raises: ~azure.core.exceptions.HttpResponseError + ~azure.core.paging.ItemPaged[~azure.mgmt.resource.resources.v2019_07_01.models.DeploymentExtended] + :raises ~azure.core.exceptions.HttpResponseError: """ - api_version = kwargs.pop('api_version', "2019-07-01") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2019-07-01")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[_models.DeploymentListResult] - cls = kwargs.pop('cls', None) # type: ClsType["_models.DeploymentListResult"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) + def prepare_request(next_link=None): if not next_link: - + request = build_deployments_list_at_subscription_scope_request( subscription_id=self._config.subscription_id, - api_version=api_version, filter=filter, top=top, - template_url=self.list_at_subscription_scope.metadata['url'], + api_version=api_version, + template_url=self.list_at_subscription_scope.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore else: - - request = build_deployments_list_at_subscription_scope_request( - subscription_id=self._config.subscription_id, - template_url=next_link, - ) + # make call to next link with the client's api-version + _parsed_next_link = urlparse(next_link) + _next_request_params = case_insensitive_dict(parse_qs(_parsed_next_link.query)) + _next_request_params["api-version"] = self._config.api_version + request = HttpRequest("GET", urljoin(next_link, _parsed_next_link.path), params=_next_request_params) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore request.method = "GET" return request @@ -5865,10 +6069,8 @@ def extract_data(pipeline_response): def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) response = pipeline_response.http_response @@ -5878,42 +6080,43 @@ def get_next(next_link=None): return pipeline_response + return ItemPaged(get_next, extract_data) - return ItemPaged( - get_next, extract_data - ) - list_at_subscription_scope.metadata = {'url': "/subscriptions/{subscriptionId}/providers/Microsoft.Resources/deployments/"} # type: ignore + list_at_subscription_scope.metadata = {"url": "/subscriptions/{subscriptionId}/providers/Microsoft.Resources/deployments/"} # type: ignore def _delete_initial( # pylint: disable=inconsistent-return-statements - self, - resource_group_name: str, - deployment_name: str, - **kwargs: Any + self, resource_group_name: str, deployment_name: str, **kwargs: Any ) -> None: - cls = kwargs.pop('cls', None) # type: ClsType[None] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) - api_version = kwargs.pop('api_version', "2019-07-01") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - request = build_deployments_delete_request_initial( + api_version = kwargs.pop("api_version", _params.pop("api-version", "2019-07-01")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[None] + + request = build_deployments_delete_request( resource_group_name=resource_group_name, deployment_name=deployment_name, subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self._delete_initial.metadata['url'], + template_url=self._delete_initial.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [202, 204]: @@ -5923,16 +6126,10 @@ 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.Resources/deployments/{deploymentName}"} # type: ignore - + _delete_initial.metadata = {"url": "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/Microsoft.Resources/deployments/{deploymentName}"} # type: ignore @distributed_trace - def begin_delete( # pylint: disable=inconsistent-return-statements - self, - resource_group_name: str, - deployment_name: str, - **kwargs: Any - ) -> LROPoller[None]: + def begin_delete(self, resource_group_name: str, deployment_name: str, **kwargs: Any) -> LROPoller[None]: """Deletes a deployment from the deployment history. A template deployment that is currently running cannot be deleted. Deleting a template @@ -5945,9 +6142,9 @@ def begin_delete( # pylint: disable=inconsistent-return-statements asynchronous request failed, the URI in the Location header returns an error-level status code. :param resource_group_name: The name of the resource group with the deployment to delete. The - name is case insensitive. + name is case insensitive. Required. :type resource_group_name: str - :param deployment_name: The name of the deployment. + :param deployment_name: The name of the deployment. Required. :type deployment_name: str :keyword callable cls: A custom type or function that will be passed the direct response :keyword str continuation_token: A continuation token to restart a poller from a saved state. @@ -5959,88 +6156,93 @@ def begin_delete( # pylint: disable=inconsistent-return-statements Retry-After header is present. :return: An instance of LROPoller that returns either None or the result of cls(response) :rtype: ~azure.core.polling.LROPoller[None] - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - api_version = kwargs.pop('api_version', "2019-07-01") # type: str - polling = kwargs.pop('polling', True) # type: Union[bool, PollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType[None] - lro_delay = kwargs.pop( - 'polling_interval', - self._config.polling_interval - ) - cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2019-07-01")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[None] + polling = kwargs.pop("polling", True) # type: Union[bool, PollingMethod] + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token = kwargs.pop("continuation_token", None) # type: Optional[str] if cont_token is None: - raw_result = self._delete_initial( + raw_result = self._delete_initial( # type: ignore resource_group_name=resource_group_name, deployment_name=deployment_name, api_version=api_version, - cls=lambda x,y,z: x, + cls=lambda x, y, z: x, + headers=_headers, + params=_params, **kwargs ) - kwargs.pop('error_map', None) + kwargs.pop("error_map", None) - def get_long_running_output(pipeline_response): + def get_long_running_output(pipeline_response): # pylint: disable=inconsistent-return-statements if cls: return cls(pipeline_response, None, {}) - - if polling is True: polling_method = ARMPolling(lro_delay, **kwargs) - elif polling is False: polling_method = NoPolling() - else: polling_method = polling + if polling is True: + polling_method = cast(PollingMethod, ARMPolling(lro_delay, **kwargs)) # type: PollingMethod + elif polling is False: + polling_method = cast(PollingMethod, NoPolling()) + else: + polling_method = polling if cont_token: return LROPoller.from_continuation_token( polling_method=polling_method, continuation_token=cont_token, client=self._client, - deserialization_callback=get_long_running_output + deserialization_callback=get_long_running_output, ) return LROPoller(self._client, raw_result, get_long_running_output, polling_method) - begin_delete.metadata = {'url': "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/Microsoft.Resources/deployments/{deploymentName}"} # type: ignore + begin_delete.metadata = {"url": "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/Microsoft.Resources/deployments/{deploymentName}"} # type: ignore @distributed_trace - def check_existence( - self, - resource_group_name: str, - deployment_name: str, - **kwargs: Any - ) -> bool: + def check_existence(self, resource_group_name: str, deployment_name: str, **kwargs: Any) -> bool: """Checks whether the deployment exists. :param resource_group_name: The name of the resource group with the deployment to check. The - name is case insensitive. + name is case insensitive. Required. :type resource_group_name: str - :param deployment_name: The name of the deployment. + :param deployment_name: The name of the deployment. Required. :type deployment_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: bool, or the result of cls(response) + :return: bool or the result of cls(response) :rtype: bool - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType[None] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + 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', "2019-07-01") # type: str + api_version = kwargs.pop("api_version", _params.pop("api-version", "2019-07-01")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[None] - request = build_deployments_check_existence_request( resource_group_name=resource_group_name, deployment_name=deployment_name, subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.check_existence.metadata['url'], + template_url=self.check_existence.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [204, 404]: @@ -6051,44 +6253,53 @@ def check_existence( return cls(pipeline_response, None, {}) return 200 <= response.status_code <= 299 - check_existence.metadata = {'url': "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/Microsoft.Resources/deployments/{deploymentName}"} # type: ignore - + check_existence.metadata = {"url": "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/Microsoft.Resources/deployments/{deploymentName}"} # type: ignore def _create_or_update_initial( - self, - resource_group_name: str, - deployment_name: str, - parameters: "_models.Deployment", - **kwargs: Any - ) -> "_models.DeploymentExtended": - cls = kwargs.pop('cls', None) # type: ClsType["_models.DeploymentExtended"] + self, resource_group_name: str, deployment_name: str, parameters: Union[_models.Deployment, IO], **kwargs: Any + ) -> _models.DeploymentExtended: error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) - api_version = kwargs.pop('api_version', "2019-07-01") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - _json = self._serialize.body(parameters, 'Deployment') + api_version = kwargs.pop("api_version", _params.pop("api-version", "2019-07-01")) # type: str + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.DeploymentExtended] - request = build_deployments_create_or_update_request_initial( + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(parameters, (IO, bytes)): + _content = parameters + else: + _json = self._serialize.body(parameters, "Deployment") + + request = build_deployments_create_or_update_request( resource_group_name=resource_group_name, deployment_name=deployment_name, subscription_id=self._config.subscription_id, api_version=api_version, content_type=content_type, json=_json, - template_url=self._create_or_update_initial.metadata['url'], + content=_content, + template_url=self._create_or_update_initial.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200, 201]: @@ -6096,38 +6307,42 @@ def _create_or_update_initial( raise HttpResponseError(response=response, error_format=ARMErrorFormat) if response.status_code == 200: - deserialized = self._deserialize('DeploymentExtended', pipeline_response) + deserialized = self._deserialize("DeploymentExtended", pipeline_response) if response.status_code == 201: - deserialized = self._deserialize('DeploymentExtended', pipeline_response) + deserialized = self._deserialize("DeploymentExtended", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - _create_or_update_initial.metadata = {'url': "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/Microsoft.Resources/deployments/{deploymentName}"} # type: ignore + _create_or_update_initial.metadata = {"url": "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/Microsoft.Resources/deployments/{deploymentName}"} # type: ignore - - @distributed_trace + @overload def begin_create_or_update( self, resource_group_name: str, deployment_name: str, - parameters: "_models.Deployment", + parameters: _models.Deployment, + *, + content_type: str = "application/json", **kwargs: Any - ) -> LROPoller["_models.DeploymentExtended"]: + ) -> LROPoller[_models.DeploymentExtended]: """Deploys resources to a resource group. You can provide the template and parameters directly in the request or link to JSON files. :param resource_group_name: The name of the resource group to deploy the resources to. The name - is case insensitive. The resource group must already exist. + is case insensitive. The resource group must already exist. Required. :type resource_group_name: str - :param deployment_name: The name of the deployment. + :param deployment_name: The name of the deployment. Required. :type deployment_name: str - :param parameters: Additional parameters supplied to the operation. + :param parameters: Additional parameters supplied to the operation. Required. :type parameters: ~azure.mgmt.resource.resources.v2019_07_01.models.Deployment + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str :keyword callable cls: A custom type or function that will be passed the direct response :keyword str continuation_token: A continuation token to restart a poller from a saved state. :keyword polling: By default, your polling method will be ARMPolling. Pass in False for this @@ -6140,115 +6355,189 @@ def begin_create_or_update( cls(response) :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.resource.resources.v2019_07_01.models.DeploymentExtended] - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - api_version = kwargs.pop('api_version', "2019-07-01") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] - polling = kwargs.pop('polling', True) # type: Union[bool, PollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType["_models.DeploymentExtended"] - lro_delay = kwargs.pop( - 'polling_interval', - self._config.polling_interval - ) - cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] + + @overload + def begin_create_or_update( + self, + resource_group_name: str, + deployment_name: str, + parameters: IO, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> LROPoller[_models.DeploymentExtended]: + """Deploys resources to a resource group. + + You can provide the template and parameters directly in the request or link to JSON files. + + :param resource_group_name: The name of the resource group to deploy the resources to. The name + is case insensitive. The resource group must already exist. Required. + :type resource_group_name: str + :param deployment_name: The name of the deployment. Required. + :type deployment_name: str + :param parameters: Additional parameters supplied to the operation. Required. + :type parameters: IO + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be ARMPolling. Pass in False for this + operation to not poll, or pass in your own initialized polling object for a personal polling + strategy. + :paramtype polling: bool or ~azure.core.polling.PollingMethod + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of LROPoller that returns either DeploymentExtended or the result of + cls(response) + :rtype: + ~azure.core.polling.LROPoller[~azure.mgmt.resource.resources.v2019_07_01.models.DeploymentExtended] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace + def begin_create_or_update( + self, resource_group_name: str, deployment_name: str, parameters: Union[_models.Deployment, IO], **kwargs: Any + ) -> LROPoller[_models.DeploymentExtended]: + """Deploys resources to a resource group. + + You can provide the template and parameters directly in the request or link to JSON files. + + :param resource_group_name: The name of the resource group to deploy the resources to. The name + is case insensitive. The resource group must already exist. Required. + :type resource_group_name: str + :param deployment_name: The name of the deployment. Required. + :type deployment_name: str + :param parameters: Additional parameters supplied to the operation. Is either a model type or a + IO type. Required. + :type parameters: ~azure.mgmt.resource.resources.v2019_07_01.models.Deployment or IO + :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. + Default value is None. + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be ARMPolling. Pass in False for this + operation to not poll, or pass in your own initialized polling object for a personal polling + strategy. + :paramtype polling: bool or ~azure.core.polling.PollingMethod + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of LROPoller that returns either DeploymentExtended or the result of + cls(response) + :rtype: + ~azure.core.polling.LROPoller[~azure.mgmt.resource.resources.v2019_07_01.models.DeploymentExtended] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _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", "2019-07-01")) # type: str + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.DeploymentExtended] + polling = kwargs.pop("polling", True) # type: Union[bool, PollingMethod] + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token = kwargs.pop("continuation_token", None) # type: Optional[str] if cont_token is None: - raw_result = self._create_or_update_initial( + raw_result = self._create_or_update_initial( # type: ignore resource_group_name=resource_group_name, deployment_name=deployment_name, parameters=parameters, api_version=api_version, content_type=content_type, - cls=lambda x,y,z: x, + cls=lambda x, y, z: x, + headers=_headers, + params=_params, **kwargs ) - kwargs.pop('error_map', None) + kwargs.pop("error_map", None) def get_long_running_output(pipeline_response): - response = pipeline_response.http_response - deserialized = self._deserialize('DeploymentExtended', pipeline_response) + deserialized = self._deserialize("DeploymentExtended", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - - if polling is True: polling_method = ARMPolling(lro_delay, **kwargs) - elif polling is False: polling_method = NoPolling() - else: polling_method = polling + if polling is True: + polling_method = cast(PollingMethod, ARMPolling(lro_delay, **kwargs)) # type: PollingMethod + elif polling is False: + polling_method = cast(PollingMethod, NoPolling()) + else: + polling_method = polling if cont_token: return LROPoller.from_continuation_token( polling_method=polling_method, continuation_token=cont_token, client=self._client, - deserialization_callback=get_long_running_output + deserialization_callback=get_long_running_output, ) return LROPoller(self._client, raw_result, get_long_running_output, polling_method) - begin_create_or_update.metadata = {'url': "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/Microsoft.Resources/deployments/{deploymentName}"} # type: ignore + begin_create_or_update.metadata = {"url": "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/Microsoft.Resources/deployments/{deploymentName}"} # type: ignore @distributed_trace - def get( - self, - resource_group_name: str, - deployment_name: str, - **kwargs: Any - ) -> "_models.DeploymentExtended": + def get(self, resource_group_name: str, deployment_name: str, **kwargs: Any) -> _models.DeploymentExtended: """Gets a deployment. :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. :type resource_group_name: str - :param deployment_name: The name of the deployment. + :param deployment_name: The name of the deployment. Required. :type deployment_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: DeploymentExtended, or the result of cls(response) + :return: DeploymentExtended or the result of cls(response) :rtype: ~azure.mgmt.resource.resources.v2019_07_01.models.DeploymentExtended - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.DeploymentExtended"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) - api_version = kwargs.pop('api_version', "2019-07-01") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2019-07-01")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[_models.DeploymentExtended] - request = build_deployments_get_request( resource_group_name=resource_group_name, deployment_name=deployment_name, subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.get.metadata['url'], + template_url=self.get.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) - deserialized = self._deserialize('DeploymentExtended', pipeline_response) + deserialized = self._deserialize("DeploymentExtended", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - get.metadata = {'url': "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/Microsoft.Resources/deployments/{deploymentName}"} # type: ignore - + get.metadata = {"url": "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/Microsoft.Resources/deployments/{deploymentName}"} # type: ignore @distributed_trace def cancel( # pylint: disable=inconsistent-return-statements - self, - resource_group_name: str, - deployment_name: str, - **kwargs: Any + self, resource_group_name: str, deployment_name: str, **kwargs: Any ) -> None: """Cancels a currently running template deployment. @@ -6258,38 +6547,45 @@ def cancel( # pylint: disable=inconsistent-return-statements partially deployed. :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. :type resource_group_name: str - :param deployment_name: The name of the deployment. + :param deployment_name: The name of the deployment. Required. :type deployment_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: None, or the result of cls(response) + :return: None or the result of cls(response) :rtype: None - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType[None] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + 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', "2019-07-01") # type: str + api_version = kwargs.pop("api_version", _params.pop("api-version", "2019-07-01")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[None] - request = build_deployments_cancel_request( resource_group_name=resource_group_name, deployment_name=deployment_name, subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.cancel.metadata['url'], + template_url=self.cancel.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [204]: @@ -6299,42 +6595,110 @@ def cancel( # pylint: disable=inconsistent-return-statements if cls: return cls(pipeline_response, None, {}) - cancel.metadata = {'url': "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/Microsoft.Resources/deployments/{deploymentName}/cancel"} # type: ignore - + cancel.metadata = {"url": "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/Microsoft.Resources/deployments/{deploymentName}/cancel"} # type: ignore - @distributed_trace + @overload def validate( self, resource_group_name: str, deployment_name: str, - parameters: "_models.Deployment", + parameters: _models.Deployment, + *, + content_type: str = "application/json", **kwargs: Any - ) -> "_models.DeploymentValidateResult": + ) -> _models.DeploymentValidateResult: """Validates whether the specified template is syntactically correct and will be accepted by Azure Resource Manager.. :param resource_group_name: The name of the resource group the template will be deployed to. - The name is case insensitive. + The name is case insensitive. Required. :type resource_group_name: str - :param deployment_name: The name of the deployment. + :param deployment_name: The name of the deployment. Required. :type deployment_name: str - :param parameters: Parameters to validate. + :param parameters: Parameters to validate. Required. :type parameters: ~azure.mgmt.resource.resources.v2019_07_01.models.Deployment + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: DeploymentValidateResult or the result of cls(response) + :rtype: ~azure.mgmt.resource.resources.v2019_07_01.models.DeploymentValidateResult + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + def validate( + self, + resource_group_name: str, + deployment_name: str, + parameters: IO, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.DeploymentValidateResult: + """Validates whether the specified template is syntactically correct and will be accepted by Azure + Resource Manager.. + + :param resource_group_name: The name of the resource group the template will be deployed to. + The name is case insensitive. Required. + :type resource_group_name: str + :param deployment_name: The name of the deployment. Required. + :type deployment_name: str + :param parameters: Parameters to validate. Required. + :type parameters: IO + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: DeploymentValidateResult or the result of cls(response) + :rtype: ~azure.mgmt.resource.resources.v2019_07_01.models.DeploymentValidateResult + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace + def validate( + self, resource_group_name: str, deployment_name: str, parameters: Union[_models.Deployment, IO], **kwargs: Any + ) -> _models.DeploymentValidateResult: + """Validates whether the specified template is syntactically correct and will be accepted by Azure + Resource Manager.. + + :param resource_group_name: The name of the resource group the template will be deployed to. + The name is case insensitive. Required. + :type resource_group_name: str + :param deployment_name: The name of the deployment. Required. + :type deployment_name: str + :param parameters: Parameters to validate. Is either a model type or a IO type. Required. + :type parameters: ~azure.mgmt.resource.resources.v2019_07_01.models.Deployment or IO + :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. + Default value is None. + :paramtype content_type: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: DeploymentValidateResult, or the result of cls(response) + :return: DeploymentValidateResult or the result of cls(response) :rtype: ~azure.mgmt.resource.resources.v2019_07_01.models.DeploymentValidateResult - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.DeploymentValidateResult"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', "2019-07-01") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + api_version = kwargs.pop("api_version", _params.pop("api-version", "2019-07-01")) # type: str + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.DeploymentValidateResult] - _json = self._serialize.body(parameters, 'Deployment') + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(parameters, (IO, bytes)): + _content = parameters + else: + _json = self._serialize.body(parameters, "Deployment") request = build_deployments_validate_request( resource_group_name=resource_group_name, @@ -6343,16 +6707,18 @@ def validate( api_version=api_version, content_type=content_type, json=_json, - template_url=self.validate.metadata['url'], + content=_content, + template_url=self.validate.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200, 400]: @@ -6360,54 +6726,67 @@ def validate( raise HttpResponseError(response=response, error_format=ARMErrorFormat) if response.status_code == 200: - deserialized = self._deserialize('DeploymentValidateResult', pipeline_response) + deserialized = self._deserialize("DeploymentValidateResult", pipeline_response) if response.status_code == 400: - deserialized = self._deserialize('DeploymentValidateResult', pipeline_response) + deserialized = self._deserialize("DeploymentValidateResult", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - validate.metadata = {'url': "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/Microsoft.Resources/deployments/{deploymentName}/validate"} # type: ignore - + validate.metadata = {"url": "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/Microsoft.Resources/deployments/{deploymentName}/validate"} # type: ignore def _what_if_initial( self, resource_group_name: str, deployment_name: str, - parameters: "_models.DeploymentWhatIf", + parameters: Union[_models.DeploymentWhatIf, IO], **kwargs: Any - ) -> Optional["_models.WhatIfOperationResult"]: - cls = kwargs.pop('cls', None) # type: ClsType[Optional["_models.WhatIfOperationResult"]] + ) -> Optional[_models.WhatIfOperationResult]: error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) - api_version = kwargs.pop('api_version', "2019-07-01") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - _json = self._serialize.body(parameters, 'DeploymentWhatIf') + api_version = kwargs.pop("api_version", _params.pop("api-version", "2019-07-01")) # type: str + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[Optional[_models.WhatIfOperationResult]] - request = build_deployments_what_if_request_initial( + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(parameters, (IO, bytes)): + _content = parameters + else: + _json = self._serialize.body(parameters, "DeploymentWhatIf") + + request = build_deployments_what_if_request( resource_group_name=resource_group_name, deployment_name=deployment_name, subscription_id=self._config.subscription_id, api_version=api_version, content_type=content_type, json=_json, - template_url=self._what_if_initial.metadata['url'], + content=_content, + template_url=self._what_if_initial.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200, 202]: @@ -6417,39 +6796,42 @@ def _what_if_initial( deserialized = None response_headers = {} if response.status_code == 200: - deserialized = self._deserialize('WhatIfOperationResult', pipeline_response) + deserialized = self._deserialize("WhatIfOperationResult", pipeline_response) if response.status_code == 202: - response_headers['Location']=self._deserialize('str', response.headers.get('Location')) - response_headers['Retry-After']=self._deserialize('str', response.headers.get('Retry-After')) - + response_headers["Location"] = self._deserialize("str", response.headers.get("Location")) + response_headers["Retry-After"] = self._deserialize("str", response.headers.get("Retry-After")) if cls: return cls(pipeline_response, deserialized, response_headers) return deserialized - _what_if_initial.metadata = {'url': "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/Microsoft.Resources/deployments/{deploymentName}/whatIf"} # type: ignore + _what_if_initial.metadata = {"url": "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/Microsoft.Resources/deployments/{deploymentName}/whatIf"} # type: ignore - - @distributed_trace + @overload def begin_what_if( self, resource_group_name: str, deployment_name: str, - parameters: "_models.DeploymentWhatIf", + parameters: _models.DeploymentWhatIf, + *, + content_type: str = "application/json", **kwargs: Any - ) -> LROPoller["_models.WhatIfOperationResult"]: + ) -> LROPoller[_models.WhatIfOperationResult]: """Returns changes that will be made by the deployment if executed at the scope of the resource group. :param resource_group_name: The name of the resource group the template will be deployed to. - The name is case insensitive. + The name is case insensitive. Required. :type resource_group_name: str - :param deployment_name: The name of the deployment. + :param deployment_name: The name of the deployment. Required. :type deployment_name: str - :param parameters: Parameters to validate. + :param parameters: Parameters to validate. Required. :type parameters: ~azure.mgmt.resource.resources.v2019_07_01.models.DeploymentWhatIf + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str :keyword callable cls: A custom type or function that will be passed the direct response :keyword str continuation_token: A continuation token to restart a poller from a saved state. :keyword polling: By default, your polling method will be ARMPolling. Pass in False for this @@ -6462,121 +6844,199 @@ def begin_what_if( cls(response) :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.resource.resources.v2019_07_01.models.WhatIfOperationResult] - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - api_version = kwargs.pop('api_version', "2019-07-01") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] - polling = kwargs.pop('polling', True) # type: Union[bool, PollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType["_models.WhatIfOperationResult"] - lro_delay = kwargs.pop( - 'polling_interval', - self._config.polling_interval - ) - cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] - if cont_token is None: - raw_result = self._what_if_initial( - resource_group_name=resource_group_name, - deployment_name=deployment_name, - parameters=parameters, - api_version=api_version, - content_type=content_type, - cls=lambda x,y,z: x, - **kwargs - ) - kwargs.pop('error_map', None) - - def get_long_running_output(pipeline_response): - response = pipeline_response.http_response - deserialized = self._deserialize('WhatIfOperationResult', pipeline_response) - if cls: - return cls(pipeline_response, deserialized, {}) - return deserialized + @overload + def begin_what_if( + self, + resource_group_name: str, + deployment_name: str, + parameters: IO, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> LROPoller[_models.WhatIfOperationResult]: + """Returns changes that will be made by the deployment if executed at the scope of the resource + group. - if polling is True: polling_method = ARMPolling(lro_delay, lro_options={'final-state-via': 'location'}, **kwargs) - elif polling is False: polling_method = NoPolling() - else: polling_method = polling + :param resource_group_name: The name of the resource group the template will be deployed to. + The name is case insensitive. Required. + :type resource_group_name: str + :param deployment_name: The name of the deployment. Required. + :type deployment_name: str + :param parameters: Parameters to validate. Required. + :type parameters: IO + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be ARMPolling. Pass in False for this + operation to not poll, or pass in your own initialized polling object for a personal polling + strategy. + :paramtype polling: bool or ~azure.core.polling.PollingMethod + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of LROPoller that returns either WhatIfOperationResult or the result of + cls(response) + :rtype: + ~azure.core.polling.LROPoller[~azure.mgmt.resource.resources.v2019_07_01.models.WhatIfOperationResult] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace + def begin_what_if( + self, + resource_group_name: str, + deployment_name: str, + parameters: Union[_models.DeploymentWhatIf, IO], + **kwargs: Any + ) -> LROPoller[_models.WhatIfOperationResult]: + """Returns changes that will be made by the deployment if executed at the scope of the resource + group. + + :param resource_group_name: The name of the resource group the template will be deployed to. + The name is case insensitive. Required. + :type resource_group_name: str + :param deployment_name: The name of the deployment. Required. + :type deployment_name: str + :param parameters: Parameters to validate. Is either a model type or a IO type. Required. + :type parameters: ~azure.mgmt.resource.resources.v2019_07_01.models.DeploymentWhatIf or IO + :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. + Default value is None. + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be ARMPolling. Pass in False for this + operation to not poll, or pass in your own initialized polling object for a personal polling + strategy. + :paramtype polling: bool or ~azure.core.polling.PollingMethod + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of LROPoller that returns either WhatIfOperationResult or the result of + cls(response) + :rtype: + ~azure.core.polling.LROPoller[~azure.mgmt.resource.resources.v2019_07_01.models.WhatIfOperationResult] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _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", "2019-07-01")) # type: str + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.WhatIfOperationResult] + polling = kwargs.pop("polling", True) # type: Union[bool, PollingMethod] + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token = kwargs.pop("continuation_token", None) # type: Optional[str] + if cont_token is None: + raw_result = self._what_if_initial( # type: ignore + resource_group_name=resource_group_name, + deployment_name=deployment_name, + parameters=parameters, + api_version=api_version, + content_type=content_type, + cls=lambda x, y, z: x, + headers=_headers, + params=_params, + **kwargs + ) + kwargs.pop("error_map", None) + + def get_long_running_output(pipeline_response): + deserialized = self._deserialize("WhatIfOperationResult", pipeline_response) + if cls: + return cls(pipeline_response, deserialized, {}) + return deserialized + + if polling is True: + polling_method = cast( + PollingMethod, ARMPolling(lro_delay, lro_options={"final-state-via": "location"}, **kwargs) + ) # type: PollingMethod + elif polling is False: + polling_method = cast(PollingMethod, NoPolling()) + else: + polling_method = polling if cont_token: return LROPoller.from_continuation_token( polling_method=polling_method, continuation_token=cont_token, client=self._client, - deserialization_callback=get_long_running_output + deserialization_callback=get_long_running_output, ) return LROPoller(self._client, raw_result, get_long_running_output, polling_method) - begin_what_if.metadata = {'url': "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/Microsoft.Resources/deployments/{deploymentName}/whatIf"} # type: ignore + begin_what_if.metadata = {"url": "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/Microsoft.Resources/deployments/{deploymentName}/whatIf"} # type: ignore @distributed_trace def export_template( - self, - resource_group_name: str, - deployment_name: str, - **kwargs: Any - ) -> "_models.DeploymentExportResult": + self, resource_group_name: str, deployment_name: str, **kwargs: Any + ) -> _models.DeploymentExportResult: """Exports the template used for specified deployment. :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. :type resource_group_name: str - :param deployment_name: The name of the deployment. + :param deployment_name: The name of the deployment. Required. :type deployment_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: DeploymentExportResult, or the result of cls(response) + :return: DeploymentExportResult or the result of cls(response) :rtype: ~azure.mgmt.resource.resources.v2019_07_01.models.DeploymentExportResult - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.DeploymentExportResult"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + 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', "2019-07-01") # type: str + api_version = kwargs.pop("api_version", _params.pop("api-version", "2019-07-01")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[_models.DeploymentExportResult] - request = build_deployments_export_template_request( resource_group_name=resource_group_name, deployment_name=deployment_name, subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.export_template.metadata['url'], + template_url=self.export_template.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) - deserialized = self._deserialize('DeploymentExportResult', pipeline_response) + deserialized = self._deserialize("DeploymentExportResult", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - export_template.metadata = {'url': "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/Microsoft.Resources/deployments/{deploymentName}/exportTemplate"} # type: ignore - + export_template.metadata = {"url": "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/Microsoft.Resources/deployments/{deploymentName}/exportTemplate"} # type: ignore @distributed_trace def list_by_resource_group( - self, - resource_group_name: str, - filter: Optional[str] = None, - top: Optional[int] = None, - **kwargs: Any - ) -> Iterable["_models.DeploymentListResult"]: + self, resource_group_name: str, filter: Optional[str] = None, top: Optional[int] = None, **kwargs: Any + ) -> Iterable["_models.DeploymentExtended"]: """Get all the deployments for a resource group. :param resource_group_name: The name of the resource group with the deployments to get. The - name is case insensitive. + name is case insensitive. Required. :type resource_group_name: str :param filter: The filter to apply on the operation. For example, you can use $filter=provisioningState eq '{state}'. Default value is None. @@ -6585,42 +7045,49 @@ def list_by_resource_group( value is None. :type top: int :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either DeploymentListResult or the result of - cls(response) + :return: An iterator like instance of either DeploymentExtended or the result of cls(response) :rtype: - ~azure.core.paging.ItemPaged[~azure.mgmt.resource.resources.v2019_07_01.models.DeploymentListResult] - :raises: ~azure.core.exceptions.HttpResponseError + ~azure.core.paging.ItemPaged[~azure.mgmt.resource.resources.v2019_07_01.models.DeploymentExtended] + :raises ~azure.core.exceptions.HttpResponseError: """ - api_version = kwargs.pop('api_version', "2019-07-01") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2019-07-01")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[_models.DeploymentListResult] - cls = kwargs.pop('cls', None) # type: ClsType["_models.DeploymentListResult"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) + def prepare_request(next_link=None): if not next_link: - + request = build_deployments_list_by_resource_group_request( resource_group_name=resource_group_name, subscription_id=self._config.subscription_id, - api_version=api_version, filter=filter, top=top, - template_url=self.list_by_resource_group.metadata['url'], + 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.url = self._client.format_url(request.url) # type: ignore else: - - request = build_deployments_list_by_resource_group_request( - resource_group_name=resource_group_name, - subscription_id=self._config.subscription_id, - template_url=next_link, - ) + # make call to next link with the client's api-version + _parsed_next_link = urlparse(next_link) + _next_request_params = case_insensitive_dict(parse_qs(_parsed_next_link.query)) + _next_request_params["api-version"] = self._config.api_version + request = HttpRequest("GET", urljoin(next_link, _parsed_next_link.path), params=_next_request_params) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore request.method = "GET" return request @@ -6634,10 +7101,8 @@ def extract_data(pipeline_response): def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) response = pipeline_response.http_response @@ -6647,204 +7112,204 @@ def get_next(next_link=None): return pipeline_response + return ItemPaged(get_next, extract_data) - return ItemPaged( - get_next, extract_data - ) - list_by_resource_group.metadata = {'url': "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/Microsoft.Resources/deployments/"} # type: ignore + list_by_resource_group.metadata = {"url": "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/Microsoft.Resources/deployments/"} # type: ignore @distributed_trace - def calculate_template_hash( - self, - template: Any, - **kwargs: Any - ) -> "_models.TemplateHashResult": + def calculate_template_hash(self, template: JSON, **kwargs: Any) -> _models.TemplateHashResult: """Calculate the hash of the given template. - :param template: The template provided to calculate hash. - :type template: any + :param template: The template provided to calculate hash. Required. + :type template: JSON :keyword callable cls: A custom type or function that will be passed the direct response - :return: TemplateHashResult, or the result of cls(response) + :return: TemplateHashResult or the result of cls(response) :rtype: ~azure.mgmt.resource.resources.v2019_07_01.models.TemplateHashResult - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.TemplateHashResult"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', "2019-07-01") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + api_version = kwargs.pop("api_version", _params.pop("api-version", "2019-07-01")) # type: str + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", "application/json")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[_models.TemplateHashResult] - _json = self._serialize.body(template, 'object') + _json = self._serialize.body(template, "object") request = build_deployments_calculate_template_hash_request( api_version=api_version, content_type=content_type, json=_json, - template_url=self.calculate_template_hash.metadata['url'], + template_url=self.calculate_template_hash.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) - deserialized = self._deserialize('TemplateHashResult', pipeline_response) + deserialized = self._deserialize("TemplateHashResult", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - calculate_template_hash.metadata = {'url': "/providers/Microsoft.Resources/calculateTemplateHash"} # type: ignore + calculate_template_hash.metadata = {"url": "/providers/Microsoft.Resources/calculateTemplateHash"} # type: ignore -class ProvidersOperations(object): - """ProvidersOperations operations. - You should not instantiate this class directly. Instead, you should create a Client instance that - instantiates it for you and attaches it as an attribute. +class ProvidersOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. - :ivar models: Alias to model classes used in this operation group. - :type models: ~azure.mgmt.resource.resources.v2019_07_01.models - :param client: Client for service requests. - :param config: Configuration of service client. - :param serializer: An object model serializer. - :param deserializer: An object model deserializer. + Instead, you should access the following operations through + :class:`~azure.mgmt.resource.resources.v2019_07_01.ResourceManagementClient`'s + :attr:`providers` attribute. """ models = _models - def __init__(self, client, config, serializer, deserializer): - self._client = client - self._serialize = serializer - self._deserialize = deserializer - self._config = config + def __init__(self, *args, **kwargs): + input_args = list(args) + self._client = input_args.pop(0) if input_args else kwargs.pop("client") + self._config = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") @distributed_trace - def unregister( - self, - resource_provider_namespace: str, - **kwargs: Any - ) -> "_models.Provider": + def unregister(self, resource_provider_namespace: str, **kwargs: Any) -> _models.Provider: """Unregisters a subscription from a resource provider. :param resource_provider_namespace: The namespace of the resource provider to unregister. + Required. :type resource_provider_namespace: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: Provider, or the result of cls(response) + :return: Provider or the result of cls(response) :rtype: ~azure.mgmt.resource.resources.v2019_07_01.models.Provider - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.Provider"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + 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', "2019-07-01") # type: str + api_version = kwargs.pop("api_version", _params.pop("api-version", "2019-07-01")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[_models.Provider] - request = build_providers_unregister_request( resource_provider_namespace=resource_provider_namespace, subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.unregister.metadata['url'], + template_url=self.unregister.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) - deserialized = self._deserialize('Provider', pipeline_response) + deserialized = self._deserialize("Provider", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - unregister.metadata = {'url': "/subscriptions/{subscriptionId}/providers/{resourceProviderNamespace}/unregister"} # type: ignore - + unregister.metadata = {"url": "/subscriptions/{subscriptionId}/providers/{resourceProviderNamespace}/unregister"} # type: ignore @distributed_trace - def register( - self, - resource_provider_namespace: str, - **kwargs: Any - ) -> "_models.Provider": + def register(self, resource_provider_namespace: str, **kwargs: Any) -> _models.Provider: """Registers a subscription with a resource provider. :param resource_provider_namespace: The namespace of the resource provider to register. + Required. :type resource_provider_namespace: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: Provider, or the result of cls(response) + :return: Provider or the result of cls(response) :rtype: ~azure.mgmt.resource.resources.v2019_07_01.models.Provider - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.Provider"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + 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', "2019-07-01") # type: str + api_version = kwargs.pop("api_version", _params.pop("api-version", "2019-07-01")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[_models.Provider] - request = build_providers_register_request( resource_provider_namespace=resource_provider_namespace, subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.register.metadata['url'], + template_url=self.register.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) - deserialized = self._deserialize('Provider', pipeline_response) + deserialized = self._deserialize("Provider", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - register.metadata = {'url': "/subscriptions/{subscriptionId}/providers/{resourceProviderNamespace}/register"} # type: ignore - + register.metadata = {"url": "/subscriptions/{subscriptionId}/providers/{resourceProviderNamespace}/register"} # type: ignore @distributed_trace def list( - self, - top: Optional[int] = None, - expand: Optional[str] = None, - **kwargs: Any - ) -> Iterable["_models.ProviderListResult"]: + self, top: Optional[int] = None, expand: Optional[str] = None, **kwargs: Any + ) -> Iterable["_models.Provider"]: """Gets all resource providers for a subscription. :param top: The number of results to return. If null is passed returns all deployments. Default @@ -6855,39 +7320,48 @@ def list( response, use $expand=resourceTypes/aliases. Default value is None. :type expand: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either ProviderListResult or the result of cls(response) + :return: An iterator like instance of either Provider or the result of cls(response) :rtype: - ~azure.core.paging.ItemPaged[~azure.mgmt.resource.resources.v2019_07_01.models.ProviderListResult] - :raises: ~azure.core.exceptions.HttpResponseError + ~azure.core.paging.ItemPaged[~azure.mgmt.resource.resources.v2019_07_01.models.Provider] + :raises ~azure.core.exceptions.HttpResponseError: """ - api_version = kwargs.pop('api_version', "2019-07-01") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2019-07-01")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[_models.ProviderListResult] - cls = kwargs.pop('cls', None) # type: ClsType["_models.ProviderListResult"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) + def prepare_request(next_link=None): if not next_link: - + request = build_providers_list_request( subscription_id=self._config.subscription_id, - api_version=api_version, top=top, expand=expand, - template_url=self.list.metadata['url'], + 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.url = self._client.format_url(request.url) # type: ignore else: - - request = build_providers_list_request( - subscription_id=self._config.subscription_id, - template_url=next_link, - ) + # make call to next link with the client's api-version + _parsed_next_link = urlparse(next_link) + _next_request_params = case_insensitive_dict(parse_qs(_parsed_next_link.query)) + _next_request_params["api-version"] = self._config.api_version + request = HttpRequest("GET", urljoin(next_link, _parsed_next_link.path), params=_next_request_params) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore request.method = "GET" return request @@ -6901,10 +7375,8 @@ def extract_data(pipeline_response): def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) response = pipeline_response.http_response @@ -6914,19 +7386,14 @@ def get_next(next_link=None): return pipeline_response + return ItemPaged(get_next, extract_data) - return ItemPaged( - get_next, extract_data - ) - list.metadata = {'url': "/subscriptions/{subscriptionId}/providers"} # type: ignore + list.metadata = {"url": "/subscriptions/{subscriptionId}/providers"} # type: ignore @distributed_trace def list_at_tenant_scope( - self, - top: Optional[int] = None, - expand: Optional[str] = None, - **kwargs: Any - ) -> Iterable["_models.ProviderListResult"]: + self, top: Optional[int] = None, expand: Optional[str] = None, **kwargs: Any + ) -> Iterable["_models.Provider"]: """Gets all resource providers for the tenant. :param top: The number of results to return. If null is passed returns all providers. Default @@ -6937,37 +7404,47 @@ def list_at_tenant_scope( response, use $expand=resourceTypes/aliases. Default value is None. :type expand: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either ProviderListResult or the result of cls(response) + :return: An iterator like instance of either Provider or the result of cls(response) :rtype: - ~azure.core.paging.ItemPaged[~azure.mgmt.resource.resources.v2019_07_01.models.ProviderListResult] - :raises: ~azure.core.exceptions.HttpResponseError + ~azure.core.paging.ItemPaged[~azure.mgmt.resource.resources.v2019_07_01.models.Provider] + :raises ~azure.core.exceptions.HttpResponseError: """ - api_version = kwargs.pop('api_version', "2019-07-01") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2019-07-01")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[_models.ProviderListResult] - cls = kwargs.pop('cls', None) # type: ClsType["_models.ProviderListResult"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) + def prepare_request(next_link=None): if not next_link: - + request = build_providers_list_at_tenant_scope_request( - api_version=api_version, top=top, expand=expand, - template_url=self.list_at_tenant_scope.metadata['url'], + api_version=api_version, + template_url=self.list_at_tenant_scope.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore else: - - request = build_providers_list_at_tenant_scope_request( - template_url=next_link, - ) + # make call to next link with the client's api-version + _parsed_next_link = urlparse(next_link) + _next_request_params = case_insensitive_dict(parse_qs(_parsed_next_link.query)) + _next_request_params["api-version"] = self._config.api_version + request = HttpRequest("GET", urljoin(next_link, _parsed_next_link.path), params=_next_request_params) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore request.method = "GET" return request @@ -6981,10 +7458,8 @@ def extract_data(pipeline_response): def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) response = pipeline_response.http_response @@ -6994,149 +7469,148 @@ def get_next(next_link=None): return pipeline_response + return ItemPaged(get_next, extract_data) - return ItemPaged( - get_next, extract_data - ) - list_at_tenant_scope.metadata = {'url': "/providers"} # type: ignore + list_at_tenant_scope.metadata = {"url": "/providers"} # type: ignore @distributed_trace - def get( - self, - resource_provider_namespace: str, - expand: Optional[str] = None, - **kwargs: Any - ) -> "_models.Provider": + def get(self, resource_provider_namespace: str, expand: Optional[str] = None, **kwargs: Any) -> _models.Provider: """Gets the specified resource provider. - :param resource_provider_namespace: The namespace of the resource provider. + :param resource_provider_namespace: The namespace of the resource provider. Required. :type resource_provider_namespace: str :param expand: The $expand query parameter. For example, to include property aliases in response, use $expand=resourceTypes/aliases. Default value is None. :type expand: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: Provider, or the result of cls(response) + :return: Provider or the result of cls(response) :rtype: ~azure.mgmt.resource.resources.v2019_07_01.models.Provider - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.Provider"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) - api_version = kwargs.pop('api_version', "2019-07-01") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2019-07-01")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[_models.Provider] - request = build_providers_get_request( resource_provider_namespace=resource_provider_namespace, subscription_id=self._config.subscription_id, - api_version=api_version, expand=expand, - template_url=self.get.metadata['url'], + api_version=api_version, + template_url=self.get.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) - deserialized = self._deserialize('Provider', pipeline_response) + deserialized = self._deserialize("Provider", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - get.metadata = {'url': "/subscriptions/{subscriptionId}/providers/{resourceProviderNamespace}"} # type: ignore - + get.metadata = {"url": "/subscriptions/{subscriptionId}/providers/{resourceProviderNamespace}"} # type: ignore @distributed_trace def get_at_tenant_scope( - self, - resource_provider_namespace: str, - expand: Optional[str] = None, - **kwargs: Any - ) -> "_models.Provider": + self, resource_provider_namespace: str, expand: Optional[str] = None, **kwargs: Any + ) -> _models.Provider: """Gets the specified resource provider at the tenant level. - :param resource_provider_namespace: The namespace of the resource provider. + :param resource_provider_namespace: The namespace of the resource provider. Required. :type resource_provider_namespace: str :param expand: The $expand query parameter. For example, to include property aliases in response, use $expand=resourceTypes/aliases. Default value is None. :type expand: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: Provider, or the result of cls(response) + :return: Provider or the result of cls(response) :rtype: ~azure.mgmt.resource.resources.v2019_07_01.models.Provider - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.Provider"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + 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', "2019-07-01") # type: str + api_version = kwargs.pop("api_version", _params.pop("api-version", "2019-07-01")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[_models.Provider] - request = build_providers_get_at_tenant_scope_request( resource_provider_namespace=resource_provider_namespace, - api_version=api_version, expand=expand, - template_url=self.get_at_tenant_scope.metadata['url'], + api_version=api_version, + template_url=self.get_at_tenant_scope.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) - deserialized = self._deserialize('Provider', pipeline_response) + deserialized = self._deserialize("Provider", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - get_at_tenant_scope.metadata = {'url': "/providers/{resourceProviderNamespace}"} # type: ignore + get_at_tenant_scope.metadata = {"url": "/providers/{resourceProviderNamespace}"} # type: ignore -class ResourcesOperations(object): # pylint: disable=too-many-public-methods - """ResourcesOperations operations. - You should not instantiate this class directly. Instead, you should create a Client instance that - instantiates it for you and attaches it as an attribute. +class ResourcesOperations: # pylint: disable=too-many-public-methods + """ + .. warning:: + **DO NOT** instantiate this class directly. - :ivar models: Alias to model classes used in this operation group. - :type models: ~azure.mgmt.resource.resources.v2019_07_01.models - :param client: Client for service requests. - :param config: Configuration of service client. - :param serializer: An object model serializer. - :param deserializer: An object model deserializer. + Instead, you should access the following operations through + :class:`~azure.mgmt.resource.resources.v2019_07_01.ResourceManagementClient`'s + :attr:`resources` attribute. """ models = _models - def __init__(self, client, config, serializer, deserializer): - self._client = client - self._serialize = serializer - self._deserialize = deserializer - self._config = config + def __init__(self, *args, **kwargs): + input_args = list(args) + self._client = input_args.pop(0) if input_args else kwargs.pop("client") + self._config = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") @distributed_trace def list_by_resource_group( @@ -7146,10 +7620,10 @@ def list_by_resource_group( expand: Optional[str] = None, top: Optional[int] = None, **kwargs: Any - ) -> Iterable["_models.ResourceListResult"]: + ) -> Iterable["_models.GenericResourceExpanded"]: """Get all the resources for a resource group. - :param resource_group_name: The resource group with the resources to get. + :param resource_group_name: The resource group with the resources to get. Required. :type resource_group_name: str :param filter: The filter to apply on the operation.:code:`
`:code:`
`The properties you can use for eq (equals) or ne (not equals) are: location, resourceType, name, resourceGroup, @@ -7174,42 +7648,51 @@ def list_by_resource_group( value is None. :type top: int :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either ResourceListResult or the result of cls(response) + :return: An iterator like instance of either GenericResourceExpanded or the result of + cls(response) :rtype: - ~azure.core.paging.ItemPaged[~azure.mgmt.resource.resources.v2019_07_01.models.ResourceListResult] - :raises: ~azure.core.exceptions.HttpResponseError + ~azure.core.paging.ItemPaged[~azure.mgmt.resource.resources.v2019_07_01.models.GenericResourceExpanded] + :raises ~azure.core.exceptions.HttpResponseError: """ - api_version = kwargs.pop('api_version', "2019-07-01") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2019-07-01")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[_models.ResourceListResult] - cls = kwargs.pop('cls', None) # type: ClsType["_models.ResourceListResult"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) + def prepare_request(next_link=None): if not next_link: - + request = build_resources_list_by_resource_group_request( resource_group_name=resource_group_name, subscription_id=self._config.subscription_id, - api_version=api_version, filter=filter, expand=expand, top=top, - template_url=self.list_by_resource_group.metadata['url'], + 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.url = self._client.format_url(request.url) # type: ignore else: - - request = build_resources_list_by_resource_group_request( - resource_group_name=resource_group_name, - subscription_id=self._config.subscription_id, - template_url=next_link, - ) + # make call to next link with the client's api-version + _parsed_next_link = urlparse(next_link) + _next_request_params = case_insensitive_dict(parse_qs(_parsed_next_link.query)) + _next_request_params["api-version"] = self._config.api_version + request = HttpRequest("GET", urljoin(next_link, _parsed_next_link.path), params=_next_request_params) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore request.method = "GET" return request @@ -7223,10 +7706,8 @@ def extract_data(pipeline_response): def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) response = pipeline_response.http_response @@ -7236,45 +7717,54 @@ def get_next(next_link=None): return pipeline_response + return ItemPaged(get_next, extract_data) - return ItemPaged( - get_next, extract_data - ) - list_by_resource_group.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/resources"} # type: ignore + list_by_resource_group.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/resources"} # type: ignore def _move_resources_initial( # pylint: disable=inconsistent-return-statements - self, - source_resource_group_name: str, - parameters: "_models.ResourcesMoveInfo", - **kwargs: Any + self, source_resource_group_name: str, parameters: Union[_models.ResourcesMoveInfo, IO], **kwargs: Any ) -> None: - cls = kwargs.pop('cls', None) # type: ClsType[None] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', "2019-07-01") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + api_version = kwargs.pop("api_version", _params.pop("api-version", "2019-07-01")) # type: str + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[None] - _json = self._serialize.body(parameters, 'ResourcesMoveInfo') + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(parameters, (IO, bytes)): + _content = parameters + else: + _json = self._serialize.body(parameters, "ResourcesMoveInfo") - request = build_resources_move_resources_request_initial( + request = build_resources_move_resources_request( source_resource_group_name=source_resource_group_name, subscription_id=self._config.subscription_id, api_version=api_version, content_type=content_type, json=_json, - template_url=self._move_resources_initial.metadata['url'], + content=_content, + template_url=self._move_resources_initial.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [202, 204]: @@ -7284,14 +7774,15 @@ def _move_resources_initial( # pylint: disable=inconsistent-return-statements if cls: return cls(pipeline_response, None, {}) - _move_resources_initial.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{sourceResourceGroupName}/moveResources"} # type: ignore - + _move_resources_initial.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{sourceResourceGroupName}/moveResources"} # type: ignore - @distributed_trace - def begin_move_resources( # pylint: disable=inconsistent-return-statements + @overload + def begin_move_resources( self, source_resource_group_name: str, - parameters: "_models.ResourcesMoveInfo", + parameters: _models.ResourcesMoveInfo, + *, + content_type: str = "application/json", **kwargs: Any ) -> LROPoller[None]: """Moves resources from one resource group to another resource group. @@ -7302,10 +7793,13 @@ def begin_move_resources( # pylint: disable=inconsistent-return-statements the groups until the move completes. :param source_resource_group_name: The name of the resource group containing the resources to - move. + move. Required. :type source_resource_group_name: str - :param parameters: Parameters for moving resources. + :param parameters: Parameters for moving resources. Required. :type parameters: ~azure.mgmt.resource.resources.v2019_07_01.models.ResourcesMoveInfo + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str :keyword callable cls: A custom type or function that will be passed the direct response :keyword str continuation_token: A continuation token to restart a poller from a saved state. :keyword polling: By default, your polling method will be ARMPolling. Pass in False for this @@ -7316,80 +7810,160 @@ def begin_move_resources( # pylint: disable=inconsistent-return-statements Retry-After header is present. :return: An instance of LROPoller that returns either None or the result of cls(response) :rtype: ~azure.core.polling.LROPoller[None] - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - api_version = kwargs.pop('api_version', "2019-07-01") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] - polling = kwargs.pop('polling', True) # type: Union[bool, PollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType[None] - lro_delay = kwargs.pop( - 'polling_interval', - self._config.polling_interval - ) - cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] + + @overload + def begin_move_resources( + self, source_resource_group_name: str, parameters: IO, *, content_type: str = "application/json", **kwargs: Any + ) -> LROPoller[None]: + """Moves resources from one resource group to another resource group. + + The resources to move must be in the same source resource group. The target resource group may + be in a different subscription. When moving resources, both the source group and the target + group are locked for the duration of the operation. Write and delete operations are blocked on + the groups until the move completes. + + :param source_resource_group_name: The name of the resource group containing the resources to + move. Required. + :type source_resource_group_name: str + :param parameters: Parameters for moving resources. Required. + :type parameters: IO + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be ARMPolling. Pass in False for this + operation to not poll, or pass in your own initialized polling object for a personal polling + strategy. + :paramtype polling: bool or ~azure.core.polling.PollingMethod + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of LROPoller that returns either None or the result of cls(response) + :rtype: ~azure.core.polling.LROPoller[None] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace + def begin_move_resources( + self, source_resource_group_name: str, parameters: Union[_models.ResourcesMoveInfo, IO], **kwargs: Any + ) -> LROPoller[None]: + """Moves resources from one resource group to another resource group. + + The resources to move must be in the same source resource group. The target resource group may + be in a different subscription. When moving resources, both the source group and the target + group are locked for the duration of the operation. Write and delete operations are blocked on + the groups until the move completes. + + :param source_resource_group_name: The name of the resource group containing the resources to + move. Required. + :type source_resource_group_name: str + :param parameters: Parameters for moving resources. Is either a model type or a IO type. + Required. + :type parameters: ~azure.mgmt.resource.resources.v2019_07_01.models.ResourcesMoveInfo or IO + :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. + Default value is None. + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be ARMPolling. Pass in False for this + operation to not poll, or pass in your own initialized polling object for a personal polling + strategy. + :paramtype polling: bool or ~azure.core.polling.PollingMethod + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of LROPoller that returns either None or the result of cls(response) + :rtype: ~azure.core.polling.LROPoller[None] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _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", "2019-07-01")) # type: str + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[None] + polling = kwargs.pop("polling", True) # type: Union[bool, PollingMethod] + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token = kwargs.pop("continuation_token", None) # type: Optional[str] if cont_token is None: - raw_result = self._move_resources_initial( + raw_result = self._move_resources_initial( # type: ignore source_resource_group_name=source_resource_group_name, parameters=parameters, api_version=api_version, content_type=content_type, - cls=lambda x,y,z: x, + cls=lambda x, y, z: x, + headers=_headers, + params=_params, **kwargs ) - kwargs.pop('error_map', None) + kwargs.pop("error_map", None) - def get_long_running_output(pipeline_response): + def get_long_running_output(pipeline_response): # pylint: disable=inconsistent-return-statements if cls: return cls(pipeline_response, None, {}) - - if polling is True: polling_method = ARMPolling(lro_delay, **kwargs) - elif polling is False: polling_method = NoPolling() - else: polling_method = polling + if polling is True: + polling_method = cast(PollingMethod, ARMPolling(lro_delay, **kwargs)) # type: PollingMethod + elif polling is False: + polling_method = cast(PollingMethod, NoPolling()) + else: + polling_method = polling if cont_token: return LROPoller.from_continuation_token( polling_method=polling_method, continuation_token=cont_token, client=self._client, - deserialization_callback=get_long_running_output + deserialization_callback=get_long_running_output, ) return LROPoller(self._client, raw_result, get_long_running_output, polling_method) - begin_move_resources.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{sourceResourceGroupName}/moveResources"} # type: ignore + begin_move_resources.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{sourceResourceGroupName}/moveResources"} # type: ignore def _validate_move_resources_initial( # pylint: disable=inconsistent-return-statements - self, - source_resource_group_name: str, - parameters: "_models.ResourcesMoveInfo", - **kwargs: Any + self, source_resource_group_name: str, parameters: Union[_models.ResourcesMoveInfo, IO], **kwargs: Any ) -> None: - cls = kwargs.pop('cls', None) # type: ClsType[None] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', "2019-07-01") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + api_version = kwargs.pop("api_version", _params.pop("api-version", "2019-07-01")) # type: str + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[None] - _json = self._serialize.body(parameters, 'ResourcesMoveInfo') + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(parameters, (IO, bytes)): + _content = parameters + else: + _json = self._serialize.body(parameters, "ResourcesMoveInfo") - request = build_resources_validate_move_resources_request_initial( + request = build_resources_validate_move_resources_request( source_resource_group_name=source_resource_group_name, subscription_id=self._config.subscription_id, api_version=api_version, content_type=content_type, json=_json, - template_url=self._validate_move_resources_initial.metadata['url'], + content=_content, + template_url=self._validate_move_resources_initial.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [202, 204]: @@ -7399,14 +7973,15 @@ def _validate_move_resources_initial( # pylint: disable=inconsistent-return-sta if cls: return cls(pipeline_response, None, {}) - _validate_move_resources_initial.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{sourceResourceGroupName}/validateMoveResources"} # type: ignore - + _validate_move_resources_initial.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{sourceResourceGroupName}/validateMoveResources"} # type: ignore - @distributed_trace - def begin_validate_move_resources( # pylint: disable=inconsistent-return-statements + @overload + def begin_validate_move_resources( self, source_resource_group_name: str, - parameters: "_models.ResourcesMoveInfo", + parameters: _models.ResourcesMoveInfo, + *, + content_type: str = "application/json", **kwargs: Any ) -> LROPoller[None]: """Validates whether resources can be moved from one resource group to another resource group. @@ -7419,10 +7994,13 @@ def begin_validate_move_resources( # pylint: disable=inconsistent-return-statem operation. :param source_resource_group_name: The name of the resource group containing the resources to - validate for move. + validate for move. Required. :type source_resource_group_name: str - :param parameters: Parameters for moving resources. + :param parameters: Parameters for moving resources. Required. :type parameters: ~azure.mgmt.resource.resources.v2019_07_01.models.ResourcesMoveInfo + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str :keyword callable cls: A custom type or function that will be passed the direct response :keyword str continuation_token: A continuation token to restart a poller from a saved state. :keyword polling: By default, your polling method will be ARMPolling. Pass in False for this @@ -7433,56 +8011,125 @@ def begin_validate_move_resources( # pylint: disable=inconsistent-return-statem Retry-After header is present. :return: An instance of LROPoller that returns either None or the result of cls(response) :rtype: ~azure.core.polling.LROPoller[None] - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - api_version = kwargs.pop('api_version', "2019-07-01") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] - polling = kwargs.pop('polling', True) # type: Union[bool, PollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType[None] - lro_delay = kwargs.pop( - 'polling_interval', - self._config.polling_interval - ) - cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] - if cont_token is None: - raw_result = self._validate_move_resources_initial( - source_resource_group_name=source_resource_group_name, - parameters=parameters, - api_version=api_version, - content_type=content_type, - cls=lambda x,y,z: x, - **kwargs - ) - kwargs.pop('error_map', None) - - def get_long_running_output(pipeline_response): - if cls: - return cls(pipeline_response, None, {}) - - - if polling is True: polling_method = ARMPolling(lro_delay, **kwargs) - elif polling is False: polling_method = NoPolling() - else: polling_method = polling - if cont_token: - return LROPoller.from_continuation_token( - polling_method=polling_method, - continuation_token=cont_token, - client=self._client, - deserialization_callback=get_long_running_output - ) - return LROPoller(self._client, raw_result, get_long_running_output, polling_method) - begin_validate_move_resources.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{sourceResourceGroupName}/validateMoveResources"} # type: ignore + @overload + def begin_validate_move_resources( + self, source_resource_group_name: str, parameters: IO, *, content_type: str = "application/json", **kwargs: Any + ) -> LROPoller[None]: + """Validates whether resources can be moved from one resource group to another resource group. - @distributed_trace - def list( - self, - filter: Optional[str] = None, - expand: Optional[str] = None, - top: Optional[int] = None, - **kwargs: Any - ) -> Iterable["_models.ResourceListResult"]: - """Get all the resources in a subscription. + This operation checks whether the specified resources can be moved to the target. The resources + to move must be in the same source resource group. The target resource group may be in a + different subscription. If validation succeeds, it returns HTTP response code 204 (no content). + If validation fails, it returns HTTP response code 409 (Conflict) with an error message. + Retrieve the URL in the Location header value to check the result of the long-running + operation. + + :param source_resource_group_name: The name of the resource group containing the resources to + validate for move. Required. + :type source_resource_group_name: str + :param parameters: Parameters for moving resources. Required. + :type parameters: IO + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be ARMPolling. Pass in False for this + operation to not poll, or pass in your own initialized polling object for a personal polling + strategy. + :paramtype polling: bool or ~azure.core.polling.PollingMethod + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of LROPoller that returns either None or the result of cls(response) + :rtype: ~azure.core.polling.LROPoller[None] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace + def begin_validate_move_resources( + self, source_resource_group_name: str, parameters: Union[_models.ResourcesMoveInfo, IO], **kwargs: Any + ) -> LROPoller[None]: + """Validates whether resources can be moved from one resource group to another resource group. + + This operation checks whether the specified resources can be moved to the target. The resources + to move must be in the same source resource group. The target resource group may be in a + different subscription. If validation succeeds, it returns HTTP response code 204 (no content). + If validation fails, it returns HTTP response code 409 (Conflict) with an error message. + Retrieve the URL in the Location header value to check the result of the long-running + operation. + + :param source_resource_group_name: The name of the resource group containing the resources to + validate for move. Required. + :type source_resource_group_name: str + :param parameters: Parameters for moving resources. Is either a model type or a IO type. + Required. + :type parameters: ~azure.mgmt.resource.resources.v2019_07_01.models.ResourcesMoveInfo or IO + :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. + Default value is None. + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be ARMPolling. Pass in False for this + operation to not poll, or pass in your own initialized polling object for a personal polling + strategy. + :paramtype polling: bool or ~azure.core.polling.PollingMethod + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of LROPoller that returns either None or the result of cls(response) + :rtype: ~azure.core.polling.LROPoller[None] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _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", "2019-07-01")) # type: str + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[None] + polling = kwargs.pop("polling", True) # type: Union[bool, PollingMethod] + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token = kwargs.pop("continuation_token", None) # type: Optional[str] + if cont_token is None: + raw_result = self._validate_move_resources_initial( # type: ignore + source_resource_group_name=source_resource_group_name, + parameters=parameters, + api_version=api_version, + content_type=content_type, + cls=lambda x, y, z: x, + headers=_headers, + params=_params, + **kwargs + ) + kwargs.pop("error_map", None) + + def get_long_running_output(pipeline_response): # pylint: disable=inconsistent-return-statements + if cls: + return cls(pipeline_response, None, {}) + + if polling is True: + polling_method = cast(PollingMethod, ARMPolling(lro_delay, **kwargs)) # type: PollingMethod + elif polling is False: + polling_method = cast(PollingMethod, NoPolling()) + else: + polling_method = polling + if cont_token: + return LROPoller.from_continuation_token( + polling_method=polling_method, + continuation_token=cont_token, + client=self._client, + deserialization_callback=get_long_running_output, + ) + return LROPoller(self._client, raw_result, get_long_running_output, polling_method) + + begin_validate_move_resources.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{sourceResourceGroupName}/validateMoveResources"} # type: ignore + + @distributed_trace + def list( + self, filter: Optional[str] = None, expand: Optional[str] = None, top: Optional[int] = None, **kwargs: Any + ) -> Iterable["_models.GenericResourceExpanded"]: + """Get all the resources in a subscription. :param filter: The filter to apply on the operation.:code:`
`:code:`
`The properties you can use for eq (equals) or ne (not equals) are: location, resourceType, name, resourceGroup, @@ -7507,40 +8154,50 @@ def list( value is None. :type top: int :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either ResourceListResult or the result of cls(response) + :return: An iterator like instance of either GenericResourceExpanded or the result of + cls(response) :rtype: - ~azure.core.paging.ItemPaged[~azure.mgmt.resource.resources.v2019_07_01.models.ResourceListResult] - :raises: ~azure.core.exceptions.HttpResponseError + ~azure.core.paging.ItemPaged[~azure.mgmt.resource.resources.v2019_07_01.models.GenericResourceExpanded] + :raises ~azure.core.exceptions.HttpResponseError: """ - api_version = kwargs.pop('api_version', "2019-07-01") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2019-07-01")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[_models.ResourceListResult] - cls = kwargs.pop('cls', None) # type: ClsType["_models.ResourceListResult"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) + def prepare_request(next_link=None): if not next_link: - + request = build_resources_list_request( subscription_id=self._config.subscription_id, - api_version=api_version, filter=filter, expand=expand, top=top, - template_url=self.list.metadata['url'], + 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.url = self._client.format_url(request.url) # type: ignore else: - - request = build_resources_list_request( - subscription_id=self._config.subscription_id, - template_url=next_link, - ) + # make call to next link with the client's api-version + _parsed_next_link = urlparse(next_link) + _next_request_params = case_insensitive_dict(parse_qs(_parsed_next_link.query)) + _next_request_params["api-version"] = self._config.api_version + request = HttpRequest("GET", urljoin(next_link, _parsed_next_link.path), params=_next_request_params) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore request.method = "GET" return request @@ -7554,10 +8211,8 @@ def extract_data(pipeline_response): def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) response = pipeline_response.http_response @@ -7567,11 +8222,9 @@ def get_next(next_link=None): return pipeline_response + return ItemPaged(get_next, extract_data) - return ItemPaged( - get_next, extract_data - ) - list.metadata = {'url': "/subscriptions/{subscriptionId}/resources"} # type: ignore + list.metadata = {"url": "/subscriptions/{subscriptionId}/resources"} # type: ignore @distributed_trace def check_existence( @@ -7587,30 +8240,36 @@ def check_existence( """Checks whether a resource exists. :param resource_group_name: The name of the resource group containing the resource to check. - The name is case insensitive. + The name is case insensitive. Required. :type resource_group_name: str - :param resource_provider_namespace: The resource provider of the resource to check. + :param resource_provider_namespace: The resource provider of the resource to check. Required. :type resource_provider_namespace: str - :param parent_resource_path: The parent resource identity. + :param parent_resource_path: The parent resource identity. Required. :type parent_resource_path: str - :param resource_type: The resource type. + :param resource_type: The resource type. Required. :type resource_type: str - :param resource_name: The name of the resource to check whether it exists. + :param resource_name: The name of the resource to check whether it exists. Required. :type resource_name: str - :param api_version: The API version to use for the operation. + :param api_version: The API version to use for the operation. Required. :type api_version: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: bool, or the result of cls(response) + :return: bool or the result of cls(response) :rtype: bool - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType[None] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = kwargs.pop("params", {}) or {} + + cls = kwargs.pop("cls", None) # type: ClsType[None] - request = build_resources_check_existence_request( resource_group_name=resource_group_name, resource_provider_namespace=resource_provider_namespace, @@ -7619,16 +8278,17 @@ def check_existence( resource_name=resource_name, subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.check_existence.metadata['url'], + template_url=self.check_existence.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [204, 404]: @@ -7639,8 +8299,7 @@ def check_existence( return cls(pipeline_response, None, {}) return 200 <= response.status_code <= 299 - check_existence.metadata = {'url': "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{parentResourcePath}/{resourceType}/{resourceName}"} # type: ignore - + check_existence.metadata = {"url": "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{parentResourcePath}/{resourceType}/{resourceName}"} # type: ignore def _delete_initial( # pylint: disable=inconsistent-return-statements self, @@ -7652,14 +8311,20 @@ def _delete_initial( # pylint: disable=inconsistent-return-statements api_version: str, **kwargs: Any ) -> None: - cls = kwargs.pop('cls', None) # type: ClsType[None] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = kwargs.pop("params", {}) or {} - - request = build_resources_delete_request_initial( + cls = kwargs.pop("cls", None) # type: ClsType[None] + + request = build_resources_delete_request( resource_group_name=resource_group_name, resource_provider_namespace=resource_provider_namespace, parent_resource_path=parent_resource_path, @@ -7667,16 +8332,17 @@ def _delete_initial( # pylint: disable=inconsistent-return-statements resource_name=resource_name, subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self._delete_initial.metadata['url'], + template_url=self._delete_initial.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200, 202, 204]: @@ -7686,11 +8352,10 @@ def _delete_initial( # pylint: disable=inconsistent-return-statements if cls: return cls(pipeline_response, None, {}) - _delete_initial.metadata = {'url': "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{parentResourcePath}/{resourceType}/{resourceName}"} # type: ignore - + _delete_initial.metadata = {"url": "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{parentResourcePath}/{resourceType}/{resourceName}"} # type: ignore @distributed_trace - def begin_delete( # pylint: disable=inconsistent-return-statements + def begin_delete( self, resource_group_name: str, resource_provider_namespace: str, @@ -7703,17 +8368,17 @@ def begin_delete( # pylint: disable=inconsistent-return-statements """Deletes a resource. :param resource_group_name: The name of the resource group that contains the resource to - delete. The name is case insensitive. + delete. The name is case insensitive. Required. :type resource_group_name: str - :param resource_provider_namespace: The namespace of the resource provider. + :param resource_provider_namespace: The namespace of the resource provider. Required. :type resource_provider_namespace: str - :param parent_resource_path: The parent resource identity. + :param parent_resource_path: The parent resource identity. Required. :type parent_resource_path: str - :param resource_type: The resource type. + :param resource_type: The resource type. Required. :type resource_type: str - :param resource_name: The name of the resource to delete. + :param resource_name: The name of the resource to delete. Required. :type resource_name: str - :param api_version: The API version to use for the operation. + :param api_version: The API version to use for the operation. Required. :type api_version: str :keyword callable cls: A custom type or function that will be passed the direct response :keyword str continuation_token: A continuation token to restart a poller from a saved state. @@ -7725,46 +8390,50 @@ def begin_delete( # pylint: disable=inconsistent-return-statements Retry-After header is present. :return: An instance of LROPoller that returns either None or the result of cls(response) :rtype: ~azure.core.polling.LROPoller[None] - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - polling = kwargs.pop('polling', True) # type: Union[bool, PollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType[None] - lro_delay = kwargs.pop( - 'polling_interval', - self._config.polling_interval - ) - cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] + _headers = kwargs.pop("headers", {}) or {} + _params = kwargs.pop("params", {}) or {} + + cls = kwargs.pop("cls", None) # type: ClsType[None] + polling = kwargs.pop("polling", True) # type: Union[bool, PollingMethod] + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token = kwargs.pop("continuation_token", None) # type: Optional[str] if cont_token is None: - raw_result = self._delete_initial( + raw_result = self._delete_initial( # type: ignore resource_group_name=resource_group_name, resource_provider_namespace=resource_provider_namespace, parent_resource_path=parent_resource_path, resource_type=resource_type, resource_name=resource_name, api_version=api_version, - cls=lambda x,y,z: x, + cls=lambda x, y, z: x, + headers=_headers, + params=_params, **kwargs ) - kwargs.pop('error_map', None) + kwargs.pop("error_map", None) - def get_long_running_output(pipeline_response): + def get_long_running_output(pipeline_response): # pylint: disable=inconsistent-return-statements if cls: return cls(pipeline_response, None, {}) - - if polling is True: polling_method = ARMPolling(lro_delay, **kwargs) - elif polling is False: polling_method = NoPolling() - else: polling_method = polling + if polling is True: + polling_method = cast(PollingMethod, ARMPolling(lro_delay, **kwargs)) # type: PollingMethod + elif polling is False: + polling_method = cast(PollingMethod, NoPolling()) + else: + polling_method = polling if cont_token: return LROPoller.from_continuation_token( polling_method=polling_method, continuation_token=cont_token, client=self._client, - deserialization_callback=get_long_running_output + deserialization_callback=get_long_running_output, ) return LROPoller(self._client, raw_result, get_long_running_output, polling_method) - begin_delete.metadata = {'url': "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{parentResourcePath}/{resourceType}/{resourceName}"} # type: ignore + begin_delete.metadata = {"url": "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{parentResourcePath}/{resourceType}/{resourceName}"} # type: ignore def _create_or_update_initial( self, @@ -7774,39 +8443,53 @@ def _create_or_update_initial( resource_type: str, resource_name: str, api_version: str, - parameters: "_models.GenericResource", + parameters: Union[_models.GenericResource, IO], **kwargs: Any - ) -> Optional["_models.GenericResource"]: - cls = kwargs.pop('cls', None) # type: ClsType[Optional["_models.GenericResource"]] + ) -> Optional[_models.GenericResource]: error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = kwargs.pop("params", {}) or {} - _json = self._serialize.body(parameters, 'GenericResource') + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[Optional[_models.GenericResource]] - request = build_resources_create_or_update_request_initial( + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(parameters, (IO, bytes)): + _content = parameters + else: + _json = self._serialize.body(parameters, "GenericResource") + + request = build_resources_create_or_update_request( resource_group_name=resource_group_name, resource_provider_namespace=resource_provider_namespace, parent_resource_path=parent_resource_path, resource_type=resource_type, resource_name=resource_name, subscription_id=self._config.subscription_id, - content_type=content_type, api_version=api_version, + content_type=content_type, json=_json, - template_url=self._create_or_update_initial.metadata['url'], + content=_content, + template_url=self._create_or_update_initial.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200, 201, 202]: @@ -7815,18 +8498,115 @@ def _create_or_update_initial( deserialized = None if response.status_code == 200: - deserialized = self._deserialize('GenericResource', pipeline_response) + deserialized = self._deserialize("GenericResource", pipeline_response) if response.status_code == 201: - deserialized = self._deserialize('GenericResource', pipeline_response) + deserialized = self._deserialize("GenericResource", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - _create_or_update_initial.metadata = {'url': "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{parentResourcePath}/{resourceType}/{resourceName}"} # type: ignore + _create_or_update_initial.metadata = {"url": "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{parentResourcePath}/{resourceType}/{resourceName}"} # type: ignore + + @overload + def begin_create_or_update( + self, + resource_group_name: str, + resource_provider_namespace: str, + parent_resource_path: str, + resource_type: str, + resource_name: str, + api_version: str, + parameters: _models.GenericResource, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> LROPoller[_models.GenericResource]: + """Creates a resource. + + :param resource_group_name: The name of the resource group for the resource. The name is case + insensitive. Required. + :type resource_group_name: str + :param resource_provider_namespace: The namespace of the resource provider. Required. + :type resource_provider_namespace: str + :param parent_resource_path: The parent resource identity. Required. + :type parent_resource_path: str + :param resource_type: The resource type of the resource to create. Required. + :type resource_type: str + :param resource_name: The name of the resource to create. Required. + :type resource_name: str + :param api_version: The API version to use for the operation. Required. + :type api_version: str + :param parameters: Parameters for creating or updating the resource. Required. + :type parameters: ~azure.mgmt.resource.resources.v2019_07_01.models.GenericResource + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be ARMPolling. Pass in False for this + operation to not poll, or pass in your own initialized polling object for a personal polling + strategy. + :paramtype polling: bool or ~azure.core.polling.PollingMethod + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of LROPoller that returns either GenericResource or the result of + cls(response) + :rtype: + ~azure.core.polling.LROPoller[~azure.mgmt.resource.resources.v2019_07_01.models.GenericResource] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + def begin_create_or_update( + self, + resource_group_name: str, + resource_provider_namespace: str, + parent_resource_path: str, + resource_type: str, + resource_name: str, + api_version: str, + parameters: IO, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> LROPoller[_models.GenericResource]: + """Creates a resource. + :param resource_group_name: The name of the resource group for the resource. The name is case + insensitive. Required. + :type resource_group_name: str + :param resource_provider_namespace: The namespace of the resource provider. Required. + :type resource_provider_namespace: str + :param parent_resource_path: The parent resource identity. Required. + :type parent_resource_path: str + :param resource_type: The resource type of the resource to create. Required. + :type resource_type: str + :param resource_name: The name of the resource to create. Required. + :type resource_name: str + :param api_version: The API version to use for the operation. Required. + :type api_version: str + :param parameters: Parameters for creating or updating the resource. Required. + :type parameters: IO + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be ARMPolling. Pass in False for this + operation to not poll, or pass in your own initialized polling object for a personal polling + strategy. + :paramtype polling: bool or ~azure.core.polling.PollingMethod + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of LROPoller that returns either GenericResource or the result of + cls(response) + :rtype: + ~azure.core.polling.LROPoller[~azure.mgmt.resource.resources.v2019_07_01.models.GenericResource] + :raises ~azure.core.exceptions.HttpResponseError: + """ @distributed_trace def begin_create_or_update( @@ -7837,26 +8617,30 @@ def begin_create_or_update( resource_type: str, resource_name: str, api_version: str, - parameters: "_models.GenericResource", + parameters: Union[_models.GenericResource, IO], **kwargs: Any - ) -> LROPoller["_models.GenericResource"]: + ) -> LROPoller[_models.GenericResource]: """Creates a resource. :param resource_group_name: The name of the resource group for the resource. The name is case - insensitive. + insensitive. Required. :type resource_group_name: str - :param resource_provider_namespace: The namespace of the resource provider. + :param resource_provider_namespace: The namespace of the resource provider. Required. :type resource_provider_namespace: str - :param parent_resource_path: The parent resource identity. + :param parent_resource_path: The parent resource identity. Required. :type parent_resource_path: str - :param resource_type: The resource type of the resource to create. + :param resource_type: The resource type of the resource to create. Required. :type resource_type: str - :param resource_name: The name of the resource to create. + :param resource_name: The name of the resource to create. Required. :type resource_name: str - :param api_version: The API version to use for the operation. + :param api_version: The API version to use for the operation. Required. :type api_version: str - :param parameters: Parameters for creating or updating the resource. - :type parameters: ~azure.mgmt.resource.resources.v2019_07_01.models.GenericResource + :param parameters: Parameters for creating or updating the resource. Is either a model type or + a IO type. Required. + :type parameters: ~azure.mgmt.resource.resources.v2019_07_01.models.GenericResource or IO + :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. + Default value is None. + :paramtype content_type: str :keyword callable cls: A custom type or function that will be passed the direct response :keyword str continuation_token: A continuation token to restart a poller from a saved state. :keyword polling: By default, your polling method will be ARMPolling. Pass in False for this @@ -7869,18 +8653,18 @@ def begin_create_or_update( cls(response) :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.resource.resources.v2019_07_01.models.GenericResource] - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] - polling = kwargs.pop('polling', True) # type: Union[bool, PollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType["_models.GenericResource"] - lro_delay = kwargs.pop( - 'polling_interval', - self._config.polling_interval - ) - cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = kwargs.pop("params", {}) or {} + + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.GenericResource] + polling = kwargs.pop("polling", True) # type: Union[bool, PollingMethod] + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token = kwargs.pop("continuation_token", None) # type: Optional[str] if cont_token is None: - raw_result = self._create_or_update_initial( + raw_result = self._create_or_update_initial( # type: ignore resource_group_name=resource_group_name, resource_provider_namespace=resource_provider_namespace, parent_resource_path=parent_resource_path, @@ -7889,32 +8673,35 @@ def begin_create_or_update( api_version=api_version, parameters=parameters, content_type=content_type, - cls=lambda x,y,z: x, + cls=lambda x, y, z: x, + headers=_headers, + params=_params, **kwargs ) - kwargs.pop('error_map', None) + kwargs.pop("error_map", None) def get_long_running_output(pipeline_response): - response = pipeline_response.http_response - deserialized = self._deserialize('GenericResource', pipeline_response) + deserialized = self._deserialize("GenericResource", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - - if polling is True: polling_method = ARMPolling(lro_delay, **kwargs) - elif polling is False: polling_method = NoPolling() - else: polling_method = polling + if polling is True: + polling_method = cast(PollingMethod, ARMPolling(lro_delay, **kwargs)) # type: PollingMethod + elif polling is False: + polling_method = cast(PollingMethod, NoPolling()) + else: + polling_method = polling if cont_token: return LROPoller.from_continuation_token( polling_method=polling_method, continuation_token=cont_token, client=self._client, - deserialization_callback=get_long_running_output + deserialization_callback=get_long_running_output, ) return LROPoller(self._client, raw_result, get_long_running_output, polling_method) - begin_create_or_update.metadata = {'url': "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{parentResourcePath}/{resourceType}/{resourceName}"} # type: ignore + begin_create_or_update.metadata = {"url": "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{parentResourcePath}/{resourceType}/{resourceName}"} # type: ignore def _update_initial( self, @@ -7924,39 +8711,53 @@ def _update_initial( resource_type: str, resource_name: str, api_version: str, - parameters: "_models.GenericResource", + parameters: Union[_models.GenericResource, IO], **kwargs: Any - ) -> Optional["_models.GenericResource"]: - cls = kwargs.pop('cls', None) # type: ClsType[Optional["_models.GenericResource"]] + ) -> Optional[_models.GenericResource]: error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = kwargs.pop("params", {}) or {} - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[Optional[_models.GenericResource]] - _json = self._serialize.body(parameters, 'GenericResource') + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(parameters, (IO, bytes)): + _content = parameters + else: + _json = self._serialize.body(parameters, "GenericResource") - request = build_resources_update_request_initial( + request = build_resources_update_request( resource_group_name=resource_group_name, resource_provider_namespace=resource_provider_namespace, parent_resource_path=parent_resource_path, resource_type=resource_type, resource_name=resource_name, subscription_id=self._config.subscription_id, - content_type=content_type, api_version=api_version, + content_type=content_type, json=_json, - template_url=self._update_initial.metadata['url'], + content=_content, + template_url=self._update_initial.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200, 202]: @@ -7965,15 +8766,112 @@ def _update_initial( deserialized = None if response.status_code == 200: - deserialized = self._deserialize('GenericResource', pipeline_response) + deserialized = self._deserialize("GenericResource", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - _update_initial.metadata = {'url': "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{parentResourcePath}/{resourceType}/{resourceName}"} # type: ignore + _update_initial.metadata = {"url": "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{parentResourcePath}/{resourceType}/{resourceName}"} # type: ignore + + @overload + def begin_update( + self, + resource_group_name: str, + resource_provider_namespace: str, + parent_resource_path: str, + resource_type: str, + resource_name: str, + api_version: str, + parameters: _models.GenericResource, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> LROPoller[_models.GenericResource]: + """Updates a resource. + + :param resource_group_name: The name of the resource group for the resource. The name is case + insensitive. Required. + :type resource_group_name: str + :param resource_provider_namespace: The namespace of the resource provider. Required. + :type resource_provider_namespace: str + :param parent_resource_path: The parent resource identity. Required. + :type parent_resource_path: str + :param resource_type: The resource type of the resource to update. Required. + :type resource_type: str + :param resource_name: The name of the resource to update. Required. + :type resource_name: str + :param api_version: The API version to use for the operation. Required. + :type api_version: str + :param parameters: Parameters for updating the resource. Required. + :type parameters: ~azure.mgmt.resource.resources.v2019_07_01.models.GenericResource + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be ARMPolling. Pass in False for this + operation to not poll, or pass in your own initialized polling object for a personal polling + strategy. + :paramtype polling: bool or ~azure.core.polling.PollingMethod + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of LROPoller that returns either GenericResource or the result of + cls(response) + :rtype: + ~azure.core.polling.LROPoller[~azure.mgmt.resource.resources.v2019_07_01.models.GenericResource] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + def begin_update( + self, + resource_group_name: str, + resource_provider_namespace: str, + parent_resource_path: str, + resource_type: str, + resource_name: str, + api_version: str, + parameters: IO, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> LROPoller[_models.GenericResource]: + """Updates a resource. + :param resource_group_name: The name of the resource group for the resource. The name is case + insensitive. Required. + :type resource_group_name: str + :param resource_provider_namespace: The namespace of the resource provider. Required. + :type resource_provider_namespace: str + :param parent_resource_path: The parent resource identity. Required. + :type parent_resource_path: str + :param resource_type: The resource type of the resource to update. Required. + :type resource_type: str + :param resource_name: The name of the resource to update. Required. + :type resource_name: str + :param api_version: The API version to use for the operation. Required. + :type api_version: str + :param parameters: Parameters for updating the resource. Required. + :type parameters: IO + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be ARMPolling. Pass in False for this + operation to not poll, or pass in your own initialized polling object for a personal polling + strategy. + :paramtype polling: bool or ~azure.core.polling.PollingMethod + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of LROPoller that returns either GenericResource or the result of + cls(response) + :rtype: + ~azure.core.polling.LROPoller[~azure.mgmt.resource.resources.v2019_07_01.models.GenericResource] + :raises ~azure.core.exceptions.HttpResponseError: + """ @distributed_trace def begin_update( @@ -7984,26 +8882,30 @@ def begin_update( resource_type: str, resource_name: str, api_version: str, - parameters: "_models.GenericResource", + parameters: Union[_models.GenericResource, IO], **kwargs: Any - ) -> LROPoller["_models.GenericResource"]: + ) -> LROPoller[_models.GenericResource]: """Updates a resource. :param resource_group_name: The name of the resource group for the resource. The name is case - insensitive. + insensitive. Required. :type resource_group_name: str - :param resource_provider_namespace: The namespace of the resource provider. + :param resource_provider_namespace: The namespace of the resource provider. Required. :type resource_provider_namespace: str - :param parent_resource_path: The parent resource identity. + :param parent_resource_path: The parent resource identity. Required. :type parent_resource_path: str - :param resource_type: The resource type of the resource to update. + :param resource_type: The resource type of the resource to update. Required. :type resource_type: str - :param resource_name: The name of the resource to update. + :param resource_name: The name of the resource to update. Required. :type resource_name: str - :param api_version: The API version to use for the operation. + :param api_version: The API version to use for the operation. Required. :type api_version: str - :param parameters: Parameters for updating the resource. - :type parameters: ~azure.mgmt.resource.resources.v2019_07_01.models.GenericResource + :param parameters: Parameters for updating the resource. Is either a model type or a IO type. + Required. + :type parameters: ~azure.mgmt.resource.resources.v2019_07_01.models.GenericResource or IO + :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. + Default value is None. + :paramtype content_type: str :keyword callable cls: A custom type or function that will be passed the direct response :keyword str continuation_token: A continuation token to restart a poller from a saved state. :keyword polling: By default, your polling method will be ARMPolling. Pass in False for this @@ -8016,18 +8918,18 @@ def begin_update( cls(response) :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.resource.resources.v2019_07_01.models.GenericResource] - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] - polling = kwargs.pop('polling', True) # type: Union[bool, PollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType["_models.GenericResource"] - lro_delay = kwargs.pop( - 'polling_interval', - self._config.polling_interval - ) - cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = kwargs.pop("params", {}) or {} + + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.GenericResource] + polling = kwargs.pop("polling", True) # type: Union[bool, PollingMethod] + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token = kwargs.pop("continuation_token", None) # type: Optional[str] if cont_token is None: - raw_result = self._update_initial( + raw_result = self._update_initial( # type: ignore resource_group_name=resource_group_name, resource_provider_namespace=resource_provider_namespace, parent_resource_path=parent_resource_path, @@ -8036,32 +8938,35 @@ def begin_update( api_version=api_version, parameters=parameters, content_type=content_type, - cls=lambda x,y,z: x, + cls=lambda x, y, z: x, + headers=_headers, + params=_params, **kwargs ) - kwargs.pop('error_map', None) + kwargs.pop("error_map", None) def get_long_running_output(pipeline_response): - response = pipeline_response.http_response - deserialized = self._deserialize('GenericResource', pipeline_response) + deserialized = self._deserialize("GenericResource", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - - if polling is True: polling_method = ARMPolling(lro_delay, **kwargs) - elif polling is False: polling_method = NoPolling() - else: polling_method = polling + if polling is True: + polling_method = cast(PollingMethod, ARMPolling(lro_delay, **kwargs)) # type: PollingMethod + elif polling is False: + polling_method = cast(PollingMethod, NoPolling()) + else: + polling_method = polling if cont_token: return LROPoller.from_continuation_token( polling_method=polling_method, continuation_token=cont_token, client=self._client, - deserialization_callback=get_long_running_output + deserialization_callback=get_long_running_output, ) return LROPoller(self._client, raw_result, get_long_running_output, polling_method) - begin_update.metadata = {'url': "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{parentResourcePath}/{resourceType}/{resourceName}"} # type: ignore + begin_update.metadata = {"url": "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{parentResourcePath}/{resourceType}/{resourceName}"} # type: ignore @distributed_trace def get( @@ -8073,34 +8978,40 @@ def get( resource_name: str, api_version: str, **kwargs: Any - ) -> "_models.GenericResource": + ) -> _models.GenericResource: """Gets a resource. :param resource_group_name: The name of the resource group containing the resource to get. The - name is case insensitive. + name is case insensitive. Required. :type resource_group_name: str - :param resource_provider_namespace: The namespace of the resource provider. + :param resource_provider_namespace: The namespace of the resource provider. Required. :type resource_provider_namespace: str - :param parent_resource_path: The parent resource identity. + :param parent_resource_path: The parent resource identity. Required. :type parent_resource_path: str - :param resource_type: The resource type of the resource. + :param resource_type: The resource type of the resource. Required. :type resource_type: str - :param resource_name: The name of the resource to get. + :param resource_name: The name of the resource to get. Required. :type resource_name: str - :param api_version: The API version to use for the operation. + :param api_version: The API version to use for the operation. Required. :type api_version: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: GenericResource, or the result of cls(response) + :return: GenericResource or the result of cls(response) :rtype: ~azure.mgmt.resource.resources.v2019_07_01.models.GenericResource - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.GenericResource"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = kwargs.pop("params", {}) or {} + + cls = kwargs.pop("cls", None) # type: ClsType[_models.GenericResource] - request = build_resources_get_request( resource_group_name=resource_group_name, resource_provider_namespace=resource_provider_namespace, @@ -8109,72 +9020,75 @@ def get( resource_name=resource_name, subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.get.metadata['url'], + template_url=self.get.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) - deserialized = self._deserialize('GenericResource', pipeline_response) + deserialized = self._deserialize("GenericResource", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - get.metadata = {'url': "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{parentResourcePath}/{resourceType}/{resourceName}"} # type: ignore - + get.metadata = {"url": "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{parentResourcePath}/{resourceType}/{resourceName}"} # type: ignore @distributed_trace - def check_existence_by_id( - self, - resource_id: str, - api_version: str, - **kwargs: Any - ) -> bool: + def check_existence_by_id(self, resource_id: str, api_version: str, **kwargs: Any) -> bool: """Checks by ID whether a resource exists. :param resource_id: The fully qualified ID of the resource, including the resource name and resource type. Use the format, /subscriptions/{guid}/resourceGroups/{resource-group-name}/{resource-provider-namespace}/{resource-type}/{resource-name}. + Required. :type resource_id: str - :param api_version: The API version to use for the operation. + :param api_version: The API version to use for the operation. Required. :type api_version: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: bool, or the result of cls(response) + :return: bool or the result of cls(response) :rtype: bool - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType[None] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = kwargs.pop("params", {}) or {} + + cls = kwargs.pop("cls", None) # type: ClsType[None] - request = build_resources_check_existence_by_id_request( resource_id=resource_id, api_version=api_version, - template_url=self.check_existence_by_id.metadata['url'], + template_url=self.check_existence_by_id.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [204, 404]: @@ -8185,35 +9099,38 @@ def check_existence_by_id( return cls(pipeline_response, None, {}) return 200 <= response.status_code <= 299 - check_existence_by_id.metadata = {'url': "/{resourceId}"} # type: ignore - + check_existence_by_id.metadata = {"url": "/{resourceId}"} # type: ignore def _delete_by_id_initial( # pylint: disable=inconsistent-return-statements - self, - resource_id: str, - api_version: str, - **kwargs: Any + self, resource_id: str, api_version: str, **kwargs: Any ) -> None: - cls = kwargs.pop('cls', None) # type: ClsType[None] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = kwargs.pop("params", {}) or {} - - request = build_resources_delete_by_id_request_initial( + cls = kwargs.pop("cls", None) # type: ClsType[None] + + request = build_resources_delete_by_id_request( resource_id=resource_id, api_version=api_version, - template_url=self._delete_by_id_initial.metadata['url'], + template_url=self._delete_by_id_initial.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200, 202, 204]: @@ -8223,23 +9140,18 @@ def _delete_by_id_initial( # pylint: disable=inconsistent-return-statements if cls: return cls(pipeline_response, None, {}) - _delete_by_id_initial.metadata = {'url': "/{resourceId}"} # type: ignore - + _delete_by_id_initial.metadata = {"url": "/{resourceId}"} # type: ignore @distributed_trace - def begin_delete_by_id( # pylint: disable=inconsistent-return-statements - self, - resource_id: str, - api_version: str, - **kwargs: Any - ) -> LROPoller[None]: + def begin_delete_by_id(self, resource_id: str, api_version: str, **kwargs: Any) -> LROPoller[None]: """Deletes a resource by ID. :param resource_id: The fully qualified ID of the resource, including the resource name and resource type. Use the format, /subscriptions/{guid}/resourceGroups/{resource-group-name}/{resource-provider-namespace}/{resource-type}/{resource-name}. + Required. :type resource_id: str - :param api_version: The API version to use for the operation. + :param api_version: The API version to use for the operation. Required. :type api_version: str :keyword callable cls: A custom type or function that will be passed the direct response :keyword str continuation_token: A continuation token to restart a poller from a saved state. @@ -8251,75 +9163,89 @@ def begin_delete_by_id( # pylint: disable=inconsistent-return-statements Retry-After header is present. :return: An instance of LROPoller that returns either None or the result of cls(response) :rtype: ~azure.core.polling.LROPoller[None] - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - polling = kwargs.pop('polling', True) # type: Union[bool, PollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType[None] - lro_delay = kwargs.pop( - 'polling_interval', - self._config.polling_interval - ) - cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] + _headers = kwargs.pop("headers", {}) or {} + _params = kwargs.pop("params", {}) or {} + + cls = kwargs.pop("cls", None) # type: ClsType[None] + polling = kwargs.pop("polling", True) # type: Union[bool, PollingMethod] + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token = kwargs.pop("continuation_token", None) # type: Optional[str] if cont_token is None: - raw_result = self._delete_by_id_initial( + raw_result = self._delete_by_id_initial( # type: ignore resource_id=resource_id, api_version=api_version, - cls=lambda x,y,z: x, + cls=lambda x, y, z: x, + headers=_headers, + params=_params, **kwargs ) - kwargs.pop('error_map', None) + kwargs.pop("error_map", None) - def get_long_running_output(pipeline_response): + def get_long_running_output(pipeline_response): # pylint: disable=inconsistent-return-statements if cls: return cls(pipeline_response, None, {}) - - if polling is True: polling_method = ARMPolling(lro_delay, **kwargs) - elif polling is False: polling_method = NoPolling() - else: polling_method = polling + if polling is True: + polling_method = cast(PollingMethod, ARMPolling(lro_delay, **kwargs)) # type: PollingMethod + elif polling is False: + polling_method = cast(PollingMethod, NoPolling()) + else: + polling_method = polling if cont_token: return LROPoller.from_continuation_token( polling_method=polling_method, continuation_token=cont_token, client=self._client, - deserialization_callback=get_long_running_output + deserialization_callback=get_long_running_output, ) return LROPoller(self._client, raw_result, get_long_running_output, polling_method) - begin_delete_by_id.metadata = {'url': "/{resourceId}"} # type: ignore + begin_delete_by_id.metadata = {"url": "/{resourceId}"} # type: ignore def _create_or_update_by_id_initial( - self, - resource_id: str, - api_version: str, - parameters: "_models.GenericResource", - **kwargs: Any - ) -> Optional["_models.GenericResource"]: - cls = kwargs.pop('cls', None) # type: ClsType[Optional["_models.GenericResource"]] + self, resource_id: str, api_version: str, parameters: Union[_models.GenericResource, IO], **kwargs: Any + ) -> Optional[_models.GenericResource]: error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = kwargs.pop("params", {}) or {} - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[Optional[_models.GenericResource]] - _json = self._serialize.body(parameters, 'GenericResource') + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(parameters, (IO, bytes)): + _content = parameters + else: + _json = self._serialize.body(parameters, "GenericResource") - request = build_resources_create_or_update_by_id_request_initial( + request = build_resources_create_or_update_by_id_request( resource_id=resource_id, - content_type=content_type, api_version=api_version, + content_type=content_type, json=_json, - template_url=self._create_or_update_by_id_initial.metadata['url'], + content=_content, + template_url=self._create_or_update_by_id_initial.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200, 201, 202]: @@ -8328,37 +9254,42 @@ def _create_or_update_by_id_initial( deserialized = None if response.status_code == 200: - deserialized = self._deserialize('GenericResource', pipeline_response) + deserialized = self._deserialize("GenericResource", pipeline_response) if response.status_code == 201: - deserialized = self._deserialize('GenericResource', pipeline_response) + deserialized = self._deserialize("GenericResource", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - _create_or_update_by_id_initial.metadata = {'url': "/{resourceId}"} # type: ignore + _create_or_update_by_id_initial.metadata = {"url": "/{resourceId}"} # type: ignore - - @distributed_trace + @overload def begin_create_or_update_by_id( self, resource_id: str, api_version: str, - parameters: "_models.GenericResource", + parameters: _models.GenericResource, + *, + content_type: str = "application/json", **kwargs: Any - ) -> LROPoller["_models.GenericResource"]: + ) -> LROPoller[_models.GenericResource]: """Create a resource by ID. :param resource_id: The fully qualified ID of the resource, including the resource name and resource type. Use the format, /subscriptions/{guid}/resourceGroups/{resource-group-name}/{resource-provider-namespace}/{resource-type}/{resource-name}. + Required. :type resource_id: str - :param api_version: The API version to use for the operation. + :param api_version: The API version to use for the operation. Required. :type api_version: str - :param parameters: Create or update resource parameters. + :param parameters: Create or update resource parameters. Required. :type parameters: ~azure.mgmt.resource.resources.v2019_07_01.models.GenericResource + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str :keyword callable cls: A custom type or function that will be passed the direct response :keyword str continuation_token: A continuation token to restart a poller from a saved state. :keyword polling: By default, your polling method will be ARMPolling. Pass in False for this @@ -8371,81 +9302,167 @@ def begin_create_or_update_by_id( cls(response) :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.resource.resources.v2019_07_01.models.GenericResource] - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] - polling = kwargs.pop('polling', True) # type: Union[bool, PollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType["_models.GenericResource"] - lro_delay = kwargs.pop( - 'polling_interval', - self._config.polling_interval - ) - cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] + + @overload + def begin_create_or_update_by_id( + self, + resource_id: str, + api_version: str, + parameters: IO, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> LROPoller[_models.GenericResource]: + """Create a resource by ID. + + :param resource_id: The fully qualified ID of the resource, including the resource name and + resource type. Use the format, + /subscriptions/{guid}/resourceGroups/{resource-group-name}/{resource-provider-namespace}/{resource-type}/{resource-name}. + Required. + :type resource_id: str + :param api_version: The API version to use for the operation. Required. + :type api_version: str + :param parameters: Create or update resource parameters. Required. + :type parameters: IO + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be ARMPolling. Pass in False for this + operation to not poll, or pass in your own initialized polling object for a personal polling + strategy. + :paramtype polling: bool or ~azure.core.polling.PollingMethod + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of LROPoller that returns either GenericResource or the result of + cls(response) + :rtype: + ~azure.core.polling.LROPoller[~azure.mgmt.resource.resources.v2019_07_01.models.GenericResource] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace + def begin_create_or_update_by_id( + self, resource_id: str, api_version: str, parameters: Union[_models.GenericResource, IO], **kwargs: Any + ) -> LROPoller[_models.GenericResource]: + """Create a resource by ID. + + :param resource_id: The fully qualified ID of the resource, including the resource name and + resource type. Use the format, + /subscriptions/{guid}/resourceGroups/{resource-group-name}/{resource-provider-namespace}/{resource-type}/{resource-name}. + Required. + :type resource_id: str + :param api_version: The API version to use for the operation. Required. + :type api_version: str + :param parameters: Create or update resource parameters. Is either a model type or a IO type. + Required. + :type parameters: ~azure.mgmt.resource.resources.v2019_07_01.models.GenericResource or IO + :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. + Default value is None. + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be ARMPolling. Pass in False for this + operation to not poll, or pass in your own initialized polling object for a personal polling + strategy. + :paramtype polling: bool or ~azure.core.polling.PollingMethod + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of LROPoller that returns either GenericResource or the result of + cls(response) + :rtype: + ~azure.core.polling.LROPoller[~azure.mgmt.resource.resources.v2019_07_01.models.GenericResource] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = kwargs.pop("params", {}) or {} + + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.GenericResource] + polling = kwargs.pop("polling", True) # type: Union[bool, PollingMethod] + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token = kwargs.pop("continuation_token", None) # type: Optional[str] if cont_token is None: - raw_result = self._create_or_update_by_id_initial( + raw_result = self._create_or_update_by_id_initial( # type: ignore resource_id=resource_id, api_version=api_version, parameters=parameters, content_type=content_type, - cls=lambda x,y,z: x, + cls=lambda x, y, z: x, + headers=_headers, + params=_params, **kwargs ) - kwargs.pop('error_map', None) + kwargs.pop("error_map", None) def get_long_running_output(pipeline_response): - response = pipeline_response.http_response - deserialized = self._deserialize('GenericResource', pipeline_response) + deserialized = self._deserialize("GenericResource", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - - if polling is True: polling_method = ARMPolling(lro_delay, **kwargs) - elif polling is False: polling_method = NoPolling() - else: polling_method = polling + if polling is True: + polling_method = cast(PollingMethod, ARMPolling(lro_delay, **kwargs)) # type: PollingMethod + elif polling is False: + polling_method = cast(PollingMethod, NoPolling()) + else: + polling_method = polling if cont_token: return LROPoller.from_continuation_token( polling_method=polling_method, continuation_token=cont_token, client=self._client, - deserialization_callback=get_long_running_output + deserialization_callback=get_long_running_output, ) return LROPoller(self._client, raw_result, get_long_running_output, polling_method) - begin_create_or_update_by_id.metadata = {'url': "/{resourceId}"} # type: ignore + begin_create_or_update_by_id.metadata = {"url": "/{resourceId}"} # type: ignore def _update_by_id_initial( - self, - resource_id: str, - api_version: str, - parameters: "_models.GenericResource", - **kwargs: Any - ) -> Optional["_models.GenericResource"]: - cls = kwargs.pop('cls', None) # type: ClsType[Optional["_models.GenericResource"]] + self, resource_id: str, api_version: str, parameters: Union[_models.GenericResource, IO], **kwargs: Any + ) -> Optional[_models.GenericResource]: error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = kwargs.pop("params", {}) or {} - _json = self._serialize.body(parameters, 'GenericResource') + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[Optional[_models.GenericResource]] - request = build_resources_update_by_id_request_initial( + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(parameters, (IO, bytes)): + _content = parameters + else: + _json = self._serialize.body(parameters, "GenericResource") + + request = build_resources_update_by_id_request( resource_id=resource_id, - content_type=content_type, api_version=api_version, + content_type=content_type, json=_json, - template_url=self._update_by_id_initial.metadata['url'], + content=_content, + template_url=self._update_by_id_initial.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200, 202]: @@ -8454,34 +9471,39 @@ def _update_by_id_initial( deserialized = None if response.status_code == 200: - deserialized = self._deserialize('GenericResource', pipeline_response) + deserialized = self._deserialize("GenericResource", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - _update_by_id_initial.metadata = {'url': "/{resourceId}"} # type: ignore + _update_by_id_initial.metadata = {"url": "/{resourceId}"} # type: ignore - - @distributed_trace + @overload def begin_update_by_id( self, resource_id: str, api_version: str, - parameters: "_models.GenericResource", + parameters: _models.GenericResource, + *, + content_type: str = "application/json", **kwargs: Any - ) -> LROPoller["_models.GenericResource"]: + ) -> LROPoller[_models.GenericResource]: """Updates a resource by ID. :param resource_id: The fully qualified ID of the resource, including the resource name and resource type. Use the format, /subscriptions/{guid}/resourceGroups/{resource-group-name}/{resource-provider-namespace}/{resource-type}/{resource-name}. + Required. :type resource_id: str - :param api_version: The API version to use for the operation. + :param api_version: The API version to use for the operation. Required. :type api_version: str - :param parameters: Update resource parameters. + :param parameters: Update resource parameters. Required. :type parameters: ~azure.mgmt.resource.resources.v2019_07_01.models.GenericResource + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str :keyword callable cls: A custom type or function that will be passed the direct response :keyword str continuation_token: A continuation token to restart a poller from a saved state. :keyword polling: By default, your polling method will be ARMPolling. Pass in False for this @@ -8494,165 +9516,243 @@ def begin_update_by_id( cls(response) :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.resource.resources.v2019_07_01.models.GenericResource] - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] - polling = kwargs.pop('polling', True) # type: Union[bool, PollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType["_models.GenericResource"] - lro_delay = kwargs.pop( - 'polling_interval', - self._config.polling_interval - ) - cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] + + @overload + def begin_update_by_id( + self, + resource_id: str, + api_version: str, + parameters: IO, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> LROPoller[_models.GenericResource]: + """Updates a resource by ID. + + :param resource_id: The fully qualified ID of the resource, including the resource name and + resource type. Use the format, + /subscriptions/{guid}/resourceGroups/{resource-group-name}/{resource-provider-namespace}/{resource-type}/{resource-name}. + Required. + :type resource_id: str + :param api_version: The API version to use for the operation. Required. + :type api_version: str + :param parameters: Update resource parameters. Required. + :type parameters: IO + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be ARMPolling. Pass in False for this + operation to not poll, or pass in your own initialized polling object for a personal polling + strategy. + :paramtype polling: bool or ~azure.core.polling.PollingMethod + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of LROPoller that returns either GenericResource or the result of + cls(response) + :rtype: + ~azure.core.polling.LROPoller[~azure.mgmt.resource.resources.v2019_07_01.models.GenericResource] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace + def begin_update_by_id( + self, resource_id: str, api_version: str, parameters: Union[_models.GenericResource, IO], **kwargs: Any + ) -> LROPoller[_models.GenericResource]: + """Updates a resource by ID. + + :param resource_id: The fully qualified ID of the resource, including the resource name and + resource type. Use the format, + /subscriptions/{guid}/resourceGroups/{resource-group-name}/{resource-provider-namespace}/{resource-type}/{resource-name}. + Required. + :type resource_id: str + :param api_version: The API version to use for the operation. Required. + :type api_version: str + :param parameters: Update resource parameters. Is either a model type or a IO type. Required. + :type parameters: ~azure.mgmt.resource.resources.v2019_07_01.models.GenericResource or IO + :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. + Default value is None. + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be ARMPolling. Pass in False for this + operation to not poll, or pass in your own initialized polling object for a personal polling + strategy. + :paramtype polling: bool or ~azure.core.polling.PollingMethod + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of LROPoller that returns either GenericResource or the result of + cls(response) + :rtype: + ~azure.core.polling.LROPoller[~azure.mgmt.resource.resources.v2019_07_01.models.GenericResource] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = kwargs.pop("params", {}) or {} + + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.GenericResource] + polling = kwargs.pop("polling", True) # type: Union[bool, PollingMethod] + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token = kwargs.pop("continuation_token", None) # type: Optional[str] if cont_token is None: - raw_result = self._update_by_id_initial( + raw_result = self._update_by_id_initial( # type: ignore resource_id=resource_id, api_version=api_version, parameters=parameters, content_type=content_type, - cls=lambda x,y,z: x, + cls=lambda x, y, z: x, + headers=_headers, + params=_params, **kwargs ) - kwargs.pop('error_map', None) + kwargs.pop("error_map", None) def get_long_running_output(pipeline_response): - response = pipeline_response.http_response - deserialized = self._deserialize('GenericResource', pipeline_response) + deserialized = self._deserialize("GenericResource", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - - if polling is True: polling_method = ARMPolling(lro_delay, **kwargs) - elif polling is False: polling_method = NoPolling() - else: polling_method = polling + if polling is True: + polling_method = cast(PollingMethod, ARMPolling(lro_delay, **kwargs)) # type: PollingMethod + elif polling is False: + polling_method = cast(PollingMethod, NoPolling()) + else: + polling_method = polling if cont_token: return LROPoller.from_continuation_token( polling_method=polling_method, continuation_token=cont_token, client=self._client, - deserialization_callback=get_long_running_output + deserialization_callback=get_long_running_output, ) return LROPoller(self._client, raw_result, get_long_running_output, polling_method) - begin_update_by_id.metadata = {'url': "/{resourceId}"} # type: ignore + begin_update_by_id.metadata = {"url": "/{resourceId}"} # type: ignore @distributed_trace - def get_by_id( - self, - resource_id: str, - api_version: str, - **kwargs: Any - ) -> "_models.GenericResource": + def get_by_id(self, resource_id: str, api_version: str, **kwargs: Any) -> _models.GenericResource: """Gets a resource by ID. :param resource_id: The fully qualified ID of the resource, including the resource name and resource type. Use the format, /subscriptions/{guid}/resourceGroups/{resource-group-name}/{resource-provider-namespace}/{resource-type}/{resource-name}. + Required. :type resource_id: str - :param api_version: The API version to use for the operation. + :param api_version: The API version to use for the operation. Required. :type api_version: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: GenericResource, or the result of cls(response) + :return: GenericResource or the result of cls(response) :rtype: ~azure.mgmt.resource.resources.v2019_07_01.models.GenericResource - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.GenericResource"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = kwargs.pop("params", {}) or {} + + cls = kwargs.pop("cls", None) # type: ClsType[_models.GenericResource] - request = build_resources_get_by_id_request( resource_id=resource_id, api_version=api_version, - template_url=self.get_by_id.metadata['url'], + template_url=self.get_by_id.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) - deserialized = self._deserialize('GenericResource', pipeline_response) + deserialized = self._deserialize("GenericResource", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - get_by_id.metadata = {'url': "/{resourceId}"} # type: ignore + get_by_id.metadata = {"url": "/{resourceId}"} # type: ignore -class ResourceGroupsOperations(object): - """ResourceGroupsOperations operations. - You should not instantiate this class directly. Instead, you should create a Client instance that - instantiates it for you and attaches it as an attribute. +class ResourceGroupsOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. - :ivar models: Alias to model classes used in this operation group. - :type models: ~azure.mgmt.resource.resources.v2019_07_01.models - :param client: Client for service requests. - :param config: Configuration of service client. - :param serializer: An object model serializer. - :param deserializer: An object model deserializer. + Instead, you should access the following operations through + :class:`~azure.mgmt.resource.resources.v2019_07_01.ResourceManagementClient`'s + :attr:`resource_groups` attribute. """ models = _models - def __init__(self, client, config, serializer, deserializer): - self._client = client - self._serialize = serializer - self._deserialize = deserializer - self._config = config + def __init__(self, *args, **kwargs): + input_args = list(args) + self._client = input_args.pop(0) if input_args else kwargs.pop("client") + self._config = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") @distributed_trace - def check_existence( - self, - resource_group_name: str, - **kwargs: Any - ) -> bool: + def check_existence(self, resource_group_name: str, **kwargs: Any) -> bool: """Checks whether a resource group exists. :param resource_group_name: The name of the resource group to check. The name is case - insensitive. + insensitive. Required. :type resource_group_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: bool, or the result of cls(response) + :return: bool or the result of cls(response) :rtype: bool - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType[None] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) - api_version = kwargs.pop('api_version', "2019-07-01") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2019-07-01")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[None] - request = build_resource_groups_check_existence_request( resource_group_name=resource_group_name, subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.check_existence.metadata['url'], + template_url=self.check_existence.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [204, 404]: @@ -8663,39 +9763,98 @@ def check_existence( return cls(pipeline_response, None, {}) return 200 <= response.status_code <= 299 - check_existence.metadata = {'url': "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}"} # type: ignore + check_existence.metadata = {"url": "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}"} # type: ignore + + @overload + def create_or_update( + self, + resource_group_name: str, + parameters: _models.ResourceGroup, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.ResourceGroup: + """Creates or updates a resource group. + + :param resource_group_name: The name of the resource group to create or update. Can include + alphanumeric, underscore, parentheses, hyphen, period (except at end), and Unicode characters + that match the allowed characters. Required. + :type resource_group_name: str + :param parameters: Parameters supplied to the create or update a resource group. Required. + :type parameters: ~azure.mgmt.resource.resources.v2019_07_01.models.ResourceGroup + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: ResourceGroup or the result of cls(response) + :rtype: ~azure.mgmt.resource.resources.v2019_07_01.models.ResourceGroup + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + def create_or_update( + self, resource_group_name: str, parameters: IO, *, content_type: str = "application/json", **kwargs: Any + ) -> _models.ResourceGroup: + """Creates or updates a resource group. + :param resource_group_name: The name of the resource group to create or update. Can include + alphanumeric, underscore, parentheses, hyphen, period (except at end), and Unicode characters + that match the allowed characters. Required. + :type resource_group_name: str + :param parameters: Parameters supplied to the create or update a resource group. Required. + :type parameters: IO + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: ResourceGroup or the result of cls(response) + :rtype: ~azure.mgmt.resource.resources.v2019_07_01.models.ResourceGroup + :raises ~azure.core.exceptions.HttpResponseError: + """ @distributed_trace def create_or_update( - self, - resource_group_name: str, - parameters: "_models.ResourceGroup", - **kwargs: Any - ) -> "_models.ResourceGroup": + self, resource_group_name: str, parameters: Union[_models.ResourceGroup, IO], **kwargs: Any + ) -> _models.ResourceGroup: """Creates or updates a resource group. :param resource_group_name: The name of the resource group to create or update. Can include alphanumeric, underscore, parentheses, hyphen, period (except at end), and Unicode characters - that match the allowed characters. + that match the allowed characters. Required. :type resource_group_name: str - :param parameters: Parameters supplied to the create or update a resource group. - :type parameters: ~azure.mgmt.resource.resources.v2019_07_01.models.ResourceGroup + :param parameters: Parameters supplied to the create or update a resource group. Is either a + model type or a IO type. Required. + :type parameters: ~azure.mgmt.resource.resources.v2019_07_01.models.ResourceGroup or IO + :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. + Default value is None. + :paramtype content_type: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: ResourceGroup, or the result of cls(response) + :return: ResourceGroup or the result of cls(response) :rtype: ~azure.mgmt.resource.resources.v2019_07_01.models.ResourceGroup - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.ResourceGroup"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', "2019-07-01") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + api_version = kwargs.pop("api_version", _params.pop("api-version", "2019-07-01")) # type: str + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.ResourceGroup] - _json = self._serialize.body(parameters, 'ResourceGroup') + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(parameters, (IO, bytes)): + _content = parameters + else: + _json = self._serialize.body(parameters, "ResourceGroup") request = build_resource_groups_create_or_update_request( resource_group_name=resource_group_name, @@ -8703,16 +9862,18 @@ def create_or_update( api_version=api_version, content_type=content_type, json=_json, - template_url=self.create_or_update.metadata['url'], + content=_content, + template_url=self.create_or_update.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200, 201]: @@ -8720,47 +9881,50 @@ def create_or_update( raise HttpResponseError(response=response, error_format=ARMErrorFormat) if response.status_code == 200: - deserialized = self._deserialize('ResourceGroup', pipeline_response) + deserialized = self._deserialize("ResourceGroup", pipeline_response) if response.status_code == 201: - deserialized = self._deserialize('ResourceGroup', pipeline_response) + deserialized = self._deserialize("ResourceGroup", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - create_or_update.metadata = {'url': "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}"} # type: ignore - + create_or_update.metadata = {"url": "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}"} # type: ignore def _delete_initial( # pylint: disable=inconsistent-return-statements - self, - resource_group_name: str, - **kwargs: Any + self, resource_group_name: str, **kwargs: Any ) -> None: - cls = kwargs.pop('cls', None) # type: ClsType[None] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + 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', "2019-07-01") # type: str + api_version = kwargs.pop("api_version", _params.pop("api-version", "2019-07-01")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[None] - - request = build_resource_groups_delete_request_initial( + request = build_resource_groups_delete_request( resource_group_name=resource_group_name, subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self._delete_initial.metadata['url'], + template_url=self._delete_initial.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200, 202]: @@ -8770,22 +9934,17 @@ def _delete_initial( # pylint: disable=inconsistent-return-statements if cls: return cls(pipeline_response, None, {}) - _delete_initial.metadata = {'url': "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}"} # type: ignore - + _delete_initial.metadata = {"url": "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}"} # type: ignore @distributed_trace - def begin_delete( # pylint: disable=inconsistent-return-statements - self, - resource_group_name: str, - **kwargs: Any - ) -> LROPoller[None]: + def begin_delete(self, resource_group_name: str, **kwargs: Any) -> LROPoller[None]: """Deletes a resource group. When you delete a resource group, all of its resources are also deleted. Deleting a resource group deletes all of its template deployments and currently stored operations. :param resource_group_name: The name of the resource group to delete. The name is case - insensitive. + insensitive. Required. :type resource_group_name: str :keyword callable cls: A custom type or function that will be passed the direct response :keyword str continuation_token: A continuation token to restart a poller from a saved state. @@ -8797,106 +9956,113 @@ def begin_delete( # pylint: disable=inconsistent-return-statements Retry-After header is present. :return: An instance of LROPoller that returns either None or the result of cls(response) :rtype: ~azure.core.polling.LROPoller[None] - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - api_version = kwargs.pop('api_version', "2019-07-01") # type: str - polling = kwargs.pop('polling', True) # type: Union[bool, PollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType[None] - lro_delay = kwargs.pop( - 'polling_interval', - self._config.polling_interval - ) - cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2019-07-01")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[None] + polling = kwargs.pop("polling", True) # type: Union[bool, PollingMethod] + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token = kwargs.pop("continuation_token", None) # type: Optional[str] if cont_token is None: - raw_result = self._delete_initial( + raw_result = self._delete_initial( # type: ignore resource_group_name=resource_group_name, api_version=api_version, - cls=lambda x,y,z: x, + cls=lambda x, y, z: x, + headers=_headers, + params=_params, **kwargs ) - kwargs.pop('error_map', None) + kwargs.pop("error_map", None) - def get_long_running_output(pipeline_response): + def get_long_running_output(pipeline_response): # pylint: disable=inconsistent-return-statements if cls: return cls(pipeline_response, None, {}) - - if polling is True: polling_method = ARMPolling(lro_delay, **kwargs) - elif polling is False: polling_method = NoPolling() - else: polling_method = polling + if polling is True: + polling_method = cast(PollingMethod, ARMPolling(lro_delay, **kwargs)) # type: PollingMethod + elif polling is False: + polling_method = cast(PollingMethod, NoPolling()) + else: + polling_method = polling if cont_token: return LROPoller.from_continuation_token( polling_method=polling_method, continuation_token=cont_token, client=self._client, - deserialization_callback=get_long_running_output + deserialization_callback=get_long_running_output, ) return LROPoller(self._client, raw_result, get_long_running_output, polling_method) - begin_delete.metadata = {'url': "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}"} # type: ignore + begin_delete.metadata = {"url": "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}"} # type: ignore @distributed_trace - def get( - self, - resource_group_name: str, - **kwargs: Any - ) -> "_models.ResourceGroup": + def get(self, resource_group_name: str, **kwargs: Any) -> _models.ResourceGroup: """Gets a resource group. :param resource_group_name: The name of the resource group to get. The name is case - insensitive. + insensitive. Required. :type resource_group_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: ResourceGroup, or the result of cls(response) + :return: ResourceGroup or the result of cls(response) :rtype: ~azure.mgmt.resource.resources.v2019_07_01.models.ResourceGroup - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.ResourceGroup"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + 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', "2019-07-01") # type: str + api_version = kwargs.pop("api_version", _params.pop("api-version", "2019-07-01")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[_models.ResourceGroup] - request = build_resource_groups_get_request( resource_group_name=resource_group_name, subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.get.metadata['url'], + template_url=self.get.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) - deserialized = self._deserialize('ResourceGroup', pipeline_response) + deserialized = self._deserialize("ResourceGroup", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - get.metadata = {'url': "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}"} # type: ignore - + get.metadata = {"url": "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}"} # type: ignore - @distributed_trace + @overload def update( self, resource_group_name: str, - parameters: "_models.ResourceGroupPatchable", + parameters: _models.ResourceGroupPatchable, + *, + content_type: str = "application/json", **kwargs: Any - ) -> "_models.ResourceGroup": + ) -> _models.ResourceGroup: """Updates a resource group. Resource groups can be updated through a simple PATCH operation to a group address. The format @@ -8904,25 +10070,90 @@ def update( the current value is retained. :param resource_group_name: The name of the resource group to update. The name is case - insensitive. + insensitive. Required. :type resource_group_name: str - :param parameters: Parameters supplied to update a resource group. + :param parameters: Parameters supplied to update a resource group. Required. :type parameters: ~azure.mgmt.resource.resources.v2019_07_01.models.ResourceGroupPatchable + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: ResourceGroup or the result of cls(response) + :rtype: ~azure.mgmt.resource.resources.v2019_07_01.models.ResourceGroup + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + def update( + self, resource_group_name: str, parameters: IO, *, content_type: str = "application/json", **kwargs: Any + ) -> _models.ResourceGroup: + """Updates a resource group. + + Resource groups can be updated through a simple PATCH operation to a group address. The format + of the request is the same as that for creating a resource group. If a field is unspecified, + the current value is retained. + + :param resource_group_name: The name of the resource group to update. The name is case + insensitive. Required. + :type resource_group_name: str + :param parameters: Parameters supplied to update a resource group. Required. + :type parameters: IO + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: ResourceGroup, or the result of cls(response) + :return: ResourceGroup or the result of cls(response) :rtype: ~azure.mgmt.resource.resources.v2019_07_01.models.ResourceGroup - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace + def update( + self, resource_group_name: str, parameters: Union[_models.ResourceGroupPatchable, IO], **kwargs: Any + ) -> _models.ResourceGroup: + """Updates a resource group. + + Resource groups can be updated through a simple PATCH operation to a group address. The format + of the request is the same as that for creating a resource group. If a field is unspecified, + the current value is retained. + + :param resource_group_name: The name of the resource group to update. The name is case + insensitive. Required. + :type resource_group_name: str + :param parameters: Parameters supplied to update a resource group. Is either a model type or a + IO type. Required. + :type parameters: ~azure.mgmt.resource.resources.v2019_07_01.models.ResourceGroupPatchable or + IO + :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. + Default value is None. + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: ResourceGroup or the result of cls(response) + :rtype: ~azure.mgmt.resource.resources.v2019_07_01.models.ResourceGroup + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.ResourceGroup"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', "2019-07-01") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + api_version = kwargs.pop("api_version", _params.pop("api-version", "2019-07-01")) # type: str + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.ResourceGroup] - _json = self._serialize.body(parameters, 'ResourceGroupPatchable') + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(parameters, (IO, bytes)): + _content = parameters + else: + _json = self._serialize.body(parameters, "ResourceGroupPatchable") request = build_resource_groups_update_request( resource_group_name=resource_group_name, @@ -8930,60 +10161,117 @@ def update( api_version=api_version, content_type=content_type, json=_json, - template_url=self.update.metadata['url'], + content=_content, + template_url=self.update.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) - deserialized = self._deserialize('ResourceGroup', pipeline_response) + deserialized = self._deserialize("ResourceGroup", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - update.metadata = {'url': "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}"} # type: ignore - + update.metadata = {"url": "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}"} # type: ignore - @distributed_trace + @overload def export_template( self, resource_group_name: str, - parameters: "_models.ExportTemplateRequest", + parameters: _models.ExportTemplateRequest, + *, + content_type: str = "application/json", **kwargs: Any - ) -> "_models.ResourceGroupExportResult": + ) -> _models.ResourceGroupExportResult: """Captures the specified resource group as a template. - :param resource_group_name: The name of the resource group to export as a template. + :param resource_group_name: The name of the resource group to export as a template. Required. :type resource_group_name: str - :param parameters: Parameters for exporting the template. + :param parameters: Parameters for exporting the template. Required. :type parameters: ~azure.mgmt.resource.resources.v2019_07_01.models.ExportTemplateRequest + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: ResourceGroupExportResult or the result of cls(response) + :rtype: ~azure.mgmt.resource.resources.v2019_07_01.models.ResourceGroupExportResult + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + def export_template( + self, resource_group_name: str, parameters: IO, *, content_type: str = "application/json", **kwargs: Any + ) -> _models.ResourceGroupExportResult: + """Captures the specified resource group as a template. + + :param resource_group_name: The name of the resource group to export as a template. Required. + :type resource_group_name: str + :param parameters: Parameters for exporting the template. Required. + :type parameters: IO + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: ResourceGroupExportResult or the result of cls(response) + :rtype: ~azure.mgmt.resource.resources.v2019_07_01.models.ResourceGroupExportResult + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace + def export_template( + self, resource_group_name: str, parameters: Union[_models.ExportTemplateRequest, IO], **kwargs: Any + ) -> _models.ResourceGroupExportResult: + """Captures the specified resource group as a template. + + :param resource_group_name: The name of the resource group to export as a template. Required. + :type resource_group_name: str + :param parameters: Parameters for exporting the template. Is either a model type or a IO type. + Required. + :type parameters: ~azure.mgmt.resource.resources.v2019_07_01.models.ExportTemplateRequest or IO + :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. + Default value is None. + :paramtype content_type: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: ResourceGroupExportResult, or the result of cls(response) + :return: ResourceGroupExportResult or the result of cls(response) :rtype: ~azure.mgmt.resource.resources.v2019_07_01.models.ResourceGroupExportResult - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.ResourceGroupExportResult"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', "2019-07-01") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + api_version = kwargs.pop("api_version", _params.pop("api-version", "2019-07-01")) # type: str + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.ResourceGroupExportResult] - _json = self._serialize.body(parameters, 'ExportTemplateRequest') + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(parameters, (IO, bytes)): + _content = parameters + else: + _json = self._serialize.body(parameters, "ExportTemplateRequest") request = build_resource_groups_export_template_request( resource_group_name=resource_group_name, @@ -8991,39 +10279,37 @@ def export_template( api_version=api_version, content_type=content_type, json=_json, - template_url=self.export_template.metadata['url'], + content=_content, + template_url=self.export_template.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) - deserialized = self._deserialize('ResourceGroupExportResult', pipeline_response) + deserialized = self._deserialize("ResourceGroupExportResult", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - export_template.metadata = {'url': "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/exportTemplate"} # type: ignore - + export_template.metadata = {"url": "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/exportTemplate"} # type: ignore @distributed_trace def list( - self, - filter: Optional[str] = None, - top: Optional[int] = None, - **kwargs: Any - ) -> Iterable["_models.ResourceGroupListResult"]: + self, filter: Optional[str] = None, top: Optional[int] = None, **kwargs: Any + ) -> Iterable["_models.ResourceGroup"]: """Gets all the resource groups for a subscription. :param filter: The filter to apply on the operation.:code:`
`:code:`
`You can filter by @@ -9034,40 +10320,48 @@ def list( Default value is None. :type top: int :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either ResourceGroupListResult or the result of - cls(response) + :return: An iterator like instance of either ResourceGroup or the result of cls(response) :rtype: - ~azure.core.paging.ItemPaged[~azure.mgmt.resource.resources.v2019_07_01.models.ResourceGroupListResult] - :raises: ~azure.core.exceptions.HttpResponseError + ~azure.core.paging.ItemPaged[~azure.mgmt.resource.resources.v2019_07_01.models.ResourceGroup] + :raises ~azure.core.exceptions.HttpResponseError: """ - api_version = kwargs.pop('api_version', "2019-07-01") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2019-07-01")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[_models.ResourceGroupListResult] - cls = kwargs.pop('cls', None) # type: ClsType["_models.ResourceGroupListResult"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) + def prepare_request(next_link=None): if not next_link: - + request = build_resource_groups_list_request( subscription_id=self._config.subscription_id, - api_version=api_version, filter=filter, top=top, - template_url=self.list.metadata['url'], + 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.url = self._client.format_url(request.url) # type: ignore else: - - request = build_resource_groups_list_request( - subscription_id=self._config.subscription_id, - template_url=next_link, - ) + # make call to next link with the client's api-version + _parsed_next_link = urlparse(next_link) + _next_request_params = case_insensitive_dict(parse_qs(_parsed_next_link.query)) + _next_request_params["api-version"] = self._config.api_version + request = HttpRequest("GET", urljoin(next_link, _parsed_next_link.path), params=_next_request_params) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore request.method = "GET" return request @@ -9081,10 +10375,8 @@ def extract_data(pipeline_response): def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) response = pipeline_response.http_response @@ -9094,75 +10386,75 @@ def get_next(next_link=None): return pipeline_response + return ItemPaged(get_next, extract_data) + + list.metadata = {"url": "/subscriptions/{subscriptionId}/resourcegroups"} # type: ignore - return ItemPaged( - get_next, extract_data - ) - list.metadata = {'url': "/subscriptions/{subscriptionId}/resourcegroups"} # type: ignore -class TagsOperations(object): - """TagsOperations operations. - You should not instantiate this class directly. Instead, you should create a Client instance that - instantiates it for you and attaches it as an attribute. +class TagsOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. - :ivar models: Alias to model classes used in this operation group. - :type models: ~azure.mgmt.resource.resources.v2019_07_01.models - :param client: Client for service requests. - :param config: Configuration of service client. - :param serializer: An object model serializer. - :param deserializer: An object model deserializer. + Instead, you should access the following operations through + :class:`~azure.mgmt.resource.resources.v2019_07_01.ResourceManagementClient`'s + :attr:`tags` attribute. """ models = _models - def __init__(self, client, config, serializer, deserializer): - self._client = client - self._serialize = serializer - self._deserialize = deserializer - self._config = config + def __init__(self, *args, **kwargs): + input_args = list(args) + self._client = input_args.pop(0) if input_args else kwargs.pop("client") + self._config = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") @distributed_trace def delete_value( # pylint: disable=inconsistent-return-statements - self, - tag_name: str, - tag_value: str, - **kwargs: Any + self, tag_name: str, tag_value: str, **kwargs: Any ) -> None: """Deletes a tag value. - :param tag_name: The name of the tag. + :param tag_name: The name of the tag. Required. :type tag_name: str - :param tag_value: The value of the tag to delete. + :param tag_value: The value of the tag to delete. Required. :type tag_value: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: None, or the result of cls(response) + :return: None or the result of cls(response) :rtype: None - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType[None] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + 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', "2019-07-01") # type: str + api_version = kwargs.pop("api_version", _params.pop("api-version", "2019-07-01")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[None] - request = build_tags_delete_value_request( tag_name=tag_name, tag_value=tag_value, subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.delete_value.metadata['url'], + template_url=self.delete_value.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200, 204]: @@ -9172,51 +10464,51 @@ def delete_value( # pylint: disable=inconsistent-return-statements if cls: return cls(pipeline_response, None, {}) - delete_value.metadata = {'url': "/subscriptions/{subscriptionId}/tagNames/{tagName}/tagValues/{tagValue}"} # type: ignore - + delete_value.metadata = {"url": "/subscriptions/{subscriptionId}/tagNames/{tagName}/tagValues/{tagValue}"} # type: ignore @distributed_trace - def create_or_update_value( - self, - tag_name: str, - tag_value: str, - **kwargs: Any - ) -> "_models.TagValue": + def create_or_update_value(self, tag_name: str, tag_value: str, **kwargs: Any) -> _models.TagValue: """Creates a tag value. The name of the tag must already exist. - :param tag_name: The name of the tag. + :param tag_name: The name of the tag. Required. :type tag_name: str - :param tag_value: The value of the tag to create. + :param tag_value: The value of the tag to create. Required. :type tag_value: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: TagValue, or the result of cls(response) + :return: TagValue or the result of cls(response) :rtype: ~azure.mgmt.resource.resources.v2019_07_01.models.TagValue - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.TagValue"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) - api_version = kwargs.pop('api_version', "2019-07-01") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2019-07-01")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[_models.TagValue] - request = build_tags_create_or_update_value_request( tag_name=tag_name, tag_value=tag_value, subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.create_or_update_value.metadata['url'], + template_url=self.create_or_update_value.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200, 201]: @@ -9224,61 +10516,62 @@ def create_or_update_value( raise HttpResponseError(response=response, error_format=ARMErrorFormat) if response.status_code == 200: - deserialized = self._deserialize('TagValue', pipeline_response) + deserialized = self._deserialize("TagValue", pipeline_response) if response.status_code == 201: - deserialized = self._deserialize('TagValue', pipeline_response) + deserialized = self._deserialize("TagValue", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - create_or_update_value.metadata = {'url': "/subscriptions/{subscriptionId}/tagNames/{tagName}/tagValues/{tagValue}"} # type: ignore - + create_or_update_value.metadata = {"url": "/subscriptions/{subscriptionId}/tagNames/{tagName}/tagValues/{tagValue}"} # type: ignore @distributed_trace - def create_or_update( - self, - tag_name: str, - **kwargs: Any - ) -> "_models.TagDetails": + def create_or_update(self, tag_name: str, **kwargs: Any) -> _models.TagDetails: """Creates a tag in the subscription. The tag name can have a maximum of 512 characters and is case insensitive. Tag names created by Azure have prefixes of microsoft, azure, or windows. You cannot create tags with one of these prefixes. - :param tag_name: The name of the tag to create. + :param tag_name: The name of the tag to create. Required. :type tag_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: TagDetails, or the result of cls(response) + :return: TagDetails or the result of cls(response) :rtype: ~azure.mgmt.resource.resources.v2019_07_01.models.TagDetails - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.TagDetails"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) - api_version = kwargs.pop('api_version', "2019-07-01") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2019-07-01")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[_models.TagDetails] - request = build_tags_create_or_update_request( tag_name=tag_name, subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.create_or_update.metadata['url'], + template_url=self.create_or_update.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200, 201]: @@ -9286,59 +10579,60 @@ def create_or_update( raise HttpResponseError(response=response, error_format=ARMErrorFormat) if response.status_code == 200: - deserialized = self._deserialize('TagDetails', pipeline_response) + deserialized = self._deserialize("TagDetails", pipeline_response) if response.status_code == 201: - deserialized = self._deserialize('TagDetails', pipeline_response) + deserialized = self._deserialize("TagDetails", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - create_or_update.metadata = {'url': "/subscriptions/{subscriptionId}/tagNames/{tagName}"} # type: ignore - + create_or_update.metadata = {"url": "/subscriptions/{subscriptionId}/tagNames/{tagName}"} # type: ignore @distributed_trace - def delete( # pylint: disable=inconsistent-return-statements - self, - tag_name: str, - **kwargs: Any - ) -> None: + def delete(self, tag_name: str, **kwargs: Any) -> None: # pylint: disable=inconsistent-return-statements """Deletes a tag from the subscription. You must remove all values from a resource tag before you can delete it. - :param tag_name: The name of the tag. + :param tag_name: The name of the tag. Required. :type tag_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: None, or the result of cls(response) + :return: None or the result of cls(response) :rtype: None - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType[None] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) - api_version = kwargs.pop('api_version', "2019-07-01") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2019-07-01")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[None] - request = build_tags_delete_request( tag_name=tag_name, subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.delete.metadata['url'], + template_url=self.delete.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200, 204]: @@ -9348,48 +10642,53 @@ def delete( # pylint: disable=inconsistent-return-statements if cls: return cls(pipeline_response, None, {}) - delete.metadata = {'url': "/subscriptions/{subscriptionId}/tagNames/{tagName}"} # type: ignore - + delete.metadata = {"url": "/subscriptions/{subscriptionId}/tagNames/{tagName}"} # type: ignore @distributed_trace - def list( - self, - **kwargs: Any - ) -> Iterable["_models.TagsListResult"]: + def list(self, **kwargs: Any) -> Iterable["_models.TagDetails"]: """Gets the names and values of all resource tags that are defined in a subscription. :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either TagsListResult or the result of cls(response) + :return: An iterator like instance of either TagDetails or the result of cls(response) :rtype: - ~azure.core.paging.ItemPaged[~azure.mgmt.resource.resources.v2019_07_01.models.TagsListResult] - :raises: ~azure.core.exceptions.HttpResponseError + ~azure.core.paging.ItemPaged[~azure.mgmt.resource.resources.v2019_07_01.models.TagDetails] + :raises ~azure.core.exceptions.HttpResponseError: """ - api_version = kwargs.pop('api_version', "2019-07-01") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2019-07-01")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[_models.TagsListResult] - cls = kwargs.pop('cls', None) # type: ClsType["_models.TagsListResult"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) + def prepare_request(next_link=None): if not next_link: - + request = build_tags_list_request( subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.list.metadata['url'], + template_url=self.list.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore else: - - request = build_tags_list_request( - subscription_id=self._config.subscription_id, - template_url=next_link, - ) + # make call to next link with the client's api-version + _parsed_next_link = urlparse(next_link) + _next_request_params = case_insensitive_dict(parse_qs(_parsed_next_link.query)) + _next_request_params["api-version"] = self._config.api_version + request = HttpRequest("GET", urljoin(next_link, _parsed_next_link.path), params=_next_request_params) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore request.method = "GET" return request @@ -9403,10 +10702,8 @@ def extract_data(pipeline_response): def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) response = pipeline_response.http_response @@ -9416,146 +10713,147 @@ def get_next(next_link=None): return pipeline_response + return ItemPaged(get_next, extract_data) - return ItemPaged( - get_next, extract_data - ) - list.metadata = {'url': "/subscriptions/{subscriptionId}/tagNames"} # type: ignore -class DeploymentOperationsOperations(object): - """DeploymentOperationsOperations operations. + list.metadata = {"url": "/subscriptions/{subscriptionId}/tagNames"} # type: ignore - You should not instantiate this class directly. Instead, you should create a Client instance that - instantiates it for you and attaches it as an attribute. - :ivar models: Alias to model classes used in this operation group. - :type models: ~azure.mgmt.resource.resources.v2019_07_01.models - :param client: Client for service requests. - :param config: Configuration of service client. - :param serializer: An object model serializer. - :param deserializer: An object model deserializer. +class DeploymentOperationsOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. + + Instead, you should access the following operations through + :class:`~azure.mgmt.resource.resources.v2019_07_01.ResourceManagementClient`'s + :attr:`deployment_operations` attribute. """ models = _models - def __init__(self, client, config, serializer, deserializer): - self._client = client - self._serialize = serializer - self._deserialize = deserializer - self._config = config + def __init__(self, *args, **kwargs): + input_args = list(args) + self._client = input_args.pop(0) if input_args else kwargs.pop("client") + self._config = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") @distributed_trace def get_at_scope( - self, - scope: str, - deployment_name: str, - operation_id: str, - **kwargs: Any - ) -> "_models.DeploymentOperation": + self, scope: str, deployment_name: str, operation_id: str, **kwargs: Any + ) -> _models.DeploymentOperation: """Gets a deployments operation. - :param scope: The scope of a deployment. + :param scope: The scope of a deployment. Required. :type scope: str - :param deployment_name: The name of the deployment. + :param deployment_name: The name of the deployment. Required. :type deployment_name: str - :param operation_id: The ID of the operation to get. + :param operation_id: The ID of the operation to get. Required. :type operation_id: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: DeploymentOperation, or the result of cls(response) + :return: DeploymentOperation or the result of cls(response) :rtype: ~azure.mgmt.resource.resources.v2019_07_01.models.DeploymentOperation - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.DeploymentOperation"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) - api_version = kwargs.pop('api_version', "2019-07-01") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2019-07-01")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[_models.DeploymentOperation] - request = build_deployment_operations_get_at_scope_request( scope=scope, deployment_name=deployment_name, operation_id=operation_id, api_version=api_version, - template_url=self.get_at_scope.metadata['url'], + template_url=self.get_at_scope.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) - deserialized = self._deserialize('DeploymentOperation', pipeline_response) + deserialized = self._deserialize("DeploymentOperation", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - get_at_scope.metadata = {'url': "/{scope}/providers/Microsoft.Resources/deployments/{deploymentName}/operations/{operationId}"} # type: ignore - + get_at_scope.metadata = {"url": "/{scope}/providers/Microsoft.Resources/deployments/{deploymentName}/operations/{operationId}"} # type: ignore @distributed_trace def list_at_scope( - self, - scope: str, - deployment_name: str, - top: Optional[int] = None, - **kwargs: Any - ) -> Iterable["_models.DeploymentOperationsListResult"]: + self, scope: str, deployment_name: str, top: Optional[int] = None, **kwargs: Any + ) -> Iterable["_models.DeploymentOperation"]: """Gets all deployments operations for a deployment. - :param scope: The scope of a deployment. + :param scope: The scope of a deployment. Required. :type scope: str - :param deployment_name: The name of the deployment. + :param deployment_name: The name of the deployment. Required. :type deployment_name: str :param top: The number of results to return. Default value is None. :type top: int :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either DeploymentOperationsListResult or the result of - cls(response) + :return: An iterator like instance of either DeploymentOperation or the result of cls(response) :rtype: - ~azure.core.paging.ItemPaged[~azure.mgmt.resource.resources.v2019_07_01.models.DeploymentOperationsListResult] - :raises: ~azure.core.exceptions.HttpResponseError + ~azure.core.paging.ItemPaged[~azure.mgmt.resource.resources.v2019_07_01.models.DeploymentOperation] + :raises ~azure.core.exceptions.HttpResponseError: """ - api_version = kwargs.pop('api_version', "2019-07-01") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2019-07-01")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[_models.DeploymentOperationsListResult] - cls = kwargs.pop('cls', None) # type: ClsType["_models.DeploymentOperationsListResult"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) + def prepare_request(next_link=None): if not next_link: - + request = build_deployment_operations_list_at_scope_request( scope=scope, deployment_name=deployment_name, - api_version=api_version, top=top, - template_url=self.list_at_scope.metadata['url'], + api_version=api_version, + template_url=self.list_at_scope.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore else: - - request = build_deployment_operations_list_at_scope_request( - scope=scope, - deployment_name=deployment_name, - template_url=next_link, - ) + # make call to next link with the client's api-version + _parsed_next_link = urlparse(next_link) + _next_request_params = case_insensitive_dict(parse_qs(_parsed_next_link.query)) + _next_request_params["api-version"] = self._config.api_version + request = HttpRequest("GET", urljoin(next_link, _parsed_next_link.path), params=_next_request_params) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore request.method = "GET" return request @@ -9569,10 +10867,8 @@ def extract_data(pipeline_response): def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) response = pipeline_response.http_response @@ -9582,116 +10878,121 @@ def get_next(next_link=None): return pipeline_response + return ItemPaged(get_next, extract_data) - return ItemPaged( - get_next, extract_data - ) - list_at_scope.metadata = {'url': "/{scope}/providers/Microsoft.Resources/deployments/{deploymentName}/operations"} # type: ignore + list_at_scope.metadata = {"url": "/{scope}/providers/Microsoft.Resources/deployments/{deploymentName}/operations"} # type: ignore @distributed_trace def get_at_tenant_scope( - self, - deployment_name: str, - operation_id: str, - **kwargs: Any - ) -> "_models.DeploymentOperation": + self, deployment_name: str, operation_id: str, **kwargs: Any + ) -> _models.DeploymentOperation: """Gets a deployments operation. - :param deployment_name: The name of the deployment. + :param deployment_name: The name of the deployment. Required. :type deployment_name: str - :param operation_id: The ID of the operation to get. + :param operation_id: The ID of the operation to get. Required. :type operation_id: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: DeploymentOperation, or the result of cls(response) + :return: DeploymentOperation or the result of cls(response) :rtype: ~azure.mgmt.resource.resources.v2019_07_01.models.DeploymentOperation - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.DeploymentOperation"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + 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', "2019-07-01") # type: str + api_version = kwargs.pop("api_version", _params.pop("api-version", "2019-07-01")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[_models.DeploymentOperation] - request = build_deployment_operations_get_at_tenant_scope_request( deployment_name=deployment_name, operation_id=operation_id, api_version=api_version, - template_url=self.get_at_tenant_scope.metadata['url'], + template_url=self.get_at_tenant_scope.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) - deserialized = self._deserialize('DeploymentOperation', pipeline_response) + deserialized = self._deserialize("DeploymentOperation", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - get_at_tenant_scope.metadata = {'url': "/providers/Microsoft.Resources/deployments/{deploymentName}/operations/{operationId}"} # type: ignore - + get_at_tenant_scope.metadata = {"url": "/providers/Microsoft.Resources/deployments/{deploymentName}/operations/{operationId}"} # type: ignore @distributed_trace def list_at_tenant_scope( - self, - deployment_name: str, - top: Optional[int] = None, - **kwargs: Any - ) -> Iterable["_models.DeploymentOperationsListResult"]: + self, deployment_name: str, top: Optional[int] = None, **kwargs: Any + ) -> Iterable["_models.DeploymentOperation"]: """Gets all deployments operations for a deployment. - :param deployment_name: The name of the deployment. + :param deployment_name: The name of the deployment. Required. :type deployment_name: str :param top: The number of results to return. Default value is None. :type top: int :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either DeploymentOperationsListResult or the result of - cls(response) + :return: An iterator like instance of either DeploymentOperation or the result of cls(response) :rtype: - ~azure.core.paging.ItemPaged[~azure.mgmt.resource.resources.v2019_07_01.models.DeploymentOperationsListResult] - :raises: ~azure.core.exceptions.HttpResponseError + ~azure.core.paging.ItemPaged[~azure.mgmt.resource.resources.v2019_07_01.models.DeploymentOperation] + :raises ~azure.core.exceptions.HttpResponseError: """ - api_version = kwargs.pop('api_version', "2019-07-01") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2019-07-01")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[_models.DeploymentOperationsListResult] - cls = kwargs.pop('cls', None) # type: ClsType["_models.DeploymentOperationsListResult"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) + def prepare_request(next_link=None): if not next_link: - + request = build_deployment_operations_list_at_tenant_scope_request( deployment_name=deployment_name, - api_version=api_version, top=top, - template_url=self.list_at_tenant_scope.metadata['url'], + api_version=api_version, + template_url=self.list_at_tenant_scope.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore else: - - request = build_deployment_operations_list_at_tenant_scope_request( - deployment_name=deployment_name, - template_url=next_link, - ) + # make call to next link with the client's api-version + _parsed_next_link = urlparse(next_link) + _next_request_params = case_insensitive_dict(parse_qs(_parsed_next_link.query)) + _next_request_params["api-version"] = self._config.api_version + request = HttpRequest("GET", urljoin(next_link, _parsed_next_link.path), params=_next_request_params) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore request.method = "GET" return request @@ -9705,10 +11006,8 @@ def extract_data(pipeline_response): def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) response = pipeline_response.http_response @@ -9718,125 +11017,127 @@ def get_next(next_link=None): return pipeline_response + return ItemPaged(get_next, extract_data) - return ItemPaged( - get_next, extract_data - ) - list_at_tenant_scope.metadata = {'url': "/providers/Microsoft.Resources/deployments/{deploymentName}/operations"} # type: ignore + list_at_tenant_scope.metadata = {"url": "/providers/Microsoft.Resources/deployments/{deploymentName}/operations"} # type: ignore @distributed_trace def get_at_management_group_scope( - self, - group_id: str, - deployment_name: str, - operation_id: str, - **kwargs: Any - ) -> "_models.DeploymentOperation": + self, group_id: str, deployment_name: str, operation_id: str, **kwargs: Any + ) -> _models.DeploymentOperation: """Gets a deployments operation. - :param group_id: The management group ID. + :param group_id: The management group ID. Required. :type group_id: str - :param deployment_name: The name of the deployment. + :param deployment_name: The name of the deployment. Required. :type deployment_name: str - :param operation_id: The ID of the operation to get. + :param operation_id: The ID of the operation to get. Required. :type operation_id: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: DeploymentOperation, or the result of cls(response) + :return: DeploymentOperation or the result of cls(response) :rtype: ~azure.mgmt.resource.resources.v2019_07_01.models.DeploymentOperation - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.DeploymentOperation"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + 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', "2019-07-01") # type: str + api_version = kwargs.pop("api_version", _params.pop("api-version", "2019-07-01")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[_models.DeploymentOperation] - request = build_deployment_operations_get_at_management_group_scope_request( group_id=group_id, deployment_name=deployment_name, operation_id=operation_id, api_version=api_version, - template_url=self.get_at_management_group_scope.metadata['url'], + template_url=self.get_at_management_group_scope.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) - deserialized = self._deserialize('DeploymentOperation', pipeline_response) + deserialized = self._deserialize("DeploymentOperation", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - get_at_management_group_scope.metadata = {'url': "/providers/Microsoft.Management/managementGroups/{groupId}/providers/Microsoft.Resources/deployments/{deploymentName}/operations/{operationId}"} # type: ignore - + get_at_management_group_scope.metadata = {"url": "/providers/Microsoft.Management/managementGroups/{groupId}/providers/Microsoft.Resources/deployments/{deploymentName}/operations/{operationId}"} # type: ignore @distributed_trace def list_at_management_group_scope( - self, - group_id: str, - deployment_name: str, - top: Optional[int] = None, - **kwargs: Any - ) -> Iterable["_models.DeploymentOperationsListResult"]: + self, group_id: str, deployment_name: str, top: Optional[int] = None, **kwargs: Any + ) -> Iterable["_models.DeploymentOperation"]: """Gets all deployments operations for a deployment. - :param group_id: The management group ID. + :param group_id: The management group ID. Required. :type group_id: str - :param deployment_name: The name of the deployment. + :param deployment_name: The name of the deployment. Required. :type deployment_name: str :param top: The number of results to return. Default value is None. :type top: int :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either DeploymentOperationsListResult or the result of - cls(response) + :return: An iterator like instance of either DeploymentOperation or the result of cls(response) :rtype: - ~azure.core.paging.ItemPaged[~azure.mgmt.resource.resources.v2019_07_01.models.DeploymentOperationsListResult] - :raises: ~azure.core.exceptions.HttpResponseError + ~azure.core.paging.ItemPaged[~azure.mgmt.resource.resources.v2019_07_01.models.DeploymentOperation] + :raises ~azure.core.exceptions.HttpResponseError: """ - api_version = kwargs.pop('api_version', "2019-07-01") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2019-07-01")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[_models.DeploymentOperationsListResult] - cls = kwargs.pop('cls', None) # type: ClsType["_models.DeploymentOperationsListResult"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) + def prepare_request(next_link=None): if not next_link: - + request = build_deployment_operations_list_at_management_group_scope_request( group_id=group_id, deployment_name=deployment_name, - api_version=api_version, top=top, - template_url=self.list_at_management_group_scope.metadata['url'], + api_version=api_version, + template_url=self.list_at_management_group_scope.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore else: - - request = build_deployment_operations_list_at_management_group_scope_request( - group_id=group_id, - deployment_name=deployment_name, - template_url=next_link, - ) + # make call to next link with the client's api-version + _parsed_next_link = urlparse(next_link) + _next_request_params = case_insensitive_dict(parse_qs(_parsed_next_link.query)) + _next_request_params["api-version"] = self._config.api_version + request = HttpRequest("GET", urljoin(next_link, _parsed_next_link.path), params=_next_request_params) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore request.method = "GET" return request @@ -9850,10 +11151,8 @@ def extract_data(pipeline_response): def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) response = pipeline_response.http_response @@ -9863,119 +11162,123 @@ def get_next(next_link=None): return pipeline_response + return ItemPaged(get_next, extract_data) - return ItemPaged( - get_next, extract_data - ) - list_at_management_group_scope.metadata = {'url': "/providers/Microsoft.Management/managementGroups/{groupId}/providers/Microsoft.Resources/deployments/{deploymentName}/operations"} # type: ignore + list_at_management_group_scope.metadata = {"url": "/providers/Microsoft.Management/managementGroups/{groupId}/providers/Microsoft.Resources/deployments/{deploymentName}/operations"} # type: ignore @distributed_trace def get_at_subscription_scope( - self, - deployment_name: str, - operation_id: str, - **kwargs: Any - ) -> "_models.DeploymentOperation": + self, deployment_name: str, operation_id: str, **kwargs: Any + ) -> _models.DeploymentOperation: """Gets a deployments operation. - :param deployment_name: The name of the deployment. + :param deployment_name: The name of the deployment. Required. :type deployment_name: str - :param operation_id: The ID of the operation to get. + :param operation_id: The ID of the operation to get. Required. :type operation_id: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: DeploymentOperation, or the result of cls(response) + :return: DeploymentOperation or the result of cls(response) :rtype: ~azure.mgmt.resource.resources.v2019_07_01.models.DeploymentOperation - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.DeploymentOperation"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) - api_version = kwargs.pop('api_version', "2019-07-01") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2019-07-01")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[_models.DeploymentOperation] - request = build_deployment_operations_get_at_subscription_scope_request( deployment_name=deployment_name, operation_id=operation_id, subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.get_at_subscription_scope.metadata['url'], + template_url=self.get_at_subscription_scope.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) - deserialized = self._deserialize('DeploymentOperation', pipeline_response) + deserialized = self._deserialize("DeploymentOperation", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - get_at_subscription_scope.metadata = {'url': "/subscriptions/{subscriptionId}/providers/Microsoft.Resources/deployments/{deploymentName}/operations/{operationId}"} # type: ignore - + get_at_subscription_scope.metadata = {"url": "/subscriptions/{subscriptionId}/providers/Microsoft.Resources/deployments/{deploymentName}/operations/{operationId}"} # type: ignore @distributed_trace def list_at_subscription_scope( - self, - deployment_name: str, - top: Optional[int] = None, - **kwargs: Any - ) -> Iterable["_models.DeploymentOperationsListResult"]: + self, deployment_name: str, top: Optional[int] = None, **kwargs: Any + ) -> Iterable["_models.DeploymentOperation"]: """Gets all deployments operations for a deployment. - :param deployment_name: The name of the deployment. + :param deployment_name: The name of the deployment. Required. :type deployment_name: str :param top: The number of results to return. Default value is None. :type top: int :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either DeploymentOperationsListResult or the result of - cls(response) + :return: An iterator like instance of either DeploymentOperation or the result of cls(response) :rtype: - ~azure.core.paging.ItemPaged[~azure.mgmt.resource.resources.v2019_07_01.models.DeploymentOperationsListResult] - :raises: ~azure.core.exceptions.HttpResponseError + ~azure.core.paging.ItemPaged[~azure.mgmt.resource.resources.v2019_07_01.models.DeploymentOperation] + :raises ~azure.core.exceptions.HttpResponseError: """ - api_version = kwargs.pop('api_version', "2019-07-01") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2019-07-01")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[_models.DeploymentOperationsListResult] - cls = kwargs.pop('cls', None) # type: ClsType["_models.DeploymentOperationsListResult"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) + def prepare_request(next_link=None): if not next_link: - + request = build_deployment_operations_list_at_subscription_scope_request( deployment_name=deployment_name, subscription_id=self._config.subscription_id, - api_version=api_version, top=top, - template_url=self.list_at_subscription_scope.metadata['url'], + api_version=api_version, + template_url=self.list_at_subscription_scope.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore else: - - request = build_deployment_operations_list_at_subscription_scope_request( - deployment_name=deployment_name, - subscription_id=self._config.subscription_id, - template_url=next_link, - ) + # make call to next link with the client's api-version + _parsed_next_link = urlparse(next_link) + _next_request_params = case_insensitive_dict(parse_qs(_parsed_next_link.query)) + _next_request_params["api-version"] = self._config.api_version + request = HttpRequest("GET", urljoin(next_link, _parsed_next_link.path), params=_next_request_params) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore request.method = "GET" return request @@ -9989,10 +11292,8 @@ def extract_data(pipeline_response): def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) response = pipeline_response.http_response @@ -10002,128 +11303,131 @@ def get_next(next_link=None): return pipeline_response + return ItemPaged(get_next, extract_data) - return ItemPaged( - get_next, extract_data - ) - list_at_subscription_scope.metadata = {'url': "/subscriptions/{subscriptionId}/providers/Microsoft.Resources/deployments/{deploymentName}/operations"} # type: ignore + list_at_subscription_scope.metadata = {"url": "/subscriptions/{subscriptionId}/providers/Microsoft.Resources/deployments/{deploymentName}/operations"} # type: ignore @distributed_trace def get( - self, - resource_group_name: str, - deployment_name: str, - operation_id: str, - **kwargs: Any - ) -> "_models.DeploymentOperation": + self, resource_group_name: str, deployment_name: str, operation_id: str, **kwargs: Any + ) -> _models.DeploymentOperation: """Gets a deployments operation. :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. :type resource_group_name: str - :param deployment_name: The name of the deployment. + :param deployment_name: The name of the deployment. Required. :type deployment_name: str - :param operation_id: The ID of the operation to get. + :param operation_id: The ID of the operation to get. Required. :type operation_id: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: DeploymentOperation, or the result of cls(response) + :return: DeploymentOperation or the result of cls(response) :rtype: ~azure.mgmt.resource.resources.v2019_07_01.models.DeploymentOperation - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.DeploymentOperation"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + 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', "2019-07-01") # type: str + api_version = kwargs.pop("api_version", _params.pop("api-version", "2019-07-01")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[_models.DeploymentOperation] - request = build_deployment_operations_get_request( resource_group_name=resource_group_name, deployment_name=deployment_name, operation_id=operation_id, subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.get.metadata['url'], + template_url=self.get.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) - deserialized = self._deserialize('DeploymentOperation', pipeline_response) + deserialized = self._deserialize("DeploymentOperation", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - get.metadata = {'url': "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/deployments/{deploymentName}/operations/{operationId}"} # type: ignore - + get.metadata = {"url": "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/deployments/{deploymentName}/operations/{operationId}"} # type: ignore @distributed_trace def list( - self, - resource_group_name: str, - deployment_name: str, - top: Optional[int] = None, - **kwargs: Any - ) -> Iterable["_models.DeploymentOperationsListResult"]: + self, resource_group_name: str, deployment_name: str, top: Optional[int] = None, **kwargs: Any + ) -> Iterable["_models.DeploymentOperation"]: """Gets all deployments operations for a deployment. :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. :type resource_group_name: str - :param deployment_name: The name of the deployment. + :param deployment_name: The name of the deployment. Required. :type deployment_name: str :param top: The number of results to return. Default value is None. :type top: int :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either DeploymentOperationsListResult or the result of - cls(response) + :return: An iterator like instance of either DeploymentOperation or the result of cls(response) :rtype: - ~azure.core.paging.ItemPaged[~azure.mgmt.resource.resources.v2019_07_01.models.DeploymentOperationsListResult] - :raises: ~azure.core.exceptions.HttpResponseError + ~azure.core.paging.ItemPaged[~azure.mgmt.resource.resources.v2019_07_01.models.DeploymentOperation] + :raises ~azure.core.exceptions.HttpResponseError: """ - api_version = kwargs.pop('api_version', "2019-07-01") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2019-07-01")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[_models.DeploymentOperationsListResult] - cls = kwargs.pop('cls', None) # type: ClsType["_models.DeploymentOperationsListResult"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) + def prepare_request(next_link=None): if not next_link: - + request = build_deployment_operations_list_request( resource_group_name=resource_group_name, deployment_name=deployment_name, subscription_id=self._config.subscription_id, - api_version=api_version, top=top, - template_url=self.list.metadata['url'], + 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.url = self._client.format_url(request.url) # type: ignore else: - - request = build_deployment_operations_list_request( - resource_group_name=resource_group_name, - deployment_name=deployment_name, - subscription_id=self._config.subscription_id, - template_url=next_link, - ) + # make call to next link with the client's api-version + _parsed_next_link = urlparse(next_link) + _next_request_params = case_insensitive_dict(parse_qs(_parsed_next_link.query)) + _next_request_params["api-version"] = self._config.api_version + request = HttpRequest("GET", urljoin(next_link, _parsed_next_link.path), params=_next_request_params) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore request.method = "GET" return request @@ -10137,10 +11441,8 @@ def extract_data(pipeline_response): def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) response = pipeline_response.http_response @@ -10150,8 +11452,6 @@ def get_next(next_link=None): return pipeline_response + return ItemPaged(get_next, extract_data) - return ItemPaged( - get_next, extract_data - ) - list.metadata = {'url': "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/deployments/{deploymentName}/operations"} # type: ignore + list.metadata = {"url": "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/deployments/{deploymentName}/operations"} # type: ignore diff --git a/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/resources/v2019_07_01/operations/_patch.py b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/resources/v2019_07_01/operations/_patch.py new file mode 100644 index 0000000000000..f7dd32510333d --- /dev/null +++ b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/resources/v2019_07_01/operations/_patch.py @@ -0,0 +1,20 @@ +# ------------------------------------ +# Copyright (c) Microsoft Corporation. +# Licensed under the MIT License. +# ------------------------------------ +"""Customize generated code here. + +Follow our quickstart for examples: https://aka.ms/azsdk/python/dpcodegen/python/customize +""" +from typing import List + +__all__: List[str] = [] # Add all objects you want publicly available to users at this package level + + +def patch_sdk(): + """Do not remove from this file. + + `patch_sdk` is a last resort escape hatch that allows you to do customizations + you can't accomplish using the techniques described in + https://aka.ms/azsdk/python/dpcodegen/python/customize + """ diff --git a/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/resources/v2019_08_01/__init__.py b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/resources/v2019_08_01/__init__.py index 449220069f2f2..2b201470d075e 100644 --- a/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/resources/v2019_08_01/__init__.py +++ b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/resources/v2019_08_01/__init__.py @@ -10,9 +10,15 @@ from ._version import VERSION __version__ = VERSION -__all__ = ['ResourceManagementClient'] -# `._patch.py` is used for handwritten extensions to the generated code -# Example: https://github.com/Azure/azure-sdk-for-python/blob/main/doc/dev/customize_code/how-to-patch-sdk-code.md -from ._patch import patch_sdk -patch_sdk() +try: + from ._patch import __all__ as _patch_all + from ._patch import * # type: ignore # pylint: disable=unused-wildcard-import +except ImportError: + _patch_all = [] +from ._patch import patch_sdk as _patch_sdk + +__all__ = ["ResourceManagementClient"] +__all__.extend([p for p in _patch_all if p not in __all__]) + +_patch_sdk() diff --git a/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/resources/v2019_08_01/_configuration.py b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/resources/v2019_08_01/_configuration.py index 08c77b24998f3..524b05ebd47df 100644 --- a/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/resources/v2019_08_01/_configuration.py +++ b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/resources/v2019_08_01/_configuration.py @@ -25,23 +25,18 @@ class ResourceManagementClientConfiguration(Configuration): # pylint: disable=t Note that all parameters used to create this instance are saved as instance attributes. - :param credential: Credential needed for the client to connect to Azure. + :param credential: Credential needed for the client to connect to Azure. Required. :type credential: ~azure.core.credentials.TokenCredential - :param subscription_id: The ID of the target subscription. + :param subscription_id: The ID of the target subscription. Required. :type subscription_id: str :keyword api_version: Api Version. Default value is "2019-08-01". Note that overriding this default value may result in unsupported behavior. :paramtype api_version: str """ - def __init__( - self, - credential: "TokenCredential", - subscription_id: str, - **kwargs: Any - ) -> None: + def __init__(self, credential: "TokenCredential", subscription_id: str, **kwargs: Any) -> None: super(ResourceManagementClientConfiguration, self).__init__(**kwargs) - api_version = kwargs.pop('api_version', "2019-08-01") # type: str + api_version = kwargs.pop("api_version", "2019-08-01") # type: str if credential is None: raise ValueError("Parameter 'credential' must not be None.") @@ -51,23 +46,24 @@ def __init__( self.credential = credential self.subscription_id = subscription_id self.api_version = api_version - self.credential_scopes = kwargs.pop('credential_scopes', ['https://management.azure.com/.default']) - kwargs.setdefault('sdk_moniker', 'mgmt-resource/{}'.format(VERSION)) + self.credential_scopes = kwargs.pop("credential_scopes", ["https://management.azure.com/.default"]) + kwargs.setdefault("sdk_moniker", "mgmt-resource/{}".format(VERSION)) self._configure(**kwargs) def _configure( - self, - **kwargs # type: Any + self, **kwargs # type: Any ): # type: (...) -> 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) - self.logging_policy = kwargs.get('logging_policy') or policies.NetworkTraceLoggingPolicy(**kwargs) - self.http_logging_policy = kwargs.get('http_logging_policy') or ARMHttpLoggingPolicy(**kwargs) - self.retry_policy = kwargs.get('retry_policy') or policies.RetryPolicy(**kwargs) - self.custom_hook_policy = kwargs.get('custom_hook_policy') or policies.CustomHookPolicy(**kwargs) - self.redirect_policy = kwargs.get('redirect_policy') or policies.RedirectPolicy(**kwargs) - self.authentication_policy = kwargs.get('authentication_policy') + 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) + self.logging_policy = kwargs.get("logging_policy") or policies.NetworkTraceLoggingPolicy(**kwargs) + self.http_logging_policy = kwargs.get("http_logging_policy") or ARMHttpLoggingPolicy(**kwargs) + self.retry_policy = kwargs.get("retry_policy") or policies.RetryPolicy(**kwargs) + self.custom_hook_policy = kwargs.get("custom_hook_policy") or policies.CustomHookPolicy(**kwargs) + self.redirect_policy = kwargs.get("redirect_policy") or policies.RedirectPolicy(**kwargs) + self.authentication_policy = kwargs.get("authentication_policy") if self.credential and not self.authentication_policy: - self.authentication_policy = ARMChallengeAuthenticationPolicy(self.credential, *self.credential_scopes, **kwargs) + self.authentication_policy = ARMChallengeAuthenticationPolicy( + self.credential, *self.credential_scopes, **kwargs + ) diff --git a/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/resources/v2019_08_01/_metadata.json b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/resources/v2019_08_01/_metadata.json index f175181fcc27e..16dde3d249563 100644 --- a/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/resources/v2019_08_01/_metadata.json +++ b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/resources/v2019_08_01/_metadata.json @@ -10,20 +10,20 @@ "azure_arm": true, "has_lro_operations": true, "client_side_validation": false, - "sync_imports": "{\"typing\": {\"azurecore\": {\"azure.core.credentials\": [\"TokenCredential\"]}}, \"regular\": {\"azurecore\": {\"azure.profiles\": [\"KnownProfiles\", \"ProfileDefinition\"], \"azure.profiles.multiapiclient\": [\"MultiApiClientMixin\"], \"azure.mgmt.core\": [\"ARMPipelineClient\"]}, \"local\": {\"._configuration\": [\"ResourceManagementClientConfiguration\"]}, \"thirdparty\": {\"msrest\": [\"Deserializer\", \"Serializer\"]}}, \"conditional\": {\"stdlib\": {\"typing\": [\"Any\", \"Optional\"]}}}", - "async_imports": "{\"typing\": {\"azurecore\": {\"azure.core.credentials_async\": [\"AsyncTokenCredential\"], \"azure.core.credentials\": [\"TokenCredential\"]}}, \"regular\": {\"azurecore\": {\"azure.profiles\": [\"KnownProfiles\", \"ProfileDefinition\"], \"azure.profiles.multiapiclient\": [\"MultiApiClientMixin\"], \"azure.mgmt.core\": [\"AsyncARMPipelineClient\"]}, \"local\": {\"._configuration\": [\"ResourceManagementClientConfiguration\"]}, \"thirdparty\": {\"msrest\": [\"Deserializer\", \"Serializer\"]}}, \"conditional\": {\"stdlib\": {\"typing\": [\"Any\", \"Optional\"]}}}" + "sync_imports": "{\"conditional\": {\"stdlib\": {\"typing\": [\"Any\", \"Optional\"]}}, \"regular\": {\"azurecore\": {\"azure.mgmt.core\": [\"ARMPipelineClient\"], \"azure.profiles\": [\"KnownProfiles\", \"ProfileDefinition\"], \"azure.profiles.multiapiclient\": [\"MultiApiClientMixin\"]}, \"local\": {\"._configuration\": [\"ResourceManagementClientConfiguration\"], \".._serialization\": [\"Deserializer\", \"Serializer\"]}}, \"typing\": {\"azurecore\": {\"azure.core.credentials\": [\"TokenCredential\"]}}}", + "async_imports": "{\"conditional\": {\"stdlib\": {\"typing\": [\"Any\", \"Optional\"]}}, \"regular\": {\"azurecore\": {\"azure.mgmt.core\": [\"AsyncARMPipelineClient\"], \"azure.profiles\": [\"KnownProfiles\", \"ProfileDefinition\"], \"azure.profiles.multiapiclient\": [\"MultiApiClientMixin\"]}, \"local\": {\"._configuration\": [\"ResourceManagementClientConfiguration\"], \"..._serialization\": [\"Deserializer\", \"Serializer\"]}}, \"typing\": {\"azurecore\": {\"azure.core.credentials_async\": [\"AsyncTokenCredential\"]}}}" }, "global_parameters": { "sync": { "credential": { - "signature": "credential, # type: \"TokenCredential\"", - "description": "Credential needed for the client to connect to Azure.", + "signature": "credential: \"TokenCredential\",", + "description": "Credential needed for the client to connect to Azure. Required.", "docstring_type": "~azure.core.credentials.TokenCredential", "required": true }, "subscription_id": { - "signature": "subscription_id, # type: str", - "description": "The ID of the target subscription.", + "signature": "subscription_id: str,", + "description": "The ID of the target subscription. Required.", "docstring_type": "str", "required": true } @@ -31,13 +31,13 @@ "async": { "credential": { "signature": "credential: \"AsyncTokenCredential\",", - "description": "Credential needed for the client to connect to Azure.", + "description": "Credential needed for the client to connect to Azure. Required.", "docstring_type": "~azure.core.credentials_async.AsyncTokenCredential", "required": true }, "subscription_id": { "signature": "subscription_id: str,", - "description": "The ID of the target subscription.", + "description": "The ID of the target subscription. Required.", "docstring_type": "str", "required": true } @@ -54,7 +54,7 @@ "required": false }, "base_url": { - "signature": "base_url=\"https://management.azure.com\", # type: str", + "signature": "base_url: str = \"https://management.azure.com\",", "description": "Service URL", "docstring_type": "str", "required": false diff --git a/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/resources/v2019_08_01/_patch.py b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/resources/v2019_08_01/_patch.py index 74e48ecd07cf3..f99e77fef9861 100644 --- a/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/resources/v2019_08_01/_patch.py +++ b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/resources/v2019_08_01/_patch.py @@ -28,4 +28,4 @@ # This file is used for handwritten extensions to the generated code. Example: # https://github.com/Azure/azure-sdk-for-python/blob/main/doc/dev/customize_code/how-to-patch-sdk-code.md def patch_sdk(): - pass \ No newline at end of file + pass diff --git a/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/resources/v2019_08_01/_resource_management_client.py b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/resources/v2019_08_01/_resource_management_client.py index 6753b8501c4f1..20e3dfc3d75a9 100644 --- a/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/resources/v2019_08_01/_resource_management_client.py +++ b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/resources/v2019_08_01/_resource_management_client.py @@ -9,20 +9,28 @@ from copy import deepcopy from typing import Any, TYPE_CHECKING -from msrest import Deserializer, Serializer - from azure.core.rest import HttpRequest, HttpResponse from azure.mgmt.core import ARMPipelineClient from . import models +from .._serialization import Deserializer, Serializer from ._configuration import ResourceManagementClientConfiguration -from .operations import DeploymentOperationsOperations, DeploymentsOperations, Operations, ProvidersOperations, ResourceGroupsOperations, ResourcesOperations, TagsOperations +from .operations import ( + DeploymentOperationsOperations, + DeploymentsOperations, + Operations, + ProvidersOperations, + ResourceGroupsOperations, + ResourcesOperations, + TagsOperations, +) if TYPE_CHECKING: # pylint: disable=unused-import,ungrouped-imports from azure.core.credentials import TokenCredential -class ResourceManagementClient: # pylint: disable=too-many-instance-attributes + +class ResourceManagementClient: # pylint: disable=client-accepts-api-version-keyword,too-many-instance-attributes """Provides operations for working with resources and resource groups. :ivar operations: Operations operations @@ -42,9 +50,9 @@ class ResourceManagementClient: # pylint: disable=too-many-instance-attribute :ivar deployment_operations: DeploymentOperationsOperations operations :vartype deployment_operations: azure.mgmt.resource.resources.v2019_08_01.operations.DeploymentOperationsOperations - :param credential: Credential needed for the client to connect to Azure. + :param credential: Credential needed for the client to connect to Azure. Required. :type credential: ~azure.core.credentials.TokenCredential - :param subscription_id: The ID of the target subscription. + :param subscription_id: The ID of the target subscription. Required. :type subscription_id: str :param base_url: Service URL. Default value is "https://management.azure.com". :type base_url: str @@ -62,7 +70,9 @@ def __init__( base_url: str = "https://management.azure.com", **kwargs: Any ) -> None: - self._config = ResourceManagementClientConfiguration(credential=credential, subscription_id=subscription_id, **kwargs) + self._config = ResourceManagementClientConfiguration( + credential=credential, subscription_id=subscription_id, **kwargs + ) self._client = ARMPipelineClient(base_url=base_url, config=self._config, **kwargs) client_models = {k: v for k, v in models.__dict__.items() if isinstance(v, type)} @@ -75,14 +85,11 @@ def __init__( self.resources = ResourcesOperations(self._client, self._config, self._serialize, self._deserialize) self.resource_groups = ResourceGroupsOperations(self._client, self._config, self._serialize, self._deserialize) self.tags = TagsOperations(self._client, self._config, self._serialize, self._deserialize) - self.deployment_operations = DeploymentOperationsOperations(self._client, self._config, self._serialize, self._deserialize) - + self.deployment_operations = DeploymentOperationsOperations( + self._client, self._config, self._serialize, self._deserialize + ) - def _send_request( - self, - request: HttpRequest, - **kwargs: Any - ) -> HttpResponse: + def _send_request(self, request: HttpRequest, **kwargs: Any) -> HttpResponse: """Runs the network request through the client's chained policies. >>> from azure.core.rest import HttpRequest @@ -91,7 +98,7 @@ def _send_request( >>> response = client._send_request(request) - For more information on this code flow, see https://aka.ms/azsdk/python/protocol/quickstart + For more information on this code flow, see https://aka.ms/azsdk/dpcodegen/python/send_request :param request: The network request you want to make. Required. :type request: ~azure.core.rest.HttpRequest diff --git a/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/resources/v2019_08_01/_vendor.py b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/resources/v2019_08_01/_vendor.py index 138f663c53a4e..9aad73fc743e7 100644 --- a/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/resources/v2019_08_01/_vendor.py +++ b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/resources/v2019_08_01/_vendor.py @@ -7,6 +7,7 @@ from azure.core.pipeline.transport import HttpRequest + def _convert_request(request, files=None): data = request.content if not files else None request = HttpRequest(method=request.method, url=request.url, headers=request.headers, data=data) @@ -14,6 +15,7 @@ def _convert_request(request, files=None): request.set_formdata_body(files) return request + def _format_url_section(template, **kwargs): components = template.split("/") while components: @@ -21,7 +23,5 @@ def _format_url_section(template, **kwargs): 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 - ] + components = [c for c in formatted_components if "{}".format(key.args[0]) not in c] template = "/".join(components) diff --git a/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/resources/v2019_08_01/_version.py b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/resources/v2019_08_01/_version.py index a012ac01c480c..e5754a47ce68f 100644 --- a/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/resources/v2019_08_01/_version.py +++ b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/resources/v2019_08_01/_version.py @@ -6,4 +6,4 @@ # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -VERSION = "21.1.0" +VERSION = "1.0.0b1" diff --git a/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/resources/v2019_08_01/aio/__init__.py b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/resources/v2019_08_01/aio/__init__.py index c6c3cf64a37a6..98d6782c2530c 100644 --- a/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/resources/v2019_08_01/aio/__init__.py +++ b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/resources/v2019_08_01/aio/__init__.py @@ -7,9 +7,15 @@ # -------------------------------------------------------------------------- from ._resource_management_client import ResourceManagementClient -__all__ = ['ResourceManagementClient'] -# `._patch.py` is used for handwritten extensions to the generated code -# Example: https://github.com/Azure/azure-sdk-for-python/blob/main/doc/dev/customize_code/how-to-patch-sdk-code.md -from ._patch import patch_sdk -patch_sdk() +try: + from ._patch import __all__ as _patch_all + from ._patch import * # type: ignore # pylint: disable=unused-wildcard-import +except ImportError: + _patch_all = [] +from ._patch import patch_sdk as _patch_sdk + +__all__ = ["ResourceManagementClient"] +__all__.extend([p for p in _patch_all if p not in __all__]) + +_patch_sdk() diff --git a/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/resources/v2019_08_01/aio/_configuration.py b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/resources/v2019_08_01/aio/_configuration.py index c7d94a9a89c3c..e91bcebf18a1f 100644 --- a/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/resources/v2019_08_01/aio/_configuration.py +++ b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/resources/v2019_08_01/aio/_configuration.py @@ -25,23 +25,18 @@ class ResourceManagementClientConfiguration(Configuration): # pylint: disable=t Note that all parameters used to create this instance are saved as instance attributes. - :param credential: Credential needed for the client to connect to Azure. + :param credential: Credential needed for the client to connect to Azure. Required. :type credential: ~azure.core.credentials_async.AsyncTokenCredential - :param subscription_id: The ID of the target subscription. + :param subscription_id: The ID of the target subscription. Required. :type subscription_id: str :keyword api_version: Api Version. Default value is "2019-08-01". Note that overriding this default value may result in unsupported behavior. :paramtype api_version: str """ - def __init__( - self, - credential: "AsyncTokenCredential", - subscription_id: str, - **kwargs: Any - ) -> None: + def __init__(self, credential: "AsyncTokenCredential", subscription_id: str, **kwargs: Any) -> None: super(ResourceManagementClientConfiguration, self).__init__(**kwargs) - api_version = kwargs.pop('api_version', "2019-08-01") # type: str + api_version = kwargs.pop("api_version", "2019-08-01") # type: str if credential is None: raise ValueError("Parameter 'credential' must not be None.") @@ -51,22 +46,21 @@ def __init__( self.credential = credential self.subscription_id = subscription_id self.api_version = api_version - self.credential_scopes = kwargs.pop('credential_scopes', ['https://management.azure.com/.default']) - kwargs.setdefault('sdk_moniker', 'mgmt-resource/{}'.format(VERSION)) + self.credential_scopes = kwargs.pop("credential_scopes", ["https://management.azure.com/.default"]) + kwargs.setdefault("sdk_moniker", "mgmt-resource/{}".format(VERSION)) self._configure(**kwargs) - 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) - self.logging_policy = kwargs.get('logging_policy') or policies.NetworkTraceLoggingPolicy(**kwargs) - self.http_logging_policy = kwargs.get('http_logging_policy') or ARMHttpLoggingPolicy(**kwargs) - self.retry_policy = kwargs.get('retry_policy') or policies.AsyncRetryPolicy(**kwargs) - self.custom_hook_policy = kwargs.get('custom_hook_policy') or policies.CustomHookPolicy(**kwargs) - self.redirect_policy = kwargs.get('redirect_policy') or policies.AsyncRedirectPolicy(**kwargs) - self.authentication_policy = kwargs.get('authentication_policy') + 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) + self.logging_policy = kwargs.get("logging_policy") or policies.NetworkTraceLoggingPolicy(**kwargs) + self.http_logging_policy = kwargs.get("http_logging_policy") or ARMHttpLoggingPolicy(**kwargs) + self.retry_policy = kwargs.get("retry_policy") or policies.AsyncRetryPolicy(**kwargs) + self.custom_hook_policy = kwargs.get("custom_hook_policy") or policies.CustomHookPolicy(**kwargs) + self.redirect_policy = kwargs.get("redirect_policy") or policies.AsyncRedirectPolicy(**kwargs) + self.authentication_policy = kwargs.get("authentication_policy") if self.credential and not self.authentication_policy: - self.authentication_policy = AsyncARMChallengeAuthenticationPolicy(self.credential, *self.credential_scopes, **kwargs) + self.authentication_policy = AsyncARMChallengeAuthenticationPolicy( + self.credential, *self.credential_scopes, **kwargs + ) diff --git a/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/resources/v2019_08_01/aio/_patch.py b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/resources/v2019_08_01/aio/_patch.py index 74e48ecd07cf3..f99e77fef9861 100644 --- a/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/resources/v2019_08_01/aio/_patch.py +++ b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/resources/v2019_08_01/aio/_patch.py @@ -28,4 +28,4 @@ # This file is used for handwritten extensions to the generated code. Example: # https://github.com/Azure/azure-sdk-for-python/blob/main/doc/dev/customize_code/how-to-patch-sdk-code.md def patch_sdk(): - pass \ No newline at end of file + pass diff --git a/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/resources/v2019_08_01/aio/_resource_management_client.py b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/resources/v2019_08_01/aio/_resource_management_client.py index 72612e4972038..2facb9ce20dd2 100644 --- a/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/resources/v2019_08_01/aio/_resource_management_client.py +++ b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/resources/v2019_08_01/aio/_resource_management_client.py @@ -9,20 +9,28 @@ from copy import deepcopy from typing import Any, Awaitable, TYPE_CHECKING -from msrest import Deserializer, Serializer - from azure.core.rest import AsyncHttpResponse, HttpRequest from azure.mgmt.core import AsyncARMPipelineClient from .. import models +from ..._serialization import Deserializer, Serializer from ._configuration import ResourceManagementClientConfiguration -from .operations import DeploymentOperationsOperations, DeploymentsOperations, Operations, ProvidersOperations, ResourceGroupsOperations, ResourcesOperations, TagsOperations +from .operations import ( + DeploymentOperationsOperations, + DeploymentsOperations, + Operations, + ProvidersOperations, + ResourceGroupsOperations, + ResourcesOperations, + TagsOperations, +) if TYPE_CHECKING: # pylint: disable=unused-import,ungrouped-imports from azure.core.credentials_async import AsyncTokenCredential -class ResourceManagementClient: # pylint: disable=too-many-instance-attributes + +class ResourceManagementClient: # pylint: disable=client-accepts-api-version-keyword,too-many-instance-attributes """Provides operations for working with resources and resource groups. :ivar operations: Operations operations @@ -44,9 +52,9 @@ class ResourceManagementClient: # pylint: disable=too-many-instance-attribute :ivar deployment_operations: DeploymentOperationsOperations operations :vartype deployment_operations: azure.mgmt.resource.resources.v2019_08_01.aio.operations.DeploymentOperationsOperations - :param credential: Credential needed for the client to connect to Azure. + :param credential: Credential needed for the client to connect to Azure. Required. :type credential: ~azure.core.credentials_async.AsyncTokenCredential - :param subscription_id: The ID of the target subscription. + :param subscription_id: The ID of the target subscription. Required. :type subscription_id: str :param base_url: Service URL. Default value is "https://management.azure.com". :type base_url: str @@ -64,7 +72,9 @@ def __init__( base_url: str = "https://management.azure.com", **kwargs: Any ) -> None: - self._config = ResourceManagementClientConfiguration(credential=credential, subscription_id=subscription_id, **kwargs) + self._config = ResourceManagementClientConfiguration( + credential=credential, subscription_id=subscription_id, **kwargs + ) self._client = AsyncARMPipelineClient(base_url=base_url, config=self._config, **kwargs) client_models = {k: v for k, v in models.__dict__.items() if isinstance(v, type)} @@ -77,14 +87,11 @@ def __init__( self.resources = ResourcesOperations(self._client, self._config, self._serialize, self._deserialize) self.resource_groups = ResourceGroupsOperations(self._client, self._config, self._serialize, self._deserialize) self.tags = TagsOperations(self._client, self._config, self._serialize, self._deserialize) - self.deployment_operations = DeploymentOperationsOperations(self._client, self._config, self._serialize, self._deserialize) - + self.deployment_operations = DeploymentOperationsOperations( + self._client, self._config, self._serialize, self._deserialize + ) - def _send_request( - self, - request: HttpRequest, - **kwargs: Any - ) -> Awaitable[AsyncHttpResponse]: + def _send_request(self, request: HttpRequest, **kwargs: Any) -> Awaitable[AsyncHttpResponse]: """Runs the network request through the client's chained policies. >>> from azure.core.rest import HttpRequest @@ -93,7 +100,7 @@ def _send_request( >>> response = await client._send_request(request) - For more information on this code flow, see https://aka.ms/azsdk/python/protocol/quickstart + For more information on this code flow, see https://aka.ms/azsdk/dpcodegen/python/send_request :param request: The network request you want to make. Required. :type request: ~azure.core.rest.HttpRequest diff --git a/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/resources/v2019_08_01/aio/operations/__init__.py b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/resources/v2019_08_01/aio/operations/__init__.py index 53876d82bf5d7..804fee65e3137 100644 --- a/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/resources/v2019_08_01/aio/operations/__init__.py +++ b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/resources/v2019_08_01/aio/operations/__init__.py @@ -14,12 +14,18 @@ from ._operations import TagsOperations from ._operations import DeploymentOperationsOperations +from ._patch import __all__ as _patch_all +from ._patch import * # type: ignore # pylint: disable=unused-wildcard-import +from ._patch import patch_sdk as _patch_sdk + __all__ = [ - 'Operations', - 'DeploymentsOperations', - 'ProvidersOperations', - 'ResourcesOperations', - 'ResourceGroupsOperations', - 'TagsOperations', - 'DeploymentOperationsOperations', + "Operations", + "DeploymentsOperations", + "ProvidersOperations", + "ResourcesOperations", + "ResourceGroupsOperations", + "TagsOperations", + "DeploymentOperationsOperations", ] +__all__.extend([p for p in _patch_all if p not in __all__]) +_patch_sdk() diff --git a/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/resources/v2019_08_01/aio/operations/_operations.py b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/resources/v2019_08_01/aio/operations/_operations.py index 790bb2b2346db..58c45380aac29 100644 --- a/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/resources/v2019_08_01/aio/operations/_operations.py +++ b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/resources/v2019_08_01/aio/operations/_operations.py @@ -6,84 +6,192 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -from typing import Any, AsyncIterable, Callable, Dict, Optional, TypeVar, Union +import sys +from typing import Any, AsyncIterable, Callable, Dict, IO, Optional, TypeVar, Union, cast, overload +from urllib.parse import parse_qs, urljoin, urlparse from azure.core.async_paging import AsyncItemPaged, AsyncList -from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error +from azure.core.exceptions import ( + ClientAuthenticationError, + HttpResponseError, + ResourceExistsError, + ResourceNotFoundError, + ResourceNotModifiedError, + map_error, +) from azure.core.pipeline import PipelineResponse from azure.core.pipeline.transport import AsyncHttpResponse from azure.core.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 from azure.mgmt.core.polling.async_arm_polling import AsyncARMPolling from ... import models as _models from ..._vendor import _convert_request -from ...operations._operations import build_deployment_operations_get_at_management_group_scope_request, build_deployment_operations_get_at_scope_request, build_deployment_operations_get_at_subscription_scope_request, build_deployment_operations_get_at_tenant_scope_request, build_deployment_operations_get_request, build_deployment_operations_list_at_management_group_scope_request, build_deployment_operations_list_at_scope_request, build_deployment_operations_list_at_subscription_scope_request, build_deployment_operations_list_at_tenant_scope_request, build_deployment_operations_list_request, build_deployments_calculate_template_hash_request, build_deployments_cancel_at_management_group_scope_request, build_deployments_cancel_at_scope_request, build_deployments_cancel_at_subscription_scope_request, build_deployments_cancel_at_tenant_scope_request, build_deployments_cancel_request, build_deployments_check_existence_at_management_group_scope_request, build_deployments_check_existence_at_scope_request, build_deployments_check_existence_at_subscription_scope_request, build_deployments_check_existence_at_tenant_scope_request, build_deployments_check_existence_request, build_deployments_create_or_update_at_management_group_scope_request_initial, build_deployments_create_or_update_at_scope_request_initial, build_deployments_create_or_update_at_subscription_scope_request_initial, build_deployments_create_or_update_at_tenant_scope_request_initial, build_deployments_create_or_update_request_initial, build_deployments_delete_at_management_group_scope_request_initial, build_deployments_delete_at_scope_request_initial, build_deployments_delete_at_subscription_scope_request_initial, build_deployments_delete_at_tenant_scope_request_initial, build_deployments_delete_request_initial, build_deployments_export_template_at_management_group_scope_request, build_deployments_export_template_at_scope_request, build_deployments_export_template_at_subscription_scope_request, build_deployments_export_template_at_tenant_scope_request, build_deployments_export_template_request, build_deployments_get_at_management_group_scope_request, build_deployments_get_at_scope_request, build_deployments_get_at_subscription_scope_request, build_deployments_get_at_tenant_scope_request, build_deployments_get_request, build_deployments_list_at_management_group_scope_request, build_deployments_list_at_scope_request, build_deployments_list_at_subscription_scope_request, build_deployments_list_at_tenant_scope_request, build_deployments_list_by_resource_group_request, build_deployments_validate_at_management_group_scope_request, build_deployments_validate_at_scope_request, build_deployments_validate_at_subscription_scope_request, build_deployments_validate_at_tenant_scope_request, build_deployments_validate_request, build_deployments_what_if_at_subscription_scope_request_initial, build_deployments_what_if_request_initial, build_operations_list_request, build_providers_get_at_tenant_scope_request, build_providers_get_request, build_providers_list_at_tenant_scope_request, build_providers_list_request, build_providers_register_request, build_providers_unregister_request, build_resource_groups_check_existence_request, build_resource_groups_create_or_update_request, build_resource_groups_delete_request_initial, build_resource_groups_export_template_request_initial, build_resource_groups_get_request, build_resource_groups_list_request, build_resource_groups_update_request, build_resources_check_existence_by_id_request, build_resources_check_existence_request, build_resources_create_or_update_by_id_request_initial, build_resources_create_or_update_request_initial, build_resources_delete_by_id_request_initial, build_resources_delete_request_initial, build_resources_get_by_id_request, build_resources_get_request, build_resources_list_by_resource_group_request, build_resources_list_request, build_resources_move_resources_request_initial, build_resources_update_by_id_request_initial, build_resources_update_request_initial, build_resources_validate_move_resources_request_initial, build_tags_create_or_update_request, build_tags_create_or_update_value_request, build_tags_delete_request, build_tags_delete_value_request, build_tags_list_request -T = TypeVar('T') +from ...operations._operations import ( + build_deployment_operations_get_at_management_group_scope_request, + build_deployment_operations_get_at_scope_request, + build_deployment_operations_get_at_subscription_scope_request, + build_deployment_operations_get_at_tenant_scope_request, + build_deployment_operations_get_request, + build_deployment_operations_list_at_management_group_scope_request, + build_deployment_operations_list_at_scope_request, + build_deployment_operations_list_at_subscription_scope_request, + build_deployment_operations_list_at_tenant_scope_request, + build_deployment_operations_list_request, + build_deployments_calculate_template_hash_request, + build_deployments_cancel_at_management_group_scope_request, + build_deployments_cancel_at_scope_request, + build_deployments_cancel_at_subscription_scope_request, + build_deployments_cancel_at_tenant_scope_request, + build_deployments_cancel_request, + build_deployments_check_existence_at_management_group_scope_request, + build_deployments_check_existence_at_scope_request, + build_deployments_check_existence_at_subscription_scope_request, + build_deployments_check_existence_at_tenant_scope_request, + build_deployments_check_existence_request, + build_deployments_create_or_update_at_management_group_scope_request, + build_deployments_create_or_update_at_scope_request, + build_deployments_create_or_update_at_subscription_scope_request, + build_deployments_create_or_update_at_tenant_scope_request, + build_deployments_create_or_update_request, + build_deployments_delete_at_management_group_scope_request, + build_deployments_delete_at_scope_request, + build_deployments_delete_at_subscription_scope_request, + build_deployments_delete_at_tenant_scope_request, + build_deployments_delete_request, + build_deployments_export_template_at_management_group_scope_request, + build_deployments_export_template_at_scope_request, + build_deployments_export_template_at_subscription_scope_request, + build_deployments_export_template_at_tenant_scope_request, + build_deployments_export_template_request, + build_deployments_get_at_management_group_scope_request, + build_deployments_get_at_scope_request, + build_deployments_get_at_subscription_scope_request, + build_deployments_get_at_tenant_scope_request, + build_deployments_get_request, + build_deployments_list_at_management_group_scope_request, + build_deployments_list_at_scope_request, + build_deployments_list_at_subscription_scope_request, + build_deployments_list_at_tenant_scope_request, + build_deployments_list_by_resource_group_request, + build_deployments_validate_at_management_group_scope_request, + build_deployments_validate_at_scope_request, + build_deployments_validate_at_subscription_scope_request, + build_deployments_validate_at_tenant_scope_request, + build_deployments_validate_request, + build_deployments_what_if_at_subscription_scope_request, + build_deployments_what_if_request, + build_operations_list_request, + build_providers_get_at_tenant_scope_request, + build_providers_get_request, + build_providers_list_at_tenant_scope_request, + build_providers_list_request, + build_providers_register_request, + build_providers_unregister_request, + build_resource_groups_check_existence_request, + build_resource_groups_create_or_update_request, + build_resource_groups_delete_request, + build_resource_groups_export_template_request, + build_resource_groups_get_request, + build_resource_groups_list_request, + build_resource_groups_update_request, + build_resources_check_existence_by_id_request, + build_resources_check_existence_request, + build_resources_create_or_update_by_id_request, + build_resources_create_or_update_request, + build_resources_delete_by_id_request, + build_resources_delete_request, + build_resources_get_by_id_request, + build_resources_get_request, + build_resources_list_by_resource_group_request, + build_resources_list_request, + build_resources_move_resources_request, + build_resources_update_by_id_request, + build_resources_update_request, + build_resources_validate_move_resources_request, + build_tags_create_or_update_request, + build_tags_create_or_update_value_request, + build_tags_delete_request, + build_tags_delete_value_request, + build_tags_list_request, +) + +T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] +if sys.version_info >= (3, 9): + from collections.abc import MutableMapping +else: + from typing import MutableMapping # type: ignore # pylint: disable=ungrouped-imports +JSON = MutableMapping[str, Any] # pylint: disable=unsubscriptable-object -class Operations: - """Operations async operations. - You should not instantiate this class directly. Instead, you should create a Client instance that - instantiates it for you and attaches it as an attribute. +class Operations: + """ + .. warning:: + **DO NOT** instantiate this class directly. - :ivar models: Alias to model classes used in this operation group. - :type models: ~azure.mgmt.resource.resources.v2019_08_01.models - :param client: Client for service requests. - :param config: Configuration of service client. - :param serializer: An object model serializer. - :param deserializer: An object model deserializer. + Instead, you should access the following operations through + :class:`~azure.mgmt.resource.resources.v2019_08_01.aio.ResourceManagementClient`'s + :attr:`operations` attribute. """ models = _models - def __init__(self, client, config, serializer, deserializer) -> None: - self._client = client - self._serialize = serializer - self._deserialize = deserializer - self._config = config + def __init__(self, *args, **kwargs) -> None: + input_args = list(args) + self._client = input_args.pop(0) if input_args else kwargs.pop("client") + self._config = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") @distributed_trace - def list( - self, - **kwargs: Any - ) -> AsyncIterable["_models.OperationListResult"]: + def list(self, **kwargs: Any) -> AsyncIterable["_models.Operation"]: """Lists all of the available Microsoft.Resources REST API operations. :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either OperationListResult or the result of cls(response) + :return: An iterator like instance of either Operation or the result of cls(response) :rtype: - ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.resource.resources.v2019_08_01.models.OperationListResult] - :raises: ~azure.core.exceptions.HttpResponseError + ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.resource.resources.v2019_08_01.models.Operation] + :raises ~azure.core.exceptions.HttpResponseError: """ - api_version = kwargs.pop('api_version', "2019-08-01") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2019-08-01")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[_models.OperationListResult] - cls = kwargs.pop('cls', None) # type: ClsType["_models.OperationListResult"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) + def prepare_request(next_link=None): if not next_link: - + request = build_operations_list_request( api_version=api_version, - template_url=self.list.metadata['url'], + template_url=self.list.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore else: - - request = build_operations_list_request( - template_url=next_link, - ) + # make call to next link with the client's api-version + _parsed_next_link = urlparse(next_link) + _next_request_params = case_insensitive_dict(parse_qs(_parsed_next_link.query)) + _next_request_params["api-version"] = self._config.api_version + request = HttpRequest("GET", urljoin(next_link, _parsed_next_link.path), params=_next_request_params) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore request.method = "GET" return request @@ -97,10 +205,8 @@ async def extract_data(pipeline_response): async def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) response = pipeline_response.http_response @@ -110,62 +216,62 @@ async def get_next(next_link=None): return pipeline_response + return AsyncItemPaged(get_next, extract_data) - return AsyncItemPaged( - get_next, extract_data - ) - list.metadata = {'url': "/providers/Microsoft.Resources/operations"} # type: ignore -class DeploymentsOperations: # pylint: disable=too-many-public-methods - """DeploymentsOperations async operations. + list.metadata = {"url": "/providers/Microsoft.Resources/operations"} # type: ignore - You should not instantiate this class directly. Instead, you should create a Client instance that - instantiates it for you and attaches it as an attribute. - :ivar models: Alias to model classes used in this operation group. - :type models: ~azure.mgmt.resource.resources.v2019_08_01.models - :param client: Client for service requests. - :param config: Configuration of service client. - :param serializer: An object model serializer. - :param deserializer: An object model deserializer. +class DeploymentsOperations: # pylint: disable=too-many-public-methods + """ + .. warning:: + **DO NOT** instantiate this class directly. + + Instead, you should access the following operations through + :class:`~azure.mgmt.resource.resources.v2019_08_01.aio.ResourceManagementClient`'s + :attr:`deployments` attribute. """ models = _models - def __init__(self, client, config, serializer, deserializer) -> None: - self._client = client - self._serialize = serializer - self._deserialize = deserializer - self._config = config + def __init__(self, *args, **kwargs) -> None: + input_args = list(args) + self._client = input_args.pop(0) if input_args else kwargs.pop("client") + self._config = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") async def _delete_at_scope_initial( # pylint: disable=inconsistent-return-statements - self, - scope: str, - deployment_name: str, - **kwargs: Any + self, scope: str, deployment_name: str, **kwargs: Any ) -> None: - cls = kwargs.pop('cls', None) # type: ClsType[None] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + 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', "2019-08-01") # type: str + api_version = kwargs.pop("api_version", _params.pop("api-version", "2019-08-01")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[None] - - request = build_deployments_delete_at_scope_request_initial( + request = build_deployments_delete_at_scope_request( scope=scope, deployment_name=deployment_name, api_version=api_version, - template_url=self._delete_at_scope_initial.metadata['url'], + template_url=self._delete_at_scope_initial.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [202, 204]: @@ -175,16 +281,10 @@ async def _delete_at_scope_initial( # pylint: disable=inconsistent-return-state if cls: return cls(pipeline_response, None, {}) - _delete_at_scope_initial.metadata = {'url': "/{scope}/providers/Microsoft.Resources/deployments/{deploymentName}"} # type: ignore - + _delete_at_scope_initial.metadata = {"url": "/{scope}/providers/Microsoft.Resources/deployments/{deploymentName}"} # type: ignore @distributed_trace_async - async def begin_delete_at_scope( # pylint: disable=inconsistent-return-statements - self, - scope: str, - deployment_name: str, - **kwargs: Any - ) -> AsyncLROPoller[None]: + async def begin_delete_at_scope(self, scope: str, deployment_name: str, **kwargs: Any) -> AsyncLROPoller[None]: """Deletes a deployment from the deployment history. A template deployment that is currently running cannot be deleted. Deleting a template @@ -195,9 +295,9 @@ async def begin_delete_at_scope( # pylint: disable=inconsistent-return-statemen process finishes, the URI in the Location header returns a status of 204 on success. If the asynchronous request failed, the URI in the Location header returns an error-level status code. - :param scope: The scope of a deployment. + :param scope: The scope of a deployment. Required. :type scope: str - :param deployment_name: The name of the deployment. + :param deployment_name: The name of the deployment. Required. :type deployment_name: str :keyword callable cls: A custom type or function that will be passed the direct response :keyword str continuation_token: A continuation token to restart a poller from a saved state. @@ -209,86 +309,91 @@ async def begin_delete_at_scope( # pylint: disable=inconsistent-return-statemen Retry-After header is present. :return: An instance of AsyncLROPoller that returns either None or the result of cls(response) :rtype: ~azure.core.polling.AsyncLROPoller[None] - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - api_version = kwargs.pop('api_version', "2019-08-01") # type: str - polling = kwargs.pop('polling', True) # type: Union[bool, AsyncPollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType[None] - lro_delay = kwargs.pop( - 'polling_interval', - self._config.polling_interval - ) - cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2019-08-01")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[None] + polling = kwargs.pop("polling", True) # type: Union[bool, AsyncPollingMethod] + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token = kwargs.pop("continuation_token", None) # type: Optional[str] if cont_token is None: - raw_result = await self._delete_at_scope_initial( + raw_result = await self._delete_at_scope_initial( # type: ignore scope=scope, deployment_name=deployment_name, api_version=api_version, - cls=lambda x,y,z: x, + cls=lambda x, y, z: x, + headers=_headers, + params=_params, **kwargs ) - kwargs.pop('error_map', None) + kwargs.pop("error_map", None) - def get_long_running_output(pipeline_response): + def get_long_running_output(pipeline_response): # pylint: disable=inconsistent-return-statements if cls: return cls(pipeline_response, None, {}) - - if polling is True: polling_method = AsyncARMPolling(lro_delay, **kwargs) - elif polling is False: polling_method = AsyncNoPolling() - else: polling_method = polling + if polling is True: + polling_method = cast(AsyncPollingMethod, AsyncARMPolling(lro_delay, **kwargs)) # type: AsyncPollingMethod + elif polling is False: + polling_method = cast(AsyncPollingMethod, AsyncNoPolling()) + else: + polling_method = polling if cont_token: return AsyncLROPoller.from_continuation_token( polling_method=polling_method, continuation_token=cont_token, client=self._client, - deserialization_callback=get_long_running_output + deserialization_callback=get_long_running_output, ) return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) - begin_delete_at_scope.metadata = {'url': "/{scope}/providers/Microsoft.Resources/deployments/{deploymentName}"} # type: ignore + begin_delete_at_scope.metadata = {"url": "/{scope}/providers/Microsoft.Resources/deployments/{deploymentName}"} # type: ignore @distributed_trace_async - async def check_existence_at_scope( - self, - scope: str, - deployment_name: str, - **kwargs: Any - ) -> bool: + async def check_existence_at_scope(self, scope: str, deployment_name: str, **kwargs: Any) -> bool: """Checks whether the deployment exists. - :param scope: The scope of a deployment. + :param scope: The scope of a deployment. Required. :type scope: str - :param deployment_name: The name of the deployment. + :param deployment_name: The name of the deployment. Required. :type deployment_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: bool, or the result of cls(response) + :return: bool or the result of cls(response) :rtype: bool - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType[None] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + 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', "2019-08-01") # type: str + api_version = kwargs.pop("api_version", _params.pop("api-version", "2019-08-01")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[None] - request = build_deployments_check_existence_at_scope_request( scope=scope, deployment_name=deployment_name, api_version=api_version, - template_url=self.check_existence_at_scope.metadata['url'], + template_url=self.check_existence_at_scope.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [204, 404]: @@ -299,43 +404,52 @@ async def check_existence_at_scope( return cls(pipeline_response, None, {}) return 200 <= response.status_code <= 299 - check_existence_at_scope.metadata = {'url': "/{scope}/providers/Microsoft.Resources/deployments/{deploymentName}"} # type: ignore - + check_existence_at_scope.metadata = {"url": "/{scope}/providers/Microsoft.Resources/deployments/{deploymentName}"} # type: ignore async def _create_or_update_at_scope_initial( - self, - scope: str, - deployment_name: str, - parameters: "_models.Deployment", - **kwargs: Any - ) -> "_models.DeploymentExtended": - cls = kwargs.pop('cls', None) # type: ClsType["_models.DeploymentExtended"] + self, scope: str, deployment_name: str, parameters: Union[_models.Deployment, IO], **kwargs: Any + ) -> _models.DeploymentExtended: error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) - api_version = kwargs.pop('api_version', "2019-08-01") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - _json = self._serialize.body(parameters, 'Deployment') + api_version = kwargs.pop("api_version", _params.pop("api-version", "2019-08-01")) # type: str + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.DeploymentExtended] - request = build_deployments_create_or_update_at_scope_request_initial( + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(parameters, (IO, bytes)): + _content = parameters + else: + _json = self._serialize.body(parameters, "Deployment") + + request = build_deployments_create_or_update_at_scope_request( scope=scope, deployment_name=deployment_name, api_version=api_version, content_type=content_type, json=_json, - template_url=self._create_or_update_at_scope_initial.metadata['url'], + content=_content, + template_url=self._create_or_update_at_scope_initial.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200, 201]: @@ -343,37 +457,41 @@ async def _create_or_update_at_scope_initial( raise HttpResponseError(response=response, error_format=ARMErrorFormat) if response.status_code == 200: - deserialized = self._deserialize('DeploymentExtended', pipeline_response) + deserialized = self._deserialize("DeploymentExtended", pipeline_response) if response.status_code == 201: - deserialized = self._deserialize('DeploymentExtended', pipeline_response) + deserialized = self._deserialize("DeploymentExtended", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - _create_or_update_at_scope_initial.metadata = {'url': "/{scope}/providers/Microsoft.Resources/deployments/{deploymentName}"} # type: ignore + _create_or_update_at_scope_initial.metadata = {"url": "/{scope}/providers/Microsoft.Resources/deployments/{deploymentName}"} # type: ignore - - @distributed_trace_async + @overload async def begin_create_or_update_at_scope( self, scope: str, deployment_name: str, - parameters: "_models.Deployment", + parameters: _models.Deployment, + *, + content_type: str = "application/json", **kwargs: Any - ) -> AsyncLROPoller["_models.DeploymentExtended"]: + ) -> AsyncLROPoller[_models.DeploymentExtended]: """Deploys resources at a given scope. You can provide the template and parameters directly in the request or link to JSON files. - :param scope: The scope of a deployment. + :param scope: The scope of a deployment. Required. :type scope: str - :param deployment_name: The name of the deployment. + :param deployment_name: The name of the deployment. Required. :type deployment_name: str - :param parameters: Additional parameters supplied to the operation. + :param parameters: Additional parameters supplied to the operation. Required. :type parameters: ~azure.mgmt.resource.resources.v2019_08_01.models.Deployment + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str :keyword callable cls: A custom type or function that will be passed the direct response :keyword str continuation_token: A continuation token to restart a poller from a saved state. :keyword polling: By default, your polling method will be AsyncARMPolling. Pass in False for @@ -386,114 +504,179 @@ async def begin_create_or_update_at_scope( cls(response) :rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.resource.resources.v2019_08_01.models.DeploymentExtended] - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - api_version = kwargs.pop('api_version', "2019-08-01") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] - polling = kwargs.pop('polling', True) # type: Union[bool, AsyncPollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType["_models.DeploymentExtended"] - lro_delay = kwargs.pop( - 'polling_interval', - self._config.polling_interval - ) - cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] + + @overload + async def begin_create_or_update_at_scope( + self, scope: str, deployment_name: str, parameters: IO, *, content_type: str = "application/json", **kwargs: Any + ) -> AsyncLROPoller[_models.DeploymentExtended]: + """Deploys resources at a given scope. + + You can provide the template and parameters directly in the request or link to JSON files. + + :param scope: The scope of a deployment. Required. + :type scope: str + :param deployment_name: The name of the deployment. Required. + :type deployment_name: str + :param parameters: Additional parameters supplied to the operation. Required. + :type parameters: IO + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be AsyncARMPolling. Pass in False for + this operation to not poll, or pass in your own initialized polling object for a personal + polling strategy. + :paramtype polling: bool or ~azure.core.polling.AsyncPollingMethod + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of AsyncLROPoller that returns either DeploymentExtended or the result of + cls(response) + :rtype: + ~azure.core.polling.AsyncLROPoller[~azure.mgmt.resource.resources.v2019_08_01.models.DeploymentExtended] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace_async + async def begin_create_or_update_at_scope( + self, scope: str, deployment_name: str, parameters: Union[_models.Deployment, IO], **kwargs: Any + ) -> AsyncLROPoller[_models.DeploymentExtended]: + """Deploys resources at a given scope. + + You can provide the template and parameters directly in the request or link to JSON files. + + :param scope: The scope of a deployment. Required. + :type scope: str + :param deployment_name: The name of the deployment. Required. + :type deployment_name: str + :param parameters: Additional parameters supplied to the operation. Is either a model type or a + IO type. Required. + :type parameters: ~azure.mgmt.resource.resources.v2019_08_01.models.Deployment or IO + :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. + Default value is None. + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be AsyncARMPolling. Pass in False for + this operation to not poll, or pass in your own initialized polling object for a personal + polling strategy. + :paramtype polling: bool or ~azure.core.polling.AsyncPollingMethod + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of AsyncLROPoller that returns either DeploymentExtended or the result of + cls(response) + :rtype: + ~azure.core.polling.AsyncLROPoller[~azure.mgmt.resource.resources.v2019_08_01.models.DeploymentExtended] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _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", "2019-08-01")) # type: str + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.DeploymentExtended] + polling = kwargs.pop("polling", True) # type: Union[bool, AsyncPollingMethod] + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token = kwargs.pop("continuation_token", None) # type: Optional[str] if cont_token is None: - raw_result = await self._create_or_update_at_scope_initial( + raw_result = await self._create_or_update_at_scope_initial( # type: ignore scope=scope, deployment_name=deployment_name, parameters=parameters, api_version=api_version, content_type=content_type, - cls=lambda x,y,z: x, + cls=lambda x, y, z: x, + headers=_headers, + params=_params, **kwargs ) - kwargs.pop('error_map', None) + kwargs.pop("error_map", None) def get_long_running_output(pipeline_response): - response = pipeline_response.http_response - deserialized = self._deserialize('DeploymentExtended', pipeline_response) + deserialized = self._deserialize("DeploymentExtended", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - - if polling is True: polling_method = AsyncARMPolling(lro_delay, **kwargs) - elif polling is False: polling_method = AsyncNoPolling() - else: polling_method = polling + if polling is True: + polling_method = cast(AsyncPollingMethod, AsyncARMPolling(lro_delay, **kwargs)) # type: AsyncPollingMethod + elif polling is False: + polling_method = cast(AsyncPollingMethod, AsyncNoPolling()) + else: + polling_method = polling if cont_token: return AsyncLROPoller.from_continuation_token( polling_method=polling_method, continuation_token=cont_token, client=self._client, - deserialization_callback=get_long_running_output + deserialization_callback=get_long_running_output, ) return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) - begin_create_or_update_at_scope.metadata = {'url': "/{scope}/providers/Microsoft.Resources/deployments/{deploymentName}"} # type: ignore + begin_create_or_update_at_scope.metadata = {"url": "/{scope}/providers/Microsoft.Resources/deployments/{deploymentName}"} # type: ignore @distributed_trace_async - async def get_at_scope( - self, - scope: str, - deployment_name: str, - **kwargs: Any - ) -> "_models.DeploymentExtended": + async def get_at_scope(self, scope: str, deployment_name: str, **kwargs: Any) -> _models.DeploymentExtended: """Gets a deployment. - :param scope: The scope of a deployment. + :param scope: The scope of a deployment. Required. :type scope: str - :param deployment_name: The name of the deployment. + :param deployment_name: The name of the deployment. Required. :type deployment_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: DeploymentExtended, or the result of cls(response) + :return: DeploymentExtended or the result of cls(response) :rtype: ~azure.mgmt.resource.resources.v2019_08_01.models.DeploymentExtended - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.DeploymentExtended"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) - api_version = kwargs.pop('api_version', "2019-08-01") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2019-08-01")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[_models.DeploymentExtended] - request = build_deployments_get_at_scope_request( scope=scope, deployment_name=deployment_name, api_version=api_version, - template_url=self.get_at_scope.metadata['url'], + template_url=self.get_at_scope.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) - deserialized = self._deserialize('DeploymentExtended', pipeline_response) + deserialized = self._deserialize("DeploymentExtended", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - get_at_scope.metadata = {'url': "/{scope}/providers/Microsoft.Resources/deployments/{deploymentName}"} # type: ignore - + get_at_scope.metadata = {"url": "/{scope}/providers/Microsoft.Resources/deployments/{deploymentName}"} # type: ignore @distributed_trace_async async def cancel_at_scope( # pylint: disable=inconsistent-return-statements - self, - scope: str, - deployment_name: str, - **kwargs: Any + self, scope: str, deployment_name: str, **kwargs: Any ) -> None: """Cancels a currently running template deployment. @@ -502,38 +685,44 @@ async def cancel_at_scope( # pylint: disable=inconsistent-return-statements deployment stops the currently running template deployment and leaves the resources partially deployed. - :param scope: The scope of a deployment. + :param scope: The scope of a deployment. Required. :type scope: str - :param deployment_name: The name of the deployment. + :param deployment_name: The name of the deployment. Required. :type deployment_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: None, or the result of cls(response) + :return: None or the result of cls(response) :rtype: None - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType[None] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + 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', "2019-08-01") # type: str + api_version = kwargs.pop("api_version", _params.pop("api-version", "2019-08-01")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[None] - request = build_deployments_cancel_at_scope_request( scope=scope, deployment_name=deployment_name, api_version=api_version, - template_url=self.cancel_at_scope.metadata['url'], + template_url=self.cancel_at_scope.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [204]: @@ -543,41 +732,101 @@ async def cancel_at_scope( # pylint: disable=inconsistent-return-statements if cls: return cls(pipeline_response, None, {}) - cancel_at_scope.metadata = {'url': "/{scope}/providers/Microsoft.Resources/deployments/{deploymentName}/cancel"} # type: ignore - + cancel_at_scope.metadata = {"url": "/{scope}/providers/Microsoft.Resources/deployments/{deploymentName}/cancel"} # type: ignore - @distributed_trace_async + @overload async def validate_at_scope( self, scope: str, deployment_name: str, - parameters: "_models.Deployment", + parameters: _models.Deployment, + *, + content_type: str = "application/json", **kwargs: Any - ) -> "_models.DeploymentValidateResult": + ) -> _models.DeploymentValidateResult: """Validates whether the specified template is syntactically correct and will be accepted by Azure Resource Manager.. - :param scope: The scope of a deployment. + :param scope: The scope of a deployment. Required. :type scope: str - :param deployment_name: The name of the deployment. + :param deployment_name: The name of the deployment. Required. :type deployment_name: str - :param parameters: Parameters to validate. + :param parameters: Parameters to validate. Required. :type parameters: ~azure.mgmt.resource.resources.v2019_08_01.models.Deployment + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: DeploymentValidateResult or the result of cls(response) + :rtype: ~azure.mgmt.resource.resources.v2019_08_01.models.DeploymentValidateResult + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + async def validate_at_scope( + self, scope: str, deployment_name: str, parameters: IO, *, content_type: str = "application/json", **kwargs: Any + ) -> _models.DeploymentValidateResult: + """Validates whether the specified template is syntactically correct and will be accepted by Azure + Resource Manager.. + + :param scope: The scope of a deployment. Required. + :type scope: str + :param deployment_name: The name of the deployment. Required. + :type deployment_name: str + :param parameters: Parameters to validate. Required. + :type parameters: IO + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: DeploymentValidateResult or the result of cls(response) + :rtype: ~azure.mgmt.resource.resources.v2019_08_01.models.DeploymentValidateResult + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace_async + async def validate_at_scope( + self, scope: str, deployment_name: str, parameters: Union[_models.Deployment, IO], **kwargs: Any + ) -> _models.DeploymentValidateResult: + """Validates whether the specified template is syntactically correct and will be accepted by Azure + Resource Manager.. + + :param scope: The scope of a deployment. Required. + :type scope: str + :param deployment_name: The name of the deployment. Required. + :type deployment_name: str + :param parameters: Parameters to validate. Is either a model type or a IO type. Required. + :type parameters: ~azure.mgmt.resource.resources.v2019_08_01.models.Deployment or IO + :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. + Default value is None. + :paramtype content_type: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: DeploymentValidateResult, or the result of cls(response) + :return: DeploymentValidateResult or the result of cls(response) :rtype: ~azure.mgmt.resource.resources.v2019_08_01.models.DeploymentValidateResult - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.DeploymentValidateResult"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', "2019-08-01") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + api_version = kwargs.pop("api_version", _params.pop("api-version", "2019-08-01")) # type: str + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.DeploymentValidateResult] - _json = self._serialize.body(parameters, 'Deployment') + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(parameters, (IO, bytes)): + _content = parameters + else: + _json = self._serialize.body(parameters, "Deployment") request = build_deployments_validate_at_scope_request( scope=scope, @@ -585,16 +834,18 @@ async def validate_at_scope( api_version=api_version, content_type=content_type, json=_json, - template_url=self.validate_at_scope.metadata['url'], + content=_content, + template_url=self.validate_at_scope.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200, 400]: @@ -602,87 +853,84 @@ async def validate_at_scope( raise HttpResponseError(response=response, error_format=ARMErrorFormat) if response.status_code == 200: - deserialized = self._deserialize('DeploymentValidateResult', pipeline_response) + deserialized = self._deserialize("DeploymentValidateResult", pipeline_response) if response.status_code == 400: - deserialized = self._deserialize('DeploymentValidateResult', pipeline_response) + deserialized = self._deserialize("DeploymentValidateResult", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - validate_at_scope.metadata = {'url': "/{scope}/providers/Microsoft.Resources/deployments/{deploymentName}/validate"} # type: ignore - + validate_at_scope.metadata = {"url": "/{scope}/providers/Microsoft.Resources/deployments/{deploymentName}/validate"} # type: ignore @distributed_trace_async async def export_template_at_scope( - self, - scope: str, - deployment_name: str, - **kwargs: Any - ) -> "_models.DeploymentExportResult": + self, scope: str, deployment_name: str, **kwargs: Any + ) -> _models.DeploymentExportResult: """Exports the template used for specified deployment. - :param scope: The scope of a deployment. + :param scope: The scope of a deployment. Required. :type scope: str - :param deployment_name: The name of the deployment. + :param deployment_name: The name of the deployment. Required. :type deployment_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: DeploymentExportResult, or the result of cls(response) + :return: DeploymentExportResult or the result of cls(response) :rtype: ~azure.mgmt.resource.resources.v2019_08_01.models.DeploymentExportResult - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.DeploymentExportResult"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) - api_version = kwargs.pop('api_version', "2019-08-01") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2019-08-01")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[_models.DeploymentExportResult] - request = build_deployments_export_template_at_scope_request( scope=scope, deployment_name=deployment_name, api_version=api_version, - template_url=self.export_template_at_scope.metadata['url'], + template_url=self.export_template_at_scope.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) - deserialized = self._deserialize('DeploymentExportResult', pipeline_response) + deserialized = self._deserialize("DeploymentExportResult", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - export_template_at_scope.metadata = {'url': "/{scope}/providers/Microsoft.Resources/deployments/{deploymentName}/exportTemplate"} # type: ignore - + export_template_at_scope.metadata = {"url": "/{scope}/providers/Microsoft.Resources/deployments/{deploymentName}/exportTemplate"} # type: ignore @distributed_trace def list_at_scope( - self, - scope: str, - filter: Optional[str] = None, - top: Optional[int] = None, - **kwargs: Any - ) -> AsyncIterable["_models.DeploymentListResult"]: + self, scope: str, filter: Optional[str] = None, top: Optional[int] = None, **kwargs: Any + ) -> AsyncIterable["_models.DeploymentExtended"]: """Get all the deployments at the given scope. - :param scope: The scope of a deployment. + :param scope: The scope of a deployment. Required. :type scope: str :param filter: The filter to apply on the operation. For example, you can use $filter=provisioningState eq '{state}'. Default value is None. @@ -691,40 +939,48 @@ def list_at_scope( value is None. :type top: int :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either DeploymentListResult or the result of - cls(response) + :return: An iterator like instance of either DeploymentExtended or the result of cls(response) :rtype: - ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.resource.resources.v2019_08_01.models.DeploymentListResult] - :raises: ~azure.core.exceptions.HttpResponseError + ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.resource.resources.v2019_08_01.models.DeploymentExtended] + :raises ~azure.core.exceptions.HttpResponseError: """ - api_version = kwargs.pop('api_version', "2019-08-01") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2019-08-01")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[_models.DeploymentListResult] - cls = kwargs.pop('cls', None) # type: ClsType["_models.DeploymentListResult"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) + def prepare_request(next_link=None): if not next_link: - + request = build_deployments_list_at_scope_request( scope=scope, - api_version=api_version, filter=filter, top=top, - template_url=self.list_at_scope.metadata['url'], + api_version=api_version, + template_url=self.list_at_scope.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore else: - - request = build_deployments_list_at_scope_request( - scope=scope, - template_url=next_link, - ) + # make call to next link with the client's api-version + _parsed_next_link = urlparse(next_link) + _next_request_params = case_insensitive_dict(parse_qs(_parsed_next_link.query)) + _next_request_params["api-version"] = self._config.api_version + request = HttpRequest("GET", urljoin(next_link, _parsed_next_link.path), params=_next_request_params) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore request.method = "GET" return request @@ -738,10 +994,8 @@ async def extract_data(pipeline_response): async def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) response = pipeline_response.http_response @@ -751,39 +1005,41 @@ async def get_next(next_link=None): return pipeline_response + return AsyncItemPaged(get_next, extract_data) - return AsyncItemPaged( - get_next, extract_data - ) - list_at_scope.metadata = {'url': "/{scope}/providers/Microsoft.Resources/deployments/"} # type: ignore + list_at_scope.metadata = {"url": "/{scope}/providers/Microsoft.Resources/deployments/"} # type: ignore async def _delete_at_tenant_scope_initial( # pylint: disable=inconsistent-return-statements - self, - deployment_name: str, - **kwargs: Any + self, deployment_name: str, **kwargs: Any ) -> None: - cls = kwargs.pop('cls', None) # type: ClsType[None] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) - api_version = kwargs.pop('api_version', "2019-08-01") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - request = build_deployments_delete_at_tenant_scope_request_initial( + api_version = kwargs.pop("api_version", _params.pop("api-version", "2019-08-01")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[None] + + request = build_deployments_delete_at_tenant_scope_request( deployment_name=deployment_name, api_version=api_version, - template_url=self._delete_at_tenant_scope_initial.metadata['url'], + template_url=self._delete_at_tenant_scope_initial.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [202, 204]: @@ -793,15 +1049,10 @@ async def _delete_at_tenant_scope_initial( # pylint: disable=inconsistent-retur if cls: return cls(pipeline_response, None, {}) - _delete_at_tenant_scope_initial.metadata = {'url': "/providers/Microsoft.Resources/deployments/{deploymentName}"} # type: ignore - + _delete_at_tenant_scope_initial.metadata = {"url": "/providers/Microsoft.Resources/deployments/{deploymentName}"} # type: ignore @distributed_trace_async - async def begin_delete_at_tenant_scope( # pylint: disable=inconsistent-return-statements - self, - deployment_name: str, - **kwargs: Any - ) -> AsyncLROPoller[None]: + async def begin_delete_at_tenant_scope(self, deployment_name: str, **kwargs: Any) -> AsyncLROPoller[None]: """Deletes a deployment from the deployment history. A template deployment that is currently running cannot be deleted. Deleting a template @@ -812,7 +1063,7 @@ async def begin_delete_at_tenant_scope( # pylint: disable=inconsistent-return-s process finishes, the URI in the Location header returns a status of 204 on success. If the asynchronous request failed, the URI in the Location header returns an error-level status code. - :param deployment_name: The name of the deployment. + :param deployment_name: The name of the deployment. Required. :type deployment_name: str :keyword callable cls: A custom type or function that will be passed the direct response :keyword str continuation_token: A continuation token to restart a poller from a saved state. @@ -824,81 +1075,87 @@ async def begin_delete_at_tenant_scope( # pylint: disable=inconsistent-return-s Retry-After header is present. :return: An instance of AsyncLROPoller that returns either None or the result of cls(response) :rtype: ~azure.core.polling.AsyncLROPoller[None] - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - api_version = kwargs.pop('api_version', "2019-08-01") # type: str - polling = kwargs.pop('polling', True) # type: Union[bool, AsyncPollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType[None] - lro_delay = kwargs.pop( - 'polling_interval', - self._config.polling_interval - ) - cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2019-08-01")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[None] + polling = kwargs.pop("polling", True) # type: Union[bool, AsyncPollingMethod] + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token = kwargs.pop("continuation_token", None) # type: Optional[str] if cont_token is None: - raw_result = await self._delete_at_tenant_scope_initial( + raw_result = await self._delete_at_tenant_scope_initial( # type: ignore deployment_name=deployment_name, api_version=api_version, - cls=lambda x,y,z: x, + cls=lambda x, y, z: x, + headers=_headers, + params=_params, **kwargs ) - kwargs.pop('error_map', None) + kwargs.pop("error_map", None) - def get_long_running_output(pipeline_response): + def get_long_running_output(pipeline_response): # pylint: disable=inconsistent-return-statements if cls: return cls(pipeline_response, None, {}) - - if polling is True: polling_method = AsyncARMPolling(lro_delay, **kwargs) - elif polling is False: polling_method = AsyncNoPolling() - else: polling_method = polling + if polling is True: + polling_method = cast(AsyncPollingMethod, AsyncARMPolling(lro_delay, **kwargs)) # type: AsyncPollingMethod + elif polling is False: + polling_method = cast(AsyncPollingMethod, AsyncNoPolling()) + else: + polling_method = polling if cont_token: return AsyncLROPoller.from_continuation_token( polling_method=polling_method, continuation_token=cont_token, client=self._client, - deserialization_callback=get_long_running_output + deserialization_callback=get_long_running_output, ) return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) - begin_delete_at_tenant_scope.metadata = {'url': "/providers/Microsoft.Resources/deployments/{deploymentName}"} # type: ignore + begin_delete_at_tenant_scope.metadata = {"url": "/providers/Microsoft.Resources/deployments/{deploymentName}"} # type: ignore @distributed_trace_async - async def check_existence_at_tenant_scope( - self, - deployment_name: str, - **kwargs: Any - ) -> bool: + async def check_existence_at_tenant_scope(self, deployment_name: str, **kwargs: Any) -> bool: """Checks whether the deployment exists. - :param deployment_name: The name of the deployment. + :param deployment_name: The name of the deployment. Required. :type deployment_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: bool, or the result of cls(response) + :return: bool or the result of cls(response) :rtype: bool - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType[None] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) - api_version = kwargs.pop('api_version', "2019-08-01") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2019-08-01")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[None] - request = build_deployments_check_existence_at_tenant_scope_request( deployment_name=deployment_name, api_version=api_version, - template_url=self.check_existence_at_tenant_scope.metadata['url'], + template_url=self.check_existence_at_tenant_scope.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [204, 404]: @@ -909,41 +1166,51 @@ async def check_existence_at_tenant_scope( return cls(pipeline_response, None, {}) return 200 <= response.status_code <= 299 - check_existence_at_tenant_scope.metadata = {'url': "/providers/Microsoft.Resources/deployments/{deploymentName}"} # type: ignore - + check_existence_at_tenant_scope.metadata = {"url": "/providers/Microsoft.Resources/deployments/{deploymentName}"} # type: ignore async def _create_or_update_at_tenant_scope_initial( - self, - deployment_name: str, - parameters: "_models.ScopedDeployment", - **kwargs: Any - ) -> "_models.DeploymentExtended": - cls = kwargs.pop('cls', None) # type: ClsType["_models.DeploymentExtended"] + self, deployment_name: str, parameters: Union[_models.ScopedDeployment, IO], **kwargs: Any + ) -> _models.DeploymentExtended: error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) - api_version = kwargs.pop('api_version', "2019-08-01") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - _json = self._serialize.body(parameters, 'ScopedDeployment') + api_version = kwargs.pop("api_version", _params.pop("api-version", "2019-08-01")) # type: str + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.DeploymentExtended] - request = build_deployments_create_or_update_at_tenant_scope_request_initial( + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(parameters, (IO, bytes)): + _content = parameters + else: + _json = self._serialize.body(parameters, "ScopedDeployment") + + request = build_deployments_create_or_update_at_tenant_scope_request( deployment_name=deployment_name, api_version=api_version, content_type=content_type, json=_json, - template_url=self._create_or_update_at_tenant_scope_initial.metadata['url'], + content=_content, + template_url=self._create_or_update_at_tenant_scope_initial.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200, 201]: @@ -951,34 +1218,38 @@ async def _create_or_update_at_tenant_scope_initial( raise HttpResponseError(response=response, error_format=ARMErrorFormat) if response.status_code == 200: - deserialized = self._deserialize('DeploymentExtended', pipeline_response) + deserialized = self._deserialize("DeploymentExtended", pipeline_response) if response.status_code == 201: - deserialized = self._deserialize('DeploymentExtended', pipeline_response) + deserialized = self._deserialize("DeploymentExtended", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - _create_or_update_at_tenant_scope_initial.metadata = {'url': "/providers/Microsoft.Resources/deployments/{deploymentName}"} # type: ignore + _create_or_update_at_tenant_scope_initial.metadata = {"url": "/providers/Microsoft.Resources/deployments/{deploymentName}"} # type: ignore - - @distributed_trace_async + @overload async def begin_create_or_update_at_tenant_scope( self, deployment_name: str, - parameters: "_models.ScopedDeployment", + parameters: _models.ScopedDeployment, + *, + content_type: str = "application/json", **kwargs: Any - ) -> AsyncLROPoller["_models.DeploymentExtended"]: + ) -> AsyncLROPoller[_models.DeploymentExtended]: """Deploys resources at tenant scope. You can provide the template and parameters directly in the request or link to JSON files. - :param deployment_name: The name of the deployment. + :param deployment_name: The name of the deployment. Required. :type deployment_name: str - :param parameters: Additional parameters supplied to the operation. + :param parameters: Additional parameters supplied to the operation. Required. :type parameters: ~azure.mgmt.resource.resources.v2019_08_01.models.ScopedDeployment + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str :keyword callable cls: A custom type or function that will be passed the direct response :keyword str continuation_token: A continuation token to restart a poller from a saved state. :keyword polling: By default, your polling method will be AsyncARMPolling. Pass in False for @@ -991,108 +1262,171 @@ async def begin_create_or_update_at_tenant_scope( cls(response) :rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.resource.resources.v2019_08_01.models.DeploymentExtended] - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - api_version = kwargs.pop('api_version', "2019-08-01") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] - polling = kwargs.pop('polling', True) # type: Union[bool, AsyncPollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType["_models.DeploymentExtended"] - lro_delay = kwargs.pop( - 'polling_interval', - self._config.polling_interval - ) - cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] + + @overload + async def begin_create_or_update_at_tenant_scope( + self, deployment_name: str, parameters: IO, *, content_type: str = "application/json", **kwargs: Any + ) -> AsyncLROPoller[_models.DeploymentExtended]: + """Deploys resources at tenant scope. + + You can provide the template and parameters directly in the request or link to JSON files. + + :param deployment_name: The name of the deployment. Required. + :type deployment_name: str + :param parameters: Additional parameters supplied to the operation. Required. + :type parameters: IO + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be AsyncARMPolling. Pass in False for + this operation to not poll, or pass in your own initialized polling object for a personal + polling strategy. + :paramtype polling: bool or ~azure.core.polling.AsyncPollingMethod + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of AsyncLROPoller that returns either DeploymentExtended or the result of + cls(response) + :rtype: + ~azure.core.polling.AsyncLROPoller[~azure.mgmt.resource.resources.v2019_08_01.models.DeploymentExtended] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace_async + async def begin_create_or_update_at_tenant_scope( + self, deployment_name: str, parameters: Union[_models.ScopedDeployment, IO], **kwargs: Any + ) -> AsyncLROPoller[_models.DeploymentExtended]: + """Deploys resources at tenant scope. + + You can provide the template and parameters directly in the request or link to JSON files. + + :param deployment_name: The name of the deployment. Required. + :type deployment_name: str + :param parameters: Additional parameters supplied to the operation. Is either a model type or a + IO type. Required. + :type parameters: ~azure.mgmt.resource.resources.v2019_08_01.models.ScopedDeployment or IO + :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. + Default value is None. + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be AsyncARMPolling. Pass in False for + this operation to not poll, or pass in your own initialized polling object for a personal + polling strategy. + :paramtype polling: bool or ~azure.core.polling.AsyncPollingMethod + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of AsyncLROPoller that returns either DeploymentExtended or the result of + cls(response) + :rtype: + ~azure.core.polling.AsyncLROPoller[~azure.mgmt.resource.resources.v2019_08_01.models.DeploymentExtended] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _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", "2019-08-01")) # type: str + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.DeploymentExtended] + polling = kwargs.pop("polling", True) # type: Union[bool, AsyncPollingMethod] + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token = kwargs.pop("continuation_token", None) # type: Optional[str] if cont_token is None: - raw_result = await self._create_or_update_at_tenant_scope_initial( + raw_result = await self._create_or_update_at_tenant_scope_initial( # type: ignore deployment_name=deployment_name, parameters=parameters, api_version=api_version, content_type=content_type, - cls=lambda x,y,z: x, + cls=lambda x, y, z: x, + headers=_headers, + params=_params, **kwargs ) - kwargs.pop('error_map', None) + kwargs.pop("error_map", None) def get_long_running_output(pipeline_response): - response = pipeline_response.http_response - deserialized = self._deserialize('DeploymentExtended', pipeline_response) + deserialized = self._deserialize("DeploymentExtended", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - - if polling is True: polling_method = AsyncARMPolling(lro_delay, **kwargs) - elif polling is False: polling_method = AsyncNoPolling() - else: polling_method = polling + if polling is True: + polling_method = cast(AsyncPollingMethod, AsyncARMPolling(lro_delay, **kwargs)) # type: AsyncPollingMethod + elif polling is False: + polling_method = cast(AsyncPollingMethod, AsyncNoPolling()) + else: + polling_method = polling if cont_token: return AsyncLROPoller.from_continuation_token( polling_method=polling_method, continuation_token=cont_token, client=self._client, - deserialization_callback=get_long_running_output + deserialization_callback=get_long_running_output, ) return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) - begin_create_or_update_at_tenant_scope.metadata = {'url': "/providers/Microsoft.Resources/deployments/{deploymentName}"} # type: ignore + begin_create_or_update_at_tenant_scope.metadata = {"url": "/providers/Microsoft.Resources/deployments/{deploymentName}"} # type: ignore @distributed_trace_async - async def get_at_tenant_scope( - self, - deployment_name: str, - **kwargs: Any - ) -> "_models.DeploymentExtended": + async def get_at_tenant_scope(self, deployment_name: str, **kwargs: Any) -> _models.DeploymentExtended: """Gets a deployment. - :param deployment_name: The name of the deployment. + :param deployment_name: The name of the deployment. Required. :type deployment_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: DeploymentExtended, or the result of cls(response) + :return: DeploymentExtended or the result of cls(response) :rtype: ~azure.mgmt.resource.resources.v2019_08_01.models.DeploymentExtended - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.DeploymentExtended"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + 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', "2019-08-01") # type: str + api_version = kwargs.pop("api_version", _params.pop("api-version", "2019-08-01")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[_models.DeploymentExtended] - request = build_deployments_get_at_tenant_scope_request( deployment_name=deployment_name, api_version=api_version, - template_url=self.get_at_tenant_scope.metadata['url'], + template_url=self.get_at_tenant_scope.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) - deserialized = self._deserialize('DeploymentExtended', pipeline_response) + deserialized = self._deserialize("DeploymentExtended", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - get_at_tenant_scope.metadata = {'url': "/providers/Microsoft.Resources/deployments/{deploymentName}"} # type: ignore - + get_at_tenant_scope.metadata = {"url": "/providers/Microsoft.Resources/deployments/{deploymentName}"} # type: ignore @distributed_trace_async async def cancel_at_tenant_scope( # pylint: disable=inconsistent-return-statements - self, - deployment_name: str, - **kwargs: Any + self, deployment_name: str, **kwargs: Any ) -> None: """Cancels a currently running template deployment. @@ -1101,35 +1435,41 @@ async def cancel_at_tenant_scope( # pylint: disable=inconsistent-return-stateme deployment stops the currently running template deployment and leaves the resources partially deployed. - :param deployment_name: The name of the deployment. + :param deployment_name: The name of the deployment. Required. :type deployment_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: None, or the result of cls(response) + :return: None or the result of cls(response) :rtype: None - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType[None] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + 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', "2019-08-01") # type: str + api_version = kwargs.pop("api_version", _params.pop("api-version", "2019-08-01")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[None] - request = build_deployments_cancel_at_tenant_scope_request( deployment_name=deployment_name, api_version=api_version, - template_url=self.cancel_at_tenant_scope.metadata['url'], + template_url=self.cancel_at_tenant_scope.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [204]: @@ -1139,54 +1479,112 @@ async def cancel_at_tenant_scope( # pylint: disable=inconsistent-return-stateme if cls: return cls(pipeline_response, None, {}) - cancel_at_tenant_scope.metadata = {'url': "/providers/Microsoft.Resources/deployments/{deploymentName}/cancel"} # type: ignore - + cancel_at_tenant_scope.metadata = {"url": "/providers/Microsoft.Resources/deployments/{deploymentName}/cancel"} # type: ignore - @distributed_trace_async + @overload async def validate_at_tenant_scope( self, deployment_name: str, - parameters: "_models.ScopedDeployment", + parameters: _models.ScopedDeployment, + *, + content_type: str = "application/json", **kwargs: Any - ) -> "_models.DeploymentValidateResult": + ) -> _models.DeploymentValidateResult: """Validates whether the specified template is syntactically correct and will be accepted by Azure Resource Manager.. - :param deployment_name: The name of the deployment. + :param deployment_name: The name of the deployment. Required. :type deployment_name: str - :param parameters: Parameters to validate. + :param parameters: Parameters to validate. Required. :type parameters: ~azure.mgmt.resource.resources.v2019_08_01.models.ScopedDeployment + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: DeploymentValidateResult, or the result of cls(response) + :return: DeploymentValidateResult or the result of cls(response) :rtype: ~azure.mgmt.resource.resources.v2019_08_01.models.DeploymentValidateResult - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.DeploymentValidateResult"] - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {})) - api_version = kwargs.pop('api_version', "2019-08-01") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + @overload + async def validate_at_tenant_scope( + self, deployment_name: str, parameters: IO, *, content_type: str = "application/json", **kwargs: Any + ) -> _models.DeploymentValidateResult: + """Validates whether the specified template is syntactically correct and will be accepted by Azure + Resource Manager.. - _json = self._serialize.body(parameters, 'ScopedDeployment') + :param deployment_name: The name of the deployment. Required. + :type deployment_name: str + :param parameters: Parameters to validate. Required. + :type parameters: IO + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: DeploymentValidateResult or the result of cls(response) + :rtype: ~azure.mgmt.resource.resources.v2019_08_01.models.DeploymentValidateResult + :raises ~azure.core.exceptions.HttpResponseError: + """ - request = build_deployments_validate_at_tenant_scope_request( - deployment_name=deployment_name, + @distributed_trace_async + async def validate_at_tenant_scope( + self, deployment_name: str, parameters: Union[_models.ScopedDeployment, IO], **kwargs: Any + ) -> _models.DeploymentValidateResult: + """Validates whether the specified template is syntactically correct and will be accepted by Azure + Resource Manager.. + + :param deployment_name: The name of the deployment. Required. + :type deployment_name: str + :param parameters: Parameters to validate. Is either a model type or a IO type. Required. + :type parameters: ~azure.mgmt.resource.resources.v2019_08_01.models.ScopedDeployment or IO + :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. + Default value is None. + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: DeploymentValidateResult or the result of cls(response) + :rtype: ~azure.mgmt.resource.resources.v2019_08_01.models.DeploymentValidateResult + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2019-08-01")) # type: str + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.DeploymentValidateResult] + + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(parameters, (IO, bytes)): + _content = parameters + else: + _json = self._serialize.body(parameters, "ScopedDeployment") + + request = build_deployments_validate_at_tenant_scope_request( + deployment_name=deployment_name, api_version=api_version, content_type=content_type, json=_json, - template_url=self.validate_at_tenant_scope.metadata['url'], + content=_content, + template_url=self.validate_at_tenant_scope.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200, 400]: @@ -1194,79 +1592,78 @@ async def validate_at_tenant_scope( raise HttpResponseError(response=response, error_format=ARMErrorFormat) if response.status_code == 200: - deserialized = self._deserialize('DeploymentValidateResult', pipeline_response) + deserialized = self._deserialize("DeploymentValidateResult", pipeline_response) if response.status_code == 400: - deserialized = self._deserialize('DeploymentValidateResult', pipeline_response) + deserialized = self._deserialize("DeploymentValidateResult", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - validate_at_tenant_scope.metadata = {'url': "/providers/Microsoft.Resources/deployments/{deploymentName}/validate"} # type: ignore - + validate_at_tenant_scope.metadata = {"url": "/providers/Microsoft.Resources/deployments/{deploymentName}/validate"} # type: ignore @distributed_trace_async async def export_template_at_tenant_scope( - self, - deployment_name: str, - **kwargs: Any - ) -> "_models.DeploymentExportResult": + self, deployment_name: str, **kwargs: Any + ) -> _models.DeploymentExportResult: """Exports the template used for specified deployment. - :param deployment_name: The name of the deployment. + :param deployment_name: The name of the deployment. Required. :type deployment_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: DeploymentExportResult, or the result of cls(response) + :return: DeploymentExportResult or the result of cls(response) :rtype: ~azure.mgmt.resource.resources.v2019_08_01.models.DeploymentExportResult - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.DeploymentExportResult"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + 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', "2019-08-01") # type: str + api_version = kwargs.pop("api_version", _params.pop("api-version", "2019-08-01")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[_models.DeploymentExportResult] - request = build_deployments_export_template_at_tenant_scope_request( deployment_name=deployment_name, api_version=api_version, - template_url=self.export_template_at_tenant_scope.metadata['url'], + template_url=self.export_template_at_tenant_scope.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) - deserialized = self._deserialize('DeploymentExportResult', pipeline_response) + deserialized = self._deserialize("DeploymentExportResult", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - export_template_at_tenant_scope.metadata = {'url': "/providers/Microsoft.Resources/deployments/{deploymentName}/exportTemplate"} # type: ignore - + export_template_at_tenant_scope.metadata = {"url": "/providers/Microsoft.Resources/deployments/{deploymentName}/exportTemplate"} # type: ignore @distributed_trace def list_at_tenant_scope( - self, - filter: Optional[str] = None, - top: Optional[int] = None, - **kwargs: Any - ) -> AsyncIterable["_models.DeploymentListResult"]: + self, filter: Optional[str] = None, top: Optional[int] = None, **kwargs: Any + ) -> AsyncIterable["_models.DeploymentExtended"]: """Get all the deployments at the tenant scope. :param filter: The filter to apply on the operation. For example, you can use @@ -1276,38 +1673,47 @@ def list_at_tenant_scope( value is None. :type top: int :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either DeploymentListResult or the result of - cls(response) + :return: An iterator like instance of either DeploymentExtended or the result of cls(response) :rtype: - ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.resource.resources.v2019_08_01.models.DeploymentListResult] - :raises: ~azure.core.exceptions.HttpResponseError + ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.resource.resources.v2019_08_01.models.DeploymentExtended] + :raises ~azure.core.exceptions.HttpResponseError: """ - api_version = kwargs.pop('api_version', "2019-08-01") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2019-08-01")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[_models.DeploymentListResult] - cls = kwargs.pop('cls', None) # type: ClsType["_models.DeploymentListResult"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) + def prepare_request(next_link=None): if not next_link: - + request = build_deployments_list_at_tenant_scope_request( - api_version=api_version, filter=filter, top=top, - template_url=self.list_at_tenant_scope.metadata['url'], + api_version=api_version, + template_url=self.list_at_tenant_scope.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore else: - - request = build_deployments_list_at_tenant_scope_request( - template_url=next_link, - ) + # make call to next link with the client's api-version + _parsed_next_link = urlparse(next_link) + _next_request_params = case_insensitive_dict(parse_qs(_parsed_next_link.query)) + _next_request_params["api-version"] = self._config.api_version + request = HttpRequest("GET", urljoin(next_link, _parsed_next_link.path), params=_next_request_params) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore request.method = "GET" return request @@ -1321,10 +1727,8 @@ async def extract_data(pipeline_response): async def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) response = pipeline_response.http_response @@ -1334,41 +1738,42 @@ async def get_next(next_link=None): return pipeline_response + return AsyncItemPaged(get_next, extract_data) - return AsyncItemPaged( - get_next, extract_data - ) - list_at_tenant_scope.metadata = {'url': "/providers/Microsoft.Resources/deployments/"} # type: ignore + list_at_tenant_scope.metadata = {"url": "/providers/Microsoft.Resources/deployments/"} # type: ignore async def _delete_at_management_group_scope_initial( # pylint: disable=inconsistent-return-statements - self, - group_id: str, - deployment_name: str, - **kwargs: Any + self, group_id: str, deployment_name: str, **kwargs: Any ) -> None: - cls = kwargs.pop('cls', None) # type: ClsType[None] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) - api_version = kwargs.pop('api_version', "2019-08-01") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - request = build_deployments_delete_at_management_group_scope_request_initial( + api_version = kwargs.pop("api_version", _params.pop("api-version", "2019-08-01")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[None] + + request = build_deployments_delete_at_management_group_scope_request( group_id=group_id, deployment_name=deployment_name, api_version=api_version, - template_url=self._delete_at_management_group_scope_initial.metadata['url'], + template_url=self._delete_at_management_group_scope_initial.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [202, 204]: @@ -1378,15 +1783,11 @@ async def _delete_at_management_group_scope_initial( # pylint: disable=inconsis if cls: return cls(pipeline_response, None, {}) - _delete_at_management_group_scope_initial.metadata = {'url': "/providers/Microsoft.Management/managementGroups/{groupId}/providers/Microsoft.Resources/deployments/{deploymentName}"} # type: ignore - + _delete_at_management_group_scope_initial.metadata = {"url": "/providers/Microsoft.Management/managementGroups/{groupId}/providers/Microsoft.Resources/deployments/{deploymentName}"} # type: ignore @distributed_trace_async - async def begin_delete_at_management_group_scope( # pylint: disable=inconsistent-return-statements - self, - group_id: str, - deployment_name: str, - **kwargs: Any + async def begin_delete_at_management_group_scope( + self, group_id: str, deployment_name: str, **kwargs: Any ) -> AsyncLROPoller[None]: """Deletes a deployment from the deployment history. @@ -1398,9 +1799,9 @@ async def begin_delete_at_management_group_scope( # pylint: disable=inconsisten process finishes, the URI in the Location header returns a status of 204 on success. If the asynchronous request failed, the URI in the Location header returns an error-level status code. - :param group_id: The management group ID. + :param group_id: The management group ID. Required. :type group_id: str - :param deployment_name: The name of the deployment. + :param deployment_name: The name of the deployment. Required. :type deployment_name: str :keyword callable cls: A custom type or function that will be passed the direct response :keyword str continuation_token: A continuation token to restart a poller from a saved state. @@ -1412,86 +1813,93 @@ async def begin_delete_at_management_group_scope( # pylint: disable=inconsisten Retry-After header is present. :return: An instance of AsyncLROPoller that returns either None or the result of cls(response) :rtype: ~azure.core.polling.AsyncLROPoller[None] - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - api_version = kwargs.pop('api_version', "2019-08-01") # type: str - polling = kwargs.pop('polling', True) # type: Union[bool, AsyncPollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType[None] - lro_delay = kwargs.pop( - 'polling_interval', - self._config.polling_interval - ) - cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2019-08-01")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[None] + polling = kwargs.pop("polling", True) # type: Union[bool, AsyncPollingMethod] + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token = kwargs.pop("continuation_token", None) # type: Optional[str] if cont_token is None: - raw_result = await self._delete_at_management_group_scope_initial( + raw_result = await self._delete_at_management_group_scope_initial( # type: ignore group_id=group_id, deployment_name=deployment_name, api_version=api_version, - cls=lambda x,y,z: x, + cls=lambda x, y, z: x, + headers=_headers, + params=_params, **kwargs ) - kwargs.pop('error_map', None) + kwargs.pop("error_map", None) - def get_long_running_output(pipeline_response): + def get_long_running_output(pipeline_response): # pylint: disable=inconsistent-return-statements if cls: return cls(pipeline_response, None, {}) - - if polling is True: polling_method = AsyncARMPolling(lro_delay, **kwargs) - elif polling is False: polling_method = AsyncNoPolling() - else: polling_method = polling + if polling is True: + polling_method = cast(AsyncPollingMethod, AsyncARMPolling(lro_delay, **kwargs)) # type: AsyncPollingMethod + elif polling is False: + polling_method = cast(AsyncPollingMethod, AsyncNoPolling()) + else: + polling_method = polling if cont_token: return AsyncLROPoller.from_continuation_token( polling_method=polling_method, continuation_token=cont_token, client=self._client, - deserialization_callback=get_long_running_output + deserialization_callback=get_long_running_output, ) return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) - begin_delete_at_management_group_scope.metadata = {'url': "/providers/Microsoft.Management/managementGroups/{groupId}/providers/Microsoft.Resources/deployments/{deploymentName}"} # type: ignore + begin_delete_at_management_group_scope.metadata = {"url": "/providers/Microsoft.Management/managementGroups/{groupId}/providers/Microsoft.Resources/deployments/{deploymentName}"} # type: ignore @distributed_trace_async async def check_existence_at_management_group_scope( - self, - group_id: str, - deployment_name: str, - **kwargs: Any + self, group_id: str, deployment_name: str, **kwargs: Any ) -> bool: """Checks whether the deployment exists. - :param group_id: The management group ID. + :param group_id: The management group ID. Required. :type group_id: str - :param deployment_name: The name of the deployment. + :param deployment_name: The name of the deployment. Required. :type deployment_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: bool, or the result of cls(response) + :return: bool or the result of cls(response) :rtype: bool - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType[None] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) - api_version = kwargs.pop('api_version', "2019-08-01") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2019-08-01")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[None] - request = build_deployments_check_existence_at_management_group_scope_request( group_id=group_id, deployment_name=deployment_name, api_version=api_version, - template_url=self.check_existence_at_management_group_scope.metadata['url'], + template_url=self.check_existence_at_management_group_scope.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [204, 404]: @@ -1502,43 +1910,52 @@ async def check_existence_at_management_group_scope( return cls(pipeline_response, None, {}) return 200 <= response.status_code <= 299 - check_existence_at_management_group_scope.metadata = {'url': "/providers/Microsoft.Management/managementGroups/{groupId}/providers/Microsoft.Resources/deployments/{deploymentName}"} # type: ignore - + check_existence_at_management_group_scope.metadata = {"url": "/providers/Microsoft.Management/managementGroups/{groupId}/providers/Microsoft.Resources/deployments/{deploymentName}"} # type: ignore async def _create_or_update_at_management_group_scope_initial( - self, - group_id: str, - deployment_name: str, - parameters: "_models.ScopedDeployment", - **kwargs: Any - ) -> "_models.DeploymentExtended": - cls = kwargs.pop('cls', None) # type: ClsType["_models.DeploymentExtended"] + self, group_id: str, deployment_name: str, parameters: Union[_models.ScopedDeployment, IO], **kwargs: Any + ) -> _models.DeploymentExtended: error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', "2019-08-01") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + api_version = kwargs.pop("api_version", _params.pop("api-version", "2019-08-01")) # type: str + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.DeploymentExtended] - _json = self._serialize.body(parameters, 'ScopedDeployment') + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(parameters, (IO, bytes)): + _content = parameters + else: + _json = self._serialize.body(parameters, "ScopedDeployment") - request = build_deployments_create_or_update_at_management_group_scope_request_initial( + request = build_deployments_create_or_update_at_management_group_scope_request( group_id=group_id, deployment_name=deployment_name, api_version=api_version, content_type=content_type, json=_json, - template_url=self._create_or_update_at_management_group_scope_initial.metadata['url'], + content=_content, + template_url=self._create_or_update_at_management_group_scope_initial.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200, 201]: @@ -1546,37 +1963,41 @@ async def _create_or_update_at_management_group_scope_initial( raise HttpResponseError(response=response, error_format=ARMErrorFormat) if response.status_code == 200: - deserialized = self._deserialize('DeploymentExtended', pipeline_response) + deserialized = self._deserialize("DeploymentExtended", pipeline_response) if response.status_code == 201: - deserialized = self._deserialize('DeploymentExtended', pipeline_response) + deserialized = self._deserialize("DeploymentExtended", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - _create_or_update_at_management_group_scope_initial.metadata = {'url': "/providers/Microsoft.Management/managementGroups/{groupId}/providers/Microsoft.Resources/deployments/{deploymentName}"} # type: ignore - + _create_or_update_at_management_group_scope_initial.metadata = {"url": "/providers/Microsoft.Management/managementGroups/{groupId}/providers/Microsoft.Resources/deployments/{deploymentName}"} # type: ignore - @distributed_trace_async + @overload async def begin_create_or_update_at_management_group_scope( self, group_id: str, deployment_name: str, - parameters: "_models.ScopedDeployment", + parameters: _models.ScopedDeployment, + *, + content_type: str = "application/json", **kwargs: Any - ) -> AsyncLROPoller["_models.DeploymentExtended"]: + ) -> AsyncLROPoller[_models.DeploymentExtended]: """Deploys resources at management group scope. You can provide the template and parameters directly in the request or link to JSON files. - :param group_id: The management group ID. + :param group_id: The management group ID. Required. :type group_id: str - :param deployment_name: The name of the deployment. + :param deployment_name: The name of the deployment. Required. :type deployment_name: str - :param parameters: Additional parameters supplied to the operation. + :param parameters: Additional parameters supplied to the operation. Required. :type parameters: ~azure.mgmt.resource.resources.v2019_08_01.models.ScopedDeployment + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str :keyword callable cls: A custom type or function that will be passed the direct response :keyword str continuation_token: A continuation token to restart a poller from a saved state. :keyword polling: By default, your polling method will be AsyncARMPolling. Pass in False for @@ -1589,114 +2010,187 @@ async def begin_create_or_update_at_management_group_scope( cls(response) :rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.resource.resources.v2019_08_01.models.DeploymentExtended] - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - api_version = kwargs.pop('api_version', "2019-08-01") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] - polling = kwargs.pop('polling', True) # type: Union[bool, AsyncPollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType["_models.DeploymentExtended"] - lro_delay = kwargs.pop( - 'polling_interval', - self._config.polling_interval - ) - cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] + + @overload + async def begin_create_or_update_at_management_group_scope( + self, + group_id: str, + deployment_name: str, + parameters: IO, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> AsyncLROPoller[_models.DeploymentExtended]: + """Deploys resources at management group scope. + + You can provide the template and parameters directly in the request or link to JSON files. + + :param group_id: The management group ID. Required. + :type group_id: str + :param deployment_name: The name of the deployment. Required. + :type deployment_name: str + :param parameters: Additional parameters supplied to the operation. Required. + :type parameters: IO + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be AsyncARMPolling. Pass in False for + this operation to not poll, or pass in your own initialized polling object for a personal + polling strategy. + :paramtype polling: bool or ~azure.core.polling.AsyncPollingMethod + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of AsyncLROPoller that returns either DeploymentExtended or the result of + cls(response) + :rtype: + ~azure.core.polling.AsyncLROPoller[~azure.mgmt.resource.resources.v2019_08_01.models.DeploymentExtended] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace_async + async def begin_create_or_update_at_management_group_scope( + self, group_id: str, deployment_name: str, parameters: Union[_models.ScopedDeployment, IO], **kwargs: Any + ) -> AsyncLROPoller[_models.DeploymentExtended]: + """Deploys resources at management group scope. + + You can provide the template and parameters directly in the request or link to JSON files. + + :param group_id: The management group ID. Required. + :type group_id: str + :param deployment_name: The name of the deployment. Required. + :type deployment_name: str + :param parameters: Additional parameters supplied to the operation. Is either a model type or a + IO type. Required. + :type parameters: ~azure.mgmt.resource.resources.v2019_08_01.models.ScopedDeployment or IO + :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. + Default value is None. + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be AsyncARMPolling. Pass in False for + this operation to not poll, or pass in your own initialized polling object for a personal + polling strategy. + :paramtype polling: bool or ~azure.core.polling.AsyncPollingMethod + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of AsyncLROPoller that returns either DeploymentExtended or the result of + cls(response) + :rtype: + ~azure.core.polling.AsyncLROPoller[~azure.mgmt.resource.resources.v2019_08_01.models.DeploymentExtended] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _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", "2019-08-01")) # type: str + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.DeploymentExtended] + polling = kwargs.pop("polling", True) # type: Union[bool, AsyncPollingMethod] + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token = kwargs.pop("continuation_token", None) # type: Optional[str] if cont_token is None: - raw_result = await self._create_or_update_at_management_group_scope_initial( + raw_result = await self._create_or_update_at_management_group_scope_initial( # type: ignore group_id=group_id, deployment_name=deployment_name, parameters=parameters, api_version=api_version, content_type=content_type, - cls=lambda x,y,z: x, + cls=lambda x, y, z: x, + headers=_headers, + params=_params, **kwargs ) - kwargs.pop('error_map', None) + kwargs.pop("error_map", None) def get_long_running_output(pipeline_response): - response = pipeline_response.http_response - deserialized = self._deserialize('DeploymentExtended', pipeline_response) + deserialized = self._deserialize("DeploymentExtended", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - - if polling is True: polling_method = AsyncARMPolling(lro_delay, **kwargs) - elif polling is False: polling_method = AsyncNoPolling() - else: polling_method = polling + if polling is True: + polling_method = cast(AsyncPollingMethod, AsyncARMPolling(lro_delay, **kwargs)) # type: AsyncPollingMethod + elif polling is False: + polling_method = cast(AsyncPollingMethod, AsyncNoPolling()) + else: + polling_method = polling if cont_token: return AsyncLROPoller.from_continuation_token( polling_method=polling_method, continuation_token=cont_token, client=self._client, - deserialization_callback=get_long_running_output + deserialization_callback=get_long_running_output, ) return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) - begin_create_or_update_at_management_group_scope.metadata = {'url': "/providers/Microsoft.Management/managementGroups/{groupId}/providers/Microsoft.Resources/deployments/{deploymentName}"} # type: ignore + begin_create_or_update_at_management_group_scope.metadata = {"url": "/providers/Microsoft.Management/managementGroups/{groupId}/providers/Microsoft.Resources/deployments/{deploymentName}"} # type: ignore @distributed_trace_async async def get_at_management_group_scope( - self, - group_id: str, - deployment_name: str, - **kwargs: Any - ) -> "_models.DeploymentExtended": + self, group_id: str, deployment_name: str, **kwargs: Any + ) -> _models.DeploymentExtended: """Gets a deployment. - :param group_id: The management group ID. + :param group_id: The management group ID. Required. :type group_id: str - :param deployment_name: The name of the deployment. + :param deployment_name: The name of the deployment. Required. :type deployment_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: DeploymentExtended, or the result of cls(response) + :return: DeploymentExtended or the result of cls(response) :rtype: ~azure.mgmt.resource.resources.v2019_08_01.models.DeploymentExtended - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.DeploymentExtended"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) - api_version = kwargs.pop('api_version', "2019-08-01") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2019-08-01")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[_models.DeploymentExtended] - request = build_deployments_get_at_management_group_scope_request( group_id=group_id, deployment_name=deployment_name, api_version=api_version, - template_url=self.get_at_management_group_scope.metadata['url'], + template_url=self.get_at_management_group_scope.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) - deserialized = self._deserialize('DeploymentExtended', pipeline_response) + deserialized = self._deserialize("DeploymentExtended", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - get_at_management_group_scope.metadata = {'url': "/providers/Microsoft.Management/managementGroups/{groupId}/providers/Microsoft.Resources/deployments/{deploymentName}"} # type: ignore - + get_at_management_group_scope.metadata = {"url": "/providers/Microsoft.Management/managementGroups/{groupId}/providers/Microsoft.Resources/deployments/{deploymentName}"} # type: ignore @distributed_trace_async async def cancel_at_management_group_scope( # pylint: disable=inconsistent-return-statements - self, - group_id: str, - deployment_name: str, - **kwargs: Any + self, group_id: str, deployment_name: str, **kwargs: Any ) -> None: """Cancels a currently running template deployment. @@ -1705,38 +2199,44 @@ async def cancel_at_management_group_scope( # pylint: disable=inconsistent-retu deployment stops the currently running template deployment and leaves the resources partially deployed. - :param group_id: The management group ID. + :param group_id: The management group ID. Required. :type group_id: str - :param deployment_name: The name of the deployment. + :param deployment_name: The name of the deployment. Required. :type deployment_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: None, or the result of cls(response) + :return: None or the result of cls(response) :rtype: None - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType[None] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + 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', "2019-08-01") # type: str + api_version = kwargs.pop("api_version", _params.pop("api-version", "2019-08-01")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[None] - request = build_deployments_cancel_at_management_group_scope_request( group_id=group_id, deployment_name=deployment_name, api_version=api_version, - template_url=self.cancel_at_management_group_scope.metadata['url'], + template_url=self.cancel_at_management_group_scope.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [204]: @@ -1746,41 +2246,107 @@ async def cancel_at_management_group_scope( # pylint: disable=inconsistent-retu if cls: return cls(pipeline_response, None, {}) - cancel_at_management_group_scope.metadata = {'url': "/providers/Microsoft.Management/managementGroups/{groupId}/providers/Microsoft.Resources/deployments/{deploymentName}/cancel"} # type: ignore - + cancel_at_management_group_scope.metadata = {"url": "/providers/Microsoft.Management/managementGroups/{groupId}/providers/Microsoft.Resources/deployments/{deploymentName}/cancel"} # type: ignore - @distributed_trace_async + @overload async def validate_at_management_group_scope( self, group_id: str, deployment_name: str, - parameters: "_models.ScopedDeployment", + parameters: _models.ScopedDeployment, + *, + content_type: str = "application/json", **kwargs: Any - ) -> "_models.DeploymentValidateResult": + ) -> _models.DeploymentValidateResult: """Validates whether the specified template is syntactically correct and will be accepted by Azure Resource Manager.. - :param group_id: The management group ID. + :param group_id: The management group ID. Required. :type group_id: str - :param deployment_name: The name of the deployment. + :param deployment_name: The name of the deployment. Required. :type deployment_name: str - :param parameters: Parameters to validate. + :param parameters: Parameters to validate. Required. :type parameters: ~azure.mgmt.resource.resources.v2019_08_01.models.ScopedDeployment + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: DeploymentValidateResult or the result of cls(response) + :rtype: ~azure.mgmt.resource.resources.v2019_08_01.models.DeploymentValidateResult + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + async def validate_at_management_group_scope( + self, + group_id: str, + deployment_name: str, + parameters: IO, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.DeploymentValidateResult: + """Validates whether the specified template is syntactically correct and will be accepted by Azure + Resource Manager.. + + :param group_id: The management group ID. Required. + :type group_id: str + :param deployment_name: The name of the deployment. Required. + :type deployment_name: str + :param parameters: Parameters to validate. Required. + :type parameters: IO + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: DeploymentValidateResult or the result of cls(response) + :rtype: ~azure.mgmt.resource.resources.v2019_08_01.models.DeploymentValidateResult + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace_async + async def validate_at_management_group_scope( + self, group_id: str, deployment_name: str, parameters: Union[_models.ScopedDeployment, IO], **kwargs: Any + ) -> _models.DeploymentValidateResult: + """Validates whether the specified template is syntactically correct and will be accepted by Azure + Resource Manager.. + + :param group_id: The management group ID. Required. + :type group_id: str + :param deployment_name: The name of the deployment. Required. + :type deployment_name: str + :param parameters: Parameters to validate. Is either a model type or a IO type. Required. + :type parameters: ~azure.mgmt.resource.resources.v2019_08_01.models.ScopedDeployment or IO + :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. + Default value is None. + :paramtype content_type: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: DeploymentValidateResult, or the result of cls(response) + :return: DeploymentValidateResult or the result of cls(response) :rtype: ~azure.mgmt.resource.resources.v2019_08_01.models.DeploymentValidateResult - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.DeploymentValidateResult"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', "2019-08-01") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + api_version = kwargs.pop("api_version", _params.pop("api-version", "2019-08-01")) # type: str + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.DeploymentValidateResult] - _json = self._serialize.body(parameters, 'ScopedDeployment') + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(parameters, (IO, bytes)): + _content = parameters + else: + _json = self._serialize.body(parameters, "ScopedDeployment") request = build_deployments_validate_at_management_group_scope_request( group_id=group_id, @@ -1788,16 +2354,18 @@ async def validate_at_management_group_scope( api_version=api_version, content_type=content_type, json=_json, - template_url=self.validate_at_management_group_scope.metadata['url'], + content=_content, + template_url=self.validate_at_management_group_scope.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200, 400]: @@ -1805,87 +2373,84 @@ async def validate_at_management_group_scope( raise HttpResponseError(response=response, error_format=ARMErrorFormat) if response.status_code == 200: - deserialized = self._deserialize('DeploymentValidateResult', pipeline_response) + deserialized = self._deserialize("DeploymentValidateResult", pipeline_response) if response.status_code == 400: - deserialized = self._deserialize('DeploymentValidateResult', pipeline_response) + deserialized = self._deserialize("DeploymentValidateResult", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - validate_at_management_group_scope.metadata = {'url': "/providers/Microsoft.Management/managementGroups/{groupId}/providers/Microsoft.Resources/deployments/{deploymentName}/validate"} # type: ignore - + validate_at_management_group_scope.metadata = {"url": "/providers/Microsoft.Management/managementGroups/{groupId}/providers/Microsoft.Resources/deployments/{deploymentName}/validate"} # type: ignore @distributed_trace_async async def export_template_at_management_group_scope( - self, - group_id: str, - deployment_name: str, - **kwargs: Any - ) -> "_models.DeploymentExportResult": + self, group_id: str, deployment_name: str, **kwargs: Any + ) -> _models.DeploymentExportResult: """Exports the template used for specified deployment. - :param group_id: The management group ID. + :param group_id: The management group ID. Required. :type group_id: str - :param deployment_name: The name of the deployment. + :param deployment_name: The name of the deployment. Required. :type deployment_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: DeploymentExportResult, or the result of cls(response) + :return: DeploymentExportResult or the result of cls(response) :rtype: ~azure.mgmt.resource.resources.v2019_08_01.models.DeploymentExportResult - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.DeploymentExportResult"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) - api_version = kwargs.pop('api_version', "2019-08-01") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2019-08-01")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[_models.DeploymentExportResult] - request = build_deployments_export_template_at_management_group_scope_request( group_id=group_id, deployment_name=deployment_name, api_version=api_version, - template_url=self.export_template_at_management_group_scope.metadata['url'], + template_url=self.export_template_at_management_group_scope.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) - deserialized = self._deserialize('DeploymentExportResult', pipeline_response) + deserialized = self._deserialize("DeploymentExportResult", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - export_template_at_management_group_scope.metadata = {'url': "/providers/Microsoft.Management/managementGroups/{groupId}/providers/Microsoft.Resources/deployments/{deploymentName}/exportTemplate"} # type: ignore - + export_template_at_management_group_scope.metadata = {"url": "/providers/Microsoft.Management/managementGroups/{groupId}/providers/Microsoft.Resources/deployments/{deploymentName}/exportTemplate"} # type: ignore @distributed_trace def list_at_management_group_scope( - self, - group_id: str, - filter: Optional[str] = None, - top: Optional[int] = None, - **kwargs: Any - ) -> AsyncIterable["_models.DeploymentListResult"]: + self, group_id: str, filter: Optional[str] = None, top: Optional[int] = None, **kwargs: Any + ) -> AsyncIterable["_models.DeploymentExtended"]: """Get all the deployments for a management group. - :param group_id: The management group ID. + :param group_id: The management group ID. Required. :type group_id: str :param filter: The filter to apply on the operation. For example, you can use $filter=provisioningState eq '{state}'. Default value is None. @@ -1894,40 +2459,48 @@ def list_at_management_group_scope( value is None. :type top: int :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either DeploymentListResult or the result of - cls(response) + :return: An iterator like instance of either DeploymentExtended or the result of cls(response) :rtype: - ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.resource.resources.v2019_08_01.models.DeploymentListResult] - :raises: ~azure.core.exceptions.HttpResponseError + ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.resource.resources.v2019_08_01.models.DeploymentExtended] + :raises ~azure.core.exceptions.HttpResponseError: """ - api_version = kwargs.pop('api_version', "2019-08-01") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2019-08-01")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[_models.DeploymentListResult] - cls = kwargs.pop('cls', None) # type: ClsType["_models.DeploymentListResult"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) + def prepare_request(next_link=None): if not next_link: - + request = build_deployments_list_at_management_group_scope_request( group_id=group_id, - api_version=api_version, filter=filter, top=top, - template_url=self.list_at_management_group_scope.metadata['url'], + api_version=api_version, + template_url=self.list_at_management_group_scope.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore else: - - request = build_deployments_list_at_management_group_scope_request( - group_id=group_id, - template_url=next_link, - ) + # make call to next link with the client's api-version + _parsed_next_link = urlparse(next_link) + _next_request_params = case_insensitive_dict(parse_qs(_parsed_next_link.query)) + _next_request_params["api-version"] = self._config.api_version + request = HttpRequest("GET", urljoin(next_link, _parsed_next_link.path), params=_next_request_params) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore request.method = "GET" return request @@ -1941,10 +2514,8 @@ async def extract_data(pipeline_response): async def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) response = pipeline_response.http_response @@ -1954,40 +2525,42 @@ async def get_next(next_link=None): return pipeline_response + return AsyncItemPaged(get_next, extract_data) - return AsyncItemPaged( - get_next, extract_data - ) - list_at_management_group_scope.metadata = {'url': "/providers/Microsoft.Management/managementGroups/{groupId}/providers/Microsoft.Resources/deployments/"} # type: ignore + list_at_management_group_scope.metadata = {"url": "/providers/Microsoft.Management/managementGroups/{groupId}/providers/Microsoft.Resources/deployments/"} # type: ignore async def _delete_at_subscription_scope_initial( # pylint: disable=inconsistent-return-statements - self, - deployment_name: str, - **kwargs: Any + self, deployment_name: str, **kwargs: Any ) -> None: - cls = kwargs.pop('cls', None) # type: ClsType[None] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) - api_version = kwargs.pop('api_version', "2019-08-01") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - request = build_deployments_delete_at_subscription_scope_request_initial( + api_version = kwargs.pop("api_version", _params.pop("api-version", "2019-08-01")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[None] + + request = build_deployments_delete_at_subscription_scope_request( deployment_name=deployment_name, subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self._delete_at_subscription_scope_initial.metadata['url'], + template_url=self._delete_at_subscription_scope_initial.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [202, 204]: @@ -1997,15 +2570,10 @@ async def _delete_at_subscription_scope_initial( # pylint: disable=inconsistent if cls: return cls(pipeline_response, None, {}) - _delete_at_subscription_scope_initial.metadata = {'url': "/subscriptions/{subscriptionId}/providers/Microsoft.Resources/deployments/{deploymentName}"} # type: ignore - + _delete_at_subscription_scope_initial.metadata = {"url": "/subscriptions/{subscriptionId}/providers/Microsoft.Resources/deployments/{deploymentName}"} # type: ignore @distributed_trace_async - async def begin_delete_at_subscription_scope( # pylint: disable=inconsistent-return-statements - self, - deployment_name: str, - **kwargs: Any - ) -> AsyncLROPoller[None]: + async def begin_delete_at_subscription_scope(self, deployment_name: str, **kwargs: Any) -> AsyncLROPoller[None]: """Deletes a deployment from the deployment history. A template deployment that is currently running cannot be deleted. Deleting a template @@ -2016,7 +2584,7 @@ async def begin_delete_at_subscription_scope( # pylint: disable=inconsistent-re process finishes, the URI in the Location header returns a status of 204 on success. If the asynchronous request failed, the URI in the Location header returns an error-level status code. - :param deployment_name: The name of the deployment. + :param deployment_name: The name of the deployment. Required. :type deployment_name: str :keyword callable cls: A custom type or function that will be passed the direct response :keyword str continuation_token: A continuation token to restart a poller from a saved state. @@ -2028,82 +2596,88 @@ async def begin_delete_at_subscription_scope( # pylint: disable=inconsistent-re Retry-After header is present. :return: An instance of AsyncLROPoller that returns either None or the result of cls(response) :rtype: ~azure.core.polling.AsyncLROPoller[None] - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - api_version = kwargs.pop('api_version', "2019-08-01") # type: str - polling = kwargs.pop('polling', True) # type: Union[bool, AsyncPollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType[None] - lro_delay = kwargs.pop( - 'polling_interval', - self._config.polling_interval - ) - cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2019-08-01")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[None] + polling = kwargs.pop("polling", True) # type: Union[bool, AsyncPollingMethod] + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token = kwargs.pop("continuation_token", None) # type: Optional[str] if cont_token is None: - raw_result = await self._delete_at_subscription_scope_initial( + raw_result = await self._delete_at_subscription_scope_initial( # type: ignore deployment_name=deployment_name, api_version=api_version, - cls=lambda x,y,z: x, + cls=lambda x, y, z: x, + headers=_headers, + params=_params, **kwargs ) - kwargs.pop('error_map', None) + kwargs.pop("error_map", None) - def get_long_running_output(pipeline_response): + def get_long_running_output(pipeline_response): # pylint: disable=inconsistent-return-statements if cls: return cls(pipeline_response, None, {}) - - if polling is True: polling_method = AsyncARMPolling(lro_delay, **kwargs) - elif polling is False: polling_method = AsyncNoPolling() - else: polling_method = polling + if polling is True: + polling_method = cast(AsyncPollingMethod, AsyncARMPolling(lro_delay, **kwargs)) # type: AsyncPollingMethod + elif polling is False: + polling_method = cast(AsyncPollingMethod, AsyncNoPolling()) + else: + polling_method = polling if cont_token: return AsyncLROPoller.from_continuation_token( polling_method=polling_method, continuation_token=cont_token, client=self._client, - deserialization_callback=get_long_running_output + deserialization_callback=get_long_running_output, ) return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) - begin_delete_at_subscription_scope.metadata = {'url': "/subscriptions/{subscriptionId}/providers/Microsoft.Resources/deployments/{deploymentName}"} # type: ignore + begin_delete_at_subscription_scope.metadata = {"url": "/subscriptions/{subscriptionId}/providers/Microsoft.Resources/deployments/{deploymentName}"} # type: ignore @distributed_trace_async - async def check_existence_at_subscription_scope( - self, - deployment_name: str, - **kwargs: Any - ) -> bool: + async def check_existence_at_subscription_scope(self, deployment_name: str, **kwargs: Any) -> bool: """Checks whether the deployment exists. - :param deployment_name: The name of the deployment. + :param deployment_name: The name of the deployment. Required. :type deployment_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: bool, or the result of cls(response) + :return: bool or the result of cls(response) :rtype: bool - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType[None] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) - api_version = kwargs.pop('api_version', "2019-08-01") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2019-08-01")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[None] - request = build_deployments_check_existence_at_subscription_scope_request( deployment_name=deployment_name, subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.check_existence_at_subscription_scope.metadata['url'], + template_url=self.check_existence_at_subscription_scope.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [204, 404]: @@ -2114,42 +2688,52 @@ async def check_existence_at_subscription_scope( return cls(pipeline_response, None, {}) return 200 <= response.status_code <= 299 - check_existence_at_subscription_scope.metadata = {'url': "/subscriptions/{subscriptionId}/providers/Microsoft.Resources/deployments/{deploymentName}"} # type: ignore - + check_existence_at_subscription_scope.metadata = {"url": "/subscriptions/{subscriptionId}/providers/Microsoft.Resources/deployments/{deploymentName}"} # type: ignore async def _create_or_update_at_subscription_scope_initial( - self, - deployment_name: str, - parameters: "_models.Deployment", - **kwargs: Any - ) -> "_models.DeploymentExtended": - cls = kwargs.pop('cls', None) # type: ClsType["_models.DeploymentExtended"] + self, deployment_name: str, parameters: Union[_models.Deployment, IO], **kwargs: Any + ) -> _models.DeploymentExtended: error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) - api_version = kwargs.pop('api_version', "2019-08-01") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - _json = self._serialize.body(parameters, 'Deployment') + api_version = kwargs.pop("api_version", _params.pop("api-version", "2019-08-01")) # type: str + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.DeploymentExtended] - request = build_deployments_create_or_update_at_subscription_scope_request_initial( + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(parameters, (IO, bytes)): + _content = parameters + else: + _json = self._serialize.body(parameters, "Deployment") + + request = build_deployments_create_or_update_at_subscription_scope_request( deployment_name=deployment_name, subscription_id=self._config.subscription_id, api_version=api_version, content_type=content_type, json=_json, - template_url=self._create_or_update_at_subscription_scope_initial.metadata['url'], + content=_content, + template_url=self._create_or_update_at_subscription_scope_initial.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200, 201]: @@ -2157,34 +2741,38 @@ async def _create_or_update_at_subscription_scope_initial( raise HttpResponseError(response=response, error_format=ARMErrorFormat) if response.status_code == 200: - deserialized = self._deserialize('DeploymentExtended', pipeline_response) + deserialized = self._deserialize("DeploymentExtended", pipeline_response) if response.status_code == 201: - deserialized = self._deserialize('DeploymentExtended', pipeline_response) + deserialized = self._deserialize("DeploymentExtended", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - _create_or_update_at_subscription_scope_initial.metadata = {'url': "/subscriptions/{subscriptionId}/providers/Microsoft.Resources/deployments/{deploymentName}"} # type: ignore + _create_or_update_at_subscription_scope_initial.metadata = {"url": "/subscriptions/{subscriptionId}/providers/Microsoft.Resources/deployments/{deploymentName}"} # type: ignore - - @distributed_trace_async + @overload async def begin_create_or_update_at_subscription_scope( self, deployment_name: str, - parameters: "_models.Deployment", + parameters: _models.Deployment, + *, + content_type: str = "application/json", **kwargs: Any - ) -> AsyncLROPoller["_models.DeploymentExtended"]: + ) -> AsyncLROPoller[_models.DeploymentExtended]: """Deploys resources at subscription scope. You can provide the template and parameters directly in the request or link to JSON files. - :param deployment_name: The name of the deployment. + :param deployment_name: The name of the deployment. Required. :type deployment_name: str - :param parameters: Additional parameters supplied to the operation. + :param parameters: Additional parameters supplied to the operation. Required. :type parameters: ~azure.mgmt.resource.resources.v2019_08_01.models.Deployment + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str :keyword callable cls: A custom type or function that will be passed the direct response :keyword str continuation_token: A continuation token to restart a poller from a saved state. :keyword polling: By default, your polling method will be AsyncARMPolling. Pass in False for @@ -2197,109 +2785,172 @@ async def begin_create_or_update_at_subscription_scope( cls(response) :rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.resource.resources.v2019_08_01.models.DeploymentExtended] - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - api_version = kwargs.pop('api_version', "2019-08-01") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] - polling = kwargs.pop('polling', True) # type: Union[bool, AsyncPollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType["_models.DeploymentExtended"] - lro_delay = kwargs.pop( - 'polling_interval', - self._config.polling_interval - ) - cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] - if cont_token is None: - raw_result = await self._create_or_update_at_subscription_scope_initial( - deployment_name=deployment_name, - parameters=parameters, - api_version=api_version, - content_type=content_type, - cls=lambda x,y,z: x, - **kwargs - ) - kwargs.pop('error_map', None) - - def get_long_running_output(pipeline_response): - response = pipeline_response.http_response - deserialized = self._deserialize('DeploymentExtended', pipeline_response) - if cls: - return cls(pipeline_response, deserialized, {}) - return deserialized - - - if polling is True: polling_method = AsyncARMPolling(lro_delay, **kwargs) - elif polling is False: polling_method = AsyncNoPolling() - else: polling_method = polling - if cont_token: - return AsyncLROPoller.from_continuation_token( - polling_method=polling_method, - continuation_token=cont_token, - client=self._client, - deserialization_callback=get_long_running_output - ) - return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) - begin_create_or_update_at_subscription_scope.metadata = {'url': "/subscriptions/{subscriptionId}/providers/Microsoft.Resources/deployments/{deploymentName}"} # type: ignore + @overload + async def begin_create_or_update_at_subscription_scope( + self, deployment_name: str, parameters: IO, *, content_type: str = "application/json", **kwargs: Any + ) -> AsyncLROPoller[_models.DeploymentExtended]: + """Deploys resources at subscription scope. - @distributed_trace_async - async def get_at_subscription_scope( - self, - deployment_name: str, - **kwargs: Any - ) -> "_models.DeploymentExtended": - """Gets a deployment. + You can provide the template and parameters directly in the request or link to JSON files. - :param deployment_name: The name of the deployment. + :param deployment_name: The name of the deployment. Required. :type deployment_name: str + :param parameters: Additional parameters supplied to the operation. Required. + :type parameters: IO + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: DeploymentExtended, or the result of cls(response) - :rtype: ~azure.mgmt.resource.resources.v2019_08_01.models.DeploymentExtended - :raises: ~azure.core.exceptions.HttpResponseError - """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.DeploymentExtended"] - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {})) - - api_version = kwargs.pop('api_version', "2019-08-01") # type: str - - - request = build_deployments_get_at_subscription_scope_request( - deployment_name=deployment_name, - subscription_id=self._config.subscription_id, - api_version=api_version, - template_url=self.get_at_subscription_scope.metadata['url'], + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be AsyncARMPolling. Pass in False for + this operation to not poll, or pass in your own initialized polling object for a personal + polling strategy. + :paramtype polling: bool or ~azure.core.polling.AsyncPollingMethod + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of AsyncLROPoller that returns either DeploymentExtended or the result of + cls(response) + :rtype: + ~azure.core.polling.AsyncLROPoller[~azure.mgmt.resource.resources.v2019_08_01.models.DeploymentExtended] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace_async + async def begin_create_or_update_at_subscription_scope( + self, deployment_name: str, parameters: Union[_models.Deployment, IO], **kwargs: Any + ) -> AsyncLROPoller[_models.DeploymentExtended]: + """Deploys resources at subscription scope. + + You can provide the template and parameters directly in the request or link to JSON files. + + :param deployment_name: The name of the deployment. Required. + :type deployment_name: str + :param parameters: Additional parameters supplied to the operation. Is either a model type or a + IO type. Required. + :type parameters: ~azure.mgmt.resource.resources.v2019_08_01.models.Deployment or IO + :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. + Default value is None. + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be AsyncARMPolling. Pass in False for + this operation to not poll, or pass in your own initialized polling object for a personal + polling strategy. + :paramtype polling: bool or ~azure.core.polling.AsyncPollingMethod + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of AsyncLROPoller that returns either DeploymentExtended or the result of + cls(response) + :rtype: + ~azure.core.polling.AsyncLROPoller[~azure.mgmt.resource.resources.v2019_08_01.models.DeploymentExtended] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _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", "2019-08-01")) # type: str + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.DeploymentExtended] + polling = kwargs.pop("polling", True) # type: Union[bool, AsyncPollingMethod] + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token = kwargs.pop("continuation_token", None) # type: Optional[str] + if cont_token is None: + raw_result = await self._create_or_update_at_subscription_scope_initial( # type: ignore + deployment_name=deployment_name, + parameters=parameters, + api_version=api_version, + content_type=content_type, + cls=lambda x, y, z: x, + headers=_headers, + params=_params, + **kwargs + ) + kwargs.pop("error_map", None) + + def get_long_running_output(pipeline_response): + deserialized = self._deserialize("DeploymentExtended", pipeline_response) + if cls: + return cls(pipeline_response, deserialized, {}) + return deserialized + + if polling is True: + polling_method = cast(AsyncPollingMethod, AsyncARMPolling(lro_delay, **kwargs)) # type: AsyncPollingMethod + elif polling is False: + polling_method = cast(AsyncPollingMethod, AsyncNoPolling()) + else: + polling_method = polling + if cont_token: + return AsyncLROPoller.from_continuation_token( + polling_method=polling_method, + continuation_token=cont_token, + client=self._client, + deserialization_callback=get_long_running_output, + ) + return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) + + begin_create_or_update_at_subscription_scope.metadata = {"url": "/subscriptions/{subscriptionId}/providers/Microsoft.Resources/deployments/{deploymentName}"} # type: ignore + + @distributed_trace_async + async def get_at_subscription_scope(self, deployment_name: str, **kwargs: Any) -> _models.DeploymentExtended: + """Gets a deployment. + + :param deployment_name: The name of the deployment. Required. + :type deployment_name: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: DeploymentExtended or the result of cls(response) + :rtype: ~azure.mgmt.resource.resources.v2019_08_01.models.DeploymentExtended + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2019-08-01")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[_models.DeploymentExtended] + + request = build_deployments_get_at_subscription_scope_request( + deployment_name=deployment_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + template_url=self.get_at_subscription_scope.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) - deserialized = self._deserialize('DeploymentExtended', pipeline_response) + deserialized = self._deserialize("DeploymentExtended", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - get_at_subscription_scope.metadata = {'url': "/subscriptions/{subscriptionId}/providers/Microsoft.Resources/deployments/{deploymentName}"} # type: ignore - + get_at_subscription_scope.metadata = {"url": "/subscriptions/{subscriptionId}/providers/Microsoft.Resources/deployments/{deploymentName}"} # type: ignore @distributed_trace_async async def cancel_at_subscription_scope( # pylint: disable=inconsistent-return-statements - self, - deployment_name: str, - **kwargs: Any + self, deployment_name: str, **kwargs: Any ) -> None: """Cancels a currently running template deployment. @@ -2308,36 +2959,42 @@ async def cancel_at_subscription_scope( # pylint: disable=inconsistent-return-s deployment stops the currently running template deployment and leaves the resources partially deployed. - :param deployment_name: The name of the deployment. + :param deployment_name: The name of the deployment. Required. :type deployment_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: None, or the result of cls(response) + :return: None or the result of cls(response) :rtype: None - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType[None] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) - api_version = kwargs.pop('api_version', "2019-08-01") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2019-08-01")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[None] - request = build_deployments_cancel_at_subscription_scope_request( deployment_name=deployment_name, subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.cancel_at_subscription_scope.metadata['url'], + template_url=self.cancel_at_subscription_scope.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [204]: @@ -2347,38 +3004,94 @@ async def cancel_at_subscription_scope( # pylint: disable=inconsistent-return-s if cls: return cls(pipeline_response, None, {}) - cancel_at_subscription_scope.metadata = {'url': "/subscriptions/{subscriptionId}/providers/Microsoft.Resources/deployments/{deploymentName}/cancel"} # type: ignore + cancel_at_subscription_scope.metadata = {"url": "/subscriptions/{subscriptionId}/providers/Microsoft.Resources/deployments/{deploymentName}/cancel"} # type: ignore - - @distributed_trace_async + @overload async def validate_at_subscription_scope( self, deployment_name: str, - parameters: "_models.Deployment", + parameters: _models.Deployment, + *, + content_type: str = "application/json", **kwargs: Any - ) -> "_models.DeploymentValidateResult": + ) -> _models.DeploymentValidateResult: """Validates whether the specified template is syntactically correct and will be accepted by Azure Resource Manager.. - :param deployment_name: The name of the deployment. + :param deployment_name: The name of the deployment. Required. :type deployment_name: str - :param parameters: Parameters to validate. + :param parameters: Parameters to validate. Required. :type parameters: ~azure.mgmt.resource.resources.v2019_08_01.models.Deployment + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: DeploymentValidateResult, or the result of cls(response) + :return: DeploymentValidateResult or the result of cls(response) :rtype: ~azure.mgmt.resource.resources.v2019_08_01.models.DeploymentValidateResult - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + async def validate_at_subscription_scope( + self, deployment_name: str, parameters: IO, *, content_type: str = "application/json", **kwargs: Any + ) -> _models.DeploymentValidateResult: + """Validates whether the specified template is syntactically correct and will be accepted by Azure + Resource Manager.. + + :param deployment_name: The name of the deployment. Required. + :type deployment_name: str + :param parameters: Parameters to validate. Required. + :type parameters: IO + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: DeploymentValidateResult or the result of cls(response) + :rtype: ~azure.mgmt.resource.resources.v2019_08_01.models.DeploymentValidateResult + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace_async + async def validate_at_subscription_scope( + self, deployment_name: str, parameters: Union[_models.Deployment, IO], **kwargs: Any + ) -> _models.DeploymentValidateResult: + """Validates whether the specified template is syntactically correct and will be accepted by Azure + Resource Manager.. + + :param deployment_name: The name of the deployment. Required. + :type deployment_name: str + :param parameters: Parameters to validate. Is either a model type or a IO type. Required. + :type parameters: ~azure.mgmt.resource.resources.v2019_08_01.models.Deployment or IO + :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. + Default value is None. + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: DeploymentValidateResult or the result of cls(response) + :rtype: ~azure.mgmt.resource.resources.v2019_08_01.models.DeploymentValidateResult + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.DeploymentValidateResult"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', "2019-08-01") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + api_version = kwargs.pop("api_version", _params.pop("api-version", "2019-08-01")) # type: str + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.DeploymentValidateResult] - _json = self._serialize.body(parameters, 'Deployment') + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(parameters, (IO, bytes)): + _content = parameters + else: + _json = self._serialize.body(parameters, "Deployment") request = build_deployments_validate_at_subscription_scope_request( deployment_name=deployment_name, @@ -2386,16 +3099,18 @@ async def validate_at_subscription_scope( api_version=api_version, content_type=content_type, json=_json, - template_url=self.validate_at_subscription_scope.metadata['url'], + content=_content, + template_url=self.validate_at_subscription_scope.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200, 400]: @@ -2403,52 +3118,62 @@ async def validate_at_subscription_scope( raise HttpResponseError(response=response, error_format=ARMErrorFormat) if response.status_code == 200: - deserialized = self._deserialize('DeploymentValidateResult', pipeline_response) + deserialized = self._deserialize("DeploymentValidateResult", pipeline_response) if response.status_code == 400: - deserialized = self._deserialize('DeploymentValidateResult', pipeline_response) + deserialized = self._deserialize("DeploymentValidateResult", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - validate_at_subscription_scope.metadata = {'url': "/subscriptions/{subscriptionId}/providers/Microsoft.Resources/deployments/{deploymentName}/validate"} # type: ignore - + validate_at_subscription_scope.metadata = {"url": "/subscriptions/{subscriptionId}/providers/Microsoft.Resources/deployments/{deploymentName}/validate"} # type: ignore async def _what_if_at_subscription_scope_initial( - self, - deployment_name: str, - parameters: "_models.DeploymentWhatIf", - **kwargs: Any - ) -> Optional["_models.WhatIfOperationResult"]: - cls = kwargs.pop('cls', None) # type: ClsType[Optional["_models.WhatIfOperationResult"]] + self, deployment_name: str, parameters: Union[_models.DeploymentWhatIf, IO], **kwargs: Any + ) -> Optional[_models.WhatIfOperationResult]: error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) - api_version = kwargs.pop('api_version', "2019-08-01") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - _json = self._serialize.body(parameters, 'DeploymentWhatIf') + api_version = kwargs.pop("api_version", _params.pop("api-version", "2019-08-01")) # type: str + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[Optional[_models.WhatIfOperationResult]] - request = build_deployments_what_if_at_subscription_scope_request_initial( + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(parameters, (IO, bytes)): + _content = parameters + else: + _json = self._serialize.body(parameters, "DeploymentWhatIf") + + request = build_deployments_what_if_at_subscription_scope_request( deployment_name=deployment_name, subscription_id=self._config.subscription_id, api_version=api_version, content_type=content_type, json=_json, - template_url=self._what_if_at_subscription_scope_initial.metadata['url'], + content=_content, + template_url=self._what_if_at_subscription_scope_initial.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200, 202]: @@ -2458,35 +3183,38 @@ async def _what_if_at_subscription_scope_initial( deserialized = None response_headers = {} if response.status_code == 200: - deserialized = self._deserialize('WhatIfOperationResult', pipeline_response) + deserialized = self._deserialize("WhatIfOperationResult", pipeline_response) if response.status_code == 202: - response_headers['Location']=self._deserialize('str', response.headers.get('Location')) - response_headers['Retry-After']=self._deserialize('str', response.headers.get('Retry-After')) - + response_headers["Location"] = self._deserialize("str", response.headers.get("Location")) + response_headers["Retry-After"] = self._deserialize("str", response.headers.get("Retry-After")) if cls: return cls(pipeline_response, deserialized, response_headers) return deserialized - _what_if_at_subscription_scope_initial.metadata = {'url': "/subscriptions/{subscriptionId}/providers/Microsoft.Resources/deployments/{deploymentName}/whatIf"} # type: ignore + _what_if_at_subscription_scope_initial.metadata = {"url": "/subscriptions/{subscriptionId}/providers/Microsoft.Resources/deployments/{deploymentName}/whatIf"} # type: ignore - - @distributed_trace_async + @overload async def begin_what_if_at_subscription_scope( self, deployment_name: str, - parameters: "_models.DeploymentWhatIf", + parameters: _models.DeploymentWhatIf, + *, + content_type: str = "application/json", **kwargs: Any - ) -> AsyncLROPoller["_models.WhatIfOperationResult"]: + ) -> AsyncLROPoller[_models.WhatIfOperationResult]: """Returns changes that will be made by the deployment if executed at the scope of the subscription. - :param deployment_name: The name of the deployment. + :param deployment_name: The name of the deployment. Required. :type deployment_name: str - :param parameters: Parameters to What If. + :param parameters: Parameters to What If. Required. :type parameters: ~azure.mgmt.resource.resources.v2019_08_01.models.DeploymentWhatIf + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str :keyword callable cls: A custom type or function that will be passed the direct response :keyword str continuation_token: A continuation token to restart a poller from a saved state. :keyword polling: By default, your polling method will be AsyncARMPolling. Pass in False for @@ -2499,111 +3227,174 @@ async def begin_what_if_at_subscription_scope( of cls(response) :rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.resource.resources.v2019_08_01.models.WhatIfOperationResult] - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - api_version = kwargs.pop('api_version', "2019-08-01") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] - polling = kwargs.pop('polling', True) # type: Union[bool, AsyncPollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType["_models.WhatIfOperationResult"] - lro_delay = kwargs.pop( - 'polling_interval', - self._config.polling_interval - ) - cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] + + @overload + async def begin_what_if_at_subscription_scope( + self, deployment_name: str, parameters: IO, *, content_type: str = "application/json", **kwargs: Any + ) -> AsyncLROPoller[_models.WhatIfOperationResult]: + """Returns changes that will be made by the deployment if executed at the scope of the + subscription. + + :param deployment_name: The name of the deployment. Required. + :type deployment_name: str + :param parameters: Parameters to What If. Required. + :type parameters: IO + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be AsyncARMPolling. Pass in False for + this operation to not poll, or pass in your own initialized polling object for a personal + polling strategy. + :paramtype polling: bool or ~azure.core.polling.AsyncPollingMethod + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of AsyncLROPoller that returns either WhatIfOperationResult or the result + of cls(response) + :rtype: + ~azure.core.polling.AsyncLROPoller[~azure.mgmt.resource.resources.v2019_08_01.models.WhatIfOperationResult] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace_async + async def begin_what_if_at_subscription_scope( + self, deployment_name: str, parameters: Union[_models.DeploymentWhatIf, IO], **kwargs: Any + ) -> AsyncLROPoller[_models.WhatIfOperationResult]: + """Returns changes that will be made by the deployment if executed at the scope of the + subscription. + + :param deployment_name: The name of the deployment. Required. + :type deployment_name: str + :param parameters: Parameters to What If. Is either a model type or a IO type. Required. + :type parameters: ~azure.mgmt.resource.resources.v2019_08_01.models.DeploymentWhatIf or IO + :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. + Default value is None. + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be AsyncARMPolling. Pass in False for + this operation to not poll, or pass in your own initialized polling object for a personal + polling strategy. + :paramtype polling: bool or ~azure.core.polling.AsyncPollingMethod + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of AsyncLROPoller that returns either WhatIfOperationResult or the result + of cls(response) + :rtype: + ~azure.core.polling.AsyncLROPoller[~azure.mgmt.resource.resources.v2019_08_01.models.WhatIfOperationResult] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _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", "2019-08-01")) # type: str + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.WhatIfOperationResult] + polling = kwargs.pop("polling", True) # type: Union[bool, AsyncPollingMethod] + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token = kwargs.pop("continuation_token", None) # type: Optional[str] if cont_token is None: - raw_result = await self._what_if_at_subscription_scope_initial( + raw_result = await self._what_if_at_subscription_scope_initial( # type: ignore deployment_name=deployment_name, parameters=parameters, api_version=api_version, content_type=content_type, - cls=lambda x,y,z: x, + cls=lambda x, y, z: x, + headers=_headers, + params=_params, **kwargs ) - kwargs.pop('error_map', None) + kwargs.pop("error_map", None) def get_long_running_output(pipeline_response): - response = pipeline_response.http_response - deserialized = self._deserialize('WhatIfOperationResult', pipeline_response) + deserialized = self._deserialize("WhatIfOperationResult", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - - if polling is True: polling_method = AsyncARMPolling(lro_delay, lro_options={'final-state-via': 'location'}, **kwargs) - elif polling is False: polling_method = AsyncNoPolling() - else: polling_method = polling + if polling is True: + polling_method = cast( + AsyncPollingMethod, AsyncARMPolling(lro_delay, lro_options={"final-state-via": "location"}, **kwargs) + ) # type: AsyncPollingMethod + elif polling is False: + polling_method = cast(AsyncPollingMethod, AsyncNoPolling()) + else: + polling_method = polling if cont_token: return AsyncLROPoller.from_continuation_token( polling_method=polling_method, continuation_token=cont_token, client=self._client, - deserialization_callback=get_long_running_output + deserialization_callback=get_long_running_output, ) return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) - begin_what_if_at_subscription_scope.metadata = {'url': "/subscriptions/{subscriptionId}/providers/Microsoft.Resources/deployments/{deploymentName}/whatIf"} # type: ignore + begin_what_if_at_subscription_scope.metadata = {"url": "/subscriptions/{subscriptionId}/providers/Microsoft.Resources/deployments/{deploymentName}/whatIf"} # type: ignore @distributed_trace_async async def export_template_at_subscription_scope( - self, - deployment_name: str, - **kwargs: Any - ) -> "_models.DeploymentExportResult": + self, deployment_name: str, **kwargs: Any + ) -> _models.DeploymentExportResult: """Exports the template used for specified deployment. - :param deployment_name: The name of the deployment. + :param deployment_name: The name of the deployment. Required. :type deployment_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: DeploymentExportResult, or the result of cls(response) + :return: DeploymentExportResult or the result of cls(response) :rtype: ~azure.mgmt.resource.resources.v2019_08_01.models.DeploymentExportResult - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.DeploymentExportResult"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) - api_version = kwargs.pop('api_version', "2019-08-01") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2019-08-01")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[_models.DeploymentExportResult] - request = build_deployments_export_template_at_subscription_scope_request( deployment_name=deployment_name, subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.export_template_at_subscription_scope.metadata['url'], + template_url=self.export_template_at_subscription_scope.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) - deserialized = self._deserialize('DeploymentExportResult', pipeline_response) + deserialized = self._deserialize("DeploymentExportResult", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - export_template_at_subscription_scope.metadata = {'url': "/subscriptions/{subscriptionId}/providers/Microsoft.Resources/deployments/{deploymentName}/exportTemplate"} # type: ignore - + export_template_at_subscription_scope.metadata = {"url": "/subscriptions/{subscriptionId}/providers/Microsoft.Resources/deployments/{deploymentName}/exportTemplate"} # type: ignore @distributed_trace def list_at_subscription_scope( - self, - filter: Optional[str] = None, - top: Optional[int] = None, - **kwargs: Any - ) -> AsyncIterable["_models.DeploymentListResult"]: + self, filter: Optional[str] = None, top: Optional[int] = None, **kwargs: Any + ) -> AsyncIterable["_models.DeploymentExtended"]: """Get all the deployments for a subscription. :param filter: The filter to apply on the operation. For example, you can use @@ -2613,40 +3404,48 @@ def list_at_subscription_scope( value is None. :type top: int :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either DeploymentListResult or the result of - cls(response) + :return: An iterator like instance of either DeploymentExtended or the result of cls(response) :rtype: - ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.resource.resources.v2019_08_01.models.DeploymentListResult] - :raises: ~azure.core.exceptions.HttpResponseError + ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.resource.resources.v2019_08_01.models.DeploymentExtended] + :raises ~azure.core.exceptions.HttpResponseError: """ - api_version = kwargs.pop('api_version', "2019-08-01") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2019-08-01")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[_models.DeploymentListResult] - cls = kwargs.pop('cls', None) # type: ClsType["_models.DeploymentListResult"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) + def prepare_request(next_link=None): if not next_link: - + request = build_deployments_list_at_subscription_scope_request( subscription_id=self._config.subscription_id, - api_version=api_version, filter=filter, top=top, - template_url=self.list_at_subscription_scope.metadata['url'], + api_version=api_version, + template_url=self.list_at_subscription_scope.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore else: - - request = build_deployments_list_at_subscription_scope_request( - subscription_id=self._config.subscription_id, - template_url=next_link, - ) + # make call to next link with the client's api-version + _parsed_next_link = urlparse(next_link) + _next_request_params = case_insensitive_dict(parse_qs(_parsed_next_link.query)) + _next_request_params["api-version"] = self._config.api_version + request = HttpRequest("GET", urljoin(next_link, _parsed_next_link.path), params=_next_request_params) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore request.method = "GET" return request @@ -2660,10 +3459,8 @@ async def extract_data(pipeline_response): async def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) response = pipeline_response.http_response @@ -2673,42 +3470,43 @@ async def get_next(next_link=None): return pipeline_response + return AsyncItemPaged(get_next, extract_data) - return AsyncItemPaged( - get_next, extract_data - ) - list_at_subscription_scope.metadata = {'url': "/subscriptions/{subscriptionId}/providers/Microsoft.Resources/deployments/"} # type: ignore + list_at_subscription_scope.metadata = {"url": "/subscriptions/{subscriptionId}/providers/Microsoft.Resources/deployments/"} # type: ignore async def _delete_initial( # pylint: disable=inconsistent-return-statements - self, - resource_group_name: str, - deployment_name: str, - **kwargs: Any + self, resource_group_name: str, deployment_name: str, **kwargs: Any ) -> None: - cls = kwargs.pop('cls', None) # type: ClsType[None] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + 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', "2019-08-01") # type: str + api_version = kwargs.pop("api_version", _params.pop("api-version", "2019-08-01")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[None] - - request = build_deployments_delete_request_initial( + request = build_deployments_delete_request( resource_group_name=resource_group_name, deployment_name=deployment_name, subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self._delete_initial.metadata['url'], + template_url=self._delete_initial.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [202, 204]: @@ -2718,16 +3516,10 @@ 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.Resources/deployments/{deploymentName}"} # type: ignore - + _delete_initial.metadata = {"url": "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/Microsoft.Resources/deployments/{deploymentName}"} # type: ignore @distributed_trace_async - async def begin_delete( # pylint: disable=inconsistent-return-statements - self, - resource_group_name: str, - deployment_name: str, - **kwargs: Any - ) -> AsyncLROPoller[None]: + async def begin_delete(self, resource_group_name: str, deployment_name: str, **kwargs: Any) -> AsyncLROPoller[None]: """Deletes a deployment from the deployment history. A template deployment that is currently running cannot be deleted. Deleting a template @@ -2740,9 +3532,9 @@ async def begin_delete( # pylint: disable=inconsistent-return-statements asynchronous request failed, the URI in the Location header returns an error-level status code. :param resource_group_name: The name of the resource group with the deployment to delete. The - name is case insensitive. + name is case insensitive. Required. :type resource_group_name: str - :param deployment_name: The name of the deployment. + :param deployment_name: The name of the deployment. Required. :type deployment_name: str :keyword callable cls: A custom type or function that will be passed the direct response :keyword str continuation_token: A continuation token to restart a poller from a saved state. @@ -2754,88 +3546,93 @@ async def begin_delete( # pylint: disable=inconsistent-return-statements Retry-After header is present. :return: An instance of AsyncLROPoller that returns either None or the result of cls(response) :rtype: ~azure.core.polling.AsyncLROPoller[None] - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - api_version = kwargs.pop('api_version', "2019-08-01") # type: str - polling = kwargs.pop('polling', True) # type: Union[bool, AsyncPollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType[None] - lro_delay = kwargs.pop( - 'polling_interval', - self._config.polling_interval - ) - cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2019-08-01")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[None] + polling = kwargs.pop("polling", True) # type: Union[bool, AsyncPollingMethod] + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token = kwargs.pop("continuation_token", None) # type: Optional[str] if cont_token is None: - raw_result = await self._delete_initial( + raw_result = await self._delete_initial( # type: ignore resource_group_name=resource_group_name, deployment_name=deployment_name, api_version=api_version, - cls=lambda x,y,z: x, + cls=lambda x, y, z: x, + headers=_headers, + params=_params, **kwargs ) - kwargs.pop('error_map', None) + kwargs.pop("error_map", None) - def get_long_running_output(pipeline_response): + def get_long_running_output(pipeline_response): # pylint: disable=inconsistent-return-statements if cls: return cls(pipeline_response, None, {}) - - if polling is True: polling_method = AsyncARMPolling(lro_delay, **kwargs) - elif polling is False: polling_method = AsyncNoPolling() - else: polling_method = polling + if polling is True: + polling_method = cast(AsyncPollingMethod, AsyncARMPolling(lro_delay, **kwargs)) # type: AsyncPollingMethod + elif polling is False: + polling_method = cast(AsyncPollingMethod, AsyncNoPolling()) + else: + polling_method = polling if cont_token: return AsyncLROPoller.from_continuation_token( polling_method=polling_method, continuation_token=cont_token, client=self._client, - deserialization_callback=get_long_running_output + deserialization_callback=get_long_running_output, ) return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) - begin_delete.metadata = {'url': "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/Microsoft.Resources/deployments/{deploymentName}"} # type: ignore + begin_delete.metadata = {"url": "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/Microsoft.Resources/deployments/{deploymentName}"} # type: ignore @distributed_trace_async - async def check_existence( - self, - resource_group_name: str, - deployment_name: str, - **kwargs: Any - ) -> bool: + async def check_existence(self, resource_group_name: str, deployment_name: str, **kwargs: Any) -> bool: """Checks whether the deployment exists. :param resource_group_name: The name of the resource group with the deployment to check. The - name is case insensitive. + name is case insensitive. Required. :type resource_group_name: str - :param deployment_name: The name of the deployment. + :param deployment_name: The name of the deployment. Required. :type deployment_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: bool, or the result of cls(response) + :return: bool or the result of cls(response) :rtype: bool - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType[None] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + 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', "2019-08-01") # type: str + api_version = kwargs.pop("api_version", _params.pop("api-version", "2019-08-01")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[None] - request = build_deployments_check_existence_request( resource_group_name=resource_group_name, deployment_name=deployment_name, subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.check_existence.metadata['url'], + template_url=self.check_existence.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [204, 404]: @@ -2846,44 +3643,53 @@ async def check_existence( return cls(pipeline_response, None, {}) return 200 <= response.status_code <= 299 - check_existence.metadata = {'url': "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/Microsoft.Resources/deployments/{deploymentName}"} # type: ignore - + check_existence.metadata = {"url": "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/Microsoft.Resources/deployments/{deploymentName}"} # type: ignore async def _create_or_update_initial( - self, - resource_group_name: str, - deployment_name: str, - parameters: "_models.Deployment", - **kwargs: Any - ) -> "_models.DeploymentExtended": - cls = kwargs.pop('cls', None) # type: ClsType["_models.DeploymentExtended"] + self, resource_group_name: str, deployment_name: str, parameters: Union[_models.Deployment, IO], **kwargs: Any + ) -> _models.DeploymentExtended: error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) - api_version = kwargs.pop('api_version', "2019-08-01") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - _json = self._serialize.body(parameters, 'Deployment') + api_version = kwargs.pop("api_version", _params.pop("api-version", "2019-08-01")) # type: str + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.DeploymentExtended] - request = build_deployments_create_or_update_request_initial( + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(parameters, (IO, bytes)): + _content = parameters + else: + _json = self._serialize.body(parameters, "Deployment") + + request = build_deployments_create_or_update_request( resource_group_name=resource_group_name, deployment_name=deployment_name, subscription_id=self._config.subscription_id, api_version=api_version, content_type=content_type, json=_json, - template_url=self._create_or_update_initial.metadata['url'], + content=_content, + template_url=self._create_or_update_initial.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200, 201]: @@ -2891,38 +3697,42 @@ async def _create_or_update_initial( raise HttpResponseError(response=response, error_format=ARMErrorFormat) if response.status_code == 200: - deserialized = self._deserialize('DeploymentExtended', pipeline_response) + deserialized = self._deserialize("DeploymentExtended", pipeline_response) if response.status_code == 201: - deserialized = self._deserialize('DeploymentExtended', pipeline_response) + deserialized = self._deserialize("DeploymentExtended", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - _create_or_update_initial.metadata = {'url': "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/Microsoft.Resources/deployments/{deploymentName}"} # type: ignore + _create_or_update_initial.metadata = {"url": "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/Microsoft.Resources/deployments/{deploymentName}"} # type: ignore - - @distributed_trace_async + @overload async def begin_create_or_update( self, resource_group_name: str, deployment_name: str, - parameters: "_models.Deployment", + parameters: _models.Deployment, + *, + content_type: str = "application/json", **kwargs: Any - ) -> AsyncLROPoller["_models.DeploymentExtended"]: + ) -> AsyncLROPoller[_models.DeploymentExtended]: """Deploys resources to a resource group. You can provide the template and parameters directly in the request or link to JSON files. :param resource_group_name: The name of the resource group to deploy the resources to. The name - is case insensitive. The resource group must already exist. + is case insensitive. The resource group must already exist. Required. :type resource_group_name: str - :param deployment_name: The name of the deployment. + :param deployment_name: The name of the deployment. Required. :type deployment_name: str - :param parameters: Additional parameters supplied to the operation. + :param parameters: Additional parameters supplied to the operation. Required. :type parameters: ~azure.mgmt.resource.resources.v2019_08_01.models.Deployment + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str :keyword callable cls: A custom type or function that will be passed the direct response :keyword str continuation_token: A continuation token to restart a poller from a saved state. :keyword polling: By default, your polling method will be AsyncARMPolling. Pass in False for @@ -2935,115 +3745,189 @@ async def begin_create_or_update( cls(response) :rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.resource.resources.v2019_08_01.models.DeploymentExtended] - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - api_version = kwargs.pop('api_version', "2019-08-01") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] - polling = kwargs.pop('polling', True) # type: Union[bool, AsyncPollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType["_models.DeploymentExtended"] - lro_delay = kwargs.pop( - 'polling_interval', - self._config.polling_interval - ) - cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] + + @overload + async def begin_create_or_update( + self, + resource_group_name: str, + deployment_name: str, + parameters: IO, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> AsyncLROPoller[_models.DeploymentExtended]: + """Deploys resources to a resource group. + + You can provide the template and parameters directly in the request or link to JSON files. + + :param resource_group_name: The name of the resource group to deploy the resources to. The name + is case insensitive. The resource group must already exist. Required. + :type resource_group_name: str + :param deployment_name: The name of the deployment. Required. + :type deployment_name: str + :param parameters: Additional parameters supplied to the operation. Required. + :type parameters: IO + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be AsyncARMPolling. Pass in False for + this operation to not poll, or pass in your own initialized polling object for a personal + polling strategy. + :paramtype polling: bool or ~azure.core.polling.AsyncPollingMethod + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of AsyncLROPoller that returns either DeploymentExtended or the result of + cls(response) + :rtype: + ~azure.core.polling.AsyncLROPoller[~azure.mgmt.resource.resources.v2019_08_01.models.DeploymentExtended] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace_async + async def begin_create_or_update( + self, resource_group_name: str, deployment_name: str, parameters: Union[_models.Deployment, IO], **kwargs: Any + ) -> AsyncLROPoller[_models.DeploymentExtended]: + """Deploys resources to a resource group. + + You can provide the template and parameters directly in the request or link to JSON files. + + :param resource_group_name: The name of the resource group to deploy the resources to. The name + is case insensitive. The resource group must already exist. Required. + :type resource_group_name: str + :param deployment_name: The name of the deployment. Required. + :type deployment_name: str + :param parameters: Additional parameters supplied to the operation. Is either a model type or a + IO type. Required. + :type parameters: ~azure.mgmt.resource.resources.v2019_08_01.models.Deployment or IO + :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. + Default value is None. + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be AsyncARMPolling. Pass in False for + this operation to not poll, or pass in your own initialized polling object for a personal + polling strategy. + :paramtype polling: bool or ~azure.core.polling.AsyncPollingMethod + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of AsyncLROPoller that returns either DeploymentExtended or the result of + cls(response) + :rtype: + ~azure.core.polling.AsyncLROPoller[~azure.mgmt.resource.resources.v2019_08_01.models.DeploymentExtended] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _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", "2019-08-01")) # type: str + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.DeploymentExtended] + polling = kwargs.pop("polling", True) # type: Union[bool, AsyncPollingMethod] + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token = kwargs.pop("continuation_token", None) # type: Optional[str] if cont_token is None: - raw_result = await self._create_or_update_initial( + raw_result = await self._create_or_update_initial( # type: ignore resource_group_name=resource_group_name, deployment_name=deployment_name, parameters=parameters, api_version=api_version, content_type=content_type, - cls=lambda x,y,z: x, + cls=lambda x, y, z: x, + headers=_headers, + params=_params, **kwargs ) - kwargs.pop('error_map', None) + kwargs.pop("error_map", None) def get_long_running_output(pipeline_response): - response = pipeline_response.http_response - deserialized = self._deserialize('DeploymentExtended', pipeline_response) + deserialized = self._deserialize("DeploymentExtended", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - - if polling is True: polling_method = AsyncARMPolling(lro_delay, **kwargs) - elif polling is False: polling_method = AsyncNoPolling() - else: polling_method = polling + if polling is True: + polling_method = cast(AsyncPollingMethod, AsyncARMPolling(lro_delay, **kwargs)) # type: AsyncPollingMethod + elif polling is False: + polling_method = cast(AsyncPollingMethod, AsyncNoPolling()) + else: + polling_method = polling if cont_token: return AsyncLROPoller.from_continuation_token( polling_method=polling_method, continuation_token=cont_token, client=self._client, - deserialization_callback=get_long_running_output + deserialization_callback=get_long_running_output, ) return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) - begin_create_or_update.metadata = {'url': "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/Microsoft.Resources/deployments/{deploymentName}"} # type: ignore + begin_create_or_update.metadata = {"url": "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/Microsoft.Resources/deployments/{deploymentName}"} # type: ignore @distributed_trace_async - async def get( - self, - resource_group_name: str, - deployment_name: str, - **kwargs: Any - ) -> "_models.DeploymentExtended": + async def get(self, resource_group_name: str, deployment_name: str, **kwargs: Any) -> _models.DeploymentExtended: """Gets a deployment. :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. :type resource_group_name: str - :param deployment_name: The name of the deployment. + :param deployment_name: The name of the deployment. Required. :type deployment_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: DeploymentExtended, or the result of cls(response) + :return: DeploymentExtended or the result of cls(response) :rtype: ~azure.mgmt.resource.resources.v2019_08_01.models.DeploymentExtended - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.DeploymentExtended"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + 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', "2019-08-01") # type: str + api_version = kwargs.pop("api_version", _params.pop("api-version", "2019-08-01")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[_models.DeploymentExtended] - request = build_deployments_get_request( resource_group_name=resource_group_name, deployment_name=deployment_name, subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.get.metadata['url'], + template_url=self.get.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) - deserialized = self._deserialize('DeploymentExtended', pipeline_response) + deserialized = self._deserialize("DeploymentExtended", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - get.metadata = {'url': "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/Microsoft.Resources/deployments/{deploymentName}"} # type: ignore - + get.metadata = {"url": "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/Microsoft.Resources/deployments/{deploymentName}"} # type: ignore @distributed_trace_async async def cancel( # pylint: disable=inconsistent-return-statements - self, - resource_group_name: str, - deployment_name: str, - **kwargs: Any + self, resource_group_name: str, deployment_name: str, **kwargs: Any ) -> None: """Cancels a currently running template deployment. @@ -3053,38 +3937,45 @@ async def cancel( # pylint: disable=inconsistent-return-statements partially deployed. :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. :type resource_group_name: str - :param deployment_name: The name of the deployment. + :param deployment_name: The name of the deployment. Required. :type deployment_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: None, or the result of cls(response) + :return: None or the result of cls(response) :rtype: None - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType[None] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) - api_version = kwargs.pop('api_version', "2019-08-01") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2019-08-01")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[None] - request = build_deployments_cancel_request( resource_group_name=resource_group_name, deployment_name=deployment_name, subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.cancel.metadata['url'], + template_url=self.cancel.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [204]: @@ -3094,42 +3985,110 @@ async def cancel( # pylint: disable=inconsistent-return-statements if cls: return cls(pipeline_response, None, {}) - cancel.metadata = {'url': "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/Microsoft.Resources/deployments/{deploymentName}/cancel"} # type: ignore - + cancel.metadata = {"url": "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/Microsoft.Resources/deployments/{deploymentName}/cancel"} # type: ignore - @distributed_trace_async + @overload async def validate( self, resource_group_name: str, deployment_name: str, - parameters: "_models.Deployment", + parameters: _models.Deployment, + *, + content_type: str = "application/json", **kwargs: Any - ) -> "_models.DeploymentValidateResult": + ) -> _models.DeploymentValidateResult: """Validates whether the specified template is syntactically correct and will be accepted by Azure Resource Manager.. :param resource_group_name: The name of the resource group the template will be deployed to. - The name is case insensitive. + The name is case insensitive. Required. :type resource_group_name: str - :param deployment_name: The name of the deployment. + :param deployment_name: The name of the deployment. Required. :type deployment_name: str - :param parameters: Parameters to validate. + :param parameters: Parameters to validate. Required. :type parameters: ~azure.mgmt.resource.resources.v2019_08_01.models.Deployment + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: DeploymentValidateResult or the result of cls(response) + :rtype: ~azure.mgmt.resource.resources.v2019_08_01.models.DeploymentValidateResult + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + async def validate( + self, + resource_group_name: str, + deployment_name: str, + parameters: IO, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.DeploymentValidateResult: + """Validates whether the specified template is syntactically correct and will be accepted by Azure + Resource Manager.. + + :param resource_group_name: The name of the resource group the template will be deployed to. + The name is case insensitive. Required. + :type resource_group_name: str + :param deployment_name: The name of the deployment. Required. + :type deployment_name: str + :param parameters: Parameters to validate. Required. + :type parameters: IO + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: DeploymentValidateResult, or the result of cls(response) + :return: DeploymentValidateResult or the result of cls(response) :rtype: ~azure.mgmt.resource.resources.v2019_08_01.models.DeploymentValidateResult - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace_async + async def validate( + self, resource_group_name: str, deployment_name: str, parameters: Union[_models.Deployment, IO], **kwargs: Any + ) -> _models.DeploymentValidateResult: + """Validates whether the specified template is syntactically correct and will be accepted by Azure + Resource Manager.. + + :param resource_group_name: The name of the resource group the template will be deployed to. + The name is case insensitive. Required. + :type resource_group_name: str + :param deployment_name: The name of the deployment. Required. + :type deployment_name: str + :param parameters: Parameters to validate. Is either a model type or a IO type. Required. + :type parameters: ~azure.mgmt.resource.resources.v2019_08_01.models.Deployment or IO + :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. + Default value is None. + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: DeploymentValidateResult or the result of cls(response) + :rtype: ~azure.mgmt.resource.resources.v2019_08_01.models.DeploymentValidateResult + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.DeploymentValidateResult"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', "2019-08-01") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + api_version = kwargs.pop("api_version", _params.pop("api-version", "2019-08-01")) # type: str + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.DeploymentValidateResult] - _json = self._serialize.body(parameters, 'Deployment') + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(parameters, (IO, bytes)): + _content = parameters + else: + _json = self._serialize.body(parameters, "Deployment") request = build_deployments_validate_request( resource_group_name=resource_group_name, @@ -3138,16 +4097,18 @@ async def validate( api_version=api_version, content_type=content_type, json=_json, - template_url=self.validate.metadata['url'], + content=_content, + template_url=self.validate.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200, 400]: @@ -3155,54 +4116,67 @@ async def validate( raise HttpResponseError(response=response, error_format=ARMErrorFormat) if response.status_code == 200: - deserialized = self._deserialize('DeploymentValidateResult', pipeline_response) + deserialized = self._deserialize("DeploymentValidateResult", pipeline_response) if response.status_code == 400: - deserialized = self._deserialize('DeploymentValidateResult', pipeline_response) + deserialized = self._deserialize("DeploymentValidateResult", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - validate.metadata = {'url': "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/Microsoft.Resources/deployments/{deploymentName}/validate"} # type: ignore - + validate.metadata = {"url": "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/Microsoft.Resources/deployments/{deploymentName}/validate"} # type: ignore async def _what_if_initial( self, resource_group_name: str, deployment_name: str, - parameters: "_models.DeploymentWhatIf", + parameters: Union[_models.DeploymentWhatIf, IO], **kwargs: Any - ) -> Optional["_models.WhatIfOperationResult"]: - cls = kwargs.pop('cls', None) # type: ClsType[Optional["_models.WhatIfOperationResult"]] + ) -> Optional[_models.WhatIfOperationResult]: error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) - api_version = kwargs.pop('api_version', "2019-08-01") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - _json = self._serialize.body(parameters, 'DeploymentWhatIf') + api_version = kwargs.pop("api_version", _params.pop("api-version", "2019-08-01")) # type: str + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[Optional[_models.WhatIfOperationResult]] - request = build_deployments_what_if_request_initial( + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(parameters, (IO, bytes)): + _content = parameters + else: + _json = self._serialize.body(parameters, "DeploymentWhatIf") + + request = build_deployments_what_if_request( resource_group_name=resource_group_name, deployment_name=deployment_name, subscription_id=self._config.subscription_id, api_version=api_version, content_type=content_type, json=_json, - template_url=self._what_if_initial.metadata['url'], + content=_content, + template_url=self._what_if_initial.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200, 202]: @@ -3212,39 +4186,116 @@ async def _what_if_initial( deserialized = None response_headers = {} if response.status_code == 200: - deserialized = self._deserialize('WhatIfOperationResult', pipeline_response) + deserialized = self._deserialize("WhatIfOperationResult", pipeline_response) if response.status_code == 202: - response_headers['Location']=self._deserialize('str', response.headers.get('Location')) - response_headers['Retry-After']=self._deserialize('str', response.headers.get('Retry-After')) - + response_headers["Location"] = self._deserialize("str", response.headers.get("Location")) + response_headers["Retry-After"] = self._deserialize("str", response.headers.get("Retry-After")) if cls: return cls(pipeline_response, deserialized, response_headers) return deserialized - _what_if_initial.metadata = {'url': "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/Microsoft.Resources/deployments/{deploymentName}/whatIf"} # type: ignore + _what_if_initial.metadata = {"url": "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/Microsoft.Resources/deployments/{deploymentName}/whatIf"} # type: ignore + @overload + async def begin_what_if( + self, + resource_group_name: str, + deployment_name: str, + parameters: _models.DeploymentWhatIf, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> AsyncLROPoller[_models.WhatIfOperationResult]: + """Returns changes that will be made by the deployment if executed at the scope of the resource + group. + + :param resource_group_name: The name of the resource group the template will be deployed to. + The name is case insensitive. Required. + :type resource_group_name: str + :param deployment_name: The name of the deployment. Required. + :type deployment_name: str + :param parameters: Parameters to validate. Required. + :type parameters: ~azure.mgmt.resource.resources.v2019_08_01.models.DeploymentWhatIf + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be AsyncARMPolling. Pass in False for + this operation to not poll, or pass in your own initialized polling object for a personal + polling strategy. + :paramtype polling: bool or ~azure.core.polling.AsyncPollingMethod + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of AsyncLROPoller that returns either WhatIfOperationResult or the result + of cls(response) + :rtype: + ~azure.core.polling.AsyncLROPoller[~azure.mgmt.resource.resources.v2019_08_01.models.WhatIfOperationResult] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + async def begin_what_if( + self, + resource_group_name: str, + deployment_name: str, + parameters: IO, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> AsyncLROPoller[_models.WhatIfOperationResult]: + """Returns changes that will be made by the deployment if executed at the scope of the resource + group. + + :param resource_group_name: The name of the resource group the template will be deployed to. + The name is case insensitive. Required. + :type resource_group_name: str + :param deployment_name: The name of the deployment. Required. + :type deployment_name: str + :param parameters: Parameters to validate. Required. + :type parameters: IO + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be AsyncARMPolling. Pass in False for + this operation to not poll, or pass in your own initialized polling object for a personal + polling strategy. + :paramtype polling: bool or ~azure.core.polling.AsyncPollingMethod + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of AsyncLROPoller that returns either WhatIfOperationResult or the result + of cls(response) + :rtype: + ~azure.core.polling.AsyncLROPoller[~azure.mgmt.resource.resources.v2019_08_01.models.WhatIfOperationResult] + :raises ~azure.core.exceptions.HttpResponseError: + """ @distributed_trace_async async def begin_what_if( self, resource_group_name: str, deployment_name: str, - parameters: "_models.DeploymentWhatIf", + parameters: Union[_models.DeploymentWhatIf, IO], **kwargs: Any - ) -> AsyncLROPoller["_models.WhatIfOperationResult"]: + ) -> AsyncLROPoller[_models.WhatIfOperationResult]: """Returns changes that will be made by the deployment if executed at the scope of the resource group. :param resource_group_name: The name of the resource group the template will be deployed to. - The name is case insensitive. + The name is case insensitive. Required. :type resource_group_name: str - :param deployment_name: The name of the deployment. + :param deployment_name: The name of the deployment. Required. :type deployment_name: str - :param parameters: Parameters to validate. - :type parameters: ~azure.mgmt.resource.resources.v2019_08_01.models.DeploymentWhatIf + :param parameters: Parameters to validate. Is either a model type or a IO type. Required. + :type parameters: ~azure.mgmt.resource.resources.v2019_08_01.models.DeploymentWhatIf or IO + :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. + Default value is None. + :paramtype content_type: str :keyword callable cls: A custom type or function that will be passed the direct response :keyword str continuation_token: A continuation token to restart a poller from a saved state. :keyword polling: By default, your polling method will be AsyncARMPolling. Pass in False for @@ -3257,121 +4308,125 @@ async def begin_what_if( of cls(response) :rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.resource.resources.v2019_08_01.models.WhatIfOperationResult] - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - api_version = kwargs.pop('api_version', "2019-08-01") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] - polling = kwargs.pop('polling', True) # type: Union[bool, AsyncPollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType["_models.WhatIfOperationResult"] - lro_delay = kwargs.pop( - 'polling_interval', - self._config.polling_interval - ) - cont_token = kwargs.pop('continuation_token', None) # type: Optional[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", "2019-08-01")) # type: str + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.WhatIfOperationResult] + polling = kwargs.pop("polling", True) # type: Union[bool, AsyncPollingMethod] + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token = kwargs.pop("continuation_token", None) # type: Optional[str] if cont_token is None: - raw_result = await self._what_if_initial( + raw_result = await self._what_if_initial( # type: ignore resource_group_name=resource_group_name, deployment_name=deployment_name, parameters=parameters, api_version=api_version, content_type=content_type, - cls=lambda x,y,z: x, + cls=lambda x, y, z: x, + headers=_headers, + params=_params, **kwargs ) - kwargs.pop('error_map', None) + kwargs.pop("error_map", None) def get_long_running_output(pipeline_response): - response = pipeline_response.http_response - deserialized = self._deserialize('WhatIfOperationResult', pipeline_response) + deserialized = self._deserialize("WhatIfOperationResult", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - - if polling is True: polling_method = AsyncARMPolling(lro_delay, lro_options={'final-state-via': 'location'}, **kwargs) - elif polling is False: polling_method = AsyncNoPolling() - else: polling_method = polling + if polling is True: + polling_method = cast( + AsyncPollingMethod, AsyncARMPolling(lro_delay, lro_options={"final-state-via": "location"}, **kwargs) + ) # type: AsyncPollingMethod + elif polling is False: + polling_method = cast(AsyncPollingMethod, AsyncNoPolling()) + else: + polling_method = polling if cont_token: return AsyncLROPoller.from_continuation_token( polling_method=polling_method, continuation_token=cont_token, client=self._client, - deserialization_callback=get_long_running_output + deserialization_callback=get_long_running_output, ) return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) - begin_what_if.metadata = {'url': "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/Microsoft.Resources/deployments/{deploymentName}/whatIf"} # type: ignore + begin_what_if.metadata = {"url": "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/Microsoft.Resources/deployments/{deploymentName}/whatIf"} # type: ignore @distributed_trace_async async def export_template( - self, - resource_group_name: str, - deployment_name: str, - **kwargs: Any - ) -> "_models.DeploymentExportResult": + self, resource_group_name: str, deployment_name: str, **kwargs: Any + ) -> _models.DeploymentExportResult: """Exports the template used for specified deployment. :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. :type resource_group_name: str - :param deployment_name: The name of the deployment. + :param deployment_name: The name of the deployment. Required. :type deployment_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: DeploymentExportResult, or the result of cls(response) + :return: DeploymentExportResult or the result of cls(response) :rtype: ~azure.mgmt.resource.resources.v2019_08_01.models.DeploymentExportResult - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.DeploymentExportResult"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) - api_version = kwargs.pop('api_version', "2019-08-01") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2019-08-01")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[_models.DeploymentExportResult] - request = build_deployments_export_template_request( resource_group_name=resource_group_name, deployment_name=deployment_name, subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.export_template.metadata['url'], + template_url=self.export_template.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) - deserialized = self._deserialize('DeploymentExportResult', pipeline_response) + deserialized = self._deserialize("DeploymentExportResult", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - export_template.metadata = {'url': "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/Microsoft.Resources/deployments/{deploymentName}/exportTemplate"} # type: ignore - + export_template.metadata = {"url": "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/Microsoft.Resources/deployments/{deploymentName}/exportTemplate"} # type: ignore @distributed_trace def list_by_resource_group( - self, - resource_group_name: str, - filter: Optional[str] = None, - top: Optional[int] = None, - **kwargs: Any - ) -> AsyncIterable["_models.DeploymentListResult"]: + self, resource_group_name: str, filter: Optional[str] = None, top: Optional[int] = None, **kwargs: Any + ) -> AsyncIterable["_models.DeploymentExtended"]: """Get all the deployments for a resource group. :param resource_group_name: The name of the resource group with the deployments to get. The - name is case insensitive. + name is case insensitive. Required. :type resource_group_name: str :param filter: The filter to apply on the operation. For example, you can use $filter=provisioningState eq '{state}'. Default value is None. @@ -3380,42 +4435,49 @@ def list_by_resource_group( value is None. :type top: int :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either DeploymentListResult or the result of - cls(response) + :return: An iterator like instance of either DeploymentExtended or the result of cls(response) :rtype: - ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.resource.resources.v2019_08_01.models.DeploymentListResult] - :raises: ~azure.core.exceptions.HttpResponseError + ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.resource.resources.v2019_08_01.models.DeploymentExtended] + :raises ~azure.core.exceptions.HttpResponseError: """ - api_version = kwargs.pop('api_version', "2019-08-01") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2019-08-01")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[_models.DeploymentListResult] - cls = kwargs.pop('cls', None) # type: ClsType["_models.DeploymentListResult"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) + def prepare_request(next_link=None): if not next_link: - + request = build_deployments_list_by_resource_group_request( resource_group_name=resource_group_name, subscription_id=self._config.subscription_id, - api_version=api_version, filter=filter, top=top, - template_url=self.list_by_resource_group.metadata['url'], + 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.url = self._client.format_url(request.url) # type: ignore else: - - request = build_deployments_list_by_resource_group_request( - resource_group_name=resource_group_name, - subscription_id=self._config.subscription_id, - template_url=next_link, - ) + # make call to next link with the client's api-version + _parsed_next_link = urlparse(next_link) + _next_request_params = case_insensitive_dict(parse_qs(_parsed_next_link.query)) + _next_request_params["api-version"] = self._config.api_version + request = HttpRequest("GET", urljoin(next_link, _parsed_next_link.path), params=_next_request_params) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore request.method = "GET" return request @@ -3429,10 +4491,8 @@ async def extract_data(pipeline_response): async def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) response = pipeline_response.http_response @@ -3442,204 +4502,204 @@ async def get_next(next_link=None): return pipeline_response + return AsyncItemPaged(get_next, extract_data) - return AsyncItemPaged( - get_next, extract_data - ) - list_by_resource_group.metadata = {'url': "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/Microsoft.Resources/deployments/"} # type: ignore + list_by_resource_group.metadata = {"url": "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/Microsoft.Resources/deployments/"} # type: ignore @distributed_trace_async - async def calculate_template_hash( - self, - template: Any, - **kwargs: Any - ) -> "_models.TemplateHashResult": + async def calculate_template_hash(self, template: JSON, **kwargs: Any) -> _models.TemplateHashResult: """Calculate the hash of the given template. - :param template: The template provided to calculate hash. - :type template: any + :param template: The template provided to calculate hash. Required. + :type template: JSON :keyword callable cls: A custom type or function that will be passed the direct response - :return: TemplateHashResult, or the result of cls(response) + :return: TemplateHashResult or the result of cls(response) :rtype: ~azure.mgmt.resource.resources.v2019_08_01.models.TemplateHashResult - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.TemplateHashResult"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) - api_version = kwargs.pop('api_version', "2019-08-01") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - _json = self._serialize.body(template, 'object') + api_version = kwargs.pop("api_version", _params.pop("api-version", "2019-08-01")) # type: str + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", "application/json")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[_models.TemplateHashResult] + + _json = self._serialize.body(template, "object") request = build_deployments_calculate_template_hash_request( api_version=api_version, content_type=content_type, json=_json, - template_url=self.calculate_template_hash.metadata['url'], + template_url=self.calculate_template_hash.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) - deserialized = self._deserialize('TemplateHashResult', pipeline_response) + deserialized = self._deserialize("TemplateHashResult", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - calculate_template_hash.metadata = {'url': "/providers/Microsoft.Resources/calculateTemplateHash"} # type: ignore + calculate_template_hash.metadata = {"url": "/providers/Microsoft.Resources/calculateTemplateHash"} # type: ignore -class ProvidersOperations: - """ProvidersOperations async operations. - You should not instantiate this class directly. Instead, you should create a Client instance that - instantiates it for you and attaches it as an attribute. +class ProvidersOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. - :ivar models: Alias to model classes used in this operation group. - :type models: ~azure.mgmt.resource.resources.v2019_08_01.models - :param client: Client for service requests. - :param config: Configuration of service client. - :param serializer: An object model serializer. - :param deserializer: An object model deserializer. + Instead, you should access the following operations through + :class:`~azure.mgmt.resource.resources.v2019_08_01.aio.ResourceManagementClient`'s + :attr:`providers` attribute. """ models = _models - def __init__(self, client, config, serializer, deserializer) -> None: - self._client = client - self._serialize = serializer - self._deserialize = deserializer - self._config = config + def __init__(self, *args, **kwargs) -> None: + input_args = list(args) + self._client = input_args.pop(0) if input_args else kwargs.pop("client") + self._config = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") @distributed_trace_async - async def unregister( - self, - resource_provider_namespace: str, - **kwargs: Any - ) -> "_models.Provider": + async def unregister(self, resource_provider_namespace: str, **kwargs: Any) -> _models.Provider: """Unregisters a subscription from a resource provider. :param resource_provider_namespace: The namespace of the resource provider to unregister. + Required. :type resource_provider_namespace: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: Provider, or the result of cls(response) + :return: Provider or the result of cls(response) :rtype: ~azure.mgmt.resource.resources.v2019_08_01.models.Provider - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.Provider"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + 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', "2019-08-01") # type: str + api_version = kwargs.pop("api_version", _params.pop("api-version", "2019-08-01")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[_models.Provider] - request = build_providers_unregister_request( resource_provider_namespace=resource_provider_namespace, subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.unregister.metadata['url'], + template_url=self.unregister.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) - deserialized = self._deserialize('Provider', pipeline_response) + deserialized = self._deserialize("Provider", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - unregister.metadata = {'url': "/subscriptions/{subscriptionId}/providers/{resourceProviderNamespace}/unregister"} # type: ignore - + unregister.metadata = {"url": "/subscriptions/{subscriptionId}/providers/{resourceProviderNamespace}/unregister"} # type: ignore @distributed_trace_async - async def register( - self, - resource_provider_namespace: str, - **kwargs: Any - ) -> "_models.Provider": + async def register(self, resource_provider_namespace: str, **kwargs: Any) -> _models.Provider: """Registers a subscription with a resource provider. :param resource_provider_namespace: The namespace of the resource provider to register. + Required. :type resource_provider_namespace: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: Provider, or the result of cls(response) + :return: Provider or the result of cls(response) :rtype: ~azure.mgmt.resource.resources.v2019_08_01.models.Provider - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.Provider"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + 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', "2019-08-01") # type: str + api_version = kwargs.pop("api_version", _params.pop("api-version", "2019-08-01")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[_models.Provider] - request = build_providers_register_request( resource_provider_namespace=resource_provider_namespace, subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.register.metadata['url'], + template_url=self.register.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) - deserialized = self._deserialize('Provider', pipeline_response) + deserialized = self._deserialize("Provider", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - register.metadata = {'url': "/subscriptions/{subscriptionId}/providers/{resourceProviderNamespace}/register"} # type: ignore - + register.metadata = {"url": "/subscriptions/{subscriptionId}/providers/{resourceProviderNamespace}/register"} # type: ignore @distributed_trace def list( - self, - top: Optional[int] = None, - expand: Optional[str] = None, - **kwargs: Any - ) -> AsyncIterable["_models.ProviderListResult"]: + self, top: Optional[int] = None, expand: Optional[str] = None, **kwargs: Any + ) -> AsyncIterable["_models.Provider"]: """Gets all resource providers for a subscription. :param top: The number of results to return. If null is passed returns all deployments. Default @@ -3650,39 +4710,48 @@ def list( response, use $expand=resourceTypes/aliases. Default value is None. :type expand: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either ProviderListResult or the result of cls(response) + :return: An iterator like instance of either Provider or the result of cls(response) :rtype: - ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.resource.resources.v2019_08_01.models.ProviderListResult] - :raises: ~azure.core.exceptions.HttpResponseError + ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.resource.resources.v2019_08_01.models.Provider] + :raises ~azure.core.exceptions.HttpResponseError: """ - api_version = kwargs.pop('api_version', "2019-08-01") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2019-08-01")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[_models.ProviderListResult] - cls = kwargs.pop('cls', None) # type: ClsType["_models.ProviderListResult"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) + def prepare_request(next_link=None): if not next_link: - + request = build_providers_list_request( subscription_id=self._config.subscription_id, - api_version=api_version, top=top, expand=expand, - template_url=self.list.metadata['url'], + 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.url = self._client.format_url(request.url) # type: ignore else: - - request = build_providers_list_request( - subscription_id=self._config.subscription_id, - template_url=next_link, - ) + # make call to next link with the client's api-version + _parsed_next_link = urlparse(next_link) + _next_request_params = case_insensitive_dict(parse_qs(_parsed_next_link.query)) + _next_request_params["api-version"] = self._config.api_version + request = HttpRequest("GET", urljoin(next_link, _parsed_next_link.path), params=_next_request_params) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore request.method = "GET" return request @@ -3696,10 +4765,8 @@ async def extract_data(pipeline_response): async def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) response = pipeline_response.http_response @@ -3709,19 +4776,14 @@ async def get_next(next_link=None): return pipeline_response + return AsyncItemPaged(get_next, extract_data) - return AsyncItemPaged( - get_next, extract_data - ) - list.metadata = {'url': "/subscriptions/{subscriptionId}/providers"} # type: ignore + list.metadata = {"url": "/subscriptions/{subscriptionId}/providers"} # type: ignore @distributed_trace def list_at_tenant_scope( - self, - top: Optional[int] = None, - expand: Optional[str] = None, - **kwargs: Any - ) -> AsyncIterable["_models.ProviderListResult"]: + self, top: Optional[int] = None, expand: Optional[str] = None, **kwargs: Any + ) -> AsyncIterable["_models.Provider"]: """Gets all resource providers for the tenant. :param top: The number of results to return. If null is passed returns all providers. Default @@ -3732,37 +4794,47 @@ def list_at_tenant_scope( response, use $expand=resourceTypes/aliases. Default value is None. :type expand: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either ProviderListResult or the result of cls(response) + :return: An iterator like instance of either Provider or the result of cls(response) :rtype: - ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.resource.resources.v2019_08_01.models.ProviderListResult] - :raises: ~azure.core.exceptions.HttpResponseError + ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.resource.resources.v2019_08_01.models.Provider] + :raises ~azure.core.exceptions.HttpResponseError: """ - api_version = kwargs.pop('api_version', "2019-08-01") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2019-08-01")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[_models.ProviderListResult] - cls = kwargs.pop('cls', None) # type: ClsType["_models.ProviderListResult"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) + def prepare_request(next_link=None): if not next_link: - + request = build_providers_list_at_tenant_scope_request( - api_version=api_version, top=top, expand=expand, - template_url=self.list_at_tenant_scope.metadata['url'], + api_version=api_version, + template_url=self.list_at_tenant_scope.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore else: - - request = build_providers_list_at_tenant_scope_request( - template_url=next_link, - ) + # make call to next link with the client's api-version + _parsed_next_link = urlparse(next_link) + _next_request_params = case_insensitive_dict(parse_qs(_parsed_next_link.query)) + _next_request_params["api-version"] = self._config.api_version + request = HttpRequest("GET", urljoin(next_link, _parsed_next_link.path), params=_next_request_params) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore request.method = "GET" return request @@ -3776,10 +4848,8 @@ async def extract_data(pipeline_response): async def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) response = pipeline_response.http_response @@ -3789,149 +4859,150 @@ async def get_next(next_link=None): return pipeline_response + return AsyncItemPaged(get_next, extract_data) - return AsyncItemPaged( - get_next, extract_data - ) - list_at_tenant_scope.metadata = {'url': "/providers"} # type: ignore + list_at_tenant_scope.metadata = {"url": "/providers"} # type: ignore @distributed_trace_async async def get( - self, - resource_provider_namespace: str, - expand: Optional[str] = None, - **kwargs: Any - ) -> "_models.Provider": + self, resource_provider_namespace: str, expand: Optional[str] = None, **kwargs: Any + ) -> _models.Provider: """Gets the specified resource provider. - :param resource_provider_namespace: The namespace of the resource provider. + :param resource_provider_namespace: The namespace of the resource provider. Required. :type resource_provider_namespace: str :param expand: The $expand query parameter. For example, to include property aliases in response, use $expand=resourceTypes/aliases. Default value is None. :type expand: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: Provider, or the result of cls(response) + :return: Provider or the result of cls(response) :rtype: ~azure.mgmt.resource.resources.v2019_08_01.models.Provider - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.Provider"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + 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', "2019-08-01") # type: str + api_version = kwargs.pop("api_version", _params.pop("api-version", "2019-08-01")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[_models.Provider] - request = build_providers_get_request( resource_provider_namespace=resource_provider_namespace, subscription_id=self._config.subscription_id, - api_version=api_version, expand=expand, - template_url=self.get.metadata['url'], + api_version=api_version, + template_url=self.get.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) - deserialized = self._deserialize('Provider', pipeline_response) + deserialized = self._deserialize("Provider", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - get.metadata = {'url': "/subscriptions/{subscriptionId}/providers/{resourceProviderNamespace}"} # type: ignore - + get.metadata = {"url": "/subscriptions/{subscriptionId}/providers/{resourceProviderNamespace}"} # type: ignore @distributed_trace_async async def get_at_tenant_scope( - self, - resource_provider_namespace: str, - expand: Optional[str] = None, - **kwargs: Any - ) -> "_models.Provider": + self, resource_provider_namespace: str, expand: Optional[str] = None, **kwargs: Any + ) -> _models.Provider: """Gets the specified resource provider at the tenant level. - :param resource_provider_namespace: The namespace of the resource provider. + :param resource_provider_namespace: The namespace of the resource provider. Required. :type resource_provider_namespace: str :param expand: The $expand query parameter. For example, to include property aliases in response, use $expand=resourceTypes/aliases. Default value is None. :type expand: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: Provider, or the result of cls(response) + :return: Provider or the result of cls(response) :rtype: ~azure.mgmt.resource.resources.v2019_08_01.models.Provider - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.Provider"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) - api_version = kwargs.pop('api_version', "2019-08-01") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2019-08-01")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[_models.Provider] - request = build_providers_get_at_tenant_scope_request( resource_provider_namespace=resource_provider_namespace, - api_version=api_version, expand=expand, - template_url=self.get_at_tenant_scope.metadata['url'], + api_version=api_version, + template_url=self.get_at_tenant_scope.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) - deserialized = self._deserialize('Provider', pipeline_response) + deserialized = self._deserialize("Provider", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - get_at_tenant_scope.metadata = {'url': "/providers/{resourceProviderNamespace}"} # type: ignore + get_at_tenant_scope.metadata = {"url": "/providers/{resourceProviderNamespace}"} # type: ignore -class ResourcesOperations: # pylint: disable=too-many-public-methods - """ResourcesOperations async operations. - You should not instantiate this class directly. Instead, you should create a Client instance that - instantiates it for you and attaches it as an attribute. +class ResourcesOperations: # pylint: disable=too-many-public-methods + """ + .. warning:: + **DO NOT** instantiate this class directly. - :ivar models: Alias to model classes used in this operation group. - :type models: ~azure.mgmt.resource.resources.v2019_08_01.models - :param client: Client for service requests. - :param config: Configuration of service client. - :param serializer: An object model serializer. - :param deserializer: An object model deserializer. + Instead, you should access the following operations through + :class:`~azure.mgmt.resource.resources.v2019_08_01.aio.ResourceManagementClient`'s + :attr:`resources` attribute. """ models = _models - def __init__(self, client, config, serializer, deserializer) -> None: - self._client = client - self._serialize = serializer - self._deserialize = deserializer - self._config = config + def __init__(self, *args, **kwargs) -> None: + input_args = list(args) + self._client = input_args.pop(0) if input_args else kwargs.pop("client") + self._config = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") @distributed_trace def list_by_resource_group( @@ -3941,10 +5012,10 @@ def list_by_resource_group( expand: Optional[str] = None, top: Optional[int] = None, **kwargs: Any - ) -> AsyncIterable["_models.ResourceListResult"]: + ) -> AsyncIterable["_models.GenericResourceExpanded"]: """Get all the resources for a resource group. - :param resource_group_name: The resource group with the resources to get. + :param resource_group_name: The resource group with the resources to get. Required. :type resource_group_name: str :param filter: The filter to apply on the operation.:code:`
`:code:`
`The properties you can use for eq (equals) or ne (not equals) are: location, resourceType, name, resourceGroup, @@ -3970,42 +5041,51 @@ def list_by_resource_group( value is None. :type top: int :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either ResourceListResult or the result of cls(response) + :return: An iterator like instance of either GenericResourceExpanded or the result of + cls(response) :rtype: - ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.resource.resources.v2019_08_01.models.ResourceListResult] - :raises: ~azure.core.exceptions.HttpResponseError + ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.resource.resources.v2019_08_01.models.GenericResourceExpanded] + :raises ~azure.core.exceptions.HttpResponseError: """ - api_version = kwargs.pop('api_version', "2019-08-01") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2019-08-01")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[_models.ResourceListResult] - cls = kwargs.pop('cls', None) # type: ClsType["_models.ResourceListResult"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) + def prepare_request(next_link=None): if not next_link: - + request = build_resources_list_by_resource_group_request( resource_group_name=resource_group_name, subscription_id=self._config.subscription_id, - api_version=api_version, filter=filter, expand=expand, top=top, - template_url=self.list_by_resource_group.metadata['url'], + 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.url = self._client.format_url(request.url) # type: ignore else: - - request = build_resources_list_by_resource_group_request( - resource_group_name=resource_group_name, - subscription_id=self._config.subscription_id, - template_url=next_link, - ) + # make call to next link with the client's api-version + _parsed_next_link = urlparse(next_link) + _next_request_params = case_insensitive_dict(parse_qs(_parsed_next_link.query)) + _next_request_params["api-version"] = self._config.api_version + request = HttpRequest("GET", urljoin(next_link, _parsed_next_link.path), params=_next_request_params) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore request.method = "GET" return request @@ -4019,10 +5099,8 @@ async def extract_data(pipeline_response): async def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) response = pipeline_response.http_response @@ -4032,63 +5110,137 @@ async def get_next(next_link=None): return pipeline_response + return AsyncItemPaged(get_next, extract_data) - return AsyncItemPaged( - get_next, extract_data - ) - list_by_resource_group.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/resources"} # type: ignore + list_by_resource_group.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/resources"} # type: ignore async def _move_resources_initial( # pylint: disable=inconsistent-return-statements - self, - source_resource_group_name: str, - parameters: "_models.ResourcesMoveInfo", - **kwargs: Any + self, source_resource_group_name: str, parameters: Union[_models.ResourcesMoveInfo, IO], **kwargs: Any ) -> None: - cls = kwargs.pop('cls', None) # type: ClsType[None] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', "2019-08-01") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + api_version = kwargs.pop("api_version", _params.pop("api-version", "2019-08-01")) # type: str + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[None] - _json = self._serialize.body(parameters, 'ResourcesMoveInfo') + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(parameters, (IO, bytes)): + _content = parameters + else: + _json = self._serialize.body(parameters, "ResourcesMoveInfo") - request = build_resources_move_resources_request_initial( + request = build_resources_move_resources_request( source_resource_group_name=source_resource_group_name, subscription_id=self._config.subscription_id, api_version=api_version, content_type=content_type, json=_json, - template_url=self._move_resources_initial.metadata['url'], + content=_content, + template_url=self._move_resources_initial.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response - if response.status_code not in [202, 204]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - raise HttpResponseError(response=response, error_format=ARMErrorFormat) + if response.status_code not in [202, 204]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + if cls: + return cls(pipeline_response, None, {}) + + _move_resources_initial.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{sourceResourceGroupName}/moveResources"} # type: ignore + + @overload + async def begin_move_resources( + self, + source_resource_group_name: str, + parameters: _models.ResourcesMoveInfo, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> AsyncLROPoller[None]: + """Moves resources from one resource group to another resource group. + + The resources to move must be in the same source resource group. The target resource group may + be in a different subscription. When moving resources, both the source group and the target + group are locked for the duration of the operation. Write and delete operations are blocked on + the groups until the move completes. + + :param source_resource_group_name: The name of the resource group containing the resources to + move. Required. + :type source_resource_group_name: str + :param parameters: Parameters for moving resources. Required. + :type parameters: ~azure.mgmt.resource.resources.v2019_08_01.models.ResourcesMoveInfo + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be AsyncARMPolling. Pass in False for + this operation to not poll, or pass in your own initialized polling object for a personal + polling strategy. + :paramtype polling: bool or ~azure.core.polling.AsyncPollingMethod + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of AsyncLROPoller that returns either None or the result of cls(response) + :rtype: ~azure.core.polling.AsyncLROPoller[None] + :raises ~azure.core.exceptions.HttpResponseError: + """ - if cls: - return cls(pipeline_response, None, {}) + @overload + async def begin_move_resources( + self, source_resource_group_name: str, parameters: IO, *, content_type: str = "application/json", **kwargs: Any + ) -> AsyncLROPoller[None]: + """Moves resources from one resource group to another resource group. - _move_resources_initial.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{sourceResourceGroupName}/moveResources"} # type: ignore + The resources to move must be in the same source resource group. The target resource group may + be in a different subscription. When moving resources, both the source group and the target + group are locked for the duration of the operation. Write and delete operations are blocked on + the groups until the move completes. + :param source_resource_group_name: The name of the resource group containing the resources to + move. Required. + :type source_resource_group_name: str + :param parameters: Parameters for moving resources. Required. + :type parameters: IO + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be AsyncARMPolling. Pass in False for + this operation to not poll, or pass in your own initialized polling object for a personal + polling strategy. + :paramtype polling: bool or ~azure.core.polling.AsyncPollingMethod + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of AsyncLROPoller that returns either None or the result of cls(response) + :rtype: ~azure.core.polling.AsyncLROPoller[None] + :raises ~azure.core.exceptions.HttpResponseError: + """ @distributed_trace_async - async def begin_move_resources( # pylint: disable=inconsistent-return-statements - self, - source_resource_group_name: str, - parameters: "_models.ResourcesMoveInfo", - **kwargs: Any + async def begin_move_resources( + self, source_resource_group_name: str, parameters: Union[_models.ResourcesMoveInfo, IO], **kwargs: Any ) -> AsyncLROPoller[None]: """Moves resources from one resource group to another resource group. @@ -4098,10 +5250,14 @@ async def begin_move_resources( # pylint: disable=inconsistent-return-statement the groups until the move completes. :param source_resource_group_name: The name of the resource group containing the resources to - move. + move. Required. :type source_resource_group_name: str - :param parameters: Parameters for moving resources. - :type parameters: ~azure.mgmt.resource.resources.v2019_08_01.models.ResourcesMoveInfo + :param parameters: Parameters for moving resources. Is either a model type or a IO type. + Required. + :type parameters: ~azure.mgmt.resource.resources.v2019_08_01.models.ResourcesMoveInfo or IO + :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. + Default value is None. + :paramtype content_type: str :keyword callable cls: A custom type or function that will be passed the direct response :keyword str continuation_token: A continuation token to restart a poller from a saved state. :keyword polling: By default, your polling method will be AsyncARMPolling. Pass in False for @@ -4112,80 +5268,95 @@ async def begin_move_resources( # pylint: disable=inconsistent-return-statement Retry-After header is present. :return: An instance of AsyncLROPoller that returns either None or the result of cls(response) :rtype: ~azure.core.polling.AsyncLROPoller[None] - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - api_version = kwargs.pop('api_version', "2019-08-01") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] - polling = kwargs.pop('polling', True) # type: Union[bool, AsyncPollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType[None] - lro_delay = kwargs.pop( - 'polling_interval', - self._config.polling_interval - ) - cont_token = kwargs.pop('continuation_token', None) # type: Optional[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", "2019-08-01")) # type: str + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[None] + polling = kwargs.pop("polling", True) # type: Union[bool, AsyncPollingMethod] + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token = kwargs.pop("continuation_token", None) # type: Optional[str] if cont_token is None: - raw_result = await self._move_resources_initial( + raw_result = await self._move_resources_initial( # type: ignore source_resource_group_name=source_resource_group_name, parameters=parameters, api_version=api_version, content_type=content_type, - cls=lambda x,y,z: x, + cls=lambda x, y, z: x, + headers=_headers, + params=_params, **kwargs ) - kwargs.pop('error_map', None) + kwargs.pop("error_map", None) - def get_long_running_output(pipeline_response): + def get_long_running_output(pipeline_response): # pylint: disable=inconsistent-return-statements if cls: return cls(pipeline_response, None, {}) - - if polling is True: polling_method = AsyncARMPolling(lro_delay, **kwargs) - elif polling is False: polling_method = AsyncNoPolling() - else: polling_method = polling + if polling is True: + polling_method = cast(AsyncPollingMethod, AsyncARMPolling(lro_delay, **kwargs)) # type: AsyncPollingMethod + elif polling is False: + polling_method = cast(AsyncPollingMethod, AsyncNoPolling()) + else: + polling_method = polling if cont_token: return AsyncLROPoller.from_continuation_token( polling_method=polling_method, continuation_token=cont_token, client=self._client, - deserialization_callback=get_long_running_output + deserialization_callback=get_long_running_output, ) return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) - begin_move_resources.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{sourceResourceGroupName}/moveResources"} # type: ignore + begin_move_resources.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{sourceResourceGroupName}/moveResources"} # type: ignore async def _validate_move_resources_initial( # pylint: disable=inconsistent-return-statements - self, - source_resource_group_name: str, - parameters: "_models.ResourcesMoveInfo", - **kwargs: Any + self, source_resource_group_name: str, parameters: Union[_models.ResourcesMoveInfo, IO], **kwargs: Any ) -> None: - cls = kwargs.pop('cls', None) # type: ClsType[None] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', "2019-08-01") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + api_version = kwargs.pop("api_version", _params.pop("api-version", "2019-08-01")) # type: str + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[None] - _json = self._serialize.body(parameters, 'ResourcesMoveInfo') + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(parameters, (IO, bytes)): + _content = parameters + else: + _json = self._serialize.body(parameters, "ResourcesMoveInfo") - request = build_resources_validate_move_resources_request_initial( + request = build_resources_validate_move_resources_request( source_resource_group_name=source_resource_group_name, subscription_id=self._config.subscription_id, api_version=api_version, content_type=content_type, json=_json, - template_url=self._validate_move_resources_initial.metadata['url'], + content=_content, + template_url=self._validate_move_resources_initial.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [202, 204]: @@ -4195,14 +5366,15 @@ async def _validate_move_resources_initial( # pylint: disable=inconsistent-retu if cls: return cls(pipeline_response, None, {}) - _validate_move_resources_initial.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{sourceResourceGroupName}/validateMoveResources"} # type: ignore - + _validate_move_resources_initial.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{sourceResourceGroupName}/validateMoveResources"} # type: ignore - @distributed_trace_async - async def begin_validate_move_resources( # pylint: disable=inconsistent-return-statements + @overload + async def begin_validate_move_resources( self, source_resource_group_name: str, - parameters: "_models.ResourcesMoveInfo", + parameters: _models.ResourcesMoveInfo, + *, + content_type: str = "application/json", **kwargs: Any ) -> AsyncLROPoller[None]: """Validates whether resources can be moved from one resource group to another resource group. @@ -4215,10 +5387,13 @@ async def begin_validate_move_resources( # pylint: disable=inconsistent-return- operation. :param source_resource_group_name: The name of the resource group containing the resources to - validate for move. + validate for move. Required. :type source_resource_group_name: str - :param parameters: Parameters for moving resources. + :param parameters: Parameters for moving resources. Required. :type parameters: ~azure.mgmt.resource.resources.v2019_08_01.models.ResourcesMoveInfo + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str :keyword callable cls: A custom type or function that will be passed the direct response :keyword str continuation_token: A continuation token to restart a poller from a saved state. :keyword polling: By default, your polling method will be AsyncARMPolling. Pass in False for @@ -4229,55 +5404,124 @@ async def begin_validate_move_resources( # pylint: disable=inconsistent-return- Retry-After header is present. :return: An instance of AsyncLROPoller that returns either None or the result of cls(response) :rtype: ~azure.core.polling.AsyncLROPoller[None] - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - api_version = kwargs.pop('api_version', "2019-08-01") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] - polling = kwargs.pop('polling', True) # type: Union[bool, AsyncPollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType[None] - lro_delay = kwargs.pop( - 'polling_interval', - self._config.polling_interval - ) - cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] + + @overload + async def begin_validate_move_resources( + self, source_resource_group_name: str, parameters: IO, *, content_type: str = "application/json", **kwargs: Any + ) -> AsyncLROPoller[None]: + """Validates whether resources can be moved from one resource group to another resource group. + + This operation checks whether the specified resources can be moved to the target. The resources + to move must be in the same source resource group. The target resource group may be in a + different subscription. If validation succeeds, it returns HTTP response code 204 (no content). + If validation fails, it returns HTTP response code 409 (Conflict) with an error message. + Retrieve the URL in the Location header value to check the result of the long-running + operation. + + :param source_resource_group_name: The name of the resource group containing the resources to + validate for move. Required. + :type source_resource_group_name: str + :param parameters: Parameters for moving resources. Required. + :type parameters: IO + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be AsyncARMPolling. Pass in False for + this operation to not poll, or pass in your own initialized polling object for a personal + polling strategy. + :paramtype polling: bool or ~azure.core.polling.AsyncPollingMethod + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of AsyncLROPoller that returns either None or the result of cls(response) + :rtype: ~azure.core.polling.AsyncLROPoller[None] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace_async + async def begin_validate_move_resources( + self, source_resource_group_name: str, parameters: Union[_models.ResourcesMoveInfo, IO], **kwargs: Any + ) -> AsyncLROPoller[None]: + """Validates whether resources can be moved from one resource group to another resource group. + + This operation checks whether the specified resources can be moved to the target. The resources + to move must be in the same source resource group. The target resource group may be in a + different subscription. If validation succeeds, it returns HTTP response code 204 (no content). + If validation fails, it returns HTTP response code 409 (Conflict) with an error message. + Retrieve the URL in the Location header value to check the result of the long-running + operation. + + :param source_resource_group_name: The name of the resource group containing the resources to + validate for move. Required. + :type source_resource_group_name: str + :param parameters: Parameters for moving resources. Is either a model type or a IO type. + Required. + :type parameters: ~azure.mgmt.resource.resources.v2019_08_01.models.ResourcesMoveInfo or IO + :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. + Default value is None. + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be AsyncARMPolling. Pass in False for + this operation to not poll, or pass in your own initialized polling object for a personal + polling strategy. + :paramtype polling: bool or ~azure.core.polling.AsyncPollingMethod + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of AsyncLROPoller that returns either None or the result of cls(response) + :rtype: ~azure.core.polling.AsyncLROPoller[None] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _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", "2019-08-01")) # type: str + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[None] + polling = kwargs.pop("polling", True) # type: Union[bool, AsyncPollingMethod] + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token = kwargs.pop("continuation_token", None) # type: Optional[str] if cont_token is None: - raw_result = await self._validate_move_resources_initial( + raw_result = await self._validate_move_resources_initial( # type: ignore source_resource_group_name=source_resource_group_name, parameters=parameters, api_version=api_version, content_type=content_type, - cls=lambda x,y,z: x, + cls=lambda x, y, z: x, + headers=_headers, + params=_params, **kwargs ) - kwargs.pop('error_map', None) + kwargs.pop("error_map", None) - def get_long_running_output(pipeline_response): + def get_long_running_output(pipeline_response): # pylint: disable=inconsistent-return-statements if cls: return cls(pipeline_response, None, {}) - - if polling is True: polling_method = AsyncARMPolling(lro_delay, **kwargs) - elif polling is False: polling_method = AsyncNoPolling() - else: polling_method = polling + if polling is True: + polling_method = cast(AsyncPollingMethod, AsyncARMPolling(lro_delay, **kwargs)) # type: AsyncPollingMethod + elif polling is False: + polling_method = cast(AsyncPollingMethod, AsyncNoPolling()) + else: + polling_method = polling if cont_token: return AsyncLROPoller.from_continuation_token( polling_method=polling_method, continuation_token=cont_token, client=self._client, - deserialization_callback=get_long_running_output + deserialization_callback=get_long_running_output, ) return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) - begin_validate_move_resources.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{sourceResourceGroupName}/validateMoveResources"} # type: ignore + begin_validate_move_resources.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{sourceResourceGroupName}/validateMoveResources"} # type: ignore @distributed_trace def list( - self, - filter: Optional[str] = None, - expand: Optional[str] = None, - top: Optional[int] = None, - **kwargs: Any - ) -> AsyncIterable["_models.ResourceListResult"]: + self, filter: Optional[str] = None, expand: Optional[str] = None, top: Optional[int] = None, **kwargs: Any + ) -> AsyncIterable["_models.GenericResourceExpanded"]: """Get all the resources in a subscription. :param filter: The filter to apply on the operation.:code:`
`:code:`
`The properties you @@ -4304,40 +5548,50 @@ def list( value is None. :type top: int :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either ResourceListResult or the result of cls(response) + :return: An iterator like instance of either GenericResourceExpanded or the result of + cls(response) :rtype: - ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.resource.resources.v2019_08_01.models.ResourceListResult] - :raises: ~azure.core.exceptions.HttpResponseError + ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.resource.resources.v2019_08_01.models.GenericResourceExpanded] + :raises ~azure.core.exceptions.HttpResponseError: """ - api_version = kwargs.pop('api_version', "2019-08-01") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2019-08-01")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[_models.ResourceListResult] - cls = kwargs.pop('cls', None) # type: ClsType["_models.ResourceListResult"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) + def prepare_request(next_link=None): if not next_link: - + request = build_resources_list_request( subscription_id=self._config.subscription_id, - api_version=api_version, filter=filter, expand=expand, top=top, - template_url=self.list.metadata['url'], + 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.url = self._client.format_url(request.url) # type: ignore else: - - request = build_resources_list_request( - subscription_id=self._config.subscription_id, - template_url=next_link, - ) + # make call to next link with the client's api-version + _parsed_next_link = urlparse(next_link) + _next_request_params = case_insensitive_dict(parse_qs(_parsed_next_link.query)) + _next_request_params["api-version"] = self._config.api_version + request = HttpRequest("GET", urljoin(next_link, _parsed_next_link.path), params=_next_request_params) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore request.method = "GET" return request @@ -4351,10 +5605,8 @@ async def extract_data(pipeline_response): async def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) response = pipeline_response.http_response @@ -4364,11 +5616,9 @@ async def get_next(next_link=None): return pipeline_response + return AsyncItemPaged(get_next, extract_data) - return AsyncItemPaged( - get_next, extract_data - ) - list.metadata = {'url': "/subscriptions/{subscriptionId}/resources"} # type: ignore + list.metadata = {"url": "/subscriptions/{subscriptionId}/resources"} # type: ignore @distributed_trace_async async def check_existence( @@ -4384,30 +5634,36 @@ async def check_existence( """Checks whether a resource exists. :param resource_group_name: The name of the resource group containing the resource to check. - The name is case insensitive. + The name is case insensitive. Required. :type resource_group_name: str - :param resource_provider_namespace: The resource provider of the resource to check. + :param resource_provider_namespace: The resource provider of the resource to check. Required. :type resource_provider_namespace: str - :param parent_resource_path: The parent resource identity. + :param parent_resource_path: The parent resource identity. Required. :type parent_resource_path: str - :param resource_type: The resource type. + :param resource_type: The resource type. Required. :type resource_type: str - :param resource_name: The name of the resource to check whether it exists. + :param resource_name: The name of the resource to check whether it exists. Required. :type resource_name: str - :param api_version: The API version to use for the operation. + :param api_version: The API version to use for the operation. Required. :type api_version: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: bool, or the result of cls(response) + :return: bool or the result of cls(response) :rtype: bool - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType[None] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = kwargs.pop("params", {}) or {} + + cls = kwargs.pop("cls", None) # type: ClsType[None] - request = build_resources_check_existence_request( resource_group_name=resource_group_name, resource_provider_namespace=resource_provider_namespace, @@ -4416,16 +5672,17 @@ async def check_existence( resource_name=resource_name, subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.check_existence.metadata['url'], + template_url=self.check_existence.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [204, 404]: @@ -4436,8 +5693,7 @@ async def check_existence( return cls(pipeline_response, None, {}) return 200 <= response.status_code <= 299 - check_existence.metadata = {'url': "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{parentResourcePath}/{resourceType}/{resourceName}"} # type: ignore - + check_existence.metadata = {"url": "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{parentResourcePath}/{resourceType}/{resourceName}"} # type: ignore async def _delete_initial( # pylint: disable=inconsistent-return-statements self, @@ -4449,14 +5705,20 @@ async def _delete_initial( # pylint: disable=inconsistent-return-statements api_version: str, **kwargs: Any ) -> None: - cls = kwargs.pop('cls', None) # type: ClsType[None] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) - - request = build_resources_delete_request_initial( + _headers = kwargs.pop("headers", {}) or {} + _params = kwargs.pop("params", {}) or {} + + cls = kwargs.pop("cls", None) # type: ClsType[None] + + request = build_resources_delete_request( resource_group_name=resource_group_name, resource_provider_namespace=resource_provider_namespace, parent_resource_path=parent_resource_path, @@ -4464,16 +5726,17 @@ async def _delete_initial( # pylint: disable=inconsistent-return-statements resource_name=resource_name, subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self._delete_initial.metadata['url'], + template_url=self._delete_initial.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200, 202, 204]: @@ -4483,11 +5746,10 @@ 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/{resourceProviderNamespace}/{parentResourcePath}/{resourceType}/{resourceName}"} # type: ignore - + _delete_initial.metadata = {"url": "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{parentResourcePath}/{resourceType}/{resourceName}"} # type: ignore @distributed_trace_async - async def begin_delete( # pylint: disable=inconsistent-return-statements + async def begin_delete( self, resource_group_name: str, resource_provider_namespace: str, @@ -4500,17 +5762,17 @@ async def begin_delete( # pylint: disable=inconsistent-return-statements """Deletes a resource. :param resource_group_name: The name of the resource group that contains the resource to - delete. The name is case insensitive. + delete. The name is case insensitive. Required. :type resource_group_name: str - :param resource_provider_namespace: The namespace of the resource provider. + :param resource_provider_namespace: The namespace of the resource provider. Required. :type resource_provider_namespace: str - :param parent_resource_path: The parent resource identity. + :param parent_resource_path: The parent resource identity. Required. :type parent_resource_path: str - :param resource_type: The resource type. + :param resource_type: The resource type. Required. :type resource_type: str - :param resource_name: The name of the resource to delete. + :param resource_name: The name of the resource to delete. Required. :type resource_name: str - :param api_version: The API version to use for the operation. + :param api_version: The API version to use for the operation. Required. :type api_version: str :keyword callable cls: A custom type or function that will be passed the direct response :keyword str continuation_token: A continuation token to restart a poller from a saved state. @@ -4522,46 +5784,50 @@ async def begin_delete( # pylint: disable=inconsistent-return-statements Retry-After header is present. :return: An instance of AsyncLROPoller that returns either None or the result of cls(response) :rtype: ~azure.core.polling.AsyncLROPoller[None] - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - polling = kwargs.pop('polling', True) # type: Union[bool, AsyncPollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType[None] - lro_delay = kwargs.pop( - 'polling_interval', - self._config.polling_interval - ) - cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] + _headers = kwargs.pop("headers", {}) or {} + _params = kwargs.pop("params", {}) or {} + + cls = kwargs.pop("cls", None) # type: ClsType[None] + polling = kwargs.pop("polling", True) # type: Union[bool, AsyncPollingMethod] + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token = kwargs.pop("continuation_token", None) # type: Optional[str] if cont_token is None: - raw_result = await self._delete_initial( + raw_result = await self._delete_initial( # type: ignore resource_group_name=resource_group_name, resource_provider_namespace=resource_provider_namespace, parent_resource_path=parent_resource_path, resource_type=resource_type, resource_name=resource_name, api_version=api_version, - cls=lambda x,y,z: x, + cls=lambda x, y, z: x, + headers=_headers, + params=_params, **kwargs ) - kwargs.pop('error_map', None) + kwargs.pop("error_map", None) - def get_long_running_output(pipeline_response): + def get_long_running_output(pipeline_response): # pylint: disable=inconsistent-return-statements if cls: return cls(pipeline_response, None, {}) - - if polling is True: polling_method = AsyncARMPolling(lro_delay, **kwargs) - elif polling is False: polling_method = AsyncNoPolling() - else: polling_method = polling + if polling is True: + polling_method = cast(AsyncPollingMethod, AsyncARMPolling(lro_delay, **kwargs)) # type: AsyncPollingMethod + elif polling is False: + polling_method = cast(AsyncPollingMethod, AsyncNoPolling()) + else: + polling_method = polling if cont_token: return AsyncLROPoller.from_continuation_token( polling_method=polling_method, continuation_token=cont_token, client=self._client, - deserialization_callback=get_long_running_output + deserialization_callback=get_long_running_output, ) return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) - begin_delete.metadata = {'url': "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{parentResourcePath}/{resourceType}/{resourceName}"} # type: ignore + begin_delete.metadata = {"url": "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{parentResourcePath}/{resourceType}/{resourceName}"} # type: ignore async def _create_or_update_initial( self, @@ -4571,39 +5837,53 @@ async def _create_or_update_initial( resource_type: str, resource_name: str, api_version: str, - parameters: "_models.GenericResource", + parameters: Union[_models.GenericResource, IO], **kwargs: Any - ) -> Optional["_models.GenericResource"]: - cls = kwargs.pop('cls', None) # type: ClsType[Optional["_models.GenericResource"]] + ) -> Optional[_models.GenericResource]: error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = kwargs.pop("params", {}) or {} - _json = self._serialize.body(parameters, 'GenericResource') + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[Optional[_models.GenericResource]] - request = build_resources_create_or_update_request_initial( + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(parameters, (IO, bytes)): + _content = parameters + else: + _json = self._serialize.body(parameters, "GenericResource") + + request = build_resources_create_or_update_request( resource_group_name=resource_group_name, resource_provider_namespace=resource_provider_namespace, parent_resource_path=parent_resource_path, resource_type=resource_type, resource_name=resource_name, subscription_id=self._config.subscription_id, - content_type=content_type, api_version=api_version, + content_type=content_type, json=_json, - template_url=self._create_or_update_initial.metadata['url'], + content=_content, + template_url=self._create_or_update_initial.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200, 201, 202]: @@ -4612,18 +5892,115 @@ async def _create_or_update_initial( deserialized = None if response.status_code == 200: - deserialized = self._deserialize('GenericResource', pipeline_response) + deserialized = self._deserialize("GenericResource", pipeline_response) if response.status_code == 201: - deserialized = self._deserialize('GenericResource', pipeline_response) + deserialized = self._deserialize("GenericResource", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - _create_or_update_initial.metadata = {'url': "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{parentResourcePath}/{resourceType}/{resourceName}"} # type: ignore + _create_or_update_initial.metadata = {"url": "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{parentResourcePath}/{resourceType}/{resourceName}"} # type: ignore + + @overload + async def begin_create_or_update( + self, + resource_group_name: str, + resource_provider_namespace: str, + parent_resource_path: str, + resource_type: str, + resource_name: str, + api_version: str, + parameters: _models.GenericResource, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> AsyncLROPoller[_models.GenericResource]: + """Creates a resource. + + :param resource_group_name: The name of the resource group for the resource. The name is case + insensitive. Required. + :type resource_group_name: str + :param resource_provider_namespace: The namespace of the resource provider. Required. + :type resource_provider_namespace: str + :param parent_resource_path: The parent resource identity. Required. + :type parent_resource_path: str + :param resource_type: The resource type of the resource to create. Required. + :type resource_type: str + :param resource_name: The name of the resource to create. Required. + :type resource_name: str + :param api_version: The API version to use for the operation. Required. + :type api_version: str + :param parameters: Parameters for creating or updating the resource. Required. + :type parameters: ~azure.mgmt.resource.resources.v2019_08_01.models.GenericResource + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be AsyncARMPolling. Pass in False for + this operation to not poll, or pass in your own initialized polling object for a personal + polling strategy. + :paramtype polling: bool or ~azure.core.polling.AsyncPollingMethod + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of AsyncLROPoller that returns either GenericResource or the result of + cls(response) + :rtype: + ~azure.core.polling.AsyncLROPoller[~azure.mgmt.resource.resources.v2019_08_01.models.GenericResource] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + async def begin_create_or_update( + self, + resource_group_name: str, + resource_provider_namespace: str, + parent_resource_path: str, + resource_type: str, + resource_name: str, + api_version: str, + parameters: IO, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> AsyncLROPoller[_models.GenericResource]: + """Creates a resource. + :param resource_group_name: The name of the resource group for the resource. The name is case + insensitive. Required. + :type resource_group_name: str + :param resource_provider_namespace: The namespace of the resource provider. Required. + :type resource_provider_namespace: str + :param parent_resource_path: The parent resource identity. Required. + :type parent_resource_path: str + :param resource_type: The resource type of the resource to create. Required. + :type resource_type: str + :param resource_name: The name of the resource to create. Required. + :type resource_name: str + :param api_version: The API version to use for the operation. Required. + :type api_version: str + :param parameters: Parameters for creating or updating the resource. Required. + :type parameters: IO + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be AsyncARMPolling. Pass in False for + this operation to not poll, or pass in your own initialized polling object for a personal + polling strategy. + :paramtype polling: bool or ~azure.core.polling.AsyncPollingMethod + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of AsyncLROPoller that returns either GenericResource or the result of + cls(response) + :rtype: + ~azure.core.polling.AsyncLROPoller[~azure.mgmt.resource.resources.v2019_08_01.models.GenericResource] + :raises ~azure.core.exceptions.HttpResponseError: + """ @distributed_trace_async async def begin_create_or_update( @@ -4634,26 +6011,30 @@ async def begin_create_or_update( resource_type: str, resource_name: str, api_version: str, - parameters: "_models.GenericResource", + parameters: Union[_models.GenericResource, IO], **kwargs: Any - ) -> AsyncLROPoller["_models.GenericResource"]: + ) -> AsyncLROPoller[_models.GenericResource]: """Creates a resource. :param resource_group_name: The name of the resource group for the resource. The name is case - insensitive. + insensitive. Required. :type resource_group_name: str - :param resource_provider_namespace: The namespace of the resource provider. + :param resource_provider_namespace: The namespace of the resource provider. Required. :type resource_provider_namespace: str - :param parent_resource_path: The parent resource identity. + :param parent_resource_path: The parent resource identity. Required. :type parent_resource_path: str - :param resource_type: The resource type of the resource to create. + :param resource_type: The resource type of the resource to create. Required. :type resource_type: str - :param resource_name: The name of the resource to create. + :param resource_name: The name of the resource to create. Required. :type resource_name: str - :param api_version: The API version to use for the operation. + :param api_version: The API version to use for the operation. Required. :type api_version: str - :param parameters: Parameters for creating or updating the resource. - :type parameters: ~azure.mgmt.resource.resources.v2019_08_01.models.GenericResource + :param parameters: Parameters for creating or updating the resource. Is either a model type or + a IO type. Required. + :type parameters: ~azure.mgmt.resource.resources.v2019_08_01.models.GenericResource or IO + :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. + Default value is None. + :paramtype content_type: str :keyword callable cls: A custom type or function that will be passed the direct response :keyword str continuation_token: A continuation token to restart a poller from a saved state. :keyword polling: By default, your polling method will be AsyncARMPolling. Pass in False for @@ -4666,18 +6047,18 @@ async def begin_create_or_update( cls(response) :rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.resource.resources.v2019_08_01.models.GenericResource] - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] - polling = kwargs.pop('polling', True) # type: Union[bool, AsyncPollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType["_models.GenericResource"] - lro_delay = kwargs.pop( - 'polling_interval', - self._config.polling_interval - ) - cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = kwargs.pop("params", {}) or {} + + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.GenericResource] + polling = kwargs.pop("polling", True) # type: Union[bool, AsyncPollingMethod] + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token = kwargs.pop("continuation_token", None) # type: Optional[str] if cont_token is None: - raw_result = await self._create_or_update_initial( + raw_result = await self._create_or_update_initial( # type: ignore resource_group_name=resource_group_name, resource_provider_namespace=resource_provider_namespace, parent_resource_path=parent_resource_path, @@ -4686,32 +6067,35 @@ async def begin_create_or_update( api_version=api_version, parameters=parameters, content_type=content_type, - cls=lambda x,y,z: x, + cls=lambda x, y, z: x, + headers=_headers, + params=_params, **kwargs ) - kwargs.pop('error_map', None) + kwargs.pop("error_map", None) def get_long_running_output(pipeline_response): - response = pipeline_response.http_response - deserialized = self._deserialize('GenericResource', pipeline_response) + deserialized = self._deserialize("GenericResource", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - - if polling is True: polling_method = AsyncARMPolling(lro_delay, **kwargs) - elif polling is False: polling_method = AsyncNoPolling() - else: polling_method = polling + if polling is True: + polling_method = cast(AsyncPollingMethod, AsyncARMPolling(lro_delay, **kwargs)) # type: AsyncPollingMethod + elif polling is False: + polling_method = cast(AsyncPollingMethod, AsyncNoPolling()) + else: + polling_method = polling if cont_token: return AsyncLROPoller.from_continuation_token( polling_method=polling_method, continuation_token=cont_token, client=self._client, - deserialization_callback=get_long_running_output + deserialization_callback=get_long_running_output, ) return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) - begin_create_or_update.metadata = {'url': "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{parentResourcePath}/{resourceType}/{resourceName}"} # type: ignore + begin_create_or_update.metadata = {"url": "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{parentResourcePath}/{resourceType}/{resourceName}"} # type: ignore async def _update_initial( self, @@ -4721,39 +6105,53 @@ async def _update_initial( resource_type: str, resource_name: str, api_version: str, - parameters: "_models.GenericResource", + parameters: Union[_models.GenericResource, IO], **kwargs: Any - ) -> Optional["_models.GenericResource"]: - cls = kwargs.pop('cls', None) # type: ClsType[Optional["_models.GenericResource"]] + ) -> Optional[_models.GenericResource]: error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = kwargs.pop("params", {}) or {} - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[Optional[_models.GenericResource]] - _json = self._serialize.body(parameters, 'GenericResource') + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(parameters, (IO, bytes)): + _content = parameters + else: + _json = self._serialize.body(parameters, "GenericResource") - request = build_resources_update_request_initial( + request = build_resources_update_request( resource_group_name=resource_group_name, resource_provider_namespace=resource_provider_namespace, parent_resource_path=parent_resource_path, resource_type=resource_type, resource_name=resource_name, subscription_id=self._config.subscription_id, - content_type=content_type, api_version=api_version, + content_type=content_type, json=_json, - template_url=self._update_initial.metadata['url'], + content=_content, + template_url=self._update_initial.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200, 202]: @@ -4762,15 +6160,112 @@ async def _update_initial( deserialized = None if response.status_code == 200: - deserialized = self._deserialize('GenericResource', pipeline_response) + deserialized = self._deserialize("GenericResource", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - _update_initial.metadata = {'url': "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{parentResourcePath}/{resourceType}/{resourceName}"} # type: ignore + _update_initial.metadata = {"url": "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{parentResourcePath}/{resourceType}/{resourceName}"} # type: ignore + + @overload + async def begin_update( + self, + resource_group_name: str, + resource_provider_namespace: str, + parent_resource_path: str, + resource_type: str, + resource_name: str, + api_version: str, + parameters: _models.GenericResource, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> AsyncLROPoller[_models.GenericResource]: + """Updates a resource. + + :param resource_group_name: The name of the resource group for the resource. The name is case + insensitive. Required. + :type resource_group_name: str + :param resource_provider_namespace: The namespace of the resource provider. Required. + :type resource_provider_namespace: str + :param parent_resource_path: The parent resource identity. Required. + :type parent_resource_path: str + :param resource_type: The resource type of the resource to update. Required. + :type resource_type: str + :param resource_name: The name of the resource to update. Required. + :type resource_name: str + :param api_version: The API version to use for the operation. Required. + :type api_version: str + :param parameters: Parameters for updating the resource. Required. + :type parameters: ~azure.mgmt.resource.resources.v2019_08_01.models.GenericResource + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be AsyncARMPolling. Pass in False for + this operation to not poll, or pass in your own initialized polling object for a personal + polling strategy. + :paramtype polling: bool or ~azure.core.polling.AsyncPollingMethod + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of AsyncLROPoller that returns either GenericResource or the result of + cls(response) + :rtype: + ~azure.core.polling.AsyncLROPoller[~azure.mgmt.resource.resources.v2019_08_01.models.GenericResource] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + async def begin_update( + self, + resource_group_name: str, + resource_provider_namespace: str, + parent_resource_path: str, + resource_type: str, + resource_name: str, + api_version: str, + parameters: IO, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> AsyncLROPoller[_models.GenericResource]: + """Updates a resource. + :param resource_group_name: The name of the resource group for the resource. The name is case + insensitive. Required. + :type resource_group_name: str + :param resource_provider_namespace: The namespace of the resource provider. Required. + :type resource_provider_namespace: str + :param parent_resource_path: The parent resource identity. Required. + :type parent_resource_path: str + :param resource_type: The resource type of the resource to update. Required. + :type resource_type: str + :param resource_name: The name of the resource to update. Required. + :type resource_name: str + :param api_version: The API version to use for the operation. Required. + :type api_version: str + :param parameters: Parameters for updating the resource. Required. + :type parameters: IO + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be AsyncARMPolling. Pass in False for + this operation to not poll, or pass in your own initialized polling object for a personal + polling strategy. + :paramtype polling: bool or ~azure.core.polling.AsyncPollingMethod + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of AsyncLROPoller that returns either GenericResource or the result of + cls(response) + :rtype: + ~azure.core.polling.AsyncLROPoller[~azure.mgmt.resource.resources.v2019_08_01.models.GenericResource] + :raises ~azure.core.exceptions.HttpResponseError: + """ @distributed_trace_async async def begin_update( @@ -4781,26 +6276,30 @@ async def begin_update( resource_type: str, resource_name: str, api_version: str, - parameters: "_models.GenericResource", + parameters: Union[_models.GenericResource, IO], **kwargs: Any - ) -> AsyncLROPoller["_models.GenericResource"]: + ) -> AsyncLROPoller[_models.GenericResource]: """Updates a resource. :param resource_group_name: The name of the resource group for the resource. The name is case - insensitive. + insensitive. Required. :type resource_group_name: str - :param resource_provider_namespace: The namespace of the resource provider. + :param resource_provider_namespace: The namespace of the resource provider. Required. :type resource_provider_namespace: str - :param parent_resource_path: The parent resource identity. + :param parent_resource_path: The parent resource identity. Required. :type parent_resource_path: str - :param resource_type: The resource type of the resource to update. + :param resource_type: The resource type of the resource to update. Required. :type resource_type: str - :param resource_name: The name of the resource to update. + :param resource_name: The name of the resource to update. Required. :type resource_name: str - :param api_version: The API version to use for the operation. + :param api_version: The API version to use for the operation. Required. :type api_version: str - :param parameters: Parameters for updating the resource. - :type parameters: ~azure.mgmt.resource.resources.v2019_08_01.models.GenericResource + :param parameters: Parameters for updating the resource. Is either a model type or a IO type. + Required. + :type parameters: ~azure.mgmt.resource.resources.v2019_08_01.models.GenericResource or IO + :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. + Default value is None. + :paramtype content_type: str :keyword callable cls: A custom type or function that will be passed the direct response :keyword str continuation_token: A continuation token to restart a poller from a saved state. :keyword polling: By default, your polling method will be AsyncARMPolling. Pass in False for @@ -4813,18 +6312,18 @@ async def begin_update( cls(response) :rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.resource.resources.v2019_08_01.models.GenericResource] - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] - polling = kwargs.pop('polling', True) # type: Union[bool, AsyncPollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType["_models.GenericResource"] - lro_delay = kwargs.pop( - 'polling_interval', - self._config.polling_interval - ) - cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = kwargs.pop("params", {}) or {} + + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.GenericResource] + polling = kwargs.pop("polling", True) # type: Union[bool, AsyncPollingMethod] + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token = kwargs.pop("continuation_token", None) # type: Optional[str] if cont_token is None: - raw_result = await self._update_initial( + raw_result = await self._update_initial( # type: ignore resource_group_name=resource_group_name, resource_provider_namespace=resource_provider_namespace, parent_resource_path=parent_resource_path, @@ -4833,32 +6332,35 @@ async def begin_update( api_version=api_version, parameters=parameters, content_type=content_type, - cls=lambda x,y,z: x, + cls=lambda x, y, z: x, + headers=_headers, + params=_params, **kwargs ) - kwargs.pop('error_map', None) + kwargs.pop("error_map", None) def get_long_running_output(pipeline_response): - response = pipeline_response.http_response - deserialized = self._deserialize('GenericResource', pipeline_response) + deserialized = self._deserialize("GenericResource", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - - if polling is True: polling_method = AsyncARMPolling(lro_delay, **kwargs) - elif polling is False: polling_method = AsyncNoPolling() - else: polling_method = polling + if polling is True: + polling_method = cast(AsyncPollingMethod, AsyncARMPolling(lro_delay, **kwargs)) # type: AsyncPollingMethod + elif polling is False: + polling_method = cast(AsyncPollingMethod, AsyncNoPolling()) + else: + polling_method = polling if cont_token: return AsyncLROPoller.from_continuation_token( polling_method=polling_method, continuation_token=cont_token, client=self._client, - deserialization_callback=get_long_running_output + deserialization_callback=get_long_running_output, ) return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) - begin_update.metadata = {'url': "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{parentResourcePath}/{resourceType}/{resourceName}"} # type: ignore + begin_update.metadata = {"url": "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{parentResourcePath}/{resourceType}/{resourceName}"} # type: ignore @distributed_trace_async async def get( @@ -4870,34 +6372,40 @@ async def get( resource_name: str, api_version: str, **kwargs: Any - ) -> "_models.GenericResource": + ) -> _models.GenericResource: """Gets a resource. :param resource_group_name: The name of the resource group containing the resource to get. The - name is case insensitive. + name is case insensitive. Required. :type resource_group_name: str - :param resource_provider_namespace: The namespace of the resource provider. + :param resource_provider_namespace: The namespace of the resource provider. Required. :type resource_provider_namespace: str - :param parent_resource_path: The parent resource identity. + :param parent_resource_path: The parent resource identity. Required. :type parent_resource_path: str - :param resource_type: The resource type of the resource. + :param resource_type: The resource type of the resource. Required. :type resource_type: str - :param resource_name: The name of the resource to get. + :param resource_name: The name of the resource to get. Required. :type resource_name: str - :param api_version: The API version to use for the operation. + :param api_version: The API version to use for the operation. Required. :type api_version: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: GenericResource, or the result of cls(response) + :return: GenericResource or the result of cls(response) :rtype: ~azure.mgmt.resource.resources.v2019_08_01.models.GenericResource - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.GenericResource"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = kwargs.pop("params", {}) or {} + + cls = kwargs.pop("cls", None) # type: ClsType[_models.GenericResource] - request = build_resources_get_request( resource_group_name=resource_group_name, resource_provider_namespace=resource_provider_namespace, @@ -4906,72 +6414,75 @@ async def get( resource_name=resource_name, subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.get.metadata['url'], + template_url=self.get.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) - deserialized = self._deserialize('GenericResource', pipeline_response) + deserialized = self._deserialize("GenericResource", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - get.metadata = {'url': "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{parentResourcePath}/{resourceType}/{resourceName}"} # type: ignore - + get.metadata = {"url": "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{parentResourcePath}/{resourceType}/{resourceName}"} # type: ignore @distributed_trace_async - async def check_existence_by_id( - self, - resource_id: str, - api_version: str, - **kwargs: Any - ) -> bool: + async def check_existence_by_id(self, resource_id: str, api_version: str, **kwargs: Any) -> bool: """Checks by ID whether a resource exists. :param resource_id: The fully qualified ID of the resource, including the resource name and resource type. Use the format, /subscriptions/{guid}/resourceGroups/{resource-group-name}/{resource-provider-namespace}/{resource-type}/{resource-name}. + Required. :type resource_id: str - :param api_version: The API version to use for the operation. + :param api_version: The API version to use for the operation. Required. :type api_version: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: bool, or the result of cls(response) + :return: bool or the result of cls(response) :rtype: bool - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType[None] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = kwargs.pop("params", {}) or {} + + cls = kwargs.pop("cls", None) # type: ClsType[None] - request = build_resources_check_existence_by_id_request( resource_id=resource_id, api_version=api_version, - template_url=self.check_existence_by_id.metadata['url'], + template_url=self.check_existence_by_id.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [204, 404]: @@ -4982,35 +6493,38 @@ async def check_existence_by_id( return cls(pipeline_response, None, {}) return 200 <= response.status_code <= 299 - check_existence_by_id.metadata = {'url': "/{resourceId}"} # type: ignore - + check_existence_by_id.metadata = {"url": "/{resourceId}"} # type: ignore async def _delete_by_id_initial( # pylint: disable=inconsistent-return-statements - self, - resource_id: str, - api_version: str, - **kwargs: Any + self, resource_id: str, api_version: str, **kwargs: Any ) -> None: - cls = kwargs.pop('cls', None) # type: ClsType[None] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = kwargs.pop("params", {}) or {} - - request = build_resources_delete_by_id_request_initial( + cls = kwargs.pop("cls", None) # type: ClsType[None] + + request = build_resources_delete_by_id_request( resource_id=resource_id, api_version=api_version, - template_url=self._delete_by_id_initial.metadata['url'], + template_url=self._delete_by_id_initial.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200, 202, 204]: @@ -5020,23 +6534,18 @@ async def _delete_by_id_initial( # pylint: disable=inconsistent-return-statemen if cls: return cls(pipeline_response, None, {}) - _delete_by_id_initial.metadata = {'url': "/{resourceId}"} # type: ignore - + _delete_by_id_initial.metadata = {"url": "/{resourceId}"} # type: ignore @distributed_trace_async - async def begin_delete_by_id( # pylint: disable=inconsistent-return-statements - self, - resource_id: str, - api_version: str, - **kwargs: Any - ) -> AsyncLROPoller[None]: + async def begin_delete_by_id(self, resource_id: str, api_version: str, **kwargs: Any) -> AsyncLROPoller[None]: """Deletes a resource by ID. :param resource_id: The fully qualified ID of the resource, including the resource name and resource type. Use the format, /subscriptions/{guid}/resourceGroups/{resource-group-name}/{resource-provider-namespace}/{resource-type}/{resource-name}. + Required. :type resource_id: str - :param api_version: The API version to use for the operation. + :param api_version: The API version to use for the operation. Required. :type api_version: str :keyword callable cls: A custom type or function that will be passed the direct response :keyword str continuation_token: A continuation token to restart a poller from a saved state. @@ -5048,75 +6557,89 @@ async def begin_delete_by_id( # pylint: disable=inconsistent-return-statements Retry-After header is present. :return: An instance of AsyncLROPoller that returns either None or the result of cls(response) :rtype: ~azure.core.polling.AsyncLROPoller[None] - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - polling = kwargs.pop('polling', True) # type: Union[bool, AsyncPollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType[None] - lro_delay = kwargs.pop( - 'polling_interval', - self._config.polling_interval - ) - cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] + _headers = kwargs.pop("headers", {}) or {} + _params = kwargs.pop("params", {}) or {} + + cls = kwargs.pop("cls", None) # type: ClsType[None] + polling = kwargs.pop("polling", True) # type: Union[bool, AsyncPollingMethod] + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token = kwargs.pop("continuation_token", None) # type: Optional[str] if cont_token is None: - raw_result = await self._delete_by_id_initial( + raw_result = await self._delete_by_id_initial( # type: ignore resource_id=resource_id, api_version=api_version, - cls=lambda x,y,z: x, + cls=lambda x, y, z: x, + headers=_headers, + params=_params, **kwargs ) - kwargs.pop('error_map', None) + kwargs.pop("error_map", None) - def get_long_running_output(pipeline_response): + def get_long_running_output(pipeline_response): # pylint: disable=inconsistent-return-statements if cls: return cls(pipeline_response, None, {}) - - if polling is True: polling_method = AsyncARMPolling(lro_delay, **kwargs) - elif polling is False: polling_method = AsyncNoPolling() - else: polling_method = polling + if polling is True: + polling_method = cast(AsyncPollingMethod, AsyncARMPolling(lro_delay, **kwargs)) # type: AsyncPollingMethod + elif polling is False: + polling_method = cast(AsyncPollingMethod, AsyncNoPolling()) + else: + polling_method = polling if cont_token: return AsyncLROPoller.from_continuation_token( polling_method=polling_method, continuation_token=cont_token, client=self._client, - deserialization_callback=get_long_running_output + deserialization_callback=get_long_running_output, ) return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) - begin_delete_by_id.metadata = {'url': "/{resourceId}"} # type: ignore + begin_delete_by_id.metadata = {"url": "/{resourceId}"} # type: ignore async def _create_or_update_by_id_initial( - self, - resource_id: str, - api_version: str, - parameters: "_models.GenericResource", - **kwargs: Any - ) -> Optional["_models.GenericResource"]: - cls = kwargs.pop('cls', None) # type: ClsType[Optional["_models.GenericResource"]] + self, resource_id: str, api_version: str, parameters: Union[_models.GenericResource, IO], **kwargs: Any + ) -> Optional[_models.GenericResource]: error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = kwargs.pop("params", {}) or {} - _json = self._serialize.body(parameters, 'GenericResource') + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[Optional[_models.GenericResource]] - request = build_resources_create_or_update_by_id_request_initial( + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(parameters, (IO, bytes)): + _content = parameters + else: + _json = self._serialize.body(parameters, "GenericResource") + + request = build_resources_create_or_update_by_id_request( resource_id=resource_id, - content_type=content_type, api_version=api_version, + content_type=content_type, json=_json, - template_url=self._create_or_update_by_id_initial.metadata['url'], + content=_content, + template_url=self._create_or_update_by_id_initial.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200, 201, 202]: @@ -5125,37 +6648,42 @@ async def _create_or_update_by_id_initial( deserialized = None if response.status_code == 200: - deserialized = self._deserialize('GenericResource', pipeline_response) + deserialized = self._deserialize("GenericResource", pipeline_response) if response.status_code == 201: - deserialized = self._deserialize('GenericResource', pipeline_response) + deserialized = self._deserialize("GenericResource", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - _create_or_update_by_id_initial.metadata = {'url': "/{resourceId}"} # type: ignore + _create_or_update_by_id_initial.metadata = {"url": "/{resourceId}"} # type: ignore - - @distributed_trace_async + @overload async def begin_create_or_update_by_id( self, resource_id: str, api_version: str, - parameters: "_models.GenericResource", + parameters: _models.GenericResource, + *, + content_type: str = "application/json", **kwargs: Any - ) -> AsyncLROPoller["_models.GenericResource"]: + ) -> AsyncLROPoller[_models.GenericResource]: """Create a resource by ID. :param resource_id: The fully qualified ID of the resource, including the resource name and resource type. Use the format, /subscriptions/{guid}/resourceGroups/{resource-group-name}/{resource-provider-namespace}/{resource-type}/{resource-name}. + Required. :type resource_id: str - :param api_version: The API version to use for the operation. + :param api_version: The API version to use for the operation. Required. :type api_version: str - :param parameters: Create or update resource parameters. + :param parameters: Create or update resource parameters. Required. :type parameters: ~azure.mgmt.resource.resources.v2019_08_01.models.GenericResource + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str :keyword callable cls: A custom type or function that will be passed the direct response :keyword str continuation_token: A continuation token to restart a poller from a saved state. :keyword polling: By default, your polling method will be AsyncARMPolling. Pass in False for @@ -5168,81 +6696,167 @@ async def begin_create_or_update_by_id( cls(response) :rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.resource.resources.v2019_08_01.models.GenericResource] - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] - polling = kwargs.pop('polling', True) # type: Union[bool, AsyncPollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType["_models.GenericResource"] - lro_delay = kwargs.pop( - 'polling_interval', - self._config.polling_interval - ) - cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] + + @overload + async def begin_create_or_update_by_id( + self, + resource_id: str, + api_version: str, + parameters: IO, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> AsyncLROPoller[_models.GenericResource]: + """Create a resource by ID. + + :param resource_id: The fully qualified ID of the resource, including the resource name and + resource type. Use the format, + /subscriptions/{guid}/resourceGroups/{resource-group-name}/{resource-provider-namespace}/{resource-type}/{resource-name}. + Required. + :type resource_id: str + :param api_version: The API version to use for the operation. Required. + :type api_version: str + :param parameters: Create or update resource parameters. Required. + :type parameters: IO + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be AsyncARMPolling. Pass in False for + this operation to not poll, or pass in your own initialized polling object for a personal + polling strategy. + :paramtype polling: bool or ~azure.core.polling.AsyncPollingMethod + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of AsyncLROPoller that returns either GenericResource or the result of + cls(response) + :rtype: + ~azure.core.polling.AsyncLROPoller[~azure.mgmt.resource.resources.v2019_08_01.models.GenericResource] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace_async + async def begin_create_or_update_by_id( + self, resource_id: str, api_version: str, parameters: Union[_models.GenericResource, IO], **kwargs: Any + ) -> AsyncLROPoller[_models.GenericResource]: + """Create a resource by ID. + + :param resource_id: The fully qualified ID of the resource, including the resource name and + resource type. Use the format, + /subscriptions/{guid}/resourceGroups/{resource-group-name}/{resource-provider-namespace}/{resource-type}/{resource-name}. + Required. + :type resource_id: str + :param api_version: The API version to use for the operation. Required. + :type api_version: str + :param parameters: Create or update resource parameters. Is either a model type or a IO type. + Required. + :type parameters: ~azure.mgmt.resource.resources.v2019_08_01.models.GenericResource or IO + :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. + Default value is None. + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be AsyncARMPolling. Pass in False for + this operation to not poll, or pass in your own initialized polling object for a personal + polling strategy. + :paramtype polling: bool or ~azure.core.polling.AsyncPollingMethod + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of AsyncLROPoller that returns either GenericResource or the result of + cls(response) + :rtype: + ~azure.core.polling.AsyncLROPoller[~azure.mgmt.resource.resources.v2019_08_01.models.GenericResource] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = kwargs.pop("params", {}) or {} + + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.GenericResource] + polling = kwargs.pop("polling", True) # type: Union[bool, AsyncPollingMethod] + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token = kwargs.pop("continuation_token", None) # type: Optional[str] if cont_token is None: - raw_result = await self._create_or_update_by_id_initial( + raw_result = await self._create_or_update_by_id_initial( # type: ignore resource_id=resource_id, api_version=api_version, parameters=parameters, content_type=content_type, - cls=lambda x,y,z: x, + cls=lambda x, y, z: x, + headers=_headers, + params=_params, **kwargs ) - kwargs.pop('error_map', None) + kwargs.pop("error_map", None) def get_long_running_output(pipeline_response): - response = pipeline_response.http_response - deserialized = self._deserialize('GenericResource', pipeline_response) + deserialized = self._deserialize("GenericResource", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - - if polling is True: polling_method = AsyncARMPolling(lro_delay, **kwargs) - elif polling is False: polling_method = AsyncNoPolling() - else: polling_method = polling + if polling is True: + polling_method = cast(AsyncPollingMethod, AsyncARMPolling(lro_delay, **kwargs)) # type: AsyncPollingMethod + elif polling is False: + polling_method = cast(AsyncPollingMethod, AsyncNoPolling()) + else: + polling_method = polling if cont_token: return AsyncLROPoller.from_continuation_token( polling_method=polling_method, continuation_token=cont_token, client=self._client, - deserialization_callback=get_long_running_output + deserialization_callback=get_long_running_output, ) return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) - begin_create_or_update_by_id.metadata = {'url': "/{resourceId}"} # type: ignore + begin_create_or_update_by_id.metadata = {"url": "/{resourceId}"} # type: ignore async def _update_by_id_initial( - self, - resource_id: str, - api_version: str, - parameters: "_models.GenericResource", - **kwargs: Any - ) -> Optional["_models.GenericResource"]: - cls = kwargs.pop('cls', None) # type: ClsType[Optional["_models.GenericResource"]] + self, resource_id: str, api_version: str, parameters: Union[_models.GenericResource, IO], **kwargs: Any + ) -> Optional[_models.GenericResource]: error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = kwargs.pop("params", {}) or {} - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[Optional[_models.GenericResource]] - _json = self._serialize.body(parameters, 'GenericResource') + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(parameters, (IO, bytes)): + _content = parameters + else: + _json = self._serialize.body(parameters, "GenericResource") - request = build_resources_update_by_id_request_initial( + request = build_resources_update_by_id_request( resource_id=resource_id, - content_type=content_type, api_version=api_version, + content_type=content_type, json=_json, - template_url=self._update_by_id_initial.metadata['url'], + content=_content, + template_url=self._update_by_id_initial.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200, 202]: @@ -5251,34 +6865,39 @@ async def _update_by_id_initial( deserialized = None if response.status_code == 200: - deserialized = self._deserialize('GenericResource', pipeline_response) + deserialized = self._deserialize("GenericResource", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - _update_by_id_initial.metadata = {'url': "/{resourceId}"} # type: ignore - + _update_by_id_initial.metadata = {"url": "/{resourceId}"} # type: ignore - @distributed_trace_async + @overload async def begin_update_by_id( self, resource_id: str, api_version: str, - parameters: "_models.GenericResource", + parameters: _models.GenericResource, + *, + content_type: str = "application/json", **kwargs: Any - ) -> AsyncLROPoller["_models.GenericResource"]: + ) -> AsyncLROPoller[_models.GenericResource]: """Updates a resource by ID. :param resource_id: The fully qualified ID of the resource, including the resource name and resource type. Use the format, /subscriptions/{guid}/resourceGroups/{resource-group-name}/{resource-provider-namespace}/{resource-type}/{resource-name}. + Required. :type resource_id: str - :param api_version: The API version to use for the operation. + :param api_version: The API version to use for the operation. Required. :type api_version: str - :param parameters: Update resource parameters. + :param parameters: Update resource parameters. Required. :type parameters: ~azure.mgmt.resource.resources.v2019_08_01.models.GenericResource + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str :keyword callable cls: A custom type or function that will be passed the direct response :keyword str continuation_token: A continuation token to restart a poller from a saved state. :keyword polling: By default, your polling method will be AsyncARMPolling. Pass in False for @@ -5291,165 +6910,243 @@ async def begin_update_by_id( cls(response) :rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.resource.resources.v2019_08_01.models.GenericResource] - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] - polling = kwargs.pop('polling', True) # type: Union[bool, AsyncPollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType["_models.GenericResource"] - lro_delay = kwargs.pop( - 'polling_interval', - self._config.polling_interval - ) - cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] + + @overload + async def begin_update_by_id( + self, + resource_id: str, + api_version: str, + parameters: IO, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> AsyncLROPoller[_models.GenericResource]: + """Updates a resource by ID. + + :param resource_id: The fully qualified ID of the resource, including the resource name and + resource type. Use the format, + /subscriptions/{guid}/resourceGroups/{resource-group-name}/{resource-provider-namespace}/{resource-type}/{resource-name}. + Required. + :type resource_id: str + :param api_version: The API version to use for the operation. Required. + :type api_version: str + :param parameters: Update resource parameters. Required. + :type parameters: IO + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be AsyncARMPolling. Pass in False for + this operation to not poll, or pass in your own initialized polling object for a personal + polling strategy. + :paramtype polling: bool or ~azure.core.polling.AsyncPollingMethod + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of AsyncLROPoller that returns either GenericResource or the result of + cls(response) + :rtype: + ~azure.core.polling.AsyncLROPoller[~azure.mgmt.resource.resources.v2019_08_01.models.GenericResource] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace_async + async def begin_update_by_id( + self, resource_id: str, api_version: str, parameters: Union[_models.GenericResource, IO], **kwargs: Any + ) -> AsyncLROPoller[_models.GenericResource]: + """Updates a resource by ID. + + :param resource_id: The fully qualified ID of the resource, including the resource name and + resource type. Use the format, + /subscriptions/{guid}/resourceGroups/{resource-group-name}/{resource-provider-namespace}/{resource-type}/{resource-name}. + Required. + :type resource_id: str + :param api_version: The API version to use for the operation. Required. + :type api_version: str + :param parameters: Update resource parameters. Is either a model type or a IO type. Required. + :type parameters: ~azure.mgmt.resource.resources.v2019_08_01.models.GenericResource or IO + :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. + Default value is None. + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be AsyncARMPolling. Pass in False for + this operation to not poll, or pass in your own initialized polling object for a personal + polling strategy. + :paramtype polling: bool or ~azure.core.polling.AsyncPollingMethod + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of AsyncLROPoller that returns either GenericResource or the result of + cls(response) + :rtype: + ~azure.core.polling.AsyncLROPoller[~azure.mgmt.resource.resources.v2019_08_01.models.GenericResource] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = kwargs.pop("params", {}) or {} + + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.GenericResource] + polling = kwargs.pop("polling", True) # type: Union[bool, AsyncPollingMethod] + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token = kwargs.pop("continuation_token", None) # type: Optional[str] if cont_token is None: - raw_result = await self._update_by_id_initial( + raw_result = await self._update_by_id_initial( # type: ignore resource_id=resource_id, api_version=api_version, parameters=parameters, content_type=content_type, - cls=lambda x,y,z: x, + cls=lambda x, y, z: x, + headers=_headers, + params=_params, **kwargs ) - kwargs.pop('error_map', None) + kwargs.pop("error_map", None) def get_long_running_output(pipeline_response): - response = pipeline_response.http_response - deserialized = self._deserialize('GenericResource', pipeline_response) + deserialized = self._deserialize("GenericResource", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - - if polling is True: polling_method = AsyncARMPolling(lro_delay, **kwargs) - elif polling is False: polling_method = AsyncNoPolling() - else: polling_method = polling + if polling is True: + polling_method = cast(AsyncPollingMethod, AsyncARMPolling(lro_delay, **kwargs)) # type: AsyncPollingMethod + elif polling is False: + polling_method = cast(AsyncPollingMethod, AsyncNoPolling()) + else: + polling_method = polling if cont_token: return AsyncLROPoller.from_continuation_token( polling_method=polling_method, continuation_token=cont_token, client=self._client, - deserialization_callback=get_long_running_output + deserialization_callback=get_long_running_output, ) return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) - begin_update_by_id.metadata = {'url': "/{resourceId}"} # type: ignore + begin_update_by_id.metadata = {"url": "/{resourceId}"} # type: ignore @distributed_trace_async - async def get_by_id( - self, - resource_id: str, - api_version: str, - **kwargs: Any - ) -> "_models.GenericResource": + async def get_by_id(self, resource_id: str, api_version: str, **kwargs: Any) -> _models.GenericResource: """Gets a resource by ID. :param resource_id: The fully qualified ID of the resource, including the resource name and resource type. Use the format, /subscriptions/{guid}/resourceGroups/{resource-group-name}/{resource-provider-namespace}/{resource-type}/{resource-name}. + Required. :type resource_id: str - :param api_version: The API version to use for the operation. + :param api_version: The API version to use for the operation. Required. :type api_version: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: GenericResource, or the result of cls(response) + :return: GenericResource or the result of cls(response) :rtype: ~azure.mgmt.resource.resources.v2019_08_01.models.GenericResource - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.GenericResource"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = kwargs.pop("params", {}) or {} + + cls = kwargs.pop("cls", None) # type: ClsType[_models.GenericResource] - request = build_resources_get_by_id_request( resource_id=resource_id, api_version=api_version, - template_url=self.get_by_id.metadata['url'], + template_url=self.get_by_id.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) - deserialized = self._deserialize('GenericResource', pipeline_response) + deserialized = self._deserialize("GenericResource", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - get_by_id.metadata = {'url': "/{resourceId}"} # type: ignore + get_by_id.metadata = {"url": "/{resourceId}"} # type: ignore -class ResourceGroupsOperations: - """ResourceGroupsOperations async operations. - You should not instantiate this class directly. Instead, you should create a Client instance that - instantiates it for you and attaches it as an attribute. +class ResourceGroupsOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. - :ivar models: Alias to model classes used in this operation group. - :type models: ~azure.mgmt.resource.resources.v2019_08_01.models - :param client: Client for service requests. - :param config: Configuration of service client. - :param serializer: An object model serializer. - :param deserializer: An object model deserializer. + Instead, you should access the following operations through + :class:`~azure.mgmt.resource.resources.v2019_08_01.aio.ResourceManagementClient`'s + :attr:`resource_groups` attribute. """ models = _models - def __init__(self, client, config, serializer, deserializer) -> None: - self._client = client - self._serialize = serializer - self._deserialize = deserializer - self._config = config + def __init__(self, *args, **kwargs) -> None: + input_args = list(args) + self._client = input_args.pop(0) if input_args else kwargs.pop("client") + self._config = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") @distributed_trace_async - async def check_existence( - self, - resource_group_name: str, - **kwargs: Any - ) -> bool: + async def check_existence(self, resource_group_name: str, **kwargs: Any) -> bool: """Checks whether a resource group exists. :param resource_group_name: The name of the resource group to check. The name is case - insensitive. + insensitive. Required. :type resource_group_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: bool, or the result of cls(response) + :return: bool or the result of cls(response) :rtype: bool - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType[None] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + 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', "2019-08-01") # type: str + api_version = kwargs.pop("api_version", _params.pop("api-version", "2019-08-01")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[None] - request = build_resource_groups_check_existence_request( resource_group_name=resource_group_name, subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.check_existence.metadata['url'], + template_url=self.check_existence.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [204, 404]: @@ -5460,39 +7157,98 @@ async def check_existence( return cls(pipeline_response, None, {}) return 200 <= response.status_code <= 299 - check_existence.metadata = {'url': "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}"} # type: ignore - + check_existence.metadata = {"url": "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}"} # type: ignore - @distributed_trace_async + @overload async def create_or_update( self, resource_group_name: str, - parameters: "_models.ResourceGroup", + parameters: _models.ResourceGroup, + *, + content_type: str = "application/json", **kwargs: Any - ) -> "_models.ResourceGroup": + ) -> _models.ResourceGroup: """Creates or updates a resource group. :param resource_group_name: The name of the resource group to create or update. Can include alphanumeric, underscore, parentheses, hyphen, period (except at end), and Unicode characters - that match the allowed characters. + that match the allowed characters. Required. :type resource_group_name: str - :param parameters: Parameters supplied to the create or update a resource group. + :param parameters: Parameters supplied to the create or update a resource group. Required. :type parameters: ~azure.mgmt.resource.resources.v2019_08_01.models.ResourceGroup + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: ResourceGroup or the result of cls(response) + :rtype: ~azure.mgmt.resource.resources.v2019_08_01.models.ResourceGroup + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + async def create_or_update( + self, resource_group_name: str, parameters: IO, *, content_type: str = "application/json", **kwargs: Any + ) -> _models.ResourceGroup: + """Creates or updates a resource group. + + :param resource_group_name: The name of the resource group to create or update. Can include + alphanumeric, underscore, parentheses, hyphen, period (except at end), and Unicode characters + that match the allowed characters. Required. + :type resource_group_name: str + :param parameters: Parameters supplied to the create or update a resource group. Required. + :type parameters: IO + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: ResourceGroup or the result of cls(response) + :rtype: ~azure.mgmt.resource.resources.v2019_08_01.models.ResourceGroup + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace_async + async def create_or_update( + self, resource_group_name: str, parameters: Union[_models.ResourceGroup, IO], **kwargs: Any + ) -> _models.ResourceGroup: + """Creates or updates a resource group. + + :param resource_group_name: The name of the resource group to create or update. Can include + alphanumeric, underscore, parentheses, hyphen, period (except at end), and Unicode characters + that match the allowed characters. Required. + :type resource_group_name: str + :param parameters: Parameters supplied to the create or update a resource group. Is either a + model type or a IO type. Required. + :type parameters: ~azure.mgmt.resource.resources.v2019_08_01.models.ResourceGroup or IO + :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. + Default value is None. + :paramtype content_type: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: ResourceGroup, or the result of cls(response) + :return: ResourceGroup or the result of cls(response) :rtype: ~azure.mgmt.resource.resources.v2019_08_01.models.ResourceGroup - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.ResourceGroup"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', "2019-08-01") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + api_version = kwargs.pop("api_version", _params.pop("api-version", "2019-08-01")) # type: str + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.ResourceGroup] - _json = self._serialize.body(parameters, 'ResourceGroup') + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(parameters, (IO, bytes)): + _content = parameters + else: + _json = self._serialize.body(parameters, "ResourceGroup") request = build_resource_groups_create_or_update_request( resource_group_name=resource_group_name, @@ -5500,16 +7256,18 @@ async def create_or_update( api_version=api_version, content_type=content_type, json=_json, - template_url=self.create_or_update.metadata['url'], + content=_content, + template_url=self.create_or_update.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200, 201]: @@ -5517,47 +7275,50 @@ async def create_or_update( raise HttpResponseError(response=response, error_format=ARMErrorFormat) if response.status_code == 200: - deserialized = self._deserialize('ResourceGroup', pipeline_response) + deserialized = self._deserialize("ResourceGroup", pipeline_response) if response.status_code == 201: - deserialized = self._deserialize('ResourceGroup', pipeline_response) + deserialized = self._deserialize("ResourceGroup", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - create_or_update.metadata = {'url': "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}"} # type: ignore - + create_or_update.metadata = {"url": "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}"} # type: ignore async def _delete_initial( # pylint: disable=inconsistent-return-statements - self, - resource_group_name: str, - **kwargs: Any + self, resource_group_name: str, **kwargs: Any ) -> None: - cls = kwargs.pop('cls', None) # type: ClsType[None] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + 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', "2019-08-01") # type: str + api_version = kwargs.pop("api_version", _params.pop("api-version", "2019-08-01")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[None] - - request = build_resource_groups_delete_request_initial( + request = build_resource_groups_delete_request( resource_group_name=resource_group_name, subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self._delete_initial.metadata['url'], + template_url=self._delete_initial.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200, 202]: @@ -5567,22 +7328,17 @@ async def _delete_initial( # pylint: disable=inconsistent-return-statements if cls: return cls(pipeline_response, None, {}) - _delete_initial.metadata = {'url': "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}"} # type: ignore - + _delete_initial.metadata = {"url": "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}"} # type: ignore @distributed_trace_async - async def begin_delete( # pylint: disable=inconsistent-return-statements - self, - resource_group_name: str, - **kwargs: Any - ) -> AsyncLROPoller[None]: + async def begin_delete(self, resource_group_name: str, **kwargs: Any) -> AsyncLROPoller[None]: """Deletes a resource group. When you delete a resource group, all of its resources are also deleted. Deleting a resource group deletes all of its template deployments and currently stored operations. :param resource_group_name: The name of the resource group to delete. The name is case - insensitive. + insensitive. Required. :type resource_group_name: str :keyword callable cls: A custom type or function that will be passed the direct response :keyword str continuation_token: A continuation token to restart a poller from a saved state. @@ -5594,106 +7350,161 @@ async def begin_delete( # pylint: disable=inconsistent-return-statements Retry-After header is present. :return: An instance of AsyncLROPoller that returns either None or the result of cls(response) :rtype: ~azure.core.polling.AsyncLROPoller[None] - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - api_version = kwargs.pop('api_version', "2019-08-01") # type: str - polling = kwargs.pop('polling', True) # type: Union[bool, AsyncPollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType[None] - lro_delay = kwargs.pop( - 'polling_interval', - self._config.polling_interval - ) - cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2019-08-01")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[None] + polling = kwargs.pop("polling", True) # type: Union[bool, AsyncPollingMethod] + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token = kwargs.pop("continuation_token", None) # type: Optional[str] if cont_token is None: - raw_result = await self._delete_initial( + raw_result = await self._delete_initial( # type: ignore resource_group_name=resource_group_name, api_version=api_version, - cls=lambda x,y,z: x, + cls=lambda x, y, z: x, + headers=_headers, + params=_params, **kwargs ) - kwargs.pop('error_map', None) + kwargs.pop("error_map", None) - def get_long_running_output(pipeline_response): + def get_long_running_output(pipeline_response): # pylint: disable=inconsistent-return-statements if cls: return cls(pipeline_response, None, {}) - - if polling is True: polling_method = AsyncARMPolling(lro_delay, **kwargs) - elif polling is False: polling_method = AsyncNoPolling() - else: polling_method = polling + if polling is True: + polling_method = cast(AsyncPollingMethod, AsyncARMPolling(lro_delay, **kwargs)) # type: AsyncPollingMethod + elif polling is False: + polling_method = cast(AsyncPollingMethod, AsyncNoPolling()) + else: + polling_method = polling if cont_token: return AsyncLROPoller.from_continuation_token( polling_method=polling_method, continuation_token=cont_token, client=self._client, - deserialization_callback=get_long_running_output + deserialization_callback=get_long_running_output, ) return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) - begin_delete.metadata = {'url': "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}"} # type: ignore + begin_delete.metadata = {"url": "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}"} # type: ignore @distributed_trace_async - async def get( - self, - resource_group_name: str, - **kwargs: Any - ) -> "_models.ResourceGroup": + async def get(self, resource_group_name: str, **kwargs: Any) -> _models.ResourceGroup: """Gets a resource group. :param resource_group_name: The name of the resource group to get. The name is case - insensitive. + insensitive. Required. :type resource_group_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: ResourceGroup, or the result of cls(response) + :return: ResourceGroup or the result of cls(response) :rtype: ~azure.mgmt.resource.resources.v2019_08_01.models.ResourceGroup - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.ResourceGroup"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + 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', "2019-08-01") # type: str + api_version = kwargs.pop("api_version", _params.pop("api-version", "2019-08-01")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[_models.ResourceGroup] - request = build_resource_groups_get_request( resource_group_name=resource_group_name, subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.get.metadata['url'], + template_url=self.get.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) - deserialized = self._deserialize('ResourceGroup', pipeline_response) + deserialized = self._deserialize("ResourceGroup", pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + + get.metadata = {"url": "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}"} # type: ignore + + @overload + async def update( + self, + resource_group_name: str, + parameters: _models.ResourceGroupPatchable, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.ResourceGroup: + """Updates a resource group. + + Resource groups can be updated through a simple PATCH operation to a group address. The format + of the request is the same as that for creating a resource group. If a field is unspecified, + the current value is retained. - if cls: - return cls(pipeline_response, deserialized, {}) + :param resource_group_name: The name of the resource group to update. The name is case + insensitive. Required. + :type resource_group_name: str + :param parameters: Parameters supplied to update a resource group. Required. + :type parameters: ~azure.mgmt.resource.resources.v2019_08_01.models.ResourceGroupPatchable + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: ResourceGroup or the result of cls(response) + :rtype: ~azure.mgmt.resource.resources.v2019_08_01.models.ResourceGroup + :raises ~azure.core.exceptions.HttpResponseError: + """ - return deserialized + @overload + async def update( + self, resource_group_name: str, parameters: IO, *, content_type: str = "application/json", **kwargs: Any + ) -> _models.ResourceGroup: + """Updates a resource group. - get.metadata = {'url': "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}"} # type: ignore + Resource groups can be updated through a simple PATCH operation to a group address. The format + of the request is the same as that for creating a resource group. If a field is unspecified, + the current value is retained. + :param resource_group_name: The name of the resource group to update. The name is case + insensitive. Required. + :type resource_group_name: str + :param parameters: Parameters supplied to update a resource group. Required. + :type parameters: IO + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: ResourceGroup or the result of cls(response) + :rtype: ~azure.mgmt.resource.resources.v2019_08_01.models.ResourceGroup + :raises ~azure.core.exceptions.HttpResponseError: + """ @distributed_trace_async async def update( - self, - resource_group_name: str, - parameters: "_models.ResourceGroupPatchable", - **kwargs: Any - ) -> "_models.ResourceGroup": + self, resource_group_name: str, parameters: Union[_models.ResourceGroupPatchable, IO], **kwargs: Any + ) -> _models.ResourceGroup: """Updates a resource group. Resource groups can be updated through a simple PATCH operation to a group address. The format @@ -5701,25 +7512,42 @@ async def update( the current value is retained. :param resource_group_name: The name of the resource group to update. The name is case - insensitive. + insensitive. Required. :type resource_group_name: str - :param parameters: Parameters supplied to update a resource group. - :type parameters: ~azure.mgmt.resource.resources.v2019_08_01.models.ResourceGroupPatchable + :param parameters: Parameters supplied to update a resource group. Is either a model type or a + IO type. Required. + :type parameters: ~azure.mgmt.resource.resources.v2019_08_01.models.ResourceGroupPatchable or + IO + :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. + Default value is None. + :paramtype content_type: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: ResourceGroup, or the result of cls(response) + :return: ResourceGroup or the result of cls(response) :rtype: ~azure.mgmt.resource.resources.v2019_08_01.models.ResourceGroup - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.ResourceGroup"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', "2019-08-01") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + api_version = kwargs.pop("api_version", _params.pop("api-version", "2019-08-01")) # type: str + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.ResourceGroup] - _json = self._serialize.body(parameters, 'ResourceGroupPatchable') + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(parameters, (IO, bytes)): + _content = parameters + else: + _json = self._serialize.body(parameters, "ResourceGroupPatchable") request = build_resource_groups_update_request( resource_group_name=resource_group_name, @@ -5727,65 +7555,77 @@ async def update( api_version=api_version, content_type=content_type, json=_json, - template_url=self.update.metadata['url'], + content=_content, + template_url=self.update.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) - deserialized = self._deserialize('ResourceGroup', pipeline_response) + deserialized = self._deserialize("ResourceGroup", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - update.metadata = {'url': "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}"} # type: ignore - + update.metadata = {"url": "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}"} # type: ignore async def _export_template_initial( - self, - resource_group_name: str, - parameters: "_models.ExportTemplateRequest", - **kwargs: Any - ) -> Optional["_models.ResourceGroupExportResult"]: - cls = kwargs.pop('cls', None) # type: ClsType[Optional["_models.ResourceGroupExportResult"]] + self, resource_group_name: str, parameters: Union[_models.ExportTemplateRequest, IO], **kwargs: Any + ) -> Optional[_models.ResourceGroupExportResult]: error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) - api_version = kwargs.pop('api_version', "2019-08-01") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - _json = self._serialize.body(parameters, 'ExportTemplateRequest') + api_version = kwargs.pop("api_version", _params.pop("api-version", "2019-08-01")) # type: str + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[Optional[_models.ResourceGroupExportResult]] - request = build_resource_groups_export_template_request_initial( - subscription_id=self._config.subscription_id, + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(parameters, (IO, bytes)): + _content = parameters + else: + _json = self._serialize.body(parameters, "ExportTemplateRequest") + + request = build_resource_groups_export_template_request( resource_group_name=resource_group_name, + subscription_id=self._config.subscription_id, api_version=api_version, content_type=content_type, json=_json, - template_url=self._export_template_initial.metadata['url'], + content=_content, + template_url=self._export_template_initial.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200, 202]: @@ -5794,29 +7634,34 @@ async def _export_template_initial( deserialized = None if response.status_code == 200: - deserialized = self._deserialize('ResourceGroupExportResult', pipeline_response) + deserialized = self._deserialize("ResourceGroupExportResult", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - _export_template_initial.metadata = {'url': "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/exportTemplate"} # type: ignore - + _export_template_initial.metadata = {"url": "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/exportTemplate"} # type: ignore - @distributed_trace_async + @overload async def begin_export_template( self, resource_group_name: str, - parameters: "_models.ExportTemplateRequest", + parameters: _models.ExportTemplateRequest, + *, + content_type: str = "application/json", **kwargs: Any - ) -> AsyncLROPoller["_models.ResourceGroupExportResult"]: + ) -> AsyncLROPoller[_models.ResourceGroupExportResult]: """Captures the specified resource group as a template. :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. :type resource_group_name: str - :param parameters: Parameters for exporting the template. + :param parameters: Parameters for exporting the template. Required. :type parameters: ~azure.mgmt.resource.resources.v2019_08_01.models.ExportTemplateRequest + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str :keyword callable cls: A custom type or function that will be passed the direct response :keyword str continuation_token: A continuation token to restart a poller from a saved state. :keyword polling: By default, your polling method will be AsyncARMPolling. Pass in False for @@ -5829,57 +7674,118 @@ async def begin_export_template( result of cls(response) :rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.resource.resources.v2019_08_01.models.ResourceGroupExportResult] - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - api_version = kwargs.pop('api_version', "2019-08-01") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] - polling = kwargs.pop('polling', True) # type: Union[bool, AsyncPollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType["_models.ResourceGroupExportResult"] - lro_delay = kwargs.pop( - 'polling_interval', - self._config.polling_interval - ) - cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] + + @overload + async def begin_export_template( + self, resource_group_name: str, parameters: IO, *, content_type: str = "application/json", **kwargs: Any + ) -> AsyncLROPoller[_models.ResourceGroupExportResult]: + """Captures the specified resource group as a template. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param parameters: Parameters for exporting the template. Required. + :type parameters: IO + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be AsyncARMPolling. Pass in False for + this operation to not poll, or pass in your own initialized polling object for a personal + polling strategy. + :paramtype polling: bool or ~azure.core.polling.AsyncPollingMethod + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of AsyncLROPoller that returns either ResourceGroupExportResult or the + result of cls(response) + :rtype: + ~azure.core.polling.AsyncLROPoller[~azure.mgmt.resource.resources.v2019_08_01.models.ResourceGroupExportResult] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace_async + async def begin_export_template( + self, resource_group_name: str, parameters: Union[_models.ExportTemplateRequest, IO], **kwargs: Any + ) -> AsyncLROPoller[_models.ResourceGroupExportResult]: + """Captures the specified resource group as a template. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param parameters: Parameters for exporting the template. Is either a model type or a IO type. + Required. + :type parameters: ~azure.mgmt.resource.resources.v2019_08_01.models.ExportTemplateRequest or IO + :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. + Default value is None. + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be AsyncARMPolling. Pass in False for + this operation to not poll, or pass in your own initialized polling object for a personal + polling strategy. + :paramtype polling: bool or ~azure.core.polling.AsyncPollingMethod + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of AsyncLROPoller that returns either ResourceGroupExportResult or the + result of cls(response) + :rtype: + ~azure.core.polling.AsyncLROPoller[~azure.mgmt.resource.resources.v2019_08_01.models.ResourceGroupExportResult] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _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", "2019-08-01")) # type: str + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.ResourceGroupExportResult] + polling = kwargs.pop("polling", True) # type: Union[bool, AsyncPollingMethod] + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token = kwargs.pop("continuation_token", None) # type: Optional[str] if cont_token is None: - raw_result = await self._export_template_initial( + raw_result = await self._export_template_initial( # type: ignore resource_group_name=resource_group_name, parameters=parameters, api_version=api_version, content_type=content_type, - cls=lambda x,y,z: x, + cls=lambda x, y, z: x, + headers=_headers, + params=_params, **kwargs ) - kwargs.pop('error_map', None) + kwargs.pop("error_map", None) def get_long_running_output(pipeline_response): - response = pipeline_response.http_response - deserialized = self._deserialize('ResourceGroupExportResult', pipeline_response) + deserialized = self._deserialize("ResourceGroupExportResult", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - - if polling is True: polling_method = AsyncARMPolling(lro_delay, lro_options={'final-state-via': 'location'}, **kwargs) - elif polling is False: polling_method = AsyncNoPolling() - else: polling_method = polling + if polling is True: + polling_method = cast( + AsyncPollingMethod, AsyncARMPolling(lro_delay, lro_options={"final-state-via": "location"}, **kwargs) + ) # type: AsyncPollingMethod + elif polling is False: + polling_method = cast(AsyncPollingMethod, AsyncNoPolling()) + else: + polling_method = polling if cont_token: return AsyncLROPoller.from_continuation_token( polling_method=polling_method, continuation_token=cont_token, client=self._client, - deserialization_callback=get_long_running_output + deserialization_callback=get_long_running_output, ) return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) - begin_export_template.metadata = {'url': "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/exportTemplate"} # type: ignore + begin_export_template.metadata = {"url": "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/exportTemplate"} # type: ignore @distributed_trace def list( - self, - filter: Optional[str] = None, - top: Optional[int] = None, - **kwargs: Any - ) -> AsyncIterable["_models.ResourceGroupListResult"]: + self, filter: Optional[str] = None, top: Optional[int] = None, **kwargs: Any + ) -> AsyncIterable["_models.ResourceGroup"]: """Gets all the resource groups for a subscription. :param filter: The filter to apply on the operation.:code:`
`:code:`
`You can filter by @@ -5890,40 +7796,48 @@ def list( Default value is None. :type top: int :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either ResourceGroupListResult or the result of - cls(response) + :return: An iterator like instance of either ResourceGroup or the result of cls(response) :rtype: - ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.resource.resources.v2019_08_01.models.ResourceGroupListResult] - :raises: ~azure.core.exceptions.HttpResponseError + ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.resource.resources.v2019_08_01.models.ResourceGroup] + :raises ~azure.core.exceptions.HttpResponseError: """ - api_version = kwargs.pop('api_version', "2019-08-01") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2019-08-01")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[_models.ResourceGroupListResult] - cls = kwargs.pop('cls', None) # type: ClsType["_models.ResourceGroupListResult"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) + def prepare_request(next_link=None): if not next_link: - + request = build_resource_groups_list_request( subscription_id=self._config.subscription_id, - api_version=api_version, filter=filter, top=top, - template_url=self.list.metadata['url'], + 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.url = self._client.format_url(request.url) # type: ignore else: - - request = build_resource_groups_list_request( - subscription_id=self._config.subscription_id, - template_url=next_link, - ) + # make call to next link with the client's api-version + _parsed_next_link = urlparse(next_link) + _next_request_params = case_insensitive_dict(parse_qs(_parsed_next_link.query)) + _next_request_params["api-version"] = self._config.api_version + request = HttpRequest("GET", urljoin(next_link, _parsed_next_link.path), params=_next_request_params) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore request.method = "GET" return request @@ -5937,10 +7851,8 @@ async def extract_data(pipeline_response): async def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) response = pipeline_response.http_response @@ -5950,75 +7862,75 @@ async def get_next(next_link=None): return pipeline_response + return AsyncItemPaged(get_next, extract_data) - return AsyncItemPaged( - get_next, extract_data - ) - list.metadata = {'url': "/subscriptions/{subscriptionId}/resourcegroups"} # type: ignore -class TagsOperations: - """TagsOperations async operations. + list.metadata = {"url": "/subscriptions/{subscriptionId}/resourcegroups"} # type: ignore - You should not instantiate this class directly. Instead, you should create a Client instance that - instantiates it for you and attaches it as an attribute. - :ivar models: Alias to model classes used in this operation group. - :type models: ~azure.mgmt.resource.resources.v2019_08_01.models - :param client: Client for service requests. - :param config: Configuration of service client. - :param serializer: An object model serializer. - :param deserializer: An object model deserializer. +class TagsOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. + + Instead, you should access the following operations through + :class:`~azure.mgmt.resource.resources.v2019_08_01.aio.ResourceManagementClient`'s + :attr:`tags` attribute. """ models = _models - def __init__(self, client, config, serializer, deserializer) -> None: - self._client = client - self._serialize = serializer - self._deserialize = deserializer - self._config = config + def __init__(self, *args, **kwargs) -> None: + input_args = list(args) + self._client = input_args.pop(0) if input_args else kwargs.pop("client") + self._config = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") @distributed_trace_async async def delete_value( # pylint: disable=inconsistent-return-statements - self, - tag_name: str, - tag_value: str, - **kwargs: Any + self, tag_name: str, tag_value: str, **kwargs: Any ) -> None: """Deletes a tag value. - :param tag_name: The name of the tag. + :param tag_name: The name of the tag. Required. :type tag_name: str - :param tag_value: The value of the tag to delete. + :param tag_value: The value of the tag to delete. Required. :type tag_value: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: None, or the result of cls(response) + :return: None or the result of cls(response) :rtype: None - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType[None] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + 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', "2019-08-01") # type: str + api_version = kwargs.pop("api_version", _params.pop("api-version", "2019-08-01")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[None] - request = build_tags_delete_value_request( tag_name=tag_name, tag_value=tag_value, subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.delete_value.metadata['url'], + template_url=self.delete_value.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200, 204]: @@ -6028,51 +7940,51 @@ async def delete_value( # pylint: disable=inconsistent-return-statements if cls: return cls(pipeline_response, None, {}) - delete_value.metadata = {'url': "/subscriptions/{subscriptionId}/tagNames/{tagName}/tagValues/{tagValue}"} # type: ignore - + delete_value.metadata = {"url": "/subscriptions/{subscriptionId}/tagNames/{tagName}/tagValues/{tagValue}"} # type: ignore @distributed_trace_async - async def create_or_update_value( - self, - tag_name: str, - tag_value: str, - **kwargs: Any - ) -> "_models.TagValue": + async def create_or_update_value(self, tag_name: str, tag_value: str, **kwargs: Any) -> _models.TagValue: """Creates a tag value. The name of the tag must already exist. - :param tag_name: The name of the tag. + :param tag_name: The name of the tag. Required. :type tag_name: str - :param tag_value: The value of the tag to create. + :param tag_value: The value of the tag to create. Required. :type tag_value: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: TagValue, or the result of cls(response) + :return: TagValue or the result of cls(response) :rtype: ~azure.mgmt.resource.resources.v2019_08_01.models.TagValue - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.TagValue"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) - api_version = kwargs.pop('api_version', "2019-08-01") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2019-08-01")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[_models.TagValue] - request = build_tags_create_or_update_value_request( tag_name=tag_name, tag_value=tag_value, subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.create_or_update_value.metadata['url'], + template_url=self.create_or_update_value.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200, 201]: @@ -6080,61 +7992,62 @@ async def create_or_update_value( raise HttpResponseError(response=response, error_format=ARMErrorFormat) if response.status_code == 200: - deserialized = self._deserialize('TagValue', pipeline_response) + deserialized = self._deserialize("TagValue", pipeline_response) if response.status_code == 201: - deserialized = self._deserialize('TagValue', pipeline_response) + deserialized = self._deserialize("TagValue", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - create_or_update_value.metadata = {'url': "/subscriptions/{subscriptionId}/tagNames/{tagName}/tagValues/{tagValue}"} # type: ignore - + create_or_update_value.metadata = {"url": "/subscriptions/{subscriptionId}/tagNames/{tagName}/tagValues/{tagValue}"} # type: ignore @distributed_trace_async - async def create_or_update( - self, - tag_name: str, - **kwargs: Any - ) -> "_models.TagDetails": + async def create_or_update(self, tag_name: str, **kwargs: Any) -> _models.TagDetails: """Creates a tag in the subscription. The tag name can have a maximum of 512 characters and is case insensitive. Tag names created by Azure have prefixes of microsoft, azure, or windows. You cannot create tags with one of these prefixes. - :param tag_name: The name of the tag to create. + :param tag_name: The name of the tag to create. Required. :type tag_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: TagDetails, or the result of cls(response) + :return: TagDetails or the result of cls(response) :rtype: ~azure.mgmt.resource.resources.v2019_08_01.models.TagDetails - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.TagDetails"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) - api_version = kwargs.pop('api_version', "2019-08-01") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2019-08-01")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[_models.TagDetails] - request = build_tags_create_or_update_request( tag_name=tag_name, subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.create_or_update.metadata['url'], + template_url=self.create_or_update.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200, 201]: @@ -6142,59 +8055,60 @@ async def create_or_update( raise HttpResponseError(response=response, error_format=ARMErrorFormat) if response.status_code == 200: - deserialized = self._deserialize('TagDetails', pipeline_response) + deserialized = self._deserialize("TagDetails", pipeline_response) if response.status_code == 201: - deserialized = self._deserialize('TagDetails', pipeline_response) + deserialized = self._deserialize("TagDetails", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - create_or_update.metadata = {'url': "/subscriptions/{subscriptionId}/tagNames/{tagName}"} # type: ignore - + create_or_update.metadata = {"url": "/subscriptions/{subscriptionId}/tagNames/{tagName}"} # type: ignore @distributed_trace_async - async def delete( # pylint: disable=inconsistent-return-statements - self, - tag_name: str, - **kwargs: Any - ) -> None: + async def delete(self, tag_name: str, **kwargs: Any) -> None: # pylint: disable=inconsistent-return-statements """Deletes a tag from the subscription. You must remove all values from a resource tag before you can delete it. - :param tag_name: The name of the tag. + :param tag_name: The name of the tag. Required. :type tag_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: None, or the result of cls(response) + :return: None or the result of cls(response) :rtype: None - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType[None] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) - api_version = kwargs.pop('api_version', "2019-08-01") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2019-08-01")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[None] - request = build_tags_delete_request( tag_name=tag_name, subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.delete.metadata['url'], + template_url=self.delete.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200, 204]: @@ -6204,48 +8118,53 @@ async def delete( # pylint: disable=inconsistent-return-statements if cls: return cls(pipeline_response, None, {}) - delete.metadata = {'url': "/subscriptions/{subscriptionId}/tagNames/{tagName}"} # type: ignore - + delete.metadata = {"url": "/subscriptions/{subscriptionId}/tagNames/{tagName}"} # type: ignore @distributed_trace - def list( - self, - **kwargs: Any - ) -> AsyncIterable["_models.TagsListResult"]: + def list(self, **kwargs: Any) -> AsyncIterable["_models.TagDetails"]: """Gets the names and values of all resource tags that are defined in a subscription. :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either TagsListResult or the result of cls(response) + :return: An iterator like instance of either TagDetails or the result of cls(response) :rtype: - ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.resource.resources.v2019_08_01.models.TagsListResult] - :raises: ~azure.core.exceptions.HttpResponseError + ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.resource.resources.v2019_08_01.models.TagDetails] + :raises ~azure.core.exceptions.HttpResponseError: """ - api_version = kwargs.pop('api_version', "2019-08-01") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2019-08-01")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[_models.TagsListResult] - cls = kwargs.pop('cls', None) # type: ClsType["_models.TagsListResult"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) + def prepare_request(next_link=None): if not next_link: - + request = build_tags_list_request( subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.list.metadata['url'], + template_url=self.list.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore else: - - request = build_tags_list_request( - subscription_id=self._config.subscription_id, - template_url=next_link, - ) + # make call to next link with the client's api-version + _parsed_next_link = urlparse(next_link) + _next_request_params = case_insensitive_dict(parse_qs(_parsed_next_link.query)) + _next_request_params["api-version"] = self._config.api_version + request = HttpRequest("GET", urljoin(next_link, _parsed_next_link.path), params=_next_request_params) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore request.method = "GET" return request @@ -6259,10 +8178,8 @@ async def extract_data(pipeline_response): async def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) response = pipeline_response.http_response @@ -6272,146 +8189,147 @@ async def get_next(next_link=None): return pipeline_response + return AsyncItemPaged(get_next, extract_data) + + list.metadata = {"url": "/subscriptions/{subscriptionId}/tagNames"} # type: ignore - return AsyncItemPaged( - get_next, extract_data - ) - list.metadata = {'url': "/subscriptions/{subscriptionId}/tagNames"} # type: ignore -class DeploymentOperationsOperations: - """DeploymentOperationsOperations async operations. - You should not instantiate this class directly. Instead, you should create a Client instance that - instantiates it for you and attaches it as an attribute. +class DeploymentOperationsOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. - :ivar models: Alias to model classes used in this operation group. - :type models: ~azure.mgmt.resource.resources.v2019_08_01.models - :param client: Client for service requests. - :param config: Configuration of service client. - :param serializer: An object model serializer. - :param deserializer: An object model deserializer. + Instead, you should access the following operations through + :class:`~azure.mgmt.resource.resources.v2019_08_01.aio.ResourceManagementClient`'s + :attr:`deployment_operations` attribute. """ models = _models - def __init__(self, client, config, serializer, deserializer) -> None: - self._client = client - self._serialize = serializer - self._deserialize = deserializer - self._config = config + def __init__(self, *args, **kwargs) -> None: + input_args = list(args) + self._client = input_args.pop(0) if input_args else kwargs.pop("client") + self._config = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") @distributed_trace_async async def get_at_scope( - self, - scope: str, - deployment_name: str, - operation_id: str, - **kwargs: Any - ) -> "_models.DeploymentOperation": + self, scope: str, deployment_name: str, operation_id: str, **kwargs: Any + ) -> _models.DeploymentOperation: """Gets a deployments operation. - :param scope: The scope of a deployment. + :param scope: The scope of a deployment. Required. :type scope: str - :param deployment_name: The name of the deployment. + :param deployment_name: The name of the deployment. Required. :type deployment_name: str - :param operation_id: The ID of the operation to get. + :param operation_id: The ID of the operation to get. Required. :type operation_id: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: DeploymentOperation, or the result of cls(response) + :return: DeploymentOperation or the result of cls(response) :rtype: ~azure.mgmt.resource.resources.v2019_08_01.models.DeploymentOperation - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.DeploymentOperation"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) - api_version = kwargs.pop('api_version', "2019-08-01") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2019-08-01")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[_models.DeploymentOperation] - request = build_deployment_operations_get_at_scope_request( scope=scope, deployment_name=deployment_name, operation_id=operation_id, api_version=api_version, - template_url=self.get_at_scope.metadata['url'], + template_url=self.get_at_scope.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) - deserialized = self._deserialize('DeploymentOperation', pipeline_response) + deserialized = self._deserialize("DeploymentOperation", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - get_at_scope.metadata = {'url': "/{scope}/providers/Microsoft.Resources/deployments/{deploymentName}/operations/{operationId}"} # type: ignore - + get_at_scope.metadata = {"url": "/{scope}/providers/Microsoft.Resources/deployments/{deploymentName}/operations/{operationId}"} # type: ignore @distributed_trace def list_at_scope( - self, - scope: str, - deployment_name: str, - top: Optional[int] = None, - **kwargs: Any - ) -> AsyncIterable["_models.DeploymentOperationsListResult"]: + self, scope: str, deployment_name: str, top: Optional[int] = None, **kwargs: Any + ) -> AsyncIterable["_models.DeploymentOperation"]: """Gets all deployments operations for a deployment. - :param scope: The scope of a deployment. + :param scope: The scope of a deployment. Required. :type scope: str - :param deployment_name: The name of the deployment. + :param deployment_name: The name of the deployment. Required. :type deployment_name: str :param top: The number of results to return. Default value is None. :type top: int :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either DeploymentOperationsListResult or the result of - cls(response) + :return: An iterator like instance of either DeploymentOperation or the result of cls(response) :rtype: - ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.resource.resources.v2019_08_01.models.DeploymentOperationsListResult] - :raises: ~azure.core.exceptions.HttpResponseError + ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.resource.resources.v2019_08_01.models.DeploymentOperation] + :raises ~azure.core.exceptions.HttpResponseError: """ - api_version = kwargs.pop('api_version', "2019-08-01") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2019-08-01")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[_models.DeploymentOperationsListResult] - cls = kwargs.pop('cls', None) # type: ClsType["_models.DeploymentOperationsListResult"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) + def prepare_request(next_link=None): if not next_link: - + request = build_deployment_operations_list_at_scope_request( scope=scope, deployment_name=deployment_name, - api_version=api_version, top=top, - template_url=self.list_at_scope.metadata['url'], + api_version=api_version, + template_url=self.list_at_scope.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore else: - - request = build_deployment_operations_list_at_scope_request( - scope=scope, - deployment_name=deployment_name, - template_url=next_link, - ) + # make call to next link with the client's api-version + _parsed_next_link = urlparse(next_link) + _next_request_params = case_insensitive_dict(parse_qs(_parsed_next_link.query)) + _next_request_params["api-version"] = self._config.api_version + request = HttpRequest("GET", urljoin(next_link, _parsed_next_link.path), params=_next_request_params) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore request.method = "GET" return request @@ -6425,10 +8343,8 @@ async def extract_data(pipeline_response): async def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) response = pipeline_response.http_response @@ -6438,116 +8354,121 @@ async def get_next(next_link=None): return pipeline_response + return AsyncItemPaged(get_next, extract_data) - return AsyncItemPaged( - get_next, extract_data - ) - list_at_scope.metadata = {'url': "/{scope}/providers/Microsoft.Resources/deployments/{deploymentName}/operations"} # type: ignore + list_at_scope.metadata = {"url": "/{scope}/providers/Microsoft.Resources/deployments/{deploymentName}/operations"} # type: ignore @distributed_trace_async async def get_at_tenant_scope( - self, - deployment_name: str, - operation_id: str, - **kwargs: Any - ) -> "_models.DeploymentOperation": + self, deployment_name: str, operation_id: str, **kwargs: Any + ) -> _models.DeploymentOperation: """Gets a deployments operation. - :param deployment_name: The name of the deployment. + :param deployment_name: The name of the deployment. Required. :type deployment_name: str - :param operation_id: The ID of the operation to get. + :param operation_id: The ID of the operation to get. Required. :type operation_id: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: DeploymentOperation, or the result of cls(response) + :return: DeploymentOperation or the result of cls(response) :rtype: ~azure.mgmt.resource.resources.v2019_08_01.models.DeploymentOperation - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.DeploymentOperation"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + 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', "2019-08-01") # type: str + api_version = kwargs.pop("api_version", _params.pop("api-version", "2019-08-01")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[_models.DeploymentOperation] - request = build_deployment_operations_get_at_tenant_scope_request( deployment_name=deployment_name, operation_id=operation_id, api_version=api_version, - template_url=self.get_at_tenant_scope.metadata['url'], + template_url=self.get_at_tenant_scope.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) - deserialized = self._deserialize('DeploymentOperation', pipeline_response) + deserialized = self._deserialize("DeploymentOperation", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - get_at_tenant_scope.metadata = {'url': "/providers/Microsoft.Resources/deployments/{deploymentName}/operations/{operationId}"} # type: ignore - + get_at_tenant_scope.metadata = {"url": "/providers/Microsoft.Resources/deployments/{deploymentName}/operations/{operationId}"} # type: ignore @distributed_trace def list_at_tenant_scope( - self, - deployment_name: str, - top: Optional[int] = None, - **kwargs: Any - ) -> AsyncIterable["_models.DeploymentOperationsListResult"]: + self, deployment_name: str, top: Optional[int] = None, **kwargs: Any + ) -> AsyncIterable["_models.DeploymentOperation"]: """Gets all deployments operations for a deployment. - :param deployment_name: The name of the deployment. + :param deployment_name: The name of the deployment. Required. :type deployment_name: str :param top: The number of results to return. Default value is None. :type top: int :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either DeploymentOperationsListResult or the result of - cls(response) + :return: An iterator like instance of either DeploymentOperation or the result of cls(response) :rtype: - ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.resource.resources.v2019_08_01.models.DeploymentOperationsListResult] - :raises: ~azure.core.exceptions.HttpResponseError + ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.resource.resources.v2019_08_01.models.DeploymentOperation] + :raises ~azure.core.exceptions.HttpResponseError: """ - api_version = kwargs.pop('api_version', "2019-08-01") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2019-08-01")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[_models.DeploymentOperationsListResult] - cls = kwargs.pop('cls', None) # type: ClsType["_models.DeploymentOperationsListResult"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) + def prepare_request(next_link=None): if not next_link: - + request = build_deployment_operations_list_at_tenant_scope_request( deployment_name=deployment_name, - api_version=api_version, top=top, - template_url=self.list_at_tenant_scope.metadata['url'], + api_version=api_version, + template_url=self.list_at_tenant_scope.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore else: - - request = build_deployment_operations_list_at_tenant_scope_request( - deployment_name=deployment_name, - template_url=next_link, - ) + # make call to next link with the client's api-version + _parsed_next_link = urlparse(next_link) + _next_request_params = case_insensitive_dict(parse_qs(_parsed_next_link.query)) + _next_request_params["api-version"] = self._config.api_version + request = HttpRequest("GET", urljoin(next_link, _parsed_next_link.path), params=_next_request_params) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore request.method = "GET" return request @@ -6561,10 +8482,8 @@ async def extract_data(pipeline_response): async def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) response = pipeline_response.http_response @@ -6574,125 +8493,127 @@ async def get_next(next_link=None): return pipeline_response + return AsyncItemPaged(get_next, extract_data) - return AsyncItemPaged( - get_next, extract_data - ) - list_at_tenant_scope.metadata = {'url': "/providers/Microsoft.Resources/deployments/{deploymentName}/operations"} # type: ignore + list_at_tenant_scope.metadata = {"url": "/providers/Microsoft.Resources/deployments/{deploymentName}/operations"} # type: ignore @distributed_trace_async async def get_at_management_group_scope( - self, - group_id: str, - deployment_name: str, - operation_id: str, - **kwargs: Any - ) -> "_models.DeploymentOperation": + self, group_id: str, deployment_name: str, operation_id: str, **kwargs: Any + ) -> _models.DeploymentOperation: """Gets a deployments operation. - :param group_id: The management group ID. + :param group_id: The management group ID. Required. :type group_id: str - :param deployment_name: The name of the deployment. + :param deployment_name: The name of the deployment. Required. :type deployment_name: str - :param operation_id: The ID of the operation to get. + :param operation_id: The ID of the operation to get. Required. :type operation_id: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: DeploymentOperation, or the result of cls(response) + :return: DeploymentOperation or the result of cls(response) :rtype: ~azure.mgmt.resource.resources.v2019_08_01.models.DeploymentOperation - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.DeploymentOperation"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + 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', "2019-08-01") # type: str + api_version = kwargs.pop("api_version", _params.pop("api-version", "2019-08-01")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[_models.DeploymentOperation] - request = build_deployment_operations_get_at_management_group_scope_request( group_id=group_id, deployment_name=deployment_name, operation_id=operation_id, api_version=api_version, - template_url=self.get_at_management_group_scope.metadata['url'], + template_url=self.get_at_management_group_scope.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) - deserialized = self._deserialize('DeploymentOperation', pipeline_response) + deserialized = self._deserialize("DeploymentOperation", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - get_at_management_group_scope.metadata = {'url': "/providers/Microsoft.Management/managementGroups/{groupId}/providers/Microsoft.Resources/deployments/{deploymentName}/operations/{operationId}"} # type: ignore - + get_at_management_group_scope.metadata = {"url": "/providers/Microsoft.Management/managementGroups/{groupId}/providers/Microsoft.Resources/deployments/{deploymentName}/operations/{operationId}"} # type: ignore @distributed_trace def list_at_management_group_scope( - self, - group_id: str, - deployment_name: str, - top: Optional[int] = None, - **kwargs: Any - ) -> AsyncIterable["_models.DeploymentOperationsListResult"]: + self, group_id: str, deployment_name: str, top: Optional[int] = None, **kwargs: Any + ) -> AsyncIterable["_models.DeploymentOperation"]: """Gets all deployments operations for a deployment. - :param group_id: The management group ID. + :param group_id: The management group ID. Required. :type group_id: str - :param deployment_name: The name of the deployment. + :param deployment_name: The name of the deployment. Required. :type deployment_name: str :param top: The number of results to return. Default value is None. :type top: int :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either DeploymentOperationsListResult or the result of - cls(response) + :return: An iterator like instance of either DeploymentOperation or the result of cls(response) :rtype: - ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.resource.resources.v2019_08_01.models.DeploymentOperationsListResult] - :raises: ~azure.core.exceptions.HttpResponseError + ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.resource.resources.v2019_08_01.models.DeploymentOperation] + :raises ~azure.core.exceptions.HttpResponseError: """ - api_version = kwargs.pop('api_version', "2019-08-01") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2019-08-01")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[_models.DeploymentOperationsListResult] - cls = kwargs.pop('cls', None) # type: ClsType["_models.DeploymentOperationsListResult"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) + def prepare_request(next_link=None): if not next_link: - + request = build_deployment_operations_list_at_management_group_scope_request( group_id=group_id, deployment_name=deployment_name, - api_version=api_version, top=top, - template_url=self.list_at_management_group_scope.metadata['url'], + api_version=api_version, + template_url=self.list_at_management_group_scope.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore else: - - request = build_deployment_operations_list_at_management_group_scope_request( - group_id=group_id, - deployment_name=deployment_name, - template_url=next_link, - ) + # make call to next link with the client's api-version + _parsed_next_link = urlparse(next_link) + _next_request_params = case_insensitive_dict(parse_qs(_parsed_next_link.query)) + _next_request_params["api-version"] = self._config.api_version + request = HttpRequest("GET", urljoin(next_link, _parsed_next_link.path), params=_next_request_params) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore request.method = "GET" return request @@ -6706,10 +8627,8 @@ async def extract_data(pipeline_response): async def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) response = pipeline_response.http_response @@ -6719,119 +8638,123 @@ async def get_next(next_link=None): return pipeline_response + return AsyncItemPaged(get_next, extract_data) - return AsyncItemPaged( - get_next, extract_data - ) - list_at_management_group_scope.metadata = {'url': "/providers/Microsoft.Management/managementGroups/{groupId}/providers/Microsoft.Resources/deployments/{deploymentName}/operations"} # type: ignore + list_at_management_group_scope.metadata = {"url": "/providers/Microsoft.Management/managementGroups/{groupId}/providers/Microsoft.Resources/deployments/{deploymentName}/operations"} # type: ignore @distributed_trace_async async def get_at_subscription_scope( - self, - deployment_name: str, - operation_id: str, - **kwargs: Any - ) -> "_models.DeploymentOperation": + self, deployment_name: str, operation_id: str, **kwargs: Any + ) -> _models.DeploymentOperation: """Gets a deployments operation. - :param deployment_name: The name of the deployment. + :param deployment_name: The name of the deployment. Required. :type deployment_name: str - :param operation_id: The ID of the operation to get. + :param operation_id: The ID of the operation to get. Required. :type operation_id: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: DeploymentOperation, or the result of cls(response) + :return: DeploymentOperation or the result of cls(response) :rtype: ~azure.mgmt.resource.resources.v2019_08_01.models.DeploymentOperation - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.DeploymentOperation"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) - api_version = kwargs.pop('api_version', "2019-08-01") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2019-08-01")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[_models.DeploymentOperation] - request = build_deployment_operations_get_at_subscription_scope_request( deployment_name=deployment_name, operation_id=operation_id, subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.get_at_subscription_scope.metadata['url'], + template_url=self.get_at_subscription_scope.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) - deserialized = self._deserialize('DeploymentOperation', pipeline_response) + deserialized = self._deserialize("DeploymentOperation", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - get_at_subscription_scope.metadata = {'url': "/subscriptions/{subscriptionId}/providers/Microsoft.Resources/deployments/{deploymentName}/operations/{operationId}"} # type: ignore - + get_at_subscription_scope.metadata = {"url": "/subscriptions/{subscriptionId}/providers/Microsoft.Resources/deployments/{deploymentName}/operations/{operationId}"} # type: ignore @distributed_trace def list_at_subscription_scope( - self, - deployment_name: str, - top: Optional[int] = None, - **kwargs: Any - ) -> AsyncIterable["_models.DeploymentOperationsListResult"]: + self, deployment_name: str, top: Optional[int] = None, **kwargs: Any + ) -> AsyncIterable["_models.DeploymentOperation"]: """Gets all deployments operations for a deployment. - :param deployment_name: The name of the deployment. + :param deployment_name: The name of the deployment. Required. :type deployment_name: str :param top: The number of results to return. Default value is None. :type top: int :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either DeploymentOperationsListResult or the result of - cls(response) + :return: An iterator like instance of either DeploymentOperation or the result of cls(response) :rtype: - ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.resource.resources.v2019_08_01.models.DeploymentOperationsListResult] - :raises: ~azure.core.exceptions.HttpResponseError + ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.resource.resources.v2019_08_01.models.DeploymentOperation] + :raises ~azure.core.exceptions.HttpResponseError: """ - api_version = kwargs.pop('api_version', "2019-08-01") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2019-08-01")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[_models.DeploymentOperationsListResult] - cls = kwargs.pop('cls', None) # type: ClsType["_models.DeploymentOperationsListResult"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) + def prepare_request(next_link=None): if not next_link: - + request = build_deployment_operations_list_at_subscription_scope_request( deployment_name=deployment_name, subscription_id=self._config.subscription_id, - api_version=api_version, top=top, - template_url=self.list_at_subscription_scope.metadata['url'], + api_version=api_version, + template_url=self.list_at_subscription_scope.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore else: - - request = build_deployment_operations_list_at_subscription_scope_request( - deployment_name=deployment_name, - subscription_id=self._config.subscription_id, - template_url=next_link, - ) + # make call to next link with the client's api-version + _parsed_next_link = urlparse(next_link) + _next_request_params = case_insensitive_dict(parse_qs(_parsed_next_link.query)) + _next_request_params["api-version"] = self._config.api_version + request = HttpRequest("GET", urljoin(next_link, _parsed_next_link.path), params=_next_request_params) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore request.method = "GET" return request @@ -6845,10 +8768,8 @@ async def extract_data(pipeline_response): async def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) response = pipeline_response.http_response @@ -6858,128 +8779,131 @@ async def get_next(next_link=None): return pipeline_response + return AsyncItemPaged(get_next, extract_data) - return AsyncItemPaged( - get_next, extract_data - ) - list_at_subscription_scope.metadata = {'url': "/subscriptions/{subscriptionId}/providers/Microsoft.Resources/deployments/{deploymentName}/operations"} # type: ignore + list_at_subscription_scope.metadata = {"url": "/subscriptions/{subscriptionId}/providers/Microsoft.Resources/deployments/{deploymentName}/operations"} # type: ignore @distributed_trace_async async def get( - self, - resource_group_name: str, - deployment_name: str, - operation_id: str, - **kwargs: Any - ) -> "_models.DeploymentOperation": + self, resource_group_name: str, deployment_name: str, operation_id: str, **kwargs: Any + ) -> _models.DeploymentOperation: """Gets a deployments operation. :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. :type resource_group_name: str - :param deployment_name: The name of the deployment. + :param deployment_name: The name of the deployment. Required. :type deployment_name: str - :param operation_id: The ID of the operation to get. + :param operation_id: The ID of the operation to get. Required. :type operation_id: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: DeploymentOperation, or the result of cls(response) + :return: DeploymentOperation or the result of cls(response) :rtype: ~azure.mgmt.resource.resources.v2019_08_01.models.DeploymentOperation - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.DeploymentOperation"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + 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', "2019-08-01") # type: str + api_version = kwargs.pop("api_version", _params.pop("api-version", "2019-08-01")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[_models.DeploymentOperation] - request = build_deployment_operations_get_request( resource_group_name=resource_group_name, deployment_name=deployment_name, operation_id=operation_id, subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.get.metadata['url'], + template_url=self.get.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) - deserialized = self._deserialize('DeploymentOperation', pipeline_response) + deserialized = self._deserialize("DeploymentOperation", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - get.metadata = {'url': "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/deployments/{deploymentName}/operations/{operationId}"} # type: ignore - + get.metadata = {"url": "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/deployments/{deploymentName}/operations/{operationId}"} # type: ignore @distributed_trace def list( - self, - resource_group_name: str, - deployment_name: str, - top: Optional[int] = None, - **kwargs: Any - ) -> AsyncIterable["_models.DeploymentOperationsListResult"]: + self, resource_group_name: str, deployment_name: str, top: Optional[int] = None, **kwargs: Any + ) -> AsyncIterable["_models.DeploymentOperation"]: """Gets all deployments operations for a deployment. :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. :type resource_group_name: str - :param deployment_name: The name of the deployment. + :param deployment_name: The name of the deployment. Required. :type deployment_name: str :param top: The number of results to return. Default value is None. :type top: int :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either DeploymentOperationsListResult or the result of - cls(response) + :return: An iterator like instance of either DeploymentOperation or the result of cls(response) :rtype: - ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.resource.resources.v2019_08_01.models.DeploymentOperationsListResult] - :raises: ~azure.core.exceptions.HttpResponseError + ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.resource.resources.v2019_08_01.models.DeploymentOperation] + :raises ~azure.core.exceptions.HttpResponseError: """ - api_version = kwargs.pop('api_version', "2019-08-01") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2019-08-01")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[_models.DeploymentOperationsListResult] - cls = kwargs.pop('cls', None) # type: ClsType["_models.DeploymentOperationsListResult"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) + def prepare_request(next_link=None): if not next_link: - + request = build_deployment_operations_list_request( resource_group_name=resource_group_name, deployment_name=deployment_name, subscription_id=self._config.subscription_id, - api_version=api_version, top=top, - template_url=self.list.metadata['url'], + 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.url = self._client.format_url(request.url) # type: ignore else: - - request = build_deployment_operations_list_request( - resource_group_name=resource_group_name, - deployment_name=deployment_name, - subscription_id=self._config.subscription_id, - template_url=next_link, - ) + # make call to next link with the client's api-version + _parsed_next_link = urlparse(next_link) + _next_request_params = case_insensitive_dict(parse_qs(_parsed_next_link.query)) + _next_request_params["api-version"] = self._config.api_version + request = HttpRequest("GET", urljoin(next_link, _parsed_next_link.path), params=_next_request_params) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore request.method = "GET" return request @@ -6993,10 +8917,8 @@ async def extract_data(pipeline_response): async def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) response = pipeline_response.http_response @@ -7006,8 +8928,6 @@ async def get_next(next_link=None): return pipeline_response + return AsyncItemPaged(get_next, extract_data) - return AsyncItemPaged( - get_next, extract_data - ) - list.metadata = {'url': "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/deployments/{deploymentName}/operations"} # type: ignore + list.metadata = {"url": "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/deployments/{deploymentName}/operations"} # type: ignore diff --git a/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/resources/v2019_08_01/aio/operations/_patch.py b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/resources/v2019_08_01/aio/operations/_patch.py new file mode 100644 index 0000000000000..f7dd32510333d --- /dev/null +++ b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/resources/v2019_08_01/aio/operations/_patch.py @@ -0,0 +1,20 @@ +# ------------------------------------ +# Copyright (c) Microsoft Corporation. +# Licensed under the MIT License. +# ------------------------------------ +"""Customize generated code here. + +Follow our quickstart for examples: https://aka.ms/azsdk/python/dpcodegen/python/customize +""" +from typing import List + +__all__: List[str] = [] # Add all objects you want publicly available to users at this package level + + +def patch_sdk(): + """Do not remove from this file. + + `patch_sdk` is a last resort escape hatch that allows you to do customizations + you can't accomplish using the techniques described in + https://aka.ms/azsdk/python/dpcodegen/python/customize + """ diff --git a/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/resources/v2019_08_01/models/__init__.py b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/resources/v2019_08_01/models/__init__.py index 8c1822d6995c3..49decb2de0edd 100644 --- a/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/resources/v2019_08_01/models/__init__.py +++ b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/resources/v2019_08_01/models/__init__.py @@ -69,83 +69,85 @@ from ._models_py3 import WhatIfPropertyChange from ._models_py3 import ZoneMapping - -from ._resource_management_client_enums import ( - ChangeType, - DeploymentMode, - OnErrorDeploymentType, - PropertyChangeType, - ResourceIdentityType, - WhatIfResultFormat, -) +from ._resource_management_client_enums import ChangeType +from ._resource_management_client_enums import DeploymentMode +from ._resource_management_client_enums import OnErrorDeploymentType +from ._resource_management_client_enums import PropertyChangeType +from ._resource_management_client_enums import ResourceIdentityType +from ._resource_management_client_enums import WhatIfResultFormat +from ._patch import __all__ as _patch_all +from ._patch import * # type: ignore # pylint: disable=unused-wildcard-import +from ._patch import patch_sdk as _patch_sdk __all__ = [ - 'AliasPathType', - 'AliasType', - 'BasicDependency', - 'ComponentsSgqdofSchemasIdentityPropertiesUserassignedidentitiesAdditionalproperties', - 'DebugSetting', - 'Dependency', - 'Deployment', - 'DeploymentExportResult', - 'DeploymentExtended', - 'DeploymentExtendedFilter', - 'DeploymentListResult', - 'DeploymentOperation', - 'DeploymentOperationProperties', - 'DeploymentOperationsListResult', - 'DeploymentProperties', - 'DeploymentPropertiesExtended', - 'DeploymentValidateResult', - 'DeploymentWhatIf', - 'DeploymentWhatIfProperties', - 'DeploymentWhatIfSettings', - 'ErrorAdditionalInfo', - 'ErrorResponse', - 'ExportTemplateRequest', - 'GenericResource', - 'GenericResourceExpanded', - 'GenericResourceFilter', - 'HttpMessage', - 'Identity', - 'OnErrorDeployment', - 'OnErrorDeploymentExtended', - 'Operation', - 'OperationDisplay', - 'OperationListResult', - 'ParametersLink', - 'Plan', - 'Provider', - 'ProviderListResult', - 'ProviderResourceType', - 'Resource', - 'ResourceGroup', - 'ResourceGroupExportResult', - 'ResourceGroupFilter', - 'ResourceGroupListResult', - 'ResourceGroupPatchable', - 'ResourceGroupProperties', - 'ResourceListResult', - 'ResourceProviderOperationDisplayProperties', - 'ResourcesMoveInfo', - 'ScopedDeployment', - 'Sku', - 'SubResource', - 'TagCount', - 'TagDetails', - 'TagValue', - 'TagsListResult', - 'TargetResource', - 'TemplateHashResult', - 'TemplateLink', - 'WhatIfChange', - 'WhatIfOperationResult', - 'WhatIfPropertyChange', - 'ZoneMapping', - 'ChangeType', - 'DeploymentMode', - 'OnErrorDeploymentType', - 'PropertyChangeType', - 'ResourceIdentityType', - 'WhatIfResultFormat', + "AliasPathType", + "AliasType", + "BasicDependency", + "ComponentsSgqdofSchemasIdentityPropertiesUserassignedidentitiesAdditionalproperties", + "DebugSetting", + "Dependency", + "Deployment", + "DeploymentExportResult", + "DeploymentExtended", + "DeploymentExtendedFilter", + "DeploymentListResult", + "DeploymentOperation", + "DeploymentOperationProperties", + "DeploymentOperationsListResult", + "DeploymentProperties", + "DeploymentPropertiesExtended", + "DeploymentValidateResult", + "DeploymentWhatIf", + "DeploymentWhatIfProperties", + "DeploymentWhatIfSettings", + "ErrorAdditionalInfo", + "ErrorResponse", + "ExportTemplateRequest", + "GenericResource", + "GenericResourceExpanded", + "GenericResourceFilter", + "HttpMessage", + "Identity", + "OnErrorDeployment", + "OnErrorDeploymentExtended", + "Operation", + "OperationDisplay", + "OperationListResult", + "ParametersLink", + "Plan", + "Provider", + "ProviderListResult", + "ProviderResourceType", + "Resource", + "ResourceGroup", + "ResourceGroupExportResult", + "ResourceGroupFilter", + "ResourceGroupListResult", + "ResourceGroupPatchable", + "ResourceGroupProperties", + "ResourceListResult", + "ResourceProviderOperationDisplayProperties", + "ResourcesMoveInfo", + "ScopedDeployment", + "Sku", + "SubResource", + "TagCount", + "TagDetails", + "TagValue", + "TagsListResult", + "TargetResource", + "TemplateHashResult", + "TemplateLink", + "WhatIfChange", + "WhatIfOperationResult", + "WhatIfPropertyChange", + "ZoneMapping", + "ChangeType", + "DeploymentMode", + "OnErrorDeploymentType", + "PropertyChangeType", + "ResourceIdentityType", + "WhatIfResultFormat", ] +__all__.extend([p for p in _patch_all if p not in __all__]) +_patch_sdk() diff --git a/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/resources/v2019_08_01/models/_models_py3.py b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/resources/v2019_08_01/models/_models_py3.py index fca8e881da949..f95e2923e55dd 100644 --- a/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/resources/v2019_08_01/models/_models_py3.py +++ b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/resources/v2019_08_01/models/_models_py3.py @@ -1,4 +1,5 @@ # coding=utf-8 +# pylint: disable=too-many-lines # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. # Licensed under the MIT License. See License.txt in the project root for license information. @@ -6,14 +7,22 @@ # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -from typing import Any, Dict, List, Optional, Union +import sys +from typing import Any, Dict, List, Optional, TYPE_CHECKING, Union -import msrest.serialization +from ... import _serialization -from ._resource_management_client_enums import * +if TYPE_CHECKING: + # pylint: disable=unused-import,ungrouped-imports + from .. import models as _models +if sys.version_info >= (3, 9): + from collections.abc import MutableMapping +else: + from typing import MutableMapping # type: ignore # pylint: disable=ungrouped-imports +JSON = MutableMapping[str, Any] # pylint: disable=unsubscriptable-object -class AliasPathType(msrest.serialization.Model): +class AliasPathType(_serialization.Model): """The type of the paths for alias. :ivar path: The path of an alias. @@ -23,29 +32,23 @@ class AliasPathType(msrest.serialization.Model): """ _attribute_map = { - 'path': {'key': 'path', 'type': 'str'}, - 'api_versions': {'key': 'apiVersions', 'type': '[str]'}, + "path": {"key": "path", "type": "str"}, + "api_versions": {"key": "apiVersions", "type": "[str]"}, } - def __init__( - self, - *, - path: Optional[str] = None, - api_versions: Optional[List[str]] = None, - **kwargs - ): + def __init__(self, *, path: Optional[str] = None, api_versions: Optional[List[str]] = None, **kwargs): """ :keyword path: The path of an alias. :paramtype path: str :keyword api_versions: The API versions. :paramtype api_versions: list[str] """ - super(AliasPathType, self).__init__(**kwargs) + super().__init__(**kwargs) self.path = path self.api_versions = api_versions -class AliasType(msrest.serialization.Model): +class AliasType(_serialization.Model): """The alias type. :ivar name: The alias name. @@ -55,29 +58,23 @@ class AliasType(msrest.serialization.Model): """ _attribute_map = { - 'name': {'key': 'name', 'type': 'str'}, - 'paths': {'key': 'paths', 'type': '[AliasPathType]'}, + "name": {"key": "name", "type": "str"}, + "paths": {"key": "paths", "type": "[AliasPathType]"}, } - def __init__( - self, - *, - name: Optional[str] = None, - paths: Optional[List["AliasPathType"]] = None, - **kwargs - ): + def __init__(self, *, name: Optional[str] = None, paths: Optional[List["_models.AliasPathType"]] = None, **kwargs): """ :keyword name: The alias name. :paramtype name: str :keyword paths: The paths for an alias. :paramtype paths: list[~azure.mgmt.resource.resources.v2019_08_01.models.AliasPathType] """ - super(AliasType, self).__init__(**kwargs) + super().__init__(**kwargs) self.name = name self.paths = paths -class BasicDependency(msrest.serialization.Model): +class BasicDependency(_serialization.Model): """Deployment dependency information. :ivar id: The ID of the dependency. @@ -89,15 +86,15 @@ class BasicDependency(msrest.serialization.Model): """ _attribute_map = { - 'id': {'key': 'id', 'type': 'str'}, - 'resource_type': {'key': 'resourceType', 'type': 'str'}, - 'resource_name': {'key': 'resourceName', 'type': 'str'}, + "id": {"key": "id", "type": "str"}, + "resource_type": {"key": "resourceType", "type": "str"}, + "resource_name": {"key": "resourceName", "type": "str"}, } def __init__( self, *, - id: Optional[str] = None, + id: Optional[str] = None, # pylint: disable=redefined-builtin resource_type: Optional[str] = None, resource_name: Optional[str] = None, **kwargs @@ -110,13 +107,13 @@ def __init__( :keyword resource_name: The dependency resource name. :paramtype resource_name: str """ - super(BasicDependency, self).__init__(**kwargs) + super().__init__(**kwargs) self.id = id self.resource_type = resource_type self.resource_name = resource_name -class ComponentsSgqdofSchemasIdentityPropertiesUserassignedidentitiesAdditionalproperties(msrest.serialization.Model): +class ComponentsSgqdofSchemasIdentityPropertiesUserassignedidentitiesAdditionalproperties(_serialization.Model): """ComponentsSgqdofSchemasIdentityPropertiesUserassignedidentitiesAdditionalproperties. Variables are only populated by the server, and will be ignored when sending a request. @@ -128,27 +125,23 @@ class ComponentsSgqdofSchemasIdentityPropertiesUserassignedidentitiesAdditionalp """ _validation = { - 'principal_id': {'readonly': True}, - 'client_id': {'readonly': True}, + "principal_id": {"readonly": True}, + "client_id": {"readonly": True}, } _attribute_map = { - 'principal_id': {'key': 'principalId', 'type': 'str'}, - 'client_id': {'key': 'clientId', 'type': 'str'}, + "principal_id": {"key": "principalId", "type": "str"}, + "client_id": {"key": "clientId", "type": "str"}, } - def __init__( - self, - **kwargs - ): - """ - """ - super(ComponentsSgqdofSchemasIdentityPropertiesUserassignedidentitiesAdditionalproperties, self).__init__(**kwargs) + def __init__(self, **kwargs): + """ """ + super().__init__(**kwargs) self.principal_id = None self.client_id = None -class DebugSetting(msrest.serialization.Model): +class DebugSetting(_serialization.Model): """The debug setting. :ivar detail_level: Specifies the type of information to log for debugging. The permitted @@ -161,15 +154,10 @@ class DebugSetting(msrest.serialization.Model): """ _attribute_map = { - 'detail_level': {'key': 'detailLevel', 'type': 'str'}, + "detail_level": {"key": "detailLevel", "type": "str"}, } - def __init__( - self, - *, - detail_level: Optional[str] = None, - **kwargs - ): + def __init__(self, *, detail_level: Optional[str] = None, **kwargs): """ :keyword detail_level: Specifies the type of information to log for debugging. The permitted values are none, requestContent, responseContent, or both requestContent and responseContent @@ -179,11 +167,11 @@ def __init__( deployment operations. :paramtype detail_level: str """ - super(DebugSetting, self).__init__(**kwargs) + super().__init__(**kwargs) self.detail_level = detail_level -class Dependency(msrest.serialization.Model): +class Dependency(_serialization.Model): """Deployment dependency information. :ivar depends_on: The list of dependencies. @@ -197,17 +185,17 @@ class Dependency(msrest.serialization.Model): """ _attribute_map = { - 'depends_on': {'key': 'dependsOn', 'type': '[BasicDependency]'}, - 'id': {'key': 'id', 'type': 'str'}, - 'resource_type': {'key': 'resourceType', 'type': 'str'}, - 'resource_name': {'key': 'resourceName', 'type': 'str'}, + "depends_on": {"key": "dependsOn", "type": "[BasicDependency]"}, + "id": {"key": "id", "type": "str"}, + "resource_type": {"key": "resourceType", "type": "str"}, + "resource_name": {"key": "resourceName", "type": "str"}, } def __init__( self, *, - depends_on: Optional[List["BasicDependency"]] = None, - id: Optional[str] = None, + depends_on: Optional[List["_models.BasicDependency"]] = None, + id: Optional[str] = None, # pylint: disable=redefined-builtin resource_type: Optional[str] = None, resource_name: Optional[str] = None, **kwargs @@ -222,77 +210,66 @@ def __init__( :keyword resource_name: The dependency resource name. :paramtype resource_name: str """ - super(Dependency, self).__init__(**kwargs) + super().__init__(**kwargs) self.depends_on = depends_on self.id = id self.resource_type = resource_type self.resource_name = resource_name -class Deployment(msrest.serialization.Model): +class Deployment(_serialization.Model): """Deployment operation parameters. All required parameters must be populated in order to send to Azure. :ivar location: The location to store the deployment data. :vartype location: str - :ivar properties: Required. The deployment properties. + :ivar properties: The deployment properties. Required. :vartype properties: ~azure.mgmt.resource.resources.v2019_08_01.models.DeploymentProperties """ _validation = { - 'properties': {'required': True}, + "properties": {"required": True}, } _attribute_map = { - 'location': {'key': 'location', 'type': 'str'}, - 'properties': {'key': 'properties', 'type': 'DeploymentProperties'}, + "location": {"key": "location", "type": "str"}, + "properties": {"key": "properties", "type": "DeploymentProperties"}, } - def __init__( - self, - *, - properties: "DeploymentProperties", - location: Optional[str] = None, - **kwargs - ): + def __init__(self, *, properties: "_models.DeploymentProperties", location: Optional[str] = None, **kwargs): """ :keyword location: The location to store the deployment data. :paramtype location: str - :keyword properties: Required. The deployment properties. + :keyword properties: The deployment properties. Required. :paramtype properties: ~azure.mgmt.resource.resources.v2019_08_01.models.DeploymentProperties """ - super(Deployment, self).__init__(**kwargs) + super().__init__(**kwargs) self.location = location self.properties = properties -class DeploymentExportResult(msrest.serialization.Model): +class DeploymentExportResult(_serialization.Model): """The deployment export result. :ivar template: The template content. - :vartype template: any + :vartype template: JSON """ _attribute_map = { - 'template': {'key': 'template', 'type': 'object'}, + "template": {"key": "template", "type": "object"}, } - def __init__( - self, - *, - template: Optional[Any] = None, - **kwargs - ): + def __init__(self, *, template: Optional[JSON] = None, **kwargs): """ :keyword template: The template content. - :paramtype template: any + :paramtype template: JSON """ - super(DeploymentExportResult, self).__init__(**kwargs) + super().__init__(**kwargs) self.template = template -class DeploymentExtended(msrest.serialization.Model): +class DeploymentExtended(_serialization.Model): """Deployment information. Variables are only populated by the server, and will be ignored when sending a request. @@ -311,24 +288,24 @@ class DeploymentExtended(msrest.serialization.Model): """ _validation = { - 'id': {'readonly': True}, - 'name': {'readonly': True}, - 'type': {'readonly': True}, + "id": {"readonly": True}, + "name": {"readonly": True}, + "type": {"readonly": True}, } _attribute_map = { - 'id': {'key': 'id', 'type': 'str'}, - 'name': {'key': 'name', 'type': 'str'}, - 'type': {'key': 'type', 'type': 'str'}, - 'location': {'key': 'location', 'type': 'str'}, - 'properties': {'key': 'properties', 'type': 'DeploymentPropertiesExtended'}, + "id": {"key": "id", "type": "str"}, + "name": {"key": "name", "type": "str"}, + "type": {"key": "type", "type": "str"}, + "location": {"key": "location", "type": "str"}, + "properties": {"key": "properties", "type": "DeploymentPropertiesExtended"}, } def __init__( self, *, location: Optional[str] = None, - properties: Optional["DeploymentPropertiesExtended"] = None, + properties: Optional["_models.DeploymentPropertiesExtended"] = None, **kwargs ): """ @@ -338,7 +315,7 @@ def __init__( :paramtype properties: ~azure.mgmt.resource.resources.v2019_08_01.models.DeploymentPropertiesExtended """ - super(DeploymentExtended, self).__init__(**kwargs) + super().__init__(**kwargs) self.id = None self.name = None self.type = None @@ -346,7 +323,7 @@ def __init__( self.properties = properties -class DeploymentExtendedFilter(msrest.serialization.Model): +class DeploymentExtendedFilter(_serialization.Model): """Deployment filter. :ivar provisioning_state: The provisioning state. @@ -354,24 +331,19 @@ class DeploymentExtendedFilter(msrest.serialization.Model): """ _attribute_map = { - 'provisioning_state': {'key': 'provisioningState', 'type': 'str'}, + "provisioning_state": {"key": "provisioningState", "type": "str"}, } - def __init__( - self, - *, - provisioning_state: Optional[str] = None, - **kwargs - ): + def __init__(self, *, provisioning_state: Optional[str] = None, **kwargs): """ :keyword provisioning_state: The provisioning state. :paramtype provisioning_state: str """ - super(DeploymentExtendedFilter, self).__init__(**kwargs) + super().__init__(**kwargs) self.provisioning_state = provisioning_state -class DeploymentListResult(msrest.serialization.Model): +class DeploymentListResult(_serialization.Model): """List of deployments. Variables are only populated by the server, and will be ignored when sending a request. @@ -383,30 +355,25 @@ class DeploymentListResult(msrest.serialization.Model): """ _validation = { - 'next_link': {'readonly': True}, + "next_link": {"readonly": True}, } _attribute_map = { - 'value': {'key': 'value', 'type': '[DeploymentExtended]'}, - 'next_link': {'key': 'nextLink', 'type': 'str'}, + "value": {"key": "value", "type": "[DeploymentExtended]"}, + "next_link": {"key": "nextLink", "type": "str"}, } - def __init__( - self, - *, - value: Optional[List["DeploymentExtended"]] = None, - **kwargs - ): + def __init__(self, *, value: Optional[List["_models.DeploymentExtended"]] = None, **kwargs): """ :keyword value: An array of deployments. :paramtype value: list[~azure.mgmt.resource.resources.v2019_08_01.models.DeploymentExtended] """ - super(DeploymentListResult, self).__init__(**kwargs) + super().__init__(**kwargs) self.value = value self.next_link = None -class DeploymentOperation(msrest.serialization.Model): +class DeploymentOperation(_serialization.Model): """Deployment operation information. Variables are only populated by the server, and will be ignored when sending a request. @@ -421,34 +388,29 @@ class DeploymentOperation(msrest.serialization.Model): """ _validation = { - 'id': {'readonly': True}, - 'operation_id': {'readonly': True}, + "id": {"readonly": True}, + "operation_id": {"readonly": True}, } _attribute_map = { - 'id': {'key': 'id', 'type': 'str'}, - 'operation_id': {'key': 'operationId', 'type': 'str'}, - 'properties': {'key': 'properties', 'type': 'DeploymentOperationProperties'}, + "id": {"key": "id", "type": "str"}, + "operation_id": {"key": "operationId", "type": "str"}, + "properties": {"key": "properties", "type": "DeploymentOperationProperties"}, } - def __init__( - self, - *, - properties: Optional["DeploymentOperationProperties"] = None, - **kwargs - ): + def __init__(self, *, properties: Optional["_models.DeploymentOperationProperties"] = None, **kwargs): """ :keyword properties: Deployment properties. :paramtype properties: ~azure.mgmt.resource.resources.v2019_08_01.models.DeploymentOperationProperties """ - super(DeploymentOperation, self).__init__(**kwargs) + super().__init__(**kwargs) self.id = None self.operation_id = None self.properties = properties -class DeploymentOperationProperties(msrest.serialization.Model): +class DeploymentOperationProperties(_serialization.Model): """Deployment operation properties. Variables are only populated by the server, and will be ignored when sending a request. @@ -464,7 +426,7 @@ class DeploymentOperationProperties(msrest.serialization.Model): :ivar status_code: Operation status code. :vartype status_code: str :ivar status_message: Operation status message. - :vartype status_message: any + :vartype status_message: JSON :ivar target_resource: The target resource. :vartype target_resource: ~azure.mgmt.resource.resources.v2019_08_01.models.TargetResource :ivar request: The HTTP request message. @@ -474,36 +436,32 @@ class DeploymentOperationProperties(msrest.serialization.Model): """ _validation = { - 'provisioning_state': {'readonly': True}, - 'timestamp': {'readonly': True}, - 'duration': {'readonly': True}, - 'service_request_id': {'readonly': True}, - 'status_code': {'readonly': True}, - 'status_message': {'readonly': True}, - 'target_resource': {'readonly': True}, - 'request': {'readonly': True}, - 'response': {'readonly': True}, + "provisioning_state": {"readonly": True}, + "timestamp": {"readonly": True}, + "duration": {"readonly": True}, + "service_request_id": {"readonly": True}, + "status_code": {"readonly": True}, + "status_message": {"readonly": True}, + "target_resource": {"readonly": True}, + "request": {"readonly": True}, + "response": {"readonly": True}, } _attribute_map = { - 'provisioning_state': {'key': 'provisioningState', 'type': 'str'}, - 'timestamp': {'key': 'timestamp', 'type': 'iso-8601'}, - 'duration': {'key': 'duration', 'type': 'str'}, - 'service_request_id': {'key': 'serviceRequestId', 'type': 'str'}, - 'status_code': {'key': 'statusCode', 'type': 'str'}, - 'status_message': {'key': 'statusMessage', 'type': 'object'}, - 'target_resource': {'key': 'targetResource', 'type': 'TargetResource'}, - 'request': {'key': 'request', 'type': 'HttpMessage'}, - 'response': {'key': 'response', 'type': 'HttpMessage'}, - } - - def __init__( - self, - **kwargs - ): - """ - """ - super(DeploymentOperationProperties, self).__init__(**kwargs) + "provisioning_state": {"key": "provisioningState", "type": "str"}, + "timestamp": {"key": "timestamp", "type": "iso-8601"}, + "duration": {"key": "duration", "type": "str"}, + "service_request_id": {"key": "serviceRequestId", "type": "str"}, + "status_code": {"key": "statusCode", "type": "str"}, + "status_message": {"key": "statusMessage", "type": "object"}, + "target_resource": {"key": "targetResource", "type": "TargetResource"}, + "request": {"key": "request", "type": "HttpMessage"}, + "response": {"key": "response", "type": "HttpMessage"}, + } + + def __init__(self, **kwargs): + """ """ + super().__init__(**kwargs) self.provisioning_state = None self.timestamp = None self.duration = None @@ -515,7 +473,7 @@ def __init__( self.response = None -class DeploymentOperationsListResult(msrest.serialization.Model): +class DeploymentOperationsListResult(_serialization.Model): """List of deployment operations. Variables are only populated by the server, and will be ignored when sending a request. @@ -527,30 +485,25 @@ class DeploymentOperationsListResult(msrest.serialization.Model): """ _validation = { - 'next_link': {'readonly': True}, + "next_link": {"readonly": True}, } _attribute_map = { - 'value': {'key': 'value', 'type': '[DeploymentOperation]'}, - 'next_link': {'key': 'nextLink', 'type': 'str'}, + "value": {"key": "value", "type": "[DeploymentOperation]"}, + "next_link": {"key": "nextLink", "type": "str"}, } - def __init__( - self, - *, - value: Optional[List["DeploymentOperation"]] = None, - **kwargs - ): + def __init__(self, *, value: Optional[List["_models.DeploymentOperation"]] = None, **kwargs): """ :keyword value: An array of deployment operations. :paramtype value: list[~azure.mgmt.resource.resources.v2019_08_01.models.DeploymentOperation] """ - super(DeploymentOperationsListResult, self).__init__(**kwargs) + super().__init__(**kwargs) self.value = value self.next_link = None -class DeploymentProperties(msrest.serialization.Model): +class DeploymentProperties(_serialization.Model): """Deployment properties. All required parameters must be populated in order to send to Azure. @@ -559,7 +512,7 @@ class DeploymentProperties(msrest.serialization.Model): syntax directly in the request rather than link to an existing template. It can be a JObject or well-formed JSON string. Use either the templateLink property or the template property, but not both. - :vartype template: any + :vartype template: JSON :ivar template_link: The URI of the template. Use either the templateLink property or the template property, but not both. :vartype template_link: ~azure.mgmt.resource.resources.v2019_08_01.models.TemplateLink @@ -567,17 +520,17 @@ class DeploymentProperties(msrest.serialization.Model): You use this element when you want to provide the parameter values directly in the request rather than link to an existing parameter file. Use either the parametersLink property or the parameters property, but not both. It can be a JObject or a well formed JSON string. - :vartype parameters: any + :vartype parameters: JSON :ivar parameters_link: The URI of parameters file. You use this element to link to an existing parameters file. Use either the parametersLink property or the parameters property, but not both. :vartype parameters_link: ~azure.mgmt.resource.resources.v2019_08_01.models.ParametersLink - :ivar mode: Required. The mode that is used to deploy resources. This value can be either - Incremental or Complete. In Incremental mode, resources are deployed without deleting existing - resources that are not included in the template. In Complete mode, resources are deployed and - existing resources in the resource group that are not included in the template are deleted. Be - careful when using Complete mode as you may unintentionally delete resources. Possible values - include: "Incremental", "Complete". + :ivar mode: The mode that is used to deploy resources. This value can be either Incremental or + Complete. In Incremental mode, resources are deployed without deleting existing resources that + are not included in the template. In Complete mode, resources are deployed and existing + resources in the resource group that are not included in the template are deleted. Be careful + when using Complete mode as you may unintentionally delete resources. Required. Known values + are: "Incremental" and "Complete". :vartype mode: str or ~azure.mgmt.resource.resources.v2019_08_01.models.DeploymentMode :ivar debug_setting: The debug setting of the deployment. :vartype debug_setting: ~azure.mgmt.resource.resources.v2019_08_01.models.DebugSetting @@ -587,29 +540,29 @@ class DeploymentProperties(msrest.serialization.Model): """ _validation = { - 'mode': {'required': True}, + "mode": {"required": True}, } _attribute_map = { - 'template': {'key': 'template', 'type': 'object'}, - 'template_link': {'key': 'templateLink', 'type': 'TemplateLink'}, - 'parameters': {'key': 'parameters', 'type': 'object'}, - 'parameters_link': {'key': 'parametersLink', 'type': 'ParametersLink'}, - 'mode': {'key': 'mode', 'type': 'str'}, - 'debug_setting': {'key': 'debugSetting', 'type': 'DebugSetting'}, - 'on_error_deployment': {'key': 'onErrorDeployment', 'type': 'OnErrorDeployment'}, + "template": {"key": "template", "type": "object"}, + "template_link": {"key": "templateLink", "type": "TemplateLink"}, + "parameters": {"key": "parameters", "type": "object"}, + "parameters_link": {"key": "parametersLink", "type": "ParametersLink"}, + "mode": {"key": "mode", "type": "str"}, + "debug_setting": {"key": "debugSetting", "type": "DebugSetting"}, + "on_error_deployment": {"key": "onErrorDeployment", "type": "OnErrorDeployment"}, } def __init__( self, *, - mode: Union[str, "DeploymentMode"], - template: Optional[Any] = None, - template_link: Optional["TemplateLink"] = None, - parameters: Optional[Any] = None, - parameters_link: Optional["ParametersLink"] = None, - debug_setting: Optional["DebugSetting"] = None, - on_error_deployment: Optional["OnErrorDeployment"] = None, + mode: Union[str, "_models.DeploymentMode"], + template: Optional[JSON] = None, + template_link: Optional["_models.TemplateLink"] = None, + parameters: Optional[JSON] = None, + parameters_link: Optional["_models.ParametersLink"] = None, + debug_setting: Optional["_models.DebugSetting"] = None, + on_error_deployment: Optional["_models.OnErrorDeployment"] = None, **kwargs ): """ @@ -617,7 +570,7 @@ def __init__( template syntax directly in the request rather than link to an existing template. It can be a JObject or well-formed JSON string. Use either the templateLink property or the template property, but not both. - :paramtype template: any + :paramtype template: JSON :keyword template_link: The URI of the template. Use either the templateLink property or the template property, but not both. :paramtype template_link: ~azure.mgmt.resource.resources.v2019_08_01.models.TemplateLink @@ -625,17 +578,17 @@ def __init__( template. You use this element when you want to provide the parameter values directly in the request rather than link to an existing parameter file. Use either the parametersLink property or the parameters property, but not both. It can be a JObject or a well formed JSON string. - :paramtype parameters: any + :paramtype parameters: JSON :keyword parameters_link: The URI of parameters file. You use this element to link to an existing parameters file. Use either the parametersLink property or the parameters property, but not both. :paramtype parameters_link: ~azure.mgmt.resource.resources.v2019_08_01.models.ParametersLink - :keyword mode: Required. The mode that is used to deploy resources. This value can be either - Incremental or Complete. In Incremental mode, resources are deployed without deleting existing - resources that are not included in the template. In Complete mode, resources are deployed and - existing resources in the resource group that are not included in the template are deleted. Be - careful when using Complete mode as you may unintentionally delete resources. Possible values - include: "Incremental", "Complete". + :keyword mode: The mode that is used to deploy resources. This value can be either Incremental + or Complete. In Incremental mode, resources are deployed without deleting existing resources + that are not included in the template. In Complete mode, resources are deployed and existing + resources in the resource group that are not included in the template are deleted. Be careful + when using Complete mode as you may unintentionally delete resources. Required. Known values + are: "Incremental" and "Complete". :paramtype mode: str or ~azure.mgmt.resource.resources.v2019_08_01.models.DeploymentMode :keyword debug_setting: The debug setting of the deployment. :paramtype debug_setting: ~azure.mgmt.resource.resources.v2019_08_01.models.DebugSetting @@ -643,7 +596,7 @@ def __init__( :paramtype on_error_deployment: ~azure.mgmt.resource.resources.v2019_08_01.models.OnErrorDeployment """ - super(DeploymentProperties, self).__init__(**kwargs) + super().__init__(**kwargs) self.template = template self.template_link = template_link self.parameters = parameters @@ -653,7 +606,7 @@ def __init__( self.on_error_deployment = on_error_deployment -class DeploymentPropertiesExtended(msrest.serialization.Model): +class DeploymentPropertiesExtended(_serialization.Model): # pylint: disable=too-many-instance-attributes """Deployment properties with additional details. Variables are only populated by the server, and will be ignored when sending a request. @@ -667,23 +620,23 @@ class DeploymentPropertiesExtended(msrest.serialization.Model): :ivar duration: The duration of the template deployment. :vartype duration: str :ivar outputs: Key/value pairs that represent deployment output. - :vartype outputs: any + :vartype outputs: JSON :ivar providers: The list of resource providers needed for the deployment. :vartype providers: list[~azure.mgmt.resource.resources.v2019_08_01.models.Provider] :ivar dependencies: The list of deployment dependencies. :vartype dependencies: list[~azure.mgmt.resource.resources.v2019_08_01.models.Dependency] :ivar template: The template content. Use only one of Template or TemplateLink. - :vartype template: any + :vartype template: JSON :ivar template_link: The URI referencing the template. Use only one of Template or TemplateLink. :vartype template_link: ~azure.mgmt.resource.resources.v2019_08_01.models.TemplateLink :ivar parameters: Deployment parameters. Use only one of Parameters or ParametersLink. - :vartype parameters: any + :vartype parameters: JSON :ivar parameters_link: The URI referencing the parameters. Use only one of Parameters or ParametersLink. :vartype parameters_link: ~azure.mgmt.resource.resources.v2019_08_01.models.ParametersLink - :ivar mode: The deployment mode. Possible values are Incremental and Complete. Possible values - include: "Incremental", "Complete". + :ivar mode: The deployment mode. Possible values are Incremental and Complete. Known values + are: "Incremental" and "Complete". :vartype mode: str or ~azure.mgmt.resource.resources.v2019_08_01.models.DeploymentMode :ivar debug_setting: The debug setting of the deployment. :vartype debug_setting: ~azure.mgmt.resource.resources.v2019_08_01.models.DebugSetting @@ -695,65 +648,65 @@ class DeploymentPropertiesExtended(msrest.serialization.Model): """ _validation = { - 'provisioning_state': {'readonly': True}, - 'correlation_id': {'readonly': True}, - 'timestamp': {'readonly': True}, - 'duration': {'readonly': True}, - 'error': {'readonly': True}, + "provisioning_state": {"readonly": True}, + "correlation_id": {"readonly": True}, + "timestamp": {"readonly": True}, + "duration": {"readonly": True}, + "error": {"readonly": True}, } _attribute_map = { - 'provisioning_state': {'key': 'provisioningState', 'type': 'str'}, - 'correlation_id': {'key': 'correlationId', 'type': 'str'}, - 'timestamp': {'key': 'timestamp', 'type': 'iso-8601'}, - 'duration': {'key': 'duration', 'type': 'str'}, - 'outputs': {'key': 'outputs', 'type': 'object'}, - 'providers': {'key': 'providers', 'type': '[Provider]'}, - 'dependencies': {'key': 'dependencies', 'type': '[Dependency]'}, - 'template': {'key': 'template', 'type': 'object'}, - 'template_link': {'key': 'templateLink', 'type': 'TemplateLink'}, - 'parameters': {'key': 'parameters', 'type': 'object'}, - 'parameters_link': {'key': 'parametersLink', 'type': 'ParametersLink'}, - 'mode': {'key': 'mode', 'type': 'str'}, - 'debug_setting': {'key': 'debugSetting', 'type': 'DebugSetting'}, - 'on_error_deployment': {'key': 'onErrorDeployment', 'type': 'OnErrorDeploymentExtended'}, - 'error': {'key': 'error', 'type': 'ErrorResponse'}, + "provisioning_state": {"key": "provisioningState", "type": "str"}, + "correlation_id": {"key": "correlationId", "type": "str"}, + "timestamp": {"key": "timestamp", "type": "iso-8601"}, + "duration": {"key": "duration", "type": "str"}, + "outputs": {"key": "outputs", "type": "object"}, + "providers": {"key": "providers", "type": "[Provider]"}, + "dependencies": {"key": "dependencies", "type": "[Dependency]"}, + "template": {"key": "template", "type": "object"}, + "template_link": {"key": "templateLink", "type": "TemplateLink"}, + "parameters": {"key": "parameters", "type": "object"}, + "parameters_link": {"key": "parametersLink", "type": "ParametersLink"}, + "mode": {"key": "mode", "type": "str"}, + "debug_setting": {"key": "debugSetting", "type": "DebugSetting"}, + "on_error_deployment": {"key": "onErrorDeployment", "type": "OnErrorDeploymentExtended"}, + "error": {"key": "error", "type": "ErrorResponse"}, } def __init__( self, *, - outputs: Optional[Any] = None, - providers: Optional[List["Provider"]] = None, - dependencies: Optional[List["Dependency"]] = None, - template: Optional[Any] = None, - template_link: Optional["TemplateLink"] = None, - parameters: Optional[Any] = None, - parameters_link: Optional["ParametersLink"] = None, - mode: Optional[Union[str, "DeploymentMode"]] = None, - debug_setting: Optional["DebugSetting"] = None, - on_error_deployment: Optional["OnErrorDeploymentExtended"] = None, + outputs: Optional[JSON] = None, + providers: Optional[List["_models.Provider"]] = None, + dependencies: Optional[List["_models.Dependency"]] = None, + template: Optional[JSON] = None, + template_link: Optional["_models.TemplateLink"] = None, + parameters: Optional[JSON] = None, + parameters_link: Optional["_models.ParametersLink"] = None, + mode: Optional[Union[str, "_models.DeploymentMode"]] = None, + debug_setting: Optional["_models.DebugSetting"] = None, + on_error_deployment: Optional["_models.OnErrorDeploymentExtended"] = None, **kwargs ): """ :keyword outputs: Key/value pairs that represent deployment output. - :paramtype outputs: any + :paramtype outputs: JSON :keyword providers: The list of resource providers needed for the deployment. :paramtype providers: list[~azure.mgmt.resource.resources.v2019_08_01.models.Provider] :keyword dependencies: The list of deployment dependencies. :paramtype dependencies: list[~azure.mgmt.resource.resources.v2019_08_01.models.Dependency] :keyword template: The template content. Use only one of Template or TemplateLink. - :paramtype template: any + :paramtype template: JSON :keyword template_link: The URI referencing the template. Use only one of Template or TemplateLink. :paramtype template_link: ~azure.mgmt.resource.resources.v2019_08_01.models.TemplateLink :keyword parameters: Deployment parameters. Use only one of Parameters or ParametersLink. - :paramtype parameters: any + :paramtype parameters: JSON :keyword parameters_link: The URI referencing the parameters. Use only one of Parameters or ParametersLink. :paramtype parameters_link: ~azure.mgmt.resource.resources.v2019_08_01.models.ParametersLink - :keyword mode: The deployment mode. Possible values are Incremental and Complete. Possible - values include: "Incremental", "Complete". + :keyword mode: The deployment mode. Possible values are Incremental and Complete. Known values + are: "Incremental" and "Complete". :paramtype mode: str or ~azure.mgmt.resource.resources.v2019_08_01.models.DeploymentMode :keyword debug_setting: The debug setting of the deployment. :paramtype debug_setting: ~azure.mgmt.resource.resources.v2019_08_01.models.DebugSetting @@ -761,7 +714,7 @@ def __init__( :paramtype on_error_deployment: ~azure.mgmt.resource.resources.v2019_08_01.models.OnErrorDeploymentExtended """ - super(DeploymentPropertiesExtended, self).__init__(**kwargs) + super().__init__(**kwargs) self.provisioning_state = None self.correlation_id = None self.timestamp = None @@ -779,7 +732,7 @@ def __init__( self.error = None -class DeploymentValidateResult(msrest.serialization.Model): +class DeploymentValidateResult(_serialization.Model): """Information from validate template deployment response. :ivar error: The deployment validation error. @@ -790,15 +743,15 @@ class DeploymentValidateResult(msrest.serialization.Model): """ _attribute_map = { - 'error': {'key': 'error', 'type': 'ErrorResponse'}, - 'properties': {'key': 'properties', 'type': 'DeploymentPropertiesExtended'}, + "error": {"key": "error", "type": "ErrorResponse"}, + "properties": {"key": "properties", "type": "DeploymentPropertiesExtended"}, } def __init__( self, *, - error: Optional["ErrorResponse"] = None, - properties: Optional["DeploymentPropertiesExtended"] = None, + error: Optional["_models.ErrorResponse"] = None, + properties: Optional["_models.DeploymentPropertiesExtended"] = None, **kwargs ): """ @@ -808,47 +761,41 @@ def __init__( :paramtype properties: ~azure.mgmt.resource.resources.v2019_08_01.models.DeploymentPropertiesExtended """ - super(DeploymentValidateResult, self).__init__(**kwargs) + super().__init__(**kwargs) self.error = error self.properties = properties -class DeploymentWhatIf(msrest.serialization.Model): +class DeploymentWhatIf(_serialization.Model): """Deployment What-if operation parameters. All required parameters must be populated in order to send to Azure. :ivar location: The location to store the deployment data. :vartype location: str - :ivar properties: Required. The deployment properties. + :ivar properties: The deployment properties. Required. :vartype properties: ~azure.mgmt.resource.resources.v2019_08_01.models.DeploymentWhatIfProperties """ _validation = { - 'properties': {'required': True}, + "properties": {"required": True}, } _attribute_map = { - 'location': {'key': 'location', 'type': 'str'}, - 'properties': {'key': 'properties', 'type': 'DeploymentWhatIfProperties'}, + "location": {"key": "location", "type": "str"}, + "properties": {"key": "properties", "type": "DeploymentWhatIfProperties"}, } - def __init__( - self, - *, - properties: "DeploymentWhatIfProperties", - location: Optional[str] = None, - **kwargs - ): + def __init__(self, *, properties: "_models.DeploymentWhatIfProperties", location: Optional[str] = None, **kwargs): """ :keyword location: The location to store the deployment data. :paramtype location: str - :keyword properties: Required. The deployment properties. + :keyword properties: The deployment properties. Required. :paramtype properties: ~azure.mgmt.resource.resources.v2019_08_01.models.DeploymentWhatIfProperties """ - super(DeploymentWhatIf, self).__init__(**kwargs) + super().__init__(**kwargs) self.location = location self.properties = properties @@ -862,7 +809,7 @@ class DeploymentWhatIfProperties(DeploymentProperties): syntax directly in the request rather than link to an existing template. It can be a JObject or well-formed JSON string. Use either the templateLink property or the template property, but not both. - :vartype template: any + :vartype template: JSON :ivar template_link: The URI of the template. Use either the templateLink property or the template property, but not both. :vartype template_link: ~azure.mgmt.resource.resources.v2019_08_01.models.TemplateLink @@ -870,17 +817,17 @@ class DeploymentWhatIfProperties(DeploymentProperties): You use this element when you want to provide the parameter values directly in the request rather than link to an existing parameter file. Use either the parametersLink property or the parameters property, but not both. It can be a JObject or a well formed JSON string. - :vartype parameters: any + :vartype parameters: JSON :ivar parameters_link: The URI of parameters file. You use this element to link to an existing parameters file. Use either the parametersLink property or the parameters property, but not both. :vartype parameters_link: ~azure.mgmt.resource.resources.v2019_08_01.models.ParametersLink - :ivar mode: Required. The mode that is used to deploy resources. This value can be either - Incremental or Complete. In Incremental mode, resources are deployed without deleting existing - resources that are not included in the template. In Complete mode, resources are deployed and - existing resources in the resource group that are not included in the template are deleted. Be - careful when using Complete mode as you may unintentionally delete resources. Possible values - include: "Incremental", "Complete". + :ivar mode: The mode that is used to deploy resources. This value can be either Incremental or + Complete. In Incremental mode, resources are deployed without deleting existing resources that + are not included in the template. In Complete mode, resources are deployed and existing + resources in the resource group that are not included in the template are deleted. Be careful + when using Complete mode as you may unintentionally delete resources. Required. Known values + are: "Incremental" and "Complete". :vartype mode: str or ~azure.mgmt.resource.resources.v2019_08_01.models.DeploymentMode :ivar debug_setting: The debug setting of the deployment. :vartype debug_setting: ~azure.mgmt.resource.resources.v2019_08_01.models.DebugSetting @@ -893,31 +840,31 @@ class DeploymentWhatIfProperties(DeploymentProperties): """ _validation = { - 'mode': {'required': True}, + "mode": {"required": True}, } _attribute_map = { - 'template': {'key': 'template', 'type': 'object'}, - 'template_link': {'key': 'templateLink', 'type': 'TemplateLink'}, - 'parameters': {'key': 'parameters', 'type': 'object'}, - 'parameters_link': {'key': 'parametersLink', 'type': 'ParametersLink'}, - 'mode': {'key': 'mode', 'type': 'str'}, - 'debug_setting': {'key': 'debugSetting', 'type': 'DebugSetting'}, - 'on_error_deployment': {'key': 'onErrorDeployment', 'type': 'OnErrorDeployment'}, - 'what_if_settings': {'key': 'whatIfSettings', 'type': 'DeploymentWhatIfSettings'}, + "template": {"key": "template", "type": "object"}, + "template_link": {"key": "templateLink", "type": "TemplateLink"}, + "parameters": {"key": "parameters", "type": "object"}, + "parameters_link": {"key": "parametersLink", "type": "ParametersLink"}, + "mode": {"key": "mode", "type": "str"}, + "debug_setting": {"key": "debugSetting", "type": "DebugSetting"}, + "on_error_deployment": {"key": "onErrorDeployment", "type": "OnErrorDeployment"}, + "what_if_settings": {"key": "whatIfSettings", "type": "DeploymentWhatIfSettings"}, } def __init__( self, *, - mode: Union[str, "DeploymentMode"], - template: Optional[Any] = None, - template_link: Optional["TemplateLink"] = None, - parameters: Optional[Any] = None, - parameters_link: Optional["ParametersLink"] = None, - debug_setting: Optional["DebugSetting"] = None, - on_error_deployment: Optional["OnErrorDeployment"] = None, - what_if_settings: Optional["DeploymentWhatIfSettings"] = None, + mode: Union[str, "_models.DeploymentMode"], + template: Optional[JSON] = None, + template_link: Optional["_models.TemplateLink"] = None, + parameters: Optional[JSON] = None, + parameters_link: Optional["_models.ParametersLink"] = None, + debug_setting: Optional["_models.DebugSetting"] = None, + on_error_deployment: Optional["_models.OnErrorDeployment"] = None, + what_if_settings: Optional["_models.DeploymentWhatIfSettings"] = None, **kwargs ): """ @@ -925,7 +872,7 @@ def __init__( template syntax directly in the request rather than link to an existing template. It can be a JObject or well-formed JSON string. Use either the templateLink property or the template property, but not both. - :paramtype template: any + :paramtype template: JSON :keyword template_link: The URI of the template. Use either the templateLink property or the template property, but not both. :paramtype template_link: ~azure.mgmt.resource.resources.v2019_08_01.models.TemplateLink @@ -933,17 +880,17 @@ def __init__( template. You use this element when you want to provide the parameter values directly in the request rather than link to an existing parameter file. Use either the parametersLink property or the parameters property, but not both. It can be a JObject or a well formed JSON string. - :paramtype parameters: any + :paramtype parameters: JSON :keyword parameters_link: The URI of parameters file. You use this element to link to an existing parameters file. Use either the parametersLink property or the parameters property, but not both. :paramtype parameters_link: ~azure.mgmt.resource.resources.v2019_08_01.models.ParametersLink - :keyword mode: Required. The mode that is used to deploy resources. This value can be either - Incremental or Complete. In Incremental mode, resources are deployed without deleting existing - resources that are not included in the template. In Complete mode, resources are deployed and - existing resources in the resource group that are not included in the template are deleted. Be - careful when using Complete mode as you may unintentionally delete resources. Possible values - include: "Incremental", "Complete". + :keyword mode: The mode that is used to deploy resources. This value can be either Incremental + or Complete. In Incremental mode, resources are deployed without deleting existing resources + that are not included in the template. In Complete mode, resources are deployed and existing + resources in the resource group that are not included in the template are deleted. Be careful + when using Complete mode as you may unintentionally delete resources. Required. Known values + are: "Incremental" and "Complete". :paramtype mode: str or ~azure.mgmt.resource.resources.v2019_08_01.models.DeploymentMode :keyword debug_setting: The debug setting of the deployment. :paramtype debug_setting: ~azure.mgmt.resource.resources.v2019_08_01.models.DebugSetting @@ -954,40 +901,44 @@ def __init__( :paramtype what_if_settings: ~azure.mgmt.resource.resources.v2019_08_01.models.DeploymentWhatIfSettings """ - super(DeploymentWhatIfProperties, self).__init__(template=template, template_link=template_link, parameters=parameters, parameters_link=parameters_link, mode=mode, debug_setting=debug_setting, on_error_deployment=on_error_deployment, **kwargs) + super().__init__( + template=template, + template_link=template_link, + parameters=parameters, + parameters_link=parameters_link, + mode=mode, + debug_setting=debug_setting, + on_error_deployment=on_error_deployment, + **kwargs + ) self.what_if_settings = what_if_settings -class DeploymentWhatIfSettings(msrest.serialization.Model): +class DeploymentWhatIfSettings(_serialization.Model): """Deployment What-If operation settings. - :ivar result_format: The format of the What-If results. Possible values include: - "ResourceIdOnly", "FullResourcePayloads". + :ivar result_format: The format of the What-If results. Known values are: "ResourceIdOnly" and + "FullResourcePayloads". :vartype result_format: str or ~azure.mgmt.resource.resources.v2019_08_01.models.WhatIfResultFormat """ _attribute_map = { - 'result_format': {'key': 'resultFormat', 'type': 'str'}, + "result_format": {"key": "resultFormat", "type": "str"}, } - def __init__( - self, - *, - result_format: Optional[Union[str, "WhatIfResultFormat"]] = None, - **kwargs - ): + def __init__(self, *, result_format: Optional[Union[str, "_models.WhatIfResultFormat"]] = None, **kwargs): """ - :keyword result_format: The format of the What-If results. Possible values include: - "ResourceIdOnly", "FullResourcePayloads". + :keyword result_format: The format of the What-If results. Known values are: "ResourceIdOnly" + and "FullResourcePayloads". :paramtype result_format: str or ~azure.mgmt.resource.resources.v2019_08_01.models.WhatIfResultFormat """ - super(DeploymentWhatIfSettings, self).__init__(**kwargs) + super().__init__(**kwargs) self.result_format = result_format -class ErrorAdditionalInfo(msrest.serialization.Model): +class ErrorAdditionalInfo(_serialization.Model): """The resource management error additional info. Variables are only populated by the server, and will be ignored when sending a request. @@ -995,31 +946,27 @@ class ErrorAdditionalInfo(msrest.serialization.Model): :ivar type: The additional info type. :vartype type: str :ivar info: The additional info. - :vartype info: any + :vartype info: JSON """ _validation = { - 'type': {'readonly': True}, - 'info': {'readonly': True}, + "type": {"readonly": True}, + "info": {"readonly": True}, } _attribute_map = { - 'type': {'key': 'type', 'type': 'str'}, - 'info': {'key': 'info', 'type': 'object'}, + "type": {"key": "type", "type": "str"}, + "info": {"key": "info", "type": "object"}, } - def __init__( - self, - **kwargs - ): - """ - """ - super(ErrorAdditionalInfo, self).__init__(**kwargs) + def __init__(self, **kwargs): + """ """ + super().__init__(**kwargs) self.type = None self.info = None -class ErrorResponse(msrest.serialization.Model): +class ErrorResponse(_serialization.Model): """Common error response for all Azure Resource Manager APIs to return error details for failed operations. (This also follows the OData error response format.). Variables are only populated by the server, and will be ignored when sending a request. @@ -1038,28 +985,24 @@ class ErrorResponse(msrest.serialization.Model): """ _validation = { - 'code': {'readonly': True}, - 'message': {'readonly': True}, - 'target': {'readonly': True}, - 'details': {'readonly': True}, - 'additional_info': {'readonly': True}, + "code": {"readonly": True}, + "message": {"readonly": True}, + "target": {"readonly": True}, + "details": {"readonly": True}, + "additional_info": {"readonly": True}, } _attribute_map = { - 'code': {'key': 'code', 'type': 'str'}, - 'message': {'key': 'message', 'type': 'str'}, - 'target': {'key': 'target', 'type': 'str'}, - 'details': {'key': 'details', 'type': '[ErrorResponse]'}, - 'additional_info': {'key': 'additionalInfo', 'type': '[ErrorAdditionalInfo]'}, + "code": {"key": "code", "type": "str"}, + "message": {"key": "message", "type": "str"}, + "target": {"key": "target", "type": "str"}, + "details": {"key": "details", "type": "[ErrorResponse]"}, + "additional_info": {"key": "additionalInfo", "type": "[ErrorAdditionalInfo]"}, } - def __init__( - self, - **kwargs - ): - """ - """ - super(ErrorResponse, self).__init__(**kwargs) + def __init__(self, **kwargs): + """ """ + super().__init__(**kwargs) self.code = None self.message = None self.target = None @@ -1067,7 +1010,7 @@ def __init__( self.additional_info = None -class ExportTemplateRequest(msrest.serialization.Model): +class ExportTemplateRequest(_serialization.Model): """Export resource group template request parameters. :ivar resources: The IDs of the resources to filter the export by. To export all resources, @@ -1080,17 +1023,11 @@ class ExportTemplateRequest(msrest.serialization.Model): """ _attribute_map = { - 'resources': {'key': 'resources', 'type': '[str]'}, - 'options': {'key': 'options', 'type': 'str'}, + "resources": {"key": "resources", "type": "[str]"}, + "options": {"key": "options", "type": "str"}, } - def __init__( - self, - *, - resources: Optional[List[str]] = None, - options: Optional[str] = None, - **kwargs - ): + def __init__(self, *, resources: Optional[List[str]] = None, options: Optional[str] = None, **kwargs): """ :keyword resources: The IDs of the resources to filter the export by. To export all resources, supply an array with single entry '*'. @@ -1100,12 +1037,12 @@ def __init__( 'SkipResourceNameParameterization', 'SkipAllParameterization'. :paramtype options: str """ - super(ExportTemplateRequest, self).__init__(**kwargs) + super().__init__(**kwargs) self.resources = resources self.options = options -class Resource(msrest.serialization.Model): +class Resource(_serialization.Model): """Specified resource. Variables are only populated by the server, and will be ignored when sending a request. @@ -1118,38 +1055,32 @@ class Resource(msrest.serialization.Model): :vartype type: str :ivar location: Resource location. :vartype location: str - :ivar tags: A set of tags. Resource tags. + :ivar tags: Resource tags. :vartype tags: dict[str, str] """ _validation = { - 'id': {'readonly': True}, - 'name': {'readonly': True}, - 'type': {'readonly': True}, + "id": {"readonly": True}, + "name": {"readonly": True}, + "type": {"readonly": True}, } _attribute_map = { - 'id': {'key': 'id', 'type': 'str'}, - 'name': {'key': 'name', 'type': 'str'}, - 'type': {'key': 'type', 'type': 'str'}, - 'location': {'key': 'location', 'type': 'str'}, - 'tags': {'key': 'tags', 'type': '{str}'}, + "id": {"key": "id", "type": "str"}, + "name": {"key": "name", "type": "str"}, + "type": {"key": "type", "type": "str"}, + "location": {"key": "location", "type": "str"}, + "tags": {"key": "tags", "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): """ :keyword location: Resource location. :paramtype location: str - :keyword tags: A set of tags. Resource tags. + :keyword tags: Resource tags. :paramtype tags: dict[str, str] """ - super(Resource, self).__init__(**kwargs) + super().__init__(**kwargs) self.id = None self.name = None self.type = None @@ -1157,7 +1088,7 @@ def __init__( self.tags = tags -class GenericResource(Resource): +class GenericResource(Resource): # pylint: disable=too-many-instance-attributes """Resource information. Variables are only populated by the server, and will be ignored when sending a request. @@ -1170,12 +1101,12 @@ class GenericResource(Resource): :vartype type: str :ivar location: Resource location. :vartype location: str - :ivar tags: A set of tags. Resource tags. + :ivar tags: Resource tags. :vartype tags: dict[str, str] :ivar plan: The plan of the resource. :vartype plan: ~azure.mgmt.resource.resources.v2019_08_01.models.Plan :ivar properties: The resource properties. - :vartype properties: any + :vartype properties: JSON :ivar kind: The kind of the resource. :vartype kind: str :ivar managed_by: ID of the resource that manages this resource. @@ -1187,24 +1118,24 @@ class GenericResource(Resource): """ _validation = { - 'id': {'readonly': True}, - 'name': {'readonly': True}, - 'type': {'readonly': True}, - 'kind': {'pattern': r'^[-\w\._,\(\)]+$'}, + "id": {"readonly": True}, + "name": {"readonly": True}, + "type": {"readonly": True}, + "kind": {"pattern": r"^[-\w\._,\(\)]+$"}, } _attribute_map = { - 'id': {'key': 'id', 'type': 'str'}, - 'name': {'key': 'name', 'type': 'str'}, - 'type': {'key': 'type', 'type': 'str'}, - 'location': {'key': 'location', 'type': 'str'}, - 'tags': {'key': 'tags', 'type': '{str}'}, - 'plan': {'key': 'plan', 'type': 'Plan'}, - 'properties': {'key': 'properties', 'type': 'object'}, - 'kind': {'key': 'kind', 'type': 'str'}, - 'managed_by': {'key': 'managedBy', 'type': 'str'}, - 'sku': {'key': 'sku', 'type': 'Sku'}, - 'identity': {'key': 'identity', 'type': 'Identity'}, + "id": {"key": "id", "type": "str"}, + "name": {"key": "name", "type": "str"}, + "type": {"key": "type", "type": "str"}, + "location": {"key": "location", "type": "str"}, + "tags": {"key": "tags", "type": "{str}"}, + "plan": {"key": "plan", "type": "Plan"}, + "properties": {"key": "properties", "type": "object"}, + "kind": {"key": "kind", "type": "str"}, + "managed_by": {"key": "managedBy", "type": "str"}, + "sku": {"key": "sku", "type": "Sku"}, + "identity": {"key": "identity", "type": "Identity"}, } def __init__( @@ -1212,23 +1143,23 @@ def __init__( *, location: Optional[str] = None, tags: Optional[Dict[str, str]] = None, - plan: Optional["Plan"] = None, - properties: Optional[Any] = None, + plan: Optional["_models.Plan"] = None, + properties: Optional[JSON] = None, kind: Optional[str] = None, managed_by: Optional[str] = None, - sku: Optional["Sku"] = None, - identity: Optional["Identity"] = None, + sku: Optional["_models.Sku"] = None, + identity: Optional["_models.Identity"] = None, **kwargs ): """ :keyword location: Resource location. :paramtype location: str - :keyword tags: A set of tags. Resource tags. + :keyword tags: Resource tags. :paramtype tags: dict[str, str] :keyword plan: The plan of the resource. :paramtype plan: ~azure.mgmt.resource.resources.v2019_08_01.models.Plan :keyword properties: The resource properties. - :paramtype properties: any + :paramtype properties: JSON :keyword kind: The kind of the resource. :paramtype kind: str :keyword managed_by: ID of the resource that manages this resource. @@ -1238,7 +1169,7 @@ def __init__( :keyword identity: The identity of the resource. :paramtype identity: ~azure.mgmt.resource.resources.v2019_08_01.models.Identity """ - super(GenericResource, self).__init__(location=location, tags=tags, **kwargs) + super().__init__(location=location, tags=tags, **kwargs) self.plan = plan self.properties = properties self.kind = kind @@ -1247,7 +1178,7 @@ def __init__( self.identity = identity -class GenericResourceExpanded(GenericResource): +class GenericResourceExpanded(GenericResource): # pylint: disable=too-many-instance-attributes """Resource information. Variables are only populated by the server, and will be ignored when sending a request. @@ -1260,12 +1191,12 @@ class GenericResourceExpanded(GenericResource): :vartype type: str :ivar location: Resource location. :vartype location: str - :ivar tags: A set of tags. Resource tags. + :ivar tags: Resource tags. :vartype tags: dict[str, str] :ivar plan: The plan of the resource. :vartype plan: ~azure.mgmt.resource.resources.v2019_08_01.models.Plan :ivar properties: The resource properties. - :vartype properties: any + :vartype properties: JSON :ivar kind: The kind of the resource. :vartype kind: str :ivar managed_by: ID of the resource that manages this resource. @@ -1286,30 +1217,30 @@ class GenericResourceExpanded(GenericResource): """ _validation = { - 'id': {'readonly': True}, - 'name': {'readonly': True}, - 'type': {'readonly': True}, - 'kind': {'pattern': r'^[-\w\._,\(\)]+$'}, - 'created_time': {'readonly': True}, - 'changed_time': {'readonly': True}, - 'provisioning_state': {'readonly': True}, + "id": {"readonly": True}, + "name": {"readonly": True}, + "type": {"readonly": True}, + "kind": {"pattern": r"^[-\w\._,\(\)]+$"}, + "created_time": {"readonly": True}, + "changed_time": {"readonly": True}, + "provisioning_state": {"readonly": True}, } _attribute_map = { - 'id': {'key': 'id', 'type': 'str'}, - 'name': {'key': 'name', 'type': 'str'}, - 'type': {'key': 'type', 'type': 'str'}, - 'location': {'key': 'location', 'type': 'str'}, - 'tags': {'key': 'tags', 'type': '{str}'}, - 'plan': {'key': 'plan', 'type': 'Plan'}, - 'properties': {'key': 'properties', 'type': 'object'}, - 'kind': {'key': 'kind', 'type': 'str'}, - 'managed_by': {'key': 'managedBy', 'type': 'str'}, - 'sku': {'key': 'sku', 'type': 'Sku'}, - 'identity': {'key': 'identity', 'type': 'Identity'}, - 'created_time': {'key': 'createdTime', 'type': 'iso-8601'}, - 'changed_time': {'key': 'changedTime', 'type': 'iso-8601'}, - 'provisioning_state': {'key': 'provisioningState', 'type': 'str'}, + "id": {"key": "id", "type": "str"}, + "name": {"key": "name", "type": "str"}, + "type": {"key": "type", "type": "str"}, + "location": {"key": "location", "type": "str"}, + "tags": {"key": "tags", "type": "{str}"}, + "plan": {"key": "plan", "type": "Plan"}, + "properties": {"key": "properties", "type": "object"}, + "kind": {"key": "kind", "type": "str"}, + "managed_by": {"key": "managedBy", "type": "str"}, + "sku": {"key": "sku", "type": "Sku"}, + "identity": {"key": "identity", "type": "Identity"}, + "created_time": {"key": "createdTime", "type": "iso-8601"}, + "changed_time": {"key": "changedTime", "type": "iso-8601"}, + "provisioning_state": {"key": "provisioningState", "type": "str"}, } def __init__( @@ -1317,23 +1248,23 @@ def __init__( *, location: Optional[str] = None, tags: Optional[Dict[str, str]] = None, - plan: Optional["Plan"] = None, - properties: Optional[Any] = None, + plan: Optional["_models.Plan"] = None, + properties: Optional[JSON] = None, kind: Optional[str] = None, managed_by: Optional[str] = None, - sku: Optional["Sku"] = None, - identity: Optional["Identity"] = None, + sku: Optional["_models.Sku"] = None, + identity: Optional["_models.Identity"] = None, **kwargs ): """ :keyword location: Resource location. :paramtype location: str - :keyword tags: A set of tags. Resource tags. + :keyword tags: Resource tags. :paramtype tags: dict[str, str] :keyword plan: The plan of the resource. :paramtype plan: ~azure.mgmt.resource.resources.v2019_08_01.models.Plan :keyword properties: The resource properties. - :paramtype properties: any + :paramtype properties: JSON :keyword kind: The kind of the resource. :paramtype kind: str :keyword managed_by: ID of the resource that manages this resource. @@ -1343,13 +1274,23 @@ def __init__( :keyword identity: The identity of the resource. :paramtype identity: ~azure.mgmt.resource.resources.v2019_08_01.models.Identity """ - super(GenericResourceExpanded, self).__init__(location=location, tags=tags, plan=plan, properties=properties, kind=kind, managed_by=managed_by, sku=sku, identity=identity, **kwargs) + super().__init__( + location=location, + tags=tags, + plan=plan, + properties=properties, + kind=kind, + managed_by=managed_by, + sku=sku, + identity=identity, + **kwargs + ) self.created_time = None self.changed_time = None self.provisioning_state = None -class GenericResourceFilter(msrest.serialization.Model): +class GenericResourceFilter(_serialization.Model): """Resource filter. :ivar resource_type: The resource type. @@ -1361,9 +1302,9 @@ class GenericResourceFilter(msrest.serialization.Model): """ _attribute_map = { - 'resource_type': {'key': 'resourceType', 'type': 'str'}, - 'tagname': {'key': 'tagname', 'type': 'str'}, - 'tagvalue': {'key': 'tagvalue', 'type': 'str'}, + "resource_type": {"key": "resourceType", "type": "str"}, + "tagname": {"key": "tagname", "type": "str"}, + "tagvalue": {"key": "tagvalue", "type": "str"}, } def __init__( @@ -1382,38 +1323,33 @@ def __init__( :keyword tagvalue: The tag value. :paramtype tagvalue: str """ - super(GenericResourceFilter, self).__init__(**kwargs) + super().__init__(**kwargs) self.resource_type = resource_type self.tagname = tagname self.tagvalue = tagvalue -class HttpMessage(msrest.serialization.Model): +class HttpMessage(_serialization.Model): """HTTP message. :ivar content: HTTP message content. - :vartype content: any + :vartype content: JSON """ _attribute_map = { - 'content': {'key': 'content', 'type': 'object'}, + "content": {"key": "content", "type": "object"}, } - def __init__( - self, - *, - content: Optional[Any] = None, - **kwargs - ): + def __init__(self, *, content: Optional[JSON] = None, **kwargs): """ :keyword content: HTTP message content. - :paramtype content: any + :paramtype content: JSON """ - super(HttpMessage, self).__init__(**kwargs) + super().__init__(**kwargs) self.content = content -class Identity(msrest.serialization.Model): +class Identity(_serialization.Model): """Identity for the resource. Variables are only populated by the server, and will be ignored when sending a request. @@ -1422,8 +1358,8 @@ class Identity(msrest.serialization.Model): :vartype principal_id: str :ivar tenant_id: The tenant ID of resource. :vartype tenant_id: str - :ivar type: The identity type. Possible values include: "SystemAssigned", "UserAssigned", - "SystemAssigned, UserAssigned", "None". + :ivar type: The identity type. Known values are: "SystemAssigned", "UserAssigned", + "SystemAssigned, UserAssigned", and "None". :vartype type: str or ~azure.mgmt.resource.resources.v2019_08_01.models.ResourceIdentityType :ivar user_assigned_identities: The list of user identities associated with the resource. The user identity dictionary key references will be ARM resource ids in the form: @@ -1433,27 +1369,32 @@ class Identity(msrest.serialization.Model): """ _validation = { - 'principal_id': {'readonly': True}, - 'tenant_id': {'readonly': True}, + "principal_id": {"readonly": True}, + "tenant_id": {"readonly": True}, } _attribute_map = { - 'principal_id': {'key': 'principalId', 'type': 'str'}, - 'tenant_id': {'key': 'tenantId', 'type': 'str'}, - 'type': {'key': 'type', 'type': 'str'}, - 'user_assigned_identities': {'key': 'userAssignedIdentities', 'type': '{ComponentsSgqdofSchemasIdentityPropertiesUserassignedidentitiesAdditionalproperties}'}, + "principal_id": {"key": "principalId", "type": "str"}, + "tenant_id": {"key": "tenantId", "type": "str"}, + "type": {"key": "type", "type": "str"}, + "user_assigned_identities": { + "key": "userAssignedIdentities", + "type": "{ComponentsSgqdofSchemasIdentityPropertiesUserassignedidentitiesAdditionalproperties}", + }, } def __init__( self, *, - type: Optional[Union[str, "ResourceIdentityType"]] = None, - user_assigned_identities: Optional[Dict[str, "ComponentsSgqdofSchemasIdentityPropertiesUserassignedidentitiesAdditionalproperties"]] = None, + type: Optional[Union[str, "_models.ResourceIdentityType"]] = None, + user_assigned_identities: Optional[ + Dict[str, "_models.ComponentsSgqdofSchemasIdentityPropertiesUserassignedidentitiesAdditionalproperties"] + ] = None, **kwargs ): """ - :keyword type: The identity type. Possible values include: "SystemAssigned", "UserAssigned", - "SystemAssigned, UserAssigned", "None". + :keyword type: The identity type. Known values are: "SystemAssigned", "UserAssigned", + "SystemAssigned, UserAssigned", and "None". :paramtype type: str or ~azure.mgmt.resource.resources.v2019_08_01.models.ResourceIdentityType :keyword user_assigned_identities: The list of user identities associated with the resource. The user identity dictionary key references will be ARM resource ids in the form: @@ -1461,48 +1402,48 @@ def __init__( :paramtype user_assigned_identities: dict[str, ~azure.mgmt.resource.resources.v2019_08_01.models.ComponentsSgqdofSchemasIdentityPropertiesUserassignedidentitiesAdditionalproperties] """ - super(Identity, self).__init__(**kwargs) + super().__init__(**kwargs) self.principal_id = None self.tenant_id = None self.type = type self.user_assigned_identities = user_assigned_identities -class OnErrorDeployment(msrest.serialization.Model): +class OnErrorDeployment(_serialization.Model): """Deployment on error behavior. :ivar type: The deployment on error behavior type. Possible values are LastSuccessful and - SpecificDeployment. Possible values include: "LastSuccessful", "SpecificDeployment". + SpecificDeployment. Known values are: "LastSuccessful" and "SpecificDeployment". :vartype type: str or ~azure.mgmt.resource.resources.v2019_08_01.models.OnErrorDeploymentType :ivar deployment_name: The deployment to be used on error case. :vartype deployment_name: str """ _attribute_map = { - 'type': {'key': 'type', 'type': 'str'}, - 'deployment_name': {'key': 'deploymentName', 'type': 'str'}, + "type": {"key": "type", "type": "str"}, + "deployment_name": {"key": "deploymentName", "type": "str"}, } def __init__( self, *, - type: Optional[Union[str, "OnErrorDeploymentType"]] = None, + type: Optional[Union[str, "_models.OnErrorDeploymentType"]] = None, deployment_name: Optional[str] = None, **kwargs ): """ :keyword type: The deployment on error behavior type. Possible values are LastSuccessful and - SpecificDeployment. Possible values include: "LastSuccessful", "SpecificDeployment". + SpecificDeployment. Known values are: "LastSuccessful" and "SpecificDeployment". :paramtype type: str or ~azure.mgmt.resource.resources.v2019_08_01.models.OnErrorDeploymentType :keyword deployment_name: The deployment to be used on error case. :paramtype deployment_name: str """ - super(OnErrorDeployment, self).__init__(**kwargs) + super().__init__(**kwargs) self.type = type self.deployment_name = deployment_name -class OnErrorDeploymentExtended(msrest.serialization.Model): +class OnErrorDeploymentExtended(_serialization.Model): """Deployment on error behavior with additional details. Variables are only populated by the server, and will be ignored when sending a request. @@ -1510,43 +1451,43 @@ class OnErrorDeploymentExtended(msrest.serialization.Model): :ivar provisioning_state: The state of the provisioning for the on error deployment. :vartype provisioning_state: str :ivar type: The deployment on error behavior type. Possible values are LastSuccessful and - SpecificDeployment. Possible values include: "LastSuccessful", "SpecificDeployment". + SpecificDeployment. Known values are: "LastSuccessful" and "SpecificDeployment". :vartype type: str or ~azure.mgmt.resource.resources.v2019_08_01.models.OnErrorDeploymentType :ivar deployment_name: The deployment to be used on error case. :vartype deployment_name: str """ _validation = { - 'provisioning_state': {'readonly': True}, + "provisioning_state": {"readonly": True}, } _attribute_map = { - 'provisioning_state': {'key': 'provisioningState', 'type': 'str'}, - 'type': {'key': 'type', 'type': 'str'}, - 'deployment_name': {'key': 'deploymentName', 'type': 'str'}, + "provisioning_state": {"key": "provisioningState", "type": "str"}, + "type": {"key": "type", "type": "str"}, + "deployment_name": {"key": "deploymentName", "type": "str"}, } def __init__( self, *, - type: Optional[Union[str, "OnErrorDeploymentType"]] = None, + type: Optional[Union[str, "_models.OnErrorDeploymentType"]] = None, deployment_name: Optional[str] = None, **kwargs ): """ :keyword type: The deployment on error behavior type. Possible values are LastSuccessful and - SpecificDeployment. Possible values include: "LastSuccessful", "SpecificDeployment". + SpecificDeployment. Known values are: "LastSuccessful" and "SpecificDeployment". :paramtype type: str or ~azure.mgmt.resource.resources.v2019_08_01.models.OnErrorDeploymentType :keyword deployment_name: The deployment to be used on error case. :paramtype deployment_name: str """ - super(OnErrorDeploymentExtended, self).__init__(**kwargs) + super().__init__(**kwargs) self.provisioning_state = None self.type = type self.deployment_name = deployment_name -class Operation(msrest.serialization.Model): +class Operation(_serialization.Model): """Microsoft.Resources operation. :ivar name: Operation name: {provider}/{resource}/{operation}. @@ -1556,29 +1497,23 @@ class Operation(msrest.serialization.Model): """ _attribute_map = { - 'name': {'key': 'name', 'type': 'str'}, - 'display': {'key': 'display', 'type': 'OperationDisplay'}, + "name": {"key": "name", "type": "str"}, + "display": {"key": "display", "type": "OperationDisplay"}, } - def __init__( - self, - *, - name: Optional[str] = None, - display: Optional["OperationDisplay"] = None, - **kwargs - ): + def __init__(self, *, name: Optional[str] = None, display: Optional["_models.OperationDisplay"] = None, **kwargs): """ :keyword name: Operation name: {provider}/{resource}/{operation}. :paramtype name: str :keyword display: The object that represents the operation. :paramtype display: ~azure.mgmt.resource.resources.v2019_08_01.models.OperationDisplay """ - super(Operation, self).__init__(**kwargs) + super().__init__(**kwargs) self.name = name self.display = display -class OperationDisplay(msrest.serialization.Model): +class OperationDisplay(_serialization.Model): """The object that represents the operation. :ivar provider: Service provider: Microsoft.Resources. @@ -1592,10 +1527,10 @@ class OperationDisplay(msrest.serialization.Model): """ _attribute_map = { - 'provider': {'key': 'provider', 'type': 'str'}, - 'resource': {'key': 'resource', 'type': 'str'}, - 'operation': {'key': 'operation', 'type': 'str'}, - 'description': {'key': 'description', 'type': 'str'}, + "provider": {"key": "provider", "type": "str"}, + "resource": {"key": "resource", "type": "str"}, + "operation": {"key": "operation", "type": "str"}, + "description": {"key": "description", "type": "str"}, } def __init__( @@ -1617,14 +1552,14 @@ def __init__( :keyword description: Description of the operation. :paramtype description: str """ - super(OperationDisplay, self).__init__(**kwargs) + super().__init__(**kwargs) self.provider = provider self.resource = resource self.operation = operation self.description = description -class OperationListResult(msrest.serialization.Model): +class OperationListResult(_serialization.Model): """Result of the request to list Microsoft.Resources operations. It contains a list of operations and a URL link to get the next set of results. :ivar value: List of Microsoft.Resources operations. @@ -1634,67 +1569,55 @@ class OperationListResult(msrest.serialization.Model): """ _attribute_map = { - 'value': {'key': 'value', 'type': '[Operation]'}, - 'next_link': {'key': 'nextLink', 'type': 'str'}, + "value": {"key": "value", "type": "[Operation]"}, + "next_link": {"key": "nextLink", "type": "str"}, } - def __init__( - self, - *, - value: Optional[List["Operation"]] = None, - next_link: Optional[str] = None, - **kwargs - ): + def __init__(self, *, value: Optional[List["_models.Operation"]] = None, next_link: Optional[str] = None, **kwargs): """ :keyword value: List of Microsoft.Resources operations. :paramtype value: list[~azure.mgmt.resource.resources.v2019_08_01.models.Operation] :keyword next_link: URL to get the next set of operation list results if there are any. :paramtype next_link: str """ - super(OperationListResult, self).__init__(**kwargs) + super().__init__(**kwargs) self.value = value self.next_link = next_link -class ParametersLink(msrest.serialization.Model): +class ParametersLink(_serialization.Model): """Entity representing the reference to the deployment parameters. All required parameters must be populated in order to send to Azure. - :ivar uri: Required. The URI of the parameters file. + :ivar uri: The URI of the parameters file. Required. :vartype uri: str :ivar content_version: If included, must match the ContentVersion in the template. :vartype content_version: str """ _validation = { - 'uri': {'required': True}, + "uri": {"required": True}, } _attribute_map = { - 'uri': {'key': 'uri', 'type': 'str'}, - 'content_version': {'key': 'contentVersion', 'type': 'str'}, + "uri": {"key": "uri", "type": "str"}, + "content_version": {"key": "contentVersion", "type": "str"}, } - def __init__( - self, - *, - uri: str, - content_version: Optional[str] = None, - **kwargs - ): + def __init__(self, *, uri: str, content_version: Optional[str] = None, **kwargs): """ - :keyword uri: Required. The URI of the parameters file. + :keyword uri: The URI of the parameters file. Required. :paramtype uri: str :keyword content_version: If included, must match the ContentVersion in the template. :paramtype content_version: str """ - super(ParametersLink, self).__init__(**kwargs) + super().__init__(**kwargs) self.uri = uri self.content_version = content_version -class Plan(msrest.serialization.Model): +class Plan(_serialization.Model): """Plan for the resource. :ivar name: The plan ID. @@ -1710,11 +1633,11 @@ class Plan(msrest.serialization.Model): """ _attribute_map = { - 'name': {'key': 'name', 'type': 'str'}, - 'publisher': {'key': 'publisher', 'type': 'str'}, - 'product': {'key': 'product', 'type': 'str'}, - 'promotion_code': {'key': 'promotionCode', 'type': 'str'}, - 'version': {'key': 'version', 'type': 'str'}, + "name": {"key": "name", "type": "str"}, + "publisher": {"key": "publisher", "type": "str"}, + "product": {"key": "product", "type": "str"}, + "promotion_code": {"key": "promotionCode", "type": "str"}, + "version": {"key": "version", "type": "str"}, } def __init__( @@ -1739,7 +1662,7 @@ def __init__( :keyword version: The plan's version. :paramtype version: str """ - super(Plan, self).__init__(**kwargs) + super().__init__(**kwargs) self.name = name self.publisher = publisher self.product = product @@ -1747,7 +1670,7 @@ def __init__( self.version = version -class Provider(msrest.serialization.Model): +class Provider(_serialization.Model): """Resource provider information. Variables are only populated by the server, and will be ignored when sending a request. @@ -1766,31 +1689,26 @@ class Provider(msrest.serialization.Model): """ _validation = { - 'id': {'readonly': True}, - 'registration_state': {'readonly': True}, - 'registration_policy': {'readonly': True}, - 'resource_types': {'readonly': True}, + "id": {"readonly": True}, + "registration_state": {"readonly": True}, + "registration_policy": {"readonly": True}, + "resource_types": {"readonly": True}, } _attribute_map = { - 'id': {'key': 'id', 'type': 'str'}, - 'namespace': {'key': 'namespace', 'type': 'str'}, - 'registration_state': {'key': 'registrationState', 'type': 'str'}, - 'registration_policy': {'key': 'registrationPolicy', 'type': 'str'}, - 'resource_types': {'key': 'resourceTypes', 'type': '[ProviderResourceType]'}, + "id": {"key": "id", "type": "str"}, + "namespace": {"key": "namespace", "type": "str"}, + "registration_state": {"key": "registrationState", "type": "str"}, + "registration_policy": {"key": "registrationPolicy", "type": "str"}, + "resource_types": {"key": "resourceTypes", "type": "[ProviderResourceType]"}, } - def __init__( - self, - *, - namespace: Optional[str] = None, - **kwargs - ): + def __init__(self, *, namespace: Optional[str] = None, **kwargs): """ :keyword namespace: The namespace of the resource provider. :paramtype namespace: str """ - super(Provider, self).__init__(**kwargs) + super().__init__(**kwargs) self.id = None self.namespace = namespace self.registration_state = None @@ -1798,7 +1716,7 @@ def __init__( self.resource_types = None -class ProviderListResult(msrest.serialization.Model): +class ProviderListResult(_serialization.Model): """List of resource providers. Variables are only populated by the server, and will be ignored when sending a request. @@ -1810,30 +1728,25 @@ class ProviderListResult(msrest.serialization.Model): """ _validation = { - 'next_link': {'readonly': True}, + "next_link": {"readonly": True}, } _attribute_map = { - 'value': {'key': 'value', 'type': '[Provider]'}, - 'next_link': {'key': 'nextLink', 'type': 'str'}, + "value": {"key": "value", "type": "[Provider]"}, + "next_link": {"key": "nextLink", "type": "str"}, } - def __init__( - self, - *, - value: Optional[List["Provider"]] = None, - **kwargs - ): + def __init__(self, *, value: Optional[List["_models.Provider"]] = None, **kwargs): """ :keyword value: An array of resource providers. :paramtype value: list[~azure.mgmt.resource.resources.v2019_08_01.models.Provider] """ - super(ProviderListResult, self).__init__(**kwargs) + super().__init__(**kwargs) self.value = value self.next_link = None -class ProviderResourceType(msrest.serialization.Model): +class ProviderResourceType(_serialization.Model): """Resource type managed by the resource provider. :ivar resource_type: The resource type. @@ -1853,13 +1766,13 @@ class ProviderResourceType(msrest.serialization.Model): """ _attribute_map = { - 'resource_type': {'key': 'resourceType', 'type': 'str'}, - 'locations': {'key': 'locations', 'type': '[str]'}, - 'aliases': {'key': 'aliases', 'type': '[AliasType]'}, - 'api_versions': {'key': 'apiVersions', 'type': '[str]'}, - 'zone_mappings': {'key': 'zoneMappings', 'type': '[ZoneMapping]'}, - 'capabilities': {'key': 'capabilities', 'type': 'str'}, - 'properties': {'key': 'properties', 'type': '{str}'}, + "resource_type": {"key": "resourceType", "type": "str"}, + "locations": {"key": "locations", "type": "[str]"}, + "aliases": {"key": "aliases", "type": "[AliasType]"}, + "api_versions": {"key": "apiVersions", "type": "[str]"}, + "zone_mappings": {"key": "zoneMappings", "type": "[ZoneMapping]"}, + "capabilities": {"key": "capabilities", "type": "str"}, + "properties": {"key": "properties", "type": "{str}"}, } def __init__( @@ -1867,9 +1780,9 @@ def __init__( *, resource_type: Optional[str] = None, locations: Optional[List[str]] = None, - aliases: Optional[List["AliasType"]] = None, + aliases: Optional[List["_models.AliasType"]] = None, api_versions: Optional[List[str]] = None, - zone_mappings: Optional[List["ZoneMapping"]] = None, + zone_mappings: Optional[List["_models.ZoneMapping"]] = None, capabilities: Optional[str] = None, properties: Optional[Dict[str, str]] = None, **kwargs @@ -1890,7 +1803,7 @@ def __init__( :keyword properties: The properties. :paramtype properties: dict[str, str] """ - super(ProviderResourceType, self).__init__(**kwargs) + super().__init__(**kwargs) self.resource_type = resource_type self.locations = locations self.aliases = aliases @@ -1900,7 +1813,7 @@ def __init__( self.properties = properties -class ResourceGroup(msrest.serialization.Model): +class ResourceGroup(_serialization.Model): """Resource group information. Variables are only populated by the server, and will be ignored when sending a request. @@ -1915,37 +1828,37 @@ class ResourceGroup(msrest.serialization.Model): :vartype type: str :ivar properties: The resource group properties. :vartype properties: ~azure.mgmt.resource.resources.v2019_08_01.models.ResourceGroupProperties - :ivar location: Required. The location of the resource group. It cannot be changed after the - resource group has been created. It must be one of the supported Azure locations. + :ivar location: The location of the resource group. It cannot be changed after the resource + group has been created. It must be one of the supported Azure locations. Required. :vartype location: str :ivar managed_by: The ID of the resource that manages this resource group. :vartype managed_by: str - :ivar tags: A set of tags. The tags attached to the resource group. + :ivar tags: The tags attached to the resource group. :vartype tags: dict[str, str] """ _validation = { - 'id': {'readonly': True}, - 'name': {'readonly': True}, - 'type': {'readonly': True}, - 'location': {'required': True}, + "id": {"readonly": True}, + "name": {"readonly": True}, + "type": {"readonly": True}, + "location": {"required": True}, } _attribute_map = { - 'id': {'key': 'id', 'type': 'str'}, - 'name': {'key': 'name', 'type': 'str'}, - 'type': {'key': 'type', 'type': 'str'}, - 'properties': {'key': 'properties', 'type': 'ResourceGroupProperties'}, - 'location': {'key': 'location', 'type': 'str'}, - 'managed_by': {'key': 'managedBy', 'type': 'str'}, - 'tags': {'key': 'tags', 'type': '{str}'}, + "id": {"key": "id", "type": "str"}, + "name": {"key": "name", "type": "str"}, + "type": {"key": "type", "type": "str"}, + "properties": {"key": "properties", "type": "ResourceGroupProperties"}, + "location": {"key": "location", "type": "str"}, + "managed_by": {"key": "managedBy", "type": "str"}, + "tags": {"key": "tags", "type": "{str}"}, } def __init__( self, *, location: str, - properties: Optional["ResourceGroupProperties"] = None, + properties: Optional["_models.ResourceGroupProperties"] = None, managed_by: Optional[str] = None, tags: Optional[Dict[str, str]] = None, **kwargs @@ -1954,15 +1867,15 @@ def __init__( :keyword properties: The resource group properties. :paramtype properties: ~azure.mgmt.resource.resources.v2019_08_01.models.ResourceGroupProperties - :keyword location: Required. The location of the resource group. It cannot be changed after the - resource group has been created. It must be one of the supported Azure locations. + :keyword location: The location of the resource group. It cannot be changed after the resource + group has been created. It must be one of the supported Azure locations. Required. :paramtype location: str :keyword managed_by: The ID of the resource that manages this resource group. :paramtype managed_by: str - :keyword tags: A set of tags. The tags attached to the resource group. + :keyword tags: The tags attached to the resource group. :paramtype tags: dict[str, str] """ - super(ResourceGroup, self).__init__(**kwargs) + super().__init__(**kwargs) self.id = None self.name = None self.type = None @@ -1972,39 +1885,33 @@ def __init__( self.tags = tags -class ResourceGroupExportResult(msrest.serialization.Model): +class ResourceGroupExportResult(_serialization.Model): """Resource group export result. :ivar template: The template content. - :vartype template: any + :vartype template: JSON :ivar error: The template export error. :vartype error: ~azure.mgmt.resource.resources.v2019_08_01.models.ErrorResponse """ _attribute_map = { - 'template': {'key': 'template', 'type': 'object'}, - 'error': {'key': 'error', 'type': 'ErrorResponse'}, + "template": {"key": "template", "type": "object"}, + "error": {"key": "error", "type": "ErrorResponse"}, } - def __init__( - self, - *, - template: Optional[Any] = None, - error: Optional["ErrorResponse"] = None, - **kwargs - ): + def __init__(self, *, template: Optional[JSON] = None, error: Optional["_models.ErrorResponse"] = None, **kwargs): """ :keyword template: The template content. - :paramtype template: any + :paramtype template: JSON :keyword error: The template export error. :paramtype error: ~azure.mgmt.resource.resources.v2019_08_01.models.ErrorResponse """ - super(ResourceGroupExportResult, self).__init__(**kwargs) + super().__init__(**kwargs) self.template = template self.error = error -class ResourceGroupFilter(msrest.serialization.Model): +class ResourceGroupFilter(_serialization.Model): """Resource group filter. :ivar tag_name: The tag name. @@ -2014,29 +1921,23 @@ class ResourceGroupFilter(msrest.serialization.Model): """ _attribute_map = { - 'tag_name': {'key': 'tagName', 'type': 'str'}, - 'tag_value': {'key': 'tagValue', 'type': 'str'}, + "tag_name": {"key": "tagName", "type": "str"}, + "tag_value": {"key": "tagValue", "type": "str"}, } - def __init__( - self, - *, - tag_name: Optional[str] = None, - tag_value: Optional[str] = None, - **kwargs - ): + def __init__(self, *, tag_name: Optional[str] = None, tag_value: Optional[str] = None, **kwargs): """ :keyword tag_name: The tag name. :paramtype tag_name: str :keyword tag_value: The tag value. :paramtype tag_value: str """ - super(ResourceGroupFilter, self).__init__(**kwargs) + super().__init__(**kwargs) self.tag_name = tag_name self.tag_value = tag_value -class ResourceGroupListResult(msrest.serialization.Model): +class ResourceGroupListResult(_serialization.Model): """List of resource groups. Variables are only populated by the server, and will be ignored when sending a request. @@ -2048,30 +1949,25 @@ class ResourceGroupListResult(msrest.serialization.Model): """ _validation = { - 'next_link': {'readonly': True}, + "next_link": {"readonly": True}, } _attribute_map = { - 'value': {'key': 'value', 'type': '[ResourceGroup]'}, - 'next_link': {'key': 'nextLink', 'type': 'str'}, + "value": {"key": "value", "type": "[ResourceGroup]"}, + "next_link": {"key": "nextLink", "type": "str"}, } - def __init__( - self, - *, - value: Optional[List["ResourceGroup"]] = None, - **kwargs - ): + def __init__(self, *, value: Optional[List["_models.ResourceGroup"]] = None, **kwargs): """ :keyword value: An array of resource groups. :paramtype value: list[~azure.mgmt.resource.resources.v2019_08_01.models.ResourceGroup] """ - super(ResourceGroupListResult, self).__init__(**kwargs) + super().__init__(**kwargs) self.value = value self.next_link = None -class ResourceGroupPatchable(msrest.serialization.Model): +class ResourceGroupPatchable(_serialization.Model): """Resource group information. :ivar name: The name of the resource group. @@ -2080,22 +1976,22 @@ class ResourceGroupPatchable(msrest.serialization.Model): :vartype properties: ~azure.mgmt.resource.resources.v2019_08_01.models.ResourceGroupProperties :ivar managed_by: The ID of the resource that manages this resource group. :vartype managed_by: str - :ivar tags: A set of tags. The tags attached to the resource group. + :ivar tags: The tags attached to the resource group. :vartype tags: dict[str, str] """ _attribute_map = { - 'name': {'key': 'name', 'type': 'str'}, - 'properties': {'key': 'properties', 'type': 'ResourceGroupProperties'}, - 'managed_by': {'key': 'managedBy', 'type': 'str'}, - 'tags': {'key': 'tags', 'type': '{str}'}, + "name": {"key": "name", "type": "str"}, + "properties": {"key": "properties", "type": "ResourceGroupProperties"}, + "managed_by": {"key": "managedBy", "type": "str"}, + "tags": {"key": "tags", "type": "{str}"}, } def __init__( self, *, name: Optional[str] = None, - properties: Optional["ResourceGroupProperties"] = None, + properties: Optional["_models.ResourceGroupProperties"] = None, managed_by: Optional[str] = None, tags: Optional[Dict[str, str]] = None, **kwargs @@ -2108,17 +2004,17 @@ def __init__( ~azure.mgmt.resource.resources.v2019_08_01.models.ResourceGroupProperties :keyword managed_by: The ID of the resource that manages this resource group. :paramtype managed_by: str - :keyword tags: A set of tags. The tags attached to the resource group. + :keyword tags: The tags attached to the resource group. :paramtype tags: dict[str, str] """ - super(ResourceGroupPatchable, self).__init__(**kwargs) + super().__init__(**kwargs) self.name = name self.properties = properties self.managed_by = managed_by self.tags = tags -class ResourceGroupProperties(msrest.serialization.Model): +class ResourceGroupProperties(_serialization.Model): """The resource group properties. Variables are only populated by the server, and will be ignored when sending a request. @@ -2128,24 +2024,20 @@ class ResourceGroupProperties(msrest.serialization.Model): """ _validation = { - 'provisioning_state': {'readonly': True}, + "provisioning_state": {"readonly": True}, } _attribute_map = { - 'provisioning_state': {'key': 'provisioningState', 'type': 'str'}, + "provisioning_state": {"key": "provisioningState", "type": "str"}, } - def __init__( - self, - **kwargs - ): - """ - """ - super(ResourceGroupProperties, self).__init__(**kwargs) + def __init__(self, **kwargs): + """ """ + super().__init__(**kwargs) self.provisioning_state = None -class ResourceListResult(msrest.serialization.Model): +class ResourceListResult(_serialization.Model): """List of resource groups. Variables are only populated by the server, and will be ignored when sending a request. @@ -2157,31 +2049,26 @@ class ResourceListResult(msrest.serialization.Model): """ _validation = { - 'next_link': {'readonly': True}, + "next_link": {"readonly": True}, } _attribute_map = { - 'value': {'key': 'value', 'type': '[GenericResourceExpanded]'}, - 'next_link': {'key': 'nextLink', 'type': 'str'}, + "value": {"key": "value", "type": "[GenericResourceExpanded]"}, + "next_link": {"key": "nextLink", "type": "str"}, } - def __init__( - self, - *, - value: Optional[List["GenericResourceExpanded"]] = None, - **kwargs - ): + def __init__(self, *, value: Optional[List["_models.GenericResourceExpanded"]] = None, **kwargs): """ :keyword value: An array of resources. :paramtype value: list[~azure.mgmt.resource.resources.v2019_08_01.models.GenericResourceExpanded] """ - super(ResourceListResult, self).__init__(**kwargs) + super().__init__(**kwargs) self.value = value self.next_link = None -class ResourceProviderOperationDisplayProperties(msrest.serialization.Model): +class ResourceProviderOperationDisplayProperties(_serialization.Model): """Resource provider operation's display properties. :ivar publisher: Operation description. @@ -2197,11 +2084,11 @@ class ResourceProviderOperationDisplayProperties(msrest.serialization.Model): """ _attribute_map = { - 'publisher': {'key': 'publisher', 'type': 'str'}, - 'provider': {'key': 'provider', 'type': 'str'}, - 'resource': {'key': 'resource', 'type': 'str'}, - 'operation': {'key': 'operation', 'type': 'str'}, - 'description': {'key': 'description', 'type': 'str'}, + "publisher": {"key": "publisher", "type": "str"}, + "provider": {"key": "provider", "type": "str"}, + "resource": {"key": "resource", "type": "str"}, + "operation": {"key": "operation", "type": "str"}, + "description": {"key": "description", "type": "str"}, } def __init__( @@ -2226,7 +2113,7 @@ def __init__( :keyword description: Operation description. :paramtype description: str """ - super(ResourceProviderOperationDisplayProperties, self).__init__(**kwargs) + super().__init__(**kwargs) self.publisher = publisher self.provider = provider self.resource = resource @@ -2234,7 +2121,7 @@ def __init__( self.description = description -class ResourcesMoveInfo(msrest.serialization.Model): +class ResourcesMoveInfo(_serialization.Model): """Parameters of move resources. :ivar resources: The IDs of the resources. @@ -2244,68 +2131,56 @@ class ResourcesMoveInfo(msrest.serialization.Model): """ _attribute_map = { - 'resources': {'key': 'resources', 'type': '[str]'}, - 'target_resource_group': {'key': 'targetResourceGroup', 'type': 'str'}, + "resources": {"key": "resources", "type": "[str]"}, + "target_resource_group": {"key": "targetResourceGroup", "type": "str"}, } - def __init__( - self, - *, - resources: Optional[List[str]] = None, - target_resource_group: Optional[str] = None, - **kwargs - ): + def __init__(self, *, resources: Optional[List[str]] = None, target_resource_group: Optional[str] = None, **kwargs): """ :keyword resources: The IDs of the resources. :paramtype resources: list[str] :keyword target_resource_group: The target resource group. :paramtype target_resource_group: str """ - super(ResourcesMoveInfo, self).__init__(**kwargs) + super().__init__(**kwargs) self.resources = resources self.target_resource_group = target_resource_group -class ScopedDeployment(msrest.serialization.Model): +class ScopedDeployment(_serialization.Model): """Deployment operation parameters. All required parameters must be populated in order to send to Azure. - :ivar location: Required. The location to store the deployment data. + :ivar location: The location to store the deployment data. Required. :vartype location: str - :ivar properties: Required. The deployment properties. + :ivar properties: The deployment properties. Required. :vartype properties: ~azure.mgmt.resource.resources.v2019_08_01.models.DeploymentProperties """ _validation = { - 'location': {'required': True}, - 'properties': {'required': True}, + "location": {"required": True}, + "properties": {"required": True}, } _attribute_map = { - 'location': {'key': 'location', 'type': 'str'}, - 'properties': {'key': 'properties', 'type': 'DeploymentProperties'}, + "location": {"key": "location", "type": "str"}, + "properties": {"key": "properties", "type": "DeploymentProperties"}, } - def __init__( - self, - *, - location: str, - properties: "DeploymentProperties", - **kwargs - ): + def __init__(self, *, location: str, properties: "_models.DeploymentProperties", **kwargs): """ - :keyword location: Required. The location to store the deployment data. + :keyword location: The location to store the deployment data. Required. :paramtype location: str - :keyword properties: Required. The deployment properties. + :keyword properties: The deployment properties. Required. :paramtype properties: ~azure.mgmt.resource.resources.v2019_08_01.models.DeploymentProperties """ - super(ScopedDeployment, self).__init__(**kwargs) + super().__init__(**kwargs) self.location = location self.properties = properties -class Sku(msrest.serialization.Model): +class Sku(_serialization.Model): """SKU for the resource. :ivar name: The SKU name. @@ -2323,12 +2198,12 @@ class Sku(msrest.serialization.Model): """ _attribute_map = { - 'name': {'key': 'name', 'type': 'str'}, - 'tier': {'key': 'tier', 'type': 'str'}, - 'size': {'key': 'size', 'type': 'str'}, - 'family': {'key': 'family', 'type': 'str'}, - 'model': {'key': 'model', 'type': 'str'}, - 'capacity': {'key': 'capacity', 'type': 'int'}, + "name": {"key": "name", "type": "str"}, + "tier": {"key": "tier", "type": "str"}, + "size": {"key": "size", "type": "str"}, + "family": {"key": "family", "type": "str"}, + "model": {"key": "model", "type": "str"}, + "capacity": {"key": "capacity", "type": "int"}, } def __init__( @@ -2356,7 +2231,7 @@ def __init__( :keyword capacity: The SKU capacity. :paramtype capacity: int """ - super(Sku, self).__init__(**kwargs) + super().__init__(**kwargs) self.name = name self.tier = tier self.size = size @@ -2365,7 +2240,7 @@ def __init__( self.capacity = capacity -class SubResource(msrest.serialization.Model): +class SubResource(_serialization.Model): """Sub-resource. :ivar id: Resource ID. @@ -2373,24 +2248,19 @@ class SubResource(msrest.serialization.Model): """ _attribute_map = { - 'id': {'key': 'id', 'type': 'str'}, + "id": {"key": "id", "type": "str"}, } - def __init__( - self, - *, - id: Optional[str] = None, - **kwargs - ): + def __init__(self, *, id: Optional[str] = None, **kwargs): # pylint: disable=redefined-builtin """ :keyword id: Resource ID. :paramtype id: str """ - super(SubResource, self).__init__(**kwargs) + super().__init__(**kwargs) self.id = id -class TagCount(msrest.serialization.Model): +class TagCount(_serialization.Model): """Tag count. :ivar type: Type of count. @@ -2400,29 +2270,23 @@ class TagCount(msrest.serialization.Model): """ _attribute_map = { - 'type': {'key': 'type', 'type': 'str'}, - 'value': {'key': 'value', 'type': 'int'}, + "type": {"key": "type", "type": "str"}, + "value": {"key": "value", "type": "int"}, } - def __init__( - self, - *, - type: Optional[str] = None, - value: Optional[int] = None, - **kwargs - ): + def __init__(self, *, type: Optional[str] = None, value: Optional[int] = None, **kwargs): """ :keyword type: Type of count. :paramtype type: str :keyword value: Value of count. :paramtype value: int """ - super(TagCount, self).__init__(**kwargs) + super().__init__(**kwargs) self.type = type self.value = value -class TagDetails(msrest.serialization.Model): +class TagDetails(_serialization.Model): """Tag details. Variables are only populated by the server, and will be ignored when sending a request. @@ -2439,22 +2303,22 @@ class TagDetails(msrest.serialization.Model): """ _validation = { - 'id': {'readonly': True}, + "id": {"readonly": True}, } _attribute_map = { - 'id': {'key': 'id', 'type': 'str'}, - 'tag_name': {'key': 'tagName', 'type': 'str'}, - 'count': {'key': 'count', 'type': 'TagCount'}, - 'values': {'key': 'values', 'type': '[TagValue]'}, + "id": {"key": "id", "type": "str"}, + "tag_name": {"key": "tagName", "type": "str"}, + "count": {"key": "count", "type": "TagCount"}, + "values": {"key": "values", "type": "[TagValue]"}, } def __init__( self, *, tag_name: Optional[str] = None, - count: Optional["TagCount"] = None, - values: Optional[List["TagValue"]] = None, + count: Optional["_models.TagCount"] = None, + values: Optional[List["_models.TagValue"]] = None, **kwargs ): """ @@ -2466,14 +2330,14 @@ def __init__( :keyword values: The list of tag values. :paramtype values: list[~azure.mgmt.resource.resources.v2019_08_01.models.TagValue] """ - super(TagDetails, self).__init__(**kwargs) + super().__init__(**kwargs) self.id = None self.tag_name = tag_name self.count = count self.values = values -class TagsListResult(msrest.serialization.Model): +class TagsListResult(_serialization.Model): """List of subscription tags. Variables are only populated by the server, and will be ignored when sending a request. @@ -2485,30 +2349,25 @@ class TagsListResult(msrest.serialization.Model): """ _validation = { - 'next_link': {'readonly': True}, + "next_link": {"readonly": True}, } _attribute_map = { - 'value': {'key': 'value', 'type': '[TagDetails]'}, - 'next_link': {'key': 'nextLink', 'type': 'str'}, + "value": {"key": "value", "type": "[TagDetails]"}, + "next_link": {"key": "nextLink", "type": "str"}, } - def __init__( - self, - *, - value: Optional[List["TagDetails"]] = None, - **kwargs - ): + def __init__(self, *, value: Optional[List["_models.TagDetails"]] = None, **kwargs): """ :keyword value: An array of tags. :paramtype value: list[~azure.mgmt.resource.resources.v2019_08_01.models.TagDetails] """ - super(TagsListResult, self).__init__(**kwargs) + super().__init__(**kwargs) self.value = value self.next_link = None -class TagValue(msrest.serialization.Model): +class TagValue(_serialization.Model): """Tag information. Variables are only populated by the server, and will be ignored when sending a request. @@ -2522,35 +2381,29 @@ class TagValue(msrest.serialization.Model): """ _validation = { - 'id': {'readonly': True}, + "id": {"readonly": True}, } _attribute_map = { - 'id': {'key': 'id', 'type': 'str'}, - 'tag_value': {'key': 'tagValue', 'type': 'str'}, - 'count': {'key': 'count', 'type': 'TagCount'}, + "id": {"key": "id", "type": "str"}, + "tag_value": {"key": "tagValue", "type": "str"}, + "count": {"key": "count", "type": "TagCount"}, } - def __init__( - self, - *, - tag_value: Optional[str] = None, - count: Optional["TagCount"] = None, - **kwargs - ): + def __init__(self, *, tag_value: Optional[str] = None, count: Optional["_models.TagCount"] = None, **kwargs): """ :keyword tag_value: The tag value. :paramtype tag_value: str :keyword count: The tag value count. :paramtype count: ~azure.mgmt.resource.resources.v2019_08_01.models.TagCount """ - super(TagValue, self).__init__(**kwargs) + super().__init__(**kwargs) self.id = None self.tag_value = tag_value self.count = count -class TargetResource(msrest.serialization.Model): +class TargetResource(_serialization.Model): """Target resource. :ivar id: The ID of the resource. @@ -2562,15 +2415,15 @@ class TargetResource(msrest.serialization.Model): """ _attribute_map = { - 'id': {'key': 'id', 'type': 'str'}, - 'resource_name': {'key': 'resourceName', 'type': 'str'}, - 'resource_type': {'key': 'resourceType', 'type': 'str'}, + "id": {"key": "id", "type": "str"}, + "resource_name": {"key": "resourceName", "type": "str"}, + "resource_type": {"key": "resourceType", "type": "str"}, } def __init__( self, *, - id: Optional[str] = None, + id: Optional[str] = None, # pylint: disable=redefined-builtin resource_name: Optional[str] = None, resource_type: Optional[str] = None, **kwargs @@ -2583,13 +2436,13 @@ def __init__( :keyword resource_type: The type of the resource. :paramtype resource_type: str """ - super(TargetResource, self).__init__(**kwargs) + super().__init__(**kwargs) self.id = id self.resource_name = resource_name self.resource_type = resource_type -class TemplateHashResult(msrest.serialization.Model): +class TemplateHashResult(_serialization.Model): """Result of the request to calculate template hash. It contains a string of minified template and its hash. :ivar minified_template: The minified template string. @@ -2599,123 +2452,111 @@ class TemplateHashResult(msrest.serialization.Model): """ _attribute_map = { - 'minified_template': {'key': 'minifiedTemplate', 'type': 'str'}, - 'template_hash': {'key': 'templateHash', 'type': 'str'}, + "minified_template": {"key": "minifiedTemplate", "type": "str"}, + "template_hash": {"key": "templateHash", "type": "str"}, } - def __init__( - self, - *, - minified_template: Optional[str] = None, - template_hash: Optional[str] = None, - **kwargs - ): + def __init__(self, *, minified_template: Optional[str] = None, template_hash: Optional[str] = None, **kwargs): """ :keyword minified_template: The minified template string. :paramtype minified_template: str :keyword template_hash: The template hash. :paramtype template_hash: str """ - super(TemplateHashResult, self).__init__(**kwargs) + super().__init__(**kwargs) self.minified_template = minified_template self.template_hash = template_hash -class TemplateLink(msrest.serialization.Model): +class TemplateLink(_serialization.Model): """Entity representing the reference to the template. All required parameters must be populated in order to send to Azure. - :ivar uri: Required. The URI of the template to deploy. + :ivar uri: The URI of the template to deploy. Required. :vartype uri: str :ivar content_version: If included, must match the ContentVersion in the template. :vartype content_version: str """ _validation = { - 'uri': {'required': True}, + "uri": {"required": True}, } _attribute_map = { - 'uri': {'key': 'uri', 'type': 'str'}, - 'content_version': {'key': 'contentVersion', 'type': 'str'}, + "uri": {"key": "uri", "type": "str"}, + "content_version": {"key": "contentVersion", "type": "str"}, } - def __init__( - self, - *, - uri: str, - content_version: Optional[str] = None, - **kwargs - ): + def __init__(self, *, uri: str, content_version: Optional[str] = None, **kwargs): """ - :keyword uri: Required. The URI of the template to deploy. + :keyword uri: The URI of the template to deploy. Required. :paramtype uri: str :keyword content_version: If included, must match the ContentVersion in the template. :paramtype content_version: str """ - super(TemplateLink, self).__init__(**kwargs) + super().__init__(**kwargs) self.uri = uri self.content_version = content_version -class WhatIfChange(msrest.serialization.Model): +class WhatIfChange(_serialization.Model): """Information about a single resource change predicted by What-If operation. All required parameters must be populated in order to send to Azure. - :ivar resource_id: Required. Resource ID. + :ivar resource_id: Resource ID. Required. :vartype resource_id: str - :ivar change_type: Required. Type of change that will be made to the resource when the - deployment is executed. Possible values include: "Create", "Delete", "Ignore", "Deploy", - "NoChange", "Modify". + :ivar change_type: Type of change that will be made to the resource when the deployment is + executed. Required. Known values are: "Create", "Delete", "Ignore", "Deploy", "NoChange", and + "Modify". :vartype change_type: str or ~azure.mgmt.resource.resources.v2019_08_01.models.ChangeType :ivar before: The snapshot of the resource before the deployment is executed. - :vartype before: any + :vartype before: JSON :ivar after: The predicted snapshot of the resource after the deployment is executed. - :vartype after: any + :vartype after: JSON :ivar delta: The predicted changes to resource properties. :vartype delta: list[~azure.mgmt.resource.resources.v2019_08_01.models.WhatIfPropertyChange] """ _validation = { - 'resource_id': {'required': True}, - 'change_type': {'required': True}, + "resource_id": {"required": True}, + "change_type": {"required": True}, } _attribute_map = { - 'resource_id': {'key': 'resourceId', 'type': 'str'}, - 'change_type': {'key': 'changeType', 'type': 'str'}, - 'before': {'key': 'before', 'type': 'object'}, - 'after': {'key': 'after', 'type': 'object'}, - 'delta': {'key': 'delta', 'type': '[WhatIfPropertyChange]'}, + "resource_id": {"key": "resourceId", "type": "str"}, + "change_type": {"key": "changeType", "type": "str"}, + "before": {"key": "before", "type": "object"}, + "after": {"key": "after", "type": "object"}, + "delta": {"key": "delta", "type": "[WhatIfPropertyChange]"}, } def __init__( self, *, resource_id: str, - change_type: Union[str, "ChangeType"], - before: Optional[Any] = None, - after: Optional[Any] = None, - delta: Optional[List["WhatIfPropertyChange"]] = None, + change_type: Union[str, "_models.ChangeType"], + before: Optional[JSON] = None, + after: Optional[JSON] = None, + delta: Optional[List["_models.WhatIfPropertyChange"]] = None, **kwargs ): """ - :keyword resource_id: Required. Resource ID. + :keyword resource_id: Resource ID. Required. :paramtype resource_id: str - :keyword change_type: Required. Type of change that will be made to the resource when the - deployment is executed. Possible values include: "Create", "Delete", "Ignore", "Deploy", - "NoChange", "Modify". + :keyword change_type: Type of change that will be made to the resource when the deployment is + executed. Required. Known values are: "Create", "Delete", "Ignore", "Deploy", "NoChange", and + "Modify". :paramtype change_type: str or ~azure.mgmt.resource.resources.v2019_08_01.models.ChangeType :keyword before: The snapshot of the resource before the deployment is executed. - :paramtype before: any + :paramtype before: JSON :keyword after: The predicted snapshot of the resource after the deployment is executed. - :paramtype after: any + :paramtype after: JSON :keyword delta: The predicted changes to resource properties. :paramtype delta: list[~azure.mgmt.resource.resources.v2019_08_01.models.WhatIfPropertyChange] """ - super(WhatIfChange, self).__init__(**kwargs) + super().__init__(**kwargs) self.resource_id = resource_id self.change_type = change_type self.before = before @@ -2723,7 +2564,7 @@ def __init__( self.delta = delta -class WhatIfOperationResult(msrest.serialization.Model): +class WhatIfOperationResult(_serialization.Model): """Result of the What-If operation. Contains a list of predicted changes and a URL link to get to the next set of results. :ivar status: Status of the What-If operation. @@ -2735,17 +2576,17 @@ class WhatIfOperationResult(msrest.serialization.Model): """ _attribute_map = { - 'status': {'key': 'status', 'type': 'str'}, - 'error': {'key': 'error', 'type': 'ErrorResponse'}, - 'changes': {'key': 'properties.changes', 'type': '[WhatIfChange]'}, + "status": {"key": "status", "type": "str"}, + "error": {"key": "error", "type": "ErrorResponse"}, + "changes": {"key": "properties.changes", "type": "[WhatIfChange]"}, } def __init__( self, *, status: Optional[str] = None, - error: Optional["ErrorResponse"] = None, - changes: Optional[List["WhatIfChange"]] = None, + error: Optional["_models.ErrorResponse"] = None, + changes: Optional[List["_models.WhatIfChange"]] = None, **kwargs ): """ @@ -2756,70 +2597,70 @@ def __init__( :keyword changes: List of resource changes predicted by What-If operation. :paramtype changes: list[~azure.mgmt.resource.resources.v2019_08_01.models.WhatIfChange] """ - super(WhatIfOperationResult, self).__init__(**kwargs) + super().__init__(**kwargs) self.status = status self.error = error self.changes = changes -class WhatIfPropertyChange(msrest.serialization.Model): +class WhatIfPropertyChange(_serialization.Model): """The predicted change to the resource property. All required parameters must be populated in order to send to Azure. - :ivar path: Required. The path of the property. + :ivar path: The path of the property. Required. :vartype path: str - :ivar property_change_type: Required. The type of property change. Possible values include: - "Create", "Delete", "Modify", "Array". + :ivar property_change_type: The type of property change. Required. Known values are: "Create", + "Delete", "Modify", and "Array". :vartype property_change_type: str or ~azure.mgmt.resource.resources.v2019_08_01.models.PropertyChangeType :ivar before: The value of the property before the deployment is executed. - :vartype before: any + :vartype before: JSON :ivar after: The value of the property after the deployment is executed. - :vartype after: any + :vartype after: JSON :ivar children: Nested property changes. :vartype children: list[~azure.mgmt.resource.resources.v2019_08_01.models.WhatIfPropertyChange] """ _validation = { - 'path': {'required': True}, - 'property_change_type': {'required': True}, + "path": {"required": True}, + "property_change_type": {"required": True}, } _attribute_map = { - 'path': {'key': 'path', 'type': 'str'}, - 'property_change_type': {'key': 'propertyChangeType', 'type': 'str'}, - 'before': {'key': 'before', 'type': 'object'}, - 'after': {'key': 'after', 'type': 'object'}, - 'children': {'key': 'children', 'type': '[WhatIfPropertyChange]'}, + "path": {"key": "path", "type": "str"}, + "property_change_type": {"key": "propertyChangeType", "type": "str"}, + "before": {"key": "before", "type": "object"}, + "after": {"key": "after", "type": "object"}, + "children": {"key": "children", "type": "[WhatIfPropertyChange]"}, } def __init__( self, *, path: str, - property_change_type: Union[str, "PropertyChangeType"], - before: Optional[Any] = None, - after: Optional[Any] = None, - children: Optional[List["WhatIfPropertyChange"]] = None, + property_change_type: Union[str, "_models.PropertyChangeType"], + before: Optional[JSON] = None, + after: Optional[JSON] = None, + children: Optional[List["_models.WhatIfPropertyChange"]] = None, **kwargs ): """ - :keyword path: Required. The path of the property. + :keyword path: The path of the property. Required. :paramtype path: str - :keyword property_change_type: Required. The type of property change. Possible values include: - "Create", "Delete", "Modify", "Array". + :keyword property_change_type: The type of property change. Required. Known values are: + "Create", "Delete", "Modify", and "Array". :paramtype property_change_type: str or ~azure.mgmt.resource.resources.v2019_08_01.models.PropertyChangeType :keyword before: The value of the property before the deployment is executed. - :paramtype before: any + :paramtype before: JSON :keyword after: The value of the property after the deployment is executed. - :paramtype after: any + :paramtype after: JSON :keyword children: Nested property changes. :paramtype children: list[~azure.mgmt.resource.resources.v2019_08_01.models.WhatIfPropertyChange] """ - super(WhatIfPropertyChange, self).__init__(**kwargs) + super().__init__(**kwargs) self.path = path self.property_change_type = property_change_type self.before = before @@ -2827,7 +2668,7 @@ def __init__( self.children = children -class ZoneMapping(msrest.serialization.Model): +class ZoneMapping(_serialization.Model): """ZoneMapping. :ivar location: The location of the zone mapping. @@ -2837,23 +2678,17 @@ class ZoneMapping(msrest.serialization.Model): """ _attribute_map = { - 'location': {'key': 'location', 'type': 'str'}, - 'zones': {'key': 'zones', 'type': '[str]'}, + "location": {"key": "location", "type": "str"}, + "zones": {"key": "zones", "type": "[str]"}, } - def __init__( - self, - *, - location: Optional[str] = None, - zones: Optional[List[str]] = None, - **kwargs - ): + def __init__(self, *, location: Optional[str] = None, zones: Optional[List[str]] = None, **kwargs): """ :keyword location: The location of the zone mapping. :paramtype location: str :keyword zones: :paramtype zones: list[str] """ - super(ZoneMapping, self).__init__(**kwargs) + super().__init__(**kwargs) self.location = location self.zones = zones diff --git a/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/resources/v2019_08_01/models/_patch.py b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/resources/v2019_08_01/models/_patch.py new file mode 100644 index 0000000000000..f7dd32510333d --- /dev/null +++ b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/resources/v2019_08_01/models/_patch.py @@ -0,0 +1,20 @@ +# ------------------------------------ +# Copyright (c) Microsoft Corporation. +# Licensed under the MIT License. +# ------------------------------------ +"""Customize generated code here. + +Follow our quickstart for examples: https://aka.ms/azsdk/python/dpcodegen/python/customize +""" +from typing import List + +__all__: List[str] = [] # Add all objects you want publicly available to users at this package level + + +def patch_sdk(): + """Do not remove from this file. + + `patch_sdk` is a last resort escape hatch that allows you to do customizations + you can't accomplish using the techniques described in + https://aka.ms/azsdk/python/dpcodegen/python/customize + """ diff --git a/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/resources/v2019_08_01/models/_resource_management_client_enums.py b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/resources/v2019_08_01/models/_resource_management_client_enums.py index 137526fd26afc..9c3da29484b18 100644 --- a/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/resources/v2019_08_01/models/_resource_management_client_enums.py +++ b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/resources/v2019_08_01/models/_resource_management_client_enums.py @@ -7,13 +7,11 @@ # -------------------------------------------------------------------------- from enum import Enum -from six import with_metaclass from azure.core import CaseInsensitiveEnumMeta -class ChangeType(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): - """Type of change that will be made to the resource when the deployment is executed. - """ +class ChangeType(str, Enum, metaclass=CaseInsensitiveEnumMeta): + """Type of change that will be made to the resource when the deployment is executed.""" #: The resource does not exist in the current state but is present in the desired state. The #: resource will be created when the deployment is executed. @@ -34,7 +32,8 @@ class ChangeType(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): #: deployment is executed. The properties of the resource will change. MODIFY = "Modify" -class DeploymentMode(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): + +class DeploymentMode(str, Enum, metaclass=CaseInsensitiveEnumMeta): """The mode that is used to deploy resources. This value can be either Incremental or Complete. In Incremental mode, resources are deployed without deleting existing resources that are not included in the template. In Complete mode, resources are deployed and existing resources in @@ -45,7 +44,8 @@ class DeploymentMode(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): INCREMENTAL = "Incremental" COMPLETE = "Complete" -class OnErrorDeploymentType(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): + +class OnErrorDeploymentType(str, Enum, metaclass=CaseInsensitiveEnumMeta): """The deployment on error behavior type. Possible values are LastSuccessful and SpecificDeployment. """ @@ -53,9 +53,9 @@ class OnErrorDeploymentType(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): LAST_SUCCESSFUL = "LastSuccessful" SPECIFIC_DEPLOYMENT = "SpecificDeployment" -class PropertyChangeType(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): - """The type of property change. - """ + +class PropertyChangeType(str, Enum, metaclass=CaseInsensitiveEnumMeta): + """The type of property change.""" #: The property does not exist in the current state but is present in the desired state. The #: property will be created when the deployment is executed. @@ -69,18 +69,18 @@ class PropertyChangeType(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): #: The property is an array and contains nested changes. ARRAY = "Array" -class ResourceIdentityType(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): - """The identity type. - """ + +class ResourceIdentityType(str, Enum, metaclass=CaseInsensitiveEnumMeta): + """The identity type.""" SYSTEM_ASSIGNED = "SystemAssigned" USER_ASSIGNED = "UserAssigned" SYSTEM_ASSIGNED_USER_ASSIGNED = "SystemAssigned, UserAssigned" NONE = "None" -class WhatIfResultFormat(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): - """The format of the What-If results - """ + +class WhatIfResultFormat(str, Enum, metaclass=CaseInsensitiveEnumMeta): + """The format of the What-If results.""" RESOURCE_ID_ONLY = "ResourceIdOnly" FULL_RESOURCE_PAYLOADS = "FullResourcePayloads" diff --git a/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/resources/v2019_08_01/operations/__init__.py b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/resources/v2019_08_01/operations/__init__.py index 53876d82bf5d7..804fee65e3137 100644 --- a/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/resources/v2019_08_01/operations/__init__.py +++ b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/resources/v2019_08_01/operations/__init__.py @@ -14,12 +14,18 @@ from ._operations import TagsOperations from ._operations import DeploymentOperationsOperations +from ._patch import __all__ as _patch_all +from ._patch import * # type: ignore # pylint: disable=unused-wildcard-import +from ._patch import patch_sdk as _patch_sdk + __all__ = [ - 'Operations', - 'DeploymentsOperations', - 'ProvidersOperations', - 'ResourcesOperations', - 'ResourceGroupsOperations', - 'TagsOperations', - 'DeploymentOperationsOperations', + "Operations", + "DeploymentsOperations", + "ProvidersOperations", + "ResourcesOperations", + "ResourceGroupsOperations", + "TagsOperations", + "DeploymentOperationsOperations", ] +__all__.extend([p for p in _patch_all if p not in __all__]) +_patch_sdk() diff --git a/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/resources/v2019_08_01/operations/_operations.py b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/resources/v2019_08_01/operations/_operations.py index f10cf7530cfce..884cf79671f39 100644 --- a/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/resources/v2019_08_01/operations/_operations.py +++ b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/resources/v2019_08_01/operations/_operations.py @@ -6,1559 +6,1344 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -from typing import Any, Callable, Dict, Iterable, Optional, TypeVar, Union - -from msrest import Serializer - -from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error +import sys +from typing import Any, Callable, Dict, IO, Iterable, Optional, TypeVar, Union, cast, overload +from urllib.parse import parse_qs, urljoin, urlparse + +from azure.core.exceptions import ( + ClientAuthenticationError, + HttpResponseError, + ResourceExistsError, + ResourceNotFoundError, + ResourceNotModifiedError, + map_error, +) from azure.core.paging import ItemPaged from azure.core.pipeline import PipelineResponse from azure.core.pipeline.transport import HttpResponse from azure.core.polling import LROPoller, NoPolling, PollingMethod from azure.core.rest import HttpRequest from azure.core.tracing.decorator import distributed_trace +from azure.core.utils import case_insensitive_dict from azure.mgmt.core.exceptions import ARMErrorFormat from azure.mgmt.core.polling.arm_polling import ARMPolling from .. import models as _models +from ..._serialization import Serializer from .._vendor import _convert_request, _format_url_section -T = TypeVar('T') + +T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] -JSONType = Any +if sys.version_info >= (3, 9): + from collections.abc import MutableMapping +else: + from typing import MutableMapping # type: ignore # pylint: disable=ungrouped-imports +JSON = MutableMapping[str, Any] # pylint: disable=unsubscriptable-object _SERIALIZER = Serializer() _SERIALIZER.client_side_validation = False -def build_operations_list_request( - **kwargs: Any -) -> HttpRequest: - api_version = kwargs.pop('api_version', "2019-08-01") # type: str - accept = "application/json" +def build_operations_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", "2019-08-01")) # type: str + accept = _headers.pop("Accept", "application/json") + # Construct URL _url = kwargs.pop("template_url", "/providers/Microsoft.Resources/operations") # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') - - return HttpRequest( - method="GET", - url=_url, - params=_query_parameters, - headers=_header_parameters, - **kwargs - ) + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) -def build_deployments_delete_at_scope_request_initial( - scope: str, - deployment_name: str, - **kwargs: Any -) -> HttpRequest: - api_version = kwargs.pop('api_version', "2019-08-01") # type: str - accept = "application/json" +def build_deployments_delete_at_scope_request(scope: str, deployment_name: 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", "2019-08-01")) # type: str + accept = _headers.pop("Accept", "application/json") + # Construct URL _url = kwargs.pop("template_url", "/{scope}/providers/Microsoft.Resources/deployments/{deploymentName}") path_format_arguments = { - "scope": _SERIALIZER.url("scope", scope, 'str'), - "deploymentName": _SERIALIZER.url("deployment_name", deployment_name, 'str', max_length=64, min_length=1, pattern=r'^[-\w\._\(\)]+$'), + "scope": _SERIALIZER.url("scope", scope, "str"), + "deploymentName": _SERIALIZER.url( + "deployment_name", deployment_name, "str", max_length=64, min_length=1, pattern=r"^[-\w\._\(\)]+$" + ), } _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') - - return HttpRequest( - method="DELETE", - url=_url, - params=_query_parameters, - headers=_header_parameters, - **kwargs - ) + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + return HttpRequest(method="DELETE", url=_url, params=_params, headers=_headers, **kwargs) -def build_deployments_check_existence_at_scope_request( - scope: str, - deployment_name: str, - **kwargs: Any -) -> HttpRequest: - api_version = kwargs.pop('api_version', "2019-08-01") # type: str - accept = "application/json" +def build_deployments_check_existence_at_scope_request(scope: str, deployment_name: 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", "2019-08-01")) # type: str + accept = _headers.pop("Accept", "application/json") + # Construct URL _url = kwargs.pop("template_url", "/{scope}/providers/Microsoft.Resources/deployments/{deploymentName}") path_format_arguments = { - "scope": _SERIALIZER.url("scope", scope, 'str'), - "deploymentName": _SERIALIZER.url("deployment_name", deployment_name, 'str', max_length=64, min_length=1, pattern=r'^[-\w\._\(\)]+$'), + "scope": _SERIALIZER.url("scope", scope, "str"), + "deploymentName": _SERIALIZER.url( + "deployment_name", deployment_name, "str", max_length=64, min_length=1, pattern=r"^[-\w\._\(\)]+$" + ), } _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') - - return HttpRequest( - method="HEAD", - url=_url, - params=_query_parameters, - headers=_header_parameters, - **kwargs - ) + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + return HttpRequest(method="HEAD", url=_url, params=_params, headers=_headers, **kwargs) -def build_deployments_create_or_update_at_scope_request_initial( - scope: str, - deployment_name: str, - *, - json: JSONType = None, - content: Any = None, - **kwargs: Any -) -> HttpRequest: - api_version = kwargs.pop('api_version', "2019-08-01") # type: str - content_type = kwargs.pop('content_type', None) # type: Optional[str] - accept = "application/json" +def build_deployments_create_or_update_at_scope_request(scope: str, deployment_name: 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", "2019-08-01")) # type: str + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + accept = _headers.pop("Accept", "application/json") + # Construct URL _url = kwargs.pop("template_url", "/{scope}/providers/Microsoft.Resources/deployments/{deploymentName}") path_format_arguments = { - "scope": _SERIALIZER.url("scope", scope, 'str'), - "deploymentName": _SERIALIZER.url("deployment_name", deployment_name, 'str', max_length=64, min_length=1, pattern=r'^[-\w\._\(\)]+$'), + "scope": _SERIALIZER.url("scope", scope, "str"), + "deploymentName": _SERIALIZER.url( + "deployment_name", deployment_name, "str", max_length=64, min_length=1, pattern=r"^[-\w\._\(\)]+$" + ), } _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] if content_type is not None: - _header_parameters['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') - _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') - - return HttpRequest( - method="PUT", - url=_url, - params=_query_parameters, - headers=_header_parameters, - json=json, - content=content, - **kwargs - ) + _headers["Content-Type"] = _SERIALIZER.header("content_type", content_type, "str") + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + return HttpRequest(method="PUT", url=_url, params=_params, headers=_headers, **kwargs) -def build_deployments_get_at_scope_request( - scope: str, - deployment_name: str, - **kwargs: Any -) -> HttpRequest: - api_version = kwargs.pop('api_version', "2019-08-01") # type: str - accept = "application/json" +def build_deployments_get_at_scope_request(scope: str, deployment_name: 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", "2019-08-01")) # type: str + accept = _headers.pop("Accept", "application/json") + # Construct URL _url = kwargs.pop("template_url", "/{scope}/providers/Microsoft.Resources/deployments/{deploymentName}") path_format_arguments = { - "scope": _SERIALIZER.url("scope", scope, 'str'), - "deploymentName": _SERIALIZER.url("deployment_name", deployment_name, 'str', max_length=64, min_length=1, pattern=r'^[-\w\._\(\)]+$'), + "scope": _SERIALIZER.url("scope", scope, "str"), + "deploymentName": _SERIALIZER.url( + "deployment_name", deployment_name, "str", max_length=64, min_length=1, pattern=r"^[-\w\._\(\)]+$" + ), } _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') - - return HttpRequest( - method="GET", - url=_url, - params=_query_parameters, - headers=_header_parameters, - **kwargs - ) + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) -def build_deployments_cancel_at_scope_request( - scope: str, - deployment_name: str, - **kwargs: Any -) -> HttpRequest: - api_version = kwargs.pop('api_version', "2019-08-01") # type: str - accept = "application/json" +def build_deployments_cancel_at_scope_request(scope: str, deployment_name: 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", "2019-08-01")) # type: str + accept = _headers.pop("Accept", "application/json") + # Construct URL _url = kwargs.pop("template_url", "/{scope}/providers/Microsoft.Resources/deployments/{deploymentName}/cancel") path_format_arguments = { - "scope": _SERIALIZER.url("scope", scope, 'str'), - "deploymentName": _SERIALIZER.url("deployment_name", deployment_name, 'str', max_length=64, min_length=1, pattern=r'^[-\w\._\(\)]+$'), + "scope": _SERIALIZER.url("scope", scope, "str"), + "deploymentName": _SERIALIZER.url( + "deployment_name", deployment_name, "str", max_length=64, min_length=1, pattern=r"^[-\w\._\(\)]+$" + ), } _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') - - return HttpRequest( - method="POST", - url=_url, - params=_query_parameters, - headers=_header_parameters, - **kwargs - ) + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + return HttpRequest(method="POST", url=_url, params=_params, headers=_headers, **kwargs) -def build_deployments_validate_at_scope_request( - scope: str, - deployment_name: str, - *, - json: JSONType = None, - content: Any = None, - **kwargs: Any -) -> HttpRequest: - api_version = kwargs.pop('api_version', "2019-08-01") # type: str - content_type = kwargs.pop('content_type', None) # type: Optional[str] - accept = "application/json" +def build_deployments_validate_at_scope_request(scope: str, deployment_name: 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", "2019-08-01")) # type: str + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + accept = _headers.pop("Accept", "application/json") + # Construct URL _url = kwargs.pop("template_url", "/{scope}/providers/Microsoft.Resources/deployments/{deploymentName}/validate") path_format_arguments = { - "scope": _SERIALIZER.url("scope", scope, 'str'), - "deploymentName": _SERIALIZER.url("deployment_name", deployment_name, 'str', max_length=64, min_length=1, pattern=r'^[-\w\._\(\)]+$'), + "scope": _SERIALIZER.url("scope", scope, "str"), + "deploymentName": _SERIALIZER.url( + "deployment_name", deployment_name, "str", max_length=64, min_length=1, pattern=r"^[-\w\._\(\)]+$" + ), } _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] if content_type is not None: - _header_parameters['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') - _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') - - return HttpRequest( - method="POST", - url=_url, - params=_query_parameters, - headers=_header_parameters, - json=json, - content=content, - **kwargs - ) + _headers["Content-Type"] = _SERIALIZER.header("content_type", content_type, "str") + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + return HttpRequest(method="POST", url=_url, params=_params, headers=_headers, **kwargs) -def build_deployments_export_template_at_scope_request( - scope: str, - deployment_name: str, - **kwargs: Any -) -> HttpRequest: - api_version = kwargs.pop('api_version', "2019-08-01") # type: str - accept = "application/json" +def build_deployments_export_template_at_scope_request(scope: str, deployment_name: 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", "2019-08-01")) # type: str + accept = _headers.pop("Accept", "application/json") + # Construct URL - _url = kwargs.pop("template_url", "/{scope}/providers/Microsoft.Resources/deployments/{deploymentName}/exportTemplate") + _url = kwargs.pop( + "template_url", "/{scope}/providers/Microsoft.Resources/deployments/{deploymentName}/exportTemplate" + ) path_format_arguments = { - "scope": _SERIALIZER.url("scope", scope, 'str'), - "deploymentName": _SERIALIZER.url("deployment_name", deployment_name, 'str', max_length=64, min_length=1, pattern=r'^[-\w\._\(\)]+$'), + "scope": _SERIALIZER.url("scope", scope, "str"), + "deploymentName": _SERIALIZER.url( + "deployment_name", deployment_name, "str", max_length=64, min_length=1, pattern=r"^[-\w\._\(\)]+$" + ), } _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') - - return HttpRequest( - method="POST", - url=_url, - params=_query_parameters, - headers=_header_parameters, - **kwargs - ) + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="POST", url=_url, params=_params, headers=_headers, **kwargs) def build_deployments_list_at_scope_request( - scope: str, - *, - filter: Optional[str] = None, - top: Optional[int] = None, - **kwargs: Any + scope: str, *, filter: Optional[str] = None, top: Optional[int] = None, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2019-08-01") # type: 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", "2019-08-01")) # type: str + accept = _headers.pop("Accept", "application/json") - accept = "application/json" # Construct URL _url = kwargs.pop("template_url", "/{scope}/providers/Microsoft.Resources/deployments/") path_format_arguments = { - "scope": _SERIALIZER.url("scope", scope, 'str'), + "scope": _SERIALIZER.url("scope", scope, "str"), } _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] if filter is not None: - _query_parameters['$filter'] = _SERIALIZER.query("filter", filter, 'str') + _params["$filter"] = _SERIALIZER.query("filter", filter, "str") if top is not None: - _query_parameters['$top'] = _SERIALIZER.query("top", top, 'int') - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["$top"] = _SERIALIZER.query("top", top, "int") + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') - - return HttpRequest( - method="GET", - url=_url, - params=_query_parameters, - headers=_header_parameters, - **kwargs - ) + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) -def build_deployments_delete_at_tenant_scope_request_initial( - deployment_name: str, - **kwargs: Any -) -> HttpRequest: - api_version = kwargs.pop('api_version', "2019-08-01") # type: str - accept = "application/json" +def build_deployments_delete_at_tenant_scope_request(deployment_name: 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", "2019-08-01")) # type: str + accept = _headers.pop("Accept", "application/json") + # Construct URL _url = kwargs.pop("template_url", "/providers/Microsoft.Resources/deployments/{deploymentName}") path_format_arguments = { - "deploymentName": _SERIALIZER.url("deployment_name", deployment_name, 'str', max_length=64, min_length=1, pattern=r'^[-\w\._\(\)]+$'), + "deploymentName": _SERIALIZER.url( + "deployment_name", deployment_name, "str", max_length=64, min_length=1, pattern=r"^[-\w\._\(\)]+$" + ), } _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') - - return HttpRequest( - method="DELETE", - url=_url, - params=_query_parameters, - headers=_header_parameters, - **kwargs - ) + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + return HttpRequest(method="DELETE", url=_url, params=_params, headers=_headers, **kwargs) -def build_deployments_check_existence_at_tenant_scope_request( - deployment_name: str, - **kwargs: Any -) -> HttpRequest: - api_version = kwargs.pop('api_version', "2019-08-01") # type: str - accept = "application/json" +def build_deployments_check_existence_at_tenant_scope_request(deployment_name: 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", "2019-08-01")) # type: str + accept = _headers.pop("Accept", "application/json") + # Construct URL _url = kwargs.pop("template_url", "/providers/Microsoft.Resources/deployments/{deploymentName}") path_format_arguments = { - "deploymentName": _SERIALIZER.url("deployment_name", deployment_name, 'str', max_length=64, min_length=1, pattern=r'^[-\w\._\(\)]+$'), + "deploymentName": _SERIALIZER.url( + "deployment_name", deployment_name, "str", max_length=64, min_length=1, pattern=r"^[-\w\._\(\)]+$" + ), } _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') - - return HttpRequest( - method="HEAD", - url=_url, - params=_query_parameters, - headers=_header_parameters, - **kwargs - ) + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + return HttpRequest(method="HEAD", url=_url, params=_params, headers=_headers, **kwargs) -def build_deployments_create_or_update_at_tenant_scope_request_initial( - deployment_name: str, - *, - json: JSONType = None, - content: Any = None, - **kwargs: Any -) -> HttpRequest: - api_version = kwargs.pop('api_version', "2019-08-01") # type: str - content_type = kwargs.pop('content_type', None) # type: Optional[str] - accept = "application/json" +def build_deployments_create_or_update_at_tenant_scope_request(deployment_name: 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", "2019-08-01")) # type: str + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + accept = _headers.pop("Accept", "application/json") + # Construct URL _url = kwargs.pop("template_url", "/providers/Microsoft.Resources/deployments/{deploymentName}") path_format_arguments = { - "deploymentName": _SERIALIZER.url("deployment_name", deployment_name, 'str', max_length=64, min_length=1, pattern=r'^[-\w\._\(\)]+$'), + "deploymentName": _SERIALIZER.url( + "deployment_name", deployment_name, "str", max_length=64, min_length=1, pattern=r"^[-\w\._\(\)]+$" + ), } _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] if content_type is not None: - _header_parameters['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') - _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') - - return HttpRequest( - method="PUT", - url=_url, - params=_query_parameters, - headers=_header_parameters, - json=json, - content=content, - **kwargs - ) + _headers["Content-Type"] = _SERIALIZER.header("content_type", content_type, "str") + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + return HttpRequest(method="PUT", url=_url, params=_params, headers=_headers, **kwargs) -def build_deployments_get_at_tenant_scope_request( - deployment_name: str, - **kwargs: Any -) -> HttpRequest: - api_version = kwargs.pop('api_version', "2019-08-01") # type: str - accept = "application/json" +def build_deployments_get_at_tenant_scope_request(deployment_name: 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", "2019-08-01")) # type: str + accept = _headers.pop("Accept", "application/json") + # Construct URL _url = kwargs.pop("template_url", "/providers/Microsoft.Resources/deployments/{deploymentName}") path_format_arguments = { - "deploymentName": _SERIALIZER.url("deployment_name", deployment_name, 'str', max_length=64, min_length=1, pattern=r'^[-\w\._\(\)]+$'), + "deploymentName": _SERIALIZER.url( + "deployment_name", deployment_name, "str", max_length=64, min_length=1, pattern=r"^[-\w\._\(\)]+$" + ), } _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') - - return HttpRequest( - method="GET", - url=_url, - params=_query_parameters, - headers=_header_parameters, - **kwargs - ) + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) -def build_deployments_cancel_at_tenant_scope_request( - deployment_name: str, - **kwargs: Any -) -> HttpRequest: - api_version = kwargs.pop('api_version', "2019-08-01") # type: str - accept = "application/json" +def build_deployments_cancel_at_tenant_scope_request(deployment_name: 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", "2019-08-01")) # type: str + accept = _headers.pop("Accept", "application/json") + # Construct URL _url = kwargs.pop("template_url", "/providers/Microsoft.Resources/deployments/{deploymentName}/cancel") path_format_arguments = { - "deploymentName": _SERIALIZER.url("deployment_name", deployment_name, 'str', max_length=64, min_length=1, pattern=r'^[-\w\._\(\)]+$'), + "deploymentName": _SERIALIZER.url( + "deployment_name", deployment_name, "str", max_length=64, min_length=1, pattern=r"^[-\w\._\(\)]+$" + ), } _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') - - return HttpRequest( - method="POST", - url=_url, - params=_query_parameters, - headers=_header_parameters, - **kwargs - ) + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + return HttpRequest(method="POST", url=_url, params=_params, headers=_headers, **kwargs) -def build_deployments_validate_at_tenant_scope_request( - deployment_name: str, - *, - json: JSONType = None, - content: Any = None, - **kwargs: Any -) -> HttpRequest: - api_version = kwargs.pop('api_version', "2019-08-01") # type: str - content_type = kwargs.pop('content_type', None) # type: Optional[str] - accept = "application/json" +def build_deployments_validate_at_tenant_scope_request(deployment_name: 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", "2019-08-01")) # type: str + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + accept = _headers.pop("Accept", "application/json") + # Construct URL _url = kwargs.pop("template_url", "/providers/Microsoft.Resources/deployments/{deploymentName}/validate") path_format_arguments = { - "deploymentName": _SERIALIZER.url("deployment_name", deployment_name, 'str', max_length=64, min_length=1, pattern=r'^[-\w\._\(\)]+$'), + "deploymentName": _SERIALIZER.url( + "deployment_name", deployment_name, "str", max_length=64, min_length=1, pattern=r"^[-\w\._\(\)]+$" + ), } _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] if content_type is not None: - _header_parameters['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') - _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') - - return HttpRequest( - method="POST", - url=_url, - params=_query_parameters, - headers=_header_parameters, - json=json, - content=content, - **kwargs - ) + _headers["Content-Type"] = _SERIALIZER.header("content_type", content_type, "str") + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + return HttpRequest(method="POST", url=_url, params=_params, headers=_headers, **kwargs) -def build_deployments_export_template_at_tenant_scope_request( - deployment_name: str, - **kwargs: Any -) -> HttpRequest: - api_version = kwargs.pop('api_version', "2019-08-01") # type: str - accept = "application/json" +def build_deployments_export_template_at_tenant_scope_request(deployment_name: 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", "2019-08-01")) # type: str + accept = _headers.pop("Accept", "application/json") + # Construct URL _url = kwargs.pop("template_url", "/providers/Microsoft.Resources/deployments/{deploymentName}/exportTemplate") path_format_arguments = { - "deploymentName": _SERIALIZER.url("deployment_name", deployment_name, 'str', max_length=64, min_length=1, pattern=r'^[-\w\._\(\)]+$'), + "deploymentName": _SERIALIZER.url( + "deployment_name", deployment_name, "str", max_length=64, min_length=1, pattern=r"^[-\w\._\(\)]+$" + ), } _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') - - return HttpRequest( - method="POST", - url=_url, - params=_query_parameters, - headers=_header_parameters, - **kwargs - ) + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="POST", url=_url, params=_params, headers=_headers, **kwargs) def build_deployments_list_at_tenant_scope_request( - *, - filter: Optional[str] = None, - top: Optional[int] = None, - **kwargs: Any + *, filter: Optional[str] = None, top: Optional[int] = None, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2019-08-01") # type: 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", "2019-08-01")) # type: str + accept = _headers.pop("Accept", "application/json") - accept = "application/json" # Construct URL _url = kwargs.pop("template_url", "/providers/Microsoft.Resources/deployments/") # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] if filter is not None: - _query_parameters['$filter'] = _SERIALIZER.query("filter", filter, 'str') + _params["$filter"] = _SERIALIZER.query("filter", filter, "str") if top is not None: - _query_parameters['$top'] = _SERIALIZER.query("top", top, 'int') - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["$top"] = _SERIALIZER.query("top", top, "int") + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') - - return HttpRequest( - method="GET", - url=_url, - params=_query_parameters, - headers=_header_parameters, - **kwargs - ) + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) -def build_deployments_delete_at_management_group_scope_request_initial( - group_id: str, - deployment_name: str, - **kwargs: Any + +def build_deployments_delete_at_management_group_scope_request( + group_id: str, deployment_name: str, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2019-08-01") # type: 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", "2019-08-01")) # type: str + accept = _headers.pop("Accept", "application/json") - accept = "application/json" # Construct URL - _url = kwargs.pop("template_url", "/providers/Microsoft.Management/managementGroups/{groupId}/providers/Microsoft.Resources/deployments/{deploymentName}") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", + "/providers/Microsoft.Management/managementGroups/{groupId}/providers/Microsoft.Resources/deployments/{deploymentName}", + ) # pylint: disable=line-too-long path_format_arguments = { - "groupId": _SERIALIZER.url("group_id", group_id, 'str', max_length=90, min_length=1), - "deploymentName": _SERIALIZER.url("deployment_name", deployment_name, 'str', max_length=64, min_length=1, pattern=r'^[-\w\._\(\)]+$'), + "groupId": _SERIALIZER.url("group_id", group_id, "str", max_length=90, min_length=1), + "deploymentName": _SERIALIZER.url( + "deployment_name", deployment_name, "str", max_length=64, min_length=1, pattern=r"^[-\w\._\(\)]+$" + ), } _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') - - return HttpRequest( - method="DELETE", - url=_url, - params=_query_parameters, - headers=_header_parameters, - **kwargs - ) + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="DELETE", url=_url, params=_params, headers=_headers, **kwargs) def build_deployments_check_existence_at_management_group_scope_request( - group_id: str, - deployment_name: str, - **kwargs: Any + group_id: str, deployment_name: str, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2019-08-01") # type: 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", "2019-08-01")) # type: str + accept = _headers.pop("Accept", "application/json") - accept = "application/json" # Construct URL - _url = kwargs.pop("template_url", "/providers/Microsoft.Management/managementGroups/{groupId}/providers/Microsoft.Resources/deployments/{deploymentName}") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", + "/providers/Microsoft.Management/managementGroups/{groupId}/providers/Microsoft.Resources/deployments/{deploymentName}", + ) # pylint: disable=line-too-long path_format_arguments = { - "groupId": _SERIALIZER.url("group_id", group_id, 'str', max_length=90, min_length=1), - "deploymentName": _SERIALIZER.url("deployment_name", deployment_name, 'str', max_length=64, min_length=1, pattern=r'^[-\w\._\(\)]+$'), + "groupId": _SERIALIZER.url("group_id", group_id, "str", max_length=90, min_length=1), + "deploymentName": _SERIALIZER.url( + "deployment_name", deployment_name, "str", max_length=64, min_length=1, pattern=r"^[-\w\._\(\)]+$" + ), } _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') - - return HttpRequest( - method="HEAD", - url=_url, - params=_query_parameters, - headers=_header_parameters, - **kwargs - ) + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + return HttpRequest(method="HEAD", url=_url, params=_params, headers=_headers, **kwargs) -def build_deployments_create_or_update_at_management_group_scope_request_initial( - group_id: str, - deployment_name: str, - *, - json: JSONType = None, - content: Any = None, - **kwargs: Any + +def build_deployments_create_or_update_at_management_group_scope_request( + group_id: str, deployment_name: str, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2019-08-01") # type: str - content_type = kwargs.pop('content_type', None) # type: Optional[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", "2019-08-01")) # type: str + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + accept = _headers.pop("Accept", "application/json") - accept = "application/json" # Construct URL - _url = kwargs.pop("template_url", "/providers/Microsoft.Management/managementGroups/{groupId}/providers/Microsoft.Resources/deployments/{deploymentName}") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", + "/providers/Microsoft.Management/managementGroups/{groupId}/providers/Microsoft.Resources/deployments/{deploymentName}", + ) # pylint: disable=line-too-long path_format_arguments = { - "groupId": _SERIALIZER.url("group_id", group_id, 'str', max_length=90, min_length=1), - "deploymentName": _SERIALIZER.url("deployment_name", deployment_name, 'str', max_length=64, min_length=1, pattern=r'^[-\w\._\(\)]+$'), + "groupId": _SERIALIZER.url("group_id", group_id, "str", max_length=90, min_length=1), + "deploymentName": _SERIALIZER.url( + "deployment_name", deployment_name, "str", max_length=64, min_length=1, pattern=r"^[-\w\._\(\)]+$" + ), } _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] if content_type is not None: - _header_parameters['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') - _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') - - return HttpRequest( - method="PUT", - url=_url, - params=_query_parameters, - headers=_header_parameters, - json=json, - content=content, - **kwargs - ) + _headers["Content-Type"] = _SERIALIZER.header("content_type", content_type, "str") + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="PUT", url=_url, params=_params, headers=_headers, **kwargs) def build_deployments_get_at_management_group_scope_request( - group_id: str, - deployment_name: str, - **kwargs: Any + group_id: str, deployment_name: str, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2019-08-01") # type: 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", "2019-08-01")) # type: str + accept = _headers.pop("Accept", "application/json") - accept = "application/json" # Construct URL - _url = kwargs.pop("template_url", "/providers/Microsoft.Management/managementGroups/{groupId}/providers/Microsoft.Resources/deployments/{deploymentName}") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", + "/providers/Microsoft.Management/managementGroups/{groupId}/providers/Microsoft.Resources/deployments/{deploymentName}", + ) # pylint: disable=line-too-long path_format_arguments = { - "groupId": _SERIALIZER.url("group_id", group_id, 'str', max_length=90, min_length=1), - "deploymentName": _SERIALIZER.url("deployment_name", deployment_name, 'str', max_length=64, min_length=1, pattern=r'^[-\w\._\(\)]+$'), + "groupId": _SERIALIZER.url("group_id", group_id, "str", max_length=90, min_length=1), + "deploymentName": _SERIALIZER.url( + "deployment_name", deployment_name, "str", max_length=64, min_length=1, pattern=r"^[-\w\._\(\)]+$" + ), } _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') - - return HttpRequest( - method="GET", - url=_url, - params=_query_parameters, - headers=_header_parameters, - **kwargs - ) + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) def build_deployments_cancel_at_management_group_scope_request( - group_id: str, - deployment_name: str, - **kwargs: Any + group_id: str, deployment_name: str, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2019-08-01") # type: 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", "2019-08-01")) # type: str + accept = _headers.pop("Accept", "application/json") - accept = "application/json" # Construct URL - _url = kwargs.pop("template_url", "/providers/Microsoft.Management/managementGroups/{groupId}/providers/Microsoft.Resources/deployments/{deploymentName}/cancel") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", + "/providers/Microsoft.Management/managementGroups/{groupId}/providers/Microsoft.Resources/deployments/{deploymentName}/cancel", + ) # pylint: disable=line-too-long path_format_arguments = { - "groupId": _SERIALIZER.url("group_id", group_id, 'str', max_length=90, min_length=1), - "deploymentName": _SERIALIZER.url("deployment_name", deployment_name, 'str', max_length=64, min_length=1, pattern=r'^[-\w\._\(\)]+$'), + "groupId": _SERIALIZER.url("group_id", group_id, "str", max_length=90, min_length=1), + "deploymentName": _SERIALIZER.url( + "deployment_name", deployment_name, "str", max_length=64, min_length=1, pattern=r"^[-\w\._\(\)]+$" + ), } _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') - - return HttpRequest( - method="POST", - url=_url, - params=_query_parameters, - headers=_header_parameters, - **kwargs - ) + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="POST", url=_url, params=_params, headers=_headers, **kwargs) def build_deployments_validate_at_management_group_scope_request( - group_id: str, - deployment_name: str, - *, - json: JSONType = None, - content: Any = None, - **kwargs: Any + group_id: str, deployment_name: str, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2019-08-01") # type: str - content_type = kwargs.pop('content_type', None) # type: Optional[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", "2019-08-01")) # type: str + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + accept = _headers.pop("Accept", "application/json") - accept = "application/json" # Construct URL - _url = kwargs.pop("template_url", "/providers/Microsoft.Management/managementGroups/{groupId}/providers/Microsoft.Resources/deployments/{deploymentName}/validate") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", + "/providers/Microsoft.Management/managementGroups/{groupId}/providers/Microsoft.Resources/deployments/{deploymentName}/validate", + ) # pylint: disable=line-too-long path_format_arguments = { - "groupId": _SERIALIZER.url("group_id", group_id, 'str', max_length=90, min_length=1), - "deploymentName": _SERIALIZER.url("deployment_name", deployment_name, 'str', max_length=64, min_length=1, pattern=r'^[-\w\._\(\)]+$'), + "groupId": _SERIALIZER.url("group_id", group_id, "str", max_length=90, min_length=1), + "deploymentName": _SERIALIZER.url( + "deployment_name", deployment_name, "str", max_length=64, min_length=1, pattern=r"^[-\w\._\(\)]+$" + ), } _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] if content_type is not None: - _header_parameters['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') - _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') - - return HttpRequest( - method="POST", - url=_url, - params=_query_parameters, - headers=_header_parameters, - json=json, - content=content, - **kwargs - ) + _headers["Content-Type"] = _SERIALIZER.header("content_type", content_type, "str") + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="POST", url=_url, params=_params, headers=_headers, **kwargs) def build_deployments_export_template_at_management_group_scope_request( - group_id: str, - deployment_name: str, - **kwargs: Any + group_id: str, deployment_name: str, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2019-08-01") # type: 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", "2019-08-01")) # type: str + accept = _headers.pop("Accept", "application/json") - accept = "application/json" # Construct URL - _url = kwargs.pop("template_url", "/providers/Microsoft.Management/managementGroups/{groupId}/providers/Microsoft.Resources/deployments/{deploymentName}/exportTemplate") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", + "/providers/Microsoft.Management/managementGroups/{groupId}/providers/Microsoft.Resources/deployments/{deploymentName}/exportTemplate", + ) # pylint: disable=line-too-long path_format_arguments = { - "groupId": _SERIALIZER.url("group_id", group_id, 'str', max_length=90, min_length=1), - "deploymentName": _SERIALIZER.url("deployment_name", deployment_name, 'str', max_length=64, min_length=1, pattern=r'^[-\w\._\(\)]+$'), + "groupId": _SERIALIZER.url("group_id", group_id, "str", max_length=90, min_length=1), + "deploymentName": _SERIALIZER.url( + "deployment_name", deployment_name, "str", max_length=64, min_length=1, pattern=r"^[-\w\._\(\)]+$" + ), } _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') - - return HttpRequest( - method="POST", - url=_url, - params=_query_parameters, - headers=_header_parameters, - **kwargs - ) + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="POST", url=_url, params=_params, headers=_headers, **kwargs) def build_deployments_list_at_management_group_scope_request( - group_id: str, - *, - filter: Optional[str] = None, - top: Optional[int] = None, - **kwargs: Any + group_id: str, *, filter: Optional[str] = None, top: Optional[int] = None, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2019-08-01") # type: 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", "2019-08-01")) # type: str + accept = _headers.pop("Accept", "application/json") - accept = "application/json" # Construct URL - _url = kwargs.pop("template_url", "/providers/Microsoft.Management/managementGroups/{groupId}/providers/Microsoft.Resources/deployments/") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", + "/providers/Microsoft.Management/managementGroups/{groupId}/providers/Microsoft.Resources/deployments/", + ) # pylint: disable=line-too-long path_format_arguments = { - "groupId": _SERIALIZER.url("group_id", group_id, 'str', max_length=90, min_length=1), + "groupId": _SERIALIZER.url("group_id", group_id, "str", max_length=90, min_length=1), } _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] if filter is not None: - _query_parameters['$filter'] = _SERIALIZER.query("filter", filter, 'str') + _params["$filter"] = _SERIALIZER.query("filter", filter, "str") if top is not None: - _query_parameters['$top'] = _SERIALIZER.query("top", top, 'int') - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["$top"] = _SERIALIZER.query("top", top, "int") + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') - - return HttpRequest( - method="GET", - url=_url, - params=_query_parameters, - headers=_header_parameters, - **kwargs - ) + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) -def build_deployments_delete_at_subscription_scope_request_initial( - deployment_name: str, - subscription_id: str, - **kwargs: Any + +def build_deployments_delete_at_subscription_scope_request( + deployment_name: str, subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2019-08-01") # type: 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", "2019-08-01")) # type: str + accept = _headers.pop("Accept", "application/json") - accept = "application/json" # Construct URL - _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/providers/Microsoft.Resources/deployments/{deploymentName}") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", "/subscriptions/{subscriptionId}/providers/Microsoft.Resources/deployments/{deploymentName}" + ) # pylint: disable=line-too-long path_format_arguments = { - "deploymentName": _SERIALIZER.url("deployment_name", deployment_name, 'str', max_length=64, min_length=1, pattern=r'^[-\w\._\(\)]+$'), - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), + "deploymentName": _SERIALIZER.url( + "deployment_name", deployment_name, "str", max_length=64, min_length=1, pattern=r"^[-\w\._\(\)]+$" + ), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), } _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') - - return HttpRequest( - method="DELETE", - url=_url, - params=_query_parameters, - headers=_header_parameters, - **kwargs - ) + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="DELETE", url=_url, params=_params, headers=_headers, **kwargs) def build_deployments_check_existence_at_subscription_scope_request( - deployment_name: str, - subscription_id: str, - **kwargs: Any + deployment_name: str, subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2019-08-01") # type: 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", "2019-08-01")) # type: str + accept = _headers.pop("Accept", "application/json") - accept = "application/json" # Construct URL - _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/providers/Microsoft.Resources/deployments/{deploymentName}") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", "/subscriptions/{subscriptionId}/providers/Microsoft.Resources/deployments/{deploymentName}" + ) # pylint: disable=line-too-long path_format_arguments = { - "deploymentName": _SERIALIZER.url("deployment_name", deployment_name, 'str', max_length=64, min_length=1, pattern=r'^[-\w\._\(\)]+$'), - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), + "deploymentName": _SERIALIZER.url( + "deployment_name", deployment_name, "str", max_length=64, min_length=1, pattern=r"^[-\w\._\(\)]+$" + ), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), } _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') - - return HttpRequest( - method="HEAD", - url=_url, - params=_query_parameters, - headers=_header_parameters, - **kwargs - ) + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + return HttpRequest(method="HEAD", url=_url, params=_params, headers=_headers, **kwargs) -def build_deployments_create_or_update_at_subscription_scope_request_initial( - deployment_name: str, - subscription_id: str, - *, - json: JSONType = None, - content: Any = None, - **kwargs: Any + +def build_deployments_create_or_update_at_subscription_scope_request( + deployment_name: str, subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2019-08-01") # type: str - content_type = kwargs.pop('content_type', None) # type: Optional[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", "2019-08-01")) # type: str + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + accept = _headers.pop("Accept", "application/json") - accept = "application/json" # Construct URL - _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/providers/Microsoft.Resources/deployments/{deploymentName}") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", "/subscriptions/{subscriptionId}/providers/Microsoft.Resources/deployments/{deploymentName}" + ) # pylint: disable=line-too-long path_format_arguments = { - "deploymentName": _SERIALIZER.url("deployment_name", deployment_name, 'str', max_length=64, min_length=1, pattern=r'^[-\w\._\(\)]+$'), - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), + "deploymentName": _SERIALIZER.url( + "deployment_name", deployment_name, "str", max_length=64, min_length=1, pattern=r"^[-\w\._\(\)]+$" + ), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), } _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] if content_type is not None: - _header_parameters['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') - _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') - - return HttpRequest( - method="PUT", - url=_url, - params=_query_parameters, - headers=_header_parameters, - json=json, - content=content, - **kwargs - ) + _headers["Content-Type"] = _SERIALIZER.header("content_type", content_type, "str") + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="PUT", url=_url, params=_params, headers=_headers, **kwargs) def build_deployments_get_at_subscription_scope_request( - deployment_name: str, - subscription_id: str, - **kwargs: Any + deployment_name: str, subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2019-08-01") # type: 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", "2019-08-01")) # type: str + accept = _headers.pop("Accept", "application/json") - accept = "application/json" # Construct URL - _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/providers/Microsoft.Resources/deployments/{deploymentName}") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", "/subscriptions/{subscriptionId}/providers/Microsoft.Resources/deployments/{deploymentName}" + ) # pylint: disable=line-too-long path_format_arguments = { - "deploymentName": _SERIALIZER.url("deployment_name", deployment_name, 'str', max_length=64, min_length=1, pattern=r'^[-\w\._\(\)]+$'), - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), + "deploymentName": _SERIALIZER.url( + "deployment_name", deployment_name, "str", max_length=64, min_length=1, pattern=r"^[-\w\._\(\)]+$" + ), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), } _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') - - return HttpRequest( - method="GET", - url=_url, - params=_query_parameters, - headers=_header_parameters, - **kwargs - ) + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) def build_deployments_cancel_at_subscription_scope_request( - deployment_name: str, - subscription_id: str, - **kwargs: Any + deployment_name: str, subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2019-08-01") # type: 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", "2019-08-01")) # type: str + accept = _headers.pop("Accept", "application/json") - accept = "application/json" # Construct URL - _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/providers/Microsoft.Resources/deployments/{deploymentName}/cancel") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/providers/Microsoft.Resources/deployments/{deploymentName}/cancel", + ) # pylint: disable=line-too-long path_format_arguments = { - "deploymentName": _SERIALIZER.url("deployment_name", deployment_name, 'str', max_length=64, min_length=1, pattern=r'^[-\w\._\(\)]+$'), - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), + "deploymentName": _SERIALIZER.url( + "deployment_name", deployment_name, "str", max_length=64, min_length=1, pattern=r"^[-\w\._\(\)]+$" + ), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), } _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') - - return HttpRequest( - method="POST", - url=_url, - params=_query_parameters, - headers=_header_parameters, - **kwargs - ) + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="POST", url=_url, params=_params, headers=_headers, **kwargs) def build_deployments_validate_at_subscription_scope_request( - deployment_name: str, - subscription_id: str, - *, - json: JSONType = None, - content: Any = None, - **kwargs: Any + deployment_name: str, subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2019-08-01") # type: str - content_type = kwargs.pop('content_type', None) # type: Optional[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", "2019-08-01")) # type: str + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + accept = _headers.pop("Accept", "application/json") - accept = "application/json" # Construct URL - _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/providers/Microsoft.Resources/deployments/{deploymentName}/validate") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/providers/Microsoft.Resources/deployments/{deploymentName}/validate", + ) # pylint: disable=line-too-long path_format_arguments = { - "deploymentName": _SERIALIZER.url("deployment_name", deployment_name, 'str', max_length=64, min_length=1, pattern=r'^[-\w\._\(\)]+$'), - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), + "deploymentName": _SERIALIZER.url( + "deployment_name", deployment_name, "str", max_length=64, min_length=1, pattern=r"^[-\w\._\(\)]+$" + ), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), } _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] if content_type is not None: - _header_parameters['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') - _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') - - return HttpRequest( - method="POST", - url=_url, - params=_query_parameters, - headers=_header_parameters, - json=json, - content=content, - **kwargs - ) + _headers["Content-Type"] = _SERIALIZER.header("content_type", content_type, "str") + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + return HttpRequest(method="POST", url=_url, params=_params, headers=_headers, **kwargs) -def build_deployments_what_if_at_subscription_scope_request_initial( - deployment_name: str, - subscription_id: str, - *, - json: JSONType = None, - content: Any = None, - **kwargs: Any + +def build_deployments_what_if_at_subscription_scope_request( + deployment_name: str, subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2019-08-01") # type: str - content_type = kwargs.pop('content_type', None) # type: Optional[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", "2019-08-01")) # type: str + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + accept = _headers.pop("Accept", "application/json") - accept = "application/json" # Construct URL - _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/providers/Microsoft.Resources/deployments/{deploymentName}/whatIf") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/providers/Microsoft.Resources/deployments/{deploymentName}/whatIf", + ) # pylint: disable=line-too-long path_format_arguments = { - "deploymentName": _SERIALIZER.url("deployment_name", deployment_name, 'str', max_length=64, min_length=1, pattern=r'^[-\w\._\(\)]+$'), - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), + "deploymentName": _SERIALIZER.url( + "deployment_name", deployment_name, "str", max_length=64, min_length=1, pattern=r"^[-\w\._\(\)]+$" + ), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), } _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] if content_type is not None: - _header_parameters['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') - _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') - - return HttpRequest( - method="POST", - url=_url, - params=_query_parameters, - headers=_header_parameters, - json=json, - content=content, - **kwargs - ) + _headers["Content-Type"] = _SERIALIZER.header("content_type", content_type, "str") + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="POST", url=_url, params=_params, headers=_headers, **kwargs) def build_deployments_export_template_at_subscription_scope_request( - deployment_name: str, - subscription_id: str, - **kwargs: Any + deployment_name: str, subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2019-08-01") # type: 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", "2019-08-01")) # type: str + accept = _headers.pop("Accept", "application/json") - accept = "application/json" # Construct URL - _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/providers/Microsoft.Resources/deployments/{deploymentName}/exportTemplate") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/providers/Microsoft.Resources/deployments/{deploymentName}/exportTemplate", + ) # pylint: disable=line-too-long path_format_arguments = { - "deploymentName": _SERIALIZER.url("deployment_name", deployment_name, 'str', max_length=64, min_length=1, pattern=r'^[-\w\._\(\)]+$'), - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), + "deploymentName": _SERIALIZER.url( + "deployment_name", deployment_name, "str", max_length=64, min_length=1, pattern=r"^[-\w\._\(\)]+$" + ), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), } _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') - - return HttpRequest( - method="POST", - url=_url, - params=_query_parameters, - headers=_header_parameters, - **kwargs - ) + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="POST", url=_url, params=_params, headers=_headers, **kwargs) def build_deployments_list_at_subscription_scope_request( - subscription_id: str, - *, - filter: Optional[str] = None, - top: Optional[int] = None, - **kwargs: Any + subscription_id: str, *, filter: Optional[str] = None, top: Optional[int] = None, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2019-08-01") # type: 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", "2019-08-01")) # type: str + accept = _headers.pop("Accept", "application/json") - accept = "application/json" # Construct URL _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/providers/Microsoft.Resources/deployments/") path_format_arguments = { - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), } _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] if filter is not None: - _query_parameters['$filter'] = _SERIALIZER.query("filter", filter, 'str') + _params["$filter"] = _SERIALIZER.query("filter", filter, "str") if top is not None: - _query_parameters['$top'] = _SERIALIZER.query("top", top, 'int') - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["$top"] = _SERIALIZER.query("top", top, "int") + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') - - return HttpRequest( - method="GET", - url=_url, - params=_query_parameters, - headers=_header_parameters, - **kwargs - ) + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) -def build_deployments_delete_request_initial( - resource_group_name: str, - deployment_name: str, - subscription_id: str, - **kwargs: Any + +def build_deployments_delete_request( + resource_group_name: str, deployment_name: str, subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2019-08-01") # type: 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", "2019-08-01")) # type: str + accept = _headers.pop("Accept", "application/json") - accept = "application/json" # Construct URL - _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/Microsoft.Resources/deployments/{deploymentName}") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/Microsoft.Resources/deployments/{deploymentName}", + ) # pylint: disable=line-too-long path_format_arguments = { - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._\(\)]+$'), - "deploymentName": _SERIALIZER.url("deployment_name", deployment_name, 'str', max_length=64, min_length=1, pattern=r'^[-\w\._\(\)]+$'), - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), + "resourceGroupName": _SERIALIZER.url( + "resource_group_name", resource_group_name, "str", max_length=90, min_length=1, pattern=r"^[-\w\._\(\)]+$" + ), + "deploymentName": _SERIALIZER.url( + "deployment_name", deployment_name, "str", max_length=64, min_length=1, pattern=r"^[-\w\._\(\)]+$" + ), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), } _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') - - return HttpRequest( - method="DELETE", - url=_url, - params=_query_parameters, - headers=_header_parameters, - **kwargs - ) + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="DELETE", url=_url, params=_params, headers=_headers, **kwargs) def build_deployments_check_existence_request( - resource_group_name: str, - deployment_name: str, - subscription_id: str, - **kwargs: Any + resource_group_name: str, deployment_name: str, subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2019-08-01") # type: 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", "2019-08-01")) # type: str + accept = _headers.pop("Accept", "application/json") - accept = "application/json" # Construct URL - _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/Microsoft.Resources/deployments/{deploymentName}") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/Microsoft.Resources/deployments/{deploymentName}", + ) # pylint: disable=line-too-long path_format_arguments = { - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._\(\)]+$'), - "deploymentName": _SERIALIZER.url("deployment_name", deployment_name, 'str', max_length=64, min_length=1, pattern=r'^[-\w\._\(\)]+$'), - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), + "resourceGroupName": _SERIALIZER.url( + "resource_group_name", resource_group_name, "str", max_length=90, min_length=1, pattern=r"^[-\w\._\(\)]+$" + ), + "deploymentName": _SERIALIZER.url( + "deployment_name", deployment_name, "str", max_length=64, min_length=1, pattern=r"^[-\w\._\(\)]+$" + ), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), } _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') - - return HttpRequest( - method="HEAD", - url=_url, - params=_query_parameters, - headers=_header_parameters, - **kwargs - ) + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + return HttpRequest(method="HEAD", url=_url, params=_params, headers=_headers, **kwargs) -def build_deployments_create_or_update_request_initial( - resource_group_name: str, - deployment_name: str, - subscription_id: str, - *, - json: JSONType = None, - content: Any = None, - **kwargs: Any + +def build_deployments_create_or_update_request( + resource_group_name: str, deployment_name: str, subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2019-08-01") # type: str - content_type = kwargs.pop('content_type', None) # type: Optional[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", "2019-08-01")) # type: str + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + accept = _headers.pop("Accept", "application/json") - accept = "application/json" # Construct URL - _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/Microsoft.Resources/deployments/{deploymentName}") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/Microsoft.Resources/deployments/{deploymentName}", + ) # pylint: disable=line-too-long path_format_arguments = { - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._\(\)]+$'), - "deploymentName": _SERIALIZER.url("deployment_name", deployment_name, 'str', max_length=64, min_length=1, pattern=r'^[-\w\._\(\)]+$'), - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), + "resourceGroupName": _SERIALIZER.url( + "resource_group_name", resource_group_name, "str", max_length=90, min_length=1, pattern=r"^[-\w\._\(\)]+$" + ), + "deploymentName": _SERIALIZER.url( + "deployment_name", deployment_name, "str", max_length=64, min_length=1, pattern=r"^[-\w\._\(\)]+$" + ), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), } _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] if content_type is not None: - _header_parameters['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') - _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') - - return HttpRequest( - method="PUT", - url=_url, - params=_query_parameters, - headers=_header_parameters, - json=json, - content=content, - **kwargs - ) + _headers["Content-Type"] = _SERIALIZER.header("content_type", content_type, "str") + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="PUT", url=_url, params=_params, headers=_headers, **kwargs) def build_deployments_get_request( - resource_group_name: str, - deployment_name: str, - subscription_id: str, - **kwargs: Any + resource_group_name: str, deployment_name: str, subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2019-08-01") # type: 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", "2019-08-01")) # type: str + accept = _headers.pop("Accept", "application/json") - accept = "application/json" # Construct URL - _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/Microsoft.Resources/deployments/{deploymentName}") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/Microsoft.Resources/deployments/{deploymentName}", + ) # pylint: disable=line-too-long path_format_arguments = { - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._\(\)]+$'), - "deploymentName": _SERIALIZER.url("deployment_name", deployment_name, 'str', max_length=64, min_length=1, pattern=r'^[-\w\._\(\)]+$'), - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), + "resourceGroupName": _SERIALIZER.url( + "resource_group_name", resource_group_name, "str", max_length=90, min_length=1, pattern=r"^[-\w\._\(\)]+$" + ), + "deploymentName": _SERIALIZER.url( + "deployment_name", deployment_name, "str", max_length=64, min_length=1, pattern=r"^[-\w\._\(\)]+$" + ), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), } _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') - - return HttpRequest( - method="GET", - url=_url, - params=_query_parameters, - headers=_header_parameters, - **kwargs - ) + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) def build_deployments_cancel_request( - resource_group_name: str, - deployment_name: str, - subscription_id: str, - **kwargs: Any + resource_group_name: str, deployment_name: str, subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2019-08-01") # type: 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", "2019-08-01")) # type: str + accept = _headers.pop("Accept", "application/json") - accept = "application/json" # Construct URL - _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/Microsoft.Resources/deployments/{deploymentName}/cancel") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/Microsoft.Resources/deployments/{deploymentName}/cancel", + ) # pylint: disable=line-too-long path_format_arguments = { - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._\(\)]+$'), - "deploymentName": _SERIALIZER.url("deployment_name", deployment_name, 'str', max_length=64, min_length=1, pattern=r'^[-\w\._\(\)]+$'), - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), + "resourceGroupName": _SERIALIZER.url( + "resource_group_name", resource_group_name, "str", max_length=90, min_length=1, pattern=r"^[-\w\._\(\)]+$" + ), + "deploymentName": _SERIALIZER.url( + "deployment_name", deployment_name, "str", max_length=64, min_length=1, pattern=r"^[-\w\._\(\)]+$" + ), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), } _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') - - return HttpRequest( - method="POST", - url=_url, - params=_query_parameters, - headers=_header_parameters, - **kwargs - ) + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="POST", url=_url, params=_params, headers=_headers, **kwargs) def build_deployments_validate_request( - resource_group_name: str, - deployment_name: str, - subscription_id: str, - *, - json: JSONType = None, - content: Any = None, - **kwargs: Any + resource_group_name: str, deployment_name: str, subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2019-08-01") # type: str - content_type = kwargs.pop('content_type', None) # type: Optional[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", "2019-08-01")) # type: str + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + accept = _headers.pop("Accept", "application/json") - accept = "application/json" # Construct URL - _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/Microsoft.Resources/deployments/{deploymentName}/validate") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/Microsoft.Resources/deployments/{deploymentName}/validate", + ) # pylint: disable=line-too-long path_format_arguments = { - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._\(\)]+$'), - "deploymentName": _SERIALIZER.url("deployment_name", deployment_name, 'str', max_length=64, min_length=1, pattern=r'^[-\w\._\(\)]+$'), - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), + "resourceGroupName": _SERIALIZER.url( + "resource_group_name", resource_group_name, "str", max_length=90, min_length=1, pattern=r"^[-\w\._\(\)]+$" + ), + "deploymentName": _SERIALIZER.url( + "deployment_name", deployment_name, "str", max_length=64, min_length=1, pattern=r"^[-\w\._\(\)]+$" + ), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), } _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] if content_type is not None: - _header_parameters['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') - _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') - - return HttpRequest( - method="POST", - url=_url, - params=_query_parameters, - headers=_header_parameters, - json=json, - content=content, - **kwargs - ) + _headers["Content-Type"] = _SERIALIZER.header("content_type", content_type, "str") + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + return HttpRequest(method="POST", url=_url, params=_params, headers=_headers, **kwargs) -def build_deployments_what_if_request_initial( - resource_group_name: str, - deployment_name: str, - subscription_id: str, - *, - json: JSONType = None, - content: Any = None, - **kwargs: Any + +def build_deployments_what_if_request( + resource_group_name: str, deployment_name: str, subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2019-08-01") # type: str - content_type = kwargs.pop('content_type', None) # type: Optional[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", "2019-08-01")) # type: str + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + accept = _headers.pop("Accept", "application/json") - accept = "application/json" # Construct URL - _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/Microsoft.Resources/deployments/{deploymentName}/whatIf") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/Microsoft.Resources/deployments/{deploymentName}/whatIf", + ) # pylint: disable=line-too-long path_format_arguments = { - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._\(\)]+$'), - "deploymentName": _SERIALIZER.url("deployment_name", deployment_name, 'str', max_length=64, min_length=1, pattern=r'^[-\w\._\(\)]+$'), - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), + "resourceGroupName": _SERIALIZER.url( + "resource_group_name", resource_group_name, "str", max_length=90, min_length=1, pattern=r"^[-\w\._\(\)]+$" + ), + "deploymentName": _SERIALIZER.url( + "deployment_name", deployment_name, "str", max_length=64, min_length=1, pattern=r"^[-\w\._\(\)]+$" + ), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), } _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] if content_type is not None: - _header_parameters['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') - _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') - - return HttpRequest( - method="POST", - url=_url, - params=_query_parameters, - headers=_header_parameters, - json=json, - content=content, - **kwargs - ) + _headers["Content-Type"] = _SERIALIZER.header("content_type", content_type, "str") + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="POST", url=_url, params=_params, headers=_headers, **kwargs) def build_deployments_export_template_request( - resource_group_name: str, - deployment_name: str, - subscription_id: str, - **kwargs: Any + resource_group_name: str, deployment_name: str, subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2019-08-01") # type: 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", "2019-08-01")) # type: str + accept = _headers.pop("Accept", "application/json") - accept = "application/json" # Construct URL - _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/Microsoft.Resources/deployments/{deploymentName}/exportTemplate") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/Microsoft.Resources/deployments/{deploymentName}/exportTemplate", + ) # pylint: disable=line-too-long path_format_arguments = { - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._\(\)]+$'), - "deploymentName": _SERIALIZER.url("deployment_name", deployment_name, 'str', max_length=64, min_length=1, pattern=r'^[-\w\._\(\)]+$'), - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), + "resourceGroupName": _SERIALIZER.url( + "resource_group_name", resource_group_name, "str", max_length=90, min_length=1, pattern=r"^[-\w\._\(\)]+$" + ), + "deploymentName": _SERIALIZER.url( + "deployment_name", deployment_name, "str", max_length=64, min_length=1, pattern=r"^[-\w\._\(\)]+$" + ), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), } _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') - - return HttpRequest( - method="POST", - url=_url, - params=_query_parameters, - headers=_header_parameters, - **kwargs - ) + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="POST", url=_url, params=_params, headers=_headers, **kwargs) def build_deployments_list_by_resource_group_request( @@ -1569,285 +1354,227 @@ def build_deployments_list_by_resource_group_request( top: Optional[int] = None, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2019-08-01") # type: 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", "2019-08-01")) # type: str + accept = _headers.pop("Accept", "application/json") - accept = "application/json" # Construct URL - _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/Microsoft.Resources/deployments/") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/Microsoft.Resources/deployments/", + ) # pylint: disable=line-too-long path_format_arguments = { - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._\(\)]+$'), - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), + "resourceGroupName": _SERIALIZER.url( + "resource_group_name", resource_group_name, "str", max_length=90, min_length=1, pattern=r"^[-\w\._\(\)]+$" + ), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), } _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] if filter is not None: - _query_parameters['$filter'] = _SERIALIZER.query("filter", filter, 'str') + _params["$filter"] = _SERIALIZER.query("filter", filter, "str") if top is not None: - _query_parameters['$top'] = _SERIALIZER.query("top", top, 'int') - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["$top"] = _SERIALIZER.query("top", top, "int") + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') - - return HttpRequest( - method="GET", - url=_url, - params=_query_parameters, - headers=_header_parameters, - **kwargs - ) + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) -def build_deployments_calculate_template_hash_request( - *, - json: JSONType = None, - content: Any = None, - **kwargs: Any -) -> HttpRequest: - api_version = kwargs.pop('api_version', "2019-08-01") # type: str - content_type = kwargs.pop('content_type', None) # type: Optional[str] - accept = "application/json" +def build_deployments_calculate_template_hash_request(*, json: JSON, **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", "2019-08-01")) # type: str + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + accept = _headers.pop("Accept", "application/json") + # Construct URL _url = kwargs.pop("template_url", "/providers/Microsoft.Resources/calculateTemplateHash") # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] if content_type is not None: - _header_parameters['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') - _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') - - return HttpRequest( - method="POST", - url=_url, - params=_query_parameters, - headers=_header_parameters, - json=json, - content=content, - **kwargs - ) + _headers["Content-Type"] = _SERIALIZER.header("content_type", content_type, "str") + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="POST", url=_url, params=_params, headers=_headers, json=json, **kwargs) def build_providers_unregister_request( - resource_provider_namespace: str, - subscription_id: str, - **kwargs: Any + resource_provider_namespace: str, subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2019-08-01") # type: 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", "2019-08-01")) # type: str + accept = _headers.pop("Accept", "application/json") - accept = "application/json" # Construct URL - _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/providers/{resourceProviderNamespace}/unregister") + _url = kwargs.pop( + "template_url", "/subscriptions/{subscriptionId}/providers/{resourceProviderNamespace}/unregister" + ) path_format_arguments = { - "resourceProviderNamespace": _SERIALIZER.url("resource_provider_namespace", resource_provider_namespace, 'str'), - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), + "resourceProviderNamespace": _SERIALIZER.url("resource_provider_namespace", resource_provider_namespace, "str"), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), } _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') - - return HttpRequest( - method="POST", - url=_url, - params=_query_parameters, - headers=_header_parameters, - **kwargs - ) + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="POST", url=_url, params=_params, headers=_headers, **kwargs) def build_providers_register_request( - resource_provider_namespace: str, - subscription_id: str, - **kwargs: Any + resource_provider_namespace: str, subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2019-08-01") # type: 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", "2019-08-01")) # type: str + accept = _headers.pop("Accept", "application/json") - accept = "application/json" # Construct URL _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/providers/{resourceProviderNamespace}/register") path_format_arguments = { - "resourceProviderNamespace": _SERIALIZER.url("resource_provider_namespace", resource_provider_namespace, 'str'), - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), + "resourceProviderNamespace": _SERIALIZER.url("resource_provider_namespace", resource_provider_namespace, "str"), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), } _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') - - return HttpRequest( - method="POST", - url=_url, - params=_query_parameters, - headers=_header_parameters, - **kwargs - ) + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="POST", url=_url, params=_params, headers=_headers, **kwargs) def build_providers_list_request( - subscription_id: str, - *, - top: Optional[int] = None, - expand: Optional[str] = None, - **kwargs: Any + subscription_id: str, *, top: Optional[int] = None, expand: Optional[str] = None, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2019-08-01") # type: 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", "2019-08-01")) # type: str + accept = _headers.pop("Accept", "application/json") - accept = "application/json" # Construct URL _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/providers") path_format_arguments = { - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), } _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] if top is not None: - _query_parameters['$top'] = _SERIALIZER.query("top", top, 'int') + _params["$top"] = _SERIALIZER.query("top", top, "int") if expand is not None: - _query_parameters['$expand'] = _SERIALIZER.query("expand", expand, 'str') - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["$expand"] = _SERIALIZER.query("expand", expand, "str") + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') - - return HttpRequest( - method="GET", - url=_url, - params=_query_parameters, - headers=_header_parameters, - **kwargs - ) + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) def build_providers_list_at_tenant_scope_request( - *, - top: Optional[int] = None, - expand: Optional[str] = None, - **kwargs: Any + *, top: Optional[int] = None, expand: Optional[str] = None, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2019-08-01") # type: 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", "2019-08-01")) # type: str + accept = _headers.pop("Accept", "application/json") - accept = "application/json" # Construct URL _url = kwargs.pop("template_url", "/providers") # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] if top is not None: - _query_parameters['$top'] = _SERIALIZER.query("top", top, 'int') + _params["$top"] = _SERIALIZER.query("top", top, "int") if expand is not None: - _query_parameters['$expand'] = _SERIALIZER.query("expand", expand, 'str') - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["$expand"] = _SERIALIZER.query("expand", expand, "str") + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') - - return HttpRequest( - method="GET", - url=_url, - params=_query_parameters, - headers=_header_parameters, - **kwargs - ) + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) def build_providers_get_request( - resource_provider_namespace: str, - subscription_id: str, - *, - expand: Optional[str] = None, - **kwargs: Any + resource_provider_namespace: str, subscription_id: str, *, expand: Optional[str] = None, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2019-08-01") # type: 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", "2019-08-01")) # type: str + accept = _headers.pop("Accept", "application/json") - accept = "application/json" # Construct URL _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/providers/{resourceProviderNamespace}") path_format_arguments = { - "resourceProviderNamespace": _SERIALIZER.url("resource_provider_namespace", resource_provider_namespace, 'str'), - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), + "resourceProviderNamespace": _SERIALIZER.url("resource_provider_namespace", resource_provider_namespace, "str"), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), } _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] if expand is not None: - _query_parameters['$expand'] = _SERIALIZER.query("expand", expand, 'str') - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["$expand"] = _SERIALIZER.query("expand", expand, "str") + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') - - return HttpRequest( - method="GET", - url=_url, - params=_query_parameters, - headers=_header_parameters, - **kwargs - ) + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) def build_providers_get_at_tenant_scope_request( - resource_provider_namespace: str, - *, - expand: Optional[str] = None, - **kwargs: Any + resource_provider_namespace: str, *, expand: Optional[str] = None, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2019-08-01") # type: 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", "2019-08-01")) # type: str + accept = _headers.pop("Accept", "application/json") - accept = "application/json" # Construct URL _url = kwargs.pop("template_url", "/providers/{resourceProviderNamespace}") path_format_arguments = { - "resourceProviderNamespace": _SERIALIZER.url("resource_provider_namespace", resource_provider_namespace, 'str'), + "resourceProviderNamespace": _SERIALIZER.url("resource_provider_namespace", resource_provider_namespace, "str"), } _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] if expand is not None: - _query_parameters['$expand'] = _SERIALIZER.query("expand", expand, 'str') - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["$expand"] = _SERIALIZER.query("expand", expand, "str") + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') - - return HttpRequest( - method="GET", - url=_url, - params=_query_parameters, - headers=_header_parameters, - **kwargs - ) + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) def build_resources_list_by_resource_group_request( @@ -1859,123 +1586,114 @@ def build_resources_list_by_resource_group_request( top: Optional[int] = None, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2019-08-01") # type: 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", "2019-08-01")) # type: str + accept = _headers.pop("Accept", "application/json") - accept = "application/json" # Construct URL _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/resources") path_format_arguments = { - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._\(\)]+$'), - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), + "resourceGroupName": _SERIALIZER.url( + "resource_group_name", resource_group_name, "str", max_length=90, min_length=1, pattern=r"^[-\w\._\(\)]+$" + ), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), } _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] if filter is not None: - _query_parameters['$filter'] = _SERIALIZER.query("filter", filter, 'str') + _params["$filter"] = _SERIALIZER.query("filter", filter, "str") if expand is not None: - _query_parameters['$expand'] = _SERIALIZER.query("expand", expand, 'str') + _params["$expand"] = _SERIALIZER.query("expand", expand, "str") if top is not None: - _query_parameters['$top'] = _SERIALIZER.query("top", top, 'int') - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["$top"] = _SERIALIZER.query("top", top, "int") + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') - - return HttpRequest( - method="GET", - url=_url, - params=_query_parameters, - headers=_header_parameters, - **kwargs - ) + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) -def build_resources_move_resources_request_initial( - source_resource_group_name: str, - subscription_id: str, - *, - json: JSONType = None, - content: Any = None, - **kwargs: Any + +def build_resources_move_resources_request( + source_resource_group_name: str, subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2019-08-01") # type: str - content_type = kwargs.pop('content_type', None) # type: Optional[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", "2019-08-01")) # type: str + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + accept = _headers.pop("Accept", "application/json") - accept = "application/json" # Construct URL - _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{sourceResourceGroupName}/moveResources") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", "/subscriptions/{subscriptionId}/resourceGroups/{sourceResourceGroupName}/moveResources" + ) # pylint: disable=line-too-long path_format_arguments = { - "sourceResourceGroupName": _SERIALIZER.url("source_resource_group_name", source_resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._\(\)]+$'), - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), + "sourceResourceGroupName": _SERIALIZER.url( + "source_resource_group_name", + source_resource_group_name, + "str", + max_length=90, + min_length=1, + pattern=r"^[-\w\._\(\)]+$", + ), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), } _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] if content_type is not None: - _header_parameters['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') - _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') - - return HttpRequest( - method="POST", - url=_url, - params=_query_parameters, - headers=_header_parameters, - json=json, - content=content, - **kwargs - ) + _headers["Content-Type"] = _SERIALIZER.header("content_type", content_type, "str") + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + return HttpRequest(method="POST", url=_url, params=_params, headers=_headers, **kwargs) -def build_resources_validate_move_resources_request_initial( - source_resource_group_name: str, - subscription_id: str, - *, - json: JSONType = None, - content: Any = None, - **kwargs: Any + +def build_resources_validate_move_resources_request( + source_resource_group_name: str, subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2019-08-01") # type: str - content_type = kwargs.pop('content_type', None) # type: Optional[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", "2019-08-01")) # type: str + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + accept = _headers.pop("Accept", "application/json") - accept = "application/json" # Construct URL - _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{sourceResourceGroupName}/validateMoveResources") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", "/subscriptions/{subscriptionId}/resourceGroups/{sourceResourceGroupName}/validateMoveResources" + ) # pylint: disable=line-too-long path_format_arguments = { - "sourceResourceGroupName": _SERIALIZER.url("source_resource_group_name", source_resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._\(\)]+$'), - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), + "sourceResourceGroupName": _SERIALIZER.url( + "source_resource_group_name", + source_resource_group_name, + "str", + max_length=90, + min_length=1, + pattern=r"^[-\w\._\(\)]+$", + ), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), } _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] if content_type is not None: - _header_parameters['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') - _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') - - return HttpRequest( - method="POST", - url=_url, - params=_query_parameters, - headers=_header_parameters, - json=json, - content=content, - **kwargs - ) + _headers["Content-Type"] = _SERIALIZER.header("content_type", content_type, "str") + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="POST", url=_url, params=_params, headers=_headers, **kwargs) def build_resources_list_request( @@ -1986,38 +1704,33 @@ def build_resources_list_request( top: Optional[int] = None, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2019-08-01") # type: 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", "2019-08-01")) # type: str + accept = _headers.pop("Accept", "application/json") - accept = "application/json" # Construct URL _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resources") path_format_arguments = { - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), } _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] if filter is not None: - _query_parameters['$filter'] = _SERIALIZER.query("filter", filter, 'str') + _params["$filter"] = _SERIALIZER.query("filter", filter, "str") if expand is not None: - _query_parameters['$expand'] = _SERIALIZER.query("expand", expand, 'str') + _params["$expand"] = _SERIALIZER.query("expand", expand, "str") if top is not None: - _query_parameters['$top'] = _SERIALIZER.query("top", top, 'int') - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["$top"] = _SERIALIZER.query("top", top, "int") + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') - - return HttpRequest( - method="GET", - url=_url, - params=_query_parameters, - headers=_header_parameters, - **kwargs - ) + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) def build_resources_check_existence_request( @@ -2031,38 +1744,39 @@ def build_resources_check_existence_request( api_version: str, **kwargs: Any ) -> HttpRequest: - accept = "application/json" + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + accept = _headers.pop("Accept", "application/json") + # Construct URL - _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{parentResourcePath}/{resourceType}/{resourceName}") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{parentResourcePath}/{resourceType}/{resourceName}", + ) # pylint: disable=line-too-long path_format_arguments = { - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._\(\)]+$'), - "resourceProviderNamespace": _SERIALIZER.url("resource_provider_namespace", resource_provider_namespace, 'str'), - "parentResourcePath": _SERIALIZER.url("parent_resource_path", parent_resource_path, 'str', skip_quote=True), - "resourceType": _SERIALIZER.url("resource_type", resource_type, 'str', skip_quote=True), - "resourceName": _SERIALIZER.url("resource_name", resource_name, 'str'), - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), + "resourceGroupName": _SERIALIZER.url( + "resource_group_name", resource_group_name, "str", max_length=90, min_length=1, pattern=r"^[-\w\._\(\)]+$" + ), + "resourceProviderNamespace": _SERIALIZER.url("resource_provider_namespace", resource_provider_namespace, "str"), + "parentResourcePath": _SERIALIZER.url("parent_resource_path", parent_resource_path, "str", skip_quote=True), + "resourceType": _SERIALIZER.url("resource_type", resource_type, "str", skip_quote=True), + "resourceName": _SERIALIZER.url("resource_name", resource_name, "str"), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), } _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') - - return HttpRequest( - method="HEAD", - url=_url, - params=_query_parameters, - headers=_header_parameters, - **kwargs - ) + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + return HttpRequest(method="HEAD", url=_url, params=_params, headers=_headers, **kwargs) -def build_resources_delete_request_initial( + +def build_resources_delete_request( resource_group_name: str, resource_provider_namespace: str, parent_resource_path: str, @@ -2073,38 +1787,39 @@ def build_resources_delete_request_initial( api_version: str, **kwargs: Any ) -> HttpRequest: - accept = "application/json" + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + accept = _headers.pop("Accept", "application/json") + # Construct URL - _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{parentResourcePath}/{resourceType}/{resourceName}") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{parentResourcePath}/{resourceType}/{resourceName}", + ) # pylint: disable=line-too-long path_format_arguments = { - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._\(\)]+$'), - "resourceProviderNamespace": _SERIALIZER.url("resource_provider_namespace", resource_provider_namespace, 'str'), - "parentResourcePath": _SERIALIZER.url("parent_resource_path", parent_resource_path, 'str', skip_quote=True), - "resourceType": _SERIALIZER.url("resource_type", resource_type, 'str', skip_quote=True), - "resourceName": _SERIALIZER.url("resource_name", resource_name, 'str'), - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), + "resourceGroupName": _SERIALIZER.url( + "resource_group_name", resource_group_name, "str", max_length=90, min_length=1, pattern=r"^[-\w\._\(\)]+$" + ), + "resourceProviderNamespace": _SERIALIZER.url("resource_provider_namespace", resource_provider_namespace, "str"), + "parentResourcePath": _SERIALIZER.url("parent_resource_path", parent_resource_path, "str", skip_quote=True), + "resourceType": _SERIALIZER.url("resource_type", resource_type, "str", skip_quote=True), + "resourceName": _SERIALIZER.url("resource_name", resource_name, "str"), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), } _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') - - return HttpRequest( - method="DELETE", - url=_url, - params=_query_parameters, - headers=_header_parameters, - **kwargs - ) + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + return HttpRequest(method="DELETE", url=_url, params=_params, headers=_headers, **kwargs) -def build_resources_create_or_update_request_initial( + +def build_resources_create_or_update_request( resource_group_name: str, resource_provider_namespace: str, parent_resource_path: str, @@ -2113,48 +1828,44 @@ def build_resources_create_or_update_request_initial( subscription_id: str, *, api_version: str, - json: JSONType = None, - content: Any = None, **kwargs: Any ) -> HttpRequest: - content_type = kwargs.pop('content_type', None) # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + accept = _headers.pop("Accept", "application/json") - accept = "application/json" # Construct URL - _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{parentResourcePath}/{resourceType}/{resourceName}") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{parentResourcePath}/{resourceType}/{resourceName}", + ) # pylint: disable=line-too-long path_format_arguments = { - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._\(\)]+$'), - "resourceProviderNamespace": _SERIALIZER.url("resource_provider_namespace", resource_provider_namespace, 'str'), - "parentResourcePath": _SERIALIZER.url("parent_resource_path", parent_resource_path, 'str', skip_quote=True), - "resourceType": _SERIALIZER.url("resource_type", resource_type, 'str', skip_quote=True), - "resourceName": _SERIALIZER.url("resource_name", resource_name, 'str'), - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), + "resourceGroupName": _SERIALIZER.url( + "resource_group_name", resource_group_name, "str", max_length=90, min_length=1, pattern=r"^[-\w\._\(\)]+$" + ), + "resourceProviderNamespace": _SERIALIZER.url("resource_provider_namespace", resource_provider_namespace, "str"), + "parentResourcePath": _SERIALIZER.url("parent_resource_path", parent_resource_path, "str", skip_quote=True), + "resourceType": _SERIALIZER.url("resource_type", resource_type, "str", skip_quote=True), + "resourceName": _SERIALIZER.url("resource_name", resource_name, "str"), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), } _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] if content_type is not None: - _header_parameters['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') - _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') - - return HttpRequest( - method="PUT", - url=_url, - params=_query_parameters, - headers=_header_parameters, - json=json, - content=content, - **kwargs - ) + _headers["Content-Type"] = _SERIALIZER.header("content_type", content_type, "str") + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="PUT", url=_url, params=_params, headers=_headers, **kwargs) -def build_resources_update_request_initial( +def build_resources_update_request( resource_group_name: str, resource_provider_namespace: str, parent_resource_path: str, @@ -2163,45 +1874,41 @@ def build_resources_update_request_initial( subscription_id: str, *, api_version: str, - json: JSONType = None, - content: Any = None, **kwargs: Any ) -> HttpRequest: - content_type = kwargs.pop('content_type', None) # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + accept = _headers.pop("Accept", "application/json") - accept = "application/json" # Construct URL - _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{parentResourcePath}/{resourceType}/{resourceName}") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{parentResourcePath}/{resourceType}/{resourceName}", + ) # pylint: disable=line-too-long path_format_arguments = { - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._\(\)]+$'), - "resourceProviderNamespace": _SERIALIZER.url("resource_provider_namespace", resource_provider_namespace, 'str'), - "parentResourcePath": _SERIALIZER.url("parent_resource_path", parent_resource_path, 'str', skip_quote=True), - "resourceType": _SERIALIZER.url("resource_type", resource_type, 'str', skip_quote=True), - "resourceName": _SERIALIZER.url("resource_name", resource_name, 'str'), - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), + "resourceGroupName": _SERIALIZER.url( + "resource_group_name", resource_group_name, "str", max_length=90, min_length=1, pattern=r"^[-\w\._\(\)]+$" + ), + "resourceProviderNamespace": _SERIALIZER.url("resource_provider_namespace", resource_provider_namespace, "str"), + "parentResourcePath": _SERIALIZER.url("parent_resource_path", parent_resource_path, "str", skip_quote=True), + "resourceType": _SERIALIZER.url("resource_type", resource_type, "str", skip_quote=True), + "resourceName": _SERIALIZER.url("resource_name", resource_name, "str"), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), } _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] if content_type is not None: - _header_parameters['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') - _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') - - return HttpRequest( - method="PATCH", - url=_url, - params=_query_parameters, - headers=_header_parameters, - json=json, - content=content, - **kwargs - ) + _headers["Content-Type"] = _SERIALIZER.header("content_type", content_type, "str") + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="PATCH", url=_url, params=_params, headers=_headers, **kwargs) def build_resources_get_request( @@ -2215,1080 +1922,890 @@ def build_resources_get_request( api_version: str, **kwargs: Any ) -> HttpRequest: - accept = "application/json" + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + accept = _headers.pop("Accept", "application/json") + # Construct URL - _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{parentResourcePath}/{resourceType}/{resourceName}") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{parentResourcePath}/{resourceType}/{resourceName}", + ) # pylint: disable=line-too-long path_format_arguments = { - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._\(\)]+$'), - "resourceProviderNamespace": _SERIALIZER.url("resource_provider_namespace", resource_provider_namespace, 'str'), - "parentResourcePath": _SERIALIZER.url("parent_resource_path", parent_resource_path, 'str', skip_quote=True), - "resourceType": _SERIALIZER.url("resource_type", resource_type, 'str', skip_quote=True), - "resourceName": _SERIALIZER.url("resource_name", resource_name, 'str'), - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), + "resourceGroupName": _SERIALIZER.url( + "resource_group_name", resource_group_name, "str", max_length=90, min_length=1, pattern=r"^[-\w\._\(\)]+$" + ), + "resourceProviderNamespace": _SERIALIZER.url("resource_provider_namespace", resource_provider_namespace, "str"), + "parentResourcePath": _SERIALIZER.url("parent_resource_path", parent_resource_path, "str", skip_quote=True), + "resourceType": _SERIALIZER.url("resource_type", resource_type, "str", skip_quote=True), + "resourceName": _SERIALIZER.url("resource_name", resource_name, "str"), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), } _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') - - return HttpRequest( - method="GET", - url=_url, - params=_query_parameters, - headers=_header_parameters, - **kwargs - ) + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) + + +def build_resources_check_existence_by_id_request(resource_id: str, *, api_version: str, **kwargs: Any) -> HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + accept = _headers.pop("Accept", "application/json") -def build_resources_check_existence_by_id_request( - resource_id: str, - *, - api_version: str, - **kwargs: Any -) -> HttpRequest: - accept = "application/json" # Construct URL _url = kwargs.pop("template_url", "/{resourceId}") path_format_arguments = { - "resourceId": _SERIALIZER.url("resource_id", resource_id, 'str', skip_quote=True), + "resourceId": _SERIALIZER.url("resource_id", resource_id, "str", skip_quote=True), } _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') - - return HttpRequest( - method="HEAD", - url=_url, - params=_query_parameters, - headers=_header_parameters, - **kwargs - ) + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + return HttpRequest(method="HEAD", url=_url, params=_params, headers=_headers, **kwargs) + + +def build_resources_delete_by_id_request(resource_id: str, *, api_version: str, **kwargs: Any) -> HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + accept = _headers.pop("Accept", "application/json") -def build_resources_delete_by_id_request_initial( - resource_id: str, - *, - api_version: str, - **kwargs: Any -) -> HttpRequest: - accept = "application/json" # Construct URL _url = kwargs.pop("template_url", "/{resourceId}") path_format_arguments = { - "resourceId": _SERIALIZER.url("resource_id", resource_id, 'str', skip_quote=True), + "resourceId": _SERIALIZER.url("resource_id", resource_id, "str", skip_quote=True), } _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') - - return HttpRequest( - method="DELETE", - url=_url, - params=_query_parameters, - headers=_header_parameters, - **kwargs - ) + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + return HttpRequest(method="DELETE", url=_url, params=_params, headers=_headers, **kwargs) -def build_resources_create_or_update_by_id_request_initial( - resource_id: str, - *, - api_version: str, - json: JSONType = None, - content: Any = None, - **kwargs: Any -) -> HttpRequest: - content_type = kwargs.pop('content_type', None) # type: Optional[str] - accept = "application/json" +def build_resources_create_or_update_by_id_request(resource_id: str, *, api_version: str, **kwargs: Any) -> HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + accept = _headers.pop("Accept", "application/json") + # Construct URL _url = kwargs.pop("template_url", "/{resourceId}") path_format_arguments = { - "resourceId": _SERIALIZER.url("resource_id", resource_id, 'str', skip_quote=True), + "resourceId": _SERIALIZER.url("resource_id", resource_id, "str", skip_quote=True), } _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] if content_type is not None: - _header_parameters['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') - _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') - - return HttpRequest( - method="PUT", - url=_url, - params=_query_parameters, - headers=_header_parameters, - json=json, - content=content, - **kwargs - ) + _headers["Content-Type"] = _SERIALIZER.header("content_type", content_type, "str") + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + return HttpRequest(method="PUT", url=_url, params=_params, headers=_headers, **kwargs) -def build_resources_update_by_id_request_initial( - resource_id: str, - *, - api_version: str, - json: JSONType = None, - content: Any = None, - **kwargs: Any -) -> HttpRequest: - content_type = kwargs.pop('content_type', None) # type: Optional[str] - accept = "application/json" +def build_resources_update_by_id_request(resource_id: str, *, api_version: str, **kwargs: Any) -> HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + accept = _headers.pop("Accept", "application/json") + # Construct URL _url = kwargs.pop("template_url", "/{resourceId}") path_format_arguments = { - "resourceId": _SERIALIZER.url("resource_id", resource_id, 'str', skip_quote=True), + "resourceId": _SERIALIZER.url("resource_id", resource_id, "str", skip_quote=True), } _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] if content_type is not None: - _header_parameters['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') - _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') - - return HttpRequest( - method="PATCH", - url=_url, - params=_query_parameters, - headers=_header_parameters, - json=json, - content=content, - **kwargs - ) + _headers["Content-Type"] = _SERIALIZER.header("content_type", content_type, "str") + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + return HttpRequest(method="PATCH", url=_url, params=_params, headers=_headers, **kwargs) + + +def build_resources_get_by_id_request(resource_id: str, *, api_version: str, **kwargs: Any) -> HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + accept = _headers.pop("Accept", "application/json") -def build_resources_get_by_id_request( - resource_id: str, - *, - api_version: str, - **kwargs: Any -) -> HttpRequest: - accept = "application/json" # Construct URL _url = kwargs.pop("template_url", "/{resourceId}") path_format_arguments = { - "resourceId": _SERIALIZER.url("resource_id", resource_id, 'str', skip_quote=True), + "resourceId": _SERIALIZER.url("resource_id", resource_id, "str", skip_quote=True), } _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') - - return HttpRequest( - method="GET", - url=_url, - params=_query_parameters, - headers=_header_parameters, - **kwargs - ) + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) def build_resource_groups_check_existence_request( - resource_group_name: str, - subscription_id: str, - **kwargs: Any + resource_group_name: str, subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2019-08-01") # type: 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", "2019-08-01")) # type: str + accept = _headers.pop("Accept", "application/json") - accept = "application/json" # Construct URL _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}") path_format_arguments = { - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._\(\)]+$'), - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), + "resourceGroupName": _SERIALIZER.url( + "resource_group_name", resource_group_name, "str", max_length=90, min_length=1, pattern=r"^[-\w\._\(\)]+$" + ), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), } _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') - - return HttpRequest( - method="HEAD", - url=_url, - params=_query_parameters, - headers=_header_parameters, - **kwargs - ) + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="HEAD", url=_url, params=_params, headers=_headers, **kwargs) def build_resource_groups_create_or_update_request( - resource_group_name: str, - subscription_id: str, - *, - json: JSONType = None, - content: Any = None, - **kwargs: Any + resource_group_name: str, subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2019-08-01") # type: str - content_type = kwargs.pop('content_type', None) # type: Optional[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", "2019-08-01")) # type: str + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + accept = _headers.pop("Accept", "application/json") - accept = "application/json" # Construct URL _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}") path_format_arguments = { - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._\(\)]+$'), - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), + "resourceGroupName": _SERIALIZER.url( + "resource_group_name", resource_group_name, "str", max_length=90, min_length=1, pattern=r"^[-\w\._\(\)]+$" + ), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), } _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] if content_type is not None: - _header_parameters['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') - _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') - - return HttpRequest( - method="PUT", - url=_url, - params=_query_parameters, - headers=_header_parameters, - json=json, - content=content, - **kwargs - ) + _headers["Content-Type"] = _SERIALIZER.header("content_type", content_type, "str") + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + return HttpRequest(method="PUT", url=_url, params=_params, headers=_headers, **kwargs) -def build_resource_groups_delete_request_initial( - resource_group_name: str, - subscription_id: str, - **kwargs: Any -) -> HttpRequest: - api_version = kwargs.pop('api_version', "2019-08-01") # type: str - accept = "application/json" +def build_resource_groups_delete_request(resource_group_name: str, subscription_id: str, **kwargs: Any) -> HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2019-08-01")) # type: str + accept = _headers.pop("Accept", "application/json") + # Construct URL _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}") path_format_arguments = { - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._\(\)]+$'), - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), + "resourceGroupName": _SERIALIZER.url( + "resource_group_name", resource_group_name, "str", max_length=90, min_length=1, pattern=r"^[-\w\._\(\)]+$" + ), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), } _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') - - return HttpRequest( - method="DELETE", - url=_url, - params=_query_parameters, - headers=_header_parameters, - **kwargs - ) + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + return HttpRequest(method="DELETE", url=_url, params=_params, headers=_headers, **kwargs) -def build_resource_groups_get_request( - resource_group_name: str, - subscription_id: str, - **kwargs: Any -) -> HttpRequest: - api_version = kwargs.pop('api_version', "2019-08-01") # type: str - accept = "application/json" +def build_resource_groups_get_request(resource_group_name: str, subscription_id: str, **kwargs: Any) -> HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2019-08-01")) # type: str + accept = _headers.pop("Accept", "application/json") + # Construct URL _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}") path_format_arguments = { - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._\(\)]+$'), - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), + "resourceGroupName": _SERIALIZER.url( + "resource_group_name", resource_group_name, "str", max_length=90, min_length=1, pattern=r"^[-\w\._\(\)]+$" + ), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), } _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') - - return HttpRequest( - method="GET", - url=_url, - params=_query_parameters, - headers=_header_parameters, - **kwargs - ) + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) -def build_resource_groups_update_request( - resource_group_name: str, - subscription_id: str, - *, - json: JSONType = None, - content: Any = None, - **kwargs: Any -) -> HttpRequest: - api_version = kwargs.pop('api_version', "2019-08-01") # type: str - content_type = kwargs.pop('content_type', None) # type: Optional[str] - accept = "application/json" +def build_resource_groups_update_request(resource_group_name: str, subscription_id: str, **kwargs: Any) -> HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2019-08-01")) # type: str + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + accept = _headers.pop("Accept", "application/json") + # Construct URL _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}") path_format_arguments = { - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._\(\)]+$'), - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), + "resourceGroupName": _SERIALIZER.url( + "resource_group_name", resource_group_name, "str", max_length=90, min_length=1, pattern=r"^[-\w\._\(\)]+$" + ), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), } _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] if content_type is not None: - _header_parameters['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') - _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') - - return HttpRequest( - method="PATCH", - url=_url, - params=_query_parameters, - headers=_header_parameters, - json=json, - content=content, - **kwargs - ) + _headers["Content-Type"] = _SERIALIZER.header("content_type", content_type, "str") + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + return HttpRequest(method="PATCH", url=_url, params=_params, headers=_headers, **kwargs) -def build_resource_groups_export_template_request_initial( - subscription_id: str, - resource_group_name: str, - *, - json: JSONType = None, - content: Any = None, - **kwargs: Any + +def build_resource_groups_export_template_request( + resource_group_name: str, subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2019-08-01") # type: str - content_type = kwargs.pop('content_type', None) # type: Optional[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", "2019-08-01")) # type: str + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + accept = _headers.pop("Accept", "application/json") - accept = "application/json" # Construct URL - _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/exportTemplate") + _url = kwargs.pop( + "template_url", "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/exportTemplate" + ) path_format_arguments = { - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url( + "resource_group_name", resource_group_name, "str", max_length=90, min_length=1 + ), } _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] if content_type is not None: - _header_parameters['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') - _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') - - return HttpRequest( - method="POST", - url=_url, - params=_query_parameters, - headers=_header_parameters, - json=json, - content=content, - **kwargs - ) + _headers["Content-Type"] = _SERIALIZER.header("content_type", content_type, "str") + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="POST", url=_url, params=_params, headers=_headers, **kwargs) def build_resource_groups_list_request( - subscription_id: str, - *, - filter: Optional[str] = None, - top: Optional[int] = None, - **kwargs: Any + subscription_id: str, *, filter: Optional[str] = None, top: Optional[int] = None, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2019-08-01") # type: 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", "2019-08-01")) # type: str + accept = _headers.pop("Accept", "application/json") - accept = "application/json" # Construct URL _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourcegroups") path_format_arguments = { - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), } _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] if filter is not None: - _query_parameters['$filter'] = _SERIALIZER.query("filter", filter, 'str') + _params["$filter"] = _SERIALIZER.query("filter", filter, "str") if top is not None: - _query_parameters['$top'] = _SERIALIZER.query("top", top, 'int') - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["$top"] = _SERIALIZER.query("top", top, "int") + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') - - return HttpRequest( - method="GET", - url=_url, - params=_query_parameters, - headers=_header_parameters, - **kwargs - ) + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) -def build_tags_delete_value_request( - tag_name: str, - tag_value: str, - subscription_id: str, - **kwargs: Any -) -> HttpRequest: - api_version = kwargs.pop('api_version', "2019-08-01") # type: str - accept = "application/json" +def build_tags_delete_value_request(tag_name: str, tag_value: str, subscription_id: str, **kwargs: Any) -> HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2019-08-01")) # type: str + accept = _headers.pop("Accept", "application/json") + # Construct URL _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/tagNames/{tagName}/tagValues/{tagValue}") path_format_arguments = { - "tagName": _SERIALIZER.url("tag_name", tag_name, 'str'), - "tagValue": _SERIALIZER.url("tag_value", tag_value, 'str'), - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), + "tagName": _SERIALIZER.url("tag_name", tag_name, "str"), + "tagValue": _SERIALIZER.url("tag_value", tag_value, "str"), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), } _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') - - return HttpRequest( - method="DELETE", - url=_url, - params=_query_parameters, - headers=_header_parameters, - **kwargs - ) + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="DELETE", url=_url, params=_params, headers=_headers, **kwargs) def build_tags_create_or_update_value_request( - tag_name: str, - tag_value: str, - subscription_id: str, - **kwargs: Any + tag_name: str, tag_value: str, subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2019-08-01") # type: 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", "2019-08-01")) # type: str + accept = _headers.pop("Accept", "application/json") - accept = "application/json" # Construct URL _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/tagNames/{tagName}/tagValues/{tagValue}") path_format_arguments = { - "tagName": _SERIALIZER.url("tag_name", tag_name, 'str'), - "tagValue": _SERIALIZER.url("tag_value", tag_value, 'str'), - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), + "tagName": _SERIALIZER.url("tag_name", tag_name, "str"), + "tagValue": _SERIALIZER.url("tag_value", tag_value, "str"), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), } _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') - - return HttpRequest( - method="PUT", - url=_url, - params=_query_parameters, - headers=_header_parameters, - **kwargs - ) + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + return HttpRequest(method="PUT", url=_url, params=_params, headers=_headers, **kwargs) -def build_tags_create_or_update_request( - tag_name: str, - subscription_id: str, - **kwargs: Any -) -> HttpRequest: - api_version = kwargs.pop('api_version', "2019-08-01") # type: str - accept = "application/json" +def build_tags_create_or_update_request(tag_name: str, subscription_id: str, **kwargs: Any) -> HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2019-08-01")) # type: str + accept = _headers.pop("Accept", "application/json") + # Construct URL _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/tagNames/{tagName}") path_format_arguments = { - "tagName": _SERIALIZER.url("tag_name", tag_name, 'str'), - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), + "tagName": _SERIALIZER.url("tag_name", tag_name, "str"), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), } _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') - - return HttpRequest( - method="PUT", - url=_url, - params=_query_parameters, - headers=_header_parameters, - **kwargs - ) + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + return HttpRequest(method="PUT", url=_url, params=_params, headers=_headers, **kwargs) -def build_tags_delete_request( - tag_name: str, - subscription_id: str, - **kwargs: Any -) -> HttpRequest: - api_version = kwargs.pop('api_version', "2019-08-01") # type: str - accept = "application/json" +def build_tags_delete_request(tag_name: str, subscription_id: str, **kwargs: Any) -> HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2019-08-01")) # type: str + accept = _headers.pop("Accept", "application/json") + # Construct URL _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/tagNames/{tagName}") path_format_arguments = { - "tagName": _SERIALIZER.url("tag_name", tag_name, 'str'), - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), + "tagName": _SERIALIZER.url("tag_name", tag_name, "str"), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), } _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') - - return HttpRequest( - method="DELETE", - url=_url, - params=_query_parameters, - headers=_header_parameters, - **kwargs - ) + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + return HttpRequest(method="DELETE", url=_url, params=_params, headers=_headers, **kwargs) -def build_tags_list_request( - subscription_id: str, - **kwargs: Any -) -> HttpRequest: - api_version = kwargs.pop('api_version', "2019-08-01") # type: str - accept = "application/json" +def build_tags_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", "2019-08-01")) # type: str + accept = _headers.pop("Accept", "application/json") + # Construct URL _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/tagNames") path_format_arguments = { - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), } _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') - - return HttpRequest( - method="GET", - url=_url, - params=_query_parameters, - headers=_header_parameters, - **kwargs - ) + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) def build_deployment_operations_get_at_scope_request( - scope: str, - deployment_name: str, - operation_id: str, - **kwargs: Any + scope: str, deployment_name: str, operation_id: str, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2019-08-01") # type: 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", "2019-08-01")) # type: str + accept = _headers.pop("Accept", "application/json") - accept = "application/json" # Construct URL - _url = kwargs.pop("template_url", "/{scope}/providers/Microsoft.Resources/deployments/{deploymentName}/operations/{operationId}") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", "/{scope}/providers/Microsoft.Resources/deployments/{deploymentName}/operations/{operationId}" + ) # pylint: disable=line-too-long path_format_arguments = { - "scope": _SERIALIZER.url("scope", scope, 'str'), - "deploymentName": _SERIALIZER.url("deployment_name", deployment_name, 'str', max_length=64, min_length=1, pattern=r'^[-\w\._\(\)]+$'), - "operationId": _SERIALIZER.url("operation_id", operation_id, 'str'), + "scope": _SERIALIZER.url("scope", scope, "str"), + "deploymentName": _SERIALIZER.url( + "deployment_name", deployment_name, "str", max_length=64, min_length=1, pattern=r"^[-\w\._\(\)]+$" + ), + "operationId": _SERIALIZER.url("operation_id", operation_id, "str"), } _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') - - return HttpRequest( - method="GET", - url=_url, - params=_query_parameters, - headers=_header_parameters, - **kwargs - ) + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) def build_deployment_operations_list_at_scope_request( - scope: str, - deployment_name: str, - *, - top: Optional[int] = None, - **kwargs: Any + scope: str, deployment_name: str, *, top: Optional[int] = None, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2019-08-01") # type: 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", "2019-08-01")) # type: str + accept = _headers.pop("Accept", "application/json") - accept = "application/json" # Construct URL _url = kwargs.pop("template_url", "/{scope}/providers/Microsoft.Resources/deployments/{deploymentName}/operations") path_format_arguments = { - "scope": _SERIALIZER.url("scope", scope, 'str'), - "deploymentName": _SERIALIZER.url("deployment_name", deployment_name, 'str', max_length=64, min_length=1, pattern=r'^[-\w\._\(\)]+$'), + "scope": _SERIALIZER.url("scope", scope, "str"), + "deploymentName": _SERIALIZER.url( + "deployment_name", deployment_name, "str", max_length=64, min_length=1, pattern=r"^[-\w\._\(\)]+$" + ), } _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] if top is not None: - _query_parameters['$top'] = _SERIALIZER.query("top", top, 'int') - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["$top"] = _SERIALIZER.query("top", top, "int") + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') - - return HttpRequest( - method="GET", - url=_url, - params=_query_parameters, - headers=_header_parameters, - **kwargs - ) + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) def build_deployment_operations_get_at_tenant_scope_request( - deployment_name: str, - operation_id: str, - **kwargs: Any + deployment_name: str, operation_id: str, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2019-08-01") # type: 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", "2019-08-01")) # type: str + accept = _headers.pop("Accept", "application/json") - accept = "application/json" # Construct URL - _url = kwargs.pop("template_url", "/providers/Microsoft.Resources/deployments/{deploymentName}/operations/{operationId}") + _url = kwargs.pop( + "template_url", "/providers/Microsoft.Resources/deployments/{deploymentName}/operations/{operationId}" + ) path_format_arguments = { - "deploymentName": _SERIALIZER.url("deployment_name", deployment_name, 'str', max_length=64, min_length=1, pattern=r'^[-\w\._\(\)]+$'), - "operationId": _SERIALIZER.url("operation_id", operation_id, 'str'), + "deploymentName": _SERIALIZER.url( + "deployment_name", deployment_name, "str", max_length=64, min_length=1, pattern=r"^[-\w\._\(\)]+$" + ), + "operationId": _SERIALIZER.url("operation_id", operation_id, "str"), } _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') - - return HttpRequest( - method="GET", - url=_url, - params=_query_parameters, - headers=_header_parameters, - **kwargs - ) + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) def build_deployment_operations_list_at_tenant_scope_request( - deployment_name: str, - *, - top: Optional[int] = None, - **kwargs: Any + deployment_name: str, *, top: Optional[int] = None, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2019-08-01") # type: 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", "2019-08-01")) # type: str + accept = _headers.pop("Accept", "application/json") - accept = "application/json" # Construct URL _url = kwargs.pop("template_url", "/providers/Microsoft.Resources/deployments/{deploymentName}/operations") path_format_arguments = { - "deploymentName": _SERIALIZER.url("deployment_name", deployment_name, 'str', max_length=64, min_length=1, pattern=r'^[-\w\._\(\)]+$'), + "deploymentName": _SERIALIZER.url( + "deployment_name", deployment_name, "str", max_length=64, min_length=1, pattern=r"^[-\w\._\(\)]+$" + ), } _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] if top is not None: - _query_parameters['$top'] = _SERIALIZER.query("top", top, 'int') - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["$top"] = _SERIALIZER.query("top", top, "int") + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') - - return HttpRequest( - method="GET", - url=_url, - params=_query_parameters, - headers=_header_parameters, - **kwargs - ) + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) def build_deployment_operations_get_at_management_group_scope_request( - group_id: str, - deployment_name: str, - operation_id: str, - **kwargs: Any + group_id: str, deployment_name: str, operation_id: str, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2019-08-01") # type: 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", "2019-08-01")) # type: str + accept = _headers.pop("Accept", "application/json") - accept = "application/json" # Construct URL - _url = kwargs.pop("template_url", "/providers/Microsoft.Management/managementGroups/{groupId}/providers/Microsoft.Resources/deployments/{deploymentName}/operations/{operationId}") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", + "/providers/Microsoft.Management/managementGroups/{groupId}/providers/Microsoft.Resources/deployments/{deploymentName}/operations/{operationId}", + ) # pylint: disable=line-too-long path_format_arguments = { - "groupId": _SERIALIZER.url("group_id", group_id, 'str', max_length=90, min_length=1), - "deploymentName": _SERIALIZER.url("deployment_name", deployment_name, 'str', max_length=64, min_length=1, pattern=r'^[-\w\._\(\)]+$'), - "operationId": _SERIALIZER.url("operation_id", operation_id, 'str'), + "groupId": _SERIALIZER.url("group_id", group_id, "str", max_length=90, min_length=1), + "deploymentName": _SERIALIZER.url( + "deployment_name", deployment_name, "str", max_length=64, min_length=1, pattern=r"^[-\w\._\(\)]+$" + ), + "operationId": _SERIALIZER.url("operation_id", operation_id, "str"), } _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') - - return HttpRequest( - method="GET", - url=_url, - params=_query_parameters, - headers=_header_parameters, - **kwargs - ) + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) def build_deployment_operations_list_at_management_group_scope_request( - group_id: str, - deployment_name: str, - *, - top: Optional[int] = None, - **kwargs: Any + group_id: str, deployment_name: str, *, top: Optional[int] = None, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2019-08-01") # type: 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", "2019-08-01")) # type: str + accept = _headers.pop("Accept", "application/json") - accept = "application/json" # Construct URL - _url = kwargs.pop("template_url", "/providers/Microsoft.Management/managementGroups/{groupId}/providers/Microsoft.Resources/deployments/{deploymentName}/operations") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", + "/providers/Microsoft.Management/managementGroups/{groupId}/providers/Microsoft.Resources/deployments/{deploymentName}/operations", + ) # pylint: disable=line-too-long path_format_arguments = { - "groupId": _SERIALIZER.url("group_id", group_id, 'str', max_length=90, min_length=1), - "deploymentName": _SERIALIZER.url("deployment_name", deployment_name, 'str', max_length=64, min_length=1, pattern=r'^[-\w\._\(\)]+$'), + "groupId": _SERIALIZER.url("group_id", group_id, "str", max_length=90, min_length=1), + "deploymentName": _SERIALIZER.url( + "deployment_name", deployment_name, "str", max_length=64, min_length=1, pattern=r"^[-\w\._\(\)]+$" + ), } _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] if top is not None: - _query_parameters['$top'] = _SERIALIZER.query("top", top, 'int') - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["$top"] = _SERIALIZER.query("top", top, "int") + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') - - return HttpRequest( - method="GET", - url=_url, - params=_query_parameters, - headers=_header_parameters, - **kwargs - ) + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) def build_deployment_operations_get_at_subscription_scope_request( - deployment_name: str, - operation_id: str, - subscription_id: str, - **kwargs: Any + deployment_name: str, operation_id: str, subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2019-08-01") # type: 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", "2019-08-01")) # type: str + accept = _headers.pop("Accept", "application/json") - accept = "application/json" # Construct URL - _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/providers/Microsoft.Resources/deployments/{deploymentName}/operations/{operationId}") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/providers/Microsoft.Resources/deployments/{deploymentName}/operations/{operationId}", + ) # pylint: disable=line-too-long path_format_arguments = { - "deploymentName": _SERIALIZER.url("deployment_name", deployment_name, 'str', max_length=64, min_length=1, pattern=r'^[-\w\._\(\)]+$'), - "operationId": _SERIALIZER.url("operation_id", operation_id, 'str'), - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), + "deploymentName": _SERIALIZER.url( + "deployment_name", deployment_name, "str", max_length=64, min_length=1, pattern=r"^[-\w\._\(\)]+$" + ), + "operationId": _SERIALIZER.url("operation_id", operation_id, "str"), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), } _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') - - return HttpRequest( - method="GET", - url=_url, - params=_query_parameters, - headers=_header_parameters, - **kwargs - ) + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) def build_deployment_operations_list_at_subscription_scope_request( - deployment_name: str, - subscription_id: str, - *, - top: Optional[int] = None, - **kwargs: Any + deployment_name: str, subscription_id: str, *, top: Optional[int] = None, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2019-08-01") # type: 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", "2019-08-01")) # type: str + accept = _headers.pop("Accept", "application/json") - accept = "application/json" # Construct URL - _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/providers/Microsoft.Resources/deployments/{deploymentName}/operations") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/providers/Microsoft.Resources/deployments/{deploymentName}/operations", + ) # pylint: disable=line-too-long path_format_arguments = { - "deploymentName": _SERIALIZER.url("deployment_name", deployment_name, 'str', max_length=64, min_length=1, pattern=r'^[-\w\._\(\)]+$'), - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), + "deploymentName": _SERIALIZER.url( + "deployment_name", deployment_name, "str", max_length=64, min_length=1, pattern=r"^[-\w\._\(\)]+$" + ), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), } _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] if top is not None: - _query_parameters['$top'] = _SERIALIZER.query("top", top, 'int') - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["$top"] = _SERIALIZER.query("top", top, "int") + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') - - return HttpRequest( - method="GET", - url=_url, - params=_query_parameters, - headers=_header_parameters, - **kwargs - ) + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) def build_deployment_operations_get_request( - resource_group_name: str, - deployment_name: str, - operation_id: str, - subscription_id: str, - **kwargs: Any + resource_group_name: str, deployment_name: str, operation_id: str, subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2019-08-01") # type: 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", "2019-08-01")) # type: str + accept = _headers.pop("Accept", "application/json") - accept = "application/json" # Construct URL - _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/deployments/{deploymentName}/operations/{operationId}") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/deployments/{deploymentName}/operations/{operationId}", + ) # pylint: disable=line-too-long path_format_arguments = { - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._\(\)]+$'), - "deploymentName": _SERIALIZER.url("deployment_name", deployment_name, 'str', max_length=64, min_length=1, pattern=r'^[-\w\._\(\)]+$'), - "operationId": _SERIALIZER.url("operation_id", operation_id, 'str'), - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), + "resourceGroupName": _SERIALIZER.url( + "resource_group_name", resource_group_name, "str", max_length=90, min_length=1, pattern=r"^[-\w\._\(\)]+$" + ), + "deploymentName": _SERIALIZER.url( + "deployment_name", deployment_name, "str", max_length=64, min_length=1, pattern=r"^[-\w\._\(\)]+$" + ), + "operationId": _SERIALIZER.url("operation_id", operation_id, "str"), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), } _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') - - return HttpRequest( - method="GET", - url=_url, - params=_query_parameters, - headers=_header_parameters, - **kwargs - ) + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) def build_deployment_operations_list_request( - resource_group_name: str, - deployment_name: str, - subscription_id: str, - *, - top: Optional[int] = None, - **kwargs: Any + resource_group_name: str, deployment_name: str, subscription_id: str, *, top: Optional[int] = None, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2019-08-01") # type: 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", "2019-08-01")) # type: str + accept = _headers.pop("Accept", "application/json") - accept = "application/json" # Construct URL - _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/deployments/{deploymentName}/operations") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/deployments/{deploymentName}/operations", + ) # pylint: disable=line-too-long path_format_arguments = { - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._\(\)]+$'), - "deploymentName": _SERIALIZER.url("deployment_name", deployment_name, 'str', max_length=64, min_length=1, pattern=r'^[-\w\._\(\)]+$'), - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), + "resourceGroupName": _SERIALIZER.url( + "resource_group_name", resource_group_name, "str", max_length=90, min_length=1, pattern=r"^[-\w\._\(\)]+$" + ), + "deploymentName": _SERIALIZER.url( + "deployment_name", deployment_name, "str", max_length=64, min_length=1, pattern=r"^[-\w\._\(\)]+$" + ), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), } _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] if top is not None: - _query_parameters['$top'] = _SERIALIZER.query("top", top, 'int') - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["$top"] = _SERIALIZER.query("top", top, "int") + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') - - return HttpRequest( - method="GET", - url=_url, - params=_query_parameters, - headers=_header_parameters, - **kwargs - ) + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) -class Operations(object): - """Operations operations. - You should not instantiate this class directly. Instead, you should create a Client instance that - instantiates it for you and attaches it as an attribute. +class Operations: + """ + .. warning:: + **DO NOT** instantiate this class directly. - :ivar models: Alias to model classes used in this operation group. - :type models: ~azure.mgmt.resource.resources.v2019_08_01.models - :param client: Client for service requests. - :param config: Configuration of service client. - :param serializer: An object model serializer. - :param deserializer: An object model deserializer. + Instead, you should access the following operations through + :class:`~azure.mgmt.resource.resources.v2019_08_01.ResourceManagementClient`'s + :attr:`operations` attribute. """ models = _models - def __init__(self, client, config, serializer, deserializer): - self._client = client - self._serialize = serializer - self._deserialize = deserializer - self._config = config + def __init__(self, *args, **kwargs): + input_args = list(args) + self._client = input_args.pop(0) if input_args else kwargs.pop("client") + self._config = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") @distributed_trace - def list( - self, - **kwargs: Any - ) -> Iterable["_models.OperationListResult"]: + def list(self, **kwargs: Any) -> Iterable["_models.Operation"]: """Lists all of the available Microsoft.Resources REST API operations. :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either OperationListResult or the result of cls(response) + :return: An iterator like instance of either Operation or the result of cls(response) :rtype: - ~azure.core.paging.ItemPaged[~azure.mgmt.resource.resources.v2019_08_01.models.OperationListResult] - :raises: ~azure.core.exceptions.HttpResponseError + ~azure.core.paging.ItemPaged[~azure.mgmt.resource.resources.v2019_08_01.models.Operation] + :raises ~azure.core.exceptions.HttpResponseError: """ - api_version = kwargs.pop('api_version', "2019-08-01") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2019-08-01")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[_models.OperationListResult] - cls = kwargs.pop('cls', None) # type: ClsType["_models.OperationListResult"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) + def prepare_request(next_link=None): if not next_link: - + request = build_operations_list_request( api_version=api_version, - template_url=self.list.metadata['url'], + template_url=self.list.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore else: - - request = build_operations_list_request( - template_url=next_link, - ) + # make call to next link with the client's api-version + _parsed_next_link = urlparse(next_link) + _next_request_params = case_insensitive_dict(parse_qs(_parsed_next_link.query)) + _next_request_params["api-version"] = self._config.api_version + request = HttpRequest("GET", urljoin(next_link, _parsed_next_link.path), params=_next_request_params) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore request.method = "GET" return request @@ -3302,10 +2819,8 @@ def extract_data(pipeline_response): def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) response = pipeline_response.http_response @@ -3315,62 +2830,62 @@ def get_next(next_link=None): return pipeline_response + return ItemPaged(get_next, extract_data) - return ItemPaged( - get_next, extract_data - ) - list.metadata = {'url': "/providers/Microsoft.Resources/operations"} # type: ignore -class DeploymentsOperations(object): # pylint: disable=too-many-public-methods - """DeploymentsOperations operations. + list.metadata = {"url": "/providers/Microsoft.Resources/operations"} # type: ignore - You should not instantiate this class directly. Instead, you should create a Client instance that - instantiates it for you and attaches it as an attribute. - :ivar models: Alias to model classes used in this operation group. - :type models: ~azure.mgmt.resource.resources.v2019_08_01.models - :param client: Client for service requests. - :param config: Configuration of service client. - :param serializer: An object model serializer. - :param deserializer: An object model deserializer. +class DeploymentsOperations: # pylint: disable=too-many-public-methods """ + .. warning:: + **DO NOT** instantiate this class directly. - models = _models + Instead, you should access the following operations through + :class:`~azure.mgmt.resource.resources.v2019_08_01.ResourceManagementClient`'s + :attr:`deployments` attribute. + """ + + models = _models - def __init__(self, client, config, serializer, deserializer): - self._client = client - self._serialize = serializer - self._deserialize = deserializer - self._config = config + def __init__(self, *args, **kwargs): + input_args = list(args) + self._client = input_args.pop(0) if input_args else kwargs.pop("client") + self._config = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") def _delete_at_scope_initial( # pylint: disable=inconsistent-return-statements - self, - scope: str, - deployment_name: str, - **kwargs: Any + self, scope: str, deployment_name: str, **kwargs: Any ) -> None: - cls = kwargs.pop('cls', None) # type: ClsType[None] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + 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', "2019-08-01") # type: str + api_version = kwargs.pop("api_version", _params.pop("api-version", "2019-08-01")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[None] - - request = build_deployments_delete_at_scope_request_initial( + request = build_deployments_delete_at_scope_request( scope=scope, deployment_name=deployment_name, api_version=api_version, - template_url=self._delete_at_scope_initial.metadata['url'], + template_url=self._delete_at_scope_initial.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [202, 204]: @@ -3380,16 +2895,10 @@ def _delete_at_scope_initial( # pylint: disable=inconsistent-return-statements if cls: return cls(pipeline_response, None, {}) - _delete_at_scope_initial.metadata = {'url': "/{scope}/providers/Microsoft.Resources/deployments/{deploymentName}"} # type: ignore - + _delete_at_scope_initial.metadata = {"url": "/{scope}/providers/Microsoft.Resources/deployments/{deploymentName}"} # type: ignore @distributed_trace - def begin_delete_at_scope( # pylint: disable=inconsistent-return-statements - self, - scope: str, - deployment_name: str, - **kwargs: Any - ) -> LROPoller[None]: + def begin_delete_at_scope(self, scope: str, deployment_name: str, **kwargs: Any) -> LROPoller[None]: """Deletes a deployment from the deployment history. A template deployment that is currently running cannot be deleted. Deleting a template @@ -3400,9 +2909,9 @@ def begin_delete_at_scope( # pylint: disable=inconsistent-return-statements process finishes, the URI in the Location header returns a status of 204 on success. If the asynchronous request failed, the URI in the Location header returns an error-level status code. - :param scope: The scope of a deployment. + :param scope: The scope of a deployment. Required. :type scope: str - :param deployment_name: The name of the deployment. + :param deployment_name: The name of the deployment. Required. :type deployment_name: str :keyword callable cls: A custom type or function that will be passed the direct response :keyword str continuation_token: A continuation token to restart a poller from a saved state. @@ -3414,86 +2923,91 @@ def begin_delete_at_scope( # pylint: disable=inconsistent-return-statements Retry-After header is present. :return: An instance of LROPoller that returns either None or the result of cls(response) :rtype: ~azure.core.polling.LROPoller[None] - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - api_version = kwargs.pop('api_version', "2019-08-01") # type: str - polling = kwargs.pop('polling', True) # type: Union[bool, PollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType[None] - lro_delay = kwargs.pop( - 'polling_interval', - self._config.polling_interval - ) - cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2019-08-01")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[None] + polling = kwargs.pop("polling", True) # type: Union[bool, PollingMethod] + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token = kwargs.pop("continuation_token", None) # type: Optional[str] if cont_token is None: - raw_result = self._delete_at_scope_initial( + raw_result = self._delete_at_scope_initial( # type: ignore scope=scope, deployment_name=deployment_name, api_version=api_version, - cls=lambda x,y,z: x, + cls=lambda x, y, z: x, + headers=_headers, + params=_params, **kwargs ) - kwargs.pop('error_map', None) + kwargs.pop("error_map", None) - def get_long_running_output(pipeline_response): + def get_long_running_output(pipeline_response): # pylint: disable=inconsistent-return-statements if cls: return cls(pipeline_response, None, {}) - - if polling is True: polling_method = ARMPolling(lro_delay, **kwargs) - elif polling is False: polling_method = NoPolling() - else: polling_method = polling + if polling is True: + polling_method = cast(PollingMethod, ARMPolling(lro_delay, **kwargs)) # type: PollingMethod + elif polling is False: + polling_method = cast(PollingMethod, NoPolling()) + else: + polling_method = polling if cont_token: return LROPoller.from_continuation_token( polling_method=polling_method, continuation_token=cont_token, client=self._client, - deserialization_callback=get_long_running_output + deserialization_callback=get_long_running_output, ) return LROPoller(self._client, raw_result, get_long_running_output, polling_method) - begin_delete_at_scope.metadata = {'url': "/{scope}/providers/Microsoft.Resources/deployments/{deploymentName}"} # type: ignore + begin_delete_at_scope.metadata = {"url": "/{scope}/providers/Microsoft.Resources/deployments/{deploymentName}"} # type: ignore @distributed_trace - def check_existence_at_scope( - self, - scope: str, - deployment_name: str, - **kwargs: Any - ) -> bool: + def check_existence_at_scope(self, scope: str, deployment_name: str, **kwargs: Any) -> bool: """Checks whether the deployment exists. - :param scope: The scope of a deployment. + :param scope: The scope of a deployment. Required. :type scope: str - :param deployment_name: The name of the deployment. + :param deployment_name: The name of the deployment. Required. :type deployment_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: bool, or the result of cls(response) + :return: bool or the result of cls(response) :rtype: bool - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType[None] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + 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', "2019-08-01") # type: str + api_version = kwargs.pop("api_version", _params.pop("api-version", "2019-08-01")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[None] - request = build_deployments_check_existence_at_scope_request( scope=scope, deployment_name=deployment_name, api_version=api_version, - template_url=self.check_existence_at_scope.metadata['url'], + template_url=self.check_existence_at_scope.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [204, 404]: @@ -3504,43 +3018,52 @@ def check_existence_at_scope( return cls(pipeline_response, None, {}) return 200 <= response.status_code <= 299 - check_existence_at_scope.metadata = {'url': "/{scope}/providers/Microsoft.Resources/deployments/{deploymentName}"} # type: ignore - + check_existence_at_scope.metadata = {"url": "/{scope}/providers/Microsoft.Resources/deployments/{deploymentName}"} # type: ignore def _create_or_update_at_scope_initial( - self, - scope: str, - deployment_name: str, - parameters: "_models.Deployment", - **kwargs: Any - ) -> "_models.DeploymentExtended": - cls = kwargs.pop('cls', None) # type: ClsType["_models.DeploymentExtended"] + self, scope: str, deployment_name: str, parameters: Union[_models.Deployment, IO], **kwargs: Any + ) -> _models.DeploymentExtended: error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) - api_version = kwargs.pop('api_version', "2019-08-01") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - _json = self._serialize.body(parameters, 'Deployment') + api_version = kwargs.pop("api_version", _params.pop("api-version", "2019-08-01")) # type: str + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.DeploymentExtended] - request = build_deployments_create_or_update_at_scope_request_initial( + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(parameters, (IO, bytes)): + _content = parameters + else: + _json = self._serialize.body(parameters, "Deployment") + + request = build_deployments_create_or_update_at_scope_request( scope=scope, deployment_name=deployment_name, api_version=api_version, content_type=content_type, json=_json, - template_url=self._create_or_update_at_scope_initial.metadata['url'], + content=_content, + template_url=self._create_or_update_at_scope_initial.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200, 201]: @@ -3548,37 +3071,41 @@ def _create_or_update_at_scope_initial( raise HttpResponseError(response=response, error_format=ARMErrorFormat) if response.status_code == 200: - deserialized = self._deserialize('DeploymentExtended', pipeline_response) + deserialized = self._deserialize("DeploymentExtended", pipeline_response) if response.status_code == 201: - deserialized = self._deserialize('DeploymentExtended', pipeline_response) + deserialized = self._deserialize("DeploymentExtended", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - _create_or_update_at_scope_initial.metadata = {'url': "/{scope}/providers/Microsoft.Resources/deployments/{deploymentName}"} # type: ignore + _create_or_update_at_scope_initial.metadata = {"url": "/{scope}/providers/Microsoft.Resources/deployments/{deploymentName}"} # type: ignore - - @distributed_trace + @overload def begin_create_or_update_at_scope( self, scope: str, deployment_name: str, - parameters: "_models.Deployment", + parameters: _models.Deployment, + *, + content_type: str = "application/json", **kwargs: Any - ) -> LROPoller["_models.DeploymentExtended"]: + ) -> LROPoller[_models.DeploymentExtended]: """Deploys resources at a given scope. You can provide the template and parameters directly in the request or link to JSON files. - :param scope: The scope of a deployment. + :param scope: The scope of a deployment. Required. :type scope: str - :param deployment_name: The name of the deployment. + :param deployment_name: The name of the deployment. Required. :type deployment_name: str - :param parameters: Additional parameters supplied to the operation. + :param parameters: Additional parameters supplied to the operation. Required. :type parameters: ~azure.mgmt.resource.resources.v2019_08_01.models.Deployment + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str :keyword callable cls: A custom type or function that will be passed the direct response :keyword str continuation_token: A continuation token to restart a poller from a saved state. :keyword polling: By default, your polling method will be ARMPolling. Pass in False for this @@ -3591,114 +3118,179 @@ def begin_create_or_update_at_scope( cls(response) :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.resource.resources.v2019_08_01.models.DeploymentExtended] - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - api_version = kwargs.pop('api_version', "2019-08-01") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] - polling = kwargs.pop('polling', True) # type: Union[bool, PollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType["_models.DeploymentExtended"] - lro_delay = kwargs.pop( - 'polling_interval', - self._config.polling_interval - ) - cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] + + @overload + def begin_create_or_update_at_scope( + self, scope: str, deployment_name: str, parameters: IO, *, content_type: str = "application/json", **kwargs: Any + ) -> LROPoller[_models.DeploymentExtended]: + """Deploys resources at a given scope. + + You can provide the template and parameters directly in the request or link to JSON files. + + :param scope: The scope of a deployment. Required. + :type scope: str + :param deployment_name: The name of the deployment. Required. + :type deployment_name: str + :param parameters: Additional parameters supplied to the operation. Required. + :type parameters: IO + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be ARMPolling. Pass in False for this + operation to not poll, or pass in your own initialized polling object for a personal polling + strategy. + :paramtype polling: bool or ~azure.core.polling.PollingMethod + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of LROPoller that returns either DeploymentExtended or the result of + cls(response) + :rtype: + ~azure.core.polling.LROPoller[~azure.mgmt.resource.resources.v2019_08_01.models.DeploymentExtended] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace + def begin_create_or_update_at_scope( + self, scope: str, deployment_name: str, parameters: Union[_models.Deployment, IO], **kwargs: Any + ) -> LROPoller[_models.DeploymentExtended]: + """Deploys resources at a given scope. + + You can provide the template and parameters directly in the request or link to JSON files. + + :param scope: The scope of a deployment. Required. + :type scope: str + :param deployment_name: The name of the deployment. Required. + :type deployment_name: str + :param parameters: Additional parameters supplied to the operation. Is either a model type or a + IO type. Required. + :type parameters: ~azure.mgmt.resource.resources.v2019_08_01.models.Deployment or IO + :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. + Default value is None. + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be ARMPolling. Pass in False for this + operation to not poll, or pass in your own initialized polling object for a personal polling + strategy. + :paramtype polling: bool or ~azure.core.polling.PollingMethod + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of LROPoller that returns either DeploymentExtended or the result of + cls(response) + :rtype: + ~azure.core.polling.LROPoller[~azure.mgmt.resource.resources.v2019_08_01.models.DeploymentExtended] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _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", "2019-08-01")) # type: str + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.DeploymentExtended] + polling = kwargs.pop("polling", True) # type: Union[bool, PollingMethod] + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token = kwargs.pop("continuation_token", None) # type: Optional[str] if cont_token is None: - raw_result = self._create_or_update_at_scope_initial( + raw_result = self._create_or_update_at_scope_initial( # type: ignore scope=scope, deployment_name=deployment_name, parameters=parameters, api_version=api_version, content_type=content_type, - cls=lambda x,y,z: x, + cls=lambda x, y, z: x, + headers=_headers, + params=_params, **kwargs ) - kwargs.pop('error_map', None) + kwargs.pop("error_map", None) def get_long_running_output(pipeline_response): - response = pipeline_response.http_response - deserialized = self._deserialize('DeploymentExtended', pipeline_response) + deserialized = self._deserialize("DeploymentExtended", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - - if polling is True: polling_method = ARMPolling(lro_delay, **kwargs) - elif polling is False: polling_method = NoPolling() - else: polling_method = polling + if polling is True: + polling_method = cast(PollingMethod, ARMPolling(lro_delay, **kwargs)) # type: PollingMethod + elif polling is False: + polling_method = cast(PollingMethod, NoPolling()) + else: + polling_method = polling if cont_token: return LROPoller.from_continuation_token( polling_method=polling_method, continuation_token=cont_token, client=self._client, - deserialization_callback=get_long_running_output + deserialization_callback=get_long_running_output, ) return LROPoller(self._client, raw_result, get_long_running_output, polling_method) - begin_create_or_update_at_scope.metadata = {'url': "/{scope}/providers/Microsoft.Resources/deployments/{deploymentName}"} # type: ignore + begin_create_or_update_at_scope.metadata = {"url": "/{scope}/providers/Microsoft.Resources/deployments/{deploymentName}"} # type: ignore @distributed_trace - def get_at_scope( - self, - scope: str, - deployment_name: str, - **kwargs: Any - ) -> "_models.DeploymentExtended": + def get_at_scope(self, scope: str, deployment_name: str, **kwargs: Any) -> _models.DeploymentExtended: """Gets a deployment. - :param scope: The scope of a deployment. + :param scope: The scope of a deployment. Required. :type scope: str - :param deployment_name: The name of the deployment. + :param deployment_name: The name of the deployment. Required. :type deployment_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: DeploymentExtended, or the result of cls(response) + :return: DeploymentExtended or the result of cls(response) :rtype: ~azure.mgmt.resource.resources.v2019_08_01.models.DeploymentExtended - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.DeploymentExtended"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) - api_version = kwargs.pop('api_version', "2019-08-01") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2019-08-01")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[_models.DeploymentExtended] - request = build_deployments_get_at_scope_request( scope=scope, deployment_name=deployment_name, api_version=api_version, - template_url=self.get_at_scope.metadata['url'], + template_url=self.get_at_scope.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) - deserialized = self._deserialize('DeploymentExtended', pipeline_response) + deserialized = self._deserialize("DeploymentExtended", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - get_at_scope.metadata = {'url': "/{scope}/providers/Microsoft.Resources/deployments/{deploymentName}"} # type: ignore - + get_at_scope.metadata = {"url": "/{scope}/providers/Microsoft.Resources/deployments/{deploymentName}"} # type: ignore @distributed_trace def cancel_at_scope( # pylint: disable=inconsistent-return-statements - self, - scope: str, - deployment_name: str, - **kwargs: Any + self, scope: str, deployment_name: str, **kwargs: Any ) -> None: """Cancels a currently running template deployment. @@ -3707,38 +3299,44 @@ def cancel_at_scope( # pylint: disable=inconsistent-return-statements deployment stops the currently running template deployment and leaves the resources partially deployed. - :param scope: The scope of a deployment. + :param scope: The scope of a deployment. Required. :type scope: str - :param deployment_name: The name of the deployment. + :param deployment_name: The name of the deployment. Required. :type deployment_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: None, or the result of cls(response) + :return: None or the result of cls(response) :rtype: None - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType[None] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + 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', "2019-08-01") # type: str + api_version = kwargs.pop("api_version", _params.pop("api-version", "2019-08-01")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[None] - request = build_deployments_cancel_at_scope_request( scope=scope, deployment_name=deployment_name, api_version=api_version, - template_url=self.cancel_at_scope.metadata['url'], + template_url=self.cancel_at_scope.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [204]: @@ -3748,41 +3346,101 @@ def cancel_at_scope( # pylint: disable=inconsistent-return-statements if cls: return cls(pipeline_response, None, {}) - cancel_at_scope.metadata = {'url': "/{scope}/providers/Microsoft.Resources/deployments/{deploymentName}/cancel"} # type: ignore - + cancel_at_scope.metadata = {"url": "/{scope}/providers/Microsoft.Resources/deployments/{deploymentName}/cancel"} # type: ignore - @distributed_trace + @overload def validate_at_scope( self, scope: str, deployment_name: str, - parameters: "_models.Deployment", + parameters: _models.Deployment, + *, + content_type: str = "application/json", **kwargs: Any - ) -> "_models.DeploymentValidateResult": + ) -> _models.DeploymentValidateResult: """Validates whether the specified template is syntactically correct and will be accepted by Azure Resource Manager.. - :param scope: The scope of a deployment. + :param scope: The scope of a deployment. Required. :type scope: str - :param deployment_name: The name of the deployment. + :param deployment_name: The name of the deployment. Required. :type deployment_name: str - :param parameters: Parameters to validate. + :param parameters: Parameters to validate. Required. :type parameters: ~azure.mgmt.resource.resources.v2019_08_01.models.Deployment + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: DeploymentValidateResult or the result of cls(response) + :rtype: ~azure.mgmt.resource.resources.v2019_08_01.models.DeploymentValidateResult + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + def validate_at_scope( + self, scope: str, deployment_name: str, parameters: IO, *, content_type: str = "application/json", **kwargs: Any + ) -> _models.DeploymentValidateResult: + """Validates whether the specified template is syntactically correct and will be accepted by Azure + Resource Manager.. + + :param scope: The scope of a deployment. Required. + :type scope: str + :param deployment_name: The name of the deployment. Required. + :type deployment_name: str + :param parameters: Parameters to validate. Required. + :type parameters: IO + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: DeploymentValidateResult or the result of cls(response) + :rtype: ~azure.mgmt.resource.resources.v2019_08_01.models.DeploymentValidateResult + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace + def validate_at_scope( + self, scope: str, deployment_name: str, parameters: Union[_models.Deployment, IO], **kwargs: Any + ) -> _models.DeploymentValidateResult: + """Validates whether the specified template is syntactically correct and will be accepted by Azure + Resource Manager.. + + :param scope: The scope of a deployment. Required. + :type scope: str + :param deployment_name: The name of the deployment. Required. + :type deployment_name: str + :param parameters: Parameters to validate. Is either a model type or a IO type. Required. + :type parameters: ~azure.mgmt.resource.resources.v2019_08_01.models.Deployment or IO + :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. + Default value is None. + :paramtype content_type: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: DeploymentValidateResult, or the result of cls(response) + :return: DeploymentValidateResult or the result of cls(response) :rtype: ~azure.mgmt.resource.resources.v2019_08_01.models.DeploymentValidateResult - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.DeploymentValidateResult"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', "2019-08-01") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + api_version = kwargs.pop("api_version", _params.pop("api-version", "2019-08-01")) # type: str + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.DeploymentValidateResult] - _json = self._serialize.body(parameters, 'Deployment') + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(parameters, (IO, bytes)): + _content = parameters + else: + _json = self._serialize.body(parameters, "Deployment") request = build_deployments_validate_at_scope_request( scope=scope, @@ -3790,16 +3448,18 @@ def validate_at_scope( api_version=api_version, content_type=content_type, json=_json, - template_url=self.validate_at_scope.metadata['url'], + content=_content, + template_url=self.validate_at_scope.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200, 400]: @@ -3807,87 +3467,84 @@ def validate_at_scope( raise HttpResponseError(response=response, error_format=ARMErrorFormat) if response.status_code == 200: - deserialized = self._deserialize('DeploymentValidateResult', pipeline_response) + deserialized = self._deserialize("DeploymentValidateResult", pipeline_response) if response.status_code == 400: - deserialized = self._deserialize('DeploymentValidateResult', pipeline_response) + deserialized = self._deserialize("DeploymentValidateResult", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - validate_at_scope.metadata = {'url': "/{scope}/providers/Microsoft.Resources/deployments/{deploymentName}/validate"} # type: ignore - + validate_at_scope.metadata = {"url": "/{scope}/providers/Microsoft.Resources/deployments/{deploymentName}/validate"} # type: ignore @distributed_trace def export_template_at_scope( - self, - scope: str, - deployment_name: str, - **kwargs: Any - ) -> "_models.DeploymentExportResult": + self, scope: str, deployment_name: str, **kwargs: Any + ) -> _models.DeploymentExportResult: """Exports the template used for specified deployment. - :param scope: The scope of a deployment. + :param scope: The scope of a deployment. Required. :type scope: str - :param deployment_name: The name of the deployment. + :param deployment_name: The name of the deployment. Required. :type deployment_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: DeploymentExportResult, or the result of cls(response) + :return: DeploymentExportResult or the result of cls(response) :rtype: ~azure.mgmt.resource.resources.v2019_08_01.models.DeploymentExportResult - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.DeploymentExportResult"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) - api_version = kwargs.pop('api_version', "2019-08-01") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2019-08-01")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[_models.DeploymentExportResult] - request = build_deployments_export_template_at_scope_request( scope=scope, deployment_name=deployment_name, api_version=api_version, - template_url=self.export_template_at_scope.metadata['url'], + template_url=self.export_template_at_scope.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) - deserialized = self._deserialize('DeploymentExportResult', pipeline_response) + deserialized = self._deserialize("DeploymentExportResult", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - export_template_at_scope.metadata = {'url': "/{scope}/providers/Microsoft.Resources/deployments/{deploymentName}/exportTemplate"} # type: ignore - + export_template_at_scope.metadata = {"url": "/{scope}/providers/Microsoft.Resources/deployments/{deploymentName}/exportTemplate"} # type: ignore @distributed_trace def list_at_scope( - self, - scope: str, - filter: Optional[str] = None, - top: Optional[int] = None, - **kwargs: Any - ) -> Iterable["_models.DeploymentListResult"]: + self, scope: str, filter: Optional[str] = None, top: Optional[int] = None, **kwargs: Any + ) -> Iterable["_models.DeploymentExtended"]: """Get all the deployments at the given scope. - :param scope: The scope of a deployment. + :param scope: The scope of a deployment. Required. :type scope: str :param filter: The filter to apply on the operation. For example, you can use $filter=provisioningState eq '{state}'. Default value is None. @@ -3896,40 +3553,48 @@ def list_at_scope( value is None. :type top: int :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either DeploymentListResult or the result of - cls(response) + :return: An iterator like instance of either DeploymentExtended or the result of cls(response) :rtype: - ~azure.core.paging.ItemPaged[~azure.mgmt.resource.resources.v2019_08_01.models.DeploymentListResult] - :raises: ~azure.core.exceptions.HttpResponseError + ~azure.core.paging.ItemPaged[~azure.mgmt.resource.resources.v2019_08_01.models.DeploymentExtended] + :raises ~azure.core.exceptions.HttpResponseError: """ - api_version = kwargs.pop('api_version', "2019-08-01") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2019-08-01")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[_models.DeploymentListResult] - cls = kwargs.pop('cls', None) # type: ClsType["_models.DeploymentListResult"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) + def prepare_request(next_link=None): if not next_link: - + request = build_deployments_list_at_scope_request( scope=scope, - api_version=api_version, filter=filter, top=top, - template_url=self.list_at_scope.metadata['url'], + api_version=api_version, + template_url=self.list_at_scope.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore else: - - request = build_deployments_list_at_scope_request( - scope=scope, - template_url=next_link, - ) + # make call to next link with the client's api-version + _parsed_next_link = urlparse(next_link) + _next_request_params = case_insensitive_dict(parse_qs(_parsed_next_link.query)) + _next_request_params["api-version"] = self._config.api_version + request = HttpRequest("GET", urljoin(next_link, _parsed_next_link.path), params=_next_request_params) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore request.method = "GET" return request @@ -3943,10 +3608,8 @@ def extract_data(pipeline_response): def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) response = pipeline_response.http_response @@ -3956,39 +3619,41 @@ def get_next(next_link=None): return pipeline_response + return ItemPaged(get_next, extract_data) - return ItemPaged( - get_next, extract_data - ) - list_at_scope.metadata = {'url': "/{scope}/providers/Microsoft.Resources/deployments/"} # type: ignore + list_at_scope.metadata = {"url": "/{scope}/providers/Microsoft.Resources/deployments/"} # type: ignore def _delete_at_tenant_scope_initial( # pylint: disable=inconsistent-return-statements - self, - deployment_name: str, - **kwargs: Any + self, deployment_name: str, **kwargs: Any ) -> None: - cls = kwargs.pop('cls', None) # type: ClsType[None] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) - api_version = kwargs.pop('api_version', "2019-08-01") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - request = build_deployments_delete_at_tenant_scope_request_initial( + api_version = kwargs.pop("api_version", _params.pop("api-version", "2019-08-01")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[None] + + request = build_deployments_delete_at_tenant_scope_request( deployment_name=deployment_name, api_version=api_version, - template_url=self._delete_at_tenant_scope_initial.metadata['url'], + template_url=self._delete_at_tenant_scope_initial.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [202, 204]: @@ -3998,15 +3663,10 @@ def _delete_at_tenant_scope_initial( # pylint: disable=inconsistent-return-stat if cls: return cls(pipeline_response, None, {}) - _delete_at_tenant_scope_initial.metadata = {'url': "/providers/Microsoft.Resources/deployments/{deploymentName}"} # type: ignore - + _delete_at_tenant_scope_initial.metadata = {"url": "/providers/Microsoft.Resources/deployments/{deploymentName}"} # type: ignore @distributed_trace - def begin_delete_at_tenant_scope( # pylint: disable=inconsistent-return-statements - self, - deployment_name: str, - **kwargs: Any - ) -> LROPoller[None]: + def begin_delete_at_tenant_scope(self, deployment_name: str, **kwargs: Any) -> LROPoller[None]: """Deletes a deployment from the deployment history. A template deployment that is currently running cannot be deleted. Deleting a template @@ -4017,7 +3677,7 @@ def begin_delete_at_tenant_scope( # pylint: disable=inconsistent-return-stateme process finishes, the URI in the Location header returns a status of 204 on success. If the asynchronous request failed, the URI in the Location header returns an error-level status code. - :param deployment_name: The name of the deployment. + :param deployment_name: The name of the deployment. Required. :type deployment_name: str :keyword callable cls: A custom type or function that will be passed the direct response :keyword str continuation_token: A continuation token to restart a poller from a saved state. @@ -4029,81 +3689,87 @@ def begin_delete_at_tenant_scope( # pylint: disable=inconsistent-return-stateme Retry-After header is present. :return: An instance of LROPoller that returns either None or the result of cls(response) :rtype: ~azure.core.polling.LROPoller[None] - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - api_version = kwargs.pop('api_version', "2019-08-01") # type: str - polling = kwargs.pop('polling', True) # type: Union[bool, PollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType[None] - lro_delay = kwargs.pop( - 'polling_interval', - self._config.polling_interval - ) - cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2019-08-01")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[None] + polling = kwargs.pop("polling", True) # type: Union[bool, PollingMethod] + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token = kwargs.pop("continuation_token", None) # type: Optional[str] if cont_token is None: - raw_result = self._delete_at_tenant_scope_initial( + raw_result = self._delete_at_tenant_scope_initial( # type: ignore deployment_name=deployment_name, api_version=api_version, - cls=lambda x,y,z: x, + cls=lambda x, y, z: x, + headers=_headers, + params=_params, **kwargs ) - kwargs.pop('error_map', None) + kwargs.pop("error_map", None) - def get_long_running_output(pipeline_response): + def get_long_running_output(pipeline_response): # pylint: disable=inconsistent-return-statements if cls: return cls(pipeline_response, None, {}) - - if polling is True: polling_method = ARMPolling(lro_delay, **kwargs) - elif polling is False: polling_method = NoPolling() - else: polling_method = polling + if polling is True: + polling_method = cast(PollingMethod, ARMPolling(lro_delay, **kwargs)) # type: PollingMethod + elif polling is False: + polling_method = cast(PollingMethod, NoPolling()) + else: + polling_method = polling if cont_token: return LROPoller.from_continuation_token( polling_method=polling_method, continuation_token=cont_token, client=self._client, - deserialization_callback=get_long_running_output + deserialization_callback=get_long_running_output, ) return LROPoller(self._client, raw_result, get_long_running_output, polling_method) - begin_delete_at_tenant_scope.metadata = {'url': "/providers/Microsoft.Resources/deployments/{deploymentName}"} # type: ignore + begin_delete_at_tenant_scope.metadata = {"url": "/providers/Microsoft.Resources/deployments/{deploymentName}"} # type: ignore @distributed_trace - def check_existence_at_tenant_scope( - self, - deployment_name: str, - **kwargs: Any - ) -> bool: + def check_existence_at_tenant_scope(self, deployment_name: str, **kwargs: Any) -> bool: """Checks whether the deployment exists. - :param deployment_name: The name of the deployment. + :param deployment_name: The name of the deployment. Required. :type deployment_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: bool, or the result of cls(response) + :return: bool or the result of cls(response) :rtype: bool - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType[None] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) - api_version = kwargs.pop('api_version', "2019-08-01") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2019-08-01")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[None] - request = build_deployments_check_existence_at_tenant_scope_request( deployment_name=deployment_name, api_version=api_version, - template_url=self.check_existence_at_tenant_scope.metadata['url'], + template_url=self.check_existence_at_tenant_scope.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [204, 404]: @@ -4114,41 +3780,51 @@ def check_existence_at_tenant_scope( return cls(pipeline_response, None, {}) return 200 <= response.status_code <= 299 - check_existence_at_tenant_scope.metadata = {'url': "/providers/Microsoft.Resources/deployments/{deploymentName}"} # type: ignore - + check_existence_at_tenant_scope.metadata = {"url": "/providers/Microsoft.Resources/deployments/{deploymentName}"} # type: ignore def _create_or_update_at_tenant_scope_initial( - self, - deployment_name: str, - parameters: "_models.ScopedDeployment", - **kwargs: Any - ) -> "_models.DeploymentExtended": - cls = kwargs.pop('cls', None) # type: ClsType["_models.DeploymentExtended"] + self, deployment_name: str, parameters: Union[_models.ScopedDeployment, IO], **kwargs: Any + ) -> _models.DeploymentExtended: error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) - api_version = kwargs.pop('api_version', "2019-08-01") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - _json = self._serialize.body(parameters, 'ScopedDeployment') + api_version = kwargs.pop("api_version", _params.pop("api-version", "2019-08-01")) # type: str + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.DeploymentExtended] - request = build_deployments_create_or_update_at_tenant_scope_request_initial( + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(parameters, (IO, bytes)): + _content = parameters + else: + _json = self._serialize.body(parameters, "ScopedDeployment") + + request = build_deployments_create_or_update_at_tenant_scope_request( deployment_name=deployment_name, api_version=api_version, content_type=content_type, json=_json, - template_url=self._create_or_update_at_tenant_scope_initial.metadata['url'], + content=_content, + template_url=self._create_or_update_at_tenant_scope_initial.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200, 201]: @@ -4156,34 +3832,38 @@ def _create_or_update_at_tenant_scope_initial( raise HttpResponseError(response=response, error_format=ARMErrorFormat) if response.status_code == 200: - deserialized = self._deserialize('DeploymentExtended', pipeline_response) + deserialized = self._deserialize("DeploymentExtended", pipeline_response) if response.status_code == 201: - deserialized = self._deserialize('DeploymentExtended', pipeline_response) + deserialized = self._deserialize("DeploymentExtended", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - _create_or_update_at_tenant_scope_initial.metadata = {'url': "/providers/Microsoft.Resources/deployments/{deploymentName}"} # type: ignore + _create_or_update_at_tenant_scope_initial.metadata = {"url": "/providers/Microsoft.Resources/deployments/{deploymentName}"} # type: ignore - - @distributed_trace + @overload def begin_create_or_update_at_tenant_scope( self, deployment_name: str, - parameters: "_models.ScopedDeployment", + parameters: _models.ScopedDeployment, + *, + content_type: str = "application/json", **kwargs: Any - ) -> LROPoller["_models.DeploymentExtended"]: + ) -> LROPoller[_models.DeploymentExtended]: """Deploys resources at tenant scope. You can provide the template and parameters directly in the request or link to JSON files. - :param deployment_name: The name of the deployment. + :param deployment_name: The name of the deployment. Required. :type deployment_name: str - :param parameters: Additional parameters supplied to the operation. + :param parameters: Additional parameters supplied to the operation. Required. :type parameters: ~azure.mgmt.resource.resources.v2019_08_01.models.ScopedDeployment + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str :keyword callable cls: A custom type or function that will be passed the direct response :keyword str continuation_token: A continuation token to restart a poller from a saved state. :keyword polling: By default, your polling method will be ARMPolling. Pass in False for this @@ -4196,108 +3876,171 @@ def begin_create_or_update_at_tenant_scope( cls(response) :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.resource.resources.v2019_08_01.models.DeploymentExtended] - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - api_version = kwargs.pop('api_version', "2019-08-01") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] - polling = kwargs.pop('polling', True) # type: Union[bool, PollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType["_models.DeploymentExtended"] - lro_delay = kwargs.pop( - 'polling_interval', - self._config.polling_interval - ) - cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] + + @overload + def begin_create_or_update_at_tenant_scope( + self, deployment_name: str, parameters: IO, *, content_type: str = "application/json", **kwargs: Any + ) -> LROPoller[_models.DeploymentExtended]: + """Deploys resources at tenant scope. + + You can provide the template and parameters directly in the request or link to JSON files. + + :param deployment_name: The name of the deployment. Required. + :type deployment_name: str + :param parameters: Additional parameters supplied to the operation. Required. + :type parameters: IO + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be ARMPolling. Pass in False for this + operation to not poll, or pass in your own initialized polling object for a personal polling + strategy. + :paramtype polling: bool or ~azure.core.polling.PollingMethod + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of LROPoller that returns either DeploymentExtended or the result of + cls(response) + :rtype: + ~azure.core.polling.LROPoller[~azure.mgmt.resource.resources.v2019_08_01.models.DeploymentExtended] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace + def begin_create_or_update_at_tenant_scope( + self, deployment_name: str, parameters: Union[_models.ScopedDeployment, IO], **kwargs: Any + ) -> LROPoller[_models.DeploymentExtended]: + """Deploys resources at tenant scope. + + You can provide the template and parameters directly in the request or link to JSON files. + + :param deployment_name: The name of the deployment. Required. + :type deployment_name: str + :param parameters: Additional parameters supplied to the operation. Is either a model type or a + IO type. Required. + :type parameters: ~azure.mgmt.resource.resources.v2019_08_01.models.ScopedDeployment or IO + :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. + Default value is None. + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be ARMPolling. Pass in False for this + operation to not poll, or pass in your own initialized polling object for a personal polling + strategy. + :paramtype polling: bool or ~azure.core.polling.PollingMethod + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of LROPoller that returns either DeploymentExtended or the result of + cls(response) + :rtype: + ~azure.core.polling.LROPoller[~azure.mgmt.resource.resources.v2019_08_01.models.DeploymentExtended] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _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", "2019-08-01")) # type: str + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.DeploymentExtended] + polling = kwargs.pop("polling", True) # type: Union[bool, PollingMethod] + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token = kwargs.pop("continuation_token", None) # type: Optional[str] if cont_token is None: - raw_result = self._create_or_update_at_tenant_scope_initial( + raw_result = self._create_or_update_at_tenant_scope_initial( # type: ignore deployment_name=deployment_name, parameters=parameters, api_version=api_version, content_type=content_type, - cls=lambda x,y,z: x, + cls=lambda x, y, z: x, + headers=_headers, + params=_params, **kwargs ) - kwargs.pop('error_map', None) + kwargs.pop("error_map", None) def get_long_running_output(pipeline_response): - response = pipeline_response.http_response - deserialized = self._deserialize('DeploymentExtended', pipeline_response) + deserialized = self._deserialize("DeploymentExtended", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - - if polling is True: polling_method = ARMPolling(lro_delay, **kwargs) - elif polling is False: polling_method = NoPolling() - else: polling_method = polling + if polling is True: + polling_method = cast(PollingMethod, ARMPolling(lro_delay, **kwargs)) # type: PollingMethod + elif polling is False: + polling_method = cast(PollingMethod, NoPolling()) + else: + polling_method = polling if cont_token: return LROPoller.from_continuation_token( polling_method=polling_method, continuation_token=cont_token, client=self._client, - deserialization_callback=get_long_running_output + deserialization_callback=get_long_running_output, ) return LROPoller(self._client, raw_result, get_long_running_output, polling_method) - begin_create_or_update_at_tenant_scope.metadata = {'url': "/providers/Microsoft.Resources/deployments/{deploymentName}"} # type: ignore + begin_create_or_update_at_tenant_scope.metadata = {"url": "/providers/Microsoft.Resources/deployments/{deploymentName}"} # type: ignore @distributed_trace - def get_at_tenant_scope( - self, - deployment_name: str, - **kwargs: Any - ) -> "_models.DeploymentExtended": + def get_at_tenant_scope(self, deployment_name: str, **kwargs: Any) -> _models.DeploymentExtended: """Gets a deployment. - :param deployment_name: The name of the deployment. + :param deployment_name: The name of the deployment. Required. :type deployment_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: DeploymentExtended, or the result of cls(response) + :return: DeploymentExtended or the result of cls(response) :rtype: ~azure.mgmt.resource.resources.v2019_08_01.models.DeploymentExtended - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.DeploymentExtended"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + 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', "2019-08-01") # type: str + api_version = kwargs.pop("api_version", _params.pop("api-version", "2019-08-01")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[_models.DeploymentExtended] - request = build_deployments_get_at_tenant_scope_request( deployment_name=deployment_name, api_version=api_version, - template_url=self.get_at_tenant_scope.metadata['url'], + template_url=self.get_at_tenant_scope.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) - deserialized = self._deserialize('DeploymentExtended', pipeline_response) + deserialized = self._deserialize("DeploymentExtended", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - get_at_tenant_scope.metadata = {'url': "/providers/Microsoft.Resources/deployments/{deploymentName}"} # type: ignore - + get_at_tenant_scope.metadata = {"url": "/providers/Microsoft.Resources/deployments/{deploymentName}"} # type: ignore @distributed_trace def cancel_at_tenant_scope( # pylint: disable=inconsistent-return-statements - self, - deployment_name: str, - **kwargs: Any + self, deployment_name: str, **kwargs: Any ) -> None: """Cancels a currently running template deployment. @@ -4306,35 +4049,41 @@ def cancel_at_tenant_scope( # pylint: disable=inconsistent-return-statements deployment stops the currently running template deployment and leaves the resources partially deployed. - :param deployment_name: The name of the deployment. + :param deployment_name: The name of the deployment. Required. :type deployment_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: None, or the result of cls(response) + :return: None or the result of cls(response) :rtype: None - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType[None] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + 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', "2019-08-01") # type: str + api_version = kwargs.pop("api_version", _params.pop("api-version", "2019-08-01")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[None] - request = build_deployments_cancel_at_tenant_scope_request( deployment_name=deployment_name, api_version=api_version, - template_url=self.cancel_at_tenant_scope.metadata['url'], + template_url=self.cancel_at_tenant_scope.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [204]: @@ -4344,54 +4093,112 @@ def cancel_at_tenant_scope( # pylint: disable=inconsistent-return-statements if cls: return cls(pipeline_response, None, {}) - cancel_at_tenant_scope.metadata = {'url': "/providers/Microsoft.Resources/deployments/{deploymentName}/cancel"} # type: ignore - + cancel_at_tenant_scope.metadata = {"url": "/providers/Microsoft.Resources/deployments/{deploymentName}/cancel"} # type: ignore - @distributed_trace + @overload def validate_at_tenant_scope( self, deployment_name: str, - parameters: "_models.ScopedDeployment", + parameters: _models.ScopedDeployment, + *, + content_type: str = "application/json", **kwargs: Any - ) -> "_models.DeploymentValidateResult": + ) -> _models.DeploymentValidateResult: """Validates whether the specified template is syntactically correct and will be accepted by Azure Resource Manager.. - :param deployment_name: The name of the deployment. + :param deployment_name: The name of the deployment. Required. :type deployment_name: str - :param parameters: Parameters to validate. + :param parameters: Parameters to validate. Required. :type parameters: ~azure.mgmt.resource.resources.v2019_08_01.models.ScopedDeployment + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: DeploymentValidateResult or the result of cls(response) + :rtype: ~azure.mgmt.resource.resources.v2019_08_01.models.DeploymentValidateResult + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + def validate_at_tenant_scope( + self, deployment_name: str, parameters: IO, *, content_type: str = "application/json", **kwargs: Any + ) -> _models.DeploymentValidateResult: + """Validates whether the specified template is syntactically correct and will be accepted by Azure + Resource Manager.. + + :param deployment_name: The name of the deployment. Required. + :type deployment_name: str + :param parameters: Parameters to validate. Required. + :type parameters: IO + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: DeploymentValidateResult, or the result of cls(response) + :return: DeploymentValidateResult or the result of cls(response) :rtype: ~azure.mgmt.resource.resources.v2019_08_01.models.DeploymentValidateResult - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace + def validate_at_tenant_scope( + self, deployment_name: str, parameters: Union[_models.ScopedDeployment, IO], **kwargs: Any + ) -> _models.DeploymentValidateResult: + """Validates whether the specified template is syntactically correct and will be accepted by Azure + Resource Manager.. + + :param deployment_name: The name of the deployment. Required. + :type deployment_name: str + :param parameters: Parameters to validate. Is either a model type or a IO type. Required. + :type parameters: ~azure.mgmt.resource.resources.v2019_08_01.models.ScopedDeployment or IO + :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. + Default value is None. + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: DeploymentValidateResult or the result of cls(response) + :rtype: ~azure.mgmt.resource.resources.v2019_08_01.models.DeploymentValidateResult + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.DeploymentValidateResult"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', "2019-08-01") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + api_version = kwargs.pop("api_version", _params.pop("api-version", "2019-08-01")) # type: str + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.DeploymentValidateResult] - _json = self._serialize.body(parameters, 'ScopedDeployment') + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(parameters, (IO, bytes)): + _content = parameters + else: + _json = self._serialize.body(parameters, "ScopedDeployment") request = build_deployments_validate_at_tenant_scope_request( deployment_name=deployment_name, api_version=api_version, content_type=content_type, json=_json, - template_url=self.validate_at_tenant_scope.metadata['url'], + content=_content, + template_url=self.validate_at_tenant_scope.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200, 400]: @@ -4399,79 +4206,76 @@ def validate_at_tenant_scope( raise HttpResponseError(response=response, error_format=ARMErrorFormat) if response.status_code == 200: - deserialized = self._deserialize('DeploymentValidateResult', pipeline_response) + deserialized = self._deserialize("DeploymentValidateResult", pipeline_response) if response.status_code == 400: - deserialized = self._deserialize('DeploymentValidateResult', pipeline_response) + deserialized = self._deserialize("DeploymentValidateResult", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - validate_at_tenant_scope.metadata = {'url': "/providers/Microsoft.Resources/deployments/{deploymentName}/validate"} # type: ignore - + validate_at_tenant_scope.metadata = {"url": "/providers/Microsoft.Resources/deployments/{deploymentName}/validate"} # type: ignore @distributed_trace - def export_template_at_tenant_scope( - self, - deployment_name: str, - **kwargs: Any - ) -> "_models.DeploymentExportResult": + def export_template_at_tenant_scope(self, deployment_name: str, **kwargs: Any) -> _models.DeploymentExportResult: """Exports the template used for specified deployment. - :param deployment_name: The name of the deployment. + :param deployment_name: The name of the deployment. Required. :type deployment_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: DeploymentExportResult, or the result of cls(response) + :return: DeploymentExportResult or the result of cls(response) :rtype: ~azure.mgmt.resource.resources.v2019_08_01.models.DeploymentExportResult - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.DeploymentExportResult"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + 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', "2019-08-01") # type: str + api_version = kwargs.pop("api_version", _params.pop("api-version", "2019-08-01")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[_models.DeploymentExportResult] - request = build_deployments_export_template_at_tenant_scope_request( deployment_name=deployment_name, api_version=api_version, - template_url=self.export_template_at_tenant_scope.metadata['url'], + template_url=self.export_template_at_tenant_scope.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) - deserialized = self._deserialize('DeploymentExportResult', pipeline_response) + deserialized = self._deserialize("DeploymentExportResult", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - export_template_at_tenant_scope.metadata = {'url': "/providers/Microsoft.Resources/deployments/{deploymentName}/exportTemplate"} # type: ignore - + export_template_at_tenant_scope.metadata = {"url": "/providers/Microsoft.Resources/deployments/{deploymentName}/exportTemplate"} # type: ignore @distributed_trace def list_at_tenant_scope( - self, - filter: Optional[str] = None, - top: Optional[int] = None, - **kwargs: Any - ) -> Iterable["_models.DeploymentListResult"]: + self, filter: Optional[str] = None, top: Optional[int] = None, **kwargs: Any + ) -> Iterable["_models.DeploymentExtended"]: """Get all the deployments at the tenant scope. :param filter: The filter to apply on the operation. For example, you can use @@ -4481,38 +4285,47 @@ def list_at_tenant_scope( value is None. :type top: int :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either DeploymentListResult or the result of - cls(response) + :return: An iterator like instance of either DeploymentExtended or the result of cls(response) :rtype: - ~azure.core.paging.ItemPaged[~azure.mgmt.resource.resources.v2019_08_01.models.DeploymentListResult] - :raises: ~azure.core.exceptions.HttpResponseError + ~azure.core.paging.ItemPaged[~azure.mgmt.resource.resources.v2019_08_01.models.DeploymentExtended] + :raises ~azure.core.exceptions.HttpResponseError: """ - api_version = kwargs.pop('api_version', "2019-08-01") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2019-08-01")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[_models.DeploymentListResult] - cls = kwargs.pop('cls', None) # type: ClsType["_models.DeploymentListResult"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) + def prepare_request(next_link=None): if not next_link: - + request = build_deployments_list_at_tenant_scope_request( - api_version=api_version, filter=filter, top=top, - template_url=self.list_at_tenant_scope.metadata['url'], + api_version=api_version, + template_url=self.list_at_tenant_scope.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore else: - - request = build_deployments_list_at_tenant_scope_request( - template_url=next_link, - ) + # make call to next link with the client's api-version + _parsed_next_link = urlparse(next_link) + _next_request_params = case_insensitive_dict(parse_qs(_parsed_next_link.query)) + _next_request_params["api-version"] = self._config.api_version + request = HttpRequest("GET", urljoin(next_link, _parsed_next_link.path), params=_next_request_params) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore request.method = "GET" return request @@ -4526,10 +4339,8 @@ def extract_data(pipeline_response): def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) response = pipeline_response.http_response @@ -4539,41 +4350,42 @@ def get_next(next_link=None): return pipeline_response + return ItemPaged(get_next, extract_data) - return ItemPaged( - get_next, extract_data - ) - list_at_tenant_scope.metadata = {'url': "/providers/Microsoft.Resources/deployments/"} # type: ignore + list_at_tenant_scope.metadata = {"url": "/providers/Microsoft.Resources/deployments/"} # type: ignore def _delete_at_management_group_scope_initial( # pylint: disable=inconsistent-return-statements - self, - group_id: str, - deployment_name: str, - **kwargs: Any + self, group_id: str, deployment_name: str, **kwargs: Any ) -> None: - cls = kwargs.pop('cls', None) # type: ClsType[None] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) - api_version = kwargs.pop('api_version', "2019-08-01") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - request = build_deployments_delete_at_management_group_scope_request_initial( + api_version = kwargs.pop("api_version", _params.pop("api-version", "2019-08-01")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[None] + + request = build_deployments_delete_at_management_group_scope_request( group_id=group_id, deployment_name=deployment_name, api_version=api_version, - template_url=self._delete_at_management_group_scope_initial.metadata['url'], + template_url=self._delete_at_management_group_scope_initial.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [202, 204]: @@ -4583,15 +4395,11 @@ def _delete_at_management_group_scope_initial( # pylint: disable=inconsistent-r if cls: return cls(pipeline_response, None, {}) - _delete_at_management_group_scope_initial.metadata = {'url': "/providers/Microsoft.Management/managementGroups/{groupId}/providers/Microsoft.Resources/deployments/{deploymentName}"} # type: ignore - + _delete_at_management_group_scope_initial.metadata = {"url": "/providers/Microsoft.Management/managementGroups/{groupId}/providers/Microsoft.Resources/deployments/{deploymentName}"} # type: ignore @distributed_trace - def begin_delete_at_management_group_scope( # pylint: disable=inconsistent-return-statements - self, - group_id: str, - deployment_name: str, - **kwargs: Any + def begin_delete_at_management_group_scope( + self, group_id: str, deployment_name: str, **kwargs: Any ) -> LROPoller[None]: """Deletes a deployment from the deployment history. @@ -4603,9 +4411,9 @@ def begin_delete_at_management_group_scope( # pylint: disable=inconsistent-retu process finishes, the URI in the Location header returns a status of 204 on success. If the asynchronous request failed, the URI in the Location header returns an error-level status code. - :param group_id: The management group ID. + :param group_id: The management group ID. Required. :type group_id: str - :param deployment_name: The name of the deployment. + :param deployment_name: The name of the deployment. Required. :type deployment_name: str :keyword callable cls: A custom type or function that will be passed the direct response :keyword str continuation_token: A continuation token to restart a poller from a saved state. @@ -4617,86 +4425,91 @@ def begin_delete_at_management_group_scope( # pylint: disable=inconsistent-retu Retry-After header is present. :return: An instance of LROPoller that returns either None or the result of cls(response) :rtype: ~azure.core.polling.LROPoller[None] - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - api_version = kwargs.pop('api_version', "2019-08-01") # type: str - polling = kwargs.pop('polling', True) # type: Union[bool, PollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType[None] - lro_delay = kwargs.pop( - 'polling_interval', - self._config.polling_interval - ) - cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2019-08-01")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[None] + polling = kwargs.pop("polling", True) # type: Union[bool, PollingMethod] + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token = kwargs.pop("continuation_token", None) # type: Optional[str] if cont_token is None: - raw_result = self._delete_at_management_group_scope_initial( + raw_result = self._delete_at_management_group_scope_initial( # type: ignore group_id=group_id, deployment_name=deployment_name, api_version=api_version, - cls=lambda x,y,z: x, + cls=lambda x, y, z: x, + headers=_headers, + params=_params, **kwargs ) - kwargs.pop('error_map', None) + kwargs.pop("error_map", None) - def get_long_running_output(pipeline_response): + def get_long_running_output(pipeline_response): # pylint: disable=inconsistent-return-statements if cls: return cls(pipeline_response, None, {}) - - if polling is True: polling_method = ARMPolling(lro_delay, **kwargs) - elif polling is False: polling_method = NoPolling() - else: polling_method = polling + if polling is True: + polling_method = cast(PollingMethod, ARMPolling(lro_delay, **kwargs)) # type: PollingMethod + elif polling is False: + polling_method = cast(PollingMethod, NoPolling()) + else: + polling_method = polling if cont_token: return LROPoller.from_continuation_token( polling_method=polling_method, continuation_token=cont_token, client=self._client, - deserialization_callback=get_long_running_output + deserialization_callback=get_long_running_output, ) return LROPoller(self._client, raw_result, get_long_running_output, polling_method) - begin_delete_at_management_group_scope.metadata = {'url': "/providers/Microsoft.Management/managementGroups/{groupId}/providers/Microsoft.Resources/deployments/{deploymentName}"} # type: ignore + begin_delete_at_management_group_scope.metadata = {"url": "/providers/Microsoft.Management/managementGroups/{groupId}/providers/Microsoft.Resources/deployments/{deploymentName}"} # type: ignore @distributed_trace - def check_existence_at_management_group_scope( - self, - group_id: str, - deployment_name: str, - **kwargs: Any - ) -> bool: + def check_existence_at_management_group_scope(self, group_id: str, deployment_name: str, **kwargs: Any) -> bool: """Checks whether the deployment exists. - :param group_id: The management group ID. + :param group_id: The management group ID. Required. :type group_id: str - :param deployment_name: The name of the deployment. + :param deployment_name: The name of the deployment. Required. :type deployment_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: bool, or the result of cls(response) + :return: bool or the result of cls(response) :rtype: bool - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType[None] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + 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', "2019-08-01") # type: str + api_version = kwargs.pop("api_version", _params.pop("api-version", "2019-08-01")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[None] - request = build_deployments_check_existence_at_management_group_scope_request( group_id=group_id, deployment_name=deployment_name, api_version=api_version, - template_url=self.check_existence_at_management_group_scope.metadata['url'], + template_url=self.check_existence_at_management_group_scope.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [204, 404]: @@ -4707,43 +4520,52 @@ def check_existence_at_management_group_scope( return cls(pipeline_response, None, {}) return 200 <= response.status_code <= 299 - check_existence_at_management_group_scope.metadata = {'url': "/providers/Microsoft.Management/managementGroups/{groupId}/providers/Microsoft.Resources/deployments/{deploymentName}"} # type: ignore - + check_existence_at_management_group_scope.metadata = {"url": "/providers/Microsoft.Management/managementGroups/{groupId}/providers/Microsoft.Resources/deployments/{deploymentName}"} # type: ignore def _create_or_update_at_management_group_scope_initial( - self, - group_id: str, - deployment_name: str, - parameters: "_models.ScopedDeployment", - **kwargs: Any - ) -> "_models.DeploymentExtended": - cls = kwargs.pop('cls', None) # type: ClsType["_models.DeploymentExtended"] + self, group_id: str, deployment_name: str, parameters: Union[_models.ScopedDeployment, IO], **kwargs: Any + ) -> _models.DeploymentExtended: error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) - api_version = kwargs.pop('api_version', "2019-08-01") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - _json = self._serialize.body(parameters, 'ScopedDeployment') + api_version = kwargs.pop("api_version", _params.pop("api-version", "2019-08-01")) # type: str + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.DeploymentExtended] - request = build_deployments_create_or_update_at_management_group_scope_request_initial( + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(parameters, (IO, bytes)): + _content = parameters + else: + _json = self._serialize.body(parameters, "ScopedDeployment") + + request = build_deployments_create_or_update_at_management_group_scope_request( group_id=group_id, deployment_name=deployment_name, api_version=api_version, content_type=content_type, json=_json, - template_url=self._create_or_update_at_management_group_scope_initial.metadata['url'], + content=_content, + template_url=self._create_or_update_at_management_group_scope_initial.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200, 201]: @@ -4751,37 +4573,41 @@ def _create_or_update_at_management_group_scope_initial( raise HttpResponseError(response=response, error_format=ARMErrorFormat) if response.status_code == 200: - deserialized = self._deserialize('DeploymentExtended', pipeline_response) + deserialized = self._deserialize("DeploymentExtended", pipeline_response) if response.status_code == 201: - deserialized = self._deserialize('DeploymentExtended', pipeline_response) + deserialized = self._deserialize("DeploymentExtended", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - _create_or_update_at_management_group_scope_initial.metadata = {'url': "/providers/Microsoft.Management/managementGroups/{groupId}/providers/Microsoft.Resources/deployments/{deploymentName}"} # type: ignore + _create_or_update_at_management_group_scope_initial.metadata = {"url": "/providers/Microsoft.Management/managementGroups/{groupId}/providers/Microsoft.Resources/deployments/{deploymentName}"} # type: ignore - - @distributed_trace + @overload def begin_create_or_update_at_management_group_scope( self, group_id: str, deployment_name: str, - parameters: "_models.ScopedDeployment", + parameters: _models.ScopedDeployment, + *, + content_type: str = "application/json", **kwargs: Any - ) -> LROPoller["_models.DeploymentExtended"]: + ) -> LROPoller[_models.DeploymentExtended]: """Deploys resources at management group scope. You can provide the template and parameters directly in the request or link to JSON files. - :param group_id: The management group ID. + :param group_id: The management group ID. Required. :type group_id: str - :param deployment_name: The name of the deployment. + :param deployment_name: The name of the deployment. Required. :type deployment_name: str - :param parameters: Additional parameters supplied to the operation. + :param parameters: Additional parameters supplied to the operation. Required. :type parameters: ~azure.mgmt.resource.resources.v2019_08_01.models.ScopedDeployment + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str :keyword callable cls: A custom type or function that will be passed the direct response :keyword str continuation_token: A continuation token to restart a poller from a saved state. :keyword polling: By default, your polling method will be ARMPolling. Pass in False for this @@ -4794,114 +4620,187 @@ def begin_create_or_update_at_management_group_scope( cls(response) :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.resource.resources.v2019_08_01.models.DeploymentExtended] - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - api_version = kwargs.pop('api_version', "2019-08-01") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] - polling = kwargs.pop('polling', True) # type: Union[bool, PollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType["_models.DeploymentExtended"] - lro_delay = kwargs.pop( - 'polling_interval', - self._config.polling_interval - ) - cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] + + @overload + def begin_create_or_update_at_management_group_scope( + self, + group_id: str, + deployment_name: str, + parameters: IO, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> LROPoller[_models.DeploymentExtended]: + """Deploys resources at management group scope. + + You can provide the template and parameters directly in the request or link to JSON files. + + :param group_id: The management group ID. Required. + :type group_id: str + :param deployment_name: The name of the deployment. Required. + :type deployment_name: str + :param parameters: Additional parameters supplied to the operation. Required. + :type parameters: IO + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be ARMPolling. Pass in False for this + operation to not poll, or pass in your own initialized polling object for a personal polling + strategy. + :paramtype polling: bool or ~azure.core.polling.PollingMethod + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of LROPoller that returns either DeploymentExtended or the result of + cls(response) + :rtype: + ~azure.core.polling.LROPoller[~azure.mgmt.resource.resources.v2019_08_01.models.DeploymentExtended] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace + def begin_create_or_update_at_management_group_scope( + self, group_id: str, deployment_name: str, parameters: Union[_models.ScopedDeployment, IO], **kwargs: Any + ) -> LROPoller[_models.DeploymentExtended]: + """Deploys resources at management group scope. + + You can provide the template and parameters directly in the request or link to JSON files. + + :param group_id: The management group ID. Required. + :type group_id: str + :param deployment_name: The name of the deployment. Required. + :type deployment_name: str + :param parameters: Additional parameters supplied to the operation. Is either a model type or a + IO type. Required. + :type parameters: ~azure.mgmt.resource.resources.v2019_08_01.models.ScopedDeployment or IO + :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. + Default value is None. + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be ARMPolling. Pass in False for this + operation to not poll, or pass in your own initialized polling object for a personal polling + strategy. + :paramtype polling: bool or ~azure.core.polling.PollingMethod + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of LROPoller that returns either DeploymentExtended or the result of + cls(response) + :rtype: + ~azure.core.polling.LROPoller[~azure.mgmt.resource.resources.v2019_08_01.models.DeploymentExtended] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _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", "2019-08-01")) # type: str + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.DeploymentExtended] + polling = kwargs.pop("polling", True) # type: Union[bool, PollingMethod] + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token = kwargs.pop("continuation_token", None) # type: Optional[str] if cont_token is None: - raw_result = self._create_or_update_at_management_group_scope_initial( + raw_result = self._create_or_update_at_management_group_scope_initial( # type: ignore group_id=group_id, deployment_name=deployment_name, parameters=parameters, api_version=api_version, content_type=content_type, - cls=lambda x,y,z: x, + cls=lambda x, y, z: x, + headers=_headers, + params=_params, **kwargs ) - kwargs.pop('error_map', None) + kwargs.pop("error_map", None) def get_long_running_output(pipeline_response): - response = pipeline_response.http_response - deserialized = self._deserialize('DeploymentExtended', pipeline_response) + deserialized = self._deserialize("DeploymentExtended", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - - if polling is True: polling_method = ARMPolling(lro_delay, **kwargs) - elif polling is False: polling_method = NoPolling() - else: polling_method = polling + if polling is True: + polling_method = cast(PollingMethod, ARMPolling(lro_delay, **kwargs)) # type: PollingMethod + elif polling is False: + polling_method = cast(PollingMethod, NoPolling()) + else: + polling_method = polling if cont_token: return LROPoller.from_continuation_token( polling_method=polling_method, continuation_token=cont_token, client=self._client, - deserialization_callback=get_long_running_output + deserialization_callback=get_long_running_output, ) return LROPoller(self._client, raw_result, get_long_running_output, polling_method) - begin_create_or_update_at_management_group_scope.metadata = {'url': "/providers/Microsoft.Management/managementGroups/{groupId}/providers/Microsoft.Resources/deployments/{deploymentName}"} # type: ignore + begin_create_or_update_at_management_group_scope.metadata = {"url": "/providers/Microsoft.Management/managementGroups/{groupId}/providers/Microsoft.Resources/deployments/{deploymentName}"} # type: ignore @distributed_trace def get_at_management_group_scope( - self, - group_id: str, - deployment_name: str, - **kwargs: Any - ) -> "_models.DeploymentExtended": + self, group_id: str, deployment_name: str, **kwargs: Any + ) -> _models.DeploymentExtended: """Gets a deployment. - :param group_id: The management group ID. + :param group_id: The management group ID. Required. :type group_id: str - :param deployment_name: The name of the deployment. + :param deployment_name: The name of the deployment. Required. :type deployment_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: DeploymentExtended, or the result of cls(response) + :return: DeploymentExtended or the result of cls(response) :rtype: ~azure.mgmt.resource.resources.v2019_08_01.models.DeploymentExtended - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.DeploymentExtended"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + 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', "2019-08-01") # type: str + api_version = kwargs.pop("api_version", _params.pop("api-version", "2019-08-01")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[_models.DeploymentExtended] - request = build_deployments_get_at_management_group_scope_request( group_id=group_id, deployment_name=deployment_name, api_version=api_version, - template_url=self.get_at_management_group_scope.metadata['url'], + template_url=self.get_at_management_group_scope.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) - deserialized = self._deserialize('DeploymentExtended', pipeline_response) + deserialized = self._deserialize("DeploymentExtended", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - get_at_management_group_scope.metadata = {'url': "/providers/Microsoft.Management/managementGroups/{groupId}/providers/Microsoft.Resources/deployments/{deploymentName}"} # type: ignore - + get_at_management_group_scope.metadata = {"url": "/providers/Microsoft.Management/managementGroups/{groupId}/providers/Microsoft.Resources/deployments/{deploymentName}"} # type: ignore @distributed_trace def cancel_at_management_group_scope( # pylint: disable=inconsistent-return-statements - self, - group_id: str, - deployment_name: str, - **kwargs: Any + self, group_id: str, deployment_name: str, **kwargs: Any ) -> None: """Cancels a currently running template deployment. @@ -4910,38 +4809,44 @@ def cancel_at_management_group_scope( # pylint: disable=inconsistent-return-sta deployment stops the currently running template deployment and leaves the resources partially deployed. - :param group_id: The management group ID. + :param group_id: The management group ID. Required. :type group_id: str - :param deployment_name: The name of the deployment. + :param deployment_name: The name of the deployment. Required. :type deployment_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: None, or the result of cls(response) + :return: None or the result of cls(response) :rtype: None - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType[None] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) - api_version = kwargs.pop('api_version', "2019-08-01") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2019-08-01")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[None] - request = build_deployments_cancel_at_management_group_scope_request( group_id=group_id, deployment_name=deployment_name, api_version=api_version, - template_url=self.cancel_at_management_group_scope.metadata['url'], + template_url=self.cancel_at_management_group_scope.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [204]: @@ -4951,41 +4856,107 @@ def cancel_at_management_group_scope( # pylint: disable=inconsistent-return-sta if cls: return cls(pipeline_response, None, {}) - cancel_at_management_group_scope.metadata = {'url': "/providers/Microsoft.Management/managementGroups/{groupId}/providers/Microsoft.Resources/deployments/{deploymentName}/cancel"} # type: ignore + cancel_at_management_group_scope.metadata = {"url": "/providers/Microsoft.Management/managementGroups/{groupId}/providers/Microsoft.Resources/deployments/{deploymentName}/cancel"} # type: ignore - - @distributed_trace + @overload def validate_at_management_group_scope( self, group_id: str, deployment_name: str, - parameters: "_models.ScopedDeployment", + parameters: _models.ScopedDeployment, + *, + content_type: str = "application/json", **kwargs: Any - ) -> "_models.DeploymentValidateResult": + ) -> _models.DeploymentValidateResult: """Validates whether the specified template is syntactically correct and will be accepted by Azure Resource Manager.. - :param group_id: The management group ID. + :param group_id: The management group ID. Required. :type group_id: str - :param deployment_name: The name of the deployment. + :param deployment_name: The name of the deployment. Required. :type deployment_name: str - :param parameters: Parameters to validate. + :param parameters: Parameters to validate. Required. :type parameters: ~azure.mgmt.resource.resources.v2019_08_01.models.ScopedDeployment + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: DeploymentValidateResult or the result of cls(response) + :rtype: ~azure.mgmt.resource.resources.v2019_08_01.models.DeploymentValidateResult + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + def validate_at_management_group_scope( + self, + group_id: str, + deployment_name: str, + parameters: IO, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.DeploymentValidateResult: + """Validates whether the specified template is syntactically correct and will be accepted by Azure + Resource Manager.. + + :param group_id: The management group ID. Required. + :type group_id: str + :param deployment_name: The name of the deployment. Required. + :type deployment_name: str + :param parameters: Parameters to validate. Required. + :type parameters: IO + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: DeploymentValidateResult, or the result of cls(response) + :return: DeploymentValidateResult or the result of cls(response) :rtype: ~azure.mgmt.resource.resources.v2019_08_01.models.DeploymentValidateResult - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace + def validate_at_management_group_scope( + self, group_id: str, deployment_name: str, parameters: Union[_models.ScopedDeployment, IO], **kwargs: Any + ) -> _models.DeploymentValidateResult: + """Validates whether the specified template is syntactically correct and will be accepted by Azure + Resource Manager.. + + :param group_id: The management group ID. Required. + :type group_id: str + :param deployment_name: The name of the deployment. Required. + :type deployment_name: str + :param parameters: Parameters to validate. Is either a model type or a IO type. Required. + :type parameters: ~azure.mgmt.resource.resources.v2019_08_01.models.ScopedDeployment or IO + :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. + Default value is None. + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: DeploymentValidateResult or the result of cls(response) + :rtype: ~azure.mgmt.resource.resources.v2019_08_01.models.DeploymentValidateResult + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.DeploymentValidateResult"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) - api_version = kwargs.pop('api_version', "2019-08-01") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - _json = self._serialize.body(parameters, 'ScopedDeployment') + api_version = kwargs.pop("api_version", _params.pop("api-version", "2019-08-01")) # type: str + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.DeploymentValidateResult] + + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(parameters, (IO, bytes)): + _content = parameters + else: + _json = self._serialize.body(parameters, "ScopedDeployment") request = build_deployments_validate_at_management_group_scope_request( group_id=group_id, @@ -4993,16 +4964,18 @@ def validate_at_management_group_scope( api_version=api_version, content_type=content_type, json=_json, - template_url=self.validate_at_management_group_scope.metadata['url'], + content=_content, + template_url=self.validate_at_management_group_scope.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200, 400]: @@ -5010,87 +4983,84 @@ def validate_at_management_group_scope( raise HttpResponseError(response=response, error_format=ARMErrorFormat) if response.status_code == 200: - deserialized = self._deserialize('DeploymentValidateResult', pipeline_response) + deserialized = self._deserialize("DeploymentValidateResult", pipeline_response) if response.status_code == 400: - deserialized = self._deserialize('DeploymentValidateResult', pipeline_response) + deserialized = self._deserialize("DeploymentValidateResult", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - validate_at_management_group_scope.metadata = {'url': "/providers/Microsoft.Management/managementGroups/{groupId}/providers/Microsoft.Resources/deployments/{deploymentName}/validate"} # type: ignore - + validate_at_management_group_scope.metadata = {"url": "/providers/Microsoft.Management/managementGroups/{groupId}/providers/Microsoft.Resources/deployments/{deploymentName}/validate"} # type: ignore @distributed_trace def export_template_at_management_group_scope( - self, - group_id: str, - deployment_name: str, - **kwargs: Any - ) -> "_models.DeploymentExportResult": + self, group_id: str, deployment_name: str, **kwargs: Any + ) -> _models.DeploymentExportResult: """Exports the template used for specified deployment. - :param group_id: The management group ID. + :param group_id: The management group ID. Required. :type group_id: str - :param deployment_name: The name of the deployment. + :param deployment_name: The name of the deployment. Required. :type deployment_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: DeploymentExportResult, or the result of cls(response) + :return: DeploymentExportResult or the result of cls(response) :rtype: ~azure.mgmt.resource.resources.v2019_08_01.models.DeploymentExportResult - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.DeploymentExportResult"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + 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', "2019-08-01") # type: str + api_version = kwargs.pop("api_version", _params.pop("api-version", "2019-08-01")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[_models.DeploymentExportResult] - request = build_deployments_export_template_at_management_group_scope_request( group_id=group_id, deployment_name=deployment_name, api_version=api_version, - template_url=self.export_template_at_management_group_scope.metadata['url'], + template_url=self.export_template_at_management_group_scope.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) - deserialized = self._deserialize('DeploymentExportResult', pipeline_response) + deserialized = self._deserialize("DeploymentExportResult", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - export_template_at_management_group_scope.metadata = {'url': "/providers/Microsoft.Management/managementGroups/{groupId}/providers/Microsoft.Resources/deployments/{deploymentName}/exportTemplate"} # type: ignore - + export_template_at_management_group_scope.metadata = {"url": "/providers/Microsoft.Management/managementGroups/{groupId}/providers/Microsoft.Resources/deployments/{deploymentName}/exportTemplate"} # type: ignore @distributed_trace def list_at_management_group_scope( - self, - group_id: str, - filter: Optional[str] = None, - top: Optional[int] = None, - **kwargs: Any - ) -> Iterable["_models.DeploymentListResult"]: + self, group_id: str, filter: Optional[str] = None, top: Optional[int] = None, **kwargs: Any + ) -> Iterable["_models.DeploymentExtended"]: """Get all the deployments for a management group. - :param group_id: The management group ID. + :param group_id: The management group ID. Required. :type group_id: str :param filter: The filter to apply on the operation. For example, you can use $filter=provisioningState eq '{state}'. Default value is None. @@ -5099,40 +5069,48 @@ def list_at_management_group_scope( value is None. :type top: int :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either DeploymentListResult or the result of - cls(response) + :return: An iterator like instance of either DeploymentExtended or the result of cls(response) :rtype: - ~azure.core.paging.ItemPaged[~azure.mgmt.resource.resources.v2019_08_01.models.DeploymentListResult] - :raises: ~azure.core.exceptions.HttpResponseError + ~azure.core.paging.ItemPaged[~azure.mgmt.resource.resources.v2019_08_01.models.DeploymentExtended] + :raises ~azure.core.exceptions.HttpResponseError: """ - api_version = kwargs.pop('api_version', "2019-08-01") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2019-08-01")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[_models.DeploymentListResult] - cls = kwargs.pop('cls', None) # type: ClsType["_models.DeploymentListResult"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) + def prepare_request(next_link=None): if not next_link: - + request = build_deployments_list_at_management_group_scope_request( group_id=group_id, - api_version=api_version, filter=filter, top=top, - template_url=self.list_at_management_group_scope.metadata['url'], + api_version=api_version, + template_url=self.list_at_management_group_scope.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore else: - - request = build_deployments_list_at_management_group_scope_request( - group_id=group_id, - template_url=next_link, - ) + # make call to next link with the client's api-version + _parsed_next_link = urlparse(next_link) + _next_request_params = case_insensitive_dict(parse_qs(_parsed_next_link.query)) + _next_request_params["api-version"] = self._config.api_version + request = HttpRequest("GET", urljoin(next_link, _parsed_next_link.path), params=_next_request_params) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore request.method = "GET" return request @@ -5146,10 +5124,8 @@ def extract_data(pipeline_response): def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) response = pipeline_response.http_response @@ -5159,40 +5135,42 @@ def get_next(next_link=None): return pipeline_response + return ItemPaged(get_next, extract_data) - return ItemPaged( - get_next, extract_data - ) - list_at_management_group_scope.metadata = {'url': "/providers/Microsoft.Management/managementGroups/{groupId}/providers/Microsoft.Resources/deployments/"} # type: ignore + list_at_management_group_scope.metadata = {"url": "/providers/Microsoft.Management/managementGroups/{groupId}/providers/Microsoft.Resources/deployments/"} # type: ignore def _delete_at_subscription_scope_initial( # pylint: disable=inconsistent-return-statements - self, - deployment_name: str, - **kwargs: Any + self, deployment_name: str, **kwargs: Any ) -> None: - cls = kwargs.pop('cls', None) # type: ClsType[None] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + 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', "2019-08-01") # type: str + api_version = kwargs.pop("api_version", _params.pop("api-version", "2019-08-01")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[None] - - request = build_deployments_delete_at_subscription_scope_request_initial( + request = build_deployments_delete_at_subscription_scope_request( deployment_name=deployment_name, subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self._delete_at_subscription_scope_initial.metadata['url'], + template_url=self._delete_at_subscription_scope_initial.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [202, 204]: @@ -5202,15 +5180,10 @@ def _delete_at_subscription_scope_initial( # pylint: disable=inconsistent-retur if cls: return cls(pipeline_response, None, {}) - _delete_at_subscription_scope_initial.metadata = {'url': "/subscriptions/{subscriptionId}/providers/Microsoft.Resources/deployments/{deploymentName}"} # type: ignore - + _delete_at_subscription_scope_initial.metadata = {"url": "/subscriptions/{subscriptionId}/providers/Microsoft.Resources/deployments/{deploymentName}"} # type: ignore @distributed_trace - def begin_delete_at_subscription_scope( # pylint: disable=inconsistent-return-statements - self, - deployment_name: str, - **kwargs: Any - ) -> LROPoller[None]: + def begin_delete_at_subscription_scope(self, deployment_name: str, **kwargs: Any) -> LROPoller[None]: """Deletes a deployment from the deployment history. A template deployment that is currently running cannot be deleted. Deleting a template @@ -5221,7 +5194,7 @@ def begin_delete_at_subscription_scope( # pylint: disable=inconsistent-return-s process finishes, the URI in the Location header returns a status of 204 on success. If the asynchronous request failed, the URI in the Location header returns an error-level status code. - :param deployment_name: The name of the deployment. + :param deployment_name: The name of the deployment. Required. :type deployment_name: str :keyword callable cls: A custom type or function that will be passed the direct response :keyword str continuation_token: A continuation token to restart a poller from a saved state. @@ -5233,82 +5206,88 @@ def begin_delete_at_subscription_scope( # pylint: disable=inconsistent-return-s Retry-After header is present. :return: An instance of LROPoller that returns either None or the result of cls(response) :rtype: ~azure.core.polling.LROPoller[None] - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - api_version = kwargs.pop('api_version', "2019-08-01") # type: str - polling = kwargs.pop('polling', True) # type: Union[bool, PollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType[None] - lro_delay = kwargs.pop( - 'polling_interval', - self._config.polling_interval - ) - cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2019-08-01")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[None] + polling = kwargs.pop("polling", True) # type: Union[bool, PollingMethod] + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token = kwargs.pop("continuation_token", None) # type: Optional[str] if cont_token is None: - raw_result = self._delete_at_subscription_scope_initial( + raw_result = self._delete_at_subscription_scope_initial( # type: ignore deployment_name=deployment_name, api_version=api_version, - cls=lambda x,y,z: x, + cls=lambda x, y, z: x, + headers=_headers, + params=_params, **kwargs ) - kwargs.pop('error_map', None) + kwargs.pop("error_map", None) - def get_long_running_output(pipeline_response): + def get_long_running_output(pipeline_response): # pylint: disable=inconsistent-return-statements if cls: return cls(pipeline_response, None, {}) - - if polling is True: polling_method = ARMPolling(lro_delay, **kwargs) - elif polling is False: polling_method = NoPolling() - else: polling_method = polling + if polling is True: + polling_method = cast(PollingMethod, ARMPolling(lro_delay, **kwargs)) # type: PollingMethod + elif polling is False: + polling_method = cast(PollingMethod, NoPolling()) + else: + polling_method = polling if cont_token: return LROPoller.from_continuation_token( polling_method=polling_method, continuation_token=cont_token, client=self._client, - deserialization_callback=get_long_running_output + deserialization_callback=get_long_running_output, ) return LROPoller(self._client, raw_result, get_long_running_output, polling_method) - begin_delete_at_subscription_scope.metadata = {'url': "/subscriptions/{subscriptionId}/providers/Microsoft.Resources/deployments/{deploymentName}"} # type: ignore + begin_delete_at_subscription_scope.metadata = {"url": "/subscriptions/{subscriptionId}/providers/Microsoft.Resources/deployments/{deploymentName}"} # type: ignore @distributed_trace - def check_existence_at_subscription_scope( - self, - deployment_name: str, - **kwargs: Any - ) -> bool: + def check_existence_at_subscription_scope(self, deployment_name: str, **kwargs: Any) -> bool: """Checks whether the deployment exists. - :param deployment_name: The name of the deployment. + :param deployment_name: The name of the deployment. Required. :type deployment_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: bool, or the result of cls(response) + :return: bool or the result of cls(response) :rtype: bool - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType[None] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + 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', "2019-08-01") # type: str + api_version = kwargs.pop("api_version", _params.pop("api-version", "2019-08-01")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[None] - request = build_deployments_check_existence_at_subscription_scope_request( deployment_name=deployment_name, subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.check_existence_at_subscription_scope.metadata['url'], + template_url=self.check_existence_at_subscription_scope.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [204, 404]: @@ -5319,42 +5298,52 @@ def check_existence_at_subscription_scope( return cls(pipeline_response, None, {}) return 200 <= response.status_code <= 299 - check_existence_at_subscription_scope.metadata = {'url': "/subscriptions/{subscriptionId}/providers/Microsoft.Resources/deployments/{deploymentName}"} # type: ignore - + check_existence_at_subscription_scope.metadata = {"url": "/subscriptions/{subscriptionId}/providers/Microsoft.Resources/deployments/{deploymentName}"} # type: ignore def _create_or_update_at_subscription_scope_initial( - self, - deployment_name: str, - parameters: "_models.Deployment", - **kwargs: Any - ) -> "_models.DeploymentExtended": - cls = kwargs.pop('cls', None) # type: ClsType["_models.DeploymentExtended"] + self, deployment_name: str, parameters: Union[_models.Deployment, IO], **kwargs: Any + ) -> _models.DeploymentExtended: error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', "2019-08-01") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + api_version = kwargs.pop("api_version", _params.pop("api-version", "2019-08-01")) # type: str + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.DeploymentExtended] - _json = self._serialize.body(parameters, 'Deployment') + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(parameters, (IO, bytes)): + _content = parameters + else: + _json = self._serialize.body(parameters, "Deployment") - request = build_deployments_create_or_update_at_subscription_scope_request_initial( + request = build_deployments_create_or_update_at_subscription_scope_request( deployment_name=deployment_name, subscription_id=self._config.subscription_id, api_version=api_version, content_type=content_type, json=_json, - template_url=self._create_or_update_at_subscription_scope_initial.metadata['url'], + content=_content, + template_url=self._create_or_update_at_subscription_scope_initial.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200, 201]: @@ -5362,34 +5351,38 @@ def _create_or_update_at_subscription_scope_initial( raise HttpResponseError(response=response, error_format=ARMErrorFormat) if response.status_code == 200: - deserialized = self._deserialize('DeploymentExtended', pipeline_response) + deserialized = self._deserialize("DeploymentExtended", pipeline_response) if response.status_code == 201: - deserialized = self._deserialize('DeploymentExtended', pipeline_response) + deserialized = self._deserialize("DeploymentExtended", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - _create_or_update_at_subscription_scope_initial.metadata = {'url': "/subscriptions/{subscriptionId}/providers/Microsoft.Resources/deployments/{deploymentName}"} # type: ignore - + _create_or_update_at_subscription_scope_initial.metadata = {"url": "/subscriptions/{subscriptionId}/providers/Microsoft.Resources/deployments/{deploymentName}"} # type: ignore - @distributed_trace + @overload def begin_create_or_update_at_subscription_scope( self, deployment_name: str, - parameters: "_models.Deployment", + parameters: _models.Deployment, + *, + content_type: str = "application/json", **kwargs: Any - ) -> LROPoller["_models.DeploymentExtended"]: + ) -> LROPoller[_models.DeploymentExtended]: """Deploys resources at subscription scope. You can provide the template and parameters directly in the request or link to JSON files. - :param deployment_name: The name of the deployment. + :param deployment_name: The name of the deployment. Required. :type deployment_name: str - :param parameters: Additional parameters supplied to the operation. + :param parameters: Additional parameters supplied to the operation. Required. :type parameters: ~azure.mgmt.resource.resources.v2019_08_01.models.Deployment + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str :keyword callable cls: A custom type or function that will be passed the direct response :keyword str continuation_token: A continuation token to restart a poller from a saved state. :keyword polling: By default, your polling method will be ARMPolling. Pass in False for this @@ -5402,109 +5395,172 @@ def begin_create_or_update_at_subscription_scope( cls(response) :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.resource.resources.v2019_08_01.models.DeploymentExtended] - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - api_version = kwargs.pop('api_version', "2019-08-01") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] - polling = kwargs.pop('polling', True) # type: Union[bool, PollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType["_models.DeploymentExtended"] - lro_delay = kwargs.pop( - 'polling_interval', - self._config.polling_interval - ) - cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] + + @overload + def begin_create_or_update_at_subscription_scope( + self, deployment_name: str, parameters: IO, *, content_type: str = "application/json", **kwargs: Any + ) -> LROPoller[_models.DeploymentExtended]: + """Deploys resources at subscription scope. + + You can provide the template and parameters directly in the request or link to JSON files. + + :param deployment_name: The name of the deployment. Required. + :type deployment_name: str + :param parameters: Additional parameters supplied to the operation. Required. + :type parameters: IO + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be ARMPolling. Pass in False for this + operation to not poll, or pass in your own initialized polling object for a personal polling + strategy. + :paramtype polling: bool or ~azure.core.polling.PollingMethod + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of LROPoller that returns either DeploymentExtended or the result of + cls(response) + :rtype: + ~azure.core.polling.LROPoller[~azure.mgmt.resource.resources.v2019_08_01.models.DeploymentExtended] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace + def begin_create_or_update_at_subscription_scope( + self, deployment_name: str, parameters: Union[_models.Deployment, IO], **kwargs: Any + ) -> LROPoller[_models.DeploymentExtended]: + """Deploys resources at subscription scope. + + You can provide the template and parameters directly in the request or link to JSON files. + + :param deployment_name: The name of the deployment. Required. + :type deployment_name: str + :param parameters: Additional parameters supplied to the operation. Is either a model type or a + IO type. Required. + :type parameters: ~azure.mgmt.resource.resources.v2019_08_01.models.Deployment or IO + :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. + Default value is None. + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be ARMPolling. Pass in False for this + operation to not poll, or pass in your own initialized polling object for a personal polling + strategy. + :paramtype polling: bool or ~azure.core.polling.PollingMethod + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of LROPoller that returns either DeploymentExtended or the result of + cls(response) + :rtype: + ~azure.core.polling.LROPoller[~azure.mgmt.resource.resources.v2019_08_01.models.DeploymentExtended] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _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", "2019-08-01")) # type: str + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.DeploymentExtended] + polling = kwargs.pop("polling", True) # type: Union[bool, PollingMethod] + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token = kwargs.pop("continuation_token", None) # type: Optional[str] if cont_token is None: - raw_result = self._create_or_update_at_subscription_scope_initial( + raw_result = self._create_or_update_at_subscription_scope_initial( # type: ignore deployment_name=deployment_name, parameters=parameters, api_version=api_version, content_type=content_type, - cls=lambda x,y,z: x, + cls=lambda x, y, z: x, + headers=_headers, + params=_params, **kwargs ) - kwargs.pop('error_map', None) + kwargs.pop("error_map", None) def get_long_running_output(pipeline_response): - response = pipeline_response.http_response - deserialized = self._deserialize('DeploymentExtended', pipeline_response) + deserialized = self._deserialize("DeploymentExtended", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - - if polling is True: polling_method = ARMPolling(lro_delay, **kwargs) - elif polling is False: polling_method = NoPolling() - else: polling_method = polling + if polling is True: + polling_method = cast(PollingMethod, ARMPolling(lro_delay, **kwargs)) # type: PollingMethod + elif polling is False: + polling_method = cast(PollingMethod, NoPolling()) + else: + polling_method = polling if cont_token: return LROPoller.from_continuation_token( polling_method=polling_method, continuation_token=cont_token, client=self._client, - deserialization_callback=get_long_running_output + deserialization_callback=get_long_running_output, ) return LROPoller(self._client, raw_result, get_long_running_output, polling_method) - begin_create_or_update_at_subscription_scope.metadata = {'url': "/subscriptions/{subscriptionId}/providers/Microsoft.Resources/deployments/{deploymentName}"} # type: ignore + begin_create_or_update_at_subscription_scope.metadata = {"url": "/subscriptions/{subscriptionId}/providers/Microsoft.Resources/deployments/{deploymentName}"} # type: ignore @distributed_trace - def get_at_subscription_scope( - self, - deployment_name: str, - **kwargs: Any - ) -> "_models.DeploymentExtended": + def get_at_subscription_scope(self, deployment_name: str, **kwargs: Any) -> _models.DeploymentExtended: """Gets a deployment. - :param deployment_name: The name of the deployment. + :param deployment_name: The name of the deployment. Required. :type deployment_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: DeploymentExtended, or the result of cls(response) + :return: DeploymentExtended or the result of cls(response) :rtype: ~azure.mgmt.resource.resources.v2019_08_01.models.DeploymentExtended - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.DeploymentExtended"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) - api_version = kwargs.pop('api_version', "2019-08-01") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2019-08-01")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[_models.DeploymentExtended] - request = build_deployments_get_at_subscription_scope_request( deployment_name=deployment_name, subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.get_at_subscription_scope.metadata['url'], + template_url=self.get_at_subscription_scope.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) - deserialized = self._deserialize('DeploymentExtended', pipeline_response) + deserialized = self._deserialize("DeploymentExtended", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - get_at_subscription_scope.metadata = {'url': "/subscriptions/{subscriptionId}/providers/Microsoft.Resources/deployments/{deploymentName}"} # type: ignore - + get_at_subscription_scope.metadata = {"url": "/subscriptions/{subscriptionId}/providers/Microsoft.Resources/deployments/{deploymentName}"} # type: ignore @distributed_trace def cancel_at_subscription_scope( # pylint: disable=inconsistent-return-statements - self, - deployment_name: str, - **kwargs: Any + self, deployment_name: str, **kwargs: Any ) -> None: """Cancels a currently running template deployment. @@ -5513,36 +5569,42 @@ def cancel_at_subscription_scope( # pylint: disable=inconsistent-return-stateme deployment stops the currently running template deployment and leaves the resources partially deployed. - :param deployment_name: The name of the deployment. + :param deployment_name: The name of the deployment. Required. :type deployment_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: None, or the result of cls(response) + :return: None or the result of cls(response) :rtype: None - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType[None] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) - api_version = kwargs.pop('api_version', "2019-08-01") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2019-08-01")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[None] - request = build_deployments_cancel_at_subscription_scope_request( deployment_name=deployment_name, subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.cancel_at_subscription_scope.metadata['url'], + template_url=self.cancel_at_subscription_scope.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [204]: @@ -5552,38 +5614,94 @@ def cancel_at_subscription_scope( # pylint: disable=inconsistent-return-stateme if cls: return cls(pipeline_response, None, {}) - cancel_at_subscription_scope.metadata = {'url': "/subscriptions/{subscriptionId}/providers/Microsoft.Resources/deployments/{deploymentName}/cancel"} # type: ignore + cancel_at_subscription_scope.metadata = {"url": "/subscriptions/{subscriptionId}/providers/Microsoft.Resources/deployments/{deploymentName}/cancel"} # type: ignore - - @distributed_trace + @overload def validate_at_subscription_scope( self, deployment_name: str, - parameters: "_models.Deployment", + parameters: _models.Deployment, + *, + content_type: str = "application/json", **kwargs: Any - ) -> "_models.DeploymentValidateResult": + ) -> _models.DeploymentValidateResult: """Validates whether the specified template is syntactically correct and will be accepted by Azure Resource Manager.. - :param deployment_name: The name of the deployment. + :param deployment_name: The name of the deployment. Required. :type deployment_name: str - :param parameters: Parameters to validate. + :param parameters: Parameters to validate. Required. :type parameters: ~azure.mgmt.resource.resources.v2019_08_01.models.Deployment + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: DeploymentValidateResult, or the result of cls(response) + :return: DeploymentValidateResult or the result of cls(response) :rtype: ~azure.mgmt.resource.resources.v2019_08_01.models.DeploymentValidateResult - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.DeploymentValidateResult"] - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {})) - - api_version = kwargs.pop('api_version', "2019-08-01") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] - - _json = self._serialize.body(parameters, 'Deployment') + + @overload + def validate_at_subscription_scope( + self, deployment_name: str, parameters: IO, *, content_type: str = "application/json", **kwargs: Any + ) -> _models.DeploymentValidateResult: + """Validates whether the specified template is syntactically correct and will be accepted by Azure + Resource Manager.. + + :param deployment_name: The name of the deployment. Required. + :type deployment_name: str + :param parameters: Parameters to validate. Required. + :type parameters: IO + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: DeploymentValidateResult or the result of cls(response) + :rtype: ~azure.mgmt.resource.resources.v2019_08_01.models.DeploymentValidateResult + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace + def validate_at_subscription_scope( + self, deployment_name: str, parameters: Union[_models.Deployment, IO], **kwargs: Any + ) -> _models.DeploymentValidateResult: + """Validates whether the specified template is syntactically correct and will be accepted by Azure + Resource Manager.. + + :param deployment_name: The name of the deployment. Required. + :type deployment_name: str + :param parameters: Parameters to validate. Is either a model type or a IO type. Required. + :type parameters: ~azure.mgmt.resource.resources.v2019_08_01.models.Deployment or IO + :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. + Default value is None. + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: DeploymentValidateResult or the result of cls(response) + :rtype: ~azure.mgmt.resource.resources.v2019_08_01.models.DeploymentValidateResult + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2019-08-01")) # type: str + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.DeploymentValidateResult] + + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(parameters, (IO, bytes)): + _content = parameters + else: + _json = self._serialize.body(parameters, "Deployment") request = build_deployments_validate_at_subscription_scope_request( deployment_name=deployment_name, @@ -5591,16 +5709,18 @@ def validate_at_subscription_scope( api_version=api_version, content_type=content_type, json=_json, - template_url=self.validate_at_subscription_scope.metadata['url'], + content=_content, + template_url=self.validate_at_subscription_scope.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200, 400]: @@ -5608,52 +5728,62 @@ def validate_at_subscription_scope( raise HttpResponseError(response=response, error_format=ARMErrorFormat) if response.status_code == 200: - deserialized = self._deserialize('DeploymentValidateResult', pipeline_response) + deserialized = self._deserialize("DeploymentValidateResult", pipeline_response) if response.status_code == 400: - deserialized = self._deserialize('DeploymentValidateResult', pipeline_response) + deserialized = self._deserialize("DeploymentValidateResult", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - validate_at_subscription_scope.metadata = {'url': "/subscriptions/{subscriptionId}/providers/Microsoft.Resources/deployments/{deploymentName}/validate"} # type: ignore - + validate_at_subscription_scope.metadata = {"url": "/subscriptions/{subscriptionId}/providers/Microsoft.Resources/deployments/{deploymentName}/validate"} # type: ignore def _what_if_at_subscription_scope_initial( - self, - deployment_name: str, - parameters: "_models.DeploymentWhatIf", - **kwargs: Any - ) -> Optional["_models.WhatIfOperationResult"]: - cls = kwargs.pop('cls', None) # type: ClsType[Optional["_models.WhatIfOperationResult"]] + self, deployment_name: str, parameters: Union[_models.DeploymentWhatIf, IO], **kwargs: Any + ) -> Optional[_models.WhatIfOperationResult]: error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) - api_version = kwargs.pop('api_version', "2019-08-01") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - _json = self._serialize.body(parameters, 'DeploymentWhatIf') + api_version = kwargs.pop("api_version", _params.pop("api-version", "2019-08-01")) # type: str + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[Optional[_models.WhatIfOperationResult]] - request = build_deployments_what_if_at_subscription_scope_request_initial( + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(parameters, (IO, bytes)): + _content = parameters + else: + _json = self._serialize.body(parameters, "DeploymentWhatIf") + + request = build_deployments_what_if_at_subscription_scope_request( deployment_name=deployment_name, subscription_id=self._config.subscription_id, api_version=api_version, content_type=content_type, json=_json, - template_url=self._what_if_at_subscription_scope_initial.metadata['url'], + content=_content, + template_url=self._what_if_at_subscription_scope_initial.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200, 202]: @@ -5663,35 +5793,38 @@ def _what_if_at_subscription_scope_initial( deserialized = None response_headers = {} if response.status_code == 200: - deserialized = self._deserialize('WhatIfOperationResult', pipeline_response) + deserialized = self._deserialize("WhatIfOperationResult", pipeline_response) if response.status_code == 202: - response_headers['Location']=self._deserialize('str', response.headers.get('Location')) - response_headers['Retry-After']=self._deserialize('str', response.headers.get('Retry-After')) - + response_headers["Location"] = self._deserialize("str", response.headers.get("Location")) + response_headers["Retry-After"] = self._deserialize("str", response.headers.get("Retry-After")) if cls: return cls(pipeline_response, deserialized, response_headers) return deserialized - _what_if_at_subscription_scope_initial.metadata = {'url': "/subscriptions/{subscriptionId}/providers/Microsoft.Resources/deployments/{deploymentName}/whatIf"} # type: ignore + _what_if_at_subscription_scope_initial.metadata = {"url": "/subscriptions/{subscriptionId}/providers/Microsoft.Resources/deployments/{deploymentName}/whatIf"} # type: ignore - - @distributed_trace + @overload def begin_what_if_at_subscription_scope( self, deployment_name: str, - parameters: "_models.DeploymentWhatIf", + parameters: _models.DeploymentWhatIf, + *, + content_type: str = "application/json", **kwargs: Any - ) -> LROPoller["_models.WhatIfOperationResult"]: + ) -> LROPoller[_models.WhatIfOperationResult]: """Returns changes that will be made by the deployment if executed at the scope of the subscription. - :param deployment_name: The name of the deployment. + :param deployment_name: The name of the deployment. Required. :type deployment_name: str - :param parameters: Parameters to What If. + :param parameters: Parameters to What If. Required. :type parameters: ~azure.mgmt.resource.resources.v2019_08_01.models.DeploymentWhatIf + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str :keyword callable cls: A custom type or function that will be passed the direct response :keyword str continuation_token: A continuation token to restart a poller from a saved state. :keyword polling: By default, your polling method will be ARMPolling. Pass in False for this @@ -5704,111 +5837,174 @@ def begin_what_if_at_subscription_scope( cls(response) :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.resource.resources.v2019_08_01.models.WhatIfOperationResult] - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - api_version = kwargs.pop('api_version', "2019-08-01") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] - polling = kwargs.pop('polling', True) # type: Union[bool, PollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType["_models.WhatIfOperationResult"] - lro_delay = kwargs.pop( - 'polling_interval', - self._config.polling_interval - ) - cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] + + @overload + def begin_what_if_at_subscription_scope( + self, deployment_name: str, parameters: IO, *, content_type: str = "application/json", **kwargs: Any + ) -> LROPoller[_models.WhatIfOperationResult]: + """Returns changes that will be made by the deployment if executed at the scope of the + subscription. + + :param deployment_name: The name of the deployment. Required. + :type deployment_name: str + :param parameters: Parameters to What If. Required. + :type parameters: IO + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be ARMPolling. Pass in False for this + operation to not poll, or pass in your own initialized polling object for a personal polling + strategy. + :paramtype polling: bool or ~azure.core.polling.PollingMethod + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of LROPoller that returns either WhatIfOperationResult or the result of + cls(response) + :rtype: + ~azure.core.polling.LROPoller[~azure.mgmt.resource.resources.v2019_08_01.models.WhatIfOperationResult] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace + def begin_what_if_at_subscription_scope( + self, deployment_name: str, parameters: Union[_models.DeploymentWhatIf, IO], **kwargs: Any + ) -> LROPoller[_models.WhatIfOperationResult]: + """Returns changes that will be made by the deployment if executed at the scope of the + subscription. + + :param deployment_name: The name of the deployment. Required. + :type deployment_name: str + :param parameters: Parameters to What If. Is either a model type or a IO type. Required. + :type parameters: ~azure.mgmt.resource.resources.v2019_08_01.models.DeploymentWhatIf or IO + :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. + Default value is None. + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be ARMPolling. Pass in False for this + operation to not poll, or pass in your own initialized polling object for a personal polling + strategy. + :paramtype polling: bool or ~azure.core.polling.PollingMethod + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of LROPoller that returns either WhatIfOperationResult or the result of + cls(response) + :rtype: + ~azure.core.polling.LROPoller[~azure.mgmt.resource.resources.v2019_08_01.models.WhatIfOperationResult] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _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", "2019-08-01")) # type: str + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.WhatIfOperationResult] + polling = kwargs.pop("polling", True) # type: Union[bool, PollingMethod] + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token = kwargs.pop("continuation_token", None) # type: Optional[str] if cont_token is None: - raw_result = self._what_if_at_subscription_scope_initial( + raw_result = self._what_if_at_subscription_scope_initial( # type: ignore deployment_name=deployment_name, parameters=parameters, api_version=api_version, content_type=content_type, - cls=lambda x,y,z: x, + cls=lambda x, y, z: x, + headers=_headers, + params=_params, **kwargs ) - kwargs.pop('error_map', None) + kwargs.pop("error_map", None) def get_long_running_output(pipeline_response): - response = pipeline_response.http_response - deserialized = self._deserialize('WhatIfOperationResult', pipeline_response) + deserialized = self._deserialize("WhatIfOperationResult", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - - if polling is True: polling_method = ARMPolling(lro_delay, lro_options={'final-state-via': 'location'}, **kwargs) - elif polling is False: polling_method = NoPolling() - else: polling_method = polling + if polling is True: + polling_method = cast( + PollingMethod, ARMPolling(lro_delay, lro_options={"final-state-via": "location"}, **kwargs) + ) # type: PollingMethod + elif polling is False: + polling_method = cast(PollingMethod, NoPolling()) + else: + polling_method = polling if cont_token: return LROPoller.from_continuation_token( polling_method=polling_method, continuation_token=cont_token, client=self._client, - deserialization_callback=get_long_running_output + deserialization_callback=get_long_running_output, ) return LROPoller(self._client, raw_result, get_long_running_output, polling_method) - begin_what_if_at_subscription_scope.metadata = {'url': "/subscriptions/{subscriptionId}/providers/Microsoft.Resources/deployments/{deploymentName}/whatIf"} # type: ignore + begin_what_if_at_subscription_scope.metadata = {"url": "/subscriptions/{subscriptionId}/providers/Microsoft.Resources/deployments/{deploymentName}/whatIf"} # type: ignore @distributed_trace def export_template_at_subscription_scope( - self, - deployment_name: str, - **kwargs: Any - ) -> "_models.DeploymentExportResult": + self, deployment_name: str, **kwargs: Any + ) -> _models.DeploymentExportResult: """Exports the template used for specified deployment. - :param deployment_name: The name of the deployment. + :param deployment_name: The name of the deployment. Required. :type deployment_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: DeploymentExportResult, or the result of cls(response) + :return: DeploymentExportResult or the result of cls(response) :rtype: ~azure.mgmt.resource.resources.v2019_08_01.models.DeploymentExportResult - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.DeploymentExportResult"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) - api_version = kwargs.pop('api_version', "2019-08-01") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2019-08-01")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[_models.DeploymentExportResult] - request = build_deployments_export_template_at_subscription_scope_request( deployment_name=deployment_name, subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.export_template_at_subscription_scope.metadata['url'], + template_url=self.export_template_at_subscription_scope.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) - deserialized = self._deserialize('DeploymentExportResult', pipeline_response) + deserialized = self._deserialize("DeploymentExportResult", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - export_template_at_subscription_scope.metadata = {'url': "/subscriptions/{subscriptionId}/providers/Microsoft.Resources/deployments/{deploymentName}/exportTemplate"} # type: ignore - + export_template_at_subscription_scope.metadata = {"url": "/subscriptions/{subscriptionId}/providers/Microsoft.Resources/deployments/{deploymentName}/exportTemplate"} # type: ignore @distributed_trace def list_at_subscription_scope( - self, - filter: Optional[str] = None, - top: Optional[int] = None, - **kwargs: Any - ) -> Iterable["_models.DeploymentListResult"]: + self, filter: Optional[str] = None, top: Optional[int] = None, **kwargs: Any + ) -> Iterable["_models.DeploymentExtended"]: """Get all the deployments for a subscription. :param filter: The filter to apply on the operation. For example, you can use @@ -5818,40 +6014,48 @@ def list_at_subscription_scope( value is None. :type top: int :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either DeploymentListResult or the result of - cls(response) + :return: An iterator like instance of either DeploymentExtended or the result of cls(response) :rtype: - ~azure.core.paging.ItemPaged[~azure.mgmt.resource.resources.v2019_08_01.models.DeploymentListResult] - :raises: ~azure.core.exceptions.HttpResponseError + ~azure.core.paging.ItemPaged[~azure.mgmt.resource.resources.v2019_08_01.models.DeploymentExtended] + :raises ~azure.core.exceptions.HttpResponseError: """ - api_version = kwargs.pop('api_version', "2019-08-01") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2019-08-01")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[_models.DeploymentListResult] - cls = kwargs.pop('cls', None) # type: ClsType["_models.DeploymentListResult"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) + def prepare_request(next_link=None): if not next_link: - + request = build_deployments_list_at_subscription_scope_request( subscription_id=self._config.subscription_id, - api_version=api_version, filter=filter, top=top, - template_url=self.list_at_subscription_scope.metadata['url'], + api_version=api_version, + template_url=self.list_at_subscription_scope.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore else: - - request = build_deployments_list_at_subscription_scope_request( - subscription_id=self._config.subscription_id, - template_url=next_link, - ) + # make call to next link with the client's api-version + _parsed_next_link = urlparse(next_link) + _next_request_params = case_insensitive_dict(parse_qs(_parsed_next_link.query)) + _next_request_params["api-version"] = self._config.api_version + request = HttpRequest("GET", urljoin(next_link, _parsed_next_link.path), params=_next_request_params) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore request.method = "GET" return request @@ -5865,10 +6069,8 @@ def extract_data(pipeline_response): def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) response = pipeline_response.http_response @@ -5878,42 +6080,43 @@ def get_next(next_link=None): return pipeline_response + return ItemPaged(get_next, extract_data) - return ItemPaged( - get_next, extract_data - ) - list_at_subscription_scope.metadata = {'url': "/subscriptions/{subscriptionId}/providers/Microsoft.Resources/deployments/"} # type: ignore + list_at_subscription_scope.metadata = {"url": "/subscriptions/{subscriptionId}/providers/Microsoft.Resources/deployments/"} # type: ignore def _delete_initial( # pylint: disable=inconsistent-return-statements - self, - resource_group_name: str, - deployment_name: str, - **kwargs: Any + self, resource_group_name: str, deployment_name: str, **kwargs: Any ) -> None: - cls = kwargs.pop('cls', None) # type: ClsType[None] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) - api_version = kwargs.pop('api_version', "2019-08-01") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - request = build_deployments_delete_request_initial( + api_version = kwargs.pop("api_version", _params.pop("api-version", "2019-08-01")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[None] + + request = build_deployments_delete_request( resource_group_name=resource_group_name, deployment_name=deployment_name, subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self._delete_initial.metadata['url'], + template_url=self._delete_initial.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [202, 204]: @@ -5923,16 +6126,10 @@ 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.Resources/deployments/{deploymentName}"} # type: ignore - + _delete_initial.metadata = {"url": "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/Microsoft.Resources/deployments/{deploymentName}"} # type: ignore @distributed_trace - def begin_delete( # pylint: disable=inconsistent-return-statements - self, - resource_group_name: str, - deployment_name: str, - **kwargs: Any - ) -> LROPoller[None]: + def begin_delete(self, resource_group_name: str, deployment_name: str, **kwargs: Any) -> LROPoller[None]: """Deletes a deployment from the deployment history. A template deployment that is currently running cannot be deleted. Deleting a template @@ -5945,9 +6142,9 @@ def begin_delete( # pylint: disable=inconsistent-return-statements asynchronous request failed, the URI in the Location header returns an error-level status code. :param resource_group_name: The name of the resource group with the deployment to delete. The - name is case insensitive. + name is case insensitive. Required. :type resource_group_name: str - :param deployment_name: The name of the deployment. + :param deployment_name: The name of the deployment. Required. :type deployment_name: str :keyword callable cls: A custom type or function that will be passed the direct response :keyword str continuation_token: A continuation token to restart a poller from a saved state. @@ -5959,88 +6156,93 @@ def begin_delete( # pylint: disable=inconsistent-return-statements Retry-After header is present. :return: An instance of LROPoller that returns either None or the result of cls(response) :rtype: ~azure.core.polling.LROPoller[None] - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - api_version = kwargs.pop('api_version', "2019-08-01") # type: str - polling = kwargs.pop('polling', True) # type: Union[bool, PollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType[None] - lro_delay = kwargs.pop( - 'polling_interval', - self._config.polling_interval - ) - cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2019-08-01")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[None] + polling = kwargs.pop("polling", True) # type: Union[bool, PollingMethod] + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token = kwargs.pop("continuation_token", None) # type: Optional[str] if cont_token is None: - raw_result = self._delete_initial( + raw_result = self._delete_initial( # type: ignore resource_group_name=resource_group_name, deployment_name=deployment_name, api_version=api_version, - cls=lambda x,y,z: x, + cls=lambda x, y, z: x, + headers=_headers, + params=_params, **kwargs ) - kwargs.pop('error_map', None) + kwargs.pop("error_map", None) - def get_long_running_output(pipeline_response): + def get_long_running_output(pipeline_response): # pylint: disable=inconsistent-return-statements if cls: return cls(pipeline_response, None, {}) - - if polling is True: polling_method = ARMPolling(lro_delay, **kwargs) - elif polling is False: polling_method = NoPolling() - else: polling_method = polling + if polling is True: + polling_method = cast(PollingMethod, ARMPolling(lro_delay, **kwargs)) # type: PollingMethod + elif polling is False: + polling_method = cast(PollingMethod, NoPolling()) + else: + polling_method = polling if cont_token: return LROPoller.from_continuation_token( polling_method=polling_method, continuation_token=cont_token, client=self._client, - deserialization_callback=get_long_running_output + deserialization_callback=get_long_running_output, ) return LROPoller(self._client, raw_result, get_long_running_output, polling_method) - begin_delete.metadata = {'url': "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/Microsoft.Resources/deployments/{deploymentName}"} # type: ignore + begin_delete.metadata = {"url": "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/Microsoft.Resources/deployments/{deploymentName}"} # type: ignore @distributed_trace - def check_existence( - self, - resource_group_name: str, - deployment_name: str, - **kwargs: Any - ) -> bool: + def check_existence(self, resource_group_name: str, deployment_name: str, **kwargs: Any) -> bool: """Checks whether the deployment exists. :param resource_group_name: The name of the resource group with the deployment to check. The - name is case insensitive. + name is case insensitive. Required. :type resource_group_name: str - :param deployment_name: The name of the deployment. + :param deployment_name: The name of the deployment. Required. :type deployment_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: bool, or the result of cls(response) + :return: bool or the result of cls(response) :rtype: bool - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType[None] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + 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', "2019-08-01") # type: str + api_version = kwargs.pop("api_version", _params.pop("api-version", "2019-08-01")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[None] - request = build_deployments_check_existence_request( resource_group_name=resource_group_name, deployment_name=deployment_name, subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.check_existence.metadata['url'], + template_url=self.check_existence.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [204, 404]: @@ -6051,44 +6253,53 @@ def check_existence( return cls(pipeline_response, None, {}) return 200 <= response.status_code <= 299 - check_existence.metadata = {'url': "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/Microsoft.Resources/deployments/{deploymentName}"} # type: ignore - + check_existence.metadata = {"url": "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/Microsoft.Resources/deployments/{deploymentName}"} # type: ignore def _create_or_update_initial( - self, - resource_group_name: str, - deployment_name: str, - parameters: "_models.Deployment", - **kwargs: Any - ) -> "_models.DeploymentExtended": - cls = kwargs.pop('cls', None) # type: ClsType["_models.DeploymentExtended"] + self, resource_group_name: str, deployment_name: str, parameters: Union[_models.Deployment, IO], **kwargs: Any + ) -> _models.DeploymentExtended: error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) - api_version = kwargs.pop('api_version', "2019-08-01") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - _json = self._serialize.body(parameters, 'Deployment') + api_version = kwargs.pop("api_version", _params.pop("api-version", "2019-08-01")) # type: str + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.DeploymentExtended] - request = build_deployments_create_or_update_request_initial( + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(parameters, (IO, bytes)): + _content = parameters + else: + _json = self._serialize.body(parameters, "Deployment") + + request = build_deployments_create_or_update_request( resource_group_name=resource_group_name, deployment_name=deployment_name, subscription_id=self._config.subscription_id, api_version=api_version, content_type=content_type, json=_json, - template_url=self._create_or_update_initial.metadata['url'], + content=_content, + template_url=self._create_or_update_initial.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200, 201]: @@ -6096,38 +6307,42 @@ def _create_or_update_initial( raise HttpResponseError(response=response, error_format=ARMErrorFormat) if response.status_code == 200: - deserialized = self._deserialize('DeploymentExtended', pipeline_response) + deserialized = self._deserialize("DeploymentExtended", pipeline_response) if response.status_code == 201: - deserialized = self._deserialize('DeploymentExtended', pipeline_response) + deserialized = self._deserialize("DeploymentExtended", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - _create_or_update_initial.metadata = {'url': "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/Microsoft.Resources/deployments/{deploymentName}"} # type: ignore + _create_or_update_initial.metadata = {"url": "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/Microsoft.Resources/deployments/{deploymentName}"} # type: ignore - - @distributed_trace + @overload def begin_create_or_update( self, resource_group_name: str, deployment_name: str, - parameters: "_models.Deployment", + parameters: _models.Deployment, + *, + content_type: str = "application/json", **kwargs: Any - ) -> LROPoller["_models.DeploymentExtended"]: + ) -> LROPoller[_models.DeploymentExtended]: """Deploys resources to a resource group. You can provide the template and parameters directly in the request or link to JSON files. :param resource_group_name: The name of the resource group to deploy the resources to. The name - is case insensitive. The resource group must already exist. + is case insensitive. The resource group must already exist. Required. :type resource_group_name: str - :param deployment_name: The name of the deployment. + :param deployment_name: The name of the deployment. Required. :type deployment_name: str - :param parameters: Additional parameters supplied to the operation. + :param parameters: Additional parameters supplied to the operation. Required. :type parameters: ~azure.mgmt.resource.resources.v2019_08_01.models.Deployment + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str :keyword callable cls: A custom type or function that will be passed the direct response :keyword str continuation_token: A continuation token to restart a poller from a saved state. :keyword polling: By default, your polling method will be ARMPolling. Pass in False for this @@ -6140,115 +6355,189 @@ def begin_create_or_update( cls(response) :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.resource.resources.v2019_08_01.models.DeploymentExtended] - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - api_version = kwargs.pop('api_version', "2019-08-01") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] - polling = kwargs.pop('polling', True) # type: Union[bool, PollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType["_models.DeploymentExtended"] - lro_delay = kwargs.pop( - 'polling_interval', - self._config.polling_interval - ) - cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] + + @overload + def begin_create_or_update( + self, + resource_group_name: str, + deployment_name: str, + parameters: IO, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> LROPoller[_models.DeploymentExtended]: + """Deploys resources to a resource group. + + You can provide the template and parameters directly in the request or link to JSON files. + + :param resource_group_name: The name of the resource group to deploy the resources to. The name + is case insensitive. The resource group must already exist. Required. + :type resource_group_name: str + :param deployment_name: The name of the deployment. Required. + :type deployment_name: str + :param parameters: Additional parameters supplied to the operation. Required. + :type parameters: IO + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be ARMPolling. Pass in False for this + operation to not poll, or pass in your own initialized polling object for a personal polling + strategy. + :paramtype polling: bool or ~azure.core.polling.PollingMethod + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of LROPoller that returns either DeploymentExtended or the result of + cls(response) + :rtype: + ~azure.core.polling.LROPoller[~azure.mgmt.resource.resources.v2019_08_01.models.DeploymentExtended] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace + def begin_create_or_update( + self, resource_group_name: str, deployment_name: str, parameters: Union[_models.Deployment, IO], **kwargs: Any + ) -> LROPoller[_models.DeploymentExtended]: + """Deploys resources to a resource group. + + You can provide the template and parameters directly in the request or link to JSON files. + + :param resource_group_name: The name of the resource group to deploy the resources to. The name + is case insensitive. The resource group must already exist. Required. + :type resource_group_name: str + :param deployment_name: The name of the deployment. Required. + :type deployment_name: str + :param parameters: Additional parameters supplied to the operation. Is either a model type or a + IO type. Required. + :type parameters: ~azure.mgmt.resource.resources.v2019_08_01.models.Deployment or IO + :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. + Default value is None. + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be ARMPolling. Pass in False for this + operation to not poll, or pass in your own initialized polling object for a personal polling + strategy. + :paramtype polling: bool or ~azure.core.polling.PollingMethod + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of LROPoller that returns either DeploymentExtended or the result of + cls(response) + :rtype: + ~azure.core.polling.LROPoller[~azure.mgmt.resource.resources.v2019_08_01.models.DeploymentExtended] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _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", "2019-08-01")) # type: str + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.DeploymentExtended] + polling = kwargs.pop("polling", True) # type: Union[bool, PollingMethod] + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token = kwargs.pop("continuation_token", None) # type: Optional[str] if cont_token is None: - raw_result = self._create_or_update_initial( + raw_result = self._create_or_update_initial( # type: ignore resource_group_name=resource_group_name, deployment_name=deployment_name, parameters=parameters, api_version=api_version, content_type=content_type, - cls=lambda x,y,z: x, + cls=lambda x, y, z: x, + headers=_headers, + params=_params, **kwargs ) - kwargs.pop('error_map', None) + kwargs.pop("error_map", None) def get_long_running_output(pipeline_response): - response = pipeline_response.http_response - deserialized = self._deserialize('DeploymentExtended', pipeline_response) + deserialized = self._deserialize("DeploymentExtended", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - - if polling is True: polling_method = ARMPolling(lro_delay, **kwargs) - elif polling is False: polling_method = NoPolling() - else: polling_method = polling + if polling is True: + polling_method = cast(PollingMethod, ARMPolling(lro_delay, **kwargs)) # type: PollingMethod + elif polling is False: + polling_method = cast(PollingMethod, NoPolling()) + else: + polling_method = polling if cont_token: return LROPoller.from_continuation_token( polling_method=polling_method, continuation_token=cont_token, client=self._client, - deserialization_callback=get_long_running_output + deserialization_callback=get_long_running_output, ) return LROPoller(self._client, raw_result, get_long_running_output, polling_method) - begin_create_or_update.metadata = {'url': "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/Microsoft.Resources/deployments/{deploymentName}"} # type: ignore + begin_create_or_update.metadata = {"url": "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/Microsoft.Resources/deployments/{deploymentName}"} # type: ignore @distributed_trace - def get( - self, - resource_group_name: str, - deployment_name: str, - **kwargs: Any - ) -> "_models.DeploymentExtended": + def get(self, resource_group_name: str, deployment_name: str, **kwargs: Any) -> _models.DeploymentExtended: """Gets a deployment. :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. :type resource_group_name: str - :param deployment_name: The name of the deployment. + :param deployment_name: The name of the deployment. Required. :type deployment_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: DeploymentExtended, or the result of cls(response) + :return: DeploymentExtended or the result of cls(response) :rtype: ~azure.mgmt.resource.resources.v2019_08_01.models.DeploymentExtended - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.DeploymentExtended"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) - api_version = kwargs.pop('api_version', "2019-08-01") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2019-08-01")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[_models.DeploymentExtended] - request = build_deployments_get_request( resource_group_name=resource_group_name, deployment_name=deployment_name, subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.get.metadata['url'], + template_url=self.get.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) - deserialized = self._deserialize('DeploymentExtended', pipeline_response) + deserialized = self._deserialize("DeploymentExtended", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - get.metadata = {'url': "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/Microsoft.Resources/deployments/{deploymentName}"} # type: ignore - + get.metadata = {"url": "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/Microsoft.Resources/deployments/{deploymentName}"} # type: ignore @distributed_trace def cancel( # pylint: disable=inconsistent-return-statements - self, - resource_group_name: str, - deployment_name: str, - **kwargs: Any + self, resource_group_name: str, deployment_name: str, **kwargs: Any ) -> None: """Cancels a currently running template deployment. @@ -6258,38 +6547,45 @@ def cancel( # pylint: disable=inconsistent-return-statements partially deployed. :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. :type resource_group_name: str - :param deployment_name: The name of the deployment. + :param deployment_name: The name of the deployment. Required. :type deployment_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: None, or the result of cls(response) + :return: None or the result of cls(response) :rtype: None - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType[None] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + 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', "2019-08-01") # type: str + api_version = kwargs.pop("api_version", _params.pop("api-version", "2019-08-01")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[None] - request = build_deployments_cancel_request( resource_group_name=resource_group_name, deployment_name=deployment_name, subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.cancel.metadata['url'], + template_url=self.cancel.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [204]: @@ -6299,42 +6595,110 @@ def cancel( # pylint: disable=inconsistent-return-statements if cls: return cls(pipeline_response, None, {}) - cancel.metadata = {'url': "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/Microsoft.Resources/deployments/{deploymentName}/cancel"} # type: ignore - + cancel.metadata = {"url": "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/Microsoft.Resources/deployments/{deploymentName}/cancel"} # type: ignore - @distributed_trace + @overload def validate( self, resource_group_name: str, deployment_name: str, - parameters: "_models.Deployment", + parameters: _models.Deployment, + *, + content_type: str = "application/json", **kwargs: Any - ) -> "_models.DeploymentValidateResult": + ) -> _models.DeploymentValidateResult: """Validates whether the specified template is syntactically correct and will be accepted by Azure Resource Manager.. :param resource_group_name: The name of the resource group the template will be deployed to. - The name is case insensitive. + The name is case insensitive. Required. :type resource_group_name: str - :param deployment_name: The name of the deployment. + :param deployment_name: The name of the deployment. Required. :type deployment_name: str - :param parameters: Parameters to validate. + :param parameters: Parameters to validate. Required. :type parameters: ~azure.mgmt.resource.resources.v2019_08_01.models.Deployment + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: DeploymentValidateResult or the result of cls(response) + :rtype: ~azure.mgmt.resource.resources.v2019_08_01.models.DeploymentValidateResult + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + def validate( + self, + resource_group_name: str, + deployment_name: str, + parameters: IO, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.DeploymentValidateResult: + """Validates whether the specified template is syntactically correct and will be accepted by Azure + Resource Manager.. + + :param resource_group_name: The name of the resource group the template will be deployed to. + The name is case insensitive. Required. + :type resource_group_name: str + :param deployment_name: The name of the deployment. Required. + :type deployment_name: str + :param parameters: Parameters to validate. Required. + :type parameters: IO + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: DeploymentValidateResult or the result of cls(response) + :rtype: ~azure.mgmt.resource.resources.v2019_08_01.models.DeploymentValidateResult + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace + def validate( + self, resource_group_name: str, deployment_name: str, parameters: Union[_models.Deployment, IO], **kwargs: Any + ) -> _models.DeploymentValidateResult: + """Validates whether the specified template is syntactically correct and will be accepted by Azure + Resource Manager.. + + :param resource_group_name: The name of the resource group the template will be deployed to. + The name is case insensitive. Required. + :type resource_group_name: str + :param deployment_name: The name of the deployment. Required. + :type deployment_name: str + :param parameters: Parameters to validate. Is either a model type or a IO type. Required. + :type parameters: ~azure.mgmt.resource.resources.v2019_08_01.models.Deployment or IO + :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. + Default value is None. + :paramtype content_type: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: DeploymentValidateResult, or the result of cls(response) + :return: DeploymentValidateResult or the result of cls(response) :rtype: ~azure.mgmt.resource.resources.v2019_08_01.models.DeploymentValidateResult - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.DeploymentValidateResult"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', "2019-08-01") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + api_version = kwargs.pop("api_version", _params.pop("api-version", "2019-08-01")) # type: str + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.DeploymentValidateResult] - _json = self._serialize.body(parameters, 'Deployment') + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(parameters, (IO, bytes)): + _content = parameters + else: + _json = self._serialize.body(parameters, "Deployment") request = build_deployments_validate_request( resource_group_name=resource_group_name, @@ -6343,16 +6707,18 @@ def validate( api_version=api_version, content_type=content_type, json=_json, - template_url=self.validate.metadata['url'], + content=_content, + template_url=self.validate.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200, 400]: @@ -6360,54 +6726,67 @@ def validate( raise HttpResponseError(response=response, error_format=ARMErrorFormat) if response.status_code == 200: - deserialized = self._deserialize('DeploymentValidateResult', pipeline_response) + deserialized = self._deserialize("DeploymentValidateResult", pipeline_response) if response.status_code == 400: - deserialized = self._deserialize('DeploymentValidateResult', pipeline_response) + deserialized = self._deserialize("DeploymentValidateResult", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - validate.metadata = {'url': "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/Microsoft.Resources/deployments/{deploymentName}/validate"} # type: ignore - + validate.metadata = {"url": "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/Microsoft.Resources/deployments/{deploymentName}/validate"} # type: ignore def _what_if_initial( self, resource_group_name: str, deployment_name: str, - parameters: "_models.DeploymentWhatIf", + parameters: Union[_models.DeploymentWhatIf, IO], **kwargs: Any - ) -> Optional["_models.WhatIfOperationResult"]: - cls = kwargs.pop('cls', None) # type: ClsType[Optional["_models.WhatIfOperationResult"]] + ) -> Optional[_models.WhatIfOperationResult]: error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) - api_version = kwargs.pop('api_version', "2019-08-01") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - _json = self._serialize.body(parameters, 'DeploymentWhatIf') + api_version = kwargs.pop("api_version", _params.pop("api-version", "2019-08-01")) # type: str + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[Optional[_models.WhatIfOperationResult]] - request = build_deployments_what_if_request_initial( + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(parameters, (IO, bytes)): + _content = parameters + else: + _json = self._serialize.body(parameters, "DeploymentWhatIf") + + request = build_deployments_what_if_request( resource_group_name=resource_group_name, deployment_name=deployment_name, subscription_id=self._config.subscription_id, api_version=api_version, content_type=content_type, json=_json, - template_url=self._what_if_initial.metadata['url'], + content=_content, + template_url=self._what_if_initial.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200, 202]: @@ -6417,39 +6796,42 @@ def _what_if_initial( deserialized = None response_headers = {} if response.status_code == 200: - deserialized = self._deserialize('WhatIfOperationResult', pipeline_response) + deserialized = self._deserialize("WhatIfOperationResult", pipeline_response) if response.status_code == 202: - response_headers['Location']=self._deserialize('str', response.headers.get('Location')) - response_headers['Retry-After']=self._deserialize('str', response.headers.get('Retry-After')) - + response_headers["Location"] = self._deserialize("str", response.headers.get("Location")) + response_headers["Retry-After"] = self._deserialize("str", response.headers.get("Retry-After")) if cls: return cls(pipeline_response, deserialized, response_headers) return deserialized - _what_if_initial.metadata = {'url': "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/Microsoft.Resources/deployments/{deploymentName}/whatIf"} # type: ignore + _what_if_initial.metadata = {"url": "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/Microsoft.Resources/deployments/{deploymentName}/whatIf"} # type: ignore - - @distributed_trace + @overload def begin_what_if( self, resource_group_name: str, deployment_name: str, - parameters: "_models.DeploymentWhatIf", + parameters: _models.DeploymentWhatIf, + *, + content_type: str = "application/json", **kwargs: Any - ) -> LROPoller["_models.WhatIfOperationResult"]: + ) -> LROPoller[_models.WhatIfOperationResult]: """Returns changes that will be made by the deployment if executed at the scope of the resource group. :param resource_group_name: The name of the resource group the template will be deployed to. - The name is case insensitive. + The name is case insensitive. Required. :type resource_group_name: str - :param deployment_name: The name of the deployment. + :param deployment_name: The name of the deployment. Required. :type deployment_name: str - :param parameters: Parameters to validate. + :param parameters: Parameters to validate. Required. :type parameters: ~azure.mgmt.resource.resources.v2019_08_01.models.DeploymentWhatIf + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str :keyword callable cls: A custom type or function that will be passed the direct response :keyword str continuation_token: A continuation token to restart a poller from a saved state. :keyword polling: By default, your polling method will be ARMPolling. Pass in False for this @@ -6462,121 +6844,199 @@ def begin_what_if( cls(response) :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.resource.resources.v2019_08_01.models.WhatIfOperationResult] - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - api_version = kwargs.pop('api_version', "2019-08-01") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] - polling = kwargs.pop('polling', True) # type: Union[bool, PollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType["_models.WhatIfOperationResult"] - lro_delay = kwargs.pop( - 'polling_interval', - self._config.polling_interval - ) - cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] - if cont_token is None: - raw_result = self._what_if_initial( - resource_group_name=resource_group_name, - deployment_name=deployment_name, - parameters=parameters, - api_version=api_version, - content_type=content_type, - cls=lambda x,y,z: x, - **kwargs - ) - kwargs.pop('error_map', None) - - def get_long_running_output(pipeline_response): - response = pipeline_response.http_response - deserialized = self._deserialize('WhatIfOperationResult', pipeline_response) - if cls: - return cls(pipeline_response, deserialized, {}) - return deserialized + @overload + def begin_what_if( + self, + resource_group_name: str, + deployment_name: str, + parameters: IO, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> LROPoller[_models.WhatIfOperationResult]: + """Returns changes that will be made by the deployment if executed at the scope of the resource + group. - if polling is True: polling_method = ARMPolling(lro_delay, lro_options={'final-state-via': 'location'}, **kwargs) - elif polling is False: polling_method = NoPolling() - else: polling_method = polling + :param resource_group_name: The name of the resource group the template will be deployed to. + The name is case insensitive. Required. + :type resource_group_name: str + :param deployment_name: The name of the deployment. Required. + :type deployment_name: str + :param parameters: Parameters to validate. Required. + :type parameters: IO + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be ARMPolling. Pass in False for this + operation to not poll, or pass in your own initialized polling object for a personal polling + strategy. + :paramtype polling: bool or ~azure.core.polling.PollingMethod + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of LROPoller that returns either WhatIfOperationResult or the result of + cls(response) + :rtype: + ~azure.core.polling.LROPoller[~azure.mgmt.resource.resources.v2019_08_01.models.WhatIfOperationResult] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace + def begin_what_if( + self, + resource_group_name: str, + deployment_name: str, + parameters: Union[_models.DeploymentWhatIf, IO], + **kwargs: Any + ) -> LROPoller[_models.WhatIfOperationResult]: + """Returns changes that will be made by the deployment if executed at the scope of the resource + group. + + :param resource_group_name: The name of the resource group the template will be deployed to. + The name is case insensitive. Required. + :type resource_group_name: str + :param deployment_name: The name of the deployment. Required. + :type deployment_name: str + :param parameters: Parameters to validate. Is either a model type or a IO type. Required. + :type parameters: ~azure.mgmt.resource.resources.v2019_08_01.models.DeploymentWhatIf or IO + :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. + Default value is None. + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be ARMPolling. Pass in False for this + operation to not poll, or pass in your own initialized polling object for a personal polling + strategy. + :paramtype polling: bool or ~azure.core.polling.PollingMethod + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of LROPoller that returns either WhatIfOperationResult or the result of + cls(response) + :rtype: + ~azure.core.polling.LROPoller[~azure.mgmt.resource.resources.v2019_08_01.models.WhatIfOperationResult] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _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", "2019-08-01")) # type: str + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.WhatIfOperationResult] + polling = kwargs.pop("polling", True) # type: Union[bool, PollingMethod] + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token = kwargs.pop("continuation_token", None) # type: Optional[str] + if cont_token is None: + raw_result = self._what_if_initial( # type: ignore + resource_group_name=resource_group_name, + deployment_name=deployment_name, + parameters=parameters, + api_version=api_version, + content_type=content_type, + cls=lambda x, y, z: x, + headers=_headers, + params=_params, + **kwargs + ) + kwargs.pop("error_map", None) + + def get_long_running_output(pipeline_response): + deserialized = self._deserialize("WhatIfOperationResult", pipeline_response) + if cls: + return cls(pipeline_response, deserialized, {}) + return deserialized + + if polling is True: + polling_method = cast( + PollingMethod, ARMPolling(lro_delay, lro_options={"final-state-via": "location"}, **kwargs) + ) # type: PollingMethod + elif polling is False: + polling_method = cast(PollingMethod, NoPolling()) + else: + polling_method = polling if cont_token: return LROPoller.from_continuation_token( polling_method=polling_method, continuation_token=cont_token, client=self._client, - deserialization_callback=get_long_running_output + deserialization_callback=get_long_running_output, ) return LROPoller(self._client, raw_result, get_long_running_output, polling_method) - begin_what_if.metadata = {'url': "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/Microsoft.Resources/deployments/{deploymentName}/whatIf"} # type: ignore + begin_what_if.metadata = {"url": "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/Microsoft.Resources/deployments/{deploymentName}/whatIf"} # type: ignore @distributed_trace def export_template( - self, - resource_group_name: str, - deployment_name: str, - **kwargs: Any - ) -> "_models.DeploymentExportResult": + self, resource_group_name: str, deployment_name: str, **kwargs: Any + ) -> _models.DeploymentExportResult: """Exports the template used for specified deployment. :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. :type resource_group_name: str - :param deployment_name: The name of the deployment. + :param deployment_name: The name of the deployment. Required. :type deployment_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: DeploymentExportResult, or the result of cls(response) + :return: DeploymentExportResult or the result of cls(response) :rtype: ~azure.mgmt.resource.resources.v2019_08_01.models.DeploymentExportResult - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.DeploymentExportResult"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + 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', "2019-08-01") # type: str + api_version = kwargs.pop("api_version", _params.pop("api-version", "2019-08-01")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[_models.DeploymentExportResult] - request = build_deployments_export_template_request( resource_group_name=resource_group_name, deployment_name=deployment_name, subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.export_template.metadata['url'], + template_url=self.export_template.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) - deserialized = self._deserialize('DeploymentExportResult', pipeline_response) + deserialized = self._deserialize("DeploymentExportResult", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - export_template.metadata = {'url': "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/Microsoft.Resources/deployments/{deploymentName}/exportTemplate"} # type: ignore - + export_template.metadata = {"url": "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/Microsoft.Resources/deployments/{deploymentName}/exportTemplate"} # type: ignore @distributed_trace def list_by_resource_group( - self, - resource_group_name: str, - filter: Optional[str] = None, - top: Optional[int] = None, - **kwargs: Any - ) -> Iterable["_models.DeploymentListResult"]: + self, resource_group_name: str, filter: Optional[str] = None, top: Optional[int] = None, **kwargs: Any + ) -> Iterable["_models.DeploymentExtended"]: """Get all the deployments for a resource group. :param resource_group_name: The name of the resource group with the deployments to get. The - name is case insensitive. + name is case insensitive. Required. :type resource_group_name: str :param filter: The filter to apply on the operation. For example, you can use $filter=provisioningState eq '{state}'. Default value is None. @@ -6585,42 +7045,49 @@ def list_by_resource_group( value is None. :type top: int :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either DeploymentListResult or the result of - cls(response) + :return: An iterator like instance of either DeploymentExtended or the result of cls(response) :rtype: - ~azure.core.paging.ItemPaged[~azure.mgmt.resource.resources.v2019_08_01.models.DeploymentListResult] - :raises: ~azure.core.exceptions.HttpResponseError + ~azure.core.paging.ItemPaged[~azure.mgmt.resource.resources.v2019_08_01.models.DeploymentExtended] + :raises ~azure.core.exceptions.HttpResponseError: """ - api_version = kwargs.pop('api_version', "2019-08-01") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2019-08-01")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[_models.DeploymentListResult] - cls = kwargs.pop('cls', None) # type: ClsType["_models.DeploymentListResult"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) + def prepare_request(next_link=None): if not next_link: - + request = build_deployments_list_by_resource_group_request( resource_group_name=resource_group_name, subscription_id=self._config.subscription_id, - api_version=api_version, filter=filter, top=top, - template_url=self.list_by_resource_group.metadata['url'], + 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.url = self._client.format_url(request.url) # type: ignore else: - - request = build_deployments_list_by_resource_group_request( - resource_group_name=resource_group_name, - subscription_id=self._config.subscription_id, - template_url=next_link, - ) + # make call to next link with the client's api-version + _parsed_next_link = urlparse(next_link) + _next_request_params = case_insensitive_dict(parse_qs(_parsed_next_link.query)) + _next_request_params["api-version"] = self._config.api_version + request = HttpRequest("GET", urljoin(next_link, _parsed_next_link.path), params=_next_request_params) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore request.method = "GET" return request @@ -6634,10 +7101,8 @@ def extract_data(pipeline_response): def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) response = pipeline_response.http_response @@ -6647,204 +7112,204 @@ def get_next(next_link=None): return pipeline_response + return ItemPaged(get_next, extract_data) - return ItemPaged( - get_next, extract_data - ) - list_by_resource_group.metadata = {'url': "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/Microsoft.Resources/deployments/"} # type: ignore + list_by_resource_group.metadata = {"url": "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/Microsoft.Resources/deployments/"} # type: ignore @distributed_trace - def calculate_template_hash( - self, - template: Any, - **kwargs: Any - ) -> "_models.TemplateHashResult": + def calculate_template_hash(self, template: JSON, **kwargs: Any) -> _models.TemplateHashResult: """Calculate the hash of the given template. - :param template: The template provided to calculate hash. - :type template: any + :param template: The template provided to calculate hash. Required. + :type template: JSON :keyword callable cls: A custom type or function that will be passed the direct response - :return: TemplateHashResult, or the result of cls(response) + :return: TemplateHashResult or the result of cls(response) :rtype: ~azure.mgmt.resource.resources.v2019_08_01.models.TemplateHashResult - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.TemplateHashResult"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', "2019-08-01") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + api_version = kwargs.pop("api_version", _params.pop("api-version", "2019-08-01")) # type: str + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", "application/json")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[_models.TemplateHashResult] - _json = self._serialize.body(template, 'object') + _json = self._serialize.body(template, "object") request = build_deployments_calculate_template_hash_request( api_version=api_version, content_type=content_type, json=_json, - template_url=self.calculate_template_hash.metadata['url'], + template_url=self.calculate_template_hash.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) - deserialized = self._deserialize('TemplateHashResult', pipeline_response) + deserialized = self._deserialize("TemplateHashResult", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - calculate_template_hash.metadata = {'url': "/providers/Microsoft.Resources/calculateTemplateHash"} # type: ignore + calculate_template_hash.metadata = {"url": "/providers/Microsoft.Resources/calculateTemplateHash"} # type: ignore -class ProvidersOperations(object): - """ProvidersOperations operations. - You should not instantiate this class directly. Instead, you should create a Client instance that - instantiates it for you and attaches it as an attribute. +class ProvidersOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. - :ivar models: Alias to model classes used in this operation group. - :type models: ~azure.mgmt.resource.resources.v2019_08_01.models - :param client: Client for service requests. - :param config: Configuration of service client. - :param serializer: An object model serializer. - :param deserializer: An object model deserializer. + Instead, you should access the following operations through + :class:`~azure.mgmt.resource.resources.v2019_08_01.ResourceManagementClient`'s + :attr:`providers` attribute. """ models = _models - def __init__(self, client, config, serializer, deserializer): - self._client = client - self._serialize = serializer - self._deserialize = deserializer - self._config = config + def __init__(self, *args, **kwargs): + input_args = list(args) + self._client = input_args.pop(0) if input_args else kwargs.pop("client") + self._config = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") @distributed_trace - def unregister( - self, - resource_provider_namespace: str, - **kwargs: Any - ) -> "_models.Provider": + def unregister(self, resource_provider_namespace: str, **kwargs: Any) -> _models.Provider: """Unregisters a subscription from a resource provider. :param resource_provider_namespace: The namespace of the resource provider to unregister. + Required. :type resource_provider_namespace: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: Provider, or the result of cls(response) + :return: Provider or the result of cls(response) :rtype: ~azure.mgmt.resource.resources.v2019_08_01.models.Provider - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.Provider"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + 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', "2019-08-01") # type: str + api_version = kwargs.pop("api_version", _params.pop("api-version", "2019-08-01")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[_models.Provider] - request = build_providers_unregister_request( resource_provider_namespace=resource_provider_namespace, subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.unregister.metadata['url'], + template_url=self.unregister.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) - deserialized = self._deserialize('Provider', pipeline_response) + deserialized = self._deserialize("Provider", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - unregister.metadata = {'url': "/subscriptions/{subscriptionId}/providers/{resourceProviderNamespace}/unregister"} # type: ignore - + unregister.metadata = {"url": "/subscriptions/{subscriptionId}/providers/{resourceProviderNamespace}/unregister"} # type: ignore @distributed_trace - def register( - self, - resource_provider_namespace: str, - **kwargs: Any - ) -> "_models.Provider": + def register(self, resource_provider_namespace: str, **kwargs: Any) -> _models.Provider: """Registers a subscription with a resource provider. :param resource_provider_namespace: The namespace of the resource provider to register. + Required. :type resource_provider_namespace: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: Provider, or the result of cls(response) + :return: Provider or the result of cls(response) :rtype: ~azure.mgmt.resource.resources.v2019_08_01.models.Provider - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.Provider"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + 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', "2019-08-01") # type: str + api_version = kwargs.pop("api_version", _params.pop("api-version", "2019-08-01")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[_models.Provider] - request = build_providers_register_request( resource_provider_namespace=resource_provider_namespace, subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.register.metadata['url'], + template_url=self.register.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) - deserialized = self._deserialize('Provider', pipeline_response) + deserialized = self._deserialize("Provider", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - register.metadata = {'url': "/subscriptions/{subscriptionId}/providers/{resourceProviderNamespace}/register"} # type: ignore - + register.metadata = {"url": "/subscriptions/{subscriptionId}/providers/{resourceProviderNamespace}/register"} # type: ignore @distributed_trace def list( - self, - top: Optional[int] = None, - expand: Optional[str] = None, - **kwargs: Any - ) -> Iterable["_models.ProviderListResult"]: + self, top: Optional[int] = None, expand: Optional[str] = None, **kwargs: Any + ) -> Iterable["_models.Provider"]: """Gets all resource providers for a subscription. :param top: The number of results to return. If null is passed returns all deployments. Default @@ -6855,39 +7320,48 @@ def list( response, use $expand=resourceTypes/aliases. Default value is None. :type expand: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either ProviderListResult or the result of cls(response) + :return: An iterator like instance of either Provider or the result of cls(response) :rtype: - ~azure.core.paging.ItemPaged[~azure.mgmt.resource.resources.v2019_08_01.models.ProviderListResult] - :raises: ~azure.core.exceptions.HttpResponseError + ~azure.core.paging.ItemPaged[~azure.mgmt.resource.resources.v2019_08_01.models.Provider] + :raises ~azure.core.exceptions.HttpResponseError: """ - api_version = kwargs.pop('api_version', "2019-08-01") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2019-08-01")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[_models.ProviderListResult] - cls = kwargs.pop('cls', None) # type: ClsType["_models.ProviderListResult"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) + def prepare_request(next_link=None): if not next_link: - + request = build_providers_list_request( subscription_id=self._config.subscription_id, - api_version=api_version, top=top, expand=expand, - template_url=self.list.metadata['url'], + 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.url = self._client.format_url(request.url) # type: ignore else: - - request = build_providers_list_request( - subscription_id=self._config.subscription_id, - template_url=next_link, - ) + # make call to next link with the client's api-version + _parsed_next_link = urlparse(next_link) + _next_request_params = case_insensitive_dict(parse_qs(_parsed_next_link.query)) + _next_request_params["api-version"] = self._config.api_version + request = HttpRequest("GET", urljoin(next_link, _parsed_next_link.path), params=_next_request_params) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore request.method = "GET" return request @@ -6901,10 +7375,8 @@ def extract_data(pipeline_response): def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) response = pipeline_response.http_response @@ -6914,19 +7386,14 @@ def get_next(next_link=None): return pipeline_response + return ItemPaged(get_next, extract_data) - return ItemPaged( - get_next, extract_data - ) - list.metadata = {'url': "/subscriptions/{subscriptionId}/providers"} # type: ignore + list.metadata = {"url": "/subscriptions/{subscriptionId}/providers"} # type: ignore @distributed_trace def list_at_tenant_scope( - self, - top: Optional[int] = None, - expand: Optional[str] = None, - **kwargs: Any - ) -> Iterable["_models.ProviderListResult"]: + self, top: Optional[int] = None, expand: Optional[str] = None, **kwargs: Any + ) -> Iterable["_models.Provider"]: """Gets all resource providers for the tenant. :param top: The number of results to return. If null is passed returns all providers. Default @@ -6937,37 +7404,47 @@ def list_at_tenant_scope( response, use $expand=resourceTypes/aliases. Default value is None. :type expand: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either ProviderListResult or the result of cls(response) + :return: An iterator like instance of either Provider or the result of cls(response) :rtype: - ~azure.core.paging.ItemPaged[~azure.mgmt.resource.resources.v2019_08_01.models.ProviderListResult] - :raises: ~azure.core.exceptions.HttpResponseError + ~azure.core.paging.ItemPaged[~azure.mgmt.resource.resources.v2019_08_01.models.Provider] + :raises ~azure.core.exceptions.HttpResponseError: """ - api_version = kwargs.pop('api_version', "2019-08-01") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2019-08-01")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[_models.ProviderListResult] - cls = kwargs.pop('cls', None) # type: ClsType["_models.ProviderListResult"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) + def prepare_request(next_link=None): if not next_link: - + request = build_providers_list_at_tenant_scope_request( - api_version=api_version, top=top, expand=expand, - template_url=self.list_at_tenant_scope.metadata['url'], + api_version=api_version, + template_url=self.list_at_tenant_scope.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore else: - - request = build_providers_list_at_tenant_scope_request( - template_url=next_link, - ) + # make call to next link with the client's api-version + _parsed_next_link = urlparse(next_link) + _next_request_params = case_insensitive_dict(parse_qs(_parsed_next_link.query)) + _next_request_params["api-version"] = self._config.api_version + request = HttpRequest("GET", urljoin(next_link, _parsed_next_link.path), params=_next_request_params) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore request.method = "GET" return request @@ -6981,10 +7458,8 @@ def extract_data(pipeline_response): def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) response = pipeline_response.http_response @@ -6994,149 +7469,148 @@ def get_next(next_link=None): return pipeline_response + return ItemPaged(get_next, extract_data) - return ItemPaged( - get_next, extract_data - ) - list_at_tenant_scope.metadata = {'url': "/providers"} # type: ignore + list_at_tenant_scope.metadata = {"url": "/providers"} # type: ignore @distributed_trace - def get( - self, - resource_provider_namespace: str, - expand: Optional[str] = None, - **kwargs: Any - ) -> "_models.Provider": + def get(self, resource_provider_namespace: str, expand: Optional[str] = None, **kwargs: Any) -> _models.Provider: """Gets the specified resource provider. - :param resource_provider_namespace: The namespace of the resource provider. + :param resource_provider_namespace: The namespace of the resource provider. Required. :type resource_provider_namespace: str :param expand: The $expand query parameter. For example, to include property aliases in response, use $expand=resourceTypes/aliases. Default value is None. :type expand: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: Provider, or the result of cls(response) + :return: Provider or the result of cls(response) :rtype: ~azure.mgmt.resource.resources.v2019_08_01.models.Provider - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.Provider"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) - api_version = kwargs.pop('api_version', "2019-08-01") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2019-08-01")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[_models.Provider] - request = build_providers_get_request( resource_provider_namespace=resource_provider_namespace, subscription_id=self._config.subscription_id, - api_version=api_version, expand=expand, - template_url=self.get.metadata['url'], + api_version=api_version, + template_url=self.get.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) - deserialized = self._deserialize('Provider', pipeline_response) + deserialized = self._deserialize("Provider", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - get.metadata = {'url': "/subscriptions/{subscriptionId}/providers/{resourceProviderNamespace}"} # type: ignore - + get.metadata = {"url": "/subscriptions/{subscriptionId}/providers/{resourceProviderNamespace}"} # type: ignore @distributed_trace def get_at_tenant_scope( - self, - resource_provider_namespace: str, - expand: Optional[str] = None, - **kwargs: Any - ) -> "_models.Provider": + self, resource_provider_namespace: str, expand: Optional[str] = None, **kwargs: Any + ) -> _models.Provider: """Gets the specified resource provider at the tenant level. - :param resource_provider_namespace: The namespace of the resource provider. + :param resource_provider_namespace: The namespace of the resource provider. Required. :type resource_provider_namespace: str :param expand: The $expand query parameter. For example, to include property aliases in response, use $expand=resourceTypes/aliases. Default value is None. :type expand: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: Provider, or the result of cls(response) + :return: Provider or the result of cls(response) :rtype: ~azure.mgmt.resource.resources.v2019_08_01.models.Provider - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.Provider"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + 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', "2019-08-01") # type: str + api_version = kwargs.pop("api_version", _params.pop("api-version", "2019-08-01")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[_models.Provider] - request = build_providers_get_at_tenant_scope_request( resource_provider_namespace=resource_provider_namespace, - api_version=api_version, expand=expand, - template_url=self.get_at_tenant_scope.metadata['url'], + api_version=api_version, + template_url=self.get_at_tenant_scope.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) - deserialized = self._deserialize('Provider', pipeline_response) + deserialized = self._deserialize("Provider", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - get_at_tenant_scope.metadata = {'url': "/providers/{resourceProviderNamespace}"} # type: ignore + get_at_tenant_scope.metadata = {"url": "/providers/{resourceProviderNamespace}"} # type: ignore -class ResourcesOperations(object): # pylint: disable=too-many-public-methods - """ResourcesOperations operations. - You should not instantiate this class directly. Instead, you should create a Client instance that - instantiates it for you and attaches it as an attribute. +class ResourcesOperations: # pylint: disable=too-many-public-methods + """ + .. warning:: + **DO NOT** instantiate this class directly. - :ivar models: Alias to model classes used in this operation group. - :type models: ~azure.mgmt.resource.resources.v2019_08_01.models - :param client: Client for service requests. - :param config: Configuration of service client. - :param serializer: An object model serializer. - :param deserializer: An object model deserializer. + Instead, you should access the following operations through + :class:`~azure.mgmt.resource.resources.v2019_08_01.ResourceManagementClient`'s + :attr:`resources` attribute. """ models = _models - def __init__(self, client, config, serializer, deserializer): - self._client = client - self._serialize = serializer - self._deserialize = deserializer - self._config = config + def __init__(self, *args, **kwargs): + input_args = list(args) + self._client = input_args.pop(0) if input_args else kwargs.pop("client") + self._config = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") @distributed_trace def list_by_resource_group( @@ -7146,10 +7620,10 @@ def list_by_resource_group( expand: Optional[str] = None, top: Optional[int] = None, **kwargs: Any - ) -> Iterable["_models.ResourceListResult"]: + ) -> Iterable["_models.GenericResourceExpanded"]: """Get all the resources for a resource group. - :param resource_group_name: The resource group with the resources to get. + :param resource_group_name: The resource group with the resources to get. Required. :type resource_group_name: str :param filter: The filter to apply on the operation.:code:`
`:code:`
`The properties you can use for eq (equals) or ne (not equals) are: location, resourceType, name, resourceGroup, @@ -7175,42 +7649,51 @@ def list_by_resource_group( value is None. :type top: int :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either ResourceListResult or the result of cls(response) + :return: An iterator like instance of either GenericResourceExpanded or the result of + cls(response) :rtype: - ~azure.core.paging.ItemPaged[~azure.mgmt.resource.resources.v2019_08_01.models.ResourceListResult] - :raises: ~azure.core.exceptions.HttpResponseError + ~azure.core.paging.ItemPaged[~azure.mgmt.resource.resources.v2019_08_01.models.GenericResourceExpanded] + :raises ~azure.core.exceptions.HttpResponseError: """ - api_version = kwargs.pop('api_version', "2019-08-01") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2019-08-01")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[_models.ResourceListResult] - cls = kwargs.pop('cls', None) # type: ClsType["_models.ResourceListResult"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) + def prepare_request(next_link=None): if not next_link: - + request = build_resources_list_by_resource_group_request( resource_group_name=resource_group_name, subscription_id=self._config.subscription_id, - api_version=api_version, filter=filter, expand=expand, top=top, - template_url=self.list_by_resource_group.metadata['url'], + 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.url = self._client.format_url(request.url) # type: ignore else: - - request = build_resources_list_by_resource_group_request( - resource_group_name=resource_group_name, - subscription_id=self._config.subscription_id, - template_url=next_link, - ) + # make call to next link with the client's api-version + _parsed_next_link = urlparse(next_link) + _next_request_params = case_insensitive_dict(parse_qs(_parsed_next_link.query)) + _next_request_params["api-version"] = self._config.api_version + request = HttpRequest("GET", urljoin(next_link, _parsed_next_link.path), params=_next_request_params) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore request.method = "GET" return request @@ -7224,10 +7707,8 @@ def extract_data(pipeline_response): def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) response = pipeline_response.http_response @@ -7237,45 +7718,54 @@ def get_next(next_link=None): return pipeline_response + return ItemPaged(get_next, extract_data) - return ItemPaged( - get_next, extract_data - ) - list_by_resource_group.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/resources"} # type: ignore + list_by_resource_group.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/resources"} # type: ignore def _move_resources_initial( # pylint: disable=inconsistent-return-statements - self, - source_resource_group_name: str, - parameters: "_models.ResourcesMoveInfo", - **kwargs: Any + self, source_resource_group_name: str, parameters: Union[_models.ResourcesMoveInfo, IO], **kwargs: Any ) -> None: - cls = kwargs.pop('cls', None) # type: ClsType[None] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', "2019-08-01") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + api_version = kwargs.pop("api_version", _params.pop("api-version", "2019-08-01")) # type: str + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[None] - _json = self._serialize.body(parameters, 'ResourcesMoveInfo') + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(parameters, (IO, bytes)): + _content = parameters + else: + _json = self._serialize.body(parameters, "ResourcesMoveInfo") - request = build_resources_move_resources_request_initial( + request = build_resources_move_resources_request( source_resource_group_name=source_resource_group_name, subscription_id=self._config.subscription_id, api_version=api_version, content_type=content_type, json=_json, - template_url=self._move_resources_initial.metadata['url'], + content=_content, + template_url=self._move_resources_initial.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [202, 204]: @@ -7285,14 +7775,15 @@ def _move_resources_initial( # pylint: disable=inconsistent-return-statements if cls: return cls(pipeline_response, None, {}) - _move_resources_initial.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{sourceResourceGroupName}/moveResources"} # type: ignore - + _move_resources_initial.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{sourceResourceGroupName}/moveResources"} # type: ignore - @distributed_trace - def begin_move_resources( # pylint: disable=inconsistent-return-statements + @overload + def begin_move_resources( self, source_resource_group_name: str, - parameters: "_models.ResourcesMoveInfo", + parameters: _models.ResourcesMoveInfo, + *, + content_type: str = "application/json", **kwargs: Any ) -> LROPoller[None]: """Moves resources from one resource group to another resource group. @@ -7303,10 +7794,13 @@ def begin_move_resources( # pylint: disable=inconsistent-return-statements the groups until the move completes. :param source_resource_group_name: The name of the resource group containing the resources to - move. + move. Required. :type source_resource_group_name: str - :param parameters: Parameters for moving resources. + :param parameters: Parameters for moving resources. Required. :type parameters: ~azure.mgmt.resource.resources.v2019_08_01.models.ResourcesMoveInfo + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str :keyword callable cls: A custom type or function that will be passed the direct response :keyword str continuation_token: A continuation token to restart a poller from a saved state. :keyword polling: By default, your polling method will be ARMPolling. Pass in False for this @@ -7317,80 +7811,160 @@ def begin_move_resources( # pylint: disable=inconsistent-return-statements Retry-After header is present. :return: An instance of LROPoller that returns either None or the result of cls(response) :rtype: ~azure.core.polling.LROPoller[None] - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - api_version = kwargs.pop('api_version', "2019-08-01") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] - polling = kwargs.pop('polling', True) # type: Union[bool, PollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType[None] - lro_delay = kwargs.pop( - 'polling_interval', - self._config.polling_interval - ) - cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] + + @overload + def begin_move_resources( + self, source_resource_group_name: str, parameters: IO, *, content_type: str = "application/json", **kwargs: Any + ) -> LROPoller[None]: + """Moves resources from one resource group to another resource group. + + The resources to move must be in the same source resource group. The target resource group may + be in a different subscription. When moving resources, both the source group and the target + group are locked for the duration of the operation. Write and delete operations are blocked on + the groups until the move completes. + + :param source_resource_group_name: The name of the resource group containing the resources to + move. Required. + :type source_resource_group_name: str + :param parameters: Parameters for moving resources. Required. + :type parameters: IO + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be ARMPolling. Pass in False for this + operation to not poll, or pass in your own initialized polling object for a personal polling + strategy. + :paramtype polling: bool or ~azure.core.polling.PollingMethod + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of LROPoller that returns either None or the result of cls(response) + :rtype: ~azure.core.polling.LROPoller[None] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace + def begin_move_resources( + self, source_resource_group_name: str, parameters: Union[_models.ResourcesMoveInfo, IO], **kwargs: Any + ) -> LROPoller[None]: + """Moves resources from one resource group to another resource group. + + The resources to move must be in the same source resource group. The target resource group may + be in a different subscription. When moving resources, both the source group and the target + group are locked for the duration of the operation. Write and delete operations are blocked on + the groups until the move completes. + + :param source_resource_group_name: The name of the resource group containing the resources to + move. Required. + :type source_resource_group_name: str + :param parameters: Parameters for moving resources. Is either a model type or a IO type. + Required. + :type parameters: ~azure.mgmt.resource.resources.v2019_08_01.models.ResourcesMoveInfo or IO + :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. + Default value is None. + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be ARMPolling. Pass in False for this + operation to not poll, or pass in your own initialized polling object for a personal polling + strategy. + :paramtype polling: bool or ~azure.core.polling.PollingMethod + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of LROPoller that returns either None or the result of cls(response) + :rtype: ~azure.core.polling.LROPoller[None] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _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", "2019-08-01")) # type: str + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[None] + polling = kwargs.pop("polling", True) # type: Union[bool, PollingMethod] + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token = kwargs.pop("continuation_token", None) # type: Optional[str] if cont_token is None: - raw_result = self._move_resources_initial( + raw_result = self._move_resources_initial( # type: ignore source_resource_group_name=source_resource_group_name, parameters=parameters, api_version=api_version, content_type=content_type, - cls=lambda x,y,z: x, + cls=lambda x, y, z: x, + headers=_headers, + params=_params, **kwargs ) - kwargs.pop('error_map', None) + kwargs.pop("error_map", None) - def get_long_running_output(pipeline_response): + def get_long_running_output(pipeline_response): # pylint: disable=inconsistent-return-statements if cls: return cls(pipeline_response, None, {}) - - if polling is True: polling_method = ARMPolling(lro_delay, **kwargs) - elif polling is False: polling_method = NoPolling() - else: polling_method = polling + if polling is True: + polling_method = cast(PollingMethod, ARMPolling(lro_delay, **kwargs)) # type: PollingMethod + elif polling is False: + polling_method = cast(PollingMethod, NoPolling()) + else: + polling_method = polling if cont_token: return LROPoller.from_continuation_token( polling_method=polling_method, continuation_token=cont_token, client=self._client, - deserialization_callback=get_long_running_output + deserialization_callback=get_long_running_output, ) return LROPoller(self._client, raw_result, get_long_running_output, polling_method) - begin_move_resources.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{sourceResourceGroupName}/moveResources"} # type: ignore + begin_move_resources.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{sourceResourceGroupName}/moveResources"} # type: ignore def _validate_move_resources_initial( # pylint: disable=inconsistent-return-statements - self, - source_resource_group_name: str, - parameters: "_models.ResourcesMoveInfo", - **kwargs: Any + self, source_resource_group_name: str, parameters: Union[_models.ResourcesMoveInfo, IO], **kwargs: Any ) -> None: - cls = kwargs.pop('cls', None) # type: ClsType[None] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', "2019-08-01") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + api_version = kwargs.pop("api_version", _params.pop("api-version", "2019-08-01")) # type: str + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[None] - _json = self._serialize.body(parameters, 'ResourcesMoveInfo') + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(parameters, (IO, bytes)): + _content = parameters + else: + _json = self._serialize.body(parameters, "ResourcesMoveInfo") - request = build_resources_validate_move_resources_request_initial( + request = build_resources_validate_move_resources_request( source_resource_group_name=source_resource_group_name, subscription_id=self._config.subscription_id, api_version=api_version, content_type=content_type, json=_json, - template_url=self._validate_move_resources_initial.metadata['url'], + content=_content, + template_url=self._validate_move_resources_initial.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [202, 204]: @@ -7400,14 +7974,15 @@ def _validate_move_resources_initial( # pylint: disable=inconsistent-return-sta if cls: return cls(pipeline_response, None, {}) - _validate_move_resources_initial.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{sourceResourceGroupName}/validateMoveResources"} # type: ignore - + _validate_move_resources_initial.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{sourceResourceGroupName}/validateMoveResources"} # type: ignore - @distributed_trace - def begin_validate_move_resources( # pylint: disable=inconsistent-return-statements + @overload + def begin_validate_move_resources( self, source_resource_group_name: str, - parameters: "_models.ResourcesMoveInfo", + parameters: _models.ResourcesMoveInfo, + *, + content_type: str = "application/json", **kwargs: Any ) -> LROPoller[None]: """Validates whether resources can be moved from one resource group to another resource group. @@ -7420,10 +7995,13 @@ def begin_validate_move_resources( # pylint: disable=inconsistent-return-statem operation. :param source_resource_group_name: The name of the resource group containing the resources to - validate for move. + validate for move. Required. :type source_resource_group_name: str - :param parameters: Parameters for moving resources. + :param parameters: Parameters for moving resources. Required. :type parameters: ~azure.mgmt.resource.resources.v2019_08_01.models.ResourcesMoveInfo + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str :keyword callable cls: A custom type or function that will be passed the direct response :keyword str continuation_token: A continuation token to restart a poller from a saved state. :keyword polling: By default, your polling method will be ARMPolling. Pass in False for this @@ -7434,56 +8012,125 @@ def begin_validate_move_resources( # pylint: disable=inconsistent-return-statem Retry-After header is present. :return: An instance of LROPoller that returns either None or the result of cls(response) :rtype: ~azure.core.polling.LROPoller[None] - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - api_version = kwargs.pop('api_version', "2019-08-01") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] - polling = kwargs.pop('polling', True) # type: Union[bool, PollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType[None] - lro_delay = kwargs.pop( - 'polling_interval', - self._config.polling_interval - ) - cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] - if cont_token is None: - raw_result = self._validate_move_resources_initial( - source_resource_group_name=source_resource_group_name, - parameters=parameters, - api_version=api_version, - content_type=content_type, - cls=lambda x,y,z: x, - **kwargs - ) - kwargs.pop('error_map', None) - - def get_long_running_output(pipeline_response): - if cls: - return cls(pipeline_response, None, {}) - - - if polling is True: polling_method = ARMPolling(lro_delay, **kwargs) - elif polling is False: polling_method = NoPolling() - else: polling_method = polling - if cont_token: - return LROPoller.from_continuation_token( - polling_method=polling_method, - continuation_token=cont_token, - client=self._client, - deserialization_callback=get_long_running_output - ) - return LROPoller(self._client, raw_result, get_long_running_output, polling_method) - begin_validate_move_resources.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{sourceResourceGroupName}/validateMoveResources"} # type: ignore + @overload + def begin_validate_move_resources( + self, source_resource_group_name: str, parameters: IO, *, content_type: str = "application/json", **kwargs: Any + ) -> LROPoller[None]: + """Validates whether resources can be moved from one resource group to another resource group. - @distributed_trace - def list( - self, - filter: Optional[str] = None, - expand: Optional[str] = None, - top: Optional[int] = None, - **kwargs: Any - ) -> Iterable["_models.ResourceListResult"]: - """Get all the resources in a subscription. + This operation checks whether the specified resources can be moved to the target. The resources + to move must be in the same source resource group. The target resource group may be in a + different subscription. If validation succeeds, it returns HTTP response code 204 (no content). + If validation fails, it returns HTTP response code 409 (Conflict) with an error message. + Retrieve the URL in the Location header value to check the result of the long-running + operation. + + :param source_resource_group_name: The name of the resource group containing the resources to + validate for move. Required. + :type source_resource_group_name: str + :param parameters: Parameters for moving resources. Required. + :type parameters: IO + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be ARMPolling. Pass in False for this + operation to not poll, or pass in your own initialized polling object for a personal polling + strategy. + :paramtype polling: bool or ~azure.core.polling.PollingMethod + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of LROPoller that returns either None or the result of cls(response) + :rtype: ~azure.core.polling.LROPoller[None] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace + def begin_validate_move_resources( + self, source_resource_group_name: str, parameters: Union[_models.ResourcesMoveInfo, IO], **kwargs: Any + ) -> LROPoller[None]: + """Validates whether resources can be moved from one resource group to another resource group. + + This operation checks whether the specified resources can be moved to the target. The resources + to move must be in the same source resource group. The target resource group may be in a + different subscription. If validation succeeds, it returns HTTP response code 204 (no content). + If validation fails, it returns HTTP response code 409 (Conflict) with an error message. + Retrieve the URL in the Location header value to check the result of the long-running + operation. + + :param source_resource_group_name: The name of the resource group containing the resources to + validate for move. Required. + :type source_resource_group_name: str + :param parameters: Parameters for moving resources. Is either a model type or a IO type. + Required. + :type parameters: ~azure.mgmt.resource.resources.v2019_08_01.models.ResourcesMoveInfo or IO + :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. + Default value is None. + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be ARMPolling. Pass in False for this + operation to not poll, or pass in your own initialized polling object for a personal polling + strategy. + :paramtype polling: bool or ~azure.core.polling.PollingMethod + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of LROPoller that returns either None or the result of cls(response) + :rtype: ~azure.core.polling.LROPoller[None] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _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", "2019-08-01")) # type: str + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[None] + polling = kwargs.pop("polling", True) # type: Union[bool, PollingMethod] + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token = kwargs.pop("continuation_token", None) # type: Optional[str] + if cont_token is None: + raw_result = self._validate_move_resources_initial( # type: ignore + source_resource_group_name=source_resource_group_name, + parameters=parameters, + api_version=api_version, + content_type=content_type, + cls=lambda x, y, z: x, + headers=_headers, + params=_params, + **kwargs + ) + kwargs.pop("error_map", None) + + def get_long_running_output(pipeline_response): # pylint: disable=inconsistent-return-statements + if cls: + return cls(pipeline_response, None, {}) + + if polling is True: + polling_method = cast(PollingMethod, ARMPolling(lro_delay, **kwargs)) # type: PollingMethod + elif polling is False: + polling_method = cast(PollingMethod, NoPolling()) + else: + polling_method = polling + if cont_token: + return LROPoller.from_continuation_token( + polling_method=polling_method, + continuation_token=cont_token, + client=self._client, + deserialization_callback=get_long_running_output, + ) + return LROPoller(self._client, raw_result, get_long_running_output, polling_method) + + begin_validate_move_resources.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{sourceResourceGroupName}/validateMoveResources"} # type: ignore + + @distributed_trace + def list( + self, filter: Optional[str] = None, expand: Optional[str] = None, top: Optional[int] = None, **kwargs: Any + ) -> Iterable["_models.GenericResourceExpanded"]: + """Get all the resources in a subscription. :param filter: The filter to apply on the operation.:code:`
`:code:`
`The properties you can use for eq (equals) or ne (not equals) are: location, resourceType, name, resourceGroup, @@ -7509,40 +8156,50 @@ def list( value is None. :type top: int :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either ResourceListResult or the result of cls(response) + :return: An iterator like instance of either GenericResourceExpanded or the result of + cls(response) :rtype: - ~azure.core.paging.ItemPaged[~azure.mgmt.resource.resources.v2019_08_01.models.ResourceListResult] - :raises: ~azure.core.exceptions.HttpResponseError + ~azure.core.paging.ItemPaged[~azure.mgmt.resource.resources.v2019_08_01.models.GenericResourceExpanded] + :raises ~azure.core.exceptions.HttpResponseError: """ - api_version = kwargs.pop('api_version', "2019-08-01") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2019-08-01")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[_models.ResourceListResult] - cls = kwargs.pop('cls', None) # type: ClsType["_models.ResourceListResult"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) + def prepare_request(next_link=None): if not next_link: - + request = build_resources_list_request( subscription_id=self._config.subscription_id, - api_version=api_version, filter=filter, expand=expand, top=top, - template_url=self.list.metadata['url'], + 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.url = self._client.format_url(request.url) # type: ignore else: - - request = build_resources_list_request( - subscription_id=self._config.subscription_id, - template_url=next_link, - ) + # make call to next link with the client's api-version + _parsed_next_link = urlparse(next_link) + _next_request_params = case_insensitive_dict(parse_qs(_parsed_next_link.query)) + _next_request_params["api-version"] = self._config.api_version + request = HttpRequest("GET", urljoin(next_link, _parsed_next_link.path), params=_next_request_params) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore request.method = "GET" return request @@ -7556,10 +8213,8 @@ def extract_data(pipeline_response): def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) response = pipeline_response.http_response @@ -7569,11 +8224,9 @@ def get_next(next_link=None): return pipeline_response + return ItemPaged(get_next, extract_data) - return ItemPaged( - get_next, extract_data - ) - list.metadata = {'url': "/subscriptions/{subscriptionId}/resources"} # type: ignore + list.metadata = {"url": "/subscriptions/{subscriptionId}/resources"} # type: ignore @distributed_trace def check_existence( @@ -7589,30 +8242,36 @@ def check_existence( """Checks whether a resource exists. :param resource_group_name: The name of the resource group containing the resource to check. - The name is case insensitive. + The name is case insensitive. Required. :type resource_group_name: str - :param resource_provider_namespace: The resource provider of the resource to check. + :param resource_provider_namespace: The resource provider of the resource to check. Required. :type resource_provider_namespace: str - :param parent_resource_path: The parent resource identity. + :param parent_resource_path: The parent resource identity. Required. :type parent_resource_path: str - :param resource_type: The resource type. + :param resource_type: The resource type. Required. :type resource_type: str - :param resource_name: The name of the resource to check whether it exists. + :param resource_name: The name of the resource to check whether it exists. Required. :type resource_name: str - :param api_version: The API version to use for the operation. + :param api_version: The API version to use for the operation. Required. :type api_version: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: bool, or the result of cls(response) + :return: bool or the result of cls(response) :rtype: bool - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType[None] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = kwargs.pop("params", {}) or {} + + cls = kwargs.pop("cls", None) # type: ClsType[None] - request = build_resources_check_existence_request( resource_group_name=resource_group_name, resource_provider_namespace=resource_provider_namespace, @@ -7621,16 +8280,17 @@ def check_existence( resource_name=resource_name, subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.check_existence.metadata['url'], + template_url=self.check_existence.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [204, 404]: @@ -7641,8 +8301,7 @@ def check_existence( return cls(pipeline_response, None, {}) return 200 <= response.status_code <= 299 - check_existence.metadata = {'url': "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{parentResourcePath}/{resourceType}/{resourceName}"} # type: ignore - + check_existence.metadata = {"url": "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{parentResourcePath}/{resourceType}/{resourceName}"} # type: ignore def _delete_initial( # pylint: disable=inconsistent-return-statements self, @@ -7654,14 +8313,20 @@ def _delete_initial( # pylint: disable=inconsistent-return-statements api_version: str, **kwargs: Any ) -> None: - cls = kwargs.pop('cls', None) # type: ClsType[None] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = kwargs.pop("params", {}) or {} - - request = build_resources_delete_request_initial( + cls = kwargs.pop("cls", None) # type: ClsType[None] + + request = build_resources_delete_request( resource_group_name=resource_group_name, resource_provider_namespace=resource_provider_namespace, parent_resource_path=parent_resource_path, @@ -7669,16 +8334,17 @@ def _delete_initial( # pylint: disable=inconsistent-return-statements resource_name=resource_name, subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self._delete_initial.metadata['url'], + template_url=self._delete_initial.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200, 202, 204]: @@ -7688,11 +8354,10 @@ def _delete_initial( # pylint: disable=inconsistent-return-statements if cls: return cls(pipeline_response, None, {}) - _delete_initial.metadata = {'url': "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{parentResourcePath}/{resourceType}/{resourceName}"} # type: ignore - + _delete_initial.metadata = {"url": "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{parentResourcePath}/{resourceType}/{resourceName}"} # type: ignore @distributed_trace - def begin_delete( # pylint: disable=inconsistent-return-statements + def begin_delete( self, resource_group_name: str, resource_provider_namespace: str, @@ -7705,17 +8370,17 @@ def begin_delete( # pylint: disable=inconsistent-return-statements """Deletes a resource. :param resource_group_name: The name of the resource group that contains the resource to - delete. The name is case insensitive. + delete. The name is case insensitive. Required. :type resource_group_name: str - :param resource_provider_namespace: The namespace of the resource provider. + :param resource_provider_namespace: The namespace of the resource provider. Required. :type resource_provider_namespace: str - :param parent_resource_path: The parent resource identity. + :param parent_resource_path: The parent resource identity. Required. :type parent_resource_path: str - :param resource_type: The resource type. + :param resource_type: The resource type. Required. :type resource_type: str - :param resource_name: The name of the resource to delete. + :param resource_name: The name of the resource to delete. Required. :type resource_name: str - :param api_version: The API version to use for the operation. + :param api_version: The API version to use for the operation. Required. :type api_version: str :keyword callable cls: A custom type or function that will be passed the direct response :keyword str continuation_token: A continuation token to restart a poller from a saved state. @@ -7727,46 +8392,50 @@ def begin_delete( # pylint: disable=inconsistent-return-statements Retry-After header is present. :return: An instance of LROPoller that returns either None or the result of cls(response) :rtype: ~azure.core.polling.LROPoller[None] - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - polling = kwargs.pop('polling', True) # type: Union[bool, PollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType[None] - lro_delay = kwargs.pop( - 'polling_interval', - self._config.polling_interval - ) - cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] + _headers = kwargs.pop("headers", {}) or {} + _params = kwargs.pop("params", {}) or {} + + cls = kwargs.pop("cls", None) # type: ClsType[None] + polling = kwargs.pop("polling", True) # type: Union[bool, PollingMethod] + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token = kwargs.pop("continuation_token", None) # type: Optional[str] if cont_token is None: - raw_result = self._delete_initial( + raw_result = self._delete_initial( # type: ignore resource_group_name=resource_group_name, resource_provider_namespace=resource_provider_namespace, parent_resource_path=parent_resource_path, resource_type=resource_type, resource_name=resource_name, api_version=api_version, - cls=lambda x,y,z: x, + cls=lambda x, y, z: x, + headers=_headers, + params=_params, **kwargs ) - kwargs.pop('error_map', None) + kwargs.pop("error_map", None) - def get_long_running_output(pipeline_response): + def get_long_running_output(pipeline_response): # pylint: disable=inconsistent-return-statements if cls: return cls(pipeline_response, None, {}) - - if polling is True: polling_method = ARMPolling(lro_delay, **kwargs) - elif polling is False: polling_method = NoPolling() - else: polling_method = polling + if polling is True: + polling_method = cast(PollingMethod, ARMPolling(lro_delay, **kwargs)) # type: PollingMethod + elif polling is False: + polling_method = cast(PollingMethod, NoPolling()) + else: + polling_method = polling if cont_token: return LROPoller.from_continuation_token( polling_method=polling_method, continuation_token=cont_token, client=self._client, - deserialization_callback=get_long_running_output + deserialization_callback=get_long_running_output, ) return LROPoller(self._client, raw_result, get_long_running_output, polling_method) - begin_delete.metadata = {'url': "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{parentResourcePath}/{resourceType}/{resourceName}"} # type: ignore + begin_delete.metadata = {"url": "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{parentResourcePath}/{resourceType}/{resourceName}"} # type: ignore def _create_or_update_initial( self, @@ -7776,39 +8445,53 @@ def _create_or_update_initial( resource_type: str, resource_name: str, api_version: str, - parameters: "_models.GenericResource", + parameters: Union[_models.GenericResource, IO], **kwargs: Any - ) -> Optional["_models.GenericResource"]: - cls = kwargs.pop('cls', None) # type: ClsType[Optional["_models.GenericResource"]] + ) -> Optional[_models.GenericResource]: error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = kwargs.pop("params", {}) or {} - _json = self._serialize.body(parameters, 'GenericResource') + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[Optional[_models.GenericResource]] - request = build_resources_create_or_update_request_initial( + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(parameters, (IO, bytes)): + _content = parameters + else: + _json = self._serialize.body(parameters, "GenericResource") + + request = build_resources_create_or_update_request( resource_group_name=resource_group_name, resource_provider_namespace=resource_provider_namespace, parent_resource_path=parent_resource_path, resource_type=resource_type, resource_name=resource_name, subscription_id=self._config.subscription_id, - content_type=content_type, api_version=api_version, + content_type=content_type, json=_json, - template_url=self._create_or_update_initial.metadata['url'], + content=_content, + template_url=self._create_or_update_initial.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200, 201, 202]: @@ -7817,18 +8500,115 @@ def _create_or_update_initial( deserialized = None if response.status_code == 200: - deserialized = self._deserialize('GenericResource', pipeline_response) + deserialized = self._deserialize("GenericResource", pipeline_response) if response.status_code == 201: - deserialized = self._deserialize('GenericResource', pipeline_response) + deserialized = self._deserialize("GenericResource", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - _create_or_update_initial.metadata = {'url': "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{parentResourcePath}/{resourceType}/{resourceName}"} # type: ignore + _create_or_update_initial.metadata = {"url": "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{parentResourcePath}/{resourceType}/{resourceName}"} # type: ignore + + @overload + def begin_create_or_update( + self, + resource_group_name: str, + resource_provider_namespace: str, + parent_resource_path: str, + resource_type: str, + resource_name: str, + api_version: str, + parameters: _models.GenericResource, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> LROPoller[_models.GenericResource]: + """Creates a resource. + + :param resource_group_name: The name of the resource group for the resource. The name is case + insensitive. Required. + :type resource_group_name: str + :param resource_provider_namespace: The namespace of the resource provider. Required. + :type resource_provider_namespace: str + :param parent_resource_path: The parent resource identity. Required. + :type parent_resource_path: str + :param resource_type: The resource type of the resource to create. Required. + :type resource_type: str + :param resource_name: The name of the resource to create. Required. + :type resource_name: str + :param api_version: The API version to use for the operation. Required. + :type api_version: str + :param parameters: Parameters for creating or updating the resource. Required. + :type parameters: ~azure.mgmt.resource.resources.v2019_08_01.models.GenericResource + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be ARMPolling. Pass in False for this + operation to not poll, or pass in your own initialized polling object for a personal polling + strategy. + :paramtype polling: bool or ~azure.core.polling.PollingMethod + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of LROPoller that returns either GenericResource or the result of + cls(response) + :rtype: + ~azure.core.polling.LROPoller[~azure.mgmt.resource.resources.v2019_08_01.models.GenericResource] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + def begin_create_or_update( + self, + resource_group_name: str, + resource_provider_namespace: str, + parent_resource_path: str, + resource_type: str, + resource_name: str, + api_version: str, + parameters: IO, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> LROPoller[_models.GenericResource]: + """Creates a resource. + :param resource_group_name: The name of the resource group for the resource. The name is case + insensitive. Required. + :type resource_group_name: str + :param resource_provider_namespace: The namespace of the resource provider. Required. + :type resource_provider_namespace: str + :param parent_resource_path: The parent resource identity. Required. + :type parent_resource_path: str + :param resource_type: The resource type of the resource to create. Required. + :type resource_type: str + :param resource_name: The name of the resource to create. Required. + :type resource_name: str + :param api_version: The API version to use for the operation. Required. + :type api_version: str + :param parameters: Parameters for creating or updating the resource. Required. + :type parameters: IO + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be ARMPolling. Pass in False for this + operation to not poll, or pass in your own initialized polling object for a personal polling + strategy. + :paramtype polling: bool or ~azure.core.polling.PollingMethod + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of LROPoller that returns either GenericResource or the result of + cls(response) + :rtype: + ~azure.core.polling.LROPoller[~azure.mgmt.resource.resources.v2019_08_01.models.GenericResource] + :raises ~azure.core.exceptions.HttpResponseError: + """ @distributed_trace def begin_create_or_update( @@ -7839,26 +8619,30 @@ def begin_create_or_update( resource_type: str, resource_name: str, api_version: str, - parameters: "_models.GenericResource", + parameters: Union[_models.GenericResource, IO], **kwargs: Any - ) -> LROPoller["_models.GenericResource"]: + ) -> LROPoller[_models.GenericResource]: """Creates a resource. :param resource_group_name: The name of the resource group for the resource. The name is case - insensitive. + insensitive. Required. :type resource_group_name: str - :param resource_provider_namespace: The namespace of the resource provider. + :param resource_provider_namespace: The namespace of the resource provider. Required. :type resource_provider_namespace: str - :param parent_resource_path: The parent resource identity. + :param parent_resource_path: The parent resource identity. Required. :type parent_resource_path: str - :param resource_type: The resource type of the resource to create. + :param resource_type: The resource type of the resource to create. Required. :type resource_type: str - :param resource_name: The name of the resource to create. + :param resource_name: The name of the resource to create. Required. :type resource_name: str - :param api_version: The API version to use for the operation. + :param api_version: The API version to use for the operation. Required. :type api_version: str - :param parameters: Parameters for creating or updating the resource. - :type parameters: ~azure.mgmt.resource.resources.v2019_08_01.models.GenericResource + :param parameters: Parameters for creating or updating the resource. Is either a model type or + a IO type. Required. + :type parameters: ~azure.mgmt.resource.resources.v2019_08_01.models.GenericResource or IO + :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. + Default value is None. + :paramtype content_type: str :keyword callable cls: A custom type or function that will be passed the direct response :keyword str continuation_token: A continuation token to restart a poller from a saved state. :keyword polling: By default, your polling method will be ARMPolling. Pass in False for this @@ -7871,18 +8655,18 @@ def begin_create_or_update( cls(response) :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.resource.resources.v2019_08_01.models.GenericResource] - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] - polling = kwargs.pop('polling', True) # type: Union[bool, PollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType["_models.GenericResource"] - lro_delay = kwargs.pop( - 'polling_interval', - self._config.polling_interval - ) - cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = kwargs.pop("params", {}) or {} + + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.GenericResource] + polling = kwargs.pop("polling", True) # type: Union[bool, PollingMethod] + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token = kwargs.pop("continuation_token", None) # type: Optional[str] if cont_token is None: - raw_result = self._create_or_update_initial( + raw_result = self._create_or_update_initial( # type: ignore resource_group_name=resource_group_name, resource_provider_namespace=resource_provider_namespace, parent_resource_path=parent_resource_path, @@ -7891,32 +8675,35 @@ def begin_create_or_update( api_version=api_version, parameters=parameters, content_type=content_type, - cls=lambda x,y,z: x, + cls=lambda x, y, z: x, + headers=_headers, + params=_params, **kwargs ) - kwargs.pop('error_map', None) + kwargs.pop("error_map", None) def get_long_running_output(pipeline_response): - response = pipeline_response.http_response - deserialized = self._deserialize('GenericResource', pipeline_response) + deserialized = self._deserialize("GenericResource", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - - if polling is True: polling_method = ARMPolling(lro_delay, **kwargs) - elif polling is False: polling_method = NoPolling() - else: polling_method = polling + if polling is True: + polling_method = cast(PollingMethod, ARMPolling(lro_delay, **kwargs)) # type: PollingMethod + elif polling is False: + polling_method = cast(PollingMethod, NoPolling()) + else: + polling_method = polling if cont_token: return LROPoller.from_continuation_token( polling_method=polling_method, continuation_token=cont_token, client=self._client, - deserialization_callback=get_long_running_output + deserialization_callback=get_long_running_output, ) return LROPoller(self._client, raw_result, get_long_running_output, polling_method) - begin_create_or_update.metadata = {'url': "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{parentResourcePath}/{resourceType}/{resourceName}"} # type: ignore + begin_create_or_update.metadata = {"url": "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{parentResourcePath}/{resourceType}/{resourceName}"} # type: ignore def _update_initial( self, @@ -7926,39 +8713,53 @@ def _update_initial( resource_type: str, resource_name: str, api_version: str, - parameters: "_models.GenericResource", + parameters: Union[_models.GenericResource, IO], **kwargs: Any - ) -> Optional["_models.GenericResource"]: - cls = kwargs.pop('cls', None) # type: ClsType[Optional["_models.GenericResource"]] + ) -> Optional[_models.GenericResource]: error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = kwargs.pop("params", {}) or {} - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[Optional[_models.GenericResource]] - _json = self._serialize.body(parameters, 'GenericResource') + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(parameters, (IO, bytes)): + _content = parameters + else: + _json = self._serialize.body(parameters, "GenericResource") - request = build_resources_update_request_initial( + request = build_resources_update_request( resource_group_name=resource_group_name, resource_provider_namespace=resource_provider_namespace, parent_resource_path=parent_resource_path, resource_type=resource_type, resource_name=resource_name, subscription_id=self._config.subscription_id, - content_type=content_type, api_version=api_version, + content_type=content_type, json=_json, - template_url=self._update_initial.metadata['url'], + content=_content, + template_url=self._update_initial.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200, 202]: @@ -7967,15 +8768,112 @@ def _update_initial( deserialized = None if response.status_code == 200: - deserialized = self._deserialize('GenericResource', pipeline_response) + deserialized = self._deserialize("GenericResource", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - _update_initial.metadata = {'url': "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{parentResourcePath}/{resourceType}/{resourceName}"} # type: ignore + _update_initial.metadata = {"url": "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{parentResourcePath}/{resourceType}/{resourceName}"} # type: ignore + + @overload + def begin_update( + self, + resource_group_name: str, + resource_provider_namespace: str, + parent_resource_path: str, + resource_type: str, + resource_name: str, + api_version: str, + parameters: _models.GenericResource, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> LROPoller[_models.GenericResource]: + """Updates a resource. + + :param resource_group_name: The name of the resource group for the resource. The name is case + insensitive. Required. + :type resource_group_name: str + :param resource_provider_namespace: The namespace of the resource provider. Required. + :type resource_provider_namespace: str + :param parent_resource_path: The parent resource identity. Required. + :type parent_resource_path: str + :param resource_type: The resource type of the resource to update. Required. + :type resource_type: str + :param resource_name: The name of the resource to update. Required. + :type resource_name: str + :param api_version: The API version to use for the operation. Required. + :type api_version: str + :param parameters: Parameters for updating the resource. Required. + :type parameters: ~azure.mgmt.resource.resources.v2019_08_01.models.GenericResource + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be ARMPolling. Pass in False for this + operation to not poll, or pass in your own initialized polling object for a personal polling + strategy. + :paramtype polling: bool or ~azure.core.polling.PollingMethod + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of LROPoller that returns either GenericResource or the result of + cls(response) + :rtype: + ~azure.core.polling.LROPoller[~azure.mgmt.resource.resources.v2019_08_01.models.GenericResource] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + def begin_update( + self, + resource_group_name: str, + resource_provider_namespace: str, + parent_resource_path: str, + resource_type: str, + resource_name: str, + api_version: str, + parameters: IO, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> LROPoller[_models.GenericResource]: + """Updates a resource. + :param resource_group_name: The name of the resource group for the resource. The name is case + insensitive. Required. + :type resource_group_name: str + :param resource_provider_namespace: The namespace of the resource provider. Required. + :type resource_provider_namespace: str + :param parent_resource_path: The parent resource identity. Required. + :type parent_resource_path: str + :param resource_type: The resource type of the resource to update. Required. + :type resource_type: str + :param resource_name: The name of the resource to update. Required. + :type resource_name: str + :param api_version: The API version to use for the operation. Required. + :type api_version: str + :param parameters: Parameters for updating the resource. Required. + :type parameters: IO + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be ARMPolling. Pass in False for this + operation to not poll, or pass in your own initialized polling object for a personal polling + strategy. + :paramtype polling: bool or ~azure.core.polling.PollingMethod + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of LROPoller that returns either GenericResource or the result of + cls(response) + :rtype: + ~azure.core.polling.LROPoller[~azure.mgmt.resource.resources.v2019_08_01.models.GenericResource] + :raises ~azure.core.exceptions.HttpResponseError: + """ @distributed_trace def begin_update( @@ -7986,26 +8884,30 @@ def begin_update( resource_type: str, resource_name: str, api_version: str, - parameters: "_models.GenericResource", + parameters: Union[_models.GenericResource, IO], **kwargs: Any - ) -> LROPoller["_models.GenericResource"]: + ) -> LROPoller[_models.GenericResource]: """Updates a resource. :param resource_group_name: The name of the resource group for the resource. The name is case - insensitive. + insensitive. Required. :type resource_group_name: str - :param resource_provider_namespace: The namespace of the resource provider. + :param resource_provider_namespace: The namespace of the resource provider. Required. :type resource_provider_namespace: str - :param parent_resource_path: The parent resource identity. + :param parent_resource_path: The parent resource identity. Required. :type parent_resource_path: str - :param resource_type: The resource type of the resource to update. + :param resource_type: The resource type of the resource to update. Required. :type resource_type: str - :param resource_name: The name of the resource to update. + :param resource_name: The name of the resource to update. Required. :type resource_name: str - :param api_version: The API version to use for the operation. + :param api_version: The API version to use for the operation. Required. :type api_version: str - :param parameters: Parameters for updating the resource. - :type parameters: ~azure.mgmt.resource.resources.v2019_08_01.models.GenericResource + :param parameters: Parameters for updating the resource. Is either a model type or a IO type. + Required. + :type parameters: ~azure.mgmt.resource.resources.v2019_08_01.models.GenericResource or IO + :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. + Default value is None. + :paramtype content_type: str :keyword callable cls: A custom type or function that will be passed the direct response :keyword str continuation_token: A continuation token to restart a poller from a saved state. :keyword polling: By default, your polling method will be ARMPolling. Pass in False for this @@ -8018,18 +8920,18 @@ def begin_update( cls(response) :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.resource.resources.v2019_08_01.models.GenericResource] - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] - polling = kwargs.pop('polling', True) # type: Union[bool, PollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType["_models.GenericResource"] - lro_delay = kwargs.pop( - 'polling_interval', - self._config.polling_interval - ) - cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = kwargs.pop("params", {}) or {} + + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.GenericResource] + polling = kwargs.pop("polling", True) # type: Union[bool, PollingMethod] + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token = kwargs.pop("continuation_token", None) # type: Optional[str] if cont_token is None: - raw_result = self._update_initial( + raw_result = self._update_initial( # type: ignore resource_group_name=resource_group_name, resource_provider_namespace=resource_provider_namespace, parent_resource_path=parent_resource_path, @@ -8038,32 +8940,35 @@ def begin_update( api_version=api_version, parameters=parameters, content_type=content_type, - cls=lambda x,y,z: x, + cls=lambda x, y, z: x, + headers=_headers, + params=_params, **kwargs ) - kwargs.pop('error_map', None) + kwargs.pop("error_map", None) def get_long_running_output(pipeline_response): - response = pipeline_response.http_response - deserialized = self._deserialize('GenericResource', pipeline_response) + deserialized = self._deserialize("GenericResource", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - - if polling is True: polling_method = ARMPolling(lro_delay, **kwargs) - elif polling is False: polling_method = NoPolling() - else: polling_method = polling + if polling is True: + polling_method = cast(PollingMethod, ARMPolling(lro_delay, **kwargs)) # type: PollingMethod + elif polling is False: + polling_method = cast(PollingMethod, NoPolling()) + else: + polling_method = polling if cont_token: return LROPoller.from_continuation_token( polling_method=polling_method, continuation_token=cont_token, client=self._client, - deserialization_callback=get_long_running_output + deserialization_callback=get_long_running_output, ) return LROPoller(self._client, raw_result, get_long_running_output, polling_method) - begin_update.metadata = {'url': "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{parentResourcePath}/{resourceType}/{resourceName}"} # type: ignore + begin_update.metadata = {"url": "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{parentResourcePath}/{resourceType}/{resourceName}"} # type: ignore @distributed_trace def get( @@ -8075,34 +8980,40 @@ def get( resource_name: str, api_version: str, **kwargs: Any - ) -> "_models.GenericResource": + ) -> _models.GenericResource: """Gets a resource. :param resource_group_name: The name of the resource group containing the resource to get. The - name is case insensitive. + name is case insensitive. Required. :type resource_group_name: str - :param resource_provider_namespace: The namespace of the resource provider. + :param resource_provider_namespace: The namespace of the resource provider. Required. :type resource_provider_namespace: str - :param parent_resource_path: The parent resource identity. + :param parent_resource_path: The parent resource identity. Required. :type parent_resource_path: str - :param resource_type: The resource type of the resource. + :param resource_type: The resource type of the resource. Required. :type resource_type: str - :param resource_name: The name of the resource to get. + :param resource_name: The name of the resource to get. Required. :type resource_name: str - :param api_version: The API version to use for the operation. + :param api_version: The API version to use for the operation. Required. :type api_version: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: GenericResource, or the result of cls(response) + :return: GenericResource or the result of cls(response) :rtype: ~azure.mgmt.resource.resources.v2019_08_01.models.GenericResource - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.GenericResource"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = kwargs.pop("params", {}) or {} + + cls = kwargs.pop("cls", None) # type: ClsType[_models.GenericResource] - request = build_resources_get_request( resource_group_name=resource_group_name, resource_provider_namespace=resource_provider_namespace, @@ -8111,72 +9022,75 @@ def get( resource_name=resource_name, subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.get.metadata['url'], + template_url=self.get.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) - deserialized = self._deserialize('GenericResource', pipeline_response) + deserialized = self._deserialize("GenericResource", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - get.metadata = {'url': "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{parentResourcePath}/{resourceType}/{resourceName}"} # type: ignore - + get.metadata = {"url": "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{parentResourcePath}/{resourceType}/{resourceName}"} # type: ignore @distributed_trace - def check_existence_by_id( - self, - resource_id: str, - api_version: str, - **kwargs: Any - ) -> bool: + def check_existence_by_id(self, resource_id: str, api_version: str, **kwargs: Any) -> bool: """Checks by ID whether a resource exists. :param resource_id: The fully qualified ID of the resource, including the resource name and resource type. Use the format, /subscriptions/{guid}/resourceGroups/{resource-group-name}/{resource-provider-namespace}/{resource-type}/{resource-name}. + Required. :type resource_id: str - :param api_version: The API version to use for the operation. + :param api_version: The API version to use for the operation. Required. :type api_version: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: bool, or the result of cls(response) + :return: bool or the result of cls(response) :rtype: bool - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType[None] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = kwargs.pop("params", {}) or {} + + cls = kwargs.pop("cls", None) # type: ClsType[None] - request = build_resources_check_existence_by_id_request( resource_id=resource_id, api_version=api_version, - template_url=self.check_existence_by_id.metadata['url'], + template_url=self.check_existence_by_id.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [204, 404]: @@ -8187,35 +9101,38 @@ def check_existence_by_id( return cls(pipeline_response, None, {}) return 200 <= response.status_code <= 299 - check_existence_by_id.metadata = {'url': "/{resourceId}"} # type: ignore - + check_existence_by_id.metadata = {"url": "/{resourceId}"} # type: ignore def _delete_by_id_initial( # pylint: disable=inconsistent-return-statements - self, - resource_id: str, - api_version: str, - **kwargs: Any + self, resource_id: str, api_version: str, **kwargs: Any ) -> None: - cls = kwargs.pop('cls', None) # type: ClsType[None] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) - - request = build_resources_delete_by_id_request_initial( + _headers = kwargs.pop("headers", {}) or {} + _params = kwargs.pop("params", {}) or {} + + cls = kwargs.pop("cls", None) # type: ClsType[None] + + request = build_resources_delete_by_id_request( resource_id=resource_id, api_version=api_version, - template_url=self._delete_by_id_initial.metadata['url'], + template_url=self._delete_by_id_initial.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200, 202, 204]: @@ -8225,23 +9142,18 @@ def _delete_by_id_initial( # pylint: disable=inconsistent-return-statements if cls: return cls(pipeline_response, None, {}) - _delete_by_id_initial.metadata = {'url': "/{resourceId}"} # type: ignore - + _delete_by_id_initial.metadata = {"url": "/{resourceId}"} # type: ignore @distributed_trace - def begin_delete_by_id( # pylint: disable=inconsistent-return-statements - self, - resource_id: str, - api_version: str, - **kwargs: Any - ) -> LROPoller[None]: + def begin_delete_by_id(self, resource_id: str, api_version: str, **kwargs: Any) -> LROPoller[None]: """Deletes a resource by ID. :param resource_id: The fully qualified ID of the resource, including the resource name and resource type. Use the format, /subscriptions/{guid}/resourceGroups/{resource-group-name}/{resource-provider-namespace}/{resource-type}/{resource-name}. + Required. :type resource_id: str - :param api_version: The API version to use for the operation. + :param api_version: The API version to use for the operation. Required. :type api_version: str :keyword callable cls: A custom type or function that will be passed the direct response :keyword str continuation_token: A continuation token to restart a poller from a saved state. @@ -8253,75 +9165,89 @@ def begin_delete_by_id( # pylint: disable=inconsistent-return-statements Retry-After header is present. :return: An instance of LROPoller that returns either None or the result of cls(response) :rtype: ~azure.core.polling.LROPoller[None] - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - polling = kwargs.pop('polling', True) # type: Union[bool, PollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType[None] - lro_delay = kwargs.pop( - 'polling_interval', - self._config.polling_interval - ) - cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] + _headers = kwargs.pop("headers", {}) or {} + _params = kwargs.pop("params", {}) or {} + + cls = kwargs.pop("cls", None) # type: ClsType[None] + polling = kwargs.pop("polling", True) # type: Union[bool, PollingMethod] + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token = kwargs.pop("continuation_token", None) # type: Optional[str] if cont_token is None: - raw_result = self._delete_by_id_initial( + raw_result = self._delete_by_id_initial( # type: ignore resource_id=resource_id, api_version=api_version, - cls=lambda x,y,z: x, + cls=lambda x, y, z: x, + headers=_headers, + params=_params, **kwargs ) - kwargs.pop('error_map', None) + kwargs.pop("error_map", None) - def get_long_running_output(pipeline_response): + def get_long_running_output(pipeline_response): # pylint: disable=inconsistent-return-statements if cls: return cls(pipeline_response, None, {}) - - if polling is True: polling_method = ARMPolling(lro_delay, **kwargs) - elif polling is False: polling_method = NoPolling() - else: polling_method = polling + if polling is True: + polling_method = cast(PollingMethod, ARMPolling(lro_delay, **kwargs)) # type: PollingMethod + elif polling is False: + polling_method = cast(PollingMethod, NoPolling()) + else: + polling_method = polling if cont_token: return LROPoller.from_continuation_token( polling_method=polling_method, continuation_token=cont_token, client=self._client, - deserialization_callback=get_long_running_output + deserialization_callback=get_long_running_output, ) return LROPoller(self._client, raw_result, get_long_running_output, polling_method) - begin_delete_by_id.metadata = {'url': "/{resourceId}"} # type: ignore + begin_delete_by_id.metadata = {"url": "/{resourceId}"} # type: ignore def _create_or_update_by_id_initial( - self, - resource_id: str, - api_version: str, - parameters: "_models.GenericResource", - **kwargs: Any - ) -> Optional["_models.GenericResource"]: - cls = kwargs.pop('cls', None) # type: ClsType[Optional["_models.GenericResource"]] + self, resource_id: str, api_version: str, parameters: Union[_models.GenericResource, IO], **kwargs: Any + ) -> Optional[_models.GenericResource]: error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = kwargs.pop("params", {}) or {} - _json = self._serialize.body(parameters, 'GenericResource') + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[Optional[_models.GenericResource]] - request = build_resources_create_or_update_by_id_request_initial( + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(parameters, (IO, bytes)): + _content = parameters + else: + _json = self._serialize.body(parameters, "GenericResource") + + request = build_resources_create_or_update_by_id_request( resource_id=resource_id, - content_type=content_type, api_version=api_version, + content_type=content_type, json=_json, - template_url=self._create_or_update_by_id_initial.metadata['url'], + content=_content, + template_url=self._create_or_update_by_id_initial.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200, 201, 202]: @@ -8330,37 +9256,42 @@ def _create_or_update_by_id_initial( deserialized = None if response.status_code == 200: - deserialized = self._deserialize('GenericResource', pipeline_response) + deserialized = self._deserialize("GenericResource", pipeline_response) if response.status_code == 201: - deserialized = self._deserialize('GenericResource', pipeline_response) + deserialized = self._deserialize("GenericResource", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - _create_or_update_by_id_initial.metadata = {'url': "/{resourceId}"} # type: ignore + _create_or_update_by_id_initial.metadata = {"url": "/{resourceId}"} # type: ignore - - @distributed_trace + @overload def begin_create_or_update_by_id( self, resource_id: str, api_version: str, - parameters: "_models.GenericResource", + parameters: _models.GenericResource, + *, + content_type: str = "application/json", **kwargs: Any - ) -> LROPoller["_models.GenericResource"]: + ) -> LROPoller[_models.GenericResource]: """Create a resource by ID. :param resource_id: The fully qualified ID of the resource, including the resource name and resource type. Use the format, /subscriptions/{guid}/resourceGroups/{resource-group-name}/{resource-provider-namespace}/{resource-type}/{resource-name}. + Required. :type resource_id: str - :param api_version: The API version to use for the operation. + :param api_version: The API version to use for the operation. Required. :type api_version: str - :param parameters: Create or update resource parameters. + :param parameters: Create or update resource parameters. Required. :type parameters: ~azure.mgmt.resource.resources.v2019_08_01.models.GenericResource + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str :keyword callable cls: A custom type or function that will be passed the direct response :keyword str continuation_token: A continuation token to restart a poller from a saved state. :keyword polling: By default, your polling method will be ARMPolling. Pass in False for this @@ -8373,81 +9304,167 @@ def begin_create_or_update_by_id( cls(response) :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.resource.resources.v2019_08_01.models.GenericResource] - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] - polling = kwargs.pop('polling', True) # type: Union[bool, PollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType["_models.GenericResource"] - lro_delay = kwargs.pop( - 'polling_interval', - self._config.polling_interval - ) - cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] + + @overload + def begin_create_or_update_by_id( + self, + resource_id: str, + api_version: str, + parameters: IO, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> LROPoller[_models.GenericResource]: + """Create a resource by ID. + + :param resource_id: The fully qualified ID of the resource, including the resource name and + resource type. Use the format, + /subscriptions/{guid}/resourceGroups/{resource-group-name}/{resource-provider-namespace}/{resource-type}/{resource-name}. + Required. + :type resource_id: str + :param api_version: The API version to use for the operation. Required. + :type api_version: str + :param parameters: Create or update resource parameters. Required. + :type parameters: IO + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be ARMPolling. Pass in False for this + operation to not poll, or pass in your own initialized polling object for a personal polling + strategy. + :paramtype polling: bool or ~azure.core.polling.PollingMethod + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of LROPoller that returns either GenericResource or the result of + cls(response) + :rtype: + ~azure.core.polling.LROPoller[~azure.mgmt.resource.resources.v2019_08_01.models.GenericResource] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace + def begin_create_or_update_by_id( + self, resource_id: str, api_version: str, parameters: Union[_models.GenericResource, IO], **kwargs: Any + ) -> LROPoller[_models.GenericResource]: + """Create a resource by ID. + + :param resource_id: The fully qualified ID of the resource, including the resource name and + resource type. Use the format, + /subscriptions/{guid}/resourceGroups/{resource-group-name}/{resource-provider-namespace}/{resource-type}/{resource-name}. + Required. + :type resource_id: str + :param api_version: The API version to use for the operation. Required. + :type api_version: str + :param parameters: Create or update resource parameters. Is either a model type or a IO type. + Required. + :type parameters: ~azure.mgmt.resource.resources.v2019_08_01.models.GenericResource or IO + :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. + Default value is None. + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be ARMPolling. Pass in False for this + operation to not poll, or pass in your own initialized polling object for a personal polling + strategy. + :paramtype polling: bool or ~azure.core.polling.PollingMethod + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of LROPoller that returns either GenericResource or the result of + cls(response) + :rtype: + ~azure.core.polling.LROPoller[~azure.mgmt.resource.resources.v2019_08_01.models.GenericResource] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = kwargs.pop("params", {}) or {} + + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.GenericResource] + polling = kwargs.pop("polling", True) # type: Union[bool, PollingMethod] + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token = kwargs.pop("continuation_token", None) # type: Optional[str] if cont_token is None: - raw_result = self._create_or_update_by_id_initial( + raw_result = self._create_or_update_by_id_initial( # type: ignore resource_id=resource_id, api_version=api_version, parameters=parameters, content_type=content_type, - cls=lambda x,y,z: x, + cls=lambda x, y, z: x, + headers=_headers, + params=_params, **kwargs ) - kwargs.pop('error_map', None) + kwargs.pop("error_map", None) def get_long_running_output(pipeline_response): - response = pipeline_response.http_response - deserialized = self._deserialize('GenericResource', pipeline_response) + deserialized = self._deserialize("GenericResource", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - - if polling is True: polling_method = ARMPolling(lro_delay, **kwargs) - elif polling is False: polling_method = NoPolling() - else: polling_method = polling + if polling is True: + polling_method = cast(PollingMethod, ARMPolling(lro_delay, **kwargs)) # type: PollingMethod + elif polling is False: + polling_method = cast(PollingMethod, NoPolling()) + else: + polling_method = polling if cont_token: return LROPoller.from_continuation_token( polling_method=polling_method, continuation_token=cont_token, client=self._client, - deserialization_callback=get_long_running_output + deserialization_callback=get_long_running_output, ) return LROPoller(self._client, raw_result, get_long_running_output, polling_method) - begin_create_or_update_by_id.metadata = {'url': "/{resourceId}"} # type: ignore + begin_create_or_update_by_id.metadata = {"url": "/{resourceId}"} # type: ignore def _update_by_id_initial( - self, - resource_id: str, - api_version: str, - parameters: "_models.GenericResource", - **kwargs: Any - ) -> Optional["_models.GenericResource"]: - cls = kwargs.pop('cls', None) # type: ClsType[Optional["_models.GenericResource"]] + self, resource_id: str, api_version: str, parameters: Union[_models.GenericResource, IO], **kwargs: Any + ) -> Optional[_models.GenericResource]: error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = kwargs.pop("params", {}) or {} - _json = self._serialize.body(parameters, 'GenericResource') + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[Optional[_models.GenericResource]] - request = build_resources_update_by_id_request_initial( + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(parameters, (IO, bytes)): + _content = parameters + else: + _json = self._serialize.body(parameters, "GenericResource") + + request = build_resources_update_by_id_request( resource_id=resource_id, - content_type=content_type, api_version=api_version, + content_type=content_type, json=_json, - template_url=self._update_by_id_initial.metadata['url'], + content=_content, + template_url=self._update_by_id_initial.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200, 202]: @@ -8456,34 +9473,39 @@ def _update_by_id_initial( deserialized = None if response.status_code == 200: - deserialized = self._deserialize('GenericResource', pipeline_response) + deserialized = self._deserialize("GenericResource", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - _update_by_id_initial.metadata = {'url': "/{resourceId}"} # type: ignore + _update_by_id_initial.metadata = {"url": "/{resourceId}"} # type: ignore - - @distributed_trace + @overload def begin_update_by_id( self, resource_id: str, api_version: str, - parameters: "_models.GenericResource", + parameters: _models.GenericResource, + *, + content_type: str = "application/json", **kwargs: Any - ) -> LROPoller["_models.GenericResource"]: + ) -> LROPoller[_models.GenericResource]: """Updates a resource by ID. :param resource_id: The fully qualified ID of the resource, including the resource name and resource type. Use the format, /subscriptions/{guid}/resourceGroups/{resource-group-name}/{resource-provider-namespace}/{resource-type}/{resource-name}. + Required. :type resource_id: str - :param api_version: The API version to use for the operation. + :param api_version: The API version to use for the operation. Required. :type api_version: str - :param parameters: Update resource parameters. + :param parameters: Update resource parameters. Required. :type parameters: ~azure.mgmt.resource.resources.v2019_08_01.models.GenericResource + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str :keyword callable cls: A custom type or function that will be passed the direct response :keyword str continuation_token: A continuation token to restart a poller from a saved state. :keyword polling: By default, your polling method will be ARMPolling. Pass in False for this @@ -8496,165 +9518,243 @@ def begin_update_by_id( cls(response) :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.resource.resources.v2019_08_01.models.GenericResource] - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] - polling = kwargs.pop('polling', True) # type: Union[bool, PollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType["_models.GenericResource"] - lro_delay = kwargs.pop( - 'polling_interval', - self._config.polling_interval - ) - cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] + + @overload + def begin_update_by_id( + self, + resource_id: str, + api_version: str, + parameters: IO, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> LROPoller[_models.GenericResource]: + """Updates a resource by ID. + + :param resource_id: The fully qualified ID of the resource, including the resource name and + resource type. Use the format, + /subscriptions/{guid}/resourceGroups/{resource-group-name}/{resource-provider-namespace}/{resource-type}/{resource-name}. + Required. + :type resource_id: str + :param api_version: The API version to use for the operation. Required. + :type api_version: str + :param parameters: Update resource parameters. Required. + :type parameters: IO + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be ARMPolling. Pass in False for this + operation to not poll, or pass in your own initialized polling object for a personal polling + strategy. + :paramtype polling: bool or ~azure.core.polling.PollingMethod + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of LROPoller that returns either GenericResource or the result of + cls(response) + :rtype: + ~azure.core.polling.LROPoller[~azure.mgmt.resource.resources.v2019_08_01.models.GenericResource] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace + def begin_update_by_id( + self, resource_id: str, api_version: str, parameters: Union[_models.GenericResource, IO], **kwargs: Any + ) -> LROPoller[_models.GenericResource]: + """Updates a resource by ID. + + :param resource_id: The fully qualified ID of the resource, including the resource name and + resource type. Use the format, + /subscriptions/{guid}/resourceGroups/{resource-group-name}/{resource-provider-namespace}/{resource-type}/{resource-name}. + Required. + :type resource_id: str + :param api_version: The API version to use for the operation. Required. + :type api_version: str + :param parameters: Update resource parameters. Is either a model type or a IO type. Required. + :type parameters: ~azure.mgmt.resource.resources.v2019_08_01.models.GenericResource or IO + :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. + Default value is None. + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be ARMPolling. Pass in False for this + operation to not poll, or pass in your own initialized polling object for a personal polling + strategy. + :paramtype polling: bool or ~azure.core.polling.PollingMethod + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of LROPoller that returns either GenericResource or the result of + cls(response) + :rtype: + ~azure.core.polling.LROPoller[~azure.mgmt.resource.resources.v2019_08_01.models.GenericResource] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = kwargs.pop("params", {}) or {} + + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.GenericResource] + polling = kwargs.pop("polling", True) # type: Union[bool, PollingMethod] + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token = kwargs.pop("continuation_token", None) # type: Optional[str] if cont_token is None: - raw_result = self._update_by_id_initial( + raw_result = self._update_by_id_initial( # type: ignore resource_id=resource_id, api_version=api_version, parameters=parameters, content_type=content_type, - cls=lambda x,y,z: x, + cls=lambda x, y, z: x, + headers=_headers, + params=_params, **kwargs ) - kwargs.pop('error_map', None) + kwargs.pop("error_map", None) def get_long_running_output(pipeline_response): - response = pipeline_response.http_response - deserialized = self._deserialize('GenericResource', pipeline_response) + deserialized = self._deserialize("GenericResource", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - - if polling is True: polling_method = ARMPolling(lro_delay, **kwargs) - elif polling is False: polling_method = NoPolling() - else: polling_method = polling + if polling is True: + polling_method = cast(PollingMethod, ARMPolling(lro_delay, **kwargs)) # type: PollingMethod + elif polling is False: + polling_method = cast(PollingMethod, NoPolling()) + else: + polling_method = polling if cont_token: return LROPoller.from_continuation_token( polling_method=polling_method, continuation_token=cont_token, client=self._client, - deserialization_callback=get_long_running_output + deserialization_callback=get_long_running_output, ) return LROPoller(self._client, raw_result, get_long_running_output, polling_method) - begin_update_by_id.metadata = {'url': "/{resourceId}"} # type: ignore + begin_update_by_id.metadata = {"url": "/{resourceId}"} # type: ignore @distributed_trace - def get_by_id( - self, - resource_id: str, - api_version: str, - **kwargs: Any - ) -> "_models.GenericResource": + def get_by_id(self, resource_id: str, api_version: str, **kwargs: Any) -> _models.GenericResource: """Gets a resource by ID. :param resource_id: The fully qualified ID of the resource, including the resource name and resource type. Use the format, /subscriptions/{guid}/resourceGroups/{resource-group-name}/{resource-provider-namespace}/{resource-type}/{resource-name}. + Required. :type resource_id: str - :param api_version: The API version to use for the operation. + :param api_version: The API version to use for the operation. Required. :type api_version: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: GenericResource, or the result of cls(response) + :return: GenericResource or the result of cls(response) :rtype: ~azure.mgmt.resource.resources.v2019_08_01.models.GenericResource - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.GenericResource"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = kwargs.pop("params", {}) or {} + + cls = kwargs.pop("cls", None) # type: ClsType[_models.GenericResource] - request = build_resources_get_by_id_request( resource_id=resource_id, api_version=api_version, - template_url=self.get_by_id.metadata['url'], + template_url=self.get_by_id.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) - deserialized = self._deserialize('GenericResource', pipeline_response) + deserialized = self._deserialize("GenericResource", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - get_by_id.metadata = {'url': "/{resourceId}"} # type: ignore + get_by_id.metadata = {"url": "/{resourceId}"} # type: ignore -class ResourceGroupsOperations(object): - """ResourceGroupsOperations operations. - You should not instantiate this class directly. Instead, you should create a Client instance that - instantiates it for you and attaches it as an attribute. +class ResourceGroupsOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. - :ivar models: Alias to model classes used in this operation group. - :type models: ~azure.mgmt.resource.resources.v2019_08_01.models - :param client: Client for service requests. - :param config: Configuration of service client. - :param serializer: An object model serializer. - :param deserializer: An object model deserializer. + Instead, you should access the following operations through + :class:`~azure.mgmt.resource.resources.v2019_08_01.ResourceManagementClient`'s + :attr:`resource_groups` attribute. """ models = _models - def __init__(self, client, config, serializer, deserializer): - self._client = client - self._serialize = serializer - self._deserialize = deserializer - self._config = config + def __init__(self, *args, **kwargs): + input_args = list(args) + self._client = input_args.pop(0) if input_args else kwargs.pop("client") + self._config = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") @distributed_trace - def check_existence( - self, - resource_group_name: str, - **kwargs: Any - ) -> bool: + def check_existence(self, resource_group_name: str, **kwargs: Any) -> bool: """Checks whether a resource group exists. :param resource_group_name: The name of the resource group to check. The name is case - insensitive. + insensitive. Required. :type resource_group_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: bool, or the result of cls(response) + :return: bool or the result of cls(response) :rtype: bool - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType[None] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) - api_version = kwargs.pop('api_version', "2019-08-01") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2019-08-01")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[None] - request = build_resource_groups_check_existence_request( resource_group_name=resource_group_name, subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.check_existence.metadata['url'], + template_url=self.check_existence.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [204, 404]: @@ -8665,39 +9765,98 @@ def check_existence( return cls(pipeline_response, None, {}) return 200 <= response.status_code <= 299 - check_existence.metadata = {'url': "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}"} # type: ignore + check_existence.metadata = {"url": "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}"} # type: ignore - - @distributed_trace + @overload def create_or_update( self, resource_group_name: str, - parameters: "_models.ResourceGroup", + parameters: _models.ResourceGroup, + *, + content_type: str = "application/json", **kwargs: Any - ) -> "_models.ResourceGroup": + ) -> _models.ResourceGroup: """Creates or updates a resource group. :param resource_group_name: The name of the resource group to create or update. Can include alphanumeric, underscore, parentheses, hyphen, period (except at end), and Unicode characters - that match the allowed characters. + that match the allowed characters. Required. :type resource_group_name: str - :param parameters: Parameters supplied to the create or update a resource group. + :param parameters: Parameters supplied to the create or update a resource group. Required. :type parameters: ~azure.mgmt.resource.resources.v2019_08_01.models.ResourceGroup + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: ResourceGroup or the result of cls(response) + :rtype: ~azure.mgmt.resource.resources.v2019_08_01.models.ResourceGroup + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + def create_or_update( + self, resource_group_name: str, parameters: IO, *, content_type: str = "application/json", **kwargs: Any + ) -> _models.ResourceGroup: + """Creates or updates a resource group. + + :param resource_group_name: The name of the resource group to create or update. Can include + alphanumeric, underscore, parentheses, hyphen, period (except at end), and Unicode characters + that match the allowed characters. Required. + :type resource_group_name: str + :param parameters: Parameters supplied to the create or update a resource group. Required. + :type parameters: IO + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: ResourceGroup or the result of cls(response) + :rtype: ~azure.mgmt.resource.resources.v2019_08_01.models.ResourceGroup + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace + def create_or_update( + self, resource_group_name: str, parameters: Union[_models.ResourceGroup, IO], **kwargs: Any + ) -> _models.ResourceGroup: + """Creates or updates a resource group. + + :param resource_group_name: The name of the resource group to create or update. Can include + alphanumeric, underscore, parentheses, hyphen, period (except at end), and Unicode characters + that match the allowed characters. Required. + :type resource_group_name: str + :param parameters: Parameters supplied to the create or update a resource group. Is either a + model type or a IO type. Required. + :type parameters: ~azure.mgmt.resource.resources.v2019_08_01.models.ResourceGroup or IO + :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. + Default value is None. + :paramtype content_type: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: ResourceGroup, or the result of cls(response) + :return: ResourceGroup or the result of cls(response) :rtype: ~azure.mgmt.resource.resources.v2019_08_01.models.ResourceGroup - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.ResourceGroup"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) - api_version = kwargs.pop('api_version', "2019-08-01") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - _json = self._serialize.body(parameters, 'ResourceGroup') + api_version = kwargs.pop("api_version", _params.pop("api-version", "2019-08-01")) # type: str + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.ResourceGroup] + + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(parameters, (IO, bytes)): + _content = parameters + else: + _json = self._serialize.body(parameters, "ResourceGroup") request = build_resource_groups_create_or_update_request( resource_group_name=resource_group_name, @@ -8705,16 +9864,18 @@ def create_or_update( api_version=api_version, content_type=content_type, json=_json, - template_url=self.create_or_update.metadata['url'], + content=_content, + template_url=self.create_or_update.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200, 201]: @@ -8722,47 +9883,50 @@ def create_or_update( raise HttpResponseError(response=response, error_format=ARMErrorFormat) if response.status_code == 200: - deserialized = self._deserialize('ResourceGroup', pipeline_response) + deserialized = self._deserialize("ResourceGroup", pipeline_response) if response.status_code == 201: - deserialized = self._deserialize('ResourceGroup', pipeline_response) + deserialized = self._deserialize("ResourceGroup", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - create_or_update.metadata = {'url': "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}"} # type: ignore - + create_or_update.metadata = {"url": "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}"} # type: ignore def _delete_initial( # pylint: disable=inconsistent-return-statements - self, - resource_group_name: str, - **kwargs: Any + self, resource_group_name: str, **kwargs: Any ) -> None: - cls = kwargs.pop('cls', None) # type: ClsType[None] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + 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', "2019-08-01") # type: str + api_version = kwargs.pop("api_version", _params.pop("api-version", "2019-08-01")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[None] - - request = build_resource_groups_delete_request_initial( + request = build_resource_groups_delete_request( resource_group_name=resource_group_name, subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self._delete_initial.metadata['url'], + template_url=self._delete_initial.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200, 202]: @@ -8772,22 +9936,17 @@ def _delete_initial( # pylint: disable=inconsistent-return-statements if cls: return cls(pipeline_response, None, {}) - _delete_initial.metadata = {'url': "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}"} # type: ignore - + _delete_initial.metadata = {"url": "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}"} # type: ignore @distributed_trace - def begin_delete( # pylint: disable=inconsistent-return-statements - self, - resource_group_name: str, - **kwargs: Any - ) -> LROPoller[None]: + def begin_delete(self, resource_group_name: str, **kwargs: Any) -> LROPoller[None]: """Deletes a resource group. When you delete a resource group, all of its resources are also deleted. Deleting a resource group deletes all of its template deployments and currently stored operations. :param resource_group_name: The name of the resource group to delete. The name is case - insensitive. + insensitive. Required. :type resource_group_name: str :keyword callable cls: A custom type or function that will be passed the direct response :keyword str continuation_token: A continuation token to restart a poller from a saved state. @@ -8799,106 +9958,113 @@ def begin_delete( # pylint: disable=inconsistent-return-statements Retry-After header is present. :return: An instance of LROPoller that returns either None or the result of cls(response) :rtype: ~azure.core.polling.LROPoller[None] - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - api_version = kwargs.pop('api_version', "2019-08-01") # type: str - polling = kwargs.pop('polling', True) # type: Union[bool, PollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType[None] - lro_delay = kwargs.pop( - 'polling_interval', - self._config.polling_interval - ) - cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2019-08-01")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[None] + polling = kwargs.pop("polling", True) # type: Union[bool, PollingMethod] + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token = kwargs.pop("continuation_token", None) # type: Optional[str] if cont_token is None: - raw_result = self._delete_initial( + raw_result = self._delete_initial( # type: ignore resource_group_name=resource_group_name, api_version=api_version, - cls=lambda x,y,z: x, + cls=lambda x, y, z: x, + headers=_headers, + params=_params, **kwargs ) - kwargs.pop('error_map', None) + kwargs.pop("error_map", None) - def get_long_running_output(pipeline_response): + def get_long_running_output(pipeline_response): # pylint: disable=inconsistent-return-statements if cls: return cls(pipeline_response, None, {}) - - if polling is True: polling_method = ARMPolling(lro_delay, **kwargs) - elif polling is False: polling_method = NoPolling() - else: polling_method = polling + if polling is True: + polling_method = cast(PollingMethod, ARMPolling(lro_delay, **kwargs)) # type: PollingMethod + elif polling is False: + polling_method = cast(PollingMethod, NoPolling()) + else: + polling_method = polling if cont_token: return LROPoller.from_continuation_token( polling_method=polling_method, continuation_token=cont_token, client=self._client, - deserialization_callback=get_long_running_output + deserialization_callback=get_long_running_output, ) return LROPoller(self._client, raw_result, get_long_running_output, polling_method) - begin_delete.metadata = {'url': "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}"} # type: ignore + begin_delete.metadata = {"url": "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}"} # type: ignore - @distributed_trace - def get( - self, - resource_group_name: str, - **kwargs: Any - ) -> "_models.ResourceGroup": + @distributed_trace + def get(self, resource_group_name: str, **kwargs: Any) -> _models.ResourceGroup: """Gets a resource group. :param resource_group_name: The name of the resource group to get. The name is case - insensitive. + insensitive. Required. :type resource_group_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: ResourceGroup, or the result of cls(response) + :return: ResourceGroup or the result of cls(response) :rtype: ~azure.mgmt.resource.resources.v2019_08_01.models.ResourceGroup - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.ResourceGroup"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + 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', "2019-08-01") # type: str + api_version = kwargs.pop("api_version", _params.pop("api-version", "2019-08-01")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[_models.ResourceGroup] - request = build_resource_groups_get_request( resource_group_name=resource_group_name, subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.get.metadata['url'], + template_url=self.get.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) - deserialized = self._deserialize('ResourceGroup', pipeline_response) + deserialized = self._deserialize("ResourceGroup", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - get.metadata = {'url': "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}"} # type: ignore - + get.metadata = {"url": "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}"} # type: ignore - @distributed_trace + @overload def update( self, resource_group_name: str, - parameters: "_models.ResourceGroupPatchable", + parameters: _models.ResourceGroupPatchable, + *, + content_type: str = "application/json", **kwargs: Any - ) -> "_models.ResourceGroup": + ) -> _models.ResourceGroup: """Updates a resource group. Resource groups can be updated through a simple PATCH operation to a group address. The format @@ -8906,25 +10072,90 @@ def update( the current value is retained. :param resource_group_name: The name of the resource group to update. The name is case - insensitive. + insensitive. Required. :type resource_group_name: str - :param parameters: Parameters supplied to update a resource group. + :param parameters: Parameters supplied to update a resource group. Required. :type parameters: ~azure.mgmt.resource.resources.v2019_08_01.models.ResourceGroupPatchable + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: ResourceGroup or the result of cls(response) + :rtype: ~azure.mgmt.resource.resources.v2019_08_01.models.ResourceGroup + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + def update( + self, resource_group_name: str, parameters: IO, *, content_type: str = "application/json", **kwargs: Any + ) -> _models.ResourceGroup: + """Updates a resource group. + + Resource groups can be updated through a simple PATCH operation to a group address. The format + of the request is the same as that for creating a resource group. If a field is unspecified, + the current value is retained. + + :param resource_group_name: The name of the resource group to update. The name is case + insensitive. Required. + :type resource_group_name: str + :param parameters: Parameters supplied to update a resource group. Required. + :type parameters: IO + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: ResourceGroup or the result of cls(response) + :rtype: ~azure.mgmt.resource.resources.v2019_08_01.models.ResourceGroup + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace + def update( + self, resource_group_name: str, parameters: Union[_models.ResourceGroupPatchable, IO], **kwargs: Any + ) -> _models.ResourceGroup: + """Updates a resource group. + + Resource groups can be updated through a simple PATCH operation to a group address. The format + of the request is the same as that for creating a resource group. If a field is unspecified, + the current value is retained. + + :param resource_group_name: The name of the resource group to update. The name is case + insensitive. Required. + :type resource_group_name: str + :param parameters: Parameters supplied to update a resource group. Is either a model type or a + IO type. Required. + :type parameters: ~azure.mgmt.resource.resources.v2019_08_01.models.ResourceGroupPatchable or + IO + :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. + Default value is None. + :paramtype content_type: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: ResourceGroup, or the result of cls(response) + :return: ResourceGroup or the result of cls(response) :rtype: ~azure.mgmt.resource.resources.v2019_08_01.models.ResourceGroup - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.ResourceGroup"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', "2019-08-01") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + api_version = kwargs.pop("api_version", _params.pop("api-version", "2019-08-01")) # type: str + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.ResourceGroup] - _json = self._serialize.body(parameters, 'ResourceGroupPatchable') + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(parameters, (IO, bytes)): + _content = parameters + else: + _json = self._serialize.body(parameters, "ResourceGroupPatchable") request = build_resource_groups_update_request( resource_group_name=resource_group_name, @@ -8932,65 +10163,77 @@ def update( api_version=api_version, content_type=content_type, json=_json, - template_url=self.update.metadata['url'], + content=_content, + template_url=self.update.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) - deserialized = self._deserialize('ResourceGroup', pipeline_response) + deserialized = self._deserialize("ResourceGroup", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - update.metadata = {'url': "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}"} # type: ignore - + update.metadata = {"url": "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}"} # type: ignore def _export_template_initial( - self, - resource_group_name: str, - parameters: "_models.ExportTemplateRequest", - **kwargs: Any - ) -> Optional["_models.ResourceGroupExportResult"]: - cls = kwargs.pop('cls', None) # type: ClsType[Optional["_models.ResourceGroupExportResult"]] + self, resource_group_name: str, parameters: Union[_models.ExportTemplateRequest, IO], **kwargs: Any + ) -> Optional[_models.ResourceGroupExportResult]: error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) - api_version = kwargs.pop('api_version', "2019-08-01") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - _json = self._serialize.body(parameters, 'ExportTemplateRequest') + api_version = kwargs.pop("api_version", _params.pop("api-version", "2019-08-01")) # type: str + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[Optional[_models.ResourceGroupExportResult]] - request = build_resource_groups_export_template_request_initial( - subscription_id=self._config.subscription_id, + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(parameters, (IO, bytes)): + _content = parameters + else: + _json = self._serialize.body(parameters, "ExportTemplateRequest") + + request = build_resource_groups_export_template_request( resource_group_name=resource_group_name, + subscription_id=self._config.subscription_id, api_version=api_version, content_type=content_type, json=_json, - template_url=self._export_template_initial.metadata['url'], + content=_content, + template_url=self._export_template_initial.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200, 202]: @@ -8999,29 +10242,34 @@ def _export_template_initial( deserialized = None if response.status_code == 200: - deserialized = self._deserialize('ResourceGroupExportResult', pipeline_response) + deserialized = self._deserialize("ResourceGroupExportResult", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - _export_template_initial.metadata = {'url': "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/exportTemplate"} # type: ignore - + _export_template_initial.metadata = {"url": "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/exportTemplate"} # type: ignore - @distributed_trace + @overload def begin_export_template( self, resource_group_name: str, - parameters: "_models.ExportTemplateRequest", + parameters: _models.ExportTemplateRequest, + *, + content_type: str = "application/json", **kwargs: Any - ) -> LROPoller["_models.ResourceGroupExportResult"]: + ) -> LROPoller[_models.ResourceGroupExportResult]: """Captures the specified resource group as a template. :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. :type resource_group_name: str - :param parameters: Parameters for exporting the template. + :param parameters: Parameters for exporting the template. Required. :type parameters: ~azure.mgmt.resource.resources.v2019_08_01.models.ExportTemplateRequest + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str :keyword callable cls: A custom type or function that will be passed the direct response :keyword str continuation_token: A continuation token to restart a poller from a saved state. :keyword polling: By default, your polling method will be ARMPolling. Pass in False for this @@ -9034,57 +10282,118 @@ def begin_export_template( of cls(response) :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.resource.resources.v2019_08_01.models.ResourceGroupExportResult] - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - api_version = kwargs.pop('api_version', "2019-08-01") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] - polling = kwargs.pop('polling', True) # type: Union[bool, PollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType["_models.ResourceGroupExportResult"] - lro_delay = kwargs.pop( - 'polling_interval', - self._config.polling_interval - ) - cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] + + @overload + def begin_export_template( + self, resource_group_name: str, parameters: IO, *, content_type: str = "application/json", **kwargs: Any + ) -> LROPoller[_models.ResourceGroupExportResult]: + """Captures the specified resource group as a template. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param parameters: Parameters for exporting the template. Required. + :type parameters: IO + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be ARMPolling. Pass in False for this + operation to not poll, or pass in your own initialized polling object for a personal polling + strategy. + :paramtype polling: bool or ~azure.core.polling.PollingMethod + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of LROPoller that returns either ResourceGroupExportResult or the result + of cls(response) + :rtype: + ~azure.core.polling.LROPoller[~azure.mgmt.resource.resources.v2019_08_01.models.ResourceGroupExportResult] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace + def begin_export_template( + self, resource_group_name: str, parameters: Union[_models.ExportTemplateRequest, IO], **kwargs: Any + ) -> LROPoller[_models.ResourceGroupExportResult]: + """Captures the specified resource group as a template. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param parameters: Parameters for exporting the template. Is either a model type or a IO type. + Required. + :type parameters: ~azure.mgmt.resource.resources.v2019_08_01.models.ExportTemplateRequest or IO + :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. + Default value is None. + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be ARMPolling. Pass in False for this + operation to not poll, or pass in your own initialized polling object for a personal polling + strategy. + :paramtype polling: bool or ~azure.core.polling.PollingMethod + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of LROPoller that returns either ResourceGroupExportResult or the result + of cls(response) + :rtype: + ~azure.core.polling.LROPoller[~azure.mgmt.resource.resources.v2019_08_01.models.ResourceGroupExportResult] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _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", "2019-08-01")) # type: str + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.ResourceGroupExportResult] + polling = kwargs.pop("polling", True) # type: Union[bool, PollingMethod] + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token = kwargs.pop("continuation_token", None) # type: Optional[str] if cont_token is None: - raw_result = self._export_template_initial( + raw_result = self._export_template_initial( # type: ignore resource_group_name=resource_group_name, parameters=parameters, api_version=api_version, content_type=content_type, - cls=lambda x,y,z: x, + cls=lambda x, y, z: x, + headers=_headers, + params=_params, **kwargs ) - kwargs.pop('error_map', None) + kwargs.pop("error_map", None) def get_long_running_output(pipeline_response): - response = pipeline_response.http_response - deserialized = self._deserialize('ResourceGroupExportResult', pipeline_response) + deserialized = self._deserialize("ResourceGroupExportResult", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - - if polling is True: polling_method = ARMPolling(lro_delay, lro_options={'final-state-via': 'location'}, **kwargs) - elif polling is False: polling_method = NoPolling() - else: polling_method = polling + if polling is True: + polling_method = cast( + PollingMethod, ARMPolling(lro_delay, lro_options={"final-state-via": "location"}, **kwargs) + ) # type: PollingMethod + elif polling is False: + polling_method = cast(PollingMethod, NoPolling()) + else: + polling_method = polling if cont_token: return LROPoller.from_continuation_token( polling_method=polling_method, continuation_token=cont_token, client=self._client, - deserialization_callback=get_long_running_output + deserialization_callback=get_long_running_output, ) return LROPoller(self._client, raw_result, get_long_running_output, polling_method) - begin_export_template.metadata = {'url': "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/exportTemplate"} # type: ignore + begin_export_template.metadata = {"url": "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/exportTemplate"} # type: ignore @distributed_trace def list( - self, - filter: Optional[str] = None, - top: Optional[int] = None, - **kwargs: Any - ) -> Iterable["_models.ResourceGroupListResult"]: + self, filter: Optional[str] = None, top: Optional[int] = None, **kwargs: Any + ) -> Iterable["_models.ResourceGroup"]: """Gets all the resource groups for a subscription. :param filter: The filter to apply on the operation.:code:`
`:code:`
`You can filter by @@ -9095,40 +10404,48 @@ def list( Default value is None. :type top: int :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either ResourceGroupListResult or the result of - cls(response) + :return: An iterator like instance of either ResourceGroup or the result of cls(response) :rtype: - ~azure.core.paging.ItemPaged[~azure.mgmt.resource.resources.v2019_08_01.models.ResourceGroupListResult] - :raises: ~azure.core.exceptions.HttpResponseError + ~azure.core.paging.ItemPaged[~azure.mgmt.resource.resources.v2019_08_01.models.ResourceGroup] + :raises ~azure.core.exceptions.HttpResponseError: """ - api_version = kwargs.pop('api_version', "2019-08-01") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2019-08-01")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[_models.ResourceGroupListResult] - cls = kwargs.pop('cls', None) # type: ClsType["_models.ResourceGroupListResult"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) + def prepare_request(next_link=None): if not next_link: - + request = build_resource_groups_list_request( subscription_id=self._config.subscription_id, - api_version=api_version, filter=filter, top=top, - template_url=self.list.metadata['url'], + 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.url = self._client.format_url(request.url) # type: ignore else: - - request = build_resource_groups_list_request( - subscription_id=self._config.subscription_id, - template_url=next_link, - ) + # make call to next link with the client's api-version + _parsed_next_link = urlparse(next_link) + _next_request_params = case_insensitive_dict(parse_qs(_parsed_next_link.query)) + _next_request_params["api-version"] = self._config.api_version + request = HttpRequest("GET", urljoin(next_link, _parsed_next_link.path), params=_next_request_params) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore request.method = "GET" return request @@ -9142,10 +10459,8 @@ def extract_data(pipeline_response): def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) response = pipeline_response.http_response @@ -9155,75 +10470,75 @@ def get_next(next_link=None): return pipeline_response + return ItemPaged(get_next, extract_data) + + list.metadata = {"url": "/subscriptions/{subscriptionId}/resourcegroups"} # type: ignore - return ItemPaged( - get_next, extract_data - ) - list.metadata = {'url': "/subscriptions/{subscriptionId}/resourcegroups"} # type: ignore -class TagsOperations(object): - """TagsOperations operations. - You should not instantiate this class directly. Instead, you should create a Client instance that - instantiates it for you and attaches it as an attribute. +class TagsOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. - :ivar models: Alias to model classes used in this operation group. - :type models: ~azure.mgmt.resource.resources.v2019_08_01.models - :param client: Client for service requests. - :param config: Configuration of service client. - :param serializer: An object model serializer. - :param deserializer: An object model deserializer. + Instead, you should access the following operations through + :class:`~azure.mgmt.resource.resources.v2019_08_01.ResourceManagementClient`'s + :attr:`tags` attribute. """ models = _models - def __init__(self, client, config, serializer, deserializer): - self._client = client - self._serialize = serializer - self._deserialize = deserializer - self._config = config + def __init__(self, *args, **kwargs): + input_args = list(args) + self._client = input_args.pop(0) if input_args else kwargs.pop("client") + self._config = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") @distributed_trace def delete_value( # pylint: disable=inconsistent-return-statements - self, - tag_name: str, - tag_value: str, - **kwargs: Any + self, tag_name: str, tag_value: str, **kwargs: Any ) -> None: """Deletes a tag value. - :param tag_name: The name of the tag. + :param tag_name: The name of the tag. Required. :type tag_name: str - :param tag_value: The value of the tag to delete. + :param tag_value: The value of the tag to delete. Required. :type tag_value: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: None, or the result of cls(response) + :return: None or the result of cls(response) :rtype: None - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType[None] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + 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', "2019-08-01") # type: str + api_version = kwargs.pop("api_version", _params.pop("api-version", "2019-08-01")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[None] - request = build_tags_delete_value_request( tag_name=tag_name, tag_value=tag_value, subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.delete_value.metadata['url'], + template_url=self.delete_value.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200, 204]: @@ -9233,51 +10548,51 @@ def delete_value( # pylint: disable=inconsistent-return-statements if cls: return cls(pipeline_response, None, {}) - delete_value.metadata = {'url': "/subscriptions/{subscriptionId}/tagNames/{tagName}/tagValues/{tagValue}"} # type: ignore - + delete_value.metadata = {"url": "/subscriptions/{subscriptionId}/tagNames/{tagName}/tagValues/{tagValue}"} # type: ignore @distributed_trace - def create_or_update_value( - self, - tag_name: str, - tag_value: str, - **kwargs: Any - ) -> "_models.TagValue": + def create_or_update_value(self, tag_name: str, tag_value: str, **kwargs: Any) -> _models.TagValue: """Creates a tag value. The name of the tag must already exist. - :param tag_name: The name of the tag. + :param tag_name: The name of the tag. Required. :type tag_name: str - :param tag_value: The value of the tag to create. + :param tag_value: The value of the tag to create. Required. :type tag_value: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: TagValue, or the result of cls(response) + :return: TagValue or the result of cls(response) :rtype: ~azure.mgmt.resource.resources.v2019_08_01.models.TagValue - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.TagValue"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) - api_version = kwargs.pop('api_version', "2019-08-01") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2019-08-01")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[_models.TagValue] - request = build_tags_create_or_update_value_request( tag_name=tag_name, tag_value=tag_value, subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.create_or_update_value.metadata['url'], + template_url=self.create_or_update_value.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200, 201]: @@ -9285,61 +10600,62 @@ def create_or_update_value( raise HttpResponseError(response=response, error_format=ARMErrorFormat) if response.status_code == 200: - deserialized = self._deserialize('TagValue', pipeline_response) + deserialized = self._deserialize("TagValue", pipeline_response) if response.status_code == 201: - deserialized = self._deserialize('TagValue', pipeline_response) + deserialized = self._deserialize("TagValue", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - create_or_update_value.metadata = {'url': "/subscriptions/{subscriptionId}/tagNames/{tagName}/tagValues/{tagValue}"} # type: ignore - + create_or_update_value.metadata = {"url": "/subscriptions/{subscriptionId}/tagNames/{tagName}/tagValues/{tagValue}"} # type: ignore @distributed_trace - def create_or_update( - self, - tag_name: str, - **kwargs: Any - ) -> "_models.TagDetails": + def create_or_update(self, tag_name: str, **kwargs: Any) -> _models.TagDetails: """Creates a tag in the subscription. The tag name can have a maximum of 512 characters and is case insensitive. Tag names created by Azure have prefixes of microsoft, azure, or windows. You cannot create tags with one of these prefixes. - :param tag_name: The name of the tag to create. + :param tag_name: The name of the tag to create. Required. :type tag_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: TagDetails, or the result of cls(response) + :return: TagDetails or the result of cls(response) :rtype: ~azure.mgmt.resource.resources.v2019_08_01.models.TagDetails - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.TagDetails"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) - api_version = kwargs.pop('api_version', "2019-08-01") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2019-08-01")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[_models.TagDetails] - request = build_tags_create_or_update_request( tag_name=tag_name, subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.create_or_update.metadata['url'], + template_url=self.create_or_update.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200, 201]: @@ -9347,59 +10663,60 @@ def create_or_update( raise HttpResponseError(response=response, error_format=ARMErrorFormat) if response.status_code == 200: - deserialized = self._deserialize('TagDetails', pipeline_response) + deserialized = self._deserialize("TagDetails", pipeline_response) if response.status_code == 201: - deserialized = self._deserialize('TagDetails', pipeline_response) + deserialized = self._deserialize("TagDetails", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - create_or_update.metadata = {'url': "/subscriptions/{subscriptionId}/tagNames/{tagName}"} # type: ignore - + create_or_update.metadata = {"url": "/subscriptions/{subscriptionId}/tagNames/{tagName}"} # type: ignore @distributed_trace - def delete( # pylint: disable=inconsistent-return-statements - self, - tag_name: str, - **kwargs: Any - ) -> None: + def delete(self, tag_name: str, **kwargs: Any) -> None: # pylint: disable=inconsistent-return-statements """Deletes a tag from the subscription. You must remove all values from a resource tag before you can delete it. - :param tag_name: The name of the tag. + :param tag_name: The name of the tag. Required. :type tag_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: None, or the result of cls(response) + :return: None or the result of cls(response) :rtype: None - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType[None] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) - api_version = kwargs.pop('api_version', "2019-08-01") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2019-08-01")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[None] - request = build_tags_delete_request( tag_name=tag_name, subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.delete.metadata['url'], + template_url=self.delete.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200, 204]: @@ -9409,48 +10726,53 @@ def delete( # pylint: disable=inconsistent-return-statements if cls: return cls(pipeline_response, None, {}) - delete.metadata = {'url': "/subscriptions/{subscriptionId}/tagNames/{tagName}"} # type: ignore - + delete.metadata = {"url": "/subscriptions/{subscriptionId}/tagNames/{tagName}"} # type: ignore @distributed_trace - def list( - self, - **kwargs: Any - ) -> Iterable["_models.TagsListResult"]: + def list(self, **kwargs: Any) -> Iterable["_models.TagDetails"]: """Gets the names and values of all resource tags that are defined in a subscription. :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either TagsListResult or the result of cls(response) + :return: An iterator like instance of either TagDetails or the result of cls(response) :rtype: - ~azure.core.paging.ItemPaged[~azure.mgmt.resource.resources.v2019_08_01.models.TagsListResult] - :raises: ~azure.core.exceptions.HttpResponseError + ~azure.core.paging.ItemPaged[~azure.mgmt.resource.resources.v2019_08_01.models.TagDetails] + :raises ~azure.core.exceptions.HttpResponseError: """ - api_version = kwargs.pop('api_version', "2019-08-01") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2019-08-01")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[_models.TagsListResult] - cls = kwargs.pop('cls', None) # type: ClsType["_models.TagsListResult"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) + def prepare_request(next_link=None): if not next_link: - + request = build_tags_list_request( subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.list.metadata['url'], + template_url=self.list.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore else: - - request = build_tags_list_request( - subscription_id=self._config.subscription_id, - template_url=next_link, - ) + # make call to next link with the client's api-version + _parsed_next_link = urlparse(next_link) + _next_request_params = case_insensitive_dict(parse_qs(_parsed_next_link.query)) + _next_request_params["api-version"] = self._config.api_version + request = HttpRequest("GET", urljoin(next_link, _parsed_next_link.path), params=_next_request_params) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore request.method = "GET" return request @@ -9464,10 +10786,8 @@ def extract_data(pipeline_response): def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) response = pipeline_response.http_response @@ -9477,146 +10797,147 @@ def get_next(next_link=None): return pipeline_response + return ItemPaged(get_next, extract_data) - return ItemPaged( - get_next, extract_data - ) - list.metadata = {'url': "/subscriptions/{subscriptionId}/tagNames"} # type: ignore -class DeploymentOperationsOperations(object): - """DeploymentOperationsOperations operations. + list.metadata = {"url": "/subscriptions/{subscriptionId}/tagNames"} # type: ignore - You should not instantiate this class directly. Instead, you should create a Client instance that - instantiates it for you and attaches it as an attribute. - :ivar models: Alias to model classes used in this operation group. - :type models: ~azure.mgmt.resource.resources.v2019_08_01.models - :param client: Client for service requests. - :param config: Configuration of service client. - :param serializer: An object model serializer. - :param deserializer: An object model deserializer. +class DeploymentOperationsOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. + + Instead, you should access the following operations through + :class:`~azure.mgmt.resource.resources.v2019_08_01.ResourceManagementClient`'s + :attr:`deployment_operations` attribute. """ models = _models - def __init__(self, client, config, serializer, deserializer): - self._client = client - self._serialize = serializer - self._deserialize = deserializer - self._config = config + def __init__(self, *args, **kwargs): + input_args = list(args) + self._client = input_args.pop(0) if input_args else kwargs.pop("client") + self._config = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") @distributed_trace def get_at_scope( - self, - scope: str, - deployment_name: str, - operation_id: str, - **kwargs: Any - ) -> "_models.DeploymentOperation": + self, scope: str, deployment_name: str, operation_id: str, **kwargs: Any + ) -> _models.DeploymentOperation: """Gets a deployments operation. - :param scope: The scope of a deployment. + :param scope: The scope of a deployment. Required. :type scope: str - :param deployment_name: The name of the deployment. + :param deployment_name: The name of the deployment. Required. :type deployment_name: str - :param operation_id: The ID of the operation to get. + :param operation_id: The ID of the operation to get. Required. :type operation_id: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: DeploymentOperation, or the result of cls(response) + :return: DeploymentOperation or the result of cls(response) :rtype: ~azure.mgmt.resource.resources.v2019_08_01.models.DeploymentOperation - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.DeploymentOperation"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) - api_version = kwargs.pop('api_version', "2019-08-01") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2019-08-01")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[_models.DeploymentOperation] - request = build_deployment_operations_get_at_scope_request( scope=scope, deployment_name=deployment_name, operation_id=operation_id, api_version=api_version, - template_url=self.get_at_scope.metadata['url'], + template_url=self.get_at_scope.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) - deserialized = self._deserialize('DeploymentOperation', pipeline_response) + deserialized = self._deserialize("DeploymentOperation", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - get_at_scope.metadata = {'url': "/{scope}/providers/Microsoft.Resources/deployments/{deploymentName}/operations/{operationId}"} # type: ignore - + get_at_scope.metadata = {"url": "/{scope}/providers/Microsoft.Resources/deployments/{deploymentName}/operations/{operationId}"} # type: ignore @distributed_trace def list_at_scope( - self, - scope: str, - deployment_name: str, - top: Optional[int] = None, - **kwargs: Any - ) -> Iterable["_models.DeploymentOperationsListResult"]: + self, scope: str, deployment_name: str, top: Optional[int] = None, **kwargs: Any + ) -> Iterable["_models.DeploymentOperation"]: """Gets all deployments operations for a deployment. - :param scope: The scope of a deployment. + :param scope: The scope of a deployment. Required. :type scope: str - :param deployment_name: The name of the deployment. + :param deployment_name: The name of the deployment. Required. :type deployment_name: str :param top: The number of results to return. Default value is None. :type top: int :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either DeploymentOperationsListResult or the result of - cls(response) + :return: An iterator like instance of either DeploymentOperation or the result of cls(response) :rtype: - ~azure.core.paging.ItemPaged[~azure.mgmt.resource.resources.v2019_08_01.models.DeploymentOperationsListResult] - :raises: ~azure.core.exceptions.HttpResponseError + ~azure.core.paging.ItemPaged[~azure.mgmt.resource.resources.v2019_08_01.models.DeploymentOperation] + :raises ~azure.core.exceptions.HttpResponseError: """ - api_version = kwargs.pop('api_version', "2019-08-01") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2019-08-01")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[_models.DeploymentOperationsListResult] - cls = kwargs.pop('cls', None) # type: ClsType["_models.DeploymentOperationsListResult"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) + def prepare_request(next_link=None): if not next_link: - + request = build_deployment_operations_list_at_scope_request( scope=scope, deployment_name=deployment_name, - api_version=api_version, top=top, - template_url=self.list_at_scope.metadata['url'], + api_version=api_version, + template_url=self.list_at_scope.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore else: - - request = build_deployment_operations_list_at_scope_request( - scope=scope, - deployment_name=deployment_name, - template_url=next_link, - ) + # make call to next link with the client's api-version + _parsed_next_link = urlparse(next_link) + _next_request_params = case_insensitive_dict(parse_qs(_parsed_next_link.query)) + _next_request_params["api-version"] = self._config.api_version + request = HttpRequest("GET", urljoin(next_link, _parsed_next_link.path), params=_next_request_params) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore request.method = "GET" return request @@ -9630,10 +10951,8 @@ def extract_data(pipeline_response): def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) response = pipeline_response.http_response @@ -9643,116 +10962,121 @@ def get_next(next_link=None): return pipeline_response + return ItemPaged(get_next, extract_data) - return ItemPaged( - get_next, extract_data - ) - list_at_scope.metadata = {'url': "/{scope}/providers/Microsoft.Resources/deployments/{deploymentName}/operations"} # type: ignore + list_at_scope.metadata = {"url": "/{scope}/providers/Microsoft.Resources/deployments/{deploymentName}/operations"} # type: ignore @distributed_trace def get_at_tenant_scope( - self, - deployment_name: str, - operation_id: str, - **kwargs: Any - ) -> "_models.DeploymentOperation": + self, deployment_name: str, operation_id: str, **kwargs: Any + ) -> _models.DeploymentOperation: """Gets a deployments operation. - :param deployment_name: The name of the deployment. + :param deployment_name: The name of the deployment. Required. :type deployment_name: str - :param operation_id: The ID of the operation to get. + :param operation_id: The ID of the operation to get. Required. :type operation_id: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: DeploymentOperation, or the result of cls(response) + :return: DeploymentOperation or the result of cls(response) :rtype: ~azure.mgmt.resource.resources.v2019_08_01.models.DeploymentOperation - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.DeploymentOperation"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + 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', "2019-08-01") # type: str + api_version = kwargs.pop("api_version", _params.pop("api-version", "2019-08-01")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[_models.DeploymentOperation] - request = build_deployment_operations_get_at_tenant_scope_request( deployment_name=deployment_name, operation_id=operation_id, api_version=api_version, - template_url=self.get_at_tenant_scope.metadata['url'], + template_url=self.get_at_tenant_scope.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) - deserialized = self._deserialize('DeploymentOperation', pipeline_response) + deserialized = self._deserialize("DeploymentOperation", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - get_at_tenant_scope.metadata = {'url': "/providers/Microsoft.Resources/deployments/{deploymentName}/operations/{operationId}"} # type: ignore - + get_at_tenant_scope.metadata = {"url": "/providers/Microsoft.Resources/deployments/{deploymentName}/operations/{operationId}"} # type: ignore @distributed_trace def list_at_tenant_scope( - self, - deployment_name: str, - top: Optional[int] = None, - **kwargs: Any - ) -> Iterable["_models.DeploymentOperationsListResult"]: + self, deployment_name: str, top: Optional[int] = None, **kwargs: Any + ) -> Iterable["_models.DeploymentOperation"]: """Gets all deployments operations for a deployment. - :param deployment_name: The name of the deployment. + :param deployment_name: The name of the deployment. Required. :type deployment_name: str :param top: The number of results to return. Default value is None. :type top: int :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either DeploymentOperationsListResult or the result of - cls(response) + :return: An iterator like instance of either DeploymentOperation or the result of cls(response) :rtype: - ~azure.core.paging.ItemPaged[~azure.mgmt.resource.resources.v2019_08_01.models.DeploymentOperationsListResult] - :raises: ~azure.core.exceptions.HttpResponseError + ~azure.core.paging.ItemPaged[~azure.mgmt.resource.resources.v2019_08_01.models.DeploymentOperation] + :raises ~azure.core.exceptions.HttpResponseError: """ - api_version = kwargs.pop('api_version', "2019-08-01") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2019-08-01")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[_models.DeploymentOperationsListResult] - cls = kwargs.pop('cls', None) # type: ClsType["_models.DeploymentOperationsListResult"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) + def prepare_request(next_link=None): if not next_link: - + request = build_deployment_operations_list_at_tenant_scope_request( deployment_name=deployment_name, - api_version=api_version, top=top, - template_url=self.list_at_tenant_scope.metadata['url'], + api_version=api_version, + template_url=self.list_at_tenant_scope.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore else: - - request = build_deployment_operations_list_at_tenant_scope_request( - deployment_name=deployment_name, - template_url=next_link, - ) + # make call to next link with the client's api-version + _parsed_next_link = urlparse(next_link) + _next_request_params = case_insensitive_dict(parse_qs(_parsed_next_link.query)) + _next_request_params["api-version"] = self._config.api_version + request = HttpRequest("GET", urljoin(next_link, _parsed_next_link.path), params=_next_request_params) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore request.method = "GET" return request @@ -9766,10 +11090,8 @@ def extract_data(pipeline_response): def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) response = pipeline_response.http_response @@ -9779,125 +11101,127 @@ def get_next(next_link=None): return pipeline_response + return ItemPaged(get_next, extract_data) - return ItemPaged( - get_next, extract_data - ) - list_at_tenant_scope.metadata = {'url': "/providers/Microsoft.Resources/deployments/{deploymentName}/operations"} # type: ignore + list_at_tenant_scope.metadata = {"url": "/providers/Microsoft.Resources/deployments/{deploymentName}/operations"} # type: ignore @distributed_trace def get_at_management_group_scope( - self, - group_id: str, - deployment_name: str, - operation_id: str, - **kwargs: Any - ) -> "_models.DeploymentOperation": + self, group_id: str, deployment_name: str, operation_id: str, **kwargs: Any + ) -> _models.DeploymentOperation: """Gets a deployments operation. - :param group_id: The management group ID. + :param group_id: The management group ID. Required. :type group_id: str - :param deployment_name: The name of the deployment. + :param deployment_name: The name of the deployment. Required. :type deployment_name: str - :param operation_id: The ID of the operation to get. + :param operation_id: The ID of the operation to get. Required. :type operation_id: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: DeploymentOperation, or the result of cls(response) + :return: DeploymentOperation or the result of cls(response) :rtype: ~azure.mgmt.resource.resources.v2019_08_01.models.DeploymentOperation - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.DeploymentOperation"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + 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', "2019-08-01") # type: str + api_version = kwargs.pop("api_version", _params.pop("api-version", "2019-08-01")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[_models.DeploymentOperation] - request = build_deployment_operations_get_at_management_group_scope_request( group_id=group_id, deployment_name=deployment_name, operation_id=operation_id, api_version=api_version, - template_url=self.get_at_management_group_scope.metadata['url'], + template_url=self.get_at_management_group_scope.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) - deserialized = self._deserialize('DeploymentOperation', pipeline_response) + deserialized = self._deserialize("DeploymentOperation", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - get_at_management_group_scope.metadata = {'url': "/providers/Microsoft.Management/managementGroups/{groupId}/providers/Microsoft.Resources/deployments/{deploymentName}/operations/{operationId}"} # type: ignore - + get_at_management_group_scope.metadata = {"url": "/providers/Microsoft.Management/managementGroups/{groupId}/providers/Microsoft.Resources/deployments/{deploymentName}/operations/{operationId}"} # type: ignore @distributed_trace def list_at_management_group_scope( - self, - group_id: str, - deployment_name: str, - top: Optional[int] = None, - **kwargs: Any - ) -> Iterable["_models.DeploymentOperationsListResult"]: + self, group_id: str, deployment_name: str, top: Optional[int] = None, **kwargs: Any + ) -> Iterable["_models.DeploymentOperation"]: """Gets all deployments operations for a deployment. - :param group_id: The management group ID. + :param group_id: The management group ID. Required. :type group_id: str - :param deployment_name: The name of the deployment. + :param deployment_name: The name of the deployment. Required. :type deployment_name: str :param top: The number of results to return. Default value is None. :type top: int :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either DeploymentOperationsListResult or the result of - cls(response) + :return: An iterator like instance of either DeploymentOperation or the result of cls(response) :rtype: - ~azure.core.paging.ItemPaged[~azure.mgmt.resource.resources.v2019_08_01.models.DeploymentOperationsListResult] - :raises: ~azure.core.exceptions.HttpResponseError + ~azure.core.paging.ItemPaged[~azure.mgmt.resource.resources.v2019_08_01.models.DeploymentOperation] + :raises ~azure.core.exceptions.HttpResponseError: """ - api_version = kwargs.pop('api_version', "2019-08-01") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2019-08-01")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[_models.DeploymentOperationsListResult] - cls = kwargs.pop('cls', None) # type: ClsType["_models.DeploymentOperationsListResult"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) + def prepare_request(next_link=None): if not next_link: - + request = build_deployment_operations_list_at_management_group_scope_request( group_id=group_id, deployment_name=deployment_name, - api_version=api_version, top=top, - template_url=self.list_at_management_group_scope.metadata['url'], + api_version=api_version, + template_url=self.list_at_management_group_scope.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore else: - - request = build_deployment_operations_list_at_management_group_scope_request( - group_id=group_id, - deployment_name=deployment_name, - template_url=next_link, - ) + # make call to next link with the client's api-version + _parsed_next_link = urlparse(next_link) + _next_request_params = case_insensitive_dict(parse_qs(_parsed_next_link.query)) + _next_request_params["api-version"] = self._config.api_version + request = HttpRequest("GET", urljoin(next_link, _parsed_next_link.path), params=_next_request_params) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore request.method = "GET" return request @@ -9911,10 +11235,8 @@ def extract_data(pipeline_response): def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) response = pipeline_response.http_response @@ -9924,119 +11246,123 @@ def get_next(next_link=None): return pipeline_response + return ItemPaged(get_next, extract_data) - return ItemPaged( - get_next, extract_data - ) - list_at_management_group_scope.metadata = {'url': "/providers/Microsoft.Management/managementGroups/{groupId}/providers/Microsoft.Resources/deployments/{deploymentName}/operations"} # type: ignore + list_at_management_group_scope.metadata = {"url": "/providers/Microsoft.Management/managementGroups/{groupId}/providers/Microsoft.Resources/deployments/{deploymentName}/operations"} # type: ignore @distributed_trace def get_at_subscription_scope( - self, - deployment_name: str, - operation_id: str, - **kwargs: Any - ) -> "_models.DeploymentOperation": + self, deployment_name: str, operation_id: str, **kwargs: Any + ) -> _models.DeploymentOperation: """Gets a deployments operation. - :param deployment_name: The name of the deployment. + :param deployment_name: The name of the deployment. Required. :type deployment_name: str - :param operation_id: The ID of the operation to get. + :param operation_id: The ID of the operation to get. Required. :type operation_id: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: DeploymentOperation, or the result of cls(response) + :return: DeploymentOperation or the result of cls(response) :rtype: ~azure.mgmt.resource.resources.v2019_08_01.models.DeploymentOperation - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.DeploymentOperation"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) - api_version = kwargs.pop('api_version', "2019-08-01") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2019-08-01")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[_models.DeploymentOperation] - request = build_deployment_operations_get_at_subscription_scope_request( deployment_name=deployment_name, operation_id=operation_id, subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.get_at_subscription_scope.metadata['url'], + template_url=self.get_at_subscription_scope.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) - deserialized = self._deserialize('DeploymentOperation', pipeline_response) + deserialized = self._deserialize("DeploymentOperation", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - get_at_subscription_scope.metadata = {'url': "/subscriptions/{subscriptionId}/providers/Microsoft.Resources/deployments/{deploymentName}/operations/{operationId}"} # type: ignore - + get_at_subscription_scope.metadata = {"url": "/subscriptions/{subscriptionId}/providers/Microsoft.Resources/deployments/{deploymentName}/operations/{operationId}"} # type: ignore @distributed_trace def list_at_subscription_scope( - self, - deployment_name: str, - top: Optional[int] = None, - **kwargs: Any - ) -> Iterable["_models.DeploymentOperationsListResult"]: + self, deployment_name: str, top: Optional[int] = None, **kwargs: Any + ) -> Iterable["_models.DeploymentOperation"]: """Gets all deployments operations for a deployment. - :param deployment_name: The name of the deployment. + :param deployment_name: The name of the deployment. Required. :type deployment_name: str :param top: The number of results to return. Default value is None. :type top: int :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either DeploymentOperationsListResult or the result of - cls(response) + :return: An iterator like instance of either DeploymentOperation or the result of cls(response) :rtype: - ~azure.core.paging.ItemPaged[~azure.mgmt.resource.resources.v2019_08_01.models.DeploymentOperationsListResult] - :raises: ~azure.core.exceptions.HttpResponseError + ~azure.core.paging.ItemPaged[~azure.mgmt.resource.resources.v2019_08_01.models.DeploymentOperation] + :raises ~azure.core.exceptions.HttpResponseError: """ - api_version = kwargs.pop('api_version', "2019-08-01") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2019-08-01")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[_models.DeploymentOperationsListResult] - cls = kwargs.pop('cls', None) # type: ClsType["_models.DeploymentOperationsListResult"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) + def prepare_request(next_link=None): if not next_link: - + request = build_deployment_operations_list_at_subscription_scope_request( deployment_name=deployment_name, subscription_id=self._config.subscription_id, - api_version=api_version, top=top, - template_url=self.list_at_subscription_scope.metadata['url'], + api_version=api_version, + template_url=self.list_at_subscription_scope.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore else: - - request = build_deployment_operations_list_at_subscription_scope_request( - deployment_name=deployment_name, - subscription_id=self._config.subscription_id, - template_url=next_link, - ) + # make call to next link with the client's api-version + _parsed_next_link = urlparse(next_link) + _next_request_params = case_insensitive_dict(parse_qs(_parsed_next_link.query)) + _next_request_params["api-version"] = self._config.api_version + request = HttpRequest("GET", urljoin(next_link, _parsed_next_link.path), params=_next_request_params) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore request.method = "GET" return request @@ -10050,10 +11376,8 @@ def extract_data(pipeline_response): def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) response = pipeline_response.http_response @@ -10063,128 +11387,131 @@ def get_next(next_link=None): return pipeline_response + return ItemPaged(get_next, extract_data) - return ItemPaged( - get_next, extract_data - ) - list_at_subscription_scope.metadata = {'url': "/subscriptions/{subscriptionId}/providers/Microsoft.Resources/deployments/{deploymentName}/operations"} # type: ignore + list_at_subscription_scope.metadata = {"url": "/subscriptions/{subscriptionId}/providers/Microsoft.Resources/deployments/{deploymentName}/operations"} # type: ignore @distributed_trace def get( - self, - resource_group_name: str, - deployment_name: str, - operation_id: str, - **kwargs: Any - ) -> "_models.DeploymentOperation": + self, resource_group_name: str, deployment_name: str, operation_id: str, **kwargs: Any + ) -> _models.DeploymentOperation: """Gets a deployments operation. :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. :type resource_group_name: str - :param deployment_name: The name of the deployment. + :param deployment_name: The name of the deployment. Required. :type deployment_name: str - :param operation_id: The ID of the operation to get. + :param operation_id: The ID of the operation to get. Required. :type operation_id: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: DeploymentOperation, or the result of cls(response) + :return: DeploymentOperation or the result of cls(response) :rtype: ~azure.mgmt.resource.resources.v2019_08_01.models.DeploymentOperation - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.DeploymentOperation"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + 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', "2019-08-01") # type: str + api_version = kwargs.pop("api_version", _params.pop("api-version", "2019-08-01")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[_models.DeploymentOperation] - request = build_deployment_operations_get_request( resource_group_name=resource_group_name, deployment_name=deployment_name, operation_id=operation_id, subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.get.metadata['url'], + template_url=self.get.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) - deserialized = self._deserialize('DeploymentOperation', pipeline_response) + deserialized = self._deserialize("DeploymentOperation", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - get.metadata = {'url': "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/deployments/{deploymentName}/operations/{operationId}"} # type: ignore - + get.metadata = {"url": "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/deployments/{deploymentName}/operations/{operationId}"} # type: ignore @distributed_trace def list( - self, - resource_group_name: str, - deployment_name: str, - top: Optional[int] = None, - **kwargs: Any - ) -> Iterable["_models.DeploymentOperationsListResult"]: + self, resource_group_name: str, deployment_name: str, top: Optional[int] = None, **kwargs: Any + ) -> Iterable["_models.DeploymentOperation"]: """Gets all deployments operations for a deployment. :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. :type resource_group_name: str - :param deployment_name: The name of the deployment. + :param deployment_name: The name of the deployment. Required. :type deployment_name: str :param top: The number of results to return. Default value is None. :type top: int :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either DeploymentOperationsListResult or the result of - cls(response) + :return: An iterator like instance of either DeploymentOperation or the result of cls(response) :rtype: - ~azure.core.paging.ItemPaged[~azure.mgmt.resource.resources.v2019_08_01.models.DeploymentOperationsListResult] - :raises: ~azure.core.exceptions.HttpResponseError + ~azure.core.paging.ItemPaged[~azure.mgmt.resource.resources.v2019_08_01.models.DeploymentOperation] + :raises ~azure.core.exceptions.HttpResponseError: """ - api_version = kwargs.pop('api_version', "2019-08-01") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2019-08-01")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[_models.DeploymentOperationsListResult] - cls = kwargs.pop('cls', None) # type: ClsType["_models.DeploymentOperationsListResult"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) + def prepare_request(next_link=None): if not next_link: - + request = build_deployment_operations_list_request( resource_group_name=resource_group_name, deployment_name=deployment_name, subscription_id=self._config.subscription_id, - api_version=api_version, top=top, - template_url=self.list.metadata['url'], + 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.url = self._client.format_url(request.url) # type: ignore else: - - request = build_deployment_operations_list_request( - resource_group_name=resource_group_name, - deployment_name=deployment_name, - subscription_id=self._config.subscription_id, - template_url=next_link, - ) + # make call to next link with the client's api-version + _parsed_next_link = urlparse(next_link) + _next_request_params = case_insensitive_dict(parse_qs(_parsed_next_link.query)) + _next_request_params["api-version"] = self._config.api_version + request = HttpRequest("GET", urljoin(next_link, _parsed_next_link.path), params=_next_request_params) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore request.method = "GET" return request @@ -10198,10 +11525,8 @@ def extract_data(pipeline_response): def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) response = pipeline_response.http_response @@ -10211,8 +11536,6 @@ def get_next(next_link=None): return pipeline_response + return ItemPaged(get_next, extract_data) - return ItemPaged( - get_next, extract_data - ) - list.metadata = {'url': "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/deployments/{deploymentName}/operations"} # type: ignore + list.metadata = {"url": "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/deployments/{deploymentName}/operations"} # type: ignore diff --git a/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/resources/v2019_08_01/operations/_patch.py b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/resources/v2019_08_01/operations/_patch.py new file mode 100644 index 0000000000000..f7dd32510333d --- /dev/null +++ b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/resources/v2019_08_01/operations/_patch.py @@ -0,0 +1,20 @@ +# ------------------------------------ +# Copyright (c) Microsoft Corporation. +# Licensed under the MIT License. +# ------------------------------------ +"""Customize generated code here. + +Follow our quickstart for examples: https://aka.ms/azsdk/python/dpcodegen/python/customize +""" +from typing import List + +__all__: List[str] = [] # Add all objects you want publicly available to users at this package level + + +def patch_sdk(): + """Do not remove from this file. + + `patch_sdk` is a last resort escape hatch that allows you to do customizations + you can't accomplish using the techniques described in + https://aka.ms/azsdk/python/dpcodegen/python/customize + """ diff --git a/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/resources/v2019_10_01/__init__.py b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/resources/v2019_10_01/__init__.py index 449220069f2f2..2b201470d075e 100644 --- a/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/resources/v2019_10_01/__init__.py +++ b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/resources/v2019_10_01/__init__.py @@ -10,9 +10,15 @@ from ._version import VERSION __version__ = VERSION -__all__ = ['ResourceManagementClient'] -# `._patch.py` is used for handwritten extensions to the generated code -# Example: https://github.com/Azure/azure-sdk-for-python/blob/main/doc/dev/customize_code/how-to-patch-sdk-code.md -from ._patch import patch_sdk -patch_sdk() +try: + from ._patch import __all__ as _patch_all + from ._patch import * # type: ignore # pylint: disable=unused-wildcard-import +except ImportError: + _patch_all = [] +from ._patch import patch_sdk as _patch_sdk + +__all__ = ["ResourceManagementClient"] +__all__.extend([p for p in _patch_all if p not in __all__]) + +_patch_sdk() diff --git a/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/resources/v2019_10_01/_configuration.py b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/resources/v2019_10_01/_configuration.py index ab64500052f5b..4aefd549a0172 100644 --- a/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/resources/v2019_10_01/_configuration.py +++ b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/resources/v2019_10_01/_configuration.py @@ -25,23 +25,18 @@ class ResourceManagementClientConfiguration(Configuration): # pylint: disable=t Note that all parameters used to create this instance are saved as instance attributes. - :param credential: Credential needed for the client to connect to Azure. + :param credential: Credential needed for the client to connect to Azure. Required. :type credential: ~azure.core.credentials.TokenCredential - :param subscription_id: The ID of the target subscription. + :param subscription_id: The ID of the target subscription. Required. :type subscription_id: str :keyword api_version: Api Version. Default value is "2019-10-01". Note that overriding this default value may result in unsupported behavior. :paramtype api_version: str """ - def __init__( - self, - credential: "TokenCredential", - subscription_id: str, - **kwargs: Any - ) -> None: + def __init__(self, credential: "TokenCredential", subscription_id: str, **kwargs: Any) -> None: super(ResourceManagementClientConfiguration, self).__init__(**kwargs) - api_version = kwargs.pop('api_version', "2019-10-01") # type: str + api_version = kwargs.pop("api_version", "2019-10-01") # type: str if credential is None: raise ValueError("Parameter 'credential' must not be None.") @@ -51,23 +46,24 @@ def __init__( self.credential = credential self.subscription_id = subscription_id self.api_version = api_version - self.credential_scopes = kwargs.pop('credential_scopes', ['https://management.azure.com/.default']) - kwargs.setdefault('sdk_moniker', 'mgmt-resource/{}'.format(VERSION)) + self.credential_scopes = kwargs.pop("credential_scopes", ["https://management.azure.com/.default"]) + kwargs.setdefault("sdk_moniker", "mgmt-resource/{}".format(VERSION)) self._configure(**kwargs) def _configure( - self, - **kwargs # type: Any + self, **kwargs # type: Any ): # type: (...) -> 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) - self.logging_policy = kwargs.get('logging_policy') or policies.NetworkTraceLoggingPolicy(**kwargs) - self.http_logging_policy = kwargs.get('http_logging_policy') or ARMHttpLoggingPolicy(**kwargs) - self.retry_policy = kwargs.get('retry_policy') or policies.RetryPolicy(**kwargs) - self.custom_hook_policy = kwargs.get('custom_hook_policy') or policies.CustomHookPolicy(**kwargs) - self.redirect_policy = kwargs.get('redirect_policy') or policies.RedirectPolicy(**kwargs) - self.authentication_policy = kwargs.get('authentication_policy') + 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) + self.logging_policy = kwargs.get("logging_policy") or policies.NetworkTraceLoggingPolicy(**kwargs) + self.http_logging_policy = kwargs.get("http_logging_policy") or ARMHttpLoggingPolicy(**kwargs) + self.retry_policy = kwargs.get("retry_policy") or policies.RetryPolicy(**kwargs) + self.custom_hook_policy = kwargs.get("custom_hook_policy") or policies.CustomHookPolicy(**kwargs) + self.redirect_policy = kwargs.get("redirect_policy") or policies.RedirectPolicy(**kwargs) + self.authentication_policy = kwargs.get("authentication_policy") if self.credential and not self.authentication_policy: - self.authentication_policy = ARMChallengeAuthenticationPolicy(self.credential, *self.credential_scopes, **kwargs) + self.authentication_policy = ARMChallengeAuthenticationPolicy( + self.credential, *self.credential_scopes, **kwargs + ) diff --git a/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/resources/v2019_10_01/_metadata.json b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/resources/v2019_10_01/_metadata.json index c346b5b079e55..ae3264548e9ec 100644 --- a/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/resources/v2019_10_01/_metadata.json +++ b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/resources/v2019_10_01/_metadata.json @@ -10,20 +10,20 @@ "azure_arm": true, "has_lro_operations": true, "client_side_validation": false, - "sync_imports": "{\"typing\": {\"azurecore\": {\"azure.core.credentials\": [\"TokenCredential\"]}}, \"regular\": {\"azurecore\": {\"azure.profiles\": [\"KnownProfiles\", \"ProfileDefinition\"], \"azure.profiles.multiapiclient\": [\"MultiApiClientMixin\"], \"azure.mgmt.core\": [\"ARMPipelineClient\"]}, \"local\": {\"._configuration\": [\"ResourceManagementClientConfiguration\"]}, \"thirdparty\": {\"msrest\": [\"Deserializer\", \"Serializer\"]}}, \"conditional\": {\"stdlib\": {\"typing\": [\"Any\", \"Optional\"]}}}", - "async_imports": "{\"typing\": {\"azurecore\": {\"azure.core.credentials_async\": [\"AsyncTokenCredential\"], \"azure.core.credentials\": [\"TokenCredential\"]}}, \"regular\": {\"azurecore\": {\"azure.profiles\": [\"KnownProfiles\", \"ProfileDefinition\"], \"azure.profiles.multiapiclient\": [\"MultiApiClientMixin\"], \"azure.mgmt.core\": [\"AsyncARMPipelineClient\"]}, \"local\": {\"._configuration\": [\"ResourceManagementClientConfiguration\"]}, \"thirdparty\": {\"msrest\": [\"Deserializer\", \"Serializer\"]}}, \"conditional\": {\"stdlib\": {\"typing\": [\"Any\", \"Optional\"]}}}" + "sync_imports": "{\"conditional\": {\"stdlib\": {\"typing\": [\"Any\", \"Optional\"]}}, \"regular\": {\"azurecore\": {\"azure.mgmt.core\": [\"ARMPipelineClient\"], \"azure.profiles\": [\"KnownProfiles\", \"ProfileDefinition\"], \"azure.profiles.multiapiclient\": [\"MultiApiClientMixin\"]}, \"local\": {\"._configuration\": [\"ResourceManagementClientConfiguration\"], \".._serialization\": [\"Deserializer\", \"Serializer\"]}}, \"typing\": {\"azurecore\": {\"azure.core.credentials\": [\"TokenCredential\"]}}}", + "async_imports": "{\"conditional\": {\"stdlib\": {\"typing\": [\"Any\", \"Optional\"]}}, \"regular\": {\"azurecore\": {\"azure.mgmt.core\": [\"AsyncARMPipelineClient\"], \"azure.profiles\": [\"KnownProfiles\", \"ProfileDefinition\"], \"azure.profiles.multiapiclient\": [\"MultiApiClientMixin\"]}, \"local\": {\"._configuration\": [\"ResourceManagementClientConfiguration\"], \"..._serialization\": [\"Deserializer\", \"Serializer\"]}}, \"typing\": {\"azurecore\": {\"azure.core.credentials_async\": [\"AsyncTokenCredential\"]}}}" }, "global_parameters": { "sync": { "credential": { - "signature": "credential, # type: \"TokenCredential\"", - "description": "Credential needed for the client to connect to Azure.", + "signature": "credential: \"TokenCredential\",", + "description": "Credential needed for the client to connect to Azure. Required.", "docstring_type": "~azure.core.credentials.TokenCredential", "required": true }, "subscription_id": { - "signature": "subscription_id, # type: str", - "description": "The ID of the target subscription.", + "signature": "subscription_id: str,", + "description": "The ID of the target subscription. Required.", "docstring_type": "str", "required": true } @@ -31,13 +31,13 @@ "async": { "credential": { "signature": "credential: \"AsyncTokenCredential\",", - "description": "Credential needed for the client to connect to Azure.", + "description": "Credential needed for the client to connect to Azure. Required.", "docstring_type": "~azure.core.credentials_async.AsyncTokenCredential", "required": true }, "subscription_id": { "signature": "subscription_id: str,", - "description": "The ID of the target subscription.", + "description": "The ID of the target subscription. Required.", "docstring_type": "str", "required": true } @@ -54,7 +54,7 @@ "required": false }, "base_url": { - "signature": "base_url=\"https://management.azure.com\", # type: str", + "signature": "base_url: str = \"https://management.azure.com\",", "description": "Service URL", "docstring_type": "str", "required": false diff --git a/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/resources/v2019_10_01/_patch.py b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/resources/v2019_10_01/_patch.py index 74e48ecd07cf3..f99e77fef9861 100644 --- a/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/resources/v2019_10_01/_patch.py +++ b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/resources/v2019_10_01/_patch.py @@ -28,4 +28,4 @@ # This file is used for handwritten extensions to the generated code. Example: # https://github.com/Azure/azure-sdk-for-python/blob/main/doc/dev/customize_code/how-to-patch-sdk-code.md def patch_sdk(): - pass \ No newline at end of file + pass diff --git a/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/resources/v2019_10_01/_resource_management_client.py b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/resources/v2019_10_01/_resource_management_client.py index 139daaac40a07..7bf062e0f8345 100644 --- a/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/resources/v2019_10_01/_resource_management_client.py +++ b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/resources/v2019_10_01/_resource_management_client.py @@ -9,20 +9,28 @@ from copy import deepcopy from typing import Any, TYPE_CHECKING -from msrest import Deserializer, Serializer - from azure.core.rest import HttpRequest, HttpResponse from azure.mgmt.core import ARMPipelineClient from . import models +from .._serialization import Deserializer, Serializer from ._configuration import ResourceManagementClientConfiguration -from .operations import DeploymentOperationsOperations, DeploymentsOperations, Operations, ProvidersOperations, ResourceGroupsOperations, ResourcesOperations, TagsOperations +from .operations import ( + DeploymentOperationsOperations, + DeploymentsOperations, + Operations, + ProvidersOperations, + ResourceGroupsOperations, + ResourcesOperations, + TagsOperations, +) if TYPE_CHECKING: # pylint: disable=unused-import,ungrouped-imports from azure.core.credentials import TokenCredential -class ResourceManagementClient: # pylint: disable=too-many-instance-attributes + +class ResourceManagementClient: # pylint: disable=client-accepts-api-version-keyword,too-many-instance-attributes """Provides operations for working with resources and resource groups. :ivar operations: Operations operations @@ -42,9 +50,9 @@ class ResourceManagementClient: # pylint: disable=too-many-instance-attribute :ivar deployment_operations: DeploymentOperationsOperations operations :vartype deployment_operations: azure.mgmt.resource.resources.v2019_10_01.operations.DeploymentOperationsOperations - :param credential: Credential needed for the client to connect to Azure. + :param credential: Credential needed for the client to connect to Azure. Required. :type credential: ~azure.core.credentials.TokenCredential - :param subscription_id: The ID of the target subscription. + :param subscription_id: The ID of the target subscription. Required. :type subscription_id: str :param base_url: Service URL. Default value is "https://management.azure.com". :type base_url: str @@ -62,7 +70,9 @@ def __init__( base_url: str = "https://management.azure.com", **kwargs: Any ) -> None: - self._config = ResourceManagementClientConfiguration(credential=credential, subscription_id=subscription_id, **kwargs) + self._config = ResourceManagementClientConfiguration( + credential=credential, subscription_id=subscription_id, **kwargs + ) self._client = ARMPipelineClient(base_url=base_url, config=self._config, **kwargs) client_models = {k: v for k, v in models.__dict__.items() if isinstance(v, type)} @@ -75,14 +85,11 @@ def __init__( self.resources = ResourcesOperations(self._client, self._config, self._serialize, self._deserialize) self.resource_groups = ResourceGroupsOperations(self._client, self._config, self._serialize, self._deserialize) self.tags = TagsOperations(self._client, self._config, self._serialize, self._deserialize) - self.deployment_operations = DeploymentOperationsOperations(self._client, self._config, self._serialize, self._deserialize) - + self.deployment_operations = DeploymentOperationsOperations( + self._client, self._config, self._serialize, self._deserialize + ) - def _send_request( - self, - request: HttpRequest, - **kwargs: Any - ) -> HttpResponse: + def _send_request(self, request: HttpRequest, **kwargs: Any) -> HttpResponse: """Runs the network request through the client's chained policies. >>> from azure.core.rest import HttpRequest @@ -91,7 +98,7 @@ def _send_request( >>> response = client._send_request(request) - For more information on this code flow, see https://aka.ms/azsdk/python/protocol/quickstart + For more information on this code flow, see https://aka.ms/azsdk/dpcodegen/python/send_request :param request: The network request you want to make. Required. :type request: ~azure.core.rest.HttpRequest diff --git a/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/resources/v2019_10_01/_vendor.py b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/resources/v2019_10_01/_vendor.py index 138f663c53a4e..9aad73fc743e7 100644 --- a/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/resources/v2019_10_01/_vendor.py +++ b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/resources/v2019_10_01/_vendor.py @@ -7,6 +7,7 @@ from azure.core.pipeline.transport import HttpRequest + def _convert_request(request, files=None): data = request.content if not files else None request = HttpRequest(method=request.method, url=request.url, headers=request.headers, data=data) @@ -14,6 +15,7 @@ def _convert_request(request, files=None): request.set_formdata_body(files) return request + def _format_url_section(template, **kwargs): components = template.split("/") while components: @@ -21,7 +23,5 @@ def _format_url_section(template, **kwargs): 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 - ] + components = [c for c in formatted_components if "{}".format(key.args[0]) not in c] template = "/".join(components) diff --git a/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/resources/v2019_10_01/_version.py b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/resources/v2019_10_01/_version.py index a012ac01c480c..e5754a47ce68f 100644 --- a/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/resources/v2019_10_01/_version.py +++ b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/resources/v2019_10_01/_version.py @@ -6,4 +6,4 @@ # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -VERSION = "21.1.0" +VERSION = "1.0.0b1" diff --git a/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/resources/v2019_10_01/aio/__init__.py b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/resources/v2019_10_01/aio/__init__.py index c6c3cf64a37a6..98d6782c2530c 100644 --- a/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/resources/v2019_10_01/aio/__init__.py +++ b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/resources/v2019_10_01/aio/__init__.py @@ -7,9 +7,15 @@ # -------------------------------------------------------------------------- from ._resource_management_client import ResourceManagementClient -__all__ = ['ResourceManagementClient'] -# `._patch.py` is used for handwritten extensions to the generated code -# Example: https://github.com/Azure/azure-sdk-for-python/blob/main/doc/dev/customize_code/how-to-patch-sdk-code.md -from ._patch import patch_sdk -patch_sdk() +try: + from ._patch import __all__ as _patch_all + from ._patch import * # type: ignore # pylint: disable=unused-wildcard-import +except ImportError: + _patch_all = [] +from ._patch import patch_sdk as _patch_sdk + +__all__ = ["ResourceManagementClient"] +__all__.extend([p for p in _patch_all if p not in __all__]) + +_patch_sdk() diff --git a/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/resources/v2019_10_01/aio/_configuration.py b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/resources/v2019_10_01/aio/_configuration.py index b315e6d3b6514..e1c4d82b05041 100644 --- a/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/resources/v2019_10_01/aio/_configuration.py +++ b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/resources/v2019_10_01/aio/_configuration.py @@ -25,23 +25,18 @@ class ResourceManagementClientConfiguration(Configuration): # pylint: disable=t Note that all parameters used to create this instance are saved as instance attributes. - :param credential: Credential needed for the client to connect to Azure. + :param credential: Credential needed for the client to connect to Azure. Required. :type credential: ~azure.core.credentials_async.AsyncTokenCredential - :param subscription_id: The ID of the target subscription. + :param subscription_id: The ID of the target subscription. Required. :type subscription_id: str :keyword api_version: Api Version. Default value is "2019-10-01". Note that overriding this default value may result in unsupported behavior. :paramtype api_version: str """ - def __init__( - self, - credential: "AsyncTokenCredential", - subscription_id: str, - **kwargs: Any - ) -> None: + def __init__(self, credential: "AsyncTokenCredential", subscription_id: str, **kwargs: Any) -> None: super(ResourceManagementClientConfiguration, self).__init__(**kwargs) - api_version = kwargs.pop('api_version', "2019-10-01") # type: str + api_version = kwargs.pop("api_version", "2019-10-01") # type: str if credential is None: raise ValueError("Parameter 'credential' must not be None.") @@ -51,22 +46,21 @@ def __init__( self.credential = credential self.subscription_id = subscription_id self.api_version = api_version - self.credential_scopes = kwargs.pop('credential_scopes', ['https://management.azure.com/.default']) - kwargs.setdefault('sdk_moniker', 'mgmt-resource/{}'.format(VERSION)) + self.credential_scopes = kwargs.pop("credential_scopes", ["https://management.azure.com/.default"]) + kwargs.setdefault("sdk_moniker", "mgmt-resource/{}".format(VERSION)) self._configure(**kwargs) - 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) - self.logging_policy = kwargs.get('logging_policy') or policies.NetworkTraceLoggingPolicy(**kwargs) - self.http_logging_policy = kwargs.get('http_logging_policy') or ARMHttpLoggingPolicy(**kwargs) - self.retry_policy = kwargs.get('retry_policy') or policies.AsyncRetryPolicy(**kwargs) - self.custom_hook_policy = kwargs.get('custom_hook_policy') or policies.CustomHookPolicy(**kwargs) - self.redirect_policy = kwargs.get('redirect_policy') or policies.AsyncRedirectPolicy(**kwargs) - self.authentication_policy = kwargs.get('authentication_policy') + 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) + self.logging_policy = kwargs.get("logging_policy") or policies.NetworkTraceLoggingPolicy(**kwargs) + self.http_logging_policy = kwargs.get("http_logging_policy") or ARMHttpLoggingPolicy(**kwargs) + self.retry_policy = kwargs.get("retry_policy") or policies.AsyncRetryPolicy(**kwargs) + self.custom_hook_policy = kwargs.get("custom_hook_policy") or policies.CustomHookPolicy(**kwargs) + self.redirect_policy = kwargs.get("redirect_policy") or policies.AsyncRedirectPolicy(**kwargs) + self.authentication_policy = kwargs.get("authentication_policy") if self.credential and not self.authentication_policy: - self.authentication_policy = AsyncARMChallengeAuthenticationPolicy(self.credential, *self.credential_scopes, **kwargs) + self.authentication_policy = AsyncARMChallengeAuthenticationPolicy( + self.credential, *self.credential_scopes, **kwargs + ) diff --git a/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/resources/v2019_10_01/aio/_patch.py b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/resources/v2019_10_01/aio/_patch.py index 74e48ecd07cf3..f99e77fef9861 100644 --- a/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/resources/v2019_10_01/aio/_patch.py +++ b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/resources/v2019_10_01/aio/_patch.py @@ -28,4 +28,4 @@ # This file is used for handwritten extensions to the generated code. Example: # https://github.com/Azure/azure-sdk-for-python/blob/main/doc/dev/customize_code/how-to-patch-sdk-code.md def patch_sdk(): - pass \ No newline at end of file + pass diff --git a/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/resources/v2019_10_01/aio/_resource_management_client.py b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/resources/v2019_10_01/aio/_resource_management_client.py index a49735af77384..cb3d2d255092d 100644 --- a/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/resources/v2019_10_01/aio/_resource_management_client.py +++ b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/resources/v2019_10_01/aio/_resource_management_client.py @@ -9,20 +9,28 @@ from copy import deepcopy from typing import Any, Awaitable, TYPE_CHECKING -from msrest import Deserializer, Serializer - from azure.core.rest import AsyncHttpResponse, HttpRequest from azure.mgmt.core import AsyncARMPipelineClient from .. import models +from ..._serialization import Deserializer, Serializer from ._configuration import ResourceManagementClientConfiguration -from .operations import DeploymentOperationsOperations, DeploymentsOperations, Operations, ProvidersOperations, ResourceGroupsOperations, ResourcesOperations, TagsOperations +from .operations import ( + DeploymentOperationsOperations, + DeploymentsOperations, + Operations, + ProvidersOperations, + ResourceGroupsOperations, + ResourcesOperations, + TagsOperations, +) if TYPE_CHECKING: # pylint: disable=unused-import,ungrouped-imports from azure.core.credentials_async import AsyncTokenCredential -class ResourceManagementClient: # pylint: disable=too-many-instance-attributes + +class ResourceManagementClient: # pylint: disable=client-accepts-api-version-keyword,too-many-instance-attributes """Provides operations for working with resources and resource groups. :ivar operations: Operations operations @@ -44,9 +52,9 @@ class ResourceManagementClient: # pylint: disable=too-many-instance-attribute :ivar deployment_operations: DeploymentOperationsOperations operations :vartype deployment_operations: azure.mgmt.resource.resources.v2019_10_01.aio.operations.DeploymentOperationsOperations - :param credential: Credential needed for the client to connect to Azure. + :param credential: Credential needed for the client to connect to Azure. Required. :type credential: ~azure.core.credentials_async.AsyncTokenCredential - :param subscription_id: The ID of the target subscription. + :param subscription_id: The ID of the target subscription. Required. :type subscription_id: str :param base_url: Service URL. Default value is "https://management.azure.com". :type base_url: str @@ -64,7 +72,9 @@ def __init__( base_url: str = "https://management.azure.com", **kwargs: Any ) -> None: - self._config = ResourceManagementClientConfiguration(credential=credential, subscription_id=subscription_id, **kwargs) + self._config = ResourceManagementClientConfiguration( + credential=credential, subscription_id=subscription_id, **kwargs + ) self._client = AsyncARMPipelineClient(base_url=base_url, config=self._config, **kwargs) client_models = {k: v for k, v in models.__dict__.items() if isinstance(v, type)} @@ -77,14 +87,11 @@ def __init__( self.resources = ResourcesOperations(self._client, self._config, self._serialize, self._deserialize) self.resource_groups = ResourceGroupsOperations(self._client, self._config, self._serialize, self._deserialize) self.tags = TagsOperations(self._client, self._config, self._serialize, self._deserialize) - self.deployment_operations = DeploymentOperationsOperations(self._client, self._config, self._serialize, self._deserialize) - + self.deployment_operations = DeploymentOperationsOperations( + self._client, self._config, self._serialize, self._deserialize + ) - def _send_request( - self, - request: HttpRequest, - **kwargs: Any - ) -> Awaitable[AsyncHttpResponse]: + def _send_request(self, request: HttpRequest, **kwargs: Any) -> Awaitable[AsyncHttpResponse]: """Runs the network request through the client's chained policies. >>> from azure.core.rest import HttpRequest @@ -93,7 +100,7 @@ def _send_request( >>> response = await client._send_request(request) - For more information on this code flow, see https://aka.ms/azsdk/python/protocol/quickstart + For more information on this code flow, see https://aka.ms/azsdk/dpcodegen/python/send_request :param request: The network request you want to make. Required. :type request: ~azure.core.rest.HttpRequest diff --git a/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/resources/v2019_10_01/aio/operations/__init__.py b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/resources/v2019_10_01/aio/operations/__init__.py index 53876d82bf5d7..804fee65e3137 100644 --- a/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/resources/v2019_10_01/aio/operations/__init__.py +++ b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/resources/v2019_10_01/aio/operations/__init__.py @@ -14,12 +14,18 @@ from ._operations import TagsOperations from ._operations import DeploymentOperationsOperations +from ._patch import __all__ as _patch_all +from ._patch import * # type: ignore # pylint: disable=unused-wildcard-import +from ._patch import patch_sdk as _patch_sdk + __all__ = [ - 'Operations', - 'DeploymentsOperations', - 'ProvidersOperations', - 'ResourcesOperations', - 'ResourceGroupsOperations', - 'TagsOperations', - 'DeploymentOperationsOperations', + "Operations", + "DeploymentsOperations", + "ProvidersOperations", + "ResourcesOperations", + "ResourceGroupsOperations", + "TagsOperations", + "DeploymentOperationsOperations", ] +__all__.extend([p for p in _patch_all if p not in __all__]) +_patch_sdk() diff --git a/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/resources/v2019_10_01/aio/operations/_operations.py b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/resources/v2019_10_01/aio/operations/_operations.py index bd40855930e8e..0481408c8f8fd 100644 --- a/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/resources/v2019_10_01/aio/operations/_operations.py +++ b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/resources/v2019_10_01/aio/operations/_operations.py @@ -6,84 +6,198 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -from typing import Any, AsyncIterable, Callable, Dict, Optional, TypeVar, Union +import sys +from typing import Any, AsyncIterable, Callable, Dict, IO, Optional, TypeVar, Union, cast, overload +from urllib.parse import parse_qs, urljoin, urlparse from azure.core.async_paging import AsyncItemPaged, AsyncList -from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error +from azure.core.exceptions import ( + ClientAuthenticationError, + HttpResponseError, + ResourceExistsError, + ResourceNotFoundError, + ResourceNotModifiedError, + map_error, +) from azure.core.pipeline import PipelineResponse from azure.core.pipeline.transport import AsyncHttpResponse from azure.core.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 from azure.mgmt.core.polling.async_arm_polling import AsyncARMPolling from ... import models as _models from ..._vendor import _convert_request -from ...operations._operations import build_deployment_operations_get_at_management_group_scope_request, build_deployment_operations_get_at_scope_request, build_deployment_operations_get_at_subscription_scope_request, build_deployment_operations_get_at_tenant_scope_request, build_deployment_operations_get_request, build_deployment_operations_list_at_management_group_scope_request, build_deployment_operations_list_at_scope_request, build_deployment_operations_list_at_subscription_scope_request, build_deployment_operations_list_at_tenant_scope_request, build_deployment_operations_list_request, build_deployments_calculate_template_hash_request, build_deployments_cancel_at_management_group_scope_request, build_deployments_cancel_at_scope_request, build_deployments_cancel_at_subscription_scope_request, build_deployments_cancel_at_tenant_scope_request, build_deployments_cancel_request, build_deployments_check_existence_at_management_group_scope_request, build_deployments_check_existence_at_scope_request, build_deployments_check_existence_at_subscription_scope_request, build_deployments_check_existence_at_tenant_scope_request, build_deployments_check_existence_request, build_deployments_create_or_update_at_management_group_scope_request_initial, build_deployments_create_or_update_at_scope_request_initial, build_deployments_create_or_update_at_subscription_scope_request_initial, build_deployments_create_or_update_at_tenant_scope_request_initial, build_deployments_create_or_update_request_initial, build_deployments_delete_at_management_group_scope_request_initial, build_deployments_delete_at_scope_request_initial, build_deployments_delete_at_subscription_scope_request_initial, build_deployments_delete_at_tenant_scope_request_initial, build_deployments_delete_request_initial, build_deployments_export_template_at_management_group_scope_request, build_deployments_export_template_at_scope_request, build_deployments_export_template_at_subscription_scope_request, build_deployments_export_template_at_tenant_scope_request, build_deployments_export_template_request, build_deployments_get_at_management_group_scope_request, build_deployments_get_at_scope_request, build_deployments_get_at_subscription_scope_request, build_deployments_get_at_tenant_scope_request, build_deployments_get_request, build_deployments_list_at_management_group_scope_request, build_deployments_list_at_scope_request, build_deployments_list_at_subscription_scope_request, build_deployments_list_at_tenant_scope_request, build_deployments_list_by_resource_group_request, build_deployments_validate_at_management_group_scope_request_initial, build_deployments_validate_at_scope_request_initial, build_deployments_validate_at_subscription_scope_request_initial, build_deployments_validate_at_tenant_scope_request_initial, build_deployments_validate_request_initial, build_deployments_what_if_at_management_group_scope_request_initial, build_deployments_what_if_at_subscription_scope_request_initial, build_deployments_what_if_at_tenant_scope_request_initial, build_deployments_what_if_request_initial, build_operations_list_request, build_providers_get_at_tenant_scope_request, build_providers_get_request, build_providers_list_at_tenant_scope_request, build_providers_list_request, build_providers_register_request, build_providers_unregister_request, build_resource_groups_check_existence_request, build_resource_groups_create_or_update_request, build_resource_groups_delete_request_initial, build_resource_groups_export_template_request_initial, build_resource_groups_get_request, build_resource_groups_list_request, build_resource_groups_update_request, build_resources_check_existence_by_id_request, build_resources_check_existence_request, build_resources_create_or_update_by_id_request_initial, build_resources_create_or_update_request_initial, build_resources_delete_by_id_request_initial, build_resources_delete_request_initial, build_resources_get_by_id_request, build_resources_get_request, build_resources_list_by_resource_group_request, build_resources_list_request, build_resources_move_resources_request_initial, build_resources_update_by_id_request_initial, build_resources_update_request_initial, build_resources_validate_move_resources_request_initial, build_tags_create_or_update_at_scope_request, build_tags_create_or_update_request, build_tags_create_or_update_value_request, build_tags_delete_at_scope_request, build_tags_delete_request, build_tags_delete_value_request, build_tags_get_at_scope_request, build_tags_list_request, build_tags_update_at_scope_request -T = TypeVar('T') +from ...operations._operations import ( + build_deployment_operations_get_at_management_group_scope_request, + build_deployment_operations_get_at_scope_request, + build_deployment_operations_get_at_subscription_scope_request, + build_deployment_operations_get_at_tenant_scope_request, + build_deployment_operations_get_request, + build_deployment_operations_list_at_management_group_scope_request, + build_deployment_operations_list_at_scope_request, + build_deployment_operations_list_at_subscription_scope_request, + build_deployment_operations_list_at_tenant_scope_request, + build_deployment_operations_list_request, + build_deployments_calculate_template_hash_request, + build_deployments_cancel_at_management_group_scope_request, + build_deployments_cancel_at_scope_request, + build_deployments_cancel_at_subscription_scope_request, + build_deployments_cancel_at_tenant_scope_request, + build_deployments_cancel_request, + build_deployments_check_existence_at_management_group_scope_request, + build_deployments_check_existence_at_scope_request, + build_deployments_check_existence_at_subscription_scope_request, + build_deployments_check_existence_at_tenant_scope_request, + build_deployments_check_existence_request, + build_deployments_create_or_update_at_management_group_scope_request, + build_deployments_create_or_update_at_scope_request, + build_deployments_create_or_update_at_subscription_scope_request, + build_deployments_create_or_update_at_tenant_scope_request, + build_deployments_create_or_update_request, + build_deployments_delete_at_management_group_scope_request, + build_deployments_delete_at_scope_request, + build_deployments_delete_at_subscription_scope_request, + build_deployments_delete_at_tenant_scope_request, + build_deployments_delete_request, + build_deployments_export_template_at_management_group_scope_request, + build_deployments_export_template_at_scope_request, + build_deployments_export_template_at_subscription_scope_request, + build_deployments_export_template_at_tenant_scope_request, + build_deployments_export_template_request, + build_deployments_get_at_management_group_scope_request, + build_deployments_get_at_scope_request, + build_deployments_get_at_subscription_scope_request, + build_deployments_get_at_tenant_scope_request, + build_deployments_get_request, + build_deployments_list_at_management_group_scope_request, + build_deployments_list_at_scope_request, + build_deployments_list_at_subscription_scope_request, + build_deployments_list_at_tenant_scope_request, + build_deployments_list_by_resource_group_request, + build_deployments_validate_at_management_group_scope_request, + build_deployments_validate_at_scope_request, + build_deployments_validate_at_subscription_scope_request, + build_deployments_validate_at_tenant_scope_request, + build_deployments_validate_request, + build_deployments_what_if_at_management_group_scope_request, + build_deployments_what_if_at_subscription_scope_request, + build_deployments_what_if_at_tenant_scope_request, + build_deployments_what_if_request, + build_operations_list_request, + build_providers_get_at_tenant_scope_request, + build_providers_get_request, + build_providers_list_at_tenant_scope_request, + build_providers_list_request, + build_providers_register_request, + build_providers_unregister_request, + build_resource_groups_check_existence_request, + build_resource_groups_create_or_update_request, + build_resource_groups_delete_request, + build_resource_groups_export_template_request, + build_resource_groups_get_request, + build_resource_groups_list_request, + build_resource_groups_update_request, + build_resources_check_existence_by_id_request, + build_resources_check_existence_request, + build_resources_create_or_update_by_id_request, + build_resources_create_or_update_request, + build_resources_delete_by_id_request, + build_resources_delete_request, + build_resources_get_by_id_request, + build_resources_get_request, + build_resources_list_by_resource_group_request, + build_resources_list_request, + build_resources_move_resources_request, + build_resources_update_by_id_request, + build_resources_update_request, + build_resources_validate_move_resources_request, + build_tags_create_or_update_at_scope_request, + build_tags_create_or_update_request, + build_tags_create_or_update_value_request, + build_tags_delete_at_scope_request, + build_tags_delete_request, + build_tags_delete_value_request, + build_tags_get_at_scope_request, + build_tags_list_request, + build_tags_update_at_scope_request, +) + +T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] +if sys.version_info >= (3, 9): + from collections.abc import MutableMapping +else: + from typing import MutableMapping # type: ignore # pylint: disable=ungrouped-imports +JSON = MutableMapping[str, Any] # pylint: disable=unsubscriptable-object -class Operations: - """Operations async operations. - You should not instantiate this class directly. Instead, you should create a Client instance that - instantiates it for you and attaches it as an attribute. +class Operations: + """ + .. warning:: + **DO NOT** instantiate this class directly. - :ivar models: Alias to model classes used in this operation group. - :type models: ~azure.mgmt.resource.resources.v2019_10_01.models - :param client: Client for service requests. - :param config: Configuration of service client. - :param serializer: An object model serializer. - :param deserializer: An object model deserializer. + Instead, you should access the following operations through + :class:`~azure.mgmt.resource.resources.v2019_10_01.aio.ResourceManagementClient`'s + :attr:`operations` attribute. """ models = _models - def __init__(self, client, config, serializer, deserializer) -> None: - self._client = client - self._serialize = serializer - self._deserialize = deserializer - self._config = config + def __init__(self, *args, **kwargs) -> None: + input_args = list(args) + self._client = input_args.pop(0) if input_args else kwargs.pop("client") + self._config = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") @distributed_trace - def list( - self, - **kwargs: Any - ) -> AsyncIterable["_models.OperationListResult"]: + def list(self, **kwargs: Any) -> AsyncIterable["_models.Operation"]: """Lists all of the available Microsoft.Resources REST API operations. :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either OperationListResult or the result of cls(response) + :return: An iterator like instance of either Operation or the result of cls(response) :rtype: - ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.resource.resources.v2019_10_01.models.OperationListResult] - :raises: ~azure.core.exceptions.HttpResponseError + ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.resource.resources.v2019_10_01.models.Operation] + :raises ~azure.core.exceptions.HttpResponseError: """ - api_version = kwargs.pop('api_version', "2019-10-01") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2019-10-01")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[_models.OperationListResult] - cls = kwargs.pop('cls', None) # type: ClsType["_models.OperationListResult"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) + def prepare_request(next_link=None): if not next_link: - + request = build_operations_list_request( api_version=api_version, - template_url=self.list.metadata['url'], + template_url=self.list.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore else: - - request = build_operations_list_request( - template_url=next_link, - ) + # make call to next link with the client's api-version + _parsed_next_link = urlparse(next_link) + _next_request_params = case_insensitive_dict(parse_qs(_parsed_next_link.query)) + _next_request_params["api-version"] = self._config.api_version + request = HttpRequest("GET", urljoin(next_link, _parsed_next_link.path), params=_next_request_params) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore request.method = "GET" return request @@ -97,10 +211,8 @@ async def extract_data(pipeline_response): async def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) response = pipeline_response.http_response @@ -110,62 +222,62 @@ async def get_next(next_link=None): return pipeline_response + return AsyncItemPaged(get_next, extract_data) - return AsyncItemPaged( - get_next, extract_data - ) - list.metadata = {'url': "/providers/Microsoft.Resources/operations"} # type: ignore -class DeploymentsOperations: # pylint: disable=too-many-public-methods - """DeploymentsOperations async operations. + list.metadata = {"url": "/providers/Microsoft.Resources/operations"} # type: ignore - You should not instantiate this class directly. Instead, you should create a Client instance that - instantiates it for you and attaches it as an attribute. - :ivar models: Alias to model classes used in this operation group. - :type models: ~azure.mgmt.resource.resources.v2019_10_01.models - :param client: Client for service requests. - :param config: Configuration of service client. - :param serializer: An object model serializer. - :param deserializer: An object model deserializer. +class DeploymentsOperations: # pylint: disable=too-many-public-methods + """ + .. warning:: + **DO NOT** instantiate this class directly. + + Instead, you should access the following operations through + :class:`~azure.mgmt.resource.resources.v2019_10_01.aio.ResourceManagementClient`'s + :attr:`deployments` attribute. """ models = _models - def __init__(self, client, config, serializer, deserializer) -> None: - self._client = client - self._serialize = serializer - self._deserialize = deserializer - self._config = config + def __init__(self, *args, **kwargs) -> None: + input_args = list(args) + self._client = input_args.pop(0) if input_args else kwargs.pop("client") + self._config = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") async def _delete_at_scope_initial( # pylint: disable=inconsistent-return-statements - self, - scope: str, - deployment_name: str, - **kwargs: Any + self, scope: str, deployment_name: str, **kwargs: Any ) -> None: - cls = kwargs.pop('cls', None) # type: ClsType[None] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + 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', "2019-10-01") # type: str + api_version = kwargs.pop("api_version", _params.pop("api-version", "2019-10-01")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[None] - - request = build_deployments_delete_at_scope_request_initial( + request = build_deployments_delete_at_scope_request( scope=scope, deployment_name=deployment_name, api_version=api_version, - template_url=self._delete_at_scope_initial.metadata['url'], + template_url=self._delete_at_scope_initial.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [202, 204]: @@ -175,16 +287,10 @@ async def _delete_at_scope_initial( # pylint: disable=inconsistent-return-state if cls: return cls(pipeline_response, None, {}) - _delete_at_scope_initial.metadata = {'url': "/{scope}/providers/Microsoft.Resources/deployments/{deploymentName}"} # type: ignore - + _delete_at_scope_initial.metadata = {"url": "/{scope}/providers/Microsoft.Resources/deployments/{deploymentName}"} # type: ignore @distributed_trace_async - async def begin_delete_at_scope( # pylint: disable=inconsistent-return-statements - self, - scope: str, - deployment_name: str, - **kwargs: Any - ) -> AsyncLROPoller[None]: + async def begin_delete_at_scope(self, scope: str, deployment_name: str, **kwargs: Any) -> AsyncLROPoller[None]: """Deletes a deployment from the deployment history. A template deployment that is currently running cannot be deleted. Deleting a template @@ -195,9 +301,9 @@ async def begin_delete_at_scope( # pylint: disable=inconsistent-return-statemen process finishes, the URI in the Location header returns a status of 204 on success. If the asynchronous request failed, the URI in the Location header returns an error-level status code. - :param scope: The resource scope. + :param scope: The resource scope. Required. :type scope: str - :param deployment_name: The name of the deployment. + :param deployment_name: The name of the deployment. Required. :type deployment_name: str :keyword callable cls: A custom type or function that will be passed the direct response :keyword str continuation_token: A continuation token to restart a poller from a saved state. @@ -209,86 +315,91 @@ async def begin_delete_at_scope( # pylint: disable=inconsistent-return-statemen Retry-After header is present. :return: An instance of AsyncLROPoller that returns either None or the result of cls(response) :rtype: ~azure.core.polling.AsyncLROPoller[None] - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - api_version = kwargs.pop('api_version', "2019-10-01") # type: str - polling = kwargs.pop('polling', True) # type: Union[bool, AsyncPollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType[None] - lro_delay = kwargs.pop( - 'polling_interval', - self._config.polling_interval - ) - cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2019-10-01")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[None] + polling = kwargs.pop("polling", True) # type: Union[bool, AsyncPollingMethod] + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token = kwargs.pop("continuation_token", None) # type: Optional[str] if cont_token is None: - raw_result = await self._delete_at_scope_initial( + raw_result = await self._delete_at_scope_initial( # type: ignore scope=scope, deployment_name=deployment_name, api_version=api_version, - cls=lambda x,y,z: x, + cls=lambda x, y, z: x, + headers=_headers, + params=_params, **kwargs ) - kwargs.pop('error_map', None) + kwargs.pop("error_map", None) - def get_long_running_output(pipeline_response): + def get_long_running_output(pipeline_response): # pylint: disable=inconsistent-return-statements if cls: return cls(pipeline_response, None, {}) - - if polling is True: polling_method = AsyncARMPolling(lro_delay, **kwargs) - elif polling is False: polling_method = AsyncNoPolling() - else: polling_method = polling + if polling is True: + polling_method = cast(AsyncPollingMethod, AsyncARMPolling(lro_delay, **kwargs)) # type: AsyncPollingMethod + elif polling is False: + polling_method = cast(AsyncPollingMethod, AsyncNoPolling()) + else: + polling_method = polling if cont_token: return AsyncLROPoller.from_continuation_token( polling_method=polling_method, continuation_token=cont_token, client=self._client, - deserialization_callback=get_long_running_output + deserialization_callback=get_long_running_output, ) return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) - begin_delete_at_scope.metadata = {'url': "/{scope}/providers/Microsoft.Resources/deployments/{deploymentName}"} # type: ignore + begin_delete_at_scope.metadata = {"url": "/{scope}/providers/Microsoft.Resources/deployments/{deploymentName}"} # type: ignore @distributed_trace_async - async def check_existence_at_scope( - self, - scope: str, - deployment_name: str, - **kwargs: Any - ) -> bool: + async def check_existence_at_scope(self, scope: str, deployment_name: str, **kwargs: Any) -> bool: """Checks whether the deployment exists. - :param scope: The resource scope. + :param scope: The resource scope. Required. :type scope: str - :param deployment_name: The name of the deployment. + :param deployment_name: The name of the deployment. Required. :type deployment_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: bool, or the result of cls(response) + :return: bool or the result of cls(response) :rtype: bool - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType[None] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + 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', "2019-10-01") # type: str + api_version = kwargs.pop("api_version", _params.pop("api-version", "2019-10-01")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[None] - request = build_deployments_check_existence_at_scope_request( scope=scope, deployment_name=deployment_name, api_version=api_version, - template_url=self.check_existence_at_scope.metadata['url'], + template_url=self.check_existence_at_scope.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [204, 404]: @@ -299,43 +410,52 @@ async def check_existence_at_scope( return cls(pipeline_response, None, {}) return 200 <= response.status_code <= 299 - check_existence_at_scope.metadata = {'url': "/{scope}/providers/Microsoft.Resources/deployments/{deploymentName}"} # type: ignore - + check_existence_at_scope.metadata = {"url": "/{scope}/providers/Microsoft.Resources/deployments/{deploymentName}"} # type: ignore async def _create_or_update_at_scope_initial( - self, - scope: str, - deployment_name: str, - parameters: "_models.Deployment", - **kwargs: Any - ) -> "_models.DeploymentExtended": - cls = kwargs.pop('cls', None) # type: ClsType["_models.DeploymentExtended"] + self, scope: str, deployment_name: str, parameters: Union[_models.Deployment, IO], **kwargs: Any + ) -> _models.DeploymentExtended: error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) - api_version = kwargs.pop('api_version', "2019-10-01") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - _json = self._serialize.body(parameters, 'Deployment') + api_version = kwargs.pop("api_version", _params.pop("api-version", "2019-10-01")) # type: str + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.DeploymentExtended] - request = build_deployments_create_or_update_at_scope_request_initial( + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(parameters, (IO, bytes)): + _content = parameters + else: + _json = self._serialize.body(parameters, "Deployment") + + request = build_deployments_create_or_update_at_scope_request( scope=scope, deployment_name=deployment_name, api_version=api_version, content_type=content_type, json=_json, - template_url=self._create_or_update_at_scope_initial.metadata['url'], + content=_content, + template_url=self._create_or_update_at_scope_initial.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200, 201]: @@ -343,37 +463,41 @@ async def _create_or_update_at_scope_initial( raise HttpResponseError(response=response, error_format=ARMErrorFormat) if response.status_code == 200: - deserialized = self._deserialize('DeploymentExtended', pipeline_response) + deserialized = self._deserialize("DeploymentExtended", pipeline_response) if response.status_code == 201: - deserialized = self._deserialize('DeploymentExtended', pipeline_response) + deserialized = self._deserialize("DeploymentExtended", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - _create_or_update_at_scope_initial.metadata = {'url': "/{scope}/providers/Microsoft.Resources/deployments/{deploymentName}"} # type: ignore + _create_or_update_at_scope_initial.metadata = {"url": "/{scope}/providers/Microsoft.Resources/deployments/{deploymentName}"} # type: ignore - - @distributed_trace_async + @overload async def begin_create_or_update_at_scope( self, scope: str, deployment_name: str, - parameters: "_models.Deployment", + parameters: _models.Deployment, + *, + content_type: str = "application/json", **kwargs: Any - ) -> AsyncLROPoller["_models.DeploymentExtended"]: + ) -> AsyncLROPoller[_models.DeploymentExtended]: """Deploys resources at a given scope. You can provide the template and parameters directly in the request or link to JSON files. - :param scope: The resource scope. + :param scope: The resource scope. Required. :type scope: str - :param deployment_name: The name of the deployment. + :param deployment_name: The name of the deployment. Required. :type deployment_name: str - :param parameters: Additional parameters supplied to the operation. + :param parameters: Additional parameters supplied to the operation. Required. :type parameters: ~azure.mgmt.resource.resources.v2019_10_01.models.Deployment + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str :keyword callable cls: A custom type or function that will be passed the direct response :keyword str continuation_token: A continuation token to restart a poller from a saved state. :keyword polling: By default, your polling method will be AsyncARMPolling. Pass in False for @@ -386,114 +510,179 @@ async def begin_create_or_update_at_scope( cls(response) :rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.resource.resources.v2019_10_01.models.DeploymentExtended] - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - api_version = kwargs.pop('api_version', "2019-10-01") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] - polling = kwargs.pop('polling', True) # type: Union[bool, AsyncPollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType["_models.DeploymentExtended"] - lro_delay = kwargs.pop( - 'polling_interval', - self._config.polling_interval - ) - cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] + + @overload + async def begin_create_or_update_at_scope( + self, scope: str, deployment_name: str, parameters: IO, *, content_type: str = "application/json", **kwargs: Any + ) -> AsyncLROPoller[_models.DeploymentExtended]: + """Deploys resources at a given scope. + + You can provide the template and parameters directly in the request or link to JSON files. + + :param scope: The resource scope. Required. + :type scope: str + :param deployment_name: The name of the deployment. Required. + :type deployment_name: str + :param parameters: Additional parameters supplied to the operation. Required. + :type parameters: IO + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be AsyncARMPolling. Pass in False for + this operation to not poll, or pass in your own initialized polling object for a personal + polling strategy. + :paramtype polling: bool or ~azure.core.polling.AsyncPollingMethod + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of AsyncLROPoller that returns either DeploymentExtended or the result of + cls(response) + :rtype: + ~azure.core.polling.AsyncLROPoller[~azure.mgmt.resource.resources.v2019_10_01.models.DeploymentExtended] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace_async + async def begin_create_or_update_at_scope( + self, scope: str, deployment_name: str, parameters: Union[_models.Deployment, IO], **kwargs: Any + ) -> AsyncLROPoller[_models.DeploymentExtended]: + """Deploys resources at a given scope. + + You can provide the template and parameters directly in the request or link to JSON files. + + :param scope: The resource scope. Required. + :type scope: str + :param deployment_name: The name of the deployment. Required. + :type deployment_name: str + :param parameters: Additional parameters supplied to the operation. Is either a model type or a + IO type. Required. + :type parameters: ~azure.mgmt.resource.resources.v2019_10_01.models.Deployment or IO + :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. + Default value is None. + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be AsyncARMPolling. Pass in False for + this operation to not poll, or pass in your own initialized polling object for a personal + polling strategy. + :paramtype polling: bool or ~azure.core.polling.AsyncPollingMethod + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of AsyncLROPoller that returns either DeploymentExtended or the result of + cls(response) + :rtype: + ~azure.core.polling.AsyncLROPoller[~azure.mgmt.resource.resources.v2019_10_01.models.DeploymentExtended] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _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", "2019-10-01")) # type: str + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.DeploymentExtended] + polling = kwargs.pop("polling", True) # type: Union[bool, AsyncPollingMethod] + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token = kwargs.pop("continuation_token", None) # type: Optional[str] if cont_token is None: - raw_result = await self._create_or_update_at_scope_initial( + raw_result = await self._create_or_update_at_scope_initial( # type: ignore scope=scope, deployment_name=deployment_name, parameters=parameters, api_version=api_version, content_type=content_type, - cls=lambda x,y,z: x, + cls=lambda x, y, z: x, + headers=_headers, + params=_params, **kwargs ) - kwargs.pop('error_map', None) + kwargs.pop("error_map", None) def get_long_running_output(pipeline_response): - response = pipeline_response.http_response - deserialized = self._deserialize('DeploymentExtended', pipeline_response) + deserialized = self._deserialize("DeploymentExtended", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - - if polling is True: polling_method = AsyncARMPolling(lro_delay, **kwargs) - elif polling is False: polling_method = AsyncNoPolling() - else: polling_method = polling + if polling is True: + polling_method = cast(AsyncPollingMethod, AsyncARMPolling(lro_delay, **kwargs)) # type: AsyncPollingMethod + elif polling is False: + polling_method = cast(AsyncPollingMethod, AsyncNoPolling()) + else: + polling_method = polling if cont_token: return AsyncLROPoller.from_continuation_token( polling_method=polling_method, continuation_token=cont_token, client=self._client, - deserialization_callback=get_long_running_output + deserialization_callback=get_long_running_output, ) return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) - begin_create_or_update_at_scope.metadata = {'url': "/{scope}/providers/Microsoft.Resources/deployments/{deploymentName}"} # type: ignore + begin_create_or_update_at_scope.metadata = {"url": "/{scope}/providers/Microsoft.Resources/deployments/{deploymentName}"} # type: ignore @distributed_trace_async - async def get_at_scope( - self, - scope: str, - deployment_name: str, - **kwargs: Any - ) -> "_models.DeploymentExtended": + async def get_at_scope(self, scope: str, deployment_name: str, **kwargs: Any) -> _models.DeploymentExtended: """Gets a deployment. - :param scope: The resource scope. + :param scope: The resource scope. Required. :type scope: str - :param deployment_name: The name of the deployment. + :param deployment_name: The name of the deployment. Required. :type deployment_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: DeploymentExtended, or the result of cls(response) + :return: DeploymentExtended or the result of cls(response) :rtype: ~azure.mgmt.resource.resources.v2019_10_01.models.DeploymentExtended - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.DeploymentExtended"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) - api_version = kwargs.pop('api_version', "2019-10-01") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2019-10-01")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[_models.DeploymentExtended] - request = build_deployments_get_at_scope_request( scope=scope, deployment_name=deployment_name, api_version=api_version, - template_url=self.get_at_scope.metadata['url'], + template_url=self.get_at_scope.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) - deserialized = self._deserialize('DeploymentExtended', pipeline_response) + deserialized = self._deserialize("DeploymentExtended", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - get_at_scope.metadata = {'url': "/{scope}/providers/Microsoft.Resources/deployments/{deploymentName}"} # type: ignore - + get_at_scope.metadata = {"url": "/{scope}/providers/Microsoft.Resources/deployments/{deploymentName}"} # type: ignore @distributed_trace_async async def cancel_at_scope( # pylint: disable=inconsistent-return-statements - self, - scope: str, - deployment_name: str, - **kwargs: Any + self, scope: str, deployment_name: str, **kwargs: Any ) -> None: """Cancels a currently running template deployment. @@ -502,38 +691,44 @@ async def cancel_at_scope( # pylint: disable=inconsistent-return-statements deployment stops the currently running template deployment and leaves the resources partially deployed. - :param scope: The resource scope. + :param scope: The resource scope. Required. :type scope: str - :param deployment_name: The name of the deployment. + :param deployment_name: The name of the deployment. Required. :type deployment_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: None, or the result of cls(response) + :return: None or the result of cls(response) :rtype: None - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType[None] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + 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', "2019-10-01") # type: str + api_version = kwargs.pop("api_version", _params.pop("api-version", "2019-10-01")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[None] - request = build_deployments_cancel_at_scope_request( scope=scope, deployment_name=deployment_name, api_version=api_version, - template_url=self.cancel_at_scope.metadata['url'], + template_url=self.cancel_at_scope.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [204]: @@ -543,43 +738,52 @@ async def cancel_at_scope( # pylint: disable=inconsistent-return-statements if cls: return cls(pipeline_response, None, {}) - cancel_at_scope.metadata = {'url': "/{scope}/providers/Microsoft.Resources/deployments/{deploymentName}/cancel"} # type: ignore - + cancel_at_scope.metadata = {"url": "/{scope}/providers/Microsoft.Resources/deployments/{deploymentName}/cancel"} # type: ignore async def _validate_at_scope_initial( - self, - scope: str, - deployment_name: str, - parameters: "_models.Deployment", - **kwargs: Any - ) -> Optional["_models.DeploymentValidateResult"]: - cls = kwargs.pop('cls', None) # type: ClsType[Optional["_models.DeploymentValidateResult"]] + self, scope: str, deployment_name: str, parameters: Union[_models.Deployment, IO], **kwargs: Any + ) -> Optional[_models.DeploymentValidateResult]: error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) - api_version = kwargs.pop('api_version', "2019-10-01") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - _json = self._serialize.body(parameters, 'Deployment') + api_version = kwargs.pop("api_version", _params.pop("api-version", "2019-10-01")) # type: str + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[Optional[_models.DeploymentValidateResult]] - request = build_deployments_validate_at_scope_request_initial( + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(parameters, (IO, bytes)): + _content = parameters + else: + _json = self._serialize.body(parameters, "Deployment") + + request = build_deployments_validate_at_scope_request( scope=scope, deployment_name=deployment_name, api_version=api_version, content_type=content_type, json=_json, - template_url=self._validate_at_scope_initial.metadata['url'], + content=_content, + template_url=self._validate_at_scope_initial.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200, 202, 400]: @@ -588,36 +792,40 @@ async def _validate_at_scope_initial( deserialized = None if response.status_code == 200: - deserialized = self._deserialize('DeploymentValidateResult', pipeline_response) + deserialized = self._deserialize("DeploymentValidateResult", pipeline_response) if response.status_code == 400: - deserialized = self._deserialize('DeploymentValidateResult', pipeline_response) + deserialized = self._deserialize("DeploymentValidateResult", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - _validate_at_scope_initial.metadata = {'url': "/{scope}/providers/Microsoft.Resources/deployments/{deploymentName}/validate"} # type: ignore + _validate_at_scope_initial.metadata = {"url": "/{scope}/providers/Microsoft.Resources/deployments/{deploymentName}/validate"} # type: ignore - - @distributed_trace_async + @overload async def begin_validate_at_scope( self, scope: str, deployment_name: str, - parameters: "_models.Deployment", + parameters: _models.Deployment, + *, + content_type: str = "application/json", **kwargs: Any - ) -> AsyncLROPoller["_models.DeploymentValidateResult"]: + ) -> AsyncLROPoller[_models.DeploymentValidateResult]: """Validates whether the specified template is syntactically correct and will be accepted by Azure Resource Manager.. - :param scope: The resource scope. + :param scope: The resource scope. Required. :type scope: str - :param deployment_name: The name of the deployment. + :param deployment_name: The name of the deployment. Required. :type deployment_name: str - :param parameters: Parameters to validate. + :param parameters: Parameters to validate. Required. :type parameters: ~azure.mgmt.resource.resources.v2019_10_01.models.Deployment + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str :keyword callable cls: A custom type or function that will be passed the direct response :keyword str continuation_token: A continuation token to restart a poller from a saved state. :keyword polling: By default, your polling method will be AsyncARMPolling. Pass in False for @@ -630,119 +838,182 @@ async def begin_validate_at_scope( result of cls(response) :rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.resource.resources.v2019_10_01.models.DeploymentValidateResult] - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - api_version = kwargs.pop('api_version', "2019-10-01") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] - polling = kwargs.pop('polling', True) # type: Union[bool, AsyncPollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType["_models.DeploymentValidateResult"] - lro_delay = kwargs.pop( - 'polling_interval', - self._config.polling_interval - ) - cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] + + @overload + async def begin_validate_at_scope( + self, scope: str, deployment_name: str, parameters: IO, *, content_type: str = "application/json", **kwargs: Any + ) -> AsyncLROPoller[_models.DeploymentValidateResult]: + """Validates whether the specified template is syntactically correct and will be accepted by Azure + Resource Manager.. + + :param scope: The resource scope. Required. + :type scope: str + :param deployment_name: The name of the deployment. Required. + :type deployment_name: str + :param parameters: Parameters to validate. Required. + :type parameters: IO + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be AsyncARMPolling. Pass in False for + this operation to not poll, or pass in your own initialized polling object for a personal + polling strategy. + :paramtype polling: bool or ~azure.core.polling.AsyncPollingMethod + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of AsyncLROPoller that returns either DeploymentValidateResult or the + result of cls(response) + :rtype: + ~azure.core.polling.AsyncLROPoller[~azure.mgmt.resource.resources.v2019_10_01.models.DeploymentValidateResult] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace_async + async def begin_validate_at_scope( + self, scope: str, deployment_name: str, parameters: Union[_models.Deployment, IO], **kwargs: Any + ) -> AsyncLROPoller[_models.DeploymentValidateResult]: + """Validates whether the specified template is syntactically correct and will be accepted by Azure + Resource Manager.. + + :param scope: The resource scope. Required. + :type scope: str + :param deployment_name: The name of the deployment. Required. + :type deployment_name: str + :param parameters: Parameters to validate. Is either a model type or a IO type. Required. + :type parameters: ~azure.mgmt.resource.resources.v2019_10_01.models.Deployment or IO + :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. + Default value is None. + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be AsyncARMPolling. Pass in False for + this operation to not poll, or pass in your own initialized polling object for a personal + polling strategy. + :paramtype polling: bool or ~azure.core.polling.AsyncPollingMethod + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of AsyncLROPoller that returns either DeploymentValidateResult or the + result of cls(response) + :rtype: + ~azure.core.polling.AsyncLROPoller[~azure.mgmt.resource.resources.v2019_10_01.models.DeploymentValidateResult] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _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", "2019-10-01")) # type: str + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.DeploymentValidateResult] + polling = kwargs.pop("polling", True) # type: Union[bool, AsyncPollingMethod] + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token = kwargs.pop("continuation_token", None) # type: Optional[str] if cont_token is None: - raw_result = await self._validate_at_scope_initial( + raw_result = await self._validate_at_scope_initial( # type: ignore scope=scope, deployment_name=deployment_name, parameters=parameters, api_version=api_version, content_type=content_type, - cls=lambda x,y,z: x, + cls=lambda x, y, z: x, + headers=_headers, + params=_params, **kwargs ) - kwargs.pop('error_map', None) + kwargs.pop("error_map", None) def get_long_running_output(pipeline_response): - response = pipeline_response.http_response - deserialized = self._deserialize('DeploymentValidateResult', pipeline_response) + deserialized = self._deserialize("DeploymentValidateResult", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - - if polling is True: polling_method = AsyncARMPolling(lro_delay, **kwargs) - elif polling is False: polling_method = AsyncNoPolling() - else: polling_method = polling + if polling is True: + polling_method = cast(AsyncPollingMethod, AsyncARMPolling(lro_delay, **kwargs)) # type: AsyncPollingMethod + elif polling is False: + polling_method = cast(AsyncPollingMethod, AsyncNoPolling()) + else: + polling_method = polling if cont_token: return AsyncLROPoller.from_continuation_token( polling_method=polling_method, continuation_token=cont_token, client=self._client, - deserialization_callback=get_long_running_output + deserialization_callback=get_long_running_output, ) return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) - begin_validate_at_scope.metadata = {'url': "/{scope}/providers/Microsoft.Resources/deployments/{deploymentName}/validate"} # type: ignore + begin_validate_at_scope.metadata = {"url": "/{scope}/providers/Microsoft.Resources/deployments/{deploymentName}/validate"} # type: ignore @distributed_trace_async async def export_template_at_scope( - self, - scope: str, - deployment_name: str, - **kwargs: Any - ) -> "_models.DeploymentExportResult": + self, scope: str, deployment_name: str, **kwargs: Any + ) -> _models.DeploymentExportResult: """Exports the template used for specified deployment. - :param scope: The resource scope. + :param scope: The resource scope. Required. :type scope: str - :param deployment_name: The name of the deployment. + :param deployment_name: The name of the deployment. Required. :type deployment_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: DeploymentExportResult, or the result of cls(response) + :return: DeploymentExportResult or the result of cls(response) :rtype: ~azure.mgmt.resource.resources.v2019_10_01.models.DeploymentExportResult - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.DeploymentExportResult"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + 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', "2019-10-01") # type: str + api_version = kwargs.pop("api_version", _params.pop("api-version", "2019-10-01")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[_models.DeploymentExportResult] - request = build_deployments_export_template_at_scope_request( scope=scope, deployment_name=deployment_name, api_version=api_version, - template_url=self.export_template_at_scope.metadata['url'], + template_url=self.export_template_at_scope.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) - deserialized = self._deserialize('DeploymentExportResult', pipeline_response) + deserialized = self._deserialize("DeploymentExportResult", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - export_template_at_scope.metadata = {'url': "/{scope}/providers/Microsoft.Resources/deployments/{deploymentName}/exportTemplate"} # type: ignore - + export_template_at_scope.metadata = {"url": "/{scope}/providers/Microsoft.Resources/deployments/{deploymentName}/exportTemplate"} # type: ignore @distributed_trace def list_at_scope( - self, - scope: str, - filter: Optional[str] = None, - top: Optional[int] = None, - **kwargs: Any - ) -> AsyncIterable["_models.DeploymentListResult"]: + self, scope: str, filter: Optional[str] = None, top: Optional[int] = None, **kwargs: Any + ) -> AsyncIterable["_models.DeploymentExtended"]: """Get all the deployments at the given scope. - :param scope: The resource scope. + :param scope: The resource scope. Required. :type scope: str :param filter: The filter to apply on the operation. For example, you can use $filter=provisioningState eq '{state}'. Default value is None. @@ -751,40 +1022,48 @@ def list_at_scope( value is None. :type top: int :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either DeploymentListResult or the result of - cls(response) + :return: An iterator like instance of either DeploymentExtended or the result of cls(response) :rtype: - ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.resource.resources.v2019_10_01.models.DeploymentListResult] - :raises: ~azure.core.exceptions.HttpResponseError + ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.resource.resources.v2019_10_01.models.DeploymentExtended] + :raises ~azure.core.exceptions.HttpResponseError: """ - api_version = kwargs.pop('api_version', "2019-10-01") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2019-10-01")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[_models.DeploymentListResult] - cls = kwargs.pop('cls', None) # type: ClsType["_models.DeploymentListResult"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) + def prepare_request(next_link=None): if not next_link: - + request = build_deployments_list_at_scope_request( scope=scope, - api_version=api_version, filter=filter, top=top, - template_url=self.list_at_scope.metadata['url'], + api_version=api_version, + template_url=self.list_at_scope.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore else: - - request = build_deployments_list_at_scope_request( - scope=scope, - template_url=next_link, - ) + # make call to next link with the client's api-version + _parsed_next_link = urlparse(next_link) + _next_request_params = case_insensitive_dict(parse_qs(_parsed_next_link.query)) + _next_request_params["api-version"] = self._config.api_version + request = HttpRequest("GET", urljoin(next_link, _parsed_next_link.path), params=_next_request_params) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore request.method = "GET" return request @@ -798,10 +1077,8 @@ async def extract_data(pipeline_response): async def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) response = pipeline_response.http_response @@ -811,39 +1088,41 @@ async def get_next(next_link=None): return pipeline_response + return AsyncItemPaged(get_next, extract_data) - return AsyncItemPaged( - get_next, extract_data - ) - list_at_scope.metadata = {'url': "/{scope}/providers/Microsoft.Resources/deployments/"} # type: ignore + list_at_scope.metadata = {"url": "/{scope}/providers/Microsoft.Resources/deployments/"} # type: ignore async def _delete_at_tenant_scope_initial( # pylint: disable=inconsistent-return-statements - self, - deployment_name: str, - **kwargs: Any + self, deployment_name: str, **kwargs: Any ) -> None: - cls = kwargs.pop('cls', None) # type: ClsType[None] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + 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', "2019-10-01") # type: str + api_version = kwargs.pop("api_version", _params.pop("api-version", "2019-10-01")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[None] - - request = build_deployments_delete_at_tenant_scope_request_initial( + request = build_deployments_delete_at_tenant_scope_request( deployment_name=deployment_name, api_version=api_version, - template_url=self._delete_at_tenant_scope_initial.metadata['url'], + template_url=self._delete_at_tenant_scope_initial.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [202, 204]: @@ -853,15 +1132,10 @@ async def _delete_at_tenant_scope_initial( # pylint: disable=inconsistent-retur if cls: return cls(pipeline_response, None, {}) - _delete_at_tenant_scope_initial.metadata = {'url': "/providers/Microsoft.Resources/deployments/{deploymentName}"} # type: ignore - + _delete_at_tenant_scope_initial.metadata = {"url": "/providers/Microsoft.Resources/deployments/{deploymentName}"} # type: ignore @distributed_trace_async - async def begin_delete_at_tenant_scope( # pylint: disable=inconsistent-return-statements - self, - deployment_name: str, - **kwargs: Any - ) -> AsyncLROPoller[None]: + async def begin_delete_at_tenant_scope(self, deployment_name: str, **kwargs: Any) -> AsyncLROPoller[None]: """Deletes a deployment from the deployment history. A template deployment that is currently running cannot be deleted. Deleting a template @@ -872,7 +1146,7 @@ async def begin_delete_at_tenant_scope( # pylint: disable=inconsistent-return-s process finishes, the URI in the Location header returns a status of 204 on success. If the asynchronous request failed, the URI in the Location header returns an error-level status code. - :param deployment_name: The name of the deployment. + :param deployment_name: The name of the deployment. Required. :type deployment_name: str :keyword callable cls: A custom type or function that will be passed the direct response :keyword str continuation_token: A continuation token to restart a poller from a saved state. @@ -884,81 +1158,87 @@ async def begin_delete_at_tenant_scope( # pylint: disable=inconsistent-return-s Retry-After header is present. :return: An instance of AsyncLROPoller that returns either None or the result of cls(response) :rtype: ~azure.core.polling.AsyncLROPoller[None] - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - api_version = kwargs.pop('api_version', "2019-10-01") # type: str - polling = kwargs.pop('polling', True) # type: Union[bool, AsyncPollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType[None] - lro_delay = kwargs.pop( - 'polling_interval', - self._config.polling_interval - ) - cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2019-10-01")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[None] + polling = kwargs.pop("polling", True) # type: Union[bool, AsyncPollingMethod] + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token = kwargs.pop("continuation_token", None) # type: Optional[str] if cont_token is None: - raw_result = await self._delete_at_tenant_scope_initial( + raw_result = await self._delete_at_tenant_scope_initial( # type: ignore deployment_name=deployment_name, api_version=api_version, - cls=lambda x,y,z: x, + cls=lambda x, y, z: x, + headers=_headers, + params=_params, **kwargs ) - kwargs.pop('error_map', None) + kwargs.pop("error_map", None) - def get_long_running_output(pipeline_response): + def get_long_running_output(pipeline_response): # pylint: disable=inconsistent-return-statements if cls: return cls(pipeline_response, None, {}) - - if polling is True: polling_method = AsyncARMPolling(lro_delay, **kwargs) - elif polling is False: polling_method = AsyncNoPolling() - else: polling_method = polling + if polling is True: + polling_method = cast(AsyncPollingMethod, AsyncARMPolling(lro_delay, **kwargs)) # type: AsyncPollingMethod + elif polling is False: + polling_method = cast(AsyncPollingMethod, AsyncNoPolling()) + else: + polling_method = polling if cont_token: return AsyncLROPoller.from_continuation_token( polling_method=polling_method, continuation_token=cont_token, client=self._client, - deserialization_callback=get_long_running_output + deserialization_callback=get_long_running_output, ) return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) - begin_delete_at_tenant_scope.metadata = {'url': "/providers/Microsoft.Resources/deployments/{deploymentName}"} # type: ignore + begin_delete_at_tenant_scope.metadata = {"url": "/providers/Microsoft.Resources/deployments/{deploymentName}"} # type: ignore @distributed_trace_async - async def check_existence_at_tenant_scope( - self, - deployment_name: str, - **kwargs: Any - ) -> bool: + async def check_existence_at_tenant_scope(self, deployment_name: str, **kwargs: Any) -> bool: """Checks whether the deployment exists. - :param deployment_name: The name of the deployment. + :param deployment_name: The name of the deployment. Required. :type deployment_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: bool, or the result of cls(response) + :return: bool or the result of cls(response) :rtype: bool - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType[None] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + 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', "2019-10-01") # type: str + api_version = kwargs.pop("api_version", _params.pop("api-version", "2019-10-01")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[None] - request = build_deployments_check_existence_at_tenant_scope_request( deployment_name=deployment_name, api_version=api_version, - template_url=self.check_existence_at_tenant_scope.metadata['url'], + template_url=self.check_existence_at_tenant_scope.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [204, 404]: @@ -969,41 +1249,51 @@ async def check_existence_at_tenant_scope( return cls(pipeline_response, None, {}) return 200 <= response.status_code <= 299 - check_existence_at_tenant_scope.metadata = {'url': "/providers/Microsoft.Resources/deployments/{deploymentName}"} # type: ignore - + check_existence_at_tenant_scope.metadata = {"url": "/providers/Microsoft.Resources/deployments/{deploymentName}"} # type: ignore async def _create_or_update_at_tenant_scope_initial( - self, - deployment_name: str, - parameters: "_models.ScopedDeployment", - **kwargs: Any - ) -> "_models.DeploymentExtended": - cls = kwargs.pop('cls', None) # type: ClsType["_models.DeploymentExtended"] + self, deployment_name: str, parameters: Union[_models.ScopedDeployment, IO], **kwargs: Any + ) -> _models.DeploymentExtended: error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', "2019-10-01") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + api_version = kwargs.pop("api_version", _params.pop("api-version", "2019-10-01")) # type: str + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.DeploymentExtended] - _json = self._serialize.body(parameters, 'ScopedDeployment') + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(parameters, (IO, bytes)): + _content = parameters + else: + _json = self._serialize.body(parameters, "ScopedDeployment") - request = build_deployments_create_or_update_at_tenant_scope_request_initial( + request = build_deployments_create_or_update_at_tenant_scope_request( deployment_name=deployment_name, api_version=api_version, content_type=content_type, json=_json, - template_url=self._create_or_update_at_tenant_scope_initial.metadata['url'], + content=_content, + template_url=self._create_or_update_at_tenant_scope_initial.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200, 201]: @@ -1011,34 +1301,38 @@ async def _create_or_update_at_tenant_scope_initial( raise HttpResponseError(response=response, error_format=ARMErrorFormat) if response.status_code == 200: - deserialized = self._deserialize('DeploymentExtended', pipeline_response) + deserialized = self._deserialize("DeploymentExtended", pipeline_response) if response.status_code == 201: - deserialized = self._deserialize('DeploymentExtended', pipeline_response) + deserialized = self._deserialize("DeploymentExtended", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - _create_or_update_at_tenant_scope_initial.metadata = {'url': "/providers/Microsoft.Resources/deployments/{deploymentName}"} # type: ignore - + _create_or_update_at_tenant_scope_initial.metadata = {"url": "/providers/Microsoft.Resources/deployments/{deploymentName}"} # type: ignore - @distributed_trace_async + @overload async def begin_create_or_update_at_tenant_scope( self, deployment_name: str, - parameters: "_models.ScopedDeployment", + parameters: _models.ScopedDeployment, + *, + content_type: str = "application/json", **kwargs: Any - ) -> AsyncLROPoller["_models.DeploymentExtended"]: + ) -> AsyncLROPoller[_models.DeploymentExtended]: """Deploys resources at tenant scope. You can provide the template and parameters directly in the request or link to JSON files. - :param deployment_name: The name of the deployment. + :param deployment_name: The name of the deployment. Required. :type deployment_name: str - :param parameters: Additional parameters supplied to the operation. + :param parameters: Additional parameters supplied to the operation. Required. :type parameters: ~azure.mgmt.resource.resources.v2019_10_01.models.ScopedDeployment + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str :keyword callable cls: A custom type or function that will be passed the direct response :keyword str continuation_token: A continuation token to restart a poller from a saved state. :keyword polling: By default, your polling method will be AsyncARMPolling. Pass in False for @@ -1051,108 +1345,171 @@ async def begin_create_or_update_at_tenant_scope( cls(response) :rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.resource.resources.v2019_10_01.models.DeploymentExtended] - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - api_version = kwargs.pop('api_version', "2019-10-01") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] - polling = kwargs.pop('polling', True) # type: Union[bool, AsyncPollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType["_models.DeploymentExtended"] - lro_delay = kwargs.pop( - 'polling_interval', - self._config.polling_interval - ) - cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] + + @overload + async def begin_create_or_update_at_tenant_scope( + self, deployment_name: str, parameters: IO, *, content_type: str = "application/json", **kwargs: Any + ) -> AsyncLROPoller[_models.DeploymentExtended]: + """Deploys resources at tenant scope. + + You can provide the template and parameters directly in the request or link to JSON files. + + :param deployment_name: The name of the deployment. Required. + :type deployment_name: str + :param parameters: Additional parameters supplied to the operation. Required. + :type parameters: IO + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be AsyncARMPolling. Pass in False for + this operation to not poll, or pass in your own initialized polling object for a personal + polling strategy. + :paramtype polling: bool or ~azure.core.polling.AsyncPollingMethod + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of AsyncLROPoller that returns either DeploymentExtended or the result of + cls(response) + :rtype: + ~azure.core.polling.AsyncLROPoller[~azure.mgmt.resource.resources.v2019_10_01.models.DeploymentExtended] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace_async + async def begin_create_or_update_at_tenant_scope( + self, deployment_name: str, parameters: Union[_models.ScopedDeployment, IO], **kwargs: Any + ) -> AsyncLROPoller[_models.DeploymentExtended]: + """Deploys resources at tenant scope. + + You can provide the template and parameters directly in the request or link to JSON files. + + :param deployment_name: The name of the deployment. Required. + :type deployment_name: str + :param parameters: Additional parameters supplied to the operation. Is either a model type or a + IO type. Required. + :type parameters: ~azure.mgmt.resource.resources.v2019_10_01.models.ScopedDeployment or IO + :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. + Default value is None. + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be AsyncARMPolling. Pass in False for + this operation to not poll, or pass in your own initialized polling object for a personal + polling strategy. + :paramtype polling: bool or ~azure.core.polling.AsyncPollingMethod + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of AsyncLROPoller that returns either DeploymentExtended or the result of + cls(response) + :rtype: + ~azure.core.polling.AsyncLROPoller[~azure.mgmt.resource.resources.v2019_10_01.models.DeploymentExtended] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _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", "2019-10-01")) # type: str + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.DeploymentExtended] + polling = kwargs.pop("polling", True) # type: Union[bool, AsyncPollingMethod] + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token = kwargs.pop("continuation_token", None) # type: Optional[str] if cont_token is None: - raw_result = await self._create_or_update_at_tenant_scope_initial( + raw_result = await self._create_or_update_at_tenant_scope_initial( # type: ignore deployment_name=deployment_name, parameters=parameters, api_version=api_version, content_type=content_type, - cls=lambda x,y,z: x, + cls=lambda x, y, z: x, + headers=_headers, + params=_params, **kwargs ) - kwargs.pop('error_map', None) + kwargs.pop("error_map", None) def get_long_running_output(pipeline_response): - response = pipeline_response.http_response - deserialized = self._deserialize('DeploymentExtended', pipeline_response) + deserialized = self._deserialize("DeploymentExtended", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - - if polling is True: polling_method = AsyncARMPolling(lro_delay, **kwargs) - elif polling is False: polling_method = AsyncNoPolling() - else: polling_method = polling + if polling is True: + polling_method = cast(AsyncPollingMethod, AsyncARMPolling(lro_delay, **kwargs)) # type: AsyncPollingMethod + elif polling is False: + polling_method = cast(AsyncPollingMethod, AsyncNoPolling()) + else: + polling_method = polling if cont_token: return AsyncLROPoller.from_continuation_token( polling_method=polling_method, continuation_token=cont_token, client=self._client, - deserialization_callback=get_long_running_output + deserialization_callback=get_long_running_output, ) return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) - begin_create_or_update_at_tenant_scope.metadata = {'url': "/providers/Microsoft.Resources/deployments/{deploymentName}"} # type: ignore + begin_create_or_update_at_tenant_scope.metadata = {"url": "/providers/Microsoft.Resources/deployments/{deploymentName}"} # type: ignore @distributed_trace_async - async def get_at_tenant_scope( - self, - deployment_name: str, - **kwargs: Any - ) -> "_models.DeploymentExtended": + async def get_at_tenant_scope(self, deployment_name: str, **kwargs: Any) -> _models.DeploymentExtended: """Gets a deployment. - :param deployment_name: The name of the deployment. + :param deployment_name: The name of the deployment. Required. :type deployment_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: DeploymentExtended, or the result of cls(response) + :return: DeploymentExtended or the result of cls(response) :rtype: ~azure.mgmt.resource.resources.v2019_10_01.models.DeploymentExtended - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.DeploymentExtended"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) - api_version = kwargs.pop('api_version', "2019-10-01") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2019-10-01")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[_models.DeploymentExtended] - request = build_deployments_get_at_tenant_scope_request( deployment_name=deployment_name, api_version=api_version, - template_url=self.get_at_tenant_scope.metadata['url'], + template_url=self.get_at_tenant_scope.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) - deserialized = self._deserialize('DeploymentExtended', pipeline_response) + deserialized = self._deserialize("DeploymentExtended", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - get_at_tenant_scope.metadata = {'url': "/providers/Microsoft.Resources/deployments/{deploymentName}"} # type: ignore - + get_at_tenant_scope.metadata = {"url": "/providers/Microsoft.Resources/deployments/{deploymentName}"} # type: ignore @distributed_trace_async async def cancel_at_tenant_scope( # pylint: disable=inconsistent-return-statements - self, - deployment_name: str, - **kwargs: Any + self, deployment_name: str, **kwargs: Any ) -> None: """Cancels a currently running template deployment. @@ -1161,35 +1518,41 @@ async def cancel_at_tenant_scope( # pylint: disable=inconsistent-return-stateme deployment stops the currently running template deployment and leaves the resources partially deployed. - :param deployment_name: The name of the deployment. + :param deployment_name: The name of the deployment. Required. :type deployment_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: None, or the result of cls(response) + :return: None or the result of cls(response) :rtype: None - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType[None] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) - api_version = kwargs.pop('api_version', "2019-10-01") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2019-10-01")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[None] - request = build_deployments_cancel_at_tenant_scope_request( deployment_name=deployment_name, api_version=api_version, - template_url=self.cancel_at_tenant_scope.metadata['url'], + template_url=self.cancel_at_tenant_scope.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [204]: @@ -1199,41 +1562,51 @@ async def cancel_at_tenant_scope( # pylint: disable=inconsistent-return-stateme if cls: return cls(pipeline_response, None, {}) - cancel_at_tenant_scope.metadata = {'url': "/providers/Microsoft.Resources/deployments/{deploymentName}/cancel"} # type: ignore - + cancel_at_tenant_scope.metadata = {"url": "/providers/Microsoft.Resources/deployments/{deploymentName}/cancel"} # type: ignore async def _validate_at_tenant_scope_initial( - self, - deployment_name: str, - parameters: "_models.ScopedDeployment", - **kwargs: Any - ) -> Optional["_models.DeploymentValidateResult"]: - cls = kwargs.pop('cls', None) # type: ClsType[Optional["_models.DeploymentValidateResult"]] + self, deployment_name: str, parameters: Union[_models.ScopedDeployment, IO], **kwargs: Any + ) -> Optional[_models.DeploymentValidateResult]: error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) - api_version = kwargs.pop('api_version', "2019-10-01") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - _json = self._serialize.body(parameters, 'ScopedDeployment') + api_version = kwargs.pop("api_version", _params.pop("api-version", "2019-10-01")) # type: str + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[Optional[_models.DeploymentValidateResult]] - request = build_deployments_validate_at_tenant_scope_request_initial( + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(parameters, (IO, bytes)): + _content = parameters + else: + _json = self._serialize.body(parameters, "ScopedDeployment") + + request = build_deployments_validate_at_tenant_scope_request( deployment_name=deployment_name, api_version=api_version, content_type=content_type, json=_json, - template_url=self._validate_at_tenant_scope_initial.metadata['url'], + content=_content, + template_url=self._validate_at_tenant_scope_initial.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200, 202, 400]: @@ -1242,33 +1615,37 @@ async def _validate_at_tenant_scope_initial( deserialized = None if response.status_code == 200: - deserialized = self._deserialize('DeploymentValidateResult', pipeline_response) + deserialized = self._deserialize("DeploymentValidateResult", pipeline_response) if response.status_code == 400: - deserialized = self._deserialize('DeploymentValidateResult', pipeline_response) + deserialized = self._deserialize("DeploymentValidateResult", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - _validate_at_tenant_scope_initial.metadata = {'url': "/providers/Microsoft.Resources/deployments/{deploymentName}/validate"} # type: ignore + _validate_at_tenant_scope_initial.metadata = {"url": "/providers/Microsoft.Resources/deployments/{deploymentName}/validate"} # type: ignore - - @distributed_trace_async + @overload async def begin_validate_at_tenant_scope( self, deployment_name: str, - parameters: "_models.ScopedDeployment", + parameters: _models.ScopedDeployment, + *, + content_type: str = "application/json", **kwargs: Any - ) -> AsyncLROPoller["_models.DeploymentValidateResult"]: + ) -> AsyncLROPoller[_models.DeploymentValidateResult]: """Validates whether the specified template is syntactically correct and will be accepted by Azure Resource Manager.. - :param deployment_name: The name of the deployment. + :param deployment_name: The name of the deployment. Required. :type deployment_name: str - :param parameters: Parameters to validate. + :param parameters: Parameters to validate. Required. :type parameters: ~azure.mgmt.resource.resources.v2019_10_01.models.ScopedDeployment + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str :keyword callable cls: A custom type or function that will be passed the direct response :keyword str continuation_token: A continuation token to restart a poller from a saved state. :keyword polling: By default, your polling method will be AsyncARMPolling. Pass in False for @@ -1281,82 +1658,154 @@ async def begin_validate_at_tenant_scope( result of cls(response) :rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.resource.resources.v2019_10_01.models.DeploymentValidateResult] - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - api_version = kwargs.pop('api_version', "2019-10-01") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] - polling = kwargs.pop('polling', True) # type: Union[bool, AsyncPollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType["_models.DeploymentValidateResult"] - lro_delay = kwargs.pop( - 'polling_interval', - self._config.polling_interval - ) - cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] + + @overload + async def begin_validate_at_tenant_scope( + self, deployment_name: str, parameters: IO, *, content_type: str = "application/json", **kwargs: Any + ) -> AsyncLROPoller[_models.DeploymentValidateResult]: + """Validates whether the specified template is syntactically correct and will be accepted by Azure + Resource Manager.. + + :param deployment_name: The name of the deployment. Required. + :type deployment_name: str + :param parameters: Parameters to validate. Required. + :type parameters: IO + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be AsyncARMPolling. Pass in False for + this operation to not poll, or pass in your own initialized polling object for a personal + polling strategy. + :paramtype polling: bool or ~azure.core.polling.AsyncPollingMethod + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of AsyncLROPoller that returns either DeploymentValidateResult or the + result of cls(response) + :rtype: + ~azure.core.polling.AsyncLROPoller[~azure.mgmt.resource.resources.v2019_10_01.models.DeploymentValidateResult] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace_async + async def begin_validate_at_tenant_scope( + self, deployment_name: str, parameters: Union[_models.ScopedDeployment, IO], **kwargs: Any + ) -> AsyncLROPoller[_models.DeploymentValidateResult]: + """Validates whether the specified template is syntactically correct and will be accepted by Azure + Resource Manager.. + + :param deployment_name: The name of the deployment. Required. + :type deployment_name: str + :param parameters: Parameters to validate. Is either a model type or a IO type. Required. + :type parameters: ~azure.mgmt.resource.resources.v2019_10_01.models.ScopedDeployment or IO + :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. + Default value is None. + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be AsyncARMPolling. Pass in False for + this operation to not poll, or pass in your own initialized polling object for a personal + polling strategy. + :paramtype polling: bool or ~azure.core.polling.AsyncPollingMethod + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of AsyncLROPoller that returns either DeploymentValidateResult or the + result of cls(response) + :rtype: + ~azure.core.polling.AsyncLROPoller[~azure.mgmt.resource.resources.v2019_10_01.models.DeploymentValidateResult] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _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", "2019-10-01")) # type: str + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.DeploymentValidateResult] + polling = kwargs.pop("polling", True) # type: Union[bool, AsyncPollingMethod] + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token = kwargs.pop("continuation_token", None) # type: Optional[str] if cont_token is None: - raw_result = await self._validate_at_tenant_scope_initial( + raw_result = await self._validate_at_tenant_scope_initial( # type: ignore deployment_name=deployment_name, parameters=parameters, api_version=api_version, content_type=content_type, - cls=lambda x,y,z: x, + cls=lambda x, y, z: x, + headers=_headers, + params=_params, **kwargs ) - kwargs.pop('error_map', None) + kwargs.pop("error_map", None) def get_long_running_output(pipeline_response): - response = pipeline_response.http_response - deserialized = self._deserialize('DeploymentValidateResult', pipeline_response) + deserialized = self._deserialize("DeploymentValidateResult", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - - if polling is True: polling_method = AsyncARMPolling(lro_delay, **kwargs) - elif polling is False: polling_method = AsyncNoPolling() - else: polling_method = polling + if polling is True: + polling_method = cast(AsyncPollingMethod, AsyncARMPolling(lro_delay, **kwargs)) # type: AsyncPollingMethod + elif polling is False: + polling_method = cast(AsyncPollingMethod, AsyncNoPolling()) + else: + polling_method = polling if cont_token: return AsyncLROPoller.from_continuation_token( polling_method=polling_method, continuation_token=cont_token, client=self._client, - deserialization_callback=get_long_running_output + deserialization_callback=get_long_running_output, ) return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) - begin_validate_at_tenant_scope.metadata = {'url': "/providers/Microsoft.Resources/deployments/{deploymentName}/validate"} # type: ignore + begin_validate_at_tenant_scope.metadata = {"url": "/providers/Microsoft.Resources/deployments/{deploymentName}/validate"} # type: ignore async def _what_if_at_tenant_scope_initial( - self, - deployment_name: str, - parameters: "_models.ScopedDeploymentWhatIf", - **kwargs: Any - ) -> Optional["_models.WhatIfOperationResult"]: - cls = kwargs.pop('cls', None) # type: ClsType[Optional["_models.WhatIfOperationResult"]] + self, deployment_name: str, parameters: Union[_models.ScopedDeploymentWhatIf, IO], **kwargs: Any + ) -> Optional[_models.WhatIfOperationResult]: error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) - api_version = kwargs.pop('api_version', "2019-10-01") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - _json = self._serialize.body(parameters, 'ScopedDeploymentWhatIf') + api_version = kwargs.pop("api_version", _params.pop("api-version", "2019-10-01")) # type: str + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[Optional[_models.WhatIfOperationResult]] - request = build_deployments_what_if_at_tenant_scope_request_initial( + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(parameters, (IO, bytes)): + _content = parameters + else: + _json = self._serialize.body(parameters, "ScopedDeploymentWhatIf") + + request = build_deployments_what_if_at_tenant_scope_request( deployment_name=deployment_name, api_version=api_version, content_type=content_type, json=_json, - template_url=self._what_if_at_tenant_scope_initial.metadata['url'], + content=_content, + template_url=self._what_if_at_tenant_scope_initial.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200, 202]: @@ -1366,35 +1815,38 @@ async def _what_if_at_tenant_scope_initial( deserialized = None response_headers = {} if response.status_code == 200: - deserialized = self._deserialize('WhatIfOperationResult', pipeline_response) + deserialized = self._deserialize("WhatIfOperationResult", pipeline_response) if response.status_code == 202: - response_headers['Location']=self._deserialize('str', response.headers.get('Location')) - response_headers['Retry-After']=self._deserialize('str', response.headers.get('Retry-After')) - + response_headers["Location"] = self._deserialize("str", response.headers.get("Location")) + response_headers["Retry-After"] = self._deserialize("str", response.headers.get("Retry-After")) if cls: return cls(pipeline_response, deserialized, response_headers) return deserialized - _what_if_at_tenant_scope_initial.metadata = {'url': "/providers/Microsoft.Resources/deployments/{deploymentName}/whatIf"} # type: ignore + _what_if_at_tenant_scope_initial.metadata = {"url": "/providers/Microsoft.Resources/deployments/{deploymentName}/whatIf"} # type: ignore - - @distributed_trace_async + @overload async def begin_what_if_at_tenant_scope( self, deployment_name: str, - parameters: "_models.ScopedDeploymentWhatIf", + parameters: _models.ScopedDeploymentWhatIf, + *, + content_type: str = "application/json", **kwargs: Any - ) -> AsyncLROPoller["_models.WhatIfOperationResult"]: + ) -> AsyncLROPoller[_models.WhatIfOperationResult]: """Returns changes that will be made by the deployment if executed at the scope of the tenant group. - :param deployment_name: The name of the deployment. + :param deployment_name: The name of the deployment. Required. :type deployment_name: str - :param parameters: Parameters to validate. + :param parameters: Parameters to validate. Required. :type parameters: ~azure.mgmt.resource.resources.v2019_10_01.models.ScopedDeploymentWhatIf + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str :keyword callable cls: A custom type or function that will be passed the direct response :keyword str continuation_token: A continuation token to restart a poller from a saved state. :keyword polling: By default, your polling method will be AsyncARMPolling. Pass in False for @@ -1407,110 +1859,174 @@ async def begin_what_if_at_tenant_scope( of cls(response) :rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.resource.resources.v2019_10_01.models.WhatIfOperationResult] - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - api_version = kwargs.pop('api_version', "2019-10-01") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] - polling = kwargs.pop('polling', True) # type: Union[bool, AsyncPollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType["_models.WhatIfOperationResult"] - lro_delay = kwargs.pop( - 'polling_interval', - self._config.polling_interval - ) - cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] + + @overload + async def begin_what_if_at_tenant_scope( + self, deployment_name: str, parameters: IO, *, content_type: str = "application/json", **kwargs: Any + ) -> AsyncLROPoller[_models.WhatIfOperationResult]: + """Returns changes that will be made by the deployment if executed at the scope of the tenant + group. + + :param deployment_name: The name of the deployment. Required. + :type deployment_name: str + :param parameters: Parameters to validate. Required. + :type parameters: IO + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be AsyncARMPolling. Pass in False for + this operation to not poll, or pass in your own initialized polling object for a personal + polling strategy. + :paramtype polling: bool or ~azure.core.polling.AsyncPollingMethod + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of AsyncLROPoller that returns either WhatIfOperationResult or the result + of cls(response) + :rtype: + ~azure.core.polling.AsyncLROPoller[~azure.mgmt.resource.resources.v2019_10_01.models.WhatIfOperationResult] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace_async + async def begin_what_if_at_tenant_scope( + self, deployment_name: str, parameters: Union[_models.ScopedDeploymentWhatIf, IO], **kwargs: Any + ) -> AsyncLROPoller[_models.WhatIfOperationResult]: + """Returns changes that will be made by the deployment if executed at the scope of the tenant + group. + + :param deployment_name: The name of the deployment. Required. + :type deployment_name: str + :param parameters: Parameters to validate. Is either a model type or a IO type. Required. + :type parameters: ~azure.mgmt.resource.resources.v2019_10_01.models.ScopedDeploymentWhatIf or + IO + :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. + Default value is None. + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be AsyncARMPolling. Pass in False for + this operation to not poll, or pass in your own initialized polling object for a personal + polling strategy. + :paramtype polling: bool or ~azure.core.polling.AsyncPollingMethod + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of AsyncLROPoller that returns either WhatIfOperationResult or the result + of cls(response) + :rtype: + ~azure.core.polling.AsyncLROPoller[~azure.mgmt.resource.resources.v2019_10_01.models.WhatIfOperationResult] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _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", "2019-10-01")) # type: str + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.WhatIfOperationResult] + polling = kwargs.pop("polling", True) # type: Union[bool, AsyncPollingMethod] + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token = kwargs.pop("continuation_token", None) # type: Optional[str] if cont_token is None: - raw_result = await self._what_if_at_tenant_scope_initial( + raw_result = await self._what_if_at_tenant_scope_initial( # type: ignore deployment_name=deployment_name, parameters=parameters, api_version=api_version, content_type=content_type, - cls=lambda x,y,z: x, + cls=lambda x, y, z: x, + headers=_headers, + params=_params, **kwargs ) - kwargs.pop('error_map', None) + kwargs.pop("error_map", None) def get_long_running_output(pipeline_response): - response = pipeline_response.http_response - deserialized = self._deserialize('WhatIfOperationResult', pipeline_response) + deserialized = self._deserialize("WhatIfOperationResult", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - - if polling is True: polling_method = AsyncARMPolling(lro_delay, lro_options={'final-state-via': 'location'}, **kwargs) - elif polling is False: polling_method = AsyncNoPolling() - else: polling_method = polling + if polling is True: + polling_method = cast( + AsyncPollingMethod, AsyncARMPolling(lro_delay, lro_options={"final-state-via": "location"}, **kwargs) + ) # type: AsyncPollingMethod + elif polling is False: + polling_method = cast(AsyncPollingMethod, AsyncNoPolling()) + else: + polling_method = polling if cont_token: return AsyncLROPoller.from_continuation_token( polling_method=polling_method, continuation_token=cont_token, client=self._client, - deserialization_callback=get_long_running_output + deserialization_callback=get_long_running_output, ) return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) - begin_what_if_at_tenant_scope.metadata = {'url': "/providers/Microsoft.Resources/deployments/{deploymentName}/whatIf"} # type: ignore + begin_what_if_at_tenant_scope.metadata = {"url": "/providers/Microsoft.Resources/deployments/{deploymentName}/whatIf"} # type: ignore @distributed_trace_async async def export_template_at_tenant_scope( - self, - deployment_name: str, - **kwargs: Any - ) -> "_models.DeploymentExportResult": + self, deployment_name: str, **kwargs: Any + ) -> _models.DeploymentExportResult: """Exports the template used for specified deployment. - :param deployment_name: The name of the deployment. + :param deployment_name: The name of the deployment. Required. :type deployment_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: DeploymentExportResult, or the result of cls(response) + :return: DeploymentExportResult or the result of cls(response) :rtype: ~azure.mgmt.resource.resources.v2019_10_01.models.DeploymentExportResult - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.DeploymentExportResult"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) - api_version = kwargs.pop('api_version', "2019-10-01") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2019-10-01")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[_models.DeploymentExportResult] - request = build_deployments_export_template_at_tenant_scope_request( deployment_name=deployment_name, api_version=api_version, - template_url=self.export_template_at_tenant_scope.metadata['url'], + template_url=self.export_template_at_tenant_scope.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) - deserialized = self._deserialize('DeploymentExportResult', pipeline_response) + deserialized = self._deserialize("DeploymentExportResult", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - export_template_at_tenant_scope.metadata = {'url': "/providers/Microsoft.Resources/deployments/{deploymentName}/exportTemplate"} # type: ignore - + export_template_at_tenant_scope.metadata = {"url": "/providers/Microsoft.Resources/deployments/{deploymentName}/exportTemplate"} # type: ignore @distributed_trace def list_at_tenant_scope( - self, - filter: Optional[str] = None, - top: Optional[int] = None, - **kwargs: Any - ) -> AsyncIterable["_models.DeploymentListResult"]: + self, filter: Optional[str] = None, top: Optional[int] = None, **kwargs: Any + ) -> AsyncIterable["_models.DeploymentExtended"]: """Get all the deployments at the tenant scope. :param filter: The filter to apply on the operation. For example, you can use @@ -1520,38 +2036,47 @@ def list_at_tenant_scope( value is None. :type top: int :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either DeploymentListResult or the result of - cls(response) + :return: An iterator like instance of either DeploymentExtended or the result of cls(response) :rtype: - ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.resource.resources.v2019_10_01.models.DeploymentListResult] - :raises: ~azure.core.exceptions.HttpResponseError + ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.resource.resources.v2019_10_01.models.DeploymentExtended] + :raises ~azure.core.exceptions.HttpResponseError: """ - api_version = kwargs.pop('api_version', "2019-10-01") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2019-10-01")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[_models.DeploymentListResult] - cls = kwargs.pop('cls', None) # type: ClsType["_models.DeploymentListResult"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) + def prepare_request(next_link=None): if not next_link: - + request = build_deployments_list_at_tenant_scope_request( - api_version=api_version, filter=filter, top=top, - template_url=self.list_at_tenant_scope.metadata['url'], + api_version=api_version, + template_url=self.list_at_tenant_scope.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore else: - - request = build_deployments_list_at_tenant_scope_request( - template_url=next_link, - ) + # make call to next link with the client's api-version + _parsed_next_link = urlparse(next_link) + _next_request_params = case_insensitive_dict(parse_qs(_parsed_next_link.query)) + _next_request_params["api-version"] = self._config.api_version + request = HttpRequest("GET", urljoin(next_link, _parsed_next_link.path), params=_next_request_params) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore request.method = "GET" return request @@ -1565,10 +2090,8 @@ async def extract_data(pipeline_response): async def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) response = pipeline_response.http_response @@ -1578,41 +2101,42 @@ async def get_next(next_link=None): return pipeline_response + return AsyncItemPaged(get_next, extract_data) - return AsyncItemPaged( - get_next, extract_data - ) - list_at_tenant_scope.metadata = {'url': "/providers/Microsoft.Resources/deployments/"} # type: ignore + list_at_tenant_scope.metadata = {"url": "/providers/Microsoft.Resources/deployments/"} # type: ignore async def _delete_at_management_group_scope_initial( # pylint: disable=inconsistent-return-statements - self, - group_id: str, - deployment_name: str, - **kwargs: Any + self, group_id: str, deployment_name: str, **kwargs: Any ) -> None: - cls = kwargs.pop('cls', None) # type: ClsType[None] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + 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', "2019-10-01") # type: str + api_version = kwargs.pop("api_version", _params.pop("api-version", "2019-10-01")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[None] - - request = build_deployments_delete_at_management_group_scope_request_initial( + request = build_deployments_delete_at_management_group_scope_request( group_id=group_id, deployment_name=deployment_name, api_version=api_version, - template_url=self._delete_at_management_group_scope_initial.metadata['url'], + template_url=self._delete_at_management_group_scope_initial.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [202, 204]: @@ -1622,15 +2146,11 @@ async def _delete_at_management_group_scope_initial( # pylint: disable=inconsis if cls: return cls(pipeline_response, None, {}) - _delete_at_management_group_scope_initial.metadata = {'url': "/providers/Microsoft.Management/managementGroups/{groupId}/providers/Microsoft.Resources/deployments/{deploymentName}"} # type: ignore - + _delete_at_management_group_scope_initial.metadata = {"url": "/providers/Microsoft.Management/managementGroups/{groupId}/providers/Microsoft.Resources/deployments/{deploymentName}"} # type: ignore @distributed_trace_async - async def begin_delete_at_management_group_scope( # pylint: disable=inconsistent-return-statements - self, - group_id: str, - deployment_name: str, - **kwargs: Any + async def begin_delete_at_management_group_scope( + self, group_id: str, deployment_name: str, **kwargs: Any ) -> AsyncLROPoller[None]: """Deletes a deployment from the deployment history. @@ -1642,9 +2162,9 @@ async def begin_delete_at_management_group_scope( # pylint: disable=inconsisten process finishes, the URI in the Location header returns a status of 204 on success. If the asynchronous request failed, the URI in the Location header returns an error-level status code. - :param group_id: The management group ID. + :param group_id: The management group ID. Required. :type group_id: str - :param deployment_name: The name of the deployment. + :param deployment_name: The name of the deployment. Required. :type deployment_name: str :keyword callable cls: A custom type or function that will be passed the direct response :keyword str continuation_token: A continuation token to restart a poller from a saved state. @@ -1656,86 +2176,93 @@ async def begin_delete_at_management_group_scope( # pylint: disable=inconsisten Retry-After header is present. :return: An instance of AsyncLROPoller that returns either None or the result of cls(response) :rtype: ~azure.core.polling.AsyncLROPoller[None] - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - api_version = kwargs.pop('api_version', "2019-10-01") # type: str - polling = kwargs.pop('polling', True) # type: Union[bool, AsyncPollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType[None] - lro_delay = kwargs.pop( - 'polling_interval', - self._config.polling_interval - ) - cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2019-10-01")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[None] + polling = kwargs.pop("polling", True) # type: Union[bool, AsyncPollingMethod] + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token = kwargs.pop("continuation_token", None) # type: Optional[str] if cont_token is None: - raw_result = await self._delete_at_management_group_scope_initial( + raw_result = await self._delete_at_management_group_scope_initial( # type: ignore group_id=group_id, deployment_name=deployment_name, api_version=api_version, - cls=lambda x,y,z: x, + cls=lambda x, y, z: x, + headers=_headers, + params=_params, **kwargs ) - kwargs.pop('error_map', None) + kwargs.pop("error_map", None) - def get_long_running_output(pipeline_response): + def get_long_running_output(pipeline_response): # pylint: disable=inconsistent-return-statements if cls: return cls(pipeline_response, None, {}) - - if polling is True: polling_method = AsyncARMPolling(lro_delay, **kwargs) - elif polling is False: polling_method = AsyncNoPolling() - else: polling_method = polling + if polling is True: + polling_method = cast(AsyncPollingMethod, AsyncARMPolling(lro_delay, **kwargs)) # type: AsyncPollingMethod + elif polling is False: + polling_method = cast(AsyncPollingMethod, AsyncNoPolling()) + else: + polling_method = polling if cont_token: return AsyncLROPoller.from_continuation_token( polling_method=polling_method, continuation_token=cont_token, client=self._client, - deserialization_callback=get_long_running_output + deserialization_callback=get_long_running_output, ) return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) - begin_delete_at_management_group_scope.metadata = {'url': "/providers/Microsoft.Management/managementGroups/{groupId}/providers/Microsoft.Resources/deployments/{deploymentName}"} # type: ignore + begin_delete_at_management_group_scope.metadata = {"url": "/providers/Microsoft.Management/managementGroups/{groupId}/providers/Microsoft.Resources/deployments/{deploymentName}"} # type: ignore @distributed_trace_async async def check_existence_at_management_group_scope( - self, - group_id: str, - deployment_name: str, - **kwargs: Any + self, group_id: str, deployment_name: str, **kwargs: Any ) -> bool: """Checks whether the deployment exists. - :param group_id: The management group ID. + :param group_id: The management group ID. Required. :type group_id: str - :param deployment_name: The name of the deployment. + :param deployment_name: The name of the deployment. Required. :type deployment_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: bool, or the result of cls(response) + :return: bool or the result of cls(response) :rtype: bool - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType[None] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + 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', "2019-10-01") # type: str + api_version = kwargs.pop("api_version", _params.pop("api-version", "2019-10-01")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[None] - request = build_deployments_check_existence_at_management_group_scope_request( group_id=group_id, deployment_name=deployment_name, api_version=api_version, - template_url=self.check_existence_at_management_group_scope.metadata['url'], + template_url=self.check_existence_at_management_group_scope.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [204, 404]: @@ -1746,43 +2273,52 @@ async def check_existence_at_management_group_scope( return cls(pipeline_response, None, {}) return 200 <= response.status_code <= 299 - check_existence_at_management_group_scope.metadata = {'url': "/providers/Microsoft.Management/managementGroups/{groupId}/providers/Microsoft.Resources/deployments/{deploymentName}"} # type: ignore - + check_existence_at_management_group_scope.metadata = {"url": "/providers/Microsoft.Management/managementGroups/{groupId}/providers/Microsoft.Resources/deployments/{deploymentName}"} # type: ignore async def _create_or_update_at_management_group_scope_initial( - self, - group_id: str, - deployment_name: str, - parameters: "_models.ScopedDeployment", - **kwargs: Any - ) -> "_models.DeploymentExtended": - cls = kwargs.pop('cls', None) # type: ClsType["_models.DeploymentExtended"] + self, group_id: str, deployment_name: str, parameters: Union[_models.ScopedDeployment, IO], **kwargs: Any + ) -> _models.DeploymentExtended: error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) - api_version = kwargs.pop('api_version', "2019-10-01") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - _json = self._serialize.body(parameters, 'ScopedDeployment') + api_version = kwargs.pop("api_version", _params.pop("api-version", "2019-10-01")) # type: str + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.DeploymentExtended] - request = build_deployments_create_or_update_at_management_group_scope_request_initial( + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(parameters, (IO, bytes)): + _content = parameters + else: + _json = self._serialize.body(parameters, "ScopedDeployment") + + request = build_deployments_create_or_update_at_management_group_scope_request( group_id=group_id, deployment_name=deployment_name, api_version=api_version, content_type=content_type, json=_json, - template_url=self._create_or_update_at_management_group_scope_initial.metadata['url'], + content=_content, + template_url=self._create_or_update_at_management_group_scope_initial.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200, 201]: @@ -1790,37 +2326,41 @@ async def _create_or_update_at_management_group_scope_initial( raise HttpResponseError(response=response, error_format=ARMErrorFormat) if response.status_code == 200: - deserialized = self._deserialize('DeploymentExtended', pipeline_response) + deserialized = self._deserialize("DeploymentExtended", pipeline_response) if response.status_code == 201: - deserialized = self._deserialize('DeploymentExtended', pipeline_response) + deserialized = self._deserialize("DeploymentExtended", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - _create_or_update_at_management_group_scope_initial.metadata = {'url': "/providers/Microsoft.Management/managementGroups/{groupId}/providers/Microsoft.Resources/deployments/{deploymentName}"} # type: ignore + _create_or_update_at_management_group_scope_initial.metadata = {"url": "/providers/Microsoft.Management/managementGroups/{groupId}/providers/Microsoft.Resources/deployments/{deploymentName}"} # type: ignore - - @distributed_trace_async + @overload async def begin_create_or_update_at_management_group_scope( self, group_id: str, deployment_name: str, - parameters: "_models.ScopedDeployment", + parameters: _models.ScopedDeployment, + *, + content_type: str = "application/json", **kwargs: Any - ) -> AsyncLROPoller["_models.DeploymentExtended"]: + ) -> AsyncLROPoller[_models.DeploymentExtended]: """Deploys resources at management group scope. You can provide the template and parameters directly in the request or link to JSON files. - :param group_id: The management group ID. + :param group_id: The management group ID. Required. :type group_id: str - :param deployment_name: The name of the deployment. + :param deployment_name: The name of the deployment. Required. :type deployment_name: str - :param parameters: Additional parameters supplied to the operation. + :param parameters: Additional parameters supplied to the operation. Required. :type parameters: ~azure.mgmt.resource.resources.v2019_10_01.models.ScopedDeployment + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str :keyword callable cls: A custom type or function that will be passed the direct response :keyword str continuation_token: A continuation token to restart a poller from a saved state. :keyword polling: By default, your polling method will be AsyncARMPolling. Pass in False for @@ -1833,114 +2373,187 @@ async def begin_create_or_update_at_management_group_scope( cls(response) :rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.resource.resources.v2019_10_01.models.DeploymentExtended] - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - api_version = kwargs.pop('api_version', "2019-10-01") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] - polling = kwargs.pop('polling', True) # type: Union[bool, AsyncPollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType["_models.DeploymentExtended"] - lro_delay = kwargs.pop( - 'polling_interval', - self._config.polling_interval - ) - cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] + + @overload + async def begin_create_or_update_at_management_group_scope( + self, + group_id: str, + deployment_name: str, + parameters: IO, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> AsyncLROPoller[_models.DeploymentExtended]: + """Deploys resources at management group scope. + + You can provide the template and parameters directly in the request or link to JSON files. + + :param group_id: The management group ID. Required. + :type group_id: str + :param deployment_name: The name of the deployment. Required. + :type deployment_name: str + :param parameters: Additional parameters supplied to the operation. Required. + :type parameters: IO + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be AsyncARMPolling. Pass in False for + this operation to not poll, or pass in your own initialized polling object for a personal + polling strategy. + :paramtype polling: bool or ~azure.core.polling.AsyncPollingMethod + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of AsyncLROPoller that returns either DeploymentExtended or the result of + cls(response) + :rtype: + ~azure.core.polling.AsyncLROPoller[~azure.mgmt.resource.resources.v2019_10_01.models.DeploymentExtended] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace_async + async def begin_create_or_update_at_management_group_scope( + self, group_id: str, deployment_name: str, parameters: Union[_models.ScopedDeployment, IO], **kwargs: Any + ) -> AsyncLROPoller[_models.DeploymentExtended]: + """Deploys resources at management group scope. + + You can provide the template and parameters directly in the request or link to JSON files. + + :param group_id: The management group ID. Required. + :type group_id: str + :param deployment_name: The name of the deployment. Required. + :type deployment_name: str + :param parameters: Additional parameters supplied to the operation. Is either a model type or a + IO type. Required. + :type parameters: ~azure.mgmt.resource.resources.v2019_10_01.models.ScopedDeployment or IO + :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. + Default value is None. + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be AsyncARMPolling. Pass in False for + this operation to not poll, or pass in your own initialized polling object for a personal + polling strategy. + :paramtype polling: bool or ~azure.core.polling.AsyncPollingMethod + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of AsyncLROPoller that returns either DeploymentExtended or the result of + cls(response) + :rtype: + ~azure.core.polling.AsyncLROPoller[~azure.mgmt.resource.resources.v2019_10_01.models.DeploymentExtended] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _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", "2019-10-01")) # type: str + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.DeploymentExtended] + polling = kwargs.pop("polling", True) # type: Union[bool, AsyncPollingMethod] + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token = kwargs.pop("continuation_token", None) # type: Optional[str] if cont_token is None: - raw_result = await self._create_or_update_at_management_group_scope_initial( + raw_result = await self._create_or_update_at_management_group_scope_initial( # type: ignore group_id=group_id, deployment_name=deployment_name, parameters=parameters, api_version=api_version, content_type=content_type, - cls=lambda x,y,z: x, + cls=lambda x, y, z: x, + headers=_headers, + params=_params, **kwargs ) - kwargs.pop('error_map', None) + kwargs.pop("error_map", None) def get_long_running_output(pipeline_response): - response = pipeline_response.http_response - deserialized = self._deserialize('DeploymentExtended', pipeline_response) + deserialized = self._deserialize("DeploymentExtended", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - - if polling is True: polling_method = AsyncARMPolling(lro_delay, **kwargs) - elif polling is False: polling_method = AsyncNoPolling() - else: polling_method = polling + if polling is True: + polling_method = cast(AsyncPollingMethod, AsyncARMPolling(lro_delay, **kwargs)) # type: AsyncPollingMethod + elif polling is False: + polling_method = cast(AsyncPollingMethod, AsyncNoPolling()) + else: + polling_method = polling if cont_token: return AsyncLROPoller.from_continuation_token( polling_method=polling_method, continuation_token=cont_token, client=self._client, - deserialization_callback=get_long_running_output + deserialization_callback=get_long_running_output, ) return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) - begin_create_or_update_at_management_group_scope.metadata = {'url': "/providers/Microsoft.Management/managementGroups/{groupId}/providers/Microsoft.Resources/deployments/{deploymentName}"} # type: ignore + begin_create_or_update_at_management_group_scope.metadata = {"url": "/providers/Microsoft.Management/managementGroups/{groupId}/providers/Microsoft.Resources/deployments/{deploymentName}"} # type: ignore @distributed_trace_async async def get_at_management_group_scope( - self, - group_id: str, - deployment_name: str, - **kwargs: Any - ) -> "_models.DeploymentExtended": + self, group_id: str, deployment_name: str, **kwargs: Any + ) -> _models.DeploymentExtended: """Gets a deployment. - :param group_id: The management group ID. + :param group_id: The management group ID. Required. :type group_id: str - :param deployment_name: The name of the deployment. + :param deployment_name: The name of the deployment. Required. :type deployment_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: DeploymentExtended, or the result of cls(response) + :return: DeploymentExtended or the result of cls(response) :rtype: ~azure.mgmt.resource.resources.v2019_10_01.models.DeploymentExtended - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.DeploymentExtended"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + 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', "2019-10-01") # type: str + api_version = kwargs.pop("api_version", _params.pop("api-version", "2019-10-01")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[_models.DeploymentExtended] - request = build_deployments_get_at_management_group_scope_request( group_id=group_id, deployment_name=deployment_name, api_version=api_version, - template_url=self.get_at_management_group_scope.metadata['url'], + template_url=self.get_at_management_group_scope.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) - deserialized = self._deserialize('DeploymentExtended', pipeline_response) + deserialized = self._deserialize("DeploymentExtended", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - get_at_management_group_scope.metadata = {'url': "/providers/Microsoft.Management/managementGroups/{groupId}/providers/Microsoft.Resources/deployments/{deploymentName}"} # type: ignore - + get_at_management_group_scope.metadata = {"url": "/providers/Microsoft.Management/managementGroups/{groupId}/providers/Microsoft.Resources/deployments/{deploymentName}"} # type: ignore @distributed_trace_async async def cancel_at_management_group_scope( # pylint: disable=inconsistent-return-statements - self, - group_id: str, - deployment_name: str, - **kwargs: Any + self, group_id: str, deployment_name: str, **kwargs: Any ) -> None: """Cancels a currently running template deployment. @@ -1949,38 +2562,44 @@ async def cancel_at_management_group_scope( # pylint: disable=inconsistent-retu deployment stops the currently running template deployment and leaves the resources partially deployed. - :param group_id: The management group ID. + :param group_id: The management group ID. Required. :type group_id: str - :param deployment_name: The name of the deployment. + :param deployment_name: The name of the deployment. Required. :type deployment_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: None, or the result of cls(response) + :return: None or the result of cls(response) :rtype: None - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType[None] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) - api_version = kwargs.pop('api_version', "2019-10-01") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2019-10-01")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[None] - request = build_deployments_cancel_at_management_group_scope_request( group_id=group_id, deployment_name=deployment_name, api_version=api_version, - template_url=self.cancel_at_management_group_scope.metadata['url'], + template_url=self.cancel_at_management_group_scope.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [204]: @@ -1990,43 +2609,52 @@ async def cancel_at_management_group_scope( # pylint: disable=inconsistent-retu if cls: return cls(pipeline_response, None, {}) - cancel_at_management_group_scope.metadata = {'url': "/providers/Microsoft.Management/managementGroups/{groupId}/providers/Microsoft.Resources/deployments/{deploymentName}/cancel"} # type: ignore - + cancel_at_management_group_scope.metadata = {"url": "/providers/Microsoft.Management/managementGroups/{groupId}/providers/Microsoft.Resources/deployments/{deploymentName}/cancel"} # type: ignore async def _validate_at_management_group_scope_initial( - self, - group_id: str, - deployment_name: str, - parameters: "_models.ScopedDeployment", - **kwargs: Any - ) -> Optional["_models.DeploymentValidateResult"]: - cls = kwargs.pop('cls', None) # type: ClsType[Optional["_models.DeploymentValidateResult"]] + self, group_id: str, deployment_name: str, parameters: Union[_models.ScopedDeployment, IO], **kwargs: Any + ) -> Optional[_models.DeploymentValidateResult]: error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', "2019-10-01") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + api_version = kwargs.pop("api_version", _params.pop("api-version", "2019-10-01")) # type: str + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[Optional[_models.DeploymentValidateResult]] - _json = self._serialize.body(parameters, 'ScopedDeployment') + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(parameters, (IO, bytes)): + _content = parameters + else: + _json = self._serialize.body(parameters, "ScopedDeployment") - request = build_deployments_validate_at_management_group_scope_request_initial( + request = build_deployments_validate_at_management_group_scope_request( group_id=group_id, deployment_name=deployment_name, api_version=api_version, content_type=content_type, json=_json, - template_url=self._validate_at_management_group_scope_initial.metadata['url'], + content=_content, + template_url=self._validate_at_management_group_scope_initial.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200, 202, 400]: @@ -2035,36 +2663,40 @@ async def _validate_at_management_group_scope_initial( deserialized = None if response.status_code == 200: - deserialized = self._deserialize('DeploymentValidateResult', pipeline_response) + deserialized = self._deserialize("DeploymentValidateResult", pipeline_response) if response.status_code == 400: - deserialized = self._deserialize('DeploymentValidateResult', pipeline_response) + deserialized = self._deserialize("DeploymentValidateResult", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - _validate_at_management_group_scope_initial.metadata = {'url': "/providers/Microsoft.Management/managementGroups/{groupId}/providers/Microsoft.Resources/deployments/{deploymentName}/validate"} # type: ignore - + _validate_at_management_group_scope_initial.metadata = {"url": "/providers/Microsoft.Management/managementGroups/{groupId}/providers/Microsoft.Resources/deployments/{deploymentName}/validate"} # type: ignore - @distributed_trace_async + @overload async def begin_validate_at_management_group_scope( self, group_id: str, deployment_name: str, - parameters: "_models.ScopedDeployment", + parameters: _models.ScopedDeployment, + *, + content_type: str = "application/json", **kwargs: Any - ) -> AsyncLROPoller["_models.DeploymentValidateResult"]: + ) -> AsyncLROPoller[_models.DeploymentValidateResult]: """Validates whether the specified template is syntactically correct and will be accepted by Azure Resource Manager.. - :param group_id: The management group ID. + :param group_id: The management group ID. Required. :type group_id: str - :param deployment_name: The name of the deployment. + :param deployment_name: The name of the deployment. Required. :type deployment_name: str - :param parameters: Parameters to validate. + :param parameters: Parameters to validate. Required. :type parameters: ~azure.mgmt.resource.resources.v2019_10_01.models.ScopedDeployment + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str :keyword callable cls: A custom type or function that will be passed the direct response :keyword str continuation_token: A continuation token to restart a poller from a saved state. :keyword polling: By default, your polling method will be AsyncARMPolling. Pass in False for @@ -2077,85 +2709,166 @@ async def begin_validate_at_management_group_scope( result of cls(response) :rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.resource.resources.v2019_10_01.models.DeploymentValidateResult] - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - api_version = kwargs.pop('api_version', "2019-10-01") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] - polling = kwargs.pop('polling', True) # type: Union[bool, AsyncPollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType["_models.DeploymentValidateResult"] - lro_delay = kwargs.pop( - 'polling_interval', - self._config.polling_interval - ) - cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] - if cont_token is None: - raw_result = await self._validate_at_management_group_scope_initial( - group_id=group_id, - deployment_name=deployment_name, - parameters=parameters, - api_version=api_version, - content_type=content_type, - cls=lambda x,y,z: x, - **kwargs - ) - kwargs.pop('error_map', None) - - def get_long_running_output(pipeline_response): - response = pipeline_response.http_response - deserialized = self._deserialize('DeploymentValidateResult', pipeline_response) - if cls: - return cls(pipeline_response, deserialized, {}) - return deserialized - - if polling is True: polling_method = AsyncARMPolling(lro_delay, **kwargs) - elif polling is False: polling_method = AsyncNoPolling() - else: polling_method = polling - if cont_token: - return AsyncLROPoller.from_continuation_token( - polling_method=polling_method, + @overload + async def begin_validate_at_management_group_scope( + self, + group_id: str, + deployment_name: str, + parameters: IO, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> AsyncLROPoller[_models.DeploymentValidateResult]: + """Validates whether the specified template is syntactically correct and will be accepted by Azure + Resource Manager.. + + :param group_id: The management group ID. Required. + :type group_id: str + :param deployment_name: The name of the deployment. Required. + :type deployment_name: str + :param parameters: Parameters to validate. Required. + :type parameters: IO + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be AsyncARMPolling. Pass in False for + this operation to not poll, or pass in your own initialized polling object for a personal + polling strategy. + :paramtype polling: bool or ~azure.core.polling.AsyncPollingMethod + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of AsyncLROPoller that returns either DeploymentValidateResult or the + result of cls(response) + :rtype: + ~azure.core.polling.AsyncLROPoller[~azure.mgmt.resource.resources.v2019_10_01.models.DeploymentValidateResult] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace_async + async def begin_validate_at_management_group_scope( + self, group_id: str, deployment_name: str, parameters: Union[_models.ScopedDeployment, IO], **kwargs: Any + ) -> AsyncLROPoller[_models.DeploymentValidateResult]: + """Validates whether the specified template is syntactically correct and will be accepted by Azure + Resource Manager.. + + :param group_id: The management group ID. Required. + :type group_id: str + :param deployment_name: The name of the deployment. Required. + :type deployment_name: str + :param parameters: Parameters to validate. Is either a model type or a IO type. Required. + :type parameters: ~azure.mgmt.resource.resources.v2019_10_01.models.ScopedDeployment or IO + :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. + Default value is None. + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be AsyncARMPolling. Pass in False for + this operation to not poll, or pass in your own initialized polling object for a personal + polling strategy. + :paramtype polling: bool or ~azure.core.polling.AsyncPollingMethod + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of AsyncLROPoller that returns either DeploymentValidateResult or the + result of cls(response) + :rtype: + ~azure.core.polling.AsyncLROPoller[~azure.mgmt.resource.resources.v2019_10_01.models.DeploymentValidateResult] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _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", "2019-10-01")) # type: str + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.DeploymentValidateResult] + polling = kwargs.pop("polling", True) # type: Union[bool, AsyncPollingMethod] + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token = kwargs.pop("continuation_token", None) # type: Optional[str] + if cont_token is None: + raw_result = await self._validate_at_management_group_scope_initial( # type: ignore + group_id=group_id, + deployment_name=deployment_name, + parameters=parameters, + api_version=api_version, + content_type=content_type, + cls=lambda x, y, z: x, + headers=_headers, + params=_params, + **kwargs + ) + kwargs.pop("error_map", None) + + def get_long_running_output(pipeline_response): + deserialized = self._deserialize("DeploymentValidateResult", pipeline_response) + if cls: + return cls(pipeline_response, deserialized, {}) + return deserialized + + if polling is True: + polling_method = cast(AsyncPollingMethod, AsyncARMPolling(lro_delay, **kwargs)) # type: AsyncPollingMethod + elif polling is False: + polling_method = cast(AsyncPollingMethod, AsyncNoPolling()) + else: + polling_method = polling + if cont_token: + return AsyncLROPoller.from_continuation_token( + polling_method=polling_method, continuation_token=cont_token, client=self._client, - deserialization_callback=get_long_running_output + deserialization_callback=get_long_running_output, ) return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) - begin_validate_at_management_group_scope.metadata = {'url': "/providers/Microsoft.Management/managementGroups/{groupId}/providers/Microsoft.Resources/deployments/{deploymentName}/validate"} # type: ignore + begin_validate_at_management_group_scope.metadata = {"url": "/providers/Microsoft.Management/managementGroups/{groupId}/providers/Microsoft.Resources/deployments/{deploymentName}/validate"} # type: ignore async def _what_if_at_management_group_scope_initial( - self, - group_id: str, - deployment_name: str, - parameters: "_models.ScopedDeploymentWhatIf", - **kwargs: Any - ) -> Optional["_models.WhatIfOperationResult"]: - cls = kwargs.pop('cls', None) # type: ClsType[Optional["_models.WhatIfOperationResult"]] + self, group_id: str, deployment_name: str, parameters: Union[_models.ScopedDeploymentWhatIf, IO], **kwargs: Any + ) -> Optional[_models.WhatIfOperationResult]: error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) - api_version = kwargs.pop('api_version', "2019-10-01") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - _json = self._serialize.body(parameters, 'ScopedDeploymentWhatIf') + api_version = kwargs.pop("api_version", _params.pop("api-version", "2019-10-01")) # type: str + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[Optional[_models.WhatIfOperationResult]] - request = build_deployments_what_if_at_management_group_scope_request_initial( + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(parameters, (IO, bytes)): + _content = parameters + else: + _json = self._serialize.body(parameters, "ScopedDeploymentWhatIf") + + request = build_deployments_what_if_at_management_group_scope_request( group_id=group_id, deployment_name=deployment_name, api_version=api_version, content_type=content_type, json=_json, - template_url=self._what_if_at_management_group_scope_initial.metadata['url'], + content=_content, + template_url=self._what_if_at_management_group_scope_initial.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200, 202]: @@ -2165,38 +2878,41 @@ async def _what_if_at_management_group_scope_initial( deserialized = None response_headers = {} if response.status_code == 200: - deserialized = self._deserialize('WhatIfOperationResult', pipeline_response) + deserialized = self._deserialize("WhatIfOperationResult", pipeline_response) if response.status_code == 202: - response_headers['Location']=self._deserialize('str', response.headers.get('Location')) - response_headers['Retry-After']=self._deserialize('str', response.headers.get('Retry-After')) - + response_headers["Location"] = self._deserialize("str", response.headers.get("Location")) + response_headers["Retry-After"] = self._deserialize("str", response.headers.get("Retry-After")) if cls: return cls(pipeline_response, deserialized, response_headers) return deserialized - _what_if_at_management_group_scope_initial.metadata = {'url': "/providers/Microsoft.Management/managementGroups/{groupId}/providers/Microsoft.Resources/deployments/{deploymentName}/whatIf"} # type: ignore + _what_if_at_management_group_scope_initial.metadata = {"url": "/providers/Microsoft.Management/managementGroups/{groupId}/providers/Microsoft.Resources/deployments/{deploymentName}/whatIf"} # type: ignore - - @distributed_trace_async + @overload async def begin_what_if_at_management_group_scope( self, group_id: str, deployment_name: str, - parameters: "_models.ScopedDeploymentWhatIf", + parameters: _models.ScopedDeploymentWhatIf, + *, + content_type: str = "application/json", **kwargs: Any - ) -> AsyncLROPoller["_models.WhatIfOperationResult"]: + ) -> AsyncLROPoller[_models.WhatIfOperationResult]: """Returns changes that will be made by the deployment if executed at the scope of the management group. - :param group_id: The management group ID. + :param group_id: The management group ID. Required. :type group_id: str - :param deployment_name: The name of the deployment. + :param deployment_name: The name of the deployment. Required. :type deployment_name: str - :param parameters: Parameters to validate. + :param parameters: Parameters to validate. Required. :type parameters: ~azure.mgmt.resource.resources.v2019_10_01.models.ScopedDeploymentWhatIf + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str :keyword callable cls: A custom type or function that will be passed the direct response :keyword str continuation_token: A continuation token to restart a poller from a saved state. :keyword polling: By default, your polling method will be AsyncARMPolling. Pass in False for @@ -2209,119 +2925,191 @@ async def begin_what_if_at_management_group_scope( of cls(response) :rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.resource.resources.v2019_10_01.models.WhatIfOperationResult] - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - api_version = kwargs.pop('api_version', "2019-10-01") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] - polling = kwargs.pop('polling', True) # type: Union[bool, AsyncPollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType["_models.WhatIfOperationResult"] - lro_delay = kwargs.pop( - 'polling_interval', - self._config.polling_interval - ) - cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] + + @overload + async def begin_what_if_at_management_group_scope( + self, + group_id: str, + deployment_name: str, + parameters: IO, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> AsyncLROPoller[_models.WhatIfOperationResult]: + """Returns changes that will be made by the deployment if executed at the scope of the management + group. + + :param group_id: The management group ID. Required. + :type group_id: str + :param deployment_name: The name of the deployment. Required. + :type deployment_name: str + :param parameters: Parameters to validate. Required. + :type parameters: IO + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be AsyncARMPolling. Pass in False for + this operation to not poll, or pass in your own initialized polling object for a personal + polling strategy. + :paramtype polling: bool or ~azure.core.polling.AsyncPollingMethod + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of AsyncLROPoller that returns either WhatIfOperationResult or the result + of cls(response) + :rtype: + ~azure.core.polling.AsyncLROPoller[~azure.mgmt.resource.resources.v2019_10_01.models.WhatIfOperationResult] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace_async + async def begin_what_if_at_management_group_scope( + self, group_id: str, deployment_name: str, parameters: Union[_models.ScopedDeploymentWhatIf, IO], **kwargs: Any + ) -> AsyncLROPoller[_models.WhatIfOperationResult]: + """Returns changes that will be made by the deployment if executed at the scope of the management + group. + + :param group_id: The management group ID. Required. + :type group_id: str + :param deployment_name: The name of the deployment. Required. + :type deployment_name: str + :param parameters: Parameters to validate. Is either a model type or a IO type. Required. + :type parameters: ~azure.mgmt.resource.resources.v2019_10_01.models.ScopedDeploymentWhatIf or + IO + :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. + Default value is None. + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be AsyncARMPolling. Pass in False for + this operation to not poll, or pass in your own initialized polling object for a personal + polling strategy. + :paramtype polling: bool or ~azure.core.polling.AsyncPollingMethod + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of AsyncLROPoller that returns either WhatIfOperationResult or the result + of cls(response) + :rtype: + ~azure.core.polling.AsyncLROPoller[~azure.mgmt.resource.resources.v2019_10_01.models.WhatIfOperationResult] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _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", "2019-10-01")) # type: str + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.WhatIfOperationResult] + polling = kwargs.pop("polling", True) # type: Union[bool, AsyncPollingMethod] + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token = kwargs.pop("continuation_token", None) # type: Optional[str] if cont_token is None: - raw_result = await self._what_if_at_management_group_scope_initial( + raw_result = await self._what_if_at_management_group_scope_initial( # type: ignore group_id=group_id, deployment_name=deployment_name, parameters=parameters, api_version=api_version, content_type=content_type, - cls=lambda x,y,z: x, + cls=lambda x, y, z: x, + headers=_headers, + params=_params, **kwargs ) - kwargs.pop('error_map', None) + kwargs.pop("error_map", None) def get_long_running_output(pipeline_response): - response = pipeline_response.http_response - deserialized = self._deserialize('WhatIfOperationResult', pipeline_response) + deserialized = self._deserialize("WhatIfOperationResult", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - - if polling is True: polling_method = AsyncARMPolling(lro_delay, lro_options={'final-state-via': 'location'}, **kwargs) - elif polling is False: polling_method = AsyncNoPolling() - else: polling_method = polling + if polling is True: + polling_method = cast( + AsyncPollingMethod, AsyncARMPolling(lro_delay, lro_options={"final-state-via": "location"}, **kwargs) + ) # type: AsyncPollingMethod + elif polling is False: + polling_method = cast(AsyncPollingMethod, AsyncNoPolling()) + else: + polling_method = polling if cont_token: return AsyncLROPoller.from_continuation_token( polling_method=polling_method, continuation_token=cont_token, client=self._client, - deserialization_callback=get_long_running_output + deserialization_callback=get_long_running_output, ) return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) - begin_what_if_at_management_group_scope.metadata = {'url': "/providers/Microsoft.Management/managementGroups/{groupId}/providers/Microsoft.Resources/deployments/{deploymentName}/whatIf"} # type: ignore + begin_what_if_at_management_group_scope.metadata = {"url": "/providers/Microsoft.Management/managementGroups/{groupId}/providers/Microsoft.Resources/deployments/{deploymentName}/whatIf"} # type: ignore @distributed_trace_async async def export_template_at_management_group_scope( - self, - group_id: str, - deployment_name: str, - **kwargs: Any - ) -> "_models.DeploymentExportResult": + self, group_id: str, deployment_name: str, **kwargs: Any + ) -> _models.DeploymentExportResult: """Exports the template used for specified deployment. - :param group_id: The management group ID. + :param group_id: The management group ID. Required. :type group_id: str - :param deployment_name: The name of the deployment. + :param deployment_name: The name of the deployment. Required. :type deployment_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: DeploymentExportResult, or the result of cls(response) + :return: DeploymentExportResult or the result of cls(response) :rtype: ~azure.mgmt.resource.resources.v2019_10_01.models.DeploymentExportResult - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.DeploymentExportResult"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + 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', "2019-10-01") # type: str + api_version = kwargs.pop("api_version", _params.pop("api-version", "2019-10-01")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[_models.DeploymentExportResult] - request = build_deployments_export_template_at_management_group_scope_request( group_id=group_id, deployment_name=deployment_name, api_version=api_version, - template_url=self.export_template_at_management_group_scope.metadata['url'], + template_url=self.export_template_at_management_group_scope.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) - deserialized = self._deserialize('DeploymentExportResult', pipeline_response) + deserialized = self._deserialize("DeploymentExportResult", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - export_template_at_management_group_scope.metadata = {'url': "/providers/Microsoft.Management/managementGroups/{groupId}/providers/Microsoft.Resources/deployments/{deploymentName}/exportTemplate"} # type: ignore - + export_template_at_management_group_scope.metadata = {"url": "/providers/Microsoft.Management/managementGroups/{groupId}/providers/Microsoft.Resources/deployments/{deploymentName}/exportTemplate"} # type: ignore @distributed_trace def list_at_management_group_scope( - self, - group_id: str, - filter: Optional[str] = None, - top: Optional[int] = None, - **kwargs: Any - ) -> AsyncIterable["_models.DeploymentListResult"]: + self, group_id: str, filter: Optional[str] = None, top: Optional[int] = None, **kwargs: Any + ) -> AsyncIterable["_models.DeploymentExtended"]: """Get all the deployments for a management group. - :param group_id: The management group ID. + :param group_id: The management group ID. Required. :type group_id: str :param filter: The filter to apply on the operation. For example, you can use $filter=provisioningState eq '{state}'. Default value is None. @@ -2330,40 +3118,48 @@ def list_at_management_group_scope( value is None. :type top: int :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either DeploymentListResult or the result of - cls(response) + :return: An iterator like instance of either DeploymentExtended or the result of cls(response) :rtype: - ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.resource.resources.v2019_10_01.models.DeploymentListResult] - :raises: ~azure.core.exceptions.HttpResponseError + ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.resource.resources.v2019_10_01.models.DeploymentExtended] + :raises ~azure.core.exceptions.HttpResponseError: """ - api_version = kwargs.pop('api_version', "2019-10-01") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2019-10-01")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[_models.DeploymentListResult] - cls = kwargs.pop('cls', None) # type: ClsType["_models.DeploymentListResult"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) + def prepare_request(next_link=None): if not next_link: - + request = build_deployments_list_at_management_group_scope_request( group_id=group_id, - api_version=api_version, filter=filter, top=top, - template_url=self.list_at_management_group_scope.metadata['url'], + api_version=api_version, + template_url=self.list_at_management_group_scope.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore else: - - request = build_deployments_list_at_management_group_scope_request( - group_id=group_id, - template_url=next_link, - ) + # make call to next link with the client's api-version + _parsed_next_link = urlparse(next_link) + _next_request_params = case_insensitive_dict(parse_qs(_parsed_next_link.query)) + _next_request_params["api-version"] = self._config.api_version + request = HttpRequest("GET", urljoin(next_link, _parsed_next_link.path), params=_next_request_params) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore request.method = "GET" return request @@ -2377,10 +3173,8 @@ async def extract_data(pipeline_response): async def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) response = pipeline_response.http_response @@ -2390,40 +3184,42 @@ async def get_next(next_link=None): return pipeline_response + return AsyncItemPaged(get_next, extract_data) - return AsyncItemPaged( - get_next, extract_data - ) - list_at_management_group_scope.metadata = {'url': "/providers/Microsoft.Management/managementGroups/{groupId}/providers/Microsoft.Resources/deployments/"} # type: ignore + list_at_management_group_scope.metadata = {"url": "/providers/Microsoft.Management/managementGroups/{groupId}/providers/Microsoft.Resources/deployments/"} # type: ignore async def _delete_at_subscription_scope_initial( # pylint: disable=inconsistent-return-statements - self, - deployment_name: str, - **kwargs: Any + self, deployment_name: str, **kwargs: Any ) -> None: - cls = kwargs.pop('cls', None) # type: ClsType[None] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + 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', "2019-10-01") # type: str + api_version = kwargs.pop("api_version", _params.pop("api-version", "2019-10-01")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[None] - - request = build_deployments_delete_at_subscription_scope_request_initial( + request = build_deployments_delete_at_subscription_scope_request( deployment_name=deployment_name, subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self._delete_at_subscription_scope_initial.metadata['url'], + template_url=self._delete_at_subscription_scope_initial.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [202, 204]: @@ -2433,15 +3229,10 @@ async def _delete_at_subscription_scope_initial( # pylint: disable=inconsistent if cls: return cls(pipeline_response, None, {}) - _delete_at_subscription_scope_initial.metadata = {'url': "/subscriptions/{subscriptionId}/providers/Microsoft.Resources/deployments/{deploymentName}"} # type: ignore - + _delete_at_subscription_scope_initial.metadata = {"url": "/subscriptions/{subscriptionId}/providers/Microsoft.Resources/deployments/{deploymentName}"} # type: ignore @distributed_trace_async - async def begin_delete_at_subscription_scope( # pylint: disable=inconsistent-return-statements - self, - deployment_name: str, - **kwargs: Any - ) -> AsyncLROPoller[None]: + async def begin_delete_at_subscription_scope(self, deployment_name: str, **kwargs: Any) -> AsyncLROPoller[None]: """Deletes a deployment from the deployment history. A template deployment that is currently running cannot be deleted. Deleting a template @@ -2452,7 +3243,7 @@ async def begin_delete_at_subscription_scope( # pylint: disable=inconsistent-re process finishes, the URI in the Location header returns a status of 204 on success. If the asynchronous request failed, the URI in the Location header returns an error-level status code. - :param deployment_name: The name of the deployment. + :param deployment_name: The name of the deployment. Required. :type deployment_name: str :keyword callable cls: A custom type or function that will be passed the direct response :keyword str continuation_token: A continuation token to restart a poller from a saved state. @@ -2464,82 +3255,88 @@ async def begin_delete_at_subscription_scope( # pylint: disable=inconsistent-re Retry-After header is present. :return: An instance of AsyncLROPoller that returns either None or the result of cls(response) :rtype: ~azure.core.polling.AsyncLROPoller[None] - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - api_version = kwargs.pop('api_version', "2019-10-01") # type: str - polling = kwargs.pop('polling', True) # type: Union[bool, AsyncPollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType[None] - lro_delay = kwargs.pop( - 'polling_interval', - self._config.polling_interval - ) - cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2019-10-01")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[None] + polling = kwargs.pop("polling", True) # type: Union[bool, AsyncPollingMethod] + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token = kwargs.pop("continuation_token", None) # type: Optional[str] if cont_token is None: - raw_result = await self._delete_at_subscription_scope_initial( + raw_result = await self._delete_at_subscription_scope_initial( # type: ignore deployment_name=deployment_name, api_version=api_version, - cls=lambda x,y,z: x, + cls=lambda x, y, z: x, + headers=_headers, + params=_params, **kwargs ) - kwargs.pop('error_map', None) + kwargs.pop("error_map", None) - def get_long_running_output(pipeline_response): + def get_long_running_output(pipeline_response): # pylint: disable=inconsistent-return-statements if cls: return cls(pipeline_response, None, {}) - - if polling is True: polling_method = AsyncARMPolling(lro_delay, **kwargs) - elif polling is False: polling_method = AsyncNoPolling() - else: polling_method = polling + if polling is True: + polling_method = cast(AsyncPollingMethod, AsyncARMPolling(lro_delay, **kwargs)) # type: AsyncPollingMethod + elif polling is False: + polling_method = cast(AsyncPollingMethod, AsyncNoPolling()) + else: + polling_method = polling if cont_token: return AsyncLROPoller.from_continuation_token( polling_method=polling_method, continuation_token=cont_token, client=self._client, - deserialization_callback=get_long_running_output + deserialization_callback=get_long_running_output, ) return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) - begin_delete_at_subscription_scope.metadata = {'url': "/subscriptions/{subscriptionId}/providers/Microsoft.Resources/deployments/{deploymentName}"} # type: ignore + begin_delete_at_subscription_scope.metadata = {"url": "/subscriptions/{subscriptionId}/providers/Microsoft.Resources/deployments/{deploymentName}"} # type: ignore @distributed_trace_async - async def check_existence_at_subscription_scope( - self, - deployment_name: str, - **kwargs: Any - ) -> bool: + async def check_existence_at_subscription_scope(self, deployment_name: str, **kwargs: Any) -> bool: """Checks whether the deployment exists. - :param deployment_name: The name of the deployment. + :param deployment_name: The name of the deployment. Required. :type deployment_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: bool, or the result of cls(response) + :return: bool or the result of cls(response) :rtype: bool - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType[None] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + 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', "2019-10-01") # type: str + api_version = kwargs.pop("api_version", _params.pop("api-version", "2019-10-01")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[None] - request = build_deployments_check_existence_at_subscription_scope_request( deployment_name=deployment_name, subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.check_existence_at_subscription_scope.metadata['url'], + template_url=self.check_existence_at_subscription_scope.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [204, 404]: @@ -2550,42 +3347,52 @@ async def check_existence_at_subscription_scope( return cls(pipeline_response, None, {}) return 200 <= response.status_code <= 299 - check_existence_at_subscription_scope.metadata = {'url': "/subscriptions/{subscriptionId}/providers/Microsoft.Resources/deployments/{deploymentName}"} # type: ignore - + check_existence_at_subscription_scope.metadata = {"url": "/subscriptions/{subscriptionId}/providers/Microsoft.Resources/deployments/{deploymentName}"} # type: ignore async def _create_or_update_at_subscription_scope_initial( - self, - deployment_name: str, - parameters: "_models.Deployment", - **kwargs: Any - ) -> "_models.DeploymentExtended": - cls = kwargs.pop('cls', None) # type: ClsType["_models.DeploymentExtended"] + self, deployment_name: str, parameters: Union[_models.Deployment, IO], **kwargs: Any + ) -> _models.DeploymentExtended: error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', "2019-10-01") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + api_version = kwargs.pop("api_version", _params.pop("api-version", "2019-10-01")) # type: str + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.DeploymentExtended] - _json = self._serialize.body(parameters, 'Deployment') + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(parameters, (IO, bytes)): + _content = parameters + else: + _json = self._serialize.body(parameters, "Deployment") - request = build_deployments_create_or_update_at_subscription_scope_request_initial( + request = build_deployments_create_or_update_at_subscription_scope_request( deployment_name=deployment_name, subscription_id=self._config.subscription_id, api_version=api_version, content_type=content_type, json=_json, - template_url=self._create_or_update_at_subscription_scope_initial.metadata['url'], + content=_content, + template_url=self._create_or_update_at_subscription_scope_initial.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200, 201]: @@ -2593,34 +3400,38 @@ async def _create_or_update_at_subscription_scope_initial( raise HttpResponseError(response=response, error_format=ARMErrorFormat) if response.status_code == 200: - deserialized = self._deserialize('DeploymentExtended', pipeline_response) + deserialized = self._deserialize("DeploymentExtended", pipeline_response) if response.status_code == 201: - deserialized = self._deserialize('DeploymentExtended', pipeline_response) + deserialized = self._deserialize("DeploymentExtended", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - _create_or_update_at_subscription_scope_initial.metadata = {'url': "/subscriptions/{subscriptionId}/providers/Microsoft.Resources/deployments/{deploymentName}"} # type: ignore - + _create_or_update_at_subscription_scope_initial.metadata = {"url": "/subscriptions/{subscriptionId}/providers/Microsoft.Resources/deployments/{deploymentName}"} # type: ignore - @distributed_trace_async + @overload async def begin_create_or_update_at_subscription_scope( self, deployment_name: str, - parameters: "_models.Deployment", + parameters: _models.Deployment, + *, + content_type: str = "application/json", **kwargs: Any - ) -> AsyncLROPoller["_models.DeploymentExtended"]: + ) -> AsyncLROPoller[_models.DeploymentExtended]: """Deploys resources at subscription scope. You can provide the template and parameters directly in the request or link to JSON files. - :param deployment_name: The name of the deployment. + :param deployment_name: The name of the deployment. Required. :type deployment_name: str - :param parameters: Additional parameters supplied to the operation. + :param parameters: Additional parameters supplied to the operation. Required. :type parameters: ~azure.mgmt.resource.resources.v2019_10_01.models.Deployment + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str :keyword callable cls: A custom type or function that will be passed the direct response :keyword str continuation_token: A continuation token to restart a poller from a saved state. :keyword polling: By default, your polling method will be AsyncARMPolling. Pass in False for @@ -2633,109 +3444,172 @@ async def begin_create_or_update_at_subscription_scope( cls(response) :rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.resource.resources.v2019_10_01.models.DeploymentExtended] - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - api_version = kwargs.pop('api_version', "2019-10-01") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] - polling = kwargs.pop('polling', True) # type: Union[bool, AsyncPollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType["_models.DeploymentExtended"] - lro_delay = kwargs.pop( - 'polling_interval', - self._config.polling_interval - ) - cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] + + @overload + async def begin_create_or_update_at_subscription_scope( + self, deployment_name: str, parameters: IO, *, content_type: str = "application/json", **kwargs: Any + ) -> AsyncLROPoller[_models.DeploymentExtended]: + """Deploys resources at subscription scope. + + You can provide the template and parameters directly in the request or link to JSON files. + + :param deployment_name: The name of the deployment. Required. + :type deployment_name: str + :param parameters: Additional parameters supplied to the operation. Required. + :type parameters: IO + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be AsyncARMPolling. Pass in False for + this operation to not poll, or pass in your own initialized polling object for a personal + polling strategy. + :paramtype polling: bool or ~azure.core.polling.AsyncPollingMethod + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of AsyncLROPoller that returns either DeploymentExtended or the result of + cls(response) + :rtype: + ~azure.core.polling.AsyncLROPoller[~azure.mgmt.resource.resources.v2019_10_01.models.DeploymentExtended] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace_async + async def begin_create_or_update_at_subscription_scope( + self, deployment_name: str, parameters: Union[_models.Deployment, IO], **kwargs: Any + ) -> AsyncLROPoller[_models.DeploymentExtended]: + """Deploys resources at subscription scope. + + You can provide the template and parameters directly in the request or link to JSON files. + + :param deployment_name: The name of the deployment. Required. + :type deployment_name: str + :param parameters: Additional parameters supplied to the operation. Is either a model type or a + IO type. Required. + :type parameters: ~azure.mgmt.resource.resources.v2019_10_01.models.Deployment or IO + :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. + Default value is None. + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be AsyncARMPolling. Pass in False for + this operation to not poll, or pass in your own initialized polling object for a personal + polling strategy. + :paramtype polling: bool or ~azure.core.polling.AsyncPollingMethod + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of AsyncLROPoller that returns either DeploymentExtended or the result of + cls(response) + :rtype: + ~azure.core.polling.AsyncLROPoller[~azure.mgmt.resource.resources.v2019_10_01.models.DeploymentExtended] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _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", "2019-10-01")) # type: str + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.DeploymentExtended] + polling = kwargs.pop("polling", True) # type: Union[bool, AsyncPollingMethod] + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token = kwargs.pop("continuation_token", None) # type: Optional[str] if cont_token is None: - raw_result = await self._create_or_update_at_subscription_scope_initial( + raw_result = await self._create_or_update_at_subscription_scope_initial( # type: ignore deployment_name=deployment_name, parameters=parameters, api_version=api_version, content_type=content_type, - cls=lambda x,y,z: x, + cls=lambda x, y, z: x, + headers=_headers, + params=_params, **kwargs ) - kwargs.pop('error_map', None) + kwargs.pop("error_map", None) def get_long_running_output(pipeline_response): - response = pipeline_response.http_response - deserialized = self._deserialize('DeploymentExtended', pipeline_response) + deserialized = self._deserialize("DeploymentExtended", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - - if polling is True: polling_method = AsyncARMPolling(lro_delay, **kwargs) - elif polling is False: polling_method = AsyncNoPolling() - else: polling_method = polling + if polling is True: + polling_method = cast(AsyncPollingMethod, AsyncARMPolling(lro_delay, **kwargs)) # type: AsyncPollingMethod + elif polling is False: + polling_method = cast(AsyncPollingMethod, AsyncNoPolling()) + else: + polling_method = polling if cont_token: return AsyncLROPoller.from_continuation_token( polling_method=polling_method, continuation_token=cont_token, client=self._client, - deserialization_callback=get_long_running_output + deserialization_callback=get_long_running_output, ) return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) - begin_create_or_update_at_subscription_scope.metadata = {'url': "/subscriptions/{subscriptionId}/providers/Microsoft.Resources/deployments/{deploymentName}"} # type: ignore + begin_create_or_update_at_subscription_scope.metadata = {"url": "/subscriptions/{subscriptionId}/providers/Microsoft.Resources/deployments/{deploymentName}"} # type: ignore @distributed_trace_async - async def get_at_subscription_scope( - self, - deployment_name: str, - **kwargs: Any - ) -> "_models.DeploymentExtended": + async def get_at_subscription_scope(self, deployment_name: str, **kwargs: Any) -> _models.DeploymentExtended: """Gets a deployment. - :param deployment_name: The name of the deployment. + :param deployment_name: The name of the deployment. Required. :type deployment_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: DeploymentExtended, or the result of cls(response) + :return: DeploymentExtended or the result of cls(response) :rtype: ~azure.mgmt.resource.resources.v2019_10_01.models.DeploymentExtended - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.DeploymentExtended"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) - api_version = kwargs.pop('api_version', "2019-10-01") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2019-10-01")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[_models.DeploymentExtended] - request = build_deployments_get_at_subscription_scope_request( deployment_name=deployment_name, subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.get_at_subscription_scope.metadata['url'], + template_url=self.get_at_subscription_scope.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) - deserialized = self._deserialize('DeploymentExtended', pipeline_response) + deserialized = self._deserialize("DeploymentExtended", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - get_at_subscription_scope.metadata = {'url': "/subscriptions/{subscriptionId}/providers/Microsoft.Resources/deployments/{deploymentName}"} # type: ignore - + get_at_subscription_scope.metadata = {"url": "/subscriptions/{subscriptionId}/providers/Microsoft.Resources/deployments/{deploymentName}"} # type: ignore @distributed_trace_async async def cancel_at_subscription_scope( # pylint: disable=inconsistent-return-statements - self, - deployment_name: str, - **kwargs: Any + self, deployment_name: str, **kwargs: Any ) -> None: """Cancels a currently running template deployment. @@ -2744,36 +3618,42 @@ async def cancel_at_subscription_scope( # pylint: disable=inconsistent-return-s deployment stops the currently running template deployment and leaves the resources partially deployed. - :param deployment_name: The name of the deployment. + :param deployment_name: The name of the deployment. Required. :type deployment_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: None, or the result of cls(response) + :return: None or the result of cls(response) :rtype: None - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType[None] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) - api_version = kwargs.pop('api_version', "2019-10-01") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2019-10-01")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[None] - request = build_deployments_cancel_at_subscription_scope_request( deployment_name=deployment_name, subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.cancel_at_subscription_scope.metadata['url'], + template_url=self.cancel_at_subscription_scope.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [204]: @@ -2783,42 +3663,52 @@ async def cancel_at_subscription_scope( # pylint: disable=inconsistent-return-s if cls: return cls(pipeline_response, None, {}) - cancel_at_subscription_scope.metadata = {'url': "/subscriptions/{subscriptionId}/providers/Microsoft.Resources/deployments/{deploymentName}/cancel"} # type: ignore - + cancel_at_subscription_scope.metadata = {"url": "/subscriptions/{subscriptionId}/providers/Microsoft.Resources/deployments/{deploymentName}/cancel"} # type: ignore async def _validate_at_subscription_scope_initial( - self, - deployment_name: str, - parameters: "_models.Deployment", - **kwargs: Any - ) -> Optional["_models.DeploymentValidateResult"]: - cls = kwargs.pop('cls', None) # type: ClsType[Optional["_models.DeploymentValidateResult"]] + self, deployment_name: str, parameters: Union[_models.Deployment, IO], **kwargs: Any + ) -> Optional[_models.DeploymentValidateResult]: error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) - api_version = kwargs.pop('api_version', "2019-10-01") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - _json = self._serialize.body(parameters, 'Deployment') + api_version = kwargs.pop("api_version", _params.pop("api-version", "2019-10-01")) # type: str + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[Optional[_models.DeploymentValidateResult]] - request = build_deployments_validate_at_subscription_scope_request_initial( + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(parameters, (IO, bytes)): + _content = parameters + else: + _json = self._serialize.body(parameters, "Deployment") + + request = build_deployments_validate_at_subscription_scope_request( deployment_name=deployment_name, subscription_id=self._config.subscription_id, api_version=api_version, content_type=content_type, json=_json, - template_url=self._validate_at_subscription_scope_initial.metadata['url'], + content=_content, + template_url=self._validate_at_subscription_scope_initial.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200, 202, 400]: @@ -2827,33 +3717,37 @@ async def _validate_at_subscription_scope_initial( deserialized = None if response.status_code == 200: - deserialized = self._deserialize('DeploymentValidateResult', pipeline_response) + deserialized = self._deserialize("DeploymentValidateResult", pipeline_response) if response.status_code == 400: - deserialized = self._deserialize('DeploymentValidateResult', pipeline_response) + deserialized = self._deserialize("DeploymentValidateResult", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - _validate_at_subscription_scope_initial.metadata = {'url': "/subscriptions/{subscriptionId}/providers/Microsoft.Resources/deployments/{deploymentName}/validate"} # type: ignore + _validate_at_subscription_scope_initial.metadata = {"url": "/subscriptions/{subscriptionId}/providers/Microsoft.Resources/deployments/{deploymentName}/validate"} # type: ignore - - @distributed_trace_async + @overload async def begin_validate_at_subscription_scope( self, deployment_name: str, - parameters: "_models.Deployment", + parameters: _models.Deployment, + *, + content_type: str = "application/json", **kwargs: Any - ) -> AsyncLROPoller["_models.DeploymentValidateResult"]: + ) -> AsyncLROPoller[_models.DeploymentValidateResult]: """Validates whether the specified template is syntactically correct and will be accepted by Azure Resource Manager.. - :param deployment_name: The name of the deployment. + :param deployment_name: The name of the deployment. Required. :type deployment_name: str - :param parameters: Parameters to validate. + :param parameters: Parameters to validate. Required. :type parameters: ~azure.mgmt.resource.resources.v2019_10_01.models.Deployment + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str :keyword callable cls: A custom type or function that will be passed the direct response :keyword str continuation_token: A continuation token to restart a poller from a saved state. :keyword polling: By default, your polling method will be AsyncARMPolling. Pass in False for @@ -2866,83 +3760,155 @@ async def begin_validate_at_subscription_scope( result of cls(response) :rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.resource.resources.v2019_10_01.models.DeploymentValidateResult] - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - api_version = kwargs.pop('api_version', "2019-10-01") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] - polling = kwargs.pop('polling', True) # type: Union[bool, AsyncPollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType["_models.DeploymentValidateResult"] - lro_delay = kwargs.pop( - 'polling_interval', - self._config.polling_interval - ) - cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] - if cont_token is None: - raw_result = await self._validate_at_subscription_scope_initial( - deployment_name=deployment_name, - parameters=parameters, - api_version=api_version, - content_type=content_type, - cls=lambda x,y,z: x, - **kwargs - ) - kwargs.pop('error_map', None) - - def get_long_running_output(pipeline_response): - response = pipeline_response.http_response - deserialized = self._deserialize('DeploymentValidateResult', pipeline_response) - if cls: - return cls(pipeline_response, deserialized, {}) - return deserialized + @overload + async def begin_validate_at_subscription_scope( + self, deployment_name: str, parameters: IO, *, content_type: str = "application/json", **kwargs: Any + ) -> AsyncLROPoller[_models.DeploymentValidateResult]: + """Validates whether the specified template is syntactically correct and will be accepted by Azure + Resource Manager.. - if polling is True: polling_method = AsyncARMPolling(lro_delay, **kwargs) - elif polling is False: polling_method = AsyncNoPolling() - else: polling_method = polling - if cont_token: - return AsyncLROPoller.from_continuation_token( - polling_method=polling_method, - continuation_token=cont_token, - client=self._client, - deserialization_callback=get_long_running_output + :param deployment_name: The name of the deployment. Required. + :type deployment_name: str + :param parameters: Parameters to validate. Required. + :type parameters: IO + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be AsyncARMPolling. Pass in False for + this operation to not poll, or pass in your own initialized polling object for a personal + polling strategy. + :paramtype polling: bool or ~azure.core.polling.AsyncPollingMethod + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of AsyncLROPoller that returns either DeploymentValidateResult or the + result of cls(response) + :rtype: + ~azure.core.polling.AsyncLROPoller[~azure.mgmt.resource.resources.v2019_10_01.models.DeploymentValidateResult] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace_async + async def begin_validate_at_subscription_scope( + self, deployment_name: str, parameters: Union[_models.Deployment, IO], **kwargs: Any + ) -> AsyncLROPoller[_models.DeploymentValidateResult]: + """Validates whether the specified template is syntactically correct and will be accepted by Azure + Resource Manager.. + + :param deployment_name: The name of the deployment. Required. + :type deployment_name: str + :param parameters: Parameters to validate. Is either a model type or a IO type. Required. + :type parameters: ~azure.mgmt.resource.resources.v2019_10_01.models.Deployment or IO + :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. + Default value is None. + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be AsyncARMPolling. Pass in False for + this operation to not poll, or pass in your own initialized polling object for a personal + polling strategy. + :paramtype polling: bool or ~azure.core.polling.AsyncPollingMethod + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of AsyncLROPoller that returns either DeploymentValidateResult or the + result of cls(response) + :rtype: + ~azure.core.polling.AsyncLROPoller[~azure.mgmt.resource.resources.v2019_10_01.models.DeploymentValidateResult] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _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", "2019-10-01")) # type: str + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.DeploymentValidateResult] + polling = kwargs.pop("polling", True) # type: Union[bool, AsyncPollingMethod] + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token = kwargs.pop("continuation_token", None) # type: Optional[str] + if cont_token is None: + raw_result = await self._validate_at_subscription_scope_initial( # type: ignore + deployment_name=deployment_name, + parameters=parameters, + api_version=api_version, + content_type=content_type, + cls=lambda x, y, z: x, + headers=_headers, + params=_params, + **kwargs + ) + kwargs.pop("error_map", None) + + def get_long_running_output(pipeline_response): + deserialized = self._deserialize("DeploymentValidateResult", pipeline_response) + if cls: + return cls(pipeline_response, deserialized, {}) + return deserialized + + if polling is True: + polling_method = cast(AsyncPollingMethod, AsyncARMPolling(lro_delay, **kwargs)) # type: AsyncPollingMethod + elif polling is False: + polling_method = cast(AsyncPollingMethod, AsyncNoPolling()) + else: + polling_method = polling + if cont_token: + return AsyncLROPoller.from_continuation_token( + polling_method=polling_method, + continuation_token=cont_token, + client=self._client, + deserialization_callback=get_long_running_output, ) return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) - begin_validate_at_subscription_scope.metadata = {'url': "/subscriptions/{subscriptionId}/providers/Microsoft.Resources/deployments/{deploymentName}/validate"} # type: ignore + begin_validate_at_subscription_scope.metadata = {"url": "/subscriptions/{subscriptionId}/providers/Microsoft.Resources/deployments/{deploymentName}/validate"} # type: ignore async def _what_if_at_subscription_scope_initial( - self, - deployment_name: str, - parameters: "_models.DeploymentWhatIf", - **kwargs: Any - ) -> Optional["_models.WhatIfOperationResult"]: - cls = kwargs.pop('cls', None) # type: ClsType[Optional["_models.WhatIfOperationResult"]] + self, deployment_name: str, parameters: Union[_models.DeploymentWhatIf, IO], **kwargs: Any + ) -> Optional[_models.WhatIfOperationResult]: error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) - api_version = kwargs.pop('api_version', "2019-10-01") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - _json = self._serialize.body(parameters, 'DeploymentWhatIf') + api_version = kwargs.pop("api_version", _params.pop("api-version", "2019-10-01")) # type: str + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[Optional[_models.WhatIfOperationResult]] - request = build_deployments_what_if_at_subscription_scope_request_initial( + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(parameters, (IO, bytes)): + _content = parameters + else: + _json = self._serialize.body(parameters, "DeploymentWhatIf") + + request = build_deployments_what_if_at_subscription_scope_request( deployment_name=deployment_name, subscription_id=self._config.subscription_id, api_version=api_version, content_type=content_type, json=_json, - template_url=self._what_if_at_subscription_scope_initial.metadata['url'], + content=_content, + template_url=self._what_if_at_subscription_scope_initial.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200, 202]: @@ -2952,35 +3918,38 @@ async def _what_if_at_subscription_scope_initial( deserialized = None response_headers = {} if response.status_code == 200: - deserialized = self._deserialize('WhatIfOperationResult', pipeline_response) + deserialized = self._deserialize("WhatIfOperationResult", pipeline_response) if response.status_code == 202: - response_headers['Location']=self._deserialize('str', response.headers.get('Location')) - response_headers['Retry-After']=self._deserialize('str', response.headers.get('Retry-After')) - + response_headers["Location"] = self._deserialize("str", response.headers.get("Location")) + response_headers["Retry-After"] = self._deserialize("str", response.headers.get("Retry-After")) if cls: return cls(pipeline_response, deserialized, response_headers) return deserialized - _what_if_at_subscription_scope_initial.metadata = {'url': "/subscriptions/{subscriptionId}/providers/Microsoft.Resources/deployments/{deploymentName}/whatIf"} # type: ignore + _what_if_at_subscription_scope_initial.metadata = {"url": "/subscriptions/{subscriptionId}/providers/Microsoft.Resources/deployments/{deploymentName}/whatIf"} # type: ignore - - @distributed_trace_async + @overload async def begin_what_if_at_subscription_scope( self, deployment_name: str, - parameters: "_models.DeploymentWhatIf", + parameters: _models.DeploymentWhatIf, + *, + content_type: str = "application/json", **kwargs: Any - ) -> AsyncLROPoller["_models.WhatIfOperationResult"]: + ) -> AsyncLROPoller[_models.WhatIfOperationResult]: """Returns changes that will be made by the deployment if executed at the scope of the subscription. - :param deployment_name: The name of the deployment. + :param deployment_name: The name of the deployment. Required. :type deployment_name: str - :param parameters: Parameters to What If. + :param parameters: Parameters to What If. Required. :type parameters: ~azure.mgmt.resource.resources.v2019_10_01.models.DeploymentWhatIf + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str :keyword callable cls: A custom type or function that will be passed the direct response :keyword str continuation_token: A continuation token to restart a poller from a saved state. :keyword polling: By default, your polling method will be AsyncARMPolling. Pass in False for @@ -2993,111 +3962,174 @@ async def begin_what_if_at_subscription_scope( of cls(response) :rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.resource.resources.v2019_10_01.models.WhatIfOperationResult] - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - api_version = kwargs.pop('api_version', "2019-10-01") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] - polling = kwargs.pop('polling', True) # type: Union[bool, AsyncPollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType["_models.WhatIfOperationResult"] - lro_delay = kwargs.pop( - 'polling_interval', - self._config.polling_interval - ) - cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] + + @overload + async def begin_what_if_at_subscription_scope( + self, deployment_name: str, parameters: IO, *, content_type: str = "application/json", **kwargs: Any + ) -> AsyncLROPoller[_models.WhatIfOperationResult]: + """Returns changes that will be made by the deployment if executed at the scope of the + subscription. + + :param deployment_name: The name of the deployment. Required. + :type deployment_name: str + :param parameters: Parameters to What If. Required. + :type parameters: IO + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be AsyncARMPolling. Pass in False for + this operation to not poll, or pass in your own initialized polling object for a personal + polling strategy. + :paramtype polling: bool or ~azure.core.polling.AsyncPollingMethod + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of AsyncLROPoller that returns either WhatIfOperationResult or the result + of cls(response) + :rtype: + ~azure.core.polling.AsyncLROPoller[~azure.mgmt.resource.resources.v2019_10_01.models.WhatIfOperationResult] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace_async + async def begin_what_if_at_subscription_scope( + self, deployment_name: str, parameters: Union[_models.DeploymentWhatIf, IO], **kwargs: Any + ) -> AsyncLROPoller[_models.WhatIfOperationResult]: + """Returns changes that will be made by the deployment if executed at the scope of the + subscription. + + :param deployment_name: The name of the deployment. Required. + :type deployment_name: str + :param parameters: Parameters to What If. Is either a model type or a IO type. Required. + :type parameters: ~azure.mgmt.resource.resources.v2019_10_01.models.DeploymentWhatIf or IO + :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. + Default value is None. + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be AsyncARMPolling. Pass in False for + this operation to not poll, or pass in your own initialized polling object for a personal + polling strategy. + :paramtype polling: bool or ~azure.core.polling.AsyncPollingMethod + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of AsyncLROPoller that returns either WhatIfOperationResult or the result + of cls(response) + :rtype: + ~azure.core.polling.AsyncLROPoller[~azure.mgmt.resource.resources.v2019_10_01.models.WhatIfOperationResult] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _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", "2019-10-01")) # type: str + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.WhatIfOperationResult] + polling = kwargs.pop("polling", True) # type: Union[bool, AsyncPollingMethod] + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token = kwargs.pop("continuation_token", None) # type: Optional[str] if cont_token is None: - raw_result = await self._what_if_at_subscription_scope_initial( + raw_result = await self._what_if_at_subscription_scope_initial( # type: ignore deployment_name=deployment_name, parameters=parameters, api_version=api_version, content_type=content_type, - cls=lambda x,y,z: x, + cls=lambda x, y, z: x, + headers=_headers, + params=_params, **kwargs ) - kwargs.pop('error_map', None) + kwargs.pop("error_map", None) def get_long_running_output(pipeline_response): - response = pipeline_response.http_response - deserialized = self._deserialize('WhatIfOperationResult', pipeline_response) + deserialized = self._deserialize("WhatIfOperationResult", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - - if polling is True: polling_method = AsyncARMPolling(lro_delay, lro_options={'final-state-via': 'location'}, **kwargs) - elif polling is False: polling_method = AsyncNoPolling() - else: polling_method = polling + if polling is True: + polling_method = cast( + AsyncPollingMethod, AsyncARMPolling(lro_delay, lro_options={"final-state-via": "location"}, **kwargs) + ) # type: AsyncPollingMethod + elif polling is False: + polling_method = cast(AsyncPollingMethod, AsyncNoPolling()) + else: + polling_method = polling if cont_token: return AsyncLROPoller.from_continuation_token( polling_method=polling_method, continuation_token=cont_token, client=self._client, - deserialization_callback=get_long_running_output + deserialization_callback=get_long_running_output, ) return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) - begin_what_if_at_subscription_scope.metadata = {'url': "/subscriptions/{subscriptionId}/providers/Microsoft.Resources/deployments/{deploymentName}/whatIf"} # type: ignore + begin_what_if_at_subscription_scope.metadata = {"url": "/subscriptions/{subscriptionId}/providers/Microsoft.Resources/deployments/{deploymentName}/whatIf"} # type: ignore @distributed_trace_async async def export_template_at_subscription_scope( - self, - deployment_name: str, - **kwargs: Any - ) -> "_models.DeploymentExportResult": + self, deployment_name: str, **kwargs: Any + ) -> _models.DeploymentExportResult: """Exports the template used for specified deployment. - :param deployment_name: The name of the deployment. + :param deployment_name: The name of the deployment. Required. :type deployment_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: DeploymentExportResult, or the result of cls(response) + :return: DeploymentExportResult or the result of cls(response) :rtype: ~azure.mgmt.resource.resources.v2019_10_01.models.DeploymentExportResult - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.DeploymentExportResult"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) - api_version = kwargs.pop('api_version', "2019-10-01") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2019-10-01")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[_models.DeploymentExportResult] - request = build_deployments_export_template_at_subscription_scope_request( deployment_name=deployment_name, subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.export_template_at_subscription_scope.metadata['url'], + template_url=self.export_template_at_subscription_scope.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) - deserialized = self._deserialize('DeploymentExportResult', pipeline_response) + deserialized = self._deserialize("DeploymentExportResult", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - export_template_at_subscription_scope.metadata = {'url': "/subscriptions/{subscriptionId}/providers/Microsoft.Resources/deployments/{deploymentName}/exportTemplate"} # type: ignore - + export_template_at_subscription_scope.metadata = {"url": "/subscriptions/{subscriptionId}/providers/Microsoft.Resources/deployments/{deploymentName}/exportTemplate"} # type: ignore @distributed_trace def list_at_subscription_scope( - self, - filter: Optional[str] = None, - top: Optional[int] = None, - **kwargs: Any - ) -> AsyncIterable["_models.DeploymentListResult"]: + self, filter: Optional[str] = None, top: Optional[int] = None, **kwargs: Any + ) -> AsyncIterable["_models.DeploymentExtended"]: """Get all the deployments for a subscription. :param filter: The filter to apply on the operation. For example, you can use @@ -3107,40 +4139,48 @@ def list_at_subscription_scope( value is None. :type top: int :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either DeploymentListResult or the result of - cls(response) + :return: An iterator like instance of either DeploymentExtended or the result of cls(response) :rtype: - ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.resource.resources.v2019_10_01.models.DeploymentListResult] - :raises: ~azure.core.exceptions.HttpResponseError + ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.resource.resources.v2019_10_01.models.DeploymentExtended] + :raises ~azure.core.exceptions.HttpResponseError: """ - api_version = kwargs.pop('api_version', "2019-10-01") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2019-10-01")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[_models.DeploymentListResult] - cls = kwargs.pop('cls', None) # type: ClsType["_models.DeploymentListResult"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) + def prepare_request(next_link=None): if not next_link: - + request = build_deployments_list_at_subscription_scope_request( subscription_id=self._config.subscription_id, - api_version=api_version, filter=filter, top=top, - template_url=self.list_at_subscription_scope.metadata['url'], + api_version=api_version, + template_url=self.list_at_subscription_scope.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore else: - - request = build_deployments_list_at_subscription_scope_request( - subscription_id=self._config.subscription_id, - template_url=next_link, - ) + # make call to next link with the client's api-version + _parsed_next_link = urlparse(next_link) + _next_request_params = case_insensitive_dict(parse_qs(_parsed_next_link.query)) + _next_request_params["api-version"] = self._config.api_version + request = HttpRequest("GET", urljoin(next_link, _parsed_next_link.path), params=_next_request_params) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore request.method = "GET" return request @@ -3154,10 +4194,8 @@ async def extract_data(pipeline_response): async def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) response = pipeline_response.http_response @@ -3167,42 +4205,43 @@ async def get_next(next_link=None): return pipeline_response + return AsyncItemPaged(get_next, extract_data) - return AsyncItemPaged( - get_next, extract_data - ) - list_at_subscription_scope.metadata = {'url': "/subscriptions/{subscriptionId}/providers/Microsoft.Resources/deployments/"} # type: ignore + list_at_subscription_scope.metadata = {"url": "/subscriptions/{subscriptionId}/providers/Microsoft.Resources/deployments/"} # type: ignore async def _delete_initial( # pylint: disable=inconsistent-return-statements - self, - resource_group_name: str, - deployment_name: str, - **kwargs: Any + self, resource_group_name: str, deployment_name: str, **kwargs: Any ) -> None: - cls = kwargs.pop('cls', None) # type: ClsType[None] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) - api_version = kwargs.pop('api_version', "2019-10-01") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - request = build_deployments_delete_request_initial( + api_version = kwargs.pop("api_version", _params.pop("api-version", "2019-10-01")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[None] + + request = build_deployments_delete_request( resource_group_name=resource_group_name, deployment_name=deployment_name, subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self._delete_initial.metadata['url'], + template_url=self._delete_initial.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [202, 204]: @@ -3212,16 +4251,10 @@ 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.Resources/deployments/{deploymentName}"} # type: ignore - + _delete_initial.metadata = {"url": "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/Microsoft.Resources/deployments/{deploymentName}"} # type: ignore @distributed_trace_async - async def begin_delete( # pylint: disable=inconsistent-return-statements - self, - resource_group_name: str, - deployment_name: str, - **kwargs: Any - ) -> AsyncLROPoller[None]: + async def begin_delete(self, resource_group_name: str, deployment_name: str, **kwargs: Any) -> AsyncLROPoller[None]: """Deletes a deployment from the deployment history. A template deployment that is currently running cannot be deleted. Deleting a template @@ -3234,9 +4267,9 @@ async def begin_delete( # pylint: disable=inconsistent-return-statements asynchronous request failed, the URI in the Location header returns an error-level status code. :param resource_group_name: The name of the resource group with the deployment to delete. The - name is case insensitive. + name is case insensitive. Required. :type resource_group_name: str - :param deployment_name: The name of the deployment. + :param deployment_name: The name of the deployment. Required. :type deployment_name: str :keyword callable cls: A custom type or function that will be passed the direct response :keyword str continuation_token: A continuation token to restart a poller from a saved state. @@ -3248,88 +4281,93 @@ async def begin_delete( # pylint: disable=inconsistent-return-statements Retry-After header is present. :return: An instance of AsyncLROPoller that returns either None or the result of cls(response) :rtype: ~azure.core.polling.AsyncLROPoller[None] - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - api_version = kwargs.pop('api_version', "2019-10-01") # type: str - polling = kwargs.pop('polling', True) # type: Union[bool, AsyncPollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType[None] - lro_delay = kwargs.pop( - 'polling_interval', - self._config.polling_interval - ) - cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2019-10-01")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[None] + polling = kwargs.pop("polling", True) # type: Union[bool, AsyncPollingMethod] + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token = kwargs.pop("continuation_token", None) # type: Optional[str] if cont_token is None: - raw_result = await self._delete_initial( + raw_result = await self._delete_initial( # type: ignore resource_group_name=resource_group_name, deployment_name=deployment_name, api_version=api_version, - cls=lambda x,y,z: x, + cls=lambda x, y, z: x, + headers=_headers, + params=_params, **kwargs ) - kwargs.pop('error_map', None) + kwargs.pop("error_map", None) - def get_long_running_output(pipeline_response): + def get_long_running_output(pipeline_response): # pylint: disable=inconsistent-return-statements if cls: return cls(pipeline_response, None, {}) - - if polling is True: polling_method = AsyncARMPolling(lro_delay, **kwargs) - elif polling is False: polling_method = AsyncNoPolling() - else: polling_method = polling + if polling is True: + polling_method = cast(AsyncPollingMethod, AsyncARMPolling(lro_delay, **kwargs)) # type: AsyncPollingMethod + elif polling is False: + polling_method = cast(AsyncPollingMethod, AsyncNoPolling()) + else: + polling_method = polling if cont_token: return AsyncLROPoller.from_continuation_token( polling_method=polling_method, continuation_token=cont_token, client=self._client, - deserialization_callback=get_long_running_output + deserialization_callback=get_long_running_output, ) return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) - begin_delete.metadata = {'url': "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/Microsoft.Resources/deployments/{deploymentName}"} # type: ignore + begin_delete.metadata = {"url": "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/Microsoft.Resources/deployments/{deploymentName}"} # type: ignore @distributed_trace_async - async def check_existence( - self, - resource_group_name: str, - deployment_name: str, - **kwargs: Any - ) -> bool: + async def check_existence(self, resource_group_name: str, deployment_name: str, **kwargs: Any) -> bool: """Checks whether the deployment exists. :param resource_group_name: The name of the resource group with the deployment to check. The - name is case insensitive. + name is case insensitive. Required. :type resource_group_name: str - :param deployment_name: The name of the deployment. + :param deployment_name: The name of the deployment. Required. :type deployment_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: bool, or the result of cls(response) + :return: bool or the result of cls(response) :rtype: bool - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType[None] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + 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', "2019-10-01") # type: str + api_version = kwargs.pop("api_version", _params.pop("api-version", "2019-10-01")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[None] - request = build_deployments_check_existence_request( resource_group_name=resource_group_name, deployment_name=deployment_name, subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.check_existence.metadata['url'], + template_url=self.check_existence.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [204, 404]: @@ -3340,44 +4378,53 @@ async def check_existence( return cls(pipeline_response, None, {}) return 200 <= response.status_code <= 299 - check_existence.metadata = {'url': "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/Microsoft.Resources/deployments/{deploymentName}"} # type: ignore - + check_existence.metadata = {"url": "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/Microsoft.Resources/deployments/{deploymentName}"} # type: ignore async def _create_or_update_initial( - self, - resource_group_name: str, - deployment_name: str, - parameters: "_models.Deployment", - **kwargs: Any - ) -> "_models.DeploymentExtended": - cls = kwargs.pop('cls', None) # type: ClsType["_models.DeploymentExtended"] + self, resource_group_name: str, deployment_name: str, parameters: Union[_models.Deployment, IO], **kwargs: Any + ) -> _models.DeploymentExtended: error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) - api_version = kwargs.pop('api_version', "2019-10-01") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - _json = self._serialize.body(parameters, 'Deployment') + api_version = kwargs.pop("api_version", _params.pop("api-version", "2019-10-01")) # type: str + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.DeploymentExtended] - request = build_deployments_create_or_update_request_initial( + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(parameters, (IO, bytes)): + _content = parameters + else: + _json = self._serialize.body(parameters, "Deployment") + + request = build_deployments_create_or_update_request( resource_group_name=resource_group_name, deployment_name=deployment_name, subscription_id=self._config.subscription_id, api_version=api_version, content_type=content_type, json=_json, - template_url=self._create_or_update_initial.metadata['url'], + content=_content, + template_url=self._create_or_update_initial.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200, 201]: @@ -3385,38 +4432,42 @@ async def _create_or_update_initial( raise HttpResponseError(response=response, error_format=ARMErrorFormat) if response.status_code == 200: - deserialized = self._deserialize('DeploymentExtended', pipeline_response) + deserialized = self._deserialize("DeploymentExtended", pipeline_response) if response.status_code == 201: - deserialized = self._deserialize('DeploymentExtended', pipeline_response) + deserialized = self._deserialize("DeploymentExtended", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - _create_or_update_initial.metadata = {'url': "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/Microsoft.Resources/deployments/{deploymentName}"} # type: ignore + _create_or_update_initial.metadata = {"url": "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/Microsoft.Resources/deployments/{deploymentName}"} # type: ignore - - @distributed_trace_async + @overload async def begin_create_or_update( self, resource_group_name: str, deployment_name: str, - parameters: "_models.Deployment", + parameters: _models.Deployment, + *, + content_type: str = "application/json", **kwargs: Any - ) -> AsyncLROPoller["_models.DeploymentExtended"]: + ) -> AsyncLROPoller[_models.DeploymentExtended]: """Deploys resources to a resource group. You can provide the template and parameters directly in the request or link to JSON files. :param resource_group_name: The name of the resource group to deploy the resources to. The name - is case insensitive. The resource group must already exist. + is case insensitive. The resource group must already exist. Required. :type resource_group_name: str - :param deployment_name: The name of the deployment. + :param deployment_name: The name of the deployment. Required. :type deployment_name: str - :param parameters: Additional parameters supplied to the operation. + :param parameters: Additional parameters supplied to the operation. Required. :type parameters: ~azure.mgmt.resource.resources.v2019_10_01.models.Deployment + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str :keyword callable cls: A custom type or function that will be passed the direct response :keyword str continuation_token: A continuation token to restart a poller from a saved state. :keyword polling: By default, your polling method will be AsyncARMPolling. Pass in False for @@ -3429,115 +4480,189 @@ async def begin_create_or_update( cls(response) :rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.resource.resources.v2019_10_01.models.DeploymentExtended] - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - api_version = kwargs.pop('api_version', "2019-10-01") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] - polling = kwargs.pop('polling', True) # type: Union[bool, AsyncPollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType["_models.DeploymentExtended"] - lro_delay = kwargs.pop( - 'polling_interval', - self._config.polling_interval - ) - cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] + + @overload + async def begin_create_or_update( + self, + resource_group_name: str, + deployment_name: str, + parameters: IO, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> AsyncLROPoller[_models.DeploymentExtended]: + """Deploys resources to a resource group. + + You can provide the template and parameters directly in the request or link to JSON files. + + :param resource_group_name: The name of the resource group to deploy the resources to. The name + is case insensitive. The resource group must already exist. Required. + :type resource_group_name: str + :param deployment_name: The name of the deployment. Required. + :type deployment_name: str + :param parameters: Additional parameters supplied to the operation. Required. + :type parameters: IO + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be AsyncARMPolling. Pass in False for + this operation to not poll, or pass in your own initialized polling object for a personal + polling strategy. + :paramtype polling: bool or ~azure.core.polling.AsyncPollingMethod + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of AsyncLROPoller that returns either DeploymentExtended or the result of + cls(response) + :rtype: + ~azure.core.polling.AsyncLROPoller[~azure.mgmt.resource.resources.v2019_10_01.models.DeploymentExtended] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace_async + async def begin_create_or_update( + self, resource_group_name: str, deployment_name: str, parameters: Union[_models.Deployment, IO], **kwargs: Any + ) -> AsyncLROPoller[_models.DeploymentExtended]: + """Deploys resources to a resource group. + + You can provide the template and parameters directly in the request or link to JSON files. + + :param resource_group_name: The name of the resource group to deploy the resources to. The name + is case insensitive. The resource group must already exist. Required. + :type resource_group_name: str + :param deployment_name: The name of the deployment. Required. + :type deployment_name: str + :param parameters: Additional parameters supplied to the operation. Is either a model type or a + IO type. Required. + :type parameters: ~azure.mgmt.resource.resources.v2019_10_01.models.Deployment or IO + :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. + Default value is None. + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be AsyncARMPolling. Pass in False for + this operation to not poll, or pass in your own initialized polling object for a personal + polling strategy. + :paramtype polling: bool or ~azure.core.polling.AsyncPollingMethod + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of AsyncLROPoller that returns either DeploymentExtended or the result of + cls(response) + :rtype: + ~azure.core.polling.AsyncLROPoller[~azure.mgmt.resource.resources.v2019_10_01.models.DeploymentExtended] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _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", "2019-10-01")) # type: str + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.DeploymentExtended] + polling = kwargs.pop("polling", True) # type: Union[bool, AsyncPollingMethod] + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token = kwargs.pop("continuation_token", None) # type: Optional[str] if cont_token is None: - raw_result = await self._create_or_update_initial( + raw_result = await self._create_or_update_initial( # type: ignore resource_group_name=resource_group_name, deployment_name=deployment_name, parameters=parameters, api_version=api_version, content_type=content_type, - cls=lambda x,y,z: x, + cls=lambda x, y, z: x, + headers=_headers, + params=_params, **kwargs ) - kwargs.pop('error_map', None) + kwargs.pop("error_map", None) def get_long_running_output(pipeline_response): - response = pipeline_response.http_response - deserialized = self._deserialize('DeploymentExtended', pipeline_response) + deserialized = self._deserialize("DeploymentExtended", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - - if polling is True: polling_method = AsyncARMPolling(lro_delay, **kwargs) - elif polling is False: polling_method = AsyncNoPolling() - else: polling_method = polling + if polling is True: + polling_method = cast(AsyncPollingMethod, AsyncARMPolling(lro_delay, **kwargs)) # type: AsyncPollingMethod + elif polling is False: + polling_method = cast(AsyncPollingMethod, AsyncNoPolling()) + else: + polling_method = polling if cont_token: return AsyncLROPoller.from_continuation_token( polling_method=polling_method, continuation_token=cont_token, client=self._client, - deserialization_callback=get_long_running_output + deserialization_callback=get_long_running_output, ) return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) - begin_create_or_update.metadata = {'url': "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/Microsoft.Resources/deployments/{deploymentName}"} # type: ignore + begin_create_or_update.metadata = {"url": "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/Microsoft.Resources/deployments/{deploymentName}"} # type: ignore @distributed_trace_async - async def get( - self, - resource_group_name: str, - deployment_name: str, - **kwargs: Any - ) -> "_models.DeploymentExtended": + async def get(self, resource_group_name: str, deployment_name: str, **kwargs: Any) -> _models.DeploymentExtended: """Gets a deployment. :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. :type resource_group_name: str - :param deployment_name: The name of the deployment. + :param deployment_name: The name of the deployment. Required. :type deployment_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: DeploymentExtended, or the result of cls(response) + :return: DeploymentExtended or the result of cls(response) :rtype: ~azure.mgmt.resource.resources.v2019_10_01.models.DeploymentExtended - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.DeploymentExtended"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) - api_version = kwargs.pop('api_version', "2019-10-01") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2019-10-01")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[_models.DeploymentExtended] - request = build_deployments_get_request( resource_group_name=resource_group_name, deployment_name=deployment_name, subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.get.metadata['url'], + template_url=self.get.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) - deserialized = self._deserialize('DeploymentExtended', pipeline_response) + deserialized = self._deserialize("DeploymentExtended", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - get.metadata = {'url': "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/Microsoft.Resources/deployments/{deploymentName}"} # type: ignore - + get.metadata = {"url": "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/Microsoft.Resources/deployments/{deploymentName}"} # type: ignore @distributed_trace_async async def cancel( # pylint: disable=inconsistent-return-statements - self, - resource_group_name: str, - deployment_name: str, - **kwargs: Any + self, resource_group_name: str, deployment_name: str, **kwargs: Any ) -> None: """Cancels a currently running template deployment. @@ -3547,38 +4672,45 @@ async def cancel( # pylint: disable=inconsistent-return-statements partially deployed. :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. :type resource_group_name: str - :param deployment_name: The name of the deployment. + :param deployment_name: The name of the deployment. Required. :type deployment_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: None, or the result of cls(response) + :return: None or the result of cls(response) :rtype: None - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType[None] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + 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', "2019-10-01") # type: str + api_version = kwargs.pop("api_version", _params.pop("api-version", "2019-10-01")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[None] - request = build_deployments_cancel_request( resource_group_name=resource_group_name, deployment_name=deployment_name, subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.cancel.metadata['url'], + template_url=self.cancel.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [204]: @@ -3588,44 +4720,53 @@ async def cancel( # pylint: disable=inconsistent-return-statements if cls: return cls(pipeline_response, None, {}) - cancel.metadata = {'url': "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/Microsoft.Resources/deployments/{deploymentName}/cancel"} # type: ignore - + cancel.metadata = {"url": "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/Microsoft.Resources/deployments/{deploymentName}/cancel"} # type: ignore async def _validate_initial( - self, - resource_group_name: str, - deployment_name: str, - parameters: "_models.Deployment", - **kwargs: Any - ) -> Optional["_models.DeploymentValidateResult"]: - cls = kwargs.pop('cls', None) # type: ClsType[Optional["_models.DeploymentValidateResult"]] + self, resource_group_name: str, deployment_name: str, parameters: Union[_models.Deployment, IO], **kwargs: Any + ) -> Optional[_models.DeploymentValidateResult]: error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) - api_version = kwargs.pop('api_version', "2019-10-01") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - _json = self._serialize.body(parameters, 'Deployment') + api_version = kwargs.pop("api_version", _params.pop("api-version", "2019-10-01")) # type: str + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[Optional[_models.DeploymentValidateResult]] - request = build_deployments_validate_request_initial( + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(parameters, (IO, bytes)): + _content = parameters + else: + _json = self._serialize.body(parameters, "Deployment") + + request = build_deployments_validate_request( resource_group_name=resource_group_name, deployment_name=deployment_name, subscription_id=self._config.subscription_id, api_version=api_version, content_type=content_type, json=_json, - template_url=self._validate_initial.metadata['url'], + content=_content, + template_url=self._validate_initial.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200, 202, 400]: @@ -3634,37 +4775,41 @@ async def _validate_initial( deserialized = None if response.status_code == 200: - deserialized = self._deserialize('DeploymentValidateResult', pipeline_response) + deserialized = self._deserialize("DeploymentValidateResult", pipeline_response) if response.status_code == 400: - deserialized = self._deserialize('DeploymentValidateResult', pipeline_response) + deserialized = self._deserialize("DeploymentValidateResult", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - _validate_initial.metadata = {'url': "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/Microsoft.Resources/deployments/{deploymentName}/validate"} # type: ignore + _validate_initial.metadata = {"url": "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/Microsoft.Resources/deployments/{deploymentName}/validate"} # type: ignore - - @distributed_trace_async + @overload async def begin_validate( self, resource_group_name: str, deployment_name: str, - parameters: "_models.Deployment", + parameters: _models.Deployment, + *, + content_type: str = "application/json", **kwargs: Any - ) -> AsyncLROPoller["_models.DeploymentValidateResult"]: + ) -> AsyncLROPoller[_models.DeploymentValidateResult]: """Validates whether the specified template is syntactically correct and will be accepted by Azure Resource Manager.. :param resource_group_name: The name of the resource group the template will be deployed to. - The name is case insensitive. + The name is case insensitive. Required. :type resource_group_name: str - :param deployment_name: The name of the deployment. + :param deployment_name: The name of the deployment. Required. :type deployment_name: str - :param parameters: Parameters to validate. + :param parameters: Parameters to validate. Required. :type parameters: ~azure.mgmt.resource.resources.v2019_10_01.models.Deployment + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str :keyword callable cls: A custom type or function that will be passed the direct response :keyword str continuation_token: A continuation token to restart a poller from a saved state. :keyword polling: By default, your polling method will be AsyncARMPolling. Pass in False for @@ -3677,86 +4822,173 @@ async def begin_validate( result of cls(response) :rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.resource.resources.v2019_10_01.models.DeploymentValidateResult] - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - api_version = kwargs.pop('api_version', "2019-10-01") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] - polling = kwargs.pop('polling', True) # type: Union[bool, AsyncPollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType["_models.DeploymentValidateResult"] - lro_delay = kwargs.pop( - 'polling_interval', - self._config.polling_interval - ) - cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] - if cont_token is None: - raw_result = await self._validate_initial( - resource_group_name=resource_group_name, - deployment_name=deployment_name, - parameters=parameters, - api_version=api_version, - content_type=content_type, - cls=lambda x,y,z: x, - **kwargs - ) - kwargs.pop('error_map', None) - - def get_long_running_output(pipeline_response): - response = pipeline_response.http_response - deserialized = self._deserialize('DeploymentValidateResult', pipeline_response) - if cls: - return cls(pipeline_response, deserialized, {}) - return deserialized + @overload + async def begin_validate( + self, + resource_group_name: str, + deployment_name: str, + parameters: IO, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> AsyncLROPoller[_models.DeploymentValidateResult]: + """Validates whether the specified template is syntactically correct and will be accepted by Azure + Resource Manager.. - if polling is True: polling_method = AsyncARMPolling(lro_delay, **kwargs) - elif polling is False: polling_method = AsyncNoPolling() - else: polling_method = polling - if cont_token: - return AsyncLROPoller.from_continuation_token( + :param resource_group_name: The name of the resource group the template will be deployed to. + The name is case insensitive. Required. + :type resource_group_name: str + :param deployment_name: The name of the deployment. Required. + :type deployment_name: str + :param parameters: Parameters to validate. Required. + :type parameters: IO + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be AsyncARMPolling. Pass in False for + this operation to not poll, or pass in your own initialized polling object for a personal + polling strategy. + :paramtype polling: bool or ~azure.core.polling.AsyncPollingMethod + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of AsyncLROPoller that returns either DeploymentValidateResult or the + result of cls(response) + :rtype: + ~azure.core.polling.AsyncLROPoller[~azure.mgmt.resource.resources.v2019_10_01.models.DeploymentValidateResult] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace_async + async def begin_validate( + self, resource_group_name: str, deployment_name: str, parameters: Union[_models.Deployment, IO], **kwargs: Any + ) -> AsyncLROPoller[_models.DeploymentValidateResult]: + """Validates whether the specified template is syntactically correct and will be accepted by Azure + Resource Manager.. + + :param resource_group_name: The name of the resource group the template will be deployed to. + The name is case insensitive. Required. + :type resource_group_name: str + :param deployment_name: The name of the deployment. Required. + :type deployment_name: str + :param parameters: Parameters to validate. Is either a model type or a IO type. Required. + :type parameters: ~azure.mgmt.resource.resources.v2019_10_01.models.Deployment or IO + :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. + Default value is None. + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be AsyncARMPolling. Pass in False for + this operation to not poll, or pass in your own initialized polling object for a personal + polling strategy. + :paramtype polling: bool or ~azure.core.polling.AsyncPollingMethod + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of AsyncLROPoller that returns either DeploymentValidateResult or the + result of cls(response) + :rtype: + ~azure.core.polling.AsyncLROPoller[~azure.mgmt.resource.resources.v2019_10_01.models.DeploymentValidateResult] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _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", "2019-10-01")) # type: str + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.DeploymentValidateResult] + polling = kwargs.pop("polling", True) # type: Union[bool, AsyncPollingMethod] + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token = kwargs.pop("continuation_token", None) # type: Optional[str] + if cont_token is None: + raw_result = await self._validate_initial( # type: ignore + resource_group_name=resource_group_name, + deployment_name=deployment_name, + parameters=parameters, + api_version=api_version, + content_type=content_type, + cls=lambda x, y, z: x, + headers=_headers, + params=_params, + **kwargs + ) + kwargs.pop("error_map", None) + + def get_long_running_output(pipeline_response): + deserialized = self._deserialize("DeploymentValidateResult", pipeline_response) + if cls: + return cls(pipeline_response, deserialized, {}) + return deserialized + + if polling is True: + polling_method = cast(AsyncPollingMethod, AsyncARMPolling(lro_delay, **kwargs)) # type: AsyncPollingMethod + elif polling is False: + polling_method = cast(AsyncPollingMethod, AsyncNoPolling()) + else: + polling_method = polling + if cont_token: + return AsyncLROPoller.from_continuation_token( polling_method=polling_method, continuation_token=cont_token, client=self._client, - deserialization_callback=get_long_running_output + deserialization_callback=get_long_running_output, ) return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) - begin_validate.metadata = {'url': "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/Microsoft.Resources/deployments/{deploymentName}/validate"} # type: ignore + begin_validate.metadata = {"url": "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/Microsoft.Resources/deployments/{deploymentName}/validate"} # type: ignore async def _what_if_initial( self, resource_group_name: str, deployment_name: str, - parameters: "_models.DeploymentWhatIf", + parameters: Union[_models.DeploymentWhatIf, IO], **kwargs: Any - ) -> Optional["_models.WhatIfOperationResult"]: - cls = kwargs.pop('cls', None) # type: ClsType[Optional["_models.WhatIfOperationResult"]] + ) -> Optional[_models.WhatIfOperationResult]: error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', "2019-10-01") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + api_version = kwargs.pop("api_version", _params.pop("api-version", "2019-10-01")) # type: str + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[Optional[_models.WhatIfOperationResult]] - _json = self._serialize.body(parameters, 'DeploymentWhatIf') + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(parameters, (IO, bytes)): + _content = parameters + else: + _json = self._serialize.body(parameters, "DeploymentWhatIf") - request = build_deployments_what_if_request_initial( + request = build_deployments_what_if_request( resource_group_name=resource_group_name, deployment_name=deployment_name, subscription_id=self._config.subscription_id, api_version=api_version, content_type=content_type, json=_json, - template_url=self._what_if_initial.metadata['url'], + content=_content, + template_url=self._what_if_initial.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200, 202]: @@ -3766,39 +4998,116 @@ async def _what_if_initial( deserialized = None response_headers = {} if response.status_code == 200: - deserialized = self._deserialize('WhatIfOperationResult', pipeline_response) + deserialized = self._deserialize("WhatIfOperationResult", pipeline_response) if response.status_code == 202: - response_headers['Location']=self._deserialize('str', response.headers.get('Location')) - response_headers['Retry-After']=self._deserialize('str', response.headers.get('Retry-After')) - + response_headers["Location"] = self._deserialize("str", response.headers.get("Location")) + response_headers["Retry-After"] = self._deserialize("str", response.headers.get("Retry-After")) if cls: return cls(pipeline_response, deserialized, response_headers) return deserialized - _what_if_initial.metadata = {'url': "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/Microsoft.Resources/deployments/{deploymentName}/whatIf"} # type: ignore + _what_if_initial.metadata = {"url": "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/Microsoft.Resources/deployments/{deploymentName}/whatIf"} # type: ignore + + @overload + async def begin_what_if( + self, + resource_group_name: str, + deployment_name: str, + parameters: _models.DeploymentWhatIf, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> AsyncLROPoller[_models.WhatIfOperationResult]: + """Returns changes that will be made by the deployment if executed at the scope of the resource + group. + + :param resource_group_name: The name of the resource group the template will be deployed to. + The name is case insensitive. Required. + :type resource_group_name: str + :param deployment_name: The name of the deployment. Required. + :type deployment_name: str + :param parameters: Parameters to validate. Required. + :type parameters: ~azure.mgmt.resource.resources.v2019_10_01.models.DeploymentWhatIf + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be AsyncARMPolling. Pass in False for + this operation to not poll, or pass in your own initialized polling object for a personal + polling strategy. + :paramtype polling: bool or ~azure.core.polling.AsyncPollingMethod + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of AsyncLROPoller that returns either WhatIfOperationResult or the result + of cls(response) + :rtype: + ~azure.core.polling.AsyncLROPoller[~azure.mgmt.resource.resources.v2019_10_01.models.WhatIfOperationResult] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + async def begin_what_if( + self, + resource_group_name: str, + deployment_name: str, + parameters: IO, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> AsyncLROPoller[_models.WhatIfOperationResult]: + """Returns changes that will be made by the deployment if executed at the scope of the resource + group. + :param resource_group_name: The name of the resource group the template will be deployed to. + The name is case insensitive. Required. + :type resource_group_name: str + :param deployment_name: The name of the deployment. Required. + :type deployment_name: str + :param parameters: Parameters to validate. Required. + :type parameters: IO + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be AsyncARMPolling. Pass in False for + this operation to not poll, or pass in your own initialized polling object for a personal + polling strategy. + :paramtype polling: bool or ~azure.core.polling.AsyncPollingMethod + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of AsyncLROPoller that returns either WhatIfOperationResult or the result + of cls(response) + :rtype: + ~azure.core.polling.AsyncLROPoller[~azure.mgmt.resource.resources.v2019_10_01.models.WhatIfOperationResult] + :raises ~azure.core.exceptions.HttpResponseError: + """ @distributed_trace_async async def begin_what_if( self, resource_group_name: str, deployment_name: str, - parameters: "_models.DeploymentWhatIf", + parameters: Union[_models.DeploymentWhatIf, IO], **kwargs: Any - ) -> AsyncLROPoller["_models.WhatIfOperationResult"]: + ) -> AsyncLROPoller[_models.WhatIfOperationResult]: """Returns changes that will be made by the deployment if executed at the scope of the resource group. :param resource_group_name: The name of the resource group the template will be deployed to. - The name is case insensitive. + The name is case insensitive. Required. :type resource_group_name: str - :param deployment_name: The name of the deployment. + :param deployment_name: The name of the deployment. Required. :type deployment_name: str - :param parameters: Parameters to validate. - :type parameters: ~azure.mgmt.resource.resources.v2019_10_01.models.DeploymentWhatIf + :param parameters: Parameters to validate. Is either a model type or a IO type. Required. + :type parameters: ~azure.mgmt.resource.resources.v2019_10_01.models.DeploymentWhatIf or IO + :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. + Default value is None. + :paramtype content_type: str :keyword callable cls: A custom type or function that will be passed the direct response :keyword str continuation_token: A continuation token to restart a poller from a saved state. :keyword polling: By default, your polling method will be AsyncARMPolling. Pass in False for @@ -3811,121 +5120,125 @@ async def begin_what_if( of cls(response) :rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.resource.resources.v2019_10_01.models.WhatIfOperationResult] - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - api_version = kwargs.pop('api_version', "2019-10-01") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] - polling = kwargs.pop('polling', True) # type: Union[bool, AsyncPollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType["_models.WhatIfOperationResult"] - lro_delay = kwargs.pop( - 'polling_interval', - self._config.polling_interval - ) - cont_token = kwargs.pop('continuation_token', None) # type: Optional[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", "2019-10-01")) # type: str + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.WhatIfOperationResult] + polling = kwargs.pop("polling", True) # type: Union[bool, AsyncPollingMethod] + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token = kwargs.pop("continuation_token", None) # type: Optional[str] if cont_token is None: - raw_result = await self._what_if_initial( + raw_result = await self._what_if_initial( # type: ignore resource_group_name=resource_group_name, deployment_name=deployment_name, parameters=parameters, api_version=api_version, content_type=content_type, - cls=lambda x,y,z: x, + cls=lambda x, y, z: x, + headers=_headers, + params=_params, **kwargs ) - kwargs.pop('error_map', None) + kwargs.pop("error_map", None) def get_long_running_output(pipeline_response): - response = pipeline_response.http_response - deserialized = self._deserialize('WhatIfOperationResult', pipeline_response) + deserialized = self._deserialize("WhatIfOperationResult", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - - if polling is True: polling_method = AsyncARMPolling(lro_delay, lro_options={'final-state-via': 'location'}, **kwargs) - elif polling is False: polling_method = AsyncNoPolling() - else: polling_method = polling + if polling is True: + polling_method = cast( + AsyncPollingMethod, AsyncARMPolling(lro_delay, lro_options={"final-state-via": "location"}, **kwargs) + ) # type: AsyncPollingMethod + elif polling is False: + polling_method = cast(AsyncPollingMethod, AsyncNoPolling()) + else: + polling_method = polling if cont_token: return AsyncLROPoller.from_continuation_token( polling_method=polling_method, continuation_token=cont_token, client=self._client, - deserialization_callback=get_long_running_output + deserialization_callback=get_long_running_output, ) return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) - begin_what_if.metadata = {'url': "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/Microsoft.Resources/deployments/{deploymentName}/whatIf"} # type: ignore + begin_what_if.metadata = {"url": "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/Microsoft.Resources/deployments/{deploymentName}/whatIf"} # type: ignore @distributed_trace_async async def export_template( - self, - resource_group_name: str, - deployment_name: str, - **kwargs: Any - ) -> "_models.DeploymentExportResult": + self, resource_group_name: str, deployment_name: str, **kwargs: Any + ) -> _models.DeploymentExportResult: """Exports the template used for specified deployment. :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. :type resource_group_name: str - :param deployment_name: The name of the deployment. + :param deployment_name: The name of the deployment. Required. :type deployment_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: DeploymentExportResult, or the result of cls(response) + :return: DeploymentExportResult or the result of cls(response) :rtype: ~azure.mgmt.resource.resources.v2019_10_01.models.DeploymentExportResult - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.DeploymentExportResult"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) - api_version = kwargs.pop('api_version', "2019-10-01") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2019-10-01")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[_models.DeploymentExportResult] - request = build_deployments_export_template_request( resource_group_name=resource_group_name, deployment_name=deployment_name, subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.export_template.metadata['url'], + template_url=self.export_template.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) - deserialized = self._deserialize('DeploymentExportResult', pipeline_response) + deserialized = self._deserialize("DeploymentExportResult", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - export_template.metadata = {'url': "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/Microsoft.Resources/deployments/{deploymentName}/exportTemplate"} # type: ignore - + export_template.metadata = {"url": "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/Microsoft.Resources/deployments/{deploymentName}/exportTemplate"} # type: ignore @distributed_trace def list_by_resource_group( - self, - resource_group_name: str, - filter: Optional[str] = None, - top: Optional[int] = None, - **kwargs: Any - ) -> AsyncIterable["_models.DeploymentListResult"]: + self, resource_group_name: str, filter: Optional[str] = None, top: Optional[int] = None, **kwargs: Any + ) -> AsyncIterable["_models.DeploymentExtended"]: """Get all the deployments for a resource group. :param resource_group_name: The name of the resource group with the deployments to get. The - name is case insensitive. + name is case insensitive. Required. :type resource_group_name: str :param filter: The filter to apply on the operation. For example, you can use $filter=provisioningState eq '{state}'. Default value is None. @@ -3934,42 +5247,49 @@ def list_by_resource_group( value is None. :type top: int :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either DeploymentListResult or the result of - cls(response) + :return: An iterator like instance of either DeploymentExtended or the result of cls(response) :rtype: - ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.resource.resources.v2019_10_01.models.DeploymentListResult] - :raises: ~azure.core.exceptions.HttpResponseError + ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.resource.resources.v2019_10_01.models.DeploymentExtended] + :raises ~azure.core.exceptions.HttpResponseError: """ - api_version = kwargs.pop('api_version', "2019-10-01") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2019-10-01")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[_models.DeploymentListResult] - cls = kwargs.pop('cls', None) # type: ClsType["_models.DeploymentListResult"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) + def prepare_request(next_link=None): if not next_link: - + request = build_deployments_list_by_resource_group_request( resource_group_name=resource_group_name, subscription_id=self._config.subscription_id, - api_version=api_version, filter=filter, top=top, - template_url=self.list_by_resource_group.metadata['url'], + 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.url = self._client.format_url(request.url) # type: ignore else: - - request = build_deployments_list_by_resource_group_request( - resource_group_name=resource_group_name, - subscription_id=self._config.subscription_id, - template_url=next_link, - ) + # make call to next link with the client's api-version + _parsed_next_link = urlparse(next_link) + _next_request_params = case_insensitive_dict(parse_qs(_parsed_next_link.query)) + _next_request_params["api-version"] = self._config.api_version + request = HttpRequest("GET", urljoin(next_link, _parsed_next_link.path), params=_next_request_params) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore request.method = "GET" return request @@ -3983,10 +5303,8 @@ async def extract_data(pipeline_response): async def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) response = pipeline_response.http_response @@ -3996,204 +5314,204 @@ async def get_next(next_link=None): return pipeline_response + return AsyncItemPaged(get_next, extract_data) - return AsyncItemPaged( - get_next, extract_data - ) - list_by_resource_group.metadata = {'url': "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/Microsoft.Resources/deployments/"} # type: ignore + list_by_resource_group.metadata = {"url": "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/Microsoft.Resources/deployments/"} # type: ignore @distributed_trace_async - async def calculate_template_hash( - self, - template: Any, - **kwargs: Any - ) -> "_models.TemplateHashResult": + async def calculate_template_hash(self, template: JSON, **kwargs: Any) -> _models.TemplateHashResult: """Calculate the hash of the given template. - :param template: The template provided to calculate hash. - :type template: any + :param template: The template provided to calculate hash. Required. + :type template: JSON :keyword callable cls: A custom type or function that will be passed the direct response - :return: TemplateHashResult, or the result of cls(response) + :return: TemplateHashResult or the result of cls(response) :rtype: ~azure.mgmt.resource.resources.v2019_10_01.models.TemplateHashResult - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.TemplateHashResult"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) - api_version = kwargs.pop('api_version', "2019-10-01") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - _json = self._serialize.body(template, 'object') + api_version = kwargs.pop("api_version", _params.pop("api-version", "2019-10-01")) # type: str + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", "application/json")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[_models.TemplateHashResult] + + _json = self._serialize.body(template, "object") request = build_deployments_calculate_template_hash_request( api_version=api_version, content_type=content_type, json=_json, - template_url=self.calculate_template_hash.metadata['url'], + template_url=self.calculate_template_hash.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) - deserialized = self._deserialize('TemplateHashResult', pipeline_response) + deserialized = self._deserialize("TemplateHashResult", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - calculate_template_hash.metadata = {'url': "/providers/Microsoft.Resources/calculateTemplateHash"} # type: ignore + calculate_template_hash.metadata = {"url": "/providers/Microsoft.Resources/calculateTemplateHash"} # type: ignore -class ProvidersOperations: - """ProvidersOperations async operations. - You should not instantiate this class directly. Instead, you should create a Client instance that - instantiates it for you and attaches it as an attribute. +class ProvidersOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. - :ivar models: Alias to model classes used in this operation group. - :type models: ~azure.mgmt.resource.resources.v2019_10_01.models - :param client: Client for service requests. - :param config: Configuration of service client. - :param serializer: An object model serializer. - :param deserializer: An object model deserializer. + Instead, you should access the following operations through + :class:`~azure.mgmt.resource.resources.v2019_10_01.aio.ResourceManagementClient`'s + :attr:`providers` attribute. """ models = _models - def __init__(self, client, config, serializer, deserializer) -> None: - self._client = client - self._serialize = serializer - self._deserialize = deserializer - self._config = config + def __init__(self, *args, **kwargs) -> None: + input_args = list(args) + self._client = input_args.pop(0) if input_args else kwargs.pop("client") + self._config = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") @distributed_trace_async - async def unregister( - self, - resource_provider_namespace: str, - **kwargs: Any - ) -> "_models.Provider": + async def unregister(self, resource_provider_namespace: str, **kwargs: Any) -> _models.Provider: """Unregisters a subscription from a resource provider. :param resource_provider_namespace: The namespace of the resource provider to unregister. + Required. :type resource_provider_namespace: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: Provider, or the result of cls(response) + :return: Provider or the result of cls(response) :rtype: ~azure.mgmt.resource.resources.v2019_10_01.models.Provider - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.Provider"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) - api_version = kwargs.pop('api_version', "2019-10-01") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2019-10-01")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[_models.Provider] - request = build_providers_unregister_request( resource_provider_namespace=resource_provider_namespace, subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.unregister.metadata['url'], + template_url=self.unregister.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) - deserialized = self._deserialize('Provider', pipeline_response) + deserialized = self._deserialize("Provider", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - unregister.metadata = {'url': "/subscriptions/{subscriptionId}/providers/{resourceProviderNamespace}/unregister"} # type: ignore - + unregister.metadata = {"url": "/subscriptions/{subscriptionId}/providers/{resourceProviderNamespace}/unregister"} # type: ignore @distributed_trace_async - async def register( - self, - resource_provider_namespace: str, - **kwargs: Any - ) -> "_models.Provider": + async def register(self, resource_provider_namespace: str, **kwargs: Any) -> _models.Provider: """Registers a subscription with a resource provider. :param resource_provider_namespace: The namespace of the resource provider to register. + Required. :type resource_provider_namespace: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: Provider, or the result of cls(response) + :return: Provider or the result of cls(response) :rtype: ~azure.mgmt.resource.resources.v2019_10_01.models.Provider - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.Provider"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) - api_version = kwargs.pop('api_version', "2019-10-01") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2019-10-01")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[_models.Provider] - request = build_providers_register_request( resource_provider_namespace=resource_provider_namespace, subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.register.metadata['url'], + template_url=self.register.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) - deserialized = self._deserialize('Provider', pipeline_response) + deserialized = self._deserialize("Provider", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - register.metadata = {'url': "/subscriptions/{subscriptionId}/providers/{resourceProviderNamespace}/register"} # type: ignore - + register.metadata = {"url": "/subscriptions/{subscriptionId}/providers/{resourceProviderNamespace}/register"} # type: ignore @distributed_trace def list( - self, - top: Optional[int] = None, - expand: Optional[str] = None, - **kwargs: Any - ) -> AsyncIterable["_models.ProviderListResult"]: + self, top: Optional[int] = None, expand: Optional[str] = None, **kwargs: Any + ) -> AsyncIterable["_models.Provider"]: """Gets all resource providers for a subscription. :param top: The number of results to return. If null is passed returns all deployments. Default @@ -4204,39 +5522,48 @@ def list( response, use $expand=resourceTypes/aliases. Default value is None. :type expand: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either ProviderListResult or the result of cls(response) + :return: An iterator like instance of either Provider or the result of cls(response) :rtype: - ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.resource.resources.v2019_10_01.models.ProviderListResult] - :raises: ~azure.core.exceptions.HttpResponseError + ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.resource.resources.v2019_10_01.models.Provider] + :raises ~azure.core.exceptions.HttpResponseError: """ - api_version = kwargs.pop('api_version', "2019-10-01") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2019-10-01")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[_models.ProviderListResult] - cls = kwargs.pop('cls', None) # type: ClsType["_models.ProviderListResult"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) + def prepare_request(next_link=None): if not next_link: - + request = build_providers_list_request( subscription_id=self._config.subscription_id, - api_version=api_version, top=top, expand=expand, - template_url=self.list.metadata['url'], + 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.url = self._client.format_url(request.url) # type: ignore else: - - request = build_providers_list_request( - subscription_id=self._config.subscription_id, - template_url=next_link, - ) + # make call to next link with the client's api-version + _parsed_next_link = urlparse(next_link) + _next_request_params = case_insensitive_dict(parse_qs(_parsed_next_link.query)) + _next_request_params["api-version"] = self._config.api_version + request = HttpRequest("GET", urljoin(next_link, _parsed_next_link.path), params=_next_request_params) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore request.method = "GET" return request @@ -4250,10 +5577,8 @@ async def extract_data(pipeline_response): async def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) response = pipeline_response.http_response @@ -4263,19 +5588,14 @@ async def get_next(next_link=None): return pipeline_response + return AsyncItemPaged(get_next, extract_data) - return AsyncItemPaged( - get_next, extract_data - ) - list.metadata = {'url': "/subscriptions/{subscriptionId}/providers"} # type: ignore + list.metadata = {"url": "/subscriptions/{subscriptionId}/providers"} # type: ignore @distributed_trace def list_at_tenant_scope( - self, - top: Optional[int] = None, - expand: Optional[str] = None, - **kwargs: Any - ) -> AsyncIterable["_models.ProviderListResult"]: + self, top: Optional[int] = None, expand: Optional[str] = None, **kwargs: Any + ) -> AsyncIterable["_models.Provider"]: """Gets all resource providers for the tenant. :param top: The number of results to return. If null is passed returns all providers. Default @@ -4286,37 +5606,47 @@ def list_at_tenant_scope( response, use $expand=resourceTypes/aliases. Default value is None. :type expand: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either ProviderListResult or the result of cls(response) + :return: An iterator like instance of either Provider or the result of cls(response) :rtype: - ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.resource.resources.v2019_10_01.models.ProviderListResult] - :raises: ~azure.core.exceptions.HttpResponseError + ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.resource.resources.v2019_10_01.models.Provider] + :raises ~azure.core.exceptions.HttpResponseError: """ - api_version = kwargs.pop('api_version', "2019-10-01") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2019-10-01")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[_models.ProviderListResult] - cls = kwargs.pop('cls', None) # type: ClsType["_models.ProviderListResult"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) + def prepare_request(next_link=None): if not next_link: - + request = build_providers_list_at_tenant_scope_request( - api_version=api_version, top=top, expand=expand, - template_url=self.list_at_tenant_scope.metadata['url'], + api_version=api_version, + template_url=self.list_at_tenant_scope.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore else: - - request = build_providers_list_at_tenant_scope_request( - template_url=next_link, - ) + # make call to next link with the client's api-version + _parsed_next_link = urlparse(next_link) + _next_request_params = case_insensitive_dict(parse_qs(_parsed_next_link.query)) + _next_request_params["api-version"] = self._config.api_version + request = HttpRequest("GET", urljoin(next_link, _parsed_next_link.path), params=_next_request_params) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore request.method = "GET" return request @@ -4330,10 +5660,8 @@ async def extract_data(pipeline_response): async def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) response = pipeline_response.http_response @@ -4343,149 +5671,150 @@ async def get_next(next_link=None): return pipeline_response + return AsyncItemPaged(get_next, extract_data) - return AsyncItemPaged( - get_next, extract_data - ) - list_at_tenant_scope.metadata = {'url': "/providers"} # type: ignore + list_at_tenant_scope.metadata = {"url": "/providers"} # type: ignore @distributed_trace_async async def get( - self, - resource_provider_namespace: str, - expand: Optional[str] = None, - **kwargs: Any - ) -> "_models.Provider": + self, resource_provider_namespace: str, expand: Optional[str] = None, **kwargs: Any + ) -> _models.Provider: """Gets the specified resource provider. - :param resource_provider_namespace: The namespace of the resource provider. + :param resource_provider_namespace: The namespace of the resource provider. Required. :type resource_provider_namespace: str :param expand: The $expand query parameter. For example, to include property aliases in response, use $expand=resourceTypes/aliases. Default value is None. :type expand: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: Provider, or the result of cls(response) + :return: Provider or the result of cls(response) :rtype: ~azure.mgmt.resource.resources.v2019_10_01.models.Provider - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.Provider"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) - api_version = kwargs.pop('api_version', "2019-10-01") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2019-10-01")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[_models.Provider] - request = build_providers_get_request( resource_provider_namespace=resource_provider_namespace, subscription_id=self._config.subscription_id, - api_version=api_version, expand=expand, - template_url=self.get.metadata['url'], + api_version=api_version, + template_url=self.get.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) - deserialized = self._deserialize('Provider', pipeline_response) + deserialized = self._deserialize("Provider", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - get.metadata = {'url': "/subscriptions/{subscriptionId}/providers/{resourceProviderNamespace}"} # type: ignore - + get.metadata = {"url": "/subscriptions/{subscriptionId}/providers/{resourceProviderNamespace}"} # type: ignore @distributed_trace_async async def get_at_tenant_scope( - self, - resource_provider_namespace: str, - expand: Optional[str] = None, - **kwargs: Any - ) -> "_models.Provider": + self, resource_provider_namespace: str, expand: Optional[str] = None, **kwargs: Any + ) -> _models.Provider: """Gets the specified resource provider at the tenant level. - :param resource_provider_namespace: The namespace of the resource provider. + :param resource_provider_namespace: The namespace of the resource provider. Required. :type resource_provider_namespace: str :param expand: The $expand query parameter. For example, to include property aliases in response, use $expand=resourceTypes/aliases. Default value is None. :type expand: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: Provider, or the result of cls(response) + :return: Provider or the result of cls(response) :rtype: ~azure.mgmt.resource.resources.v2019_10_01.models.Provider - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.Provider"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + 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', "2019-10-01") # type: str + api_version = kwargs.pop("api_version", _params.pop("api-version", "2019-10-01")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[_models.Provider] - request = build_providers_get_at_tenant_scope_request( resource_provider_namespace=resource_provider_namespace, - api_version=api_version, expand=expand, - template_url=self.get_at_tenant_scope.metadata['url'], + api_version=api_version, + template_url=self.get_at_tenant_scope.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) - deserialized = self._deserialize('Provider', pipeline_response) + deserialized = self._deserialize("Provider", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - get_at_tenant_scope.metadata = {'url': "/providers/{resourceProviderNamespace}"} # type: ignore + get_at_tenant_scope.metadata = {"url": "/providers/{resourceProviderNamespace}"} # type: ignore -class ResourcesOperations: # pylint: disable=too-many-public-methods - """ResourcesOperations async operations. - You should not instantiate this class directly. Instead, you should create a Client instance that - instantiates it for you and attaches it as an attribute. +class ResourcesOperations: # pylint: disable=too-many-public-methods + """ + .. warning:: + **DO NOT** instantiate this class directly. - :ivar models: Alias to model classes used in this operation group. - :type models: ~azure.mgmt.resource.resources.v2019_10_01.models - :param client: Client for service requests. - :param config: Configuration of service client. - :param serializer: An object model serializer. - :param deserializer: An object model deserializer. + Instead, you should access the following operations through + :class:`~azure.mgmt.resource.resources.v2019_10_01.aio.ResourceManagementClient`'s + :attr:`resources` attribute. """ models = _models - def __init__(self, client, config, serializer, deserializer) -> None: - self._client = client - self._serialize = serializer - self._deserialize = deserializer - self._config = config + def __init__(self, *args, **kwargs) -> None: + input_args = list(args) + self._client = input_args.pop(0) if input_args else kwargs.pop("client") + self._config = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") @distributed_trace def list_by_resource_group( @@ -4495,10 +5824,10 @@ def list_by_resource_group( expand: Optional[str] = None, top: Optional[int] = None, **kwargs: Any - ) -> AsyncIterable["_models.ResourceListResult"]: + ) -> AsyncIterable["_models.GenericResourceExpanded"]: """Get all the resources for a resource group. - :param resource_group_name: The resource group with the resources to get. + :param resource_group_name: The resource group with the resources to get. Required. :type resource_group_name: str :param filter: The filter to apply on the operation.:code:`
`:code:`
`The properties you can use for eq (equals) or ne (not equals) are: location, resourceType, name, resourceGroup, @@ -4524,42 +5853,51 @@ def list_by_resource_group( value is None. :type top: int :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either ResourceListResult or the result of cls(response) + :return: An iterator like instance of either GenericResourceExpanded or the result of + cls(response) :rtype: - ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.resource.resources.v2019_10_01.models.ResourceListResult] - :raises: ~azure.core.exceptions.HttpResponseError + ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.resource.resources.v2019_10_01.models.GenericResourceExpanded] + :raises ~azure.core.exceptions.HttpResponseError: """ - api_version = kwargs.pop('api_version', "2019-10-01") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2019-10-01")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[_models.ResourceListResult] - cls = kwargs.pop('cls', None) # type: ClsType["_models.ResourceListResult"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) + def prepare_request(next_link=None): if not next_link: - + request = build_resources_list_by_resource_group_request( resource_group_name=resource_group_name, subscription_id=self._config.subscription_id, - api_version=api_version, filter=filter, expand=expand, top=top, - template_url=self.list_by_resource_group.metadata['url'], + 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.url = self._client.format_url(request.url) # type: ignore else: - - request = build_resources_list_by_resource_group_request( - resource_group_name=resource_group_name, - subscription_id=self._config.subscription_id, - template_url=next_link, - ) + # make call to next link with the client's api-version + _parsed_next_link = urlparse(next_link) + _next_request_params = case_insensitive_dict(parse_qs(_parsed_next_link.query)) + _next_request_params["api-version"] = self._config.api_version + request = HttpRequest("GET", urljoin(next_link, _parsed_next_link.path), params=_next_request_params) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore request.method = "GET" return request @@ -4573,10 +5911,8 @@ async def extract_data(pipeline_response): async def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) response = pipeline_response.http_response @@ -4586,45 +5922,54 @@ async def get_next(next_link=None): return pipeline_response + return AsyncItemPaged(get_next, extract_data) - return AsyncItemPaged( - get_next, extract_data - ) - list_by_resource_group.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/resources"} # type: ignore + list_by_resource_group.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/resources"} # type: ignore async def _move_resources_initial( # pylint: disable=inconsistent-return-statements - self, - source_resource_group_name: str, - parameters: "_models.ResourcesMoveInfo", - **kwargs: Any + self, source_resource_group_name: str, parameters: Union[_models.ResourcesMoveInfo, IO], **kwargs: Any ) -> None: - cls = kwargs.pop('cls', None) # type: ClsType[None] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', "2019-10-01") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + api_version = kwargs.pop("api_version", _params.pop("api-version", "2019-10-01")) # type: str + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[None] - _json = self._serialize.body(parameters, 'ResourcesMoveInfo') + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(parameters, (IO, bytes)): + _content = parameters + else: + _json = self._serialize.body(parameters, "ResourcesMoveInfo") - request = build_resources_move_resources_request_initial( + request = build_resources_move_resources_request( source_resource_group_name=source_resource_group_name, subscription_id=self._config.subscription_id, api_version=api_version, content_type=content_type, json=_json, - template_url=self._move_resources_initial.metadata['url'], + content=_content, + template_url=self._move_resources_initial.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [202, 204]: @@ -4634,14 +5979,15 @@ async def _move_resources_initial( # pylint: disable=inconsistent-return-statem if cls: return cls(pipeline_response, None, {}) - _move_resources_initial.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{sourceResourceGroupName}/moveResources"} # type: ignore - + _move_resources_initial.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{sourceResourceGroupName}/moveResources"} # type: ignore - @distributed_trace_async - async def begin_move_resources( # pylint: disable=inconsistent-return-statements + @overload + async def begin_move_resources( self, source_resource_group_name: str, - parameters: "_models.ResourcesMoveInfo", + parameters: _models.ResourcesMoveInfo, + *, + content_type: str = "application/json", **kwargs: Any ) -> AsyncLROPoller[None]: """Moves resources from one resource group to another resource group. @@ -4652,10 +5998,13 @@ async def begin_move_resources( # pylint: disable=inconsistent-return-statement the groups until the move completes. :param source_resource_group_name: The name of the resource group containing the resources to - move. + move. Required. :type source_resource_group_name: str - :param parameters: Parameters for moving resources. + :param parameters: Parameters for moving resources. Required. :type parameters: ~azure.mgmt.resource.resources.v2019_10_01.models.ResourcesMoveInfo + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str :keyword callable cls: A custom type or function that will be passed the direct response :keyword str continuation_token: A continuation token to restart a poller from a saved state. :keyword polling: By default, your polling method will be AsyncARMPolling. Pass in False for @@ -4666,80 +6015,160 @@ async def begin_move_resources( # pylint: disable=inconsistent-return-statement Retry-After header is present. :return: An instance of AsyncLROPoller that returns either None or the result of cls(response) :rtype: ~azure.core.polling.AsyncLROPoller[None] - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - api_version = kwargs.pop('api_version', "2019-10-01") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] - polling = kwargs.pop('polling', True) # type: Union[bool, AsyncPollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType[None] - lro_delay = kwargs.pop( - 'polling_interval', - self._config.polling_interval - ) - cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] - if cont_token is None: - raw_result = await self._move_resources_initial( - source_resource_group_name=source_resource_group_name, - parameters=parameters, - api_version=api_version, - content_type=content_type, - cls=lambda x,y,z: x, - **kwargs - ) - kwargs.pop('error_map', None) - - def get_long_running_output(pipeline_response): - if cls: - return cls(pipeline_response, None, {}) - - - if polling is True: polling_method = AsyncARMPolling(lro_delay, **kwargs) - elif polling is False: polling_method = AsyncNoPolling() - else: polling_method = polling - if cont_token: - return AsyncLROPoller.from_continuation_token( - polling_method=polling_method, - continuation_token=cont_token, - client=self._client, - deserialization_callback=get_long_running_output - ) - return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) - begin_move_resources.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{sourceResourceGroupName}/moveResources"} # type: ignore - - async def _validate_move_resources_initial( # pylint: disable=inconsistent-return-statements - self, - source_resource_group_name: str, - parameters: "_models.ResourcesMoveInfo", - **kwargs: Any - ) -> None: - cls = kwargs.pop('cls', None) # type: ClsType[None] - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {})) + @overload + async def begin_move_resources( + self, source_resource_group_name: str, parameters: IO, *, content_type: str = "application/json", **kwargs: Any + ) -> AsyncLROPoller[None]: + """Moves resources from one resource group to another resource group. - api_version = kwargs.pop('api_version', "2019-10-01") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + The resources to move must be in the same source resource group. The target resource group may + be in a different subscription. When moving resources, both the source group and the target + group are locked for the duration of the operation. Write and delete operations are blocked on + the groups until the move completes. - _json = self._serialize.body(parameters, 'ResourcesMoveInfo') + :param source_resource_group_name: The name of the resource group containing the resources to + move. Required. + :type source_resource_group_name: str + :param parameters: Parameters for moving resources. Required. + :type parameters: IO + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be AsyncARMPolling. Pass in False for + this operation to not poll, or pass in your own initialized polling object for a personal + polling strategy. + :paramtype polling: bool or ~azure.core.polling.AsyncPollingMethod + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of AsyncLROPoller that returns either None or the result of cls(response) + :rtype: ~azure.core.polling.AsyncLROPoller[None] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace_async + async def begin_move_resources( + self, source_resource_group_name: str, parameters: Union[_models.ResourcesMoveInfo, IO], **kwargs: Any + ) -> AsyncLROPoller[None]: + """Moves resources from one resource group to another resource group. + + The resources to move must be in the same source resource group. The target resource group may + be in a different subscription. When moving resources, both the source group and the target + group are locked for the duration of the operation. Write and delete operations are blocked on + the groups until the move completes. + + :param source_resource_group_name: The name of the resource group containing the resources to + move. Required. + :type source_resource_group_name: str + :param parameters: Parameters for moving resources. Is either a model type or a IO type. + Required. + :type parameters: ~azure.mgmt.resource.resources.v2019_10_01.models.ResourcesMoveInfo or IO + :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. + Default value is None. + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be AsyncARMPolling. Pass in False for + this operation to not poll, or pass in your own initialized polling object for a personal + polling strategy. + :paramtype polling: bool or ~azure.core.polling.AsyncPollingMethod + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of AsyncLROPoller that returns either None or the result of cls(response) + :rtype: ~azure.core.polling.AsyncLROPoller[None] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _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", "2019-10-01")) # type: str + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[None] + polling = kwargs.pop("polling", True) # type: Union[bool, AsyncPollingMethod] + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token = kwargs.pop("continuation_token", None) # type: Optional[str] + if cont_token is None: + raw_result = await self._move_resources_initial( # type: ignore + source_resource_group_name=source_resource_group_name, + parameters=parameters, + api_version=api_version, + content_type=content_type, + cls=lambda x, y, z: x, + headers=_headers, + params=_params, + **kwargs + ) + kwargs.pop("error_map", None) + + def get_long_running_output(pipeline_response): # pylint: disable=inconsistent-return-statements + if cls: + return cls(pipeline_response, None, {}) + + if polling is True: + polling_method = cast(AsyncPollingMethod, AsyncARMPolling(lro_delay, **kwargs)) # type: AsyncPollingMethod + elif polling is False: + polling_method = cast(AsyncPollingMethod, AsyncNoPolling()) + else: + polling_method = polling + if cont_token: + return AsyncLROPoller.from_continuation_token( + polling_method=polling_method, + continuation_token=cont_token, + client=self._client, + deserialization_callback=get_long_running_output, + ) + return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) + + begin_move_resources.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{sourceResourceGroupName}/moveResources"} # type: ignore + + async def _validate_move_resources_initial( # pylint: disable=inconsistent-return-statements + self, source_resource_group_name: str, parameters: Union[_models.ResourcesMoveInfo, IO], **kwargs: Any + ) -> None: + error_map = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2019-10-01")) # type: str + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[None] + + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(parameters, (IO, bytes)): + _content = parameters + else: + _json = self._serialize.body(parameters, "ResourcesMoveInfo") - request = build_resources_validate_move_resources_request_initial( + request = build_resources_validate_move_resources_request( source_resource_group_name=source_resource_group_name, subscription_id=self._config.subscription_id, api_version=api_version, content_type=content_type, json=_json, - template_url=self._validate_move_resources_initial.metadata['url'], + content=_content, + template_url=self._validate_move_resources_initial.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [202, 204]: @@ -4749,14 +6178,15 @@ async def _validate_move_resources_initial( # pylint: disable=inconsistent-retu if cls: return cls(pipeline_response, None, {}) - _validate_move_resources_initial.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{sourceResourceGroupName}/validateMoveResources"} # type: ignore - + _validate_move_resources_initial.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{sourceResourceGroupName}/validateMoveResources"} # type: ignore - @distributed_trace_async - async def begin_validate_move_resources( # pylint: disable=inconsistent-return-statements + @overload + async def begin_validate_move_resources( self, source_resource_group_name: str, - parameters: "_models.ResourcesMoveInfo", + parameters: _models.ResourcesMoveInfo, + *, + content_type: str = "application/json", **kwargs: Any ) -> AsyncLROPoller[None]: """Validates whether resources can be moved from one resource group to another resource group. @@ -4769,10 +6199,13 @@ async def begin_validate_move_resources( # pylint: disable=inconsistent-return- operation. :param source_resource_group_name: The name of the resource group containing the resources to - validate for move. + validate for move. Required. :type source_resource_group_name: str - :param parameters: Parameters for moving resources. + :param parameters: Parameters for moving resources. Required. :type parameters: ~azure.mgmt.resource.resources.v2019_10_01.models.ResourcesMoveInfo + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str :keyword callable cls: A custom type or function that will be passed the direct response :keyword str continuation_token: A continuation token to restart a poller from a saved state. :keyword polling: By default, your polling method will be AsyncARMPolling. Pass in False for @@ -4783,55 +6216,124 @@ async def begin_validate_move_resources( # pylint: disable=inconsistent-return- Retry-After header is present. :return: An instance of AsyncLROPoller that returns either None or the result of cls(response) :rtype: ~azure.core.polling.AsyncLROPoller[None] - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - api_version = kwargs.pop('api_version', "2019-10-01") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] - polling = kwargs.pop('polling', True) # type: Union[bool, AsyncPollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType[None] - lro_delay = kwargs.pop( - 'polling_interval', - self._config.polling_interval - ) - cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] + + @overload + async def begin_validate_move_resources( + self, source_resource_group_name: str, parameters: IO, *, content_type: str = "application/json", **kwargs: Any + ) -> AsyncLROPoller[None]: + """Validates whether resources can be moved from one resource group to another resource group. + + This operation checks whether the specified resources can be moved to the target. The resources + to move must be in the same source resource group. The target resource group may be in a + different subscription. If validation succeeds, it returns HTTP response code 204 (no content). + If validation fails, it returns HTTP response code 409 (Conflict) with an error message. + Retrieve the URL in the Location header value to check the result of the long-running + operation. + + :param source_resource_group_name: The name of the resource group containing the resources to + validate for move. Required. + :type source_resource_group_name: str + :param parameters: Parameters for moving resources. Required. + :type parameters: IO + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be AsyncARMPolling. Pass in False for + this operation to not poll, or pass in your own initialized polling object for a personal + polling strategy. + :paramtype polling: bool or ~azure.core.polling.AsyncPollingMethod + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of AsyncLROPoller that returns either None or the result of cls(response) + :rtype: ~azure.core.polling.AsyncLROPoller[None] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace_async + async def begin_validate_move_resources( + self, source_resource_group_name: str, parameters: Union[_models.ResourcesMoveInfo, IO], **kwargs: Any + ) -> AsyncLROPoller[None]: + """Validates whether resources can be moved from one resource group to another resource group. + + This operation checks whether the specified resources can be moved to the target. The resources + to move must be in the same source resource group. The target resource group may be in a + different subscription. If validation succeeds, it returns HTTP response code 204 (no content). + If validation fails, it returns HTTP response code 409 (Conflict) with an error message. + Retrieve the URL in the Location header value to check the result of the long-running + operation. + + :param source_resource_group_name: The name of the resource group containing the resources to + validate for move. Required. + :type source_resource_group_name: str + :param parameters: Parameters for moving resources. Is either a model type or a IO type. + Required. + :type parameters: ~azure.mgmt.resource.resources.v2019_10_01.models.ResourcesMoveInfo or IO + :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. + Default value is None. + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be AsyncARMPolling. Pass in False for + this operation to not poll, or pass in your own initialized polling object for a personal + polling strategy. + :paramtype polling: bool or ~azure.core.polling.AsyncPollingMethod + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of AsyncLROPoller that returns either None or the result of cls(response) + :rtype: ~azure.core.polling.AsyncLROPoller[None] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _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", "2019-10-01")) # type: str + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[None] + polling = kwargs.pop("polling", True) # type: Union[bool, AsyncPollingMethod] + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token = kwargs.pop("continuation_token", None) # type: Optional[str] if cont_token is None: - raw_result = await self._validate_move_resources_initial( + raw_result = await self._validate_move_resources_initial( # type: ignore source_resource_group_name=source_resource_group_name, parameters=parameters, api_version=api_version, content_type=content_type, - cls=lambda x,y,z: x, + cls=lambda x, y, z: x, + headers=_headers, + params=_params, **kwargs ) - kwargs.pop('error_map', None) + kwargs.pop("error_map", None) - def get_long_running_output(pipeline_response): + def get_long_running_output(pipeline_response): # pylint: disable=inconsistent-return-statements if cls: return cls(pipeline_response, None, {}) - - if polling is True: polling_method = AsyncARMPolling(lro_delay, **kwargs) - elif polling is False: polling_method = AsyncNoPolling() - else: polling_method = polling + if polling is True: + polling_method = cast(AsyncPollingMethod, AsyncARMPolling(lro_delay, **kwargs)) # type: AsyncPollingMethod + elif polling is False: + polling_method = cast(AsyncPollingMethod, AsyncNoPolling()) + else: + polling_method = polling if cont_token: return AsyncLROPoller.from_continuation_token( polling_method=polling_method, continuation_token=cont_token, client=self._client, - deserialization_callback=get_long_running_output + deserialization_callback=get_long_running_output, ) return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) - begin_validate_move_resources.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{sourceResourceGroupName}/validateMoveResources"} # type: ignore + begin_validate_move_resources.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{sourceResourceGroupName}/validateMoveResources"} # type: ignore @distributed_trace def list( - self, - filter: Optional[str] = None, - expand: Optional[str] = None, - top: Optional[int] = None, - **kwargs: Any - ) -> AsyncIterable["_models.ResourceListResult"]: + self, filter: Optional[str] = None, expand: Optional[str] = None, top: Optional[int] = None, **kwargs: Any + ) -> AsyncIterable["_models.GenericResourceExpanded"]: """Get all the resources in a subscription. :param filter: The filter to apply on the operation.:code:`
`:code:`
`The properties you @@ -4858,40 +6360,50 @@ def list( value is None. :type top: int :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either ResourceListResult or the result of cls(response) + :return: An iterator like instance of either GenericResourceExpanded or the result of + cls(response) :rtype: - ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.resource.resources.v2019_10_01.models.ResourceListResult] - :raises: ~azure.core.exceptions.HttpResponseError + ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.resource.resources.v2019_10_01.models.GenericResourceExpanded] + :raises ~azure.core.exceptions.HttpResponseError: """ - api_version = kwargs.pop('api_version', "2019-10-01") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2019-10-01")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[_models.ResourceListResult] - cls = kwargs.pop('cls', None) # type: ClsType["_models.ResourceListResult"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) + def prepare_request(next_link=None): if not next_link: - + request = build_resources_list_request( subscription_id=self._config.subscription_id, - api_version=api_version, filter=filter, expand=expand, top=top, - template_url=self.list.metadata['url'], + 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.url = self._client.format_url(request.url) # type: ignore else: - - request = build_resources_list_request( - subscription_id=self._config.subscription_id, - template_url=next_link, - ) + # make call to next link with the client's api-version + _parsed_next_link = urlparse(next_link) + _next_request_params = case_insensitive_dict(parse_qs(_parsed_next_link.query)) + _next_request_params["api-version"] = self._config.api_version + request = HttpRequest("GET", urljoin(next_link, _parsed_next_link.path), params=_next_request_params) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore request.method = "GET" return request @@ -4905,10 +6417,8 @@ async def extract_data(pipeline_response): async def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) response = pipeline_response.http_response @@ -4918,11 +6428,9 @@ async def get_next(next_link=None): return pipeline_response + return AsyncItemPaged(get_next, extract_data) - return AsyncItemPaged( - get_next, extract_data - ) - list.metadata = {'url': "/subscriptions/{subscriptionId}/resources"} # type: ignore + list.metadata = {"url": "/subscriptions/{subscriptionId}/resources"} # type: ignore @distributed_trace_async async def check_existence( @@ -4938,30 +6446,36 @@ async def check_existence( """Checks whether a resource exists. :param resource_group_name: The name of the resource group containing the resource to check. - The name is case insensitive. + The name is case insensitive. Required. :type resource_group_name: str - :param resource_provider_namespace: The resource provider of the resource to check. + :param resource_provider_namespace: The resource provider of the resource to check. Required. :type resource_provider_namespace: str - :param parent_resource_path: The parent resource identity. + :param parent_resource_path: The parent resource identity. Required. :type parent_resource_path: str - :param resource_type: The resource type. + :param resource_type: The resource type. Required. :type resource_type: str - :param resource_name: The name of the resource to check whether it exists. + :param resource_name: The name of the resource to check whether it exists. Required. :type resource_name: str - :param api_version: The API version to use for the operation. + :param api_version: The API version to use for the operation. Required. :type api_version: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: bool, or the result of cls(response) + :return: bool or the result of cls(response) :rtype: bool - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType[None] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = kwargs.pop("params", {}) or {} + + cls = kwargs.pop("cls", None) # type: ClsType[None] - request = build_resources_check_existence_request( resource_group_name=resource_group_name, resource_provider_namespace=resource_provider_namespace, @@ -4970,16 +6484,17 @@ async def check_existence( resource_name=resource_name, subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.check_existence.metadata['url'], + template_url=self.check_existence.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [204, 404]: @@ -4990,8 +6505,7 @@ async def check_existence( return cls(pipeline_response, None, {}) return 200 <= response.status_code <= 299 - check_existence.metadata = {'url': "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{parentResourcePath}/{resourceType}/{resourceName}"} # type: ignore - + check_existence.metadata = {"url": "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{parentResourcePath}/{resourceType}/{resourceName}"} # type: ignore async def _delete_initial( # pylint: disable=inconsistent-return-statements self, @@ -5003,14 +6517,20 @@ async def _delete_initial( # pylint: disable=inconsistent-return-statements api_version: str, **kwargs: Any ) -> None: - cls = kwargs.pop('cls', None) # type: ClsType[None] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) - - request = build_resources_delete_request_initial( + _headers = kwargs.pop("headers", {}) or {} + _params = kwargs.pop("params", {}) or {} + + cls = kwargs.pop("cls", None) # type: ClsType[None] + + request = build_resources_delete_request( resource_group_name=resource_group_name, resource_provider_namespace=resource_provider_namespace, parent_resource_path=parent_resource_path, @@ -5018,16 +6538,17 @@ async def _delete_initial( # pylint: disable=inconsistent-return-statements resource_name=resource_name, subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self._delete_initial.metadata['url'], + template_url=self._delete_initial.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200, 202, 204]: @@ -5037,11 +6558,10 @@ 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/{resourceProviderNamespace}/{parentResourcePath}/{resourceType}/{resourceName}"} # type: ignore - + _delete_initial.metadata = {"url": "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{parentResourcePath}/{resourceType}/{resourceName}"} # type: ignore @distributed_trace_async - async def begin_delete( # pylint: disable=inconsistent-return-statements + async def begin_delete( self, resource_group_name: str, resource_provider_namespace: str, @@ -5054,17 +6574,17 @@ async def begin_delete( # pylint: disable=inconsistent-return-statements """Deletes a resource. :param resource_group_name: The name of the resource group that contains the resource to - delete. The name is case insensitive. + delete. The name is case insensitive. Required. :type resource_group_name: str - :param resource_provider_namespace: The namespace of the resource provider. + :param resource_provider_namespace: The namespace of the resource provider. Required. :type resource_provider_namespace: str - :param parent_resource_path: The parent resource identity. + :param parent_resource_path: The parent resource identity. Required. :type parent_resource_path: str - :param resource_type: The resource type. + :param resource_type: The resource type. Required. :type resource_type: str - :param resource_name: The name of the resource to delete. + :param resource_name: The name of the resource to delete. Required. :type resource_name: str - :param api_version: The API version to use for the operation. + :param api_version: The API version to use for the operation. Required. :type api_version: str :keyword callable cls: A custom type or function that will be passed the direct response :keyword str continuation_token: A continuation token to restart a poller from a saved state. @@ -5076,46 +6596,50 @@ async def begin_delete( # pylint: disable=inconsistent-return-statements Retry-After header is present. :return: An instance of AsyncLROPoller that returns either None or the result of cls(response) :rtype: ~azure.core.polling.AsyncLROPoller[None] - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - polling = kwargs.pop('polling', True) # type: Union[bool, AsyncPollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType[None] - lro_delay = kwargs.pop( - 'polling_interval', - self._config.polling_interval - ) - cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] + _headers = kwargs.pop("headers", {}) or {} + _params = kwargs.pop("params", {}) or {} + + cls = kwargs.pop("cls", None) # type: ClsType[None] + polling = kwargs.pop("polling", True) # type: Union[bool, AsyncPollingMethod] + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token = kwargs.pop("continuation_token", None) # type: Optional[str] if cont_token is None: - raw_result = await self._delete_initial( + raw_result = await self._delete_initial( # type: ignore resource_group_name=resource_group_name, resource_provider_namespace=resource_provider_namespace, parent_resource_path=parent_resource_path, resource_type=resource_type, resource_name=resource_name, api_version=api_version, - cls=lambda x,y,z: x, + cls=lambda x, y, z: x, + headers=_headers, + params=_params, **kwargs ) - kwargs.pop('error_map', None) + kwargs.pop("error_map", None) - def get_long_running_output(pipeline_response): + def get_long_running_output(pipeline_response): # pylint: disable=inconsistent-return-statements if cls: return cls(pipeline_response, None, {}) - - if polling is True: polling_method = AsyncARMPolling(lro_delay, **kwargs) - elif polling is False: polling_method = AsyncNoPolling() - else: polling_method = polling + if polling is True: + polling_method = cast(AsyncPollingMethod, AsyncARMPolling(lro_delay, **kwargs)) # type: AsyncPollingMethod + elif polling is False: + polling_method = cast(AsyncPollingMethod, AsyncNoPolling()) + else: + polling_method = polling if cont_token: return AsyncLROPoller.from_continuation_token( polling_method=polling_method, continuation_token=cont_token, client=self._client, - deserialization_callback=get_long_running_output + deserialization_callback=get_long_running_output, ) return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) - begin_delete.metadata = {'url': "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{parentResourcePath}/{resourceType}/{resourceName}"} # type: ignore + begin_delete.metadata = {"url": "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{parentResourcePath}/{resourceType}/{resourceName}"} # type: ignore async def _create_or_update_initial( self, @@ -5125,39 +6649,53 @@ async def _create_or_update_initial( resource_type: str, resource_name: str, api_version: str, - parameters: "_models.GenericResource", + parameters: Union[_models.GenericResource, IO], **kwargs: Any - ) -> Optional["_models.GenericResource"]: - cls = kwargs.pop('cls', None) # type: ClsType[Optional["_models.GenericResource"]] + ) -> Optional[_models.GenericResource]: error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = kwargs.pop("params", {}) or {} - _json = self._serialize.body(parameters, 'GenericResource') + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[Optional[_models.GenericResource]] - request = build_resources_create_or_update_request_initial( + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(parameters, (IO, bytes)): + _content = parameters + else: + _json = self._serialize.body(parameters, "GenericResource") + + request = build_resources_create_or_update_request( resource_group_name=resource_group_name, resource_provider_namespace=resource_provider_namespace, parent_resource_path=parent_resource_path, resource_type=resource_type, resource_name=resource_name, subscription_id=self._config.subscription_id, - content_type=content_type, api_version=api_version, + content_type=content_type, json=_json, - template_url=self._create_or_update_initial.metadata['url'], + content=_content, + template_url=self._create_or_update_initial.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200, 201, 202]: @@ -5166,18 +6704,115 @@ async def _create_or_update_initial( deserialized = None if response.status_code == 200: - deserialized = self._deserialize('GenericResource', pipeline_response) + deserialized = self._deserialize("GenericResource", pipeline_response) if response.status_code == 201: - deserialized = self._deserialize('GenericResource', pipeline_response) + deserialized = self._deserialize("GenericResource", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - _create_or_update_initial.metadata = {'url': "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{parentResourcePath}/{resourceType}/{resourceName}"} # type: ignore + _create_or_update_initial.metadata = {"url": "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{parentResourcePath}/{resourceType}/{resourceName}"} # type: ignore + + @overload + async def begin_create_or_update( + self, + resource_group_name: str, + resource_provider_namespace: str, + parent_resource_path: str, + resource_type: str, + resource_name: str, + api_version: str, + parameters: _models.GenericResource, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> AsyncLROPoller[_models.GenericResource]: + """Creates a resource. + + :param resource_group_name: The name of the resource group for the resource. The name is case + insensitive. Required. + :type resource_group_name: str + :param resource_provider_namespace: The namespace of the resource provider. Required. + :type resource_provider_namespace: str + :param parent_resource_path: The parent resource identity. Required. + :type parent_resource_path: str + :param resource_type: The resource type of the resource to create. Required. + :type resource_type: str + :param resource_name: The name of the resource to create. Required. + :type resource_name: str + :param api_version: The API version to use for the operation. Required. + :type api_version: str + :param parameters: Parameters for creating or updating the resource. Required. + :type parameters: ~azure.mgmt.resource.resources.v2019_10_01.models.GenericResource + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be AsyncARMPolling. Pass in False for + this operation to not poll, or pass in your own initialized polling object for a personal + polling strategy. + :paramtype polling: bool or ~azure.core.polling.AsyncPollingMethod + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of AsyncLROPoller that returns either GenericResource or the result of + cls(response) + :rtype: + ~azure.core.polling.AsyncLROPoller[~azure.mgmt.resource.resources.v2019_10_01.models.GenericResource] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + async def begin_create_or_update( + self, + resource_group_name: str, + resource_provider_namespace: str, + parent_resource_path: str, + resource_type: str, + resource_name: str, + api_version: str, + parameters: IO, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> AsyncLROPoller[_models.GenericResource]: + """Creates a resource. + :param resource_group_name: The name of the resource group for the resource. The name is case + insensitive. Required. + :type resource_group_name: str + :param resource_provider_namespace: The namespace of the resource provider. Required. + :type resource_provider_namespace: str + :param parent_resource_path: The parent resource identity. Required. + :type parent_resource_path: str + :param resource_type: The resource type of the resource to create. Required. + :type resource_type: str + :param resource_name: The name of the resource to create. Required. + :type resource_name: str + :param api_version: The API version to use for the operation. Required. + :type api_version: str + :param parameters: Parameters for creating or updating the resource. Required. + :type parameters: IO + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be AsyncARMPolling. Pass in False for + this operation to not poll, or pass in your own initialized polling object for a personal + polling strategy. + :paramtype polling: bool or ~azure.core.polling.AsyncPollingMethod + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of AsyncLROPoller that returns either GenericResource or the result of + cls(response) + :rtype: + ~azure.core.polling.AsyncLROPoller[~azure.mgmt.resource.resources.v2019_10_01.models.GenericResource] + :raises ~azure.core.exceptions.HttpResponseError: + """ @distributed_trace_async async def begin_create_or_update( @@ -5188,26 +6823,30 @@ async def begin_create_or_update( resource_type: str, resource_name: str, api_version: str, - parameters: "_models.GenericResource", + parameters: Union[_models.GenericResource, IO], **kwargs: Any - ) -> AsyncLROPoller["_models.GenericResource"]: + ) -> AsyncLROPoller[_models.GenericResource]: """Creates a resource. :param resource_group_name: The name of the resource group for the resource. The name is case - insensitive. + insensitive. Required. :type resource_group_name: str - :param resource_provider_namespace: The namespace of the resource provider. + :param resource_provider_namespace: The namespace of the resource provider. Required. :type resource_provider_namespace: str - :param parent_resource_path: The parent resource identity. + :param parent_resource_path: The parent resource identity. Required. :type parent_resource_path: str - :param resource_type: The resource type of the resource to create. + :param resource_type: The resource type of the resource to create. Required. :type resource_type: str - :param resource_name: The name of the resource to create. + :param resource_name: The name of the resource to create. Required. :type resource_name: str - :param api_version: The API version to use for the operation. + :param api_version: The API version to use for the operation. Required. :type api_version: str - :param parameters: Parameters for creating or updating the resource. - :type parameters: ~azure.mgmt.resource.resources.v2019_10_01.models.GenericResource + :param parameters: Parameters for creating or updating the resource. Is either a model type or + a IO type. Required. + :type parameters: ~azure.mgmt.resource.resources.v2019_10_01.models.GenericResource or IO + :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. + Default value is None. + :paramtype content_type: str :keyword callable cls: A custom type or function that will be passed the direct response :keyword str continuation_token: A continuation token to restart a poller from a saved state. :keyword polling: By default, your polling method will be AsyncARMPolling. Pass in False for @@ -5220,18 +6859,18 @@ async def begin_create_or_update( cls(response) :rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.resource.resources.v2019_10_01.models.GenericResource] - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] - polling = kwargs.pop('polling', True) # type: Union[bool, AsyncPollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType["_models.GenericResource"] - lro_delay = kwargs.pop( - 'polling_interval', - self._config.polling_interval - ) - cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = kwargs.pop("params", {}) or {} + + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.GenericResource] + polling = kwargs.pop("polling", True) # type: Union[bool, AsyncPollingMethod] + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token = kwargs.pop("continuation_token", None) # type: Optional[str] if cont_token is None: - raw_result = await self._create_or_update_initial( + raw_result = await self._create_or_update_initial( # type: ignore resource_group_name=resource_group_name, resource_provider_namespace=resource_provider_namespace, parent_resource_path=parent_resource_path, @@ -5240,32 +6879,35 @@ async def begin_create_or_update( api_version=api_version, parameters=parameters, content_type=content_type, - cls=lambda x,y,z: x, + cls=lambda x, y, z: x, + headers=_headers, + params=_params, **kwargs ) - kwargs.pop('error_map', None) + kwargs.pop("error_map", None) def get_long_running_output(pipeline_response): - response = pipeline_response.http_response - deserialized = self._deserialize('GenericResource', pipeline_response) + deserialized = self._deserialize("GenericResource", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - - if polling is True: polling_method = AsyncARMPolling(lro_delay, **kwargs) - elif polling is False: polling_method = AsyncNoPolling() - else: polling_method = polling + if polling is True: + polling_method = cast(AsyncPollingMethod, AsyncARMPolling(lro_delay, **kwargs)) # type: AsyncPollingMethod + elif polling is False: + polling_method = cast(AsyncPollingMethod, AsyncNoPolling()) + else: + polling_method = polling if cont_token: return AsyncLROPoller.from_continuation_token( polling_method=polling_method, continuation_token=cont_token, client=self._client, - deserialization_callback=get_long_running_output + deserialization_callback=get_long_running_output, ) return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) - begin_create_or_update.metadata = {'url': "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{parentResourcePath}/{resourceType}/{resourceName}"} # type: ignore + begin_create_or_update.metadata = {"url": "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{parentResourcePath}/{resourceType}/{resourceName}"} # type: ignore async def _update_initial( self, @@ -5275,39 +6917,53 @@ async def _update_initial( resource_type: str, resource_name: str, api_version: str, - parameters: "_models.GenericResource", + parameters: Union[_models.GenericResource, IO], **kwargs: Any - ) -> Optional["_models.GenericResource"]: - cls = kwargs.pop('cls', None) # type: ClsType[Optional["_models.GenericResource"]] + ) -> Optional[_models.GenericResource]: error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = kwargs.pop("params", {}) or {} - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[Optional[_models.GenericResource]] - _json = self._serialize.body(parameters, 'GenericResource') + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(parameters, (IO, bytes)): + _content = parameters + else: + _json = self._serialize.body(parameters, "GenericResource") - request = build_resources_update_request_initial( + request = build_resources_update_request( resource_group_name=resource_group_name, resource_provider_namespace=resource_provider_namespace, parent_resource_path=parent_resource_path, resource_type=resource_type, resource_name=resource_name, subscription_id=self._config.subscription_id, - content_type=content_type, api_version=api_version, + content_type=content_type, json=_json, - template_url=self._update_initial.metadata['url'], + content=_content, + template_url=self._update_initial.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200, 202]: @@ -5316,17 +6972,16 @@ async def _update_initial( deserialized = None if response.status_code == 200: - deserialized = self._deserialize('GenericResource', pipeline_response) + deserialized = self._deserialize("GenericResource", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - _update_initial.metadata = {'url': "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{parentResourcePath}/{resourceType}/{resourceName}"} # type: ignore - + _update_initial.metadata = {"url": "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{parentResourcePath}/{resourceType}/{resourceName}"} # type: ignore - @distributed_trace_async + @overload async def begin_update( self, resource_group_name: str, @@ -5335,26 +6990,31 @@ async def begin_update( resource_type: str, resource_name: str, api_version: str, - parameters: "_models.GenericResource", + parameters: _models.GenericResource, + *, + content_type: str = "application/json", **kwargs: Any - ) -> AsyncLROPoller["_models.GenericResource"]: + ) -> AsyncLROPoller[_models.GenericResource]: """Updates a resource. :param resource_group_name: The name of the resource group for the resource. The name is case - insensitive. + insensitive. Required. :type resource_group_name: str - :param resource_provider_namespace: The namespace of the resource provider. + :param resource_provider_namespace: The namespace of the resource provider. Required. :type resource_provider_namespace: str - :param parent_resource_path: The parent resource identity. + :param parent_resource_path: The parent resource identity. Required. :type parent_resource_path: str - :param resource_type: The resource type of the resource to update. + :param resource_type: The resource type of the resource to update. Required. :type resource_type: str - :param resource_name: The name of the resource to update. + :param resource_name: The name of the resource to update. Required. :type resource_name: str - :param api_version: The API version to use for the operation. + :param api_version: The API version to use for the operation. Required. :type api_version: str - :param parameters: Parameters for updating the resource. + :param parameters: Parameters for updating the resource. Required. :type parameters: ~azure.mgmt.resource.resources.v2019_10_01.models.GenericResource + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str :keyword callable cls: A custom type or function that will be passed the direct response :keyword str continuation_token: A continuation token to restart a poller from a saved state. :keyword polling: By default, your polling method will be AsyncARMPolling. Pass in False for @@ -5367,52 +7027,152 @@ async def begin_update( cls(response) :rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.resource.resources.v2019_10_01.models.GenericResource] - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] - polling = kwargs.pop('polling', True) # type: Union[bool, AsyncPollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType["_models.GenericResource"] - lro_delay = kwargs.pop( - 'polling_interval', - self._config.polling_interval - ) - cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] - if cont_token is None: - raw_result = await self._update_initial( - resource_group_name=resource_group_name, - resource_provider_namespace=resource_provider_namespace, - parent_resource_path=parent_resource_path, - resource_type=resource_type, - resource_name=resource_name, - api_version=api_version, - parameters=parameters, - content_type=content_type, - cls=lambda x,y,z: x, - **kwargs - ) - kwargs.pop('error_map', None) - - def get_long_running_output(pipeline_response): - response = pipeline_response.http_response - deserialized = self._deserialize('GenericResource', pipeline_response) - if cls: - return cls(pipeline_response, deserialized, {}) - return deserialized + @overload + async def begin_update( + self, + resource_group_name: str, + resource_provider_namespace: str, + parent_resource_path: str, + resource_type: str, + resource_name: str, + api_version: str, + parameters: IO, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> AsyncLROPoller[_models.GenericResource]: + """Updates a resource. - if polling is True: polling_method = AsyncARMPolling(lro_delay, **kwargs) - elif polling is False: polling_method = AsyncNoPolling() - else: polling_method = polling - if cont_token: + :param resource_group_name: The name of the resource group for the resource. The name is case + insensitive. Required. + :type resource_group_name: str + :param resource_provider_namespace: The namespace of the resource provider. Required. + :type resource_provider_namespace: str + :param parent_resource_path: The parent resource identity. Required. + :type parent_resource_path: str + :param resource_type: The resource type of the resource to update. Required. + :type resource_type: str + :param resource_name: The name of the resource to update. Required. + :type resource_name: str + :param api_version: The API version to use for the operation. Required. + :type api_version: str + :param parameters: Parameters for updating the resource. Required. + :type parameters: IO + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be AsyncARMPolling. Pass in False for + this operation to not poll, or pass in your own initialized polling object for a personal + polling strategy. + :paramtype polling: bool or ~azure.core.polling.AsyncPollingMethod + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of AsyncLROPoller that returns either GenericResource or the result of + cls(response) + :rtype: + ~azure.core.polling.AsyncLROPoller[~azure.mgmt.resource.resources.v2019_10_01.models.GenericResource] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace_async + async def begin_update( + self, + resource_group_name: str, + resource_provider_namespace: str, + parent_resource_path: str, + resource_type: str, + resource_name: str, + api_version: str, + parameters: Union[_models.GenericResource, IO], + **kwargs: Any + ) -> AsyncLROPoller[_models.GenericResource]: + """Updates a resource. + + :param resource_group_name: The name of the resource group for the resource. The name is case + insensitive. Required. + :type resource_group_name: str + :param resource_provider_namespace: The namespace of the resource provider. Required. + :type resource_provider_namespace: str + :param parent_resource_path: The parent resource identity. Required. + :type parent_resource_path: str + :param resource_type: The resource type of the resource to update. Required. + :type resource_type: str + :param resource_name: The name of the resource to update. Required. + :type resource_name: str + :param api_version: The API version to use for the operation. Required. + :type api_version: str + :param parameters: Parameters for updating the resource. Is either a model type or a IO type. + Required. + :type parameters: ~azure.mgmt.resource.resources.v2019_10_01.models.GenericResource or IO + :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. + Default value is None. + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be AsyncARMPolling. Pass in False for + this operation to not poll, or pass in your own initialized polling object for a personal + polling strategy. + :paramtype polling: bool or ~azure.core.polling.AsyncPollingMethod + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of AsyncLROPoller that returns either GenericResource or the result of + cls(response) + :rtype: + ~azure.core.polling.AsyncLROPoller[~azure.mgmt.resource.resources.v2019_10_01.models.GenericResource] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = kwargs.pop("params", {}) or {} + + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.GenericResource] + polling = kwargs.pop("polling", True) # type: Union[bool, AsyncPollingMethod] + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token = kwargs.pop("continuation_token", None) # type: Optional[str] + if cont_token is None: + raw_result = await self._update_initial( # type: ignore + resource_group_name=resource_group_name, + resource_provider_namespace=resource_provider_namespace, + parent_resource_path=parent_resource_path, + resource_type=resource_type, + resource_name=resource_name, + api_version=api_version, + parameters=parameters, + content_type=content_type, + cls=lambda x, y, z: x, + headers=_headers, + params=_params, + **kwargs + ) + kwargs.pop("error_map", None) + + def get_long_running_output(pipeline_response): + deserialized = self._deserialize("GenericResource", pipeline_response) + if cls: + return cls(pipeline_response, deserialized, {}) + return deserialized + + if polling is True: + polling_method = cast(AsyncPollingMethod, AsyncARMPolling(lro_delay, **kwargs)) # type: AsyncPollingMethod + elif polling is False: + polling_method = cast(AsyncPollingMethod, AsyncNoPolling()) + else: + polling_method = polling + if cont_token: return AsyncLROPoller.from_continuation_token( polling_method=polling_method, continuation_token=cont_token, client=self._client, - deserialization_callback=get_long_running_output + deserialization_callback=get_long_running_output, ) return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) - begin_update.metadata = {'url': "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{parentResourcePath}/{resourceType}/{resourceName}"} # type: ignore + begin_update.metadata = {"url": "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{parentResourcePath}/{resourceType}/{resourceName}"} # type: ignore @distributed_trace_async async def get( @@ -5424,34 +7184,40 @@ async def get( resource_name: str, api_version: str, **kwargs: Any - ) -> "_models.GenericResource": + ) -> _models.GenericResource: """Gets a resource. :param resource_group_name: The name of the resource group containing the resource to get. The - name is case insensitive. + name is case insensitive. Required. :type resource_group_name: str - :param resource_provider_namespace: The namespace of the resource provider. + :param resource_provider_namespace: The namespace of the resource provider. Required. :type resource_provider_namespace: str - :param parent_resource_path: The parent resource identity. + :param parent_resource_path: The parent resource identity. Required. :type parent_resource_path: str - :param resource_type: The resource type of the resource. + :param resource_type: The resource type of the resource. Required. :type resource_type: str - :param resource_name: The name of the resource to get. + :param resource_name: The name of the resource to get. Required. :type resource_name: str - :param api_version: The API version to use for the operation. + :param api_version: The API version to use for the operation. Required. :type api_version: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: GenericResource, or the result of cls(response) + :return: GenericResource or the result of cls(response) :rtype: ~azure.mgmt.resource.resources.v2019_10_01.models.GenericResource - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.GenericResource"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = kwargs.pop("params", {}) or {} + + cls = kwargs.pop("cls", None) # type: ClsType[_models.GenericResource] - request = build_resources_get_request( resource_group_name=resource_group_name, resource_provider_namespace=resource_provider_namespace, @@ -5460,72 +7226,75 @@ async def get( resource_name=resource_name, subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.get.metadata['url'], + template_url=self.get.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) - deserialized = self._deserialize('GenericResource', pipeline_response) + deserialized = self._deserialize("GenericResource", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - get.metadata = {'url': "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{parentResourcePath}/{resourceType}/{resourceName}"} # type: ignore - + get.metadata = {"url": "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{parentResourcePath}/{resourceType}/{resourceName}"} # type: ignore @distributed_trace_async - async def check_existence_by_id( - self, - resource_id: str, - api_version: str, - **kwargs: Any - ) -> bool: + async def check_existence_by_id(self, resource_id: str, api_version: str, **kwargs: Any) -> bool: """Checks by ID whether a resource exists. :param resource_id: The fully qualified ID of the resource, including the resource name and resource type. Use the format, /subscriptions/{guid}/resourceGroups/{resource-group-name}/{resource-provider-namespace}/{resource-type}/{resource-name}. + Required. :type resource_id: str - :param api_version: The API version to use for the operation. + :param api_version: The API version to use for the operation. Required. :type api_version: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: bool, or the result of cls(response) + :return: bool or the result of cls(response) :rtype: bool - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType[None] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = kwargs.pop("params", {}) or {} + + cls = kwargs.pop("cls", None) # type: ClsType[None] - request = build_resources_check_existence_by_id_request( resource_id=resource_id, api_version=api_version, - template_url=self.check_existence_by_id.metadata['url'], + template_url=self.check_existence_by_id.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [204, 404]: @@ -5536,35 +7305,38 @@ async def check_existence_by_id( return cls(pipeline_response, None, {}) return 200 <= response.status_code <= 299 - check_existence_by_id.metadata = {'url': "/{resourceId}"} # type: ignore - + check_existence_by_id.metadata = {"url": "/{resourceId}"} # type: ignore async def _delete_by_id_initial( # pylint: disable=inconsistent-return-statements - self, - resource_id: str, - api_version: str, - **kwargs: Any + self, resource_id: str, api_version: str, **kwargs: Any ) -> None: - cls = kwargs.pop('cls', None) # type: ClsType[None] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = kwargs.pop("params", {}) or {} + + cls = kwargs.pop("cls", None) # type: ClsType[None] - - request = build_resources_delete_by_id_request_initial( + request = build_resources_delete_by_id_request( resource_id=resource_id, api_version=api_version, - template_url=self._delete_by_id_initial.metadata['url'], + template_url=self._delete_by_id_initial.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200, 202, 204]: @@ -5574,23 +7346,18 @@ async def _delete_by_id_initial( # pylint: disable=inconsistent-return-statemen if cls: return cls(pipeline_response, None, {}) - _delete_by_id_initial.metadata = {'url': "/{resourceId}"} # type: ignore - + _delete_by_id_initial.metadata = {"url": "/{resourceId}"} # type: ignore @distributed_trace_async - async def begin_delete_by_id( # pylint: disable=inconsistent-return-statements - self, - resource_id: str, - api_version: str, - **kwargs: Any - ) -> AsyncLROPoller[None]: + async def begin_delete_by_id(self, resource_id: str, api_version: str, **kwargs: Any) -> AsyncLROPoller[None]: """Deletes a resource by ID. :param resource_id: The fully qualified ID of the resource, including the resource name and resource type. Use the format, /subscriptions/{guid}/resourceGroups/{resource-group-name}/{resource-provider-namespace}/{resource-type}/{resource-name}. + Required. :type resource_id: str - :param api_version: The API version to use for the operation. + :param api_version: The API version to use for the operation. Required. :type api_version: str :keyword callable cls: A custom type or function that will be passed the direct response :keyword str continuation_token: A continuation token to restart a poller from a saved state. @@ -5602,75 +7369,89 @@ async def begin_delete_by_id( # pylint: disable=inconsistent-return-statements Retry-After header is present. :return: An instance of AsyncLROPoller that returns either None or the result of cls(response) :rtype: ~azure.core.polling.AsyncLROPoller[None] - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - polling = kwargs.pop('polling', True) # type: Union[bool, AsyncPollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType[None] - lro_delay = kwargs.pop( - 'polling_interval', - self._config.polling_interval - ) - cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] + _headers = kwargs.pop("headers", {}) or {} + _params = kwargs.pop("params", {}) or {} + + cls = kwargs.pop("cls", None) # type: ClsType[None] + polling = kwargs.pop("polling", True) # type: Union[bool, AsyncPollingMethod] + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token = kwargs.pop("continuation_token", None) # type: Optional[str] if cont_token is None: - raw_result = await self._delete_by_id_initial( + raw_result = await self._delete_by_id_initial( # type: ignore resource_id=resource_id, api_version=api_version, - cls=lambda x,y,z: x, + cls=lambda x, y, z: x, + headers=_headers, + params=_params, **kwargs ) - kwargs.pop('error_map', None) + kwargs.pop("error_map", None) - def get_long_running_output(pipeline_response): + def get_long_running_output(pipeline_response): # pylint: disable=inconsistent-return-statements if cls: return cls(pipeline_response, None, {}) - - if polling is True: polling_method = AsyncARMPolling(lro_delay, **kwargs) - elif polling is False: polling_method = AsyncNoPolling() - else: polling_method = polling + if polling is True: + polling_method = cast(AsyncPollingMethod, AsyncARMPolling(lro_delay, **kwargs)) # type: AsyncPollingMethod + elif polling is False: + polling_method = cast(AsyncPollingMethod, AsyncNoPolling()) + else: + polling_method = polling if cont_token: return AsyncLROPoller.from_continuation_token( polling_method=polling_method, continuation_token=cont_token, client=self._client, - deserialization_callback=get_long_running_output + deserialization_callback=get_long_running_output, ) return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) - begin_delete_by_id.metadata = {'url': "/{resourceId}"} # type: ignore + begin_delete_by_id.metadata = {"url": "/{resourceId}"} # type: ignore async def _create_or_update_by_id_initial( - self, - resource_id: str, - api_version: str, - parameters: "_models.GenericResource", - **kwargs: Any - ) -> Optional["_models.GenericResource"]: - cls = kwargs.pop('cls', None) # type: ClsType[Optional["_models.GenericResource"]] + self, resource_id: str, api_version: str, parameters: Union[_models.GenericResource, IO], **kwargs: Any + ) -> Optional[_models.GenericResource]: error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = kwargs.pop("params", {}) or {} - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[Optional[_models.GenericResource]] - _json = self._serialize.body(parameters, 'GenericResource') + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(parameters, (IO, bytes)): + _content = parameters + else: + _json = self._serialize.body(parameters, "GenericResource") - request = build_resources_create_or_update_by_id_request_initial( + request = build_resources_create_or_update_by_id_request( resource_id=resource_id, - content_type=content_type, api_version=api_version, + content_type=content_type, json=_json, - template_url=self._create_or_update_by_id_initial.metadata['url'], + content=_content, + template_url=self._create_or_update_by_id_initial.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200, 201, 202]: @@ -5679,37 +7460,42 @@ async def _create_or_update_by_id_initial( deserialized = None if response.status_code == 200: - deserialized = self._deserialize('GenericResource', pipeline_response) + deserialized = self._deserialize("GenericResource", pipeline_response) if response.status_code == 201: - deserialized = self._deserialize('GenericResource', pipeline_response) + deserialized = self._deserialize("GenericResource", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - _create_or_update_by_id_initial.metadata = {'url': "/{resourceId}"} # type: ignore - + _create_or_update_by_id_initial.metadata = {"url": "/{resourceId}"} # type: ignore - @distributed_trace_async + @overload async def begin_create_or_update_by_id( self, resource_id: str, api_version: str, - parameters: "_models.GenericResource", + parameters: _models.GenericResource, + *, + content_type: str = "application/json", **kwargs: Any - ) -> AsyncLROPoller["_models.GenericResource"]: + ) -> AsyncLROPoller[_models.GenericResource]: """Create a resource by ID. :param resource_id: The fully qualified ID of the resource, including the resource name and resource type. Use the format, /subscriptions/{guid}/resourceGroups/{resource-group-name}/{resource-provider-namespace}/{resource-type}/{resource-name}. + Required. :type resource_id: str - :param api_version: The API version to use for the operation. + :param api_version: The API version to use for the operation. Required. :type api_version: str - :param parameters: Create or update resource parameters. + :param parameters: Create or update resource parameters. Required. :type parameters: ~azure.mgmt.resource.resources.v2019_10_01.models.GenericResource + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str :keyword callable cls: A custom type or function that will be passed the direct response :keyword str continuation_token: A continuation token to restart a poller from a saved state. :keyword polling: By default, your polling method will be AsyncARMPolling. Pass in False for @@ -5722,81 +7508,167 @@ async def begin_create_or_update_by_id( cls(response) :rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.resource.resources.v2019_10_01.models.GenericResource] - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] - polling = kwargs.pop('polling', True) # type: Union[bool, AsyncPollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType["_models.GenericResource"] - lro_delay = kwargs.pop( - 'polling_interval', - self._config.polling_interval - ) - cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] + + @overload + async def begin_create_or_update_by_id( + self, + resource_id: str, + api_version: str, + parameters: IO, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> AsyncLROPoller[_models.GenericResource]: + """Create a resource by ID. + + :param resource_id: The fully qualified ID of the resource, including the resource name and + resource type. Use the format, + /subscriptions/{guid}/resourceGroups/{resource-group-name}/{resource-provider-namespace}/{resource-type}/{resource-name}. + Required. + :type resource_id: str + :param api_version: The API version to use for the operation. Required. + :type api_version: str + :param parameters: Create or update resource parameters. Required. + :type parameters: IO + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be AsyncARMPolling. Pass in False for + this operation to not poll, or pass in your own initialized polling object for a personal + polling strategy. + :paramtype polling: bool or ~azure.core.polling.AsyncPollingMethod + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of AsyncLROPoller that returns either GenericResource or the result of + cls(response) + :rtype: + ~azure.core.polling.AsyncLROPoller[~azure.mgmt.resource.resources.v2019_10_01.models.GenericResource] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace_async + async def begin_create_or_update_by_id( + self, resource_id: str, api_version: str, parameters: Union[_models.GenericResource, IO], **kwargs: Any + ) -> AsyncLROPoller[_models.GenericResource]: + """Create a resource by ID. + + :param resource_id: The fully qualified ID of the resource, including the resource name and + resource type. Use the format, + /subscriptions/{guid}/resourceGroups/{resource-group-name}/{resource-provider-namespace}/{resource-type}/{resource-name}. + Required. + :type resource_id: str + :param api_version: The API version to use for the operation. Required. + :type api_version: str + :param parameters: Create or update resource parameters. Is either a model type or a IO type. + Required. + :type parameters: ~azure.mgmt.resource.resources.v2019_10_01.models.GenericResource or IO + :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. + Default value is None. + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be AsyncARMPolling. Pass in False for + this operation to not poll, or pass in your own initialized polling object for a personal + polling strategy. + :paramtype polling: bool or ~azure.core.polling.AsyncPollingMethod + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of AsyncLROPoller that returns either GenericResource or the result of + cls(response) + :rtype: + ~azure.core.polling.AsyncLROPoller[~azure.mgmt.resource.resources.v2019_10_01.models.GenericResource] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = kwargs.pop("params", {}) or {} + + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.GenericResource] + polling = kwargs.pop("polling", True) # type: Union[bool, AsyncPollingMethod] + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token = kwargs.pop("continuation_token", None) # type: Optional[str] if cont_token is None: - raw_result = await self._create_or_update_by_id_initial( + raw_result = await self._create_or_update_by_id_initial( # type: ignore resource_id=resource_id, api_version=api_version, parameters=parameters, content_type=content_type, - cls=lambda x,y,z: x, + cls=lambda x, y, z: x, + headers=_headers, + params=_params, **kwargs ) - kwargs.pop('error_map', None) + kwargs.pop("error_map", None) def get_long_running_output(pipeline_response): - response = pipeline_response.http_response - deserialized = self._deserialize('GenericResource', pipeline_response) + deserialized = self._deserialize("GenericResource", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - - if polling is True: polling_method = AsyncARMPolling(lro_delay, **kwargs) - elif polling is False: polling_method = AsyncNoPolling() - else: polling_method = polling + if polling is True: + polling_method = cast(AsyncPollingMethod, AsyncARMPolling(lro_delay, **kwargs)) # type: AsyncPollingMethod + elif polling is False: + polling_method = cast(AsyncPollingMethod, AsyncNoPolling()) + else: + polling_method = polling if cont_token: return AsyncLROPoller.from_continuation_token( polling_method=polling_method, continuation_token=cont_token, client=self._client, - deserialization_callback=get_long_running_output + deserialization_callback=get_long_running_output, ) return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) - begin_create_or_update_by_id.metadata = {'url': "/{resourceId}"} # type: ignore + begin_create_or_update_by_id.metadata = {"url": "/{resourceId}"} # type: ignore async def _update_by_id_initial( - self, - resource_id: str, - api_version: str, - parameters: "_models.GenericResource", - **kwargs: Any - ) -> Optional["_models.GenericResource"]: - cls = kwargs.pop('cls', None) # type: ClsType[Optional["_models.GenericResource"]] + self, resource_id: str, api_version: str, parameters: Union[_models.GenericResource, IO], **kwargs: Any + ) -> Optional[_models.GenericResource]: error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = kwargs.pop("params", {}) or {} - _json = self._serialize.body(parameters, 'GenericResource') + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[Optional[_models.GenericResource]] - request = build_resources_update_by_id_request_initial( + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(parameters, (IO, bytes)): + _content = parameters + else: + _json = self._serialize.body(parameters, "GenericResource") + + request = build_resources_update_by_id_request( resource_id=resource_id, - content_type=content_type, api_version=api_version, + content_type=content_type, json=_json, - template_url=self._update_by_id_initial.metadata['url'], + content=_content, + template_url=self._update_by_id_initial.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200, 202]: @@ -5805,34 +7677,39 @@ async def _update_by_id_initial( deserialized = None if response.status_code == 200: - deserialized = self._deserialize('GenericResource', pipeline_response) + deserialized = self._deserialize("GenericResource", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - _update_by_id_initial.metadata = {'url': "/{resourceId}"} # type: ignore - + _update_by_id_initial.metadata = {"url": "/{resourceId}"} # type: ignore - @distributed_trace_async + @overload async def begin_update_by_id( self, resource_id: str, api_version: str, - parameters: "_models.GenericResource", + parameters: _models.GenericResource, + *, + content_type: str = "application/json", **kwargs: Any - ) -> AsyncLROPoller["_models.GenericResource"]: + ) -> AsyncLROPoller[_models.GenericResource]: """Updates a resource by ID. :param resource_id: The fully qualified ID of the resource, including the resource name and resource type. Use the format, /subscriptions/{guid}/resourceGroups/{resource-group-name}/{resource-provider-namespace}/{resource-type}/{resource-name}. + Required. :type resource_id: str - :param api_version: The API version to use for the operation. + :param api_version: The API version to use for the operation. Required. :type api_version: str - :param parameters: Update resource parameters. + :param parameters: Update resource parameters. Required. :type parameters: ~azure.mgmt.resource.resources.v2019_10_01.models.GenericResource + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str :keyword callable cls: A custom type or function that will be passed the direct response :keyword str continuation_token: A continuation token to restart a poller from a saved state. :keyword polling: By default, your polling method will be AsyncARMPolling. Pass in False for @@ -5845,165 +7722,243 @@ async def begin_update_by_id( cls(response) :rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.resource.resources.v2019_10_01.models.GenericResource] - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] - polling = kwargs.pop('polling', True) # type: Union[bool, AsyncPollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType["_models.GenericResource"] - lro_delay = kwargs.pop( - 'polling_interval', - self._config.polling_interval - ) - cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] + + @overload + async def begin_update_by_id( + self, + resource_id: str, + api_version: str, + parameters: IO, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> AsyncLROPoller[_models.GenericResource]: + """Updates a resource by ID. + + :param resource_id: The fully qualified ID of the resource, including the resource name and + resource type. Use the format, + /subscriptions/{guid}/resourceGroups/{resource-group-name}/{resource-provider-namespace}/{resource-type}/{resource-name}. + Required. + :type resource_id: str + :param api_version: The API version to use for the operation. Required. + :type api_version: str + :param parameters: Update resource parameters. Required. + :type parameters: IO + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be AsyncARMPolling. Pass in False for + this operation to not poll, or pass in your own initialized polling object for a personal + polling strategy. + :paramtype polling: bool or ~azure.core.polling.AsyncPollingMethod + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of AsyncLROPoller that returns either GenericResource or the result of + cls(response) + :rtype: + ~azure.core.polling.AsyncLROPoller[~azure.mgmt.resource.resources.v2019_10_01.models.GenericResource] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace_async + async def begin_update_by_id( + self, resource_id: str, api_version: str, parameters: Union[_models.GenericResource, IO], **kwargs: Any + ) -> AsyncLROPoller[_models.GenericResource]: + """Updates a resource by ID. + + :param resource_id: The fully qualified ID of the resource, including the resource name and + resource type. Use the format, + /subscriptions/{guid}/resourceGroups/{resource-group-name}/{resource-provider-namespace}/{resource-type}/{resource-name}. + Required. + :type resource_id: str + :param api_version: The API version to use for the operation. Required. + :type api_version: str + :param parameters: Update resource parameters. Is either a model type or a IO type. Required. + :type parameters: ~azure.mgmt.resource.resources.v2019_10_01.models.GenericResource or IO + :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. + Default value is None. + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be AsyncARMPolling. Pass in False for + this operation to not poll, or pass in your own initialized polling object for a personal + polling strategy. + :paramtype polling: bool or ~azure.core.polling.AsyncPollingMethod + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of AsyncLROPoller that returns either GenericResource or the result of + cls(response) + :rtype: + ~azure.core.polling.AsyncLROPoller[~azure.mgmt.resource.resources.v2019_10_01.models.GenericResource] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = kwargs.pop("params", {}) or {} + + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.GenericResource] + polling = kwargs.pop("polling", True) # type: Union[bool, AsyncPollingMethod] + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token = kwargs.pop("continuation_token", None) # type: Optional[str] if cont_token is None: - raw_result = await self._update_by_id_initial( + raw_result = await self._update_by_id_initial( # type: ignore resource_id=resource_id, api_version=api_version, parameters=parameters, content_type=content_type, - cls=lambda x,y,z: x, + cls=lambda x, y, z: x, + headers=_headers, + params=_params, **kwargs ) - kwargs.pop('error_map', None) + kwargs.pop("error_map", None) def get_long_running_output(pipeline_response): - response = pipeline_response.http_response - deserialized = self._deserialize('GenericResource', pipeline_response) + deserialized = self._deserialize("GenericResource", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - - if polling is True: polling_method = AsyncARMPolling(lro_delay, **kwargs) - elif polling is False: polling_method = AsyncNoPolling() - else: polling_method = polling + if polling is True: + polling_method = cast(AsyncPollingMethod, AsyncARMPolling(lro_delay, **kwargs)) # type: AsyncPollingMethod + elif polling is False: + polling_method = cast(AsyncPollingMethod, AsyncNoPolling()) + else: + polling_method = polling if cont_token: return AsyncLROPoller.from_continuation_token( polling_method=polling_method, continuation_token=cont_token, client=self._client, - deserialization_callback=get_long_running_output + deserialization_callback=get_long_running_output, ) return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) - begin_update_by_id.metadata = {'url': "/{resourceId}"} # type: ignore + begin_update_by_id.metadata = {"url": "/{resourceId}"} # type: ignore @distributed_trace_async - async def get_by_id( - self, - resource_id: str, - api_version: str, - **kwargs: Any - ) -> "_models.GenericResource": + async def get_by_id(self, resource_id: str, api_version: str, **kwargs: Any) -> _models.GenericResource: """Gets a resource by ID. :param resource_id: The fully qualified ID of the resource, including the resource name and resource type. Use the format, /subscriptions/{guid}/resourceGroups/{resource-group-name}/{resource-provider-namespace}/{resource-type}/{resource-name}. + Required. :type resource_id: str - :param api_version: The API version to use for the operation. + :param api_version: The API version to use for the operation. Required. :type api_version: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: GenericResource, or the result of cls(response) + :return: GenericResource or the result of cls(response) :rtype: ~azure.mgmt.resource.resources.v2019_10_01.models.GenericResource - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.GenericResource"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = kwargs.pop("params", {}) or {} + + cls = kwargs.pop("cls", None) # type: ClsType[_models.GenericResource] - request = build_resources_get_by_id_request( resource_id=resource_id, api_version=api_version, - template_url=self.get_by_id.metadata['url'], + template_url=self.get_by_id.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) - deserialized = self._deserialize('GenericResource', pipeline_response) + deserialized = self._deserialize("GenericResource", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - get_by_id.metadata = {'url': "/{resourceId}"} # type: ignore + get_by_id.metadata = {"url": "/{resourceId}"} # type: ignore -class ResourceGroupsOperations: - """ResourceGroupsOperations async operations. - You should not instantiate this class directly. Instead, you should create a Client instance that - instantiates it for you and attaches it as an attribute. +class ResourceGroupsOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. - :ivar models: Alias to model classes used in this operation group. - :type models: ~azure.mgmt.resource.resources.v2019_10_01.models - :param client: Client for service requests. - :param config: Configuration of service client. - :param serializer: An object model serializer. - :param deserializer: An object model deserializer. + Instead, you should access the following operations through + :class:`~azure.mgmt.resource.resources.v2019_10_01.aio.ResourceManagementClient`'s + :attr:`resource_groups` attribute. """ models = _models - def __init__(self, client, config, serializer, deserializer) -> None: - self._client = client - self._serialize = serializer - self._deserialize = deserializer - self._config = config + def __init__(self, *args, **kwargs) -> None: + input_args = list(args) + self._client = input_args.pop(0) if input_args else kwargs.pop("client") + self._config = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") @distributed_trace_async - async def check_existence( - self, - resource_group_name: str, - **kwargs: Any - ) -> bool: + async def check_existence(self, resource_group_name: str, **kwargs: Any) -> bool: """Checks whether a resource group exists. :param resource_group_name: The name of the resource group to check. The name is case - insensitive. + insensitive. Required. :type resource_group_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: bool, or the result of cls(response) + :return: bool or the result of cls(response) :rtype: bool - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType[None] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + 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', "2019-10-01") # type: str + api_version = kwargs.pop("api_version", _params.pop("api-version", "2019-10-01")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[None] - request = build_resource_groups_check_existence_request( resource_group_name=resource_group_name, subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.check_existence.metadata['url'], + template_url=self.check_existence.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [204, 404]: @@ -6014,39 +7969,98 @@ async def check_existence( return cls(pipeline_response, None, {}) return 200 <= response.status_code <= 299 - check_existence.metadata = {'url': "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}"} # type: ignore + check_existence.metadata = {"url": "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}"} # type: ignore - - @distributed_trace_async + @overload async def create_or_update( self, resource_group_name: str, - parameters: "_models.ResourceGroup", + parameters: _models.ResourceGroup, + *, + content_type: str = "application/json", **kwargs: Any - ) -> "_models.ResourceGroup": + ) -> _models.ResourceGroup: """Creates or updates a resource group. :param resource_group_name: The name of the resource group to create or update. Can include alphanumeric, underscore, parentheses, hyphen, period (except at end), and Unicode characters - that match the allowed characters. + that match the allowed characters. Required. :type resource_group_name: str - :param parameters: Parameters supplied to the create or update a resource group. + :param parameters: Parameters supplied to the create or update a resource group. Required. :type parameters: ~azure.mgmt.resource.resources.v2019_10_01.models.ResourceGroup + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: ResourceGroup or the result of cls(response) + :rtype: ~azure.mgmt.resource.resources.v2019_10_01.models.ResourceGroup + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + async def create_or_update( + self, resource_group_name: str, parameters: IO, *, content_type: str = "application/json", **kwargs: Any + ) -> _models.ResourceGroup: + """Creates or updates a resource group. + + :param resource_group_name: The name of the resource group to create or update. Can include + alphanumeric, underscore, parentheses, hyphen, period (except at end), and Unicode characters + that match the allowed characters. Required. + :type resource_group_name: str + :param parameters: Parameters supplied to the create or update a resource group. Required. + :type parameters: IO + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: ResourceGroup, or the result of cls(response) + :return: ResourceGroup or the result of cls(response) :rtype: ~azure.mgmt.resource.resources.v2019_10_01.models.ResourceGroup - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace_async + async def create_or_update( + self, resource_group_name: str, parameters: Union[_models.ResourceGroup, IO], **kwargs: Any + ) -> _models.ResourceGroup: + """Creates or updates a resource group. + + :param resource_group_name: The name of the resource group to create or update. Can include + alphanumeric, underscore, parentheses, hyphen, period (except at end), and Unicode characters + that match the allowed characters. Required. + :type resource_group_name: str + :param parameters: Parameters supplied to the create or update a resource group. Is either a + model type or a IO type. Required. + :type parameters: ~azure.mgmt.resource.resources.v2019_10_01.models.ResourceGroup or IO + :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. + Default value is None. + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: ResourceGroup or the result of cls(response) + :rtype: ~azure.mgmt.resource.resources.v2019_10_01.models.ResourceGroup + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.ResourceGroup"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', "2019-10-01") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + api_version = kwargs.pop("api_version", _params.pop("api-version", "2019-10-01")) # type: str + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.ResourceGroup] - _json = self._serialize.body(parameters, 'ResourceGroup') + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(parameters, (IO, bytes)): + _content = parameters + else: + _json = self._serialize.body(parameters, "ResourceGroup") request = build_resource_groups_create_or_update_request( resource_group_name=resource_group_name, @@ -6054,16 +8068,18 @@ async def create_or_update( api_version=api_version, content_type=content_type, json=_json, - template_url=self.create_or_update.metadata['url'], + content=_content, + template_url=self.create_or_update.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200, 201]: @@ -6071,47 +8087,50 @@ async def create_or_update( raise HttpResponseError(response=response, error_format=ARMErrorFormat) if response.status_code == 200: - deserialized = self._deserialize('ResourceGroup', pipeline_response) + deserialized = self._deserialize("ResourceGroup", pipeline_response) if response.status_code == 201: - deserialized = self._deserialize('ResourceGroup', pipeline_response) + deserialized = self._deserialize("ResourceGroup", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - create_or_update.metadata = {'url': "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}"} # type: ignore - + create_or_update.metadata = {"url": "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}"} # type: ignore async def _delete_initial( # pylint: disable=inconsistent-return-statements - self, - resource_group_name: str, - **kwargs: Any + self, resource_group_name: str, **kwargs: Any ) -> None: - cls = kwargs.pop('cls', None) # type: ClsType[None] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + 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', "2019-10-01") # type: str + api_version = kwargs.pop("api_version", _params.pop("api-version", "2019-10-01")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[None] - - request = build_resource_groups_delete_request_initial( + request = build_resource_groups_delete_request( resource_group_name=resource_group_name, subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self._delete_initial.metadata['url'], + template_url=self._delete_initial.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200, 202]: @@ -6121,22 +8140,17 @@ async def _delete_initial( # pylint: disable=inconsistent-return-statements if cls: return cls(pipeline_response, None, {}) - _delete_initial.metadata = {'url': "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}"} # type: ignore - + _delete_initial.metadata = {"url": "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}"} # type: ignore @distributed_trace_async - async def begin_delete( # pylint: disable=inconsistent-return-statements - self, - resource_group_name: str, - **kwargs: Any - ) -> AsyncLROPoller[None]: + async def begin_delete(self, resource_group_name: str, **kwargs: Any) -> AsyncLROPoller[None]: """Deletes a resource group. When you delete a resource group, all of its resources are also deleted. Deleting a resource group deletes all of its template deployments and currently stored operations. :param resource_group_name: The name of the resource group to delete. The name is case - insensitive. + insensitive. Required. :type resource_group_name: str :keyword callable cls: A custom type or function that will be passed the direct response :keyword str continuation_token: A continuation token to restart a poller from a saved state. @@ -6148,106 +8162,113 @@ async def begin_delete( # pylint: disable=inconsistent-return-statements Retry-After header is present. :return: An instance of AsyncLROPoller that returns either None or the result of cls(response) :rtype: ~azure.core.polling.AsyncLROPoller[None] - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - api_version = kwargs.pop('api_version', "2019-10-01") # type: str - polling = kwargs.pop('polling', True) # type: Union[bool, AsyncPollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType[None] - lro_delay = kwargs.pop( - 'polling_interval', - self._config.polling_interval - ) - cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2019-10-01")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[None] + polling = kwargs.pop("polling", True) # type: Union[bool, AsyncPollingMethod] + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token = kwargs.pop("continuation_token", None) # type: Optional[str] if cont_token is None: - raw_result = await self._delete_initial( + raw_result = await self._delete_initial( # type: ignore resource_group_name=resource_group_name, api_version=api_version, - cls=lambda x,y,z: x, + cls=lambda x, y, z: x, + headers=_headers, + params=_params, **kwargs ) - kwargs.pop('error_map', None) + kwargs.pop("error_map", None) - def get_long_running_output(pipeline_response): + def get_long_running_output(pipeline_response): # pylint: disable=inconsistent-return-statements if cls: return cls(pipeline_response, None, {}) - - if polling is True: polling_method = AsyncARMPolling(lro_delay, **kwargs) - elif polling is False: polling_method = AsyncNoPolling() - else: polling_method = polling + if polling is True: + polling_method = cast(AsyncPollingMethod, AsyncARMPolling(lro_delay, **kwargs)) # type: AsyncPollingMethod + elif polling is False: + polling_method = cast(AsyncPollingMethod, AsyncNoPolling()) + else: + polling_method = polling if cont_token: return AsyncLROPoller.from_continuation_token( polling_method=polling_method, continuation_token=cont_token, client=self._client, - deserialization_callback=get_long_running_output + deserialization_callback=get_long_running_output, ) return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) - begin_delete.metadata = {'url': "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}"} # type: ignore + begin_delete.metadata = {"url": "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}"} # type: ignore @distributed_trace_async - async def get( - self, - resource_group_name: str, - **kwargs: Any - ) -> "_models.ResourceGroup": + async def get(self, resource_group_name: str, **kwargs: Any) -> _models.ResourceGroup: """Gets a resource group. :param resource_group_name: The name of the resource group to get. The name is case - insensitive. + insensitive. Required. :type resource_group_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: ResourceGroup, or the result of cls(response) + :return: ResourceGroup or the result of cls(response) :rtype: ~azure.mgmt.resource.resources.v2019_10_01.models.ResourceGroup - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.ResourceGroup"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + 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', "2019-10-01") # type: str + api_version = kwargs.pop("api_version", _params.pop("api-version", "2019-10-01")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[_models.ResourceGroup] - request = build_resource_groups_get_request( resource_group_name=resource_group_name, subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.get.metadata['url'], + template_url=self.get.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) - deserialized = self._deserialize('ResourceGroup', pipeline_response) + deserialized = self._deserialize("ResourceGroup", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - get.metadata = {'url': "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}"} # type: ignore + get.metadata = {"url": "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}"} # type: ignore - - @distributed_trace_async + @overload async def update( self, resource_group_name: str, - parameters: "_models.ResourceGroupPatchable", + parameters: _models.ResourceGroupPatchable, + *, + content_type: str = "application/json", **kwargs: Any - ) -> "_models.ResourceGroup": + ) -> _models.ResourceGroup: """Updates a resource group. Resource groups can be updated through a simple PATCH operation to a group address. The format @@ -6255,25 +8276,90 @@ async def update( the current value is retained. :param resource_group_name: The name of the resource group to update. The name is case - insensitive. + insensitive. Required. :type resource_group_name: str - :param parameters: Parameters supplied to update a resource group. + :param parameters: Parameters supplied to update a resource group. Required. :type parameters: ~azure.mgmt.resource.resources.v2019_10_01.models.ResourceGroupPatchable + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: ResourceGroup, or the result of cls(response) + :return: ResourceGroup or the result of cls(response) :rtype: ~azure.mgmt.resource.resources.v2019_10_01.models.ResourceGroup - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + async def update( + self, resource_group_name: str, parameters: IO, *, content_type: str = "application/json", **kwargs: Any + ) -> _models.ResourceGroup: + """Updates a resource group. + + Resource groups can be updated through a simple PATCH operation to a group address. The format + of the request is the same as that for creating a resource group. If a field is unspecified, + the current value is retained. + + :param resource_group_name: The name of the resource group to update. The name is case + insensitive. Required. + :type resource_group_name: str + :param parameters: Parameters supplied to update a resource group. Required. + :type parameters: IO + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: ResourceGroup or the result of cls(response) + :rtype: ~azure.mgmt.resource.resources.v2019_10_01.models.ResourceGroup + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace_async + async def update( + self, resource_group_name: str, parameters: Union[_models.ResourceGroupPatchable, IO], **kwargs: Any + ) -> _models.ResourceGroup: + """Updates a resource group. + + Resource groups can be updated through a simple PATCH operation to a group address. The format + of the request is the same as that for creating a resource group. If a field is unspecified, + the current value is retained. + + :param resource_group_name: The name of the resource group to update. The name is case + insensitive. Required. + :type resource_group_name: str + :param parameters: Parameters supplied to update a resource group. Is either a model type or a + IO type. Required. + :type parameters: ~azure.mgmt.resource.resources.v2019_10_01.models.ResourceGroupPatchable or + IO + :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. + Default value is None. + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: ResourceGroup or the result of cls(response) + :rtype: ~azure.mgmt.resource.resources.v2019_10_01.models.ResourceGroup + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.ResourceGroup"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) - api_version = kwargs.pop('api_version', "2019-10-01") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - _json = self._serialize.body(parameters, 'ResourceGroupPatchable') + api_version = kwargs.pop("api_version", _params.pop("api-version", "2019-10-01")) # type: str + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.ResourceGroup] + + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(parameters, (IO, bytes)): + _content = parameters + else: + _json = self._serialize.body(parameters, "ResourceGroupPatchable") request = build_resource_groups_update_request( resource_group_name=resource_group_name, @@ -6281,65 +8367,77 @@ async def update( api_version=api_version, content_type=content_type, json=_json, - template_url=self.update.metadata['url'], + content=_content, + template_url=self.update.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) - deserialized = self._deserialize('ResourceGroup', pipeline_response) + deserialized = self._deserialize("ResourceGroup", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - update.metadata = {'url': "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}"} # type: ignore - + update.metadata = {"url": "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}"} # type: ignore async def _export_template_initial( - self, - resource_group_name: str, - parameters: "_models.ExportTemplateRequest", - **kwargs: Any - ) -> Optional["_models.ResourceGroupExportResult"]: - cls = kwargs.pop('cls', None) # type: ClsType[Optional["_models.ResourceGroupExportResult"]] + self, resource_group_name: str, parameters: Union[_models.ExportTemplateRequest, IO], **kwargs: Any + ) -> Optional[_models.ResourceGroupExportResult]: error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) - api_version = kwargs.pop('api_version', "2019-10-01") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - _json = self._serialize.body(parameters, 'ExportTemplateRequest') + api_version = kwargs.pop("api_version", _params.pop("api-version", "2019-10-01")) # type: str + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[Optional[_models.ResourceGroupExportResult]] - request = build_resource_groups_export_template_request_initial( - subscription_id=self._config.subscription_id, + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(parameters, (IO, bytes)): + _content = parameters + else: + _json = self._serialize.body(parameters, "ExportTemplateRequest") + + request = build_resource_groups_export_template_request( resource_group_name=resource_group_name, + subscription_id=self._config.subscription_id, api_version=api_version, content_type=content_type, json=_json, - template_url=self._export_template_initial.metadata['url'], + content=_content, + template_url=self._export_template_initial.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200, 202]: @@ -6348,29 +8446,93 @@ async def _export_template_initial( deserialized = None if response.status_code == 200: - deserialized = self._deserialize('ResourceGroupExportResult', pipeline_response) + deserialized = self._deserialize("ResourceGroupExportResult", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - _export_template_initial.metadata = {'url': "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/exportTemplate"} # type: ignore - + _export_template_initial.metadata = {"url": "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/exportTemplate"} # type: ignore - @distributed_trace_async + @overload async def begin_export_template( self, resource_group_name: str, - parameters: "_models.ExportTemplateRequest", + parameters: _models.ExportTemplateRequest, + *, + content_type: str = "application/json", **kwargs: Any - ) -> AsyncLROPoller["_models.ResourceGroupExportResult"]: + ) -> AsyncLROPoller[_models.ResourceGroupExportResult]: + """Captures the specified resource group as a template. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param parameters: Parameters for exporting the template. Required. + :type parameters: ~azure.mgmt.resource.resources.v2019_10_01.models.ExportTemplateRequest + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be AsyncARMPolling. Pass in False for + this operation to not poll, or pass in your own initialized polling object for a personal + polling strategy. + :paramtype polling: bool or ~azure.core.polling.AsyncPollingMethod + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of AsyncLROPoller that returns either ResourceGroupExportResult or the + result of cls(response) + :rtype: + ~azure.core.polling.AsyncLROPoller[~azure.mgmt.resource.resources.v2019_10_01.models.ResourceGroupExportResult] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + async def begin_export_template( + self, resource_group_name: str, parameters: IO, *, content_type: str = "application/json", **kwargs: Any + ) -> AsyncLROPoller[_models.ResourceGroupExportResult]: + """Captures the specified resource group as a template. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param parameters: Parameters for exporting the template. Required. + :type parameters: IO + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be AsyncARMPolling. Pass in False for + this operation to not poll, or pass in your own initialized polling object for a personal + polling strategy. + :paramtype polling: bool or ~azure.core.polling.AsyncPollingMethod + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of AsyncLROPoller that returns either ResourceGroupExportResult or the + result of cls(response) + :rtype: + ~azure.core.polling.AsyncLROPoller[~azure.mgmt.resource.resources.v2019_10_01.models.ResourceGroupExportResult] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace_async + async def begin_export_template( + self, resource_group_name: str, parameters: Union[_models.ExportTemplateRequest, IO], **kwargs: Any + ) -> AsyncLROPoller[_models.ResourceGroupExportResult]: """Captures the specified resource group as a template. :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. :type resource_group_name: str - :param parameters: Parameters for exporting the template. - :type parameters: ~azure.mgmt.resource.resources.v2019_10_01.models.ExportTemplateRequest + :param parameters: Parameters for exporting the template. Is either a model type or a IO type. + Required. + :type parameters: ~azure.mgmt.resource.resources.v2019_10_01.models.ExportTemplateRequest or IO + :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. + Default value is None. + :paramtype content_type: str :keyword callable cls: A custom type or function that will be passed the direct response :keyword str continuation_token: A continuation token to restart a poller from a saved state. :keyword polling: By default, your polling method will be AsyncARMPolling. Pass in False for @@ -6383,57 +8545,59 @@ async def begin_export_template( result of cls(response) :rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.resource.resources.v2019_10_01.models.ResourceGroupExportResult] - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - api_version = kwargs.pop('api_version', "2019-10-01") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] - polling = kwargs.pop('polling', True) # type: Union[bool, AsyncPollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType["_models.ResourceGroupExportResult"] - lro_delay = kwargs.pop( - 'polling_interval', - self._config.polling_interval - ) - cont_token = kwargs.pop('continuation_token', None) # type: Optional[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", "2019-10-01")) # type: str + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.ResourceGroupExportResult] + polling = kwargs.pop("polling", True) # type: Union[bool, AsyncPollingMethod] + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token = kwargs.pop("continuation_token", None) # type: Optional[str] if cont_token is None: - raw_result = await self._export_template_initial( + raw_result = await self._export_template_initial( # type: ignore resource_group_name=resource_group_name, parameters=parameters, api_version=api_version, content_type=content_type, - cls=lambda x,y,z: x, + cls=lambda x, y, z: x, + headers=_headers, + params=_params, **kwargs ) - kwargs.pop('error_map', None) + kwargs.pop("error_map", None) def get_long_running_output(pipeline_response): - response = pipeline_response.http_response - deserialized = self._deserialize('ResourceGroupExportResult', pipeline_response) + deserialized = self._deserialize("ResourceGroupExportResult", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - - if polling is True: polling_method = AsyncARMPolling(lro_delay, lro_options={'final-state-via': 'location'}, **kwargs) - elif polling is False: polling_method = AsyncNoPolling() - else: polling_method = polling + if polling is True: + polling_method = cast( + AsyncPollingMethod, AsyncARMPolling(lro_delay, lro_options={"final-state-via": "location"}, **kwargs) + ) # type: AsyncPollingMethod + elif polling is False: + polling_method = cast(AsyncPollingMethod, AsyncNoPolling()) + else: + polling_method = polling if cont_token: return AsyncLROPoller.from_continuation_token( polling_method=polling_method, continuation_token=cont_token, client=self._client, - deserialization_callback=get_long_running_output + deserialization_callback=get_long_running_output, ) return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) - begin_export_template.metadata = {'url': "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/exportTemplate"} # type: ignore + begin_export_template.metadata = {"url": "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/exportTemplate"} # type: ignore @distributed_trace def list( - self, - filter: Optional[str] = None, - top: Optional[int] = None, - **kwargs: Any - ) -> AsyncIterable["_models.ResourceGroupListResult"]: + self, filter: Optional[str] = None, top: Optional[int] = None, **kwargs: Any + ) -> AsyncIterable["_models.ResourceGroup"]: """Gets all the resource groups for a subscription. :param filter: The filter to apply on the operation.:code:`
`:code:`
`You can filter by @@ -6444,40 +8608,48 @@ def list( Default value is None. :type top: int :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either ResourceGroupListResult or the result of - cls(response) + :return: An iterator like instance of either ResourceGroup or the result of cls(response) :rtype: - ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.resource.resources.v2019_10_01.models.ResourceGroupListResult] - :raises: ~azure.core.exceptions.HttpResponseError + ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.resource.resources.v2019_10_01.models.ResourceGroup] + :raises ~azure.core.exceptions.HttpResponseError: """ - api_version = kwargs.pop('api_version', "2019-10-01") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2019-10-01")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[_models.ResourceGroupListResult] - cls = kwargs.pop('cls', None) # type: ClsType["_models.ResourceGroupListResult"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) + def prepare_request(next_link=None): if not next_link: - + request = build_resource_groups_list_request( subscription_id=self._config.subscription_id, - api_version=api_version, filter=filter, top=top, - template_url=self.list.metadata['url'], + 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.url = self._client.format_url(request.url) # type: ignore else: - - request = build_resource_groups_list_request( - subscription_id=self._config.subscription_id, - template_url=next_link, - ) + # make call to next link with the client's api-version + _parsed_next_link = urlparse(next_link) + _next_request_params = case_insensitive_dict(parse_qs(_parsed_next_link.query)) + _next_request_params["api-version"] = self._config.api_version + request = HttpRequest("GET", urljoin(next_link, _parsed_next_link.path), params=_next_request_params) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore request.method = "GET" return request @@ -6491,10 +8663,8 @@ async def extract_data(pipeline_response): async def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) response = pipeline_response.http_response @@ -6504,39 +8674,33 @@ async def get_next(next_link=None): return pipeline_response + return AsyncItemPaged(get_next, extract_data) - return AsyncItemPaged( - get_next, extract_data - ) - list.metadata = {'url': "/subscriptions/{subscriptionId}/resourcegroups"} # type: ignore -class TagsOperations: - """TagsOperations async operations. + list.metadata = {"url": "/subscriptions/{subscriptionId}/resourcegroups"} # type: ignore - You should not instantiate this class directly. Instead, you should create a Client instance that - instantiates it for you and attaches it as an attribute. - :ivar models: Alias to model classes used in this operation group. - :type models: ~azure.mgmt.resource.resources.v2019_10_01.models - :param client: Client for service requests. - :param config: Configuration of service client. - :param serializer: An object model serializer. - :param deserializer: An object model deserializer. +class TagsOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. + + Instead, you should access the following operations through + :class:`~azure.mgmt.resource.resources.v2019_10_01.aio.ResourceManagementClient`'s + :attr:`tags` attribute. """ models = _models - def __init__(self, client, config, serializer, deserializer) -> None: - self._client = client - self._serialize = serializer - self._deserialize = deserializer - self._config = config + def __init__(self, *args, **kwargs) -> None: + input_args = list(args) + self._client = input_args.pop(0) if input_args else kwargs.pop("client") + self._config = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") @distributed_trace_async async def delete_value( # pylint: disable=inconsistent-return-statements - self, - tag_name: str, - tag_value: str, - **kwargs: Any + self, tag_name: str, tag_value: str, **kwargs: Any ) -> None: """Deletes a predefined tag value for a predefined tag name. @@ -6544,39 +8708,45 @@ async def delete_value( # pylint: disable=inconsistent-return-statements predefined tag name. The value being deleted must not be in use as a tag value for the given tag name for any resource. - :param tag_name: The name of the tag. + :param tag_name: The name of the tag. Required. :type tag_name: str - :param tag_value: The value of the tag to delete. + :param tag_value: The value of the tag to delete. Required. :type tag_value: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: None, or the result of cls(response) + :return: None or the result of cls(response) :rtype: None - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType[None] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + 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', "2019-10-01") # type: str + api_version = kwargs.pop("api_version", _params.pop("api-version", "2019-10-01")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[None] - request = build_tags_delete_value_request( tag_name=tag_name, tag_value=tag_value, subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.delete_value.metadata['url'], + template_url=self.delete_value.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200, 204]: @@ -6586,54 +8756,54 @@ async def delete_value( # pylint: disable=inconsistent-return-statements if cls: return cls(pipeline_response, None, {}) - delete_value.metadata = {'url': "/subscriptions/{subscriptionId}/tagNames/{tagName}/tagValues/{tagValue}"} # type: ignore - + delete_value.metadata = {"url": "/subscriptions/{subscriptionId}/tagNames/{tagName}/tagValues/{tagValue}"} # type: ignore @distributed_trace_async - async def create_or_update_value( - self, - tag_name: str, - tag_value: str, - **kwargs: Any - ) -> "_models.TagValue": + async def create_or_update_value(self, tag_name: str, tag_value: str, **kwargs: Any) -> _models.TagValue: """Creates a predefined value for a predefined tag name. This operation allows adding a value to the list of predefined values for an existing predefined tag name. A tag value can have a maximum of 256 characters. - :param tag_name: The name of the tag. + :param tag_name: The name of the tag. Required. :type tag_name: str - :param tag_value: The value of the tag to create. + :param tag_value: The value of the tag to create. Required. :type tag_value: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: TagValue, or the result of cls(response) + :return: TagValue or the result of cls(response) :rtype: ~azure.mgmt.resource.resources.v2019_10_01.models.TagValue - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.TagValue"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) - api_version = kwargs.pop('api_version', "2019-10-01") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2019-10-01")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[_models.TagValue] - request = build_tags_create_or_update_value_request( tag_name=tag_name, tag_value=tag_value, subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.create_or_update_value.metadata['url'], + template_url=self.create_or_update_value.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200, 201]: @@ -6641,25 +8811,20 @@ async def create_or_update_value( raise HttpResponseError(response=response, error_format=ARMErrorFormat) if response.status_code == 200: - deserialized = self._deserialize('TagValue', pipeline_response) + deserialized = self._deserialize("TagValue", pipeline_response) if response.status_code == 201: - deserialized = self._deserialize('TagValue', pipeline_response) + deserialized = self._deserialize("TagValue", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - create_or_update_value.metadata = {'url': "/subscriptions/{subscriptionId}/tagNames/{tagName}/tagValues/{tagValue}"} # type: ignore - + create_or_update_value.metadata = {"url": "/subscriptions/{subscriptionId}/tagNames/{tagName}/tagValues/{tagValue}"} # type: ignore @distributed_trace_async - async def create_or_update( - self, - tag_name: str, - **kwargs: Any - ) -> "_models.TagDetails": + async def create_or_update(self, tag_name: str, **kwargs: Any) -> _models.TagDetails: """Creates a predefined tag name. This operation allows adding a name to the list of predefined tag names for the given @@ -6667,36 +8832,42 @@ async def create_or_update( names cannot have the following prefixes which are reserved for Azure use: 'microsoft', 'azure', 'windows'. - :param tag_name: The name of the tag to create. + :param tag_name: The name of the tag to create. Required. :type tag_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: TagDetails, or the result of cls(response) + :return: TagDetails or the result of cls(response) :rtype: ~azure.mgmt.resource.resources.v2019_10_01.models.TagDetails - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.TagDetails"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) - api_version = kwargs.pop('api_version', "2019-10-01") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2019-10-01")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[_models.TagDetails] - request = build_tags_create_or_update_request( tag_name=tag_name, subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.create_or_update.metadata['url'], + template_url=self.create_or_update.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200, 201]: @@ -6704,61 +8875,62 @@ async def create_or_update( raise HttpResponseError(response=response, error_format=ARMErrorFormat) if response.status_code == 200: - deserialized = self._deserialize('TagDetails', pipeline_response) + deserialized = self._deserialize("TagDetails", pipeline_response) if response.status_code == 201: - deserialized = self._deserialize('TagDetails', pipeline_response) + deserialized = self._deserialize("TagDetails", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - create_or_update.metadata = {'url': "/subscriptions/{subscriptionId}/tagNames/{tagName}"} # type: ignore - + create_or_update.metadata = {"url": "/subscriptions/{subscriptionId}/tagNames/{tagName}"} # type: ignore @distributed_trace_async - async def delete( # pylint: disable=inconsistent-return-statements - self, - tag_name: str, - **kwargs: Any - ) -> None: + async def delete(self, tag_name: str, **kwargs: Any) -> None: # pylint: disable=inconsistent-return-statements """Deletes a predefined tag name. This operation allows deleting a name from the list of predefined tag names for the given subscription. The name being deleted must not be in use as a tag name for any resource. All predefined values for the given name must have already been deleted. - :param tag_name: The name of the tag. + :param tag_name: The name of the tag. Required. :type tag_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: None, or the result of cls(response) + :return: None or the result of cls(response) :rtype: None - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType[None] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) - api_version = kwargs.pop('api_version', "2019-10-01") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2019-10-01")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[None] - request = build_tags_delete_request( tag_name=tag_name, subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.delete.metadata['url'], + template_url=self.delete.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200, 204]: @@ -6768,14 +8940,10 @@ async def delete( # pylint: disable=inconsistent-return-statements if cls: return cls(pipeline_response, None, {}) - delete.metadata = {'url': "/subscriptions/{subscriptionId}/tagNames/{tagName}"} # type: ignore - + delete.metadata = {"url": "/subscriptions/{subscriptionId}/tagNames/{tagName}"} # type: ignore @distributed_trace - def list( - self, - **kwargs: Any - ) -> AsyncIterable["_models.TagsListResult"]: + def list(self, **kwargs: Any) -> AsyncIterable["_models.TagDetails"]: """Gets a summary of tag usage under the subscription. This operation performs a union of predefined tags, resource tags, resource group tags and @@ -6784,37 +8952,46 @@ def list( result. :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either TagsListResult or the result of cls(response) + :return: An iterator like instance of either TagDetails or the result of cls(response) :rtype: - ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.resource.resources.v2019_10_01.models.TagsListResult] - :raises: ~azure.core.exceptions.HttpResponseError + ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.resource.resources.v2019_10_01.models.TagDetails] + :raises ~azure.core.exceptions.HttpResponseError: """ - api_version = kwargs.pop('api_version', "2019-10-01") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2019-10-01")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[_models.TagsListResult] - cls = kwargs.pop('cls', None) # type: ClsType["_models.TagsListResult"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) + def prepare_request(next_link=None): if not next_link: - + request = build_tags_list_request( subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.list.metadata['url'], + template_url=self.list.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore else: - - request = build_tags_list_request( - subscription_id=self._config.subscription_id, - template_url=next_link, - ) + # make call to next link with the client's api-version + _parsed_next_link = urlparse(next_link) + _next_request_params = case_insensitive_dict(parse_qs(_parsed_next_link.query)) + _next_request_params["api-version"] = self._config.api_version + request = HttpRequest("GET", urljoin(next_link, _parsed_next_link.path), params=_next_request_params) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore request.method = "GET" return request @@ -6828,10 +9005,8 @@ async def extract_data(pipeline_response): async def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) response = pipeline_response.http_response @@ -6841,82 +9016,139 @@ async def get_next(next_link=None): return pipeline_response + return AsyncItemPaged(get_next, extract_data) - return AsyncItemPaged( - get_next, extract_data - ) - list.metadata = {'url': "/subscriptions/{subscriptionId}/tagNames"} # type: ignore + list.metadata = {"url": "/subscriptions/{subscriptionId}/tagNames"} # type: ignore - @distributed_trace_async + @overload async def create_or_update_at_scope( - self, - scope: str, - parameters: "_models.TagsResource", - **kwargs: Any - ) -> "_models.TagsResource": + self, scope: str, parameters: _models.TagsResource, *, content_type: str = "application/json", **kwargs: Any + ) -> _models.TagsResource: """Creates or updates the entire set of tags on a resource or subscription. This operation allows adding or replacing the entire set of tags on the specified resource or subscription. The specified entity can have a maximum of 50 tags. - :param scope: The resource scope. + :param scope: The resource scope. Required. :type scope: str - :param parameters: + :param parameters: Required. :type parameters: ~azure.mgmt.resource.resources.v2019_10_01.models.TagsResource + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: TagsResource or the result of cls(response) + :rtype: ~azure.mgmt.resource.resources.v2019_10_01.models.TagsResource + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + async def create_or_update_at_scope( + self, scope: str, parameters: IO, *, content_type: str = "application/json", **kwargs: Any + ) -> _models.TagsResource: + """Creates or updates the entire set of tags on a resource or subscription. + + This operation allows adding or replacing the entire set of tags on the specified resource or + subscription. The specified entity can have a maximum of 50 tags. + + :param scope: The resource scope. Required. + :type scope: str + :param parameters: Required. + :type parameters: IO + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: TagsResource or the result of cls(response) + :rtype: ~azure.mgmt.resource.resources.v2019_10_01.models.TagsResource + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace_async + async def create_or_update_at_scope( + self, scope: str, parameters: Union[_models.TagsResource, IO], **kwargs: Any + ) -> _models.TagsResource: + """Creates or updates the entire set of tags on a resource or subscription. + + This operation allows adding or replacing the entire set of tags on the specified resource or + subscription. The specified entity can have a maximum of 50 tags. + + :param scope: The resource scope. Required. + :type scope: str + :param parameters: Is either a model type or a IO type. Required. + :type parameters: ~azure.mgmt.resource.resources.v2019_10_01.models.TagsResource or IO + :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. + Default value is None. + :paramtype content_type: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: TagsResource, or the result of cls(response) + :return: TagsResource or the result of cls(response) :rtype: ~azure.mgmt.resource.resources.v2019_10_01.models.TagsResource - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.TagsResource"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) - api_version = kwargs.pop('api_version', "2019-10-01") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - _json = self._serialize.body(parameters, 'TagsResource') + api_version = kwargs.pop("api_version", _params.pop("api-version", "2019-10-01")) # type: str + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.TagsResource] + + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(parameters, (IO, bytes)): + _content = parameters + else: + _json = self._serialize.body(parameters, "TagsResource") request = build_tags_create_or_update_at_scope_request( scope=scope, api_version=api_version, content_type=content_type, json=_json, - template_url=self.create_or_update_at_scope.metadata['url'], + content=_content, + template_url=self.create_or_update_at_scope.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) - deserialized = self._deserialize('TagsResource', pipeline_response) + deserialized = self._deserialize("TagsResource", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - create_or_update_at_scope.metadata = {'url': "/{scope}/providers/Microsoft.Resources/tags/default"} # type: ignore + create_or_update_at_scope.metadata = {"url": "/{scope}/providers/Microsoft.Resources/tags/default"} # type: ignore - - @distributed_trace_async + @overload async def update_at_scope( self, scope: str, - parameters: "_models.TagsPatchResource", + parameters: _models.TagsPatchResource, + *, + content_type: str = "application/json", **kwargs: Any - ) -> "_models.TagsResource": + ) -> _models.TagsResource: """Selectively updates the set of tags on a resource or subscription. This operation allows replacing, merging or selectively deleting tags on the specified resource @@ -6926,151 +9158,224 @@ async def update_at_scope( names. The 'delete' option allows selectively deleting tags based on given names or name/value pairs. - :param scope: The resource scope. + :param scope: The resource scope. Required. :type scope: str - :param parameters: + :param parameters: Required. :type parameters: ~azure.mgmt.resource.resources.v2019_10_01.models.TagsPatchResource + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: TagsResource or the result of cls(response) + :rtype: ~azure.mgmt.resource.resources.v2019_10_01.models.TagsResource + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + async def update_at_scope( + self, scope: str, parameters: IO, *, content_type: str = "application/json", **kwargs: Any + ) -> _models.TagsResource: + """Selectively updates the set of tags on a resource or subscription. + + This operation allows replacing, merging or selectively deleting tags on the specified resource + or subscription. The specified entity can have a maximum of 50 tags at the end of the + operation. The 'replace' option replaces the entire set of existing tags with a new set. The + 'merge' option allows adding tags with new names and updating the values of tags with existing + names. The 'delete' option allows selectively deleting tags based on given names or name/value + pairs. + + :param scope: The resource scope. Required. + :type scope: str + :param parameters: Required. + :type parameters: IO + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: TagsResource or the result of cls(response) + :rtype: ~azure.mgmt.resource.resources.v2019_10_01.models.TagsResource + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace_async + async def update_at_scope( + self, scope: str, parameters: Union[_models.TagsPatchResource, IO], **kwargs: Any + ) -> _models.TagsResource: + """Selectively updates the set of tags on a resource or subscription. + + This operation allows replacing, merging or selectively deleting tags on the specified resource + or subscription. The specified entity can have a maximum of 50 tags at the end of the + operation. The 'replace' option replaces the entire set of existing tags with a new set. The + 'merge' option allows adding tags with new names and updating the values of tags with existing + names. The 'delete' option allows selectively deleting tags based on given names or name/value + pairs. + + :param scope: The resource scope. Required. + :type scope: str + :param parameters: Is either a model type or a IO type. Required. + :type parameters: ~azure.mgmt.resource.resources.v2019_10_01.models.TagsPatchResource or IO + :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. + Default value is None. + :paramtype content_type: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: TagsResource, or the result of cls(response) + :return: TagsResource or the result of cls(response) :rtype: ~azure.mgmt.resource.resources.v2019_10_01.models.TagsResource - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.TagsResource"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) - api_version = kwargs.pop('api_version', "2019-10-01") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - _json = self._serialize.body(parameters, 'TagsPatchResource') + api_version = kwargs.pop("api_version", _params.pop("api-version", "2019-10-01")) # type: str + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.TagsResource] + + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(parameters, (IO, bytes)): + _content = parameters + else: + _json = self._serialize.body(parameters, "TagsPatchResource") request = build_tags_update_at_scope_request( scope=scope, api_version=api_version, content_type=content_type, json=_json, - template_url=self.update_at_scope.metadata['url'], + content=_content, + template_url=self.update_at_scope.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) - deserialized = self._deserialize('TagsResource', pipeline_response) + deserialized = self._deserialize("TagsResource", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - update_at_scope.metadata = {'url': "/{scope}/providers/Microsoft.Resources/tags/default"} # type: ignore - + update_at_scope.metadata = {"url": "/{scope}/providers/Microsoft.Resources/tags/default"} # type: ignore @distributed_trace_async - async def get_at_scope( - self, - scope: str, - **kwargs: Any - ) -> "_models.TagsResource": + async def get_at_scope(self, scope: str, **kwargs: Any) -> _models.TagsResource: """Gets the entire set of tags on a resource or subscription. Gets the entire set of tags on a resource or subscription. - :param scope: The resource scope. + :param scope: The resource scope. Required. :type scope: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: TagsResource, or the result of cls(response) + :return: TagsResource or the result of cls(response) :rtype: ~azure.mgmt.resource.resources.v2019_10_01.models.TagsResource - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.TagsResource"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + 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', "2019-10-01") # type: str + api_version = kwargs.pop("api_version", _params.pop("api-version", "2019-10-01")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[_models.TagsResource] - request = build_tags_get_at_scope_request( scope=scope, api_version=api_version, - template_url=self.get_at_scope.metadata['url'], + template_url=self.get_at_scope.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) - deserialized = self._deserialize('TagsResource', pipeline_response) + deserialized = self._deserialize("TagsResource", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - get_at_scope.metadata = {'url': "/{scope}/providers/Microsoft.Resources/tags/default"} # type: ignore - + get_at_scope.metadata = {"url": "/{scope}/providers/Microsoft.Resources/tags/default"} # type: ignore @distributed_trace_async async def delete_at_scope( # pylint: disable=inconsistent-return-statements - self, - scope: str, - **kwargs: Any + self, scope: str, **kwargs: Any ) -> None: """Deletes the entire set of tags on a resource or subscription. Deletes the entire set of tags on a resource or subscription. - :param scope: The resource scope. + :param scope: The resource scope. Required. :type scope: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: None, or the result of cls(response) + :return: None or the result of cls(response) :rtype: None - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType[None] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + 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', "2019-10-01") # type: str + api_version = kwargs.pop("api_version", _params.pop("api-version", "2019-10-01")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[None] - request = build_tags_delete_at_scope_request( scope=scope, api_version=api_version, - template_url=self.delete_at_scope.metadata['url'], + template_url=self.delete_at_scope.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200]: @@ -7080,143 +9385,145 @@ async def delete_at_scope( # pylint: disable=inconsistent-return-statements if cls: return cls(pipeline_response, None, {}) - delete_at_scope.metadata = {'url': "/{scope}/providers/Microsoft.Resources/tags/default"} # type: ignore + delete_at_scope.metadata = {"url": "/{scope}/providers/Microsoft.Resources/tags/default"} # type: ignore -class DeploymentOperationsOperations: - """DeploymentOperationsOperations async operations. - You should not instantiate this class directly. Instead, you should create a Client instance that - instantiates it for you and attaches it as an attribute. +class DeploymentOperationsOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. - :ivar models: Alias to model classes used in this operation group. - :type models: ~azure.mgmt.resource.resources.v2019_10_01.models - :param client: Client for service requests. - :param config: Configuration of service client. - :param serializer: An object model serializer. - :param deserializer: An object model deserializer. + Instead, you should access the following operations through + :class:`~azure.mgmt.resource.resources.v2019_10_01.aio.ResourceManagementClient`'s + :attr:`deployment_operations` attribute. """ models = _models - def __init__(self, client, config, serializer, deserializer) -> None: - self._client = client - self._serialize = serializer - self._deserialize = deserializer - self._config = config + def __init__(self, *args, **kwargs) -> None: + input_args = list(args) + self._client = input_args.pop(0) if input_args else kwargs.pop("client") + self._config = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") @distributed_trace_async async def get_at_scope( - self, - scope: str, - deployment_name: str, - operation_id: str, - **kwargs: Any - ) -> "_models.DeploymentOperation": + self, scope: str, deployment_name: str, operation_id: str, **kwargs: Any + ) -> _models.DeploymentOperation: """Gets a deployments operation. - :param scope: The resource scope. + :param scope: The resource scope. Required. :type scope: str - :param deployment_name: The name of the deployment. + :param deployment_name: The name of the deployment. Required. :type deployment_name: str - :param operation_id: The ID of the operation to get. + :param operation_id: The ID of the operation to get. Required. :type operation_id: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: DeploymentOperation, or the result of cls(response) + :return: DeploymentOperation or the result of cls(response) :rtype: ~azure.mgmt.resource.resources.v2019_10_01.models.DeploymentOperation - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.DeploymentOperation"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) - api_version = kwargs.pop('api_version', "2019-10-01") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2019-10-01")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[_models.DeploymentOperation] - request = build_deployment_operations_get_at_scope_request( scope=scope, deployment_name=deployment_name, operation_id=operation_id, api_version=api_version, - template_url=self.get_at_scope.metadata['url'], + template_url=self.get_at_scope.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) - deserialized = self._deserialize('DeploymentOperation', pipeline_response) + deserialized = self._deserialize("DeploymentOperation", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - get_at_scope.metadata = {'url': "/{scope}/providers/Microsoft.Resources/deployments/{deploymentName}/operations/{operationId}"} # type: ignore - + get_at_scope.metadata = {"url": "/{scope}/providers/Microsoft.Resources/deployments/{deploymentName}/operations/{operationId}"} # type: ignore @distributed_trace def list_at_scope( - self, - scope: str, - deployment_name: str, - top: Optional[int] = None, - **kwargs: Any - ) -> AsyncIterable["_models.DeploymentOperationsListResult"]: + self, scope: str, deployment_name: str, top: Optional[int] = None, **kwargs: Any + ) -> AsyncIterable["_models.DeploymentOperation"]: """Gets all deployments operations for a deployment. - :param scope: The resource scope. + :param scope: The resource scope. Required. :type scope: str - :param deployment_name: The name of the deployment. + :param deployment_name: The name of the deployment. Required. :type deployment_name: str :param top: The number of results to return. Default value is None. :type top: int :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either DeploymentOperationsListResult or the result of - cls(response) + :return: An iterator like instance of either DeploymentOperation or the result of cls(response) :rtype: - ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.resource.resources.v2019_10_01.models.DeploymentOperationsListResult] - :raises: ~azure.core.exceptions.HttpResponseError + ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.resource.resources.v2019_10_01.models.DeploymentOperation] + :raises ~azure.core.exceptions.HttpResponseError: """ - api_version = kwargs.pop('api_version', "2019-10-01") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2019-10-01")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[_models.DeploymentOperationsListResult] - cls = kwargs.pop('cls', None) # type: ClsType["_models.DeploymentOperationsListResult"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) + def prepare_request(next_link=None): if not next_link: - + request = build_deployment_operations_list_at_scope_request( scope=scope, deployment_name=deployment_name, - api_version=api_version, top=top, - template_url=self.list_at_scope.metadata['url'], + api_version=api_version, + template_url=self.list_at_scope.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore else: - - request = build_deployment_operations_list_at_scope_request( - scope=scope, - deployment_name=deployment_name, - template_url=next_link, - ) + # make call to next link with the client's api-version + _parsed_next_link = urlparse(next_link) + _next_request_params = case_insensitive_dict(parse_qs(_parsed_next_link.query)) + _next_request_params["api-version"] = self._config.api_version + request = HttpRequest("GET", urljoin(next_link, _parsed_next_link.path), params=_next_request_params) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore request.method = "GET" return request @@ -7230,10 +9537,8 @@ async def extract_data(pipeline_response): async def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) response = pipeline_response.http_response @@ -7243,116 +9548,121 @@ async def get_next(next_link=None): return pipeline_response + return AsyncItemPaged(get_next, extract_data) - return AsyncItemPaged( - get_next, extract_data - ) - list_at_scope.metadata = {'url': "/{scope}/providers/Microsoft.Resources/deployments/{deploymentName}/operations"} # type: ignore + list_at_scope.metadata = {"url": "/{scope}/providers/Microsoft.Resources/deployments/{deploymentName}/operations"} # type: ignore @distributed_trace_async async def get_at_tenant_scope( - self, - deployment_name: str, - operation_id: str, - **kwargs: Any - ) -> "_models.DeploymentOperation": + self, deployment_name: str, operation_id: str, **kwargs: Any + ) -> _models.DeploymentOperation: """Gets a deployments operation. - :param deployment_name: The name of the deployment. + :param deployment_name: The name of the deployment. Required. :type deployment_name: str - :param operation_id: The ID of the operation to get. + :param operation_id: The ID of the operation to get. Required. :type operation_id: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: DeploymentOperation, or the result of cls(response) + :return: DeploymentOperation or the result of cls(response) :rtype: ~azure.mgmt.resource.resources.v2019_10_01.models.DeploymentOperation - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.DeploymentOperation"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + 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', "2019-10-01") # type: str + api_version = kwargs.pop("api_version", _params.pop("api-version", "2019-10-01")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[_models.DeploymentOperation] - request = build_deployment_operations_get_at_tenant_scope_request( deployment_name=deployment_name, operation_id=operation_id, api_version=api_version, - template_url=self.get_at_tenant_scope.metadata['url'], + template_url=self.get_at_tenant_scope.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) - deserialized = self._deserialize('DeploymentOperation', pipeline_response) + deserialized = self._deserialize("DeploymentOperation", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - get_at_tenant_scope.metadata = {'url': "/providers/Microsoft.Resources/deployments/{deploymentName}/operations/{operationId}"} # type: ignore - + get_at_tenant_scope.metadata = {"url": "/providers/Microsoft.Resources/deployments/{deploymentName}/operations/{operationId}"} # type: ignore @distributed_trace def list_at_tenant_scope( - self, - deployment_name: str, - top: Optional[int] = None, - **kwargs: Any - ) -> AsyncIterable["_models.DeploymentOperationsListResult"]: + self, deployment_name: str, top: Optional[int] = None, **kwargs: Any + ) -> AsyncIterable["_models.DeploymentOperation"]: """Gets all deployments operations for a deployment. - :param deployment_name: The name of the deployment. + :param deployment_name: The name of the deployment. Required. :type deployment_name: str :param top: The number of results to return. Default value is None. :type top: int :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either DeploymentOperationsListResult or the result of - cls(response) + :return: An iterator like instance of either DeploymentOperation or the result of cls(response) :rtype: - ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.resource.resources.v2019_10_01.models.DeploymentOperationsListResult] - :raises: ~azure.core.exceptions.HttpResponseError + ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.resource.resources.v2019_10_01.models.DeploymentOperation] + :raises ~azure.core.exceptions.HttpResponseError: """ - api_version = kwargs.pop('api_version', "2019-10-01") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2019-10-01")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[_models.DeploymentOperationsListResult] - cls = kwargs.pop('cls', None) # type: ClsType["_models.DeploymentOperationsListResult"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) + def prepare_request(next_link=None): if not next_link: - + request = build_deployment_operations_list_at_tenant_scope_request( deployment_name=deployment_name, - api_version=api_version, top=top, - template_url=self.list_at_tenant_scope.metadata['url'], + api_version=api_version, + template_url=self.list_at_tenant_scope.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore else: - - request = build_deployment_operations_list_at_tenant_scope_request( - deployment_name=deployment_name, - template_url=next_link, - ) + # make call to next link with the client's api-version + _parsed_next_link = urlparse(next_link) + _next_request_params = case_insensitive_dict(parse_qs(_parsed_next_link.query)) + _next_request_params["api-version"] = self._config.api_version + request = HttpRequest("GET", urljoin(next_link, _parsed_next_link.path), params=_next_request_params) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore request.method = "GET" return request @@ -7366,10 +9676,8 @@ async def extract_data(pipeline_response): async def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) response = pipeline_response.http_response @@ -7379,125 +9687,127 @@ async def get_next(next_link=None): return pipeline_response + return AsyncItemPaged(get_next, extract_data) - return AsyncItemPaged( - get_next, extract_data - ) - list_at_tenant_scope.metadata = {'url': "/providers/Microsoft.Resources/deployments/{deploymentName}/operations"} # type: ignore + list_at_tenant_scope.metadata = {"url": "/providers/Microsoft.Resources/deployments/{deploymentName}/operations"} # type: ignore @distributed_trace_async async def get_at_management_group_scope( - self, - group_id: str, - deployment_name: str, - operation_id: str, - **kwargs: Any - ) -> "_models.DeploymentOperation": + self, group_id: str, deployment_name: str, operation_id: str, **kwargs: Any + ) -> _models.DeploymentOperation: """Gets a deployments operation. - :param group_id: The management group ID. + :param group_id: The management group ID. Required. :type group_id: str - :param deployment_name: The name of the deployment. + :param deployment_name: The name of the deployment. Required. :type deployment_name: str - :param operation_id: The ID of the operation to get. + :param operation_id: The ID of the operation to get. Required. :type operation_id: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: DeploymentOperation, or the result of cls(response) + :return: DeploymentOperation or the result of cls(response) :rtype: ~azure.mgmt.resource.resources.v2019_10_01.models.DeploymentOperation - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.DeploymentOperation"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + 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', "2019-10-01") # type: str + api_version = kwargs.pop("api_version", _params.pop("api-version", "2019-10-01")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[_models.DeploymentOperation] - request = build_deployment_operations_get_at_management_group_scope_request( group_id=group_id, deployment_name=deployment_name, operation_id=operation_id, api_version=api_version, - template_url=self.get_at_management_group_scope.metadata['url'], + template_url=self.get_at_management_group_scope.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) - deserialized = self._deserialize('DeploymentOperation', pipeline_response) + deserialized = self._deserialize("DeploymentOperation", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - get_at_management_group_scope.metadata = {'url': "/providers/Microsoft.Management/managementGroups/{groupId}/providers/Microsoft.Resources/deployments/{deploymentName}/operations/{operationId}"} # type: ignore - + get_at_management_group_scope.metadata = {"url": "/providers/Microsoft.Management/managementGroups/{groupId}/providers/Microsoft.Resources/deployments/{deploymentName}/operations/{operationId}"} # type: ignore @distributed_trace def list_at_management_group_scope( - self, - group_id: str, - deployment_name: str, - top: Optional[int] = None, - **kwargs: Any - ) -> AsyncIterable["_models.DeploymentOperationsListResult"]: + self, group_id: str, deployment_name: str, top: Optional[int] = None, **kwargs: Any + ) -> AsyncIterable["_models.DeploymentOperation"]: """Gets all deployments operations for a deployment. - :param group_id: The management group ID. + :param group_id: The management group ID. Required. :type group_id: str - :param deployment_name: The name of the deployment. + :param deployment_name: The name of the deployment. Required. :type deployment_name: str :param top: The number of results to return. Default value is None. :type top: int :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either DeploymentOperationsListResult or the result of - cls(response) + :return: An iterator like instance of either DeploymentOperation or the result of cls(response) :rtype: - ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.resource.resources.v2019_10_01.models.DeploymentOperationsListResult] - :raises: ~azure.core.exceptions.HttpResponseError + ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.resource.resources.v2019_10_01.models.DeploymentOperation] + :raises ~azure.core.exceptions.HttpResponseError: """ - api_version = kwargs.pop('api_version', "2019-10-01") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2019-10-01")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[_models.DeploymentOperationsListResult] - cls = kwargs.pop('cls', None) # type: ClsType["_models.DeploymentOperationsListResult"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) + def prepare_request(next_link=None): if not next_link: - + request = build_deployment_operations_list_at_management_group_scope_request( group_id=group_id, deployment_name=deployment_name, - api_version=api_version, top=top, - template_url=self.list_at_management_group_scope.metadata['url'], + api_version=api_version, + template_url=self.list_at_management_group_scope.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore else: - - request = build_deployment_operations_list_at_management_group_scope_request( - group_id=group_id, - deployment_name=deployment_name, - template_url=next_link, - ) + # make call to next link with the client's api-version + _parsed_next_link = urlparse(next_link) + _next_request_params = case_insensitive_dict(parse_qs(_parsed_next_link.query)) + _next_request_params["api-version"] = self._config.api_version + request = HttpRequest("GET", urljoin(next_link, _parsed_next_link.path), params=_next_request_params) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore request.method = "GET" return request @@ -7511,10 +9821,8 @@ async def extract_data(pipeline_response): async def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) response = pipeline_response.http_response @@ -7524,119 +9832,123 @@ async def get_next(next_link=None): return pipeline_response + return AsyncItemPaged(get_next, extract_data) - return AsyncItemPaged( - get_next, extract_data - ) - list_at_management_group_scope.metadata = {'url': "/providers/Microsoft.Management/managementGroups/{groupId}/providers/Microsoft.Resources/deployments/{deploymentName}/operations"} # type: ignore + list_at_management_group_scope.metadata = {"url": "/providers/Microsoft.Management/managementGroups/{groupId}/providers/Microsoft.Resources/deployments/{deploymentName}/operations"} # type: ignore @distributed_trace_async async def get_at_subscription_scope( - self, - deployment_name: str, - operation_id: str, - **kwargs: Any - ) -> "_models.DeploymentOperation": + self, deployment_name: str, operation_id: str, **kwargs: Any + ) -> _models.DeploymentOperation: """Gets a deployments operation. - :param deployment_name: The name of the deployment. + :param deployment_name: The name of the deployment. Required. :type deployment_name: str - :param operation_id: The ID of the operation to get. + :param operation_id: The ID of the operation to get. Required. :type operation_id: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: DeploymentOperation, or the result of cls(response) + :return: DeploymentOperation or the result of cls(response) :rtype: ~azure.mgmt.resource.resources.v2019_10_01.models.DeploymentOperation - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.DeploymentOperation"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) - api_version = kwargs.pop('api_version', "2019-10-01") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2019-10-01")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[_models.DeploymentOperation] - request = build_deployment_operations_get_at_subscription_scope_request( deployment_name=deployment_name, operation_id=operation_id, subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.get_at_subscription_scope.metadata['url'], + template_url=self.get_at_subscription_scope.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) - deserialized = self._deserialize('DeploymentOperation', pipeline_response) + deserialized = self._deserialize("DeploymentOperation", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - get_at_subscription_scope.metadata = {'url': "/subscriptions/{subscriptionId}/providers/Microsoft.Resources/deployments/{deploymentName}/operations/{operationId}"} # type: ignore - + get_at_subscription_scope.metadata = {"url": "/subscriptions/{subscriptionId}/providers/Microsoft.Resources/deployments/{deploymentName}/operations/{operationId}"} # type: ignore @distributed_trace def list_at_subscription_scope( - self, - deployment_name: str, - top: Optional[int] = None, - **kwargs: Any - ) -> AsyncIterable["_models.DeploymentOperationsListResult"]: + self, deployment_name: str, top: Optional[int] = None, **kwargs: Any + ) -> AsyncIterable["_models.DeploymentOperation"]: """Gets all deployments operations for a deployment. - :param deployment_name: The name of the deployment. + :param deployment_name: The name of the deployment. Required. :type deployment_name: str :param top: The number of results to return. Default value is None. :type top: int :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either DeploymentOperationsListResult or the result of - cls(response) + :return: An iterator like instance of either DeploymentOperation or the result of cls(response) :rtype: - ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.resource.resources.v2019_10_01.models.DeploymentOperationsListResult] - :raises: ~azure.core.exceptions.HttpResponseError + ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.resource.resources.v2019_10_01.models.DeploymentOperation] + :raises ~azure.core.exceptions.HttpResponseError: """ - api_version = kwargs.pop('api_version', "2019-10-01") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2019-10-01")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[_models.DeploymentOperationsListResult] - cls = kwargs.pop('cls', None) # type: ClsType["_models.DeploymentOperationsListResult"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) + def prepare_request(next_link=None): if not next_link: - + request = build_deployment_operations_list_at_subscription_scope_request( deployment_name=deployment_name, subscription_id=self._config.subscription_id, - api_version=api_version, top=top, - template_url=self.list_at_subscription_scope.metadata['url'], + api_version=api_version, + template_url=self.list_at_subscription_scope.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore else: - - request = build_deployment_operations_list_at_subscription_scope_request( - deployment_name=deployment_name, - subscription_id=self._config.subscription_id, - template_url=next_link, - ) + # make call to next link with the client's api-version + _parsed_next_link = urlparse(next_link) + _next_request_params = case_insensitive_dict(parse_qs(_parsed_next_link.query)) + _next_request_params["api-version"] = self._config.api_version + request = HttpRequest("GET", urljoin(next_link, _parsed_next_link.path), params=_next_request_params) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore request.method = "GET" return request @@ -7650,10 +9962,8 @@ async def extract_data(pipeline_response): async def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) response = pipeline_response.http_response @@ -7663,128 +9973,131 @@ async def get_next(next_link=None): return pipeline_response + return AsyncItemPaged(get_next, extract_data) - return AsyncItemPaged( - get_next, extract_data - ) - list_at_subscription_scope.metadata = {'url': "/subscriptions/{subscriptionId}/providers/Microsoft.Resources/deployments/{deploymentName}/operations"} # type: ignore + list_at_subscription_scope.metadata = {"url": "/subscriptions/{subscriptionId}/providers/Microsoft.Resources/deployments/{deploymentName}/operations"} # type: ignore @distributed_trace_async async def get( - self, - resource_group_name: str, - deployment_name: str, - operation_id: str, - **kwargs: Any - ) -> "_models.DeploymentOperation": + self, resource_group_name: str, deployment_name: str, operation_id: str, **kwargs: Any + ) -> _models.DeploymentOperation: """Gets a deployments operation. :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. :type resource_group_name: str - :param deployment_name: The name of the deployment. + :param deployment_name: The name of the deployment. Required. :type deployment_name: str - :param operation_id: The ID of the operation to get. + :param operation_id: The ID of the operation to get. Required. :type operation_id: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: DeploymentOperation, or the result of cls(response) + :return: DeploymentOperation or the result of cls(response) :rtype: ~azure.mgmt.resource.resources.v2019_10_01.models.DeploymentOperation - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.DeploymentOperation"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + 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', "2019-10-01") # type: str + api_version = kwargs.pop("api_version", _params.pop("api-version", "2019-10-01")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[_models.DeploymentOperation] - request = build_deployment_operations_get_request( resource_group_name=resource_group_name, deployment_name=deployment_name, operation_id=operation_id, subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.get.metadata['url'], + template_url=self.get.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) - deserialized = self._deserialize('DeploymentOperation', pipeline_response) + deserialized = self._deserialize("DeploymentOperation", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - get.metadata = {'url': "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/deployments/{deploymentName}/operations/{operationId}"} # type: ignore - + get.metadata = {"url": "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/deployments/{deploymentName}/operations/{operationId}"} # type: ignore @distributed_trace def list( - self, - resource_group_name: str, - deployment_name: str, - top: Optional[int] = None, - **kwargs: Any - ) -> AsyncIterable["_models.DeploymentOperationsListResult"]: + self, resource_group_name: str, deployment_name: str, top: Optional[int] = None, **kwargs: Any + ) -> AsyncIterable["_models.DeploymentOperation"]: """Gets all deployments operations for a deployment. :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. :type resource_group_name: str - :param deployment_name: The name of the deployment. + :param deployment_name: The name of the deployment. Required. :type deployment_name: str :param top: The number of results to return. Default value is None. :type top: int :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either DeploymentOperationsListResult or the result of - cls(response) + :return: An iterator like instance of either DeploymentOperation or the result of cls(response) :rtype: - ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.resource.resources.v2019_10_01.models.DeploymentOperationsListResult] - :raises: ~azure.core.exceptions.HttpResponseError + ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.resource.resources.v2019_10_01.models.DeploymentOperation] + :raises ~azure.core.exceptions.HttpResponseError: """ - api_version = kwargs.pop('api_version', "2019-10-01") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2019-10-01")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[_models.DeploymentOperationsListResult] - cls = kwargs.pop('cls', None) # type: ClsType["_models.DeploymentOperationsListResult"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) + def prepare_request(next_link=None): if not next_link: - + request = build_deployment_operations_list_request( resource_group_name=resource_group_name, deployment_name=deployment_name, subscription_id=self._config.subscription_id, - api_version=api_version, top=top, - template_url=self.list.metadata['url'], + 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.url = self._client.format_url(request.url) # type: ignore else: - - request = build_deployment_operations_list_request( - resource_group_name=resource_group_name, - deployment_name=deployment_name, - subscription_id=self._config.subscription_id, - template_url=next_link, - ) + # make call to next link with the client's api-version + _parsed_next_link = urlparse(next_link) + _next_request_params = case_insensitive_dict(parse_qs(_parsed_next_link.query)) + _next_request_params["api-version"] = self._config.api_version + request = HttpRequest("GET", urljoin(next_link, _parsed_next_link.path), params=_next_request_params) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore request.method = "GET" return request @@ -7798,10 +10111,8 @@ async def extract_data(pipeline_response): async def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) response = pipeline_response.http_response @@ -7811,8 +10122,6 @@ async def get_next(next_link=None): return pipeline_response + return AsyncItemPaged(get_next, extract_data) - return AsyncItemPaged( - get_next, extract_data - ) - list.metadata = {'url': "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/deployments/{deploymentName}/operations"} # type: ignore + list.metadata = {"url": "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/deployments/{deploymentName}/operations"} # type: ignore diff --git a/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/resources/v2019_10_01/aio/operations/_patch.py b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/resources/v2019_10_01/aio/operations/_patch.py new file mode 100644 index 0000000000000..f7dd32510333d --- /dev/null +++ b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/resources/v2019_10_01/aio/operations/_patch.py @@ -0,0 +1,20 @@ +# ------------------------------------ +# Copyright (c) Microsoft Corporation. +# Licensed under the MIT License. +# ------------------------------------ +"""Customize generated code here. + +Follow our quickstart for examples: https://aka.ms/azsdk/python/dpcodegen/python/customize +""" +from typing import List + +__all__: List[str] = [] # Add all objects you want publicly available to users at this package level + + +def patch_sdk(): + """Do not remove from this file. + + `patch_sdk` is a last resort escape hatch that allows you to do customizations + you can't accomplish using the techniques described in + https://aka.ms/azsdk/python/dpcodegen/python/customize + """ diff --git a/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/resources/v2019_10_01/models/__init__.py b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/resources/v2019_10_01/models/__init__.py index 4ed0e846e5b3b..a07cf336e59ed 100644 --- a/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/resources/v2019_10_01/models/__init__.py +++ b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/resources/v2019_10_01/models/__init__.py @@ -75,97 +75,99 @@ from ._models_py3 import WhatIfPropertyChange from ._models_py3 import ZoneMapping - -from ._resource_management_client_enums import ( - AliasPatternType, - AliasType, - ChangeType, - DeploymentMode, - OnErrorDeploymentType, - PropertyChangeType, - ProvisioningOperation, - ResourceIdentityType, - TagsPatchOperation, - WhatIfResultFormat, -) +from ._resource_management_client_enums import AliasPatternType +from ._resource_management_client_enums import AliasType +from ._resource_management_client_enums import ChangeType +from ._resource_management_client_enums import DeploymentMode +from ._resource_management_client_enums import OnErrorDeploymentType +from ._resource_management_client_enums import PropertyChangeType +from ._resource_management_client_enums import ProvisioningOperation +from ._resource_management_client_enums import ResourceIdentityType +from ._resource_management_client_enums import TagsPatchOperation +from ._resource_management_client_enums import WhatIfResultFormat +from ._patch import __all__ as _patch_all +from ._patch import * # type: ignore # pylint: disable=unused-wildcard-import +from ._patch import patch_sdk as _patch_sdk __all__ = [ - 'Alias', - 'AliasPath', - 'AliasPattern', - 'BasicDependency', - 'DebugSetting', - 'Dependency', - 'Deployment', - 'DeploymentExportResult', - 'DeploymentExtended', - 'DeploymentExtendedFilter', - 'DeploymentListResult', - 'DeploymentOperation', - 'DeploymentOperationProperties', - 'DeploymentOperationsListResult', - 'DeploymentProperties', - 'DeploymentPropertiesExtended', - 'DeploymentValidateResult', - 'DeploymentWhatIf', - 'DeploymentWhatIfProperties', - 'DeploymentWhatIfSettings', - 'ErrorAdditionalInfo', - 'ErrorResponse', - 'ExportTemplateRequest', - 'GenericResource', - 'GenericResourceExpanded', - 'GenericResourceFilter', - 'HttpMessage', - 'Identity', - 'IdentityUserAssignedIdentitiesValue', - 'OnErrorDeployment', - 'OnErrorDeploymentExtended', - 'Operation', - 'OperationDisplay', - 'OperationListResult', - 'ParametersLink', - 'Plan', - 'Provider', - 'ProviderListResult', - 'ProviderResourceType', - 'Resource', - 'ResourceGroup', - 'ResourceGroupExportResult', - 'ResourceGroupFilter', - 'ResourceGroupListResult', - 'ResourceGroupPatchable', - 'ResourceGroupProperties', - 'ResourceListResult', - 'ResourceProviderOperationDisplayProperties', - 'ResourceReference', - 'ResourcesMoveInfo', - 'ScopedDeployment', - 'ScopedDeploymentWhatIf', - 'Sku', - 'SubResource', - 'TagCount', - 'TagDetails', - 'TagValue', - 'Tags', - 'TagsListResult', - 'TagsPatchResource', - 'TagsResource', - 'TargetResource', - 'TemplateHashResult', - 'TemplateLink', - 'WhatIfChange', - 'WhatIfOperationResult', - 'WhatIfPropertyChange', - 'ZoneMapping', - 'AliasPatternType', - 'AliasType', - 'ChangeType', - 'DeploymentMode', - 'OnErrorDeploymentType', - 'PropertyChangeType', - 'ProvisioningOperation', - 'ResourceIdentityType', - 'TagsPatchOperation', - 'WhatIfResultFormat', + "Alias", + "AliasPath", + "AliasPattern", + "BasicDependency", + "DebugSetting", + "Dependency", + "Deployment", + "DeploymentExportResult", + "DeploymentExtended", + "DeploymentExtendedFilter", + "DeploymentListResult", + "DeploymentOperation", + "DeploymentOperationProperties", + "DeploymentOperationsListResult", + "DeploymentProperties", + "DeploymentPropertiesExtended", + "DeploymentValidateResult", + "DeploymentWhatIf", + "DeploymentWhatIfProperties", + "DeploymentWhatIfSettings", + "ErrorAdditionalInfo", + "ErrorResponse", + "ExportTemplateRequest", + "GenericResource", + "GenericResourceExpanded", + "GenericResourceFilter", + "HttpMessage", + "Identity", + "IdentityUserAssignedIdentitiesValue", + "OnErrorDeployment", + "OnErrorDeploymentExtended", + "Operation", + "OperationDisplay", + "OperationListResult", + "ParametersLink", + "Plan", + "Provider", + "ProviderListResult", + "ProviderResourceType", + "Resource", + "ResourceGroup", + "ResourceGroupExportResult", + "ResourceGroupFilter", + "ResourceGroupListResult", + "ResourceGroupPatchable", + "ResourceGroupProperties", + "ResourceListResult", + "ResourceProviderOperationDisplayProperties", + "ResourceReference", + "ResourcesMoveInfo", + "ScopedDeployment", + "ScopedDeploymentWhatIf", + "Sku", + "SubResource", + "TagCount", + "TagDetails", + "TagValue", + "Tags", + "TagsListResult", + "TagsPatchResource", + "TagsResource", + "TargetResource", + "TemplateHashResult", + "TemplateLink", + "WhatIfChange", + "WhatIfOperationResult", + "WhatIfPropertyChange", + "ZoneMapping", + "AliasPatternType", + "AliasType", + "ChangeType", + "DeploymentMode", + "OnErrorDeploymentType", + "PropertyChangeType", + "ProvisioningOperation", + "ResourceIdentityType", + "TagsPatchOperation", + "WhatIfResultFormat", ] +__all__.extend([p for p in _patch_all if p not in __all__]) +_patch_sdk() diff --git a/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/resources/v2019_10_01/models/_models_py3.py b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/resources/v2019_10_01/models/_models_py3.py index d6668d2ee27da..57091d1378a68 100644 --- a/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/resources/v2019_10_01/models/_models_py3.py +++ b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/resources/v2019_10_01/models/_models_py3.py @@ -1,4 +1,5 @@ # coding=utf-8 +# pylint: disable=too-many-lines # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. # Licensed under the MIT License. See License.txt in the project root for license information. @@ -6,22 +7,29 @@ # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -from typing import Any, Dict, List, Optional, Union +import sys +from typing import Any, Dict, List, Optional, TYPE_CHECKING, Union -import msrest.serialization +from ... import _serialization -from ._resource_management_client_enums import * +if TYPE_CHECKING: + # pylint: disable=unused-import,ungrouped-imports + from .. import models as _models +if sys.version_info >= (3, 9): + from collections.abc import MutableMapping +else: + from typing import MutableMapping # type: ignore # pylint: disable=ungrouped-imports +JSON = MutableMapping[str, Any] # pylint: disable=unsubscriptable-object -class Alias(msrest.serialization.Model): +class Alias(_serialization.Model): """The alias type. :ivar name: The alias name. :vartype name: str :ivar paths: The paths for an alias. :vartype paths: list[~azure.mgmt.resource.resources.v2019_10_01.models.AliasPath] - :ivar type: The type of the alias. Possible values include: "NotSpecified", "PlainText", - "Mask". + :ivar type: The type of the alias. Known values are: "NotSpecified", "PlainText", and "Mask". :vartype type: str or ~azure.mgmt.resource.resources.v2019_10_01.models.AliasType :ivar default_path: The default path for an alias. :vartype default_path: str @@ -30,21 +38,21 @@ class Alias(msrest.serialization.Model): """ _attribute_map = { - 'name': {'key': 'name', 'type': 'str'}, - 'paths': {'key': 'paths', 'type': '[AliasPath]'}, - 'type': {'key': 'type', 'type': 'str'}, - 'default_path': {'key': 'defaultPath', 'type': 'str'}, - 'default_pattern': {'key': 'defaultPattern', 'type': 'AliasPattern'}, + "name": {"key": "name", "type": "str"}, + "paths": {"key": "paths", "type": "[AliasPath]"}, + "type": {"key": "type", "type": "str"}, + "default_path": {"key": "defaultPath", "type": "str"}, + "default_pattern": {"key": "defaultPattern", "type": "AliasPattern"}, } def __init__( self, *, name: Optional[str] = None, - paths: Optional[List["AliasPath"]] = None, - type: Optional[Union[str, "AliasType"]] = None, + paths: Optional[List["_models.AliasPath"]] = None, + type: Optional[Union[str, "_models.AliasType"]] = None, default_path: Optional[str] = None, - default_pattern: Optional["AliasPattern"] = None, + default_pattern: Optional["_models.AliasPattern"] = None, **kwargs ): """ @@ -52,7 +60,7 @@ def __init__( :paramtype name: str :keyword paths: The paths for an alias. :paramtype paths: list[~azure.mgmt.resource.resources.v2019_10_01.models.AliasPath] - :keyword type: The type of the alias. Possible values include: "NotSpecified", "PlainText", + :keyword type: The type of the alias. Known values are: "NotSpecified", "PlainText", and "Mask". :paramtype type: str or ~azure.mgmt.resource.resources.v2019_10_01.models.AliasType :keyword default_path: The default path for an alias. @@ -60,7 +68,7 @@ def __init__( :keyword default_pattern: The default pattern for an alias. :paramtype default_pattern: ~azure.mgmt.resource.resources.v2019_10_01.models.AliasPattern """ - super(Alias, self).__init__(**kwargs) + super().__init__(**kwargs) self.name = name self.paths = paths self.type = type @@ -68,7 +76,7 @@ def __init__( self.default_pattern = default_pattern -class AliasPath(msrest.serialization.Model): +class AliasPath(_serialization.Model): """The type of the paths for alias. :ivar path: The path of an alias. @@ -80,9 +88,9 @@ class AliasPath(msrest.serialization.Model): """ _attribute_map = { - 'path': {'key': 'path', 'type': 'str'}, - 'api_versions': {'key': 'apiVersions', 'type': '[str]'}, - 'pattern': {'key': 'pattern', 'type': 'AliasPattern'}, + "path": {"key": "path", "type": "str"}, + "api_versions": {"key": "apiVersions", "type": "[str]"}, + "pattern": {"key": "pattern", "type": "AliasPattern"}, } def __init__( @@ -90,7 +98,7 @@ def __init__( *, path: Optional[str] = None, api_versions: Optional[List[str]] = None, - pattern: Optional["AliasPattern"] = None, + pattern: Optional["_models.AliasPattern"] = None, **kwargs ): """ @@ -101,27 +109,27 @@ def __init__( :keyword pattern: The pattern for an alias path. :paramtype pattern: ~azure.mgmt.resource.resources.v2019_10_01.models.AliasPattern """ - super(AliasPath, self).__init__(**kwargs) + super().__init__(**kwargs) self.path = path self.api_versions = api_versions self.pattern = pattern -class AliasPattern(msrest.serialization.Model): +class AliasPattern(_serialization.Model): """The type of the pattern for an alias path. :ivar phrase: The alias pattern phrase. :vartype phrase: str :ivar variable: The alias pattern variable. :vartype variable: str - :ivar type: The type of alias pattern. Possible values include: "NotSpecified", "Extract". + :ivar type: The type of alias pattern. Known values are: "NotSpecified" and "Extract". :vartype type: str or ~azure.mgmt.resource.resources.v2019_10_01.models.AliasPatternType """ _attribute_map = { - 'phrase': {'key': 'phrase', 'type': 'str'}, - 'variable': {'key': 'variable', 'type': 'str'}, - 'type': {'key': 'type', 'type': 'str'}, + "phrase": {"key": "phrase", "type": "str"}, + "variable": {"key": "variable", "type": "str"}, + "type": {"key": "type", "type": "str"}, } def __init__( @@ -129,7 +137,7 @@ def __init__( *, phrase: Optional[str] = None, variable: Optional[str] = None, - type: Optional[Union[str, "AliasPatternType"]] = None, + type: Optional[Union[str, "_models.AliasPatternType"]] = None, **kwargs ): """ @@ -137,16 +145,16 @@ def __init__( :paramtype phrase: str :keyword variable: The alias pattern variable. :paramtype variable: str - :keyword type: The type of alias pattern. Possible values include: "NotSpecified", "Extract". + :keyword type: The type of alias pattern. Known values are: "NotSpecified" and "Extract". :paramtype type: str or ~azure.mgmt.resource.resources.v2019_10_01.models.AliasPatternType """ - super(AliasPattern, self).__init__(**kwargs) + super().__init__(**kwargs) self.phrase = phrase self.variable = variable self.type = type -class BasicDependency(msrest.serialization.Model): +class BasicDependency(_serialization.Model): """Deployment dependency information. :ivar id: The ID of the dependency. @@ -158,15 +166,15 @@ class BasicDependency(msrest.serialization.Model): """ _attribute_map = { - 'id': {'key': 'id', 'type': 'str'}, - 'resource_type': {'key': 'resourceType', 'type': 'str'}, - 'resource_name': {'key': 'resourceName', 'type': 'str'}, + "id": {"key": "id", "type": "str"}, + "resource_type": {"key": "resourceType", "type": "str"}, + "resource_name": {"key": "resourceName", "type": "str"}, } def __init__( self, *, - id: Optional[str] = None, + id: Optional[str] = None, # pylint: disable=redefined-builtin resource_type: Optional[str] = None, resource_name: Optional[str] = None, **kwargs @@ -179,13 +187,13 @@ def __init__( :keyword resource_name: The dependency resource name. :paramtype resource_name: str """ - super(BasicDependency, self).__init__(**kwargs) + super().__init__(**kwargs) self.id = id self.resource_type = resource_type self.resource_name = resource_name -class DebugSetting(msrest.serialization.Model): +class DebugSetting(_serialization.Model): """The debug setting. :ivar detail_level: Specifies the type of information to log for debugging. The permitted @@ -198,15 +206,10 @@ class DebugSetting(msrest.serialization.Model): """ _attribute_map = { - 'detail_level': {'key': 'detailLevel', 'type': 'str'}, + "detail_level": {"key": "detailLevel", "type": "str"}, } - def __init__( - self, - *, - detail_level: Optional[str] = None, - **kwargs - ): + def __init__(self, *, detail_level: Optional[str] = None, **kwargs): """ :keyword detail_level: Specifies the type of information to log for debugging. The permitted values are none, requestContent, responseContent, or both requestContent and responseContent @@ -216,11 +219,11 @@ def __init__( deployment operations. :paramtype detail_level: str """ - super(DebugSetting, self).__init__(**kwargs) + super().__init__(**kwargs) self.detail_level = detail_level -class Dependency(msrest.serialization.Model): +class Dependency(_serialization.Model): """Deployment dependency information. :ivar depends_on: The list of dependencies. @@ -234,17 +237,17 @@ class Dependency(msrest.serialization.Model): """ _attribute_map = { - 'depends_on': {'key': 'dependsOn', 'type': '[BasicDependency]'}, - 'id': {'key': 'id', 'type': 'str'}, - 'resource_type': {'key': 'resourceType', 'type': 'str'}, - 'resource_name': {'key': 'resourceName', 'type': 'str'}, + "depends_on": {"key": "dependsOn", "type": "[BasicDependency]"}, + "id": {"key": "id", "type": "str"}, + "resource_type": {"key": "resourceType", "type": "str"}, + "resource_name": {"key": "resourceName", "type": "str"}, } def __init__( self, *, - depends_on: Optional[List["BasicDependency"]] = None, - id: Optional[str] = None, + depends_on: Optional[List["_models.BasicDependency"]] = None, + id: Optional[str] = None, # pylint: disable=redefined-builtin resource_type: Optional[str] = None, resource_name: Optional[str] = None, **kwargs @@ -259,40 +262,40 @@ def __init__( :keyword resource_name: The dependency resource name. :paramtype resource_name: str """ - super(Dependency, self).__init__(**kwargs) + super().__init__(**kwargs) self.depends_on = depends_on self.id = id self.resource_type = resource_type self.resource_name = resource_name -class Deployment(msrest.serialization.Model): +class Deployment(_serialization.Model): """Deployment operation parameters. All required parameters must be populated in order to send to Azure. :ivar location: The location to store the deployment data. :vartype location: str - :ivar properties: Required. The deployment properties. + :ivar properties: The deployment properties. Required. :vartype properties: ~azure.mgmt.resource.resources.v2019_10_01.models.DeploymentProperties - :ivar tags: A set of tags. Deployment tags. + :ivar tags: Deployment tags. :vartype tags: dict[str, str] """ _validation = { - 'properties': {'required': True}, + "properties": {"required": True}, } _attribute_map = { - 'location': {'key': 'location', 'type': 'str'}, - 'properties': {'key': 'properties', 'type': 'DeploymentProperties'}, - 'tags': {'key': 'tags', 'type': '{str}'}, + "location": {"key": "location", "type": "str"}, + "properties": {"key": "properties", "type": "DeploymentProperties"}, + "tags": {"key": "tags", "type": "{str}"}, } def __init__( self, *, - properties: "DeploymentProperties", + properties: "_models.DeploymentProperties", location: Optional[str] = None, tags: Optional[Dict[str, str]] = None, **kwargs @@ -300,43 +303,38 @@ def __init__( """ :keyword location: The location to store the deployment data. :paramtype location: str - :keyword properties: Required. The deployment properties. + :keyword properties: The deployment properties. Required. :paramtype properties: ~azure.mgmt.resource.resources.v2019_10_01.models.DeploymentProperties - :keyword tags: A set of tags. Deployment tags. + :keyword tags: Deployment tags. :paramtype tags: dict[str, str] """ - super(Deployment, self).__init__(**kwargs) + super().__init__(**kwargs) self.location = location self.properties = properties self.tags = tags -class DeploymentExportResult(msrest.serialization.Model): +class DeploymentExportResult(_serialization.Model): """The deployment export result. :ivar template: The template content. - :vartype template: any + :vartype template: JSON """ _attribute_map = { - 'template': {'key': 'template', 'type': 'object'}, + "template": {"key": "template", "type": "object"}, } - def __init__( - self, - *, - template: Optional[Any] = None, - **kwargs - ): + def __init__(self, *, template: Optional[JSON] = None, **kwargs): """ :keyword template: The template content. - :paramtype template: any + :paramtype template: JSON """ - super(DeploymentExportResult, self).__init__(**kwargs) + super().__init__(**kwargs) self.template = template -class DeploymentExtended(msrest.serialization.Model): +class DeploymentExtended(_serialization.Model): """Deployment information. Variables are only populated by the server, and will be ignored when sending a request. @@ -352,30 +350,30 @@ class DeploymentExtended(msrest.serialization.Model): :ivar properties: Deployment properties. :vartype properties: ~azure.mgmt.resource.resources.v2019_10_01.models.DeploymentPropertiesExtended - :ivar tags: A set of tags. Deployment tags. + :ivar tags: Deployment tags. :vartype tags: dict[str, str] """ _validation = { - 'id': {'readonly': True}, - 'name': {'readonly': True}, - 'type': {'readonly': True}, + "id": {"readonly": True}, + "name": {"readonly": True}, + "type": {"readonly": True}, } _attribute_map = { - 'id': {'key': 'id', 'type': 'str'}, - 'name': {'key': 'name', 'type': 'str'}, - 'type': {'key': 'type', 'type': 'str'}, - 'location': {'key': 'location', 'type': 'str'}, - 'properties': {'key': 'properties', 'type': 'DeploymentPropertiesExtended'}, - 'tags': {'key': 'tags', 'type': '{str}'}, + "id": {"key": "id", "type": "str"}, + "name": {"key": "name", "type": "str"}, + "type": {"key": "type", "type": "str"}, + "location": {"key": "location", "type": "str"}, + "properties": {"key": "properties", "type": "DeploymentPropertiesExtended"}, + "tags": {"key": "tags", "type": "{str}"}, } def __init__( self, *, location: Optional[str] = None, - properties: Optional["DeploymentPropertiesExtended"] = None, + properties: Optional["_models.DeploymentPropertiesExtended"] = None, tags: Optional[Dict[str, str]] = None, **kwargs ): @@ -385,10 +383,10 @@ def __init__( :keyword properties: Deployment properties. :paramtype properties: ~azure.mgmt.resource.resources.v2019_10_01.models.DeploymentPropertiesExtended - :keyword tags: A set of tags. Deployment tags. + :keyword tags: Deployment tags. :paramtype tags: dict[str, str] """ - super(DeploymentExtended, self).__init__(**kwargs) + super().__init__(**kwargs) self.id = None self.name = None self.type = None @@ -397,7 +395,7 @@ def __init__( self.tags = tags -class DeploymentExtendedFilter(msrest.serialization.Model): +class DeploymentExtendedFilter(_serialization.Model): """Deployment filter. :ivar provisioning_state: The provisioning state. @@ -405,24 +403,19 @@ class DeploymentExtendedFilter(msrest.serialization.Model): """ _attribute_map = { - 'provisioning_state': {'key': 'provisioningState', 'type': 'str'}, + "provisioning_state": {"key": "provisioningState", "type": "str"}, } - def __init__( - self, - *, - provisioning_state: Optional[str] = None, - **kwargs - ): + def __init__(self, *, provisioning_state: Optional[str] = None, **kwargs): """ :keyword provisioning_state: The provisioning state. :paramtype provisioning_state: str """ - super(DeploymentExtendedFilter, self).__init__(**kwargs) + super().__init__(**kwargs) self.provisioning_state = provisioning_state -class DeploymentListResult(msrest.serialization.Model): +class DeploymentListResult(_serialization.Model): """List of deployments. Variables are only populated by the server, and will be ignored when sending a request. @@ -434,30 +427,25 @@ class DeploymentListResult(msrest.serialization.Model): """ _validation = { - 'next_link': {'readonly': True}, + "next_link": {"readonly": True}, } _attribute_map = { - 'value': {'key': 'value', 'type': '[DeploymentExtended]'}, - 'next_link': {'key': 'nextLink', 'type': 'str'}, + "value": {"key": "value", "type": "[DeploymentExtended]"}, + "next_link": {"key": "nextLink", "type": "str"}, } - def __init__( - self, - *, - value: Optional[List["DeploymentExtended"]] = None, - **kwargs - ): + def __init__(self, *, value: Optional[List["_models.DeploymentExtended"]] = None, **kwargs): """ :keyword value: An array of deployments. :paramtype value: list[~azure.mgmt.resource.resources.v2019_10_01.models.DeploymentExtended] """ - super(DeploymentListResult, self).__init__(**kwargs) + super().__init__(**kwargs) self.value = value self.next_link = None -class DeploymentOperation(msrest.serialization.Model): +class DeploymentOperation(_serialization.Model): """Deployment operation information. Variables are only populated by the server, and will be ignored when sending a request. @@ -472,41 +460,36 @@ class DeploymentOperation(msrest.serialization.Model): """ _validation = { - 'id': {'readonly': True}, - 'operation_id': {'readonly': True}, + "id": {"readonly": True}, + "operation_id": {"readonly": True}, } _attribute_map = { - 'id': {'key': 'id', 'type': 'str'}, - 'operation_id': {'key': 'operationId', 'type': 'str'}, - 'properties': {'key': 'properties', 'type': 'DeploymentOperationProperties'}, + "id": {"key": "id", "type": "str"}, + "operation_id": {"key": "operationId", "type": "str"}, + "properties": {"key": "properties", "type": "DeploymentOperationProperties"}, } - def __init__( - self, - *, - properties: Optional["DeploymentOperationProperties"] = None, - **kwargs - ): + def __init__(self, *, properties: Optional["_models.DeploymentOperationProperties"] = None, **kwargs): """ :keyword properties: Deployment properties. :paramtype properties: ~azure.mgmt.resource.resources.v2019_10_01.models.DeploymentOperationProperties """ - super(DeploymentOperation, self).__init__(**kwargs) + super().__init__(**kwargs) self.id = None self.operation_id = None self.properties = properties -class DeploymentOperationProperties(msrest.serialization.Model): +class DeploymentOperationProperties(_serialization.Model): """Deployment operation properties. Variables are only populated by the server, and will be ignored when sending a request. - :ivar provisioning_operation: The name of the current provisioning operation. Possible values - include: "NotSpecified", "Create", "Delete", "Waiting", "AzureAsyncOperationWaiting", - "ResourceCacheWaiting", "Action", "Read", "EvaluateDeploymentOutput", "DeploymentCleanup". + :ivar provisioning_operation: The name of the current provisioning operation. Known values are: + "NotSpecified", "Create", "Delete", "Waiting", "AzureAsyncOperationWaiting", + "ResourceCacheWaiting", "Action", "Read", "EvaluateDeploymentOutput", and "DeploymentCleanup". :vartype provisioning_operation: str or ~azure.mgmt.resource.resources.v2019_10_01.models.ProvisioningOperation :ivar provisioning_state: The state of the provisioning. @@ -520,7 +503,7 @@ class DeploymentOperationProperties(msrest.serialization.Model): :ivar status_code: Operation status code. :vartype status_code: str :ivar status_message: Operation status message. - :vartype status_message: any + :vartype status_message: JSON :ivar target_resource: The target resource. :vartype target_resource: ~azure.mgmt.resource.resources.v2019_10_01.models.TargetResource :ivar request: The HTTP request message. @@ -530,38 +513,34 @@ class DeploymentOperationProperties(msrest.serialization.Model): """ _validation = { - 'provisioning_operation': {'readonly': True}, - 'provisioning_state': {'readonly': True}, - 'timestamp': {'readonly': True}, - 'duration': {'readonly': True}, - 'service_request_id': {'readonly': True}, - 'status_code': {'readonly': True}, - 'status_message': {'readonly': True}, - 'target_resource': {'readonly': True}, - 'request': {'readonly': True}, - 'response': {'readonly': True}, - } - - _attribute_map = { - 'provisioning_operation': {'key': 'provisioningOperation', 'type': 'str'}, - 'provisioning_state': {'key': 'provisioningState', 'type': 'str'}, - 'timestamp': {'key': 'timestamp', 'type': 'iso-8601'}, - 'duration': {'key': 'duration', 'type': 'str'}, - 'service_request_id': {'key': 'serviceRequestId', 'type': 'str'}, - 'status_code': {'key': 'statusCode', 'type': 'str'}, - 'status_message': {'key': 'statusMessage', 'type': 'object'}, - 'target_resource': {'key': 'targetResource', 'type': 'TargetResource'}, - 'request': {'key': 'request', 'type': 'HttpMessage'}, - 'response': {'key': 'response', 'type': 'HttpMessage'}, - } - - def __init__( - self, - **kwargs - ): - """ - """ - super(DeploymentOperationProperties, self).__init__(**kwargs) + "provisioning_operation": {"readonly": True}, + "provisioning_state": {"readonly": True}, + "timestamp": {"readonly": True}, + "duration": {"readonly": True}, + "service_request_id": {"readonly": True}, + "status_code": {"readonly": True}, + "status_message": {"readonly": True}, + "target_resource": {"readonly": True}, + "request": {"readonly": True}, + "response": {"readonly": True}, + } + + _attribute_map = { + "provisioning_operation": {"key": "provisioningOperation", "type": "str"}, + "provisioning_state": {"key": "provisioningState", "type": "str"}, + "timestamp": {"key": "timestamp", "type": "iso-8601"}, + "duration": {"key": "duration", "type": "str"}, + "service_request_id": {"key": "serviceRequestId", "type": "str"}, + "status_code": {"key": "statusCode", "type": "str"}, + "status_message": {"key": "statusMessage", "type": "object"}, + "target_resource": {"key": "targetResource", "type": "TargetResource"}, + "request": {"key": "request", "type": "HttpMessage"}, + "response": {"key": "response", "type": "HttpMessage"}, + } + + def __init__(self, **kwargs): + """ """ + super().__init__(**kwargs) self.provisioning_operation = None self.provisioning_state = None self.timestamp = None @@ -574,7 +553,7 @@ def __init__( self.response = None -class DeploymentOperationsListResult(msrest.serialization.Model): +class DeploymentOperationsListResult(_serialization.Model): """List of deployment operations. Variables are only populated by the server, and will be ignored when sending a request. @@ -586,30 +565,25 @@ class DeploymentOperationsListResult(msrest.serialization.Model): """ _validation = { - 'next_link': {'readonly': True}, + "next_link": {"readonly": True}, } _attribute_map = { - 'value': {'key': 'value', 'type': '[DeploymentOperation]'}, - 'next_link': {'key': 'nextLink', 'type': 'str'}, + "value": {"key": "value", "type": "[DeploymentOperation]"}, + "next_link": {"key": "nextLink", "type": "str"}, } - def __init__( - self, - *, - value: Optional[List["DeploymentOperation"]] = None, - **kwargs - ): + def __init__(self, *, value: Optional[List["_models.DeploymentOperation"]] = None, **kwargs): """ :keyword value: An array of deployment operations. :paramtype value: list[~azure.mgmt.resource.resources.v2019_10_01.models.DeploymentOperation] """ - super(DeploymentOperationsListResult, self).__init__(**kwargs) + super().__init__(**kwargs) self.value = value self.next_link = None -class DeploymentProperties(msrest.serialization.Model): +class DeploymentProperties(_serialization.Model): """Deployment properties. All required parameters must be populated in order to send to Azure. @@ -618,7 +592,7 @@ class DeploymentProperties(msrest.serialization.Model): syntax directly in the request rather than link to an existing template. It can be a JObject or well-formed JSON string. Use either the templateLink property or the template property, but not both. - :vartype template: any + :vartype template: JSON :ivar template_link: The URI of the template. Use either the templateLink property or the template property, but not both. :vartype template_link: ~azure.mgmt.resource.resources.v2019_10_01.models.TemplateLink @@ -626,17 +600,17 @@ class DeploymentProperties(msrest.serialization.Model): You use this element when you want to provide the parameter values directly in the request rather than link to an existing parameter file. Use either the parametersLink property or the parameters property, but not both. It can be a JObject or a well formed JSON string. - :vartype parameters: any + :vartype parameters: JSON :ivar parameters_link: The URI of parameters file. You use this element to link to an existing parameters file. Use either the parametersLink property or the parameters property, but not both. :vartype parameters_link: ~azure.mgmt.resource.resources.v2019_10_01.models.ParametersLink - :ivar mode: Required. The mode that is used to deploy resources. This value can be either - Incremental or Complete. In Incremental mode, resources are deployed without deleting existing - resources that are not included in the template. In Complete mode, resources are deployed and - existing resources in the resource group that are not included in the template are deleted. Be - careful when using Complete mode as you may unintentionally delete resources. Possible values - include: "Incremental", "Complete". + :ivar mode: The mode that is used to deploy resources. This value can be either Incremental or + Complete. In Incremental mode, resources are deployed without deleting existing resources that + are not included in the template. In Complete mode, resources are deployed and existing + resources in the resource group that are not included in the template are deleted. Be careful + when using Complete mode as you may unintentionally delete resources. Required. Known values + are: "Incremental" and "Complete". :vartype mode: str or ~azure.mgmt.resource.resources.v2019_10_01.models.DeploymentMode :ivar debug_setting: The debug setting of the deployment. :vartype debug_setting: ~azure.mgmt.resource.resources.v2019_10_01.models.DebugSetting @@ -646,29 +620,29 @@ class DeploymentProperties(msrest.serialization.Model): """ _validation = { - 'mode': {'required': True}, + "mode": {"required": True}, } _attribute_map = { - 'template': {'key': 'template', 'type': 'object'}, - 'template_link': {'key': 'templateLink', 'type': 'TemplateLink'}, - 'parameters': {'key': 'parameters', 'type': 'object'}, - 'parameters_link': {'key': 'parametersLink', 'type': 'ParametersLink'}, - 'mode': {'key': 'mode', 'type': 'str'}, - 'debug_setting': {'key': 'debugSetting', 'type': 'DebugSetting'}, - 'on_error_deployment': {'key': 'onErrorDeployment', 'type': 'OnErrorDeployment'}, + "template": {"key": "template", "type": "object"}, + "template_link": {"key": "templateLink", "type": "TemplateLink"}, + "parameters": {"key": "parameters", "type": "object"}, + "parameters_link": {"key": "parametersLink", "type": "ParametersLink"}, + "mode": {"key": "mode", "type": "str"}, + "debug_setting": {"key": "debugSetting", "type": "DebugSetting"}, + "on_error_deployment": {"key": "onErrorDeployment", "type": "OnErrorDeployment"}, } def __init__( self, *, - mode: Union[str, "DeploymentMode"], - template: Optional[Any] = None, - template_link: Optional["TemplateLink"] = None, - parameters: Optional[Any] = None, - parameters_link: Optional["ParametersLink"] = None, - debug_setting: Optional["DebugSetting"] = None, - on_error_deployment: Optional["OnErrorDeployment"] = None, + mode: Union[str, "_models.DeploymentMode"], + template: Optional[JSON] = None, + template_link: Optional["_models.TemplateLink"] = None, + parameters: Optional[JSON] = None, + parameters_link: Optional["_models.ParametersLink"] = None, + debug_setting: Optional["_models.DebugSetting"] = None, + on_error_deployment: Optional["_models.OnErrorDeployment"] = None, **kwargs ): """ @@ -676,7 +650,7 @@ def __init__( template syntax directly in the request rather than link to an existing template. It can be a JObject or well-formed JSON string. Use either the templateLink property or the template property, but not both. - :paramtype template: any + :paramtype template: JSON :keyword template_link: The URI of the template. Use either the templateLink property or the template property, but not both. :paramtype template_link: ~azure.mgmt.resource.resources.v2019_10_01.models.TemplateLink @@ -684,17 +658,17 @@ def __init__( template. You use this element when you want to provide the parameter values directly in the request rather than link to an existing parameter file. Use either the parametersLink property or the parameters property, but not both. It can be a JObject or a well formed JSON string. - :paramtype parameters: any + :paramtype parameters: JSON :keyword parameters_link: The URI of parameters file. You use this element to link to an existing parameters file. Use either the parametersLink property or the parameters property, but not both. :paramtype parameters_link: ~azure.mgmt.resource.resources.v2019_10_01.models.ParametersLink - :keyword mode: Required. The mode that is used to deploy resources. This value can be either - Incremental or Complete. In Incremental mode, resources are deployed without deleting existing - resources that are not included in the template. In Complete mode, resources are deployed and - existing resources in the resource group that are not included in the template are deleted. Be - careful when using Complete mode as you may unintentionally delete resources. Possible values - include: "Incremental", "Complete". + :keyword mode: The mode that is used to deploy resources. This value can be either Incremental + or Complete. In Incremental mode, resources are deployed without deleting existing resources + that are not included in the template. In Complete mode, resources are deployed and existing + resources in the resource group that are not included in the template are deleted. Be careful + when using Complete mode as you may unintentionally delete resources. Required. Known values + are: "Incremental" and "Complete". :paramtype mode: str or ~azure.mgmt.resource.resources.v2019_10_01.models.DeploymentMode :keyword debug_setting: The debug setting of the deployment. :paramtype debug_setting: ~azure.mgmt.resource.resources.v2019_10_01.models.DebugSetting @@ -702,7 +676,7 @@ def __init__( :paramtype on_error_deployment: ~azure.mgmt.resource.resources.v2019_10_01.models.OnErrorDeployment """ - super(DeploymentProperties, self).__init__(**kwargs) + super().__init__(**kwargs) self.template = template self.template_link = template_link self.parameters = parameters @@ -712,7 +686,7 @@ def __init__( self.on_error_deployment = on_error_deployment -class DeploymentPropertiesExtended(msrest.serialization.Model): +class DeploymentPropertiesExtended(_serialization.Model): # pylint: disable=too-many-instance-attributes """Deployment properties with additional details. Variables are only populated by the server, and will be ignored when sending a request. @@ -726,7 +700,7 @@ class DeploymentPropertiesExtended(msrest.serialization.Model): :ivar duration: The duration of the template deployment. :vartype duration: str :ivar outputs: Key/value pairs that represent deployment output. - :vartype outputs: any + :vartype outputs: JSON :ivar providers: The list of resource providers needed for the deployment. :vartype providers: list[~azure.mgmt.resource.resources.v2019_10_01.models.Provider] :ivar dependencies: The list of deployment dependencies. @@ -734,11 +708,11 @@ class DeploymentPropertiesExtended(msrest.serialization.Model): :ivar template_link: The URI referencing the template. :vartype template_link: ~azure.mgmt.resource.resources.v2019_10_01.models.TemplateLink :ivar parameters: Deployment parameters. - :vartype parameters: any + :vartype parameters: JSON :ivar parameters_link: The URI referencing the parameters. :vartype parameters_link: ~azure.mgmt.resource.resources.v2019_10_01.models.ParametersLink - :ivar mode: The deployment mode. Possible values are Incremental and Complete. Possible values - include: "Incremental", "Complete". + :ivar mode: The deployment mode. Possible values are Incremental and Complete. Known values + are: "Incremental" and "Complete". :vartype mode: str or ~azure.mgmt.resource.resources.v2019_10_01.models.DeploymentMode :ivar debug_setting: The debug setting of the deployment. :vartype debug_setting: ~azure.mgmt.resource.resources.v2019_10_01.models.DebugSetting @@ -758,52 +732,48 @@ class DeploymentPropertiesExtended(msrest.serialization.Model): """ _validation = { - 'provisioning_state': {'readonly': True}, - 'correlation_id': {'readonly': True}, - 'timestamp': {'readonly': True}, - 'duration': {'readonly': True}, - 'outputs': {'readonly': True}, - 'providers': {'readonly': True}, - 'dependencies': {'readonly': True}, - 'template_link': {'readonly': True}, - 'parameters': {'readonly': True}, - 'parameters_link': {'readonly': True}, - 'mode': {'readonly': True}, - 'debug_setting': {'readonly': True}, - 'on_error_deployment': {'readonly': True}, - 'template_hash': {'readonly': True}, - 'output_resources': {'readonly': True}, - 'validated_resources': {'readonly': True}, - 'error': {'readonly': True}, - } - - _attribute_map = { - 'provisioning_state': {'key': 'provisioningState', 'type': 'str'}, - 'correlation_id': {'key': 'correlationId', 'type': 'str'}, - 'timestamp': {'key': 'timestamp', 'type': 'iso-8601'}, - 'duration': {'key': 'duration', 'type': 'str'}, - 'outputs': {'key': 'outputs', 'type': 'object'}, - 'providers': {'key': 'providers', 'type': '[Provider]'}, - 'dependencies': {'key': 'dependencies', 'type': '[Dependency]'}, - 'template_link': {'key': 'templateLink', 'type': 'TemplateLink'}, - 'parameters': {'key': 'parameters', 'type': 'object'}, - 'parameters_link': {'key': 'parametersLink', 'type': 'ParametersLink'}, - 'mode': {'key': 'mode', 'type': 'str'}, - 'debug_setting': {'key': 'debugSetting', 'type': 'DebugSetting'}, - 'on_error_deployment': {'key': 'onErrorDeployment', 'type': 'OnErrorDeploymentExtended'}, - 'template_hash': {'key': 'templateHash', 'type': 'str'}, - 'output_resources': {'key': 'outputResources', 'type': '[ResourceReference]'}, - 'validated_resources': {'key': 'validatedResources', 'type': '[ResourceReference]'}, - 'error': {'key': 'error', 'type': 'ErrorResponse'}, - } - - def __init__( - self, - **kwargs - ): - """ - """ - super(DeploymentPropertiesExtended, self).__init__(**kwargs) + "provisioning_state": {"readonly": True}, + "correlation_id": {"readonly": True}, + "timestamp": {"readonly": True}, + "duration": {"readonly": True}, + "outputs": {"readonly": True}, + "providers": {"readonly": True}, + "dependencies": {"readonly": True}, + "template_link": {"readonly": True}, + "parameters": {"readonly": True}, + "parameters_link": {"readonly": True}, + "mode": {"readonly": True}, + "debug_setting": {"readonly": True}, + "on_error_deployment": {"readonly": True}, + "template_hash": {"readonly": True}, + "output_resources": {"readonly": True}, + "validated_resources": {"readonly": True}, + "error": {"readonly": True}, + } + + _attribute_map = { + "provisioning_state": {"key": "provisioningState", "type": "str"}, + "correlation_id": {"key": "correlationId", "type": "str"}, + "timestamp": {"key": "timestamp", "type": "iso-8601"}, + "duration": {"key": "duration", "type": "str"}, + "outputs": {"key": "outputs", "type": "object"}, + "providers": {"key": "providers", "type": "[Provider]"}, + "dependencies": {"key": "dependencies", "type": "[Dependency]"}, + "template_link": {"key": "templateLink", "type": "TemplateLink"}, + "parameters": {"key": "parameters", "type": "object"}, + "parameters_link": {"key": "parametersLink", "type": "ParametersLink"}, + "mode": {"key": "mode", "type": "str"}, + "debug_setting": {"key": "debugSetting", "type": "DebugSetting"}, + "on_error_deployment": {"key": "onErrorDeployment", "type": "OnErrorDeploymentExtended"}, + "template_hash": {"key": "templateHash", "type": "str"}, + "output_resources": {"key": "outputResources", "type": "[ResourceReference]"}, + "validated_resources": {"key": "validatedResources", "type": "[ResourceReference]"}, + "error": {"key": "error", "type": "ErrorResponse"}, + } + + def __init__(self, **kwargs): + """ """ + super().__init__(**kwargs) self.provisioning_state = None self.correlation_id = None self.timestamp = None @@ -823,7 +793,7 @@ def __init__( self.error = None -class DeploymentValidateResult(msrest.serialization.Model): +class DeploymentValidateResult(_serialization.Model): """Information from validate template deployment response. Variables are only populated by the server, and will be ignored when sending a request. @@ -836,66 +806,55 @@ class DeploymentValidateResult(msrest.serialization.Model): """ _validation = { - 'error': {'readonly': True}, + "error": {"readonly": True}, } _attribute_map = { - 'error': {'key': 'error', 'type': 'ErrorResponse'}, - 'properties': {'key': 'properties', 'type': 'DeploymentPropertiesExtended'}, + "error": {"key": "error", "type": "ErrorResponse"}, + "properties": {"key": "properties", "type": "DeploymentPropertiesExtended"}, } - def __init__( - self, - *, - properties: Optional["DeploymentPropertiesExtended"] = None, - **kwargs - ): + def __init__(self, *, properties: Optional["_models.DeploymentPropertiesExtended"] = None, **kwargs): """ :keyword properties: The template deployment properties. :paramtype properties: ~azure.mgmt.resource.resources.v2019_10_01.models.DeploymentPropertiesExtended """ - super(DeploymentValidateResult, self).__init__(**kwargs) + super().__init__(**kwargs) self.error = None self.properties = properties -class DeploymentWhatIf(msrest.serialization.Model): +class DeploymentWhatIf(_serialization.Model): """Deployment What-if operation parameters. All required parameters must be populated in order to send to Azure. :ivar location: The location to store the deployment data. :vartype location: str - :ivar properties: Required. The deployment properties. + :ivar properties: The deployment properties. Required. :vartype properties: ~azure.mgmt.resource.resources.v2019_10_01.models.DeploymentWhatIfProperties """ _validation = { - 'properties': {'required': True}, + "properties": {"required": True}, } _attribute_map = { - 'location': {'key': 'location', 'type': 'str'}, - 'properties': {'key': 'properties', 'type': 'DeploymentWhatIfProperties'}, + "location": {"key": "location", "type": "str"}, + "properties": {"key": "properties", "type": "DeploymentWhatIfProperties"}, } - def __init__( - self, - *, - properties: "DeploymentWhatIfProperties", - location: Optional[str] = None, - **kwargs - ): + def __init__(self, *, properties: "_models.DeploymentWhatIfProperties", location: Optional[str] = None, **kwargs): """ :keyword location: The location to store the deployment data. :paramtype location: str - :keyword properties: Required. The deployment properties. + :keyword properties: The deployment properties. Required. :paramtype properties: ~azure.mgmt.resource.resources.v2019_10_01.models.DeploymentWhatIfProperties """ - super(DeploymentWhatIf, self).__init__(**kwargs) + super().__init__(**kwargs) self.location = location self.properties = properties @@ -909,7 +868,7 @@ class DeploymentWhatIfProperties(DeploymentProperties): syntax directly in the request rather than link to an existing template. It can be a JObject or well-formed JSON string. Use either the templateLink property or the template property, but not both. - :vartype template: any + :vartype template: JSON :ivar template_link: The URI of the template. Use either the templateLink property or the template property, but not both. :vartype template_link: ~azure.mgmt.resource.resources.v2019_10_01.models.TemplateLink @@ -917,17 +876,17 @@ class DeploymentWhatIfProperties(DeploymentProperties): You use this element when you want to provide the parameter values directly in the request rather than link to an existing parameter file. Use either the parametersLink property or the parameters property, but not both. It can be a JObject or a well formed JSON string. - :vartype parameters: any + :vartype parameters: JSON :ivar parameters_link: The URI of parameters file. You use this element to link to an existing parameters file. Use either the parametersLink property or the parameters property, but not both. :vartype parameters_link: ~azure.mgmt.resource.resources.v2019_10_01.models.ParametersLink - :ivar mode: Required. The mode that is used to deploy resources. This value can be either - Incremental or Complete. In Incremental mode, resources are deployed without deleting existing - resources that are not included in the template. In Complete mode, resources are deployed and - existing resources in the resource group that are not included in the template are deleted. Be - careful when using Complete mode as you may unintentionally delete resources. Possible values - include: "Incremental", "Complete". + :ivar mode: The mode that is used to deploy resources. This value can be either Incremental or + Complete. In Incremental mode, resources are deployed without deleting existing resources that + are not included in the template. In Complete mode, resources are deployed and existing + resources in the resource group that are not included in the template are deleted. Be careful + when using Complete mode as you may unintentionally delete resources. Required. Known values + are: "Incremental" and "Complete". :vartype mode: str or ~azure.mgmt.resource.resources.v2019_10_01.models.DeploymentMode :ivar debug_setting: The debug setting of the deployment. :vartype debug_setting: ~azure.mgmt.resource.resources.v2019_10_01.models.DebugSetting @@ -940,31 +899,31 @@ class DeploymentWhatIfProperties(DeploymentProperties): """ _validation = { - 'mode': {'required': True}, + "mode": {"required": True}, } _attribute_map = { - 'template': {'key': 'template', 'type': 'object'}, - 'template_link': {'key': 'templateLink', 'type': 'TemplateLink'}, - 'parameters': {'key': 'parameters', 'type': 'object'}, - 'parameters_link': {'key': 'parametersLink', 'type': 'ParametersLink'}, - 'mode': {'key': 'mode', 'type': 'str'}, - 'debug_setting': {'key': 'debugSetting', 'type': 'DebugSetting'}, - 'on_error_deployment': {'key': 'onErrorDeployment', 'type': 'OnErrorDeployment'}, - 'what_if_settings': {'key': 'whatIfSettings', 'type': 'DeploymentWhatIfSettings'}, + "template": {"key": "template", "type": "object"}, + "template_link": {"key": "templateLink", "type": "TemplateLink"}, + "parameters": {"key": "parameters", "type": "object"}, + "parameters_link": {"key": "parametersLink", "type": "ParametersLink"}, + "mode": {"key": "mode", "type": "str"}, + "debug_setting": {"key": "debugSetting", "type": "DebugSetting"}, + "on_error_deployment": {"key": "onErrorDeployment", "type": "OnErrorDeployment"}, + "what_if_settings": {"key": "whatIfSettings", "type": "DeploymentWhatIfSettings"}, } def __init__( self, *, - mode: Union[str, "DeploymentMode"], - template: Optional[Any] = None, - template_link: Optional["TemplateLink"] = None, - parameters: Optional[Any] = None, - parameters_link: Optional["ParametersLink"] = None, - debug_setting: Optional["DebugSetting"] = None, - on_error_deployment: Optional["OnErrorDeployment"] = None, - what_if_settings: Optional["DeploymentWhatIfSettings"] = None, + mode: Union[str, "_models.DeploymentMode"], + template: Optional[JSON] = None, + template_link: Optional["_models.TemplateLink"] = None, + parameters: Optional[JSON] = None, + parameters_link: Optional["_models.ParametersLink"] = None, + debug_setting: Optional["_models.DebugSetting"] = None, + on_error_deployment: Optional["_models.OnErrorDeployment"] = None, + what_if_settings: Optional["_models.DeploymentWhatIfSettings"] = None, **kwargs ): """ @@ -972,7 +931,7 @@ def __init__( template syntax directly in the request rather than link to an existing template. It can be a JObject or well-formed JSON string. Use either the templateLink property or the template property, but not both. - :paramtype template: any + :paramtype template: JSON :keyword template_link: The URI of the template. Use either the templateLink property or the template property, but not both. :paramtype template_link: ~azure.mgmt.resource.resources.v2019_10_01.models.TemplateLink @@ -980,17 +939,17 @@ def __init__( template. You use this element when you want to provide the parameter values directly in the request rather than link to an existing parameter file. Use either the parametersLink property or the parameters property, but not both. It can be a JObject or a well formed JSON string. - :paramtype parameters: any + :paramtype parameters: JSON :keyword parameters_link: The URI of parameters file. You use this element to link to an existing parameters file. Use either the parametersLink property or the parameters property, but not both. :paramtype parameters_link: ~azure.mgmt.resource.resources.v2019_10_01.models.ParametersLink - :keyword mode: Required. The mode that is used to deploy resources. This value can be either - Incremental or Complete. In Incremental mode, resources are deployed without deleting existing - resources that are not included in the template. In Complete mode, resources are deployed and - existing resources in the resource group that are not included in the template are deleted. Be - careful when using Complete mode as you may unintentionally delete resources. Possible values - include: "Incremental", "Complete". + :keyword mode: The mode that is used to deploy resources. This value can be either Incremental + or Complete. In Incremental mode, resources are deployed without deleting existing resources + that are not included in the template. In Complete mode, resources are deployed and existing + resources in the resource group that are not included in the template are deleted. Be careful + when using Complete mode as you may unintentionally delete resources. Required. Known values + are: "Incremental" and "Complete". :paramtype mode: str or ~azure.mgmt.resource.resources.v2019_10_01.models.DeploymentMode :keyword debug_setting: The debug setting of the deployment. :paramtype debug_setting: ~azure.mgmt.resource.resources.v2019_10_01.models.DebugSetting @@ -1001,40 +960,44 @@ def __init__( :paramtype what_if_settings: ~azure.mgmt.resource.resources.v2019_10_01.models.DeploymentWhatIfSettings """ - super(DeploymentWhatIfProperties, self).__init__(template=template, template_link=template_link, parameters=parameters, parameters_link=parameters_link, mode=mode, debug_setting=debug_setting, on_error_deployment=on_error_deployment, **kwargs) + super().__init__( + template=template, + template_link=template_link, + parameters=parameters, + parameters_link=parameters_link, + mode=mode, + debug_setting=debug_setting, + on_error_deployment=on_error_deployment, + **kwargs + ) self.what_if_settings = what_if_settings -class DeploymentWhatIfSettings(msrest.serialization.Model): +class DeploymentWhatIfSettings(_serialization.Model): """Deployment What-If operation settings. - :ivar result_format: The format of the What-If results. Possible values include: - "ResourceIdOnly", "FullResourcePayloads". + :ivar result_format: The format of the What-If results. Known values are: "ResourceIdOnly" and + "FullResourcePayloads". :vartype result_format: str or ~azure.mgmt.resource.resources.v2019_10_01.models.WhatIfResultFormat """ _attribute_map = { - 'result_format': {'key': 'resultFormat', 'type': 'str'}, + "result_format": {"key": "resultFormat", "type": "str"}, } - def __init__( - self, - *, - result_format: Optional[Union[str, "WhatIfResultFormat"]] = None, - **kwargs - ): + def __init__(self, *, result_format: Optional[Union[str, "_models.WhatIfResultFormat"]] = None, **kwargs): """ - :keyword result_format: The format of the What-If results. Possible values include: - "ResourceIdOnly", "FullResourcePayloads". + :keyword result_format: The format of the What-If results. Known values are: "ResourceIdOnly" + and "FullResourcePayloads". :paramtype result_format: str or ~azure.mgmt.resource.resources.v2019_10_01.models.WhatIfResultFormat """ - super(DeploymentWhatIfSettings, self).__init__(**kwargs) + super().__init__(**kwargs) self.result_format = result_format -class ErrorAdditionalInfo(msrest.serialization.Model): +class ErrorAdditionalInfo(_serialization.Model): """The resource management error additional info. Variables are only populated by the server, and will be ignored when sending a request. @@ -1042,31 +1005,27 @@ class ErrorAdditionalInfo(msrest.serialization.Model): :ivar type: The additional info type. :vartype type: str :ivar info: The additional info. - :vartype info: any + :vartype info: JSON """ _validation = { - 'type': {'readonly': True}, - 'info': {'readonly': True}, + "type": {"readonly": True}, + "info": {"readonly": True}, } _attribute_map = { - 'type': {'key': 'type', 'type': 'str'}, - 'info': {'key': 'info', 'type': 'object'}, + "type": {"key": "type", "type": "str"}, + "info": {"key": "info", "type": "object"}, } - def __init__( - self, - **kwargs - ): - """ - """ - super(ErrorAdditionalInfo, self).__init__(**kwargs) + def __init__(self, **kwargs): + """ """ + super().__init__(**kwargs) self.type = None self.info = None -class ErrorResponse(msrest.serialization.Model): +class ErrorResponse(_serialization.Model): """Common error response for all Azure Resource Manager APIs to return error details for failed operations. (This also follows the OData error response format.). Variables are only populated by the server, and will be ignored when sending a request. @@ -1085,28 +1044,24 @@ class ErrorResponse(msrest.serialization.Model): """ _validation = { - 'code': {'readonly': True}, - 'message': {'readonly': True}, - 'target': {'readonly': True}, - 'details': {'readonly': True}, - 'additional_info': {'readonly': True}, + "code": {"readonly": True}, + "message": {"readonly": True}, + "target": {"readonly": True}, + "details": {"readonly": True}, + "additional_info": {"readonly": True}, } _attribute_map = { - 'code': {'key': 'code', 'type': 'str'}, - 'message': {'key': 'message', 'type': 'str'}, - 'target': {'key': 'target', 'type': 'str'}, - 'details': {'key': 'details', 'type': '[ErrorResponse]'}, - 'additional_info': {'key': 'additionalInfo', 'type': '[ErrorAdditionalInfo]'}, + "code": {"key": "code", "type": "str"}, + "message": {"key": "message", "type": "str"}, + "target": {"key": "target", "type": "str"}, + "details": {"key": "details", "type": "[ErrorResponse]"}, + "additional_info": {"key": "additionalInfo", "type": "[ErrorAdditionalInfo]"}, } - def __init__( - self, - **kwargs - ): - """ - """ - super(ErrorResponse, self).__init__(**kwargs) + def __init__(self, **kwargs): + """ """ + super().__init__(**kwargs) self.code = None self.message = None self.target = None @@ -1114,7 +1069,7 @@ def __init__( self.additional_info = None -class ExportTemplateRequest(msrest.serialization.Model): +class ExportTemplateRequest(_serialization.Model): """Export resource group template request parameters. :ivar resources: The IDs of the resources to filter the export by. To export all resources, @@ -1127,17 +1082,11 @@ class ExportTemplateRequest(msrest.serialization.Model): """ _attribute_map = { - 'resources': {'key': 'resources', 'type': '[str]'}, - 'options': {'key': 'options', 'type': 'str'}, + "resources": {"key": "resources", "type": "[str]"}, + "options": {"key": "options", "type": "str"}, } - def __init__( - self, - *, - resources: Optional[List[str]] = None, - options: Optional[str] = None, - **kwargs - ): + def __init__(self, *, resources: Optional[List[str]] = None, options: Optional[str] = None, **kwargs): """ :keyword resources: The IDs of the resources to filter the export by. To export all resources, supply an array with single entry '*'. @@ -1147,12 +1096,12 @@ def __init__( 'SkipResourceNameParameterization', 'SkipAllParameterization'. :paramtype options: str """ - super(ExportTemplateRequest, self).__init__(**kwargs) + super().__init__(**kwargs) self.resources = resources self.options = options -class Resource(msrest.serialization.Model): +class Resource(_serialization.Model): """Specified resource. Variables are only populated by the server, and will be ignored when sending a request. @@ -1165,38 +1114,32 @@ class Resource(msrest.serialization.Model): :vartype type: str :ivar location: Resource location. :vartype location: str - :ivar tags: A set of tags. Resource tags. + :ivar tags: Resource tags. :vartype tags: dict[str, str] """ _validation = { - 'id': {'readonly': True}, - 'name': {'readonly': True}, - 'type': {'readonly': True}, + "id": {"readonly": True}, + "name": {"readonly": True}, + "type": {"readonly": True}, } _attribute_map = { - 'id': {'key': 'id', 'type': 'str'}, - 'name': {'key': 'name', 'type': 'str'}, - 'type': {'key': 'type', 'type': 'str'}, - 'location': {'key': 'location', 'type': 'str'}, - 'tags': {'key': 'tags', 'type': '{str}'}, + "id": {"key": "id", "type": "str"}, + "name": {"key": "name", "type": "str"}, + "type": {"key": "type", "type": "str"}, + "location": {"key": "location", "type": "str"}, + "tags": {"key": "tags", "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): """ :keyword location: Resource location. :paramtype location: str - :keyword tags: A set of tags. Resource tags. + :keyword tags: Resource tags. :paramtype tags: dict[str, str] """ - super(Resource, self).__init__(**kwargs) + super().__init__(**kwargs) self.id = None self.name = None self.type = None @@ -1204,7 +1147,7 @@ def __init__( self.tags = tags -class GenericResource(Resource): +class GenericResource(Resource): # pylint: disable=too-many-instance-attributes """Resource information. Variables are only populated by the server, and will be ignored when sending a request. @@ -1217,12 +1160,12 @@ class GenericResource(Resource): :vartype type: str :ivar location: Resource location. :vartype location: str - :ivar tags: A set of tags. Resource tags. + :ivar tags: Resource tags. :vartype tags: dict[str, str] :ivar plan: The plan of the resource. :vartype plan: ~azure.mgmt.resource.resources.v2019_10_01.models.Plan :ivar properties: The resource properties. - :vartype properties: any + :vartype properties: JSON :ivar kind: The kind of the resource. :vartype kind: str :ivar managed_by: ID of the resource that manages this resource. @@ -1234,24 +1177,24 @@ class GenericResource(Resource): """ _validation = { - 'id': {'readonly': True}, - 'name': {'readonly': True}, - 'type': {'readonly': True}, - 'kind': {'pattern': r'^[-\w\._,\(\)]+$'}, + "id": {"readonly": True}, + "name": {"readonly": True}, + "type": {"readonly": True}, + "kind": {"pattern": r"^[-\w\._,\(\)]+$"}, } _attribute_map = { - 'id': {'key': 'id', 'type': 'str'}, - 'name': {'key': 'name', 'type': 'str'}, - 'type': {'key': 'type', 'type': 'str'}, - 'location': {'key': 'location', 'type': 'str'}, - 'tags': {'key': 'tags', 'type': '{str}'}, - 'plan': {'key': 'plan', 'type': 'Plan'}, - 'properties': {'key': 'properties', 'type': 'object'}, - 'kind': {'key': 'kind', 'type': 'str'}, - 'managed_by': {'key': 'managedBy', 'type': 'str'}, - 'sku': {'key': 'sku', 'type': 'Sku'}, - 'identity': {'key': 'identity', 'type': 'Identity'}, + "id": {"key": "id", "type": "str"}, + "name": {"key": "name", "type": "str"}, + "type": {"key": "type", "type": "str"}, + "location": {"key": "location", "type": "str"}, + "tags": {"key": "tags", "type": "{str}"}, + "plan": {"key": "plan", "type": "Plan"}, + "properties": {"key": "properties", "type": "object"}, + "kind": {"key": "kind", "type": "str"}, + "managed_by": {"key": "managedBy", "type": "str"}, + "sku": {"key": "sku", "type": "Sku"}, + "identity": {"key": "identity", "type": "Identity"}, } def __init__( @@ -1259,23 +1202,23 @@ def __init__( *, location: Optional[str] = None, tags: Optional[Dict[str, str]] = None, - plan: Optional["Plan"] = None, - properties: Optional[Any] = None, + plan: Optional["_models.Plan"] = None, + properties: Optional[JSON] = None, kind: Optional[str] = None, managed_by: Optional[str] = None, - sku: Optional["Sku"] = None, - identity: Optional["Identity"] = None, + sku: Optional["_models.Sku"] = None, + identity: Optional["_models.Identity"] = None, **kwargs ): """ :keyword location: Resource location. :paramtype location: str - :keyword tags: A set of tags. Resource tags. + :keyword tags: Resource tags. :paramtype tags: dict[str, str] :keyword plan: The plan of the resource. :paramtype plan: ~azure.mgmt.resource.resources.v2019_10_01.models.Plan :keyword properties: The resource properties. - :paramtype properties: any + :paramtype properties: JSON :keyword kind: The kind of the resource. :paramtype kind: str :keyword managed_by: ID of the resource that manages this resource. @@ -1285,7 +1228,7 @@ def __init__( :keyword identity: The identity of the resource. :paramtype identity: ~azure.mgmt.resource.resources.v2019_10_01.models.Identity """ - super(GenericResource, self).__init__(location=location, tags=tags, **kwargs) + super().__init__(location=location, tags=tags, **kwargs) self.plan = plan self.properties = properties self.kind = kind @@ -1294,7 +1237,7 @@ def __init__( self.identity = identity -class GenericResourceExpanded(GenericResource): +class GenericResourceExpanded(GenericResource): # pylint: disable=too-many-instance-attributes """Resource information. Variables are only populated by the server, and will be ignored when sending a request. @@ -1307,12 +1250,12 @@ class GenericResourceExpanded(GenericResource): :vartype type: str :ivar location: Resource location. :vartype location: str - :ivar tags: A set of tags. Resource tags. + :ivar tags: Resource tags. :vartype tags: dict[str, str] :ivar plan: The plan of the resource. :vartype plan: ~azure.mgmt.resource.resources.v2019_10_01.models.Plan :ivar properties: The resource properties. - :vartype properties: any + :vartype properties: JSON :ivar kind: The kind of the resource. :vartype kind: str :ivar managed_by: ID of the resource that manages this resource. @@ -1333,30 +1276,30 @@ class GenericResourceExpanded(GenericResource): """ _validation = { - 'id': {'readonly': True}, - 'name': {'readonly': True}, - 'type': {'readonly': True}, - 'kind': {'pattern': r'^[-\w\._,\(\)]+$'}, - 'created_time': {'readonly': True}, - 'changed_time': {'readonly': True}, - 'provisioning_state': {'readonly': True}, - } - - _attribute_map = { - 'id': {'key': 'id', 'type': 'str'}, - 'name': {'key': 'name', 'type': 'str'}, - 'type': {'key': 'type', 'type': 'str'}, - 'location': {'key': 'location', 'type': 'str'}, - 'tags': {'key': 'tags', 'type': '{str}'}, - 'plan': {'key': 'plan', 'type': 'Plan'}, - 'properties': {'key': 'properties', 'type': 'object'}, - 'kind': {'key': 'kind', 'type': 'str'}, - 'managed_by': {'key': 'managedBy', 'type': 'str'}, - 'sku': {'key': 'sku', 'type': 'Sku'}, - 'identity': {'key': 'identity', 'type': 'Identity'}, - 'created_time': {'key': 'createdTime', 'type': 'iso-8601'}, - 'changed_time': {'key': 'changedTime', 'type': 'iso-8601'}, - 'provisioning_state': {'key': 'provisioningState', 'type': 'str'}, + "id": {"readonly": True}, + "name": {"readonly": True}, + "type": {"readonly": True}, + "kind": {"pattern": r"^[-\w\._,\(\)]+$"}, + "created_time": {"readonly": True}, + "changed_time": {"readonly": True}, + "provisioning_state": {"readonly": True}, + } + + _attribute_map = { + "id": {"key": "id", "type": "str"}, + "name": {"key": "name", "type": "str"}, + "type": {"key": "type", "type": "str"}, + "location": {"key": "location", "type": "str"}, + "tags": {"key": "tags", "type": "{str}"}, + "plan": {"key": "plan", "type": "Plan"}, + "properties": {"key": "properties", "type": "object"}, + "kind": {"key": "kind", "type": "str"}, + "managed_by": {"key": "managedBy", "type": "str"}, + "sku": {"key": "sku", "type": "Sku"}, + "identity": {"key": "identity", "type": "Identity"}, + "created_time": {"key": "createdTime", "type": "iso-8601"}, + "changed_time": {"key": "changedTime", "type": "iso-8601"}, + "provisioning_state": {"key": "provisioningState", "type": "str"}, } def __init__( @@ -1364,23 +1307,23 @@ def __init__( *, location: Optional[str] = None, tags: Optional[Dict[str, str]] = None, - plan: Optional["Plan"] = None, - properties: Optional[Any] = None, + plan: Optional["_models.Plan"] = None, + properties: Optional[JSON] = None, kind: Optional[str] = None, managed_by: Optional[str] = None, - sku: Optional["Sku"] = None, - identity: Optional["Identity"] = None, + sku: Optional["_models.Sku"] = None, + identity: Optional["_models.Identity"] = None, **kwargs ): """ :keyword location: Resource location. :paramtype location: str - :keyword tags: A set of tags. Resource tags. + :keyword tags: Resource tags. :paramtype tags: dict[str, str] :keyword plan: The plan of the resource. :paramtype plan: ~azure.mgmt.resource.resources.v2019_10_01.models.Plan :keyword properties: The resource properties. - :paramtype properties: any + :paramtype properties: JSON :keyword kind: The kind of the resource. :paramtype kind: str :keyword managed_by: ID of the resource that manages this resource. @@ -1390,13 +1333,23 @@ def __init__( :keyword identity: The identity of the resource. :paramtype identity: ~azure.mgmt.resource.resources.v2019_10_01.models.Identity """ - super(GenericResourceExpanded, self).__init__(location=location, tags=tags, plan=plan, properties=properties, kind=kind, managed_by=managed_by, sku=sku, identity=identity, **kwargs) + super().__init__( + location=location, + tags=tags, + plan=plan, + properties=properties, + kind=kind, + managed_by=managed_by, + sku=sku, + identity=identity, + **kwargs + ) self.created_time = None self.changed_time = None self.provisioning_state = None -class GenericResourceFilter(msrest.serialization.Model): +class GenericResourceFilter(_serialization.Model): """Resource filter. :ivar resource_type: The resource type. @@ -1408,9 +1361,9 @@ class GenericResourceFilter(msrest.serialization.Model): """ _attribute_map = { - 'resource_type': {'key': 'resourceType', 'type': 'str'}, - 'tagname': {'key': 'tagname', 'type': 'str'}, - 'tagvalue': {'key': 'tagvalue', 'type': 'str'}, + "resource_type": {"key": "resourceType", "type": "str"}, + "tagname": {"key": "tagname", "type": "str"}, + "tagvalue": {"key": "tagvalue", "type": "str"}, } def __init__( @@ -1429,38 +1382,33 @@ def __init__( :keyword tagvalue: The tag value. :paramtype tagvalue: str """ - super(GenericResourceFilter, self).__init__(**kwargs) + super().__init__(**kwargs) self.resource_type = resource_type self.tagname = tagname self.tagvalue = tagvalue -class HttpMessage(msrest.serialization.Model): +class HttpMessage(_serialization.Model): """HTTP message. :ivar content: HTTP message content. - :vartype content: any + :vartype content: JSON """ _attribute_map = { - 'content': {'key': 'content', 'type': 'object'}, + "content": {"key": "content", "type": "object"}, } - def __init__( - self, - *, - content: Optional[Any] = None, - **kwargs - ): + def __init__(self, *, content: Optional[JSON] = None, **kwargs): """ :keyword content: HTTP message content. - :paramtype content: any + :paramtype content: JSON """ - super(HttpMessage, self).__init__(**kwargs) + super().__init__(**kwargs) self.content = content -class Identity(msrest.serialization.Model): +class Identity(_serialization.Model): """Identity for the resource. Variables are only populated by the server, and will be ignored when sending a request. @@ -1469,8 +1417,8 @@ class Identity(msrest.serialization.Model): :vartype principal_id: str :ivar tenant_id: The tenant ID of resource. :vartype tenant_id: str - :ivar type: The identity type. Possible values include: "SystemAssigned", "UserAssigned", - "SystemAssigned, UserAssigned", "None". + :ivar type: The identity type. Known values are: "SystemAssigned", "UserAssigned", + "SystemAssigned, UserAssigned", and "None". :vartype type: str or ~azure.mgmt.resource.resources.v2019_10_01.models.ResourceIdentityType :ivar user_assigned_identities: The list of user identities associated with the resource. The user identity dictionary key references will be ARM resource ids in the form: @@ -1480,27 +1428,27 @@ class Identity(msrest.serialization.Model): """ _validation = { - 'principal_id': {'readonly': True}, - 'tenant_id': {'readonly': True}, + "principal_id": {"readonly": True}, + "tenant_id": {"readonly": True}, } _attribute_map = { - 'principal_id': {'key': 'principalId', 'type': 'str'}, - 'tenant_id': {'key': 'tenantId', 'type': 'str'}, - 'type': {'key': 'type', 'type': 'str'}, - 'user_assigned_identities': {'key': 'userAssignedIdentities', 'type': '{IdentityUserAssignedIdentitiesValue}'}, + "principal_id": {"key": "principalId", "type": "str"}, + "tenant_id": {"key": "tenantId", "type": "str"}, + "type": {"key": "type", "type": "str"}, + "user_assigned_identities": {"key": "userAssignedIdentities", "type": "{IdentityUserAssignedIdentitiesValue}"}, } def __init__( self, *, - type: Optional[Union[str, "ResourceIdentityType"]] = None, - user_assigned_identities: Optional[Dict[str, "IdentityUserAssignedIdentitiesValue"]] = None, + type: Optional[Union[str, "_models.ResourceIdentityType"]] = None, + user_assigned_identities: Optional[Dict[str, "_models.IdentityUserAssignedIdentitiesValue"]] = None, **kwargs ): """ - :keyword type: The identity type. Possible values include: "SystemAssigned", "UserAssigned", - "SystemAssigned, UserAssigned", "None". + :keyword type: The identity type. Known values are: "SystemAssigned", "UserAssigned", + "SystemAssigned, UserAssigned", and "None". :paramtype type: str or ~azure.mgmt.resource.resources.v2019_10_01.models.ResourceIdentityType :keyword user_assigned_identities: The list of user identities associated with the resource. The user identity dictionary key references will be ARM resource ids in the form: @@ -1508,14 +1456,14 @@ def __init__( :paramtype user_assigned_identities: dict[str, ~azure.mgmt.resource.resources.v2019_10_01.models.IdentityUserAssignedIdentitiesValue] """ - super(Identity, self).__init__(**kwargs) + super().__init__(**kwargs) self.principal_id = None self.tenant_id = None self.type = type self.user_assigned_identities = user_assigned_identities -class IdentityUserAssignedIdentitiesValue(msrest.serialization.Model): +class IdentityUserAssignedIdentitiesValue(_serialization.Model): """IdentityUserAssignedIdentitiesValue. Variables are only populated by the server, and will be ignored when sending a request. @@ -1527,61 +1475,57 @@ class IdentityUserAssignedIdentitiesValue(msrest.serialization.Model): """ _validation = { - 'principal_id': {'readonly': True}, - 'client_id': {'readonly': True}, + "principal_id": {"readonly": True}, + "client_id": {"readonly": True}, } _attribute_map = { - 'principal_id': {'key': 'principalId', 'type': 'str'}, - 'client_id': {'key': 'clientId', 'type': 'str'}, + "principal_id": {"key": "principalId", "type": "str"}, + "client_id": {"key": "clientId", "type": "str"}, } - def __init__( - self, - **kwargs - ): - """ - """ - super(IdentityUserAssignedIdentitiesValue, self).__init__(**kwargs) + def __init__(self, **kwargs): + """ """ + super().__init__(**kwargs) self.principal_id = None self.client_id = None -class OnErrorDeployment(msrest.serialization.Model): +class OnErrorDeployment(_serialization.Model): """Deployment on error behavior. :ivar type: The deployment on error behavior type. Possible values are LastSuccessful and - SpecificDeployment. Possible values include: "LastSuccessful", "SpecificDeployment". + SpecificDeployment. Known values are: "LastSuccessful" and "SpecificDeployment". :vartype type: str or ~azure.mgmt.resource.resources.v2019_10_01.models.OnErrorDeploymentType :ivar deployment_name: The deployment to be used on error case. :vartype deployment_name: str """ _attribute_map = { - 'type': {'key': 'type', 'type': 'str'}, - 'deployment_name': {'key': 'deploymentName', 'type': 'str'}, + "type": {"key": "type", "type": "str"}, + "deployment_name": {"key": "deploymentName", "type": "str"}, } def __init__( self, *, - type: Optional[Union[str, "OnErrorDeploymentType"]] = None, + type: Optional[Union[str, "_models.OnErrorDeploymentType"]] = None, deployment_name: Optional[str] = None, **kwargs ): """ :keyword type: The deployment on error behavior type. Possible values are LastSuccessful and - SpecificDeployment. Possible values include: "LastSuccessful", "SpecificDeployment". + SpecificDeployment. Known values are: "LastSuccessful" and "SpecificDeployment". :paramtype type: str or ~azure.mgmt.resource.resources.v2019_10_01.models.OnErrorDeploymentType :keyword deployment_name: The deployment to be used on error case. :paramtype deployment_name: str """ - super(OnErrorDeployment, self).__init__(**kwargs) + super().__init__(**kwargs) self.type = type self.deployment_name = deployment_name -class OnErrorDeploymentExtended(msrest.serialization.Model): +class OnErrorDeploymentExtended(_serialization.Model): """Deployment on error behavior with additional details. Variables are only populated by the server, and will be ignored when sending a request. @@ -1589,43 +1533,43 @@ class OnErrorDeploymentExtended(msrest.serialization.Model): :ivar provisioning_state: The state of the provisioning for the on error deployment. :vartype provisioning_state: str :ivar type: The deployment on error behavior type. Possible values are LastSuccessful and - SpecificDeployment. Possible values include: "LastSuccessful", "SpecificDeployment". + SpecificDeployment. Known values are: "LastSuccessful" and "SpecificDeployment". :vartype type: str or ~azure.mgmt.resource.resources.v2019_10_01.models.OnErrorDeploymentType :ivar deployment_name: The deployment to be used on error case. :vartype deployment_name: str """ _validation = { - 'provisioning_state': {'readonly': True}, + "provisioning_state": {"readonly": True}, } _attribute_map = { - 'provisioning_state': {'key': 'provisioningState', 'type': 'str'}, - 'type': {'key': 'type', 'type': 'str'}, - 'deployment_name': {'key': 'deploymentName', 'type': 'str'}, + "provisioning_state": {"key": "provisioningState", "type": "str"}, + "type": {"key": "type", "type": "str"}, + "deployment_name": {"key": "deploymentName", "type": "str"}, } def __init__( self, *, - type: Optional[Union[str, "OnErrorDeploymentType"]] = None, + type: Optional[Union[str, "_models.OnErrorDeploymentType"]] = None, deployment_name: Optional[str] = None, **kwargs ): """ :keyword type: The deployment on error behavior type. Possible values are LastSuccessful and - SpecificDeployment. Possible values include: "LastSuccessful", "SpecificDeployment". + SpecificDeployment. Known values are: "LastSuccessful" and "SpecificDeployment". :paramtype type: str or ~azure.mgmt.resource.resources.v2019_10_01.models.OnErrorDeploymentType :keyword deployment_name: The deployment to be used on error case. :paramtype deployment_name: str """ - super(OnErrorDeploymentExtended, self).__init__(**kwargs) + super().__init__(**kwargs) self.provisioning_state = None self.type = type self.deployment_name = deployment_name -class Operation(msrest.serialization.Model): +class Operation(_serialization.Model): """Microsoft.Resources operation. :ivar name: Operation name: {provider}/{resource}/{operation}. @@ -1635,29 +1579,23 @@ class Operation(msrest.serialization.Model): """ _attribute_map = { - 'name': {'key': 'name', 'type': 'str'}, - 'display': {'key': 'display', 'type': 'OperationDisplay'}, + "name": {"key": "name", "type": "str"}, + "display": {"key": "display", "type": "OperationDisplay"}, } - def __init__( - self, - *, - name: Optional[str] = None, - display: Optional["OperationDisplay"] = None, - **kwargs - ): + def __init__(self, *, name: Optional[str] = None, display: Optional["_models.OperationDisplay"] = None, **kwargs): """ :keyword name: Operation name: {provider}/{resource}/{operation}. :paramtype name: str :keyword display: The object that represents the operation. :paramtype display: ~azure.mgmt.resource.resources.v2019_10_01.models.OperationDisplay """ - super(Operation, self).__init__(**kwargs) + super().__init__(**kwargs) self.name = name self.display = display -class OperationDisplay(msrest.serialization.Model): +class OperationDisplay(_serialization.Model): """The object that represents the operation. :ivar provider: Service provider: Microsoft.Resources. @@ -1671,10 +1609,10 @@ class OperationDisplay(msrest.serialization.Model): """ _attribute_map = { - 'provider': {'key': 'provider', 'type': 'str'}, - 'resource': {'key': 'resource', 'type': 'str'}, - 'operation': {'key': 'operation', 'type': 'str'}, - 'description': {'key': 'description', 'type': 'str'}, + "provider": {"key": "provider", "type": "str"}, + "resource": {"key": "resource", "type": "str"}, + "operation": {"key": "operation", "type": "str"}, + "description": {"key": "description", "type": "str"}, } def __init__( @@ -1696,14 +1634,14 @@ def __init__( :keyword description: Description of the operation. :paramtype description: str """ - super(OperationDisplay, self).__init__(**kwargs) + super().__init__(**kwargs) self.provider = provider self.resource = resource self.operation = operation self.description = description -class OperationListResult(msrest.serialization.Model): +class OperationListResult(_serialization.Model): """Result of the request to list Microsoft.Resources operations. It contains a list of operations and a URL link to get the next set of results. :ivar value: List of Microsoft.Resources operations. @@ -1713,67 +1651,55 @@ class OperationListResult(msrest.serialization.Model): """ _attribute_map = { - 'value': {'key': 'value', 'type': '[Operation]'}, - 'next_link': {'key': 'nextLink', 'type': 'str'}, + "value": {"key": "value", "type": "[Operation]"}, + "next_link": {"key": "nextLink", "type": "str"}, } - def __init__( - self, - *, - value: Optional[List["Operation"]] = None, - next_link: Optional[str] = None, - **kwargs - ): + def __init__(self, *, value: Optional[List["_models.Operation"]] = None, next_link: Optional[str] = None, **kwargs): """ :keyword value: List of Microsoft.Resources operations. :paramtype value: list[~azure.mgmt.resource.resources.v2019_10_01.models.Operation] :keyword next_link: URL to get the next set of operation list results if there are any. :paramtype next_link: str """ - super(OperationListResult, self).__init__(**kwargs) + super().__init__(**kwargs) self.value = value self.next_link = next_link -class ParametersLink(msrest.serialization.Model): +class ParametersLink(_serialization.Model): """Entity representing the reference to the deployment parameters. All required parameters must be populated in order to send to Azure. - :ivar uri: Required. The URI of the parameters file. + :ivar uri: The URI of the parameters file. Required. :vartype uri: str :ivar content_version: If included, must match the ContentVersion in the template. :vartype content_version: str """ _validation = { - 'uri': {'required': True}, + "uri": {"required": True}, } _attribute_map = { - 'uri': {'key': 'uri', 'type': 'str'}, - 'content_version': {'key': 'contentVersion', 'type': 'str'}, + "uri": {"key": "uri", "type": "str"}, + "content_version": {"key": "contentVersion", "type": "str"}, } - def __init__( - self, - *, - uri: str, - content_version: Optional[str] = None, - **kwargs - ): + def __init__(self, *, uri: str, content_version: Optional[str] = None, **kwargs): """ - :keyword uri: Required. The URI of the parameters file. + :keyword uri: The URI of the parameters file. Required. :paramtype uri: str :keyword content_version: If included, must match the ContentVersion in the template. :paramtype content_version: str """ - super(ParametersLink, self).__init__(**kwargs) + super().__init__(**kwargs) self.uri = uri self.content_version = content_version -class Plan(msrest.serialization.Model): +class Plan(_serialization.Model): """Plan for the resource. :ivar name: The plan ID. @@ -1789,11 +1715,11 @@ class Plan(msrest.serialization.Model): """ _attribute_map = { - 'name': {'key': 'name', 'type': 'str'}, - 'publisher': {'key': 'publisher', 'type': 'str'}, - 'product': {'key': 'product', 'type': 'str'}, - 'promotion_code': {'key': 'promotionCode', 'type': 'str'}, - 'version': {'key': 'version', 'type': 'str'}, + "name": {"key": "name", "type": "str"}, + "publisher": {"key": "publisher", "type": "str"}, + "product": {"key": "product", "type": "str"}, + "promotion_code": {"key": "promotionCode", "type": "str"}, + "version": {"key": "version", "type": "str"}, } def __init__( @@ -1818,7 +1744,7 @@ def __init__( :keyword version: The plan's version. :paramtype version: str """ - super(Plan, self).__init__(**kwargs) + super().__init__(**kwargs) self.name = name self.publisher = publisher self.product = product @@ -1826,7 +1752,7 @@ def __init__( self.version = version -class Provider(msrest.serialization.Model): +class Provider(_serialization.Model): """Resource provider information. Variables are only populated by the server, and will be ignored when sending a request. @@ -1845,31 +1771,26 @@ class Provider(msrest.serialization.Model): """ _validation = { - 'id': {'readonly': True}, - 'registration_state': {'readonly': True}, - 'registration_policy': {'readonly': True}, - 'resource_types': {'readonly': True}, + "id": {"readonly": True}, + "registration_state": {"readonly": True}, + "registration_policy": {"readonly": True}, + "resource_types": {"readonly": True}, } _attribute_map = { - 'id': {'key': 'id', 'type': 'str'}, - 'namespace': {'key': 'namespace', 'type': 'str'}, - 'registration_state': {'key': 'registrationState', 'type': 'str'}, - 'registration_policy': {'key': 'registrationPolicy', 'type': 'str'}, - 'resource_types': {'key': 'resourceTypes', 'type': '[ProviderResourceType]'}, + "id": {"key": "id", "type": "str"}, + "namespace": {"key": "namespace", "type": "str"}, + "registration_state": {"key": "registrationState", "type": "str"}, + "registration_policy": {"key": "registrationPolicy", "type": "str"}, + "resource_types": {"key": "resourceTypes", "type": "[ProviderResourceType]"}, } - def __init__( - self, - *, - namespace: Optional[str] = None, - **kwargs - ): + def __init__(self, *, namespace: Optional[str] = None, **kwargs): """ :keyword namespace: The namespace of the resource provider. :paramtype namespace: str """ - super(Provider, self).__init__(**kwargs) + super().__init__(**kwargs) self.id = None self.namespace = namespace self.registration_state = None @@ -1877,7 +1798,7 @@ def __init__( self.resource_types = None -class ProviderListResult(msrest.serialization.Model): +class ProviderListResult(_serialization.Model): """List of resource providers. Variables are only populated by the server, and will be ignored when sending a request. @@ -1889,30 +1810,25 @@ class ProviderListResult(msrest.serialization.Model): """ _validation = { - 'next_link': {'readonly': True}, + "next_link": {"readonly": True}, } _attribute_map = { - 'value': {'key': 'value', 'type': '[Provider]'}, - 'next_link': {'key': 'nextLink', 'type': 'str'}, + "value": {"key": "value", "type": "[Provider]"}, + "next_link": {"key": "nextLink", "type": "str"}, } - def __init__( - self, - *, - value: Optional[List["Provider"]] = None, - **kwargs - ): + def __init__(self, *, value: Optional[List["_models.Provider"]] = None, **kwargs): """ :keyword value: An array of resource providers. :paramtype value: list[~azure.mgmt.resource.resources.v2019_10_01.models.Provider] """ - super(ProviderListResult, self).__init__(**kwargs) + super().__init__(**kwargs) self.value = value self.next_link = None -class ProviderResourceType(msrest.serialization.Model): +class ProviderResourceType(_serialization.Model): """Resource type managed by the resource provider. :ivar resource_type: The resource type. @@ -1932,13 +1848,13 @@ class ProviderResourceType(msrest.serialization.Model): """ _attribute_map = { - 'resource_type': {'key': 'resourceType', 'type': 'str'}, - 'locations': {'key': 'locations', 'type': '[str]'}, - 'aliases': {'key': 'aliases', 'type': '[Alias]'}, - 'api_versions': {'key': 'apiVersions', 'type': '[str]'}, - 'zone_mappings': {'key': 'zoneMappings', 'type': '[ZoneMapping]'}, - 'capabilities': {'key': 'capabilities', 'type': 'str'}, - 'properties': {'key': 'properties', 'type': '{str}'}, + "resource_type": {"key": "resourceType", "type": "str"}, + "locations": {"key": "locations", "type": "[str]"}, + "aliases": {"key": "aliases", "type": "[Alias]"}, + "api_versions": {"key": "apiVersions", "type": "[str]"}, + "zone_mappings": {"key": "zoneMappings", "type": "[ZoneMapping]"}, + "capabilities": {"key": "capabilities", "type": "str"}, + "properties": {"key": "properties", "type": "{str}"}, } def __init__( @@ -1946,9 +1862,9 @@ def __init__( *, resource_type: Optional[str] = None, locations: Optional[List[str]] = None, - aliases: Optional[List["Alias"]] = None, + aliases: Optional[List["_models.Alias"]] = None, api_versions: Optional[List[str]] = None, - zone_mappings: Optional[List["ZoneMapping"]] = None, + zone_mappings: Optional[List["_models.ZoneMapping"]] = None, capabilities: Optional[str] = None, properties: Optional[Dict[str, str]] = None, **kwargs @@ -1969,7 +1885,7 @@ def __init__( :keyword properties: The properties. :paramtype properties: dict[str, str] """ - super(ProviderResourceType, self).__init__(**kwargs) + super().__init__(**kwargs) self.resource_type = resource_type self.locations = locations self.aliases = aliases @@ -1979,7 +1895,7 @@ def __init__( self.properties = properties -class ResourceGroup(msrest.serialization.Model): +class ResourceGroup(_serialization.Model): """Resource group information. Variables are only populated by the server, and will be ignored when sending a request. @@ -1994,37 +1910,37 @@ class ResourceGroup(msrest.serialization.Model): :vartype type: str :ivar properties: The resource group properties. :vartype properties: ~azure.mgmt.resource.resources.v2019_10_01.models.ResourceGroupProperties - :ivar location: Required. The location of the resource group. It cannot be changed after the - resource group has been created. It must be one of the supported Azure locations. + :ivar location: The location of the resource group. It cannot be changed after the resource + group has been created. It must be one of the supported Azure locations. Required. :vartype location: str :ivar managed_by: The ID of the resource that manages this resource group. :vartype managed_by: str - :ivar tags: A set of tags. The tags attached to the resource group. + :ivar tags: The tags attached to the resource group. :vartype tags: dict[str, str] """ _validation = { - 'id': {'readonly': True}, - 'name': {'readonly': True}, - 'type': {'readonly': True}, - 'location': {'required': True}, + "id": {"readonly": True}, + "name": {"readonly": True}, + "type": {"readonly": True}, + "location": {"required": True}, } _attribute_map = { - 'id': {'key': 'id', 'type': 'str'}, - 'name': {'key': 'name', 'type': 'str'}, - 'type': {'key': 'type', 'type': 'str'}, - 'properties': {'key': 'properties', 'type': 'ResourceGroupProperties'}, - 'location': {'key': 'location', 'type': 'str'}, - 'managed_by': {'key': 'managedBy', 'type': 'str'}, - 'tags': {'key': 'tags', 'type': '{str}'}, + "id": {"key": "id", "type": "str"}, + "name": {"key": "name", "type": "str"}, + "type": {"key": "type", "type": "str"}, + "properties": {"key": "properties", "type": "ResourceGroupProperties"}, + "location": {"key": "location", "type": "str"}, + "managed_by": {"key": "managedBy", "type": "str"}, + "tags": {"key": "tags", "type": "{str}"}, } def __init__( self, *, location: str, - properties: Optional["ResourceGroupProperties"] = None, + properties: Optional["_models.ResourceGroupProperties"] = None, managed_by: Optional[str] = None, tags: Optional[Dict[str, str]] = None, **kwargs @@ -2033,15 +1949,15 @@ def __init__( :keyword properties: The resource group properties. :paramtype properties: ~azure.mgmt.resource.resources.v2019_10_01.models.ResourceGroupProperties - :keyword location: Required. The location of the resource group. It cannot be changed after the - resource group has been created. It must be one of the supported Azure locations. + :keyword location: The location of the resource group. It cannot be changed after the resource + group has been created. It must be one of the supported Azure locations. Required. :paramtype location: str :keyword managed_by: The ID of the resource that manages this resource group. :paramtype managed_by: str - :keyword tags: A set of tags. The tags attached to the resource group. + :keyword tags: The tags attached to the resource group. :paramtype tags: dict[str, str] """ - super(ResourceGroup, self).__init__(**kwargs) + super().__init__(**kwargs) self.id = None self.name = None self.type = None @@ -2051,39 +1967,33 @@ def __init__( self.tags = tags -class ResourceGroupExportResult(msrest.serialization.Model): +class ResourceGroupExportResult(_serialization.Model): """Resource group export result. :ivar template: The template content. - :vartype template: any + :vartype template: JSON :ivar error: The template export error. :vartype error: ~azure.mgmt.resource.resources.v2019_10_01.models.ErrorResponse """ _attribute_map = { - 'template': {'key': 'template', 'type': 'object'}, - 'error': {'key': 'error', 'type': 'ErrorResponse'}, + "template": {"key": "template", "type": "object"}, + "error": {"key": "error", "type": "ErrorResponse"}, } - def __init__( - self, - *, - template: Optional[Any] = None, - error: Optional["ErrorResponse"] = None, - **kwargs - ): + def __init__(self, *, template: Optional[JSON] = None, error: Optional["_models.ErrorResponse"] = None, **kwargs): """ :keyword template: The template content. - :paramtype template: any + :paramtype template: JSON :keyword error: The template export error. :paramtype error: ~azure.mgmt.resource.resources.v2019_10_01.models.ErrorResponse """ - super(ResourceGroupExportResult, self).__init__(**kwargs) + super().__init__(**kwargs) self.template = template self.error = error -class ResourceGroupFilter(msrest.serialization.Model): +class ResourceGroupFilter(_serialization.Model): """Resource group filter. :ivar tag_name: The tag name. @@ -2093,29 +2003,23 @@ class ResourceGroupFilter(msrest.serialization.Model): """ _attribute_map = { - 'tag_name': {'key': 'tagName', 'type': 'str'}, - 'tag_value': {'key': 'tagValue', 'type': 'str'}, + "tag_name": {"key": "tagName", "type": "str"}, + "tag_value": {"key": "tagValue", "type": "str"}, } - def __init__( - self, - *, - tag_name: Optional[str] = None, - tag_value: Optional[str] = None, - **kwargs - ): + def __init__(self, *, tag_name: Optional[str] = None, tag_value: Optional[str] = None, **kwargs): """ :keyword tag_name: The tag name. :paramtype tag_name: str :keyword tag_value: The tag value. :paramtype tag_value: str """ - super(ResourceGroupFilter, self).__init__(**kwargs) + super().__init__(**kwargs) self.tag_name = tag_name self.tag_value = tag_value -class ResourceGroupListResult(msrest.serialization.Model): +class ResourceGroupListResult(_serialization.Model): """List of resource groups. Variables are only populated by the server, and will be ignored when sending a request. @@ -2127,30 +2031,25 @@ class ResourceGroupListResult(msrest.serialization.Model): """ _validation = { - 'next_link': {'readonly': True}, + "next_link": {"readonly": True}, } _attribute_map = { - 'value': {'key': 'value', 'type': '[ResourceGroup]'}, - 'next_link': {'key': 'nextLink', 'type': 'str'}, + "value": {"key": "value", "type": "[ResourceGroup]"}, + "next_link": {"key": "nextLink", "type": "str"}, } - def __init__( - self, - *, - value: Optional[List["ResourceGroup"]] = None, - **kwargs - ): + def __init__(self, *, value: Optional[List["_models.ResourceGroup"]] = None, **kwargs): """ :keyword value: An array of resource groups. :paramtype value: list[~azure.mgmt.resource.resources.v2019_10_01.models.ResourceGroup] """ - super(ResourceGroupListResult, self).__init__(**kwargs) + super().__init__(**kwargs) self.value = value self.next_link = None -class ResourceGroupPatchable(msrest.serialization.Model): +class ResourceGroupPatchable(_serialization.Model): """Resource group information. :ivar name: The name of the resource group. @@ -2159,22 +2058,22 @@ class ResourceGroupPatchable(msrest.serialization.Model): :vartype properties: ~azure.mgmt.resource.resources.v2019_10_01.models.ResourceGroupProperties :ivar managed_by: The ID of the resource that manages this resource group. :vartype managed_by: str - :ivar tags: A set of tags. The tags attached to the resource group. + :ivar tags: The tags attached to the resource group. :vartype tags: dict[str, str] """ _attribute_map = { - 'name': {'key': 'name', 'type': 'str'}, - 'properties': {'key': 'properties', 'type': 'ResourceGroupProperties'}, - 'managed_by': {'key': 'managedBy', 'type': 'str'}, - 'tags': {'key': 'tags', 'type': '{str}'}, + "name": {"key": "name", "type": "str"}, + "properties": {"key": "properties", "type": "ResourceGroupProperties"}, + "managed_by": {"key": "managedBy", "type": "str"}, + "tags": {"key": "tags", "type": "{str}"}, } def __init__( self, *, name: Optional[str] = None, - properties: Optional["ResourceGroupProperties"] = None, + properties: Optional["_models.ResourceGroupProperties"] = None, managed_by: Optional[str] = None, tags: Optional[Dict[str, str]] = None, **kwargs @@ -2187,17 +2086,17 @@ def __init__( ~azure.mgmt.resource.resources.v2019_10_01.models.ResourceGroupProperties :keyword managed_by: The ID of the resource that manages this resource group. :paramtype managed_by: str - :keyword tags: A set of tags. The tags attached to the resource group. + :keyword tags: The tags attached to the resource group. :paramtype tags: dict[str, str] """ - super(ResourceGroupPatchable, self).__init__(**kwargs) + super().__init__(**kwargs) self.name = name self.properties = properties self.managed_by = managed_by self.tags = tags -class ResourceGroupProperties(msrest.serialization.Model): +class ResourceGroupProperties(_serialization.Model): """The resource group properties. Variables are only populated by the server, and will be ignored when sending a request. @@ -2207,24 +2106,20 @@ class ResourceGroupProperties(msrest.serialization.Model): """ _validation = { - 'provisioning_state': {'readonly': True}, + "provisioning_state": {"readonly": True}, } _attribute_map = { - 'provisioning_state': {'key': 'provisioningState', 'type': 'str'}, + "provisioning_state": {"key": "provisioningState", "type": "str"}, } - def __init__( - self, - **kwargs - ): - """ - """ - super(ResourceGroupProperties, self).__init__(**kwargs) + def __init__(self, **kwargs): + """ """ + super().__init__(**kwargs) self.provisioning_state = None -class ResourceListResult(msrest.serialization.Model): +class ResourceListResult(_serialization.Model): """List of resource groups. Variables are only populated by the server, and will be ignored when sending a request. @@ -2236,31 +2131,26 @@ class ResourceListResult(msrest.serialization.Model): """ _validation = { - 'next_link': {'readonly': True}, + "next_link": {"readonly": True}, } _attribute_map = { - 'value': {'key': 'value', 'type': '[GenericResourceExpanded]'}, - 'next_link': {'key': 'nextLink', 'type': 'str'}, + "value": {"key": "value", "type": "[GenericResourceExpanded]"}, + "next_link": {"key": "nextLink", "type": "str"}, } - def __init__( - self, - *, - value: Optional[List["GenericResourceExpanded"]] = None, - **kwargs - ): + def __init__(self, *, value: Optional[List["_models.GenericResourceExpanded"]] = None, **kwargs): """ :keyword value: An array of resources. :paramtype value: list[~azure.mgmt.resource.resources.v2019_10_01.models.GenericResourceExpanded] """ - super(ResourceListResult, self).__init__(**kwargs) + super().__init__(**kwargs) self.value = value self.next_link = None -class ResourceProviderOperationDisplayProperties(msrest.serialization.Model): +class ResourceProviderOperationDisplayProperties(_serialization.Model): """Resource provider operation's display properties. :ivar publisher: Operation description. @@ -2276,11 +2166,11 @@ class ResourceProviderOperationDisplayProperties(msrest.serialization.Model): """ _attribute_map = { - 'publisher': {'key': 'publisher', 'type': 'str'}, - 'provider': {'key': 'provider', 'type': 'str'}, - 'resource': {'key': 'resource', 'type': 'str'}, - 'operation': {'key': 'operation', 'type': 'str'}, - 'description': {'key': 'description', 'type': 'str'}, + "publisher": {"key": "publisher", "type": "str"}, + "provider": {"key": "provider", "type": "str"}, + "resource": {"key": "resource", "type": "str"}, + "operation": {"key": "operation", "type": "str"}, + "description": {"key": "description", "type": "str"}, } def __init__( @@ -2305,7 +2195,7 @@ def __init__( :keyword description: Operation description. :paramtype description: str """ - super(ResourceProviderOperationDisplayProperties, self).__init__(**kwargs) + super().__init__(**kwargs) self.publisher = publisher self.provider = provider self.resource = resource @@ -2313,7 +2203,7 @@ def __init__( self.description = description -class ResourceReference(msrest.serialization.Model): +class ResourceReference(_serialization.Model): """The resource Id model. Variables are only populated by the server, and will be ignored when sending a request. @@ -2323,24 +2213,20 @@ class ResourceReference(msrest.serialization.Model): """ _validation = { - 'id': {'readonly': True}, + "id": {"readonly": True}, } _attribute_map = { - 'id': {'key': 'id', 'type': 'str'}, + "id": {"key": "id", "type": "str"}, } - def __init__( - self, - **kwargs - ): - """ - """ - super(ResourceReference, self).__init__(**kwargs) + def __init__(self, **kwargs): + """ """ + super().__init__(**kwargs) self.id = None -class ResourcesMoveInfo(msrest.serialization.Model): +class ResourcesMoveInfo(_serialization.Model): """Parameters of move resources. :ivar resources: The IDs of the resources. @@ -2350,116 +2236,104 @@ class ResourcesMoveInfo(msrest.serialization.Model): """ _attribute_map = { - 'resources': {'key': 'resources', 'type': '[str]'}, - 'target_resource_group': {'key': 'targetResourceGroup', 'type': 'str'}, + "resources": {"key": "resources", "type": "[str]"}, + "target_resource_group": {"key": "targetResourceGroup", "type": "str"}, } - def __init__( - self, - *, - resources: Optional[List[str]] = None, - target_resource_group: Optional[str] = None, - **kwargs - ): + def __init__(self, *, resources: Optional[List[str]] = None, target_resource_group: Optional[str] = None, **kwargs): """ :keyword resources: The IDs of the resources. :paramtype resources: list[str] :keyword target_resource_group: The target resource group. :paramtype target_resource_group: str """ - super(ResourcesMoveInfo, self).__init__(**kwargs) + super().__init__(**kwargs) self.resources = resources self.target_resource_group = target_resource_group -class ScopedDeployment(msrest.serialization.Model): +class ScopedDeployment(_serialization.Model): """Deployment operation parameters. All required parameters must be populated in order to send to Azure. - :ivar location: Required. The location to store the deployment data. + :ivar location: The location to store the deployment data. Required. :vartype location: str - :ivar properties: Required. The deployment properties. + :ivar properties: The deployment properties. Required. :vartype properties: ~azure.mgmt.resource.resources.v2019_10_01.models.DeploymentProperties - :ivar tags: A set of tags. Deployment tags. + :ivar tags: Deployment tags. :vartype tags: dict[str, str] """ _validation = { - 'location': {'required': True}, - 'properties': {'required': True}, + "location": {"required": True}, + "properties": {"required": True}, } _attribute_map = { - 'location': {'key': 'location', 'type': 'str'}, - 'properties': {'key': 'properties', 'type': 'DeploymentProperties'}, - 'tags': {'key': 'tags', 'type': '{str}'}, + "location": {"key": "location", "type": "str"}, + "properties": {"key": "properties", "type": "DeploymentProperties"}, + "tags": {"key": "tags", "type": "{str}"}, } def __init__( self, *, location: str, - properties: "DeploymentProperties", + properties: "_models.DeploymentProperties", tags: Optional[Dict[str, str]] = None, **kwargs ): """ - :keyword location: Required. The location to store the deployment data. + :keyword location: The location to store the deployment data. Required. :paramtype location: str - :keyword properties: Required. The deployment properties. + :keyword properties: The deployment properties. Required. :paramtype properties: ~azure.mgmt.resource.resources.v2019_10_01.models.DeploymentProperties - :keyword tags: A set of tags. Deployment tags. + :keyword tags: Deployment tags. :paramtype tags: dict[str, str] """ - super(ScopedDeployment, self).__init__(**kwargs) + super().__init__(**kwargs) self.location = location self.properties = properties self.tags = tags -class ScopedDeploymentWhatIf(msrest.serialization.Model): +class ScopedDeploymentWhatIf(_serialization.Model): """Deployment What-if operation parameters. All required parameters must be populated in order to send to Azure. - :ivar location: Required. The location to store the deployment data. + :ivar location: The location to store the deployment data. Required. :vartype location: str - :ivar properties: Required. The deployment properties. + :ivar properties: The deployment properties. Required. :vartype properties: ~azure.mgmt.resource.resources.v2019_10_01.models.DeploymentWhatIfProperties """ _validation = { - 'location': {'required': True}, - 'properties': {'required': True}, + "location": {"required": True}, + "properties": {"required": True}, } _attribute_map = { - 'location': {'key': 'location', 'type': 'str'}, - 'properties': {'key': 'properties', 'type': 'DeploymentWhatIfProperties'}, + "location": {"key": "location", "type": "str"}, + "properties": {"key": "properties", "type": "DeploymentWhatIfProperties"}, } - def __init__( - self, - *, - location: str, - properties: "DeploymentWhatIfProperties", - **kwargs - ): + def __init__(self, *, location: str, properties: "_models.DeploymentWhatIfProperties", **kwargs): """ - :keyword location: Required. The location to store the deployment data. + :keyword location: The location to store the deployment data. Required. :paramtype location: str - :keyword properties: Required. The deployment properties. + :keyword properties: The deployment properties. Required. :paramtype properties: ~azure.mgmt.resource.resources.v2019_10_01.models.DeploymentWhatIfProperties """ - super(ScopedDeploymentWhatIf, self).__init__(**kwargs) + super().__init__(**kwargs) self.location = location self.properties = properties -class Sku(msrest.serialization.Model): +class Sku(_serialization.Model): """SKU for the resource. :ivar name: The SKU name. @@ -2477,12 +2351,12 @@ class Sku(msrest.serialization.Model): """ _attribute_map = { - 'name': {'key': 'name', 'type': 'str'}, - 'tier': {'key': 'tier', 'type': 'str'}, - 'size': {'key': 'size', 'type': 'str'}, - 'family': {'key': 'family', 'type': 'str'}, - 'model': {'key': 'model', 'type': 'str'}, - 'capacity': {'key': 'capacity', 'type': 'int'}, + "name": {"key": "name", "type": "str"}, + "tier": {"key": "tier", "type": "str"}, + "size": {"key": "size", "type": "str"}, + "family": {"key": "family", "type": "str"}, + "model": {"key": "model", "type": "str"}, + "capacity": {"key": "capacity", "type": "int"}, } def __init__( @@ -2510,7 +2384,7 @@ def __init__( :keyword capacity: The SKU capacity. :paramtype capacity: int """ - super(Sku, self).__init__(**kwargs) + super().__init__(**kwargs) self.name = name self.tier = tier self.size = size @@ -2519,7 +2393,7 @@ def __init__( self.capacity = capacity -class SubResource(msrest.serialization.Model): +class SubResource(_serialization.Model): """Sub-resource. :ivar id: Resource ID. @@ -2527,24 +2401,19 @@ class SubResource(msrest.serialization.Model): """ _attribute_map = { - 'id': {'key': 'id', 'type': 'str'}, + "id": {"key": "id", "type": "str"}, } - def __init__( - self, - *, - id: Optional[str] = None, - **kwargs - ): + def __init__(self, *, id: Optional[str] = None, **kwargs): # pylint: disable=redefined-builtin """ :keyword id: Resource ID. :paramtype id: str """ - super(SubResource, self).__init__(**kwargs) + super().__init__(**kwargs) self.id = id -class TagCount(msrest.serialization.Model): +class TagCount(_serialization.Model): """Tag count. :ivar type: Type of count. @@ -2554,29 +2423,23 @@ class TagCount(msrest.serialization.Model): """ _attribute_map = { - 'type': {'key': 'type', 'type': 'str'}, - 'value': {'key': 'value', 'type': 'int'}, + "type": {"key": "type", "type": "str"}, + "value": {"key": "value", "type": "int"}, } - def __init__( - self, - *, - type: Optional[str] = None, - value: Optional[int] = None, - **kwargs - ): + def __init__(self, *, type: Optional[str] = None, value: Optional[int] = None, **kwargs): """ :keyword type: Type of count. :paramtype type: str :keyword value: Value of count. :paramtype value: int """ - super(TagCount, self).__init__(**kwargs) + super().__init__(**kwargs) self.type = type self.value = value -class TagDetails(msrest.serialization.Model): +class TagDetails(_serialization.Model): """Tag details. Variables are only populated by the server, and will be ignored when sending a request. @@ -2593,22 +2456,22 @@ class TagDetails(msrest.serialization.Model): """ _validation = { - 'id': {'readonly': True}, + "id": {"readonly": True}, } _attribute_map = { - 'id': {'key': 'id', 'type': 'str'}, - 'tag_name': {'key': 'tagName', 'type': 'str'}, - 'count': {'key': 'count', 'type': 'TagCount'}, - 'values': {'key': 'values', 'type': '[TagValue]'}, + "id": {"key": "id", "type": "str"}, + "tag_name": {"key": "tagName", "type": "str"}, + "count": {"key": "count", "type": "TagCount"}, + "values": {"key": "values", "type": "[TagValue]"}, } def __init__( self, *, tag_name: Optional[str] = None, - count: Optional["TagCount"] = None, - values: Optional[List["TagValue"]] = None, + count: Optional["_models.TagCount"] = None, + values: Optional[List["_models.TagValue"]] = None, **kwargs ): """ @@ -2620,39 +2483,34 @@ def __init__( :keyword values: The list of tag values. :paramtype values: list[~azure.mgmt.resource.resources.v2019_10_01.models.TagValue] """ - super(TagDetails, self).__init__(**kwargs) + super().__init__(**kwargs) self.id = None self.tag_name = tag_name self.count = count self.values = values -class Tags(msrest.serialization.Model): +class Tags(_serialization.Model): """A dictionary of name and value pairs. - :ivar tags: A set of tags. Dictionary of :code:``. + :ivar tags: Dictionary of :code:``. :vartype tags: dict[str, str] """ _attribute_map = { - 'tags': {'key': 'tags', 'type': '{str}'}, + "tags": {"key": "tags", "type": "{str}"}, } - def __init__( - self, - *, - tags: Optional[Dict[str, str]] = None, - **kwargs - ): + def __init__(self, *, tags: Optional[Dict[str, str]] = None, **kwargs): """ - :keyword tags: A set of tags. Dictionary of :code:``. + :keyword tags: Dictionary of :code:``. :paramtype tags: dict[str, str] """ - super(Tags, self).__init__(**kwargs) + super().__init__(**kwargs) self.tags = tags -class TagsListResult(msrest.serialization.Model): +class TagsListResult(_serialization.Model): """List of subscription tags. Variables are only populated by the server, and will be ignored when sending a request. @@ -2664,65 +2522,60 @@ class TagsListResult(msrest.serialization.Model): """ _validation = { - 'next_link': {'readonly': True}, + "next_link": {"readonly": True}, } _attribute_map = { - 'value': {'key': 'value', 'type': '[TagDetails]'}, - 'next_link': {'key': 'nextLink', 'type': 'str'}, + "value": {"key": "value", "type": "[TagDetails]"}, + "next_link": {"key": "nextLink", "type": "str"}, } - def __init__( - self, - *, - value: Optional[List["TagDetails"]] = None, - **kwargs - ): + def __init__(self, *, value: Optional[List["_models.TagDetails"]] = None, **kwargs): """ :keyword value: An array of tags. :paramtype value: list[~azure.mgmt.resource.resources.v2019_10_01.models.TagDetails] """ - super(TagsListResult, self).__init__(**kwargs) + super().__init__(**kwargs) self.value = value self.next_link = None -class TagsPatchResource(msrest.serialization.Model): +class TagsPatchResource(_serialization.Model): """Wrapper resource for tags patch API request only. - :ivar operation: The operation type for the patch API. Possible values include: "Replace", - "Merge", "Delete". + :ivar operation: The operation type for the patch API. Known values are: "Replace", "Merge", + and "Delete". :vartype operation: str or ~azure.mgmt.resource.resources.v2019_10_01.models.TagsPatchOperation :ivar properties: The set of tags. :vartype properties: ~azure.mgmt.resource.resources.v2019_10_01.models.Tags """ _attribute_map = { - 'operation': {'key': 'operation', 'type': 'str'}, - 'properties': {'key': 'properties', 'type': 'Tags'}, + "operation": {"key": "operation", "type": "str"}, + "properties": {"key": "properties", "type": "Tags"}, } def __init__( self, *, - operation: Optional[Union[str, "TagsPatchOperation"]] = None, - properties: Optional["Tags"] = None, + operation: Optional[Union[str, "_models.TagsPatchOperation"]] = None, + properties: Optional["_models.Tags"] = None, **kwargs ): """ - :keyword operation: The operation type for the patch API. Possible values include: "Replace", - "Merge", "Delete". + :keyword operation: The operation type for the patch API. Known values are: "Replace", "Merge", + and "Delete". :paramtype operation: str or ~azure.mgmt.resource.resources.v2019_10_01.models.TagsPatchOperation :keyword properties: The set of tags. :paramtype properties: ~azure.mgmt.resource.resources.v2019_10_01.models.Tags """ - super(TagsPatchResource, self).__init__(**kwargs) + super().__init__(**kwargs) self.operation = operation self.properties = properties -class TagsResource(msrest.serialization.Model): +class TagsResource(_serialization.Model): """Wrapper resource for tags API requests and responses. Variables are only populated by the server, and will be ignored when sending a request. @@ -2735,42 +2588,37 @@ class TagsResource(msrest.serialization.Model): :vartype name: str :ivar type: The type of the tags wrapper resource. :vartype type: str - :ivar properties: Required. The set of tags. + :ivar properties: The set of tags. Required. :vartype properties: ~azure.mgmt.resource.resources.v2019_10_01.models.Tags """ _validation = { - 'id': {'readonly': True}, - 'name': {'readonly': True}, - 'type': {'readonly': True}, - 'properties': {'required': True}, + "id": {"readonly": True}, + "name": {"readonly": True}, + "type": {"readonly": True}, + "properties": {"required": True}, } _attribute_map = { - 'id': {'key': 'id', 'type': 'str'}, - 'name': {'key': 'name', 'type': 'str'}, - 'type': {'key': 'type', 'type': 'str'}, - 'properties': {'key': 'properties', 'type': 'Tags'}, + "id": {"key": "id", "type": "str"}, + "name": {"key": "name", "type": "str"}, + "type": {"key": "type", "type": "str"}, + "properties": {"key": "properties", "type": "Tags"}, } - def __init__( - self, - *, - properties: "Tags", - **kwargs - ): + def __init__(self, *, properties: "_models.Tags", **kwargs): """ - :keyword properties: Required. The set of tags. + :keyword properties: The set of tags. Required. :paramtype properties: ~azure.mgmt.resource.resources.v2019_10_01.models.Tags """ - super(TagsResource, self).__init__(**kwargs) + super().__init__(**kwargs) self.id = None self.name = None self.type = None self.properties = properties -class TagValue(msrest.serialization.Model): +class TagValue(_serialization.Model): """Tag information. Variables are only populated by the server, and will be ignored when sending a request. @@ -2784,35 +2632,29 @@ class TagValue(msrest.serialization.Model): """ _validation = { - 'id': {'readonly': True}, + "id": {"readonly": True}, } _attribute_map = { - 'id': {'key': 'id', 'type': 'str'}, - 'tag_value': {'key': 'tagValue', 'type': 'str'}, - 'count': {'key': 'count', 'type': 'TagCount'}, + "id": {"key": "id", "type": "str"}, + "tag_value": {"key": "tagValue", "type": "str"}, + "count": {"key": "count", "type": "TagCount"}, } - def __init__( - self, - *, - tag_value: Optional[str] = None, - count: Optional["TagCount"] = None, - **kwargs - ): + def __init__(self, *, tag_value: Optional[str] = None, count: Optional["_models.TagCount"] = None, **kwargs): """ :keyword tag_value: The tag value. :paramtype tag_value: str :keyword count: The tag value count. :paramtype count: ~azure.mgmt.resource.resources.v2019_10_01.models.TagCount """ - super(TagValue, self).__init__(**kwargs) + super().__init__(**kwargs) self.id = None self.tag_value = tag_value self.count = count -class TargetResource(msrest.serialization.Model): +class TargetResource(_serialization.Model): """Target resource. :ivar id: The ID of the resource. @@ -2824,15 +2666,15 @@ class TargetResource(msrest.serialization.Model): """ _attribute_map = { - 'id': {'key': 'id', 'type': 'str'}, - 'resource_name': {'key': 'resourceName', 'type': 'str'}, - 'resource_type': {'key': 'resourceType', 'type': 'str'}, + "id": {"key": "id", "type": "str"}, + "resource_name": {"key": "resourceName", "type": "str"}, + "resource_type": {"key": "resourceType", "type": "str"}, } def __init__( self, *, - id: Optional[str] = None, + id: Optional[str] = None, # pylint: disable=redefined-builtin resource_name: Optional[str] = None, resource_type: Optional[str] = None, **kwargs @@ -2845,13 +2687,13 @@ def __init__( :keyword resource_type: The type of the resource. :paramtype resource_type: str """ - super(TargetResource, self).__init__(**kwargs) + super().__init__(**kwargs) self.id = id self.resource_name = resource_name self.resource_type = resource_type -class TemplateHashResult(msrest.serialization.Model): +class TemplateHashResult(_serialization.Model): """Result of the request to calculate template hash. It contains a string of minified template and its hash. :ivar minified_template: The minified template string. @@ -2861,123 +2703,111 @@ class TemplateHashResult(msrest.serialization.Model): """ _attribute_map = { - 'minified_template': {'key': 'minifiedTemplate', 'type': 'str'}, - 'template_hash': {'key': 'templateHash', 'type': 'str'}, + "minified_template": {"key": "minifiedTemplate", "type": "str"}, + "template_hash": {"key": "templateHash", "type": "str"}, } - def __init__( - self, - *, - minified_template: Optional[str] = None, - template_hash: Optional[str] = None, - **kwargs - ): + def __init__(self, *, minified_template: Optional[str] = None, template_hash: Optional[str] = None, **kwargs): """ :keyword minified_template: The minified template string. :paramtype minified_template: str :keyword template_hash: The template hash. :paramtype template_hash: str """ - super(TemplateHashResult, self).__init__(**kwargs) + super().__init__(**kwargs) self.minified_template = minified_template self.template_hash = template_hash -class TemplateLink(msrest.serialization.Model): +class TemplateLink(_serialization.Model): """Entity representing the reference to the template. All required parameters must be populated in order to send to Azure. - :ivar uri: Required. The URI of the template to deploy. + :ivar uri: The URI of the template to deploy. Required. :vartype uri: str :ivar content_version: If included, must match the ContentVersion in the template. :vartype content_version: str """ _validation = { - 'uri': {'required': True}, + "uri": {"required": True}, } _attribute_map = { - 'uri': {'key': 'uri', 'type': 'str'}, - 'content_version': {'key': 'contentVersion', 'type': 'str'}, + "uri": {"key": "uri", "type": "str"}, + "content_version": {"key": "contentVersion", "type": "str"}, } - def __init__( - self, - *, - uri: str, - content_version: Optional[str] = None, - **kwargs - ): + def __init__(self, *, uri: str, content_version: Optional[str] = None, **kwargs): """ - :keyword uri: Required. The URI of the template to deploy. + :keyword uri: The URI of the template to deploy. Required. :paramtype uri: str :keyword content_version: If included, must match the ContentVersion in the template. :paramtype content_version: str """ - super(TemplateLink, self).__init__(**kwargs) + super().__init__(**kwargs) self.uri = uri self.content_version = content_version -class WhatIfChange(msrest.serialization.Model): +class WhatIfChange(_serialization.Model): """Information about a single resource change predicted by What-If operation. All required parameters must be populated in order to send to Azure. - :ivar resource_id: Required. Resource ID. + :ivar resource_id: Resource ID. Required. :vartype resource_id: str - :ivar change_type: Required. Type of change that will be made to the resource when the - deployment is executed. Possible values include: "Create", "Delete", "Ignore", "Deploy", - "NoChange", "Modify". + :ivar change_type: Type of change that will be made to the resource when the deployment is + executed. Required. Known values are: "Create", "Delete", "Ignore", "Deploy", "NoChange", and + "Modify". :vartype change_type: str or ~azure.mgmt.resource.resources.v2019_10_01.models.ChangeType :ivar before: The snapshot of the resource before the deployment is executed. - :vartype before: any + :vartype before: JSON :ivar after: The predicted snapshot of the resource after the deployment is executed. - :vartype after: any + :vartype after: JSON :ivar delta: The predicted changes to resource properties. :vartype delta: list[~azure.mgmt.resource.resources.v2019_10_01.models.WhatIfPropertyChange] """ _validation = { - 'resource_id': {'required': True}, - 'change_type': {'required': True}, + "resource_id": {"required": True}, + "change_type": {"required": True}, } _attribute_map = { - 'resource_id': {'key': 'resourceId', 'type': 'str'}, - 'change_type': {'key': 'changeType', 'type': 'str'}, - 'before': {'key': 'before', 'type': 'object'}, - 'after': {'key': 'after', 'type': 'object'}, - 'delta': {'key': 'delta', 'type': '[WhatIfPropertyChange]'}, + "resource_id": {"key": "resourceId", "type": "str"}, + "change_type": {"key": "changeType", "type": "str"}, + "before": {"key": "before", "type": "object"}, + "after": {"key": "after", "type": "object"}, + "delta": {"key": "delta", "type": "[WhatIfPropertyChange]"}, } def __init__( self, *, resource_id: str, - change_type: Union[str, "ChangeType"], - before: Optional[Any] = None, - after: Optional[Any] = None, - delta: Optional[List["WhatIfPropertyChange"]] = None, + change_type: Union[str, "_models.ChangeType"], + before: Optional[JSON] = None, + after: Optional[JSON] = None, + delta: Optional[List["_models.WhatIfPropertyChange"]] = None, **kwargs ): """ - :keyword resource_id: Required. Resource ID. + :keyword resource_id: Resource ID. Required. :paramtype resource_id: str - :keyword change_type: Required. Type of change that will be made to the resource when the - deployment is executed. Possible values include: "Create", "Delete", "Ignore", "Deploy", - "NoChange", "Modify". + :keyword change_type: Type of change that will be made to the resource when the deployment is + executed. Required. Known values are: "Create", "Delete", "Ignore", "Deploy", "NoChange", and + "Modify". :paramtype change_type: str or ~azure.mgmt.resource.resources.v2019_10_01.models.ChangeType :keyword before: The snapshot of the resource before the deployment is executed. - :paramtype before: any + :paramtype before: JSON :keyword after: The predicted snapshot of the resource after the deployment is executed. - :paramtype after: any + :paramtype after: JSON :keyword delta: The predicted changes to resource properties. :paramtype delta: list[~azure.mgmt.resource.resources.v2019_10_01.models.WhatIfPropertyChange] """ - super(WhatIfChange, self).__init__(**kwargs) + super().__init__(**kwargs) self.resource_id = resource_id self.change_type = change_type self.before = before @@ -2985,7 +2815,7 @@ def __init__( self.delta = delta -class WhatIfOperationResult(msrest.serialization.Model): +class WhatIfOperationResult(_serialization.Model): """Result of the What-If operation. Contains a list of predicted changes and a URL link to get to the next set of results. :ivar status: Status of the What-If operation. @@ -2997,17 +2827,17 @@ class WhatIfOperationResult(msrest.serialization.Model): """ _attribute_map = { - 'status': {'key': 'status', 'type': 'str'}, - 'error': {'key': 'error', 'type': 'ErrorResponse'}, - 'changes': {'key': 'properties.changes', 'type': '[WhatIfChange]'}, + "status": {"key": "status", "type": "str"}, + "error": {"key": "error", "type": "ErrorResponse"}, + "changes": {"key": "properties.changes", "type": "[WhatIfChange]"}, } def __init__( self, *, status: Optional[str] = None, - error: Optional["ErrorResponse"] = None, - changes: Optional[List["WhatIfChange"]] = None, + error: Optional["_models.ErrorResponse"] = None, + changes: Optional[List["_models.WhatIfChange"]] = None, **kwargs ): """ @@ -3018,70 +2848,70 @@ def __init__( :keyword changes: List of resource changes predicted by What-If operation. :paramtype changes: list[~azure.mgmt.resource.resources.v2019_10_01.models.WhatIfChange] """ - super(WhatIfOperationResult, self).__init__(**kwargs) + super().__init__(**kwargs) self.status = status self.error = error self.changes = changes -class WhatIfPropertyChange(msrest.serialization.Model): +class WhatIfPropertyChange(_serialization.Model): """The predicted change to the resource property. All required parameters must be populated in order to send to Azure. - :ivar path: Required. The path of the property. + :ivar path: The path of the property. Required. :vartype path: str - :ivar property_change_type: Required. The type of property change. Possible values include: - "Create", "Delete", "Modify", "Array". + :ivar property_change_type: The type of property change. Required. Known values are: "Create", + "Delete", "Modify", and "Array". :vartype property_change_type: str or ~azure.mgmt.resource.resources.v2019_10_01.models.PropertyChangeType :ivar before: The value of the property before the deployment is executed. - :vartype before: any + :vartype before: JSON :ivar after: The value of the property after the deployment is executed. - :vartype after: any + :vartype after: JSON :ivar children: Nested property changes. :vartype children: list[~azure.mgmt.resource.resources.v2019_10_01.models.WhatIfPropertyChange] """ _validation = { - 'path': {'required': True}, - 'property_change_type': {'required': True}, + "path": {"required": True}, + "property_change_type": {"required": True}, } _attribute_map = { - 'path': {'key': 'path', 'type': 'str'}, - 'property_change_type': {'key': 'propertyChangeType', 'type': 'str'}, - 'before': {'key': 'before', 'type': 'object'}, - 'after': {'key': 'after', 'type': 'object'}, - 'children': {'key': 'children', 'type': '[WhatIfPropertyChange]'}, + "path": {"key": "path", "type": "str"}, + "property_change_type": {"key": "propertyChangeType", "type": "str"}, + "before": {"key": "before", "type": "object"}, + "after": {"key": "after", "type": "object"}, + "children": {"key": "children", "type": "[WhatIfPropertyChange]"}, } def __init__( self, *, path: str, - property_change_type: Union[str, "PropertyChangeType"], - before: Optional[Any] = None, - after: Optional[Any] = None, - children: Optional[List["WhatIfPropertyChange"]] = None, + property_change_type: Union[str, "_models.PropertyChangeType"], + before: Optional[JSON] = None, + after: Optional[JSON] = None, + children: Optional[List["_models.WhatIfPropertyChange"]] = None, **kwargs ): """ - :keyword path: Required. The path of the property. + :keyword path: The path of the property. Required. :paramtype path: str - :keyword property_change_type: Required. The type of property change. Possible values include: - "Create", "Delete", "Modify", "Array". + :keyword property_change_type: The type of property change. Required. Known values are: + "Create", "Delete", "Modify", and "Array". :paramtype property_change_type: str or ~azure.mgmt.resource.resources.v2019_10_01.models.PropertyChangeType :keyword before: The value of the property before the deployment is executed. - :paramtype before: any + :paramtype before: JSON :keyword after: The value of the property after the deployment is executed. - :paramtype after: any + :paramtype after: JSON :keyword children: Nested property changes. :paramtype children: list[~azure.mgmt.resource.resources.v2019_10_01.models.WhatIfPropertyChange] """ - super(WhatIfPropertyChange, self).__init__(**kwargs) + super().__init__(**kwargs) self.path = path self.property_change_type = property_change_type self.before = before @@ -3089,7 +2919,7 @@ def __init__( self.children = children -class ZoneMapping(msrest.serialization.Model): +class ZoneMapping(_serialization.Model): """ZoneMapping. :ivar location: The location of the zone mapping. @@ -3099,23 +2929,17 @@ class ZoneMapping(msrest.serialization.Model): """ _attribute_map = { - 'location': {'key': 'location', 'type': 'str'}, - 'zones': {'key': 'zones', 'type': '[str]'}, + "location": {"key": "location", "type": "str"}, + "zones": {"key": "zones", "type": "[str]"}, } - def __init__( - self, - *, - location: Optional[str] = None, - zones: Optional[List[str]] = None, - **kwargs - ): + def __init__(self, *, location: Optional[str] = None, zones: Optional[List[str]] = None, **kwargs): """ :keyword location: The location of the zone mapping. :paramtype location: str :keyword zones: :paramtype zones: list[str] """ - super(ZoneMapping, self).__init__(**kwargs) + super().__init__(**kwargs) self.location = location self.zones = zones diff --git a/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/resources/v2019_10_01/models/_patch.py b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/resources/v2019_10_01/models/_patch.py new file mode 100644 index 0000000000000..f7dd32510333d --- /dev/null +++ b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/resources/v2019_10_01/models/_patch.py @@ -0,0 +1,20 @@ +# ------------------------------------ +# Copyright (c) Microsoft Corporation. +# Licensed under the MIT License. +# ------------------------------------ +"""Customize generated code here. + +Follow our quickstart for examples: https://aka.ms/azsdk/python/dpcodegen/python/customize +""" +from typing import List + +__all__: List[str] = [] # Add all objects you want publicly available to users at this package level + + +def patch_sdk(): + """Do not remove from this file. + + `patch_sdk` is a last resort escape hatch that allows you to do customizations + you can't accomplish using the techniques described in + https://aka.ms/azsdk/python/dpcodegen/python/customize + """ diff --git a/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/resources/v2019_10_01/models/_resource_management_client_enums.py b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/resources/v2019_10_01/models/_resource_management_client_enums.py index ee5ba746c5827..6e88be60b0cfd 100644 --- a/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/resources/v2019_10_01/models/_resource_management_client_enums.py +++ b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/resources/v2019_10_01/models/_resource_management_client_enums.py @@ -7,22 +7,20 @@ # -------------------------------------------------------------------------- from enum import Enum -from six import with_metaclass from azure.core import CaseInsensitiveEnumMeta -class AliasPatternType(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): - """The type of alias pattern - """ +class AliasPatternType(str, Enum, metaclass=CaseInsensitiveEnumMeta): + """The type of alias pattern.""" #: NotSpecified is not allowed. NOT_SPECIFIED = "NotSpecified" #: Extract is the only allowed value. EXTRACT = "Extract" -class AliasType(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): - """The type of the alias. - """ + +class AliasType(str, Enum, metaclass=CaseInsensitiveEnumMeta): + """The type of the alias.""" #: Alias type is unknown (same as not providing alias type). NOT_SPECIFIED = "NotSpecified" @@ -31,9 +29,9 @@ class AliasType(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): #: Alias value is secret. MASK = "Mask" -class ChangeType(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): - """Type of change that will be made to the resource when the deployment is executed. - """ + +class ChangeType(str, Enum, metaclass=CaseInsensitiveEnumMeta): + """Type of change that will be made to the resource when the deployment is executed.""" #: The resource does not exist in the current state but is present in the desired state. The #: resource will be created when the deployment is executed. @@ -54,7 +52,8 @@ class ChangeType(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): #: deployment is executed. The properties of the resource will change. MODIFY = "Modify" -class DeploymentMode(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): + +class DeploymentMode(str, Enum, metaclass=CaseInsensitiveEnumMeta): """The mode that is used to deploy resources. This value can be either Incremental or Complete. In Incremental mode, resources are deployed without deleting existing resources that are not included in the template. In Complete mode, resources are deployed and existing resources in @@ -65,7 +64,8 @@ class DeploymentMode(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): INCREMENTAL = "Incremental" COMPLETE = "Complete" -class OnErrorDeploymentType(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): + +class OnErrorDeploymentType(str, Enum, metaclass=CaseInsensitiveEnumMeta): """The deployment on error behavior type. Possible values are LastSuccessful and SpecificDeployment. """ @@ -73,9 +73,9 @@ class OnErrorDeploymentType(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): LAST_SUCCESSFUL = "LastSuccessful" SPECIFIC_DEPLOYMENT = "SpecificDeployment" -class PropertyChangeType(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): - """The type of property change. - """ + +class PropertyChangeType(str, Enum, metaclass=CaseInsensitiveEnumMeta): + """The type of property change.""" #: The property does not exist in the current state but is present in the desired state. The #: property will be created when the deployment is executed. @@ -89,9 +89,9 @@ class PropertyChangeType(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): #: The property is an array and contains nested changes. ARRAY = "Array" -class ProvisioningOperation(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): - """The name of the current provisioning operation. - """ + +class ProvisioningOperation(str, Enum, metaclass=CaseInsensitiveEnumMeta): + """The name of the current provisioning operation.""" #: The provisioning operation is not specified. NOT_SPECIFIED = "NotSpecified" @@ -115,18 +115,18 @@ class ProvisioningOperation(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): #: deployment. DEPLOYMENT_CLEANUP = "DeploymentCleanup" -class ResourceIdentityType(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): - """The identity type. - """ + +class ResourceIdentityType(str, Enum, metaclass=CaseInsensitiveEnumMeta): + """The identity type.""" SYSTEM_ASSIGNED = "SystemAssigned" USER_ASSIGNED = "UserAssigned" SYSTEM_ASSIGNED_USER_ASSIGNED = "SystemAssigned, UserAssigned" NONE = "None" -class TagsPatchOperation(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): - """The operation type for the patch API. - """ + +class TagsPatchOperation(str, Enum, metaclass=CaseInsensitiveEnumMeta): + """The operation type for the patch API.""" #: The 'replace' option replaces the entire set of existing tags with a new set. REPLACE = "Replace" @@ -136,9 +136,9 @@ class TagsPatchOperation(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): #: The 'delete' option allows selectively deleting tags based on given names or name/value pairs. DELETE = "Delete" -class WhatIfResultFormat(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): - """The format of the What-If results - """ + +class WhatIfResultFormat(str, Enum, metaclass=CaseInsensitiveEnumMeta): + """The format of the What-If results.""" RESOURCE_ID_ONLY = "ResourceIdOnly" FULL_RESOURCE_PAYLOADS = "FullResourcePayloads" diff --git a/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/resources/v2019_10_01/operations/__init__.py b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/resources/v2019_10_01/operations/__init__.py index 53876d82bf5d7..804fee65e3137 100644 --- a/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/resources/v2019_10_01/operations/__init__.py +++ b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/resources/v2019_10_01/operations/__init__.py @@ -14,12 +14,18 @@ from ._operations import TagsOperations from ._operations import DeploymentOperationsOperations +from ._patch import __all__ as _patch_all +from ._patch import * # type: ignore # pylint: disable=unused-wildcard-import +from ._patch import patch_sdk as _patch_sdk + __all__ = [ - 'Operations', - 'DeploymentsOperations', - 'ProvidersOperations', - 'ResourcesOperations', - 'ResourceGroupsOperations', - 'TagsOperations', - 'DeploymentOperationsOperations', + "Operations", + "DeploymentsOperations", + "ProvidersOperations", + "ResourcesOperations", + "ResourceGroupsOperations", + "TagsOperations", + "DeploymentOperationsOperations", ] +__all__.extend([p for p in _patch_all if p not in __all__]) +_patch_sdk() diff --git a/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/resources/v2019_10_01/operations/_operations.py b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/resources/v2019_10_01/operations/_operations.py index f5822c6c9e319..83518b0ccfb74 100644 --- a/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/resources/v2019_10_01/operations/_operations.py +++ b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/resources/v2019_10_01/operations/_operations.py @@ -6,1641 +6,1408 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -from typing import Any, Callable, Dict, Iterable, Optional, TypeVar, Union - -from msrest import Serializer - -from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error +import sys +from typing import Any, Callable, Dict, IO, Iterable, Optional, TypeVar, Union, cast, overload +from urllib.parse import parse_qs, urljoin, urlparse + +from azure.core.exceptions import ( + ClientAuthenticationError, + HttpResponseError, + ResourceExistsError, + ResourceNotFoundError, + ResourceNotModifiedError, + map_error, +) from azure.core.paging import ItemPaged from azure.core.pipeline import PipelineResponse from azure.core.pipeline.transport import HttpResponse from azure.core.polling import LROPoller, NoPolling, PollingMethod from azure.core.rest import HttpRequest from azure.core.tracing.decorator import distributed_trace +from azure.core.utils import case_insensitive_dict from azure.mgmt.core.exceptions import ARMErrorFormat from azure.mgmt.core.polling.arm_polling import ARMPolling from .. import models as _models +from ..._serialization import Serializer from .._vendor import _convert_request, _format_url_section -T = TypeVar('T') + +T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] -JSONType = Any +if sys.version_info >= (3, 9): + from collections.abc import MutableMapping +else: + from typing import MutableMapping # type: ignore # pylint: disable=ungrouped-imports +JSON = MutableMapping[str, Any] # pylint: disable=unsubscriptable-object _SERIALIZER = Serializer() _SERIALIZER.client_side_validation = False -def build_operations_list_request( - **kwargs: Any -) -> HttpRequest: - api_version = kwargs.pop('api_version', "2019-10-01") # type: str - accept = "application/json" +def build_operations_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", "2019-10-01")) # type: str + accept = _headers.pop("Accept", "application/json") + # Construct URL _url = kwargs.pop("template_url", "/providers/Microsoft.Resources/operations") # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') - - return HttpRequest( - method="GET", - url=_url, - params=_query_parameters, - headers=_header_parameters, - **kwargs - ) + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) -def build_deployments_delete_at_scope_request_initial( - scope: str, - deployment_name: str, - **kwargs: Any -) -> HttpRequest: - api_version = kwargs.pop('api_version', "2019-10-01") # type: str - accept = "application/json" +def build_deployments_delete_at_scope_request(scope: str, deployment_name: 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", "2019-10-01")) # type: str + accept = _headers.pop("Accept", "application/json") + # Construct URL _url = kwargs.pop("template_url", "/{scope}/providers/Microsoft.Resources/deployments/{deploymentName}") path_format_arguments = { - "scope": _SERIALIZER.url("scope", scope, 'str', skip_quote=True), - "deploymentName": _SERIALIZER.url("deployment_name", deployment_name, 'str', max_length=64, min_length=1, pattern=r'^[-\w\._\(\)]+$'), + "scope": _SERIALIZER.url("scope", scope, "str", skip_quote=True), + "deploymentName": _SERIALIZER.url( + "deployment_name", deployment_name, "str", max_length=64, min_length=1, pattern=r"^[-\w\._\(\)]+$" + ), } _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') - - return HttpRequest( - method="DELETE", - url=_url, - params=_query_parameters, - headers=_header_parameters, - **kwargs - ) + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + return HttpRequest(method="DELETE", url=_url, params=_params, headers=_headers, **kwargs) -def build_deployments_check_existence_at_scope_request( - scope: str, - deployment_name: str, - **kwargs: Any -) -> HttpRequest: - api_version = kwargs.pop('api_version', "2019-10-01") # type: str - accept = "application/json" +def build_deployments_check_existence_at_scope_request(scope: str, deployment_name: 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", "2019-10-01")) # type: str + accept = _headers.pop("Accept", "application/json") + # Construct URL _url = kwargs.pop("template_url", "/{scope}/providers/Microsoft.Resources/deployments/{deploymentName}") path_format_arguments = { - "scope": _SERIALIZER.url("scope", scope, 'str', skip_quote=True), - "deploymentName": _SERIALIZER.url("deployment_name", deployment_name, 'str', max_length=64, min_length=1, pattern=r'^[-\w\._\(\)]+$'), + "scope": _SERIALIZER.url("scope", scope, "str", skip_quote=True), + "deploymentName": _SERIALIZER.url( + "deployment_name", deployment_name, "str", max_length=64, min_length=1, pattern=r"^[-\w\._\(\)]+$" + ), } _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') - - return HttpRequest( - method="HEAD", - url=_url, - params=_query_parameters, - headers=_header_parameters, - **kwargs - ) + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + return HttpRequest(method="HEAD", url=_url, params=_params, headers=_headers, **kwargs) -def build_deployments_create_or_update_at_scope_request_initial( - scope: str, - deployment_name: str, - *, - json: JSONType = None, - content: Any = None, - **kwargs: Any -) -> HttpRequest: - api_version = kwargs.pop('api_version', "2019-10-01") # type: str - content_type = kwargs.pop('content_type', None) # type: Optional[str] - accept = "application/json" +def build_deployments_create_or_update_at_scope_request(scope: str, deployment_name: 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", "2019-10-01")) # type: str + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + accept = _headers.pop("Accept", "application/json") + # Construct URL _url = kwargs.pop("template_url", "/{scope}/providers/Microsoft.Resources/deployments/{deploymentName}") path_format_arguments = { - "scope": _SERIALIZER.url("scope", scope, 'str', skip_quote=True), - "deploymentName": _SERIALIZER.url("deployment_name", deployment_name, 'str', max_length=64, min_length=1, pattern=r'^[-\w\._\(\)]+$'), + "scope": _SERIALIZER.url("scope", scope, "str", skip_quote=True), + "deploymentName": _SERIALIZER.url( + "deployment_name", deployment_name, "str", max_length=64, min_length=1, pattern=r"^[-\w\._\(\)]+$" + ), } _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] if content_type is not None: - _header_parameters['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') - _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') - - return HttpRequest( - method="PUT", - url=_url, - params=_query_parameters, - headers=_header_parameters, - json=json, - content=content, - **kwargs - ) + _headers["Content-Type"] = _SERIALIZER.header("content_type", content_type, "str") + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + return HttpRequest(method="PUT", url=_url, params=_params, headers=_headers, **kwargs) -def build_deployments_get_at_scope_request( - scope: str, - deployment_name: str, - **kwargs: Any -) -> HttpRequest: - api_version = kwargs.pop('api_version', "2019-10-01") # type: str - accept = "application/json" +def build_deployments_get_at_scope_request(scope: str, deployment_name: 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", "2019-10-01")) # type: str + accept = _headers.pop("Accept", "application/json") + # Construct URL _url = kwargs.pop("template_url", "/{scope}/providers/Microsoft.Resources/deployments/{deploymentName}") path_format_arguments = { - "scope": _SERIALIZER.url("scope", scope, 'str', skip_quote=True), - "deploymentName": _SERIALIZER.url("deployment_name", deployment_name, 'str', max_length=64, min_length=1, pattern=r'^[-\w\._\(\)]+$'), + "scope": _SERIALIZER.url("scope", scope, "str", skip_quote=True), + "deploymentName": _SERIALIZER.url( + "deployment_name", deployment_name, "str", max_length=64, min_length=1, pattern=r"^[-\w\._\(\)]+$" + ), } _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') - - return HttpRequest( - method="GET", - url=_url, - params=_query_parameters, - headers=_header_parameters, - **kwargs - ) + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) -def build_deployments_cancel_at_scope_request( - scope: str, - deployment_name: str, - **kwargs: Any -) -> HttpRequest: - api_version = kwargs.pop('api_version', "2019-10-01") # type: str - accept = "application/json" +def build_deployments_cancel_at_scope_request(scope: str, deployment_name: 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", "2019-10-01")) # type: str + accept = _headers.pop("Accept", "application/json") + # Construct URL _url = kwargs.pop("template_url", "/{scope}/providers/Microsoft.Resources/deployments/{deploymentName}/cancel") path_format_arguments = { - "scope": _SERIALIZER.url("scope", scope, 'str', skip_quote=True), - "deploymentName": _SERIALIZER.url("deployment_name", deployment_name, 'str', max_length=64, min_length=1, pattern=r'^[-\w\._\(\)]+$'), + "scope": _SERIALIZER.url("scope", scope, "str", skip_quote=True), + "deploymentName": _SERIALIZER.url( + "deployment_name", deployment_name, "str", max_length=64, min_length=1, pattern=r"^[-\w\._\(\)]+$" + ), } _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') - - return HttpRequest( - method="POST", - url=_url, - params=_query_parameters, - headers=_header_parameters, - **kwargs - ) + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + return HttpRequest(method="POST", url=_url, params=_params, headers=_headers, **kwargs) -def build_deployments_validate_at_scope_request_initial( - scope: str, - deployment_name: str, - *, - json: JSONType = None, - content: Any = None, - **kwargs: Any -) -> HttpRequest: - api_version = kwargs.pop('api_version', "2019-10-01") # type: str - content_type = kwargs.pop('content_type', None) # type: Optional[str] - accept = "application/json" +def build_deployments_validate_at_scope_request(scope: str, deployment_name: 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", "2019-10-01")) # type: str + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + accept = _headers.pop("Accept", "application/json") + # Construct URL _url = kwargs.pop("template_url", "/{scope}/providers/Microsoft.Resources/deployments/{deploymentName}/validate") path_format_arguments = { - "scope": _SERIALIZER.url("scope", scope, 'str', skip_quote=True), - "deploymentName": _SERIALIZER.url("deployment_name", deployment_name, 'str', max_length=64, min_length=1, pattern=r'^[-\w\._\(\)]+$'), + "scope": _SERIALIZER.url("scope", scope, "str", skip_quote=True), + "deploymentName": _SERIALIZER.url( + "deployment_name", deployment_name, "str", max_length=64, min_length=1, pattern=r"^[-\w\._\(\)]+$" + ), } _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] if content_type is not None: - _header_parameters['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') - _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') - - return HttpRequest( - method="POST", - url=_url, - params=_query_parameters, - headers=_header_parameters, - json=json, - content=content, - **kwargs - ) + _headers["Content-Type"] = _SERIALIZER.header("content_type", content_type, "str") + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + return HttpRequest(method="POST", url=_url, params=_params, headers=_headers, **kwargs) -def build_deployments_export_template_at_scope_request( - scope: str, - deployment_name: str, - **kwargs: Any -) -> HttpRequest: - api_version = kwargs.pop('api_version', "2019-10-01") # type: str - accept = "application/json" +def build_deployments_export_template_at_scope_request(scope: str, deployment_name: 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", "2019-10-01")) # type: str + accept = _headers.pop("Accept", "application/json") + # Construct URL - _url = kwargs.pop("template_url", "/{scope}/providers/Microsoft.Resources/deployments/{deploymentName}/exportTemplate") + _url = kwargs.pop( + "template_url", "/{scope}/providers/Microsoft.Resources/deployments/{deploymentName}/exportTemplate" + ) path_format_arguments = { - "scope": _SERIALIZER.url("scope", scope, 'str', skip_quote=True), - "deploymentName": _SERIALIZER.url("deployment_name", deployment_name, 'str', max_length=64, min_length=1, pattern=r'^[-\w\._\(\)]+$'), + "scope": _SERIALIZER.url("scope", scope, "str", skip_quote=True), + "deploymentName": _SERIALIZER.url( + "deployment_name", deployment_name, "str", max_length=64, min_length=1, pattern=r"^[-\w\._\(\)]+$" + ), } _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') - - return HttpRequest( - method="POST", - url=_url, - params=_query_parameters, - headers=_header_parameters, - **kwargs - ) + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="POST", url=_url, params=_params, headers=_headers, **kwargs) def build_deployments_list_at_scope_request( - scope: str, - *, - filter: Optional[str] = None, - top: Optional[int] = None, - **kwargs: Any + scope: str, *, filter: Optional[str] = None, top: Optional[int] = None, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2019-10-01") # type: 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", "2019-10-01")) # type: str + accept = _headers.pop("Accept", "application/json") - accept = "application/json" # Construct URL _url = kwargs.pop("template_url", "/{scope}/providers/Microsoft.Resources/deployments/") path_format_arguments = { - "scope": _SERIALIZER.url("scope", scope, 'str', skip_quote=True), + "scope": _SERIALIZER.url("scope", scope, "str", skip_quote=True), } _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] if filter is not None: - _query_parameters['$filter'] = _SERIALIZER.query("filter", filter, 'str') + _params["$filter"] = _SERIALIZER.query("filter", filter, "str") if top is not None: - _query_parameters['$top'] = _SERIALIZER.query("top", top, 'int') - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["$top"] = _SERIALIZER.query("top", top, "int") + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') - - return HttpRequest( - method="GET", - url=_url, - params=_query_parameters, - headers=_header_parameters, - **kwargs - ) + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) -def build_deployments_delete_at_tenant_scope_request_initial( - deployment_name: str, - **kwargs: Any -) -> HttpRequest: - api_version = kwargs.pop('api_version', "2019-10-01") # type: str - accept = "application/json" +def build_deployments_delete_at_tenant_scope_request(deployment_name: 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", "2019-10-01")) # type: str + accept = _headers.pop("Accept", "application/json") + # Construct URL _url = kwargs.pop("template_url", "/providers/Microsoft.Resources/deployments/{deploymentName}") path_format_arguments = { - "deploymentName": _SERIALIZER.url("deployment_name", deployment_name, 'str', max_length=64, min_length=1, pattern=r'^[-\w\._\(\)]+$'), + "deploymentName": _SERIALIZER.url( + "deployment_name", deployment_name, "str", max_length=64, min_length=1, pattern=r"^[-\w\._\(\)]+$" + ), } _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') - - return HttpRequest( - method="DELETE", - url=_url, - params=_query_parameters, - headers=_header_parameters, - **kwargs - ) + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + return HttpRequest(method="DELETE", url=_url, params=_params, headers=_headers, **kwargs) -def build_deployments_check_existence_at_tenant_scope_request( - deployment_name: str, - **kwargs: Any -) -> HttpRequest: - api_version = kwargs.pop('api_version', "2019-10-01") # type: str - accept = "application/json" +def build_deployments_check_existence_at_tenant_scope_request(deployment_name: 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", "2019-10-01")) # type: str + accept = _headers.pop("Accept", "application/json") + # Construct URL _url = kwargs.pop("template_url", "/providers/Microsoft.Resources/deployments/{deploymentName}") path_format_arguments = { - "deploymentName": _SERIALIZER.url("deployment_name", deployment_name, 'str', max_length=64, min_length=1, pattern=r'^[-\w\._\(\)]+$'), + "deploymentName": _SERIALIZER.url( + "deployment_name", deployment_name, "str", max_length=64, min_length=1, pattern=r"^[-\w\._\(\)]+$" + ), } _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') - - return HttpRequest( - method="HEAD", - url=_url, - params=_query_parameters, - headers=_header_parameters, - **kwargs - ) + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + return HttpRequest(method="HEAD", url=_url, params=_params, headers=_headers, **kwargs) -def build_deployments_create_or_update_at_tenant_scope_request_initial( - deployment_name: str, - *, - json: JSONType = None, - content: Any = None, - **kwargs: Any -) -> HttpRequest: - api_version = kwargs.pop('api_version', "2019-10-01") # type: str - content_type = kwargs.pop('content_type', None) # type: Optional[str] - accept = "application/json" +def build_deployments_create_or_update_at_tenant_scope_request(deployment_name: 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", "2019-10-01")) # type: str + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + accept = _headers.pop("Accept", "application/json") + # Construct URL _url = kwargs.pop("template_url", "/providers/Microsoft.Resources/deployments/{deploymentName}") path_format_arguments = { - "deploymentName": _SERIALIZER.url("deployment_name", deployment_name, 'str', max_length=64, min_length=1, pattern=r'^[-\w\._\(\)]+$'), + "deploymentName": _SERIALIZER.url( + "deployment_name", deployment_name, "str", max_length=64, min_length=1, pattern=r"^[-\w\._\(\)]+$" + ), } _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] if content_type is not None: - _header_parameters['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') - _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') - - return HttpRequest( - method="PUT", - url=_url, - params=_query_parameters, - headers=_header_parameters, - json=json, - content=content, - **kwargs - ) + _headers["Content-Type"] = _SERIALIZER.header("content_type", content_type, "str") + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + return HttpRequest(method="PUT", url=_url, params=_params, headers=_headers, **kwargs) -def build_deployments_get_at_tenant_scope_request( - deployment_name: str, - **kwargs: Any -) -> HttpRequest: - api_version = kwargs.pop('api_version', "2019-10-01") # type: str - accept = "application/json" +def build_deployments_get_at_tenant_scope_request(deployment_name: 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", "2019-10-01")) # type: str + accept = _headers.pop("Accept", "application/json") + # Construct URL _url = kwargs.pop("template_url", "/providers/Microsoft.Resources/deployments/{deploymentName}") path_format_arguments = { - "deploymentName": _SERIALIZER.url("deployment_name", deployment_name, 'str', max_length=64, min_length=1, pattern=r'^[-\w\._\(\)]+$'), + "deploymentName": _SERIALIZER.url( + "deployment_name", deployment_name, "str", max_length=64, min_length=1, pattern=r"^[-\w\._\(\)]+$" + ), } _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') - - return HttpRequest( - method="GET", - url=_url, - params=_query_parameters, - headers=_header_parameters, - **kwargs - ) + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) -def build_deployments_cancel_at_tenant_scope_request( - deployment_name: str, - **kwargs: Any -) -> HttpRequest: - api_version = kwargs.pop('api_version', "2019-10-01") # type: str - accept = "application/json" +def build_deployments_cancel_at_tenant_scope_request(deployment_name: 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", "2019-10-01")) # type: str + accept = _headers.pop("Accept", "application/json") + # Construct URL _url = kwargs.pop("template_url", "/providers/Microsoft.Resources/deployments/{deploymentName}/cancel") path_format_arguments = { - "deploymentName": _SERIALIZER.url("deployment_name", deployment_name, 'str', max_length=64, min_length=1, pattern=r'^[-\w\._\(\)]+$'), + "deploymentName": _SERIALIZER.url( + "deployment_name", deployment_name, "str", max_length=64, min_length=1, pattern=r"^[-\w\._\(\)]+$" + ), } _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') - - return HttpRequest( - method="POST", - url=_url, - params=_query_parameters, - headers=_header_parameters, - **kwargs - ) + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + return HttpRequest(method="POST", url=_url, params=_params, headers=_headers, **kwargs) -def build_deployments_validate_at_tenant_scope_request_initial( - deployment_name: str, - *, - json: JSONType = None, - content: Any = None, - **kwargs: Any -) -> HttpRequest: - api_version = kwargs.pop('api_version', "2019-10-01") # type: str - content_type = kwargs.pop('content_type', None) # type: Optional[str] - accept = "application/json" +def build_deployments_validate_at_tenant_scope_request(deployment_name: 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", "2019-10-01")) # type: str + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + accept = _headers.pop("Accept", "application/json") + # Construct URL _url = kwargs.pop("template_url", "/providers/Microsoft.Resources/deployments/{deploymentName}/validate") path_format_arguments = { - "deploymentName": _SERIALIZER.url("deployment_name", deployment_name, 'str', max_length=64, min_length=1, pattern=r'^[-\w\._\(\)]+$'), + "deploymentName": _SERIALIZER.url( + "deployment_name", deployment_name, "str", max_length=64, min_length=1, pattern=r"^[-\w\._\(\)]+$" + ), } _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] if content_type is not None: - _header_parameters['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') - _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') - - return HttpRequest( - method="POST", - url=_url, - params=_query_parameters, - headers=_header_parameters, - json=json, - content=content, - **kwargs - ) + _headers["Content-Type"] = _SERIALIZER.header("content_type", content_type, "str") + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + return HttpRequest(method="POST", url=_url, params=_params, headers=_headers, **kwargs) -def build_deployments_what_if_at_tenant_scope_request_initial( - deployment_name: str, - *, - json: JSONType = None, - content: Any = None, - **kwargs: Any -) -> HttpRequest: - api_version = kwargs.pop('api_version', "2019-10-01") # type: str - content_type = kwargs.pop('content_type', None) # type: Optional[str] - accept = "application/json" +def build_deployments_what_if_at_tenant_scope_request(deployment_name: 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", "2019-10-01")) # type: str + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + accept = _headers.pop("Accept", "application/json") + # Construct URL _url = kwargs.pop("template_url", "/providers/Microsoft.Resources/deployments/{deploymentName}/whatIf") path_format_arguments = { - "deploymentName": _SERIALIZER.url("deployment_name", deployment_name, 'str', max_length=64, min_length=1, pattern=r'^[-\w\._\(\)]+$'), + "deploymentName": _SERIALIZER.url( + "deployment_name", deployment_name, "str", max_length=64, min_length=1, pattern=r"^[-\w\._\(\)]+$" + ), } _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] if content_type is not None: - _header_parameters['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') - _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') - - return HttpRequest( - method="POST", - url=_url, - params=_query_parameters, - headers=_header_parameters, - json=json, - content=content, - **kwargs - ) + _headers["Content-Type"] = _SERIALIZER.header("content_type", content_type, "str") + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + return HttpRequest(method="POST", url=_url, params=_params, headers=_headers, **kwargs) -def build_deployments_export_template_at_tenant_scope_request( - deployment_name: str, - **kwargs: Any -) -> HttpRequest: - api_version = kwargs.pop('api_version', "2019-10-01") # type: str - accept = "application/json" +def build_deployments_export_template_at_tenant_scope_request(deployment_name: 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", "2019-10-01")) # type: str + accept = _headers.pop("Accept", "application/json") + # Construct URL _url = kwargs.pop("template_url", "/providers/Microsoft.Resources/deployments/{deploymentName}/exportTemplate") path_format_arguments = { - "deploymentName": _SERIALIZER.url("deployment_name", deployment_name, 'str', max_length=64, min_length=1, pattern=r'^[-\w\._\(\)]+$'), + "deploymentName": _SERIALIZER.url( + "deployment_name", deployment_name, "str", max_length=64, min_length=1, pattern=r"^[-\w\._\(\)]+$" + ), } _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') - - return HttpRequest( - method="POST", - url=_url, - params=_query_parameters, - headers=_header_parameters, - **kwargs - ) + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="POST", url=_url, params=_params, headers=_headers, **kwargs) def build_deployments_list_at_tenant_scope_request( - *, - filter: Optional[str] = None, - top: Optional[int] = None, - **kwargs: Any + *, filter: Optional[str] = None, top: Optional[int] = None, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2019-10-01") # type: 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", "2019-10-01")) # type: str + accept = _headers.pop("Accept", "application/json") - accept = "application/json" # Construct URL _url = kwargs.pop("template_url", "/providers/Microsoft.Resources/deployments/") # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] if filter is not None: - _query_parameters['$filter'] = _SERIALIZER.query("filter", filter, 'str') + _params["$filter"] = _SERIALIZER.query("filter", filter, "str") if top is not None: - _query_parameters['$top'] = _SERIALIZER.query("top", top, 'int') - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["$top"] = _SERIALIZER.query("top", top, "int") + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') - - return HttpRequest( - method="GET", - url=_url, - params=_query_parameters, - headers=_header_parameters, - **kwargs - ) + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) -def build_deployments_delete_at_management_group_scope_request_initial( - group_id: str, - deployment_name: str, - **kwargs: Any + +def build_deployments_delete_at_management_group_scope_request( + group_id: str, deployment_name: str, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2019-10-01") # type: 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", "2019-10-01")) # type: str + accept = _headers.pop("Accept", "application/json") - accept = "application/json" # Construct URL - _url = kwargs.pop("template_url", "/providers/Microsoft.Management/managementGroups/{groupId}/providers/Microsoft.Resources/deployments/{deploymentName}") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", + "/providers/Microsoft.Management/managementGroups/{groupId}/providers/Microsoft.Resources/deployments/{deploymentName}", + ) # pylint: disable=line-too-long path_format_arguments = { - "groupId": _SERIALIZER.url("group_id", group_id, 'str', max_length=90, min_length=1), - "deploymentName": _SERIALIZER.url("deployment_name", deployment_name, 'str', max_length=64, min_length=1, pattern=r'^[-\w\._\(\)]+$'), + "groupId": _SERIALIZER.url("group_id", group_id, "str", max_length=90, min_length=1), + "deploymentName": _SERIALIZER.url( + "deployment_name", deployment_name, "str", max_length=64, min_length=1, pattern=r"^[-\w\._\(\)]+$" + ), } _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') - - return HttpRequest( - method="DELETE", - url=_url, - params=_query_parameters, - headers=_header_parameters, - **kwargs - ) + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="DELETE", url=_url, params=_params, headers=_headers, **kwargs) def build_deployments_check_existence_at_management_group_scope_request( - group_id: str, - deployment_name: str, - **kwargs: Any + group_id: str, deployment_name: str, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2019-10-01") # type: 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", "2019-10-01")) # type: str + accept = _headers.pop("Accept", "application/json") - accept = "application/json" # Construct URL - _url = kwargs.pop("template_url", "/providers/Microsoft.Management/managementGroups/{groupId}/providers/Microsoft.Resources/deployments/{deploymentName}") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", + "/providers/Microsoft.Management/managementGroups/{groupId}/providers/Microsoft.Resources/deployments/{deploymentName}", + ) # pylint: disable=line-too-long path_format_arguments = { - "groupId": _SERIALIZER.url("group_id", group_id, 'str', max_length=90, min_length=1), - "deploymentName": _SERIALIZER.url("deployment_name", deployment_name, 'str', max_length=64, min_length=1, pattern=r'^[-\w\._\(\)]+$'), + "groupId": _SERIALIZER.url("group_id", group_id, "str", max_length=90, min_length=1), + "deploymentName": _SERIALIZER.url( + "deployment_name", deployment_name, "str", max_length=64, min_length=1, pattern=r"^[-\w\._\(\)]+$" + ), } _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') - - return HttpRequest( - method="HEAD", - url=_url, - params=_query_parameters, - headers=_header_parameters, - **kwargs - ) + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + return HttpRequest(method="HEAD", url=_url, params=_params, headers=_headers, **kwargs) -def build_deployments_create_or_update_at_management_group_scope_request_initial( - group_id: str, - deployment_name: str, - *, - json: JSONType = None, - content: Any = None, - **kwargs: Any + +def build_deployments_create_or_update_at_management_group_scope_request( + group_id: str, deployment_name: str, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2019-10-01") # type: str - content_type = kwargs.pop('content_type', None) # type: Optional[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", "2019-10-01")) # type: str + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + accept = _headers.pop("Accept", "application/json") - accept = "application/json" # Construct URL - _url = kwargs.pop("template_url", "/providers/Microsoft.Management/managementGroups/{groupId}/providers/Microsoft.Resources/deployments/{deploymentName}") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", + "/providers/Microsoft.Management/managementGroups/{groupId}/providers/Microsoft.Resources/deployments/{deploymentName}", + ) # pylint: disable=line-too-long path_format_arguments = { - "groupId": _SERIALIZER.url("group_id", group_id, 'str', max_length=90, min_length=1), - "deploymentName": _SERIALIZER.url("deployment_name", deployment_name, 'str', max_length=64, min_length=1, pattern=r'^[-\w\._\(\)]+$'), + "groupId": _SERIALIZER.url("group_id", group_id, "str", max_length=90, min_length=1), + "deploymentName": _SERIALIZER.url( + "deployment_name", deployment_name, "str", max_length=64, min_length=1, pattern=r"^[-\w\._\(\)]+$" + ), } _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] if content_type is not None: - _header_parameters['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') - _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') - - return HttpRequest( - method="PUT", - url=_url, - params=_query_parameters, - headers=_header_parameters, - json=json, - content=content, - **kwargs - ) + _headers["Content-Type"] = _SERIALIZER.header("content_type", content_type, "str") + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="PUT", url=_url, params=_params, headers=_headers, **kwargs) def build_deployments_get_at_management_group_scope_request( - group_id: str, - deployment_name: str, - **kwargs: Any + group_id: str, deployment_name: str, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2019-10-01") # type: 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", "2019-10-01")) # type: str + accept = _headers.pop("Accept", "application/json") - accept = "application/json" # Construct URL - _url = kwargs.pop("template_url", "/providers/Microsoft.Management/managementGroups/{groupId}/providers/Microsoft.Resources/deployments/{deploymentName}") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", + "/providers/Microsoft.Management/managementGroups/{groupId}/providers/Microsoft.Resources/deployments/{deploymentName}", + ) # pylint: disable=line-too-long path_format_arguments = { - "groupId": _SERIALIZER.url("group_id", group_id, 'str', max_length=90, min_length=1), - "deploymentName": _SERIALIZER.url("deployment_name", deployment_name, 'str', max_length=64, min_length=1, pattern=r'^[-\w\._\(\)]+$'), + "groupId": _SERIALIZER.url("group_id", group_id, "str", max_length=90, min_length=1), + "deploymentName": _SERIALIZER.url( + "deployment_name", deployment_name, "str", max_length=64, min_length=1, pattern=r"^[-\w\._\(\)]+$" + ), } _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') - - return HttpRequest( - method="GET", - url=_url, - params=_query_parameters, - headers=_header_parameters, - **kwargs - ) + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) def build_deployments_cancel_at_management_group_scope_request( - group_id: str, - deployment_name: str, - **kwargs: Any + group_id: str, deployment_name: str, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2019-10-01") # type: 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", "2019-10-01")) # type: str + accept = _headers.pop("Accept", "application/json") - accept = "application/json" # Construct URL - _url = kwargs.pop("template_url", "/providers/Microsoft.Management/managementGroups/{groupId}/providers/Microsoft.Resources/deployments/{deploymentName}/cancel") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", + "/providers/Microsoft.Management/managementGroups/{groupId}/providers/Microsoft.Resources/deployments/{deploymentName}/cancel", + ) # pylint: disable=line-too-long path_format_arguments = { - "groupId": _SERIALIZER.url("group_id", group_id, 'str', max_length=90, min_length=1), - "deploymentName": _SERIALIZER.url("deployment_name", deployment_name, 'str', max_length=64, min_length=1, pattern=r'^[-\w\._\(\)]+$'), + "groupId": _SERIALIZER.url("group_id", group_id, "str", max_length=90, min_length=1), + "deploymentName": _SERIALIZER.url( + "deployment_name", deployment_name, "str", max_length=64, min_length=1, pattern=r"^[-\w\._\(\)]+$" + ), } _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') - - return HttpRequest( - method="POST", - url=_url, - params=_query_parameters, - headers=_header_parameters, - **kwargs - ) + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + return HttpRequest(method="POST", url=_url, params=_params, headers=_headers, **kwargs) -def build_deployments_validate_at_management_group_scope_request_initial( - group_id: str, - deployment_name: str, - *, - json: JSONType = None, - content: Any = None, - **kwargs: Any + +def build_deployments_validate_at_management_group_scope_request( + group_id: str, deployment_name: str, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2019-10-01") # type: str - content_type = kwargs.pop('content_type', None) # type: Optional[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", "2019-10-01")) # type: str + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + accept = _headers.pop("Accept", "application/json") - accept = "application/json" # Construct URL - _url = kwargs.pop("template_url", "/providers/Microsoft.Management/managementGroups/{groupId}/providers/Microsoft.Resources/deployments/{deploymentName}/validate") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", + "/providers/Microsoft.Management/managementGroups/{groupId}/providers/Microsoft.Resources/deployments/{deploymentName}/validate", + ) # pylint: disable=line-too-long path_format_arguments = { - "groupId": _SERIALIZER.url("group_id", group_id, 'str', max_length=90, min_length=1), - "deploymentName": _SERIALIZER.url("deployment_name", deployment_name, 'str', max_length=64, min_length=1, pattern=r'^[-\w\._\(\)]+$'), + "groupId": _SERIALIZER.url("group_id", group_id, "str", max_length=90, min_length=1), + "deploymentName": _SERIALIZER.url( + "deployment_name", deployment_name, "str", max_length=64, min_length=1, pattern=r"^[-\w\._\(\)]+$" + ), } _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] if content_type is not None: - _header_parameters['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') - _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') - - return HttpRequest( - method="POST", - url=_url, - params=_query_parameters, - headers=_header_parameters, - json=json, - content=content, - **kwargs - ) + _headers["Content-Type"] = _SERIALIZER.header("content_type", content_type, "str") + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + return HttpRequest(method="POST", url=_url, params=_params, headers=_headers, **kwargs) -def build_deployments_what_if_at_management_group_scope_request_initial( - group_id: str, - deployment_name: str, - *, - json: JSONType = None, - content: Any = None, - **kwargs: Any + +def build_deployments_what_if_at_management_group_scope_request( + group_id: str, deployment_name: str, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2019-10-01") # type: str - content_type = kwargs.pop('content_type', None) # type: Optional[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", "2019-10-01")) # type: str + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + accept = _headers.pop("Accept", "application/json") - accept = "application/json" # Construct URL - _url = kwargs.pop("template_url", "/providers/Microsoft.Management/managementGroups/{groupId}/providers/Microsoft.Resources/deployments/{deploymentName}/whatIf") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", + "/providers/Microsoft.Management/managementGroups/{groupId}/providers/Microsoft.Resources/deployments/{deploymentName}/whatIf", + ) # pylint: disable=line-too-long path_format_arguments = { - "groupId": _SERIALIZER.url("group_id", group_id, 'str', max_length=90, min_length=1), - "deploymentName": _SERIALIZER.url("deployment_name", deployment_name, 'str', max_length=64, min_length=1, pattern=r'^[-\w\._\(\)]+$'), + "groupId": _SERIALIZER.url("group_id", group_id, "str", max_length=90, min_length=1), + "deploymentName": _SERIALIZER.url( + "deployment_name", deployment_name, "str", max_length=64, min_length=1, pattern=r"^[-\w\._\(\)]+$" + ), } _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] if content_type is not None: - _header_parameters['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') - _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') - - return HttpRequest( - method="POST", - url=_url, - params=_query_parameters, - headers=_header_parameters, - json=json, - content=content, - **kwargs - ) + _headers["Content-Type"] = _SERIALIZER.header("content_type", content_type, "str") + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="POST", url=_url, params=_params, headers=_headers, **kwargs) def build_deployments_export_template_at_management_group_scope_request( - group_id: str, - deployment_name: str, - **kwargs: Any + group_id: str, deployment_name: str, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2019-10-01") # type: 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", "2019-10-01")) # type: str + accept = _headers.pop("Accept", "application/json") - accept = "application/json" # Construct URL - _url = kwargs.pop("template_url", "/providers/Microsoft.Management/managementGroups/{groupId}/providers/Microsoft.Resources/deployments/{deploymentName}/exportTemplate") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", + "/providers/Microsoft.Management/managementGroups/{groupId}/providers/Microsoft.Resources/deployments/{deploymentName}/exportTemplate", + ) # pylint: disable=line-too-long path_format_arguments = { - "groupId": _SERIALIZER.url("group_id", group_id, 'str', max_length=90, min_length=1), - "deploymentName": _SERIALIZER.url("deployment_name", deployment_name, 'str', max_length=64, min_length=1, pattern=r'^[-\w\._\(\)]+$'), + "groupId": _SERIALIZER.url("group_id", group_id, "str", max_length=90, min_length=1), + "deploymentName": _SERIALIZER.url( + "deployment_name", deployment_name, "str", max_length=64, min_length=1, pattern=r"^[-\w\._\(\)]+$" + ), } _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') - - return HttpRequest( - method="POST", - url=_url, - params=_query_parameters, - headers=_header_parameters, - **kwargs - ) + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="POST", url=_url, params=_params, headers=_headers, **kwargs) def build_deployments_list_at_management_group_scope_request( - group_id: str, - *, - filter: Optional[str] = None, - top: Optional[int] = None, - **kwargs: Any + group_id: str, *, filter: Optional[str] = None, top: Optional[int] = None, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2019-10-01") # type: 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", "2019-10-01")) # type: str + accept = _headers.pop("Accept", "application/json") - accept = "application/json" # Construct URL - _url = kwargs.pop("template_url", "/providers/Microsoft.Management/managementGroups/{groupId}/providers/Microsoft.Resources/deployments/") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", + "/providers/Microsoft.Management/managementGroups/{groupId}/providers/Microsoft.Resources/deployments/", + ) # pylint: disable=line-too-long path_format_arguments = { - "groupId": _SERIALIZER.url("group_id", group_id, 'str', max_length=90, min_length=1), + "groupId": _SERIALIZER.url("group_id", group_id, "str", max_length=90, min_length=1), } _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] if filter is not None: - _query_parameters['$filter'] = _SERIALIZER.query("filter", filter, 'str') + _params["$filter"] = _SERIALIZER.query("filter", filter, "str") if top is not None: - _query_parameters['$top'] = _SERIALIZER.query("top", top, 'int') - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["$top"] = _SERIALIZER.query("top", top, "int") + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') - - return HttpRequest( - method="GET", - url=_url, - params=_query_parameters, - headers=_header_parameters, - **kwargs - ) + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) -def build_deployments_delete_at_subscription_scope_request_initial( - deployment_name: str, - subscription_id: str, - **kwargs: Any + +def build_deployments_delete_at_subscription_scope_request( + deployment_name: str, subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2019-10-01") # type: 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", "2019-10-01")) # type: str + accept = _headers.pop("Accept", "application/json") - accept = "application/json" # Construct URL - _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/providers/Microsoft.Resources/deployments/{deploymentName}") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", "/subscriptions/{subscriptionId}/providers/Microsoft.Resources/deployments/{deploymentName}" + ) # pylint: disable=line-too-long path_format_arguments = { - "deploymentName": _SERIALIZER.url("deployment_name", deployment_name, 'str', max_length=64, min_length=1, pattern=r'^[-\w\._\(\)]+$'), - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), + "deploymentName": _SERIALIZER.url( + "deployment_name", deployment_name, "str", max_length=64, min_length=1, pattern=r"^[-\w\._\(\)]+$" + ), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), } _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') - - return HttpRequest( - method="DELETE", - url=_url, - params=_query_parameters, - headers=_header_parameters, - **kwargs - ) + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="DELETE", url=_url, params=_params, headers=_headers, **kwargs) def build_deployments_check_existence_at_subscription_scope_request( - deployment_name: str, - subscription_id: str, - **kwargs: Any + deployment_name: str, subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2019-10-01") # type: 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", "2019-10-01")) # type: str + accept = _headers.pop("Accept", "application/json") - accept = "application/json" # Construct URL - _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/providers/Microsoft.Resources/deployments/{deploymentName}") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", "/subscriptions/{subscriptionId}/providers/Microsoft.Resources/deployments/{deploymentName}" + ) # pylint: disable=line-too-long path_format_arguments = { - "deploymentName": _SERIALIZER.url("deployment_name", deployment_name, 'str', max_length=64, min_length=1, pattern=r'^[-\w\._\(\)]+$'), - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), + "deploymentName": _SERIALIZER.url( + "deployment_name", deployment_name, "str", max_length=64, min_length=1, pattern=r"^[-\w\._\(\)]+$" + ), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), } _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') - - return HttpRequest( - method="HEAD", - url=_url, - params=_query_parameters, - headers=_header_parameters, - **kwargs - ) + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + return HttpRequest(method="HEAD", url=_url, params=_params, headers=_headers, **kwargs) -def build_deployments_create_or_update_at_subscription_scope_request_initial( - deployment_name: str, - subscription_id: str, - *, - json: JSONType = None, - content: Any = None, - **kwargs: Any + +def build_deployments_create_or_update_at_subscription_scope_request( + deployment_name: str, subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2019-10-01") # type: str - content_type = kwargs.pop('content_type', None) # type: Optional[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", "2019-10-01")) # type: str + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + accept = _headers.pop("Accept", "application/json") - accept = "application/json" # Construct URL - _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/providers/Microsoft.Resources/deployments/{deploymentName}") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", "/subscriptions/{subscriptionId}/providers/Microsoft.Resources/deployments/{deploymentName}" + ) # pylint: disable=line-too-long path_format_arguments = { - "deploymentName": _SERIALIZER.url("deployment_name", deployment_name, 'str', max_length=64, min_length=1, pattern=r'^[-\w\._\(\)]+$'), - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), + "deploymentName": _SERIALIZER.url( + "deployment_name", deployment_name, "str", max_length=64, min_length=1, pattern=r"^[-\w\._\(\)]+$" + ), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), } _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] if content_type is not None: - _header_parameters['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') - _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') - - return HttpRequest( - method="PUT", - url=_url, - params=_query_parameters, - headers=_header_parameters, - json=json, - content=content, - **kwargs - ) + _headers["Content-Type"] = _SERIALIZER.header("content_type", content_type, "str") + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="PUT", url=_url, params=_params, headers=_headers, **kwargs) def build_deployments_get_at_subscription_scope_request( - deployment_name: str, - subscription_id: str, - **kwargs: Any + deployment_name: str, subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2019-10-01") # type: 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", "2019-10-01")) # type: str + accept = _headers.pop("Accept", "application/json") - accept = "application/json" # Construct URL - _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/providers/Microsoft.Resources/deployments/{deploymentName}") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", "/subscriptions/{subscriptionId}/providers/Microsoft.Resources/deployments/{deploymentName}" + ) # pylint: disable=line-too-long path_format_arguments = { - "deploymentName": _SERIALIZER.url("deployment_name", deployment_name, 'str', max_length=64, min_length=1, pattern=r'^[-\w\._\(\)]+$'), - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), + "deploymentName": _SERIALIZER.url( + "deployment_name", deployment_name, "str", max_length=64, min_length=1, pattern=r"^[-\w\._\(\)]+$" + ), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), } _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') - - return HttpRequest( - method="GET", - url=_url, - params=_query_parameters, - headers=_header_parameters, - **kwargs - ) + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) def build_deployments_cancel_at_subscription_scope_request( - deployment_name: str, - subscription_id: str, - **kwargs: Any + deployment_name: str, subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2019-10-01") # type: 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", "2019-10-01")) # type: str + accept = _headers.pop("Accept", "application/json") - accept = "application/json" # Construct URL - _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/providers/Microsoft.Resources/deployments/{deploymentName}/cancel") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/providers/Microsoft.Resources/deployments/{deploymentName}/cancel", + ) # pylint: disable=line-too-long path_format_arguments = { - "deploymentName": _SERIALIZER.url("deployment_name", deployment_name, 'str', max_length=64, min_length=1, pattern=r'^[-\w\._\(\)]+$'), - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), + "deploymentName": _SERIALIZER.url( + "deployment_name", deployment_name, "str", max_length=64, min_length=1, pattern=r"^[-\w\._\(\)]+$" + ), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), } _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') - - return HttpRequest( - method="POST", - url=_url, - params=_query_parameters, - headers=_header_parameters, - **kwargs - ) + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + return HttpRequest(method="POST", url=_url, params=_params, headers=_headers, **kwargs) -def build_deployments_validate_at_subscription_scope_request_initial( - deployment_name: str, - subscription_id: str, - *, - json: JSONType = None, - content: Any = None, - **kwargs: Any + +def build_deployments_validate_at_subscription_scope_request( + deployment_name: str, subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2019-10-01") # type: str - content_type = kwargs.pop('content_type', None) # type: Optional[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", "2019-10-01")) # type: str + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + accept = _headers.pop("Accept", "application/json") - accept = "application/json" # Construct URL - _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/providers/Microsoft.Resources/deployments/{deploymentName}/validate") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/providers/Microsoft.Resources/deployments/{deploymentName}/validate", + ) # pylint: disable=line-too-long path_format_arguments = { - "deploymentName": _SERIALIZER.url("deployment_name", deployment_name, 'str', max_length=64, min_length=1, pattern=r'^[-\w\._\(\)]+$'), - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), + "deploymentName": _SERIALIZER.url( + "deployment_name", deployment_name, "str", max_length=64, min_length=1, pattern=r"^[-\w\._\(\)]+$" + ), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), } _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] if content_type is not None: - _header_parameters['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') - _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') - - return HttpRequest( - method="POST", - url=_url, - params=_query_parameters, - headers=_header_parameters, - json=json, - content=content, - **kwargs - ) + _headers["Content-Type"] = _SERIALIZER.header("content_type", content_type, "str") + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + return HttpRequest(method="POST", url=_url, params=_params, headers=_headers, **kwargs) -def build_deployments_what_if_at_subscription_scope_request_initial( - deployment_name: str, - subscription_id: str, - *, - json: JSONType = None, - content: Any = None, - **kwargs: Any + +def build_deployments_what_if_at_subscription_scope_request( + deployment_name: str, subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2019-10-01") # type: str - content_type = kwargs.pop('content_type', None) # type: Optional[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", "2019-10-01")) # type: str + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + accept = _headers.pop("Accept", "application/json") - accept = "application/json" # Construct URL - _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/providers/Microsoft.Resources/deployments/{deploymentName}/whatIf") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/providers/Microsoft.Resources/deployments/{deploymentName}/whatIf", + ) # pylint: disable=line-too-long path_format_arguments = { - "deploymentName": _SERIALIZER.url("deployment_name", deployment_name, 'str', max_length=64, min_length=1, pattern=r'^[-\w\._\(\)]+$'), - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), + "deploymentName": _SERIALIZER.url( + "deployment_name", deployment_name, "str", max_length=64, min_length=1, pattern=r"^[-\w\._\(\)]+$" + ), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), } _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] if content_type is not None: - _header_parameters['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') - _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') - - return HttpRequest( - method="POST", - url=_url, - params=_query_parameters, - headers=_header_parameters, - json=json, - content=content, - **kwargs - ) + _headers["Content-Type"] = _SERIALIZER.header("content_type", content_type, "str") + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="POST", url=_url, params=_params, headers=_headers, **kwargs) def build_deployments_export_template_at_subscription_scope_request( - deployment_name: str, - subscription_id: str, - **kwargs: Any + deployment_name: str, subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2019-10-01") # type: 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", "2019-10-01")) # type: str + accept = _headers.pop("Accept", "application/json") - accept = "application/json" # Construct URL - _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/providers/Microsoft.Resources/deployments/{deploymentName}/exportTemplate") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/providers/Microsoft.Resources/deployments/{deploymentName}/exportTemplate", + ) # pylint: disable=line-too-long path_format_arguments = { - "deploymentName": _SERIALIZER.url("deployment_name", deployment_name, 'str', max_length=64, min_length=1, pattern=r'^[-\w\._\(\)]+$'), - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), + "deploymentName": _SERIALIZER.url( + "deployment_name", deployment_name, "str", max_length=64, min_length=1, pattern=r"^[-\w\._\(\)]+$" + ), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), } _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') - - return HttpRequest( - method="POST", - url=_url, - params=_query_parameters, - headers=_header_parameters, - **kwargs - ) + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="POST", url=_url, params=_params, headers=_headers, **kwargs) def build_deployments_list_at_subscription_scope_request( - subscription_id: str, - *, - filter: Optional[str] = None, - top: Optional[int] = None, - **kwargs: Any + subscription_id: str, *, filter: Optional[str] = None, top: Optional[int] = None, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2019-10-01") # type: 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", "2019-10-01")) # type: str + accept = _headers.pop("Accept", "application/json") - accept = "application/json" # Construct URL _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/providers/Microsoft.Resources/deployments/") path_format_arguments = { - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), } _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] if filter is not None: - _query_parameters['$filter'] = _SERIALIZER.query("filter", filter, 'str') + _params["$filter"] = _SERIALIZER.query("filter", filter, "str") if top is not None: - _query_parameters['$top'] = _SERIALIZER.query("top", top, 'int') - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["$top"] = _SERIALIZER.query("top", top, "int") + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') - - return HttpRequest( - method="GET", - url=_url, - params=_query_parameters, - headers=_header_parameters, - **kwargs - ) + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) -def build_deployments_delete_request_initial( - resource_group_name: str, - deployment_name: str, - subscription_id: str, - **kwargs: Any + +def build_deployments_delete_request( + resource_group_name: str, deployment_name: str, subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2019-10-01") # type: 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", "2019-10-01")) # type: str + accept = _headers.pop("Accept", "application/json") - accept = "application/json" # Construct URL - _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/Microsoft.Resources/deployments/{deploymentName}") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/Microsoft.Resources/deployments/{deploymentName}", + ) # pylint: disable=line-too-long path_format_arguments = { - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._\(\)]+$'), - "deploymentName": _SERIALIZER.url("deployment_name", deployment_name, 'str', max_length=64, min_length=1, pattern=r'^[-\w\._\(\)]+$'), - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), + "resourceGroupName": _SERIALIZER.url( + "resource_group_name", resource_group_name, "str", max_length=90, min_length=1, pattern=r"^[-\w\._\(\)]+$" + ), + "deploymentName": _SERIALIZER.url( + "deployment_name", deployment_name, "str", max_length=64, min_length=1, pattern=r"^[-\w\._\(\)]+$" + ), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), } _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') - - return HttpRequest( - method="DELETE", - url=_url, - params=_query_parameters, - headers=_header_parameters, - **kwargs - ) + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="DELETE", url=_url, params=_params, headers=_headers, **kwargs) def build_deployments_check_existence_request( - resource_group_name: str, - deployment_name: str, - subscription_id: str, - **kwargs: Any + resource_group_name: str, deployment_name: str, subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2019-10-01") # type: 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", "2019-10-01")) # type: str + accept = _headers.pop("Accept", "application/json") - accept = "application/json" # Construct URL - _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/Microsoft.Resources/deployments/{deploymentName}") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/Microsoft.Resources/deployments/{deploymentName}", + ) # pylint: disable=line-too-long path_format_arguments = { - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._\(\)]+$'), - "deploymentName": _SERIALIZER.url("deployment_name", deployment_name, 'str', max_length=64, min_length=1, pattern=r'^[-\w\._\(\)]+$'), - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), + "resourceGroupName": _SERIALIZER.url( + "resource_group_name", resource_group_name, "str", max_length=90, min_length=1, pattern=r"^[-\w\._\(\)]+$" + ), + "deploymentName": _SERIALIZER.url( + "deployment_name", deployment_name, "str", max_length=64, min_length=1, pattern=r"^[-\w\._\(\)]+$" + ), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), } _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') - - return HttpRequest( - method="HEAD", - url=_url, - params=_query_parameters, - headers=_header_parameters, - **kwargs - ) + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + return HttpRequest(method="HEAD", url=_url, params=_params, headers=_headers, **kwargs) -def build_deployments_create_or_update_request_initial( - resource_group_name: str, - deployment_name: str, - subscription_id: str, - *, - json: JSONType = None, - content: Any = None, - **kwargs: Any + +def build_deployments_create_or_update_request( + resource_group_name: str, deployment_name: str, subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2019-10-01") # type: str - content_type = kwargs.pop('content_type', None) # type: Optional[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", "2019-10-01")) # type: str + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + accept = _headers.pop("Accept", "application/json") - accept = "application/json" # Construct URL - _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/Microsoft.Resources/deployments/{deploymentName}") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/Microsoft.Resources/deployments/{deploymentName}", + ) # pylint: disable=line-too-long path_format_arguments = { - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._\(\)]+$'), - "deploymentName": _SERIALIZER.url("deployment_name", deployment_name, 'str', max_length=64, min_length=1, pattern=r'^[-\w\._\(\)]+$'), - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), + "resourceGroupName": _SERIALIZER.url( + "resource_group_name", resource_group_name, "str", max_length=90, min_length=1, pattern=r"^[-\w\._\(\)]+$" + ), + "deploymentName": _SERIALIZER.url( + "deployment_name", deployment_name, "str", max_length=64, min_length=1, pattern=r"^[-\w\._\(\)]+$" + ), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), } _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] if content_type is not None: - _header_parameters['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') - _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') - - return HttpRequest( - method="PUT", - url=_url, - params=_query_parameters, - headers=_header_parameters, - json=json, - content=content, - **kwargs - ) + _headers["Content-Type"] = _SERIALIZER.header("content_type", content_type, "str") + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="PUT", url=_url, params=_params, headers=_headers, **kwargs) def build_deployments_get_request( - resource_group_name: str, - deployment_name: str, - subscription_id: str, - **kwargs: Any + resource_group_name: str, deployment_name: str, subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2019-10-01") # type: 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", "2019-10-01")) # type: str + accept = _headers.pop("Accept", "application/json") - accept = "application/json" # Construct URL - _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/Microsoft.Resources/deployments/{deploymentName}") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/Microsoft.Resources/deployments/{deploymentName}", + ) # pylint: disable=line-too-long path_format_arguments = { - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._\(\)]+$'), - "deploymentName": _SERIALIZER.url("deployment_name", deployment_name, 'str', max_length=64, min_length=1, pattern=r'^[-\w\._\(\)]+$'), - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), + "resourceGroupName": _SERIALIZER.url( + "resource_group_name", resource_group_name, "str", max_length=90, min_length=1, pattern=r"^[-\w\._\(\)]+$" + ), + "deploymentName": _SERIALIZER.url( + "deployment_name", deployment_name, "str", max_length=64, min_length=1, pattern=r"^[-\w\._\(\)]+$" + ), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), } _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') - - return HttpRequest( - method="GET", - url=_url, - params=_query_parameters, - headers=_header_parameters, - **kwargs - ) + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) def build_deployments_cancel_request( - resource_group_name: str, - deployment_name: str, - subscription_id: str, - **kwargs: Any + resource_group_name: str, deployment_name: str, subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2019-10-01") # type: 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", "2019-10-01")) # type: str + accept = _headers.pop("Accept", "application/json") - accept = "application/json" # Construct URL - _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/Microsoft.Resources/deployments/{deploymentName}/cancel") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/Microsoft.Resources/deployments/{deploymentName}/cancel", + ) # pylint: disable=line-too-long path_format_arguments = { - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._\(\)]+$'), - "deploymentName": _SERIALIZER.url("deployment_name", deployment_name, 'str', max_length=64, min_length=1, pattern=r'^[-\w\._\(\)]+$'), - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), + "resourceGroupName": _SERIALIZER.url( + "resource_group_name", resource_group_name, "str", max_length=90, min_length=1, pattern=r"^[-\w\._\(\)]+$" + ), + "deploymentName": _SERIALIZER.url( + "deployment_name", deployment_name, "str", max_length=64, min_length=1, pattern=r"^[-\w\._\(\)]+$" + ), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), } _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') - - return HttpRequest( - method="POST", - url=_url, - params=_query_parameters, - headers=_header_parameters, - **kwargs - ) + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + return HttpRequest(method="POST", url=_url, params=_params, headers=_headers, **kwargs) -def build_deployments_validate_request_initial( - resource_group_name: str, - deployment_name: str, - subscription_id: str, - *, - json: JSONType = None, - content: Any = None, - **kwargs: Any + +def build_deployments_validate_request( + resource_group_name: str, deployment_name: str, subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2019-10-01") # type: str - content_type = kwargs.pop('content_type', None) # type: Optional[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", "2019-10-01")) # type: str + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + accept = _headers.pop("Accept", "application/json") - accept = "application/json" # Construct URL - _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/Microsoft.Resources/deployments/{deploymentName}/validate") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/Microsoft.Resources/deployments/{deploymentName}/validate", + ) # pylint: disable=line-too-long path_format_arguments = { - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._\(\)]+$'), - "deploymentName": _SERIALIZER.url("deployment_name", deployment_name, 'str', max_length=64, min_length=1, pattern=r'^[-\w\._\(\)]+$'), - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), + "resourceGroupName": _SERIALIZER.url( + "resource_group_name", resource_group_name, "str", max_length=90, min_length=1, pattern=r"^[-\w\._\(\)]+$" + ), + "deploymentName": _SERIALIZER.url( + "deployment_name", deployment_name, "str", max_length=64, min_length=1, pattern=r"^[-\w\._\(\)]+$" + ), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), } _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] if content_type is not None: - _header_parameters['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') - _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') - - return HttpRequest( - method="POST", - url=_url, - params=_query_parameters, - headers=_header_parameters, - json=json, - content=content, - **kwargs - ) + _headers["Content-Type"] = _SERIALIZER.header("content_type", content_type, "str") + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + return HttpRequest(method="POST", url=_url, params=_params, headers=_headers, **kwargs) -def build_deployments_what_if_request_initial( - resource_group_name: str, - deployment_name: str, - subscription_id: str, - *, - json: JSONType = None, - content: Any = None, - **kwargs: Any + +def build_deployments_what_if_request( + resource_group_name: str, deployment_name: str, subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2019-10-01") # type: str - content_type = kwargs.pop('content_type', None) # type: Optional[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", "2019-10-01")) # type: str + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + accept = _headers.pop("Accept", "application/json") - accept = "application/json" # Construct URL - _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/Microsoft.Resources/deployments/{deploymentName}/whatIf") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/Microsoft.Resources/deployments/{deploymentName}/whatIf", + ) # pylint: disable=line-too-long path_format_arguments = { - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._\(\)]+$'), - "deploymentName": _SERIALIZER.url("deployment_name", deployment_name, 'str', max_length=64, min_length=1, pattern=r'^[-\w\._\(\)]+$'), - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), + "resourceGroupName": _SERIALIZER.url( + "resource_group_name", resource_group_name, "str", max_length=90, min_length=1, pattern=r"^[-\w\._\(\)]+$" + ), + "deploymentName": _SERIALIZER.url( + "deployment_name", deployment_name, "str", max_length=64, min_length=1, pattern=r"^[-\w\._\(\)]+$" + ), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), } _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] if content_type is not None: - _header_parameters['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') - _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') - - return HttpRequest( - method="POST", - url=_url, - params=_query_parameters, - headers=_header_parameters, - json=json, - content=content, - **kwargs - ) + _headers["Content-Type"] = _SERIALIZER.header("content_type", content_type, "str") + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="POST", url=_url, params=_params, headers=_headers, **kwargs) def build_deployments_export_template_request( - resource_group_name: str, - deployment_name: str, - subscription_id: str, - **kwargs: Any + resource_group_name: str, deployment_name: str, subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2019-10-01") # type: 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", "2019-10-01")) # type: str + accept = _headers.pop("Accept", "application/json") - accept = "application/json" # Construct URL - _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/Microsoft.Resources/deployments/{deploymentName}/exportTemplate") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/Microsoft.Resources/deployments/{deploymentName}/exportTemplate", + ) # pylint: disable=line-too-long path_format_arguments = { - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._\(\)]+$'), - "deploymentName": _SERIALIZER.url("deployment_name", deployment_name, 'str', max_length=64, min_length=1, pattern=r'^[-\w\._\(\)]+$'), - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), + "resourceGroupName": _SERIALIZER.url( + "resource_group_name", resource_group_name, "str", max_length=90, min_length=1, pattern=r"^[-\w\._\(\)]+$" + ), + "deploymentName": _SERIALIZER.url( + "deployment_name", deployment_name, "str", max_length=64, min_length=1, pattern=r"^[-\w\._\(\)]+$" + ), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), } _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') - - return HttpRequest( - method="POST", - url=_url, - params=_query_parameters, - headers=_header_parameters, - **kwargs - ) + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="POST", url=_url, params=_params, headers=_headers, **kwargs) def build_deployments_list_by_resource_group_request( @@ -1651,285 +1418,227 @@ def build_deployments_list_by_resource_group_request( top: Optional[int] = None, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2019-10-01") # type: 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", "2019-10-01")) # type: str + accept = _headers.pop("Accept", "application/json") - accept = "application/json" # Construct URL - _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/Microsoft.Resources/deployments/") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/Microsoft.Resources/deployments/", + ) # pylint: disable=line-too-long path_format_arguments = { - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._\(\)]+$'), - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), + "resourceGroupName": _SERIALIZER.url( + "resource_group_name", resource_group_name, "str", max_length=90, min_length=1, pattern=r"^[-\w\._\(\)]+$" + ), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), } _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] if filter is not None: - _query_parameters['$filter'] = _SERIALIZER.query("filter", filter, 'str') + _params["$filter"] = _SERIALIZER.query("filter", filter, "str") if top is not None: - _query_parameters['$top'] = _SERIALIZER.query("top", top, 'int') - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["$top"] = _SERIALIZER.query("top", top, "int") + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') - - return HttpRequest( - method="GET", - url=_url, - params=_query_parameters, - headers=_header_parameters, - **kwargs - ) + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) -def build_deployments_calculate_template_hash_request( - *, - json: JSONType = None, - content: Any = None, - **kwargs: Any -) -> HttpRequest: - api_version = kwargs.pop('api_version', "2019-10-01") # type: str - content_type = kwargs.pop('content_type', None) # type: Optional[str] - accept = "application/json" +def build_deployments_calculate_template_hash_request(*, json: JSON, **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", "2019-10-01")) # type: str + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + accept = _headers.pop("Accept", "application/json") + # Construct URL _url = kwargs.pop("template_url", "/providers/Microsoft.Resources/calculateTemplateHash") # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] if content_type is not None: - _header_parameters['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') - _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') - - return HttpRequest( - method="POST", - url=_url, - params=_query_parameters, - headers=_header_parameters, - json=json, - content=content, - **kwargs - ) + _headers["Content-Type"] = _SERIALIZER.header("content_type", content_type, "str") + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="POST", url=_url, params=_params, headers=_headers, json=json, **kwargs) def build_providers_unregister_request( - resource_provider_namespace: str, - subscription_id: str, - **kwargs: Any + resource_provider_namespace: str, subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2019-10-01") # type: 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", "2019-10-01")) # type: str + accept = _headers.pop("Accept", "application/json") - accept = "application/json" # Construct URL - _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/providers/{resourceProviderNamespace}/unregister") + _url = kwargs.pop( + "template_url", "/subscriptions/{subscriptionId}/providers/{resourceProviderNamespace}/unregister" + ) path_format_arguments = { - "resourceProviderNamespace": _SERIALIZER.url("resource_provider_namespace", resource_provider_namespace, 'str'), - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), + "resourceProviderNamespace": _SERIALIZER.url("resource_provider_namespace", resource_provider_namespace, "str"), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), } _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') - - return HttpRequest( - method="POST", - url=_url, - params=_query_parameters, - headers=_header_parameters, - **kwargs - ) + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="POST", url=_url, params=_params, headers=_headers, **kwargs) def build_providers_register_request( - resource_provider_namespace: str, - subscription_id: str, - **kwargs: Any + resource_provider_namespace: str, subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2019-10-01") # type: 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", "2019-10-01")) # type: str + accept = _headers.pop("Accept", "application/json") - accept = "application/json" # Construct URL _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/providers/{resourceProviderNamespace}/register") path_format_arguments = { - "resourceProviderNamespace": _SERIALIZER.url("resource_provider_namespace", resource_provider_namespace, 'str'), - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), + "resourceProviderNamespace": _SERIALIZER.url("resource_provider_namespace", resource_provider_namespace, "str"), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), } _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') - - return HttpRequest( - method="POST", - url=_url, - params=_query_parameters, - headers=_header_parameters, - **kwargs - ) + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="POST", url=_url, params=_params, headers=_headers, **kwargs) def build_providers_list_request( - subscription_id: str, - *, - top: Optional[int] = None, - expand: Optional[str] = None, - **kwargs: Any + subscription_id: str, *, top: Optional[int] = None, expand: Optional[str] = None, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2019-10-01") # type: 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", "2019-10-01")) # type: str + accept = _headers.pop("Accept", "application/json") - accept = "application/json" # Construct URL _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/providers") path_format_arguments = { - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), } _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] if top is not None: - _query_parameters['$top'] = _SERIALIZER.query("top", top, 'int') + _params["$top"] = _SERIALIZER.query("top", top, "int") if expand is not None: - _query_parameters['$expand'] = _SERIALIZER.query("expand", expand, 'str') - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["$expand"] = _SERIALIZER.query("expand", expand, "str") + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') - - return HttpRequest( - method="GET", - url=_url, - params=_query_parameters, - headers=_header_parameters, - **kwargs - ) + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) def build_providers_list_at_tenant_scope_request( - *, - top: Optional[int] = None, - expand: Optional[str] = None, - **kwargs: Any + *, top: Optional[int] = None, expand: Optional[str] = None, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2019-10-01") # type: 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", "2019-10-01")) # type: str + accept = _headers.pop("Accept", "application/json") - accept = "application/json" # Construct URL _url = kwargs.pop("template_url", "/providers") # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] if top is not None: - _query_parameters['$top'] = _SERIALIZER.query("top", top, 'int') + _params["$top"] = _SERIALIZER.query("top", top, "int") if expand is not None: - _query_parameters['$expand'] = _SERIALIZER.query("expand", expand, 'str') - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["$expand"] = _SERIALIZER.query("expand", expand, "str") + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') - - return HttpRequest( - method="GET", - url=_url, - params=_query_parameters, - headers=_header_parameters, - **kwargs - ) + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) def build_providers_get_request( - resource_provider_namespace: str, - subscription_id: str, - *, - expand: Optional[str] = None, - **kwargs: Any + resource_provider_namespace: str, subscription_id: str, *, expand: Optional[str] = None, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2019-10-01") # type: 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", "2019-10-01")) # type: str + accept = _headers.pop("Accept", "application/json") - accept = "application/json" # Construct URL _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/providers/{resourceProviderNamespace}") path_format_arguments = { - "resourceProviderNamespace": _SERIALIZER.url("resource_provider_namespace", resource_provider_namespace, 'str'), - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), + "resourceProviderNamespace": _SERIALIZER.url("resource_provider_namespace", resource_provider_namespace, "str"), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), } _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] if expand is not None: - _query_parameters['$expand'] = _SERIALIZER.query("expand", expand, 'str') - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["$expand"] = _SERIALIZER.query("expand", expand, "str") + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') - - return HttpRequest( - method="GET", - url=_url, - params=_query_parameters, - headers=_header_parameters, - **kwargs - ) + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) def build_providers_get_at_tenant_scope_request( - resource_provider_namespace: str, - *, - expand: Optional[str] = None, - **kwargs: Any + resource_provider_namespace: str, *, expand: Optional[str] = None, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2019-10-01") # type: 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", "2019-10-01")) # type: str + accept = _headers.pop("Accept", "application/json") - accept = "application/json" # Construct URL _url = kwargs.pop("template_url", "/providers/{resourceProviderNamespace}") path_format_arguments = { - "resourceProviderNamespace": _SERIALIZER.url("resource_provider_namespace", resource_provider_namespace, 'str'), + "resourceProviderNamespace": _SERIALIZER.url("resource_provider_namespace", resource_provider_namespace, "str"), } _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] if expand is not None: - _query_parameters['$expand'] = _SERIALIZER.query("expand", expand, 'str') - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["$expand"] = _SERIALIZER.query("expand", expand, "str") + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') - - return HttpRequest( - method="GET", - url=_url, - params=_query_parameters, - headers=_header_parameters, - **kwargs - ) + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) def build_resources_list_by_resource_group_request( @@ -1941,123 +1650,114 @@ def build_resources_list_by_resource_group_request( top: Optional[int] = None, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2019-10-01") # type: 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", "2019-10-01")) # type: str + accept = _headers.pop("Accept", "application/json") - accept = "application/json" # Construct URL _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/resources") path_format_arguments = { - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._\(\)]+$'), - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), + "resourceGroupName": _SERIALIZER.url( + "resource_group_name", resource_group_name, "str", max_length=90, min_length=1, pattern=r"^[-\w\._\(\)]+$" + ), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), } _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] if filter is not None: - _query_parameters['$filter'] = _SERIALIZER.query("filter", filter, 'str') + _params["$filter"] = _SERIALIZER.query("filter", filter, "str") if expand is not None: - _query_parameters['$expand'] = _SERIALIZER.query("expand", expand, 'str') + _params["$expand"] = _SERIALIZER.query("expand", expand, "str") if top is not None: - _query_parameters['$top'] = _SERIALIZER.query("top", top, 'int') - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["$top"] = _SERIALIZER.query("top", top, "int") + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') - - return HttpRequest( - method="GET", - url=_url, - params=_query_parameters, - headers=_header_parameters, - **kwargs - ) + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) -def build_resources_move_resources_request_initial( - source_resource_group_name: str, - subscription_id: str, - *, - json: JSONType = None, - content: Any = None, - **kwargs: Any + +def build_resources_move_resources_request( + source_resource_group_name: str, subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2019-10-01") # type: str - content_type = kwargs.pop('content_type', None) # type: Optional[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", "2019-10-01")) # type: str + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + accept = _headers.pop("Accept", "application/json") - accept = "application/json" # Construct URL - _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{sourceResourceGroupName}/moveResources") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", "/subscriptions/{subscriptionId}/resourceGroups/{sourceResourceGroupName}/moveResources" + ) # pylint: disable=line-too-long path_format_arguments = { - "sourceResourceGroupName": _SERIALIZER.url("source_resource_group_name", source_resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._\(\)]+$'), - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), + "sourceResourceGroupName": _SERIALIZER.url( + "source_resource_group_name", + source_resource_group_name, + "str", + max_length=90, + min_length=1, + pattern=r"^[-\w\._\(\)]+$", + ), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), } _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] if content_type is not None: - _header_parameters['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') - _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') - - return HttpRequest( - method="POST", - url=_url, - params=_query_parameters, - headers=_header_parameters, - json=json, - content=content, - **kwargs - ) + _headers["Content-Type"] = _SERIALIZER.header("content_type", content_type, "str") + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + return HttpRequest(method="POST", url=_url, params=_params, headers=_headers, **kwargs) -def build_resources_validate_move_resources_request_initial( - source_resource_group_name: str, - subscription_id: str, - *, - json: JSONType = None, - content: Any = None, - **kwargs: Any + +def build_resources_validate_move_resources_request( + source_resource_group_name: str, subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2019-10-01") # type: str - content_type = kwargs.pop('content_type', None) # type: Optional[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", "2019-10-01")) # type: str + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + accept = _headers.pop("Accept", "application/json") - accept = "application/json" # Construct URL - _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{sourceResourceGroupName}/validateMoveResources") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", "/subscriptions/{subscriptionId}/resourceGroups/{sourceResourceGroupName}/validateMoveResources" + ) # pylint: disable=line-too-long path_format_arguments = { - "sourceResourceGroupName": _SERIALIZER.url("source_resource_group_name", source_resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._\(\)]+$'), - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), + "sourceResourceGroupName": _SERIALIZER.url( + "source_resource_group_name", + source_resource_group_name, + "str", + max_length=90, + min_length=1, + pattern=r"^[-\w\._\(\)]+$", + ), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), } _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] if content_type is not None: - _header_parameters['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') - _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') - - return HttpRequest( - method="POST", - url=_url, - params=_query_parameters, - headers=_header_parameters, - json=json, - content=content, - **kwargs - ) + _headers["Content-Type"] = _SERIALIZER.header("content_type", content_type, "str") + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="POST", url=_url, params=_params, headers=_headers, **kwargs) def build_resources_list_request( @@ -2068,38 +1768,33 @@ def build_resources_list_request( top: Optional[int] = None, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2019-10-01") # type: 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", "2019-10-01")) # type: str + accept = _headers.pop("Accept", "application/json") - accept = "application/json" # Construct URL _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resources") path_format_arguments = { - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), } _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] if filter is not None: - _query_parameters['$filter'] = _SERIALIZER.query("filter", filter, 'str') + _params["$filter"] = _SERIALIZER.query("filter", filter, "str") if expand is not None: - _query_parameters['$expand'] = _SERIALIZER.query("expand", expand, 'str') + _params["$expand"] = _SERIALIZER.query("expand", expand, "str") if top is not None: - _query_parameters['$top'] = _SERIALIZER.query("top", top, 'int') - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["$top"] = _SERIALIZER.query("top", top, "int") + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') - - return HttpRequest( - method="GET", - url=_url, - params=_query_parameters, - headers=_header_parameters, - **kwargs - ) + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) def build_resources_check_existence_request( @@ -2113,38 +1808,39 @@ def build_resources_check_existence_request( api_version: str, **kwargs: Any ) -> HttpRequest: - accept = "application/json" + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + accept = _headers.pop("Accept", "application/json") + # Construct URL - _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{parentResourcePath}/{resourceType}/{resourceName}") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{parentResourcePath}/{resourceType}/{resourceName}", + ) # pylint: disable=line-too-long path_format_arguments = { - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._\(\)]+$'), - "resourceProviderNamespace": _SERIALIZER.url("resource_provider_namespace", resource_provider_namespace, 'str'), - "parentResourcePath": _SERIALIZER.url("parent_resource_path", parent_resource_path, 'str', skip_quote=True), - "resourceType": _SERIALIZER.url("resource_type", resource_type, 'str', skip_quote=True), - "resourceName": _SERIALIZER.url("resource_name", resource_name, 'str'), - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), + "resourceGroupName": _SERIALIZER.url( + "resource_group_name", resource_group_name, "str", max_length=90, min_length=1, pattern=r"^[-\w\._\(\)]+$" + ), + "resourceProviderNamespace": _SERIALIZER.url("resource_provider_namespace", resource_provider_namespace, "str"), + "parentResourcePath": _SERIALIZER.url("parent_resource_path", parent_resource_path, "str", skip_quote=True), + "resourceType": _SERIALIZER.url("resource_type", resource_type, "str", skip_quote=True), + "resourceName": _SERIALIZER.url("resource_name", resource_name, "str"), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), } _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') - - return HttpRequest( - method="HEAD", - url=_url, - params=_query_parameters, - headers=_header_parameters, - **kwargs - ) + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="HEAD", url=_url, params=_params, headers=_headers, **kwargs) -def build_resources_delete_request_initial( +def build_resources_delete_request( resource_group_name: str, resource_provider_namespace: str, parent_resource_path: str, @@ -2155,38 +1851,39 @@ def build_resources_delete_request_initial( api_version: str, **kwargs: Any ) -> HttpRequest: - accept = "application/json" + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + accept = _headers.pop("Accept", "application/json") + # Construct URL - _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{parentResourcePath}/{resourceType}/{resourceName}") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{parentResourcePath}/{resourceType}/{resourceName}", + ) # pylint: disable=line-too-long path_format_arguments = { - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._\(\)]+$'), - "resourceProviderNamespace": _SERIALIZER.url("resource_provider_namespace", resource_provider_namespace, 'str'), - "parentResourcePath": _SERIALIZER.url("parent_resource_path", parent_resource_path, 'str', skip_quote=True), - "resourceType": _SERIALIZER.url("resource_type", resource_type, 'str', skip_quote=True), - "resourceName": _SERIALIZER.url("resource_name", resource_name, 'str'), - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), + "resourceGroupName": _SERIALIZER.url( + "resource_group_name", resource_group_name, "str", max_length=90, min_length=1, pattern=r"^[-\w\._\(\)]+$" + ), + "resourceProviderNamespace": _SERIALIZER.url("resource_provider_namespace", resource_provider_namespace, "str"), + "parentResourcePath": _SERIALIZER.url("parent_resource_path", parent_resource_path, "str", skip_quote=True), + "resourceType": _SERIALIZER.url("resource_type", resource_type, "str", skip_quote=True), + "resourceName": _SERIALIZER.url("resource_name", resource_name, "str"), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), } _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') - - return HttpRequest( - method="DELETE", - url=_url, - params=_query_parameters, - headers=_header_parameters, - **kwargs - ) + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="DELETE", url=_url, params=_params, headers=_headers, **kwargs) -def build_resources_create_or_update_request_initial( +def build_resources_create_or_update_request( resource_group_name: str, resource_provider_namespace: str, parent_resource_path: str, @@ -2195,48 +1892,44 @@ def build_resources_create_or_update_request_initial( subscription_id: str, *, api_version: str, - json: JSONType = None, - content: Any = None, **kwargs: Any ) -> HttpRequest: - content_type = kwargs.pop('content_type', None) # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + accept = _headers.pop("Accept", "application/json") - accept = "application/json" # Construct URL - _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{parentResourcePath}/{resourceType}/{resourceName}") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{parentResourcePath}/{resourceType}/{resourceName}", + ) # pylint: disable=line-too-long path_format_arguments = { - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._\(\)]+$'), - "resourceProviderNamespace": _SERIALIZER.url("resource_provider_namespace", resource_provider_namespace, 'str'), - "parentResourcePath": _SERIALIZER.url("parent_resource_path", parent_resource_path, 'str', skip_quote=True), - "resourceType": _SERIALIZER.url("resource_type", resource_type, 'str', skip_quote=True), - "resourceName": _SERIALIZER.url("resource_name", resource_name, 'str'), - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), + "resourceGroupName": _SERIALIZER.url( + "resource_group_name", resource_group_name, "str", max_length=90, min_length=1, pattern=r"^[-\w\._\(\)]+$" + ), + "resourceProviderNamespace": _SERIALIZER.url("resource_provider_namespace", resource_provider_namespace, "str"), + "parentResourcePath": _SERIALIZER.url("parent_resource_path", parent_resource_path, "str", skip_quote=True), + "resourceType": _SERIALIZER.url("resource_type", resource_type, "str", skip_quote=True), + "resourceName": _SERIALIZER.url("resource_name", resource_name, "str"), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), } _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] if content_type is not None: - _header_parameters['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') - _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') - - return HttpRequest( - method="PUT", - url=_url, - params=_query_parameters, - headers=_header_parameters, - json=json, - content=content, - **kwargs - ) + _headers["Content-Type"] = _SERIALIZER.header("content_type", content_type, "str") + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + return HttpRequest(method="PUT", url=_url, params=_params, headers=_headers, **kwargs) -def build_resources_update_request_initial( + +def build_resources_update_request( resource_group_name: str, resource_provider_namespace: str, parent_resource_path: str, @@ -2245,45 +1938,41 @@ def build_resources_update_request_initial( subscription_id: str, *, api_version: str, - json: JSONType = None, - content: Any = None, **kwargs: Any ) -> HttpRequest: - content_type = kwargs.pop('content_type', None) # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + accept = _headers.pop("Accept", "application/json") - accept = "application/json" # Construct URL - _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{parentResourcePath}/{resourceType}/{resourceName}") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{parentResourcePath}/{resourceType}/{resourceName}", + ) # pylint: disable=line-too-long path_format_arguments = { - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._\(\)]+$'), - "resourceProviderNamespace": _SERIALIZER.url("resource_provider_namespace", resource_provider_namespace, 'str'), - "parentResourcePath": _SERIALIZER.url("parent_resource_path", parent_resource_path, 'str', skip_quote=True), - "resourceType": _SERIALIZER.url("resource_type", resource_type, 'str', skip_quote=True), - "resourceName": _SERIALIZER.url("resource_name", resource_name, 'str'), - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), + "resourceGroupName": _SERIALIZER.url( + "resource_group_name", resource_group_name, "str", max_length=90, min_length=1, pattern=r"^[-\w\._\(\)]+$" + ), + "resourceProviderNamespace": _SERIALIZER.url("resource_provider_namespace", resource_provider_namespace, "str"), + "parentResourcePath": _SERIALIZER.url("parent_resource_path", parent_resource_path, "str", skip_quote=True), + "resourceType": _SERIALIZER.url("resource_type", resource_type, "str", skip_quote=True), + "resourceName": _SERIALIZER.url("resource_name", resource_name, "str"), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), } _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] if content_type is not None: - _header_parameters['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') - _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') - - return HttpRequest( - method="PATCH", - url=_url, - params=_query_parameters, - headers=_header_parameters, - json=json, - content=content, - **kwargs - ) + _headers["Content-Type"] = _SERIALIZER.header("content_type", content_type, "str") + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="PATCH", url=_url, params=_params, headers=_headers, **kwargs) def build_resources_get_request( @@ -2297,1224 +1986,992 @@ def build_resources_get_request( api_version: str, **kwargs: Any ) -> HttpRequest: - accept = "application/json" + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + accept = _headers.pop("Accept", "application/json") + # Construct URL - _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{parentResourcePath}/{resourceType}/{resourceName}") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{parentResourcePath}/{resourceType}/{resourceName}", + ) # pylint: disable=line-too-long path_format_arguments = { - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._\(\)]+$'), - "resourceProviderNamespace": _SERIALIZER.url("resource_provider_namespace", resource_provider_namespace, 'str'), - "parentResourcePath": _SERIALIZER.url("parent_resource_path", parent_resource_path, 'str', skip_quote=True), - "resourceType": _SERIALIZER.url("resource_type", resource_type, 'str', skip_quote=True), - "resourceName": _SERIALIZER.url("resource_name", resource_name, 'str'), - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), + "resourceGroupName": _SERIALIZER.url( + "resource_group_name", resource_group_name, "str", max_length=90, min_length=1, pattern=r"^[-\w\._\(\)]+$" + ), + "resourceProviderNamespace": _SERIALIZER.url("resource_provider_namespace", resource_provider_namespace, "str"), + "parentResourcePath": _SERIALIZER.url("parent_resource_path", parent_resource_path, "str", skip_quote=True), + "resourceType": _SERIALIZER.url("resource_type", resource_type, "str", skip_quote=True), + "resourceName": _SERIALIZER.url("resource_name", resource_name, "str"), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), } _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') - - return HttpRequest( - method="GET", - url=_url, - params=_query_parameters, - headers=_header_parameters, - **kwargs - ) + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) + + +def build_resources_check_existence_by_id_request(resource_id: str, *, api_version: str, **kwargs: Any) -> HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + accept = _headers.pop("Accept", "application/json") -def build_resources_check_existence_by_id_request( - resource_id: str, - *, - api_version: str, - **kwargs: Any -) -> HttpRequest: - accept = "application/json" # Construct URL _url = kwargs.pop("template_url", "/{resourceId}") path_format_arguments = { - "resourceId": _SERIALIZER.url("resource_id", resource_id, 'str', skip_quote=True), + "resourceId": _SERIALIZER.url("resource_id", resource_id, "str", skip_quote=True), } _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') - - return HttpRequest( - method="HEAD", - url=_url, - params=_query_parameters, - headers=_header_parameters, - **kwargs - ) + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + return HttpRequest(method="HEAD", url=_url, params=_params, headers=_headers, **kwargs) + + +def build_resources_delete_by_id_request(resource_id: str, *, api_version: str, **kwargs: Any) -> HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + accept = _headers.pop("Accept", "application/json") -def build_resources_delete_by_id_request_initial( - resource_id: str, - *, - api_version: str, - **kwargs: Any -) -> HttpRequest: - accept = "application/json" # Construct URL _url = kwargs.pop("template_url", "/{resourceId}") path_format_arguments = { - "resourceId": _SERIALIZER.url("resource_id", resource_id, 'str', skip_quote=True), + "resourceId": _SERIALIZER.url("resource_id", resource_id, "str", skip_quote=True), } _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') - - return HttpRequest( - method="DELETE", - url=_url, - params=_query_parameters, - headers=_header_parameters, - **kwargs - ) + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + return HttpRequest(method="DELETE", url=_url, params=_params, headers=_headers, **kwargs) -def build_resources_create_or_update_by_id_request_initial( - resource_id: str, - *, - api_version: str, - json: JSONType = None, - content: Any = None, - **kwargs: Any -) -> HttpRequest: - content_type = kwargs.pop('content_type', None) # type: Optional[str] - accept = "application/json" +def build_resources_create_or_update_by_id_request(resource_id: str, *, api_version: str, **kwargs: Any) -> HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + accept = _headers.pop("Accept", "application/json") + # Construct URL _url = kwargs.pop("template_url", "/{resourceId}") path_format_arguments = { - "resourceId": _SERIALIZER.url("resource_id", resource_id, 'str', skip_quote=True), + "resourceId": _SERIALIZER.url("resource_id", resource_id, "str", skip_quote=True), } _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] if content_type is not None: - _header_parameters['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') - _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') - - return HttpRequest( - method="PUT", - url=_url, - params=_query_parameters, - headers=_header_parameters, - json=json, - content=content, - **kwargs - ) + _headers["Content-Type"] = _SERIALIZER.header("content_type", content_type, "str") + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + return HttpRequest(method="PUT", url=_url, params=_params, headers=_headers, **kwargs) -def build_resources_update_by_id_request_initial( - resource_id: str, - *, - api_version: str, - json: JSONType = None, - content: Any = None, - **kwargs: Any -) -> HttpRequest: - content_type = kwargs.pop('content_type', None) # type: Optional[str] - accept = "application/json" +def build_resources_update_by_id_request(resource_id: str, *, api_version: str, **kwargs: Any) -> HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + accept = _headers.pop("Accept", "application/json") + # Construct URL _url = kwargs.pop("template_url", "/{resourceId}") path_format_arguments = { - "resourceId": _SERIALIZER.url("resource_id", resource_id, 'str', skip_quote=True), + "resourceId": _SERIALIZER.url("resource_id", resource_id, "str", skip_quote=True), } _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] if content_type is not None: - _header_parameters['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') - _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') - - return HttpRequest( - method="PATCH", - url=_url, - params=_query_parameters, - headers=_header_parameters, - json=json, - content=content, - **kwargs - ) + _headers["Content-Type"] = _SERIALIZER.header("content_type", content_type, "str") + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + return HttpRequest(method="PATCH", url=_url, params=_params, headers=_headers, **kwargs) + + +def build_resources_get_by_id_request(resource_id: str, *, api_version: str, **kwargs: Any) -> HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + accept = _headers.pop("Accept", "application/json") -def build_resources_get_by_id_request( - resource_id: str, - *, - api_version: str, - **kwargs: Any -) -> HttpRequest: - accept = "application/json" # Construct URL _url = kwargs.pop("template_url", "/{resourceId}") path_format_arguments = { - "resourceId": _SERIALIZER.url("resource_id", resource_id, 'str', skip_quote=True), + "resourceId": _SERIALIZER.url("resource_id", resource_id, "str", skip_quote=True), } _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') - - return HttpRequest( - method="GET", - url=_url, - params=_query_parameters, - headers=_header_parameters, - **kwargs - ) + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) def build_resource_groups_check_existence_request( - resource_group_name: str, - subscription_id: str, - **kwargs: Any + resource_group_name: str, subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2019-10-01") # type: 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", "2019-10-01")) # type: str + accept = _headers.pop("Accept", "application/json") - accept = "application/json" # Construct URL _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}") path_format_arguments = { - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._\(\)]+$'), - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), + "resourceGroupName": _SERIALIZER.url( + "resource_group_name", resource_group_name, "str", max_length=90, min_length=1, pattern=r"^[-\w\._\(\)]+$" + ), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), } _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') - - return HttpRequest( - method="HEAD", - url=_url, - params=_query_parameters, - headers=_header_parameters, - **kwargs - ) + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="HEAD", url=_url, params=_params, headers=_headers, **kwargs) def build_resource_groups_create_or_update_request( - resource_group_name: str, - subscription_id: str, - *, - json: JSONType = None, - content: Any = None, - **kwargs: Any + resource_group_name: str, subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2019-10-01") # type: str - content_type = kwargs.pop('content_type', None) # type: Optional[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", "2019-10-01")) # type: str + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + accept = _headers.pop("Accept", "application/json") - accept = "application/json" # Construct URL _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}") path_format_arguments = { - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._\(\)]+$'), - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), + "resourceGroupName": _SERIALIZER.url( + "resource_group_name", resource_group_name, "str", max_length=90, min_length=1, pattern=r"^[-\w\._\(\)]+$" + ), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), } _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] if content_type is not None: - _header_parameters['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') - _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') - - return HttpRequest( - method="PUT", - url=_url, - params=_query_parameters, - headers=_header_parameters, - json=json, - content=content, - **kwargs - ) + _headers["Content-Type"] = _SERIALIZER.header("content_type", content_type, "str") + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + return HttpRequest(method="PUT", url=_url, params=_params, headers=_headers, **kwargs) -def build_resource_groups_delete_request_initial( - resource_group_name: str, - subscription_id: str, - **kwargs: Any -) -> HttpRequest: - api_version = kwargs.pop('api_version', "2019-10-01") # type: str - accept = "application/json" +def build_resource_groups_delete_request(resource_group_name: str, subscription_id: str, **kwargs: Any) -> HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2019-10-01")) # type: str + accept = _headers.pop("Accept", "application/json") + # Construct URL _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}") path_format_arguments = { - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._\(\)]+$'), - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), + "resourceGroupName": _SERIALIZER.url( + "resource_group_name", resource_group_name, "str", max_length=90, min_length=1, pattern=r"^[-\w\._\(\)]+$" + ), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), } _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') - - return HttpRequest( - method="DELETE", - url=_url, - params=_query_parameters, - headers=_header_parameters, - **kwargs - ) + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + return HttpRequest(method="DELETE", url=_url, params=_params, headers=_headers, **kwargs) -def build_resource_groups_get_request( - resource_group_name: str, - subscription_id: str, - **kwargs: Any -) -> HttpRequest: - api_version = kwargs.pop('api_version', "2019-10-01") # type: str - accept = "application/json" +def build_resource_groups_get_request(resource_group_name: str, subscription_id: str, **kwargs: Any) -> HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2019-10-01")) # type: str + accept = _headers.pop("Accept", "application/json") + # Construct URL _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}") path_format_arguments = { - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._\(\)]+$'), - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), + "resourceGroupName": _SERIALIZER.url( + "resource_group_name", resource_group_name, "str", max_length=90, min_length=1, pattern=r"^[-\w\._\(\)]+$" + ), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), } _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') - - return HttpRequest( - method="GET", - url=_url, - params=_query_parameters, - headers=_header_parameters, - **kwargs - ) + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) -def build_resource_groups_update_request( - resource_group_name: str, - subscription_id: str, - *, - json: JSONType = None, - content: Any = None, - **kwargs: Any -) -> HttpRequest: - api_version = kwargs.pop('api_version', "2019-10-01") # type: str - content_type = kwargs.pop('content_type', None) # type: Optional[str] - accept = "application/json" +def build_resource_groups_update_request(resource_group_name: str, subscription_id: str, **kwargs: Any) -> HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2019-10-01")) # type: str + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + accept = _headers.pop("Accept", "application/json") + # Construct URL _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}") path_format_arguments = { - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._\(\)]+$'), - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), + "resourceGroupName": _SERIALIZER.url( + "resource_group_name", resource_group_name, "str", max_length=90, min_length=1, pattern=r"^[-\w\._\(\)]+$" + ), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), } _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] if content_type is not None: - _header_parameters['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') - _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') - - return HttpRequest( - method="PATCH", - url=_url, - params=_query_parameters, - headers=_header_parameters, - json=json, - content=content, - **kwargs - ) + _headers["Content-Type"] = _SERIALIZER.header("content_type", content_type, "str") + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + return HttpRequest(method="PATCH", url=_url, params=_params, headers=_headers, **kwargs) -def build_resource_groups_export_template_request_initial( - subscription_id: str, - resource_group_name: str, - *, - json: JSONType = None, - content: Any = None, - **kwargs: Any + +def build_resource_groups_export_template_request( + resource_group_name: str, subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2019-10-01") # type: str - content_type = kwargs.pop('content_type', None) # type: Optional[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", "2019-10-01")) # type: str + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + accept = _headers.pop("Accept", "application/json") - accept = "application/json" # Construct URL - _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/exportTemplate") + _url = kwargs.pop( + "template_url", "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/exportTemplate" + ) path_format_arguments = { - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url( + "resource_group_name", resource_group_name, "str", max_length=90, min_length=1 + ), } _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] if content_type is not None: - _header_parameters['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') - _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') - - return HttpRequest( - method="POST", - url=_url, - params=_query_parameters, - headers=_header_parameters, - json=json, - content=content, - **kwargs - ) + _headers["Content-Type"] = _SERIALIZER.header("content_type", content_type, "str") + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="POST", url=_url, params=_params, headers=_headers, **kwargs) def build_resource_groups_list_request( - subscription_id: str, - *, - filter: Optional[str] = None, - top: Optional[int] = None, - **kwargs: Any + subscription_id: str, *, filter: Optional[str] = None, top: Optional[int] = None, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2019-10-01") # type: 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", "2019-10-01")) # type: str + accept = _headers.pop("Accept", "application/json") - accept = "application/json" # Construct URL _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourcegroups") path_format_arguments = { - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), } _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] if filter is not None: - _query_parameters['$filter'] = _SERIALIZER.query("filter", filter, 'str') + _params["$filter"] = _SERIALIZER.query("filter", filter, "str") if top is not None: - _query_parameters['$top'] = _SERIALIZER.query("top", top, 'int') - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["$top"] = _SERIALIZER.query("top", top, "int") + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') - - return HttpRequest( - method="GET", - url=_url, - params=_query_parameters, - headers=_header_parameters, - **kwargs - ) + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) -def build_tags_delete_value_request( - tag_name: str, - tag_value: str, - subscription_id: str, - **kwargs: Any -) -> HttpRequest: - api_version = kwargs.pop('api_version', "2019-10-01") # type: str - accept = "application/json" +def build_tags_delete_value_request(tag_name: str, tag_value: str, subscription_id: str, **kwargs: Any) -> HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2019-10-01")) # type: str + accept = _headers.pop("Accept", "application/json") + # Construct URL _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/tagNames/{tagName}/tagValues/{tagValue}") path_format_arguments = { - "tagName": _SERIALIZER.url("tag_name", tag_name, 'str'), - "tagValue": _SERIALIZER.url("tag_value", tag_value, 'str'), - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), + "tagName": _SERIALIZER.url("tag_name", tag_name, "str"), + "tagValue": _SERIALIZER.url("tag_value", tag_value, "str"), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), } _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') - - return HttpRequest( - method="DELETE", - url=_url, - params=_query_parameters, - headers=_header_parameters, - **kwargs - ) + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="DELETE", url=_url, params=_params, headers=_headers, **kwargs) def build_tags_create_or_update_value_request( - tag_name: str, - tag_value: str, - subscription_id: str, - **kwargs: Any + tag_name: str, tag_value: str, subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2019-10-01") # type: 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", "2019-10-01")) # type: str + accept = _headers.pop("Accept", "application/json") - accept = "application/json" # Construct URL _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/tagNames/{tagName}/tagValues/{tagValue}") path_format_arguments = { - "tagName": _SERIALIZER.url("tag_name", tag_name, 'str'), - "tagValue": _SERIALIZER.url("tag_value", tag_value, 'str'), - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), + "tagName": _SERIALIZER.url("tag_name", tag_name, "str"), + "tagValue": _SERIALIZER.url("tag_value", tag_value, "str"), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), } _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') - - return HttpRequest( - method="PUT", - url=_url, - params=_query_parameters, - headers=_header_parameters, - **kwargs - ) + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + return HttpRequest(method="PUT", url=_url, params=_params, headers=_headers, **kwargs) -def build_tags_create_or_update_request( - tag_name: str, - subscription_id: str, - **kwargs: Any -) -> HttpRequest: - api_version = kwargs.pop('api_version', "2019-10-01") # type: str - accept = "application/json" +def build_tags_create_or_update_request(tag_name: str, subscription_id: str, **kwargs: Any) -> HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2019-10-01")) # type: str + accept = _headers.pop("Accept", "application/json") + # Construct URL _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/tagNames/{tagName}") path_format_arguments = { - "tagName": _SERIALIZER.url("tag_name", tag_name, 'str'), - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), + "tagName": _SERIALIZER.url("tag_name", tag_name, "str"), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), } _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') - - return HttpRequest( - method="PUT", - url=_url, - params=_query_parameters, - headers=_header_parameters, - **kwargs - ) + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + return HttpRequest(method="PUT", url=_url, params=_params, headers=_headers, **kwargs) -def build_tags_delete_request( - tag_name: str, - subscription_id: str, - **kwargs: Any -) -> HttpRequest: - api_version = kwargs.pop('api_version', "2019-10-01") # type: str - accept = "application/json" +def build_tags_delete_request(tag_name: str, subscription_id: str, **kwargs: Any) -> HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2019-10-01")) # type: str + accept = _headers.pop("Accept", "application/json") + # Construct URL _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/tagNames/{tagName}") path_format_arguments = { - "tagName": _SERIALIZER.url("tag_name", tag_name, 'str'), - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), + "tagName": _SERIALIZER.url("tag_name", tag_name, "str"), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), } _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') - - return HttpRequest( - method="DELETE", - url=_url, - params=_query_parameters, - headers=_header_parameters, - **kwargs - ) + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + return HttpRequest(method="DELETE", url=_url, params=_params, headers=_headers, **kwargs) -def build_tags_list_request( - subscription_id: str, - **kwargs: Any -) -> HttpRequest: - api_version = kwargs.pop('api_version', "2019-10-01") # type: str - accept = "application/json" +def build_tags_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", "2019-10-01")) # type: str + accept = _headers.pop("Accept", "application/json") + # Construct URL _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/tagNames") path_format_arguments = { - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), } _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') - - return HttpRequest( - method="GET", - url=_url, - params=_query_parameters, - headers=_header_parameters, - **kwargs - ) + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) -def build_tags_create_or_update_at_scope_request( - scope: str, - *, - json: JSONType = None, - content: Any = None, - **kwargs: Any -) -> HttpRequest: - api_version = kwargs.pop('api_version', "2019-10-01") # type: str - content_type = kwargs.pop('content_type', None) # type: Optional[str] - accept = "application/json" +def build_tags_create_or_update_at_scope_request(scope: 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", "2019-10-01")) # type: str + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + accept = _headers.pop("Accept", "application/json") + # Construct URL _url = kwargs.pop("template_url", "/{scope}/providers/Microsoft.Resources/tags/default") path_format_arguments = { - "scope": _SERIALIZER.url("scope", scope, 'str', skip_quote=True), + "scope": _SERIALIZER.url("scope", scope, "str", skip_quote=True), } _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] if content_type is not None: - _header_parameters['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') - _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') - - return HttpRequest( - method="PUT", - url=_url, - params=_query_parameters, - headers=_header_parameters, - json=json, - content=content, - **kwargs - ) + _headers["Content-Type"] = _SERIALIZER.header("content_type", content_type, "str") + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + return HttpRequest(method="PUT", url=_url, params=_params, headers=_headers, **kwargs) -def build_tags_update_at_scope_request( - scope: str, - *, - json: JSONType = None, - content: Any = None, - **kwargs: Any -) -> HttpRequest: - api_version = kwargs.pop('api_version', "2019-10-01") # type: str - content_type = kwargs.pop('content_type', None) # type: Optional[str] - accept = "application/json" +def build_tags_update_at_scope_request(scope: 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", "2019-10-01")) # type: str + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + accept = _headers.pop("Accept", "application/json") + # Construct URL _url = kwargs.pop("template_url", "/{scope}/providers/Microsoft.Resources/tags/default") path_format_arguments = { - "scope": _SERIALIZER.url("scope", scope, 'str', skip_quote=True), + "scope": _SERIALIZER.url("scope", scope, "str", skip_quote=True), } _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] if content_type is not None: - _header_parameters['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') - _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') - - return HttpRequest( - method="PATCH", - url=_url, - params=_query_parameters, - headers=_header_parameters, - json=json, - content=content, - **kwargs - ) + _headers["Content-Type"] = _SERIALIZER.header("content_type", content_type, "str") + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + return HttpRequest(method="PATCH", url=_url, params=_params, headers=_headers, **kwargs) -def build_tags_get_at_scope_request( - scope: str, - **kwargs: Any -) -> HttpRequest: - api_version = kwargs.pop('api_version', "2019-10-01") # type: str - accept = "application/json" +def build_tags_get_at_scope_request(scope: 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", "2019-10-01")) # type: str + accept = _headers.pop("Accept", "application/json") + # Construct URL _url = kwargs.pop("template_url", "/{scope}/providers/Microsoft.Resources/tags/default") path_format_arguments = { - "scope": _SERIALIZER.url("scope", scope, 'str', skip_quote=True), + "scope": _SERIALIZER.url("scope", scope, "str", skip_quote=True), } _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') - - return HttpRequest( - method="GET", - url=_url, - params=_query_parameters, - headers=_header_parameters, - **kwargs - ) + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) -def build_tags_delete_at_scope_request( - scope: str, - **kwargs: Any -) -> HttpRequest: - api_version = kwargs.pop('api_version', "2019-10-01") # type: str - accept = "application/json" +def build_tags_delete_at_scope_request(scope: 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", "2019-10-01")) # type: str + accept = _headers.pop("Accept", "application/json") + # Construct URL _url = kwargs.pop("template_url", "/{scope}/providers/Microsoft.Resources/tags/default") path_format_arguments = { - "scope": _SERIALIZER.url("scope", scope, 'str', skip_quote=True), + "scope": _SERIALIZER.url("scope", scope, "str", skip_quote=True), } _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') - - return HttpRequest( - method="DELETE", - url=_url, - params=_query_parameters, - headers=_header_parameters, - **kwargs - ) + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="DELETE", url=_url, params=_params, headers=_headers, **kwargs) def build_deployment_operations_get_at_scope_request( - scope: str, - deployment_name: str, - operation_id: str, - **kwargs: Any + scope: str, deployment_name: str, operation_id: str, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2019-10-01") # type: 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", "2019-10-01")) # type: str + accept = _headers.pop("Accept", "application/json") - accept = "application/json" # Construct URL - _url = kwargs.pop("template_url", "/{scope}/providers/Microsoft.Resources/deployments/{deploymentName}/operations/{operationId}") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", "/{scope}/providers/Microsoft.Resources/deployments/{deploymentName}/operations/{operationId}" + ) # pylint: disable=line-too-long path_format_arguments = { - "scope": _SERIALIZER.url("scope", scope, 'str', skip_quote=True), - "deploymentName": _SERIALIZER.url("deployment_name", deployment_name, 'str', max_length=64, min_length=1, pattern=r'^[-\w\._\(\)]+$'), - "operationId": _SERIALIZER.url("operation_id", operation_id, 'str'), + "scope": _SERIALIZER.url("scope", scope, "str", skip_quote=True), + "deploymentName": _SERIALIZER.url( + "deployment_name", deployment_name, "str", max_length=64, min_length=1, pattern=r"^[-\w\._\(\)]+$" + ), + "operationId": _SERIALIZER.url("operation_id", operation_id, "str"), } _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') - - return HttpRequest( - method="GET", - url=_url, - params=_query_parameters, - headers=_header_parameters, - **kwargs - ) + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) def build_deployment_operations_list_at_scope_request( - scope: str, - deployment_name: str, - *, - top: Optional[int] = None, - **kwargs: Any + scope: str, deployment_name: str, *, top: Optional[int] = None, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2019-10-01") # type: 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", "2019-10-01")) # type: str + accept = _headers.pop("Accept", "application/json") - accept = "application/json" # Construct URL _url = kwargs.pop("template_url", "/{scope}/providers/Microsoft.Resources/deployments/{deploymentName}/operations") path_format_arguments = { - "scope": _SERIALIZER.url("scope", scope, 'str', skip_quote=True), - "deploymentName": _SERIALIZER.url("deployment_name", deployment_name, 'str', max_length=64, min_length=1, pattern=r'^[-\w\._\(\)]+$'), + "scope": _SERIALIZER.url("scope", scope, "str", skip_quote=True), + "deploymentName": _SERIALIZER.url( + "deployment_name", deployment_name, "str", max_length=64, min_length=1, pattern=r"^[-\w\._\(\)]+$" + ), } _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] if top is not None: - _query_parameters['$top'] = _SERIALIZER.query("top", top, 'int') - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["$top"] = _SERIALIZER.query("top", top, "int") + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') - - return HttpRequest( - method="GET", - url=_url, - params=_query_parameters, - headers=_header_parameters, - **kwargs - ) + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) def build_deployment_operations_get_at_tenant_scope_request( - deployment_name: str, - operation_id: str, - **kwargs: Any + deployment_name: str, operation_id: str, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2019-10-01") # type: 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", "2019-10-01")) # type: str + accept = _headers.pop("Accept", "application/json") - accept = "application/json" # Construct URL - _url = kwargs.pop("template_url", "/providers/Microsoft.Resources/deployments/{deploymentName}/operations/{operationId}") + _url = kwargs.pop( + "template_url", "/providers/Microsoft.Resources/deployments/{deploymentName}/operations/{operationId}" + ) path_format_arguments = { - "deploymentName": _SERIALIZER.url("deployment_name", deployment_name, 'str', max_length=64, min_length=1, pattern=r'^[-\w\._\(\)]+$'), - "operationId": _SERIALIZER.url("operation_id", operation_id, 'str'), + "deploymentName": _SERIALIZER.url( + "deployment_name", deployment_name, "str", max_length=64, min_length=1, pattern=r"^[-\w\._\(\)]+$" + ), + "operationId": _SERIALIZER.url("operation_id", operation_id, "str"), } _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') - - return HttpRequest( - method="GET", - url=_url, - params=_query_parameters, - headers=_header_parameters, - **kwargs - ) + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) def build_deployment_operations_list_at_tenant_scope_request( - deployment_name: str, - *, - top: Optional[int] = None, - **kwargs: Any + deployment_name: str, *, top: Optional[int] = None, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2019-10-01") # type: 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", "2019-10-01")) # type: str + accept = _headers.pop("Accept", "application/json") - accept = "application/json" # Construct URL _url = kwargs.pop("template_url", "/providers/Microsoft.Resources/deployments/{deploymentName}/operations") path_format_arguments = { - "deploymentName": _SERIALIZER.url("deployment_name", deployment_name, 'str', max_length=64, min_length=1, pattern=r'^[-\w\._\(\)]+$'), + "deploymentName": _SERIALIZER.url( + "deployment_name", deployment_name, "str", max_length=64, min_length=1, pattern=r"^[-\w\._\(\)]+$" + ), } _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] if top is not None: - _query_parameters['$top'] = _SERIALIZER.query("top", top, 'int') - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["$top"] = _SERIALIZER.query("top", top, "int") + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') - - return HttpRequest( - method="GET", - url=_url, - params=_query_parameters, - headers=_header_parameters, - **kwargs - ) + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) def build_deployment_operations_get_at_management_group_scope_request( - group_id: str, - deployment_name: str, - operation_id: str, - **kwargs: Any + group_id: str, deployment_name: str, operation_id: str, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2019-10-01") # type: 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", "2019-10-01")) # type: str + accept = _headers.pop("Accept", "application/json") - accept = "application/json" # Construct URL - _url = kwargs.pop("template_url", "/providers/Microsoft.Management/managementGroups/{groupId}/providers/Microsoft.Resources/deployments/{deploymentName}/operations/{operationId}") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", + "/providers/Microsoft.Management/managementGroups/{groupId}/providers/Microsoft.Resources/deployments/{deploymentName}/operations/{operationId}", + ) # pylint: disable=line-too-long path_format_arguments = { - "groupId": _SERIALIZER.url("group_id", group_id, 'str', max_length=90, min_length=1), - "deploymentName": _SERIALIZER.url("deployment_name", deployment_name, 'str', max_length=64, min_length=1, pattern=r'^[-\w\._\(\)]+$'), - "operationId": _SERIALIZER.url("operation_id", operation_id, 'str'), + "groupId": _SERIALIZER.url("group_id", group_id, "str", max_length=90, min_length=1), + "deploymentName": _SERIALIZER.url( + "deployment_name", deployment_name, "str", max_length=64, min_length=1, pattern=r"^[-\w\._\(\)]+$" + ), + "operationId": _SERIALIZER.url("operation_id", operation_id, "str"), } _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') - - return HttpRequest( - method="GET", - url=_url, - params=_query_parameters, - headers=_header_parameters, - **kwargs - ) + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) def build_deployment_operations_list_at_management_group_scope_request( - group_id: str, - deployment_name: str, - *, - top: Optional[int] = None, - **kwargs: Any + group_id: str, deployment_name: str, *, top: Optional[int] = None, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2019-10-01") # type: 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", "2019-10-01")) # type: str + accept = _headers.pop("Accept", "application/json") - accept = "application/json" # Construct URL - _url = kwargs.pop("template_url", "/providers/Microsoft.Management/managementGroups/{groupId}/providers/Microsoft.Resources/deployments/{deploymentName}/operations") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", + "/providers/Microsoft.Management/managementGroups/{groupId}/providers/Microsoft.Resources/deployments/{deploymentName}/operations", + ) # pylint: disable=line-too-long path_format_arguments = { - "groupId": _SERIALIZER.url("group_id", group_id, 'str', max_length=90, min_length=1), - "deploymentName": _SERIALIZER.url("deployment_name", deployment_name, 'str', max_length=64, min_length=1, pattern=r'^[-\w\._\(\)]+$'), + "groupId": _SERIALIZER.url("group_id", group_id, "str", max_length=90, min_length=1), + "deploymentName": _SERIALIZER.url( + "deployment_name", deployment_name, "str", max_length=64, min_length=1, pattern=r"^[-\w\._\(\)]+$" + ), } _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] if top is not None: - _query_parameters['$top'] = _SERIALIZER.query("top", top, 'int') - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["$top"] = _SERIALIZER.query("top", top, "int") + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') - - return HttpRequest( - method="GET", - url=_url, - params=_query_parameters, - headers=_header_parameters, - **kwargs - ) + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) def build_deployment_operations_get_at_subscription_scope_request( - deployment_name: str, - operation_id: str, - subscription_id: str, - **kwargs: Any + deployment_name: str, operation_id: str, subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2019-10-01") # type: 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", "2019-10-01")) # type: str + accept = _headers.pop("Accept", "application/json") - accept = "application/json" # Construct URL - _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/providers/Microsoft.Resources/deployments/{deploymentName}/operations/{operationId}") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/providers/Microsoft.Resources/deployments/{deploymentName}/operations/{operationId}", + ) # pylint: disable=line-too-long path_format_arguments = { - "deploymentName": _SERIALIZER.url("deployment_name", deployment_name, 'str', max_length=64, min_length=1, pattern=r'^[-\w\._\(\)]+$'), - "operationId": _SERIALIZER.url("operation_id", operation_id, 'str'), - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), + "deploymentName": _SERIALIZER.url( + "deployment_name", deployment_name, "str", max_length=64, min_length=1, pattern=r"^[-\w\._\(\)]+$" + ), + "operationId": _SERIALIZER.url("operation_id", operation_id, "str"), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), } _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') - - return HttpRequest( - method="GET", - url=_url, - params=_query_parameters, - headers=_header_parameters, - **kwargs - ) + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) def build_deployment_operations_list_at_subscription_scope_request( - deployment_name: str, - subscription_id: str, - *, - top: Optional[int] = None, - **kwargs: Any + deployment_name: str, subscription_id: str, *, top: Optional[int] = None, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2019-10-01") # type: 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", "2019-10-01")) # type: str + accept = _headers.pop("Accept", "application/json") - accept = "application/json" # Construct URL - _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/providers/Microsoft.Resources/deployments/{deploymentName}/operations") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/providers/Microsoft.Resources/deployments/{deploymentName}/operations", + ) # pylint: disable=line-too-long path_format_arguments = { - "deploymentName": _SERIALIZER.url("deployment_name", deployment_name, 'str', max_length=64, min_length=1, pattern=r'^[-\w\._\(\)]+$'), - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), + "deploymentName": _SERIALIZER.url( + "deployment_name", deployment_name, "str", max_length=64, min_length=1, pattern=r"^[-\w\._\(\)]+$" + ), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), } _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] if top is not None: - _query_parameters['$top'] = _SERIALIZER.query("top", top, 'int') - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["$top"] = _SERIALIZER.query("top", top, "int") + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') - - return HttpRequest( - method="GET", - url=_url, - params=_query_parameters, - headers=_header_parameters, - **kwargs - ) + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) def build_deployment_operations_get_request( - resource_group_name: str, - deployment_name: str, - operation_id: str, - subscription_id: str, - **kwargs: Any + resource_group_name: str, deployment_name: str, operation_id: str, subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2019-10-01") # type: 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", "2019-10-01")) # type: str + accept = _headers.pop("Accept", "application/json") - accept = "application/json" # Construct URL - _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/deployments/{deploymentName}/operations/{operationId}") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/deployments/{deploymentName}/operations/{operationId}", + ) # pylint: disable=line-too-long path_format_arguments = { - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._\(\)]+$'), - "deploymentName": _SERIALIZER.url("deployment_name", deployment_name, 'str', max_length=64, min_length=1, pattern=r'^[-\w\._\(\)]+$'), - "operationId": _SERIALIZER.url("operation_id", operation_id, 'str'), - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), + "resourceGroupName": _SERIALIZER.url( + "resource_group_name", resource_group_name, "str", max_length=90, min_length=1, pattern=r"^[-\w\._\(\)]+$" + ), + "deploymentName": _SERIALIZER.url( + "deployment_name", deployment_name, "str", max_length=64, min_length=1, pattern=r"^[-\w\._\(\)]+$" + ), + "operationId": _SERIALIZER.url("operation_id", operation_id, "str"), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), } _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') - - return HttpRequest( - method="GET", - url=_url, - params=_query_parameters, - headers=_header_parameters, - **kwargs - ) + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) def build_deployment_operations_list_request( - resource_group_name: str, - deployment_name: str, - subscription_id: str, - *, - top: Optional[int] = None, - **kwargs: Any + resource_group_name: str, deployment_name: str, subscription_id: str, *, top: Optional[int] = None, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2019-10-01") # type: 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", "2019-10-01")) # type: str + accept = _headers.pop("Accept", "application/json") - accept = "application/json" # Construct URL - _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/deployments/{deploymentName}/operations") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/deployments/{deploymentName}/operations", + ) # pylint: disable=line-too-long path_format_arguments = { - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._\(\)]+$'), - "deploymentName": _SERIALIZER.url("deployment_name", deployment_name, 'str', max_length=64, min_length=1, pattern=r'^[-\w\._\(\)]+$'), - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), + "resourceGroupName": _SERIALIZER.url( + "resource_group_name", resource_group_name, "str", max_length=90, min_length=1, pattern=r"^[-\w\._\(\)]+$" + ), + "deploymentName": _SERIALIZER.url( + "deployment_name", deployment_name, "str", max_length=64, min_length=1, pattern=r"^[-\w\._\(\)]+$" + ), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), } _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] if top is not None: - _query_parameters['$top'] = _SERIALIZER.query("top", top, 'int') - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["$top"] = _SERIALIZER.query("top", top, "int") + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') - - return HttpRequest( - method="GET", - url=_url, - params=_query_parameters, - headers=_header_parameters, - **kwargs - ) + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") -class Operations(object): - """Operations operations. + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) - You should not instantiate this class directly. Instead, you should create a Client instance that - instantiates it for you and attaches it as an attribute. - :ivar models: Alias to model classes used in this operation group. - :type models: ~azure.mgmt.resource.resources.v2019_10_01.models - :param client: Client for service requests. - :param config: Configuration of service client. - :param serializer: An object model serializer. - :param deserializer: An object model deserializer. +class Operations: + """ + .. warning:: + **DO NOT** instantiate this class directly. + + Instead, you should access the following operations through + :class:`~azure.mgmt.resource.resources.v2019_10_01.ResourceManagementClient`'s + :attr:`operations` attribute. """ models = _models - def __init__(self, client, config, serializer, deserializer): - self._client = client - self._serialize = serializer - self._deserialize = deserializer - self._config = config + def __init__(self, *args, **kwargs): + input_args = list(args) + self._client = input_args.pop(0) if input_args else kwargs.pop("client") + self._config = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") @distributed_trace - def list( - self, - **kwargs: Any - ) -> Iterable["_models.OperationListResult"]: + def list(self, **kwargs: Any) -> Iterable["_models.Operation"]: """Lists all of the available Microsoft.Resources REST API operations. :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either OperationListResult or the result of cls(response) + :return: An iterator like instance of either Operation or the result of cls(response) :rtype: - ~azure.core.paging.ItemPaged[~azure.mgmt.resource.resources.v2019_10_01.models.OperationListResult] - :raises: ~azure.core.exceptions.HttpResponseError + ~azure.core.paging.ItemPaged[~azure.mgmt.resource.resources.v2019_10_01.models.Operation] + :raises ~azure.core.exceptions.HttpResponseError: """ - api_version = kwargs.pop('api_version', "2019-10-01") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2019-10-01")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[_models.OperationListResult] - cls = kwargs.pop('cls', None) # type: ClsType["_models.OperationListResult"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) + def prepare_request(next_link=None): if not next_link: - + request = build_operations_list_request( api_version=api_version, - template_url=self.list.metadata['url'], + template_url=self.list.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore else: - - request = build_operations_list_request( - template_url=next_link, - ) + # make call to next link with the client's api-version + _parsed_next_link = urlparse(next_link) + _next_request_params = case_insensitive_dict(parse_qs(_parsed_next_link.query)) + _next_request_params["api-version"] = self._config.api_version + request = HttpRequest("GET", urljoin(next_link, _parsed_next_link.path), params=_next_request_params) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore request.method = "GET" return request @@ -3528,10 +2985,8 @@ def extract_data(pipeline_response): def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) response = pipeline_response.http_response @@ -3541,62 +2996,62 @@ def get_next(next_link=None): return pipeline_response + return ItemPaged(get_next, extract_data) - return ItemPaged( - get_next, extract_data - ) - list.metadata = {'url': "/providers/Microsoft.Resources/operations"} # type: ignore -class DeploymentsOperations(object): # pylint: disable=too-many-public-methods - """DeploymentsOperations operations. + list.metadata = {"url": "/providers/Microsoft.Resources/operations"} # type: ignore - You should not instantiate this class directly. Instead, you should create a Client instance that - instantiates it for you and attaches it as an attribute. - :ivar models: Alias to model classes used in this operation group. - :type models: ~azure.mgmt.resource.resources.v2019_10_01.models - :param client: Client for service requests. - :param config: Configuration of service client. - :param serializer: An object model serializer. - :param deserializer: An object model deserializer. +class DeploymentsOperations: # pylint: disable=too-many-public-methods + """ + .. warning:: + **DO NOT** instantiate this class directly. + + Instead, you should access the following operations through + :class:`~azure.mgmt.resource.resources.v2019_10_01.ResourceManagementClient`'s + :attr:`deployments` attribute. """ models = _models - def __init__(self, client, config, serializer, deserializer): - self._client = client - self._serialize = serializer - self._deserialize = deserializer - self._config = config + def __init__(self, *args, **kwargs): + input_args = list(args) + self._client = input_args.pop(0) if input_args else kwargs.pop("client") + self._config = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") def _delete_at_scope_initial( # pylint: disable=inconsistent-return-statements - self, - scope: str, - deployment_name: str, - **kwargs: Any + self, scope: str, deployment_name: str, **kwargs: Any ) -> None: - cls = kwargs.pop('cls', None) # type: ClsType[None] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) - api_version = kwargs.pop('api_version', "2019-10-01") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - request = build_deployments_delete_at_scope_request_initial( + api_version = kwargs.pop("api_version", _params.pop("api-version", "2019-10-01")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[None] + + request = build_deployments_delete_at_scope_request( scope=scope, deployment_name=deployment_name, api_version=api_version, - template_url=self._delete_at_scope_initial.metadata['url'], + template_url=self._delete_at_scope_initial.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [202, 204]: @@ -3606,16 +3061,10 @@ def _delete_at_scope_initial( # pylint: disable=inconsistent-return-statements if cls: return cls(pipeline_response, None, {}) - _delete_at_scope_initial.metadata = {'url': "/{scope}/providers/Microsoft.Resources/deployments/{deploymentName}"} # type: ignore - + _delete_at_scope_initial.metadata = {"url": "/{scope}/providers/Microsoft.Resources/deployments/{deploymentName}"} # type: ignore @distributed_trace - def begin_delete_at_scope( # pylint: disable=inconsistent-return-statements - self, - scope: str, - deployment_name: str, - **kwargs: Any - ) -> LROPoller[None]: + def begin_delete_at_scope(self, scope: str, deployment_name: str, **kwargs: Any) -> LROPoller[None]: """Deletes a deployment from the deployment history. A template deployment that is currently running cannot be deleted. Deleting a template @@ -3626,9 +3075,9 @@ def begin_delete_at_scope( # pylint: disable=inconsistent-return-statements process finishes, the URI in the Location header returns a status of 204 on success. If the asynchronous request failed, the URI in the Location header returns an error-level status code. - :param scope: The resource scope. + :param scope: The resource scope. Required. :type scope: str - :param deployment_name: The name of the deployment. + :param deployment_name: The name of the deployment. Required. :type deployment_name: str :keyword callable cls: A custom type or function that will be passed the direct response :keyword str continuation_token: A continuation token to restart a poller from a saved state. @@ -3640,86 +3089,91 @@ def begin_delete_at_scope( # pylint: disable=inconsistent-return-statements Retry-After header is present. :return: An instance of LROPoller that returns either None or the result of cls(response) :rtype: ~azure.core.polling.LROPoller[None] - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - api_version = kwargs.pop('api_version', "2019-10-01") # type: str - polling = kwargs.pop('polling', True) # type: Union[bool, PollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType[None] - lro_delay = kwargs.pop( - 'polling_interval', - self._config.polling_interval - ) - cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2019-10-01")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[None] + polling = kwargs.pop("polling", True) # type: Union[bool, PollingMethod] + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token = kwargs.pop("continuation_token", None) # type: Optional[str] if cont_token is None: - raw_result = self._delete_at_scope_initial( + raw_result = self._delete_at_scope_initial( # type: ignore scope=scope, deployment_name=deployment_name, api_version=api_version, - cls=lambda x,y,z: x, + cls=lambda x, y, z: x, + headers=_headers, + params=_params, **kwargs ) - kwargs.pop('error_map', None) + kwargs.pop("error_map", None) - def get_long_running_output(pipeline_response): + def get_long_running_output(pipeline_response): # pylint: disable=inconsistent-return-statements if cls: return cls(pipeline_response, None, {}) - - if polling is True: polling_method = ARMPolling(lro_delay, **kwargs) - elif polling is False: polling_method = NoPolling() - else: polling_method = polling + if polling is True: + polling_method = cast(PollingMethod, ARMPolling(lro_delay, **kwargs)) # type: PollingMethod + elif polling is False: + polling_method = cast(PollingMethod, NoPolling()) + else: + polling_method = polling if cont_token: return LROPoller.from_continuation_token( polling_method=polling_method, continuation_token=cont_token, client=self._client, - deserialization_callback=get_long_running_output + deserialization_callback=get_long_running_output, ) return LROPoller(self._client, raw_result, get_long_running_output, polling_method) - begin_delete_at_scope.metadata = {'url': "/{scope}/providers/Microsoft.Resources/deployments/{deploymentName}"} # type: ignore + begin_delete_at_scope.metadata = {"url": "/{scope}/providers/Microsoft.Resources/deployments/{deploymentName}"} # type: ignore @distributed_trace - def check_existence_at_scope( - self, - scope: str, - deployment_name: str, - **kwargs: Any - ) -> bool: + def check_existence_at_scope(self, scope: str, deployment_name: str, **kwargs: Any) -> bool: """Checks whether the deployment exists. - :param scope: The resource scope. + :param scope: The resource scope. Required. :type scope: str - :param deployment_name: The name of the deployment. + :param deployment_name: The name of the deployment. Required. :type deployment_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: bool, or the result of cls(response) + :return: bool or the result of cls(response) :rtype: bool - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType[None] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) - api_version = kwargs.pop('api_version', "2019-10-01") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2019-10-01")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[None] - request = build_deployments_check_existence_at_scope_request( scope=scope, deployment_name=deployment_name, api_version=api_version, - template_url=self.check_existence_at_scope.metadata['url'], + template_url=self.check_existence_at_scope.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [204, 404]: @@ -3730,43 +3184,52 @@ def check_existence_at_scope( return cls(pipeline_response, None, {}) return 200 <= response.status_code <= 299 - check_existence_at_scope.metadata = {'url': "/{scope}/providers/Microsoft.Resources/deployments/{deploymentName}"} # type: ignore - + check_existence_at_scope.metadata = {"url": "/{scope}/providers/Microsoft.Resources/deployments/{deploymentName}"} # type: ignore def _create_or_update_at_scope_initial( - self, - scope: str, - deployment_name: str, - parameters: "_models.Deployment", - **kwargs: Any - ) -> "_models.DeploymentExtended": - cls = kwargs.pop('cls', None) # type: ClsType["_models.DeploymentExtended"] + self, scope: str, deployment_name: str, parameters: Union[_models.Deployment, IO], **kwargs: Any + ) -> _models.DeploymentExtended: error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', "2019-10-01") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + api_version = kwargs.pop("api_version", _params.pop("api-version", "2019-10-01")) # type: str + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.DeploymentExtended] - _json = self._serialize.body(parameters, 'Deployment') + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(parameters, (IO, bytes)): + _content = parameters + else: + _json = self._serialize.body(parameters, "Deployment") - request = build_deployments_create_or_update_at_scope_request_initial( + request = build_deployments_create_or_update_at_scope_request( scope=scope, deployment_name=deployment_name, api_version=api_version, content_type=content_type, json=_json, - template_url=self._create_or_update_at_scope_initial.metadata['url'], + content=_content, + template_url=self._create_or_update_at_scope_initial.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200, 201]: @@ -3774,37 +3237,41 @@ def _create_or_update_at_scope_initial( raise HttpResponseError(response=response, error_format=ARMErrorFormat) if response.status_code == 200: - deserialized = self._deserialize('DeploymentExtended', pipeline_response) + deserialized = self._deserialize("DeploymentExtended", pipeline_response) if response.status_code == 201: - deserialized = self._deserialize('DeploymentExtended', pipeline_response) + deserialized = self._deserialize("DeploymentExtended", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - _create_or_update_at_scope_initial.metadata = {'url': "/{scope}/providers/Microsoft.Resources/deployments/{deploymentName}"} # type: ignore - + _create_or_update_at_scope_initial.metadata = {"url": "/{scope}/providers/Microsoft.Resources/deployments/{deploymentName}"} # type: ignore - @distributed_trace + @overload def begin_create_or_update_at_scope( self, scope: str, deployment_name: str, - parameters: "_models.Deployment", + parameters: _models.Deployment, + *, + content_type: str = "application/json", **kwargs: Any - ) -> LROPoller["_models.DeploymentExtended"]: + ) -> LROPoller[_models.DeploymentExtended]: """Deploys resources at a given scope. You can provide the template and parameters directly in the request or link to JSON files. - :param scope: The resource scope. + :param scope: The resource scope. Required. :type scope: str - :param deployment_name: The name of the deployment. + :param deployment_name: The name of the deployment. Required. :type deployment_name: str - :param parameters: Additional parameters supplied to the operation. + :param parameters: Additional parameters supplied to the operation. Required. :type parameters: ~azure.mgmt.resource.resources.v2019_10_01.models.Deployment + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str :keyword callable cls: A custom type or function that will be passed the direct response :keyword str continuation_token: A continuation token to restart a poller from a saved state. :keyword polling: By default, your polling method will be ARMPolling. Pass in False for this @@ -3817,114 +3284,179 @@ def begin_create_or_update_at_scope( cls(response) :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.resource.resources.v2019_10_01.models.DeploymentExtended] - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - api_version = kwargs.pop('api_version', "2019-10-01") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] - polling = kwargs.pop('polling', True) # type: Union[bool, PollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType["_models.DeploymentExtended"] - lro_delay = kwargs.pop( - 'polling_interval', - self._config.polling_interval - ) - cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] + + @overload + def begin_create_or_update_at_scope( + self, scope: str, deployment_name: str, parameters: IO, *, content_type: str = "application/json", **kwargs: Any + ) -> LROPoller[_models.DeploymentExtended]: + """Deploys resources at a given scope. + + You can provide the template and parameters directly in the request or link to JSON files. + + :param scope: The resource scope. Required. + :type scope: str + :param deployment_name: The name of the deployment. Required. + :type deployment_name: str + :param parameters: Additional parameters supplied to the operation. Required. + :type parameters: IO + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be ARMPolling. Pass in False for this + operation to not poll, or pass in your own initialized polling object for a personal polling + strategy. + :paramtype polling: bool or ~azure.core.polling.PollingMethod + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of LROPoller that returns either DeploymentExtended or the result of + cls(response) + :rtype: + ~azure.core.polling.LROPoller[~azure.mgmt.resource.resources.v2019_10_01.models.DeploymentExtended] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace + def begin_create_or_update_at_scope( + self, scope: str, deployment_name: str, parameters: Union[_models.Deployment, IO], **kwargs: Any + ) -> LROPoller[_models.DeploymentExtended]: + """Deploys resources at a given scope. + + You can provide the template and parameters directly in the request or link to JSON files. + + :param scope: The resource scope. Required. + :type scope: str + :param deployment_name: The name of the deployment. Required. + :type deployment_name: str + :param parameters: Additional parameters supplied to the operation. Is either a model type or a + IO type. Required. + :type parameters: ~azure.mgmt.resource.resources.v2019_10_01.models.Deployment or IO + :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. + Default value is None. + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be ARMPolling. Pass in False for this + operation to not poll, or pass in your own initialized polling object for a personal polling + strategy. + :paramtype polling: bool or ~azure.core.polling.PollingMethod + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of LROPoller that returns either DeploymentExtended or the result of + cls(response) + :rtype: + ~azure.core.polling.LROPoller[~azure.mgmt.resource.resources.v2019_10_01.models.DeploymentExtended] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _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", "2019-10-01")) # type: str + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.DeploymentExtended] + polling = kwargs.pop("polling", True) # type: Union[bool, PollingMethod] + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token = kwargs.pop("continuation_token", None) # type: Optional[str] if cont_token is None: - raw_result = self._create_or_update_at_scope_initial( + raw_result = self._create_or_update_at_scope_initial( # type: ignore scope=scope, deployment_name=deployment_name, parameters=parameters, api_version=api_version, content_type=content_type, - cls=lambda x,y,z: x, + cls=lambda x, y, z: x, + headers=_headers, + params=_params, **kwargs ) - kwargs.pop('error_map', None) + kwargs.pop("error_map", None) def get_long_running_output(pipeline_response): - response = pipeline_response.http_response - deserialized = self._deserialize('DeploymentExtended', pipeline_response) + deserialized = self._deserialize("DeploymentExtended", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - - if polling is True: polling_method = ARMPolling(lro_delay, **kwargs) - elif polling is False: polling_method = NoPolling() - else: polling_method = polling + if polling is True: + polling_method = cast(PollingMethod, ARMPolling(lro_delay, **kwargs)) # type: PollingMethod + elif polling is False: + polling_method = cast(PollingMethod, NoPolling()) + else: + polling_method = polling if cont_token: return LROPoller.from_continuation_token( polling_method=polling_method, continuation_token=cont_token, client=self._client, - deserialization_callback=get_long_running_output + deserialization_callback=get_long_running_output, ) return LROPoller(self._client, raw_result, get_long_running_output, polling_method) - begin_create_or_update_at_scope.metadata = {'url': "/{scope}/providers/Microsoft.Resources/deployments/{deploymentName}"} # type: ignore + begin_create_or_update_at_scope.metadata = {"url": "/{scope}/providers/Microsoft.Resources/deployments/{deploymentName}"} # type: ignore @distributed_trace - def get_at_scope( - self, - scope: str, - deployment_name: str, - **kwargs: Any - ) -> "_models.DeploymentExtended": + def get_at_scope(self, scope: str, deployment_name: str, **kwargs: Any) -> _models.DeploymentExtended: """Gets a deployment. - :param scope: The resource scope. + :param scope: The resource scope. Required. :type scope: str - :param deployment_name: The name of the deployment. + :param deployment_name: The name of the deployment. Required. :type deployment_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: DeploymentExtended, or the result of cls(response) + :return: DeploymentExtended or the result of cls(response) :rtype: ~azure.mgmt.resource.resources.v2019_10_01.models.DeploymentExtended - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.DeploymentExtended"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + 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', "2019-10-01") # type: str + api_version = kwargs.pop("api_version", _params.pop("api-version", "2019-10-01")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[_models.DeploymentExtended] - request = build_deployments_get_at_scope_request( scope=scope, deployment_name=deployment_name, api_version=api_version, - template_url=self.get_at_scope.metadata['url'], + template_url=self.get_at_scope.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) - deserialized = self._deserialize('DeploymentExtended', pipeline_response) + deserialized = self._deserialize("DeploymentExtended", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - get_at_scope.metadata = {'url': "/{scope}/providers/Microsoft.Resources/deployments/{deploymentName}"} # type: ignore - + get_at_scope.metadata = {"url": "/{scope}/providers/Microsoft.Resources/deployments/{deploymentName}"} # type: ignore @distributed_trace def cancel_at_scope( # pylint: disable=inconsistent-return-statements - self, - scope: str, - deployment_name: str, - **kwargs: Any + self, scope: str, deployment_name: str, **kwargs: Any ) -> None: """Cancels a currently running template deployment. @@ -3933,38 +3465,44 @@ def cancel_at_scope( # pylint: disable=inconsistent-return-statements deployment stops the currently running template deployment and leaves the resources partially deployed. - :param scope: The resource scope. + :param scope: The resource scope. Required. :type scope: str - :param deployment_name: The name of the deployment. + :param deployment_name: The name of the deployment. Required. :type deployment_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: None, or the result of cls(response) + :return: None or the result of cls(response) :rtype: None - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType[None] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) - api_version = kwargs.pop('api_version', "2019-10-01") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2019-10-01")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[None] - request = build_deployments_cancel_at_scope_request( scope=scope, deployment_name=deployment_name, api_version=api_version, - template_url=self.cancel_at_scope.metadata['url'], + template_url=self.cancel_at_scope.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [204]: @@ -3974,43 +3512,52 @@ def cancel_at_scope( # pylint: disable=inconsistent-return-statements if cls: return cls(pipeline_response, None, {}) - cancel_at_scope.metadata = {'url': "/{scope}/providers/Microsoft.Resources/deployments/{deploymentName}/cancel"} # type: ignore - + cancel_at_scope.metadata = {"url": "/{scope}/providers/Microsoft.Resources/deployments/{deploymentName}/cancel"} # type: ignore def _validate_at_scope_initial( - self, - scope: str, - deployment_name: str, - parameters: "_models.Deployment", - **kwargs: Any - ) -> Optional["_models.DeploymentValidateResult"]: - cls = kwargs.pop('cls', None) # type: ClsType[Optional["_models.DeploymentValidateResult"]] + self, scope: str, deployment_name: str, parameters: Union[_models.Deployment, IO], **kwargs: Any + ) -> Optional[_models.DeploymentValidateResult]: error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', "2019-10-01") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + api_version = kwargs.pop("api_version", _params.pop("api-version", "2019-10-01")) # type: str + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[Optional[_models.DeploymentValidateResult]] - _json = self._serialize.body(parameters, 'Deployment') + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(parameters, (IO, bytes)): + _content = parameters + else: + _json = self._serialize.body(parameters, "Deployment") - request = build_deployments_validate_at_scope_request_initial( + request = build_deployments_validate_at_scope_request( scope=scope, deployment_name=deployment_name, api_version=api_version, content_type=content_type, json=_json, - template_url=self._validate_at_scope_initial.metadata['url'], + content=_content, + template_url=self._validate_at_scope_initial.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200, 202, 400]: @@ -4019,36 +3566,40 @@ def _validate_at_scope_initial( deserialized = None if response.status_code == 200: - deserialized = self._deserialize('DeploymentValidateResult', pipeline_response) + deserialized = self._deserialize("DeploymentValidateResult", pipeline_response) if response.status_code == 400: - deserialized = self._deserialize('DeploymentValidateResult', pipeline_response) + deserialized = self._deserialize("DeploymentValidateResult", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - _validate_at_scope_initial.metadata = {'url': "/{scope}/providers/Microsoft.Resources/deployments/{deploymentName}/validate"} # type: ignore - + _validate_at_scope_initial.metadata = {"url": "/{scope}/providers/Microsoft.Resources/deployments/{deploymentName}/validate"} # type: ignore - @distributed_trace + @overload def begin_validate_at_scope( self, scope: str, deployment_name: str, - parameters: "_models.Deployment", + parameters: _models.Deployment, + *, + content_type: str = "application/json", **kwargs: Any - ) -> LROPoller["_models.DeploymentValidateResult"]: + ) -> LROPoller[_models.DeploymentValidateResult]: """Validates whether the specified template is syntactically correct and will be accepted by Azure Resource Manager.. - :param scope: The resource scope. + :param scope: The resource scope. Required. :type scope: str - :param deployment_name: The name of the deployment. + :param deployment_name: The name of the deployment. Required. :type deployment_name: str - :param parameters: Parameters to validate. + :param parameters: Parameters to validate. Required. :type parameters: ~azure.mgmt.resource.resources.v2019_10_01.models.Deployment + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str :keyword callable cls: A custom type or function that will be passed the direct response :keyword str continuation_token: A continuation token to restart a poller from a saved state. :keyword polling: By default, your polling method will be ARMPolling. Pass in False for this @@ -4061,119 +3612,182 @@ def begin_validate_at_scope( cls(response) :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.resource.resources.v2019_10_01.models.DeploymentValidateResult] - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - api_version = kwargs.pop('api_version', "2019-10-01") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] - polling = kwargs.pop('polling', True) # type: Union[bool, PollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType["_models.DeploymentValidateResult"] - lro_delay = kwargs.pop( - 'polling_interval', - self._config.polling_interval - ) - cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] + + @overload + def begin_validate_at_scope( + self, scope: str, deployment_name: str, parameters: IO, *, content_type: str = "application/json", **kwargs: Any + ) -> LROPoller[_models.DeploymentValidateResult]: + """Validates whether the specified template is syntactically correct and will be accepted by Azure + Resource Manager.. + + :param scope: The resource scope. Required. + :type scope: str + :param deployment_name: The name of the deployment. Required. + :type deployment_name: str + :param parameters: Parameters to validate. Required. + :type parameters: IO + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be ARMPolling. Pass in False for this + operation to not poll, or pass in your own initialized polling object for a personal polling + strategy. + :paramtype polling: bool or ~azure.core.polling.PollingMethod + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of LROPoller that returns either DeploymentValidateResult or the result of + cls(response) + :rtype: + ~azure.core.polling.LROPoller[~azure.mgmt.resource.resources.v2019_10_01.models.DeploymentValidateResult] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace + def begin_validate_at_scope( + self, scope: str, deployment_name: str, parameters: Union[_models.Deployment, IO], **kwargs: Any + ) -> LROPoller[_models.DeploymentValidateResult]: + """Validates whether the specified template is syntactically correct and will be accepted by Azure + Resource Manager.. + + :param scope: The resource scope. Required. + :type scope: str + :param deployment_name: The name of the deployment. Required. + :type deployment_name: str + :param parameters: Parameters to validate. Is either a model type or a IO type. Required. + :type parameters: ~azure.mgmt.resource.resources.v2019_10_01.models.Deployment or IO + :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. + Default value is None. + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be ARMPolling. Pass in False for this + operation to not poll, or pass in your own initialized polling object for a personal polling + strategy. + :paramtype polling: bool or ~azure.core.polling.PollingMethod + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of LROPoller that returns either DeploymentValidateResult or the result of + cls(response) + :rtype: + ~azure.core.polling.LROPoller[~azure.mgmt.resource.resources.v2019_10_01.models.DeploymentValidateResult] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _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", "2019-10-01")) # type: str + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.DeploymentValidateResult] + polling = kwargs.pop("polling", True) # type: Union[bool, PollingMethod] + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token = kwargs.pop("continuation_token", None) # type: Optional[str] if cont_token is None: - raw_result = self._validate_at_scope_initial( + raw_result = self._validate_at_scope_initial( # type: ignore scope=scope, deployment_name=deployment_name, parameters=parameters, api_version=api_version, content_type=content_type, - cls=lambda x,y,z: x, + cls=lambda x, y, z: x, + headers=_headers, + params=_params, **kwargs ) - kwargs.pop('error_map', None) + kwargs.pop("error_map", None) def get_long_running_output(pipeline_response): - response = pipeline_response.http_response - deserialized = self._deserialize('DeploymentValidateResult', pipeline_response) + deserialized = self._deserialize("DeploymentValidateResult", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - - if polling is True: polling_method = ARMPolling(lro_delay, **kwargs) - elif polling is False: polling_method = NoPolling() - else: polling_method = polling + if polling is True: + polling_method = cast(PollingMethod, ARMPolling(lro_delay, **kwargs)) # type: PollingMethod + elif polling is False: + polling_method = cast(PollingMethod, NoPolling()) + else: + polling_method = polling if cont_token: return LROPoller.from_continuation_token( polling_method=polling_method, continuation_token=cont_token, client=self._client, - deserialization_callback=get_long_running_output + deserialization_callback=get_long_running_output, ) return LROPoller(self._client, raw_result, get_long_running_output, polling_method) - begin_validate_at_scope.metadata = {'url': "/{scope}/providers/Microsoft.Resources/deployments/{deploymentName}/validate"} # type: ignore + begin_validate_at_scope.metadata = {"url": "/{scope}/providers/Microsoft.Resources/deployments/{deploymentName}/validate"} # type: ignore @distributed_trace def export_template_at_scope( - self, - scope: str, - deployment_name: str, - **kwargs: Any - ) -> "_models.DeploymentExportResult": + self, scope: str, deployment_name: str, **kwargs: Any + ) -> _models.DeploymentExportResult: """Exports the template used for specified deployment. - :param scope: The resource scope. + :param scope: The resource scope. Required. :type scope: str - :param deployment_name: The name of the deployment. + :param deployment_name: The name of the deployment. Required. :type deployment_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: DeploymentExportResult, or the result of cls(response) + :return: DeploymentExportResult or the result of cls(response) :rtype: ~azure.mgmt.resource.resources.v2019_10_01.models.DeploymentExportResult - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.DeploymentExportResult"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) - api_version = kwargs.pop('api_version', "2019-10-01") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2019-10-01")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[_models.DeploymentExportResult] - request = build_deployments_export_template_at_scope_request( scope=scope, deployment_name=deployment_name, api_version=api_version, - template_url=self.export_template_at_scope.metadata['url'], + template_url=self.export_template_at_scope.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) - deserialized = self._deserialize('DeploymentExportResult', pipeline_response) + deserialized = self._deserialize("DeploymentExportResult", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - export_template_at_scope.metadata = {'url': "/{scope}/providers/Microsoft.Resources/deployments/{deploymentName}/exportTemplate"} # type: ignore - + export_template_at_scope.metadata = {"url": "/{scope}/providers/Microsoft.Resources/deployments/{deploymentName}/exportTemplate"} # type: ignore @distributed_trace def list_at_scope( - self, - scope: str, - filter: Optional[str] = None, - top: Optional[int] = None, - **kwargs: Any - ) -> Iterable["_models.DeploymentListResult"]: + self, scope: str, filter: Optional[str] = None, top: Optional[int] = None, **kwargs: Any + ) -> Iterable["_models.DeploymentExtended"]: """Get all the deployments at the given scope. - :param scope: The resource scope. + :param scope: The resource scope. Required. :type scope: str :param filter: The filter to apply on the operation. For example, you can use $filter=provisioningState eq '{state}'. Default value is None. @@ -4182,40 +3796,48 @@ def list_at_scope( value is None. :type top: int :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either DeploymentListResult or the result of - cls(response) + :return: An iterator like instance of either DeploymentExtended or the result of cls(response) :rtype: - ~azure.core.paging.ItemPaged[~azure.mgmt.resource.resources.v2019_10_01.models.DeploymentListResult] - :raises: ~azure.core.exceptions.HttpResponseError + ~azure.core.paging.ItemPaged[~azure.mgmt.resource.resources.v2019_10_01.models.DeploymentExtended] + :raises ~azure.core.exceptions.HttpResponseError: """ - api_version = kwargs.pop('api_version', "2019-10-01") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2019-10-01")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[_models.DeploymentListResult] - cls = kwargs.pop('cls', None) # type: ClsType["_models.DeploymentListResult"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) + def prepare_request(next_link=None): if not next_link: - + request = build_deployments_list_at_scope_request( scope=scope, - api_version=api_version, filter=filter, top=top, - template_url=self.list_at_scope.metadata['url'], + api_version=api_version, + template_url=self.list_at_scope.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore else: - - request = build_deployments_list_at_scope_request( - scope=scope, - template_url=next_link, - ) + # make call to next link with the client's api-version + _parsed_next_link = urlparse(next_link) + _next_request_params = case_insensitive_dict(parse_qs(_parsed_next_link.query)) + _next_request_params["api-version"] = self._config.api_version + request = HttpRequest("GET", urljoin(next_link, _parsed_next_link.path), params=_next_request_params) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore request.method = "GET" return request @@ -4229,10 +3851,8 @@ def extract_data(pipeline_response): def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) response = pipeline_response.http_response @@ -4242,39 +3862,41 @@ def get_next(next_link=None): return pipeline_response + return ItemPaged(get_next, extract_data) - return ItemPaged( - get_next, extract_data - ) - list_at_scope.metadata = {'url': "/{scope}/providers/Microsoft.Resources/deployments/"} # type: ignore + list_at_scope.metadata = {"url": "/{scope}/providers/Microsoft.Resources/deployments/"} # type: ignore def _delete_at_tenant_scope_initial( # pylint: disable=inconsistent-return-statements - self, - deployment_name: str, - **kwargs: Any + self, deployment_name: str, **kwargs: Any ) -> None: - cls = kwargs.pop('cls', None) # type: ClsType[None] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) - api_version = kwargs.pop('api_version', "2019-10-01") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - request = build_deployments_delete_at_tenant_scope_request_initial( + api_version = kwargs.pop("api_version", _params.pop("api-version", "2019-10-01")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[None] + + request = build_deployments_delete_at_tenant_scope_request( deployment_name=deployment_name, api_version=api_version, - template_url=self._delete_at_tenant_scope_initial.metadata['url'], + template_url=self._delete_at_tenant_scope_initial.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [202, 204]: @@ -4284,15 +3906,10 @@ def _delete_at_tenant_scope_initial( # pylint: disable=inconsistent-return-stat if cls: return cls(pipeline_response, None, {}) - _delete_at_tenant_scope_initial.metadata = {'url': "/providers/Microsoft.Resources/deployments/{deploymentName}"} # type: ignore - + _delete_at_tenant_scope_initial.metadata = {"url": "/providers/Microsoft.Resources/deployments/{deploymentName}"} # type: ignore @distributed_trace - def begin_delete_at_tenant_scope( # pylint: disable=inconsistent-return-statements - self, - deployment_name: str, - **kwargs: Any - ) -> LROPoller[None]: + def begin_delete_at_tenant_scope(self, deployment_name: str, **kwargs: Any) -> LROPoller[None]: """Deletes a deployment from the deployment history. A template deployment that is currently running cannot be deleted. Deleting a template @@ -4303,7 +3920,7 @@ def begin_delete_at_tenant_scope( # pylint: disable=inconsistent-return-stateme process finishes, the URI in the Location header returns a status of 204 on success. If the asynchronous request failed, the URI in the Location header returns an error-level status code. - :param deployment_name: The name of the deployment. + :param deployment_name: The name of the deployment. Required. :type deployment_name: str :keyword callable cls: A custom type or function that will be passed the direct response :keyword str continuation_token: A continuation token to restart a poller from a saved state. @@ -4315,81 +3932,87 @@ def begin_delete_at_tenant_scope( # pylint: disable=inconsistent-return-stateme Retry-After header is present. :return: An instance of LROPoller that returns either None or the result of cls(response) :rtype: ~azure.core.polling.LROPoller[None] - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - api_version = kwargs.pop('api_version', "2019-10-01") # type: str - polling = kwargs.pop('polling', True) # type: Union[bool, PollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType[None] - lro_delay = kwargs.pop( - 'polling_interval', - self._config.polling_interval - ) - cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2019-10-01")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[None] + polling = kwargs.pop("polling", True) # type: Union[bool, PollingMethod] + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token = kwargs.pop("continuation_token", None) # type: Optional[str] if cont_token is None: - raw_result = self._delete_at_tenant_scope_initial( + raw_result = self._delete_at_tenant_scope_initial( # type: ignore deployment_name=deployment_name, api_version=api_version, - cls=lambda x,y,z: x, + cls=lambda x, y, z: x, + headers=_headers, + params=_params, **kwargs ) - kwargs.pop('error_map', None) + kwargs.pop("error_map", None) - def get_long_running_output(pipeline_response): + def get_long_running_output(pipeline_response): # pylint: disable=inconsistent-return-statements if cls: return cls(pipeline_response, None, {}) - - if polling is True: polling_method = ARMPolling(lro_delay, **kwargs) - elif polling is False: polling_method = NoPolling() - else: polling_method = polling + if polling is True: + polling_method = cast(PollingMethod, ARMPolling(lro_delay, **kwargs)) # type: PollingMethod + elif polling is False: + polling_method = cast(PollingMethod, NoPolling()) + else: + polling_method = polling if cont_token: return LROPoller.from_continuation_token( polling_method=polling_method, continuation_token=cont_token, client=self._client, - deserialization_callback=get_long_running_output + deserialization_callback=get_long_running_output, ) return LROPoller(self._client, raw_result, get_long_running_output, polling_method) - begin_delete_at_tenant_scope.metadata = {'url': "/providers/Microsoft.Resources/deployments/{deploymentName}"} # type: ignore + begin_delete_at_tenant_scope.metadata = {"url": "/providers/Microsoft.Resources/deployments/{deploymentName}"} # type: ignore @distributed_trace - def check_existence_at_tenant_scope( - self, - deployment_name: str, - **kwargs: Any - ) -> bool: + def check_existence_at_tenant_scope(self, deployment_name: str, **kwargs: Any) -> bool: """Checks whether the deployment exists. - :param deployment_name: The name of the deployment. + :param deployment_name: The name of the deployment. Required. :type deployment_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: bool, or the result of cls(response) + :return: bool or the result of cls(response) :rtype: bool - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType[None] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) - api_version = kwargs.pop('api_version', "2019-10-01") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2019-10-01")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[None] - request = build_deployments_check_existence_at_tenant_scope_request( deployment_name=deployment_name, api_version=api_version, - template_url=self.check_existence_at_tenant_scope.metadata['url'], + template_url=self.check_existence_at_tenant_scope.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [204, 404]: @@ -4400,41 +4023,51 @@ def check_existence_at_tenant_scope( return cls(pipeline_response, None, {}) return 200 <= response.status_code <= 299 - check_existence_at_tenant_scope.metadata = {'url': "/providers/Microsoft.Resources/deployments/{deploymentName}"} # type: ignore - + check_existence_at_tenant_scope.metadata = {"url": "/providers/Microsoft.Resources/deployments/{deploymentName}"} # type: ignore def _create_or_update_at_tenant_scope_initial( - self, - deployment_name: str, - parameters: "_models.ScopedDeployment", - **kwargs: Any - ) -> "_models.DeploymentExtended": - cls = kwargs.pop('cls', None) # type: ClsType["_models.DeploymentExtended"] + self, deployment_name: str, parameters: Union[_models.ScopedDeployment, IO], **kwargs: Any + ) -> _models.DeploymentExtended: error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) - api_version = kwargs.pop('api_version', "2019-10-01") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - _json = self._serialize.body(parameters, 'ScopedDeployment') + api_version = kwargs.pop("api_version", _params.pop("api-version", "2019-10-01")) # type: str + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.DeploymentExtended] - request = build_deployments_create_or_update_at_tenant_scope_request_initial( + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(parameters, (IO, bytes)): + _content = parameters + else: + _json = self._serialize.body(parameters, "ScopedDeployment") + + request = build_deployments_create_or_update_at_tenant_scope_request( deployment_name=deployment_name, api_version=api_version, content_type=content_type, json=_json, - template_url=self._create_or_update_at_tenant_scope_initial.metadata['url'], + content=_content, + template_url=self._create_or_update_at_tenant_scope_initial.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200, 201]: @@ -4442,34 +4075,38 @@ def _create_or_update_at_tenant_scope_initial( raise HttpResponseError(response=response, error_format=ARMErrorFormat) if response.status_code == 200: - deserialized = self._deserialize('DeploymentExtended', pipeline_response) + deserialized = self._deserialize("DeploymentExtended", pipeline_response) if response.status_code == 201: - deserialized = self._deserialize('DeploymentExtended', pipeline_response) + deserialized = self._deserialize("DeploymentExtended", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - _create_or_update_at_tenant_scope_initial.metadata = {'url': "/providers/Microsoft.Resources/deployments/{deploymentName}"} # type: ignore + _create_or_update_at_tenant_scope_initial.metadata = {"url": "/providers/Microsoft.Resources/deployments/{deploymentName}"} # type: ignore - - @distributed_trace + @overload def begin_create_or_update_at_tenant_scope( self, deployment_name: str, - parameters: "_models.ScopedDeployment", + parameters: _models.ScopedDeployment, + *, + content_type: str = "application/json", **kwargs: Any - ) -> LROPoller["_models.DeploymentExtended"]: + ) -> LROPoller[_models.DeploymentExtended]: """Deploys resources at tenant scope. You can provide the template and parameters directly in the request or link to JSON files. - :param deployment_name: The name of the deployment. + :param deployment_name: The name of the deployment. Required. :type deployment_name: str - :param parameters: Additional parameters supplied to the operation. + :param parameters: Additional parameters supplied to the operation. Required. :type parameters: ~azure.mgmt.resource.resources.v2019_10_01.models.ScopedDeployment + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str :keyword callable cls: A custom type or function that will be passed the direct response :keyword str continuation_token: A continuation token to restart a poller from a saved state. :keyword polling: By default, your polling method will be ARMPolling. Pass in False for this @@ -4482,108 +4119,171 @@ def begin_create_or_update_at_tenant_scope( cls(response) :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.resource.resources.v2019_10_01.models.DeploymentExtended] - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - api_version = kwargs.pop('api_version', "2019-10-01") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] - polling = kwargs.pop('polling', True) # type: Union[bool, PollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType["_models.DeploymentExtended"] - lro_delay = kwargs.pop( - 'polling_interval', - self._config.polling_interval - ) - cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] - if cont_token is None: - raw_result = self._create_or_update_at_tenant_scope_initial( - deployment_name=deployment_name, - parameters=parameters, - api_version=api_version, - content_type=content_type, - cls=lambda x,y,z: x, - **kwargs - ) - kwargs.pop('error_map', None) - - def get_long_running_output(pipeline_response): - response = pipeline_response.http_response - deserialized = self._deserialize('DeploymentExtended', pipeline_response) - if cls: - return cls(pipeline_response, deserialized, {}) - return deserialized + @overload + def begin_create_or_update_at_tenant_scope( + self, deployment_name: str, parameters: IO, *, content_type: str = "application/json", **kwargs: Any + ) -> LROPoller[_models.DeploymentExtended]: + """Deploys resources at tenant scope. - if polling is True: polling_method = ARMPolling(lro_delay, **kwargs) - elif polling is False: polling_method = NoPolling() - else: polling_method = polling - if cont_token: - return LROPoller.from_continuation_token( - polling_method=polling_method, - continuation_token=cont_token, - client=self._client, - deserialization_callback=get_long_running_output - ) - return LROPoller(self._client, raw_result, get_long_running_output, polling_method) - - begin_create_or_update_at_tenant_scope.metadata = {'url': "/providers/Microsoft.Resources/deployments/{deploymentName}"} # type: ignore + You can provide the template and parameters directly in the request or link to JSON files. - @distributed_trace - def get_at_tenant_scope( - self, - deployment_name: str, - **kwargs: Any - ) -> "_models.DeploymentExtended": + :param deployment_name: The name of the deployment. Required. + :type deployment_name: str + :param parameters: Additional parameters supplied to the operation. Required. + :type parameters: IO + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be ARMPolling. Pass in False for this + operation to not poll, or pass in your own initialized polling object for a personal polling + strategy. + :paramtype polling: bool or ~azure.core.polling.PollingMethod + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of LROPoller that returns either DeploymentExtended or the result of + cls(response) + :rtype: + ~azure.core.polling.LROPoller[~azure.mgmt.resource.resources.v2019_10_01.models.DeploymentExtended] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace + def begin_create_or_update_at_tenant_scope( + self, deployment_name: str, parameters: Union[_models.ScopedDeployment, IO], **kwargs: Any + ) -> LROPoller[_models.DeploymentExtended]: + """Deploys resources at tenant scope. + + You can provide the template and parameters directly in the request or link to JSON files. + + :param deployment_name: The name of the deployment. Required. + :type deployment_name: str + :param parameters: Additional parameters supplied to the operation. Is either a model type or a + IO type. Required. + :type parameters: ~azure.mgmt.resource.resources.v2019_10_01.models.ScopedDeployment or IO + :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. + Default value is None. + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be ARMPolling. Pass in False for this + operation to not poll, or pass in your own initialized polling object for a personal polling + strategy. + :paramtype polling: bool or ~azure.core.polling.PollingMethod + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of LROPoller that returns either DeploymentExtended or the result of + cls(response) + :rtype: + ~azure.core.polling.LROPoller[~azure.mgmt.resource.resources.v2019_10_01.models.DeploymentExtended] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _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", "2019-10-01")) # type: str + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.DeploymentExtended] + polling = kwargs.pop("polling", True) # type: Union[bool, PollingMethod] + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token = kwargs.pop("continuation_token", None) # type: Optional[str] + if cont_token is None: + raw_result = self._create_or_update_at_tenant_scope_initial( # type: ignore + deployment_name=deployment_name, + parameters=parameters, + api_version=api_version, + content_type=content_type, + cls=lambda x, y, z: x, + headers=_headers, + params=_params, + **kwargs + ) + kwargs.pop("error_map", None) + + def get_long_running_output(pipeline_response): + deserialized = self._deserialize("DeploymentExtended", pipeline_response) + if cls: + return cls(pipeline_response, deserialized, {}) + return deserialized + + if polling is True: + polling_method = cast(PollingMethod, ARMPolling(lro_delay, **kwargs)) # type: PollingMethod + elif polling is False: + polling_method = cast(PollingMethod, NoPolling()) + else: + polling_method = polling + if cont_token: + return LROPoller.from_continuation_token( + polling_method=polling_method, + continuation_token=cont_token, + client=self._client, + deserialization_callback=get_long_running_output, + ) + return LROPoller(self._client, raw_result, get_long_running_output, polling_method) + + begin_create_or_update_at_tenant_scope.metadata = {"url": "/providers/Microsoft.Resources/deployments/{deploymentName}"} # type: ignore + + @distributed_trace + def get_at_tenant_scope(self, deployment_name: str, **kwargs: Any) -> _models.DeploymentExtended: """Gets a deployment. - :param deployment_name: The name of the deployment. + :param deployment_name: The name of the deployment. Required. :type deployment_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: DeploymentExtended, or the result of cls(response) + :return: DeploymentExtended or the result of cls(response) :rtype: ~azure.mgmt.resource.resources.v2019_10_01.models.DeploymentExtended - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.DeploymentExtended"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + 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', "2019-10-01") # type: str + api_version = kwargs.pop("api_version", _params.pop("api-version", "2019-10-01")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[_models.DeploymentExtended] - request = build_deployments_get_at_tenant_scope_request( deployment_name=deployment_name, api_version=api_version, - template_url=self.get_at_tenant_scope.metadata['url'], + template_url=self.get_at_tenant_scope.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) - deserialized = self._deserialize('DeploymentExtended', pipeline_response) + deserialized = self._deserialize("DeploymentExtended", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - get_at_tenant_scope.metadata = {'url': "/providers/Microsoft.Resources/deployments/{deploymentName}"} # type: ignore - + get_at_tenant_scope.metadata = {"url": "/providers/Microsoft.Resources/deployments/{deploymentName}"} # type: ignore @distributed_trace def cancel_at_tenant_scope( # pylint: disable=inconsistent-return-statements - self, - deployment_name: str, - **kwargs: Any + self, deployment_name: str, **kwargs: Any ) -> None: """Cancels a currently running template deployment. @@ -4592,35 +4292,41 @@ def cancel_at_tenant_scope( # pylint: disable=inconsistent-return-statements deployment stops the currently running template deployment and leaves the resources partially deployed. - :param deployment_name: The name of the deployment. + :param deployment_name: The name of the deployment. Required. :type deployment_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: None, or the result of cls(response) + :return: None or the result of cls(response) :rtype: None - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType[None] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + 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', "2019-10-01") # type: str + api_version = kwargs.pop("api_version", _params.pop("api-version", "2019-10-01")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[None] - request = build_deployments_cancel_at_tenant_scope_request( deployment_name=deployment_name, api_version=api_version, - template_url=self.cancel_at_tenant_scope.metadata['url'], + template_url=self.cancel_at_tenant_scope.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [204]: @@ -4630,41 +4336,51 @@ def cancel_at_tenant_scope( # pylint: disable=inconsistent-return-statements if cls: return cls(pipeline_response, None, {}) - cancel_at_tenant_scope.metadata = {'url': "/providers/Microsoft.Resources/deployments/{deploymentName}/cancel"} # type: ignore - + cancel_at_tenant_scope.metadata = {"url": "/providers/Microsoft.Resources/deployments/{deploymentName}/cancel"} # type: ignore def _validate_at_tenant_scope_initial( - self, - deployment_name: str, - parameters: "_models.ScopedDeployment", - **kwargs: Any - ) -> Optional["_models.DeploymentValidateResult"]: - cls = kwargs.pop('cls', None) # type: ClsType[Optional["_models.DeploymentValidateResult"]] + self, deployment_name: str, parameters: Union[_models.ScopedDeployment, IO], **kwargs: Any + ) -> Optional[_models.DeploymentValidateResult]: error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', "2019-10-01") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + api_version = kwargs.pop("api_version", _params.pop("api-version", "2019-10-01")) # type: str + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[Optional[_models.DeploymentValidateResult]] - _json = self._serialize.body(parameters, 'ScopedDeployment') + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(parameters, (IO, bytes)): + _content = parameters + else: + _json = self._serialize.body(parameters, "ScopedDeployment") - request = build_deployments_validate_at_tenant_scope_request_initial( + request = build_deployments_validate_at_tenant_scope_request( deployment_name=deployment_name, api_version=api_version, content_type=content_type, json=_json, - template_url=self._validate_at_tenant_scope_initial.metadata['url'], + content=_content, + template_url=self._validate_at_tenant_scope_initial.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200, 202, 400]: @@ -4673,33 +4389,37 @@ def _validate_at_tenant_scope_initial( deserialized = None if response.status_code == 200: - deserialized = self._deserialize('DeploymentValidateResult', pipeline_response) + deserialized = self._deserialize("DeploymentValidateResult", pipeline_response) if response.status_code == 400: - deserialized = self._deserialize('DeploymentValidateResult', pipeline_response) + deserialized = self._deserialize("DeploymentValidateResult", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - _validate_at_tenant_scope_initial.metadata = {'url': "/providers/Microsoft.Resources/deployments/{deploymentName}/validate"} # type: ignore - + _validate_at_tenant_scope_initial.metadata = {"url": "/providers/Microsoft.Resources/deployments/{deploymentName}/validate"} # type: ignore - @distributed_trace + @overload def begin_validate_at_tenant_scope( self, deployment_name: str, - parameters: "_models.ScopedDeployment", + parameters: _models.ScopedDeployment, + *, + content_type: str = "application/json", **kwargs: Any - ) -> LROPoller["_models.DeploymentValidateResult"]: + ) -> LROPoller[_models.DeploymentValidateResult]: """Validates whether the specified template is syntactically correct and will be accepted by Azure Resource Manager.. - :param deployment_name: The name of the deployment. + :param deployment_name: The name of the deployment. Required. :type deployment_name: str - :param parameters: Parameters to validate. + :param parameters: Parameters to validate. Required. :type parameters: ~azure.mgmt.resource.resources.v2019_10_01.models.ScopedDeployment + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str :keyword callable cls: A custom type or function that will be passed the direct response :keyword str continuation_token: A continuation token to restart a poller from a saved state. :keyword polling: By default, your polling method will be ARMPolling. Pass in False for this @@ -4712,82 +4432,154 @@ def begin_validate_at_tenant_scope( cls(response) :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.resource.resources.v2019_10_01.models.DeploymentValidateResult] - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - api_version = kwargs.pop('api_version', "2019-10-01") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] - polling = kwargs.pop('polling', True) # type: Union[bool, PollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType["_models.DeploymentValidateResult"] - lro_delay = kwargs.pop( - 'polling_interval', - self._config.polling_interval - ) - cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] + + @overload + def begin_validate_at_tenant_scope( + self, deployment_name: str, parameters: IO, *, content_type: str = "application/json", **kwargs: Any + ) -> LROPoller[_models.DeploymentValidateResult]: + """Validates whether the specified template is syntactically correct and will be accepted by Azure + Resource Manager.. + + :param deployment_name: The name of the deployment. Required. + :type deployment_name: str + :param parameters: Parameters to validate. Required. + :type parameters: IO + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be ARMPolling. Pass in False for this + operation to not poll, or pass in your own initialized polling object for a personal polling + strategy. + :paramtype polling: bool or ~azure.core.polling.PollingMethod + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of LROPoller that returns either DeploymentValidateResult or the result of + cls(response) + :rtype: + ~azure.core.polling.LROPoller[~azure.mgmt.resource.resources.v2019_10_01.models.DeploymentValidateResult] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace + def begin_validate_at_tenant_scope( + self, deployment_name: str, parameters: Union[_models.ScopedDeployment, IO], **kwargs: Any + ) -> LROPoller[_models.DeploymentValidateResult]: + """Validates whether the specified template is syntactically correct and will be accepted by Azure + Resource Manager.. + + :param deployment_name: The name of the deployment. Required. + :type deployment_name: str + :param parameters: Parameters to validate. Is either a model type or a IO type. Required. + :type parameters: ~azure.mgmt.resource.resources.v2019_10_01.models.ScopedDeployment or IO + :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. + Default value is None. + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be ARMPolling. Pass in False for this + operation to not poll, or pass in your own initialized polling object for a personal polling + strategy. + :paramtype polling: bool or ~azure.core.polling.PollingMethod + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of LROPoller that returns either DeploymentValidateResult or the result of + cls(response) + :rtype: + ~azure.core.polling.LROPoller[~azure.mgmt.resource.resources.v2019_10_01.models.DeploymentValidateResult] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _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", "2019-10-01")) # type: str + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.DeploymentValidateResult] + polling = kwargs.pop("polling", True) # type: Union[bool, PollingMethod] + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token = kwargs.pop("continuation_token", None) # type: Optional[str] if cont_token is None: - raw_result = self._validate_at_tenant_scope_initial( + raw_result = self._validate_at_tenant_scope_initial( # type: ignore deployment_name=deployment_name, parameters=parameters, api_version=api_version, content_type=content_type, - cls=lambda x,y,z: x, + cls=lambda x, y, z: x, + headers=_headers, + params=_params, **kwargs ) - kwargs.pop('error_map', None) + kwargs.pop("error_map", None) def get_long_running_output(pipeline_response): - response = pipeline_response.http_response - deserialized = self._deserialize('DeploymentValidateResult', pipeline_response) + deserialized = self._deserialize("DeploymentValidateResult", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - - if polling is True: polling_method = ARMPolling(lro_delay, **kwargs) - elif polling is False: polling_method = NoPolling() - else: polling_method = polling + if polling is True: + polling_method = cast(PollingMethod, ARMPolling(lro_delay, **kwargs)) # type: PollingMethod + elif polling is False: + polling_method = cast(PollingMethod, NoPolling()) + else: + polling_method = polling if cont_token: return LROPoller.from_continuation_token( polling_method=polling_method, continuation_token=cont_token, client=self._client, - deserialization_callback=get_long_running_output + deserialization_callback=get_long_running_output, ) return LROPoller(self._client, raw_result, get_long_running_output, polling_method) - begin_validate_at_tenant_scope.metadata = {'url': "/providers/Microsoft.Resources/deployments/{deploymentName}/validate"} # type: ignore + begin_validate_at_tenant_scope.metadata = {"url": "/providers/Microsoft.Resources/deployments/{deploymentName}/validate"} # type: ignore def _what_if_at_tenant_scope_initial( - self, - deployment_name: str, - parameters: "_models.ScopedDeploymentWhatIf", - **kwargs: Any - ) -> Optional["_models.WhatIfOperationResult"]: - cls = kwargs.pop('cls', None) # type: ClsType[Optional["_models.WhatIfOperationResult"]] + self, deployment_name: str, parameters: Union[_models.ScopedDeploymentWhatIf, IO], **kwargs: Any + ) -> Optional[_models.WhatIfOperationResult]: error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', "2019-10-01") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + api_version = kwargs.pop("api_version", _params.pop("api-version", "2019-10-01")) # type: str + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[Optional[_models.WhatIfOperationResult]] - _json = self._serialize.body(parameters, 'ScopedDeploymentWhatIf') + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(parameters, (IO, bytes)): + _content = parameters + else: + _json = self._serialize.body(parameters, "ScopedDeploymentWhatIf") - request = build_deployments_what_if_at_tenant_scope_request_initial( + request = build_deployments_what_if_at_tenant_scope_request( deployment_name=deployment_name, api_version=api_version, content_type=content_type, json=_json, - template_url=self._what_if_at_tenant_scope_initial.metadata['url'], + content=_content, + template_url=self._what_if_at_tenant_scope_initial.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200, 202]: @@ -4797,35 +4589,38 @@ def _what_if_at_tenant_scope_initial( deserialized = None response_headers = {} if response.status_code == 200: - deserialized = self._deserialize('WhatIfOperationResult', pipeline_response) + deserialized = self._deserialize("WhatIfOperationResult", pipeline_response) if response.status_code == 202: - response_headers['Location']=self._deserialize('str', response.headers.get('Location')) - response_headers['Retry-After']=self._deserialize('str', response.headers.get('Retry-After')) - + response_headers["Location"] = self._deserialize("str", response.headers.get("Location")) + response_headers["Retry-After"] = self._deserialize("str", response.headers.get("Retry-After")) if cls: return cls(pipeline_response, deserialized, response_headers) return deserialized - _what_if_at_tenant_scope_initial.metadata = {'url': "/providers/Microsoft.Resources/deployments/{deploymentName}/whatIf"} # type: ignore - + _what_if_at_tenant_scope_initial.metadata = {"url": "/providers/Microsoft.Resources/deployments/{deploymentName}/whatIf"} # type: ignore - @distributed_trace + @overload def begin_what_if_at_tenant_scope( self, deployment_name: str, - parameters: "_models.ScopedDeploymentWhatIf", + parameters: _models.ScopedDeploymentWhatIf, + *, + content_type: str = "application/json", **kwargs: Any - ) -> LROPoller["_models.WhatIfOperationResult"]: + ) -> LROPoller[_models.WhatIfOperationResult]: """Returns changes that will be made by the deployment if executed at the scope of the tenant group. - :param deployment_name: The name of the deployment. + :param deployment_name: The name of the deployment. Required. :type deployment_name: str - :param parameters: Parameters to validate. + :param parameters: Parameters to validate. Required. :type parameters: ~azure.mgmt.resource.resources.v2019_10_01.models.ScopedDeploymentWhatIf + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str :keyword callable cls: A custom type or function that will be passed the direct response :keyword str continuation_token: A continuation token to restart a poller from a saved state. :keyword polling: By default, your polling method will be ARMPolling. Pass in False for this @@ -4838,110 +4633,172 @@ def begin_what_if_at_tenant_scope( cls(response) :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.resource.resources.v2019_10_01.models.WhatIfOperationResult] - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - api_version = kwargs.pop('api_version', "2019-10-01") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] - polling = kwargs.pop('polling', True) # type: Union[bool, PollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType["_models.WhatIfOperationResult"] - lro_delay = kwargs.pop( - 'polling_interval', - self._config.polling_interval - ) - cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] + + @overload + def begin_what_if_at_tenant_scope( + self, deployment_name: str, parameters: IO, *, content_type: str = "application/json", **kwargs: Any + ) -> LROPoller[_models.WhatIfOperationResult]: + """Returns changes that will be made by the deployment if executed at the scope of the tenant + group. + + :param deployment_name: The name of the deployment. Required. + :type deployment_name: str + :param parameters: Parameters to validate. Required. + :type parameters: IO + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be ARMPolling. Pass in False for this + operation to not poll, or pass in your own initialized polling object for a personal polling + strategy. + :paramtype polling: bool or ~azure.core.polling.PollingMethod + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of LROPoller that returns either WhatIfOperationResult or the result of + cls(response) + :rtype: + ~azure.core.polling.LROPoller[~azure.mgmt.resource.resources.v2019_10_01.models.WhatIfOperationResult] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace + def begin_what_if_at_tenant_scope( + self, deployment_name: str, parameters: Union[_models.ScopedDeploymentWhatIf, IO], **kwargs: Any + ) -> LROPoller[_models.WhatIfOperationResult]: + """Returns changes that will be made by the deployment if executed at the scope of the tenant + group. + + :param deployment_name: The name of the deployment. Required. + :type deployment_name: str + :param parameters: Parameters to validate. Is either a model type or a IO type. Required. + :type parameters: ~azure.mgmt.resource.resources.v2019_10_01.models.ScopedDeploymentWhatIf or + IO + :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. + Default value is None. + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be ARMPolling. Pass in False for this + operation to not poll, or pass in your own initialized polling object for a personal polling + strategy. + :paramtype polling: bool or ~azure.core.polling.PollingMethod + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of LROPoller that returns either WhatIfOperationResult or the result of + cls(response) + :rtype: + ~azure.core.polling.LROPoller[~azure.mgmt.resource.resources.v2019_10_01.models.WhatIfOperationResult] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _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", "2019-10-01")) # type: str + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.WhatIfOperationResult] + polling = kwargs.pop("polling", True) # type: Union[bool, PollingMethod] + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token = kwargs.pop("continuation_token", None) # type: Optional[str] if cont_token is None: - raw_result = self._what_if_at_tenant_scope_initial( + raw_result = self._what_if_at_tenant_scope_initial( # type: ignore deployment_name=deployment_name, parameters=parameters, api_version=api_version, content_type=content_type, - cls=lambda x,y,z: x, + cls=lambda x, y, z: x, + headers=_headers, + params=_params, **kwargs ) - kwargs.pop('error_map', None) + kwargs.pop("error_map", None) def get_long_running_output(pipeline_response): - response = pipeline_response.http_response - deserialized = self._deserialize('WhatIfOperationResult', pipeline_response) + deserialized = self._deserialize("WhatIfOperationResult", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - - if polling is True: polling_method = ARMPolling(lro_delay, lro_options={'final-state-via': 'location'}, **kwargs) - elif polling is False: polling_method = NoPolling() - else: polling_method = polling + if polling is True: + polling_method = cast( + PollingMethod, ARMPolling(lro_delay, lro_options={"final-state-via": "location"}, **kwargs) + ) # type: PollingMethod + elif polling is False: + polling_method = cast(PollingMethod, NoPolling()) + else: + polling_method = polling if cont_token: return LROPoller.from_continuation_token( polling_method=polling_method, continuation_token=cont_token, client=self._client, - deserialization_callback=get_long_running_output + deserialization_callback=get_long_running_output, ) return LROPoller(self._client, raw_result, get_long_running_output, polling_method) - begin_what_if_at_tenant_scope.metadata = {'url': "/providers/Microsoft.Resources/deployments/{deploymentName}/whatIf"} # type: ignore + begin_what_if_at_tenant_scope.metadata = {"url": "/providers/Microsoft.Resources/deployments/{deploymentName}/whatIf"} # type: ignore @distributed_trace - def export_template_at_tenant_scope( - self, - deployment_name: str, - **kwargs: Any - ) -> "_models.DeploymentExportResult": + def export_template_at_tenant_scope(self, deployment_name: str, **kwargs: Any) -> _models.DeploymentExportResult: """Exports the template used for specified deployment. - :param deployment_name: The name of the deployment. + :param deployment_name: The name of the deployment. Required. :type deployment_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: DeploymentExportResult, or the result of cls(response) + :return: DeploymentExportResult or the result of cls(response) :rtype: ~azure.mgmt.resource.resources.v2019_10_01.models.DeploymentExportResult - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.DeploymentExportResult"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + 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', "2019-10-01") # type: str + api_version = kwargs.pop("api_version", _params.pop("api-version", "2019-10-01")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[_models.DeploymentExportResult] - request = build_deployments_export_template_at_tenant_scope_request( deployment_name=deployment_name, api_version=api_version, - template_url=self.export_template_at_tenant_scope.metadata['url'], + template_url=self.export_template_at_tenant_scope.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) - deserialized = self._deserialize('DeploymentExportResult', pipeline_response) + deserialized = self._deserialize("DeploymentExportResult", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - export_template_at_tenant_scope.metadata = {'url': "/providers/Microsoft.Resources/deployments/{deploymentName}/exportTemplate"} # type: ignore - + export_template_at_tenant_scope.metadata = {"url": "/providers/Microsoft.Resources/deployments/{deploymentName}/exportTemplate"} # type: ignore @distributed_trace def list_at_tenant_scope( - self, - filter: Optional[str] = None, - top: Optional[int] = None, - **kwargs: Any - ) -> Iterable["_models.DeploymentListResult"]: + self, filter: Optional[str] = None, top: Optional[int] = None, **kwargs: Any + ) -> Iterable["_models.DeploymentExtended"]: """Get all the deployments at the tenant scope. :param filter: The filter to apply on the operation. For example, you can use @@ -4951,38 +4808,47 @@ def list_at_tenant_scope( value is None. :type top: int :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either DeploymentListResult or the result of - cls(response) + :return: An iterator like instance of either DeploymentExtended or the result of cls(response) :rtype: - ~azure.core.paging.ItemPaged[~azure.mgmt.resource.resources.v2019_10_01.models.DeploymentListResult] - :raises: ~azure.core.exceptions.HttpResponseError + ~azure.core.paging.ItemPaged[~azure.mgmt.resource.resources.v2019_10_01.models.DeploymentExtended] + :raises ~azure.core.exceptions.HttpResponseError: """ - api_version = kwargs.pop('api_version', "2019-10-01") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2019-10-01")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[_models.DeploymentListResult] - cls = kwargs.pop('cls', None) # type: ClsType["_models.DeploymentListResult"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) + def prepare_request(next_link=None): if not next_link: - + request = build_deployments_list_at_tenant_scope_request( - api_version=api_version, filter=filter, top=top, - template_url=self.list_at_tenant_scope.metadata['url'], + api_version=api_version, + template_url=self.list_at_tenant_scope.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore else: - - request = build_deployments_list_at_tenant_scope_request( - template_url=next_link, - ) + # make call to next link with the client's api-version + _parsed_next_link = urlparse(next_link) + _next_request_params = case_insensitive_dict(parse_qs(_parsed_next_link.query)) + _next_request_params["api-version"] = self._config.api_version + request = HttpRequest("GET", urljoin(next_link, _parsed_next_link.path), params=_next_request_params) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore request.method = "GET" return request @@ -4996,10 +4862,8 @@ def extract_data(pipeline_response): def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) response = pipeline_response.http_response @@ -5009,41 +4873,42 @@ def get_next(next_link=None): return pipeline_response + return ItemPaged(get_next, extract_data) - return ItemPaged( - get_next, extract_data - ) - list_at_tenant_scope.metadata = {'url': "/providers/Microsoft.Resources/deployments/"} # type: ignore + list_at_tenant_scope.metadata = {"url": "/providers/Microsoft.Resources/deployments/"} # type: ignore def _delete_at_management_group_scope_initial( # pylint: disable=inconsistent-return-statements - self, - group_id: str, - deployment_name: str, - **kwargs: Any + self, group_id: str, deployment_name: str, **kwargs: Any ) -> None: - cls = kwargs.pop('cls', None) # type: ClsType[None] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) - api_version = kwargs.pop('api_version', "2019-10-01") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - request = build_deployments_delete_at_management_group_scope_request_initial( + api_version = kwargs.pop("api_version", _params.pop("api-version", "2019-10-01")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[None] + + request = build_deployments_delete_at_management_group_scope_request( group_id=group_id, deployment_name=deployment_name, api_version=api_version, - template_url=self._delete_at_management_group_scope_initial.metadata['url'], + template_url=self._delete_at_management_group_scope_initial.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [202, 204]: @@ -5053,15 +4918,11 @@ def _delete_at_management_group_scope_initial( # pylint: disable=inconsistent-r if cls: return cls(pipeline_response, None, {}) - _delete_at_management_group_scope_initial.metadata = {'url': "/providers/Microsoft.Management/managementGroups/{groupId}/providers/Microsoft.Resources/deployments/{deploymentName}"} # type: ignore - + _delete_at_management_group_scope_initial.metadata = {"url": "/providers/Microsoft.Management/managementGroups/{groupId}/providers/Microsoft.Resources/deployments/{deploymentName}"} # type: ignore @distributed_trace - def begin_delete_at_management_group_scope( # pylint: disable=inconsistent-return-statements - self, - group_id: str, - deployment_name: str, - **kwargs: Any + def begin_delete_at_management_group_scope( + self, group_id: str, deployment_name: str, **kwargs: Any ) -> LROPoller[None]: """Deletes a deployment from the deployment history. @@ -5073,9 +4934,9 @@ def begin_delete_at_management_group_scope( # pylint: disable=inconsistent-retu process finishes, the URI in the Location header returns a status of 204 on success. If the asynchronous request failed, the URI in the Location header returns an error-level status code. - :param group_id: The management group ID. + :param group_id: The management group ID. Required. :type group_id: str - :param deployment_name: The name of the deployment. + :param deployment_name: The name of the deployment. Required. :type deployment_name: str :keyword callable cls: A custom type or function that will be passed the direct response :keyword str continuation_token: A continuation token to restart a poller from a saved state. @@ -5087,86 +4948,91 @@ def begin_delete_at_management_group_scope( # pylint: disable=inconsistent-retu Retry-After header is present. :return: An instance of LROPoller that returns either None or the result of cls(response) :rtype: ~azure.core.polling.LROPoller[None] - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - api_version = kwargs.pop('api_version', "2019-10-01") # type: str - polling = kwargs.pop('polling', True) # type: Union[bool, PollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType[None] - lro_delay = kwargs.pop( - 'polling_interval', - self._config.polling_interval - ) - cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2019-10-01")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[None] + polling = kwargs.pop("polling", True) # type: Union[bool, PollingMethod] + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token = kwargs.pop("continuation_token", None) # type: Optional[str] if cont_token is None: - raw_result = self._delete_at_management_group_scope_initial( + raw_result = self._delete_at_management_group_scope_initial( # type: ignore group_id=group_id, deployment_name=deployment_name, api_version=api_version, - cls=lambda x,y,z: x, + cls=lambda x, y, z: x, + headers=_headers, + params=_params, **kwargs ) - kwargs.pop('error_map', None) + kwargs.pop("error_map", None) - def get_long_running_output(pipeline_response): + def get_long_running_output(pipeline_response): # pylint: disable=inconsistent-return-statements if cls: return cls(pipeline_response, None, {}) - - if polling is True: polling_method = ARMPolling(lro_delay, **kwargs) - elif polling is False: polling_method = NoPolling() - else: polling_method = polling + if polling is True: + polling_method = cast(PollingMethod, ARMPolling(lro_delay, **kwargs)) # type: PollingMethod + elif polling is False: + polling_method = cast(PollingMethod, NoPolling()) + else: + polling_method = polling if cont_token: return LROPoller.from_continuation_token( polling_method=polling_method, continuation_token=cont_token, client=self._client, - deserialization_callback=get_long_running_output + deserialization_callback=get_long_running_output, ) return LROPoller(self._client, raw_result, get_long_running_output, polling_method) - begin_delete_at_management_group_scope.metadata = {'url': "/providers/Microsoft.Management/managementGroups/{groupId}/providers/Microsoft.Resources/deployments/{deploymentName}"} # type: ignore + begin_delete_at_management_group_scope.metadata = {"url": "/providers/Microsoft.Management/managementGroups/{groupId}/providers/Microsoft.Resources/deployments/{deploymentName}"} # type: ignore @distributed_trace - def check_existence_at_management_group_scope( - self, - group_id: str, - deployment_name: str, - **kwargs: Any - ) -> bool: + def check_existence_at_management_group_scope(self, group_id: str, deployment_name: str, **kwargs: Any) -> bool: """Checks whether the deployment exists. - :param group_id: The management group ID. + :param group_id: The management group ID. Required. :type group_id: str - :param deployment_name: The name of the deployment. + :param deployment_name: The name of the deployment. Required. :type deployment_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: bool, or the result of cls(response) + :return: bool or the result of cls(response) :rtype: bool - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType[None] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + 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', "2019-10-01") # type: str + api_version = kwargs.pop("api_version", _params.pop("api-version", "2019-10-01")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[None] - request = build_deployments_check_existence_at_management_group_scope_request( group_id=group_id, deployment_name=deployment_name, api_version=api_version, - template_url=self.check_existence_at_management_group_scope.metadata['url'], + template_url=self.check_existence_at_management_group_scope.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [204, 404]: @@ -5177,43 +5043,52 @@ def check_existence_at_management_group_scope( return cls(pipeline_response, None, {}) return 200 <= response.status_code <= 299 - check_existence_at_management_group_scope.metadata = {'url': "/providers/Microsoft.Management/managementGroups/{groupId}/providers/Microsoft.Resources/deployments/{deploymentName}"} # type: ignore - + check_existence_at_management_group_scope.metadata = {"url": "/providers/Microsoft.Management/managementGroups/{groupId}/providers/Microsoft.Resources/deployments/{deploymentName}"} # type: ignore def _create_or_update_at_management_group_scope_initial( - self, - group_id: str, - deployment_name: str, - parameters: "_models.ScopedDeployment", - **kwargs: Any - ) -> "_models.DeploymentExtended": - cls = kwargs.pop('cls', None) # type: ClsType["_models.DeploymentExtended"] + self, group_id: str, deployment_name: str, parameters: Union[_models.ScopedDeployment, IO], **kwargs: Any + ) -> _models.DeploymentExtended: error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) - api_version = kwargs.pop('api_version', "2019-10-01") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - _json = self._serialize.body(parameters, 'ScopedDeployment') + api_version = kwargs.pop("api_version", _params.pop("api-version", "2019-10-01")) # type: str + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.DeploymentExtended] - request = build_deployments_create_or_update_at_management_group_scope_request_initial( + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(parameters, (IO, bytes)): + _content = parameters + else: + _json = self._serialize.body(parameters, "ScopedDeployment") + + request = build_deployments_create_or_update_at_management_group_scope_request( group_id=group_id, deployment_name=deployment_name, api_version=api_version, content_type=content_type, json=_json, - template_url=self._create_or_update_at_management_group_scope_initial.metadata['url'], + content=_content, + template_url=self._create_or_update_at_management_group_scope_initial.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200, 201]: @@ -5221,37 +5096,41 @@ def _create_or_update_at_management_group_scope_initial( raise HttpResponseError(response=response, error_format=ARMErrorFormat) if response.status_code == 200: - deserialized = self._deserialize('DeploymentExtended', pipeline_response) + deserialized = self._deserialize("DeploymentExtended", pipeline_response) if response.status_code == 201: - deserialized = self._deserialize('DeploymentExtended', pipeline_response) + deserialized = self._deserialize("DeploymentExtended", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - _create_or_update_at_management_group_scope_initial.metadata = {'url': "/providers/Microsoft.Management/managementGroups/{groupId}/providers/Microsoft.Resources/deployments/{deploymentName}"} # type: ignore + _create_or_update_at_management_group_scope_initial.metadata = {"url": "/providers/Microsoft.Management/managementGroups/{groupId}/providers/Microsoft.Resources/deployments/{deploymentName}"} # type: ignore - - @distributed_trace + @overload def begin_create_or_update_at_management_group_scope( self, group_id: str, deployment_name: str, - parameters: "_models.ScopedDeployment", + parameters: _models.ScopedDeployment, + *, + content_type: str = "application/json", **kwargs: Any - ) -> LROPoller["_models.DeploymentExtended"]: + ) -> LROPoller[_models.DeploymentExtended]: """Deploys resources at management group scope. You can provide the template and parameters directly in the request or link to JSON files. - :param group_id: The management group ID. + :param group_id: The management group ID. Required. :type group_id: str - :param deployment_name: The name of the deployment. + :param deployment_name: The name of the deployment. Required. :type deployment_name: str - :param parameters: Additional parameters supplied to the operation. + :param parameters: Additional parameters supplied to the operation. Required. :type parameters: ~azure.mgmt.resource.resources.v2019_10_01.models.ScopedDeployment + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str :keyword callable cls: A custom type or function that will be passed the direct response :keyword str continuation_token: A continuation token to restart a poller from a saved state. :keyword polling: By default, your polling method will be ARMPolling. Pass in False for this @@ -5264,114 +5143,187 @@ def begin_create_or_update_at_management_group_scope( cls(response) :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.resource.resources.v2019_10_01.models.DeploymentExtended] - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - api_version = kwargs.pop('api_version', "2019-10-01") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] - polling = kwargs.pop('polling', True) # type: Union[bool, PollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType["_models.DeploymentExtended"] - lro_delay = kwargs.pop( - 'polling_interval', - self._config.polling_interval - ) - cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] - if cont_token is None: - raw_result = self._create_or_update_at_management_group_scope_initial( - group_id=group_id, - deployment_name=deployment_name, - parameters=parameters, - api_version=api_version, - content_type=content_type, - cls=lambda x,y,z: x, - **kwargs - ) - kwargs.pop('error_map', None) - - def get_long_running_output(pipeline_response): - response = pipeline_response.http_response - deserialized = self._deserialize('DeploymentExtended', pipeline_response) - if cls: - return cls(pipeline_response, deserialized, {}) - return deserialized - - - if polling is True: polling_method = ARMPolling(lro_delay, **kwargs) - elif polling is False: polling_method = NoPolling() - else: polling_method = polling - if cont_token: - return LROPoller.from_continuation_token( - polling_method=polling_method, - continuation_token=cont_token, - client=self._client, - deserialization_callback=get_long_running_output - ) - return LROPoller(self._client, raw_result, get_long_running_output, polling_method) - begin_create_or_update_at_management_group_scope.metadata = {'url': "/providers/Microsoft.Management/managementGroups/{groupId}/providers/Microsoft.Resources/deployments/{deploymentName}"} # type: ignore - - @distributed_trace - def get_at_management_group_scope( + @overload + def begin_create_or_update_at_management_group_scope( self, group_id: str, deployment_name: str, + parameters: IO, + *, + content_type: str = "application/json", **kwargs: Any - ) -> "_models.DeploymentExtended": - """Gets a deployment. + ) -> LROPoller[_models.DeploymentExtended]: + """Deploys resources at management group scope. - :param group_id: The management group ID. + You can provide the template and parameters directly in the request or link to JSON files. + + :param group_id: The management group ID. Required. :type group_id: str - :param deployment_name: The name of the deployment. + :param deployment_name: The name of the deployment. Required. :type deployment_name: str + :param parameters: Additional parameters supplied to the operation. Required. + :type parameters: IO + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: DeploymentExtended, or the result of cls(response) - :rtype: ~azure.mgmt.resource.resources.v2019_10_01.models.DeploymentExtended - :raises: ~azure.core.exceptions.HttpResponseError - """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.DeploymentExtended"] + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be ARMPolling. Pass in False for this + operation to not poll, or pass in your own initialized polling object for a personal polling + strategy. + :paramtype polling: bool or ~azure.core.polling.PollingMethod + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of LROPoller that returns either DeploymentExtended or the result of + cls(response) + :rtype: + ~azure.core.polling.LROPoller[~azure.mgmt.resource.resources.v2019_10_01.models.DeploymentExtended] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace + def begin_create_or_update_at_management_group_scope( + self, group_id: str, deployment_name: str, parameters: Union[_models.ScopedDeployment, IO], **kwargs: Any + ) -> LROPoller[_models.DeploymentExtended]: + """Deploys resources at management group scope. + + You can provide the template and parameters directly in the request or link to JSON files. + + :param group_id: The management group ID. Required. + :type group_id: str + :param deployment_name: The name of the deployment. Required. + :type deployment_name: str + :param parameters: Additional parameters supplied to the operation. Is either a model type or a + IO type. Required. + :type parameters: ~azure.mgmt.resource.resources.v2019_10_01.models.ScopedDeployment or IO + :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. + Default value is None. + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be ARMPolling. Pass in False for this + operation to not poll, or pass in your own initialized polling object for a personal polling + strategy. + :paramtype polling: bool or ~azure.core.polling.PollingMethod + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of LROPoller that returns either DeploymentExtended or the result of + cls(response) + :rtype: + ~azure.core.polling.LROPoller[~azure.mgmt.resource.resources.v2019_10_01.models.DeploymentExtended] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _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", "2019-10-01")) # type: str + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.DeploymentExtended] + polling = kwargs.pop("polling", True) # type: Union[bool, PollingMethod] + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token = kwargs.pop("continuation_token", None) # type: Optional[str] + if cont_token is None: + raw_result = self._create_or_update_at_management_group_scope_initial( # type: ignore + group_id=group_id, + deployment_name=deployment_name, + parameters=parameters, + api_version=api_version, + content_type=content_type, + cls=lambda x, y, z: x, + headers=_headers, + params=_params, + **kwargs + ) + kwargs.pop("error_map", None) + + def get_long_running_output(pipeline_response): + deserialized = self._deserialize("DeploymentExtended", pipeline_response) + if cls: + return cls(pipeline_response, deserialized, {}) + return deserialized + + if polling is True: + polling_method = cast(PollingMethod, ARMPolling(lro_delay, **kwargs)) # type: PollingMethod + elif polling is False: + polling_method = cast(PollingMethod, NoPolling()) + else: + polling_method = polling + if cont_token: + return LROPoller.from_continuation_token( + polling_method=polling_method, + continuation_token=cont_token, + client=self._client, + deserialization_callback=get_long_running_output, + ) + return LROPoller(self._client, raw_result, get_long_running_output, polling_method) + + begin_create_or_update_at_management_group_scope.metadata = {"url": "/providers/Microsoft.Management/managementGroups/{groupId}/providers/Microsoft.Resources/deployments/{deploymentName}"} # type: ignore + + @distributed_trace + def get_at_management_group_scope( + self, group_id: str, deployment_name: str, **kwargs: Any + ) -> _models.DeploymentExtended: + """Gets a deployment. + + :param group_id: The management group ID. Required. + :type group_id: str + :param deployment_name: The name of the deployment. Required. + :type deployment_name: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: DeploymentExtended or the result of cls(response) + :rtype: ~azure.mgmt.resource.resources.v2019_10_01.models.DeploymentExtended + :raises ~azure.core.exceptions.HttpResponseError: + """ error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + 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', "2019-10-01") # type: str + api_version = kwargs.pop("api_version", _params.pop("api-version", "2019-10-01")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[_models.DeploymentExtended] - request = build_deployments_get_at_management_group_scope_request( group_id=group_id, deployment_name=deployment_name, api_version=api_version, - template_url=self.get_at_management_group_scope.metadata['url'], + template_url=self.get_at_management_group_scope.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) - deserialized = self._deserialize('DeploymentExtended', pipeline_response) + deserialized = self._deserialize("DeploymentExtended", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - get_at_management_group_scope.metadata = {'url': "/providers/Microsoft.Management/managementGroups/{groupId}/providers/Microsoft.Resources/deployments/{deploymentName}"} # type: ignore - + get_at_management_group_scope.metadata = {"url": "/providers/Microsoft.Management/managementGroups/{groupId}/providers/Microsoft.Resources/deployments/{deploymentName}"} # type: ignore @distributed_trace def cancel_at_management_group_scope( # pylint: disable=inconsistent-return-statements - self, - group_id: str, - deployment_name: str, - **kwargs: Any + self, group_id: str, deployment_name: str, **kwargs: Any ) -> None: """Cancels a currently running template deployment. @@ -5380,38 +5332,44 @@ def cancel_at_management_group_scope( # pylint: disable=inconsistent-return-sta deployment stops the currently running template deployment and leaves the resources partially deployed. - :param group_id: The management group ID. + :param group_id: The management group ID. Required. :type group_id: str - :param deployment_name: The name of the deployment. + :param deployment_name: The name of the deployment. Required. :type deployment_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: None, or the result of cls(response) + :return: None or the result of cls(response) :rtype: None - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType[None] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) - api_version = kwargs.pop('api_version', "2019-10-01") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2019-10-01")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[None] - request = build_deployments_cancel_at_management_group_scope_request( group_id=group_id, deployment_name=deployment_name, api_version=api_version, - template_url=self.cancel_at_management_group_scope.metadata['url'], + template_url=self.cancel_at_management_group_scope.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [204]: @@ -5421,43 +5379,52 @@ def cancel_at_management_group_scope( # pylint: disable=inconsistent-return-sta if cls: return cls(pipeline_response, None, {}) - cancel_at_management_group_scope.metadata = {'url': "/providers/Microsoft.Management/managementGroups/{groupId}/providers/Microsoft.Resources/deployments/{deploymentName}/cancel"} # type: ignore - + cancel_at_management_group_scope.metadata = {"url": "/providers/Microsoft.Management/managementGroups/{groupId}/providers/Microsoft.Resources/deployments/{deploymentName}/cancel"} # type: ignore def _validate_at_management_group_scope_initial( - self, - group_id: str, - deployment_name: str, - parameters: "_models.ScopedDeployment", - **kwargs: Any - ) -> Optional["_models.DeploymentValidateResult"]: - cls = kwargs.pop('cls', None) # type: ClsType[Optional["_models.DeploymentValidateResult"]] + self, group_id: str, deployment_name: str, parameters: Union[_models.ScopedDeployment, IO], **kwargs: Any + ) -> Optional[_models.DeploymentValidateResult]: error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', "2019-10-01") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + api_version = kwargs.pop("api_version", _params.pop("api-version", "2019-10-01")) # type: str + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[Optional[_models.DeploymentValidateResult]] - _json = self._serialize.body(parameters, 'ScopedDeployment') + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(parameters, (IO, bytes)): + _content = parameters + else: + _json = self._serialize.body(parameters, "ScopedDeployment") - request = build_deployments_validate_at_management_group_scope_request_initial( + request = build_deployments_validate_at_management_group_scope_request( group_id=group_id, deployment_name=deployment_name, api_version=api_version, content_type=content_type, json=_json, - template_url=self._validate_at_management_group_scope_initial.metadata['url'], + content=_content, + template_url=self._validate_at_management_group_scope_initial.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200, 202, 400]: @@ -5466,36 +5433,40 @@ def _validate_at_management_group_scope_initial( deserialized = None if response.status_code == 200: - deserialized = self._deserialize('DeploymentValidateResult', pipeline_response) + deserialized = self._deserialize("DeploymentValidateResult", pipeline_response) if response.status_code == 400: - deserialized = self._deserialize('DeploymentValidateResult', pipeline_response) + deserialized = self._deserialize("DeploymentValidateResult", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - _validate_at_management_group_scope_initial.metadata = {'url': "/providers/Microsoft.Management/managementGroups/{groupId}/providers/Microsoft.Resources/deployments/{deploymentName}/validate"} # type: ignore - + _validate_at_management_group_scope_initial.metadata = {"url": "/providers/Microsoft.Management/managementGroups/{groupId}/providers/Microsoft.Resources/deployments/{deploymentName}/validate"} # type: ignore - @distributed_trace + @overload def begin_validate_at_management_group_scope( self, group_id: str, deployment_name: str, - parameters: "_models.ScopedDeployment", + parameters: _models.ScopedDeployment, + *, + content_type: str = "application/json", **kwargs: Any - ) -> LROPoller["_models.DeploymentValidateResult"]: + ) -> LROPoller[_models.DeploymentValidateResult]: """Validates whether the specified template is syntactically correct and will be accepted by Azure Resource Manager.. - :param group_id: The management group ID. + :param group_id: The management group ID. Required. :type group_id: str - :param deployment_name: The name of the deployment. + :param deployment_name: The name of the deployment. Required. :type deployment_name: str - :param parameters: Parameters to validate. + :param parameters: Parameters to validate. Required. :type parameters: ~azure.mgmt.resource.resources.v2019_10_01.models.ScopedDeployment + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str :keyword callable cls: A custom type or function that will be passed the direct response :keyword str continuation_token: A continuation token to restart a poller from a saved state. :keyword polling: By default, your polling method will be ARMPolling. Pass in False for this @@ -5508,85 +5479,166 @@ def begin_validate_at_management_group_scope( cls(response) :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.resource.resources.v2019_10_01.models.DeploymentValidateResult] - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - api_version = kwargs.pop('api_version', "2019-10-01") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] - polling = kwargs.pop('polling', True) # type: Union[bool, PollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType["_models.DeploymentValidateResult"] - lro_delay = kwargs.pop( - 'polling_interval', - self._config.polling_interval - ) - cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] + + @overload + def begin_validate_at_management_group_scope( + self, + group_id: str, + deployment_name: str, + parameters: IO, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> LROPoller[_models.DeploymentValidateResult]: + """Validates whether the specified template is syntactically correct and will be accepted by Azure + Resource Manager.. + + :param group_id: The management group ID. Required. + :type group_id: str + :param deployment_name: The name of the deployment. Required. + :type deployment_name: str + :param parameters: Parameters to validate. Required. + :type parameters: IO + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be ARMPolling. Pass in False for this + operation to not poll, or pass in your own initialized polling object for a personal polling + strategy. + :paramtype polling: bool or ~azure.core.polling.PollingMethod + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of LROPoller that returns either DeploymentValidateResult or the result of + cls(response) + :rtype: + ~azure.core.polling.LROPoller[~azure.mgmt.resource.resources.v2019_10_01.models.DeploymentValidateResult] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace + def begin_validate_at_management_group_scope( + self, group_id: str, deployment_name: str, parameters: Union[_models.ScopedDeployment, IO], **kwargs: Any + ) -> LROPoller[_models.DeploymentValidateResult]: + """Validates whether the specified template is syntactically correct and will be accepted by Azure + Resource Manager.. + + :param group_id: The management group ID. Required. + :type group_id: str + :param deployment_name: The name of the deployment. Required. + :type deployment_name: str + :param parameters: Parameters to validate. Is either a model type or a IO type. Required. + :type parameters: ~azure.mgmt.resource.resources.v2019_10_01.models.ScopedDeployment or IO + :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. + Default value is None. + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be ARMPolling. Pass in False for this + operation to not poll, or pass in your own initialized polling object for a personal polling + strategy. + :paramtype polling: bool or ~azure.core.polling.PollingMethod + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of LROPoller that returns either DeploymentValidateResult or the result of + cls(response) + :rtype: + ~azure.core.polling.LROPoller[~azure.mgmt.resource.resources.v2019_10_01.models.DeploymentValidateResult] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _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", "2019-10-01")) # type: str + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.DeploymentValidateResult] + polling = kwargs.pop("polling", True) # type: Union[bool, PollingMethod] + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token = kwargs.pop("continuation_token", None) # type: Optional[str] if cont_token is None: - raw_result = self._validate_at_management_group_scope_initial( + raw_result = self._validate_at_management_group_scope_initial( # type: ignore group_id=group_id, deployment_name=deployment_name, parameters=parameters, api_version=api_version, content_type=content_type, - cls=lambda x,y,z: x, + cls=lambda x, y, z: x, + headers=_headers, + params=_params, **kwargs ) - kwargs.pop('error_map', None) + kwargs.pop("error_map", None) def get_long_running_output(pipeline_response): - response = pipeline_response.http_response - deserialized = self._deserialize('DeploymentValidateResult', pipeline_response) + deserialized = self._deserialize("DeploymentValidateResult", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - - if polling is True: polling_method = ARMPolling(lro_delay, **kwargs) - elif polling is False: polling_method = NoPolling() - else: polling_method = polling + if polling is True: + polling_method = cast(PollingMethod, ARMPolling(lro_delay, **kwargs)) # type: PollingMethod + elif polling is False: + polling_method = cast(PollingMethod, NoPolling()) + else: + polling_method = polling if cont_token: return LROPoller.from_continuation_token( polling_method=polling_method, continuation_token=cont_token, client=self._client, - deserialization_callback=get_long_running_output + deserialization_callback=get_long_running_output, ) return LROPoller(self._client, raw_result, get_long_running_output, polling_method) - begin_validate_at_management_group_scope.metadata = {'url': "/providers/Microsoft.Management/managementGroups/{groupId}/providers/Microsoft.Resources/deployments/{deploymentName}/validate"} # type: ignore + begin_validate_at_management_group_scope.metadata = {"url": "/providers/Microsoft.Management/managementGroups/{groupId}/providers/Microsoft.Resources/deployments/{deploymentName}/validate"} # type: ignore def _what_if_at_management_group_scope_initial( - self, - group_id: str, - deployment_name: str, - parameters: "_models.ScopedDeploymentWhatIf", - **kwargs: Any - ) -> Optional["_models.WhatIfOperationResult"]: - cls = kwargs.pop('cls', None) # type: ClsType[Optional["_models.WhatIfOperationResult"]] + self, group_id: str, deployment_name: str, parameters: Union[_models.ScopedDeploymentWhatIf, IO], **kwargs: Any + ) -> Optional[_models.WhatIfOperationResult]: error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) - api_version = kwargs.pop('api_version', "2019-10-01") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - _json = self._serialize.body(parameters, 'ScopedDeploymentWhatIf') + api_version = kwargs.pop("api_version", _params.pop("api-version", "2019-10-01")) # type: str + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[Optional[_models.WhatIfOperationResult]] - request = build_deployments_what_if_at_management_group_scope_request_initial( + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(parameters, (IO, bytes)): + _content = parameters + else: + _json = self._serialize.body(parameters, "ScopedDeploymentWhatIf") + + request = build_deployments_what_if_at_management_group_scope_request( group_id=group_id, deployment_name=deployment_name, api_version=api_version, content_type=content_type, json=_json, - template_url=self._what_if_at_management_group_scope_initial.metadata['url'], + content=_content, + template_url=self._what_if_at_management_group_scope_initial.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200, 202]: @@ -5596,38 +5648,41 @@ def _what_if_at_management_group_scope_initial( deserialized = None response_headers = {} if response.status_code == 200: - deserialized = self._deserialize('WhatIfOperationResult', pipeline_response) + deserialized = self._deserialize("WhatIfOperationResult", pipeline_response) if response.status_code == 202: - response_headers['Location']=self._deserialize('str', response.headers.get('Location')) - response_headers['Retry-After']=self._deserialize('str', response.headers.get('Retry-After')) - + response_headers["Location"] = self._deserialize("str", response.headers.get("Location")) + response_headers["Retry-After"] = self._deserialize("str", response.headers.get("Retry-After")) if cls: return cls(pipeline_response, deserialized, response_headers) return deserialized - _what_if_at_management_group_scope_initial.metadata = {'url': "/providers/Microsoft.Management/managementGroups/{groupId}/providers/Microsoft.Resources/deployments/{deploymentName}/whatIf"} # type: ignore + _what_if_at_management_group_scope_initial.metadata = {"url": "/providers/Microsoft.Management/managementGroups/{groupId}/providers/Microsoft.Resources/deployments/{deploymentName}/whatIf"} # type: ignore - - @distributed_trace + @overload def begin_what_if_at_management_group_scope( self, group_id: str, deployment_name: str, - parameters: "_models.ScopedDeploymentWhatIf", + parameters: _models.ScopedDeploymentWhatIf, + *, + content_type: str = "application/json", **kwargs: Any - ) -> LROPoller["_models.WhatIfOperationResult"]: + ) -> LROPoller[_models.WhatIfOperationResult]: """Returns changes that will be made by the deployment if executed at the scope of the management group. - :param group_id: The management group ID. + :param group_id: The management group ID. Required. :type group_id: str - :param deployment_name: The name of the deployment. + :param deployment_name: The name of the deployment. Required. :type deployment_name: str - :param parameters: Parameters to validate. + :param parameters: Parameters to validate. Required. :type parameters: ~azure.mgmt.resource.resources.v2019_10_01.models.ScopedDeploymentWhatIf + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str :keyword callable cls: A custom type or function that will be passed the direct response :keyword str continuation_token: A continuation token to restart a poller from a saved state. :keyword polling: By default, your polling method will be ARMPolling. Pass in False for this @@ -5640,119 +5695,191 @@ def begin_what_if_at_management_group_scope( cls(response) :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.resource.resources.v2019_10_01.models.WhatIfOperationResult] - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - api_version = kwargs.pop('api_version', "2019-10-01") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] - polling = kwargs.pop('polling', True) # type: Union[bool, PollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType["_models.WhatIfOperationResult"] - lro_delay = kwargs.pop( - 'polling_interval', - self._config.polling_interval - ) - cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] + + @overload + def begin_what_if_at_management_group_scope( + self, + group_id: str, + deployment_name: str, + parameters: IO, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> LROPoller[_models.WhatIfOperationResult]: + """Returns changes that will be made by the deployment if executed at the scope of the management + group. + + :param group_id: The management group ID. Required. + :type group_id: str + :param deployment_name: The name of the deployment. Required. + :type deployment_name: str + :param parameters: Parameters to validate. Required. + :type parameters: IO + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be ARMPolling. Pass in False for this + operation to not poll, or pass in your own initialized polling object for a personal polling + strategy. + :paramtype polling: bool or ~azure.core.polling.PollingMethod + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of LROPoller that returns either WhatIfOperationResult or the result of + cls(response) + :rtype: + ~azure.core.polling.LROPoller[~azure.mgmt.resource.resources.v2019_10_01.models.WhatIfOperationResult] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace + def begin_what_if_at_management_group_scope( + self, group_id: str, deployment_name: str, parameters: Union[_models.ScopedDeploymentWhatIf, IO], **kwargs: Any + ) -> LROPoller[_models.WhatIfOperationResult]: + """Returns changes that will be made by the deployment if executed at the scope of the management + group. + + :param group_id: The management group ID. Required. + :type group_id: str + :param deployment_name: The name of the deployment. Required. + :type deployment_name: str + :param parameters: Parameters to validate. Is either a model type or a IO type. Required. + :type parameters: ~azure.mgmt.resource.resources.v2019_10_01.models.ScopedDeploymentWhatIf or + IO + :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. + Default value is None. + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be ARMPolling. Pass in False for this + operation to not poll, or pass in your own initialized polling object for a personal polling + strategy. + :paramtype polling: bool or ~azure.core.polling.PollingMethod + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of LROPoller that returns either WhatIfOperationResult or the result of + cls(response) + :rtype: + ~azure.core.polling.LROPoller[~azure.mgmt.resource.resources.v2019_10_01.models.WhatIfOperationResult] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _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", "2019-10-01")) # type: str + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.WhatIfOperationResult] + polling = kwargs.pop("polling", True) # type: Union[bool, PollingMethod] + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token = kwargs.pop("continuation_token", None) # type: Optional[str] if cont_token is None: - raw_result = self._what_if_at_management_group_scope_initial( + raw_result = self._what_if_at_management_group_scope_initial( # type: ignore group_id=group_id, deployment_name=deployment_name, parameters=parameters, api_version=api_version, content_type=content_type, - cls=lambda x,y,z: x, + cls=lambda x, y, z: x, + headers=_headers, + params=_params, **kwargs ) - kwargs.pop('error_map', None) + kwargs.pop("error_map", None) def get_long_running_output(pipeline_response): - response = pipeline_response.http_response - deserialized = self._deserialize('WhatIfOperationResult', pipeline_response) + deserialized = self._deserialize("WhatIfOperationResult", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - - if polling is True: polling_method = ARMPolling(lro_delay, lro_options={'final-state-via': 'location'}, **kwargs) - elif polling is False: polling_method = NoPolling() - else: polling_method = polling + if polling is True: + polling_method = cast( + PollingMethod, ARMPolling(lro_delay, lro_options={"final-state-via": "location"}, **kwargs) + ) # type: PollingMethod + elif polling is False: + polling_method = cast(PollingMethod, NoPolling()) + else: + polling_method = polling if cont_token: return LROPoller.from_continuation_token( polling_method=polling_method, continuation_token=cont_token, client=self._client, - deserialization_callback=get_long_running_output + deserialization_callback=get_long_running_output, ) return LROPoller(self._client, raw_result, get_long_running_output, polling_method) - begin_what_if_at_management_group_scope.metadata = {'url': "/providers/Microsoft.Management/managementGroups/{groupId}/providers/Microsoft.Resources/deployments/{deploymentName}/whatIf"} # type: ignore + begin_what_if_at_management_group_scope.metadata = {"url": "/providers/Microsoft.Management/managementGroups/{groupId}/providers/Microsoft.Resources/deployments/{deploymentName}/whatIf"} # type: ignore @distributed_trace def export_template_at_management_group_scope( - self, - group_id: str, - deployment_name: str, - **kwargs: Any - ) -> "_models.DeploymentExportResult": + self, group_id: str, deployment_name: str, **kwargs: Any + ) -> _models.DeploymentExportResult: """Exports the template used for specified deployment. - :param group_id: The management group ID. + :param group_id: The management group ID. Required. :type group_id: str - :param deployment_name: The name of the deployment. + :param deployment_name: The name of the deployment. Required. :type deployment_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: DeploymentExportResult, or the result of cls(response) + :return: DeploymentExportResult or the result of cls(response) :rtype: ~azure.mgmt.resource.resources.v2019_10_01.models.DeploymentExportResult - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.DeploymentExportResult"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + 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', "2019-10-01") # type: str + api_version = kwargs.pop("api_version", _params.pop("api-version", "2019-10-01")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[_models.DeploymentExportResult] - request = build_deployments_export_template_at_management_group_scope_request( group_id=group_id, deployment_name=deployment_name, api_version=api_version, - template_url=self.export_template_at_management_group_scope.metadata['url'], + template_url=self.export_template_at_management_group_scope.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) - deserialized = self._deserialize('DeploymentExportResult', pipeline_response) + deserialized = self._deserialize("DeploymentExportResult", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - export_template_at_management_group_scope.metadata = {'url': "/providers/Microsoft.Management/managementGroups/{groupId}/providers/Microsoft.Resources/deployments/{deploymentName}/exportTemplate"} # type: ignore - + export_template_at_management_group_scope.metadata = {"url": "/providers/Microsoft.Management/managementGroups/{groupId}/providers/Microsoft.Resources/deployments/{deploymentName}/exportTemplate"} # type: ignore @distributed_trace def list_at_management_group_scope( - self, - group_id: str, - filter: Optional[str] = None, - top: Optional[int] = None, - **kwargs: Any - ) -> Iterable["_models.DeploymentListResult"]: + self, group_id: str, filter: Optional[str] = None, top: Optional[int] = None, **kwargs: Any + ) -> Iterable["_models.DeploymentExtended"]: """Get all the deployments for a management group. - :param group_id: The management group ID. + :param group_id: The management group ID. Required. :type group_id: str :param filter: The filter to apply on the operation. For example, you can use $filter=provisioningState eq '{state}'. Default value is None. @@ -5761,40 +5888,48 @@ def list_at_management_group_scope( value is None. :type top: int :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either DeploymentListResult or the result of - cls(response) + :return: An iterator like instance of either DeploymentExtended or the result of cls(response) :rtype: - ~azure.core.paging.ItemPaged[~azure.mgmt.resource.resources.v2019_10_01.models.DeploymentListResult] - :raises: ~azure.core.exceptions.HttpResponseError + ~azure.core.paging.ItemPaged[~azure.mgmt.resource.resources.v2019_10_01.models.DeploymentExtended] + :raises ~azure.core.exceptions.HttpResponseError: """ - api_version = kwargs.pop('api_version', "2019-10-01") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2019-10-01")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[_models.DeploymentListResult] - cls = kwargs.pop('cls', None) # type: ClsType["_models.DeploymentListResult"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) + def prepare_request(next_link=None): if not next_link: - + request = build_deployments_list_at_management_group_scope_request( group_id=group_id, - api_version=api_version, filter=filter, top=top, - template_url=self.list_at_management_group_scope.metadata['url'], + api_version=api_version, + template_url=self.list_at_management_group_scope.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore else: - - request = build_deployments_list_at_management_group_scope_request( - group_id=group_id, - template_url=next_link, - ) + # make call to next link with the client's api-version + _parsed_next_link = urlparse(next_link) + _next_request_params = case_insensitive_dict(parse_qs(_parsed_next_link.query)) + _next_request_params["api-version"] = self._config.api_version + request = HttpRequest("GET", urljoin(next_link, _parsed_next_link.path), params=_next_request_params) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore request.method = "GET" return request @@ -5808,10 +5943,8 @@ def extract_data(pipeline_response): def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) response = pipeline_response.http_response @@ -5821,40 +5954,42 @@ def get_next(next_link=None): return pipeline_response + return ItemPaged(get_next, extract_data) - return ItemPaged( - get_next, extract_data - ) - list_at_management_group_scope.metadata = {'url': "/providers/Microsoft.Management/managementGroups/{groupId}/providers/Microsoft.Resources/deployments/"} # type: ignore + list_at_management_group_scope.metadata = {"url": "/providers/Microsoft.Management/managementGroups/{groupId}/providers/Microsoft.Resources/deployments/"} # type: ignore def _delete_at_subscription_scope_initial( # pylint: disable=inconsistent-return-statements - self, - deployment_name: str, - **kwargs: Any + self, deployment_name: str, **kwargs: Any ) -> None: - cls = kwargs.pop('cls', None) # type: ClsType[None] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + 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', "2019-10-01") # type: str + api_version = kwargs.pop("api_version", _params.pop("api-version", "2019-10-01")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[None] - - request = build_deployments_delete_at_subscription_scope_request_initial( + request = build_deployments_delete_at_subscription_scope_request( deployment_name=deployment_name, subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self._delete_at_subscription_scope_initial.metadata['url'], + template_url=self._delete_at_subscription_scope_initial.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [202, 204]: @@ -5864,15 +5999,10 @@ def _delete_at_subscription_scope_initial( # pylint: disable=inconsistent-retur if cls: return cls(pipeline_response, None, {}) - _delete_at_subscription_scope_initial.metadata = {'url': "/subscriptions/{subscriptionId}/providers/Microsoft.Resources/deployments/{deploymentName}"} # type: ignore - + _delete_at_subscription_scope_initial.metadata = {"url": "/subscriptions/{subscriptionId}/providers/Microsoft.Resources/deployments/{deploymentName}"} # type: ignore @distributed_trace - def begin_delete_at_subscription_scope( # pylint: disable=inconsistent-return-statements - self, - deployment_name: str, - **kwargs: Any - ) -> LROPoller[None]: + def begin_delete_at_subscription_scope(self, deployment_name: str, **kwargs: Any) -> LROPoller[None]: """Deletes a deployment from the deployment history. A template deployment that is currently running cannot be deleted. Deleting a template @@ -5883,7 +6013,7 @@ def begin_delete_at_subscription_scope( # pylint: disable=inconsistent-return-s process finishes, the URI in the Location header returns a status of 204 on success. If the asynchronous request failed, the URI in the Location header returns an error-level status code. - :param deployment_name: The name of the deployment. + :param deployment_name: The name of the deployment. Required. :type deployment_name: str :keyword callable cls: A custom type or function that will be passed the direct response :keyword str continuation_token: A continuation token to restart a poller from a saved state. @@ -5895,82 +6025,88 @@ def begin_delete_at_subscription_scope( # pylint: disable=inconsistent-return-s Retry-After header is present. :return: An instance of LROPoller that returns either None or the result of cls(response) :rtype: ~azure.core.polling.LROPoller[None] - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - api_version = kwargs.pop('api_version', "2019-10-01") # type: str - polling = kwargs.pop('polling', True) # type: Union[bool, PollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType[None] - lro_delay = kwargs.pop( - 'polling_interval', - self._config.polling_interval - ) - cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2019-10-01")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[None] + polling = kwargs.pop("polling", True) # type: Union[bool, PollingMethod] + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token = kwargs.pop("continuation_token", None) # type: Optional[str] if cont_token is None: - raw_result = self._delete_at_subscription_scope_initial( + raw_result = self._delete_at_subscription_scope_initial( # type: ignore deployment_name=deployment_name, api_version=api_version, - cls=lambda x,y,z: x, + cls=lambda x, y, z: x, + headers=_headers, + params=_params, **kwargs ) - kwargs.pop('error_map', None) + kwargs.pop("error_map", None) - def get_long_running_output(pipeline_response): + def get_long_running_output(pipeline_response): # pylint: disable=inconsistent-return-statements if cls: return cls(pipeline_response, None, {}) - - if polling is True: polling_method = ARMPolling(lro_delay, **kwargs) - elif polling is False: polling_method = NoPolling() - else: polling_method = polling + if polling is True: + polling_method = cast(PollingMethod, ARMPolling(lro_delay, **kwargs)) # type: PollingMethod + elif polling is False: + polling_method = cast(PollingMethod, NoPolling()) + else: + polling_method = polling if cont_token: return LROPoller.from_continuation_token( polling_method=polling_method, continuation_token=cont_token, client=self._client, - deserialization_callback=get_long_running_output + deserialization_callback=get_long_running_output, ) return LROPoller(self._client, raw_result, get_long_running_output, polling_method) - begin_delete_at_subscription_scope.metadata = {'url': "/subscriptions/{subscriptionId}/providers/Microsoft.Resources/deployments/{deploymentName}"} # type: ignore + begin_delete_at_subscription_scope.metadata = {"url": "/subscriptions/{subscriptionId}/providers/Microsoft.Resources/deployments/{deploymentName}"} # type: ignore @distributed_trace - def check_existence_at_subscription_scope( - self, - deployment_name: str, - **kwargs: Any - ) -> bool: + def check_existence_at_subscription_scope(self, deployment_name: str, **kwargs: Any) -> bool: """Checks whether the deployment exists. - :param deployment_name: The name of the deployment. + :param deployment_name: The name of the deployment. Required. :type deployment_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: bool, or the result of cls(response) + :return: bool or the result of cls(response) :rtype: bool - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType[None] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + 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', "2019-10-01") # type: str + api_version = kwargs.pop("api_version", _params.pop("api-version", "2019-10-01")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[None] - request = build_deployments_check_existence_at_subscription_scope_request( deployment_name=deployment_name, subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.check_existence_at_subscription_scope.metadata['url'], + template_url=self.check_existence_at_subscription_scope.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [204, 404]: @@ -5981,42 +6117,52 @@ def check_existence_at_subscription_scope( return cls(pipeline_response, None, {}) return 200 <= response.status_code <= 299 - check_existence_at_subscription_scope.metadata = {'url': "/subscriptions/{subscriptionId}/providers/Microsoft.Resources/deployments/{deploymentName}"} # type: ignore - + check_existence_at_subscription_scope.metadata = {"url": "/subscriptions/{subscriptionId}/providers/Microsoft.Resources/deployments/{deploymentName}"} # type: ignore def _create_or_update_at_subscription_scope_initial( - self, - deployment_name: str, - parameters: "_models.Deployment", - **kwargs: Any - ) -> "_models.DeploymentExtended": - cls = kwargs.pop('cls', None) # type: ClsType["_models.DeploymentExtended"] + self, deployment_name: str, parameters: Union[_models.Deployment, IO], **kwargs: Any + ) -> _models.DeploymentExtended: error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', "2019-10-01") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + api_version = kwargs.pop("api_version", _params.pop("api-version", "2019-10-01")) # type: str + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.DeploymentExtended] - _json = self._serialize.body(parameters, 'Deployment') + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(parameters, (IO, bytes)): + _content = parameters + else: + _json = self._serialize.body(parameters, "Deployment") - request = build_deployments_create_or_update_at_subscription_scope_request_initial( + request = build_deployments_create_or_update_at_subscription_scope_request( deployment_name=deployment_name, subscription_id=self._config.subscription_id, api_version=api_version, content_type=content_type, json=_json, - template_url=self._create_or_update_at_subscription_scope_initial.metadata['url'], + content=_content, + template_url=self._create_or_update_at_subscription_scope_initial.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200, 201]: @@ -6024,34 +6170,38 @@ def _create_or_update_at_subscription_scope_initial( raise HttpResponseError(response=response, error_format=ARMErrorFormat) if response.status_code == 200: - deserialized = self._deserialize('DeploymentExtended', pipeline_response) + deserialized = self._deserialize("DeploymentExtended", pipeline_response) if response.status_code == 201: - deserialized = self._deserialize('DeploymentExtended', pipeline_response) + deserialized = self._deserialize("DeploymentExtended", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - _create_or_update_at_subscription_scope_initial.metadata = {'url': "/subscriptions/{subscriptionId}/providers/Microsoft.Resources/deployments/{deploymentName}"} # type: ignore - + _create_or_update_at_subscription_scope_initial.metadata = {"url": "/subscriptions/{subscriptionId}/providers/Microsoft.Resources/deployments/{deploymentName}"} # type: ignore - @distributed_trace + @overload def begin_create_or_update_at_subscription_scope( self, deployment_name: str, - parameters: "_models.Deployment", + parameters: _models.Deployment, + *, + content_type: str = "application/json", **kwargs: Any - ) -> LROPoller["_models.DeploymentExtended"]: + ) -> LROPoller[_models.DeploymentExtended]: """Deploys resources at subscription scope. You can provide the template and parameters directly in the request or link to JSON files. - :param deployment_name: The name of the deployment. + :param deployment_name: The name of the deployment. Required. :type deployment_name: str - :param parameters: Additional parameters supplied to the operation. + :param parameters: Additional parameters supplied to the operation. Required. :type parameters: ~azure.mgmt.resource.resources.v2019_10_01.models.Deployment + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str :keyword callable cls: A custom type or function that will be passed the direct response :keyword str continuation_token: A continuation token to restart a poller from a saved state. :keyword polling: By default, your polling method will be ARMPolling. Pass in False for this @@ -6064,109 +6214,172 @@ def begin_create_or_update_at_subscription_scope( cls(response) :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.resource.resources.v2019_10_01.models.DeploymentExtended] - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - api_version = kwargs.pop('api_version', "2019-10-01") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] - polling = kwargs.pop('polling', True) # type: Union[bool, PollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType["_models.DeploymentExtended"] - lro_delay = kwargs.pop( - 'polling_interval', - self._config.polling_interval - ) - cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] - if cont_token is None: - raw_result = self._create_or_update_at_subscription_scope_initial( - deployment_name=deployment_name, - parameters=parameters, - api_version=api_version, - content_type=content_type, - cls=lambda x,y,z: x, - **kwargs - ) - kwargs.pop('error_map', None) - def get_long_running_output(pipeline_response): - response = pipeline_response.http_response - deserialized = self._deserialize('DeploymentExtended', pipeline_response) - if cls: - return cls(pipeline_response, deserialized, {}) - return deserialized + @overload + def begin_create_or_update_at_subscription_scope( + self, deployment_name: str, parameters: IO, *, content_type: str = "application/json", **kwargs: Any + ) -> LROPoller[_models.DeploymentExtended]: + """Deploys resources at subscription scope. + You can provide the template and parameters directly in the request or link to JSON files. + + :param deployment_name: The name of the deployment. Required. + :type deployment_name: str + :param parameters: Additional parameters supplied to the operation. Required. + :type parameters: IO + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be ARMPolling. Pass in False for this + operation to not poll, or pass in your own initialized polling object for a personal polling + strategy. + :paramtype polling: bool or ~azure.core.polling.PollingMethod + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of LROPoller that returns either DeploymentExtended or the result of + cls(response) + :rtype: + ~azure.core.polling.LROPoller[~azure.mgmt.resource.resources.v2019_10_01.models.DeploymentExtended] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace + def begin_create_or_update_at_subscription_scope( + self, deployment_name: str, parameters: Union[_models.Deployment, IO], **kwargs: Any + ) -> LROPoller[_models.DeploymentExtended]: + """Deploys resources at subscription scope. + + You can provide the template and parameters directly in the request or link to JSON files. + + :param deployment_name: The name of the deployment. Required. + :type deployment_name: str + :param parameters: Additional parameters supplied to the operation. Is either a model type or a + IO type. Required. + :type parameters: ~azure.mgmt.resource.resources.v2019_10_01.models.Deployment or IO + :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. + Default value is None. + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be ARMPolling. Pass in False for this + operation to not poll, or pass in your own initialized polling object for a personal polling + strategy. + :paramtype polling: bool or ~azure.core.polling.PollingMethod + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of LROPoller that returns either DeploymentExtended or the result of + cls(response) + :rtype: + ~azure.core.polling.LROPoller[~azure.mgmt.resource.resources.v2019_10_01.models.DeploymentExtended] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _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", "2019-10-01")) # type: str + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.DeploymentExtended] + polling = kwargs.pop("polling", True) # type: Union[bool, PollingMethod] + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token = kwargs.pop("continuation_token", None) # type: Optional[str] + if cont_token is None: + raw_result = self._create_or_update_at_subscription_scope_initial( # type: ignore + deployment_name=deployment_name, + parameters=parameters, + api_version=api_version, + content_type=content_type, + cls=lambda x, y, z: x, + headers=_headers, + params=_params, + **kwargs + ) + kwargs.pop("error_map", None) + + def get_long_running_output(pipeline_response): + deserialized = self._deserialize("DeploymentExtended", pipeline_response) + if cls: + return cls(pipeline_response, deserialized, {}) + return deserialized - if polling is True: polling_method = ARMPolling(lro_delay, **kwargs) - elif polling is False: polling_method = NoPolling() - else: polling_method = polling + if polling is True: + polling_method = cast(PollingMethod, ARMPolling(lro_delay, **kwargs)) # type: PollingMethod + elif polling is False: + polling_method = cast(PollingMethod, NoPolling()) + else: + polling_method = polling if cont_token: return LROPoller.from_continuation_token( polling_method=polling_method, continuation_token=cont_token, client=self._client, - deserialization_callback=get_long_running_output + deserialization_callback=get_long_running_output, ) return LROPoller(self._client, raw_result, get_long_running_output, polling_method) - begin_create_or_update_at_subscription_scope.metadata = {'url': "/subscriptions/{subscriptionId}/providers/Microsoft.Resources/deployments/{deploymentName}"} # type: ignore + begin_create_or_update_at_subscription_scope.metadata = {"url": "/subscriptions/{subscriptionId}/providers/Microsoft.Resources/deployments/{deploymentName}"} # type: ignore @distributed_trace - def get_at_subscription_scope( - self, - deployment_name: str, - **kwargs: Any - ) -> "_models.DeploymentExtended": + def get_at_subscription_scope(self, deployment_name: str, **kwargs: Any) -> _models.DeploymentExtended: """Gets a deployment. - :param deployment_name: The name of the deployment. + :param deployment_name: The name of the deployment. Required. :type deployment_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: DeploymentExtended, or the result of cls(response) + :return: DeploymentExtended or the result of cls(response) :rtype: ~azure.mgmt.resource.resources.v2019_10_01.models.DeploymentExtended - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.DeploymentExtended"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) - api_version = kwargs.pop('api_version', "2019-10-01") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2019-10-01")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[_models.DeploymentExtended] - request = build_deployments_get_at_subscription_scope_request( deployment_name=deployment_name, subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.get_at_subscription_scope.metadata['url'], + template_url=self.get_at_subscription_scope.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) - deserialized = self._deserialize('DeploymentExtended', pipeline_response) + deserialized = self._deserialize("DeploymentExtended", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - get_at_subscription_scope.metadata = {'url': "/subscriptions/{subscriptionId}/providers/Microsoft.Resources/deployments/{deploymentName}"} # type: ignore - + get_at_subscription_scope.metadata = {"url": "/subscriptions/{subscriptionId}/providers/Microsoft.Resources/deployments/{deploymentName}"} # type: ignore @distributed_trace def cancel_at_subscription_scope( # pylint: disable=inconsistent-return-statements - self, - deployment_name: str, - **kwargs: Any + self, deployment_name: str, **kwargs: Any ) -> None: """Cancels a currently running template deployment. @@ -6175,36 +6388,42 @@ def cancel_at_subscription_scope( # pylint: disable=inconsistent-return-stateme deployment stops the currently running template deployment and leaves the resources partially deployed. - :param deployment_name: The name of the deployment. + :param deployment_name: The name of the deployment. Required. :type deployment_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: None, or the result of cls(response) + :return: None or the result of cls(response) :rtype: None - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType[None] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) - api_version = kwargs.pop('api_version', "2019-10-01") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2019-10-01")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[None] - request = build_deployments_cancel_at_subscription_scope_request( deployment_name=deployment_name, subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.cancel_at_subscription_scope.metadata['url'], + template_url=self.cancel_at_subscription_scope.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [204]: @@ -6214,42 +6433,52 @@ def cancel_at_subscription_scope( # pylint: disable=inconsistent-return-stateme if cls: return cls(pipeline_response, None, {}) - cancel_at_subscription_scope.metadata = {'url': "/subscriptions/{subscriptionId}/providers/Microsoft.Resources/deployments/{deploymentName}/cancel"} # type: ignore - + cancel_at_subscription_scope.metadata = {"url": "/subscriptions/{subscriptionId}/providers/Microsoft.Resources/deployments/{deploymentName}/cancel"} # type: ignore def _validate_at_subscription_scope_initial( - self, - deployment_name: str, - parameters: "_models.Deployment", - **kwargs: Any - ) -> Optional["_models.DeploymentValidateResult"]: - cls = kwargs.pop('cls', None) # type: ClsType[Optional["_models.DeploymentValidateResult"]] + self, deployment_name: str, parameters: Union[_models.Deployment, IO], **kwargs: Any + ) -> Optional[_models.DeploymentValidateResult]: error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) - api_version = kwargs.pop('api_version', "2019-10-01") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - _json = self._serialize.body(parameters, 'Deployment') + api_version = kwargs.pop("api_version", _params.pop("api-version", "2019-10-01")) # type: str + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[Optional[_models.DeploymentValidateResult]] - request = build_deployments_validate_at_subscription_scope_request_initial( + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(parameters, (IO, bytes)): + _content = parameters + else: + _json = self._serialize.body(parameters, "Deployment") + + request = build_deployments_validate_at_subscription_scope_request( deployment_name=deployment_name, subscription_id=self._config.subscription_id, api_version=api_version, content_type=content_type, json=_json, - template_url=self._validate_at_subscription_scope_initial.metadata['url'], + content=_content, + template_url=self._validate_at_subscription_scope_initial.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200, 202, 400]: @@ -6258,33 +6487,37 @@ def _validate_at_subscription_scope_initial( deserialized = None if response.status_code == 200: - deserialized = self._deserialize('DeploymentValidateResult', pipeline_response) + deserialized = self._deserialize("DeploymentValidateResult", pipeline_response) if response.status_code == 400: - deserialized = self._deserialize('DeploymentValidateResult', pipeline_response) + deserialized = self._deserialize("DeploymentValidateResult", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - _validate_at_subscription_scope_initial.metadata = {'url': "/subscriptions/{subscriptionId}/providers/Microsoft.Resources/deployments/{deploymentName}/validate"} # type: ignore + _validate_at_subscription_scope_initial.metadata = {"url": "/subscriptions/{subscriptionId}/providers/Microsoft.Resources/deployments/{deploymentName}/validate"} # type: ignore - - @distributed_trace + @overload def begin_validate_at_subscription_scope( self, deployment_name: str, - parameters: "_models.Deployment", + parameters: _models.Deployment, + *, + content_type: str = "application/json", **kwargs: Any - ) -> LROPoller["_models.DeploymentValidateResult"]: + ) -> LROPoller[_models.DeploymentValidateResult]: """Validates whether the specified template is syntactically correct and will be accepted by Azure Resource Manager.. - :param deployment_name: The name of the deployment. + :param deployment_name: The name of the deployment. Required. :type deployment_name: str - :param parameters: Parameters to validate. + :param parameters: Parameters to validate. Required. :type parameters: ~azure.mgmt.resource.resources.v2019_10_01.models.Deployment + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str :keyword callable cls: A custom type or function that will be passed the direct response :keyword str continuation_token: A continuation token to restart a poller from a saved state. :keyword polling: By default, your polling method will be ARMPolling. Pass in False for this @@ -6297,83 +6530,155 @@ def begin_validate_at_subscription_scope( cls(response) :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.resource.resources.v2019_10_01.models.DeploymentValidateResult] - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - api_version = kwargs.pop('api_version', "2019-10-01") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] - polling = kwargs.pop('polling', True) # type: Union[bool, PollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType["_models.DeploymentValidateResult"] - lro_delay = kwargs.pop( - 'polling_interval', - self._config.polling_interval - ) - cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] + + @overload + def begin_validate_at_subscription_scope( + self, deployment_name: str, parameters: IO, *, content_type: str = "application/json", **kwargs: Any + ) -> LROPoller[_models.DeploymentValidateResult]: + """Validates whether the specified template is syntactically correct and will be accepted by Azure + Resource Manager.. + + :param deployment_name: The name of the deployment. Required. + :type deployment_name: str + :param parameters: Parameters to validate. Required. + :type parameters: IO + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be ARMPolling. Pass in False for this + operation to not poll, or pass in your own initialized polling object for a personal polling + strategy. + :paramtype polling: bool or ~azure.core.polling.PollingMethod + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of LROPoller that returns either DeploymentValidateResult or the result of + cls(response) + :rtype: + ~azure.core.polling.LROPoller[~azure.mgmt.resource.resources.v2019_10_01.models.DeploymentValidateResult] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace + def begin_validate_at_subscription_scope( + self, deployment_name: str, parameters: Union[_models.Deployment, IO], **kwargs: Any + ) -> LROPoller[_models.DeploymentValidateResult]: + """Validates whether the specified template is syntactically correct and will be accepted by Azure + Resource Manager.. + + :param deployment_name: The name of the deployment. Required. + :type deployment_name: str + :param parameters: Parameters to validate. Is either a model type or a IO type. Required. + :type parameters: ~azure.mgmt.resource.resources.v2019_10_01.models.Deployment or IO + :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. + Default value is None. + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be ARMPolling. Pass in False for this + operation to not poll, or pass in your own initialized polling object for a personal polling + strategy. + :paramtype polling: bool or ~azure.core.polling.PollingMethod + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of LROPoller that returns either DeploymentValidateResult or the result of + cls(response) + :rtype: + ~azure.core.polling.LROPoller[~azure.mgmt.resource.resources.v2019_10_01.models.DeploymentValidateResult] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _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", "2019-10-01")) # type: str + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.DeploymentValidateResult] + polling = kwargs.pop("polling", True) # type: Union[bool, PollingMethod] + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token = kwargs.pop("continuation_token", None) # type: Optional[str] if cont_token is None: - raw_result = self._validate_at_subscription_scope_initial( + raw_result = self._validate_at_subscription_scope_initial( # type: ignore deployment_name=deployment_name, parameters=parameters, api_version=api_version, content_type=content_type, - cls=lambda x,y,z: x, + cls=lambda x, y, z: x, + headers=_headers, + params=_params, **kwargs ) - kwargs.pop('error_map', None) + kwargs.pop("error_map", None) def get_long_running_output(pipeline_response): - response = pipeline_response.http_response - deserialized = self._deserialize('DeploymentValidateResult', pipeline_response) + deserialized = self._deserialize("DeploymentValidateResult", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - - if polling is True: polling_method = ARMPolling(lro_delay, **kwargs) - elif polling is False: polling_method = NoPolling() - else: polling_method = polling + if polling is True: + polling_method = cast(PollingMethod, ARMPolling(lro_delay, **kwargs)) # type: PollingMethod + elif polling is False: + polling_method = cast(PollingMethod, NoPolling()) + else: + polling_method = polling if cont_token: return LROPoller.from_continuation_token( polling_method=polling_method, continuation_token=cont_token, client=self._client, - deserialization_callback=get_long_running_output + deserialization_callback=get_long_running_output, ) return LROPoller(self._client, raw_result, get_long_running_output, polling_method) - begin_validate_at_subscription_scope.metadata = {'url': "/subscriptions/{subscriptionId}/providers/Microsoft.Resources/deployments/{deploymentName}/validate"} # type: ignore + begin_validate_at_subscription_scope.metadata = {"url": "/subscriptions/{subscriptionId}/providers/Microsoft.Resources/deployments/{deploymentName}/validate"} # type: ignore def _what_if_at_subscription_scope_initial( - self, - deployment_name: str, - parameters: "_models.DeploymentWhatIf", - **kwargs: Any - ) -> Optional["_models.WhatIfOperationResult"]: - cls = kwargs.pop('cls', None) # type: ClsType[Optional["_models.WhatIfOperationResult"]] + self, deployment_name: str, parameters: Union[_models.DeploymentWhatIf, IO], **kwargs: Any + ) -> Optional[_models.WhatIfOperationResult]: error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) - api_version = kwargs.pop('api_version', "2019-10-01") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - _json = self._serialize.body(parameters, 'DeploymentWhatIf') + api_version = kwargs.pop("api_version", _params.pop("api-version", "2019-10-01")) # type: str + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[Optional[_models.WhatIfOperationResult]] - request = build_deployments_what_if_at_subscription_scope_request_initial( + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(parameters, (IO, bytes)): + _content = parameters + else: + _json = self._serialize.body(parameters, "DeploymentWhatIf") + + request = build_deployments_what_if_at_subscription_scope_request( deployment_name=deployment_name, subscription_id=self._config.subscription_id, api_version=api_version, content_type=content_type, json=_json, - template_url=self._what_if_at_subscription_scope_initial.metadata['url'], + content=_content, + template_url=self._what_if_at_subscription_scope_initial.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200, 202]: @@ -6383,35 +6688,38 @@ def _what_if_at_subscription_scope_initial( deserialized = None response_headers = {} if response.status_code == 200: - deserialized = self._deserialize('WhatIfOperationResult', pipeline_response) + deserialized = self._deserialize("WhatIfOperationResult", pipeline_response) if response.status_code == 202: - response_headers['Location']=self._deserialize('str', response.headers.get('Location')) - response_headers['Retry-After']=self._deserialize('str', response.headers.get('Retry-After')) - + response_headers["Location"] = self._deserialize("str", response.headers.get("Location")) + response_headers["Retry-After"] = self._deserialize("str", response.headers.get("Retry-After")) if cls: return cls(pipeline_response, deserialized, response_headers) return deserialized - _what_if_at_subscription_scope_initial.metadata = {'url': "/subscriptions/{subscriptionId}/providers/Microsoft.Resources/deployments/{deploymentName}/whatIf"} # type: ignore + _what_if_at_subscription_scope_initial.metadata = {"url": "/subscriptions/{subscriptionId}/providers/Microsoft.Resources/deployments/{deploymentName}/whatIf"} # type: ignore - - @distributed_trace + @overload def begin_what_if_at_subscription_scope( self, deployment_name: str, - parameters: "_models.DeploymentWhatIf", + parameters: _models.DeploymentWhatIf, + *, + content_type: str = "application/json", **kwargs: Any - ) -> LROPoller["_models.WhatIfOperationResult"]: + ) -> LROPoller[_models.WhatIfOperationResult]: """Returns changes that will be made by the deployment if executed at the scope of the subscription. - :param deployment_name: The name of the deployment. + :param deployment_name: The name of the deployment. Required. :type deployment_name: str - :param parameters: Parameters to What If. + :param parameters: Parameters to What If. Required. :type parameters: ~azure.mgmt.resource.resources.v2019_10_01.models.DeploymentWhatIf + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str :keyword callable cls: A custom type or function that will be passed the direct response :keyword str continuation_token: A continuation token to restart a poller from a saved state. :keyword polling: By default, your polling method will be ARMPolling. Pass in False for this @@ -6424,111 +6732,174 @@ def begin_what_if_at_subscription_scope( cls(response) :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.resource.resources.v2019_10_01.models.WhatIfOperationResult] - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - api_version = kwargs.pop('api_version', "2019-10-01") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] - polling = kwargs.pop('polling', True) # type: Union[bool, PollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType["_models.WhatIfOperationResult"] - lro_delay = kwargs.pop( - 'polling_interval', - self._config.polling_interval - ) - cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] + + @overload + def begin_what_if_at_subscription_scope( + self, deployment_name: str, parameters: IO, *, content_type: str = "application/json", **kwargs: Any + ) -> LROPoller[_models.WhatIfOperationResult]: + """Returns changes that will be made by the deployment if executed at the scope of the + subscription. + + :param deployment_name: The name of the deployment. Required. + :type deployment_name: str + :param parameters: Parameters to What If. Required. + :type parameters: IO + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be ARMPolling. Pass in False for this + operation to not poll, or pass in your own initialized polling object for a personal polling + strategy. + :paramtype polling: bool or ~azure.core.polling.PollingMethod + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of LROPoller that returns either WhatIfOperationResult or the result of + cls(response) + :rtype: + ~azure.core.polling.LROPoller[~azure.mgmt.resource.resources.v2019_10_01.models.WhatIfOperationResult] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace + def begin_what_if_at_subscription_scope( + self, deployment_name: str, parameters: Union[_models.DeploymentWhatIf, IO], **kwargs: Any + ) -> LROPoller[_models.WhatIfOperationResult]: + """Returns changes that will be made by the deployment if executed at the scope of the + subscription. + + :param deployment_name: The name of the deployment. Required. + :type deployment_name: str + :param parameters: Parameters to What If. Is either a model type or a IO type. Required. + :type parameters: ~azure.mgmt.resource.resources.v2019_10_01.models.DeploymentWhatIf or IO + :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. + Default value is None. + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be ARMPolling. Pass in False for this + operation to not poll, or pass in your own initialized polling object for a personal polling + strategy. + :paramtype polling: bool or ~azure.core.polling.PollingMethod + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of LROPoller that returns either WhatIfOperationResult or the result of + cls(response) + :rtype: + ~azure.core.polling.LROPoller[~azure.mgmt.resource.resources.v2019_10_01.models.WhatIfOperationResult] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _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", "2019-10-01")) # type: str + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.WhatIfOperationResult] + polling = kwargs.pop("polling", True) # type: Union[bool, PollingMethod] + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token = kwargs.pop("continuation_token", None) # type: Optional[str] if cont_token is None: - raw_result = self._what_if_at_subscription_scope_initial( + raw_result = self._what_if_at_subscription_scope_initial( # type: ignore deployment_name=deployment_name, parameters=parameters, api_version=api_version, content_type=content_type, - cls=lambda x,y,z: x, + cls=lambda x, y, z: x, + headers=_headers, + params=_params, **kwargs ) - kwargs.pop('error_map', None) + kwargs.pop("error_map", None) def get_long_running_output(pipeline_response): - response = pipeline_response.http_response - deserialized = self._deserialize('WhatIfOperationResult', pipeline_response) + deserialized = self._deserialize("WhatIfOperationResult", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - - if polling is True: polling_method = ARMPolling(lro_delay, lro_options={'final-state-via': 'location'}, **kwargs) - elif polling is False: polling_method = NoPolling() - else: polling_method = polling + if polling is True: + polling_method = cast( + PollingMethod, ARMPolling(lro_delay, lro_options={"final-state-via": "location"}, **kwargs) + ) # type: PollingMethod + elif polling is False: + polling_method = cast(PollingMethod, NoPolling()) + else: + polling_method = polling if cont_token: return LROPoller.from_continuation_token( polling_method=polling_method, continuation_token=cont_token, client=self._client, - deserialization_callback=get_long_running_output + deserialization_callback=get_long_running_output, ) return LROPoller(self._client, raw_result, get_long_running_output, polling_method) - begin_what_if_at_subscription_scope.metadata = {'url': "/subscriptions/{subscriptionId}/providers/Microsoft.Resources/deployments/{deploymentName}/whatIf"} # type: ignore + begin_what_if_at_subscription_scope.metadata = {"url": "/subscriptions/{subscriptionId}/providers/Microsoft.Resources/deployments/{deploymentName}/whatIf"} # type: ignore @distributed_trace def export_template_at_subscription_scope( - self, - deployment_name: str, - **kwargs: Any - ) -> "_models.DeploymentExportResult": + self, deployment_name: str, **kwargs: Any + ) -> _models.DeploymentExportResult: """Exports the template used for specified deployment. - :param deployment_name: The name of the deployment. + :param deployment_name: The name of the deployment. Required. :type deployment_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: DeploymentExportResult, or the result of cls(response) + :return: DeploymentExportResult or the result of cls(response) :rtype: ~azure.mgmt.resource.resources.v2019_10_01.models.DeploymentExportResult - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.DeploymentExportResult"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) - api_version = kwargs.pop('api_version', "2019-10-01") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2019-10-01")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[_models.DeploymentExportResult] - request = build_deployments_export_template_at_subscription_scope_request( deployment_name=deployment_name, subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.export_template_at_subscription_scope.metadata['url'], + template_url=self.export_template_at_subscription_scope.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) - deserialized = self._deserialize('DeploymentExportResult', pipeline_response) + deserialized = self._deserialize("DeploymentExportResult", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - export_template_at_subscription_scope.metadata = {'url': "/subscriptions/{subscriptionId}/providers/Microsoft.Resources/deployments/{deploymentName}/exportTemplate"} # type: ignore - + export_template_at_subscription_scope.metadata = {"url": "/subscriptions/{subscriptionId}/providers/Microsoft.Resources/deployments/{deploymentName}/exportTemplate"} # type: ignore @distributed_trace def list_at_subscription_scope( - self, - filter: Optional[str] = None, - top: Optional[int] = None, - **kwargs: Any - ) -> Iterable["_models.DeploymentListResult"]: + self, filter: Optional[str] = None, top: Optional[int] = None, **kwargs: Any + ) -> Iterable["_models.DeploymentExtended"]: """Get all the deployments for a subscription. :param filter: The filter to apply on the operation. For example, you can use @@ -6538,40 +6909,48 @@ def list_at_subscription_scope( value is None. :type top: int :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either DeploymentListResult or the result of - cls(response) + :return: An iterator like instance of either DeploymentExtended or the result of cls(response) :rtype: - ~azure.core.paging.ItemPaged[~azure.mgmt.resource.resources.v2019_10_01.models.DeploymentListResult] - :raises: ~azure.core.exceptions.HttpResponseError + ~azure.core.paging.ItemPaged[~azure.mgmt.resource.resources.v2019_10_01.models.DeploymentExtended] + :raises ~azure.core.exceptions.HttpResponseError: """ - api_version = kwargs.pop('api_version', "2019-10-01") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2019-10-01")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[_models.DeploymentListResult] - cls = kwargs.pop('cls', None) # type: ClsType["_models.DeploymentListResult"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) + def prepare_request(next_link=None): if not next_link: - + request = build_deployments_list_at_subscription_scope_request( subscription_id=self._config.subscription_id, - api_version=api_version, filter=filter, top=top, - template_url=self.list_at_subscription_scope.metadata['url'], + api_version=api_version, + template_url=self.list_at_subscription_scope.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore else: - - request = build_deployments_list_at_subscription_scope_request( - subscription_id=self._config.subscription_id, - template_url=next_link, - ) + # make call to next link with the client's api-version + _parsed_next_link = urlparse(next_link) + _next_request_params = case_insensitive_dict(parse_qs(_parsed_next_link.query)) + _next_request_params["api-version"] = self._config.api_version + request = HttpRequest("GET", urljoin(next_link, _parsed_next_link.path), params=_next_request_params) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore request.method = "GET" return request @@ -6585,10 +6964,8 @@ def extract_data(pipeline_response): def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) response = pipeline_response.http_response @@ -6598,42 +6975,43 @@ def get_next(next_link=None): return pipeline_response + return ItemPaged(get_next, extract_data) - return ItemPaged( - get_next, extract_data - ) - list_at_subscription_scope.metadata = {'url': "/subscriptions/{subscriptionId}/providers/Microsoft.Resources/deployments/"} # type: ignore + list_at_subscription_scope.metadata = {"url": "/subscriptions/{subscriptionId}/providers/Microsoft.Resources/deployments/"} # type: ignore def _delete_initial( # pylint: disable=inconsistent-return-statements - self, - resource_group_name: str, - deployment_name: str, - **kwargs: Any + self, resource_group_name: str, deployment_name: str, **kwargs: Any ) -> None: - cls = kwargs.pop('cls', None) # type: ClsType[None] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) - api_version = kwargs.pop('api_version', "2019-10-01") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - request = build_deployments_delete_request_initial( + api_version = kwargs.pop("api_version", _params.pop("api-version", "2019-10-01")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[None] + + request = build_deployments_delete_request( resource_group_name=resource_group_name, deployment_name=deployment_name, subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self._delete_initial.metadata['url'], + template_url=self._delete_initial.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [202, 204]: @@ -6643,16 +7021,10 @@ 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.Resources/deployments/{deploymentName}"} # type: ignore - + _delete_initial.metadata = {"url": "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/Microsoft.Resources/deployments/{deploymentName}"} # type: ignore @distributed_trace - def begin_delete( # pylint: disable=inconsistent-return-statements - self, - resource_group_name: str, - deployment_name: str, - **kwargs: Any - ) -> LROPoller[None]: + def begin_delete(self, resource_group_name: str, deployment_name: str, **kwargs: Any) -> LROPoller[None]: """Deletes a deployment from the deployment history. A template deployment that is currently running cannot be deleted. Deleting a template @@ -6665,9 +7037,9 @@ def begin_delete( # pylint: disable=inconsistent-return-statements asynchronous request failed, the URI in the Location header returns an error-level status code. :param resource_group_name: The name of the resource group with the deployment to delete. The - name is case insensitive. + name is case insensitive. Required. :type resource_group_name: str - :param deployment_name: The name of the deployment. + :param deployment_name: The name of the deployment. Required. :type deployment_name: str :keyword callable cls: A custom type or function that will be passed the direct response :keyword str continuation_token: A continuation token to restart a poller from a saved state. @@ -6679,88 +7051,93 @@ def begin_delete( # pylint: disable=inconsistent-return-statements Retry-After header is present. :return: An instance of LROPoller that returns either None or the result of cls(response) :rtype: ~azure.core.polling.LROPoller[None] - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - api_version = kwargs.pop('api_version', "2019-10-01") # type: str - polling = kwargs.pop('polling', True) # type: Union[bool, PollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType[None] - lro_delay = kwargs.pop( - 'polling_interval', - self._config.polling_interval - ) - cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2019-10-01")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[None] + polling = kwargs.pop("polling", True) # type: Union[bool, PollingMethod] + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token = kwargs.pop("continuation_token", None) # type: Optional[str] if cont_token is None: - raw_result = self._delete_initial( + raw_result = self._delete_initial( # type: ignore resource_group_name=resource_group_name, deployment_name=deployment_name, api_version=api_version, - cls=lambda x,y,z: x, + cls=lambda x, y, z: x, + headers=_headers, + params=_params, **kwargs ) - kwargs.pop('error_map', None) + kwargs.pop("error_map", None) - def get_long_running_output(pipeline_response): + def get_long_running_output(pipeline_response): # pylint: disable=inconsistent-return-statements if cls: return cls(pipeline_response, None, {}) - - if polling is True: polling_method = ARMPolling(lro_delay, **kwargs) - elif polling is False: polling_method = NoPolling() - else: polling_method = polling + if polling is True: + polling_method = cast(PollingMethod, ARMPolling(lro_delay, **kwargs)) # type: PollingMethod + elif polling is False: + polling_method = cast(PollingMethod, NoPolling()) + else: + polling_method = polling if cont_token: return LROPoller.from_continuation_token( polling_method=polling_method, continuation_token=cont_token, client=self._client, - deserialization_callback=get_long_running_output + deserialization_callback=get_long_running_output, ) return LROPoller(self._client, raw_result, get_long_running_output, polling_method) - begin_delete.metadata = {'url': "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/Microsoft.Resources/deployments/{deploymentName}"} # type: ignore + begin_delete.metadata = {"url": "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/Microsoft.Resources/deployments/{deploymentName}"} # type: ignore @distributed_trace - def check_existence( - self, - resource_group_name: str, - deployment_name: str, - **kwargs: Any - ) -> bool: + def check_existence(self, resource_group_name: str, deployment_name: str, **kwargs: Any) -> bool: """Checks whether the deployment exists. :param resource_group_name: The name of the resource group with the deployment to check. The - name is case insensitive. + name is case insensitive. Required. :type resource_group_name: str - :param deployment_name: The name of the deployment. + :param deployment_name: The name of the deployment. Required. :type deployment_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: bool, or the result of cls(response) + :return: bool or the result of cls(response) :rtype: bool - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType[None] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + 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', "2019-10-01") # type: str + api_version = kwargs.pop("api_version", _params.pop("api-version", "2019-10-01")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[None] - request = build_deployments_check_existence_request( resource_group_name=resource_group_name, deployment_name=deployment_name, subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.check_existence.metadata['url'], + template_url=self.check_existence.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [204, 404]: @@ -6771,44 +7148,53 @@ def check_existence( return cls(pipeline_response, None, {}) return 200 <= response.status_code <= 299 - check_existence.metadata = {'url': "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/Microsoft.Resources/deployments/{deploymentName}"} # type: ignore - + check_existence.metadata = {"url": "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/Microsoft.Resources/deployments/{deploymentName}"} # type: ignore def _create_or_update_initial( - self, - resource_group_name: str, - deployment_name: str, - parameters: "_models.Deployment", - **kwargs: Any - ) -> "_models.DeploymentExtended": - cls = kwargs.pop('cls', None) # type: ClsType["_models.DeploymentExtended"] + self, resource_group_name: str, deployment_name: str, parameters: Union[_models.Deployment, IO], **kwargs: Any + ) -> _models.DeploymentExtended: error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) - api_version = kwargs.pop('api_version', "2019-10-01") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - _json = self._serialize.body(parameters, 'Deployment') + api_version = kwargs.pop("api_version", _params.pop("api-version", "2019-10-01")) # type: str + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.DeploymentExtended] - request = build_deployments_create_or_update_request_initial( + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(parameters, (IO, bytes)): + _content = parameters + else: + _json = self._serialize.body(parameters, "Deployment") + + request = build_deployments_create_or_update_request( resource_group_name=resource_group_name, deployment_name=deployment_name, subscription_id=self._config.subscription_id, api_version=api_version, content_type=content_type, json=_json, - template_url=self._create_or_update_initial.metadata['url'], + content=_content, + template_url=self._create_or_update_initial.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200, 201]: @@ -6816,38 +7202,42 @@ def _create_or_update_initial( raise HttpResponseError(response=response, error_format=ARMErrorFormat) if response.status_code == 200: - deserialized = self._deserialize('DeploymentExtended', pipeline_response) + deserialized = self._deserialize("DeploymentExtended", pipeline_response) if response.status_code == 201: - deserialized = self._deserialize('DeploymentExtended', pipeline_response) + deserialized = self._deserialize("DeploymentExtended", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - _create_or_update_initial.metadata = {'url': "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/Microsoft.Resources/deployments/{deploymentName}"} # type: ignore + _create_or_update_initial.metadata = {"url": "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/Microsoft.Resources/deployments/{deploymentName}"} # type: ignore - - @distributed_trace + @overload def begin_create_or_update( self, resource_group_name: str, deployment_name: str, - parameters: "_models.Deployment", + parameters: _models.Deployment, + *, + content_type: str = "application/json", **kwargs: Any - ) -> LROPoller["_models.DeploymentExtended"]: + ) -> LROPoller[_models.DeploymentExtended]: """Deploys resources to a resource group. You can provide the template and parameters directly in the request or link to JSON files. :param resource_group_name: The name of the resource group to deploy the resources to. The name - is case insensitive. The resource group must already exist. + is case insensitive. The resource group must already exist. Required. :type resource_group_name: str - :param deployment_name: The name of the deployment. + :param deployment_name: The name of the deployment. Required. :type deployment_name: str - :param parameters: Additional parameters supplied to the operation. + :param parameters: Additional parameters supplied to the operation. Required. :type parameters: ~azure.mgmt.resource.resources.v2019_10_01.models.Deployment + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str :keyword callable cls: A custom type or function that will be passed the direct response :keyword str continuation_token: A continuation token to restart a poller from a saved state. :keyword polling: By default, your polling method will be ARMPolling. Pass in False for this @@ -6860,115 +7250,189 @@ def begin_create_or_update( cls(response) :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.resource.resources.v2019_10_01.models.DeploymentExtended] - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - api_version = kwargs.pop('api_version', "2019-10-01") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] - polling = kwargs.pop('polling', True) # type: Union[bool, PollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType["_models.DeploymentExtended"] - lro_delay = kwargs.pop( - 'polling_interval', - self._config.polling_interval - ) - cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] - if cont_token is None: - raw_result = self._create_or_update_initial( - resource_group_name=resource_group_name, - deployment_name=deployment_name, - parameters=parameters, - api_version=api_version, - content_type=content_type, - cls=lambda x,y,z: x, - **kwargs - ) - kwargs.pop('error_map', None) - - def get_long_running_output(pipeline_response): - response = pipeline_response.http_response - deserialized = self._deserialize('DeploymentExtended', pipeline_response) - if cls: - return cls(pipeline_response, deserialized, {}) - return deserialized - - - if polling is True: polling_method = ARMPolling(lro_delay, **kwargs) - elif polling is False: polling_method = NoPolling() - else: polling_method = polling - if cont_token: - return LROPoller.from_continuation_token( - polling_method=polling_method, - continuation_token=cont_token, - client=self._client, - deserialization_callback=get_long_running_output - ) - return LROPoller(self._client, raw_result, get_long_running_output, polling_method) - begin_create_or_update.metadata = {'url': "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/Microsoft.Resources/deployments/{deploymentName}"} # type: ignore - - @distributed_trace - def get( + @overload + def begin_create_or_update( self, resource_group_name: str, deployment_name: str, + parameters: IO, + *, + content_type: str = "application/json", **kwargs: Any - ) -> "_models.DeploymentExtended": - """Gets a deployment. + ) -> LROPoller[_models.DeploymentExtended]: + """Deploys resources to a resource group. - :param resource_group_name: The name of the resource group. The name is case insensitive. + You can provide the template and parameters directly in the request or link to JSON files. + + :param resource_group_name: The name of the resource group to deploy the resources to. The name + is case insensitive. The resource group must already exist. Required. :type resource_group_name: str - :param deployment_name: The name of the deployment. + :param deployment_name: The name of the deployment. Required. :type deployment_name: str + :param parameters: Additional parameters supplied to the operation. Required. + :type parameters: IO + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: DeploymentExtended, or the result of cls(response) - :rtype: ~azure.mgmt.resource.resources.v2019_10_01.models.DeploymentExtended - :raises: ~azure.core.exceptions.HttpResponseError - """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.DeploymentExtended"] - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {})) - - api_version = kwargs.pop('api_version', "2019-10-01") # type: str - - + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be ARMPolling. Pass in False for this + operation to not poll, or pass in your own initialized polling object for a personal polling + strategy. + :paramtype polling: bool or ~azure.core.polling.PollingMethod + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of LROPoller that returns either DeploymentExtended or the result of + cls(response) + :rtype: + ~azure.core.polling.LROPoller[~azure.mgmt.resource.resources.v2019_10_01.models.DeploymentExtended] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace + def begin_create_or_update( + self, resource_group_name: str, deployment_name: str, parameters: Union[_models.Deployment, IO], **kwargs: Any + ) -> LROPoller[_models.DeploymentExtended]: + """Deploys resources to a resource group. + + You can provide the template and parameters directly in the request or link to JSON files. + + :param resource_group_name: The name of the resource group to deploy the resources to. The name + is case insensitive. The resource group must already exist. Required. + :type resource_group_name: str + :param deployment_name: The name of the deployment. Required. + :type deployment_name: str + :param parameters: Additional parameters supplied to the operation. Is either a model type or a + IO type. Required. + :type parameters: ~azure.mgmt.resource.resources.v2019_10_01.models.Deployment or IO + :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. + Default value is None. + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be ARMPolling. Pass in False for this + operation to not poll, or pass in your own initialized polling object for a personal polling + strategy. + :paramtype polling: bool or ~azure.core.polling.PollingMethod + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of LROPoller that returns either DeploymentExtended or the result of + cls(response) + :rtype: + ~azure.core.polling.LROPoller[~azure.mgmt.resource.resources.v2019_10_01.models.DeploymentExtended] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _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", "2019-10-01")) # type: str + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.DeploymentExtended] + polling = kwargs.pop("polling", True) # type: Union[bool, PollingMethod] + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token = kwargs.pop("continuation_token", None) # type: Optional[str] + if cont_token is None: + raw_result = self._create_or_update_initial( # type: ignore + resource_group_name=resource_group_name, + deployment_name=deployment_name, + parameters=parameters, + api_version=api_version, + content_type=content_type, + cls=lambda x, y, z: x, + headers=_headers, + params=_params, + **kwargs + ) + kwargs.pop("error_map", None) + + def get_long_running_output(pipeline_response): + deserialized = self._deserialize("DeploymentExtended", pipeline_response) + if cls: + return cls(pipeline_response, deserialized, {}) + return deserialized + + if polling is True: + polling_method = cast(PollingMethod, ARMPolling(lro_delay, **kwargs)) # type: PollingMethod + elif polling is False: + polling_method = cast(PollingMethod, NoPolling()) + else: + polling_method = polling + if cont_token: + return LROPoller.from_continuation_token( + polling_method=polling_method, + continuation_token=cont_token, + client=self._client, + deserialization_callback=get_long_running_output, + ) + return LROPoller(self._client, raw_result, get_long_running_output, polling_method) + + begin_create_or_update.metadata = {"url": "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/Microsoft.Resources/deployments/{deploymentName}"} # type: ignore + + @distributed_trace + def get(self, resource_group_name: str, deployment_name: str, **kwargs: Any) -> _models.DeploymentExtended: + """Gets a deployment. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param deployment_name: The name of the deployment. Required. + :type deployment_name: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: DeploymentExtended or the result of cls(response) + :rtype: ~azure.mgmt.resource.resources.v2019_10_01.models.DeploymentExtended + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2019-10-01")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[_models.DeploymentExtended] + request = build_deployments_get_request( resource_group_name=resource_group_name, deployment_name=deployment_name, subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.get.metadata['url'], + template_url=self.get.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) - deserialized = self._deserialize('DeploymentExtended', pipeline_response) + deserialized = self._deserialize("DeploymentExtended", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - get.metadata = {'url': "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/Microsoft.Resources/deployments/{deploymentName}"} # type: ignore - + get.metadata = {"url": "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/Microsoft.Resources/deployments/{deploymentName}"} # type: ignore @distributed_trace def cancel( # pylint: disable=inconsistent-return-statements - self, - resource_group_name: str, - deployment_name: str, - **kwargs: Any + self, resource_group_name: str, deployment_name: str, **kwargs: Any ) -> None: """Cancels a currently running template deployment. @@ -6978,38 +7442,45 @@ def cancel( # pylint: disable=inconsistent-return-statements partially deployed. :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. :type resource_group_name: str - :param deployment_name: The name of the deployment. + :param deployment_name: The name of the deployment. Required. :type deployment_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: None, or the result of cls(response) + :return: None or the result of cls(response) :rtype: None - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType[None] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + 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', "2019-10-01") # type: str + api_version = kwargs.pop("api_version", _params.pop("api-version", "2019-10-01")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[None] - request = build_deployments_cancel_request( resource_group_name=resource_group_name, deployment_name=deployment_name, subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.cancel.metadata['url'], + template_url=self.cancel.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [204]: @@ -7019,44 +7490,53 @@ def cancel( # pylint: disable=inconsistent-return-statements if cls: return cls(pipeline_response, None, {}) - cancel.metadata = {'url': "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/Microsoft.Resources/deployments/{deploymentName}/cancel"} # type: ignore - + cancel.metadata = {"url": "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/Microsoft.Resources/deployments/{deploymentName}/cancel"} # type: ignore def _validate_initial( - self, - resource_group_name: str, - deployment_name: str, - parameters: "_models.Deployment", - **kwargs: Any - ) -> Optional["_models.DeploymentValidateResult"]: - cls = kwargs.pop('cls', None) # type: ClsType[Optional["_models.DeploymentValidateResult"]] + self, resource_group_name: str, deployment_name: str, parameters: Union[_models.Deployment, IO], **kwargs: Any + ) -> Optional[_models.DeploymentValidateResult]: error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) - api_version = kwargs.pop('api_version', "2019-10-01") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - _json = self._serialize.body(parameters, 'Deployment') + api_version = kwargs.pop("api_version", _params.pop("api-version", "2019-10-01")) # type: str + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[Optional[_models.DeploymentValidateResult]] - request = build_deployments_validate_request_initial( + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(parameters, (IO, bytes)): + _content = parameters + else: + _json = self._serialize.body(parameters, "Deployment") + + request = build_deployments_validate_request( resource_group_name=resource_group_name, deployment_name=deployment_name, subscription_id=self._config.subscription_id, api_version=api_version, content_type=content_type, json=_json, - template_url=self._validate_initial.metadata['url'], + content=_content, + template_url=self._validate_initial.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200, 202, 400]: @@ -7065,37 +7545,41 @@ def _validate_initial( deserialized = None if response.status_code == 200: - deserialized = self._deserialize('DeploymentValidateResult', pipeline_response) + deserialized = self._deserialize("DeploymentValidateResult", pipeline_response) if response.status_code == 400: - deserialized = self._deserialize('DeploymentValidateResult', pipeline_response) + deserialized = self._deserialize("DeploymentValidateResult", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - _validate_initial.metadata = {'url': "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/Microsoft.Resources/deployments/{deploymentName}/validate"} # type: ignore + _validate_initial.metadata = {"url": "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/Microsoft.Resources/deployments/{deploymentName}/validate"} # type: ignore - - @distributed_trace + @overload def begin_validate( self, resource_group_name: str, deployment_name: str, - parameters: "_models.Deployment", + parameters: _models.Deployment, + *, + content_type: str = "application/json", **kwargs: Any - ) -> LROPoller["_models.DeploymentValidateResult"]: + ) -> LROPoller[_models.DeploymentValidateResult]: """Validates whether the specified template is syntactically correct and will be accepted by Azure Resource Manager.. :param resource_group_name: The name of the resource group the template will be deployed to. - The name is case insensitive. + The name is case insensitive. Required. :type resource_group_name: str - :param deployment_name: The name of the deployment. + :param deployment_name: The name of the deployment. Required. :type deployment_name: str - :param parameters: Parameters to validate. + :param parameters: Parameters to validate. Required. :type parameters: ~azure.mgmt.resource.resources.v2019_10_01.models.Deployment + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str :keyword callable cls: A custom type or function that will be passed the direct response :keyword str continuation_token: A continuation token to restart a poller from a saved state. :keyword polling: By default, your polling method will be ARMPolling. Pass in False for this @@ -7108,86 +7592,173 @@ def begin_validate( cls(response) :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.resource.resources.v2019_10_01.models.DeploymentValidateResult] - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - api_version = kwargs.pop('api_version', "2019-10-01") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] - polling = kwargs.pop('polling', True) # type: Union[bool, PollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType["_models.DeploymentValidateResult"] - lro_delay = kwargs.pop( - 'polling_interval', - self._config.polling_interval - ) - cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] + + @overload + def begin_validate( + self, + resource_group_name: str, + deployment_name: str, + parameters: IO, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> LROPoller[_models.DeploymentValidateResult]: + """Validates whether the specified template is syntactically correct and will be accepted by Azure + Resource Manager.. + + :param resource_group_name: The name of the resource group the template will be deployed to. + The name is case insensitive. Required. + :type resource_group_name: str + :param deployment_name: The name of the deployment. Required. + :type deployment_name: str + :param parameters: Parameters to validate. Required. + :type parameters: IO + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be ARMPolling. Pass in False for this + operation to not poll, or pass in your own initialized polling object for a personal polling + strategy. + :paramtype polling: bool or ~azure.core.polling.PollingMethod + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of LROPoller that returns either DeploymentValidateResult or the result of + cls(response) + :rtype: + ~azure.core.polling.LROPoller[~azure.mgmt.resource.resources.v2019_10_01.models.DeploymentValidateResult] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace + def begin_validate( + self, resource_group_name: str, deployment_name: str, parameters: Union[_models.Deployment, IO], **kwargs: Any + ) -> LROPoller[_models.DeploymentValidateResult]: + """Validates whether the specified template is syntactically correct and will be accepted by Azure + Resource Manager.. + + :param resource_group_name: The name of the resource group the template will be deployed to. + The name is case insensitive. Required. + :type resource_group_name: str + :param deployment_name: The name of the deployment. Required. + :type deployment_name: str + :param parameters: Parameters to validate. Is either a model type or a IO type. Required. + :type parameters: ~azure.mgmt.resource.resources.v2019_10_01.models.Deployment or IO + :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. + Default value is None. + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be ARMPolling. Pass in False for this + operation to not poll, or pass in your own initialized polling object for a personal polling + strategy. + :paramtype polling: bool or ~azure.core.polling.PollingMethod + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of LROPoller that returns either DeploymentValidateResult or the result of + cls(response) + :rtype: + ~azure.core.polling.LROPoller[~azure.mgmt.resource.resources.v2019_10_01.models.DeploymentValidateResult] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _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", "2019-10-01")) # type: str + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.DeploymentValidateResult] + polling = kwargs.pop("polling", True) # type: Union[bool, PollingMethod] + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token = kwargs.pop("continuation_token", None) # type: Optional[str] if cont_token is None: - raw_result = self._validate_initial( + raw_result = self._validate_initial( # type: ignore resource_group_name=resource_group_name, deployment_name=deployment_name, parameters=parameters, api_version=api_version, content_type=content_type, - cls=lambda x,y,z: x, + cls=lambda x, y, z: x, + headers=_headers, + params=_params, **kwargs ) - kwargs.pop('error_map', None) + kwargs.pop("error_map", None) def get_long_running_output(pipeline_response): - response = pipeline_response.http_response - deserialized = self._deserialize('DeploymentValidateResult', pipeline_response) + deserialized = self._deserialize("DeploymentValidateResult", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - - if polling is True: polling_method = ARMPolling(lro_delay, **kwargs) - elif polling is False: polling_method = NoPolling() - else: polling_method = polling + if polling is True: + polling_method = cast(PollingMethod, ARMPolling(lro_delay, **kwargs)) # type: PollingMethod + elif polling is False: + polling_method = cast(PollingMethod, NoPolling()) + else: + polling_method = polling if cont_token: return LROPoller.from_continuation_token( polling_method=polling_method, continuation_token=cont_token, client=self._client, - deserialization_callback=get_long_running_output + deserialization_callback=get_long_running_output, ) return LROPoller(self._client, raw_result, get_long_running_output, polling_method) - begin_validate.metadata = {'url': "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/Microsoft.Resources/deployments/{deploymentName}/validate"} # type: ignore + begin_validate.metadata = {"url": "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/Microsoft.Resources/deployments/{deploymentName}/validate"} # type: ignore def _what_if_initial( self, resource_group_name: str, deployment_name: str, - parameters: "_models.DeploymentWhatIf", + parameters: Union[_models.DeploymentWhatIf, IO], **kwargs: Any - ) -> Optional["_models.WhatIfOperationResult"]: - cls = kwargs.pop('cls', None) # type: ClsType[Optional["_models.WhatIfOperationResult"]] + ) -> Optional[_models.WhatIfOperationResult]: error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', "2019-10-01") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + api_version = kwargs.pop("api_version", _params.pop("api-version", "2019-10-01")) # type: str + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[Optional[_models.WhatIfOperationResult]] - _json = self._serialize.body(parameters, 'DeploymentWhatIf') + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(parameters, (IO, bytes)): + _content = parameters + else: + _json = self._serialize.body(parameters, "DeploymentWhatIf") - request = build_deployments_what_if_request_initial( + request = build_deployments_what_if_request( resource_group_name=resource_group_name, deployment_name=deployment_name, subscription_id=self._config.subscription_id, api_version=api_version, content_type=content_type, json=_json, - template_url=self._what_if_initial.metadata['url'], + content=_content, + template_url=self._what_if_initial.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200, 202]: @@ -7197,39 +7768,116 @@ def _what_if_initial( deserialized = None response_headers = {} if response.status_code == 200: - deserialized = self._deserialize('WhatIfOperationResult', pipeline_response) + deserialized = self._deserialize("WhatIfOperationResult", pipeline_response) if response.status_code == 202: - response_headers['Location']=self._deserialize('str', response.headers.get('Location')) - response_headers['Retry-After']=self._deserialize('str', response.headers.get('Retry-After')) - + response_headers["Location"] = self._deserialize("str", response.headers.get("Location")) + response_headers["Retry-After"] = self._deserialize("str", response.headers.get("Retry-After")) if cls: return cls(pipeline_response, deserialized, response_headers) return deserialized - _what_if_initial.metadata = {'url': "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/Microsoft.Resources/deployments/{deploymentName}/whatIf"} # type: ignore + _what_if_initial.metadata = {"url": "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/Microsoft.Resources/deployments/{deploymentName}/whatIf"} # type: ignore + + @overload + def begin_what_if( + self, + resource_group_name: str, + deployment_name: str, + parameters: _models.DeploymentWhatIf, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> LROPoller[_models.WhatIfOperationResult]: + """Returns changes that will be made by the deployment if executed at the scope of the resource + group. + + :param resource_group_name: The name of the resource group the template will be deployed to. + The name is case insensitive. Required. + :type resource_group_name: str + :param deployment_name: The name of the deployment. Required. + :type deployment_name: str + :param parameters: Parameters to validate. Required. + :type parameters: ~azure.mgmt.resource.resources.v2019_10_01.models.DeploymentWhatIf + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be ARMPolling. Pass in False for this + operation to not poll, or pass in your own initialized polling object for a personal polling + strategy. + :paramtype polling: bool or ~azure.core.polling.PollingMethod + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of LROPoller that returns either WhatIfOperationResult or the result of + cls(response) + :rtype: + ~azure.core.polling.LROPoller[~azure.mgmt.resource.resources.v2019_10_01.models.WhatIfOperationResult] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + def begin_what_if( + self, + resource_group_name: str, + deployment_name: str, + parameters: IO, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> LROPoller[_models.WhatIfOperationResult]: + """Returns changes that will be made by the deployment if executed at the scope of the resource + group. + :param resource_group_name: The name of the resource group the template will be deployed to. + The name is case insensitive. Required. + :type resource_group_name: str + :param deployment_name: The name of the deployment. Required. + :type deployment_name: str + :param parameters: Parameters to validate. Required. + :type parameters: IO + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be ARMPolling. Pass in False for this + operation to not poll, or pass in your own initialized polling object for a personal polling + strategy. + :paramtype polling: bool or ~azure.core.polling.PollingMethod + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of LROPoller that returns either WhatIfOperationResult or the result of + cls(response) + :rtype: + ~azure.core.polling.LROPoller[~azure.mgmt.resource.resources.v2019_10_01.models.WhatIfOperationResult] + :raises ~azure.core.exceptions.HttpResponseError: + """ @distributed_trace def begin_what_if( self, resource_group_name: str, deployment_name: str, - parameters: "_models.DeploymentWhatIf", + parameters: Union[_models.DeploymentWhatIf, IO], **kwargs: Any - ) -> LROPoller["_models.WhatIfOperationResult"]: + ) -> LROPoller[_models.WhatIfOperationResult]: """Returns changes that will be made by the deployment if executed at the scope of the resource group. :param resource_group_name: The name of the resource group the template will be deployed to. - The name is case insensitive. + The name is case insensitive. Required. :type resource_group_name: str - :param deployment_name: The name of the deployment. + :param deployment_name: The name of the deployment. Required. :type deployment_name: str - :param parameters: Parameters to validate. - :type parameters: ~azure.mgmt.resource.resources.v2019_10_01.models.DeploymentWhatIf + :param parameters: Parameters to validate. Is either a model type or a IO type. Required. + :type parameters: ~azure.mgmt.resource.resources.v2019_10_01.models.DeploymentWhatIf or IO + :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. + Default value is None. + :paramtype content_type: str :keyword callable cls: A custom type or function that will be passed the direct response :keyword str continuation_token: A continuation token to restart a poller from a saved state. :keyword polling: By default, your polling method will be ARMPolling. Pass in False for this @@ -7242,121 +7890,125 @@ def begin_what_if( cls(response) :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.resource.resources.v2019_10_01.models.WhatIfOperationResult] - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - api_version = kwargs.pop('api_version', "2019-10-01") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] - polling = kwargs.pop('polling', True) # type: Union[bool, PollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType["_models.WhatIfOperationResult"] - lro_delay = kwargs.pop( - 'polling_interval', - self._config.polling_interval - ) - cont_token = kwargs.pop('continuation_token', None) # type: Optional[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", "2019-10-01")) # type: str + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.WhatIfOperationResult] + polling = kwargs.pop("polling", True) # type: Union[bool, PollingMethod] + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token = kwargs.pop("continuation_token", None) # type: Optional[str] if cont_token is None: - raw_result = self._what_if_initial( + raw_result = self._what_if_initial( # type: ignore resource_group_name=resource_group_name, deployment_name=deployment_name, parameters=parameters, api_version=api_version, content_type=content_type, - cls=lambda x,y,z: x, + cls=lambda x, y, z: x, + headers=_headers, + params=_params, **kwargs ) - kwargs.pop('error_map', None) + kwargs.pop("error_map", None) def get_long_running_output(pipeline_response): - response = pipeline_response.http_response - deserialized = self._deserialize('WhatIfOperationResult', pipeline_response) + deserialized = self._deserialize("WhatIfOperationResult", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - - if polling is True: polling_method = ARMPolling(lro_delay, lro_options={'final-state-via': 'location'}, **kwargs) - elif polling is False: polling_method = NoPolling() - else: polling_method = polling + if polling is True: + polling_method = cast( + PollingMethod, ARMPolling(lro_delay, lro_options={"final-state-via": "location"}, **kwargs) + ) # type: PollingMethod + elif polling is False: + polling_method = cast(PollingMethod, NoPolling()) + else: + polling_method = polling if cont_token: return LROPoller.from_continuation_token( polling_method=polling_method, continuation_token=cont_token, client=self._client, - deserialization_callback=get_long_running_output + deserialization_callback=get_long_running_output, ) return LROPoller(self._client, raw_result, get_long_running_output, polling_method) - begin_what_if.metadata = {'url': "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/Microsoft.Resources/deployments/{deploymentName}/whatIf"} # type: ignore + begin_what_if.metadata = {"url": "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/Microsoft.Resources/deployments/{deploymentName}/whatIf"} # type: ignore @distributed_trace def export_template( - self, - resource_group_name: str, - deployment_name: str, - **kwargs: Any - ) -> "_models.DeploymentExportResult": + self, resource_group_name: str, deployment_name: str, **kwargs: Any + ) -> _models.DeploymentExportResult: """Exports the template used for specified deployment. :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. :type resource_group_name: str - :param deployment_name: The name of the deployment. + :param deployment_name: The name of the deployment. Required. :type deployment_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: DeploymentExportResult, or the result of cls(response) + :return: DeploymentExportResult or the result of cls(response) :rtype: ~azure.mgmt.resource.resources.v2019_10_01.models.DeploymentExportResult - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.DeploymentExportResult"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) - api_version = kwargs.pop('api_version', "2019-10-01") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2019-10-01")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[_models.DeploymentExportResult] - request = build_deployments_export_template_request( resource_group_name=resource_group_name, deployment_name=deployment_name, subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.export_template.metadata['url'], + template_url=self.export_template.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) - deserialized = self._deserialize('DeploymentExportResult', pipeline_response) + deserialized = self._deserialize("DeploymentExportResult", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - export_template.metadata = {'url': "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/Microsoft.Resources/deployments/{deploymentName}/exportTemplate"} # type: ignore - + export_template.metadata = {"url": "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/Microsoft.Resources/deployments/{deploymentName}/exportTemplate"} # type: ignore @distributed_trace def list_by_resource_group( - self, - resource_group_name: str, - filter: Optional[str] = None, - top: Optional[int] = None, - **kwargs: Any - ) -> Iterable["_models.DeploymentListResult"]: + self, resource_group_name: str, filter: Optional[str] = None, top: Optional[int] = None, **kwargs: Any + ) -> Iterable["_models.DeploymentExtended"]: """Get all the deployments for a resource group. :param resource_group_name: The name of the resource group with the deployments to get. The - name is case insensitive. + name is case insensitive. Required. :type resource_group_name: str :param filter: The filter to apply on the operation. For example, you can use $filter=provisioningState eq '{state}'. Default value is None. @@ -7365,42 +8017,49 @@ def list_by_resource_group( value is None. :type top: int :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either DeploymentListResult or the result of - cls(response) + :return: An iterator like instance of either DeploymentExtended or the result of cls(response) :rtype: - ~azure.core.paging.ItemPaged[~azure.mgmt.resource.resources.v2019_10_01.models.DeploymentListResult] - :raises: ~azure.core.exceptions.HttpResponseError + ~azure.core.paging.ItemPaged[~azure.mgmt.resource.resources.v2019_10_01.models.DeploymentExtended] + :raises ~azure.core.exceptions.HttpResponseError: """ - api_version = kwargs.pop('api_version', "2019-10-01") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2019-10-01")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[_models.DeploymentListResult] - cls = kwargs.pop('cls', None) # type: ClsType["_models.DeploymentListResult"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) + def prepare_request(next_link=None): if not next_link: - + request = build_deployments_list_by_resource_group_request( resource_group_name=resource_group_name, subscription_id=self._config.subscription_id, - api_version=api_version, filter=filter, top=top, - template_url=self.list_by_resource_group.metadata['url'], + 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.url = self._client.format_url(request.url) # type: ignore else: - - request = build_deployments_list_by_resource_group_request( - resource_group_name=resource_group_name, - subscription_id=self._config.subscription_id, - template_url=next_link, - ) + # make call to next link with the client's api-version + _parsed_next_link = urlparse(next_link) + _next_request_params = case_insensitive_dict(parse_qs(_parsed_next_link.query)) + _next_request_params["api-version"] = self._config.api_version + request = HttpRequest("GET", urljoin(next_link, _parsed_next_link.path), params=_next_request_params) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore request.method = "GET" return request @@ -7414,10 +8073,8 @@ def extract_data(pipeline_response): def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) response = pipeline_response.http_response @@ -7427,204 +8084,204 @@ def get_next(next_link=None): return pipeline_response + return ItemPaged(get_next, extract_data) - return ItemPaged( - get_next, extract_data - ) - list_by_resource_group.metadata = {'url': "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/Microsoft.Resources/deployments/"} # type: ignore + list_by_resource_group.metadata = {"url": "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/Microsoft.Resources/deployments/"} # type: ignore @distributed_trace - def calculate_template_hash( - self, - template: Any, - **kwargs: Any - ) -> "_models.TemplateHashResult": + def calculate_template_hash(self, template: JSON, **kwargs: Any) -> _models.TemplateHashResult: """Calculate the hash of the given template. - :param template: The template provided to calculate hash. - :type template: any + :param template: The template provided to calculate hash. Required. + :type template: JSON :keyword callable cls: A custom type or function that will be passed the direct response - :return: TemplateHashResult, or the result of cls(response) + :return: TemplateHashResult or the result of cls(response) :rtype: ~azure.mgmt.resource.resources.v2019_10_01.models.TemplateHashResult - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.TemplateHashResult"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) - api_version = kwargs.pop('api_version', "2019-10-01") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - _json = self._serialize.body(template, 'object') + api_version = kwargs.pop("api_version", _params.pop("api-version", "2019-10-01")) # type: str + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", "application/json")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[_models.TemplateHashResult] + + _json = self._serialize.body(template, "object") request = build_deployments_calculate_template_hash_request( api_version=api_version, content_type=content_type, json=_json, - template_url=self.calculate_template_hash.metadata['url'], + template_url=self.calculate_template_hash.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) - deserialized = self._deserialize('TemplateHashResult', pipeline_response) + deserialized = self._deserialize("TemplateHashResult", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - calculate_template_hash.metadata = {'url': "/providers/Microsoft.Resources/calculateTemplateHash"} # type: ignore + calculate_template_hash.metadata = {"url": "/providers/Microsoft.Resources/calculateTemplateHash"} # type: ignore -class ProvidersOperations(object): - """ProvidersOperations operations. - You should not instantiate this class directly. Instead, you should create a Client instance that - instantiates it for you and attaches it as an attribute. +class ProvidersOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. - :ivar models: Alias to model classes used in this operation group. - :type models: ~azure.mgmt.resource.resources.v2019_10_01.models - :param client: Client for service requests. - :param config: Configuration of service client. - :param serializer: An object model serializer. - :param deserializer: An object model deserializer. + Instead, you should access the following operations through + :class:`~azure.mgmt.resource.resources.v2019_10_01.ResourceManagementClient`'s + :attr:`providers` attribute. """ models = _models - def __init__(self, client, config, serializer, deserializer): - self._client = client - self._serialize = serializer - self._deserialize = deserializer - self._config = config + def __init__(self, *args, **kwargs): + input_args = list(args) + self._client = input_args.pop(0) if input_args else kwargs.pop("client") + self._config = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") @distributed_trace - def unregister( - self, - resource_provider_namespace: str, - **kwargs: Any - ) -> "_models.Provider": + def unregister(self, resource_provider_namespace: str, **kwargs: Any) -> _models.Provider: """Unregisters a subscription from a resource provider. :param resource_provider_namespace: The namespace of the resource provider to unregister. + Required. :type resource_provider_namespace: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: Provider, or the result of cls(response) + :return: Provider or the result of cls(response) :rtype: ~azure.mgmt.resource.resources.v2019_10_01.models.Provider - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.Provider"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) - api_version = kwargs.pop('api_version', "2019-10-01") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2019-10-01")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[_models.Provider] - request = build_providers_unregister_request( resource_provider_namespace=resource_provider_namespace, subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.unregister.metadata['url'], + template_url=self.unregister.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) - deserialized = self._deserialize('Provider', pipeline_response) + deserialized = self._deserialize("Provider", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - unregister.metadata = {'url': "/subscriptions/{subscriptionId}/providers/{resourceProviderNamespace}/unregister"} # type: ignore - + unregister.metadata = {"url": "/subscriptions/{subscriptionId}/providers/{resourceProviderNamespace}/unregister"} # type: ignore @distributed_trace - def register( - self, - resource_provider_namespace: str, - **kwargs: Any - ) -> "_models.Provider": + def register(self, resource_provider_namespace: str, **kwargs: Any) -> _models.Provider: """Registers a subscription with a resource provider. :param resource_provider_namespace: The namespace of the resource provider to register. + Required. :type resource_provider_namespace: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: Provider, or the result of cls(response) + :return: Provider or the result of cls(response) :rtype: ~azure.mgmt.resource.resources.v2019_10_01.models.Provider - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.Provider"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) - api_version = kwargs.pop('api_version', "2019-10-01") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2019-10-01")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[_models.Provider] - request = build_providers_register_request( resource_provider_namespace=resource_provider_namespace, subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.register.metadata['url'], + template_url=self.register.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) - deserialized = self._deserialize('Provider', pipeline_response) + deserialized = self._deserialize("Provider", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - register.metadata = {'url': "/subscriptions/{subscriptionId}/providers/{resourceProviderNamespace}/register"} # type: ignore - + register.metadata = {"url": "/subscriptions/{subscriptionId}/providers/{resourceProviderNamespace}/register"} # type: ignore @distributed_trace def list( - self, - top: Optional[int] = None, - expand: Optional[str] = None, - **kwargs: Any - ) -> Iterable["_models.ProviderListResult"]: + self, top: Optional[int] = None, expand: Optional[str] = None, **kwargs: Any + ) -> Iterable["_models.Provider"]: """Gets all resource providers for a subscription. :param top: The number of results to return. If null is passed returns all deployments. Default @@ -7635,39 +8292,48 @@ def list( response, use $expand=resourceTypes/aliases. Default value is None. :type expand: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either ProviderListResult or the result of cls(response) + :return: An iterator like instance of either Provider or the result of cls(response) :rtype: - ~azure.core.paging.ItemPaged[~azure.mgmt.resource.resources.v2019_10_01.models.ProviderListResult] - :raises: ~azure.core.exceptions.HttpResponseError + ~azure.core.paging.ItemPaged[~azure.mgmt.resource.resources.v2019_10_01.models.Provider] + :raises ~azure.core.exceptions.HttpResponseError: """ - api_version = kwargs.pop('api_version', "2019-10-01") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2019-10-01")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[_models.ProviderListResult] - cls = kwargs.pop('cls', None) # type: ClsType["_models.ProviderListResult"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) + def prepare_request(next_link=None): if not next_link: - + request = build_providers_list_request( subscription_id=self._config.subscription_id, - api_version=api_version, top=top, expand=expand, - template_url=self.list.metadata['url'], + 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.url = self._client.format_url(request.url) # type: ignore else: - - request = build_providers_list_request( - subscription_id=self._config.subscription_id, - template_url=next_link, - ) + # make call to next link with the client's api-version + _parsed_next_link = urlparse(next_link) + _next_request_params = case_insensitive_dict(parse_qs(_parsed_next_link.query)) + _next_request_params["api-version"] = self._config.api_version + request = HttpRequest("GET", urljoin(next_link, _parsed_next_link.path), params=_next_request_params) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore request.method = "GET" return request @@ -7681,10 +8347,8 @@ def extract_data(pipeline_response): def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) response = pipeline_response.http_response @@ -7694,19 +8358,14 @@ def get_next(next_link=None): return pipeline_response + return ItemPaged(get_next, extract_data) - return ItemPaged( - get_next, extract_data - ) - list.metadata = {'url': "/subscriptions/{subscriptionId}/providers"} # type: ignore + list.metadata = {"url": "/subscriptions/{subscriptionId}/providers"} # type: ignore @distributed_trace def list_at_tenant_scope( - self, - top: Optional[int] = None, - expand: Optional[str] = None, - **kwargs: Any - ) -> Iterable["_models.ProviderListResult"]: + self, top: Optional[int] = None, expand: Optional[str] = None, **kwargs: Any + ) -> Iterable["_models.Provider"]: """Gets all resource providers for the tenant. :param top: The number of results to return. If null is passed returns all providers. Default @@ -7717,37 +8376,47 @@ def list_at_tenant_scope( response, use $expand=resourceTypes/aliases. Default value is None. :type expand: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either ProviderListResult or the result of cls(response) + :return: An iterator like instance of either Provider or the result of cls(response) :rtype: - ~azure.core.paging.ItemPaged[~azure.mgmt.resource.resources.v2019_10_01.models.ProviderListResult] - :raises: ~azure.core.exceptions.HttpResponseError + ~azure.core.paging.ItemPaged[~azure.mgmt.resource.resources.v2019_10_01.models.Provider] + :raises ~azure.core.exceptions.HttpResponseError: """ - api_version = kwargs.pop('api_version', "2019-10-01") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2019-10-01")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[_models.ProviderListResult] - cls = kwargs.pop('cls', None) # type: ClsType["_models.ProviderListResult"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) + def prepare_request(next_link=None): if not next_link: - + request = build_providers_list_at_tenant_scope_request( - api_version=api_version, top=top, expand=expand, - template_url=self.list_at_tenant_scope.metadata['url'], + api_version=api_version, + template_url=self.list_at_tenant_scope.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore else: - - request = build_providers_list_at_tenant_scope_request( - template_url=next_link, - ) + # make call to next link with the client's api-version + _parsed_next_link = urlparse(next_link) + _next_request_params = case_insensitive_dict(parse_qs(_parsed_next_link.query)) + _next_request_params["api-version"] = self._config.api_version + request = HttpRequest("GET", urljoin(next_link, _parsed_next_link.path), params=_next_request_params) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore request.method = "GET" return request @@ -7761,10 +8430,8 @@ def extract_data(pipeline_response): def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) response = pipeline_response.http_response @@ -7774,149 +8441,148 @@ def get_next(next_link=None): return pipeline_response + return ItemPaged(get_next, extract_data) - return ItemPaged( - get_next, extract_data - ) - list_at_tenant_scope.metadata = {'url': "/providers"} # type: ignore + list_at_tenant_scope.metadata = {"url": "/providers"} # type: ignore @distributed_trace - def get( - self, - resource_provider_namespace: str, - expand: Optional[str] = None, - **kwargs: Any - ) -> "_models.Provider": + def get(self, resource_provider_namespace: str, expand: Optional[str] = None, **kwargs: Any) -> _models.Provider: """Gets the specified resource provider. - :param resource_provider_namespace: The namespace of the resource provider. + :param resource_provider_namespace: The namespace of the resource provider. Required. :type resource_provider_namespace: str :param expand: The $expand query parameter. For example, to include property aliases in response, use $expand=resourceTypes/aliases. Default value is None. :type expand: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: Provider, or the result of cls(response) + :return: Provider or the result of cls(response) :rtype: ~azure.mgmt.resource.resources.v2019_10_01.models.Provider - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.Provider"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + 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', "2019-10-01") # type: str + api_version = kwargs.pop("api_version", _params.pop("api-version", "2019-10-01")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[_models.Provider] - request = build_providers_get_request( resource_provider_namespace=resource_provider_namespace, subscription_id=self._config.subscription_id, - api_version=api_version, expand=expand, - template_url=self.get.metadata['url'], + api_version=api_version, + template_url=self.get.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) - deserialized = self._deserialize('Provider', pipeline_response) + deserialized = self._deserialize("Provider", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - get.metadata = {'url': "/subscriptions/{subscriptionId}/providers/{resourceProviderNamespace}"} # type: ignore - + get.metadata = {"url": "/subscriptions/{subscriptionId}/providers/{resourceProviderNamespace}"} # type: ignore @distributed_trace def get_at_tenant_scope( - self, - resource_provider_namespace: str, - expand: Optional[str] = None, - **kwargs: Any - ) -> "_models.Provider": + self, resource_provider_namespace: str, expand: Optional[str] = None, **kwargs: Any + ) -> _models.Provider: """Gets the specified resource provider at the tenant level. - :param resource_provider_namespace: The namespace of the resource provider. + :param resource_provider_namespace: The namespace of the resource provider. Required. :type resource_provider_namespace: str :param expand: The $expand query parameter. For example, to include property aliases in response, use $expand=resourceTypes/aliases. Default value is None. :type expand: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: Provider, or the result of cls(response) + :return: Provider or the result of cls(response) :rtype: ~azure.mgmt.resource.resources.v2019_10_01.models.Provider - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.Provider"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) - api_version = kwargs.pop('api_version', "2019-10-01") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2019-10-01")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[_models.Provider] - request = build_providers_get_at_tenant_scope_request( resource_provider_namespace=resource_provider_namespace, - api_version=api_version, expand=expand, - template_url=self.get_at_tenant_scope.metadata['url'], + api_version=api_version, + template_url=self.get_at_tenant_scope.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) - deserialized = self._deserialize('Provider', pipeline_response) + deserialized = self._deserialize("Provider", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - get_at_tenant_scope.metadata = {'url': "/providers/{resourceProviderNamespace}"} # type: ignore + get_at_tenant_scope.metadata = {"url": "/providers/{resourceProviderNamespace}"} # type: ignore -class ResourcesOperations(object): # pylint: disable=too-many-public-methods - """ResourcesOperations operations. - You should not instantiate this class directly. Instead, you should create a Client instance that - instantiates it for you and attaches it as an attribute. +class ResourcesOperations: # pylint: disable=too-many-public-methods + """ + .. warning:: + **DO NOT** instantiate this class directly. - :ivar models: Alias to model classes used in this operation group. - :type models: ~azure.mgmt.resource.resources.v2019_10_01.models - :param client: Client for service requests. - :param config: Configuration of service client. - :param serializer: An object model serializer. - :param deserializer: An object model deserializer. + Instead, you should access the following operations through + :class:`~azure.mgmt.resource.resources.v2019_10_01.ResourceManagementClient`'s + :attr:`resources` attribute. """ models = _models - def __init__(self, client, config, serializer, deserializer): - self._client = client - self._serialize = serializer - self._deserialize = deserializer - self._config = config + def __init__(self, *args, **kwargs): + input_args = list(args) + self._client = input_args.pop(0) if input_args else kwargs.pop("client") + self._config = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") @distributed_trace def list_by_resource_group( @@ -7926,10 +8592,10 @@ def list_by_resource_group( expand: Optional[str] = None, top: Optional[int] = None, **kwargs: Any - ) -> Iterable["_models.ResourceListResult"]: + ) -> Iterable["_models.GenericResourceExpanded"]: """Get all the resources for a resource group. - :param resource_group_name: The resource group with the resources to get. + :param resource_group_name: The resource group with the resources to get. Required. :type resource_group_name: str :param filter: The filter to apply on the operation.:code:`
`:code:`
`The properties you can use for eq (equals) or ne (not equals) are: location, resourceType, name, resourceGroup, @@ -7955,42 +8621,51 @@ def list_by_resource_group( value is None. :type top: int :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either ResourceListResult or the result of cls(response) + :return: An iterator like instance of either GenericResourceExpanded or the result of + cls(response) :rtype: - ~azure.core.paging.ItemPaged[~azure.mgmt.resource.resources.v2019_10_01.models.ResourceListResult] - :raises: ~azure.core.exceptions.HttpResponseError + ~azure.core.paging.ItemPaged[~azure.mgmt.resource.resources.v2019_10_01.models.GenericResourceExpanded] + :raises ~azure.core.exceptions.HttpResponseError: """ - api_version = kwargs.pop('api_version', "2019-10-01") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2019-10-01")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[_models.ResourceListResult] - cls = kwargs.pop('cls', None) # type: ClsType["_models.ResourceListResult"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) + def prepare_request(next_link=None): if not next_link: - + request = build_resources_list_by_resource_group_request( resource_group_name=resource_group_name, subscription_id=self._config.subscription_id, - api_version=api_version, filter=filter, expand=expand, top=top, - template_url=self.list_by_resource_group.metadata['url'], + 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.url = self._client.format_url(request.url) # type: ignore else: - - request = build_resources_list_by_resource_group_request( - resource_group_name=resource_group_name, - subscription_id=self._config.subscription_id, - template_url=next_link, - ) + # make call to next link with the client's api-version + _parsed_next_link = urlparse(next_link) + _next_request_params = case_insensitive_dict(parse_qs(_parsed_next_link.query)) + _next_request_params["api-version"] = self._config.api_version + request = HttpRequest("GET", urljoin(next_link, _parsed_next_link.path), params=_next_request_params) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore request.method = "GET" return request @@ -8004,10 +8679,8 @@ def extract_data(pipeline_response): def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) response = pipeline_response.http_response @@ -8017,45 +8690,54 @@ def get_next(next_link=None): return pipeline_response + return ItemPaged(get_next, extract_data) - return ItemPaged( - get_next, extract_data - ) - list_by_resource_group.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/resources"} # type: ignore + list_by_resource_group.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/resources"} # type: ignore def _move_resources_initial( # pylint: disable=inconsistent-return-statements - self, - source_resource_group_name: str, - parameters: "_models.ResourcesMoveInfo", - **kwargs: Any + self, source_resource_group_name: str, parameters: Union[_models.ResourcesMoveInfo, IO], **kwargs: Any ) -> None: - cls = kwargs.pop('cls', None) # type: ClsType[None] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) - api_version = kwargs.pop('api_version', "2019-10-01") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - _json = self._serialize.body(parameters, 'ResourcesMoveInfo') + api_version = kwargs.pop("api_version", _params.pop("api-version", "2019-10-01")) # type: str + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[None] - request = build_resources_move_resources_request_initial( + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(parameters, (IO, bytes)): + _content = parameters + else: + _json = self._serialize.body(parameters, "ResourcesMoveInfo") + + request = build_resources_move_resources_request( source_resource_group_name=source_resource_group_name, subscription_id=self._config.subscription_id, api_version=api_version, content_type=content_type, json=_json, - template_url=self._move_resources_initial.metadata['url'], + content=_content, + template_url=self._move_resources_initial.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [202, 204]: @@ -8065,14 +8747,15 @@ def _move_resources_initial( # pylint: disable=inconsistent-return-statements if cls: return cls(pipeline_response, None, {}) - _move_resources_initial.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{sourceResourceGroupName}/moveResources"} # type: ignore + _move_resources_initial.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{sourceResourceGroupName}/moveResources"} # type: ignore - - @distributed_trace - def begin_move_resources( # pylint: disable=inconsistent-return-statements + @overload + def begin_move_resources( self, source_resource_group_name: str, - parameters: "_models.ResourcesMoveInfo", + parameters: _models.ResourcesMoveInfo, + *, + content_type: str = "application/json", **kwargs: Any ) -> LROPoller[None]: """Moves resources from one resource group to another resource group. @@ -8083,10 +8766,13 @@ def begin_move_resources( # pylint: disable=inconsistent-return-statements the groups until the move completes. :param source_resource_group_name: The name of the resource group containing the resources to - move. + move. Required. :type source_resource_group_name: str - :param parameters: Parameters for moving resources. + :param parameters: Parameters for moving resources. Required. :type parameters: ~azure.mgmt.resource.resources.v2019_10_01.models.ResourcesMoveInfo + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str :keyword callable cls: A custom type or function that will be passed the direct response :keyword str continuation_token: A continuation token to restart a poller from a saved state. :keyword polling: By default, your polling method will be ARMPolling. Pass in False for this @@ -8097,80 +8783,160 @@ def begin_move_resources( # pylint: disable=inconsistent-return-statements Retry-After header is present. :return: An instance of LROPoller that returns either None or the result of cls(response) :rtype: ~azure.core.polling.LROPoller[None] - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - api_version = kwargs.pop('api_version', "2019-10-01") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] - polling = kwargs.pop('polling', True) # type: Union[bool, PollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType[None] - lro_delay = kwargs.pop( - 'polling_interval', - self._config.polling_interval - ) - cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] + + @overload + def begin_move_resources( + self, source_resource_group_name: str, parameters: IO, *, content_type: str = "application/json", **kwargs: Any + ) -> LROPoller[None]: + """Moves resources from one resource group to another resource group. + + The resources to move must be in the same source resource group. The target resource group may + be in a different subscription. When moving resources, both the source group and the target + group are locked for the duration of the operation. Write and delete operations are blocked on + the groups until the move completes. + + :param source_resource_group_name: The name of the resource group containing the resources to + move. Required. + :type source_resource_group_name: str + :param parameters: Parameters for moving resources. Required. + :type parameters: IO + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be ARMPolling. Pass in False for this + operation to not poll, or pass in your own initialized polling object for a personal polling + strategy. + :paramtype polling: bool or ~azure.core.polling.PollingMethod + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of LROPoller that returns either None or the result of cls(response) + :rtype: ~azure.core.polling.LROPoller[None] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace + def begin_move_resources( + self, source_resource_group_name: str, parameters: Union[_models.ResourcesMoveInfo, IO], **kwargs: Any + ) -> LROPoller[None]: + """Moves resources from one resource group to another resource group. + + The resources to move must be in the same source resource group. The target resource group may + be in a different subscription. When moving resources, both the source group and the target + group are locked for the duration of the operation. Write and delete operations are blocked on + the groups until the move completes. + + :param source_resource_group_name: The name of the resource group containing the resources to + move. Required. + :type source_resource_group_name: str + :param parameters: Parameters for moving resources. Is either a model type or a IO type. + Required. + :type parameters: ~azure.mgmt.resource.resources.v2019_10_01.models.ResourcesMoveInfo or IO + :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. + Default value is None. + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be ARMPolling. Pass in False for this + operation to not poll, or pass in your own initialized polling object for a personal polling + strategy. + :paramtype polling: bool or ~azure.core.polling.PollingMethod + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of LROPoller that returns either None or the result of cls(response) + :rtype: ~azure.core.polling.LROPoller[None] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _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", "2019-10-01")) # type: str + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[None] + polling = kwargs.pop("polling", True) # type: Union[bool, PollingMethod] + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token = kwargs.pop("continuation_token", None) # type: Optional[str] if cont_token is None: - raw_result = self._move_resources_initial( + raw_result = self._move_resources_initial( # type: ignore source_resource_group_name=source_resource_group_name, parameters=parameters, api_version=api_version, content_type=content_type, - cls=lambda x,y,z: x, + cls=lambda x, y, z: x, + headers=_headers, + params=_params, **kwargs ) - kwargs.pop('error_map', None) + kwargs.pop("error_map", None) - def get_long_running_output(pipeline_response): + def get_long_running_output(pipeline_response): # pylint: disable=inconsistent-return-statements if cls: return cls(pipeline_response, None, {}) - - if polling is True: polling_method = ARMPolling(lro_delay, **kwargs) - elif polling is False: polling_method = NoPolling() - else: polling_method = polling + if polling is True: + polling_method = cast(PollingMethod, ARMPolling(lro_delay, **kwargs)) # type: PollingMethod + elif polling is False: + polling_method = cast(PollingMethod, NoPolling()) + else: + polling_method = polling if cont_token: return LROPoller.from_continuation_token( polling_method=polling_method, continuation_token=cont_token, client=self._client, - deserialization_callback=get_long_running_output + deserialization_callback=get_long_running_output, ) return LROPoller(self._client, raw_result, get_long_running_output, polling_method) - begin_move_resources.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{sourceResourceGroupName}/moveResources"} # type: ignore + begin_move_resources.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{sourceResourceGroupName}/moveResources"} # type: ignore def _validate_move_resources_initial( # pylint: disable=inconsistent-return-statements - self, - source_resource_group_name: str, - parameters: "_models.ResourcesMoveInfo", - **kwargs: Any + self, source_resource_group_name: str, parameters: Union[_models.ResourcesMoveInfo, IO], **kwargs: Any ) -> None: - cls = kwargs.pop('cls', None) # type: ClsType[None] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) - api_version = kwargs.pop('api_version', "2019-10-01") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - _json = self._serialize.body(parameters, 'ResourcesMoveInfo') + api_version = kwargs.pop("api_version", _params.pop("api-version", "2019-10-01")) # type: str + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[None] - request = build_resources_validate_move_resources_request_initial( + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(parameters, (IO, bytes)): + _content = parameters + else: + _json = self._serialize.body(parameters, "ResourcesMoveInfo") + + request = build_resources_validate_move_resources_request( source_resource_group_name=source_resource_group_name, subscription_id=self._config.subscription_id, api_version=api_version, content_type=content_type, json=_json, - template_url=self._validate_move_resources_initial.metadata['url'], + content=_content, + template_url=self._validate_move_resources_initial.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [202, 204]: @@ -8180,14 +8946,15 @@ def _validate_move_resources_initial( # pylint: disable=inconsistent-return-sta if cls: return cls(pipeline_response, None, {}) - _validate_move_resources_initial.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{sourceResourceGroupName}/validateMoveResources"} # type: ignore + _validate_move_resources_initial.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{sourceResourceGroupName}/validateMoveResources"} # type: ignore - - @distributed_trace - def begin_validate_move_resources( # pylint: disable=inconsistent-return-statements + @overload + def begin_validate_move_resources( self, source_resource_group_name: str, - parameters: "_models.ResourcesMoveInfo", + parameters: _models.ResourcesMoveInfo, + *, + content_type: str = "application/json", **kwargs: Any ) -> LROPoller[None]: """Validates whether resources can be moved from one resource group to another resource group. @@ -8200,10 +8967,13 @@ def begin_validate_move_resources( # pylint: disable=inconsistent-return-statem operation. :param source_resource_group_name: The name of the resource group containing the resources to - validate for move. + validate for move. Required. :type source_resource_group_name: str - :param parameters: Parameters for moving resources. + :param parameters: Parameters for moving resources. Required. :type parameters: ~azure.mgmt.resource.resources.v2019_10_01.models.ResourcesMoveInfo + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str :keyword callable cls: A custom type or function that will be passed the direct response :keyword str continuation_token: A continuation token to restart a poller from a saved state. :keyword polling: By default, your polling method will be ARMPolling. Pass in False for this @@ -8214,55 +8984,124 @@ def begin_validate_move_resources( # pylint: disable=inconsistent-return-statem Retry-After header is present. :return: An instance of LROPoller that returns either None or the result of cls(response) :rtype: ~azure.core.polling.LROPoller[None] - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - api_version = kwargs.pop('api_version', "2019-10-01") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] - polling = kwargs.pop('polling', True) # type: Union[bool, PollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType[None] - lro_delay = kwargs.pop( - 'polling_interval', - self._config.polling_interval - ) - cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] + + @overload + def begin_validate_move_resources( + self, source_resource_group_name: str, parameters: IO, *, content_type: str = "application/json", **kwargs: Any + ) -> LROPoller[None]: + """Validates whether resources can be moved from one resource group to another resource group. + + This operation checks whether the specified resources can be moved to the target. The resources + to move must be in the same source resource group. The target resource group may be in a + different subscription. If validation succeeds, it returns HTTP response code 204 (no content). + If validation fails, it returns HTTP response code 409 (Conflict) with an error message. + Retrieve the URL in the Location header value to check the result of the long-running + operation. + + :param source_resource_group_name: The name of the resource group containing the resources to + validate for move. Required. + :type source_resource_group_name: str + :param parameters: Parameters for moving resources. Required. + :type parameters: IO + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be ARMPolling. Pass in False for this + operation to not poll, or pass in your own initialized polling object for a personal polling + strategy. + :paramtype polling: bool or ~azure.core.polling.PollingMethod + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of LROPoller that returns either None or the result of cls(response) + :rtype: ~azure.core.polling.LROPoller[None] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace + def begin_validate_move_resources( + self, source_resource_group_name: str, parameters: Union[_models.ResourcesMoveInfo, IO], **kwargs: Any + ) -> LROPoller[None]: + """Validates whether resources can be moved from one resource group to another resource group. + + This operation checks whether the specified resources can be moved to the target. The resources + to move must be in the same source resource group. The target resource group may be in a + different subscription. If validation succeeds, it returns HTTP response code 204 (no content). + If validation fails, it returns HTTP response code 409 (Conflict) with an error message. + Retrieve the URL in the Location header value to check the result of the long-running + operation. + + :param source_resource_group_name: The name of the resource group containing the resources to + validate for move. Required. + :type source_resource_group_name: str + :param parameters: Parameters for moving resources. Is either a model type or a IO type. + Required. + :type parameters: ~azure.mgmt.resource.resources.v2019_10_01.models.ResourcesMoveInfo or IO + :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. + Default value is None. + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be ARMPolling. Pass in False for this + operation to not poll, or pass in your own initialized polling object for a personal polling + strategy. + :paramtype polling: bool or ~azure.core.polling.PollingMethod + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of LROPoller that returns either None or the result of cls(response) + :rtype: ~azure.core.polling.LROPoller[None] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _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", "2019-10-01")) # type: str + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[None] + polling = kwargs.pop("polling", True) # type: Union[bool, PollingMethod] + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token = kwargs.pop("continuation_token", None) # type: Optional[str] if cont_token is None: - raw_result = self._validate_move_resources_initial( + raw_result = self._validate_move_resources_initial( # type: ignore source_resource_group_name=source_resource_group_name, parameters=parameters, api_version=api_version, content_type=content_type, - cls=lambda x,y,z: x, + cls=lambda x, y, z: x, + headers=_headers, + params=_params, **kwargs ) - kwargs.pop('error_map', None) + kwargs.pop("error_map", None) - def get_long_running_output(pipeline_response): + def get_long_running_output(pipeline_response): # pylint: disable=inconsistent-return-statements if cls: return cls(pipeline_response, None, {}) - - if polling is True: polling_method = ARMPolling(lro_delay, **kwargs) - elif polling is False: polling_method = NoPolling() - else: polling_method = polling + if polling is True: + polling_method = cast(PollingMethod, ARMPolling(lro_delay, **kwargs)) # type: PollingMethod + elif polling is False: + polling_method = cast(PollingMethod, NoPolling()) + else: + polling_method = polling if cont_token: return LROPoller.from_continuation_token( polling_method=polling_method, continuation_token=cont_token, client=self._client, - deserialization_callback=get_long_running_output + deserialization_callback=get_long_running_output, ) return LROPoller(self._client, raw_result, get_long_running_output, polling_method) - begin_validate_move_resources.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{sourceResourceGroupName}/validateMoveResources"} # type: ignore + begin_validate_move_resources.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{sourceResourceGroupName}/validateMoveResources"} # type: ignore @distributed_trace def list( - self, - filter: Optional[str] = None, - expand: Optional[str] = None, - top: Optional[int] = None, - **kwargs: Any - ) -> Iterable["_models.ResourceListResult"]: + self, filter: Optional[str] = None, expand: Optional[str] = None, top: Optional[int] = None, **kwargs: Any + ) -> Iterable["_models.GenericResourceExpanded"]: """Get all the resources in a subscription. :param filter: The filter to apply on the operation.:code:`
`:code:`
`The properties you @@ -8289,40 +9128,50 @@ def list( value is None. :type top: int :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either ResourceListResult or the result of cls(response) + :return: An iterator like instance of either GenericResourceExpanded or the result of + cls(response) :rtype: - ~azure.core.paging.ItemPaged[~azure.mgmt.resource.resources.v2019_10_01.models.ResourceListResult] - :raises: ~azure.core.exceptions.HttpResponseError + ~azure.core.paging.ItemPaged[~azure.mgmt.resource.resources.v2019_10_01.models.GenericResourceExpanded] + :raises ~azure.core.exceptions.HttpResponseError: """ - api_version = kwargs.pop('api_version', "2019-10-01") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2019-10-01")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[_models.ResourceListResult] - cls = kwargs.pop('cls', None) # type: ClsType["_models.ResourceListResult"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) + def prepare_request(next_link=None): if not next_link: - + request = build_resources_list_request( subscription_id=self._config.subscription_id, - api_version=api_version, filter=filter, expand=expand, top=top, - template_url=self.list.metadata['url'], + 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.url = self._client.format_url(request.url) # type: ignore else: - - request = build_resources_list_request( - subscription_id=self._config.subscription_id, - template_url=next_link, - ) + # make call to next link with the client's api-version + _parsed_next_link = urlparse(next_link) + _next_request_params = case_insensitive_dict(parse_qs(_parsed_next_link.query)) + _next_request_params["api-version"] = self._config.api_version + request = HttpRequest("GET", urljoin(next_link, _parsed_next_link.path), params=_next_request_params) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore request.method = "GET" return request @@ -8336,10 +9185,8 @@ def extract_data(pipeline_response): def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) response = pipeline_response.http_response @@ -8349,11 +9196,9 @@ def get_next(next_link=None): return pipeline_response + return ItemPaged(get_next, extract_data) - return ItemPaged( - get_next, extract_data - ) - list.metadata = {'url': "/subscriptions/{subscriptionId}/resources"} # type: ignore + list.metadata = {"url": "/subscriptions/{subscriptionId}/resources"} # type: ignore @distributed_trace def check_existence( @@ -8369,30 +9214,36 @@ def check_existence( """Checks whether a resource exists. :param resource_group_name: The name of the resource group containing the resource to check. - The name is case insensitive. + The name is case insensitive. Required. :type resource_group_name: str - :param resource_provider_namespace: The resource provider of the resource to check. + :param resource_provider_namespace: The resource provider of the resource to check. Required. :type resource_provider_namespace: str - :param parent_resource_path: The parent resource identity. + :param parent_resource_path: The parent resource identity. Required. :type parent_resource_path: str - :param resource_type: The resource type. + :param resource_type: The resource type. Required. :type resource_type: str - :param resource_name: The name of the resource to check whether it exists. + :param resource_name: The name of the resource to check whether it exists. Required. :type resource_name: str - :param api_version: The API version to use for the operation. + :param api_version: The API version to use for the operation. Required. :type api_version: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: bool, or the result of cls(response) + :return: bool or the result of cls(response) :rtype: bool - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType[None] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = kwargs.pop("params", {}) or {} + + cls = kwargs.pop("cls", None) # type: ClsType[None] - request = build_resources_check_existence_request( resource_group_name=resource_group_name, resource_provider_namespace=resource_provider_namespace, @@ -8401,16 +9252,17 @@ def check_existence( resource_name=resource_name, subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.check_existence.metadata['url'], + template_url=self.check_existence.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [204, 404]: @@ -8421,8 +9273,7 @@ def check_existence( return cls(pipeline_response, None, {}) return 200 <= response.status_code <= 299 - check_existence.metadata = {'url': "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{parentResourcePath}/{resourceType}/{resourceName}"} # type: ignore - + check_existence.metadata = {"url": "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{parentResourcePath}/{resourceType}/{resourceName}"} # type: ignore def _delete_initial( # pylint: disable=inconsistent-return-statements self, @@ -8434,14 +9285,20 @@ def _delete_initial( # pylint: disable=inconsistent-return-statements api_version: str, **kwargs: Any ) -> None: - cls = kwargs.pop('cls', None) # type: ClsType[None] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = kwargs.pop("params", {}) or {} - - request = build_resources_delete_request_initial( + cls = kwargs.pop("cls", None) # type: ClsType[None] + + request = build_resources_delete_request( resource_group_name=resource_group_name, resource_provider_namespace=resource_provider_namespace, parent_resource_path=parent_resource_path, @@ -8449,16 +9306,17 @@ def _delete_initial( # pylint: disable=inconsistent-return-statements resource_name=resource_name, subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self._delete_initial.metadata['url'], + template_url=self._delete_initial.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200, 202, 204]: @@ -8468,11 +9326,10 @@ def _delete_initial( # pylint: disable=inconsistent-return-statements if cls: return cls(pipeline_response, None, {}) - _delete_initial.metadata = {'url': "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{parentResourcePath}/{resourceType}/{resourceName}"} # type: ignore - + _delete_initial.metadata = {"url": "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{parentResourcePath}/{resourceType}/{resourceName}"} # type: ignore @distributed_trace - def begin_delete( # pylint: disable=inconsistent-return-statements + def begin_delete( self, resource_group_name: str, resource_provider_namespace: str, @@ -8485,17 +9342,17 @@ def begin_delete( # pylint: disable=inconsistent-return-statements """Deletes a resource. :param resource_group_name: The name of the resource group that contains the resource to - delete. The name is case insensitive. + delete. The name is case insensitive. Required. :type resource_group_name: str - :param resource_provider_namespace: The namespace of the resource provider. + :param resource_provider_namespace: The namespace of the resource provider. Required. :type resource_provider_namespace: str - :param parent_resource_path: The parent resource identity. + :param parent_resource_path: The parent resource identity. Required. :type parent_resource_path: str - :param resource_type: The resource type. + :param resource_type: The resource type. Required. :type resource_type: str - :param resource_name: The name of the resource to delete. + :param resource_name: The name of the resource to delete. Required. :type resource_name: str - :param api_version: The API version to use for the operation. + :param api_version: The API version to use for the operation. Required. :type api_version: str :keyword callable cls: A custom type or function that will be passed the direct response :keyword str continuation_token: A continuation token to restart a poller from a saved state. @@ -8507,46 +9364,50 @@ def begin_delete( # pylint: disable=inconsistent-return-statements Retry-After header is present. :return: An instance of LROPoller that returns either None or the result of cls(response) :rtype: ~azure.core.polling.LROPoller[None] - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - polling = kwargs.pop('polling', True) # type: Union[bool, PollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType[None] - lro_delay = kwargs.pop( - 'polling_interval', - self._config.polling_interval - ) - cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] + _headers = kwargs.pop("headers", {}) or {} + _params = kwargs.pop("params", {}) or {} + + cls = kwargs.pop("cls", None) # type: ClsType[None] + polling = kwargs.pop("polling", True) # type: Union[bool, PollingMethod] + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token = kwargs.pop("continuation_token", None) # type: Optional[str] if cont_token is None: - raw_result = self._delete_initial( + raw_result = self._delete_initial( # type: ignore resource_group_name=resource_group_name, resource_provider_namespace=resource_provider_namespace, parent_resource_path=parent_resource_path, resource_type=resource_type, resource_name=resource_name, api_version=api_version, - cls=lambda x,y,z: x, + cls=lambda x, y, z: x, + headers=_headers, + params=_params, **kwargs ) - kwargs.pop('error_map', None) + kwargs.pop("error_map", None) - def get_long_running_output(pipeline_response): + def get_long_running_output(pipeline_response): # pylint: disable=inconsistent-return-statements if cls: return cls(pipeline_response, None, {}) - - if polling is True: polling_method = ARMPolling(lro_delay, **kwargs) - elif polling is False: polling_method = NoPolling() - else: polling_method = polling + if polling is True: + polling_method = cast(PollingMethod, ARMPolling(lro_delay, **kwargs)) # type: PollingMethod + elif polling is False: + polling_method = cast(PollingMethod, NoPolling()) + else: + polling_method = polling if cont_token: return LROPoller.from_continuation_token( polling_method=polling_method, continuation_token=cont_token, client=self._client, - deserialization_callback=get_long_running_output + deserialization_callback=get_long_running_output, ) return LROPoller(self._client, raw_result, get_long_running_output, polling_method) - begin_delete.metadata = {'url': "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{parentResourcePath}/{resourceType}/{resourceName}"} # type: ignore + begin_delete.metadata = {"url": "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{parentResourcePath}/{resourceType}/{resourceName}"} # type: ignore def _create_or_update_initial( self, @@ -8556,39 +9417,53 @@ def _create_or_update_initial( resource_type: str, resource_name: str, api_version: str, - parameters: "_models.GenericResource", + parameters: Union[_models.GenericResource, IO], **kwargs: Any - ) -> Optional["_models.GenericResource"]: - cls = kwargs.pop('cls', None) # type: ClsType[Optional["_models.GenericResource"]] + ) -> Optional[_models.GenericResource]: error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = kwargs.pop("params", {}) or {} - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[Optional[_models.GenericResource]] - _json = self._serialize.body(parameters, 'GenericResource') + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(parameters, (IO, bytes)): + _content = parameters + else: + _json = self._serialize.body(parameters, "GenericResource") - request = build_resources_create_or_update_request_initial( + request = build_resources_create_or_update_request( resource_group_name=resource_group_name, resource_provider_namespace=resource_provider_namespace, parent_resource_path=parent_resource_path, resource_type=resource_type, resource_name=resource_name, subscription_id=self._config.subscription_id, - content_type=content_type, api_version=api_version, + content_type=content_type, json=_json, - template_url=self._create_or_update_initial.metadata['url'], + content=_content, + template_url=self._create_or_update_initial.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200, 201, 202]: @@ -8597,18 +9472,115 @@ def _create_or_update_initial( deserialized = None if response.status_code == 200: - deserialized = self._deserialize('GenericResource', pipeline_response) + deserialized = self._deserialize("GenericResource", pipeline_response) if response.status_code == 201: - deserialized = self._deserialize('GenericResource', pipeline_response) + deserialized = self._deserialize("GenericResource", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - _create_or_update_initial.metadata = {'url': "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{parentResourcePath}/{resourceType}/{resourceName}"} # type: ignore + _create_or_update_initial.metadata = {"url": "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{parentResourcePath}/{resourceType}/{resourceName}"} # type: ignore + + @overload + def begin_create_or_update( + self, + resource_group_name: str, + resource_provider_namespace: str, + parent_resource_path: str, + resource_type: str, + resource_name: str, + api_version: str, + parameters: _models.GenericResource, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> LROPoller[_models.GenericResource]: + """Creates a resource. + + :param resource_group_name: The name of the resource group for the resource. The name is case + insensitive. Required. + :type resource_group_name: str + :param resource_provider_namespace: The namespace of the resource provider. Required. + :type resource_provider_namespace: str + :param parent_resource_path: The parent resource identity. Required. + :type parent_resource_path: str + :param resource_type: The resource type of the resource to create. Required. + :type resource_type: str + :param resource_name: The name of the resource to create. Required. + :type resource_name: str + :param api_version: The API version to use for the operation. Required. + :type api_version: str + :param parameters: Parameters for creating or updating the resource. Required. + :type parameters: ~azure.mgmt.resource.resources.v2019_10_01.models.GenericResource + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be ARMPolling. Pass in False for this + operation to not poll, or pass in your own initialized polling object for a personal polling + strategy. + :paramtype polling: bool or ~azure.core.polling.PollingMethod + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of LROPoller that returns either GenericResource or the result of + cls(response) + :rtype: + ~azure.core.polling.LROPoller[~azure.mgmt.resource.resources.v2019_10_01.models.GenericResource] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + def begin_create_or_update( + self, + resource_group_name: str, + resource_provider_namespace: str, + parent_resource_path: str, + resource_type: str, + resource_name: str, + api_version: str, + parameters: IO, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> LROPoller[_models.GenericResource]: + """Creates a resource. + :param resource_group_name: The name of the resource group for the resource. The name is case + insensitive. Required. + :type resource_group_name: str + :param resource_provider_namespace: The namespace of the resource provider. Required. + :type resource_provider_namespace: str + :param parent_resource_path: The parent resource identity. Required. + :type parent_resource_path: str + :param resource_type: The resource type of the resource to create. Required. + :type resource_type: str + :param resource_name: The name of the resource to create. Required. + :type resource_name: str + :param api_version: The API version to use for the operation. Required. + :type api_version: str + :param parameters: Parameters for creating or updating the resource. Required. + :type parameters: IO + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be ARMPolling. Pass in False for this + operation to not poll, or pass in your own initialized polling object for a personal polling + strategy. + :paramtype polling: bool or ~azure.core.polling.PollingMethod + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of LROPoller that returns either GenericResource or the result of + cls(response) + :rtype: + ~azure.core.polling.LROPoller[~azure.mgmt.resource.resources.v2019_10_01.models.GenericResource] + :raises ~azure.core.exceptions.HttpResponseError: + """ @distributed_trace def begin_create_or_update( @@ -8619,26 +9591,30 @@ def begin_create_or_update( resource_type: str, resource_name: str, api_version: str, - parameters: "_models.GenericResource", + parameters: Union[_models.GenericResource, IO], **kwargs: Any - ) -> LROPoller["_models.GenericResource"]: + ) -> LROPoller[_models.GenericResource]: """Creates a resource. :param resource_group_name: The name of the resource group for the resource. The name is case - insensitive. + insensitive. Required. :type resource_group_name: str - :param resource_provider_namespace: The namespace of the resource provider. + :param resource_provider_namespace: The namespace of the resource provider. Required. :type resource_provider_namespace: str - :param parent_resource_path: The parent resource identity. + :param parent_resource_path: The parent resource identity. Required. :type parent_resource_path: str - :param resource_type: The resource type of the resource to create. + :param resource_type: The resource type of the resource to create. Required. :type resource_type: str - :param resource_name: The name of the resource to create. + :param resource_name: The name of the resource to create. Required. :type resource_name: str - :param api_version: The API version to use for the operation. + :param api_version: The API version to use for the operation. Required. :type api_version: str - :param parameters: Parameters for creating or updating the resource. - :type parameters: ~azure.mgmt.resource.resources.v2019_10_01.models.GenericResource + :param parameters: Parameters for creating or updating the resource. Is either a model type or + a IO type. Required. + :type parameters: ~azure.mgmt.resource.resources.v2019_10_01.models.GenericResource or IO + :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. + Default value is None. + :paramtype content_type: str :keyword callable cls: A custom type or function that will be passed the direct response :keyword str continuation_token: A continuation token to restart a poller from a saved state. :keyword polling: By default, your polling method will be ARMPolling. Pass in False for this @@ -8651,18 +9627,18 @@ def begin_create_or_update( cls(response) :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.resource.resources.v2019_10_01.models.GenericResource] - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] - polling = kwargs.pop('polling', True) # type: Union[bool, PollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType["_models.GenericResource"] - lro_delay = kwargs.pop( - 'polling_interval', - self._config.polling_interval - ) - cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = kwargs.pop("params", {}) or {} + + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.GenericResource] + polling = kwargs.pop("polling", True) # type: Union[bool, PollingMethod] + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token = kwargs.pop("continuation_token", None) # type: Optional[str] if cont_token is None: - raw_result = self._create_or_update_initial( + raw_result = self._create_or_update_initial( # type: ignore resource_group_name=resource_group_name, resource_provider_namespace=resource_provider_namespace, parent_resource_path=parent_resource_path, @@ -8671,32 +9647,35 @@ def begin_create_or_update( api_version=api_version, parameters=parameters, content_type=content_type, - cls=lambda x,y,z: x, + cls=lambda x, y, z: x, + headers=_headers, + params=_params, **kwargs ) - kwargs.pop('error_map', None) + kwargs.pop("error_map", None) def get_long_running_output(pipeline_response): - response = pipeline_response.http_response - deserialized = self._deserialize('GenericResource', pipeline_response) + deserialized = self._deserialize("GenericResource", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - - if polling is True: polling_method = ARMPolling(lro_delay, **kwargs) - elif polling is False: polling_method = NoPolling() - else: polling_method = polling + if polling is True: + polling_method = cast(PollingMethod, ARMPolling(lro_delay, **kwargs)) # type: PollingMethod + elif polling is False: + polling_method = cast(PollingMethod, NoPolling()) + else: + polling_method = polling if cont_token: return LROPoller.from_continuation_token( polling_method=polling_method, continuation_token=cont_token, client=self._client, - deserialization_callback=get_long_running_output + deserialization_callback=get_long_running_output, ) return LROPoller(self._client, raw_result, get_long_running_output, polling_method) - begin_create_or_update.metadata = {'url': "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{parentResourcePath}/{resourceType}/{resourceName}"} # type: ignore + begin_create_or_update.metadata = {"url": "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{parentResourcePath}/{resourceType}/{resourceName}"} # type: ignore def _update_initial( self, @@ -8706,39 +9685,53 @@ def _update_initial( resource_type: str, resource_name: str, api_version: str, - parameters: "_models.GenericResource", + parameters: Union[_models.GenericResource, IO], **kwargs: Any - ) -> Optional["_models.GenericResource"]: - cls = kwargs.pop('cls', None) # type: ClsType[Optional["_models.GenericResource"]] + ) -> Optional[_models.GenericResource]: error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = kwargs.pop("params", {}) or {} - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[Optional[_models.GenericResource]] - _json = self._serialize.body(parameters, 'GenericResource') + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(parameters, (IO, bytes)): + _content = parameters + else: + _json = self._serialize.body(parameters, "GenericResource") - request = build_resources_update_request_initial( + request = build_resources_update_request( resource_group_name=resource_group_name, resource_provider_namespace=resource_provider_namespace, parent_resource_path=parent_resource_path, resource_type=resource_type, resource_name=resource_name, subscription_id=self._config.subscription_id, - content_type=content_type, api_version=api_version, + content_type=content_type, json=_json, - template_url=self._update_initial.metadata['url'], + content=_content, + template_url=self._update_initial.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200, 202]: @@ -8747,15 +9740,112 @@ def _update_initial( deserialized = None if response.status_code == 200: - deserialized = self._deserialize('GenericResource', pipeline_response) + deserialized = self._deserialize("GenericResource", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - _update_initial.metadata = {'url': "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{parentResourcePath}/{resourceType}/{resourceName}"} # type: ignore + _update_initial.metadata = {"url": "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{parentResourcePath}/{resourceType}/{resourceName}"} # type: ignore + @overload + def begin_update( + self, + resource_group_name: str, + resource_provider_namespace: str, + parent_resource_path: str, + resource_type: str, + resource_name: str, + api_version: str, + parameters: _models.GenericResource, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> LROPoller[_models.GenericResource]: + """Updates a resource. + + :param resource_group_name: The name of the resource group for the resource. The name is case + insensitive. Required. + :type resource_group_name: str + :param resource_provider_namespace: The namespace of the resource provider. Required. + :type resource_provider_namespace: str + :param parent_resource_path: The parent resource identity. Required. + :type parent_resource_path: str + :param resource_type: The resource type of the resource to update. Required. + :type resource_type: str + :param resource_name: The name of the resource to update. Required. + :type resource_name: str + :param api_version: The API version to use for the operation. Required. + :type api_version: str + :param parameters: Parameters for updating the resource. Required. + :type parameters: ~azure.mgmt.resource.resources.v2019_10_01.models.GenericResource + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be ARMPolling. Pass in False for this + operation to not poll, or pass in your own initialized polling object for a personal polling + strategy. + :paramtype polling: bool or ~azure.core.polling.PollingMethod + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of LROPoller that returns either GenericResource or the result of + cls(response) + :rtype: + ~azure.core.polling.LROPoller[~azure.mgmt.resource.resources.v2019_10_01.models.GenericResource] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + def begin_update( + self, + resource_group_name: str, + resource_provider_namespace: str, + parent_resource_path: str, + resource_type: str, + resource_name: str, + api_version: str, + parameters: IO, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> LROPoller[_models.GenericResource]: + """Updates a resource. + + :param resource_group_name: The name of the resource group for the resource. The name is case + insensitive. Required. + :type resource_group_name: str + :param resource_provider_namespace: The namespace of the resource provider. Required. + :type resource_provider_namespace: str + :param parent_resource_path: The parent resource identity. Required. + :type parent_resource_path: str + :param resource_type: The resource type of the resource to update. Required. + :type resource_type: str + :param resource_name: The name of the resource to update. Required. + :type resource_name: str + :param api_version: The API version to use for the operation. Required. + :type api_version: str + :param parameters: Parameters for updating the resource. Required. + :type parameters: IO + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be ARMPolling. Pass in False for this + operation to not poll, or pass in your own initialized polling object for a personal polling + strategy. + :paramtype polling: bool or ~azure.core.polling.PollingMethod + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of LROPoller that returns either GenericResource or the result of + cls(response) + :rtype: + ~azure.core.polling.LROPoller[~azure.mgmt.resource.resources.v2019_10_01.models.GenericResource] + :raises ~azure.core.exceptions.HttpResponseError: + """ @distributed_trace def begin_update( @@ -8766,26 +9856,30 @@ def begin_update( resource_type: str, resource_name: str, api_version: str, - parameters: "_models.GenericResource", + parameters: Union[_models.GenericResource, IO], **kwargs: Any - ) -> LROPoller["_models.GenericResource"]: + ) -> LROPoller[_models.GenericResource]: """Updates a resource. :param resource_group_name: The name of the resource group for the resource. The name is case - insensitive. + insensitive. Required. :type resource_group_name: str - :param resource_provider_namespace: The namespace of the resource provider. + :param resource_provider_namespace: The namespace of the resource provider. Required. :type resource_provider_namespace: str - :param parent_resource_path: The parent resource identity. + :param parent_resource_path: The parent resource identity. Required. :type parent_resource_path: str - :param resource_type: The resource type of the resource to update. + :param resource_type: The resource type of the resource to update. Required. :type resource_type: str - :param resource_name: The name of the resource to update. + :param resource_name: The name of the resource to update. Required. :type resource_name: str - :param api_version: The API version to use for the operation. + :param api_version: The API version to use for the operation. Required. :type api_version: str - :param parameters: Parameters for updating the resource. - :type parameters: ~azure.mgmt.resource.resources.v2019_10_01.models.GenericResource + :param parameters: Parameters for updating the resource. Is either a model type or a IO type. + Required. + :type parameters: ~azure.mgmt.resource.resources.v2019_10_01.models.GenericResource or IO + :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. + Default value is None. + :paramtype content_type: str :keyword callable cls: A custom type or function that will be passed the direct response :keyword str continuation_token: A continuation token to restart a poller from a saved state. :keyword polling: By default, your polling method will be ARMPolling. Pass in False for this @@ -8798,18 +9892,18 @@ def begin_update( cls(response) :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.resource.resources.v2019_10_01.models.GenericResource] - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] - polling = kwargs.pop('polling', True) # type: Union[bool, PollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType["_models.GenericResource"] - lro_delay = kwargs.pop( - 'polling_interval', - self._config.polling_interval - ) - cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = kwargs.pop("params", {}) or {} + + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.GenericResource] + polling = kwargs.pop("polling", True) # type: Union[bool, PollingMethod] + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token = kwargs.pop("continuation_token", None) # type: Optional[str] if cont_token is None: - raw_result = self._update_initial( + raw_result = self._update_initial( # type: ignore resource_group_name=resource_group_name, resource_provider_namespace=resource_provider_namespace, parent_resource_path=parent_resource_path, @@ -8818,32 +9912,35 @@ def begin_update( api_version=api_version, parameters=parameters, content_type=content_type, - cls=lambda x,y,z: x, + cls=lambda x, y, z: x, + headers=_headers, + params=_params, **kwargs ) - kwargs.pop('error_map', None) + kwargs.pop("error_map", None) def get_long_running_output(pipeline_response): - response = pipeline_response.http_response - deserialized = self._deserialize('GenericResource', pipeline_response) + deserialized = self._deserialize("GenericResource", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - - if polling is True: polling_method = ARMPolling(lro_delay, **kwargs) - elif polling is False: polling_method = NoPolling() - else: polling_method = polling + if polling is True: + polling_method = cast(PollingMethod, ARMPolling(lro_delay, **kwargs)) # type: PollingMethod + elif polling is False: + polling_method = cast(PollingMethod, NoPolling()) + else: + polling_method = polling if cont_token: return LROPoller.from_continuation_token( polling_method=polling_method, continuation_token=cont_token, client=self._client, - deserialization_callback=get_long_running_output + deserialization_callback=get_long_running_output, ) return LROPoller(self._client, raw_result, get_long_running_output, polling_method) - begin_update.metadata = {'url': "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{parentResourcePath}/{resourceType}/{resourceName}"} # type: ignore + begin_update.metadata = {"url": "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{parentResourcePath}/{resourceType}/{resourceName}"} # type: ignore @distributed_trace def get( @@ -8855,34 +9952,40 @@ def get( resource_name: str, api_version: str, **kwargs: Any - ) -> "_models.GenericResource": + ) -> _models.GenericResource: """Gets a resource. :param resource_group_name: The name of the resource group containing the resource to get. The - name is case insensitive. + name is case insensitive. Required. :type resource_group_name: str - :param resource_provider_namespace: The namespace of the resource provider. + :param resource_provider_namespace: The namespace of the resource provider. Required. :type resource_provider_namespace: str - :param parent_resource_path: The parent resource identity. + :param parent_resource_path: The parent resource identity. Required. :type parent_resource_path: str - :param resource_type: The resource type of the resource. + :param resource_type: The resource type of the resource. Required. :type resource_type: str - :param resource_name: The name of the resource to get. + :param resource_name: The name of the resource to get. Required. :type resource_name: str - :param api_version: The API version to use for the operation. + :param api_version: The API version to use for the operation. Required. :type api_version: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: GenericResource, or the result of cls(response) + :return: GenericResource or the result of cls(response) :rtype: ~azure.mgmt.resource.resources.v2019_10_01.models.GenericResource - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.GenericResource"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = kwargs.pop("params", {}) or {} + + cls = kwargs.pop("cls", None) # type: ClsType[_models.GenericResource] - request = build_resources_get_request( resource_group_name=resource_group_name, resource_provider_namespace=resource_provider_namespace, @@ -8891,72 +9994,75 @@ def get( resource_name=resource_name, subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.get.metadata['url'], + template_url=self.get.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) - deserialized = self._deserialize('GenericResource', pipeline_response) + deserialized = self._deserialize("GenericResource", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - get.metadata = {'url': "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{parentResourcePath}/{resourceType}/{resourceName}"} # type: ignore - + get.metadata = {"url": "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{parentResourcePath}/{resourceType}/{resourceName}"} # type: ignore @distributed_trace - def check_existence_by_id( - self, - resource_id: str, - api_version: str, - **kwargs: Any - ) -> bool: + def check_existence_by_id(self, resource_id: str, api_version: str, **kwargs: Any) -> bool: """Checks by ID whether a resource exists. :param resource_id: The fully qualified ID of the resource, including the resource name and resource type. Use the format, /subscriptions/{guid}/resourceGroups/{resource-group-name}/{resource-provider-namespace}/{resource-type}/{resource-name}. + Required. :type resource_id: str - :param api_version: The API version to use for the operation. + :param api_version: The API version to use for the operation. Required. :type api_version: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: bool, or the result of cls(response) + :return: bool or the result of cls(response) :rtype: bool - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType[None] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = kwargs.pop("params", {}) or {} + + cls = kwargs.pop("cls", None) # type: ClsType[None] - request = build_resources_check_existence_by_id_request( resource_id=resource_id, api_version=api_version, - template_url=self.check_existence_by_id.metadata['url'], + template_url=self.check_existence_by_id.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [204, 404]: @@ -8967,35 +10073,38 @@ def check_existence_by_id( return cls(pipeline_response, None, {}) return 200 <= response.status_code <= 299 - check_existence_by_id.metadata = {'url': "/{resourceId}"} # type: ignore - + check_existence_by_id.metadata = {"url": "/{resourceId}"} # type: ignore def _delete_by_id_initial( # pylint: disable=inconsistent-return-statements - self, - resource_id: str, - api_version: str, - **kwargs: Any + self, resource_id: str, api_version: str, **kwargs: Any ) -> None: - cls = kwargs.pop('cls', None) # type: ClsType[None] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = kwargs.pop("params", {}) or {} - - request = build_resources_delete_by_id_request_initial( + cls = kwargs.pop("cls", None) # type: ClsType[None] + + request = build_resources_delete_by_id_request( resource_id=resource_id, api_version=api_version, - template_url=self._delete_by_id_initial.metadata['url'], + template_url=self._delete_by_id_initial.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200, 202, 204]: @@ -9005,23 +10114,18 @@ def _delete_by_id_initial( # pylint: disable=inconsistent-return-statements if cls: return cls(pipeline_response, None, {}) - _delete_by_id_initial.metadata = {'url': "/{resourceId}"} # type: ignore - + _delete_by_id_initial.metadata = {"url": "/{resourceId}"} # type: ignore @distributed_trace - def begin_delete_by_id( # pylint: disable=inconsistent-return-statements - self, - resource_id: str, - api_version: str, - **kwargs: Any - ) -> LROPoller[None]: + def begin_delete_by_id(self, resource_id: str, api_version: str, **kwargs: Any) -> LROPoller[None]: """Deletes a resource by ID. :param resource_id: The fully qualified ID of the resource, including the resource name and resource type. Use the format, /subscriptions/{guid}/resourceGroups/{resource-group-name}/{resource-provider-namespace}/{resource-type}/{resource-name}. + Required. :type resource_id: str - :param api_version: The API version to use for the operation. + :param api_version: The API version to use for the operation. Required. :type api_version: str :keyword callable cls: A custom type or function that will be passed the direct response :keyword str continuation_token: A continuation token to restart a poller from a saved state. @@ -9033,75 +10137,89 @@ def begin_delete_by_id( # pylint: disable=inconsistent-return-statements Retry-After header is present. :return: An instance of LROPoller that returns either None or the result of cls(response) :rtype: ~azure.core.polling.LROPoller[None] - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - polling = kwargs.pop('polling', True) # type: Union[bool, PollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType[None] - lro_delay = kwargs.pop( - 'polling_interval', - self._config.polling_interval - ) - cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] + _headers = kwargs.pop("headers", {}) or {} + _params = kwargs.pop("params", {}) or {} + + cls = kwargs.pop("cls", None) # type: ClsType[None] + polling = kwargs.pop("polling", True) # type: Union[bool, PollingMethod] + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token = kwargs.pop("continuation_token", None) # type: Optional[str] if cont_token is None: - raw_result = self._delete_by_id_initial( + raw_result = self._delete_by_id_initial( # type: ignore resource_id=resource_id, api_version=api_version, - cls=lambda x,y,z: x, + cls=lambda x, y, z: x, + headers=_headers, + params=_params, **kwargs ) - kwargs.pop('error_map', None) + kwargs.pop("error_map", None) - def get_long_running_output(pipeline_response): + def get_long_running_output(pipeline_response): # pylint: disable=inconsistent-return-statements if cls: return cls(pipeline_response, None, {}) - - if polling is True: polling_method = ARMPolling(lro_delay, **kwargs) - elif polling is False: polling_method = NoPolling() - else: polling_method = polling + if polling is True: + polling_method = cast(PollingMethod, ARMPolling(lro_delay, **kwargs)) # type: PollingMethod + elif polling is False: + polling_method = cast(PollingMethod, NoPolling()) + else: + polling_method = polling if cont_token: return LROPoller.from_continuation_token( polling_method=polling_method, continuation_token=cont_token, client=self._client, - deserialization_callback=get_long_running_output + deserialization_callback=get_long_running_output, ) return LROPoller(self._client, raw_result, get_long_running_output, polling_method) - begin_delete_by_id.metadata = {'url': "/{resourceId}"} # type: ignore + begin_delete_by_id.metadata = {"url": "/{resourceId}"} # type: ignore def _create_or_update_by_id_initial( - self, - resource_id: str, - api_version: str, - parameters: "_models.GenericResource", - **kwargs: Any - ) -> Optional["_models.GenericResource"]: - cls = kwargs.pop('cls', None) # type: ClsType[Optional["_models.GenericResource"]] + self, resource_id: str, api_version: str, parameters: Union[_models.GenericResource, IO], **kwargs: Any + ) -> Optional[_models.GenericResource]: error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = kwargs.pop("params", {}) or {} - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[Optional[_models.GenericResource]] - _json = self._serialize.body(parameters, 'GenericResource') + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(parameters, (IO, bytes)): + _content = parameters + else: + _json = self._serialize.body(parameters, "GenericResource") - request = build_resources_create_or_update_by_id_request_initial( + request = build_resources_create_or_update_by_id_request( resource_id=resource_id, - content_type=content_type, api_version=api_version, + content_type=content_type, json=_json, - template_url=self._create_or_update_by_id_initial.metadata['url'], + content=_content, + template_url=self._create_or_update_by_id_initial.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200, 201, 202]: @@ -9110,37 +10228,42 @@ def _create_or_update_by_id_initial( deserialized = None if response.status_code == 200: - deserialized = self._deserialize('GenericResource', pipeline_response) + deserialized = self._deserialize("GenericResource", pipeline_response) if response.status_code == 201: - deserialized = self._deserialize('GenericResource', pipeline_response) + deserialized = self._deserialize("GenericResource", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - _create_or_update_by_id_initial.metadata = {'url': "/{resourceId}"} # type: ignore - + _create_or_update_by_id_initial.metadata = {"url": "/{resourceId}"} # type: ignore - @distributed_trace + @overload def begin_create_or_update_by_id( self, resource_id: str, api_version: str, - parameters: "_models.GenericResource", + parameters: _models.GenericResource, + *, + content_type: str = "application/json", **kwargs: Any - ) -> LROPoller["_models.GenericResource"]: + ) -> LROPoller[_models.GenericResource]: """Create a resource by ID. :param resource_id: The fully qualified ID of the resource, including the resource name and resource type. Use the format, /subscriptions/{guid}/resourceGroups/{resource-group-name}/{resource-provider-namespace}/{resource-type}/{resource-name}. + Required. :type resource_id: str - :param api_version: The API version to use for the operation. + :param api_version: The API version to use for the operation. Required. :type api_version: str - :param parameters: Create or update resource parameters. + :param parameters: Create or update resource parameters. Required. :type parameters: ~azure.mgmt.resource.resources.v2019_10_01.models.GenericResource + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str :keyword callable cls: A custom type or function that will be passed the direct response :keyword str continuation_token: A continuation token to restart a poller from a saved state. :keyword polling: By default, your polling method will be ARMPolling. Pass in False for this @@ -9153,81 +10276,167 @@ def begin_create_or_update_by_id( cls(response) :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.resource.resources.v2019_10_01.models.GenericResource] - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] - polling = kwargs.pop('polling', True) # type: Union[bool, PollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType["_models.GenericResource"] - lro_delay = kwargs.pop( - 'polling_interval', - self._config.polling_interval - ) - cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] + + @overload + def begin_create_or_update_by_id( + self, + resource_id: str, + api_version: str, + parameters: IO, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> LROPoller[_models.GenericResource]: + """Create a resource by ID. + + :param resource_id: The fully qualified ID of the resource, including the resource name and + resource type. Use the format, + /subscriptions/{guid}/resourceGroups/{resource-group-name}/{resource-provider-namespace}/{resource-type}/{resource-name}. + Required. + :type resource_id: str + :param api_version: The API version to use for the operation. Required. + :type api_version: str + :param parameters: Create or update resource parameters. Required. + :type parameters: IO + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be ARMPolling. Pass in False for this + operation to not poll, or pass in your own initialized polling object for a personal polling + strategy. + :paramtype polling: bool or ~azure.core.polling.PollingMethod + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of LROPoller that returns either GenericResource or the result of + cls(response) + :rtype: + ~azure.core.polling.LROPoller[~azure.mgmt.resource.resources.v2019_10_01.models.GenericResource] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace + def begin_create_or_update_by_id( + self, resource_id: str, api_version: str, parameters: Union[_models.GenericResource, IO], **kwargs: Any + ) -> LROPoller[_models.GenericResource]: + """Create a resource by ID. + + :param resource_id: The fully qualified ID of the resource, including the resource name and + resource type. Use the format, + /subscriptions/{guid}/resourceGroups/{resource-group-name}/{resource-provider-namespace}/{resource-type}/{resource-name}. + Required. + :type resource_id: str + :param api_version: The API version to use for the operation. Required. + :type api_version: str + :param parameters: Create or update resource parameters. Is either a model type or a IO type. + Required. + :type parameters: ~azure.mgmt.resource.resources.v2019_10_01.models.GenericResource or IO + :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. + Default value is None. + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be ARMPolling. Pass in False for this + operation to not poll, or pass in your own initialized polling object for a personal polling + strategy. + :paramtype polling: bool or ~azure.core.polling.PollingMethod + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of LROPoller that returns either GenericResource or the result of + cls(response) + :rtype: + ~azure.core.polling.LROPoller[~azure.mgmt.resource.resources.v2019_10_01.models.GenericResource] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = kwargs.pop("params", {}) or {} + + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.GenericResource] + polling = kwargs.pop("polling", True) # type: Union[bool, PollingMethod] + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token = kwargs.pop("continuation_token", None) # type: Optional[str] if cont_token is None: - raw_result = self._create_or_update_by_id_initial( + raw_result = self._create_or_update_by_id_initial( # type: ignore resource_id=resource_id, api_version=api_version, parameters=parameters, content_type=content_type, - cls=lambda x,y,z: x, + cls=lambda x, y, z: x, + headers=_headers, + params=_params, **kwargs ) - kwargs.pop('error_map', None) + kwargs.pop("error_map", None) def get_long_running_output(pipeline_response): - response = pipeline_response.http_response - deserialized = self._deserialize('GenericResource', pipeline_response) + deserialized = self._deserialize("GenericResource", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - - if polling is True: polling_method = ARMPolling(lro_delay, **kwargs) - elif polling is False: polling_method = NoPolling() - else: polling_method = polling + if polling is True: + polling_method = cast(PollingMethod, ARMPolling(lro_delay, **kwargs)) # type: PollingMethod + elif polling is False: + polling_method = cast(PollingMethod, NoPolling()) + else: + polling_method = polling if cont_token: return LROPoller.from_continuation_token( polling_method=polling_method, continuation_token=cont_token, client=self._client, - deserialization_callback=get_long_running_output + deserialization_callback=get_long_running_output, ) return LROPoller(self._client, raw_result, get_long_running_output, polling_method) - begin_create_or_update_by_id.metadata = {'url': "/{resourceId}"} # type: ignore + begin_create_or_update_by_id.metadata = {"url": "/{resourceId}"} # type: ignore def _update_by_id_initial( - self, - resource_id: str, - api_version: str, - parameters: "_models.GenericResource", - **kwargs: Any - ) -> Optional["_models.GenericResource"]: - cls = kwargs.pop('cls', None) # type: ClsType[Optional["_models.GenericResource"]] + self, resource_id: str, api_version: str, parameters: Union[_models.GenericResource, IO], **kwargs: Any + ) -> Optional[_models.GenericResource]: error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = kwargs.pop("params", {}) or {} - _json = self._serialize.body(parameters, 'GenericResource') + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[Optional[_models.GenericResource]] - request = build_resources_update_by_id_request_initial( + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(parameters, (IO, bytes)): + _content = parameters + else: + _json = self._serialize.body(parameters, "GenericResource") + + request = build_resources_update_by_id_request( resource_id=resource_id, - content_type=content_type, api_version=api_version, + content_type=content_type, json=_json, - template_url=self._update_by_id_initial.metadata['url'], + content=_content, + template_url=self._update_by_id_initial.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200, 202]: @@ -9236,34 +10445,39 @@ def _update_by_id_initial( deserialized = None if response.status_code == 200: - deserialized = self._deserialize('GenericResource', pipeline_response) + deserialized = self._deserialize("GenericResource", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - _update_by_id_initial.metadata = {'url': "/{resourceId}"} # type: ignore - + _update_by_id_initial.metadata = {"url": "/{resourceId}"} # type: ignore - @distributed_trace + @overload def begin_update_by_id( self, resource_id: str, api_version: str, - parameters: "_models.GenericResource", + parameters: _models.GenericResource, + *, + content_type: str = "application/json", **kwargs: Any - ) -> LROPoller["_models.GenericResource"]: + ) -> LROPoller[_models.GenericResource]: """Updates a resource by ID. :param resource_id: The fully qualified ID of the resource, including the resource name and resource type. Use the format, /subscriptions/{guid}/resourceGroups/{resource-group-name}/{resource-provider-namespace}/{resource-type}/{resource-name}. + Required. :type resource_id: str - :param api_version: The API version to use for the operation. + :param api_version: The API version to use for the operation. Required. :type api_version: str - :param parameters: Update resource parameters. + :param parameters: Update resource parameters. Required. :type parameters: ~azure.mgmt.resource.resources.v2019_10_01.models.GenericResource + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str :keyword callable cls: A custom type or function that will be passed the direct response :keyword str continuation_token: A continuation token to restart a poller from a saved state. :keyword polling: By default, your polling method will be ARMPolling. Pass in False for this @@ -9276,165 +10490,243 @@ def begin_update_by_id( cls(response) :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.resource.resources.v2019_10_01.models.GenericResource] - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] - polling = kwargs.pop('polling', True) # type: Union[bool, PollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType["_models.GenericResource"] - lro_delay = kwargs.pop( - 'polling_interval', - self._config.polling_interval - ) - cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] + + @overload + def begin_update_by_id( + self, + resource_id: str, + api_version: str, + parameters: IO, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> LROPoller[_models.GenericResource]: + """Updates a resource by ID. + + :param resource_id: The fully qualified ID of the resource, including the resource name and + resource type. Use the format, + /subscriptions/{guid}/resourceGroups/{resource-group-name}/{resource-provider-namespace}/{resource-type}/{resource-name}. + Required. + :type resource_id: str + :param api_version: The API version to use for the operation. Required. + :type api_version: str + :param parameters: Update resource parameters. Required. + :type parameters: IO + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be ARMPolling. Pass in False for this + operation to not poll, or pass in your own initialized polling object for a personal polling + strategy. + :paramtype polling: bool or ~azure.core.polling.PollingMethod + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of LROPoller that returns either GenericResource or the result of + cls(response) + :rtype: + ~azure.core.polling.LROPoller[~azure.mgmt.resource.resources.v2019_10_01.models.GenericResource] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace + def begin_update_by_id( + self, resource_id: str, api_version: str, parameters: Union[_models.GenericResource, IO], **kwargs: Any + ) -> LROPoller[_models.GenericResource]: + """Updates a resource by ID. + + :param resource_id: The fully qualified ID of the resource, including the resource name and + resource type. Use the format, + /subscriptions/{guid}/resourceGroups/{resource-group-name}/{resource-provider-namespace}/{resource-type}/{resource-name}. + Required. + :type resource_id: str + :param api_version: The API version to use for the operation. Required. + :type api_version: str + :param parameters: Update resource parameters. Is either a model type or a IO type. Required. + :type parameters: ~azure.mgmt.resource.resources.v2019_10_01.models.GenericResource or IO + :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. + Default value is None. + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be ARMPolling. Pass in False for this + operation to not poll, or pass in your own initialized polling object for a personal polling + strategy. + :paramtype polling: bool or ~azure.core.polling.PollingMethod + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of LROPoller that returns either GenericResource or the result of + cls(response) + :rtype: + ~azure.core.polling.LROPoller[~azure.mgmt.resource.resources.v2019_10_01.models.GenericResource] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = kwargs.pop("params", {}) or {} + + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.GenericResource] + polling = kwargs.pop("polling", True) # type: Union[bool, PollingMethod] + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token = kwargs.pop("continuation_token", None) # type: Optional[str] if cont_token is None: - raw_result = self._update_by_id_initial( + raw_result = self._update_by_id_initial( # type: ignore resource_id=resource_id, api_version=api_version, parameters=parameters, content_type=content_type, - cls=lambda x,y,z: x, + cls=lambda x, y, z: x, + headers=_headers, + params=_params, **kwargs ) - kwargs.pop('error_map', None) + kwargs.pop("error_map", None) def get_long_running_output(pipeline_response): - response = pipeline_response.http_response - deserialized = self._deserialize('GenericResource', pipeline_response) + deserialized = self._deserialize("GenericResource", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - - if polling is True: polling_method = ARMPolling(lro_delay, **kwargs) - elif polling is False: polling_method = NoPolling() - else: polling_method = polling + if polling is True: + polling_method = cast(PollingMethod, ARMPolling(lro_delay, **kwargs)) # type: PollingMethod + elif polling is False: + polling_method = cast(PollingMethod, NoPolling()) + else: + polling_method = polling if cont_token: return LROPoller.from_continuation_token( polling_method=polling_method, continuation_token=cont_token, client=self._client, - deserialization_callback=get_long_running_output + deserialization_callback=get_long_running_output, ) return LROPoller(self._client, raw_result, get_long_running_output, polling_method) - begin_update_by_id.metadata = {'url': "/{resourceId}"} # type: ignore + begin_update_by_id.metadata = {"url": "/{resourceId}"} # type: ignore @distributed_trace - def get_by_id( - self, - resource_id: str, - api_version: str, - **kwargs: Any - ) -> "_models.GenericResource": + def get_by_id(self, resource_id: str, api_version: str, **kwargs: Any) -> _models.GenericResource: """Gets a resource by ID. :param resource_id: The fully qualified ID of the resource, including the resource name and resource type. Use the format, /subscriptions/{guid}/resourceGroups/{resource-group-name}/{resource-provider-namespace}/{resource-type}/{resource-name}. + Required. :type resource_id: str - :param api_version: The API version to use for the operation. + :param api_version: The API version to use for the operation. Required. :type api_version: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: GenericResource, or the result of cls(response) + :return: GenericResource or the result of cls(response) :rtype: ~azure.mgmt.resource.resources.v2019_10_01.models.GenericResource - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.GenericResource"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = kwargs.pop("params", {}) or {} + + cls = kwargs.pop("cls", None) # type: ClsType[_models.GenericResource] - request = build_resources_get_by_id_request( resource_id=resource_id, api_version=api_version, - template_url=self.get_by_id.metadata['url'], + template_url=self.get_by_id.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) - deserialized = self._deserialize('GenericResource', pipeline_response) + deserialized = self._deserialize("GenericResource", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - get_by_id.metadata = {'url': "/{resourceId}"} # type: ignore + get_by_id.metadata = {"url": "/{resourceId}"} # type: ignore -class ResourceGroupsOperations(object): - """ResourceGroupsOperations operations. - You should not instantiate this class directly. Instead, you should create a Client instance that - instantiates it for you and attaches it as an attribute. +class ResourceGroupsOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. - :ivar models: Alias to model classes used in this operation group. - :type models: ~azure.mgmt.resource.resources.v2019_10_01.models - :param client: Client for service requests. - :param config: Configuration of service client. - :param serializer: An object model serializer. - :param deserializer: An object model deserializer. + Instead, you should access the following operations through + :class:`~azure.mgmt.resource.resources.v2019_10_01.ResourceManagementClient`'s + :attr:`resource_groups` attribute. """ models = _models - def __init__(self, client, config, serializer, deserializer): - self._client = client - self._serialize = serializer - self._deserialize = deserializer - self._config = config + def __init__(self, *args, **kwargs): + input_args = list(args) + self._client = input_args.pop(0) if input_args else kwargs.pop("client") + self._config = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") @distributed_trace - def check_existence( - self, - resource_group_name: str, - **kwargs: Any - ) -> bool: + def check_existence(self, resource_group_name: str, **kwargs: Any) -> bool: """Checks whether a resource group exists. :param resource_group_name: The name of the resource group to check. The name is case - insensitive. + insensitive. Required. :type resource_group_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: bool, or the result of cls(response) + :return: bool or the result of cls(response) :rtype: bool - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType[None] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + 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', "2019-10-01") # type: str + api_version = kwargs.pop("api_version", _params.pop("api-version", "2019-10-01")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[None] - request = build_resource_groups_check_existence_request( resource_group_name=resource_group_name, subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.check_existence.metadata['url'], + template_url=self.check_existence.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [204, 404]: @@ -9445,39 +10737,98 @@ def check_existence( return cls(pipeline_response, None, {}) return 200 <= response.status_code <= 299 - check_existence.metadata = {'url': "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}"} # type: ignore - + check_existence.metadata = {"url": "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}"} # type: ignore - @distributed_trace + @overload def create_or_update( self, resource_group_name: str, - parameters: "_models.ResourceGroup", + parameters: _models.ResourceGroup, + *, + content_type: str = "application/json", **kwargs: Any - ) -> "_models.ResourceGroup": + ) -> _models.ResourceGroup: """Creates or updates a resource group. :param resource_group_name: The name of the resource group to create or update. Can include alphanumeric, underscore, parentheses, hyphen, period (except at end), and Unicode characters - that match the allowed characters. + that match the allowed characters. Required. :type resource_group_name: str - :param parameters: Parameters supplied to the create or update a resource group. + :param parameters: Parameters supplied to the create or update a resource group. Required. :type parameters: ~azure.mgmt.resource.resources.v2019_10_01.models.ResourceGroup + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: ResourceGroup or the result of cls(response) + :rtype: ~azure.mgmt.resource.resources.v2019_10_01.models.ResourceGroup + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + def create_or_update( + self, resource_group_name: str, parameters: IO, *, content_type: str = "application/json", **kwargs: Any + ) -> _models.ResourceGroup: + """Creates or updates a resource group. + + :param resource_group_name: The name of the resource group to create or update. Can include + alphanumeric, underscore, parentheses, hyphen, period (except at end), and Unicode characters + that match the allowed characters. Required. + :type resource_group_name: str + :param parameters: Parameters supplied to the create or update a resource group. Required. + :type parameters: IO + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: ResourceGroup, or the result of cls(response) + :return: ResourceGroup or the result of cls(response) :rtype: ~azure.mgmt.resource.resources.v2019_10_01.models.ResourceGroup - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace + def create_or_update( + self, resource_group_name: str, parameters: Union[_models.ResourceGroup, IO], **kwargs: Any + ) -> _models.ResourceGroup: + """Creates or updates a resource group. + + :param resource_group_name: The name of the resource group to create or update. Can include + alphanumeric, underscore, parentheses, hyphen, period (except at end), and Unicode characters + that match the allowed characters. Required. + :type resource_group_name: str + :param parameters: Parameters supplied to the create or update a resource group. Is either a + model type or a IO type. Required. + :type parameters: ~azure.mgmt.resource.resources.v2019_10_01.models.ResourceGroup or IO + :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. + Default value is None. + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: ResourceGroup or the result of cls(response) + :rtype: ~azure.mgmt.resource.resources.v2019_10_01.models.ResourceGroup + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.ResourceGroup"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', "2019-10-01") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + api_version = kwargs.pop("api_version", _params.pop("api-version", "2019-10-01")) # type: str + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.ResourceGroup] - _json = self._serialize.body(parameters, 'ResourceGroup') + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(parameters, (IO, bytes)): + _content = parameters + else: + _json = self._serialize.body(parameters, "ResourceGroup") request = build_resource_groups_create_or_update_request( resource_group_name=resource_group_name, @@ -9485,16 +10836,18 @@ def create_or_update( api_version=api_version, content_type=content_type, json=_json, - template_url=self.create_or_update.metadata['url'], + content=_content, + template_url=self.create_or_update.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200, 201]: @@ -9502,47 +10855,50 @@ def create_or_update( raise HttpResponseError(response=response, error_format=ARMErrorFormat) if response.status_code == 200: - deserialized = self._deserialize('ResourceGroup', pipeline_response) + deserialized = self._deserialize("ResourceGroup", pipeline_response) if response.status_code == 201: - deserialized = self._deserialize('ResourceGroup', pipeline_response) + deserialized = self._deserialize("ResourceGroup", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - create_or_update.metadata = {'url': "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}"} # type: ignore - + create_or_update.metadata = {"url": "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}"} # type: ignore def _delete_initial( # pylint: disable=inconsistent-return-statements - self, - resource_group_name: str, - **kwargs: Any + self, resource_group_name: str, **kwargs: Any ) -> None: - cls = kwargs.pop('cls', None) # type: ClsType[None] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + 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', "2019-10-01") # type: str + api_version = kwargs.pop("api_version", _params.pop("api-version", "2019-10-01")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[None] - - request = build_resource_groups_delete_request_initial( + request = build_resource_groups_delete_request( resource_group_name=resource_group_name, subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self._delete_initial.metadata['url'], + template_url=self._delete_initial.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200, 202]: @@ -9552,22 +10908,17 @@ def _delete_initial( # pylint: disable=inconsistent-return-statements if cls: return cls(pipeline_response, None, {}) - _delete_initial.metadata = {'url': "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}"} # type: ignore - + _delete_initial.metadata = {"url": "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}"} # type: ignore @distributed_trace - def begin_delete( # pylint: disable=inconsistent-return-statements - self, - resource_group_name: str, - **kwargs: Any - ) -> LROPoller[None]: + def begin_delete(self, resource_group_name: str, **kwargs: Any) -> LROPoller[None]: """Deletes a resource group. When you delete a resource group, all of its resources are also deleted. Deleting a resource group deletes all of its template deployments and currently stored operations. :param resource_group_name: The name of the resource group to delete. The name is case - insensitive. + insensitive. Required. :type resource_group_name: str :keyword callable cls: A custom type or function that will be passed the direct response :keyword str continuation_token: A continuation token to restart a poller from a saved state. @@ -9579,106 +10930,113 @@ def begin_delete( # pylint: disable=inconsistent-return-statements Retry-After header is present. :return: An instance of LROPoller that returns either None or the result of cls(response) :rtype: ~azure.core.polling.LROPoller[None] - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - api_version = kwargs.pop('api_version', "2019-10-01") # type: str - polling = kwargs.pop('polling', True) # type: Union[bool, PollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType[None] - lro_delay = kwargs.pop( - 'polling_interval', - self._config.polling_interval - ) - cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2019-10-01")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[None] + polling = kwargs.pop("polling", True) # type: Union[bool, PollingMethod] + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token = kwargs.pop("continuation_token", None) # type: Optional[str] if cont_token is None: - raw_result = self._delete_initial( + raw_result = self._delete_initial( # type: ignore resource_group_name=resource_group_name, api_version=api_version, - cls=lambda x,y,z: x, + cls=lambda x, y, z: x, + headers=_headers, + params=_params, **kwargs ) - kwargs.pop('error_map', None) + kwargs.pop("error_map", None) - def get_long_running_output(pipeline_response): + def get_long_running_output(pipeline_response): # pylint: disable=inconsistent-return-statements if cls: return cls(pipeline_response, None, {}) - - if polling is True: polling_method = ARMPolling(lro_delay, **kwargs) - elif polling is False: polling_method = NoPolling() - else: polling_method = polling + if polling is True: + polling_method = cast(PollingMethod, ARMPolling(lro_delay, **kwargs)) # type: PollingMethod + elif polling is False: + polling_method = cast(PollingMethod, NoPolling()) + else: + polling_method = polling if cont_token: return LROPoller.from_continuation_token( polling_method=polling_method, continuation_token=cont_token, client=self._client, - deserialization_callback=get_long_running_output + deserialization_callback=get_long_running_output, ) return LROPoller(self._client, raw_result, get_long_running_output, polling_method) - begin_delete.metadata = {'url': "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}"} # type: ignore + begin_delete.metadata = {"url": "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}"} # type: ignore @distributed_trace - def get( - self, - resource_group_name: str, - **kwargs: Any - ) -> "_models.ResourceGroup": + def get(self, resource_group_name: str, **kwargs: Any) -> _models.ResourceGroup: """Gets a resource group. :param resource_group_name: The name of the resource group to get. The name is case - insensitive. + insensitive. Required. :type resource_group_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: ResourceGroup, or the result of cls(response) + :return: ResourceGroup or the result of cls(response) :rtype: ~azure.mgmt.resource.resources.v2019_10_01.models.ResourceGroup - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.ResourceGroup"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + 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', "2019-10-01") # type: str + api_version = kwargs.pop("api_version", _params.pop("api-version", "2019-10-01")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[_models.ResourceGroup] - request = build_resource_groups_get_request( resource_group_name=resource_group_name, subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.get.metadata['url'], + template_url=self.get.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) - deserialized = self._deserialize('ResourceGroup', pipeline_response) + deserialized = self._deserialize("ResourceGroup", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - get.metadata = {'url': "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}"} # type: ignore - + get.metadata = {"url": "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}"} # type: ignore - @distributed_trace + @overload def update( self, resource_group_name: str, - parameters: "_models.ResourceGroupPatchable", + parameters: _models.ResourceGroupPatchable, + *, + content_type: str = "application/json", **kwargs: Any - ) -> "_models.ResourceGroup": + ) -> _models.ResourceGroup: """Updates a resource group. Resource groups can be updated through a simple PATCH operation to a group address. The format @@ -9686,25 +11044,90 @@ def update( the current value is retained. :param resource_group_name: The name of the resource group to update. The name is case - insensitive. + insensitive. Required. :type resource_group_name: str - :param parameters: Parameters supplied to update a resource group. + :param parameters: Parameters supplied to update a resource group. Required. :type parameters: ~azure.mgmt.resource.resources.v2019_10_01.models.ResourceGroupPatchable + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: ResourceGroup, or the result of cls(response) + :return: ResourceGroup or the result of cls(response) :rtype: ~azure.mgmt.resource.resources.v2019_10_01.models.ResourceGroup - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + def update( + self, resource_group_name: str, parameters: IO, *, content_type: str = "application/json", **kwargs: Any + ) -> _models.ResourceGroup: + """Updates a resource group. + + Resource groups can be updated through a simple PATCH operation to a group address. The format + of the request is the same as that for creating a resource group. If a field is unspecified, + the current value is retained. + + :param resource_group_name: The name of the resource group to update. The name is case + insensitive. Required. + :type resource_group_name: str + :param parameters: Parameters supplied to update a resource group. Required. + :type parameters: IO + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: ResourceGroup or the result of cls(response) + :rtype: ~azure.mgmt.resource.resources.v2019_10_01.models.ResourceGroup + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace + def update( + self, resource_group_name: str, parameters: Union[_models.ResourceGroupPatchable, IO], **kwargs: Any + ) -> _models.ResourceGroup: + """Updates a resource group. + + Resource groups can be updated through a simple PATCH operation to a group address. The format + of the request is the same as that for creating a resource group. If a field is unspecified, + the current value is retained. + + :param resource_group_name: The name of the resource group to update. The name is case + insensitive. Required. + :type resource_group_name: str + :param parameters: Parameters supplied to update a resource group. Is either a model type or a + IO type. Required. + :type parameters: ~azure.mgmt.resource.resources.v2019_10_01.models.ResourceGroupPatchable or + IO + :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. + Default value is None. + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: ResourceGroup or the result of cls(response) + :rtype: ~azure.mgmt.resource.resources.v2019_10_01.models.ResourceGroup + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.ResourceGroup"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', "2019-10-01") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + api_version = kwargs.pop("api_version", _params.pop("api-version", "2019-10-01")) # type: str + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.ResourceGroup] - _json = self._serialize.body(parameters, 'ResourceGroupPatchable') + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(parameters, (IO, bytes)): + _content = parameters + else: + _json = self._serialize.body(parameters, "ResourceGroupPatchable") request = build_resource_groups_update_request( resource_group_name=resource_group_name, @@ -9712,65 +11135,77 @@ def update( api_version=api_version, content_type=content_type, json=_json, - template_url=self.update.metadata['url'], + content=_content, + template_url=self.update.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) - deserialized = self._deserialize('ResourceGroup', pipeline_response) + deserialized = self._deserialize("ResourceGroup", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - update.metadata = {'url': "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}"} # type: ignore - + update.metadata = {"url": "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}"} # type: ignore def _export_template_initial( - self, - resource_group_name: str, - parameters: "_models.ExportTemplateRequest", - **kwargs: Any - ) -> Optional["_models.ResourceGroupExportResult"]: - cls = kwargs.pop('cls', None) # type: ClsType[Optional["_models.ResourceGroupExportResult"]] + self, resource_group_name: str, parameters: Union[_models.ExportTemplateRequest, IO], **kwargs: Any + ) -> Optional[_models.ResourceGroupExportResult]: error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) - api_version = kwargs.pop('api_version', "2019-10-01") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - _json = self._serialize.body(parameters, 'ExportTemplateRequest') + api_version = kwargs.pop("api_version", _params.pop("api-version", "2019-10-01")) # type: str + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[Optional[_models.ResourceGroupExportResult]] - request = build_resource_groups_export_template_request_initial( - subscription_id=self._config.subscription_id, + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(parameters, (IO, bytes)): + _content = parameters + else: + _json = self._serialize.body(parameters, "ExportTemplateRequest") + + request = build_resource_groups_export_template_request( resource_group_name=resource_group_name, + subscription_id=self._config.subscription_id, api_version=api_version, content_type=content_type, json=_json, - template_url=self._export_template_initial.metadata['url'], + content=_content, + template_url=self._export_template_initial.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200, 202]: @@ -9779,29 +11214,93 @@ def _export_template_initial( deserialized = None if response.status_code == 200: - deserialized = self._deserialize('ResourceGroupExportResult', pipeline_response) + deserialized = self._deserialize("ResourceGroupExportResult", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - _export_template_initial.metadata = {'url': "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/exportTemplate"} # type: ignore + _export_template_initial.metadata = {"url": "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/exportTemplate"} # type: ignore + + @overload + def begin_export_template( + self, + resource_group_name: str, + parameters: _models.ExportTemplateRequest, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> LROPoller[_models.ResourceGroupExportResult]: + """Captures the specified resource group as a template. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param parameters: Parameters for exporting the template. Required. + :type parameters: ~azure.mgmt.resource.resources.v2019_10_01.models.ExportTemplateRequest + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be ARMPolling. Pass in False for this + operation to not poll, or pass in your own initialized polling object for a personal polling + strategy. + :paramtype polling: bool or ~azure.core.polling.PollingMethod + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of LROPoller that returns either ResourceGroupExportResult or the result + of cls(response) + :rtype: + ~azure.core.polling.LROPoller[~azure.mgmt.resource.resources.v2019_10_01.models.ResourceGroupExportResult] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + def begin_export_template( + self, resource_group_name: str, parameters: IO, *, content_type: str = "application/json", **kwargs: Any + ) -> LROPoller[_models.ResourceGroupExportResult]: + """Captures the specified resource group as a template. + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param parameters: Parameters for exporting the template. Required. + :type parameters: IO + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be ARMPolling. Pass in False for this + operation to not poll, or pass in your own initialized polling object for a personal polling + strategy. + :paramtype polling: bool or ~azure.core.polling.PollingMethod + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of LROPoller that returns either ResourceGroupExportResult or the result + of cls(response) + :rtype: + ~azure.core.polling.LROPoller[~azure.mgmt.resource.resources.v2019_10_01.models.ResourceGroupExportResult] + :raises ~azure.core.exceptions.HttpResponseError: + """ @distributed_trace def begin_export_template( - self, - resource_group_name: str, - parameters: "_models.ExportTemplateRequest", - **kwargs: Any - ) -> LROPoller["_models.ResourceGroupExportResult"]: + self, resource_group_name: str, parameters: Union[_models.ExportTemplateRequest, IO], **kwargs: Any + ) -> LROPoller[_models.ResourceGroupExportResult]: """Captures the specified resource group as a template. :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. :type resource_group_name: str - :param parameters: Parameters for exporting the template. - :type parameters: ~azure.mgmt.resource.resources.v2019_10_01.models.ExportTemplateRequest + :param parameters: Parameters for exporting the template. Is either a model type or a IO type. + Required. + :type parameters: ~azure.mgmt.resource.resources.v2019_10_01.models.ExportTemplateRequest or IO + :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. + Default value is None. + :paramtype content_type: str :keyword callable cls: A custom type or function that will be passed the direct response :keyword str continuation_token: A continuation token to restart a poller from a saved state. :keyword polling: By default, your polling method will be ARMPolling. Pass in False for this @@ -9814,57 +11313,59 @@ def begin_export_template( of cls(response) :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.resource.resources.v2019_10_01.models.ResourceGroupExportResult] - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - api_version = kwargs.pop('api_version', "2019-10-01") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] - polling = kwargs.pop('polling', True) # type: Union[bool, PollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType["_models.ResourceGroupExportResult"] - lro_delay = kwargs.pop( - 'polling_interval', - self._config.polling_interval - ) - cont_token = kwargs.pop('continuation_token', None) # type: Optional[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", "2019-10-01")) # type: str + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.ResourceGroupExportResult] + polling = kwargs.pop("polling", True) # type: Union[bool, PollingMethod] + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token = kwargs.pop("continuation_token", None) # type: Optional[str] if cont_token is None: - raw_result = self._export_template_initial( + raw_result = self._export_template_initial( # type: ignore resource_group_name=resource_group_name, parameters=parameters, api_version=api_version, content_type=content_type, - cls=lambda x,y,z: x, + cls=lambda x, y, z: x, + headers=_headers, + params=_params, **kwargs ) - kwargs.pop('error_map', None) + kwargs.pop("error_map", None) def get_long_running_output(pipeline_response): - response = pipeline_response.http_response - deserialized = self._deserialize('ResourceGroupExportResult', pipeline_response) + deserialized = self._deserialize("ResourceGroupExportResult", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - - if polling is True: polling_method = ARMPolling(lro_delay, lro_options={'final-state-via': 'location'}, **kwargs) - elif polling is False: polling_method = NoPolling() - else: polling_method = polling + if polling is True: + polling_method = cast( + PollingMethod, ARMPolling(lro_delay, lro_options={"final-state-via": "location"}, **kwargs) + ) # type: PollingMethod + elif polling is False: + polling_method = cast(PollingMethod, NoPolling()) + else: + polling_method = polling if cont_token: return LROPoller.from_continuation_token( polling_method=polling_method, continuation_token=cont_token, client=self._client, - deserialization_callback=get_long_running_output + deserialization_callback=get_long_running_output, ) return LROPoller(self._client, raw_result, get_long_running_output, polling_method) - begin_export_template.metadata = {'url': "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/exportTemplate"} # type: ignore + begin_export_template.metadata = {"url": "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/exportTemplate"} # type: ignore @distributed_trace def list( - self, - filter: Optional[str] = None, - top: Optional[int] = None, - **kwargs: Any - ) -> Iterable["_models.ResourceGroupListResult"]: + self, filter: Optional[str] = None, top: Optional[int] = None, **kwargs: Any + ) -> Iterable["_models.ResourceGroup"]: """Gets all the resource groups for a subscription. :param filter: The filter to apply on the operation.:code:`
`:code:`
`You can filter by @@ -9875,40 +11376,48 @@ def list( Default value is None. :type top: int :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either ResourceGroupListResult or the result of - cls(response) + :return: An iterator like instance of either ResourceGroup or the result of cls(response) :rtype: - ~azure.core.paging.ItemPaged[~azure.mgmt.resource.resources.v2019_10_01.models.ResourceGroupListResult] - :raises: ~azure.core.exceptions.HttpResponseError + ~azure.core.paging.ItemPaged[~azure.mgmt.resource.resources.v2019_10_01.models.ResourceGroup] + :raises ~azure.core.exceptions.HttpResponseError: """ - api_version = kwargs.pop('api_version', "2019-10-01") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2019-10-01")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[_models.ResourceGroupListResult] - cls = kwargs.pop('cls', None) # type: ClsType["_models.ResourceGroupListResult"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) + def prepare_request(next_link=None): if not next_link: - + request = build_resource_groups_list_request( subscription_id=self._config.subscription_id, - api_version=api_version, filter=filter, top=top, - template_url=self.list.metadata['url'], + 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.url = self._client.format_url(request.url) # type: ignore else: - - request = build_resource_groups_list_request( - subscription_id=self._config.subscription_id, - template_url=next_link, - ) + # make call to next link with the client's api-version + _parsed_next_link = urlparse(next_link) + _next_request_params = case_insensitive_dict(parse_qs(_parsed_next_link.query)) + _next_request_params["api-version"] = self._config.api_version + request = HttpRequest("GET", urljoin(next_link, _parsed_next_link.path), params=_next_request_params) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore request.method = "GET" return request @@ -9922,10 +11431,8 @@ def extract_data(pipeline_response): def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) response = pipeline_response.http_response @@ -9935,39 +11442,33 @@ def get_next(next_link=None): return pipeline_response + return ItemPaged(get_next, extract_data) - return ItemPaged( - get_next, extract_data - ) - list.metadata = {'url': "/subscriptions/{subscriptionId}/resourcegroups"} # type: ignore -class TagsOperations(object): - """TagsOperations operations. + list.metadata = {"url": "/subscriptions/{subscriptionId}/resourcegroups"} # type: ignore - You should not instantiate this class directly. Instead, you should create a Client instance that - instantiates it for you and attaches it as an attribute. - :ivar models: Alias to model classes used in this operation group. - :type models: ~azure.mgmt.resource.resources.v2019_10_01.models - :param client: Client for service requests. - :param config: Configuration of service client. - :param serializer: An object model serializer. - :param deserializer: An object model deserializer. +class TagsOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. + + Instead, you should access the following operations through + :class:`~azure.mgmt.resource.resources.v2019_10_01.ResourceManagementClient`'s + :attr:`tags` attribute. """ models = _models - def __init__(self, client, config, serializer, deserializer): - self._client = client - self._serialize = serializer - self._deserialize = deserializer - self._config = config + def __init__(self, *args, **kwargs): + input_args = list(args) + self._client = input_args.pop(0) if input_args else kwargs.pop("client") + self._config = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") @distributed_trace def delete_value( # pylint: disable=inconsistent-return-statements - self, - tag_name: str, - tag_value: str, - **kwargs: Any + self, tag_name: str, tag_value: str, **kwargs: Any ) -> None: """Deletes a predefined tag value for a predefined tag name. @@ -9975,39 +11476,45 @@ def delete_value( # pylint: disable=inconsistent-return-statements predefined tag name. The value being deleted must not be in use as a tag value for the given tag name for any resource. - :param tag_name: The name of the tag. + :param tag_name: The name of the tag. Required. :type tag_name: str - :param tag_value: The value of the tag to delete. + :param tag_value: The value of the tag to delete. Required. :type tag_value: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: None, or the result of cls(response) + :return: None or the result of cls(response) :rtype: None - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType[None] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) - api_version = kwargs.pop('api_version', "2019-10-01") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2019-10-01")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[None] - request = build_tags_delete_value_request( tag_name=tag_name, tag_value=tag_value, subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.delete_value.metadata['url'], + template_url=self.delete_value.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200, 204]: @@ -10017,54 +11524,54 @@ def delete_value( # pylint: disable=inconsistent-return-statements if cls: return cls(pipeline_response, None, {}) - delete_value.metadata = {'url': "/subscriptions/{subscriptionId}/tagNames/{tagName}/tagValues/{tagValue}"} # type: ignore - + delete_value.metadata = {"url": "/subscriptions/{subscriptionId}/tagNames/{tagName}/tagValues/{tagValue}"} # type: ignore @distributed_trace - def create_or_update_value( - self, - tag_name: str, - tag_value: str, - **kwargs: Any - ) -> "_models.TagValue": + def create_or_update_value(self, tag_name: str, tag_value: str, **kwargs: Any) -> _models.TagValue: """Creates a predefined value for a predefined tag name. This operation allows adding a value to the list of predefined values for an existing predefined tag name. A tag value can have a maximum of 256 characters. - :param tag_name: The name of the tag. + :param tag_name: The name of the tag. Required. :type tag_name: str - :param tag_value: The value of the tag to create. + :param tag_value: The value of the tag to create. Required. :type tag_value: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: TagValue, or the result of cls(response) + :return: TagValue or the result of cls(response) :rtype: ~azure.mgmt.resource.resources.v2019_10_01.models.TagValue - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.TagValue"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + 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', "2019-10-01") # type: str + api_version = kwargs.pop("api_version", _params.pop("api-version", "2019-10-01")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[_models.TagValue] - request = build_tags_create_or_update_value_request( tag_name=tag_name, tag_value=tag_value, subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.create_or_update_value.metadata['url'], + template_url=self.create_or_update_value.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200, 201]: @@ -10072,25 +11579,20 @@ def create_or_update_value( raise HttpResponseError(response=response, error_format=ARMErrorFormat) if response.status_code == 200: - deserialized = self._deserialize('TagValue', pipeline_response) + deserialized = self._deserialize("TagValue", pipeline_response) if response.status_code == 201: - deserialized = self._deserialize('TagValue', pipeline_response) + deserialized = self._deserialize("TagValue", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - create_or_update_value.metadata = {'url': "/subscriptions/{subscriptionId}/tagNames/{tagName}/tagValues/{tagValue}"} # type: ignore - + create_or_update_value.metadata = {"url": "/subscriptions/{subscriptionId}/tagNames/{tagName}/tagValues/{tagValue}"} # type: ignore @distributed_trace - def create_or_update( - self, - tag_name: str, - **kwargs: Any - ) -> "_models.TagDetails": + def create_or_update(self, tag_name: str, **kwargs: Any) -> _models.TagDetails: """Creates a predefined tag name. This operation allows adding a name to the list of predefined tag names for the given @@ -10098,36 +11600,42 @@ def create_or_update( names cannot have the following prefixes which are reserved for Azure use: 'microsoft', 'azure', 'windows'. - :param tag_name: The name of the tag to create. + :param tag_name: The name of the tag to create. Required. :type tag_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: TagDetails, or the result of cls(response) + :return: TagDetails or the result of cls(response) :rtype: ~azure.mgmt.resource.resources.v2019_10_01.models.TagDetails - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.TagDetails"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + 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', "2019-10-01") # type: str + api_version = kwargs.pop("api_version", _params.pop("api-version", "2019-10-01")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[_models.TagDetails] - request = build_tags_create_or_update_request( tag_name=tag_name, subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.create_or_update.metadata['url'], + template_url=self.create_or_update.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200, 201]: @@ -10135,61 +11643,62 @@ def create_or_update( raise HttpResponseError(response=response, error_format=ARMErrorFormat) if response.status_code == 200: - deserialized = self._deserialize('TagDetails', pipeline_response) + deserialized = self._deserialize("TagDetails", pipeline_response) if response.status_code == 201: - deserialized = self._deserialize('TagDetails', pipeline_response) + deserialized = self._deserialize("TagDetails", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - create_or_update.metadata = {'url': "/subscriptions/{subscriptionId}/tagNames/{tagName}"} # type: ignore - + create_or_update.metadata = {"url": "/subscriptions/{subscriptionId}/tagNames/{tagName}"} # type: ignore @distributed_trace - def delete( # pylint: disable=inconsistent-return-statements - self, - tag_name: str, - **kwargs: Any - ) -> None: + def delete(self, tag_name: str, **kwargs: Any) -> None: # pylint: disable=inconsistent-return-statements """Deletes a predefined tag name. This operation allows deleting a name from the list of predefined tag names for the given subscription. The name being deleted must not be in use as a tag name for any resource. All predefined values for the given name must have already been deleted. - :param tag_name: The name of the tag. + :param tag_name: The name of the tag. Required. :type tag_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: None, or the result of cls(response) + :return: None or the result of cls(response) :rtype: None - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType[None] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + 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', "2019-10-01") # type: str + api_version = kwargs.pop("api_version", _params.pop("api-version", "2019-10-01")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[None] - request = build_tags_delete_request( tag_name=tag_name, subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.delete.metadata['url'], + template_url=self.delete.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200, 204]: @@ -10199,14 +11708,10 @@ def delete( # pylint: disable=inconsistent-return-statements if cls: return cls(pipeline_response, None, {}) - delete.metadata = {'url': "/subscriptions/{subscriptionId}/tagNames/{tagName}"} # type: ignore - + delete.metadata = {"url": "/subscriptions/{subscriptionId}/tagNames/{tagName}"} # type: ignore @distributed_trace - def list( - self, - **kwargs: Any - ) -> Iterable["_models.TagsListResult"]: + def list(self, **kwargs: Any) -> Iterable["_models.TagDetails"]: """Gets a summary of tag usage under the subscription. This operation performs a union of predefined tags, resource tags, resource group tags and @@ -10215,37 +11720,46 @@ def list( result. :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either TagsListResult or the result of cls(response) + :return: An iterator like instance of either TagDetails or the result of cls(response) :rtype: - ~azure.core.paging.ItemPaged[~azure.mgmt.resource.resources.v2019_10_01.models.TagsListResult] - :raises: ~azure.core.exceptions.HttpResponseError + ~azure.core.paging.ItemPaged[~azure.mgmt.resource.resources.v2019_10_01.models.TagDetails] + :raises ~azure.core.exceptions.HttpResponseError: """ - api_version = kwargs.pop('api_version', "2019-10-01") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2019-10-01")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[_models.TagsListResult] - cls = kwargs.pop('cls', None) # type: ClsType["_models.TagsListResult"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) + def prepare_request(next_link=None): if not next_link: - + request = build_tags_list_request( subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.list.metadata['url'], + template_url=self.list.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore else: - - request = build_tags_list_request( - subscription_id=self._config.subscription_id, - template_url=next_link, - ) + # make call to next link with the client's api-version + _parsed_next_link = urlparse(next_link) + _next_request_params = case_insensitive_dict(parse_qs(_parsed_next_link.query)) + _next_request_params["api-version"] = self._config.api_version + request = HttpRequest("GET", urljoin(next_link, _parsed_next_link.path), params=_next_request_params) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore request.method = "GET" return request @@ -10259,10 +11773,8 @@ def extract_data(pipeline_response): def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) response = pipeline_response.http_response @@ -10272,82 +11784,139 @@ def get_next(next_link=None): return pipeline_response + return ItemPaged(get_next, extract_data) - return ItemPaged( - get_next, extract_data - ) - list.metadata = {'url': "/subscriptions/{subscriptionId}/tagNames"} # type: ignore + list.metadata = {"url": "/subscriptions/{subscriptionId}/tagNames"} # type: ignore - @distributed_trace + @overload def create_or_update_at_scope( - self, - scope: str, - parameters: "_models.TagsResource", - **kwargs: Any - ) -> "_models.TagsResource": + self, scope: str, parameters: _models.TagsResource, *, content_type: str = "application/json", **kwargs: Any + ) -> _models.TagsResource: """Creates or updates the entire set of tags on a resource or subscription. This operation allows adding or replacing the entire set of tags on the specified resource or subscription. The specified entity can have a maximum of 50 tags. - :param scope: The resource scope. + :param scope: The resource scope. Required. :type scope: str - :param parameters: + :param parameters: Required. :type parameters: ~azure.mgmt.resource.resources.v2019_10_01.models.TagsResource + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: TagsResource or the result of cls(response) + :rtype: ~azure.mgmt.resource.resources.v2019_10_01.models.TagsResource + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + def create_or_update_at_scope( + self, scope: str, parameters: IO, *, content_type: str = "application/json", **kwargs: Any + ) -> _models.TagsResource: + """Creates or updates the entire set of tags on a resource or subscription. + + This operation allows adding or replacing the entire set of tags on the specified resource or + subscription. The specified entity can have a maximum of 50 tags. + + :param scope: The resource scope. Required. + :type scope: str + :param parameters: Required. + :type parameters: IO + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: TagsResource or the result of cls(response) + :rtype: ~azure.mgmt.resource.resources.v2019_10_01.models.TagsResource + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace + def create_or_update_at_scope( + self, scope: str, parameters: Union[_models.TagsResource, IO], **kwargs: Any + ) -> _models.TagsResource: + """Creates or updates the entire set of tags on a resource or subscription. + + This operation allows adding or replacing the entire set of tags on the specified resource or + subscription. The specified entity can have a maximum of 50 tags. + + :param scope: The resource scope. Required. + :type scope: str + :param parameters: Is either a model type or a IO type. Required. + :type parameters: ~azure.mgmt.resource.resources.v2019_10_01.models.TagsResource or IO + :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. + Default value is None. + :paramtype content_type: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: TagsResource, or the result of cls(response) + :return: TagsResource or the result of cls(response) :rtype: ~azure.mgmt.resource.resources.v2019_10_01.models.TagsResource - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.TagsResource"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', "2019-10-01") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + api_version = kwargs.pop("api_version", _params.pop("api-version", "2019-10-01")) # type: str + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.TagsResource] - _json = self._serialize.body(parameters, 'TagsResource') + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(parameters, (IO, bytes)): + _content = parameters + else: + _json = self._serialize.body(parameters, "TagsResource") request = build_tags_create_or_update_at_scope_request( scope=scope, api_version=api_version, content_type=content_type, json=_json, - template_url=self.create_or_update_at_scope.metadata['url'], + content=_content, + template_url=self.create_or_update_at_scope.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) - deserialized = self._deserialize('TagsResource', pipeline_response) + deserialized = self._deserialize("TagsResource", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - create_or_update_at_scope.metadata = {'url': "/{scope}/providers/Microsoft.Resources/tags/default"} # type: ignore - + create_or_update_at_scope.metadata = {"url": "/{scope}/providers/Microsoft.Resources/tags/default"} # type: ignore - @distributed_trace + @overload def update_at_scope( self, scope: str, - parameters: "_models.TagsPatchResource", + parameters: _models.TagsPatchResource, + *, + content_type: str = "application/json", **kwargs: Any - ) -> "_models.TagsResource": + ) -> _models.TagsResource: """Selectively updates the set of tags on a resource or subscription. This operation allows replacing, merging or selectively deleting tags on the specified resource @@ -10357,151 +11926,222 @@ def update_at_scope( names. The 'delete' option allows selectively deleting tags based on given names or name/value pairs. - :param scope: The resource scope. + :param scope: The resource scope. Required. :type scope: str - :param parameters: + :param parameters: Required. :type parameters: ~azure.mgmt.resource.resources.v2019_10_01.models.TagsPatchResource + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: TagsResource or the result of cls(response) + :rtype: ~azure.mgmt.resource.resources.v2019_10_01.models.TagsResource + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + def update_at_scope( + self, scope: str, parameters: IO, *, content_type: str = "application/json", **kwargs: Any + ) -> _models.TagsResource: + """Selectively updates the set of tags on a resource or subscription. + + This operation allows replacing, merging or selectively deleting tags on the specified resource + or subscription. The specified entity can have a maximum of 50 tags at the end of the + operation. The 'replace' option replaces the entire set of existing tags with a new set. The + 'merge' option allows adding tags with new names and updating the values of tags with existing + names. The 'delete' option allows selectively deleting tags based on given names or name/value + pairs. + + :param scope: The resource scope. Required. + :type scope: str + :param parameters: Required. + :type parameters: IO + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: TagsResource or the result of cls(response) + :rtype: ~azure.mgmt.resource.resources.v2019_10_01.models.TagsResource + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace + def update_at_scope( + self, scope: str, parameters: Union[_models.TagsPatchResource, IO], **kwargs: Any + ) -> _models.TagsResource: + """Selectively updates the set of tags on a resource or subscription. + + This operation allows replacing, merging or selectively deleting tags on the specified resource + or subscription. The specified entity can have a maximum of 50 tags at the end of the + operation. The 'replace' option replaces the entire set of existing tags with a new set. The + 'merge' option allows adding tags with new names and updating the values of tags with existing + names. The 'delete' option allows selectively deleting tags based on given names or name/value + pairs. + + :param scope: The resource scope. Required. + :type scope: str + :param parameters: Is either a model type or a IO type. Required. + :type parameters: ~azure.mgmt.resource.resources.v2019_10_01.models.TagsPatchResource or IO + :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. + Default value is None. + :paramtype content_type: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: TagsResource, or the result of cls(response) + :return: TagsResource or the result of cls(response) :rtype: ~azure.mgmt.resource.resources.v2019_10_01.models.TagsResource - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.TagsResource"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', "2019-10-01") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + api_version = kwargs.pop("api_version", _params.pop("api-version", "2019-10-01")) # type: str + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.TagsResource] - _json = self._serialize.body(parameters, 'TagsPatchResource') + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(parameters, (IO, bytes)): + _content = parameters + else: + _json = self._serialize.body(parameters, "TagsPatchResource") request = build_tags_update_at_scope_request( scope=scope, api_version=api_version, content_type=content_type, json=_json, - template_url=self.update_at_scope.metadata['url'], + content=_content, + template_url=self.update_at_scope.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) - deserialized = self._deserialize('TagsResource', pipeline_response) + deserialized = self._deserialize("TagsResource", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - update_at_scope.metadata = {'url': "/{scope}/providers/Microsoft.Resources/tags/default"} # type: ignore - + update_at_scope.metadata = {"url": "/{scope}/providers/Microsoft.Resources/tags/default"} # type: ignore @distributed_trace - def get_at_scope( - self, - scope: str, - **kwargs: Any - ) -> "_models.TagsResource": + def get_at_scope(self, scope: str, **kwargs: Any) -> _models.TagsResource: """Gets the entire set of tags on a resource or subscription. Gets the entire set of tags on a resource or subscription. - :param scope: The resource scope. + :param scope: The resource scope. Required. :type scope: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: TagsResource, or the result of cls(response) + :return: TagsResource or the result of cls(response) :rtype: ~azure.mgmt.resource.resources.v2019_10_01.models.TagsResource - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.TagsResource"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) - api_version = kwargs.pop('api_version', "2019-10-01") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2019-10-01")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[_models.TagsResource] - request = build_tags_get_at_scope_request( scope=scope, api_version=api_version, - template_url=self.get_at_scope.metadata['url'], + template_url=self.get_at_scope.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) - deserialized = self._deserialize('TagsResource', pipeline_response) + deserialized = self._deserialize("TagsResource", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - get_at_scope.metadata = {'url': "/{scope}/providers/Microsoft.Resources/tags/default"} # type: ignore - + get_at_scope.metadata = {"url": "/{scope}/providers/Microsoft.Resources/tags/default"} # type: ignore @distributed_trace - def delete_at_scope( # pylint: disable=inconsistent-return-statements - self, - scope: str, - **kwargs: Any - ) -> None: + def delete_at_scope(self, scope: str, **kwargs: Any) -> None: # pylint: disable=inconsistent-return-statements """Deletes the entire set of tags on a resource or subscription. Deletes the entire set of tags on a resource or subscription. - :param scope: The resource scope. + :param scope: The resource scope. Required. :type scope: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: None, or the result of cls(response) + :return: None or the result of cls(response) :rtype: None - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType[None] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + 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', "2019-10-01") # type: str + api_version = kwargs.pop("api_version", _params.pop("api-version", "2019-10-01")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[None] - request = build_tags_delete_at_scope_request( scope=scope, api_version=api_version, - template_url=self.delete_at_scope.metadata['url'], + template_url=self.delete_at_scope.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200]: @@ -10511,143 +12151,145 @@ def delete_at_scope( # pylint: disable=inconsistent-return-statements if cls: return cls(pipeline_response, None, {}) - delete_at_scope.metadata = {'url': "/{scope}/providers/Microsoft.Resources/tags/default"} # type: ignore + delete_at_scope.metadata = {"url": "/{scope}/providers/Microsoft.Resources/tags/default"} # type: ignore -class DeploymentOperationsOperations(object): - """DeploymentOperationsOperations operations. - You should not instantiate this class directly. Instead, you should create a Client instance that - instantiates it for you and attaches it as an attribute. +class DeploymentOperationsOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. - :ivar models: Alias to model classes used in this operation group. - :type models: ~azure.mgmt.resource.resources.v2019_10_01.models - :param client: Client for service requests. - :param config: Configuration of service client. - :param serializer: An object model serializer. - :param deserializer: An object model deserializer. + Instead, you should access the following operations through + :class:`~azure.mgmt.resource.resources.v2019_10_01.ResourceManagementClient`'s + :attr:`deployment_operations` attribute. """ models = _models - def __init__(self, client, config, serializer, deserializer): - self._client = client - self._serialize = serializer - self._deserialize = deserializer - self._config = config + def __init__(self, *args, **kwargs): + input_args = list(args) + self._client = input_args.pop(0) if input_args else kwargs.pop("client") + self._config = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") @distributed_trace def get_at_scope( - self, - scope: str, - deployment_name: str, - operation_id: str, - **kwargs: Any - ) -> "_models.DeploymentOperation": + self, scope: str, deployment_name: str, operation_id: str, **kwargs: Any + ) -> _models.DeploymentOperation: """Gets a deployments operation. - :param scope: The resource scope. + :param scope: The resource scope. Required. :type scope: str - :param deployment_name: The name of the deployment. + :param deployment_name: The name of the deployment. Required. :type deployment_name: str - :param operation_id: The ID of the operation to get. + :param operation_id: The ID of the operation to get. Required. :type operation_id: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: DeploymentOperation, or the result of cls(response) + :return: DeploymentOperation or the result of cls(response) :rtype: ~azure.mgmt.resource.resources.v2019_10_01.models.DeploymentOperation - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.DeploymentOperation"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) - api_version = kwargs.pop('api_version', "2019-10-01") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2019-10-01")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[_models.DeploymentOperation] - request = build_deployment_operations_get_at_scope_request( scope=scope, deployment_name=deployment_name, operation_id=operation_id, api_version=api_version, - template_url=self.get_at_scope.metadata['url'], + template_url=self.get_at_scope.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) - deserialized = self._deserialize('DeploymentOperation', pipeline_response) + deserialized = self._deserialize("DeploymentOperation", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - get_at_scope.metadata = {'url': "/{scope}/providers/Microsoft.Resources/deployments/{deploymentName}/operations/{operationId}"} # type: ignore - + get_at_scope.metadata = {"url": "/{scope}/providers/Microsoft.Resources/deployments/{deploymentName}/operations/{operationId}"} # type: ignore @distributed_trace def list_at_scope( - self, - scope: str, - deployment_name: str, - top: Optional[int] = None, - **kwargs: Any - ) -> Iterable["_models.DeploymentOperationsListResult"]: + self, scope: str, deployment_name: str, top: Optional[int] = None, **kwargs: Any + ) -> Iterable["_models.DeploymentOperation"]: """Gets all deployments operations for a deployment. - :param scope: The resource scope. + :param scope: The resource scope. Required. :type scope: str - :param deployment_name: The name of the deployment. + :param deployment_name: The name of the deployment. Required. :type deployment_name: str :param top: The number of results to return. Default value is None. :type top: int :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either DeploymentOperationsListResult or the result of - cls(response) + :return: An iterator like instance of either DeploymentOperation or the result of cls(response) :rtype: - ~azure.core.paging.ItemPaged[~azure.mgmt.resource.resources.v2019_10_01.models.DeploymentOperationsListResult] - :raises: ~azure.core.exceptions.HttpResponseError + ~azure.core.paging.ItemPaged[~azure.mgmt.resource.resources.v2019_10_01.models.DeploymentOperation] + :raises ~azure.core.exceptions.HttpResponseError: """ - api_version = kwargs.pop('api_version', "2019-10-01") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2019-10-01")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[_models.DeploymentOperationsListResult] - cls = kwargs.pop('cls', None) # type: ClsType["_models.DeploymentOperationsListResult"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) + def prepare_request(next_link=None): if not next_link: - + request = build_deployment_operations_list_at_scope_request( scope=scope, deployment_name=deployment_name, - api_version=api_version, top=top, - template_url=self.list_at_scope.metadata['url'], + api_version=api_version, + template_url=self.list_at_scope.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore else: - - request = build_deployment_operations_list_at_scope_request( - scope=scope, - deployment_name=deployment_name, - template_url=next_link, - ) + # make call to next link with the client's api-version + _parsed_next_link = urlparse(next_link) + _next_request_params = case_insensitive_dict(parse_qs(_parsed_next_link.query)) + _next_request_params["api-version"] = self._config.api_version + request = HttpRequest("GET", urljoin(next_link, _parsed_next_link.path), params=_next_request_params) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore request.method = "GET" return request @@ -10661,10 +12303,8 @@ def extract_data(pipeline_response): def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) response = pipeline_response.http_response @@ -10674,116 +12314,121 @@ def get_next(next_link=None): return pipeline_response + return ItemPaged(get_next, extract_data) - return ItemPaged( - get_next, extract_data - ) - list_at_scope.metadata = {'url': "/{scope}/providers/Microsoft.Resources/deployments/{deploymentName}/operations"} # type: ignore + list_at_scope.metadata = {"url": "/{scope}/providers/Microsoft.Resources/deployments/{deploymentName}/operations"} # type: ignore @distributed_trace def get_at_tenant_scope( - self, - deployment_name: str, - operation_id: str, - **kwargs: Any - ) -> "_models.DeploymentOperation": + self, deployment_name: str, operation_id: str, **kwargs: Any + ) -> _models.DeploymentOperation: """Gets a deployments operation. - :param deployment_name: The name of the deployment. + :param deployment_name: The name of the deployment. Required. :type deployment_name: str - :param operation_id: The ID of the operation to get. + :param operation_id: The ID of the operation to get. Required. :type operation_id: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: DeploymentOperation, or the result of cls(response) + :return: DeploymentOperation or the result of cls(response) :rtype: ~azure.mgmt.resource.resources.v2019_10_01.models.DeploymentOperation - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.DeploymentOperation"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + 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', "2019-10-01") # type: str + api_version = kwargs.pop("api_version", _params.pop("api-version", "2019-10-01")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[_models.DeploymentOperation] - request = build_deployment_operations_get_at_tenant_scope_request( deployment_name=deployment_name, operation_id=operation_id, api_version=api_version, - template_url=self.get_at_tenant_scope.metadata['url'], + template_url=self.get_at_tenant_scope.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) - deserialized = self._deserialize('DeploymentOperation', pipeline_response) + deserialized = self._deserialize("DeploymentOperation", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - get_at_tenant_scope.metadata = {'url': "/providers/Microsoft.Resources/deployments/{deploymentName}/operations/{operationId}"} # type: ignore - + get_at_tenant_scope.metadata = {"url": "/providers/Microsoft.Resources/deployments/{deploymentName}/operations/{operationId}"} # type: ignore @distributed_trace def list_at_tenant_scope( - self, - deployment_name: str, - top: Optional[int] = None, - **kwargs: Any - ) -> Iterable["_models.DeploymentOperationsListResult"]: + self, deployment_name: str, top: Optional[int] = None, **kwargs: Any + ) -> Iterable["_models.DeploymentOperation"]: """Gets all deployments operations for a deployment. - :param deployment_name: The name of the deployment. + :param deployment_name: The name of the deployment. Required. :type deployment_name: str :param top: The number of results to return. Default value is None. :type top: int :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either DeploymentOperationsListResult or the result of - cls(response) + :return: An iterator like instance of either DeploymentOperation or the result of cls(response) :rtype: - ~azure.core.paging.ItemPaged[~azure.mgmt.resource.resources.v2019_10_01.models.DeploymentOperationsListResult] - :raises: ~azure.core.exceptions.HttpResponseError + ~azure.core.paging.ItemPaged[~azure.mgmt.resource.resources.v2019_10_01.models.DeploymentOperation] + :raises ~azure.core.exceptions.HttpResponseError: """ - api_version = kwargs.pop('api_version', "2019-10-01") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2019-10-01")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[_models.DeploymentOperationsListResult] - cls = kwargs.pop('cls', None) # type: ClsType["_models.DeploymentOperationsListResult"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) + def prepare_request(next_link=None): if not next_link: - + request = build_deployment_operations_list_at_tenant_scope_request( deployment_name=deployment_name, - api_version=api_version, top=top, - template_url=self.list_at_tenant_scope.metadata['url'], + api_version=api_version, + template_url=self.list_at_tenant_scope.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore else: - - request = build_deployment_operations_list_at_tenant_scope_request( - deployment_name=deployment_name, - template_url=next_link, - ) + # make call to next link with the client's api-version + _parsed_next_link = urlparse(next_link) + _next_request_params = case_insensitive_dict(parse_qs(_parsed_next_link.query)) + _next_request_params["api-version"] = self._config.api_version + request = HttpRequest("GET", urljoin(next_link, _parsed_next_link.path), params=_next_request_params) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore request.method = "GET" return request @@ -10797,10 +12442,8 @@ def extract_data(pipeline_response): def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) response = pipeline_response.http_response @@ -10810,125 +12453,127 @@ def get_next(next_link=None): return pipeline_response + return ItemPaged(get_next, extract_data) - return ItemPaged( - get_next, extract_data - ) - list_at_tenant_scope.metadata = {'url': "/providers/Microsoft.Resources/deployments/{deploymentName}/operations"} # type: ignore + list_at_tenant_scope.metadata = {"url": "/providers/Microsoft.Resources/deployments/{deploymentName}/operations"} # type: ignore @distributed_trace def get_at_management_group_scope( - self, - group_id: str, - deployment_name: str, - operation_id: str, - **kwargs: Any - ) -> "_models.DeploymentOperation": + self, group_id: str, deployment_name: str, operation_id: str, **kwargs: Any + ) -> _models.DeploymentOperation: """Gets a deployments operation. - :param group_id: The management group ID. + :param group_id: The management group ID. Required. :type group_id: str - :param deployment_name: The name of the deployment. + :param deployment_name: The name of the deployment. Required. :type deployment_name: str - :param operation_id: The ID of the operation to get. + :param operation_id: The ID of the operation to get. Required. :type operation_id: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: DeploymentOperation, or the result of cls(response) + :return: DeploymentOperation or the result of cls(response) :rtype: ~azure.mgmt.resource.resources.v2019_10_01.models.DeploymentOperation - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.DeploymentOperation"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + 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', "2019-10-01") # type: str + api_version = kwargs.pop("api_version", _params.pop("api-version", "2019-10-01")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[_models.DeploymentOperation] - request = build_deployment_operations_get_at_management_group_scope_request( group_id=group_id, deployment_name=deployment_name, operation_id=operation_id, api_version=api_version, - template_url=self.get_at_management_group_scope.metadata['url'], + template_url=self.get_at_management_group_scope.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) - deserialized = self._deserialize('DeploymentOperation', pipeline_response) + deserialized = self._deserialize("DeploymentOperation", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - get_at_management_group_scope.metadata = {'url': "/providers/Microsoft.Management/managementGroups/{groupId}/providers/Microsoft.Resources/deployments/{deploymentName}/operations/{operationId}"} # type: ignore - + get_at_management_group_scope.metadata = {"url": "/providers/Microsoft.Management/managementGroups/{groupId}/providers/Microsoft.Resources/deployments/{deploymentName}/operations/{operationId}"} # type: ignore @distributed_trace def list_at_management_group_scope( - self, - group_id: str, - deployment_name: str, - top: Optional[int] = None, - **kwargs: Any - ) -> Iterable["_models.DeploymentOperationsListResult"]: + self, group_id: str, deployment_name: str, top: Optional[int] = None, **kwargs: Any + ) -> Iterable["_models.DeploymentOperation"]: """Gets all deployments operations for a deployment. - :param group_id: The management group ID. + :param group_id: The management group ID. Required. :type group_id: str - :param deployment_name: The name of the deployment. + :param deployment_name: The name of the deployment. Required. :type deployment_name: str :param top: The number of results to return. Default value is None. :type top: int :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either DeploymentOperationsListResult or the result of - cls(response) + :return: An iterator like instance of either DeploymentOperation or the result of cls(response) :rtype: - ~azure.core.paging.ItemPaged[~azure.mgmt.resource.resources.v2019_10_01.models.DeploymentOperationsListResult] - :raises: ~azure.core.exceptions.HttpResponseError + ~azure.core.paging.ItemPaged[~azure.mgmt.resource.resources.v2019_10_01.models.DeploymentOperation] + :raises ~azure.core.exceptions.HttpResponseError: """ - api_version = kwargs.pop('api_version', "2019-10-01") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2019-10-01")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[_models.DeploymentOperationsListResult] - cls = kwargs.pop('cls', None) # type: ClsType["_models.DeploymentOperationsListResult"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) + def prepare_request(next_link=None): if not next_link: - + request = build_deployment_operations_list_at_management_group_scope_request( group_id=group_id, deployment_name=deployment_name, - api_version=api_version, top=top, - template_url=self.list_at_management_group_scope.metadata['url'], + api_version=api_version, + template_url=self.list_at_management_group_scope.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore else: - - request = build_deployment_operations_list_at_management_group_scope_request( - group_id=group_id, - deployment_name=deployment_name, - template_url=next_link, - ) + # make call to next link with the client's api-version + _parsed_next_link = urlparse(next_link) + _next_request_params = case_insensitive_dict(parse_qs(_parsed_next_link.query)) + _next_request_params["api-version"] = self._config.api_version + request = HttpRequest("GET", urljoin(next_link, _parsed_next_link.path), params=_next_request_params) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore request.method = "GET" return request @@ -10942,10 +12587,8 @@ def extract_data(pipeline_response): def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) response = pipeline_response.http_response @@ -10955,119 +12598,123 @@ def get_next(next_link=None): return pipeline_response + return ItemPaged(get_next, extract_data) - return ItemPaged( - get_next, extract_data - ) - list_at_management_group_scope.metadata = {'url': "/providers/Microsoft.Management/managementGroups/{groupId}/providers/Microsoft.Resources/deployments/{deploymentName}/operations"} # type: ignore + list_at_management_group_scope.metadata = {"url": "/providers/Microsoft.Management/managementGroups/{groupId}/providers/Microsoft.Resources/deployments/{deploymentName}/operations"} # type: ignore @distributed_trace def get_at_subscription_scope( - self, - deployment_name: str, - operation_id: str, - **kwargs: Any - ) -> "_models.DeploymentOperation": + self, deployment_name: str, operation_id: str, **kwargs: Any + ) -> _models.DeploymentOperation: """Gets a deployments operation. - :param deployment_name: The name of the deployment. + :param deployment_name: The name of the deployment. Required. :type deployment_name: str - :param operation_id: The ID of the operation to get. + :param operation_id: The ID of the operation to get. Required. :type operation_id: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: DeploymentOperation, or the result of cls(response) + :return: DeploymentOperation or the result of cls(response) :rtype: ~azure.mgmt.resource.resources.v2019_10_01.models.DeploymentOperation - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.DeploymentOperation"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) - api_version = kwargs.pop('api_version', "2019-10-01") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2019-10-01")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[_models.DeploymentOperation] - request = build_deployment_operations_get_at_subscription_scope_request( deployment_name=deployment_name, operation_id=operation_id, subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.get_at_subscription_scope.metadata['url'], + template_url=self.get_at_subscription_scope.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) - deserialized = self._deserialize('DeploymentOperation', pipeline_response) + deserialized = self._deserialize("DeploymentOperation", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - get_at_subscription_scope.metadata = {'url': "/subscriptions/{subscriptionId}/providers/Microsoft.Resources/deployments/{deploymentName}/operations/{operationId}"} # type: ignore - + get_at_subscription_scope.metadata = {"url": "/subscriptions/{subscriptionId}/providers/Microsoft.Resources/deployments/{deploymentName}/operations/{operationId}"} # type: ignore @distributed_trace def list_at_subscription_scope( - self, - deployment_name: str, - top: Optional[int] = None, - **kwargs: Any - ) -> Iterable["_models.DeploymentOperationsListResult"]: + self, deployment_name: str, top: Optional[int] = None, **kwargs: Any + ) -> Iterable["_models.DeploymentOperation"]: """Gets all deployments operations for a deployment. - :param deployment_name: The name of the deployment. + :param deployment_name: The name of the deployment. Required. :type deployment_name: str :param top: The number of results to return. Default value is None. :type top: int :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either DeploymentOperationsListResult or the result of - cls(response) + :return: An iterator like instance of either DeploymentOperation or the result of cls(response) :rtype: - ~azure.core.paging.ItemPaged[~azure.mgmt.resource.resources.v2019_10_01.models.DeploymentOperationsListResult] - :raises: ~azure.core.exceptions.HttpResponseError + ~azure.core.paging.ItemPaged[~azure.mgmt.resource.resources.v2019_10_01.models.DeploymentOperation] + :raises ~azure.core.exceptions.HttpResponseError: """ - api_version = kwargs.pop('api_version', "2019-10-01") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2019-10-01")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[_models.DeploymentOperationsListResult] - cls = kwargs.pop('cls', None) # type: ClsType["_models.DeploymentOperationsListResult"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) + def prepare_request(next_link=None): if not next_link: - + request = build_deployment_operations_list_at_subscription_scope_request( deployment_name=deployment_name, subscription_id=self._config.subscription_id, - api_version=api_version, top=top, - template_url=self.list_at_subscription_scope.metadata['url'], + api_version=api_version, + template_url=self.list_at_subscription_scope.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore else: - - request = build_deployment_operations_list_at_subscription_scope_request( - deployment_name=deployment_name, - subscription_id=self._config.subscription_id, - template_url=next_link, - ) + # make call to next link with the client's api-version + _parsed_next_link = urlparse(next_link) + _next_request_params = case_insensitive_dict(parse_qs(_parsed_next_link.query)) + _next_request_params["api-version"] = self._config.api_version + request = HttpRequest("GET", urljoin(next_link, _parsed_next_link.path), params=_next_request_params) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore request.method = "GET" return request @@ -11081,10 +12728,8 @@ def extract_data(pipeline_response): def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) response = pipeline_response.http_response @@ -11094,128 +12739,131 @@ def get_next(next_link=None): return pipeline_response + return ItemPaged(get_next, extract_data) - return ItemPaged( - get_next, extract_data - ) - list_at_subscription_scope.metadata = {'url': "/subscriptions/{subscriptionId}/providers/Microsoft.Resources/deployments/{deploymentName}/operations"} # type: ignore + list_at_subscription_scope.metadata = {"url": "/subscriptions/{subscriptionId}/providers/Microsoft.Resources/deployments/{deploymentName}/operations"} # type: ignore @distributed_trace def get( - self, - resource_group_name: str, - deployment_name: str, - operation_id: str, - **kwargs: Any - ) -> "_models.DeploymentOperation": + self, resource_group_name: str, deployment_name: str, operation_id: str, **kwargs: Any + ) -> _models.DeploymentOperation: """Gets a deployments operation. :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. :type resource_group_name: str - :param deployment_name: The name of the deployment. + :param deployment_name: The name of the deployment. Required. :type deployment_name: str - :param operation_id: The ID of the operation to get. + :param operation_id: The ID of the operation to get. Required. :type operation_id: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: DeploymentOperation, or the result of cls(response) + :return: DeploymentOperation or the result of cls(response) :rtype: ~azure.mgmt.resource.resources.v2019_10_01.models.DeploymentOperation - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.DeploymentOperation"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + 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', "2019-10-01") # type: str + api_version = kwargs.pop("api_version", _params.pop("api-version", "2019-10-01")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[_models.DeploymentOperation] - request = build_deployment_operations_get_request( resource_group_name=resource_group_name, deployment_name=deployment_name, operation_id=operation_id, subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.get.metadata['url'], + template_url=self.get.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) - deserialized = self._deserialize('DeploymentOperation', pipeline_response) + deserialized = self._deserialize("DeploymentOperation", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - get.metadata = {'url': "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/deployments/{deploymentName}/operations/{operationId}"} # type: ignore - + get.metadata = {"url": "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/deployments/{deploymentName}/operations/{operationId}"} # type: ignore @distributed_trace def list( - self, - resource_group_name: str, - deployment_name: str, - top: Optional[int] = None, - **kwargs: Any - ) -> Iterable["_models.DeploymentOperationsListResult"]: + self, resource_group_name: str, deployment_name: str, top: Optional[int] = None, **kwargs: Any + ) -> Iterable["_models.DeploymentOperation"]: """Gets all deployments operations for a deployment. :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. :type resource_group_name: str - :param deployment_name: The name of the deployment. + :param deployment_name: The name of the deployment. Required. :type deployment_name: str :param top: The number of results to return. Default value is None. :type top: int :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either DeploymentOperationsListResult or the result of - cls(response) + :return: An iterator like instance of either DeploymentOperation or the result of cls(response) :rtype: - ~azure.core.paging.ItemPaged[~azure.mgmt.resource.resources.v2019_10_01.models.DeploymentOperationsListResult] - :raises: ~azure.core.exceptions.HttpResponseError + ~azure.core.paging.ItemPaged[~azure.mgmt.resource.resources.v2019_10_01.models.DeploymentOperation] + :raises ~azure.core.exceptions.HttpResponseError: """ - api_version = kwargs.pop('api_version', "2019-10-01") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2019-10-01")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[_models.DeploymentOperationsListResult] - cls = kwargs.pop('cls', None) # type: ClsType["_models.DeploymentOperationsListResult"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) + def prepare_request(next_link=None): if not next_link: - + request = build_deployment_operations_list_request( resource_group_name=resource_group_name, deployment_name=deployment_name, subscription_id=self._config.subscription_id, - api_version=api_version, top=top, - template_url=self.list.metadata['url'], + 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.url = self._client.format_url(request.url) # type: ignore else: - - request = build_deployment_operations_list_request( - resource_group_name=resource_group_name, - deployment_name=deployment_name, - subscription_id=self._config.subscription_id, - template_url=next_link, - ) + # make call to next link with the client's api-version + _parsed_next_link = urlparse(next_link) + _next_request_params = case_insensitive_dict(parse_qs(_parsed_next_link.query)) + _next_request_params["api-version"] = self._config.api_version + request = HttpRequest("GET", urljoin(next_link, _parsed_next_link.path), params=_next_request_params) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore request.method = "GET" return request @@ -11229,10 +12877,8 @@ def extract_data(pipeline_response): def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) response = pipeline_response.http_response @@ -11242,8 +12888,6 @@ def get_next(next_link=None): return pipeline_response + return ItemPaged(get_next, extract_data) - return ItemPaged( - get_next, extract_data - ) - list.metadata = {'url': "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/deployments/{deploymentName}/operations"} # type: ignore + list.metadata = {"url": "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/deployments/{deploymentName}/operations"} # type: ignore diff --git a/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/resources/v2019_10_01/operations/_patch.py b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/resources/v2019_10_01/operations/_patch.py new file mode 100644 index 0000000000000..f7dd32510333d --- /dev/null +++ b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/resources/v2019_10_01/operations/_patch.py @@ -0,0 +1,20 @@ +# ------------------------------------ +# Copyright (c) Microsoft Corporation. +# Licensed under the MIT License. +# ------------------------------------ +"""Customize generated code here. + +Follow our quickstart for examples: https://aka.ms/azsdk/python/dpcodegen/python/customize +""" +from typing import List + +__all__: List[str] = [] # Add all objects you want publicly available to users at this package level + + +def patch_sdk(): + """Do not remove from this file. + + `patch_sdk` is a last resort escape hatch that allows you to do customizations + you can't accomplish using the techniques described in + https://aka.ms/azsdk/python/dpcodegen/python/customize + """ diff --git a/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/resources/v2020_06_01/__init__.py b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/resources/v2020_06_01/__init__.py index 449220069f2f2..2b201470d075e 100644 --- a/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/resources/v2020_06_01/__init__.py +++ b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/resources/v2020_06_01/__init__.py @@ -10,9 +10,15 @@ from ._version import VERSION __version__ = VERSION -__all__ = ['ResourceManagementClient'] -# `._patch.py` is used for handwritten extensions to the generated code -# Example: https://github.com/Azure/azure-sdk-for-python/blob/main/doc/dev/customize_code/how-to-patch-sdk-code.md -from ._patch import patch_sdk -patch_sdk() +try: + from ._patch import __all__ as _patch_all + from ._patch import * # type: ignore # pylint: disable=unused-wildcard-import +except ImportError: + _patch_all = [] +from ._patch import patch_sdk as _patch_sdk + +__all__ = ["ResourceManagementClient"] +__all__.extend([p for p in _patch_all if p not in __all__]) + +_patch_sdk() diff --git a/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/resources/v2020_06_01/_configuration.py b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/resources/v2020_06_01/_configuration.py index 0a694252ee00c..0023d1528afac 100644 --- a/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/resources/v2020_06_01/_configuration.py +++ b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/resources/v2020_06_01/_configuration.py @@ -25,23 +25,18 @@ class ResourceManagementClientConfiguration(Configuration): # pylint: disable=t Note that all parameters used to create this instance are saved as instance attributes. - :param credential: Credential needed for the client to connect to Azure. + :param credential: Credential needed for the client to connect to Azure. Required. :type credential: ~azure.core.credentials.TokenCredential - :param subscription_id: The ID of the target subscription. + :param subscription_id: The ID of the target subscription. Required. :type subscription_id: str :keyword api_version: Api Version. Default value is "2020-06-01". Note that overriding this default value may result in unsupported behavior. :paramtype api_version: str """ - def __init__( - self, - credential: "TokenCredential", - subscription_id: str, - **kwargs: Any - ) -> None: + def __init__(self, credential: "TokenCredential", subscription_id: str, **kwargs: Any) -> None: super(ResourceManagementClientConfiguration, self).__init__(**kwargs) - api_version = kwargs.pop('api_version', "2020-06-01") # type: str + api_version = kwargs.pop("api_version", "2020-06-01") # type: str if credential is None: raise ValueError("Parameter 'credential' must not be None.") @@ -51,23 +46,24 @@ def __init__( self.credential = credential self.subscription_id = subscription_id self.api_version = api_version - self.credential_scopes = kwargs.pop('credential_scopes', ['https://management.azure.com/.default']) - kwargs.setdefault('sdk_moniker', 'mgmt-resource/{}'.format(VERSION)) + self.credential_scopes = kwargs.pop("credential_scopes", ["https://management.azure.com/.default"]) + kwargs.setdefault("sdk_moniker", "mgmt-resource/{}".format(VERSION)) self._configure(**kwargs) def _configure( - self, - **kwargs # type: Any + self, **kwargs # type: Any ): # type: (...) -> 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) - self.logging_policy = kwargs.get('logging_policy') or policies.NetworkTraceLoggingPolicy(**kwargs) - self.http_logging_policy = kwargs.get('http_logging_policy') or ARMHttpLoggingPolicy(**kwargs) - self.retry_policy = kwargs.get('retry_policy') or policies.RetryPolicy(**kwargs) - self.custom_hook_policy = kwargs.get('custom_hook_policy') or policies.CustomHookPolicy(**kwargs) - self.redirect_policy = kwargs.get('redirect_policy') or policies.RedirectPolicy(**kwargs) - self.authentication_policy = kwargs.get('authentication_policy') + 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) + self.logging_policy = kwargs.get("logging_policy") or policies.NetworkTraceLoggingPolicy(**kwargs) + self.http_logging_policy = kwargs.get("http_logging_policy") or ARMHttpLoggingPolicy(**kwargs) + self.retry_policy = kwargs.get("retry_policy") or policies.RetryPolicy(**kwargs) + self.custom_hook_policy = kwargs.get("custom_hook_policy") or policies.CustomHookPolicy(**kwargs) + self.redirect_policy = kwargs.get("redirect_policy") or policies.RedirectPolicy(**kwargs) + self.authentication_policy = kwargs.get("authentication_policy") if self.credential and not self.authentication_policy: - self.authentication_policy = ARMChallengeAuthenticationPolicy(self.credential, *self.credential_scopes, **kwargs) + self.authentication_policy = ARMChallengeAuthenticationPolicy( + self.credential, *self.credential_scopes, **kwargs + ) diff --git a/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/resources/v2020_06_01/_metadata.json b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/resources/v2020_06_01/_metadata.json index 7d0fe62707591..4cfdde13d7d74 100644 --- a/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/resources/v2020_06_01/_metadata.json +++ b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/resources/v2020_06_01/_metadata.json @@ -10,20 +10,20 @@ "azure_arm": true, "has_lro_operations": true, "client_side_validation": false, - "sync_imports": "{\"typing\": {\"azurecore\": {\"azure.core.credentials\": [\"TokenCredential\"]}}, \"regular\": {\"azurecore\": {\"azure.profiles\": [\"KnownProfiles\", \"ProfileDefinition\"], \"azure.profiles.multiapiclient\": [\"MultiApiClientMixin\"], \"azure.mgmt.core\": [\"ARMPipelineClient\"]}, \"local\": {\"._configuration\": [\"ResourceManagementClientConfiguration\"]}, \"thirdparty\": {\"msrest\": [\"Deserializer\", \"Serializer\"]}}, \"conditional\": {\"stdlib\": {\"typing\": [\"Any\", \"Optional\"]}}}", - "async_imports": "{\"typing\": {\"azurecore\": {\"azure.core.credentials_async\": [\"AsyncTokenCredential\"], \"azure.core.credentials\": [\"TokenCredential\"]}}, \"regular\": {\"azurecore\": {\"azure.profiles\": [\"KnownProfiles\", \"ProfileDefinition\"], \"azure.profiles.multiapiclient\": [\"MultiApiClientMixin\"], \"azure.mgmt.core\": [\"AsyncARMPipelineClient\"]}, \"local\": {\"._configuration\": [\"ResourceManagementClientConfiguration\"]}, \"thirdparty\": {\"msrest\": [\"Deserializer\", \"Serializer\"]}}, \"conditional\": {\"stdlib\": {\"typing\": [\"Any\", \"Optional\"]}}}" + "sync_imports": "{\"conditional\": {\"stdlib\": {\"typing\": [\"Any\", \"Optional\"]}}, \"regular\": {\"azurecore\": {\"azure.mgmt.core\": [\"ARMPipelineClient\"], \"azure.profiles\": [\"KnownProfiles\", \"ProfileDefinition\"], \"azure.profiles.multiapiclient\": [\"MultiApiClientMixin\"]}, \"local\": {\"._configuration\": [\"ResourceManagementClientConfiguration\"], \".._serialization\": [\"Deserializer\", \"Serializer\"]}}, \"typing\": {\"azurecore\": {\"azure.core.credentials\": [\"TokenCredential\"]}}}", + "async_imports": "{\"conditional\": {\"stdlib\": {\"typing\": [\"Any\", \"Optional\"]}}, \"regular\": {\"azurecore\": {\"azure.mgmt.core\": [\"AsyncARMPipelineClient\"], \"azure.profiles\": [\"KnownProfiles\", \"ProfileDefinition\"], \"azure.profiles.multiapiclient\": [\"MultiApiClientMixin\"]}, \"local\": {\"._configuration\": [\"ResourceManagementClientConfiguration\"], \"..._serialization\": [\"Deserializer\", \"Serializer\"]}}, \"typing\": {\"azurecore\": {\"azure.core.credentials_async\": [\"AsyncTokenCredential\"]}}}" }, "global_parameters": { "sync": { "credential": { - "signature": "credential, # type: \"TokenCredential\"", - "description": "Credential needed for the client to connect to Azure.", + "signature": "credential: \"TokenCredential\",", + "description": "Credential needed for the client to connect to Azure. Required.", "docstring_type": "~azure.core.credentials.TokenCredential", "required": true }, "subscription_id": { - "signature": "subscription_id, # type: str", - "description": "The ID of the target subscription.", + "signature": "subscription_id: str,", + "description": "The ID of the target subscription. Required.", "docstring_type": "str", "required": true } @@ -31,13 +31,13 @@ "async": { "credential": { "signature": "credential: \"AsyncTokenCredential\",", - "description": "Credential needed for the client to connect to Azure.", + "description": "Credential needed for the client to connect to Azure. Required.", "docstring_type": "~azure.core.credentials_async.AsyncTokenCredential", "required": true }, "subscription_id": { "signature": "subscription_id: str,", - "description": "The ID of the target subscription.", + "description": "The ID of the target subscription. Required.", "docstring_type": "str", "required": true } @@ -54,7 +54,7 @@ "required": false }, "base_url": { - "signature": "base_url=\"https://management.azure.com\", # type: str", + "signature": "base_url: str = \"https://management.azure.com\",", "description": "Service URL", "docstring_type": "str", "required": false diff --git a/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/resources/v2020_06_01/_patch.py b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/resources/v2020_06_01/_patch.py index 74e48ecd07cf3..f99e77fef9861 100644 --- a/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/resources/v2020_06_01/_patch.py +++ b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/resources/v2020_06_01/_patch.py @@ -28,4 +28,4 @@ # This file is used for handwritten extensions to the generated code. Example: # https://github.com/Azure/azure-sdk-for-python/blob/main/doc/dev/customize_code/how-to-patch-sdk-code.md def patch_sdk(): - pass \ No newline at end of file + pass diff --git a/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/resources/v2020_06_01/_resource_management_client.py b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/resources/v2020_06_01/_resource_management_client.py index 008fb3c8147f7..05bf72dc22512 100644 --- a/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/resources/v2020_06_01/_resource_management_client.py +++ b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/resources/v2020_06_01/_resource_management_client.py @@ -9,20 +9,28 @@ from copy import deepcopy from typing import Any, TYPE_CHECKING -from msrest import Deserializer, Serializer - from azure.core.rest import HttpRequest, HttpResponse from azure.mgmt.core import ARMPipelineClient from . import models +from .._serialization import Deserializer, Serializer from ._configuration import ResourceManagementClientConfiguration -from .operations import DeploymentOperationsOperations, DeploymentsOperations, Operations, ProvidersOperations, ResourceGroupsOperations, ResourcesOperations, TagsOperations +from .operations import ( + DeploymentOperationsOperations, + DeploymentsOperations, + Operations, + ProvidersOperations, + ResourceGroupsOperations, + ResourcesOperations, + TagsOperations, +) if TYPE_CHECKING: # pylint: disable=unused-import,ungrouped-imports from azure.core.credentials import TokenCredential -class ResourceManagementClient: # pylint: disable=too-many-instance-attributes + +class ResourceManagementClient: # pylint: disable=client-accepts-api-version-keyword,too-many-instance-attributes """Provides operations for working with resources and resource groups. :ivar operations: Operations operations @@ -42,9 +50,9 @@ class ResourceManagementClient: # pylint: disable=too-many-instance-attribute :ivar deployment_operations: DeploymentOperationsOperations operations :vartype deployment_operations: azure.mgmt.resource.resources.v2020_06_01.operations.DeploymentOperationsOperations - :param credential: Credential needed for the client to connect to Azure. + :param credential: Credential needed for the client to connect to Azure. Required. :type credential: ~azure.core.credentials.TokenCredential - :param subscription_id: The ID of the target subscription. + :param subscription_id: The ID of the target subscription. Required. :type subscription_id: str :param base_url: Service URL. Default value is "https://management.azure.com". :type base_url: str @@ -62,7 +70,9 @@ def __init__( base_url: str = "https://management.azure.com", **kwargs: Any ) -> None: - self._config = ResourceManagementClientConfiguration(credential=credential, subscription_id=subscription_id, **kwargs) + self._config = ResourceManagementClientConfiguration( + credential=credential, subscription_id=subscription_id, **kwargs + ) self._client = ARMPipelineClient(base_url=base_url, config=self._config, **kwargs) client_models = {k: v for k, v in models.__dict__.items() if isinstance(v, type)} @@ -75,14 +85,11 @@ def __init__( self.resources = ResourcesOperations(self._client, self._config, self._serialize, self._deserialize) self.resource_groups = ResourceGroupsOperations(self._client, self._config, self._serialize, self._deserialize) self.tags = TagsOperations(self._client, self._config, self._serialize, self._deserialize) - self.deployment_operations = DeploymentOperationsOperations(self._client, self._config, self._serialize, self._deserialize) - + self.deployment_operations = DeploymentOperationsOperations( + self._client, self._config, self._serialize, self._deserialize + ) - def _send_request( - self, - request: HttpRequest, - **kwargs: Any - ) -> HttpResponse: + def _send_request(self, request: HttpRequest, **kwargs: Any) -> HttpResponse: """Runs the network request through the client's chained policies. >>> from azure.core.rest import HttpRequest @@ -91,7 +98,7 @@ def _send_request( >>> response = client._send_request(request) - For more information on this code flow, see https://aka.ms/azsdk/python/protocol/quickstart + For more information on this code flow, see https://aka.ms/azsdk/dpcodegen/python/send_request :param request: The network request you want to make. Required. :type request: ~azure.core.rest.HttpRequest diff --git a/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/resources/v2020_06_01/_vendor.py b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/resources/v2020_06_01/_vendor.py index 138f663c53a4e..9aad73fc743e7 100644 --- a/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/resources/v2020_06_01/_vendor.py +++ b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/resources/v2020_06_01/_vendor.py @@ -7,6 +7,7 @@ from azure.core.pipeline.transport import HttpRequest + def _convert_request(request, files=None): data = request.content if not files else None request = HttpRequest(method=request.method, url=request.url, headers=request.headers, data=data) @@ -14,6 +15,7 @@ def _convert_request(request, files=None): request.set_formdata_body(files) return request + def _format_url_section(template, **kwargs): components = template.split("/") while components: @@ -21,7 +23,5 @@ def _format_url_section(template, **kwargs): 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 - ] + components = [c for c in formatted_components if "{}".format(key.args[0]) not in c] template = "/".join(components) diff --git a/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/resources/v2020_06_01/_version.py b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/resources/v2020_06_01/_version.py index a012ac01c480c..e5754a47ce68f 100644 --- a/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/resources/v2020_06_01/_version.py +++ b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/resources/v2020_06_01/_version.py @@ -6,4 +6,4 @@ # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -VERSION = "21.1.0" +VERSION = "1.0.0b1" diff --git a/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/resources/v2020_06_01/aio/__init__.py b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/resources/v2020_06_01/aio/__init__.py index c6c3cf64a37a6..98d6782c2530c 100644 --- a/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/resources/v2020_06_01/aio/__init__.py +++ b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/resources/v2020_06_01/aio/__init__.py @@ -7,9 +7,15 @@ # -------------------------------------------------------------------------- from ._resource_management_client import ResourceManagementClient -__all__ = ['ResourceManagementClient'] -# `._patch.py` is used for handwritten extensions to the generated code -# Example: https://github.com/Azure/azure-sdk-for-python/blob/main/doc/dev/customize_code/how-to-patch-sdk-code.md -from ._patch import patch_sdk -patch_sdk() +try: + from ._patch import __all__ as _patch_all + from ._patch import * # type: ignore # pylint: disable=unused-wildcard-import +except ImportError: + _patch_all = [] +from ._patch import patch_sdk as _patch_sdk + +__all__ = ["ResourceManagementClient"] +__all__.extend([p for p in _patch_all if p not in __all__]) + +_patch_sdk() diff --git a/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/resources/v2020_06_01/aio/_configuration.py b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/resources/v2020_06_01/aio/_configuration.py index 66ebaf9738c7c..bd36012142e8c 100644 --- a/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/resources/v2020_06_01/aio/_configuration.py +++ b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/resources/v2020_06_01/aio/_configuration.py @@ -25,23 +25,18 @@ class ResourceManagementClientConfiguration(Configuration): # pylint: disable=t Note that all parameters used to create this instance are saved as instance attributes. - :param credential: Credential needed for the client to connect to Azure. + :param credential: Credential needed for the client to connect to Azure. Required. :type credential: ~azure.core.credentials_async.AsyncTokenCredential - :param subscription_id: The ID of the target subscription. + :param subscription_id: The ID of the target subscription. Required. :type subscription_id: str :keyword api_version: Api Version. Default value is "2020-06-01". Note that overriding this default value may result in unsupported behavior. :paramtype api_version: str """ - def __init__( - self, - credential: "AsyncTokenCredential", - subscription_id: str, - **kwargs: Any - ) -> None: + def __init__(self, credential: "AsyncTokenCredential", subscription_id: str, **kwargs: Any) -> None: super(ResourceManagementClientConfiguration, self).__init__(**kwargs) - api_version = kwargs.pop('api_version', "2020-06-01") # type: str + api_version = kwargs.pop("api_version", "2020-06-01") # type: str if credential is None: raise ValueError("Parameter 'credential' must not be None.") @@ -51,22 +46,21 @@ def __init__( self.credential = credential self.subscription_id = subscription_id self.api_version = api_version - self.credential_scopes = kwargs.pop('credential_scopes', ['https://management.azure.com/.default']) - kwargs.setdefault('sdk_moniker', 'mgmt-resource/{}'.format(VERSION)) + self.credential_scopes = kwargs.pop("credential_scopes", ["https://management.azure.com/.default"]) + kwargs.setdefault("sdk_moniker", "mgmt-resource/{}".format(VERSION)) self._configure(**kwargs) - 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) - self.logging_policy = kwargs.get('logging_policy') or policies.NetworkTraceLoggingPolicy(**kwargs) - self.http_logging_policy = kwargs.get('http_logging_policy') or ARMHttpLoggingPolicy(**kwargs) - self.retry_policy = kwargs.get('retry_policy') or policies.AsyncRetryPolicy(**kwargs) - self.custom_hook_policy = kwargs.get('custom_hook_policy') or policies.CustomHookPolicy(**kwargs) - self.redirect_policy = kwargs.get('redirect_policy') or policies.AsyncRedirectPolicy(**kwargs) - self.authentication_policy = kwargs.get('authentication_policy') + 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) + self.logging_policy = kwargs.get("logging_policy") or policies.NetworkTraceLoggingPolicy(**kwargs) + self.http_logging_policy = kwargs.get("http_logging_policy") or ARMHttpLoggingPolicy(**kwargs) + self.retry_policy = kwargs.get("retry_policy") or policies.AsyncRetryPolicy(**kwargs) + self.custom_hook_policy = kwargs.get("custom_hook_policy") or policies.CustomHookPolicy(**kwargs) + self.redirect_policy = kwargs.get("redirect_policy") or policies.AsyncRedirectPolicy(**kwargs) + self.authentication_policy = kwargs.get("authentication_policy") if self.credential and not self.authentication_policy: - self.authentication_policy = AsyncARMChallengeAuthenticationPolicy(self.credential, *self.credential_scopes, **kwargs) + self.authentication_policy = AsyncARMChallengeAuthenticationPolicy( + self.credential, *self.credential_scopes, **kwargs + ) diff --git a/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/resources/v2020_06_01/aio/_patch.py b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/resources/v2020_06_01/aio/_patch.py index 74e48ecd07cf3..f99e77fef9861 100644 --- a/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/resources/v2020_06_01/aio/_patch.py +++ b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/resources/v2020_06_01/aio/_patch.py @@ -28,4 +28,4 @@ # This file is used for handwritten extensions to the generated code. Example: # https://github.com/Azure/azure-sdk-for-python/blob/main/doc/dev/customize_code/how-to-patch-sdk-code.md def patch_sdk(): - pass \ No newline at end of file + pass diff --git a/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/resources/v2020_06_01/aio/_resource_management_client.py b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/resources/v2020_06_01/aio/_resource_management_client.py index 0612bc0c984f4..daada416f2b01 100644 --- a/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/resources/v2020_06_01/aio/_resource_management_client.py +++ b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/resources/v2020_06_01/aio/_resource_management_client.py @@ -9,20 +9,28 @@ from copy import deepcopy from typing import Any, Awaitable, TYPE_CHECKING -from msrest import Deserializer, Serializer - from azure.core.rest import AsyncHttpResponse, HttpRequest from azure.mgmt.core import AsyncARMPipelineClient from .. import models +from ..._serialization import Deserializer, Serializer from ._configuration import ResourceManagementClientConfiguration -from .operations import DeploymentOperationsOperations, DeploymentsOperations, Operations, ProvidersOperations, ResourceGroupsOperations, ResourcesOperations, TagsOperations +from .operations import ( + DeploymentOperationsOperations, + DeploymentsOperations, + Operations, + ProvidersOperations, + ResourceGroupsOperations, + ResourcesOperations, + TagsOperations, +) if TYPE_CHECKING: # pylint: disable=unused-import,ungrouped-imports from azure.core.credentials_async import AsyncTokenCredential -class ResourceManagementClient: # pylint: disable=too-many-instance-attributes + +class ResourceManagementClient: # pylint: disable=client-accepts-api-version-keyword,too-many-instance-attributes """Provides operations for working with resources and resource groups. :ivar operations: Operations operations @@ -44,9 +52,9 @@ class ResourceManagementClient: # pylint: disable=too-many-instance-attribute :ivar deployment_operations: DeploymentOperationsOperations operations :vartype deployment_operations: azure.mgmt.resource.resources.v2020_06_01.aio.operations.DeploymentOperationsOperations - :param credential: Credential needed for the client to connect to Azure. + :param credential: Credential needed for the client to connect to Azure. Required. :type credential: ~azure.core.credentials_async.AsyncTokenCredential - :param subscription_id: The ID of the target subscription. + :param subscription_id: The ID of the target subscription. Required. :type subscription_id: str :param base_url: Service URL. Default value is "https://management.azure.com". :type base_url: str @@ -64,7 +72,9 @@ def __init__( base_url: str = "https://management.azure.com", **kwargs: Any ) -> None: - self._config = ResourceManagementClientConfiguration(credential=credential, subscription_id=subscription_id, **kwargs) + self._config = ResourceManagementClientConfiguration( + credential=credential, subscription_id=subscription_id, **kwargs + ) self._client = AsyncARMPipelineClient(base_url=base_url, config=self._config, **kwargs) client_models = {k: v for k, v in models.__dict__.items() if isinstance(v, type)} @@ -77,14 +87,11 @@ def __init__( self.resources = ResourcesOperations(self._client, self._config, self._serialize, self._deserialize) self.resource_groups = ResourceGroupsOperations(self._client, self._config, self._serialize, self._deserialize) self.tags = TagsOperations(self._client, self._config, self._serialize, self._deserialize) - self.deployment_operations = DeploymentOperationsOperations(self._client, self._config, self._serialize, self._deserialize) - + self.deployment_operations = DeploymentOperationsOperations( + self._client, self._config, self._serialize, self._deserialize + ) - def _send_request( - self, - request: HttpRequest, - **kwargs: Any - ) -> Awaitable[AsyncHttpResponse]: + def _send_request(self, request: HttpRequest, **kwargs: Any) -> Awaitable[AsyncHttpResponse]: """Runs the network request through the client's chained policies. >>> from azure.core.rest import HttpRequest @@ -93,7 +100,7 @@ def _send_request( >>> response = await client._send_request(request) - For more information on this code flow, see https://aka.ms/azsdk/python/protocol/quickstart + For more information on this code flow, see https://aka.ms/azsdk/dpcodegen/python/send_request :param request: The network request you want to make. Required. :type request: ~azure.core.rest.HttpRequest diff --git a/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/resources/v2020_06_01/aio/operations/__init__.py b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/resources/v2020_06_01/aio/operations/__init__.py index 53876d82bf5d7..804fee65e3137 100644 --- a/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/resources/v2020_06_01/aio/operations/__init__.py +++ b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/resources/v2020_06_01/aio/operations/__init__.py @@ -14,12 +14,18 @@ from ._operations import TagsOperations from ._operations import DeploymentOperationsOperations +from ._patch import __all__ as _patch_all +from ._patch import * # type: ignore # pylint: disable=unused-wildcard-import +from ._patch import patch_sdk as _patch_sdk + __all__ = [ - 'Operations', - 'DeploymentsOperations', - 'ProvidersOperations', - 'ResourcesOperations', - 'ResourceGroupsOperations', - 'TagsOperations', - 'DeploymentOperationsOperations', + "Operations", + "DeploymentsOperations", + "ProvidersOperations", + "ResourcesOperations", + "ResourceGroupsOperations", + "TagsOperations", + "DeploymentOperationsOperations", ] +__all__.extend([p for p in _patch_all if p not in __all__]) +_patch_sdk() diff --git a/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/resources/v2020_06_01/aio/operations/_operations.py b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/resources/v2020_06_01/aio/operations/_operations.py index 4eb670d763693..b98742abafe65 100644 --- a/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/resources/v2020_06_01/aio/operations/_operations.py +++ b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/resources/v2020_06_01/aio/operations/_operations.py @@ -6,84 +6,199 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -from typing import Any, AsyncIterable, Callable, Dict, Optional, TypeVar, Union +import sys +from typing import Any, AsyncIterable, Callable, Dict, IO, Optional, TypeVar, Union, cast, overload +from urllib.parse import parse_qs, urljoin, urlparse from azure.core.async_paging import AsyncItemPaged, AsyncList -from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error +from azure.core.exceptions import ( + ClientAuthenticationError, + HttpResponseError, + ResourceExistsError, + ResourceNotFoundError, + ResourceNotModifiedError, + map_error, +) from azure.core.pipeline import PipelineResponse from azure.core.pipeline.transport import AsyncHttpResponse from azure.core.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 from azure.mgmt.core.polling.async_arm_polling import AsyncARMPolling from ... import models as _models from ..._vendor import _convert_request -from ...operations._operations import build_deployment_operations_get_at_management_group_scope_request, build_deployment_operations_get_at_scope_request, build_deployment_operations_get_at_subscription_scope_request, build_deployment_operations_get_at_tenant_scope_request, build_deployment_operations_get_request, build_deployment_operations_list_at_management_group_scope_request, build_deployment_operations_list_at_scope_request, build_deployment_operations_list_at_subscription_scope_request, build_deployment_operations_list_at_tenant_scope_request, build_deployment_operations_list_request, build_deployments_calculate_template_hash_request, build_deployments_cancel_at_management_group_scope_request, build_deployments_cancel_at_scope_request, build_deployments_cancel_at_subscription_scope_request, build_deployments_cancel_at_tenant_scope_request, build_deployments_cancel_request, build_deployments_check_existence_at_management_group_scope_request, build_deployments_check_existence_at_scope_request, build_deployments_check_existence_at_subscription_scope_request, build_deployments_check_existence_at_tenant_scope_request, build_deployments_check_existence_request, build_deployments_create_or_update_at_management_group_scope_request_initial, build_deployments_create_or_update_at_scope_request_initial, build_deployments_create_or_update_at_subscription_scope_request_initial, build_deployments_create_or_update_at_tenant_scope_request_initial, build_deployments_create_or_update_request_initial, build_deployments_delete_at_management_group_scope_request_initial, build_deployments_delete_at_scope_request_initial, build_deployments_delete_at_subscription_scope_request_initial, build_deployments_delete_at_tenant_scope_request_initial, build_deployments_delete_request_initial, build_deployments_export_template_at_management_group_scope_request, build_deployments_export_template_at_scope_request, build_deployments_export_template_at_subscription_scope_request, build_deployments_export_template_at_tenant_scope_request, build_deployments_export_template_request, build_deployments_get_at_management_group_scope_request, build_deployments_get_at_scope_request, build_deployments_get_at_subscription_scope_request, build_deployments_get_at_tenant_scope_request, build_deployments_get_request, build_deployments_list_at_management_group_scope_request, build_deployments_list_at_scope_request, build_deployments_list_at_subscription_scope_request, build_deployments_list_at_tenant_scope_request, build_deployments_list_by_resource_group_request, build_deployments_validate_at_management_group_scope_request_initial, build_deployments_validate_at_scope_request_initial, build_deployments_validate_at_subscription_scope_request_initial, build_deployments_validate_at_tenant_scope_request_initial, build_deployments_validate_request_initial, build_deployments_what_if_at_management_group_scope_request_initial, build_deployments_what_if_at_subscription_scope_request_initial, build_deployments_what_if_at_tenant_scope_request_initial, build_deployments_what_if_request_initial, build_operations_list_request, build_providers_get_at_tenant_scope_request, build_providers_get_request, build_providers_list_at_tenant_scope_request, build_providers_list_request, build_providers_register_at_management_group_scope_request, build_providers_register_request, build_providers_unregister_request, build_resource_groups_check_existence_request, build_resource_groups_create_or_update_request, build_resource_groups_delete_request_initial, build_resource_groups_export_template_request_initial, build_resource_groups_get_request, build_resource_groups_list_request, build_resource_groups_update_request, build_resources_check_existence_by_id_request, build_resources_check_existence_request, build_resources_create_or_update_by_id_request_initial, build_resources_create_or_update_request_initial, build_resources_delete_by_id_request_initial, build_resources_delete_request_initial, build_resources_get_by_id_request, build_resources_get_request, build_resources_list_by_resource_group_request, build_resources_list_request, build_resources_move_resources_request_initial, build_resources_update_by_id_request_initial, build_resources_update_request_initial, build_resources_validate_move_resources_request_initial, build_tags_create_or_update_at_scope_request, build_tags_create_or_update_request, build_tags_create_or_update_value_request, build_tags_delete_at_scope_request, build_tags_delete_request, build_tags_delete_value_request, build_tags_get_at_scope_request, build_tags_list_request, build_tags_update_at_scope_request -T = TypeVar('T') +from ...operations._operations import ( + build_deployment_operations_get_at_management_group_scope_request, + build_deployment_operations_get_at_scope_request, + build_deployment_operations_get_at_subscription_scope_request, + build_deployment_operations_get_at_tenant_scope_request, + build_deployment_operations_get_request, + build_deployment_operations_list_at_management_group_scope_request, + build_deployment_operations_list_at_scope_request, + build_deployment_operations_list_at_subscription_scope_request, + build_deployment_operations_list_at_tenant_scope_request, + build_deployment_operations_list_request, + build_deployments_calculate_template_hash_request, + build_deployments_cancel_at_management_group_scope_request, + build_deployments_cancel_at_scope_request, + build_deployments_cancel_at_subscription_scope_request, + build_deployments_cancel_at_tenant_scope_request, + build_deployments_cancel_request, + build_deployments_check_existence_at_management_group_scope_request, + build_deployments_check_existence_at_scope_request, + build_deployments_check_existence_at_subscription_scope_request, + build_deployments_check_existence_at_tenant_scope_request, + build_deployments_check_existence_request, + build_deployments_create_or_update_at_management_group_scope_request, + build_deployments_create_or_update_at_scope_request, + build_deployments_create_or_update_at_subscription_scope_request, + build_deployments_create_or_update_at_tenant_scope_request, + build_deployments_create_or_update_request, + build_deployments_delete_at_management_group_scope_request, + build_deployments_delete_at_scope_request, + build_deployments_delete_at_subscription_scope_request, + build_deployments_delete_at_tenant_scope_request, + build_deployments_delete_request, + build_deployments_export_template_at_management_group_scope_request, + build_deployments_export_template_at_scope_request, + build_deployments_export_template_at_subscription_scope_request, + build_deployments_export_template_at_tenant_scope_request, + build_deployments_export_template_request, + build_deployments_get_at_management_group_scope_request, + build_deployments_get_at_scope_request, + build_deployments_get_at_subscription_scope_request, + build_deployments_get_at_tenant_scope_request, + build_deployments_get_request, + build_deployments_list_at_management_group_scope_request, + build_deployments_list_at_scope_request, + build_deployments_list_at_subscription_scope_request, + build_deployments_list_at_tenant_scope_request, + build_deployments_list_by_resource_group_request, + build_deployments_validate_at_management_group_scope_request, + build_deployments_validate_at_scope_request, + build_deployments_validate_at_subscription_scope_request, + build_deployments_validate_at_tenant_scope_request, + build_deployments_validate_request, + build_deployments_what_if_at_management_group_scope_request, + build_deployments_what_if_at_subscription_scope_request, + build_deployments_what_if_at_tenant_scope_request, + build_deployments_what_if_request, + build_operations_list_request, + build_providers_get_at_tenant_scope_request, + build_providers_get_request, + build_providers_list_at_tenant_scope_request, + build_providers_list_request, + build_providers_register_at_management_group_scope_request, + build_providers_register_request, + build_providers_unregister_request, + build_resource_groups_check_existence_request, + build_resource_groups_create_or_update_request, + build_resource_groups_delete_request, + build_resource_groups_export_template_request, + build_resource_groups_get_request, + build_resource_groups_list_request, + build_resource_groups_update_request, + build_resources_check_existence_by_id_request, + build_resources_check_existence_request, + build_resources_create_or_update_by_id_request, + build_resources_create_or_update_request, + build_resources_delete_by_id_request, + build_resources_delete_request, + build_resources_get_by_id_request, + build_resources_get_request, + build_resources_list_by_resource_group_request, + build_resources_list_request, + build_resources_move_resources_request, + build_resources_update_by_id_request, + build_resources_update_request, + build_resources_validate_move_resources_request, + build_tags_create_or_update_at_scope_request, + build_tags_create_or_update_request, + build_tags_create_or_update_value_request, + build_tags_delete_at_scope_request, + build_tags_delete_request, + build_tags_delete_value_request, + build_tags_get_at_scope_request, + build_tags_list_request, + build_tags_update_at_scope_request, +) + +T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] +if sys.version_info >= (3, 9): + from collections.abc import MutableMapping +else: + from typing import MutableMapping # type: ignore # pylint: disable=ungrouped-imports +JSON = MutableMapping[str, Any] # pylint: disable=unsubscriptable-object -class Operations: - """Operations async operations. - You should not instantiate this class directly. Instead, you should create a Client instance that - instantiates it for you and attaches it as an attribute. +class Operations: + """ + .. warning:: + **DO NOT** instantiate this class directly. - :ivar models: Alias to model classes used in this operation group. - :type models: ~azure.mgmt.resource.resources.v2020_06_01.models - :param client: Client for service requests. - :param config: Configuration of service client. - :param serializer: An object model serializer. - :param deserializer: An object model deserializer. + Instead, you should access the following operations through + :class:`~azure.mgmt.resource.resources.v2020_06_01.aio.ResourceManagementClient`'s + :attr:`operations` attribute. """ models = _models - def __init__(self, client, config, serializer, deserializer) -> None: - self._client = client - self._serialize = serializer - self._deserialize = deserializer - self._config = config + def __init__(self, *args, **kwargs) -> None: + input_args = list(args) + self._client = input_args.pop(0) if input_args else kwargs.pop("client") + self._config = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") @distributed_trace - def list( - self, - **kwargs: Any - ) -> AsyncIterable["_models.OperationListResult"]: + def list(self, **kwargs: Any) -> AsyncIterable["_models.Operation"]: """Lists all of the available Microsoft.Resources REST API operations. :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either OperationListResult or the result of cls(response) + :return: An iterator like instance of either Operation or the result of cls(response) :rtype: - ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.resource.resources.v2020_06_01.models.OperationListResult] - :raises: ~azure.core.exceptions.HttpResponseError + ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.resource.resources.v2020_06_01.models.Operation] + :raises ~azure.core.exceptions.HttpResponseError: """ - api_version = kwargs.pop('api_version', "2020-06-01") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2020-06-01")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[_models.OperationListResult] - cls = kwargs.pop('cls', None) # type: ClsType["_models.OperationListResult"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) + def prepare_request(next_link=None): if not next_link: - + request = build_operations_list_request( api_version=api_version, - template_url=self.list.metadata['url'], + template_url=self.list.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore else: - - request = build_operations_list_request( - template_url=next_link, - ) + # make call to next link with the client's api-version + _parsed_next_link = urlparse(next_link) + _next_request_params = case_insensitive_dict(parse_qs(_parsed_next_link.query)) + _next_request_params["api-version"] = self._config.api_version + request = HttpRequest("GET", urljoin(next_link, _parsed_next_link.path), params=_next_request_params) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore request.method = "GET" return request @@ -97,10 +212,8 @@ async def extract_data(pipeline_response): async def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) response = pipeline_response.http_response @@ -110,62 +223,62 @@ async def get_next(next_link=None): return pipeline_response + return AsyncItemPaged(get_next, extract_data) - return AsyncItemPaged( - get_next, extract_data - ) - list.metadata = {'url': "/providers/Microsoft.Resources/operations"} # type: ignore -class DeploymentsOperations: # pylint: disable=too-many-public-methods - """DeploymentsOperations async operations. + list.metadata = {"url": "/providers/Microsoft.Resources/operations"} # type: ignore - You should not instantiate this class directly. Instead, you should create a Client instance that - instantiates it for you and attaches it as an attribute. - :ivar models: Alias to model classes used in this operation group. - :type models: ~azure.mgmt.resource.resources.v2020_06_01.models - :param client: Client for service requests. - :param config: Configuration of service client. - :param serializer: An object model serializer. - :param deserializer: An object model deserializer. +class DeploymentsOperations: # pylint: disable=too-many-public-methods + """ + .. warning:: + **DO NOT** instantiate this class directly. + + Instead, you should access the following operations through + :class:`~azure.mgmt.resource.resources.v2020_06_01.aio.ResourceManagementClient`'s + :attr:`deployments` attribute. """ models = _models - def __init__(self, client, config, serializer, deserializer) -> None: - self._client = client - self._serialize = serializer - self._deserialize = deserializer - self._config = config + def __init__(self, *args, **kwargs) -> None: + input_args = list(args) + self._client = input_args.pop(0) if input_args else kwargs.pop("client") + self._config = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") async def _delete_at_scope_initial( # pylint: disable=inconsistent-return-statements - self, - scope: str, - deployment_name: str, - **kwargs: Any + self, scope: str, deployment_name: str, **kwargs: Any ) -> None: - cls = kwargs.pop('cls', None) # type: ClsType[None] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + 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', "2020-06-01") # type: str + api_version = kwargs.pop("api_version", _params.pop("api-version", "2020-06-01")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[None] - - request = build_deployments_delete_at_scope_request_initial( + request = build_deployments_delete_at_scope_request( scope=scope, deployment_name=deployment_name, api_version=api_version, - template_url=self._delete_at_scope_initial.metadata['url'], + template_url=self._delete_at_scope_initial.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [202, 204]: @@ -175,16 +288,10 @@ async def _delete_at_scope_initial( # pylint: disable=inconsistent-return-state if cls: return cls(pipeline_response, None, {}) - _delete_at_scope_initial.metadata = {'url': "/{scope}/providers/Microsoft.Resources/deployments/{deploymentName}"} # type: ignore - + _delete_at_scope_initial.metadata = {"url": "/{scope}/providers/Microsoft.Resources/deployments/{deploymentName}"} # type: ignore @distributed_trace_async - async def begin_delete_at_scope( # pylint: disable=inconsistent-return-statements - self, - scope: str, - deployment_name: str, - **kwargs: Any - ) -> AsyncLROPoller[None]: + async def begin_delete_at_scope(self, scope: str, deployment_name: str, **kwargs: Any) -> AsyncLROPoller[None]: """Deletes a deployment from the deployment history. A template deployment that is currently running cannot be deleted. Deleting a template @@ -195,9 +302,9 @@ async def begin_delete_at_scope( # pylint: disable=inconsistent-return-statemen process finishes, the URI in the Location header returns a status of 204 on success. If the asynchronous request failed, the URI in the Location header returns an error-level status code. - :param scope: The resource scope. + :param scope: The resource scope. Required. :type scope: str - :param deployment_name: The name of the deployment. + :param deployment_name: The name of the deployment. Required. :type deployment_name: str :keyword callable cls: A custom type or function that will be passed the direct response :keyword str continuation_token: A continuation token to restart a poller from a saved state. @@ -209,86 +316,91 @@ async def begin_delete_at_scope( # pylint: disable=inconsistent-return-statemen Retry-After header is present. :return: An instance of AsyncLROPoller that returns either None or the result of cls(response) :rtype: ~azure.core.polling.AsyncLROPoller[None] - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - api_version = kwargs.pop('api_version', "2020-06-01") # type: str - polling = kwargs.pop('polling', True) # type: Union[bool, AsyncPollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType[None] - lro_delay = kwargs.pop( - 'polling_interval', - self._config.polling_interval - ) - cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2020-06-01")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[None] + polling = kwargs.pop("polling", True) # type: Union[bool, AsyncPollingMethod] + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token = kwargs.pop("continuation_token", None) # type: Optional[str] if cont_token is None: - raw_result = await self._delete_at_scope_initial( + raw_result = await self._delete_at_scope_initial( # type: ignore scope=scope, deployment_name=deployment_name, api_version=api_version, - cls=lambda x,y,z: x, + cls=lambda x, y, z: x, + headers=_headers, + params=_params, **kwargs ) - kwargs.pop('error_map', None) + kwargs.pop("error_map", None) - def get_long_running_output(pipeline_response): + def get_long_running_output(pipeline_response): # pylint: disable=inconsistent-return-statements if cls: return cls(pipeline_response, None, {}) - - if polling is True: polling_method = AsyncARMPolling(lro_delay, **kwargs) - elif polling is False: polling_method = AsyncNoPolling() - else: polling_method = polling + if polling is True: + polling_method = cast(AsyncPollingMethod, AsyncARMPolling(lro_delay, **kwargs)) # type: AsyncPollingMethod + elif polling is False: + polling_method = cast(AsyncPollingMethod, AsyncNoPolling()) + else: + polling_method = polling if cont_token: return AsyncLROPoller.from_continuation_token( polling_method=polling_method, continuation_token=cont_token, client=self._client, - deserialization_callback=get_long_running_output + deserialization_callback=get_long_running_output, ) return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) - begin_delete_at_scope.metadata = {'url': "/{scope}/providers/Microsoft.Resources/deployments/{deploymentName}"} # type: ignore + begin_delete_at_scope.metadata = {"url": "/{scope}/providers/Microsoft.Resources/deployments/{deploymentName}"} # type: ignore @distributed_trace_async - async def check_existence_at_scope( - self, - scope: str, - deployment_name: str, - **kwargs: Any - ) -> bool: + async def check_existence_at_scope(self, scope: str, deployment_name: str, **kwargs: Any) -> bool: """Checks whether the deployment exists. - :param scope: The resource scope. + :param scope: The resource scope. Required. :type scope: str - :param deployment_name: The name of the deployment. + :param deployment_name: The name of the deployment. Required. :type deployment_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: bool, or the result of cls(response) + :return: bool or the result of cls(response) :rtype: bool - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType[None] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + 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', "2020-06-01") # type: str + api_version = kwargs.pop("api_version", _params.pop("api-version", "2020-06-01")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[None] - request = build_deployments_check_existence_at_scope_request( scope=scope, deployment_name=deployment_name, api_version=api_version, - template_url=self.check_existence_at_scope.metadata['url'], + template_url=self.check_existence_at_scope.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [204, 404]: @@ -299,43 +411,52 @@ async def check_existence_at_scope( return cls(pipeline_response, None, {}) return 200 <= response.status_code <= 299 - check_existence_at_scope.metadata = {'url': "/{scope}/providers/Microsoft.Resources/deployments/{deploymentName}"} # type: ignore - + check_existence_at_scope.metadata = {"url": "/{scope}/providers/Microsoft.Resources/deployments/{deploymentName}"} # type: ignore async def _create_or_update_at_scope_initial( - self, - scope: str, - deployment_name: str, - parameters: "_models.Deployment", - **kwargs: Any - ) -> "_models.DeploymentExtended": - cls = kwargs.pop('cls', None) # type: ClsType["_models.DeploymentExtended"] + self, scope: str, deployment_name: str, parameters: Union[_models.Deployment, IO], **kwargs: Any + ) -> _models.DeploymentExtended: error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) - api_version = kwargs.pop('api_version', "2020-06-01") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - _json = self._serialize.body(parameters, 'Deployment') + api_version = kwargs.pop("api_version", _params.pop("api-version", "2020-06-01")) # type: str + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.DeploymentExtended] - request = build_deployments_create_or_update_at_scope_request_initial( + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(parameters, (IO, bytes)): + _content = parameters + else: + _json = self._serialize.body(parameters, "Deployment") + + request = build_deployments_create_or_update_at_scope_request( scope=scope, deployment_name=deployment_name, api_version=api_version, content_type=content_type, json=_json, - template_url=self._create_or_update_at_scope_initial.metadata['url'], + content=_content, + template_url=self._create_or_update_at_scope_initial.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200, 201]: @@ -343,37 +464,41 @@ async def _create_or_update_at_scope_initial( raise HttpResponseError(response=response, error_format=ARMErrorFormat) if response.status_code == 200: - deserialized = self._deserialize('DeploymentExtended', pipeline_response) + deserialized = self._deserialize("DeploymentExtended", pipeline_response) if response.status_code == 201: - deserialized = self._deserialize('DeploymentExtended', pipeline_response) + deserialized = self._deserialize("DeploymentExtended", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - _create_or_update_at_scope_initial.metadata = {'url': "/{scope}/providers/Microsoft.Resources/deployments/{deploymentName}"} # type: ignore + _create_or_update_at_scope_initial.metadata = {"url": "/{scope}/providers/Microsoft.Resources/deployments/{deploymentName}"} # type: ignore - - @distributed_trace_async + @overload async def begin_create_or_update_at_scope( self, scope: str, deployment_name: str, - parameters: "_models.Deployment", + parameters: _models.Deployment, + *, + content_type: str = "application/json", **kwargs: Any - ) -> AsyncLROPoller["_models.DeploymentExtended"]: + ) -> AsyncLROPoller[_models.DeploymentExtended]: """Deploys resources at a given scope. You can provide the template and parameters directly in the request or link to JSON files. - :param scope: The resource scope. + :param scope: The resource scope. Required. :type scope: str - :param deployment_name: The name of the deployment. + :param deployment_name: The name of the deployment. Required. :type deployment_name: str - :param parameters: Additional parameters supplied to the operation. + :param parameters: Additional parameters supplied to the operation. Required. :type parameters: ~azure.mgmt.resource.resources.v2020_06_01.models.Deployment + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str :keyword callable cls: A custom type or function that will be passed the direct response :keyword str continuation_token: A continuation token to restart a poller from a saved state. :keyword polling: By default, your polling method will be AsyncARMPolling. Pass in False for @@ -386,114 +511,179 @@ async def begin_create_or_update_at_scope( cls(response) :rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.resource.resources.v2020_06_01.models.DeploymentExtended] - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - api_version = kwargs.pop('api_version', "2020-06-01") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] - polling = kwargs.pop('polling', True) # type: Union[bool, AsyncPollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType["_models.DeploymentExtended"] - lro_delay = kwargs.pop( - 'polling_interval', - self._config.polling_interval - ) - cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] + + @overload + async def begin_create_or_update_at_scope( + self, scope: str, deployment_name: str, parameters: IO, *, content_type: str = "application/json", **kwargs: Any + ) -> AsyncLROPoller[_models.DeploymentExtended]: + """Deploys resources at a given scope. + + You can provide the template and parameters directly in the request or link to JSON files. + + :param scope: The resource scope. Required. + :type scope: str + :param deployment_name: The name of the deployment. Required. + :type deployment_name: str + :param parameters: Additional parameters supplied to the operation. Required. + :type parameters: IO + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be AsyncARMPolling. Pass in False for + this operation to not poll, or pass in your own initialized polling object for a personal + polling strategy. + :paramtype polling: bool or ~azure.core.polling.AsyncPollingMethod + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of AsyncLROPoller that returns either DeploymentExtended or the result of + cls(response) + :rtype: + ~azure.core.polling.AsyncLROPoller[~azure.mgmt.resource.resources.v2020_06_01.models.DeploymentExtended] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace_async + async def begin_create_or_update_at_scope( + self, scope: str, deployment_name: str, parameters: Union[_models.Deployment, IO], **kwargs: Any + ) -> AsyncLROPoller[_models.DeploymentExtended]: + """Deploys resources at a given scope. + + You can provide the template and parameters directly in the request or link to JSON files. + + :param scope: The resource scope. Required. + :type scope: str + :param deployment_name: The name of the deployment. Required. + :type deployment_name: str + :param parameters: Additional parameters supplied to the operation. Is either a model type or a + IO type. Required. + :type parameters: ~azure.mgmt.resource.resources.v2020_06_01.models.Deployment or IO + :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. + Default value is None. + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be AsyncARMPolling. Pass in False for + this operation to not poll, or pass in your own initialized polling object for a personal + polling strategy. + :paramtype polling: bool or ~azure.core.polling.AsyncPollingMethod + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of AsyncLROPoller that returns either DeploymentExtended or the result of + cls(response) + :rtype: + ~azure.core.polling.AsyncLROPoller[~azure.mgmt.resource.resources.v2020_06_01.models.DeploymentExtended] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _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", "2020-06-01")) # type: str + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.DeploymentExtended] + polling = kwargs.pop("polling", True) # type: Union[bool, AsyncPollingMethod] + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token = kwargs.pop("continuation_token", None) # type: Optional[str] if cont_token is None: - raw_result = await self._create_or_update_at_scope_initial( + raw_result = await self._create_or_update_at_scope_initial( # type: ignore scope=scope, deployment_name=deployment_name, parameters=parameters, api_version=api_version, content_type=content_type, - cls=lambda x,y,z: x, + cls=lambda x, y, z: x, + headers=_headers, + params=_params, **kwargs ) - kwargs.pop('error_map', None) + kwargs.pop("error_map", None) def get_long_running_output(pipeline_response): - response = pipeline_response.http_response - deserialized = self._deserialize('DeploymentExtended', pipeline_response) + deserialized = self._deserialize("DeploymentExtended", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - - if polling is True: polling_method = AsyncARMPolling(lro_delay, **kwargs) - elif polling is False: polling_method = AsyncNoPolling() - else: polling_method = polling + if polling is True: + polling_method = cast(AsyncPollingMethod, AsyncARMPolling(lro_delay, **kwargs)) # type: AsyncPollingMethod + elif polling is False: + polling_method = cast(AsyncPollingMethod, AsyncNoPolling()) + else: + polling_method = polling if cont_token: return AsyncLROPoller.from_continuation_token( polling_method=polling_method, continuation_token=cont_token, client=self._client, - deserialization_callback=get_long_running_output + deserialization_callback=get_long_running_output, ) return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) - begin_create_or_update_at_scope.metadata = {'url': "/{scope}/providers/Microsoft.Resources/deployments/{deploymentName}"} # type: ignore + begin_create_or_update_at_scope.metadata = {"url": "/{scope}/providers/Microsoft.Resources/deployments/{deploymentName}"} # type: ignore @distributed_trace_async - async def get_at_scope( - self, - scope: str, - deployment_name: str, - **kwargs: Any - ) -> "_models.DeploymentExtended": + async def get_at_scope(self, scope: str, deployment_name: str, **kwargs: Any) -> _models.DeploymentExtended: """Gets a deployment. - :param scope: The resource scope. + :param scope: The resource scope. Required. :type scope: str - :param deployment_name: The name of the deployment. + :param deployment_name: The name of the deployment. Required. :type deployment_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: DeploymentExtended, or the result of cls(response) + :return: DeploymentExtended or the result of cls(response) :rtype: ~azure.mgmt.resource.resources.v2020_06_01.models.DeploymentExtended - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.DeploymentExtended"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) - api_version = kwargs.pop('api_version', "2020-06-01") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2020-06-01")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[_models.DeploymentExtended] - request = build_deployments_get_at_scope_request( scope=scope, deployment_name=deployment_name, api_version=api_version, - template_url=self.get_at_scope.metadata['url'], + template_url=self.get_at_scope.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) - deserialized = self._deserialize('DeploymentExtended', pipeline_response) + deserialized = self._deserialize("DeploymentExtended", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - get_at_scope.metadata = {'url': "/{scope}/providers/Microsoft.Resources/deployments/{deploymentName}"} # type: ignore - + get_at_scope.metadata = {"url": "/{scope}/providers/Microsoft.Resources/deployments/{deploymentName}"} # type: ignore @distributed_trace_async async def cancel_at_scope( # pylint: disable=inconsistent-return-statements - self, - scope: str, - deployment_name: str, - **kwargs: Any + self, scope: str, deployment_name: str, **kwargs: Any ) -> None: """Cancels a currently running template deployment. @@ -502,38 +692,44 @@ async def cancel_at_scope( # pylint: disable=inconsistent-return-statements deployment stops the currently running template deployment and leaves the resources partially deployed. - :param scope: The resource scope. + :param scope: The resource scope. Required. :type scope: str - :param deployment_name: The name of the deployment. + :param deployment_name: The name of the deployment. Required. :type deployment_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: None, or the result of cls(response) + :return: None or the result of cls(response) :rtype: None - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType[None] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + 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', "2020-06-01") # type: str + api_version = kwargs.pop("api_version", _params.pop("api-version", "2020-06-01")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[None] - request = build_deployments_cancel_at_scope_request( scope=scope, deployment_name=deployment_name, api_version=api_version, - template_url=self.cancel_at_scope.metadata['url'], + template_url=self.cancel_at_scope.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [204]: @@ -543,43 +739,52 @@ async def cancel_at_scope( # pylint: disable=inconsistent-return-statements if cls: return cls(pipeline_response, None, {}) - cancel_at_scope.metadata = {'url': "/{scope}/providers/Microsoft.Resources/deployments/{deploymentName}/cancel"} # type: ignore - + cancel_at_scope.metadata = {"url": "/{scope}/providers/Microsoft.Resources/deployments/{deploymentName}/cancel"} # type: ignore async def _validate_at_scope_initial( - self, - scope: str, - deployment_name: str, - parameters: "_models.Deployment", - **kwargs: Any - ) -> Optional["_models.DeploymentValidateResult"]: - cls = kwargs.pop('cls', None) # type: ClsType[Optional["_models.DeploymentValidateResult"]] + self, scope: str, deployment_name: str, parameters: Union[_models.Deployment, IO], **kwargs: Any + ) -> Optional[_models.DeploymentValidateResult]: error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) - api_version = kwargs.pop('api_version', "2020-06-01") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - _json = self._serialize.body(parameters, 'Deployment') + api_version = kwargs.pop("api_version", _params.pop("api-version", "2020-06-01")) # type: str + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[Optional[_models.DeploymentValidateResult]] - request = build_deployments_validate_at_scope_request_initial( + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(parameters, (IO, bytes)): + _content = parameters + else: + _json = self._serialize.body(parameters, "Deployment") + + request = build_deployments_validate_at_scope_request( scope=scope, deployment_name=deployment_name, api_version=api_version, content_type=content_type, json=_json, - template_url=self._validate_at_scope_initial.metadata['url'], + content=_content, + template_url=self._validate_at_scope_initial.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200, 202, 400]: @@ -588,36 +793,40 @@ async def _validate_at_scope_initial( deserialized = None if response.status_code == 200: - deserialized = self._deserialize('DeploymentValidateResult', pipeline_response) + deserialized = self._deserialize("DeploymentValidateResult", pipeline_response) if response.status_code == 400: - deserialized = self._deserialize('DeploymentValidateResult', pipeline_response) + deserialized = self._deserialize("DeploymentValidateResult", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - _validate_at_scope_initial.metadata = {'url': "/{scope}/providers/Microsoft.Resources/deployments/{deploymentName}/validate"} # type: ignore + _validate_at_scope_initial.metadata = {"url": "/{scope}/providers/Microsoft.Resources/deployments/{deploymentName}/validate"} # type: ignore - - @distributed_trace_async + @overload async def begin_validate_at_scope( self, scope: str, deployment_name: str, - parameters: "_models.Deployment", + parameters: _models.Deployment, + *, + content_type: str = "application/json", **kwargs: Any - ) -> AsyncLROPoller["_models.DeploymentValidateResult"]: + ) -> AsyncLROPoller[_models.DeploymentValidateResult]: """Validates whether the specified template is syntactically correct and will be accepted by Azure Resource Manager.. - :param scope: The resource scope. + :param scope: The resource scope. Required. :type scope: str - :param deployment_name: The name of the deployment. + :param deployment_name: The name of the deployment. Required. :type deployment_name: str - :param parameters: Parameters to validate. + :param parameters: Parameters to validate. Required. :type parameters: ~azure.mgmt.resource.resources.v2020_06_01.models.Deployment + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str :keyword callable cls: A custom type or function that will be passed the direct response :keyword str continuation_token: A continuation token to restart a poller from a saved state. :keyword polling: By default, your polling method will be AsyncARMPolling. Pass in False for @@ -630,119 +839,182 @@ async def begin_validate_at_scope( result of cls(response) :rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.resource.resources.v2020_06_01.models.DeploymentValidateResult] - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - api_version = kwargs.pop('api_version', "2020-06-01") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] - polling = kwargs.pop('polling', True) # type: Union[bool, AsyncPollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType["_models.DeploymentValidateResult"] - lro_delay = kwargs.pop( - 'polling_interval', - self._config.polling_interval - ) - cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] + + @overload + async def begin_validate_at_scope( + self, scope: str, deployment_name: str, parameters: IO, *, content_type: str = "application/json", **kwargs: Any + ) -> AsyncLROPoller[_models.DeploymentValidateResult]: + """Validates whether the specified template is syntactically correct and will be accepted by Azure + Resource Manager.. + + :param scope: The resource scope. Required. + :type scope: str + :param deployment_name: The name of the deployment. Required. + :type deployment_name: str + :param parameters: Parameters to validate. Required. + :type parameters: IO + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be AsyncARMPolling. Pass in False for + this operation to not poll, or pass in your own initialized polling object for a personal + polling strategy. + :paramtype polling: bool or ~azure.core.polling.AsyncPollingMethod + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of AsyncLROPoller that returns either DeploymentValidateResult or the + result of cls(response) + :rtype: + ~azure.core.polling.AsyncLROPoller[~azure.mgmt.resource.resources.v2020_06_01.models.DeploymentValidateResult] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace_async + async def begin_validate_at_scope( + self, scope: str, deployment_name: str, parameters: Union[_models.Deployment, IO], **kwargs: Any + ) -> AsyncLROPoller[_models.DeploymentValidateResult]: + """Validates whether the specified template is syntactically correct and will be accepted by Azure + Resource Manager.. + + :param scope: The resource scope. Required. + :type scope: str + :param deployment_name: The name of the deployment. Required. + :type deployment_name: str + :param parameters: Parameters to validate. Is either a model type or a IO type. Required. + :type parameters: ~azure.mgmt.resource.resources.v2020_06_01.models.Deployment or IO + :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. + Default value is None. + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be AsyncARMPolling. Pass in False for + this operation to not poll, or pass in your own initialized polling object for a personal + polling strategy. + :paramtype polling: bool or ~azure.core.polling.AsyncPollingMethod + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of AsyncLROPoller that returns either DeploymentValidateResult or the + result of cls(response) + :rtype: + ~azure.core.polling.AsyncLROPoller[~azure.mgmt.resource.resources.v2020_06_01.models.DeploymentValidateResult] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _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", "2020-06-01")) # type: str + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.DeploymentValidateResult] + polling = kwargs.pop("polling", True) # type: Union[bool, AsyncPollingMethod] + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token = kwargs.pop("continuation_token", None) # type: Optional[str] if cont_token is None: - raw_result = await self._validate_at_scope_initial( + raw_result = await self._validate_at_scope_initial( # type: ignore scope=scope, deployment_name=deployment_name, parameters=parameters, api_version=api_version, content_type=content_type, - cls=lambda x,y,z: x, + cls=lambda x, y, z: x, + headers=_headers, + params=_params, **kwargs ) - kwargs.pop('error_map', None) + kwargs.pop("error_map", None) def get_long_running_output(pipeline_response): - response = pipeline_response.http_response - deserialized = self._deserialize('DeploymentValidateResult', pipeline_response) + deserialized = self._deserialize("DeploymentValidateResult", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - - if polling is True: polling_method = AsyncARMPolling(lro_delay, **kwargs) - elif polling is False: polling_method = AsyncNoPolling() - else: polling_method = polling + if polling is True: + polling_method = cast(AsyncPollingMethod, AsyncARMPolling(lro_delay, **kwargs)) # type: AsyncPollingMethod + elif polling is False: + polling_method = cast(AsyncPollingMethod, AsyncNoPolling()) + else: + polling_method = polling if cont_token: return AsyncLROPoller.from_continuation_token( polling_method=polling_method, continuation_token=cont_token, client=self._client, - deserialization_callback=get_long_running_output + deserialization_callback=get_long_running_output, ) return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) - begin_validate_at_scope.metadata = {'url': "/{scope}/providers/Microsoft.Resources/deployments/{deploymentName}/validate"} # type: ignore + begin_validate_at_scope.metadata = {"url": "/{scope}/providers/Microsoft.Resources/deployments/{deploymentName}/validate"} # type: ignore @distributed_trace_async async def export_template_at_scope( - self, - scope: str, - deployment_name: str, - **kwargs: Any - ) -> "_models.DeploymentExportResult": + self, scope: str, deployment_name: str, **kwargs: Any + ) -> _models.DeploymentExportResult: """Exports the template used for specified deployment. - :param scope: The resource scope. + :param scope: The resource scope. Required. :type scope: str - :param deployment_name: The name of the deployment. + :param deployment_name: The name of the deployment. Required. :type deployment_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: DeploymentExportResult, or the result of cls(response) + :return: DeploymentExportResult or the result of cls(response) :rtype: ~azure.mgmt.resource.resources.v2020_06_01.models.DeploymentExportResult - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.DeploymentExportResult"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + 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', "2020-06-01") # type: str + api_version = kwargs.pop("api_version", _params.pop("api-version", "2020-06-01")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[_models.DeploymentExportResult] - request = build_deployments_export_template_at_scope_request( scope=scope, deployment_name=deployment_name, api_version=api_version, - template_url=self.export_template_at_scope.metadata['url'], + template_url=self.export_template_at_scope.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) - deserialized = self._deserialize('DeploymentExportResult', pipeline_response) + deserialized = self._deserialize("DeploymentExportResult", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - export_template_at_scope.metadata = {'url': "/{scope}/providers/Microsoft.Resources/deployments/{deploymentName}/exportTemplate"} # type: ignore - + export_template_at_scope.metadata = {"url": "/{scope}/providers/Microsoft.Resources/deployments/{deploymentName}/exportTemplate"} # type: ignore @distributed_trace def list_at_scope( - self, - scope: str, - filter: Optional[str] = None, - top: Optional[int] = None, - **kwargs: Any - ) -> AsyncIterable["_models.DeploymentListResult"]: + self, scope: str, filter: Optional[str] = None, top: Optional[int] = None, **kwargs: Any + ) -> AsyncIterable["_models.DeploymentExtended"]: """Get all the deployments at the given scope. - :param scope: The resource scope. + :param scope: The resource scope. Required. :type scope: str :param filter: The filter to apply on the operation. For example, you can use $filter=provisioningState eq '{state}'. Default value is None. @@ -751,40 +1023,48 @@ def list_at_scope( value is None. :type top: int :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either DeploymentListResult or the result of - cls(response) + :return: An iterator like instance of either DeploymentExtended or the result of cls(response) :rtype: - ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.resource.resources.v2020_06_01.models.DeploymentListResult] - :raises: ~azure.core.exceptions.HttpResponseError + ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.resource.resources.v2020_06_01.models.DeploymentExtended] + :raises ~azure.core.exceptions.HttpResponseError: """ - api_version = kwargs.pop('api_version', "2020-06-01") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2020-06-01")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[_models.DeploymentListResult] - cls = kwargs.pop('cls', None) # type: ClsType["_models.DeploymentListResult"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) + def prepare_request(next_link=None): if not next_link: - + request = build_deployments_list_at_scope_request( scope=scope, - api_version=api_version, filter=filter, top=top, - template_url=self.list_at_scope.metadata['url'], + api_version=api_version, + template_url=self.list_at_scope.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore else: - - request = build_deployments_list_at_scope_request( - scope=scope, - template_url=next_link, - ) + # make call to next link with the client's api-version + _parsed_next_link = urlparse(next_link) + _next_request_params = case_insensitive_dict(parse_qs(_parsed_next_link.query)) + _next_request_params["api-version"] = self._config.api_version + request = HttpRequest("GET", urljoin(next_link, _parsed_next_link.path), params=_next_request_params) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore request.method = "GET" return request @@ -798,10 +1078,8 @@ async def extract_data(pipeline_response): async def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) response = pipeline_response.http_response @@ -811,39 +1089,41 @@ async def get_next(next_link=None): return pipeline_response + return AsyncItemPaged(get_next, extract_data) - return AsyncItemPaged( - get_next, extract_data - ) - list_at_scope.metadata = {'url': "/{scope}/providers/Microsoft.Resources/deployments/"} # type: ignore + list_at_scope.metadata = {"url": "/{scope}/providers/Microsoft.Resources/deployments/"} # type: ignore async def _delete_at_tenant_scope_initial( # pylint: disable=inconsistent-return-statements - self, - deployment_name: str, - **kwargs: Any + self, deployment_name: str, **kwargs: Any ) -> None: - cls = kwargs.pop('cls', None) # type: ClsType[None] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + 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', "2020-06-01") # type: str + api_version = kwargs.pop("api_version", _params.pop("api-version", "2020-06-01")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[None] - - request = build_deployments_delete_at_tenant_scope_request_initial( + request = build_deployments_delete_at_tenant_scope_request( deployment_name=deployment_name, api_version=api_version, - template_url=self._delete_at_tenant_scope_initial.metadata['url'], + template_url=self._delete_at_tenant_scope_initial.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [202, 204]: @@ -853,15 +1133,10 @@ async def _delete_at_tenant_scope_initial( # pylint: disable=inconsistent-retur if cls: return cls(pipeline_response, None, {}) - _delete_at_tenant_scope_initial.metadata = {'url': "/providers/Microsoft.Resources/deployments/{deploymentName}"} # type: ignore - + _delete_at_tenant_scope_initial.metadata = {"url": "/providers/Microsoft.Resources/deployments/{deploymentName}"} # type: ignore @distributed_trace_async - async def begin_delete_at_tenant_scope( # pylint: disable=inconsistent-return-statements - self, - deployment_name: str, - **kwargs: Any - ) -> AsyncLROPoller[None]: + async def begin_delete_at_tenant_scope(self, deployment_name: str, **kwargs: Any) -> AsyncLROPoller[None]: """Deletes a deployment from the deployment history. A template deployment that is currently running cannot be deleted. Deleting a template @@ -872,7 +1147,7 @@ async def begin_delete_at_tenant_scope( # pylint: disable=inconsistent-return-s process finishes, the URI in the Location header returns a status of 204 on success. If the asynchronous request failed, the URI in the Location header returns an error-level status code. - :param deployment_name: The name of the deployment. + :param deployment_name: The name of the deployment. Required. :type deployment_name: str :keyword callable cls: A custom type or function that will be passed the direct response :keyword str continuation_token: A continuation token to restart a poller from a saved state. @@ -884,81 +1159,87 @@ async def begin_delete_at_tenant_scope( # pylint: disable=inconsistent-return-s Retry-After header is present. :return: An instance of AsyncLROPoller that returns either None or the result of cls(response) :rtype: ~azure.core.polling.AsyncLROPoller[None] - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - api_version = kwargs.pop('api_version', "2020-06-01") # type: str - polling = kwargs.pop('polling', True) # type: Union[bool, AsyncPollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType[None] - lro_delay = kwargs.pop( - 'polling_interval', - self._config.polling_interval - ) - cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2020-06-01")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[None] + polling = kwargs.pop("polling", True) # type: Union[bool, AsyncPollingMethod] + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token = kwargs.pop("continuation_token", None) # type: Optional[str] if cont_token is None: - raw_result = await self._delete_at_tenant_scope_initial( + raw_result = await self._delete_at_tenant_scope_initial( # type: ignore deployment_name=deployment_name, api_version=api_version, - cls=lambda x,y,z: x, + cls=lambda x, y, z: x, + headers=_headers, + params=_params, **kwargs ) - kwargs.pop('error_map', None) + kwargs.pop("error_map", None) - def get_long_running_output(pipeline_response): + def get_long_running_output(pipeline_response): # pylint: disable=inconsistent-return-statements if cls: return cls(pipeline_response, None, {}) - - if polling is True: polling_method = AsyncARMPolling(lro_delay, **kwargs) - elif polling is False: polling_method = AsyncNoPolling() - else: polling_method = polling + if polling is True: + polling_method = cast(AsyncPollingMethod, AsyncARMPolling(lro_delay, **kwargs)) # type: AsyncPollingMethod + elif polling is False: + polling_method = cast(AsyncPollingMethod, AsyncNoPolling()) + else: + polling_method = polling if cont_token: return AsyncLROPoller.from_continuation_token( polling_method=polling_method, continuation_token=cont_token, client=self._client, - deserialization_callback=get_long_running_output + deserialization_callback=get_long_running_output, ) return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) - begin_delete_at_tenant_scope.metadata = {'url': "/providers/Microsoft.Resources/deployments/{deploymentName}"} # type: ignore + begin_delete_at_tenant_scope.metadata = {"url": "/providers/Microsoft.Resources/deployments/{deploymentName}"} # type: ignore @distributed_trace_async - async def check_existence_at_tenant_scope( - self, - deployment_name: str, - **kwargs: Any - ) -> bool: + async def check_existence_at_tenant_scope(self, deployment_name: str, **kwargs: Any) -> bool: """Checks whether the deployment exists. - :param deployment_name: The name of the deployment. + :param deployment_name: The name of the deployment. Required. :type deployment_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: bool, or the result of cls(response) + :return: bool or the result of cls(response) :rtype: bool - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType[None] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + 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', "2020-06-01") # type: str + api_version = kwargs.pop("api_version", _params.pop("api-version", "2020-06-01")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[None] - request = build_deployments_check_existence_at_tenant_scope_request( deployment_name=deployment_name, api_version=api_version, - template_url=self.check_existence_at_tenant_scope.metadata['url'], + template_url=self.check_existence_at_tenant_scope.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [204, 404]: @@ -969,41 +1250,51 @@ async def check_existence_at_tenant_scope( return cls(pipeline_response, None, {}) return 200 <= response.status_code <= 299 - check_existence_at_tenant_scope.metadata = {'url': "/providers/Microsoft.Resources/deployments/{deploymentName}"} # type: ignore - + check_existence_at_tenant_scope.metadata = {"url": "/providers/Microsoft.Resources/deployments/{deploymentName}"} # type: ignore async def _create_or_update_at_tenant_scope_initial( - self, - deployment_name: str, - parameters: "_models.ScopedDeployment", - **kwargs: Any - ) -> "_models.DeploymentExtended": - cls = kwargs.pop('cls', None) # type: ClsType["_models.DeploymentExtended"] + self, deployment_name: str, parameters: Union[_models.ScopedDeployment, IO], **kwargs: Any + ) -> _models.DeploymentExtended: error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', "2020-06-01") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + api_version = kwargs.pop("api_version", _params.pop("api-version", "2020-06-01")) # type: str + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.DeploymentExtended] - _json = self._serialize.body(parameters, 'ScopedDeployment') + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(parameters, (IO, bytes)): + _content = parameters + else: + _json = self._serialize.body(parameters, "ScopedDeployment") - request = build_deployments_create_or_update_at_tenant_scope_request_initial( + request = build_deployments_create_or_update_at_tenant_scope_request( deployment_name=deployment_name, api_version=api_version, content_type=content_type, json=_json, - template_url=self._create_or_update_at_tenant_scope_initial.metadata['url'], + content=_content, + template_url=self._create_or_update_at_tenant_scope_initial.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200, 201]: @@ -1011,34 +1302,38 @@ async def _create_or_update_at_tenant_scope_initial( raise HttpResponseError(response=response, error_format=ARMErrorFormat) if response.status_code == 200: - deserialized = self._deserialize('DeploymentExtended', pipeline_response) + deserialized = self._deserialize("DeploymentExtended", pipeline_response) if response.status_code == 201: - deserialized = self._deserialize('DeploymentExtended', pipeline_response) + deserialized = self._deserialize("DeploymentExtended", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - _create_or_update_at_tenant_scope_initial.metadata = {'url': "/providers/Microsoft.Resources/deployments/{deploymentName}"} # type: ignore - + _create_or_update_at_tenant_scope_initial.metadata = {"url": "/providers/Microsoft.Resources/deployments/{deploymentName}"} # type: ignore - @distributed_trace_async + @overload async def begin_create_or_update_at_tenant_scope( self, deployment_name: str, - parameters: "_models.ScopedDeployment", + parameters: _models.ScopedDeployment, + *, + content_type: str = "application/json", **kwargs: Any - ) -> AsyncLROPoller["_models.DeploymentExtended"]: + ) -> AsyncLROPoller[_models.DeploymentExtended]: """Deploys resources at tenant scope. You can provide the template and parameters directly in the request or link to JSON files. - :param deployment_name: The name of the deployment. + :param deployment_name: The name of the deployment. Required. :type deployment_name: str - :param parameters: Additional parameters supplied to the operation. + :param parameters: Additional parameters supplied to the operation. Required. :type parameters: ~azure.mgmt.resource.resources.v2020_06_01.models.ScopedDeployment + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str :keyword callable cls: A custom type or function that will be passed the direct response :keyword str continuation_token: A continuation token to restart a poller from a saved state. :keyword polling: By default, your polling method will be AsyncARMPolling. Pass in False for @@ -1051,108 +1346,171 @@ async def begin_create_or_update_at_tenant_scope( cls(response) :rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.resource.resources.v2020_06_01.models.DeploymentExtended] - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - api_version = kwargs.pop('api_version', "2020-06-01") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] - polling = kwargs.pop('polling', True) # type: Union[bool, AsyncPollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType["_models.DeploymentExtended"] - lro_delay = kwargs.pop( - 'polling_interval', - self._config.polling_interval - ) - cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] + + @overload + async def begin_create_or_update_at_tenant_scope( + self, deployment_name: str, parameters: IO, *, content_type: str = "application/json", **kwargs: Any + ) -> AsyncLROPoller[_models.DeploymentExtended]: + """Deploys resources at tenant scope. + + You can provide the template and parameters directly in the request or link to JSON files. + + :param deployment_name: The name of the deployment. Required. + :type deployment_name: str + :param parameters: Additional parameters supplied to the operation. Required. + :type parameters: IO + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be AsyncARMPolling. Pass in False for + this operation to not poll, or pass in your own initialized polling object for a personal + polling strategy. + :paramtype polling: bool or ~azure.core.polling.AsyncPollingMethod + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of AsyncLROPoller that returns either DeploymentExtended or the result of + cls(response) + :rtype: + ~azure.core.polling.AsyncLROPoller[~azure.mgmt.resource.resources.v2020_06_01.models.DeploymentExtended] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace_async + async def begin_create_or_update_at_tenant_scope( + self, deployment_name: str, parameters: Union[_models.ScopedDeployment, IO], **kwargs: Any + ) -> AsyncLROPoller[_models.DeploymentExtended]: + """Deploys resources at tenant scope. + + You can provide the template and parameters directly in the request or link to JSON files. + + :param deployment_name: The name of the deployment. Required. + :type deployment_name: str + :param parameters: Additional parameters supplied to the operation. Is either a model type or a + IO type. Required. + :type parameters: ~azure.mgmt.resource.resources.v2020_06_01.models.ScopedDeployment or IO + :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. + Default value is None. + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be AsyncARMPolling. Pass in False for + this operation to not poll, or pass in your own initialized polling object for a personal + polling strategy. + :paramtype polling: bool or ~azure.core.polling.AsyncPollingMethod + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of AsyncLROPoller that returns either DeploymentExtended or the result of + cls(response) + :rtype: + ~azure.core.polling.AsyncLROPoller[~azure.mgmt.resource.resources.v2020_06_01.models.DeploymentExtended] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _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", "2020-06-01")) # type: str + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.DeploymentExtended] + polling = kwargs.pop("polling", True) # type: Union[bool, AsyncPollingMethod] + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token = kwargs.pop("continuation_token", None) # type: Optional[str] if cont_token is None: - raw_result = await self._create_or_update_at_tenant_scope_initial( + raw_result = await self._create_or_update_at_tenant_scope_initial( # type: ignore deployment_name=deployment_name, parameters=parameters, api_version=api_version, content_type=content_type, - cls=lambda x,y,z: x, + cls=lambda x, y, z: x, + headers=_headers, + params=_params, **kwargs ) - kwargs.pop('error_map', None) + kwargs.pop("error_map", None) def get_long_running_output(pipeline_response): - response = pipeline_response.http_response - deserialized = self._deserialize('DeploymentExtended', pipeline_response) + deserialized = self._deserialize("DeploymentExtended", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - - if polling is True: polling_method = AsyncARMPolling(lro_delay, **kwargs) - elif polling is False: polling_method = AsyncNoPolling() - else: polling_method = polling + if polling is True: + polling_method = cast(AsyncPollingMethod, AsyncARMPolling(lro_delay, **kwargs)) # type: AsyncPollingMethod + elif polling is False: + polling_method = cast(AsyncPollingMethod, AsyncNoPolling()) + else: + polling_method = polling if cont_token: return AsyncLROPoller.from_continuation_token( polling_method=polling_method, continuation_token=cont_token, client=self._client, - deserialization_callback=get_long_running_output + deserialization_callback=get_long_running_output, ) return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) - begin_create_or_update_at_tenant_scope.metadata = {'url': "/providers/Microsoft.Resources/deployments/{deploymentName}"} # type: ignore + begin_create_or_update_at_tenant_scope.metadata = {"url": "/providers/Microsoft.Resources/deployments/{deploymentName}"} # type: ignore @distributed_trace_async - async def get_at_tenant_scope( - self, - deployment_name: str, - **kwargs: Any - ) -> "_models.DeploymentExtended": + async def get_at_tenant_scope(self, deployment_name: str, **kwargs: Any) -> _models.DeploymentExtended: """Gets a deployment. - :param deployment_name: The name of the deployment. + :param deployment_name: The name of the deployment. Required. :type deployment_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: DeploymentExtended, or the result of cls(response) + :return: DeploymentExtended or the result of cls(response) :rtype: ~azure.mgmt.resource.resources.v2020_06_01.models.DeploymentExtended - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.DeploymentExtended"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) - api_version = kwargs.pop('api_version', "2020-06-01") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2020-06-01")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[_models.DeploymentExtended] - request = build_deployments_get_at_tenant_scope_request( deployment_name=deployment_name, api_version=api_version, - template_url=self.get_at_tenant_scope.metadata['url'], + template_url=self.get_at_tenant_scope.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) - deserialized = self._deserialize('DeploymentExtended', pipeline_response) + deserialized = self._deserialize("DeploymentExtended", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - get_at_tenant_scope.metadata = {'url': "/providers/Microsoft.Resources/deployments/{deploymentName}"} # type: ignore - + get_at_tenant_scope.metadata = {"url": "/providers/Microsoft.Resources/deployments/{deploymentName}"} # type: ignore @distributed_trace_async async def cancel_at_tenant_scope( # pylint: disable=inconsistent-return-statements - self, - deployment_name: str, - **kwargs: Any + self, deployment_name: str, **kwargs: Any ) -> None: """Cancels a currently running template deployment. @@ -1161,35 +1519,41 @@ async def cancel_at_tenant_scope( # pylint: disable=inconsistent-return-stateme deployment stops the currently running template deployment and leaves the resources partially deployed. - :param deployment_name: The name of the deployment. + :param deployment_name: The name of the deployment. Required. :type deployment_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: None, or the result of cls(response) + :return: None or the result of cls(response) :rtype: None - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType[None] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) - api_version = kwargs.pop('api_version', "2020-06-01") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2020-06-01")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[None] - request = build_deployments_cancel_at_tenant_scope_request( deployment_name=deployment_name, api_version=api_version, - template_url=self.cancel_at_tenant_scope.metadata['url'], + template_url=self.cancel_at_tenant_scope.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [204]: @@ -1199,41 +1563,51 @@ async def cancel_at_tenant_scope( # pylint: disable=inconsistent-return-stateme if cls: return cls(pipeline_response, None, {}) - cancel_at_tenant_scope.metadata = {'url': "/providers/Microsoft.Resources/deployments/{deploymentName}/cancel"} # type: ignore - + cancel_at_tenant_scope.metadata = {"url": "/providers/Microsoft.Resources/deployments/{deploymentName}/cancel"} # type: ignore async def _validate_at_tenant_scope_initial( - self, - deployment_name: str, - parameters: "_models.ScopedDeployment", - **kwargs: Any - ) -> Optional["_models.DeploymentValidateResult"]: - cls = kwargs.pop('cls', None) # type: ClsType[Optional["_models.DeploymentValidateResult"]] + self, deployment_name: str, parameters: Union[_models.ScopedDeployment, IO], **kwargs: Any + ) -> Optional[_models.DeploymentValidateResult]: error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) - api_version = kwargs.pop('api_version', "2020-06-01") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - _json = self._serialize.body(parameters, 'ScopedDeployment') + api_version = kwargs.pop("api_version", _params.pop("api-version", "2020-06-01")) # type: str + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[Optional[_models.DeploymentValidateResult]] - request = build_deployments_validate_at_tenant_scope_request_initial( + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(parameters, (IO, bytes)): + _content = parameters + else: + _json = self._serialize.body(parameters, "ScopedDeployment") + + request = build_deployments_validate_at_tenant_scope_request( deployment_name=deployment_name, api_version=api_version, content_type=content_type, json=_json, - template_url=self._validate_at_tenant_scope_initial.metadata['url'], + content=_content, + template_url=self._validate_at_tenant_scope_initial.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200, 202, 400]: @@ -1242,33 +1616,37 @@ async def _validate_at_tenant_scope_initial( deserialized = None if response.status_code == 200: - deserialized = self._deserialize('DeploymentValidateResult', pipeline_response) + deserialized = self._deserialize("DeploymentValidateResult", pipeline_response) if response.status_code == 400: - deserialized = self._deserialize('DeploymentValidateResult', pipeline_response) + deserialized = self._deserialize("DeploymentValidateResult", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - _validate_at_tenant_scope_initial.metadata = {'url': "/providers/Microsoft.Resources/deployments/{deploymentName}/validate"} # type: ignore + _validate_at_tenant_scope_initial.metadata = {"url": "/providers/Microsoft.Resources/deployments/{deploymentName}/validate"} # type: ignore - - @distributed_trace_async + @overload async def begin_validate_at_tenant_scope( self, deployment_name: str, - parameters: "_models.ScopedDeployment", + parameters: _models.ScopedDeployment, + *, + content_type: str = "application/json", **kwargs: Any - ) -> AsyncLROPoller["_models.DeploymentValidateResult"]: + ) -> AsyncLROPoller[_models.DeploymentValidateResult]: """Validates whether the specified template is syntactically correct and will be accepted by Azure Resource Manager.. - :param deployment_name: The name of the deployment. + :param deployment_name: The name of the deployment. Required. :type deployment_name: str - :param parameters: Parameters to validate. + :param parameters: Parameters to validate. Required. :type parameters: ~azure.mgmt.resource.resources.v2020_06_01.models.ScopedDeployment + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str :keyword callable cls: A custom type or function that will be passed the direct response :keyword str continuation_token: A continuation token to restart a poller from a saved state. :keyword polling: By default, your polling method will be AsyncARMPolling. Pass in False for @@ -1281,82 +1659,154 @@ async def begin_validate_at_tenant_scope( result of cls(response) :rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.resource.resources.v2020_06_01.models.DeploymentValidateResult] - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - api_version = kwargs.pop('api_version', "2020-06-01") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] - polling = kwargs.pop('polling', True) # type: Union[bool, AsyncPollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType["_models.DeploymentValidateResult"] - lro_delay = kwargs.pop( - 'polling_interval', - self._config.polling_interval - ) - cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] + + @overload + async def begin_validate_at_tenant_scope( + self, deployment_name: str, parameters: IO, *, content_type: str = "application/json", **kwargs: Any + ) -> AsyncLROPoller[_models.DeploymentValidateResult]: + """Validates whether the specified template is syntactically correct and will be accepted by Azure + Resource Manager.. + + :param deployment_name: The name of the deployment. Required. + :type deployment_name: str + :param parameters: Parameters to validate. Required. + :type parameters: IO + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be AsyncARMPolling. Pass in False for + this operation to not poll, or pass in your own initialized polling object for a personal + polling strategy. + :paramtype polling: bool or ~azure.core.polling.AsyncPollingMethod + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of AsyncLROPoller that returns either DeploymentValidateResult or the + result of cls(response) + :rtype: + ~azure.core.polling.AsyncLROPoller[~azure.mgmt.resource.resources.v2020_06_01.models.DeploymentValidateResult] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace_async + async def begin_validate_at_tenant_scope( + self, deployment_name: str, parameters: Union[_models.ScopedDeployment, IO], **kwargs: Any + ) -> AsyncLROPoller[_models.DeploymentValidateResult]: + """Validates whether the specified template is syntactically correct and will be accepted by Azure + Resource Manager.. + + :param deployment_name: The name of the deployment. Required. + :type deployment_name: str + :param parameters: Parameters to validate. Is either a model type or a IO type. Required. + :type parameters: ~azure.mgmt.resource.resources.v2020_06_01.models.ScopedDeployment or IO + :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. + Default value is None. + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be AsyncARMPolling. Pass in False for + this operation to not poll, or pass in your own initialized polling object for a personal + polling strategy. + :paramtype polling: bool or ~azure.core.polling.AsyncPollingMethod + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of AsyncLROPoller that returns either DeploymentValidateResult or the + result of cls(response) + :rtype: + ~azure.core.polling.AsyncLROPoller[~azure.mgmt.resource.resources.v2020_06_01.models.DeploymentValidateResult] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _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", "2020-06-01")) # type: str + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.DeploymentValidateResult] + polling = kwargs.pop("polling", True) # type: Union[bool, AsyncPollingMethod] + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token = kwargs.pop("continuation_token", None) # type: Optional[str] if cont_token is None: - raw_result = await self._validate_at_tenant_scope_initial( + raw_result = await self._validate_at_tenant_scope_initial( # type: ignore deployment_name=deployment_name, parameters=parameters, api_version=api_version, content_type=content_type, - cls=lambda x,y,z: x, + cls=lambda x, y, z: x, + headers=_headers, + params=_params, **kwargs ) - kwargs.pop('error_map', None) + kwargs.pop("error_map", None) def get_long_running_output(pipeline_response): - response = pipeline_response.http_response - deserialized = self._deserialize('DeploymentValidateResult', pipeline_response) + deserialized = self._deserialize("DeploymentValidateResult", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - - if polling is True: polling_method = AsyncARMPolling(lro_delay, **kwargs) - elif polling is False: polling_method = AsyncNoPolling() - else: polling_method = polling + if polling is True: + polling_method = cast(AsyncPollingMethod, AsyncARMPolling(lro_delay, **kwargs)) # type: AsyncPollingMethod + elif polling is False: + polling_method = cast(AsyncPollingMethod, AsyncNoPolling()) + else: + polling_method = polling if cont_token: return AsyncLROPoller.from_continuation_token( polling_method=polling_method, continuation_token=cont_token, client=self._client, - deserialization_callback=get_long_running_output + deserialization_callback=get_long_running_output, ) return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) - begin_validate_at_tenant_scope.metadata = {'url': "/providers/Microsoft.Resources/deployments/{deploymentName}/validate"} # type: ignore + begin_validate_at_tenant_scope.metadata = {"url": "/providers/Microsoft.Resources/deployments/{deploymentName}/validate"} # type: ignore async def _what_if_at_tenant_scope_initial( - self, - deployment_name: str, - parameters: "_models.ScopedDeploymentWhatIf", - **kwargs: Any - ) -> Optional["_models.WhatIfOperationResult"]: - cls = kwargs.pop('cls', None) # type: ClsType[Optional["_models.WhatIfOperationResult"]] + self, deployment_name: str, parameters: Union[_models.ScopedDeploymentWhatIf, IO], **kwargs: Any + ) -> Optional[_models.WhatIfOperationResult]: error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) - api_version = kwargs.pop('api_version', "2020-06-01") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - _json = self._serialize.body(parameters, 'ScopedDeploymentWhatIf') + api_version = kwargs.pop("api_version", _params.pop("api-version", "2020-06-01")) # type: str + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[Optional[_models.WhatIfOperationResult]] - request = build_deployments_what_if_at_tenant_scope_request_initial( + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(parameters, (IO, bytes)): + _content = parameters + else: + _json = self._serialize.body(parameters, "ScopedDeploymentWhatIf") + + request = build_deployments_what_if_at_tenant_scope_request( deployment_name=deployment_name, api_version=api_version, content_type=content_type, json=_json, - template_url=self._what_if_at_tenant_scope_initial.metadata['url'], + content=_content, + template_url=self._what_if_at_tenant_scope_initial.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200, 202]: @@ -1366,35 +1816,38 @@ async def _what_if_at_tenant_scope_initial( deserialized = None response_headers = {} if response.status_code == 200: - deserialized = self._deserialize('WhatIfOperationResult', pipeline_response) + deserialized = self._deserialize("WhatIfOperationResult", pipeline_response) if response.status_code == 202: - response_headers['Location']=self._deserialize('str', response.headers.get('Location')) - response_headers['Retry-After']=self._deserialize('str', response.headers.get('Retry-After')) - + response_headers["Location"] = self._deserialize("str", response.headers.get("Location")) + response_headers["Retry-After"] = self._deserialize("str", response.headers.get("Retry-After")) if cls: return cls(pipeline_response, deserialized, response_headers) return deserialized - _what_if_at_tenant_scope_initial.metadata = {'url': "/providers/Microsoft.Resources/deployments/{deploymentName}/whatIf"} # type: ignore + _what_if_at_tenant_scope_initial.metadata = {"url": "/providers/Microsoft.Resources/deployments/{deploymentName}/whatIf"} # type: ignore - - @distributed_trace_async + @overload async def begin_what_if_at_tenant_scope( self, deployment_name: str, - parameters: "_models.ScopedDeploymentWhatIf", + parameters: _models.ScopedDeploymentWhatIf, + *, + content_type: str = "application/json", **kwargs: Any - ) -> AsyncLROPoller["_models.WhatIfOperationResult"]: + ) -> AsyncLROPoller[_models.WhatIfOperationResult]: """Returns changes that will be made by the deployment if executed at the scope of the tenant group. - :param deployment_name: The name of the deployment. + :param deployment_name: The name of the deployment. Required. :type deployment_name: str - :param parameters: Parameters to validate. + :param parameters: Parameters to validate. Required. :type parameters: ~azure.mgmt.resource.resources.v2020_06_01.models.ScopedDeploymentWhatIf + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str :keyword callable cls: A custom type or function that will be passed the direct response :keyword str continuation_token: A continuation token to restart a poller from a saved state. :keyword polling: By default, your polling method will be AsyncARMPolling. Pass in False for @@ -1407,110 +1860,174 @@ async def begin_what_if_at_tenant_scope( of cls(response) :rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.resource.resources.v2020_06_01.models.WhatIfOperationResult] - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - api_version = kwargs.pop('api_version', "2020-06-01") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] - polling = kwargs.pop('polling', True) # type: Union[bool, AsyncPollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType["_models.WhatIfOperationResult"] - lro_delay = kwargs.pop( - 'polling_interval', - self._config.polling_interval - ) - cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] + + @overload + async def begin_what_if_at_tenant_scope( + self, deployment_name: str, parameters: IO, *, content_type: str = "application/json", **kwargs: Any + ) -> AsyncLROPoller[_models.WhatIfOperationResult]: + """Returns changes that will be made by the deployment if executed at the scope of the tenant + group. + + :param deployment_name: The name of the deployment. Required. + :type deployment_name: str + :param parameters: Parameters to validate. Required. + :type parameters: IO + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be AsyncARMPolling. Pass in False for + this operation to not poll, or pass in your own initialized polling object for a personal + polling strategy. + :paramtype polling: bool or ~azure.core.polling.AsyncPollingMethod + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of AsyncLROPoller that returns either WhatIfOperationResult or the result + of cls(response) + :rtype: + ~azure.core.polling.AsyncLROPoller[~azure.mgmt.resource.resources.v2020_06_01.models.WhatIfOperationResult] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace_async + async def begin_what_if_at_tenant_scope( + self, deployment_name: str, parameters: Union[_models.ScopedDeploymentWhatIf, IO], **kwargs: Any + ) -> AsyncLROPoller[_models.WhatIfOperationResult]: + """Returns changes that will be made by the deployment if executed at the scope of the tenant + group. + + :param deployment_name: The name of the deployment. Required. + :type deployment_name: str + :param parameters: Parameters to validate. Is either a model type or a IO type. Required. + :type parameters: ~azure.mgmt.resource.resources.v2020_06_01.models.ScopedDeploymentWhatIf or + IO + :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. + Default value is None. + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be AsyncARMPolling. Pass in False for + this operation to not poll, or pass in your own initialized polling object for a personal + polling strategy. + :paramtype polling: bool or ~azure.core.polling.AsyncPollingMethod + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of AsyncLROPoller that returns either WhatIfOperationResult or the result + of cls(response) + :rtype: + ~azure.core.polling.AsyncLROPoller[~azure.mgmt.resource.resources.v2020_06_01.models.WhatIfOperationResult] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _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", "2020-06-01")) # type: str + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.WhatIfOperationResult] + polling = kwargs.pop("polling", True) # type: Union[bool, AsyncPollingMethod] + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token = kwargs.pop("continuation_token", None) # type: Optional[str] if cont_token is None: - raw_result = await self._what_if_at_tenant_scope_initial( + raw_result = await self._what_if_at_tenant_scope_initial( # type: ignore deployment_name=deployment_name, parameters=parameters, api_version=api_version, content_type=content_type, - cls=lambda x,y,z: x, + cls=lambda x, y, z: x, + headers=_headers, + params=_params, **kwargs ) - kwargs.pop('error_map', None) + kwargs.pop("error_map", None) def get_long_running_output(pipeline_response): - response = pipeline_response.http_response - deserialized = self._deserialize('WhatIfOperationResult', pipeline_response) + deserialized = self._deserialize("WhatIfOperationResult", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - - if polling is True: polling_method = AsyncARMPolling(lro_delay, lro_options={'final-state-via': 'location'}, **kwargs) - elif polling is False: polling_method = AsyncNoPolling() - else: polling_method = polling + if polling is True: + polling_method = cast( + AsyncPollingMethod, AsyncARMPolling(lro_delay, lro_options={"final-state-via": "location"}, **kwargs) + ) # type: AsyncPollingMethod + elif polling is False: + polling_method = cast(AsyncPollingMethod, AsyncNoPolling()) + else: + polling_method = polling if cont_token: return AsyncLROPoller.from_continuation_token( polling_method=polling_method, continuation_token=cont_token, client=self._client, - deserialization_callback=get_long_running_output + deserialization_callback=get_long_running_output, ) return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) - begin_what_if_at_tenant_scope.metadata = {'url': "/providers/Microsoft.Resources/deployments/{deploymentName}/whatIf"} # type: ignore + begin_what_if_at_tenant_scope.metadata = {"url": "/providers/Microsoft.Resources/deployments/{deploymentName}/whatIf"} # type: ignore @distributed_trace_async async def export_template_at_tenant_scope( - self, - deployment_name: str, - **kwargs: Any - ) -> "_models.DeploymentExportResult": + self, deployment_name: str, **kwargs: Any + ) -> _models.DeploymentExportResult: """Exports the template used for specified deployment. - :param deployment_name: The name of the deployment. + :param deployment_name: The name of the deployment. Required. :type deployment_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: DeploymentExportResult, or the result of cls(response) + :return: DeploymentExportResult or the result of cls(response) :rtype: ~azure.mgmt.resource.resources.v2020_06_01.models.DeploymentExportResult - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.DeploymentExportResult"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) - api_version = kwargs.pop('api_version', "2020-06-01") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2020-06-01")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[_models.DeploymentExportResult] - request = build_deployments_export_template_at_tenant_scope_request( deployment_name=deployment_name, api_version=api_version, - template_url=self.export_template_at_tenant_scope.metadata['url'], + template_url=self.export_template_at_tenant_scope.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) - deserialized = self._deserialize('DeploymentExportResult', pipeline_response) + deserialized = self._deserialize("DeploymentExportResult", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - export_template_at_tenant_scope.metadata = {'url': "/providers/Microsoft.Resources/deployments/{deploymentName}/exportTemplate"} # type: ignore - + export_template_at_tenant_scope.metadata = {"url": "/providers/Microsoft.Resources/deployments/{deploymentName}/exportTemplate"} # type: ignore @distributed_trace def list_at_tenant_scope( - self, - filter: Optional[str] = None, - top: Optional[int] = None, - **kwargs: Any - ) -> AsyncIterable["_models.DeploymentListResult"]: + self, filter: Optional[str] = None, top: Optional[int] = None, **kwargs: Any + ) -> AsyncIterable["_models.DeploymentExtended"]: """Get all the deployments at the tenant scope. :param filter: The filter to apply on the operation. For example, you can use @@ -1520,38 +2037,47 @@ def list_at_tenant_scope( value is None. :type top: int :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either DeploymentListResult or the result of - cls(response) + :return: An iterator like instance of either DeploymentExtended or the result of cls(response) :rtype: - ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.resource.resources.v2020_06_01.models.DeploymentListResult] - :raises: ~azure.core.exceptions.HttpResponseError + ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.resource.resources.v2020_06_01.models.DeploymentExtended] + :raises ~azure.core.exceptions.HttpResponseError: """ - api_version = kwargs.pop('api_version', "2020-06-01") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2020-06-01")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[_models.DeploymentListResult] - cls = kwargs.pop('cls', None) # type: ClsType["_models.DeploymentListResult"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) + def prepare_request(next_link=None): if not next_link: - + request = build_deployments_list_at_tenant_scope_request( - api_version=api_version, filter=filter, top=top, - template_url=self.list_at_tenant_scope.metadata['url'], + api_version=api_version, + template_url=self.list_at_tenant_scope.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore else: - - request = build_deployments_list_at_tenant_scope_request( - template_url=next_link, - ) + # make call to next link with the client's api-version + _parsed_next_link = urlparse(next_link) + _next_request_params = case_insensitive_dict(parse_qs(_parsed_next_link.query)) + _next_request_params["api-version"] = self._config.api_version + request = HttpRequest("GET", urljoin(next_link, _parsed_next_link.path), params=_next_request_params) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore request.method = "GET" return request @@ -1565,10 +2091,8 @@ async def extract_data(pipeline_response): async def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) response = pipeline_response.http_response @@ -1578,41 +2102,42 @@ async def get_next(next_link=None): return pipeline_response + return AsyncItemPaged(get_next, extract_data) - return AsyncItemPaged( - get_next, extract_data - ) - list_at_tenant_scope.metadata = {'url': "/providers/Microsoft.Resources/deployments/"} # type: ignore + list_at_tenant_scope.metadata = {"url": "/providers/Microsoft.Resources/deployments/"} # type: ignore async def _delete_at_management_group_scope_initial( # pylint: disable=inconsistent-return-statements - self, - group_id: str, - deployment_name: str, - **kwargs: Any + self, group_id: str, deployment_name: str, **kwargs: Any ) -> None: - cls = kwargs.pop('cls', None) # type: ClsType[None] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + 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', "2020-06-01") # type: str + api_version = kwargs.pop("api_version", _params.pop("api-version", "2020-06-01")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[None] - - request = build_deployments_delete_at_management_group_scope_request_initial( + request = build_deployments_delete_at_management_group_scope_request( group_id=group_id, deployment_name=deployment_name, api_version=api_version, - template_url=self._delete_at_management_group_scope_initial.metadata['url'], + template_url=self._delete_at_management_group_scope_initial.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [202, 204]: @@ -1622,15 +2147,11 @@ async def _delete_at_management_group_scope_initial( # pylint: disable=inconsis if cls: return cls(pipeline_response, None, {}) - _delete_at_management_group_scope_initial.metadata = {'url': "/providers/Microsoft.Management/managementGroups/{groupId}/providers/Microsoft.Resources/deployments/{deploymentName}"} # type: ignore - + _delete_at_management_group_scope_initial.metadata = {"url": "/providers/Microsoft.Management/managementGroups/{groupId}/providers/Microsoft.Resources/deployments/{deploymentName}"} # type: ignore @distributed_trace_async - async def begin_delete_at_management_group_scope( # pylint: disable=inconsistent-return-statements - self, - group_id: str, - deployment_name: str, - **kwargs: Any + async def begin_delete_at_management_group_scope( + self, group_id: str, deployment_name: str, **kwargs: Any ) -> AsyncLROPoller[None]: """Deletes a deployment from the deployment history. @@ -1642,9 +2163,9 @@ async def begin_delete_at_management_group_scope( # pylint: disable=inconsisten process finishes, the URI in the Location header returns a status of 204 on success. If the asynchronous request failed, the URI in the Location header returns an error-level status code. - :param group_id: The management group ID. + :param group_id: The management group ID. Required. :type group_id: str - :param deployment_name: The name of the deployment. + :param deployment_name: The name of the deployment. Required. :type deployment_name: str :keyword callable cls: A custom type or function that will be passed the direct response :keyword str continuation_token: A continuation token to restart a poller from a saved state. @@ -1656,86 +2177,93 @@ async def begin_delete_at_management_group_scope( # pylint: disable=inconsisten Retry-After header is present. :return: An instance of AsyncLROPoller that returns either None or the result of cls(response) :rtype: ~azure.core.polling.AsyncLROPoller[None] - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - api_version = kwargs.pop('api_version', "2020-06-01") # type: str - polling = kwargs.pop('polling', True) # type: Union[bool, AsyncPollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType[None] - lro_delay = kwargs.pop( - 'polling_interval', - self._config.polling_interval - ) - cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2020-06-01")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[None] + polling = kwargs.pop("polling", True) # type: Union[bool, AsyncPollingMethod] + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token = kwargs.pop("continuation_token", None) # type: Optional[str] if cont_token is None: - raw_result = await self._delete_at_management_group_scope_initial( + raw_result = await self._delete_at_management_group_scope_initial( # type: ignore group_id=group_id, deployment_name=deployment_name, api_version=api_version, - cls=lambda x,y,z: x, + cls=lambda x, y, z: x, + headers=_headers, + params=_params, **kwargs ) - kwargs.pop('error_map', None) + kwargs.pop("error_map", None) - def get_long_running_output(pipeline_response): + def get_long_running_output(pipeline_response): # pylint: disable=inconsistent-return-statements if cls: return cls(pipeline_response, None, {}) - - if polling is True: polling_method = AsyncARMPolling(lro_delay, **kwargs) - elif polling is False: polling_method = AsyncNoPolling() - else: polling_method = polling + if polling is True: + polling_method = cast(AsyncPollingMethod, AsyncARMPolling(lro_delay, **kwargs)) # type: AsyncPollingMethod + elif polling is False: + polling_method = cast(AsyncPollingMethod, AsyncNoPolling()) + else: + polling_method = polling if cont_token: return AsyncLROPoller.from_continuation_token( polling_method=polling_method, continuation_token=cont_token, client=self._client, - deserialization_callback=get_long_running_output + deserialization_callback=get_long_running_output, ) return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) - begin_delete_at_management_group_scope.metadata = {'url': "/providers/Microsoft.Management/managementGroups/{groupId}/providers/Microsoft.Resources/deployments/{deploymentName}"} # type: ignore + begin_delete_at_management_group_scope.metadata = {"url": "/providers/Microsoft.Management/managementGroups/{groupId}/providers/Microsoft.Resources/deployments/{deploymentName}"} # type: ignore @distributed_trace_async async def check_existence_at_management_group_scope( - self, - group_id: str, - deployment_name: str, - **kwargs: Any + self, group_id: str, deployment_name: str, **kwargs: Any ) -> bool: """Checks whether the deployment exists. - :param group_id: The management group ID. + :param group_id: The management group ID. Required. :type group_id: str - :param deployment_name: The name of the deployment. + :param deployment_name: The name of the deployment. Required. :type deployment_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: bool, or the result of cls(response) + :return: bool or the result of cls(response) :rtype: bool - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType[None] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + 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', "2020-06-01") # type: str + api_version = kwargs.pop("api_version", _params.pop("api-version", "2020-06-01")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[None] - request = build_deployments_check_existence_at_management_group_scope_request( group_id=group_id, deployment_name=deployment_name, api_version=api_version, - template_url=self.check_existence_at_management_group_scope.metadata['url'], + template_url=self.check_existence_at_management_group_scope.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [204, 404]: @@ -1746,43 +2274,52 @@ async def check_existence_at_management_group_scope( return cls(pipeline_response, None, {}) return 200 <= response.status_code <= 299 - check_existence_at_management_group_scope.metadata = {'url': "/providers/Microsoft.Management/managementGroups/{groupId}/providers/Microsoft.Resources/deployments/{deploymentName}"} # type: ignore - + check_existence_at_management_group_scope.metadata = {"url": "/providers/Microsoft.Management/managementGroups/{groupId}/providers/Microsoft.Resources/deployments/{deploymentName}"} # type: ignore async def _create_or_update_at_management_group_scope_initial( - self, - group_id: str, - deployment_name: str, - parameters: "_models.ScopedDeployment", - **kwargs: Any - ) -> "_models.DeploymentExtended": - cls = kwargs.pop('cls', None) # type: ClsType["_models.DeploymentExtended"] + self, group_id: str, deployment_name: str, parameters: Union[_models.ScopedDeployment, IO], **kwargs: Any + ) -> _models.DeploymentExtended: error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) - api_version = kwargs.pop('api_version', "2020-06-01") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - _json = self._serialize.body(parameters, 'ScopedDeployment') + api_version = kwargs.pop("api_version", _params.pop("api-version", "2020-06-01")) # type: str + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.DeploymentExtended] - request = build_deployments_create_or_update_at_management_group_scope_request_initial( + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(parameters, (IO, bytes)): + _content = parameters + else: + _json = self._serialize.body(parameters, "ScopedDeployment") + + request = build_deployments_create_or_update_at_management_group_scope_request( group_id=group_id, deployment_name=deployment_name, api_version=api_version, content_type=content_type, json=_json, - template_url=self._create_or_update_at_management_group_scope_initial.metadata['url'], + content=_content, + template_url=self._create_or_update_at_management_group_scope_initial.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200, 201]: @@ -1790,37 +2327,41 @@ async def _create_or_update_at_management_group_scope_initial( raise HttpResponseError(response=response, error_format=ARMErrorFormat) if response.status_code == 200: - deserialized = self._deserialize('DeploymentExtended', pipeline_response) + deserialized = self._deserialize("DeploymentExtended", pipeline_response) if response.status_code == 201: - deserialized = self._deserialize('DeploymentExtended', pipeline_response) + deserialized = self._deserialize("DeploymentExtended", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - _create_or_update_at_management_group_scope_initial.metadata = {'url': "/providers/Microsoft.Management/managementGroups/{groupId}/providers/Microsoft.Resources/deployments/{deploymentName}"} # type: ignore + _create_or_update_at_management_group_scope_initial.metadata = {"url": "/providers/Microsoft.Management/managementGroups/{groupId}/providers/Microsoft.Resources/deployments/{deploymentName}"} # type: ignore - - @distributed_trace_async + @overload async def begin_create_or_update_at_management_group_scope( self, group_id: str, deployment_name: str, - parameters: "_models.ScopedDeployment", + parameters: _models.ScopedDeployment, + *, + content_type: str = "application/json", **kwargs: Any - ) -> AsyncLROPoller["_models.DeploymentExtended"]: + ) -> AsyncLROPoller[_models.DeploymentExtended]: """Deploys resources at management group scope. You can provide the template and parameters directly in the request or link to JSON files. - :param group_id: The management group ID. + :param group_id: The management group ID. Required. :type group_id: str - :param deployment_name: The name of the deployment. + :param deployment_name: The name of the deployment. Required. :type deployment_name: str - :param parameters: Additional parameters supplied to the operation. + :param parameters: Additional parameters supplied to the operation. Required. :type parameters: ~azure.mgmt.resource.resources.v2020_06_01.models.ScopedDeployment + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str :keyword callable cls: A custom type or function that will be passed the direct response :keyword str continuation_token: A continuation token to restart a poller from a saved state. :keyword polling: By default, your polling method will be AsyncARMPolling. Pass in False for @@ -1833,114 +2374,187 @@ async def begin_create_or_update_at_management_group_scope( cls(response) :rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.resource.resources.v2020_06_01.models.DeploymentExtended] - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - api_version = kwargs.pop('api_version', "2020-06-01") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] - polling = kwargs.pop('polling', True) # type: Union[bool, AsyncPollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType["_models.DeploymentExtended"] - lro_delay = kwargs.pop( - 'polling_interval', - self._config.polling_interval - ) - cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] + + @overload + async def begin_create_or_update_at_management_group_scope( + self, + group_id: str, + deployment_name: str, + parameters: IO, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> AsyncLROPoller[_models.DeploymentExtended]: + """Deploys resources at management group scope. + + You can provide the template and parameters directly in the request or link to JSON files. + + :param group_id: The management group ID. Required. + :type group_id: str + :param deployment_name: The name of the deployment. Required. + :type deployment_name: str + :param parameters: Additional parameters supplied to the operation. Required. + :type parameters: IO + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be AsyncARMPolling. Pass in False for + this operation to not poll, or pass in your own initialized polling object for a personal + polling strategy. + :paramtype polling: bool or ~azure.core.polling.AsyncPollingMethod + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of AsyncLROPoller that returns either DeploymentExtended or the result of + cls(response) + :rtype: + ~azure.core.polling.AsyncLROPoller[~azure.mgmt.resource.resources.v2020_06_01.models.DeploymentExtended] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace_async + async def begin_create_or_update_at_management_group_scope( + self, group_id: str, deployment_name: str, parameters: Union[_models.ScopedDeployment, IO], **kwargs: Any + ) -> AsyncLROPoller[_models.DeploymentExtended]: + """Deploys resources at management group scope. + + You can provide the template and parameters directly in the request or link to JSON files. + + :param group_id: The management group ID. Required. + :type group_id: str + :param deployment_name: The name of the deployment. Required. + :type deployment_name: str + :param parameters: Additional parameters supplied to the operation. Is either a model type or a + IO type. Required. + :type parameters: ~azure.mgmt.resource.resources.v2020_06_01.models.ScopedDeployment or IO + :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. + Default value is None. + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be AsyncARMPolling. Pass in False for + this operation to not poll, or pass in your own initialized polling object for a personal + polling strategy. + :paramtype polling: bool or ~azure.core.polling.AsyncPollingMethod + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of AsyncLROPoller that returns either DeploymentExtended or the result of + cls(response) + :rtype: + ~azure.core.polling.AsyncLROPoller[~azure.mgmt.resource.resources.v2020_06_01.models.DeploymentExtended] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _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", "2020-06-01")) # type: str + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.DeploymentExtended] + polling = kwargs.pop("polling", True) # type: Union[bool, AsyncPollingMethod] + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token = kwargs.pop("continuation_token", None) # type: Optional[str] if cont_token is None: - raw_result = await self._create_or_update_at_management_group_scope_initial( + raw_result = await self._create_or_update_at_management_group_scope_initial( # type: ignore group_id=group_id, deployment_name=deployment_name, parameters=parameters, api_version=api_version, content_type=content_type, - cls=lambda x,y,z: x, + cls=lambda x, y, z: x, + headers=_headers, + params=_params, **kwargs ) - kwargs.pop('error_map', None) + kwargs.pop("error_map", None) def get_long_running_output(pipeline_response): - response = pipeline_response.http_response - deserialized = self._deserialize('DeploymentExtended', pipeline_response) + deserialized = self._deserialize("DeploymentExtended", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - - if polling is True: polling_method = AsyncARMPolling(lro_delay, **kwargs) - elif polling is False: polling_method = AsyncNoPolling() - else: polling_method = polling + if polling is True: + polling_method = cast(AsyncPollingMethod, AsyncARMPolling(lro_delay, **kwargs)) # type: AsyncPollingMethod + elif polling is False: + polling_method = cast(AsyncPollingMethod, AsyncNoPolling()) + else: + polling_method = polling if cont_token: return AsyncLROPoller.from_continuation_token( polling_method=polling_method, continuation_token=cont_token, client=self._client, - deserialization_callback=get_long_running_output + deserialization_callback=get_long_running_output, ) return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) - begin_create_or_update_at_management_group_scope.metadata = {'url': "/providers/Microsoft.Management/managementGroups/{groupId}/providers/Microsoft.Resources/deployments/{deploymentName}"} # type: ignore + begin_create_or_update_at_management_group_scope.metadata = {"url": "/providers/Microsoft.Management/managementGroups/{groupId}/providers/Microsoft.Resources/deployments/{deploymentName}"} # type: ignore @distributed_trace_async async def get_at_management_group_scope( - self, - group_id: str, - deployment_name: str, - **kwargs: Any - ) -> "_models.DeploymentExtended": + self, group_id: str, deployment_name: str, **kwargs: Any + ) -> _models.DeploymentExtended: """Gets a deployment. - :param group_id: The management group ID. + :param group_id: The management group ID. Required. :type group_id: str - :param deployment_name: The name of the deployment. + :param deployment_name: The name of the deployment. Required. :type deployment_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: DeploymentExtended, or the result of cls(response) + :return: DeploymentExtended or the result of cls(response) :rtype: ~azure.mgmt.resource.resources.v2020_06_01.models.DeploymentExtended - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.DeploymentExtended"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + 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', "2020-06-01") # type: str + api_version = kwargs.pop("api_version", _params.pop("api-version", "2020-06-01")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[_models.DeploymentExtended] - request = build_deployments_get_at_management_group_scope_request( group_id=group_id, deployment_name=deployment_name, api_version=api_version, - template_url=self.get_at_management_group_scope.metadata['url'], + template_url=self.get_at_management_group_scope.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) - deserialized = self._deserialize('DeploymentExtended', pipeline_response) + deserialized = self._deserialize("DeploymentExtended", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - get_at_management_group_scope.metadata = {'url': "/providers/Microsoft.Management/managementGroups/{groupId}/providers/Microsoft.Resources/deployments/{deploymentName}"} # type: ignore - + get_at_management_group_scope.metadata = {"url": "/providers/Microsoft.Management/managementGroups/{groupId}/providers/Microsoft.Resources/deployments/{deploymentName}"} # type: ignore @distributed_trace_async async def cancel_at_management_group_scope( # pylint: disable=inconsistent-return-statements - self, - group_id: str, - deployment_name: str, - **kwargs: Any + self, group_id: str, deployment_name: str, **kwargs: Any ) -> None: """Cancels a currently running template deployment. @@ -1949,38 +2563,44 @@ async def cancel_at_management_group_scope( # pylint: disable=inconsistent-retu deployment stops the currently running template deployment and leaves the resources partially deployed. - :param group_id: The management group ID. + :param group_id: The management group ID. Required. :type group_id: str - :param deployment_name: The name of the deployment. + :param deployment_name: The name of the deployment. Required. :type deployment_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: None, or the result of cls(response) + :return: None or the result of cls(response) :rtype: None - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType[None] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) - api_version = kwargs.pop('api_version', "2020-06-01") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2020-06-01")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[None] - request = build_deployments_cancel_at_management_group_scope_request( group_id=group_id, deployment_name=deployment_name, api_version=api_version, - template_url=self.cancel_at_management_group_scope.metadata['url'], + template_url=self.cancel_at_management_group_scope.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [204]: @@ -1990,43 +2610,52 @@ async def cancel_at_management_group_scope( # pylint: disable=inconsistent-retu if cls: return cls(pipeline_response, None, {}) - cancel_at_management_group_scope.metadata = {'url': "/providers/Microsoft.Management/managementGroups/{groupId}/providers/Microsoft.Resources/deployments/{deploymentName}/cancel"} # type: ignore - + cancel_at_management_group_scope.metadata = {"url": "/providers/Microsoft.Management/managementGroups/{groupId}/providers/Microsoft.Resources/deployments/{deploymentName}/cancel"} # type: ignore async def _validate_at_management_group_scope_initial( - self, - group_id: str, - deployment_name: str, - parameters: "_models.ScopedDeployment", - **kwargs: Any - ) -> Optional["_models.DeploymentValidateResult"]: - cls = kwargs.pop('cls', None) # type: ClsType[Optional["_models.DeploymentValidateResult"]] + self, group_id: str, deployment_name: str, parameters: Union[_models.ScopedDeployment, IO], **kwargs: Any + ) -> Optional[_models.DeploymentValidateResult]: error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', "2020-06-01") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + api_version = kwargs.pop("api_version", _params.pop("api-version", "2020-06-01")) # type: str + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[Optional[_models.DeploymentValidateResult]] - _json = self._serialize.body(parameters, 'ScopedDeployment') + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(parameters, (IO, bytes)): + _content = parameters + else: + _json = self._serialize.body(parameters, "ScopedDeployment") - request = build_deployments_validate_at_management_group_scope_request_initial( + request = build_deployments_validate_at_management_group_scope_request( group_id=group_id, deployment_name=deployment_name, api_version=api_version, content_type=content_type, json=_json, - template_url=self._validate_at_management_group_scope_initial.metadata['url'], + content=_content, + template_url=self._validate_at_management_group_scope_initial.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200, 202, 400]: @@ -2035,36 +2664,40 @@ async def _validate_at_management_group_scope_initial( deserialized = None if response.status_code == 200: - deserialized = self._deserialize('DeploymentValidateResult', pipeline_response) + deserialized = self._deserialize("DeploymentValidateResult", pipeline_response) if response.status_code == 400: - deserialized = self._deserialize('DeploymentValidateResult', pipeline_response) + deserialized = self._deserialize("DeploymentValidateResult", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - _validate_at_management_group_scope_initial.metadata = {'url': "/providers/Microsoft.Management/managementGroups/{groupId}/providers/Microsoft.Resources/deployments/{deploymentName}/validate"} # type: ignore - + _validate_at_management_group_scope_initial.metadata = {"url": "/providers/Microsoft.Management/managementGroups/{groupId}/providers/Microsoft.Resources/deployments/{deploymentName}/validate"} # type: ignore - @distributed_trace_async + @overload async def begin_validate_at_management_group_scope( self, group_id: str, deployment_name: str, - parameters: "_models.ScopedDeployment", + parameters: _models.ScopedDeployment, + *, + content_type: str = "application/json", **kwargs: Any - ) -> AsyncLROPoller["_models.DeploymentValidateResult"]: + ) -> AsyncLROPoller[_models.DeploymentValidateResult]: """Validates whether the specified template is syntactically correct and will be accepted by Azure Resource Manager.. - :param group_id: The management group ID. + :param group_id: The management group ID. Required. :type group_id: str - :param deployment_name: The name of the deployment. + :param deployment_name: The name of the deployment. Required. :type deployment_name: str - :param parameters: Parameters to validate. + :param parameters: Parameters to validate. Required. :type parameters: ~azure.mgmt.resource.resources.v2020_06_01.models.ScopedDeployment + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str :keyword callable cls: A custom type or function that will be passed the direct response :keyword str continuation_token: A continuation token to restart a poller from a saved state. :keyword polling: By default, your polling method will be AsyncARMPolling. Pass in False for @@ -2077,85 +2710,166 @@ async def begin_validate_at_management_group_scope( result of cls(response) :rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.resource.resources.v2020_06_01.models.DeploymentValidateResult] - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - api_version = kwargs.pop('api_version', "2020-06-01") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] - polling = kwargs.pop('polling', True) # type: Union[bool, AsyncPollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType["_models.DeploymentValidateResult"] - lro_delay = kwargs.pop( - 'polling_interval', - self._config.polling_interval - ) - cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] - if cont_token is None: - raw_result = await self._validate_at_management_group_scope_initial( - group_id=group_id, - deployment_name=deployment_name, - parameters=parameters, - api_version=api_version, - content_type=content_type, - cls=lambda x,y,z: x, - **kwargs - ) - kwargs.pop('error_map', None) - - def get_long_running_output(pipeline_response): - response = pipeline_response.http_response - deserialized = self._deserialize('DeploymentValidateResult', pipeline_response) - if cls: - return cls(pipeline_response, deserialized, {}) - return deserialized - - if polling is True: polling_method = AsyncARMPolling(lro_delay, **kwargs) - elif polling is False: polling_method = AsyncNoPolling() - else: polling_method = polling - if cont_token: - return AsyncLROPoller.from_continuation_token( - polling_method=polling_method, + @overload + async def begin_validate_at_management_group_scope( + self, + group_id: str, + deployment_name: str, + parameters: IO, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> AsyncLROPoller[_models.DeploymentValidateResult]: + """Validates whether the specified template is syntactically correct and will be accepted by Azure + Resource Manager.. + + :param group_id: The management group ID. Required. + :type group_id: str + :param deployment_name: The name of the deployment. Required. + :type deployment_name: str + :param parameters: Parameters to validate. Required. + :type parameters: IO + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be AsyncARMPolling. Pass in False for + this operation to not poll, or pass in your own initialized polling object for a personal + polling strategy. + :paramtype polling: bool or ~azure.core.polling.AsyncPollingMethod + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of AsyncLROPoller that returns either DeploymentValidateResult or the + result of cls(response) + :rtype: + ~azure.core.polling.AsyncLROPoller[~azure.mgmt.resource.resources.v2020_06_01.models.DeploymentValidateResult] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace_async + async def begin_validate_at_management_group_scope( + self, group_id: str, deployment_name: str, parameters: Union[_models.ScopedDeployment, IO], **kwargs: Any + ) -> AsyncLROPoller[_models.DeploymentValidateResult]: + """Validates whether the specified template is syntactically correct and will be accepted by Azure + Resource Manager.. + + :param group_id: The management group ID. Required. + :type group_id: str + :param deployment_name: The name of the deployment. Required. + :type deployment_name: str + :param parameters: Parameters to validate. Is either a model type or a IO type. Required. + :type parameters: ~azure.mgmt.resource.resources.v2020_06_01.models.ScopedDeployment or IO + :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. + Default value is None. + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be AsyncARMPolling. Pass in False for + this operation to not poll, or pass in your own initialized polling object for a personal + polling strategy. + :paramtype polling: bool or ~azure.core.polling.AsyncPollingMethod + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of AsyncLROPoller that returns either DeploymentValidateResult or the + result of cls(response) + :rtype: + ~azure.core.polling.AsyncLROPoller[~azure.mgmt.resource.resources.v2020_06_01.models.DeploymentValidateResult] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _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", "2020-06-01")) # type: str + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.DeploymentValidateResult] + polling = kwargs.pop("polling", True) # type: Union[bool, AsyncPollingMethod] + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token = kwargs.pop("continuation_token", None) # type: Optional[str] + if cont_token is None: + raw_result = await self._validate_at_management_group_scope_initial( # type: ignore + group_id=group_id, + deployment_name=deployment_name, + parameters=parameters, + api_version=api_version, + content_type=content_type, + cls=lambda x, y, z: x, + headers=_headers, + params=_params, + **kwargs + ) + kwargs.pop("error_map", None) + + def get_long_running_output(pipeline_response): + deserialized = self._deserialize("DeploymentValidateResult", pipeline_response) + if cls: + return cls(pipeline_response, deserialized, {}) + return deserialized + + if polling is True: + polling_method = cast(AsyncPollingMethod, AsyncARMPolling(lro_delay, **kwargs)) # type: AsyncPollingMethod + elif polling is False: + polling_method = cast(AsyncPollingMethod, AsyncNoPolling()) + else: + polling_method = polling + if cont_token: + return AsyncLROPoller.from_continuation_token( + polling_method=polling_method, continuation_token=cont_token, client=self._client, - deserialization_callback=get_long_running_output + deserialization_callback=get_long_running_output, ) return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) - begin_validate_at_management_group_scope.metadata = {'url': "/providers/Microsoft.Management/managementGroups/{groupId}/providers/Microsoft.Resources/deployments/{deploymentName}/validate"} # type: ignore + begin_validate_at_management_group_scope.metadata = {"url": "/providers/Microsoft.Management/managementGroups/{groupId}/providers/Microsoft.Resources/deployments/{deploymentName}/validate"} # type: ignore async def _what_if_at_management_group_scope_initial( - self, - group_id: str, - deployment_name: str, - parameters: "_models.ScopedDeploymentWhatIf", - **kwargs: Any - ) -> Optional["_models.WhatIfOperationResult"]: - cls = kwargs.pop('cls', None) # type: ClsType[Optional["_models.WhatIfOperationResult"]] + self, group_id: str, deployment_name: str, parameters: Union[_models.ScopedDeploymentWhatIf, IO], **kwargs: Any + ) -> Optional[_models.WhatIfOperationResult]: error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) - api_version = kwargs.pop('api_version', "2020-06-01") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - _json = self._serialize.body(parameters, 'ScopedDeploymentWhatIf') + api_version = kwargs.pop("api_version", _params.pop("api-version", "2020-06-01")) # type: str + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[Optional[_models.WhatIfOperationResult]] - request = build_deployments_what_if_at_management_group_scope_request_initial( + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(parameters, (IO, bytes)): + _content = parameters + else: + _json = self._serialize.body(parameters, "ScopedDeploymentWhatIf") + + request = build_deployments_what_if_at_management_group_scope_request( group_id=group_id, deployment_name=deployment_name, api_version=api_version, content_type=content_type, json=_json, - template_url=self._what_if_at_management_group_scope_initial.metadata['url'], + content=_content, + template_url=self._what_if_at_management_group_scope_initial.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200, 202]: @@ -2165,38 +2879,41 @@ async def _what_if_at_management_group_scope_initial( deserialized = None response_headers = {} if response.status_code == 200: - deserialized = self._deserialize('WhatIfOperationResult', pipeline_response) + deserialized = self._deserialize("WhatIfOperationResult", pipeline_response) if response.status_code == 202: - response_headers['Location']=self._deserialize('str', response.headers.get('Location')) - response_headers['Retry-After']=self._deserialize('str', response.headers.get('Retry-After')) - + response_headers["Location"] = self._deserialize("str", response.headers.get("Location")) + response_headers["Retry-After"] = self._deserialize("str", response.headers.get("Retry-After")) if cls: return cls(pipeline_response, deserialized, response_headers) return deserialized - _what_if_at_management_group_scope_initial.metadata = {'url': "/providers/Microsoft.Management/managementGroups/{groupId}/providers/Microsoft.Resources/deployments/{deploymentName}/whatIf"} # type: ignore + _what_if_at_management_group_scope_initial.metadata = {"url": "/providers/Microsoft.Management/managementGroups/{groupId}/providers/Microsoft.Resources/deployments/{deploymentName}/whatIf"} # type: ignore - - @distributed_trace_async + @overload async def begin_what_if_at_management_group_scope( self, group_id: str, deployment_name: str, - parameters: "_models.ScopedDeploymentWhatIf", + parameters: _models.ScopedDeploymentWhatIf, + *, + content_type: str = "application/json", **kwargs: Any - ) -> AsyncLROPoller["_models.WhatIfOperationResult"]: + ) -> AsyncLROPoller[_models.WhatIfOperationResult]: """Returns changes that will be made by the deployment if executed at the scope of the management group. - :param group_id: The management group ID. + :param group_id: The management group ID. Required. :type group_id: str - :param deployment_name: The name of the deployment. + :param deployment_name: The name of the deployment. Required. :type deployment_name: str - :param parameters: Parameters to validate. + :param parameters: Parameters to validate. Required. :type parameters: ~azure.mgmt.resource.resources.v2020_06_01.models.ScopedDeploymentWhatIf + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str :keyword callable cls: A custom type or function that will be passed the direct response :keyword str continuation_token: A continuation token to restart a poller from a saved state. :keyword polling: By default, your polling method will be AsyncARMPolling. Pass in False for @@ -2209,119 +2926,191 @@ async def begin_what_if_at_management_group_scope( of cls(response) :rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.resource.resources.v2020_06_01.models.WhatIfOperationResult] - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - api_version = kwargs.pop('api_version', "2020-06-01") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] - polling = kwargs.pop('polling', True) # type: Union[bool, AsyncPollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType["_models.WhatIfOperationResult"] - lro_delay = kwargs.pop( - 'polling_interval', - self._config.polling_interval - ) - cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] + + @overload + async def begin_what_if_at_management_group_scope( + self, + group_id: str, + deployment_name: str, + parameters: IO, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> AsyncLROPoller[_models.WhatIfOperationResult]: + """Returns changes that will be made by the deployment if executed at the scope of the management + group. + + :param group_id: The management group ID. Required. + :type group_id: str + :param deployment_name: The name of the deployment. Required. + :type deployment_name: str + :param parameters: Parameters to validate. Required. + :type parameters: IO + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be AsyncARMPolling. Pass in False for + this operation to not poll, or pass in your own initialized polling object for a personal + polling strategy. + :paramtype polling: bool or ~azure.core.polling.AsyncPollingMethod + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of AsyncLROPoller that returns either WhatIfOperationResult or the result + of cls(response) + :rtype: + ~azure.core.polling.AsyncLROPoller[~azure.mgmt.resource.resources.v2020_06_01.models.WhatIfOperationResult] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace_async + async def begin_what_if_at_management_group_scope( + self, group_id: str, deployment_name: str, parameters: Union[_models.ScopedDeploymentWhatIf, IO], **kwargs: Any + ) -> AsyncLROPoller[_models.WhatIfOperationResult]: + """Returns changes that will be made by the deployment if executed at the scope of the management + group. + + :param group_id: The management group ID. Required. + :type group_id: str + :param deployment_name: The name of the deployment. Required. + :type deployment_name: str + :param parameters: Parameters to validate. Is either a model type or a IO type. Required. + :type parameters: ~azure.mgmt.resource.resources.v2020_06_01.models.ScopedDeploymentWhatIf or + IO + :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. + Default value is None. + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be AsyncARMPolling. Pass in False for + this operation to not poll, or pass in your own initialized polling object for a personal + polling strategy. + :paramtype polling: bool or ~azure.core.polling.AsyncPollingMethod + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of AsyncLROPoller that returns either WhatIfOperationResult or the result + of cls(response) + :rtype: + ~azure.core.polling.AsyncLROPoller[~azure.mgmt.resource.resources.v2020_06_01.models.WhatIfOperationResult] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _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", "2020-06-01")) # type: str + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.WhatIfOperationResult] + polling = kwargs.pop("polling", True) # type: Union[bool, AsyncPollingMethod] + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token = kwargs.pop("continuation_token", None) # type: Optional[str] if cont_token is None: - raw_result = await self._what_if_at_management_group_scope_initial( + raw_result = await self._what_if_at_management_group_scope_initial( # type: ignore group_id=group_id, deployment_name=deployment_name, parameters=parameters, api_version=api_version, content_type=content_type, - cls=lambda x,y,z: x, + cls=lambda x, y, z: x, + headers=_headers, + params=_params, **kwargs ) - kwargs.pop('error_map', None) + kwargs.pop("error_map", None) def get_long_running_output(pipeline_response): - response = pipeline_response.http_response - deserialized = self._deserialize('WhatIfOperationResult', pipeline_response) + deserialized = self._deserialize("WhatIfOperationResult", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - - if polling is True: polling_method = AsyncARMPolling(lro_delay, lro_options={'final-state-via': 'location'}, **kwargs) - elif polling is False: polling_method = AsyncNoPolling() - else: polling_method = polling + if polling is True: + polling_method = cast( + AsyncPollingMethod, AsyncARMPolling(lro_delay, lro_options={"final-state-via": "location"}, **kwargs) + ) # type: AsyncPollingMethod + elif polling is False: + polling_method = cast(AsyncPollingMethod, AsyncNoPolling()) + else: + polling_method = polling if cont_token: return AsyncLROPoller.from_continuation_token( polling_method=polling_method, continuation_token=cont_token, client=self._client, - deserialization_callback=get_long_running_output + deserialization_callback=get_long_running_output, ) return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) - begin_what_if_at_management_group_scope.metadata = {'url': "/providers/Microsoft.Management/managementGroups/{groupId}/providers/Microsoft.Resources/deployments/{deploymentName}/whatIf"} # type: ignore + begin_what_if_at_management_group_scope.metadata = {"url": "/providers/Microsoft.Management/managementGroups/{groupId}/providers/Microsoft.Resources/deployments/{deploymentName}/whatIf"} # type: ignore @distributed_trace_async async def export_template_at_management_group_scope( - self, - group_id: str, - deployment_name: str, - **kwargs: Any - ) -> "_models.DeploymentExportResult": + self, group_id: str, deployment_name: str, **kwargs: Any + ) -> _models.DeploymentExportResult: """Exports the template used for specified deployment. - :param group_id: The management group ID. + :param group_id: The management group ID. Required. :type group_id: str - :param deployment_name: The name of the deployment. + :param deployment_name: The name of the deployment. Required. :type deployment_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: DeploymentExportResult, or the result of cls(response) + :return: DeploymentExportResult or the result of cls(response) :rtype: ~azure.mgmt.resource.resources.v2020_06_01.models.DeploymentExportResult - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.DeploymentExportResult"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + 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', "2020-06-01") # type: str + api_version = kwargs.pop("api_version", _params.pop("api-version", "2020-06-01")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[_models.DeploymentExportResult] - request = build_deployments_export_template_at_management_group_scope_request( group_id=group_id, deployment_name=deployment_name, api_version=api_version, - template_url=self.export_template_at_management_group_scope.metadata['url'], + template_url=self.export_template_at_management_group_scope.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) - deserialized = self._deserialize('DeploymentExportResult', pipeline_response) + deserialized = self._deserialize("DeploymentExportResult", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - export_template_at_management_group_scope.metadata = {'url': "/providers/Microsoft.Management/managementGroups/{groupId}/providers/Microsoft.Resources/deployments/{deploymentName}/exportTemplate"} # type: ignore - + export_template_at_management_group_scope.metadata = {"url": "/providers/Microsoft.Management/managementGroups/{groupId}/providers/Microsoft.Resources/deployments/{deploymentName}/exportTemplate"} # type: ignore @distributed_trace def list_at_management_group_scope( - self, - group_id: str, - filter: Optional[str] = None, - top: Optional[int] = None, - **kwargs: Any - ) -> AsyncIterable["_models.DeploymentListResult"]: + self, group_id: str, filter: Optional[str] = None, top: Optional[int] = None, **kwargs: Any + ) -> AsyncIterable["_models.DeploymentExtended"]: """Get all the deployments for a management group. - :param group_id: The management group ID. + :param group_id: The management group ID. Required. :type group_id: str :param filter: The filter to apply on the operation. For example, you can use $filter=provisioningState eq '{state}'. Default value is None. @@ -2330,40 +3119,48 @@ def list_at_management_group_scope( value is None. :type top: int :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either DeploymentListResult or the result of - cls(response) + :return: An iterator like instance of either DeploymentExtended or the result of cls(response) :rtype: - ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.resource.resources.v2020_06_01.models.DeploymentListResult] - :raises: ~azure.core.exceptions.HttpResponseError + ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.resource.resources.v2020_06_01.models.DeploymentExtended] + :raises ~azure.core.exceptions.HttpResponseError: """ - api_version = kwargs.pop('api_version', "2020-06-01") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2020-06-01")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[_models.DeploymentListResult] - cls = kwargs.pop('cls', None) # type: ClsType["_models.DeploymentListResult"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) + def prepare_request(next_link=None): if not next_link: - + request = build_deployments_list_at_management_group_scope_request( group_id=group_id, - api_version=api_version, filter=filter, top=top, - template_url=self.list_at_management_group_scope.metadata['url'], + api_version=api_version, + template_url=self.list_at_management_group_scope.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore else: - - request = build_deployments_list_at_management_group_scope_request( - group_id=group_id, - template_url=next_link, - ) + # make call to next link with the client's api-version + _parsed_next_link = urlparse(next_link) + _next_request_params = case_insensitive_dict(parse_qs(_parsed_next_link.query)) + _next_request_params["api-version"] = self._config.api_version + request = HttpRequest("GET", urljoin(next_link, _parsed_next_link.path), params=_next_request_params) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore request.method = "GET" return request @@ -2377,10 +3174,8 @@ async def extract_data(pipeline_response): async def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) response = pipeline_response.http_response @@ -2390,40 +3185,42 @@ async def get_next(next_link=None): return pipeline_response + return AsyncItemPaged(get_next, extract_data) - return AsyncItemPaged( - get_next, extract_data - ) - list_at_management_group_scope.metadata = {'url': "/providers/Microsoft.Management/managementGroups/{groupId}/providers/Microsoft.Resources/deployments/"} # type: ignore + list_at_management_group_scope.metadata = {"url": "/providers/Microsoft.Management/managementGroups/{groupId}/providers/Microsoft.Resources/deployments/"} # type: ignore async def _delete_at_subscription_scope_initial( # pylint: disable=inconsistent-return-statements - self, - deployment_name: str, - **kwargs: Any + self, deployment_name: str, **kwargs: Any ) -> None: - cls = kwargs.pop('cls', None) # type: ClsType[None] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + 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', "2020-06-01") # type: str + api_version = kwargs.pop("api_version", _params.pop("api-version", "2020-06-01")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[None] - - request = build_deployments_delete_at_subscription_scope_request_initial( + request = build_deployments_delete_at_subscription_scope_request( deployment_name=deployment_name, subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self._delete_at_subscription_scope_initial.metadata['url'], + template_url=self._delete_at_subscription_scope_initial.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [202, 204]: @@ -2433,15 +3230,10 @@ async def _delete_at_subscription_scope_initial( # pylint: disable=inconsistent if cls: return cls(pipeline_response, None, {}) - _delete_at_subscription_scope_initial.metadata = {'url': "/subscriptions/{subscriptionId}/providers/Microsoft.Resources/deployments/{deploymentName}"} # type: ignore - + _delete_at_subscription_scope_initial.metadata = {"url": "/subscriptions/{subscriptionId}/providers/Microsoft.Resources/deployments/{deploymentName}"} # type: ignore @distributed_trace_async - async def begin_delete_at_subscription_scope( # pylint: disable=inconsistent-return-statements - self, - deployment_name: str, - **kwargs: Any - ) -> AsyncLROPoller[None]: + async def begin_delete_at_subscription_scope(self, deployment_name: str, **kwargs: Any) -> AsyncLROPoller[None]: """Deletes a deployment from the deployment history. A template deployment that is currently running cannot be deleted. Deleting a template @@ -2452,7 +3244,7 @@ async def begin_delete_at_subscription_scope( # pylint: disable=inconsistent-re process finishes, the URI in the Location header returns a status of 204 on success. If the asynchronous request failed, the URI in the Location header returns an error-level status code. - :param deployment_name: The name of the deployment. + :param deployment_name: The name of the deployment. Required. :type deployment_name: str :keyword callable cls: A custom type or function that will be passed the direct response :keyword str continuation_token: A continuation token to restart a poller from a saved state. @@ -2464,82 +3256,88 @@ async def begin_delete_at_subscription_scope( # pylint: disable=inconsistent-re Retry-After header is present. :return: An instance of AsyncLROPoller that returns either None or the result of cls(response) :rtype: ~azure.core.polling.AsyncLROPoller[None] - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - api_version = kwargs.pop('api_version', "2020-06-01") # type: str - polling = kwargs.pop('polling', True) # type: Union[bool, AsyncPollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType[None] - lro_delay = kwargs.pop( - 'polling_interval', - self._config.polling_interval - ) - cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2020-06-01")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[None] + polling = kwargs.pop("polling", True) # type: Union[bool, AsyncPollingMethod] + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token = kwargs.pop("continuation_token", None) # type: Optional[str] if cont_token is None: - raw_result = await self._delete_at_subscription_scope_initial( + raw_result = await self._delete_at_subscription_scope_initial( # type: ignore deployment_name=deployment_name, api_version=api_version, - cls=lambda x,y,z: x, + cls=lambda x, y, z: x, + headers=_headers, + params=_params, **kwargs ) - kwargs.pop('error_map', None) + kwargs.pop("error_map", None) - def get_long_running_output(pipeline_response): + def get_long_running_output(pipeline_response): # pylint: disable=inconsistent-return-statements if cls: return cls(pipeline_response, None, {}) - - if polling is True: polling_method = AsyncARMPolling(lro_delay, **kwargs) - elif polling is False: polling_method = AsyncNoPolling() - else: polling_method = polling + if polling is True: + polling_method = cast(AsyncPollingMethod, AsyncARMPolling(lro_delay, **kwargs)) # type: AsyncPollingMethod + elif polling is False: + polling_method = cast(AsyncPollingMethod, AsyncNoPolling()) + else: + polling_method = polling if cont_token: return AsyncLROPoller.from_continuation_token( polling_method=polling_method, continuation_token=cont_token, client=self._client, - deserialization_callback=get_long_running_output + deserialization_callback=get_long_running_output, ) return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) - begin_delete_at_subscription_scope.metadata = {'url': "/subscriptions/{subscriptionId}/providers/Microsoft.Resources/deployments/{deploymentName}"} # type: ignore + begin_delete_at_subscription_scope.metadata = {"url": "/subscriptions/{subscriptionId}/providers/Microsoft.Resources/deployments/{deploymentName}"} # type: ignore @distributed_trace_async - async def check_existence_at_subscription_scope( - self, - deployment_name: str, - **kwargs: Any - ) -> bool: + async def check_existence_at_subscription_scope(self, deployment_name: str, **kwargs: Any) -> bool: """Checks whether the deployment exists. - :param deployment_name: The name of the deployment. + :param deployment_name: The name of the deployment. Required. :type deployment_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: bool, or the result of cls(response) + :return: bool or the result of cls(response) :rtype: bool - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType[None] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + 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', "2020-06-01") # type: str + api_version = kwargs.pop("api_version", _params.pop("api-version", "2020-06-01")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[None] - request = build_deployments_check_existence_at_subscription_scope_request( deployment_name=deployment_name, subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.check_existence_at_subscription_scope.metadata['url'], + template_url=self.check_existence_at_subscription_scope.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [204, 404]: @@ -2550,42 +3348,52 @@ async def check_existence_at_subscription_scope( return cls(pipeline_response, None, {}) return 200 <= response.status_code <= 299 - check_existence_at_subscription_scope.metadata = {'url': "/subscriptions/{subscriptionId}/providers/Microsoft.Resources/deployments/{deploymentName}"} # type: ignore - + check_existence_at_subscription_scope.metadata = {"url": "/subscriptions/{subscriptionId}/providers/Microsoft.Resources/deployments/{deploymentName}"} # type: ignore async def _create_or_update_at_subscription_scope_initial( - self, - deployment_name: str, - parameters: "_models.Deployment", - **kwargs: Any - ) -> "_models.DeploymentExtended": - cls = kwargs.pop('cls', None) # type: ClsType["_models.DeploymentExtended"] + self, deployment_name: str, parameters: Union[_models.Deployment, IO], **kwargs: Any + ) -> _models.DeploymentExtended: error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', "2020-06-01") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + api_version = kwargs.pop("api_version", _params.pop("api-version", "2020-06-01")) # type: str + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.DeploymentExtended] - _json = self._serialize.body(parameters, 'Deployment') + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(parameters, (IO, bytes)): + _content = parameters + else: + _json = self._serialize.body(parameters, "Deployment") - request = build_deployments_create_or_update_at_subscription_scope_request_initial( + request = build_deployments_create_or_update_at_subscription_scope_request( deployment_name=deployment_name, subscription_id=self._config.subscription_id, api_version=api_version, content_type=content_type, json=_json, - template_url=self._create_or_update_at_subscription_scope_initial.metadata['url'], + content=_content, + template_url=self._create_or_update_at_subscription_scope_initial.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200, 201]: @@ -2593,34 +3401,38 @@ async def _create_or_update_at_subscription_scope_initial( raise HttpResponseError(response=response, error_format=ARMErrorFormat) if response.status_code == 200: - deserialized = self._deserialize('DeploymentExtended', pipeline_response) + deserialized = self._deserialize("DeploymentExtended", pipeline_response) if response.status_code == 201: - deserialized = self._deserialize('DeploymentExtended', pipeline_response) + deserialized = self._deserialize("DeploymentExtended", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - _create_or_update_at_subscription_scope_initial.metadata = {'url': "/subscriptions/{subscriptionId}/providers/Microsoft.Resources/deployments/{deploymentName}"} # type: ignore - + _create_or_update_at_subscription_scope_initial.metadata = {"url": "/subscriptions/{subscriptionId}/providers/Microsoft.Resources/deployments/{deploymentName}"} # type: ignore - @distributed_trace_async + @overload async def begin_create_or_update_at_subscription_scope( self, deployment_name: str, - parameters: "_models.Deployment", + parameters: _models.Deployment, + *, + content_type: str = "application/json", **kwargs: Any - ) -> AsyncLROPoller["_models.DeploymentExtended"]: + ) -> AsyncLROPoller[_models.DeploymentExtended]: """Deploys resources at subscription scope. You can provide the template and parameters directly in the request or link to JSON files. - :param deployment_name: The name of the deployment. + :param deployment_name: The name of the deployment. Required. :type deployment_name: str - :param parameters: Additional parameters supplied to the operation. + :param parameters: Additional parameters supplied to the operation. Required. :type parameters: ~azure.mgmt.resource.resources.v2020_06_01.models.Deployment + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str :keyword callable cls: A custom type or function that will be passed the direct response :keyword str continuation_token: A continuation token to restart a poller from a saved state. :keyword polling: By default, your polling method will be AsyncARMPolling. Pass in False for @@ -2633,109 +3445,172 @@ async def begin_create_or_update_at_subscription_scope( cls(response) :rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.resource.resources.v2020_06_01.models.DeploymentExtended] - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - api_version = kwargs.pop('api_version', "2020-06-01") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] - polling = kwargs.pop('polling', True) # type: Union[bool, AsyncPollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType["_models.DeploymentExtended"] - lro_delay = kwargs.pop( - 'polling_interval', - self._config.polling_interval - ) - cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] + + @overload + async def begin_create_or_update_at_subscription_scope( + self, deployment_name: str, parameters: IO, *, content_type: str = "application/json", **kwargs: Any + ) -> AsyncLROPoller[_models.DeploymentExtended]: + """Deploys resources at subscription scope. + + You can provide the template and parameters directly in the request or link to JSON files. + + :param deployment_name: The name of the deployment. Required. + :type deployment_name: str + :param parameters: Additional parameters supplied to the operation. Required. + :type parameters: IO + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be AsyncARMPolling. Pass in False for + this operation to not poll, or pass in your own initialized polling object for a personal + polling strategy. + :paramtype polling: bool or ~azure.core.polling.AsyncPollingMethod + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of AsyncLROPoller that returns either DeploymentExtended or the result of + cls(response) + :rtype: + ~azure.core.polling.AsyncLROPoller[~azure.mgmt.resource.resources.v2020_06_01.models.DeploymentExtended] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace_async + async def begin_create_or_update_at_subscription_scope( + self, deployment_name: str, parameters: Union[_models.Deployment, IO], **kwargs: Any + ) -> AsyncLROPoller[_models.DeploymentExtended]: + """Deploys resources at subscription scope. + + You can provide the template and parameters directly in the request or link to JSON files. + + :param deployment_name: The name of the deployment. Required. + :type deployment_name: str + :param parameters: Additional parameters supplied to the operation. Is either a model type or a + IO type. Required. + :type parameters: ~azure.mgmt.resource.resources.v2020_06_01.models.Deployment or IO + :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. + Default value is None. + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be AsyncARMPolling. Pass in False for + this operation to not poll, or pass in your own initialized polling object for a personal + polling strategy. + :paramtype polling: bool or ~azure.core.polling.AsyncPollingMethod + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of AsyncLROPoller that returns either DeploymentExtended or the result of + cls(response) + :rtype: + ~azure.core.polling.AsyncLROPoller[~azure.mgmt.resource.resources.v2020_06_01.models.DeploymentExtended] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _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", "2020-06-01")) # type: str + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.DeploymentExtended] + polling = kwargs.pop("polling", True) # type: Union[bool, AsyncPollingMethod] + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token = kwargs.pop("continuation_token", None) # type: Optional[str] if cont_token is None: - raw_result = await self._create_or_update_at_subscription_scope_initial( + raw_result = await self._create_or_update_at_subscription_scope_initial( # type: ignore deployment_name=deployment_name, parameters=parameters, api_version=api_version, content_type=content_type, - cls=lambda x,y,z: x, + cls=lambda x, y, z: x, + headers=_headers, + params=_params, **kwargs ) - kwargs.pop('error_map', None) + kwargs.pop("error_map", None) def get_long_running_output(pipeline_response): - response = pipeline_response.http_response - deserialized = self._deserialize('DeploymentExtended', pipeline_response) + deserialized = self._deserialize("DeploymentExtended", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - - if polling is True: polling_method = AsyncARMPolling(lro_delay, **kwargs) - elif polling is False: polling_method = AsyncNoPolling() - else: polling_method = polling + if polling is True: + polling_method = cast(AsyncPollingMethod, AsyncARMPolling(lro_delay, **kwargs)) # type: AsyncPollingMethod + elif polling is False: + polling_method = cast(AsyncPollingMethod, AsyncNoPolling()) + else: + polling_method = polling if cont_token: return AsyncLROPoller.from_continuation_token( polling_method=polling_method, continuation_token=cont_token, client=self._client, - deserialization_callback=get_long_running_output + deserialization_callback=get_long_running_output, ) return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) - begin_create_or_update_at_subscription_scope.metadata = {'url': "/subscriptions/{subscriptionId}/providers/Microsoft.Resources/deployments/{deploymentName}"} # type: ignore + begin_create_or_update_at_subscription_scope.metadata = {"url": "/subscriptions/{subscriptionId}/providers/Microsoft.Resources/deployments/{deploymentName}"} # type: ignore @distributed_trace_async - async def get_at_subscription_scope( - self, - deployment_name: str, - **kwargs: Any - ) -> "_models.DeploymentExtended": + async def get_at_subscription_scope(self, deployment_name: str, **kwargs: Any) -> _models.DeploymentExtended: """Gets a deployment. - :param deployment_name: The name of the deployment. + :param deployment_name: The name of the deployment. Required. :type deployment_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: DeploymentExtended, or the result of cls(response) + :return: DeploymentExtended or the result of cls(response) :rtype: ~azure.mgmt.resource.resources.v2020_06_01.models.DeploymentExtended - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.DeploymentExtended"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) - api_version = kwargs.pop('api_version', "2020-06-01") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2020-06-01")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[_models.DeploymentExtended] - request = build_deployments_get_at_subscription_scope_request( deployment_name=deployment_name, subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.get_at_subscription_scope.metadata['url'], + template_url=self.get_at_subscription_scope.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) - deserialized = self._deserialize('DeploymentExtended', pipeline_response) + deserialized = self._deserialize("DeploymentExtended", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - get_at_subscription_scope.metadata = {'url': "/subscriptions/{subscriptionId}/providers/Microsoft.Resources/deployments/{deploymentName}"} # type: ignore - + get_at_subscription_scope.metadata = {"url": "/subscriptions/{subscriptionId}/providers/Microsoft.Resources/deployments/{deploymentName}"} # type: ignore @distributed_trace_async async def cancel_at_subscription_scope( # pylint: disable=inconsistent-return-statements - self, - deployment_name: str, - **kwargs: Any + self, deployment_name: str, **kwargs: Any ) -> None: """Cancels a currently running template deployment. @@ -2744,36 +3619,42 @@ async def cancel_at_subscription_scope( # pylint: disable=inconsistent-return-s deployment stops the currently running template deployment and leaves the resources partially deployed. - :param deployment_name: The name of the deployment. + :param deployment_name: The name of the deployment. Required. :type deployment_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: None, or the result of cls(response) + :return: None or the result of cls(response) :rtype: None - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType[None] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) - api_version = kwargs.pop('api_version', "2020-06-01") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2020-06-01")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[None] - request = build_deployments_cancel_at_subscription_scope_request( deployment_name=deployment_name, subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.cancel_at_subscription_scope.metadata['url'], + template_url=self.cancel_at_subscription_scope.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [204]: @@ -2783,42 +3664,52 @@ async def cancel_at_subscription_scope( # pylint: disable=inconsistent-return-s if cls: return cls(pipeline_response, None, {}) - cancel_at_subscription_scope.metadata = {'url': "/subscriptions/{subscriptionId}/providers/Microsoft.Resources/deployments/{deploymentName}/cancel"} # type: ignore - + cancel_at_subscription_scope.metadata = {"url": "/subscriptions/{subscriptionId}/providers/Microsoft.Resources/deployments/{deploymentName}/cancel"} # type: ignore async def _validate_at_subscription_scope_initial( - self, - deployment_name: str, - parameters: "_models.Deployment", - **kwargs: Any - ) -> Optional["_models.DeploymentValidateResult"]: - cls = kwargs.pop('cls', None) # type: ClsType[Optional["_models.DeploymentValidateResult"]] + self, deployment_name: str, parameters: Union[_models.Deployment, IO], **kwargs: Any + ) -> Optional[_models.DeploymentValidateResult]: error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) - api_version = kwargs.pop('api_version', "2020-06-01") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - _json = self._serialize.body(parameters, 'Deployment') + api_version = kwargs.pop("api_version", _params.pop("api-version", "2020-06-01")) # type: str + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[Optional[_models.DeploymentValidateResult]] - request = build_deployments_validate_at_subscription_scope_request_initial( + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(parameters, (IO, bytes)): + _content = parameters + else: + _json = self._serialize.body(parameters, "Deployment") + + request = build_deployments_validate_at_subscription_scope_request( deployment_name=deployment_name, subscription_id=self._config.subscription_id, api_version=api_version, content_type=content_type, json=_json, - template_url=self._validate_at_subscription_scope_initial.metadata['url'], + content=_content, + template_url=self._validate_at_subscription_scope_initial.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200, 202, 400]: @@ -2827,33 +3718,37 @@ async def _validate_at_subscription_scope_initial( deserialized = None if response.status_code == 200: - deserialized = self._deserialize('DeploymentValidateResult', pipeline_response) + deserialized = self._deserialize("DeploymentValidateResult", pipeline_response) if response.status_code == 400: - deserialized = self._deserialize('DeploymentValidateResult', pipeline_response) + deserialized = self._deserialize("DeploymentValidateResult", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - _validate_at_subscription_scope_initial.metadata = {'url': "/subscriptions/{subscriptionId}/providers/Microsoft.Resources/deployments/{deploymentName}/validate"} # type: ignore + _validate_at_subscription_scope_initial.metadata = {"url": "/subscriptions/{subscriptionId}/providers/Microsoft.Resources/deployments/{deploymentName}/validate"} # type: ignore - - @distributed_trace_async + @overload async def begin_validate_at_subscription_scope( self, deployment_name: str, - parameters: "_models.Deployment", + parameters: _models.Deployment, + *, + content_type: str = "application/json", **kwargs: Any - ) -> AsyncLROPoller["_models.DeploymentValidateResult"]: + ) -> AsyncLROPoller[_models.DeploymentValidateResult]: """Validates whether the specified template is syntactically correct and will be accepted by Azure Resource Manager.. - :param deployment_name: The name of the deployment. + :param deployment_name: The name of the deployment. Required. :type deployment_name: str - :param parameters: Parameters to validate. + :param parameters: Parameters to validate. Required. :type parameters: ~azure.mgmt.resource.resources.v2020_06_01.models.Deployment + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str :keyword callable cls: A custom type or function that will be passed the direct response :keyword str continuation_token: A continuation token to restart a poller from a saved state. :keyword polling: By default, your polling method will be AsyncARMPolling. Pass in False for @@ -2866,83 +3761,155 @@ async def begin_validate_at_subscription_scope( result of cls(response) :rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.resource.resources.v2020_06_01.models.DeploymentValidateResult] - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - api_version = kwargs.pop('api_version', "2020-06-01") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] - polling = kwargs.pop('polling', True) # type: Union[bool, AsyncPollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType["_models.DeploymentValidateResult"] - lro_delay = kwargs.pop( - 'polling_interval', - self._config.polling_interval - ) - cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] - if cont_token is None: - raw_result = await self._validate_at_subscription_scope_initial( - deployment_name=deployment_name, - parameters=parameters, - api_version=api_version, - content_type=content_type, - cls=lambda x,y,z: x, - **kwargs - ) - kwargs.pop('error_map', None) - - def get_long_running_output(pipeline_response): - response = pipeline_response.http_response - deserialized = self._deserialize('DeploymentValidateResult', pipeline_response) - if cls: - return cls(pipeline_response, deserialized, {}) - return deserialized + @overload + async def begin_validate_at_subscription_scope( + self, deployment_name: str, parameters: IO, *, content_type: str = "application/json", **kwargs: Any + ) -> AsyncLROPoller[_models.DeploymentValidateResult]: + """Validates whether the specified template is syntactically correct and will be accepted by Azure + Resource Manager.. - if polling is True: polling_method = AsyncARMPolling(lro_delay, **kwargs) - elif polling is False: polling_method = AsyncNoPolling() - else: polling_method = polling - if cont_token: - return AsyncLROPoller.from_continuation_token( - polling_method=polling_method, - continuation_token=cont_token, - client=self._client, - deserialization_callback=get_long_running_output + :param deployment_name: The name of the deployment. Required. + :type deployment_name: str + :param parameters: Parameters to validate. Required. + :type parameters: IO + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be AsyncARMPolling. Pass in False for + this operation to not poll, or pass in your own initialized polling object for a personal + polling strategy. + :paramtype polling: bool or ~azure.core.polling.AsyncPollingMethod + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of AsyncLROPoller that returns either DeploymentValidateResult or the + result of cls(response) + :rtype: + ~azure.core.polling.AsyncLROPoller[~azure.mgmt.resource.resources.v2020_06_01.models.DeploymentValidateResult] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace_async + async def begin_validate_at_subscription_scope( + self, deployment_name: str, parameters: Union[_models.Deployment, IO], **kwargs: Any + ) -> AsyncLROPoller[_models.DeploymentValidateResult]: + """Validates whether the specified template is syntactically correct and will be accepted by Azure + Resource Manager.. + + :param deployment_name: The name of the deployment. Required. + :type deployment_name: str + :param parameters: Parameters to validate. Is either a model type or a IO type. Required. + :type parameters: ~azure.mgmt.resource.resources.v2020_06_01.models.Deployment or IO + :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. + Default value is None. + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be AsyncARMPolling. Pass in False for + this operation to not poll, or pass in your own initialized polling object for a personal + polling strategy. + :paramtype polling: bool or ~azure.core.polling.AsyncPollingMethod + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of AsyncLROPoller that returns either DeploymentValidateResult or the + result of cls(response) + :rtype: + ~azure.core.polling.AsyncLROPoller[~azure.mgmt.resource.resources.v2020_06_01.models.DeploymentValidateResult] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _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", "2020-06-01")) # type: str + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.DeploymentValidateResult] + polling = kwargs.pop("polling", True) # type: Union[bool, AsyncPollingMethod] + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token = kwargs.pop("continuation_token", None) # type: Optional[str] + if cont_token is None: + raw_result = await self._validate_at_subscription_scope_initial( # type: ignore + deployment_name=deployment_name, + parameters=parameters, + api_version=api_version, + content_type=content_type, + cls=lambda x, y, z: x, + headers=_headers, + params=_params, + **kwargs + ) + kwargs.pop("error_map", None) + + def get_long_running_output(pipeline_response): + deserialized = self._deserialize("DeploymentValidateResult", pipeline_response) + if cls: + return cls(pipeline_response, deserialized, {}) + return deserialized + + if polling is True: + polling_method = cast(AsyncPollingMethod, AsyncARMPolling(lro_delay, **kwargs)) # type: AsyncPollingMethod + elif polling is False: + polling_method = cast(AsyncPollingMethod, AsyncNoPolling()) + else: + polling_method = polling + if cont_token: + return AsyncLROPoller.from_continuation_token( + polling_method=polling_method, + continuation_token=cont_token, + client=self._client, + deserialization_callback=get_long_running_output, ) return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) - begin_validate_at_subscription_scope.metadata = {'url': "/subscriptions/{subscriptionId}/providers/Microsoft.Resources/deployments/{deploymentName}/validate"} # type: ignore + begin_validate_at_subscription_scope.metadata = {"url": "/subscriptions/{subscriptionId}/providers/Microsoft.Resources/deployments/{deploymentName}/validate"} # type: ignore async def _what_if_at_subscription_scope_initial( - self, - deployment_name: str, - parameters: "_models.DeploymentWhatIf", - **kwargs: Any - ) -> Optional["_models.WhatIfOperationResult"]: - cls = kwargs.pop('cls', None) # type: ClsType[Optional["_models.WhatIfOperationResult"]] + self, deployment_name: str, parameters: Union[_models.DeploymentWhatIf, IO], **kwargs: Any + ) -> Optional[_models.WhatIfOperationResult]: error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) - api_version = kwargs.pop('api_version', "2020-06-01") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - _json = self._serialize.body(parameters, 'DeploymentWhatIf') + api_version = kwargs.pop("api_version", _params.pop("api-version", "2020-06-01")) # type: str + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[Optional[_models.WhatIfOperationResult]] - request = build_deployments_what_if_at_subscription_scope_request_initial( + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(parameters, (IO, bytes)): + _content = parameters + else: + _json = self._serialize.body(parameters, "DeploymentWhatIf") + + request = build_deployments_what_if_at_subscription_scope_request( deployment_name=deployment_name, subscription_id=self._config.subscription_id, api_version=api_version, content_type=content_type, json=_json, - template_url=self._what_if_at_subscription_scope_initial.metadata['url'], + content=_content, + template_url=self._what_if_at_subscription_scope_initial.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200, 202]: @@ -2952,35 +3919,38 @@ async def _what_if_at_subscription_scope_initial( deserialized = None response_headers = {} if response.status_code == 200: - deserialized = self._deserialize('WhatIfOperationResult', pipeline_response) + deserialized = self._deserialize("WhatIfOperationResult", pipeline_response) if response.status_code == 202: - response_headers['Location']=self._deserialize('str', response.headers.get('Location')) - response_headers['Retry-After']=self._deserialize('str', response.headers.get('Retry-After')) - + response_headers["Location"] = self._deserialize("str", response.headers.get("Location")) + response_headers["Retry-After"] = self._deserialize("str", response.headers.get("Retry-After")) if cls: return cls(pipeline_response, deserialized, response_headers) return deserialized - _what_if_at_subscription_scope_initial.metadata = {'url': "/subscriptions/{subscriptionId}/providers/Microsoft.Resources/deployments/{deploymentName}/whatIf"} # type: ignore + _what_if_at_subscription_scope_initial.metadata = {"url": "/subscriptions/{subscriptionId}/providers/Microsoft.Resources/deployments/{deploymentName}/whatIf"} # type: ignore - - @distributed_trace_async + @overload async def begin_what_if_at_subscription_scope( self, deployment_name: str, - parameters: "_models.DeploymentWhatIf", + parameters: _models.DeploymentWhatIf, + *, + content_type: str = "application/json", **kwargs: Any - ) -> AsyncLROPoller["_models.WhatIfOperationResult"]: + ) -> AsyncLROPoller[_models.WhatIfOperationResult]: """Returns changes that will be made by the deployment if executed at the scope of the subscription. - :param deployment_name: The name of the deployment. + :param deployment_name: The name of the deployment. Required. :type deployment_name: str - :param parameters: Parameters to What If. + :param parameters: Parameters to What If. Required. :type parameters: ~azure.mgmt.resource.resources.v2020_06_01.models.DeploymentWhatIf + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str :keyword callable cls: A custom type or function that will be passed the direct response :keyword str continuation_token: A continuation token to restart a poller from a saved state. :keyword polling: By default, your polling method will be AsyncARMPolling. Pass in False for @@ -2993,111 +3963,174 @@ async def begin_what_if_at_subscription_scope( of cls(response) :rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.resource.resources.v2020_06_01.models.WhatIfOperationResult] - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - api_version = kwargs.pop('api_version', "2020-06-01") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] - polling = kwargs.pop('polling', True) # type: Union[bool, AsyncPollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType["_models.WhatIfOperationResult"] - lro_delay = kwargs.pop( - 'polling_interval', - self._config.polling_interval - ) - cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] + + @overload + async def begin_what_if_at_subscription_scope( + self, deployment_name: str, parameters: IO, *, content_type: str = "application/json", **kwargs: Any + ) -> AsyncLROPoller[_models.WhatIfOperationResult]: + """Returns changes that will be made by the deployment if executed at the scope of the + subscription. + + :param deployment_name: The name of the deployment. Required. + :type deployment_name: str + :param parameters: Parameters to What If. Required. + :type parameters: IO + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be AsyncARMPolling. Pass in False for + this operation to not poll, or pass in your own initialized polling object for a personal + polling strategy. + :paramtype polling: bool or ~azure.core.polling.AsyncPollingMethod + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of AsyncLROPoller that returns either WhatIfOperationResult or the result + of cls(response) + :rtype: + ~azure.core.polling.AsyncLROPoller[~azure.mgmt.resource.resources.v2020_06_01.models.WhatIfOperationResult] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace_async + async def begin_what_if_at_subscription_scope( + self, deployment_name: str, parameters: Union[_models.DeploymentWhatIf, IO], **kwargs: Any + ) -> AsyncLROPoller[_models.WhatIfOperationResult]: + """Returns changes that will be made by the deployment if executed at the scope of the + subscription. + + :param deployment_name: The name of the deployment. Required. + :type deployment_name: str + :param parameters: Parameters to What If. Is either a model type or a IO type. Required. + :type parameters: ~azure.mgmt.resource.resources.v2020_06_01.models.DeploymentWhatIf or IO + :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. + Default value is None. + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be AsyncARMPolling. Pass in False for + this operation to not poll, or pass in your own initialized polling object for a personal + polling strategy. + :paramtype polling: bool or ~azure.core.polling.AsyncPollingMethod + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of AsyncLROPoller that returns either WhatIfOperationResult or the result + of cls(response) + :rtype: + ~azure.core.polling.AsyncLROPoller[~azure.mgmt.resource.resources.v2020_06_01.models.WhatIfOperationResult] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _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", "2020-06-01")) # type: str + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.WhatIfOperationResult] + polling = kwargs.pop("polling", True) # type: Union[bool, AsyncPollingMethod] + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token = kwargs.pop("continuation_token", None) # type: Optional[str] if cont_token is None: - raw_result = await self._what_if_at_subscription_scope_initial( + raw_result = await self._what_if_at_subscription_scope_initial( # type: ignore deployment_name=deployment_name, parameters=parameters, api_version=api_version, content_type=content_type, - cls=lambda x,y,z: x, + cls=lambda x, y, z: x, + headers=_headers, + params=_params, **kwargs ) - kwargs.pop('error_map', None) + kwargs.pop("error_map", None) def get_long_running_output(pipeline_response): - response = pipeline_response.http_response - deserialized = self._deserialize('WhatIfOperationResult', pipeline_response) + deserialized = self._deserialize("WhatIfOperationResult", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - - if polling is True: polling_method = AsyncARMPolling(lro_delay, lro_options={'final-state-via': 'location'}, **kwargs) - elif polling is False: polling_method = AsyncNoPolling() - else: polling_method = polling + if polling is True: + polling_method = cast( + AsyncPollingMethod, AsyncARMPolling(lro_delay, lro_options={"final-state-via": "location"}, **kwargs) + ) # type: AsyncPollingMethod + elif polling is False: + polling_method = cast(AsyncPollingMethod, AsyncNoPolling()) + else: + polling_method = polling if cont_token: return AsyncLROPoller.from_continuation_token( polling_method=polling_method, continuation_token=cont_token, client=self._client, - deserialization_callback=get_long_running_output + deserialization_callback=get_long_running_output, ) return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) - begin_what_if_at_subscription_scope.metadata = {'url': "/subscriptions/{subscriptionId}/providers/Microsoft.Resources/deployments/{deploymentName}/whatIf"} # type: ignore + begin_what_if_at_subscription_scope.metadata = {"url": "/subscriptions/{subscriptionId}/providers/Microsoft.Resources/deployments/{deploymentName}/whatIf"} # type: ignore @distributed_trace_async async def export_template_at_subscription_scope( - self, - deployment_name: str, - **kwargs: Any - ) -> "_models.DeploymentExportResult": + self, deployment_name: str, **kwargs: Any + ) -> _models.DeploymentExportResult: """Exports the template used for specified deployment. - :param deployment_name: The name of the deployment. + :param deployment_name: The name of the deployment. Required. :type deployment_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: DeploymentExportResult, or the result of cls(response) + :return: DeploymentExportResult or the result of cls(response) :rtype: ~azure.mgmt.resource.resources.v2020_06_01.models.DeploymentExportResult - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.DeploymentExportResult"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) - api_version = kwargs.pop('api_version', "2020-06-01") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2020-06-01")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[_models.DeploymentExportResult] - request = build_deployments_export_template_at_subscription_scope_request( deployment_name=deployment_name, subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.export_template_at_subscription_scope.metadata['url'], + template_url=self.export_template_at_subscription_scope.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) - deserialized = self._deserialize('DeploymentExportResult', pipeline_response) + deserialized = self._deserialize("DeploymentExportResult", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - export_template_at_subscription_scope.metadata = {'url': "/subscriptions/{subscriptionId}/providers/Microsoft.Resources/deployments/{deploymentName}/exportTemplate"} # type: ignore - + export_template_at_subscription_scope.metadata = {"url": "/subscriptions/{subscriptionId}/providers/Microsoft.Resources/deployments/{deploymentName}/exportTemplate"} # type: ignore @distributed_trace def list_at_subscription_scope( - self, - filter: Optional[str] = None, - top: Optional[int] = None, - **kwargs: Any - ) -> AsyncIterable["_models.DeploymentListResult"]: + self, filter: Optional[str] = None, top: Optional[int] = None, **kwargs: Any + ) -> AsyncIterable["_models.DeploymentExtended"]: """Get all the deployments for a subscription. :param filter: The filter to apply on the operation. For example, you can use @@ -3107,40 +4140,48 @@ def list_at_subscription_scope( value is None. :type top: int :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either DeploymentListResult or the result of - cls(response) + :return: An iterator like instance of either DeploymentExtended or the result of cls(response) :rtype: - ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.resource.resources.v2020_06_01.models.DeploymentListResult] - :raises: ~azure.core.exceptions.HttpResponseError + ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.resource.resources.v2020_06_01.models.DeploymentExtended] + :raises ~azure.core.exceptions.HttpResponseError: """ - api_version = kwargs.pop('api_version', "2020-06-01") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2020-06-01")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[_models.DeploymentListResult] - cls = kwargs.pop('cls', None) # type: ClsType["_models.DeploymentListResult"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) + def prepare_request(next_link=None): if not next_link: - + request = build_deployments_list_at_subscription_scope_request( subscription_id=self._config.subscription_id, - api_version=api_version, filter=filter, top=top, - template_url=self.list_at_subscription_scope.metadata['url'], + api_version=api_version, + template_url=self.list_at_subscription_scope.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore else: - - request = build_deployments_list_at_subscription_scope_request( - subscription_id=self._config.subscription_id, - template_url=next_link, - ) + # make call to next link with the client's api-version + _parsed_next_link = urlparse(next_link) + _next_request_params = case_insensitive_dict(parse_qs(_parsed_next_link.query)) + _next_request_params["api-version"] = self._config.api_version + request = HttpRequest("GET", urljoin(next_link, _parsed_next_link.path), params=_next_request_params) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore request.method = "GET" return request @@ -3154,10 +4195,8 @@ async def extract_data(pipeline_response): async def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) response = pipeline_response.http_response @@ -3167,42 +4206,43 @@ async def get_next(next_link=None): return pipeline_response + return AsyncItemPaged(get_next, extract_data) - return AsyncItemPaged( - get_next, extract_data - ) - list_at_subscription_scope.metadata = {'url': "/subscriptions/{subscriptionId}/providers/Microsoft.Resources/deployments/"} # type: ignore + list_at_subscription_scope.metadata = {"url": "/subscriptions/{subscriptionId}/providers/Microsoft.Resources/deployments/"} # type: ignore async def _delete_initial( # pylint: disable=inconsistent-return-statements - self, - resource_group_name: str, - deployment_name: str, - **kwargs: Any + self, resource_group_name: str, deployment_name: str, **kwargs: Any ) -> None: - cls = kwargs.pop('cls', None) # type: ClsType[None] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) - api_version = kwargs.pop('api_version', "2020-06-01") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - request = build_deployments_delete_request_initial( + api_version = kwargs.pop("api_version", _params.pop("api-version", "2020-06-01")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[None] + + request = build_deployments_delete_request( resource_group_name=resource_group_name, deployment_name=deployment_name, subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self._delete_initial.metadata['url'], + template_url=self._delete_initial.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [202, 204]: @@ -3212,16 +4252,10 @@ 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.Resources/deployments/{deploymentName}"} # type: ignore - + _delete_initial.metadata = {"url": "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/Microsoft.Resources/deployments/{deploymentName}"} # type: ignore @distributed_trace_async - async def begin_delete( # pylint: disable=inconsistent-return-statements - self, - resource_group_name: str, - deployment_name: str, - **kwargs: Any - ) -> AsyncLROPoller[None]: + async def begin_delete(self, resource_group_name: str, deployment_name: str, **kwargs: Any) -> AsyncLROPoller[None]: """Deletes a deployment from the deployment history. A template deployment that is currently running cannot be deleted. Deleting a template @@ -3234,9 +4268,9 @@ async def begin_delete( # pylint: disable=inconsistent-return-statements asynchronous request failed, the URI in the Location header returns an error-level status code. :param resource_group_name: The name of the resource group with the deployment to delete. The - name is case insensitive. + name is case insensitive. Required. :type resource_group_name: str - :param deployment_name: The name of the deployment. + :param deployment_name: The name of the deployment. Required. :type deployment_name: str :keyword callable cls: A custom type or function that will be passed the direct response :keyword str continuation_token: A continuation token to restart a poller from a saved state. @@ -3248,88 +4282,93 @@ async def begin_delete( # pylint: disable=inconsistent-return-statements Retry-After header is present. :return: An instance of AsyncLROPoller that returns either None or the result of cls(response) :rtype: ~azure.core.polling.AsyncLROPoller[None] - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - api_version = kwargs.pop('api_version', "2020-06-01") # type: str - polling = kwargs.pop('polling', True) # type: Union[bool, AsyncPollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType[None] - lro_delay = kwargs.pop( - 'polling_interval', - self._config.polling_interval - ) - cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2020-06-01")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[None] + polling = kwargs.pop("polling", True) # type: Union[bool, AsyncPollingMethod] + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token = kwargs.pop("continuation_token", None) # type: Optional[str] if cont_token is None: - raw_result = await self._delete_initial( + raw_result = await self._delete_initial( # type: ignore resource_group_name=resource_group_name, deployment_name=deployment_name, api_version=api_version, - cls=lambda x,y,z: x, + cls=lambda x, y, z: x, + headers=_headers, + params=_params, **kwargs ) - kwargs.pop('error_map', None) + kwargs.pop("error_map", None) - def get_long_running_output(pipeline_response): + def get_long_running_output(pipeline_response): # pylint: disable=inconsistent-return-statements if cls: return cls(pipeline_response, None, {}) - - if polling is True: polling_method = AsyncARMPolling(lro_delay, **kwargs) - elif polling is False: polling_method = AsyncNoPolling() - else: polling_method = polling + if polling is True: + polling_method = cast(AsyncPollingMethod, AsyncARMPolling(lro_delay, **kwargs)) # type: AsyncPollingMethod + elif polling is False: + polling_method = cast(AsyncPollingMethod, AsyncNoPolling()) + else: + polling_method = polling if cont_token: return AsyncLROPoller.from_continuation_token( polling_method=polling_method, continuation_token=cont_token, client=self._client, - deserialization_callback=get_long_running_output + deserialization_callback=get_long_running_output, ) return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) - begin_delete.metadata = {'url': "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/Microsoft.Resources/deployments/{deploymentName}"} # type: ignore + begin_delete.metadata = {"url": "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/Microsoft.Resources/deployments/{deploymentName}"} # type: ignore @distributed_trace_async - async def check_existence( - self, - resource_group_name: str, - deployment_name: str, - **kwargs: Any - ) -> bool: + async def check_existence(self, resource_group_name: str, deployment_name: str, **kwargs: Any) -> bool: """Checks whether the deployment exists. :param resource_group_name: The name of the resource group with the deployment to check. The - name is case insensitive. + name is case insensitive. Required. :type resource_group_name: str - :param deployment_name: The name of the deployment. + :param deployment_name: The name of the deployment. Required. :type deployment_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: bool, or the result of cls(response) + :return: bool or the result of cls(response) :rtype: bool - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType[None] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + 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', "2020-06-01") # type: str + api_version = kwargs.pop("api_version", _params.pop("api-version", "2020-06-01")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[None] - request = build_deployments_check_existence_request( resource_group_name=resource_group_name, deployment_name=deployment_name, subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.check_existence.metadata['url'], + template_url=self.check_existence.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [204, 404]: @@ -3340,44 +4379,53 @@ async def check_existence( return cls(pipeline_response, None, {}) return 200 <= response.status_code <= 299 - check_existence.metadata = {'url': "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/Microsoft.Resources/deployments/{deploymentName}"} # type: ignore - + check_existence.metadata = {"url": "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/Microsoft.Resources/deployments/{deploymentName}"} # type: ignore async def _create_or_update_initial( - self, - resource_group_name: str, - deployment_name: str, - parameters: "_models.Deployment", - **kwargs: Any - ) -> "_models.DeploymentExtended": - cls = kwargs.pop('cls', None) # type: ClsType["_models.DeploymentExtended"] + self, resource_group_name: str, deployment_name: str, parameters: Union[_models.Deployment, IO], **kwargs: Any + ) -> _models.DeploymentExtended: error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) - api_version = kwargs.pop('api_version', "2020-06-01") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - _json = self._serialize.body(parameters, 'Deployment') + api_version = kwargs.pop("api_version", _params.pop("api-version", "2020-06-01")) # type: str + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.DeploymentExtended] - request = build_deployments_create_or_update_request_initial( + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(parameters, (IO, bytes)): + _content = parameters + else: + _json = self._serialize.body(parameters, "Deployment") + + request = build_deployments_create_or_update_request( resource_group_name=resource_group_name, deployment_name=deployment_name, subscription_id=self._config.subscription_id, api_version=api_version, content_type=content_type, json=_json, - template_url=self._create_or_update_initial.metadata['url'], + content=_content, + template_url=self._create_or_update_initial.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200, 201]: @@ -3385,38 +4433,42 @@ async def _create_or_update_initial( raise HttpResponseError(response=response, error_format=ARMErrorFormat) if response.status_code == 200: - deserialized = self._deserialize('DeploymentExtended', pipeline_response) + deserialized = self._deserialize("DeploymentExtended", pipeline_response) if response.status_code == 201: - deserialized = self._deserialize('DeploymentExtended', pipeline_response) + deserialized = self._deserialize("DeploymentExtended", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - _create_or_update_initial.metadata = {'url': "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/Microsoft.Resources/deployments/{deploymentName}"} # type: ignore + _create_or_update_initial.metadata = {"url": "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/Microsoft.Resources/deployments/{deploymentName}"} # type: ignore - - @distributed_trace_async + @overload async def begin_create_or_update( self, resource_group_name: str, deployment_name: str, - parameters: "_models.Deployment", + parameters: _models.Deployment, + *, + content_type: str = "application/json", **kwargs: Any - ) -> AsyncLROPoller["_models.DeploymentExtended"]: + ) -> AsyncLROPoller[_models.DeploymentExtended]: """Deploys resources to a resource group. You can provide the template and parameters directly in the request or link to JSON files. :param resource_group_name: The name of the resource group to deploy the resources to. The name - is case insensitive. The resource group must already exist. + is case insensitive. The resource group must already exist. Required. :type resource_group_name: str - :param deployment_name: The name of the deployment. + :param deployment_name: The name of the deployment. Required. :type deployment_name: str - :param parameters: Additional parameters supplied to the operation. + :param parameters: Additional parameters supplied to the operation. Required. :type parameters: ~azure.mgmt.resource.resources.v2020_06_01.models.Deployment + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str :keyword callable cls: A custom type or function that will be passed the direct response :keyword str continuation_token: A continuation token to restart a poller from a saved state. :keyword polling: By default, your polling method will be AsyncARMPolling. Pass in False for @@ -3429,115 +4481,189 @@ async def begin_create_or_update( cls(response) :rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.resource.resources.v2020_06_01.models.DeploymentExtended] - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - api_version = kwargs.pop('api_version', "2020-06-01") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] - polling = kwargs.pop('polling', True) # type: Union[bool, AsyncPollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType["_models.DeploymentExtended"] - lro_delay = kwargs.pop( - 'polling_interval', - self._config.polling_interval - ) - cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] + + @overload + async def begin_create_or_update( + self, + resource_group_name: str, + deployment_name: str, + parameters: IO, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> AsyncLROPoller[_models.DeploymentExtended]: + """Deploys resources to a resource group. + + You can provide the template and parameters directly in the request or link to JSON files. + + :param resource_group_name: The name of the resource group to deploy the resources to. The name + is case insensitive. The resource group must already exist. Required. + :type resource_group_name: str + :param deployment_name: The name of the deployment. Required. + :type deployment_name: str + :param parameters: Additional parameters supplied to the operation. Required. + :type parameters: IO + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be AsyncARMPolling. Pass in False for + this operation to not poll, or pass in your own initialized polling object for a personal + polling strategy. + :paramtype polling: bool or ~azure.core.polling.AsyncPollingMethod + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of AsyncLROPoller that returns either DeploymentExtended or the result of + cls(response) + :rtype: + ~azure.core.polling.AsyncLROPoller[~azure.mgmt.resource.resources.v2020_06_01.models.DeploymentExtended] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace_async + async def begin_create_or_update( + self, resource_group_name: str, deployment_name: str, parameters: Union[_models.Deployment, IO], **kwargs: Any + ) -> AsyncLROPoller[_models.DeploymentExtended]: + """Deploys resources to a resource group. + + You can provide the template and parameters directly in the request or link to JSON files. + + :param resource_group_name: The name of the resource group to deploy the resources to. The name + is case insensitive. The resource group must already exist. Required. + :type resource_group_name: str + :param deployment_name: The name of the deployment. Required. + :type deployment_name: str + :param parameters: Additional parameters supplied to the operation. Is either a model type or a + IO type. Required. + :type parameters: ~azure.mgmt.resource.resources.v2020_06_01.models.Deployment or IO + :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. + Default value is None. + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be AsyncARMPolling. Pass in False for + this operation to not poll, or pass in your own initialized polling object for a personal + polling strategy. + :paramtype polling: bool or ~azure.core.polling.AsyncPollingMethod + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of AsyncLROPoller that returns either DeploymentExtended or the result of + cls(response) + :rtype: + ~azure.core.polling.AsyncLROPoller[~azure.mgmt.resource.resources.v2020_06_01.models.DeploymentExtended] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _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", "2020-06-01")) # type: str + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.DeploymentExtended] + polling = kwargs.pop("polling", True) # type: Union[bool, AsyncPollingMethod] + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token = kwargs.pop("continuation_token", None) # type: Optional[str] if cont_token is None: - raw_result = await self._create_or_update_initial( + raw_result = await self._create_or_update_initial( # type: ignore resource_group_name=resource_group_name, deployment_name=deployment_name, parameters=parameters, api_version=api_version, content_type=content_type, - cls=lambda x,y,z: x, + cls=lambda x, y, z: x, + headers=_headers, + params=_params, **kwargs ) - kwargs.pop('error_map', None) + kwargs.pop("error_map", None) def get_long_running_output(pipeline_response): - response = pipeline_response.http_response - deserialized = self._deserialize('DeploymentExtended', pipeline_response) + deserialized = self._deserialize("DeploymentExtended", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - - if polling is True: polling_method = AsyncARMPolling(lro_delay, **kwargs) - elif polling is False: polling_method = AsyncNoPolling() - else: polling_method = polling + if polling is True: + polling_method = cast(AsyncPollingMethod, AsyncARMPolling(lro_delay, **kwargs)) # type: AsyncPollingMethod + elif polling is False: + polling_method = cast(AsyncPollingMethod, AsyncNoPolling()) + else: + polling_method = polling if cont_token: return AsyncLROPoller.from_continuation_token( polling_method=polling_method, continuation_token=cont_token, client=self._client, - deserialization_callback=get_long_running_output + deserialization_callback=get_long_running_output, ) return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) - begin_create_or_update.metadata = {'url': "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/Microsoft.Resources/deployments/{deploymentName}"} # type: ignore + begin_create_or_update.metadata = {"url": "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/Microsoft.Resources/deployments/{deploymentName}"} # type: ignore @distributed_trace_async - async def get( - self, - resource_group_name: str, - deployment_name: str, - **kwargs: Any - ) -> "_models.DeploymentExtended": + async def get(self, resource_group_name: str, deployment_name: str, **kwargs: Any) -> _models.DeploymentExtended: """Gets a deployment. :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. :type resource_group_name: str - :param deployment_name: The name of the deployment. + :param deployment_name: The name of the deployment. Required. :type deployment_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: DeploymentExtended, or the result of cls(response) + :return: DeploymentExtended or the result of cls(response) :rtype: ~azure.mgmt.resource.resources.v2020_06_01.models.DeploymentExtended - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.DeploymentExtended"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) - api_version = kwargs.pop('api_version', "2020-06-01") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2020-06-01")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[_models.DeploymentExtended] - request = build_deployments_get_request( resource_group_name=resource_group_name, deployment_name=deployment_name, subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.get.metadata['url'], + template_url=self.get.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) - deserialized = self._deserialize('DeploymentExtended', pipeline_response) + deserialized = self._deserialize("DeploymentExtended", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - get.metadata = {'url': "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/Microsoft.Resources/deployments/{deploymentName}"} # type: ignore - + get.metadata = {"url": "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/Microsoft.Resources/deployments/{deploymentName}"} # type: ignore @distributed_trace_async async def cancel( # pylint: disable=inconsistent-return-statements - self, - resource_group_name: str, - deployment_name: str, - **kwargs: Any + self, resource_group_name: str, deployment_name: str, **kwargs: Any ) -> None: """Cancels a currently running template deployment. @@ -3547,38 +4673,45 @@ async def cancel( # pylint: disable=inconsistent-return-statements partially deployed. :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. :type resource_group_name: str - :param deployment_name: The name of the deployment. + :param deployment_name: The name of the deployment. Required. :type deployment_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: None, or the result of cls(response) + :return: None or the result of cls(response) :rtype: None - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType[None] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + 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', "2020-06-01") # type: str + api_version = kwargs.pop("api_version", _params.pop("api-version", "2020-06-01")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[None] - request = build_deployments_cancel_request( resource_group_name=resource_group_name, deployment_name=deployment_name, subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.cancel.metadata['url'], + template_url=self.cancel.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [204]: @@ -3588,44 +4721,53 @@ async def cancel( # pylint: disable=inconsistent-return-statements if cls: return cls(pipeline_response, None, {}) - cancel.metadata = {'url': "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/Microsoft.Resources/deployments/{deploymentName}/cancel"} # type: ignore - + cancel.metadata = {"url": "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/Microsoft.Resources/deployments/{deploymentName}/cancel"} # type: ignore async def _validate_initial( - self, - resource_group_name: str, - deployment_name: str, - parameters: "_models.Deployment", - **kwargs: Any - ) -> Optional["_models.DeploymentValidateResult"]: - cls = kwargs.pop('cls', None) # type: ClsType[Optional["_models.DeploymentValidateResult"]] + self, resource_group_name: str, deployment_name: str, parameters: Union[_models.Deployment, IO], **kwargs: Any + ) -> Optional[_models.DeploymentValidateResult]: error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) - api_version = kwargs.pop('api_version', "2020-06-01") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - _json = self._serialize.body(parameters, 'Deployment') + api_version = kwargs.pop("api_version", _params.pop("api-version", "2020-06-01")) # type: str + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[Optional[_models.DeploymentValidateResult]] - request = build_deployments_validate_request_initial( + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(parameters, (IO, bytes)): + _content = parameters + else: + _json = self._serialize.body(parameters, "Deployment") + + request = build_deployments_validate_request( resource_group_name=resource_group_name, deployment_name=deployment_name, subscription_id=self._config.subscription_id, api_version=api_version, content_type=content_type, json=_json, - template_url=self._validate_initial.metadata['url'], + content=_content, + template_url=self._validate_initial.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200, 202, 400]: @@ -3634,37 +4776,41 @@ async def _validate_initial( deserialized = None if response.status_code == 200: - deserialized = self._deserialize('DeploymentValidateResult', pipeline_response) + deserialized = self._deserialize("DeploymentValidateResult", pipeline_response) if response.status_code == 400: - deserialized = self._deserialize('DeploymentValidateResult', pipeline_response) + deserialized = self._deserialize("DeploymentValidateResult", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - _validate_initial.metadata = {'url': "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/Microsoft.Resources/deployments/{deploymentName}/validate"} # type: ignore + _validate_initial.metadata = {"url": "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/Microsoft.Resources/deployments/{deploymentName}/validate"} # type: ignore - - @distributed_trace_async + @overload async def begin_validate( self, resource_group_name: str, deployment_name: str, - parameters: "_models.Deployment", + parameters: _models.Deployment, + *, + content_type: str = "application/json", **kwargs: Any - ) -> AsyncLROPoller["_models.DeploymentValidateResult"]: + ) -> AsyncLROPoller[_models.DeploymentValidateResult]: """Validates whether the specified template is syntactically correct and will be accepted by Azure Resource Manager.. :param resource_group_name: The name of the resource group the template will be deployed to. - The name is case insensitive. + The name is case insensitive. Required. :type resource_group_name: str - :param deployment_name: The name of the deployment. + :param deployment_name: The name of the deployment. Required. :type deployment_name: str - :param parameters: Parameters to validate. + :param parameters: Parameters to validate. Required. :type parameters: ~azure.mgmt.resource.resources.v2020_06_01.models.Deployment + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str :keyword callable cls: A custom type or function that will be passed the direct response :keyword str continuation_token: A continuation token to restart a poller from a saved state. :keyword polling: By default, your polling method will be AsyncARMPolling. Pass in False for @@ -3677,86 +4823,173 @@ async def begin_validate( result of cls(response) :rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.resource.resources.v2020_06_01.models.DeploymentValidateResult] - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - api_version = kwargs.pop('api_version', "2020-06-01") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] - polling = kwargs.pop('polling', True) # type: Union[bool, AsyncPollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType["_models.DeploymentValidateResult"] - lro_delay = kwargs.pop( - 'polling_interval', - self._config.polling_interval - ) - cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] - if cont_token is None: - raw_result = await self._validate_initial( - resource_group_name=resource_group_name, - deployment_name=deployment_name, - parameters=parameters, - api_version=api_version, - content_type=content_type, - cls=lambda x,y,z: x, - **kwargs - ) - kwargs.pop('error_map', None) - - def get_long_running_output(pipeline_response): - response = pipeline_response.http_response - deserialized = self._deserialize('DeploymentValidateResult', pipeline_response) - if cls: - return cls(pipeline_response, deserialized, {}) - return deserialized + @overload + async def begin_validate( + self, + resource_group_name: str, + deployment_name: str, + parameters: IO, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> AsyncLROPoller[_models.DeploymentValidateResult]: + """Validates whether the specified template is syntactically correct and will be accepted by Azure + Resource Manager.. - if polling is True: polling_method = AsyncARMPolling(lro_delay, **kwargs) - elif polling is False: polling_method = AsyncNoPolling() - else: polling_method = polling - if cont_token: - return AsyncLROPoller.from_continuation_token( + :param resource_group_name: The name of the resource group the template will be deployed to. + The name is case insensitive. Required. + :type resource_group_name: str + :param deployment_name: The name of the deployment. Required. + :type deployment_name: str + :param parameters: Parameters to validate. Required. + :type parameters: IO + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be AsyncARMPolling. Pass in False for + this operation to not poll, or pass in your own initialized polling object for a personal + polling strategy. + :paramtype polling: bool or ~azure.core.polling.AsyncPollingMethod + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of AsyncLROPoller that returns either DeploymentValidateResult or the + result of cls(response) + :rtype: + ~azure.core.polling.AsyncLROPoller[~azure.mgmt.resource.resources.v2020_06_01.models.DeploymentValidateResult] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace_async + async def begin_validate( + self, resource_group_name: str, deployment_name: str, parameters: Union[_models.Deployment, IO], **kwargs: Any + ) -> AsyncLROPoller[_models.DeploymentValidateResult]: + """Validates whether the specified template is syntactically correct and will be accepted by Azure + Resource Manager.. + + :param resource_group_name: The name of the resource group the template will be deployed to. + The name is case insensitive. Required. + :type resource_group_name: str + :param deployment_name: The name of the deployment. Required. + :type deployment_name: str + :param parameters: Parameters to validate. Is either a model type or a IO type. Required. + :type parameters: ~azure.mgmt.resource.resources.v2020_06_01.models.Deployment or IO + :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. + Default value is None. + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be AsyncARMPolling. Pass in False for + this operation to not poll, or pass in your own initialized polling object for a personal + polling strategy. + :paramtype polling: bool or ~azure.core.polling.AsyncPollingMethod + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of AsyncLROPoller that returns either DeploymentValidateResult or the + result of cls(response) + :rtype: + ~azure.core.polling.AsyncLROPoller[~azure.mgmt.resource.resources.v2020_06_01.models.DeploymentValidateResult] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _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", "2020-06-01")) # type: str + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.DeploymentValidateResult] + polling = kwargs.pop("polling", True) # type: Union[bool, AsyncPollingMethod] + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token = kwargs.pop("continuation_token", None) # type: Optional[str] + if cont_token is None: + raw_result = await self._validate_initial( # type: ignore + resource_group_name=resource_group_name, + deployment_name=deployment_name, + parameters=parameters, + api_version=api_version, + content_type=content_type, + cls=lambda x, y, z: x, + headers=_headers, + params=_params, + **kwargs + ) + kwargs.pop("error_map", None) + + def get_long_running_output(pipeline_response): + deserialized = self._deserialize("DeploymentValidateResult", pipeline_response) + if cls: + return cls(pipeline_response, deserialized, {}) + return deserialized + + if polling is True: + polling_method = cast(AsyncPollingMethod, AsyncARMPolling(lro_delay, **kwargs)) # type: AsyncPollingMethod + elif polling is False: + polling_method = cast(AsyncPollingMethod, AsyncNoPolling()) + else: + polling_method = polling + if cont_token: + return AsyncLROPoller.from_continuation_token( polling_method=polling_method, continuation_token=cont_token, client=self._client, - deserialization_callback=get_long_running_output + deserialization_callback=get_long_running_output, ) return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) - begin_validate.metadata = {'url': "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/Microsoft.Resources/deployments/{deploymentName}/validate"} # type: ignore + begin_validate.metadata = {"url": "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/Microsoft.Resources/deployments/{deploymentName}/validate"} # type: ignore async def _what_if_initial( self, resource_group_name: str, deployment_name: str, - parameters: "_models.DeploymentWhatIf", + parameters: Union[_models.DeploymentWhatIf, IO], **kwargs: Any - ) -> Optional["_models.WhatIfOperationResult"]: - cls = kwargs.pop('cls', None) # type: ClsType[Optional["_models.WhatIfOperationResult"]] + ) -> Optional[_models.WhatIfOperationResult]: error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', "2020-06-01") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + api_version = kwargs.pop("api_version", _params.pop("api-version", "2020-06-01")) # type: str + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[Optional[_models.WhatIfOperationResult]] - _json = self._serialize.body(parameters, 'DeploymentWhatIf') + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(parameters, (IO, bytes)): + _content = parameters + else: + _json = self._serialize.body(parameters, "DeploymentWhatIf") - request = build_deployments_what_if_request_initial( + request = build_deployments_what_if_request( resource_group_name=resource_group_name, deployment_name=deployment_name, subscription_id=self._config.subscription_id, api_version=api_version, content_type=content_type, json=_json, - template_url=self._what_if_initial.metadata['url'], + content=_content, + template_url=self._what_if_initial.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200, 202]: @@ -3766,39 +4999,116 @@ async def _what_if_initial( deserialized = None response_headers = {} if response.status_code == 200: - deserialized = self._deserialize('WhatIfOperationResult', pipeline_response) + deserialized = self._deserialize("WhatIfOperationResult", pipeline_response) if response.status_code == 202: - response_headers['Location']=self._deserialize('str', response.headers.get('Location')) - response_headers['Retry-After']=self._deserialize('str', response.headers.get('Retry-After')) - + response_headers["Location"] = self._deserialize("str", response.headers.get("Location")) + response_headers["Retry-After"] = self._deserialize("str", response.headers.get("Retry-After")) if cls: return cls(pipeline_response, deserialized, response_headers) return deserialized - _what_if_initial.metadata = {'url': "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/Microsoft.Resources/deployments/{deploymentName}/whatIf"} # type: ignore + _what_if_initial.metadata = {"url": "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/Microsoft.Resources/deployments/{deploymentName}/whatIf"} # type: ignore + + @overload + async def begin_what_if( + self, + resource_group_name: str, + deployment_name: str, + parameters: _models.DeploymentWhatIf, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> AsyncLROPoller[_models.WhatIfOperationResult]: + """Returns changes that will be made by the deployment if executed at the scope of the resource + group. + + :param resource_group_name: The name of the resource group the template will be deployed to. + The name is case insensitive. Required. + :type resource_group_name: str + :param deployment_name: The name of the deployment. Required. + :type deployment_name: str + :param parameters: Parameters to validate. Required. + :type parameters: ~azure.mgmt.resource.resources.v2020_06_01.models.DeploymentWhatIf + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be AsyncARMPolling. Pass in False for + this operation to not poll, or pass in your own initialized polling object for a personal + polling strategy. + :paramtype polling: bool or ~azure.core.polling.AsyncPollingMethod + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of AsyncLROPoller that returns either WhatIfOperationResult or the result + of cls(response) + :rtype: + ~azure.core.polling.AsyncLROPoller[~azure.mgmt.resource.resources.v2020_06_01.models.WhatIfOperationResult] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + async def begin_what_if( + self, + resource_group_name: str, + deployment_name: str, + parameters: IO, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> AsyncLROPoller[_models.WhatIfOperationResult]: + """Returns changes that will be made by the deployment if executed at the scope of the resource + group. + :param resource_group_name: The name of the resource group the template will be deployed to. + The name is case insensitive. Required. + :type resource_group_name: str + :param deployment_name: The name of the deployment. Required. + :type deployment_name: str + :param parameters: Parameters to validate. Required. + :type parameters: IO + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be AsyncARMPolling. Pass in False for + this operation to not poll, or pass in your own initialized polling object for a personal + polling strategy. + :paramtype polling: bool or ~azure.core.polling.AsyncPollingMethod + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of AsyncLROPoller that returns either WhatIfOperationResult or the result + of cls(response) + :rtype: + ~azure.core.polling.AsyncLROPoller[~azure.mgmt.resource.resources.v2020_06_01.models.WhatIfOperationResult] + :raises ~azure.core.exceptions.HttpResponseError: + """ @distributed_trace_async async def begin_what_if( self, resource_group_name: str, deployment_name: str, - parameters: "_models.DeploymentWhatIf", + parameters: Union[_models.DeploymentWhatIf, IO], **kwargs: Any - ) -> AsyncLROPoller["_models.WhatIfOperationResult"]: + ) -> AsyncLROPoller[_models.WhatIfOperationResult]: """Returns changes that will be made by the deployment if executed at the scope of the resource group. :param resource_group_name: The name of the resource group the template will be deployed to. - The name is case insensitive. + The name is case insensitive. Required. :type resource_group_name: str - :param deployment_name: The name of the deployment. + :param deployment_name: The name of the deployment. Required. :type deployment_name: str - :param parameters: Parameters to validate. - :type parameters: ~azure.mgmt.resource.resources.v2020_06_01.models.DeploymentWhatIf + :param parameters: Parameters to validate. Is either a model type or a IO type. Required. + :type parameters: ~azure.mgmt.resource.resources.v2020_06_01.models.DeploymentWhatIf or IO + :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. + Default value is None. + :paramtype content_type: str :keyword callable cls: A custom type or function that will be passed the direct response :keyword str continuation_token: A continuation token to restart a poller from a saved state. :keyword polling: By default, your polling method will be AsyncARMPolling. Pass in False for @@ -3811,121 +5121,125 @@ async def begin_what_if( of cls(response) :rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.resource.resources.v2020_06_01.models.WhatIfOperationResult] - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - api_version = kwargs.pop('api_version', "2020-06-01") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] - polling = kwargs.pop('polling', True) # type: Union[bool, AsyncPollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType["_models.WhatIfOperationResult"] - lro_delay = kwargs.pop( - 'polling_interval', - self._config.polling_interval - ) - cont_token = kwargs.pop('continuation_token', None) # type: Optional[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", "2020-06-01")) # type: str + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.WhatIfOperationResult] + polling = kwargs.pop("polling", True) # type: Union[bool, AsyncPollingMethod] + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token = kwargs.pop("continuation_token", None) # type: Optional[str] if cont_token is None: - raw_result = await self._what_if_initial( + raw_result = await self._what_if_initial( # type: ignore resource_group_name=resource_group_name, deployment_name=deployment_name, parameters=parameters, api_version=api_version, content_type=content_type, - cls=lambda x,y,z: x, + cls=lambda x, y, z: x, + headers=_headers, + params=_params, **kwargs ) - kwargs.pop('error_map', None) + kwargs.pop("error_map", None) def get_long_running_output(pipeline_response): - response = pipeline_response.http_response - deserialized = self._deserialize('WhatIfOperationResult', pipeline_response) + deserialized = self._deserialize("WhatIfOperationResult", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - - if polling is True: polling_method = AsyncARMPolling(lro_delay, lro_options={'final-state-via': 'location'}, **kwargs) - elif polling is False: polling_method = AsyncNoPolling() - else: polling_method = polling + if polling is True: + polling_method = cast( + AsyncPollingMethod, AsyncARMPolling(lro_delay, lro_options={"final-state-via": "location"}, **kwargs) + ) # type: AsyncPollingMethod + elif polling is False: + polling_method = cast(AsyncPollingMethod, AsyncNoPolling()) + else: + polling_method = polling if cont_token: return AsyncLROPoller.from_continuation_token( polling_method=polling_method, continuation_token=cont_token, client=self._client, - deserialization_callback=get_long_running_output + deserialization_callback=get_long_running_output, ) return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) - begin_what_if.metadata = {'url': "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/Microsoft.Resources/deployments/{deploymentName}/whatIf"} # type: ignore + begin_what_if.metadata = {"url": "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/Microsoft.Resources/deployments/{deploymentName}/whatIf"} # type: ignore @distributed_trace_async async def export_template( - self, - resource_group_name: str, - deployment_name: str, - **kwargs: Any - ) -> "_models.DeploymentExportResult": + self, resource_group_name: str, deployment_name: str, **kwargs: Any + ) -> _models.DeploymentExportResult: """Exports the template used for specified deployment. :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. :type resource_group_name: str - :param deployment_name: The name of the deployment. + :param deployment_name: The name of the deployment. Required. :type deployment_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: DeploymentExportResult, or the result of cls(response) + :return: DeploymentExportResult or the result of cls(response) :rtype: ~azure.mgmt.resource.resources.v2020_06_01.models.DeploymentExportResult - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.DeploymentExportResult"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) - api_version = kwargs.pop('api_version', "2020-06-01") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2020-06-01")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[_models.DeploymentExportResult] - request = build_deployments_export_template_request( resource_group_name=resource_group_name, deployment_name=deployment_name, subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.export_template.metadata['url'], + template_url=self.export_template.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) - deserialized = self._deserialize('DeploymentExportResult', pipeline_response) + deserialized = self._deserialize("DeploymentExportResult", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - export_template.metadata = {'url': "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/Microsoft.Resources/deployments/{deploymentName}/exportTemplate"} # type: ignore - + export_template.metadata = {"url": "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/Microsoft.Resources/deployments/{deploymentName}/exportTemplate"} # type: ignore @distributed_trace def list_by_resource_group( - self, - resource_group_name: str, - filter: Optional[str] = None, - top: Optional[int] = None, - **kwargs: Any - ) -> AsyncIterable["_models.DeploymentListResult"]: + self, resource_group_name: str, filter: Optional[str] = None, top: Optional[int] = None, **kwargs: Any + ) -> AsyncIterable["_models.DeploymentExtended"]: """Get all the deployments for a resource group. :param resource_group_name: The name of the resource group with the deployments to get. The - name is case insensitive. + name is case insensitive. Required. :type resource_group_name: str :param filter: The filter to apply on the operation. For example, you can use $filter=provisioningState eq '{state}'. Default value is None. @@ -3934,42 +5248,49 @@ def list_by_resource_group( value is None. :type top: int :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either DeploymentListResult or the result of - cls(response) + :return: An iterator like instance of either DeploymentExtended or the result of cls(response) :rtype: - ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.resource.resources.v2020_06_01.models.DeploymentListResult] - :raises: ~azure.core.exceptions.HttpResponseError + ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.resource.resources.v2020_06_01.models.DeploymentExtended] + :raises ~azure.core.exceptions.HttpResponseError: """ - api_version = kwargs.pop('api_version', "2020-06-01") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2020-06-01")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[_models.DeploymentListResult] - cls = kwargs.pop('cls', None) # type: ClsType["_models.DeploymentListResult"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) + def prepare_request(next_link=None): if not next_link: - + request = build_deployments_list_by_resource_group_request( resource_group_name=resource_group_name, subscription_id=self._config.subscription_id, - api_version=api_version, filter=filter, top=top, - template_url=self.list_by_resource_group.metadata['url'], + 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.url = self._client.format_url(request.url) # type: ignore else: - - request = build_deployments_list_by_resource_group_request( - resource_group_name=resource_group_name, - subscription_id=self._config.subscription_id, - template_url=next_link, - ) + # make call to next link with the client's api-version + _parsed_next_link = urlparse(next_link) + _next_request_params = case_insensitive_dict(parse_qs(_parsed_next_link.query)) + _next_request_params["api-version"] = self._config.api_version + request = HttpRequest("GET", urljoin(next_link, _parsed_next_link.path), params=_next_request_params) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore request.method = "GET" return request @@ -3983,10 +5304,8 @@ async def extract_data(pipeline_response): async def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) response = pipeline_response.http_response @@ -3996,184 +5315,189 @@ async def get_next(next_link=None): return pipeline_response + return AsyncItemPaged(get_next, extract_data) - return AsyncItemPaged( - get_next, extract_data - ) - list_by_resource_group.metadata = {'url': "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/Microsoft.Resources/deployments/"} # type: ignore + list_by_resource_group.metadata = {"url": "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/Microsoft.Resources/deployments/"} # type: ignore @distributed_trace_async - async def calculate_template_hash( - self, - template: Any, - **kwargs: Any - ) -> "_models.TemplateHashResult": + async def calculate_template_hash(self, template: JSON, **kwargs: Any) -> _models.TemplateHashResult: """Calculate the hash of the given template. - :param template: The template provided to calculate hash. - :type template: any + :param template: The template provided to calculate hash. Required. + :type template: JSON :keyword callable cls: A custom type or function that will be passed the direct response - :return: TemplateHashResult, or the result of cls(response) + :return: TemplateHashResult or the result of cls(response) :rtype: ~azure.mgmt.resource.resources.v2020_06_01.models.TemplateHashResult - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.TemplateHashResult"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) - api_version = kwargs.pop('api_version', "2020-06-01") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - _json = self._serialize.body(template, 'object') + api_version = kwargs.pop("api_version", _params.pop("api-version", "2020-06-01")) # type: str + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", "application/json")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[_models.TemplateHashResult] + + _json = self._serialize.body(template, "object") request = build_deployments_calculate_template_hash_request( api_version=api_version, content_type=content_type, json=_json, - template_url=self.calculate_template_hash.metadata['url'], + template_url=self.calculate_template_hash.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) - deserialized = self._deserialize('TemplateHashResult', pipeline_response) + deserialized = self._deserialize("TemplateHashResult", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - calculate_template_hash.metadata = {'url': "/providers/Microsoft.Resources/calculateTemplateHash"} # type: ignore + calculate_template_hash.metadata = {"url": "/providers/Microsoft.Resources/calculateTemplateHash"} # type: ignore -class ProvidersOperations: - """ProvidersOperations async operations. - You should not instantiate this class directly. Instead, you should create a Client instance that - instantiates it for you and attaches it as an attribute. +class ProvidersOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. - :ivar models: Alias to model classes used in this operation group. - :type models: ~azure.mgmt.resource.resources.v2020_06_01.models - :param client: Client for service requests. - :param config: Configuration of service client. - :param serializer: An object model serializer. - :param deserializer: An object model deserializer. + Instead, you should access the following operations through + :class:`~azure.mgmt.resource.resources.v2020_06_01.aio.ResourceManagementClient`'s + :attr:`providers` attribute. """ models = _models - def __init__(self, client, config, serializer, deserializer) -> None: - self._client = client - self._serialize = serializer - self._deserialize = deserializer - self._config = config + def __init__(self, *args, **kwargs) -> None: + input_args = list(args) + self._client = input_args.pop(0) if input_args else kwargs.pop("client") + self._config = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") @distributed_trace_async - async def unregister( - self, - resource_provider_namespace: str, - **kwargs: Any - ) -> "_models.Provider": + async def unregister(self, resource_provider_namespace: str, **kwargs: Any) -> _models.Provider: """Unregisters a subscription from a resource provider. :param resource_provider_namespace: The namespace of the resource provider to unregister. + Required. :type resource_provider_namespace: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: Provider, or the result of cls(response) + :return: Provider or the result of cls(response) :rtype: ~azure.mgmt.resource.resources.v2020_06_01.models.Provider - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.Provider"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) - api_version = kwargs.pop('api_version', "2020-06-01") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2020-06-01")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[_models.Provider] - request = build_providers_unregister_request( resource_provider_namespace=resource_provider_namespace, subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.unregister.metadata['url'], + template_url=self.unregister.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) - deserialized = self._deserialize('Provider', pipeline_response) + deserialized = self._deserialize("Provider", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - unregister.metadata = {'url': "/subscriptions/{subscriptionId}/providers/{resourceProviderNamespace}/unregister"} # type: ignore - + unregister.metadata = {"url": "/subscriptions/{subscriptionId}/providers/{resourceProviderNamespace}/unregister"} # type: ignore @distributed_trace_async async def register_at_management_group_scope( # pylint: disable=inconsistent-return-statements - self, - resource_provider_namespace: str, - group_id: str, - **kwargs: Any + self, resource_provider_namespace: str, group_id: str, **kwargs: Any ) -> None: """Registers a management group with a resource provider. :param resource_provider_namespace: The namespace of the resource provider to register. + Required. :type resource_provider_namespace: str - :param group_id: The management group ID. + :param group_id: The management group ID. Required. :type group_id: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: None, or the result of cls(response) + :return: None or the result of cls(response) :rtype: None - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType[None] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + 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', "2020-06-01") # type: str + api_version = kwargs.pop("api_version", _params.pop("api-version", "2020-06-01")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[None] - request = build_providers_register_at_management_group_scope_request( resource_provider_namespace=resource_provider_namespace, group_id=group_id, api_version=api_version, - template_url=self.register_at_management_group_scope.metadata['url'], + template_url=self.register_at_management_group_scope.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200]: @@ -4183,70 +5507,68 @@ async def register_at_management_group_scope( # pylint: disable=inconsistent-re if cls: return cls(pipeline_response, None, {}) - register_at_management_group_scope.metadata = {'url': "/providers/Microsoft.Management/managementGroups/{groupId}/providers/{resourceProviderNamespace}/register"} # type: ignore - + register_at_management_group_scope.metadata = {"url": "/providers/Microsoft.Management/managementGroups/{groupId}/providers/{resourceProviderNamespace}/register"} # type: ignore @distributed_trace_async - async def register( - self, - resource_provider_namespace: str, - **kwargs: Any - ) -> "_models.Provider": + async def register(self, resource_provider_namespace: str, **kwargs: Any) -> _models.Provider: """Registers a subscription with a resource provider. :param resource_provider_namespace: The namespace of the resource provider to register. + Required. :type resource_provider_namespace: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: Provider, or the result of cls(response) + :return: Provider or the result of cls(response) :rtype: ~azure.mgmt.resource.resources.v2020_06_01.models.Provider - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.Provider"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + 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', "2020-06-01") # type: str + api_version = kwargs.pop("api_version", _params.pop("api-version", "2020-06-01")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[_models.Provider] - request = build_providers_register_request( resource_provider_namespace=resource_provider_namespace, subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.register.metadata['url'], + template_url=self.register.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) - deserialized = self._deserialize('Provider', pipeline_response) + deserialized = self._deserialize("Provider", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - register.metadata = {'url': "/subscriptions/{subscriptionId}/providers/{resourceProviderNamespace}/register"} # type: ignore - + register.metadata = {"url": "/subscriptions/{subscriptionId}/providers/{resourceProviderNamespace}/register"} # type: ignore @distributed_trace def list( - self, - top: Optional[int] = None, - expand: Optional[str] = None, - **kwargs: Any - ) -> AsyncIterable["_models.ProviderListResult"]: + self, top: Optional[int] = None, expand: Optional[str] = None, **kwargs: Any + ) -> AsyncIterable["_models.Provider"]: """Gets all resource providers for a subscription. :param top: The number of results to return. If null is passed returns all deployments. Default @@ -4257,39 +5579,48 @@ def list( response, use $expand=resourceTypes/aliases. Default value is None. :type expand: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either ProviderListResult or the result of cls(response) + :return: An iterator like instance of either Provider or the result of cls(response) :rtype: - ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.resource.resources.v2020_06_01.models.ProviderListResult] - :raises: ~azure.core.exceptions.HttpResponseError + ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.resource.resources.v2020_06_01.models.Provider] + :raises ~azure.core.exceptions.HttpResponseError: """ - api_version = kwargs.pop('api_version', "2020-06-01") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2020-06-01")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[_models.ProviderListResult] - cls = kwargs.pop('cls', None) # type: ClsType["_models.ProviderListResult"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) + def prepare_request(next_link=None): if not next_link: - + request = build_providers_list_request( subscription_id=self._config.subscription_id, - api_version=api_version, top=top, expand=expand, - template_url=self.list.metadata['url'], + 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.url = self._client.format_url(request.url) # type: ignore else: - - request = build_providers_list_request( - subscription_id=self._config.subscription_id, - template_url=next_link, - ) + # make call to next link with the client's api-version + _parsed_next_link = urlparse(next_link) + _next_request_params = case_insensitive_dict(parse_qs(_parsed_next_link.query)) + _next_request_params["api-version"] = self._config.api_version + request = HttpRequest("GET", urljoin(next_link, _parsed_next_link.path), params=_next_request_params) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore request.method = "GET" return request @@ -4303,10 +5634,8 @@ async def extract_data(pipeline_response): async def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) response = pipeline_response.http_response @@ -4316,19 +5645,14 @@ async def get_next(next_link=None): return pipeline_response + return AsyncItemPaged(get_next, extract_data) - return AsyncItemPaged( - get_next, extract_data - ) - list.metadata = {'url': "/subscriptions/{subscriptionId}/providers"} # type: ignore + list.metadata = {"url": "/subscriptions/{subscriptionId}/providers"} # type: ignore @distributed_trace def list_at_tenant_scope( - self, - top: Optional[int] = None, - expand: Optional[str] = None, - **kwargs: Any - ) -> AsyncIterable["_models.ProviderListResult"]: + self, top: Optional[int] = None, expand: Optional[str] = None, **kwargs: Any + ) -> AsyncIterable["_models.Provider"]: """Gets all resource providers for the tenant. :param top: The number of results to return. If null is passed returns all providers. Default @@ -4339,37 +5663,47 @@ def list_at_tenant_scope( response, use $expand=resourceTypes/aliases. Default value is None. :type expand: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either ProviderListResult or the result of cls(response) + :return: An iterator like instance of either Provider or the result of cls(response) :rtype: - ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.resource.resources.v2020_06_01.models.ProviderListResult] - :raises: ~azure.core.exceptions.HttpResponseError + ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.resource.resources.v2020_06_01.models.Provider] + :raises ~azure.core.exceptions.HttpResponseError: """ - api_version = kwargs.pop('api_version', "2020-06-01") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2020-06-01")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[_models.ProviderListResult] - cls = kwargs.pop('cls', None) # type: ClsType["_models.ProviderListResult"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) + def prepare_request(next_link=None): if not next_link: - + request = build_providers_list_at_tenant_scope_request( - api_version=api_version, top=top, expand=expand, - template_url=self.list_at_tenant_scope.metadata['url'], + api_version=api_version, + template_url=self.list_at_tenant_scope.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore else: - - request = build_providers_list_at_tenant_scope_request( - template_url=next_link, - ) + # make call to next link with the client's api-version + _parsed_next_link = urlparse(next_link) + _next_request_params = case_insensitive_dict(parse_qs(_parsed_next_link.query)) + _next_request_params["api-version"] = self._config.api_version + request = HttpRequest("GET", urljoin(next_link, _parsed_next_link.path), params=_next_request_params) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore request.method = "GET" return request @@ -4383,10 +5717,8 @@ async def extract_data(pipeline_response): async def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) response = pipeline_response.http_response @@ -4396,149 +5728,150 @@ async def get_next(next_link=None): return pipeline_response + return AsyncItemPaged(get_next, extract_data) - return AsyncItemPaged( - get_next, extract_data - ) - list_at_tenant_scope.metadata = {'url': "/providers"} # type: ignore + list_at_tenant_scope.metadata = {"url": "/providers"} # type: ignore @distributed_trace_async async def get( - self, - resource_provider_namespace: str, - expand: Optional[str] = None, - **kwargs: Any - ) -> "_models.Provider": + self, resource_provider_namespace: str, expand: Optional[str] = None, **kwargs: Any + ) -> _models.Provider: """Gets the specified resource provider. - :param resource_provider_namespace: The namespace of the resource provider. + :param resource_provider_namespace: The namespace of the resource provider. Required. :type resource_provider_namespace: str :param expand: The $expand query parameter. For example, to include property aliases in response, use $expand=resourceTypes/aliases. Default value is None. :type expand: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: Provider, or the result of cls(response) + :return: Provider or the result of cls(response) :rtype: ~azure.mgmt.resource.resources.v2020_06_01.models.Provider - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.Provider"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + 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', "2020-06-01") # type: str + api_version = kwargs.pop("api_version", _params.pop("api-version", "2020-06-01")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[_models.Provider] - request = build_providers_get_request( resource_provider_namespace=resource_provider_namespace, subscription_id=self._config.subscription_id, - api_version=api_version, expand=expand, - template_url=self.get.metadata['url'], + api_version=api_version, + template_url=self.get.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) - deserialized = self._deserialize('Provider', pipeline_response) + deserialized = self._deserialize("Provider", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - get.metadata = {'url': "/subscriptions/{subscriptionId}/providers/{resourceProviderNamespace}"} # type: ignore - + get.metadata = {"url": "/subscriptions/{subscriptionId}/providers/{resourceProviderNamespace}"} # type: ignore @distributed_trace_async async def get_at_tenant_scope( - self, - resource_provider_namespace: str, - expand: Optional[str] = None, - **kwargs: Any - ) -> "_models.Provider": + self, resource_provider_namespace: str, expand: Optional[str] = None, **kwargs: Any + ) -> _models.Provider: """Gets the specified resource provider at the tenant level. - :param resource_provider_namespace: The namespace of the resource provider. + :param resource_provider_namespace: The namespace of the resource provider. Required. :type resource_provider_namespace: str :param expand: The $expand query parameter. For example, to include property aliases in response, use $expand=resourceTypes/aliases. Default value is None. :type expand: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: Provider, or the result of cls(response) + :return: Provider or the result of cls(response) :rtype: ~azure.mgmt.resource.resources.v2020_06_01.models.Provider - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.Provider"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) - api_version = kwargs.pop('api_version', "2020-06-01") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2020-06-01")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[_models.Provider] - request = build_providers_get_at_tenant_scope_request( resource_provider_namespace=resource_provider_namespace, - api_version=api_version, expand=expand, - template_url=self.get_at_tenant_scope.metadata['url'], + api_version=api_version, + template_url=self.get_at_tenant_scope.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) - deserialized = self._deserialize('Provider', pipeline_response) + deserialized = self._deserialize("Provider", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - get_at_tenant_scope.metadata = {'url': "/providers/{resourceProviderNamespace}"} # type: ignore + get_at_tenant_scope.metadata = {"url": "/providers/{resourceProviderNamespace}"} # type: ignore -class ResourcesOperations: # pylint: disable=too-many-public-methods - """ResourcesOperations async operations. - You should not instantiate this class directly. Instead, you should create a Client instance that - instantiates it for you and attaches it as an attribute. +class ResourcesOperations: # pylint: disable=too-many-public-methods + """ + .. warning:: + **DO NOT** instantiate this class directly. - :ivar models: Alias to model classes used in this operation group. - :type models: ~azure.mgmt.resource.resources.v2020_06_01.models - :param client: Client for service requests. - :param config: Configuration of service client. - :param serializer: An object model serializer. - :param deserializer: An object model deserializer. + Instead, you should access the following operations through + :class:`~azure.mgmt.resource.resources.v2020_06_01.aio.ResourceManagementClient`'s + :attr:`resources` attribute. """ models = _models - def __init__(self, client, config, serializer, deserializer) -> None: - self._client = client - self._serialize = serializer - self._deserialize = deserializer - self._config = config + def __init__(self, *args, **kwargs) -> None: + input_args = list(args) + self._client = input_args.pop(0) if input_args else kwargs.pop("client") + self._config = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") @distributed_trace def list_by_resource_group( @@ -4548,10 +5881,10 @@ def list_by_resource_group( expand: Optional[str] = None, top: Optional[int] = None, **kwargs: Any - ) -> AsyncIterable["_models.ResourceListResult"]: + ) -> AsyncIterable["_models.GenericResourceExpanded"]: """Get all the resources for a resource group. - :param resource_group_name: The resource group with the resources to get. + :param resource_group_name: The resource group with the resources to get. Required. :type resource_group_name: str :param filter: The filter to apply on the operation.:code:`
`:code:`
`The properties you can use for eq (equals) or ne (not equals) are: location, resourceType, name, resourceGroup, @@ -4577,42 +5910,51 @@ def list_by_resource_group( value is None. :type top: int :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either ResourceListResult or the result of cls(response) + :return: An iterator like instance of either GenericResourceExpanded or the result of + cls(response) :rtype: - ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.resource.resources.v2020_06_01.models.ResourceListResult] - :raises: ~azure.core.exceptions.HttpResponseError + ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.resource.resources.v2020_06_01.models.GenericResourceExpanded] + :raises ~azure.core.exceptions.HttpResponseError: """ - api_version = kwargs.pop('api_version', "2020-06-01") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2020-06-01")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[_models.ResourceListResult] - cls = kwargs.pop('cls', None) # type: ClsType["_models.ResourceListResult"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) + def prepare_request(next_link=None): if not next_link: - + request = build_resources_list_by_resource_group_request( resource_group_name=resource_group_name, subscription_id=self._config.subscription_id, - api_version=api_version, filter=filter, expand=expand, top=top, - template_url=self.list_by_resource_group.metadata['url'], + 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.url = self._client.format_url(request.url) # type: ignore else: - - request = build_resources_list_by_resource_group_request( - resource_group_name=resource_group_name, - subscription_id=self._config.subscription_id, - template_url=next_link, - ) + # make call to next link with the client's api-version + _parsed_next_link = urlparse(next_link) + _next_request_params = case_insensitive_dict(parse_qs(_parsed_next_link.query)) + _next_request_params["api-version"] = self._config.api_version + request = HttpRequest("GET", urljoin(next_link, _parsed_next_link.path), params=_next_request_params) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore request.method = "GET" return request @@ -4626,10 +5968,8 @@ async def extract_data(pipeline_response): async def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) response = pipeline_response.http_response @@ -4639,45 +5979,54 @@ async def get_next(next_link=None): return pipeline_response + return AsyncItemPaged(get_next, extract_data) - return AsyncItemPaged( - get_next, extract_data - ) - list_by_resource_group.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/resources"} # type: ignore + list_by_resource_group.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/resources"} # type: ignore async def _move_resources_initial( # pylint: disable=inconsistent-return-statements - self, - source_resource_group_name: str, - parameters: "_models.ResourcesMoveInfo", - **kwargs: Any + self, source_resource_group_name: str, parameters: Union[_models.ResourcesMoveInfo, IO], **kwargs: Any ) -> None: - cls = kwargs.pop('cls', None) # type: ClsType[None] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) - api_version = kwargs.pop('api_version', "2020-06-01") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - _json = self._serialize.body(parameters, 'ResourcesMoveInfo') + api_version = kwargs.pop("api_version", _params.pop("api-version", "2020-06-01")) # type: str + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[None] - request = build_resources_move_resources_request_initial( + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(parameters, (IO, bytes)): + _content = parameters + else: + _json = self._serialize.body(parameters, "ResourcesMoveInfo") + + request = build_resources_move_resources_request( source_resource_group_name=source_resource_group_name, subscription_id=self._config.subscription_id, api_version=api_version, content_type=content_type, json=_json, - template_url=self._move_resources_initial.metadata['url'], + content=_content, + template_url=self._move_resources_initial.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [202, 204]: @@ -4687,14 +6036,15 @@ async def _move_resources_initial( # pylint: disable=inconsistent-return-statem if cls: return cls(pipeline_response, None, {}) - _move_resources_initial.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{sourceResourceGroupName}/moveResources"} # type: ignore + _move_resources_initial.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{sourceResourceGroupName}/moveResources"} # type: ignore - - @distributed_trace_async - async def begin_move_resources( # pylint: disable=inconsistent-return-statements + @overload + async def begin_move_resources( self, source_resource_group_name: str, - parameters: "_models.ResourcesMoveInfo", + parameters: _models.ResourcesMoveInfo, + *, + content_type: str = "application/json", **kwargs: Any ) -> AsyncLROPoller[None]: """Moves resources from one resource group to another resource group. @@ -4705,10 +6055,13 @@ async def begin_move_resources( # pylint: disable=inconsistent-return-statement the groups until the move completes. :param source_resource_group_name: The name of the resource group containing the resources to - move. + move. Required. :type source_resource_group_name: str - :param parameters: Parameters for moving resources. + :param parameters: Parameters for moving resources. Required. :type parameters: ~azure.mgmt.resource.resources.v2020_06_01.models.ResourcesMoveInfo + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str :keyword callable cls: A custom type or function that will be passed the direct response :keyword str continuation_token: A continuation token to restart a poller from a saved state. :keyword polling: By default, your polling method will be AsyncARMPolling. Pass in False for @@ -4719,80 +6072,160 @@ async def begin_move_resources( # pylint: disable=inconsistent-return-statement Retry-After header is present. :return: An instance of AsyncLROPoller that returns either None or the result of cls(response) :rtype: ~azure.core.polling.AsyncLROPoller[None] - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - api_version = kwargs.pop('api_version', "2020-06-01") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] - polling = kwargs.pop('polling', True) # type: Union[bool, AsyncPollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType[None] - lro_delay = kwargs.pop( - 'polling_interval', - self._config.polling_interval - ) - cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] - if cont_token is None: - raw_result = await self._move_resources_initial( - source_resource_group_name=source_resource_group_name, - parameters=parameters, - api_version=api_version, - content_type=content_type, - cls=lambda x,y,z: x, - **kwargs - ) - kwargs.pop('error_map', None) - - def get_long_running_output(pipeline_response): - if cls: - return cls(pipeline_response, None, {}) + @overload + async def begin_move_resources( + self, source_resource_group_name: str, parameters: IO, *, content_type: str = "application/json", **kwargs: Any + ) -> AsyncLROPoller[None]: + """Moves resources from one resource group to another resource group. - if polling is True: polling_method = AsyncARMPolling(lro_delay, **kwargs) - elif polling is False: polling_method = AsyncNoPolling() - else: polling_method = polling - if cont_token: - return AsyncLROPoller.from_continuation_token( - polling_method=polling_method, - continuation_token=cont_token, - client=self._client, - deserialization_callback=get_long_running_output - ) - return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) - - begin_move_resources.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{sourceResourceGroupName}/moveResources"} # type: ignore + The resources to move must be in the same source resource group. The target resource group may + be in a different subscription. When moving resources, both the source group and the target + group are locked for the duration of the operation. Write and delete operations are blocked on + the groups until the move completes. - async def _validate_move_resources_initial( # pylint: disable=inconsistent-return-statements - self, - source_resource_group_name: str, - parameters: "_models.ResourcesMoveInfo", - **kwargs: Any + :param source_resource_group_name: The name of the resource group containing the resources to + move. Required. + :type source_resource_group_name: str + :param parameters: Parameters for moving resources. Required. + :type parameters: IO + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be AsyncARMPolling. Pass in False for + this operation to not poll, or pass in your own initialized polling object for a personal + polling strategy. + :paramtype polling: bool or ~azure.core.polling.AsyncPollingMethod + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of AsyncLROPoller that returns either None or the result of cls(response) + :rtype: ~azure.core.polling.AsyncLROPoller[None] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace_async + async def begin_move_resources( + self, source_resource_group_name: str, parameters: Union[_models.ResourcesMoveInfo, IO], **kwargs: Any + ) -> AsyncLROPoller[None]: + """Moves resources from one resource group to another resource group. + + The resources to move must be in the same source resource group. The target resource group may + be in a different subscription. When moving resources, both the source group and the target + group are locked for the duration of the operation. Write and delete operations are blocked on + the groups until the move completes. + + :param source_resource_group_name: The name of the resource group containing the resources to + move. Required. + :type source_resource_group_name: str + :param parameters: Parameters for moving resources. Is either a model type or a IO type. + Required. + :type parameters: ~azure.mgmt.resource.resources.v2020_06_01.models.ResourcesMoveInfo or IO + :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. + Default value is None. + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be AsyncARMPolling. Pass in False for + this operation to not poll, or pass in your own initialized polling object for a personal + polling strategy. + :paramtype polling: bool or ~azure.core.polling.AsyncPollingMethod + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of AsyncLROPoller that returns either None or the result of cls(response) + :rtype: ~azure.core.polling.AsyncLROPoller[None] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _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", "2020-06-01")) # type: str + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[None] + polling = kwargs.pop("polling", True) # type: Union[bool, AsyncPollingMethod] + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token = kwargs.pop("continuation_token", None) # type: Optional[str] + if cont_token is None: + raw_result = await self._move_resources_initial( # type: ignore + source_resource_group_name=source_resource_group_name, + parameters=parameters, + api_version=api_version, + content_type=content_type, + cls=lambda x, y, z: x, + headers=_headers, + params=_params, + **kwargs + ) + kwargs.pop("error_map", None) + + def get_long_running_output(pipeline_response): # pylint: disable=inconsistent-return-statements + if cls: + return cls(pipeline_response, None, {}) + + if polling is True: + polling_method = cast(AsyncPollingMethod, AsyncARMPolling(lro_delay, **kwargs)) # type: AsyncPollingMethod + elif polling is False: + polling_method = cast(AsyncPollingMethod, AsyncNoPolling()) + else: + polling_method = polling + if cont_token: + return AsyncLROPoller.from_continuation_token( + polling_method=polling_method, + continuation_token=cont_token, + client=self._client, + deserialization_callback=get_long_running_output, + ) + return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) + + begin_move_resources.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{sourceResourceGroupName}/moveResources"} # type: ignore + + async def _validate_move_resources_initial( # pylint: disable=inconsistent-return-statements + self, source_resource_group_name: str, parameters: Union[_models.ResourcesMoveInfo, IO], **kwargs: Any ) -> None: - cls = kwargs.pop('cls', None) # type: ClsType[None] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) - api_version = kwargs.pop('api_version', "2020-06-01") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - _json = self._serialize.body(parameters, 'ResourcesMoveInfo') + api_version = kwargs.pop("api_version", _params.pop("api-version", "2020-06-01")) # type: str + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[None] - request = build_resources_validate_move_resources_request_initial( + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(parameters, (IO, bytes)): + _content = parameters + else: + _json = self._serialize.body(parameters, "ResourcesMoveInfo") + + request = build_resources_validate_move_resources_request( source_resource_group_name=source_resource_group_name, subscription_id=self._config.subscription_id, api_version=api_version, content_type=content_type, json=_json, - template_url=self._validate_move_resources_initial.metadata['url'], + content=_content, + template_url=self._validate_move_resources_initial.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [202, 204]: @@ -4802,14 +6235,15 @@ async def _validate_move_resources_initial( # pylint: disable=inconsistent-retu if cls: return cls(pipeline_response, None, {}) - _validate_move_resources_initial.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{sourceResourceGroupName}/validateMoveResources"} # type: ignore + _validate_move_resources_initial.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{sourceResourceGroupName}/validateMoveResources"} # type: ignore - - @distributed_trace_async - async def begin_validate_move_resources( # pylint: disable=inconsistent-return-statements + @overload + async def begin_validate_move_resources( self, source_resource_group_name: str, - parameters: "_models.ResourcesMoveInfo", + parameters: _models.ResourcesMoveInfo, + *, + content_type: str = "application/json", **kwargs: Any ) -> AsyncLROPoller[None]: """Validates whether resources can be moved from one resource group to another resource group. @@ -4822,10 +6256,13 @@ async def begin_validate_move_resources( # pylint: disable=inconsistent-return- operation. :param source_resource_group_name: The name of the resource group containing the resources to - validate for move. + validate for move. Required. :type source_resource_group_name: str - :param parameters: Parameters for moving resources. + :param parameters: Parameters for moving resources. Required. :type parameters: ~azure.mgmt.resource.resources.v2020_06_01.models.ResourcesMoveInfo + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str :keyword callable cls: A custom type or function that will be passed the direct response :keyword str continuation_token: A continuation token to restart a poller from a saved state. :keyword polling: By default, your polling method will be AsyncARMPolling. Pass in False for @@ -4836,55 +6273,124 @@ async def begin_validate_move_resources( # pylint: disable=inconsistent-return- Retry-After header is present. :return: An instance of AsyncLROPoller that returns either None or the result of cls(response) :rtype: ~azure.core.polling.AsyncLROPoller[None] - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - api_version = kwargs.pop('api_version', "2020-06-01") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] - polling = kwargs.pop('polling', True) # type: Union[bool, AsyncPollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType[None] - lro_delay = kwargs.pop( - 'polling_interval', - self._config.polling_interval - ) - cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] + + @overload + async def begin_validate_move_resources( + self, source_resource_group_name: str, parameters: IO, *, content_type: str = "application/json", **kwargs: Any + ) -> AsyncLROPoller[None]: + """Validates whether resources can be moved from one resource group to another resource group. + + This operation checks whether the specified resources can be moved to the target. The resources + to move must be in the same source resource group. The target resource group may be in a + different subscription. If validation succeeds, it returns HTTP response code 204 (no content). + If validation fails, it returns HTTP response code 409 (Conflict) with an error message. + Retrieve the URL in the Location header value to check the result of the long-running + operation. + + :param source_resource_group_name: The name of the resource group containing the resources to + validate for move. Required. + :type source_resource_group_name: str + :param parameters: Parameters for moving resources. Required. + :type parameters: IO + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be AsyncARMPolling. Pass in False for + this operation to not poll, or pass in your own initialized polling object for a personal + polling strategy. + :paramtype polling: bool or ~azure.core.polling.AsyncPollingMethod + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of AsyncLROPoller that returns either None or the result of cls(response) + :rtype: ~azure.core.polling.AsyncLROPoller[None] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace_async + async def begin_validate_move_resources( + self, source_resource_group_name: str, parameters: Union[_models.ResourcesMoveInfo, IO], **kwargs: Any + ) -> AsyncLROPoller[None]: + """Validates whether resources can be moved from one resource group to another resource group. + + This operation checks whether the specified resources can be moved to the target. The resources + to move must be in the same source resource group. The target resource group may be in a + different subscription. If validation succeeds, it returns HTTP response code 204 (no content). + If validation fails, it returns HTTP response code 409 (Conflict) with an error message. + Retrieve the URL in the Location header value to check the result of the long-running + operation. + + :param source_resource_group_name: The name of the resource group containing the resources to + validate for move. Required. + :type source_resource_group_name: str + :param parameters: Parameters for moving resources. Is either a model type or a IO type. + Required. + :type parameters: ~azure.mgmt.resource.resources.v2020_06_01.models.ResourcesMoveInfo or IO + :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. + Default value is None. + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be AsyncARMPolling. Pass in False for + this operation to not poll, or pass in your own initialized polling object for a personal + polling strategy. + :paramtype polling: bool or ~azure.core.polling.AsyncPollingMethod + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of AsyncLROPoller that returns either None or the result of cls(response) + :rtype: ~azure.core.polling.AsyncLROPoller[None] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _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", "2020-06-01")) # type: str + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[None] + polling = kwargs.pop("polling", True) # type: Union[bool, AsyncPollingMethod] + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token = kwargs.pop("continuation_token", None) # type: Optional[str] if cont_token is None: - raw_result = await self._validate_move_resources_initial( + raw_result = await self._validate_move_resources_initial( # type: ignore source_resource_group_name=source_resource_group_name, parameters=parameters, api_version=api_version, content_type=content_type, - cls=lambda x,y,z: x, + cls=lambda x, y, z: x, + headers=_headers, + params=_params, **kwargs ) - kwargs.pop('error_map', None) + kwargs.pop("error_map", None) - def get_long_running_output(pipeline_response): + def get_long_running_output(pipeline_response): # pylint: disable=inconsistent-return-statements if cls: return cls(pipeline_response, None, {}) - - if polling is True: polling_method = AsyncARMPolling(lro_delay, **kwargs) - elif polling is False: polling_method = AsyncNoPolling() - else: polling_method = polling + if polling is True: + polling_method = cast(AsyncPollingMethod, AsyncARMPolling(lro_delay, **kwargs)) # type: AsyncPollingMethod + elif polling is False: + polling_method = cast(AsyncPollingMethod, AsyncNoPolling()) + else: + polling_method = polling if cont_token: return AsyncLROPoller.from_continuation_token( polling_method=polling_method, continuation_token=cont_token, client=self._client, - deserialization_callback=get_long_running_output + deserialization_callback=get_long_running_output, ) return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) - begin_validate_move_resources.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{sourceResourceGroupName}/validateMoveResources"} # type: ignore + begin_validate_move_resources.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{sourceResourceGroupName}/validateMoveResources"} # type: ignore @distributed_trace def list( - self, - filter: Optional[str] = None, - expand: Optional[str] = None, - top: Optional[int] = None, - **kwargs: Any - ) -> AsyncIterable["_models.ResourceListResult"]: + self, filter: Optional[str] = None, expand: Optional[str] = None, top: Optional[int] = None, **kwargs: Any + ) -> AsyncIterable["_models.GenericResourceExpanded"]: """Get all the resources in a subscription. :param filter: The filter to apply on the operation.:code:`
`:code:`
`The properties you @@ -4911,40 +6417,50 @@ def list( value is None. :type top: int :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either ResourceListResult or the result of cls(response) + :return: An iterator like instance of either GenericResourceExpanded or the result of + cls(response) :rtype: - ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.resource.resources.v2020_06_01.models.ResourceListResult] - :raises: ~azure.core.exceptions.HttpResponseError + ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.resource.resources.v2020_06_01.models.GenericResourceExpanded] + :raises ~azure.core.exceptions.HttpResponseError: """ - api_version = kwargs.pop('api_version', "2020-06-01") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2020-06-01")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[_models.ResourceListResult] - cls = kwargs.pop('cls', None) # type: ClsType["_models.ResourceListResult"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) + def prepare_request(next_link=None): if not next_link: - + request = build_resources_list_request( subscription_id=self._config.subscription_id, - api_version=api_version, filter=filter, expand=expand, top=top, - template_url=self.list.metadata['url'], + 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.url = self._client.format_url(request.url) # type: ignore else: - - request = build_resources_list_request( - subscription_id=self._config.subscription_id, - template_url=next_link, - ) + # make call to next link with the client's api-version + _parsed_next_link = urlparse(next_link) + _next_request_params = case_insensitive_dict(parse_qs(_parsed_next_link.query)) + _next_request_params["api-version"] = self._config.api_version + request = HttpRequest("GET", urljoin(next_link, _parsed_next_link.path), params=_next_request_params) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore request.method = "GET" return request @@ -4958,10 +6474,8 @@ async def extract_data(pipeline_response): async def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) response = pipeline_response.http_response @@ -4971,11 +6485,9 @@ async def get_next(next_link=None): return pipeline_response + return AsyncItemPaged(get_next, extract_data) - return AsyncItemPaged( - get_next, extract_data - ) - list.metadata = {'url': "/subscriptions/{subscriptionId}/resources"} # type: ignore + list.metadata = {"url": "/subscriptions/{subscriptionId}/resources"} # type: ignore @distributed_trace_async async def check_existence( @@ -4991,30 +6503,36 @@ async def check_existence( """Checks whether a resource exists. :param resource_group_name: The name of the resource group containing the resource to check. - The name is case insensitive. + The name is case insensitive. Required. :type resource_group_name: str - :param resource_provider_namespace: The resource provider of the resource to check. + :param resource_provider_namespace: The resource provider of the resource to check. Required. :type resource_provider_namespace: str - :param parent_resource_path: The parent resource identity. + :param parent_resource_path: The parent resource identity. Required. :type parent_resource_path: str - :param resource_type: The resource type. + :param resource_type: The resource type. Required. :type resource_type: str - :param resource_name: The name of the resource to check whether it exists. + :param resource_name: The name of the resource to check whether it exists. Required. :type resource_name: str - :param api_version: The API version to use for the operation. + :param api_version: The API version to use for the operation. Required. :type api_version: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: bool, or the result of cls(response) + :return: bool or the result of cls(response) :rtype: bool - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType[None] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = kwargs.pop("params", {}) or {} + + cls = kwargs.pop("cls", None) # type: ClsType[None] - request = build_resources_check_existence_request( resource_group_name=resource_group_name, resource_provider_namespace=resource_provider_namespace, @@ -5023,16 +6541,17 @@ async def check_existence( resource_name=resource_name, subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.check_existence.metadata['url'], + template_url=self.check_existence.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [204, 404]: @@ -5043,8 +6562,7 @@ async def check_existence( return cls(pipeline_response, None, {}) return 200 <= response.status_code <= 299 - check_existence.metadata = {'url': "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{parentResourcePath}/{resourceType}/{resourceName}"} # type: ignore - + check_existence.metadata = {"url": "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{parentResourcePath}/{resourceType}/{resourceName}"} # type: ignore async def _delete_initial( # pylint: disable=inconsistent-return-statements self, @@ -5056,14 +6574,20 @@ async def _delete_initial( # pylint: disable=inconsistent-return-statements api_version: str, **kwargs: Any ) -> None: - cls = kwargs.pop('cls', None) # type: ClsType[None] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = kwargs.pop("params", {}) or {} - - request = build_resources_delete_request_initial( + cls = kwargs.pop("cls", None) # type: ClsType[None] + + request = build_resources_delete_request( resource_group_name=resource_group_name, resource_provider_namespace=resource_provider_namespace, parent_resource_path=parent_resource_path, @@ -5071,16 +6595,17 @@ async def _delete_initial( # pylint: disable=inconsistent-return-statements resource_name=resource_name, subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self._delete_initial.metadata['url'], + template_url=self._delete_initial.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200, 202, 204]: @@ -5090,11 +6615,10 @@ 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/{resourceProviderNamespace}/{parentResourcePath}/{resourceType}/{resourceName}"} # type: ignore - + _delete_initial.metadata = {"url": "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{parentResourcePath}/{resourceType}/{resourceName}"} # type: ignore @distributed_trace_async - async def begin_delete( # pylint: disable=inconsistent-return-statements + async def begin_delete( self, resource_group_name: str, resource_provider_namespace: str, @@ -5107,17 +6631,17 @@ async def begin_delete( # pylint: disable=inconsistent-return-statements """Deletes a resource. :param resource_group_name: The name of the resource group that contains the resource to - delete. The name is case insensitive. + delete. The name is case insensitive. Required. :type resource_group_name: str - :param resource_provider_namespace: The namespace of the resource provider. + :param resource_provider_namespace: The namespace of the resource provider. Required. :type resource_provider_namespace: str - :param parent_resource_path: The parent resource identity. + :param parent_resource_path: The parent resource identity. Required. :type parent_resource_path: str - :param resource_type: The resource type. + :param resource_type: The resource type. Required. :type resource_type: str - :param resource_name: The name of the resource to delete. + :param resource_name: The name of the resource to delete. Required. :type resource_name: str - :param api_version: The API version to use for the operation. + :param api_version: The API version to use for the operation. Required. :type api_version: str :keyword callable cls: A custom type or function that will be passed the direct response :keyword str continuation_token: A continuation token to restart a poller from a saved state. @@ -5129,46 +6653,50 @@ async def begin_delete( # pylint: disable=inconsistent-return-statements Retry-After header is present. :return: An instance of AsyncLROPoller that returns either None or the result of cls(response) :rtype: ~azure.core.polling.AsyncLROPoller[None] - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - polling = kwargs.pop('polling', True) # type: Union[bool, AsyncPollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType[None] - lro_delay = kwargs.pop( - 'polling_interval', - self._config.polling_interval - ) - cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] + _headers = kwargs.pop("headers", {}) or {} + _params = kwargs.pop("params", {}) or {} + + cls = kwargs.pop("cls", None) # type: ClsType[None] + polling = kwargs.pop("polling", True) # type: Union[bool, AsyncPollingMethod] + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token = kwargs.pop("continuation_token", None) # type: Optional[str] if cont_token is None: - raw_result = await self._delete_initial( + raw_result = await self._delete_initial( # type: ignore resource_group_name=resource_group_name, resource_provider_namespace=resource_provider_namespace, parent_resource_path=parent_resource_path, resource_type=resource_type, resource_name=resource_name, api_version=api_version, - cls=lambda x,y,z: x, + cls=lambda x, y, z: x, + headers=_headers, + params=_params, **kwargs ) - kwargs.pop('error_map', None) + kwargs.pop("error_map", None) - def get_long_running_output(pipeline_response): + def get_long_running_output(pipeline_response): # pylint: disable=inconsistent-return-statements if cls: return cls(pipeline_response, None, {}) - - if polling is True: polling_method = AsyncARMPolling(lro_delay, **kwargs) - elif polling is False: polling_method = AsyncNoPolling() - else: polling_method = polling + if polling is True: + polling_method = cast(AsyncPollingMethod, AsyncARMPolling(lro_delay, **kwargs)) # type: AsyncPollingMethod + elif polling is False: + polling_method = cast(AsyncPollingMethod, AsyncNoPolling()) + else: + polling_method = polling if cont_token: return AsyncLROPoller.from_continuation_token( polling_method=polling_method, continuation_token=cont_token, client=self._client, - deserialization_callback=get_long_running_output + deserialization_callback=get_long_running_output, ) return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) - begin_delete.metadata = {'url': "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{parentResourcePath}/{resourceType}/{resourceName}"} # type: ignore + begin_delete.metadata = {"url": "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{parentResourcePath}/{resourceType}/{resourceName}"} # type: ignore async def _create_or_update_initial( self, @@ -5178,39 +6706,53 @@ async def _create_or_update_initial( resource_type: str, resource_name: str, api_version: str, - parameters: "_models.GenericResource", + parameters: Union[_models.GenericResource, IO], **kwargs: Any - ) -> Optional["_models.GenericResource"]: - cls = kwargs.pop('cls', None) # type: ClsType[Optional["_models.GenericResource"]] + ) -> Optional[_models.GenericResource]: error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = kwargs.pop("params", {}) or {} - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[Optional[_models.GenericResource]] - _json = self._serialize.body(parameters, 'GenericResource') + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(parameters, (IO, bytes)): + _content = parameters + else: + _json = self._serialize.body(parameters, "GenericResource") - request = build_resources_create_or_update_request_initial( + request = build_resources_create_or_update_request( resource_group_name=resource_group_name, resource_provider_namespace=resource_provider_namespace, parent_resource_path=parent_resource_path, resource_type=resource_type, resource_name=resource_name, subscription_id=self._config.subscription_id, - content_type=content_type, api_version=api_version, + content_type=content_type, json=_json, - template_url=self._create_or_update_initial.metadata['url'], + content=_content, + template_url=self._create_or_update_initial.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200, 201, 202]: @@ -5219,18 +6761,115 @@ async def _create_or_update_initial( deserialized = None if response.status_code == 200: - deserialized = self._deserialize('GenericResource', pipeline_response) + deserialized = self._deserialize("GenericResource", pipeline_response) if response.status_code == 201: - deserialized = self._deserialize('GenericResource', pipeline_response) + deserialized = self._deserialize("GenericResource", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - _create_or_update_initial.metadata = {'url': "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{parentResourcePath}/{resourceType}/{resourceName}"} # type: ignore + _create_or_update_initial.metadata = {"url": "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{parentResourcePath}/{resourceType}/{resourceName}"} # type: ignore + + @overload + async def begin_create_or_update( + self, + resource_group_name: str, + resource_provider_namespace: str, + parent_resource_path: str, + resource_type: str, + resource_name: str, + api_version: str, + parameters: _models.GenericResource, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> AsyncLROPoller[_models.GenericResource]: + """Creates a resource. + + :param resource_group_name: The name of the resource group for the resource. The name is case + insensitive. Required. + :type resource_group_name: str + :param resource_provider_namespace: The namespace of the resource provider. Required. + :type resource_provider_namespace: str + :param parent_resource_path: The parent resource identity. Required. + :type parent_resource_path: str + :param resource_type: The resource type of the resource to create. Required. + :type resource_type: str + :param resource_name: The name of the resource to create. Required. + :type resource_name: str + :param api_version: The API version to use for the operation. Required. + :type api_version: str + :param parameters: Parameters for creating or updating the resource. Required. + :type parameters: ~azure.mgmt.resource.resources.v2020_06_01.models.GenericResource + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be AsyncARMPolling. Pass in False for + this operation to not poll, or pass in your own initialized polling object for a personal + polling strategy. + :paramtype polling: bool or ~azure.core.polling.AsyncPollingMethod + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of AsyncLROPoller that returns either GenericResource or the result of + cls(response) + :rtype: + ~azure.core.polling.AsyncLROPoller[~azure.mgmt.resource.resources.v2020_06_01.models.GenericResource] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + async def begin_create_or_update( + self, + resource_group_name: str, + resource_provider_namespace: str, + parent_resource_path: str, + resource_type: str, + resource_name: str, + api_version: str, + parameters: IO, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> AsyncLROPoller[_models.GenericResource]: + """Creates a resource. + :param resource_group_name: The name of the resource group for the resource. The name is case + insensitive. Required. + :type resource_group_name: str + :param resource_provider_namespace: The namespace of the resource provider. Required. + :type resource_provider_namespace: str + :param parent_resource_path: The parent resource identity. Required. + :type parent_resource_path: str + :param resource_type: The resource type of the resource to create. Required. + :type resource_type: str + :param resource_name: The name of the resource to create. Required. + :type resource_name: str + :param api_version: The API version to use for the operation. Required. + :type api_version: str + :param parameters: Parameters for creating or updating the resource. Required. + :type parameters: IO + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be AsyncARMPolling. Pass in False for + this operation to not poll, or pass in your own initialized polling object for a personal + polling strategy. + :paramtype polling: bool or ~azure.core.polling.AsyncPollingMethod + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of AsyncLROPoller that returns either GenericResource or the result of + cls(response) + :rtype: + ~azure.core.polling.AsyncLROPoller[~azure.mgmt.resource.resources.v2020_06_01.models.GenericResource] + :raises ~azure.core.exceptions.HttpResponseError: + """ @distributed_trace_async async def begin_create_or_update( @@ -5241,26 +6880,30 @@ async def begin_create_or_update( resource_type: str, resource_name: str, api_version: str, - parameters: "_models.GenericResource", + parameters: Union[_models.GenericResource, IO], **kwargs: Any - ) -> AsyncLROPoller["_models.GenericResource"]: + ) -> AsyncLROPoller[_models.GenericResource]: """Creates a resource. :param resource_group_name: The name of the resource group for the resource. The name is case - insensitive. + insensitive. Required. :type resource_group_name: str - :param resource_provider_namespace: The namespace of the resource provider. + :param resource_provider_namespace: The namespace of the resource provider. Required. :type resource_provider_namespace: str - :param parent_resource_path: The parent resource identity. + :param parent_resource_path: The parent resource identity. Required. :type parent_resource_path: str - :param resource_type: The resource type of the resource to create. + :param resource_type: The resource type of the resource to create. Required. :type resource_type: str - :param resource_name: The name of the resource to create. + :param resource_name: The name of the resource to create. Required. :type resource_name: str - :param api_version: The API version to use for the operation. + :param api_version: The API version to use for the operation. Required. :type api_version: str - :param parameters: Parameters for creating or updating the resource. - :type parameters: ~azure.mgmt.resource.resources.v2020_06_01.models.GenericResource + :param parameters: Parameters for creating or updating the resource. Is either a model type or + a IO type. Required. + :type parameters: ~azure.mgmt.resource.resources.v2020_06_01.models.GenericResource or IO + :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. + Default value is None. + :paramtype content_type: str :keyword callable cls: A custom type or function that will be passed the direct response :keyword str continuation_token: A continuation token to restart a poller from a saved state. :keyword polling: By default, your polling method will be AsyncARMPolling. Pass in False for @@ -5273,18 +6916,18 @@ async def begin_create_or_update( cls(response) :rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.resource.resources.v2020_06_01.models.GenericResource] - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] - polling = kwargs.pop('polling', True) # type: Union[bool, AsyncPollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType["_models.GenericResource"] - lro_delay = kwargs.pop( - 'polling_interval', - self._config.polling_interval - ) - cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = kwargs.pop("params", {}) or {} + + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.GenericResource] + polling = kwargs.pop("polling", True) # type: Union[bool, AsyncPollingMethod] + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token = kwargs.pop("continuation_token", None) # type: Optional[str] if cont_token is None: - raw_result = await self._create_or_update_initial( + raw_result = await self._create_or_update_initial( # type: ignore resource_group_name=resource_group_name, resource_provider_namespace=resource_provider_namespace, parent_resource_path=parent_resource_path, @@ -5293,32 +6936,35 @@ async def begin_create_or_update( api_version=api_version, parameters=parameters, content_type=content_type, - cls=lambda x,y,z: x, + cls=lambda x, y, z: x, + headers=_headers, + params=_params, **kwargs ) - kwargs.pop('error_map', None) + kwargs.pop("error_map", None) def get_long_running_output(pipeline_response): - response = pipeline_response.http_response - deserialized = self._deserialize('GenericResource', pipeline_response) + deserialized = self._deserialize("GenericResource", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - - if polling is True: polling_method = AsyncARMPolling(lro_delay, **kwargs) - elif polling is False: polling_method = AsyncNoPolling() - else: polling_method = polling + if polling is True: + polling_method = cast(AsyncPollingMethod, AsyncARMPolling(lro_delay, **kwargs)) # type: AsyncPollingMethod + elif polling is False: + polling_method = cast(AsyncPollingMethod, AsyncNoPolling()) + else: + polling_method = polling if cont_token: return AsyncLROPoller.from_continuation_token( polling_method=polling_method, continuation_token=cont_token, client=self._client, - deserialization_callback=get_long_running_output + deserialization_callback=get_long_running_output, ) return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) - begin_create_or_update.metadata = {'url': "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{parentResourcePath}/{resourceType}/{resourceName}"} # type: ignore + begin_create_or_update.metadata = {"url": "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{parentResourcePath}/{resourceType}/{resourceName}"} # type: ignore async def _update_initial( self, @@ -5328,39 +6974,53 @@ async def _update_initial( resource_type: str, resource_name: str, api_version: str, - parameters: "_models.GenericResource", + parameters: Union[_models.GenericResource, IO], **kwargs: Any - ) -> Optional["_models.GenericResource"]: - cls = kwargs.pop('cls', None) # type: ClsType[Optional["_models.GenericResource"]] + ) -> Optional[_models.GenericResource]: error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = kwargs.pop("params", {}) or {} - _json = self._serialize.body(parameters, 'GenericResource') + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[Optional[_models.GenericResource]] - request = build_resources_update_request_initial( + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(parameters, (IO, bytes)): + _content = parameters + else: + _json = self._serialize.body(parameters, "GenericResource") + + request = build_resources_update_request( resource_group_name=resource_group_name, resource_provider_namespace=resource_provider_namespace, parent_resource_path=parent_resource_path, resource_type=resource_type, resource_name=resource_name, subscription_id=self._config.subscription_id, - content_type=content_type, api_version=api_version, + content_type=content_type, json=_json, - template_url=self._update_initial.metadata['url'], + content=_content, + template_url=self._update_initial.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200, 202]: @@ -5369,17 +7029,16 @@ async def _update_initial( deserialized = None if response.status_code == 200: - deserialized = self._deserialize('GenericResource', pipeline_response) + deserialized = self._deserialize("GenericResource", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - _update_initial.metadata = {'url': "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{parentResourcePath}/{resourceType}/{resourceName}"} # type: ignore + _update_initial.metadata = {"url": "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{parentResourcePath}/{resourceType}/{resourceName}"} # type: ignore - - @distributed_trace_async + @overload async def begin_update( self, resource_group_name: str, @@ -5388,26 +7047,31 @@ async def begin_update( resource_type: str, resource_name: str, api_version: str, - parameters: "_models.GenericResource", + parameters: _models.GenericResource, + *, + content_type: str = "application/json", **kwargs: Any - ) -> AsyncLROPoller["_models.GenericResource"]: + ) -> AsyncLROPoller[_models.GenericResource]: """Updates a resource. :param resource_group_name: The name of the resource group for the resource. The name is case - insensitive. + insensitive. Required. :type resource_group_name: str - :param resource_provider_namespace: The namespace of the resource provider. + :param resource_provider_namespace: The namespace of the resource provider. Required. :type resource_provider_namespace: str - :param parent_resource_path: The parent resource identity. + :param parent_resource_path: The parent resource identity. Required. :type parent_resource_path: str - :param resource_type: The resource type of the resource to update. + :param resource_type: The resource type of the resource to update. Required. :type resource_type: str - :param resource_name: The name of the resource to update. + :param resource_name: The name of the resource to update. Required. :type resource_name: str - :param api_version: The API version to use for the operation. + :param api_version: The API version to use for the operation. Required. :type api_version: str - :param parameters: Parameters for updating the resource. + :param parameters: Parameters for updating the resource. Required. :type parameters: ~azure.mgmt.resource.resources.v2020_06_01.models.GenericResource + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str :keyword callable cls: A custom type or function that will be passed the direct response :keyword str continuation_token: A continuation token to restart a poller from a saved state. :keyword polling: By default, your polling method will be AsyncARMPolling. Pass in False for @@ -5420,55 +7084,11 @@ async def begin_update( cls(response) :rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.resource.resources.v2020_06_01.models.GenericResource] - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] - polling = kwargs.pop('polling', True) # type: Union[bool, AsyncPollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType["_models.GenericResource"] - lro_delay = kwargs.pop( - 'polling_interval', - self._config.polling_interval - ) - cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] - if cont_token is None: - raw_result = await self._update_initial( - resource_group_name=resource_group_name, - resource_provider_namespace=resource_provider_namespace, - parent_resource_path=parent_resource_path, - resource_type=resource_type, - resource_name=resource_name, - api_version=api_version, - parameters=parameters, - content_type=content_type, - cls=lambda x,y,z: x, - **kwargs - ) - kwargs.pop('error_map', None) - - def get_long_running_output(pipeline_response): - response = pipeline_response.http_response - deserialized = self._deserialize('GenericResource', pipeline_response) - if cls: - return cls(pipeline_response, deserialized, {}) - return deserialized - - - if polling is True: polling_method = AsyncARMPolling(lro_delay, **kwargs) - elif polling is False: polling_method = AsyncNoPolling() - else: polling_method = polling - if cont_token: - return AsyncLROPoller.from_continuation_token( - polling_method=polling_method, - continuation_token=cont_token, - client=self._client, - deserialization_callback=get_long_running_output - ) - return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) - - begin_update.metadata = {'url': "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{parentResourcePath}/{resourceType}/{resourceName}"} # type: ignore - @distributed_trace_async - async def get( + @overload + async def begin_update( self, resource_group_name: str, resource_provider_namespace: str, @@ -5476,35 +7096,185 @@ async def get( resource_type: str, resource_name: str, api_version: str, + parameters: IO, + *, + content_type: str = "application/json", **kwargs: Any - ) -> "_models.GenericResource": - """Gets a resource. + ) -> AsyncLROPoller[_models.GenericResource]: + """Updates a resource. + + :param resource_group_name: The name of the resource group for the resource. The name is case + insensitive. Required. + :type resource_group_name: str + :param resource_provider_namespace: The namespace of the resource provider. Required. + :type resource_provider_namespace: str + :param parent_resource_path: The parent resource identity. Required. + :type parent_resource_path: str + :param resource_type: The resource type of the resource to update. Required. + :type resource_type: str + :param resource_name: The name of the resource to update. Required. + :type resource_name: str + :param api_version: The API version to use for the operation. Required. + :type api_version: str + :param parameters: Parameters for updating the resource. Required. + :type parameters: IO + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be AsyncARMPolling. Pass in False for + this operation to not poll, or pass in your own initialized polling object for a personal + polling strategy. + :paramtype polling: bool or ~azure.core.polling.AsyncPollingMethod + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of AsyncLROPoller that returns either GenericResource or the result of + cls(response) + :rtype: + ~azure.core.polling.AsyncLROPoller[~azure.mgmt.resource.resources.v2020_06_01.models.GenericResource] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace_async + async def begin_update( + self, + resource_group_name: str, + resource_provider_namespace: str, + parent_resource_path: str, + resource_type: str, + resource_name: str, + api_version: str, + parameters: Union[_models.GenericResource, IO], + **kwargs: Any + ) -> AsyncLROPoller[_models.GenericResource]: + """Updates a resource. + + :param resource_group_name: The name of the resource group for the resource. The name is case + insensitive. Required. + :type resource_group_name: str + :param resource_provider_namespace: The namespace of the resource provider. Required. + :type resource_provider_namespace: str + :param parent_resource_path: The parent resource identity. Required. + :type parent_resource_path: str + :param resource_type: The resource type of the resource to update. Required. + :type resource_type: str + :param resource_name: The name of the resource to update. Required. + :type resource_name: str + :param api_version: The API version to use for the operation. Required. + :type api_version: str + :param parameters: Parameters for updating the resource. Is either a model type or a IO type. + Required. + :type parameters: ~azure.mgmt.resource.resources.v2020_06_01.models.GenericResource or IO + :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. + Default value is None. + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be AsyncARMPolling. Pass in False for + this operation to not poll, or pass in your own initialized polling object for a personal + polling strategy. + :paramtype polling: bool or ~azure.core.polling.AsyncPollingMethod + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of AsyncLROPoller that returns either GenericResource or the result of + cls(response) + :rtype: + ~azure.core.polling.AsyncLROPoller[~azure.mgmt.resource.resources.v2020_06_01.models.GenericResource] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = kwargs.pop("params", {}) or {} + + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.GenericResource] + polling = kwargs.pop("polling", True) # type: Union[bool, AsyncPollingMethod] + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token = kwargs.pop("continuation_token", None) # type: Optional[str] + if cont_token is None: + raw_result = await self._update_initial( # type: ignore + resource_group_name=resource_group_name, + resource_provider_namespace=resource_provider_namespace, + parent_resource_path=parent_resource_path, + resource_type=resource_type, + resource_name=resource_name, + api_version=api_version, + parameters=parameters, + content_type=content_type, + cls=lambda x, y, z: x, + headers=_headers, + params=_params, + **kwargs + ) + kwargs.pop("error_map", None) + + def get_long_running_output(pipeline_response): + deserialized = self._deserialize("GenericResource", pipeline_response) + if cls: + return cls(pipeline_response, deserialized, {}) + return deserialized + + if polling is True: + polling_method = cast(AsyncPollingMethod, AsyncARMPolling(lro_delay, **kwargs)) # type: AsyncPollingMethod + elif polling is False: + polling_method = cast(AsyncPollingMethod, AsyncNoPolling()) + else: + polling_method = polling + if cont_token: + return AsyncLROPoller.from_continuation_token( + polling_method=polling_method, + continuation_token=cont_token, + client=self._client, + deserialization_callback=get_long_running_output, + ) + return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) + + begin_update.metadata = {"url": "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{parentResourcePath}/{resourceType}/{resourceName}"} # type: ignore + + @distributed_trace_async + async def get( + self, + resource_group_name: str, + resource_provider_namespace: str, + parent_resource_path: str, + resource_type: str, + resource_name: str, + api_version: str, + **kwargs: Any + ) -> _models.GenericResource: + """Gets a resource. :param resource_group_name: The name of the resource group containing the resource to get. The - name is case insensitive. + name is case insensitive. Required. :type resource_group_name: str - :param resource_provider_namespace: The namespace of the resource provider. + :param resource_provider_namespace: The namespace of the resource provider. Required. :type resource_provider_namespace: str - :param parent_resource_path: The parent resource identity. + :param parent_resource_path: The parent resource identity. Required. :type parent_resource_path: str - :param resource_type: The resource type of the resource. + :param resource_type: The resource type of the resource. Required. :type resource_type: str - :param resource_name: The name of the resource to get. + :param resource_name: The name of the resource to get. Required. :type resource_name: str - :param api_version: The API version to use for the operation. + :param api_version: The API version to use for the operation. Required. :type api_version: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: GenericResource, or the result of cls(response) + :return: GenericResource or the result of cls(response) :rtype: ~azure.mgmt.resource.resources.v2020_06_01.models.GenericResource - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.GenericResource"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = kwargs.pop("params", {}) or {} + + cls = kwargs.pop("cls", None) # type: ClsType[_models.GenericResource] - request = build_resources_get_request( resource_group_name=resource_group_name, resource_provider_namespace=resource_provider_namespace, @@ -5513,72 +7283,75 @@ async def get( resource_name=resource_name, subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.get.metadata['url'], + template_url=self.get.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) - deserialized = self._deserialize('GenericResource', pipeline_response) + deserialized = self._deserialize("GenericResource", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - get.metadata = {'url': "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{parentResourcePath}/{resourceType}/{resourceName}"} # type: ignore - + get.metadata = {"url": "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{parentResourcePath}/{resourceType}/{resourceName}"} # type: ignore @distributed_trace_async - async def check_existence_by_id( - self, - resource_id: str, - api_version: str, - **kwargs: Any - ) -> bool: + async def check_existence_by_id(self, resource_id: str, api_version: str, **kwargs: Any) -> bool: """Checks by ID whether a resource exists. :param resource_id: The fully qualified ID of the resource, including the resource name and resource type. Use the format, /subscriptions/{guid}/resourceGroups/{resource-group-name}/{resource-provider-namespace}/{resource-type}/{resource-name}. + Required. :type resource_id: str - :param api_version: The API version to use for the operation. + :param api_version: The API version to use for the operation. Required. :type api_version: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: bool, or the result of cls(response) + :return: bool or the result of cls(response) :rtype: bool - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType[None] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = kwargs.pop("params", {}) or {} + + cls = kwargs.pop("cls", None) # type: ClsType[None] - request = build_resources_check_existence_by_id_request( resource_id=resource_id, api_version=api_version, - template_url=self.check_existence_by_id.metadata['url'], + template_url=self.check_existence_by_id.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [204, 404]: @@ -5589,35 +7362,38 @@ async def check_existence_by_id( return cls(pipeline_response, None, {}) return 200 <= response.status_code <= 299 - check_existence_by_id.metadata = {'url': "/{resourceId}"} # type: ignore - + check_existence_by_id.metadata = {"url": "/{resourceId}"} # type: ignore async def _delete_by_id_initial( # pylint: disable=inconsistent-return-statements - self, - resource_id: str, - api_version: str, - **kwargs: Any + self, resource_id: str, api_version: str, **kwargs: Any ) -> None: - cls = kwargs.pop('cls', None) # type: ClsType[None] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = kwargs.pop("params", {}) or {} + + cls = kwargs.pop("cls", None) # type: ClsType[None] - - request = build_resources_delete_by_id_request_initial( + request = build_resources_delete_by_id_request( resource_id=resource_id, api_version=api_version, - template_url=self._delete_by_id_initial.metadata['url'], + template_url=self._delete_by_id_initial.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200, 202, 204]: @@ -5627,23 +7403,18 @@ async def _delete_by_id_initial( # pylint: disable=inconsistent-return-statemen if cls: return cls(pipeline_response, None, {}) - _delete_by_id_initial.metadata = {'url': "/{resourceId}"} # type: ignore - + _delete_by_id_initial.metadata = {"url": "/{resourceId}"} # type: ignore @distributed_trace_async - async def begin_delete_by_id( # pylint: disable=inconsistent-return-statements - self, - resource_id: str, - api_version: str, - **kwargs: Any - ) -> AsyncLROPoller[None]: + async def begin_delete_by_id(self, resource_id: str, api_version: str, **kwargs: Any) -> AsyncLROPoller[None]: """Deletes a resource by ID. :param resource_id: The fully qualified ID of the resource, including the resource name and resource type. Use the format, /subscriptions/{guid}/resourceGroups/{resource-group-name}/{resource-provider-namespace}/{resource-type}/{resource-name}. + Required. :type resource_id: str - :param api_version: The API version to use for the operation. + :param api_version: The API version to use for the operation. Required. :type api_version: str :keyword callable cls: A custom type or function that will be passed the direct response :keyword str continuation_token: A continuation token to restart a poller from a saved state. @@ -5655,75 +7426,89 @@ async def begin_delete_by_id( # pylint: disable=inconsistent-return-statements Retry-After header is present. :return: An instance of AsyncLROPoller that returns either None or the result of cls(response) :rtype: ~azure.core.polling.AsyncLROPoller[None] - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - polling = kwargs.pop('polling', True) # type: Union[bool, AsyncPollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType[None] - lro_delay = kwargs.pop( - 'polling_interval', - self._config.polling_interval - ) - cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] + _headers = kwargs.pop("headers", {}) or {} + _params = kwargs.pop("params", {}) or {} + + cls = kwargs.pop("cls", None) # type: ClsType[None] + polling = kwargs.pop("polling", True) # type: Union[bool, AsyncPollingMethod] + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token = kwargs.pop("continuation_token", None) # type: Optional[str] if cont_token is None: - raw_result = await self._delete_by_id_initial( + raw_result = await self._delete_by_id_initial( # type: ignore resource_id=resource_id, api_version=api_version, - cls=lambda x,y,z: x, + cls=lambda x, y, z: x, + headers=_headers, + params=_params, **kwargs ) - kwargs.pop('error_map', None) + kwargs.pop("error_map", None) - def get_long_running_output(pipeline_response): + def get_long_running_output(pipeline_response): # pylint: disable=inconsistent-return-statements if cls: return cls(pipeline_response, None, {}) - - if polling is True: polling_method = AsyncARMPolling(lro_delay, **kwargs) - elif polling is False: polling_method = AsyncNoPolling() - else: polling_method = polling + if polling is True: + polling_method = cast(AsyncPollingMethod, AsyncARMPolling(lro_delay, **kwargs)) # type: AsyncPollingMethod + elif polling is False: + polling_method = cast(AsyncPollingMethod, AsyncNoPolling()) + else: + polling_method = polling if cont_token: return AsyncLROPoller.from_continuation_token( polling_method=polling_method, continuation_token=cont_token, client=self._client, - deserialization_callback=get_long_running_output + deserialization_callback=get_long_running_output, ) return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) - begin_delete_by_id.metadata = {'url': "/{resourceId}"} # type: ignore + begin_delete_by_id.metadata = {"url": "/{resourceId}"} # type: ignore async def _create_or_update_by_id_initial( - self, - resource_id: str, - api_version: str, - parameters: "_models.GenericResource", - **kwargs: Any - ) -> Optional["_models.GenericResource"]: - cls = kwargs.pop('cls', None) # type: ClsType[Optional["_models.GenericResource"]] + self, resource_id: str, api_version: str, parameters: Union[_models.GenericResource, IO], **kwargs: Any + ) -> Optional[_models.GenericResource]: error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = kwargs.pop("params", {}) or {} - _json = self._serialize.body(parameters, 'GenericResource') + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[Optional[_models.GenericResource]] - request = build_resources_create_or_update_by_id_request_initial( + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(parameters, (IO, bytes)): + _content = parameters + else: + _json = self._serialize.body(parameters, "GenericResource") + + request = build_resources_create_or_update_by_id_request( resource_id=resource_id, - content_type=content_type, api_version=api_version, + content_type=content_type, json=_json, - template_url=self._create_or_update_by_id_initial.metadata['url'], + content=_content, + template_url=self._create_or_update_by_id_initial.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200, 201, 202]: @@ -5732,37 +7517,42 @@ async def _create_or_update_by_id_initial( deserialized = None if response.status_code == 200: - deserialized = self._deserialize('GenericResource', pipeline_response) + deserialized = self._deserialize("GenericResource", pipeline_response) if response.status_code == 201: - deserialized = self._deserialize('GenericResource', pipeline_response) + deserialized = self._deserialize("GenericResource", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - _create_or_update_by_id_initial.metadata = {'url': "/{resourceId}"} # type: ignore - + _create_or_update_by_id_initial.metadata = {"url": "/{resourceId}"} # type: ignore - @distributed_trace_async + @overload async def begin_create_or_update_by_id( self, resource_id: str, api_version: str, - parameters: "_models.GenericResource", + parameters: _models.GenericResource, + *, + content_type: str = "application/json", **kwargs: Any - ) -> AsyncLROPoller["_models.GenericResource"]: + ) -> AsyncLROPoller[_models.GenericResource]: """Create a resource by ID. :param resource_id: The fully qualified ID of the resource, including the resource name and resource type. Use the format, /subscriptions/{guid}/resourceGroups/{resource-group-name}/{resource-provider-namespace}/{resource-type}/{resource-name}. + Required. :type resource_id: str - :param api_version: The API version to use for the operation. + :param api_version: The API version to use for the operation. Required. :type api_version: str - :param parameters: Create or update resource parameters. + :param parameters: Create or update resource parameters. Required. :type parameters: ~azure.mgmt.resource.resources.v2020_06_01.models.GenericResource + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str :keyword callable cls: A custom type or function that will be passed the direct response :keyword str continuation_token: A continuation token to restart a poller from a saved state. :keyword polling: By default, your polling method will be AsyncARMPolling. Pass in False for @@ -5775,81 +7565,167 @@ async def begin_create_or_update_by_id( cls(response) :rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.resource.resources.v2020_06_01.models.GenericResource] - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] - polling = kwargs.pop('polling', True) # type: Union[bool, AsyncPollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType["_models.GenericResource"] - lro_delay = kwargs.pop( - 'polling_interval', - self._config.polling_interval - ) - cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] + + @overload + async def begin_create_or_update_by_id( + self, + resource_id: str, + api_version: str, + parameters: IO, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> AsyncLROPoller[_models.GenericResource]: + """Create a resource by ID. + + :param resource_id: The fully qualified ID of the resource, including the resource name and + resource type. Use the format, + /subscriptions/{guid}/resourceGroups/{resource-group-name}/{resource-provider-namespace}/{resource-type}/{resource-name}. + Required. + :type resource_id: str + :param api_version: The API version to use for the operation. Required. + :type api_version: str + :param parameters: Create or update resource parameters. Required. + :type parameters: IO + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be AsyncARMPolling. Pass in False for + this operation to not poll, or pass in your own initialized polling object for a personal + polling strategy. + :paramtype polling: bool or ~azure.core.polling.AsyncPollingMethod + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of AsyncLROPoller that returns either GenericResource or the result of + cls(response) + :rtype: + ~azure.core.polling.AsyncLROPoller[~azure.mgmt.resource.resources.v2020_06_01.models.GenericResource] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace_async + async def begin_create_or_update_by_id( + self, resource_id: str, api_version: str, parameters: Union[_models.GenericResource, IO], **kwargs: Any + ) -> AsyncLROPoller[_models.GenericResource]: + """Create a resource by ID. + + :param resource_id: The fully qualified ID of the resource, including the resource name and + resource type. Use the format, + /subscriptions/{guid}/resourceGroups/{resource-group-name}/{resource-provider-namespace}/{resource-type}/{resource-name}. + Required. + :type resource_id: str + :param api_version: The API version to use for the operation. Required. + :type api_version: str + :param parameters: Create or update resource parameters. Is either a model type or a IO type. + Required. + :type parameters: ~azure.mgmt.resource.resources.v2020_06_01.models.GenericResource or IO + :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. + Default value is None. + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be AsyncARMPolling. Pass in False for + this operation to not poll, or pass in your own initialized polling object for a personal + polling strategy. + :paramtype polling: bool or ~azure.core.polling.AsyncPollingMethod + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of AsyncLROPoller that returns either GenericResource or the result of + cls(response) + :rtype: + ~azure.core.polling.AsyncLROPoller[~azure.mgmt.resource.resources.v2020_06_01.models.GenericResource] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = kwargs.pop("params", {}) or {} + + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.GenericResource] + polling = kwargs.pop("polling", True) # type: Union[bool, AsyncPollingMethod] + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token = kwargs.pop("continuation_token", None) # type: Optional[str] if cont_token is None: - raw_result = await self._create_or_update_by_id_initial( + raw_result = await self._create_or_update_by_id_initial( # type: ignore resource_id=resource_id, api_version=api_version, parameters=parameters, content_type=content_type, - cls=lambda x,y,z: x, + cls=lambda x, y, z: x, + headers=_headers, + params=_params, **kwargs ) - kwargs.pop('error_map', None) + kwargs.pop("error_map", None) def get_long_running_output(pipeline_response): - response = pipeline_response.http_response - deserialized = self._deserialize('GenericResource', pipeline_response) + deserialized = self._deserialize("GenericResource", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - - if polling is True: polling_method = AsyncARMPolling(lro_delay, **kwargs) - elif polling is False: polling_method = AsyncNoPolling() - else: polling_method = polling + if polling is True: + polling_method = cast(AsyncPollingMethod, AsyncARMPolling(lro_delay, **kwargs)) # type: AsyncPollingMethod + elif polling is False: + polling_method = cast(AsyncPollingMethod, AsyncNoPolling()) + else: + polling_method = polling if cont_token: return AsyncLROPoller.from_continuation_token( polling_method=polling_method, continuation_token=cont_token, client=self._client, - deserialization_callback=get_long_running_output + deserialization_callback=get_long_running_output, ) return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) - begin_create_or_update_by_id.metadata = {'url': "/{resourceId}"} # type: ignore + begin_create_or_update_by_id.metadata = {"url": "/{resourceId}"} # type: ignore async def _update_by_id_initial( - self, - resource_id: str, - api_version: str, - parameters: "_models.GenericResource", - **kwargs: Any - ) -> Optional["_models.GenericResource"]: - cls = kwargs.pop('cls', None) # type: ClsType[Optional["_models.GenericResource"]] + self, resource_id: str, api_version: str, parameters: Union[_models.GenericResource, IO], **kwargs: Any + ) -> Optional[_models.GenericResource]: error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = kwargs.pop("params", {}) or {} - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[Optional[_models.GenericResource]] - _json = self._serialize.body(parameters, 'GenericResource') + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(parameters, (IO, bytes)): + _content = parameters + else: + _json = self._serialize.body(parameters, "GenericResource") - request = build_resources_update_by_id_request_initial( + request = build_resources_update_by_id_request( resource_id=resource_id, - content_type=content_type, api_version=api_version, + content_type=content_type, json=_json, - template_url=self._update_by_id_initial.metadata['url'], + content=_content, + template_url=self._update_by_id_initial.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200, 202]: @@ -5858,34 +7734,39 @@ async def _update_by_id_initial( deserialized = None if response.status_code == 200: - deserialized = self._deserialize('GenericResource', pipeline_response) + deserialized = self._deserialize("GenericResource", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - _update_by_id_initial.metadata = {'url': "/{resourceId}"} # type: ignore + _update_by_id_initial.metadata = {"url": "/{resourceId}"} # type: ignore - - @distributed_trace_async + @overload async def begin_update_by_id( self, resource_id: str, api_version: str, - parameters: "_models.GenericResource", + parameters: _models.GenericResource, + *, + content_type: str = "application/json", **kwargs: Any - ) -> AsyncLROPoller["_models.GenericResource"]: + ) -> AsyncLROPoller[_models.GenericResource]: """Updates a resource by ID. :param resource_id: The fully qualified ID of the resource, including the resource name and resource type. Use the format, /subscriptions/{guid}/resourceGroups/{resource-group-name}/{resource-provider-namespace}/{resource-type}/{resource-name}. + Required. :type resource_id: str - :param api_version: The API version to use for the operation. + :param api_version: The API version to use for the operation. Required. :type api_version: str - :param parameters: Update resource parameters. + :param parameters: Update resource parameters. Required. :type parameters: ~azure.mgmt.resource.resources.v2020_06_01.models.GenericResource + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str :keyword callable cls: A custom type or function that will be passed the direct response :keyword str continuation_token: A continuation token to restart a poller from a saved state. :keyword polling: By default, your polling method will be AsyncARMPolling. Pass in False for @@ -5898,165 +7779,243 @@ async def begin_update_by_id( cls(response) :rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.resource.resources.v2020_06_01.models.GenericResource] - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] - polling = kwargs.pop('polling', True) # type: Union[bool, AsyncPollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType["_models.GenericResource"] - lro_delay = kwargs.pop( - 'polling_interval', - self._config.polling_interval - ) - cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] + + @overload + async def begin_update_by_id( + self, + resource_id: str, + api_version: str, + parameters: IO, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> AsyncLROPoller[_models.GenericResource]: + """Updates a resource by ID. + + :param resource_id: The fully qualified ID of the resource, including the resource name and + resource type. Use the format, + /subscriptions/{guid}/resourceGroups/{resource-group-name}/{resource-provider-namespace}/{resource-type}/{resource-name}. + Required. + :type resource_id: str + :param api_version: The API version to use for the operation. Required. + :type api_version: str + :param parameters: Update resource parameters. Required. + :type parameters: IO + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be AsyncARMPolling. Pass in False for + this operation to not poll, or pass in your own initialized polling object for a personal + polling strategy. + :paramtype polling: bool or ~azure.core.polling.AsyncPollingMethod + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of AsyncLROPoller that returns either GenericResource or the result of + cls(response) + :rtype: + ~azure.core.polling.AsyncLROPoller[~azure.mgmt.resource.resources.v2020_06_01.models.GenericResource] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace_async + async def begin_update_by_id( + self, resource_id: str, api_version: str, parameters: Union[_models.GenericResource, IO], **kwargs: Any + ) -> AsyncLROPoller[_models.GenericResource]: + """Updates a resource by ID. + + :param resource_id: The fully qualified ID of the resource, including the resource name and + resource type. Use the format, + /subscriptions/{guid}/resourceGroups/{resource-group-name}/{resource-provider-namespace}/{resource-type}/{resource-name}. + Required. + :type resource_id: str + :param api_version: The API version to use for the operation. Required. + :type api_version: str + :param parameters: Update resource parameters. Is either a model type or a IO type. Required. + :type parameters: ~azure.mgmt.resource.resources.v2020_06_01.models.GenericResource or IO + :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. + Default value is None. + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be AsyncARMPolling. Pass in False for + this operation to not poll, or pass in your own initialized polling object for a personal + polling strategy. + :paramtype polling: bool or ~azure.core.polling.AsyncPollingMethod + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of AsyncLROPoller that returns either GenericResource or the result of + cls(response) + :rtype: + ~azure.core.polling.AsyncLROPoller[~azure.mgmt.resource.resources.v2020_06_01.models.GenericResource] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = kwargs.pop("params", {}) or {} + + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.GenericResource] + polling = kwargs.pop("polling", True) # type: Union[bool, AsyncPollingMethod] + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token = kwargs.pop("continuation_token", None) # type: Optional[str] if cont_token is None: - raw_result = await self._update_by_id_initial( + raw_result = await self._update_by_id_initial( # type: ignore resource_id=resource_id, api_version=api_version, parameters=parameters, content_type=content_type, - cls=lambda x,y,z: x, + cls=lambda x, y, z: x, + headers=_headers, + params=_params, **kwargs ) - kwargs.pop('error_map', None) + kwargs.pop("error_map", None) def get_long_running_output(pipeline_response): - response = pipeline_response.http_response - deserialized = self._deserialize('GenericResource', pipeline_response) + deserialized = self._deserialize("GenericResource", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - - if polling is True: polling_method = AsyncARMPolling(lro_delay, **kwargs) - elif polling is False: polling_method = AsyncNoPolling() - else: polling_method = polling + if polling is True: + polling_method = cast(AsyncPollingMethod, AsyncARMPolling(lro_delay, **kwargs)) # type: AsyncPollingMethod + elif polling is False: + polling_method = cast(AsyncPollingMethod, AsyncNoPolling()) + else: + polling_method = polling if cont_token: return AsyncLROPoller.from_continuation_token( polling_method=polling_method, continuation_token=cont_token, client=self._client, - deserialization_callback=get_long_running_output + deserialization_callback=get_long_running_output, ) return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) - begin_update_by_id.metadata = {'url': "/{resourceId}"} # type: ignore + begin_update_by_id.metadata = {"url": "/{resourceId}"} # type: ignore @distributed_trace_async - async def get_by_id( - self, - resource_id: str, - api_version: str, - **kwargs: Any - ) -> "_models.GenericResource": + async def get_by_id(self, resource_id: str, api_version: str, **kwargs: Any) -> _models.GenericResource: """Gets a resource by ID. :param resource_id: The fully qualified ID of the resource, including the resource name and resource type. Use the format, /subscriptions/{guid}/resourceGroups/{resource-group-name}/{resource-provider-namespace}/{resource-type}/{resource-name}. + Required. :type resource_id: str - :param api_version: The API version to use for the operation. + :param api_version: The API version to use for the operation. Required. :type api_version: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: GenericResource, or the result of cls(response) + :return: GenericResource or the result of cls(response) :rtype: ~azure.mgmt.resource.resources.v2020_06_01.models.GenericResource - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.GenericResource"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = kwargs.pop("params", {}) or {} + + cls = kwargs.pop("cls", None) # type: ClsType[_models.GenericResource] - request = build_resources_get_by_id_request( resource_id=resource_id, api_version=api_version, - template_url=self.get_by_id.metadata['url'], + template_url=self.get_by_id.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) - deserialized = self._deserialize('GenericResource', pipeline_response) + deserialized = self._deserialize("GenericResource", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - get_by_id.metadata = {'url': "/{resourceId}"} # type: ignore + get_by_id.metadata = {"url": "/{resourceId}"} # type: ignore -class ResourceGroupsOperations: - """ResourceGroupsOperations async operations. - You should not instantiate this class directly. Instead, you should create a Client instance that - instantiates it for you and attaches it as an attribute. +class ResourceGroupsOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. - :ivar models: Alias to model classes used in this operation group. - :type models: ~azure.mgmt.resource.resources.v2020_06_01.models - :param client: Client for service requests. - :param config: Configuration of service client. - :param serializer: An object model serializer. - :param deserializer: An object model deserializer. + Instead, you should access the following operations through + :class:`~azure.mgmt.resource.resources.v2020_06_01.aio.ResourceManagementClient`'s + :attr:`resource_groups` attribute. """ models = _models - def __init__(self, client, config, serializer, deserializer) -> None: - self._client = client - self._serialize = serializer - self._deserialize = deserializer - self._config = config + def __init__(self, *args, **kwargs) -> None: + input_args = list(args) + self._client = input_args.pop(0) if input_args else kwargs.pop("client") + self._config = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") @distributed_trace_async - async def check_existence( - self, - resource_group_name: str, - **kwargs: Any - ) -> bool: + async def check_existence(self, resource_group_name: str, **kwargs: Any) -> bool: """Checks whether a resource group exists. :param resource_group_name: The name of the resource group to check. The name is case - insensitive. + insensitive. Required. :type resource_group_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: bool, or the result of cls(response) + :return: bool or the result of cls(response) :rtype: bool - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType[None] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + 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', "2020-06-01") # type: str + api_version = kwargs.pop("api_version", _params.pop("api-version", "2020-06-01")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[None] - request = build_resource_groups_check_existence_request( resource_group_name=resource_group_name, subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.check_existence.metadata['url'], + template_url=self.check_existence.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [204, 404]: @@ -6067,39 +8026,98 @@ async def check_existence( return cls(pipeline_response, None, {}) return 200 <= response.status_code <= 299 - check_existence.metadata = {'url': "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}"} # type: ignore + check_existence.metadata = {"url": "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}"} # type: ignore - - @distributed_trace_async + @overload async def create_or_update( self, resource_group_name: str, - parameters: "_models.ResourceGroup", + parameters: _models.ResourceGroup, + *, + content_type: str = "application/json", **kwargs: Any - ) -> "_models.ResourceGroup": + ) -> _models.ResourceGroup: """Creates or updates a resource group. :param resource_group_name: The name of the resource group to create or update. Can include alphanumeric, underscore, parentheses, hyphen, period (except at end), and Unicode characters - that match the allowed characters. + that match the allowed characters. Required. :type resource_group_name: str - :param parameters: Parameters supplied to the create or update a resource group. + :param parameters: Parameters supplied to the create or update a resource group. Required. :type parameters: ~azure.mgmt.resource.resources.v2020_06_01.models.ResourceGroup + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: ResourceGroup, or the result of cls(response) + :return: ResourceGroup or the result of cls(response) :rtype: ~azure.mgmt.resource.resources.v2020_06_01.models.ResourceGroup - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + async def create_or_update( + self, resource_group_name: str, parameters: IO, *, content_type: str = "application/json", **kwargs: Any + ) -> _models.ResourceGroup: + """Creates or updates a resource group. + + :param resource_group_name: The name of the resource group to create or update. Can include + alphanumeric, underscore, parentheses, hyphen, period (except at end), and Unicode characters + that match the allowed characters. Required. + :type resource_group_name: str + :param parameters: Parameters supplied to the create or update a resource group. Required. + :type parameters: IO + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: ResourceGroup or the result of cls(response) + :rtype: ~azure.mgmt.resource.resources.v2020_06_01.models.ResourceGroup + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace_async + async def create_or_update( + self, resource_group_name: str, parameters: Union[_models.ResourceGroup, IO], **kwargs: Any + ) -> _models.ResourceGroup: + """Creates or updates a resource group. + + :param resource_group_name: The name of the resource group to create or update. Can include + alphanumeric, underscore, parentheses, hyphen, period (except at end), and Unicode characters + that match the allowed characters. Required. + :type resource_group_name: str + :param parameters: Parameters supplied to the create or update a resource group. Is either a + model type or a IO type. Required. + :type parameters: ~azure.mgmt.resource.resources.v2020_06_01.models.ResourceGroup or IO + :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. + Default value is None. + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: ResourceGroup or the result of cls(response) + :rtype: ~azure.mgmt.resource.resources.v2020_06_01.models.ResourceGroup + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.ResourceGroup"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) - api_version = kwargs.pop('api_version', "2020-06-01") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - _json = self._serialize.body(parameters, 'ResourceGroup') + api_version = kwargs.pop("api_version", _params.pop("api-version", "2020-06-01")) # type: str + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.ResourceGroup] + + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(parameters, (IO, bytes)): + _content = parameters + else: + _json = self._serialize.body(parameters, "ResourceGroup") request = build_resource_groups_create_or_update_request( resource_group_name=resource_group_name, @@ -6107,16 +8125,18 @@ async def create_or_update( api_version=api_version, content_type=content_type, json=_json, - template_url=self.create_or_update.metadata['url'], + content=_content, + template_url=self.create_or_update.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200, 201]: @@ -6124,49 +8144,51 @@ async def create_or_update( raise HttpResponseError(response=response, error_format=ARMErrorFormat) if response.status_code == 200: - deserialized = self._deserialize('ResourceGroup', pipeline_response) + deserialized = self._deserialize("ResourceGroup", pipeline_response) if response.status_code == 201: - deserialized = self._deserialize('ResourceGroup', pipeline_response) + deserialized = self._deserialize("ResourceGroup", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - create_or_update.metadata = {'url': "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}"} # type: ignore - + create_or_update.metadata = {"url": "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}"} # type: ignore async def _delete_initial( # pylint: disable=inconsistent-return-statements - self, - resource_group_name: str, - force_deletion_types: Optional[str] = None, - **kwargs: Any + self, resource_group_name: str, force_deletion_types: Optional[str] = None, **kwargs: Any ) -> None: - cls = kwargs.pop('cls', None) # type: ClsType[None] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) - api_version = kwargs.pop('api_version', "2020-06-01") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - request = build_resource_groups_delete_request_initial( + api_version = kwargs.pop("api_version", _params.pop("api-version", "2020-06-01")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[None] + + request = build_resource_groups_delete_request( resource_group_name=resource_group_name, subscription_id=self._config.subscription_id, - api_version=api_version, force_deletion_types=force_deletion_types, - template_url=self._delete_initial.metadata['url'], + api_version=api_version, + template_url=self._delete_initial.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200, 202]: @@ -6176,15 +8198,11 @@ async def _delete_initial( # pylint: disable=inconsistent-return-statements if cls: return cls(pipeline_response, None, {}) - _delete_initial.metadata = {'url': "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}"} # type: ignore - + _delete_initial.metadata = {"url": "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}"} # type: ignore @distributed_trace_async - async def begin_delete( # pylint: disable=inconsistent-return-statements - self, - resource_group_name: str, - force_deletion_types: Optional[str] = None, - **kwargs: Any + async def begin_delete( + self, resource_group_name: str, force_deletion_types: Optional[str] = None, **kwargs: Any ) -> AsyncLROPoller[None]: """Deletes a resource group. @@ -6192,7 +8210,7 @@ async def begin_delete( # pylint: disable=inconsistent-return-statements group deletes all of its template deployments and currently stored operations. :param resource_group_name: The name of the resource group to delete. The name is case - insensitive. + insensitive. Required. :type resource_group_name: str :param force_deletion_types: The resource types you want to force delete. Currently, only the following is supported: @@ -6209,107 +8227,114 @@ async def begin_delete( # pylint: disable=inconsistent-return-statements Retry-After header is present. :return: An instance of AsyncLROPoller that returns either None or the result of cls(response) :rtype: ~azure.core.polling.AsyncLROPoller[None] - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - api_version = kwargs.pop('api_version', "2020-06-01") # type: str - polling = kwargs.pop('polling', True) # type: Union[bool, AsyncPollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType[None] - lro_delay = kwargs.pop( - 'polling_interval', - self._config.polling_interval - ) - cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2020-06-01")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[None] + polling = kwargs.pop("polling", True) # type: Union[bool, AsyncPollingMethod] + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token = kwargs.pop("continuation_token", None) # type: Optional[str] if cont_token is None: - raw_result = await self._delete_initial( + raw_result = await self._delete_initial( # type: ignore resource_group_name=resource_group_name, force_deletion_types=force_deletion_types, api_version=api_version, - cls=lambda x,y,z: x, + cls=lambda x, y, z: x, + headers=_headers, + params=_params, **kwargs ) - kwargs.pop('error_map', None) + kwargs.pop("error_map", None) - def get_long_running_output(pipeline_response): + def get_long_running_output(pipeline_response): # pylint: disable=inconsistent-return-statements if cls: return cls(pipeline_response, None, {}) - - if polling is True: polling_method = AsyncARMPolling(lro_delay, **kwargs) - elif polling is False: polling_method = AsyncNoPolling() - else: polling_method = polling + if polling is True: + polling_method = cast(AsyncPollingMethod, AsyncARMPolling(lro_delay, **kwargs)) # type: AsyncPollingMethod + elif polling is False: + polling_method = cast(AsyncPollingMethod, AsyncNoPolling()) + else: + polling_method = polling if cont_token: return AsyncLROPoller.from_continuation_token( polling_method=polling_method, continuation_token=cont_token, client=self._client, - deserialization_callback=get_long_running_output + deserialization_callback=get_long_running_output, ) return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) - begin_delete.metadata = {'url': "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}"} # type: ignore + begin_delete.metadata = {"url": "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}"} # type: ignore @distributed_trace_async - async def get( - self, - resource_group_name: str, - **kwargs: Any - ) -> "_models.ResourceGroup": + async def get(self, resource_group_name: str, **kwargs: Any) -> _models.ResourceGroup: """Gets a resource group. :param resource_group_name: The name of the resource group to get. The name is case - insensitive. + insensitive. Required. :type resource_group_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: ResourceGroup, or the result of cls(response) + :return: ResourceGroup or the result of cls(response) :rtype: ~azure.mgmt.resource.resources.v2020_06_01.models.ResourceGroup - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.ResourceGroup"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + 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', "2020-06-01") # type: str + api_version = kwargs.pop("api_version", _params.pop("api-version", "2020-06-01")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[_models.ResourceGroup] - request = build_resource_groups_get_request( resource_group_name=resource_group_name, subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.get.metadata['url'], + template_url=self.get.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) - deserialized = self._deserialize('ResourceGroup', pipeline_response) + deserialized = self._deserialize("ResourceGroup", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - get.metadata = {'url': "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}"} # type: ignore - + get.metadata = {"url": "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}"} # type: ignore - @distributed_trace_async + @overload async def update( self, resource_group_name: str, - parameters: "_models.ResourceGroupPatchable", + parameters: _models.ResourceGroupPatchable, + *, + content_type: str = "application/json", **kwargs: Any - ) -> "_models.ResourceGroup": + ) -> _models.ResourceGroup: """Updates a resource group. Resource groups can be updated through a simple PATCH operation to a group address. The format @@ -6317,25 +8342,90 @@ async def update( the current value is retained. :param resource_group_name: The name of the resource group to update. The name is case - insensitive. + insensitive. Required. :type resource_group_name: str - :param parameters: Parameters supplied to update a resource group. + :param parameters: Parameters supplied to update a resource group. Required. :type parameters: ~azure.mgmt.resource.resources.v2020_06_01.models.ResourceGroupPatchable + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: ResourceGroup, or the result of cls(response) + :return: ResourceGroup or the result of cls(response) :rtype: ~azure.mgmt.resource.resources.v2020_06_01.models.ResourceGroup - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + async def update( + self, resource_group_name: str, parameters: IO, *, content_type: str = "application/json", **kwargs: Any + ) -> _models.ResourceGroup: + """Updates a resource group. + + Resource groups can be updated through a simple PATCH operation to a group address. The format + of the request is the same as that for creating a resource group. If a field is unspecified, + the current value is retained. + + :param resource_group_name: The name of the resource group to update. The name is case + insensitive. Required. + :type resource_group_name: str + :param parameters: Parameters supplied to update a resource group. Required. + :type parameters: IO + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: ResourceGroup or the result of cls(response) + :rtype: ~azure.mgmt.resource.resources.v2020_06_01.models.ResourceGroup + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace_async + async def update( + self, resource_group_name: str, parameters: Union[_models.ResourceGroupPatchable, IO], **kwargs: Any + ) -> _models.ResourceGroup: + """Updates a resource group. + + Resource groups can be updated through a simple PATCH operation to a group address. The format + of the request is the same as that for creating a resource group. If a field is unspecified, + the current value is retained. + + :param resource_group_name: The name of the resource group to update. The name is case + insensitive. Required. + :type resource_group_name: str + :param parameters: Parameters supplied to update a resource group. Is either a model type or a + IO type. Required. + :type parameters: ~azure.mgmt.resource.resources.v2020_06_01.models.ResourceGroupPatchable or + IO + :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. + Default value is None. + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: ResourceGroup or the result of cls(response) + :rtype: ~azure.mgmt.resource.resources.v2020_06_01.models.ResourceGroup + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.ResourceGroup"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', "2020-06-01") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + api_version = kwargs.pop("api_version", _params.pop("api-version", "2020-06-01")) # type: str + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.ResourceGroup] - _json = self._serialize.body(parameters, 'ResourceGroupPatchable') + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(parameters, (IO, bytes)): + _content = parameters + else: + _json = self._serialize.body(parameters, "ResourceGroupPatchable") request = build_resource_groups_update_request( resource_group_name=resource_group_name, @@ -6343,65 +8433,77 @@ async def update( api_version=api_version, content_type=content_type, json=_json, - template_url=self.update.metadata['url'], + content=_content, + template_url=self.update.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) - deserialized = self._deserialize('ResourceGroup', pipeline_response) + deserialized = self._deserialize("ResourceGroup", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - update.metadata = {'url': "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}"} # type: ignore - + update.metadata = {"url": "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}"} # type: ignore async def _export_template_initial( - self, - resource_group_name: str, - parameters: "_models.ExportTemplateRequest", - **kwargs: Any - ) -> Optional["_models.ResourceGroupExportResult"]: - cls = kwargs.pop('cls', None) # type: ClsType[Optional["_models.ResourceGroupExportResult"]] + self, resource_group_name: str, parameters: Union[_models.ExportTemplateRequest, IO], **kwargs: Any + ) -> Optional[_models.ResourceGroupExportResult]: error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) - api_version = kwargs.pop('api_version', "2020-06-01") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - _json = self._serialize.body(parameters, 'ExportTemplateRequest') + api_version = kwargs.pop("api_version", _params.pop("api-version", "2020-06-01")) # type: str + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[Optional[_models.ResourceGroupExportResult]] - request = build_resource_groups_export_template_request_initial( - subscription_id=self._config.subscription_id, + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(parameters, (IO, bytes)): + _content = parameters + else: + _json = self._serialize.body(parameters, "ExportTemplateRequest") + + request = build_resource_groups_export_template_request( resource_group_name=resource_group_name, + subscription_id=self._config.subscription_id, api_version=api_version, content_type=content_type, json=_json, - template_url=self._export_template_initial.metadata['url'], + content=_content, + template_url=self._export_template_initial.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200, 202]: @@ -6410,29 +8512,93 @@ async def _export_template_initial( deserialized = None if response.status_code == 200: - deserialized = self._deserialize('ResourceGroupExportResult', pipeline_response) + deserialized = self._deserialize("ResourceGroupExportResult", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - _export_template_initial.metadata = {'url': "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/exportTemplate"} # type: ignore - + _export_template_initial.metadata = {"url": "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/exportTemplate"} # type: ignore - @distributed_trace_async + @overload async def begin_export_template( self, resource_group_name: str, - parameters: "_models.ExportTemplateRequest", + parameters: _models.ExportTemplateRequest, + *, + content_type: str = "application/json", **kwargs: Any - ) -> AsyncLROPoller["_models.ResourceGroupExportResult"]: + ) -> AsyncLROPoller[_models.ResourceGroupExportResult]: + """Captures the specified resource group as a template. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param parameters: Parameters for exporting the template. Required. + :type parameters: ~azure.mgmt.resource.resources.v2020_06_01.models.ExportTemplateRequest + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be AsyncARMPolling. Pass in False for + this operation to not poll, or pass in your own initialized polling object for a personal + polling strategy. + :paramtype polling: bool or ~azure.core.polling.AsyncPollingMethod + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of AsyncLROPoller that returns either ResourceGroupExportResult or the + result of cls(response) + :rtype: + ~azure.core.polling.AsyncLROPoller[~azure.mgmt.resource.resources.v2020_06_01.models.ResourceGroupExportResult] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + async def begin_export_template( + self, resource_group_name: str, parameters: IO, *, content_type: str = "application/json", **kwargs: Any + ) -> AsyncLROPoller[_models.ResourceGroupExportResult]: + """Captures the specified resource group as a template. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param parameters: Parameters for exporting the template. Required. + :type parameters: IO + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be AsyncARMPolling. Pass in False for + this operation to not poll, or pass in your own initialized polling object for a personal + polling strategy. + :paramtype polling: bool or ~azure.core.polling.AsyncPollingMethod + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of AsyncLROPoller that returns either ResourceGroupExportResult or the + result of cls(response) + :rtype: + ~azure.core.polling.AsyncLROPoller[~azure.mgmt.resource.resources.v2020_06_01.models.ResourceGroupExportResult] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace_async + async def begin_export_template( + self, resource_group_name: str, parameters: Union[_models.ExportTemplateRequest, IO], **kwargs: Any + ) -> AsyncLROPoller[_models.ResourceGroupExportResult]: """Captures the specified resource group as a template. :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. :type resource_group_name: str - :param parameters: Parameters for exporting the template. - :type parameters: ~azure.mgmt.resource.resources.v2020_06_01.models.ExportTemplateRequest + :param parameters: Parameters for exporting the template. Is either a model type or a IO type. + Required. + :type parameters: ~azure.mgmt.resource.resources.v2020_06_01.models.ExportTemplateRequest or IO + :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. + Default value is None. + :paramtype content_type: str :keyword callable cls: A custom type or function that will be passed the direct response :keyword str continuation_token: A continuation token to restart a poller from a saved state. :keyword polling: By default, your polling method will be AsyncARMPolling. Pass in False for @@ -6445,57 +8611,59 @@ async def begin_export_template( result of cls(response) :rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.resource.resources.v2020_06_01.models.ResourceGroupExportResult] - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - api_version = kwargs.pop('api_version', "2020-06-01") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] - polling = kwargs.pop('polling', True) # type: Union[bool, AsyncPollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType["_models.ResourceGroupExportResult"] - lro_delay = kwargs.pop( - 'polling_interval', - self._config.polling_interval - ) - cont_token = kwargs.pop('continuation_token', None) # type: Optional[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", "2020-06-01")) # type: str + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.ResourceGroupExportResult] + polling = kwargs.pop("polling", True) # type: Union[bool, AsyncPollingMethod] + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token = kwargs.pop("continuation_token", None) # type: Optional[str] if cont_token is None: - raw_result = await self._export_template_initial( + raw_result = await self._export_template_initial( # type: ignore resource_group_name=resource_group_name, parameters=parameters, api_version=api_version, content_type=content_type, - cls=lambda x,y,z: x, + cls=lambda x, y, z: x, + headers=_headers, + params=_params, **kwargs ) - kwargs.pop('error_map', None) + kwargs.pop("error_map", None) def get_long_running_output(pipeline_response): - response = pipeline_response.http_response - deserialized = self._deserialize('ResourceGroupExportResult', pipeline_response) + deserialized = self._deserialize("ResourceGroupExportResult", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - - if polling is True: polling_method = AsyncARMPolling(lro_delay, lro_options={'final-state-via': 'location'}, **kwargs) - elif polling is False: polling_method = AsyncNoPolling() - else: polling_method = polling + if polling is True: + polling_method = cast( + AsyncPollingMethod, AsyncARMPolling(lro_delay, lro_options={"final-state-via": "location"}, **kwargs) + ) # type: AsyncPollingMethod + elif polling is False: + polling_method = cast(AsyncPollingMethod, AsyncNoPolling()) + else: + polling_method = polling if cont_token: return AsyncLROPoller.from_continuation_token( polling_method=polling_method, continuation_token=cont_token, client=self._client, - deserialization_callback=get_long_running_output + deserialization_callback=get_long_running_output, ) return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) - begin_export_template.metadata = {'url': "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/exportTemplate"} # type: ignore + begin_export_template.metadata = {"url": "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/exportTemplate"} # type: ignore @distributed_trace def list( - self, - filter: Optional[str] = None, - top: Optional[int] = None, - **kwargs: Any - ) -> AsyncIterable["_models.ResourceGroupListResult"]: + self, filter: Optional[str] = None, top: Optional[int] = None, **kwargs: Any + ) -> AsyncIterable["_models.ResourceGroup"]: """Gets all the resource groups for a subscription. :param filter: The filter to apply on the operation.:code:`
`:code:`
`You can filter by @@ -6506,40 +8674,48 @@ def list( Default value is None. :type top: int :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either ResourceGroupListResult or the result of - cls(response) + :return: An iterator like instance of either ResourceGroup or the result of cls(response) :rtype: - ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.resource.resources.v2020_06_01.models.ResourceGroupListResult] - :raises: ~azure.core.exceptions.HttpResponseError + ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.resource.resources.v2020_06_01.models.ResourceGroup] + :raises ~azure.core.exceptions.HttpResponseError: """ - api_version = kwargs.pop('api_version', "2020-06-01") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2020-06-01")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[_models.ResourceGroupListResult] - cls = kwargs.pop('cls', None) # type: ClsType["_models.ResourceGroupListResult"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) + def prepare_request(next_link=None): if not next_link: - + request = build_resource_groups_list_request( subscription_id=self._config.subscription_id, - api_version=api_version, filter=filter, top=top, - template_url=self.list.metadata['url'], + 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.url = self._client.format_url(request.url) # type: ignore else: - - request = build_resource_groups_list_request( - subscription_id=self._config.subscription_id, - template_url=next_link, - ) + # make call to next link with the client's api-version + _parsed_next_link = urlparse(next_link) + _next_request_params = case_insensitive_dict(parse_qs(_parsed_next_link.query)) + _next_request_params["api-version"] = self._config.api_version + request = HttpRequest("GET", urljoin(next_link, _parsed_next_link.path), params=_next_request_params) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore request.method = "GET" return request @@ -6553,10 +8729,8 @@ async def extract_data(pipeline_response): async def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) response = pipeline_response.http_response @@ -6566,39 +8740,33 @@ async def get_next(next_link=None): return pipeline_response + return AsyncItemPaged(get_next, extract_data) - return AsyncItemPaged( - get_next, extract_data - ) - list.metadata = {'url': "/subscriptions/{subscriptionId}/resourcegroups"} # type: ignore -class TagsOperations: - """TagsOperations async operations. + list.metadata = {"url": "/subscriptions/{subscriptionId}/resourcegroups"} # type: ignore - You should not instantiate this class directly. Instead, you should create a Client instance that - instantiates it for you and attaches it as an attribute. - :ivar models: Alias to model classes used in this operation group. - :type models: ~azure.mgmt.resource.resources.v2020_06_01.models - :param client: Client for service requests. - :param config: Configuration of service client. - :param serializer: An object model serializer. - :param deserializer: An object model deserializer. +class TagsOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. + + Instead, you should access the following operations through + :class:`~azure.mgmt.resource.resources.v2020_06_01.aio.ResourceManagementClient`'s + :attr:`tags` attribute. """ models = _models - def __init__(self, client, config, serializer, deserializer) -> None: - self._client = client - self._serialize = serializer - self._deserialize = deserializer - self._config = config + def __init__(self, *args, **kwargs) -> None: + input_args = list(args) + self._client = input_args.pop(0) if input_args else kwargs.pop("client") + self._config = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") @distributed_trace_async async def delete_value( # pylint: disable=inconsistent-return-statements - self, - tag_name: str, - tag_value: str, - **kwargs: Any + self, tag_name: str, tag_value: str, **kwargs: Any ) -> None: """Deletes a predefined tag value for a predefined tag name. @@ -6606,39 +8774,45 @@ async def delete_value( # pylint: disable=inconsistent-return-statements predefined tag name. The value being deleted must not be in use as a tag value for the given tag name for any resource. - :param tag_name: The name of the tag. + :param tag_name: The name of the tag. Required. :type tag_name: str - :param tag_value: The value of the tag to delete. + :param tag_value: The value of the tag to delete. Required. :type tag_value: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: None, or the result of cls(response) + :return: None or the result of cls(response) :rtype: None - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType[None] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + 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', "2020-06-01") # type: str + api_version = kwargs.pop("api_version", _params.pop("api-version", "2020-06-01")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[None] - request = build_tags_delete_value_request( tag_name=tag_name, tag_value=tag_value, subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.delete_value.metadata['url'], + template_url=self.delete_value.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200, 204]: @@ -6648,54 +8822,54 @@ async def delete_value( # pylint: disable=inconsistent-return-statements if cls: return cls(pipeline_response, None, {}) - delete_value.metadata = {'url': "/subscriptions/{subscriptionId}/tagNames/{tagName}/tagValues/{tagValue}"} # type: ignore - + delete_value.metadata = {"url": "/subscriptions/{subscriptionId}/tagNames/{tagName}/tagValues/{tagValue}"} # type: ignore @distributed_trace_async - async def create_or_update_value( - self, - tag_name: str, - tag_value: str, - **kwargs: Any - ) -> "_models.TagValue": + async def create_or_update_value(self, tag_name: str, tag_value: str, **kwargs: Any) -> _models.TagValue: """Creates a predefined value for a predefined tag name. This operation allows adding a value to the list of predefined values for an existing predefined tag name. A tag value can have a maximum of 256 characters. - :param tag_name: The name of the tag. + :param tag_name: The name of the tag. Required. :type tag_name: str - :param tag_value: The value of the tag to create. + :param tag_value: The value of the tag to create. Required. :type tag_value: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: TagValue, or the result of cls(response) + :return: TagValue or the result of cls(response) :rtype: ~azure.mgmt.resource.resources.v2020_06_01.models.TagValue - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.TagValue"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) - api_version = kwargs.pop('api_version', "2020-06-01") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2020-06-01")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[_models.TagValue] - request = build_tags_create_or_update_value_request( tag_name=tag_name, tag_value=tag_value, subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.create_or_update_value.metadata['url'], + template_url=self.create_or_update_value.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200, 201]: @@ -6703,25 +8877,20 @@ async def create_or_update_value( raise HttpResponseError(response=response, error_format=ARMErrorFormat) if response.status_code == 200: - deserialized = self._deserialize('TagValue', pipeline_response) + deserialized = self._deserialize("TagValue", pipeline_response) if response.status_code == 201: - deserialized = self._deserialize('TagValue', pipeline_response) + deserialized = self._deserialize("TagValue", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - create_or_update_value.metadata = {'url': "/subscriptions/{subscriptionId}/tagNames/{tagName}/tagValues/{tagValue}"} # type: ignore - + create_or_update_value.metadata = {"url": "/subscriptions/{subscriptionId}/tagNames/{tagName}/tagValues/{tagValue}"} # type: ignore @distributed_trace_async - async def create_or_update( - self, - tag_name: str, - **kwargs: Any - ) -> "_models.TagDetails": + async def create_or_update(self, tag_name: str, **kwargs: Any) -> _models.TagDetails: """Creates a predefined tag name. This operation allows adding a name to the list of predefined tag names for the given @@ -6729,36 +8898,42 @@ async def create_or_update( names cannot have the following prefixes which are reserved for Azure use: 'microsoft', 'azure', 'windows'. - :param tag_name: The name of the tag to create. + :param tag_name: The name of the tag to create. Required. :type tag_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: TagDetails, or the result of cls(response) + :return: TagDetails or the result of cls(response) :rtype: ~azure.mgmt.resource.resources.v2020_06_01.models.TagDetails - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.TagDetails"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) - api_version = kwargs.pop('api_version', "2020-06-01") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2020-06-01")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[_models.TagDetails] - request = build_tags_create_or_update_request( tag_name=tag_name, subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.create_or_update.metadata['url'], + template_url=self.create_or_update.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200, 201]: @@ -6766,61 +8941,62 @@ async def create_or_update( raise HttpResponseError(response=response, error_format=ARMErrorFormat) if response.status_code == 200: - deserialized = self._deserialize('TagDetails', pipeline_response) + deserialized = self._deserialize("TagDetails", pipeline_response) if response.status_code == 201: - deserialized = self._deserialize('TagDetails', pipeline_response) + deserialized = self._deserialize("TagDetails", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - create_or_update.metadata = {'url': "/subscriptions/{subscriptionId}/tagNames/{tagName}"} # type: ignore - + create_or_update.metadata = {"url": "/subscriptions/{subscriptionId}/tagNames/{tagName}"} # type: ignore @distributed_trace_async - async def delete( # pylint: disable=inconsistent-return-statements - self, - tag_name: str, - **kwargs: Any - ) -> None: + async def delete(self, tag_name: str, **kwargs: Any) -> None: # pylint: disable=inconsistent-return-statements """Deletes a predefined tag name. This operation allows deleting a name from the list of predefined tag names for the given subscription. The name being deleted must not be in use as a tag name for any resource. All predefined values for the given name must have already been deleted. - :param tag_name: The name of the tag. + :param tag_name: The name of the tag. Required. :type tag_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: None, or the result of cls(response) + :return: None or the result of cls(response) :rtype: None - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType[None] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) - api_version = kwargs.pop('api_version', "2020-06-01") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2020-06-01")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[None] - request = build_tags_delete_request( tag_name=tag_name, subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.delete.metadata['url'], + template_url=self.delete.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200, 204]: @@ -6830,14 +9006,10 @@ async def delete( # pylint: disable=inconsistent-return-statements if cls: return cls(pipeline_response, None, {}) - delete.metadata = {'url': "/subscriptions/{subscriptionId}/tagNames/{tagName}"} # type: ignore - + delete.metadata = {"url": "/subscriptions/{subscriptionId}/tagNames/{tagName}"} # type: ignore @distributed_trace - def list( - self, - **kwargs: Any - ) -> AsyncIterable["_models.TagsListResult"]: + def list(self, **kwargs: Any) -> AsyncIterable["_models.TagDetails"]: """Gets a summary of tag usage under the subscription. This operation performs a union of predefined tags, resource tags, resource group tags and @@ -6846,37 +9018,46 @@ def list( result. :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either TagsListResult or the result of cls(response) + :return: An iterator like instance of either TagDetails or the result of cls(response) :rtype: - ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.resource.resources.v2020_06_01.models.TagsListResult] - :raises: ~azure.core.exceptions.HttpResponseError + ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.resource.resources.v2020_06_01.models.TagDetails] + :raises ~azure.core.exceptions.HttpResponseError: """ - api_version = kwargs.pop('api_version', "2020-06-01") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2020-06-01")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[_models.TagsListResult] - cls = kwargs.pop('cls', None) # type: ClsType["_models.TagsListResult"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) + def prepare_request(next_link=None): if not next_link: - + request = build_tags_list_request( subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.list.metadata['url'], + template_url=self.list.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore else: - - request = build_tags_list_request( - subscription_id=self._config.subscription_id, - template_url=next_link, - ) + # make call to next link with the client's api-version + _parsed_next_link = urlparse(next_link) + _next_request_params = case_insensitive_dict(parse_qs(_parsed_next_link.query)) + _next_request_params["api-version"] = self._config.api_version + request = HttpRequest("GET", urljoin(next_link, _parsed_next_link.path), params=_next_request_params) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore request.method = "GET" return request @@ -6890,10 +9071,8 @@ async def extract_data(pipeline_response): async def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) response = pipeline_response.http_response @@ -6903,82 +9082,139 @@ async def get_next(next_link=None): return pipeline_response + return AsyncItemPaged(get_next, extract_data) - return AsyncItemPaged( - get_next, extract_data - ) - list.metadata = {'url': "/subscriptions/{subscriptionId}/tagNames"} # type: ignore + list.metadata = {"url": "/subscriptions/{subscriptionId}/tagNames"} # type: ignore - @distributed_trace_async + @overload async def create_or_update_at_scope( - self, - scope: str, - parameters: "_models.TagsResource", - **kwargs: Any - ) -> "_models.TagsResource": + self, scope: str, parameters: _models.TagsResource, *, content_type: str = "application/json", **kwargs: Any + ) -> _models.TagsResource: """Creates or updates the entire set of tags on a resource or subscription. This operation allows adding or replacing the entire set of tags on the specified resource or subscription. The specified entity can have a maximum of 50 tags. - :param scope: The resource scope. + :param scope: The resource scope. Required. :type scope: str - :param parameters: + :param parameters: Required. :type parameters: ~azure.mgmt.resource.resources.v2020_06_01.models.TagsResource + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: TagsResource or the result of cls(response) + :rtype: ~azure.mgmt.resource.resources.v2020_06_01.models.TagsResource + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + async def create_or_update_at_scope( + self, scope: str, parameters: IO, *, content_type: str = "application/json", **kwargs: Any + ) -> _models.TagsResource: + """Creates or updates the entire set of tags on a resource or subscription. + + This operation allows adding or replacing the entire set of tags on the specified resource or + subscription. The specified entity can have a maximum of 50 tags. + + :param scope: The resource scope. Required. + :type scope: str + :param parameters: Required. + :type parameters: IO + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: TagsResource or the result of cls(response) + :rtype: ~azure.mgmt.resource.resources.v2020_06_01.models.TagsResource + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace_async + async def create_or_update_at_scope( + self, scope: str, parameters: Union[_models.TagsResource, IO], **kwargs: Any + ) -> _models.TagsResource: + """Creates or updates the entire set of tags on a resource or subscription. + + This operation allows adding or replacing the entire set of tags on the specified resource or + subscription. The specified entity can have a maximum of 50 tags. + + :param scope: The resource scope. Required. + :type scope: str + :param parameters: Is either a model type or a IO type. Required. + :type parameters: ~azure.mgmt.resource.resources.v2020_06_01.models.TagsResource or IO + :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. + Default value is None. + :paramtype content_type: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: TagsResource, or the result of cls(response) + :return: TagsResource or the result of cls(response) :rtype: ~azure.mgmt.resource.resources.v2020_06_01.models.TagsResource - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.TagsResource"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) - api_version = kwargs.pop('api_version', "2020-06-01") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - _json = self._serialize.body(parameters, 'TagsResource') + api_version = kwargs.pop("api_version", _params.pop("api-version", "2020-06-01")) # type: str + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.TagsResource] + + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(parameters, (IO, bytes)): + _content = parameters + else: + _json = self._serialize.body(parameters, "TagsResource") request = build_tags_create_or_update_at_scope_request( scope=scope, api_version=api_version, content_type=content_type, json=_json, - template_url=self.create_or_update_at_scope.metadata['url'], + content=_content, + template_url=self.create_or_update_at_scope.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) - deserialized = self._deserialize('TagsResource', pipeline_response) + deserialized = self._deserialize("TagsResource", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - create_or_update_at_scope.metadata = {'url': "/{scope}/providers/Microsoft.Resources/tags/default"} # type: ignore + create_or_update_at_scope.metadata = {"url": "/{scope}/providers/Microsoft.Resources/tags/default"} # type: ignore - - @distributed_trace_async + @overload async def update_at_scope( self, scope: str, - parameters: "_models.TagsPatchResource", + parameters: _models.TagsPatchResource, + *, + content_type: str = "application/json", **kwargs: Any - ) -> "_models.TagsResource": + ) -> _models.TagsResource: """Selectively updates the set of tags on a resource or subscription. This operation allows replacing, merging or selectively deleting tags on the specified resource @@ -6988,151 +9224,224 @@ async def update_at_scope( names. The 'delete' option allows selectively deleting tags based on given names or name/value pairs. - :param scope: The resource scope. + :param scope: The resource scope. Required. :type scope: str - :param parameters: + :param parameters: Required. :type parameters: ~azure.mgmt.resource.resources.v2020_06_01.models.TagsPatchResource + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: TagsResource or the result of cls(response) + :rtype: ~azure.mgmt.resource.resources.v2020_06_01.models.TagsResource + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + async def update_at_scope( + self, scope: str, parameters: IO, *, content_type: str = "application/json", **kwargs: Any + ) -> _models.TagsResource: + """Selectively updates the set of tags on a resource or subscription. + + This operation allows replacing, merging or selectively deleting tags on the specified resource + or subscription. The specified entity can have a maximum of 50 tags at the end of the + operation. The 'replace' option replaces the entire set of existing tags with a new set. The + 'merge' option allows adding tags with new names and updating the values of tags with existing + names. The 'delete' option allows selectively deleting tags based on given names or name/value + pairs. + + :param scope: The resource scope. Required. + :type scope: str + :param parameters: Required. + :type parameters: IO + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: TagsResource or the result of cls(response) + :rtype: ~azure.mgmt.resource.resources.v2020_06_01.models.TagsResource + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace_async + async def update_at_scope( + self, scope: str, parameters: Union[_models.TagsPatchResource, IO], **kwargs: Any + ) -> _models.TagsResource: + """Selectively updates the set of tags on a resource or subscription. + + This operation allows replacing, merging or selectively deleting tags on the specified resource + or subscription. The specified entity can have a maximum of 50 tags at the end of the + operation. The 'replace' option replaces the entire set of existing tags with a new set. The + 'merge' option allows adding tags with new names and updating the values of tags with existing + names. The 'delete' option allows selectively deleting tags based on given names or name/value + pairs. + + :param scope: The resource scope. Required. + :type scope: str + :param parameters: Is either a model type or a IO type. Required. + :type parameters: ~azure.mgmt.resource.resources.v2020_06_01.models.TagsPatchResource or IO + :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. + Default value is None. + :paramtype content_type: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: TagsResource, or the result of cls(response) + :return: TagsResource or the result of cls(response) :rtype: ~azure.mgmt.resource.resources.v2020_06_01.models.TagsResource - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.TagsResource"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) - api_version = kwargs.pop('api_version', "2020-06-01") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - _json = self._serialize.body(parameters, 'TagsPatchResource') + api_version = kwargs.pop("api_version", _params.pop("api-version", "2020-06-01")) # type: str + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.TagsResource] + + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(parameters, (IO, bytes)): + _content = parameters + else: + _json = self._serialize.body(parameters, "TagsPatchResource") request = build_tags_update_at_scope_request( scope=scope, api_version=api_version, content_type=content_type, json=_json, - template_url=self.update_at_scope.metadata['url'], + content=_content, + template_url=self.update_at_scope.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) - deserialized = self._deserialize('TagsResource', pipeline_response) + deserialized = self._deserialize("TagsResource", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - update_at_scope.metadata = {'url': "/{scope}/providers/Microsoft.Resources/tags/default"} # type: ignore - + update_at_scope.metadata = {"url": "/{scope}/providers/Microsoft.Resources/tags/default"} # type: ignore @distributed_trace_async - async def get_at_scope( - self, - scope: str, - **kwargs: Any - ) -> "_models.TagsResource": + async def get_at_scope(self, scope: str, **kwargs: Any) -> _models.TagsResource: """Gets the entire set of tags on a resource or subscription. Gets the entire set of tags on a resource or subscription. - :param scope: The resource scope. + :param scope: The resource scope. Required. :type scope: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: TagsResource, or the result of cls(response) + :return: TagsResource or the result of cls(response) :rtype: ~azure.mgmt.resource.resources.v2020_06_01.models.TagsResource - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.TagsResource"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + 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', "2020-06-01") # type: str + api_version = kwargs.pop("api_version", _params.pop("api-version", "2020-06-01")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[_models.TagsResource] - request = build_tags_get_at_scope_request( scope=scope, api_version=api_version, - template_url=self.get_at_scope.metadata['url'], + template_url=self.get_at_scope.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) - deserialized = self._deserialize('TagsResource', pipeline_response) + deserialized = self._deserialize("TagsResource", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - get_at_scope.metadata = {'url': "/{scope}/providers/Microsoft.Resources/tags/default"} # type: ignore - + get_at_scope.metadata = {"url": "/{scope}/providers/Microsoft.Resources/tags/default"} # type: ignore @distributed_trace_async async def delete_at_scope( # pylint: disable=inconsistent-return-statements - self, - scope: str, - **kwargs: Any + self, scope: str, **kwargs: Any ) -> None: """Deletes the entire set of tags on a resource or subscription. Deletes the entire set of tags on a resource or subscription. - :param scope: The resource scope. + :param scope: The resource scope. Required. :type scope: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: None, or the result of cls(response) + :return: None or the result of cls(response) :rtype: None - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType[None] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + 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', "2020-06-01") # type: str + api_version = kwargs.pop("api_version", _params.pop("api-version", "2020-06-01")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[None] - request = build_tags_delete_at_scope_request( scope=scope, api_version=api_version, - template_url=self.delete_at_scope.metadata['url'], + template_url=self.delete_at_scope.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200]: @@ -7142,143 +9451,145 @@ async def delete_at_scope( # pylint: disable=inconsistent-return-statements if cls: return cls(pipeline_response, None, {}) - delete_at_scope.metadata = {'url': "/{scope}/providers/Microsoft.Resources/tags/default"} # type: ignore + delete_at_scope.metadata = {"url": "/{scope}/providers/Microsoft.Resources/tags/default"} # type: ignore -class DeploymentOperationsOperations: - """DeploymentOperationsOperations async operations. - You should not instantiate this class directly. Instead, you should create a Client instance that - instantiates it for you and attaches it as an attribute. +class DeploymentOperationsOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. - :ivar models: Alias to model classes used in this operation group. - :type models: ~azure.mgmt.resource.resources.v2020_06_01.models - :param client: Client for service requests. - :param config: Configuration of service client. - :param serializer: An object model serializer. - :param deserializer: An object model deserializer. + Instead, you should access the following operations through + :class:`~azure.mgmt.resource.resources.v2020_06_01.aio.ResourceManagementClient`'s + :attr:`deployment_operations` attribute. """ models = _models - def __init__(self, client, config, serializer, deserializer) -> None: - self._client = client - self._serialize = serializer - self._deserialize = deserializer - self._config = config + def __init__(self, *args, **kwargs) -> None: + input_args = list(args) + self._client = input_args.pop(0) if input_args else kwargs.pop("client") + self._config = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") @distributed_trace_async async def get_at_scope( - self, - scope: str, - deployment_name: str, - operation_id: str, - **kwargs: Any - ) -> "_models.DeploymentOperation": + self, scope: str, deployment_name: str, operation_id: str, **kwargs: Any + ) -> _models.DeploymentOperation: """Gets a deployments operation. - :param scope: The resource scope. + :param scope: The resource scope. Required. :type scope: str - :param deployment_name: The name of the deployment. + :param deployment_name: The name of the deployment. Required. :type deployment_name: str - :param operation_id: The ID of the operation to get. + :param operation_id: The ID of the operation to get. Required. :type operation_id: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: DeploymentOperation, or the result of cls(response) + :return: DeploymentOperation or the result of cls(response) :rtype: ~azure.mgmt.resource.resources.v2020_06_01.models.DeploymentOperation - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.DeploymentOperation"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) - api_version = kwargs.pop('api_version', "2020-06-01") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2020-06-01")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[_models.DeploymentOperation] - request = build_deployment_operations_get_at_scope_request( scope=scope, deployment_name=deployment_name, operation_id=operation_id, api_version=api_version, - template_url=self.get_at_scope.metadata['url'], + template_url=self.get_at_scope.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) - deserialized = self._deserialize('DeploymentOperation', pipeline_response) + deserialized = self._deserialize("DeploymentOperation", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - get_at_scope.metadata = {'url': "/{scope}/providers/Microsoft.Resources/deployments/{deploymentName}/operations/{operationId}"} # type: ignore - + get_at_scope.metadata = {"url": "/{scope}/providers/Microsoft.Resources/deployments/{deploymentName}/operations/{operationId}"} # type: ignore @distributed_trace def list_at_scope( - self, - scope: str, - deployment_name: str, - top: Optional[int] = None, - **kwargs: Any - ) -> AsyncIterable["_models.DeploymentOperationsListResult"]: + self, scope: str, deployment_name: str, top: Optional[int] = None, **kwargs: Any + ) -> AsyncIterable["_models.DeploymentOperation"]: """Gets all deployments operations for a deployment. - :param scope: The resource scope. + :param scope: The resource scope. Required. :type scope: str - :param deployment_name: The name of the deployment. + :param deployment_name: The name of the deployment. Required. :type deployment_name: str :param top: The number of results to return. Default value is None. :type top: int :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either DeploymentOperationsListResult or the result of - cls(response) + :return: An iterator like instance of either DeploymentOperation or the result of cls(response) :rtype: - ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.resource.resources.v2020_06_01.models.DeploymentOperationsListResult] - :raises: ~azure.core.exceptions.HttpResponseError + ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.resource.resources.v2020_06_01.models.DeploymentOperation] + :raises ~azure.core.exceptions.HttpResponseError: """ - api_version = kwargs.pop('api_version', "2020-06-01") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2020-06-01")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[_models.DeploymentOperationsListResult] - cls = kwargs.pop('cls', None) # type: ClsType["_models.DeploymentOperationsListResult"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) + def prepare_request(next_link=None): if not next_link: - + request = build_deployment_operations_list_at_scope_request( scope=scope, deployment_name=deployment_name, - api_version=api_version, top=top, - template_url=self.list_at_scope.metadata['url'], + api_version=api_version, + template_url=self.list_at_scope.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore else: - - request = build_deployment_operations_list_at_scope_request( - scope=scope, - deployment_name=deployment_name, - template_url=next_link, - ) + # make call to next link with the client's api-version + _parsed_next_link = urlparse(next_link) + _next_request_params = case_insensitive_dict(parse_qs(_parsed_next_link.query)) + _next_request_params["api-version"] = self._config.api_version + request = HttpRequest("GET", urljoin(next_link, _parsed_next_link.path), params=_next_request_params) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore request.method = "GET" return request @@ -7292,10 +9603,8 @@ async def extract_data(pipeline_response): async def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) response = pipeline_response.http_response @@ -7305,116 +9614,121 @@ async def get_next(next_link=None): return pipeline_response + return AsyncItemPaged(get_next, extract_data) - return AsyncItemPaged( - get_next, extract_data - ) - list_at_scope.metadata = {'url': "/{scope}/providers/Microsoft.Resources/deployments/{deploymentName}/operations"} # type: ignore + list_at_scope.metadata = {"url": "/{scope}/providers/Microsoft.Resources/deployments/{deploymentName}/operations"} # type: ignore @distributed_trace_async async def get_at_tenant_scope( - self, - deployment_name: str, - operation_id: str, - **kwargs: Any - ) -> "_models.DeploymentOperation": + self, deployment_name: str, operation_id: str, **kwargs: Any + ) -> _models.DeploymentOperation: """Gets a deployments operation. - :param deployment_name: The name of the deployment. + :param deployment_name: The name of the deployment. Required. :type deployment_name: str - :param operation_id: The ID of the operation to get. + :param operation_id: The ID of the operation to get. Required. :type operation_id: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: DeploymentOperation, or the result of cls(response) + :return: DeploymentOperation or the result of cls(response) :rtype: ~azure.mgmt.resource.resources.v2020_06_01.models.DeploymentOperation - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.DeploymentOperation"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + 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', "2020-06-01") # type: str + api_version = kwargs.pop("api_version", _params.pop("api-version", "2020-06-01")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[_models.DeploymentOperation] - request = build_deployment_operations_get_at_tenant_scope_request( deployment_name=deployment_name, operation_id=operation_id, api_version=api_version, - template_url=self.get_at_tenant_scope.metadata['url'], + template_url=self.get_at_tenant_scope.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) - deserialized = self._deserialize('DeploymentOperation', pipeline_response) + deserialized = self._deserialize("DeploymentOperation", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - get_at_tenant_scope.metadata = {'url': "/providers/Microsoft.Resources/deployments/{deploymentName}/operations/{operationId}"} # type: ignore - + get_at_tenant_scope.metadata = {"url": "/providers/Microsoft.Resources/deployments/{deploymentName}/operations/{operationId}"} # type: ignore @distributed_trace def list_at_tenant_scope( - self, - deployment_name: str, - top: Optional[int] = None, - **kwargs: Any - ) -> AsyncIterable["_models.DeploymentOperationsListResult"]: + self, deployment_name: str, top: Optional[int] = None, **kwargs: Any + ) -> AsyncIterable["_models.DeploymentOperation"]: """Gets all deployments operations for a deployment. - :param deployment_name: The name of the deployment. + :param deployment_name: The name of the deployment. Required. :type deployment_name: str :param top: The number of results to return. Default value is None. :type top: int :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either DeploymentOperationsListResult or the result of - cls(response) + :return: An iterator like instance of either DeploymentOperation or the result of cls(response) :rtype: - ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.resource.resources.v2020_06_01.models.DeploymentOperationsListResult] - :raises: ~azure.core.exceptions.HttpResponseError + ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.resource.resources.v2020_06_01.models.DeploymentOperation] + :raises ~azure.core.exceptions.HttpResponseError: """ - api_version = kwargs.pop('api_version', "2020-06-01") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2020-06-01")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[_models.DeploymentOperationsListResult] - cls = kwargs.pop('cls', None) # type: ClsType["_models.DeploymentOperationsListResult"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) + def prepare_request(next_link=None): if not next_link: - + request = build_deployment_operations_list_at_tenant_scope_request( deployment_name=deployment_name, - api_version=api_version, top=top, - template_url=self.list_at_tenant_scope.metadata['url'], + api_version=api_version, + template_url=self.list_at_tenant_scope.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore else: - - request = build_deployment_operations_list_at_tenant_scope_request( - deployment_name=deployment_name, - template_url=next_link, - ) + # make call to next link with the client's api-version + _parsed_next_link = urlparse(next_link) + _next_request_params = case_insensitive_dict(parse_qs(_parsed_next_link.query)) + _next_request_params["api-version"] = self._config.api_version + request = HttpRequest("GET", urljoin(next_link, _parsed_next_link.path), params=_next_request_params) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore request.method = "GET" return request @@ -7428,10 +9742,8 @@ async def extract_data(pipeline_response): async def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) response = pipeline_response.http_response @@ -7441,125 +9753,127 @@ async def get_next(next_link=None): return pipeline_response + return AsyncItemPaged(get_next, extract_data) - return AsyncItemPaged( - get_next, extract_data - ) - list_at_tenant_scope.metadata = {'url': "/providers/Microsoft.Resources/deployments/{deploymentName}/operations"} # type: ignore + list_at_tenant_scope.metadata = {"url": "/providers/Microsoft.Resources/deployments/{deploymentName}/operations"} # type: ignore @distributed_trace_async async def get_at_management_group_scope( - self, - group_id: str, - deployment_name: str, - operation_id: str, - **kwargs: Any - ) -> "_models.DeploymentOperation": + self, group_id: str, deployment_name: str, operation_id: str, **kwargs: Any + ) -> _models.DeploymentOperation: """Gets a deployments operation. - :param group_id: The management group ID. + :param group_id: The management group ID. Required. :type group_id: str - :param deployment_name: The name of the deployment. + :param deployment_name: The name of the deployment. Required. :type deployment_name: str - :param operation_id: The ID of the operation to get. + :param operation_id: The ID of the operation to get. Required. :type operation_id: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: DeploymentOperation, or the result of cls(response) + :return: DeploymentOperation or the result of cls(response) :rtype: ~azure.mgmt.resource.resources.v2020_06_01.models.DeploymentOperation - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.DeploymentOperation"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + 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', "2020-06-01") # type: str + api_version = kwargs.pop("api_version", _params.pop("api-version", "2020-06-01")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[_models.DeploymentOperation] - request = build_deployment_operations_get_at_management_group_scope_request( group_id=group_id, deployment_name=deployment_name, operation_id=operation_id, api_version=api_version, - template_url=self.get_at_management_group_scope.metadata['url'], + template_url=self.get_at_management_group_scope.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) - deserialized = self._deserialize('DeploymentOperation', pipeline_response) + deserialized = self._deserialize("DeploymentOperation", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - get_at_management_group_scope.metadata = {'url': "/providers/Microsoft.Management/managementGroups/{groupId}/providers/Microsoft.Resources/deployments/{deploymentName}/operations/{operationId}"} # type: ignore - + get_at_management_group_scope.metadata = {"url": "/providers/Microsoft.Management/managementGroups/{groupId}/providers/Microsoft.Resources/deployments/{deploymentName}/operations/{operationId}"} # type: ignore @distributed_trace def list_at_management_group_scope( - self, - group_id: str, - deployment_name: str, - top: Optional[int] = None, - **kwargs: Any - ) -> AsyncIterable["_models.DeploymentOperationsListResult"]: + self, group_id: str, deployment_name: str, top: Optional[int] = None, **kwargs: Any + ) -> AsyncIterable["_models.DeploymentOperation"]: """Gets all deployments operations for a deployment. - :param group_id: The management group ID. + :param group_id: The management group ID. Required. :type group_id: str - :param deployment_name: The name of the deployment. + :param deployment_name: The name of the deployment. Required. :type deployment_name: str :param top: The number of results to return. Default value is None. :type top: int :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either DeploymentOperationsListResult or the result of - cls(response) + :return: An iterator like instance of either DeploymentOperation or the result of cls(response) :rtype: - ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.resource.resources.v2020_06_01.models.DeploymentOperationsListResult] - :raises: ~azure.core.exceptions.HttpResponseError + ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.resource.resources.v2020_06_01.models.DeploymentOperation] + :raises ~azure.core.exceptions.HttpResponseError: """ - api_version = kwargs.pop('api_version', "2020-06-01") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2020-06-01")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[_models.DeploymentOperationsListResult] - cls = kwargs.pop('cls', None) # type: ClsType["_models.DeploymentOperationsListResult"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) + def prepare_request(next_link=None): if not next_link: - + request = build_deployment_operations_list_at_management_group_scope_request( group_id=group_id, deployment_name=deployment_name, - api_version=api_version, top=top, - template_url=self.list_at_management_group_scope.metadata['url'], + api_version=api_version, + template_url=self.list_at_management_group_scope.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore else: - - request = build_deployment_operations_list_at_management_group_scope_request( - group_id=group_id, - deployment_name=deployment_name, - template_url=next_link, - ) + # make call to next link with the client's api-version + _parsed_next_link = urlparse(next_link) + _next_request_params = case_insensitive_dict(parse_qs(_parsed_next_link.query)) + _next_request_params["api-version"] = self._config.api_version + request = HttpRequest("GET", urljoin(next_link, _parsed_next_link.path), params=_next_request_params) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore request.method = "GET" return request @@ -7573,10 +9887,8 @@ async def extract_data(pipeline_response): async def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) response = pipeline_response.http_response @@ -7586,119 +9898,123 @@ async def get_next(next_link=None): return pipeline_response + return AsyncItemPaged(get_next, extract_data) - return AsyncItemPaged( - get_next, extract_data - ) - list_at_management_group_scope.metadata = {'url': "/providers/Microsoft.Management/managementGroups/{groupId}/providers/Microsoft.Resources/deployments/{deploymentName}/operations"} # type: ignore + list_at_management_group_scope.metadata = {"url": "/providers/Microsoft.Management/managementGroups/{groupId}/providers/Microsoft.Resources/deployments/{deploymentName}/operations"} # type: ignore @distributed_trace_async async def get_at_subscription_scope( - self, - deployment_name: str, - operation_id: str, - **kwargs: Any - ) -> "_models.DeploymentOperation": + self, deployment_name: str, operation_id: str, **kwargs: Any + ) -> _models.DeploymentOperation: """Gets a deployments operation. - :param deployment_name: The name of the deployment. + :param deployment_name: The name of the deployment. Required. :type deployment_name: str - :param operation_id: The ID of the operation to get. + :param operation_id: The ID of the operation to get. Required. :type operation_id: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: DeploymentOperation, or the result of cls(response) + :return: DeploymentOperation or the result of cls(response) :rtype: ~azure.mgmt.resource.resources.v2020_06_01.models.DeploymentOperation - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.DeploymentOperation"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) - api_version = kwargs.pop('api_version', "2020-06-01") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2020-06-01")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[_models.DeploymentOperation] - request = build_deployment_operations_get_at_subscription_scope_request( deployment_name=deployment_name, operation_id=operation_id, subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.get_at_subscription_scope.metadata['url'], + template_url=self.get_at_subscription_scope.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) - deserialized = self._deserialize('DeploymentOperation', pipeline_response) + deserialized = self._deserialize("DeploymentOperation", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - get_at_subscription_scope.metadata = {'url': "/subscriptions/{subscriptionId}/providers/Microsoft.Resources/deployments/{deploymentName}/operations/{operationId}"} # type: ignore - + get_at_subscription_scope.metadata = {"url": "/subscriptions/{subscriptionId}/providers/Microsoft.Resources/deployments/{deploymentName}/operations/{operationId}"} # type: ignore @distributed_trace def list_at_subscription_scope( - self, - deployment_name: str, - top: Optional[int] = None, - **kwargs: Any - ) -> AsyncIterable["_models.DeploymentOperationsListResult"]: + self, deployment_name: str, top: Optional[int] = None, **kwargs: Any + ) -> AsyncIterable["_models.DeploymentOperation"]: """Gets all deployments operations for a deployment. - :param deployment_name: The name of the deployment. + :param deployment_name: The name of the deployment. Required. :type deployment_name: str :param top: The number of results to return. Default value is None. :type top: int :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either DeploymentOperationsListResult or the result of - cls(response) + :return: An iterator like instance of either DeploymentOperation or the result of cls(response) :rtype: - ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.resource.resources.v2020_06_01.models.DeploymentOperationsListResult] - :raises: ~azure.core.exceptions.HttpResponseError + ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.resource.resources.v2020_06_01.models.DeploymentOperation] + :raises ~azure.core.exceptions.HttpResponseError: """ - api_version = kwargs.pop('api_version', "2020-06-01") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2020-06-01")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[_models.DeploymentOperationsListResult] - cls = kwargs.pop('cls', None) # type: ClsType["_models.DeploymentOperationsListResult"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) + def prepare_request(next_link=None): if not next_link: - + request = build_deployment_operations_list_at_subscription_scope_request( deployment_name=deployment_name, subscription_id=self._config.subscription_id, - api_version=api_version, top=top, - template_url=self.list_at_subscription_scope.metadata['url'], + api_version=api_version, + template_url=self.list_at_subscription_scope.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore else: - - request = build_deployment_operations_list_at_subscription_scope_request( - deployment_name=deployment_name, - subscription_id=self._config.subscription_id, - template_url=next_link, - ) + # make call to next link with the client's api-version + _parsed_next_link = urlparse(next_link) + _next_request_params = case_insensitive_dict(parse_qs(_parsed_next_link.query)) + _next_request_params["api-version"] = self._config.api_version + request = HttpRequest("GET", urljoin(next_link, _parsed_next_link.path), params=_next_request_params) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore request.method = "GET" return request @@ -7712,10 +10028,8 @@ async def extract_data(pipeline_response): async def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) response = pipeline_response.http_response @@ -7725,128 +10039,131 @@ async def get_next(next_link=None): return pipeline_response + return AsyncItemPaged(get_next, extract_data) - return AsyncItemPaged( - get_next, extract_data - ) - list_at_subscription_scope.metadata = {'url': "/subscriptions/{subscriptionId}/providers/Microsoft.Resources/deployments/{deploymentName}/operations"} # type: ignore + list_at_subscription_scope.metadata = {"url": "/subscriptions/{subscriptionId}/providers/Microsoft.Resources/deployments/{deploymentName}/operations"} # type: ignore @distributed_trace_async async def get( - self, - resource_group_name: str, - deployment_name: str, - operation_id: str, - **kwargs: Any - ) -> "_models.DeploymentOperation": + self, resource_group_name: str, deployment_name: str, operation_id: str, **kwargs: Any + ) -> _models.DeploymentOperation: """Gets a deployments operation. :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. :type resource_group_name: str - :param deployment_name: The name of the deployment. + :param deployment_name: The name of the deployment. Required. :type deployment_name: str - :param operation_id: The ID of the operation to get. + :param operation_id: The ID of the operation to get. Required. :type operation_id: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: DeploymentOperation, or the result of cls(response) + :return: DeploymentOperation or the result of cls(response) :rtype: ~azure.mgmt.resource.resources.v2020_06_01.models.DeploymentOperation - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.DeploymentOperation"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + 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', "2020-06-01") # type: str + api_version = kwargs.pop("api_version", _params.pop("api-version", "2020-06-01")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[_models.DeploymentOperation] - request = build_deployment_operations_get_request( resource_group_name=resource_group_name, deployment_name=deployment_name, operation_id=operation_id, subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.get.metadata['url'], + template_url=self.get.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) - deserialized = self._deserialize('DeploymentOperation', pipeline_response) + deserialized = self._deserialize("DeploymentOperation", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - get.metadata = {'url': "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/deployments/{deploymentName}/operations/{operationId}"} # type: ignore - + get.metadata = {"url": "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/deployments/{deploymentName}/operations/{operationId}"} # type: ignore @distributed_trace def list( - self, - resource_group_name: str, - deployment_name: str, - top: Optional[int] = None, - **kwargs: Any - ) -> AsyncIterable["_models.DeploymentOperationsListResult"]: + self, resource_group_name: str, deployment_name: str, top: Optional[int] = None, **kwargs: Any + ) -> AsyncIterable["_models.DeploymentOperation"]: """Gets all deployments operations for a deployment. :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. :type resource_group_name: str - :param deployment_name: The name of the deployment. + :param deployment_name: The name of the deployment. Required. :type deployment_name: str :param top: The number of results to return. Default value is None. :type top: int :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either DeploymentOperationsListResult or the result of - cls(response) + :return: An iterator like instance of either DeploymentOperation or the result of cls(response) :rtype: - ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.resource.resources.v2020_06_01.models.DeploymentOperationsListResult] - :raises: ~azure.core.exceptions.HttpResponseError + ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.resource.resources.v2020_06_01.models.DeploymentOperation] + :raises ~azure.core.exceptions.HttpResponseError: """ - api_version = kwargs.pop('api_version', "2020-06-01") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2020-06-01")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[_models.DeploymentOperationsListResult] - cls = kwargs.pop('cls', None) # type: ClsType["_models.DeploymentOperationsListResult"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) + def prepare_request(next_link=None): if not next_link: - + request = build_deployment_operations_list_request( resource_group_name=resource_group_name, deployment_name=deployment_name, subscription_id=self._config.subscription_id, - api_version=api_version, top=top, - template_url=self.list.metadata['url'], + 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.url = self._client.format_url(request.url) # type: ignore else: - - request = build_deployment_operations_list_request( - resource_group_name=resource_group_name, - deployment_name=deployment_name, - subscription_id=self._config.subscription_id, - template_url=next_link, - ) + # make call to next link with the client's api-version + _parsed_next_link = urlparse(next_link) + _next_request_params = case_insensitive_dict(parse_qs(_parsed_next_link.query)) + _next_request_params["api-version"] = self._config.api_version + request = HttpRequest("GET", urljoin(next_link, _parsed_next_link.path), params=_next_request_params) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore request.method = "GET" return request @@ -7860,10 +10177,8 @@ async def extract_data(pipeline_response): async def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) response = pipeline_response.http_response @@ -7873,8 +10188,6 @@ async def get_next(next_link=None): return pipeline_response + return AsyncItemPaged(get_next, extract_data) - return AsyncItemPaged( - get_next, extract_data - ) - list.metadata = {'url': "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/deployments/{deploymentName}/operations"} # type: ignore + list.metadata = {"url": "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/deployments/{deploymentName}/operations"} # type: ignore diff --git a/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/resources/v2020_06_01/aio/operations/_patch.py b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/resources/v2020_06_01/aio/operations/_patch.py new file mode 100644 index 0000000000000..f7dd32510333d --- /dev/null +++ b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/resources/v2020_06_01/aio/operations/_patch.py @@ -0,0 +1,20 @@ +# ------------------------------------ +# Copyright (c) Microsoft Corporation. +# Licensed under the MIT License. +# ------------------------------------ +"""Customize generated code here. + +Follow our quickstart for examples: https://aka.ms/azsdk/python/dpcodegen/python/customize +""" +from typing import List + +__all__: List[str] = [] # Add all objects you want publicly available to users at this package level + + +def patch_sdk(): + """Do not remove from this file. + + `patch_sdk` is a last resort escape hatch that allows you to do customizations + you can't accomplish using the techniques described in + https://aka.ms/azsdk/python/dpcodegen/python/customize + """ diff --git a/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/resources/v2020_06_01/models/__init__.py b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/resources/v2020_06_01/models/__init__.py index 66b190955e4c0..2c6ac10ab162c 100644 --- a/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/resources/v2020_06_01/models/__init__.py +++ b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/resources/v2020_06_01/models/__init__.py @@ -79,109 +79,111 @@ from ._models_py3 import WhatIfPropertyChange from ._models_py3 import ZoneMapping - -from ._resource_management_client_enums import ( - AliasPathAttributes, - AliasPathTokenType, - AliasPatternType, - AliasType, - ChangeType, - DeploymentMode, - ExpressionEvaluationOptionsScopeType, - OnErrorDeploymentType, - PropertyChangeType, - ProvisioningOperation, - ProvisioningState, - ResourceIdentityType, - TagsPatchOperation, - WhatIfResultFormat, -) +from ._resource_management_client_enums import AliasPathAttributes +from ._resource_management_client_enums import AliasPathTokenType +from ._resource_management_client_enums import AliasPatternType +from ._resource_management_client_enums import AliasType +from ._resource_management_client_enums import ChangeType +from ._resource_management_client_enums import DeploymentMode +from ._resource_management_client_enums import ExpressionEvaluationOptionsScopeType +from ._resource_management_client_enums import OnErrorDeploymentType +from ._resource_management_client_enums import PropertyChangeType +from ._resource_management_client_enums import ProvisioningOperation +from ._resource_management_client_enums import ProvisioningState +from ._resource_management_client_enums import ResourceIdentityType +from ._resource_management_client_enums import TagsPatchOperation +from ._resource_management_client_enums import WhatIfResultFormat +from ._patch import __all__ as _patch_all +from ._patch import * # type: ignore # pylint: disable=unused-wildcard-import +from ._patch import patch_sdk as _patch_sdk __all__ = [ - 'Alias', - 'AliasPath', - 'AliasPathMetadata', - 'AliasPattern', - 'ApiProfile', - 'BasicDependency', - 'DebugSetting', - 'Dependency', - 'Deployment', - 'DeploymentExportResult', - 'DeploymentExtended', - 'DeploymentExtendedFilter', - 'DeploymentListResult', - 'DeploymentOperation', - 'DeploymentOperationProperties', - 'DeploymentOperationsListResult', - 'DeploymentProperties', - 'DeploymentPropertiesExtended', - 'DeploymentValidateResult', - 'DeploymentWhatIf', - 'DeploymentWhatIfProperties', - 'DeploymentWhatIfSettings', - 'ErrorAdditionalInfo', - 'ErrorResponse', - 'ExportTemplateRequest', - 'ExpressionEvaluationOptions', - 'GenericResource', - 'GenericResourceExpanded', - 'GenericResourceFilter', - 'HttpMessage', - 'Identity', - 'IdentityUserAssignedIdentitiesValue', - 'OnErrorDeployment', - 'OnErrorDeploymentExtended', - 'Operation', - 'OperationDisplay', - 'OperationListResult', - 'ParametersLink', - 'Plan', - 'Provider', - 'ProviderListResult', - 'ProviderResourceType', - 'Resource', - 'ResourceGroup', - 'ResourceGroupExportResult', - 'ResourceGroupFilter', - 'ResourceGroupListResult', - 'ResourceGroupPatchable', - 'ResourceGroupProperties', - 'ResourceListResult', - 'ResourceProviderOperationDisplayProperties', - 'ResourceReference', - 'ResourcesMoveInfo', - 'ScopedDeployment', - 'ScopedDeploymentWhatIf', - 'Sku', - 'StatusMessage', - 'SubResource', - 'TagCount', - 'TagDetails', - 'TagValue', - 'Tags', - 'TagsListResult', - 'TagsPatchResource', - 'TagsResource', - 'TargetResource', - 'TemplateHashResult', - 'TemplateLink', - 'WhatIfChange', - 'WhatIfOperationResult', - 'WhatIfPropertyChange', - 'ZoneMapping', - 'AliasPathAttributes', - 'AliasPathTokenType', - 'AliasPatternType', - 'AliasType', - 'ChangeType', - 'DeploymentMode', - 'ExpressionEvaluationOptionsScopeType', - 'OnErrorDeploymentType', - 'PropertyChangeType', - 'ProvisioningOperation', - 'ProvisioningState', - 'ResourceIdentityType', - 'TagsPatchOperation', - 'WhatIfResultFormat', + "Alias", + "AliasPath", + "AliasPathMetadata", + "AliasPattern", + "ApiProfile", + "BasicDependency", + "DebugSetting", + "Dependency", + "Deployment", + "DeploymentExportResult", + "DeploymentExtended", + "DeploymentExtendedFilter", + "DeploymentListResult", + "DeploymentOperation", + "DeploymentOperationProperties", + "DeploymentOperationsListResult", + "DeploymentProperties", + "DeploymentPropertiesExtended", + "DeploymentValidateResult", + "DeploymentWhatIf", + "DeploymentWhatIfProperties", + "DeploymentWhatIfSettings", + "ErrorAdditionalInfo", + "ErrorResponse", + "ExportTemplateRequest", + "ExpressionEvaluationOptions", + "GenericResource", + "GenericResourceExpanded", + "GenericResourceFilter", + "HttpMessage", + "Identity", + "IdentityUserAssignedIdentitiesValue", + "OnErrorDeployment", + "OnErrorDeploymentExtended", + "Operation", + "OperationDisplay", + "OperationListResult", + "ParametersLink", + "Plan", + "Provider", + "ProviderListResult", + "ProviderResourceType", + "Resource", + "ResourceGroup", + "ResourceGroupExportResult", + "ResourceGroupFilter", + "ResourceGroupListResult", + "ResourceGroupPatchable", + "ResourceGroupProperties", + "ResourceListResult", + "ResourceProviderOperationDisplayProperties", + "ResourceReference", + "ResourcesMoveInfo", + "ScopedDeployment", + "ScopedDeploymentWhatIf", + "Sku", + "StatusMessage", + "SubResource", + "TagCount", + "TagDetails", + "TagValue", + "Tags", + "TagsListResult", + "TagsPatchResource", + "TagsResource", + "TargetResource", + "TemplateHashResult", + "TemplateLink", + "WhatIfChange", + "WhatIfOperationResult", + "WhatIfPropertyChange", + "ZoneMapping", + "AliasPathAttributes", + "AliasPathTokenType", + "AliasPatternType", + "AliasType", + "ChangeType", + "DeploymentMode", + "ExpressionEvaluationOptionsScopeType", + "OnErrorDeploymentType", + "PropertyChangeType", + "ProvisioningOperation", + "ProvisioningState", + "ResourceIdentityType", + "TagsPatchOperation", + "WhatIfResultFormat", ] +__all__.extend([p for p in _patch_all if p not in __all__]) +_patch_sdk() diff --git a/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/resources/v2020_06_01/models/_models_py3.py b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/resources/v2020_06_01/models/_models_py3.py index 2b4cad261fb41..4d47986cf0339 100644 --- a/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/resources/v2020_06_01/models/_models_py3.py +++ b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/resources/v2020_06_01/models/_models_py3.py @@ -1,4 +1,5 @@ # coding=utf-8 +# pylint: disable=too-many-lines # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. # Licensed under the MIT License. See License.txt in the project root for license information. @@ -6,14 +7,22 @@ # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -from typing import Any, Dict, List, Optional, Union +import sys +from typing import Any, Dict, List, Optional, TYPE_CHECKING, Union -import msrest.serialization +from ... import _serialization -from ._resource_management_client_enums import * +if TYPE_CHECKING: + # pylint: disable=unused-import,ungrouped-imports + from .. import models as _models +if sys.version_info >= (3, 9): + from collections.abc import MutableMapping +else: + from typing import MutableMapping # type: ignore # pylint: disable=ungrouped-imports +JSON = MutableMapping[str, Any] # pylint: disable=unsubscriptable-object -class Alias(msrest.serialization.Model): +class Alias(_serialization.Model): """The alias type. Variables are only populated by the server, and will be ignored when sending a request. @@ -22,8 +31,7 @@ class Alias(msrest.serialization.Model): :vartype name: str :ivar paths: The paths for an alias. :vartype paths: list[~azure.mgmt.resource.resources.v2020_06_01.models.AliasPath] - :ivar type: The type of the alias. Possible values include: "NotSpecified", "PlainText", - "Mask". + :ivar type: The type of the alias. Known values are: "NotSpecified", "PlainText", and "Mask". :vartype type: str or ~azure.mgmt.resource.resources.v2020_06_01.models.AliasType :ivar default_path: The default path for an alias. :vartype default_path: str @@ -35,26 +43,26 @@ class Alias(msrest.serialization.Model): """ _validation = { - 'default_metadata': {'readonly': True}, + "default_metadata": {"readonly": True}, } _attribute_map = { - 'name': {'key': 'name', 'type': 'str'}, - 'paths': {'key': 'paths', 'type': '[AliasPath]'}, - 'type': {'key': 'type', 'type': 'str'}, - 'default_path': {'key': 'defaultPath', 'type': 'str'}, - 'default_pattern': {'key': 'defaultPattern', 'type': 'AliasPattern'}, - 'default_metadata': {'key': 'defaultMetadata', 'type': 'AliasPathMetadata'}, + "name": {"key": "name", "type": "str"}, + "paths": {"key": "paths", "type": "[AliasPath]"}, + "type": {"key": "type", "type": "str"}, + "default_path": {"key": "defaultPath", "type": "str"}, + "default_pattern": {"key": "defaultPattern", "type": "AliasPattern"}, + "default_metadata": {"key": "defaultMetadata", "type": "AliasPathMetadata"}, } def __init__( self, *, name: Optional[str] = None, - paths: Optional[List["AliasPath"]] = None, - type: Optional[Union[str, "AliasType"]] = None, + paths: Optional[List["_models.AliasPath"]] = None, + type: Optional[Union[str, "_models.AliasType"]] = None, default_path: Optional[str] = None, - default_pattern: Optional["AliasPattern"] = None, + default_pattern: Optional["_models.AliasPattern"] = None, **kwargs ): """ @@ -62,7 +70,7 @@ def __init__( :paramtype name: str :keyword paths: The paths for an alias. :paramtype paths: list[~azure.mgmt.resource.resources.v2020_06_01.models.AliasPath] - :keyword type: The type of the alias. Possible values include: "NotSpecified", "PlainText", + :keyword type: The type of the alias. Known values are: "NotSpecified", "PlainText", and "Mask". :paramtype type: str or ~azure.mgmt.resource.resources.v2020_06_01.models.AliasType :keyword default_path: The default path for an alias. @@ -70,7 +78,7 @@ def __init__( :keyword default_pattern: The default pattern for an alias. :paramtype default_pattern: ~azure.mgmt.resource.resources.v2020_06_01.models.AliasPattern """ - super(Alias, self).__init__(**kwargs) + super().__init__(**kwargs) self.name = name self.paths = paths self.type = type @@ -79,7 +87,7 @@ def __init__( self.default_metadata = None -class AliasPath(msrest.serialization.Model): +class AliasPath(_serialization.Model): """The type of the paths for alias. Variables are only populated by the server, and will be ignored when sending a request. @@ -96,14 +104,14 @@ class AliasPath(msrest.serialization.Model): """ _validation = { - 'metadata': {'readonly': True}, + "metadata": {"readonly": True}, } _attribute_map = { - 'path': {'key': 'path', 'type': 'str'}, - 'api_versions': {'key': 'apiVersions', 'type': '[str]'}, - 'pattern': {'key': 'pattern', 'type': 'AliasPattern'}, - 'metadata': {'key': 'metadata', 'type': 'AliasPathMetadata'}, + "path": {"key": "path", "type": "str"}, + "api_versions": {"key": "apiVersions", "type": "[str]"}, + "pattern": {"key": "pattern", "type": "AliasPattern"}, + "metadata": {"key": "metadata", "type": "AliasPathMetadata"}, } def __init__( @@ -111,7 +119,7 @@ def __init__( *, path: Optional[str] = None, api_versions: Optional[List[str]] = None, - pattern: Optional["AliasPattern"] = None, + pattern: Optional["_models.AliasPattern"] = None, **kwargs ): """ @@ -122,63 +130,59 @@ def __init__( :keyword pattern: The pattern for an alias path. :paramtype pattern: ~azure.mgmt.resource.resources.v2020_06_01.models.AliasPattern """ - super(AliasPath, self).__init__(**kwargs) + super().__init__(**kwargs) self.path = path self.api_versions = api_versions self.pattern = pattern self.metadata = None -class AliasPathMetadata(msrest.serialization.Model): +class AliasPathMetadata(_serialization.Model): """AliasPathMetadata. Variables are only populated by the server, and will be ignored when sending a request. - :ivar type: The type of the token that the alias path is referring to. Possible values include: - "NotSpecified", "Any", "String", "Object", "Array", "Integer", "Number", "Boolean". + :ivar type: The type of the token that the alias path is referring to. Known values are: + "NotSpecified", "Any", "String", "Object", "Array", "Integer", "Number", and "Boolean". :vartype type: str or ~azure.mgmt.resource.resources.v2020_06_01.models.AliasPathTokenType - :ivar attributes: The attributes of the token that the alias path is referring to. Possible - values include: "None", "Modifiable". + :ivar attributes: The attributes of the token that the alias path is referring to. Known values + are: "None" and "Modifiable". :vartype attributes: str or ~azure.mgmt.resource.resources.v2020_06_01.models.AliasPathAttributes """ _validation = { - 'type': {'readonly': True}, - 'attributes': {'readonly': True}, + "type": {"readonly": True}, + "attributes": {"readonly": True}, } _attribute_map = { - 'type': {'key': 'type', 'type': 'str'}, - 'attributes': {'key': 'attributes', 'type': 'str'}, + "type": {"key": "type", "type": "str"}, + "attributes": {"key": "attributes", "type": "str"}, } - def __init__( - self, - **kwargs - ): - """ - """ - super(AliasPathMetadata, self).__init__(**kwargs) + def __init__(self, **kwargs): + """ """ + super().__init__(**kwargs) self.type = None self.attributes = None -class AliasPattern(msrest.serialization.Model): +class AliasPattern(_serialization.Model): """The type of the pattern for an alias path. :ivar phrase: The alias pattern phrase. :vartype phrase: str :ivar variable: The alias pattern variable. :vartype variable: str - :ivar type: The type of alias pattern. Possible values include: "NotSpecified", "Extract". + :ivar type: The type of alias pattern. Known values are: "NotSpecified" and "Extract". :vartype type: str or ~azure.mgmt.resource.resources.v2020_06_01.models.AliasPatternType """ _attribute_map = { - 'phrase': {'key': 'phrase', 'type': 'str'}, - 'variable': {'key': 'variable', 'type': 'str'}, - 'type': {'key': 'type', 'type': 'str'}, + "phrase": {"key": "phrase", "type": "str"}, + "variable": {"key": "variable", "type": "str"}, + "type": {"key": "type", "type": "str"}, } def __init__( @@ -186,7 +190,7 @@ def __init__( *, phrase: Optional[str] = None, variable: Optional[str] = None, - type: Optional[Union[str, "AliasPatternType"]] = None, + type: Optional[Union[str, "_models.AliasPatternType"]] = None, **kwargs ): """ @@ -194,16 +198,16 @@ def __init__( :paramtype phrase: str :keyword variable: The alias pattern variable. :paramtype variable: str - :keyword type: The type of alias pattern. Possible values include: "NotSpecified", "Extract". + :keyword type: The type of alias pattern. Known values are: "NotSpecified" and "Extract". :paramtype type: str or ~azure.mgmt.resource.resources.v2020_06_01.models.AliasPatternType """ - super(AliasPattern, self).__init__(**kwargs) + super().__init__(**kwargs) self.phrase = phrase self.variable = variable self.type = type -class ApiProfile(msrest.serialization.Model): +class ApiProfile(_serialization.Model): """ApiProfile. Variables are only populated by the server, and will be ignored when sending a request. @@ -215,27 +219,23 @@ class ApiProfile(msrest.serialization.Model): """ _validation = { - 'profile_version': {'readonly': True}, - 'api_version': {'readonly': True}, + "profile_version": {"readonly": True}, + "api_version": {"readonly": True}, } _attribute_map = { - 'profile_version': {'key': 'profileVersion', 'type': 'str'}, - 'api_version': {'key': 'apiVersion', 'type': 'str'}, + "profile_version": {"key": "profileVersion", "type": "str"}, + "api_version": {"key": "apiVersion", "type": "str"}, } - def __init__( - self, - **kwargs - ): - """ - """ - super(ApiProfile, self).__init__(**kwargs) + def __init__(self, **kwargs): + """ """ + super().__init__(**kwargs) self.profile_version = None self.api_version = None -class BasicDependency(msrest.serialization.Model): +class BasicDependency(_serialization.Model): """Deployment dependency information. :ivar id: The ID of the dependency. @@ -247,15 +247,15 @@ class BasicDependency(msrest.serialization.Model): """ _attribute_map = { - 'id': {'key': 'id', 'type': 'str'}, - 'resource_type': {'key': 'resourceType', 'type': 'str'}, - 'resource_name': {'key': 'resourceName', 'type': 'str'}, + "id": {"key": "id", "type": "str"}, + "resource_type": {"key": "resourceType", "type": "str"}, + "resource_name": {"key": "resourceName", "type": "str"}, } def __init__( self, *, - id: Optional[str] = None, + id: Optional[str] = None, # pylint: disable=redefined-builtin resource_type: Optional[str] = None, resource_name: Optional[str] = None, **kwargs @@ -268,13 +268,13 @@ def __init__( :keyword resource_name: The dependency resource name. :paramtype resource_name: str """ - super(BasicDependency, self).__init__(**kwargs) + super().__init__(**kwargs) self.id = id self.resource_type = resource_type self.resource_name = resource_name -class DebugSetting(msrest.serialization.Model): +class DebugSetting(_serialization.Model): """The debug setting. :ivar detail_level: Specifies the type of information to log for debugging. The permitted @@ -287,15 +287,10 @@ class DebugSetting(msrest.serialization.Model): """ _attribute_map = { - 'detail_level': {'key': 'detailLevel', 'type': 'str'}, + "detail_level": {"key": "detailLevel", "type": "str"}, } - def __init__( - self, - *, - detail_level: Optional[str] = None, - **kwargs - ): + def __init__(self, *, detail_level: Optional[str] = None, **kwargs): """ :keyword detail_level: Specifies the type of information to log for debugging. The permitted values are none, requestContent, responseContent, or both requestContent and responseContent @@ -305,11 +300,11 @@ def __init__( deployment operations. :paramtype detail_level: str """ - super(DebugSetting, self).__init__(**kwargs) + super().__init__(**kwargs) self.detail_level = detail_level -class Dependency(msrest.serialization.Model): +class Dependency(_serialization.Model): """Deployment dependency information. :ivar depends_on: The list of dependencies. @@ -323,17 +318,17 @@ class Dependency(msrest.serialization.Model): """ _attribute_map = { - 'depends_on': {'key': 'dependsOn', 'type': '[BasicDependency]'}, - 'id': {'key': 'id', 'type': 'str'}, - 'resource_type': {'key': 'resourceType', 'type': 'str'}, - 'resource_name': {'key': 'resourceName', 'type': 'str'}, + "depends_on": {"key": "dependsOn", "type": "[BasicDependency]"}, + "id": {"key": "id", "type": "str"}, + "resource_type": {"key": "resourceType", "type": "str"}, + "resource_name": {"key": "resourceName", "type": "str"}, } def __init__( self, *, - depends_on: Optional[List["BasicDependency"]] = None, - id: Optional[str] = None, + depends_on: Optional[List["_models.BasicDependency"]] = None, + id: Optional[str] = None, # pylint: disable=redefined-builtin resource_type: Optional[str] = None, resource_name: Optional[str] = None, **kwargs @@ -348,40 +343,40 @@ def __init__( :keyword resource_name: The dependency resource name. :paramtype resource_name: str """ - super(Dependency, self).__init__(**kwargs) + super().__init__(**kwargs) self.depends_on = depends_on self.id = id self.resource_type = resource_type self.resource_name = resource_name -class Deployment(msrest.serialization.Model): +class Deployment(_serialization.Model): """Deployment operation parameters. All required parameters must be populated in order to send to Azure. :ivar location: The location to store the deployment data. :vartype location: str - :ivar properties: Required. The deployment properties. + :ivar properties: The deployment properties. Required. :vartype properties: ~azure.mgmt.resource.resources.v2020_06_01.models.DeploymentProperties - :ivar tags: A set of tags. Deployment tags. + :ivar tags: Deployment tags. :vartype tags: dict[str, str] """ _validation = { - 'properties': {'required': True}, + "properties": {"required": True}, } _attribute_map = { - 'location': {'key': 'location', 'type': 'str'}, - 'properties': {'key': 'properties', 'type': 'DeploymentProperties'}, - 'tags': {'key': 'tags', 'type': '{str}'}, + "location": {"key": "location", "type": "str"}, + "properties": {"key": "properties", "type": "DeploymentProperties"}, + "tags": {"key": "tags", "type": "{str}"}, } def __init__( self, *, - properties: "DeploymentProperties", + properties: "_models.DeploymentProperties", location: Optional[str] = None, tags: Optional[Dict[str, str]] = None, **kwargs @@ -389,43 +384,38 @@ def __init__( """ :keyword location: The location to store the deployment data. :paramtype location: str - :keyword properties: Required. The deployment properties. + :keyword properties: The deployment properties. Required. :paramtype properties: ~azure.mgmt.resource.resources.v2020_06_01.models.DeploymentProperties - :keyword tags: A set of tags. Deployment tags. + :keyword tags: Deployment tags. :paramtype tags: dict[str, str] """ - super(Deployment, self).__init__(**kwargs) + super().__init__(**kwargs) self.location = location self.properties = properties self.tags = tags -class DeploymentExportResult(msrest.serialization.Model): +class DeploymentExportResult(_serialization.Model): """The deployment export result. :ivar template: The template content. - :vartype template: any + :vartype template: JSON """ _attribute_map = { - 'template': {'key': 'template', 'type': 'object'}, + "template": {"key": "template", "type": "object"}, } - def __init__( - self, - *, - template: Optional[Any] = None, - **kwargs - ): + def __init__(self, *, template: Optional[JSON] = None, **kwargs): """ :keyword template: The template content. - :paramtype template: any + :paramtype template: JSON """ - super(DeploymentExportResult, self).__init__(**kwargs) + super().__init__(**kwargs) self.template = template -class DeploymentExtended(msrest.serialization.Model): +class DeploymentExtended(_serialization.Model): """Deployment information. Variables are only populated by the server, and will be ignored when sending a request. @@ -441,30 +431,30 @@ class DeploymentExtended(msrest.serialization.Model): :ivar properties: Deployment properties. :vartype properties: ~azure.mgmt.resource.resources.v2020_06_01.models.DeploymentPropertiesExtended - :ivar tags: A set of tags. Deployment tags. + :ivar tags: Deployment tags. :vartype tags: dict[str, str] """ _validation = { - 'id': {'readonly': True}, - 'name': {'readonly': True}, - 'type': {'readonly': True}, + "id": {"readonly": True}, + "name": {"readonly": True}, + "type": {"readonly": True}, } _attribute_map = { - 'id': {'key': 'id', 'type': 'str'}, - 'name': {'key': 'name', 'type': 'str'}, - 'type': {'key': 'type', 'type': 'str'}, - 'location': {'key': 'location', 'type': 'str'}, - 'properties': {'key': 'properties', 'type': 'DeploymentPropertiesExtended'}, - 'tags': {'key': 'tags', 'type': '{str}'}, + "id": {"key": "id", "type": "str"}, + "name": {"key": "name", "type": "str"}, + "type": {"key": "type", "type": "str"}, + "location": {"key": "location", "type": "str"}, + "properties": {"key": "properties", "type": "DeploymentPropertiesExtended"}, + "tags": {"key": "tags", "type": "{str}"}, } def __init__( self, *, location: Optional[str] = None, - properties: Optional["DeploymentPropertiesExtended"] = None, + properties: Optional["_models.DeploymentPropertiesExtended"] = None, tags: Optional[Dict[str, str]] = None, **kwargs ): @@ -474,10 +464,10 @@ def __init__( :keyword properties: Deployment properties. :paramtype properties: ~azure.mgmt.resource.resources.v2020_06_01.models.DeploymentPropertiesExtended - :keyword tags: A set of tags. Deployment tags. + :keyword tags: Deployment tags. :paramtype tags: dict[str, str] """ - super(DeploymentExtended, self).__init__(**kwargs) + super().__init__(**kwargs) self.id = None self.name = None self.type = None @@ -486,7 +476,7 @@ def __init__( self.tags = tags -class DeploymentExtendedFilter(msrest.serialization.Model): +class DeploymentExtendedFilter(_serialization.Model): """Deployment filter. :ivar provisioning_state: The provisioning state. @@ -494,24 +484,19 @@ class DeploymentExtendedFilter(msrest.serialization.Model): """ _attribute_map = { - 'provisioning_state': {'key': 'provisioningState', 'type': 'str'}, + "provisioning_state": {"key": "provisioningState", "type": "str"}, } - def __init__( - self, - *, - provisioning_state: Optional[str] = None, - **kwargs - ): + def __init__(self, *, provisioning_state: Optional[str] = None, **kwargs): """ :keyword provisioning_state: The provisioning state. :paramtype provisioning_state: str """ - super(DeploymentExtendedFilter, self).__init__(**kwargs) + super().__init__(**kwargs) self.provisioning_state = provisioning_state -class DeploymentListResult(msrest.serialization.Model): +class DeploymentListResult(_serialization.Model): """List of deployments. Variables are only populated by the server, and will be ignored when sending a request. @@ -523,30 +508,25 @@ class DeploymentListResult(msrest.serialization.Model): """ _validation = { - 'next_link': {'readonly': True}, + "next_link": {"readonly": True}, } _attribute_map = { - 'value': {'key': 'value', 'type': '[DeploymentExtended]'}, - 'next_link': {'key': 'nextLink', 'type': 'str'}, + "value": {"key": "value", "type": "[DeploymentExtended]"}, + "next_link": {"key": "nextLink", "type": "str"}, } - def __init__( - self, - *, - value: Optional[List["DeploymentExtended"]] = None, - **kwargs - ): + def __init__(self, *, value: Optional[List["_models.DeploymentExtended"]] = None, **kwargs): """ :keyword value: An array of deployments. :paramtype value: list[~azure.mgmt.resource.resources.v2020_06_01.models.DeploymentExtended] """ - super(DeploymentListResult, self).__init__(**kwargs) + super().__init__(**kwargs) self.value = value self.next_link = None -class DeploymentOperation(msrest.serialization.Model): +class DeploymentOperation(_serialization.Model): """Deployment operation information. Variables are only populated by the server, and will be ignored when sending a request. @@ -561,41 +541,36 @@ class DeploymentOperation(msrest.serialization.Model): """ _validation = { - 'id': {'readonly': True}, - 'operation_id': {'readonly': True}, + "id": {"readonly": True}, + "operation_id": {"readonly": True}, } _attribute_map = { - 'id': {'key': 'id', 'type': 'str'}, - 'operation_id': {'key': 'operationId', 'type': 'str'}, - 'properties': {'key': 'properties', 'type': 'DeploymentOperationProperties'}, + "id": {"key": "id", "type": "str"}, + "operation_id": {"key": "operationId", "type": "str"}, + "properties": {"key": "properties", "type": "DeploymentOperationProperties"}, } - def __init__( - self, - *, - properties: Optional["DeploymentOperationProperties"] = None, - **kwargs - ): + def __init__(self, *, properties: Optional["_models.DeploymentOperationProperties"] = None, **kwargs): """ :keyword properties: Deployment properties. :paramtype properties: ~azure.mgmt.resource.resources.v2020_06_01.models.DeploymentOperationProperties """ - super(DeploymentOperation, self).__init__(**kwargs) + super().__init__(**kwargs) self.id = None self.operation_id = None self.properties = properties -class DeploymentOperationProperties(msrest.serialization.Model): +class DeploymentOperationProperties(_serialization.Model): """Deployment operation properties. Variables are only populated by the server, and will be ignored when sending a request. - :ivar provisioning_operation: The name of the current provisioning operation. Possible values - include: "NotSpecified", "Create", "Delete", "Waiting", "AzureAsyncOperationWaiting", - "ResourceCacheWaiting", "Action", "Read", "EvaluateDeploymentOutput", "DeploymentCleanup". + :ivar provisioning_operation: The name of the current provisioning operation. Known values are: + "NotSpecified", "Create", "Delete", "Waiting", "AzureAsyncOperationWaiting", + "ResourceCacheWaiting", "Action", "Read", "EvaluateDeploymentOutput", and "DeploymentCleanup". :vartype provisioning_operation: str or ~azure.mgmt.resource.resources.v2020_06_01.models.ProvisioningOperation :ivar provisioning_state: The state of the provisioning. @@ -621,38 +596,34 @@ class DeploymentOperationProperties(msrest.serialization.Model): """ _validation = { - 'provisioning_operation': {'readonly': True}, - 'provisioning_state': {'readonly': True}, - 'timestamp': {'readonly': True}, - 'duration': {'readonly': True}, - 'service_request_id': {'readonly': True}, - 'status_code': {'readonly': True}, - 'status_message': {'readonly': True}, - 'target_resource': {'readonly': True}, - 'request': {'readonly': True}, - 'response': {'readonly': True}, - } - - _attribute_map = { - 'provisioning_operation': {'key': 'provisioningOperation', 'type': 'str'}, - 'provisioning_state': {'key': 'provisioningState', 'type': 'str'}, - 'timestamp': {'key': 'timestamp', 'type': 'iso-8601'}, - 'duration': {'key': 'duration', 'type': 'str'}, - 'service_request_id': {'key': 'serviceRequestId', 'type': 'str'}, - 'status_code': {'key': 'statusCode', 'type': 'str'}, - 'status_message': {'key': 'statusMessage', 'type': 'StatusMessage'}, - 'target_resource': {'key': 'targetResource', 'type': 'TargetResource'}, - 'request': {'key': 'request', 'type': 'HttpMessage'}, - 'response': {'key': 'response', 'type': 'HttpMessage'}, - } - - def __init__( - self, - **kwargs - ): - """ - """ - super(DeploymentOperationProperties, self).__init__(**kwargs) + "provisioning_operation": {"readonly": True}, + "provisioning_state": {"readonly": True}, + "timestamp": {"readonly": True}, + "duration": {"readonly": True}, + "service_request_id": {"readonly": True}, + "status_code": {"readonly": True}, + "status_message": {"readonly": True}, + "target_resource": {"readonly": True}, + "request": {"readonly": True}, + "response": {"readonly": True}, + } + + _attribute_map = { + "provisioning_operation": {"key": "provisioningOperation", "type": "str"}, + "provisioning_state": {"key": "provisioningState", "type": "str"}, + "timestamp": {"key": "timestamp", "type": "iso-8601"}, + "duration": {"key": "duration", "type": "str"}, + "service_request_id": {"key": "serviceRequestId", "type": "str"}, + "status_code": {"key": "statusCode", "type": "str"}, + "status_message": {"key": "statusMessage", "type": "StatusMessage"}, + "target_resource": {"key": "targetResource", "type": "TargetResource"}, + "request": {"key": "request", "type": "HttpMessage"}, + "response": {"key": "response", "type": "HttpMessage"}, + } + + def __init__(self, **kwargs): + """ """ + super().__init__(**kwargs) self.provisioning_operation = None self.provisioning_state = None self.timestamp = None @@ -665,7 +636,7 @@ def __init__( self.response = None -class DeploymentOperationsListResult(msrest.serialization.Model): +class DeploymentOperationsListResult(_serialization.Model): """List of deployment operations. Variables are only populated by the server, and will be ignored when sending a request. @@ -677,30 +648,25 @@ class DeploymentOperationsListResult(msrest.serialization.Model): """ _validation = { - 'next_link': {'readonly': True}, + "next_link": {"readonly": True}, } _attribute_map = { - 'value': {'key': 'value', 'type': '[DeploymentOperation]'}, - 'next_link': {'key': 'nextLink', 'type': 'str'}, + "value": {"key": "value", "type": "[DeploymentOperation]"}, + "next_link": {"key": "nextLink", "type": "str"}, } - def __init__( - self, - *, - value: Optional[List["DeploymentOperation"]] = None, - **kwargs - ): + def __init__(self, *, value: Optional[List["_models.DeploymentOperation"]] = None, **kwargs): """ :keyword value: An array of deployment operations. :paramtype value: list[~azure.mgmt.resource.resources.v2020_06_01.models.DeploymentOperation] """ - super(DeploymentOperationsListResult, self).__init__(**kwargs) + super().__init__(**kwargs) self.value = value self.next_link = None -class DeploymentProperties(msrest.serialization.Model): +class DeploymentProperties(_serialization.Model): """Deployment properties. All required parameters must be populated in order to send to Azure. @@ -709,7 +675,7 @@ class DeploymentProperties(msrest.serialization.Model): syntax directly in the request rather than link to an existing template. It can be a JObject or well-formed JSON string. Use either the templateLink property or the template property, but not both. - :vartype template: any + :vartype template: JSON :ivar template_link: The URI of the template. Use either the templateLink property or the template property, but not both. :vartype template_link: ~azure.mgmt.resource.resources.v2020_06_01.models.TemplateLink @@ -717,17 +683,17 @@ class DeploymentProperties(msrest.serialization.Model): You use this element when you want to provide the parameter values directly in the request rather than link to an existing parameter file. Use either the parametersLink property or the parameters property, but not both. It can be a JObject or a well formed JSON string. - :vartype parameters: any + :vartype parameters: JSON :ivar parameters_link: The URI of parameters file. You use this element to link to an existing parameters file. Use either the parametersLink property or the parameters property, but not both. :vartype parameters_link: ~azure.mgmt.resource.resources.v2020_06_01.models.ParametersLink - :ivar mode: Required. The mode that is used to deploy resources. This value can be either - Incremental or Complete. In Incremental mode, resources are deployed without deleting existing - resources that are not included in the template. In Complete mode, resources are deployed and - existing resources in the resource group that are not included in the template are deleted. Be - careful when using Complete mode as you may unintentionally delete resources. Possible values - include: "Incremental", "Complete". + :ivar mode: The mode that is used to deploy resources. This value can be either Incremental or + Complete. In Incremental mode, resources are deployed without deleting existing resources that + are not included in the template. In Complete mode, resources are deployed and existing + resources in the resource group that are not included in the template are deleted. Be careful + when using Complete mode as you may unintentionally delete resources. Required. Known values + are: "Incremental" and "Complete". :vartype mode: str or ~azure.mgmt.resource.resources.v2020_06_01.models.DeploymentMode :ivar debug_setting: The debug setting of the deployment. :vartype debug_setting: ~azure.mgmt.resource.resources.v2020_06_01.models.DebugSetting @@ -742,31 +708,31 @@ class DeploymentProperties(msrest.serialization.Model): """ _validation = { - 'mode': {'required': True}, + "mode": {"required": True}, } _attribute_map = { - 'template': {'key': 'template', 'type': 'object'}, - 'template_link': {'key': 'templateLink', 'type': 'TemplateLink'}, - 'parameters': {'key': 'parameters', 'type': 'object'}, - 'parameters_link': {'key': 'parametersLink', 'type': 'ParametersLink'}, - 'mode': {'key': 'mode', 'type': 'str'}, - 'debug_setting': {'key': 'debugSetting', 'type': 'DebugSetting'}, - 'on_error_deployment': {'key': 'onErrorDeployment', 'type': 'OnErrorDeployment'}, - 'expression_evaluation_options': {'key': 'expressionEvaluationOptions', 'type': 'ExpressionEvaluationOptions'}, + "template": {"key": "template", "type": "object"}, + "template_link": {"key": "templateLink", "type": "TemplateLink"}, + "parameters": {"key": "parameters", "type": "object"}, + "parameters_link": {"key": "parametersLink", "type": "ParametersLink"}, + "mode": {"key": "mode", "type": "str"}, + "debug_setting": {"key": "debugSetting", "type": "DebugSetting"}, + "on_error_deployment": {"key": "onErrorDeployment", "type": "OnErrorDeployment"}, + "expression_evaluation_options": {"key": "expressionEvaluationOptions", "type": "ExpressionEvaluationOptions"}, } def __init__( self, *, - mode: Union[str, "DeploymentMode"], - template: Optional[Any] = None, - template_link: Optional["TemplateLink"] = None, - parameters: Optional[Any] = None, - parameters_link: Optional["ParametersLink"] = None, - debug_setting: Optional["DebugSetting"] = None, - on_error_deployment: Optional["OnErrorDeployment"] = None, - expression_evaluation_options: Optional["ExpressionEvaluationOptions"] = None, + mode: Union[str, "_models.DeploymentMode"], + template: Optional[JSON] = None, + template_link: Optional["_models.TemplateLink"] = None, + parameters: Optional[JSON] = None, + parameters_link: Optional["_models.ParametersLink"] = None, + debug_setting: Optional["_models.DebugSetting"] = None, + on_error_deployment: Optional["_models.OnErrorDeployment"] = None, + expression_evaluation_options: Optional["_models.ExpressionEvaluationOptions"] = None, **kwargs ): """ @@ -774,7 +740,7 @@ def __init__( template syntax directly in the request rather than link to an existing template. It can be a JObject or well-formed JSON string. Use either the templateLink property or the template property, but not both. - :paramtype template: any + :paramtype template: JSON :keyword template_link: The URI of the template. Use either the templateLink property or the template property, but not both. :paramtype template_link: ~azure.mgmt.resource.resources.v2020_06_01.models.TemplateLink @@ -782,17 +748,17 @@ def __init__( template. You use this element when you want to provide the parameter values directly in the request rather than link to an existing parameter file. Use either the parametersLink property or the parameters property, but not both. It can be a JObject or a well formed JSON string. - :paramtype parameters: any + :paramtype parameters: JSON :keyword parameters_link: The URI of parameters file. You use this element to link to an existing parameters file. Use either the parametersLink property or the parameters property, but not both. :paramtype parameters_link: ~azure.mgmt.resource.resources.v2020_06_01.models.ParametersLink - :keyword mode: Required. The mode that is used to deploy resources. This value can be either - Incremental or Complete. In Incremental mode, resources are deployed without deleting existing - resources that are not included in the template. In Complete mode, resources are deployed and - existing resources in the resource group that are not included in the template are deleted. Be - careful when using Complete mode as you may unintentionally delete resources. Possible values - include: "Incremental", "Complete". + :keyword mode: The mode that is used to deploy resources. This value can be either Incremental + or Complete. In Incremental mode, resources are deployed without deleting existing resources + that are not included in the template. In Complete mode, resources are deployed and existing + resources in the resource group that are not included in the template are deleted. Be careful + when using Complete mode as you may unintentionally delete resources. Required. Known values + are: "Incremental" and "Complete". :paramtype mode: str or ~azure.mgmt.resource.resources.v2020_06_01.models.DeploymentMode :keyword debug_setting: The debug setting of the deployment. :paramtype debug_setting: ~azure.mgmt.resource.resources.v2020_06_01.models.DebugSetting @@ -805,7 +771,7 @@ def __init__( :paramtype expression_evaluation_options: ~azure.mgmt.resource.resources.v2020_06_01.models.ExpressionEvaluationOptions """ - super(DeploymentProperties, self).__init__(**kwargs) + super().__init__(**kwargs) self.template = template self.template_link = template_link self.parameters = parameters @@ -816,14 +782,14 @@ def __init__( self.expression_evaluation_options = expression_evaluation_options -class DeploymentPropertiesExtended(msrest.serialization.Model): +class DeploymentPropertiesExtended(_serialization.Model): # pylint: disable=too-many-instance-attributes """Deployment properties with additional details. Variables are only populated by the server, and will be ignored when sending a request. - :ivar provisioning_state: Denotes the state of provisioning. Possible values include: - "NotSpecified", "Accepted", "Running", "Ready", "Creating", "Created", "Deleting", "Deleted", - "Canceled", "Failed", "Succeeded", "Updating". + :ivar provisioning_state: Denotes the state of provisioning. Known values are: "NotSpecified", + "Accepted", "Running", "Ready", "Creating", "Created", "Deleting", "Deleted", "Canceled", + "Failed", "Succeeded", and "Updating". :vartype provisioning_state: str or ~azure.mgmt.resource.resources.v2020_06_01.models.ProvisioningState :ivar correlation_id: The correlation ID of the deployment. @@ -833,7 +799,7 @@ class DeploymentPropertiesExtended(msrest.serialization.Model): :ivar duration: The duration of the template deployment. :vartype duration: str :ivar outputs: Key/value pairs that represent deployment output. - :vartype outputs: any + :vartype outputs: JSON :ivar providers: The list of resource providers needed for the deployment. :vartype providers: list[~azure.mgmt.resource.resources.v2020_06_01.models.Provider] :ivar dependencies: The list of deployment dependencies. @@ -841,11 +807,11 @@ class DeploymentPropertiesExtended(msrest.serialization.Model): :ivar template_link: The URI referencing the template. :vartype template_link: ~azure.mgmt.resource.resources.v2020_06_01.models.TemplateLink :ivar parameters: Deployment parameters. - :vartype parameters: any + :vartype parameters: JSON :ivar parameters_link: The URI referencing the parameters. :vartype parameters_link: ~azure.mgmt.resource.resources.v2020_06_01.models.ParametersLink - :ivar mode: The deployment mode. Possible values are Incremental and Complete. Possible values - include: "Incremental", "Complete". + :ivar mode: The deployment mode. Possible values are Incremental and Complete. Known values + are: "Incremental" and "Complete". :vartype mode: str or ~azure.mgmt.resource.resources.v2020_06_01.models.DeploymentMode :ivar debug_setting: The debug setting of the deployment. :vartype debug_setting: ~azure.mgmt.resource.resources.v2020_06_01.models.DebugSetting @@ -865,52 +831,48 @@ class DeploymentPropertiesExtended(msrest.serialization.Model): """ _validation = { - 'provisioning_state': {'readonly': True}, - 'correlation_id': {'readonly': True}, - 'timestamp': {'readonly': True}, - 'duration': {'readonly': True}, - 'outputs': {'readonly': True}, - 'providers': {'readonly': True}, - 'dependencies': {'readonly': True}, - 'template_link': {'readonly': True}, - 'parameters': {'readonly': True}, - 'parameters_link': {'readonly': True}, - 'mode': {'readonly': True}, - 'debug_setting': {'readonly': True}, - 'on_error_deployment': {'readonly': True}, - 'template_hash': {'readonly': True}, - 'output_resources': {'readonly': True}, - 'validated_resources': {'readonly': True}, - 'error': {'readonly': True}, - } - - _attribute_map = { - 'provisioning_state': {'key': 'provisioningState', 'type': 'str'}, - 'correlation_id': {'key': 'correlationId', 'type': 'str'}, - 'timestamp': {'key': 'timestamp', 'type': 'iso-8601'}, - 'duration': {'key': 'duration', 'type': 'str'}, - 'outputs': {'key': 'outputs', 'type': 'object'}, - 'providers': {'key': 'providers', 'type': '[Provider]'}, - 'dependencies': {'key': 'dependencies', 'type': '[Dependency]'}, - 'template_link': {'key': 'templateLink', 'type': 'TemplateLink'}, - 'parameters': {'key': 'parameters', 'type': 'object'}, - 'parameters_link': {'key': 'parametersLink', 'type': 'ParametersLink'}, - 'mode': {'key': 'mode', 'type': 'str'}, - 'debug_setting': {'key': 'debugSetting', 'type': 'DebugSetting'}, - 'on_error_deployment': {'key': 'onErrorDeployment', 'type': 'OnErrorDeploymentExtended'}, - 'template_hash': {'key': 'templateHash', 'type': 'str'}, - 'output_resources': {'key': 'outputResources', 'type': '[ResourceReference]'}, - 'validated_resources': {'key': 'validatedResources', 'type': '[ResourceReference]'}, - 'error': {'key': 'error', 'type': 'ErrorResponse'}, - } - - def __init__( - self, - **kwargs - ): - """ - """ - super(DeploymentPropertiesExtended, self).__init__(**kwargs) + "provisioning_state": {"readonly": True}, + "correlation_id": {"readonly": True}, + "timestamp": {"readonly": True}, + "duration": {"readonly": True}, + "outputs": {"readonly": True}, + "providers": {"readonly": True}, + "dependencies": {"readonly": True}, + "template_link": {"readonly": True}, + "parameters": {"readonly": True}, + "parameters_link": {"readonly": True}, + "mode": {"readonly": True}, + "debug_setting": {"readonly": True}, + "on_error_deployment": {"readonly": True}, + "template_hash": {"readonly": True}, + "output_resources": {"readonly": True}, + "validated_resources": {"readonly": True}, + "error": {"readonly": True}, + } + + _attribute_map = { + "provisioning_state": {"key": "provisioningState", "type": "str"}, + "correlation_id": {"key": "correlationId", "type": "str"}, + "timestamp": {"key": "timestamp", "type": "iso-8601"}, + "duration": {"key": "duration", "type": "str"}, + "outputs": {"key": "outputs", "type": "object"}, + "providers": {"key": "providers", "type": "[Provider]"}, + "dependencies": {"key": "dependencies", "type": "[Dependency]"}, + "template_link": {"key": "templateLink", "type": "TemplateLink"}, + "parameters": {"key": "parameters", "type": "object"}, + "parameters_link": {"key": "parametersLink", "type": "ParametersLink"}, + "mode": {"key": "mode", "type": "str"}, + "debug_setting": {"key": "debugSetting", "type": "DebugSetting"}, + "on_error_deployment": {"key": "onErrorDeployment", "type": "OnErrorDeploymentExtended"}, + "template_hash": {"key": "templateHash", "type": "str"}, + "output_resources": {"key": "outputResources", "type": "[ResourceReference]"}, + "validated_resources": {"key": "validatedResources", "type": "[ResourceReference]"}, + "error": {"key": "error", "type": "ErrorResponse"}, + } + + def __init__(self, **kwargs): + """ """ + super().__init__(**kwargs) self.provisioning_state = None self.correlation_id = None self.timestamp = None @@ -930,7 +892,7 @@ def __init__( self.error = None -class DeploymentValidateResult(msrest.serialization.Model): +class DeploymentValidateResult(_serialization.Model): """Information from validate template deployment response. Variables are only populated by the server, and will be ignored when sending a request. @@ -943,66 +905,55 @@ class DeploymentValidateResult(msrest.serialization.Model): """ _validation = { - 'error': {'readonly': True}, + "error": {"readonly": True}, } _attribute_map = { - 'error': {'key': 'error', 'type': 'ErrorResponse'}, - 'properties': {'key': 'properties', 'type': 'DeploymentPropertiesExtended'}, + "error": {"key": "error", "type": "ErrorResponse"}, + "properties": {"key": "properties", "type": "DeploymentPropertiesExtended"}, } - def __init__( - self, - *, - properties: Optional["DeploymentPropertiesExtended"] = None, - **kwargs - ): + def __init__(self, *, properties: Optional["_models.DeploymentPropertiesExtended"] = None, **kwargs): """ :keyword properties: The template deployment properties. :paramtype properties: ~azure.mgmt.resource.resources.v2020_06_01.models.DeploymentPropertiesExtended """ - super(DeploymentValidateResult, self).__init__(**kwargs) + super().__init__(**kwargs) self.error = None self.properties = properties -class DeploymentWhatIf(msrest.serialization.Model): +class DeploymentWhatIf(_serialization.Model): """Deployment What-if operation parameters. All required parameters must be populated in order to send to Azure. :ivar location: The location to store the deployment data. :vartype location: str - :ivar properties: Required. The deployment properties. + :ivar properties: The deployment properties. Required. :vartype properties: ~azure.mgmt.resource.resources.v2020_06_01.models.DeploymentWhatIfProperties """ _validation = { - 'properties': {'required': True}, + "properties": {"required": True}, } _attribute_map = { - 'location': {'key': 'location', 'type': 'str'}, - 'properties': {'key': 'properties', 'type': 'DeploymentWhatIfProperties'}, + "location": {"key": "location", "type": "str"}, + "properties": {"key": "properties", "type": "DeploymentWhatIfProperties"}, } - def __init__( - self, - *, - properties: "DeploymentWhatIfProperties", - location: Optional[str] = None, - **kwargs - ): + def __init__(self, *, properties: "_models.DeploymentWhatIfProperties", location: Optional[str] = None, **kwargs): """ :keyword location: The location to store the deployment data. :paramtype location: str - :keyword properties: Required. The deployment properties. + :keyword properties: The deployment properties. Required. :paramtype properties: ~azure.mgmt.resource.resources.v2020_06_01.models.DeploymentWhatIfProperties """ - super(DeploymentWhatIf, self).__init__(**kwargs) + super().__init__(**kwargs) self.location = location self.properties = properties @@ -1016,7 +967,7 @@ class DeploymentWhatIfProperties(DeploymentProperties): syntax directly in the request rather than link to an existing template. It can be a JObject or well-formed JSON string. Use either the templateLink property or the template property, but not both. - :vartype template: any + :vartype template: JSON :ivar template_link: The URI of the template. Use either the templateLink property or the template property, but not both. :vartype template_link: ~azure.mgmt.resource.resources.v2020_06_01.models.TemplateLink @@ -1024,17 +975,17 @@ class DeploymentWhatIfProperties(DeploymentProperties): You use this element when you want to provide the parameter values directly in the request rather than link to an existing parameter file. Use either the parametersLink property or the parameters property, but not both. It can be a JObject or a well formed JSON string. - :vartype parameters: any + :vartype parameters: JSON :ivar parameters_link: The URI of parameters file. You use this element to link to an existing parameters file. Use either the parametersLink property or the parameters property, but not both. :vartype parameters_link: ~azure.mgmt.resource.resources.v2020_06_01.models.ParametersLink - :ivar mode: Required. The mode that is used to deploy resources. This value can be either - Incremental or Complete. In Incremental mode, resources are deployed without deleting existing - resources that are not included in the template. In Complete mode, resources are deployed and - existing resources in the resource group that are not included in the template are deleted. Be - careful when using Complete mode as you may unintentionally delete resources. Possible values - include: "Incremental", "Complete". + :ivar mode: The mode that is used to deploy resources. This value can be either Incremental or + Complete. In Incremental mode, resources are deployed without deleting existing resources that + are not included in the template. In Complete mode, resources are deployed and existing + resources in the resource group that are not included in the template are deleted. Be careful + when using Complete mode as you may unintentionally delete resources. Required. Known values + are: "Incremental" and "Complete". :vartype mode: str or ~azure.mgmt.resource.resources.v2020_06_01.models.DeploymentMode :ivar debug_setting: The debug setting of the deployment. :vartype debug_setting: ~azure.mgmt.resource.resources.v2020_06_01.models.DebugSetting @@ -1052,33 +1003,33 @@ class DeploymentWhatIfProperties(DeploymentProperties): """ _validation = { - 'mode': {'required': True}, + "mode": {"required": True}, } _attribute_map = { - 'template': {'key': 'template', 'type': 'object'}, - 'template_link': {'key': 'templateLink', 'type': 'TemplateLink'}, - 'parameters': {'key': 'parameters', 'type': 'object'}, - 'parameters_link': {'key': 'parametersLink', 'type': 'ParametersLink'}, - 'mode': {'key': 'mode', 'type': 'str'}, - 'debug_setting': {'key': 'debugSetting', 'type': 'DebugSetting'}, - 'on_error_deployment': {'key': 'onErrorDeployment', 'type': 'OnErrorDeployment'}, - 'expression_evaluation_options': {'key': 'expressionEvaluationOptions', 'type': 'ExpressionEvaluationOptions'}, - 'what_if_settings': {'key': 'whatIfSettings', 'type': 'DeploymentWhatIfSettings'}, + "template": {"key": "template", "type": "object"}, + "template_link": {"key": "templateLink", "type": "TemplateLink"}, + "parameters": {"key": "parameters", "type": "object"}, + "parameters_link": {"key": "parametersLink", "type": "ParametersLink"}, + "mode": {"key": "mode", "type": "str"}, + "debug_setting": {"key": "debugSetting", "type": "DebugSetting"}, + "on_error_deployment": {"key": "onErrorDeployment", "type": "OnErrorDeployment"}, + "expression_evaluation_options": {"key": "expressionEvaluationOptions", "type": "ExpressionEvaluationOptions"}, + "what_if_settings": {"key": "whatIfSettings", "type": "DeploymentWhatIfSettings"}, } def __init__( self, *, - mode: Union[str, "DeploymentMode"], - template: Optional[Any] = None, - template_link: Optional["TemplateLink"] = None, - parameters: Optional[Any] = None, - parameters_link: Optional["ParametersLink"] = None, - debug_setting: Optional["DebugSetting"] = None, - on_error_deployment: Optional["OnErrorDeployment"] = None, - expression_evaluation_options: Optional["ExpressionEvaluationOptions"] = None, - what_if_settings: Optional["DeploymentWhatIfSettings"] = None, + mode: Union[str, "_models.DeploymentMode"], + template: Optional[JSON] = None, + template_link: Optional["_models.TemplateLink"] = None, + parameters: Optional[JSON] = None, + parameters_link: Optional["_models.ParametersLink"] = None, + debug_setting: Optional["_models.DebugSetting"] = None, + on_error_deployment: Optional["_models.OnErrorDeployment"] = None, + expression_evaluation_options: Optional["_models.ExpressionEvaluationOptions"] = None, + what_if_settings: Optional["_models.DeploymentWhatIfSettings"] = None, **kwargs ): """ @@ -1086,7 +1037,7 @@ def __init__( template syntax directly in the request rather than link to an existing template. It can be a JObject or well-formed JSON string. Use either the templateLink property or the template property, but not both. - :paramtype template: any + :paramtype template: JSON :keyword template_link: The URI of the template. Use either the templateLink property or the template property, but not both. :paramtype template_link: ~azure.mgmt.resource.resources.v2020_06_01.models.TemplateLink @@ -1094,17 +1045,17 @@ def __init__( template. You use this element when you want to provide the parameter values directly in the request rather than link to an existing parameter file. Use either the parametersLink property or the parameters property, but not both. It can be a JObject or a well formed JSON string. - :paramtype parameters: any + :paramtype parameters: JSON :keyword parameters_link: The URI of parameters file. You use this element to link to an existing parameters file. Use either the parametersLink property or the parameters property, but not both. :paramtype parameters_link: ~azure.mgmt.resource.resources.v2020_06_01.models.ParametersLink - :keyword mode: Required. The mode that is used to deploy resources. This value can be either - Incremental or Complete. In Incremental mode, resources are deployed without deleting existing - resources that are not included in the template. In Complete mode, resources are deployed and - existing resources in the resource group that are not included in the template are deleted. Be - careful when using Complete mode as you may unintentionally delete resources. Possible values - include: "Incremental", "Complete". + :keyword mode: The mode that is used to deploy resources. This value can be either Incremental + or Complete. In Incremental mode, resources are deployed without deleting existing resources + that are not included in the template. In Complete mode, resources are deployed and existing + resources in the resource group that are not included in the template are deleted. Be careful + when using Complete mode as you may unintentionally delete resources. Required. Known values + are: "Incremental" and "Complete". :paramtype mode: str or ~azure.mgmt.resource.resources.v2020_06_01.models.DeploymentMode :keyword debug_setting: The debug setting of the deployment. :paramtype debug_setting: ~azure.mgmt.resource.resources.v2020_06_01.models.DebugSetting @@ -1120,40 +1071,45 @@ def __init__( :paramtype what_if_settings: ~azure.mgmt.resource.resources.v2020_06_01.models.DeploymentWhatIfSettings """ - super(DeploymentWhatIfProperties, self).__init__(template=template, template_link=template_link, parameters=parameters, parameters_link=parameters_link, mode=mode, debug_setting=debug_setting, on_error_deployment=on_error_deployment, expression_evaluation_options=expression_evaluation_options, **kwargs) + super().__init__( + template=template, + template_link=template_link, + parameters=parameters, + parameters_link=parameters_link, + mode=mode, + debug_setting=debug_setting, + on_error_deployment=on_error_deployment, + expression_evaluation_options=expression_evaluation_options, + **kwargs + ) self.what_if_settings = what_if_settings -class DeploymentWhatIfSettings(msrest.serialization.Model): +class DeploymentWhatIfSettings(_serialization.Model): """Deployment What-If operation settings. - :ivar result_format: The format of the What-If results. Possible values include: - "ResourceIdOnly", "FullResourcePayloads". + :ivar result_format: The format of the What-If results. Known values are: "ResourceIdOnly" and + "FullResourcePayloads". :vartype result_format: str or ~azure.mgmt.resource.resources.v2020_06_01.models.WhatIfResultFormat """ _attribute_map = { - 'result_format': {'key': 'resultFormat', 'type': 'str'}, + "result_format": {"key": "resultFormat", "type": "str"}, } - def __init__( - self, - *, - result_format: Optional[Union[str, "WhatIfResultFormat"]] = None, - **kwargs - ): + def __init__(self, *, result_format: Optional[Union[str, "_models.WhatIfResultFormat"]] = None, **kwargs): """ - :keyword result_format: The format of the What-If results. Possible values include: - "ResourceIdOnly", "FullResourcePayloads". + :keyword result_format: The format of the What-If results. Known values are: "ResourceIdOnly" + and "FullResourcePayloads". :paramtype result_format: str or ~azure.mgmt.resource.resources.v2020_06_01.models.WhatIfResultFormat """ - super(DeploymentWhatIfSettings, self).__init__(**kwargs) + super().__init__(**kwargs) self.result_format = result_format -class ErrorAdditionalInfo(msrest.serialization.Model): +class ErrorAdditionalInfo(_serialization.Model): """The resource management error additional info. Variables are only populated by the server, and will be ignored when sending a request. @@ -1161,31 +1117,27 @@ class ErrorAdditionalInfo(msrest.serialization.Model): :ivar type: The additional info type. :vartype type: str :ivar info: The additional info. - :vartype info: any + :vartype info: JSON """ _validation = { - 'type': {'readonly': True}, - 'info': {'readonly': True}, + "type": {"readonly": True}, + "info": {"readonly": True}, } _attribute_map = { - 'type': {'key': 'type', 'type': 'str'}, - 'info': {'key': 'info', 'type': 'object'}, + "type": {"key": "type", "type": "str"}, + "info": {"key": "info", "type": "object"}, } - def __init__( - self, - **kwargs - ): - """ - """ - super(ErrorAdditionalInfo, self).__init__(**kwargs) + def __init__(self, **kwargs): + """ """ + super().__init__(**kwargs) self.type = None self.info = None -class ErrorResponse(msrest.serialization.Model): +class ErrorResponse(_serialization.Model): """Common error response for all Azure Resource Manager APIs to return error details for failed operations. (This also follows the OData error response format.). Variables are only populated by the server, and will be ignored when sending a request. @@ -1204,28 +1156,24 @@ class ErrorResponse(msrest.serialization.Model): """ _validation = { - 'code': {'readonly': True}, - 'message': {'readonly': True}, - 'target': {'readonly': True}, - 'details': {'readonly': True}, - 'additional_info': {'readonly': True}, + "code": {"readonly": True}, + "message": {"readonly": True}, + "target": {"readonly": True}, + "details": {"readonly": True}, + "additional_info": {"readonly": True}, } _attribute_map = { - 'code': {'key': 'code', 'type': 'str'}, - 'message': {'key': 'message', 'type': 'str'}, - 'target': {'key': 'target', 'type': 'str'}, - 'details': {'key': 'details', 'type': '[ErrorResponse]'}, - 'additional_info': {'key': 'additionalInfo', 'type': '[ErrorAdditionalInfo]'}, + "code": {"key": "code", "type": "str"}, + "message": {"key": "message", "type": "str"}, + "target": {"key": "target", "type": "str"}, + "details": {"key": "details", "type": "[ErrorResponse]"}, + "additional_info": {"key": "additionalInfo", "type": "[ErrorAdditionalInfo]"}, } - def __init__( - self, - **kwargs - ): - """ - """ - super(ErrorResponse, self).__init__(**kwargs) + def __init__(self, **kwargs): + """ """ + super().__init__(**kwargs) self.code = None self.message = None self.target = None @@ -1233,7 +1181,7 @@ def __init__( self.additional_info = None -class ExportTemplateRequest(msrest.serialization.Model): +class ExportTemplateRequest(_serialization.Model): """Export resource group template request parameters. :ivar resources: The IDs of the resources to filter the export by. To export all resources, @@ -1246,17 +1194,11 @@ class ExportTemplateRequest(msrest.serialization.Model): """ _attribute_map = { - 'resources': {'key': 'resources', 'type': '[str]'}, - 'options': {'key': 'options', 'type': 'str'}, + "resources": {"key": "resources", "type": "[str]"}, + "options": {"key": "options", "type": "str"}, } - def __init__( - self, - *, - resources: Optional[List[str]] = None, - options: Optional[str] = None, - **kwargs - ): + def __init__(self, *, resources: Optional[List[str]] = None, options: Optional[str] = None, **kwargs): """ :keyword resources: The IDs of the resources to filter the export by. To export all resources, supply an array with single entry '*'. @@ -1266,41 +1208,36 @@ def __init__( 'SkipResourceNameParameterization', 'SkipAllParameterization'. :paramtype options: str """ - super(ExportTemplateRequest, self).__init__(**kwargs) + super().__init__(**kwargs) self.resources = resources self.options = options -class ExpressionEvaluationOptions(msrest.serialization.Model): +class ExpressionEvaluationOptions(_serialization.Model): """Specifies whether template expressions are evaluated within the scope of the parent template or nested template. :ivar scope: The scope to be used for evaluation of parameters, variables and functions in a - nested template. Possible values include: "NotSpecified", "Outer", "Inner". + nested template. Known values are: "NotSpecified", "Outer", and "Inner". :vartype scope: str or ~azure.mgmt.resource.resources.v2020_06_01.models.ExpressionEvaluationOptionsScopeType """ _attribute_map = { - 'scope': {'key': 'scope', 'type': 'str'}, + "scope": {"key": "scope", "type": "str"}, } - def __init__( - self, - *, - scope: Optional[Union[str, "ExpressionEvaluationOptionsScopeType"]] = None, - **kwargs - ): + def __init__(self, *, scope: Optional[Union[str, "_models.ExpressionEvaluationOptionsScopeType"]] = None, **kwargs): """ :keyword scope: The scope to be used for evaluation of parameters, variables and functions in a - nested template. Possible values include: "NotSpecified", "Outer", "Inner". + nested template. Known values are: "NotSpecified", "Outer", and "Inner". :paramtype scope: str or ~azure.mgmt.resource.resources.v2020_06_01.models.ExpressionEvaluationOptionsScopeType """ - super(ExpressionEvaluationOptions, self).__init__(**kwargs) + super().__init__(**kwargs) self.scope = scope -class Resource(msrest.serialization.Model): +class Resource(_serialization.Model): """Specified resource. Variables are only populated by the server, and will be ignored when sending a request. @@ -1313,38 +1250,32 @@ class Resource(msrest.serialization.Model): :vartype type: str :ivar location: Resource location. :vartype location: str - :ivar tags: A set of tags. Resource tags. + :ivar tags: Resource tags. :vartype tags: dict[str, str] """ _validation = { - 'id': {'readonly': True}, - 'name': {'readonly': True}, - 'type': {'readonly': True}, + "id": {"readonly": True}, + "name": {"readonly": True}, + "type": {"readonly": True}, } _attribute_map = { - 'id': {'key': 'id', 'type': 'str'}, - 'name': {'key': 'name', 'type': 'str'}, - 'type': {'key': 'type', 'type': 'str'}, - 'location': {'key': 'location', 'type': 'str'}, - 'tags': {'key': 'tags', 'type': '{str}'}, + "id": {"key": "id", "type": "str"}, + "name": {"key": "name", "type": "str"}, + "type": {"key": "type", "type": "str"}, + "location": {"key": "location", "type": "str"}, + "tags": {"key": "tags", "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): """ :keyword location: Resource location. :paramtype location: str - :keyword tags: A set of tags. Resource tags. + :keyword tags: Resource tags. :paramtype tags: dict[str, str] """ - super(Resource, self).__init__(**kwargs) + super().__init__(**kwargs) self.id = None self.name = None self.type = None @@ -1352,7 +1283,7 @@ def __init__( self.tags = tags -class GenericResource(Resource): +class GenericResource(Resource): # pylint: disable=too-many-instance-attributes """Resource information. Variables are only populated by the server, and will be ignored when sending a request. @@ -1365,12 +1296,12 @@ class GenericResource(Resource): :vartype type: str :ivar location: Resource location. :vartype location: str - :ivar tags: A set of tags. Resource tags. + :ivar tags: Resource tags. :vartype tags: dict[str, str] :ivar plan: The plan of the resource. :vartype plan: ~azure.mgmt.resource.resources.v2020_06_01.models.Plan :ivar properties: The resource properties. - :vartype properties: any + :vartype properties: JSON :ivar kind: The kind of the resource. :vartype kind: str :ivar managed_by: ID of the resource that manages this resource. @@ -1382,23 +1313,23 @@ class GenericResource(Resource): """ _validation = { - 'id': {'readonly': True}, - 'name': {'readonly': True}, - 'type': {'readonly': True}, + "id": {"readonly": True}, + "name": {"readonly": True}, + "type": {"readonly": True}, } _attribute_map = { - 'id': {'key': 'id', 'type': 'str'}, - 'name': {'key': 'name', 'type': 'str'}, - 'type': {'key': 'type', 'type': 'str'}, - 'location': {'key': 'location', 'type': 'str'}, - 'tags': {'key': 'tags', 'type': '{str}'}, - 'plan': {'key': 'plan', 'type': 'Plan'}, - 'properties': {'key': 'properties', 'type': 'object'}, - 'kind': {'key': 'kind', 'type': 'str'}, - 'managed_by': {'key': 'managedBy', 'type': 'str'}, - 'sku': {'key': 'sku', 'type': 'Sku'}, - 'identity': {'key': 'identity', 'type': 'Identity'}, + "id": {"key": "id", "type": "str"}, + "name": {"key": "name", "type": "str"}, + "type": {"key": "type", "type": "str"}, + "location": {"key": "location", "type": "str"}, + "tags": {"key": "tags", "type": "{str}"}, + "plan": {"key": "plan", "type": "Plan"}, + "properties": {"key": "properties", "type": "object"}, + "kind": {"key": "kind", "type": "str"}, + "managed_by": {"key": "managedBy", "type": "str"}, + "sku": {"key": "sku", "type": "Sku"}, + "identity": {"key": "identity", "type": "Identity"}, } def __init__( @@ -1406,23 +1337,23 @@ def __init__( *, location: Optional[str] = None, tags: Optional[Dict[str, str]] = None, - plan: Optional["Plan"] = None, - properties: Optional[Any] = None, + plan: Optional["_models.Plan"] = None, + properties: Optional[JSON] = None, kind: Optional[str] = None, managed_by: Optional[str] = None, - sku: Optional["Sku"] = None, - identity: Optional["Identity"] = None, + sku: Optional["_models.Sku"] = None, + identity: Optional["_models.Identity"] = None, **kwargs ): """ :keyword location: Resource location. :paramtype location: str - :keyword tags: A set of tags. Resource tags. + :keyword tags: Resource tags. :paramtype tags: dict[str, str] :keyword plan: The plan of the resource. :paramtype plan: ~azure.mgmt.resource.resources.v2020_06_01.models.Plan :keyword properties: The resource properties. - :paramtype properties: any + :paramtype properties: JSON :keyword kind: The kind of the resource. :paramtype kind: str :keyword managed_by: ID of the resource that manages this resource. @@ -1432,7 +1363,7 @@ def __init__( :keyword identity: The identity of the resource. :paramtype identity: ~azure.mgmt.resource.resources.v2020_06_01.models.Identity """ - super(GenericResource, self).__init__(location=location, tags=tags, **kwargs) + super().__init__(location=location, tags=tags, **kwargs) self.plan = plan self.properties = properties self.kind = kind @@ -1441,7 +1372,7 @@ def __init__( self.identity = identity -class GenericResourceExpanded(GenericResource): +class GenericResourceExpanded(GenericResource): # pylint: disable=too-many-instance-attributes """Resource information. Variables are only populated by the server, and will be ignored when sending a request. @@ -1454,12 +1385,12 @@ class GenericResourceExpanded(GenericResource): :vartype type: str :ivar location: Resource location. :vartype location: str - :ivar tags: A set of tags. Resource tags. + :ivar tags: Resource tags. :vartype tags: dict[str, str] :ivar plan: The plan of the resource. :vartype plan: ~azure.mgmt.resource.resources.v2020_06_01.models.Plan :ivar properties: The resource properties. - :vartype properties: any + :vartype properties: JSON :ivar kind: The kind of the resource. :vartype kind: str :ivar managed_by: ID of the resource that manages this resource. @@ -1480,29 +1411,29 @@ class GenericResourceExpanded(GenericResource): """ _validation = { - 'id': {'readonly': True}, - 'name': {'readonly': True}, - 'type': {'readonly': True}, - 'created_time': {'readonly': True}, - 'changed_time': {'readonly': True}, - 'provisioning_state': {'readonly': True}, - } - - _attribute_map = { - 'id': {'key': 'id', 'type': 'str'}, - 'name': {'key': 'name', 'type': 'str'}, - 'type': {'key': 'type', 'type': 'str'}, - 'location': {'key': 'location', 'type': 'str'}, - 'tags': {'key': 'tags', 'type': '{str}'}, - 'plan': {'key': 'plan', 'type': 'Plan'}, - 'properties': {'key': 'properties', 'type': 'object'}, - 'kind': {'key': 'kind', 'type': 'str'}, - 'managed_by': {'key': 'managedBy', 'type': 'str'}, - 'sku': {'key': 'sku', 'type': 'Sku'}, - 'identity': {'key': 'identity', 'type': 'Identity'}, - 'created_time': {'key': 'createdTime', 'type': 'iso-8601'}, - 'changed_time': {'key': 'changedTime', 'type': 'iso-8601'}, - 'provisioning_state': {'key': 'provisioningState', 'type': 'str'}, + "id": {"readonly": True}, + "name": {"readonly": True}, + "type": {"readonly": True}, + "created_time": {"readonly": True}, + "changed_time": {"readonly": True}, + "provisioning_state": {"readonly": True}, + } + + _attribute_map = { + "id": {"key": "id", "type": "str"}, + "name": {"key": "name", "type": "str"}, + "type": {"key": "type", "type": "str"}, + "location": {"key": "location", "type": "str"}, + "tags": {"key": "tags", "type": "{str}"}, + "plan": {"key": "plan", "type": "Plan"}, + "properties": {"key": "properties", "type": "object"}, + "kind": {"key": "kind", "type": "str"}, + "managed_by": {"key": "managedBy", "type": "str"}, + "sku": {"key": "sku", "type": "Sku"}, + "identity": {"key": "identity", "type": "Identity"}, + "created_time": {"key": "createdTime", "type": "iso-8601"}, + "changed_time": {"key": "changedTime", "type": "iso-8601"}, + "provisioning_state": {"key": "provisioningState", "type": "str"}, } def __init__( @@ -1510,23 +1441,23 @@ def __init__( *, location: Optional[str] = None, tags: Optional[Dict[str, str]] = None, - plan: Optional["Plan"] = None, - properties: Optional[Any] = None, + plan: Optional["_models.Plan"] = None, + properties: Optional[JSON] = None, kind: Optional[str] = None, managed_by: Optional[str] = None, - sku: Optional["Sku"] = None, - identity: Optional["Identity"] = None, + sku: Optional["_models.Sku"] = None, + identity: Optional["_models.Identity"] = None, **kwargs ): """ :keyword location: Resource location. :paramtype location: str - :keyword tags: A set of tags. Resource tags. + :keyword tags: Resource tags. :paramtype tags: dict[str, str] :keyword plan: The plan of the resource. :paramtype plan: ~azure.mgmt.resource.resources.v2020_06_01.models.Plan :keyword properties: The resource properties. - :paramtype properties: any + :paramtype properties: JSON :keyword kind: The kind of the resource. :paramtype kind: str :keyword managed_by: ID of the resource that manages this resource. @@ -1536,13 +1467,23 @@ def __init__( :keyword identity: The identity of the resource. :paramtype identity: ~azure.mgmt.resource.resources.v2020_06_01.models.Identity """ - super(GenericResourceExpanded, self).__init__(location=location, tags=tags, plan=plan, properties=properties, kind=kind, managed_by=managed_by, sku=sku, identity=identity, **kwargs) + super().__init__( + location=location, + tags=tags, + plan=plan, + properties=properties, + kind=kind, + managed_by=managed_by, + sku=sku, + identity=identity, + **kwargs + ) self.created_time = None self.changed_time = None self.provisioning_state = None -class GenericResourceFilter(msrest.serialization.Model): +class GenericResourceFilter(_serialization.Model): """Resource filter. :ivar resource_type: The resource type. @@ -1554,9 +1495,9 @@ class GenericResourceFilter(msrest.serialization.Model): """ _attribute_map = { - 'resource_type': {'key': 'resourceType', 'type': 'str'}, - 'tagname': {'key': 'tagname', 'type': 'str'}, - 'tagvalue': {'key': 'tagvalue', 'type': 'str'}, + "resource_type": {"key": "resourceType", "type": "str"}, + "tagname": {"key": "tagname", "type": "str"}, + "tagvalue": {"key": "tagvalue", "type": "str"}, } def __init__( @@ -1575,38 +1516,33 @@ def __init__( :keyword tagvalue: The tag value. :paramtype tagvalue: str """ - super(GenericResourceFilter, self).__init__(**kwargs) + super().__init__(**kwargs) self.resource_type = resource_type self.tagname = tagname self.tagvalue = tagvalue -class HttpMessage(msrest.serialization.Model): +class HttpMessage(_serialization.Model): """HTTP message. :ivar content: HTTP message content. - :vartype content: any + :vartype content: JSON """ _attribute_map = { - 'content': {'key': 'content', 'type': 'object'}, + "content": {"key": "content", "type": "object"}, } - def __init__( - self, - *, - content: Optional[Any] = None, - **kwargs - ): + def __init__(self, *, content: Optional[JSON] = None, **kwargs): """ :keyword content: HTTP message content. - :paramtype content: any + :paramtype content: JSON """ - super(HttpMessage, self).__init__(**kwargs) + super().__init__(**kwargs) self.content = content -class Identity(msrest.serialization.Model): +class Identity(_serialization.Model): """Identity for the resource. Variables are only populated by the server, and will be ignored when sending a request. @@ -1615,8 +1551,8 @@ class Identity(msrest.serialization.Model): :vartype principal_id: str :ivar tenant_id: The tenant ID of resource. :vartype tenant_id: str - :ivar type: The identity type. Possible values include: "SystemAssigned", "UserAssigned", - "SystemAssigned, UserAssigned", "None". + :ivar type: The identity type. Known values are: "SystemAssigned", "UserAssigned", + "SystemAssigned, UserAssigned", and "None". :vartype type: str or ~azure.mgmt.resource.resources.v2020_06_01.models.ResourceIdentityType :ivar user_assigned_identities: The list of user identities associated with the resource. The user identity dictionary key references will be ARM resource ids in the form: @@ -1626,27 +1562,27 @@ class Identity(msrest.serialization.Model): """ _validation = { - 'principal_id': {'readonly': True}, - 'tenant_id': {'readonly': True}, + "principal_id": {"readonly": True}, + "tenant_id": {"readonly": True}, } _attribute_map = { - 'principal_id': {'key': 'principalId', 'type': 'str'}, - 'tenant_id': {'key': 'tenantId', 'type': 'str'}, - 'type': {'key': 'type', 'type': 'str'}, - 'user_assigned_identities': {'key': 'userAssignedIdentities', 'type': '{IdentityUserAssignedIdentitiesValue}'}, + "principal_id": {"key": "principalId", "type": "str"}, + "tenant_id": {"key": "tenantId", "type": "str"}, + "type": {"key": "type", "type": "str"}, + "user_assigned_identities": {"key": "userAssignedIdentities", "type": "{IdentityUserAssignedIdentitiesValue}"}, } def __init__( self, *, - type: Optional[Union[str, "ResourceIdentityType"]] = None, - user_assigned_identities: Optional[Dict[str, "IdentityUserAssignedIdentitiesValue"]] = None, + type: Optional[Union[str, "_models.ResourceIdentityType"]] = None, + user_assigned_identities: Optional[Dict[str, "_models.IdentityUserAssignedIdentitiesValue"]] = None, **kwargs ): """ - :keyword type: The identity type. Possible values include: "SystemAssigned", "UserAssigned", - "SystemAssigned, UserAssigned", "None". + :keyword type: The identity type. Known values are: "SystemAssigned", "UserAssigned", + "SystemAssigned, UserAssigned", and "None". :paramtype type: str or ~azure.mgmt.resource.resources.v2020_06_01.models.ResourceIdentityType :keyword user_assigned_identities: The list of user identities associated with the resource. The user identity dictionary key references will be ARM resource ids in the form: @@ -1654,14 +1590,14 @@ def __init__( :paramtype user_assigned_identities: dict[str, ~azure.mgmt.resource.resources.v2020_06_01.models.IdentityUserAssignedIdentitiesValue] """ - super(Identity, self).__init__(**kwargs) + super().__init__(**kwargs) self.principal_id = None self.tenant_id = None self.type = type self.user_assigned_identities = user_assigned_identities -class IdentityUserAssignedIdentitiesValue(msrest.serialization.Model): +class IdentityUserAssignedIdentitiesValue(_serialization.Model): """IdentityUserAssignedIdentitiesValue. Variables are only populated by the server, and will be ignored when sending a request. @@ -1673,61 +1609,57 @@ class IdentityUserAssignedIdentitiesValue(msrest.serialization.Model): """ _validation = { - 'principal_id': {'readonly': True}, - 'client_id': {'readonly': True}, + "principal_id": {"readonly": True}, + "client_id": {"readonly": True}, } _attribute_map = { - 'principal_id': {'key': 'principalId', 'type': 'str'}, - 'client_id': {'key': 'clientId', 'type': 'str'}, + "principal_id": {"key": "principalId", "type": "str"}, + "client_id": {"key": "clientId", "type": "str"}, } - def __init__( - self, - **kwargs - ): - """ - """ - super(IdentityUserAssignedIdentitiesValue, self).__init__(**kwargs) + def __init__(self, **kwargs): + """ """ + super().__init__(**kwargs) self.principal_id = None self.client_id = None -class OnErrorDeployment(msrest.serialization.Model): +class OnErrorDeployment(_serialization.Model): """Deployment on error behavior. :ivar type: The deployment on error behavior type. Possible values are LastSuccessful and - SpecificDeployment. Possible values include: "LastSuccessful", "SpecificDeployment". + SpecificDeployment. Known values are: "LastSuccessful" and "SpecificDeployment". :vartype type: str or ~azure.mgmt.resource.resources.v2020_06_01.models.OnErrorDeploymentType :ivar deployment_name: The deployment to be used on error case. :vartype deployment_name: str """ _attribute_map = { - 'type': {'key': 'type', 'type': 'str'}, - 'deployment_name': {'key': 'deploymentName', 'type': 'str'}, + "type": {"key": "type", "type": "str"}, + "deployment_name": {"key": "deploymentName", "type": "str"}, } def __init__( self, *, - type: Optional[Union[str, "OnErrorDeploymentType"]] = None, + type: Optional[Union[str, "_models.OnErrorDeploymentType"]] = None, deployment_name: Optional[str] = None, **kwargs ): """ :keyword type: The deployment on error behavior type. Possible values are LastSuccessful and - SpecificDeployment. Possible values include: "LastSuccessful", "SpecificDeployment". + SpecificDeployment. Known values are: "LastSuccessful" and "SpecificDeployment". :paramtype type: str or ~azure.mgmt.resource.resources.v2020_06_01.models.OnErrorDeploymentType :keyword deployment_name: The deployment to be used on error case. :paramtype deployment_name: str """ - super(OnErrorDeployment, self).__init__(**kwargs) + super().__init__(**kwargs) self.type = type self.deployment_name = deployment_name -class OnErrorDeploymentExtended(msrest.serialization.Model): +class OnErrorDeploymentExtended(_serialization.Model): """Deployment on error behavior with additional details. Variables are only populated by the server, and will be ignored when sending a request. @@ -1735,43 +1667,43 @@ class OnErrorDeploymentExtended(msrest.serialization.Model): :ivar provisioning_state: The state of the provisioning for the on error deployment. :vartype provisioning_state: str :ivar type: The deployment on error behavior type. Possible values are LastSuccessful and - SpecificDeployment. Possible values include: "LastSuccessful", "SpecificDeployment". + SpecificDeployment. Known values are: "LastSuccessful" and "SpecificDeployment". :vartype type: str or ~azure.mgmt.resource.resources.v2020_06_01.models.OnErrorDeploymentType :ivar deployment_name: The deployment to be used on error case. :vartype deployment_name: str """ _validation = { - 'provisioning_state': {'readonly': True}, + "provisioning_state": {"readonly": True}, } _attribute_map = { - 'provisioning_state': {'key': 'provisioningState', 'type': 'str'}, - 'type': {'key': 'type', 'type': 'str'}, - 'deployment_name': {'key': 'deploymentName', 'type': 'str'}, + "provisioning_state": {"key": "provisioningState", "type": "str"}, + "type": {"key": "type", "type": "str"}, + "deployment_name": {"key": "deploymentName", "type": "str"}, } def __init__( self, *, - type: Optional[Union[str, "OnErrorDeploymentType"]] = None, + type: Optional[Union[str, "_models.OnErrorDeploymentType"]] = None, deployment_name: Optional[str] = None, **kwargs ): """ :keyword type: The deployment on error behavior type. Possible values are LastSuccessful and - SpecificDeployment. Possible values include: "LastSuccessful", "SpecificDeployment". + SpecificDeployment. Known values are: "LastSuccessful" and "SpecificDeployment". :paramtype type: str or ~azure.mgmt.resource.resources.v2020_06_01.models.OnErrorDeploymentType :keyword deployment_name: The deployment to be used on error case. :paramtype deployment_name: str """ - super(OnErrorDeploymentExtended, self).__init__(**kwargs) + super().__init__(**kwargs) self.provisioning_state = None self.type = type self.deployment_name = deployment_name -class Operation(msrest.serialization.Model): +class Operation(_serialization.Model): """Microsoft.Resources operation. :ivar name: Operation name: {provider}/{resource}/{operation}. @@ -1781,29 +1713,23 @@ class Operation(msrest.serialization.Model): """ _attribute_map = { - 'name': {'key': 'name', 'type': 'str'}, - 'display': {'key': 'display', 'type': 'OperationDisplay'}, + "name": {"key": "name", "type": "str"}, + "display": {"key": "display", "type": "OperationDisplay"}, } - def __init__( - self, - *, - name: Optional[str] = None, - display: Optional["OperationDisplay"] = None, - **kwargs - ): + def __init__(self, *, name: Optional[str] = None, display: Optional["_models.OperationDisplay"] = None, **kwargs): """ :keyword name: Operation name: {provider}/{resource}/{operation}. :paramtype name: str :keyword display: The object that represents the operation. :paramtype display: ~azure.mgmt.resource.resources.v2020_06_01.models.OperationDisplay """ - super(Operation, self).__init__(**kwargs) + super().__init__(**kwargs) self.name = name self.display = display -class OperationDisplay(msrest.serialization.Model): +class OperationDisplay(_serialization.Model): """The object that represents the operation. :ivar provider: Service provider: Microsoft.Resources. @@ -1817,10 +1743,10 @@ class OperationDisplay(msrest.serialization.Model): """ _attribute_map = { - 'provider': {'key': 'provider', 'type': 'str'}, - 'resource': {'key': 'resource', 'type': 'str'}, - 'operation': {'key': 'operation', 'type': 'str'}, - 'description': {'key': 'description', 'type': 'str'}, + "provider": {"key": "provider", "type": "str"}, + "resource": {"key": "resource", "type": "str"}, + "operation": {"key": "operation", "type": "str"}, + "description": {"key": "description", "type": "str"}, } def __init__( @@ -1842,14 +1768,14 @@ def __init__( :keyword description: Description of the operation. :paramtype description: str """ - super(OperationDisplay, self).__init__(**kwargs) + super().__init__(**kwargs) self.provider = provider self.resource = resource self.operation = operation self.description = description -class OperationListResult(msrest.serialization.Model): +class OperationListResult(_serialization.Model): """Result of the request to list Microsoft.Resources operations. It contains a list of operations and a URL link to get the next set of results. :ivar value: List of Microsoft.Resources operations. @@ -1859,67 +1785,55 @@ class OperationListResult(msrest.serialization.Model): """ _attribute_map = { - 'value': {'key': 'value', 'type': '[Operation]'}, - 'next_link': {'key': 'nextLink', 'type': 'str'}, + "value": {"key": "value", "type": "[Operation]"}, + "next_link": {"key": "nextLink", "type": "str"}, } - def __init__( - self, - *, - value: Optional[List["Operation"]] = None, - next_link: Optional[str] = None, - **kwargs - ): + def __init__(self, *, value: Optional[List["_models.Operation"]] = None, next_link: Optional[str] = None, **kwargs): """ :keyword value: List of Microsoft.Resources operations. :paramtype value: list[~azure.mgmt.resource.resources.v2020_06_01.models.Operation] :keyword next_link: URL to get the next set of operation list results if there are any. :paramtype next_link: str """ - super(OperationListResult, self).__init__(**kwargs) + super().__init__(**kwargs) self.value = value self.next_link = next_link -class ParametersLink(msrest.serialization.Model): +class ParametersLink(_serialization.Model): """Entity representing the reference to the deployment parameters. All required parameters must be populated in order to send to Azure. - :ivar uri: Required. The URI of the parameters file. + :ivar uri: The URI of the parameters file. Required. :vartype uri: str :ivar content_version: If included, must match the ContentVersion in the template. :vartype content_version: str """ _validation = { - 'uri': {'required': True}, + "uri": {"required": True}, } _attribute_map = { - 'uri': {'key': 'uri', 'type': 'str'}, - 'content_version': {'key': 'contentVersion', 'type': 'str'}, + "uri": {"key": "uri", "type": "str"}, + "content_version": {"key": "contentVersion", "type": "str"}, } - def __init__( - self, - *, - uri: str, - content_version: Optional[str] = None, - **kwargs - ): + def __init__(self, *, uri: str, content_version: Optional[str] = None, **kwargs): """ - :keyword uri: Required. The URI of the parameters file. + :keyword uri: The URI of the parameters file. Required. :paramtype uri: str :keyword content_version: If included, must match the ContentVersion in the template. :paramtype content_version: str """ - super(ParametersLink, self).__init__(**kwargs) + super().__init__(**kwargs) self.uri = uri self.content_version = content_version -class Plan(msrest.serialization.Model): +class Plan(_serialization.Model): """Plan for the resource. :ivar name: The plan ID. @@ -1935,11 +1849,11 @@ class Plan(msrest.serialization.Model): """ _attribute_map = { - 'name': {'key': 'name', 'type': 'str'}, - 'publisher': {'key': 'publisher', 'type': 'str'}, - 'product': {'key': 'product', 'type': 'str'}, - 'promotion_code': {'key': 'promotionCode', 'type': 'str'}, - 'version': {'key': 'version', 'type': 'str'}, + "name": {"key": "name", "type": "str"}, + "publisher": {"key": "publisher", "type": "str"}, + "product": {"key": "product", "type": "str"}, + "promotion_code": {"key": "promotionCode", "type": "str"}, + "version": {"key": "version", "type": "str"}, } def __init__( @@ -1964,7 +1878,7 @@ def __init__( :keyword version: The plan's version. :paramtype version: str """ - super(Plan, self).__init__(**kwargs) + super().__init__(**kwargs) self.name = name self.publisher = publisher self.product = product @@ -1972,7 +1886,7 @@ def __init__( self.version = version -class Provider(msrest.serialization.Model): +class Provider(_serialization.Model): """Resource provider information. Variables are only populated by the server, and will be ignored when sending a request. @@ -1991,31 +1905,26 @@ class Provider(msrest.serialization.Model): """ _validation = { - 'id': {'readonly': True}, - 'registration_state': {'readonly': True}, - 'registration_policy': {'readonly': True}, - 'resource_types': {'readonly': True}, + "id": {"readonly": True}, + "registration_state": {"readonly": True}, + "registration_policy": {"readonly": True}, + "resource_types": {"readonly": True}, } _attribute_map = { - 'id': {'key': 'id', 'type': 'str'}, - 'namespace': {'key': 'namespace', 'type': 'str'}, - 'registration_state': {'key': 'registrationState', 'type': 'str'}, - 'registration_policy': {'key': 'registrationPolicy', 'type': 'str'}, - 'resource_types': {'key': 'resourceTypes', 'type': '[ProviderResourceType]'}, + "id": {"key": "id", "type": "str"}, + "namespace": {"key": "namespace", "type": "str"}, + "registration_state": {"key": "registrationState", "type": "str"}, + "registration_policy": {"key": "registrationPolicy", "type": "str"}, + "resource_types": {"key": "resourceTypes", "type": "[ProviderResourceType]"}, } - def __init__( - self, - *, - namespace: Optional[str] = None, - **kwargs - ): + def __init__(self, *, namespace: Optional[str] = None, **kwargs): """ :keyword namespace: The namespace of the resource provider. :paramtype namespace: str """ - super(Provider, self).__init__(**kwargs) + super().__init__(**kwargs) self.id = None self.namespace = namespace self.registration_state = None @@ -2023,7 +1932,7 @@ def __init__( self.resource_types = None -class ProviderListResult(msrest.serialization.Model): +class ProviderListResult(_serialization.Model): """List of resource providers. Variables are only populated by the server, and will be ignored when sending a request. @@ -2035,30 +1944,25 @@ class ProviderListResult(msrest.serialization.Model): """ _validation = { - 'next_link': {'readonly': True}, + "next_link": {"readonly": True}, } _attribute_map = { - 'value': {'key': 'value', 'type': '[Provider]'}, - 'next_link': {'key': 'nextLink', 'type': 'str'}, + "value": {"key": "value", "type": "[Provider]"}, + "next_link": {"key": "nextLink", "type": "str"}, } - def __init__( - self, - *, - value: Optional[List["Provider"]] = None, - **kwargs - ): + def __init__(self, *, value: Optional[List["_models.Provider"]] = None, **kwargs): """ :keyword value: An array of resource providers. :paramtype value: list[~azure.mgmt.resource.resources.v2020_06_01.models.Provider] """ - super(ProviderListResult, self).__init__(**kwargs) + super().__init__(**kwargs) self.value = value self.next_link = None -class ProviderResourceType(msrest.serialization.Model): +class ProviderResourceType(_serialization.Model): """Resource type managed by the resource provider. Variables are only populated by the server, and will be ignored when sending a request. @@ -2084,20 +1988,20 @@ class ProviderResourceType(msrest.serialization.Model): """ _validation = { - 'default_api_version': {'readonly': True}, - 'api_profiles': {'readonly': True}, + "default_api_version": {"readonly": True}, + "api_profiles": {"readonly": True}, } _attribute_map = { - 'resource_type': {'key': 'resourceType', 'type': 'str'}, - 'locations': {'key': 'locations', 'type': '[str]'}, - 'aliases': {'key': 'aliases', 'type': '[Alias]'}, - 'api_versions': {'key': 'apiVersions', 'type': '[str]'}, - 'default_api_version': {'key': 'defaultApiVersion', 'type': 'str'}, - 'zone_mappings': {'key': 'zoneMappings', 'type': '[ZoneMapping]'}, - 'api_profiles': {'key': 'apiProfiles', 'type': '[ApiProfile]'}, - 'capabilities': {'key': 'capabilities', 'type': 'str'}, - 'properties': {'key': 'properties', 'type': '{str}'}, + "resource_type": {"key": "resourceType", "type": "str"}, + "locations": {"key": "locations", "type": "[str]"}, + "aliases": {"key": "aliases", "type": "[Alias]"}, + "api_versions": {"key": "apiVersions", "type": "[str]"}, + "default_api_version": {"key": "defaultApiVersion", "type": "str"}, + "zone_mappings": {"key": "zoneMappings", "type": "[ZoneMapping]"}, + "api_profiles": {"key": "apiProfiles", "type": "[ApiProfile]"}, + "capabilities": {"key": "capabilities", "type": "str"}, + "properties": {"key": "properties", "type": "{str}"}, } def __init__( @@ -2105,9 +2009,9 @@ def __init__( *, resource_type: Optional[str] = None, locations: Optional[List[str]] = None, - aliases: Optional[List["Alias"]] = None, + aliases: Optional[List["_models.Alias"]] = None, api_versions: Optional[List[str]] = None, - zone_mappings: Optional[List["ZoneMapping"]] = None, + zone_mappings: Optional[List["_models.ZoneMapping"]] = None, capabilities: Optional[str] = None, properties: Optional[Dict[str, str]] = None, **kwargs @@ -2128,7 +2032,7 @@ def __init__( :keyword properties: The properties. :paramtype properties: dict[str, str] """ - super(ProviderResourceType, self).__init__(**kwargs) + super().__init__(**kwargs) self.resource_type = resource_type self.locations = locations self.aliases = aliases @@ -2140,7 +2044,7 @@ def __init__( self.properties = properties -class ResourceGroup(msrest.serialization.Model): +class ResourceGroup(_serialization.Model): """Resource group information. Variables are only populated by the server, and will be ignored when sending a request. @@ -2155,37 +2059,37 @@ class ResourceGroup(msrest.serialization.Model): :vartype type: str :ivar properties: The resource group properties. :vartype properties: ~azure.mgmt.resource.resources.v2020_06_01.models.ResourceGroupProperties - :ivar location: Required. The location of the resource group. It cannot be changed after the - resource group has been created. It must be one of the supported Azure locations. + :ivar location: The location of the resource group. It cannot be changed after the resource + group has been created. It must be one of the supported Azure locations. Required. :vartype location: str :ivar managed_by: The ID of the resource that manages this resource group. :vartype managed_by: str - :ivar tags: A set of tags. The tags attached to the resource group. + :ivar tags: The tags attached to the resource group. :vartype tags: dict[str, str] """ _validation = { - 'id': {'readonly': True}, - 'name': {'readonly': True}, - 'type': {'readonly': True}, - 'location': {'required': True}, + "id": {"readonly": True}, + "name": {"readonly": True}, + "type": {"readonly": True}, + "location": {"required": True}, } _attribute_map = { - 'id': {'key': 'id', 'type': 'str'}, - 'name': {'key': 'name', 'type': 'str'}, - 'type': {'key': 'type', 'type': 'str'}, - 'properties': {'key': 'properties', 'type': 'ResourceGroupProperties'}, - 'location': {'key': 'location', 'type': 'str'}, - 'managed_by': {'key': 'managedBy', 'type': 'str'}, - 'tags': {'key': 'tags', 'type': '{str}'}, + "id": {"key": "id", "type": "str"}, + "name": {"key": "name", "type": "str"}, + "type": {"key": "type", "type": "str"}, + "properties": {"key": "properties", "type": "ResourceGroupProperties"}, + "location": {"key": "location", "type": "str"}, + "managed_by": {"key": "managedBy", "type": "str"}, + "tags": {"key": "tags", "type": "{str}"}, } def __init__( self, *, location: str, - properties: Optional["ResourceGroupProperties"] = None, + properties: Optional["_models.ResourceGroupProperties"] = None, managed_by: Optional[str] = None, tags: Optional[Dict[str, str]] = None, **kwargs @@ -2194,15 +2098,15 @@ def __init__( :keyword properties: The resource group properties. :paramtype properties: ~azure.mgmt.resource.resources.v2020_06_01.models.ResourceGroupProperties - :keyword location: Required. The location of the resource group. It cannot be changed after the - resource group has been created. It must be one of the supported Azure locations. + :keyword location: The location of the resource group. It cannot be changed after the resource + group has been created. It must be one of the supported Azure locations. Required. :paramtype location: str :keyword managed_by: The ID of the resource that manages this resource group. :paramtype managed_by: str - :keyword tags: A set of tags. The tags attached to the resource group. + :keyword tags: The tags attached to the resource group. :paramtype tags: dict[str, str] """ - super(ResourceGroup, self).__init__(**kwargs) + super().__init__(**kwargs) self.id = None self.name = None self.type = None @@ -2212,39 +2116,33 @@ def __init__( self.tags = tags -class ResourceGroupExportResult(msrest.serialization.Model): +class ResourceGroupExportResult(_serialization.Model): """Resource group export result. :ivar template: The template content. - :vartype template: any + :vartype template: JSON :ivar error: The template export error. :vartype error: ~azure.mgmt.resource.resources.v2020_06_01.models.ErrorResponse """ _attribute_map = { - 'template': {'key': 'template', 'type': 'object'}, - 'error': {'key': 'error', 'type': 'ErrorResponse'}, + "template": {"key": "template", "type": "object"}, + "error": {"key": "error", "type": "ErrorResponse"}, } - def __init__( - self, - *, - template: Optional[Any] = None, - error: Optional["ErrorResponse"] = None, - **kwargs - ): + def __init__(self, *, template: Optional[JSON] = None, error: Optional["_models.ErrorResponse"] = None, **kwargs): """ :keyword template: The template content. - :paramtype template: any + :paramtype template: JSON :keyword error: The template export error. :paramtype error: ~azure.mgmt.resource.resources.v2020_06_01.models.ErrorResponse """ - super(ResourceGroupExportResult, self).__init__(**kwargs) + super().__init__(**kwargs) self.template = template self.error = error -class ResourceGroupFilter(msrest.serialization.Model): +class ResourceGroupFilter(_serialization.Model): """Resource group filter. :ivar tag_name: The tag name. @@ -2254,29 +2152,23 @@ class ResourceGroupFilter(msrest.serialization.Model): """ _attribute_map = { - 'tag_name': {'key': 'tagName', 'type': 'str'}, - 'tag_value': {'key': 'tagValue', 'type': 'str'}, + "tag_name": {"key": "tagName", "type": "str"}, + "tag_value": {"key": "tagValue", "type": "str"}, } - def __init__( - self, - *, - tag_name: Optional[str] = None, - tag_value: Optional[str] = None, - **kwargs - ): + def __init__(self, *, tag_name: Optional[str] = None, tag_value: Optional[str] = None, **kwargs): """ :keyword tag_name: The tag name. :paramtype tag_name: str :keyword tag_value: The tag value. :paramtype tag_value: str """ - super(ResourceGroupFilter, self).__init__(**kwargs) + super().__init__(**kwargs) self.tag_name = tag_name self.tag_value = tag_value -class ResourceGroupListResult(msrest.serialization.Model): +class ResourceGroupListResult(_serialization.Model): """List of resource groups. Variables are only populated by the server, and will be ignored when sending a request. @@ -2288,30 +2180,25 @@ class ResourceGroupListResult(msrest.serialization.Model): """ _validation = { - 'next_link': {'readonly': True}, + "next_link": {"readonly": True}, } _attribute_map = { - 'value': {'key': 'value', 'type': '[ResourceGroup]'}, - 'next_link': {'key': 'nextLink', 'type': 'str'}, + "value": {"key": "value", "type": "[ResourceGroup]"}, + "next_link": {"key": "nextLink", "type": "str"}, } - def __init__( - self, - *, - value: Optional[List["ResourceGroup"]] = None, - **kwargs - ): + def __init__(self, *, value: Optional[List["_models.ResourceGroup"]] = None, **kwargs): """ :keyword value: An array of resource groups. :paramtype value: list[~azure.mgmt.resource.resources.v2020_06_01.models.ResourceGroup] """ - super(ResourceGroupListResult, self).__init__(**kwargs) + super().__init__(**kwargs) self.value = value self.next_link = None -class ResourceGroupPatchable(msrest.serialization.Model): +class ResourceGroupPatchable(_serialization.Model): """Resource group information. :ivar name: The name of the resource group. @@ -2320,22 +2207,22 @@ class ResourceGroupPatchable(msrest.serialization.Model): :vartype properties: ~azure.mgmt.resource.resources.v2020_06_01.models.ResourceGroupProperties :ivar managed_by: The ID of the resource that manages this resource group. :vartype managed_by: str - :ivar tags: A set of tags. The tags attached to the resource group. + :ivar tags: The tags attached to the resource group. :vartype tags: dict[str, str] """ _attribute_map = { - 'name': {'key': 'name', 'type': 'str'}, - 'properties': {'key': 'properties', 'type': 'ResourceGroupProperties'}, - 'managed_by': {'key': 'managedBy', 'type': 'str'}, - 'tags': {'key': 'tags', 'type': '{str}'}, + "name": {"key": "name", "type": "str"}, + "properties": {"key": "properties", "type": "ResourceGroupProperties"}, + "managed_by": {"key": "managedBy", "type": "str"}, + "tags": {"key": "tags", "type": "{str}"}, } def __init__( self, *, name: Optional[str] = None, - properties: Optional["ResourceGroupProperties"] = None, + properties: Optional["_models.ResourceGroupProperties"] = None, managed_by: Optional[str] = None, tags: Optional[Dict[str, str]] = None, **kwargs @@ -2348,17 +2235,17 @@ def __init__( ~azure.mgmt.resource.resources.v2020_06_01.models.ResourceGroupProperties :keyword managed_by: The ID of the resource that manages this resource group. :paramtype managed_by: str - :keyword tags: A set of tags. The tags attached to the resource group. + :keyword tags: The tags attached to the resource group. :paramtype tags: dict[str, str] """ - super(ResourceGroupPatchable, self).__init__(**kwargs) + super().__init__(**kwargs) self.name = name self.properties = properties self.managed_by = managed_by self.tags = tags -class ResourceGroupProperties(msrest.serialization.Model): +class ResourceGroupProperties(_serialization.Model): """The resource group properties. Variables are only populated by the server, and will be ignored when sending a request. @@ -2368,24 +2255,20 @@ class ResourceGroupProperties(msrest.serialization.Model): """ _validation = { - 'provisioning_state': {'readonly': True}, + "provisioning_state": {"readonly": True}, } _attribute_map = { - 'provisioning_state': {'key': 'provisioningState', 'type': 'str'}, + "provisioning_state": {"key": "provisioningState", "type": "str"}, } - def __init__( - self, - **kwargs - ): - """ - """ - super(ResourceGroupProperties, self).__init__(**kwargs) + def __init__(self, **kwargs): + """ """ + super().__init__(**kwargs) self.provisioning_state = None -class ResourceListResult(msrest.serialization.Model): +class ResourceListResult(_serialization.Model): """List of resource groups. Variables are only populated by the server, and will be ignored when sending a request. @@ -2397,31 +2280,26 @@ class ResourceListResult(msrest.serialization.Model): """ _validation = { - 'next_link': {'readonly': True}, + "next_link": {"readonly": True}, } _attribute_map = { - 'value': {'key': 'value', 'type': '[GenericResourceExpanded]'}, - 'next_link': {'key': 'nextLink', 'type': 'str'}, + "value": {"key": "value", "type": "[GenericResourceExpanded]"}, + "next_link": {"key": "nextLink", "type": "str"}, } - def __init__( - self, - *, - value: Optional[List["GenericResourceExpanded"]] = None, - **kwargs - ): + def __init__(self, *, value: Optional[List["_models.GenericResourceExpanded"]] = None, **kwargs): """ :keyword value: An array of resources. :paramtype value: list[~azure.mgmt.resource.resources.v2020_06_01.models.GenericResourceExpanded] """ - super(ResourceListResult, self).__init__(**kwargs) + super().__init__(**kwargs) self.value = value self.next_link = None -class ResourceProviderOperationDisplayProperties(msrest.serialization.Model): +class ResourceProviderOperationDisplayProperties(_serialization.Model): """Resource provider operation's display properties. :ivar publisher: Operation description. @@ -2437,11 +2315,11 @@ class ResourceProviderOperationDisplayProperties(msrest.serialization.Model): """ _attribute_map = { - 'publisher': {'key': 'publisher', 'type': 'str'}, - 'provider': {'key': 'provider', 'type': 'str'}, - 'resource': {'key': 'resource', 'type': 'str'}, - 'operation': {'key': 'operation', 'type': 'str'}, - 'description': {'key': 'description', 'type': 'str'}, + "publisher": {"key": "publisher", "type": "str"}, + "provider": {"key": "provider", "type": "str"}, + "resource": {"key": "resource", "type": "str"}, + "operation": {"key": "operation", "type": "str"}, + "description": {"key": "description", "type": "str"}, } def __init__( @@ -2466,7 +2344,7 @@ def __init__( :keyword description: Operation description. :paramtype description: str """ - super(ResourceProviderOperationDisplayProperties, self).__init__(**kwargs) + super().__init__(**kwargs) self.publisher = publisher self.provider = provider self.resource = resource @@ -2474,7 +2352,7 @@ def __init__( self.description = description -class ResourceReference(msrest.serialization.Model): +class ResourceReference(_serialization.Model): """The resource Id model. Variables are only populated by the server, and will be ignored when sending a request. @@ -2484,24 +2362,20 @@ class ResourceReference(msrest.serialization.Model): """ _validation = { - 'id': {'readonly': True}, + "id": {"readonly": True}, } _attribute_map = { - 'id': {'key': 'id', 'type': 'str'}, + "id": {"key": "id", "type": "str"}, } - def __init__( - self, - **kwargs - ): - """ - """ - super(ResourceReference, self).__init__(**kwargs) + def __init__(self, **kwargs): + """ """ + super().__init__(**kwargs) self.id = None -class ResourcesMoveInfo(msrest.serialization.Model): +class ResourcesMoveInfo(_serialization.Model): """Parameters of move resources. :ivar resources: The IDs of the resources. @@ -2511,116 +2385,104 @@ class ResourcesMoveInfo(msrest.serialization.Model): """ _attribute_map = { - 'resources': {'key': 'resources', 'type': '[str]'}, - 'target_resource_group': {'key': 'targetResourceGroup', 'type': 'str'}, + "resources": {"key": "resources", "type": "[str]"}, + "target_resource_group": {"key": "targetResourceGroup", "type": "str"}, } - def __init__( - self, - *, - resources: Optional[List[str]] = None, - target_resource_group: Optional[str] = None, - **kwargs - ): + def __init__(self, *, resources: Optional[List[str]] = None, target_resource_group: Optional[str] = None, **kwargs): """ :keyword resources: The IDs of the resources. :paramtype resources: list[str] :keyword target_resource_group: The target resource group. :paramtype target_resource_group: str """ - super(ResourcesMoveInfo, self).__init__(**kwargs) + super().__init__(**kwargs) self.resources = resources self.target_resource_group = target_resource_group -class ScopedDeployment(msrest.serialization.Model): +class ScopedDeployment(_serialization.Model): """Deployment operation parameters. All required parameters must be populated in order to send to Azure. - :ivar location: Required. The location to store the deployment data. + :ivar location: The location to store the deployment data. Required. :vartype location: str - :ivar properties: Required. The deployment properties. + :ivar properties: The deployment properties. Required. :vartype properties: ~azure.mgmt.resource.resources.v2020_06_01.models.DeploymentProperties - :ivar tags: A set of tags. Deployment tags. + :ivar tags: Deployment tags. :vartype tags: dict[str, str] """ _validation = { - 'location': {'required': True}, - 'properties': {'required': True}, + "location": {"required": True}, + "properties": {"required": True}, } _attribute_map = { - 'location': {'key': 'location', 'type': 'str'}, - 'properties': {'key': 'properties', 'type': 'DeploymentProperties'}, - 'tags': {'key': 'tags', 'type': '{str}'}, + "location": {"key": "location", "type": "str"}, + "properties": {"key": "properties", "type": "DeploymentProperties"}, + "tags": {"key": "tags", "type": "{str}"}, } def __init__( self, *, location: str, - properties: "DeploymentProperties", + properties: "_models.DeploymentProperties", tags: Optional[Dict[str, str]] = None, **kwargs ): """ - :keyword location: Required. The location to store the deployment data. + :keyword location: The location to store the deployment data. Required. :paramtype location: str - :keyword properties: Required. The deployment properties. + :keyword properties: The deployment properties. Required. :paramtype properties: ~azure.mgmt.resource.resources.v2020_06_01.models.DeploymentProperties - :keyword tags: A set of tags. Deployment tags. + :keyword tags: Deployment tags. :paramtype tags: dict[str, str] """ - super(ScopedDeployment, self).__init__(**kwargs) + super().__init__(**kwargs) self.location = location self.properties = properties self.tags = tags -class ScopedDeploymentWhatIf(msrest.serialization.Model): +class ScopedDeploymentWhatIf(_serialization.Model): """Deployment What-if operation parameters. All required parameters must be populated in order to send to Azure. - :ivar location: Required. The location to store the deployment data. + :ivar location: The location to store the deployment data. Required. :vartype location: str - :ivar properties: Required. The deployment properties. + :ivar properties: The deployment properties. Required. :vartype properties: ~azure.mgmt.resource.resources.v2020_06_01.models.DeploymentWhatIfProperties """ _validation = { - 'location': {'required': True}, - 'properties': {'required': True}, + "location": {"required": True}, + "properties": {"required": True}, } _attribute_map = { - 'location': {'key': 'location', 'type': 'str'}, - 'properties': {'key': 'properties', 'type': 'DeploymentWhatIfProperties'}, + "location": {"key": "location", "type": "str"}, + "properties": {"key": "properties", "type": "DeploymentWhatIfProperties"}, } - def __init__( - self, - *, - location: str, - properties: "DeploymentWhatIfProperties", - **kwargs - ): + def __init__(self, *, location: str, properties: "_models.DeploymentWhatIfProperties", **kwargs): """ - :keyword location: Required. The location to store the deployment data. + :keyword location: The location to store the deployment data. Required. :paramtype location: str - :keyword properties: Required. The deployment properties. + :keyword properties: The deployment properties. Required. :paramtype properties: ~azure.mgmt.resource.resources.v2020_06_01.models.DeploymentWhatIfProperties """ - super(ScopedDeploymentWhatIf, self).__init__(**kwargs) + super().__init__(**kwargs) self.location = location self.properties = properties -class Sku(msrest.serialization.Model): +class Sku(_serialization.Model): """SKU for the resource. :ivar name: The SKU name. @@ -2638,12 +2500,12 @@ class Sku(msrest.serialization.Model): """ _attribute_map = { - 'name': {'key': 'name', 'type': 'str'}, - 'tier': {'key': 'tier', 'type': 'str'}, - 'size': {'key': 'size', 'type': 'str'}, - 'family': {'key': 'family', 'type': 'str'}, - 'model': {'key': 'model', 'type': 'str'}, - 'capacity': {'key': 'capacity', 'type': 'int'}, + "name": {"key": "name", "type": "str"}, + "tier": {"key": "tier", "type": "str"}, + "size": {"key": "size", "type": "str"}, + "family": {"key": "family", "type": "str"}, + "model": {"key": "model", "type": "str"}, + "capacity": {"key": "capacity", "type": "int"}, } def __init__( @@ -2671,7 +2533,7 @@ def __init__( :keyword capacity: The SKU capacity. :paramtype capacity: int """ - super(Sku, self).__init__(**kwargs) + super().__init__(**kwargs) self.name = name self.tier = tier self.size = size @@ -2680,7 +2542,7 @@ def __init__( self.capacity = capacity -class StatusMessage(msrest.serialization.Model): +class StatusMessage(_serialization.Model): """Operation status message object. :ivar status: Status of the deployment operation. @@ -2690,29 +2552,23 @@ class StatusMessage(msrest.serialization.Model): """ _attribute_map = { - 'status': {'key': 'status', 'type': 'str'}, - 'error': {'key': 'error', 'type': 'ErrorResponse'}, + "status": {"key": "status", "type": "str"}, + "error": {"key": "error", "type": "ErrorResponse"}, } - def __init__( - self, - *, - status: Optional[str] = None, - error: Optional["ErrorResponse"] = None, - **kwargs - ): + def __init__(self, *, status: Optional[str] = None, error: Optional["_models.ErrorResponse"] = None, **kwargs): """ :keyword status: Status of the deployment operation. :paramtype status: str :keyword error: The error reported by the operation. :paramtype error: ~azure.mgmt.resource.resources.v2020_06_01.models.ErrorResponse """ - super(StatusMessage, self).__init__(**kwargs) + super().__init__(**kwargs) self.status = status self.error = error -class SubResource(msrest.serialization.Model): +class SubResource(_serialization.Model): """Sub-resource. :ivar id: Resource ID. @@ -2720,24 +2576,19 @@ class SubResource(msrest.serialization.Model): """ _attribute_map = { - 'id': {'key': 'id', 'type': 'str'}, + "id": {"key": "id", "type": "str"}, } - def __init__( - self, - *, - id: Optional[str] = None, - **kwargs - ): + def __init__(self, *, id: Optional[str] = None, **kwargs): # pylint: disable=redefined-builtin """ :keyword id: Resource ID. :paramtype id: str """ - super(SubResource, self).__init__(**kwargs) + super().__init__(**kwargs) self.id = id -class TagCount(msrest.serialization.Model): +class TagCount(_serialization.Model): """Tag count. :ivar type: Type of count. @@ -2747,29 +2598,23 @@ class TagCount(msrest.serialization.Model): """ _attribute_map = { - 'type': {'key': 'type', 'type': 'str'}, - 'value': {'key': 'value', 'type': 'int'}, + "type": {"key": "type", "type": "str"}, + "value": {"key": "value", "type": "int"}, } - def __init__( - self, - *, - type: Optional[str] = None, - value: Optional[int] = None, - **kwargs - ): + def __init__(self, *, type: Optional[str] = None, value: Optional[int] = None, **kwargs): """ :keyword type: Type of count. :paramtype type: str :keyword value: Value of count. :paramtype value: int """ - super(TagCount, self).__init__(**kwargs) + super().__init__(**kwargs) self.type = type self.value = value -class TagDetails(msrest.serialization.Model): +class TagDetails(_serialization.Model): """Tag details. Variables are only populated by the server, and will be ignored when sending a request. @@ -2786,22 +2631,22 @@ class TagDetails(msrest.serialization.Model): """ _validation = { - 'id': {'readonly': True}, + "id": {"readonly": True}, } _attribute_map = { - 'id': {'key': 'id', 'type': 'str'}, - 'tag_name': {'key': 'tagName', 'type': 'str'}, - 'count': {'key': 'count', 'type': 'TagCount'}, - 'values': {'key': 'values', 'type': '[TagValue]'}, + "id": {"key": "id", "type": "str"}, + "tag_name": {"key": "tagName", "type": "str"}, + "count": {"key": "count", "type": "TagCount"}, + "values": {"key": "values", "type": "[TagValue]"}, } def __init__( self, *, tag_name: Optional[str] = None, - count: Optional["TagCount"] = None, - values: Optional[List["TagValue"]] = None, + count: Optional["_models.TagCount"] = None, + values: Optional[List["_models.TagValue"]] = None, **kwargs ): """ @@ -2813,39 +2658,34 @@ def __init__( :keyword values: The list of tag values. :paramtype values: list[~azure.mgmt.resource.resources.v2020_06_01.models.TagValue] """ - super(TagDetails, self).__init__(**kwargs) + super().__init__(**kwargs) self.id = None self.tag_name = tag_name self.count = count self.values = values -class Tags(msrest.serialization.Model): +class Tags(_serialization.Model): """A dictionary of name and value pairs. - :ivar tags: A set of tags. Dictionary of :code:``. + :ivar tags: Dictionary of :code:``. :vartype tags: dict[str, str] """ _attribute_map = { - 'tags': {'key': 'tags', 'type': '{str}'}, + "tags": {"key": "tags", "type": "{str}"}, } - def __init__( - self, - *, - tags: Optional[Dict[str, str]] = None, - **kwargs - ): + def __init__(self, *, tags: Optional[Dict[str, str]] = None, **kwargs): """ - :keyword tags: A set of tags. Dictionary of :code:``. + :keyword tags: Dictionary of :code:``. :paramtype tags: dict[str, str] """ - super(Tags, self).__init__(**kwargs) + super().__init__(**kwargs) self.tags = tags -class TagsListResult(msrest.serialization.Model): +class TagsListResult(_serialization.Model): """List of subscription tags. Variables are only populated by the server, and will be ignored when sending a request. @@ -2857,65 +2697,60 @@ class TagsListResult(msrest.serialization.Model): """ _validation = { - 'next_link': {'readonly': True}, + "next_link": {"readonly": True}, } _attribute_map = { - 'value': {'key': 'value', 'type': '[TagDetails]'}, - 'next_link': {'key': 'nextLink', 'type': 'str'}, + "value": {"key": "value", "type": "[TagDetails]"}, + "next_link": {"key": "nextLink", "type": "str"}, } - def __init__( - self, - *, - value: Optional[List["TagDetails"]] = None, - **kwargs - ): + def __init__(self, *, value: Optional[List["_models.TagDetails"]] = None, **kwargs): """ :keyword value: An array of tags. :paramtype value: list[~azure.mgmt.resource.resources.v2020_06_01.models.TagDetails] """ - super(TagsListResult, self).__init__(**kwargs) + super().__init__(**kwargs) self.value = value self.next_link = None -class TagsPatchResource(msrest.serialization.Model): +class TagsPatchResource(_serialization.Model): """Wrapper resource for tags patch API request only. - :ivar operation: The operation type for the patch API. Possible values include: "Replace", - "Merge", "Delete". + :ivar operation: The operation type for the patch API. Known values are: "Replace", "Merge", + and "Delete". :vartype operation: str or ~azure.mgmt.resource.resources.v2020_06_01.models.TagsPatchOperation :ivar properties: The set of tags. :vartype properties: ~azure.mgmt.resource.resources.v2020_06_01.models.Tags """ _attribute_map = { - 'operation': {'key': 'operation', 'type': 'str'}, - 'properties': {'key': 'properties', 'type': 'Tags'}, + "operation": {"key": "operation", "type": "str"}, + "properties": {"key": "properties", "type": "Tags"}, } def __init__( self, *, - operation: Optional[Union[str, "TagsPatchOperation"]] = None, - properties: Optional["Tags"] = None, + operation: Optional[Union[str, "_models.TagsPatchOperation"]] = None, + properties: Optional["_models.Tags"] = None, **kwargs ): """ - :keyword operation: The operation type for the patch API. Possible values include: "Replace", - "Merge", "Delete". + :keyword operation: The operation type for the patch API. Known values are: "Replace", "Merge", + and "Delete". :paramtype operation: str or ~azure.mgmt.resource.resources.v2020_06_01.models.TagsPatchOperation :keyword properties: The set of tags. :paramtype properties: ~azure.mgmt.resource.resources.v2020_06_01.models.Tags """ - super(TagsPatchResource, self).__init__(**kwargs) + super().__init__(**kwargs) self.operation = operation self.properties = properties -class TagsResource(msrest.serialization.Model): +class TagsResource(_serialization.Model): """Wrapper resource for tags API requests and responses. Variables are only populated by the server, and will be ignored when sending a request. @@ -2928,42 +2763,37 @@ class TagsResource(msrest.serialization.Model): :vartype name: str :ivar type: The type of the tags wrapper resource. :vartype type: str - :ivar properties: Required. The set of tags. + :ivar properties: The set of tags. Required. :vartype properties: ~azure.mgmt.resource.resources.v2020_06_01.models.Tags """ _validation = { - 'id': {'readonly': True}, - 'name': {'readonly': True}, - 'type': {'readonly': True}, - 'properties': {'required': True}, + "id": {"readonly": True}, + "name": {"readonly": True}, + "type": {"readonly": True}, + "properties": {"required": True}, } _attribute_map = { - 'id': {'key': 'id', 'type': 'str'}, - 'name': {'key': 'name', 'type': 'str'}, - 'type': {'key': 'type', 'type': 'str'}, - 'properties': {'key': 'properties', 'type': 'Tags'}, + "id": {"key": "id", "type": "str"}, + "name": {"key": "name", "type": "str"}, + "type": {"key": "type", "type": "str"}, + "properties": {"key": "properties", "type": "Tags"}, } - def __init__( - self, - *, - properties: "Tags", - **kwargs - ): + def __init__(self, *, properties: "_models.Tags", **kwargs): """ - :keyword properties: Required. The set of tags. + :keyword properties: The set of tags. Required. :paramtype properties: ~azure.mgmt.resource.resources.v2020_06_01.models.Tags """ - super(TagsResource, self).__init__(**kwargs) + super().__init__(**kwargs) self.id = None self.name = None self.type = None self.properties = properties -class TagValue(msrest.serialization.Model): +class TagValue(_serialization.Model): """Tag information. Variables are only populated by the server, and will be ignored when sending a request. @@ -2977,35 +2807,29 @@ class TagValue(msrest.serialization.Model): """ _validation = { - 'id': {'readonly': True}, + "id": {"readonly": True}, } _attribute_map = { - 'id': {'key': 'id', 'type': 'str'}, - 'tag_value': {'key': 'tagValue', 'type': 'str'}, - 'count': {'key': 'count', 'type': 'TagCount'}, + "id": {"key": "id", "type": "str"}, + "tag_value": {"key": "tagValue", "type": "str"}, + "count": {"key": "count", "type": "TagCount"}, } - def __init__( - self, - *, - tag_value: Optional[str] = None, - count: Optional["TagCount"] = None, - **kwargs - ): + def __init__(self, *, tag_value: Optional[str] = None, count: Optional["_models.TagCount"] = None, **kwargs): """ :keyword tag_value: The tag value. :paramtype tag_value: str :keyword count: The tag value count. :paramtype count: ~azure.mgmt.resource.resources.v2020_06_01.models.TagCount """ - super(TagValue, self).__init__(**kwargs) + super().__init__(**kwargs) self.id = None self.tag_value = tag_value self.count = count -class TargetResource(msrest.serialization.Model): +class TargetResource(_serialization.Model): """Target resource. :ivar id: The ID of the resource. @@ -3017,15 +2841,15 @@ class TargetResource(msrest.serialization.Model): """ _attribute_map = { - 'id': {'key': 'id', 'type': 'str'}, - 'resource_name': {'key': 'resourceName', 'type': 'str'}, - 'resource_type': {'key': 'resourceType', 'type': 'str'}, + "id": {"key": "id", "type": "str"}, + "resource_name": {"key": "resourceName", "type": "str"}, + "resource_type": {"key": "resourceType", "type": "str"}, } def __init__( self, *, - id: Optional[str] = None, + id: Optional[str] = None, # pylint: disable=redefined-builtin resource_name: Optional[str] = None, resource_type: Optional[str] = None, **kwargs @@ -3038,13 +2862,13 @@ def __init__( :keyword resource_type: The type of the resource. :paramtype resource_type: str """ - super(TargetResource, self).__init__(**kwargs) + super().__init__(**kwargs) self.id = id self.resource_name = resource_name self.resource_type = resource_type -class TemplateHashResult(msrest.serialization.Model): +class TemplateHashResult(_serialization.Model): """Result of the request to calculate template hash. It contains a string of minified template and its hash. :ivar minified_template: The minified template string. @@ -3054,29 +2878,23 @@ class TemplateHashResult(msrest.serialization.Model): """ _attribute_map = { - 'minified_template': {'key': 'minifiedTemplate', 'type': 'str'}, - 'template_hash': {'key': 'templateHash', 'type': 'str'}, + "minified_template": {"key": "minifiedTemplate", "type": "str"}, + "template_hash": {"key": "templateHash", "type": "str"}, } - def __init__( - self, - *, - minified_template: Optional[str] = None, - template_hash: Optional[str] = None, - **kwargs - ): + def __init__(self, *, minified_template: Optional[str] = None, template_hash: Optional[str] = None, **kwargs): """ :keyword minified_template: The minified template string. :paramtype minified_template: str :keyword template_hash: The template hash. :paramtype template_hash: str """ - super(TemplateHashResult, self).__init__(**kwargs) + super().__init__(**kwargs) self.minified_template = minified_template self.template_hash = template_hash -class TemplateLink(msrest.serialization.Model): +class TemplateLink(_serialization.Model): """Entity representing the reference to the template. :ivar uri: The URI of the template to deploy. Use either the uri or id property, but not both. @@ -3091,17 +2909,17 @@ class TemplateLink(msrest.serialization.Model): """ _attribute_map = { - 'uri': {'key': 'uri', 'type': 'str'}, - 'id': {'key': 'id', 'type': 'str'}, - 'relative_path': {'key': 'relativePath', 'type': 'str'}, - 'content_version': {'key': 'contentVersion', 'type': 'str'}, + "uri": {"key": "uri", "type": "str"}, + "id": {"key": "id", "type": "str"}, + "relative_path": {"key": "relativePath", "type": "str"}, + "content_version": {"key": "contentVersion", "type": "str"}, } def __init__( self, *, uri: Optional[str] = None, - id: Optional[str] = None, + id: Optional[str] = None, # pylint: disable=redefined-builtin relative_path: Optional[str] = None, content_version: Optional[str] = None, **kwargs @@ -3119,70 +2937,70 @@ def __init__( :keyword content_version: If included, must match the ContentVersion in the template. :paramtype content_version: str """ - super(TemplateLink, self).__init__(**kwargs) + super().__init__(**kwargs) self.uri = uri self.id = id self.relative_path = relative_path self.content_version = content_version -class WhatIfChange(msrest.serialization.Model): +class WhatIfChange(_serialization.Model): """Information about a single resource change predicted by What-If operation. All required parameters must be populated in order to send to Azure. - :ivar resource_id: Required. Resource ID. + :ivar resource_id: Resource ID. Required. :vartype resource_id: str - :ivar change_type: Required. Type of change that will be made to the resource when the - deployment is executed. Possible values include: "Create", "Delete", "Ignore", "Deploy", - "NoChange", "Modify". + :ivar change_type: Type of change that will be made to the resource when the deployment is + executed. Required. Known values are: "Create", "Delete", "Ignore", "Deploy", "NoChange", and + "Modify". :vartype change_type: str or ~azure.mgmt.resource.resources.v2020_06_01.models.ChangeType :ivar before: The snapshot of the resource before the deployment is executed. - :vartype before: any + :vartype before: JSON :ivar after: The predicted snapshot of the resource after the deployment is executed. - :vartype after: any + :vartype after: JSON :ivar delta: The predicted changes to resource properties. :vartype delta: list[~azure.mgmt.resource.resources.v2020_06_01.models.WhatIfPropertyChange] """ _validation = { - 'resource_id': {'required': True}, - 'change_type': {'required': True}, + "resource_id": {"required": True}, + "change_type": {"required": True}, } _attribute_map = { - 'resource_id': {'key': 'resourceId', 'type': 'str'}, - 'change_type': {'key': 'changeType', 'type': 'str'}, - 'before': {'key': 'before', 'type': 'object'}, - 'after': {'key': 'after', 'type': 'object'}, - 'delta': {'key': 'delta', 'type': '[WhatIfPropertyChange]'}, + "resource_id": {"key": "resourceId", "type": "str"}, + "change_type": {"key": "changeType", "type": "str"}, + "before": {"key": "before", "type": "object"}, + "after": {"key": "after", "type": "object"}, + "delta": {"key": "delta", "type": "[WhatIfPropertyChange]"}, } def __init__( self, *, resource_id: str, - change_type: Union[str, "ChangeType"], - before: Optional[Any] = None, - after: Optional[Any] = None, - delta: Optional[List["WhatIfPropertyChange"]] = None, + change_type: Union[str, "_models.ChangeType"], + before: Optional[JSON] = None, + after: Optional[JSON] = None, + delta: Optional[List["_models.WhatIfPropertyChange"]] = None, **kwargs ): """ - :keyword resource_id: Required. Resource ID. + :keyword resource_id: Resource ID. Required. :paramtype resource_id: str - :keyword change_type: Required. Type of change that will be made to the resource when the - deployment is executed. Possible values include: "Create", "Delete", "Ignore", "Deploy", - "NoChange", "Modify". + :keyword change_type: Type of change that will be made to the resource when the deployment is + executed. Required. Known values are: "Create", "Delete", "Ignore", "Deploy", "NoChange", and + "Modify". :paramtype change_type: str or ~azure.mgmt.resource.resources.v2020_06_01.models.ChangeType :keyword before: The snapshot of the resource before the deployment is executed. - :paramtype before: any + :paramtype before: JSON :keyword after: The predicted snapshot of the resource after the deployment is executed. - :paramtype after: any + :paramtype after: JSON :keyword delta: The predicted changes to resource properties. :paramtype delta: list[~azure.mgmt.resource.resources.v2020_06_01.models.WhatIfPropertyChange] """ - super(WhatIfChange, self).__init__(**kwargs) + super().__init__(**kwargs) self.resource_id = resource_id self.change_type = change_type self.before = before @@ -3190,7 +3008,7 @@ def __init__( self.delta = delta -class WhatIfOperationResult(msrest.serialization.Model): +class WhatIfOperationResult(_serialization.Model): """Result of the What-If operation. Contains a list of predicted changes and a URL link to get to the next set of results. :ivar status: Status of the What-If operation. @@ -3202,17 +3020,17 @@ class WhatIfOperationResult(msrest.serialization.Model): """ _attribute_map = { - 'status': {'key': 'status', 'type': 'str'}, - 'error': {'key': 'error', 'type': 'ErrorResponse'}, - 'changes': {'key': 'properties.changes', 'type': '[WhatIfChange]'}, + "status": {"key": "status", "type": "str"}, + "error": {"key": "error", "type": "ErrorResponse"}, + "changes": {"key": "properties.changes", "type": "[WhatIfChange]"}, } def __init__( self, *, status: Optional[str] = None, - error: Optional["ErrorResponse"] = None, - changes: Optional[List["WhatIfChange"]] = None, + error: Optional["_models.ErrorResponse"] = None, + changes: Optional[List["_models.WhatIfChange"]] = None, **kwargs ): """ @@ -3223,70 +3041,70 @@ def __init__( :keyword changes: List of resource changes predicted by What-If operation. :paramtype changes: list[~azure.mgmt.resource.resources.v2020_06_01.models.WhatIfChange] """ - super(WhatIfOperationResult, self).__init__(**kwargs) + super().__init__(**kwargs) self.status = status self.error = error self.changes = changes -class WhatIfPropertyChange(msrest.serialization.Model): +class WhatIfPropertyChange(_serialization.Model): """The predicted change to the resource property. All required parameters must be populated in order to send to Azure. - :ivar path: Required. The path of the property. + :ivar path: The path of the property. Required. :vartype path: str - :ivar property_change_type: Required. The type of property change. Possible values include: - "Create", "Delete", "Modify", "Array". + :ivar property_change_type: The type of property change. Required. Known values are: "Create", + "Delete", "Modify", and "Array". :vartype property_change_type: str or ~azure.mgmt.resource.resources.v2020_06_01.models.PropertyChangeType :ivar before: The value of the property before the deployment is executed. - :vartype before: any + :vartype before: JSON :ivar after: The value of the property after the deployment is executed. - :vartype after: any + :vartype after: JSON :ivar children: Nested property changes. :vartype children: list[~azure.mgmt.resource.resources.v2020_06_01.models.WhatIfPropertyChange] """ _validation = { - 'path': {'required': True}, - 'property_change_type': {'required': True}, + "path": {"required": True}, + "property_change_type": {"required": True}, } _attribute_map = { - 'path': {'key': 'path', 'type': 'str'}, - 'property_change_type': {'key': 'propertyChangeType', 'type': 'str'}, - 'before': {'key': 'before', 'type': 'object'}, - 'after': {'key': 'after', 'type': 'object'}, - 'children': {'key': 'children', 'type': '[WhatIfPropertyChange]'}, + "path": {"key": "path", "type": "str"}, + "property_change_type": {"key": "propertyChangeType", "type": "str"}, + "before": {"key": "before", "type": "object"}, + "after": {"key": "after", "type": "object"}, + "children": {"key": "children", "type": "[WhatIfPropertyChange]"}, } def __init__( self, *, path: str, - property_change_type: Union[str, "PropertyChangeType"], - before: Optional[Any] = None, - after: Optional[Any] = None, - children: Optional[List["WhatIfPropertyChange"]] = None, + property_change_type: Union[str, "_models.PropertyChangeType"], + before: Optional[JSON] = None, + after: Optional[JSON] = None, + children: Optional[List["_models.WhatIfPropertyChange"]] = None, **kwargs ): """ - :keyword path: Required. The path of the property. + :keyword path: The path of the property. Required. :paramtype path: str - :keyword property_change_type: Required. The type of property change. Possible values include: - "Create", "Delete", "Modify", "Array". + :keyword property_change_type: The type of property change. Required. Known values are: + "Create", "Delete", "Modify", and "Array". :paramtype property_change_type: str or ~azure.mgmt.resource.resources.v2020_06_01.models.PropertyChangeType :keyword before: The value of the property before the deployment is executed. - :paramtype before: any + :paramtype before: JSON :keyword after: The value of the property after the deployment is executed. - :paramtype after: any + :paramtype after: JSON :keyword children: Nested property changes. :paramtype children: list[~azure.mgmt.resource.resources.v2020_06_01.models.WhatIfPropertyChange] """ - super(WhatIfPropertyChange, self).__init__(**kwargs) + super().__init__(**kwargs) self.path = path self.property_change_type = property_change_type self.before = before @@ -3294,7 +3112,7 @@ def __init__( self.children = children -class ZoneMapping(msrest.serialization.Model): +class ZoneMapping(_serialization.Model): """ZoneMapping. :ivar location: The location of the zone mapping. @@ -3304,23 +3122,17 @@ class ZoneMapping(msrest.serialization.Model): """ _attribute_map = { - 'location': {'key': 'location', 'type': 'str'}, - 'zones': {'key': 'zones', 'type': '[str]'}, + "location": {"key": "location", "type": "str"}, + "zones": {"key": "zones", "type": "[str]"}, } - def __init__( - self, - *, - location: Optional[str] = None, - zones: Optional[List[str]] = None, - **kwargs - ): + def __init__(self, *, location: Optional[str] = None, zones: Optional[List[str]] = None, **kwargs): """ :keyword location: The location of the zone mapping. :paramtype location: str :keyword zones: :paramtype zones: list[str] """ - super(ZoneMapping, self).__init__(**kwargs) + super().__init__(**kwargs) self.location = location self.zones = zones diff --git a/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/resources/v2020_06_01/models/_patch.py b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/resources/v2020_06_01/models/_patch.py new file mode 100644 index 0000000000000..f7dd32510333d --- /dev/null +++ b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/resources/v2020_06_01/models/_patch.py @@ -0,0 +1,20 @@ +# ------------------------------------ +# Copyright (c) Microsoft Corporation. +# Licensed under the MIT License. +# ------------------------------------ +"""Customize generated code here. + +Follow our quickstart for examples: https://aka.ms/azsdk/python/dpcodegen/python/customize +""" +from typing import List + +__all__: List[str] = [] # Add all objects you want publicly available to users at this package level + + +def patch_sdk(): + """Do not remove from this file. + + `patch_sdk` is a last resort escape hatch that allows you to do customizations + you can't accomplish using the techniques described in + https://aka.ms/azsdk/python/dpcodegen/python/customize + """ diff --git a/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/resources/v2020_06_01/models/_resource_management_client_enums.py b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/resources/v2020_06_01/models/_resource_management_client_enums.py index 795ece2e655ea..aa81cf76c98a6 100644 --- a/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/resources/v2020_06_01/models/_resource_management_client_enums.py +++ b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/resources/v2020_06_01/models/_resource_management_client_enums.py @@ -7,22 +7,20 @@ # -------------------------------------------------------------------------- from enum import Enum -from six import with_metaclass from azure.core import CaseInsensitiveEnumMeta -class AliasPathAttributes(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): - """The attributes of the token that the alias path is referring to. - """ +class AliasPathAttributes(str, Enum, metaclass=CaseInsensitiveEnumMeta): + """The attributes of the token that the alias path is referring to.""" #: The token that the alias path is referring to has no attributes. NONE = "None" #: The token that the alias path is referring to is modifiable by policies with 'modify' effect. MODIFIABLE = "Modifiable" -class AliasPathTokenType(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): - """The type of the token that the alias path is referring to. - """ + +class AliasPathTokenType(str, Enum, metaclass=CaseInsensitiveEnumMeta): + """The type of the token that the alias path is referring to.""" #: The token type is not specified. NOT_SPECIFIED = "NotSpecified" @@ -41,18 +39,18 @@ class AliasPathTokenType(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): #: The token type is boolean. BOOLEAN = "Boolean" -class AliasPatternType(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): - """The type of alias pattern - """ + +class AliasPatternType(str, Enum, metaclass=CaseInsensitiveEnumMeta): + """The type of alias pattern.""" #: NotSpecified is not allowed. NOT_SPECIFIED = "NotSpecified" #: Extract is the only allowed value. EXTRACT = "Extract" -class AliasType(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): - """The type of the alias. - """ + +class AliasType(str, Enum, metaclass=CaseInsensitiveEnumMeta): + """The type of the alias.""" #: Alias type is unknown (same as not providing alias type). NOT_SPECIFIED = "NotSpecified" @@ -61,9 +59,9 @@ class AliasType(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): #: Alias value is secret. MASK = "Mask" -class ChangeType(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): - """Type of change that will be made to the resource when the deployment is executed. - """ + +class ChangeType(str, Enum, metaclass=CaseInsensitiveEnumMeta): + """Type of change that will be made to the resource when the deployment is executed.""" #: The resource does not exist in the current state but is present in the desired state. The #: resource will be created when the deployment is executed. @@ -84,7 +82,8 @@ class ChangeType(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): #: deployment is executed. The properties of the resource will change. MODIFY = "Modify" -class DeploymentMode(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): + +class DeploymentMode(str, Enum, metaclass=CaseInsensitiveEnumMeta): """The mode that is used to deploy resources. This value can be either Incremental or Complete. In Incremental mode, resources are deployed without deleting existing resources that are not included in the template. In Complete mode, resources are deployed and existing resources in @@ -95,7 +94,8 @@ class DeploymentMode(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): INCREMENTAL = "Incremental" COMPLETE = "Complete" -class ExpressionEvaluationOptionsScopeType(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): + +class ExpressionEvaluationOptionsScopeType(str, Enum, metaclass=CaseInsensitiveEnumMeta): """The scope to be used for evaluation of parameters, variables and functions in a nested template. """ @@ -104,7 +104,8 @@ class ExpressionEvaluationOptionsScopeType(with_metaclass(CaseInsensitiveEnumMet OUTER = "Outer" INNER = "Inner" -class OnErrorDeploymentType(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): + +class OnErrorDeploymentType(str, Enum, metaclass=CaseInsensitiveEnumMeta): """The deployment on error behavior type. Possible values are LastSuccessful and SpecificDeployment. """ @@ -112,9 +113,9 @@ class OnErrorDeploymentType(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): LAST_SUCCESSFUL = "LastSuccessful" SPECIFIC_DEPLOYMENT = "SpecificDeployment" -class PropertyChangeType(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): - """The type of property change. - """ + +class PropertyChangeType(str, Enum, metaclass=CaseInsensitiveEnumMeta): + """The type of property change.""" #: The property does not exist in the current state but is present in the desired state. The #: property will be created when the deployment is executed. @@ -128,9 +129,9 @@ class PropertyChangeType(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): #: The property is an array and contains nested changes. ARRAY = "Array" -class ProvisioningOperation(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): - """The name of the current provisioning operation. - """ + +class ProvisioningOperation(str, Enum, metaclass=CaseInsensitiveEnumMeta): + """The name of the current provisioning operation.""" #: The provisioning operation is not specified. NOT_SPECIFIED = "NotSpecified" @@ -154,9 +155,9 @@ class ProvisioningOperation(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): #: deployment. DEPLOYMENT_CLEANUP = "DeploymentCleanup" -class ProvisioningState(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): - """Denotes the state of provisioning. - """ + +class ProvisioningState(str, Enum, metaclass=CaseInsensitiveEnumMeta): + """Denotes the state of provisioning.""" NOT_SPECIFIED = "NotSpecified" ACCEPTED = "Accepted" @@ -171,18 +172,18 @@ class ProvisioningState(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): SUCCEEDED = "Succeeded" UPDATING = "Updating" -class ResourceIdentityType(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): - """The identity type. - """ + +class ResourceIdentityType(str, Enum, metaclass=CaseInsensitiveEnumMeta): + """The identity type.""" SYSTEM_ASSIGNED = "SystemAssigned" USER_ASSIGNED = "UserAssigned" SYSTEM_ASSIGNED_USER_ASSIGNED = "SystemAssigned, UserAssigned" NONE = "None" -class TagsPatchOperation(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): - """The operation type for the patch API. - """ + +class TagsPatchOperation(str, Enum, metaclass=CaseInsensitiveEnumMeta): + """The operation type for the patch API.""" #: The 'replace' option replaces the entire set of existing tags with a new set. REPLACE = "Replace" @@ -192,9 +193,9 @@ class TagsPatchOperation(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): #: The 'delete' option allows selectively deleting tags based on given names or name/value pairs. DELETE = "Delete" -class WhatIfResultFormat(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): - """The format of the What-If results - """ + +class WhatIfResultFormat(str, Enum, metaclass=CaseInsensitiveEnumMeta): + """The format of the What-If results.""" RESOURCE_ID_ONLY = "ResourceIdOnly" FULL_RESOURCE_PAYLOADS = "FullResourcePayloads" diff --git a/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/resources/v2020_06_01/operations/__init__.py b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/resources/v2020_06_01/operations/__init__.py index 53876d82bf5d7..804fee65e3137 100644 --- a/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/resources/v2020_06_01/operations/__init__.py +++ b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/resources/v2020_06_01/operations/__init__.py @@ -14,12 +14,18 @@ from ._operations import TagsOperations from ._operations import DeploymentOperationsOperations +from ._patch import __all__ as _patch_all +from ._patch import * # type: ignore # pylint: disable=unused-wildcard-import +from ._patch import patch_sdk as _patch_sdk + __all__ = [ - 'Operations', - 'DeploymentsOperations', - 'ProvidersOperations', - 'ResourcesOperations', - 'ResourceGroupsOperations', - 'TagsOperations', - 'DeploymentOperationsOperations', + "Operations", + "DeploymentsOperations", + "ProvidersOperations", + "ResourcesOperations", + "ResourceGroupsOperations", + "TagsOperations", + "DeploymentOperationsOperations", ] +__all__.extend([p for p in _patch_all if p not in __all__]) +_patch_sdk() diff --git a/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/resources/v2020_06_01/operations/_operations.py b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/resources/v2020_06_01/operations/_operations.py index 7f4a993020671..499479a47a18b 100644 --- a/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/resources/v2020_06_01/operations/_operations.py +++ b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/resources/v2020_06_01/operations/_operations.py @@ -6,1641 +6,1330 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -from typing import Any, Callable, Dict, Iterable, Optional, TypeVar, Union - -from msrest import Serializer - -from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error +import sys +from typing import Any, Callable, Dict, IO, Iterable, Optional, TypeVar, Union, cast, overload +from urllib.parse import parse_qs, urljoin, urlparse + +from azure.core.exceptions import ( + ClientAuthenticationError, + HttpResponseError, + ResourceExistsError, + ResourceNotFoundError, + ResourceNotModifiedError, + map_error, +) from azure.core.paging import ItemPaged from azure.core.pipeline import PipelineResponse from azure.core.pipeline.transport import HttpResponse from azure.core.polling import LROPoller, NoPolling, PollingMethod from azure.core.rest import HttpRequest from azure.core.tracing.decorator import distributed_trace +from azure.core.utils import case_insensitive_dict from azure.mgmt.core.exceptions import ARMErrorFormat from azure.mgmt.core.polling.arm_polling import ARMPolling from .. import models as _models +from ..._serialization import Serializer from .._vendor import _convert_request, _format_url_section -T = TypeVar('T') + +T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] -JSONType = Any +if sys.version_info >= (3, 9): + from collections.abc import MutableMapping +else: + from typing import MutableMapping # type: ignore # pylint: disable=ungrouped-imports +JSON = MutableMapping[str, Any] # pylint: disable=unsubscriptable-object _SERIALIZER = Serializer() _SERIALIZER.client_side_validation = False -def build_operations_list_request( - **kwargs: Any -) -> HttpRequest: - api_version = kwargs.pop('api_version', "2020-06-01") # type: str - accept = "application/json" +def build_operations_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", "2020-06-01")) # type: str + accept = _headers.pop("Accept", "application/json") + # Construct URL _url = kwargs.pop("template_url", "/providers/Microsoft.Resources/operations") # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') - - return HttpRequest( - method="GET", - url=_url, - params=_query_parameters, - headers=_header_parameters, - **kwargs - ) + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) -def build_deployments_delete_at_scope_request_initial( - scope: str, - deployment_name: str, - **kwargs: Any -) -> HttpRequest: - api_version = kwargs.pop('api_version', "2020-06-01") # type: str - accept = "application/json" +def build_deployments_delete_at_scope_request(scope: str, deployment_name: 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", "2020-06-01")) # type: str + accept = _headers.pop("Accept", "application/json") + # Construct URL _url = kwargs.pop("template_url", "/{scope}/providers/Microsoft.Resources/deployments/{deploymentName}") path_format_arguments = { - "scope": _SERIALIZER.url("scope", scope, 'str', skip_quote=True), - "deploymentName": _SERIALIZER.url("deployment_name", deployment_name, 'str', max_length=64, min_length=1), + "scope": _SERIALIZER.url("scope", scope, "str", skip_quote=True), + "deploymentName": _SERIALIZER.url("deployment_name", deployment_name, "str", max_length=64, min_length=1), } _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') - - return HttpRequest( - method="DELETE", - url=_url, - params=_query_parameters, - headers=_header_parameters, - **kwargs - ) + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + return HttpRequest(method="DELETE", url=_url, params=_params, headers=_headers, **kwargs) -def build_deployments_check_existence_at_scope_request( - scope: str, - deployment_name: str, - **kwargs: Any -) -> HttpRequest: - api_version = kwargs.pop('api_version', "2020-06-01") # type: str - accept = "application/json" +def build_deployments_check_existence_at_scope_request(scope: str, deployment_name: 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", "2020-06-01")) # type: str + accept = _headers.pop("Accept", "application/json") + # Construct URL _url = kwargs.pop("template_url", "/{scope}/providers/Microsoft.Resources/deployments/{deploymentName}") path_format_arguments = { - "scope": _SERIALIZER.url("scope", scope, 'str', skip_quote=True), - "deploymentName": _SERIALIZER.url("deployment_name", deployment_name, 'str', max_length=64, min_length=1), + "scope": _SERIALIZER.url("scope", scope, "str", skip_quote=True), + "deploymentName": _SERIALIZER.url("deployment_name", deployment_name, "str", max_length=64, min_length=1), } _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') - - return HttpRequest( - method="HEAD", - url=_url, - params=_query_parameters, - headers=_header_parameters, - **kwargs - ) + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + return HttpRequest(method="HEAD", url=_url, params=_params, headers=_headers, **kwargs) -def build_deployments_create_or_update_at_scope_request_initial( - scope: str, - deployment_name: str, - *, - json: JSONType = None, - content: Any = None, - **kwargs: Any -) -> HttpRequest: - api_version = kwargs.pop('api_version', "2020-06-01") # type: str - content_type = kwargs.pop('content_type', None) # type: Optional[str] - accept = "application/json" +def build_deployments_create_or_update_at_scope_request(scope: str, deployment_name: 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", "2020-06-01")) # type: str + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + accept = _headers.pop("Accept", "application/json") + # Construct URL _url = kwargs.pop("template_url", "/{scope}/providers/Microsoft.Resources/deployments/{deploymentName}") path_format_arguments = { - "scope": _SERIALIZER.url("scope", scope, 'str', skip_quote=True), - "deploymentName": _SERIALIZER.url("deployment_name", deployment_name, 'str', max_length=64, min_length=1), + "scope": _SERIALIZER.url("scope", scope, "str", skip_quote=True), + "deploymentName": _SERIALIZER.url("deployment_name", deployment_name, "str", max_length=64, min_length=1), } _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] if content_type is not None: - _header_parameters['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') - _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') - - return HttpRequest( - method="PUT", - url=_url, - params=_query_parameters, - headers=_header_parameters, - json=json, - content=content, - **kwargs - ) + _headers["Content-Type"] = _SERIALIZER.header("content_type", content_type, "str") + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + return HttpRequest(method="PUT", url=_url, params=_params, headers=_headers, **kwargs) -def build_deployments_get_at_scope_request( - scope: str, - deployment_name: str, - **kwargs: Any -) -> HttpRequest: - api_version = kwargs.pop('api_version', "2020-06-01") # type: str - accept = "application/json" +def build_deployments_get_at_scope_request(scope: str, deployment_name: 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", "2020-06-01")) # type: str + accept = _headers.pop("Accept", "application/json") + # Construct URL _url = kwargs.pop("template_url", "/{scope}/providers/Microsoft.Resources/deployments/{deploymentName}") path_format_arguments = { - "scope": _SERIALIZER.url("scope", scope, 'str', skip_quote=True), - "deploymentName": _SERIALIZER.url("deployment_name", deployment_name, 'str', max_length=64, min_length=1), + "scope": _SERIALIZER.url("scope", scope, "str", skip_quote=True), + "deploymentName": _SERIALIZER.url("deployment_name", deployment_name, "str", max_length=64, min_length=1), } _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') - - return HttpRequest( - method="GET", - url=_url, - params=_query_parameters, - headers=_header_parameters, - **kwargs - ) + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) -def build_deployments_cancel_at_scope_request( - scope: str, - deployment_name: str, - **kwargs: Any -) -> HttpRequest: - api_version = kwargs.pop('api_version', "2020-06-01") # type: str - accept = "application/json" +def build_deployments_cancel_at_scope_request(scope: str, deployment_name: 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", "2020-06-01")) # type: str + accept = _headers.pop("Accept", "application/json") + # Construct URL _url = kwargs.pop("template_url", "/{scope}/providers/Microsoft.Resources/deployments/{deploymentName}/cancel") path_format_arguments = { - "scope": _SERIALIZER.url("scope", scope, 'str', skip_quote=True), - "deploymentName": _SERIALIZER.url("deployment_name", deployment_name, 'str', max_length=64, min_length=1), + "scope": _SERIALIZER.url("scope", scope, "str", skip_quote=True), + "deploymentName": _SERIALIZER.url("deployment_name", deployment_name, "str", max_length=64, min_length=1), } _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') - - return HttpRequest( - method="POST", - url=_url, - params=_query_parameters, - headers=_header_parameters, - **kwargs - ) + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + return HttpRequest(method="POST", url=_url, params=_params, headers=_headers, **kwargs) -def build_deployments_validate_at_scope_request_initial( - scope: str, - deployment_name: str, - *, - json: JSONType = None, - content: Any = None, - **kwargs: Any -) -> HttpRequest: - api_version = kwargs.pop('api_version', "2020-06-01") # type: str - content_type = kwargs.pop('content_type', None) # type: Optional[str] - accept = "application/json" +def build_deployments_validate_at_scope_request(scope: str, deployment_name: 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", "2020-06-01")) # type: str + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + accept = _headers.pop("Accept", "application/json") + # Construct URL _url = kwargs.pop("template_url", "/{scope}/providers/Microsoft.Resources/deployments/{deploymentName}/validate") path_format_arguments = { - "scope": _SERIALIZER.url("scope", scope, 'str', skip_quote=True), - "deploymentName": _SERIALIZER.url("deployment_name", deployment_name, 'str', max_length=64, min_length=1), + "scope": _SERIALIZER.url("scope", scope, "str", skip_quote=True), + "deploymentName": _SERIALIZER.url("deployment_name", deployment_name, "str", max_length=64, min_length=1), } _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] if content_type is not None: - _header_parameters['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') - _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') - - return HttpRequest( - method="POST", - url=_url, - params=_query_parameters, - headers=_header_parameters, - json=json, - content=content, - **kwargs - ) + _headers["Content-Type"] = _SERIALIZER.header("content_type", content_type, "str") + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + return HttpRequest(method="POST", url=_url, params=_params, headers=_headers, **kwargs) -def build_deployments_export_template_at_scope_request( - scope: str, - deployment_name: str, - **kwargs: Any -) -> HttpRequest: - api_version = kwargs.pop('api_version', "2020-06-01") # type: str - accept = "application/json" +def build_deployments_export_template_at_scope_request(scope: str, deployment_name: 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", "2020-06-01")) # type: str + accept = _headers.pop("Accept", "application/json") + # Construct URL - _url = kwargs.pop("template_url", "/{scope}/providers/Microsoft.Resources/deployments/{deploymentName}/exportTemplate") + _url = kwargs.pop( + "template_url", "/{scope}/providers/Microsoft.Resources/deployments/{deploymentName}/exportTemplate" + ) path_format_arguments = { - "scope": _SERIALIZER.url("scope", scope, 'str', skip_quote=True), - "deploymentName": _SERIALIZER.url("deployment_name", deployment_name, 'str', max_length=64, min_length=1), + "scope": _SERIALIZER.url("scope", scope, "str", skip_quote=True), + "deploymentName": _SERIALIZER.url("deployment_name", deployment_name, "str", max_length=64, min_length=1), } _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') - - return HttpRequest( - method="POST", - url=_url, - params=_query_parameters, - headers=_header_parameters, - **kwargs - ) + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="POST", url=_url, params=_params, headers=_headers, **kwargs) def build_deployments_list_at_scope_request( - scope: str, - *, - filter: Optional[str] = None, - top: Optional[int] = None, - **kwargs: Any + scope: str, *, filter: Optional[str] = None, top: Optional[int] = None, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2020-06-01") # type: 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", "2020-06-01")) # type: str + accept = _headers.pop("Accept", "application/json") - accept = "application/json" # Construct URL _url = kwargs.pop("template_url", "/{scope}/providers/Microsoft.Resources/deployments/") path_format_arguments = { - "scope": _SERIALIZER.url("scope", scope, 'str', skip_quote=True), + "scope": _SERIALIZER.url("scope", scope, "str", skip_quote=True), } _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] if filter is not None: - _query_parameters['$filter'] = _SERIALIZER.query("filter", filter, 'str') + _params["$filter"] = _SERIALIZER.query("filter", filter, "str") if top is not None: - _query_parameters['$top'] = _SERIALIZER.query("top", top, 'int') - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["$top"] = _SERIALIZER.query("top", top, "int") + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') - - return HttpRequest( - method="GET", - url=_url, - params=_query_parameters, - headers=_header_parameters, - **kwargs - ) + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) -def build_deployments_delete_at_tenant_scope_request_initial( - deployment_name: str, - **kwargs: Any -) -> HttpRequest: - api_version = kwargs.pop('api_version', "2020-06-01") # type: str - accept = "application/json" +def build_deployments_delete_at_tenant_scope_request(deployment_name: 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", "2020-06-01")) # type: str + accept = _headers.pop("Accept", "application/json") + # Construct URL _url = kwargs.pop("template_url", "/providers/Microsoft.Resources/deployments/{deploymentName}") path_format_arguments = { - "deploymentName": _SERIALIZER.url("deployment_name", deployment_name, 'str', max_length=64, min_length=1), + "deploymentName": _SERIALIZER.url("deployment_name", deployment_name, "str", max_length=64, min_length=1), } _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') - - return HttpRequest( - method="DELETE", - url=_url, - params=_query_parameters, - headers=_header_parameters, - **kwargs - ) + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + return HttpRequest(method="DELETE", url=_url, params=_params, headers=_headers, **kwargs) -def build_deployments_check_existence_at_tenant_scope_request( - deployment_name: str, - **kwargs: Any -) -> HttpRequest: - api_version = kwargs.pop('api_version', "2020-06-01") # type: str - accept = "application/json" +def build_deployments_check_existence_at_tenant_scope_request(deployment_name: 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", "2020-06-01")) # type: str + accept = _headers.pop("Accept", "application/json") + # Construct URL _url = kwargs.pop("template_url", "/providers/Microsoft.Resources/deployments/{deploymentName}") path_format_arguments = { - "deploymentName": _SERIALIZER.url("deployment_name", deployment_name, 'str', max_length=64, min_length=1), + "deploymentName": _SERIALIZER.url("deployment_name", deployment_name, "str", max_length=64, min_length=1), } _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') - - return HttpRequest( - method="HEAD", - url=_url, - params=_query_parameters, - headers=_header_parameters, - **kwargs - ) + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + return HttpRequest(method="HEAD", url=_url, params=_params, headers=_headers, **kwargs) -def build_deployments_create_or_update_at_tenant_scope_request_initial( - deployment_name: str, - *, - json: JSONType = None, - content: Any = None, - **kwargs: Any -) -> HttpRequest: - api_version = kwargs.pop('api_version', "2020-06-01") # type: str - content_type = kwargs.pop('content_type', None) # type: Optional[str] - accept = "application/json" +def build_deployments_create_or_update_at_tenant_scope_request(deployment_name: 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", "2020-06-01")) # type: str + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + accept = _headers.pop("Accept", "application/json") + # Construct URL _url = kwargs.pop("template_url", "/providers/Microsoft.Resources/deployments/{deploymentName}") path_format_arguments = { - "deploymentName": _SERIALIZER.url("deployment_name", deployment_name, 'str', max_length=64, min_length=1), + "deploymentName": _SERIALIZER.url("deployment_name", deployment_name, "str", max_length=64, min_length=1), } _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] if content_type is not None: - _header_parameters['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') - _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') - - return HttpRequest( - method="PUT", - url=_url, - params=_query_parameters, - headers=_header_parameters, - json=json, - content=content, - **kwargs - ) + _headers["Content-Type"] = _SERIALIZER.header("content_type", content_type, "str") + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + return HttpRequest(method="PUT", url=_url, params=_params, headers=_headers, **kwargs) -def build_deployments_get_at_tenant_scope_request( - deployment_name: str, - **kwargs: Any -) -> HttpRequest: - api_version = kwargs.pop('api_version', "2020-06-01") # type: str - accept = "application/json" +def build_deployments_get_at_tenant_scope_request(deployment_name: 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", "2020-06-01")) # type: str + accept = _headers.pop("Accept", "application/json") + # Construct URL _url = kwargs.pop("template_url", "/providers/Microsoft.Resources/deployments/{deploymentName}") path_format_arguments = { - "deploymentName": _SERIALIZER.url("deployment_name", deployment_name, 'str', max_length=64, min_length=1), + "deploymentName": _SERIALIZER.url("deployment_name", deployment_name, "str", max_length=64, min_length=1), } _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') - - return HttpRequest( - method="GET", - url=_url, - params=_query_parameters, - headers=_header_parameters, - **kwargs - ) + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) -def build_deployments_cancel_at_tenant_scope_request( - deployment_name: str, - **kwargs: Any -) -> HttpRequest: - api_version = kwargs.pop('api_version', "2020-06-01") # type: str - accept = "application/json" +def build_deployments_cancel_at_tenant_scope_request(deployment_name: 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", "2020-06-01")) # type: str + accept = _headers.pop("Accept", "application/json") + # Construct URL _url = kwargs.pop("template_url", "/providers/Microsoft.Resources/deployments/{deploymentName}/cancel") path_format_arguments = { - "deploymentName": _SERIALIZER.url("deployment_name", deployment_name, 'str', max_length=64, min_length=1), + "deploymentName": _SERIALIZER.url("deployment_name", deployment_name, "str", max_length=64, min_length=1), } _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') - - return HttpRequest( - method="POST", - url=_url, - params=_query_parameters, - headers=_header_parameters, - **kwargs - ) + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + return HttpRequest(method="POST", url=_url, params=_params, headers=_headers, **kwargs) -def build_deployments_validate_at_tenant_scope_request_initial( - deployment_name: str, - *, - json: JSONType = None, - content: Any = None, - **kwargs: Any -) -> HttpRequest: - api_version = kwargs.pop('api_version', "2020-06-01") # type: str - content_type = kwargs.pop('content_type', None) # type: Optional[str] - accept = "application/json" +def build_deployments_validate_at_tenant_scope_request(deployment_name: 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", "2020-06-01")) # type: str + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + accept = _headers.pop("Accept", "application/json") + # Construct URL _url = kwargs.pop("template_url", "/providers/Microsoft.Resources/deployments/{deploymentName}/validate") path_format_arguments = { - "deploymentName": _SERIALIZER.url("deployment_name", deployment_name, 'str', max_length=64, min_length=1), + "deploymentName": _SERIALIZER.url("deployment_name", deployment_name, "str", max_length=64, min_length=1), } _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] if content_type is not None: - _header_parameters['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') - _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') - - return HttpRequest( - method="POST", - url=_url, - params=_query_parameters, - headers=_header_parameters, - json=json, - content=content, - **kwargs - ) + _headers["Content-Type"] = _SERIALIZER.header("content_type", content_type, "str") + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + return HttpRequest(method="POST", url=_url, params=_params, headers=_headers, **kwargs) -def build_deployments_what_if_at_tenant_scope_request_initial( - deployment_name: str, - *, - json: JSONType = None, - content: Any = None, - **kwargs: Any -) -> HttpRequest: - api_version = kwargs.pop('api_version', "2020-06-01") # type: str - content_type = kwargs.pop('content_type', None) # type: Optional[str] - accept = "application/json" +def build_deployments_what_if_at_tenant_scope_request(deployment_name: 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", "2020-06-01")) # type: str + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + accept = _headers.pop("Accept", "application/json") + # Construct URL _url = kwargs.pop("template_url", "/providers/Microsoft.Resources/deployments/{deploymentName}/whatIf") path_format_arguments = { - "deploymentName": _SERIALIZER.url("deployment_name", deployment_name, 'str', max_length=64, min_length=1), + "deploymentName": _SERIALIZER.url("deployment_name", deployment_name, "str", max_length=64, min_length=1), } _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] if content_type is not None: - _header_parameters['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') - _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') - - return HttpRequest( - method="POST", - url=_url, - params=_query_parameters, - headers=_header_parameters, - json=json, - content=content, - **kwargs - ) + _headers["Content-Type"] = _SERIALIZER.header("content_type", content_type, "str") + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + return HttpRequest(method="POST", url=_url, params=_params, headers=_headers, **kwargs) -def build_deployments_export_template_at_tenant_scope_request( - deployment_name: str, - **kwargs: Any -) -> HttpRequest: - api_version = kwargs.pop('api_version', "2020-06-01") # type: str - accept = "application/json" +def build_deployments_export_template_at_tenant_scope_request(deployment_name: 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", "2020-06-01")) # type: str + accept = _headers.pop("Accept", "application/json") + # Construct URL _url = kwargs.pop("template_url", "/providers/Microsoft.Resources/deployments/{deploymentName}/exportTemplate") path_format_arguments = { - "deploymentName": _SERIALIZER.url("deployment_name", deployment_name, 'str', max_length=64, min_length=1), + "deploymentName": _SERIALIZER.url("deployment_name", deployment_name, "str", max_length=64, min_length=1), } _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') - - return HttpRequest( - method="POST", - url=_url, - params=_query_parameters, - headers=_header_parameters, - **kwargs - ) + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="POST", url=_url, params=_params, headers=_headers, **kwargs) def build_deployments_list_at_tenant_scope_request( - *, - filter: Optional[str] = None, - top: Optional[int] = None, - **kwargs: Any + *, filter: Optional[str] = None, top: Optional[int] = None, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2020-06-01") # type: 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", "2020-06-01")) # type: str + accept = _headers.pop("Accept", "application/json") - accept = "application/json" # Construct URL _url = kwargs.pop("template_url", "/providers/Microsoft.Resources/deployments/") # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] if filter is not None: - _query_parameters['$filter'] = _SERIALIZER.query("filter", filter, 'str') + _params["$filter"] = _SERIALIZER.query("filter", filter, "str") if top is not None: - _query_parameters['$top'] = _SERIALIZER.query("top", top, 'int') - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["$top"] = _SERIALIZER.query("top", top, "int") + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') - - return HttpRequest( - method="GET", - url=_url, - params=_query_parameters, - headers=_header_parameters, - **kwargs - ) + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) -def build_deployments_delete_at_management_group_scope_request_initial( - group_id: str, - deployment_name: str, - **kwargs: Any + +def build_deployments_delete_at_management_group_scope_request( + group_id: str, deployment_name: str, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2020-06-01") # type: 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", "2020-06-01")) # type: str + accept = _headers.pop("Accept", "application/json") - accept = "application/json" # Construct URL - _url = kwargs.pop("template_url", "/providers/Microsoft.Management/managementGroups/{groupId}/providers/Microsoft.Resources/deployments/{deploymentName}") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", + "/providers/Microsoft.Management/managementGroups/{groupId}/providers/Microsoft.Resources/deployments/{deploymentName}", + ) # pylint: disable=line-too-long path_format_arguments = { - "groupId": _SERIALIZER.url("group_id", group_id, 'str', max_length=90, min_length=1), - "deploymentName": _SERIALIZER.url("deployment_name", deployment_name, 'str', max_length=64, min_length=1), + "groupId": _SERIALIZER.url("group_id", group_id, "str", max_length=90, min_length=1), + "deploymentName": _SERIALIZER.url("deployment_name", deployment_name, "str", max_length=64, min_length=1), } _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') - - return HttpRequest( - method="DELETE", - url=_url, - params=_query_parameters, - headers=_header_parameters, - **kwargs - ) + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="DELETE", url=_url, params=_params, headers=_headers, **kwargs) def build_deployments_check_existence_at_management_group_scope_request( - group_id: str, - deployment_name: str, - **kwargs: Any + group_id: str, deployment_name: str, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2020-06-01") # type: 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", "2020-06-01")) # type: str + accept = _headers.pop("Accept", "application/json") - accept = "application/json" # Construct URL - _url = kwargs.pop("template_url", "/providers/Microsoft.Management/managementGroups/{groupId}/providers/Microsoft.Resources/deployments/{deploymentName}") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", + "/providers/Microsoft.Management/managementGroups/{groupId}/providers/Microsoft.Resources/deployments/{deploymentName}", + ) # pylint: disable=line-too-long path_format_arguments = { - "groupId": _SERIALIZER.url("group_id", group_id, 'str', max_length=90, min_length=1), - "deploymentName": _SERIALIZER.url("deployment_name", deployment_name, 'str', max_length=64, min_length=1), + "groupId": _SERIALIZER.url("group_id", group_id, "str", max_length=90, min_length=1), + "deploymentName": _SERIALIZER.url("deployment_name", deployment_name, "str", max_length=64, min_length=1), } _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') - - return HttpRequest( - method="HEAD", - url=_url, - params=_query_parameters, - headers=_header_parameters, - **kwargs - ) + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + return HttpRequest(method="HEAD", url=_url, params=_params, headers=_headers, **kwargs) -def build_deployments_create_or_update_at_management_group_scope_request_initial( - group_id: str, - deployment_name: str, - *, - json: JSONType = None, - content: Any = None, - **kwargs: Any + +def build_deployments_create_or_update_at_management_group_scope_request( + group_id: str, deployment_name: str, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2020-06-01") # type: str - content_type = kwargs.pop('content_type', None) # type: Optional[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", "2020-06-01")) # type: str + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + accept = _headers.pop("Accept", "application/json") - accept = "application/json" # Construct URL - _url = kwargs.pop("template_url", "/providers/Microsoft.Management/managementGroups/{groupId}/providers/Microsoft.Resources/deployments/{deploymentName}") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", + "/providers/Microsoft.Management/managementGroups/{groupId}/providers/Microsoft.Resources/deployments/{deploymentName}", + ) # pylint: disable=line-too-long path_format_arguments = { - "groupId": _SERIALIZER.url("group_id", group_id, 'str', max_length=90, min_length=1), - "deploymentName": _SERIALIZER.url("deployment_name", deployment_name, 'str', max_length=64, min_length=1), + "groupId": _SERIALIZER.url("group_id", group_id, "str", max_length=90, min_length=1), + "deploymentName": _SERIALIZER.url("deployment_name", deployment_name, "str", max_length=64, min_length=1), } _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] if content_type is not None: - _header_parameters['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') - _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') - - return HttpRequest( - method="PUT", - url=_url, - params=_query_parameters, - headers=_header_parameters, - json=json, - content=content, - **kwargs - ) + _headers["Content-Type"] = _SERIALIZER.header("content_type", content_type, "str") + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="PUT", url=_url, params=_params, headers=_headers, **kwargs) def build_deployments_get_at_management_group_scope_request( - group_id: str, - deployment_name: str, - **kwargs: Any + group_id: str, deployment_name: str, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2020-06-01") # type: 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", "2020-06-01")) # type: str + accept = _headers.pop("Accept", "application/json") - accept = "application/json" # Construct URL - _url = kwargs.pop("template_url", "/providers/Microsoft.Management/managementGroups/{groupId}/providers/Microsoft.Resources/deployments/{deploymentName}") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", + "/providers/Microsoft.Management/managementGroups/{groupId}/providers/Microsoft.Resources/deployments/{deploymentName}", + ) # pylint: disable=line-too-long path_format_arguments = { - "groupId": _SERIALIZER.url("group_id", group_id, 'str', max_length=90, min_length=1), - "deploymentName": _SERIALIZER.url("deployment_name", deployment_name, 'str', max_length=64, min_length=1), + "groupId": _SERIALIZER.url("group_id", group_id, "str", max_length=90, min_length=1), + "deploymentName": _SERIALIZER.url("deployment_name", deployment_name, "str", max_length=64, min_length=1), } _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') - - return HttpRequest( - method="GET", - url=_url, - params=_query_parameters, - headers=_header_parameters, - **kwargs - ) + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) def build_deployments_cancel_at_management_group_scope_request( - group_id: str, - deployment_name: str, - **kwargs: Any + group_id: str, deployment_name: str, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2020-06-01") # type: 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", "2020-06-01")) # type: str + accept = _headers.pop("Accept", "application/json") - accept = "application/json" # Construct URL - _url = kwargs.pop("template_url", "/providers/Microsoft.Management/managementGroups/{groupId}/providers/Microsoft.Resources/deployments/{deploymentName}/cancel") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", + "/providers/Microsoft.Management/managementGroups/{groupId}/providers/Microsoft.Resources/deployments/{deploymentName}/cancel", + ) # pylint: disable=line-too-long path_format_arguments = { - "groupId": _SERIALIZER.url("group_id", group_id, 'str', max_length=90, min_length=1), - "deploymentName": _SERIALIZER.url("deployment_name", deployment_name, 'str', max_length=64, min_length=1), + "groupId": _SERIALIZER.url("group_id", group_id, "str", max_length=90, min_length=1), + "deploymentName": _SERIALIZER.url("deployment_name", deployment_name, "str", max_length=64, min_length=1), } _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') - - return HttpRequest( - method="POST", - url=_url, - params=_query_parameters, - headers=_header_parameters, - **kwargs - ) + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + return HttpRequest(method="POST", url=_url, params=_params, headers=_headers, **kwargs) -def build_deployments_validate_at_management_group_scope_request_initial( - group_id: str, - deployment_name: str, - *, - json: JSONType = None, - content: Any = None, - **kwargs: Any + +def build_deployments_validate_at_management_group_scope_request( + group_id: str, deployment_name: str, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2020-06-01") # type: str - content_type = kwargs.pop('content_type', None) # type: Optional[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", "2020-06-01")) # type: str + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + accept = _headers.pop("Accept", "application/json") - accept = "application/json" # Construct URL - _url = kwargs.pop("template_url", "/providers/Microsoft.Management/managementGroups/{groupId}/providers/Microsoft.Resources/deployments/{deploymentName}/validate") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", + "/providers/Microsoft.Management/managementGroups/{groupId}/providers/Microsoft.Resources/deployments/{deploymentName}/validate", + ) # pylint: disable=line-too-long path_format_arguments = { - "groupId": _SERIALIZER.url("group_id", group_id, 'str', max_length=90, min_length=1), - "deploymentName": _SERIALIZER.url("deployment_name", deployment_name, 'str', max_length=64, min_length=1), + "groupId": _SERIALIZER.url("group_id", group_id, "str", max_length=90, min_length=1), + "deploymentName": _SERIALIZER.url("deployment_name", deployment_name, "str", max_length=64, min_length=1), } _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] if content_type is not None: - _header_parameters['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') - _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') - - return HttpRequest( - method="POST", - url=_url, - params=_query_parameters, - headers=_header_parameters, - json=json, - content=content, - **kwargs - ) + _headers["Content-Type"] = _SERIALIZER.header("content_type", content_type, "str") + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + return HttpRequest(method="POST", url=_url, params=_params, headers=_headers, **kwargs) -def build_deployments_what_if_at_management_group_scope_request_initial( - group_id: str, - deployment_name: str, - *, - json: JSONType = None, - content: Any = None, - **kwargs: Any + +def build_deployments_what_if_at_management_group_scope_request( + group_id: str, deployment_name: str, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2020-06-01") # type: str - content_type = kwargs.pop('content_type', None) # type: Optional[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", "2020-06-01")) # type: str + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + accept = _headers.pop("Accept", "application/json") - accept = "application/json" # Construct URL - _url = kwargs.pop("template_url", "/providers/Microsoft.Management/managementGroups/{groupId}/providers/Microsoft.Resources/deployments/{deploymentName}/whatIf") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", + "/providers/Microsoft.Management/managementGroups/{groupId}/providers/Microsoft.Resources/deployments/{deploymentName}/whatIf", + ) # pylint: disable=line-too-long path_format_arguments = { - "groupId": _SERIALIZER.url("group_id", group_id, 'str', max_length=90, min_length=1), - "deploymentName": _SERIALIZER.url("deployment_name", deployment_name, 'str', max_length=64, min_length=1), + "groupId": _SERIALIZER.url("group_id", group_id, "str", max_length=90, min_length=1), + "deploymentName": _SERIALIZER.url("deployment_name", deployment_name, "str", max_length=64, min_length=1), } _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] if content_type is not None: - _header_parameters['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') - _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') - - return HttpRequest( - method="POST", - url=_url, - params=_query_parameters, - headers=_header_parameters, - json=json, - content=content, - **kwargs - ) + _headers["Content-Type"] = _SERIALIZER.header("content_type", content_type, "str") + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="POST", url=_url, params=_params, headers=_headers, **kwargs) def build_deployments_export_template_at_management_group_scope_request( - group_id: str, - deployment_name: str, - **kwargs: Any + group_id: str, deployment_name: str, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2020-06-01") # type: 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", "2020-06-01")) # type: str + accept = _headers.pop("Accept", "application/json") - accept = "application/json" # Construct URL - _url = kwargs.pop("template_url", "/providers/Microsoft.Management/managementGroups/{groupId}/providers/Microsoft.Resources/deployments/{deploymentName}/exportTemplate") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", + "/providers/Microsoft.Management/managementGroups/{groupId}/providers/Microsoft.Resources/deployments/{deploymentName}/exportTemplate", + ) # pylint: disable=line-too-long path_format_arguments = { - "groupId": _SERIALIZER.url("group_id", group_id, 'str', max_length=90, min_length=1), - "deploymentName": _SERIALIZER.url("deployment_name", deployment_name, 'str', max_length=64, min_length=1), + "groupId": _SERIALIZER.url("group_id", group_id, "str", max_length=90, min_length=1), + "deploymentName": _SERIALIZER.url("deployment_name", deployment_name, "str", max_length=64, min_length=1), } _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') - - return HttpRequest( - method="POST", - url=_url, - params=_query_parameters, - headers=_header_parameters, - **kwargs - ) + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="POST", url=_url, params=_params, headers=_headers, **kwargs) def build_deployments_list_at_management_group_scope_request( - group_id: str, - *, - filter: Optional[str] = None, - top: Optional[int] = None, - **kwargs: Any + group_id: str, *, filter: Optional[str] = None, top: Optional[int] = None, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2020-06-01") # type: 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", "2020-06-01")) # type: str + accept = _headers.pop("Accept", "application/json") - accept = "application/json" # Construct URL - _url = kwargs.pop("template_url", "/providers/Microsoft.Management/managementGroups/{groupId}/providers/Microsoft.Resources/deployments/") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", + "/providers/Microsoft.Management/managementGroups/{groupId}/providers/Microsoft.Resources/deployments/", + ) # pylint: disable=line-too-long path_format_arguments = { - "groupId": _SERIALIZER.url("group_id", group_id, 'str', max_length=90, min_length=1), + "groupId": _SERIALIZER.url("group_id", group_id, "str", max_length=90, min_length=1), } _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] if filter is not None: - _query_parameters['$filter'] = _SERIALIZER.query("filter", filter, 'str') + _params["$filter"] = _SERIALIZER.query("filter", filter, "str") if top is not None: - _query_parameters['$top'] = _SERIALIZER.query("top", top, 'int') - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["$top"] = _SERIALIZER.query("top", top, "int") + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') - - return HttpRequest( - method="GET", - url=_url, - params=_query_parameters, - headers=_header_parameters, - **kwargs - ) + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) -def build_deployments_delete_at_subscription_scope_request_initial( - deployment_name: str, - subscription_id: str, - **kwargs: Any + +def build_deployments_delete_at_subscription_scope_request( + deployment_name: str, subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2020-06-01") # type: 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", "2020-06-01")) # type: str + accept = _headers.pop("Accept", "application/json") - accept = "application/json" # Construct URL - _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/providers/Microsoft.Resources/deployments/{deploymentName}") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", "/subscriptions/{subscriptionId}/providers/Microsoft.Resources/deployments/{deploymentName}" + ) # pylint: disable=line-too-long path_format_arguments = { - "deploymentName": _SERIALIZER.url("deployment_name", deployment_name, 'str', max_length=64, min_length=1), - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), + "deploymentName": _SERIALIZER.url("deployment_name", deployment_name, "str", max_length=64, min_length=1), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), } _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') - - return HttpRequest( - method="DELETE", - url=_url, - params=_query_parameters, - headers=_header_parameters, - **kwargs - ) + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="DELETE", url=_url, params=_params, headers=_headers, **kwargs) def build_deployments_check_existence_at_subscription_scope_request( - deployment_name: str, - subscription_id: str, - **kwargs: Any + deployment_name: str, subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2020-06-01") # type: 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", "2020-06-01")) # type: str + accept = _headers.pop("Accept", "application/json") - accept = "application/json" # Construct URL - _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/providers/Microsoft.Resources/deployments/{deploymentName}") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", "/subscriptions/{subscriptionId}/providers/Microsoft.Resources/deployments/{deploymentName}" + ) # pylint: disable=line-too-long path_format_arguments = { - "deploymentName": _SERIALIZER.url("deployment_name", deployment_name, 'str', max_length=64, min_length=1), - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), + "deploymentName": _SERIALIZER.url("deployment_name", deployment_name, "str", max_length=64, min_length=1), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), } _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') - - return HttpRequest( - method="HEAD", - url=_url, - params=_query_parameters, - headers=_header_parameters, - **kwargs - ) + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + return HttpRequest(method="HEAD", url=_url, params=_params, headers=_headers, **kwargs) -def build_deployments_create_or_update_at_subscription_scope_request_initial( - deployment_name: str, - subscription_id: str, - *, - json: JSONType = None, - content: Any = None, - **kwargs: Any + +def build_deployments_create_or_update_at_subscription_scope_request( + deployment_name: str, subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2020-06-01") # type: str - content_type = kwargs.pop('content_type', None) # type: Optional[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", "2020-06-01")) # type: str + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + accept = _headers.pop("Accept", "application/json") - accept = "application/json" # Construct URL - _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/providers/Microsoft.Resources/deployments/{deploymentName}") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", "/subscriptions/{subscriptionId}/providers/Microsoft.Resources/deployments/{deploymentName}" + ) # pylint: disable=line-too-long path_format_arguments = { - "deploymentName": _SERIALIZER.url("deployment_name", deployment_name, 'str', max_length=64, min_length=1), - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), + "deploymentName": _SERIALIZER.url("deployment_name", deployment_name, "str", max_length=64, min_length=1), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), } _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] if content_type is not None: - _header_parameters['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') - _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') - - return HttpRequest( - method="PUT", - url=_url, - params=_query_parameters, - headers=_header_parameters, - json=json, - content=content, - **kwargs - ) + _headers["Content-Type"] = _SERIALIZER.header("content_type", content_type, "str") + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="PUT", url=_url, params=_params, headers=_headers, **kwargs) def build_deployments_get_at_subscription_scope_request( - deployment_name: str, - subscription_id: str, - **kwargs: Any + deployment_name: str, subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2020-06-01") # type: 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", "2020-06-01")) # type: str + accept = _headers.pop("Accept", "application/json") - accept = "application/json" # Construct URL - _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/providers/Microsoft.Resources/deployments/{deploymentName}") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", "/subscriptions/{subscriptionId}/providers/Microsoft.Resources/deployments/{deploymentName}" + ) # pylint: disable=line-too-long path_format_arguments = { - "deploymentName": _SERIALIZER.url("deployment_name", deployment_name, 'str', max_length=64, min_length=1), - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), + "deploymentName": _SERIALIZER.url("deployment_name", deployment_name, "str", max_length=64, min_length=1), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), } _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') - - return HttpRequest( - method="GET", - url=_url, - params=_query_parameters, - headers=_header_parameters, - **kwargs - ) + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) def build_deployments_cancel_at_subscription_scope_request( - deployment_name: str, - subscription_id: str, - **kwargs: Any + deployment_name: str, subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2020-06-01") # type: 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", "2020-06-01")) # type: str + accept = _headers.pop("Accept", "application/json") - accept = "application/json" # Construct URL - _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/providers/Microsoft.Resources/deployments/{deploymentName}/cancel") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/providers/Microsoft.Resources/deployments/{deploymentName}/cancel", + ) # pylint: disable=line-too-long path_format_arguments = { - "deploymentName": _SERIALIZER.url("deployment_name", deployment_name, 'str', max_length=64, min_length=1), - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), + "deploymentName": _SERIALIZER.url("deployment_name", deployment_name, "str", max_length=64, min_length=1), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), } _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') - - return HttpRequest( - method="POST", - url=_url, - params=_query_parameters, - headers=_header_parameters, - **kwargs - ) + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + return HttpRequest(method="POST", url=_url, params=_params, headers=_headers, **kwargs) -def build_deployments_validate_at_subscription_scope_request_initial( - deployment_name: str, - subscription_id: str, - *, - json: JSONType = None, - content: Any = None, - **kwargs: Any + +def build_deployments_validate_at_subscription_scope_request( + deployment_name: str, subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2020-06-01") # type: str - content_type = kwargs.pop('content_type', None) # type: Optional[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", "2020-06-01")) # type: str + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + accept = _headers.pop("Accept", "application/json") - accept = "application/json" # Construct URL - _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/providers/Microsoft.Resources/deployments/{deploymentName}/validate") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/providers/Microsoft.Resources/deployments/{deploymentName}/validate", + ) # pylint: disable=line-too-long path_format_arguments = { - "deploymentName": _SERIALIZER.url("deployment_name", deployment_name, 'str', max_length=64, min_length=1), - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), + "deploymentName": _SERIALIZER.url("deployment_name", deployment_name, "str", max_length=64, min_length=1), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), } _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] if content_type is not None: - _header_parameters['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') - _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') - - return HttpRequest( - method="POST", - url=_url, - params=_query_parameters, - headers=_header_parameters, - json=json, - content=content, - **kwargs - ) + _headers["Content-Type"] = _SERIALIZER.header("content_type", content_type, "str") + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + return HttpRequest(method="POST", url=_url, params=_params, headers=_headers, **kwargs) -def build_deployments_what_if_at_subscription_scope_request_initial( - deployment_name: str, - subscription_id: str, - *, - json: JSONType = None, - content: Any = None, - **kwargs: Any + +def build_deployments_what_if_at_subscription_scope_request( + deployment_name: str, subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2020-06-01") # type: str - content_type = kwargs.pop('content_type', None) # type: Optional[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", "2020-06-01")) # type: str + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + accept = _headers.pop("Accept", "application/json") - accept = "application/json" # Construct URL - _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/providers/Microsoft.Resources/deployments/{deploymentName}/whatIf") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/providers/Microsoft.Resources/deployments/{deploymentName}/whatIf", + ) # pylint: disable=line-too-long path_format_arguments = { - "deploymentName": _SERIALIZER.url("deployment_name", deployment_name, 'str', max_length=64, min_length=1), - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), + "deploymentName": _SERIALIZER.url("deployment_name", deployment_name, "str", max_length=64, min_length=1), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), } _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] if content_type is not None: - _header_parameters['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') - _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') - - return HttpRequest( - method="POST", - url=_url, - params=_query_parameters, - headers=_header_parameters, - json=json, - content=content, - **kwargs - ) + _headers["Content-Type"] = _SERIALIZER.header("content_type", content_type, "str") + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="POST", url=_url, params=_params, headers=_headers, **kwargs) def build_deployments_export_template_at_subscription_scope_request( - deployment_name: str, - subscription_id: str, - **kwargs: Any + deployment_name: str, subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2020-06-01") # type: 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", "2020-06-01")) # type: str + accept = _headers.pop("Accept", "application/json") - accept = "application/json" # Construct URL - _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/providers/Microsoft.Resources/deployments/{deploymentName}/exportTemplate") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/providers/Microsoft.Resources/deployments/{deploymentName}/exportTemplate", + ) # pylint: disable=line-too-long path_format_arguments = { - "deploymentName": _SERIALIZER.url("deployment_name", deployment_name, 'str', max_length=64, min_length=1), - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), + "deploymentName": _SERIALIZER.url("deployment_name", deployment_name, "str", max_length=64, min_length=1), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), } _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') - - return HttpRequest( - method="POST", - url=_url, - params=_query_parameters, - headers=_header_parameters, - **kwargs - ) + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="POST", url=_url, params=_params, headers=_headers, **kwargs) def build_deployments_list_at_subscription_scope_request( - subscription_id: str, - *, - filter: Optional[str] = None, - top: Optional[int] = None, - **kwargs: Any + subscription_id: str, *, filter: Optional[str] = None, top: Optional[int] = None, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2020-06-01") # type: 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", "2020-06-01")) # type: str + accept = _headers.pop("Accept", "application/json") - accept = "application/json" # Construct URL _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/providers/Microsoft.Resources/deployments/") path_format_arguments = { - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), } _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] if filter is not None: - _query_parameters['$filter'] = _SERIALIZER.query("filter", filter, 'str') + _params["$filter"] = _SERIALIZER.query("filter", filter, "str") if top is not None: - _query_parameters['$top'] = _SERIALIZER.query("top", top, 'int') - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["$top"] = _SERIALIZER.query("top", top, "int") + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') - - return HttpRequest( - method="GET", - url=_url, - params=_query_parameters, - headers=_header_parameters, - **kwargs - ) + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) -def build_deployments_delete_request_initial( - resource_group_name: str, - deployment_name: str, - subscription_id: str, - **kwargs: Any + +def build_deployments_delete_request( + resource_group_name: str, deployment_name: str, subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2020-06-01") # type: 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", "2020-06-01")) # type: str + accept = _headers.pop("Accept", "application/json") - accept = "application/json" # Construct URL - _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/Microsoft.Resources/deployments/{deploymentName}") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/Microsoft.Resources/deployments/{deploymentName}", + ) # pylint: disable=line-too-long path_format_arguments = { - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1), - "deploymentName": _SERIALIZER.url("deployment_name", deployment_name, 'str', max_length=64, min_length=1), - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), + "resourceGroupName": _SERIALIZER.url( + "resource_group_name", resource_group_name, "str", max_length=90, min_length=1 + ), + "deploymentName": _SERIALIZER.url("deployment_name", deployment_name, "str", max_length=64, min_length=1), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), } _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') - - return HttpRequest( - method="DELETE", - url=_url, - params=_query_parameters, - headers=_header_parameters, - **kwargs - ) + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="DELETE", url=_url, params=_params, headers=_headers, **kwargs) def build_deployments_check_existence_request( - resource_group_name: str, - deployment_name: str, - subscription_id: str, - **kwargs: Any + resource_group_name: str, deployment_name: str, subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2020-06-01") # type: 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", "2020-06-01")) # type: str + accept = _headers.pop("Accept", "application/json") - accept = "application/json" # Construct URL - _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/Microsoft.Resources/deployments/{deploymentName}") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/Microsoft.Resources/deployments/{deploymentName}", + ) # pylint: disable=line-too-long path_format_arguments = { - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1), - "deploymentName": _SERIALIZER.url("deployment_name", deployment_name, 'str', max_length=64, min_length=1), - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), + "resourceGroupName": _SERIALIZER.url( + "resource_group_name", resource_group_name, "str", max_length=90, min_length=1 + ), + "deploymentName": _SERIALIZER.url("deployment_name", deployment_name, "str", max_length=64, min_length=1), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), } _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') - - return HttpRequest( - method="HEAD", - url=_url, - params=_query_parameters, - headers=_header_parameters, - **kwargs - ) + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + return HttpRequest(method="HEAD", url=_url, params=_params, headers=_headers, **kwargs) -def build_deployments_create_or_update_request_initial( - resource_group_name: str, - deployment_name: str, - subscription_id: str, - *, - json: JSONType = None, - content: Any = None, - **kwargs: Any + +def build_deployments_create_or_update_request( + resource_group_name: str, deployment_name: str, subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2020-06-01") # type: str - content_type = kwargs.pop('content_type', None) # type: Optional[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", "2020-06-01")) # type: str + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + accept = _headers.pop("Accept", "application/json") - accept = "application/json" # Construct URL - _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/Microsoft.Resources/deployments/{deploymentName}") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/Microsoft.Resources/deployments/{deploymentName}", + ) # pylint: disable=line-too-long path_format_arguments = { - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1), - "deploymentName": _SERIALIZER.url("deployment_name", deployment_name, 'str', max_length=64, min_length=1), - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), + "resourceGroupName": _SERIALIZER.url( + "resource_group_name", resource_group_name, "str", max_length=90, min_length=1 + ), + "deploymentName": _SERIALIZER.url("deployment_name", deployment_name, "str", max_length=64, min_length=1), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), } _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] if content_type is not None: - _header_parameters['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') - _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') - - return HttpRequest( - method="PUT", - url=_url, - params=_query_parameters, - headers=_header_parameters, - json=json, - content=content, - **kwargs - ) + _headers["Content-Type"] = _SERIALIZER.header("content_type", content_type, "str") + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="PUT", url=_url, params=_params, headers=_headers, **kwargs) def build_deployments_get_request( - resource_group_name: str, - deployment_name: str, - subscription_id: str, - **kwargs: Any + resource_group_name: str, deployment_name: str, subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2020-06-01") # type: 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", "2020-06-01")) # type: str + accept = _headers.pop("Accept", "application/json") - accept = "application/json" # Construct URL - _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/Microsoft.Resources/deployments/{deploymentName}") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/Microsoft.Resources/deployments/{deploymentName}", + ) # pylint: disable=line-too-long path_format_arguments = { - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1), - "deploymentName": _SERIALIZER.url("deployment_name", deployment_name, 'str', max_length=64, min_length=1), - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), + "resourceGroupName": _SERIALIZER.url( + "resource_group_name", resource_group_name, "str", max_length=90, min_length=1 + ), + "deploymentName": _SERIALIZER.url("deployment_name", deployment_name, "str", max_length=64, min_length=1), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), } _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') - - return HttpRequest( - method="GET", - url=_url, - params=_query_parameters, - headers=_header_parameters, - **kwargs - ) + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) def build_deployments_cancel_request( - resource_group_name: str, - deployment_name: str, - subscription_id: str, - **kwargs: Any + resource_group_name: str, deployment_name: str, subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2020-06-01") # type: 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", "2020-06-01")) # type: str + accept = _headers.pop("Accept", "application/json") - accept = "application/json" # Construct URL - _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/Microsoft.Resources/deployments/{deploymentName}/cancel") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/Microsoft.Resources/deployments/{deploymentName}/cancel", + ) # pylint: disable=line-too-long path_format_arguments = { - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1), - "deploymentName": _SERIALIZER.url("deployment_name", deployment_name, 'str', max_length=64, min_length=1), - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), + "resourceGroupName": _SERIALIZER.url( + "resource_group_name", resource_group_name, "str", max_length=90, min_length=1 + ), + "deploymentName": _SERIALIZER.url("deployment_name", deployment_name, "str", max_length=64, min_length=1), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), } _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') - - return HttpRequest( - method="POST", - url=_url, - params=_query_parameters, - headers=_header_parameters, - **kwargs - ) + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + return HttpRequest(method="POST", url=_url, params=_params, headers=_headers, **kwargs) -def build_deployments_validate_request_initial( - resource_group_name: str, - deployment_name: str, - subscription_id: str, - *, - json: JSONType = None, - content: Any = None, - **kwargs: Any + +def build_deployments_validate_request( + resource_group_name: str, deployment_name: str, subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2020-06-01") # type: str - content_type = kwargs.pop('content_type', None) # type: Optional[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", "2020-06-01")) # type: str + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + accept = _headers.pop("Accept", "application/json") - accept = "application/json" # Construct URL - _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/Microsoft.Resources/deployments/{deploymentName}/validate") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/Microsoft.Resources/deployments/{deploymentName}/validate", + ) # pylint: disable=line-too-long path_format_arguments = { - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1), - "deploymentName": _SERIALIZER.url("deployment_name", deployment_name, 'str', max_length=64, min_length=1), - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), + "resourceGroupName": _SERIALIZER.url( + "resource_group_name", resource_group_name, "str", max_length=90, min_length=1 + ), + "deploymentName": _SERIALIZER.url("deployment_name", deployment_name, "str", max_length=64, min_length=1), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), } _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] if content_type is not None: - _header_parameters['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') - _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') - - return HttpRequest( - method="POST", - url=_url, - params=_query_parameters, - headers=_header_parameters, - json=json, - content=content, - **kwargs - ) + _headers["Content-Type"] = _SERIALIZER.header("content_type", content_type, "str") + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + return HttpRequest(method="POST", url=_url, params=_params, headers=_headers, **kwargs) -def build_deployments_what_if_request_initial( - resource_group_name: str, - deployment_name: str, - subscription_id: str, - *, - json: JSONType = None, - content: Any = None, - **kwargs: Any + +def build_deployments_what_if_request( + resource_group_name: str, deployment_name: str, subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2020-06-01") # type: str - content_type = kwargs.pop('content_type', None) # type: Optional[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", "2020-06-01")) # type: str + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + accept = _headers.pop("Accept", "application/json") - accept = "application/json" # Construct URL - _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/Microsoft.Resources/deployments/{deploymentName}/whatIf") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/Microsoft.Resources/deployments/{deploymentName}/whatIf", + ) # pylint: disable=line-too-long path_format_arguments = { - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1), - "deploymentName": _SERIALIZER.url("deployment_name", deployment_name, 'str', max_length=64, min_length=1), - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), + "resourceGroupName": _SERIALIZER.url( + "resource_group_name", resource_group_name, "str", max_length=90, min_length=1 + ), + "deploymentName": _SERIALIZER.url("deployment_name", deployment_name, "str", max_length=64, min_length=1), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), } _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] if content_type is not None: - _header_parameters['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') - _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') - - return HttpRequest( - method="POST", - url=_url, - params=_query_parameters, - headers=_header_parameters, - json=json, - content=content, - **kwargs - ) + _headers["Content-Type"] = _SERIALIZER.header("content_type", content_type, "str") + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="POST", url=_url, params=_params, headers=_headers, **kwargs) def build_deployments_export_template_request( - resource_group_name: str, - deployment_name: str, - subscription_id: str, - **kwargs: Any + resource_group_name: str, deployment_name: str, subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2020-06-01") # type: 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", "2020-06-01")) # type: str + accept = _headers.pop("Accept", "application/json") - accept = "application/json" # Construct URL - _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/Microsoft.Resources/deployments/{deploymentName}/exportTemplate") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/Microsoft.Resources/deployments/{deploymentName}/exportTemplate", + ) # pylint: disable=line-too-long path_format_arguments = { - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1), - "deploymentName": _SERIALIZER.url("deployment_name", deployment_name, 'str', max_length=64, min_length=1), - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), + "resourceGroupName": _SERIALIZER.url( + "resource_group_name", resource_group_name, "str", max_length=90, min_length=1 + ), + "deploymentName": _SERIALIZER.url("deployment_name", deployment_name, "str", max_length=64, min_length=1), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), } _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') - - return HttpRequest( - method="POST", - url=_url, - params=_query_parameters, - headers=_header_parameters, - **kwargs - ) + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="POST", url=_url, params=_params, headers=_headers, **kwargs) def build_deployments_list_by_resource_group_request( @@ -1651,319 +1340,257 @@ def build_deployments_list_by_resource_group_request( top: Optional[int] = None, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2020-06-01") # type: 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", "2020-06-01")) # type: str + accept = _headers.pop("Accept", "application/json") - accept = "application/json" # Construct URL - _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/Microsoft.Resources/deployments/") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/Microsoft.Resources/deployments/", + ) # pylint: disable=line-too-long path_format_arguments = { - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1), - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), + "resourceGroupName": _SERIALIZER.url( + "resource_group_name", resource_group_name, "str", max_length=90, min_length=1 + ), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), } _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] if filter is not None: - _query_parameters['$filter'] = _SERIALIZER.query("filter", filter, 'str') + _params["$filter"] = _SERIALIZER.query("filter", filter, "str") if top is not None: - _query_parameters['$top'] = _SERIALIZER.query("top", top, 'int') - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["$top"] = _SERIALIZER.query("top", top, "int") + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') - - return HttpRequest( - method="GET", - url=_url, - params=_query_parameters, - headers=_header_parameters, - **kwargs - ) + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) -def build_deployments_calculate_template_hash_request( - *, - json: JSONType = None, - content: Any = None, - **kwargs: Any -) -> HttpRequest: - api_version = kwargs.pop('api_version', "2020-06-01") # type: str - content_type = kwargs.pop('content_type', None) # type: Optional[str] - accept = "application/json" +def build_deployments_calculate_template_hash_request(*, json: JSON, **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", "2020-06-01")) # type: str + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + accept = _headers.pop("Accept", "application/json") + # Construct URL _url = kwargs.pop("template_url", "/providers/Microsoft.Resources/calculateTemplateHash") # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] if content_type is not None: - _header_parameters['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') - _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') - - return HttpRequest( - method="POST", - url=_url, - params=_query_parameters, - headers=_header_parameters, - json=json, - content=content, - **kwargs - ) + _headers["Content-Type"] = _SERIALIZER.header("content_type", content_type, "str") + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="POST", url=_url, params=_params, headers=_headers, json=json, **kwargs) def build_providers_unregister_request( - resource_provider_namespace: str, - subscription_id: str, - **kwargs: Any + resource_provider_namespace: str, subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2020-06-01") # type: 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", "2020-06-01")) # type: str + accept = _headers.pop("Accept", "application/json") - accept = "application/json" # Construct URL - _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/providers/{resourceProviderNamespace}/unregister") + _url = kwargs.pop( + "template_url", "/subscriptions/{subscriptionId}/providers/{resourceProviderNamespace}/unregister" + ) path_format_arguments = { - "resourceProviderNamespace": _SERIALIZER.url("resource_provider_namespace", resource_provider_namespace, 'str'), - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), + "resourceProviderNamespace": _SERIALIZER.url("resource_provider_namespace", resource_provider_namespace, "str"), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), } _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') - - return HttpRequest( - method="POST", - url=_url, - params=_query_parameters, - headers=_header_parameters, - **kwargs - ) + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="POST", url=_url, params=_params, headers=_headers, **kwargs) def build_providers_register_at_management_group_scope_request( - resource_provider_namespace: str, - group_id: str, - **kwargs: Any + resource_provider_namespace: str, group_id: str, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2020-06-01") # type: 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", "2020-06-01")) # type: str + accept = _headers.pop("Accept", "application/json") - accept = "application/json" # Construct URL - _url = kwargs.pop("template_url", "/providers/Microsoft.Management/managementGroups/{groupId}/providers/{resourceProviderNamespace}/register") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", + "/providers/Microsoft.Management/managementGroups/{groupId}/providers/{resourceProviderNamespace}/register", + ) # pylint: disable=line-too-long path_format_arguments = { - "resourceProviderNamespace": _SERIALIZER.url("resource_provider_namespace", resource_provider_namespace, 'str'), - "groupId": _SERIALIZER.url("group_id", group_id, 'str', max_length=90, min_length=1), + "resourceProviderNamespace": _SERIALIZER.url("resource_provider_namespace", resource_provider_namespace, "str"), + "groupId": _SERIALIZER.url("group_id", group_id, "str", max_length=90, min_length=1), } _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') - - return HttpRequest( - method="POST", - url=_url, - params=_query_parameters, - headers=_header_parameters, - **kwargs - ) + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="POST", url=_url, params=_params, headers=_headers, **kwargs) def build_providers_register_request( - resource_provider_namespace: str, - subscription_id: str, - **kwargs: Any + resource_provider_namespace: str, subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2020-06-01") # type: 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", "2020-06-01")) # type: str + accept = _headers.pop("Accept", "application/json") - accept = "application/json" # Construct URL _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/providers/{resourceProviderNamespace}/register") path_format_arguments = { - "resourceProviderNamespace": _SERIALIZER.url("resource_provider_namespace", resource_provider_namespace, 'str'), - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), + "resourceProviderNamespace": _SERIALIZER.url("resource_provider_namespace", resource_provider_namespace, "str"), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), } _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') - - return HttpRequest( - method="POST", - url=_url, - params=_query_parameters, - headers=_header_parameters, - **kwargs - ) + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="POST", url=_url, params=_params, headers=_headers, **kwargs) def build_providers_list_request( - subscription_id: str, - *, - top: Optional[int] = None, - expand: Optional[str] = None, - **kwargs: Any + subscription_id: str, *, top: Optional[int] = None, expand: Optional[str] = None, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2020-06-01") # type: 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", "2020-06-01")) # type: str + accept = _headers.pop("Accept", "application/json") - accept = "application/json" # Construct URL _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/providers") path_format_arguments = { - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), } _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] if top is not None: - _query_parameters['$top'] = _SERIALIZER.query("top", top, 'int') + _params["$top"] = _SERIALIZER.query("top", top, "int") if expand is not None: - _query_parameters['$expand'] = _SERIALIZER.query("expand", expand, 'str') - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["$expand"] = _SERIALIZER.query("expand", expand, "str") + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') - - return HttpRequest( - method="GET", - url=_url, - params=_query_parameters, - headers=_header_parameters, - **kwargs - ) + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) def build_providers_list_at_tenant_scope_request( - *, - top: Optional[int] = None, - expand: Optional[str] = None, - **kwargs: Any + *, top: Optional[int] = None, expand: Optional[str] = None, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2020-06-01") # type: 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", "2020-06-01")) # type: str + accept = _headers.pop("Accept", "application/json") - accept = "application/json" # Construct URL _url = kwargs.pop("template_url", "/providers") # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] if top is not None: - _query_parameters['$top'] = _SERIALIZER.query("top", top, 'int') + _params["$top"] = _SERIALIZER.query("top", top, "int") if expand is not None: - _query_parameters['$expand'] = _SERIALIZER.query("expand", expand, 'str') - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["$expand"] = _SERIALIZER.query("expand", expand, "str") + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') - - return HttpRequest( - method="GET", - url=_url, - params=_query_parameters, - headers=_header_parameters, - **kwargs - ) + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) def build_providers_get_request( - resource_provider_namespace: str, - subscription_id: str, - *, - expand: Optional[str] = None, - **kwargs: Any + resource_provider_namespace: str, subscription_id: str, *, expand: Optional[str] = None, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2020-06-01") # type: 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", "2020-06-01")) # type: str + accept = _headers.pop("Accept", "application/json") - accept = "application/json" # Construct URL _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/providers/{resourceProviderNamespace}") path_format_arguments = { - "resourceProviderNamespace": _SERIALIZER.url("resource_provider_namespace", resource_provider_namespace, 'str'), - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), + "resourceProviderNamespace": _SERIALIZER.url("resource_provider_namespace", resource_provider_namespace, "str"), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), } _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] if expand is not None: - _query_parameters['$expand'] = _SERIALIZER.query("expand", expand, 'str') - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["$expand"] = _SERIALIZER.query("expand", expand, "str") + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') - - return HttpRequest( - method="GET", - url=_url, - params=_query_parameters, - headers=_header_parameters, - **kwargs - ) + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) def build_providers_get_at_tenant_scope_request( - resource_provider_namespace: str, - *, - expand: Optional[str] = None, - **kwargs: Any + resource_provider_namespace: str, *, expand: Optional[str] = None, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2020-06-01") # type: 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", "2020-06-01")) # type: str + accept = _headers.pop("Accept", "application/json") - accept = "application/json" # Construct URL _url = kwargs.pop("template_url", "/providers/{resourceProviderNamespace}") path_format_arguments = { - "resourceProviderNamespace": _SERIALIZER.url("resource_provider_namespace", resource_provider_namespace, 'str'), + "resourceProviderNamespace": _SERIALIZER.url("resource_provider_namespace", resource_provider_namespace, "str"), } _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] if expand is not None: - _query_parameters['$expand'] = _SERIALIZER.query("expand", expand, 'str') - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["$expand"] = _SERIALIZER.query("expand", expand, "str") + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') - - return HttpRequest( - method="GET", - url=_url, - params=_query_parameters, - headers=_header_parameters, - **kwargs - ) + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) def build_resources_list_by_resource_group_request( @@ -1975,123 +1602,104 @@ def build_resources_list_by_resource_group_request( top: Optional[int] = None, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2020-06-01") # type: 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", "2020-06-01")) # type: str + accept = _headers.pop("Accept", "application/json") - accept = "application/json" # Construct URL _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/resources") path_format_arguments = { - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1), - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), + "resourceGroupName": _SERIALIZER.url( + "resource_group_name", resource_group_name, "str", max_length=90, min_length=1 + ), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), } _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] if filter is not None: - _query_parameters['$filter'] = _SERIALIZER.query("filter", filter, 'str') + _params["$filter"] = _SERIALIZER.query("filter", filter, "str") if expand is not None: - _query_parameters['$expand'] = _SERIALIZER.query("expand", expand, 'str') + _params["$expand"] = _SERIALIZER.query("expand", expand, "str") if top is not None: - _query_parameters['$top'] = _SERIALIZER.query("top", top, 'int') - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["$top"] = _SERIALIZER.query("top", top, "int") + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') - - return HttpRequest( - method="GET", - url=_url, - params=_query_parameters, - headers=_header_parameters, - **kwargs - ) + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) -def build_resources_move_resources_request_initial( - source_resource_group_name: str, - subscription_id: str, - *, - json: JSONType = None, - content: Any = None, - **kwargs: Any + +def build_resources_move_resources_request( + source_resource_group_name: str, subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2020-06-01") # type: str - content_type = kwargs.pop('content_type', None) # type: Optional[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", "2020-06-01")) # type: str + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + accept = _headers.pop("Accept", "application/json") - accept = "application/json" # Construct URL - _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{sourceResourceGroupName}/moveResources") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", "/subscriptions/{subscriptionId}/resourceGroups/{sourceResourceGroupName}/moveResources" + ) # pylint: disable=line-too-long path_format_arguments = { - "sourceResourceGroupName": _SERIALIZER.url("source_resource_group_name", source_resource_group_name, 'str', max_length=90, min_length=1), - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), + "sourceResourceGroupName": _SERIALIZER.url( + "source_resource_group_name", source_resource_group_name, "str", max_length=90, min_length=1 + ), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), } _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] if content_type is not None: - _header_parameters['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') - _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') - - return HttpRequest( - method="POST", - url=_url, - params=_query_parameters, - headers=_header_parameters, - json=json, - content=content, - **kwargs - ) + _headers["Content-Type"] = _SERIALIZER.header("content_type", content_type, "str") + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + return HttpRequest(method="POST", url=_url, params=_params, headers=_headers, **kwargs) -def build_resources_validate_move_resources_request_initial( - source_resource_group_name: str, - subscription_id: str, - *, - json: JSONType = None, - content: Any = None, - **kwargs: Any + +def build_resources_validate_move_resources_request( + source_resource_group_name: str, subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2020-06-01") # type: str - content_type = kwargs.pop('content_type', None) # type: Optional[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", "2020-06-01")) # type: str + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + accept = _headers.pop("Accept", "application/json") - accept = "application/json" # Construct URL - _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{sourceResourceGroupName}/validateMoveResources") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", "/subscriptions/{subscriptionId}/resourceGroups/{sourceResourceGroupName}/validateMoveResources" + ) # pylint: disable=line-too-long path_format_arguments = { - "sourceResourceGroupName": _SERIALIZER.url("source_resource_group_name", source_resource_group_name, 'str', max_length=90, min_length=1), - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), + "sourceResourceGroupName": _SERIALIZER.url( + "source_resource_group_name", source_resource_group_name, "str", max_length=90, min_length=1 + ), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), } _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] if content_type is not None: - _header_parameters['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') - _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') - - return HttpRequest( - method="POST", - url=_url, - params=_query_parameters, - headers=_header_parameters, - json=json, - content=content, - **kwargs - ) + _headers["Content-Type"] = _SERIALIZER.header("content_type", content_type, "str") + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="POST", url=_url, params=_params, headers=_headers, **kwargs) def build_resources_list_request( @@ -2102,38 +1710,33 @@ def build_resources_list_request( top: Optional[int] = None, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2020-06-01") # type: 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", "2020-06-01")) # type: str + accept = _headers.pop("Accept", "application/json") - accept = "application/json" # Construct URL _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resources") path_format_arguments = { - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), } _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] if filter is not None: - _query_parameters['$filter'] = _SERIALIZER.query("filter", filter, 'str') + _params["$filter"] = _SERIALIZER.query("filter", filter, "str") if expand is not None: - _query_parameters['$expand'] = _SERIALIZER.query("expand", expand, 'str') + _params["$expand"] = _SERIALIZER.query("expand", expand, "str") if top is not None: - _query_parameters['$top'] = _SERIALIZER.query("top", top, 'int') - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["$top"] = _SERIALIZER.query("top", top, "int") + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') - - return HttpRequest( - method="GET", - url=_url, - params=_query_parameters, - headers=_header_parameters, - **kwargs - ) + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) def build_resources_check_existence_request( @@ -2147,38 +1750,39 @@ def build_resources_check_existence_request( api_version: str, **kwargs: Any ) -> HttpRequest: - accept = "application/json" + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + accept = _headers.pop("Accept", "application/json") + # Construct URL - _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{parentResourcePath}/{resourceType}/{resourceName}") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{parentResourcePath}/{resourceType}/{resourceName}", + ) # pylint: disable=line-too-long path_format_arguments = { - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1), - "resourceProviderNamespace": _SERIALIZER.url("resource_provider_namespace", resource_provider_namespace, 'str'), - "parentResourcePath": _SERIALIZER.url("parent_resource_path", parent_resource_path, 'str', skip_quote=True), - "resourceType": _SERIALIZER.url("resource_type", resource_type, 'str', skip_quote=True), - "resourceName": _SERIALIZER.url("resource_name", resource_name, 'str'), - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), + "resourceGroupName": _SERIALIZER.url( + "resource_group_name", resource_group_name, "str", max_length=90, min_length=1 + ), + "resourceProviderNamespace": _SERIALIZER.url("resource_provider_namespace", resource_provider_namespace, "str"), + "parentResourcePath": _SERIALIZER.url("parent_resource_path", parent_resource_path, "str", skip_quote=True), + "resourceType": _SERIALIZER.url("resource_type", resource_type, "str", skip_quote=True), + "resourceName": _SERIALIZER.url("resource_name", resource_name, "str"), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), } _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') - - return HttpRequest( - method="HEAD", - url=_url, - params=_query_parameters, - headers=_header_parameters, - **kwargs - ) + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + return HttpRequest(method="HEAD", url=_url, params=_params, headers=_headers, **kwargs) -def build_resources_delete_request_initial( + +def build_resources_delete_request( resource_group_name: str, resource_provider_namespace: str, parent_resource_path: str, @@ -2189,38 +1793,39 @@ def build_resources_delete_request_initial( api_version: str, **kwargs: Any ) -> HttpRequest: - accept = "application/json" + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + accept = _headers.pop("Accept", "application/json") + # Construct URL - _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{parentResourcePath}/{resourceType}/{resourceName}") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{parentResourcePath}/{resourceType}/{resourceName}", + ) # pylint: disable=line-too-long path_format_arguments = { - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1), - "resourceProviderNamespace": _SERIALIZER.url("resource_provider_namespace", resource_provider_namespace, 'str'), - "parentResourcePath": _SERIALIZER.url("parent_resource_path", parent_resource_path, 'str', skip_quote=True), - "resourceType": _SERIALIZER.url("resource_type", resource_type, 'str', skip_quote=True), - "resourceName": _SERIALIZER.url("resource_name", resource_name, 'str'), - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), + "resourceGroupName": _SERIALIZER.url( + "resource_group_name", resource_group_name, "str", max_length=90, min_length=1 + ), + "resourceProviderNamespace": _SERIALIZER.url("resource_provider_namespace", resource_provider_namespace, "str"), + "parentResourcePath": _SERIALIZER.url("parent_resource_path", parent_resource_path, "str", skip_quote=True), + "resourceType": _SERIALIZER.url("resource_type", resource_type, "str", skip_quote=True), + "resourceName": _SERIALIZER.url("resource_name", resource_name, "str"), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), } _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') - - return HttpRequest( - method="DELETE", - url=_url, - params=_query_parameters, - headers=_header_parameters, - **kwargs - ) + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + return HttpRequest(method="DELETE", url=_url, params=_params, headers=_headers, **kwargs) -def build_resources_create_or_update_request_initial( + +def build_resources_create_or_update_request( resource_group_name: str, resource_provider_namespace: str, parent_resource_path: str, @@ -2229,48 +1834,44 @@ def build_resources_create_or_update_request_initial( subscription_id: str, *, api_version: str, - json: JSONType = None, - content: Any = None, **kwargs: Any ) -> HttpRequest: - content_type = kwargs.pop('content_type', None) # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + accept = _headers.pop("Accept", "application/json") - accept = "application/json" # Construct URL - _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{parentResourcePath}/{resourceType}/{resourceName}") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{parentResourcePath}/{resourceType}/{resourceName}", + ) # pylint: disable=line-too-long path_format_arguments = { - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1), - "resourceProviderNamespace": _SERIALIZER.url("resource_provider_namespace", resource_provider_namespace, 'str'), - "parentResourcePath": _SERIALIZER.url("parent_resource_path", parent_resource_path, 'str', skip_quote=True), - "resourceType": _SERIALIZER.url("resource_type", resource_type, 'str', skip_quote=True), - "resourceName": _SERIALIZER.url("resource_name", resource_name, 'str'), - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), + "resourceGroupName": _SERIALIZER.url( + "resource_group_name", resource_group_name, "str", max_length=90, min_length=1 + ), + "resourceProviderNamespace": _SERIALIZER.url("resource_provider_namespace", resource_provider_namespace, "str"), + "parentResourcePath": _SERIALIZER.url("parent_resource_path", parent_resource_path, "str", skip_quote=True), + "resourceType": _SERIALIZER.url("resource_type", resource_type, "str", skip_quote=True), + "resourceName": _SERIALIZER.url("resource_name", resource_name, "str"), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), } _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] if content_type is not None: - _header_parameters['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') - _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') - - return HttpRequest( - method="PUT", - url=_url, - params=_query_parameters, - headers=_header_parameters, - json=json, - content=content, - **kwargs - ) + _headers["Content-Type"] = _SERIALIZER.header("content_type", content_type, "str") + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="PUT", url=_url, params=_params, headers=_headers, **kwargs) -def build_resources_update_request_initial( +def build_resources_update_request( resource_group_name: str, resource_provider_namespace: str, parent_resource_path: str, @@ -2279,45 +1880,41 @@ def build_resources_update_request_initial( subscription_id: str, *, api_version: str, - json: JSONType = None, - content: Any = None, **kwargs: Any ) -> HttpRequest: - content_type = kwargs.pop('content_type', None) # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + accept = _headers.pop("Accept", "application/json") - accept = "application/json" # Construct URL - _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{parentResourcePath}/{resourceType}/{resourceName}") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{parentResourcePath}/{resourceType}/{resourceName}", + ) # pylint: disable=line-too-long path_format_arguments = { - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1), - "resourceProviderNamespace": _SERIALIZER.url("resource_provider_namespace", resource_provider_namespace, 'str'), - "parentResourcePath": _SERIALIZER.url("parent_resource_path", parent_resource_path, 'str', skip_quote=True), - "resourceType": _SERIALIZER.url("resource_type", resource_type, 'str', skip_quote=True), - "resourceName": _SERIALIZER.url("resource_name", resource_name, 'str'), - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), + "resourceGroupName": _SERIALIZER.url( + "resource_group_name", resource_group_name, "str", max_length=90, min_length=1 + ), + "resourceProviderNamespace": _SERIALIZER.url("resource_provider_namespace", resource_provider_namespace, "str"), + "parentResourcePath": _SERIALIZER.url("parent_resource_path", parent_resource_path, "str", skip_quote=True), + "resourceType": _SERIALIZER.url("resource_type", resource_type, "str", skip_quote=True), + "resourceName": _SERIALIZER.url("resource_name", resource_name, "str"), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), } _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] if content_type is not None: - _header_parameters['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') - _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') - - return HttpRequest( - method="PATCH", - url=_url, - params=_query_parameters, - headers=_header_parameters, - json=json, - content=content, - **kwargs - ) + _headers["Content-Type"] = _SERIALIZER.header("content_type", content_type, "str") + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="PATCH", url=_url, params=_params, headers=_headers, **kwargs) def build_resources_get_request( @@ -2331,1228 +1928,976 @@ def build_resources_get_request( api_version: str, **kwargs: Any ) -> HttpRequest: - accept = "application/json" + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + accept = _headers.pop("Accept", "application/json") + # Construct URL - _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{parentResourcePath}/{resourceType}/{resourceName}") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{parentResourcePath}/{resourceType}/{resourceName}", + ) # pylint: disable=line-too-long path_format_arguments = { - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1), - "resourceProviderNamespace": _SERIALIZER.url("resource_provider_namespace", resource_provider_namespace, 'str'), - "parentResourcePath": _SERIALIZER.url("parent_resource_path", parent_resource_path, 'str', skip_quote=True), - "resourceType": _SERIALIZER.url("resource_type", resource_type, 'str', skip_quote=True), - "resourceName": _SERIALIZER.url("resource_name", resource_name, 'str'), - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), + "resourceGroupName": _SERIALIZER.url( + "resource_group_name", resource_group_name, "str", max_length=90, min_length=1 + ), + "resourceProviderNamespace": _SERIALIZER.url("resource_provider_namespace", resource_provider_namespace, "str"), + "parentResourcePath": _SERIALIZER.url("parent_resource_path", parent_resource_path, "str", skip_quote=True), + "resourceType": _SERIALIZER.url("resource_type", resource_type, "str", skip_quote=True), + "resourceName": _SERIALIZER.url("resource_name", resource_name, "str"), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), } _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') - - return HttpRequest( - method="GET", - url=_url, - params=_query_parameters, - headers=_header_parameters, - **kwargs - ) + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) + + +def build_resources_check_existence_by_id_request(resource_id: str, *, api_version: str, **kwargs: Any) -> HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + accept = _headers.pop("Accept", "application/json") -def build_resources_check_existence_by_id_request( - resource_id: str, - *, - api_version: str, - **kwargs: Any -) -> HttpRequest: - accept = "application/json" # Construct URL _url = kwargs.pop("template_url", "/{resourceId}") path_format_arguments = { - "resourceId": _SERIALIZER.url("resource_id", resource_id, 'str', skip_quote=True), + "resourceId": _SERIALIZER.url("resource_id", resource_id, "str", skip_quote=True), } _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') - - return HttpRequest( - method="HEAD", - url=_url, - params=_query_parameters, - headers=_header_parameters, - **kwargs - ) + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + return HttpRequest(method="HEAD", url=_url, params=_params, headers=_headers, **kwargs) + + +def build_resources_delete_by_id_request(resource_id: str, *, api_version: str, **kwargs: Any) -> HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + accept = _headers.pop("Accept", "application/json") -def build_resources_delete_by_id_request_initial( - resource_id: str, - *, - api_version: str, - **kwargs: Any -) -> HttpRequest: - accept = "application/json" # Construct URL _url = kwargs.pop("template_url", "/{resourceId}") path_format_arguments = { - "resourceId": _SERIALIZER.url("resource_id", resource_id, 'str', skip_quote=True), + "resourceId": _SERIALIZER.url("resource_id", resource_id, "str", skip_quote=True), } _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') - - return HttpRequest( - method="DELETE", - url=_url, - params=_query_parameters, - headers=_header_parameters, - **kwargs - ) + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + return HttpRequest(method="DELETE", url=_url, params=_params, headers=_headers, **kwargs) -def build_resources_create_or_update_by_id_request_initial( - resource_id: str, - *, - api_version: str, - json: JSONType = None, - content: Any = None, - **kwargs: Any -) -> HttpRequest: - content_type = kwargs.pop('content_type', None) # type: Optional[str] - accept = "application/json" +def build_resources_create_or_update_by_id_request(resource_id: str, *, api_version: str, **kwargs: Any) -> HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + accept = _headers.pop("Accept", "application/json") + # Construct URL _url = kwargs.pop("template_url", "/{resourceId}") path_format_arguments = { - "resourceId": _SERIALIZER.url("resource_id", resource_id, 'str', skip_quote=True), + "resourceId": _SERIALIZER.url("resource_id", resource_id, "str", skip_quote=True), } _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] if content_type is not None: - _header_parameters['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') - _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') - - return HttpRequest( - method="PUT", - url=_url, - params=_query_parameters, - headers=_header_parameters, - json=json, - content=content, - **kwargs - ) + _headers["Content-Type"] = _SERIALIZER.header("content_type", content_type, "str") + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + return HttpRequest(method="PUT", url=_url, params=_params, headers=_headers, **kwargs) -def build_resources_update_by_id_request_initial( - resource_id: str, - *, - api_version: str, - json: JSONType = None, - content: Any = None, - **kwargs: Any -) -> HttpRequest: - content_type = kwargs.pop('content_type', None) # type: Optional[str] - accept = "application/json" +def build_resources_update_by_id_request(resource_id: str, *, api_version: str, **kwargs: Any) -> HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + accept = _headers.pop("Accept", "application/json") + # Construct URL _url = kwargs.pop("template_url", "/{resourceId}") path_format_arguments = { - "resourceId": _SERIALIZER.url("resource_id", resource_id, 'str', skip_quote=True), + "resourceId": _SERIALIZER.url("resource_id", resource_id, "str", skip_quote=True), } _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] if content_type is not None: - _header_parameters['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') - _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') - - return HttpRequest( - method="PATCH", - url=_url, - params=_query_parameters, - headers=_header_parameters, - json=json, - content=content, - **kwargs - ) + _headers["Content-Type"] = _SERIALIZER.header("content_type", content_type, "str") + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + return HttpRequest(method="PATCH", url=_url, params=_params, headers=_headers, **kwargs) + + +def build_resources_get_by_id_request(resource_id: str, *, api_version: str, **kwargs: Any) -> HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + accept = _headers.pop("Accept", "application/json") -def build_resources_get_by_id_request( - resource_id: str, - *, - api_version: str, - **kwargs: Any -) -> HttpRequest: - accept = "application/json" # Construct URL _url = kwargs.pop("template_url", "/{resourceId}") path_format_arguments = { - "resourceId": _SERIALIZER.url("resource_id", resource_id, 'str', skip_quote=True), + "resourceId": _SERIALIZER.url("resource_id", resource_id, "str", skip_quote=True), } _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') - - return HttpRequest( - method="GET", - url=_url, - params=_query_parameters, - headers=_header_parameters, - **kwargs - ) + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) def build_resource_groups_check_existence_request( - resource_group_name: str, - subscription_id: str, - **kwargs: Any + resource_group_name: str, subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2020-06-01") # type: 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", "2020-06-01")) # type: str + accept = _headers.pop("Accept", "application/json") - accept = "application/json" # Construct URL _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}") path_format_arguments = { - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1), - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), + "resourceGroupName": _SERIALIZER.url( + "resource_group_name", resource_group_name, "str", max_length=90, min_length=1 + ), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), } _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') - - return HttpRequest( - method="HEAD", - url=_url, - params=_query_parameters, - headers=_header_parameters, - **kwargs - ) + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="HEAD", url=_url, params=_params, headers=_headers, **kwargs) def build_resource_groups_create_or_update_request( - resource_group_name: str, - subscription_id: str, - *, - json: JSONType = None, - content: Any = None, - **kwargs: Any + resource_group_name: str, subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2020-06-01") # type: str - content_type = kwargs.pop('content_type', None) # type: Optional[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", "2020-06-01")) # type: str + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + accept = _headers.pop("Accept", "application/json") - accept = "application/json" # Construct URL _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}") path_format_arguments = { - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1), - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), + "resourceGroupName": _SERIALIZER.url( + "resource_group_name", resource_group_name, "str", max_length=90, min_length=1 + ), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), } _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] if content_type is not None: - _header_parameters['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') - _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') - - return HttpRequest( - method="PUT", - url=_url, - params=_query_parameters, - headers=_header_parameters, - json=json, - content=content, - **kwargs - ) + _headers["Content-Type"] = _SERIALIZER.header("content_type", content_type, "str") + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + return HttpRequest(method="PUT", url=_url, params=_params, headers=_headers, **kwargs) -def build_resource_groups_delete_request_initial( - resource_group_name: str, - subscription_id: str, - *, - force_deletion_types: Optional[str] = None, - **kwargs: Any + +def build_resource_groups_delete_request( + resource_group_name: str, subscription_id: str, *, force_deletion_types: Optional[str] = None, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2020-06-01") # type: 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", "2020-06-01")) # type: str + accept = _headers.pop("Accept", "application/json") - accept = "application/json" # Construct URL _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}") path_format_arguments = { - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1), - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), + "resourceGroupName": _SERIALIZER.url( + "resource_group_name", resource_group_name, "str", max_length=90, min_length=1 + ), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), } _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] if force_deletion_types is not None: - _query_parameters['forceDeletionTypes'] = _SERIALIZER.query("force_deletion_types", force_deletion_types, 'str') - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["forceDeletionTypes"] = _SERIALIZER.query("force_deletion_types", force_deletion_types, "str") + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') - - return HttpRequest( - method="DELETE", - url=_url, - params=_query_parameters, - headers=_header_parameters, - **kwargs - ) + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + return HttpRequest(method="DELETE", url=_url, params=_params, headers=_headers, **kwargs) -def build_resource_groups_get_request( - resource_group_name: str, - subscription_id: str, - **kwargs: Any -) -> HttpRequest: - api_version = kwargs.pop('api_version', "2020-06-01") # type: str - accept = "application/json" +def build_resource_groups_get_request(resource_group_name: str, subscription_id: str, **kwargs: Any) -> HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2020-06-01")) # type: str + accept = _headers.pop("Accept", "application/json") + # Construct URL _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}") path_format_arguments = { - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1), - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), + "resourceGroupName": _SERIALIZER.url( + "resource_group_name", resource_group_name, "str", max_length=90, min_length=1 + ), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), } _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') - - return HttpRequest( - method="GET", - url=_url, - params=_query_parameters, - headers=_header_parameters, - **kwargs - ) + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) -def build_resource_groups_update_request( - resource_group_name: str, - subscription_id: str, - *, - json: JSONType = None, - content: Any = None, - **kwargs: Any -) -> HttpRequest: - api_version = kwargs.pop('api_version', "2020-06-01") # type: str - content_type = kwargs.pop('content_type', None) # type: Optional[str] - accept = "application/json" +def build_resource_groups_update_request(resource_group_name: str, subscription_id: str, **kwargs: Any) -> HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2020-06-01")) # type: str + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + accept = _headers.pop("Accept", "application/json") + # Construct URL _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}") path_format_arguments = { - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1), - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), + "resourceGroupName": _SERIALIZER.url( + "resource_group_name", resource_group_name, "str", max_length=90, min_length=1 + ), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), } _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] if content_type is not None: - _header_parameters['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') - _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') - - return HttpRequest( - method="PATCH", - url=_url, - params=_query_parameters, - headers=_header_parameters, - json=json, - content=content, - **kwargs - ) + _headers["Content-Type"] = _SERIALIZER.header("content_type", content_type, "str") + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + return HttpRequest(method="PATCH", url=_url, params=_params, headers=_headers, **kwargs) -def build_resource_groups_export_template_request_initial( - subscription_id: str, - resource_group_name: str, - *, - json: JSONType = None, - content: Any = None, - **kwargs: Any + +def build_resource_groups_export_template_request( + resource_group_name: str, subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2020-06-01") # type: str - content_type = kwargs.pop('content_type', None) # type: Optional[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", "2020-06-01")) # type: str + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + accept = _headers.pop("Accept", "application/json") - accept = "application/json" # Construct URL - _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/exportTemplate") + _url = kwargs.pop( + "template_url", "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/exportTemplate" + ) path_format_arguments = { - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url( + "resource_group_name", resource_group_name, "str", max_length=90, min_length=1 + ), } _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] if content_type is not None: - _header_parameters['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') - _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') - - return HttpRequest( - method="POST", - url=_url, - params=_query_parameters, - headers=_header_parameters, - json=json, - content=content, - **kwargs - ) + _headers["Content-Type"] = _SERIALIZER.header("content_type", content_type, "str") + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="POST", url=_url, params=_params, headers=_headers, **kwargs) def build_resource_groups_list_request( - subscription_id: str, - *, - filter: Optional[str] = None, - top: Optional[int] = None, - **kwargs: Any + subscription_id: str, *, filter: Optional[str] = None, top: Optional[int] = None, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2020-06-01") # type: 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", "2020-06-01")) # type: str + accept = _headers.pop("Accept", "application/json") - accept = "application/json" # Construct URL _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourcegroups") path_format_arguments = { - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), } _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] if filter is not None: - _query_parameters['$filter'] = _SERIALIZER.query("filter", filter, 'str') + _params["$filter"] = _SERIALIZER.query("filter", filter, "str") if top is not None: - _query_parameters['$top'] = _SERIALIZER.query("top", top, 'int') - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["$top"] = _SERIALIZER.query("top", top, "int") + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') - - return HttpRequest( - method="GET", - url=_url, - params=_query_parameters, - headers=_header_parameters, - **kwargs - ) + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) -def build_tags_delete_value_request( - tag_name: str, - tag_value: str, - subscription_id: str, - **kwargs: Any -) -> HttpRequest: - api_version = kwargs.pop('api_version', "2020-06-01") # type: str - accept = "application/json" +def build_tags_delete_value_request(tag_name: str, tag_value: str, subscription_id: str, **kwargs: Any) -> HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2020-06-01")) # type: str + accept = _headers.pop("Accept", "application/json") + # Construct URL _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/tagNames/{tagName}/tagValues/{tagValue}") path_format_arguments = { - "tagName": _SERIALIZER.url("tag_name", tag_name, 'str'), - "tagValue": _SERIALIZER.url("tag_value", tag_value, 'str'), - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), + "tagName": _SERIALIZER.url("tag_name", tag_name, "str"), + "tagValue": _SERIALIZER.url("tag_value", tag_value, "str"), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), } _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') - - return HttpRequest( - method="DELETE", - url=_url, - params=_query_parameters, - headers=_header_parameters, - **kwargs - ) + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="DELETE", url=_url, params=_params, headers=_headers, **kwargs) def build_tags_create_or_update_value_request( - tag_name: str, - tag_value: str, - subscription_id: str, - **kwargs: Any + tag_name: str, tag_value: str, subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2020-06-01") # type: 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", "2020-06-01")) # type: str + accept = _headers.pop("Accept", "application/json") - accept = "application/json" # Construct URL _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/tagNames/{tagName}/tagValues/{tagValue}") path_format_arguments = { - "tagName": _SERIALIZER.url("tag_name", tag_name, 'str'), - "tagValue": _SERIALIZER.url("tag_value", tag_value, 'str'), - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), + "tagName": _SERIALIZER.url("tag_name", tag_name, "str"), + "tagValue": _SERIALIZER.url("tag_value", tag_value, "str"), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), } _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') - - return HttpRequest( - method="PUT", - url=_url, - params=_query_parameters, - headers=_header_parameters, - **kwargs - ) + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + return HttpRequest(method="PUT", url=_url, params=_params, headers=_headers, **kwargs) -def build_tags_create_or_update_request( - tag_name: str, - subscription_id: str, - **kwargs: Any -) -> HttpRequest: - api_version = kwargs.pop('api_version', "2020-06-01") # type: str - accept = "application/json" +def build_tags_create_or_update_request(tag_name: str, subscription_id: str, **kwargs: Any) -> HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2020-06-01")) # type: str + accept = _headers.pop("Accept", "application/json") + # Construct URL _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/tagNames/{tagName}") path_format_arguments = { - "tagName": _SERIALIZER.url("tag_name", tag_name, 'str'), - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), + "tagName": _SERIALIZER.url("tag_name", tag_name, "str"), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), } _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') - - return HttpRequest( - method="PUT", - url=_url, - params=_query_parameters, - headers=_header_parameters, - **kwargs - ) + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + return HttpRequest(method="PUT", url=_url, params=_params, headers=_headers, **kwargs) -def build_tags_delete_request( - tag_name: str, - subscription_id: str, - **kwargs: Any -) -> HttpRequest: - api_version = kwargs.pop('api_version', "2020-06-01") # type: str - accept = "application/json" +def build_tags_delete_request(tag_name: str, subscription_id: str, **kwargs: Any) -> HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2020-06-01")) # type: str + accept = _headers.pop("Accept", "application/json") + # Construct URL _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/tagNames/{tagName}") path_format_arguments = { - "tagName": _SERIALIZER.url("tag_name", tag_name, 'str'), - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), + "tagName": _SERIALIZER.url("tag_name", tag_name, "str"), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), } _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') - - return HttpRequest( - method="DELETE", - url=_url, - params=_query_parameters, - headers=_header_parameters, - **kwargs - ) + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + return HttpRequest(method="DELETE", url=_url, params=_params, headers=_headers, **kwargs) -def build_tags_list_request( - subscription_id: str, - **kwargs: Any -) -> HttpRequest: - api_version = kwargs.pop('api_version', "2020-06-01") # type: str - accept = "application/json" +def build_tags_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", "2020-06-01")) # type: str + accept = _headers.pop("Accept", "application/json") + # Construct URL _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/tagNames") path_format_arguments = { - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), } _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') - - return HttpRequest( - method="GET", - url=_url, - params=_query_parameters, - headers=_header_parameters, - **kwargs - ) + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) -def build_tags_create_or_update_at_scope_request( - scope: str, - *, - json: JSONType = None, - content: Any = None, - **kwargs: Any -) -> HttpRequest: - api_version = kwargs.pop('api_version', "2020-06-01") # type: str - content_type = kwargs.pop('content_type', None) # type: Optional[str] - accept = "application/json" +def build_tags_create_or_update_at_scope_request(scope: 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", "2020-06-01")) # type: str + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + accept = _headers.pop("Accept", "application/json") + # Construct URL _url = kwargs.pop("template_url", "/{scope}/providers/Microsoft.Resources/tags/default") path_format_arguments = { - "scope": _SERIALIZER.url("scope", scope, 'str', skip_quote=True), + "scope": _SERIALIZER.url("scope", scope, "str", skip_quote=True), } _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] if content_type is not None: - _header_parameters['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') - _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') - - return HttpRequest( - method="PUT", - url=_url, - params=_query_parameters, - headers=_header_parameters, - json=json, - content=content, - **kwargs - ) + _headers["Content-Type"] = _SERIALIZER.header("content_type", content_type, "str") + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + return HttpRequest(method="PUT", url=_url, params=_params, headers=_headers, **kwargs) -def build_tags_update_at_scope_request( - scope: str, - *, - json: JSONType = None, - content: Any = None, - **kwargs: Any -) -> HttpRequest: - api_version = kwargs.pop('api_version', "2020-06-01") # type: str - content_type = kwargs.pop('content_type', None) # type: Optional[str] - accept = "application/json" +def build_tags_update_at_scope_request(scope: 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", "2020-06-01")) # type: str + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + accept = _headers.pop("Accept", "application/json") + # Construct URL _url = kwargs.pop("template_url", "/{scope}/providers/Microsoft.Resources/tags/default") path_format_arguments = { - "scope": _SERIALIZER.url("scope", scope, 'str', skip_quote=True), + "scope": _SERIALIZER.url("scope", scope, "str", skip_quote=True), } _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] if content_type is not None: - _header_parameters['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') - _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') - - return HttpRequest( - method="PATCH", - url=_url, - params=_query_parameters, - headers=_header_parameters, - json=json, - content=content, - **kwargs - ) + _headers["Content-Type"] = _SERIALIZER.header("content_type", content_type, "str") + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + return HttpRequest(method="PATCH", url=_url, params=_params, headers=_headers, **kwargs) -def build_tags_get_at_scope_request( - scope: str, - **kwargs: Any -) -> HttpRequest: - api_version = kwargs.pop('api_version', "2020-06-01") # type: str - accept = "application/json" +def build_tags_get_at_scope_request(scope: 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", "2020-06-01")) # type: str + accept = _headers.pop("Accept", "application/json") + # Construct URL _url = kwargs.pop("template_url", "/{scope}/providers/Microsoft.Resources/tags/default") path_format_arguments = { - "scope": _SERIALIZER.url("scope", scope, 'str', skip_quote=True), + "scope": _SERIALIZER.url("scope", scope, "str", skip_quote=True), } _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') - - return HttpRequest( - method="GET", - url=_url, - params=_query_parameters, - headers=_header_parameters, - **kwargs - ) + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) -def build_tags_delete_at_scope_request( - scope: str, - **kwargs: Any -) -> HttpRequest: - api_version = kwargs.pop('api_version', "2020-06-01") # type: str - accept = "application/json" +def build_tags_delete_at_scope_request(scope: 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", "2020-06-01")) # type: str + accept = _headers.pop("Accept", "application/json") + # Construct URL _url = kwargs.pop("template_url", "/{scope}/providers/Microsoft.Resources/tags/default") path_format_arguments = { - "scope": _SERIALIZER.url("scope", scope, 'str', skip_quote=True), + "scope": _SERIALIZER.url("scope", scope, "str", skip_quote=True), } _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') - - return HttpRequest( - method="DELETE", - url=_url, - params=_query_parameters, - headers=_header_parameters, - **kwargs - ) + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="DELETE", url=_url, params=_params, headers=_headers, **kwargs) def build_deployment_operations_get_at_scope_request( - scope: str, - deployment_name: str, - operation_id: str, - **kwargs: Any + scope: str, deployment_name: str, operation_id: str, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2020-06-01") # type: 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", "2020-06-01")) # type: str + accept = _headers.pop("Accept", "application/json") - accept = "application/json" # Construct URL - _url = kwargs.pop("template_url", "/{scope}/providers/Microsoft.Resources/deployments/{deploymentName}/operations/{operationId}") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", "/{scope}/providers/Microsoft.Resources/deployments/{deploymentName}/operations/{operationId}" + ) # pylint: disable=line-too-long path_format_arguments = { - "scope": _SERIALIZER.url("scope", scope, 'str', skip_quote=True), - "deploymentName": _SERIALIZER.url("deployment_name", deployment_name, 'str', max_length=64, min_length=1), - "operationId": _SERIALIZER.url("operation_id", operation_id, 'str'), + "scope": _SERIALIZER.url("scope", scope, "str", skip_quote=True), + "deploymentName": _SERIALIZER.url("deployment_name", deployment_name, "str", max_length=64, min_length=1), + "operationId": _SERIALIZER.url("operation_id", operation_id, "str"), } _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') - - return HttpRequest( - method="GET", - url=_url, - params=_query_parameters, - headers=_header_parameters, - **kwargs - ) + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) def build_deployment_operations_list_at_scope_request( - scope: str, - deployment_name: str, - *, - top: Optional[int] = None, - **kwargs: Any + scope: str, deployment_name: str, *, top: Optional[int] = None, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2020-06-01") # type: 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", "2020-06-01")) # type: str + accept = _headers.pop("Accept", "application/json") - accept = "application/json" # Construct URL _url = kwargs.pop("template_url", "/{scope}/providers/Microsoft.Resources/deployments/{deploymentName}/operations") path_format_arguments = { - "scope": _SERIALIZER.url("scope", scope, 'str', skip_quote=True), - "deploymentName": _SERIALIZER.url("deployment_name", deployment_name, 'str', max_length=64, min_length=1), + "scope": _SERIALIZER.url("scope", scope, "str", skip_quote=True), + "deploymentName": _SERIALIZER.url("deployment_name", deployment_name, "str", max_length=64, min_length=1), } _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] if top is not None: - _query_parameters['$top'] = _SERIALIZER.query("top", top, 'int') - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["$top"] = _SERIALIZER.query("top", top, "int") + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') - - return HttpRequest( - method="GET", - url=_url, - params=_query_parameters, - headers=_header_parameters, - **kwargs - ) + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) def build_deployment_operations_get_at_tenant_scope_request( - deployment_name: str, - operation_id: str, - **kwargs: Any + deployment_name: str, operation_id: str, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2020-06-01") # type: 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", "2020-06-01")) # type: str + accept = _headers.pop("Accept", "application/json") - accept = "application/json" # Construct URL - _url = kwargs.pop("template_url", "/providers/Microsoft.Resources/deployments/{deploymentName}/operations/{operationId}") + _url = kwargs.pop( + "template_url", "/providers/Microsoft.Resources/deployments/{deploymentName}/operations/{operationId}" + ) path_format_arguments = { - "deploymentName": _SERIALIZER.url("deployment_name", deployment_name, 'str', max_length=64, min_length=1), - "operationId": _SERIALIZER.url("operation_id", operation_id, 'str'), + "deploymentName": _SERIALIZER.url("deployment_name", deployment_name, "str", max_length=64, min_length=1), + "operationId": _SERIALIZER.url("operation_id", operation_id, "str"), } _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') - - return HttpRequest( - method="GET", - url=_url, - params=_query_parameters, - headers=_header_parameters, - **kwargs - ) + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) def build_deployment_operations_list_at_tenant_scope_request( - deployment_name: str, - *, - top: Optional[int] = None, - **kwargs: Any + deployment_name: str, *, top: Optional[int] = None, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2020-06-01") # type: 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", "2020-06-01")) # type: str + accept = _headers.pop("Accept", "application/json") - accept = "application/json" # Construct URL _url = kwargs.pop("template_url", "/providers/Microsoft.Resources/deployments/{deploymentName}/operations") path_format_arguments = { - "deploymentName": _SERIALIZER.url("deployment_name", deployment_name, 'str', max_length=64, min_length=1), + "deploymentName": _SERIALIZER.url("deployment_name", deployment_name, "str", max_length=64, min_length=1), } _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] if top is not None: - _query_parameters['$top'] = _SERIALIZER.query("top", top, 'int') - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["$top"] = _SERIALIZER.query("top", top, "int") + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') - - return HttpRequest( - method="GET", - url=_url, - params=_query_parameters, - headers=_header_parameters, - **kwargs - ) + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) def build_deployment_operations_get_at_management_group_scope_request( - group_id: str, - deployment_name: str, - operation_id: str, - **kwargs: Any + group_id: str, deployment_name: str, operation_id: str, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2020-06-01") # type: 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", "2020-06-01")) # type: str + accept = _headers.pop("Accept", "application/json") - accept = "application/json" # Construct URL - _url = kwargs.pop("template_url", "/providers/Microsoft.Management/managementGroups/{groupId}/providers/Microsoft.Resources/deployments/{deploymentName}/operations/{operationId}") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", + "/providers/Microsoft.Management/managementGroups/{groupId}/providers/Microsoft.Resources/deployments/{deploymentName}/operations/{operationId}", + ) # pylint: disable=line-too-long path_format_arguments = { - "groupId": _SERIALIZER.url("group_id", group_id, 'str', max_length=90, min_length=1), - "deploymentName": _SERIALIZER.url("deployment_name", deployment_name, 'str', max_length=64, min_length=1), - "operationId": _SERIALIZER.url("operation_id", operation_id, 'str'), + "groupId": _SERIALIZER.url("group_id", group_id, "str", max_length=90, min_length=1), + "deploymentName": _SERIALIZER.url("deployment_name", deployment_name, "str", max_length=64, min_length=1), + "operationId": _SERIALIZER.url("operation_id", operation_id, "str"), } _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') - - return HttpRequest( - method="GET", - url=_url, - params=_query_parameters, - headers=_header_parameters, - **kwargs - ) + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) def build_deployment_operations_list_at_management_group_scope_request( - group_id: str, - deployment_name: str, - *, - top: Optional[int] = None, - **kwargs: Any + group_id: str, deployment_name: str, *, top: Optional[int] = None, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2020-06-01") # type: 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", "2020-06-01")) # type: str + accept = _headers.pop("Accept", "application/json") - accept = "application/json" # Construct URL - _url = kwargs.pop("template_url", "/providers/Microsoft.Management/managementGroups/{groupId}/providers/Microsoft.Resources/deployments/{deploymentName}/operations") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", + "/providers/Microsoft.Management/managementGroups/{groupId}/providers/Microsoft.Resources/deployments/{deploymentName}/operations", + ) # pylint: disable=line-too-long path_format_arguments = { - "groupId": _SERIALIZER.url("group_id", group_id, 'str', max_length=90, min_length=1), - "deploymentName": _SERIALIZER.url("deployment_name", deployment_name, 'str', max_length=64, min_length=1), + "groupId": _SERIALIZER.url("group_id", group_id, "str", max_length=90, min_length=1), + "deploymentName": _SERIALIZER.url("deployment_name", deployment_name, "str", max_length=64, min_length=1), } _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] if top is not None: - _query_parameters['$top'] = _SERIALIZER.query("top", top, 'int') - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["$top"] = _SERIALIZER.query("top", top, "int") + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') - - return HttpRequest( - method="GET", - url=_url, - params=_query_parameters, - headers=_header_parameters, - **kwargs - ) + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) def build_deployment_operations_get_at_subscription_scope_request( - deployment_name: str, - operation_id: str, - subscription_id: str, - **kwargs: Any + deployment_name: str, operation_id: str, subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2020-06-01") # type: 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", "2020-06-01")) # type: str + accept = _headers.pop("Accept", "application/json") - accept = "application/json" # Construct URL - _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/providers/Microsoft.Resources/deployments/{deploymentName}/operations/{operationId}") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/providers/Microsoft.Resources/deployments/{deploymentName}/operations/{operationId}", + ) # pylint: disable=line-too-long path_format_arguments = { - "deploymentName": _SERIALIZER.url("deployment_name", deployment_name, 'str', max_length=64, min_length=1), - "operationId": _SERIALIZER.url("operation_id", operation_id, 'str'), - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), + "deploymentName": _SERIALIZER.url("deployment_name", deployment_name, "str", max_length=64, min_length=1), + "operationId": _SERIALIZER.url("operation_id", operation_id, "str"), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), } _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') - - return HttpRequest( - method="GET", - url=_url, - params=_query_parameters, - headers=_header_parameters, - **kwargs - ) + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) def build_deployment_operations_list_at_subscription_scope_request( - deployment_name: str, - subscription_id: str, - *, - top: Optional[int] = None, - **kwargs: Any + deployment_name: str, subscription_id: str, *, top: Optional[int] = None, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2020-06-01") # type: 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", "2020-06-01")) # type: str + accept = _headers.pop("Accept", "application/json") - accept = "application/json" # Construct URL - _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/providers/Microsoft.Resources/deployments/{deploymentName}/operations") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/providers/Microsoft.Resources/deployments/{deploymentName}/operations", + ) # pylint: disable=line-too-long path_format_arguments = { - "deploymentName": _SERIALIZER.url("deployment_name", deployment_name, 'str', max_length=64, min_length=1), - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), + "deploymentName": _SERIALIZER.url("deployment_name", deployment_name, "str", max_length=64, min_length=1), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), } _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] if top is not None: - _query_parameters['$top'] = _SERIALIZER.query("top", top, 'int') - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["$top"] = _SERIALIZER.query("top", top, "int") + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') - - return HttpRequest( - method="GET", - url=_url, - params=_query_parameters, - headers=_header_parameters, - **kwargs - ) + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) def build_deployment_operations_get_request( - resource_group_name: str, - deployment_name: str, - operation_id: str, - subscription_id: str, - **kwargs: Any + resource_group_name: str, deployment_name: str, operation_id: str, subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2020-06-01") # type: 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", "2020-06-01")) # type: str + accept = _headers.pop("Accept", "application/json") - accept = "application/json" # Construct URL - _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/deployments/{deploymentName}/operations/{operationId}") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/deployments/{deploymentName}/operations/{operationId}", + ) # pylint: disable=line-too-long path_format_arguments = { - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1), - "deploymentName": _SERIALIZER.url("deployment_name", deployment_name, 'str', max_length=64, min_length=1), - "operationId": _SERIALIZER.url("operation_id", operation_id, 'str'), - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), + "resourceGroupName": _SERIALIZER.url( + "resource_group_name", resource_group_name, "str", max_length=90, min_length=1 + ), + "deploymentName": _SERIALIZER.url("deployment_name", deployment_name, "str", max_length=64, min_length=1), + "operationId": _SERIALIZER.url("operation_id", operation_id, "str"), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), } _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') - - return HttpRequest( - method="GET", - url=_url, - params=_query_parameters, - headers=_header_parameters, - **kwargs - ) + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) def build_deployment_operations_list_request( - resource_group_name: str, - deployment_name: str, - subscription_id: str, - *, - top: Optional[int] = None, - **kwargs: Any + resource_group_name: str, deployment_name: str, subscription_id: str, *, top: Optional[int] = None, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2020-06-01") # type: 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", "2020-06-01")) # type: str + accept = _headers.pop("Accept", "application/json") - accept = "application/json" # Construct URL - _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/deployments/{deploymentName}/operations") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/deployments/{deploymentName}/operations", + ) # pylint: disable=line-too-long path_format_arguments = { - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1), - "deploymentName": _SERIALIZER.url("deployment_name", deployment_name, 'str', max_length=64, min_length=1), - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), + "resourceGroupName": _SERIALIZER.url( + "resource_group_name", resource_group_name, "str", max_length=90, min_length=1 + ), + "deploymentName": _SERIALIZER.url("deployment_name", deployment_name, "str", max_length=64, min_length=1), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), } _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] if top is not None: - _query_parameters['$top'] = _SERIALIZER.query("top", top, 'int') - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["$top"] = _SERIALIZER.query("top", top, "int") + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') - - return HttpRequest( - method="GET", - url=_url, - params=_query_parameters, - headers=_header_parameters, - **kwargs - ) + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) -class Operations(object): - """Operations operations. - You should not instantiate this class directly. Instead, you should create a Client instance that - instantiates it for you and attaches it as an attribute. +class Operations: + """ + .. warning:: + **DO NOT** instantiate this class directly. - :ivar models: Alias to model classes used in this operation group. - :type models: ~azure.mgmt.resource.resources.v2020_06_01.models - :param client: Client for service requests. - :param config: Configuration of service client. - :param serializer: An object model serializer. - :param deserializer: An object model deserializer. + Instead, you should access the following operations through + :class:`~azure.mgmt.resource.resources.v2020_06_01.ResourceManagementClient`'s + :attr:`operations` attribute. """ models = _models - def __init__(self, client, config, serializer, deserializer): - self._client = client - self._serialize = serializer - self._deserialize = deserializer - self._config = config + def __init__(self, *args, **kwargs): + input_args = list(args) + self._client = input_args.pop(0) if input_args else kwargs.pop("client") + self._config = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") @distributed_trace - def list( - self, - **kwargs: Any - ) -> Iterable["_models.OperationListResult"]: + def list(self, **kwargs: Any) -> Iterable["_models.Operation"]: """Lists all of the available Microsoft.Resources REST API operations. :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either OperationListResult or the result of cls(response) + :return: An iterator like instance of either Operation or the result of cls(response) :rtype: - ~azure.core.paging.ItemPaged[~azure.mgmt.resource.resources.v2020_06_01.models.OperationListResult] - :raises: ~azure.core.exceptions.HttpResponseError + ~azure.core.paging.ItemPaged[~azure.mgmt.resource.resources.v2020_06_01.models.Operation] + :raises ~azure.core.exceptions.HttpResponseError: """ - api_version = kwargs.pop('api_version', "2020-06-01") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2020-06-01")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[_models.OperationListResult] - cls = kwargs.pop('cls', None) # type: ClsType["_models.OperationListResult"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) + def prepare_request(next_link=None): if not next_link: - + request = build_operations_list_request( api_version=api_version, - template_url=self.list.metadata['url'], + template_url=self.list.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore else: - - request = build_operations_list_request( - template_url=next_link, - ) + # make call to next link with the client's api-version + _parsed_next_link = urlparse(next_link) + _next_request_params = case_insensitive_dict(parse_qs(_parsed_next_link.query)) + _next_request_params["api-version"] = self._config.api_version + request = HttpRequest("GET", urljoin(next_link, _parsed_next_link.path), params=_next_request_params) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore request.method = "GET" return request @@ -3566,10 +2911,8 @@ def extract_data(pipeline_response): def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) response = pipeline_response.http_response @@ -3579,62 +2922,62 @@ def get_next(next_link=None): return pipeline_response + return ItemPaged(get_next, extract_data) + + list.metadata = {"url": "/providers/Microsoft.Resources/operations"} # type: ignore - return ItemPaged( - get_next, extract_data - ) - list.metadata = {'url': "/providers/Microsoft.Resources/operations"} # type: ignore -class DeploymentsOperations(object): # pylint: disable=too-many-public-methods - """DeploymentsOperations operations. - You should not instantiate this class directly. Instead, you should create a Client instance that - instantiates it for you and attaches it as an attribute. +class DeploymentsOperations: # pylint: disable=too-many-public-methods + """ + .. warning:: + **DO NOT** instantiate this class directly. - :ivar models: Alias to model classes used in this operation group. - :type models: ~azure.mgmt.resource.resources.v2020_06_01.models - :param client: Client for service requests. - :param config: Configuration of service client. - :param serializer: An object model serializer. - :param deserializer: An object model deserializer. + Instead, you should access the following operations through + :class:`~azure.mgmt.resource.resources.v2020_06_01.ResourceManagementClient`'s + :attr:`deployments` attribute. """ models = _models - def __init__(self, client, config, serializer, deserializer): - self._client = client - self._serialize = serializer - self._deserialize = deserializer - self._config = config + def __init__(self, *args, **kwargs): + input_args = list(args) + self._client = input_args.pop(0) if input_args else kwargs.pop("client") + self._config = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") def _delete_at_scope_initial( # pylint: disable=inconsistent-return-statements - self, - scope: str, - deployment_name: str, - **kwargs: Any + self, scope: str, deployment_name: str, **kwargs: Any ) -> None: - cls = kwargs.pop('cls', None) # type: ClsType[None] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + 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', "2020-06-01") # type: str + api_version = kwargs.pop("api_version", _params.pop("api-version", "2020-06-01")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[None] - - request = build_deployments_delete_at_scope_request_initial( + request = build_deployments_delete_at_scope_request( scope=scope, deployment_name=deployment_name, api_version=api_version, - template_url=self._delete_at_scope_initial.metadata['url'], + template_url=self._delete_at_scope_initial.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [202, 204]: @@ -3644,16 +2987,10 @@ def _delete_at_scope_initial( # pylint: disable=inconsistent-return-statements if cls: return cls(pipeline_response, None, {}) - _delete_at_scope_initial.metadata = {'url': "/{scope}/providers/Microsoft.Resources/deployments/{deploymentName}"} # type: ignore - + _delete_at_scope_initial.metadata = {"url": "/{scope}/providers/Microsoft.Resources/deployments/{deploymentName}"} # type: ignore @distributed_trace - def begin_delete_at_scope( # pylint: disable=inconsistent-return-statements - self, - scope: str, - deployment_name: str, - **kwargs: Any - ) -> LROPoller[None]: + def begin_delete_at_scope(self, scope: str, deployment_name: str, **kwargs: Any) -> LROPoller[None]: """Deletes a deployment from the deployment history. A template deployment that is currently running cannot be deleted. Deleting a template @@ -3664,9 +3001,9 @@ def begin_delete_at_scope( # pylint: disable=inconsistent-return-statements process finishes, the URI in the Location header returns a status of 204 on success. If the asynchronous request failed, the URI in the Location header returns an error-level status code. - :param scope: The resource scope. + :param scope: The resource scope. Required. :type scope: str - :param deployment_name: The name of the deployment. + :param deployment_name: The name of the deployment. Required. :type deployment_name: str :keyword callable cls: A custom type or function that will be passed the direct response :keyword str continuation_token: A continuation token to restart a poller from a saved state. @@ -3678,86 +3015,91 @@ def begin_delete_at_scope( # pylint: disable=inconsistent-return-statements Retry-After header is present. :return: An instance of LROPoller that returns either None or the result of cls(response) :rtype: ~azure.core.polling.LROPoller[None] - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - api_version = kwargs.pop('api_version', "2020-06-01") # type: str - polling = kwargs.pop('polling', True) # type: Union[bool, PollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType[None] - lro_delay = kwargs.pop( - 'polling_interval', - self._config.polling_interval - ) - cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2020-06-01")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[None] + polling = kwargs.pop("polling", True) # type: Union[bool, PollingMethod] + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token = kwargs.pop("continuation_token", None) # type: Optional[str] if cont_token is None: - raw_result = self._delete_at_scope_initial( + raw_result = self._delete_at_scope_initial( # type: ignore scope=scope, deployment_name=deployment_name, api_version=api_version, - cls=lambda x,y,z: x, + cls=lambda x, y, z: x, + headers=_headers, + params=_params, **kwargs ) - kwargs.pop('error_map', None) + kwargs.pop("error_map", None) - def get_long_running_output(pipeline_response): + def get_long_running_output(pipeline_response): # pylint: disable=inconsistent-return-statements if cls: return cls(pipeline_response, None, {}) - - if polling is True: polling_method = ARMPolling(lro_delay, **kwargs) - elif polling is False: polling_method = NoPolling() - else: polling_method = polling + if polling is True: + polling_method = cast(PollingMethod, ARMPolling(lro_delay, **kwargs)) # type: PollingMethod + elif polling is False: + polling_method = cast(PollingMethod, NoPolling()) + else: + polling_method = polling if cont_token: return LROPoller.from_continuation_token( polling_method=polling_method, continuation_token=cont_token, client=self._client, - deserialization_callback=get_long_running_output + deserialization_callback=get_long_running_output, ) return LROPoller(self._client, raw_result, get_long_running_output, polling_method) - begin_delete_at_scope.metadata = {'url': "/{scope}/providers/Microsoft.Resources/deployments/{deploymentName}"} # type: ignore + begin_delete_at_scope.metadata = {"url": "/{scope}/providers/Microsoft.Resources/deployments/{deploymentName}"} # type: ignore @distributed_trace - def check_existence_at_scope( - self, - scope: str, - deployment_name: str, - **kwargs: Any - ) -> bool: + def check_existence_at_scope(self, scope: str, deployment_name: str, **kwargs: Any) -> bool: """Checks whether the deployment exists. - :param scope: The resource scope. + :param scope: The resource scope. Required. :type scope: str - :param deployment_name: The name of the deployment. + :param deployment_name: The name of the deployment. Required. :type deployment_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: bool, or the result of cls(response) + :return: bool or the result of cls(response) :rtype: bool - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType[None] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + 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', "2020-06-01") # type: str + api_version = kwargs.pop("api_version", _params.pop("api-version", "2020-06-01")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[None] - request = build_deployments_check_existence_at_scope_request( scope=scope, deployment_name=deployment_name, api_version=api_version, - template_url=self.check_existence_at_scope.metadata['url'], + template_url=self.check_existence_at_scope.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [204, 404]: @@ -3768,43 +3110,52 @@ def check_existence_at_scope( return cls(pipeline_response, None, {}) return 200 <= response.status_code <= 299 - check_existence_at_scope.metadata = {'url': "/{scope}/providers/Microsoft.Resources/deployments/{deploymentName}"} # type: ignore - + check_existence_at_scope.metadata = {"url": "/{scope}/providers/Microsoft.Resources/deployments/{deploymentName}"} # type: ignore def _create_or_update_at_scope_initial( - self, - scope: str, - deployment_name: str, - parameters: "_models.Deployment", - **kwargs: Any - ) -> "_models.DeploymentExtended": - cls = kwargs.pop('cls', None) # type: ClsType["_models.DeploymentExtended"] + self, scope: str, deployment_name: str, parameters: Union[_models.Deployment, IO], **kwargs: Any + ) -> _models.DeploymentExtended: error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) - api_version = kwargs.pop('api_version', "2020-06-01") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - _json = self._serialize.body(parameters, 'Deployment') + api_version = kwargs.pop("api_version", _params.pop("api-version", "2020-06-01")) # type: str + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.DeploymentExtended] - request = build_deployments_create_or_update_at_scope_request_initial( + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(parameters, (IO, bytes)): + _content = parameters + else: + _json = self._serialize.body(parameters, "Deployment") + + request = build_deployments_create_or_update_at_scope_request( scope=scope, deployment_name=deployment_name, api_version=api_version, content_type=content_type, json=_json, - template_url=self._create_or_update_at_scope_initial.metadata['url'], + content=_content, + template_url=self._create_or_update_at_scope_initial.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200, 201]: @@ -3812,37 +3163,41 @@ def _create_or_update_at_scope_initial( raise HttpResponseError(response=response, error_format=ARMErrorFormat) if response.status_code == 200: - deserialized = self._deserialize('DeploymentExtended', pipeline_response) + deserialized = self._deserialize("DeploymentExtended", pipeline_response) if response.status_code == 201: - deserialized = self._deserialize('DeploymentExtended', pipeline_response) + deserialized = self._deserialize("DeploymentExtended", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - _create_or_update_at_scope_initial.metadata = {'url': "/{scope}/providers/Microsoft.Resources/deployments/{deploymentName}"} # type: ignore + _create_or_update_at_scope_initial.metadata = {"url": "/{scope}/providers/Microsoft.Resources/deployments/{deploymentName}"} # type: ignore - - @distributed_trace + @overload def begin_create_or_update_at_scope( self, scope: str, deployment_name: str, - parameters: "_models.Deployment", + parameters: _models.Deployment, + *, + content_type: str = "application/json", **kwargs: Any - ) -> LROPoller["_models.DeploymentExtended"]: + ) -> LROPoller[_models.DeploymentExtended]: """Deploys resources at a given scope. You can provide the template and parameters directly in the request or link to JSON files. - :param scope: The resource scope. + :param scope: The resource scope. Required. :type scope: str - :param deployment_name: The name of the deployment. + :param deployment_name: The name of the deployment. Required. :type deployment_name: str - :param parameters: Additional parameters supplied to the operation. + :param parameters: Additional parameters supplied to the operation. Required. :type parameters: ~azure.mgmt.resource.resources.v2020_06_01.models.Deployment + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str :keyword callable cls: A custom type or function that will be passed the direct response :keyword str continuation_token: A continuation token to restart a poller from a saved state. :keyword polling: By default, your polling method will be ARMPolling. Pass in False for this @@ -3855,114 +3210,179 @@ def begin_create_or_update_at_scope( cls(response) :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.resource.resources.v2020_06_01.models.DeploymentExtended] - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - api_version = kwargs.pop('api_version', "2020-06-01") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] - polling = kwargs.pop('polling', True) # type: Union[bool, PollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType["_models.DeploymentExtended"] - lro_delay = kwargs.pop( - 'polling_interval', - self._config.polling_interval - ) - cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] + + @overload + def begin_create_or_update_at_scope( + self, scope: str, deployment_name: str, parameters: IO, *, content_type: str = "application/json", **kwargs: Any + ) -> LROPoller[_models.DeploymentExtended]: + """Deploys resources at a given scope. + + You can provide the template and parameters directly in the request or link to JSON files. + + :param scope: The resource scope. Required. + :type scope: str + :param deployment_name: The name of the deployment. Required. + :type deployment_name: str + :param parameters: Additional parameters supplied to the operation. Required. + :type parameters: IO + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be ARMPolling. Pass in False for this + operation to not poll, or pass in your own initialized polling object for a personal polling + strategy. + :paramtype polling: bool or ~azure.core.polling.PollingMethod + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of LROPoller that returns either DeploymentExtended or the result of + cls(response) + :rtype: + ~azure.core.polling.LROPoller[~azure.mgmt.resource.resources.v2020_06_01.models.DeploymentExtended] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace + def begin_create_or_update_at_scope( + self, scope: str, deployment_name: str, parameters: Union[_models.Deployment, IO], **kwargs: Any + ) -> LROPoller[_models.DeploymentExtended]: + """Deploys resources at a given scope. + + You can provide the template and parameters directly in the request or link to JSON files. + + :param scope: The resource scope. Required. + :type scope: str + :param deployment_name: The name of the deployment. Required. + :type deployment_name: str + :param parameters: Additional parameters supplied to the operation. Is either a model type or a + IO type. Required. + :type parameters: ~azure.mgmt.resource.resources.v2020_06_01.models.Deployment or IO + :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. + Default value is None. + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be ARMPolling. Pass in False for this + operation to not poll, or pass in your own initialized polling object for a personal polling + strategy. + :paramtype polling: bool or ~azure.core.polling.PollingMethod + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of LROPoller that returns either DeploymentExtended or the result of + cls(response) + :rtype: + ~azure.core.polling.LROPoller[~azure.mgmt.resource.resources.v2020_06_01.models.DeploymentExtended] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _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", "2020-06-01")) # type: str + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.DeploymentExtended] + polling = kwargs.pop("polling", True) # type: Union[bool, PollingMethod] + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token = kwargs.pop("continuation_token", None) # type: Optional[str] if cont_token is None: - raw_result = self._create_or_update_at_scope_initial( + raw_result = self._create_or_update_at_scope_initial( # type: ignore scope=scope, deployment_name=deployment_name, parameters=parameters, api_version=api_version, content_type=content_type, - cls=lambda x,y,z: x, + cls=lambda x, y, z: x, + headers=_headers, + params=_params, **kwargs ) - kwargs.pop('error_map', None) + kwargs.pop("error_map", None) def get_long_running_output(pipeline_response): - response = pipeline_response.http_response - deserialized = self._deserialize('DeploymentExtended', pipeline_response) + deserialized = self._deserialize("DeploymentExtended", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - - if polling is True: polling_method = ARMPolling(lro_delay, **kwargs) - elif polling is False: polling_method = NoPolling() - else: polling_method = polling + if polling is True: + polling_method = cast(PollingMethod, ARMPolling(lro_delay, **kwargs)) # type: PollingMethod + elif polling is False: + polling_method = cast(PollingMethod, NoPolling()) + else: + polling_method = polling if cont_token: return LROPoller.from_continuation_token( polling_method=polling_method, continuation_token=cont_token, client=self._client, - deserialization_callback=get_long_running_output + deserialization_callback=get_long_running_output, ) return LROPoller(self._client, raw_result, get_long_running_output, polling_method) - begin_create_or_update_at_scope.metadata = {'url': "/{scope}/providers/Microsoft.Resources/deployments/{deploymentName}"} # type: ignore + begin_create_or_update_at_scope.metadata = {"url": "/{scope}/providers/Microsoft.Resources/deployments/{deploymentName}"} # type: ignore @distributed_trace - def get_at_scope( - self, - scope: str, - deployment_name: str, - **kwargs: Any - ) -> "_models.DeploymentExtended": + def get_at_scope(self, scope: str, deployment_name: str, **kwargs: Any) -> _models.DeploymentExtended: """Gets a deployment. - :param scope: The resource scope. + :param scope: The resource scope. Required. :type scope: str - :param deployment_name: The name of the deployment. + :param deployment_name: The name of the deployment. Required. :type deployment_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: DeploymentExtended, or the result of cls(response) + :return: DeploymentExtended or the result of cls(response) :rtype: ~azure.mgmt.resource.resources.v2020_06_01.models.DeploymentExtended - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.DeploymentExtended"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) - api_version = kwargs.pop('api_version', "2020-06-01") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2020-06-01")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[_models.DeploymentExtended] - request = build_deployments_get_at_scope_request( scope=scope, deployment_name=deployment_name, api_version=api_version, - template_url=self.get_at_scope.metadata['url'], + template_url=self.get_at_scope.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) - deserialized = self._deserialize('DeploymentExtended', pipeline_response) + deserialized = self._deserialize("DeploymentExtended", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - get_at_scope.metadata = {'url': "/{scope}/providers/Microsoft.Resources/deployments/{deploymentName}"} # type: ignore - + get_at_scope.metadata = {"url": "/{scope}/providers/Microsoft.Resources/deployments/{deploymentName}"} # type: ignore @distributed_trace def cancel_at_scope( # pylint: disable=inconsistent-return-statements - self, - scope: str, - deployment_name: str, - **kwargs: Any + self, scope: str, deployment_name: str, **kwargs: Any ) -> None: """Cancels a currently running template deployment. @@ -3971,38 +3391,44 @@ def cancel_at_scope( # pylint: disable=inconsistent-return-statements deployment stops the currently running template deployment and leaves the resources partially deployed. - :param scope: The resource scope. + :param scope: The resource scope. Required. :type scope: str - :param deployment_name: The name of the deployment. + :param deployment_name: The name of the deployment. Required. :type deployment_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: None, or the result of cls(response) + :return: None or the result of cls(response) :rtype: None - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType[None] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + 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', "2020-06-01") # type: str + api_version = kwargs.pop("api_version", _params.pop("api-version", "2020-06-01")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[None] - request = build_deployments_cancel_at_scope_request( scope=scope, deployment_name=deployment_name, api_version=api_version, - template_url=self.cancel_at_scope.metadata['url'], + template_url=self.cancel_at_scope.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [204]: @@ -4012,43 +3438,52 @@ def cancel_at_scope( # pylint: disable=inconsistent-return-statements if cls: return cls(pipeline_response, None, {}) - cancel_at_scope.metadata = {'url': "/{scope}/providers/Microsoft.Resources/deployments/{deploymentName}/cancel"} # type: ignore - + cancel_at_scope.metadata = {"url": "/{scope}/providers/Microsoft.Resources/deployments/{deploymentName}/cancel"} # type: ignore def _validate_at_scope_initial( - self, - scope: str, - deployment_name: str, - parameters: "_models.Deployment", - **kwargs: Any - ) -> Optional["_models.DeploymentValidateResult"]: - cls = kwargs.pop('cls', None) # type: ClsType[Optional["_models.DeploymentValidateResult"]] + self, scope: str, deployment_name: str, parameters: Union[_models.Deployment, IO], **kwargs: Any + ) -> Optional[_models.DeploymentValidateResult]: error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) - api_version = kwargs.pop('api_version', "2020-06-01") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - _json = self._serialize.body(parameters, 'Deployment') + api_version = kwargs.pop("api_version", _params.pop("api-version", "2020-06-01")) # type: str + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[Optional[_models.DeploymentValidateResult]] - request = build_deployments_validate_at_scope_request_initial( + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(parameters, (IO, bytes)): + _content = parameters + else: + _json = self._serialize.body(parameters, "Deployment") + + request = build_deployments_validate_at_scope_request( scope=scope, deployment_name=deployment_name, api_version=api_version, content_type=content_type, json=_json, - template_url=self._validate_at_scope_initial.metadata['url'], + content=_content, + template_url=self._validate_at_scope_initial.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200, 202, 400]: @@ -4057,36 +3492,40 @@ def _validate_at_scope_initial( deserialized = None if response.status_code == 200: - deserialized = self._deserialize('DeploymentValidateResult', pipeline_response) + deserialized = self._deserialize("DeploymentValidateResult", pipeline_response) if response.status_code == 400: - deserialized = self._deserialize('DeploymentValidateResult', pipeline_response) + deserialized = self._deserialize("DeploymentValidateResult", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - _validate_at_scope_initial.metadata = {'url': "/{scope}/providers/Microsoft.Resources/deployments/{deploymentName}/validate"} # type: ignore + _validate_at_scope_initial.metadata = {"url": "/{scope}/providers/Microsoft.Resources/deployments/{deploymentName}/validate"} # type: ignore - - @distributed_trace + @overload def begin_validate_at_scope( self, scope: str, deployment_name: str, - parameters: "_models.Deployment", + parameters: _models.Deployment, + *, + content_type: str = "application/json", **kwargs: Any - ) -> LROPoller["_models.DeploymentValidateResult"]: + ) -> LROPoller[_models.DeploymentValidateResult]: """Validates whether the specified template is syntactically correct and will be accepted by Azure Resource Manager.. - :param scope: The resource scope. + :param scope: The resource scope. Required. :type scope: str - :param deployment_name: The name of the deployment. + :param deployment_name: The name of the deployment. Required. :type deployment_name: str - :param parameters: Parameters to validate. + :param parameters: Parameters to validate. Required. :type parameters: ~azure.mgmt.resource.resources.v2020_06_01.models.Deployment + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str :keyword callable cls: A custom type or function that will be passed the direct response :keyword str continuation_token: A continuation token to restart a poller from a saved state. :keyword polling: By default, your polling method will be ARMPolling. Pass in False for this @@ -4099,119 +3538,182 @@ def begin_validate_at_scope( cls(response) :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.resource.resources.v2020_06_01.models.DeploymentValidateResult] - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - api_version = kwargs.pop('api_version', "2020-06-01") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] - polling = kwargs.pop('polling', True) # type: Union[bool, PollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType["_models.DeploymentValidateResult"] - lro_delay = kwargs.pop( - 'polling_interval', - self._config.polling_interval - ) - cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] + + @overload + def begin_validate_at_scope( + self, scope: str, deployment_name: str, parameters: IO, *, content_type: str = "application/json", **kwargs: Any + ) -> LROPoller[_models.DeploymentValidateResult]: + """Validates whether the specified template is syntactically correct and will be accepted by Azure + Resource Manager.. + + :param scope: The resource scope. Required. + :type scope: str + :param deployment_name: The name of the deployment. Required. + :type deployment_name: str + :param parameters: Parameters to validate. Required. + :type parameters: IO + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be ARMPolling. Pass in False for this + operation to not poll, or pass in your own initialized polling object for a personal polling + strategy. + :paramtype polling: bool or ~azure.core.polling.PollingMethod + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of LROPoller that returns either DeploymentValidateResult or the result of + cls(response) + :rtype: + ~azure.core.polling.LROPoller[~azure.mgmt.resource.resources.v2020_06_01.models.DeploymentValidateResult] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace + def begin_validate_at_scope( + self, scope: str, deployment_name: str, parameters: Union[_models.Deployment, IO], **kwargs: Any + ) -> LROPoller[_models.DeploymentValidateResult]: + """Validates whether the specified template is syntactically correct and will be accepted by Azure + Resource Manager.. + + :param scope: The resource scope. Required. + :type scope: str + :param deployment_name: The name of the deployment. Required. + :type deployment_name: str + :param parameters: Parameters to validate. Is either a model type or a IO type. Required. + :type parameters: ~azure.mgmt.resource.resources.v2020_06_01.models.Deployment or IO + :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. + Default value is None. + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be ARMPolling. Pass in False for this + operation to not poll, or pass in your own initialized polling object for a personal polling + strategy. + :paramtype polling: bool or ~azure.core.polling.PollingMethod + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of LROPoller that returns either DeploymentValidateResult or the result of + cls(response) + :rtype: + ~azure.core.polling.LROPoller[~azure.mgmt.resource.resources.v2020_06_01.models.DeploymentValidateResult] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _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", "2020-06-01")) # type: str + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.DeploymentValidateResult] + polling = kwargs.pop("polling", True) # type: Union[bool, PollingMethod] + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token = kwargs.pop("continuation_token", None) # type: Optional[str] if cont_token is None: - raw_result = self._validate_at_scope_initial( + raw_result = self._validate_at_scope_initial( # type: ignore scope=scope, deployment_name=deployment_name, parameters=parameters, api_version=api_version, content_type=content_type, - cls=lambda x,y,z: x, + cls=lambda x, y, z: x, + headers=_headers, + params=_params, **kwargs ) - kwargs.pop('error_map', None) + kwargs.pop("error_map", None) def get_long_running_output(pipeline_response): - response = pipeline_response.http_response - deserialized = self._deserialize('DeploymentValidateResult', pipeline_response) + deserialized = self._deserialize("DeploymentValidateResult", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - - if polling is True: polling_method = ARMPolling(lro_delay, **kwargs) - elif polling is False: polling_method = NoPolling() - else: polling_method = polling + if polling is True: + polling_method = cast(PollingMethod, ARMPolling(lro_delay, **kwargs)) # type: PollingMethod + elif polling is False: + polling_method = cast(PollingMethod, NoPolling()) + else: + polling_method = polling if cont_token: return LROPoller.from_continuation_token( polling_method=polling_method, continuation_token=cont_token, client=self._client, - deserialization_callback=get_long_running_output + deserialization_callback=get_long_running_output, ) return LROPoller(self._client, raw_result, get_long_running_output, polling_method) - begin_validate_at_scope.metadata = {'url': "/{scope}/providers/Microsoft.Resources/deployments/{deploymentName}/validate"} # type: ignore + begin_validate_at_scope.metadata = {"url": "/{scope}/providers/Microsoft.Resources/deployments/{deploymentName}/validate"} # type: ignore @distributed_trace def export_template_at_scope( - self, - scope: str, - deployment_name: str, - **kwargs: Any - ) -> "_models.DeploymentExportResult": + self, scope: str, deployment_name: str, **kwargs: Any + ) -> _models.DeploymentExportResult: """Exports the template used for specified deployment. - :param scope: The resource scope. + :param scope: The resource scope. Required. :type scope: str - :param deployment_name: The name of the deployment. + :param deployment_name: The name of the deployment. Required. :type deployment_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: DeploymentExportResult, or the result of cls(response) + :return: DeploymentExportResult or the result of cls(response) :rtype: ~azure.mgmt.resource.resources.v2020_06_01.models.DeploymentExportResult - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.DeploymentExportResult"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + 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', "2020-06-01") # type: str + api_version = kwargs.pop("api_version", _params.pop("api-version", "2020-06-01")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[_models.DeploymentExportResult] - request = build_deployments_export_template_at_scope_request( scope=scope, deployment_name=deployment_name, api_version=api_version, - template_url=self.export_template_at_scope.metadata['url'], + template_url=self.export_template_at_scope.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) - deserialized = self._deserialize('DeploymentExportResult', pipeline_response) + deserialized = self._deserialize("DeploymentExportResult", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - export_template_at_scope.metadata = {'url': "/{scope}/providers/Microsoft.Resources/deployments/{deploymentName}/exportTemplate"} # type: ignore - + export_template_at_scope.metadata = {"url": "/{scope}/providers/Microsoft.Resources/deployments/{deploymentName}/exportTemplate"} # type: ignore @distributed_trace def list_at_scope( - self, - scope: str, - filter: Optional[str] = None, - top: Optional[int] = None, - **kwargs: Any - ) -> Iterable["_models.DeploymentListResult"]: + self, scope: str, filter: Optional[str] = None, top: Optional[int] = None, **kwargs: Any + ) -> Iterable["_models.DeploymentExtended"]: """Get all the deployments at the given scope. - :param scope: The resource scope. + :param scope: The resource scope. Required. :type scope: str :param filter: The filter to apply on the operation. For example, you can use $filter=provisioningState eq '{state}'. Default value is None. @@ -4220,40 +3722,48 @@ def list_at_scope( value is None. :type top: int :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either DeploymentListResult or the result of - cls(response) + :return: An iterator like instance of either DeploymentExtended or the result of cls(response) :rtype: - ~azure.core.paging.ItemPaged[~azure.mgmt.resource.resources.v2020_06_01.models.DeploymentListResult] - :raises: ~azure.core.exceptions.HttpResponseError + ~azure.core.paging.ItemPaged[~azure.mgmt.resource.resources.v2020_06_01.models.DeploymentExtended] + :raises ~azure.core.exceptions.HttpResponseError: """ - api_version = kwargs.pop('api_version', "2020-06-01") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2020-06-01")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[_models.DeploymentListResult] - cls = kwargs.pop('cls', None) # type: ClsType["_models.DeploymentListResult"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) + def prepare_request(next_link=None): if not next_link: - + request = build_deployments_list_at_scope_request( scope=scope, - api_version=api_version, filter=filter, top=top, - template_url=self.list_at_scope.metadata['url'], + api_version=api_version, + template_url=self.list_at_scope.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore else: - - request = build_deployments_list_at_scope_request( - scope=scope, - template_url=next_link, - ) + # make call to next link with the client's api-version + _parsed_next_link = urlparse(next_link) + _next_request_params = case_insensitive_dict(parse_qs(_parsed_next_link.query)) + _next_request_params["api-version"] = self._config.api_version + request = HttpRequest("GET", urljoin(next_link, _parsed_next_link.path), params=_next_request_params) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore request.method = "GET" return request @@ -4267,10 +3777,8 @@ def extract_data(pipeline_response): def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) response = pipeline_response.http_response @@ -4280,39 +3788,41 @@ def get_next(next_link=None): return pipeline_response + return ItemPaged(get_next, extract_data) - return ItemPaged( - get_next, extract_data - ) - list_at_scope.metadata = {'url': "/{scope}/providers/Microsoft.Resources/deployments/"} # type: ignore + list_at_scope.metadata = {"url": "/{scope}/providers/Microsoft.Resources/deployments/"} # type: ignore def _delete_at_tenant_scope_initial( # pylint: disable=inconsistent-return-statements - self, - deployment_name: str, - **kwargs: Any + self, deployment_name: str, **kwargs: Any ) -> None: - cls = kwargs.pop('cls', None) # type: ClsType[None] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + 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', "2020-06-01") # type: str + api_version = kwargs.pop("api_version", _params.pop("api-version", "2020-06-01")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[None] - - request = build_deployments_delete_at_tenant_scope_request_initial( + request = build_deployments_delete_at_tenant_scope_request( deployment_name=deployment_name, api_version=api_version, - template_url=self._delete_at_tenant_scope_initial.metadata['url'], + template_url=self._delete_at_tenant_scope_initial.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [202, 204]: @@ -4322,15 +3832,10 @@ def _delete_at_tenant_scope_initial( # pylint: disable=inconsistent-return-stat if cls: return cls(pipeline_response, None, {}) - _delete_at_tenant_scope_initial.metadata = {'url': "/providers/Microsoft.Resources/deployments/{deploymentName}"} # type: ignore - + _delete_at_tenant_scope_initial.metadata = {"url": "/providers/Microsoft.Resources/deployments/{deploymentName}"} # type: ignore @distributed_trace - def begin_delete_at_tenant_scope( # pylint: disable=inconsistent-return-statements - self, - deployment_name: str, - **kwargs: Any - ) -> LROPoller[None]: + def begin_delete_at_tenant_scope(self, deployment_name: str, **kwargs: Any) -> LROPoller[None]: """Deletes a deployment from the deployment history. A template deployment that is currently running cannot be deleted. Deleting a template @@ -4341,7 +3846,7 @@ def begin_delete_at_tenant_scope( # pylint: disable=inconsistent-return-stateme process finishes, the URI in the Location header returns a status of 204 on success. If the asynchronous request failed, the URI in the Location header returns an error-level status code. - :param deployment_name: The name of the deployment. + :param deployment_name: The name of the deployment. Required. :type deployment_name: str :keyword callable cls: A custom type or function that will be passed the direct response :keyword str continuation_token: A continuation token to restart a poller from a saved state. @@ -4353,81 +3858,87 @@ def begin_delete_at_tenant_scope( # pylint: disable=inconsistent-return-stateme Retry-After header is present. :return: An instance of LROPoller that returns either None or the result of cls(response) :rtype: ~azure.core.polling.LROPoller[None] - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - api_version = kwargs.pop('api_version', "2020-06-01") # type: str - polling = kwargs.pop('polling', True) # type: Union[bool, PollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType[None] - lro_delay = kwargs.pop( - 'polling_interval', - self._config.polling_interval - ) - cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2020-06-01")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[None] + polling = kwargs.pop("polling", True) # type: Union[bool, PollingMethod] + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token = kwargs.pop("continuation_token", None) # type: Optional[str] if cont_token is None: - raw_result = self._delete_at_tenant_scope_initial( + raw_result = self._delete_at_tenant_scope_initial( # type: ignore deployment_name=deployment_name, api_version=api_version, - cls=lambda x,y,z: x, + cls=lambda x, y, z: x, + headers=_headers, + params=_params, **kwargs ) - kwargs.pop('error_map', None) + kwargs.pop("error_map", None) - def get_long_running_output(pipeline_response): + def get_long_running_output(pipeline_response): # pylint: disable=inconsistent-return-statements if cls: return cls(pipeline_response, None, {}) - - if polling is True: polling_method = ARMPolling(lro_delay, **kwargs) - elif polling is False: polling_method = NoPolling() - else: polling_method = polling + if polling is True: + polling_method = cast(PollingMethod, ARMPolling(lro_delay, **kwargs)) # type: PollingMethod + elif polling is False: + polling_method = cast(PollingMethod, NoPolling()) + else: + polling_method = polling if cont_token: return LROPoller.from_continuation_token( polling_method=polling_method, continuation_token=cont_token, client=self._client, - deserialization_callback=get_long_running_output + deserialization_callback=get_long_running_output, ) return LROPoller(self._client, raw_result, get_long_running_output, polling_method) - begin_delete_at_tenant_scope.metadata = {'url': "/providers/Microsoft.Resources/deployments/{deploymentName}"} # type: ignore + begin_delete_at_tenant_scope.metadata = {"url": "/providers/Microsoft.Resources/deployments/{deploymentName}"} # type: ignore @distributed_trace - def check_existence_at_tenant_scope( - self, - deployment_name: str, - **kwargs: Any - ) -> bool: + def check_existence_at_tenant_scope(self, deployment_name: str, **kwargs: Any) -> bool: """Checks whether the deployment exists. - :param deployment_name: The name of the deployment. + :param deployment_name: The name of the deployment. Required. :type deployment_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: bool, or the result of cls(response) + :return: bool or the result of cls(response) :rtype: bool - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType[None] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + 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', "2020-06-01") # type: str + api_version = kwargs.pop("api_version", _params.pop("api-version", "2020-06-01")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[None] - request = build_deployments_check_existence_at_tenant_scope_request( deployment_name=deployment_name, api_version=api_version, - template_url=self.check_existence_at_tenant_scope.metadata['url'], + template_url=self.check_existence_at_tenant_scope.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [204, 404]: @@ -4438,41 +3949,51 @@ def check_existence_at_tenant_scope( return cls(pipeline_response, None, {}) return 200 <= response.status_code <= 299 - check_existence_at_tenant_scope.metadata = {'url': "/providers/Microsoft.Resources/deployments/{deploymentName}"} # type: ignore - + check_existence_at_tenant_scope.metadata = {"url": "/providers/Microsoft.Resources/deployments/{deploymentName}"} # type: ignore def _create_or_update_at_tenant_scope_initial( - self, - deployment_name: str, - parameters: "_models.ScopedDeployment", - **kwargs: Any - ) -> "_models.DeploymentExtended": - cls = kwargs.pop('cls', None) # type: ClsType["_models.DeploymentExtended"] + self, deployment_name: str, parameters: Union[_models.ScopedDeployment, IO], **kwargs: Any + ) -> _models.DeploymentExtended: error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', "2020-06-01") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + api_version = kwargs.pop("api_version", _params.pop("api-version", "2020-06-01")) # type: str + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.DeploymentExtended] - _json = self._serialize.body(parameters, 'ScopedDeployment') + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(parameters, (IO, bytes)): + _content = parameters + else: + _json = self._serialize.body(parameters, "ScopedDeployment") - request = build_deployments_create_or_update_at_tenant_scope_request_initial( + request = build_deployments_create_or_update_at_tenant_scope_request( deployment_name=deployment_name, api_version=api_version, content_type=content_type, json=_json, - template_url=self._create_or_update_at_tenant_scope_initial.metadata['url'], + content=_content, + template_url=self._create_or_update_at_tenant_scope_initial.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200, 201]: @@ -4480,34 +4001,38 @@ def _create_or_update_at_tenant_scope_initial( raise HttpResponseError(response=response, error_format=ARMErrorFormat) if response.status_code == 200: - deserialized = self._deserialize('DeploymentExtended', pipeline_response) + deserialized = self._deserialize("DeploymentExtended", pipeline_response) if response.status_code == 201: - deserialized = self._deserialize('DeploymentExtended', pipeline_response) + deserialized = self._deserialize("DeploymentExtended", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - _create_or_update_at_tenant_scope_initial.metadata = {'url': "/providers/Microsoft.Resources/deployments/{deploymentName}"} # type: ignore - + _create_or_update_at_tenant_scope_initial.metadata = {"url": "/providers/Microsoft.Resources/deployments/{deploymentName}"} # type: ignore - @distributed_trace + @overload def begin_create_or_update_at_tenant_scope( self, deployment_name: str, - parameters: "_models.ScopedDeployment", + parameters: _models.ScopedDeployment, + *, + content_type: str = "application/json", **kwargs: Any - ) -> LROPoller["_models.DeploymentExtended"]: + ) -> LROPoller[_models.DeploymentExtended]: """Deploys resources at tenant scope. You can provide the template and parameters directly in the request or link to JSON files. - :param deployment_name: The name of the deployment. + :param deployment_name: The name of the deployment. Required. :type deployment_name: str - :param parameters: Additional parameters supplied to the operation. + :param parameters: Additional parameters supplied to the operation. Required. :type parameters: ~azure.mgmt.resource.resources.v2020_06_01.models.ScopedDeployment + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str :keyword callable cls: A custom type or function that will be passed the direct response :keyword str continuation_token: A continuation token to restart a poller from a saved state. :keyword polling: By default, your polling method will be ARMPolling. Pass in False for this @@ -4520,108 +4045,171 @@ def begin_create_or_update_at_tenant_scope( cls(response) :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.resource.resources.v2020_06_01.models.DeploymentExtended] - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - api_version = kwargs.pop('api_version', "2020-06-01") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] - polling = kwargs.pop('polling', True) # type: Union[bool, PollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType["_models.DeploymentExtended"] - lro_delay = kwargs.pop( - 'polling_interval', - self._config.polling_interval - ) - cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] - if cont_token is None: - raw_result = self._create_or_update_at_tenant_scope_initial( - deployment_name=deployment_name, - parameters=parameters, - api_version=api_version, - content_type=content_type, - cls=lambda x,y,z: x, - **kwargs - ) - kwargs.pop('error_map', None) - def get_long_running_output(pipeline_response): - response = pipeline_response.http_response - deserialized = self._deserialize('DeploymentExtended', pipeline_response) - if cls: - return cls(pipeline_response, deserialized, {}) - return deserialized + @overload + def begin_create_or_update_at_tenant_scope( + self, deployment_name: str, parameters: IO, *, content_type: str = "application/json", **kwargs: Any + ) -> LROPoller[_models.DeploymentExtended]: + """Deploys resources at tenant scope. + You can provide the template and parameters directly in the request or link to JSON files. - if polling is True: polling_method = ARMPolling(lro_delay, **kwargs) - elif polling is False: polling_method = NoPolling() - else: polling_method = polling - if cont_token: - return LROPoller.from_continuation_token( - polling_method=polling_method, - continuation_token=cont_token, - client=self._client, - deserialization_callback=get_long_running_output + :param deployment_name: The name of the deployment. Required. + :type deployment_name: str + :param parameters: Additional parameters supplied to the operation. Required. + :type parameters: IO + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be ARMPolling. Pass in False for this + operation to not poll, or pass in your own initialized polling object for a personal polling + strategy. + :paramtype polling: bool or ~azure.core.polling.PollingMethod + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of LROPoller that returns either DeploymentExtended or the result of + cls(response) + :rtype: + ~azure.core.polling.LROPoller[~azure.mgmt.resource.resources.v2020_06_01.models.DeploymentExtended] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace + def begin_create_or_update_at_tenant_scope( + self, deployment_name: str, parameters: Union[_models.ScopedDeployment, IO], **kwargs: Any + ) -> LROPoller[_models.DeploymentExtended]: + """Deploys resources at tenant scope. + + You can provide the template and parameters directly in the request or link to JSON files. + + :param deployment_name: The name of the deployment. Required. + :type deployment_name: str + :param parameters: Additional parameters supplied to the operation. Is either a model type or a + IO type. Required. + :type parameters: ~azure.mgmt.resource.resources.v2020_06_01.models.ScopedDeployment or IO + :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. + Default value is None. + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be ARMPolling. Pass in False for this + operation to not poll, or pass in your own initialized polling object for a personal polling + strategy. + :paramtype polling: bool or ~azure.core.polling.PollingMethod + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of LROPoller that returns either DeploymentExtended or the result of + cls(response) + :rtype: + ~azure.core.polling.LROPoller[~azure.mgmt.resource.resources.v2020_06_01.models.DeploymentExtended] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _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", "2020-06-01")) # type: str + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.DeploymentExtended] + polling = kwargs.pop("polling", True) # type: Union[bool, PollingMethod] + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token = kwargs.pop("continuation_token", None) # type: Optional[str] + if cont_token is None: + raw_result = self._create_or_update_at_tenant_scope_initial( # type: ignore + deployment_name=deployment_name, + parameters=parameters, + api_version=api_version, + content_type=content_type, + cls=lambda x, y, z: x, + headers=_headers, + params=_params, + **kwargs + ) + kwargs.pop("error_map", None) + + def get_long_running_output(pipeline_response): + deserialized = self._deserialize("DeploymentExtended", pipeline_response) + if cls: + return cls(pipeline_response, deserialized, {}) + return deserialized + + if polling is True: + polling_method = cast(PollingMethod, ARMPolling(lro_delay, **kwargs)) # type: PollingMethod + elif polling is False: + polling_method = cast(PollingMethod, NoPolling()) + else: + polling_method = polling + if cont_token: + return LROPoller.from_continuation_token( + polling_method=polling_method, + continuation_token=cont_token, + client=self._client, + deserialization_callback=get_long_running_output, ) return LROPoller(self._client, raw_result, get_long_running_output, polling_method) - begin_create_or_update_at_tenant_scope.metadata = {'url': "/providers/Microsoft.Resources/deployments/{deploymentName}"} # type: ignore + begin_create_or_update_at_tenant_scope.metadata = {"url": "/providers/Microsoft.Resources/deployments/{deploymentName}"} # type: ignore @distributed_trace - def get_at_tenant_scope( - self, - deployment_name: str, - **kwargs: Any - ) -> "_models.DeploymentExtended": + def get_at_tenant_scope(self, deployment_name: str, **kwargs: Any) -> _models.DeploymentExtended: """Gets a deployment. - :param deployment_name: The name of the deployment. + :param deployment_name: The name of the deployment. Required. :type deployment_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: DeploymentExtended, or the result of cls(response) + :return: DeploymentExtended or the result of cls(response) :rtype: ~azure.mgmt.resource.resources.v2020_06_01.models.DeploymentExtended - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.DeploymentExtended"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) - api_version = kwargs.pop('api_version', "2020-06-01") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2020-06-01")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[_models.DeploymentExtended] - request = build_deployments_get_at_tenant_scope_request( deployment_name=deployment_name, api_version=api_version, - template_url=self.get_at_tenant_scope.metadata['url'], + template_url=self.get_at_tenant_scope.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) - deserialized = self._deserialize('DeploymentExtended', pipeline_response) + deserialized = self._deserialize("DeploymentExtended", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - get_at_tenant_scope.metadata = {'url': "/providers/Microsoft.Resources/deployments/{deploymentName}"} # type: ignore - + get_at_tenant_scope.metadata = {"url": "/providers/Microsoft.Resources/deployments/{deploymentName}"} # type: ignore @distributed_trace def cancel_at_tenant_scope( # pylint: disable=inconsistent-return-statements - self, - deployment_name: str, - **kwargs: Any + self, deployment_name: str, **kwargs: Any ) -> None: """Cancels a currently running template deployment. @@ -4630,35 +4218,41 @@ def cancel_at_tenant_scope( # pylint: disable=inconsistent-return-statements deployment stops the currently running template deployment and leaves the resources partially deployed. - :param deployment_name: The name of the deployment. + :param deployment_name: The name of the deployment. Required. :type deployment_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: None, or the result of cls(response) + :return: None or the result of cls(response) :rtype: None - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType[None] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) - api_version = kwargs.pop('api_version', "2020-06-01") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2020-06-01")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[None] - request = build_deployments_cancel_at_tenant_scope_request( deployment_name=deployment_name, api_version=api_version, - template_url=self.cancel_at_tenant_scope.metadata['url'], + template_url=self.cancel_at_tenant_scope.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [204]: @@ -4668,41 +4262,51 @@ def cancel_at_tenant_scope( # pylint: disable=inconsistent-return-statements if cls: return cls(pipeline_response, None, {}) - cancel_at_tenant_scope.metadata = {'url': "/providers/Microsoft.Resources/deployments/{deploymentName}/cancel"} # type: ignore - + cancel_at_tenant_scope.metadata = {"url": "/providers/Microsoft.Resources/deployments/{deploymentName}/cancel"} # type: ignore def _validate_at_tenant_scope_initial( - self, - deployment_name: str, - parameters: "_models.ScopedDeployment", - **kwargs: Any - ) -> Optional["_models.DeploymentValidateResult"]: - cls = kwargs.pop('cls', None) # type: ClsType[Optional["_models.DeploymentValidateResult"]] + self, deployment_name: str, parameters: Union[_models.ScopedDeployment, IO], **kwargs: Any + ) -> Optional[_models.DeploymentValidateResult]: error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) - api_version = kwargs.pop('api_version', "2020-06-01") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - _json = self._serialize.body(parameters, 'ScopedDeployment') + api_version = kwargs.pop("api_version", _params.pop("api-version", "2020-06-01")) # type: str + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[Optional[_models.DeploymentValidateResult]] - request = build_deployments_validate_at_tenant_scope_request_initial( + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(parameters, (IO, bytes)): + _content = parameters + else: + _json = self._serialize.body(parameters, "ScopedDeployment") + + request = build_deployments_validate_at_tenant_scope_request( deployment_name=deployment_name, api_version=api_version, content_type=content_type, json=_json, - template_url=self._validate_at_tenant_scope_initial.metadata['url'], + content=_content, + template_url=self._validate_at_tenant_scope_initial.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200, 202, 400]: @@ -4711,33 +4315,37 @@ def _validate_at_tenant_scope_initial( deserialized = None if response.status_code == 200: - deserialized = self._deserialize('DeploymentValidateResult', pipeline_response) + deserialized = self._deserialize("DeploymentValidateResult", pipeline_response) if response.status_code == 400: - deserialized = self._deserialize('DeploymentValidateResult', pipeline_response) + deserialized = self._deserialize("DeploymentValidateResult", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - _validate_at_tenant_scope_initial.metadata = {'url': "/providers/Microsoft.Resources/deployments/{deploymentName}/validate"} # type: ignore + _validate_at_tenant_scope_initial.metadata = {"url": "/providers/Microsoft.Resources/deployments/{deploymentName}/validate"} # type: ignore - - @distributed_trace + @overload def begin_validate_at_tenant_scope( self, deployment_name: str, - parameters: "_models.ScopedDeployment", + parameters: _models.ScopedDeployment, + *, + content_type: str = "application/json", **kwargs: Any - ) -> LROPoller["_models.DeploymentValidateResult"]: + ) -> LROPoller[_models.DeploymentValidateResult]: """Validates whether the specified template is syntactically correct and will be accepted by Azure Resource Manager.. - :param deployment_name: The name of the deployment. + :param deployment_name: The name of the deployment. Required. :type deployment_name: str - :param parameters: Parameters to validate. + :param parameters: Parameters to validate. Required. :type parameters: ~azure.mgmt.resource.resources.v2020_06_01.models.ScopedDeployment + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str :keyword callable cls: A custom type or function that will be passed the direct response :keyword str continuation_token: A continuation token to restart a poller from a saved state. :keyword polling: By default, your polling method will be ARMPolling. Pass in False for this @@ -4750,82 +4358,154 @@ def begin_validate_at_tenant_scope( cls(response) :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.resource.resources.v2020_06_01.models.DeploymentValidateResult] - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - api_version = kwargs.pop('api_version', "2020-06-01") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] - polling = kwargs.pop('polling', True) # type: Union[bool, PollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType["_models.DeploymentValidateResult"] - lro_delay = kwargs.pop( - 'polling_interval', - self._config.polling_interval - ) - cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] + + @overload + def begin_validate_at_tenant_scope( + self, deployment_name: str, parameters: IO, *, content_type: str = "application/json", **kwargs: Any + ) -> LROPoller[_models.DeploymentValidateResult]: + """Validates whether the specified template is syntactically correct and will be accepted by Azure + Resource Manager.. + + :param deployment_name: The name of the deployment. Required. + :type deployment_name: str + :param parameters: Parameters to validate. Required. + :type parameters: IO + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be ARMPolling. Pass in False for this + operation to not poll, or pass in your own initialized polling object for a personal polling + strategy. + :paramtype polling: bool or ~azure.core.polling.PollingMethod + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of LROPoller that returns either DeploymentValidateResult or the result of + cls(response) + :rtype: + ~azure.core.polling.LROPoller[~azure.mgmt.resource.resources.v2020_06_01.models.DeploymentValidateResult] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace + def begin_validate_at_tenant_scope( + self, deployment_name: str, parameters: Union[_models.ScopedDeployment, IO], **kwargs: Any + ) -> LROPoller[_models.DeploymentValidateResult]: + """Validates whether the specified template is syntactically correct and will be accepted by Azure + Resource Manager.. + + :param deployment_name: The name of the deployment. Required. + :type deployment_name: str + :param parameters: Parameters to validate. Is either a model type or a IO type. Required. + :type parameters: ~azure.mgmt.resource.resources.v2020_06_01.models.ScopedDeployment or IO + :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. + Default value is None. + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be ARMPolling. Pass in False for this + operation to not poll, or pass in your own initialized polling object for a personal polling + strategy. + :paramtype polling: bool or ~azure.core.polling.PollingMethod + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of LROPoller that returns either DeploymentValidateResult or the result of + cls(response) + :rtype: + ~azure.core.polling.LROPoller[~azure.mgmt.resource.resources.v2020_06_01.models.DeploymentValidateResult] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _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", "2020-06-01")) # type: str + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.DeploymentValidateResult] + polling = kwargs.pop("polling", True) # type: Union[bool, PollingMethod] + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token = kwargs.pop("continuation_token", None) # type: Optional[str] if cont_token is None: - raw_result = self._validate_at_tenant_scope_initial( + raw_result = self._validate_at_tenant_scope_initial( # type: ignore deployment_name=deployment_name, parameters=parameters, api_version=api_version, content_type=content_type, - cls=lambda x,y,z: x, + cls=lambda x, y, z: x, + headers=_headers, + params=_params, **kwargs ) - kwargs.pop('error_map', None) + kwargs.pop("error_map", None) def get_long_running_output(pipeline_response): - response = pipeline_response.http_response - deserialized = self._deserialize('DeploymentValidateResult', pipeline_response) + deserialized = self._deserialize("DeploymentValidateResult", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - - if polling is True: polling_method = ARMPolling(lro_delay, **kwargs) - elif polling is False: polling_method = NoPolling() - else: polling_method = polling + if polling is True: + polling_method = cast(PollingMethod, ARMPolling(lro_delay, **kwargs)) # type: PollingMethod + elif polling is False: + polling_method = cast(PollingMethod, NoPolling()) + else: + polling_method = polling if cont_token: return LROPoller.from_continuation_token( polling_method=polling_method, continuation_token=cont_token, client=self._client, - deserialization_callback=get_long_running_output + deserialization_callback=get_long_running_output, ) return LROPoller(self._client, raw_result, get_long_running_output, polling_method) - begin_validate_at_tenant_scope.metadata = {'url': "/providers/Microsoft.Resources/deployments/{deploymentName}/validate"} # type: ignore + begin_validate_at_tenant_scope.metadata = {"url": "/providers/Microsoft.Resources/deployments/{deploymentName}/validate"} # type: ignore def _what_if_at_tenant_scope_initial( - self, - deployment_name: str, - parameters: "_models.ScopedDeploymentWhatIf", - **kwargs: Any - ) -> Optional["_models.WhatIfOperationResult"]: - cls = kwargs.pop('cls', None) # type: ClsType[Optional["_models.WhatIfOperationResult"]] + self, deployment_name: str, parameters: Union[_models.ScopedDeploymentWhatIf, IO], **kwargs: Any + ) -> Optional[_models.WhatIfOperationResult]: error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) - api_version = kwargs.pop('api_version', "2020-06-01") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - _json = self._serialize.body(parameters, 'ScopedDeploymentWhatIf') + api_version = kwargs.pop("api_version", _params.pop("api-version", "2020-06-01")) # type: str + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[Optional[_models.WhatIfOperationResult]] - request = build_deployments_what_if_at_tenant_scope_request_initial( + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(parameters, (IO, bytes)): + _content = parameters + else: + _json = self._serialize.body(parameters, "ScopedDeploymentWhatIf") + + request = build_deployments_what_if_at_tenant_scope_request( deployment_name=deployment_name, api_version=api_version, content_type=content_type, json=_json, - template_url=self._what_if_at_tenant_scope_initial.metadata['url'], + content=_content, + template_url=self._what_if_at_tenant_scope_initial.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200, 202]: @@ -4835,35 +4515,38 @@ def _what_if_at_tenant_scope_initial( deserialized = None response_headers = {} if response.status_code == 200: - deserialized = self._deserialize('WhatIfOperationResult', pipeline_response) + deserialized = self._deserialize("WhatIfOperationResult", pipeline_response) if response.status_code == 202: - response_headers['Location']=self._deserialize('str', response.headers.get('Location')) - response_headers['Retry-After']=self._deserialize('str', response.headers.get('Retry-After')) - + response_headers["Location"] = self._deserialize("str", response.headers.get("Location")) + response_headers["Retry-After"] = self._deserialize("str", response.headers.get("Retry-After")) if cls: return cls(pipeline_response, deserialized, response_headers) return deserialized - _what_if_at_tenant_scope_initial.metadata = {'url': "/providers/Microsoft.Resources/deployments/{deploymentName}/whatIf"} # type: ignore + _what_if_at_tenant_scope_initial.metadata = {"url": "/providers/Microsoft.Resources/deployments/{deploymentName}/whatIf"} # type: ignore - - @distributed_trace + @overload def begin_what_if_at_tenant_scope( self, deployment_name: str, - parameters: "_models.ScopedDeploymentWhatIf", + parameters: _models.ScopedDeploymentWhatIf, + *, + content_type: str = "application/json", **kwargs: Any - ) -> LROPoller["_models.WhatIfOperationResult"]: + ) -> LROPoller[_models.WhatIfOperationResult]: """Returns changes that will be made by the deployment if executed at the scope of the tenant group. - :param deployment_name: The name of the deployment. + :param deployment_name: The name of the deployment. Required. :type deployment_name: str - :param parameters: Parameters to validate. + :param parameters: Parameters to validate. Required. :type parameters: ~azure.mgmt.resource.resources.v2020_06_01.models.ScopedDeploymentWhatIf + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str :keyword callable cls: A custom type or function that will be passed the direct response :keyword str continuation_token: A continuation token to restart a poller from a saved state. :keyword polling: By default, your polling method will be ARMPolling. Pass in False for this @@ -4876,110 +4559,172 @@ def begin_what_if_at_tenant_scope( cls(response) :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.resource.resources.v2020_06_01.models.WhatIfOperationResult] - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - api_version = kwargs.pop('api_version', "2020-06-01") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] - polling = kwargs.pop('polling', True) # type: Union[bool, PollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType["_models.WhatIfOperationResult"] - lro_delay = kwargs.pop( - 'polling_interval', - self._config.polling_interval - ) - cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] + + @overload + def begin_what_if_at_tenant_scope( + self, deployment_name: str, parameters: IO, *, content_type: str = "application/json", **kwargs: Any + ) -> LROPoller[_models.WhatIfOperationResult]: + """Returns changes that will be made by the deployment if executed at the scope of the tenant + group. + + :param deployment_name: The name of the deployment. Required. + :type deployment_name: str + :param parameters: Parameters to validate. Required. + :type parameters: IO + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be ARMPolling. Pass in False for this + operation to not poll, or pass in your own initialized polling object for a personal polling + strategy. + :paramtype polling: bool or ~azure.core.polling.PollingMethod + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of LROPoller that returns either WhatIfOperationResult or the result of + cls(response) + :rtype: + ~azure.core.polling.LROPoller[~azure.mgmt.resource.resources.v2020_06_01.models.WhatIfOperationResult] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace + def begin_what_if_at_tenant_scope( + self, deployment_name: str, parameters: Union[_models.ScopedDeploymentWhatIf, IO], **kwargs: Any + ) -> LROPoller[_models.WhatIfOperationResult]: + """Returns changes that will be made by the deployment if executed at the scope of the tenant + group. + + :param deployment_name: The name of the deployment. Required. + :type deployment_name: str + :param parameters: Parameters to validate. Is either a model type or a IO type. Required. + :type parameters: ~azure.mgmt.resource.resources.v2020_06_01.models.ScopedDeploymentWhatIf or + IO + :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. + Default value is None. + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be ARMPolling. Pass in False for this + operation to not poll, or pass in your own initialized polling object for a personal polling + strategy. + :paramtype polling: bool or ~azure.core.polling.PollingMethod + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of LROPoller that returns either WhatIfOperationResult or the result of + cls(response) + :rtype: + ~azure.core.polling.LROPoller[~azure.mgmt.resource.resources.v2020_06_01.models.WhatIfOperationResult] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _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", "2020-06-01")) # type: str + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.WhatIfOperationResult] + polling = kwargs.pop("polling", True) # type: Union[bool, PollingMethod] + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token = kwargs.pop("continuation_token", None) # type: Optional[str] if cont_token is None: - raw_result = self._what_if_at_tenant_scope_initial( + raw_result = self._what_if_at_tenant_scope_initial( # type: ignore deployment_name=deployment_name, parameters=parameters, api_version=api_version, content_type=content_type, - cls=lambda x,y,z: x, + cls=lambda x, y, z: x, + headers=_headers, + params=_params, **kwargs ) - kwargs.pop('error_map', None) + kwargs.pop("error_map", None) def get_long_running_output(pipeline_response): - response = pipeline_response.http_response - deserialized = self._deserialize('WhatIfOperationResult', pipeline_response) + deserialized = self._deserialize("WhatIfOperationResult", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - - if polling is True: polling_method = ARMPolling(lro_delay, lro_options={'final-state-via': 'location'}, **kwargs) - elif polling is False: polling_method = NoPolling() - else: polling_method = polling + if polling is True: + polling_method = cast( + PollingMethod, ARMPolling(lro_delay, lro_options={"final-state-via": "location"}, **kwargs) + ) # type: PollingMethod + elif polling is False: + polling_method = cast(PollingMethod, NoPolling()) + else: + polling_method = polling if cont_token: return LROPoller.from_continuation_token( polling_method=polling_method, continuation_token=cont_token, client=self._client, - deserialization_callback=get_long_running_output + deserialization_callback=get_long_running_output, ) return LROPoller(self._client, raw_result, get_long_running_output, polling_method) - begin_what_if_at_tenant_scope.metadata = {'url': "/providers/Microsoft.Resources/deployments/{deploymentName}/whatIf"} # type: ignore + begin_what_if_at_tenant_scope.metadata = {"url": "/providers/Microsoft.Resources/deployments/{deploymentName}/whatIf"} # type: ignore @distributed_trace - def export_template_at_tenant_scope( - self, - deployment_name: str, - **kwargs: Any - ) -> "_models.DeploymentExportResult": + def export_template_at_tenant_scope(self, deployment_name: str, **kwargs: Any) -> _models.DeploymentExportResult: """Exports the template used for specified deployment. - :param deployment_name: The name of the deployment. + :param deployment_name: The name of the deployment. Required. :type deployment_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: DeploymentExportResult, or the result of cls(response) + :return: DeploymentExportResult or the result of cls(response) :rtype: ~azure.mgmt.resource.resources.v2020_06_01.models.DeploymentExportResult - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.DeploymentExportResult"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) - api_version = kwargs.pop('api_version', "2020-06-01") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2020-06-01")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[_models.DeploymentExportResult] - request = build_deployments_export_template_at_tenant_scope_request( deployment_name=deployment_name, api_version=api_version, - template_url=self.export_template_at_tenant_scope.metadata['url'], + template_url=self.export_template_at_tenant_scope.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) - deserialized = self._deserialize('DeploymentExportResult', pipeline_response) + deserialized = self._deserialize("DeploymentExportResult", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - export_template_at_tenant_scope.metadata = {'url': "/providers/Microsoft.Resources/deployments/{deploymentName}/exportTemplate"} # type: ignore - + export_template_at_tenant_scope.metadata = {"url": "/providers/Microsoft.Resources/deployments/{deploymentName}/exportTemplate"} # type: ignore @distributed_trace def list_at_tenant_scope( - self, - filter: Optional[str] = None, - top: Optional[int] = None, - **kwargs: Any - ) -> Iterable["_models.DeploymentListResult"]: + self, filter: Optional[str] = None, top: Optional[int] = None, **kwargs: Any + ) -> Iterable["_models.DeploymentExtended"]: """Get all the deployments at the tenant scope. :param filter: The filter to apply on the operation. For example, you can use @@ -4989,38 +4734,47 @@ def list_at_tenant_scope( value is None. :type top: int :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either DeploymentListResult or the result of - cls(response) + :return: An iterator like instance of either DeploymentExtended or the result of cls(response) :rtype: - ~azure.core.paging.ItemPaged[~azure.mgmt.resource.resources.v2020_06_01.models.DeploymentListResult] - :raises: ~azure.core.exceptions.HttpResponseError + ~azure.core.paging.ItemPaged[~azure.mgmt.resource.resources.v2020_06_01.models.DeploymentExtended] + :raises ~azure.core.exceptions.HttpResponseError: """ - api_version = kwargs.pop('api_version', "2020-06-01") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2020-06-01")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[_models.DeploymentListResult] - cls = kwargs.pop('cls', None) # type: ClsType["_models.DeploymentListResult"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) + def prepare_request(next_link=None): if not next_link: - + request = build_deployments_list_at_tenant_scope_request( - api_version=api_version, filter=filter, top=top, - template_url=self.list_at_tenant_scope.metadata['url'], + api_version=api_version, + template_url=self.list_at_tenant_scope.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore else: - - request = build_deployments_list_at_tenant_scope_request( - template_url=next_link, - ) + # make call to next link with the client's api-version + _parsed_next_link = urlparse(next_link) + _next_request_params = case_insensitive_dict(parse_qs(_parsed_next_link.query)) + _next_request_params["api-version"] = self._config.api_version + request = HttpRequest("GET", urljoin(next_link, _parsed_next_link.path), params=_next_request_params) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore request.method = "GET" return request @@ -5034,10 +4788,8 @@ def extract_data(pipeline_response): def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) response = pipeline_response.http_response @@ -5047,41 +4799,42 @@ def get_next(next_link=None): return pipeline_response + return ItemPaged(get_next, extract_data) - return ItemPaged( - get_next, extract_data - ) - list_at_tenant_scope.metadata = {'url': "/providers/Microsoft.Resources/deployments/"} # type: ignore + list_at_tenant_scope.metadata = {"url": "/providers/Microsoft.Resources/deployments/"} # type: ignore def _delete_at_management_group_scope_initial( # pylint: disable=inconsistent-return-statements - self, - group_id: str, - deployment_name: str, - **kwargs: Any + self, group_id: str, deployment_name: str, **kwargs: Any ) -> None: - cls = kwargs.pop('cls', None) # type: ClsType[None] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + 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', "2020-06-01") # type: str + api_version = kwargs.pop("api_version", _params.pop("api-version", "2020-06-01")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[None] - - request = build_deployments_delete_at_management_group_scope_request_initial( + request = build_deployments_delete_at_management_group_scope_request( group_id=group_id, deployment_name=deployment_name, api_version=api_version, - template_url=self._delete_at_management_group_scope_initial.metadata['url'], + template_url=self._delete_at_management_group_scope_initial.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [202, 204]: @@ -5091,15 +4844,11 @@ def _delete_at_management_group_scope_initial( # pylint: disable=inconsistent-r if cls: return cls(pipeline_response, None, {}) - _delete_at_management_group_scope_initial.metadata = {'url': "/providers/Microsoft.Management/managementGroups/{groupId}/providers/Microsoft.Resources/deployments/{deploymentName}"} # type: ignore - + _delete_at_management_group_scope_initial.metadata = {"url": "/providers/Microsoft.Management/managementGroups/{groupId}/providers/Microsoft.Resources/deployments/{deploymentName}"} # type: ignore @distributed_trace - def begin_delete_at_management_group_scope( # pylint: disable=inconsistent-return-statements - self, - group_id: str, - deployment_name: str, - **kwargs: Any + def begin_delete_at_management_group_scope( + self, group_id: str, deployment_name: str, **kwargs: Any ) -> LROPoller[None]: """Deletes a deployment from the deployment history. @@ -5111,9 +4860,9 @@ def begin_delete_at_management_group_scope( # pylint: disable=inconsistent-retu process finishes, the URI in the Location header returns a status of 204 on success. If the asynchronous request failed, the URI in the Location header returns an error-level status code. - :param group_id: The management group ID. + :param group_id: The management group ID. Required. :type group_id: str - :param deployment_name: The name of the deployment. + :param deployment_name: The name of the deployment. Required. :type deployment_name: str :keyword callable cls: A custom type or function that will be passed the direct response :keyword str continuation_token: A continuation token to restart a poller from a saved state. @@ -5125,86 +4874,91 @@ def begin_delete_at_management_group_scope( # pylint: disable=inconsistent-retu Retry-After header is present. :return: An instance of LROPoller that returns either None or the result of cls(response) :rtype: ~azure.core.polling.LROPoller[None] - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - api_version = kwargs.pop('api_version', "2020-06-01") # type: str - polling = kwargs.pop('polling', True) # type: Union[bool, PollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType[None] - lro_delay = kwargs.pop( - 'polling_interval', - self._config.polling_interval - ) - cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2020-06-01")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[None] + polling = kwargs.pop("polling", True) # type: Union[bool, PollingMethod] + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token = kwargs.pop("continuation_token", None) # type: Optional[str] if cont_token is None: - raw_result = self._delete_at_management_group_scope_initial( + raw_result = self._delete_at_management_group_scope_initial( # type: ignore group_id=group_id, deployment_name=deployment_name, api_version=api_version, - cls=lambda x,y,z: x, + cls=lambda x, y, z: x, + headers=_headers, + params=_params, **kwargs ) - kwargs.pop('error_map', None) + kwargs.pop("error_map", None) - def get_long_running_output(pipeline_response): + def get_long_running_output(pipeline_response): # pylint: disable=inconsistent-return-statements if cls: return cls(pipeline_response, None, {}) - - if polling is True: polling_method = ARMPolling(lro_delay, **kwargs) - elif polling is False: polling_method = NoPolling() - else: polling_method = polling + if polling is True: + polling_method = cast(PollingMethod, ARMPolling(lro_delay, **kwargs)) # type: PollingMethod + elif polling is False: + polling_method = cast(PollingMethod, NoPolling()) + else: + polling_method = polling if cont_token: return LROPoller.from_continuation_token( polling_method=polling_method, continuation_token=cont_token, client=self._client, - deserialization_callback=get_long_running_output + deserialization_callback=get_long_running_output, ) return LROPoller(self._client, raw_result, get_long_running_output, polling_method) - begin_delete_at_management_group_scope.metadata = {'url': "/providers/Microsoft.Management/managementGroups/{groupId}/providers/Microsoft.Resources/deployments/{deploymentName}"} # type: ignore + begin_delete_at_management_group_scope.metadata = {"url": "/providers/Microsoft.Management/managementGroups/{groupId}/providers/Microsoft.Resources/deployments/{deploymentName}"} # type: ignore @distributed_trace - def check_existence_at_management_group_scope( - self, - group_id: str, - deployment_name: str, - **kwargs: Any - ) -> bool: + def check_existence_at_management_group_scope(self, group_id: str, deployment_name: str, **kwargs: Any) -> bool: """Checks whether the deployment exists. - :param group_id: The management group ID. + :param group_id: The management group ID. Required. :type group_id: str - :param deployment_name: The name of the deployment. + :param deployment_name: The name of the deployment. Required. :type deployment_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: bool, or the result of cls(response) + :return: bool or the result of cls(response) :rtype: bool - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType[None] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) - api_version = kwargs.pop('api_version', "2020-06-01") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2020-06-01")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[None] - request = build_deployments_check_existence_at_management_group_scope_request( group_id=group_id, deployment_name=deployment_name, api_version=api_version, - template_url=self.check_existence_at_management_group_scope.metadata['url'], + template_url=self.check_existence_at_management_group_scope.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [204, 404]: @@ -5215,43 +4969,52 @@ def check_existence_at_management_group_scope( return cls(pipeline_response, None, {}) return 200 <= response.status_code <= 299 - check_existence_at_management_group_scope.metadata = {'url': "/providers/Microsoft.Management/managementGroups/{groupId}/providers/Microsoft.Resources/deployments/{deploymentName}"} # type: ignore - + check_existence_at_management_group_scope.metadata = {"url": "/providers/Microsoft.Management/managementGroups/{groupId}/providers/Microsoft.Resources/deployments/{deploymentName}"} # type: ignore def _create_or_update_at_management_group_scope_initial( - self, - group_id: str, - deployment_name: str, - parameters: "_models.ScopedDeployment", - **kwargs: Any - ) -> "_models.DeploymentExtended": - cls = kwargs.pop('cls', None) # type: ClsType["_models.DeploymentExtended"] + self, group_id: str, deployment_name: str, parameters: Union[_models.ScopedDeployment, IO], **kwargs: Any + ) -> _models.DeploymentExtended: error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', "2020-06-01") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + api_version = kwargs.pop("api_version", _params.pop("api-version", "2020-06-01")) # type: str + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.DeploymentExtended] - _json = self._serialize.body(parameters, 'ScopedDeployment') + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(parameters, (IO, bytes)): + _content = parameters + else: + _json = self._serialize.body(parameters, "ScopedDeployment") - request = build_deployments_create_or_update_at_management_group_scope_request_initial( + request = build_deployments_create_or_update_at_management_group_scope_request( group_id=group_id, deployment_name=deployment_name, api_version=api_version, content_type=content_type, json=_json, - template_url=self._create_or_update_at_management_group_scope_initial.metadata['url'], + content=_content, + template_url=self._create_or_update_at_management_group_scope_initial.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200, 201]: @@ -5259,37 +5022,41 @@ def _create_or_update_at_management_group_scope_initial( raise HttpResponseError(response=response, error_format=ARMErrorFormat) if response.status_code == 200: - deserialized = self._deserialize('DeploymentExtended', pipeline_response) + deserialized = self._deserialize("DeploymentExtended", pipeline_response) if response.status_code == 201: - deserialized = self._deserialize('DeploymentExtended', pipeline_response) + deserialized = self._deserialize("DeploymentExtended", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - _create_or_update_at_management_group_scope_initial.metadata = {'url': "/providers/Microsoft.Management/managementGroups/{groupId}/providers/Microsoft.Resources/deployments/{deploymentName}"} # type: ignore - + _create_or_update_at_management_group_scope_initial.metadata = {"url": "/providers/Microsoft.Management/managementGroups/{groupId}/providers/Microsoft.Resources/deployments/{deploymentName}"} # type: ignore - @distributed_trace + @overload def begin_create_or_update_at_management_group_scope( self, group_id: str, deployment_name: str, - parameters: "_models.ScopedDeployment", + parameters: _models.ScopedDeployment, + *, + content_type: str = "application/json", **kwargs: Any - ) -> LROPoller["_models.DeploymentExtended"]: + ) -> LROPoller[_models.DeploymentExtended]: """Deploys resources at management group scope. You can provide the template and parameters directly in the request or link to JSON files. - :param group_id: The management group ID. + :param group_id: The management group ID. Required. :type group_id: str - :param deployment_name: The name of the deployment. + :param deployment_name: The name of the deployment. Required. :type deployment_name: str - :param parameters: Additional parameters supplied to the operation. + :param parameters: Additional parameters supplied to the operation. Required. :type parameters: ~azure.mgmt.resource.resources.v2020_06_01.models.ScopedDeployment + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str :keyword callable cls: A custom type or function that will be passed the direct response :keyword str continuation_token: A continuation token to restart a poller from a saved state. :keyword polling: By default, your polling method will be ARMPolling. Pass in False for this @@ -5302,114 +5069,187 @@ def begin_create_or_update_at_management_group_scope( cls(response) :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.resource.resources.v2020_06_01.models.DeploymentExtended] - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - api_version = kwargs.pop('api_version', "2020-06-01") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] - polling = kwargs.pop('polling', True) # type: Union[bool, PollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType["_models.DeploymentExtended"] - lro_delay = kwargs.pop( - 'polling_interval', - self._config.polling_interval - ) - cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] - if cont_token is None: - raw_result = self._create_or_update_at_management_group_scope_initial( - group_id=group_id, - deployment_name=deployment_name, - parameters=parameters, - api_version=api_version, - content_type=content_type, - cls=lambda x,y,z: x, - **kwargs - ) - kwargs.pop('error_map', None) - - def get_long_running_output(pipeline_response): - response = pipeline_response.http_response - deserialized = self._deserialize('DeploymentExtended', pipeline_response) - if cls: - return cls(pipeline_response, deserialized, {}) - return deserialized - - - if polling is True: polling_method = ARMPolling(lro_delay, **kwargs) - elif polling is False: polling_method = NoPolling() - else: polling_method = polling - if cont_token: - return LROPoller.from_continuation_token( - polling_method=polling_method, - continuation_token=cont_token, - client=self._client, - deserialization_callback=get_long_running_output - ) - return LROPoller(self._client, raw_result, get_long_running_output, polling_method) - - begin_create_or_update_at_management_group_scope.metadata = {'url': "/providers/Microsoft.Management/managementGroups/{groupId}/providers/Microsoft.Resources/deployments/{deploymentName}"} # type: ignore - @distributed_trace - def get_at_management_group_scope( + @overload + def begin_create_or_update_at_management_group_scope( self, group_id: str, deployment_name: str, + parameters: IO, + *, + content_type: str = "application/json", **kwargs: Any - ) -> "_models.DeploymentExtended": - """Gets a deployment. + ) -> LROPoller[_models.DeploymentExtended]: + """Deploys resources at management group scope. + + You can provide the template and parameters directly in the request or link to JSON files. - :param group_id: The management group ID. + :param group_id: The management group ID. Required. :type group_id: str - :param deployment_name: The name of the deployment. + :param deployment_name: The name of the deployment. Required. :type deployment_name: str + :param parameters: Additional parameters supplied to the operation. Required. + :type parameters: IO + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: DeploymentExtended, or the result of cls(response) - :rtype: ~azure.mgmt.resource.resources.v2020_06_01.models.DeploymentExtended - :raises: ~azure.core.exceptions.HttpResponseError - """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.DeploymentExtended"] - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {})) - - api_version = kwargs.pop('api_version', "2020-06-01") # type: str - - - request = build_deployments_get_at_management_group_scope_request( + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be ARMPolling. Pass in False for this + operation to not poll, or pass in your own initialized polling object for a personal polling + strategy. + :paramtype polling: bool or ~azure.core.polling.PollingMethod + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of LROPoller that returns either DeploymentExtended or the result of + cls(response) + :rtype: + ~azure.core.polling.LROPoller[~azure.mgmt.resource.resources.v2020_06_01.models.DeploymentExtended] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace + def begin_create_or_update_at_management_group_scope( + self, group_id: str, deployment_name: str, parameters: Union[_models.ScopedDeployment, IO], **kwargs: Any + ) -> LROPoller[_models.DeploymentExtended]: + """Deploys resources at management group scope. + + You can provide the template and parameters directly in the request or link to JSON files. + + :param group_id: The management group ID. Required. + :type group_id: str + :param deployment_name: The name of the deployment. Required. + :type deployment_name: str + :param parameters: Additional parameters supplied to the operation. Is either a model type or a + IO type. Required. + :type parameters: ~azure.mgmt.resource.resources.v2020_06_01.models.ScopedDeployment or IO + :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. + Default value is None. + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be ARMPolling. Pass in False for this + operation to not poll, or pass in your own initialized polling object for a personal polling + strategy. + :paramtype polling: bool or ~azure.core.polling.PollingMethod + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of LROPoller that returns either DeploymentExtended or the result of + cls(response) + :rtype: + ~azure.core.polling.LROPoller[~azure.mgmt.resource.resources.v2020_06_01.models.DeploymentExtended] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _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", "2020-06-01")) # type: str + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.DeploymentExtended] + polling = kwargs.pop("polling", True) # type: Union[bool, PollingMethod] + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token = kwargs.pop("continuation_token", None) # type: Optional[str] + if cont_token is None: + raw_result = self._create_or_update_at_management_group_scope_initial( # type: ignore + group_id=group_id, + deployment_name=deployment_name, + parameters=parameters, + api_version=api_version, + content_type=content_type, + cls=lambda x, y, z: x, + headers=_headers, + params=_params, + **kwargs + ) + kwargs.pop("error_map", None) + + def get_long_running_output(pipeline_response): + deserialized = self._deserialize("DeploymentExtended", pipeline_response) + if cls: + return cls(pipeline_response, deserialized, {}) + return deserialized + + if polling is True: + polling_method = cast(PollingMethod, ARMPolling(lro_delay, **kwargs)) # type: PollingMethod + elif polling is False: + polling_method = cast(PollingMethod, NoPolling()) + else: + polling_method = polling + if cont_token: + return LROPoller.from_continuation_token( + polling_method=polling_method, + continuation_token=cont_token, + client=self._client, + deserialization_callback=get_long_running_output, + ) + return LROPoller(self._client, raw_result, get_long_running_output, polling_method) + + begin_create_or_update_at_management_group_scope.metadata = {"url": "/providers/Microsoft.Management/managementGroups/{groupId}/providers/Microsoft.Resources/deployments/{deploymentName}"} # type: ignore + + @distributed_trace + def get_at_management_group_scope( + self, group_id: str, deployment_name: str, **kwargs: Any + ) -> _models.DeploymentExtended: + """Gets a deployment. + + :param group_id: The management group ID. Required. + :type group_id: str + :param deployment_name: The name of the deployment. Required. + :type deployment_name: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: DeploymentExtended or the result of cls(response) + :rtype: ~azure.mgmt.resource.resources.v2020_06_01.models.DeploymentExtended + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2020-06-01")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[_models.DeploymentExtended] + + request = build_deployments_get_at_management_group_scope_request( group_id=group_id, deployment_name=deployment_name, api_version=api_version, - template_url=self.get_at_management_group_scope.metadata['url'], + template_url=self.get_at_management_group_scope.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) - deserialized = self._deserialize('DeploymentExtended', pipeline_response) + deserialized = self._deserialize("DeploymentExtended", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - get_at_management_group_scope.metadata = {'url': "/providers/Microsoft.Management/managementGroups/{groupId}/providers/Microsoft.Resources/deployments/{deploymentName}"} # type: ignore - + get_at_management_group_scope.metadata = {"url": "/providers/Microsoft.Management/managementGroups/{groupId}/providers/Microsoft.Resources/deployments/{deploymentName}"} # type: ignore @distributed_trace def cancel_at_management_group_scope( # pylint: disable=inconsistent-return-statements - self, - group_id: str, - deployment_name: str, - **kwargs: Any + self, group_id: str, deployment_name: str, **kwargs: Any ) -> None: """Cancels a currently running template deployment. @@ -5418,38 +5258,44 @@ def cancel_at_management_group_scope( # pylint: disable=inconsistent-return-sta deployment stops the currently running template deployment and leaves the resources partially deployed. - :param group_id: The management group ID. + :param group_id: The management group ID. Required. :type group_id: str - :param deployment_name: The name of the deployment. + :param deployment_name: The name of the deployment. Required. :type deployment_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: None, or the result of cls(response) + :return: None or the result of cls(response) :rtype: None - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType[None] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + 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', "2020-06-01") # type: str + api_version = kwargs.pop("api_version", _params.pop("api-version", "2020-06-01")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[None] - request = build_deployments_cancel_at_management_group_scope_request( group_id=group_id, deployment_name=deployment_name, api_version=api_version, - template_url=self.cancel_at_management_group_scope.metadata['url'], + template_url=self.cancel_at_management_group_scope.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [204]: @@ -5459,43 +5305,52 @@ def cancel_at_management_group_scope( # pylint: disable=inconsistent-return-sta if cls: return cls(pipeline_response, None, {}) - cancel_at_management_group_scope.metadata = {'url': "/providers/Microsoft.Management/managementGroups/{groupId}/providers/Microsoft.Resources/deployments/{deploymentName}/cancel"} # type: ignore - + cancel_at_management_group_scope.metadata = {"url": "/providers/Microsoft.Management/managementGroups/{groupId}/providers/Microsoft.Resources/deployments/{deploymentName}/cancel"} # type: ignore def _validate_at_management_group_scope_initial( - self, - group_id: str, - deployment_name: str, - parameters: "_models.ScopedDeployment", - **kwargs: Any - ) -> Optional["_models.DeploymentValidateResult"]: - cls = kwargs.pop('cls', None) # type: ClsType[Optional["_models.DeploymentValidateResult"]] + self, group_id: str, deployment_name: str, parameters: Union[_models.ScopedDeployment, IO], **kwargs: Any + ) -> Optional[_models.DeploymentValidateResult]: error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) - api_version = kwargs.pop('api_version', "2020-06-01") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - _json = self._serialize.body(parameters, 'ScopedDeployment') + api_version = kwargs.pop("api_version", _params.pop("api-version", "2020-06-01")) # type: str + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[Optional[_models.DeploymentValidateResult]] - request = build_deployments_validate_at_management_group_scope_request_initial( + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(parameters, (IO, bytes)): + _content = parameters + else: + _json = self._serialize.body(parameters, "ScopedDeployment") + + request = build_deployments_validate_at_management_group_scope_request( group_id=group_id, deployment_name=deployment_name, api_version=api_version, content_type=content_type, json=_json, - template_url=self._validate_at_management_group_scope_initial.metadata['url'], + content=_content, + template_url=self._validate_at_management_group_scope_initial.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200, 202, 400]: @@ -5504,36 +5359,40 @@ def _validate_at_management_group_scope_initial( deserialized = None if response.status_code == 200: - deserialized = self._deserialize('DeploymentValidateResult', pipeline_response) + deserialized = self._deserialize("DeploymentValidateResult", pipeline_response) if response.status_code == 400: - deserialized = self._deserialize('DeploymentValidateResult', pipeline_response) + deserialized = self._deserialize("DeploymentValidateResult", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - _validate_at_management_group_scope_initial.metadata = {'url': "/providers/Microsoft.Management/managementGroups/{groupId}/providers/Microsoft.Resources/deployments/{deploymentName}/validate"} # type: ignore + _validate_at_management_group_scope_initial.metadata = {"url": "/providers/Microsoft.Management/managementGroups/{groupId}/providers/Microsoft.Resources/deployments/{deploymentName}/validate"} # type: ignore - - @distributed_trace + @overload def begin_validate_at_management_group_scope( self, group_id: str, deployment_name: str, - parameters: "_models.ScopedDeployment", + parameters: _models.ScopedDeployment, + *, + content_type: str = "application/json", **kwargs: Any - ) -> LROPoller["_models.DeploymentValidateResult"]: + ) -> LROPoller[_models.DeploymentValidateResult]: """Validates whether the specified template is syntactically correct and will be accepted by Azure Resource Manager.. - :param group_id: The management group ID. + :param group_id: The management group ID. Required. :type group_id: str - :param deployment_name: The name of the deployment. + :param deployment_name: The name of the deployment. Required. :type deployment_name: str - :param parameters: Parameters to validate. + :param parameters: Parameters to validate. Required. :type parameters: ~azure.mgmt.resource.resources.v2020_06_01.models.ScopedDeployment + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str :keyword callable cls: A custom type or function that will be passed the direct response :keyword str continuation_token: A continuation token to restart a poller from a saved state. :keyword polling: By default, your polling method will be ARMPolling. Pass in False for this @@ -5546,85 +5405,166 @@ def begin_validate_at_management_group_scope( cls(response) :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.resource.resources.v2020_06_01.models.DeploymentValidateResult] - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - api_version = kwargs.pop('api_version', "2020-06-01") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] - polling = kwargs.pop('polling', True) # type: Union[bool, PollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType["_models.DeploymentValidateResult"] - lro_delay = kwargs.pop( - 'polling_interval', - self._config.polling_interval - ) - cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] + + @overload + def begin_validate_at_management_group_scope( + self, + group_id: str, + deployment_name: str, + parameters: IO, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> LROPoller[_models.DeploymentValidateResult]: + """Validates whether the specified template is syntactically correct and will be accepted by Azure + Resource Manager.. + + :param group_id: The management group ID. Required. + :type group_id: str + :param deployment_name: The name of the deployment. Required. + :type deployment_name: str + :param parameters: Parameters to validate. Required. + :type parameters: IO + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be ARMPolling. Pass in False for this + operation to not poll, or pass in your own initialized polling object for a personal polling + strategy. + :paramtype polling: bool or ~azure.core.polling.PollingMethod + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of LROPoller that returns either DeploymentValidateResult or the result of + cls(response) + :rtype: + ~azure.core.polling.LROPoller[~azure.mgmt.resource.resources.v2020_06_01.models.DeploymentValidateResult] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace + def begin_validate_at_management_group_scope( + self, group_id: str, deployment_name: str, parameters: Union[_models.ScopedDeployment, IO], **kwargs: Any + ) -> LROPoller[_models.DeploymentValidateResult]: + """Validates whether the specified template is syntactically correct and will be accepted by Azure + Resource Manager.. + + :param group_id: The management group ID. Required. + :type group_id: str + :param deployment_name: The name of the deployment. Required. + :type deployment_name: str + :param parameters: Parameters to validate. Is either a model type or a IO type. Required. + :type parameters: ~azure.mgmt.resource.resources.v2020_06_01.models.ScopedDeployment or IO + :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. + Default value is None. + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be ARMPolling. Pass in False for this + operation to not poll, or pass in your own initialized polling object for a personal polling + strategy. + :paramtype polling: bool or ~azure.core.polling.PollingMethod + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of LROPoller that returns either DeploymentValidateResult or the result of + cls(response) + :rtype: + ~azure.core.polling.LROPoller[~azure.mgmt.resource.resources.v2020_06_01.models.DeploymentValidateResult] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _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", "2020-06-01")) # type: str + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.DeploymentValidateResult] + polling = kwargs.pop("polling", True) # type: Union[bool, PollingMethod] + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token = kwargs.pop("continuation_token", None) # type: Optional[str] if cont_token is None: - raw_result = self._validate_at_management_group_scope_initial( + raw_result = self._validate_at_management_group_scope_initial( # type: ignore group_id=group_id, deployment_name=deployment_name, parameters=parameters, api_version=api_version, content_type=content_type, - cls=lambda x,y,z: x, + cls=lambda x, y, z: x, + headers=_headers, + params=_params, **kwargs ) - kwargs.pop('error_map', None) + kwargs.pop("error_map", None) def get_long_running_output(pipeline_response): - response = pipeline_response.http_response - deserialized = self._deserialize('DeploymentValidateResult', pipeline_response) + deserialized = self._deserialize("DeploymentValidateResult", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - - if polling is True: polling_method = ARMPolling(lro_delay, **kwargs) - elif polling is False: polling_method = NoPolling() - else: polling_method = polling + if polling is True: + polling_method = cast(PollingMethod, ARMPolling(lro_delay, **kwargs)) # type: PollingMethod + elif polling is False: + polling_method = cast(PollingMethod, NoPolling()) + else: + polling_method = polling if cont_token: return LROPoller.from_continuation_token( polling_method=polling_method, continuation_token=cont_token, client=self._client, - deserialization_callback=get_long_running_output + deserialization_callback=get_long_running_output, ) return LROPoller(self._client, raw_result, get_long_running_output, polling_method) - begin_validate_at_management_group_scope.metadata = {'url': "/providers/Microsoft.Management/managementGroups/{groupId}/providers/Microsoft.Resources/deployments/{deploymentName}/validate"} # type: ignore + begin_validate_at_management_group_scope.metadata = {"url": "/providers/Microsoft.Management/managementGroups/{groupId}/providers/Microsoft.Resources/deployments/{deploymentName}/validate"} # type: ignore def _what_if_at_management_group_scope_initial( - self, - group_id: str, - deployment_name: str, - parameters: "_models.ScopedDeploymentWhatIf", - **kwargs: Any - ) -> Optional["_models.WhatIfOperationResult"]: - cls = kwargs.pop('cls', None) # type: ClsType[Optional["_models.WhatIfOperationResult"]] + self, group_id: str, deployment_name: str, parameters: Union[_models.ScopedDeploymentWhatIf, IO], **kwargs: Any + ) -> Optional[_models.WhatIfOperationResult]: error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', "2020-06-01") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + api_version = kwargs.pop("api_version", _params.pop("api-version", "2020-06-01")) # type: str + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[Optional[_models.WhatIfOperationResult]] - _json = self._serialize.body(parameters, 'ScopedDeploymentWhatIf') + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(parameters, (IO, bytes)): + _content = parameters + else: + _json = self._serialize.body(parameters, "ScopedDeploymentWhatIf") - request = build_deployments_what_if_at_management_group_scope_request_initial( + request = build_deployments_what_if_at_management_group_scope_request( group_id=group_id, deployment_name=deployment_name, api_version=api_version, content_type=content_type, json=_json, - template_url=self._what_if_at_management_group_scope_initial.metadata['url'], + content=_content, + template_url=self._what_if_at_management_group_scope_initial.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200, 202]: @@ -5634,38 +5574,41 @@ def _what_if_at_management_group_scope_initial( deserialized = None response_headers = {} if response.status_code == 200: - deserialized = self._deserialize('WhatIfOperationResult', pipeline_response) + deserialized = self._deserialize("WhatIfOperationResult", pipeline_response) if response.status_code == 202: - response_headers['Location']=self._deserialize('str', response.headers.get('Location')) - response_headers['Retry-After']=self._deserialize('str', response.headers.get('Retry-After')) - + response_headers["Location"] = self._deserialize("str", response.headers.get("Location")) + response_headers["Retry-After"] = self._deserialize("str", response.headers.get("Retry-After")) if cls: return cls(pipeline_response, deserialized, response_headers) return deserialized - _what_if_at_management_group_scope_initial.metadata = {'url': "/providers/Microsoft.Management/managementGroups/{groupId}/providers/Microsoft.Resources/deployments/{deploymentName}/whatIf"} # type: ignore - + _what_if_at_management_group_scope_initial.metadata = {"url": "/providers/Microsoft.Management/managementGroups/{groupId}/providers/Microsoft.Resources/deployments/{deploymentName}/whatIf"} # type: ignore - @distributed_trace + @overload def begin_what_if_at_management_group_scope( self, group_id: str, deployment_name: str, - parameters: "_models.ScopedDeploymentWhatIf", + parameters: _models.ScopedDeploymentWhatIf, + *, + content_type: str = "application/json", **kwargs: Any - ) -> LROPoller["_models.WhatIfOperationResult"]: + ) -> LROPoller[_models.WhatIfOperationResult]: """Returns changes that will be made by the deployment if executed at the scope of the management group. - :param group_id: The management group ID. + :param group_id: The management group ID. Required. :type group_id: str - :param deployment_name: The name of the deployment. + :param deployment_name: The name of the deployment. Required. :type deployment_name: str - :param parameters: Parameters to validate. + :param parameters: Parameters to validate. Required. :type parameters: ~azure.mgmt.resource.resources.v2020_06_01.models.ScopedDeploymentWhatIf + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str :keyword callable cls: A custom type or function that will be passed the direct response :keyword str continuation_token: A continuation token to restart a poller from a saved state. :keyword polling: By default, your polling method will be ARMPolling. Pass in False for this @@ -5678,119 +5621,191 @@ def begin_what_if_at_management_group_scope( cls(response) :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.resource.resources.v2020_06_01.models.WhatIfOperationResult] - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - api_version = kwargs.pop('api_version', "2020-06-01") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] - polling = kwargs.pop('polling', True) # type: Union[bool, PollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType["_models.WhatIfOperationResult"] - lro_delay = kwargs.pop( - 'polling_interval', - self._config.polling_interval - ) - cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] + + @overload + def begin_what_if_at_management_group_scope( + self, + group_id: str, + deployment_name: str, + parameters: IO, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> LROPoller[_models.WhatIfOperationResult]: + """Returns changes that will be made by the deployment if executed at the scope of the management + group. + + :param group_id: The management group ID. Required. + :type group_id: str + :param deployment_name: The name of the deployment. Required. + :type deployment_name: str + :param parameters: Parameters to validate. Required. + :type parameters: IO + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be ARMPolling. Pass in False for this + operation to not poll, or pass in your own initialized polling object for a personal polling + strategy. + :paramtype polling: bool or ~azure.core.polling.PollingMethod + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of LROPoller that returns either WhatIfOperationResult or the result of + cls(response) + :rtype: + ~azure.core.polling.LROPoller[~azure.mgmt.resource.resources.v2020_06_01.models.WhatIfOperationResult] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace + def begin_what_if_at_management_group_scope( + self, group_id: str, deployment_name: str, parameters: Union[_models.ScopedDeploymentWhatIf, IO], **kwargs: Any + ) -> LROPoller[_models.WhatIfOperationResult]: + """Returns changes that will be made by the deployment if executed at the scope of the management + group. + + :param group_id: The management group ID. Required. + :type group_id: str + :param deployment_name: The name of the deployment. Required. + :type deployment_name: str + :param parameters: Parameters to validate. Is either a model type or a IO type. Required. + :type parameters: ~azure.mgmt.resource.resources.v2020_06_01.models.ScopedDeploymentWhatIf or + IO + :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. + Default value is None. + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be ARMPolling. Pass in False for this + operation to not poll, or pass in your own initialized polling object for a personal polling + strategy. + :paramtype polling: bool or ~azure.core.polling.PollingMethod + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of LROPoller that returns either WhatIfOperationResult or the result of + cls(response) + :rtype: + ~azure.core.polling.LROPoller[~azure.mgmt.resource.resources.v2020_06_01.models.WhatIfOperationResult] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _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", "2020-06-01")) # type: str + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.WhatIfOperationResult] + polling = kwargs.pop("polling", True) # type: Union[bool, PollingMethod] + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token = kwargs.pop("continuation_token", None) # type: Optional[str] if cont_token is None: - raw_result = self._what_if_at_management_group_scope_initial( + raw_result = self._what_if_at_management_group_scope_initial( # type: ignore group_id=group_id, deployment_name=deployment_name, parameters=parameters, api_version=api_version, content_type=content_type, - cls=lambda x,y,z: x, + cls=lambda x, y, z: x, + headers=_headers, + params=_params, **kwargs ) - kwargs.pop('error_map', None) + kwargs.pop("error_map", None) def get_long_running_output(pipeline_response): - response = pipeline_response.http_response - deserialized = self._deserialize('WhatIfOperationResult', pipeline_response) + deserialized = self._deserialize("WhatIfOperationResult", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - - if polling is True: polling_method = ARMPolling(lro_delay, lro_options={'final-state-via': 'location'}, **kwargs) - elif polling is False: polling_method = NoPolling() - else: polling_method = polling + if polling is True: + polling_method = cast( + PollingMethod, ARMPolling(lro_delay, lro_options={"final-state-via": "location"}, **kwargs) + ) # type: PollingMethod + elif polling is False: + polling_method = cast(PollingMethod, NoPolling()) + else: + polling_method = polling if cont_token: return LROPoller.from_continuation_token( polling_method=polling_method, continuation_token=cont_token, client=self._client, - deserialization_callback=get_long_running_output + deserialization_callback=get_long_running_output, ) return LROPoller(self._client, raw_result, get_long_running_output, polling_method) - begin_what_if_at_management_group_scope.metadata = {'url': "/providers/Microsoft.Management/managementGroups/{groupId}/providers/Microsoft.Resources/deployments/{deploymentName}/whatIf"} # type: ignore + begin_what_if_at_management_group_scope.metadata = {"url": "/providers/Microsoft.Management/managementGroups/{groupId}/providers/Microsoft.Resources/deployments/{deploymentName}/whatIf"} # type: ignore @distributed_trace def export_template_at_management_group_scope( - self, - group_id: str, - deployment_name: str, - **kwargs: Any - ) -> "_models.DeploymentExportResult": + self, group_id: str, deployment_name: str, **kwargs: Any + ) -> _models.DeploymentExportResult: """Exports the template used for specified deployment. - :param group_id: The management group ID. + :param group_id: The management group ID. Required. :type group_id: str - :param deployment_name: The name of the deployment. + :param deployment_name: The name of the deployment. Required. :type deployment_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: DeploymentExportResult, or the result of cls(response) + :return: DeploymentExportResult or the result of cls(response) :rtype: ~azure.mgmt.resource.resources.v2020_06_01.models.DeploymentExportResult - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.DeploymentExportResult"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) - api_version = kwargs.pop('api_version', "2020-06-01") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2020-06-01")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[_models.DeploymentExportResult] - request = build_deployments_export_template_at_management_group_scope_request( group_id=group_id, deployment_name=deployment_name, api_version=api_version, - template_url=self.export_template_at_management_group_scope.metadata['url'], + template_url=self.export_template_at_management_group_scope.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) - deserialized = self._deserialize('DeploymentExportResult', pipeline_response) + deserialized = self._deserialize("DeploymentExportResult", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - export_template_at_management_group_scope.metadata = {'url': "/providers/Microsoft.Management/managementGroups/{groupId}/providers/Microsoft.Resources/deployments/{deploymentName}/exportTemplate"} # type: ignore - + export_template_at_management_group_scope.metadata = {"url": "/providers/Microsoft.Management/managementGroups/{groupId}/providers/Microsoft.Resources/deployments/{deploymentName}/exportTemplate"} # type: ignore @distributed_trace def list_at_management_group_scope( - self, - group_id: str, - filter: Optional[str] = None, - top: Optional[int] = None, - **kwargs: Any - ) -> Iterable["_models.DeploymentListResult"]: + self, group_id: str, filter: Optional[str] = None, top: Optional[int] = None, **kwargs: Any + ) -> Iterable["_models.DeploymentExtended"]: """Get all the deployments for a management group. - :param group_id: The management group ID. + :param group_id: The management group ID. Required. :type group_id: str :param filter: The filter to apply on the operation. For example, you can use $filter=provisioningState eq '{state}'. Default value is None. @@ -5799,40 +5814,48 @@ def list_at_management_group_scope( value is None. :type top: int :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either DeploymentListResult or the result of - cls(response) + :return: An iterator like instance of either DeploymentExtended or the result of cls(response) :rtype: - ~azure.core.paging.ItemPaged[~azure.mgmt.resource.resources.v2020_06_01.models.DeploymentListResult] - :raises: ~azure.core.exceptions.HttpResponseError + ~azure.core.paging.ItemPaged[~azure.mgmt.resource.resources.v2020_06_01.models.DeploymentExtended] + :raises ~azure.core.exceptions.HttpResponseError: """ - api_version = kwargs.pop('api_version', "2020-06-01") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2020-06-01")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[_models.DeploymentListResult] - cls = kwargs.pop('cls', None) # type: ClsType["_models.DeploymentListResult"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) + def prepare_request(next_link=None): if not next_link: - + request = build_deployments_list_at_management_group_scope_request( group_id=group_id, - api_version=api_version, filter=filter, top=top, - template_url=self.list_at_management_group_scope.metadata['url'], + api_version=api_version, + template_url=self.list_at_management_group_scope.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore else: - - request = build_deployments_list_at_management_group_scope_request( - group_id=group_id, - template_url=next_link, - ) + # make call to next link with the client's api-version + _parsed_next_link = urlparse(next_link) + _next_request_params = case_insensitive_dict(parse_qs(_parsed_next_link.query)) + _next_request_params["api-version"] = self._config.api_version + request = HttpRequest("GET", urljoin(next_link, _parsed_next_link.path), params=_next_request_params) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore request.method = "GET" return request @@ -5846,10 +5869,8 @@ def extract_data(pipeline_response): def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) response = pipeline_response.http_response @@ -5859,40 +5880,42 @@ def get_next(next_link=None): return pipeline_response + return ItemPaged(get_next, extract_data) - return ItemPaged( - get_next, extract_data - ) - list_at_management_group_scope.metadata = {'url': "/providers/Microsoft.Management/managementGroups/{groupId}/providers/Microsoft.Resources/deployments/"} # type: ignore + list_at_management_group_scope.metadata = {"url": "/providers/Microsoft.Management/managementGroups/{groupId}/providers/Microsoft.Resources/deployments/"} # type: ignore def _delete_at_subscription_scope_initial( # pylint: disable=inconsistent-return-statements - self, - deployment_name: str, - **kwargs: Any + self, deployment_name: str, **kwargs: Any ) -> None: - cls = kwargs.pop('cls', None) # type: ClsType[None] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) - api_version = kwargs.pop('api_version', "2020-06-01") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - request = build_deployments_delete_at_subscription_scope_request_initial( + api_version = kwargs.pop("api_version", _params.pop("api-version", "2020-06-01")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[None] + + request = build_deployments_delete_at_subscription_scope_request( deployment_name=deployment_name, subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self._delete_at_subscription_scope_initial.metadata['url'], + template_url=self._delete_at_subscription_scope_initial.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [202, 204]: @@ -5902,15 +5925,10 @@ def _delete_at_subscription_scope_initial( # pylint: disable=inconsistent-retur if cls: return cls(pipeline_response, None, {}) - _delete_at_subscription_scope_initial.metadata = {'url': "/subscriptions/{subscriptionId}/providers/Microsoft.Resources/deployments/{deploymentName}"} # type: ignore - + _delete_at_subscription_scope_initial.metadata = {"url": "/subscriptions/{subscriptionId}/providers/Microsoft.Resources/deployments/{deploymentName}"} # type: ignore @distributed_trace - def begin_delete_at_subscription_scope( # pylint: disable=inconsistent-return-statements - self, - deployment_name: str, - **kwargs: Any - ) -> LROPoller[None]: + def begin_delete_at_subscription_scope(self, deployment_name: str, **kwargs: Any) -> LROPoller[None]: """Deletes a deployment from the deployment history. A template deployment that is currently running cannot be deleted. Deleting a template @@ -5921,7 +5939,7 @@ def begin_delete_at_subscription_scope( # pylint: disable=inconsistent-return-s process finishes, the URI in the Location header returns a status of 204 on success. If the asynchronous request failed, the URI in the Location header returns an error-level status code. - :param deployment_name: The name of the deployment. + :param deployment_name: The name of the deployment. Required. :type deployment_name: str :keyword callable cls: A custom type or function that will be passed the direct response :keyword str continuation_token: A continuation token to restart a poller from a saved state. @@ -5933,82 +5951,88 @@ def begin_delete_at_subscription_scope( # pylint: disable=inconsistent-return-s Retry-After header is present. :return: An instance of LROPoller that returns either None or the result of cls(response) :rtype: ~azure.core.polling.LROPoller[None] - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - api_version = kwargs.pop('api_version', "2020-06-01") # type: str - polling = kwargs.pop('polling', True) # type: Union[bool, PollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType[None] - lro_delay = kwargs.pop( - 'polling_interval', - self._config.polling_interval - ) - cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2020-06-01")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[None] + polling = kwargs.pop("polling", True) # type: Union[bool, PollingMethod] + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token = kwargs.pop("continuation_token", None) # type: Optional[str] if cont_token is None: - raw_result = self._delete_at_subscription_scope_initial( + raw_result = self._delete_at_subscription_scope_initial( # type: ignore deployment_name=deployment_name, api_version=api_version, - cls=lambda x,y,z: x, + cls=lambda x, y, z: x, + headers=_headers, + params=_params, **kwargs ) - kwargs.pop('error_map', None) + kwargs.pop("error_map", None) - def get_long_running_output(pipeline_response): + def get_long_running_output(pipeline_response): # pylint: disable=inconsistent-return-statements if cls: return cls(pipeline_response, None, {}) - - if polling is True: polling_method = ARMPolling(lro_delay, **kwargs) - elif polling is False: polling_method = NoPolling() - else: polling_method = polling + if polling is True: + polling_method = cast(PollingMethod, ARMPolling(lro_delay, **kwargs)) # type: PollingMethod + elif polling is False: + polling_method = cast(PollingMethod, NoPolling()) + else: + polling_method = polling if cont_token: return LROPoller.from_continuation_token( polling_method=polling_method, continuation_token=cont_token, client=self._client, - deserialization_callback=get_long_running_output + deserialization_callback=get_long_running_output, ) return LROPoller(self._client, raw_result, get_long_running_output, polling_method) - begin_delete_at_subscription_scope.metadata = {'url': "/subscriptions/{subscriptionId}/providers/Microsoft.Resources/deployments/{deploymentName}"} # type: ignore + begin_delete_at_subscription_scope.metadata = {"url": "/subscriptions/{subscriptionId}/providers/Microsoft.Resources/deployments/{deploymentName}"} # type: ignore @distributed_trace - def check_existence_at_subscription_scope( - self, - deployment_name: str, - **kwargs: Any - ) -> bool: + def check_existence_at_subscription_scope(self, deployment_name: str, **kwargs: Any) -> bool: """Checks whether the deployment exists. - :param deployment_name: The name of the deployment. + :param deployment_name: The name of the deployment. Required. :type deployment_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: bool, or the result of cls(response) + :return: bool or the result of cls(response) :rtype: bool - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType[None] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) - api_version = kwargs.pop('api_version', "2020-06-01") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2020-06-01")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[None] - request = build_deployments_check_existence_at_subscription_scope_request( deployment_name=deployment_name, subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.check_existence_at_subscription_scope.metadata['url'], + template_url=self.check_existence_at_subscription_scope.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [204, 404]: @@ -6019,42 +6043,52 @@ def check_existence_at_subscription_scope( return cls(pipeline_response, None, {}) return 200 <= response.status_code <= 299 - check_existence_at_subscription_scope.metadata = {'url': "/subscriptions/{subscriptionId}/providers/Microsoft.Resources/deployments/{deploymentName}"} # type: ignore - + check_existence_at_subscription_scope.metadata = {"url": "/subscriptions/{subscriptionId}/providers/Microsoft.Resources/deployments/{deploymentName}"} # type: ignore def _create_or_update_at_subscription_scope_initial( - self, - deployment_name: str, - parameters: "_models.Deployment", - **kwargs: Any - ) -> "_models.DeploymentExtended": - cls = kwargs.pop('cls', None) # type: ClsType["_models.DeploymentExtended"] + self, deployment_name: str, parameters: Union[_models.Deployment, IO], **kwargs: Any + ) -> _models.DeploymentExtended: error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) - api_version = kwargs.pop('api_version', "2020-06-01") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - _json = self._serialize.body(parameters, 'Deployment') + api_version = kwargs.pop("api_version", _params.pop("api-version", "2020-06-01")) # type: str + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.DeploymentExtended] - request = build_deployments_create_or_update_at_subscription_scope_request_initial( + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(parameters, (IO, bytes)): + _content = parameters + else: + _json = self._serialize.body(parameters, "Deployment") + + request = build_deployments_create_or_update_at_subscription_scope_request( deployment_name=deployment_name, subscription_id=self._config.subscription_id, api_version=api_version, content_type=content_type, json=_json, - template_url=self._create_or_update_at_subscription_scope_initial.metadata['url'], + content=_content, + template_url=self._create_or_update_at_subscription_scope_initial.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200, 201]: @@ -6062,34 +6096,38 @@ def _create_or_update_at_subscription_scope_initial( raise HttpResponseError(response=response, error_format=ARMErrorFormat) if response.status_code == 200: - deserialized = self._deserialize('DeploymentExtended', pipeline_response) + deserialized = self._deserialize("DeploymentExtended", pipeline_response) if response.status_code == 201: - deserialized = self._deserialize('DeploymentExtended', pipeline_response) + deserialized = self._deserialize("DeploymentExtended", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - _create_or_update_at_subscription_scope_initial.metadata = {'url': "/subscriptions/{subscriptionId}/providers/Microsoft.Resources/deployments/{deploymentName}"} # type: ignore + _create_or_update_at_subscription_scope_initial.metadata = {"url": "/subscriptions/{subscriptionId}/providers/Microsoft.Resources/deployments/{deploymentName}"} # type: ignore - - @distributed_trace + @overload def begin_create_or_update_at_subscription_scope( self, deployment_name: str, - parameters: "_models.Deployment", + parameters: _models.Deployment, + *, + content_type: str = "application/json", **kwargs: Any - ) -> LROPoller["_models.DeploymentExtended"]: + ) -> LROPoller[_models.DeploymentExtended]: """Deploys resources at subscription scope. You can provide the template and parameters directly in the request or link to JSON files. - :param deployment_name: The name of the deployment. + :param deployment_name: The name of the deployment. Required. :type deployment_name: str - :param parameters: Additional parameters supplied to the operation. + :param parameters: Additional parameters supplied to the operation. Required. :type parameters: ~azure.mgmt.resource.resources.v2020_06_01.models.Deployment + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str :keyword callable cls: A custom type or function that will be passed the direct response :keyword str continuation_token: A continuation token to restart a poller from a saved state. :keyword polling: By default, your polling method will be ARMPolling. Pass in False for this @@ -6102,109 +6140,172 @@ def begin_create_or_update_at_subscription_scope( cls(response) :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.resource.resources.v2020_06_01.models.DeploymentExtended] - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - api_version = kwargs.pop('api_version', "2020-06-01") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] - polling = kwargs.pop('polling', True) # type: Union[bool, PollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType["_models.DeploymentExtended"] - lro_delay = kwargs.pop( - 'polling_interval', - self._config.polling_interval - ) - cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] - if cont_token is None: - raw_result = self._create_or_update_at_subscription_scope_initial( - deployment_name=deployment_name, - parameters=parameters, - api_version=api_version, - content_type=content_type, - cls=lambda x,y,z: x, - **kwargs - ) - kwargs.pop('error_map', None) - def get_long_running_output(pipeline_response): - response = pipeline_response.http_response - deserialized = self._deserialize('DeploymentExtended', pipeline_response) + @overload + def begin_create_or_update_at_subscription_scope( + self, deployment_name: str, parameters: IO, *, content_type: str = "application/json", **kwargs: Any + ) -> LROPoller[_models.DeploymentExtended]: + """Deploys resources at subscription scope. + + You can provide the template and parameters directly in the request or link to JSON files. + + :param deployment_name: The name of the deployment. Required. + :type deployment_name: str + :param parameters: Additional parameters supplied to the operation. Required. + :type parameters: IO + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be ARMPolling. Pass in False for this + operation to not poll, or pass in your own initialized polling object for a personal polling + strategy. + :paramtype polling: bool or ~azure.core.polling.PollingMethod + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of LROPoller that returns either DeploymentExtended or the result of + cls(response) + :rtype: + ~azure.core.polling.LROPoller[~azure.mgmt.resource.resources.v2020_06_01.models.DeploymentExtended] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace + def begin_create_or_update_at_subscription_scope( + self, deployment_name: str, parameters: Union[_models.Deployment, IO], **kwargs: Any + ) -> LROPoller[_models.DeploymentExtended]: + """Deploys resources at subscription scope. + + You can provide the template and parameters directly in the request or link to JSON files. + + :param deployment_name: The name of the deployment. Required. + :type deployment_name: str + :param parameters: Additional parameters supplied to the operation. Is either a model type or a + IO type. Required. + :type parameters: ~azure.mgmt.resource.resources.v2020_06_01.models.Deployment or IO + :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. + Default value is None. + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be ARMPolling. Pass in False for this + operation to not poll, or pass in your own initialized polling object for a personal polling + strategy. + :paramtype polling: bool or ~azure.core.polling.PollingMethod + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of LROPoller that returns either DeploymentExtended or the result of + cls(response) + :rtype: + ~azure.core.polling.LROPoller[~azure.mgmt.resource.resources.v2020_06_01.models.DeploymentExtended] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _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", "2020-06-01")) # type: str + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.DeploymentExtended] + polling = kwargs.pop("polling", True) # type: Union[bool, PollingMethod] + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token = kwargs.pop("continuation_token", None) # type: Optional[str] + if cont_token is None: + raw_result = self._create_or_update_at_subscription_scope_initial( # type: ignore + deployment_name=deployment_name, + parameters=parameters, + api_version=api_version, + content_type=content_type, + cls=lambda x, y, z: x, + headers=_headers, + params=_params, + **kwargs + ) + kwargs.pop("error_map", None) + + def get_long_running_output(pipeline_response): + deserialized = self._deserialize("DeploymentExtended", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - - if polling is True: polling_method = ARMPolling(lro_delay, **kwargs) - elif polling is False: polling_method = NoPolling() - else: polling_method = polling + if polling is True: + polling_method = cast(PollingMethod, ARMPolling(lro_delay, **kwargs)) # type: PollingMethod + elif polling is False: + polling_method = cast(PollingMethod, NoPolling()) + else: + polling_method = polling if cont_token: return LROPoller.from_continuation_token( polling_method=polling_method, continuation_token=cont_token, client=self._client, - deserialization_callback=get_long_running_output + deserialization_callback=get_long_running_output, ) return LROPoller(self._client, raw_result, get_long_running_output, polling_method) - begin_create_or_update_at_subscription_scope.metadata = {'url': "/subscriptions/{subscriptionId}/providers/Microsoft.Resources/deployments/{deploymentName}"} # type: ignore + begin_create_or_update_at_subscription_scope.metadata = {"url": "/subscriptions/{subscriptionId}/providers/Microsoft.Resources/deployments/{deploymentName}"} # type: ignore @distributed_trace - def get_at_subscription_scope( - self, - deployment_name: str, - **kwargs: Any - ) -> "_models.DeploymentExtended": + def get_at_subscription_scope(self, deployment_name: str, **kwargs: Any) -> _models.DeploymentExtended: """Gets a deployment. - :param deployment_name: The name of the deployment. + :param deployment_name: The name of the deployment. Required. :type deployment_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: DeploymentExtended, or the result of cls(response) + :return: DeploymentExtended or the result of cls(response) :rtype: ~azure.mgmt.resource.resources.v2020_06_01.models.DeploymentExtended - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.DeploymentExtended"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + 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', "2020-06-01") # type: str + api_version = kwargs.pop("api_version", _params.pop("api-version", "2020-06-01")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[_models.DeploymentExtended] - request = build_deployments_get_at_subscription_scope_request( deployment_name=deployment_name, subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.get_at_subscription_scope.metadata['url'], + template_url=self.get_at_subscription_scope.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) - deserialized = self._deserialize('DeploymentExtended', pipeline_response) + deserialized = self._deserialize("DeploymentExtended", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - get_at_subscription_scope.metadata = {'url': "/subscriptions/{subscriptionId}/providers/Microsoft.Resources/deployments/{deploymentName}"} # type: ignore - + get_at_subscription_scope.metadata = {"url": "/subscriptions/{subscriptionId}/providers/Microsoft.Resources/deployments/{deploymentName}"} # type: ignore @distributed_trace def cancel_at_subscription_scope( # pylint: disable=inconsistent-return-statements - self, - deployment_name: str, - **kwargs: Any + self, deployment_name: str, **kwargs: Any ) -> None: """Cancels a currently running template deployment. @@ -6213,36 +6314,42 @@ def cancel_at_subscription_scope( # pylint: disable=inconsistent-return-stateme deployment stops the currently running template deployment and leaves the resources partially deployed. - :param deployment_name: The name of the deployment. + :param deployment_name: The name of the deployment. Required. :type deployment_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: None, or the result of cls(response) + :return: None or the result of cls(response) :rtype: None - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType[None] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + 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', "2020-06-01") # type: str + api_version = kwargs.pop("api_version", _params.pop("api-version", "2020-06-01")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[None] - request = build_deployments_cancel_at_subscription_scope_request( deployment_name=deployment_name, subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.cancel_at_subscription_scope.metadata['url'], + template_url=self.cancel_at_subscription_scope.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [204]: @@ -6252,42 +6359,52 @@ def cancel_at_subscription_scope( # pylint: disable=inconsistent-return-stateme if cls: return cls(pipeline_response, None, {}) - cancel_at_subscription_scope.metadata = {'url': "/subscriptions/{subscriptionId}/providers/Microsoft.Resources/deployments/{deploymentName}/cancel"} # type: ignore - + cancel_at_subscription_scope.metadata = {"url": "/subscriptions/{subscriptionId}/providers/Microsoft.Resources/deployments/{deploymentName}/cancel"} # type: ignore def _validate_at_subscription_scope_initial( - self, - deployment_name: str, - parameters: "_models.Deployment", - **kwargs: Any - ) -> Optional["_models.DeploymentValidateResult"]: - cls = kwargs.pop('cls', None) # type: ClsType[Optional["_models.DeploymentValidateResult"]] + self, deployment_name: str, parameters: Union[_models.Deployment, IO], **kwargs: Any + ) -> Optional[_models.DeploymentValidateResult]: error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', "2020-06-01") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + api_version = kwargs.pop("api_version", _params.pop("api-version", "2020-06-01")) # type: str + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[Optional[_models.DeploymentValidateResult]] - _json = self._serialize.body(parameters, 'Deployment') + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(parameters, (IO, bytes)): + _content = parameters + else: + _json = self._serialize.body(parameters, "Deployment") - request = build_deployments_validate_at_subscription_scope_request_initial( + request = build_deployments_validate_at_subscription_scope_request( deployment_name=deployment_name, subscription_id=self._config.subscription_id, api_version=api_version, content_type=content_type, json=_json, - template_url=self._validate_at_subscription_scope_initial.metadata['url'], + content=_content, + template_url=self._validate_at_subscription_scope_initial.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200, 202, 400]: @@ -6296,33 +6413,37 @@ def _validate_at_subscription_scope_initial( deserialized = None if response.status_code == 200: - deserialized = self._deserialize('DeploymentValidateResult', pipeline_response) + deserialized = self._deserialize("DeploymentValidateResult", pipeline_response) if response.status_code == 400: - deserialized = self._deserialize('DeploymentValidateResult', pipeline_response) + deserialized = self._deserialize("DeploymentValidateResult", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - _validate_at_subscription_scope_initial.metadata = {'url': "/subscriptions/{subscriptionId}/providers/Microsoft.Resources/deployments/{deploymentName}/validate"} # type: ignore - + _validate_at_subscription_scope_initial.metadata = {"url": "/subscriptions/{subscriptionId}/providers/Microsoft.Resources/deployments/{deploymentName}/validate"} # type: ignore - @distributed_trace + @overload def begin_validate_at_subscription_scope( self, deployment_name: str, - parameters: "_models.Deployment", + parameters: _models.Deployment, + *, + content_type: str = "application/json", **kwargs: Any - ) -> LROPoller["_models.DeploymentValidateResult"]: + ) -> LROPoller[_models.DeploymentValidateResult]: """Validates whether the specified template is syntactically correct and will be accepted by Azure Resource Manager.. - :param deployment_name: The name of the deployment. + :param deployment_name: The name of the deployment. Required. :type deployment_name: str - :param parameters: Parameters to validate. + :param parameters: Parameters to validate. Required. :type parameters: ~azure.mgmt.resource.resources.v2020_06_01.models.Deployment + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str :keyword callable cls: A custom type or function that will be passed the direct response :keyword str continuation_token: A continuation token to restart a poller from a saved state. :keyword polling: By default, your polling method will be ARMPolling. Pass in False for this @@ -6335,83 +6456,155 @@ def begin_validate_at_subscription_scope( cls(response) :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.resource.resources.v2020_06_01.models.DeploymentValidateResult] - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - api_version = kwargs.pop('api_version', "2020-06-01") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] - polling = kwargs.pop('polling', True) # type: Union[bool, PollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType["_models.DeploymentValidateResult"] - lro_delay = kwargs.pop( - 'polling_interval', - self._config.polling_interval - ) - cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] + + @overload + def begin_validate_at_subscription_scope( + self, deployment_name: str, parameters: IO, *, content_type: str = "application/json", **kwargs: Any + ) -> LROPoller[_models.DeploymentValidateResult]: + """Validates whether the specified template is syntactically correct and will be accepted by Azure + Resource Manager.. + + :param deployment_name: The name of the deployment. Required. + :type deployment_name: str + :param parameters: Parameters to validate. Required. + :type parameters: IO + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be ARMPolling. Pass in False for this + operation to not poll, or pass in your own initialized polling object for a personal polling + strategy. + :paramtype polling: bool or ~azure.core.polling.PollingMethod + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of LROPoller that returns either DeploymentValidateResult or the result of + cls(response) + :rtype: + ~azure.core.polling.LROPoller[~azure.mgmt.resource.resources.v2020_06_01.models.DeploymentValidateResult] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace + def begin_validate_at_subscription_scope( + self, deployment_name: str, parameters: Union[_models.Deployment, IO], **kwargs: Any + ) -> LROPoller[_models.DeploymentValidateResult]: + """Validates whether the specified template is syntactically correct and will be accepted by Azure + Resource Manager.. + + :param deployment_name: The name of the deployment. Required. + :type deployment_name: str + :param parameters: Parameters to validate. Is either a model type or a IO type. Required. + :type parameters: ~azure.mgmt.resource.resources.v2020_06_01.models.Deployment or IO + :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. + Default value is None. + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be ARMPolling. Pass in False for this + operation to not poll, or pass in your own initialized polling object for a personal polling + strategy. + :paramtype polling: bool or ~azure.core.polling.PollingMethod + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of LROPoller that returns either DeploymentValidateResult or the result of + cls(response) + :rtype: + ~azure.core.polling.LROPoller[~azure.mgmt.resource.resources.v2020_06_01.models.DeploymentValidateResult] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _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", "2020-06-01")) # type: str + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.DeploymentValidateResult] + polling = kwargs.pop("polling", True) # type: Union[bool, PollingMethod] + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token = kwargs.pop("continuation_token", None) # type: Optional[str] if cont_token is None: - raw_result = self._validate_at_subscription_scope_initial( + raw_result = self._validate_at_subscription_scope_initial( # type: ignore deployment_name=deployment_name, parameters=parameters, api_version=api_version, content_type=content_type, - cls=lambda x,y,z: x, + cls=lambda x, y, z: x, + headers=_headers, + params=_params, **kwargs ) - kwargs.pop('error_map', None) + kwargs.pop("error_map", None) def get_long_running_output(pipeline_response): - response = pipeline_response.http_response - deserialized = self._deserialize('DeploymentValidateResult', pipeline_response) + deserialized = self._deserialize("DeploymentValidateResult", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - - if polling is True: polling_method = ARMPolling(lro_delay, **kwargs) - elif polling is False: polling_method = NoPolling() - else: polling_method = polling + if polling is True: + polling_method = cast(PollingMethod, ARMPolling(lro_delay, **kwargs)) # type: PollingMethod + elif polling is False: + polling_method = cast(PollingMethod, NoPolling()) + else: + polling_method = polling if cont_token: return LROPoller.from_continuation_token( polling_method=polling_method, continuation_token=cont_token, client=self._client, - deserialization_callback=get_long_running_output + deserialization_callback=get_long_running_output, ) return LROPoller(self._client, raw_result, get_long_running_output, polling_method) - begin_validate_at_subscription_scope.metadata = {'url': "/subscriptions/{subscriptionId}/providers/Microsoft.Resources/deployments/{deploymentName}/validate"} # type: ignore + begin_validate_at_subscription_scope.metadata = {"url": "/subscriptions/{subscriptionId}/providers/Microsoft.Resources/deployments/{deploymentName}/validate"} # type: ignore def _what_if_at_subscription_scope_initial( - self, - deployment_name: str, - parameters: "_models.DeploymentWhatIf", - **kwargs: Any - ) -> Optional["_models.WhatIfOperationResult"]: - cls = kwargs.pop('cls', None) # type: ClsType[Optional["_models.WhatIfOperationResult"]] + self, deployment_name: str, parameters: Union[_models.DeploymentWhatIf, IO], **kwargs: Any + ) -> Optional[_models.WhatIfOperationResult]: error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', "2020-06-01") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + api_version = kwargs.pop("api_version", _params.pop("api-version", "2020-06-01")) # type: str + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[Optional[_models.WhatIfOperationResult]] - _json = self._serialize.body(parameters, 'DeploymentWhatIf') + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(parameters, (IO, bytes)): + _content = parameters + else: + _json = self._serialize.body(parameters, "DeploymentWhatIf") - request = build_deployments_what_if_at_subscription_scope_request_initial( + request = build_deployments_what_if_at_subscription_scope_request( deployment_name=deployment_name, subscription_id=self._config.subscription_id, api_version=api_version, content_type=content_type, json=_json, - template_url=self._what_if_at_subscription_scope_initial.metadata['url'], + content=_content, + template_url=self._what_if_at_subscription_scope_initial.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200, 202]: @@ -6421,35 +6614,38 @@ def _what_if_at_subscription_scope_initial( deserialized = None response_headers = {} if response.status_code == 200: - deserialized = self._deserialize('WhatIfOperationResult', pipeline_response) + deserialized = self._deserialize("WhatIfOperationResult", pipeline_response) if response.status_code == 202: - response_headers['Location']=self._deserialize('str', response.headers.get('Location')) - response_headers['Retry-After']=self._deserialize('str', response.headers.get('Retry-After')) - + response_headers["Location"] = self._deserialize("str", response.headers.get("Location")) + response_headers["Retry-After"] = self._deserialize("str", response.headers.get("Retry-After")) if cls: return cls(pipeline_response, deserialized, response_headers) return deserialized - _what_if_at_subscription_scope_initial.metadata = {'url': "/subscriptions/{subscriptionId}/providers/Microsoft.Resources/deployments/{deploymentName}/whatIf"} # type: ignore - + _what_if_at_subscription_scope_initial.metadata = {"url": "/subscriptions/{subscriptionId}/providers/Microsoft.Resources/deployments/{deploymentName}/whatIf"} # type: ignore - @distributed_trace + @overload def begin_what_if_at_subscription_scope( self, deployment_name: str, - parameters: "_models.DeploymentWhatIf", + parameters: _models.DeploymentWhatIf, + *, + content_type: str = "application/json", **kwargs: Any - ) -> LROPoller["_models.WhatIfOperationResult"]: + ) -> LROPoller[_models.WhatIfOperationResult]: """Returns changes that will be made by the deployment if executed at the scope of the subscription. - :param deployment_name: The name of the deployment. + :param deployment_name: The name of the deployment. Required. :type deployment_name: str - :param parameters: Parameters to What If. + :param parameters: Parameters to What If. Required. :type parameters: ~azure.mgmt.resource.resources.v2020_06_01.models.DeploymentWhatIf + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str :keyword callable cls: A custom type or function that will be passed the direct response :keyword str continuation_token: A continuation token to restart a poller from a saved state. :keyword polling: By default, your polling method will be ARMPolling. Pass in False for this @@ -6462,111 +6658,174 @@ def begin_what_if_at_subscription_scope( cls(response) :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.resource.resources.v2020_06_01.models.WhatIfOperationResult] - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - api_version = kwargs.pop('api_version', "2020-06-01") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] - polling = kwargs.pop('polling', True) # type: Union[bool, PollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType["_models.WhatIfOperationResult"] - lro_delay = kwargs.pop( - 'polling_interval', - self._config.polling_interval - ) - cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] + + @overload + def begin_what_if_at_subscription_scope( + self, deployment_name: str, parameters: IO, *, content_type: str = "application/json", **kwargs: Any + ) -> LROPoller[_models.WhatIfOperationResult]: + """Returns changes that will be made by the deployment if executed at the scope of the + subscription. + + :param deployment_name: The name of the deployment. Required. + :type deployment_name: str + :param parameters: Parameters to What If. Required. + :type parameters: IO + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be ARMPolling. Pass in False for this + operation to not poll, or pass in your own initialized polling object for a personal polling + strategy. + :paramtype polling: bool or ~azure.core.polling.PollingMethod + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of LROPoller that returns either WhatIfOperationResult or the result of + cls(response) + :rtype: + ~azure.core.polling.LROPoller[~azure.mgmt.resource.resources.v2020_06_01.models.WhatIfOperationResult] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace + def begin_what_if_at_subscription_scope( + self, deployment_name: str, parameters: Union[_models.DeploymentWhatIf, IO], **kwargs: Any + ) -> LROPoller[_models.WhatIfOperationResult]: + """Returns changes that will be made by the deployment if executed at the scope of the + subscription. + + :param deployment_name: The name of the deployment. Required. + :type deployment_name: str + :param parameters: Parameters to What If. Is either a model type or a IO type. Required. + :type parameters: ~azure.mgmt.resource.resources.v2020_06_01.models.DeploymentWhatIf or IO + :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. + Default value is None. + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be ARMPolling. Pass in False for this + operation to not poll, or pass in your own initialized polling object for a personal polling + strategy. + :paramtype polling: bool or ~azure.core.polling.PollingMethod + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of LROPoller that returns either WhatIfOperationResult or the result of + cls(response) + :rtype: + ~azure.core.polling.LROPoller[~azure.mgmt.resource.resources.v2020_06_01.models.WhatIfOperationResult] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _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", "2020-06-01")) # type: str + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.WhatIfOperationResult] + polling = kwargs.pop("polling", True) # type: Union[bool, PollingMethod] + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token = kwargs.pop("continuation_token", None) # type: Optional[str] if cont_token is None: - raw_result = self._what_if_at_subscription_scope_initial( + raw_result = self._what_if_at_subscription_scope_initial( # type: ignore deployment_name=deployment_name, parameters=parameters, api_version=api_version, content_type=content_type, - cls=lambda x,y,z: x, + cls=lambda x, y, z: x, + headers=_headers, + params=_params, **kwargs ) - kwargs.pop('error_map', None) + kwargs.pop("error_map", None) def get_long_running_output(pipeline_response): - response = pipeline_response.http_response - deserialized = self._deserialize('WhatIfOperationResult', pipeline_response) + deserialized = self._deserialize("WhatIfOperationResult", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - - if polling is True: polling_method = ARMPolling(lro_delay, lro_options={'final-state-via': 'location'}, **kwargs) - elif polling is False: polling_method = NoPolling() - else: polling_method = polling + if polling is True: + polling_method = cast( + PollingMethod, ARMPolling(lro_delay, lro_options={"final-state-via": "location"}, **kwargs) + ) # type: PollingMethod + elif polling is False: + polling_method = cast(PollingMethod, NoPolling()) + else: + polling_method = polling if cont_token: return LROPoller.from_continuation_token( polling_method=polling_method, continuation_token=cont_token, client=self._client, - deserialization_callback=get_long_running_output + deserialization_callback=get_long_running_output, ) return LROPoller(self._client, raw_result, get_long_running_output, polling_method) - begin_what_if_at_subscription_scope.metadata = {'url': "/subscriptions/{subscriptionId}/providers/Microsoft.Resources/deployments/{deploymentName}/whatIf"} # type: ignore + begin_what_if_at_subscription_scope.metadata = {"url": "/subscriptions/{subscriptionId}/providers/Microsoft.Resources/deployments/{deploymentName}/whatIf"} # type: ignore @distributed_trace def export_template_at_subscription_scope( - self, - deployment_name: str, - **kwargs: Any - ) -> "_models.DeploymentExportResult": + self, deployment_name: str, **kwargs: Any + ) -> _models.DeploymentExportResult: """Exports the template used for specified deployment. - :param deployment_name: The name of the deployment. + :param deployment_name: The name of the deployment. Required. :type deployment_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: DeploymentExportResult, or the result of cls(response) + :return: DeploymentExportResult or the result of cls(response) :rtype: ~azure.mgmt.resource.resources.v2020_06_01.models.DeploymentExportResult - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.DeploymentExportResult"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + 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', "2020-06-01") # type: str + api_version = kwargs.pop("api_version", _params.pop("api-version", "2020-06-01")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[_models.DeploymentExportResult] - request = build_deployments_export_template_at_subscription_scope_request( deployment_name=deployment_name, subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.export_template_at_subscription_scope.metadata['url'], + template_url=self.export_template_at_subscription_scope.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) - deserialized = self._deserialize('DeploymentExportResult', pipeline_response) + deserialized = self._deserialize("DeploymentExportResult", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - export_template_at_subscription_scope.metadata = {'url': "/subscriptions/{subscriptionId}/providers/Microsoft.Resources/deployments/{deploymentName}/exportTemplate"} # type: ignore - + export_template_at_subscription_scope.metadata = {"url": "/subscriptions/{subscriptionId}/providers/Microsoft.Resources/deployments/{deploymentName}/exportTemplate"} # type: ignore @distributed_trace def list_at_subscription_scope( - self, - filter: Optional[str] = None, - top: Optional[int] = None, - **kwargs: Any - ) -> Iterable["_models.DeploymentListResult"]: + self, filter: Optional[str] = None, top: Optional[int] = None, **kwargs: Any + ) -> Iterable["_models.DeploymentExtended"]: """Get all the deployments for a subscription. :param filter: The filter to apply on the operation. For example, you can use @@ -6576,40 +6835,48 @@ def list_at_subscription_scope( value is None. :type top: int :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either DeploymentListResult or the result of - cls(response) + :return: An iterator like instance of either DeploymentExtended or the result of cls(response) :rtype: - ~azure.core.paging.ItemPaged[~azure.mgmt.resource.resources.v2020_06_01.models.DeploymentListResult] - :raises: ~azure.core.exceptions.HttpResponseError + ~azure.core.paging.ItemPaged[~azure.mgmt.resource.resources.v2020_06_01.models.DeploymentExtended] + :raises ~azure.core.exceptions.HttpResponseError: """ - api_version = kwargs.pop('api_version', "2020-06-01") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2020-06-01")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[_models.DeploymentListResult] - cls = kwargs.pop('cls', None) # type: ClsType["_models.DeploymentListResult"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) + def prepare_request(next_link=None): if not next_link: - + request = build_deployments_list_at_subscription_scope_request( subscription_id=self._config.subscription_id, - api_version=api_version, filter=filter, top=top, - template_url=self.list_at_subscription_scope.metadata['url'], + api_version=api_version, + template_url=self.list_at_subscription_scope.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore else: - - request = build_deployments_list_at_subscription_scope_request( - subscription_id=self._config.subscription_id, - template_url=next_link, - ) + # make call to next link with the client's api-version + _parsed_next_link = urlparse(next_link) + _next_request_params = case_insensitive_dict(parse_qs(_parsed_next_link.query)) + _next_request_params["api-version"] = self._config.api_version + request = HttpRequest("GET", urljoin(next_link, _parsed_next_link.path), params=_next_request_params) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore request.method = "GET" return request @@ -6623,10 +6890,8 @@ def extract_data(pipeline_response): def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) response = pipeline_response.http_response @@ -6636,42 +6901,43 @@ def get_next(next_link=None): return pipeline_response + return ItemPaged(get_next, extract_data) - return ItemPaged( - get_next, extract_data - ) - list_at_subscription_scope.metadata = {'url': "/subscriptions/{subscriptionId}/providers/Microsoft.Resources/deployments/"} # type: ignore + list_at_subscription_scope.metadata = {"url": "/subscriptions/{subscriptionId}/providers/Microsoft.Resources/deployments/"} # type: ignore def _delete_initial( # pylint: disable=inconsistent-return-statements - self, - resource_group_name: str, - deployment_name: str, - **kwargs: Any + self, resource_group_name: str, deployment_name: str, **kwargs: Any ) -> None: - cls = kwargs.pop('cls', None) # type: ClsType[None] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + 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', "2020-06-01") # type: str + api_version = kwargs.pop("api_version", _params.pop("api-version", "2020-06-01")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[None] - - request = build_deployments_delete_request_initial( + request = build_deployments_delete_request( resource_group_name=resource_group_name, deployment_name=deployment_name, subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self._delete_initial.metadata['url'], + template_url=self._delete_initial.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [202, 204]: @@ -6681,16 +6947,10 @@ 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.Resources/deployments/{deploymentName}"} # type: ignore - + _delete_initial.metadata = {"url": "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/Microsoft.Resources/deployments/{deploymentName}"} # type: ignore @distributed_trace - def begin_delete( # pylint: disable=inconsistent-return-statements - self, - resource_group_name: str, - deployment_name: str, - **kwargs: Any - ) -> LROPoller[None]: + def begin_delete(self, resource_group_name: str, deployment_name: str, **kwargs: Any) -> LROPoller[None]: """Deletes a deployment from the deployment history. A template deployment that is currently running cannot be deleted. Deleting a template @@ -6703,9 +6963,9 @@ def begin_delete( # pylint: disable=inconsistent-return-statements asynchronous request failed, the URI in the Location header returns an error-level status code. :param resource_group_name: The name of the resource group with the deployment to delete. The - name is case insensitive. + name is case insensitive. Required. :type resource_group_name: str - :param deployment_name: The name of the deployment. + :param deployment_name: The name of the deployment. Required. :type deployment_name: str :keyword callable cls: A custom type or function that will be passed the direct response :keyword str continuation_token: A continuation token to restart a poller from a saved state. @@ -6717,88 +6977,93 @@ def begin_delete( # pylint: disable=inconsistent-return-statements Retry-After header is present. :return: An instance of LROPoller that returns either None or the result of cls(response) :rtype: ~azure.core.polling.LROPoller[None] - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - api_version = kwargs.pop('api_version', "2020-06-01") # type: str - polling = kwargs.pop('polling', True) # type: Union[bool, PollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType[None] - lro_delay = kwargs.pop( - 'polling_interval', - self._config.polling_interval - ) - cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2020-06-01")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[None] + polling = kwargs.pop("polling", True) # type: Union[bool, PollingMethod] + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token = kwargs.pop("continuation_token", None) # type: Optional[str] if cont_token is None: - raw_result = self._delete_initial( + raw_result = self._delete_initial( # type: ignore resource_group_name=resource_group_name, deployment_name=deployment_name, api_version=api_version, - cls=lambda x,y,z: x, + cls=lambda x, y, z: x, + headers=_headers, + params=_params, **kwargs ) - kwargs.pop('error_map', None) + kwargs.pop("error_map", None) - def get_long_running_output(pipeline_response): + def get_long_running_output(pipeline_response): # pylint: disable=inconsistent-return-statements if cls: return cls(pipeline_response, None, {}) - - if polling is True: polling_method = ARMPolling(lro_delay, **kwargs) - elif polling is False: polling_method = NoPolling() - else: polling_method = polling + if polling is True: + polling_method = cast(PollingMethod, ARMPolling(lro_delay, **kwargs)) # type: PollingMethod + elif polling is False: + polling_method = cast(PollingMethod, NoPolling()) + else: + polling_method = polling if cont_token: return LROPoller.from_continuation_token( polling_method=polling_method, continuation_token=cont_token, client=self._client, - deserialization_callback=get_long_running_output + deserialization_callback=get_long_running_output, ) return LROPoller(self._client, raw_result, get_long_running_output, polling_method) - begin_delete.metadata = {'url': "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/Microsoft.Resources/deployments/{deploymentName}"} # type: ignore + begin_delete.metadata = {"url": "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/Microsoft.Resources/deployments/{deploymentName}"} # type: ignore @distributed_trace - def check_existence( - self, - resource_group_name: str, - deployment_name: str, - **kwargs: Any - ) -> bool: + def check_existence(self, resource_group_name: str, deployment_name: str, **kwargs: Any) -> bool: """Checks whether the deployment exists. :param resource_group_name: The name of the resource group with the deployment to check. The - name is case insensitive. + name is case insensitive. Required. :type resource_group_name: str - :param deployment_name: The name of the deployment. + :param deployment_name: The name of the deployment. Required. :type deployment_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: bool, or the result of cls(response) + :return: bool or the result of cls(response) :rtype: bool - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType[None] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) - api_version = kwargs.pop('api_version', "2020-06-01") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2020-06-01")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[None] - request = build_deployments_check_existence_request( resource_group_name=resource_group_name, deployment_name=deployment_name, subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.check_existence.metadata['url'], + template_url=self.check_existence.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [204, 404]: @@ -6809,44 +7074,53 @@ def check_existence( return cls(pipeline_response, None, {}) return 200 <= response.status_code <= 299 - check_existence.metadata = {'url': "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/Microsoft.Resources/deployments/{deploymentName}"} # type: ignore - + check_existence.metadata = {"url": "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/Microsoft.Resources/deployments/{deploymentName}"} # type: ignore def _create_or_update_initial( - self, - resource_group_name: str, - deployment_name: str, - parameters: "_models.Deployment", - **kwargs: Any - ) -> "_models.DeploymentExtended": - cls = kwargs.pop('cls', None) # type: ClsType["_models.DeploymentExtended"] + self, resource_group_name: str, deployment_name: str, parameters: Union[_models.Deployment, IO], **kwargs: Any + ) -> _models.DeploymentExtended: error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', "2020-06-01") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + api_version = kwargs.pop("api_version", _params.pop("api-version", "2020-06-01")) # type: str + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.DeploymentExtended] - _json = self._serialize.body(parameters, 'Deployment') + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(parameters, (IO, bytes)): + _content = parameters + else: + _json = self._serialize.body(parameters, "Deployment") - request = build_deployments_create_or_update_request_initial( + request = build_deployments_create_or_update_request( resource_group_name=resource_group_name, deployment_name=deployment_name, subscription_id=self._config.subscription_id, api_version=api_version, content_type=content_type, json=_json, - template_url=self._create_or_update_initial.metadata['url'], + content=_content, + template_url=self._create_or_update_initial.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200, 201]: @@ -6854,38 +7128,42 @@ def _create_or_update_initial( raise HttpResponseError(response=response, error_format=ARMErrorFormat) if response.status_code == 200: - deserialized = self._deserialize('DeploymentExtended', pipeline_response) + deserialized = self._deserialize("DeploymentExtended", pipeline_response) if response.status_code == 201: - deserialized = self._deserialize('DeploymentExtended', pipeline_response) + deserialized = self._deserialize("DeploymentExtended", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - _create_or_update_initial.metadata = {'url': "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/Microsoft.Resources/deployments/{deploymentName}"} # type: ignore - + _create_or_update_initial.metadata = {"url": "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/Microsoft.Resources/deployments/{deploymentName}"} # type: ignore - @distributed_trace + @overload def begin_create_or_update( self, resource_group_name: str, deployment_name: str, - parameters: "_models.Deployment", + parameters: _models.Deployment, + *, + content_type: str = "application/json", **kwargs: Any - ) -> LROPoller["_models.DeploymentExtended"]: + ) -> LROPoller[_models.DeploymentExtended]: """Deploys resources to a resource group. You can provide the template and parameters directly in the request or link to JSON files. :param resource_group_name: The name of the resource group to deploy the resources to. The name - is case insensitive. The resource group must already exist. + is case insensitive. The resource group must already exist. Required. :type resource_group_name: str - :param deployment_name: The name of the deployment. + :param deployment_name: The name of the deployment. Required. :type deployment_name: str - :param parameters: Additional parameters supplied to the operation. + :param parameters: Additional parameters supplied to the operation. Required. :type parameters: ~azure.mgmt.resource.resources.v2020_06_01.models.Deployment + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str :keyword callable cls: A custom type or function that will be passed the direct response :keyword str continuation_token: A continuation token to restart a poller from a saved state. :keyword polling: By default, your polling method will be ARMPolling. Pass in False for this @@ -6898,115 +7176,189 @@ def begin_create_or_update( cls(response) :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.resource.resources.v2020_06_01.models.DeploymentExtended] - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - api_version = kwargs.pop('api_version', "2020-06-01") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] - polling = kwargs.pop('polling', True) # type: Union[bool, PollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType["_models.DeploymentExtended"] - lro_delay = kwargs.pop( - 'polling_interval', - self._config.polling_interval - ) - cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] - if cont_token is None: - raw_result = self._create_or_update_initial( - resource_group_name=resource_group_name, - deployment_name=deployment_name, - parameters=parameters, - api_version=api_version, - content_type=content_type, - cls=lambda x,y,z: x, - **kwargs - ) - kwargs.pop('error_map', None) - - def get_long_running_output(pipeline_response): - response = pipeline_response.http_response - deserialized = self._deserialize('DeploymentExtended', pipeline_response) - if cls: - return cls(pipeline_response, deserialized, {}) - return deserialized - - - if polling is True: polling_method = ARMPolling(lro_delay, **kwargs) - elif polling is False: polling_method = NoPolling() - else: polling_method = polling - if cont_token: - return LROPoller.from_continuation_token( - polling_method=polling_method, - continuation_token=cont_token, - client=self._client, - deserialization_callback=get_long_running_output - ) - return LROPoller(self._client, raw_result, get_long_running_output, polling_method) - - begin_create_or_update.metadata = {'url': "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/Microsoft.Resources/deployments/{deploymentName}"} # type: ignore - @distributed_trace - def get( + @overload + def begin_create_or_update( self, resource_group_name: str, deployment_name: str, + parameters: IO, + *, + content_type: str = "application/json", **kwargs: Any - ) -> "_models.DeploymentExtended": - """Gets a deployment. + ) -> LROPoller[_models.DeploymentExtended]: + """Deploys resources to a resource group. - :param resource_group_name: The name of the resource group. The name is case insensitive. + You can provide the template and parameters directly in the request or link to JSON files. + + :param resource_group_name: The name of the resource group to deploy the resources to. The name + is case insensitive. The resource group must already exist. Required. :type resource_group_name: str - :param deployment_name: The name of the deployment. + :param deployment_name: The name of the deployment. Required. :type deployment_name: str + :param parameters: Additional parameters supplied to the operation. Required. + :type parameters: IO + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: DeploymentExtended, or the result of cls(response) - :rtype: ~azure.mgmt.resource.resources.v2020_06_01.models.DeploymentExtended - :raises: ~azure.core.exceptions.HttpResponseError - """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.DeploymentExtended"] - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {})) - - api_version = kwargs.pop('api_version', "2020-06-01") # type: str + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be ARMPolling. Pass in False for this + operation to not poll, or pass in your own initialized polling object for a personal polling + strategy. + :paramtype polling: bool or ~azure.core.polling.PollingMethod + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of LROPoller that returns either DeploymentExtended or the result of + cls(response) + :rtype: + ~azure.core.polling.LROPoller[~azure.mgmt.resource.resources.v2020_06_01.models.DeploymentExtended] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace + def begin_create_or_update( + self, resource_group_name: str, deployment_name: str, parameters: Union[_models.Deployment, IO], **kwargs: Any + ) -> LROPoller[_models.DeploymentExtended]: + """Deploys resources to a resource group. + + You can provide the template and parameters directly in the request or link to JSON files. + + :param resource_group_name: The name of the resource group to deploy the resources to. The name + is case insensitive. The resource group must already exist. Required. + :type resource_group_name: str + :param deployment_name: The name of the deployment. Required. + :type deployment_name: str + :param parameters: Additional parameters supplied to the operation. Is either a model type or a + IO type. Required. + :type parameters: ~azure.mgmt.resource.resources.v2020_06_01.models.Deployment or IO + :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. + Default value is None. + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be ARMPolling. Pass in False for this + operation to not poll, or pass in your own initialized polling object for a personal polling + strategy. + :paramtype polling: bool or ~azure.core.polling.PollingMethod + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of LROPoller that returns either DeploymentExtended or the result of + cls(response) + :rtype: + ~azure.core.polling.LROPoller[~azure.mgmt.resource.resources.v2020_06_01.models.DeploymentExtended] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _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", "2020-06-01")) # type: str + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.DeploymentExtended] + polling = kwargs.pop("polling", True) # type: Union[bool, PollingMethod] + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token = kwargs.pop("continuation_token", None) # type: Optional[str] + if cont_token is None: + raw_result = self._create_or_update_initial( # type: ignore + resource_group_name=resource_group_name, + deployment_name=deployment_name, + parameters=parameters, + api_version=api_version, + content_type=content_type, + cls=lambda x, y, z: x, + headers=_headers, + params=_params, + **kwargs + ) + kwargs.pop("error_map", None) + + def get_long_running_output(pipeline_response): + deserialized = self._deserialize("DeploymentExtended", pipeline_response) + if cls: + return cls(pipeline_response, deserialized, {}) + return deserialized + + if polling is True: + polling_method = cast(PollingMethod, ARMPolling(lro_delay, **kwargs)) # type: PollingMethod + elif polling is False: + polling_method = cast(PollingMethod, NoPolling()) + else: + polling_method = polling + if cont_token: + return LROPoller.from_continuation_token( + polling_method=polling_method, + continuation_token=cont_token, + client=self._client, + deserialization_callback=get_long_running_output, + ) + return LROPoller(self._client, raw_result, get_long_running_output, polling_method) + + begin_create_or_update.metadata = {"url": "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/Microsoft.Resources/deployments/{deploymentName}"} # type: ignore + + @distributed_trace + def get(self, resource_group_name: str, deployment_name: str, **kwargs: Any) -> _models.DeploymentExtended: + """Gets a deployment. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param deployment_name: The name of the deployment. Required. + :type deployment_name: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: DeploymentExtended or the result of cls(response) + :rtype: ~azure.mgmt.resource.resources.v2020_06_01.models.DeploymentExtended + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2020-06-01")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[_models.DeploymentExtended] - request = build_deployments_get_request( resource_group_name=resource_group_name, deployment_name=deployment_name, subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.get.metadata['url'], + template_url=self.get.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) - deserialized = self._deserialize('DeploymentExtended', pipeline_response) + deserialized = self._deserialize("DeploymentExtended", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - get.metadata = {'url': "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/Microsoft.Resources/deployments/{deploymentName}"} # type: ignore - + get.metadata = {"url": "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/Microsoft.Resources/deployments/{deploymentName}"} # type: ignore @distributed_trace def cancel( # pylint: disable=inconsistent-return-statements - self, - resource_group_name: str, - deployment_name: str, - **kwargs: Any + self, resource_group_name: str, deployment_name: str, **kwargs: Any ) -> None: """Cancels a currently running template deployment. @@ -7016,38 +7368,45 @@ def cancel( # pylint: disable=inconsistent-return-statements partially deployed. :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. :type resource_group_name: str - :param deployment_name: The name of the deployment. + :param deployment_name: The name of the deployment. Required. :type deployment_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: None, or the result of cls(response) + :return: None or the result of cls(response) :rtype: None - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType[None] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) - api_version = kwargs.pop('api_version', "2020-06-01") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2020-06-01")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[None] - request = build_deployments_cancel_request( resource_group_name=resource_group_name, deployment_name=deployment_name, subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.cancel.metadata['url'], + template_url=self.cancel.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [204]: @@ -7057,44 +7416,53 @@ def cancel( # pylint: disable=inconsistent-return-statements if cls: return cls(pipeline_response, None, {}) - cancel.metadata = {'url': "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/Microsoft.Resources/deployments/{deploymentName}/cancel"} # type: ignore - + cancel.metadata = {"url": "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/Microsoft.Resources/deployments/{deploymentName}/cancel"} # type: ignore def _validate_initial( - self, - resource_group_name: str, - deployment_name: str, - parameters: "_models.Deployment", - **kwargs: Any - ) -> Optional["_models.DeploymentValidateResult"]: - cls = kwargs.pop('cls', None) # type: ClsType[Optional["_models.DeploymentValidateResult"]] + self, resource_group_name: str, deployment_name: str, parameters: Union[_models.Deployment, IO], **kwargs: Any + ) -> Optional[_models.DeploymentValidateResult]: error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', "2020-06-01") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + api_version = kwargs.pop("api_version", _params.pop("api-version", "2020-06-01")) # type: str + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[Optional[_models.DeploymentValidateResult]] - _json = self._serialize.body(parameters, 'Deployment') + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(parameters, (IO, bytes)): + _content = parameters + else: + _json = self._serialize.body(parameters, "Deployment") - request = build_deployments_validate_request_initial( + request = build_deployments_validate_request( resource_group_name=resource_group_name, deployment_name=deployment_name, subscription_id=self._config.subscription_id, api_version=api_version, content_type=content_type, json=_json, - template_url=self._validate_initial.metadata['url'], + content=_content, + template_url=self._validate_initial.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200, 202, 400]: @@ -7103,37 +7471,41 @@ def _validate_initial( deserialized = None if response.status_code == 200: - deserialized = self._deserialize('DeploymentValidateResult', pipeline_response) + deserialized = self._deserialize("DeploymentValidateResult", pipeline_response) if response.status_code == 400: - deserialized = self._deserialize('DeploymentValidateResult', pipeline_response) + deserialized = self._deserialize("DeploymentValidateResult", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - _validate_initial.metadata = {'url': "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/Microsoft.Resources/deployments/{deploymentName}/validate"} # type: ignore - + _validate_initial.metadata = {"url": "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/Microsoft.Resources/deployments/{deploymentName}/validate"} # type: ignore - @distributed_trace + @overload def begin_validate( self, resource_group_name: str, deployment_name: str, - parameters: "_models.Deployment", + parameters: _models.Deployment, + *, + content_type: str = "application/json", **kwargs: Any - ) -> LROPoller["_models.DeploymentValidateResult"]: + ) -> LROPoller[_models.DeploymentValidateResult]: """Validates whether the specified template is syntactically correct and will be accepted by Azure Resource Manager.. :param resource_group_name: The name of the resource group the template will be deployed to. - The name is case insensitive. + The name is case insensitive. Required. :type resource_group_name: str - :param deployment_name: The name of the deployment. + :param deployment_name: The name of the deployment. Required. :type deployment_name: str - :param parameters: Parameters to validate. + :param parameters: Parameters to validate. Required. :type parameters: ~azure.mgmt.resource.resources.v2020_06_01.models.Deployment + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str :keyword callable cls: A custom type or function that will be passed the direct response :keyword str continuation_token: A continuation token to restart a poller from a saved state. :keyword polling: By default, your polling method will be ARMPolling. Pass in False for this @@ -7146,86 +7518,173 @@ def begin_validate( cls(response) :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.resource.resources.v2020_06_01.models.DeploymentValidateResult] - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - api_version = kwargs.pop('api_version', "2020-06-01") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] - polling = kwargs.pop('polling', True) # type: Union[bool, PollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType["_models.DeploymentValidateResult"] - lro_delay = kwargs.pop( - 'polling_interval', - self._config.polling_interval - ) - cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] + + @overload + def begin_validate( + self, + resource_group_name: str, + deployment_name: str, + parameters: IO, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> LROPoller[_models.DeploymentValidateResult]: + """Validates whether the specified template is syntactically correct and will be accepted by Azure + Resource Manager.. + + :param resource_group_name: The name of the resource group the template will be deployed to. + The name is case insensitive. Required. + :type resource_group_name: str + :param deployment_name: The name of the deployment. Required. + :type deployment_name: str + :param parameters: Parameters to validate. Required. + :type parameters: IO + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be ARMPolling. Pass in False for this + operation to not poll, or pass in your own initialized polling object for a personal polling + strategy. + :paramtype polling: bool or ~azure.core.polling.PollingMethod + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of LROPoller that returns either DeploymentValidateResult or the result of + cls(response) + :rtype: + ~azure.core.polling.LROPoller[~azure.mgmt.resource.resources.v2020_06_01.models.DeploymentValidateResult] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace + def begin_validate( + self, resource_group_name: str, deployment_name: str, parameters: Union[_models.Deployment, IO], **kwargs: Any + ) -> LROPoller[_models.DeploymentValidateResult]: + """Validates whether the specified template is syntactically correct and will be accepted by Azure + Resource Manager.. + + :param resource_group_name: The name of the resource group the template will be deployed to. + The name is case insensitive. Required. + :type resource_group_name: str + :param deployment_name: The name of the deployment. Required. + :type deployment_name: str + :param parameters: Parameters to validate. Is either a model type or a IO type. Required. + :type parameters: ~azure.mgmt.resource.resources.v2020_06_01.models.Deployment or IO + :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. + Default value is None. + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be ARMPolling. Pass in False for this + operation to not poll, or pass in your own initialized polling object for a personal polling + strategy. + :paramtype polling: bool or ~azure.core.polling.PollingMethod + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of LROPoller that returns either DeploymentValidateResult or the result of + cls(response) + :rtype: + ~azure.core.polling.LROPoller[~azure.mgmt.resource.resources.v2020_06_01.models.DeploymentValidateResult] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _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", "2020-06-01")) # type: str + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.DeploymentValidateResult] + polling = kwargs.pop("polling", True) # type: Union[bool, PollingMethod] + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token = kwargs.pop("continuation_token", None) # type: Optional[str] if cont_token is None: - raw_result = self._validate_initial( + raw_result = self._validate_initial( # type: ignore resource_group_name=resource_group_name, deployment_name=deployment_name, parameters=parameters, api_version=api_version, content_type=content_type, - cls=lambda x,y,z: x, + cls=lambda x, y, z: x, + headers=_headers, + params=_params, **kwargs ) - kwargs.pop('error_map', None) + kwargs.pop("error_map", None) def get_long_running_output(pipeline_response): - response = pipeline_response.http_response - deserialized = self._deserialize('DeploymentValidateResult', pipeline_response) + deserialized = self._deserialize("DeploymentValidateResult", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - - if polling is True: polling_method = ARMPolling(lro_delay, **kwargs) - elif polling is False: polling_method = NoPolling() - else: polling_method = polling + if polling is True: + polling_method = cast(PollingMethod, ARMPolling(lro_delay, **kwargs)) # type: PollingMethod + elif polling is False: + polling_method = cast(PollingMethod, NoPolling()) + else: + polling_method = polling if cont_token: return LROPoller.from_continuation_token( polling_method=polling_method, continuation_token=cont_token, client=self._client, - deserialization_callback=get_long_running_output + deserialization_callback=get_long_running_output, ) return LROPoller(self._client, raw_result, get_long_running_output, polling_method) - begin_validate.metadata = {'url': "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/Microsoft.Resources/deployments/{deploymentName}/validate"} # type: ignore + begin_validate.metadata = {"url": "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/Microsoft.Resources/deployments/{deploymentName}/validate"} # type: ignore def _what_if_initial( self, resource_group_name: str, deployment_name: str, - parameters: "_models.DeploymentWhatIf", + parameters: Union[_models.DeploymentWhatIf, IO], **kwargs: Any - ) -> Optional["_models.WhatIfOperationResult"]: - cls = kwargs.pop('cls', None) # type: ClsType[Optional["_models.WhatIfOperationResult"]] + ) -> Optional[_models.WhatIfOperationResult]: error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) - api_version = kwargs.pop('api_version', "2020-06-01") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - _json = self._serialize.body(parameters, 'DeploymentWhatIf') + api_version = kwargs.pop("api_version", _params.pop("api-version", "2020-06-01")) # type: str + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[Optional[_models.WhatIfOperationResult]] - request = build_deployments_what_if_request_initial( + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(parameters, (IO, bytes)): + _content = parameters + else: + _json = self._serialize.body(parameters, "DeploymentWhatIf") + + request = build_deployments_what_if_request( resource_group_name=resource_group_name, deployment_name=deployment_name, subscription_id=self._config.subscription_id, api_version=api_version, content_type=content_type, json=_json, - template_url=self._what_if_initial.metadata['url'], + content=_content, + template_url=self._what_if_initial.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200, 202]: @@ -7235,39 +7694,116 @@ def _what_if_initial( deserialized = None response_headers = {} if response.status_code == 200: - deserialized = self._deserialize('WhatIfOperationResult', pipeline_response) + deserialized = self._deserialize("WhatIfOperationResult", pipeline_response) if response.status_code == 202: - response_headers['Location']=self._deserialize('str', response.headers.get('Location')) - response_headers['Retry-After']=self._deserialize('str', response.headers.get('Retry-After')) - + response_headers["Location"] = self._deserialize("str", response.headers.get("Location")) + response_headers["Retry-After"] = self._deserialize("str", response.headers.get("Retry-After")) if cls: return cls(pipeline_response, deserialized, response_headers) return deserialized - _what_if_initial.metadata = {'url': "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/Microsoft.Resources/deployments/{deploymentName}/whatIf"} # type: ignore + _what_if_initial.metadata = {"url": "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/Microsoft.Resources/deployments/{deploymentName}/whatIf"} # type: ignore + + @overload + def begin_what_if( + self, + resource_group_name: str, + deployment_name: str, + parameters: _models.DeploymentWhatIf, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> LROPoller[_models.WhatIfOperationResult]: + """Returns changes that will be made by the deployment if executed at the scope of the resource + group. + + :param resource_group_name: The name of the resource group the template will be deployed to. + The name is case insensitive. Required. + :type resource_group_name: str + :param deployment_name: The name of the deployment. Required. + :type deployment_name: str + :param parameters: Parameters to validate. Required. + :type parameters: ~azure.mgmt.resource.resources.v2020_06_01.models.DeploymentWhatIf + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be ARMPolling. Pass in False for this + operation to not poll, or pass in your own initialized polling object for a personal polling + strategy. + :paramtype polling: bool or ~azure.core.polling.PollingMethod + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of LROPoller that returns either WhatIfOperationResult or the result of + cls(response) + :rtype: + ~azure.core.polling.LROPoller[~azure.mgmt.resource.resources.v2020_06_01.models.WhatIfOperationResult] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + def begin_what_if( + self, + resource_group_name: str, + deployment_name: str, + parameters: IO, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> LROPoller[_models.WhatIfOperationResult]: + """Returns changes that will be made by the deployment if executed at the scope of the resource + group. + :param resource_group_name: The name of the resource group the template will be deployed to. + The name is case insensitive. Required. + :type resource_group_name: str + :param deployment_name: The name of the deployment. Required. + :type deployment_name: str + :param parameters: Parameters to validate. Required. + :type parameters: IO + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be ARMPolling. Pass in False for this + operation to not poll, or pass in your own initialized polling object for a personal polling + strategy. + :paramtype polling: bool or ~azure.core.polling.PollingMethod + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of LROPoller that returns either WhatIfOperationResult or the result of + cls(response) + :rtype: + ~azure.core.polling.LROPoller[~azure.mgmt.resource.resources.v2020_06_01.models.WhatIfOperationResult] + :raises ~azure.core.exceptions.HttpResponseError: + """ @distributed_trace def begin_what_if( self, resource_group_name: str, deployment_name: str, - parameters: "_models.DeploymentWhatIf", + parameters: Union[_models.DeploymentWhatIf, IO], **kwargs: Any - ) -> LROPoller["_models.WhatIfOperationResult"]: + ) -> LROPoller[_models.WhatIfOperationResult]: """Returns changes that will be made by the deployment if executed at the scope of the resource group. :param resource_group_name: The name of the resource group the template will be deployed to. - The name is case insensitive. + The name is case insensitive. Required. :type resource_group_name: str - :param deployment_name: The name of the deployment. + :param deployment_name: The name of the deployment. Required. :type deployment_name: str - :param parameters: Parameters to validate. - :type parameters: ~azure.mgmt.resource.resources.v2020_06_01.models.DeploymentWhatIf + :param parameters: Parameters to validate. Is either a model type or a IO type. Required. + :type parameters: ~azure.mgmt.resource.resources.v2020_06_01.models.DeploymentWhatIf or IO + :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. + Default value is None. + :paramtype content_type: str :keyword callable cls: A custom type or function that will be passed the direct response :keyword str continuation_token: A continuation token to restart a poller from a saved state. :keyword polling: By default, your polling method will be ARMPolling. Pass in False for this @@ -7280,121 +7816,125 @@ def begin_what_if( cls(response) :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.resource.resources.v2020_06_01.models.WhatIfOperationResult] - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - api_version = kwargs.pop('api_version', "2020-06-01") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] - polling = kwargs.pop('polling', True) # type: Union[bool, PollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType["_models.WhatIfOperationResult"] - lro_delay = kwargs.pop( - 'polling_interval', - self._config.polling_interval - ) - cont_token = kwargs.pop('continuation_token', None) # type: Optional[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", "2020-06-01")) # type: str + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.WhatIfOperationResult] + polling = kwargs.pop("polling", True) # type: Union[bool, PollingMethod] + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token = kwargs.pop("continuation_token", None) # type: Optional[str] if cont_token is None: - raw_result = self._what_if_initial( + raw_result = self._what_if_initial( # type: ignore resource_group_name=resource_group_name, deployment_name=deployment_name, parameters=parameters, api_version=api_version, content_type=content_type, - cls=lambda x,y,z: x, + cls=lambda x, y, z: x, + headers=_headers, + params=_params, **kwargs ) - kwargs.pop('error_map', None) + kwargs.pop("error_map", None) def get_long_running_output(pipeline_response): - response = pipeline_response.http_response - deserialized = self._deserialize('WhatIfOperationResult', pipeline_response) + deserialized = self._deserialize("WhatIfOperationResult", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - - if polling is True: polling_method = ARMPolling(lro_delay, lro_options={'final-state-via': 'location'}, **kwargs) - elif polling is False: polling_method = NoPolling() - else: polling_method = polling + if polling is True: + polling_method = cast( + PollingMethod, ARMPolling(lro_delay, lro_options={"final-state-via": "location"}, **kwargs) + ) # type: PollingMethod + elif polling is False: + polling_method = cast(PollingMethod, NoPolling()) + else: + polling_method = polling if cont_token: return LROPoller.from_continuation_token( polling_method=polling_method, continuation_token=cont_token, client=self._client, - deserialization_callback=get_long_running_output + deserialization_callback=get_long_running_output, ) return LROPoller(self._client, raw_result, get_long_running_output, polling_method) - begin_what_if.metadata = {'url': "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/Microsoft.Resources/deployments/{deploymentName}/whatIf"} # type: ignore + begin_what_if.metadata = {"url": "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/Microsoft.Resources/deployments/{deploymentName}/whatIf"} # type: ignore @distributed_trace def export_template( - self, - resource_group_name: str, - deployment_name: str, - **kwargs: Any - ) -> "_models.DeploymentExportResult": + self, resource_group_name: str, deployment_name: str, **kwargs: Any + ) -> _models.DeploymentExportResult: """Exports the template used for specified deployment. :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. :type resource_group_name: str - :param deployment_name: The name of the deployment. + :param deployment_name: The name of the deployment. Required. :type deployment_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: DeploymentExportResult, or the result of cls(response) + :return: DeploymentExportResult or the result of cls(response) :rtype: ~azure.mgmt.resource.resources.v2020_06_01.models.DeploymentExportResult - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.DeploymentExportResult"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + 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', "2020-06-01") # type: str + api_version = kwargs.pop("api_version", _params.pop("api-version", "2020-06-01")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[_models.DeploymentExportResult] - request = build_deployments_export_template_request( resource_group_name=resource_group_name, deployment_name=deployment_name, subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.export_template.metadata['url'], + template_url=self.export_template.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) - deserialized = self._deserialize('DeploymentExportResult', pipeline_response) + deserialized = self._deserialize("DeploymentExportResult", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - export_template.metadata = {'url': "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/Microsoft.Resources/deployments/{deploymentName}/exportTemplate"} # type: ignore - + export_template.metadata = {"url": "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/Microsoft.Resources/deployments/{deploymentName}/exportTemplate"} # type: ignore @distributed_trace def list_by_resource_group( - self, - resource_group_name: str, - filter: Optional[str] = None, - top: Optional[int] = None, - **kwargs: Any - ) -> Iterable["_models.DeploymentListResult"]: + self, resource_group_name: str, filter: Optional[str] = None, top: Optional[int] = None, **kwargs: Any + ) -> Iterable["_models.DeploymentExtended"]: """Get all the deployments for a resource group. :param resource_group_name: The name of the resource group with the deployments to get. The - name is case insensitive. + name is case insensitive. Required. :type resource_group_name: str :param filter: The filter to apply on the operation. For example, you can use $filter=provisioningState eq '{state}'. Default value is None. @@ -7403,42 +7943,49 @@ def list_by_resource_group( value is None. :type top: int :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either DeploymentListResult or the result of - cls(response) + :return: An iterator like instance of either DeploymentExtended or the result of cls(response) :rtype: - ~azure.core.paging.ItemPaged[~azure.mgmt.resource.resources.v2020_06_01.models.DeploymentListResult] - :raises: ~azure.core.exceptions.HttpResponseError + ~azure.core.paging.ItemPaged[~azure.mgmt.resource.resources.v2020_06_01.models.DeploymentExtended] + :raises ~azure.core.exceptions.HttpResponseError: """ - api_version = kwargs.pop('api_version', "2020-06-01") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2020-06-01")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[_models.DeploymentListResult] - cls = kwargs.pop('cls', None) # type: ClsType["_models.DeploymentListResult"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) + def prepare_request(next_link=None): if not next_link: - + request = build_deployments_list_by_resource_group_request( resource_group_name=resource_group_name, subscription_id=self._config.subscription_id, - api_version=api_version, filter=filter, top=top, - template_url=self.list_by_resource_group.metadata['url'], + 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.url = self._client.format_url(request.url) # type: ignore else: - - request = build_deployments_list_by_resource_group_request( - resource_group_name=resource_group_name, - subscription_id=self._config.subscription_id, - template_url=next_link, - ) + # make call to next link with the client's api-version + _parsed_next_link = urlparse(next_link) + _next_request_params = case_insensitive_dict(parse_qs(_parsed_next_link.query)) + _next_request_params["api-version"] = self._config.api_version + request = HttpRequest("GET", urljoin(next_link, _parsed_next_link.path), params=_next_request_params) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore request.method = "GET" return request @@ -7452,10 +7999,8 @@ def extract_data(pipeline_response): def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) response = pipeline_response.http_response @@ -7465,184 +8010,189 @@ def get_next(next_link=None): return pipeline_response + return ItemPaged(get_next, extract_data) - return ItemPaged( - get_next, extract_data - ) - list_by_resource_group.metadata = {'url': "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/Microsoft.Resources/deployments/"} # type: ignore + list_by_resource_group.metadata = {"url": "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/Microsoft.Resources/deployments/"} # type: ignore @distributed_trace - def calculate_template_hash( - self, - template: Any, - **kwargs: Any - ) -> "_models.TemplateHashResult": + def calculate_template_hash(self, template: JSON, **kwargs: Any) -> _models.TemplateHashResult: """Calculate the hash of the given template. - :param template: The template provided to calculate hash. - :type template: any + :param template: The template provided to calculate hash. Required. + :type template: JSON :keyword callable cls: A custom type or function that will be passed the direct response - :return: TemplateHashResult, or the result of cls(response) + :return: TemplateHashResult or the result of cls(response) :rtype: ~azure.mgmt.resource.resources.v2020_06_01.models.TemplateHashResult - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.TemplateHashResult"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', "2020-06-01") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + api_version = kwargs.pop("api_version", _params.pop("api-version", "2020-06-01")) # type: str + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", "application/json")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[_models.TemplateHashResult] - _json = self._serialize.body(template, 'object') + _json = self._serialize.body(template, "object") request = build_deployments_calculate_template_hash_request( api_version=api_version, content_type=content_type, json=_json, - template_url=self.calculate_template_hash.metadata['url'], + template_url=self.calculate_template_hash.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) - deserialized = self._deserialize('TemplateHashResult', pipeline_response) + deserialized = self._deserialize("TemplateHashResult", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - calculate_template_hash.metadata = {'url': "/providers/Microsoft.Resources/calculateTemplateHash"} # type: ignore + calculate_template_hash.metadata = {"url": "/providers/Microsoft.Resources/calculateTemplateHash"} # type: ignore -class ProvidersOperations(object): - """ProvidersOperations operations. - You should not instantiate this class directly. Instead, you should create a Client instance that - instantiates it for you and attaches it as an attribute. +class ProvidersOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. - :ivar models: Alias to model classes used in this operation group. - :type models: ~azure.mgmt.resource.resources.v2020_06_01.models - :param client: Client for service requests. - :param config: Configuration of service client. - :param serializer: An object model serializer. - :param deserializer: An object model deserializer. + Instead, you should access the following operations through + :class:`~azure.mgmt.resource.resources.v2020_06_01.ResourceManagementClient`'s + :attr:`providers` attribute. """ models = _models - def __init__(self, client, config, serializer, deserializer): - self._client = client - self._serialize = serializer - self._deserialize = deserializer - self._config = config + def __init__(self, *args, **kwargs): + input_args = list(args) + self._client = input_args.pop(0) if input_args else kwargs.pop("client") + self._config = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") @distributed_trace - def unregister( - self, - resource_provider_namespace: str, - **kwargs: Any - ) -> "_models.Provider": + def unregister(self, resource_provider_namespace: str, **kwargs: Any) -> _models.Provider: """Unregisters a subscription from a resource provider. :param resource_provider_namespace: The namespace of the resource provider to unregister. + Required. :type resource_provider_namespace: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: Provider, or the result of cls(response) + :return: Provider or the result of cls(response) :rtype: ~azure.mgmt.resource.resources.v2020_06_01.models.Provider - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.Provider"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + 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', "2020-06-01") # type: str + api_version = kwargs.pop("api_version", _params.pop("api-version", "2020-06-01")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[_models.Provider] - request = build_providers_unregister_request( resource_provider_namespace=resource_provider_namespace, subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.unregister.metadata['url'], + template_url=self.unregister.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) - deserialized = self._deserialize('Provider', pipeline_response) + deserialized = self._deserialize("Provider", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - unregister.metadata = {'url': "/subscriptions/{subscriptionId}/providers/{resourceProviderNamespace}/unregister"} # type: ignore - + unregister.metadata = {"url": "/subscriptions/{subscriptionId}/providers/{resourceProviderNamespace}/unregister"} # type: ignore @distributed_trace def register_at_management_group_scope( # pylint: disable=inconsistent-return-statements - self, - resource_provider_namespace: str, - group_id: str, - **kwargs: Any + self, resource_provider_namespace: str, group_id: str, **kwargs: Any ) -> None: """Registers a management group with a resource provider. :param resource_provider_namespace: The namespace of the resource provider to register. + Required. :type resource_provider_namespace: str - :param group_id: The management group ID. + :param group_id: The management group ID. Required. :type group_id: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: None, or the result of cls(response) + :return: None or the result of cls(response) :rtype: None - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType[None] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) - api_version = kwargs.pop('api_version', "2020-06-01") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2020-06-01")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[None] - request = build_providers_register_at_management_group_scope_request( resource_provider_namespace=resource_provider_namespace, group_id=group_id, api_version=api_version, - template_url=self.register_at_management_group_scope.metadata['url'], + template_url=self.register_at_management_group_scope.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200]: @@ -7652,70 +8202,68 @@ def register_at_management_group_scope( # pylint: disable=inconsistent-return-s if cls: return cls(pipeline_response, None, {}) - register_at_management_group_scope.metadata = {'url': "/providers/Microsoft.Management/managementGroups/{groupId}/providers/{resourceProviderNamespace}/register"} # type: ignore - + register_at_management_group_scope.metadata = {"url": "/providers/Microsoft.Management/managementGroups/{groupId}/providers/{resourceProviderNamespace}/register"} # type: ignore @distributed_trace - def register( - self, - resource_provider_namespace: str, - **kwargs: Any - ) -> "_models.Provider": + def register(self, resource_provider_namespace: str, **kwargs: Any) -> _models.Provider: """Registers a subscription with a resource provider. :param resource_provider_namespace: The namespace of the resource provider to register. + Required. :type resource_provider_namespace: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: Provider, or the result of cls(response) + :return: Provider or the result of cls(response) :rtype: ~azure.mgmt.resource.resources.v2020_06_01.models.Provider - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.Provider"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) - api_version = kwargs.pop('api_version', "2020-06-01") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2020-06-01")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[_models.Provider] - request = build_providers_register_request( resource_provider_namespace=resource_provider_namespace, subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.register.metadata['url'], + template_url=self.register.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) - deserialized = self._deserialize('Provider', pipeline_response) + deserialized = self._deserialize("Provider", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - register.metadata = {'url': "/subscriptions/{subscriptionId}/providers/{resourceProviderNamespace}/register"} # type: ignore - + register.metadata = {"url": "/subscriptions/{subscriptionId}/providers/{resourceProviderNamespace}/register"} # type: ignore @distributed_trace def list( - self, - top: Optional[int] = None, - expand: Optional[str] = None, - **kwargs: Any - ) -> Iterable["_models.ProviderListResult"]: + self, top: Optional[int] = None, expand: Optional[str] = None, **kwargs: Any + ) -> Iterable["_models.Provider"]: """Gets all resource providers for a subscription. :param top: The number of results to return. If null is passed returns all deployments. Default @@ -7726,39 +8274,48 @@ def list( response, use $expand=resourceTypes/aliases. Default value is None. :type expand: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either ProviderListResult or the result of cls(response) + :return: An iterator like instance of either Provider or the result of cls(response) :rtype: - ~azure.core.paging.ItemPaged[~azure.mgmt.resource.resources.v2020_06_01.models.ProviderListResult] - :raises: ~azure.core.exceptions.HttpResponseError + ~azure.core.paging.ItemPaged[~azure.mgmt.resource.resources.v2020_06_01.models.Provider] + :raises ~azure.core.exceptions.HttpResponseError: """ - api_version = kwargs.pop('api_version', "2020-06-01") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2020-06-01")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[_models.ProviderListResult] - cls = kwargs.pop('cls', None) # type: ClsType["_models.ProviderListResult"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) + def prepare_request(next_link=None): if not next_link: - + request = build_providers_list_request( subscription_id=self._config.subscription_id, - api_version=api_version, top=top, expand=expand, - template_url=self.list.metadata['url'], + 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.url = self._client.format_url(request.url) # type: ignore else: - - request = build_providers_list_request( - subscription_id=self._config.subscription_id, - template_url=next_link, - ) + # make call to next link with the client's api-version + _parsed_next_link = urlparse(next_link) + _next_request_params = case_insensitive_dict(parse_qs(_parsed_next_link.query)) + _next_request_params["api-version"] = self._config.api_version + request = HttpRequest("GET", urljoin(next_link, _parsed_next_link.path), params=_next_request_params) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore request.method = "GET" return request @@ -7772,10 +8329,8 @@ def extract_data(pipeline_response): def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) response = pipeline_response.http_response @@ -7785,19 +8340,14 @@ def get_next(next_link=None): return pipeline_response + return ItemPaged(get_next, extract_data) - return ItemPaged( - get_next, extract_data - ) - list.metadata = {'url': "/subscriptions/{subscriptionId}/providers"} # type: ignore + list.metadata = {"url": "/subscriptions/{subscriptionId}/providers"} # type: ignore @distributed_trace def list_at_tenant_scope( - self, - top: Optional[int] = None, - expand: Optional[str] = None, - **kwargs: Any - ) -> Iterable["_models.ProviderListResult"]: + self, top: Optional[int] = None, expand: Optional[str] = None, **kwargs: Any + ) -> Iterable["_models.Provider"]: """Gets all resource providers for the tenant. :param top: The number of results to return. If null is passed returns all providers. Default @@ -7808,37 +8358,47 @@ def list_at_tenant_scope( response, use $expand=resourceTypes/aliases. Default value is None. :type expand: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either ProviderListResult or the result of cls(response) + :return: An iterator like instance of either Provider or the result of cls(response) :rtype: - ~azure.core.paging.ItemPaged[~azure.mgmt.resource.resources.v2020_06_01.models.ProviderListResult] - :raises: ~azure.core.exceptions.HttpResponseError + ~azure.core.paging.ItemPaged[~azure.mgmt.resource.resources.v2020_06_01.models.Provider] + :raises ~azure.core.exceptions.HttpResponseError: """ - api_version = kwargs.pop('api_version', "2020-06-01") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2020-06-01")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[_models.ProviderListResult] - cls = kwargs.pop('cls', None) # type: ClsType["_models.ProviderListResult"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) + def prepare_request(next_link=None): if not next_link: - + request = build_providers_list_at_tenant_scope_request( - api_version=api_version, top=top, expand=expand, - template_url=self.list_at_tenant_scope.metadata['url'], + api_version=api_version, + template_url=self.list_at_tenant_scope.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore else: - - request = build_providers_list_at_tenant_scope_request( - template_url=next_link, - ) + # make call to next link with the client's api-version + _parsed_next_link = urlparse(next_link) + _next_request_params = case_insensitive_dict(parse_qs(_parsed_next_link.query)) + _next_request_params["api-version"] = self._config.api_version + request = HttpRequest("GET", urljoin(next_link, _parsed_next_link.path), params=_next_request_params) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore request.method = "GET" return request @@ -7852,10 +8412,8 @@ def extract_data(pipeline_response): def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) response = pipeline_response.http_response @@ -7865,149 +8423,148 @@ def get_next(next_link=None): return pipeline_response + return ItemPaged(get_next, extract_data) - return ItemPaged( - get_next, extract_data - ) - list_at_tenant_scope.metadata = {'url': "/providers"} # type: ignore + list_at_tenant_scope.metadata = {"url": "/providers"} # type: ignore @distributed_trace - def get( - self, - resource_provider_namespace: str, - expand: Optional[str] = None, - **kwargs: Any - ) -> "_models.Provider": + def get(self, resource_provider_namespace: str, expand: Optional[str] = None, **kwargs: Any) -> _models.Provider: """Gets the specified resource provider. - :param resource_provider_namespace: The namespace of the resource provider. + :param resource_provider_namespace: The namespace of the resource provider. Required. :type resource_provider_namespace: str :param expand: The $expand query parameter. For example, to include property aliases in response, use $expand=resourceTypes/aliases. Default value is None. :type expand: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: Provider, or the result of cls(response) + :return: Provider or the result of cls(response) :rtype: ~azure.mgmt.resource.resources.v2020_06_01.models.Provider - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.Provider"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + 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', "2020-06-01") # type: str + api_version = kwargs.pop("api_version", _params.pop("api-version", "2020-06-01")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[_models.Provider] - request = build_providers_get_request( resource_provider_namespace=resource_provider_namespace, subscription_id=self._config.subscription_id, - api_version=api_version, expand=expand, - template_url=self.get.metadata['url'], + api_version=api_version, + template_url=self.get.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) - deserialized = self._deserialize('Provider', pipeline_response) + deserialized = self._deserialize("Provider", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - get.metadata = {'url': "/subscriptions/{subscriptionId}/providers/{resourceProviderNamespace}"} # type: ignore - + get.metadata = {"url": "/subscriptions/{subscriptionId}/providers/{resourceProviderNamespace}"} # type: ignore @distributed_trace def get_at_tenant_scope( - self, - resource_provider_namespace: str, - expand: Optional[str] = None, - **kwargs: Any - ) -> "_models.Provider": + self, resource_provider_namespace: str, expand: Optional[str] = None, **kwargs: Any + ) -> _models.Provider: """Gets the specified resource provider at the tenant level. - :param resource_provider_namespace: The namespace of the resource provider. + :param resource_provider_namespace: The namespace of the resource provider. Required. :type resource_provider_namespace: str :param expand: The $expand query parameter. For example, to include property aliases in response, use $expand=resourceTypes/aliases. Default value is None. :type expand: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: Provider, or the result of cls(response) + :return: Provider or the result of cls(response) :rtype: ~azure.mgmt.resource.resources.v2020_06_01.models.Provider - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.Provider"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) - api_version = kwargs.pop('api_version', "2020-06-01") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2020-06-01")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[_models.Provider] - request = build_providers_get_at_tenant_scope_request( resource_provider_namespace=resource_provider_namespace, - api_version=api_version, expand=expand, - template_url=self.get_at_tenant_scope.metadata['url'], + api_version=api_version, + template_url=self.get_at_tenant_scope.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) - deserialized = self._deserialize('Provider', pipeline_response) + deserialized = self._deserialize("Provider", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - get_at_tenant_scope.metadata = {'url': "/providers/{resourceProviderNamespace}"} # type: ignore + get_at_tenant_scope.metadata = {"url": "/providers/{resourceProviderNamespace}"} # type: ignore -class ResourcesOperations(object): # pylint: disable=too-many-public-methods - """ResourcesOperations operations. - You should not instantiate this class directly. Instead, you should create a Client instance that - instantiates it for you and attaches it as an attribute. +class ResourcesOperations: # pylint: disable=too-many-public-methods + """ + .. warning:: + **DO NOT** instantiate this class directly. - :ivar models: Alias to model classes used in this operation group. - :type models: ~azure.mgmt.resource.resources.v2020_06_01.models - :param client: Client for service requests. - :param config: Configuration of service client. - :param serializer: An object model serializer. - :param deserializer: An object model deserializer. + Instead, you should access the following operations through + :class:`~azure.mgmt.resource.resources.v2020_06_01.ResourceManagementClient`'s + :attr:`resources` attribute. """ models = _models - def __init__(self, client, config, serializer, deserializer): - self._client = client - self._serialize = serializer - self._deserialize = deserializer - self._config = config + def __init__(self, *args, **kwargs): + input_args = list(args) + self._client = input_args.pop(0) if input_args else kwargs.pop("client") + self._config = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") @distributed_trace def list_by_resource_group( @@ -8017,10 +8574,10 @@ def list_by_resource_group( expand: Optional[str] = None, top: Optional[int] = None, **kwargs: Any - ) -> Iterable["_models.ResourceListResult"]: + ) -> Iterable["_models.GenericResourceExpanded"]: """Get all the resources for a resource group. - :param resource_group_name: The resource group with the resources to get. + :param resource_group_name: The resource group with the resources to get. Required. :type resource_group_name: str :param filter: The filter to apply on the operation.:code:`
`:code:`
`The properties you can use for eq (equals) or ne (not equals) are: location, resourceType, name, resourceGroup, @@ -8046,42 +8603,51 @@ def list_by_resource_group( value is None. :type top: int :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either ResourceListResult or the result of cls(response) + :return: An iterator like instance of either GenericResourceExpanded or the result of + cls(response) :rtype: - ~azure.core.paging.ItemPaged[~azure.mgmt.resource.resources.v2020_06_01.models.ResourceListResult] - :raises: ~azure.core.exceptions.HttpResponseError + ~azure.core.paging.ItemPaged[~azure.mgmt.resource.resources.v2020_06_01.models.GenericResourceExpanded] + :raises ~azure.core.exceptions.HttpResponseError: """ - api_version = kwargs.pop('api_version', "2020-06-01") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2020-06-01")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[_models.ResourceListResult] - cls = kwargs.pop('cls', None) # type: ClsType["_models.ResourceListResult"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) + def prepare_request(next_link=None): if not next_link: - + request = build_resources_list_by_resource_group_request( resource_group_name=resource_group_name, subscription_id=self._config.subscription_id, - api_version=api_version, filter=filter, expand=expand, top=top, - template_url=self.list_by_resource_group.metadata['url'], + 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.url = self._client.format_url(request.url) # type: ignore else: - - request = build_resources_list_by_resource_group_request( - resource_group_name=resource_group_name, - subscription_id=self._config.subscription_id, - template_url=next_link, - ) + # make call to next link with the client's api-version + _parsed_next_link = urlparse(next_link) + _next_request_params = case_insensitive_dict(parse_qs(_parsed_next_link.query)) + _next_request_params["api-version"] = self._config.api_version + request = HttpRequest("GET", urljoin(next_link, _parsed_next_link.path), params=_next_request_params) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore request.method = "GET" return request @@ -8095,10 +8661,8 @@ def extract_data(pipeline_response): def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) response = pipeline_response.http_response @@ -8108,45 +8672,54 @@ def get_next(next_link=None): return pipeline_response + return ItemPaged(get_next, extract_data) - return ItemPaged( - get_next, extract_data - ) - list_by_resource_group.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/resources"} # type: ignore + list_by_resource_group.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/resources"} # type: ignore def _move_resources_initial( # pylint: disable=inconsistent-return-statements - self, - source_resource_group_name: str, - parameters: "_models.ResourcesMoveInfo", - **kwargs: Any + self, source_resource_group_name: str, parameters: Union[_models.ResourcesMoveInfo, IO], **kwargs: Any ) -> None: - cls = kwargs.pop('cls', None) # type: ClsType[None] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) - api_version = kwargs.pop('api_version', "2020-06-01") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - _json = self._serialize.body(parameters, 'ResourcesMoveInfo') + api_version = kwargs.pop("api_version", _params.pop("api-version", "2020-06-01")) # type: str + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[None] - request = build_resources_move_resources_request_initial( + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(parameters, (IO, bytes)): + _content = parameters + else: + _json = self._serialize.body(parameters, "ResourcesMoveInfo") + + request = build_resources_move_resources_request( source_resource_group_name=source_resource_group_name, subscription_id=self._config.subscription_id, api_version=api_version, content_type=content_type, json=_json, - template_url=self._move_resources_initial.metadata['url'], + content=_content, + template_url=self._move_resources_initial.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [202, 204]: @@ -8156,14 +8729,15 @@ def _move_resources_initial( # pylint: disable=inconsistent-return-statements if cls: return cls(pipeline_response, None, {}) - _move_resources_initial.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{sourceResourceGroupName}/moveResources"} # type: ignore + _move_resources_initial.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{sourceResourceGroupName}/moveResources"} # type: ignore - - @distributed_trace - def begin_move_resources( # pylint: disable=inconsistent-return-statements + @overload + def begin_move_resources( self, source_resource_group_name: str, - parameters: "_models.ResourcesMoveInfo", + parameters: _models.ResourcesMoveInfo, + *, + content_type: str = "application/json", **kwargs: Any ) -> LROPoller[None]: """Moves resources from one resource group to another resource group. @@ -8174,10 +8748,13 @@ def begin_move_resources( # pylint: disable=inconsistent-return-statements the groups until the move completes. :param source_resource_group_name: The name of the resource group containing the resources to - move. + move. Required. :type source_resource_group_name: str - :param parameters: Parameters for moving resources. + :param parameters: Parameters for moving resources. Required. :type parameters: ~azure.mgmt.resource.resources.v2020_06_01.models.ResourcesMoveInfo + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str :keyword callable cls: A custom type or function that will be passed the direct response :keyword str continuation_token: A continuation token to restart a poller from a saved state. :keyword polling: By default, your polling method will be ARMPolling. Pass in False for this @@ -8188,80 +8765,160 @@ def begin_move_resources( # pylint: disable=inconsistent-return-statements Retry-After header is present. :return: An instance of LROPoller that returns either None or the result of cls(response) :rtype: ~azure.core.polling.LROPoller[None] - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - api_version = kwargs.pop('api_version', "2020-06-01") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] - polling = kwargs.pop('polling', True) # type: Union[bool, PollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType[None] - lro_delay = kwargs.pop( - 'polling_interval', - self._config.polling_interval - ) - cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] + + @overload + def begin_move_resources( + self, source_resource_group_name: str, parameters: IO, *, content_type: str = "application/json", **kwargs: Any + ) -> LROPoller[None]: + """Moves resources from one resource group to another resource group. + + The resources to move must be in the same source resource group. The target resource group may + be in a different subscription. When moving resources, both the source group and the target + group are locked for the duration of the operation. Write and delete operations are blocked on + the groups until the move completes. + + :param source_resource_group_name: The name of the resource group containing the resources to + move. Required. + :type source_resource_group_name: str + :param parameters: Parameters for moving resources. Required. + :type parameters: IO + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be ARMPolling. Pass in False for this + operation to not poll, or pass in your own initialized polling object for a personal polling + strategy. + :paramtype polling: bool or ~azure.core.polling.PollingMethod + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of LROPoller that returns either None or the result of cls(response) + :rtype: ~azure.core.polling.LROPoller[None] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace + def begin_move_resources( + self, source_resource_group_name: str, parameters: Union[_models.ResourcesMoveInfo, IO], **kwargs: Any + ) -> LROPoller[None]: + """Moves resources from one resource group to another resource group. + + The resources to move must be in the same source resource group. The target resource group may + be in a different subscription. When moving resources, both the source group and the target + group are locked for the duration of the operation. Write and delete operations are blocked on + the groups until the move completes. + + :param source_resource_group_name: The name of the resource group containing the resources to + move. Required. + :type source_resource_group_name: str + :param parameters: Parameters for moving resources. Is either a model type or a IO type. + Required. + :type parameters: ~azure.mgmt.resource.resources.v2020_06_01.models.ResourcesMoveInfo or IO + :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. + Default value is None. + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be ARMPolling. Pass in False for this + operation to not poll, or pass in your own initialized polling object for a personal polling + strategy. + :paramtype polling: bool or ~azure.core.polling.PollingMethod + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of LROPoller that returns either None or the result of cls(response) + :rtype: ~azure.core.polling.LROPoller[None] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _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", "2020-06-01")) # type: str + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[None] + polling = kwargs.pop("polling", True) # type: Union[bool, PollingMethod] + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token = kwargs.pop("continuation_token", None) # type: Optional[str] if cont_token is None: - raw_result = self._move_resources_initial( + raw_result = self._move_resources_initial( # type: ignore source_resource_group_name=source_resource_group_name, parameters=parameters, api_version=api_version, content_type=content_type, - cls=lambda x,y,z: x, + cls=lambda x, y, z: x, + headers=_headers, + params=_params, **kwargs ) - kwargs.pop('error_map', None) + kwargs.pop("error_map", None) - def get_long_running_output(pipeline_response): + def get_long_running_output(pipeline_response): # pylint: disable=inconsistent-return-statements if cls: return cls(pipeline_response, None, {}) - - if polling is True: polling_method = ARMPolling(lro_delay, **kwargs) - elif polling is False: polling_method = NoPolling() - else: polling_method = polling + if polling is True: + polling_method = cast(PollingMethod, ARMPolling(lro_delay, **kwargs)) # type: PollingMethod + elif polling is False: + polling_method = cast(PollingMethod, NoPolling()) + else: + polling_method = polling if cont_token: return LROPoller.from_continuation_token( polling_method=polling_method, continuation_token=cont_token, client=self._client, - deserialization_callback=get_long_running_output + deserialization_callback=get_long_running_output, ) return LROPoller(self._client, raw_result, get_long_running_output, polling_method) - begin_move_resources.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{sourceResourceGroupName}/moveResources"} # type: ignore + begin_move_resources.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{sourceResourceGroupName}/moveResources"} # type: ignore def _validate_move_resources_initial( # pylint: disable=inconsistent-return-statements - self, - source_resource_group_name: str, - parameters: "_models.ResourcesMoveInfo", - **kwargs: Any + self, source_resource_group_name: str, parameters: Union[_models.ResourcesMoveInfo, IO], **kwargs: Any ) -> None: - cls = kwargs.pop('cls', None) # type: ClsType[None] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) - api_version = kwargs.pop('api_version', "2020-06-01") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - _json = self._serialize.body(parameters, 'ResourcesMoveInfo') + api_version = kwargs.pop("api_version", _params.pop("api-version", "2020-06-01")) # type: str + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[None] - request = build_resources_validate_move_resources_request_initial( + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(parameters, (IO, bytes)): + _content = parameters + else: + _json = self._serialize.body(parameters, "ResourcesMoveInfo") + + request = build_resources_validate_move_resources_request( source_resource_group_name=source_resource_group_name, subscription_id=self._config.subscription_id, api_version=api_version, content_type=content_type, json=_json, - template_url=self._validate_move_resources_initial.metadata['url'], + content=_content, + template_url=self._validate_move_resources_initial.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [202, 204]: @@ -8271,14 +8928,15 @@ def _validate_move_resources_initial( # pylint: disable=inconsistent-return-sta if cls: return cls(pipeline_response, None, {}) - _validate_move_resources_initial.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{sourceResourceGroupName}/validateMoveResources"} # type: ignore + _validate_move_resources_initial.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{sourceResourceGroupName}/validateMoveResources"} # type: ignore - - @distributed_trace - def begin_validate_move_resources( # pylint: disable=inconsistent-return-statements + @overload + def begin_validate_move_resources( self, source_resource_group_name: str, - parameters: "_models.ResourcesMoveInfo", + parameters: _models.ResourcesMoveInfo, + *, + content_type: str = "application/json", **kwargs: Any ) -> LROPoller[None]: """Validates whether resources can be moved from one resource group to another resource group. @@ -8291,10 +8949,13 @@ def begin_validate_move_resources( # pylint: disable=inconsistent-return-statem operation. :param source_resource_group_name: The name of the resource group containing the resources to - validate for move. + validate for move. Required. :type source_resource_group_name: str - :param parameters: Parameters for moving resources. + :param parameters: Parameters for moving resources. Required. :type parameters: ~azure.mgmt.resource.resources.v2020_06_01.models.ResourcesMoveInfo + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str :keyword callable cls: A custom type or function that will be passed the direct response :keyword str continuation_token: A continuation token to restart a poller from a saved state. :keyword polling: By default, your polling method will be ARMPolling. Pass in False for this @@ -8305,55 +8966,124 @@ def begin_validate_move_resources( # pylint: disable=inconsistent-return-statem Retry-After header is present. :return: An instance of LROPoller that returns either None or the result of cls(response) :rtype: ~azure.core.polling.LROPoller[None] - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - api_version = kwargs.pop('api_version', "2020-06-01") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] - polling = kwargs.pop('polling', True) # type: Union[bool, PollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType[None] - lro_delay = kwargs.pop( - 'polling_interval', - self._config.polling_interval - ) - cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] + + @overload + def begin_validate_move_resources( + self, source_resource_group_name: str, parameters: IO, *, content_type: str = "application/json", **kwargs: Any + ) -> LROPoller[None]: + """Validates whether resources can be moved from one resource group to another resource group. + + This operation checks whether the specified resources can be moved to the target. The resources + to move must be in the same source resource group. The target resource group may be in a + different subscription. If validation succeeds, it returns HTTP response code 204 (no content). + If validation fails, it returns HTTP response code 409 (Conflict) with an error message. + Retrieve the URL in the Location header value to check the result of the long-running + operation. + + :param source_resource_group_name: The name of the resource group containing the resources to + validate for move. Required. + :type source_resource_group_name: str + :param parameters: Parameters for moving resources. Required. + :type parameters: IO + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be ARMPolling. Pass in False for this + operation to not poll, or pass in your own initialized polling object for a personal polling + strategy. + :paramtype polling: bool or ~azure.core.polling.PollingMethod + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of LROPoller that returns either None or the result of cls(response) + :rtype: ~azure.core.polling.LROPoller[None] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace + def begin_validate_move_resources( + self, source_resource_group_name: str, parameters: Union[_models.ResourcesMoveInfo, IO], **kwargs: Any + ) -> LROPoller[None]: + """Validates whether resources can be moved from one resource group to another resource group. + + This operation checks whether the specified resources can be moved to the target. The resources + to move must be in the same source resource group. The target resource group may be in a + different subscription. If validation succeeds, it returns HTTP response code 204 (no content). + If validation fails, it returns HTTP response code 409 (Conflict) with an error message. + Retrieve the URL in the Location header value to check the result of the long-running + operation. + + :param source_resource_group_name: The name of the resource group containing the resources to + validate for move. Required. + :type source_resource_group_name: str + :param parameters: Parameters for moving resources. Is either a model type or a IO type. + Required. + :type parameters: ~azure.mgmt.resource.resources.v2020_06_01.models.ResourcesMoveInfo or IO + :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. + Default value is None. + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be ARMPolling. Pass in False for this + operation to not poll, or pass in your own initialized polling object for a personal polling + strategy. + :paramtype polling: bool or ~azure.core.polling.PollingMethod + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of LROPoller that returns either None or the result of cls(response) + :rtype: ~azure.core.polling.LROPoller[None] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _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", "2020-06-01")) # type: str + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[None] + polling = kwargs.pop("polling", True) # type: Union[bool, PollingMethod] + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token = kwargs.pop("continuation_token", None) # type: Optional[str] if cont_token is None: - raw_result = self._validate_move_resources_initial( + raw_result = self._validate_move_resources_initial( # type: ignore source_resource_group_name=source_resource_group_name, parameters=parameters, api_version=api_version, content_type=content_type, - cls=lambda x,y,z: x, + cls=lambda x, y, z: x, + headers=_headers, + params=_params, **kwargs ) - kwargs.pop('error_map', None) + kwargs.pop("error_map", None) - def get_long_running_output(pipeline_response): + def get_long_running_output(pipeline_response): # pylint: disable=inconsistent-return-statements if cls: return cls(pipeline_response, None, {}) - - if polling is True: polling_method = ARMPolling(lro_delay, **kwargs) - elif polling is False: polling_method = NoPolling() - else: polling_method = polling + if polling is True: + polling_method = cast(PollingMethod, ARMPolling(lro_delay, **kwargs)) # type: PollingMethod + elif polling is False: + polling_method = cast(PollingMethod, NoPolling()) + else: + polling_method = polling if cont_token: return LROPoller.from_continuation_token( polling_method=polling_method, continuation_token=cont_token, client=self._client, - deserialization_callback=get_long_running_output + deserialization_callback=get_long_running_output, ) return LROPoller(self._client, raw_result, get_long_running_output, polling_method) - begin_validate_move_resources.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{sourceResourceGroupName}/validateMoveResources"} # type: ignore + begin_validate_move_resources.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{sourceResourceGroupName}/validateMoveResources"} # type: ignore @distributed_trace def list( - self, - filter: Optional[str] = None, - expand: Optional[str] = None, - top: Optional[int] = None, - **kwargs: Any - ) -> Iterable["_models.ResourceListResult"]: + self, filter: Optional[str] = None, expand: Optional[str] = None, top: Optional[int] = None, **kwargs: Any + ) -> Iterable["_models.GenericResourceExpanded"]: """Get all the resources in a subscription. :param filter: The filter to apply on the operation.:code:`
`:code:`
`The properties you @@ -8380,40 +9110,50 @@ def list( value is None. :type top: int :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either ResourceListResult or the result of cls(response) + :return: An iterator like instance of either GenericResourceExpanded or the result of + cls(response) :rtype: - ~azure.core.paging.ItemPaged[~azure.mgmt.resource.resources.v2020_06_01.models.ResourceListResult] - :raises: ~azure.core.exceptions.HttpResponseError + ~azure.core.paging.ItemPaged[~azure.mgmt.resource.resources.v2020_06_01.models.GenericResourceExpanded] + :raises ~azure.core.exceptions.HttpResponseError: """ - api_version = kwargs.pop('api_version', "2020-06-01") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2020-06-01")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[_models.ResourceListResult] - cls = kwargs.pop('cls', None) # type: ClsType["_models.ResourceListResult"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) + def prepare_request(next_link=None): if not next_link: - + request = build_resources_list_request( subscription_id=self._config.subscription_id, - api_version=api_version, filter=filter, expand=expand, top=top, - template_url=self.list.metadata['url'], + 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.url = self._client.format_url(request.url) # type: ignore else: - - request = build_resources_list_request( - subscription_id=self._config.subscription_id, - template_url=next_link, - ) + # make call to next link with the client's api-version + _parsed_next_link = urlparse(next_link) + _next_request_params = case_insensitive_dict(parse_qs(_parsed_next_link.query)) + _next_request_params["api-version"] = self._config.api_version + request = HttpRequest("GET", urljoin(next_link, _parsed_next_link.path), params=_next_request_params) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore request.method = "GET" return request @@ -8427,10 +9167,8 @@ def extract_data(pipeline_response): def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) response = pipeline_response.http_response @@ -8440,11 +9178,9 @@ def get_next(next_link=None): return pipeline_response + return ItemPaged(get_next, extract_data) - return ItemPaged( - get_next, extract_data - ) - list.metadata = {'url': "/subscriptions/{subscriptionId}/resources"} # type: ignore + list.metadata = {"url": "/subscriptions/{subscriptionId}/resources"} # type: ignore @distributed_trace def check_existence( @@ -8460,30 +9196,36 @@ def check_existence( """Checks whether a resource exists. :param resource_group_name: The name of the resource group containing the resource to check. - The name is case insensitive. + The name is case insensitive. Required. :type resource_group_name: str - :param resource_provider_namespace: The resource provider of the resource to check. + :param resource_provider_namespace: The resource provider of the resource to check. Required. :type resource_provider_namespace: str - :param parent_resource_path: The parent resource identity. + :param parent_resource_path: The parent resource identity. Required. :type parent_resource_path: str - :param resource_type: The resource type. + :param resource_type: The resource type. Required. :type resource_type: str - :param resource_name: The name of the resource to check whether it exists. + :param resource_name: The name of the resource to check whether it exists. Required. :type resource_name: str - :param api_version: The API version to use for the operation. + :param api_version: The API version to use for the operation. Required. :type api_version: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: bool, or the result of cls(response) + :return: bool or the result of cls(response) :rtype: bool - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType[None] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = kwargs.pop("params", {}) or {} + + cls = kwargs.pop("cls", None) # type: ClsType[None] - request = build_resources_check_existence_request( resource_group_name=resource_group_name, resource_provider_namespace=resource_provider_namespace, @@ -8492,16 +9234,17 @@ def check_existence( resource_name=resource_name, subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.check_existence.metadata['url'], + template_url=self.check_existence.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [204, 404]: @@ -8512,8 +9255,7 @@ def check_existence( return cls(pipeline_response, None, {}) return 200 <= response.status_code <= 299 - check_existence.metadata = {'url': "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{parentResourcePath}/{resourceType}/{resourceName}"} # type: ignore - + check_existence.metadata = {"url": "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{parentResourcePath}/{resourceType}/{resourceName}"} # type: ignore def _delete_initial( # pylint: disable=inconsistent-return-statements self, @@ -8525,14 +9267,20 @@ def _delete_initial( # pylint: disable=inconsistent-return-statements api_version: str, **kwargs: Any ) -> None: - cls = kwargs.pop('cls', None) # type: ClsType[None] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = kwargs.pop("params", {}) or {} - - request = build_resources_delete_request_initial( + cls = kwargs.pop("cls", None) # type: ClsType[None] + + request = build_resources_delete_request( resource_group_name=resource_group_name, resource_provider_namespace=resource_provider_namespace, parent_resource_path=parent_resource_path, @@ -8540,16 +9288,17 @@ def _delete_initial( # pylint: disable=inconsistent-return-statements resource_name=resource_name, subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self._delete_initial.metadata['url'], + template_url=self._delete_initial.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200, 202, 204]: @@ -8559,11 +9308,10 @@ def _delete_initial( # pylint: disable=inconsistent-return-statements if cls: return cls(pipeline_response, None, {}) - _delete_initial.metadata = {'url': "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{parentResourcePath}/{resourceType}/{resourceName}"} # type: ignore - + _delete_initial.metadata = {"url": "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{parentResourcePath}/{resourceType}/{resourceName}"} # type: ignore @distributed_trace - def begin_delete( # pylint: disable=inconsistent-return-statements + def begin_delete( self, resource_group_name: str, resource_provider_namespace: str, @@ -8576,17 +9324,17 @@ def begin_delete( # pylint: disable=inconsistent-return-statements """Deletes a resource. :param resource_group_name: The name of the resource group that contains the resource to - delete. The name is case insensitive. + delete. The name is case insensitive. Required. :type resource_group_name: str - :param resource_provider_namespace: The namespace of the resource provider. + :param resource_provider_namespace: The namespace of the resource provider. Required. :type resource_provider_namespace: str - :param parent_resource_path: The parent resource identity. + :param parent_resource_path: The parent resource identity. Required. :type parent_resource_path: str - :param resource_type: The resource type. + :param resource_type: The resource type. Required. :type resource_type: str - :param resource_name: The name of the resource to delete. + :param resource_name: The name of the resource to delete. Required. :type resource_name: str - :param api_version: The API version to use for the operation. + :param api_version: The API version to use for the operation. Required. :type api_version: str :keyword callable cls: A custom type or function that will be passed the direct response :keyword str continuation_token: A continuation token to restart a poller from a saved state. @@ -8598,46 +9346,50 @@ def begin_delete( # pylint: disable=inconsistent-return-statements Retry-After header is present. :return: An instance of LROPoller that returns either None or the result of cls(response) :rtype: ~azure.core.polling.LROPoller[None] - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - polling = kwargs.pop('polling', True) # type: Union[bool, PollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType[None] - lro_delay = kwargs.pop( - 'polling_interval', - self._config.polling_interval - ) - cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] + _headers = kwargs.pop("headers", {}) or {} + _params = kwargs.pop("params", {}) or {} + + cls = kwargs.pop("cls", None) # type: ClsType[None] + polling = kwargs.pop("polling", True) # type: Union[bool, PollingMethod] + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token = kwargs.pop("continuation_token", None) # type: Optional[str] if cont_token is None: - raw_result = self._delete_initial( + raw_result = self._delete_initial( # type: ignore resource_group_name=resource_group_name, resource_provider_namespace=resource_provider_namespace, parent_resource_path=parent_resource_path, resource_type=resource_type, resource_name=resource_name, api_version=api_version, - cls=lambda x,y,z: x, + cls=lambda x, y, z: x, + headers=_headers, + params=_params, **kwargs ) - kwargs.pop('error_map', None) + kwargs.pop("error_map", None) - def get_long_running_output(pipeline_response): + def get_long_running_output(pipeline_response): # pylint: disable=inconsistent-return-statements if cls: return cls(pipeline_response, None, {}) - - if polling is True: polling_method = ARMPolling(lro_delay, **kwargs) - elif polling is False: polling_method = NoPolling() - else: polling_method = polling + if polling is True: + polling_method = cast(PollingMethod, ARMPolling(lro_delay, **kwargs)) # type: PollingMethod + elif polling is False: + polling_method = cast(PollingMethod, NoPolling()) + else: + polling_method = polling if cont_token: return LROPoller.from_continuation_token( polling_method=polling_method, continuation_token=cont_token, client=self._client, - deserialization_callback=get_long_running_output + deserialization_callback=get_long_running_output, ) return LROPoller(self._client, raw_result, get_long_running_output, polling_method) - begin_delete.metadata = {'url': "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{parentResourcePath}/{resourceType}/{resourceName}"} # type: ignore + begin_delete.metadata = {"url": "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{parentResourcePath}/{resourceType}/{resourceName}"} # type: ignore def _create_or_update_initial( self, @@ -8647,39 +9399,53 @@ def _create_or_update_initial( resource_type: str, resource_name: str, api_version: str, - parameters: "_models.GenericResource", + parameters: Union[_models.GenericResource, IO], **kwargs: Any - ) -> Optional["_models.GenericResource"]: - cls = kwargs.pop('cls', None) # type: ClsType[Optional["_models.GenericResource"]] + ) -> Optional[_models.GenericResource]: error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = kwargs.pop("params", {}) or {} - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[Optional[_models.GenericResource]] - _json = self._serialize.body(parameters, 'GenericResource') + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(parameters, (IO, bytes)): + _content = parameters + else: + _json = self._serialize.body(parameters, "GenericResource") - request = build_resources_create_or_update_request_initial( + request = build_resources_create_or_update_request( resource_group_name=resource_group_name, resource_provider_namespace=resource_provider_namespace, parent_resource_path=parent_resource_path, resource_type=resource_type, resource_name=resource_name, subscription_id=self._config.subscription_id, - content_type=content_type, api_version=api_version, + content_type=content_type, json=_json, - template_url=self._create_or_update_initial.metadata['url'], + content=_content, + template_url=self._create_or_update_initial.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200, 201, 202]: @@ -8688,20 +9454,19 @@ def _create_or_update_initial( deserialized = None if response.status_code == 200: - deserialized = self._deserialize('GenericResource', pipeline_response) + deserialized = self._deserialize("GenericResource", pipeline_response) if response.status_code == 201: - deserialized = self._deserialize('GenericResource', pipeline_response) + deserialized = self._deserialize("GenericResource", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - _create_or_update_initial.metadata = {'url': "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{parentResourcePath}/{resourceType}/{resourceName}"} # type: ignore - + _create_or_update_initial.metadata = {"url": "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{parentResourcePath}/{resourceType}/{resourceName}"} # type: ignore - @distributed_trace + @overload def begin_create_or_update( self, resource_group_name: str, @@ -8710,26 +9475,31 @@ def begin_create_or_update( resource_type: str, resource_name: str, api_version: str, - parameters: "_models.GenericResource", + parameters: _models.GenericResource, + *, + content_type: str = "application/json", **kwargs: Any - ) -> LROPoller["_models.GenericResource"]: + ) -> LROPoller[_models.GenericResource]: """Creates a resource. :param resource_group_name: The name of the resource group for the resource. The name is case - insensitive. + insensitive. Required. :type resource_group_name: str - :param resource_provider_namespace: The namespace of the resource provider. + :param resource_provider_namespace: The namespace of the resource provider. Required. :type resource_provider_namespace: str - :param parent_resource_path: The parent resource identity. + :param parent_resource_path: The parent resource identity. Required. :type parent_resource_path: str - :param resource_type: The resource type of the resource to create. + :param resource_type: The resource type of the resource to create. Required. :type resource_type: str - :param resource_name: The name of the resource to create. + :param resource_name: The name of the resource to create. Required. :type resource_name: str - :param api_version: The API version to use for the operation. + :param api_version: The API version to use for the operation. Required. :type api_version: str - :param parameters: Parameters for creating or updating the resource. + :param parameters: Parameters for creating or updating the resource. Required. :type parameters: ~azure.mgmt.resource.resources.v2020_06_01.models.GenericResource + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str :keyword callable cls: A custom type or function that will be passed the direct response :keyword str continuation_token: A continuation token to restart a poller from a saved state. :keyword polling: By default, your polling method will be ARMPolling. Pass in False for this @@ -8742,54 +9512,11 @@ def begin_create_or_update( cls(response) :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.resource.resources.v2020_06_01.models.GenericResource] - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] - polling = kwargs.pop('polling', True) # type: Union[bool, PollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType["_models.GenericResource"] - lro_delay = kwargs.pop( - 'polling_interval', - self._config.polling_interval - ) - cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] - if cont_token is None: - raw_result = self._create_or_update_initial( - resource_group_name=resource_group_name, - resource_provider_namespace=resource_provider_namespace, - parent_resource_path=parent_resource_path, - resource_type=resource_type, - resource_name=resource_name, - api_version=api_version, - parameters=parameters, - content_type=content_type, - cls=lambda x,y,z: x, - **kwargs - ) - kwargs.pop('error_map', None) - - def get_long_running_output(pipeline_response): - response = pipeline_response.http_response - deserialized = self._deserialize('GenericResource', pipeline_response) - if cls: - return cls(pipeline_response, deserialized, {}) - return deserialized - - - if polling is True: polling_method = ARMPolling(lro_delay, **kwargs) - elif polling is False: polling_method = NoPolling() - else: polling_method = polling - if cont_token: - return LROPoller.from_continuation_token( - polling_method=polling_method, - continuation_token=cont_token, - client=self._client, - deserialization_callback=get_long_running_output - ) - return LROPoller(self._client, raw_result, get_long_running_output, polling_method) - begin_create_or_update.metadata = {'url': "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{parentResourcePath}/{resourceType}/{resourceName}"} # type: ignore - - def _update_initial( + @overload + def begin_create_or_update( self, resource_group_name: str, resource_provider_namespace: str, @@ -8797,39 +9524,196 @@ def _update_initial( resource_type: str, resource_name: str, api_version: str, - parameters: "_models.GenericResource", + parameters: IO, + *, + content_type: str = "application/json", **kwargs: Any - ) -> Optional["_models.GenericResource"]: - cls = kwargs.pop('cls', None) # type: ClsType[Optional["_models.GenericResource"]] - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {})) - - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + ) -> LROPoller[_models.GenericResource]: + """Creates a resource. - _json = self._serialize.body(parameters, 'GenericResource') + :param resource_group_name: The name of the resource group for the resource. The name is case + insensitive. Required. + :type resource_group_name: str + :param resource_provider_namespace: The namespace of the resource provider. Required. + :type resource_provider_namespace: str + :param parent_resource_path: The parent resource identity. Required. + :type parent_resource_path: str + :param resource_type: The resource type of the resource to create. Required. + :type resource_type: str + :param resource_name: The name of the resource to create. Required. + :type resource_name: str + :param api_version: The API version to use for the operation. Required. + :type api_version: str + :param parameters: Parameters for creating or updating the resource. Required. + :type parameters: IO + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be ARMPolling. Pass in False for this + operation to not poll, or pass in your own initialized polling object for a personal polling + strategy. + :paramtype polling: bool or ~azure.core.polling.PollingMethod + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of LROPoller that returns either GenericResource or the result of + cls(response) + :rtype: + ~azure.core.polling.LROPoller[~azure.mgmt.resource.resources.v2020_06_01.models.GenericResource] + :raises ~azure.core.exceptions.HttpResponseError: + """ - request = build_resources_update_request_initial( - resource_group_name=resource_group_name, - resource_provider_namespace=resource_provider_namespace, - parent_resource_path=parent_resource_path, - resource_type=resource_type, - resource_name=resource_name, + @distributed_trace + def begin_create_or_update( + self, + resource_group_name: str, + resource_provider_namespace: str, + parent_resource_path: str, + resource_type: str, + resource_name: str, + api_version: str, + parameters: Union[_models.GenericResource, IO], + **kwargs: Any + ) -> LROPoller[_models.GenericResource]: + """Creates a resource. + + :param resource_group_name: The name of the resource group for the resource. The name is case + insensitive. Required. + :type resource_group_name: str + :param resource_provider_namespace: The namespace of the resource provider. Required. + :type resource_provider_namespace: str + :param parent_resource_path: The parent resource identity. Required. + :type parent_resource_path: str + :param resource_type: The resource type of the resource to create. Required. + :type resource_type: str + :param resource_name: The name of the resource to create. Required. + :type resource_name: str + :param api_version: The API version to use for the operation. Required. + :type api_version: str + :param parameters: Parameters for creating or updating the resource. Is either a model type or + a IO type. Required. + :type parameters: ~azure.mgmt.resource.resources.v2020_06_01.models.GenericResource or IO + :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. + Default value is None. + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be ARMPolling. Pass in False for this + operation to not poll, or pass in your own initialized polling object for a personal polling + strategy. + :paramtype polling: bool or ~azure.core.polling.PollingMethod + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of LROPoller that returns either GenericResource or the result of + cls(response) + :rtype: + ~azure.core.polling.LROPoller[~azure.mgmt.resource.resources.v2020_06_01.models.GenericResource] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = kwargs.pop("params", {}) or {} + + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.GenericResource] + polling = kwargs.pop("polling", True) # type: Union[bool, PollingMethod] + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token = kwargs.pop("continuation_token", None) # type: Optional[str] + if cont_token is None: + raw_result = self._create_or_update_initial( # type: ignore + resource_group_name=resource_group_name, + resource_provider_namespace=resource_provider_namespace, + parent_resource_path=parent_resource_path, + resource_type=resource_type, + resource_name=resource_name, + api_version=api_version, + parameters=parameters, + content_type=content_type, + cls=lambda x, y, z: x, + headers=_headers, + params=_params, + **kwargs + ) + kwargs.pop("error_map", None) + + def get_long_running_output(pipeline_response): + deserialized = self._deserialize("GenericResource", pipeline_response) + if cls: + return cls(pipeline_response, deserialized, {}) + return deserialized + + if polling is True: + polling_method = cast(PollingMethod, ARMPolling(lro_delay, **kwargs)) # type: PollingMethod + elif polling is False: + polling_method = cast(PollingMethod, NoPolling()) + else: + polling_method = polling + if cont_token: + return LROPoller.from_continuation_token( + polling_method=polling_method, + continuation_token=cont_token, + client=self._client, + deserialization_callback=get_long_running_output, + ) + return LROPoller(self._client, raw_result, get_long_running_output, polling_method) + + begin_create_or_update.metadata = {"url": "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{parentResourcePath}/{resourceType}/{resourceName}"} # type: ignore + + def _update_initial( + self, + resource_group_name: str, + resource_provider_namespace: str, + parent_resource_path: str, + resource_type: str, + resource_name: str, + api_version: str, + parameters: Union[_models.GenericResource, IO], + **kwargs: Any + ) -> Optional[_models.GenericResource]: + error_map = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = kwargs.pop("params", {}) or {} + + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[Optional[_models.GenericResource]] + + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(parameters, (IO, bytes)): + _content = parameters + else: + _json = self._serialize.body(parameters, "GenericResource") + + request = build_resources_update_request( + resource_group_name=resource_group_name, + resource_provider_namespace=resource_provider_namespace, + parent_resource_path=parent_resource_path, + resource_type=resource_type, + resource_name=resource_name, subscription_id=self._config.subscription_id, - content_type=content_type, api_version=api_version, + content_type=content_type, json=_json, - template_url=self._update_initial.metadata['url'], + content=_content, + template_url=self._update_initial.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200, 202]: @@ -8838,15 +9722,112 @@ def _update_initial( deserialized = None if response.status_code == 200: - deserialized = self._deserialize('GenericResource', pipeline_response) + deserialized = self._deserialize("GenericResource", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - _update_initial.metadata = {'url': "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{parentResourcePath}/{resourceType}/{resourceName}"} # type: ignore + _update_initial.metadata = {"url": "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{parentResourcePath}/{resourceType}/{resourceName}"} # type: ignore + @overload + def begin_update( + self, + resource_group_name: str, + resource_provider_namespace: str, + parent_resource_path: str, + resource_type: str, + resource_name: str, + api_version: str, + parameters: _models.GenericResource, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> LROPoller[_models.GenericResource]: + """Updates a resource. + + :param resource_group_name: The name of the resource group for the resource. The name is case + insensitive. Required. + :type resource_group_name: str + :param resource_provider_namespace: The namespace of the resource provider. Required. + :type resource_provider_namespace: str + :param parent_resource_path: The parent resource identity. Required. + :type parent_resource_path: str + :param resource_type: The resource type of the resource to update. Required. + :type resource_type: str + :param resource_name: The name of the resource to update. Required. + :type resource_name: str + :param api_version: The API version to use for the operation. Required. + :type api_version: str + :param parameters: Parameters for updating the resource. Required. + :type parameters: ~azure.mgmt.resource.resources.v2020_06_01.models.GenericResource + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be ARMPolling. Pass in False for this + operation to not poll, or pass in your own initialized polling object for a personal polling + strategy. + :paramtype polling: bool or ~azure.core.polling.PollingMethod + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of LROPoller that returns either GenericResource or the result of + cls(response) + :rtype: + ~azure.core.polling.LROPoller[~azure.mgmt.resource.resources.v2020_06_01.models.GenericResource] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + def begin_update( + self, + resource_group_name: str, + resource_provider_namespace: str, + parent_resource_path: str, + resource_type: str, + resource_name: str, + api_version: str, + parameters: IO, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> LROPoller[_models.GenericResource]: + """Updates a resource. + + :param resource_group_name: The name of the resource group for the resource. The name is case + insensitive. Required. + :type resource_group_name: str + :param resource_provider_namespace: The namespace of the resource provider. Required. + :type resource_provider_namespace: str + :param parent_resource_path: The parent resource identity. Required. + :type parent_resource_path: str + :param resource_type: The resource type of the resource to update. Required. + :type resource_type: str + :param resource_name: The name of the resource to update. Required. + :type resource_name: str + :param api_version: The API version to use for the operation. Required. + :type api_version: str + :param parameters: Parameters for updating the resource. Required. + :type parameters: IO + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be ARMPolling. Pass in False for this + operation to not poll, or pass in your own initialized polling object for a personal polling + strategy. + :paramtype polling: bool or ~azure.core.polling.PollingMethod + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of LROPoller that returns either GenericResource or the result of + cls(response) + :rtype: + ~azure.core.polling.LROPoller[~azure.mgmt.resource.resources.v2020_06_01.models.GenericResource] + :raises ~azure.core.exceptions.HttpResponseError: + """ @distributed_trace def begin_update( @@ -8857,26 +9838,30 @@ def begin_update( resource_type: str, resource_name: str, api_version: str, - parameters: "_models.GenericResource", + parameters: Union[_models.GenericResource, IO], **kwargs: Any - ) -> LROPoller["_models.GenericResource"]: + ) -> LROPoller[_models.GenericResource]: """Updates a resource. :param resource_group_name: The name of the resource group for the resource. The name is case - insensitive. + insensitive. Required. :type resource_group_name: str - :param resource_provider_namespace: The namespace of the resource provider. + :param resource_provider_namespace: The namespace of the resource provider. Required. :type resource_provider_namespace: str - :param parent_resource_path: The parent resource identity. + :param parent_resource_path: The parent resource identity. Required. :type parent_resource_path: str - :param resource_type: The resource type of the resource to update. + :param resource_type: The resource type of the resource to update. Required. :type resource_type: str - :param resource_name: The name of the resource to update. + :param resource_name: The name of the resource to update. Required. :type resource_name: str - :param api_version: The API version to use for the operation. + :param api_version: The API version to use for the operation. Required. :type api_version: str - :param parameters: Parameters for updating the resource. - :type parameters: ~azure.mgmt.resource.resources.v2020_06_01.models.GenericResource + :param parameters: Parameters for updating the resource. Is either a model type or a IO type. + Required. + :type parameters: ~azure.mgmt.resource.resources.v2020_06_01.models.GenericResource or IO + :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. + Default value is None. + :paramtype content_type: str :keyword callable cls: A custom type or function that will be passed the direct response :keyword str continuation_token: A continuation token to restart a poller from a saved state. :keyword polling: By default, your polling method will be ARMPolling. Pass in False for this @@ -8889,18 +9874,18 @@ def begin_update( cls(response) :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.resource.resources.v2020_06_01.models.GenericResource] - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] - polling = kwargs.pop('polling', True) # type: Union[bool, PollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType["_models.GenericResource"] - lro_delay = kwargs.pop( - 'polling_interval', - self._config.polling_interval - ) - cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = kwargs.pop("params", {}) or {} + + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.GenericResource] + polling = kwargs.pop("polling", True) # type: Union[bool, PollingMethod] + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token = kwargs.pop("continuation_token", None) # type: Optional[str] if cont_token is None: - raw_result = self._update_initial( + raw_result = self._update_initial( # type: ignore resource_group_name=resource_group_name, resource_provider_namespace=resource_provider_namespace, parent_resource_path=parent_resource_path, @@ -8909,32 +9894,35 @@ def begin_update( api_version=api_version, parameters=parameters, content_type=content_type, - cls=lambda x,y,z: x, + cls=lambda x, y, z: x, + headers=_headers, + params=_params, **kwargs ) - kwargs.pop('error_map', None) + kwargs.pop("error_map", None) def get_long_running_output(pipeline_response): - response = pipeline_response.http_response - deserialized = self._deserialize('GenericResource', pipeline_response) + deserialized = self._deserialize("GenericResource", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - - if polling is True: polling_method = ARMPolling(lro_delay, **kwargs) - elif polling is False: polling_method = NoPolling() - else: polling_method = polling + if polling is True: + polling_method = cast(PollingMethod, ARMPolling(lro_delay, **kwargs)) # type: PollingMethod + elif polling is False: + polling_method = cast(PollingMethod, NoPolling()) + else: + polling_method = polling if cont_token: return LROPoller.from_continuation_token( polling_method=polling_method, continuation_token=cont_token, client=self._client, - deserialization_callback=get_long_running_output + deserialization_callback=get_long_running_output, ) return LROPoller(self._client, raw_result, get_long_running_output, polling_method) - begin_update.metadata = {'url': "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{parentResourcePath}/{resourceType}/{resourceName}"} # type: ignore + begin_update.metadata = {"url": "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{parentResourcePath}/{resourceType}/{resourceName}"} # type: ignore @distributed_trace def get( @@ -8946,34 +9934,40 @@ def get( resource_name: str, api_version: str, **kwargs: Any - ) -> "_models.GenericResource": + ) -> _models.GenericResource: """Gets a resource. :param resource_group_name: The name of the resource group containing the resource to get. The - name is case insensitive. + name is case insensitive. Required. :type resource_group_name: str - :param resource_provider_namespace: The namespace of the resource provider. + :param resource_provider_namespace: The namespace of the resource provider. Required. :type resource_provider_namespace: str - :param parent_resource_path: The parent resource identity. + :param parent_resource_path: The parent resource identity. Required. :type parent_resource_path: str - :param resource_type: The resource type of the resource. + :param resource_type: The resource type of the resource. Required. :type resource_type: str - :param resource_name: The name of the resource to get. + :param resource_name: The name of the resource to get. Required. :type resource_name: str - :param api_version: The API version to use for the operation. + :param api_version: The API version to use for the operation. Required. :type api_version: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: GenericResource, or the result of cls(response) + :return: GenericResource or the result of cls(response) :rtype: ~azure.mgmt.resource.resources.v2020_06_01.models.GenericResource - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.GenericResource"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = kwargs.pop("params", {}) or {} + + cls = kwargs.pop("cls", None) # type: ClsType[_models.GenericResource] - request = build_resources_get_request( resource_group_name=resource_group_name, resource_provider_namespace=resource_provider_namespace, @@ -8982,72 +9976,75 @@ def get( resource_name=resource_name, subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.get.metadata['url'], + template_url=self.get.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) - deserialized = self._deserialize('GenericResource', pipeline_response) + deserialized = self._deserialize("GenericResource", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - get.metadata = {'url': "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{parentResourcePath}/{resourceType}/{resourceName}"} # type: ignore - + get.metadata = {"url": "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{parentResourcePath}/{resourceType}/{resourceName}"} # type: ignore @distributed_trace - def check_existence_by_id( - self, - resource_id: str, - api_version: str, - **kwargs: Any - ) -> bool: + def check_existence_by_id(self, resource_id: str, api_version: str, **kwargs: Any) -> bool: """Checks by ID whether a resource exists. :param resource_id: The fully qualified ID of the resource, including the resource name and resource type. Use the format, /subscriptions/{guid}/resourceGroups/{resource-group-name}/{resource-provider-namespace}/{resource-type}/{resource-name}. + Required. :type resource_id: str - :param api_version: The API version to use for the operation. + :param api_version: The API version to use for the operation. Required. :type api_version: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: bool, or the result of cls(response) + :return: bool or the result of cls(response) :rtype: bool - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType[None] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = kwargs.pop("params", {}) or {} + + cls = kwargs.pop("cls", None) # type: ClsType[None] - request = build_resources_check_existence_by_id_request( resource_id=resource_id, api_version=api_version, - template_url=self.check_existence_by_id.metadata['url'], + template_url=self.check_existence_by_id.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [204, 404]: @@ -9058,35 +10055,38 @@ def check_existence_by_id( return cls(pipeline_response, None, {}) return 200 <= response.status_code <= 299 - check_existence_by_id.metadata = {'url': "/{resourceId}"} # type: ignore - + check_existence_by_id.metadata = {"url": "/{resourceId}"} # type: ignore def _delete_by_id_initial( # pylint: disable=inconsistent-return-statements - self, - resource_id: str, - api_version: str, - **kwargs: Any + self, resource_id: str, api_version: str, **kwargs: Any ) -> None: - cls = kwargs.pop('cls', None) # type: ClsType[None] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = kwargs.pop("params", {}) or {} - - request = build_resources_delete_by_id_request_initial( + cls = kwargs.pop("cls", None) # type: ClsType[None] + + request = build_resources_delete_by_id_request( resource_id=resource_id, api_version=api_version, - template_url=self._delete_by_id_initial.metadata['url'], + template_url=self._delete_by_id_initial.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200, 202, 204]: @@ -9096,23 +10096,18 @@ def _delete_by_id_initial( # pylint: disable=inconsistent-return-statements if cls: return cls(pipeline_response, None, {}) - _delete_by_id_initial.metadata = {'url': "/{resourceId}"} # type: ignore - + _delete_by_id_initial.metadata = {"url": "/{resourceId}"} # type: ignore @distributed_trace - def begin_delete_by_id( # pylint: disable=inconsistent-return-statements - self, - resource_id: str, - api_version: str, - **kwargs: Any - ) -> LROPoller[None]: + def begin_delete_by_id(self, resource_id: str, api_version: str, **kwargs: Any) -> LROPoller[None]: """Deletes a resource by ID. :param resource_id: The fully qualified ID of the resource, including the resource name and resource type. Use the format, /subscriptions/{guid}/resourceGroups/{resource-group-name}/{resource-provider-namespace}/{resource-type}/{resource-name}. + Required. :type resource_id: str - :param api_version: The API version to use for the operation. + :param api_version: The API version to use for the operation. Required. :type api_version: str :keyword callable cls: A custom type or function that will be passed the direct response :keyword str continuation_token: A continuation token to restart a poller from a saved state. @@ -9124,75 +10119,89 @@ def begin_delete_by_id( # pylint: disable=inconsistent-return-statements Retry-After header is present. :return: An instance of LROPoller that returns either None or the result of cls(response) :rtype: ~azure.core.polling.LROPoller[None] - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - polling = kwargs.pop('polling', True) # type: Union[bool, PollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType[None] - lro_delay = kwargs.pop( - 'polling_interval', - self._config.polling_interval - ) - cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] + _headers = kwargs.pop("headers", {}) or {} + _params = kwargs.pop("params", {}) or {} + + cls = kwargs.pop("cls", None) # type: ClsType[None] + polling = kwargs.pop("polling", True) # type: Union[bool, PollingMethod] + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token = kwargs.pop("continuation_token", None) # type: Optional[str] if cont_token is None: - raw_result = self._delete_by_id_initial( + raw_result = self._delete_by_id_initial( # type: ignore resource_id=resource_id, api_version=api_version, - cls=lambda x,y,z: x, + cls=lambda x, y, z: x, + headers=_headers, + params=_params, **kwargs ) - kwargs.pop('error_map', None) + kwargs.pop("error_map", None) - def get_long_running_output(pipeline_response): + def get_long_running_output(pipeline_response): # pylint: disable=inconsistent-return-statements if cls: return cls(pipeline_response, None, {}) - - if polling is True: polling_method = ARMPolling(lro_delay, **kwargs) - elif polling is False: polling_method = NoPolling() - else: polling_method = polling + if polling is True: + polling_method = cast(PollingMethod, ARMPolling(lro_delay, **kwargs)) # type: PollingMethod + elif polling is False: + polling_method = cast(PollingMethod, NoPolling()) + else: + polling_method = polling if cont_token: return LROPoller.from_continuation_token( polling_method=polling_method, continuation_token=cont_token, client=self._client, - deserialization_callback=get_long_running_output + deserialization_callback=get_long_running_output, ) return LROPoller(self._client, raw_result, get_long_running_output, polling_method) - begin_delete_by_id.metadata = {'url': "/{resourceId}"} # type: ignore + begin_delete_by_id.metadata = {"url": "/{resourceId}"} # type: ignore def _create_or_update_by_id_initial( - self, - resource_id: str, - api_version: str, - parameters: "_models.GenericResource", - **kwargs: Any - ) -> Optional["_models.GenericResource"]: - cls = kwargs.pop('cls', None) # type: ClsType[Optional["_models.GenericResource"]] + self, resource_id: str, api_version: str, parameters: Union[_models.GenericResource, IO], **kwargs: Any + ) -> Optional[_models.GenericResource]: error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = kwargs.pop("params", {}) or {} - _json = self._serialize.body(parameters, 'GenericResource') + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[Optional[_models.GenericResource]] - request = build_resources_create_or_update_by_id_request_initial( + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(parameters, (IO, bytes)): + _content = parameters + else: + _json = self._serialize.body(parameters, "GenericResource") + + request = build_resources_create_or_update_by_id_request( resource_id=resource_id, - content_type=content_type, api_version=api_version, + content_type=content_type, json=_json, - template_url=self._create_or_update_by_id_initial.metadata['url'], + content=_content, + template_url=self._create_or_update_by_id_initial.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200, 201, 202]: @@ -9201,37 +10210,42 @@ def _create_or_update_by_id_initial( deserialized = None if response.status_code == 200: - deserialized = self._deserialize('GenericResource', pipeline_response) + deserialized = self._deserialize("GenericResource", pipeline_response) if response.status_code == 201: - deserialized = self._deserialize('GenericResource', pipeline_response) + deserialized = self._deserialize("GenericResource", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - _create_or_update_by_id_initial.metadata = {'url': "/{resourceId}"} # type: ignore - + _create_or_update_by_id_initial.metadata = {"url": "/{resourceId}"} # type: ignore - @distributed_trace + @overload def begin_create_or_update_by_id( self, resource_id: str, api_version: str, - parameters: "_models.GenericResource", + parameters: _models.GenericResource, + *, + content_type: str = "application/json", **kwargs: Any - ) -> LROPoller["_models.GenericResource"]: + ) -> LROPoller[_models.GenericResource]: """Create a resource by ID. :param resource_id: The fully qualified ID of the resource, including the resource name and resource type. Use the format, /subscriptions/{guid}/resourceGroups/{resource-group-name}/{resource-provider-namespace}/{resource-type}/{resource-name}. + Required. :type resource_id: str - :param api_version: The API version to use for the operation. + :param api_version: The API version to use for the operation. Required. :type api_version: str - :param parameters: Create or update resource parameters. + :param parameters: Create or update resource parameters. Required. :type parameters: ~azure.mgmt.resource.resources.v2020_06_01.models.GenericResource + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str :keyword callable cls: A custom type or function that will be passed the direct response :keyword str continuation_token: A continuation token to restart a poller from a saved state. :keyword polling: By default, your polling method will be ARMPolling. Pass in False for this @@ -9244,81 +10258,167 @@ def begin_create_or_update_by_id( cls(response) :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.resource.resources.v2020_06_01.models.GenericResource] - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] - polling = kwargs.pop('polling', True) # type: Union[bool, PollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType["_models.GenericResource"] - lro_delay = kwargs.pop( - 'polling_interval', - self._config.polling_interval - ) - cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] + + @overload + def begin_create_or_update_by_id( + self, + resource_id: str, + api_version: str, + parameters: IO, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> LROPoller[_models.GenericResource]: + """Create a resource by ID. + + :param resource_id: The fully qualified ID of the resource, including the resource name and + resource type. Use the format, + /subscriptions/{guid}/resourceGroups/{resource-group-name}/{resource-provider-namespace}/{resource-type}/{resource-name}. + Required. + :type resource_id: str + :param api_version: The API version to use for the operation. Required. + :type api_version: str + :param parameters: Create or update resource parameters. Required. + :type parameters: IO + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be ARMPolling. Pass in False for this + operation to not poll, or pass in your own initialized polling object for a personal polling + strategy. + :paramtype polling: bool or ~azure.core.polling.PollingMethod + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of LROPoller that returns either GenericResource or the result of + cls(response) + :rtype: + ~azure.core.polling.LROPoller[~azure.mgmt.resource.resources.v2020_06_01.models.GenericResource] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace + def begin_create_or_update_by_id( + self, resource_id: str, api_version: str, parameters: Union[_models.GenericResource, IO], **kwargs: Any + ) -> LROPoller[_models.GenericResource]: + """Create a resource by ID. + + :param resource_id: The fully qualified ID of the resource, including the resource name and + resource type. Use the format, + /subscriptions/{guid}/resourceGroups/{resource-group-name}/{resource-provider-namespace}/{resource-type}/{resource-name}. + Required. + :type resource_id: str + :param api_version: The API version to use for the operation. Required. + :type api_version: str + :param parameters: Create or update resource parameters. Is either a model type or a IO type. + Required. + :type parameters: ~azure.mgmt.resource.resources.v2020_06_01.models.GenericResource or IO + :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. + Default value is None. + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be ARMPolling. Pass in False for this + operation to not poll, or pass in your own initialized polling object for a personal polling + strategy. + :paramtype polling: bool or ~azure.core.polling.PollingMethod + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of LROPoller that returns either GenericResource or the result of + cls(response) + :rtype: + ~azure.core.polling.LROPoller[~azure.mgmt.resource.resources.v2020_06_01.models.GenericResource] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = kwargs.pop("params", {}) or {} + + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.GenericResource] + polling = kwargs.pop("polling", True) # type: Union[bool, PollingMethod] + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token = kwargs.pop("continuation_token", None) # type: Optional[str] if cont_token is None: - raw_result = self._create_or_update_by_id_initial( + raw_result = self._create_or_update_by_id_initial( # type: ignore resource_id=resource_id, api_version=api_version, parameters=parameters, content_type=content_type, - cls=lambda x,y,z: x, + cls=lambda x, y, z: x, + headers=_headers, + params=_params, **kwargs ) - kwargs.pop('error_map', None) + kwargs.pop("error_map", None) def get_long_running_output(pipeline_response): - response = pipeline_response.http_response - deserialized = self._deserialize('GenericResource', pipeline_response) + deserialized = self._deserialize("GenericResource", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - - if polling is True: polling_method = ARMPolling(lro_delay, **kwargs) - elif polling is False: polling_method = NoPolling() - else: polling_method = polling + if polling is True: + polling_method = cast(PollingMethod, ARMPolling(lro_delay, **kwargs)) # type: PollingMethod + elif polling is False: + polling_method = cast(PollingMethod, NoPolling()) + else: + polling_method = polling if cont_token: return LROPoller.from_continuation_token( polling_method=polling_method, continuation_token=cont_token, client=self._client, - deserialization_callback=get_long_running_output + deserialization_callback=get_long_running_output, ) return LROPoller(self._client, raw_result, get_long_running_output, polling_method) - begin_create_or_update_by_id.metadata = {'url': "/{resourceId}"} # type: ignore + begin_create_or_update_by_id.metadata = {"url": "/{resourceId}"} # type: ignore def _update_by_id_initial( - self, - resource_id: str, - api_version: str, - parameters: "_models.GenericResource", - **kwargs: Any - ) -> Optional["_models.GenericResource"]: - cls = kwargs.pop('cls', None) # type: ClsType[Optional["_models.GenericResource"]] + self, resource_id: str, api_version: str, parameters: Union[_models.GenericResource, IO], **kwargs: Any + ) -> Optional[_models.GenericResource]: error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = kwargs.pop("params", {}) or {} - _json = self._serialize.body(parameters, 'GenericResource') + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[Optional[_models.GenericResource]] - request = build_resources_update_by_id_request_initial( + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(parameters, (IO, bytes)): + _content = parameters + else: + _json = self._serialize.body(parameters, "GenericResource") + + request = build_resources_update_by_id_request( resource_id=resource_id, - content_type=content_type, api_version=api_version, + content_type=content_type, json=_json, - template_url=self._update_by_id_initial.metadata['url'], + content=_content, + template_url=self._update_by_id_initial.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200, 202]: @@ -9327,34 +10427,39 @@ def _update_by_id_initial( deserialized = None if response.status_code == 200: - deserialized = self._deserialize('GenericResource', pipeline_response) + deserialized = self._deserialize("GenericResource", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - _update_by_id_initial.metadata = {'url': "/{resourceId}"} # type: ignore - + _update_by_id_initial.metadata = {"url": "/{resourceId}"} # type: ignore - @distributed_trace + @overload def begin_update_by_id( self, resource_id: str, api_version: str, - parameters: "_models.GenericResource", + parameters: _models.GenericResource, + *, + content_type: str = "application/json", **kwargs: Any - ) -> LROPoller["_models.GenericResource"]: + ) -> LROPoller[_models.GenericResource]: """Updates a resource by ID. :param resource_id: The fully qualified ID of the resource, including the resource name and resource type. Use the format, /subscriptions/{guid}/resourceGroups/{resource-group-name}/{resource-provider-namespace}/{resource-type}/{resource-name}. + Required. :type resource_id: str - :param api_version: The API version to use for the operation. + :param api_version: The API version to use for the operation. Required. :type api_version: str - :param parameters: Update resource parameters. + :param parameters: Update resource parameters. Required. :type parameters: ~azure.mgmt.resource.resources.v2020_06_01.models.GenericResource + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str :keyword callable cls: A custom type or function that will be passed the direct response :keyword str continuation_token: A continuation token to restart a poller from a saved state. :keyword polling: By default, your polling method will be ARMPolling. Pass in False for this @@ -9367,165 +10472,243 @@ def begin_update_by_id( cls(response) :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.resource.resources.v2020_06_01.models.GenericResource] - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] - polling = kwargs.pop('polling', True) # type: Union[bool, PollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType["_models.GenericResource"] - lro_delay = kwargs.pop( - 'polling_interval', - self._config.polling_interval - ) - cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] + + @overload + def begin_update_by_id( + self, + resource_id: str, + api_version: str, + parameters: IO, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> LROPoller[_models.GenericResource]: + """Updates a resource by ID. + + :param resource_id: The fully qualified ID of the resource, including the resource name and + resource type. Use the format, + /subscriptions/{guid}/resourceGroups/{resource-group-name}/{resource-provider-namespace}/{resource-type}/{resource-name}. + Required. + :type resource_id: str + :param api_version: The API version to use for the operation. Required. + :type api_version: str + :param parameters: Update resource parameters. Required. + :type parameters: IO + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be ARMPolling. Pass in False for this + operation to not poll, or pass in your own initialized polling object for a personal polling + strategy. + :paramtype polling: bool or ~azure.core.polling.PollingMethod + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of LROPoller that returns either GenericResource or the result of + cls(response) + :rtype: + ~azure.core.polling.LROPoller[~azure.mgmt.resource.resources.v2020_06_01.models.GenericResource] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace + def begin_update_by_id( + self, resource_id: str, api_version: str, parameters: Union[_models.GenericResource, IO], **kwargs: Any + ) -> LROPoller[_models.GenericResource]: + """Updates a resource by ID. + + :param resource_id: The fully qualified ID of the resource, including the resource name and + resource type. Use the format, + /subscriptions/{guid}/resourceGroups/{resource-group-name}/{resource-provider-namespace}/{resource-type}/{resource-name}. + Required. + :type resource_id: str + :param api_version: The API version to use for the operation. Required. + :type api_version: str + :param parameters: Update resource parameters. Is either a model type or a IO type. Required. + :type parameters: ~azure.mgmt.resource.resources.v2020_06_01.models.GenericResource or IO + :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. + Default value is None. + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be ARMPolling. Pass in False for this + operation to not poll, or pass in your own initialized polling object for a personal polling + strategy. + :paramtype polling: bool or ~azure.core.polling.PollingMethod + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of LROPoller that returns either GenericResource or the result of + cls(response) + :rtype: + ~azure.core.polling.LROPoller[~azure.mgmt.resource.resources.v2020_06_01.models.GenericResource] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = kwargs.pop("params", {}) or {} + + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.GenericResource] + polling = kwargs.pop("polling", True) # type: Union[bool, PollingMethod] + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token = kwargs.pop("continuation_token", None) # type: Optional[str] if cont_token is None: - raw_result = self._update_by_id_initial( + raw_result = self._update_by_id_initial( # type: ignore resource_id=resource_id, api_version=api_version, parameters=parameters, content_type=content_type, - cls=lambda x,y,z: x, + cls=lambda x, y, z: x, + headers=_headers, + params=_params, **kwargs ) - kwargs.pop('error_map', None) + kwargs.pop("error_map", None) def get_long_running_output(pipeline_response): - response = pipeline_response.http_response - deserialized = self._deserialize('GenericResource', pipeline_response) + deserialized = self._deserialize("GenericResource", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - - if polling is True: polling_method = ARMPolling(lro_delay, **kwargs) - elif polling is False: polling_method = NoPolling() - else: polling_method = polling + if polling is True: + polling_method = cast(PollingMethod, ARMPolling(lro_delay, **kwargs)) # type: PollingMethod + elif polling is False: + polling_method = cast(PollingMethod, NoPolling()) + else: + polling_method = polling if cont_token: return LROPoller.from_continuation_token( polling_method=polling_method, continuation_token=cont_token, client=self._client, - deserialization_callback=get_long_running_output + deserialization_callback=get_long_running_output, ) return LROPoller(self._client, raw_result, get_long_running_output, polling_method) - begin_update_by_id.metadata = {'url': "/{resourceId}"} # type: ignore + begin_update_by_id.metadata = {"url": "/{resourceId}"} # type: ignore @distributed_trace - def get_by_id( - self, - resource_id: str, - api_version: str, - **kwargs: Any - ) -> "_models.GenericResource": + def get_by_id(self, resource_id: str, api_version: str, **kwargs: Any) -> _models.GenericResource: """Gets a resource by ID. :param resource_id: The fully qualified ID of the resource, including the resource name and resource type. Use the format, /subscriptions/{guid}/resourceGroups/{resource-group-name}/{resource-provider-namespace}/{resource-type}/{resource-name}. + Required. :type resource_id: str - :param api_version: The API version to use for the operation. + :param api_version: The API version to use for the operation. Required. :type api_version: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: GenericResource, or the result of cls(response) + :return: GenericResource or the result of cls(response) :rtype: ~azure.mgmt.resource.resources.v2020_06_01.models.GenericResource - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.GenericResource"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = kwargs.pop("params", {}) or {} + + cls = kwargs.pop("cls", None) # type: ClsType[_models.GenericResource] - request = build_resources_get_by_id_request( resource_id=resource_id, api_version=api_version, - template_url=self.get_by_id.metadata['url'], + template_url=self.get_by_id.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) - deserialized = self._deserialize('GenericResource', pipeline_response) + deserialized = self._deserialize("GenericResource", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - get_by_id.metadata = {'url': "/{resourceId}"} # type: ignore + get_by_id.metadata = {"url": "/{resourceId}"} # type: ignore -class ResourceGroupsOperations(object): - """ResourceGroupsOperations operations. - You should not instantiate this class directly. Instead, you should create a Client instance that - instantiates it for you and attaches it as an attribute. +class ResourceGroupsOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. - :ivar models: Alias to model classes used in this operation group. - :type models: ~azure.mgmt.resource.resources.v2020_06_01.models - :param client: Client for service requests. - :param config: Configuration of service client. - :param serializer: An object model serializer. - :param deserializer: An object model deserializer. + Instead, you should access the following operations through + :class:`~azure.mgmt.resource.resources.v2020_06_01.ResourceManagementClient`'s + :attr:`resource_groups` attribute. """ models = _models - def __init__(self, client, config, serializer, deserializer): - self._client = client - self._serialize = serializer - self._deserialize = deserializer - self._config = config + def __init__(self, *args, **kwargs): + input_args = list(args) + self._client = input_args.pop(0) if input_args else kwargs.pop("client") + self._config = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") @distributed_trace - def check_existence( - self, - resource_group_name: str, - **kwargs: Any - ) -> bool: + def check_existence(self, resource_group_name: str, **kwargs: Any) -> bool: """Checks whether a resource group exists. :param resource_group_name: The name of the resource group to check. The name is case - insensitive. + insensitive. Required. :type resource_group_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: bool, or the result of cls(response) + :return: bool or the result of cls(response) :rtype: bool - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType[None] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) - api_version = kwargs.pop('api_version', "2020-06-01") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2020-06-01")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[None] - request = build_resource_groups_check_existence_request( resource_group_name=resource_group_name, subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.check_existence.metadata['url'], + template_url=self.check_existence.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [204, 404]: @@ -9536,39 +10719,98 @@ def check_existence( return cls(pipeline_response, None, {}) return 200 <= response.status_code <= 299 - check_existence.metadata = {'url': "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}"} # type: ignore - + check_existence.metadata = {"url": "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}"} # type: ignore - @distributed_trace + @overload def create_or_update( self, resource_group_name: str, - parameters: "_models.ResourceGroup", + parameters: _models.ResourceGroup, + *, + content_type: str = "application/json", **kwargs: Any - ) -> "_models.ResourceGroup": + ) -> _models.ResourceGroup: """Creates or updates a resource group. :param resource_group_name: The name of the resource group to create or update. Can include alphanumeric, underscore, parentheses, hyphen, period (except at end), and Unicode characters - that match the allowed characters. + that match the allowed characters. Required. :type resource_group_name: str - :param parameters: Parameters supplied to the create or update a resource group. + :param parameters: Parameters supplied to the create or update a resource group. Required. :type parameters: ~azure.mgmt.resource.resources.v2020_06_01.models.ResourceGroup + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: ResourceGroup or the result of cls(response) + :rtype: ~azure.mgmt.resource.resources.v2020_06_01.models.ResourceGroup + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + def create_or_update( + self, resource_group_name: str, parameters: IO, *, content_type: str = "application/json", **kwargs: Any + ) -> _models.ResourceGroup: + """Creates or updates a resource group. + + :param resource_group_name: The name of the resource group to create or update. Can include + alphanumeric, underscore, parentheses, hyphen, period (except at end), and Unicode characters + that match the allowed characters. Required. + :type resource_group_name: str + :param parameters: Parameters supplied to the create or update a resource group. Required. + :type parameters: IO + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: ResourceGroup or the result of cls(response) + :rtype: ~azure.mgmt.resource.resources.v2020_06_01.models.ResourceGroup + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace + def create_or_update( + self, resource_group_name: str, parameters: Union[_models.ResourceGroup, IO], **kwargs: Any + ) -> _models.ResourceGroup: + """Creates or updates a resource group. + + :param resource_group_name: The name of the resource group to create or update. Can include + alphanumeric, underscore, parentheses, hyphen, period (except at end), and Unicode characters + that match the allowed characters. Required. + :type resource_group_name: str + :param parameters: Parameters supplied to the create or update a resource group. Is either a + model type or a IO type. Required. + :type parameters: ~azure.mgmt.resource.resources.v2020_06_01.models.ResourceGroup or IO + :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. + Default value is None. + :paramtype content_type: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: ResourceGroup, or the result of cls(response) + :return: ResourceGroup or the result of cls(response) :rtype: ~azure.mgmt.resource.resources.v2020_06_01.models.ResourceGroup - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.ResourceGroup"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) - api_version = kwargs.pop('api_version', "2020-06-01") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - _json = self._serialize.body(parameters, 'ResourceGroup') + api_version = kwargs.pop("api_version", _params.pop("api-version", "2020-06-01")) # type: str + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.ResourceGroup] + + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(parameters, (IO, bytes)): + _content = parameters + else: + _json = self._serialize.body(parameters, "ResourceGroup") request = build_resource_groups_create_or_update_request( resource_group_name=resource_group_name, @@ -9576,16 +10818,18 @@ def create_or_update( api_version=api_version, content_type=content_type, json=_json, - template_url=self.create_or_update.metadata['url'], + content=_content, + template_url=self.create_or_update.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200, 201]: @@ -9593,49 +10837,51 @@ def create_or_update( raise HttpResponseError(response=response, error_format=ARMErrorFormat) if response.status_code == 200: - deserialized = self._deserialize('ResourceGroup', pipeline_response) + deserialized = self._deserialize("ResourceGroup", pipeline_response) if response.status_code == 201: - deserialized = self._deserialize('ResourceGroup', pipeline_response) + deserialized = self._deserialize("ResourceGroup", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - create_or_update.metadata = {'url': "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}"} # type: ignore - + create_or_update.metadata = {"url": "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}"} # type: ignore def _delete_initial( # pylint: disable=inconsistent-return-statements - self, - resource_group_name: str, - force_deletion_types: Optional[str] = None, - **kwargs: Any + self, resource_group_name: str, force_deletion_types: Optional[str] = None, **kwargs: Any ) -> None: - cls = kwargs.pop('cls', None) # type: ClsType[None] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + 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', "2020-06-01") # type: str + api_version = kwargs.pop("api_version", _params.pop("api-version", "2020-06-01")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[None] - - request = build_resource_groups_delete_request_initial( + request = build_resource_groups_delete_request( resource_group_name=resource_group_name, subscription_id=self._config.subscription_id, - api_version=api_version, force_deletion_types=force_deletion_types, - template_url=self._delete_initial.metadata['url'], + api_version=api_version, + template_url=self._delete_initial.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200, 202]: @@ -9645,15 +10891,11 @@ def _delete_initial( # pylint: disable=inconsistent-return-statements if cls: return cls(pipeline_response, None, {}) - _delete_initial.metadata = {'url': "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}"} # type: ignore - + _delete_initial.metadata = {"url": "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}"} # type: ignore @distributed_trace - def begin_delete( # pylint: disable=inconsistent-return-statements - self, - resource_group_name: str, - force_deletion_types: Optional[str] = None, - **kwargs: Any + def begin_delete( + self, resource_group_name: str, force_deletion_types: Optional[str] = None, **kwargs: Any ) -> LROPoller[None]: """Deletes a resource group. @@ -9661,7 +10903,7 @@ def begin_delete( # pylint: disable=inconsistent-return-statements group deletes all of its template deployments and currently stored operations. :param resource_group_name: The name of the resource group to delete. The name is case - insensitive. + insensitive. Required. :type resource_group_name: str :param force_deletion_types: The resource types you want to force delete. Currently, only the following is supported: @@ -9678,107 +10920,114 @@ def begin_delete( # pylint: disable=inconsistent-return-statements Retry-After header is present. :return: An instance of LROPoller that returns either None or the result of cls(response) :rtype: ~azure.core.polling.LROPoller[None] - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - api_version = kwargs.pop('api_version', "2020-06-01") # type: str - polling = kwargs.pop('polling', True) # type: Union[bool, PollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType[None] - lro_delay = kwargs.pop( - 'polling_interval', - self._config.polling_interval - ) - cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2020-06-01")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[None] + polling = kwargs.pop("polling", True) # type: Union[bool, PollingMethod] + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token = kwargs.pop("continuation_token", None) # type: Optional[str] if cont_token is None: - raw_result = self._delete_initial( + raw_result = self._delete_initial( # type: ignore resource_group_name=resource_group_name, force_deletion_types=force_deletion_types, api_version=api_version, - cls=lambda x,y,z: x, + cls=lambda x, y, z: x, + headers=_headers, + params=_params, **kwargs ) - kwargs.pop('error_map', None) + kwargs.pop("error_map", None) - def get_long_running_output(pipeline_response): + def get_long_running_output(pipeline_response): # pylint: disable=inconsistent-return-statements if cls: return cls(pipeline_response, None, {}) - - if polling is True: polling_method = ARMPolling(lro_delay, **kwargs) - elif polling is False: polling_method = NoPolling() - else: polling_method = polling + if polling is True: + polling_method = cast(PollingMethod, ARMPolling(lro_delay, **kwargs)) # type: PollingMethod + elif polling is False: + polling_method = cast(PollingMethod, NoPolling()) + else: + polling_method = polling if cont_token: return LROPoller.from_continuation_token( polling_method=polling_method, continuation_token=cont_token, client=self._client, - deserialization_callback=get_long_running_output + deserialization_callback=get_long_running_output, ) return LROPoller(self._client, raw_result, get_long_running_output, polling_method) - begin_delete.metadata = {'url': "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}"} # type: ignore + begin_delete.metadata = {"url": "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}"} # type: ignore @distributed_trace - def get( - self, - resource_group_name: str, - **kwargs: Any - ) -> "_models.ResourceGroup": + def get(self, resource_group_name: str, **kwargs: Any) -> _models.ResourceGroup: """Gets a resource group. :param resource_group_name: The name of the resource group to get. The name is case - insensitive. + insensitive. Required. :type resource_group_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: ResourceGroup, or the result of cls(response) + :return: ResourceGroup or the result of cls(response) :rtype: ~azure.mgmt.resource.resources.v2020_06_01.models.ResourceGroup - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.ResourceGroup"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) - api_version = kwargs.pop('api_version', "2020-06-01") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2020-06-01")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[_models.ResourceGroup] - request = build_resource_groups_get_request( resource_group_name=resource_group_name, subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.get.metadata['url'], + template_url=self.get.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) - deserialized = self._deserialize('ResourceGroup', pipeline_response) + deserialized = self._deserialize("ResourceGroup", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - get.metadata = {'url': "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}"} # type: ignore + get.metadata = {"url": "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}"} # type: ignore - - @distributed_trace + @overload def update( self, resource_group_name: str, - parameters: "_models.ResourceGroupPatchable", + parameters: _models.ResourceGroupPatchable, + *, + content_type: str = "application/json", **kwargs: Any - ) -> "_models.ResourceGroup": + ) -> _models.ResourceGroup: """Updates a resource group. Resource groups can be updated through a simple PATCH operation to a group address. The format @@ -9786,25 +11035,90 @@ def update( the current value is retained. :param resource_group_name: The name of the resource group to update. The name is case - insensitive. + insensitive. Required. :type resource_group_name: str - :param parameters: Parameters supplied to update a resource group. + :param parameters: Parameters supplied to update a resource group. Required. :type parameters: ~azure.mgmt.resource.resources.v2020_06_01.models.ResourceGroupPatchable + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: ResourceGroup or the result of cls(response) + :rtype: ~azure.mgmt.resource.resources.v2020_06_01.models.ResourceGroup + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + def update( + self, resource_group_name: str, parameters: IO, *, content_type: str = "application/json", **kwargs: Any + ) -> _models.ResourceGroup: + """Updates a resource group. + + Resource groups can be updated through a simple PATCH operation to a group address. The format + of the request is the same as that for creating a resource group. If a field is unspecified, + the current value is retained. + + :param resource_group_name: The name of the resource group to update. The name is case + insensitive. Required. + :type resource_group_name: str + :param parameters: Parameters supplied to update a resource group. Required. + :type parameters: IO + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: ResourceGroup or the result of cls(response) + :rtype: ~azure.mgmt.resource.resources.v2020_06_01.models.ResourceGroup + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace + def update( + self, resource_group_name: str, parameters: Union[_models.ResourceGroupPatchable, IO], **kwargs: Any + ) -> _models.ResourceGroup: + """Updates a resource group. + + Resource groups can be updated through a simple PATCH operation to a group address. The format + of the request is the same as that for creating a resource group. If a field is unspecified, + the current value is retained. + + :param resource_group_name: The name of the resource group to update. The name is case + insensitive. Required. + :type resource_group_name: str + :param parameters: Parameters supplied to update a resource group. Is either a model type or a + IO type. Required. + :type parameters: ~azure.mgmt.resource.resources.v2020_06_01.models.ResourceGroupPatchable or + IO + :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. + Default value is None. + :paramtype content_type: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: ResourceGroup, or the result of cls(response) + :return: ResourceGroup or the result of cls(response) :rtype: ~azure.mgmt.resource.resources.v2020_06_01.models.ResourceGroup - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.ResourceGroup"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', "2020-06-01") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + api_version = kwargs.pop("api_version", _params.pop("api-version", "2020-06-01")) # type: str + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.ResourceGroup] - _json = self._serialize.body(parameters, 'ResourceGroupPatchable') + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(parameters, (IO, bytes)): + _content = parameters + else: + _json = self._serialize.body(parameters, "ResourceGroupPatchable") request = build_resource_groups_update_request( resource_group_name=resource_group_name, @@ -9812,65 +11126,77 @@ def update( api_version=api_version, content_type=content_type, json=_json, - template_url=self.update.metadata['url'], + content=_content, + template_url=self.update.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) - deserialized = self._deserialize('ResourceGroup', pipeline_response) + deserialized = self._deserialize("ResourceGroup", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - update.metadata = {'url': "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}"} # type: ignore - + update.metadata = {"url": "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}"} # type: ignore def _export_template_initial( - self, - resource_group_name: str, - parameters: "_models.ExportTemplateRequest", - **kwargs: Any - ) -> Optional["_models.ResourceGroupExportResult"]: - cls = kwargs.pop('cls', None) # type: ClsType[Optional["_models.ResourceGroupExportResult"]] + self, resource_group_name: str, parameters: Union[_models.ExportTemplateRequest, IO], **kwargs: Any + ) -> Optional[_models.ResourceGroupExportResult]: error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) - api_version = kwargs.pop('api_version', "2020-06-01") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - _json = self._serialize.body(parameters, 'ExportTemplateRequest') + api_version = kwargs.pop("api_version", _params.pop("api-version", "2020-06-01")) # type: str + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[Optional[_models.ResourceGroupExportResult]] - request = build_resource_groups_export_template_request_initial( - subscription_id=self._config.subscription_id, + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(parameters, (IO, bytes)): + _content = parameters + else: + _json = self._serialize.body(parameters, "ExportTemplateRequest") + + request = build_resource_groups_export_template_request( resource_group_name=resource_group_name, + subscription_id=self._config.subscription_id, api_version=api_version, content_type=content_type, json=_json, - template_url=self._export_template_initial.metadata['url'], + content=_content, + template_url=self._export_template_initial.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200, 202]: @@ -9879,29 +11205,93 @@ def _export_template_initial( deserialized = None if response.status_code == 200: - deserialized = self._deserialize('ResourceGroupExportResult', pipeline_response) + deserialized = self._deserialize("ResourceGroupExportResult", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - _export_template_initial.metadata = {'url': "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/exportTemplate"} # type: ignore + _export_template_initial.metadata = {"url": "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/exportTemplate"} # type: ignore + + @overload + def begin_export_template( + self, + resource_group_name: str, + parameters: _models.ExportTemplateRequest, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> LROPoller[_models.ResourceGroupExportResult]: + """Captures the specified resource group as a template. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param parameters: Parameters for exporting the template. Required. + :type parameters: ~azure.mgmt.resource.resources.v2020_06_01.models.ExportTemplateRequest + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be ARMPolling. Pass in False for this + operation to not poll, or pass in your own initialized polling object for a personal polling + strategy. + :paramtype polling: bool or ~azure.core.polling.PollingMethod + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of LROPoller that returns either ResourceGroupExportResult or the result + of cls(response) + :rtype: + ~azure.core.polling.LROPoller[~azure.mgmt.resource.resources.v2020_06_01.models.ResourceGroupExportResult] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + def begin_export_template( + self, resource_group_name: str, parameters: IO, *, content_type: str = "application/json", **kwargs: Any + ) -> LROPoller[_models.ResourceGroupExportResult]: + """Captures the specified resource group as a template. + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param parameters: Parameters for exporting the template. Required. + :type parameters: IO + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be ARMPolling. Pass in False for this + operation to not poll, or pass in your own initialized polling object for a personal polling + strategy. + :paramtype polling: bool or ~azure.core.polling.PollingMethod + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of LROPoller that returns either ResourceGroupExportResult or the result + of cls(response) + :rtype: + ~azure.core.polling.LROPoller[~azure.mgmt.resource.resources.v2020_06_01.models.ResourceGroupExportResult] + :raises ~azure.core.exceptions.HttpResponseError: + """ @distributed_trace def begin_export_template( - self, - resource_group_name: str, - parameters: "_models.ExportTemplateRequest", - **kwargs: Any - ) -> LROPoller["_models.ResourceGroupExportResult"]: + self, resource_group_name: str, parameters: Union[_models.ExportTemplateRequest, IO], **kwargs: Any + ) -> LROPoller[_models.ResourceGroupExportResult]: """Captures the specified resource group as a template. :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. :type resource_group_name: str - :param parameters: Parameters for exporting the template. - :type parameters: ~azure.mgmt.resource.resources.v2020_06_01.models.ExportTemplateRequest + :param parameters: Parameters for exporting the template. Is either a model type or a IO type. + Required. + :type parameters: ~azure.mgmt.resource.resources.v2020_06_01.models.ExportTemplateRequest or IO + :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. + Default value is None. + :paramtype content_type: str :keyword callable cls: A custom type or function that will be passed the direct response :keyword str continuation_token: A continuation token to restart a poller from a saved state. :keyword polling: By default, your polling method will be ARMPolling. Pass in False for this @@ -9914,57 +11304,59 @@ def begin_export_template( of cls(response) :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.resource.resources.v2020_06_01.models.ResourceGroupExportResult] - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - api_version = kwargs.pop('api_version', "2020-06-01") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] - polling = kwargs.pop('polling', True) # type: Union[bool, PollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType["_models.ResourceGroupExportResult"] - lro_delay = kwargs.pop( - 'polling_interval', - self._config.polling_interval - ) - cont_token = kwargs.pop('continuation_token', None) # type: Optional[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", "2020-06-01")) # type: str + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.ResourceGroupExportResult] + polling = kwargs.pop("polling", True) # type: Union[bool, PollingMethod] + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token = kwargs.pop("continuation_token", None) # type: Optional[str] if cont_token is None: - raw_result = self._export_template_initial( + raw_result = self._export_template_initial( # type: ignore resource_group_name=resource_group_name, parameters=parameters, api_version=api_version, content_type=content_type, - cls=lambda x,y,z: x, + cls=lambda x, y, z: x, + headers=_headers, + params=_params, **kwargs ) - kwargs.pop('error_map', None) + kwargs.pop("error_map", None) def get_long_running_output(pipeline_response): - response = pipeline_response.http_response - deserialized = self._deserialize('ResourceGroupExportResult', pipeline_response) + deserialized = self._deserialize("ResourceGroupExportResult", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - - if polling is True: polling_method = ARMPolling(lro_delay, lro_options={'final-state-via': 'location'}, **kwargs) - elif polling is False: polling_method = NoPolling() - else: polling_method = polling + if polling is True: + polling_method = cast( + PollingMethod, ARMPolling(lro_delay, lro_options={"final-state-via": "location"}, **kwargs) + ) # type: PollingMethod + elif polling is False: + polling_method = cast(PollingMethod, NoPolling()) + else: + polling_method = polling if cont_token: return LROPoller.from_continuation_token( polling_method=polling_method, continuation_token=cont_token, client=self._client, - deserialization_callback=get_long_running_output + deserialization_callback=get_long_running_output, ) return LROPoller(self._client, raw_result, get_long_running_output, polling_method) - begin_export_template.metadata = {'url': "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/exportTemplate"} # type: ignore + begin_export_template.metadata = {"url": "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/exportTemplate"} # type: ignore @distributed_trace def list( - self, - filter: Optional[str] = None, - top: Optional[int] = None, - **kwargs: Any - ) -> Iterable["_models.ResourceGroupListResult"]: + self, filter: Optional[str] = None, top: Optional[int] = None, **kwargs: Any + ) -> Iterable["_models.ResourceGroup"]: """Gets all the resource groups for a subscription. :param filter: The filter to apply on the operation.:code:`
`:code:`
`You can filter by @@ -9975,40 +11367,48 @@ def list( Default value is None. :type top: int :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either ResourceGroupListResult or the result of - cls(response) + :return: An iterator like instance of either ResourceGroup or the result of cls(response) :rtype: - ~azure.core.paging.ItemPaged[~azure.mgmt.resource.resources.v2020_06_01.models.ResourceGroupListResult] - :raises: ~azure.core.exceptions.HttpResponseError + ~azure.core.paging.ItemPaged[~azure.mgmt.resource.resources.v2020_06_01.models.ResourceGroup] + :raises ~azure.core.exceptions.HttpResponseError: """ - api_version = kwargs.pop('api_version', "2020-06-01") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2020-06-01")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[_models.ResourceGroupListResult] - cls = kwargs.pop('cls', None) # type: ClsType["_models.ResourceGroupListResult"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) + def prepare_request(next_link=None): if not next_link: - + request = build_resource_groups_list_request( subscription_id=self._config.subscription_id, - api_version=api_version, filter=filter, top=top, - template_url=self.list.metadata['url'], + 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.url = self._client.format_url(request.url) # type: ignore else: - - request = build_resource_groups_list_request( - subscription_id=self._config.subscription_id, - template_url=next_link, - ) + # make call to next link with the client's api-version + _parsed_next_link = urlparse(next_link) + _next_request_params = case_insensitive_dict(parse_qs(_parsed_next_link.query)) + _next_request_params["api-version"] = self._config.api_version + request = HttpRequest("GET", urljoin(next_link, _parsed_next_link.path), params=_next_request_params) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore request.method = "GET" return request @@ -10022,10 +11422,8 @@ def extract_data(pipeline_response): def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) response = pipeline_response.http_response @@ -10035,39 +11433,33 @@ def get_next(next_link=None): return pipeline_response + return ItemPaged(get_next, extract_data) - return ItemPaged( - get_next, extract_data - ) - list.metadata = {'url': "/subscriptions/{subscriptionId}/resourcegroups"} # type: ignore -class TagsOperations(object): - """TagsOperations operations. + list.metadata = {"url": "/subscriptions/{subscriptionId}/resourcegroups"} # type: ignore - You should not instantiate this class directly. Instead, you should create a Client instance that - instantiates it for you and attaches it as an attribute. - :ivar models: Alias to model classes used in this operation group. - :type models: ~azure.mgmt.resource.resources.v2020_06_01.models - :param client: Client for service requests. - :param config: Configuration of service client. - :param serializer: An object model serializer. - :param deserializer: An object model deserializer. +class TagsOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. + + Instead, you should access the following operations through + :class:`~azure.mgmt.resource.resources.v2020_06_01.ResourceManagementClient`'s + :attr:`tags` attribute. """ models = _models - def __init__(self, client, config, serializer, deserializer): - self._client = client - self._serialize = serializer - self._deserialize = deserializer - self._config = config + def __init__(self, *args, **kwargs): + input_args = list(args) + self._client = input_args.pop(0) if input_args else kwargs.pop("client") + self._config = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") @distributed_trace def delete_value( # pylint: disable=inconsistent-return-statements - self, - tag_name: str, - tag_value: str, - **kwargs: Any + self, tag_name: str, tag_value: str, **kwargs: Any ) -> None: """Deletes a predefined tag value for a predefined tag name. @@ -10075,39 +11467,45 @@ def delete_value( # pylint: disable=inconsistent-return-statements predefined tag name. The value being deleted must not be in use as a tag value for the given tag name for any resource. - :param tag_name: The name of the tag. + :param tag_name: The name of the tag. Required. :type tag_name: str - :param tag_value: The value of the tag to delete. + :param tag_value: The value of the tag to delete. Required. :type tag_value: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: None, or the result of cls(response) + :return: None or the result of cls(response) :rtype: None - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType[None] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) - api_version = kwargs.pop('api_version', "2020-06-01") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2020-06-01")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[None] - request = build_tags_delete_value_request( tag_name=tag_name, tag_value=tag_value, subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.delete_value.metadata['url'], + template_url=self.delete_value.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200, 204]: @@ -10117,54 +11515,54 @@ def delete_value( # pylint: disable=inconsistent-return-statements if cls: return cls(pipeline_response, None, {}) - delete_value.metadata = {'url': "/subscriptions/{subscriptionId}/tagNames/{tagName}/tagValues/{tagValue}"} # type: ignore - + delete_value.metadata = {"url": "/subscriptions/{subscriptionId}/tagNames/{tagName}/tagValues/{tagValue}"} # type: ignore @distributed_trace - def create_or_update_value( - self, - tag_name: str, - tag_value: str, - **kwargs: Any - ) -> "_models.TagValue": + def create_or_update_value(self, tag_name: str, tag_value: str, **kwargs: Any) -> _models.TagValue: """Creates a predefined value for a predefined tag name. This operation allows adding a value to the list of predefined values for an existing predefined tag name. A tag value can have a maximum of 256 characters. - :param tag_name: The name of the tag. + :param tag_name: The name of the tag. Required. :type tag_name: str - :param tag_value: The value of the tag to create. + :param tag_value: The value of the tag to create. Required. :type tag_value: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: TagValue, or the result of cls(response) + :return: TagValue or the result of cls(response) :rtype: ~azure.mgmt.resource.resources.v2020_06_01.models.TagValue - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.TagValue"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + 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', "2020-06-01") # type: str + api_version = kwargs.pop("api_version", _params.pop("api-version", "2020-06-01")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[_models.TagValue] - request = build_tags_create_or_update_value_request( tag_name=tag_name, tag_value=tag_value, subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.create_or_update_value.metadata['url'], + template_url=self.create_or_update_value.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200, 201]: @@ -10172,25 +11570,20 @@ def create_or_update_value( raise HttpResponseError(response=response, error_format=ARMErrorFormat) if response.status_code == 200: - deserialized = self._deserialize('TagValue', pipeline_response) + deserialized = self._deserialize("TagValue", pipeline_response) if response.status_code == 201: - deserialized = self._deserialize('TagValue', pipeline_response) + deserialized = self._deserialize("TagValue", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - create_or_update_value.metadata = {'url': "/subscriptions/{subscriptionId}/tagNames/{tagName}/tagValues/{tagValue}"} # type: ignore - + create_or_update_value.metadata = {"url": "/subscriptions/{subscriptionId}/tagNames/{tagName}/tagValues/{tagValue}"} # type: ignore @distributed_trace - def create_or_update( - self, - tag_name: str, - **kwargs: Any - ) -> "_models.TagDetails": + def create_or_update(self, tag_name: str, **kwargs: Any) -> _models.TagDetails: """Creates a predefined tag name. This operation allows adding a name to the list of predefined tag names for the given @@ -10198,36 +11591,42 @@ def create_or_update( names cannot have the following prefixes which are reserved for Azure use: 'microsoft', 'azure', 'windows'. - :param tag_name: The name of the tag to create. + :param tag_name: The name of the tag to create. Required. :type tag_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: TagDetails, or the result of cls(response) + :return: TagDetails or the result of cls(response) :rtype: ~azure.mgmt.resource.resources.v2020_06_01.models.TagDetails - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.TagDetails"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + 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', "2020-06-01") # type: str + api_version = kwargs.pop("api_version", _params.pop("api-version", "2020-06-01")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[_models.TagDetails] - request = build_tags_create_or_update_request( tag_name=tag_name, subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.create_or_update.metadata['url'], + template_url=self.create_or_update.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200, 201]: @@ -10235,61 +11634,62 @@ def create_or_update( raise HttpResponseError(response=response, error_format=ARMErrorFormat) if response.status_code == 200: - deserialized = self._deserialize('TagDetails', pipeline_response) + deserialized = self._deserialize("TagDetails", pipeline_response) if response.status_code == 201: - deserialized = self._deserialize('TagDetails', pipeline_response) + deserialized = self._deserialize("TagDetails", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - create_or_update.metadata = {'url': "/subscriptions/{subscriptionId}/tagNames/{tagName}"} # type: ignore - + create_or_update.metadata = {"url": "/subscriptions/{subscriptionId}/tagNames/{tagName}"} # type: ignore @distributed_trace - def delete( # pylint: disable=inconsistent-return-statements - self, - tag_name: str, - **kwargs: Any - ) -> None: + def delete(self, tag_name: str, **kwargs: Any) -> None: # pylint: disable=inconsistent-return-statements """Deletes a predefined tag name. This operation allows deleting a name from the list of predefined tag names for the given subscription. The name being deleted must not be in use as a tag name for any resource. All predefined values for the given name must have already been deleted. - :param tag_name: The name of the tag. + :param tag_name: The name of the tag. Required. :type tag_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: None, or the result of cls(response) + :return: None or the result of cls(response) :rtype: None - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType[None] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + 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', "2020-06-01") # type: str + api_version = kwargs.pop("api_version", _params.pop("api-version", "2020-06-01")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[None] - request = build_tags_delete_request( tag_name=tag_name, subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.delete.metadata['url'], + template_url=self.delete.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200, 204]: @@ -10299,14 +11699,10 @@ def delete( # pylint: disable=inconsistent-return-statements if cls: return cls(pipeline_response, None, {}) - delete.metadata = {'url': "/subscriptions/{subscriptionId}/tagNames/{tagName}"} # type: ignore - + delete.metadata = {"url": "/subscriptions/{subscriptionId}/tagNames/{tagName}"} # type: ignore @distributed_trace - def list( - self, - **kwargs: Any - ) -> Iterable["_models.TagsListResult"]: + def list(self, **kwargs: Any) -> Iterable["_models.TagDetails"]: """Gets a summary of tag usage under the subscription. This operation performs a union of predefined tags, resource tags, resource group tags and @@ -10315,37 +11711,46 @@ def list( result. :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either TagsListResult or the result of cls(response) + :return: An iterator like instance of either TagDetails or the result of cls(response) :rtype: - ~azure.core.paging.ItemPaged[~azure.mgmt.resource.resources.v2020_06_01.models.TagsListResult] - :raises: ~azure.core.exceptions.HttpResponseError + ~azure.core.paging.ItemPaged[~azure.mgmt.resource.resources.v2020_06_01.models.TagDetails] + :raises ~azure.core.exceptions.HttpResponseError: """ - api_version = kwargs.pop('api_version', "2020-06-01") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2020-06-01")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[_models.TagsListResult] - cls = kwargs.pop('cls', None) # type: ClsType["_models.TagsListResult"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) + def prepare_request(next_link=None): if not next_link: - + request = build_tags_list_request( subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.list.metadata['url'], + template_url=self.list.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore else: - - request = build_tags_list_request( - subscription_id=self._config.subscription_id, - template_url=next_link, - ) + # make call to next link with the client's api-version + _parsed_next_link = urlparse(next_link) + _next_request_params = case_insensitive_dict(parse_qs(_parsed_next_link.query)) + _next_request_params["api-version"] = self._config.api_version + request = HttpRequest("GET", urljoin(next_link, _parsed_next_link.path), params=_next_request_params) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore request.method = "GET" return request @@ -10359,10 +11764,8 @@ def extract_data(pipeline_response): def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) response = pipeline_response.http_response @@ -10372,82 +11775,139 @@ def get_next(next_link=None): return pipeline_response + return ItemPaged(get_next, extract_data) - return ItemPaged( - get_next, extract_data - ) - list.metadata = {'url': "/subscriptions/{subscriptionId}/tagNames"} # type: ignore + list.metadata = {"url": "/subscriptions/{subscriptionId}/tagNames"} # type: ignore - @distributed_trace + @overload def create_or_update_at_scope( - self, - scope: str, - parameters: "_models.TagsResource", - **kwargs: Any - ) -> "_models.TagsResource": + self, scope: str, parameters: _models.TagsResource, *, content_type: str = "application/json", **kwargs: Any + ) -> _models.TagsResource: """Creates or updates the entire set of tags on a resource or subscription. This operation allows adding or replacing the entire set of tags on the specified resource or subscription. The specified entity can have a maximum of 50 tags. - :param scope: The resource scope. + :param scope: The resource scope. Required. :type scope: str - :param parameters: + :param parameters: Required. :type parameters: ~azure.mgmt.resource.resources.v2020_06_01.models.TagsResource + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: TagsResource or the result of cls(response) + :rtype: ~azure.mgmt.resource.resources.v2020_06_01.models.TagsResource + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + def create_or_update_at_scope( + self, scope: str, parameters: IO, *, content_type: str = "application/json", **kwargs: Any + ) -> _models.TagsResource: + """Creates or updates the entire set of tags on a resource or subscription. + + This operation allows adding or replacing the entire set of tags on the specified resource or + subscription. The specified entity can have a maximum of 50 tags. + + :param scope: The resource scope. Required. + :type scope: str + :param parameters: Required. + :type parameters: IO + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: TagsResource or the result of cls(response) + :rtype: ~azure.mgmt.resource.resources.v2020_06_01.models.TagsResource + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace + def create_or_update_at_scope( + self, scope: str, parameters: Union[_models.TagsResource, IO], **kwargs: Any + ) -> _models.TagsResource: + """Creates or updates the entire set of tags on a resource or subscription. + + This operation allows adding or replacing the entire set of tags on the specified resource or + subscription. The specified entity can have a maximum of 50 tags. + + :param scope: The resource scope. Required. + :type scope: str + :param parameters: Is either a model type or a IO type. Required. + :type parameters: ~azure.mgmt.resource.resources.v2020_06_01.models.TagsResource or IO + :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. + Default value is None. + :paramtype content_type: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: TagsResource, or the result of cls(response) + :return: TagsResource or the result of cls(response) :rtype: ~azure.mgmt.resource.resources.v2020_06_01.models.TagsResource - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.TagsResource"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', "2020-06-01") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + api_version = kwargs.pop("api_version", _params.pop("api-version", "2020-06-01")) # type: str + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.TagsResource] - _json = self._serialize.body(parameters, 'TagsResource') + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(parameters, (IO, bytes)): + _content = parameters + else: + _json = self._serialize.body(parameters, "TagsResource") request = build_tags_create_or_update_at_scope_request( scope=scope, api_version=api_version, content_type=content_type, json=_json, - template_url=self.create_or_update_at_scope.metadata['url'], + content=_content, + template_url=self.create_or_update_at_scope.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) - deserialized = self._deserialize('TagsResource', pipeline_response) + deserialized = self._deserialize("TagsResource", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - create_or_update_at_scope.metadata = {'url': "/{scope}/providers/Microsoft.Resources/tags/default"} # type: ignore - + create_or_update_at_scope.metadata = {"url": "/{scope}/providers/Microsoft.Resources/tags/default"} # type: ignore - @distributed_trace + @overload def update_at_scope( self, scope: str, - parameters: "_models.TagsPatchResource", + parameters: _models.TagsPatchResource, + *, + content_type: str = "application/json", **kwargs: Any - ) -> "_models.TagsResource": + ) -> _models.TagsResource: """Selectively updates the set of tags on a resource or subscription. This operation allows replacing, merging or selectively deleting tags on the specified resource @@ -10457,151 +11917,222 @@ def update_at_scope( names. The 'delete' option allows selectively deleting tags based on given names or name/value pairs. - :param scope: The resource scope. + :param scope: The resource scope. Required. :type scope: str - :param parameters: + :param parameters: Required. :type parameters: ~azure.mgmt.resource.resources.v2020_06_01.models.TagsPatchResource + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: TagsResource or the result of cls(response) + :rtype: ~azure.mgmt.resource.resources.v2020_06_01.models.TagsResource + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + def update_at_scope( + self, scope: str, parameters: IO, *, content_type: str = "application/json", **kwargs: Any + ) -> _models.TagsResource: + """Selectively updates the set of tags on a resource or subscription. + + This operation allows replacing, merging or selectively deleting tags on the specified resource + or subscription. The specified entity can have a maximum of 50 tags at the end of the + operation. The 'replace' option replaces the entire set of existing tags with a new set. The + 'merge' option allows adding tags with new names and updating the values of tags with existing + names. The 'delete' option allows selectively deleting tags based on given names or name/value + pairs. + + :param scope: The resource scope. Required. + :type scope: str + :param parameters: Required. + :type parameters: IO + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: TagsResource or the result of cls(response) + :rtype: ~azure.mgmt.resource.resources.v2020_06_01.models.TagsResource + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace + def update_at_scope( + self, scope: str, parameters: Union[_models.TagsPatchResource, IO], **kwargs: Any + ) -> _models.TagsResource: + """Selectively updates the set of tags on a resource or subscription. + + This operation allows replacing, merging or selectively deleting tags on the specified resource + or subscription. The specified entity can have a maximum of 50 tags at the end of the + operation. The 'replace' option replaces the entire set of existing tags with a new set. The + 'merge' option allows adding tags with new names and updating the values of tags with existing + names. The 'delete' option allows selectively deleting tags based on given names or name/value + pairs. + + :param scope: The resource scope. Required. + :type scope: str + :param parameters: Is either a model type or a IO type. Required. + :type parameters: ~azure.mgmt.resource.resources.v2020_06_01.models.TagsPatchResource or IO + :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. + Default value is None. + :paramtype content_type: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: TagsResource, or the result of cls(response) + :return: TagsResource or the result of cls(response) :rtype: ~azure.mgmt.resource.resources.v2020_06_01.models.TagsResource - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.TagsResource"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', "2020-06-01") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + api_version = kwargs.pop("api_version", _params.pop("api-version", "2020-06-01")) # type: str + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.TagsResource] - _json = self._serialize.body(parameters, 'TagsPatchResource') + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(parameters, (IO, bytes)): + _content = parameters + else: + _json = self._serialize.body(parameters, "TagsPatchResource") request = build_tags_update_at_scope_request( scope=scope, api_version=api_version, content_type=content_type, json=_json, - template_url=self.update_at_scope.metadata['url'], + content=_content, + template_url=self.update_at_scope.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) - deserialized = self._deserialize('TagsResource', pipeline_response) + deserialized = self._deserialize("TagsResource", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - update_at_scope.metadata = {'url': "/{scope}/providers/Microsoft.Resources/tags/default"} # type: ignore - + update_at_scope.metadata = {"url": "/{scope}/providers/Microsoft.Resources/tags/default"} # type: ignore @distributed_trace - def get_at_scope( - self, - scope: str, - **kwargs: Any - ) -> "_models.TagsResource": + def get_at_scope(self, scope: str, **kwargs: Any) -> _models.TagsResource: """Gets the entire set of tags on a resource or subscription. Gets the entire set of tags on a resource or subscription. - :param scope: The resource scope. + :param scope: The resource scope. Required. :type scope: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: TagsResource, or the result of cls(response) + :return: TagsResource or the result of cls(response) :rtype: ~azure.mgmt.resource.resources.v2020_06_01.models.TagsResource - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.TagsResource"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) - api_version = kwargs.pop('api_version', "2020-06-01") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2020-06-01")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[_models.TagsResource] - request = build_tags_get_at_scope_request( scope=scope, api_version=api_version, - template_url=self.get_at_scope.metadata['url'], + template_url=self.get_at_scope.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) - deserialized = self._deserialize('TagsResource', pipeline_response) + deserialized = self._deserialize("TagsResource", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - get_at_scope.metadata = {'url': "/{scope}/providers/Microsoft.Resources/tags/default"} # type: ignore - + get_at_scope.metadata = {"url": "/{scope}/providers/Microsoft.Resources/tags/default"} # type: ignore @distributed_trace - def delete_at_scope( # pylint: disable=inconsistent-return-statements - self, - scope: str, - **kwargs: Any - ) -> None: + def delete_at_scope(self, scope: str, **kwargs: Any) -> None: # pylint: disable=inconsistent-return-statements """Deletes the entire set of tags on a resource or subscription. Deletes the entire set of tags on a resource or subscription. - :param scope: The resource scope. + :param scope: The resource scope. Required. :type scope: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: None, or the result of cls(response) + :return: None or the result of cls(response) :rtype: None - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType[None] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + 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', "2020-06-01") # type: str + api_version = kwargs.pop("api_version", _params.pop("api-version", "2020-06-01")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[None] - request = build_tags_delete_at_scope_request( scope=scope, api_version=api_version, - template_url=self.delete_at_scope.metadata['url'], + template_url=self.delete_at_scope.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200]: @@ -10611,143 +12142,145 @@ def delete_at_scope( # pylint: disable=inconsistent-return-statements if cls: return cls(pipeline_response, None, {}) - delete_at_scope.metadata = {'url': "/{scope}/providers/Microsoft.Resources/tags/default"} # type: ignore + delete_at_scope.metadata = {"url": "/{scope}/providers/Microsoft.Resources/tags/default"} # type: ignore -class DeploymentOperationsOperations(object): - """DeploymentOperationsOperations operations. - You should not instantiate this class directly. Instead, you should create a Client instance that - instantiates it for you and attaches it as an attribute. +class DeploymentOperationsOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. - :ivar models: Alias to model classes used in this operation group. - :type models: ~azure.mgmt.resource.resources.v2020_06_01.models - :param client: Client for service requests. - :param config: Configuration of service client. - :param serializer: An object model serializer. - :param deserializer: An object model deserializer. + Instead, you should access the following operations through + :class:`~azure.mgmt.resource.resources.v2020_06_01.ResourceManagementClient`'s + :attr:`deployment_operations` attribute. """ models = _models - def __init__(self, client, config, serializer, deserializer): - self._client = client - self._serialize = serializer - self._deserialize = deserializer - self._config = config + def __init__(self, *args, **kwargs): + input_args = list(args) + self._client = input_args.pop(0) if input_args else kwargs.pop("client") + self._config = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") @distributed_trace def get_at_scope( - self, - scope: str, - deployment_name: str, - operation_id: str, - **kwargs: Any - ) -> "_models.DeploymentOperation": + self, scope: str, deployment_name: str, operation_id: str, **kwargs: Any + ) -> _models.DeploymentOperation: """Gets a deployments operation. - :param scope: The resource scope. + :param scope: The resource scope. Required. :type scope: str - :param deployment_name: The name of the deployment. + :param deployment_name: The name of the deployment. Required. :type deployment_name: str - :param operation_id: The ID of the operation to get. + :param operation_id: The ID of the operation to get. Required. :type operation_id: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: DeploymentOperation, or the result of cls(response) + :return: DeploymentOperation or the result of cls(response) :rtype: ~azure.mgmt.resource.resources.v2020_06_01.models.DeploymentOperation - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.DeploymentOperation"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) - api_version = kwargs.pop('api_version', "2020-06-01") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2020-06-01")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[_models.DeploymentOperation] - request = build_deployment_operations_get_at_scope_request( scope=scope, deployment_name=deployment_name, operation_id=operation_id, api_version=api_version, - template_url=self.get_at_scope.metadata['url'], + template_url=self.get_at_scope.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) - deserialized = self._deserialize('DeploymentOperation', pipeline_response) + deserialized = self._deserialize("DeploymentOperation", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - get_at_scope.metadata = {'url': "/{scope}/providers/Microsoft.Resources/deployments/{deploymentName}/operations/{operationId}"} # type: ignore - + get_at_scope.metadata = {"url": "/{scope}/providers/Microsoft.Resources/deployments/{deploymentName}/operations/{operationId}"} # type: ignore @distributed_trace def list_at_scope( - self, - scope: str, - deployment_name: str, - top: Optional[int] = None, - **kwargs: Any - ) -> Iterable["_models.DeploymentOperationsListResult"]: + self, scope: str, deployment_name: str, top: Optional[int] = None, **kwargs: Any + ) -> Iterable["_models.DeploymentOperation"]: """Gets all deployments operations for a deployment. - :param scope: The resource scope. + :param scope: The resource scope. Required. :type scope: str - :param deployment_name: The name of the deployment. + :param deployment_name: The name of the deployment. Required. :type deployment_name: str :param top: The number of results to return. Default value is None. :type top: int :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either DeploymentOperationsListResult or the result of - cls(response) + :return: An iterator like instance of either DeploymentOperation or the result of cls(response) :rtype: - ~azure.core.paging.ItemPaged[~azure.mgmt.resource.resources.v2020_06_01.models.DeploymentOperationsListResult] - :raises: ~azure.core.exceptions.HttpResponseError + ~azure.core.paging.ItemPaged[~azure.mgmt.resource.resources.v2020_06_01.models.DeploymentOperation] + :raises ~azure.core.exceptions.HttpResponseError: """ - api_version = kwargs.pop('api_version', "2020-06-01") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2020-06-01")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[_models.DeploymentOperationsListResult] - cls = kwargs.pop('cls', None) # type: ClsType["_models.DeploymentOperationsListResult"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) + def prepare_request(next_link=None): if not next_link: - + request = build_deployment_operations_list_at_scope_request( scope=scope, deployment_name=deployment_name, - api_version=api_version, top=top, - template_url=self.list_at_scope.metadata['url'], + api_version=api_version, + template_url=self.list_at_scope.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore else: - - request = build_deployment_operations_list_at_scope_request( - scope=scope, - deployment_name=deployment_name, - template_url=next_link, - ) + # make call to next link with the client's api-version + _parsed_next_link = urlparse(next_link) + _next_request_params = case_insensitive_dict(parse_qs(_parsed_next_link.query)) + _next_request_params["api-version"] = self._config.api_version + request = HttpRequest("GET", urljoin(next_link, _parsed_next_link.path), params=_next_request_params) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore request.method = "GET" return request @@ -10761,10 +12294,8 @@ def extract_data(pipeline_response): def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) response = pipeline_response.http_response @@ -10774,116 +12305,121 @@ def get_next(next_link=None): return pipeline_response + return ItemPaged(get_next, extract_data) - return ItemPaged( - get_next, extract_data - ) - list_at_scope.metadata = {'url': "/{scope}/providers/Microsoft.Resources/deployments/{deploymentName}/operations"} # type: ignore + list_at_scope.metadata = {"url": "/{scope}/providers/Microsoft.Resources/deployments/{deploymentName}/operations"} # type: ignore @distributed_trace def get_at_tenant_scope( - self, - deployment_name: str, - operation_id: str, - **kwargs: Any - ) -> "_models.DeploymentOperation": + self, deployment_name: str, operation_id: str, **kwargs: Any + ) -> _models.DeploymentOperation: """Gets a deployments operation. - :param deployment_name: The name of the deployment. + :param deployment_name: The name of the deployment. Required. :type deployment_name: str - :param operation_id: The ID of the operation to get. + :param operation_id: The ID of the operation to get. Required. :type operation_id: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: DeploymentOperation, or the result of cls(response) + :return: DeploymentOperation or the result of cls(response) :rtype: ~azure.mgmt.resource.resources.v2020_06_01.models.DeploymentOperation - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.DeploymentOperation"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + 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', "2020-06-01") # type: str + api_version = kwargs.pop("api_version", _params.pop("api-version", "2020-06-01")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[_models.DeploymentOperation] - request = build_deployment_operations_get_at_tenant_scope_request( deployment_name=deployment_name, operation_id=operation_id, api_version=api_version, - template_url=self.get_at_tenant_scope.metadata['url'], + template_url=self.get_at_tenant_scope.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) - deserialized = self._deserialize('DeploymentOperation', pipeline_response) + deserialized = self._deserialize("DeploymentOperation", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - get_at_tenant_scope.metadata = {'url': "/providers/Microsoft.Resources/deployments/{deploymentName}/operations/{operationId}"} # type: ignore - + get_at_tenant_scope.metadata = {"url": "/providers/Microsoft.Resources/deployments/{deploymentName}/operations/{operationId}"} # type: ignore @distributed_trace def list_at_tenant_scope( - self, - deployment_name: str, - top: Optional[int] = None, - **kwargs: Any - ) -> Iterable["_models.DeploymentOperationsListResult"]: + self, deployment_name: str, top: Optional[int] = None, **kwargs: Any + ) -> Iterable["_models.DeploymentOperation"]: """Gets all deployments operations for a deployment. - :param deployment_name: The name of the deployment. + :param deployment_name: The name of the deployment. Required. :type deployment_name: str :param top: The number of results to return. Default value is None. :type top: int :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either DeploymentOperationsListResult or the result of - cls(response) + :return: An iterator like instance of either DeploymentOperation or the result of cls(response) :rtype: - ~azure.core.paging.ItemPaged[~azure.mgmt.resource.resources.v2020_06_01.models.DeploymentOperationsListResult] - :raises: ~azure.core.exceptions.HttpResponseError + ~azure.core.paging.ItemPaged[~azure.mgmt.resource.resources.v2020_06_01.models.DeploymentOperation] + :raises ~azure.core.exceptions.HttpResponseError: """ - api_version = kwargs.pop('api_version', "2020-06-01") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2020-06-01")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[_models.DeploymentOperationsListResult] - cls = kwargs.pop('cls', None) # type: ClsType["_models.DeploymentOperationsListResult"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) + def prepare_request(next_link=None): if not next_link: - + request = build_deployment_operations_list_at_tenant_scope_request( deployment_name=deployment_name, - api_version=api_version, top=top, - template_url=self.list_at_tenant_scope.metadata['url'], + api_version=api_version, + template_url=self.list_at_tenant_scope.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore else: - - request = build_deployment_operations_list_at_tenant_scope_request( - deployment_name=deployment_name, - template_url=next_link, - ) + # make call to next link with the client's api-version + _parsed_next_link = urlparse(next_link) + _next_request_params = case_insensitive_dict(parse_qs(_parsed_next_link.query)) + _next_request_params["api-version"] = self._config.api_version + request = HttpRequest("GET", urljoin(next_link, _parsed_next_link.path), params=_next_request_params) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore request.method = "GET" return request @@ -10897,10 +12433,8 @@ def extract_data(pipeline_response): def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) response = pipeline_response.http_response @@ -10910,125 +12444,127 @@ def get_next(next_link=None): return pipeline_response + return ItemPaged(get_next, extract_data) - return ItemPaged( - get_next, extract_data - ) - list_at_tenant_scope.metadata = {'url': "/providers/Microsoft.Resources/deployments/{deploymentName}/operations"} # type: ignore + list_at_tenant_scope.metadata = {"url": "/providers/Microsoft.Resources/deployments/{deploymentName}/operations"} # type: ignore @distributed_trace def get_at_management_group_scope( - self, - group_id: str, - deployment_name: str, - operation_id: str, - **kwargs: Any - ) -> "_models.DeploymentOperation": + self, group_id: str, deployment_name: str, operation_id: str, **kwargs: Any + ) -> _models.DeploymentOperation: """Gets a deployments operation. - :param group_id: The management group ID. + :param group_id: The management group ID. Required. :type group_id: str - :param deployment_name: The name of the deployment. + :param deployment_name: The name of the deployment. Required. :type deployment_name: str - :param operation_id: The ID of the operation to get. + :param operation_id: The ID of the operation to get. Required. :type operation_id: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: DeploymentOperation, or the result of cls(response) + :return: DeploymentOperation or the result of cls(response) :rtype: ~azure.mgmt.resource.resources.v2020_06_01.models.DeploymentOperation - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.DeploymentOperation"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + 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', "2020-06-01") # type: str + api_version = kwargs.pop("api_version", _params.pop("api-version", "2020-06-01")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[_models.DeploymentOperation] - request = build_deployment_operations_get_at_management_group_scope_request( group_id=group_id, deployment_name=deployment_name, operation_id=operation_id, api_version=api_version, - template_url=self.get_at_management_group_scope.metadata['url'], + template_url=self.get_at_management_group_scope.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) - deserialized = self._deserialize('DeploymentOperation', pipeline_response) + deserialized = self._deserialize("DeploymentOperation", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - get_at_management_group_scope.metadata = {'url': "/providers/Microsoft.Management/managementGroups/{groupId}/providers/Microsoft.Resources/deployments/{deploymentName}/operations/{operationId}"} # type: ignore - + get_at_management_group_scope.metadata = {"url": "/providers/Microsoft.Management/managementGroups/{groupId}/providers/Microsoft.Resources/deployments/{deploymentName}/operations/{operationId}"} # type: ignore @distributed_trace def list_at_management_group_scope( - self, - group_id: str, - deployment_name: str, - top: Optional[int] = None, - **kwargs: Any - ) -> Iterable["_models.DeploymentOperationsListResult"]: + self, group_id: str, deployment_name: str, top: Optional[int] = None, **kwargs: Any + ) -> Iterable["_models.DeploymentOperation"]: """Gets all deployments operations for a deployment. - :param group_id: The management group ID. + :param group_id: The management group ID. Required. :type group_id: str - :param deployment_name: The name of the deployment. + :param deployment_name: The name of the deployment. Required. :type deployment_name: str :param top: The number of results to return. Default value is None. :type top: int :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either DeploymentOperationsListResult or the result of - cls(response) + :return: An iterator like instance of either DeploymentOperation or the result of cls(response) :rtype: - ~azure.core.paging.ItemPaged[~azure.mgmt.resource.resources.v2020_06_01.models.DeploymentOperationsListResult] - :raises: ~azure.core.exceptions.HttpResponseError + ~azure.core.paging.ItemPaged[~azure.mgmt.resource.resources.v2020_06_01.models.DeploymentOperation] + :raises ~azure.core.exceptions.HttpResponseError: """ - api_version = kwargs.pop('api_version', "2020-06-01") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2020-06-01")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[_models.DeploymentOperationsListResult] - cls = kwargs.pop('cls', None) # type: ClsType["_models.DeploymentOperationsListResult"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) + def prepare_request(next_link=None): if not next_link: - + request = build_deployment_operations_list_at_management_group_scope_request( group_id=group_id, deployment_name=deployment_name, - api_version=api_version, top=top, - template_url=self.list_at_management_group_scope.metadata['url'], + api_version=api_version, + template_url=self.list_at_management_group_scope.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore else: - - request = build_deployment_operations_list_at_management_group_scope_request( - group_id=group_id, - deployment_name=deployment_name, - template_url=next_link, - ) + # make call to next link with the client's api-version + _parsed_next_link = urlparse(next_link) + _next_request_params = case_insensitive_dict(parse_qs(_parsed_next_link.query)) + _next_request_params["api-version"] = self._config.api_version + request = HttpRequest("GET", urljoin(next_link, _parsed_next_link.path), params=_next_request_params) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore request.method = "GET" return request @@ -11042,10 +12578,8 @@ def extract_data(pipeline_response): def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) response = pipeline_response.http_response @@ -11055,119 +12589,123 @@ def get_next(next_link=None): return pipeline_response + return ItemPaged(get_next, extract_data) - return ItemPaged( - get_next, extract_data - ) - list_at_management_group_scope.metadata = {'url': "/providers/Microsoft.Management/managementGroups/{groupId}/providers/Microsoft.Resources/deployments/{deploymentName}/operations"} # type: ignore + list_at_management_group_scope.metadata = {"url": "/providers/Microsoft.Management/managementGroups/{groupId}/providers/Microsoft.Resources/deployments/{deploymentName}/operations"} # type: ignore @distributed_trace def get_at_subscription_scope( - self, - deployment_name: str, - operation_id: str, - **kwargs: Any - ) -> "_models.DeploymentOperation": + self, deployment_name: str, operation_id: str, **kwargs: Any + ) -> _models.DeploymentOperation: """Gets a deployments operation. - :param deployment_name: The name of the deployment. + :param deployment_name: The name of the deployment. Required. :type deployment_name: str - :param operation_id: The ID of the operation to get. + :param operation_id: The ID of the operation to get. Required. :type operation_id: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: DeploymentOperation, or the result of cls(response) + :return: DeploymentOperation or the result of cls(response) :rtype: ~azure.mgmt.resource.resources.v2020_06_01.models.DeploymentOperation - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.DeploymentOperation"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) - api_version = kwargs.pop('api_version', "2020-06-01") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2020-06-01")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[_models.DeploymentOperation] - request = build_deployment_operations_get_at_subscription_scope_request( deployment_name=deployment_name, operation_id=operation_id, subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.get_at_subscription_scope.metadata['url'], + template_url=self.get_at_subscription_scope.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) - deserialized = self._deserialize('DeploymentOperation', pipeline_response) + deserialized = self._deserialize("DeploymentOperation", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - get_at_subscription_scope.metadata = {'url': "/subscriptions/{subscriptionId}/providers/Microsoft.Resources/deployments/{deploymentName}/operations/{operationId}"} # type: ignore - + get_at_subscription_scope.metadata = {"url": "/subscriptions/{subscriptionId}/providers/Microsoft.Resources/deployments/{deploymentName}/operations/{operationId}"} # type: ignore @distributed_trace def list_at_subscription_scope( - self, - deployment_name: str, - top: Optional[int] = None, - **kwargs: Any - ) -> Iterable["_models.DeploymentOperationsListResult"]: + self, deployment_name: str, top: Optional[int] = None, **kwargs: Any + ) -> Iterable["_models.DeploymentOperation"]: """Gets all deployments operations for a deployment. - :param deployment_name: The name of the deployment. + :param deployment_name: The name of the deployment. Required. :type deployment_name: str :param top: The number of results to return. Default value is None. :type top: int :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either DeploymentOperationsListResult or the result of - cls(response) + :return: An iterator like instance of either DeploymentOperation or the result of cls(response) :rtype: - ~azure.core.paging.ItemPaged[~azure.mgmt.resource.resources.v2020_06_01.models.DeploymentOperationsListResult] - :raises: ~azure.core.exceptions.HttpResponseError + ~azure.core.paging.ItemPaged[~azure.mgmt.resource.resources.v2020_06_01.models.DeploymentOperation] + :raises ~azure.core.exceptions.HttpResponseError: """ - api_version = kwargs.pop('api_version', "2020-06-01") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2020-06-01")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[_models.DeploymentOperationsListResult] - cls = kwargs.pop('cls', None) # type: ClsType["_models.DeploymentOperationsListResult"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) + def prepare_request(next_link=None): if not next_link: - + request = build_deployment_operations_list_at_subscription_scope_request( deployment_name=deployment_name, subscription_id=self._config.subscription_id, - api_version=api_version, top=top, - template_url=self.list_at_subscription_scope.metadata['url'], + api_version=api_version, + template_url=self.list_at_subscription_scope.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore else: - - request = build_deployment_operations_list_at_subscription_scope_request( - deployment_name=deployment_name, - subscription_id=self._config.subscription_id, - template_url=next_link, - ) + # make call to next link with the client's api-version + _parsed_next_link = urlparse(next_link) + _next_request_params = case_insensitive_dict(parse_qs(_parsed_next_link.query)) + _next_request_params["api-version"] = self._config.api_version + request = HttpRequest("GET", urljoin(next_link, _parsed_next_link.path), params=_next_request_params) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore request.method = "GET" return request @@ -11181,10 +12719,8 @@ def extract_data(pipeline_response): def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) response = pipeline_response.http_response @@ -11194,128 +12730,131 @@ def get_next(next_link=None): return pipeline_response + return ItemPaged(get_next, extract_data) - return ItemPaged( - get_next, extract_data - ) - list_at_subscription_scope.metadata = {'url': "/subscriptions/{subscriptionId}/providers/Microsoft.Resources/deployments/{deploymentName}/operations"} # type: ignore + list_at_subscription_scope.metadata = {"url": "/subscriptions/{subscriptionId}/providers/Microsoft.Resources/deployments/{deploymentName}/operations"} # type: ignore @distributed_trace def get( - self, - resource_group_name: str, - deployment_name: str, - operation_id: str, - **kwargs: Any - ) -> "_models.DeploymentOperation": + self, resource_group_name: str, deployment_name: str, operation_id: str, **kwargs: Any + ) -> _models.DeploymentOperation: """Gets a deployments operation. :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. :type resource_group_name: str - :param deployment_name: The name of the deployment. + :param deployment_name: The name of the deployment. Required. :type deployment_name: str - :param operation_id: The ID of the operation to get. + :param operation_id: The ID of the operation to get. Required. :type operation_id: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: DeploymentOperation, or the result of cls(response) + :return: DeploymentOperation or the result of cls(response) :rtype: ~azure.mgmt.resource.resources.v2020_06_01.models.DeploymentOperation - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.DeploymentOperation"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + 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', "2020-06-01") # type: str + api_version = kwargs.pop("api_version", _params.pop("api-version", "2020-06-01")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[_models.DeploymentOperation] - request = build_deployment_operations_get_request( resource_group_name=resource_group_name, deployment_name=deployment_name, operation_id=operation_id, subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.get.metadata['url'], + template_url=self.get.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) - deserialized = self._deserialize('DeploymentOperation', pipeline_response) + deserialized = self._deserialize("DeploymentOperation", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - get.metadata = {'url': "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/deployments/{deploymentName}/operations/{operationId}"} # type: ignore - + get.metadata = {"url": "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/deployments/{deploymentName}/operations/{operationId}"} # type: ignore @distributed_trace def list( - self, - resource_group_name: str, - deployment_name: str, - top: Optional[int] = None, - **kwargs: Any - ) -> Iterable["_models.DeploymentOperationsListResult"]: + self, resource_group_name: str, deployment_name: str, top: Optional[int] = None, **kwargs: Any + ) -> Iterable["_models.DeploymentOperation"]: """Gets all deployments operations for a deployment. :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. :type resource_group_name: str - :param deployment_name: The name of the deployment. + :param deployment_name: The name of the deployment. Required. :type deployment_name: str :param top: The number of results to return. Default value is None. :type top: int :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either DeploymentOperationsListResult or the result of - cls(response) + :return: An iterator like instance of either DeploymentOperation or the result of cls(response) :rtype: - ~azure.core.paging.ItemPaged[~azure.mgmt.resource.resources.v2020_06_01.models.DeploymentOperationsListResult] - :raises: ~azure.core.exceptions.HttpResponseError + ~azure.core.paging.ItemPaged[~azure.mgmt.resource.resources.v2020_06_01.models.DeploymentOperation] + :raises ~azure.core.exceptions.HttpResponseError: """ - api_version = kwargs.pop('api_version', "2020-06-01") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2020-06-01")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[_models.DeploymentOperationsListResult] - cls = kwargs.pop('cls', None) # type: ClsType["_models.DeploymentOperationsListResult"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) + def prepare_request(next_link=None): if not next_link: - + request = build_deployment_operations_list_request( resource_group_name=resource_group_name, deployment_name=deployment_name, subscription_id=self._config.subscription_id, - api_version=api_version, top=top, - template_url=self.list.metadata['url'], + 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.url = self._client.format_url(request.url) # type: ignore else: - - request = build_deployment_operations_list_request( - resource_group_name=resource_group_name, - deployment_name=deployment_name, - subscription_id=self._config.subscription_id, - template_url=next_link, - ) + # make call to next link with the client's api-version + _parsed_next_link = urlparse(next_link) + _next_request_params = case_insensitive_dict(parse_qs(_parsed_next_link.query)) + _next_request_params["api-version"] = self._config.api_version + request = HttpRequest("GET", urljoin(next_link, _parsed_next_link.path), params=_next_request_params) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore request.method = "GET" return request @@ -11329,10 +12868,8 @@ def extract_data(pipeline_response): def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) response = pipeline_response.http_response @@ -11342,8 +12879,6 @@ def get_next(next_link=None): return pipeline_response + return ItemPaged(get_next, extract_data) - return ItemPaged( - get_next, extract_data - ) - list.metadata = {'url': "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/deployments/{deploymentName}/operations"} # type: ignore + list.metadata = {"url": "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/deployments/{deploymentName}/operations"} # type: ignore diff --git a/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/resources/v2020_06_01/operations/_patch.py b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/resources/v2020_06_01/operations/_patch.py new file mode 100644 index 0000000000000..f7dd32510333d --- /dev/null +++ b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/resources/v2020_06_01/operations/_patch.py @@ -0,0 +1,20 @@ +# ------------------------------------ +# Copyright (c) Microsoft Corporation. +# Licensed under the MIT License. +# ------------------------------------ +"""Customize generated code here. + +Follow our quickstart for examples: https://aka.ms/azsdk/python/dpcodegen/python/customize +""" +from typing import List + +__all__: List[str] = [] # Add all objects you want publicly available to users at this package level + + +def patch_sdk(): + """Do not remove from this file. + + `patch_sdk` is a last resort escape hatch that allows you to do customizations + you can't accomplish using the techniques described in + https://aka.ms/azsdk/python/dpcodegen/python/customize + """ diff --git a/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/resources/v2020_10_01/__init__.py b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/resources/v2020_10_01/__init__.py index 449220069f2f2..2b201470d075e 100644 --- a/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/resources/v2020_10_01/__init__.py +++ b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/resources/v2020_10_01/__init__.py @@ -10,9 +10,15 @@ from ._version import VERSION __version__ = VERSION -__all__ = ['ResourceManagementClient'] -# `._patch.py` is used for handwritten extensions to the generated code -# Example: https://github.com/Azure/azure-sdk-for-python/blob/main/doc/dev/customize_code/how-to-patch-sdk-code.md -from ._patch import patch_sdk -patch_sdk() +try: + from ._patch import __all__ as _patch_all + from ._patch import * # type: ignore # pylint: disable=unused-wildcard-import +except ImportError: + _patch_all = [] +from ._patch import patch_sdk as _patch_sdk + +__all__ = ["ResourceManagementClient"] +__all__.extend([p for p in _patch_all if p not in __all__]) + +_patch_sdk() diff --git a/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/resources/v2020_10_01/_configuration.py b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/resources/v2020_10_01/_configuration.py index d33be3a62bcc6..ea26bdf0fadb6 100644 --- a/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/resources/v2020_10_01/_configuration.py +++ b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/resources/v2020_10_01/_configuration.py @@ -25,23 +25,18 @@ class ResourceManagementClientConfiguration(Configuration): # pylint: disable=t Note that all parameters used to create this instance are saved as instance attributes. - :param credential: Credential needed for the client to connect to Azure. + :param credential: Credential needed for the client to connect to Azure. Required. :type credential: ~azure.core.credentials.TokenCredential - :param subscription_id: The ID of the target subscription. + :param subscription_id: The ID of the target subscription. Required. :type subscription_id: str :keyword api_version: Api Version. Default value is "2020-10-01". Note that overriding this default value may result in unsupported behavior. :paramtype api_version: str """ - def __init__( - self, - credential: "TokenCredential", - subscription_id: str, - **kwargs: Any - ) -> None: + def __init__(self, credential: "TokenCredential", subscription_id: str, **kwargs: Any) -> None: super(ResourceManagementClientConfiguration, self).__init__(**kwargs) - api_version = kwargs.pop('api_version', "2020-10-01") # type: str + api_version = kwargs.pop("api_version", "2020-10-01") # type: str if credential is None: raise ValueError("Parameter 'credential' must not be None.") @@ -51,23 +46,24 @@ def __init__( self.credential = credential self.subscription_id = subscription_id self.api_version = api_version - self.credential_scopes = kwargs.pop('credential_scopes', ['https://management.azure.com/.default']) - kwargs.setdefault('sdk_moniker', 'mgmt-resource/{}'.format(VERSION)) + self.credential_scopes = kwargs.pop("credential_scopes", ["https://management.azure.com/.default"]) + kwargs.setdefault("sdk_moniker", "mgmt-resource/{}".format(VERSION)) self._configure(**kwargs) def _configure( - self, - **kwargs # type: Any + self, **kwargs # type: Any ): # type: (...) -> 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) - self.logging_policy = kwargs.get('logging_policy') or policies.NetworkTraceLoggingPolicy(**kwargs) - self.http_logging_policy = kwargs.get('http_logging_policy') or ARMHttpLoggingPolicy(**kwargs) - self.retry_policy = kwargs.get('retry_policy') or policies.RetryPolicy(**kwargs) - self.custom_hook_policy = kwargs.get('custom_hook_policy') or policies.CustomHookPolicy(**kwargs) - self.redirect_policy = kwargs.get('redirect_policy') or policies.RedirectPolicy(**kwargs) - self.authentication_policy = kwargs.get('authentication_policy') + 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) + self.logging_policy = kwargs.get("logging_policy") or policies.NetworkTraceLoggingPolicy(**kwargs) + self.http_logging_policy = kwargs.get("http_logging_policy") or ARMHttpLoggingPolicy(**kwargs) + self.retry_policy = kwargs.get("retry_policy") or policies.RetryPolicy(**kwargs) + self.custom_hook_policy = kwargs.get("custom_hook_policy") or policies.CustomHookPolicy(**kwargs) + self.redirect_policy = kwargs.get("redirect_policy") or policies.RedirectPolicy(**kwargs) + self.authentication_policy = kwargs.get("authentication_policy") if self.credential and not self.authentication_policy: - self.authentication_policy = ARMChallengeAuthenticationPolicy(self.credential, *self.credential_scopes, **kwargs) + self.authentication_policy = ARMChallengeAuthenticationPolicy( + self.credential, *self.credential_scopes, **kwargs + ) diff --git a/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/resources/v2020_10_01/_metadata.json b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/resources/v2020_10_01/_metadata.json index 630c6c03161f2..3d92ab4f87c38 100644 --- a/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/resources/v2020_10_01/_metadata.json +++ b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/resources/v2020_10_01/_metadata.json @@ -10,20 +10,20 @@ "azure_arm": true, "has_lro_operations": true, "client_side_validation": false, - "sync_imports": "{\"typing\": {\"azurecore\": {\"azure.core.credentials\": [\"TokenCredential\"]}}, \"regular\": {\"azurecore\": {\"azure.profiles\": [\"KnownProfiles\", \"ProfileDefinition\"], \"azure.profiles.multiapiclient\": [\"MultiApiClientMixin\"], \"azure.mgmt.core\": [\"ARMPipelineClient\"]}, \"local\": {\"._configuration\": [\"ResourceManagementClientConfiguration\"]}, \"thirdparty\": {\"msrest\": [\"Deserializer\", \"Serializer\"]}}, \"conditional\": {\"stdlib\": {\"typing\": [\"Any\", \"Optional\"]}}}", - "async_imports": "{\"typing\": {\"azurecore\": {\"azure.core.credentials_async\": [\"AsyncTokenCredential\"], \"azure.core.credentials\": [\"TokenCredential\"]}}, \"regular\": {\"azurecore\": {\"azure.profiles\": [\"KnownProfiles\", \"ProfileDefinition\"], \"azure.profiles.multiapiclient\": [\"MultiApiClientMixin\"], \"azure.mgmt.core\": [\"AsyncARMPipelineClient\"]}, \"local\": {\"._configuration\": [\"ResourceManagementClientConfiguration\"]}, \"thirdparty\": {\"msrest\": [\"Deserializer\", \"Serializer\"]}}, \"conditional\": {\"stdlib\": {\"typing\": [\"Any\", \"Optional\"]}}}" + "sync_imports": "{\"conditional\": {\"stdlib\": {\"typing\": [\"Any\", \"Optional\"]}}, \"regular\": {\"azurecore\": {\"azure.mgmt.core\": [\"ARMPipelineClient\"], \"azure.profiles\": [\"KnownProfiles\", \"ProfileDefinition\"], \"azure.profiles.multiapiclient\": [\"MultiApiClientMixin\"]}, \"local\": {\"._configuration\": [\"ResourceManagementClientConfiguration\"], \".._serialization\": [\"Deserializer\", \"Serializer\"]}}, \"typing\": {\"azurecore\": {\"azure.core.credentials\": [\"TokenCredential\"]}}}", + "async_imports": "{\"conditional\": {\"stdlib\": {\"typing\": [\"Any\", \"Optional\"]}}, \"regular\": {\"azurecore\": {\"azure.mgmt.core\": [\"AsyncARMPipelineClient\"], \"azure.profiles\": [\"KnownProfiles\", \"ProfileDefinition\"], \"azure.profiles.multiapiclient\": [\"MultiApiClientMixin\"]}, \"local\": {\"._configuration\": [\"ResourceManagementClientConfiguration\"], \"..._serialization\": [\"Deserializer\", \"Serializer\"]}}, \"typing\": {\"azurecore\": {\"azure.core.credentials_async\": [\"AsyncTokenCredential\"]}}}" }, "global_parameters": { "sync": { "credential": { - "signature": "credential, # type: \"TokenCredential\"", - "description": "Credential needed for the client to connect to Azure.", + "signature": "credential: \"TokenCredential\",", + "description": "Credential needed for the client to connect to Azure. Required.", "docstring_type": "~azure.core.credentials.TokenCredential", "required": true }, "subscription_id": { - "signature": "subscription_id, # type: str", - "description": "The ID of the target subscription.", + "signature": "subscription_id: str,", + "description": "The ID of the target subscription. Required.", "docstring_type": "str", "required": true } @@ -31,13 +31,13 @@ "async": { "credential": { "signature": "credential: \"AsyncTokenCredential\",", - "description": "Credential needed for the client to connect to Azure.", + "description": "Credential needed for the client to connect to Azure. Required.", "docstring_type": "~azure.core.credentials_async.AsyncTokenCredential", "required": true }, "subscription_id": { "signature": "subscription_id: str,", - "description": "The ID of the target subscription.", + "description": "The ID of the target subscription. Required.", "docstring_type": "str", "required": true } @@ -54,7 +54,7 @@ "required": false }, "base_url": { - "signature": "base_url=\"https://management.azure.com\", # type: str", + "signature": "base_url: str = \"https://management.azure.com\",", "description": "Service URL", "docstring_type": "str", "required": false diff --git a/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/resources/v2020_10_01/_patch.py b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/resources/v2020_10_01/_patch.py index 74e48ecd07cf3..f99e77fef9861 100644 --- a/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/resources/v2020_10_01/_patch.py +++ b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/resources/v2020_10_01/_patch.py @@ -28,4 +28,4 @@ # This file is used for handwritten extensions to the generated code. Example: # https://github.com/Azure/azure-sdk-for-python/blob/main/doc/dev/customize_code/how-to-patch-sdk-code.md def patch_sdk(): - pass \ No newline at end of file + pass diff --git a/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/resources/v2020_10_01/_resource_management_client.py b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/resources/v2020_10_01/_resource_management_client.py index d9dfec31a7750..ebcc913dbdf25 100644 --- a/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/resources/v2020_10_01/_resource_management_client.py +++ b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/resources/v2020_10_01/_resource_management_client.py @@ -9,20 +9,29 @@ from copy import deepcopy from typing import Any, TYPE_CHECKING -from msrest import Deserializer, Serializer - from azure.core.rest import HttpRequest, HttpResponse from azure.mgmt.core import ARMPipelineClient from . import models +from .._serialization import Deserializer, Serializer from ._configuration import ResourceManagementClientConfiguration -from .operations import DeploymentOperationsOperations, DeploymentsOperations, Operations, ProviderResourceTypesOperations, ProvidersOperations, ResourceGroupsOperations, ResourcesOperations, TagsOperations +from .operations import ( + DeploymentOperationsOperations, + DeploymentsOperations, + Operations, + ProviderResourceTypesOperations, + ProvidersOperations, + ResourceGroupsOperations, + ResourcesOperations, + TagsOperations, +) if TYPE_CHECKING: # pylint: disable=unused-import,ungrouped-imports from azure.core.credentials import TokenCredential -class ResourceManagementClient: # pylint: disable=too-many-instance-attributes + +class ResourceManagementClient: # pylint: disable=client-accepts-api-version-keyword,too-many-instance-attributes """Provides operations for working with resources and resource groups. :ivar operations: Operations operations @@ -45,9 +54,9 @@ class ResourceManagementClient: # pylint: disable=too-many-instance-attribute :ivar deployment_operations: DeploymentOperationsOperations operations :vartype deployment_operations: azure.mgmt.resource.resources.v2020_10_01.operations.DeploymentOperationsOperations - :param credential: Credential needed for the client to connect to Azure. + :param credential: Credential needed for the client to connect to Azure. Required. :type credential: ~azure.core.credentials.TokenCredential - :param subscription_id: The ID of the target subscription. + :param subscription_id: The ID of the target subscription. Required. :type subscription_id: str :param base_url: Service URL. Default value is "https://management.azure.com". :type base_url: str @@ -65,7 +74,9 @@ def __init__( base_url: str = "https://management.azure.com", **kwargs: Any ) -> None: - self._config = ResourceManagementClientConfiguration(credential=credential, subscription_id=subscription_id, **kwargs) + self._config = ResourceManagementClientConfiguration( + credential=credential, subscription_id=subscription_id, **kwargs + ) self._client = ARMPipelineClient(base_url=base_url, config=self._config, **kwargs) client_models = {k: v for k, v in models.__dict__.items() if isinstance(v, type)} @@ -75,18 +86,17 @@ def __init__( self.operations = Operations(self._client, self._config, self._serialize, self._deserialize) self.deployments = DeploymentsOperations(self._client, self._config, self._serialize, self._deserialize) self.providers = ProvidersOperations(self._client, self._config, self._serialize, self._deserialize) - self.provider_resource_types = ProviderResourceTypesOperations(self._client, self._config, self._serialize, self._deserialize) + self.provider_resource_types = ProviderResourceTypesOperations( + self._client, self._config, self._serialize, self._deserialize + ) self.resources = ResourcesOperations(self._client, self._config, self._serialize, self._deserialize) self.resource_groups = ResourceGroupsOperations(self._client, self._config, self._serialize, self._deserialize) self.tags = TagsOperations(self._client, self._config, self._serialize, self._deserialize) - self.deployment_operations = DeploymentOperationsOperations(self._client, self._config, self._serialize, self._deserialize) - + self.deployment_operations = DeploymentOperationsOperations( + self._client, self._config, self._serialize, self._deserialize + ) - def _send_request( - self, - request: HttpRequest, - **kwargs: Any - ) -> HttpResponse: + def _send_request(self, request: HttpRequest, **kwargs: Any) -> HttpResponse: """Runs the network request through the client's chained policies. >>> from azure.core.rest import HttpRequest @@ -95,7 +105,7 @@ def _send_request( >>> response = client._send_request(request) - For more information on this code flow, see https://aka.ms/azsdk/python/protocol/quickstart + For more information on this code flow, see https://aka.ms/azsdk/dpcodegen/python/send_request :param request: The network request you want to make. Required. :type request: ~azure.core.rest.HttpRequest diff --git a/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/resources/v2020_10_01/_vendor.py b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/resources/v2020_10_01/_vendor.py index 138f663c53a4e..9aad73fc743e7 100644 --- a/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/resources/v2020_10_01/_vendor.py +++ b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/resources/v2020_10_01/_vendor.py @@ -7,6 +7,7 @@ from azure.core.pipeline.transport import HttpRequest + def _convert_request(request, files=None): data = request.content if not files else None request = HttpRequest(method=request.method, url=request.url, headers=request.headers, data=data) @@ -14,6 +15,7 @@ def _convert_request(request, files=None): request.set_formdata_body(files) return request + def _format_url_section(template, **kwargs): components = template.split("/") while components: @@ -21,7 +23,5 @@ def _format_url_section(template, **kwargs): 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 - ] + components = [c for c in formatted_components if "{}".format(key.args[0]) not in c] template = "/".join(components) diff --git a/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/resources/v2020_10_01/_version.py b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/resources/v2020_10_01/_version.py index a012ac01c480c..e5754a47ce68f 100644 --- a/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/resources/v2020_10_01/_version.py +++ b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/resources/v2020_10_01/_version.py @@ -6,4 +6,4 @@ # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -VERSION = "21.1.0" +VERSION = "1.0.0b1" diff --git a/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/resources/v2020_10_01/aio/__init__.py b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/resources/v2020_10_01/aio/__init__.py index c6c3cf64a37a6..98d6782c2530c 100644 --- a/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/resources/v2020_10_01/aio/__init__.py +++ b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/resources/v2020_10_01/aio/__init__.py @@ -7,9 +7,15 @@ # -------------------------------------------------------------------------- from ._resource_management_client import ResourceManagementClient -__all__ = ['ResourceManagementClient'] -# `._patch.py` is used for handwritten extensions to the generated code -# Example: https://github.com/Azure/azure-sdk-for-python/blob/main/doc/dev/customize_code/how-to-patch-sdk-code.md -from ._patch import patch_sdk -patch_sdk() +try: + from ._patch import __all__ as _patch_all + from ._patch import * # type: ignore # pylint: disable=unused-wildcard-import +except ImportError: + _patch_all = [] +from ._patch import patch_sdk as _patch_sdk + +__all__ = ["ResourceManagementClient"] +__all__.extend([p for p in _patch_all if p not in __all__]) + +_patch_sdk() diff --git a/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/resources/v2020_10_01/aio/_configuration.py b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/resources/v2020_10_01/aio/_configuration.py index a6deef006520e..6686d9725eafd 100644 --- a/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/resources/v2020_10_01/aio/_configuration.py +++ b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/resources/v2020_10_01/aio/_configuration.py @@ -25,23 +25,18 @@ class ResourceManagementClientConfiguration(Configuration): # pylint: disable=t Note that all parameters used to create this instance are saved as instance attributes. - :param credential: Credential needed for the client to connect to Azure. + :param credential: Credential needed for the client to connect to Azure. Required. :type credential: ~azure.core.credentials_async.AsyncTokenCredential - :param subscription_id: The ID of the target subscription. + :param subscription_id: The ID of the target subscription. Required. :type subscription_id: str :keyword api_version: Api Version. Default value is "2020-10-01". Note that overriding this default value may result in unsupported behavior. :paramtype api_version: str """ - def __init__( - self, - credential: "AsyncTokenCredential", - subscription_id: str, - **kwargs: Any - ) -> None: + def __init__(self, credential: "AsyncTokenCredential", subscription_id: str, **kwargs: Any) -> None: super(ResourceManagementClientConfiguration, self).__init__(**kwargs) - api_version = kwargs.pop('api_version', "2020-10-01") # type: str + api_version = kwargs.pop("api_version", "2020-10-01") # type: str if credential is None: raise ValueError("Parameter 'credential' must not be None.") @@ -51,22 +46,21 @@ def __init__( self.credential = credential self.subscription_id = subscription_id self.api_version = api_version - self.credential_scopes = kwargs.pop('credential_scopes', ['https://management.azure.com/.default']) - kwargs.setdefault('sdk_moniker', 'mgmt-resource/{}'.format(VERSION)) + self.credential_scopes = kwargs.pop("credential_scopes", ["https://management.azure.com/.default"]) + kwargs.setdefault("sdk_moniker", "mgmt-resource/{}".format(VERSION)) self._configure(**kwargs) - 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) - self.logging_policy = kwargs.get('logging_policy') or policies.NetworkTraceLoggingPolicy(**kwargs) - self.http_logging_policy = kwargs.get('http_logging_policy') or ARMHttpLoggingPolicy(**kwargs) - self.retry_policy = kwargs.get('retry_policy') or policies.AsyncRetryPolicy(**kwargs) - self.custom_hook_policy = kwargs.get('custom_hook_policy') or policies.CustomHookPolicy(**kwargs) - self.redirect_policy = kwargs.get('redirect_policy') or policies.AsyncRedirectPolicy(**kwargs) - self.authentication_policy = kwargs.get('authentication_policy') + 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) + self.logging_policy = kwargs.get("logging_policy") or policies.NetworkTraceLoggingPolicy(**kwargs) + self.http_logging_policy = kwargs.get("http_logging_policy") or ARMHttpLoggingPolicy(**kwargs) + self.retry_policy = kwargs.get("retry_policy") or policies.AsyncRetryPolicy(**kwargs) + self.custom_hook_policy = kwargs.get("custom_hook_policy") or policies.CustomHookPolicy(**kwargs) + self.redirect_policy = kwargs.get("redirect_policy") or policies.AsyncRedirectPolicy(**kwargs) + self.authentication_policy = kwargs.get("authentication_policy") if self.credential and not self.authentication_policy: - self.authentication_policy = AsyncARMChallengeAuthenticationPolicy(self.credential, *self.credential_scopes, **kwargs) + self.authentication_policy = AsyncARMChallengeAuthenticationPolicy( + self.credential, *self.credential_scopes, **kwargs + ) diff --git a/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/resources/v2020_10_01/aio/_patch.py b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/resources/v2020_10_01/aio/_patch.py index 74e48ecd07cf3..f99e77fef9861 100644 --- a/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/resources/v2020_10_01/aio/_patch.py +++ b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/resources/v2020_10_01/aio/_patch.py @@ -28,4 +28,4 @@ # This file is used for handwritten extensions to the generated code. Example: # https://github.com/Azure/azure-sdk-for-python/blob/main/doc/dev/customize_code/how-to-patch-sdk-code.md def patch_sdk(): - pass \ No newline at end of file + pass diff --git a/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/resources/v2020_10_01/aio/_resource_management_client.py b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/resources/v2020_10_01/aio/_resource_management_client.py index afface0d1d5b3..d6d2ae456fd71 100644 --- a/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/resources/v2020_10_01/aio/_resource_management_client.py +++ b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/resources/v2020_10_01/aio/_resource_management_client.py @@ -9,20 +9,29 @@ from copy import deepcopy from typing import Any, Awaitable, TYPE_CHECKING -from msrest import Deserializer, Serializer - from azure.core.rest import AsyncHttpResponse, HttpRequest from azure.mgmt.core import AsyncARMPipelineClient from .. import models +from ..._serialization import Deserializer, Serializer from ._configuration import ResourceManagementClientConfiguration -from .operations import DeploymentOperationsOperations, DeploymentsOperations, Operations, ProviderResourceTypesOperations, ProvidersOperations, ResourceGroupsOperations, ResourcesOperations, TagsOperations +from .operations import ( + DeploymentOperationsOperations, + DeploymentsOperations, + Operations, + ProviderResourceTypesOperations, + ProvidersOperations, + ResourceGroupsOperations, + ResourcesOperations, + TagsOperations, +) if TYPE_CHECKING: # pylint: disable=unused-import,ungrouped-imports from azure.core.credentials_async import AsyncTokenCredential -class ResourceManagementClient: # pylint: disable=too-many-instance-attributes + +class ResourceManagementClient: # pylint: disable=client-accepts-api-version-keyword,too-many-instance-attributes """Provides operations for working with resources and resource groups. :ivar operations: Operations operations @@ -47,9 +56,9 @@ class ResourceManagementClient: # pylint: disable=too-many-instance-attribute :ivar deployment_operations: DeploymentOperationsOperations operations :vartype deployment_operations: azure.mgmt.resource.resources.v2020_10_01.aio.operations.DeploymentOperationsOperations - :param credential: Credential needed for the client to connect to Azure. + :param credential: Credential needed for the client to connect to Azure. Required. :type credential: ~azure.core.credentials_async.AsyncTokenCredential - :param subscription_id: The ID of the target subscription. + :param subscription_id: The ID of the target subscription. Required. :type subscription_id: str :param base_url: Service URL. Default value is "https://management.azure.com". :type base_url: str @@ -67,7 +76,9 @@ def __init__( base_url: str = "https://management.azure.com", **kwargs: Any ) -> None: - self._config = ResourceManagementClientConfiguration(credential=credential, subscription_id=subscription_id, **kwargs) + self._config = ResourceManagementClientConfiguration( + credential=credential, subscription_id=subscription_id, **kwargs + ) self._client = AsyncARMPipelineClient(base_url=base_url, config=self._config, **kwargs) client_models = {k: v for k, v in models.__dict__.items() if isinstance(v, type)} @@ -77,18 +88,17 @@ def __init__( self.operations = Operations(self._client, self._config, self._serialize, self._deserialize) self.deployments = DeploymentsOperations(self._client, self._config, self._serialize, self._deserialize) self.providers = ProvidersOperations(self._client, self._config, self._serialize, self._deserialize) - self.provider_resource_types = ProviderResourceTypesOperations(self._client, self._config, self._serialize, self._deserialize) + self.provider_resource_types = ProviderResourceTypesOperations( + self._client, self._config, self._serialize, self._deserialize + ) self.resources = ResourcesOperations(self._client, self._config, self._serialize, self._deserialize) self.resource_groups = ResourceGroupsOperations(self._client, self._config, self._serialize, self._deserialize) self.tags = TagsOperations(self._client, self._config, self._serialize, self._deserialize) - self.deployment_operations = DeploymentOperationsOperations(self._client, self._config, self._serialize, self._deserialize) - + self.deployment_operations = DeploymentOperationsOperations( + self._client, self._config, self._serialize, self._deserialize + ) - def _send_request( - self, - request: HttpRequest, - **kwargs: Any - ) -> Awaitable[AsyncHttpResponse]: + def _send_request(self, request: HttpRequest, **kwargs: Any) -> Awaitable[AsyncHttpResponse]: """Runs the network request through the client's chained policies. >>> from azure.core.rest import HttpRequest @@ -97,7 +107,7 @@ def _send_request( >>> response = await client._send_request(request) - For more information on this code flow, see https://aka.ms/azsdk/python/protocol/quickstart + For more information on this code flow, see https://aka.ms/azsdk/dpcodegen/python/send_request :param request: The network request you want to make. Required. :type request: ~azure.core.rest.HttpRequest diff --git a/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/resources/v2020_10_01/aio/operations/__init__.py b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/resources/v2020_10_01/aio/operations/__init__.py index f1487609817b6..9e5620e4d286c 100644 --- a/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/resources/v2020_10_01/aio/operations/__init__.py +++ b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/resources/v2020_10_01/aio/operations/__init__.py @@ -15,13 +15,19 @@ from ._operations import TagsOperations from ._operations import DeploymentOperationsOperations +from ._patch import __all__ as _patch_all +from ._patch import * # type: ignore # pylint: disable=unused-wildcard-import +from ._patch import patch_sdk as _patch_sdk + __all__ = [ - 'Operations', - 'DeploymentsOperations', - 'ProvidersOperations', - 'ProviderResourceTypesOperations', - 'ResourcesOperations', - 'ResourceGroupsOperations', - 'TagsOperations', - 'DeploymentOperationsOperations', + "Operations", + "DeploymentsOperations", + "ProvidersOperations", + "ProviderResourceTypesOperations", + "ResourcesOperations", + "ResourceGroupsOperations", + "TagsOperations", + "DeploymentOperationsOperations", ] +__all__.extend([p for p in _patch_all if p not in __all__]) +_patch_sdk() diff --git a/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/resources/v2020_10_01/aio/operations/_operations.py b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/resources/v2020_10_01/aio/operations/_operations.py index 56ff1d61ffb88..8dcdf71ad6586 100644 --- a/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/resources/v2020_10_01/aio/operations/_operations.py +++ b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/resources/v2020_10_01/aio/operations/_operations.py @@ -6,84 +6,200 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -from typing import Any, AsyncIterable, Callable, Dict, Optional, TypeVar, Union +import sys +from typing import Any, AsyncIterable, Callable, Dict, IO, Optional, TypeVar, Union, cast, overload +from urllib.parse import parse_qs, urljoin, urlparse from azure.core.async_paging import AsyncItemPaged, AsyncList -from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error +from azure.core.exceptions import ( + ClientAuthenticationError, + HttpResponseError, + ResourceExistsError, + ResourceNotFoundError, + ResourceNotModifiedError, + map_error, +) from azure.core.pipeline import PipelineResponse from azure.core.pipeline.transport import AsyncHttpResponse from azure.core.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 from azure.mgmt.core.polling.async_arm_polling import AsyncARMPolling from ... import models as _models from ..._vendor import _convert_request -from ...operations._operations import build_deployment_operations_get_at_management_group_scope_request, build_deployment_operations_get_at_scope_request, build_deployment_operations_get_at_subscription_scope_request, build_deployment_operations_get_at_tenant_scope_request, build_deployment_operations_get_request, build_deployment_operations_list_at_management_group_scope_request, build_deployment_operations_list_at_scope_request, build_deployment_operations_list_at_subscription_scope_request, build_deployment_operations_list_at_tenant_scope_request, build_deployment_operations_list_request, build_deployments_calculate_template_hash_request, build_deployments_cancel_at_management_group_scope_request, build_deployments_cancel_at_scope_request, build_deployments_cancel_at_subscription_scope_request, build_deployments_cancel_at_tenant_scope_request, build_deployments_cancel_request, build_deployments_check_existence_at_management_group_scope_request, build_deployments_check_existence_at_scope_request, build_deployments_check_existence_at_subscription_scope_request, build_deployments_check_existence_at_tenant_scope_request, build_deployments_check_existence_request, build_deployments_create_or_update_at_management_group_scope_request_initial, build_deployments_create_or_update_at_scope_request_initial, build_deployments_create_or_update_at_subscription_scope_request_initial, build_deployments_create_or_update_at_tenant_scope_request_initial, build_deployments_create_or_update_request_initial, build_deployments_delete_at_management_group_scope_request_initial, build_deployments_delete_at_scope_request_initial, build_deployments_delete_at_subscription_scope_request_initial, build_deployments_delete_at_tenant_scope_request_initial, build_deployments_delete_request_initial, build_deployments_export_template_at_management_group_scope_request, build_deployments_export_template_at_scope_request, build_deployments_export_template_at_subscription_scope_request, build_deployments_export_template_at_tenant_scope_request, build_deployments_export_template_request, build_deployments_get_at_management_group_scope_request, build_deployments_get_at_scope_request, build_deployments_get_at_subscription_scope_request, build_deployments_get_at_tenant_scope_request, build_deployments_get_request, build_deployments_list_at_management_group_scope_request, build_deployments_list_at_scope_request, build_deployments_list_at_subscription_scope_request, build_deployments_list_at_tenant_scope_request, build_deployments_list_by_resource_group_request, build_deployments_validate_at_management_group_scope_request_initial, build_deployments_validate_at_scope_request_initial, build_deployments_validate_at_subscription_scope_request_initial, build_deployments_validate_at_tenant_scope_request_initial, build_deployments_validate_request_initial, build_deployments_what_if_at_management_group_scope_request_initial, build_deployments_what_if_at_subscription_scope_request_initial, build_deployments_what_if_at_tenant_scope_request_initial, build_deployments_what_if_request_initial, build_operations_list_request, build_provider_resource_types_list_request, build_providers_get_at_tenant_scope_request, build_providers_get_request, build_providers_list_at_tenant_scope_request, build_providers_list_request, build_providers_register_at_management_group_scope_request, build_providers_register_request, build_providers_unregister_request, build_resource_groups_check_existence_request, build_resource_groups_create_or_update_request, build_resource_groups_delete_request_initial, build_resource_groups_export_template_request_initial, build_resource_groups_get_request, build_resource_groups_list_request, build_resource_groups_update_request, build_resources_check_existence_by_id_request, build_resources_check_existence_request, build_resources_create_or_update_by_id_request_initial, build_resources_create_or_update_request_initial, build_resources_delete_by_id_request_initial, build_resources_delete_request_initial, build_resources_get_by_id_request, build_resources_get_request, build_resources_list_by_resource_group_request, build_resources_list_request, build_resources_move_resources_request_initial, build_resources_update_by_id_request_initial, build_resources_update_request_initial, build_resources_validate_move_resources_request_initial, build_tags_create_or_update_at_scope_request, build_tags_create_or_update_request, build_tags_create_or_update_value_request, build_tags_delete_at_scope_request, build_tags_delete_request, build_tags_delete_value_request, build_tags_get_at_scope_request, build_tags_list_request, build_tags_update_at_scope_request -T = TypeVar('T') +from ...operations._operations import ( + build_deployment_operations_get_at_management_group_scope_request, + build_deployment_operations_get_at_scope_request, + build_deployment_operations_get_at_subscription_scope_request, + build_deployment_operations_get_at_tenant_scope_request, + build_deployment_operations_get_request, + build_deployment_operations_list_at_management_group_scope_request, + build_deployment_operations_list_at_scope_request, + build_deployment_operations_list_at_subscription_scope_request, + build_deployment_operations_list_at_tenant_scope_request, + build_deployment_operations_list_request, + build_deployments_calculate_template_hash_request, + build_deployments_cancel_at_management_group_scope_request, + build_deployments_cancel_at_scope_request, + build_deployments_cancel_at_subscription_scope_request, + build_deployments_cancel_at_tenant_scope_request, + build_deployments_cancel_request, + build_deployments_check_existence_at_management_group_scope_request, + build_deployments_check_existence_at_scope_request, + build_deployments_check_existence_at_subscription_scope_request, + build_deployments_check_existence_at_tenant_scope_request, + build_deployments_check_existence_request, + build_deployments_create_or_update_at_management_group_scope_request, + build_deployments_create_or_update_at_scope_request, + build_deployments_create_or_update_at_subscription_scope_request, + build_deployments_create_or_update_at_tenant_scope_request, + build_deployments_create_or_update_request, + build_deployments_delete_at_management_group_scope_request, + build_deployments_delete_at_scope_request, + build_deployments_delete_at_subscription_scope_request, + build_deployments_delete_at_tenant_scope_request, + build_deployments_delete_request, + build_deployments_export_template_at_management_group_scope_request, + build_deployments_export_template_at_scope_request, + build_deployments_export_template_at_subscription_scope_request, + build_deployments_export_template_at_tenant_scope_request, + build_deployments_export_template_request, + build_deployments_get_at_management_group_scope_request, + build_deployments_get_at_scope_request, + build_deployments_get_at_subscription_scope_request, + build_deployments_get_at_tenant_scope_request, + build_deployments_get_request, + build_deployments_list_at_management_group_scope_request, + build_deployments_list_at_scope_request, + build_deployments_list_at_subscription_scope_request, + build_deployments_list_at_tenant_scope_request, + build_deployments_list_by_resource_group_request, + build_deployments_validate_at_management_group_scope_request, + build_deployments_validate_at_scope_request, + build_deployments_validate_at_subscription_scope_request, + build_deployments_validate_at_tenant_scope_request, + build_deployments_validate_request, + build_deployments_what_if_at_management_group_scope_request, + build_deployments_what_if_at_subscription_scope_request, + build_deployments_what_if_at_tenant_scope_request, + build_deployments_what_if_request, + build_operations_list_request, + build_provider_resource_types_list_request, + build_providers_get_at_tenant_scope_request, + build_providers_get_request, + build_providers_list_at_tenant_scope_request, + build_providers_list_request, + build_providers_register_at_management_group_scope_request, + build_providers_register_request, + build_providers_unregister_request, + build_resource_groups_check_existence_request, + build_resource_groups_create_or_update_request, + build_resource_groups_delete_request, + build_resource_groups_export_template_request, + build_resource_groups_get_request, + build_resource_groups_list_request, + build_resource_groups_update_request, + build_resources_check_existence_by_id_request, + build_resources_check_existence_request, + build_resources_create_or_update_by_id_request, + build_resources_create_or_update_request, + build_resources_delete_by_id_request, + build_resources_delete_request, + build_resources_get_by_id_request, + build_resources_get_request, + build_resources_list_by_resource_group_request, + build_resources_list_request, + build_resources_move_resources_request, + build_resources_update_by_id_request, + build_resources_update_request, + build_resources_validate_move_resources_request, + build_tags_create_or_update_at_scope_request, + build_tags_create_or_update_request, + build_tags_create_or_update_value_request, + build_tags_delete_at_scope_request, + build_tags_delete_request, + build_tags_delete_value_request, + build_tags_get_at_scope_request, + build_tags_list_request, + build_tags_update_at_scope_request, +) + +T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] +if sys.version_info >= (3, 9): + from collections.abc import MutableMapping +else: + from typing import MutableMapping # type: ignore # pylint: disable=ungrouped-imports +JSON = MutableMapping[str, Any] # pylint: disable=unsubscriptable-object -class Operations: - """Operations async operations. - You should not instantiate this class directly. Instead, you should create a Client instance that - instantiates it for you and attaches it as an attribute. +class Operations: + """ + .. warning:: + **DO NOT** instantiate this class directly. - :ivar models: Alias to model classes used in this operation group. - :type models: ~azure.mgmt.resource.resources.v2020_10_01.models - :param client: Client for service requests. - :param config: Configuration of service client. - :param serializer: An object model serializer. - :param deserializer: An object model deserializer. + Instead, you should access the following operations through + :class:`~azure.mgmt.resource.resources.v2020_10_01.aio.ResourceManagementClient`'s + :attr:`operations` attribute. """ models = _models - def __init__(self, client, config, serializer, deserializer) -> None: - self._client = client - self._serialize = serializer - self._deserialize = deserializer - self._config = config + def __init__(self, *args, **kwargs) -> None: + input_args = list(args) + self._client = input_args.pop(0) if input_args else kwargs.pop("client") + self._config = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") @distributed_trace - def list( - self, - **kwargs: Any - ) -> AsyncIterable["_models.OperationListResult"]: + def list(self, **kwargs: Any) -> AsyncIterable["_models.Operation"]: """Lists all of the available Microsoft.Resources REST API operations. :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either OperationListResult or the result of cls(response) + :return: An iterator like instance of either Operation or the result of cls(response) :rtype: - ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.resource.resources.v2020_10_01.models.OperationListResult] - :raises: ~azure.core.exceptions.HttpResponseError + ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.resource.resources.v2020_10_01.models.Operation] + :raises ~azure.core.exceptions.HttpResponseError: """ - api_version = kwargs.pop('api_version', "2020-10-01") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2020-10-01")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[_models.OperationListResult] - cls = kwargs.pop('cls', None) # type: ClsType["_models.OperationListResult"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) + def prepare_request(next_link=None): if not next_link: - + request = build_operations_list_request( api_version=api_version, - template_url=self.list.metadata['url'], + template_url=self.list.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore else: - - request = build_operations_list_request( - template_url=next_link, - ) + # make call to next link with the client's api-version + _parsed_next_link = urlparse(next_link) + _next_request_params = case_insensitive_dict(parse_qs(_parsed_next_link.query)) + _next_request_params["api-version"] = self._config.api_version + request = HttpRequest("GET", urljoin(next_link, _parsed_next_link.path), params=_next_request_params) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore request.method = "GET" return request @@ -97,10 +213,8 @@ async def extract_data(pipeline_response): async def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) response = pipeline_response.http_response @@ -110,62 +224,62 @@ async def get_next(next_link=None): return pipeline_response + return AsyncItemPaged(get_next, extract_data) - return AsyncItemPaged( - get_next, extract_data - ) - list.metadata = {'url': "/providers/Microsoft.Resources/operations"} # type: ignore -class DeploymentsOperations: # pylint: disable=too-many-public-methods - """DeploymentsOperations async operations. + list.metadata = {"url": "/providers/Microsoft.Resources/operations"} # type: ignore - You should not instantiate this class directly. Instead, you should create a Client instance that - instantiates it for you and attaches it as an attribute. - :ivar models: Alias to model classes used in this operation group. - :type models: ~azure.mgmt.resource.resources.v2020_10_01.models - :param client: Client for service requests. - :param config: Configuration of service client. - :param serializer: An object model serializer. - :param deserializer: An object model deserializer. +class DeploymentsOperations: # pylint: disable=too-many-public-methods + """ + .. warning:: + **DO NOT** instantiate this class directly. + + Instead, you should access the following operations through + :class:`~azure.mgmt.resource.resources.v2020_10_01.aio.ResourceManagementClient`'s + :attr:`deployments` attribute. """ models = _models - def __init__(self, client, config, serializer, deserializer) -> None: - self._client = client - self._serialize = serializer - self._deserialize = deserializer - self._config = config + def __init__(self, *args, **kwargs) -> None: + input_args = list(args) + self._client = input_args.pop(0) if input_args else kwargs.pop("client") + self._config = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") async def _delete_at_scope_initial( # pylint: disable=inconsistent-return-statements - self, - scope: str, - deployment_name: str, - **kwargs: Any + self, scope: str, deployment_name: str, **kwargs: Any ) -> None: - cls = kwargs.pop('cls', None) # type: ClsType[None] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + 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', "2020-10-01") # type: str + api_version = kwargs.pop("api_version", _params.pop("api-version", "2020-10-01")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[None] - - request = build_deployments_delete_at_scope_request_initial( + request = build_deployments_delete_at_scope_request( scope=scope, deployment_name=deployment_name, api_version=api_version, - template_url=self._delete_at_scope_initial.metadata['url'], + template_url=self._delete_at_scope_initial.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [202, 204]: @@ -175,16 +289,10 @@ async def _delete_at_scope_initial( # pylint: disable=inconsistent-return-state if cls: return cls(pipeline_response, None, {}) - _delete_at_scope_initial.metadata = {'url': "/{scope}/providers/Microsoft.Resources/deployments/{deploymentName}"} # type: ignore - + _delete_at_scope_initial.metadata = {"url": "/{scope}/providers/Microsoft.Resources/deployments/{deploymentName}"} # type: ignore @distributed_trace_async - async def begin_delete_at_scope( # pylint: disable=inconsistent-return-statements - self, - scope: str, - deployment_name: str, - **kwargs: Any - ) -> AsyncLROPoller[None]: + async def begin_delete_at_scope(self, scope: str, deployment_name: str, **kwargs: Any) -> AsyncLROPoller[None]: """Deletes a deployment from the deployment history. A template deployment that is currently running cannot be deleted. Deleting a template @@ -195,9 +303,9 @@ async def begin_delete_at_scope( # pylint: disable=inconsistent-return-statemen process finishes, the URI in the Location header returns a status of 204 on success. If the asynchronous request failed, the URI in the Location header returns an error-level status code. - :param scope: The resource scope. + :param scope: The resource scope. Required. :type scope: str - :param deployment_name: The name of the deployment. + :param deployment_name: The name of the deployment. Required. :type deployment_name: str :keyword callable cls: A custom type or function that will be passed the direct response :keyword str continuation_token: A continuation token to restart a poller from a saved state. @@ -209,86 +317,91 @@ async def begin_delete_at_scope( # pylint: disable=inconsistent-return-statemen Retry-After header is present. :return: An instance of AsyncLROPoller that returns either None or the result of cls(response) :rtype: ~azure.core.polling.AsyncLROPoller[None] - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - api_version = kwargs.pop('api_version', "2020-10-01") # type: str - polling = kwargs.pop('polling', True) # type: Union[bool, AsyncPollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType[None] - lro_delay = kwargs.pop( - 'polling_interval', - self._config.polling_interval - ) - cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2020-10-01")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[None] + polling = kwargs.pop("polling", True) # type: Union[bool, AsyncPollingMethod] + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token = kwargs.pop("continuation_token", None) # type: Optional[str] if cont_token is None: - raw_result = await self._delete_at_scope_initial( + raw_result = await self._delete_at_scope_initial( # type: ignore scope=scope, deployment_name=deployment_name, api_version=api_version, - cls=lambda x,y,z: x, + cls=lambda x, y, z: x, + headers=_headers, + params=_params, **kwargs ) - kwargs.pop('error_map', None) + kwargs.pop("error_map", None) - def get_long_running_output(pipeline_response): + def get_long_running_output(pipeline_response): # pylint: disable=inconsistent-return-statements if cls: return cls(pipeline_response, None, {}) - - if polling is True: polling_method = AsyncARMPolling(lro_delay, **kwargs) - elif polling is False: polling_method = AsyncNoPolling() - else: polling_method = polling + if polling is True: + polling_method = cast(AsyncPollingMethod, AsyncARMPolling(lro_delay, **kwargs)) # type: AsyncPollingMethod + elif polling is False: + polling_method = cast(AsyncPollingMethod, AsyncNoPolling()) + else: + polling_method = polling if cont_token: return AsyncLROPoller.from_continuation_token( polling_method=polling_method, continuation_token=cont_token, client=self._client, - deserialization_callback=get_long_running_output + deserialization_callback=get_long_running_output, ) return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) - begin_delete_at_scope.metadata = {'url': "/{scope}/providers/Microsoft.Resources/deployments/{deploymentName}"} # type: ignore + begin_delete_at_scope.metadata = {"url": "/{scope}/providers/Microsoft.Resources/deployments/{deploymentName}"} # type: ignore @distributed_trace_async - async def check_existence_at_scope( - self, - scope: str, - deployment_name: str, - **kwargs: Any - ) -> bool: + async def check_existence_at_scope(self, scope: str, deployment_name: str, **kwargs: Any) -> bool: """Checks whether the deployment exists. - :param scope: The resource scope. + :param scope: The resource scope. Required. :type scope: str - :param deployment_name: The name of the deployment. + :param deployment_name: The name of the deployment. Required. :type deployment_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: bool, or the result of cls(response) + :return: bool or the result of cls(response) :rtype: bool - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType[None] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + 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', "2020-10-01") # type: str + api_version = kwargs.pop("api_version", _params.pop("api-version", "2020-10-01")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[None] - request = build_deployments_check_existence_at_scope_request( scope=scope, deployment_name=deployment_name, api_version=api_version, - template_url=self.check_existence_at_scope.metadata['url'], + template_url=self.check_existence_at_scope.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [204, 404]: @@ -299,43 +412,52 @@ async def check_existence_at_scope( return cls(pipeline_response, None, {}) return 200 <= response.status_code <= 299 - check_existence_at_scope.metadata = {'url': "/{scope}/providers/Microsoft.Resources/deployments/{deploymentName}"} # type: ignore - + check_existence_at_scope.metadata = {"url": "/{scope}/providers/Microsoft.Resources/deployments/{deploymentName}"} # type: ignore async def _create_or_update_at_scope_initial( - self, - scope: str, - deployment_name: str, - parameters: "_models.Deployment", - **kwargs: Any - ) -> "_models.DeploymentExtended": - cls = kwargs.pop('cls', None) # type: ClsType["_models.DeploymentExtended"] + self, scope: str, deployment_name: str, parameters: Union[_models.Deployment, IO], **kwargs: Any + ) -> _models.DeploymentExtended: error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) - api_version = kwargs.pop('api_version', "2020-10-01") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - _json = self._serialize.body(parameters, 'Deployment') + api_version = kwargs.pop("api_version", _params.pop("api-version", "2020-10-01")) # type: str + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.DeploymentExtended] - request = build_deployments_create_or_update_at_scope_request_initial( + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(parameters, (IO, bytes)): + _content = parameters + else: + _json = self._serialize.body(parameters, "Deployment") + + request = build_deployments_create_or_update_at_scope_request( scope=scope, deployment_name=deployment_name, api_version=api_version, content_type=content_type, json=_json, - template_url=self._create_or_update_at_scope_initial.metadata['url'], + content=_content, + template_url=self._create_or_update_at_scope_initial.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200, 201]: @@ -343,37 +465,41 @@ async def _create_or_update_at_scope_initial( raise HttpResponseError(response=response, error_format=ARMErrorFormat) if response.status_code == 200: - deserialized = self._deserialize('DeploymentExtended', pipeline_response) + deserialized = self._deserialize("DeploymentExtended", pipeline_response) if response.status_code == 201: - deserialized = self._deserialize('DeploymentExtended', pipeline_response) + deserialized = self._deserialize("DeploymentExtended", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - _create_or_update_at_scope_initial.metadata = {'url': "/{scope}/providers/Microsoft.Resources/deployments/{deploymentName}"} # type: ignore + _create_or_update_at_scope_initial.metadata = {"url": "/{scope}/providers/Microsoft.Resources/deployments/{deploymentName}"} # type: ignore - - @distributed_trace_async + @overload async def begin_create_or_update_at_scope( self, scope: str, deployment_name: str, - parameters: "_models.Deployment", + parameters: _models.Deployment, + *, + content_type: str = "application/json", **kwargs: Any - ) -> AsyncLROPoller["_models.DeploymentExtended"]: + ) -> AsyncLROPoller[_models.DeploymentExtended]: """Deploys resources at a given scope. You can provide the template and parameters directly in the request or link to JSON files. - :param scope: The resource scope. + :param scope: The resource scope. Required. :type scope: str - :param deployment_name: The name of the deployment. + :param deployment_name: The name of the deployment. Required. :type deployment_name: str - :param parameters: Additional parameters supplied to the operation. + :param parameters: Additional parameters supplied to the operation. Required. :type parameters: ~azure.mgmt.resource.resources.v2020_10_01.models.Deployment + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str :keyword callable cls: A custom type or function that will be passed the direct response :keyword str continuation_token: A continuation token to restart a poller from a saved state. :keyword polling: By default, your polling method will be AsyncARMPolling. Pass in False for @@ -386,114 +512,179 @@ async def begin_create_or_update_at_scope( cls(response) :rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.resource.resources.v2020_10_01.models.DeploymentExtended] - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - api_version = kwargs.pop('api_version', "2020-10-01") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] - polling = kwargs.pop('polling', True) # type: Union[bool, AsyncPollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType["_models.DeploymentExtended"] - lro_delay = kwargs.pop( - 'polling_interval', - self._config.polling_interval - ) - cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] + + @overload + async def begin_create_or_update_at_scope( + self, scope: str, deployment_name: str, parameters: IO, *, content_type: str = "application/json", **kwargs: Any + ) -> AsyncLROPoller[_models.DeploymentExtended]: + """Deploys resources at a given scope. + + You can provide the template and parameters directly in the request or link to JSON files. + + :param scope: The resource scope. Required. + :type scope: str + :param deployment_name: The name of the deployment. Required. + :type deployment_name: str + :param parameters: Additional parameters supplied to the operation. Required. + :type parameters: IO + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be AsyncARMPolling. Pass in False for + this operation to not poll, or pass in your own initialized polling object for a personal + polling strategy. + :paramtype polling: bool or ~azure.core.polling.AsyncPollingMethod + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of AsyncLROPoller that returns either DeploymentExtended or the result of + cls(response) + :rtype: + ~azure.core.polling.AsyncLROPoller[~azure.mgmt.resource.resources.v2020_10_01.models.DeploymentExtended] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace_async + async def begin_create_or_update_at_scope( + self, scope: str, deployment_name: str, parameters: Union[_models.Deployment, IO], **kwargs: Any + ) -> AsyncLROPoller[_models.DeploymentExtended]: + """Deploys resources at a given scope. + + You can provide the template and parameters directly in the request or link to JSON files. + + :param scope: The resource scope. Required. + :type scope: str + :param deployment_name: The name of the deployment. Required. + :type deployment_name: str + :param parameters: Additional parameters supplied to the operation. Is either a model type or a + IO type. Required. + :type parameters: ~azure.mgmt.resource.resources.v2020_10_01.models.Deployment or IO + :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. + Default value is None. + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be AsyncARMPolling. Pass in False for + this operation to not poll, or pass in your own initialized polling object for a personal + polling strategy. + :paramtype polling: bool or ~azure.core.polling.AsyncPollingMethod + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of AsyncLROPoller that returns either DeploymentExtended or the result of + cls(response) + :rtype: + ~azure.core.polling.AsyncLROPoller[~azure.mgmt.resource.resources.v2020_10_01.models.DeploymentExtended] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _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", "2020-10-01")) # type: str + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.DeploymentExtended] + polling = kwargs.pop("polling", True) # type: Union[bool, AsyncPollingMethod] + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token = kwargs.pop("continuation_token", None) # type: Optional[str] if cont_token is None: - raw_result = await self._create_or_update_at_scope_initial( + raw_result = await self._create_or_update_at_scope_initial( # type: ignore scope=scope, deployment_name=deployment_name, parameters=parameters, api_version=api_version, content_type=content_type, - cls=lambda x,y,z: x, + cls=lambda x, y, z: x, + headers=_headers, + params=_params, **kwargs ) - kwargs.pop('error_map', None) + kwargs.pop("error_map", None) def get_long_running_output(pipeline_response): - response = pipeline_response.http_response - deserialized = self._deserialize('DeploymentExtended', pipeline_response) + deserialized = self._deserialize("DeploymentExtended", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - - if polling is True: polling_method = AsyncARMPolling(lro_delay, **kwargs) - elif polling is False: polling_method = AsyncNoPolling() - else: polling_method = polling + if polling is True: + polling_method = cast(AsyncPollingMethod, AsyncARMPolling(lro_delay, **kwargs)) # type: AsyncPollingMethod + elif polling is False: + polling_method = cast(AsyncPollingMethod, AsyncNoPolling()) + else: + polling_method = polling if cont_token: return AsyncLROPoller.from_continuation_token( polling_method=polling_method, continuation_token=cont_token, client=self._client, - deserialization_callback=get_long_running_output + deserialization_callback=get_long_running_output, ) return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) - begin_create_or_update_at_scope.metadata = {'url': "/{scope}/providers/Microsoft.Resources/deployments/{deploymentName}"} # type: ignore + begin_create_or_update_at_scope.metadata = {"url": "/{scope}/providers/Microsoft.Resources/deployments/{deploymentName}"} # type: ignore @distributed_trace_async - async def get_at_scope( - self, - scope: str, - deployment_name: str, - **kwargs: Any - ) -> "_models.DeploymentExtended": + async def get_at_scope(self, scope: str, deployment_name: str, **kwargs: Any) -> _models.DeploymentExtended: """Gets a deployment. - :param scope: The resource scope. + :param scope: The resource scope. Required. :type scope: str - :param deployment_name: The name of the deployment. + :param deployment_name: The name of the deployment. Required. :type deployment_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: DeploymentExtended, or the result of cls(response) + :return: DeploymentExtended or the result of cls(response) :rtype: ~azure.mgmt.resource.resources.v2020_10_01.models.DeploymentExtended - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.DeploymentExtended"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) - api_version = kwargs.pop('api_version', "2020-10-01") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2020-10-01")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[_models.DeploymentExtended] - request = build_deployments_get_at_scope_request( scope=scope, deployment_name=deployment_name, api_version=api_version, - template_url=self.get_at_scope.metadata['url'], + template_url=self.get_at_scope.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) - deserialized = self._deserialize('DeploymentExtended', pipeline_response) + deserialized = self._deserialize("DeploymentExtended", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - get_at_scope.metadata = {'url': "/{scope}/providers/Microsoft.Resources/deployments/{deploymentName}"} # type: ignore - + get_at_scope.metadata = {"url": "/{scope}/providers/Microsoft.Resources/deployments/{deploymentName}"} # type: ignore @distributed_trace_async async def cancel_at_scope( # pylint: disable=inconsistent-return-statements - self, - scope: str, - deployment_name: str, - **kwargs: Any + self, scope: str, deployment_name: str, **kwargs: Any ) -> None: """Cancels a currently running template deployment. @@ -502,38 +693,44 @@ async def cancel_at_scope( # pylint: disable=inconsistent-return-statements deployment stops the currently running template deployment and leaves the resources partially deployed. - :param scope: The resource scope. + :param scope: The resource scope. Required. :type scope: str - :param deployment_name: The name of the deployment. + :param deployment_name: The name of the deployment. Required. :type deployment_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: None, or the result of cls(response) + :return: None or the result of cls(response) :rtype: None - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType[None] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + 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', "2020-10-01") # type: str + api_version = kwargs.pop("api_version", _params.pop("api-version", "2020-10-01")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[None] - request = build_deployments_cancel_at_scope_request( scope=scope, deployment_name=deployment_name, api_version=api_version, - template_url=self.cancel_at_scope.metadata['url'], + template_url=self.cancel_at_scope.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [204]: @@ -543,43 +740,52 @@ async def cancel_at_scope( # pylint: disable=inconsistent-return-statements if cls: return cls(pipeline_response, None, {}) - cancel_at_scope.metadata = {'url': "/{scope}/providers/Microsoft.Resources/deployments/{deploymentName}/cancel"} # type: ignore - + cancel_at_scope.metadata = {"url": "/{scope}/providers/Microsoft.Resources/deployments/{deploymentName}/cancel"} # type: ignore async def _validate_at_scope_initial( - self, - scope: str, - deployment_name: str, - parameters: "_models.Deployment", - **kwargs: Any - ) -> Optional["_models.DeploymentValidateResult"]: - cls = kwargs.pop('cls', None) # type: ClsType[Optional["_models.DeploymentValidateResult"]] + self, scope: str, deployment_name: str, parameters: Union[_models.Deployment, IO], **kwargs: Any + ) -> Optional[_models.DeploymentValidateResult]: error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) - api_version = kwargs.pop('api_version', "2020-10-01") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - _json = self._serialize.body(parameters, 'Deployment') + api_version = kwargs.pop("api_version", _params.pop("api-version", "2020-10-01")) # type: str + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[Optional[_models.DeploymentValidateResult]] - request = build_deployments_validate_at_scope_request_initial( + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(parameters, (IO, bytes)): + _content = parameters + else: + _json = self._serialize.body(parameters, "Deployment") + + request = build_deployments_validate_at_scope_request( scope=scope, deployment_name=deployment_name, api_version=api_version, content_type=content_type, json=_json, - template_url=self._validate_at_scope_initial.metadata['url'], + content=_content, + template_url=self._validate_at_scope_initial.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200, 202, 400]: @@ -588,36 +794,40 @@ async def _validate_at_scope_initial( deserialized = None if response.status_code == 200: - deserialized = self._deserialize('DeploymentValidateResult', pipeline_response) + deserialized = self._deserialize("DeploymentValidateResult", pipeline_response) if response.status_code == 400: - deserialized = self._deserialize('DeploymentValidateResult', pipeline_response) + deserialized = self._deserialize("DeploymentValidateResult", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - _validate_at_scope_initial.metadata = {'url': "/{scope}/providers/Microsoft.Resources/deployments/{deploymentName}/validate"} # type: ignore + _validate_at_scope_initial.metadata = {"url": "/{scope}/providers/Microsoft.Resources/deployments/{deploymentName}/validate"} # type: ignore - - @distributed_trace_async + @overload async def begin_validate_at_scope( self, scope: str, deployment_name: str, - parameters: "_models.Deployment", + parameters: _models.Deployment, + *, + content_type: str = "application/json", **kwargs: Any - ) -> AsyncLROPoller["_models.DeploymentValidateResult"]: + ) -> AsyncLROPoller[_models.DeploymentValidateResult]: """Validates whether the specified template is syntactically correct and will be accepted by Azure Resource Manager.. - :param scope: The resource scope. + :param scope: The resource scope. Required. :type scope: str - :param deployment_name: The name of the deployment. + :param deployment_name: The name of the deployment. Required. :type deployment_name: str - :param parameters: Parameters to validate. + :param parameters: Parameters to validate. Required. :type parameters: ~azure.mgmt.resource.resources.v2020_10_01.models.Deployment + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str :keyword callable cls: A custom type or function that will be passed the direct response :keyword str continuation_token: A continuation token to restart a poller from a saved state. :keyword polling: By default, your polling method will be AsyncARMPolling. Pass in False for @@ -630,119 +840,182 @@ async def begin_validate_at_scope( result of cls(response) :rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.resource.resources.v2020_10_01.models.DeploymentValidateResult] - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - api_version = kwargs.pop('api_version', "2020-10-01") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] - polling = kwargs.pop('polling', True) # type: Union[bool, AsyncPollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType["_models.DeploymentValidateResult"] - lro_delay = kwargs.pop( - 'polling_interval', - self._config.polling_interval - ) - cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] + + @overload + async def begin_validate_at_scope( + self, scope: str, deployment_name: str, parameters: IO, *, content_type: str = "application/json", **kwargs: Any + ) -> AsyncLROPoller[_models.DeploymentValidateResult]: + """Validates whether the specified template is syntactically correct and will be accepted by Azure + Resource Manager.. + + :param scope: The resource scope. Required. + :type scope: str + :param deployment_name: The name of the deployment. Required. + :type deployment_name: str + :param parameters: Parameters to validate. Required. + :type parameters: IO + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be AsyncARMPolling. Pass in False for + this operation to not poll, or pass in your own initialized polling object for a personal + polling strategy. + :paramtype polling: bool or ~azure.core.polling.AsyncPollingMethod + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of AsyncLROPoller that returns either DeploymentValidateResult or the + result of cls(response) + :rtype: + ~azure.core.polling.AsyncLROPoller[~azure.mgmt.resource.resources.v2020_10_01.models.DeploymentValidateResult] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace_async + async def begin_validate_at_scope( + self, scope: str, deployment_name: str, parameters: Union[_models.Deployment, IO], **kwargs: Any + ) -> AsyncLROPoller[_models.DeploymentValidateResult]: + """Validates whether the specified template is syntactically correct and will be accepted by Azure + Resource Manager.. + + :param scope: The resource scope. Required. + :type scope: str + :param deployment_name: The name of the deployment. Required. + :type deployment_name: str + :param parameters: Parameters to validate. Is either a model type or a IO type. Required. + :type parameters: ~azure.mgmt.resource.resources.v2020_10_01.models.Deployment or IO + :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. + Default value is None. + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be AsyncARMPolling. Pass in False for + this operation to not poll, or pass in your own initialized polling object for a personal + polling strategy. + :paramtype polling: bool or ~azure.core.polling.AsyncPollingMethod + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of AsyncLROPoller that returns either DeploymentValidateResult or the + result of cls(response) + :rtype: + ~azure.core.polling.AsyncLROPoller[~azure.mgmt.resource.resources.v2020_10_01.models.DeploymentValidateResult] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _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", "2020-10-01")) # type: str + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.DeploymentValidateResult] + polling = kwargs.pop("polling", True) # type: Union[bool, AsyncPollingMethod] + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token = kwargs.pop("continuation_token", None) # type: Optional[str] if cont_token is None: - raw_result = await self._validate_at_scope_initial( + raw_result = await self._validate_at_scope_initial( # type: ignore scope=scope, deployment_name=deployment_name, parameters=parameters, api_version=api_version, content_type=content_type, - cls=lambda x,y,z: x, + cls=lambda x, y, z: x, + headers=_headers, + params=_params, **kwargs ) - kwargs.pop('error_map', None) + kwargs.pop("error_map", None) def get_long_running_output(pipeline_response): - response = pipeline_response.http_response - deserialized = self._deserialize('DeploymentValidateResult', pipeline_response) + deserialized = self._deserialize("DeploymentValidateResult", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - - if polling is True: polling_method = AsyncARMPolling(lro_delay, **kwargs) - elif polling is False: polling_method = AsyncNoPolling() - else: polling_method = polling + if polling is True: + polling_method = cast(AsyncPollingMethod, AsyncARMPolling(lro_delay, **kwargs)) # type: AsyncPollingMethod + elif polling is False: + polling_method = cast(AsyncPollingMethod, AsyncNoPolling()) + else: + polling_method = polling if cont_token: return AsyncLROPoller.from_continuation_token( polling_method=polling_method, continuation_token=cont_token, client=self._client, - deserialization_callback=get_long_running_output + deserialization_callback=get_long_running_output, ) return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) - begin_validate_at_scope.metadata = {'url': "/{scope}/providers/Microsoft.Resources/deployments/{deploymentName}/validate"} # type: ignore + begin_validate_at_scope.metadata = {"url": "/{scope}/providers/Microsoft.Resources/deployments/{deploymentName}/validate"} # type: ignore @distributed_trace_async async def export_template_at_scope( - self, - scope: str, - deployment_name: str, - **kwargs: Any - ) -> "_models.DeploymentExportResult": + self, scope: str, deployment_name: str, **kwargs: Any + ) -> _models.DeploymentExportResult: """Exports the template used for specified deployment. - :param scope: The resource scope. + :param scope: The resource scope. Required. :type scope: str - :param deployment_name: The name of the deployment. + :param deployment_name: The name of the deployment. Required. :type deployment_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: DeploymentExportResult, or the result of cls(response) + :return: DeploymentExportResult or the result of cls(response) :rtype: ~azure.mgmt.resource.resources.v2020_10_01.models.DeploymentExportResult - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.DeploymentExportResult"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + 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', "2020-10-01") # type: str + api_version = kwargs.pop("api_version", _params.pop("api-version", "2020-10-01")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[_models.DeploymentExportResult] - request = build_deployments_export_template_at_scope_request( scope=scope, deployment_name=deployment_name, api_version=api_version, - template_url=self.export_template_at_scope.metadata['url'], + template_url=self.export_template_at_scope.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) - deserialized = self._deserialize('DeploymentExportResult', pipeline_response) + deserialized = self._deserialize("DeploymentExportResult", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - export_template_at_scope.metadata = {'url': "/{scope}/providers/Microsoft.Resources/deployments/{deploymentName}/exportTemplate"} # type: ignore - + export_template_at_scope.metadata = {"url": "/{scope}/providers/Microsoft.Resources/deployments/{deploymentName}/exportTemplate"} # type: ignore @distributed_trace def list_at_scope( - self, - scope: str, - filter: Optional[str] = None, - top: Optional[int] = None, - **kwargs: Any - ) -> AsyncIterable["_models.DeploymentListResult"]: + self, scope: str, filter: Optional[str] = None, top: Optional[int] = None, **kwargs: Any + ) -> AsyncIterable["_models.DeploymentExtended"]: """Get all the deployments at the given scope. - :param scope: The resource scope. + :param scope: The resource scope. Required. :type scope: str :param filter: The filter to apply on the operation. For example, you can use $filter=provisioningState eq '{state}'. Default value is None. @@ -751,40 +1024,48 @@ def list_at_scope( value is None. :type top: int :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either DeploymentListResult or the result of - cls(response) + :return: An iterator like instance of either DeploymentExtended or the result of cls(response) :rtype: - ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.resource.resources.v2020_10_01.models.DeploymentListResult] - :raises: ~azure.core.exceptions.HttpResponseError + ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.resource.resources.v2020_10_01.models.DeploymentExtended] + :raises ~azure.core.exceptions.HttpResponseError: """ - api_version = kwargs.pop('api_version', "2020-10-01") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2020-10-01")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[_models.DeploymentListResult] - cls = kwargs.pop('cls', None) # type: ClsType["_models.DeploymentListResult"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) + def prepare_request(next_link=None): if not next_link: - + request = build_deployments_list_at_scope_request( scope=scope, - api_version=api_version, filter=filter, top=top, - template_url=self.list_at_scope.metadata['url'], + api_version=api_version, + template_url=self.list_at_scope.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore else: - - request = build_deployments_list_at_scope_request( - scope=scope, - template_url=next_link, - ) + # make call to next link with the client's api-version + _parsed_next_link = urlparse(next_link) + _next_request_params = case_insensitive_dict(parse_qs(_parsed_next_link.query)) + _next_request_params["api-version"] = self._config.api_version + request = HttpRequest("GET", urljoin(next_link, _parsed_next_link.path), params=_next_request_params) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore request.method = "GET" return request @@ -798,10 +1079,8 @@ async def extract_data(pipeline_response): async def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) response = pipeline_response.http_response @@ -811,39 +1090,41 @@ async def get_next(next_link=None): return pipeline_response + return AsyncItemPaged(get_next, extract_data) - return AsyncItemPaged( - get_next, extract_data - ) - list_at_scope.metadata = {'url': "/{scope}/providers/Microsoft.Resources/deployments/"} # type: ignore + list_at_scope.metadata = {"url": "/{scope}/providers/Microsoft.Resources/deployments/"} # type: ignore async def _delete_at_tenant_scope_initial( # pylint: disable=inconsistent-return-statements - self, - deployment_name: str, - **kwargs: Any + self, deployment_name: str, **kwargs: Any ) -> None: - cls = kwargs.pop('cls', None) # type: ClsType[None] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + 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', "2020-10-01") # type: str + api_version = kwargs.pop("api_version", _params.pop("api-version", "2020-10-01")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[None] - - request = build_deployments_delete_at_tenant_scope_request_initial( + request = build_deployments_delete_at_tenant_scope_request( deployment_name=deployment_name, api_version=api_version, - template_url=self._delete_at_tenant_scope_initial.metadata['url'], + template_url=self._delete_at_tenant_scope_initial.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [202, 204]: @@ -853,15 +1134,10 @@ async def _delete_at_tenant_scope_initial( # pylint: disable=inconsistent-retur if cls: return cls(pipeline_response, None, {}) - _delete_at_tenant_scope_initial.metadata = {'url': "/providers/Microsoft.Resources/deployments/{deploymentName}"} # type: ignore - + _delete_at_tenant_scope_initial.metadata = {"url": "/providers/Microsoft.Resources/deployments/{deploymentName}"} # type: ignore @distributed_trace_async - async def begin_delete_at_tenant_scope( # pylint: disable=inconsistent-return-statements - self, - deployment_name: str, - **kwargs: Any - ) -> AsyncLROPoller[None]: + async def begin_delete_at_tenant_scope(self, deployment_name: str, **kwargs: Any) -> AsyncLROPoller[None]: """Deletes a deployment from the deployment history. A template deployment that is currently running cannot be deleted. Deleting a template @@ -872,7 +1148,7 @@ async def begin_delete_at_tenant_scope( # pylint: disable=inconsistent-return-s process finishes, the URI in the Location header returns a status of 204 on success. If the asynchronous request failed, the URI in the Location header returns an error-level status code. - :param deployment_name: The name of the deployment. + :param deployment_name: The name of the deployment. Required. :type deployment_name: str :keyword callable cls: A custom type or function that will be passed the direct response :keyword str continuation_token: A continuation token to restart a poller from a saved state. @@ -884,81 +1160,87 @@ async def begin_delete_at_tenant_scope( # pylint: disable=inconsistent-return-s Retry-After header is present. :return: An instance of AsyncLROPoller that returns either None or the result of cls(response) :rtype: ~azure.core.polling.AsyncLROPoller[None] - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - api_version = kwargs.pop('api_version', "2020-10-01") # type: str - polling = kwargs.pop('polling', True) # type: Union[bool, AsyncPollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType[None] - lro_delay = kwargs.pop( - 'polling_interval', - self._config.polling_interval - ) - cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2020-10-01")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[None] + polling = kwargs.pop("polling", True) # type: Union[bool, AsyncPollingMethod] + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token = kwargs.pop("continuation_token", None) # type: Optional[str] if cont_token is None: - raw_result = await self._delete_at_tenant_scope_initial( + raw_result = await self._delete_at_tenant_scope_initial( # type: ignore deployment_name=deployment_name, api_version=api_version, - cls=lambda x,y,z: x, + cls=lambda x, y, z: x, + headers=_headers, + params=_params, **kwargs ) - kwargs.pop('error_map', None) + kwargs.pop("error_map", None) - def get_long_running_output(pipeline_response): + def get_long_running_output(pipeline_response): # pylint: disable=inconsistent-return-statements if cls: return cls(pipeline_response, None, {}) - - if polling is True: polling_method = AsyncARMPolling(lro_delay, **kwargs) - elif polling is False: polling_method = AsyncNoPolling() - else: polling_method = polling + if polling is True: + polling_method = cast(AsyncPollingMethod, AsyncARMPolling(lro_delay, **kwargs)) # type: AsyncPollingMethod + elif polling is False: + polling_method = cast(AsyncPollingMethod, AsyncNoPolling()) + else: + polling_method = polling if cont_token: return AsyncLROPoller.from_continuation_token( polling_method=polling_method, continuation_token=cont_token, client=self._client, - deserialization_callback=get_long_running_output + deserialization_callback=get_long_running_output, ) return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) - begin_delete_at_tenant_scope.metadata = {'url': "/providers/Microsoft.Resources/deployments/{deploymentName}"} # type: ignore + begin_delete_at_tenant_scope.metadata = {"url": "/providers/Microsoft.Resources/deployments/{deploymentName}"} # type: ignore @distributed_trace_async - async def check_existence_at_tenant_scope( - self, - deployment_name: str, - **kwargs: Any - ) -> bool: + async def check_existence_at_tenant_scope(self, deployment_name: str, **kwargs: Any) -> bool: """Checks whether the deployment exists. - :param deployment_name: The name of the deployment. + :param deployment_name: The name of the deployment. Required. :type deployment_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: bool, or the result of cls(response) + :return: bool or the result of cls(response) :rtype: bool - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType[None] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + 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', "2020-10-01") # type: str + api_version = kwargs.pop("api_version", _params.pop("api-version", "2020-10-01")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[None] - request = build_deployments_check_existence_at_tenant_scope_request( deployment_name=deployment_name, api_version=api_version, - template_url=self.check_existence_at_tenant_scope.metadata['url'], + template_url=self.check_existence_at_tenant_scope.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [204, 404]: @@ -969,41 +1251,51 @@ async def check_existence_at_tenant_scope( return cls(pipeline_response, None, {}) return 200 <= response.status_code <= 299 - check_existence_at_tenant_scope.metadata = {'url': "/providers/Microsoft.Resources/deployments/{deploymentName}"} # type: ignore - + check_existence_at_tenant_scope.metadata = {"url": "/providers/Microsoft.Resources/deployments/{deploymentName}"} # type: ignore async def _create_or_update_at_tenant_scope_initial( - self, - deployment_name: str, - parameters: "_models.ScopedDeployment", - **kwargs: Any - ) -> "_models.DeploymentExtended": - cls = kwargs.pop('cls', None) # type: ClsType["_models.DeploymentExtended"] + self, deployment_name: str, parameters: Union[_models.ScopedDeployment, IO], **kwargs: Any + ) -> _models.DeploymentExtended: error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', "2020-10-01") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + api_version = kwargs.pop("api_version", _params.pop("api-version", "2020-10-01")) # type: str + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.DeploymentExtended] - _json = self._serialize.body(parameters, 'ScopedDeployment') + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(parameters, (IO, bytes)): + _content = parameters + else: + _json = self._serialize.body(parameters, "ScopedDeployment") - request = build_deployments_create_or_update_at_tenant_scope_request_initial( + request = build_deployments_create_or_update_at_tenant_scope_request( deployment_name=deployment_name, api_version=api_version, content_type=content_type, json=_json, - template_url=self._create_or_update_at_tenant_scope_initial.metadata['url'], + content=_content, + template_url=self._create_or_update_at_tenant_scope_initial.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200, 201]: @@ -1011,34 +1303,38 @@ async def _create_or_update_at_tenant_scope_initial( raise HttpResponseError(response=response, error_format=ARMErrorFormat) if response.status_code == 200: - deserialized = self._deserialize('DeploymentExtended', pipeline_response) + deserialized = self._deserialize("DeploymentExtended", pipeline_response) if response.status_code == 201: - deserialized = self._deserialize('DeploymentExtended', pipeline_response) + deserialized = self._deserialize("DeploymentExtended", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - _create_or_update_at_tenant_scope_initial.metadata = {'url': "/providers/Microsoft.Resources/deployments/{deploymentName}"} # type: ignore - + _create_or_update_at_tenant_scope_initial.metadata = {"url": "/providers/Microsoft.Resources/deployments/{deploymentName}"} # type: ignore - @distributed_trace_async + @overload async def begin_create_or_update_at_tenant_scope( self, deployment_name: str, - parameters: "_models.ScopedDeployment", + parameters: _models.ScopedDeployment, + *, + content_type: str = "application/json", **kwargs: Any - ) -> AsyncLROPoller["_models.DeploymentExtended"]: + ) -> AsyncLROPoller[_models.DeploymentExtended]: """Deploys resources at tenant scope. You can provide the template and parameters directly in the request or link to JSON files. - :param deployment_name: The name of the deployment. + :param deployment_name: The name of the deployment. Required. :type deployment_name: str - :param parameters: Additional parameters supplied to the operation. + :param parameters: Additional parameters supplied to the operation. Required. :type parameters: ~azure.mgmt.resource.resources.v2020_10_01.models.ScopedDeployment + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str :keyword callable cls: A custom type or function that will be passed the direct response :keyword str continuation_token: A continuation token to restart a poller from a saved state. :keyword polling: By default, your polling method will be AsyncARMPolling. Pass in False for @@ -1051,108 +1347,171 @@ async def begin_create_or_update_at_tenant_scope( cls(response) :rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.resource.resources.v2020_10_01.models.DeploymentExtended] - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - api_version = kwargs.pop('api_version', "2020-10-01") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] - polling = kwargs.pop('polling', True) # type: Union[bool, AsyncPollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType["_models.DeploymentExtended"] - lro_delay = kwargs.pop( - 'polling_interval', - self._config.polling_interval - ) - cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] + + @overload + async def begin_create_or_update_at_tenant_scope( + self, deployment_name: str, parameters: IO, *, content_type: str = "application/json", **kwargs: Any + ) -> AsyncLROPoller[_models.DeploymentExtended]: + """Deploys resources at tenant scope. + + You can provide the template and parameters directly in the request or link to JSON files. + + :param deployment_name: The name of the deployment. Required. + :type deployment_name: str + :param parameters: Additional parameters supplied to the operation. Required. + :type parameters: IO + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be AsyncARMPolling. Pass in False for + this operation to not poll, or pass in your own initialized polling object for a personal + polling strategy. + :paramtype polling: bool or ~azure.core.polling.AsyncPollingMethod + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of AsyncLROPoller that returns either DeploymentExtended or the result of + cls(response) + :rtype: + ~azure.core.polling.AsyncLROPoller[~azure.mgmt.resource.resources.v2020_10_01.models.DeploymentExtended] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace_async + async def begin_create_or_update_at_tenant_scope( + self, deployment_name: str, parameters: Union[_models.ScopedDeployment, IO], **kwargs: Any + ) -> AsyncLROPoller[_models.DeploymentExtended]: + """Deploys resources at tenant scope. + + You can provide the template and parameters directly in the request or link to JSON files. + + :param deployment_name: The name of the deployment. Required. + :type deployment_name: str + :param parameters: Additional parameters supplied to the operation. Is either a model type or a + IO type. Required. + :type parameters: ~azure.mgmt.resource.resources.v2020_10_01.models.ScopedDeployment or IO + :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. + Default value is None. + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be AsyncARMPolling. Pass in False for + this operation to not poll, or pass in your own initialized polling object for a personal + polling strategy. + :paramtype polling: bool or ~azure.core.polling.AsyncPollingMethod + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of AsyncLROPoller that returns either DeploymentExtended or the result of + cls(response) + :rtype: + ~azure.core.polling.AsyncLROPoller[~azure.mgmt.resource.resources.v2020_10_01.models.DeploymentExtended] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _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", "2020-10-01")) # type: str + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.DeploymentExtended] + polling = kwargs.pop("polling", True) # type: Union[bool, AsyncPollingMethod] + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token = kwargs.pop("continuation_token", None) # type: Optional[str] if cont_token is None: - raw_result = await self._create_or_update_at_tenant_scope_initial( + raw_result = await self._create_or_update_at_tenant_scope_initial( # type: ignore deployment_name=deployment_name, parameters=parameters, api_version=api_version, content_type=content_type, - cls=lambda x,y,z: x, + cls=lambda x, y, z: x, + headers=_headers, + params=_params, **kwargs ) - kwargs.pop('error_map', None) + kwargs.pop("error_map", None) def get_long_running_output(pipeline_response): - response = pipeline_response.http_response - deserialized = self._deserialize('DeploymentExtended', pipeline_response) + deserialized = self._deserialize("DeploymentExtended", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - - if polling is True: polling_method = AsyncARMPolling(lro_delay, **kwargs) - elif polling is False: polling_method = AsyncNoPolling() - else: polling_method = polling + if polling is True: + polling_method = cast(AsyncPollingMethod, AsyncARMPolling(lro_delay, **kwargs)) # type: AsyncPollingMethod + elif polling is False: + polling_method = cast(AsyncPollingMethod, AsyncNoPolling()) + else: + polling_method = polling if cont_token: return AsyncLROPoller.from_continuation_token( polling_method=polling_method, continuation_token=cont_token, client=self._client, - deserialization_callback=get_long_running_output + deserialization_callback=get_long_running_output, ) return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) - begin_create_or_update_at_tenant_scope.metadata = {'url': "/providers/Microsoft.Resources/deployments/{deploymentName}"} # type: ignore + begin_create_or_update_at_tenant_scope.metadata = {"url": "/providers/Microsoft.Resources/deployments/{deploymentName}"} # type: ignore @distributed_trace_async - async def get_at_tenant_scope( - self, - deployment_name: str, - **kwargs: Any - ) -> "_models.DeploymentExtended": + async def get_at_tenant_scope(self, deployment_name: str, **kwargs: Any) -> _models.DeploymentExtended: """Gets a deployment. - :param deployment_name: The name of the deployment. + :param deployment_name: The name of the deployment. Required. :type deployment_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: DeploymentExtended, or the result of cls(response) + :return: DeploymentExtended or the result of cls(response) :rtype: ~azure.mgmt.resource.resources.v2020_10_01.models.DeploymentExtended - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.DeploymentExtended"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) - api_version = kwargs.pop('api_version', "2020-10-01") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2020-10-01")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[_models.DeploymentExtended] - request = build_deployments_get_at_tenant_scope_request( deployment_name=deployment_name, api_version=api_version, - template_url=self.get_at_tenant_scope.metadata['url'], + template_url=self.get_at_tenant_scope.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) - deserialized = self._deserialize('DeploymentExtended', pipeline_response) + deserialized = self._deserialize("DeploymentExtended", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - get_at_tenant_scope.metadata = {'url': "/providers/Microsoft.Resources/deployments/{deploymentName}"} # type: ignore - + get_at_tenant_scope.metadata = {"url": "/providers/Microsoft.Resources/deployments/{deploymentName}"} # type: ignore @distributed_trace_async async def cancel_at_tenant_scope( # pylint: disable=inconsistent-return-statements - self, - deployment_name: str, - **kwargs: Any + self, deployment_name: str, **kwargs: Any ) -> None: """Cancels a currently running template deployment. @@ -1161,35 +1520,41 @@ async def cancel_at_tenant_scope( # pylint: disable=inconsistent-return-stateme deployment stops the currently running template deployment and leaves the resources partially deployed. - :param deployment_name: The name of the deployment. + :param deployment_name: The name of the deployment. Required. :type deployment_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: None, or the result of cls(response) + :return: None or the result of cls(response) :rtype: None - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType[None] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) - api_version = kwargs.pop('api_version', "2020-10-01") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2020-10-01")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[None] - request = build_deployments_cancel_at_tenant_scope_request( deployment_name=deployment_name, api_version=api_version, - template_url=self.cancel_at_tenant_scope.metadata['url'], + template_url=self.cancel_at_tenant_scope.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [204]: @@ -1199,41 +1564,51 @@ async def cancel_at_tenant_scope( # pylint: disable=inconsistent-return-stateme if cls: return cls(pipeline_response, None, {}) - cancel_at_tenant_scope.metadata = {'url': "/providers/Microsoft.Resources/deployments/{deploymentName}/cancel"} # type: ignore - + cancel_at_tenant_scope.metadata = {"url": "/providers/Microsoft.Resources/deployments/{deploymentName}/cancel"} # type: ignore async def _validate_at_tenant_scope_initial( - self, - deployment_name: str, - parameters: "_models.ScopedDeployment", - **kwargs: Any - ) -> Optional["_models.DeploymentValidateResult"]: - cls = kwargs.pop('cls', None) # type: ClsType[Optional["_models.DeploymentValidateResult"]] + self, deployment_name: str, parameters: Union[_models.ScopedDeployment, IO], **kwargs: Any + ) -> Optional[_models.DeploymentValidateResult]: error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) - api_version = kwargs.pop('api_version', "2020-10-01") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - _json = self._serialize.body(parameters, 'ScopedDeployment') + api_version = kwargs.pop("api_version", _params.pop("api-version", "2020-10-01")) # type: str + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[Optional[_models.DeploymentValidateResult]] - request = build_deployments_validate_at_tenant_scope_request_initial( + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(parameters, (IO, bytes)): + _content = parameters + else: + _json = self._serialize.body(parameters, "ScopedDeployment") + + request = build_deployments_validate_at_tenant_scope_request( deployment_name=deployment_name, api_version=api_version, content_type=content_type, json=_json, - template_url=self._validate_at_tenant_scope_initial.metadata['url'], + content=_content, + template_url=self._validate_at_tenant_scope_initial.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200, 202, 400]: @@ -1242,33 +1617,37 @@ async def _validate_at_tenant_scope_initial( deserialized = None if response.status_code == 200: - deserialized = self._deserialize('DeploymentValidateResult', pipeline_response) + deserialized = self._deserialize("DeploymentValidateResult", pipeline_response) if response.status_code == 400: - deserialized = self._deserialize('DeploymentValidateResult', pipeline_response) + deserialized = self._deserialize("DeploymentValidateResult", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - _validate_at_tenant_scope_initial.metadata = {'url': "/providers/Microsoft.Resources/deployments/{deploymentName}/validate"} # type: ignore + _validate_at_tenant_scope_initial.metadata = {"url": "/providers/Microsoft.Resources/deployments/{deploymentName}/validate"} # type: ignore - - @distributed_trace_async + @overload async def begin_validate_at_tenant_scope( self, deployment_name: str, - parameters: "_models.ScopedDeployment", + parameters: _models.ScopedDeployment, + *, + content_type: str = "application/json", **kwargs: Any - ) -> AsyncLROPoller["_models.DeploymentValidateResult"]: + ) -> AsyncLROPoller[_models.DeploymentValidateResult]: """Validates whether the specified template is syntactically correct and will be accepted by Azure Resource Manager.. - :param deployment_name: The name of the deployment. + :param deployment_name: The name of the deployment. Required. :type deployment_name: str - :param parameters: Parameters to validate. + :param parameters: Parameters to validate. Required. :type parameters: ~azure.mgmt.resource.resources.v2020_10_01.models.ScopedDeployment + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str :keyword callable cls: A custom type or function that will be passed the direct response :keyword str continuation_token: A continuation token to restart a poller from a saved state. :keyword polling: By default, your polling method will be AsyncARMPolling. Pass in False for @@ -1281,82 +1660,154 @@ async def begin_validate_at_tenant_scope( result of cls(response) :rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.resource.resources.v2020_10_01.models.DeploymentValidateResult] - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - api_version = kwargs.pop('api_version', "2020-10-01") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] - polling = kwargs.pop('polling', True) # type: Union[bool, AsyncPollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType["_models.DeploymentValidateResult"] - lro_delay = kwargs.pop( - 'polling_interval', - self._config.polling_interval - ) - cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] + + @overload + async def begin_validate_at_tenant_scope( + self, deployment_name: str, parameters: IO, *, content_type: str = "application/json", **kwargs: Any + ) -> AsyncLROPoller[_models.DeploymentValidateResult]: + """Validates whether the specified template is syntactically correct and will be accepted by Azure + Resource Manager.. + + :param deployment_name: The name of the deployment. Required. + :type deployment_name: str + :param parameters: Parameters to validate. Required. + :type parameters: IO + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be AsyncARMPolling. Pass in False for + this operation to not poll, or pass in your own initialized polling object for a personal + polling strategy. + :paramtype polling: bool or ~azure.core.polling.AsyncPollingMethod + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of AsyncLROPoller that returns either DeploymentValidateResult or the + result of cls(response) + :rtype: + ~azure.core.polling.AsyncLROPoller[~azure.mgmt.resource.resources.v2020_10_01.models.DeploymentValidateResult] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace_async + async def begin_validate_at_tenant_scope( + self, deployment_name: str, parameters: Union[_models.ScopedDeployment, IO], **kwargs: Any + ) -> AsyncLROPoller[_models.DeploymentValidateResult]: + """Validates whether the specified template is syntactically correct and will be accepted by Azure + Resource Manager.. + + :param deployment_name: The name of the deployment. Required. + :type deployment_name: str + :param parameters: Parameters to validate. Is either a model type or a IO type. Required. + :type parameters: ~azure.mgmt.resource.resources.v2020_10_01.models.ScopedDeployment or IO + :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. + Default value is None. + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be AsyncARMPolling. Pass in False for + this operation to not poll, or pass in your own initialized polling object for a personal + polling strategy. + :paramtype polling: bool or ~azure.core.polling.AsyncPollingMethod + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of AsyncLROPoller that returns either DeploymentValidateResult or the + result of cls(response) + :rtype: + ~azure.core.polling.AsyncLROPoller[~azure.mgmt.resource.resources.v2020_10_01.models.DeploymentValidateResult] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _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", "2020-10-01")) # type: str + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.DeploymentValidateResult] + polling = kwargs.pop("polling", True) # type: Union[bool, AsyncPollingMethod] + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token = kwargs.pop("continuation_token", None) # type: Optional[str] if cont_token is None: - raw_result = await self._validate_at_tenant_scope_initial( + raw_result = await self._validate_at_tenant_scope_initial( # type: ignore deployment_name=deployment_name, parameters=parameters, api_version=api_version, content_type=content_type, - cls=lambda x,y,z: x, + cls=lambda x, y, z: x, + headers=_headers, + params=_params, **kwargs ) - kwargs.pop('error_map', None) + kwargs.pop("error_map", None) def get_long_running_output(pipeline_response): - response = pipeline_response.http_response - deserialized = self._deserialize('DeploymentValidateResult', pipeline_response) + deserialized = self._deserialize("DeploymentValidateResult", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - - if polling is True: polling_method = AsyncARMPolling(lro_delay, **kwargs) - elif polling is False: polling_method = AsyncNoPolling() - else: polling_method = polling + if polling is True: + polling_method = cast(AsyncPollingMethod, AsyncARMPolling(lro_delay, **kwargs)) # type: AsyncPollingMethod + elif polling is False: + polling_method = cast(AsyncPollingMethod, AsyncNoPolling()) + else: + polling_method = polling if cont_token: return AsyncLROPoller.from_continuation_token( polling_method=polling_method, continuation_token=cont_token, client=self._client, - deserialization_callback=get_long_running_output + deserialization_callback=get_long_running_output, ) return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) - begin_validate_at_tenant_scope.metadata = {'url': "/providers/Microsoft.Resources/deployments/{deploymentName}/validate"} # type: ignore + begin_validate_at_tenant_scope.metadata = {"url": "/providers/Microsoft.Resources/deployments/{deploymentName}/validate"} # type: ignore async def _what_if_at_tenant_scope_initial( - self, - deployment_name: str, - parameters: "_models.ScopedDeploymentWhatIf", - **kwargs: Any - ) -> Optional["_models.WhatIfOperationResult"]: - cls = kwargs.pop('cls', None) # type: ClsType[Optional["_models.WhatIfOperationResult"]] + self, deployment_name: str, parameters: Union[_models.ScopedDeploymentWhatIf, IO], **kwargs: Any + ) -> Optional[_models.WhatIfOperationResult]: error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) - api_version = kwargs.pop('api_version', "2020-10-01") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - _json = self._serialize.body(parameters, 'ScopedDeploymentWhatIf') + api_version = kwargs.pop("api_version", _params.pop("api-version", "2020-10-01")) # type: str + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[Optional[_models.WhatIfOperationResult]] - request = build_deployments_what_if_at_tenant_scope_request_initial( + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(parameters, (IO, bytes)): + _content = parameters + else: + _json = self._serialize.body(parameters, "ScopedDeploymentWhatIf") + + request = build_deployments_what_if_at_tenant_scope_request( deployment_name=deployment_name, api_version=api_version, content_type=content_type, json=_json, - template_url=self._what_if_at_tenant_scope_initial.metadata['url'], + content=_content, + template_url=self._what_if_at_tenant_scope_initial.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200, 202]: @@ -1366,35 +1817,38 @@ async def _what_if_at_tenant_scope_initial( deserialized = None response_headers = {} if response.status_code == 200: - deserialized = self._deserialize('WhatIfOperationResult', pipeline_response) + deserialized = self._deserialize("WhatIfOperationResult", pipeline_response) if response.status_code == 202: - response_headers['Location']=self._deserialize('str', response.headers.get('Location')) - response_headers['Retry-After']=self._deserialize('str', response.headers.get('Retry-After')) - + response_headers["Location"] = self._deserialize("str", response.headers.get("Location")) + response_headers["Retry-After"] = self._deserialize("str", response.headers.get("Retry-After")) if cls: return cls(pipeline_response, deserialized, response_headers) return deserialized - _what_if_at_tenant_scope_initial.metadata = {'url': "/providers/Microsoft.Resources/deployments/{deploymentName}/whatIf"} # type: ignore + _what_if_at_tenant_scope_initial.metadata = {"url": "/providers/Microsoft.Resources/deployments/{deploymentName}/whatIf"} # type: ignore - - @distributed_trace_async + @overload async def begin_what_if_at_tenant_scope( self, deployment_name: str, - parameters: "_models.ScopedDeploymentWhatIf", + parameters: _models.ScopedDeploymentWhatIf, + *, + content_type: str = "application/json", **kwargs: Any - ) -> AsyncLROPoller["_models.WhatIfOperationResult"]: + ) -> AsyncLROPoller[_models.WhatIfOperationResult]: """Returns changes that will be made by the deployment if executed at the scope of the tenant group. - :param deployment_name: The name of the deployment. + :param deployment_name: The name of the deployment. Required. :type deployment_name: str - :param parameters: Parameters to validate. + :param parameters: Parameters to validate. Required. :type parameters: ~azure.mgmt.resource.resources.v2020_10_01.models.ScopedDeploymentWhatIf + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str :keyword callable cls: A custom type or function that will be passed the direct response :keyword str continuation_token: A continuation token to restart a poller from a saved state. :keyword polling: By default, your polling method will be AsyncARMPolling. Pass in False for @@ -1407,110 +1861,174 @@ async def begin_what_if_at_tenant_scope( of cls(response) :rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.resource.resources.v2020_10_01.models.WhatIfOperationResult] - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - api_version = kwargs.pop('api_version', "2020-10-01") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] - polling = kwargs.pop('polling', True) # type: Union[bool, AsyncPollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType["_models.WhatIfOperationResult"] - lro_delay = kwargs.pop( - 'polling_interval', - self._config.polling_interval - ) - cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] + + @overload + async def begin_what_if_at_tenant_scope( + self, deployment_name: str, parameters: IO, *, content_type: str = "application/json", **kwargs: Any + ) -> AsyncLROPoller[_models.WhatIfOperationResult]: + """Returns changes that will be made by the deployment if executed at the scope of the tenant + group. + + :param deployment_name: The name of the deployment. Required. + :type deployment_name: str + :param parameters: Parameters to validate. Required. + :type parameters: IO + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be AsyncARMPolling. Pass in False for + this operation to not poll, or pass in your own initialized polling object for a personal + polling strategy. + :paramtype polling: bool or ~azure.core.polling.AsyncPollingMethod + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of AsyncLROPoller that returns either WhatIfOperationResult or the result + of cls(response) + :rtype: + ~azure.core.polling.AsyncLROPoller[~azure.mgmt.resource.resources.v2020_10_01.models.WhatIfOperationResult] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace_async + async def begin_what_if_at_tenant_scope( + self, deployment_name: str, parameters: Union[_models.ScopedDeploymentWhatIf, IO], **kwargs: Any + ) -> AsyncLROPoller[_models.WhatIfOperationResult]: + """Returns changes that will be made by the deployment if executed at the scope of the tenant + group. + + :param deployment_name: The name of the deployment. Required. + :type deployment_name: str + :param parameters: Parameters to validate. Is either a model type or a IO type. Required. + :type parameters: ~azure.mgmt.resource.resources.v2020_10_01.models.ScopedDeploymentWhatIf or + IO + :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. + Default value is None. + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be AsyncARMPolling. Pass in False for + this operation to not poll, or pass in your own initialized polling object for a personal + polling strategy. + :paramtype polling: bool or ~azure.core.polling.AsyncPollingMethod + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of AsyncLROPoller that returns either WhatIfOperationResult or the result + of cls(response) + :rtype: + ~azure.core.polling.AsyncLROPoller[~azure.mgmt.resource.resources.v2020_10_01.models.WhatIfOperationResult] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _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", "2020-10-01")) # type: str + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.WhatIfOperationResult] + polling = kwargs.pop("polling", True) # type: Union[bool, AsyncPollingMethod] + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token = kwargs.pop("continuation_token", None) # type: Optional[str] if cont_token is None: - raw_result = await self._what_if_at_tenant_scope_initial( + raw_result = await self._what_if_at_tenant_scope_initial( # type: ignore deployment_name=deployment_name, parameters=parameters, api_version=api_version, content_type=content_type, - cls=lambda x,y,z: x, + cls=lambda x, y, z: x, + headers=_headers, + params=_params, **kwargs ) - kwargs.pop('error_map', None) + kwargs.pop("error_map", None) def get_long_running_output(pipeline_response): - response = pipeline_response.http_response - deserialized = self._deserialize('WhatIfOperationResult', pipeline_response) + deserialized = self._deserialize("WhatIfOperationResult", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - - if polling is True: polling_method = AsyncARMPolling(lro_delay, lro_options={'final-state-via': 'location'}, **kwargs) - elif polling is False: polling_method = AsyncNoPolling() - else: polling_method = polling + if polling is True: + polling_method = cast( + AsyncPollingMethod, AsyncARMPolling(lro_delay, lro_options={"final-state-via": "location"}, **kwargs) + ) # type: AsyncPollingMethod + elif polling is False: + polling_method = cast(AsyncPollingMethod, AsyncNoPolling()) + else: + polling_method = polling if cont_token: return AsyncLROPoller.from_continuation_token( polling_method=polling_method, continuation_token=cont_token, client=self._client, - deserialization_callback=get_long_running_output + deserialization_callback=get_long_running_output, ) return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) - begin_what_if_at_tenant_scope.metadata = {'url': "/providers/Microsoft.Resources/deployments/{deploymentName}/whatIf"} # type: ignore + begin_what_if_at_tenant_scope.metadata = {"url": "/providers/Microsoft.Resources/deployments/{deploymentName}/whatIf"} # type: ignore @distributed_trace_async async def export_template_at_tenant_scope( - self, - deployment_name: str, - **kwargs: Any - ) -> "_models.DeploymentExportResult": + self, deployment_name: str, **kwargs: Any + ) -> _models.DeploymentExportResult: """Exports the template used for specified deployment. - :param deployment_name: The name of the deployment. + :param deployment_name: The name of the deployment. Required. :type deployment_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: DeploymentExportResult, or the result of cls(response) + :return: DeploymentExportResult or the result of cls(response) :rtype: ~azure.mgmt.resource.resources.v2020_10_01.models.DeploymentExportResult - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.DeploymentExportResult"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) - api_version = kwargs.pop('api_version', "2020-10-01") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2020-10-01")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[_models.DeploymentExportResult] - request = build_deployments_export_template_at_tenant_scope_request( deployment_name=deployment_name, api_version=api_version, - template_url=self.export_template_at_tenant_scope.metadata['url'], + template_url=self.export_template_at_tenant_scope.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) - deserialized = self._deserialize('DeploymentExportResult', pipeline_response) + deserialized = self._deserialize("DeploymentExportResult", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - export_template_at_tenant_scope.metadata = {'url': "/providers/Microsoft.Resources/deployments/{deploymentName}/exportTemplate"} # type: ignore - + export_template_at_tenant_scope.metadata = {"url": "/providers/Microsoft.Resources/deployments/{deploymentName}/exportTemplate"} # type: ignore @distributed_trace def list_at_tenant_scope( - self, - filter: Optional[str] = None, - top: Optional[int] = None, - **kwargs: Any - ) -> AsyncIterable["_models.DeploymentListResult"]: + self, filter: Optional[str] = None, top: Optional[int] = None, **kwargs: Any + ) -> AsyncIterable["_models.DeploymentExtended"]: """Get all the deployments at the tenant scope. :param filter: The filter to apply on the operation. For example, you can use @@ -1520,38 +2038,47 @@ def list_at_tenant_scope( value is None. :type top: int :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either DeploymentListResult or the result of - cls(response) + :return: An iterator like instance of either DeploymentExtended or the result of cls(response) :rtype: - ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.resource.resources.v2020_10_01.models.DeploymentListResult] - :raises: ~azure.core.exceptions.HttpResponseError + ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.resource.resources.v2020_10_01.models.DeploymentExtended] + :raises ~azure.core.exceptions.HttpResponseError: """ - api_version = kwargs.pop('api_version', "2020-10-01") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2020-10-01")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[_models.DeploymentListResult] - cls = kwargs.pop('cls', None) # type: ClsType["_models.DeploymentListResult"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) + def prepare_request(next_link=None): if not next_link: - + request = build_deployments_list_at_tenant_scope_request( - api_version=api_version, filter=filter, top=top, - template_url=self.list_at_tenant_scope.metadata['url'], + api_version=api_version, + template_url=self.list_at_tenant_scope.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore else: - - request = build_deployments_list_at_tenant_scope_request( - template_url=next_link, - ) + # make call to next link with the client's api-version + _parsed_next_link = urlparse(next_link) + _next_request_params = case_insensitive_dict(parse_qs(_parsed_next_link.query)) + _next_request_params["api-version"] = self._config.api_version + request = HttpRequest("GET", urljoin(next_link, _parsed_next_link.path), params=_next_request_params) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore request.method = "GET" return request @@ -1565,10 +2092,8 @@ async def extract_data(pipeline_response): async def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) response = pipeline_response.http_response @@ -1578,41 +2103,42 @@ async def get_next(next_link=None): return pipeline_response + return AsyncItemPaged(get_next, extract_data) - return AsyncItemPaged( - get_next, extract_data - ) - list_at_tenant_scope.metadata = {'url': "/providers/Microsoft.Resources/deployments/"} # type: ignore + list_at_tenant_scope.metadata = {"url": "/providers/Microsoft.Resources/deployments/"} # type: ignore async def _delete_at_management_group_scope_initial( # pylint: disable=inconsistent-return-statements - self, - group_id: str, - deployment_name: str, - **kwargs: Any + self, group_id: str, deployment_name: str, **kwargs: Any ) -> None: - cls = kwargs.pop('cls', None) # type: ClsType[None] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + 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', "2020-10-01") # type: str + api_version = kwargs.pop("api_version", _params.pop("api-version", "2020-10-01")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[None] - - request = build_deployments_delete_at_management_group_scope_request_initial( + request = build_deployments_delete_at_management_group_scope_request( group_id=group_id, deployment_name=deployment_name, api_version=api_version, - template_url=self._delete_at_management_group_scope_initial.metadata['url'], + template_url=self._delete_at_management_group_scope_initial.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [202, 204]: @@ -1622,15 +2148,11 @@ async def _delete_at_management_group_scope_initial( # pylint: disable=inconsis if cls: return cls(pipeline_response, None, {}) - _delete_at_management_group_scope_initial.metadata = {'url': "/providers/Microsoft.Management/managementGroups/{groupId}/providers/Microsoft.Resources/deployments/{deploymentName}"} # type: ignore - + _delete_at_management_group_scope_initial.metadata = {"url": "/providers/Microsoft.Management/managementGroups/{groupId}/providers/Microsoft.Resources/deployments/{deploymentName}"} # type: ignore @distributed_trace_async - async def begin_delete_at_management_group_scope( # pylint: disable=inconsistent-return-statements - self, - group_id: str, - deployment_name: str, - **kwargs: Any + async def begin_delete_at_management_group_scope( + self, group_id: str, deployment_name: str, **kwargs: Any ) -> AsyncLROPoller[None]: """Deletes a deployment from the deployment history. @@ -1642,9 +2164,9 @@ async def begin_delete_at_management_group_scope( # pylint: disable=inconsisten process finishes, the URI in the Location header returns a status of 204 on success. If the asynchronous request failed, the URI in the Location header returns an error-level status code. - :param group_id: The management group ID. + :param group_id: The management group ID. Required. :type group_id: str - :param deployment_name: The name of the deployment. + :param deployment_name: The name of the deployment. Required. :type deployment_name: str :keyword callable cls: A custom type or function that will be passed the direct response :keyword str continuation_token: A continuation token to restart a poller from a saved state. @@ -1656,86 +2178,93 @@ async def begin_delete_at_management_group_scope( # pylint: disable=inconsisten Retry-After header is present. :return: An instance of AsyncLROPoller that returns either None or the result of cls(response) :rtype: ~azure.core.polling.AsyncLROPoller[None] - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - api_version = kwargs.pop('api_version', "2020-10-01") # type: str - polling = kwargs.pop('polling', True) # type: Union[bool, AsyncPollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType[None] - lro_delay = kwargs.pop( - 'polling_interval', - self._config.polling_interval - ) - cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2020-10-01")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[None] + polling = kwargs.pop("polling", True) # type: Union[bool, AsyncPollingMethod] + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token = kwargs.pop("continuation_token", None) # type: Optional[str] if cont_token is None: - raw_result = await self._delete_at_management_group_scope_initial( + raw_result = await self._delete_at_management_group_scope_initial( # type: ignore group_id=group_id, deployment_name=deployment_name, api_version=api_version, - cls=lambda x,y,z: x, + cls=lambda x, y, z: x, + headers=_headers, + params=_params, **kwargs ) - kwargs.pop('error_map', None) + kwargs.pop("error_map", None) - def get_long_running_output(pipeline_response): + def get_long_running_output(pipeline_response): # pylint: disable=inconsistent-return-statements if cls: return cls(pipeline_response, None, {}) - - if polling is True: polling_method = AsyncARMPolling(lro_delay, **kwargs) - elif polling is False: polling_method = AsyncNoPolling() - else: polling_method = polling + if polling is True: + polling_method = cast(AsyncPollingMethod, AsyncARMPolling(lro_delay, **kwargs)) # type: AsyncPollingMethod + elif polling is False: + polling_method = cast(AsyncPollingMethod, AsyncNoPolling()) + else: + polling_method = polling if cont_token: return AsyncLROPoller.from_continuation_token( polling_method=polling_method, continuation_token=cont_token, client=self._client, - deserialization_callback=get_long_running_output + deserialization_callback=get_long_running_output, ) return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) - begin_delete_at_management_group_scope.metadata = {'url': "/providers/Microsoft.Management/managementGroups/{groupId}/providers/Microsoft.Resources/deployments/{deploymentName}"} # type: ignore + begin_delete_at_management_group_scope.metadata = {"url": "/providers/Microsoft.Management/managementGroups/{groupId}/providers/Microsoft.Resources/deployments/{deploymentName}"} # type: ignore @distributed_trace_async async def check_existence_at_management_group_scope( - self, - group_id: str, - deployment_name: str, - **kwargs: Any + self, group_id: str, deployment_name: str, **kwargs: Any ) -> bool: """Checks whether the deployment exists. - :param group_id: The management group ID. + :param group_id: The management group ID. Required. :type group_id: str - :param deployment_name: The name of the deployment. + :param deployment_name: The name of the deployment. Required. :type deployment_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: bool, or the result of cls(response) + :return: bool or the result of cls(response) :rtype: bool - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType[None] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + 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', "2020-10-01") # type: str + api_version = kwargs.pop("api_version", _params.pop("api-version", "2020-10-01")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[None] - request = build_deployments_check_existence_at_management_group_scope_request( group_id=group_id, deployment_name=deployment_name, api_version=api_version, - template_url=self.check_existence_at_management_group_scope.metadata['url'], + template_url=self.check_existence_at_management_group_scope.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [204, 404]: @@ -1746,43 +2275,52 @@ async def check_existence_at_management_group_scope( return cls(pipeline_response, None, {}) return 200 <= response.status_code <= 299 - check_existence_at_management_group_scope.metadata = {'url': "/providers/Microsoft.Management/managementGroups/{groupId}/providers/Microsoft.Resources/deployments/{deploymentName}"} # type: ignore - + check_existence_at_management_group_scope.metadata = {"url": "/providers/Microsoft.Management/managementGroups/{groupId}/providers/Microsoft.Resources/deployments/{deploymentName}"} # type: ignore async def _create_or_update_at_management_group_scope_initial( - self, - group_id: str, - deployment_name: str, - parameters: "_models.ScopedDeployment", - **kwargs: Any - ) -> "_models.DeploymentExtended": - cls = kwargs.pop('cls', None) # type: ClsType["_models.DeploymentExtended"] + self, group_id: str, deployment_name: str, parameters: Union[_models.ScopedDeployment, IO], **kwargs: Any + ) -> _models.DeploymentExtended: error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) - api_version = kwargs.pop('api_version', "2020-10-01") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - _json = self._serialize.body(parameters, 'ScopedDeployment') + api_version = kwargs.pop("api_version", _params.pop("api-version", "2020-10-01")) # type: str + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.DeploymentExtended] - request = build_deployments_create_or_update_at_management_group_scope_request_initial( + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(parameters, (IO, bytes)): + _content = parameters + else: + _json = self._serialize.body(parameters, "ScopedDeployment") + + request = build_deployments_create_or_update_at_management_group_scope_request( group_id=group_id, deployment_name=deployment_name, api_version=api_version, content_type=content_type, json=_json, - template_url=self._create_or_update_at_management_group_scope_initial.metadata['url'], + content=_content, + template_url=self._create_or_update_at_management_group_scope_initial.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200, 201]: @@ -1790,37 +2328,41 @@ async def _create_or_update_at_management_group_scope_initial( raise HttpResponseError(response=response, error_format=ARMErrorFormat) if response.status_code == 200: - deserialized = self._deserialize('DeploymentExtended', pipeline_response) + deserialized = self._deserialize("DeploymentExtended", pipeline_response) if response.status_code == 201: - deserialized = self._deserialize('DeploymentExtended', pipeline_response) + deserialized = self._deserialize("DeploymentExtended", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - _create_or_update_at_management_group_scope_initial.metadata = {'url': "/providers/Microsoft.Management/managementGroups/{groupId}/providers/Microsoft.Resources/deployments/{deploymentName}"} # type: ignore + _create_or_update_at_management_group_scope_initial.metadata = {"url": "/providers/Microsoft.Management/managementGroups/{groupId}/providers/Microsoft.Resources/deployments/{deploymentName}"} # type: ignore - - @distributed_trace_async + @overload async def begin_create_or_update_at_management_group_scope( self, group_id: str, deployment_name: str, - parameters: "_models.ScopedDeployment", + parameters: _models.ScopedDeployment, + *, + content_type: str = "application/json", **kwargs: Any - ) -> AsyncLROPoller["_models.DeploymentExtended"]: + ) -> AsyncLROPoller[_models.DeploymentExtended]: """Deploys resources at management group scope. You can provide the template and parameters directly in the request or link to JSON files. - :param group_id: The management group ID. + :param group_id: The management group ID. Required. :type group_id: str - :param deployment_name: The name of the deployment. + :param deployment_name: The name of the deployment. Required. :type deployment_name: str - :param parameters: Additional parameters supplied to the operation. + :param parameters: Additional parameters supplied to the operation. Required. :type parameters: ~azure.mgmt.resource.resources.v2020_10_01.models.ScopedDeployment + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str :keyword callable cls: A custom type or function that will be passed the direct response :keyword str continuation_token: A continuation token to restart a poller from a saved state. :keyword polling: By default, your polling method will be AsyncARMPolling. Pass in False for @@ -1833,114 +2375,187 @@ async def begin_create_or_update_at_management_group_scope( cls(response) :rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.resource.resources.v2020_10_01.models.DeploymentExtended] - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - api_version = kwargs.pop('api_version', "2020-10-01") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] - polling = kwargs.pop('polling', True) # type: Union[bool, AsyncPollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType["_models.DeploymentExtended"] - lro_delay = kwargs.pop( - 'polling_interval', - self._config.polling_interval - ) - cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] + + @overload + async def begin_create_or_update_at_management_group_scope( + self, + group_id: str, + deployment_name: str, + parameters: IO, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> AsyncLROPoller[_models.DeploymentExtended]: + """Deploys resources at management group scope. + + You can provide the template and parameters directly in the request or link to JSON files. + + :param group_id: The management group ID. Required. + :type group_id: str + :param deployment_name: The name of the deployment. Required. + :type deployment_name: str + :param parameters: Additional parameters supplied to the operation. Required. + :type parameters: IO + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be AsyncARMPolling. Pass in False for + this operation to not poll, or pass in your own initialized polling object for a personal + polling strategy. + :paramtype polling: bool or ~azure.core.polling.AsyncPollingMethod + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of AsyncLROPoller that returns either DeploymentExtended or the result of + cls(response) + :rtype: + ~azure.core.polling.AsyncLROPoller[~azure.mgmt.resource.resources.v2020_10_01.models.DeploymentExtended] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace_async + async def begin_create_or_update_at_management_group_scope( + self, group_id: str, deployment_name: str, parameters: Union[_models.ScopedDeployment, IO], **kwargs: Any + ) -> AsyncLROPoller[_models.DeploymentExtended]: + """Deploys resources at management group scope. + + You can provide the template and parameters directly in the request or link to JSON files. + + :param group_id: The management group ID. Required. + :type group_id: str + :param deployment_name: The name of the deployment. Required. + :type deployment_name: str + :param parameters: Additional parameters supplied to the operation. Is either a model type or a + IO type. Required. + :type parameters: ~azure.mgmt.resource.resources.v2020_10_01.models.ScopedDeployment or IO + :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. + Default value is None. + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be AsyncARMPolling. Pass in False for + this operation to not poll, or pass in your own initialized polling object for a personal + polling strategy. + :paramtype polling: bool or ~azure.core.polling.AsyncPollingMethod + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of AsyncLROPoller that returns either DeploymentExtended or the result of + cls(response) + :rtype: + ~azure.core.polling.AsyncLROPoller[~azure.mgmt.resource.resources.v2020_10_01.models.DeploymentExtended] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _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", "2020-10-01")) # type: str + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.DeploymentExtended] + polling = kwargs.pop("polling", True) # type: Union[bool, AsyncPollingMethod] + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token = kwargs.pop("continuation_token", None) # type: Optional[str] if cont_token is None: - raw_result = await self._create_or_update_at_management_group_scope_initial( + raw_result = await self._create_or_update_at_management_group_scope_initial( # type: ignore group_id=group_id, deployment_name=deployment_name, parameters=parameters, api_version=api_version, content_type=content_type, - cls=lambda x,y,z: x, + cls=lambda x, y, z: x, + headers=_headers, + params=_params, **kwargs ) - kwargs.pop('error_map', None) + kwargs.pop("error_map", None) def get_long_running_output(pipeline_response): - response = pipeline_response.http_response - deserialized = self._deserialize('DeploymentExtended', pipeline_response) + deserialized = self._deserialize("DeploymentExtended", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - - if polling is True: polling_method = AsyncARMPolling(lro_delay, **kwargs) - elif polling is False: polling_method = AsyncNoPolling() - else: polling_method = polling + if polling is True: + polling_method = cast(AsyncPollingMethod, AsyncARMPolling(lro_delay, **kwargs)) # type: AsyncPollingMethod + elif polling is False: + polling_method = cast(AsyncPollingMethod, AsyncNoPolling()) + else: + polling_method = polling if cont_token: return AsyncLROPoller.from_continuation_token( polling_method=polling_method, continuation_token=cont_token, client=self._client, - deserialization_callback=get_long_running_output + deserialization_callback=get_long_running_output, ) return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) - begin_create_or_update_at_management_group_scope.metadata = {'url': "/providers/Microsoft.Management/managementGroups/{groupId}/providers/Microsoft.Resources/deployments/{deploymentName}"} # type: ignore + begin_create_or_update_at_management_group_scope.metadata = {"url": "/providers/Microsoft.Management/managementGroups/{groupId}/providers/Microsoft.Resources/deployments/{deploymentName}"} # type: ignore @distributed_trace_async async def get_at_management_group_scope( - self, - group_id: str, - deployment_name: str, - **kwargs: Any - ) -> "_models.DeploymentExtended": + self, group_id: str, deployment_name: str, **kwargs: Any + ) -> _models.DeploymentExtended: """Gets a deployment. - :param group_id: The management group ID. + :param group_id: The management group ID. Required. :type group_id: str - :param deployment_name: The name of the deployment. + :param deployment_name: The name of the deployment. Required. :type deployment_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: DeploymentExtended, or the result of cls(response) + :return: DeploymentExtended or the result of cls(response) :rtype: ~azure.mgmt.resource.resources.v2020_10_01.models.DeploymentExtended - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.DeploymentExtended"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + 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', "2020-10-01") # type: str + api_version = kwargs.pop("api_version", _params.pop("api-version", "2020-10-01")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[_models.DeploymentExtended] - request = build_deployments_get_at_management_group_scope_request( group_id=group_id, deployment_name=deployment_name, api_version=api_version, - template_url=self.get_at_management_group_scope.metadata['url'], + template_url=self.get_at_management_group_scope.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) - deserialized = self._deserialize('DeploymentExtended', pipeline_response) + deserialized = self._deserialize("DeploymentExtended", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - get_at_management_group_scope.metadata = {'url': "/providers/Microsoft.Management/managementGroups/{groupId}/providers/Microsoft.Resources/deployments/{deploymentName}"} # type: ignore - + get_at_management_group_scope.metadata = {"url": "/providers/Microsoft.Management/managementGroups/{groupId}/providers/Microsoft.Resources/deployments/{deploymentName}"} # type: ignore @distributed_trace_async async def cancel_at_management_group_scope( # pylint: disable=inconsistent-return-statements - self, - group_id: str, - deployment_name: str, - **kwargs: Any + self, group_id: str, deployment_name: str, **kwargs: Any ) -> None: """Cancels a currently running template deployment. @@ -1949,38 +2564,44 @@ async def cancel_at_management_group_scope( # pylint: disable=inconsistent-retu deployment stops the currently running template deployment and leaves the resources partially deployed. - :param group_id: The management group ID. + :param group_id: The management group ID. Required. :type group_id: str - :param deployment_name: The name of the deployment. + :param deployment_name: The name of the deployment. Required. :type deployment_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: None, or the result of cls(response) + :return: None or the result of cls(response) :rtype: None - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType[None] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) - api_version = kwargs.pop('api_version', "2020-10-01") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2020-10-01")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[None] - request = build_deployments_cancel_at_management_group_scope_request( group_id=group_id, deployment_name=deployment_name, api_version=api_version, - template_url=self.cancel_at_management_group_scope.metadata['url'], + template_url=self.cancel_at_management_group_scope.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [204]: @@ -1990,43 +2611,52 @@ async def cancel_at_management_group_scope( # pylint: disable=inconsistent-retu if cls: return cls(pipeline_response, None, {}) - cancel_at_management_group_scope.metadata = {'url': "/providers/Microsoft.Management/managementGroups/{groupId}/providers/Microsoft.Resources/deployments/{deploymentName}/cancel"} # type: ignore - + cancel_at_management_group_scope.metadata = {"url": "/providers/Microsoft.Management/managementGroups/{groupId}/providers/Microsoft.Resources/deployments/{deploymentName}/cancel"} # type: ignore async def _validate_at_management_group_scope_initial( - self, - group_id: str, - deployment_name: str, - parameters: "_models.ScopedDeployment", - **kwargs: Any - ) -> Optional["_models.DeploymentValidateResult"]: - cls = kwargs.pop('cls', None) # type: ClsType[Optional["_models.DeploymentValidateResult"]] + self, group_id: str, deployment_name: str, parameters: Union[_models.ScopedDeployment, IO], **kwargs: Any + ) -> Optional[_models.DeploymentValidateResult]: error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', "2020-10-01") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + api_version = kwargs.pop("api_version", _params.pop("api-version", "2020-10-01")) # type: str + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[Optional[_models.DeploymentValidateResult]] - _json = self._serialize.body(parameters, 'ScopedDeployment') + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(parameters, (IO, bytes)): + _content = parameters + else: + _json = self._serialize.body(parameters, "ScopedDeployment") - request = build_deployments_validate_at_management_group_scope_request_initial( + request = build_deployments_validate_at_management_group_scope_request( group_id=group_id, deployment_name=deployment_name, api_version=api_version, content_type=content_type, json=_json, - template_url=self._validate_at_management_group_scope_initial.metadata['url'], + content=_content, + template_url=self._validate_at_management_group_scope_initial.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200, 202, 400]: @@ -2035,36 +2665,40 @@ async def _validate_at_management_group_scope_initial( deserialized = None if response.status_code == 200: - deserialized = self._deserialize('DeploymentValidateResult', pipeline_response) + deserialized = self._deserialize("DeploymentValidateResult", pipeline_response) if response.status_code == 400: - deserialized = self._deserialize('DeploymentValidateResult', pipeline_response) + deserialized = self._deserialize("DeploymentValidateResult", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - _validate_at_management_group_scope_initial.metadata = {'url': "/providers/Microsoft.Management/managementGroups/{groupId}/providers/Microsoft.Resources/deployments/{deploymentName}/validate"} # type: ignore - + _validate_at_management_group_scope_initial.metadata = {"url": "/providers/Microsoft.Management/managementGroups/{groupId}/providers/Microsoft.Resources/deployments/{deploymentName}/validate"} # type: ignore - @distributed_trace_async + @overload async def begin_validate_at_management_group_scope( self, group_id: str, deployment_name: str, - parameters: "_models.ScopedDeployment", + parameters: _models.ScopedDeployment, + *, + content_type: str = "application/json", **kwargs: Any - ) -> AsyncLROPoller["_models.DeploymentValidateResult"]: + ) -> AsyncLROPoller[_models.DeploymentValidateResult]: """Validates whether the specified template is syntactically correct and will be accepted by Azure Resource Manager.. - :param group_id: The management group ID. + :param group_id: The management group ID. Required. :type group_id: str - :param deployment_name: The name of the deployment. + :param deployment_name: The name of the deployment. Required. :type deployment_name: str - :param parameters: Parameters to validate. + :param parameters: Parameters to validate. Required. :type parameters: ~azure.mgmt.resource.resources.v2020_10_01.models.ScopedDeployment + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str :keyword callable cls: A custom type or function that will be passed the direct response :keyword str continuation_token: A continuation token to restart a poller from a saved state. :keyword polling: By default, your polling method will be AsyncARMPolling. Pass in False for @@ -2077,85 +2711,166 @@ async def begin_validate_at_management_group_scope( result of cls(response) :rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.resource.resources.v2020_10_01.models.DeploymentValidateResult] - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - api_version = kwargs.pop('api_version', "2020-10-01") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] - polling = kwargs.pop('polling', True) # type: Union[bool, AsyncPollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType["_models.DeploymentValidateResult"] - lro_delay = kwargs.pop( - 'polling_interval', - self._config.polling_interval - ) - cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] - if cont_token is None: - raw_result = await self._validate_at_management_group_scope_initial( - group_id=group_id, - deployment_name=deployment_name, - parameters=parameters, - api_version=api_version, - content_type=content_type, - cls=lambda x,y,z: x, - **kwargs - ) - kwargs.pop('error_map', None) - - def get_long_running_output(pipeline_response): - response = pipeline_response.http_response - deserialized = self._deserialize('DeploymentValidateResult', pipeline_response) - if cls: - return cls(pipeline_response, deserialized, {}) - return deserialized - - if polling is True: polling_method = AsyncARMPolling(lro_delay, **kwargs) - elif polling is False: polling_method = AsyncNoPolling() - else: polling_method = polling - if cont_token: - return AsyncLROPoller.from_continuation_token( - polling_method=polling_method, + @overload + async def begin_validate_at_management_group_scope( + self, + group_id: str, + deployment_name: str, + parameters: IO, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> AsyncLROPoller[_models.DeploymentValidateResult]: + """Validates whether the specified template is syntactically correct and will be accepted by Azure + Resource Manager.. + + :param group_id: The management group ID. Required. + :type group_id: str + :param deployment_name: The name of the deployment. Required. + :type deployment_name: str + :param parameters: Parameters to validate. Required. + :type parameters: IO + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be AsyncARMPolling. Pass in False for + this operation to not poll, or pass in your own initialized polling object for a personal + polling strategy. + :paramtype polling: bool or ~azure.core.polling.AsyncPollingMethod + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of AsyncLROPoller that returns either DeploymentValidateResult or the + result of cls(response) + :rtype: + ~azure.core.polling.AsyncLROPoller[~azure.mgmt.resource.resources.v2020_10_01.models.DeploymentValidateResult] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace_async + async def begin_validate_at_management_group_scope( + self, group_id: str, deployment_name: str, parameters: Union[_models.ScopedDeployment, IO], **kwargs: Any + ) -> AsyncLROPoller[_models.DeploymentValidateResult]: + """Validates whether the specified template is syntactically correct and will be accepted by Azure + Resource Manager.. + + :param group_id: The management group ID. Required. + :type group_id: str + :param deployment_name: The name of the deployment. Required. + :type deployment_name: str + :param parameters: Parameters to validate. Is either a model type or a IO type. Required. + :type parameters: ~azure.mgmt.resource.resources.v2020_10_01.models.ScopedDeployment or IO + :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. + Default value is None. + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be AsyncARMPolling. Pass in False for + this operation to not poll, or pass in your own initialized polling object for a personal + polling strategy. + :paramtype polling: bool or ~azure.core.polling.AsyncPollingMethod + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of AsyncLROPoller that returns either DeploymentValidateResult or the + result of cls(response) + :rtype: + ~azure.core.polling.AsyncLROPoller[~azure.mgmt.resource.resources.v2020_10_01.models.DeploymentValidateResult] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _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", "2020-10-01")) # type: str + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.DeploymentValidateResult] + polling = kwargs.pop("polling", True) # type: Union[bool, AsyncPollingMethod] + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token = kwargs.pop("continuation_token", None) # type: Optional[str] + if cont_token is None: + raw_result = await self._validate_at_management_group_scope_initial( # type: ignore + group_id=group_id, + deployment_name=deployment_name, + parameters=parameters, + api_version=api_version, + content_type=content_type, + cls=lambda x, y, z: x, + headers=_headers, + params=_params, + **kwargs + ) + kwargs.pop("error_map", None) + + def get_long_running_output(pipeline_response): + deserialized = self._deserialize("DeploymentValidateResult", pipeline_response) + if cls: + return cls(pipeline_response, deserialized, {}) + return deserialized + + if polling is True: + polling_method = cast(AsyncPollingMethod, AsyncARMPolling(lro_delay, **kwargs)) # type: AsyncPollingMethod + elif polling is False: + polling_method = cast(AsyncPollingMethod, AsyncNoPolling()) + else: + polling_method = polling + if cont_token: + return AsyncLROPoller.from_continuation_token( + polling_method=polling_method, continuation_token=cont_token, client=self._client, - deserialization_callback=get_long_running_output + deserialization_callback=get_long_running_output, ) return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) - begin_validate_at_management_group_scope.metadata = {'url': "/providers/Microsoft.Management/managementGroups/{groupId}/providers/Microsoft.Resources/deployments/{deploymentName}/validate"} # type: ignore + begin_validate_at_management_group_scope.metadata = {"url": "/providers/Microsoft.Management/managementGroups/{groupId}/providers/Microsoft.Resources/deployments/{deploymentName}/validate"} # type: ignore async def _what_if_at_management_group_scope_initial( - self, - group_id: str, - deployment_name: str, - parameters: "_models.ScopedDeploymentWhatIf", - **kwargs: Any - ) -> Optional["_models.WhatIfOperationResult"]: - cls = kwargs.pop('cls', None) # type: ClsType[Optional["_models.WhatIfOperationResult"]] + self, group_id: str, deployment_name: str, parameters: Union[_models.ScopedDeploymentWhatIf, IO], **kwargs: Any + ) -> Optional[_models.WhatIfOperationResult]: error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) - api_version = kwargs.pop('api_version', "2020-10-01") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - _json = self._serialize.body(parameters, 'ScopedDeploymentWhatIf') + api_version = kwargs.pop("api_version", _params.pop("api-version", "2020-10-01")) # type: str + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[Optional[_models.WhatIfOperationResult]] - request = build_deployments_what_if_at_management_group_scope_request_initial( + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(parameters, (IO, bytes)): + _content = parameters + else: + _json = self._serialize.body(parameters, "ScopedDeploymentWhatIf") + + request = build_deployments_what_if_at_management_group_scope_request( group_id=group_id, deployment_name=deployment_name, api_version=api_version, content_type=content_type, json=_json, - template_url=self._what_if_at_management_group_scope_initial.metadata['url'], + content=_content, + template_url=self._what_if_at_management_group_scope_initial.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200, 202]: @@ -2165,38 +2880,41 @@ async def _what_if_at_management_group_scope_initial( deserialized = None response_headers = {} if response.status_code == 200: - deserialized = self._deserialize('WhatIfOperationResult', pipeline_response) + deserialized = self._deserialize("WhatIfOperationResult", pipeline_response) if response.status_code == 202: - response_headers['Location']=self._deserialize('str', response.headers.get('Location')) - response_headers['Retry-After']=self._deserialize('str', response.headers.get('Retry-After')) - + response_headers["Location"] = self._deserialize("str", response.headers.get("Location")) + response_headers["Retry-After"] = self._deserialize("str", response.headers.get("Retry-After")) if cls: return cls(pipeline_response, deserialized, response_headers) return deserialized - _what_if_at_management_group_scope_initial.metadata = {'url': "/providers/Microsoft.Management/managementGroups/{groupId}/providers/Microsoft.Resources/deployments/{deploymentName}/whatIf"} # type: ignore + _what_if_at_management_group_scope_initial.metadata = {"url": "/providers/Microsoft.Management/managementGroups/{groupId}/providers/Microsoft.Resources/deployments/{deploymentName}/whatIf"} # type: ignore - - @distributed_trace_async + @overload async def begin_what_if_at_management_group_scope( self, group_id: str, deployment_name: str, - parameters: "_models.ScopedDeploymentWhatIf", + parameters: _models.ScopedDeploymentWhatIf, + *, + content_type: str = "application/json", **kwargs: Any - ) -> AsyncLROPoller["_models.WhatIfOperationResult"]: + ) -> AsyncLROPoller[_models.WhatIfOperationResult]: """Returns changes that will be made by the deployment if executed at the scope of the management group. - :param group_id: The management group ID. + :param group_id: The management group ID. Required. :type group_id: str - :param deployment_name: The name of the deployment. + :param deployment_name: The name of the deployment. Required. :type deployment_name: str - :param parameters: Parameters to validate. + :param parameters: Parameters to validate. Required. :type parameters: ~azure.mgmt.resource.resources.v2020_10_01.models.ScopedDeploymentWhatIf + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str :keyword callable cls: A custom type or function that will be passed the direct response :keyword str continuation_token: A continuation token to restart a poller from a saved state. :keyword polling: By default, your polling method will be AsyncARMPolling. Pass in False for @@ -2209,119 +2927,191 @@ async def begin_what_if_at_management_group_scope( of cls(response) :rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.resource.resources.v2020_10_01.models.WhatIfOperationResult] - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - api_version = kwargs.pop('api_version', "2020-10-01") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] - polling = kwargs.pop('polling', True) # type: Union[bool, AsyncPollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType["_models.WhatIfOperationResult"] - lro_delay = kwargs.pop( - 'polling_interval', - self._config.polling_interval - ) - cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] + + @overload + async def begin_what_if_at_management_group_scope( + self, + group_id: str, + deployment_name: str, + parameters: IO, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> AsyncLROPoller[_models.WhatIfOperationResult]: + """Returns changes that will be made by the deployment if executed at the scope of the management + group. + + :param group_id: The management group ID. Required. + :type group_id: str + :param deployment_name: The name of the deployment. Required. + :type deployment_name: str + :param parameters: Parameters to validate. Required. + :type parameters: IO + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be AsyncARMPolling. Pass in False for + this operation to not poll, or pass in your own initialized polling object for a personal + polling strategy. + :paramtype polling: bool or ~azure.core.polling.AsyncPollingMethod + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of AsyncLROPoller that returns either WhatIfOperationResult or the result + of cls(response) + :rtype: + ~azure.core.polling.AsyncLROPoller[~azure.mgmt.resource.resources.v2020_10_01.models.WhatIfOperationResult] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace_async + async def begin_what_if_at_management_group_scope( + self, group_id: str, deployment_name: str, parameters: Union[_models.ScopedDeploymentWhatIf, IO], **kwargs: Any + ) -> AsyncLROPoller[_models.WhatIfOperationResult]: + """Returns changes that will be made by the deployment if executed at the scope of the management + group. + + :param group_id: The management group ID. Required. + :type group_id: str + :param deployment_name: The name of the deployment. Required. + :type deployment_name: str + :param parameters: Parameters to validate. Is either a model type or a IO type. Required. + :type parameters: ~azure.mgmt.resource.resources.v2020_10_01.models.ScopedDeploymentWhatIf or + IO + :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. + Default value is None. + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be AsyncARMPolling. Pass in False for + this operation to not poll, or pass in your own initialized polling object for a personal + polling strategy. + :paramtype polling: bool or ~azure.core.polling.AsyncPollingMethod + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of AsyncLROPoller that returns either WhatIfOperationResult or the result + of cls(response) + :rtype: + ~azure.core.polling.AsyncLROPoller[~azure.mgmt.resource.resources.v2020_10_01.models.WhatIfOperationResult] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _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", "2020-10-01")) # type: str + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.WhatIfOperationResult] + polling = kwargs.pop("polling", True) # type: Union[bool, AsyncPollingMethod] + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token = kwargs.pop("continuation_token", None) # type: Optional[str] if cont_token is None: - raw_result = await self._what_if_at_management_group_scope_initial( + raw_result = await self._what_if_at_management_group_scope_initial( # type: ignore group_id=group_id, deployment_name=deployment_name, parameters=parameters, api_version=api_version, content_type=content_type, - cls=lambda x,y,z: x, + cls=lambda x, y, z: x, + headers=_headers, + params=_params, **kwargs ) - kwargs.pop('error_map', None) + kwargs.pop("error_map", None) def get_long_running_output(pipeline_response): - response = pipeline_response.http_response - deserialized = self._deserialize('WhatIfOperationResult', pipeline_response) + deserialized = self._deserialize("WhatIfOperationResult", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - - if polling is True: polling_method = AsyncARMPolling(lro_delay, lro_options={'final-state-via': 'location'}, **kwargs) - elif polling is False: polling_method = AsyncNoPolling() - else: polling_method = polling + if polling is True: + polling_method = cast( + AsyncPollingMethod, AsyncARMPolling(lro_delay, lro_options={"final-state-via": "location"}, **kwargs) + ) # type: AsyncPollingMethod + elif polling is False: + polling_method = cast(AsyncPollingMethod, AsyncNoPolling()) + else: + polling_method = polling if cont_token: return AsyncLROPoller.from_continuation_token( polling_method=polling_method, continuation_token=cont_token, client=self._client, - deserialization_callback=get_long_running_output + deserialization_callback=get_long_running_output, ) return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) - begin_what_if_at_management_group_scope.metadata = {'url': "/providers/Microsoft.Management/managementGroups/{groupId}/providers/Microsoft.Resources/deployments/{deploymentName}/whatIf"} # type: ignore + begin_what_if_at_management_group_scope.metadata = {"url": "/providers/Microsoft.Management/managementGroups/{groupId}/providers/Microsoft.Resources/deployments/{deploymentName}/whatIf"} # type: ignore @distributed_trace_async async def export_template_at_management_group_scope( - self, - group_id: str, - deployment_name: str, - **kwargs: Any - ) -> "_models.DeploymentExportResult": + self, group_id: str, deployment_name: str, **kwargs: Any + ) -> _models.DeploymentExportResult: """Exports the template used for specified deployment. - :param group_id: The management group ID. + :param group_id: The management group ID. Required. :type group_id: str - :param deployment_name: The name of the deployment. + :param deployment_name: The name of the deployment. Required. :type deployment_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: DeploymentExportResult, or the result of cls(response) + :return: DeploymentExportResult or the result of cls(response) :rtype: ~azure.mgmt.resource.resources.v2020_10_01.models.DeploymentExportResult - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.DeploymentExportResult"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + 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', "2020-10-01") # type: str + api_version = kwargs.pop("api_version", _params.pop("api-version", "2020-10-01")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[_models.DeploymentExportResult] - request = build_deployments_export_template_at_management_group_scope_request( group_id=group_id, deployment_name=deployment_name, api_version=api_version, - template_url=self.export_template_at_management_group_scope.metadata['url'], + template_url=self.export_template_at_management_group_scope.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) - deserialized = self._deserialize('DeploymentExportResult', pipeline_response) + deserialized = self._deserialize("DeploymentExportResult", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - export_template_at_management_group_scope.metadata = {'url': "/providers/Microsoft.Management/managementGroups/{groupId}/providers/Microsoft.Resources/deployments/{deploymentName}/exportTemplate"} # type: ignore - + export_template_at_management_group_scope.metadata = {"url": "/providers/Microsoft.Management/managementGroups/{groupId}/providers/Microsoft.Resources/deployments/{deploymentName}/exportTemplate"} # type: ignore @distributed_trace def list_at_management_group_scope( - self, - group_id: str, - filter: Optional[str] = None, - top: Optional[int] = None, - **kwargs: Any - ) -> AsyncIterable["_models.DeploymentListResult"]: + self, group_id: str, filter: Optional[str] = None, top: Optional[int] = None, **kwargs: Any + ) -> AsyncIterable["_models.DeploymentExtended"]: """Get all the deployments for a management group. - :param group_id: The management group ID. + :param group_id: The management group ID. Required. :type group_id: str :param filter: The filter to apply on the operation. For example, you can use $filter=provisioningState eq '{state}'. Default value is None. @@ -2330,40 +3120,48 @@ def list_at_management_group_scope( value is None. :type top: int :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either DeploymentListResult or the result of - cls(response) + :return: An iterator like instance of either DeploymentExtended or the result of cls(response) :rtype: - ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.resource.resources.v2020_10_01.models.DeploymentListResult] - :raises: ~azure.core.exceptions.HttpResponseError + ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.resource.resources.v2020_10_01.models.DeploymentExtended] + :raises ~azure.core.exceptions.HttpResponseError: """ - api_version = kwargs.pop('api_version', "2020-10-01") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2020-10-01")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[_models.DeploymentListResult] - cls = kwargs.pop('cls', None) # type: ClsType["_models.DeploymentListResult"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) + def prepare_request(next_link=None): if not next_link: - + request = build_deployments_list_at_management_group_scope_request( group_id=group_id, - api_version=api_version, filter=filter, top=top, - template_url=self.list_at_management_group_scope.metadata['url'], + api_version=api_version, + template_url=self.list_at_management_group_scope.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore else: - - request = build_deployments_list_at_management_group_scope_request( - group_id=group_id, - template_url=next_link, - ) + # make call to next link with the client's api-version + _parsed_next_link = urlparse(next_link) + _next_request_params = case_insensitive_dict(parse_qs(_parsed_next_link.query)) + _next_request_params["api-version"] = self._config.api_version + request = HttpRequest("GET", urljoin(next_link, _parsed_next_link.path), params=_next_request_params) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore request.method = "GET" return request @@ -2377,10 +3175,8 @@ async def extract_data(pipeline_response): async def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) response = pipeline_response.http_response @@ -2390,40 +3186,42 @@ async def get_next(next_link=None): return pipeline_response + return AsyncItemPaged(get_next, extract_data) - return AsyncItemPaged( - get_next, extract_data - ) - list_at_management_group_scope.metadata = {'url': "/providers/Microsoft.Management/managementGroups/{groupId}/providers/Microsoft.Resources/deployments/"} # type: ignore + list_at_management_group_scope.metadata = {"url": "/providers/Microsoft.Management/managementGroups/{groupId}/providers/Microsoft.Resources/deployments/"} # type: ignore async def _delete_at_subscription_scope_initial( # pylint: disable=inconsistent-return-statements - self, - deployment_name: str, - **kwargs: Any + self, deployment_name: str, **kwargs: Any ) -> None: - cls = kwargs.pop('cls', None) # type: ClsType[None] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + 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', "2020-10-01") # type: str + api_version = kwargs.pop("api_version", _params.pop("api-version", "2020-10-01")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[None] - - request = build_deployments_delete_at_subscription_scope_request_initial( + request = build_deployments_delete_at_subscription_scope_request( deployment_name=deployment_name, subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self._delete_at_subscription_scope_initial.metadata['url'], + template_url=self._delete_at_subscription_scope_initial.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [202, 204]: @@ -2433,15 +3231,10 @@ async def _delete_at_subscription_scope_initial( # pylint: disable=inconsistent if cls: return cls(pipeline_response, None, {}) - _delete_at_subscription_scope_initial.metadata = {'url': "/subscriptions/{subscriptionId}/providers/Microsoft.Resources/deployments/{deploymentName}"} # type: ignore - + _delete_at_subscription_scope_initial.metadata = {"url": "/subscriptions/{subscriptionId}/providers/Microsoft.Resources/deployments/{deploymentName}"} # type: ignore @distributed_trace_async - async def begin_delete_at_subscription_scope( # pylint: disable=inconsistent-return-statements - self, - deployment_name: str, - **kwargs: Any - ) -> AsyncLROPoller[None]: + async def begin_delete_at_subscription_scope(self, deployment_name: str, **kwargs: Any) -> AsyncLROPoller[None]: """Deletes a deployment from the deployment history. A template deployment that is currently running cannot be deleted. Deleting a template @@ -2452,7 +3245,7 @@ async def begin_delete_at_subscription_scope( # pylint: disable=inconsistent-re process finishes, the URI in the Location header returns a status of 204 on success. If the asynchronous request failed, the URI in the Location header returns an error-level status code. - :param deployment_name: The name of the deployment. + :param deployment_name: The name of the deployment. Required. :type deployment_name: str :keyword callable cls: A custom type or function that will be passed the direct response :keyword str continuation_token: A continuation token to restart a poller from a saved state. @@ -2464,82 +3257,88 @@ async def begin_delete_at_subscription_scope( # pylint: disable=inconsistent-re Retry-After header is present. :return: An instance of AsyncLROPoller that returns either None or the result of cls(response) :rtype: ~azure.core.polling.AsyncLROPoller[None] - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - api_version = kwargs.pop('api_version', "2020-10-01") # type: str - polling = kwargs.pop('polling', True) # type: Union[bool, AsyncPollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType[None] - lro_delay = kwargs.pop( - 'polling_interval', - self._config.polling_interval - ) - cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2020-10-01")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[None] + polling = kwargs.pop("polling", True) # type: Union[bool, AsyncPollingMethod] + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token = kwargs.pop("continuation_token", None) # type: Optional[str] if cont_token is None: - raw_result = await self._delete_at_subscription_scope_initial( + raw_result = await self._delete_at_subscription_scope_initial( # type: ignore deployment_name=deployment_name, api_version=api_version, - cls=lambda x,y,z: x, + cls=lambda x, y, z: x, + headers=_headers, + params=_params, **kwargs ) - kwargs.pop('error_map', None) + kwargs.pop("error_map", None) - def get_long_running_output(pipeline_response): + def get_long_running_output(pipeline_response): # pylint: disable=inconsistent-return-statements if cls: return cls(pipeline_response, None, {}) - - if polling is True: polling_method = AsyncARMPolling(lro_delay, **kwargs) - elif polling is False: polling_method = AsyncNoPolling() - else: polling_method = polling + if polling is True: + polling_method = cast(AsyncPollingMethod, AsyncARMPolling(lro_delay, **kwargs)) # type: AsyncPollingMethod + elif polling is False: + polling_method = cast(AsyncPollingMethod, AsyncNoPolling()) + else: + polling_method = polling if cont_token: return AsyncLROPoller.from_continuation_token( polling_method=polling_method, continuation_token=cont_token, client=self._client, - deserialization_callback=get_long_running_output + deserialization_callback=get_long_running_output, ) return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) - begin_delete_at_subscription_scope.metadata = {'url': "/subscriptions/{subscriptionId}/providers/Microsoft.Resources/deployments/{deploymentName}"} # type: ignore + begin_delete_at_subscription_scope.metadata = {"url": "/subscriptions/{subscriptionId}/providers/Microsoft.Resources/deployments/{deploymentName}"} # type: ignore @distributed_trace_async - async def check_existence_at_subscription_scope( - self, - deployment_name: str, - **kwargs: Any - ) -> bool: + async def check_existence_at_subscription_scope(self, deployment_name: str, **kwargs: Any) -> bool: """Checks whether the deployment exists. - :param deployment_name: The name of the deployment. + :param deployment_name: The name of the deployment. Required. :type deployment_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: bool, or the result of cls(response) + :return: bool or the result of cls(response) :rtype: bool - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType[None] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + 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', "2020-10-01") # type: str + api_version = kwargs.pop("api_version", _params.pop("api-version", "2020-10-01")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[None] - request = build_deployments_check_existence_at_subscription_scope_request( deployment_name=deployment_name, subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.check_existence_at_subscription_scope.metadata['url'], + template_url=self.check_existence_at_subscription_scope.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [204, 404]: @@ -2550,42 +3349,52 @@ async def check_existence_at_subscription_scope( return cls(pipeline_response, None, {}) return 200 <= response.status_code <= 299 - check_existence_at_subscription_scope.metadata = {'url': "/subscriptions/{subscriptionId}/providers/Microsoft.Resources/deployments/{deploymentName}"} # type: ignore - + check_existence_at_subscription_scope.metadata = {"url": "/subscriptions/{subscriptionId}/providers/Microsoft.Resources/deployments/{deploymentName}"} # type: ignore async def _create_or_update_at_subscription_scope_initial( - self, - deployment_name: str, - parameters: "_models.Deployment", - **kwargs: Any - ) -> "_models.DeploymentExtended": - cls = kwargs.pop('cls', None) # type: ClsType["_models.DeploymentExtended"] + self, deployment_name: str, parameters: Union[_models.Deployment, IO], **kwargs: Any + ) -> _models.DeploymentExtended: error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', "2020-10-01") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + api_version = kwargs.pop("api_version", _params.pop("api-version", "2020-10-01")) # type: str + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.DeploymentExtended] - _json = self._serialize.body(parameters, 'Deployment') + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(parameters, (IO, bytes)): + _content = parameters + else: + _json = self._serialize.body(parameters, "Deployment") - request = build_deployments_create_or_update_at_subscription_scope_request_initial( + request = build_deployments_create_or_update_at_subscription_scope_request( deployment_name=deployment_name, subscription_id=self._config.subscription_id, api_version=api_version, content_type=content_type, json=_json, - template_url=self._create_or_update_at_subscription_scope_initial.metadata['url'], + content=_content, + template_url=self._create_or_update_at_subscription_scope_initial.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200, 201]: @@ -2593,34 +3402,38 @@ async def _create_or_update_at_subscription_scope_initial( raise HttpResponseError(response=response, error_format=ARMErrorFormat) if response.status_code == 200: - deserialized = self._deserialize('DeploymentExtended', pipeline_response) + deserialized = self._deserialize("DeploymentExtended", pipeline_response) if response.status_code == 201: - deserialized = self._deserialize('DeploymentExtended', pipeline_response) + deserialized = self._deserialize("DeploymentExtended", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - _create_or_update_at_subscription_scope_initial.metadata = {'url': "/subscriptions/{subscriptionId}/providers/Microsoft.Resources/deployments/{deploymentName}"} # type: ignore - + _create_or_update_at_subscription_scope_initial.metadata = {"url": "/subscriptions/{subscriptionId}/providers/Microsoft.Resources/deployments/{deploymentName}"} # type: ignore - @distributed_trace_async + @overload async def begin_create_or_update_at_subscription_scope( self, deployment_name: str, - parameters: "_models.Deployment", + parameters: _models.Deployment, + *, + content_type: str = "application/json", **kwargs: Any - ) -> AsyncLROPoller["_models.DeploymentExtended"]: + ) -> AsyncLROPoller[_models.DeploymentExtended]: """Deploys resources at subscription scope. You can provide the template and parameters directly in the request or link to JSON files. - :param deployment_name: The name of the deployment. + :param deployment_name: The name of the deployment. Required. :type deployment_name: str - :param parameters: Additional parameters supplied to the operation. + :param parameters: Additional parameters supplied to the operation. Required. :type parameters: ~azure.mgmt.resource.resources.v2020_10_01.models.Deployment + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str :keyword callable cls: A custom type or function that will be passed the direct response :keyword str continuation_token: A continuation token to restart a poller from a saved state. :keyword polling: By default, your polling method will be AsyncARMPolling. Pass in False for @@ -2633,109 +3446,172 @@ async def begin_create_or_update_at_subscription_scope( cls(response) :rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.resource.resources.v2020_10_01.models.DeploymentExtended] - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - api_version = kwargs.pop('api_version', "2020-10-01") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] - polling = kwargs.pop('polling', True) # type: Union[bool, AsyncPollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType["_models.DeploymentExtended"] - lro_delay = kwargs.pop( - 'polling_interval', - self._config.polling_interval - ) - cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] + + @overload + async def begin_create_or_update_at_subscription_scope( + self, deployment_name: str, parameters: IO, *, content_type: str = "application/json", **kwargs: Any + ) -> AsyncLROPoller[_models.DeploymentExtended]: + """Deploys resources at subscription scope. + + You can provide the template and parameters directly in the request or link to JSON files. + + :param deployment_name: The name of the deployment. Required. + :type deployment_name: str + :param parameters: Additional parameters supplied to the operation. Required. + :type parameters: IO + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be AsyncARMPolling. Pass in False for + this operation to not poll, or pass in your own initialized polling object for a personal + polling strategy. + :paramtype polling: bool or ~azure.core.polling.AsyncPollingMethod + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of AsyncLROPoller that returns either DeploymentExtended or the result of + cls(response) + :rtype: + ~azure.core.polling.AsyncLROPoller[~azure.mgmt.resource.resources.v2020_10_01.models.DeploymentExtended] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace_async + async def begin_create_or_update_at_subscription_scope( + self, deployment_name: str, parameters: Union[_models.Deployment, IO], **kwargs: Any + ) -> AsyncLROPoller[_models.DeploymentExtended]: + """Deploys resources at subscription scope. + + You can provide the template and parameters directly in the request or link to JSON files. + + :param deployment_name: The name of the deployment. Required. + :type deployment_name: str + :param parameters: Additional parameters supplied to the operation. Is either a model type or a + IO type. Required. + :type parameters: ~azure.mgmt.resource.resources.v2020_10_01.models.Deployment or IO + :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. + Default value is None. + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be AsyncARMPolling. Pass in False for + this operation to not poll, or pass in your own initialized polling object for a personal + polling strategy. + :paramtype polling: bool or ~azure.core.polling.AsyncPollingMethod + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of AsyncLROPoller that returns either DeploymentExtended or the result of + cls(response) + :rtype: + ~azure.core.polling.AsyncLROPoller[~azure.mgmt.resource.resources.v2020_10_01.models.DeploymentExtended] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _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", "2020-10-01")) # type: str + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.DeploymentExtended] + polling = kwargs.pop("polling", True) # type: Union[bool, AsyncPollingMethod] + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token = kwargs.pop("continuation_token", None) # type: Optional[str] if cont_token is None: - raw_result = await self._create_or_update_at_subscription_scope_initial( + raw_result = await self._create_or_update_at_subscription_scope_initial( # type: ignore deployment_name=deployment_name, parameters=parameters, api_version=api_version, content_type=content_type, - cls=lambda x,y,z: x, + cls=lambda x, y, z: x, + headers=_headers, + params=_params, **kwargs ) - kwargs.pop('error_map', None) + kwargs.pop("error_map", None) def get_long_running_output(pipeline_response): - response = pipeline_response.http_response - deserialized = self._deserialize('DeploymentExtended', pipeline_response) + deserialized = self._deserialize("DeploymentExtended", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - - if polling is True: polling_method = AsyncARMPolling(lro_delay, **kwargs) - elif polling is False: polling_method = AsyncNoPolling() - else: polling_method = polling + if polling is True: + polling_method = cast(AsyncPollingMethod, AsyncARMPolling(lro_delay, **kwargs)) # type: AsyncPollingMethod + elif polling is False: + polling_method = cast(AsyncPollingMethod, AsyncNoPolling()) + else: + polling_method = polling if cont_token: return AsyncLROPoller.from_continuation_token( polling_method=polling_method, continuation_token=cont_token, client=self._client, - deserialization_callback=get_long_running_output + deserialization_callback=get_long_running_output, ) return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) - begin_create_or_update_at_subscription_scope.metadata = {'url': "/subscriptions/{subscriptionId}/providers/Microsoft.Resources/deployments/{deploymentName}"} # type: ignore + begin_create_or_update_at_subscription_scope.metadata = {"url": "/subscriptions/{subscriptionId}/providers/Microsoft.Resources/deployments/{deploymentName}"} # type: ignore @distributed_trace_async - async def get_at_subscription_scope( - self, - deployment_name: str, - **kwargs: Any - ) -> "_models.DeploymentExtended": + async def get_at_subscription_scope(self, deployment_name: str, **kwargs: Any) -> _models.DeploymentExtended: """Gets a deployment. - :param deployment_name: The name of the deployment. + :param deployment_name: The name of the deployment. Required. :type deployment_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: DeploymentExtended, or the result of cls(response) + :return: DeploymentExtended or the result of cls(response) :rtype: ~azure.mgmt.resource.resources.v2020_10_01.models.DeploymentExtended - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.DeploymentExtended"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) - api_version = kwargs.pop('api_version', "2020-10-01") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2020-10-01")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[_models.DeploymentExtended] - request = build_deployments_get_at_subscription_scope_request( deployment_name=deployment_name, subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.get_at_subscription_scope.metadata['url'], + template_url=self.get_at_subscription_scope.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) - deserialized = self._deserialize('DeploymentExtended', pipeline_response) + deserialized = self._deserialize("DeploymentExtended", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - get_at_subscription_scope.metadata = {'url': "/subscriptions/{subscriptionId}/providers/Microsoft.Resources/deployments/{deploymentName}"} # type: ignore - + get_at_subscription_scope.metadata = {"url": "/subscriptions/{subscriptionId}/providers/Microsoft.Resources/deployments/{deploymentName}"} # type: ignore @distributed_trace_async async def cancel_at_subscription_scope( # pylint: disable=inconsistent-return-statements - self, - deployment_name: str, - **kwargs: Any + self, deployment_name: str, **kwargs: Any ) -> None: """Cancels a currently running template deployment. @@ -2744,36 +3620,42 @@ async def cancel_at_subscription_scope( # pylint: disable=inconsistent-return-s deployment stops the currently running template deployment and leaves the resources partially deployed. - :param deployment_name: The name of the deployment. + :param deployment_name: The name of the deployment. Required. :type deployment_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: None, or the result of cls(response) + :return: None or the result of cls(response) :rtype: None - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType[None] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) - api_version = kwargs.pop('api_version', "2020-10-01") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2020-10-01")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[None] - request = build_deployments_cancel_at_subscription_scope_request( deployment_name=deployment_name, subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.cancel_at_subscription_scope.metadata['url'], + template_url=self.cancel_at_subscription_scope.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [204]: @@ -2783,42 +3665,52 @@ async def cancel_at_subscription_scope( # pylint: disable=inconsistent-return-s if cls: return cls(pipeline_response, None, {}) - cancel_at_subscription_scope.metadata = {'url': "/subscriptions/{subscriptionId}/providers/Microsoft.Resources/deployments/{deploymentName}/cancel"} # type: ignore - + cancel_at_subscription_scope.metadata = {"url": "/subscriptions/{subscriptionId}/providers/Microsoft.Resources/deployments/{deploymentName}/cancel"} # type: ignore async def _validate_at_subscription_scope_initial( - self, - deployment_name: str, - parameters: "_models.Deployment", - **kwargs: Any - ) -> Optional["_models.DeploymentValidateResult"]: - cls = kwargs.pop('cls', None) # type: ClsType[Optional["_models.DeploymentValidateResult"]] + self, deployment_name: str, parameters: Union[_models.Deployment, IO], **kwargs: Any + ) -> Optional[_models.DeploymentValidateResult]: error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) - api_version = kwargs.pop('api_version', "2020-10-01") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - _json = self._serialize.body(parameters, 'Deployment') + api_version = kwargs.pop("api_version", _params.pop("api-version", "2020-10-01")) # type: str + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[Optional[_models.DeploymentValidateResult]] - request = build_deployments_validate_at_subscription_scope_request_initial( + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(parameters, (IO, bytes)): + _content = parameters + else: + _json = self._serialize.body(parameters, "Deployment") + + request = build_deployments_validate_at_subscription_scope_request( deployment_name=deployment_name, subscription_id=self._config.subscription_id, api_version=api_version, content_type=content_type, json=_json, - template_url=self._validate_at_subscription_scope_initial.metadata['url'], + content=_content, + template_url=self._validate_at_subscription_scope_initial.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200, 202, 400]: @@ -2827,33 +3719,37 @@ async def _validate_at_subscription_scope_initial( deserialized = None if response.status_code == 200: - deserialized = self._deserialize('DeploymentValidateResult', pipeline_response) + deserialized = self._deserialize("DeploymentValidateResult", pipeline_response) if response.status_code == 400: - deserialized = self._deserialize('DeploymentValidateResult', pipeline_response) + deserialized = self._deserialize("DeploymentValidateResult", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - _validate_at_subscription_scope_initial.metadata = {'url': "/subscriptions/{subscriptionId}/providers/Microsoft.Resources/deployments/{deploymentName}/validate"} # type: ignore + _validate_at_subscription_scope_initial.metadata = {"url": "/subscriptions/{subscriptionId}/providers/Microsoft.Resources/deployments/{deploymentName}/validate"} # type: ignore - - @distributed_trace_async + @overload async def begin_validate_at_subscription_scope( self, deployment_name: str, - parameters: "_models.Deployment", + parameters: _models.Deployment, + *, + content_type: str = "application/json", **kwargs: Any - ) -> AsyncLROPoller["_models.DeploymentValidateResult"]: + ) -> AsyncLROPoller[_models.DeploymentValidateResult]: """Validates whether the specified template is syntactically correct and will be accepted by Azure Resource Manager.. - :param deployment_name: The name of the deployment. + :param deployment_name: The name of the deployment. Required. :type deployment_name: str - :param parameters: Parameters to validate. + :param parameters: Parameters to validate. Required. :type parameters: ~azure.mgmt.resource.resources.v2020_10_01.models.Deployment + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str :keyword callable cls: A custom type or function that will be passed the direct response :keyword str continuation_token: A continuation token to restart a poller from a saved state. :keyword polling: By default, your polling method will be AsyncARMPolling. Pass in False for @@ -2866,83 +3762,155 @@ async def begin_validate_at_subscription_scope( result of cls(response) :rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.resource.resources.v2020_10_01.models.DeploymentValidateResult] - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - api_version = kwargs.pop('api_version', "2020-10-01") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] - polling = kwargs.pop('polling', True) # type: Union[bool, AsyncPollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType["_models.DeploymentValidateResult"] - lro_delay = kwargs.pop( - 'polling_interval', - self._config.polling_interval - ) - cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] - if cont_token is None: - raw_result = await self._validate_at_subscription_scope_initial( - deployment_name=deployment_name, - parameters=parameters, - api_version=api_version, - content_type=content_type, - cls=lambda x,y,z: x, - **kwargs - ) - kwargs.pop('error_map', None) - - def get_long_running_output(pipeline_response): - response = pipeline_response.http_response - deserialized = self._deserialize('DeploymentValidateResult', pipeline_response) - if cls: - return cls(pipeline_response, deserialized, {}) - return deserialized + @overload + async def begin_validate_at_subscription_scope( + self, deployment_name: str, parameters: IO, *, content_type: str = "application/json", **kwargs: Any + ) -> AsyncLROPoller[_models.DeploymentValidateResult]: + """Validates whether the specified template is syntactically correct and will be accepted by Azure + Resource Manager.. - if polling is True: polling_method = AsyncARMPolling(lro_delay, **kwargs) - elif polling is False: polling_method = AsyncNoPolling() - else: polling_method = polling - if cont_token: - return AsyncLROPoller.from_continuation_token( - polling_method=polling_method, - continuation_token=cont_token, - client=self._client, - deserialization_callback=get_long_running_output + :param deployment_name: The name of the deployment. Required. + :type deployment_name: str + :param parameters: Parameters to validate. Required. + :type parameters: IO + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be AsyncARMPolling. Pass in False for + this operation to not poll, or pass in your own initialized polling object for a personal + polling strategy. + :paramtype polling: bool or ~azure.core.polling.AsyncPollingMethod + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of AsyncLROPoller that returns either DeploymentValidateResult or the + result of cls(response) + :rtype: + ~azure.core.polling.AsyncLROPoller[~azure.mgmt.resource.resources.v2020_10_01.models.DeploymentValidateResult] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace_async + async def begin_validate_at_subscription_scope( + self, deployment_name: str, parameters: Union[_models.Deployment, IO], **kwargs: Any + ) -> AsyncLROPoller[_models.DeploymentValidateResult]: + """Validates whether the specified template is syntactically correct and will be accepted by Azure + Resource Manager.. + + :param deployment_name: The name of the deployment. Required. + :type deployment_name: str + :param parameters: Parameters to validate. Is either a model type or a IO type. Required. + :type parameters: ~azure.mgmt.resource.resources.v2020_10_01.models.Deployment or IO + :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. + Default value is None. + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be AsyncARMPolling. Pass in False for + this operation to not poll, or pass in your own initialized polling object for a personal + polling strategy. + :paramtype polling: bool or ~azure.core.polling.AsyncPollingMethod + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of AsyncLROPoller that returns either DeploymentValidateResult or the + result of cls(response) + :rtype: + ~azure.core.polling.AsyncLROPoller[~azure.mgmt.resource.resources.v2020_10_01.models.DeploymentValidateResult] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _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", "2020-10-01")) # type: str + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.DeploymentValidateResult] + polling = kwargs.pop("polling", True) # type: Union[bool, AsyncPollingMethod] + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token = kwargs.pop("continuation_token", None) # type: Optional[str] + if cont_token is None: + raw_result = await self._validate_at_subscription_scope_initial( # type: ignore + deployment_name=deployment_name, + parameters=parameters, + api_version=api_version, + content_type=content_type, + cls=lambda x, y, z: x, + headers=_headers, + params=_params, + **kwargs + ) + kwargs.pop("error_map", None) + + def get_long_running_output(pipeline_response): + deserialized = self._deserialize("DeploymentValidateResult", pipeline_response) + if cls: + return cls(pipeline_response, deserialized, {}) + return deserialized + + if polling is True: + polling_method = cast(AsyncPollingMethod, AsyncARMPolling(lro_delay, **kwargs)) # type: AsyncPollingMethod + elif polling is False: + polling_method = cast(AsyncPollingMethod, AsyncNoPolling()) + else: + polling_method = polling + if cont_token: + return AsyncLROPoller.from_continuation_token( + polling_method=polling_method, + continuation_token=cont_token, + client=self._client, + deserialization_callback=get_long_running_output, ) return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) - begin_validate_at_subscription_scope.metadata = {'url': "/subscriptions/{subscriptionId}/providers/Microsoft.Resources/deployments/{deploymentName}/validate"} # type: ignore + begin_validate_at_subscription_scope.metadata = {"url": "/subscriptions/{subscriptionId}/providers/Microsoft.Resources/deployments/{deploymentName}/validate"} # type: ignore async def _what_if_at_subscription_scope_initial( - self, - deployment_name: str, - parameters: "_models.DeploymentWhatIf", - **kwargs: Any - ) -> Optional["_models.WhatIfOperationResult"]: - cls = kwargs.pop('cls', None) # type: ClsType[Optional["_models.WhatIfOperationResult"]] + self, deployment_name: str, parameters: Union[_models.DeploymentWhatIf, IO], **kwargs: Any + ) -> Optional[_models.WhatIfOperationResult]: error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) - api_version = kwargs.pop('api_version', "2020-10-01") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - _json = self._serialize.body(parameters, 'DeploymentWhatIf') + api_version = kwargs.pop("api_version", _params.pop("api-version", "2020-10-01")) # type: str + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[Optional[_models.WhatIfOperationResult]] - request = build_deployments_what_if_at_subscription_scope_request_initial( + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(parameters, (IO, bytes)): + _content = parameters + else: + _json = self._serialize.body(parameters, "DeploymentWhatIf") + + request = build_deployments_what_if_at_subscription_scope_request( deployment_name=deployment_name, subscription_id=self._config.subscription_id, api_version=api_version, content_type=content_type, json=_json, - template_url=self._what_if_at_subscription_scope_initial.metadata['url'], + content=_content, + template_url=self._what_if_at_subscription_scope_initial.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200, 202]: @@ -2952,35 +3920,38 @@ async def _what_if_at_subscription_scope_initial( deserialized = None response_headers = {} if response.status_code == 200: - deserialized = self._deserialize('WhatIfOperationResult', pipeline_response) + deserialized = self._deserialize("WhatIfOperationResult", pipeline_response) if response.status_code == 202: - response_headers['Location']=self._deserialize('str', response.headers.get('Location')) - response_headers['Retry-After']=self._deserialize('str', response.headers.get('Retry-After')) - + response_headers["Location"] = self._deserialize("str", response.headers.get("Location")) + response_headers["Retry-After"] = self._deserialize("str", response.headers.get("Retry-After")) if cls: return cls(pipeline_response, deserialized, response_headers) return deserialized - _what_if_at_subscription_scope_initial.metadata = {'url': "/subscriptions/{subscriptionId}/providers/Microsoft.Resources/deployments/{deploymentName}/whatIf"} # type: ignore + _what_if_at_subscription_scope_initial.metadata = {"url": "/subscriptions/{subscriptionId}/providers/Microsoft.Resources/deployments/{deploymentName}/whatIf"} # type: ignore - - @distributed_trace_async + @overload async def begin_what_if_at_subscription_scope( self, deployment_name: str, - parameters: "_models.DeploymentWhatIf", + parameters: _models.DeploymentWhatIf, + *, + content_type: str = "application/json", **kwargs: Any - ) -> AsyncLROPoller["_models.WhatIfOperationResult"]: + ) -> AsyncLROPoller[_models.WhatIfOperationResult]: """Returns changes that will be made by the deployment if executed at the scope of the subscription. - :param deployment_name: The name of the deployment. + :param deployment_name: The name of the deployment. Required. :type deployment_name: str - :param parameters: Parameters to What If. + :param parameters: Parameters to What If. Required. :type parameters: ~azure.mgmt.resource.resources.v2020_10_01.models.DeploymentWhatIf + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str :keyword callable cls: A custom type or function that will be passed the direct response :keyword str continuation_token: A continuation token to restart a poller from a saved state. :keyword polling: By default, your polling method will be AsyncARMPolling. Pass in False for @@ -2993,111 +3964,174 @@ async def begin_what_if_at_subscription_scope( of cls(response) :rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.resource.resources.v2020_10_01.models.WhatIfOperationResult] - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - api_version = kwargs.pop('api_version', "2020-10-01") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] - polling = kwargs.pop('polling', True) # type: Union[bool, AsyncPollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType["_models.WhatIfOperationResult"] - lro_delay = kwargs.pop( - 'polling_interval', - self._config.polling_interval - ) - cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] + + @overload + async def begin_what_if_at_subscription_scope( + self, deployment_name: str, parameters: IO, *, content_type: str = "application/json", **kwargs: Any + ) -> AsyncLROPoller[_models.WhatIfOperationResult]: + """Returns changes that will be made by the deployment if executed at the scope of the + subscription. + + :param deployment_name: The name of the deployment. Required. + :type deployment_name: str + :param parameters: Parameters to What If. Required. + :type parameters: IO + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be AsyncARMPolling. Pass in False for + this operation to not poll, or pass in your own initialized polling object for a personal + polling strategy. + :paramtype polling: bool or ~azure.core.polling.AsyncPollingMethod + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of AsyncLROPoller that returns either WhatIfOperationResult or the result + of cls(response) + :rtype: + ~azure.core.polling.AsyncLROPoller[~azure.mgmt.resource.resources.v2020_10_01.models.WhatIfOperationResult] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace_async + async def begin_what_if_at_subscription_scope( + self, deployment_name: str, parameters: Union[_models.DeploymentWhatIf, IO], **kwargs: Any + ) -> AsyncLROPoller[_models.WhatIfOperationResult]: + """Returns changes that will be made by the deployment if executed at the scope of the + subscription. + + :param deployment_name: The name of the deployment. Required. + :type deployment_name: str + :param parameters: Parameters to What If. Is either a model type or a IO type. Required. + :type parameters: ~azure.mgmt.resource.resources.v2020_10_01.models.DeploymentWhatIf or IO + :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. + Default value is None. + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be AsyncARMPolling. Pass in False for + this operation to not poll, or pass in your own initialized polling object for a personal + polling strategy. + :paramtype polling: bool or ~azure.core.polling.AsyncPollingMethod + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of AsyncLROPoller that returns either WhatIfOperationResult or the result + of cls(response) + :rtype: + ~azure.core.polling.AsyncLROPoller[~azure.mgmt.resource.resources.v2020_10_01.models.WhatIfOperationResult] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _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", "2020-10-01")) # type: str + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.WhatIfOperationResult] + polling = kwargs.pop("polling", True) # type: Union[bool, AsyncPollingMethod] + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token = kwargs.pop("continuation_token", None) # type: Optional[str] if cont_token is None: - raw_result = await self._what_if_at_subscription_scope_initial( + raw_result = await self._what_if_at_subscription_scope_initial( # type: ignore deployment_name=deployment_name, parameters=parameters, api_version=api_version, content_type=content_type, - cls=lambda x,y,z: x, + cls=lambda x, y, z: x, + headers=_headers, + params=_params, **kwargs ) - kwargs.pop('error_map', None) + kwargs.pop("error_map", None) def get_long_running_output(pipeline_response): - response = pipeline_response.http_response - deserialized = self._deserialize('WhatIfOperationResult', pipeline_response) + deserialized = self._deserialize("WhatIfOperationResult", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - - if polling is True: polling_method = AsyncARMPolling(lro_delay, lro_options={'final-state-via': 'location'}, **kwargs) - elif polling is False: polling_method = AsyncNoPolling() - else: polling_method = polling + if polling is True: + polling_method = cast( + AsyncPollingMethod, AsyncARMPolling(lro_delay, lro_options={"final-state-via": "location"}, **kwargs) + ) # type: AsyncPollingMethod + elif polling is False: + polling_method = cast(AsyncPollingMethod, AsyncNoPolling()) + else: + polling_method = polling if cont_token: return AsyncLROPoller.from_continuation_token( polling_method=polling_method, continuation_token=cont_token, client=self._client, - deserialization_callback=get_long_running_output + deserialization_callback=get_long_running_output, ) return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) - begin_what_if_at_subscription_scope.metadata = {'url': "/subscriptions/{subscriptionId}/providers/Microsoft.Resources/deployments/{deploymentName}/whatIf"} # type: ignore + begin_what_if_at_subscription_scope.metadata = {"url": "/subscriptions/{subscriptionId}/providers/Microsoft.Resources/deployments/{deploymentName}/whatIf"} # type: ignore @distributed_trace_async async def export_template_at_subscription_scope( - self, - deployment_name: str, - **kwargs: Any - ) -> "_models.DeploymentExportResult": + self, deployment_name: str, **kwargs: Any + ) -> _models.DeploymentExportResult: """Exports the template used for specified deployment. - :param deployment_name: The name of the deployment. + :param deployment_name: The name of the deployment. Required. :type deployment_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: DeploymentExportResult, or the result of cls(response) + :return: DeploymentExportResult or the result of cls(response) :rtype: ~azure.mgmt.resource.resources.v2020_10_01.models.DeploymentExportResult - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.DeploymentExportResult"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) - api_version = kwargs.pop('api_version', "2020-10-01") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2020-10-01")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[_models.DeploymentExportResult] - request = build_deployments_export_template_at_subscription_scope_request( deployment_name=deployment_name, subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.export_template_at_subscription_scope.metadata['url'], + template_url=self.export_template_at_subscription_scope.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) - deserialized = self._deserialize('DeploymentExportResult', pipeline_response) + deserialized = self._deserialize("DeploymentExportResult", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - export_template_at_subscription_scope.metadata = {'url': "/subscriptions/{subscriptionId}/providers/Microsoft.Resources/deployments/{deploymentName}/exportTemplate"} # type: ignore - + export_template_at_subscription_scope.metadata = {"url": "/subscriptions/{subscriptionId}/providers/Microsoft.Resources/deployments/{deploymentName}/exportTemplate"} # type: ignore @distributed_trace def list_at_subscription_scope( - self, - filter: Optional[str] = None, - top: Optional[int] = None, - **kwargs: Any - ) -> AsyncIterable["_models.DeploymentListResult"]: + self, filter: Optional[str] = None, top: Optional[int] = None, **kwargs: Any + ) -> AsyncIterable["_models.DeploymentExtended"]: """Get all the deployments for a subscription. :param filter: The filter to apply on the operation. For example, you can use @@ -3107,40 +4141,48 @@ def list_at_subscription_scope( value is None. :type top: int :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either DeploymentListResult or the result of - cls(response) + :return: An iterator like instance of either DeploymentExtended or the result of cls(response) :rtype: - ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.resource.resources.v2020_10_01.models.DeploymentListResult] - :raises: ~azure.core.exceptions.HttpResponseError + ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.resource.resources.v2020_10_01.models.DeploymentExtended] + :raises ~azure.core.exceptions.HttpResponseError: """ - api_version = kwargs.pop('api_version', "2020-10-01") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2020-10-01")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[_models.DeploymentListResult] - cls = kwargs.pop('cls', None) # type: ClsType["_models.DeploymentListResult"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) + def prepare_request(next_link=None): if not next_link: - + request = build_deployments_list_at_subscription_scope_request( subscription_id=self._config.subscription_id, - api_version=api_version, filter=filter, top=top, - template_url=self.list_at_subscription_scope.metadata['url'], + api_version=api_version, + template_url=self.list_at_subscription_scope.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore else: - - request = build_deployments_list_at_subscription_scope_request( - subscription_id=self._config.subscription_id, - template_url=next_link, - ) + # make call to next link with the client's api-version + _parsed_next_link = urlparse(next_link) + _next_request_params = case_insensitive_dict(parse_qs(_parsed_next_link.query)) + _next_request_params["api-version"] = self._config.api_version + request = HttpRequest("GET", urljoin(next_link, _parsed_next_link.path), params=_next_request_params) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore request.method = "GET" return request @@ -3154,10 +4196,8 @@ async def extract_data(pipeline_response): async def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) response = pipeline_response.http_response @@ -3167,42 +4207,43 @@ async def get_next(next_link=None): return pipeline_response + return AsyncItemPaged(get_next, extract_data) - return AsyncItemPaged( - get_next, extract_data - ) - list_at_subscription_scope.metadata = {'url': "/subscriptions/{subscriptionId}/providers/Microsoft.Resources/deployments/"} # type: ignore + list_at_subscription_scope.metadata = {"url": "/subscriptions/{subscriptionId}/providers/Microsoft.Resources/deployments/"} # type: ignore async def _delete_initial( # pylint: disable=inconsistent-return-statements - self, - resource_group_name: str, - deployment_name: str, - **kwargs: Any + self, resource_group_name: str, deployment_name: str, **kwargs: Any ) -> None: - cls = kwargs.pop('cls', None) # type: ClsType[None] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) - api_version = kwargs.pop('api_version', "2020-10-01") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - request = build_deployments_delete_request_initial( + api_version = kwargs.pop("api_version", _params.pop("api-version", "2020-10-01")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[None] + + request = build_deployments_delete_request( resource_group_name=resource_group_name, deployment_name=deployment_name, subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self._delete_initial.metadata['url'], + template_url=self._delete_initial.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [202, 204]: @@ -3212,16 +4253,10 @@ 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.Resources/deployments/{deploymentName}"} # type: ignore - + _delete_initial.metadata = {"url": "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/Microsoft.Resources/deployments/{deploymentName}"} # type: ignore @distributed_trace_async - async def begin_delete( # pylint: disable=inconsistent-return-statements - self, - resource_group_name: str, - deployment_name: str, - **kwargs: Any - ) -> AsyncLROPoller[None]: + async def begin_delete(self, resource_group_name: str, deployment_name: str, **kwargs: Any) -> AsyncLROPoller[None]: """Deletes a deployment from the deployment history. A template deployment that is currently running cannot be deleted. Deleting a template @@ -3234,9 +4269,9 @@ async def begin_delete( # pylint: disable=inconsistent-return-statements asynchronous request failed, the URI in the Location header returns an error-level status code. :param resource_group_name: The name of the resource group with the deployment to delete. The - name is case insensitive. + name is case insensitive. Required. :type resource_group_name: str - :param deployment_name: The name of the deployment. + :param deployment_name: The name of the deployment. Required. :type deployment_name: str :keyword callable cls: A custom type or function that will be passed the direct response :keyword str continuation_token: A continuation token to restart a poller from a saved state. @@ -3248,88 +4283,93 @@ async def begin_delete( # pylint: disable=inconsistent-return-statements Retry-After header is present. :return: An instance of AsyncLROPoller that returns either None or the result of cls(response) :rtype: ~azure.core.polling.AsyncLROPoller[None] - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - api_version = kwargs.pop('api_version', "2020-10-01") # type: str - polling = kwargs.pop('polling', True) # type: Union[bool, AsyncPollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType[None] - lro_delay = kwargs.pop( - 'polling_interval', - self._config.polling_interval - ) - cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2020-10-01")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[None] + polling = kwargs.pop("polling", True) # type: Union[bool, AsyncPollingMethod] + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token = kwargs.pop("continuation_token", None) # type: Optional[str] if cont_token is None: - raw_result = await self._delete_initial( + raw_result = await self._delete_initial( # type: ignore resource_group_name=resource_group_name, deployment_name=deployment_name, api_version=api_version, - cls=lambda x,y,z: x, + cls=lambda x, y, z: x, + headers=_headers, + params=_params, **kwargs ) - kwargs.pop('error_map', None) + kwargs.pop("error_map", None) - def get_long_running_output(pipeline_response): + def get_long_running_output(pipeline_response): # pylint: disable=inconsistent-return-statements if cls: return cls(pipeline_response, None, {}) - - if polling is True: polling_method = AsyncARMPolling(lro_delay, **kwargs) - elif polling is False: polling_method = AsyncNoPolling() - else: polling_method = polling + if polling is True: + polling_method = cast(AsyncPollingMethod, AsyncARMPolling(lro_delay, **kwargs)) # type: AsyncPollingMethod + elif polling is False: + polling_method = cast(AsyncPollingMethod, AsyncNoPolling()) + else: + polling_method = polling if cont_token: return AsyncLROPoller.from_continuation_token( polling_method=polling_method, continuation_token=cont_token, client=self._client, - deserialization_callback=get_long_running_output + deserialization_callback=get_long_running_output, ) return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) - begin_delete.metadata = {'url': "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/Microsoft.Resources/deployments/{deploymentName}"} # type: ignore + begin_delete.metadata = {"url": "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/Microsoft.Resources/deployments/{deploymentName}"} # type: ignore @distributed_trace_async - async def check_existence( - self, - resource_group_name: str, - deployment_name: str, - **kwargs: Any - ) -> bool: + async def check_existence(self, resource_group_name: str, deployment_name: str, **kwargs: Any) -> bool: """Checks whether the deployment exists. :param resource_group_name: The name of the resource group with the deployment to check. The - name is case insensitive. + name is case insensitive. Required. :type resource_group_name: str - :param deployment_name: The name of the deployment. + :param deployment_name: The name of the deployment. Required. :type deployment_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: bool, or the result of cls(response) + :return: bool or the result of cls(response) :rtype: bool - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType[None] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + 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', "2020-10-01") # type: str + api_version = kwargs.pop("api_version", _params.pop("api-version", "2020-10-01")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[None] - request = build_deployments_check_existence_request( resource_group_name=resource_group_name, deployment_name=deployment_name, subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.check_existence.metadata['url'], + template_url=self.check_existence.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [204, 404]: @@ -3340,44 +4380,53 @@ async def check_existence( return cls(pipeline_response, None, {}) return 200 <= response.status_code <= 299 - check_existence.metadata = {'url': "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/Microsoft.Resources/deployments/{deploymentName}"} # type: ignore - + check_existence.metadata = {"url": "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/Microsoft.Resources/deployments/{deploymentName}"} # type: ignore async def _create_or_update_initial( - self, - resource_group_name: str, - deployment_name: str, - parameters: "_models.Deployment", - **kwargs: Any - ) -> "_models.DeploymentExtended": - cls = kwargs.pop('cls', None) # type: ClsType["_models.DeploymentExtended"] + self, resource_group_name: str, deployment_name: str, parameters: Union[_models.Deployment, IO], **kwargs: Any + ) -> _models.DeploymentExtended: error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) - api_version = kwargs.pop('api_version', "2020-10-01") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - _json = self._serialize.body(parameters, 'Deployment') + api_version = kwargs.pop("api_version", _params.pop("api-version", "2020-10-01")) # type: str + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.DeploymentExtended] - request = build_deployments_create_or_update_request_initial( + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(parameters, (IO, bytes)): + _content = parameters + else: + _json = self._serialize.body(parameters, "Deployment") + + request = build_deployments_create_or_update_request( resource_group_name=resource_group_name, deployment_name=deployment_name, subscription_id=self._config.subscription_id, api_version=api_version, content_type=content_type, json=_json, - template_url=self._create_or_update_initial.metadata['url'], + content=_content, + template_url=self._create_or_update_initial.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200, 201]: @@ -3385,38 +4434,42 @@ async def _create_or_update_initial( raise HttpResponseError(response=response, error_format=ARMErrorFormat) if response.status_code == 200: - deserialized = self._deserialize('DeploymentExtended', pipeline_response) + deserialized = self._deserialize("DeploymentExtended", pipeline_response) if response.status_code == 201: - deserialized = self._deserialize('DeploymentExtended', pipeline_response) + deserialized = self._deserialize("DeploymentExtended", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - _create_or_update_initial.metadata = {'url': "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/Microsoft.Resources/deployments/{deploymentName}"} # type: ignore + _create_or_update_initial.metadata = {"url": "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/Microsoft.Resources/deployments/{deploymentName}"} # type: ignore - - @distributed_trace_async + @overload async def begin_create_or_update( self, resource_group_name: str, deployment_name: str, - parameters: "_models.Deployment", + parameters: _models.Deployment, + *, + content_type: str = "application/json", **kwargs: Any - ) -> AsyncLROPoller["_models.DeploymentExtended"]: + ) -> AsyncLROPoller[_models.DeploymentExtended]: """Deploys resources to a resource group. You can provide the template and parameters directly in the request or link to JSON files. :param resource_group_name: The name of the resource group to deploy the resources to. The name - is case insensitive. The resource group must already exist. + is case insensitive. The resource group must already exist. Required. :type resource_group_name: str - :param deployment_name: The name of the deployment. + :param deployment_name: The name of the deployment. Required. :type deployment_name: str - :param parameters: Additional parameters supplied to the operation. + :param parameters: Additional parameters supplied to the operation. Required. :type parameters: ~azure.mgmt.resource.resources.v2020_10_01.models.Deployment + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str :keyword callable cls: A custom type or function that will be passed the direct response :keyword str continuation_token: A continuation token to restart a poller from a saved state. :keyword polling: By default, your polling method will be AsyncARMPolling. Pass in False for @@ -3429,115 +4482,189 @@ async def begin_create_or_update( cls(response) :rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.resource.resources.v2020_10_01.models.DeploymentExtended] - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - api_version = kwargs.pop('api_version', "2020-10-01") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] - polling = kwargs.pop('polling', True) # type: Union[bool, AsyncPollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType["_models.DeploymentExtended"] - lro_delay = kwargs.pop( - 'polling_interval', - self._config.polling_interval - ) - cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] + + @overload + async def begin_create_or_update( + self, + resource_group_name: str, + deployment_name: str, + parameters: IO, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> AsyncLROPoller[_models.DeploymentExtended]: + """Deploys resources to a resource group. + + You can provide the template and parameters directly in the request or link to JSON files. + + :param resource_group_name: The name of the resource group to deploy the resources to. The name + is case insensitive. The resource group must already exist. Required. + :type resource_group_name: str + :param deployment_name: The name of the deployment. Required. + :type deployment_name: str + :param parameters: Additional parameters supplied to the operation. Required. + :type parameters: IO + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be AsyncARMPolling. Pass in False for + this operation to not poll, or pass in your own initialized polling object for a personal + polling strategy. + :paramtype polling: bool or ~azure.core.polling.AsyncPollingMethod + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of AsyncLROPoller that returns either DeploymentExtended or the result of + cls(response) + :rtype: + ~azure.core.polling.AsyncLROPoller[~azure.mgmt.resource.resources.v2020_10_01.models.DeploymentExtended] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace_async + async def begin_create_or_update( + self, resource_group_name: str, deployment_name: str, parameters: Union[_models.Deployment, IO], **kwargs: Any + ) -> AsyncLROPoller[_models.DeploymentExtended]: + """Deploys resources to a resource group. + + You can provide the template and parameters directly in the request or link to JSON files. + + :param resource_group_name: The name of the resource group to deploy the resources to. The name + is case insensitive. The resource group must already exist. Required. + :type resource_group_name: str + :param deployment_name: The name of the deployment. Required. + :type deployment_name: str + :param parameters: Additional parameters supplied to the operation. Is either a model type or a + IO type. Required. + :type parameters: ~azure.mgmt.resource.resources.v2020_10_01.models.Deployment or IO + :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. + Default value is None. + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be AsyncARMPolling. Pass in False for + this operation to not poll, or pass in your own initialized polling object for a personal + polling strategy. + :paramtype polling: bool or ~azure.core.polling.AsyncPollingMethod + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of AsyncLROPoller that returns either DeploymentExtended or the result of + cls(response) + :rtype: + ~azure.core.polling.AsyncLROPoller[~azure.mgmt.resource.resources.v2020_10_01.models.DeploymentExtended] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _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", "2020-10-01")) # type: str + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.DeploymentExtended] + polling = kwargs.pop("polling", True) # type: Union[bool, AsyncPollingMethod] + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token = kwargs.pop("continuation_token", None) # type: Optional[str] if cont_token is None: - raw_result = await self._create_or_update_initial( + raw_result = await self._create_or_update_initial( # type: ignore resource_group_name=resource_group_name, deployment_name=deployment_name, parameters=parameters, api_version=api_version, content_type=content_type, - cls=lambda x,y,z: x, + cls=lambda x, y, z: x, + headers=_headers, + params=_params, **kwargs ) - kwargs.pop('error_map', None) + kwargs.pop("error_map", None) def get_long_running_output(pipeline_response): - response = pipeline_response.http_response - deserialized = self._deserialize('DeploymentExtended', pipeline_response) + deserialized = self._deserialize("DeploymentExtended", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - - if polling is True: polling_method = AsyncARMPolling(lro_delay, **kwargs) - elif polling is False: polling_method = AsyncNoPolling() - else: polling_method = polling + if polling is True: + polling_method = cast(AsyncPollingMethod, AsyncARMPolling(lro_delay, **kwargs)) # type: AsyncPollingMethod + elif polling is False: + polling_method = cast(AsyncPollingMethod, AsyncNoPolling()) + else: + polling_method = polling if cont_token: return AsyncLROPoller.from_continuation_token( polling_method=polling_method, continuation_token=cont_token, client=self._client, - deserialization_callback=get_long_running_output + deserialization_callback=get_long_running_output, ) return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) - begin_create_or_update.metadata = {'url': "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/Microsoft.Resources/deployments/{deploymentName}"} # type: ignore + begin_create_or_update.metadata = {"url": "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/Microsoft.Resources/deployments/{deploymentName}"} # type: ignore @distributed_trace_async - async def get( - self, - resource_group_name: str, - deployment_name: str, - **kwargs: Any - ) -> "_models.DeploymentExtended": + async def get(self, resource_group_name: str, deployment_name: str, **kwargs: Any) -> _models.DeploymentExtended: """Gets a deployment. :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. :type resource_group_name: str - :param deployment_name: The name of the deployment. + :param deployment_name: The name of the deployment. Required. :type deployment_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: DeploymentExtended, or the result of cls(response) + :return: DeploymentExtended or the result of cls(response) :rtype: ~azure.mgmt.resource.resources.v2020_10_01.models.DeploymentExtended - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.DeploymentExtended"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) - api_version = kwargs.pop('api_version', "2020-10-01") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2020-10-01")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[_models.DeploymentExtended] - request = build_deployments_get_request( resource_group_name=resource_group_name, deployment_name=deployment_name, subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.get.metadata['url'], + template_url=self.get.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) - deserialized = self._deserialize('DeploymentExtended', pipeline_response) + deserialized = self._deserialize("DeploymentExtended", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - get.metadata = {'url': "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/Microsoft.Resources/deployments/{deploymentName}"} # type: ignore - + get.metadata = {"url": "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/Microsoft.Resources/deployments/{deploymentName}"} # type: ignore @distributed_trace_async async def cancel( # pylint: disable=inconsistent-return-statements - self, - resource_group_name: str, - deployment_name: str, - **kwargs: Any + self, resource_group_name: str, deployment_name: str, **kwargs: Any ) -> None: """Cancels a currently running template deployment. @@ -3547,38 +4674,45 @@ async def cancel( # pylint: disable=inconsistent-return-statements partially deployed. :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. :type resource_group_name: str - :param deployment_name: The name of the deployment. + :param deployment_name: The name of the deployment. Required. :type deployment_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: None, or the result of cls(response) + :return: None or the result of cls(response) :rtype: None - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType[None] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + 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', "2020-10-01") # type: str + api_version = kwargs.pop("api_version", _params.pop("api-version", "2020-10-01")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[None] - request = build_deployments_cancel_request( resource_group_name=resource_group_name, deployment_name=deployment_name, subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.cancel.metadata['url'], + template_url=self.cancel.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [204]: @@ -3588,44 +4722,53 @@ async def cancel( # pylint: disable=inconsistent-return-statements if cls: return cls(pipeline_response, None, {}) - cancel.metadata = {'url': "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/Microsoft.Resources/deployments/{deploymentName}/cancel"} # type: ignore - + cancel.metadata = {"url": "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/Microsoft.Resources/deployments/{deploymentName}/cancel"} # type: ignore async def _validate_initial( - self, - resource_group_name: str, - deployment_name: str, - parameters: "_models.Deployment", - **kwargs: Any - ) -> Optional["_models.DeploymentValidateResult"]: - cls = kwargs.pop('cls', None) # type: ClsType[Optional["_models.DeploymentValidateResult"]] + self, resource_group_name: str, deployment_name: str, parameters: Union[_models.Deployment, IO], **kwargs: Any + ) -> Optional[_models.DeploymentValidateResult]: error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) - api_version = kwargs.pop('api_version', "2020-10-01") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - _json = self._serialize.body(parameters, 'Deployment') + api_version = kwargs.pop("api_version", _params.pop("api-version", "2020-10-01")) # type: str + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[Optional[_models.DeploymentValidateResult]] - request = build_deployments_validate_request_initial( + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(parameters, (IO, bytes)): + _content = parameters + else: + _json = self._serialize.body(parameters, "Deployment") + + request = build_deployments_validate_request( resource_group_name=resource_group_name, deployment_name=deployment_name, subscription_id=self._config.subscription_id, api_version=api_version, content_type=content_type, json=_json, - template_url=self._validate_initial.metadata['url'], + content=_content, + template_url=self._validate_initial.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200, 202, 400]: @@ -3634,37 +4777,41 @@ async def _validate_initial( deserialized = None if response.status_code == 200: - deserialized = self._deserialize('DeploymentValidateResult', pipeline_response) + deserialized = self._deserialize("DeploymentValidateResult", pipeline_response) if response.status_code == 400: - deserialized = self._deserialize('DeploymentValidateResult', pipeline_response) + deserialized = self._deserialize("DeploymentValidateResult", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - _validate_initial.metadata = {'url': "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/Microsoft.Resources/deployments/{deploymentName}/validate"} # type: ignore + _validate_initial.metadata = {"url": "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/Microsoft.Resources/deployments/{deploymentName}/validate"} # type: ignore - - @distributed_trace_async + @overload async def begin_validate( self, resource_group_name: str, deployment_name: str, - parameters: "_models.Deployment", + parameters: _models.Deployment, + *, + content_type: str = "application/json", **kwargs: Any - ) -> AsyncLROPoller["_models.DeploymentValidateResult"]: + ) -> AsyncLROPoller[_models.DeploymentValidateResult]: """Validates whether the specified template is syntactically correct and will be accepted by Azure Resource Manager.. :param resource_group_name: The name of the resource group the template will be deployed to. - The name is case insensitive. + The name is case insensitive. Required. :type resource_group_name: str - :param deployment_name: The name of the deployment. + :param deployment_name: The name of the deployment. Required. :type deployment_name: str - :param parameters: Parameters to validate. + :param parameters: Parameters to validate. Required. :type parameters: ~azure.mgmt.resource.resources.v2020_10_01.models.Deployment + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str :keyword callable cls: A custom type or function that will be passed the direct response :keyword str continuation_token: A continuation token to restart a poller from a saved state. :keyword polling: By default, your polling method will be AsyncARMPolling. Pass in False for @@ -3677,86 +4824,173 @@ async def begin_validate( result of cls(response) :rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.resource.resources.v2020_10_01.models.DeploymentValidateResult] - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - api_version = kwargs.pop('api_version', "2020-10-01") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] - polling = kwargs.pop('polling', True) # type: Union[bool, AsyncPollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType["_models.DeploymentValidateResult"] - lro_delay = kwargs.pop( - 'polling_interval', - self._config.polling_interval - ) - cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] - if cont_token is None: - raw_result = await self._validate_initial( - resource_group_name=resource_group_name, - deployment_name=deployment_name, - parameters=parameters, - api_version=api_version, - content_type=content_type, - cls=lambda x,y,z: x, - **kwargs - ) - kwargs.pop('error_map', None) - - def get_long_running_output(pipeline_response): - response = pipeline_response.http_response - deserialized = self._deserialize('DeploymentValidateResult', pipeline_response) - if cls: - return cls(pipeline_response, deserialized, {}) - return deserialized + @overload + async def begin_validate( + self, + resource_group_name: str, + deployment_name: str, + parameters: IO, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> AsyncLROPoller[_models.DeploymentValidateResult]: + """Validates whether the specified template is syntactically correct and will be accepted by Azure + Resource Manager.. - if polling is True: polling_method = AsyncARMPolling(lro_delay, **kwargs) - elif polling is False: polling_method = AsyncNoPolling() - else: polling_method = polling - if cont_token: - return AsyncLROPoller.from_continuation_token( + :param resource_group_name: The name of the resource group the template will be deployed to. + The name is case insensitive. Required. + :type resource_group_name: str + :param deployment_name: The name of the deployment. Required. + :type deployment_name: str + :param parameters: Parameters to validate. Required. + :type parameters: IO + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be AsyncARMPolling. Pass in False for + this operation to not poll, or pass in your own initialized polling object for a personal + polling strategy. + :paramtype polling: bool or ~azure.core.polling.AsyncPollingMethod + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of AsyncLROPoller that returns either DeploymentValidateResult or the + result of cls(response) + :rtype: + ~azure.core.polling.AsyncLROPoller[~azure.mgmt.resource.resources.v2020_10_01.models.DeploymentValidateResult] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace_async + async def begin_validate( + self, resource_group_name: str, deployment_name: str, parameters: Union[_models.Deployment, IO], **kwargs: Any + ) -> AsyncLROPoller[_models.DeploymentValidateResult]: + """Validates whether the specified template is syntactically correct and will be accepted by Azure + Resource Manager.. + + :param resource_group_name: The name of the resource group the template will be deployed to. + The name is case insensitive. Required. + :type resource_group_name: str + :param deployment_name: The name of the deployment. Required. + :type deployment_name: str + :param parameters: Parameters to validate. Is either a model type or a IO type. Required. + :type parameters: ~azure.mgmt.resource.resources.v2020_10_01.models.Deployment or IO + :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. + Default value is None. + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be AsyncARMPolling. Pass in False for + this operation to not poll, or pass in your own initialized polling object for a personal + polling strategy. + :paramtype polling: bool or ~azure.core.polling.AsyncPollingMethod + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of AsyncLROPoller that returns either DeploymentValidateResult or the + result of cls(response) + :rtype: + ~azure.core.polling.AsyncLROPoller[~azure.mgmt.resource.resources.v2020_10_01.models.DeploymentValidateResult] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _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", "2020-10-01")) # type: str + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.DeploymentValidateResult] + polling = kwargs.pop("polling", True) # type: Union[bool, AsyncPollingMethod] + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token = kwargs.pop("continuation_token", None) # type: Optional[str] + if cont_token is None: + raw_result = await self._validate_initial( # type: ignore + resource_group_name=resource_group_name, + deployment_name=deployment_name, + parameters=parameters, + api_version=api_version, + content_type=content_type, + cls=lambda x, y, z: x, + headers=_headers, + params=_params, + **kwargs + ) + kwargs.pop("error_map", None) + + def get_long_running_output(pipeline_response): + deserialized = self._deserialize("DeploymentValidateResult", pipeline_response) + if cls: + return cls(pipeline_response, deserialized, {}) + return deserialized + + if polling is True: + polling_method = cast(AsyncPollingMethod, AsyncARMPolling(lro_delay, **kwargs)) # type: AsyncPollingMethod + elif polling is False: + polling_method = cast(AsyncPollingMethod, AsyncNoPolling()) + else: + polling_method = polling + if cont_token: + return AsyncLROPoller.from_continuation_token( polling_method=polling_method, continuation_token=cont_token, client=self._client, - deserialization_callback=get_long_running_output + deserialization_callback=get_long_running_output, ) return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) - begin_validate.metadata = {'url': "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/Microsoft.Resources/deployments/{deploymentName}/validate"} # type: ignore + begin_validate.metadata = {"url": "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/Microsoft.Resources/deployments/{deploymentName}/validate"} # type: ignore async def _what_if_initial( self, resource_group_name: str, deployment_name: str, - parameters: "_models.DeploymentWhatIf", + parameters: Union[_models.DeploymentWhatIf, IO], **kwargs: Any - ) -> Optional["_models.WhatIfOperationResult"]: - cls = kwargs.pop('cls', None) # type: ClsType[Optional["_models.WhatIfOperationResult"]] + ) -> Optional[_models.WhatIfOperationResult]: error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', "2020-10-01") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + api_version = kwargs.pop("api_version", _params.pop("api-version", "2020-10-01")) # type: str + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[Optional[_models.WhatIfOperationResult]] - _json = self._serialize.body(parameters, 'DeploymentWhatIf') + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(parameters, (IO, bytes)): + _content = parameters + else: + _json = self._serialize.body(parameters, "DeploymentWhatIf") - request = build_deployments_what_if_request_initial( + request = build_deployments_what_if_request( resource_group_name=resource_group_name, deployment_name=deployment_name, subscription_id=self._config.subscription_id, api_version=api_version, content_type=content_type, json=_json, - template_url=self._what_if_initial.metadata['url'], + content=_content, + template_url=self._what_if_initial.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200, 202]: @@ -3766,39 +5000,116 @@ async def _what_if_initial( deserialized = None response_headers = {} if response.status_code == 200: - deserialized = self._deserialize('WhatIfOperationResult', pipeline_response) + deserialized = self._deserialize("WhatIfOperationResult", pipeline_response) if response.status_code == 202: - response_headers['Location']=self._deserialize('str', response.headers.get('Location')) - response_headers['Retry-After']=self._deserialize('str', response.headers.get('Retry-After')) - + response_headers["Location"] = self._deserialize("str", response.headers.get("Location")) + response_headers["Retry-After"] = self._deserialize("str", response.headers.get("Retry-After")) if cls: return cls(pipeline_response, deserialized, response_headers) return deserialized - _what_if_initial.metadata = {'url': "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/Microsoft.Resources/deployments/{deploymentName}/whatIf"} # type: ignore + _what_if_initial.metadata = {"url": "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/Microsoft.Resources/deployments/{deploymentName}/whatIf"} # type: ignore + + @overload + async def begin_what_if( + self, + resource_group_name: str, + deployment_name: str, + parameters: _models.DeploymentWhatIf, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> AsyncLROPoller[_models.WhatIfOperationResult]: + """Returns changes that will be made by the deployment if executed at the scope of the resource + group. + + :param resource_group_name: The name of the resource group the template will be deployed to. + The name is case insensitive. Required. + :type resource_group_name: str + :param deployment_name: The name of the deployment. Required. + :type deployment_name: str + :param parameters: Parameters to validate. Required. + :type parameters: ~azure.mgmt.resource.resources.v2020_10_01.models.DeploymentWhatIf + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be AsyncARMPolling. Pass in False for + this operation to not poll, or pass in your own initialized polling object for a personal + polling strategy. + :paramtype polling: bool or ~azure.core.polling.AsyncPollingMethod + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of AsyncLROPoller that returns either WhatIfOperationResult or the result + of cls(response) + :rtype: + ~azure.core.polling.AsyncLROPoller[~azure.mgmt.resource.resources.v2020_10_01.models.WhatIfOperationResult] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + async def begin_what_if( + self, + resource_group_name: str, + deployment_name: str, + parameters: IO, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> AsyncLROPoller[_models.WhatIfOperationResult]: + """Returns changes that will be made by the deployment if executed at the scope of the resource + group. + :param resource_group_name: The name of the resource group the template will be deployed to. + The name is case insensitive. Required. + :type resource_group_name: str + :param deployment_name: The name of the deployment. Required. + :type deployment_name: str + :param parameters: Parameters to validate. Required. + :type parameters: IO + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be AsyncARMPolling. Pass in False for + this operation to not poll, or pass in your own initialized polling object for a personal + polling strategy. + :paramtype polling: bool or ~azure.core.polling.AsyncPollingMethod + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of AsyncLROPoller that returns either WhatIfOperationResult or the result + of cls(response) + :rtype: + ~azure.core.polling.AsyncLROPoller[~azure.mgmt.resource.resources.v2020_10_01.models.WhatIfOperationResult] + :raises ~azure.core.exceptions.HttpResponseError: + """ @distributed_trace_async async def begin_what_if( self, resource_group_name: str, deployment_name: str, - parameters: "_models.DeploymentWhatIf", + parameters: Union[_models.DeploymentWhatIf, IO], **kwargs: Any - ) -> AsyncLROPoller["_models.WhatIfOperationResult"]: + ) -> AsyncLROPoller[_models.WhatIfOperationResult]: """Returns changes that will be made by the deployment if executed at the scope of the resource group. :param resource_group_name: The name of the resource group the template will be deployed to. - The name is case insensitive. + The name is case insensitive. Required. :type resource_group_name: str - :param deployment_name: The name of the deployment. + :param deployment_name: The name of the deployment. Required. :type deployment_name: str - :param parameters: Parameters to validate. - :type parameters: ~azure.mgmt.resource.resources.v2020_10_01.models.DeploymentWhatIf + :param parameters: Parameters to validate. Is either a model type or a IO type. Required. + :type parameters: ~azure.mgmt.resource.resources.v2020_10_01.models.DeploymentWhatIf or IO + :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. + Default value is None. + :paramtype content_type: str :keyword callable cls: A custom type or function that will be passed the direct response :keyword str continuation_token: A continuation token to restart a poller from a saved state. :keyword polling: By default, your polling method will be AsyncARMPolling. Pass in False for @@ -3811,121 +5122,125 @@ async def begin_what_if( of cls(response) :rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.resource.resources.v2020_10_01.models.WhatIfOperationResult] - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - api_version = kwargs.pop('api_version', "2020-10-01") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] - polling = kwargs.pop('polling', True) # type: Union[bool, AsyncPollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType["_models.WhatIfOperationResult"] - lro_delay = kwargs.pop( - 'polling_interval', - self._config.polling_interval - ) - cont_token = kwargs.pop('continuation_token', None) # type: Optional[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", "2020-10-01")) # type: str + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.WhatIfOperationResult] + polling = kwargs.pop("polling", True) # type: Union[bool, AsyncPollingMethod] + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token = kwargs.pop("continuation_token", None) # type: Optional[str] if cont_token is None: - raw_result = await self._what_if_initial( + raw_result = await self._what_if_initial( # type: ignore resource_group_name=resource_group_name, deployment_name=deployment_name, parameters=parameters, api_version=api_version, content_type=content_type, - cls=lambda x,y,z: x, + cls=lambda x, y, z: x, + headers=_headers, + params=_params, **kwargs ) - kwargs.pop('error_map', None) + kwargs.pop("error_map", None) def get_long_running_output(pipeline_response): - response = pipeline_response.http_response - deserialized = self._deserialize('WhatIfOperationResult', pipeline_response) + deserialized = self._deserialize("WhatIfOperationResult", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - - if polling is True: polling_method = AsyncARMPolling(lro_delay, lro_options={'final-state-via': 'location'}, **kwargs) - elif polling is False: polling_method = AsyncNoPolling() - else: polling_method = polling + if polling is True: + polling_method = cast( + AsyncPollingMethod, AsyncARMPolling(lro_delay, lro_options={"final-state-via": "location"}, **kwargs) + ) # type: AsyncPollingMethod + elif polling is False: + polling_method = cast(AsyncPollingMethod, AsyncNoPolling()) + else: + polling_method = polling if cont_token: return AsyncLROPoller.from_continuation_token( polling_method=polling_method, continuation_token=cont_token, client=self._client, - deserialization_callback=get_long_running_output + deserialization_callback=get_long_running_output, ) return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) - begin_what_if.metadata = {'url': "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/Microsoft.Resources/deployments/{deploymentName}/whatIf"} # type: ignore + begin_what_if.metadata = {"url": "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/Microsoft.Resources/deployments/{deploymentName}/whatIf"} # type: ignore @distributed_trace_async async def export_template( - self, - resource_group_name: str, - deployment_name: str, - **kwargs: Any - ) -> "_models.DeploymentExportResult": + self, resource_group_name: str, deployment_name: str, **kwargs: Any + ) -> _models.DeploymentExportResult: """Exports the template used for specified deployment. :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. :type resource_group_name: str - :param deployment_name: The name of the deployment. + :param deployment_name: The name of the deployment. Required. :type deployment_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: DeploymentExportResult, or the result of cls(response) + :return: DeploymentExportResult or the result of cls(response) :rtype: ~azure.mgmt.resource.resources.v2020_10_01.models.DeploymentExportResult - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.DeploymentExportResult"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) - api_version = kwargs.pop('api_version', "2020-10-01") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2020-10-01")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[_models.DeploymentExportResult] - request = build_deployments_export_template_request( resource_group_name=resource_group_name, deployment_name=deployment_name, subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.export_template.metadata['url'], + template_url=self.export_template.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) - deserialized = self._deserialize('DeploymentExportResult', pipeline_response) + deserialized = self._deserialize("DeploymentExportResult", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - export_template.metadata = {'url': "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/Microsoft.Resources/deployments/{deploymentName}/exportTemplate"} # type: ignore - + export_template.metadata = {"url": "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/Microsoft.Resources/deployments/{deploymentName}/exportTemplate"} # type: ignore @distributed_trace def list_by_resource_group( - self, - resource_group_name: str, - filter: Optional[str] = None, - top: Optional[int] = None, - **kwargs: Any - ) -> AsyncIterable["_models.DeploymentListResult"]: + self, resource_group_name: str, filter: Optional[str] = None, top: Optional[int] = None, **kwargs: Any + ) -> AsyncIterable["_models.DeploymentExtended"]: """Get all the deployments for a resource group. :param resource_group_name: The name of the resource group with the deployments to get. The - name is case insensitive. + name is case insensitive. Required. :type resource_group_name: str :param filter: The filter to apply on the operation. For example, you can use $filter=provisioningState eq '{state}'. Default value is None. @@ -3934,42 +5249,49 @@ def list_by_resource_group( value is None. :type top: int :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either DeploymentListResult or the result of - cls(response) + :return: An iterator like instance of either DeploymentExtended or the result of cls(response) :rtype: - ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.resource.resources.v2020_10_01.models.DeploymentListResult] - :raises: ~azure.core.exceptions.HttpResponseError + ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.resource.resources.v2020_10_01.models.DeploymentExtended] + :raises ~azure.core.exceptions.HttpResponseError: """ - api_version = kwargs.pop('api_version', "2020-10-01") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2020-10-01")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[_models.DeploymentListResult] - cls = kwargs.pop('cls', None) # type: ClsType["_models.DeploymentListResult"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) + def prepare_request(next_link=None): if not next_link: - + request = build_deployments_list_by_resource_group_request( resource_group_name=resource_group_name, subscription_id=self._config.subscription_id, - api_version=api_version, filter=filter, top=top, - template_url=self.list_by_resource_group.metadata['url'], + 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.url = self._client.format_url(request.url) # type: ignore else: - - request = build_deployments_list_by_resource_group_request( - resource_group_name=resource_group_name, - subscription_id=self._config.subscription_id, - template_url=next_link, - ) + # make call to next link with the client's api-version + _parsed_next_link = urlparse(next_link) + _next_request_params = case_insensitive_dict(parse_qs(_parsed_next_link.query)) + _next_request_params["api-version"] = self._config.api_version + request = HttpRequest("GET", urljoin(next_link, _parsed_next_link.path), params=_next_request_params) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore request.method = "GET" return request @@ -3983,10 +5305,8 @@ async def extract_data(pipeline_response): async def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) response = pipeline_response.http_response @@ -3996,184 +5316,189 @@ async def get_next(next_link=None): return pipeline_response + return AsyncItemPaged(get_next, extract_data) - return AsyncItemPaged( - get_next, extract_data - ) - list_by_resource_group.metadata = {'url': "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/Microsoft.Resources/deployments/"} # type: ignore + list_by_resource_group.metadata = {"url": "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/Microsoft.Resources/deployments/"} # type: ignore @distributed_trace_async - async def calculate_template_hash( - self, - template: Any, - **kwargs: Any - ) -> "_models.TemplateHashResult": + async def calculate_template_hash(self, template: JSON, **kwargs: Any) -> _models.TemplateHashResult: """Calculate the hash of the given template. - :param template: The template provided to calculate hash. - :type template: any + :param template: The template provided to calculate hash. Required. + :type template: JSON :keyword callable cls: A custom type or function that will be passed the direct response - :return: TemplateHashResult, or the result of cls(response) + :return: TemplateHashResult or the result of cls(response) :rtype: ~azure.mgmt.resource.resources.v2020_10_01.models.TemplateHashResult - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.TemplateHashResult"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) - api_version = kwargs.pop('api_version', "2020-10-01") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - _json = self._serialize.body(template, 'object') + api_version = kwargs.pop("api_version", _params.pop("api-version", "2020-10-01")) # type: str + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", "application/json")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[_models.TemplateHashResult] + + _json = self._serialize.body(template, "object") request = build_deployments_calculate_template_hash_request( api_version=api_version, content_type=content_type, json=_json, - template_url=self.calculate_template_hash.metadata['url'], + template_url=self.calculate_template_hash.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) - deserialized = self._deserialize('TemplateHashResult', pipeline_response) + deserialized = self._deserialize("TemplateHashResult", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - calculate_template_hash.metadata = {'url': "/providers/Microsoft.Resources/calculateTemplateHash"} # type: ignore + calculate_template_hash.metadata = {"url": "/providers/Microsoft.Resources/calculateTemplateHash"} # type: ignore -class ProvidersOperations: - """ProvidersOperations async operations. - You should not instantiate this class directly. Instead, you should create a Client instance that - instantiates it for you and attaches it as an attribute. +class ProvidersOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. - :ivar models: Alias to model classes used in this operation group. - :type models: ~azure.mgmt.resource.resources.v2020_10_01.models - :param client: Client for service requests. - :param config: Configuration of service client. - :param serializer: An object model serializer. - :param deserializer: An object model deserializer. + Instead, you should access the following operations through + :class:`~azure.mgmt.resource.resources.v2020_10_01.aio.ResourceManagementClient`'s + :attr:`providers` attribute. """ models = _models - def __init__(self, client, config, serializer, deserializer) -> None: - self._client = client - self._serialize = serializer - self._deserialize = deserializer - self._config = config + def __init__(self, *args, **kwargs) -> None: + input_args = list(args) + self._client = input_args.pop(0) if input_args else kwargs.pop("client") + self._config = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") @distributed_trace_async - async def unregister( - self, - resource_provider_namespace: str, - **kwargs: Any - ) -> "_models.Provider": + async def unregister(self, resource_provider_namespace: str, **kwargs: Any) -> _models.Provider: """Unregisters a subscription from a resource provider. :param resource_provider_namespace: The namespace of the resource provider to unregister. + Required. :type resource_provider_namespace: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: Provider, or the result of cls(response) + :return: Provider or the result of cls(response) :rtype: ~azure.mgmt.resource.resources.v2020_10_01.models.Provider - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.Provider"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) - api_version = kwargs.pop('api_version', "2020-10-01") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2020-10-01")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[_models.Provider] - request = build_providers_unregister_request( resource_provider_namespace=resource_provider_namespace, subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.unregister.metadata['url'], + template_url=self.unregister.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) - deserialized = self._deserialize('Provider', pipeline_response) + deserialized = self._deserialize("Provider", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - unregister.metadata = {'url': "/subscriptions/{subscriptionId}/providers/{resourceProviderNamespace}/unregister"} # type: ignore - + unregister.metadata = {"url": "/subscriptions/{subscriptionId}/providers/{resourceProviderNamespace}/unregister"} # type: ignore @distributed_trace_async async def register_at_management_group_scope( # pylint: disable=inconsistent-return-statements - self, - resource_provider_namespace: str, - group_id: str, - **kwargs: Any + self, resource_provider_namespace: str, group_id: str, **kwargs: Any ) -> None: """Registers a management group with a resource provider. :param resource_provider_namespace: The namespace of the resource provider to register. + Required. :type resource_provider_namespace: str - :param group_id: The management group ID. + :param group_id: The management group ID. Required. :type group_id: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: None, or the result of cls(response) + :return: None or the result of cls(response) :rtype: None - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType[None] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + 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', "2020-10-01") # type: str + api_version = kwargs.pop("api_version", _params.pop("api-version", "2020-10-01")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[None] - request = build_providers_register_at_management_group_scope_request( resource_provider_namespace=resource_provider_namespace, group_id=group_id, api_version=api_version, - template_url=self.register_at_management_group_scope.metadata['url'], + template_url=self.register_at_management_group_scope.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200]: @@ -4183,70 +5508,68 @@ async def register_at_management_group_scope( # pylint: disable=inconsistent-re if cls: return cls(pipeline_response, None, {}) - register_at_management_group_scope.metadata = {'url': "/providers/Microsoft.Management/managementGroups/{groupId}/providers/{resourceProviderNamespace}/register"} # type: ignore - + register_at_management_group_scope.metadata = {"url": "/providers/Microsoft.Management/managementGroups/{groupId}/providers/{resourceProviderNamespace}/register"} # type: ignore @distributed_trace_async - async def register( - self, - resource_provider_namespace: str, - **kwargs: Any - ) -> "_models.Provider": + async def register(self, resource_provider_namespace: str, **kwargs: Any) -> _models.Provider: """Registers a subscription with a resource provider. :param resource_provider_namespace: The namespace of the resource provider to register. + Required. :type resource_provider_namespace: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: Provider, or the result of cls(response) + :return: Provider or the result of cls(response) :rtype: ~azure.mgmt.resource.resources.v2020_10_01.models.Provider - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.Provider"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + 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', "2020-10-01") # type: str + api_version = kwargs.pop("api_version", _params.pop("api-version", "2020-10-01")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[_models.Provider] - request = build_providers_register_request( resource_provider_namespace=resource_provider_namespace, subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.register.metadata['url'], + template_url=self.register.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) - deserialized = self._deserialize('Provider', pipeline_response) + deserialized = self._deserialize("Provider", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - register.metadata = {'url': "/subscriptions/{subscriptionId}/providers/{resourceProviderNamespace}/register"} # type: ignore - + register.metadata = {"url": "/subscriptions/{subscriptionId}/providers/{resourceProviderNamespace}/register"} # type: ignore @distributed_trace def list( - self, - top: Optional[int] = None, - expand: Optional[str] = None, - **kwargs: Any - ) -> AsyncIterable["_models.ProviderListResult"]: + self, top: Optional[int] = None, expand: Optional[str] = None, **kwargs: Any + ) -> AsyncIterable["_models.Provider"]: """Gets all resource providers for a subscription. :param top: The number of results to return. If null is passed returns all deployments. Default @@ -4257,39 +5580,48 @@ def list( response, use $expand=resourceTypes/aliases. Default value is None. :type expand: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either ProviderListResult or the result of cls(response) + :return: An iterator like instance of either Provider or the result of cls(response) :rtype: - ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.resource.resources.v2020_10_01.models.ProviderListResult] - :raises: ~azure.core.exceptions.HttpResponseError + ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.resource.resources.v2020_10_01.models.Provider] + :raises ~azure.core.exceptions.HttpResponseError: """ - api_version = kwargs.pop('api_version', "2020-10-01") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2020-10-01")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[_models.ProviderListResult] - cls = kwargs.pop('cls', None) # type: ClsType["_models.ProviderListResult"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) + def prepare_request(next_link=None): if not next_link: - + request = build_providers_list_request( subscription_id=self._config.subscription_id, - api_version=api_version, top=top, expand=expand, - template_url=self.list.metadata['url'], + 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.url = self._client.format_url(request.url) # type: ignore else: - - request = build_providers_list_request( - subscription_id=self._config.subscription_id, - template_url=next_link, - ) + # make call to next link with the client's api-version + _parsed_next_link = urlparse(next_link) + _next_request_params = case_insensitive_dict(parse_qs(_parsed_next_link.query)) + _next_request_params["api-version"] = self._config.api_version + request = HttpRequest("GET", urljoin(next_link, _parsed_next_link.path), params=_next_request_params) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore request.method = "GET" return request @@ -4303,10 +5635,8 @@ async def extract_data(pipeline_response): async def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) response = pipeline_response.http_response @@ -4316,19 +5646,14 @@ async def get_next(next_link=None): return pipeline_response + return AsyncItemPaged(get_next, extract_data) - return AsyncItemPaged( - get_next, extract_data - ) - list.metadata = {'url': "/subscriptions/{subscriptionId}/providers"} # type: ignore + list.metadata = {"url": "/subscriptions/{subscriptionId}/providers"} # type: ignore @distributed_trace def list_at_tenant_scope( - self, - top: Optional[int] = None, - expand: Optional[str] = None, - **kwargs: Any - ) -> AsyncIterable["_models.ProviderListResult"]: + self, top: Optional[int] = None, expand: Optional[str] = None, **kwargs: Any + ) -> AsyncIterable["_models.Provider"]: """Gets all resource providers for the tenant. :param top: The number of results to return. If null is passed returns all providers. Default @@ -4339,37 +5664,47 @@ def list_at_tenant_scope( response, use $expand=resourceTypes/aliases. Default value is None. :type expand: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either ProviderListResult or the result of cls(response) + :return: An iterator like instance of either Provider or the result of cls(response) :rtype: - ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.resource.resources.v2020_10_01.models.ProviderListResult] - :raises: ~azure.core.exceptions.HttpResponseError + ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.resource.resources.v2020_10_01.models.Provider] + :raises ~azure.core.exceptions.HttpResponseError: """ - api_version = kwargs.pop('api_version', "2020-10-01") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2020-10-01")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[_models.ProviderListResult] - cls = kwargs.pop('cls', None) # type: ClsType["_models.ProviderListResult"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) + def prepare_request(next_link=None): if not next_link: - + request = build_providers_list_at_tenant_scope_request( - api_version=api_version, top=top, expand=expand, - template_url=self.list_at_tenant_scope.metadata['url'], + api_version=api_version, + template_url=self.list_at_tenant_scope.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore else: - - request = build_providers_list_at_tenant_scope_request( - template_url=next_link, - ) + # make call to next link with the client's api-version + _parsed_next_link = urlparse(next_link) + _next_request_params = case_insensitive_dict(parse_qs(_parsed_next_link.query)) + _next_request_params["api-version"] = self._config.api_version + request = HttpRequest("GET", urljoin(next_link, _parsed_next_link.path), params=_next_request_params) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore request.method = "GET" return request @@ -4383,10 +5718,8 @@ async def extract_data(pipeline_response): async def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) response = pipeline_response.http_response @@ -4396,229 +5729,231 @@ async def get_next(next_link=None): return pipeline_response + return AsyncItemPaged(get_next, extract_data) - return AsyncItemPaged( - get_next, extract_data - ) - list_at_tenant_scope.metadata = {'url': "/providers"} # type: ignore + list_at_tenant_scope.metadata = {"url": "/providers"} # type: ignore @distributed_trace_async async def get( - self, - resource_provider_namespace: str, - expand: Optional[str] = None, - **kwargs: Any - ) -> "_models.Provider": + self, resource_provider_namespace: str, expand: Optional[str] = None, **kwargs: Any + ) -> _models.Provider: """Gets the specified resource provider. - :param resource_provider_namespace: The namespace of the resource provider. + :param resource_provider_namespace: The namespace of the resource provider. Required. :type resource_provider_namespace: str :param expand: The $expand query parameter. For example, to include property aliases in response, use $expand=resourceTypes/aliases. Default value is None. :type expand: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: Provider, or the result of cls(response) + :return: Provider or the result of cls(response) :rtype: ~azure.mgmt.resource.resources.v2020_10_01.models.Provider - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.Provider"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + 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', "2020-10-01") # type: str + api_version = kwargs.pop("api_version", _params.pop("api-version", "2020-10-01")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[_models.Provider] - request = build_providers_get_request( resource_provider_namespace=resource_provider_namespace, subscription_id=self._config.subscription_id, - api_version=api_version, expand=expand, - template_url=self.get.metadata['url'], + api_version=api_version, + template_url=self.get.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) - deserialized = self._deserialize('Provider', pipeline_response) + deserialized = self._deserialize("Provider", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - get.metadata = {'url': "/subscriptions/{subscriptionId}/providers/{resourceProviderNamespace}"} # type: ignore - + get.metadata = {"url": "/subscriptions/{subscriptionId}/providers/{resourceProviderNamespace}"} # type: ignore @distributed_trace_async async def get_at_tenant_scope( - self, - resource_provider_namespace: str, - expand: Optional[str] = None, - **kwargs: Any - ) -> "_models.Provider": + self, resource_provider_namespace: str, expand: Optional[str] = None, **kwargs: Any + ) -> _models.Provider: """Gets the specified resource provider at the tenant level. - :param resource_provider_namespace: The namespace of the resource provider. + :param resource_provider_namespace: The namespace of the resource provider. Required. :type resource_provider_namespace: str :param expand: The $expand query parameter. For example, to include property aliases in response, use $expand=resourceTypes/aliases. Default value is None. :type expand: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: Provider, or the result of cls(response) + :return: Provider or the result of cls(response) :rtype: ~azure.mgmt.resource.resources.v2020_10_01.models.Provider - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.Provider"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) - api_version = kwargs.pop('api_version', "2020-10-01") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2020-10-01")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[_models.Provider] - request = build_providers_get_at_tenant_scope_request( resource_provider_namespace=resource_provider_namespace, - api_version=api_version, expand=expand, - template_url=self.get_at_tenant_scope.metadata['url'], + api_version=api_version, + template_url=self.get_at_tenant_scope.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) - deserialized = self._deserialize('Provider', pipeline_response) + deserialized = self._deserialize("Provider", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - get_at_tenant_scope.metadata = {'url': "/providers/{resourceProviderNamespace}"} # type: ignore + get_at_tenant_scope.metadata = {"url": "/providers/{resourceProviderNamespace}"} # type: ignore -class ProviderResourceTypesOperations: - """ProviderResourceTypesOperations async operations. - You should not instantiate this class directly. Instead, you should create a Client instance that - instantiates it for you and attaches it as an attribute. +class ProviderResourceTypesOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. - :ivar models: Alias to model classes used in this operation group. - :type models: ~azure.mgmt.resource.resources.v2020_10_01.models - :param client: Client for service requests. - :param config: Configuration of service client. - :param serializer: An object model serializer. - :param deserializer: An object model deserializer. + Instead, you should access the following operations through + :class:`~azure.mgmt.resource.resources.v2020_10_01.aio.ResourceManagementClient`'s + :attr:`provider_resource_types` attribute. """ models = _models - def __init__(self, client, config, serializer, deserializer) -> None: - self._client = client - self._serialize = serializer - self._deserialize = deserializer - self._config = config + def __init__(self, *args, **kwargs) -> None: + input_args = list(args) + self._client = input_args.pop(0) if input_args else kwargs.pop("client") + self._config = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") @distributed_trace_async async def list( - self, - resource_provider_namespace: str, - expand: Optional[str] = None, - **kwargs: Any - ) -> "_models.ProviderResourceTypeListResult": + self, resource_provider_namespace: str, expand: Optional[str] = None, **kwargs: Any + ) -> _models.ProviderResourceTypeListResult: """List the resource types for a specified resource provider. - :param resource_provider_namespace: The namespace of the resource provider. + :param resource_provider_namespace: The namespace of the resource provider. Required. :type resource_provider_namespace: str :param expand: The $expand query parameter. For example, to include property aliases in response, use $expand=resourceTypes/aliases. Default value is None. :type expand: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: ProviderResourceTypeListResult, or the result of cls(response) + :return: ProviderResourceTypeListResult or the result of cls(response) :rtype: ~azure.mgmt.resource.resources.v2020_10_01.models.ProviderResourceTypeListResult - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.ProviderResourceTypeListResult"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + 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', "2020-10-01") # type: str + api_version = kwargs.pop("api_version", _params.pop("api-version", "2020-10-01")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[_models.ProviderResourceTypeListResult] - request = build_provider_resource_types_list_request( resource_provider_namespace=resource_provider_namespace, subscription_id=self._config.subscription_id, - api_version=api_version, expand=expand, - template_url=self.list.metadata['url'], + 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.url = self._client.format_url(request.url) # type: ignore - pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) - deserialized = self._deserialize('ProviderResourceTypeListResult', pipeline_response) + deserialized = self._deserialize("ProviderResourceTypeListResult", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - list.metadata = {'url': "/subscriptions/{subscriptionId}/providers/{resourceProviderNamespace}/resourceTypes"} # type: ignore + list.metadata = {"url": "/subscriptions/{subscriptionId}/providers/{resourceProviderNamespace}/resourceTypes"} # type: ignore -class ResourcesOperations: # pylint: disable=too-many-public-methods - """ResourcesOperations async operations. - You should not instantiate this class directly. Instead, you should create a Client instance that - instantiates it for you and attaches it as an attribute. +class ResourcesOperations: # pylint: disable=too-many-public-methods + """ + .. warning:: + **DO NOT** instantiate this class directly. - :ivar models: Alias to model classes used in this operation group. - :type models: ~azure.mgmt.resource.resources.v2020_10_01.models - :param client: Client for service requests. - :param config: Configuration of service client. - :param serializer: An object model serializer. - :param deserializer: An object model deserializer. + Instead, you should access the following operations through + :class:`~azure.mgmt.resource.resources.v2020_10_01.aio.ResourceManagementClient`'s + :attr:`resources` attribute. """ models = _models - def __init__(self, client, config, serializer, deserializer) -> None: - self._client = client - self._serialize = serializer - self._deserialize = deserializer - self._config = config + def __init__(self, *args, **kwargs) -> None: + input_args = list(args) + self._client = input_args.pop(0) if input_args else kwargs.pop("client") + self._config = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") @distributed_trace def list_by_resource_group( @@ -4628,10 +5963,10 @@ def list_by_resource_group( expand: Optional[str] = None, top: Optional[int] = None, **kwargs: Any - ) -> AsyncIterable["_models.ResourceListResult"]: + ) -> AsyncIterable["_models.GenericResourceExpanded"]: """Get all the resources for a resource group. - :param resource_group_name: The resource group with the resources to get. + :param resource_group_name: The resource group with the resources to get. Required. :type resource_group_name: str :param filter: The filter to apply on the operation.:code:`
`:code:`
`The properties you can use for eq (equals) or ne (not equals) are: location, resourceType, name, resourceGroup, @@ -4657,42 +5992,51 @@ def list_by_resource_group( value is None. :type top: int :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either ResourceListResult or the result of cls(response) + :return: An iterator like instance of either GenericResourceExpanded or the result of + cls(response) :rtype: - ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.resource.resources.v2020_10_01.models.ResourceListResult] - :raises: ~azure.core.exceptions.HttpResponseError + ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.resource.resources.v2020_10_01.models.GenericResourceExpanded] + :raises ~azure.core.exceptions.HttpResponseError: """ - api_version = kwargs.pop('api_version', "2020-10-01") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2020-10-01")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[_models.ResourceListResult] - cls = kwargs.pop('cls', None) # type: ClsType["_models.ResourceListResult"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) + def prepare_request(next_link=None): if not next_link: - + request = build_resources_list_by_resource_group_request( resource_group_name=resource_group_name, subscription_id=self._config.subscription_id, - api_version=api_version, filter=filter, expand=expand, top=top, - template_url=self.list_by_resource_group.metadata['url'], + 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.url = self._client.format_url(request.url) # type: ignore else: - - request = build_resources_list_by_resource_group_request( - resource_group_name=resource_group_name, - subscription_id=self._config.subscription_id, - template_url=next_link, - ) + # make call to next link with the client's api-version + _parsed_next_link = urlparse(next_link) + _next_request_params = case_insensitive_dict(parse_qs(_parsed_next_link.query)) + _next_request_params["api-version"] = self._config.api_version + request = HttpRequest("GET", urljoin(next_link, _parsed_next_link.path), params=_next_request_params) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore request.method = "GET" return request @@ -4706,10 +6050,8 @@ async def extract_data(pipeline_response): async def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) response = pipeline_response.http_response @@ -4719,45 +6061,54 @@ async def get_next(next_link=None): return pipeline_response + return AsyncItemPaged(get_next, extract_data) - return AsyncItemPaged( - get_next, extract_data - ) - list_by_resource_group.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/resources"} # type: ignore + list_by_resource_group.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/resources"} # type: ignore async def _move_resources_initial( # pylint: disable=inconsistent-return-statements - self, - source_resource_group_name: str, - parameters: "_models.ResourcesMoveInfo", - **kwargs: Any + self, source_resource_group_name: str, parameters: Union[_models.ResourcesMoveInfo, IO], **kwargs: Any ) -> None: - cls = kwargs.pop('cls', None) # type: ClsType[None] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', "2020-10-01") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + api_version = kwargs.pop("api_version", _params.pop("api-version", "2020-10-01")) # type: str + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[None] - _json = self._serialize.body(parameters, 'ResourcesMoveInfo') + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(parameters, (IO, bytes)): + _content = parameters + else: + _json = self._serialize.body(parameters, "ResourcesMoveInfo") - request = build_resources_move_resources_request_initial( + request = build_resources_move_resources_request( source_resource_group_name=source_resource_group_name, subscription_id=self._config.subscription_id, api_version=api_version, content_type=content_type, json=_json, - template_url=self._move_resources_initial.metadata['url'], + content=_content, + template_url=self._move_resources_initial.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [202, 204]: @@ -4767,14 +6118,15 @@ async def _move_resources_initial( # pylint: disable=inconsistent-return-statem if cls: return cls(pipeline_response, None, {}) - _move_resources_initial.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{sourceResourceGroupName}/moveResources"} # type: ignore - + _move_resources_initial.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{sourceResourceGroupName}/moveResources"} # type: ignore - @distributed_trace_async - async def begin_move_resources( # pylint: disable=inconsistent-return-statements + @overload + async def begin_move_resources( self, source_resource_group_name: str, - parameters: "_models.ResourcesMoveInfo", + parameters: _models.ResourcesMoveInfo, + *, + content_type: str = "application/json", **kwargs: Any ) -> AsyncLROPoller[None]: """Moves resources from one resource group to another resource group. @@ -4785,10 +6137,13 @@ async def begin_move_resources( # pylint: disable=inconsistent-return-statement the groups until the move completes. :param source_resource_group_name: The name of the resource group containing the resources to - move. + move. Required. :type source_resource_group_name: str - :param parameters: Parameters for moving resources. + :param parameters: Parameters for moving resources. Required. :type parameters: ~azure.mgmt.resource.resources.v2020_10_01.models.ResourcesMoveInfo + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str :keyword callable cls: A custom type or function that will be passed the direct response :keyword str continuation_token: A continuation token to restart a poller from a saved state. :keyword polling: By default, your polling method will be AsyncARMPolling. Pass in False for @@ -4799,80 +6154,160 @@ async def begin_move_resources( # pylint: disable=inconsistent-return-statement Retry-After header is present. :return: An instance of AsyncLROPoller that returns either None or the result of cls(response) :rtype: ~azure.core.polling.AsyncLROPoller[None] - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - api_version = kwargs.pop('api_version', "2020-10-01") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] - polling = kwargs.pop('polling', True) # type: Union[bool, AsyncPollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType[None] - lro_delay = kwargs.pop( - 'polling_interval', - self._config.polling_interval - ) - cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] - if cont_token is None: - raw_result = await self._move_resources_initial( - source_resource_group_name=source_resource_group_name, - parameters=parameters, - api_version=api_version, - content_type=content_type, - cls=lambda x,y,z: x, - **kwargs - ) - kwargs.pop('error_map', None) - def get_long_running_output(pipeline_response): - if cls: - return cls(pipeline_response, None, {}) + @overload + async def begin_move_resources( + self, source_resource_group_name: str, parameters: IO, *, content_type: str = "application/json", **kwargs: Any + ) -> AsyncLROPoller[None]: + """Moves resources from one resource group to another resource group. + The resources to move must be in the same source resource group. The target resource group may + be in a different subscription. When moving resources, both the source group and the target + group are locked for the duration of the operation. Write and delete operations are blocked on + the groups until the move completes. - if polling is True: polling_method = AsyncARMPolling(lro_delay, **kwargs) - elif polling is False: polling_method = AsyncNoPolling() - else: polling_method = polling + :param source_resource_group_name: The name of the resource group containing the resources to + move. Required. + :type source_resource_group_name: str + :param parameters: Parameters for moving resources. Required. + :type parameters: IO + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be AsyncARMPolling. Pass in False for + this operation to not poll, or pass in your own initialized polling object for a personal + polling strategy. + :paramtype polling: bool or ~azure.core.polling.AsyncPollingMethod + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of AsyncLROPoller that returns either None or the result of cls(response) + :rtype: ~azure.core.polling.AsyncLROPoller[None] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace_async + async def begin_move_resources( + self, source_resource_group_name: str, parameters: Union[_models.ResourcesMoveInfo, IO], **kwargs: Any + ) -> AsyncLROPoller[None]: + """Moves resources from one resource group to another resource group. + + The resources to move must be in the same source resource group. The target resource group may + be in a different subscription. When moving resources, both the source group and the target + group are locked for the duration of the operation. Write and delete operations are blocked on + the groups until the move completes. + + :param source_resource_group_name: The name of the resource group containing the resources to + move. Required. + :type source_resource_group_name: str + :param parameters: Parameters for moving resources. Is either a model type or a IO type. + Required. + :type parameters: ~azure.mgmt.resource.resources.v2020_10_01.models.ResourcesMoveInfo or IO + :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. + Default value is None. + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be AsyncARMPolling. Pass in False for + this operation to not poll, or pass in your own initialized polling object for a personal + polling strategy. + :paramtype polling: bool or ~azure.core.polling.AsyncPollingMethod + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of AsyncLROPoller that returns either None or the result of cls(response) + :rtype: ~azure.core.polling.AsyncLROPoller[None] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _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", "2020-10-01")) # type: str + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[None] + polling = kwargs.pop("polling", True) # type: Union[bool, AsyncPollingMethod] + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token = kwargs.pop("continuation_token", None) # type: Optional[str] + if cont_token is None: + raw_result = await self._move_resources_initial( # type: ignore + source_resource_group_name=source_resource_group_name, + parameters=parameters, + api_version=api_version, + content_type=content_type, + cls=lambda x, y, z: x, + headers=_headers, + params=_params, + **kwargs + ) + kwargs.pop("error_map", None) + + def get_long_running_output(pipeline_response): # pylint: disable=inconsistent-return-statements + if cls: + return cls(pipeline_response, None, {}) + + if polling is True: + polling_method = cast(AsyncPollingMethod, AsyncARMPolling(lro_delay, **kwargs)) # type: AsyncPollingMethod + elif polling is False: + polling_method = cast(AsyncPollingMethod, AsyncNoPolling()) + else: + polling_method = polling if cont_token: return AsyncLROPoller.from_continuation_token( polling_method=polling_method, continuation_token=cont_token, client=self._client, - deserialization_callback=get_long_running_output + deserialization_callback=get_long_running_output, ) return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) - begin_move_resources.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{sourceResourceGroupName}/moveResources"} # type: ignore + begin_move_resources.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{sourceResourceGroupName}/moveResources"} # type: ignore async def _validate_move_resources_initial( # pylint: disable=inconsistent-return-statements - self, - source_resource_group_name: str, - parameters: "_models.ResourcesMoveInfo", - **kwargs: Any + self, source_resource_group_name: str, parameters: Union[_models.ResourcesMoveInfo, IO], **kwargs: Any ) -> None: - cls = kwargs.pop('cls', None) # type: ClsType[None] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', "2020-10-01") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + api_version = kwargs.pop("api_version", _params.pop("api-version", "2020-10-01")) # type: str + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[None] - _json = self._serialize.body(parameters, 'ResourcesMoveInfo') + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(parameters, (IO, bytes)): + _content = parameters + else: + _json = self._serialize.body(parameters, "ResourcesMoveInfo") - request = build_resources_validate_move_resources_request_initial( + request = build_resources_validate_move_resources_request( source_resource_group_name=source_resource_group_name, subscription_id=self._config.subscription_id, api_version=api_version, content_type=content_type, json=_json, - template_url=self._validate_move_resources_initial.metadata['url'], + content=_content, + template_url=self._validate_move_resources_initial.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [202, 204]: @@ -4882,14 +6317,15 @@ async def _validate_move_resources_initial( # pylint: disable=inconsistent-retu if cls: return cls(pipeline_response, None, {}) - _validate_move_resources_initial.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{sourceResourceGroupName}/validateMoveResources"} # type: ignore - + _validate_move_resources_initial.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{sourceResourceGroupName}/validateMoveResources"} # type: ignore - @distributed_trace_async - async def begin_validate_move_resources( # pylint: disable=inconsistent-return-statements + @overload + async def begin_validate_move_resources( self, source_resource_group_name: str, - parameters: "_models.ResourcesMoveInfo", + parameters: _models.ResourcesMoveInfo, + *, + content_type: str = "application/json", **kwargs: Any ) -> AsyncLROPoller[None]: """Validates whether resources can be moved from one resource group to another resource group. @@ -4902,10 +6338,13 @@ async def begin_validate_move_resources( # pylint: disable=inconsistent-return- operation. :param source_resource_group_name: The name of the resource group containing the resources to - validate for move. + validate for move. Required. :type source_resource_group_name: str - :param parameters: Parameters for moving resources. + :param parameters: Parameters for moving resources. Required. :type parameters: ~azure.mgmt.resource.resources.v2020_10_01.models.ResourcesMoveInfo + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str :keyword callable cls: A custom type or function that will be passed the direct response :keyword str continuation_token: A continuation token to restart a poller from a saved state. :keyword polling: By default, your polling method will be AsyncARMPolling. Pass in False for @@ -4916,55 +6355,124 @@ async def begin_validate_move_resources( # pylint: disable=inconsistent-return- Retry-After header is present. :return: An instance of AsyncLROPoller that returns either None or the result of cls(response) :rtype: ~azure.core.polling.AsyncLROPoller[None] - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - api_version = kwargs.pop('api_version', "2020-10-01") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] - polling = kwargs.pop('polling', True) # type: Union[bool, AsyncPollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType[None] - lro_delay = kwargs.pop( - 'polling_interval', - self._config.polling_interval - ) - cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] + + @overload + async def begin_validate_move_resources( + self, source_resource_group_name: str, parameters: IO, *, content_type: str = "application/json", **kwargs: Any + ) -> AsyncLROPoller[None]: + """Validates whether resources can be moved from one resource group to another resource group. + + This operation checks whether the specified resources can be moved to the target. The resources + to move must be in the same source resource group. The target resource group may be in a + different subscription. If validation succeeds, it returns HTTP response code 204 (no content). + If validation fails, it returns HTTP response code 409 (Conflict) with an error message. + Retrieve the URL in the Location header value to check the result of the long-running + operation. + + :param source_resource_group_name: The name of the resource group containing the resources to + validate for move. Required. + :type source_resource_group_name: str + :param parameters: Parameters for moving resources. Required. + :type parameters: IO + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be AsyncARMPolling. Pass in False for + this operation to not poll, or pass in your own initialized polling object for a personal + polling strategy. + :paramtype polling: bool or ~azure.core.polling.AsyncPollingMethod + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of AsyncLROPoller that returns either None or the result of cls(response) + :rtype: ~azure.core.polling.AsyncLROPoller[None] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace_async + async def begin_validate_move_resources( + self, source_resource_group_name: str, parameters: Union[_models.ResourcesMoveInfo, IO], **kwargs: Any + ) -> AsyncLROPoller[None]: + """Validates whether resources can be moved from one resource group to another resource group. + + This operation checks whether the specified resources can be moved to the target. The resources + to move must be in the same source resource group. The target resource group may be in a + different subscription. If validation succeeds, it returns HTTP response code 204 (no content). + If validation fails, it returns HTTP response code 409 (Conflict) with an error message. + Retrieve the URL in the Location header value to check the result of the long-running + operation. + + :param source_resource_group_name: The name of the resource group containing the resources to + validate for move. Required. + :type source_resource_group_name: str + :param parameters: Parameters for moving resources. Is either a model type or a IO type. + Required. + :type parameters: ~azure.mgmt.resource.resources.v2020_10_01.models.ResourcesMoveInfo or IO + :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. + Default value is None. + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be AsyncARMPolling. Pass in False for + this operation to not poll, or pass in your own initialized polling object for a personal + polling strategy. + :paramtype polling: bool or ~azure.core.polling.AsyncPollingMethod + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of AsyncLROPoller that returns either None or the result of cls(response) + :rtype: ~azure.core.polling.AsyncLROPoller[None] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _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", "2020-10-01")) # type: str + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[None] + polling = kwargs.pop("polling", True) # type: Union[bool, AsyncPollingMethod] + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token = kwargs.pop("continuation_token", None) # type: Optional[str] if cont_token is None: - raw_result = await self._validate_move_resources_initial( + raw_result = await self._validate_move_resources_initial( # type: ignore source_resource_group_name=source_resource_group_name, parameters=parameters, api_version=api_version, content_type=content_type, - cls=lambda x,y,z: x, + cls=lambda x, y, z: x, + headers=_headers, + params=_params, **kwargs ) - kwargs.pop('error_map', None) + kwargs.pop("error_map", None) - def get_long_running_output(pipeline_response): + def get_long_running_output(pipeline_response): # pylint: disable=inconsistent-return-statements if cls: return cls(pipeline_response, None, {}) - - if polling is True: polling_method = AsyncARMPolling(lro_delay, **kwargs) - elif polling is False: polling_method = AsyncNoPolling() - else: polling_method = polling + if polling is True: + polling_method = cast(AsyncPollingMethod, AsyncARMPolling(lro_delay, **kwargs)) # type: AsyncPollingMethod + elif polling is False: + polling_method = cast(AsyncPollingMethod, AsyncNoPolling()) + else: + polling_method = polling if cont_token: return AsyncLROPoller.from_continuation_token( polling_method=polling_method, continuation_token=cont_token, client=self._client, - deserialization_callback=get_long_running_output + deserialization_callback=get_long_running_output, ) return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) - begin_validate_move_resources.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{sourceResourceGroupName}/validateMoveResources"} # type: ignore + begin_validate_move_resources.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{sourceResourceGroupName}/validateMoveResources"} # type: ignore @distributed_trace def list( - self, - filter: Optional[str] = None, - expand: Optional[str] = None, - top: Optional[int] = None, - **kwargs: Any - ) -> AsyncIterable["_models.ResourceListResult"]: + self, filter: Optional[str] = None, expand: Optional[str] = None, top: Optional[int] = None, **kwargs: Any + ) -> AsyncIterable["_models.GenericResourceExpanded"]: """Get all the resources in a subscription. :param filter: The filter to apply on the operation.:code:`
`:code:`
`The properties you @@ -4991,40 +6499,50 @@ def list( value is None. :type top: int :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either ResourceListResult or the result of cls(response) + :return: An iterator like instance of either GenericResourceExpanded or the result of + cls(response) :rtype: - ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.resource.resources.v2020_10_01.models.ResourceListResult] - :raises: ~azure.core.exceptions.HttpResponseError + ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.resource.resources.v2020_10_01.models.GenericResourceExpanded] + :raises ~azure.core.exceptions.HttpResponseError: """ - api_version = kwargs.pop('api_version', "2020-10-01") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2020-10-01")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[_models.ResourceListResult] - cls = kwargs.pop('cls', None) # type: ClsType["_models.ResourceListResult"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) + def prepare_request(next_link=None): if not next_link: - + request = build_resources_list_request( subscription_id=self._config.subscription_id, - api_version=api_version, filter=filter, expand=expand, top=top, - template_url=self.list.metadata['url'], + 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.url = self._client.format_url(request.url) # type: ignore else: - - request = build_resources_list_request( - subscription_id=self._config.subscription_id, - template_url=next_link, - ) + # make call to next link with the client's api-version + _parsed_next_link = urlparse(next_link) + _next_request_params = case_insensitive_dict(parse_qs(_parsed_next_link.query)) + _next_request_params["api-version"] = self._config.api_version + request = HttpRequest("GET", urljoin(next_link, _parsed_next_link.path), params=_next_request_params) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore request.method = "GET" return request @@ -5038,10 +6556,8 @@ async def extract_data(pipeline_response): async def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) response = pipeline_response.http_response @@ -5051,11 +6567,9 @@ async def get_next(next_link=None): return pipeline_response + return AsyncItemPaged(get_next, extract_data) - return AsyncItemPaged( - get_next, extract_data - ) - list.metadata = {'url': "/subscriptions/{subscriptionId}/resources"} # type: ignore + list.metadata = {"url": "/subscriptions/{subscriptionId}/resources"} # type: ignore @distributed_trace_async async def check_existence( @@ -5071,30 +6585,36 @@ async def check_existence( """Checks whether a resource exists. :param resource_group_name: The name of the resource group containing the resource to check. - The name is case insensitive. + The name is case insensitive. Required. :type resource_group_name: str - :param resource_provider_namespace: The resource provider of the resource to check. + :param resource_provider_namespace: The resource provider of the resource to check. Required. :type resource_provider_namespace: str - :param parent_resource_path: The parent resource identity. + :param parent_resource_path: The parent resource identity. Required. :type parent_resource_path: str - :param resource_type: The resource type. + :param resource_type: The resource type. Required. :type resource_type: str - :param resource_name: The name of the resource to check whether it exists. + :param resource_name: The name of the resource to check whether it exists. Required. :type resource_name: str - :param api_version: The API version to use for the operation. + :param api_version: The API version to use for the operation. Required. :type api_version: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: bool, or the result of cls(response) + :return: bool or the result of cls(response) :rtype: bool - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType[None] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = kwargs.pop("params", {}) or {} + + cls = kwargs.pop("cls", None) # type: ClsType[None] - request = build_resources_check_existence_request( resource_group_name=resource_group_name, resource_provider_namespace=resource_provider_namespace, @@ -5103,16 +6623,17 @@ async def check_existence( resource_name=resource_name, subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.check_existence.metadata['url'], + template_url=self.check_existence.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [204, 404]: @@ -5123,8 +6644,7 @@ async def check_existence( return cls(pipeline_response, None, {}) return 200 <= response.status_code <= 299 - check_existence.metadata = {'url': "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{parentResourcePath}/{resourceType}/{resourceName}"} # type: ignore - + check_existence.metadata = {"url": "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{parentResourcePath}/{resourceType}/{resourceName}"} # type: ignore async def _delete_initial( # pylint: disable=inconsistent-return-statements self, @@ -5136,14 +6656,20 @@ async def _delete_initial( # pylint: disable=inconsistent-return-statements api_version: str, **kwargs: Any ) -> None: - cls = kwargs.pop('cls', None) # type: ClsType[None] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) - - request = build_resources_delete_request_initial( + _headers = kwargs.pop("headers", {}) or {} + _params = kwargs.pop("params", {}) or {} + + cls = kwargs.pop("cls", None) # type: ClsType[None] + + request = build_resources_delete_request( resource_group_name=resource_group_name, resource_provider_namespace=resource_provider_namespace, parent_resource_path=parent_resource_path, @@ -5151,16 +6677,17 @@ async def _delete_initial( # pylint: disable=inconsistent-return-statements resource_name=resource_name, subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self._delete_initial.metadata['url'], + template_url=self._delete_initial.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200, 202, 204]: @@ -5170,11 +6697,10 @@ 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/{resourceProviderNamespace}/{parentResourcePath}/{resourceType}/{resourceName}"} # type: ignore - + _delete_initial.metadata = {"url": "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{parentResourcePath}/{resourceType}/{resourceName}"} # type: ignore @distributed_trace_async - async def begin_delete( # pylint: disable=inconsistent-return-statements + async def begin_delete( self, resource_group_name: str, resource_provider_namespace: str, @@ -5187,17 +6713,17 @@ async def begin_delete( # pylint: disable=inconsistent-return-statements """Deletes a resource. :param resource_group_name: The name of the resource group that contains the resource to - delete. The name is case insensitive. + delete. The name is case insensitive. Required. :type resource_group_name: str - :param resource_provider_namespace: The namespace of the resource provider. + :param resource_provider_namespace: The namespace of the resource provider. Required. :type resource_provider_namespace: str - :param parent_resource_path: The parent resource identity. + :param parent_resource_path: The parent resource identity. Required. :type parent_resource_path: str - :param resource_type: The resource type. + :param resource_type: The resource type. Required. :type resource_type: str - :param resource_name: The name of the resource to delete. + :param resource_name: The name of the resource to delete. Required. :type resource_name: str - :param api_version: The API version to use for the operation. + :param api_version: The API version to use for the operation. Required. :type api_version: str :keyword callable cls: A custom type or function that will be passed the direct response :keyword str continuation_token: A continuation token to restart a poller from a saved state. @@ -5209,46 +6735,50 @@ async def begin_delete( # pylint: disable=inconsistent-return-statements Retry-After header is present. :return: An instance of AsyncLROPoller that returns either None or the result of cls(response) :rtype: ~azure.core.polling.AsyncLROPoller[None] - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - polling = kwargs.pop('polling', True) # type: Union[bool, AsyncPollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType[None] - lro_delay = kwargs.pop( - 'polling_interval', - self._config.polling_interval - ) - cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] + _headers = kwargs.pop("headers", {}) or {} + _params = kwargs.pop("params", {}) or {} + + cls = kwargs.pop("cls", None) # type: ClsType[None] + polling = kwargs.pop("polling", True) # type: Union[bool, AsyncPollingMethod] + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token = kwargs.pop("continuation_token", None) # type: Optional[str] if cont_token is None: - raw_result = await self._delete_initial( + raw_result = await self._delete_initial( # type: ignore resource_group_name=resource_group_name, resource_provider_namespace=resource_provider_namespace, parent_resource_path=parent_resource_path, resource_type=resource_type, resource_name=resource_name, api_version=api_version, - cls=lambda x,y,z: x, + cls=lambda x, y, z: x, + headers=_headers, + params=_params, **kwargs ) - kwargs.pop('error_map', None) + kwargs.pop("error_map", None) - def get_long_running_output(pipeline_response): + def get_long_running_output(pipeline_response): # pylint: disable=inconsistent-return-statements if cls: return cls(pipeline_response, None, {}) - - if polling is True: polling_method = AsyncARMPolling(lro_delay, **kwargs) - elif polling is False: polling_method = AsyncNoPolling() - else: polling_method = polling + if polling is True: + polling_method = cast(AsyncPollingMethod, AsyncARMPolling(lro_delay, **kwargs)) # type: AsyncPollingMethod + elif polling is False: + polling_method = cast(AsyncPollingMethod, AsyncNoPolling()) + else: + polling_method = polling if cont_token: return AsyncLROPoller.from_continuation_token( polling_method=polling_method, continuation_token=cont_token, client=self._client, - deserialization_callback=get_long_running_output + deserialization_callback=get_long_running_output, ) return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) - begin_delete.metadata = {'url': "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{parentResourcePath}/{resourceType}/{resourceName}"} # type: ignore + begin_delete.metadata = {"url": "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{parentResourcePath}/{resourceType}/{resourceName}"} # type: ignore async def _create_or_update_initial( self, @@ -5258,39 +6788,53 @@ async def _create_or_update_initial( resource_type: str, resource_name: str, api_version: str, - parameters: "_models.GenericResource", + parameters: Union[_models.GenericResource, IO], **kwargs: Any - ) -> Optional["_models.GenericResource"]: - cls = kwargs.pop('cls', None) # type: ClsType[Optional["_models.GenericResource"]] + ) -> Optional[_models.GenericResource]: error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = kwargs.pop("params", {}) or {} - _json = self._serialize.body(parameters, 'GenericResource') + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[Optional[_models.GenericResource]] - request = build_resources_create_or_update_request_initial( + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(parameters, (IO, bytes)): + _content = parameters + else: + _json = self._serialize.body(parameters, "GenericResource") + + request = build_resources_create_or_update_request( resource_group_name=resource_group_name, resource_provider_namespace=resource_provider_namespace, parent_resource_path=parent_resource_path, resource_type=resource_type, resource_name=resource_name, subscription_id=self._config.subscription_id, - content_type=content_type, api_version=api_version, + content_type=content_type, json=_json, - template_url=self._create_or_update_initial.metadata['url'], + content=_content, + template_url=self._create_or_update_initial.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200, 201, 202]: @@ -5299,18 +6843,115 @@ async def _create_or_update_initial( deserialized = None if response.status_code == 200: - deserialized = self._deserialize('GenericResource', pipeline_response) + deserialized = self._deserialize("GenericResource", pipeline_response) if response.status_code == 201: - deserialized = self._deserialize('GenericResource', pipeline_response) + deserialized = self._deserialize("GenericResource", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - _create_or_update_initial.metadata = {'url': "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{parentResourcePath}/{resourceType}/{resourceName}"} # type: ignore + _create_or_update_initial.metadata = {"url": "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{parentResourcePath}/{resourceType}/{resourceName}"} # type: ignore + + @overload + async def begin_create_or_update( + self, + resource_group_name: str, + resource_provider_namespace: str, + parent_resource_path: str, + resource_type: str, + resource_name: str, + api_version: str, + parameters: _models.GenericResource, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> AsyncLROPoller[_models.GenericResource]: + """Creates a resource. + + :param resource_group_name: The name of the resource group for the resource. The name is case + insensitive. Required. + :type resource_group_name: str + :param resource_provider_namespace: The namespace of the resource provider. Required. + :type resource_provider_namespace: str + :param parent_resource_path: The parent resource identity. Required. + :type parent_resource_path: str + :param resource_type: The resource type of the resource to create. Required. + :type resource_type: str + :param resource_name: The name of the resource to create. Required. + :type resource_name: str + :param api_version: The API version to use for the operation. Required. + :type api_version: str + :param parameters: Parameters for creating or updating the resource. Required. + :type parameters: ~azure.mgmt.resource.resources.v2020_10_01.models.GenericResource + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be AsyncARMPolling. Pass in False for + this operation to not poll, or pass in your own initialized polling object for a personal + polling strategy. + :paramtype polling: bool or ~azure.core.polling.AsyncPollingMethod + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of AsyncLROPoller that returns either GenericResource or the result of + cls(response) + :rtype: + ~azure.core.polling.AsyncLROPoller[~azure.mgmt.resource.resources.v2020_10_01.models.GenericResource] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + async def begin_create_or_update( + self, + resource_group_name: str, + resource_provider_namespace: str, + parent_resource_path: str, + resource_type: str, + resource_name: str, + api_version: str, + parameters: IO, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> AsyncLROPoller[_models.GenericResource]: + """Creates a resource. + :param resource_group_name: The name of the resource group for the resource. The name is case + insensitive. Required. + :type resource_group_name: str + :param resource_provider_namespace: The namespace of the resource provider. Required. + :type resource_provider_namespace: str + :param parent_resource_path: The parent resource identity. Required. + :type parent_resource_path: str + :param resource_type: The resource type of the resource to create. Required. + :type resource_type: str + :param resource_name: The name of the resource to create. Required. + :type resource_name: str + :param api_version: The API version to use for the operation. Required. + :type api_version: str + :param parameters: Parameters for creating or updating the resource. Required. + :type parameters: IO + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be AsyncARMPolling. Pass in False for + this operation to not poll, or pass in your own initialized polling object for a personal + polling strategy. + :paramtype polling: bool or ~azure.core.polling.AsyncPollingMethod + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of AsyncLROPoller that returns either GenericResource or the result of + cls(response) + :rtype: + ~azure.core.polling.AsyncLROPoller[~azure.mgmt.resource.resources.v2020_10_01.models.GenericResource] + :raises ~azure.core.exceptions.HttpResponseError: + """ @distributed_trace_async async def begin_create_or_update( @@ -5321,26 +6962,30 @@ async def begin_create_or_update( resource_type: str, resource_name: str, api_version: str, - parameters: "_models.GenericResource", + parameters: Union[_models.GenericResource, IO], **kwargs: Any - ) -> AsyncLROPoller["_models.GenericResource"]: + ) -> AsyncLROPoller[_models.GenericResource]: """Creates a resource. :param resource_group_name: The name of the resource group for the resource. The name is case - insensitive. + insensitive. Required. :type resource_group_name: str - :param resource_provider_namespace: The namespace of the resource provider. + :param resource_provider_namespace: The namespace of the resource provider. Required. :type resource_provider_namespace: str - :param parent_resource_path: The parent resource identity. + :param parent_resource_path: The parent resource identity. Required. :type parent_resource_path: str - :param resource_type: The resource type of the resource to create. + :param resource_type: The resource type of the resource to create. Required. :type resource_type: str - :param resource_name: The name of the resource to create. + :param resource_name: The name of the resource to create. Required. :type resource_name: str - :param api_version: The API version to use for the operation. + :param api_version: The API version to use for the operation. Required. :type api_version: str - :param parameters: Parameters for creating or updating the resource. - :type parameters: ~azure.mgmt.resource.resources.v2020_10_01.models.GenericResource + :param parameters: Parameters for creating or updating the resource. Is either a model type or + a IO type. Required. + :type parameters: ~azure.mgmt.resource.resources.v2020_10_01.models.GenericResource or IO + :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. + Default value is None. + :paramtype content_type: str :keyword callable cls: A custom type or function that will be passed the direct response :keyword str continuation_token: A continuation token to restart a poller from a saved state. :keyword polling: By default, your polling method will be AsyncARMPolling. Pass in False for @@ -5353,18 +6998,18 @@ async def begin_create_or_update( cls(response) :rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.resource.resources.v2020_10_01.models.GenericResource] - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] - polling = kwargs.pop('polling', True) # type: Union[bool, AsyncPollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType["_models.GenericResource"] - lro_delay = kwargs.pop( - 'polling_interval', - self._config.polling_interval - ) - cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = kwargs.pop("params", {}) or {} + + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.GenericResource] + polling = kwargs.pop("polling", True) # type: Union[bool, AsyncPollingMethod] + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token = kwargs.pop("continuation_token", None) # type: Optional[str] if cont_token is None: - raw_result = await self._create_or_update_initial( + raw_result = await self._create_or_update_initial( # type: ignore resource_group_name=resource_group_name, resource_provider_namespace=resource_provider_namespace, parent_resource_path=parent_resource_path, @@ -5373,32 +7018,35 @@ async def begin_create_or_update( api_version=api_version, parameters=parameters, content_type=content_type, - cls=lambda x,y,z: x, + cls=lambda x, y, z: x, + headers=_headers, + params=_params, **kwargs ) - kwargs.pop('error_map', None) + kwargs.pop("error_map", None) def get_long_running_output(pipeline_response): - response = pipeline_response.http_response - deserialized = self._deserialize('GenericResource', pipeline_response) + deserialized = self._deserialize("GenericResource", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - - if polling is True: polling_method = AsyncARMPolling(lro_delay, **kwargs) - elif polling is False: polling_method = AsyncNoPolling() - else: polling_method = polling + if polling is True: + polling_method = cast(AsyncPollingMethod, AsyncARMPolling(lro_delay, **kwargs)) # type: AsyncPollingMethod + elif polling is False: + polling_method = cast(AsyncPollingMethod, AsyncNoPolling()) + else: + polling_method = polling if cont_token: return AsyncLROPoller.from_continuation_token( polling_method=polling_method, continuation_token=cont_token, client=self._client, - deserialization_callback=get_long_running_output + deserialization_callback=get_long_running_output, ) return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) - begin_create_or_update.metadata = {'url': "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{parentResourcePath}/{resourceType}/{resourceName}"} # type: ignore + begin_create_or_update.metadata = {"url": "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{parentResourcePath}/{resourceType}/{resourceName}"} # type: ignore async def _update_initial( self, @@ -5408,39 +7056,53 @@ async def _update_initial( resource_type: str, resource_name: str, api_version: str, - parameters: "_models.GenericResource", + parameters: Union[_models.GenericResource, IO], **kwargs: Any - ) -> Optional["_models.GenericResource"]: - cls = kwargs.pop('cls', None) # type: ClsType[Optional["_models.GenericResource"]] + ) -> Optional[_models.GenericResource]: error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = kwargs.pop("params", {}) or {} - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[Optional[_models.GenericResource]] - _json = self._serialize.body(parameters, 'GenericResource') + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(parameters, (IO, bytes)): + _content = parameters + else: + _json = self._serialize.body(parameters, "GenericResource") - request = build_resources_update_request_initial( + request = build_resources_update_request( resource_group_name=resource_group_name, resource_provider_namespace=resource_provider_namespace, parent_resource_path=parent_resource_path, resource_type=resource_type, resource_name=resource_name, subscription_id=self._config.subscription_id, - content_type=content_type, api_version=api_version, + content_type=content_type, json=_json, - template_url=self._update_initial.metadata['url'], + content=_content, + template_url=self._update_initial.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200, 202]: @@ -5449,17 +7111,16 @@ async def _update_initial( deserialized = None if response.status_code == 200: - deserialized = self._deserialize('GenericResource', pipeline_response) + deserialized = self._deserialize("GenericResource", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - _update_initial.metadata = {'url': "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{parentResourcePath}/{resourceType}/{resourceName}"} # type: ignore - + _update_initial.metadata = {"url": "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{parentResourcePath}/{resourceType}/{resourceName}"} # type: ignore - @distributed_trace_async + @overload async def begin_update( self, resource_group_name: str, @@ -5468,26 +7129,31 @@ async def begin_update( resource_type: str, resource_name: str, api_version: str, - parameters: "_models.GenericResource", + parameters: _models.GenericResource, + *, + content_type: str = "application/json", **kwargs: Any - ) -> AsyncLROPoller["_models.GenericResource"]: + ) -> AsyncLROPoller[_models.GenericResource]: """Updates a resource. :param resource_group_name: The name of the resource group for the resource. The name is case - insensitive. + insensitive. Required. :type resource_group_name: str - :param resource_provider_namespace: The namespace of the resource provider. + :param resource_provider_namespace: The namespace of the resource provider. Required. :type resource_provider_namespace: str - :param parent_resource_path: The parent resource identity. + :param parent_resource_path: The parent resource identity. Required. :type parent_resource_path: str - :param resource_type: The resource type of the resource to update. + :param resource_type: The resource type of the resource to update. Required. :type resource_type: str - :param resource_name: The name of the resource to update. + :param resource_name: The name of the resource to update. Required. :type resource_name: str - :param api_version: The API version to use for the operation. + :param api_version: The API version to use for the operation. Required. :type api_version: str - :param parameters: Parameters for updating the resource. + :param parameters: Parameters for updating the resource. Required. :type parameters: ~azure.mgmt.resource.resources.v2020_10_01.models.GenericResource + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str :keyword callable cls: A custom type or function that will be passed the direct response :keyword str continuation_token: A continuation token to restart a poller from a saved state. :keyword polling: By default, your polling method will be AsyncARMPolling. Pass in False for @@ -5500,55 +7166,11 @@ async def begin_update( cls(response) :rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.resource.resources.v2020_10_01.models.GenericResource] - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] - polling = kwargs.pop('polling', True) # type: Union[bool, AsyncPollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType["_models.GenericResource"] - lro_delay = kwargs.pop( - 'polling_interval', - self._config.polling_interval - ) - cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] - if cont_token is None: - raw_result = await self._update_initial( - resource_group_name=resource_group_name, - resource_provider_namespace=resource_provider_namespace, - parent_resource_path=parent_resource_path, - resource_type=resource_type, - resource_name=resource_name, - api_version=api_version, - parameters=parameters, - content_type=content_type, - cls=lambda x,y,z: x, - **kwargs - ) - kwargs.pop('error_map', None) - - def get_long_running_output(pipeline_response): - response = pipeline_response.http_response - deserialized = self._deserialize('GenericResource', pipeline_response) - if cls: - return cls(pipeline_response, deserialized, {}) - return deserialized - - - if polling is True: polling_method = AsyncARMPolling(lro_delay, **kwargs) - elif polling is False: polling_method = AsyncNoPolling() - else: polling_method = polling - if cont_token: - return AsyncLROPoller.from_continuation_token( - polling_method=polling_method, - continuation_token=cont_token, - client=self._client, - deserialization_callback=get_long_running_output - ) - return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) - begin_update.metadata = {'url': "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{parentResourcePath}/{resourceType}/{resourceName}"} # type: ignore - - @distributed_trace_async - async def get( + @overload + async def begin_update( self, resource_group_name: str, resource_provider_namespace: str, @@ -5556,36 +7178,186 @@ async def get( resource_type: str, resource_name: str, api_version: str, + parameters: IO, + *, + content_type: str = "application/json", **kwargs: Any - ) -> "_models.GenericResource": - """Gets a resource. + ) -> AsyncLROPoller[_models.GenericResource]: + """Updates a resource. - :param resource_group_name: The name of the resource group containing the resource to get. The - name is case insensitive. + :param resource_group_name: The name of the resource group for the resource. The name is case + insensitive. Required. :type resource_group_name: str - :param resource_provider_namespace: The namespace of the resource provider. + :param resource_provider_namespace: The namespace of the resource provider. Required. :type resource_provider_namespace: str - :param parent_resource_path: The parent resource identity. + :param parent_resource_path: The parent resource identity. Required. :type parent_resource_path: str - :param resource_type: The resource type of the resource. + :param resource_type: The resource type of the resource to update. Required. :type resource_type: str - :param resource_name: The name of the resource to get. + :param resource_name: The name of the resource to update. Required. :type resource_name: str - :param api_version: The API version to use for the operation. + :param api_version: The API version to use for the operation. Required. :type api_version: str + :param parameters: Parameters for updating the resource. Required. + :type parameters: IO + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: GenericResource, or the result of cls(response) - :rtype: ~azure.mgmt.resource.resources.v2020_10_01.models.GenericResource - :raises: ~azure.core.exceptions.HttpResponseError - """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.GenericResource"] - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {})) - - - request = build_resources_get_request( + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be AsyncARMPolling. Pass in False for + this operation to not poll, or pass in your own initialized polling object for a personal + polling strategy. + :paramtype polling: bool or ~azure.core.polling.AsyncPollingMethod + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of AsyncLROPoller that returns either GenericResource or the result of + cls(response) + :rtype: + ~azure.core.polling.AsyncLROPoller[~azure.mgmt.resource.resources.v2020_10_01.models.GenericResource] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace_async + async def begin_update( + self, + resource_group_name: str, + resource_provider_namespace: str, + parent_resource_path: str, + resource_type: str, + resource_name: str, + api_version: str, + parameters: Union[_models.GenericResource, IO], + **kwargs: Any + ) -> AsyncLROPoller[_models.GenericResource]: + """Updates a resource. + + :param resource_group_name: The name of the resource group for the resource. The name is case + insensitive. Required. + :type resource_group_name: str + :param resource_provider_namespace: The namespace of the resource provider. Required. + :type resource_provider_namespace: str + :param parent_resource_path: The parent resource identity. Required. + :type parent_resource_path: str + :param resource_type: The resource type of the resource to update. Required. + :type resource_type: str + :param resource_name: The name of the resource to update. Required. + :type resource_name: str + :param api_version: The API version to use for the operation. Required. + :type api_version: str + :param parameters: Parameters for updating the resource. Is either a model type or a IO type. + Required. + :type parameters: ~azure.mgmt.resource.resources.v2020_10_01.models.GenericResource or IO + :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. + Default value is None. + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be AsyncARMPolling. Pass in False for + this operation to not poll, or pass in your own initialized polling object for a personal + polling strategy. + :paramtype polling: bool or ~azure.core.polling.AsyncPollingMethod + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of AsyncLROPoller that returns either GenericResource or the result of + cls(response) + :rtype: + ~azure.core.polling.AsyncLROPoller[~azure.mgmt.resource.resources.v2020_10_01.models.GenericResource] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = kwargs.pop("params", {}) or {} + + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.GenericResource] + polling = kwargs.pop("polling", True) # type: Union[bool, AsyncPollingMethod] + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token = kwargs.pop("continuation_token", None) # type: Optional[str] + if cont_token is None: + raw_result = await self._update_initial( # type: ignore + resource_group_name=resource_group_name, + resource_provider_namespace=resource_provider_namespace, + parent_resource_path=parent_resource_path, + resource_type=resource_type, + resource_name=resource_name, + api_version=api_version, + parameters=parameters, + content_type=content_type, + cls=lambda x, y, z: x, + headers=_headers, + params=_params, + **kwargs + ) + kwargs.pop("error_map", None) + + def get_long_running_output(pipeline_response): + deserialized = self._deserialize("GenericResource", pipeline_response) + if cls: + return cls(pipeline_response, deserialized, {}) + return deserialized + + if polling is True: + polling_method = cast(AsyncPollingMethod, AsyncARMPolling(lro_delay, **kwargs)) # type: AsyncPollingMethod + elif polling is False: + polling_method = cast(AsyncPollingMethod, AsyncNoPolling()) + else: + polling_method = polling + if cont_token: + return AsyncLROPoller.from_continuation_token( + polling_method=polling_method, + continuation_token=cont_token, + client=self._client, + deserialization_callback=get_long_running_output, + ) + return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) + + begin_update.metadata = {"url": "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{parentResourcePath}/{resourceType}/{resourceName}"} # type: ignore + + @distributed_trace_async + async def get( + self, + resource_group_name: str, + resource_provider_namespace: str, + parent_resource_path: str, + resource_type: str, + resource_name: str, + api_version: str, + **kwargs: Any + ) -> _models.GenericResource: + """Gets a resource. + + :param resource_group_name: The name of the resource group containing the resource to get. The + name is case insensitive. Required. + :type resource_group_name: str + :param resource_provider_namespace: The namespace of the resource provider. Required. + :type resource_provider_namespace: str + :param parent_resource_path: The parent resource identity. Required. + :type parent_resource_path: str + :param resource_type: The resource type of the resource. Required. + :type resource_type: str + :param resource_name: The name of the resource to get. Required. + :type resource_name: str + :param api_version: The API version to use for the operation. Required. + :type api_version: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: GenericResource or the result of cls(response) + :rtype: ~azure.mgmt.resource.resources.v2020_10_01.models.GenericResource + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = kwargs.pop("params", {}) or {} + + cls = kwargs.pop("cls", None) # type: ClsType[_models.GenericResource] + + request = build_resources_get_request( resource_group_name=resource_group_name, resource_provider_namespace=resource_provider_namespace, parent_resource_path=parent_resource_path, @@ -5593,72 +7365,75 @@ async def get( resource_name=resource_name, subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.get.metadata['url'], + template_url=self.get.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) - deserialized = self._deserialize('GenericResource', pipeline_response) + deserialized = self._deserialize("GenericResource", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - get.metadata = {'url': "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{parentResourcePath}/{resourceType}/{resourceName}"} # type: ignore - + get.metadata = {"url": "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{parentResourcePath}/{resourceType}/{resourceName}"} # type: ignore @distributed_trace_async - async def check_existence_by_id( - self, - resource_id: str, - api_version: str, - **kwargs: Any - ) -> bool: + async def check_existence_by_id(self, resource_id: str, api_version: str, **kwargs: Any) -> bool: """Checks by ID whether a resource exists. :param resource_id: The fully qualified ID of the resource, including the resource name and resource type. Use the format, /subscriptions/{guid}/resourceGroups/{resource-group-name}/{resource-provider-namespace}/{resource-type}/{resource-name}. + Required. :type resource_id: str - :param api_version: The API version to use for the operation. + :param api_version: The API version to use for the operation. Required. :type api_version: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: bool, or the result of cls(response) + :return: bool or the result of cls(response) :rtype: bool - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType[None] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = kwargs.pop("params", {}) or {} + + cls = kwargs.pop("cls", None) # type: ClsType[None] - request = build_resources_check_existence_by_id_request( resource_id=resource_id, api_version=api_version, - template_url=self.check_existence_by_id.metadata['url'], + template_url=self.check_existence_by_id.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [204, 404]: @@ -5669,35 +7444,38 @@ async def check_existence_by_id( return cls(pipeline_response, None, {}) return 200 <= response.status_code <= 299 - check_existence_by_id.metadata = {'url': "/{resourceId}"} # type: ignore - + check_existence_by_id.metadata = {"url": "/{resourceId}"} # type: ignore async def _delete_by_id_initial( # pylint: disable=inconsistent-return-statements - self, - resource_id: str, - api_version: str, - **kwargs: Any + self, resource_id: str, api_version: str, **kwargs: Any ) -> None: - cls = kwargs.pop('cls', None) # type: ClsType[None] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = kwargs.pop("params", {}) or {} - - request = build_resources_delete_by_id_request_initial( + cls = kwargs.pop("cls", None) # type: ClsType[None] + + request = build_resources_delete_by_id_request( resource_id=resource_id, api_version=api_version, - template_url=self._delete_by_id_initial.metadata['url'], + template_url=self._delete_by_id_initial.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200, 202, 204]: @@ -5707,23 +7485,18 @@ async def _delete_by_id_initial( # pylint: disable=inconsistent-return-statemen if cls: return cls(pipeline_response, None, {}) - _delete_by_id_initial.metadata = {'url': "/{resourceId}"} # type: ignore - + _delete_by_id_initial.metadata = {"url": "/{resourceId}"} # type: ignore @distributed_trace_async - async def begin_delete_by_id( # pylint: disable=inconsistent-return-statements - self, - resource_id: str, - api_version: str, - **kwargs: Any - ) -> AsyncLROPoller[None]: + async def begin_delete_by_id(self, resource_id: str, api_version: str, **kwargs: Any) -> AsyncLROPoller[None]: """Deletes a resource by ID. :param resource_id: The fully qualified ID of the resource, including the resource name and resource type. Use the format, /subscriptions/{guid}/resourceGroups/{resource-group-name}/{resource-provider-namespace}/{resource-type}/{resource-name}. + Required. :type resource_id: str - :param api_version: The API version to use for the operation. + :param api_version: The API version to use for the operation. Required. :type api_version: str :keyword callable cls: A custom type or function that will be passed the direct response :keyword str continuation_token: A continuation token to restart a poller from a saved state. @@ -5735,75 +7508,89 @@ async def begin_delete_by_id( # pylint: disable=inconsistent-return-statements Retry-After header is present. :return: An instance of AsyncLROPoller that returns either None or the result of cls(response) :rtype: ~azure.core.polling.AsyncLROPoller[None] - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - polling = kwargs.pop('polling', True) # type: Union[bool, AsyncPollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType[None] - lro_delay = kwargs.pop( - 'polling_interval', - self._config.polling_interval - ) - cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] + _headers = kwargs.pop("headers", {}) or {} + _params = kwargs.pop("params", {}) or {} + + cls = kwargs.pop("cls", None) # type: ClsType[None] + polling = kwargs.pop("polling", True) # type: Union[bool, AsyncPollingMethod] + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token = kwargs.pop("continuation_token", None) # type: Optional[str] if cont_token is None: - raw_result = await self._delete_by_id_initial( + raw_result = await self._delete_by_id_initial( # type: ignore resource_id=resource_id, api_version=api_version, - cls=lambda x,y,z: x, + cls=lambda x, y, z: x, + headers=_headers, + params=_params, **kwargs ) - kwargs.pop('error_map', None) + kwargs.pop("error_map", None) - def get_long_running_output(pipeline_response): + def get_long_running_output(pipeline_response): # pylint: disable=inconsistent-return-statements if cls: return cls(pipeline_response, None, {}) - - if polling is True: polling_method = AsyncARMPolling(lro_delay, **kwargs) - elif polling is False: polling_method = AsyncNoPolling() - else: polling_method = polling + if polling is True: + polling_method = cast(AsyncPollingMethod, AsyncARMPolling(lro_delay, **kwargs)) # type: AsyncPollingMethod + elif polling is False: + polling_method = cast(AsyncPollingMethod, AsyncNoPolling()) + else: + polling_method = polling if cont_token: return AsyncLROPoller.from_continuation_token( polling_method=polling_method, continuation_token=cont_token, client=self._client, - deserialization_callback=get_long_running_output + deserialization_callback=get_long_running_output, ) return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) - begin_delete_by_id.metadata = {'url': "/{resourceId}"} # type: ignore + begin_delete_by_id.metadata = {"url": "/{resourceId}"} # type: ignore async def _create_or_update_by_id_initial( - self, - resource_id: str, - api_version: str, - parameters: "_models.GenericResource", - **kwargs: Any - ) -> Optional["_models.GenericResource"]: - cls = kwargs.pop('cls', None) # type: ClsType[Optional["_models.GenericResource"]] + self, resource_id: str, api_version: str, parameters: Union[_models.GenericResource, IO], **kwargs: Any + ) -> Optional[_models.GenericResource]: error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = kwargs.pop("params", {}) or {} - _json = self._serialize.body(parameters, 'GenericResource') + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[Optional[_models.GenericResource]] - request = build_resources_create_or_update_by_id_request_initial( + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(parameters, (IO, bytes)): + _content = parameters + else: + _json = self._serialize.body(parameters, "GenericResource") + + request = build_resources_create_or_update_by_id_request( resource_id=resource_id, - content_type=content_type, api_version=api_version, + content_type=content_type, json=_json, - template_url=self._create_or_update_by_id_initial.metadata['url'], + content=_content, + template_url=self._create_or_update_by_id_initial.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200, 201, 202]: @@ -5812,37 +7599,42 @@ async def _create_or_update_by_id_initial( deserialized = None if response.status_code == 200: - deserialized = self._deserialize('GenericResource', pipeline_response) + deserialized = self._deserialize("GenericResource", pipeline_response) if response.status_code == 201: - deserialized = self._deserialize('GenericResource', pipeline_response) + deserialized = self._deserialize("GenericResource", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - _create_or_update_by_id_initial.metadata = {'url': "/{resourceId}"} # type: ignore - + _create_or_update_by_id_initial.metadata = {"url": "/{resourceId}"} # type: ignore - @distributed_trace_async + @overload async def begin_create_or_update_by_id( self, resource_id: str, api_version: str, - parameters: "_models.GenericResource", + parameters: _models.GenericResource, + *, + content_type: str = "application/json", **kwargs: Any - ) -> AsyncLROPoller["_models.GenericResource"]: + ) -> AsyncLROPoller[_models.GenericResource]: """Create a resource by ID. :param resource_id: The fully qualified ID of the resource, including the resource name and resource type. Use the format, /subscriptions/{guid}/resourceGroups/{resource-group-name}/{resource-provider-namespace}/{resource-type}/{resource-name}. + Required. :type resource_id: str - :param api_version: The API version to use for the operation. + :param api_version: The API version to use for the operation. Required. :type api_version: str - :param parameters: Create or update resource parameters. + :param parameters: Create or update resource parameters. Required. :type parameters: ~azure.mgmt.resource.resources.v2020_10_01.models.GenericResource + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str :keyword callable cls: A custom type or function that will be passed the direct response :keyword str continuation_token: A continuation token to restart a poller from a saved state. :keyword polling: By default, your polling method will be AsyncARMPolling. Pass in False for @@ -5855,81 +7647,167 @@ async def begin_create_or_update_by_id( cls(response) :rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.resource.resources.v2020_10_01.models.GenericResource] - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] - polling = kwargs.pop('polling', True) # type: Union[bool, AsyncPollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType["_models.GenericResource"] - lro_delay = kwargs.pop( - 'polling_interval', - self._config.polling_interval - ) - cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] + + @overload + async def begin_create_or_update_by_id( + self, + resource_id: str, + api_version: str, + parameters: IO, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> AsyncLROPoller[_models.GenericResource]: + """Create a resource by ID. + + :param resource_id: The fully qualified ID of the resource, including the resource name and + resource type. Use the format, + /subscriptions/{guid}/resourceGroups/{resource-group-name}/{resource-provider-namespace}/{resource-type}/{resource-name}. + Required. + :type resource_id: str + :param api_version: The API version to use for the operation. Required. + :type api_version: str + :param parameters: Create or update resource parameters. Required. + :type parameters: IO + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be AsyncARMPolling. Pass in False for + this operation to not poll, or pass in your own initialized polling object for a personal + polling strategy. + :paramtype polling: bool or ~azure.core.polling.AsyncPollingMethod + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of AsyncLROPoller that returns either GenericResource or the result of + cls(response) + :rtype: + ~azure.core.polling.AsyncLROPoller[~azure.mgmt.resource.resources.v2020_10_01.models.GenericResource] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace_async + async def begin_create_or_update_by_id( + self, resource_id: str, api_version: str, parameters: Union[_models.GenericResource, IO], **kwargs: Any + ) -> AsyncLROPoller[_models.GenericResource]: + """Create a resource by ID. + + :param resource_id: The fully qualified ID of the resource, including the resource name and + resource type. Use the format, + /subscriptions/{guid}/resourceGroups/{resource-group-name}/{resource-provider-namespace}/{resource-type}/{resource-name}. + Required. + :type resource_id: str + :param api_version: The API version to use for the operation. Required. + :type api_version: str + :param parameters: Create or update resource parameters. Is either a model type or a IO type. + Required. + :type parameters: ~azure.mgmt.resource.resources.v2020_10_01.models.GenericResource or IO + :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. + Default value is None. + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be AsyncARMPolling. Pass in False for + this operation to not poll, or pass in your own initialized polling object for a personal + polling strategy. + :paramtype polling: bool or ~azure.core.polling.AsyncPollingMethod + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of AsyncLROPoller that returns either GenericResource or the result of + cls(response) + :rtype: + ~azure.core.polling.AsyncLROPoller[~azure.mgmt.resource.resources.v2020_10_01.models.GenericResource] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = kwargs.pop("params", {}) or {} + + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.GenericResource] + polling = kwargs.pop("polling", True) # type: Union[bool, AsyncPollingMethod] + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token = kwargs.pop("continuation_token", None) # type: Optional[str] if cont_token is None: - raw_result = await self._create_or_update_by_id_initial( + raw_result = await self._create_or_update_by_id_initial( # type: ignore resource_id=resource_id, api_version=api_version, parameters=parameters, content_type=content_type, - cls=lambda x,y,z: x, + cls=lambda x, y, z: x, + headers=_headers, + params=_params, **kwargs ) - kwargs.pop('error_map', None) + kwargs.pop("error_map", None) def get_long_running_output(pipeline_response): - response = pipeline_response.http_response - deserialized = self._deserialize('GenericResource', pipeline_response) + deserialized = self._deserialize("GenericResource", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - - if polling is True: polling_method = AsyncARMPolling(lro_delay, **kwargs) - elif polling is False: polling_method = AsyncNoPolling() - else: polling_method = polling + if polling is True: + polling_method = cast(AsyncPollingMethod, AsyncARMPolling(lro_delay, **kwargs)) # type: AsyncPollingMethod + elif polling is False: + polling_method = cast(AsyncPollingMethod, AsyncNoPolling()) + else: + polling_method = polling if cont_token: return AsyncLROPoller.from_continuation_token( polling_method=polling_method, continuation_token=cont_token, client=self._client, - deserialization_callback=get_long_running_output + deserialization_callback=get_long_running_output, ) return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) - begin_create_or_update_by_id.metadata = {'url': "/{resourceId}"} # type: ignore + begin_create_or_update_by_id.metadata = {"url": "/{resourceId}"} # type: ignore async def _update_by_id_initial( - self, - resource_id: str, - api_version: str, - parameters: "_models.GenericResource", - **kwargs: Any - ) -> Optional["_models.GenericResource"]: - cls = kwargs.pop('cls', None) # type: ClsType[Optional["_models.GenericResource"]] + self, resource_id: str, api_version: str, parameters: Union[_models.GenericResource, IO], **kwargs: Any + ) -> Optional[_models.GenericResource]: error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = kwargs.pop("params", {}) or {} - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[Optional[_models.GenericResource]] - _json = self._serialize.body(parameters, 'GenericResource') + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(parameters, (IO, bytes)): + _content = parameters + else: + _json = self._serialize.body(parameters, "GenericResource") - request = build_resources_update_by_id_request_initial( + request = build_resources_update_by_id_request( resource_id=resource_id, - content_type=content_type, api_version=api_version, + content_type=content_type, json=_json, - template_url=self._update_by_id_initial.metadata['url'], + content=_content, + template_url=self._update_by_id_initial.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200, 202]: @@ -5938,34 +7816,39 @@ async def _update_by_id_initial( deserialized = None if response.status_code == 200: - deserialized = self._deserialize('GenericResource', pipeline_response) + deserialized = self._deserialize("GenericResource", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - _update_by_id_initial.metadata = {'url': "/{resourceId}"} # type: ignore + _update_by_id_initial.metadata = {"url": "/{resourceId}"} # type: ignore - - @distributed_trace_async + @overload async def begin_update_by_id( self, resource_id: str, api_version: str, - parameters: "_models.GenericResource", + parameters: _models.GenericResource, + *, + content_type: str = "application/json", **kwargs: Any - ) -> AsyncLROPoller["_models.GenericResource"]: + ) -> AsyncLROPoller[_models.GenericResource]: """Updates a resource by ID. :param resource_id: The fully qualified ID of the resource, including the resource name and resource type. Use the format, /subscriptions/{guid}/resourceGroups/{resource-group-name}/{resource-provider-namespace}/{resource-type}/{resource-name}. + Required. :type resource_id: str - :param api_version: The API version to use for the operation. + :param api_version: The API version to use for the operation. Required. :type api_version: str - :param parameters: Update resource parameters. + :param parameters: Update resource parameters. Required. :type parameters: ~azure.mgmt.resource.resources.v2020_10_01.models.GenericResource + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str :keyword callable cls: A custom type or function that will be passed the direct response :keyword str continuation_token: A continuation token to restart a poller from a saved state. :keyword polling: By default, your polling method will be AsyncARMPolling. Pass in False for @@ -5978,165 +7861,243 @@ async def begin_update_by_id( cls(response) :rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.resource.resources.v2020_10_01.models.GenericResource] - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] - polling = kwargs.pop('polling', True) # type: Union[bool, AsyncPollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType["_models.GenericResource"] - lro_delay = kwargs.pop( - 'polling_interval', - self._config.polling_interval - ) - cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] + + @overload + async def begin_update_by_id( + self, + resource_id: str, + api_version: str, + parameters: IO, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> AsyncLROPoller[_models.GenericResource]: + """Updates a resource by ID. + + :param resource_id: The fully qualified ID of the resource, including the resource name and + resource type. Use the format, + /subscriptions/{guid}/resourceGroups/{resource-group-name}/{resource-provider-namespace}/{resource-type}/{resource-name}. + Required. + :type resource_id: str + :param api_version: The API version to use for the operation. Required. + :type api_version: str + :param parameters: Update resource parameters. Required. + :type parameters: IO + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be AsyncARMPolling. Pass in False for + this operation to not poll, or pass in your own initialized polling object for a personal + polling strategy. + :paramtype polling: bool or ~azure.core.polling.AsyncPollingMethod + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of AsyncLROPoller that returns either GenericResource or the result of + cls(response) + :rtype: + ~azure.core.polling.AsyncLROPoller[~azure.mgmt.resource.resources.v2020_10_01.models.GenericResource] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace_async + async def begin_update_by_id( + self, resource_id: str, api_version: str, parameters: Union[_models.GenericResource, IO], **kwargs: Any + ) -> AsyncLROPoller[_models.GenericResource]: + """Updates a resource by ID. + + :param resource_id: The fully qualified ID of the resource, including the resource name and + resource type. Use the format, + /subscriptions/{guid}/resourceGroups/{resource-group-name}/{resource-provider-namespace}/{resource-type}/{resource-name}. + Required. + :type resource_id: str + :param api_version: The API version to use for the operation. Required. + :type api_version: str + :param parameters: Update resource parameters. Is either a model type or a IO type. Required. + :type parameters: ~azure.mgmt.resource.resources.v2020_10_01.models.GenericResource or IO + :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. + Default value is None. + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be AsyncARMPolling. Pass in False for + this operation to not poll, or pass in your own initialized polling object for a personal + polling strategy. + :paramtype polling: bool or ~azure.core.polling.AsyncPollingMethod + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of AsyncLROPoller that returns either GenericResource or the result of + cls(response) + :rtype: + ~azure.core.polling.AsyncLROPoller[~azure.mgmt.resource.resources.v2020_10_01.models.GenericResource] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = kwargs.pop("params", {}) or {} + + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.GenericResource] + polling = kwargs.pop("polling", True) # type: Union[bool, AsyncPollingMethod] + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token = kwargs.pop("continuation_token", None) # type: Optional[str] if cont_token is None: - raw_result = await self._update_by_id_initial( + raw_result = await self._update_by_id_initial( # type: ignore resource_id=resource_id, api_version=api_version, parameters=parameters, content_type=content_type, - cls=lambda x,y,z: x, + cls=lambda x, y, z: x, + headers=_headers, + params=_params, **kwargs ) - kwargs.pop('error_map', None) + kwargs.pop("error_map", None) def get_long_running_output(pipeline_response): - response = pipeline_response.http_response - deserialized = self._deserialize('GenericResource', pipeline_response) + deserialized = self._deserialize("GenericResource", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - - if polling is True: polling_method = AsyncARMPolling(lro_delay, **kwargs) - elif polling is False: polling_method = AsyncNoPolling() - else: polling_method = polling + if polling is True: + polling_method = cast(AsyncPollingMethod, AsyncARMPolling(lro_delay, **kwargs)) # type: AsyncPollingMethod + elif polling is False: + polling_method = cast(AsyncPollingMethod, AsyncNoPolling()) + else: + polling_method = polling if cont_token: return AsyncLROPoller.from_continuation_token( polling_method=polling_method, continuation_token=cont_token, client=self._client, - deserialization_callback=get_long_running_output + deserialization_callback=get_long_running_output, ) return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) - begin_update_by_id.metadata = {'url': "/{resourceId}"} # type: ignore + begin_update_by_id.metadata = {"url": "/{resourceId}"} # type: ignore @distributed_trace_async - async def get_by_id( - self, - resource_id: str, - api_version: str, - **kwargs: Any - ) -> "_models.GenericResource": + async def get_by_id(self, resource_id: str, api_version: str, **kwargs: Any) -> _models.GenericResource: """Gets a resource by ID. :param resource_id: The fully qualified ID of the resource, including the resource name and resource type. Use the format, /subscriptions/{guid}/resourceGroups/{resource-group-name}/{resource-provider-namespace}/{resource-type}/{resource-name}. + Required. :type resource_id: str - :param api_version: The API version to use for the operation. + :param api_version: The API version to use for the operation. Required. :type api_version: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: GenericResource, or the result of cls(response) + :return: GenericResource or the result of cls(response) :rtype: ~azure.mgmt.resource.resources.v2020_10_01.models.GenericResource - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.GenericResource"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = kwargs.pop("params", {}) or {} + + cls = kwargs.pop("cls", None) # type: ClsType[_models.GenericResource] - request = build_resources_get_by_id_request( resource_id=resource_id, api_version=api_version, - template_url=self.get_by_id.metadata['url'], + template_url=self.get_by_id.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) - deserialized = self._deserialize('GenericResource', pipeline_response) + deserialized = self._deserialize("GenericResource", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - get_by_id.metadata = {'url': "/{resourceId}"} # type: ignore + get_by_id.metadata = {"url": "/{resourceId}"} # type: ignore -class ResourceGroupsOperations: - """ResourceGroupsOperations async operations. - You should not instantiate this class directly. Instead, you should create a Client instance that - instantiates it for you and attaches it as an attribute. +class ResourceGroupsOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. - :ivar models: Alias to model classes used in this operation group. - :type models: ~azure.mgmt.resource.resources.v2020_10_01.models - :param client: Client for service requests. - :param config: Configuration of service client. - :param serializer: An object model serializer. - :param deserializer: An object model deserializer. + Instead, you should access the following operations through + :class:`~azure.mgmt.resource.resources.v2020_10_01.aio.ResourceManagementClient`'s + :attr:`resource_groups` attribute. """ models = _models - def __init__(self, client, config, serializer, deserializer) -> None: - self._client = client - self._serialize = serializer - self._deserialize = deserializer - self._config = config + def __init__(self, *args, **kwargs) -> None: + input_args = list(args) + self._client = input_args.pop(0) if input_args else kwargs.pop("client") + self._config = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") @distributed_trace_async - async def check_existence( - self, - resource_group_name: str, - **kwargs: Any - ) -> bool: + async def check_existence(self, resource_group_name: str, **kwargs: Any) -> bool: """Checks whether a resource group exists. :param resource_group_name: The name of the resource group to check. The name is case - insensitive. + insensitive. Required. :type resource_group_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: bool, or the result of cls(response) + :return: bool or the result of cls(response) :rtype: bool - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType[None] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + 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', "2020-10-01") # type: str + api_version = kwargs.pop("api_version", _params.pop("api-version", "2020-10-01")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[None] - request = build_resource_groups_check_existence_request( resource_group_name=resource_group_name, subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.check_existence.metadata['url'], + template_url=self.check_existence.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [204, 404]: @@ -6147,39 +8108,98 @@ async def check_existence( return cls(pipeline_response, None, {}) return 200 <= response.status_code <= 299 - check_existence.metadata = {'url': "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}"} # type: ignore + check_existence.metadata = {"url": "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}"} # type: ignore - - @distributed_trace_async + @overload async def create_or_update( self, resource_group_name: str, - parameters: "_models.ResourceGroup", + parameters: _models.ResourceGroup, + *, + content_type: str = "application/json", **kwargs: Any - ) -> "_models.ResourceGroup": + ) -> _models.ResourceGroup: """Creates or updates a resource group. :param resource_group_name: The name of the resource group to create or update. Can include alphanumeric, underscore, parentheses, hyphen, period (except at end), and Unicode characters - that match the allowed characters. + that match the allowed characters. Required. :type resource_group_name: str - :param parameters: Parameters supplied to the create or update a resource group. + :param parameters: Parameters supplied to the create or update a resource group. Required. :type parameters: ~azure.mgmt.resource.resources.v2020_10_01.models.ResourceGroup + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: ResourceGroup or the result of cls(response) + :rtype: ~azure.mgmt.resource.resources.v2020_10_01.models.ResourceGroup + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + async def create_or_update( + self, resource_group_name: str, parameters: IO, *, content_type: str = "application/json", **kwargs: Any + ) -> _models.ResourceGroup: + """Creates or updates a resource group. + + :param resource_group_name: The name of the resource group to create or update. Can include + alphanumeric, underscore, parentheses, hyphen, period (except at end), and Unicode characters + that match the allowed characters. Required. + :type resource_group_name: str + :param parameters: Parameters supplied to the create or update a resource group. Required. + :type parameters: IO + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: ResourceGroup, or the result of cls(response) + :return: ResourceGroup or the result of cls(response) :rtype: ~azure.mgmt.resource.resources.v2020_10_01.models.ResourceGroup - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace_async + async def create_or_update( + self, resource_group_name: str, parameters: Union[_models.ResourceGroup, IO], **kwargs: Any + ) -> _models.ResourceGroup: + """Creates or updates a resource group. + + :param resource_group_name: The name of the resource group to create or update. Can include + alphanumeric, underscore, parentheses, hyphen, period (except at end), and Unicode characters + that match the allowed characters. Required. + :type resource_group_name: str + :param parameters: Parameters supplied to the create or update a resource group. Is either a + model type or a IO type. Required. + :type parameters: ~azure.mgmt.resource.resources.v2020_10_01.models.ResourceGroup or IO + :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. + Default value is None. + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: ResourceGroup or the result of cls(response) + :rtype: ~azure.mgmt.resource.resources.v2020_10_01.models.ResourceGroup + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.ResourceGroup"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', "2020-10-01") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + api_version = kwargs.pop("api_version", _params.pop("api-version", "2020-10-01")) # type: str + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.ResourceGroup] - _json = self._serialize.body(parameters, 'ResourceGroup') + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(parameters, (IO, bytes)): + _content = parameters + else: + _json = self._serialize.body(parameters, "ResourceGroup") request = build_resource_groups_create_or_update_request( resource_group_name=resource_group_name, @@ -6187,16 +8207,18 @@ async def create_or_update( api_version=api_version, content_type=content_type, json=_json, - template_url=self.create_or_update.metadata['url'], + content=_content, + template_url=self.create_or_update.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200, 201]: @@ -6204,47 +8226,50 @@ async def create_or_update( raise HttpResponseError(response=response, error_format=ARMErrorFormat) if response.status_code == 200: - deserialized = self._deserialize('ResourceGroup', pipeline_response) + deserialized = self._deserialize("ResourceGroup", pipeline_response) if response.status_code == 201: - deserialized = self._deserialize('ResourceGroup', pipeline_response) + deserialized = self._deserialize("ResourceGroup", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - create_or_update.metadata = {'url': "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}"} # type: ignore - + create_or_update.metadata = {"url": "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}"} # type: ignore async def _delete_initial( # pylint: disable=inconsistent-return-statements - self, - resource_group_name: str, - **kwargs: Any + self, resource_group_name: str, **kwargs: Any ) -> None: - cls = kwargs.pop('cls', None) # type: ClsType[None] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) - api_version = kwargs.pop('api_version', "2020-10-01") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - request = build_resource_groups_delete_request_initial( + api_version = kwargs.pop("api_version", _params.pop("api-version", "2020-10-01")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[None] + + request = build_resource_groups_delete_request( resource_group_name=resource_group_name, subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self._delete_initial.metadata['url'], + template_url=self._delete_initial.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200, 202]: @@ -6254,22 +8279,17 @@ async def _delete_initial( # pylint: disable=inconsistent-return-statements if cls: return cls(pipeline_response, None, {}) - _delete_initial.metadata = {'url': "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}"} # type: ignore - + _delete_initial.metadata = {"url": "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}"} # type: ignore @distributed_trace_async - async def begin_delete( # pylint: disable=inconsistent-return-statements - self, - resource_group_name: str, - **kwargs: Any - ) -> AsyncLROPoller[None]: + async def begin_delete(self, resource_group_name: str, **kwargs: Any) -> AsyncLROPoller[None]: """Deletes a resource group. When you delete a resource group, all of its resources are also deleted. Deleting a resource group deletes all of its template deployments and currently stored operations. :param resource_group_name: The name of the resource group to delete. The name is case - insensitive. + insensitive. Required. :type resource_group_name: str :keyword callable cls: A custom type or function that will be passed the direct response :keyword str continuation_token: A continuation token to restart a poller from a saved state. @@ -6281,106 +8301,113 @@ async def begin_delete( # pylint: disable=inconsistent-return-statements Retry-After header is present. :return: An instance of AsyncLROPoller that returns either None or the result of cls(response) :rtype: ~azure.core.polling.AsyncLROPoller[None] - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - api_version = kwargs.pop('api_version', "2020-10-01") # type: str - polling = kwargs.pop('polling', True) # type: Union[bool, AsyncPollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType[None] - lro_delay = kwargs.pop( - 'polling_interval', - self._config.polling_interval - ) - cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2020-10-01")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[None] + polling = kwargs.pop("polling", True) # type: Union[bool, AsyncPollingMethod] + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token = kwargs.pop("continuation_token", None) # type: Optional[str] if cont_token is None: - raw_result = await self._delete_initial( + raw_result = await self._delete_initial( # type: ignore resource_group_name=resource_group_name, api_version=api_version, - cls=lambda x,y,z: x, + cls=lambda x, y, z: x, + headers=_headers, + params=_params, **kwargs ) - kwargs.pop('error_map', None) + kwargs.pop("error_map", None) - def get_long_running_output(pipeline_response): + def get_long_running_output(pipeline_response): # pylint: disable=inconsistent-return-statements if cls: return cls(pipeline_response, None, {}) - - if polling is True: polling_method = AsyncARMPolling(lro_delay, **kwargs) - elif polling is False: polling_method = AsyncNoPolling() - else: polling_method = polling + if polling is True: + polling_method = cast(AsyncPollingMethod, AsyncARMPolling(lro_delay, **kwargs)) # type: AsyncPollingMethod + elif polling is False: + polling_method = cast(AsyncPollingMethod, AsyncNoPolling()) + else: + polling_method = polling if cont_token: return AsyncLROPoller.from_continuation_token( polling_method=polling_method, continuation_token=cont_token, client=self._client, - deserialization_callback=get_long_running_output + deserialization_callback=get_long_running_output, ) return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) - begin_delete.metadata = {'url': "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}"} # type: ignore + begin_delete.metadata = {"url": "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}"} # type: ignore @distributed_trace_async - async def get( - self, - resource_group_name: str, - **kwargs: Any - ) -> "_models.ResourceGroup": + async def get(self, resource_group_name: str, **kwargs: Any) -> _models.ResourceGroup: """Gets a resource group. :param resource_group_name: The name of the resource group to get. The name is case - insensitive. + insensitive. Required. :type resource_group_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: ResourceGroup, or the result of cls(response) + :return: ResourceGroup or the result of cls(response) :rtype: ~azure.mgmt.resource.resources.v2020_10_01.models.ResourceGroup - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.ResourceGroup"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) - api_version = kwargs.pop('api_version', "2020-10-01") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2020-10-01")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[_models.ResourceGroup] - request = build_resource_groups_get_request( resource_group_name=resource_group_name, subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.get.metadata['url'], + template_url=self.get.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) - deserialized = self._deserialize('ResourceGroup', pipeline_response) + deserialized = self._deserialize("ResourceGroup", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - get.metadata = {'url': "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}"} # type: ignore - + get.metadata = {"url": "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}"} # type: ignore - @distributed_trace_async + @overload async def update( self, resource_group_name: str, - parameters: "_models.ResourceGroupPatchable", + parameters: _models.ResourceGroupPatchable, + *, + content_type: str = "application/json", **kwargs: Any - ) -> "_models.ResourceGroup": + ) -> _models.ResourceGroup: """Updates a resource group. Resource groups can be updated through a simple PATCH operation to a group address. The format @@ -6388,25 +8415,90 @@ async def update( the current value is retained. :param resource_group_name: The name of the resource group to update. The name is case - insensitive. + insensitive. Required. :type resource_group_name: str - :param parameters: Parameters supplied to update a resource group. + :param parameters: Parameters supplied to update a resource group. Required. :type parameters: ~azure.mgmt.resource.resources.v2020_10_01.models.ResourceGroupPatchable + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: ResourceGroup or the result of cls(response) + :rtype: ~azure.mgmt.resource.resources.v2020_10_01.models.ResourceGroup + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + async def update( + self, resource_group_name: str, parameters: IO, *, content_type: str = "application/json", **kwargs: Any + ) -> _models.ResourceGroup: + """Updates a resource group. + + Resource groups can be updated through a simple PATCH operation to a group address. The format + of the request is the same as that for creating a resource group. If a field is unspecified, + the current value is retained. + + :param resource_group_name: The name of the resource group to update. The name is case + insensitive. Required. + :type resource_group_name: str + :param parameters: Parameters supplied to update a resource group. Required. + :type parameters: IO + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: ResourceGroup, or the result of cls(response) + :return: ResourceGroup or the result of cls(response) :rtype: ~azure.mgmt.resource.resources.v2020_10_01.models.ResourceGroup - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace_async + async def update( + self, resource_group_name: str, parameters: Union[_models.ResourceGroupPatchable, IO], **kwargs: Any + ) -> _models.ResourceGroup: + """Updates a resource group. + + Resource groups can be updated through a simple PATCH operation to a group address. The format + of the request is the same as that for creating a resource group. If a field is unspecified, + the current value is retained. + + :param resource_group_name: The name of the resource group to update. The name is case + insensitive. Required. + :type resource_group_name: str + :param parameters: Parameters supplied to update a resource group. Is either a model type or a + IO type. Required. + :type parameters: ~azure.mgmt.resource.resources.v2020_10_01.models.ResourceGroupPatchable or + IO + :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. + Default value is None. + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: ResourceGroup or the result of cls(response) + :rtype: ~azure.mgmt.resource.resources.v2020_10_01.models.ResourceGroup + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.ResourceGroup"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', "2020-10-01") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + api_version = kwargs.pop("api_version", _params.pop("api-version", "2020-10-01")) # type: str + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.ResourceGroup] - _json = self._serialize.body(parameters, 'ResourceGroupPatchable') + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(parameters, (IO, bytes)): + _content = parameters + else: + _json = self._serialize.body(parameters, "ResourceGroupPatchable") request = build_resource_groups_update_request( resource_group_name=resource_group_name, @@ -6414,65 +8506,77 @@ async def update( api_version=api_version, content_type=content_type, json=_json, - template_url=self.update.metadata['url'], + content=_content, + template_url=self.update.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) - deserialized = self._deserialize('ResourceGroup', pipeline_response) + deserialized = self._deserialize("ResourceGroup", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - update.metadata = {'url': "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}"} # type: ignore - + update.metadata = {"url": "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}"} # type: ignore async def _export_template_initial( - self, - resource_group_name: str, - parameters: "_models.ExportTemplateRequest", - **kwargs: Any - ) -> Optional["_models.ResourceGroupExportResult"]: - cls = kwargs.pop('cls', None) # type: ClsType[Optional["_models.ResourceGroupExportResult"]] + self, resource_group_name: str, parameters: Union[_models.ExportTemplateRequest, IO], **kwargs: Any + ) -> Optional[_models.ResourceGroupExportResult]: error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) - api_version = kwargs.pop('api_version', "2020-10-01") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - _json = self._serialize.body(parameters, 'ExportTemplateRequest') + api_version = kwargs.pop("api_version", _params.pop("api-version", "2020-10-01")) # type: str + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[Optional[_models.ResourceGroupExportResult]] - request = build_resource_groups_export_template_request_initial( - subscription_id=self._config.subscription_id, + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(parameters, (IO, bytes)): + _content = parameters + else: + _json = self._serialize.body(parameters, "ExportTemplateRequest") + + request = build_resource_groups_export_template_request( resource_group_name=resource_group_name, + subscription_id=self._config.subscription_id, api_version=api_version, content_type=content_type, json=_json, - template_url=self._export_template_initial.metadata['url'], + content=_content, + template_url=self._export_template_initial.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200, 202]: @@ -6481,29 +8585,93 @@ async def _export_template_initial( deserialized = None if response.status_code == 200: - deserialized = self._deserialize('ResourceGroupExportResult', pipeline_response) + deserialized = self._deserialize("ResourceGroupExportResult", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - _export_template_initial.metadata = {'url': "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/exportTemplate"} # type: ignore - + _export_template_initial.metadata = {"url": "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/exportTemplate"} # type: ignore - @distributed_trace_async + @overload async def begin_export_template( self, resource_group_name: str, - parameters: "_models.ExportTemplateRequest", + parameters: _models.ExportTemplateRequest, + *, + content_type: str = "application/json", **kwargs: Any - ) -> AsyncLROPoller["_models.ResourceGroupExportResult"]: + ) -> AsyncLROPoller[_models.ResourceGroupExportResult]: + """Captures the specified resource group as a template. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param parameters: Parameters for exporting the template. Required. + :type parameters: ~azure.mgmt.resource.resources.v2020_10_01.models.ExportTemplateRequest + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be AsyncARMPolling. Pass in False for + this operation to not poll, or pass in your own initialized polling object for a personal + polling strategy. + :paramtype polling: bool or ~azure.core.polling.AsyncPollingMethod + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of AsyncLROPoller that returns either ResourceGroupExportResult or the + result of cls(response) + :rtype: + ~azure.core.polling.AsyncLROPoller[~azure.mgmt.resource.resources.v2020_10_01.models.ResourceGroupExportResult] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + async def begin_export_template( + self, resource_group_name: str, parameters: IO, *, content_type: str = "application/json", **kwargs: Any + ) -> AsyncLROPoller[_models.ResourceGroupExportResult]: + """Captures the specified resource group as a template. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param parameters: Parameters for exporting the template. Required. + :type parameters: IO + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be AsyncARMPolling. Pass in False for + this operation to not poll, or pass in your own initialized polling object for a personal + polling strategy. + :paramtype polling: bool or ~azure.core.polling.AsyncPollingMethod + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of AsyncLROPoller that returns either ResourceGroupExportResult or the + result of cls(response) + :rtype: + ~azure.core.polling.AsyncLROPoller[~azure.mgmt.resource.resources.v2020_10_01.models.ResourceGroupExportResult] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace_async + async def begin_export_template( + self, resource_group_name: str, parameters: Union[_models.ExportTemplateRequest, IO], **kwargs: Any + ) -> AsyncLROPoller[_models.ResourceGroupExportResult]: """Captures the specified resource group as a template. :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. :type resource_group_name: str - :param parameters: Parameters for exporting the template. - :type parameters: ~azure.mgmt.resource.resources.v2020_10_01.models.ExportTemplateRequest + :param parameters: Parameters for exporting the template. Is either a model type or a IO type. + Required. + :type parameters: ~azure.mgmt.resource.resources.v2020_10_01.models.ExportTemplateRequest or IO + :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. + Default value is None. + :paramtype content_type: str :keyword callable cls: A custom type or function that will be passed the direct response :keyword str continuation_token: A continuation token to restart a poller from a saved state. :keyword polling: By default, your polling method will be AsyncARMPolling. Pass in False for @@ -6516,57 +8684,59 @@ async def begin_export_template( result of cls(response) :rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.resource.resources.v2020_10_01.models.ResourceGroupExportResult] - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - api_version = kwargs.pop('api_version', "2020-10-01") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] - polling = kwargs.pop('polling', True) # type: Union[bool, AsyncPollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType["_models.ResourceGroupExportResult"] - lro_delay = kwargs.pop( - 'polling_interval', - self._config.polling_interval - ) - cont_token = kwargs.pop('continuation_token', None) # type: Optional[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", "2020-10-01")) # type: str + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.ResourceGroupExportResult] + polling = kwargs.pop("polling", True) # type: Union[bool, AsyncPollingMethod] + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token = kwargs.pop("continuation_token", None) # type: Optional[str] if cont_token is None: - raw_result = await self._export_template_initial( + raw_result = await self._export_template_initial( # type: ignore resource_group_name=resource_group_name, parameters=parameters, api_version=api_version, content_type=content_type, - cls=lambda x,y,z: x, + cls=lambda x, y, z: x, + headers=_headers, + params=_params, **kwargs ) - kwargs.pop('error_map', None) + kwargs.pop("error_map", None) def get_long_running_output(pipeline_response): - response = pipeline_response.http_response - deserialized = self._deserialize('ResourceGroupExportResult', pipeline_response) + deserialized = self._deserialize("ResourceGroupExportResult", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - - if polling is True: polling_method = AsyncARMPolling(lro_delay, lro_options={'final-state-via': 'location'}, **kwargs) - elif polling is False: polling_method = AsyncNoPolling() - else: polling_method = polling + if polling is True: + polling_method = cast( + AsyncPollingMethod, AsyncARMPolling(lro_delay, lro_options={"final-state-via": "location"}, **kwargs) + ) # type: AsyncPollingMethod + elif polling is False: + polling_method = cast(AsyncPollingMethod, AsyncNoPolling()) + else: + polling_method = polling if cont_token: return AsyncLROPoller.from_continuation_token( polling_method=polling_method, continuation_token=cont_token, client=self._client, - deserialization_callback=get_long_running_output + deserialization_callback=get_long_running_output, ) return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) - begin_export_template.metadata = {'url': "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/exportTemplate"} # type: ignore + begin_export_template.metadata = {"url": "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/exportTemplate"} # type: ignore @distributed_trace def list( - self, - filter: Optional[str] = None, - top: Optional[int] = None, - **kwargs: Any - ) -> AsyncIterable["_models.ResourceGroupListResult"]: + self, filter: Optional[str] = None, top: Optional[int] = None, **kwargs: Any + ) -> AsyncIterable["_models.ResourceGroup"]: """Gets all the resource groups for a subscription. :param filter: The filter to apply on the operation.:code:`
`:code:`
`You can filter by @@ -6577,40 +8747,48 @@ def list( Default value is None. :type top: int :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either ResourceGroupListResult or the result of - cls(response) + :return: An iterator like instance of either ResourceGroup or the result of cls(response) :rtype: - ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.resource.resources.v2020_10_01.models.ResourceGroupListResult] - :raises: ~azure.core.exceptions.HttpResponseError + ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.resource.resources.v2020_10_01.models.ResourceGroup] + :raises ~azure.core.exceptions.HttpResponseError: """ - api_version = kwargs.pop('api_version', "2020-10-01") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2020-10-01")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[_models.ResourceGroupListResult] - cls = kwargs.pop('cls', None) # type: ClsType["_models.ResourceGroupListResult"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) + def prepare_request(next_link=None): if not next_link: - + request = build_resource_groups_list_request( subscription_id=self._config.subscription_id, - api_version=api_version, filter=filter, top=top, - template_url=self.list.metadata['url'], + 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.url = self._client.format_url(request.url) # type: ignore else: - - request = build_resource_groups_list_request( - subscription_id=self._config.subscription_id, - template_url=next_link, - ) + # make call to next link with the client's api-version + _parsed_next_link = urlparse(next_link) + _next_request_params = case_insensitive_dict(parse_qs(_parsed_next_link.query)) + _next_request_params["api-version"] = self._config.api_version + request = HttpRequest("GET", urljoin(next_link, _parsed_next_link.path), params=_next_request_params) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore request.method = "GET" return request @@ -6624,10 +8802,8 @@ async def extract_data(pipeline_response): async def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) response = pipeline_response.http_response @@ -6637,39 +8813,33 @@ async def get_next(next_link=None): return pipeline_response + return AsyncItemPaged(get_next, extract_data) - return AsyncItemPaged( - get_next, extract_data - ) - list.metadata = {'url': "/subscriptions/{subscriptionId}/resourcegroups"} # type: ignore -class TagsOperations: - """TagsOperations async operations. + list.metadata = {"url": "/subscriptions/{subscriptionId}/resourcegroups"} # type: ignore - You should not instantiate this class directly. Instead, you should create a Client instance that - instantiates it for you and attaches it as an attribute. - :ivar models: Alias to model classes used in this operation group. - :type models: ~azure.mgmt.resource.resources.v2020_10_01.models - :param client: Client for service requests. - :param config: Configuration of service client. - :param serializer: An object model serializer. - :param deserializer: An object model deserializer. +class TagsOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. + + Instead, you should access the following operations through + :class:`~azure.mgmt.resource.resources.v2020_10_01.aio.ResourceManagementClient`'s + :attr:`tags` attribute. """ models = _models - def __init__(self, client, config, serializer, deserializer) -> None: - self._client = client - self._serialize = serializer - self._deserialize = deserializer - self._config = config + def __init__(self, *args, **kwargs) -> None: + input_args = list(args) + self._client = input_args.pop(0) if input_args else kwargs.pop("client") + self._config = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") @distributed_trace_async async def delete_value( # pylint: disable=inconsistent-return-statements - self, - tag_name: str, - tag_value: str, - **kwargs: Any + self, tag_name: str, tag_value: str, **kwargs: Any ) -> None: """Deletes a predefined tag value for a predefined tag name. @@ -6677,39 +8847,45 @@ async def delete_value( # pylint: disable=inconsistent-return-statements predefined tag name. The value being deleted must not be in use as a tag value for the given tag name for any resource. - :param tag_name: The name of the tag. + :param tag_name: The name of the tag. Required. :type tag_name: str - :param tag_value: The value of the tag to delete. + :param tag_value: The value of the tag to delete. Required. :type tag_value: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: None, or the result of cls(response) + :return: None or the result of cls(response) :rtype: None - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType[None] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + 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', "2020-10-01") # type: str + api_version = kwargs.pop("api_version", _params.pop("api-version", "2020-10-01")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[None] - request = build_tags_delete_value_request( tag_name=tag_name, tag_value=tag_value, subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.delete_value.metadata['url'], + template_url=self.delete_value.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200, 204]: @@ -6719,54 +8895,54 @@ async def delete_value( # pylint: disable=inconsistent-return-statements if cls: return cls(pipeline_response, None, {}) - delete_value.metadata = {'url': "/subscriptions/{subscriptionId}/tagNames/{tagName}/tagValues/{tagValue}"} # type: ignore - + delete_value.metadata = {"url": "/subscriptions/{subscriptionId}/tagNames/{tagName}/tagValues/{tagValue}"} # type: ignore @distributed_trace_async - async def create_or_update_value( - self, - tag_name: str, - tag_value: str, - **kwargs: Any - ) -> "_models.TagValue": + async def create_or_update_value(self, tag_name: str, tag_value: str, **kwargs: Any) -> _models.TagValue: """Creates a predefined value for a predefined tag name. This operation allows adding a value to the list of predefined values for an existing predefined tag name. A tag value can have a maximum of 256 characters. - :param tag_name: The name of the tag. + :param tag_name: The name of the tag. Required. :type tag_name: str - :param tag_value: The value of the tag to create. + :param tag_value: The value of the tag to create. Required. :type tag_value: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: TagValue, or the result of cls(response) + :return: TagValue or the result of cls(response) :rtype: ~azure.mgmt.resource.resources.v2020_10_01.models.TagValue - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.TagValue"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) - api_version = kwargs.pop('api_version', "2020-10-01") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2020-10-01")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[_models.TagValue] - request = build_tags_create_or_update_value_request( tag_name=tag_name, tag_value=tag_value, subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.create_or_update_value.metadata['url'], + template_url=self.create_or_update_value.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200, 201]: @@ -6774,25 +8950,20 @@ async def create_or_update_value( raise HttpResponseError(response=response, error_format=ARMErrorFormat) if response.status_code == 200: - deserialized = self._deserialize('TagValue', pipeline_response) + deserialized = self._deserialize("TagValue", pipeline_response) if response.status_code == 201: - deserialized = self._deserialize('TagValue', pipeline_response) + deserialized = self._deserialize("TagValue", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - create_or_update_value.metadata = {'url': "/subscriptions/{subscriptionId}/tagNames/{tagName}/tagValues/{tagValue}"} # type: ignore - + create_or_update_value.metadata = {"url": "/subscriptions/{subscriptionId}/tagNames/{tagName}/tagValues/{tagValue}"} # type: ignore @distributed_trace_async - async def create_or_update( - self, - tag_name: str, - **kwargs: Any - ) -> "_models.TagDetails": + async def create_or_update(self, tag_name: str, **kwargs: Any) -> _models.TagDetails: """Creates a predefined tag name. This operation allows adding a name to the list of predefined tag names for the given @@ -6800,36 +8971,42 @@ async def create_or_update( names cannot have the following prefixes which are reserved for Azure use: 'microsoft', 'azure', 'windows'. - :param tag_name: The name of the tag to create. + :param tag_name: The name of the tag to create. Required. :type tag_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: TagDetails, or the result of cls(response) + :return: TagDetails or the result of cls(response) :rtype: ~azure.mgmt.resource.resources.v2020_10_01.models.TagDetails - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.TagDetails"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) - api_version = kwargs.pop('api_version', "2020-10-01") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2020-10-01")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[_models.TagDetails] - request = build_tags_create_or_update_request( tag_name=tag_name, subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.create_or_update.metadata['url'], + template_url=self.create_or_update.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200, 201]: @@ -6837,61 +9014,62 @@ async def create_or_update( raise HttpResponseError(response=response, error_format=ARMErrorFormat) if response.status_code == 200: - deserialized = self._deserialize('TagDetails', pipeline_response) + deserialized = self._deserialize("TagDetails", pipeline_response) if response.status_code == 201: - deserialized = self._deserialize('TagDetails', pipeline_response) + deserialized = self._deserialize("TagDetails", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - create_or_update.metadata = {'url': "/subscriptions/{subscriptionId}/tagNames/{tagName}"} # type: ignore - + create_or_update.metadata = {"url": "/subscriptions/{subscriptionId}/tagNames/{tagName}"} # type: ignore @distributed_trace_async - async def delete( # pylint: disable=inconsistent-return-statements - self, - tag_name: str, - **kwargs: Any - ) -> None: + async def delete(self, tag_name: str, **kwargs: Any) -> None: # pylint: disable=inconsistent-return-statements """Deletes a predefined tag name. This operation allows deleting a name from the list of predefined tag names for the given subscription. The name being deleted must not be in use as a tag name for any resource. All predefined values for the given name must have already been deleted. - :param tag_name: The name of the tag. + :param tag_name: The name of the tag. Required. :type tag_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: None, or the result of cls(response) + :return: None or the result of cls(response) :rtype: None - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType[None] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) - api_version = kwargs.pop('api_version', "2020-10-01") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2020-10-01")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[None] - request = build_tags_delete_request( tag_name=tag_name, subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.delete.metadata['url'], + template_url=self.delete.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200, 204]: @@ -6901,14 +9079,10 @@ async def delete( # pylint: disable=inconsistent-return-statements if cls: return cls(pipeline_response, None, {}) - delete.metadata = {'url': "/subscriptions/{subscriptionId}/tagNames/{tagName}"} # type: ignore - + delete.metadata = {"url": "/subscriptions/{subscriptionId}/tagNames/{tagName}"} # type: ignore @distributed_trace - def list( - self, - **kwargs: Any - ) -> AsyncIterable["_models.TagsListResult"]: + def list(self, **kwargs: Any) -> AsyncIterable["_models.TagDetails"]: """Gets a summary of tag usage under the subscription. This operation performs a union of predefined tags, resource tags, resource group tags and @@ -6917,37 +9091,46 @@ def list( result. :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either TagsListResult or the result of cls(response) + :return: An iterator like instance of either TagDetails or the result of cls(response) :rtype: - ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.resource.resources.v2020_10_01.models.TagsListResult] - :raises: ~azure.core.exceptions.HttpResponseError + ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.resource.resources.v2020_10_01.models.TagDetails] + :raises ~azure.core.exceptions.HttpResponseError: """ - api_version = kwargs.pop('api_version', "2020-10-01") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2020-10-01")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[_models.TagsListResult] - cls = kwargs.pop('cls', None) # type: ClsType["_models.TagsListResult"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) + def prepare_request(next_link=None): if not next_link: - + request = build_tags_list_request( subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.list.metadata['url'], + template_url=self.list.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore else: - - request = build_tags_list_request( - subscription_id=self._config.subscription_id, - template_url=next_link, - ) + # make call to next link with the client's api-version + _parsed_next_link = urlparse(next_link) + _next_request_params = case_insensitive_dict(parse_qs(_parsed_next_link.query)) + _next_request_params["api-version"] = self._config.api_version + request = HttpRequest("GET", urljoin(next_link, _parsed_next_link.path), params=_next_request_params) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore request.method = "GET" return request @@ -6961,10 +9144,8 @@ async def extract_data(pipeline_response): async def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) response = pipeline_response.http_response @@ -6974,82 +9155,139 @@ async def get_next(next_link=None): return pipeline_response + return AsyncItemPaged(get_next, extract_data) - return AsyncItemPaged( - get_next, extract_data - ) - list.metadata = {'url': "/subscriptions/{subscriptionId}/tagNames"} # type: ignore + list.metadata = {"url": "/subscriptions/{subscriptionId}/tagNames"} # type: ignore - @distributed_trace_async + @overload async def create_or_update_at_scope( - self, - scope: str, - parameters: "_models.TagsResource", - **kwargs: Any - ) -> "_models.TagsResource": + self, scope: str, parameters: _models.TagsResource, *, content_type: str = "application/json", **kwargs: Any + ) -> _models.TagsResource: """Creates or updates the entire set of tags on a resource or subscription. This operation allows adding or replacing the entire set of tags on the specified resource or subscription. The specified entity can have a maximum of 50 tags. - :param scope: The resource scope. + :param scope: The resource scope. Required. :type scope: str - :param parameters: + :param parameters: Required. :type parameters: ~azure.mgmt.resource.resources.v2020_10_01.models.TagsResource + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: TagsResource or the result of cls(response) + :rtype: ~azure.mgmt.resource.resources.v2020_10_01.models.TagsResource + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + async def create_or_update_at_scope( + self, scope: str, parameters: IO, *, content_type: str = "application/json", **kwargs: Any + ) -> _models.TagsResource: + """Creates or updates the entire set of tags on a resource or subscription. + + This operation allows adding or replacing the entire set of tags on the specified resource or + subscription. The specified entity can have a maximum of 50 tags. + + :param scope: The resource scope. Required. + :type scope: str + :param parameters: Required. + :type parameters: IO + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: TagsResource or the result of cls(response) + :rtype: ~azure.mgmt.resource.resources.v2020_10_01.models.TagsResource + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace_async + async def create_or_update_at_scope( + self, scope: str, parameters: Union[_models.TagsResource, IO], **kwargs: Any + ) -> _models.TagsResource: + """Creates or updates the entire set of tags on a resource or subscription. + + This operation allows adding or replacing the entire set of tags on the specified resource or + subscription. The specified entity can have a maximum of 50 tags. + + :param scope: The resource scope. Required. + :type scope: str + :param parameters: Is either a model type or a IO type. Required. + :type parameters: ~azure.mgmt.resource.resources.v2020_10_01.models.TagsResource or IO + :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. + Default value is None. + :paramtype content_type: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: TagsResource, or the result of cls(response) + :return: TagsResource or the result of cls(response) :rtype: ~azure.mgmt.resource.resources.v2020_10_01.models.TagsResource - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.TagsResource"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) - api_version = kwargs.pop('api_version', "2020-10-01") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - _json = self._serialize.body(parameters, 'TagsResource') + api_version = kwargs.pop("api_version", _params.pop("api-version", "2020-10-01")) # type: str + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.TagsResource] + + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(parameters, (IO, bytes)): + _content = parameters + else: + _json = self._serialize.body(parameters, "TagsResource") request = build_tags_create_or_update_at_scope_request( scope=scope, api_version=api_version, content_type=content_type, json=_json, - template_url=self.create_or_update_at_scope.metadata['url'], + content=_content, + template_url=self.create_or_update_at_scope.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) - deserialized = self._deserialize('TagsResource', pipeline_response) + deserialized = self._deserialize("TagsResource", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - create_or_update_at_scope.metadata = {'url': "/{scope}/providers/Microsoft.Resources/tags/default"} # type: ignore + create_or_update_at_scope.metadata = {"url": "/{scope}/providers/Microsoft.Resources/tags/default"} # type: ignore - - @distributed_trace_async + @overload async def update_at_scope( self, scope: str, - parameters: "_models.TagsPatchResource", + parameters: _models.TagsPatchResource, + *, + content_type: str = "application/json", **kwargs: Any - ) -> "_models.TagsResource": + ) -> _models.TagsResource: """Selectively updates the set of tags on a resource or subscription. This operation allows replacing, merging or selectively deleting tags on the specified resource @@ -7059,151 +9297,224 @@ async def update_at_scope( names. The 'delete' option allows selectively deleting tags based on given names or name/value pairs. - :param scope: The resource scope. + :param scope: The resource scope. Required. :type scope: str - :param parameters: + :param parameters: Required. :type parameters: ~azure.mgmt.resource.resources.v2020_10_01.models.TagsPatchResource + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: TagsResource or the result of cls(response) + :rtype: ~azure.mgmt.resource.resources.v2020_10_01.models.TagsResource + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + async def update_at_scope( + self, scope: str, parameters: IO, *, content_type: str = "application/json", **kwargs: Any + ) -> _models.TagsResource: + """Selectively updates the set of tags on a resource or subscription. + + This operation allows replacing, merging or selectively deleting tags on the specified resource + or subscription. The specified entity can have a maximum of 50 tags at the end of the + operation. The 'replace' option replaces the entire set of existing tags with a new set. The + 'merge' option allows adding tags with new names and updating the values of tags with existing + names. The 'delete' option allows selectively deleting tags based on given names or name/value + pairs. + + :param scope: The resource scope. Required. + :type scope: str + :param parameters: Required. + :type parameters: IO + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: TagsResource or the result of cls(response) + :rtype: ~azure.mgmt.resource.resources.v2020_10_01.models.TagsResource + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace_async + async def update_at_scope( + self, scope: str, parameters: Union[_models.TagsPatchResource, IO], **kwargs: Any + ) -> _models.TagsResource: + """Selectively updates the set of tags on a resource or subscription. + + This operation allows replacing, merging or selectively deleting tags on the specified resource + or subscription. The specified entity can have a maximum of 50 tags at the end of the + operation. The 'replace' option replaces the entire set of existing tags with a new set. The + 'merge' option allows adding tags with new names and updating the values of tags with existing + names. The 'delete' option allows selectively deleting tags based on given names or name/value + pairs. + + :param scope: The resource scope. Required. + :type scope: str + :param parameters: Is either a model type or a IO type. Required. + :type parameters: ~azure.mgmt.resource.resources.v2020_10_01.models.TagsPatchResource or IO + :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. + Default value is None. + :paramtype content_type: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: TagsResource, or the result of cls(response) + :return: TagsResource or the result of cls(response) :rtype: ~azure.mgmt.resource.resources.v2020_10_01.models.TagsResource - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.TagsResource"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) - api_version = kwargs.pop('api_version', "2020-10-01") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - _json = self._serialize.body(parameters, 'TagsPatchResource') + api_version = kwargs.pop("api_version", _params.pop("api-version", "2020-10-01")) # type: str + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.TagsResource] + + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(parameters, (IO, bytes)): + _content = parameters + else: + _json = self._serialize.body(parameters, "TagsPatchResource") request = build_tags_update_at_scope_request( scope=scope, api_version=api_version, content_type=content_type, json=_json, - template_url=self.update_at_scope.metadata['url'], + content=_content, + template_url=self.update_at_scope.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) - deserialized = self._deserialize('TagsResource', pipeline_response) + deserialized = self._deserialize("TagsResource", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - update_at_scope.metadata = {'url': "/{scope}/providers/Microsoft.Resources/tags/default"} # type: ignore - + update_at_scope.metadata = {"url": "/{scope}/providers/Microsoft.Resources/tags/default"} # type: ignore @distributed_trace_async - async def get_at_scope( - self, - scope: str, - **kwargs: Any - ) -> "_models.TagsResource": + async def get_at_scope(self, scope: str, **kwargs: Any) -> _models.TagsResource: """Gets the entire set of tags on a resource or subscription. Gets the entire set of tags on a resource or subscription. - :param scope: The resource scope. + :param scope: The resource scope. Required. :type scope: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: TagsResource, or the result of cls(response) + :return: TagsResource or the result of cls(response) :rtype: ~azure.mgmt.resource.resources.v2020_10_01.models.TagsResource - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.TagsResource"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + 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', "2020-10-01") # type: str + api_version = kwargs.pop("api_version", _params.pop("api-version", "2020-10-01")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[_models.TagsResource] - request = build_tags_get_at_scope_request( scope=scope, api_version=api_version, - template_url=self.get_at_scope.metadata['url'], + template_url=self.get_at_scope.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) - deserialized = self._deserialize('TagsResource', pipeline_response) + deserialized = self._deserialize("TagsResource", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - get_at_scope.metadata = {'url': "/{scope}/providers/Microsoft.Resources/tags/default"} # type: ignore - + get_at_scope.metadata = {"url": "/{scope}/providers/Microsoft.Resources/tags/default"} # type: ignore @distributed_trace_async async def delete_at_scope( # pylint: disable=inconsistent-return-statements - self, - scope: str, - **kwargs: Any + self, scope: str, **kwargs: Any ) -> None: """Deletes the entire set of tags on a resource or subscription. Deletes the entire set of tags on a resource or subscription. - :param scope: The resource scope. + :param scope: The resource scope. Required. :type scope: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: None, or the result of cls(response) + :return: None or the result of cls(response) :rtype: None - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType[None] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + 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', "2020-10-01") # type: str + api_version = kwargs.pop("api_version", _params.pop("api-version", "2020-10-01")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[None] - request = build_tags_delete_at_scope_request( scope=scope, api_version=api_version, - template_url=self.delete_at_scope.metadata['url'], + template_url=self.delete_at_scope.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200]: @@ -7213,143 +9524,145 @@ async def delete_at_scope( # pylint: disable=inconsistent-return-statements if cls: return cls(pipeline_response, None, {}) - delete_at_scope.metadata = {'url': "/{scope}/providers/Microsoft.Resources/tags/default"} # type: ignore + delete_at_scope.metadata = {"url": "/{scope}/providers/Microsoft.Resources/tags/default"} # type: ignore -class DeploymentOperationsOperations: - """DeploymentOperationsOperations async operations. - You should not instantiate this class directly. Instead, you should create a Client instance that - instantiates it for you and attaches it as an attribute. +class DeploymentOperationsOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. - :ivar models: Alias to model classes used in this operation group. - :type models: ~azure.mgmt.resource.resources.v2020_10_01.models - :param client: Client for service requests. - :param config: Configuration of service client. - :param serializer: An object model serializer. - :param deserializer: An object model deserializer. + Instead, you should access the following operations through + :class:`~azure.mgmt.resource.resources.v2020_10_01.aio.ResourceManagementClient`'s + :attr:`deployment_operations` attribute. """ models = _models - def __init__(self, client, config, serializer, deserializer) -> None: - self._client = client - self._serialize = serializer - self._deserialize = deserializer - self._config = config + def __init__(self, *args, **kwargs) -> None: + input_args = list(args) + self._client = input_args.pop(0) if input_args else kwargs.pop("client") + self._config = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") @distributed_trace_async async def get_at_scope( - self, - scope: str, - deployment_name: str, - operation_id: str, - **kwargs: Any - ) -> "_models.DeploymentOperation": + self, scope: str, deployment_name: str, operation_id: str, **kwargs: Any + ) -> _models.DeploymentOperation: """Gets a deployments operation. - :param scope: The resource scope. + :param scope: The resource scope. Required. :type scope: str - :param deployment_name: The name of the deployment. + :param deployment_name: The name of the deployment. Required. :type deployment_name: str - :param operation_id: The ID of the operation to get. + :param operation_id: The ID of the operation to get. Required. :type operation_id: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: DeploymentOperation, or the result of cls(response) + :return: DeploymentOperation or the result of cls(response) :rtype: ~azure.mgmt.resource.resources.v2020_10_01.models.DeploymentOperation - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.DeploymentOperation"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) - api_version = kwargs.pop('api_version', "2020-10-01") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2020-10-01")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[_models.DeploymentOperation] - request = build_deployment_operations_get_at_scope_request( scope=scope, deployment_name=deployment_name, operation_id=operation_id, api_version=api_version, - template_url=self.get_at_scope.metadata['url'], + template_url=self.get_at_scope.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) - deserialized = self._deserialize('DeploymentOperation', pipeline_response) + deserialized = self._deserialize("DeploymentOperation", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - get_at_scope.metadata = {'url': "/{scope}/providers/Microsoft.Resources/deployments/{deploymentName}/operations/{operationId}"} # type: ignore - + get_at_scope.metadata = {"url": "/{scope}/providers/Microsoft.Resources/deployments/{deploymentName}/operations/{operationId}"} # type: ignore @distributed_trace def list_at_scope( - self, - scope: str, - deployment_name: str, - top: Optional[int] = None, - **kwargs: Any - ) -> AsyncIterable["_models.DeploymentOperationsListResult"]: + self, scope: str, deployment_name: str, top: Optional[int] = None, **kwargs: Any + ) -> AsyncIterable["_models.DeploymentOperation"]: """Gets all deployments operations for a deployment. - :param scope: The resource scope. + :param scope: The resource scope. Required. :type scope: str - :param deployment_name: The name of the deployment. + :param deployment_name: The name of the deployment. Required. :type deployment_name: str :param top: The number of results to return. Default value is None. :type top: int :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either DeploymentOperationsListResult or the result of - cls(response) + :return: An iterator like instance of either DeploymentOperation or the result of cls(response) :rtype: - ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.resource.resources.v2020_10_01.models.DeploymentOperationsListResult] - :raises: ~azure.core.exceptions.HttpResponseError + ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.resource.resources.v2020_10_01.models.DeploymentOperation] + :raises ~azure.core.exceptions.HttpResponseError: """ - api_version = kwargs.pop('api_version', "2020-10-01") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2020-10-01")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[_models.DeploymentOperationsListResult] - cls = kwargs.pop('cls', None) # type: ClsType["_models.DeploymentOperationsListResult"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) + def prepare_request(next_link=None): if not next_link: - + request = build_deployment_operations_list_at_scope_request( scope=scope, deployment_name=deployment_name, - api_version=api_version, top=top, - template_url=self.list_at_scope.metadata['url'], + api_version=api_version, + template_url=self.list_at_scope.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore else: - - request = build_deployment_operations_list_at_scope_request( - scope=scope, - deployment_name=deployment_name, - template_url=next_link, - ) + # make call to next link with the client's api-version + _parsed_next_link = urlparse(next_link) + _next_request_params = case_insensitive_dict(parse_qs(_parsed_next_link.query)) + _next_request_params["api-version"] = self._config.api_version + request = HttpRequest("GET", urljoin(next_link, _parsed_next_link.path), params=_next_request_params) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore request.method = "GET" return request @@ -7363,10 +9676,8 @@ async def extract_data(pipeline_response): async def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) response = pipeline_response.http_response @@ -7376,116 +9687,121 @@ async def get_next(next_link=None): return pipeline_response + return AsyncItemPaged(get_next, extract_data) - return AsyncItemPaged( - get_next, extract_data - ) - list_at_scope.metadata = {'url': "/{scope}/providers/Microsoft.Resources/deployments/{deploymentName}/operations"} # type: ignore + list_at_scope.metadata = {"url": "/{scope}/providers/Microsoft.Resources/deployments/{deploymentName}/operations"} # type: ignore @distributed_trace_async async def get_at_tenant_scope( - self, - deployment_name: str, - operation_id: str, - **kwargs: Any - ) -> "_models.DeploymentOperation": + self, deployment_name: str, operation_id: str, **kwargs: Any + ) -> _models.DeploymentOperation: """Gets a deployments operation. - :param deployment_name: The name of the deployment. + :param deployment_name: The name of the deployment. Required. :type deployment_name: str - :param operation_id: The ID of the operation to get. + :param operation_id: The ID of the operation to get. Required. :type operation_id: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: DeploymentOperation, or the result of cls(response) + :return: DeploymentOperation or the result of cls(response) :rtype: ~azure.mgmt.resource.resources.v2020_10_01.models.DeploymentOperation - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.DeploymentOperation"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + 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', "2020-10-01") # type: str + api_version = kwargs.pop("api_version", _params.pop("api-version", "2020-10-01")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[_models.DeploymentOperation] - request = build_deployment_operations_get_at_tenant_scope_request( deployment_name=deployment_name, operation_id=operation_id, api_version=api_version, - template_url=self.get_at_tenant_scope.metadata['url'], + template_url=self.get_at_tenant_scope.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) - deserialized = self._deserialize('DeploymentOperation', pipeline_response) + deserialized = self._deserialize("DeploymentOperation", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - get_at_tenant_scope.metadata = {'url': "/providers/Microsoft.Resources/deployments/{deploymentName}/operations/{operationId}"} # type: ignore - + get_at_tenant_scope.metadata = {"url": "/providers/Microsoft.Resources/deployments/{deploymentName}/operations/{operationId}"} # type: ignore @distributed_trace def list_at_tenant_scope( - self, - deployment_name: str, - top: Optional[int] = None, - **kwargs: Any - ) -> AsyncIterable["_models.DeploymentOperationsListResult"]: + self, deployment_name: str, top: Optional[int] = None, **kwargs: Any + ) -> AsyncIterable["_models.DeploymentOperation"]: """Gets all deployments operations for a deployment. - :param deployment_name: The name of the deployment. + :param deployment_name: The name of the deployment. Required. :type deployment_name: str :param top: The number of results to return. Default value is None. :type top: int :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either DeploymentOperationsListResult or the result of - cls(response) + :return: An iterator like instance of either DeploymentOperation or the result of cls(response) :rtype: - ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.resource.resources.v2020_10_01.models.DeploymentOperationsListResult] - :raises: ~azure.core.exceptions.HttpResponseError + ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.resource.resources.v2020_10_01.models.DeploymentOperation] + :raises ~azure.core.exceptions.HttpResponseError: """ - api_version = kwargs.pop('api_version', "2020-10-01") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2020-10-01")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[_models.DeploymentOperationsListResult] - cls = kwargs.pop('cls', None) # type: ClsType["_models.DeploymentOperationsListResult"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) + def prepare_request(next_link=None): if not next_link: - + request = build_deployment_operations_list_at_tenant_scope_request( deployment_name=deployment_name, - api_version=api_version, top=top, - template_url=self.list_at_tenant_scope.metadata['url'], + api_version=api_version, + template_url=self.list_at_tenant_scope.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore else: - - request = build_deployment_operations_list_at_tenant_scope_request( - deployment_name=deployment_name, - template_url=next_link, - ) + # make call to next link with the client's api-version + _parsed_next_link = urlparse(next_link) + _next_request_params = case_insensitive_dict(parse_qs(_parsed_next_link.query)) + _next_request_params["api-version"] = self._config.api_version + request = HttpRequest("GET", urljoin(next_link, _parsed_next_link.path), params=_next_request_params) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore request.method = "GET" return request @@ -7499,10 +9815,8 @@ async def extract_data(pipeline_response): async def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) response = pipeline_response.http_response @@ -7512,125 +9826,127 @@ async def get_next(next_link=None): return pipeline_response + return AsyncItemPaged(get_next, extract_data) - return AsyncItemPaged( - get_next, extract_data - ) - list_at_tenant_scope.metadata = {'url': "/providers/Microsoft.Resources/deployments/{deploymentName}/operations"} # type: ignore + list_at_tenant_scope.metadata = {"url": "/providers/Microsoft.Resources/deployments/{deploymentName}/operations"} # type: ignore @distributed_trace_async async def get_at_management_group_scope( - self, - group_id: str, - deployment_name: str, - operation_id: str, - **kwargs: Any - ) -> "_models.DeploymentOperation": + self, group_id: str, deployment_name: str, operation_id: str, **kwargs: Any + ) -> _models.DeploymentOperation: """Gets a deployments operation. - :param group_id: The management group ID. + :param group_id: The management group ID. Required. :type group_id: str - :param deployment_name: The name of the deployment. + :param deployment_name: The name of the deployment. Required. :type deployment_name: str - :param operation_id: The ID of the operation to get. + :param operation_id: The ID of the operation to get. Required. :type operation_id: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: DeploymentOperation, or the result of cls(response) + :return: DeploymentOperation or the result of cls(response) :rtype: ~azure.mgmt.resource.resources.v2020_10_01.models.DeploymentOperation - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.DeploymentOperation"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + 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', "2020-10-01") # type: str + api_version = kwargs.pop("api_version", _params.pop("api-version", "2020-10-01")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[_models.DeploymentOperation] - request = build_deployment_operations_get_at_management_group_scope_request( group_id=group_id, deployment_name=deployment_name, operation_id=operation_id, api_version=api_version, - template_url=self.get_at_management_group_scope.metadata['url'], + template_url=self.get_at_management_group_scope.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) - deserialized = self._deserialize('DeploymentOperation', pipeline_response) + deserialized = self._deserialize("DeploymentOperation", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - get_at_management_group_scope.metadata = {'url': "/providers/Microsoft.Management/managementGroups/{groupId}/providers/Microsoft.Resources/deployments/{deploymentName}/operations/{operationId}"} # type: ignore - + get_at_management_group_scope.metadata = {"url": "/providers/Microsoft.Management/managementGroups/{groupId}/providers/Microsoft.Resources/deployments/{deploymentName}/operations/{operationId}"} # type: ignore @distributed_trace def list_at_management_group_scope( - self, - group_id: str, - deployment_name: str, - top: Optional[int] = None, - **kwargs: Any - ) -> AsyncIterable["_models.DeploymentOperationsListResult"]: + self, group_id: str, deployment_name: str, top: Optional[int] = None, **kwargs: Any + ) -> AsyncIterable["_models.DeploymentOperation"]: """Gets all deployments operations for a deployment. - :param group_id: The management group ID. + :param group_id: The management group ID. Required. :type group_id: str - :param deployment_name: The name of the deployment. + :param deployment_name: The name of the deployment. Required. :type deployment_name: str :param top: The number of results to return. Default value is None. :type top: int :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either DeploymentOperationsListResult or the result of - cls(response) + :return: An iterator like instance of either DeploymentOperation or the result of cls(response) :rtype: - ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.resource.resources.v2020_10_01.models.DeploymentOperationsListResult] - :raises: ~azure.core.exceptions.HttpResponseError + ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.resource.resources.v2020_10_01.models.DeploymentOperation] + :raises ~azure.core.exceptions.HttpResponseError: """ - api_version = kwargs.pop('api_version', "2020-10-01") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2020-10-01")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[_models.DeploymentOperationsListResult] - cls = kwargs.pop('cls', None) # type: ClsType["_models.DeploymentOperationsListResult"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) + def prepare_request(next_link=None): if not next_link: - + request = build_deployment_operations_list_at_management_group_scope_request( group_id=group_id, deployment_name=deployment_name, - api_version=api_version, top=top, - template_url=self.list_at_management_group_scope.metadata['url'], + api_version=api_version, + template_url=self.list_at_management_group_scope.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore else: - - request = build_deployment_operations_list_at_management_group_scope_request( - group_id=group_id, - deployment_name=deployment_name, - template_url=next_link, - ) + # make call to next link with the client's api-version + _parsed_next_link = urlparse(next_link) + _next_request_params = case_insensitive_dict(parse_qs(_parsed_next_link.query)) + _next_request_params["api-version"] = self._config.api_version + request = HttpRequest("GET", urljoin(next_link, _parsed_next_link.path), params=_next_request_params) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore request.method = "GET" return request @@ -7644,10 +9960,8 @@ async def extract_data(pipeline_response): async def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) response = pipeline_response.http_response @@ -7657,119 +9971,123 @@ async def get_next(next_link=None): return pipeline_response + return AsyncItemPaged(get_next, extract_data) - return AsyncItemPaged( - get_next, extract_data - ) - list_at_management_group_scope.metadata = {'url': "/providers/Microsoft.Management/managementGroups/{groupId}/providers/Microsoft.Resources/deployments/{deploymentName}/operations"} # type: ignore + list_at_management_group_scope.metadata = {"url": "/providers/Microsoft.Management/managementGroups/{groupId}/providers/Microsoft.Resources/deployments/{deploymentName}/operations"} # type: ignore @distributed_trace_async async def get_at_subscription_scope( - self, - deployment_name: str, - operation_id: str, - **kwargs: Any - ) -> "_models.DeploymentOperation": + self, deployment_name: str, operation_id: str, **kwargs: Any + ) -> _models.DeploymentOperation: """Gets a deployments operation. - :param deployment_name: The name of the deployment. + :param deployment_name: The name of the deployment. Required. :type deployment_name: str - :param operation_id: The ID of the operation to get. + :param operation_id: The ID of the operation to get. Required. :type operation_id: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: DeploymentOperation, or the result of cls(response) + :return: DeploymentOperation or the result of cls(response) :rtype: ~azure.mgmt.resource.resources.v2020_10_01.models.DeploymentOperation - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.DeploymentOperation"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) - api_version = kwargs.pop('api_version', "2020-10-01") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2020-10-01")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[_models.DeploymentOperation] - request = build_deployment_operations_get_at_subscription_scope_request( deployment_name=deployment_name, operation_id=operation_id, subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.get_at_subscription_scope.metadata['url'], + template_url=self.get_at_subscription_scope.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) - deserialized = self._deserialize('DeploymentOperation', pipeline_response) + deserialized = self._deserialize("DeploymentOperation", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - get_at_subscription_scope.metadata = {'url': "/subscriptions/{subscriptionId}/providers/Microsoft.Resources/deployments/{deploymentName}/operations/{operationId}"} # type: ignore - + get_at_subscription_scope.metadata = {"url": "/subscriptions/{subscriptionId}/providers/Microsoft.Resources/deployments/{deploymentName}/operations/{operationId}"} # type: ignore @distributed_trace def list_at_subscription_scope( - self, - deployment_name: str, - top: Optional[int] = None, - **kwargs: Any - ) -> AsyncIterable["_models.DeploymentOperationsListResult"]: + self, deployment_name: str, top: Optional[int] = None, **kwargs: Any + ) -> AsyncIterable["_models.DeploymentOperation"]: """Gets all deployments operations for a deployment. - :param deployment_name: The name of the deployment. + :param deployment_name: The name of the deployment. Required. :type deployment_name: str :param top: The number of results to return. Default value is None. :type top: int :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either DeploymentOperationsListResult or the result of - cls(response) + :return: An iterator like instance of either DeploymentOperation or the result of cls(response) :rtype: - ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.resource.resources.v2020_10_01.models.DeploymentOperationsListResult] - :raises: ~azure.core.exceptions.HttpResponseError + ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.resource.resources.v2020_10_01.models.DeploymentOperation] + :raises ~azure.core.exceptions.HttpResponseError: """ - api_version = kwargs.pop('api_version', "2020-10-01") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2020-10-01")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[_models.DeploymentOperationsListResult] - cls = kwargs.pop('cls', None) # type: ClsType["_models.DeploymentOperationsListResult"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) + def prepare_request(next_link=None): if not next_link: - + request = build_deployment_operations_list_at_subscription_scope_request( deployment_name=deployment_name, subscription_id=self._config.subscription_id, - api_version=api_version, top=top, - template_url=self.list_at_subscription_scope.metadata['url'], + api_version=api_version, + template_url=self.list_at_subscription_scope.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore else: - - request = build_deployment_operations_list_at_subscription_scope_request( - deployment_name=deployment_name, - subscription_id=self._config.subscription_id, - template_url=next_link, - ) + # make call to next link with the client's api-version + _parsed_next_link = urlparse(next_link) + _next_request_params = case_insensitive_dict(parse_qs(_parsed_next_link.query)) + _next_request_params["api-version"] = self._config.api_version + request = HttpRequest("GET", urljoin(next_link, _parsed_next_link.path), params=_next_request_params) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore request.method = "GET" return request @@ -7783,10 +10101,8 @@ async def extract_data(pipeline_response): async def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) response = pipeline_response.http_response @@ -7796,128 +10112,131 @@ async def get_next(next_link=None): return pipeline_response + return AsyncItemPaged(get_next, extract_data) - return AsyncItemPaged( - get_next, extract_data - ) - list_at_subscription_scope.metadata = {'url': "/subscriptions/{subscriptionId}/providers/Microsoft.Resources/deployments/{deploymentName}/operations"} # type: ignore + list_at_subscription_scope.metadata = {"url": "/subscriptions/{subscriptionId}/providers/Microsoft.Resources/deployments/{deploymentName}/operations"} # type: ignore @distributed_trace_async async def get( - self, - resource_group_name: str, - deployment_name: str, - operation_id: str, - **kwargs: Any - ) -> "_models.DeploymentOperation": + self, resource_group_name: str, deployment_name: str, operation_id: str, **kwargs: Any + ) -> _models.DeploymentOperation: """Gets a deployments operation. :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. :type resource_group_name: str - :param deployment_name: The name of the deployment. + :param deployment_name: The name of the deployment. Required. :type deployment_name: str - :param operation_id: The ID of the operation to get. + :param operation_id: The ID of the operation to get. Required. :type operation_id: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: DeploymentOperation, or the result of cls(response) + :return: DeploymentOperation or the result of cls(response) :rtype: ~azure.mgmt.resource.resources.v2020_10_01.models.DeploymentOperation - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.DeploymentOperation"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + 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', "2020-10-01") # type: str + api_version = kwargs.pop("api_version", _params.pop("api-version", "2020-10-01")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[_models.DeploymentOperation] - request = build_deployment_operations_get_request( resource_group_name=resource_group_name, deployment_name=deployment_name, operation_id=operation_id, subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.get.metadata['url'], + template_url=self.get.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) - deserialized = self._deserialize('DeploymentOperation', pipeline_response) + deserialized = self._deserialize("DeploymentOperation", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - get.metadata = {'url': "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/deployments/{deploymentName}/operations/{operationId}"} # type: ignore - + get.metadata = {"url": "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/deployments/{deploymentName}/operations/{operationId}"} # type: ignore @distributed_trace def list( - self, - resource_group_name: str, - deployment_name: str, - top: Optional[int] = None, - **kwargs: Any - ) -> AsyncIterable["_models.DeploymentOperationsListResult"]: + self, resource_group_name: str, deployment_name: str, top: Optional[int] = None, **kwargs: Any + ) -> AsyncIterable["_models.DeploymentOperation"]: """Gets all deployments operations for a deployment. :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. :type resource_group_name: str - :param deployment_name: The name of the deployment. + :param deployment_name: The name of the deployment. Required. :type deployment_name: str :param top: The number of results to return. Default value is None. :type top: int :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either DeploymentOperationsListResult or the result of - cls(response) + :return: An iterator like instance of either DeploymentOperation or the result of cls(response) :rtype: - ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.resource.resources.v2020_10_01.models.DeploymentOperationsListResult] - :raises: ~azure.core.exceptions.HttpResponseError + ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.resource.resources.v2020_10_01.models.DeploymentOperation] + :raises ~azure.core.exceptions.HttpResponseError: """ - api_version = kwargs.pop('api_version', "2020-10-01") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2020-10-01")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[_models.DeploymentOperationsListResult] - cls = kwargs.pop('cls', None) # type: ClsType["_models.DeploymentOperationsListResult"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) + def prepare_request(next_link=None): if not next_link: - + request = build_deployment_operations_list_request( resource_group_name=resource_group_name, deployment_name=deployment_name, subscription_id=self._config.subscription_id, - api_version=api_version, top=top, - template_url=self.list.metadata['url'], + 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.url = self._client.format_url(request.url) # type: ignore else: - - request = build_deployment_operations_list_request( - resource_group_name=resource_group_name, - deployment_name=deployment_name, - subscription_id=self._config.subscription_id, - template_url=next_link, - ) + # make call to next link with the client's api-version + _parsed_next_link = urlparse(next_link) + _next_request_params = case_insensitive_dict(parse_qs(_parsed_next_link.query)) + _next_request_params["api-version"] = self._config.api_version + request = HttpRequest("GET", urljoin(next_link, _parsed_next_link.path), params=_next_request_params) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore request.method = "GET" return request @@ -7931,10 +10250,8 @@ async def extract_data(pipeline_response): async def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) response = pipeline_response.http_response @@ -7944,8 +10261,6 @@ async def get_next(next_link=None): return pipeline_response + return AsyncItemPaged(get_next, extract_data) - return AsyncItemPaged( - get_next, extract_data - ) - list.metadata = {'url': "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/deployments/{deploymentName}/operations"} # type: ignore + list.metadata = {"url": "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/deployments/{deploymentName}/operations"} # type: ignore diff --git a/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/resources/v2020_10_01/aio/operations/_patch.py b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/resources/v2020_10_01/aio/operations/_patch.py new file mode 100644 index 0000000000000..f7dd32510333d --- /dev/null +++ b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/resources/v2020_10_01/aio/operations/_patch.py @@ -0,0 +1,20 @@ +# ------------------------------------ +# Copyright (c) Microsoft Corporation. +# Licensed under the MIT License. +# ------------------------------------ +"""Customize generated code here. + +Follow our quickstart for examples: https://aka.ms/azsdk/python/dpcodegen/python/customize +""" +from typing import List + +__all__: List[str] = [] # Add all objects you want publicly available to users at this package level + + +def patch_sdk(): + """Do not remove from this file. + + `patch_sdk` is a last resort escape hatch that allows you to do customizations + you can't accomplish using the techniques described in + https://aka.ms/azsdk/python/dpcodegen/python/customize + """ diff --git a/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/resources/v2020_10_01/models/__init__.py b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/resources/v2020_10_01/models/__init__.py index d4fdba0c5e879..b1c01c80ec30a 100644 --- a/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/resources/v2020_10_01/models/__init__.py +++ b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/resources/v2020_10_01/models/__init__.py @@ -81,111 +81,113 @@ from ._models_py3 import WhatIfPropertyChange from ._models_py3 import ZoneMapping - -from ._resource_management_client_enums import ( - AliasPathAttributes, - AliasPathTokenType, - AliasPatternType, - AliasType, - ChangeType, - DeploymentMode, - ExpressionEvaluationOptionsScopeType, - OnErrorDeploymentType, - PropertyChangeType, - ProvisioningOperation, - ProvisioningState, - ResourceIdentityType, - TagsPatchOperation, - WhatIfResultFormat, -) +from ._resource_management_client_enums import AliasPathAttributes +from ._resource_management_client_enums import AliasPathTokenType +from ._resource_management_client_enums import AliasPatternType +from ._resource_management_client_enums import AliasType +from ._resource_management_client_enums import ChangeType +from ._resource_management_client_enums import DeploymentMode +from ._resource_management_client_enums import ExpressionEvaluationOptionsScopeType +from ._resource_management_client_enums import OnErrorDeploymentType +from ._resource_management_client_enums import PropertyChangeType +from ._resource_management_client_enums import ProvisioningOperation +from ._resource_management_client_enums import ProvisioningState +from ._resource_management_client_enums import ResourceIdentityType +from ._resource_management_client_enums import TagsPatchOperation +from ._resource_management_client_enums import WhatIfResultFormat +from ._patch import __all__ as _patch_all +from ._patch import * # type: ignore # pylint: disable=unused-wildcard-import +from ._patch import patch_sdk as _patch_sdk __all__ = [ - 'Alias', - 'AliasPath', - 'AliasPathMetadata', - 'AliasPattern', - 'ApiProfile', - 'BasicDependency', - 'DebugSetting', - 'Dependency', - 'Deployment', - 'DeploymentExportResult', - 'DeploymentExtended', - 'DeploymentExtendedFilter', - 'DeploymentListResult', - 'DeploymentOperation', - 'DeploymentOperationProperties', - 'DeploymentOperationsListResult', - 'DeploymentProperties', - 'DeploymentPropertiesExtended', - 'DeploymentValidateResult', - 'DeploymentWhatIf', - 'DeploymentWhatIfProperties', - 'DeploymentWhatIfSettings', - 'ErrorAdditionalInfo', - 'ErrorResponse', - 'ExportTemplateRequest', - 'ExpressionEvaluationOptions', - 'GenericResource', - 'GenericResourceExpanded', - 'GenericResourceFilter', - 'HttpMessage', - 'Identity', - 'IdentityUserAssignedIdentitiesValue', - 'OnErrorDeployment', - 'OnErrorDeploymentExtended', - 'Operation', - 'OperationDisplay', - 'OperationListResult', - 'ParametersLink', - 'Plan', - 'Provider', - 'ProviderExtendedLocation', - 'ProviderListResult', - 'ProviderResourceType', - 'ProviderResourceTypeListResult', - 'Resource', - 'ResourceGroup', - 'ResourceGroupExportResult', - 'ResourceGroupFilter', - 'ResourceGroupListResult', - 'ResourceGroupPatchable', - 'ResourceGroupProperties', - 'ResourceListResult', - 'ResourceProviderOperationDisplayProperties', - 'ResourceReference', - 'ResourcesMoveInfo', - 'ScopedDeployment', - 'ScopedDeploymentWhatIf', - 'Sku', - 'StatusMessage', - 'SubResource', - 'TagCount', - 'TagDetails', - 'TagValue', - 'Tags', - 'TagsListResult', - 'TagsPatchResource', - 'TagsResource', - 'TargetResource', - 'TemplateHashResult', - 'TemplateLink', - 'WhatIfChange', - 'WhatIfOperationResult', - 'WhatIfPropertyChange', - 'ZoneMapping', - 'AliasPathAttributes', - 'AliasPathTokenType', - 'AliasPatternType', - 'AliasType', - 'ChangeType', - 'DeploymentMode', - 'ExpressionEvaluationOptionsScopeType', - 'OnErrorDeploymentType', - 'PropertyChangeType', - 'ProvisioningOperation', - 'ProvisioningState', - 'ResourceIdentityType', - 'TagsPatchOperation', - 'WhatIfResultFormat', + "Alias", + "AliasPath", + "AliasPathMetadata", + "AliasPattern", + "ApiProfile", + "BasicDependency", + "DebugSetting", + "Dependency", + "Deployment", + "DeploymentExportResult", + "DeploymentExtended", + "DeploymentExtendedFilter", + "DeploymentListResult", + "DeploymentOperation", + "DeploymentOperationProperties", + "DeploymentOperationsListResult", + "DeploymentProperties", + "DeploymentPropertiesExtended", + "DeploymentValidateResult", + "DeploymentWhatIf", + "DeploymentWhatIfProperties", + "DeploymentWhatIfSettings", + "ErrorAdditionalInfo", + "ErrorResponse", + "ExportTemplateRequest", + "ExpressionEvaluationOptions", + "GenericResource", + "GenericResourceExpanded", + "GenericResourceFilter", + "HttpMessage", + "Identity", + "IdentityUserAssignedIdentitiesValue", + "OnErrorDeployment", + "OnErrorDeploymentExtended", + "Operation", + "OperationDisplay", + "OperationListResult", + "ParametersLink", + "Plan", + "Provider", + "ProviderExtendedLocation", + "ProviderListResult", + "ProviderResourceType", + "ProviderResourceTypeListResult", + "Resource", + "ResourceGroup", + "ResourceGroupExportResult", + "ResourceGroupFilter", + "ResourceGroupListResult", + "ResourceGroupPatchable", + "ResourceGroupProperties", + "ResourceListResult", + "ResourceProviderOperationDisplayProperties", + "ResourceReference", + "ResourcesMoveInfo", + "ScopedDeployment", + "ScopedDeploymentWhatIf", + "Sku", + "StatusMessage", + "SubResource", + "TagCount", + "TagDetails", + "TagValue", + "Tags", + "TagsListResult", + "TagsPatchResource", + "TagsResource", + "TargetResource", + "TemplateHashResult", + "TemplateLink", + "WhatIfChange", + "WhatIfOperationResult", + "WhatIfPropertyChange", + "ZoneMapping", + "AliasPathAttributes", + "AliasPathTokenType", + "AliasPatternType", + "AliasType", + "ChangeType", + "DeploymentMode", + "ExpressionEvaluationOptionsScopeType", + "OnErrorDeploymentType", + "PropertyChangeType", + "ProvisioningOperation", + "ProvisioningState", + "ResourceIdentityType", + "TagsPatchOperation", + "WhatIfResultFormat", ] +__all__.extend([p for p in _patch_all if p not in __all__]) +_patch_sdk() diff --git a/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/resources/v2020_10_01/models/_models_py3.py b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/resources/v2020_10_01/models/_models_py3.py index d2607455f63da..6d2d420bfc0cc 100644 --- a/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/resources/v2020_10_01/models/_models_py3.py +++ b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/resources/v2020_10_01/models/_models_py3.py @@ -1,4 +1,5 @@ # coding=utf-8 +# pylint: disable=too-many-lines # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. # Licensed under the MIT License. See License.txt in the project root for license information. @@ -6,14 +7,22 @@ # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -from typing import Any, Dict, List, Optional, Union +import sys +from typing import Any, Dict, List, Optional, TYPE_CHECKING, Union -import msrest.serialization +from ... import _serialization -from ._resource_management_client_enums import * +if TYPE_CHECKING: + # pylint: disable=unused-import,ungrouped-imports + from .. import models as _models +if sys.version_info >= (3, 9): + from collections.abc import MutableMapping +else: + from typing import MutableMapping # type: ignore # pylint: disable=ungrouped-imports +JSON = MutableMapping[str, Any] # pylint: disable=unsubscriptable-object -class Alias(msrest.serialization.Model): +class Alias(_serialization.Model): """The alias type. Variables are only populated by the server, and will be ignored when sending a request. @@ -22,8 +31,7 @@ class Alias(msrest.serialization.Model): :vartype name: str :ivar paths: The paths for an alias. :vartype paths: list[~azure.mgmt.resource.resources.v2020_10_01.models.AliasPath] - :ivar type: The type of the alias. Possible values include: "NotSpecified", "PlainText", - "Mask". + :ivar type: The type of the alias. Known values are: "NotSpecified", "PlainText", and "Mask". :vartype type: str or ~azure.mgmt.resource.resources.v2020_10_01.models.AliasType :ivar default_path: The default path for an alias. :vartype default_path: str @@ -35,26 +43,26 @@ class Alias(msrest.serialization.Model): """ _validation = { - 'default_metadata': {'readonly': True}, + "default_metadata": {"readonly": True}, } _attribute_map = { - 'name': {'key': 'name', 'type': 'str'}, - 'paths': {'key': 'paths', 'type': '[AliasPath]'}, - 'type': {'key': 'type', 'type': 'str'}, - 'default_path': {'key': 'defaultPath', 'type': 'str'}, - 'default_pattern': {'key': 'defaultPattern', 'type': 'AliasPattern'}, - 'default_metadata': {'key': 'defaultMetadata', 'type': 'AliasPathMetadata'}, + "name": {"key": "name", "type": "str"}, + "paths": {"key": "paths", "type": "[AliasPath]"}, + "type": {"key": "type", "type": "str"}, + "default_path": {"key": "defaultPath", "type": "str"}, + "default_pattern": {"key": "defaultPattern", "type": "AliasPattern"}, + "default_metadata": {"key": "defaultMetadata", "type": "AliasPathMetadata"}, } def __init__( self, *, name: Optional[str] = None, - paths: Optional[List["AliasPath"]] = None, - type: Optional[Union[str, "AliasType"]] = None, + paths: Optional[List["_models.AliasPath"]] = None, + type: Optional[Union[str, "_models.AliasType"]] = None, default_path: Optional[str] = None, - default_pattern: Optional["AliasPattern"] = None, + default_pattern: Optional["_models.AliasPattern"] = None, **kwargs ): """ @@ -62,7 +70,7 @@ def __init__( :paramtype name: str :keyword paths: The paths for an alias. :paramtype paths: list[~azure.mgmt.resource.resources.v2020_10_01.models.AliasPath] - :keyword type: The type of the alias. Possible values include: "NotSpecified", "PlainText", + :keyword type: The type of the alias. Known values are: "NotSpecified", "PlainText", and "Mask". :paramtype type: str or ~azure.mgmt.resource.resources.v2020_10_01.models.AliasType :keyword default_path: The default path for an alias. @@ -70,7 +78,7 @@ def __init__( :keyword default_pattern: The default pattern for an alias. :paramtype default_pattern: ~azure.mgmt.resource.resources.v2020_10_01.models.AliasPattern """ - super(Alias, self).__init__(**kwargs) + super().__init__(**kwargs) self.name = name self.paths = paths self.type = type @@ -79,7 +87,7 @@ def __init__( self.default_metadata = None -class AliasPath(msrest.serialization.Model): +class AliasPath(_serialization.Model): """The type of the paths for alias. Variables are only populated by the server, and will be ignored when sending a request. @@ -96,14 +104,14 @@ class AliasPath(msrest.serialization.Model): """ _validation = { - 'metadata': {'readonly': True}, + "metadata": {"readonly": True}, } _attribute_map = { - 'path': {'key': 'path', 'type': 'str'}, - 'api_versions': {'key': 'apiVersions', 'type': '[str]'}, - 'pattern': {'key': 'pattern', 'type': 'AliasPattern'}, - 'metadata': {'key': 'metadata', 'type': 'AliasPathMetadata'}, + "path": {"key": "path", "type": "str"}, + "api_versions": {"key": "apiVersions", "type": "[str]"}, + "pattern": {"key": "pattern", "type": "AliasPattern"}, + "metadata": {"key": "metadata", "type": "AliasPathMetadata"}, } def __init__( @@ -111,7 +119,7 @@ def __init__( *, path: Optional[str] = None, api_versions: Optional[List[str]] = None, - pattern: Optional["AliasPattern"] = None, + pattern: Optional["_models.AliasPattern"] = None, **kwargs ): """ @@ -122,63 +130,59 @@ def __init__( :keyword pattern: The pattern for an alias path. :paramtype pattern: ~azure.mgmt.resource.resources.v2020_10_01.models.AliasPattern """ - super(AliasPath, self).__init__(**kwargs) + super().__init__(**kwargs) self.path = path self.api_versions = api_versions self.pattern = pattern self.metadata = None -class AliasPathMetadata(msrest.serialization.Model): +class AliasPathMetadata(_serialization.Model): """AliasPathMetadata. Variables are only populated by the server, and will be ignored when sending a request. - :ivar type: The type of the token that the alias path is referring to. Possible values include: - "NotSpecified", "Any", "String", "Object", "Array", "Integer", "Number", "Boolean". + :ivar type: The type of the token that the alias path is referring to. Known values are: + "NotSpecified", "Any", "String", "Object", "Array", "Integer", "Number", and "Boolean". :vartype type: str or ~azure.mgmt.resource.resources.v2020_10_01.models.AliasPathTokenType - :ivar attributes: The attributes of the token that the alias path is referring to. Possible - values include: "None", "Modifiable". + :ivar attributes: The attributes of the token that the alias path is referring to. Known values + are: "None" and "Modifiable". :vartype attributes: str or ~azure.mgmt.resource.resources.v2020_10_01.models.AliasPathAttributes """ _validation = { - 'type': {'readonly': True}, - 'attributes': {'readonly': True}, + "type": {"readonly": True}, + "attributes": {"readonly": True}, } _attribute_map = { - 'type': {'key': 'type', 'type': 'str'}, - 'attributes': {'key': 'attributes', 'type': 'str'}, + "type": {"key": "type", "type": "str"}, + "attributes": {"key": "attributes", "type": "str"}, } - def __init__( - self, - **kwargs - ): - """ - """ - super(AliasPathMetadata, self).__init__(**kwargs) + def __init__(self, **kwargs): + """ """ + super().__init__(**kwargs) self.type = None self.attributes = None -class AliasPattern(msrest.serialization.Model): +class AliasPattern(_serialization.Model): """The type of the pattern for an alias path. :ivar phrase: The alias pattern phrase. :vartype phrase: str :ivar variable: The alias pattern variable. :vartype variable: str - :ivar type: The type of alias pattern. Possible values include: "NotSpecified", "Extract". + :ivar type: The type of alias pattern. Known values are: "NotSpecified" and "Extract". :vartype type: str or ~azure.mgmt.resource.resources.v2020_10_01.models.AliasPatternType """ _attribute_map = { - 'phrase': {'key': 'phrase', 'type': 'str'}, - 'variable': {'key': 'variable', 'type': 'str'}, - 'type': {'key': 'type', 'type': 'str'}, + "phrase": {"key": "phrase", "type": "str"}, + "variable": {"key": "variable", "type": "str"}, + "type": {"key": "type", "type": "str"}, } def __init__( @@ -186,7 +190,7 @@ def __init__( *, phrase: Optional[str] = None, variable: Optional[str] = None, - type: Optional[Union[str, "AliasPatternType"]] = None, + type: Optional[Union[str, "_models.AliasPatternType"]] = None, **kwargs ): """ @@ -194,16 +198,16 @@ def __init__( :paramtype phrase: str :keyword variable: The alias pattern variable. :paramtype variable: str - :keyword type: The type of alias pattern. Possible values include: "NotSpecified", "Extract". + :keyword type: The type of alias pattern. Known values are: "NotSpecified" and "Extract". :paramtype type: str or ~azure.mgmt.resource.resources.v2020_10_01.models.AliasPatternType """ - super(AliasPattern, self).__init__(**kwargs) + super().__init__(**kwargs) self.phrase = phrase self.variable = variable self.type = type -class ApiProfile(msrest.serialization.Model): +class ApiProfile(_serialization.Model): """ApiProfile. Variables are only populated by the server, and will be ignored when sending a request. @@ -215,27 +219,23 @@ class ApiProfile(msrest.serialization.Model): """ _validation = { - 'profile_version': {'readonly': True}, - 'api_version': {'readonly': True}, + "profile_version": {"readonly": True}, + "api_version": {"readonly": True}, } _attribute_map = { - 'profile_version': {'key': 'profileVersion', 'type': 'str'}, - 'api_version': {'key': 'apiVersion', 'type': 'str'}, + "profile_version": {"key": "profileVersion", "type": "str"}, + "api_version": {"key": "apiVersion", "type": "str"}, } - def __init__( - self, - **kwargs - ): - """ - """ - super(ApiProfile, self).__init__(**kwargs) + def __init__(self, **kwargs): + """ """ + super().__init__(**kwargs) self.profile_version = None self.api_version = None -class BasicDependency(msrest.serialization.Model): +class BasicDependency(_serialization.Model): """Deployment dependency information. :ivar id: The ID of the dependency. @@ -247,15 +247,15 @@ class BasicDependency(msrest.serialization.Model): """ _attribute_map = { - 'id': {'key': 'id', 'type': 'str'}, - 'resource_type': {'key': 'resourceType', 'type': 'str'}, - 'resource_name': {'key': 'resourceName', 'type': 'str'}, + "id": {"key": "id", "type": "str"}, + "resource_type": {"key": "resourceType", "type": "str"}, + "resource_name": {"key": "resourceName", "type": "str"}, } def __init__( self, *, - id: Optional[str] = None, + id: Optional[str] = None, # pylint: disable=redefined-builtin resource_type: Optional[str] = None, resource_name: Optional[str] = None, **kwargs @@ -268,13 +268,13 @@ def __init__( :keyword resource_name: The dependency resource name. :paramtype resource_name: str """ - super(BasicDependency, self).__init__(**kwargs) + super().__init__(**kwargs) self.id = id self.resource_type = resource_type self.resource_name = resource_name -class DebugSetting(msrest.serialization.Model): +class DebugSetting(_serialization.Model): """The debug setting. :ivar detail_level: Specifies the type of information to log for debugging. The permitted @@ -287,15 +287,10 @@ class DebugSetting(msrest.serialization.Model): """ _attribute_map = { - 'detail_level': {'key': 'detailLevel', 'type': 'str'}, + "detail_level": {"key": "detailLevel", "type": "str"}, } - def __init__( - self, - *, - detail_level: Optional[str] = None, - **kwargs - ): + def __init__(self, *, detail_level: Optional[str] = None, **kwargs): """ :keyword detail_level: Specifies the type of information to log for debugging. The permitted values are none, requestContent, responseContent, or both requestContent and responseContent @@ -305,11 +300,11 @@ def __init__( deployment operations. :paramtype detail_level: str """ - super(DebugSetting, self).__init__(**kwargs) + super().__init__(**kwargs) self.detail_level = detail_level -class Dependency(msrest.serialization.Model): +class Dependency(_serialization.Model): """Deployment dependency information. :ivar depends_on: The list of dependencies. @@ -323,17 +318,17 @@ class Dependency(msrest.serialization.Model): """ _attribute_map = { - 'depends_on': {'key': 'dependsOn', 'type': '[BasicDependency]'}, - 'id': {'key': 'id', 'type': 'str'}, - 'resource_type': {'key': 'resourceType', 'type': 'str'}, - 'resource_name': {'key': 'resourceName', 'type': 'str'}, + "depends_on": {"key": "dependsOn", "type": "[BasicDependency]"}, + "id": {"key": "id", "type": "str"}, + "resource_type": {"key": "resourceType", "type": "str"}, + "resource_name": {"key": "resourceName", "type": "str"}, } def __init__( self, *, - depends_on: Optional[List["BasicDependency"]] = None, - id: Optional[str] = None, + depends_on: Optional[List["_models.BasicDependency"]] = None, + id: Optional[str] = None, # pylint: disable=redefined-builtin resource_type: Optional[str] = None, resource_name: Optional[str] = None, **kwargs @@ -348,40 +343,40 @@ def __init__( :keyword resource_name: The dependency resource name. :paramtype resource_name: str """ - super(Dependency, self).__init__(**kwargs) + super().__init__(**kwargs) self.depends_on = depends_on self.id = id self.resource_type = resource_type self.resource_name = resource_name -class Deployment(msrest.serialization.Model): +class Deployment(_serialization.Model): """Deployment operation parameters. All required parameters must be populated in order to send to Azure. :ivar location: The location to store the deployment data. :vartype location: str - :ivar properties: Required. The deployment properties. + :ivar properties: The deployment properties. Required. :vartype properties: ~azure.mgmt.resource.resources.v2020_10_01.models.DeploymentProperties - :ivar tags: A set of tags. Deployment tags. + :ivar tags: Deployment tags. :vartype tags: dict[str, str] """ _validation = { - 'properties': {'required': True}, + "properties": {"required": True}, } _attribute_map = { - 'location': {'key': 'location', 'type': 'str'}, - 'properties': {'key': 'properties', 'type': 'DeploymentProperties'}, - 'tags': {'key': 'tags', 'type': '{str}'}, + "location": {"key": "location", "type": "str"}, + "properties": {"key": "properties", "type": "DeploymentProperties"}, + "tags": {"key": "tags", "type": "{str}"}, } def __init__( self, *, - properties: "DeploymentProperties", + properties: "_models.DeploymentProperties", location: Optional[str] = None, tags: Optional[Dict[str, str]] = None, **kwargs @@ -389,43 +384,38 @@ def __init__( """ :keyword location: The location to store the deployment data. :paramtype location: str - :keyword properties: Required. The deployment properties. + :keyword properties: The deployment properties. Required. :paramtype properties: ~azure.mgmt.resource.resources.v2020_10_01.models.DeploymentProperties - :keyword tags: A set of tags. Deployment tags. + :keyword tags: Deployment tags. :paramtype tags: dict[str, str] """ - super(Deployment, self).__init__(**kwargs) + super().__init__(**kwargs) self.location = location self.properties = properties self.tags = tags -class DeploymentExportResult(msrest.serialization.Model): +class DeploymentExportResult(_serialization.Model): """The deployment export result. :ivar template: The template content. - :vartype template: any + :vartype template: JSON """ _attribute_map = { - 'template': {'key': 'template', 'type': 'object'}, + "template": {"key": "template", "type": "object"}, } - def __init__( - self, - *, - template: Optional[Any] = None, - **kwargs - ): + def __init__(self, *, template: Optional[JSON] = None, **kwargs): """ :keyword template: The template content. - :paramtype template: any + :paramtype template: JSON """ - super(DeploymentExportResult, self).__init__(**kwargs) + super().__init__(**kwargs) self.template = template -class DeploymentExtended(msrest.serialization.Model): +class DeploymentExtended(_serialization.Model): """Deployment information. Variables are only populated by the server, and will be ignored when sending a request. @@ -441,30 +431,30 @@ class DeploymentExtended(msrest.serialization.Model): :ivar properties: Deployment properties. :vartype properties: ~azure.mgmt.resource.resources.v2020_10_01.models.DeploymentPropertiesExtended - :ivar tags: A set of tags. Deployment tags. + :ivar tags: Deployment tags. :vartype tags: dict[str, str] """ _validation = { - 'id': {'readonly': True}, - 'name': {'readonly': True}, - 'type': {'readonly': True}, + "id": {"readonly": True}, + "name": {"readonly": True}, + "type": {"readonly": True}, } _attribute_map = { - 'id': {'key': 'id', 'type': 'str'}, - 'name': {'key': 'name', 'type': 'str'}, - 'type': {'key': 'type', 'type': 'str'}, - 'location': {'key': 'location', 'type': 'str'}, - 'properties': {'key': 'properties', 'type': 'DeploymentPropertiesExtended'}, - 'tags': {'key': 'tags', 'type': '{str}'}, + "id": {"key": "id", "type": "str"}, + "name": {"key": "name", "type": "str"}, + "type": {"key": "type", "type": "str"}, + "location": {"key": "location", "type": "str"}, + "properties": {"key": "properties", "type": "DeploymentPropertiesExtended"}, + "tags": {"key": "tags", "type": "{str}"}, } def __init__( self, *, location: Optional[str] = None, - properties: Optional["DeploymentPropertiesExtended"] = None, + properties: Optional["_models.DeploymentPropertiesExtended"] = None, tags: Optional[Dict[str, str]] = None, **kwargs ): @@ -474,10 +464,10 @@ def __init__( :keyword properties: Deployment properties. :paramtype properties: ~azure.mgmt.resource.resources.v2020_10_01.models.DeploymentPropertiesExtended - :keyword tags: A set of tags. Deployment tags. + :keyword tags: Deployment tags. :paramtype tags: dict[str, str] """ - super(DeploymentExtended, self).__init__(**kwargs) + super().__init__(**kwargs) self.id = None self.name = None self.type = None @@ -486,7 +476,7 @@ def __init__( self.tags = tags -class DeploymentExtendedFilter(msrest.serialization.Model): +class DeploymentExtendedFilter(_serialization.Model): """Deployment filter. :ivar provisioning_state: The provisioning state. @@ -494,24 +484,19 @@ class DeploymentExtendedFilter(msrest.serialization.Model): """ _attribute_map = { - 'provisioning_state': {'key': 'provisioningState', 'type': 'str'}, + "provisioning_state": {"key": "provisioningState", "type": "str"}, } - def __init__( - self, - *, - provisioning_state: Optional[str] = None, - **kwargs - ): + def __init__(self, *, provisioning_state: Optional[str] = None, **kwargs): """ :keyword provisioning_state: The provisioning state. :paramtype provisioning_state: str """ - super(DeploymentExtendedFilter, self).__init__(**kwargs) + super().__init__(**kwargs) self.provisioning_state = provisioning_state -class DeploymentListResult(msrest.serialization.Model): +class DeploymentListResult(_serialization.Model): """List of deployments. Variables are only populated by the server, and will be ignored when sending a request. @@ -523,30 +508,25 @@ class DeploymentListResult(msrest.serialization.Model): """ _validation = { - 'next_link': {'readonly': True}, + "next_link": {"readonly": True}, } _attribute_map = { - 'value': {'key': 'value', 'type': '[DeploymentExtended]'}, - 'next_link': {'key': 'nextLink', 'type': 'str'}, + "value": {"key": "value", "type": "[DeploymentExtended]"}, + "next_link": {"key": "nextLink", "type": "str"}, } - def __init__( - self, - *, - value: Optional[List["DeploymentExtended"]] = None, - **kwargs - ): + def __init__(self, *, value: Optional[List["_models.DeploymentExtended"]] = None, **kwargs): """ :keyword value: An array of deployments. :paramtype value: list[~azure.mgmt.resource.resources.v2020_10_01.models.DeploymentExtended] """ - super(DeploymentListResult, self).__init__(**kwargs) + super().__init__(**kwargs) self.value = value self.next_link = None -class DeploymentOperation(msrest.serialization.Model): +class DeploymentOperation(_serialization.Model): """Deployment operation information. Variables are only populated by the server, and will be ignored when sending a request. @@ -561,41 +541,36 @@ class DeploymentOperation(msrest.serialization.Model): """ _validation = { - 'id': {'readonly': True}, - 'operation_id': {'readonly': True}, + "id": {"readonly": True}, + "operation_id": {"readonly": True}, } _attribute_map = { - 'id': {'key': 'id', 'type': 'str'}, - 'operation_id': {'key': 'operationId', 'type': 'str'}, - 'properties': {'key': 'properties', 'type': 'DeploymentOperationProperties'}, + "id": {"key": "id", "type": "str"}, + "operation_id": {"key": "operationId", "type": "str"}, + "properties": {"key": "properties", "type": "DeploymentOperationProperties"}, } - def __init__( - self, - *, - properties: Optional["DeploymentOperationProperties"] = None, - **kwargs - ): + def __init__(self, *, properties: Optional["_models.DeploymentOperationProperties"] = None, **kwargs): """ :keyword properties: Deployment properties. :paramtype properties: ~azure.mgmt.resource.resources.v2020_10_01.models.DeploymentOperationProperties """ - super(DeploymentOperation, self).__init__(**kwargs) + super().__init__(**kwargs) self.id = None self.operation_id = None self.properties = properties -class DeploymentOperationProperties(msrest.serialization.Model): +class DeploymentOperationProperties(_serialization.Model): """Deployment operation properties. Variables are only populated by the server, and will be ignored when sending a request. - :ivar provisioning_operation: The name of the current provisioning operation. Possible values - include: "NotSpecified", "Create", "Delete", "Waiting", "AzureAsyncOperationWaiting", - "ResourceCacheWaiting", "Action", "Read", "EvaluateDeploymentOutput", "DeploymentCleanup". + :ivar provisioning_operation: The name of the current provisioning operation. Known values are: + "NotSpecified", "Create", "Delete", "Waiting", "AzureAsyncOperationWaiting", + "ResourceCacheWaiting", "Action", "Read", "EvaluateDeploymentOutput", and "DeploymentCleanup". :vartype provisioning_operation: str or ~azure.mgmt.resource.resources.v2020_10_01.models.ProvisioningOperation :ivar provisioning_state: The state of the provisioning. @@ -621,38 +596,34 @@ class DeploymentOperationProperties(msrest.serialization.Model): """ _validation = { - 'provisioning_operation': {'readonly': True}, - 'provisioning_state': {'readonly': True}, - 'timestamp': {'readonly': True}, - 'duration': {'readonly': True}, - 'service_request_id': {'readonly': True}, - 'status_code': {'readonly': True}, - 'status_message': {'readonly': True}, - 'target_resource': {'readonly': True}, - 'request': {'readonly': True}, - 'response': {'readonly': True}, - } - - _attribute_map = { - 'provisioning_operation': {'key': 'provisioningOperation', 'type': 'str'}, - 'provisioning_state': {'key': 'provisioningState', 'type': 'str'}, - 'timestamp': {'key': 'timestamp', 'type': 'iso-8601'}, - 'duration': {'key': 'duration', 'type': 'str'}, - 'service_request_id': {'key': 'serviceRequestId', 'type': 'str'}, - 'status_code': {'key': 'statusCode', 'type': 'str'}, - 'status_message': {'key': 'statusMessage', 'type': 'StatusMessage'}, - 'target_resource': {'key': 'targetResource', 'type': 'TargetResource'}, - 'request': {'key': 'request', 'type': 'HttpMessage'}, - 'response': {'key': 'response', 'type': 'HttpMessage'}, - } - - def __init__( - self, - **kwargs - ): - """ - """ - super(DeploymentOperationProperties, self).__init__(**kwargs) + "provisioning_operation": {"readonly": True}, + "provisioning_state": {"readonly": True}, + "timestamp": {"readonly": True}, + "duration": {"readonly": True}, + "service_request_id": {"readonly": True}, + "status_code": {"readonly": True}, + "status_message": {"readonly": True}, + "target_resource": {"readonly": True}, + "request": {"readonly": True}, + "response": {"readonly": True}, + } + + _attribute_map = { + "provisioning_operation": {"key": "provisioningOperation", "type": "str"}, + "provisioning_state": {"key": "provisioningState", "type": "str"}, + "timestamp": {"key": "timestamp", "type": "iso-8601"}, + "duration": {"key": "duration", "type": "str"}, + "service_request_id": {"key": "serviceRequestId", "type": "str"}, + "status_code": {"key": "statusCode", "type": "str"}, + "status_message": {"key": "statusMessage", "type": "StatusMessage"}, + "target_resource": {"key": "targetResource", "type": "TargetResource"}, + "request": {"key": "request", "type": "HttpMessage"}, + "response": {"key": "response", "type": "HttpMessage"}, + } + + def __init__(self, **kwargs): + """ """ + super().__init__(**kwargs) self.provisioning_operation = None self.provisioning_state = None self.timestamp = None @@ -665,7 +636,7 @@ def __init__( self.response = None -class DeploymentOperationsListResult(msrest.serialization.Model): +class DeploymentOperationsListResult(_serialization.Model): """List of deployment operations. Variables are only populated by the server, and will be ignored when sending a request. @@ -677,30 +648,25 @@ class DeploymentOperationsListResult(msrest.serialization.Model): """ _validation = { - 'next_link': {'readonly': True}, + "next_link": {"readonly": True}, } _attribute_map = { - 'value': {'key': 'value', 'type': '[DeploymentOperation]'}, - 'next_link': {'key': 'nextLink', 'type': 'str'}, + "value": {"key": "value", "type": "[DeploymentOperation]"}, + "next_link": {"key": "nextLink", "type": "str"}, } - def __init__( - self, - *, - value: Optional[List["DeploymentOperation"]] = None, - **kwargs - ): + def __init__(self, *, value: Optional[List["_models.DeploymentOperation"]] = None, **kwargs): """ :keyword value: An array of deployment operations. :paramtype value: list[~azure.mgmt.resource.resources.v2020_10_01.models.DeploymentOperation] """ - super(DeploymentOperationsListResult, self).__init__(**kwargs) + super().__init__(**kwargs) self.value = value self.next_link = None -class DeploymentProperties(msrest.serialization.Model): +class DeploymentProperties(_serialization.Model): """Deployment properties. All required parameters must be populated in order to send to Azure. @@ -709,7 +675,7 @@ class DeploymentProperties(msrest.serialization.Model): syntax directly in the request rather than link to an existing template. It can be a JObject or well-formed JSON string. Use either the templateLink property or the template property, but not both. - :vartype template: any + :vartype template: JSON :ivar template_link: The URI of the template. Use either the templateLink property or the template property, but not both. :vartype template_link: ~azure.mgmt.resource.resources.v2020_10_01.models.TemplateLink @@ -717,17 +683,17 @@ class DeploymentProperties(msrest.serialization.Model): You use this element when you want to provide the parameter values directly in the request rather than link to an existing parameter file. Use either the parametersLink property or the parameters property, but not both. It can be a JObject or a well formed JSON string. - :vartype parameters: any + :vartype parameters: JSON :ivar parameters_link: The URI of parameters file. You use this element to link to an existing parameters file. Use either the parametersLink property or the parameters property, but not both. :vartype parameters_link: ~azure.mgmt.resource.resources.v2020_10_01.models.ParametersLink - :ivar mode: Required. The mode that is used to deploy resources. This value can be either - Incremental or Complete. In Incremental mode, resources are deployed without deleting existing - resources that are not included in the template. In Complete mode, resources are deployed and - existing resources in the resource group that are not included in the template are deleted. Be - careful when using Complete mode as you may unintentionally delete resources. Possible values - include: "Incremental", "Complete". + :ivar mode: The mode that is used to deploy resources. This value can be either Incremental or + Complete. In Incremental mode, resources are deployed without deleting existing resources that + are not included in the template. In Complete mode, resources are deployed and existing + resources in the resource group that are not included in the template are deleted. Be careful + when using Complete mode as you may unintentionally delete resources. Required. Known values + are: "Incremental" and "Complete". :vartype mode: str or ~azure.mgmt.resource.resources.v2020_10_01.models.DeploymentMode :ivar debug_setting: The debug setting of the deployment. :vartype debug_setting: ~azure.mgmt.resource.resources.v2020_10_01.models.DebugSetting @@ -742,31 +708,31 @@ class DeploymentProperties(msrest.serialization.Model): """ _validation = { - 'mode': {'required': True}, + "mode": {"required": True}, } _attribute_map = { - 'template': {'key': 'template', 'type': 'object'}, - 'template_link': {'key': 'templateLink', 'type': 'TemplateLink'}, - 'parameters': {'key': 'parameters', 'type': 'object'}, - 'parameters_link': {'key': 'parametersLink', 'type': 'ParametersLink'}, - 'mode': {'key': 'mode', 'type': 'str'}, - 'debug_setting': {'key': 'debugSetting', 'type': 'DebugSetting'}, - 'on_error_deployment': {'key': 'onErrorDeployment', 'type': 'OnErrorDeployment'}, - 'expression_evaluation_options': {'key': 'expressionEvaluationOptions', 'type': 'ExpressionEvaluationOptions'}, + "template": {"key": "template", "type": "object"}, + "template_link": {"key": "templateLink", "type": "TemplateLink"}, + "parameters": {"key": "parameters", "type": "object"}, + "parameters_link": {"key": "parametersLink", "type": "ParametersLink"}, + "mode": {"key": "mode", "type": "str"}, + "debug_setting": {"key": "debugSetting", "type": "DebugSetting"}, + "on_error_deployment": {"key": "onErrorDeployment", "type": "OnErrorDeployment"}, + "expression_evaluation_options": {"key": "expressionEvaluationOptions", "type": "ExpressionEvaluationOptions"}, } def __init__( self, *, - mode: Union[str, "DeploymentMode"], - template: Optional[Any] = None, - template_link: Optional["TemplateLink"] = None, - parameters: Optional[Any] = None, - parameters_link: Optional["ParametersLink"] = None, - debug_setting: Optional["DebugSetting"] = None, - on_error_deployment: Optional["OnErrorDeployment"] = None, - expression_evaluation_options: Optional["ExpressionEvaluationOptions"] = None, + mode: Union[str, "_models.DeploymentMode"], + template: Optional[JSON] = None, + template_link: Optional["_models.TemplateLink"] = None, + parameters: Optional[JSON] = None, + parameters_link: Optional["_models.ParametersLink"] = None, + debug_setting: Optional["_models.DebugSetting"] = None, + on_error_deployment: Optional["_models.OnErrorDeployment"] = None, + expression_evaluation_options: Optional["_models.ExpressionEvaluationOptions"] = None, **kwargs ): """ @@ -774,7 +740,7 @@ def __init__( template syntax directly in the request rather than link to an existing template. It can be a JObject or well-formed JSON string. Use either the templateLink property or the template property, but not both. - :paramtype template: any + :paramtype template: JSON :keyword template_link: The URI of the template. Use either the templateLink property or the template property, but not both. :paramtype template_link: ~azure.mgmt.resource.resources.v2020_10_01.models.TemplateLink @@ -782,17 +748,17 @@ def __init__( template. You use this element when you want to provide the parameter values directly in the request rather than link to an existing parameter file. Use either the parametersLink property or the parameters property, but not both. It can be a JObject or a well formed JSON string. - :paramtype parameters: any + :paramtype parameters: JSON :keyword parameters_link: The URI of parameters file. You use this element to link to an existing parameters file. Use either the parametersLink property or the parameters property, but not both. :paramtype parameters_link: ~azure.mgmt.resource.resources.v2020_10_01.models.ParametersLink - :keyword mode: Required. The mode that is used to deploy resources. This value can be either - Incremental or Complete. In Incremental mode, resources are deployed without deleting existing - resources that are not included in the template. In Complete mode, resources are deployed and - existing resources in the resource group that are not included in the template are deleted. Be - careful when using Complete mode as you may unintentionally delete resources. Possible values - include: "Incremental", "Complete". + :keyword mode: The mode that is used to deploy resources. This value can be either Incremental + or Complete. In Incremental mode, resources are deployed without deleting existing resources + that are not included in the template. In Complete mode, resources are deployed and existing + resources in the resource group that are not included in the template are deleted. Be careful + when using Complete mode as you may unintentionally delete resources. Required. Known values + are: "Incremental" and "Complete". :paramtype mode: str or ~azure.mgmt.resource.resources.v2020_10_01.models.DeploymentMode :keyword debug_setting: The debug setting of the deployment. :paramtype debug_setting: ~azure.mgmt.resource.resources.v2020_10_01.models.DebugSetting @@ -805,7 +771,7 @@ def __init__( :paramtype expression_evaluation_options: ~azure.mgmt.resource.resources.v2020_10_01.models.ExpressionEvaluationOptions """ - super(DeploymentProperties, self).__init__(**kwargs) + super().__init__(**kwargs) self.template = template self.template_link = template_link self.parameters = parameters @@ -816,14 +782,14 @@ def __init__( self.expression_evaluation_options = expression_evaluation_options -class DeploymentPropertiesExtended(msrest.serialization.Model): +class DeploymentPropertiesExtended(_serialization.Model): # pylint: disable=too-many-instance-attributes """Deployment properties with additional details. Variables are only populated by the server, and will be ignored when sending a request. - :ivar provisioning_state: Denotes the state of provisioning. Possible values include: - "NotSpecified", "Accepted", "Running", "Ready", "Creating", "Created", "Deleting", "Deleted", - "Canceled", "Failed", "Succeeded", "Updating". + :ivar provisioning_state: Denotes the state of provisioning. Known values are: "NotSpecified", + "Accepted", "Running", "Ready", "Creating", "Created", "Deleting", "Deleted", "Canceled", + "Failed", "Succeeded", and "Updating". :vartype provisioning_state: str or ~azure.mgmt.resource.resources.v2020_10_01.models.ProvisioningState :ivar correlation_id: The correlation ID of the deployment. @@ -833,7 +799,7 @@ class DeploymentPropertiesExtended(msrest.serialization.Model): :ivar duration: The duration of the template deployment. :vartype duration: str :ivar outputs: Key/value pairs that represent deployment output. - :vartype outputs: any + :vartype outputs: JSON :ivar providers: The list of resource providers needed for the deployment. :vartype providers: list[~azure.mgmt.resource.resources.v2020_10_01.models.Provider] :ivar dependencies: The list of deployment dependencies. @@ -841,11 +807,11 @@ class DeploymentPropertiesExtended(msrest.serialization.Model): :ivar template_link: The URI referencing the template. :vartype template_link: ~azure.mgmt.resource.resources.v2020_10_01.models.TemplateLink :ivar parameters: Deployment parameters. - :vartype parameters: any + :vartype parameters: JSON :ivar parameters_link: The URI referencing the parameters. :vartype parameters_link: ~azure.mgmt.resource.resources.v2020_10_01.models.ParametersLink - :ivar mode: The deployment mode. Possible values are Incremental and Complete. Possible values - include: "Incremental", "Complete". + :ivar mode: The deployment mode. Possible values are Incremental and Complete. Known values + are: "Incremental" and "Complete". :vartype mode: str or ~azure.mgmt.resource.resources.v2020_10_01.models.DeploymentMode :ivar debug_setting: The debug setting of the deployment. :vartype debug_setting: ~azure.mgmt.resource.resources.v2020_10_01.models.DebugSetting @@ -865,52 +831,48 @@ class DeploymentPropertiesExtended(msrest.serialization.Model): """ _validation = { - 'provisioning_state': {'readonly': True}, - 'correlation_id': {'readonly': True}, - 'timestamp': {'readonly': True}, - 'duration': {'readonly': True}, - 'outputs': {'readonly': True}, - 'providers': {'readonly': True}, - 'dependencies': {'readonly': True}, - 'template_link': {'readonly': True}, - 'parameters': {'readonly': True}, - 'parameters_link': {'readonly': True}, - 'mode': {'readonly': True}, - 'debug_setting': {'readonly': True}, - 'on_error_deployment': {'readonly': True}, - 'template_hash': {'readonly': True}, - 'output_resources': {'readonly': True}, - 'validated_resources': {'readonly': True}, - 'error': {'readonly': True}, - } - - _attribute_map = { - 'provisioning_state': {'key': 'provisioningState', 'type': 'str'}, - 'correlation_id': {'key': 'correlationId', 'type': 'str'}, - 'timestamp': {'key': 'timestamp', 'type': 'iso-8601'}, - 'duration': {'key': 'duration', 'type': 'str'}, - 'outputs': {'key': 'outputs', 'type': 'object'}, - 'providers': {'key': 'providers', 'type': '[Provider]'}, - 'dependencies': {'key': 'dependencies', 'type': '[Dependency]'}, - 'template_link': {'key': 'templateLink', 'type': 'TemplateLink'}, - 'parameters': {'key': 'parameters', 'type': 'object'}, - 'parameters_link': {'key': 'parametersLink', 'type': 'ParametersLink'}, - 'mode': {'key': 'mode', 'type': 'str'}, - 'debug_setting': {'key': 'debugSetting', 'type': 'DebugSetting'}, - 'on_error_deployment': {'key': 'onErrorDeployment', 'type': 'OnErrorDeploymentExtended'}, - 'template_hash': {'key': 'templateHash', 'type': 'str'}, - 'output_resources': {'key': 'outputResources', 'type': '[ResourceReference]'}, - 'validated_resources': {'key': 'validatedResources', 'type': '[ResourceReference]'}, - 'error': {'key': 'error', 'type': 'ErrorResponse'}, - } - - def __init__( - self, - **kwargs - ): - """ - """ - super(DeploymentPropertiesExtended, self).__init__(**kwargs) + "provisioning_state": {"readonly": True}, + "correlation_id": {"readonly": True}, + "timestamp": {"readonly": True}, + "duration": {"readonly": True}, + "outputs": {"readonly": True}, + "providers": {"readonly": True}, + "dependencies": {"readonly": True}, + "template_link": {"readonly": True}, + "parameters": {"readonly": True}, + "parameters_link": {"readonly": True}, + "mode": {"readonly": True}, + "debug_setting": {"readonly": True}, + "on_error_deployment": {"readonly": True}, + "template_hash": {"readonly": True}, + "output_resources": {"readonly": True}, + "validated_resources": {"readonly": True}, + "error": {"readonly": True}, + } + + _attribute_map = { + "provisioning_state": {"key": "provisioningState", "type": "str"}, + "correlation_id": {"key": "correlationId", "type": "str"}, + "timestamp": {"key": "timestamp", "type": "iso-8601"}, + "duration": {"key": "duration", "type": "str"}, + "outputs": {"key": "outputs", "type": "object"}, + "providers": {"key": "providers", "type": "[Provider]"}, + "dependencies": {"key": "dependencies", "type": "[Dependency]"}, + "template_link": {"key": "templateLink", "type": "TemplateLink"}, + "parameters": {"key": "parameters", "type": "object"}, + "parameters_link": {"key": "parametersLink", "type": "ParametersLink"}, + "mode": {"key": "mode", "type": "str"}, + "debug_setting": {"key": "debugSetting", "type": "DebugSetting"}, + "on_error_deployment": {"key": "onErrorDeployment", "type": "OnErrorDeploymentExtended"}, + "template_hash": {"key": "templateHash", "type": "str"}, + "output_resources": {"key": "outputResources", "type": "[ResourceReference]"}, + "validated_resources": {"key": "validatedResources", "type": "[ResourceReference]"}, + "error": {"key": "error", "type": "ErrorResponse"}, + } + + def __init__(self, **kwargs): + """ """ + super().__init__(**kwargs) self.provisioning_state = None self.correlation_id = None self.timestamp = None @@ -930,7 +892,7 @@ def __init__( self.error = None -class DeploymentValidateResult(msrest.serialization.Model): +class DeploymentValidateResult(_serialization.Model): """Information from validate template deployment response. Variables are only populated by the server, and will be ignored when sending a request. @@ -943,66 +905,55 @@ class DeploymentValidateResult(msrest.serialization.Model): """ _validation = { - 'error': {'readonly': True}, + "error": {"readonly": True}, } _attribute_map = { - 'error': {'key': 'error', 'type': 'ErrorResponse'}, - 'properties': {'key': 'properties', 'type': 'DeploymentPropertiesExtended'}, + "error": {"key": "error", "type": "ErrorResponse"}, + "properties": {"key": "properties", "type": "DeploymentPropertiesExtended"}, } - def __init__( - self, - *, - properties: Optional["DeploymentPropertiesExtended"] = None, - **kwargs - ): + def __init__(self, *, properties: Optional["_models.DeploymentPropertiesExtended"] = None, **kwargs): """ :keyword properties: The template deployment properties. :paramtype properties: ~azure.mgmt.resource.resources.v2020_10_01.models.DeploymentPropertiesExtended """ - super(DeploymentValidateResult, self).__init__(**kwargs) + super().__init__(**kwargs) self.error = None self.properties = properties -class DeploymentWhatIf(msrest.serialization.Model): +class DeploymentWhatIf(_serialization.Model): """Deployment What-if operation parameters. All required parameters must be populated in order to send to Azure. :ivar location: The location to store the deployment data. :vartype location: str - :ivar properties: Required. The deployment properties. + :ivar properties: The deployment properties. Required. :vartype properties: ~azure.mgmt.resource.resources.v2020_10_01.models.DeploymentWhatIfProperties """ _validation = { - 'properties': {'required': True}, + "properties": {"required": True}, } _attribute_map = { - 'location': {'key': 'location', 'type': 'str'}, - 'properties': {'key': 'properties', 'type': 'DeploymentWhatIfProperties'}, + "location": {"key": "location", "type": "str"}, + "properties": {"key": "properties", "type": "DeploymentWhatIfProperties"}, } - def __init__( - self, - *, - properties: "DeploymentWhatIfProperties", - location: Optional[str] = None, - **kwargs - ): + def __init__(self, *, properties: "_models.DeploymentWhatIfProperties", location: Optional[str] = None, **kwargs): """ :keyword location: The location to store the deployment data. :paramtype location: str - :keyword properties: Required. The deployment properties. + :keyword properties: The deployment properties. Required. :paramtype properties: ~azure.mgmt.resource.resources.v2020_10_01.models.DeploymentWhatIfProperties """ - super(DeploymentWhatIf, self).__init__(**kwargs) + super().__init__(**kwargs) self.location = location self.properties = properties @@ -1016,7 +967,7 @@ class DeploymentWhatIfProperties(DeploymentProperties): syntax directly in the request rather than link to an existing template. It can be a JObject or well-formed JSON string. Use either the templateLink property or the template property, but not both. - :vartype template: any + :vartype template: JSON :ivar template_link: The URI of the template. Use either the templateLink property or the template property, but not both. :vartype template_link: ~azure.mgmt.resource.resources.v2020_10_01.models.TemplateLink @@ -1024,17 +975,17 @@ class DeploymentWhatIfProperties(DeploymentProperties): You use this element when you want to provide the parameter values directly in the request rather than link to an existing parameter file. Use either the parametersLink property or the parameters property, but not both. It can be a JObject or a well formed JSON string. - :vartype parameters: any + :vartype parameters: JSON :ivar parameters_link: The URI of parameters file. You use this element to link to an existing parameters file. Use either the parametersLink property or the parameters property, but not both. :vartype parameters_link: ~azure.mgmt.resource.resources.v2020_10_01.models.ParametersLink - :ivar mode: Required. The mode that is used to deploy resources. This value can be either - Incremental or Complete. In Incremental mode, resources are deployed without deleting existing - resources that are not included in the template. In Complete mode, resources are deployed and - existing resources in the resource group that are not included in the template are deleted. Be - careful when using Complete mode as you may unintentionally delete resources. Possible values - include: "Incremental", "Complete". + :ivar mode: The mode that is used to deploy resources. This value can be either Incremental or + Complete. In Incremental mode, resources are deployed without deleting existing resources that + are not included in the template. In Complete mode, resources are deployed and existing + resources in the resource group that are not included in the template are deleted. Be careful + when using Complete mode as you may unintentionally delete resources. Required. Known values + are: "Incremental" and "Complete". :vartype mode: str or ~azure.mgmt.resource.resources.v2020_10_01.models.DeploymentMode :ivar debug_setting: The debug setting of the deployment. :vartype debug_setting: ~azure.mgmt.resource.resources.v2020_10_01.models.DebugSetting @@ -1052,33 +1003,33 @@ class DeploymentWhatIfProperties(DeploymentProperties): """ _validation = { - 'mode': {'required': True}, + "mode": {"required": True}, } _attribute_map = { - 'template': {'key': 'template', 'type': 'object'}, - 'template_link': {'key': 'templateLink', 'type': 'TemplateLink'}, - 'parameters': {'key': 'parameters', 'type': 'object'}, - 'parameters_link': {'key': 'parametersLink', 'type': 'ParametersLink'}, - 'mode': {'key': 'mode', 'type': 'str'}, - 'debug_setting': {'key': 'debugSetting', 'type': 'DebugSetting'}, - 'on_error_deployment': {'key': 'onErrorDeployment', 'type': 'OnErrorDeployment'}, - 'expression_evaluation_options': {'key': 'expressionEvaluationOptions', 'type': 'ExpressionEvaluationOptions'}, - 'what_if_settings': {'key': 'whatIfSettings', 'type': 'DeploymentWhatIfSettings'}, + "template": {"key": "template", "type": "object"}, + "template_link": {"key": "templateLink", "type": "TemplateLink"}, + "parameters": {"key": "parameters", "type": "object"}, + "parameters_link": {"key": "parametersLink", "type": "ParametersLink"}, + "mode": {"key": "mode", "type": "str"}, + "debug_setting": {"key": "debugSetting", "type": "DebugSetting"}, + "on_error_deployment": {"key": "onErrorDeployment", "type": "OnErrorDeployment"}, + "expression_evaluation_options": {"key": "expressionEvaluationOptions", "type": "ExpressionEvaluationOptions"}, + "what_if_settings": {"key": "whatIfSettings", "type": "DeploymentWhatIfSettings"}, } def __init__( self, *, - mode: Union[str, "DeploymentMode"], - template: Optional[Any] = None, - template_link: Optional["TemplateLink"] = None, - parameters: Optional[Any] = None, - parameters_link: Optional["ParametersLink"] = None, - debug_setting: Optional["DebugSetting"] = None, - on_error_deployment: Optional["OnErrorDeployment"] = None, - expression_evaluation_options: Optional["ExpressionEvaluationOptions"] = None, - what_if_settings: Optional["DeploymentWhatIfSettings"] = None, + mode: Union[str, "_models.DeploymentMode"], + template: Optional[JSON] = None, + template_link: Optional["_models.TemplateLink"] = None, + parameters: Optional[JSON] = None, + parameters_link: Optional["_models.ParametersLink"] = None, + debug_setting: Optional["_models.DebugSetting"] = None, + on_error_deployment: Optional["_models.OnErrorDeployment"] = None, + expression_evaluation_options: Optional["_models.ExpressionEvaluationOptions"] = None, + what_if_settings: Optional["_models.DeploymentWhatIfSettings"] = None, **kwargs ): """ @@ -1086,7 +1037,7 @@ def __init__( template syntax directly in the request rather than link to an existing template. It can be a JObject or well-formed JSON string. Use either the templateLink property or the template property, but not both. - :paramtype template: any + :paramtype template: JSON :keyword template_link: The URI of the template. Use either the templateLink property or the template property, but not both. :paramtype template_link: ~azure.mgmt.resource.resources.v2020_10_01.models.TemplateLink @@ -1094,17 +1045,17 @@ def __init__( template. You use this element when you want to provide the parameter values directly in the request rather than link to an existing parameter file. Use either the parametersLink property or the parameters property, but not both. It can be a JObject or a well formed JSON string. - :paramtype parameters: any + :paramtype parameters: JSON :keyword parameters_link: The URI of parameters file. You use this element to link to an existing parameters file. Use either the parametersLink property or the parameters property, but not both. :paramtype parameters_link: ~azure.mgmt.resource.resources.v2020_10_01.models.ParametersLink - :keyword mode: Required. The mode that is used to deploy resources. This value can be either - Incremental or Complete. In Incremental mode, resources are deployed without deleting existing - resources that are not included in the template. In Complete mode, resources are deployed and - existing resources in the resource group that are not included in the template are deleted. Be - careful when using Complete mode as you may unintentionally delete resources. Possible values - include: "Incremental", "Complete". + :keyword mode: The mode that is used to deploy resources. This value can be either Incremental + or Complete. In Incremental mode, resources are deployed without deleting existing resources + that are not included in the template. In Complete mode, resources are deployed and existing + resources in the resource group that are not included in the template are deleted. Be careful + when using Complete mode as you may unintentionally delete resources. Required. Known values + are: "Incremental" and "Complete". :paramtype mode: str or ~azure.mgmt.resource.resources.v2020_10_01.models.DeploymentMode :keyword debug_setting: The debug setting of the deployment. :paramtype debug_setting: ~azure.mgmt.resource.resources.v2020_10_01.models.DebugSetting @@ -1120,40 +1071,45 @@ def __init__( :paramtype what_if_settings: ~azure.mgmt.resource.resources.v2020_10_01.models.DeploymentWhatIfSettings """ - super(DeploymentWhatIfProperties, self).__init__(template=template, template_link=template_link, parameters=parameters, parameters_link=parameters_link, mode=mode, debug_setting=debug_setting, on_error_deployment=on_error_deployment, expression_evaluation_options=expression_evaluation_options, **kwargs) + super().__init__( + template=template, + template_link=template_link, + parameters=parameters, + parameters_link=parameters_link, + mode=mode, + debug_setting=debug_setting, + on_error_deployment=on_error_deployment, + expression_evaluation_options=expression_evaluation_options, + **kwargs + ) self.what_if_settings = what_if_settings -class DeploymentWhatIfSettings(msrest.serialization.Model): +class DeploymentWhatIfSettings(_serialization.Model): """Deployment What-If operation settings. - :ivar result_format: The format of the What-If results. Possible values include: - "ResourceIdOnly", "FullResourcePayloads". + :ivar result_format: The format of the What-If results. Known values are: "ResourceIdOnly" and + "FullResourcePayloads". :vartype result_format: str or ~azure.mgmt.resource.resources.v2020_10_01.models.WhatIfResultFormat """ _attribute_map = { - 'result_format': {'key': 'resultFormat', 'type': 'str'}, + "result_format": {"key": "resultFormat", "type": "str"}, } - def __init__( - self, - *, - result_format: Optional[Union[str, "WhatIfResultFormat"]] = None, - **kwargs - ): + def __init__(self, *, result_format: Optional[Union[str, "_models.WhatIfResultFormat"]] = None, **kwargs): """ - :keyword result_format: The format of the What-If results. Possible values include: - "ResourceIdOnly", "FullResourcePayloads". + :keyword result_format: The format of the What-If results. Known values are: "ResourceIdOnly" + and "FullResourcePayloads". :paramtype result_format: str or ~azure.mgmt.resource.resources.v2020_10_01.models.WhatIfResultFormat """ - super(DeploymentWhatIfSettings, self).__init__(**kwargs) + super().__init__(**kwargs) self.result_format = result_format -class ErrorAdditionalInfo(msrest.serialization.Model): +class ErrorAdditionalInfo(_serialization.Model): """The resource management error additional info. Variables are only populated by the server, and will be ignored when sending a request. @@ -1161,31 +1117,27 @@ class ErrorAdditionalInfo(msrest.serialization.Model): :ivar type: The additional info type. :vartype type: str :ivar info: The additional info. - :vartype info: any + :vartype info: JSON """ _validation = { - 'type': {'readonly': True}, - 'info': {'readonly': True}, + "type": {"readonly": True}, + "info": {"readonly": True}, } _attribute_map = { - 'type': {'key': 'type', 'type': 'str'}, - 'info': {'key': 'info', 'type': 'object'}, + "type": {"key": "type", "type": "str"}, + "info": {"key": "info", "type": "object"}, } - def __init__( - self, - **kwargs - ): - """ - """ - super(ErrorAdditionalInfo, self).__init__(**kwargs) + def __init__(self, **kwargs): + """ """ + super().__init__(**kwargs) self.type = None self.info = None -class ErrorResponse(msrest.serialization.Model): +class ErrorResponse(_serialization.Model): """Common error response for all Azure Resource Manager APIs to return error details for failed operations. (This also follows the OData error response format.). Variables are only populated by the server, and will be ignored when sending a request. @@ -1204,28 +1156,24 @@ class ErrorResponse(msrest.serialization.Model): """ _validation = { - 'code': {'readonly': True}, - 'message': {'readonly': True}, - 'target': {'readonly': True}, - 'details': {'readonly': True}, - 'additional_info': {'readonly': True}, + "code": {"readonly": True}, + "message": {"readonly": True}, + "target": {"readonly": True}, + "details": {"readonly": True}, + "additional_info": {"readonly": True}, } _attribute_map = { - 'code': {'key': 'code', 'type': 'str'}, - 'message': {'key': 'message', 'type': 'str'}, - 'target': {'key': 'target', 'type': 'str'}, - 'details': {'key': 'details', 'type': '[ErrorResponse]'}, - 'additional_info': {'key': 'additionalInfo', 'type': '[ErrorAdditionalInfo]'}, + "code": {"key": "code", "type": "str"}, + "message": {"key": "message", "type": "str"}, + "target": {"key": "target", "type": "str"}, + "details": {"key": "details", "type": "[ErrorResponse]"}, + "additional_info": {"key": "additionalInfo", "type": "[ErrorAdditionalInfo]"}, } - def __init__( - self, - **kwargs - ): - """ - """ - super(ErrorResponse, self).__init__(**kwargs) + def __init__(self, **kwargs): + """ """ + super().__init__(**kwargs) self.code = None self.message = None self.target = None @@ -1233,7 +1181,7 @@ def __init__( self.additional_info = None -class ExportTemplateRequest(msrest.serialization.Model): +class ExportTemplateRequest(_serialization.Model): """Export resource group template request parameters. :ivar resources: The IDs of the resources to filter the export by. To export all resources, @@ -1246,17 +1194,11 @@ class ExportTemplateRequest(msrest.serialization.Model): """ _attribute_map = { - 'resources': {'key': 'resources', 'type': '[str]'}, - 'options': {'key': 'options', 'type': 'str'}, + "resources": {"key": "resources", "type": "[str]"}, + "options": {"key": "options", "type": "str"}, } - def __init__( - self, - *, - resources: Optional[List[str]] = None, - options: Optional[str] = None, - **kwargs - ): + def __init__(self, *, resources: Optional[List[str]] = None, options: Optional[str] = None, **kwargs): """ :keyword resources: The IDs of the resources to filter the export by. To export all resources, supply an array with single entry '*'. @@ -1266,41 +1208,36 @@ def __init__( 'SkipResourceNameParameterization', 'SkipAllParameterization'. :paramtype options: str """ - super(ExportTemplateRequest, self).__init__(**kwargs) + super().__init__(**kwargs) self.resources = resources self.options = options -class ExpressionEvaluationOptions(msrest.serialization.Model): +class ExpressionEvaluationOptions(_serialization.Model): """Specifies whether template expressions are evaluated within the scope of the parent template or nested template. :ivar scope: The scope to be used for evaluation of parameters, variables and functions in a - nested template. Possible values include: "NotSpecified", "Outer", "Inner". + nested template. Known values are: "NotSpecified", "Outer", and "Inner". :vartype scope: str or ~azure.mgmt.resource.resources.v2020_10_01.models.ExpressionEvaluationOptionsScopeType """ _attribute_map = { - 'scope': {'key': 'scope', 'type': 'str'}, + "scope": {"key": "scope", "type": "str"}, } - def __init__( - self, - *, - scope: Optional[Union[str, "ExpressionEvaluationOptionsScopeType"]] = None, - **kwargs - ): + def __init__(self, *, scope: Optional[Union[str, "_models.ExpressionEvaluationOptionsScopeType"]] = None, **kwargs): """ :keyword scope: The scope to be used for evaluation of parameters, variables and functions in a - nested template. Possible values include: "NotSpecified", "Outer", "Inner". + nested template. Known values are: "NotSpecified", "Outer", and "Inner". :paramtype scope: str or ~azure.mgmt.resource.resources.v2020_10_01.models.ExpressionEvaluationOptionsScopeType """ - super(ExpressionEvaluationOptions, self).__init__(**kwargs) + super().__init__(**kwargs) self.scope = scope -class Resource(msrest.serialization.Model): +class Resource(_serialization.Model): """Specified resource. Variables are only populated by the server, and will be ignored when sending a request. @@ -1313,38 +1250,32 @@ class Resource(msrest.serialization.Model): :vartype type: str :ivar location: Resource location. :vartype location: str - :ivar tags: A set of tags. Resource tags. + :ivar tags: Resource tags. :vartype tags: dict[str, str] """ _validation = { - 'id': {'readonly': True}, - 'name': {'readonly': True}, - 'type': {'readonly': True}, + "id": {"readonly": True}, + "name": {"readonly": True}, + "type": {"readonly": True}, } _attribute_map = { - 'id': {'key': 'id', 'type': 'str'}, - 'name': {'key': 'name', 'type': 'str'}, - 'type': {'key': 'type', 'type': 'str'}, - 'location': {'key': 'location', 'type': 'str'}, - 'tags': {'key': 'tags', 'type': '{str}'}, + "id": {"key": "id", "type": "str"}, + "name": {"key": "name", "type": "str"}, + "type": {"key": "type", "type": "str"}, + "location": {"key": "location", "type": "str"}, + "tags": {"key": "tags", "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): """ :keyword location: Resource location. :paramtype location: str - :keyword tags: A set of tags. Resource tags. + :keyword tags: Resource tags. :paramtype tags: dict[str, str] """ - super(Resource, self).__init__(**kwargs) + super().__init__(**kwargs) self.id = None self.name = None self.type = None @@ -1352,7 +1283,7 @@ def __init__( self.tags = tags -class GenericResource(Resource): +class GenericResource(Resource): # pylint: disable=too-many-instance-attributes """Resource information. Variables are only populated by the server, and will be ignored when sending a request. @@ -1365,12 +1296,12 @@ class GenericResource(Resource): :vartype type: str :ivar location: Resource location. :vartype location: str - :ivar tags: A set of tags. Resource tags. + :ivar tags: Resource tags. :vartype tags: dict[str, str] :ivar plan: The plan of the resource. :vartype plan: ~azure.mgmt.resource.resources.v2020_10_01.models.Plan :ivar properties: The resource properties. - :vartype properties: any + :vartype properties: JSON :ivar kind: The kind of the resource. :vartype kind: str :ivar managed_by: ID of the resource that manages this resource. @@ -1382,23 +1313,23 @@ class GenericResource(Resource): """ _validation = { - 'id': {'readonly': True}, - 'name': {'readonly': True}, - 'type': {'readonly': True}, + "id": {"readonly": True}, + "name": {"readonly": True}, + "type": {"readonly": True}, } _attribute_map = { - 'id': {'key': 'id', 'type': 'str'}, - 'name': {'key': 'name', 'type': 'str'}, - 'type': {'key': 'type', 'type': 'str'}, - 'location': {'key': 'location', 'type': 'str'}, - 'tags': {'key': 'tags', 'type': '{str}'}, - 'plan': {'key': 'plan', 'type': 'Plan'}, - 'properties': {'key': 'properties', 'type': 'object'}, - 'kind': {'key': 'kind', 'type': 'str'}, - 'managed_by': {'key': 'managedBy', 'type': 'str'}, - 'sku': {'key': 'sku', 'type': 'Sku'}, - 'identity': {'key': 'identity', 'type': 'Identity'}, + "id": {"key": "id", "type": "str"}, + "name": {"key": "name", "type": "str"}, + "type": {"key": "type", "type": "str"}, + "location": {"key": "location", "type": "str"}, + "tags": {"key": "tags", "type": "{str}"}, + "plan": {"key": "plan", "type": "Plan"}, + "properties": {"key": "properties", "type": "object"}, + "kind": {"key": "kind", "type": "str"}, + "managed_by": {"key": "managedBy", "type": "str"}, + "sku": {"key": "sku", "type": "Sku"}, + "identity": {"key": "identity", "type": "Identity"}, } def __init__( @@ -1406,23 +1337,23 @@ def __init__( *, location: Optional[str] = None, tags: Optional[Dict[str, str]] = None, - plan: Optional["Plan"] = None, - properties: Optional[Any] = None, + plan: Optional["_models.Plan"] = None, + properties: Optional[JSON] = None, kind: Optional[str] = None, managed_by: Optional[str] = None, - sku: Optional["Sku"] = None, - identity: Optional["Identity"] = None, + sku: Optional["_models.Sku"] = None, + identity: Optional["_models.Identity"] = None, **kwargs ): """ :keyword location: Resource location. :paramtype location: str - :keyword tags: A set of tags. Resource tags. + :keyword tags: Resource tags. :paramtype tags: dict[str, str] :keyword plan: The plan of the resource. :paramtype plan: ~azure.mgmt.resource.resources.v2020_10_01.models.Plan :keyword properties: The resource properties. - :paramtype properties: any + :paramtype properties: JSON :keyword kind: The kind of the resource. :paramtype kind: str :keyword managed_by: ID of the resource that manages this resource. @@ -1432,7 +1363,7 @@ def __init__( :keyword identity: The identity of the resource. :paramtype identity: ~azure.mgmt.resource.resources.v2020_10_01.models.Identity """ - super(GenericResource, self).__init__(location=location, tags=tags, **kwargs) + super().__init__(location=location, tags=tags, **kwargs) self.plan = plan self.properties = properties self.kind = kind @@ -1441,7 +1372,7 @@ def __init__( self.identity = identity -class GenericResourceExpanded(GenericResource): +class GenericResourceExpanded(GenericResource): # pylint: disable=too-many-instance-attributes """Resource information. Variables are only populated by the server, and will be ignored when sending a request. @@ -1454,12 +1385,12 @@ class GenericResourceExpanded(GenericResource): :vartype type: str :ivar location: Resource location. :vartype location: str - :ivar tags: A set of tags. Resource tags. + :ivar tags: Resource tags. :vartype tags: dict[str, str] :ivar plan: The plan of the resource. :vartype plan: ~azure.mgmt.resource.resources.v2020_10_01.models.Plan :ivar properties: The resource properties. - :vartype properties: any + :vartype properties: JSON :ivar kind: The kind of the resource. :vartype kind: str :ivar managed_by: ID of the resource that manages this resource. @@ -1480,29 +1411,29 @@ class GenericResourceExpanded(GenericResource): """ _validation = { - 'id': {'readonly': True}, - 'name': {'readonly': True}, - 'type': {'readonly': True}, - 'created_time': {'readonly': True}, - 'changed_time': {'readonly': True}, - 'provisioning_state': {'readonly': True}, - } - - _attribute_map = { - 'id': {'key': 'id', 'type': 'str'}, - 'name': {'key': 'name', 'type': 'str'}, - 'type': {'key': 'type', 'type': 'str'}, - 'location': {'key': 'location', 'type': 'str'}, - 'tags': {'key': 'tags', 'type': '{str}'}, - 'plan': {'key': 'plan', 'type': 'Plan'}, - 'properties': {'key': 'properties', 'type': 'object'}, - 'kind': {'key': 'kind', 'type': 'str'}, - 'managed_by': {'key': 'managedBy', 'type': 'str'}, - 'sku': {'key': 'sku', 'type': 'Sku'}, - 'identity': {'key': 'identity', 'type': 'Identity'}, - 'created_time': {'key': 'createdTime', 'type': 'iso-8601'}, - 'changed_time': {'key': 'changedTime', 'type': 'iso-8601'}, - 'provisioning_state': {'key': 'provisioningState', 'type': 'str'}, + "id": {"readonly": True}, + "name": {"readonly": True}, + "type": {"readonly": True}, + "created_time": {"readonly": True}, + "changed_time": {"readonly": True}, + "provisioning_state": {"readonly": True}, + } + + _attribute_map = { + "id": {"key": "id", "type": "str"}, + "name": {"key": "name", "type": "str"}, + "type": {"key": "type", "type": "str"}, + "location": {"key": "location", "type": "str"}, + "tags": {"key": "tags", "type": "{str}"}, + "plan": {"key": "plan", "type": "Plan"}, + "properties": {"key": "properties", "type": "object"}, + "kind": {"key": "kind", "type": "str"}, + "managed_by": {"key": "managedBy", "type": "str"}, + "sku": {"key": "sku", "type": "Sku"}, + "identity": {"key": "identity", "type": "Identity"}, + "created_time": {"key": "createdTime", "type": "iso-8601"}, + "changed_time": {"key": "changedTime", "type": "iso-8601"}, + "provisioning_state": {"key": "provisioningState", "type": "str"}, } def __init__( @@ -1510,23 +1441,23 @@ def __init__( *, location: Optional[str] = None, tags: Optional[Dict[str, str]] = None, - plan: Optional["Plan"] = None, - properties: Optional[Any] = None, + plan: Optional["_models.Plan"] = None, + properties: Optional[JSON] = None, kind: Optional[str] = None, managed_by: Optional[str] = None, - sku: Optional["Sku"] = None, - identity: Optional["Identity"] = None, + sku: Optional["_models.Sku"] = None, + identity: Optional["_models.Identity"] = None, **kwargs ): """ :keyword location: Resource location. :paramtype location: str - :keyword tags: A set of tags. Resource tags. + :keyword tags: Resource tags. :paramtype tags: dict[str, str] :keyword plan: The plan of the resource. :paramtype plan: ~azure.mgmt.resource.resources.v2020_10_01.models.Plan :keyword properties: The resource properties. - :paramtype properties: any + :paramtype properties: JSON :keyword kind: The kind of the resource. :paramtype kind: str :keyword managed_by: ID of the resource that manages this resource. @@ -1536,13 +1467,23 @@ def __init__( :keyword identity: The identity of the resource. :paramtype identity: ~azure.mgmt.resource.resources.v2020_10_01.models.Identity """ - super(GenericResourceExpanded, self).__init__(location=location, tags=tags, plan=plan, properties=properties, kind=kind, managed_by=managed_by, sku=sku, identity=identity, **kwargs) + super().__init__( + location=location, + tags=tags, + plan=plan, + properties=properties, + kind=kind, + managed_by=managed_by, + sku=sku, + identity=identity, + **kwargs + ) self.created_time = None self.changed_time = None self.provisioning_state = None -class GenericResourceFilter(msrest.serialization.Model): +class GenericResourceFilter(_serialization.Model): """Resource filter. :ivar resource_type: The resource type. @@ -1554,9 +1495,9 @@ class GenericResourceFilter(msrest.serialization.Model): """ _attribute_map = { - 'resource_type': {'key': 'resourceType', 'type': 'str'}, - 'tagname': {'key': 'tagname', 'type': 'str'}, - 'tagvalue': {'key': 'tagvalue', 'type': 'str'}, + "resource_type": {"key": "resourceType", "type": "str"}, + "tagname": {"key": "tagname", "type": "str"}, + "tagvalue": {"key": "tagvalue", "type": "str"}, } def __init__( @@ -1575,38 +1516,33 @@ def __init__( :keyword tagvalue: The tag value. :paramtype tagvalue: str """ - super(GenericResourceFilter, self).__init__(**kwargs) + super().__init__(**kwargs) self.resource_type = resource_type self.tagname = tagname self.tagvalue = tagvalue -class HttpMessage(msrest.serialization.Model): +class HttpMessage(_serialization.Model): """HTTP message. :ivar content: HTTP message content. - :vartype content: any + :vartype content: JSON """ _attribute_map = { - 'content': {'key': 'content', 'type': 'object'}, + "content": {"key": "content", "type": "object"}, } - def __init__( - self, - *, - content: Optional[Any] = None, - **kwargs - ): + def __init__(self, *, content: Optional[JSON] = None, **kwargs): """ :keyword content: HTTP message content. - :paramtype content: any + :paramtype content: JSON """ - super(HttpMessage, self).__init__(**kwargs) + super().__init__(**kwargs) self.content = content -class Identity(msrest.serialization.Model): +class Identity(_serialization.Model): """Identity for the resource. Variables are only populated by the server, and will be ignored when sending a request. @@ -1615,8 +1551,8 @@ class Identity(msrest.serialization.Model): :vartype principal_id: str :ivar tenant_id: The tenant ID of resource. :vartype tenant_id: str - :ivar type: The identity type. Possible values include: "SystemAssigned", "UserAssigned", - "SystemAssigned, UserAssigned", "None". + :ivar type: The identity type. Known values are: "SystemAssigned", "UserAssigned", + "SystemAssigned, UserAssigned", and "None". :vartype type: str or ~azure.mgmt.resource.resources.v2020_10_01.models.ResourceIdentityType :ivar user_assigned_identities: The list of user identities associated with the resource. The user identity dictionary key references will be ARM resource ids in the form: @@ -1626,27 +1562,27 @@ class Identity(msrest.serialization.Model): """ _validation = { - 'principal_id': {'readonly': True}, - 'tenant_id': {'readonly': True}, + "principal_id": {"readonly": True}, + "tenant_id": {"readonly": True}, } _attribute_map = { - 'principal_id': {'key': 'principalId', 'type': 'str'}, - 'tenant_id': {'key': 'tenantId', 'type': 'str'}, - 'type': {'key': 'type', 'type': 'str'}, - 'user_assigned_identities': {'key': 'userAssignedIdentities', 'type': '{IdentityUserAssignedIdentitiesValue}'}, + "principal_id": {"key": "principalId", "type": "str"}, + "tenant_id": {"key": "tenantId", "type": "str"}, + "type": {"key": "type", "type": "str"}, + "user_assigned_identities": {"key": "userAssignedIdentities", "type": "{IdentityUserAssignedIdentitiesValue}"}, } def __init__( self, *, - type: Optional[Union[str, "ResourceIdentityType"]] = None, - user_assigned_identities: Optional[Dict[str, "IdentityUserAssignedIdentitiesValue"]] = None, + type: Optional[Union[str, "_models.ResourceIdentityType"]] = None, + user_assigned_identities: Optional[Dict[str, "_models.IdentityUserAssignedIdentitiesValue"]] = None, **kwargs ): """ - :keyword type: The identity type. Possible values include: "SystemAssigned", "UserAssigned", - "SystemAssigned, UserAssigned", "None". + :keyword type: The identity type. Known values are: "SystemAssigned", "UserAssigned", + "SystemAssigned, UserAssigned", and "None". :paramtype type: str or ~azure.mgmt.resource.resources.v2020_10_01.models.ResourceIdentityType :keyword user_assigned_identities: The list of user identities associated with the resource. The user identity dictionary key references will be ARM resource ids in the form: @@ -1654,14 +1590,14 @@ def __init__( :paramtype user_assigned_identities: dict[str, ~azure.mgmt.resource.resources.v2020_10_01.models.IdentityUserAssignedIdentitiesValue] """ - super(Identity, self).__init__(**kwargs) + super().__init__(**kwargs) self.principal_id = None self.tenant_id = None self.type = type self.user_assigned_identities = user_assigned_identities -class IdentityUserAssignedIdentitiesValue(msrest.serialization.Model): +class IdentityUserAssignedIdentitiesValue(_serialization.Model): """IdentityUserAssignedIdentitiesValue. Variables are only populated by the server, and will be ignored when sending a request. @@ -1673,61 +1609,57 @@ class IdentityUserAssignedIdentitiesValue(msrest.serialization.Model): """ _validation = { - 'principal_id': {'readonly': True}, - 'client_id': {'readonly': True}, + "principal_id": {"readonly": True}, + "client_id": {"readonly": True}, } _attribute_map = { - 'principal_id': {'key': 'principalId', 'type': 'str'}, - 'client_id': {'key': 'clientId', 'type': 'str'}, + "principal_id": {"key": "principalId", "type": "str"}, + "client_id": {"key": "clientId", "type": "str"}, } - def __init__( - self, - **kwargs - ): - """ - """ - super(IdentityUserAssignedIdentitiesValue, self).__init__(**kwargs) + def __init__(self, **kwargs): + """ """ + super().__init__(**kwargs) self.principal_id = None self.client_id = None -class OnErrorDeployment(msrest.serialization.Model): +class OnErrorDeployment(_serialization.Model): """Deployment on error behavior. :ivar type: The deployment on error behavior type. Possible values are LastSuccessful and - SpecificDeployment. Possible values include: "LastSuccessful", "SpecificDeployment". + SpecificDeployment. Known values are: "LastSuccessful" and "SpecificDeployment". :vartype type: str or ~azure.mgmt.resource.resources.v2020_10_01.models.OnErrorDeploymentType :ivar deployment_name: The deployment to be used on error case. :vartype deployment_name: str """ _attribute_map = { - 'type': {'key': 'type', 'type': 'str'}, - 'deployment_name': {'key': 'deploymentName', 'type': 'str'}, + "type": {"key": "type", "type": "str"}, + "deployment_name": {"key": "deploymentName", "type": "str"}, } def __init__( self, *, - type: Optional[Union[str, "OnErrorDeploymentType"]] = None, + type: Optional[Union[str, "_models.OnErrorDeploymentType"]] = None, deployment_name: Optional[str] = None, **kwargs ): """ :keyword type: The deployment on error behavior type. Possible values are LastSuccessful and - SpecificDeployment. Possible values include: "LastSuccessful", "SpecificDeployment". + SpecificDeployment. Known values are: "LastSuccessful" and "SpecificDeployment". :paramtype type: str or ~azure.mgmt.resource.resources.v2020_10_01.models.OnErrorDeploymentType :keyword deployment_name: The deployment to be used on error case. :paramtype deployment_name: str """ - super(OnErrorDeployment, self).__init__(**kwargs) + super().__init__(**kwargs) self.type = type self.deployment_name = deployment_name -class OnErrorDeploymentExtended(msrest.serialization.Model): +class OnErrorDeploymentExtended(_serialization.Model): """Deployment on error behavior with additional details. Variables are only populated by the server, and will be ignored when sending a request. @@ -1735,43 +1667,43 @@ class OnErrorDeploymentExtended(msrest.serialization.Model): :ivar provisioning_state: The state of the provisioning for the on error deployment. :vartype provisioning_state: str :ivar type: The deployment on error behavior type. Possible values are LastSuccessful and - SpecificDeployment. Possible values include: "LastSuccessful", "SpecificDeployment". + SpecificDeployment. Known values are: "LastSuccessful" and "SpecificDeployment". :vartype type: str or ~azure.mgmt.resource.resources.v2020_10_01.models.OnErrorDeploymentType :ivar deployment_name: The deployment to be used on error case. :vartype deployment_name: str """ _validation = { - 'provisioning_state': {'readonly': True}, + "provisioning_state": {"readonly": True}, } _attribute_map = { - 'provisioning_state': {'key': 'provisioningState', 'type': 'str'}, - 'type': {'key': 'type', 'type': 'str'}, - 'deployment_name': {'key': 'deploymentName', 'type': 'str'}, + "provisioning_state": {"key": "provisioningState", "type": "str"}, + "type": {"key": "type", "type": "str"}, + "deployment_name": {"key": "deploymentName", "type": "str"}, } def __init__( self, *, - type: Optional[Union[str, "OnErrorDeploymentType"]] = None, + type: Optional[Union[str, "_models.OnErrorDeploymentType"]] = None, deployment_name: Optional[str] = None, **kwargs ): """ :keyword type: The deployment on error behavior type. Possible values are LastSuccessful and - SpecificDeployment. Possible values include: "LastSuccessful", "SpecificDeployment". + SpecificDeployment. Known values are: "LastSuccessful" and "SpecificDeployment". :paramtype type: str or ~azure.mgmt.resource.resources.v2020_10_01.models.OnErrorDeploymentType :keyword deployment_name: The deployment to be used on error case. :paramtype deployment_name: str """ - super(OnErrorDeploymentExtended, self).__init__(**kwargs) + super().__init__(**kwargs) self.provisioning_state = None self.type = type self.deployment_name = deployment_name -class Operation(msrest.serialization.Model): +class Operation(_serialization.Model): """Microsoft.Resources operation. :ivar name: Operation name: {provider}/{resource}/{operation}. @@ -1781,29 +1713,23 @@ class Operation(msrest.serialization.Model): """ _attribute_map = { - 'name': {'key': 'name', 'type': 'str'}, - 'display': {'key': 'display', 'type': 'OperationDisplay'}, + "name": {"key": "name", "type": "str"}, + "display": {"key": "display", "type": "OperationDisplay"}, } - def __init__( - self, - *, - name: Optional[str] = None, - display: Optional["OperationDisplay"] = None, - **kwargs - ): + def __init__(self, *, name: Optional[str] = None, display: Optional["_models.OperationDisplay"] = None, **kwargs): """ :keyword name: Operation name: {provider}/{resource}/{operation}. :paramtype name: str :keyword display: The object that represents the operation. :paramtype display: ~azure.mgmt.resource.resources.v2020_10_01.models.OperationDisplay """ - super(Operation, self).__init__(**kwargs) + super().__init__(**kwargs) self.name = name self.display = display -class OperationDisplay(msrest.serialization.Model): +class OperationDisplay(_serialization.Model): """The object that represents the operation. :ivar provider: Service provider: Microsoft.Resources. @@ -1817,10 +1743,10 @@ class OperationDisplay(msrest.serialization.Model): """ _attribute_map = { - 'provider': {'key': 'provider', 'type': 'str'}, - 'resource': {'key': 'resource', 'type': 'str'}, - 'operation': {'key': 'operation', 'type': 'str'}, - 'description': {'key': 'description', 'type': 'str'}, + "provider": {"key": "provider", "type": "str"}, + "resource": {"key": "resource", "type": "str"}, + "operation": {"key": "operation", "type": "str"}, + "description": {"key": "description", "type": "str"}, } def __init__( @@ -1842,14 +1768,14 @@ def __init__( :keyword description: Description of the operation. :paramtype description: str """ - super(OperationDisplay, self).__init__(**kwargs) + super().__init__(**kwargs) self.provider = provider self.resource = resource self.operation = operation self.description = description -class OperationListResult(msrest.serialization.Model): +class OperationListResult(_serialization.Model): """Result of the request to list Microsoft.Resources operations. It contains a list of operations and a URL link to get the next set of results. :ivar value: List of Microsoft.Resources operations. @@ -1859,67 +1785,55 @@ class OperationListResult(msrest.serialization.Model): """ _attribute_map = { - 'value': {'key': 'value', 'type': '[Operation]'}, - 'next_link': {'key': 'nextLink', 'type': 'str'}, + "value": {"key": "value", "type": "[Operation]"}, + "next_link": {"key": "nextLink", "type": "str"}, } - def __init__( - self, - *, - value: Optional[List["Operation"]] = None, - next_link: Optional[str] = None, - **kwargs - ): + def __init__(self, *, value: Optional[List["_models.Operation"]] = None, next_link: Optional[str] = None, **kwargs): """ :keyword value: List of Microsoft.Resources operations. :paramtype value: list[~azure.mgmt.resource.resources.v2020_10_01.models.Operation] :keyword next_link: URL to get the next set of operation list results if there are any. :paramtype next_link: str """ - super(OperationListResult, self).__init__(**kwargs) + super().__init__(**kwargs) self.value = value self.next_link = next_link -class ParametersLink(msrest.serialization.Model): +class ParametersLink(_serialization.Model): """Entity representing the reference to the deployment parameters. All required parameters must be populated in order to send to Azure. - :ivar uri: Required. The URI of the parameters file. + :ivar uri: The URI of the parameters file. Required. :vartype uri: str :ivar content_version: If included, must match the ContentVersion in the template. :vartype content_version: str """ _validation = { - 'uri': {'required': True}, + "uri": {"required": True}, } _attribute_map = { - 'uri': {'key': 'uri', 'type': 'str'}, - 'content_version': {'key': 'contentVersion', 'type': 'str'}, + "uri": {"key": "uri", "type": "str"}, + "content_version": {"key": "contentVersion", "type": "str"}, } - def __init__( - self, - *, - uri: str, - content_version: Optional[str] = None, - **kwargs - ): + def __init__(self, *, uri: str, content_version: Optional[str] = None, **kwargs): """ - :keyword uri: Required. The URI of the parameters file. + :keyword uri: The URI of the parameters file. Required. :paramtype uri: str :keyword content_version: If included, must match the ContentVersion in the template. :paramtype content_version: str """ - super(ParametersLink, self).__init__(**kwargs) + super().__init__(**kwargs) self.uri = uri self.content_version = content_version -class Plan(msrest.serialization.Model): +class Plan(_serialization.Model): """Plan for the resource. :ivar name: The plan ID. @@ -1935,11 +1849,11 @@ class Plan(msrest.serialization.Model): """ _attribute_map = { - 'name': {'key': 'name', 'type': 'str'}, - 'publisher': {'key': 'publisher', 'type': 'str'}, - 'product': {'key': 'product', 'type': 'str'}, - 'promotion_code': {'key': 'promotionCode', 'type': 'str'}, - 'version': {'key': 'version', 'type': 'str'}, + "name": {"key": "name", "type": "str"}, + "publisher": {"key": "publisher", "type": "str"}, + "product": {"key": "product", "type": "str"}, + "promotion_code": {"key": "promotionCode", "type": "str"}, + "version": {"key": "version", "type": "str"}, } def __init__( @@ -1964,7 +1878,7 @@ def __init__( :keyword version: The plan's version. :paramtype version: str """ - super(Plan, self).__init__(**kwargs) + super().__init__(**kwargs) self.name = name self.publisher = publisher self.product = product @@ -1972,7 +1886,7 @@ def __init__( self.version = version -class Provider(msrest.serialization.Model): +class Provider(_serialization.Model): """Resource provider information. Variables are only populated by the server, and will be ignored when sending a request. @@ -1991,31 +1905,26 @@ class Provider(msrest.serialization.Model): """ _validation = { - 'id': {'readonly': True}, - 'registration_state': {'readonly': True}, - 'registration_policy': {'readonly': True}, - 'resource_types': {'readonly': True}, + "id": {"readonly": True}, + "registration_state": {"readonly": True}, + "registration_policy": {"readonly": True}, + "resource_types": {"readonly": True}, } _attribute_map = { - 'id': {'key': 'id', 'type': 'str'}, - 'namespace': {'key': 'namespace', 'type': 'str'}, - 'registration_state': {'key': 'registrationState', 'type': 'str'}, - 'registration_policy': {'key': 'registrationPolicy', 'type': 'str'}, - 'resource_types': {'key': 'resourceTypes', 'type': '[ProviderResourceType]'}, + "id": {"key": "id", "type": "str"}, + "namespace": {"key": "namespace", "type": "str"}, + "registration_state": {"key": "registrationState", "type": "str"}, + "registration_policy": {"key": "registrationPolicy", "type": "str"}, + "resource_types": {"key": "resourceTypes", "type": "[ProviderResourceType]"}, } - def __init__( - self, - *, - namespace: Optional[str] = None, - **kwargs - ): + def __init__(self, *, namespace: Optional[str] = None, **kwargs): """ :keyword namespace: The namespace of the resource provider. :paramtype namespace: str """ - super(Provider, self).__init__(**kwargs) + super().__init__(**kwargs) self.id = None self.namespace = namespace self.registration_state = None @@ -2023,7 +1932,7 @@ def __init__( self.resource_types = None -class ProviderExtendedLocation(msrest.serialization.Model): +class ProviderExtendedLocation(_serialization.Model): """The provider extended location. :ivar location: The azure location. @@ -2035,9 +1944,9 @@ class ProviderExtendedLocation(msrest.serialization.Model): """ _attribute_map = { - 'location': {'key': 'location', 'type': 'str'}, - 'type': {'key': 'type', 'type': 'str'}, - 'extended_locations': {'key': 'extendedLocations', 'type': '[str]'}, + "location": {"key": "location", "type": "str"}, + "type": {"key": "type", "type": "str"}, + "extended_locations": {"key": "extendedLocations", "type": "[str]"}, } def __init__( @@ -2056,13 +1965,13 @@ def __init__( :keyword extended_locations: The extended locations for the azure location. :paramtype extended_locations: list[str] """ - super(ProviderExtendedLocation, self).__init__(**kwargs) + super().__init__(**kwargs) self.location = location self.type = type self.extended_locations = extended_locations -class ProviderListResult(msrest.serialization.Model): +class ProviderListResult(_serialization.Model): """List of resource providers. Variables are only populated by the server, and will be ignored when sending a request. @@ -2074,30 +1983,25 @@ class ProviderListResult(msrest.serialization.Model): """ _validation = { - 'next_link': {'readonly': True}, + "next_link": {"readonly": True}, } _attribute_map = { - 'value': {'key': 'value', 'type': '[Provider]'}, - 'next_link': {'key': 'nextLink', 'type': 'str'}, + "value": {"key": "value", "type": "[Provider]"}, + "next_link": {"key": "nextLink", "type": "str"}, } - def __init__( - self, - *, - value: Optional[List["Provider"]] = None, - **kwargs - ): + def __init__(self, *, value: Optional[List["_models.Provider"]] = None, **kwargs): """ :keyword value: An array of resource providers. :paramtype value: list[~azure.mgmt.resource.resources.v2020_10_01.models.Provider] """ - super(ProviderListResult, self).__init__(**kwargs) + super().__init__(**kwargs) self.value = value self.next_link = None -class ProviderResourceType(msrest.serialization.Model): +class ProviderResourceType(_serialization.Model): """Resource type managed by the resource provider. Variables are only populated by the server, and will be ignored when sending a request. @@ -2126,21 +2030,21 @@ class ProviderResourceType(msrest.serialization.Model): """ _validation = { - 'default_api_version': {'readonly': True}, - 'api_profiles': {'readonly': True}, + "default_api_version": {"readonly": True}, + "api_profiles": {"readonly": True}, } _attribute_map = { - 'resource_type': {'key': 'resourceType', 'type': 'str'}, - 'locations': {'key': 'locations', 'type': '[str]'}, - 'location_mappings': {'key': 'locationMappings', 'type': '[ProviderExtendedLocation]'}, - 'aliases': {'key': 'aliases', 'type': '[Alias]'}, - 'api_versions': {'key': 'apiVersions', 'type': '[str]'}, - 'default_api_version': {'key': 'defaultApiVersion', 'type': 'str'}, - 'zone_mappings': {'key': 'zoneMappings', 'type': '[ZoneMapping]'}, - 'api_profiles': {'key': 'apiProfiles', 'type': '[ApiProfile]'}, - 'capabilities': {'key': 'capabilities', 'type': 'str'}, - 'properties': {'key': 'properties', 'type': '{str}'}, + "resource_type": {"key": "resourceType", "type": "str"}, + "locations": {"key": "locations", "type": "[str]"}, + "location_mappings": {"key": "locationMappings", "type": "[ProviderExtendedLocation]"}, + "aliases": {"key": "aliases", "type": "[Alias]"}, + "api_versions": {"key": "apiVersions", "type": "[str]"}, + "default_api_version": {"key": "defaultApiVersion", "type": "str"}, + "zone_mappings": {"key": "zoneMappings", "type": "[ZoneMapping]"}, + "api_profiles": {"key": "apiProfiles", "type": "[ApiProfile]"}, + "capabilities": {"key": "capabilities", "type": "str"}, + "properties": {"key": "properties", "type": "{str}"}, } def __init__( @@ -2148,10 +2052,10 @@ def __init__( *, resource_type: Optional[str] = None, locations: Optional[List[str]] = None, - location_mappings: Optional[List["ProviderExtendedLocation"]] = None, - aliases: Optional[List["Alias"]] = None, + location_mappings: Optional[List["_models.ProviderExtendedLocation"]] = None, + aliases: Optional[List["_models.Alias"]] = None, api_versions: Optional[List[str]] = None, - zone_mappings: Optional[List["ZoneMapping"]] = None, + zone_mappings: Optional[List["_models.ZoneMapping"]] = None, capabilities: Optional[str] = None, properties: Optional[Dict[str, str]] = None, **kwargs @@ -2175,7 +2079,7 @@ def __init__( :keyword properties: The properties. :paramtype properties: dict[str, str] """ - super(ProviderResourceType, self).__init__(**kwargs) + super().__init__(**kwargs) self.resource_type = resource_type self.locations = locations self.location_mappings = location_mappings @@ -2188,7 +2092,7 @@ def __init__( self.properties = properties -class ProviderResourceTypeListResult(msrest.serialization.Model): +class ProviderResourceTypeListResult(_serialization.Model): """List of resource types of a resource provider. Variables are only populated by the server, and will be ignored when sending a request. @@ -2200,30 +2104,25 @@ class ProviderResourceTypeListResult(msrest.serialization.Model): """ _validation = { - 'next_link': {'readonly': True}, + "next_link": {"readonly": True}, } _attribute_map = { - 'value': {'key': 'value', 'type': '[ProviderResourceType]'}, - 'next_link': {'key': 'nextLink', 'type': 'str'}, + "value": {"key": "value", "type": "[ProviderResourceType]"}, + "next_link": {"key": "nextLink", "type": "str"}, } - def __init__( - self, - *, - value: Optional[List["ProviderResourceType"]] = None, - **kwargs - ): + def __init__(self, *, value: Optional[List["_models.ProviderResourceType"]] = None, **kwargs): """ :keyword value: An array of resource types. :paramtype value: list[~azure.mgmt.resource.resources.v2020_10_01.models.ProviderResourceType] """ - super(ProviderResourceTypeListResult, self).__init__(**kwargs) + super().__init__(**kwargs) self.value = value self.next_link = None -class ResourceGroup(msrest.serialization.Model): +class ResourceGroup(_serialization.Model): """Resource group information. Variables are only populated by the server, and will be ignored when sending a request. @@ -2238,37 +2137,37 @@ class ResourceGroup(msrest.serialization.Model): :vartype type: str :ivar properties: The resource group properties. :vartype properties: ~azure.mgmt.resource.resources.v2020_10_01.models.ResourceGroupProperties - :ivar location: Required. The location of the resource group. It cannot be changed after the - resource group has been created. It must be one of the supported Azure locations. + :ivar location: The location of the resource group. It cannot be changed after the resource + group has been created. It must be one of the supported Azure locations. Required. :vartype location: str :ivar managed_by: The ID of the resource that manages this resource group. :vartype managed_by: str - :ivar tags: A set of tags. The tags attached to the resource group. + :ivar tags: The tags attached to the resource group. :vartype tags: dict[str, str] """ _validation = { - 'id': {'readonly': True}, - 'name': {'readonly': True}, - 'type': {'readonly': True}, - 'location': {'required': True}, + "id": {"readonly": True}, + "name": {"readonly": True}, + "type": {"readonly": True}, + "location": {"required": True}, } _attribute_map = { - 'id': {'key': 'id', 'type': 'str'}, - 'name': {'key': 'name', 'type': 'str'}, - 'type': {'key': 'type', 'type': 'str'}, - 'properties': {'key': 'properties', 'type': 'ResourceGroupProperties'}, - 'location': {'key': 'location', 'type': 'str'}, - 'managed_by': {'key': 'managedBy', 'type': 'str'}, - 'tags': {'key': 'tags', 'type': '{str}'}, + "id": {"key": "id", "type": "str"}, + "name": {"key": "name", "type": "str"}, + "type": {"key": "type", "type": "str"}, + "properties": {"key": "properties", "type": "ResourceGroupProperties"}, + "location": {"key": "location", "type": "str"}, + "managed_by": {"key": "managedBy", "type": "str"}, + "tags": {"key": "tags", "type": "{str}"}, } def __init__( self, *, location: str, - properties: Optional["ResourceGroupProperties"] = None, + properties: Optional["_models.ResourceGroupProperties"] = None, managed_by: Optional[str] = None, tags: Optional[Dict[str, str]] = None, **kwargs @@ -2277,15 +2176,15 @@ def __init__( :keyword properties: The resource group properties. :paramtype properties: ~azure.mgmt.resource.resources.v2020_10_01.models.ResourceGroupProperties - :keyword location: Required. The location of the resource group. It cannot be changed after the - resource group has been created. It must be one of the supported Azure locations. + :keyword location: The location of the resource group. It cannot be changed after the resource + group has been created. It must be one of the supported Azure locations. Required. :paramtype location: str :keyword managed_by: The ID of the resource that manages this resource group. :paramtype managed_by: str - :keyword tags: A set of tags. The tags attached to the resource group. + :keyword tags: The tags attached to the resource group. :paramtype tags: dict[str, str] """ - super(ResourceGroup, self).__init__(**kwargs) + super().__init__(**kwargs) self.id = None self.name = None self.type = None @@ -2295,39 +2194,33 @@ def __init__( self.tags = tags -class ResourceGroupExportResult(msrest.serialization.Model): +class ResourceGroupExportResult(_serialization.Model): """Resource group export result. :ivar template: The template content. - :vartype template: any + :vartype template: JSON :ivar error: The template export error. :vartype error: ~azure.mgmt.resource.resources.v2020_10_01.models.ErrorResponse """ _attribute_map = { - 'template': {'key': 'template', 'type': 'object'}, - 'error': {'key': 'error', 'type': 'ErrorResponse'}, + "template": {"key": "template", "type": "object"}, + "error": {"key": "error", "type": "ErrorResponse"}, } - def __init__( - self, - *, - template: Optional[Any] = None, - error: Optional["ErrorResponse"] = None, - **kwargs - ): + def __init__(self, *, template: Optional[JSON] = None, error: Optional["_models.ErrorResponse"] = None, **kwargs): """ :keyword template: The template content. - :paramtype template: any + :paramtype template: JSON :keyword error: The template export error. :paramtype error: ~azure.mgmt.resource.resources.v2020_10_01.models.ErrorResponse """ - super(ResourceGroupExportResult, self).__init__(**kwargs) + super().__init__(**kwargs) self.template = template self.error = error -class ResourceGroupFilter(msrest.serialization.Model): +class ResourceGroupFilter(_serialization.Model): """Resource group filter. :ivar tag_name: The tag name. @@ -2337,29 +2230,23 @@ class ResourceGroupFilter(msrest.serialization.Model): """ _attribute_map = { - 'tag_name': {'key': 'tagName', 'type': 'str'}, - 'tag_value': {'key': 'tagValue', 'type': 'str'}, + "tag_name": {"key": "tagName", "type": "str"}, + "tag_value": {"key": "tagValue", "type": "str"}, } - def __init__( - self, - *, - tag_name: Optional[str] = None, - tag_value: Optional[str] = None, - **kwargs - ): + def __init__(self, *, tag_name: Optional[str] = None, tag_value: Optional[str] = None, **kwargs): """ :keyword tag_name: The tag name. :paramtype tag_name: str :keyword tag_value: The tag value. :paramtype tag_value: str """ - super(ResourceGroupFilter, self).__init__(**kwargs) + super().__init__(**kwargs) self.tag_name = tag_name self.tag_value = tag_value -class ResourceGroupListResult(msrest.serialization.Model): +class ResourceGroupListResult(_serialization.Model): """List of resource groups. Variables are only populated by the server, and will be ignored when sending a request. @@ -2371,30 +2258,25 @@ class ResourceGroupListResult(msrest.serialization.Model): """ _validation = { - 'next_link': {'readonly': True}, + "next_link": {"readonly": True}, } _attribute_map = { - 'value': {'key': 'value', 'type': '[ResourceGroup]'}, - 'next_link': {'key': 'nextLink', 'type': 'str'}, + "value": {"key": "value", "type": "[ResourceGroup]"}, + "next_link": {"key": "nextLink", "type": "str"}, } - def __init__( - self, - *, - value: Optional[List["ResourceGroup"]] = None, - **kwargs - ): + def __init__(self, *, value: Optional[List["_models.ResourceGroup"]] = None, **kwargs): """ :keyword value: An array of resource groups. :paramtype value: list[~azure.mgmt.resource.resources.v2020_10_01.models.ResourceGroup] """ - super(ResourceGroupListResult, self).__init__(**kwargs) + super().__init__(**kwargs) self.value = value self.next_link = None -class ResourceGroupPatchable(msrest.serialization.Model): +class ResourceGroupPatchable(_serialization.Model): """Resource group information. :ivar name: The name of the resource group. @@ -2403,22 +2285,22 @@ class ResourceGroupPatchable(msrest.serialization.Model): :vartype properties: ~azure.mgmt.resource.resources.v2020_10_01.models.ResourceGroupProperties :ivar managed_by: The ID of the resource that manages this resource group. :vartype managed_by: str - :ivar tags: A set of tags. The tags attached to the resource group. + :ivar tags: The tags attached to the resource group. :vartype tags: dict[str, str] """ _attribute_map = { - 'name': {'key': 'name', 'type': 'str'}, - 'properties': {'key': 'properties', 'type': 'ResourceGroupProperties'}, - 'managed_by': {'key': 'managedBy', 'type': 'str'}, - 'tags': {'key': 'tags', 'type': '{str}'}, + "name": {"key": "name", "type": "str"}, + "properties": {"key": "properties", "type": "ResourceGroupProperties"}, + "managed_by": {"key": "managedBy", "type": "str"}, + "tags": {"key": "tags", "type": "{str}"}, } def __init__( self, *, name: Optional[str] = None, - properties: Optional["ResourceGroupProperties"] = None, + properties: Optional["_models.ResourceGroupProperties"] = None, managed_by: Optional[str] = None, tags: Optional[Dict[str, str]] = None, **kwargs @@ -2431,17 +2313,17 @@ def __init__( ~azure.mgmt.resource.resources.v2020_10_01.models.ResourceGroupProperties :keyword managed_by: The ID of the resource that manages this resource group. :paramtype managed_by: str - :keyword tags: A set of tags. The tags attached to the resource group. + :keyword tags: The tags attached to the resource group. :paramtype tags: dict[str, str] """ - super(ResourceGroupPatchable, self).__init__(**kwargs) + super().__init__(**kwargs) self.name = name self.properties = properties self.managed_by = managed_by self.tags = tags -class ResourceGroupProperties(msrest.serialization.Model): +class ResourceGroupProperties(_serialization.Model): """The resource group properties. Variables are only populated by the server, and will be ignored when sending a request. @@ -2451,24 +2333,20 @@ class ResourceGroupProperties(msrest.serialization.Model): """ _validation = { - 'provisioning_state': {'readonly': True}, + "provisioning_state": {"readonly": True}, } _attribute_map = { - 'provisioning_state': {'key': 'provisioningState', 'type': 'str'}, + "provisioning_state": {"key": "provisioningState", "type": "str"}, } - def __init__( - self, - **kwargs - ): - """ - """ - super(ResourceGroupProperties, self).__init__(**kwargs) + def __init__(self, **kwargs): + """ """ + super().__init__(**kwargs) self.provisioning_state = None -class ResourceListResult(msrest.serialization.Model): +class ResourceListResult(_serialization.Model): """List of resource groups. Variables are only populated by the server, and will be ignored when sending a request. @@ -2480,31 +2358,26 @@ class ResourceListResult(msrest.serialization.Model): """ _validation = { - 'next_link': {'readonly': True}, + "next_link": {"readonly": True}, } _attribute_map = { - 'value': {'key': 'value', 'type': '[GenericResourceExpanded]'}, - 'next_link': {'key': 'nextLink', 'type': 'str'}, + "value": {"key": "value", "type": "[GenericResourceExpanded]"}, + "next_link": {"key": "nextLink", "type": "str"}, } - def __init__( - self, - *, - value: Optional[List["GenericResourceExpanded"]] = None, - **kwargs - ): + def __init__(self, *, value: Optional[List["_models.GenericResourceExpanded"]] = None, **kwargs): """ :keyword value: An array of resources. :paramtype value: list[~azure.mgmt.resource.resources.v2020_10_01.models.GenericResourceExpanded] """ - super(ResourceListResult, self).__init__(**kwargs) + super().__init__(**kwargs) self.value = value self.next_link = None -class ResourceProviderOperationDisplayProperties(msrest.serialization.Model): +class ResourceProviderOperationDisplayProperties(_serialization.Model): """Resource provider operation's display properties. :ivar publisher: Operation description. @@ -2520,11 +2393,11 @@ class ResourceProviderOperationDisplayProperties(msrest.serialization.Model): """ _attribute_map = { - 'publisher': {'key': 'publisher', 'type': 'str'}, - 'provider': {'key': 'provider', 'type': 'str'}, - 'resource': {'key': 'resource', 'type': 'str'}, - 'operation': {'key': 'operation', 'type': 'str'}, - 'description': {'key': 'description', 'type': 'str'}, + "publisher": {"key": "publisher", "type": "str"}, + "provider": {"key": "provider", "type": "str"}, + "resource": {"key": "resource", "type": "str"}, + "operation": {"key": "operation", "type": "str"}, + "description": {"key": "description", "type": "str"}, } def __init__( @@ -2549,7 +2422,7 @@ def __init__( :keyword description: Operation description. :paramtype description: str """ - super(ResourceProviderOperationDisplayProperties, self).__init__(**kwargs) + super().__init__(**kwargs) self.publisher = publisher self.provider = provider self.resource = resource @@ -2557,7 +2430,7 @@ def __init__( self.description = description -class ResourceReference(msrest.serialization.Model): +class ResourceReference(_serialization.Model): """The resource Id model. Variables are only populated by the server, and will be ignored when sending a request. @@ -2567,24 +2440,20 @@ class ResourceReference(msrest.serialization.Model): """ _validation = { - 'id': {'readonly': True}, + "id": {"readonly": True}, } _attribute_map = { - 'id': {'key': 'id', 'type': 'str'}, + "id": {"key": "id", "type": "str"}, } - def __init__( - self, - **kwargs - ): - """ - """ - super(ResourceReference, self).__init__(**kwargs) + def __init__(self, **kwargs): + """ """ + super().__init__(**kwargs) self.id = None -class ResourcesMoveInfo(msrest.serialization.Model): +class ResourcesMoveInfo(_serialization.Model): """Parameters of move resources. :ivar resources: The IDs of the resources. @@ -2594,116 +2463,104 @@ class ResourcesMoveInfo(msrest.serialization.Model): """ _attribute_map = { - 'resources': {'key': 'resources', 'type': '[str]'}, - 'target_resource_group': {'key': 'targetResourceGroup', 'type': 'str'}, + "resources": {"key": "resources", "type": "[str]"}, + "target_resource_group": {"key": "targetResourceGroup", "type": "str"}, } - def __init__( - self, - *, - resources: Optional[List[str]] = None, - target_resource_group: Optional[str] = None, - **kwargs - ): + def __init__(self, *, resources: Optional[List[str]] = None, target_resource_group: Optional[str] = None, **kwargs): """ :keyword resources: The IDs of the resources. :paramtype resources: list[str] :keyword target_resource_group: The target resource group. :paramtype target_resource_group: str """ - super(ResourcesMoveInfo, self).__init__(**kwargs) + super().__init__(**kwargs) self.resources = resources self.target_resource_group = target_resource_group -class ScopedDeployment(msrest.serialization.Model): +class ScopedDeployment(_serialization.Model): """Deployment operation parameters. All required parameters must be populated in order to send to Azure. - :ivar location: Required. The location to store the deployment data. + :ivar location: The location to store the deployment data. Required. :vartype location: str - :ivar properties: Required. The deployment properties. + :ivar properties: The deployment properties. Required. :vartype properties: ~azure.mgmt.resource.resources.v2020_10_01.models.DeploymentProperties - :ivar tags: A set of tags. Deployment tags. + :ivar tags: Deployment tags. :vartype tags: dict[str, str] """ _validation = { - 'location': {'required': True}, - 'properties': {'required': True}, + "location": {"required": True}, + "properties": {"required": True}, } _attribute_map = { - 'location': {'key': 'location', 'type': 'str'}, - 'properties': {'key': 'properties', 'type': 'DeploymentProperties'}, - 'tags': {'key': 'tags', 'type': '{str}'}, + "location": {"key": "location", "type": "str"}, + "properties": {"key": "properties", "type": "DeploymentProperties"}, + "tags": {"key": "tags", "type": "{str}"}, } def __init__( self, *, location: str, - properties: "DeploymentProperties", + properties: "_models.DeploymentProperties", tags: Optional[Dict[str, str]] = None, **kwargs ): """ - :keyword location: Required. The location to store the deployment data. + :keyword location: The location to store the deployment data. Required. :paramtype location: str - :keyword properties: Required. The deployment properties. + :keyword properties: The deployment properties. Required. :paramtype properties: ~azure.mgmt.resource.resources.v2020_10_01.models.DeploymentProperties - :keyword tags: A set of tags. Deployment tags. + :keyword tags: Deployment tags. :paramtype tags: dict[str, str] """ - super(ScopedDeployment, self).__init__(**kwargs) + super().__init__(**kwargs) self.location = location self.properties = properties self.tags = tags -class ScopedDeploymentWhatIf(msrest.serialization.Model): +class ScopedDeploymentWhatIf(_serialization.Model): """Deployment What-if operation parameters. All required parameters must be populated in order to send to Azure. - :ivar location: Required. The location to store the deployment data. + :ivar location: The location to store the deployment data. Required. :vartype location: str - :ivar properties: Required. The deployment properties. + :ivar properties: The deployment properties. Required. :vartype properties: ~azure.mgmt.resource.resources.v2020_10_01.models.DeploymentWhatIfProperties """ _validation = { - 'location': {'required': True}, - 'properties': {'required': True}, + "location": {"required": True}, + "properties": {"required": True}, } _attribute_map = { - 'location': {'key': 'location', 'type': 'str'}, - 'properties': {'key': 'properties', 'type': 'DeploymentWhatIfProperties'}, + "location": {"key": "location", "type": "str"}, + "properties": {"key": "properties", "type": "DeploymentWhatIfProperties"}, } - def __init__( - self, - *, - location: str, - properties: "DeploymentWhatIfProperties", - **kwargs - ): + def __init__(self, *, location: str, properties: "_models.DeploymentWhatIfProperties", **kwargs): """ - :keyword location: Required. The location to store the deployment data. + :keyword location: The location to store the deployment data. Required. :paramtype location: str - :keyword properties: Required. The deployment properties. + :keyword properties: The deployment properties. Required. :paramtype properties: ~azure.mgmt.resource.resources.v2020_10_01.models.DeploymentWhatIfProperties """ - super(ScopedDeploymentWhatIf, self).__init__(**kwargs) + super().__init__(**kwargs) self.location = location self.properties = properties -class Sku(msrest.serialization.Model): +class Sku(_serialization.Model): """SKU for the resource. :ivar name: The SKU name. @@ -2721,12 +2578,12 @@ class Sku(msrest.serialization.Model): """ _attribute_map = { - 'name': {'key': 'name', 'type': 'str'}, - 'tier': {'key': 'tier', 'type': 'str'}, - 'size': {'key': 'size', 'type': 'str'}, - 'family': {'key': 'family', 'type': 'str'}, - 'model': {'key': 'model', 'type': 'str'}, - 'capacity': {'key': 'capacity', 'type': 'int'}, + "name": {"key": "name", "type": "str"}, + "tier": {"key": "tier", "type": "str"}, + "size": {"key": "size", "type": "str"}, + "family": {"key": "family", "type": "str"}, + "model": {"key": "model", "type": "str"}, + "capacity": {"key": "capacity", "type": "int"}, } def __init__( @@ -2754,7 +2611,7 @@ def __init__( :keyword capacity: The SKU capacity. :paramtype capacity: int """ - super(Sku, self).__init__(**kwargs) + super().__init__(**kwargs) self.name = name self.tier = tier self.size = size @@ -2763,7 +2620,7 @@ def __init__( self.capacity = capacity -class StatusMessage(msrest.serialization.Model): +class StatusMessage(_serialization.Model): """Operation status message object. :ivar status: Status of the deployment operation. @@ -2773,29 +2630,23 @@ class StatusMessage(msrest.serialization.Model): """ _attribute_map = { - 'status': {'key': 'status', 'type': 'str'}, - 'error': {'key': 'error', 'type': 'ErrorResponse'}, + "status": {"key": "status", "type": "str"}, + "error": {"key": "error", "type": "ErrorResponse"}, } - def __init__( - self, - *, - status: Optional[str] = None, - error: Optional["ErrorResponse"] = None, - **kwargs - ): + def __init__(self, *, status: Optional[str] = None, error: Optional["_models.ErrorResponse"] = None, **kwargs): """ :keyword status: Status of the deployment operation. :paramtype status: str :keyword error: The error reported by the operation. :paramtype error: ~azure.mgmt.resource.resources.v2020_10_01.models.ErrorResponse """ - super(StatusMessage, self).__init__(**kwargs) + super().__init__(**kwargs) self.status = status self.error = error -class SubResource(msrest.serialization.Model): +class SubResource(_serialization.Model): """Sub-resource. :ivar id: Resource ID. @@ -2803,24 +2654,19 @@ class SubResource(msrest.serialization.Model): """ _attribute_map = { - 'id': {'key': 'id', 'type': 'str'}, + "id": {"key": "id", "type": "str"}, } - def __init__( - self, - *, - id: Optional[str] = None, - **kwargs - ): + def __init__(self, *, id: Optional[str] = None, **kwargs): # pylint: disable=redefined-builtin """ :keyword id: Resource ID. :paramtype id: str """ - super(SubResource, self).__init__(**kwargs) + super().__init__(**kwargs) self.id = id -class TagCount(msrest.serialization.Model): +class TagCount(_serialization.Model): """Tag count. :ivar type: Type of count. @@ -2830,29 +2676,23 @@ class TagCount(msrest.serialization.Model): """ _attribute_map = { - 'type': {'key': 'type', 'type': 'str'}, - 'value': {'key': 'value', 'type': 'int'}, + "type": {"key": "type", "type": "str"}, + "value": {"key": "value", "type": "int"}, } - def __init__( - self, - *, - type: Optional[str] = None, - value: Optional[int] = None, - **kwargs - ): + def __init__(self, *, type: Optional[str] = None, value: Optional[int] = None, **kwargs): """ :keyword type: Type of count. :paramtype type: str :keyword value: Value of count. :paramtype value: int """ - super(TagCount, self).__init__(**kwargs) + super().__init__(**kwargs) self.type = type self.value = value -class TagDetails(msrest.serialization.Model): +class TagDetails(_serialization.Model): """Tag details. Variables are only populated by the server, and will be ignored when sending a request. @@ -2869,22 +2709,22 @@ class TagDetails(msrest.serialization.Model): """ _validation = { - 'id': {'readonly': True}, + "id": {"readonly": True}, } _attribute_map = { - 'id': {'key': 'id', 'type': 'str'}, - 'tag_name': {'key': 'tagName', 'type': 'str'}, - 'count': {'key': 'count', 'type': 'TagCount'}, - 'values': {'key': 'values', 'type': '[TagValue]'}, + "id": {"key": "id", "type": "str"}, + "tag_name": {"key": "tagName", "type": "str"}, + "count": {"key": "count", "type": "TagCount"}, + "values": {"key": "values", "type": "[TagValue]"}, } def __init__( self, *, tag_name: Optional[str] = None, - count: Optional["TagCount"] = None, - values: Optional[List["TagValue"]] = None, + count: Optional["_models.TagCount"] = None, + values: Optional[List["_models.TagValue"]] = None, **kwargs ): """ @@ -2896,39 +2736,34 @@ def __init__( :keyword values: The list of tag values. :paramtype values: list[~azure.mgmt.resource.resources.v2020_10_01.models.TagValue] """ - super(TagDetails, self).__init__(**kwargs) + super().__init__(**kwargs) self.id = None self.tag_name = tag_name self.count = count self.values = values -class Tags(msrest.serialization.Model): +class Tags(_serialization.Model): """A dictionary of name and value pairs. - :ivar tags: A set of tags. Dictionary of :code:``. + :ivar tags: Dictionary of :code:``. :vartype tags: dict[str, str] """ _attribute_map = { - 'tags': {'key': 'tags', 'type': '{str}'}, + "tags": {"key": "tags", "type": "{str}"}, } - def __init__( - self, - *, - tags: Optional[Dict[str, str]] = None, - **kwargs - ): + def __init__(self, *, tags: Optional[Dict[str, str]] = None, **kwargs): """ - :keyword tags: A set of tags. Dictionary of :code:``. + :keyword tags: Dictionary of :code:``. :paramtype tags: dict[str, str] """ - super(Tags, self).__init__(**kwargs) + super().__init__(**kwargs) self.tags = tags -class TagsListResult(msrest.serialization.Model): +class TagsListResult(_serialization.Model): """List of subscription tags. Variables are only populated by the server, and will be ignored when sending a request. @@ -2940,65 +2775,60 @@ class TagsListResult(msrest.serialization.Model): """ _validation = { - 'next_link': {'readonly': True}, + "next_link": {"readonly": True}, } _attribute_map = { - 'value': {'key': 'value', 'type': '[TagDetails]'}, - 'next_link': {'key': 'nextLink', 'type': 'str'}, + "value": {"key": "value", "type": "[TagDetails]"}, + "next_link": {"key": "nextLink", "type": "str"}, } - def __init__( - self, - *, - value: Optional[List["TagDetails"]] = None, - **kwargs - ): + def __init__(self, *, value: Optional[List["_models.TagDetails"]] = None, **kwargs): """ :keyword value: An array of tags. :paramtype value: list[~azure.mgmt.resource.resources.v2020_10_01.models.TagDetails] """ - super(TagsListResult, self).__init__(**kwargs) + super().__init__(**kwargs) self.value = value self.next_link = None -class TagsPatchResource(msrest.serialization.Model): +class TagsPatchResource(_serialization.Model): """Wrapper resource for tags patch API request only. - :ivar operation: The operation type for the patch API. Possible values include: "Replace", - "Merge", "Delete". + :ivar operation: The operation type for the patch API. Known values are: "Replace", "Merge", + and "Delete". :vartype operation: str or ~azure.mgmt.resource.resources.v2020_10_01.models.TagsPatchOperation :ivar properties: The set of tags. :vartype properties: ~azure.mgmt.resource.resources.v2020_10_01.models.Tags """ _attribute_map = { - 'operation': {'key': 'operation', 'type': 'str'}, - 'properties': {'key': 'properties', 'type': 'Tags'}, + "operation": {"key": "operation", "type": "str"}, + "properties": {"key": "properties", "type": "Tags"}, } def __init__( self, *, - operation: Optional[Union[str, "TagsPatchOperation"]] = None, - properties: Optional["Tags"] = None, + operation: Optional[Union[str, "_models.TagsPatchOperation"]] = None, + properties: Optional["_models.Tags"] = None, **kwargs ): """ - :keyword operation: The operation type for the patch API. Possible values include: "Replace", - "Merge", "Delete". + :keyword operation: The operation type for the patch API. Known values are: "Replace", "Merge", + and "Delete". :paramtype operation: str or ~azure.mgmt.resource.resources.v2020_10_01.models.TagsPatchOperation :keyword properties: The set of tags. :paramtype properties: ~azure.mgmt.resource.resources.v2020_10_01.models.Tags """ - super(TagsPatchResource, self).__init__(**kwargs) + super().__init__(**kwargs) self.operation = operation self.properties = properties -class TagsResource(msrest.serialization.Model): +class TagsResource(_serialization.Model): """Wrapper resource for tags API requests and responses. Variables are only populated by the server, and will be ignored when sending a request. @@ -3011,42 +2841,37 @@ class TagsResource(msrest.serialization.Model): :vartype name: str :ivar type: The type of the tags wrapper resource. :vartype type: str - :ivar properties: Required. The set of tags. + :ivar properties: The set of tags. Required. :vartype properties: ~azure.mgmt.resource.resources.v2020_10_01.models.Tags """ _validation = { - 'id': {'readonly': True}, - 'name': {'readonly': True}, - 'type': {'readonly': True}, - 'properties': {'required': True}, + "id": {"readonly": True}, + "name": {"readonly": True}, + "type": {"readonly": True}, + "properties": {"required": True}, } _attribute_map = { - 'id': {'key': 'id', 'type': 'str'}, - 'name': {'key': 'name', 'type': 'str'}, - 'type': {'key': 'type', 'type': 'str'}, - 'properties': {'key': 'properties', 'type': 'Tags'}, + "id": {"key": "id", "type": "str"}, + "name": {"key": "name", "type": "str"}, + "type": {"key": "type", "type": "str"}, + "properties": {"key": "properties", "type": "Tags"}, } - def __init__( - self, - *, - properties: "Tags", - **kwargs - ): + def __init__(self, *, properties: "_models.Tags", **kwargs): """ - :keyword properties: Required. The set of tags. + :keyword properties: The set of tags. Required. :paramtype properties: ~azure.mgmt.resource.resources.v2020_10_01.models.Tags """ - super(TagsResource, self).__init__(**kwargs) + super().__init__(**kwargs) self.id = None self.name = None self.type = None self.properties = properties -class TagValue(msrest.serialization.Model): +class TagValue(_serialization.Model): """Tag information. Variables are only populated by the server, and will be ignored when sending a request. @@ -3060,35 +2885,29 @@ class TagValue(msrest.serialization.Model): """ _validation = { - 'id': {'readonly': True}, + "id": {"readonly": True}, } _attribute_map = { - 'id': {'key': 'id', 'type': 'str'}, - 'tag_value': {'key': 'tagValue', 'type': 'str'}, - 'count': {'key': 'count', 'type': 'TagCount'}, + "id": {"key": "id", "type": "str"}, + "tag_value": {"key": "tagValue", "type": "str"}, + "count": {"key": "count", "type": "TagCount"}, } - def __init__( - self, - *, - tag_value: Optional[str] = None, - count: Optional["TagCount"] = None, - **kwargs - ): + def __init__(self, *, tag_value: Optional[str] = None, count: Optional["_models.TagCount"] = None, **kwargs): """ :keyword tag_value: The tag value. :paramtype tag_value: str :keyword count: The tag value count. :paramtype count: ~azure.mgmt.resource.resources.v2020_10_01.models.TagCount """ - super(TagValue, self).__init__(**kwargs) + super().__init__(**kwargs) self.id = None self.tag_value = tag_value self.count = count -class TargetResource(msrest.serialization.Model): +class TargetResource(_serialization.Model): """Target resource. :ivar id: The ID of the resource. @@ -3100,15 +2919,15 @@ class TargetResource(msrest.serialization.Model): """ _attribute_map = { - 'id': {'key': 'id', 'type': 'str'}, - 'resource_name': {'key': 'resourceName', 'type': 'str'}, - 'resource_type': {'key': 'resourceType', 'type': 'str'}, + "id": {"key": "id", "type": "str"}, + "resource_name": {"key": "resourceName", "type": "str"}, + "resource_type": {"key": "resourceType", "type": "str"}, } def __init__( self, *, - id: Optional[str] = None, + id: Optional[str] = None, # pylint: disable=redefined-builtin resource_name: Optional[str] = None, resource_type: Optional[str] = None, **kwargs @@ -3121,13 +2940,13 @@ def __init__( :keyword resource_type: The type of the resource. :paramtype resource_type: str """ - super(TargetResource, self).__init__(**kwargs) + super().__init__(**kwargs) self.id = id self.resource_name = resource_name self.resource_type = resource_type -class TemplateHashResult(msrest.serialization.Model): +class TemplateHashResult(_serialization.Model): """Result of the request to calculate template hash. It contains a string of minified template and its hash. :ivar minified_template: The minified template string. @@ -3137,29 +2956,23 @@ class TemplateHashResult(msrest.serialization.Model): """ _attribute_map = { - 'minified_template': {'key': 'minifiedTemplate', 'type': 'str'}, - 'template_hash': {'key': 'templateHash', 'type': 'str'}, + "minified_template": {"key": "minifiedTemplate", "type": "str"}, + "template_hash": {"key": "templateHash", "type": "str"}, } - def __init__( - self, - *, - minified_template: Optional[str] = None, - template_hash: Optional[str] = None, - **kwargs - ): + def __init__(self, *, minified_template: Optional[str] = None, template_hash: Optional[str] = None, **kwargs): """ :keyword minified_template: The minified template string. :paramtype minified_template: str :keyword template_hash: The template hash. :paramtype template_hash: str """ - super(TemplateHashResult, self).__init__(**kwargs) + super().__init__(**kwargs) self.minified_template = minified_template self.template_hash = template_hash -class TemplateLink(msrest.serialization.Model): +class TemplateLink(_serialization.Model): """Entity representing the reference to the template. :ivar uri: The URI of the template to deploy. Use either the uri or id property, but not both. @@ -3179,18 +2992,18 @@ class TemplateLink(msrest.serialization.Model): """ _attribute_map = { - 'uri': {'key': 'uri', 'type': 'str'}, - 'id': {'key': 'id', 'type': 'str'}, - 'relative_path': {'key': 'relativePath', 'type': 'str'}, - 'content_version': {'key': 'contentVersion', 'type': 'str'}, - 'query_string': {'key': 'queryString', 'type': 'str'}, + "uri": {"key": "uri", "type": "str"}, + "id": {"key": "id", "type": "str"}, + "relative_path": {"key": "relativePath", "type": "str"}, + "content_version": {"key": "contentVersion", "type": "str"}, + "query_string": {"key": "queryString", "type": "str"}, } def __init__( self, *, uri: Optional[str] = None, - id: Optional[str] = None, + id: Optional[str] = None, # pylint: disable=redefined-builtin relative_path: Optional[str] = None, content_version: Optional[str] = None, query_string: Optional[str] = None, @@ -3214,7 +3027,7 @@ def __init__( templateLink URI. :paramtype query_string: str """ - super(TemplateLink, self).__init__(**kwargs) + super().__init__(**kwargs) self.uri = uri self.id = id self.relative_path = relative_path @@ -3222,63 +3035,63 @@ def __init__( self.query_string = query_string -class WhatIfChange(msrest.serialization.Model): +class WhatIfChange(_serialization.Model): """Information about a single resource change predicted by What-If operation. All required parameters must be populated in order to send to Azure. - :ivar resource_id: Required. Resource ID. + :ivar resource_id: Resource ID. Required. :vartype resource_id: str - :ivar change_type: Required. Type of change that will be made to the resource when the - deployment is executed. Possible values include: "Create", "Delete", "Ignore", "Deploy", - "NoChange", "Modify". + :ivar change_type: Type of change that will be made to the resource when the deployment is + executed. Required. Known values are: "Create", "Delete", "Ignore", "Deploy", "NoChange", and + "Modify". :vartype change_type: str or ~azure.mgmt.resource.resources.v2020_10_01.models.ChangeType :ivar before: The snapshot of the resource before the deployment is executed. - :vartype before: any + :vartype before: JSON :ivar after: The predicted snapshot of the resource after the deployment is executed. - :vartype after: any + :vartype after: JSON :ivar delta: The predicted changes to resource properties. :vartype delta: list[~azure.mgmt.resource.resources.v2020_10_01.models.WhatIfPropertyChange] """ _validation = { - 'resource_id': {'required': True}, - 'change_type': {'required': True}, + "resource_id": {"required": True}, + "change_type": {"required": True}, } _attribute_map = { - 'resource_id': {'key': 'resourceId', 'type': 'str'}, - 'change_type': {'key': 'changeType', 'type': 'str'}, - 'before': {'key': 'before', 'type': 'object'}, - 'after': {'key': 'after', 'type': 'object'}, - 'delta': {'key': 'delta', 'type': '[WhatIfPropertyChange]'}, + "resource_id": {"key": "resourceId", "type": "str"}, + "change_type": {"key": "changeType", "type": "str"}, + "before": {"key": "before", "type": "object"}, + "after": {"key": "after", "type": "object"}, + "delta": {"key": "delta", "type": "[WhatIfPropertyChange]"}, } def __init__( self, *, resource_id: str, - change_type: Union[str, "ChangeType"], - before: Optional[Any] = None, - after: Optional[Any] = None, - delta: Optional[List["WhatIfPropertyChange"]] = None, + change_type: Union[str, "_models.ChangeType"], + before: Optional[JSON] = None, + after: Optional[JSON] = None, + delta: Optional[List["_models.WhatIfPropertyChange"]] = None, **kwargs ): """ - :keyword resource_id: Required. Resource ID. + :keyword resource_id: Resource ID. Required. :paramtype resource_id: str - :keyword change_type: Required. Type of change that will be made to the resource when the - deployment is executed. Possible values include: "Create", "Delete", "Ignore", "Deploy", - "NoChange", "Modify". + :keyword change_type: Type of change that will be made to the resource when the deployment is + executed. Required. Known values are: "Create", "Delete", "Ignore", "Deploy", "NoChange", and + "Modify". :paramtype change_type: str or ~azure.mgmt.resource.resources.v2020_10_01.models.ChangeType :keyword before: The snapshot of the resource before the deployment is executed. - :paramtype before: any + :paramtype before: JSON :keyword after: The predicted snapshot of the resource after the deployment is executed. - :paramtype after: any + :paramtype after: JSON :keyword delta: The predicted changes to resource properties. :paramtype delta: list[~azure.mgmt.resource.resources.v2020_10_01.models.WhatIfPropertyChange] """ - super(WhatIfChange, self).__init__(**kwargs) + super().__init__(**kwargs) self.resource_id = resource_id self.change_type = change_type self.before = before @@ -3286,7 +3099,7 @@ def __init__( self.delta = delta -class WhatIfOperationResult(msrest.serialization.Model): +class WhatIfOperationResult(_serialization.Model): """Result of the What-If operation. Contains a list of predicted changes and a URL link to get to the next set of results. :ivar status: Status of the What-If operation. @@ -3298,17 +3111,17 @@ class WhatIfOperationResult(msrest.serialization.Model): """ _attribute_map = { - 'status': {'key': 'status', 'type': 'str'}, - 'error': {'key': 'error', 'type': 'ErrorResponse'}, - 'changes': {'key': 'properties.changes', 'type': '[WhatIfChange]'}, + "status": {"key": "status", "type": "str"}, + "error": {"key": "error", "type": "ErrorResponse"}, + "changes": {"key": "properties.changes", "type": "[WhatIfChange]"}, } def __init__( self, *, status: Optional[str] = None, - error: Optional["ErrorResponse"] = None, - changes: Optional[List["WhatIfChange"]] = None, + error: Optional["_models.ErrorResponse"] = None, + changes: Optional[List["_models.WhatIfChange"]] = None, **kwargs ): """ @@ -3319,70 +3132,70 @@ def __init__( :keyword changes: List of resource changes predicted by What-If operation. :paramtype changes: list[~azure.mgmt.resource.resources.v2020_10_01.models.WhatIfChange] """ - super(WhatIfOperationResult, self).__init__(**kwargs) + super().__init__(**kwargs) self.status = status self.error = error self.changes = changes -class WhatIfPropertyChange(msrest.serialization.Model): +class WhatIfPropertyChange(_serialization.Model): """The predicted change to the resource property. All required parameters must be populated in order to send to Azure. - :ivar path: Required. The path of the property. + :ivar path: The path of the property. Required. :vartype path: str - :ivar property_change_type: Required. The type of property change. Possible values include: - "Create", "Delete", "Modify", "Array". + :ivar property_change_type: The type of property change. Required. Known values are: "Create", + "Delete", "Modify", and "Array". :vartype property_change_type: str or ~azure.mgmt.resource.resources.v2020_10_01.models.PropertyChangeType :ivar before: The value of the property before the deployment is executed. - :vartype before: any + :vartype before: JSON :ivar after: The value of the property after the deployment is executed. - :vartype after: any + :vartype after: JSON :ivar children: Nested property changes. :vartype children: list[~azure.mgmt.resource.resources.v2020_10_01.models.WhatIfPropertyChange] """ _validation = { - 'path': {'required': True}, - 'property_change_type': {'required': True}, + "path": {"required": True}, + "property_change_type": {"required": True}, } _attribute_map = { - 'path': {'key': 'path', 'type': 'str'}, - 'property_change_type': {'key': 'propertyChangeType', 'type': 'str'}, - 'before': {'key': 'before', 'type': 'object'}, - 'after': {'key': 'after', 'type': 'object'}, - 'children': {'key': 'children', 'type': '[WhatIfPropertyChange]'}, + "path": {"key": "path", "type": "str"}, + "property_change_type": {"key": "propertyChangeType", "type": "str"}, + "before": {"key": "before", "type": "object"}, + "after": {"key": "after", "type": "object"}, + "children": {"key": "children", "type": "[WhatIfPropertyChange]"}, } def __init__( self, *, path: str, - property_change_type: Union[str, "PropertyChangeType"], - before: Optional[Any] = None, - after: Optional[Any] = None, - children: Optional[List["WhatIfPropertyChange"]] = None, + property_change_type: Union[str, "_models.PropertyChangeType"], + before: Optional[JSON] = None, + after: Optional[JSON] = None, + children: Optional[List["_models.WhatIfPropertyChange"]] = None, **kwargs ): """ - :keyword path: Required. The path of the property. + :keyword path: The path of the property. Required. :paramtype path: str - :keyword property_change_type: Required. The type of property change. Possible values include: - "Create", "Delete", "Modify", "Array". + :keyword property_change_type: The type of property change. Required. Known values are: + "Create", "Delete", "Modify", and "Array". :paramtype property_change_type: str or ~azure.mgmt.resource.resources.v2020_10_01.models.PropertyChangeType :keyword before: The value of the property before the deployment is executed. - :paramtype before: any + :paramtype before: JSON :keyword after: The value of the property after the deployment is executed. - :paramtype after: any + :paramtype after: JSON :keyword children: Nested property changes. :paramtype children: list[~azure.mgmt.resource.resources.v2020_10_01.models.WhatIfPropertyChange] """ - super(WhatIfPropertyChange, self).__init__(**kwargs) + super().__init__(**kwargs) self.path = path self.property_change_type = property_change_type self.before = before @@ -3390,7 +3203,7 @@ def __init__( self.children = children -class ZoneMapping(msrest.serialization.Model): +class ZoneMapping(_serialization.Model): """ZoneMapping. :ivar location: The location of the zone mapping. @@ -3400,23 +3213,17 @@ class ZoneMapping(msrest.serialization.Model): """ _attribute_map = { - 'location': {'key': 'location', 'type': 'str'}, - 'zones': {'key': 'zones', 'type': '[str]'}, + "location": {"key": "location", "type": "str"}, + "zones": {"key": "zones", "type": "[str]"}, } - def __init__( - self, - *, - location: Optional[str] = None, - zones: Optional[List[str]] = None, - **kwargs - ): + def __init__(self, *, location: Optional[str] = None, zones: Optional[List[str]] = None, **kwargs): """ :keyword location: The location of the zone mapping. :paramtype location: str :keyword zones: :paramtype zones: list[str] """ - super(ZoneMapping, self).__init__(**kwargs) + super().__init__(**kwargs) self.location = location self.zones = zones diff --git a/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/resources/v2020_10_01/models/_patch.py b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/resources/v2020_10_01/models/_patch.py new file mode 100644 index 0000000000000..f7dd32510333d --- /dev/null +++ b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/resources/v2020_10_01/models/_patch.py @@ -0,0 +1,20 @@ +# ------------------------------------ +# Copyright (c) Microsoft Corporation. +# Licensed under the MIT License. +# ------------------------------------ +"""Customize generated code here. + +Follow our quickstart for examples: https://aka.ms/azsdk/python/dpcodegen/python/customize +""" +from typing import List + +__all__: List[str] = [] # Add all objects you want publicly available to users at this package level + + +def patch_sdk(): + """Do not remove from this file. + + `patch_sdk` is a last resort escape hatch that allows you to do customizations + you can't accomplish using the techniques described in + https://aka.ms/azsdk/python/dpcodegen/python/customize + """ diff --git a/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/resources/v2020_10_01/models/_resource_management_client_enums.py b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/resources/v2020_10_01/models/_resource_management_client_enums.py index 795ece2e655ea..aa81cf76c98a6 100644 --- a/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/resources/v2020_10_01/models/_resource_management_client_enums.py +++ b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/resources/v2020_10_01/models/_resource_management_client_enums.py @@ -7,22 +7,20 @@ # -------------------------------------------------------------------------- from enum import Enum -from six import with_metaclass from azure.core import CaseInsensitiveEnumMeta -class AliasPathAttributes(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): - """The attributes of the token that the alias path is referring to. - """ +class AliasPathAttributes(str, Enum, metaclass=CaseInsensitiveEnumMeta): + """The attributes of the token that the alias path is referring to.""" #: The token that the alias path is referring to has no attributes. NONE = "None" #: The token that the alias path is referring to is modifiable by policies with 'modify' effect. MODIFIABLE = "Modifiable" -class AliasPathTokenType(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): - """The type of the token that the alias path is referring to. - """ + +class AliasPathTokenType(str, Enum, metaclass=CaseInsensitiveEnumMeta): + """The type of the token that the alias path is referring to.""" #: The token type is not specified. NOT_SPECIFIED = "NotSpecified" @@ -41,18 +39,18 @@ class AliasPathTokenType(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): #: The token type is boolean. BOOLEAN = "Boolean" -class AliasPatternType(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): - """The type of alias pattern - """ + +class AliasPatternType(str, Enum, metaclass=CaseInsensitiveEnumMeta): + """The type of alias pattern.""" #: NotSpecified is not allowed. NOT_SPECIFIED = "NotSpecified" #: Extract is the only allowed value. EXTRACT = "Extract" -class AliasType(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): - """The type of the alias. - """ + +class AliasType(str, Enum, metaclass=CaseInsensitiveEnumMeta): + """The type of the alias.""" #: Alias type is unknown (same as not providing alias type). NOT_SPECIFIED = "NotSpecified" @@ -61,9 +59,9 @@ class AliasType(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): #: Alias value is secret. MASK = "Mask" -class ChangeType(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): - """Type of change that will be made to the resource when the deployment is executed. - """ + +class ChangeType(str, Enum, metaclass=CaseInsensitiveEnumMeta): + """Type of change that will be made to the resource when the deployment is executed.""" #: The resource does not exist in the current state but is present in the desired state. The #: resource will be created when the deployment is executed. @@ -84,7 +82,8 @@ class ChangeType(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): #: deployment is executed. The properties of the resource will change. MODIFY = "Modify" -class DeploymentMode(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): + +class DeploymentMode(str, Enum, metaclass=CaseInsensitiveEnumMeta): """The mode that is used to deploy resources. This value can be either Incremental or Complete. In Incremental mode, resources are deployed without deleting existing resources that are not included in the template. In Complete mode, resources are deployed and existing resources in @@ -95,7 +94,8 @@ class DeploymentMode(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): INCREMENTAL = "Incremental" COMPLETE = "Complete" -class ExpressionEvaluationOptionsScopeType(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): + +class ExpressionEvaluationOptionsScopeType(str, Enum, metaclass=CaseInsensitiveEnumMeta): """The scope to be used for evaluation of parameters, variables and functions in a nested template. """ @@ -104,7 +104,8 @@ class ExpressionEvaluationOptionsScopeType(with_metaclass(CaseInsensitiveEnumMet OUTER = "Outer" INNER = "Inner" -class OnErrorDeploymentType(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): + +class OnErrorDeploymentType(str, Enum, metaclass=CaseInsensitiveEnumMeta): """The deployment on error behavior type. Possible values are LastSuccessful and SpecificDeployment. """ @@ -112,9 +113,9 @@ class OnErrorDeploymentType(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): LAST_SUCCESSFUL = "LastSuccessful" SPECIFIC_DEPLOYMENT = "SpecificDeployment" -class PropertyChangeType(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): - """The type of property change. - """ + +class PropertyChangeType(str, Enum, metaclass=CaseInsensitiveEnumMeta): + """The type of property change.""" #: The property does not exist in the current state but is present in the desired state. The #: property will be created when the deployment is executed. @@ -128,9 +129,9 @@ class PropertyChangeType(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): #: The property is an array and contains nested changes. ARRAY = "Array" -class ProvisioningOperation(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): - """The name of the current provisioning operation. - """ + +class ProvisioningOperation(str, Enum, metaclass=CaseInsensitiveEnumMeta): + """The name of the current provisioning operation.""" #: The provisioning operation is not specified. NOT_SPECIFIED = "NotSpecified" @@ -154,9 +155,9 @@ class ProvisioningOperation(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): #: deployment. DEPLOYMENT_CLEANUP = "DeploymentCleanup" -class ProvisioningState(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): - """Denotes the state of provisioning. - """ + +class ProvisioningState(str, Enum, metaclass=CaseInsensitiveEnumMeta): + """Denotes the state of provisioning.""" NOT_SPECIFIED = "NotSpecified" ACCEPTED = "Accepted" @@ -171,18 +172,18 @@ class ProvisioningState(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): SUCCEEDED = "Succeeded" UPDATING = "Updating" -class ResourceIdentityType(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): - """The identity type. - """ + +class ResourceIdentityType(str, Enum, metaclass=CaseInsensitiveEnumMeta): + """The identity type.""" SYSTEM_ASSIGNED = "SystemAssigned" USER_ASSIGNED = "UserAssigned" SYSTEM_ASSIGNED_USER_ASSIGNED = "SystemAssigned, UserAssigned" NONE = "None" -class TagsPatchOperation(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): - """The operation type for the patch API. - """ + +class TagsPatchOperation(str, Enum, metaclass=CaseInsensitiveEnumMeta): + """The operation type for the patch API.""" #: The 'replace' option replaces the entire set of existing tags with a new set. REPLACE = "Replace" @@ -192,9 +193,9 @@ class TagsPatchOperation(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): #: The 'delete' option allows selectively deleting tags based on given names or name/value pairs. DELETE = "Delete" -class WhatIfResultFormat(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): - """The format of the What-If results - """ + +class WhatIfResultFormat(str, Enum, metaclass=CaseInsensitiveEnumMeta): + """The format of the What-If results.""" RESOURCE_ID_ONLY = "ResourceIdOnly" FULL_RESOURCE_PAYLOADS = "FullResourcePayloads" diff --git a/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/resources/v2020_10_01/operations/__init__.py b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/resources/v2020_10_01/operations/__init__.py index f1487609817b6..9e5620e4d286c 100644 --- a/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/resources/v2020_10_01/operations/__init__.py +++ b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/resources/v2020_10_01/operations/__init__.py @@ -15,13 +15,19 @@ from ._operations import TagsOperations from ._operations import DeploymentOperationsOperations +from ._patch import __all__ as _patch_all +from ._patch import * # type: ignore # pylint: disable=unused-wildcard-import +from ._patch import patch_sdk as _patch_sdk + __all__ = [ - 'Operations', - 'DeploymentsOperations', - 'ProvidersOperations', - 'ProviderResourceTypesOperations', - 'ResourcesOperations', - 'ResourceGroupsOperations', - 'TagsOperations', - 'DeploymentOperationsOperations', + "Operations", + "DeploymentsOperations", + "ProvidersOperations", + "ProviderResourceTypesOperations", + "ResourcesOperations", + "ResourceGroupsOperations", + "TagsOperations", + "DeploymentOperationsOperations", ] +__all__.extend([p for p in _patch_all if p not in __all__]) +_patch_sdk() diff --git a/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/resources/v2020_10_01/operations/_operations.py b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/resources/v2020_10_01/operations/_operations.py index 136875996bebd..0b169b52bc05b 100644 --- a/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/resources/v2020_10_01/operations/_operations.py +++ b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/resources/v2020_10_01/operations/_operations.py @@ -6,1641 +6,1330 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -from typing import Any, Callable, Dict, Iterable, Optional, TypeVar, Union - -from msrest import Serializer - -from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error +import sys +from typing import Any, Callable, Dict, IO, Iterable, Optional, TypeVar, Union, cast, overload +from urllib.parse import parse_qs, urljoin, urlparse + +from azure.core.exceptions import ( + ClientAuthenticationError, + HttpResponseError, + ResourceExistsError, + ResourceNotFoundError, + ResourceNotModifiedError, + map_error, +) from azure.core.paging import ItemPaged from azure.core.pipeline import PipelineResponse from azure.core.pipeline.transport import HttpResponse from azure.core.polling import LROPoller, NoPolling, PollingMethod from azure.core.rest import HttpRequest from azure.core.tracing.decorator import distributed_trace +from azure.core.utils import case_insensitive_dict from azure.mgmt.core.exceptions import ARMErrorFormat from azure.mgmt.core.polling.arm_polling import ARMPolling from .. import models as _models +from ..._serialization import Serializer from .._vendor import _convert_request, _format_url_section -T = TypeVar('T') + +T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] -JSONType = Any +if sys.version_info >= (3, 9): + from collections.abc import MutableMapping +else: + from typing import MutableMapping # type: ignore # pylint: disable=ungrouped-imports +JSON = MutableMapping[str, Any] # pylint: disable=unsubscriptable-object _SERIALIZER = Serializer() _SERIALIZER.client_side_validation = False -def build_operations_list_request( - **kwargs: Any -) -> HttpRequest: - api_version = kwargs.pop('api_version', "2020-10-01") # type: str - accept = "application/json" +def build_operations_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", "2020-10-01")) # type: str + accept = _headers.pop("Accept", "application/json") + # Construct URL _url = kwargs.pop("template_url", "/providers/Microsoft.Resources/operations") # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') - - return HttpRequest( - method="GET", - url=_url, - params=_query_parameters, - headers=_header_parameters, - **kwargs - ) + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) -def build_deployments_delete_at_scope_request_initial( - scope: str, - deployment_name: str, - **kwargs: Any -) -> HttpRequest: - api_version = kwargs.pop('api_version', "2020-10-01") # type: str - accept = "application/json" +def build_deployments_delete_at_scope_request(scope: str, deployment_name: 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", "2020-10-01")) # type: str + accept = _headers.pop("Accept", "application/json") + # Construct URL _url = kwargs.pop("template_url", "/{scope}/providers/Microsoft.Resources/deployments/{deploymentName}") path_format_arguments = { - "scope": _SERIALIZER.url("scope", scope, 'str', skip_quote=True), - "deploymentName": _SERIALIZER.url("deployment_name", deployment_name, 'str', max_length=64, min_length=1), + "scope": _SERIALIZER.url("scope", scope, "str", skip_quote=True), + "deploymentName": _SERIALIZER.url("deployment_name", deployment_name, "str", max_length=64, min_length=1), } _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') - - return HttpRequest( - method="DELETE", - url=_url, - params=_query_parameters, - headers=_header_parameters, - **kwargs - ) + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + return HttpRequest(method="DELETE", url=_url, params=_params, headers=_headers, **kwargs) -def build_deployments_check_existence_at_scope_request( - scope: str, - deployment_name: str, - **kwargs: Any -) -> HttpRequest: - api_version = kwargs.pop('api_version', "2020-10-01") # type: str - accept = "application/json" +def build_deployments_check_existence_at_scope_request(scope: str, deployment_name: 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", "2020-10-01")) # type: str + accept = _headers.pop("Accept", "application/json") + # Construct URL _url = kwargs.pop("template_url", "/{scope}/providers/Microsoft.Resources/deployments/{deploymentName}") path_format_arguments = { - "scope": _SERIALIZER.url("scope", scope, 'str', skip_quote=True), - "deploymentName": _SERIALIZER.url("deployment_name", deployment_name, 'str', max_length=64, min_length=1), + "scope": _SERIALIZER.url("scope", scope, "str", skip_quote=True), + "deploymentName": _SERIALIZER.url("deployment_name", deployment_name, "str", max_length=64, min_length=1), } _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') - - return HttpRequest( - method="HEAD", - url=_url, - params=_query_parameters, - headers=_header_parameters, - **kwargs - ) + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + return HttpRequest(method="HEAD", url=_url, params=_params, headers=_headers, **kwargs) -def build_deployments_create_or_update_at_scope_request_initial( - scope: str, - deployment_name: str, - *, - json: JSONType = None, - content: Any = None, - **kwargs: Any -) -> HttpRequest: - api_version = kwargs.pop('api_version', "2020-10-01") # type: str - content_type = kwargs.pop('content_type', None) # type: Optional[str] - accept = "application/json" +def build_deployments_create_or_update_at_scope_request(scope: str, deployment_name: 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", "2020-10-01")) # type: str + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + accept = _headers.pop("Accept", "application/json") + # Construct URL _url = kwargs.pop("template_url", "/{scope}/providers/Microsoft.Resources/deployments/{deploymentName}") path_format_arguments = { - "scope": _SERIALIZER.url("scope", scope, 'str', skip_quote=True), - "deploymentName": _SERIALIZER.url("deployment_name", deployment_name, 'str', max_length=64, min_length=1), + "scope": _SERIALIZER.url("scope", scope, "str", skip_quote=True), + "deploymentName": _SERIALIZER.url("deployment_name", deployment_name, "str", max_length=64, min_length=1), } _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] if content_type is not None: - _header_parameters['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') - _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') - - return HttpRequest( - method="PUT", - url=_url, - params=_query_parameters, - headers=_header_parameters, - json=json, - content=content, - **kwargs - ) + _headers["Content-Type"] = _SERIALIZER.header("content_type", content_type, "str") + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + return HttpRequest(method="PUT", url=_url, params=_params, headers=_headers, **kwargs) -def build_deployments_get_at_scope_request( - scope: str, - deployment_name: str, - **kwargs: Any -) -> HttpRequest: - api_version = kwargs.pop('api_version', "2020-10-01") # type: str - accept = "application/json" +def build_deployments_get_at_scope_request(scope: str, deployment_name: 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", "2020-10-01")) # type: str + accept = _headers.pop("Accept", "application/json") + # Construct URL _url = kwargs.pop("template_url", "/{scope}/providers/Microsoft.Resources/deployments/{deploymentName}") path_format_arguments = { - "scope": _SERIALIZER.url("scope", scope, 'str', skip_quote=True), - "deploymentName": _SERIALIZER.url("deployment_name", deployment_name, 'str', max_length=64, min_length=1), + "scope": _SERIALIZER.url("scope", scope, "str", skip_quote=True), + "deploymentName": _SERIALIZER.url("deployment_name", deployment_name, "str", max_length=64, min_length=1), } _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') - - return HttpRequest( - method="GET", - url=_url, - params=_query_parameters, - headers=_header_parameters, - **kwargs - ) + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) -def build_deployments_cancel_at_scope_request( - scope: str, - deployment_name: str, - **kwargs: Any -) -> HttpRequest: - api_version = kwargs.pop('api_version', "2020-10-01") # type: str - accept = "application/json" +def build_deployments_cancel_at_scope_request(scope: str, deployment_name: 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", "2020-10-01")) # type: str + accept = _headers.pop("Accept", "application/json") + # Construct URL _url = kwargs.pop("template_url", "/{scope}/providers/Microsoft.Resources/deployments/{deploymentName}/cancel") path_format_arguments = { - "scope": _SERIALIZER.url("scope", scope, 'str', skip_quote=True), - "deploymentName": _SERIALIZER.url("deployment_name", deployment_name, 'str', max_length=64, min_length=1), + "scope": _SERIALIZER.url("scope", scope, "str", skip_quote=True), + "deploymentName": _SERIALIZER.url("deployment_name", deployment_name, "str", max_length=64, min_length=1), } _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') - - return HttpRequest( - method="POST", - url=_url, - params=_query_parameters, - headers=_header_parameters, - **kwargs - ) + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + return HttpRequest(method="POST", url=_url, params=_params, headers=_headers, **kwargs) -def build_deployments_validate_at_scope_request_initial( - scope: str, - deployment_name: str, - *, - json: JSONType = None, - content: Any = None, - **kwargs: Any -) -> HttpRequest: - api_version = kwargs.pop('api_version', "2020-10-01") # type: str - content_type = kwargs.pop('content_type', None) # type: Optional[str] - accept = "application/json" +def build_deployments_validate_at_scope_request(scope: str, deployment_name: 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", "2020-10-01")) # type: str + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + accept = _headers.pop("Accept", "application/json") + # Construct URL _url = kwargs.pop("template_url", "/{scope}/providers/Microsoft.Resources/deployments/{deploymentName}/validate") path_format_arguments = { - "scope": _SERIALIZER.url("scope", scope, 'str', skip_quote=True), - "deploymentName": _SERIALIZER.url("deployment_name", deployment_name, 'str', max_length=64, min_length=1), + "scope": _SERIALIZER.url("scope", scope, "str", skip_quote=True), + "deploymentName": _SERIALIZER.url("deployment_name", deployment_name, "str", max_length=64, min_length=1), } _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] if content_type is not None: - _header_parameters['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') - _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') - - return HttpRequest( - method="POST", - url=_url, - params=_query_parameters, - headers=_header_parameters, - json=json, - content=content, - **kwargs - ) + _headers["Content-Type"] = _SERIALIZER.header("content_type", content_type, "str") + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + return HttpRequest(method="POST", url=_url, params=_params, headers=_headers, **kwargs) -def build_deployments_export_template_at_scope_request( - scope: str, - deployment_name: str, - **kwargs: Any -) -> HttpRequest: - api_version = kwargs.pop('api_version', "2020-10-01") # type: str - accept = "application/json" +def build_deployments_export_template_at_scope_request(scope: str, deployment_name: 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", "2020-10-01")) # type: str + accept = _headers.pop("Accept", "application/json") + # Construct URL - _url = kwargs.pop("template_url", "/{scope}/providers/Microsoft.Resources/deployments/{deploymentName}/exportTemplate") + _url = kwargs.pop( + "template_url", "/{scope}/providers/Microsoft.Resources/deployments/{deploymentName}/exportTemplate" + ) path_format_arguments = { - "scope": _SERIALIZER.url("scope", scope, 'str', skip_quote=True), - "deploymentName": _SERIALIZER.url("deployment_name", deployment_name, 'str', max_length=64, min_length=1), + "scope": _SERIALIZER.url("scope", scope, "str", skip_quote=True), + "deploymentName": _SERIALIZER.url("deployment_name", deployment_name, "str", max_length=64, min_length=1), } _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') - - return HttpRequest( - method="POST", - url=_url, - params=_query_parameters, - headers=_header_parameters, - **kwargs - ) + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="POST", url=_url, params=_params, headers=_headers, **kwargs) def build_deployments_list_at_scope_request( - scope: str, - *, - filter: Optional[str] = None, - top: Optional[int] = None, - **kwargs: Any + scope: str, *, filter: Optional[str] = None, top: Optional[int] = None, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2020-10-01") # type: 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", "2020-10-01")) # type: str + accept = _headers.pop("Accept", "application/json") - accept = "application/json" # Construct URL _url = kwargs.pop("template_url", "/{scope}/providers/Microsoft.Resources/deployments/") path_format_arguments = { - "scope": _SERIALIZER.url("scope", scope, 'str', skip_quote=True), + "scope": _SERIALIZER.url("scope", scope, "str", skip_quote=True), } _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] if filter is not None: - _query_parameters['$filter'] = _SERIALIZER.query("filter", filter, 'str') + _params["$filter"] = _SERIALIZER.query("filter", filter, "str") if top is not None: - _query_parameters['$top'] = _SERIALIZER.query("top", top, 'int') - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["$top"] = _SERIALIZER.query("top", top, "int") + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') - - return HttpRequest( - method="GET", - url=_url, - params=_query_parameters, - headers=_header_parameters, - **kwargs - ) + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) -def build_deployments_delete_at_tenant_scope_request_initial( - deployment_name: str, - **kwargs: Any -) -> HttpRequest: - api_version = kwargs.pop('api_version', "2020-10-01") # type: str - accept = "application/json" +def build_deployments_delete_at_tenant_scope_request(deployment_name: 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", "2020-10-01")) # type: str + accept = _headers.pop("Accept", "application/json") + # Construct URL _url = kwargs.pop("template_url", "/providers/Microsoft.Resources/deployments/{deploymentName}") path_format_arguments = { - "deploymentName": _SERIALIZER.url("deployment_name", deployment_name, 'str', max_length=64, min_length=1), + "deploymentName": _SERIALIZER.url("deployment_name", deployment_name, "str", max_length=64, min_length=1), } _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') - - return HttpRequest( - method="DELETE", - url=_url, - params=_query_parameters, - headers=_header_parameters, - **kwargs - ) + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + return HttpRequest(method="DELETE", url=_url, params=_params, headers=_headers, **kwargs) -def build_deployments_check_existence_at_tenant_scope_request( - deployment_name: str, - **kwargs: Any -) -> HttpRequest: - api_version = kwargs.pop('api_version', "2020-10-01") # type: str - accept = "application/json" +def build_deployments_check_existence_at_tenant_scope_request(deployment_name: 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", "2020-10-01")) # type: str + accept = _headers.pop("Accept", "application/json") + # Construct URL _url = kwargs.pop("template_url", "/providers/Microsoft.Resources/deployments/{deploymentName}") path_format_arguments = { - "deploymentName": _SERIALIZER.url("deployment_name", deployment_name, 'str', max_length=64, min_length=1), + "deploymentName": _SERIALIZER.url("deployment_name", deployment_name, "str", max_length=64, min_length=1), } _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') - - return HttpRequest( - method="HEAD", - url=_url, - params=_query_parameters, - headers=_header_parameters, - **kwargs - ) + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + return HttpRequest(method="HEAD", url=_url, params=_params, headers=_headers, **kwargs) -def build_deployments_create_or_update_at_tenant_scope_request_initial( - deployment_name: str, - *, - json: JSONType = None, - content: Any = None, - **kwargs: Any -) -> HttpRequest: - api_version = kwargs.pop('api_version', "2020-10-01") # type: str - content_type = kwargs.pop('content_type', None) # type: Optional[str] - accept = "application/json" +def build_deployments_create_or_update_at_tenant_scope_request(deployment_name: 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", "2020-10-01")) # type: str + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + accept = _headers.pop("Accept", "application/json") + # Construct URL _url = kwargs.pop("template_url", "/providers/Microsoft.Resources/deployments/{deploymentName}") path_format_arguments = { - "deploymentName": _SERIALIZER.url("deployment_name", deployment_name, 'str', max_length=64, min_length=1), + "deploymentName": _SERIALIZER.url("deployment_name", deployment_name, "str", max_length=64, min_length=1), } _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] if content_type is not None: - _header_parameters['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') - _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') - - return HttpRequest( - method="PUT", - url=_url, - params=_query_parameters, - headers=_header_parameters, - json=json, - content=content, - **kwargs - ) + _headers["Content-Type"] = _SERIALIZER.header("content_type", content_type, "str") + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + return HttpRequest(method="PUT", url=_url, params=_params, headers=_headers, **kwargs) -def build_deployments_get_at_tenant_scope_request( - deployment_name: str, - **kwargs: Any -) -> HttpRequest: - api_version = kwargs.pop('api_version', "2020-10-01") # type: str - accept = "application/json" +def build_deployments_get_at_tenant_scope_request(deployment_name: 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", "2020-10-01")) # type: str + accept = _headers.pop("Accept", "application/json") + # Construct URL _url = kwargs.pop("template_url", "/providers/Microsoft.Resources/deployments/{deploymentName}") path_format_arguments = { - "deploymentName": _SERIALIZER.url("deployment_name", deployment_name, 'str', max_length=64, min_length=1), + "deploymentName": _SERIALIZER.url("deployment_name", deployment_name, "str", max_length=64, min_length=1), } _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') - - return HttpRequest( - method="GET", - url=_url, - params=_query_parameters, - headers=_header_parameters, - **kwargs - ) + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) -def build_deployments_cancel_at_tenant_scope_request( - deployment_name: str, - **kwargs: Any -) -> HttpRequest: - api_version = kwargs.pop('api_version', "2020-10-01") # type: str - accept = "application/json" +def build_deployments_cancel_at_tenant_scope_request(deployment_name: 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", "2020-10-01")) # type: str + accept = _headers.pop("Accept", "application/json") + # Construct URL _url = kwargs.pop("template_url", "/providers/Microsoft.Resources/deployments/{deploymentName}/cancel") path_format_arguments = { - "deploymentName": _SERIALIZER.url("deployment_name", deployment_name, 'str', max_length=64, min_length=1), + "deploymentName": _SERIALIZER.url("deployment_name", deployment_name, "str", max_length=64, min_length=1), } _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') - - return HttpRequest( - method="POST", - url=_url, - params=_query_parameters, - headers=_header_parameters, - **kwargs - ) + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + return HttpRequest(method="POST", url=_url, params=_params, headers=_headers, **kwargs) -def build_deployments_validate_at_tenant_scope_request_initial( - deployment_name: str, - *, - json: JSONType = None, - content: Any = None, - **kwargs: Any -) -> HttpRequest: - api_version = kwargs.pop('api_version', "2020-10-01") # type: str - content_type = kwargs.pop('content_type', None) # type: Optional[str] - accept = "application/json" +def build_deployments_validate_at_tenant_scope_request(deployment_name: 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", "2020-10-01")) # type: str + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + accept = _headers.pop("Accept", "application/json") + # Construct URL _url = kwargs.pop("template_url", "/providers/Microsoft.Resources/deployments/{deploymentName}/validate") path_format_arguments = { - "deploymentName": _SERIALIZER.url("deployment_name", deployment_name, 'str', max_length=64, min_length=1), + "deploymentName": _SERIALIZER.url("deployment_name", deployment_name, "str", max_length=64, min_length=1), } _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] if content_type is not None: - _header_parameters['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') - _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') - - return HttpRequest( - method="POST", - url=_url, - params=_query_parameters, - headers=_header_parameters, - json=json, - content=content, - **kwargs - ) + _headers["Content-Type"] = _SERIALIZER.header("content_type", content_type, "str") + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + return HttpRequest(method="POST", url=_url, params=_params, headers=_headers, **kwargs) -def build_deployments_what_if_at_tenant_scope_request_initial( - deployment_name: str, - *, - json: JSONType = None, - content: Any = None, - **kwargs: Any -) -> HttpRequest: - api_version = kwargs.pop('api_version', "2020-10-01") # type: str - content_type = kwargs.pop('content_type', None) # type: Optional[str] - accept = "application/json" +def build_deployments_what_if_at_tenant_scope_request(deployment_name: 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", "2020-10-01")) # type: str + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + accept = _headers.pop("Accept", "application/json") + # Construct URL _url = kwargs.pop("template_url", "/providers/Microsoft.Resources/deployments/{deploymentName}/whatIf") path_format_arguments = { - "deploymentName": _SERIALIZER.url("deployment_name", deployment_name, 'str', max_length=64, min_length=1), + "deploymentName": _SERIALIZER.url("deployment_name", deployment_name, "str", max_length=64, min_length=1), } _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] if content_type is not None: - _header_parameters['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') - _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') - - return HttpRequest( - method="POST", - url=_url, - params=_query_parameters, - headers=_header_parameters, - json=json, - content=content, - **kwargs - ) + _headers["Content-Type"] = _SERIALIZER.header("content_type", content_type, "str") + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + return HttpRequest(method="POST", url=_url, params=_params, headers=_headers, **kwargs) -def build_deployments_export_template_at_tenant_scope_request( - deployment_name: str, - **kwargs: Any -) -> HttpRequest: - api_version = kwargs.pop('api_version', "2020-10-01") # type: str - accept = "application/json" +def build_deployments_export_template_at_tenant_scope_request(deployment_name: 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", "2020-10-01")) # type: str + accept = _headers.pop("Accept", "application/json") + # Construct URL _url = kwargs.pop("template_url", "/providers/Microsoft.Resources/deployments/{deploymentName}/exportTemplate") path_format_arguments = { - "deploymentName": _SERIALIZER.url("deployment_name", deployment_name, 'str', max_length=64, min_length=1), + "deploymentName": _SERIALIZER.url("deployment_name", deployment_name, "str", max_length=64, min_length=1), } _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') - - return HttpRequest( - method="POST", - url=_url, - params=_query_parameters, - headers=_header_parameters, - **kwargs - ) + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="POST", url=_url, params=_params, headers=_headers, **kwargs) def build_deployments_list_at_tenant_scope_request( - *, - filter: Optional[str] = None, - top: Optional[int] = None, - **kwargs: Any + *, filter: Optional[str] = None, top: Optional[int] = None, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2020-10-01") # type: 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", "2020-10-01")) # type: str + accept = _headers.pop("Accept", "application/json") - accept = "application/json" # Construct URL _url = kwargs.pop("template_url", "/providers/Microsoft.Resources/deployments/") # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] if filter is not None: - _query_parameters['$filter'] = _SERIALIZER.query("filter", filter, 'str') + _params["$filter"] = _SERIALIZER.query("filter", filter, "str") if top is not None: - _query_parameters['$top'] = _SERIALIZER.query("top", top, 'int') - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["$top"] = _SERIALIZER.query("top", top, "int") + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') - - return HttpRequest( - method="GET", - url=_url, - params=_query_parameters, - headers=_header_parameters, - **kwargs - ) + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) -def build_deployments_delete_at_management_group_scope_request_initial( - group_id: str, - deployment_name: str, - **kwargs: Any + +def build_deployments_delete_at_management_group_scope_request( + group_id: str, deployment_name: str, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2020-10-01") # type: 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", "2020-10-01")) # type: str + accept = _headers.pop("Accept", "application/json") - accept = "application/json" # Construct URL - _url = kwargs.pop("template_url", "/providers/Microsoft.Management/managementGroups/{groupId}/providers/Microsoft.Resources/deployments/{deploymentName}") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", + "/providers/Microsoft.Management/managementGroups/{groupId}/providers/Microsoft.Resources/deployments/{deploymentName}", + ) # pylint: disable=line-too-long path_format_arguments = { - "groupId": _SERIALIZER.url("group_id", group_id, 'str', max_length=90, min_length=1), - "deploymentName": _SERIALIZER.url("deployment_name", deployment_name, 'str', max_length=64, min_length=1), + "groupId": _SERIALIZER.url("group_id", group_id, "str", max_length=90, min_length=1), + "deploymentName": _SERIALIZER.url("deployment_name", deployment_name, "str", max_length=64, min_length=1), } _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') - - return HttpRequest( - method="DELETE", - url=_url, - params=_query_parameters, - headers=_header_parameters, - **kwargs - ) + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="DELETE", url=_url, params=_params, headers=_headers, **kwargs) def build_deployments_check_existence_at_management_group_scope_request( - group_id: str, - deployment_name: str, - **kwargs: Any + group_id: str, deployment_name: str, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2020-10-01") # type: 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", "2020-10-01")) # type: str + accept = _headers.pop("Accept", "application/json") - accept = "application/json" # Construct URL - _url = kwargs.pop("template_url", "/providers/Microsoft.Management/managementGroups/{groupId}/providers/Microsoft.Resources/deployments/{deploymentName}") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", + "/providers/Microsoft.Management/managementGroups/{groupId}/providers/Microsoft.Resources/deployments/{deploymentName}", + ) # pylint: disable=line-too-long path_format_arguments = { - "groupId": _SERIALIZER.url("group_id", group_id, 'str', max_length=90, min_length=1), - "deploymentName": _SERIALIZER.url("deployment_name", deployment_name, 'str', max_length=64, min_length=1), + "groupId": _SERIALIZER.url("group_id", group_id, "str", max_length=90, min_length=1), + "deploymentName": _SERIALIZER.url("deployment_name", deployment_name, "str", max_length=64, min_length=1), } _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') - - return HttpRequest( - method="HEAD", - url=_url, - params=_query_parameters, - headers=_header_parameters, - **kwargs - ) + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + return HttpRequest(method="HEAD", url=_url, params=_params, headers=_headers, **kwargs) -def build_deployments_create_or_update_at_management_group_scope_request_initial( - group_id: str, - deployment_name: str, - *, - json: JSONType = None, - content: Any = None, - **kwargs: Any + +def build_deployments_create_or_update_at_management_group_scope_request( + group_id: str, deployment_name: str, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2020-10-01") # type: str - content_type = kwargs.pop('content_type', None) # type: Optional[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", "2020-10-01")) # type: str + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + accept = _headers.pop("Accept", "application/json") - accept = "application/json" # Construct URL - _url = kwargs.pop("template_url", "/providers/Microsoft.Management/managementGroups/{groupId}/providers/Microsoft.Resources/deployments/{deploymentName}") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", + "/providers/Microsoft.Management/managementGroups/{groupId}/providers/Microsoft.Resources/deployments/{deploymentName}", + ) # pylint: disable=line-too-long path_format_arguments = { - "groupId": _SERIALIZER.url("group_id", group_id, 'str', max_length=90, min_length=1), - "deploymentName": _SERIALIZER.url("deployment_name", deployment_name, 'str', max_length=64, min_length=1), + "groupId": _SERIALIZER.url("group_id", group_id, "str", max_length=90, min_length=1), + "deploymentName": _SERIALIZER.url("deployment_name", deployment_name, "str", max_length=64, min_length=1), } _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] if content_type is not None: - _header_parameters['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') - _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') - - return HttpRequest( - method="PUT", - url=_url, - params=_query_parameters, - headers=_header_parameters, - json=json, - content=content, - **kwargs - ) + _headers["Content-Type"] = _SERIALIZER.header("content_type", content_type, "str") + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="PUT", url=_url, params=_params, headers=_headers, **kwargs) def build_deployments_get_at_management_group_scope_request( - group_id: str, - deployment_name: str, - **kwargs: Any + group_id: str, deployment_name: str, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2020-10-01") # type: 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", "2020-10-01")) # type: str + accept = _headers.pop("Accept", "application/json") - accept = "application/json" # Construct URL - _url = kwargs.pop("template_url", "/providers/Microsoft.Management/managementGroups/{groupId}/providers/Microsoft.Resources/deployments/{deploymentName}") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", + "/providers/Microsoft.Management/managementGroups/{groupId}/providers/Microsoft.Resources/deployments/{deploymentName}", + ) # pylint: disable=line-too-long path_format_arguments = { - "groupId": _SERIALIZER.url("group_id", group_id, 'str', max_length=90, min_length=1), - "deploymentName": _SERIALIZER.url("deployment_name", deployment_name, 'str', max_length=64, min_length=1), + "groupId": _SERIALIZER.url("group_id", group_id, "str", max_length=90, min_length=1), + "deploymentName": _SERIALIZER.url("deployment_name", deployment_name, "str", max_length=64, min_length=1), } _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') - - return HttpRequest( - method="GET", - url=_url, - params=_query_parameters, - headers=_header_parameters, - **kwargs - ) + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) def build_deployments_cancel_at_management_group_scope_request( - group_id: str, - deployment_name: str, - **kwargs: Any + group_id: str, deployment_name: str, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2020-10-01") # type: 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", "2020-10-01")) # type: str + accept = _headers.pop("Accept", "application/json") - accept = "application/json" # Construct URL - _url = kwargs.pop("template_url", "/providers/Microsoft.Management/managementGroups/{groupId}/providers/Microsoft.Resources/deployments/{deploymentName}/cancel") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", + "/providers/Microsoft.Management/managementGroups/{groupId}/providers/Microsoft.Resources/deployments/{deploymentName}/cancel", + ) # pylint: disable=line-too-long path_format_arguments = { - "groupId": _SERIALIZER.url("group_id", group_id, 'str', max_length=90, min_length=1), - "deploymentName": _SERIALIZER.url("deployment_name", deployment_name, 'str', max_length=64, min_length=1), + "groupId": _SERIALIZER.url("group_id", group_id, "str", max_length=90, min_length=1), + "deploymentName": _SERIALIZER.url("deployment_name", deployment_name, "str", max_length=64, min_length=1), } _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') - - return HttpRequest( - method="POST", - url=_url, - params=_query_parameters, - headers=_header_parameters, - **kwargs - ) + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + return HttpRequest(method="POST", url=_url, params=_params, headers=_headers, **kwargs) -def build_deployments_validate_at_management_group_scope_request_initial( - group_id: str, - deployment_name: str, - *, - json: JSONType = None, - content: Any = None, - **kwargs: Any + +def build_deployments_validate_at_management_group_scope_request( + group_id: str, deployment_name: str, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2020-10-01") # type: str - content_type = kwargs.pop('content_type', None) # type: Optional[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", "2020-10-01")) # type: str + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + accept = _headers.pop("Accept", "application/json") - accept = "application/json" # Construct URL - _url = kwargs.pop("template_url", "/providers/Microsoft.Management/managementGroups/{groupId}/providers/Microsoft.Resources/deployments/{deploymentName}/validate") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", + "/providers/Microsoft.Management/managementGroups/{groupId}/providers/Microsoft.Resources/deployments/{deploymentName}/validate", + ) # pylint: disable=line-too-long path_format_arguments = { - "groupId": _SERIALIZER.url("group_id", group_id, 'str', max_length=90, min_length=1), - "deploymentName": _SERIALIZER.url("deployment_name", deployment_name, 'str', max_length=64, min_length=1), + "groupId": _SERIALIZER.url("group_id", group_id, "str", max_length=90, min_length=1), + "deploymentName": _SERIALIZER.url("deployment_name", deployment_name, "str", max_length=64, min_length=1), } _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] if content_type is not None: - _header_parameters['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') - _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') - - return HttpRequest( - method="POST", - url=_url, - params=_query_parameters, - headers=_header_parameters, - json=json, - content=content, - **kwargs - ) + _headers["Content-Type"] = _SERIALIZER.header("content_type", content_type, "str") + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + return HttpRequest(method="POST", url=_url, params=_params, headers=_headers, **kwargs) -def build_deployments_what_if_at_management_group_scope_request_initial( - group_id: str, - deployment_name: str, - *, - json: JSONType = None, - content: Any = None, - **kwargs: Any + +def build_deployments_what_if_at_management_group_scope_request( + group_id: str, deployment_name: str, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2020-10-01") # type: str - content_type = kwargs.pop('content_type', None) # type: Optional[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", "2020-10-01")) # type: str + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + accept = _headers.pop("Accept", "application/json") - accept = "application/json" # Construct URL - _url = kwargs.pop("template_url", "/providers/Microsoft.Management/managementGroups/{groupId}/providers/Microsoft.Resources/deployments/{deploymentName}/whatIf") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", + "/providers/Microsoft.Management/managementGroups/{groupId}/providers/Microsoft.Resources/deployments/{deploymentName}/whatIf", + ) # pylint: disable=line-too-long path_format_arguments = { - "groupId": _SERIALIZER.url("group_id", group_id, 'str', max_length=90, min_length=1), - "deploymentName": _SERIALIZER.url("deployment_name", deployment_name, 'str', max_length=64, min_length=1), + "groupId": _SERIALIZER.url("group_id", group_id, "str", max_length=90, min_length=1), + "deploymentName": _SERIALIZER.url("deployment_name", deployment_name, "str", max_length=64, min_length=1), } _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] if content_type is not None: - _header_parameters['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') - _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') - - return HttpRequest( - method="POST", - url=_url, - params=_query_parameters, - headers=_header_parameters, - json=json, - content=content, - **kwargs - ) + _headers["Content-Type"] = _SERIALIZER.header("content_type", content_type, "str") + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="POST", url=_url, params=_params, headers=_headers, **kwargs) def build_deployments_export_template_at_management_group_scope_request( - group_id: str, - deployment_name: str, - **kwargs: Any + group_id: str, deployment_name: str, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2020-10-01") # type: 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", "2020-10-01")) # type: str + accept = _headers.pop("Accept", "application/json") - accept = "application/json" # Construct URL - _url = kwargs.pop("template_url", "/providers/Microsoft.Management/managementGroups/{groupId}/providers/Microsoft.Resources/deployments/{deploymentName}/exportTemplate") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", + "/providers/Microsoft.Management/managementGroups/{groupId}/providers/Microsoft.Resources/deployments/{deploymentName}/exportTemplate", + ) # pylint: disable=line-too-long path_format_arguments = { - "groupId": _SERIALIZER.url("group_id", group_id, 'str', max_length=90, min_length=1), - "deploymentName": _SERIALIZER.url("deployment_name", deployment_name, 'str', max_length=64, min_length=1), + "groupId": _SERIALIZER.url("group_id", group_id, "str", max_length=90, min_length=1), + "deploymentName": _SERIALIZER.url("deployment_name", deployment_name, "str", max_length=64, min_length=1), } _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') - - return HttpRequest( - method="POST", - url=_url, - params=_query_parameters, - headers=_header_parameters, - **kwargs - ) + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="POST", url=_url, params=_params, headers=_headers, **kwargs) def build_deployments_list_at_management_group_scope_request( - group_id: str, - *, - filter: Optional[str] = None, - top: Optional[int] = None, - **kwargs: Any + group_id: str, *, filter: Optional[str] = None, top: Optional[int] = None, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2020-10-01") # type: 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", "2020-10-01")) # type: str + accept = _headers.pop("Accept", "application/json") - accept = "application/json" # Construct URL - _url = kwargs.pop("template_url", "/providers/Microsoft.Management/managementGroups/{groupId}/providers/Microsoft.Resources/deployments/") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", + "/providers/Microsoft.Management/managementGroups/{groupId}/providers/Microsoft.Resources/deployments/", + ) # pylint: disable=line-too-long path_format_arguments = { - "groupId": _SERIALIZER.url("group_id", group_id, 'str', max_length=90, min_length=1), + "groupId": _SERIALIZER.url("group_id", group_id, "str", max_length=90, min_length=1), } _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] if filter is not None: - _query_parameters['$filter'] = _SERIALIZER.query("filter", filter, 'str') + _params["$filter"] = _SERIALIZER.query("filter", filter, "str") if top is not None: - _query_parameters['$top'] = _SERIALIZER.query("top", top, 'int') - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["$top"] = _SERIALIZER.query("top", top, "int") + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') - - return HttpRequest( - method="GET", - url=_url, - params=_query_parameters, - headers=_header_parameters, - **kwargs - ) + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) -def build_deployments_delete_at_subscription_scope_request_initial( - deployment_name: str, - subscription_id: str, - **kwargs: Any + +def build_deployments_delete_at_subscription_scope_request( + deployment_name: str, subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2020-10-01") # type: 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", "2020-10-01")) # type: str + accept = _headers.pop("Accept", "application/json") - accept = "application/json" # Construct URL - _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/providers/Microsoft.Resources/deployments/{deploymentName}") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", "/subscriptions/{subscriptionId}/providers/Microsoft.Resources/deployments/{deploymentName}" + ) # pylint: disable=line-too-long path_format_arguments = { - "deploymentName": _SERIALIZER.url("deployment_name", deployment_name, 'str', max_length=64, min_length=1), - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), + "deploymentName": _SERIALIZER.url("deployment_name", deployment_name, "str", max_length=64, min_length=1), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), } _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') - - return HttpRequest( - method="DELETE", - url=_url, - params=_query_parameters, - headers=_header_parameters, - **kwargs - ) + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="DELETE", url=_url, params=_params, headers=_headers, **kwargs) def build_deployments_check_existence_at_subscription_scope_request( - deployment_name: str, - subscription_id: str, - **kwargs: Any + deployment_name: str, subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2020-10-01") # type: 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", "2020-10-01")) # type: str + accept = _headers.pop("Accept", "application/json") - accept = "application/json" # Construct URL - _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/providers/Microsoft.Resources/deployments/{deploymentName}") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", "/subscriptions/{subscriptionId}/providers/Microsoft.Resources/deployments/{deploymentName}" + ) # pylint: disable=line-too-long path_format_arguments = { - "deploymentName": _SERIALIZER.url("deployment_name", deployment_name, 'str', max_length=64, min_length=1), - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), + "deploymentName": _SERIALIZER.url("deployment_name", deployment_name, "str", max_length=64, min_length=1), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), } _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') - - return HttpRequest( - method="HEAD", - url=_url, - params=_query_parameters, - headers=_header_parameters, - **kwargs - ) + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + return HttpRequest(method="HEAD", url=_url, params=_params, headers=_headers, **kwargs) -def build_deployments_create_or_update_at_subscription_scope_request_initial( - deployment_name: str, - subscription_id: str, - *, - json: JSONType = None, - content: Any = None, - **kwargs: Any + +def build_deployments_create_or_update_at_subscription_scope_request( + deployment_name: str, subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2020-10-01") # type: str - content_type = kwargs.pop('content_type', None) # type: Optional[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", "2020-10-01")) # type: str + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + accept = _headers.pop("Accept", "application/json") - accept = "application/json" # Construct URL - _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/providers/Microsoft.Resources/deployments/{deploymentName}") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", "/subscriptions/{subscriptionId}/providers/Microsoft.Resources/deployments/{deploymentName}" + ) # pylint: disable=line-too-long path_format_arguments = { - "deploymentName": _SERIALIZER.url("deployment_name", deployment_name, 'str', max_length=64, min_length=1), - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), + "deploymentName": _SERIALIZER.url("deployment_name", deployment_name, "str", max_length=64, min_length=1), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), } _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] if content_type is not None: - _header_parameters['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') - _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') - - return HttpRequest( - method="PUT", - url=_url, - params=_query_parameters, - headers=_header_parameters, - json=json, - content=content, - **kwargs - ) + _headers["Content-Type"] = _SERIALIZER.header("content_type", content_type, "str") + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="PUT", url=_url, params=_params, headers=_headers, **kwargs) def build_deployments_get_at_subscription_scope_request( - deployment_name: str, - subscription_id: str, - **kwargs: Any + deployment_name: str, subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2020-10-01") # type: 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", "2020-10-01")) # type: str + accept = _headers.pop("Accept", "application/json") - accept = "application/json" # Construct URL - _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/providers/Microsoft.Resources/deployments/{deploymentName}") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", "/subscriptions/{subscriptionId}/providers/Microsoft.Resources/deployments/{deploymentName}" + ) # pylint: disable=line-too-long path_format_arguments = { - "deploymentName": _SERIALIZER.url("deployment_name", deployment_name, 'str', max_length=64, min_length=1), - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), + "deploymentName": _SERIALIZER.url("deployment_name", deployment_name, "str", max_length=64, min_length=1), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), } _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') - - return HttpRequest( - method="GET", - url=_url, - params=_query_parameters, - headers=_header_parameters, - **kwargs - ) + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) def build_deployments_cancel_at_subscription_scope_request( - deployment_name: str, - subscription_id: str, - **kwargs: Any + deployment_name: str, subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2020-10-01") # type: 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", "2020-10-01")) # type: str + accept = _headers.pop("Accept", "application/json") - accept = "application/json" # Construct URL - _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/providers/Microsoft.Resources/deployments/{deploymentName}/cancel") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/providers/Microsoft.Resources/deployments/{deploymentName}/cancel", + ) # pylint: disable=line-too-long path_format_arguments = { - "deploymentName": _SERIALIZER.url("deployment_name", deployment_name, 'str', max_length=64, min_length=1), - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), + "deploymentName": _SERIALIZER.url("deployment_name", deployment_name, "str", max_length=64, min_length=1), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), } _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') - - return HttpRequest( - method="POST", - url=_url, - params=_query_parameters, - headers=_header_parameters, - **kwargs - ) + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + return HttpRequest(method="POST", url=_url, params=_params, headers=_headers, **kwargs) -def build_deployments_validate_at_subscription_scope_request_initial( - deployment_name: str, - subscription_id: str, - *, - json: JSONType = None, - content: Any = None, - **kwargs: Any + +def build_deployments_validate_at_subscription_scope_request( + deployment_name: str, subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2020-10-01") # type: str - content_type = kwargs.pop('content_type', None) # type: Optional[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", "2020-10-01")) # type: str + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + accept = _headers.pop("Accept", "application/json") - accept = "application/json" # Construct URL - _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/providers/Microsoft.Resources/deployments/{deploymentName}/validate") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/providers/Microsoft.Resources/deployments/{deploymentName}/validate", + ) # pylint: disable=line-too-long path_format_arguments = { - "deploymentName": _SERIALIZER.url("deployment_name", deployment_name, 'str', max_length=64, min_length=1), - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), + "deploymentName": _SERIALIZER.url("deployment_name", deployment_name, "str", max_length=64, min_length=1), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), } _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] if content_type is not None: - _header_parameters['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') - _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') - - return HttpRequest( - method="POST", - url=_url, - params=_query_parameters, - headers=_header_parameters, - json=json, - content=content, - **kwargs - ) + _headers["Content-Type"] = _SERIALIZER.header("content_type", content_type, "str") + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + return HttpRequest(method="POST", url=_url, params=_params, headers=_headers, **kwargs) -def build_deployments_what_if_at_subscription_scope_request_initial( - deployment_name: str, - subscription_id: str, - *, - json: JSONType = None, - content: Any = None, - **kwargs: Any + +def build_deployments_what_if_at_subscription_scope_request( + deployment_name: str, subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2020-10-01") # type: str - content_type = kwargs.pop('content_type', None) # type: Optional[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", "2020-10-01")) # type: str + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + accept = _headers.pop("Accept", "application/json") - accept = "application/json" # Construct URL - _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/providers/Microsoft.Resources/deployments/{deploymentName}/whatIf") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/providers/Microsoft.Resources/deployments/{deploymentName}/whatIf", + ) # pylint: disable=line-too-long path_format_arguments = { - "deploymentName": _SERIALIZER.url("deployment_name", deployment_name, 'str', max_length=64, min_length=1), - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), + "deploymentName": _SERIALIZER.url("deployment_name", deployment_name, "str", max_length=64, min_length=1), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), } _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] if content_type is not None: - _header_parameters['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') - _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') - - return HttpRequest( - method="POST", - url=_url, - params=_query_parameters, - headers=_header_parameters, - json=json, - content=content, - **kwargs - ) + _headers["Content-Type"] = _SERIALIZER.header("content_type", content_type, "str") + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="POST", url=_url, params=_params, headers=_headers, **kwargs) def build_deployments_export_template_at_subscription_scope_request( - deployment_name: str, - subscription_id: str, - **kwargs: Any + deployment_name: str, subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2020-10-01") # type: 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", "2020-10-01")) # type: str + accept = _headers.pop("Accept", "application/json") - accept = "application/json" # Construct URL - _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/providers/Microsoft.Resources/deployments/{deploymentName}/exportTemplate") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/providers/Microsoft.Resources/deployments/{deploymentName}/exportTemplate", + ) # pylint: disable=line-too-long path_format_arguments = { - "deploymentName": _SERIALIZER.url("deployment_name", deployment_name, 'str', max_length=64, min_length=1), - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), + "deploymentName": _SERIALIZER.url("deployment_name", deployment_name, "str", max_length=64, min_length=1), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), } _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') - - return HttpRequest( - method="POST", - url=_url, - params=_query_parameters, - headers=_header_parameters, - **kwargs - ) + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="POST", url=_url, params=_params, headers=_headers, **kwargs) def build_deployments_list_at_subscription_scope_request( - subscription_id: str, - *, - filter: Optional[str] = None, - top: Optional[int] = None, - **kwargs: Any + subscription_id: str, *, filter: Optional[str] = None, top: Optional[int] = None, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2020-10-01") # type: 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", "2020-10-01")) # type: str + accept = _headers.pop("Accept", "application/json") - accept = "application/json" # Construct URL _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/providers/Microsoft.Resources/deployments/") path_format_arguments = { - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), } _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] if filter is not None: - _query_parameters['$filter'] = _SERIALIZER.query("filter", filter, 'str') + _params["$filter"] = _SERIALIZER.query("filter", filter, "str") if top is not None: - _query_parameters['$top'] = _SERIALIZER.query("top", top, 'int') - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["$top"] = _SERIALIZER.query("top", top, "int") + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') - - return HttpRequest( - method="GET", - url=_url, - params=_query_parameters, - headers=_header_parameters, - **kwargs - ) + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) -def build_deployments_delete_request_initial( - resource_group_name: str, - deployment_name: str, - subscription_id: str, - **kwargs: Any + +def build_deployments_delete_request( + resource_group_name: str, deployment_name: str, subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2020-10-01") # type: 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", "2020-10-01")) # type: str + accept = _headers.pop("Accept", "application/json") - accept = "application/json" # Construct URL - _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/Microsoft.Resources/deployments/{deploymentName}") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/Microsoft.Resources/deployments/{deploymentName}", + ) # pylint: disable=line-too-long path_format_arguments = { - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1), - "deploymentName": _SERIALIZER.url("deployment_name", deployment_name, 'str', max_length=64, min_length=1), - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), + "resourceGroupName": _SERIALIZER.url( + "resource_group_name", resource_group_name, "str", max_length=90, min_length=1 + ), + "deploymentName": _SERIALIZER.url("deployment_name", deployment_name, "str", max_length=64, min_length=1), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), } _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') - - return HttpRequest( - method="DELETE", - url=_url, - params=_query_parameters, - headers=_header_parameters, - **kwargs - ) + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="DELETE", url=_url, params=_params, headers=_headers, **kwargs) def build_deployments_check_existence_request( - resource_group_name: str, - deployment_name: str, - subscription_id: str, - **kwargs: Any + resource_group_name: str, deployment_name: str, subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2020-10-01") # type: 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", "2020-10-01")) # type: str + accept = _headers.pop("Accept", "application/json") - accept = "application/json" # Construct URL - _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/Microsoft.Resources/deployments/{deploymentName}") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/Microsoft.Resources/deployments/{deploymentName}", + ) # pylint: disable=line-too-long path_format_arguments = { - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1), - "deploymentName": _SERIALIZER.url("deployment_name", deployment_name, 'str', max_length=64, min_length=1), - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), + "resourceGroupName": _SERIALIZER.url( + "resource_group_name", resource_group_name, "str", max_length=90, min_length=1 + ), + "deploymentName": _SERIALIZER.url("deployment_name", deployment_name, "str", max_length=64, min_length=1), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), } _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') - - return HttpRequest( - method="HEAD", - url=_url, - params=_query_parameters, - headers=_header_parameters, - **kwargs - ) + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + return HttpRequest(method="HEAD", url=_url, params=_params, headers=_headers, **kwargs) -def build_deployments_create_or_update_request_initial( - resource_group_name: str, - deployment_name: str, - subscription_id: str, - *, - json: JSONType = None, - content: Any = None, - **kwargs: Any + +def build_deployments_create_or_update_request( + resource_group_name: str, deployment_name: str, subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2020-10-01") # type: str - content_type = kwargs.pop('content_type', None) # type: Optional[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", "2020-10-01")) # type: str + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + accept = _headers.pop("Accept", "application/json") - accept = "application/json" # Construct URL - _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/Microsoft.Resources/deployments/{deploymentName}") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/Microsoft.Resources/deployments/{deploymentName}", + ) # pylint: disable=line-too-long path_format_arguments = { - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1), - "deploymentName": _SERIALIZER.url("deployment_name", deployment_name, 'str', max_length=64, min_length=1), - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), + "resourceGroupName": _SERIALIZER.url( + "resource_group_name", resource_group_name, "str", max_length=90, min_length=1 + ), + "deploymentName": _SERIALIZER.url("deployment_name", deployment_name, "str", max_length=64, min_length=1), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), } _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] if content_type is not None: - _header_parameters['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') - _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') - - return HttpRequest( - method="PUT", - url=_url, - params=_query_parameters, - headers=_header_parameters, - json=json, - content=content, - **kwargs - ) + _headers["Content-Type"] = _SERIALIZER.header("content_type", content_type, "str") + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="PUT", url=_url, params=_params, headers=_headers, **kwargs) def build_deployments_get_request( - resource_group_name: str, - deployment_name: str, - subscription_id: str, - **kwargs: Any + resource_group_name: str, deployment_name: str, subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2020-10-01") # type: 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", "2020-10-01")) # type: str + accept = _headers.pop("Accept", "application/json") - accept = "application/json" # Construct URL - _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/Microsoft.Resources/deployments/{deploymentName}") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/Microsoft.Resources/deployments/{deploymentName}", + ) # pylint: disable=line-too-long path_format_arguments = { - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1), - "deploymentName": _SERIALIZER.url("deployment_name", deployment_name, 'str', max_length=64, min_length=1), - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), + "resourceGroupName": _SERIALIZER.url( + "resource_group_name", resource_group_name, "str", max_length=90, min_length=1 + ), + "deploymentName": _SERIALIZER.url("deployment_name", deployment_name, "str", max_length=64, min_length=1), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), } _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') - - return HttpRequest( - method="GET", - url=_url, - params=_query_parameters, - headers=_header_parameters, - **kwargs - ) + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) def build_deployments_cancel_request( - resource_group_name: str, - deployment_name: str, - subscription_id: str, - **kwargs: Any + resource_group_name: str, deployment_name: str, subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2020-10-01") # type: 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", "2020-10-01")) # type: str + accept = _headers.pop("Accept", "application/json") - accept = "application/json" # Construct URL - _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/Microsoft.Resources/deployments/{deploymentName}/cancel") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/Microsoft.Resources/deployments/{deploymentName}/cancel", + ) # pylint: disable=line-too-long path_format_arguments = { - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1), - "deploymentName": _SERIALIZER.url("deployment_name", deployment_name, 'str', max_length=64, min_length=1), - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), + "resourceGroupName": _SERIALIZER.url( + "resource_group_name", resource_group_name, "str", max_length=90, min_length=1 + ), + "deploymentName": _SERIALIZER.url("deployment_name", deployment_name, "str", max_length=64, min_length=1), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), } _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') - - return HttpRequest( - method="POST", - url=_url, - params=_query_parameters, - headers=_header_parameters, - **kwargs - ) + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + return HttpRequest(method="POST", url=_url, params=_params, headers=_headers, **kwargs) -def build_deployments_validate_request_initial( - resource_group_name: str, - deployment_name: str, - subscription_id: str, - *, - json: JSONType = None, - content: Any = None, - **kwargs: Any + +def build_deployments_validate_request( + resource_group_name: str, deployment_name: str, subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2020-10-01") # type: str - content_type = kwargs.pop('content_type', None) # type: Optional[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", "2020-10-01")) # type: str + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + accept = _headers.pop("Accept", "application/json") - accept = "application/json" # Construct URL - _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/Microsoft.Resources/deployments/{deploymentName}/validate") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/Microsoft.Resources/deployments/{deploymentName}/validate", + ) # pylint: disable=line-too-long path_format_arguments = { - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1), - "deploymentName": _SERIALIZER.url("deployment_name", deployment_name, 'str', max_length=64, min_length=1), - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), + "resourceGroupName": _SERIALIZER.url( + "resource_group_name", resource_group_name, "str", max_length=90, min_length=1 + ), + "deploymentName": _SERIALIZER.url("deployment_name", deployment_name, "str", max_length=64, min_length=1), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), } _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] if content_type is not None: - _header_parameters['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') - _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') - - return HttpRequest( - method="POST", - url=_url, - params=_query_parameters, - headers=_header_parameters, - json=json, - content=content, - **kwargs - ) + _headers["Content-Type"] = _SERIALIZER.header("content_type", content_type, "str") + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + return HttpRequest(method="POST", url=_url, params=_params, headers=_headers, **kwargs) -def build_deployments_what_if_request_initial( - resource_group_name: str, - deployment_name: str, - subscription_id: str, - *, - json: JSONType = None, - content: Any = None, - **kwargs: Any + +def build_deployments_what_if_request( + resource_group_name: str, deployment_name: str, subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2020-10-01") # type: str - content_type = kwargs.pop('content_type', None) # type: Optional[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", "2020-10-01")) # type: str + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + accept = _headers.pop("Accept", "application/json") - accept = "application/json" # Construct URL - _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/Microsoft.Resources/deployments/{deploymentName}/whatIf") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/Microsoft.Resources/deployments/{deploymentName}/whatIf", + ) # pylint: disable=line-too-long path_format_arguments = { - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1), - "deploymentName": _SERIALIZER.url("deployment_name", deployment_name, 'str', max_length=64, min_length=1), - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), + "resourceGroupName": _SERIALIZER.url( + "resource_group_name", resource_group_name, "str", max_length=90, min_length=1 + ), + "deploymentName": _SERIALIZER.url("deployment_name", deployment_name, "str", max_length=64, min_length=1), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), } _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] if content_type is not None: - _header_parameters['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') - _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') - - return HttpRequest( - method="POST", - url=_url, - params=_query_parameters, - headers=_header_parameters, - json=json, - content=content, - **kwargs - ) + _headers["Content-Type"] = _SERIALIZER.header("content_type", content_type, "str") + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="POST", url=_url, params=_params, headers=_headers, **kwargs) def build_deployments_export_template_request( - resource_group_name: str, - deployment_name: str, - subscription_id: str, - **kwargs: Any + resource_group_name: str, deployment_name: str, subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2020-10-01") # type: 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", "2020-10-01")) # type: str + accept = _headers.pop("Accept", "application/json") - accept = "application/json" # Construct URL - _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/Microsoft.Resources/deployments/{deploymentName}/exportTemplate") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/Microsoft.Resources/deployments/{deploymentName}/exportTemplate", + ) # pylint: disable=line-too-long path_format_arguments = { - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1), - "deploymentName": _SERIALIZER.url("deployment_name", deployment_name, 'str', max_length=64, min_length=1), - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), + "resourceGroupName": _SERIALIZER.url( + "resource_group_name", resource_group_name, "str", max_length=90, min_length=1 + ), + "deploymentName": _SERIALIZER.url("deployment_name", deployment_name, "str", max_length=64, min_length=1), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), } _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') - - return HttpRequest( - method="POST", - url=_url, - params=_query_parameters, - headers=_header_parameters, - **kwargs - ) + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="POST", url=_url, params=_params, headers=_headers, **kwargs) def build_deployments_list_by_resource_group_request( @@ -1651,357 +1340,288 @@ def build_deployments_list_by_resource_group_request( top: Optional[int] = None, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2020-10-01") # type: 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", "2020-10-01")) # type: str + accept = _headers.pop("Accept", "application/json") - accept = "application/json" # Construct URL - _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/Microsoft.Resources/deployments/") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/Microsoft.Resources/deployments/", + ) # pylint: disable=line-too-long path_format_arguments = { - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1), - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), + "resourceGroupName": _SERIALIZER.url( + "resource_group_name", resource_group_name, "str", max_length=90, min_length=1 + ), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), } _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] if filter is not None: - _query_parameters['$filter'] = _SERIALIZER.query("filter", filter, 'str') + _params["$filter"] = _SERIALIZER.query("filter", filter, "str") if top is not None: - _query_parameters['$top'] = _SERIALIZER.query("top", top, 'int') - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["$top"] = _SERIALIZER.query("top", top, "int") + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') - - return HttpRequest( - method="GET", - url=_url, - params=_query_parameters, - headers=_header_parameters, - **kwargs - ) + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) -def build_deployments_calculate_template_hash_request( - *, - json: JSONType = None, - content: Any = None, - **kwargs: Any -) -> HttpRequest: - api_version = kwargs.pop('api_version', "2020-10-01") # type: str - content_type = kwargs.pop('content_type', None) # type: Optional[str] - accept = "application/json" +def build_deployments_calculate_template_hash_request(*, json: JSON, **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", "2020-10-01")) # type: str + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + accept = _headers.pop("Accept", "application/json") + # Construct URL _url = kwargs.pop("template_url", "/providers/Microsoft.Resources/calculateTemplateHash") # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] if content_type is not None: - _header_parameters['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') - _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') - - return HttpRequest( - method="POST", - url=_url, - params=_query_parameters, - headers=_header_parameters, - json=json, - content=content, - **kwargs - ) + _headers["Content-Type"] = _SERIALIZER.header("content_type", content_type, "str") + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="POST", url=_url, params=_params, headers=_headers, json=json, **kwargs) def build_providers_unregister_request( - resource_provider_namespace: str, - subscription_id: str, - **kwargs: Any + resource_provider_namespace: str, subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2020-10-01") # type: 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", "2020-10-01")) # type: str + accept = _headers.pop("Accept", "application/json") - accept = "application/json" # Construct URL - _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/providers/{resourceProviderNamespace}/unregister") + _url = kwargs.pop( + "template_url", "/subscriptions/{subscriptionId}/providers/{resourceProviderNamespace}/unregister" + ) path_format_arguments = { - "resourceProviderNamespace": _SERIALIZER.url("resource_provider_namespace", resource_provider_namespace, 'str'), - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), + "resourceProviderNamespace": _SERIALIZER.url("resource_provider_namespace", resource_provider_namespace, "str"), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), } _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') - - return HttpRequest( - method="POST", - url=_url, - params=_query_parameters, - headers=_header_parameters, - **kwargs - ) + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="POST", url=_url, params=_params, headers=_headers, **kwargs) def build_providers_register_at_management_group_scope_request( - resource_provider_namespace: str, - group_id: str, - **kwargs: Any + resource_provider_namespace: str, group_id: str, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2020-10-01") # type: 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", "2020-10-01")) # type: str + accept = _headers.pop("Accept", "application/json") - accept = "application/json" # Construct URL - _url = kwargs.pop("template_url", "/providers/Microsoft.Management/managementGroups/{groupId}/providers/{resourceProviderNamespace}/register") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", + "/providers/Microsoft.Management/managementGroups/{groupId}/providers/{resourceProviderNamespace}/register", + ) # pylint: disable=line-too-long path_format_arguments = { - "resourceProviderNamespace": _SERIALIZER.url("resource_provider_namespace", resource_provider_namespace, 'str'), - "groupId": _SERIALIZER.url("group_id", group_id, 'str', max_length=90, min_length=1), + "resourceProviderNamespace": _SERIALIZER.url("resource_provider_namespace", resource_provider_namespace, "str"), + "groupId": _SERIALIZER.url("group_id", group_id, "str", max_length=90, min_length=1), } _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') - - return HttpRequest( - method="POST", - url=_url, - params=_query_parameters, - headers=_header_parameters, - **kwargs - ) + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="POST", url=_url, params=_params, headers=_headers, **kwargs) def build_providers_register_request( - resource_provider_namespace: str, - subscription_id: str, - **kwargs: Any + resource_provider_namespace: str, subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2020-10-01") # type: 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", "2020-10-01")) # type: str + accept = _headers.pop("Accept", "application/json") - accept = "application/json" # Construct URL _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/providers/{resourceProviderNamespace}/register") path_format_arguments = { - "resourceProviderNamespace": _SERIALIZER.url("resource_provider_namespace", resource_provider_namespace, 'str'), - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), + "resourceProviderNamespace": _SERIALIZER.url("resource_provider_namespace", resource_provider_namespace, "str"), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), } _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') - - return HttpRequest( - method="POST", - url=_url, - params=_query_parameters, - headers=_header_parameters, - **kwargs - ) + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="POST", url=_url, params=_params, headers=_headers, **kwargs) def build_providers_list_request( - subscription_id: str, - *, - top: Optional[int] = None, - expand: Optional[str] = None, - **kwargs: Any + subscription_id: str, *, top: Optional[int] = None, expand: Optional[str] = None, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2020-10-01") # type: 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", "2020-10-01")) # type: str + accept = _headers.pop("Accept", "application/json") - accept = "application/json" # Construct URL _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/providers") path_format_arguments = { - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), } _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] if top is not None: - _query_parameters['$top'] = _SERIALIZER.query("top", top, 'int') + _params["$top"] = _SERIALIZER.query("top", top, "int") if expand is not None: - _query_parameters['$expand'] = _SERIALIZER.query("expand", expand, 'str') - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["$expand"] = _SERIALIZER.query("expand", expand, "str") + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') - - return HttpRequest( - method="GET", - url=_url, - params=_query_parameters, - headers=_header_parameters, - **kwargs - ) + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) def build_providers_list_at_tenant_scope_request( - *, - top: Optional[int] = None, - expand: Optional[str] = None, - **kwargs: Any + *, top: Optional[int] = None, expand: Optional[str] = None, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2020-10-01") # type: 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", "2020-10-01")) # type: str + accept = _headers.pop("Accept", "application/json") - accept = "application/json" # Construct URL _url = kwargs.pop("template_url", "/providers") # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] if top is not None: - _query_parameters['$top'] = _SERIALIZER.query("top", top, 'int') + _params["$top"] = _SERIALIZER.query("top", top, "int") if expand is not None: - _query_parameters['$expand'] = _SERIALIZER.query("expand", expand, 'str') - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["$expand"] = _SERIALIZER.query("expand", expand, "str") + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') - - return HttpRequest( - method="GET", - url=_url, - params=_query_parameters, - headers=_header_parameters, - **kwargs - ) + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) def build_providers_get_request( - resource_provider_namespace: str, - subscription_id: str, - *, - expand: Optional[str] = None, - **kwargs: Any + resource_provider_namespace: str, subscription_id: str, *, expand: Optional[str] = None, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2020-10-01") # type: 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", "2020-10-01")) # type: str + accept = _headers.pop("Accept", "application/json") - accept = "application/json" # Construct URL _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/providers/{resourceProviderNamespace}") path_format_arguments = { - "resourceProviderNamespace": _SERIALIZER.url("resource_provider_namespace", resource_provider_namespace, 'str'), - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), + "resourceProviderNamespace": _SERIALIZER.url("resource_provider_namespace", resource_provider_namespace, "str"), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), } _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] if expand is not None: - _query_parameters['$expand'] = _SERIALIZER.query("expand", expand, 'str') - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["$expand"] = _SERIALIZER.query("expand", expand, "str") + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') - - return HttpRequest( - method="GET", - url=_url, - params=_query_parameters, - headers=_header_parameters, - **kwargs - ) + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) def build_providers_get_at_tenant_scope_request( - resource_provider_namespace: str, - *, - expand: Optional[str] = None, - **kwargs: Any + resource_provider_namespace: str, *, expand: Optional[str] = None, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2020-10-01") # type: 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", "2020-10-01")) # type: str + accept = _headers.pop("Accept", "application/json") - accept = "application/json" # Construct URL _url = kwargs.pop("template_url", "/providers/{resourceProviderNamespace}") path_format_arguments = { - "resourceProviderNamespace": _SERIALIZER.url("resource_provider_namespace", resource_provider_namespace, 'str'), + "resourceProviderNamespace": _SERIALIZER.url("resource_provider_namespace", resource_provider_namespace, "str"), } _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] if expand is not None: - _query_parameters['$expand'] = _SERIALIZER.query("expand", expand, 'str') - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["$expand"] = _SERIALIZER.query("expand", expand, "str") + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') - - return HttpRequest( - method="GET", - url=_url, - params=_query_parameters, - headers=_header_parameters, - **kwargs - ) + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) def build_provider_resource_types_list_request( - resource_provider_namespace: str, - subscription_id: str, - *, - expand: Optional[str] = None, - **kwargs: Any + resource_provider_namespace: str, subscription_id: str, *, expand: Optional[str] = None, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2020-10-01") # type: 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", "2020-10-01")) # type: str + accept = _headers.pop("Accept", "application/json") - accept = "application/json" # Construct URL - _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/providers/{resourceProviderNamespace}/resourceTypes") + _url = kwargs.pop( + "template_url", "/subscriptions/{subscriptionId}/providers/{resourceProviderNamespace}/resourceTypes" + ) path_format_arguments = { - "resourceProviderNamespace": _SERIALIZER.url("resource_provider_namespace", resource_provider_namespace, 'str'), - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), + "resourceProviderNamespace": _SERIALIZER.url("resource_provider_namespace", resource_provider_namespace, "str"), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), } _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] if expand is not None: - _query_parameters['$expand'] = _SERIALIZER.query("expand", expand, 'str') - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["$expand"] = _SERIALIZER.query("expand", expand, "str") + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') - - return HttpRequest( - method="GET", - url=_url, - params=_query_parameters, - headers=_header_parameters, - **kwargs - ) + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) def build_resources_list_by_resource_group_request( @@ -2013,123 +1633,104 @@ def build_resources_list_by_resource_group_request( top: Optional[int] = None, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2020-10-01") # type: 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", "2020-10-01")) # type: str + accept = _headers.pop("Accept", "application/json") - accept = "application/json" # Construct URL _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/resources") path_format_arguments = { - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1), - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), + "resourceGroupName": _SERIALIZER.url( + "resource_group_name", resource_group_name, "str", max_length=90, min_length=1 + ), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), } _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] if filter is not None: - _query_parameters['$filter'] = _SERIALIZER.query("filter", filter, 'str') + _params["$filter"] = _SERIALIZER.query("filter", filter, "str") if expand is not None: - _query_parameters['$expand'] = _SERIALIZER.query("expand", expand, 'str') + _params["$expand"] = _SERIALIZER.query("expand", expand, "str") if top is not None: - _query_parameters['$top'] = _SERIALIZER.query("top", top, 'int') - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["$top"] = _SERIALIZER.query("top", top, "int") + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') - - return HttpRequest( - method="GET", - url=_url, - params=_query_parameters, - headers=_header_parameters, - **kwargs - ) + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) -def build_resources_move_resources_request_initial( - source_resource_group_name: str, - subscription_id: str, - *, - json: JSONType = None, - content: Any = None, - **kwargs: Any + +def build_resources_move_resources_request( + source_resource_group_name: str, subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2020-10-01") # type: str - content_type = kwargs.pop('content_type', None) # type: Optional[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", "2020-10-01")) # type: str + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + accept = _headers.pop("Accept", "application/json") - accept = "application/json" # Construct URL - _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{sourceResourceGroupName}/moveResources") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", "/subscriptions/{subscriptionId}/resourceGroups/{sourceResourceGroupName}/moveResources" + ) # pylint: disable=line-too-long path_format_arguments = { - "sourceResourceGroupName": _SERIALIZER.url("source_resource_group_name", source_resource_group_name, 'str', max_length=90, min_length=1), - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), + "sourceResourceGroupName": _SERIALIZER.url( + "source_resource_group_name", source_resource_group_name, "str", max_length=90, min_length=1 + ), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), } _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] if content_type is not None: - _header_parameters['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') - _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') - - return HttpRequest( - method="POST", - url=_url, - params=_query_parameters, - headers=_header_parameters, - json=json, - content=content, - **kwargs - ) + _headers["Content-Type"] = _SERIALIZER.header("content_type", content_type, "str") + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + return HttpRequest(method="POST", url=_url, params=_params, headers=_headers, **kwargs) -def build_resources_validate_move_resources_request_initial( - source_resource_group_name: str, - subscription_id: str, - *, - json: JSONType = None, - content: Any = None, - **kwargs: Any + +def build_resources_validate_move_resources_request( + source_resource_group_name: str, subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2020-10-01") # type: str - content_type = kwargs.pop('content_type', None) # type: Optional[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", "2020-10-01")) # type: str + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + accept = _headers.pop("Accept", "application/json") - accept = "application/json" # Construct URL - _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{sourceResourceGroupName}/validateMoveResources") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", "/subscriptions/{subscriptionId}/resourceGroups/{sourceResourceGroupName}/validateMoveResources" + ) # pylint: disable=line-too-long path_format_arguments = { - "sourceResourceGroupName": _SERIALIZER.url("source_resource_group_name", source_resource_group_name, 'str', max_length=90, min_length=1), - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), + "sourceResourceGroupName": _SERIALIZER.url( + "source_resource_group_name", source_resource_group_name, "str", max_length=90, min_length=1 + ), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), } _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] if content_type is not None: - _header_parameters['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') - _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') - - return HttpRequest( - method="POST", - url=_url, - params=_query_parameters, - headers=_header_parameters, - json=json, - content=content, - **kwargs - ) + _headers["Content-Type"] = _SERIALIZER.header("content_type", content_type, "str") + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="POST", url=_url, params=_params, headers=_headers, **kwargs) def build_resources_list_request( @@ -2140,38 +1741,33 @@ def build_resources_list_request( top: Optional[int] = None, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2020-10-01") # type: 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", "2020-10-01")) # type: str + accept = _headers.pop("Accept", "application/json") - accept = "application/json" # Construct URL _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resources") path_format_arguments = { - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), } _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] if filter is not None: - _query_parameters['$filter'] = _SERIALIZER.query("filter", filter, 'str') + _params["$filter"] = _SERIALIZER.query("filter", filter, "str") if expand is not None: - _query_parameters['$expand'] = _SERIALIZER.query("expand", expand, 'str') + _params["$expand"] = _SERIALIZER.query("expand", expand, "str") if top is not None: - _query_parameters['$top'] = _SERIALIZER.query("top", top, 'int') - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["$top"] = _SERIALIZER.query("top", top, "int") + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') - - return HttpRequest( - method="GET", - url=_url, - params=_query_parameters, - headers=_header_parameters, - **kwargs - ) + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) def build_resources_check_existence_request( @@ -2185,38 +1781,39 @@ def build_resources_check_existence_request( api_version: str, **kwargs: Any ) -> HttpRequest: - accept = "application/json" + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + accept = _headers.pop("Accept", "application/json") + # Construct URL - _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{parentResourcePath}/{resourceType}/{resourceName}") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{parentResourcePath}/{resourceType}/{resourceName}", + ) # pylint: disable=line-too-long path_format_arguments = { - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1), - "resourceProviderNamespace": _SERIALIZER.url("resource_provider_namespace", resource_provider_namespace, 'str'), - "parentResourcePath": _SERIALIZER.url("parent_resource_path", parent_resource_path, 'str', skip_quote=True), - "resourceType": _SERIALIZER.url("resource_type", resource_type, 'str', skip_quote=True), - "resourceName": _SERIALIZER.url("resource_name", resource_name, 'str'), - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), + "resourceGroupName": _SERIALIZER.url( + "resource_group_name", resource_group_name, "str", max_length=90, min_length=1 + ), + "resourceProviderNamespace": _SERIALIZER.url("resource_provider_namespace", resource_provider_namespace, "str"), + "parentResourcePath": _SERIALIZER.url("parent_resource_path", parent_resource_path, "str", skip_quote=True), + "resourceType": _SERIALIZER.url("resource_type", resource_type, "str", skip_quote=True), + "resourceName": _SERIALIZER.url("resource_name", resource_name, "str"), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), } _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') - - return HttpRequest( - method="HEAD", - url=_url, - params=_query_parameters, - headers=_header_parameters, - **kwargs - ) + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="HEAD", url=_url, params=_params, headers=_headers, **kwargs) -def build_resources_delete_request_initial( +def build_resources_delete_request( resource_group_name: str, resource_provider_namespace: str, parent_resource_path: str, @@ -2227,38 +1824,39 @@ def build_resources_delete_request_initial( api_version: str, **kwargs: Any ) -> HttpRequest: - accept = "application/json" + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + accept = _headers.pop("Accept", "application/json") + # Construct URL - _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{parentResourcePath}/{resourceType}/{resourceName}") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{parentResourcePath}/{resourceType}/{resourceName}", + ) # pylint: disable=line-too-long path_format_arguments = { - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1), - "resourceProviderNamespace": _SERIALIZER.url("resource_provider_namespace", resource_provider_namespace, 'str'), - "parentResourcePath": _SERIALIZER.url("parent_resource_path", parent_resource_path, 'str', skip_quote=True), - "resourceType": _SERIALIZER.url("resource_type", resource_type, 'str', skip_quote=True), - "resourceName": _SERIALIZER.url("resource_name", resource_name, 'str'), - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), + "resourceGroupName": _SERIALIZER.url( + "resource_group_name", resource_group_name, "str", max_length=90, min_length=1 + ), + "resourceProviderNamespace": _SERIALIZER.url("resource_provider_namespace", resource_provider_namespace, "str"), + "parentResourcePath": _SERIALIZER.url("parent_resource_path", parent_resource_path, "str", skip_quote=True), + "resourceType": _SERIALIZER.url("resource_type", resource_type, "str", skip_quote=True), + "resourceName": _SERIALIZER.url("resource_name", resource_name, "str"), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), } _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') - - return HttpRequest( - method="DELETE", - url=_url, - params=_query_parameters, - headers=_header_parameters, - **kwargs - ) + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="DELETE", url=_url, params=_params, headers=_headers, **kwargs) -def build_resources_create_or_update_request_initial( +def build_resources_create_or_update_request( resource_group_name: str, resource_provider_namespace: str, parent_resource_path: str, @@ -2267,48 +1865,44 @@ def build_resources_create_or_update_request_initial( subscription_id: str, *, api_version: str, - json: JSONType = None, - content: Any = None, **kwargs: Any ) -> HttpRequest: - content_type = kwargs.pop('content_type', None) # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + accept = _headers.pop("Accept", "application/json") - accept = "application/json" # Construct URL - _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{parentResourcePath}/{resourceType}/{resourceName}") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{parentResourcePath}/{resourceType}/{resourceName}", + ) # pylint: disable=line-too-long path_format_arguments = { - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1), - "resourceProviderNamespace": _SERIALIZER.url("resource_provider_namespace", resource_provider_namespace, 'str'), - "parentResourcePath": _SERIALIZER.url("parent_resource_path", parent_resource_path, 'str', skip_quote=True), - "resourceType": _SERIALIZER.url("resource_type", resource_type, 'str', skip_quote=True), - "resourceName": _SERIALIZER.url("resource_name", resource_name, 'str'), - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), + "resourceGroupName": _SERIALIZER.url( + "resource_group_name", resource_group_name, "str", max_length=90, min_length=1 + ), + "resourceProviderNamespace": _SERIALIZER.url("resource_provider_namespace", resource_provider_namespace, "str"), + "parentResourcePath": _SERIALIZER.url("parent_resource_path", parent_resource_path, "str", skip_quote=True), + "resourceType": _SERIALIZER.url("resource_type", resource_type, "str", skip_quote=True), + "resourceName": _SERIALIZER.url("resource_name", resource_name, "str"), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), } _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] if content_type is not None: - _header_parameters['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') - _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') - - return HttpRequest( - method="PUT", - url=_url, - params=_query_parameters, - headers=_header_parameters, - json=json, - content=content, - **kwargs - ) + _headers["Content-Type"] = _SERIALIZER.header("content_type", content_type, "str") + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + return HttpRequest(method="PUT", url=_url, params=_params, headers=_headers, **kwargs) -def build_resources_update_request_initial( + +def build_resources_update_request( resource_group_name: str, resource_provider_namespace: str, parent_resource_path: str, @@ -2317,45 +1911,41 @@ def build_resources_update_request_initial( subscription_id: str, *, api_version: str, - json: JSONType = None, - content: Any = None, **kwargs: Any ) -> HttpRequest: - content_type = kwargs.pop('content_type', None) # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + accept = _headers.pop("Accept", "application/json") - accept = "application/json" # Construct URL - _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{parentResourcePath}/{resourceType}/{resourceName}") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{parentResourcePath}/{resourceType}/{resourceName}", + ) # pylint: disable=line-too-long path_format_arguments = { - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1), - "resourceProviderNamespace": _SERIALIZER.url("resource_provider_namespace", resource_provider_namespace, 'str'), - "parentResourcePath": _SERIALIZER.url("parent_resource_path", parent_resource_path, 'str', skip_quote=True), - "resourceType": _SERIALIZER.url("resource_type", resource_type, 'str', skip_quote=True), - "resourceName": _SERIALIZER.url("resource_name", resource_name, 'str'), - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), + "resourceGroupName": _SERIALIZER.url( + "resource_group_name", resource_group_name, "str", max_length=90, min_length=1 + ), + "resourceProviderNamespace": _SERIALIZER.url("resource_provider_namespace", resource_provider_namespace, "str"), + "parentResourcePath": _SERIALIZER.url("parent_resource_path", parent_resource_path, "str", skip_quote=True), + "resourceType": _SERIALIZER.url("resource_type", resource_type, "str", skip_quote=True), + "resourceName": _SERIALIZER.url("resource_name", resource_name, "str"), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), } _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] if content_type is not None: - _header_parameters['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') - _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') - - return HttpRequest( - method="PATCH", - url=_url, - params=_query_parameters, - headers=_header_parameters, - json=json, - content=content, - **kwargs - ) + _headers["Content-Type"] = _SERIALIZER.header("content_type", content_type, "str") + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="PATCH", url=_url, params=_params, headers=_headers, **kwargs) def build_resources_get_request( @@ -2369,1224 +1959,972 @@ def build_resources_get_request( api_version: str, **kwargs: Any ) -> HttpRequest: - accept = "application/json" + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + accept = _headers.pop("Accept", "application/json") + # Construct URL - _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{parentResourcePath}/{resourceType}/{resourceName}") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{parentResourcePath}/{resourceType}/{resourceName}", + ) # pylint: disable=line-too-long path_format_arguments = { - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1), - "resourceProviderNamespace": _SERIALIZER.url("resource_provider_namespace", resource_provider_namespace, 'str'), - "parentResourcePath": _SERIALIZER.url("parent_resource_path", parent_resource_path, 'str', skip_quote=True), - "resourceType": _SERIALIZER.url("resource_type", resource_type, 'str', skip_quote=True), - "resourceName": _SERIALIZER.url("resource_name", resource_name, 'str'), - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), + "resourceGroupName": _SERIALIZER.url( + "resource_group_name", resource_group_name, "str", max_length=90, min_length=1 + ), + "resourceProviderNamespace": _SERIALIZER.url("resource_provider_namespace", resource_provider_namespace, "str"), + "parentResourcePath": _SERIALIZER.url("parent_resource_path", parent_resource_path, "str", skip_quote=True), + "resourceType": _SERIALIZER.url("resource_type", resource_type, "str", skip_quote=True), + "resourceName": _SERIALIZER.url("resource_name", resource_name, "str"), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), } _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') - - return HttpRequest( - method="GET", - url=_url, - params=_query_parameters, - headers=_header_parameters, - **kwargs - ) + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) + + +def build_resources_check_existence_by_id_request(resource_id: str, *, api_version: str, **kwargs: Any) -> HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + accept = _headers.pop("Accept", "application/json") -def build_resources_check_existence_by_id_request( - resource_id: str, - *, - api_version: str, - **kwargs: Any -) -> HttpRequest: - accept = "application/json" # Construct URL _url = kwargs.pop("template_url", "/{resourceId}") path_format_arguments = { - "resourceId": _SERIALIZER.url("resource_id", resource_id, 'str', skip_quote=True), + "resourceId": _SERIALIZER.url("resource_id", resource_id, "str", skip_quote=True), } _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') - - return HttpRequest( - method="HEAD", - url=_url, - params=_query_parameters, - headers=_header_parameters, - **kwargs - ) + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + return HttpRequest(method="HEAD", url=_url, params=_params, headers=_headers, **kwargs) + + +def build_resources_delete_by_id_request(resource_id: str, *, api_version: str, **kwargs: Any) -> HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + accept = _headers.pop("Accept", "application/json") -def build_resources_delete_by_id_request_initial( - resource_id: str, - *, - api_version: str, - **kwargs: Any -) -> HttpRequest: - accept = "application/json" # Construct URL _url = kwargs.pop("template_url", "/{resourceId}") path_format_arguments = { - "resourceId": _SERIALIZER.url("resource_id", resource_id, 'str', skip_quote=True), + "resourceId": _SERIALIZER.url("resource_id", resource_id, "str", skip_quote=True), } _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') - - return HttpRequest( - method="DELETE", - url=_url, - params=_query_parameters, - headers=_header_parameters, - **kwargs - ) + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + return HttpRequest(method="DELETE", url=_url, params=_params, headers=_headers, **kwargs) -def build_resources_create_or_update_by_id_request_initial( - resource_id: str, - *, - api_version: str, - json: JSONType = None, - content: Any = None, - **kwargs: Any -) -> HttpRequest: - content_type = kwargs.pop('content_type', None) # type: Optional[str] - accept = "application/json" +def build_resources_create_or_update_by_id_request(resource_id: str, *, api_version: str, **kwargs: Any) -> HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + accept = _headers.pop("Accept", "application/json") + # Construct URL _url = kwargs.pop("template_url", "/{resourceId}") path_format_arguments = { - "resourceId": _SERIALIZER.url("resource_id", resource_id, 'str', skip_quote=True), + "resourceId": _SERIALIZER.url("resource_id", resource_id, "str", skip_quote=True), } _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] if content_type is not None: - _header_parameters['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') - _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') - - return HttpRequest( - method="PUT", - url=_url, - params=_query_parameters, - headers=_header_parameters, - json=json, - content=content, - **kwargs - ) + _headers["Content-Type"] = _SERIALIZER.header("content_type", content_type, "str") + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + return HttpRequest(method="PUT", url=_url, params=_params, headers=_headers, **kwargs) -def build_resources_update_by_id_request_initial( - resource_id: str, - *, - api_version: str, - json: JSONType = None, - content: Any = None, - **kwargs: Any -) -> HttpRequest: - content_type = kwargs.pop('content_type', None) # type: Optional[str] - accept = "application/json" +def build_resources_update_by_id_request(resource_id: str, *, api_version: str, **kwargs: Any) -> HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + accept = _headers.pop("Accept", "application/json") + # Construct URL _url = kwargs.pop("template_url", "/{resourceId}") path_format_arguments = { - "resourceId": _SERIALIZER.url("resource_id", resource_id, 'str', skip_quote=True), + "resourceId": _SERIALIZER.url("resource_id", resource_id, "str", skip_quote=True), } _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] if content_type is not None: - _header_parameters['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') - _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') - - return HttpRequest( - method="PATCH", - url=_url, - params=_query_parameters, - headers=_header_parameters, - json=json, - content=content, - **kwargs - ) + _headers["Content-Type"] = _SERIALIZER.header("content_type", content_type, "str") + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + return HttpRequest(method="PATCH", url=_url, params=_params, headers=_headers, **kwargs) + + +def build_resources_get_by_id_request(resource_id: str, *, api_version: str, **kwargs: Any) -> HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + accept = _headers.pop("Accept", "application/json") -def build_resources_get_by_id_request( - resource_id: str, - *, - api_version: str, - **kwargs: Any -) -> HttpRequest: - accept = "application/json" # Construct URL _url = kwargs.pop("template_url", "/{resourceId}") path_format_arguments = { - "resourceId": _SERIALIZER.url("resource_id", resource_id, 'str', skip_quote=True), + "resourceId": _SERIALIZER.url("resource_id", resource_id, "str", skip_quote=True), } _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') - - return HttpRequest( - method="GET", - url=_url, - params=_query_parameters, - headers=_header_parameters, - **kwargs - ) + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) def build_resource_groups_check_existence_request( - resource_group_name: str, - subscription_id: str, - **kwargs: Any + resource_group_name: str, subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2020-10-01") # type: 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", "2020-10-01")) # type: str + accept = _headers.pop("Accept", "application/json") - accept = "application/json" # Construct URL _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}") path_format_arguments = { - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1), - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), + "resourceGroupName": _SERIALIZER.url( + "resource_group_name", resource_group_name, "str", max_length=90, min_length=1 + ), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), } _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') - - return HttpRequest( - method="HEAD", - url=_url, - params=_query_parameters, - headers=_header_parameters, - **kwargs - ) + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="HEAD", url=_url, params=_params, headers=_headers, **kwargs) def build_resource_groups_create_or_update_request( - resource_group_name: str, - subscription_id: str, - *, - json: JSONType = None, - content: Any = None, - **kwargs: Any + resource_group_name: str, subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2020-10-01") # type: str - content_type = kwargs.pop('content_type', None) # type: Optional[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", "2020-10-01")) # type: str + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + accept = _headers.pop("Accept", "application/json") - accept = "application/json" # Construct URL _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}") path_format_arguments = { - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1), - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), + "resourceGroupName": _SERIALIZER.url( + "resource_group_name", resource_group_name, "str", max_length=90, min_length=1 + ), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), } _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] if content_type is not None: - _header_parameters['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') - _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') - - return HttpRequest( - method="PUT", - url=_url, - params=_query_parameters, - headers=_header_parameters, - json=json, - content=content, - **kwargs - ) + _headers["Content-Type"] = _SERIALIZER.header("content_type", content_type, "str") + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + return HttpRequest(method="PUT", url=_url, params=_params, headers=_headers, **kwargs) -def build_resource_groups_delete_request_initial( - resource_group_name: str, - subscription_id: str, - **kwargs: Any -) -> HttpRequest: - api_version = kwargs.pop('api_version', "2020-10-01") # type: str - accept = "application/json" +def build_resource_groups_delete_request(resource_group_name: str, subscription_id: str, **kwargs: Any) -> HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2020-10-01")) # type: str + accept = _headers.pop("Accept", "application/json") + # Construct URL _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}") path_format_arguments = { - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1), - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), + "resourceGroupName": _SERIALIZER.url( + "resource_group_name", resource_group_name, "str", max_length=90, min_length=1 + ), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), } _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') - - return HttpRequest( - method="DELETE", - url=_url, - params=_query_parameters, - headers=_header_parameters, - **kwargs - ) + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + return HttpRequest(method="DELETE", url=_url, params=_params, headers=_headers, **kwargs) -def build_resource_groups_get_request( - resource_group_name: str, - subscription_id: str, - **kwargs: Any -) -> HttpRequest: - api_version = kwargs.pop('api_version', "2020-10-01") # type: str - accept = "application/json" +def build_resource_groups_get_request(resource_group_name: str, subscription_id: str, **kwargs: Any) -> HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2020-10-01")) # type: str + accept = _headers.pop("Accept", "application/json") + # Construct URL _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}") path_format_arguments = { - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1), - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), + "resourceGroupName": _SERIALIZER.url( + "resource_group_name", resource_group_name, "str", max_length=90, min_length=1 + ), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), } _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') - - return HttpRequest( - method="GET", - url=_url, - params=_query_parameters, - headers=_header_parameters, - **kwargs - ) + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) -def build_resource_groups_update_request( - resource_group_name: str, - subscription_id: str, - *, - json: JSONType = None, - content: Any = None, - **kwargs: Any -) -> HttpRequest: - api_version = kwargs.pop('api_version', "2020-10-01") # type: str - content_type = kwargs.pop('content_type', None) # type: Optional[str] - accept = "application/json" +def build_resource_groups_update_request(resource_group_name: str, subscription_id: str, **kwargs: Any) -> HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2020-10-01")) # type: str + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + accept = _headers.pop("Accept", "application/json") + # Construct URL _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}") path_format_arguments = { - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1), - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), + "resourceGroupName": _SERIALIZER.url( + "resource_group_name", resource_group_name, "str", max_length=90, min_length=1 + ), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), } _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] if content_type is not None: - _header_parameters['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') - _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') - - return HttpRequest( - method="PATCH", - url=_url, - params=_query_parameters, - headers=_header_parameters, - json=json, - content=content, - **kwargs - ) + _headers["Content-Type"] = _SERIALIZER.header("content_type", content_type, "str") + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + return HttpRequest(method="PATCH", url=_url, params=_params, headers=_headers, **kwargs) -def build_resource_groups_export_template_request_initial( - subscription_id: str, - resource_group_name: str, - *, - json: JSONType = None, - content: Any = None, - **kwargs: Any + +def build_resource_groups_export_template_request( + resource_group_name: str, subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2020-10-01") # type: str - content_type = kwargs.pop('content_type', None) # type: Optional[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", "2020-10-01")) # type: str + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + accept = _headers.pop("Accept", "application/json") - accept = "application/json" # Construct URL - _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/exportTemplate") + _url = kwargs.pop( + "template_url", "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/exportTemplate" + ) path_format_arguments = { - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url( + "resource_group_name", resource_group_name, "str", max_length=90, min_length=1 + ), } _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] if content_type is not None: - _header_parameters['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') - _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') - - return HttpRequest( - method="POST", - url=_url, - params=_query_parameters, - headers=_header_parameters, - json=json, - content=content, - **kwargs - ) + _headers["Content-Type"] = _SERIALIZER.header("content_type", content_type, "str") + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="POST", url=_url, params=_params, headers=_headers, **kwargs) def build_resource_groups_list_request( - subscription_id: str, - *, - filter: Optional[str] = None, - top: Optional[int] = None, - **kwargs: Any + subscription_id: str, *, filter: Optional[str] = None, top: Optional[int] = None, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2020-10-01") # type: 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", "2020-10-01")) # type: str + accept = _headers.pop("Accept", "application/json") - accept = "application/json" # Construct URL _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourcegroups") path_format_arguments = { - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), } _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] if filter is not None: - _query_parameters['$filter'] = _SERIALIZER.query("filter", filter, 'str') + _params["$filter"] = _SERIALIZER.query("filter", filter, "str") if top is not None: - _query_parameters['$top'] = _SERIALIZER.query("top", top, 'int') - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["$top"] = _SERIALIZER.query("top", top, "int") + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') - - return HttpRequest( - method="GET", - url=_url, - params=_query_parameters, - headers=_header_parameters, - **kwargs - ) + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) -def build_tags_delete_value_request( - tag_name: str, - tag_value: str, - subscription_id: str, - **kwargs: Any -) -> HttpRequest: - api_version = kwargs.pop('api_version', "2020-10-01") # type: str - accept = "application/json" +def build_tags_delete_value_request(tag_name: str, tag_value: str, subscription_id: str, **kwargs: Any) -> HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2020-10-01")) # type: str + accept = _headers.pop("Accept", "application/json") + # Construct URL _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/tagNames/{tagName}/tagValues/{tagValue}") path_format_arguments = { - "tagName": _SERIALIZER.url("tag_name", tag_name, 'str'), - "tagValue": _SERIALIZER.url("tag_value", tag_value, 'str'), - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), + "tagName": _SERIALIZER.url("tag_name", tag_name, "str"), + "tagValue": _SERIALIZER.url("tag_value", tag_value, "str"), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), } _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') - - return HttpRequest( - method="DELETE", - url=_url, - params=_query_parameters, - headers=_header_parameters, - **kwargs - ) + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="DELETE", url=_url, params=_params, headers=_headers, **kwargs) def build_tags_create_or_update_value_request( - tag_name: str, - tag_value: str, - subscription_id: str, - **kwargs: Any + tag_name: str, tag_value: str, subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2020-10-01") # type: 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", "2020-10-01")) # type: str + accept = _headers.pop("Accept", "application/json") - accept = "application/json" # Construct URL _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/tagNames/{tagName}/tagValues/{tagValue}") path_format_arguments = { - "tagName": _SERIALIZER.url("tag_name", tag_name, 'str'), - "tagValue": _SERIALIZER.url("tag_value", tag_value, 'str'), - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), + "tagName": _SERIALIZER.url("tag_name", tag_name, "str"), + "tagValue": _SERIALIZER.url("tag_value", tag_value, "str"), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), } _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') - - return HttpRequest( - method="PUT", - url=_url, - params=_query_parameters, - headers=_header_parameters, - **kwargs - ) + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + return HttpRequest(method="PUT", url=_url, params=_params, headers=_headers, **kwargs) -def build_tags_create_or_update_request( - tag_name: str, - subscription_id: str, - **kwargs: Any -) -> HttpRequest: - api_version = kwargs.pop('api_version', "2020-10-01") # type: str - accept = "application/json" +def build_tags_create_or_update_request(tag_name: str, subscription_id: str, **kwargs: Any) -> HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2020-10-01")) # type: str + accept = _headers.pop("Accept", "application/json") + # Construct URL _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/tagNames/{tagName}") path_format_arguments = { - "tagName": _SERIALIZER.url("tag_name", tag_name, 'str'), - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), + "tagName": _SERIALIZER.url("tag_name", tag_name, "str"), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), } _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') - - return HttpRequest( - method="PUT", - url=_url, - params=_query_parameters, - headers=_header_parameters, - **kwargs - ) + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + return HttpRequest(method="PUT", url=_url, params=_params, headers=_headers, **kwargs) -def build_tags_delete_request( - tag_name: str, - subscription_id: str, - **kwargs: Any -) -> HttpRequest: - api_version = kwargs.pop('api_version', "2020-10-01") # type: str - accept = "application/json" +def build_tags_delete_request(tag_name: str, subscription_id: str, **kwargs: Any) -> HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2020-10-01")) # type: str + accept = _headers.pop("Accept", "application/json") + # Construct URL _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/tagNames/{tagName}") path_format_arguments = { - "tagName": _SERIALIZER.url("tag_name", tag_name, 'str'), - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), + "tagName": _SERIALIZER.url("tag_name", tag_name, "str"), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), } _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') - - return HttpRequest( - method="DELETE", - url=_url, - params=_query_parameters, - headers=_header_parameters, - **kwargs - ) + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + return HttpRequest(method="DELETE", url=_url, params=_params, headers=_headers, **kwargs) -def build_tags_list_request( - subscription_id: str, - **kwargs: Any -) -> HttpRequest: - api_version = kwargs.pop('api_version', "2020-10-01") # type: str - accept = "application/json" +def build_tags_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", "2020-10-01")) # type: str + accept = _headers.pop("Accept", "application/json") + # Construct URL _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/tagNames") path_format_arguments = { - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), } _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') - - return HttpRequest( - method="GET", - url=_url, - params=_query_parameters, - headers=_header_parameters, - **kwargs - ) + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) -def build_tags_create_or_update_at_scope_request( - scope: str, - *, - json: JSONType = None, - content: Any = None, - **kwargs: Any -) -> HttpRequest: - api_version = kwargs.pop('api_version', "2020-10-01") # type: str - content_type = kwargs.pop('content_type', None) # type: Optional[str] - accept = "application/json" +def build_tags_create_or_update_at_scope_request(scope: 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", "2020-10-01")) # type: str + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + accept = _headers.pop("Accept", "application/json") + # Construct URL _url = kwargs.pop("template_url", "/{scope}/providers/Microsoft.Resources/tags/default") path_format_arguments = { - "scope": _SERIALIZER.url("scope", scope, 'str', skip_quote=True), + "scope": _SERIALIZER.url("scope", scope, "str", skip_quote=True), } _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] if content_type is not None: - _header_parameters['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') - _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') - - return HttpRequest( - method="PUT", - url=_url, - params=_query_parameters, - headers=_header_parameters, - json=json, - content=content, - **kwargs - ) + _headers["Content-Type"] = _SERIALIZER.header("content_type", content_type, "str") + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + return HttpRequest(method="PUT", url=_url, params=_params, headers=_headers, **kwargs) -def build_tags_update_at_scope_request( - scope: str, - *, - json: JSONType = None, - content: Any = None, - **kwargs: Any -) -> HttpRequest: - api_version = kwargs.pop('api_version', "2020-10-01") # type: str - content_type = kwargs.pop('content_type', None) # type: Optional[str] - accept = "application/json" +def build_tags_update_at_scope_request(scope: 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", "2020-10-01")) # type: str + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + accept = _headers.pop("Accept", "application/json") + # Construct URL _url = kwargs.pop("template_url", "/{scope}/providers/Microsoft.Resources/tags/default") path_format_arguments = { - "scope": _SERIALIZER.url("scope", scope, 'str', skip_quote=True), + "scope": _SERIALIZER.url("scope", scope, "str", skip_quote=True), } _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] if content_type is not None: - _header_parameters['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') - _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') - - return HttpRequest( - method="PATCH", - url=_url, - params=_query_parameters, - headers=_header_parameters, - json=json, - content=content, - **kwargs - ) + _headers["Content-Type"] = _SERIALIZER.header("content_type", content_type, "str") + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + return HttpRequest(method="PATCH", url=_url, params=_params, headers=_headers, **kwargs) -def build_tags_get_at_scope_request( - scope: str, - **kwargs: Any -) -> HttpRequest: - api_version = kwargs.pop('api_version', "2020-10-01") # type: str - accept = "application/json" +def build_tags_get_at_scope_request(scope: 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", "2020-10-01")) # type: str + accept = _headers.pop("Accept", "application/json") + # Construct URL _url = kwargs.pop("template_url", "/{scope}/providers/Microsoft.Resources/tags/default") path_format_arguments = { - "scope": _SERIALIZER.url("scope", scope, 'str', skip_quote=True), + "scope": _SERIALIZER.url("scope", scope, "str", skip_quote=True), } _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') - - return HttpRequest( - method="GET", - url=_url, - params=_query_parameters, - headers=_header_parameters, - **kwargs - ) + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) -def build_tags_delete_at_scope_request( - scope: str, - **kwargs: Any -) -> HttpRequest: - api_version = kwargs.pop('api_version', "2020-10-01") # type: str - accept = "application/json" +def build_tags_delete_at_scope_request(scope: 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", "2020-10-01")) # type: str + accept = _headers.pop("Accept", "application/json") + # Construct URL _url = kwargs.pop("template_url", "/{scope}/providers/Microsoft.Resources/tags/default") path_format_arguments = { - "scope": _SERIALIZER.url("scope", scope, 'str', skip_quote=True), + "scope": _SERIALIZER.url("scope", scope, "str", skip_quote=True), } _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') - - return HttpRequest( - method="DELETE", - url=_url, - params=_query_parameters, - headers=_header_parameters, - **kwargs - ) + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="DELETE", url=_url, params=_params, headers=_headers, **kwargs) def build_deployment_operations_get_at_scope_request( - scope: str, - deployment_name: str, - operation_id: str, - **kwargs: Any + scope: str, deployment_name: str, operation_id: str, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2020-10-01") # type: 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", "2020-10-01")) # type: str + accept = _headers.pop("Accept", "application/json") - accept = "application/json" # Construct URL - _url = kwargs.pop("template_url", "/{scope}/providers/Microsoft.Resources/deployments/{deploymentName}/operations/{operationId}") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", "/{scope}/providers/Microsoft.Resources/deployments/{deploymentName}/operations/{operationId}" + ) # pylint: disable=line-too-long path_format_arguments = { - "scope": _SERIALIZER.url("scope", scope, 'str', skip_quote=True), - "deploymentName": _SERIALIZER.url("deployment_name", deployment_name, 'str', max_length=64, min_length=1), - "operationId": _SERIALIZER.url("operation_id", operation_id, 'str'), + "scope": _SERIALIZER.url("scope", scope, "str", skip_quote=True), + "deploymentName": _SERIALIZER.url("deployment_name", deployment_name, "str", max_length=64, min_length=1), + "operationId": _SERIALIZER.url("operation_id", operation_id, "str"), } _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') - - return HttpRequest( - method="GET", - url=_url, - params=_query_parameters, - headers=_header_parameters, - **kwargs - ) + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) def build_deployment_operations_list_at_scope_request( - scope: str, - deployment_name: str, - *, - top: Optional[int] = None, - **kwargs: Any + scope: str, deployment_name: str, *, top: Optional[int] = None, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2020-10-01") # type: 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", "2020-10-01")) # type: str + accept = _headers.pop("Accept", "application/json") - accept = "application/json" # Construct URL _url = kwargs.pop("template_url", "/{scope}/providers/Microsoft.Resources/deployments/{deploymentName}/operations") path_format_arguments = { - "scope": _SERIALIZER.url("scope", scope, 'str', skip_quote=True), - "deploymentName": _SERIALIZER.url("deployment_name", deployment_name, 'str', max_length=64, min_length=1), + "scope": _SERIALIZER.url("scope", scope, "str", skip_quote=True), + "deploymentName": _SERIALIZER.url("deployment_name", deployment_name, "str", max_length=64, min_length=1), } _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] if top is not None: - _query_parameters['$top'] = _SERIALIZER.query("top", top, 'int') - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["$top"] = _SERIALIZER.query("top", top, "int") + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') - - return HttpRequest( - method="GET", - url=_url, - params=_query_parameters, - headers=_header_parameters, - **kwargs - ) + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) def build_deployment_operations_get_at_tenant_scope_request( - deployment_name: str, - operation_id: str, - **kwargs: Any + deployment_name: str, operation_id: str, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2020-10-01") # type: 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", "2020-10-01")) # type: str + accept = _headers.pop("Accept", "application/json") - accept = "application/json" # Construct URL - _url = kwargs.pop("template_url", "/providers/Microsoft.Resources/deployments/{deploymentName}/operations/{operationId}") + _url = kwargs.pop( + "template_url", "/providers/Microsoft.Resources/deployments/{deploymentName}/operations/{operationId}" + ) path_format_arguments = { - "deploymentName": _SERIALIZER.url("deployment_name", deployment_name, 'str', max_length=64, min_length=1), - "operationId": _SERIALIZER.url("operation_id", operation_id, 'str'), + "deploymentName": _SERIALIZER.url("deployment_name", deployment_name, "str", max_length=64, min_length=1), + "operationId": _SERIALIZER.url("operation_id", operation_id, "str"), } _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') - - return HttpRequest( - method="GET", - url=_url, - params=_query_parameters, - headers=_header_parameters, - **kwargs - ) + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) def build_deployment_operations_list_at_tenant_scope_request( - deployment_name: str, - *, - top: Optional[int] = None, - **kwargs: Any + deployment_name: str, *, top: Optional[int] = None, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2020-10-01") # type: 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", "2020-10-01")) # type: str + accept = _headers.pop("Accept", "application/json") - accept = "application/json" # Construct URL _url = kwargs.pop("template_url", "/providers/Microsoft.Resources/deployments/{deploymentName}/operations") path_format_arguments = { - "deploymentName": _SERIALIZER.url("deployment_name", deployment_name, 'str', max_length=64, min_length=1), + "deploymentName": _SERIALIZER.url("deployment_name", deployment_name, "str", max_length=64, min_length=1), } _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] if top is not None: - _query_parameters['$top'] = _SERIALIZER.query("top", top, 'int') - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["$top"] = _SERIALIZER.query("top", top, "int") + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') - - return HttpRequest( - method="GET", - url=_url, - params=_query_parameters, - headers=_header_parameters, - **kwargs - ) + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) def build_deployment_operations_get_at_management_group_scope_request( - group_id: str, - deployment_name: str, - operation_id: str, - **kwargs: Any + group_id: str, deployment_name: str, operation_id: str, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2020-10-01") # type: 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", "2020-10-01")) # type: str + accept = _headers.pop("Accept", "application/json") - accept = "application/json" # Construct URL - _url = kwargs.pop("template_url", "/providers/Microsoft.Management/managementGroups/{groupId}/providers/Microsoft.Resources/deployments/{deploymentName}/operations/{operationId}") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", + "/providers/Microsoft.Management/managementGroups/{groupId}/providers/Microsoft.Resources/deployments/{deploymentName}/operations/{operationId}", + ) # pylint: disable=line-too-long path_format_arguments = { - "groupId": _SERIALIZER.url("group_id", group_id, 'str', max_length=90, min_length=1), - "deploymentName": _SERIALIZER.url("deployment_name", deployment_name, 'str', max_length=64, min_length=1), - "operationId": _SERIALIZER.url("operation_id", operation_id, 'str'), + "groupId": _SERIALIZER.url("group_id", group_id, "str", max_length=90, min_length=1), + "deploymentName": _SERIALIZER.url("deployment_name", deployment_name, "str", max_length=64, min_length=1), + "operationId": _SERIALIZER.url("operation_id", operation_id, "str"), } _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') - - return HttpRequest( - method="GET", - url=_url, - params=_query_parameters, - headers=_header_parameters, - **kwargs - ) + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) def build_deployment_operations_list_at_management_group_scope_request( - group_id: str, - deployment_name: str, - *, - top: Optional[int] = None, - **kwargs: Any + group_id: str, deployment_name: str, *, top: Optional[int] = None, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2020-10-01") # type: 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", "2020-10-01")) # type: str + accept = _headers.pop("Accept", "application/json") - accept = "application/json" # Construct URL - _url = kwargs.pop("template_url", "/providers/Microsoft.Management/managementGroups/{groupId}/providers/Microsoft.Resources/deployments/{deploymentName}/operations") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", + "/providers/Microsoft.Management/managementGroups/{groupId}/providers/Microsoft.Resources/deployments/{deploymentName}/operations", + ) # pylint: disable=line-too-long path_format_arguments = { - "groupId": _SERIALIZER.url("group_id", group_id, 'str', max_length=90, min_length=1), - "deploymentName": _SERIALIZER.url("deployment_name", deployment_name, 'str', max_length=64, min_length=1), + "groupId": _SERIALIZER.url("group_id", group_id, "str", max_length=90, min_length=1), + "deploymentName": _SERIALIZER.url("deployment_name", deployment_name, "str", max_length=64, min_length=1), } _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] if top is not None: - _query_parameters['$top'] = _SERIALIZER.query("top", top, 'int') - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["$top"] = _SERIALIZER.query("top", top, "int") + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') - - return HttpRequest( - method="GET", - url=_url, - params=_query_parameters, - headers=_header_parameters, - **kwargs - ) + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) def build_deployment_operations_get_at_subscription_scope_request( - deployment_name: str, - operation_id: str, - subscription_id: str, - **kwargs: Any + deployment_name: str, operation_id: str, subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2020-10-01") # type: 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", "2020-10-01")) # type: str + accept = _headers.pop("Accept", "application/json") - accept = "application/json" # Construct URL - _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/providers/Microsoft.Resources/deployments/{deploymentName}/operations/{operationId}") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/providers/Microsoft.Resources/deployments/{deploymentName}/operations/{operationId}", + ) # pylint: disable=line-too-long path_format_arguments = { - "deploymentName": _SERIALIZER.url("deployment_name", deployment_name, 'str', max_length=64, min_length=1), - "operationId": _SERIALIZER.url("operation_id", operation_id, 'str'), - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), + "deploymentName": _SERIALIZER.url("deployment_name", deployment_name, "str", max_length=64, min_length=1), + "operationId": _SERIALIZER.url("operation_id", operation_id, "str"), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), } _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') - - return HttpRequest( - method="GET", - url=_url, - params=_query_parameters, - headers=_header_parameters, - **kwargs - ) + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) def build_deployment_operations_list_at_subscription_scope_request( - deployment_name: str, - subscription_id: str, - *, - top: Optional[int] = None, - **kwargs: Any + deployment_name: str, subscription_id: str, *, top: Optional[int] = None, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2020-10-01") # type: 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", "2020-10-01")) # type: str + accept = _headers.pop("Accept", "application/json") - accept = "application/json" # Construct URL - _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/providers/Microsoft.Resources/deployments/{deploymentName}/operations") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/providers/Microsoft.Resources/deployments/{deploymentName}/operations", + ) # pylint: disable=line-too-long path_format_arguments = { - "deploymentName": _SERIALIZER.url("deployment_name", deployment_name, 'str', max_length=64, min_length=1), - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), + "deploymentName": _SERIALIZER.url("deployment_name", deployment_name, "str", max_length=64, min_length=1), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), } _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] if top is not None: - _query_parameters['$top'] = _SERIALIZER.query("top", top, 'int') - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["$top"] = _SERIALIZER.query("top", top, "int") + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') - - return HttpRequest( - method="GET", - url=_url, - params=_query_parameters, - headers=_header_parameters, - **kwargs - ) + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) def build_deployment_operations_get_request( - resource_group_name: str, - deployment_name: str, - operation_id: str, - subscription_id: str, - **kwargs: Any + resource_group_name: str, deployment_name: str, operation_id: str, subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2020-10-01") # type: 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", "2020-10-01")) # type: str + accept = _headers.pop("Accept", "application/json") - accept = "application/json" # Construct URL - _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/deployments/{deploymentName}/operations/{operationId}") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/deployments/{deploymentName}/operations/{operationId}", + ) # pylint: disable=line-too-long path_format_arguments = { - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1), - "deploymentName": _SERIALIZER.url("deployment_name", deployment_name, 'str', max_length=64, min_length=1), - "operationId": _SERIALIZER.url("operation_id", operation_id, 'str'), - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), + "resourceGroupName": _SERIALIZER.url( + "resource_group_name", resource_group_name, "str", max_length=90, min_length=1 + ), + "deploymentName": _SERIALIZER.url("deployment_name", deployment_name, "str", max_length=64, min_length=1), + "operationId": _SERIALIZER.url("operation_id", operation_id, "str"), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), } _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') - - return HttpRequest( - method="GET", - url=_url, - params=_query_parameters, - headers=_header_parameters, - **kwargs - ) + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) def build_deployment_operations_list_request( - resource_group_name: str, - deployment_name: str, - subscription_id: str, - *, - top: Optional[int] = None, - **kwargs: Any + resource_group_name: str, deployment_name: str, subscription_id: str, *, top: Optional[int] = None, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2020-10-01") # type: 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", "2020-10-01")) # type: str + accept = _headers.pop("Accept", "application/json") - accept = "application/json" # Construct URL - _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/deployments/{deploymentName}/operations") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/deployments/{deploymentName}/operations", + ) # pylint: disable=line-too-long path_format_arguments = { - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1), - "deploymentName": _SERIALIZER.url("deployment_name", deployment_name, 'str', max_length=64, min_length=1), - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), + "resourceGroupName": _SERIALIZER.url( + "resource_group_name", resource_group_name, "str", max_length=90, min_length=1 + ), + "deploymentName": _SERIALIZER.url("deployment_name", deployment_name, "str", max_length=64, min_length=1), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), } _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] if top is not None: - _query_parameters['$top'] = _SERIALIZER.query("top", top, 'int') - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["$top"] = _SERIALIZER.query("top", top, "int") + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') - - return HttpRequest( - method="GET", - url=_url, - params=_query_parameters, - headers=_header_parameters, - **kwargs - ) + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") -class Operations(object): - """Operations operations. + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) - You should not instantiate this class directly. Instead, you should create a Client instance that - instantiates it for you and attaches it as an attribute. - :ivar models: Alias to model classes used in this operation group. - :type models: ~azure.mgmt.resource.resources.v2020_10_01.models - :param client: Client for service requests. - :param config: Configuration of service client. - :param serializer: An object model serializer. - :param deserializer: An object model deserializer. +class Operations: + """ + .. warning:: + **DO NOT** instantiate this class directly. + + Instead, you should access the following operations through + :class:`~azure.mgmt.resource.resources.v2020_10_01.ResourceManagementClient`'s + :attr:`operations` attribute. """ models = _models - def __init__(self, client, config, serializer, deserializer): - self._client = client - self._serialize = serializer - self._deserialize = deserializer - self._config = config + def __init__(self, *args, **kwargs): + input_args = list(args) + self._client = input_args.pop(0) if input_args else kwargs.pop("client") + self._config = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") @distributed_trace - def list( - self, - **kwargs: Any - ) -> Iterable["_models.OperationListResult"]: + def list(self, **kwargs: Any) -> Iterable["_models.Operation"]: """Lists all of the available Microsoft.Resources REST API operations. :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either OperationListResult or the result of cls(response) + :return: An iterator like instance of either Operation or the result of cls(response) :rtype: - ~azure.core.paging.ItemPaged[~azure.mgmt.resource.resources.v2020_10_01.models.OperationListResult] - :raises: ~azure.core.exceptions.HttpResponseError + ~azure.core.paging.ItemPaged[~azure.mgmt.resource.resources.v2020_10_01.models.Operation] + :raises ~azure.core.exceptions.HttpResponseError: """ - api_version = kwargs.pop('api_version', "2020-10-01") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2020-10-01")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[_models.OperationListResult] - cls = kwargs.pop('cls', None) # type: ClsType["_models.OperationListResult"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) + def prepare_request(next_link=None): if not next_link: - + request = build_operations_list_request( api_version=api_version, - template_url=self.list.metadata['url'], + template_url=self.list.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore else: - - request = build_operations_list_request( - template_url=next_link, - ) + # make call to next link with the client's api-version + _parsed_next_link = urlparse(next_link) + _next_request_params = case_insensitive_dict(parse_qs(_parsed_next_link.query)) + _next_request_params["api-version"] = self._config.api_version + request = HttpRequest("GET", urljoin(next_link, _parsed_next_link.path), params=_next_request_params) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore request.method = "GET" return request @@ -3600,10 +2938,8 @@ def extract_data(pipeline_response): def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) response = pipeline_response.http_response @@ -3613,62 +2949,62 @@ def get_next(next_link=None): return pipeline_response + return ItemPaged(get_next, extract_data) - return ItemPaged( - get_next, extract_data - ) - list.metadata = {'url': "/providers/Microsoft.Resources/operations"} # type: ignore -class DeploymentsOperations(object): # pylint: disable=too-many-public-methods - """DeploymentsOperations operations. + list.metadata = {"url": "/providers/Microsoft.Resources/operations"} # type: ignore - You should not instantiate this class directly. Instead, you should create a Client instance that - instantiates it for you and attaches it as an attribute. - :ivar models: Alias to model classes used in this operation group. - :type models: ~azure.mgmt.resource.resources.v2020_10_01.models - :param client: Client for service requests. - :param config: Configuration of service client. - :param serializer: An object model serializer. - :param deserializer: An object model deserializer. +class DeploymentsOperations: # pylint: disable=too-many-public-methods + """ + .. warning:: + **DO NOT** instantiate this class directly. + + Instead, you should access the following operations through + :class:`~azure.mgmt.resource.resources.v2020_10_01.ResourceManagementClient`'s + :attr:`deployments` attribute. """ models = _models - def __init__(self, client, config, serializer, deserializer): - self._client = client - self._serialize = serializer - self._deserialize = deserializer - self._config = config + def __init__(self, *args, **kwargs): + input_args = list(args) + self._client = input_args.pop(0) if input_args else kwargs.pop("client") + self._config = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") def _delete_at_scope_initial( # pylint: disable=inconsistent-return-statements - self, - scope: str, - deployment_name: str, - **kwargs: Any + self, scope: str, deployment_name: str, **kwargs: Any ) -> None: - cls = kwargs.pop('cls', None) # type: ClsType[None] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) - api_version = kwargs.pop('api_version', "2020-10-01") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - request = build_deployments_delete_at_scope_request_initial( + api_version = kwargs.pop("api_version", _params.pop("api-version", "2020-10-01")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[None] + + request = build_deployments_delete_at_scope_request( scope=scope, deployment_name=deployment_name, api_version=api_version, - template_url=self._delete_at_scope_initial.metadata['url'], + template_url=self._delete_at_scope_initial.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [202, 204]: @@ -3678,16 +3014,10 @@ def _delete_at_scope_initial( # pylint: disable=inconsistent-return-statements if cls: return cls(pipeline_response, None, {}) - _delete_at_scope_initial.metadata = {'url': "/{scope}/providers/Microsoft.Resources/deployments/{deploymentName}"} # type: ignore - + _delete_at_scope_initial.metadata = {"url": "/{scope}/providers/Microsoft.Resources/deployments/{deploymentName}"} # type: ignore @distributed_trace - def begin_delete_at_scope( # pylint: disable=inconsistent-return-statements - self, - scope: str, - deployment_name: str, - **kwargs: Any - ) -> LROPoller[None]: + def begin_delete_at_scope(self, scope: str, deployment_name: str, **kwargs: Any) -> LROPoller[None]: """Deletes a deployment from the deployment history. A template deployment that is currently running cannot be deleted. Deleting a template @@ -3698,9 +3028,9 @@ def begin_delete_at_scope( # pylint: disable=inconsistent-return-statements process finishes, the URI in the Location header returns a status of 204 on success. If the asynchronous request failed, the URI in the Location header returns an error-level status code. - :param scope: The resource scope. + :param scope: The resource scope. Required. :type scope: str - :param deployment_name: The name of the deployment. + :param deployment_name: The name of the deployment. Required. :type deployment_name: str :keyword callable cls: A custom type or function that will be passed the direct response :keyword str continuation_token: A continuation token to restart a poller from a saved state. @@ -3712,86 +3042,91 @@ def begin_delete_at_scope( # pylint: disable=inconsistent-return-statements Retry-After header is present. :return: An instance of LROPoller that returns either None or the result of cls(response) :rtype: ~azure.core.polling.LROPoller[None] - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - api_version = kwargs.pop('api_version', "2020-10-01") # type: str - polling = kwargs.pop('polling', True) # type: Union[bool, PollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType[None] - lro_delay = kwargs.pop( - 'polling_interval', - self._config.polling_interval - ) - cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2020-10-01")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[None] + polling = kwargs.pop("polling", True) # type: Union[bool, PollingMethod] + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token = kwargs.pop("continuation_token", None) # type: Optional[str] if cont_token is None: - raw_result = self._delete_at_scope_initial( + raw_result = self._delete_at_scope_initial( # type: ignore scope=scope, deployment_name=deployment_name, api_version=api_version, - cls=lambda x,y,z: x, + cls=lambda x, y, z: x, + headers=_headers, + params=_params, **kwargs ) - kwargs.pop('error_map', None) + kwargs.pop("error_map", None) - def get_long_running_output(pipeline_response): + def get_long_running_output(pipeline_response): # pylint: disable=inconsistent-return-statements if cls: return cls(pipeline_response, None, {}) - - if polling is True: polling_method = ARMPolling(lro_delay, **kwargs) - elif polling is False: polling_method = NoPolling() - else: polling_method = polling + if polling is True: + polling_method = cast(PollingMethod, ARMPolling(lro_delay, **kwargs)) # type: PollingMethod + elif polling is False: + polling_method = cast(PollingMethod, NoPolling()) + else: + polling_method = polling if cont_token: return LROPoller.from_continuation_token( polling_method=polling_method, continuation_token=cont_token, client=self._client, - deserialization_callback=get_long_running_output + deserialization_callback=get_long_running_output, ) return LROPoller(self._client, raw_result, get_long_running_output, polling_method) - begin_delete_at_scope.metadata = {'url': "/{scope}/providers/Microsoft.Resources/deployments/{deploymentName}"} # type: ignore + begin_delete_at_scope.metadata = {"url": "/{scope}/providers/Microsoft.Resources/deployments/{deploymentName}"} # type: ignore @distributed_trace - def check_existence_at_scope( - self, - scope: str, - deployment_name: str, - **kwargs: Any - ) -> bool: + def check_existence_at_scope(self, scope: str, deployment_name: str, **kwargs: Any) -> bool: """Checks whether the deployment exists. - :param scope: The resource scope. + :param scope: The resource scope. Required. :type scope: str - :param deployment_name: The name of the deployment. + :param deployment_name: The name of the deployment. Required. :type deployment_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: bool, or the result of cls(response) + :return: bool or the result of cls(response) :rtype: bool - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType[None] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) - api_version = kwargs.pop('api_version', "2020-10-01") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2020-10-01")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[None] - request = build_deployments_check_existence_at_scope_request( scope=scope, deployment_name=deployment_name, api_version=api_version, - template_url=self.check_existence_at_scope.metadata['url'], + template_url=self.check_existence_at_scope.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [204, 404]: @@ -3802,43 +3137,52 @@ def check_existence_at_scope( return cls(pipeline_response, None, {}) return 200 <= response.status_code <= 299 - check_existence_at_scope.metadata = {'url': "/{scope}/providers/Microsoft.Resources/deployments/{deploymentName}"} # type: ignore - + check_existence_at_scope.metadata = {"url": "/{scope}/providers/Microsoft.Resources/deployments/{deploymentName}"} # type: ignore def _create_or_update_at_scope_initial( - self, - scope: str, - deployment_name: str, - parameters: "_models.Deployment", - **kwargs: Any - ) -> "_models.DeploymentExtended": - cls = kwargs.pop('cls', None) # type: ClsType["_models.DeploymentExtended"] + self, scope: str, deployment_name: str, parameters: Union[_models.Deployment, IO], **kwargs: Any + ) -> _models.DeploymentExtended: error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', "2020-10-01") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + api_version = kwargs.pop("api_version", _params.pop("api-version", "2020-10-01")) # type: str + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.DeploymentExtended] - _json = self._serialize.body(parameters, 'Deployment') + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(parameters, (IO, bytes)): + _content = parameters + else: + _json = self._serialize.body(parameters, "Deployment") - request = build_deployments_create_or_update_at_scope_request_initial( + request = build_deployments_create_or_update_at_scope_request( scope=scope, deployment_name=deployment_name, api_version=api_version, content_type=content_type, json=_json, - template_url=self._create_or_update_at_scope_initial.metadata['url'], + content=_content, + template_url=self._create_or_update_at_scope_initial.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200, 201]: @@ -3846,37 +3190,41 @@ def _create_or_update_at_scope_initial( raise HttpResponseError(response=response, error_format=ARMErrorFormat) if response.status_code == 200: - deserialized = self._deserialize('DeploymentExtended', pipeline_response) + deserialized = self._deserialize("DeploymentExtended", pipeline_response) if response.status_code == 201: - deserialized = self._deserialize('DeploymentExtended', pipeline_response) + deserialized = self._deserialize("DeploymentExtended", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - _create_or_update_at_scope_initial.metadata = {'url': "/{scope}/providers/Microsoft.Resources/deployments/{deploymentName}"} # type: ignore - + _create_or_update_at_scope_initial.metadata = {"url": "/{scope}/providers/Microsoft.Resources/deployments/{deploymentName}"} # type: ignore - @distributed_trace + @overload def begin_create_or_update_at_scope( self, scope: str, deployment_name: str, - parameters: "_models.Deployment", + parameters: _models.Deployment, + *, + content_type: str = "application/json", **kwargs: Any - ) -> LROPoller["_models.DeploymentExtended"]: + ) -> LROPoller[_models.DeploymentExtended]: """Deploys resources at a given scope. You can provide the template and parameters directly in the request or link to JSON files. - :param scope: The resource scope. + :param scope: The resource scope. Required. :type scope: str - :param deployment_name: The name of the deployment. + :param deployment_name: The name of the deployment. Required. :type deployment_name: str - :param parameters: Additional parameters supplied to the operation. + :param parameters: Additional parameters supplied to the operation. Required. :type parameters: ~azure.mgmt.resource.resources.v2020_10_01.models.Deployment + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str :keyword callable cls: A custom type or function that will be passed the direct response :keyword str continuation_token: A continuation token to restart a poller from a saved state. :keyword polling: By default, your polling method will be ARMPolling. Pass in False for this @@ -3889,114 +3237,179 @@ def begin_create_or_update_at_scope( cls(response) :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.resource.resources.v2020_10_01.models.DeploymentExtended] - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - api_version = kwargs.pop('api_version', "2020-10-01") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] - polling = kwargs.pop('polling', True) # type: Union[bool, PollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType["_models.DeploymentExtended"] - lro_delay = kwargs.pop( - 'polling_interval', - self._config.polling_interval - ) - cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] + + @overload + def begin_create_or_update_at_scope( + self, scope: str, deployment_name: str, parameters: IO, *, content_type: str = "application/json", **kwargs: Any + ) -> LROPoller[_models.DeploymentExtended]: + """Deploys resources at a given scope. + + You can provide the template and parameters directly in the request or link to JSON files. + + :param scope: The resource scope. Required. + :type scope: str + :param deployment_name: The name of the deployment. Required. + :type deployment_name: str + :param parameters: Additional parameters supplied to the operation. Required. + :type parameters: IO + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be ARMPolling. Pass in False for this + operation to not poll, or pass in your own initialized polling object for a personal polling + strategy. + :paramtype polling: bool or ~azure.core.polling.PollingMethod + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of LROPoller that returns either DeploymentExtended or the result of + cls(response) + :rtype: + ~azure.core.polling.LROPoller[~azure.mgmt.resource.resources.v2020_10_01.models.DeploymentExtended] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace + def begin_create_or_update_at_scope( + self, scope: str, deployment_name: str, parameters: Union[_models.Deployment, IO], **kwargs: Any + ) -> LROPoller[_models.DeploymentExtended]: + """Deploys resources at a given scope. + + You can provide the template and parameters directly in the request or link to JSON files. + + :param scope: The resource scope. Required. + :type scope: str + :param deployment_name: The name of the deployment. Required. + :type deployment_name: str + :param parameters: Additional parameters supplied to the operation. Is either a model type or a + IO type. Required. + :type parameters: ~azure.mgmt.resource.resources.v2020_10_01.models.Deployment or IO + :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. + Default value is None. + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be ARMPolling. Pass in False for this + operation to not poll, or pass in your own initialized polling object for a personal polling + strategy. + :paramtype polling: bool or ~azure.core.polling.PollingMethod + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of LROPoller that returns either DeploymentExtended or the result of + cls(response) + :rtype: + ~azure.core.polling.LROPoller[~azure.mgmt.resource.resources.v2020_10_01.models.DeploymentExtended] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _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", "2020-10-01")) # type: str + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.DeploymentExtended] + polling = kwargs.pop("polling", True) # type: Union[bool, PollingMethod] + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token = kwargs.pop("continuation_token", None) # type: Optional[str] if cont_token is None: - raw_result = self._create_or_update_at_scope_initial( + raw_result = self._create_or_update_at_scope_initial( # type: ignore scope=scope, deployment_name=deployment_name, parameters=parameters, api_version=api_version, content_type=content_type, - cls=lambda x,y,z: x, + cls=lambda x, y, z: x, + headers=_headers, + params=_params, **kwargs ) - kwargs.pop('error_map', None) + kwargs.pop("error_map", None) def get_long_running_output(pipeline_response): - response = pipeline_response.http_response - deserialized = self._deserialize('DeploymentExtended', pipeline_response) + deserialized = self._deserialize("DeploymentExtended", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - - if polling is True: polling_method = ARMPolling(lro_delay, **kwargs) - elif polling is False: polling_method = NoPolling() - else: polling_method = polling + if polling is True: + polling_method = cast(PollingMethod, ARMPolling(lro_delay, **kwargs)) # type: PollingMethod + elif polling is False: + polling_method = cast(PollingMethod, NoPolling()) + else: + polling_method = polling if cont_token: return LROPoller.from_continuation_token( polling_method=polling_method, continuation_token=cont_token, client=self._client, - deserialization_callback=get_long_running_output + deserialization_callback=get_long_running_output, ) return LROPoller(self._client, raw_result, get_long_running_output, polling_method) - begin_create_or_update_at_scope.metadata = {'url': "/{scope}/providers/Microsoft.Resources/deployments/{deploymentName}"} # type: ignore + begin_create_or_update_at_scope.metadata = {"url": "/{scope}/providers/Microsoft.Resources/deployments/{deploymentName}"} # type: ignore @distributed_trace - def get_at_scope( - self, - scope: str, - deployment_name: str, - **kwargs: Any - ) -> "_models.DeploymentExtended": + def get_at_scope(self, scope: str, deployment_name: str, **kwargs: Any) -> _models.DeploymentExtended: """Gets a deployment. - :param scope: The resource scope. + :param scope: The resource scope. Required. :type scope: str - :param deployment_name: The name of the deployment. + :param deployment_name: The name of the deployment. Required. :type deployment_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: DeploymentExtended, or the result of cls(response) + :return: DeploymentExtended or the result of cls(response) :rtype: ~azure.mgmt.resource.resources.v2020_10_01.models.DeploymentExtended - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.DeploymentExtended"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + 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', "2020-10-01") # type: str + api_version = kwargs.pop("api_version", _params.pop("api-version", "2020-10-01")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[_models.DeploymentExtended] - request = build_deployments_get_at_scope_request( scope=scope, deployment_name=deployment_name, api_version=api_version, - template_url=self.get_at_scope.metadata['url'], + template_url=self.get_at_scope.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) - deserialized = self._deserialize('DeploymentExtended', pipeline_response) + deserialized = self._deserialize("DeploymentExtended", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - get_at_scope.metadata = {'url': "/{scope}/providers/Microsoft.Resources/deployments/{deploymentName}"} # type: ignore - + get_at_scope.metadata = {"url": "/{scope}/providers/Microsoft.Resources/deployments/{deploymentName}"} # type: ignore @distributed_trace def cancel_at_scope( # pylint: disable=inconsistent-return-statements - self, - scope: str, - deployment_name: str, - **kwargs: Any + self, scope: str, deployment_name: str, **kwargs: Any ) -> None: """Cancels a currently running template deployment. @@ -4005,38 +3418,44 @@ def cancel_at_scope( # pylint: disable=inconsistent-return-statements deployment stops the currently running template deployment and leaves the resources partially deployed. - :param scope: The resource scope. + :param scope: The resource scope. Required. :type scope: str - :param deployment_name: The name of the deployment. + :param deployment_name: The name of the deployment. Required. :type deployment_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: None, or the result of cls(response) + :return: None or the result of cls(response) :rtype: None - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType[None] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) - api_version = kwargs.pop('api_version', "2020-10-01") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2020-10-01")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[None] - request = build_deployments_cancel_at_scope_request( scope=scope, deployment_name=deployment_name, api_version=api_version, - template_url=self.cancel_at_scope.metadata['url'], + template_url=self.cancel_at_scope.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [204]: @@ -4046,43 +3465,52 @@ def cancel_at_scope( # pylint: disable=inconsistent-return-statements if cls: return cls(pipeline_response, None, {}) - cancel_at_scope.metadata = {'url': "/{scope}/providers/Microsoft.Resources/deployments/{deploymentName}/cancel"} # type: ignore - + cancel_at_scope.metadata = {"url": "/{scope}/providers/Microsoft.Resources/deployments/{deploymentName}/cancel"} # type: ignore def _validate_at_scope_initial( - self, - scope: str, - deployment_name: str, - parameters: "_models.Deployment", - **kwargs: Any - ) -> Optional["_models.DeploymentValidateResult"]: - cls = kwargs.pop('cls', None) # type: ClsType[Optional["_models.DeploymentValidateResult"]] + self, scope: str, deployment_name: str, parameters: Union[_models.Deployment, IO], **kwargs: Any + ) -> Optional[_models.DeploymentValidateResult]: error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', "2020-10-01") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + api_version = kwargs.pop("api_version", _params.pop("api-version", "2020-10-01")) # type: str + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[Optional[_models.DeploymentValidateResult]] - _json = self._serialize.body(parameters, 'Deployment') + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(parameters, (IO, bytes)): + _content = parameters + else: + _json = self._serialize.body(parameters, "Deployment") - request = build_deployments_validate_at_scope_request_initial( + request = build_deployments_validate_at_scope_request( scope=scope, deployment_name=deployment_name, api_version=api_version, content_type=content_type, json=_json, - template_url=self._validate_at_scope_initial.metadata['url'], + content=_content, + template_url=self._validate_at_scope_initial.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200, 202, 400]: @@ -4091,36 +3519,40 @@ def _validate_at_scope_initial( deserialized = None if response.status_code == 200: - deserialized = self._deserialize('DeploymentValidateResult', pipeline_response) + deserialized = self._deserialize("DeploymentValidateResult", pipeline_response) if response.status_code == 400: - deserialized = self._deserialize('DeploymentValidateResult', pipeline_response) + deserialized = self._deserialize("DeploymentValidateResult", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - _validate_at_scope_initial.metadata = {'url': "/{scope}/providers/Microsoft.Resources/deployments/{deploymentName}/validate"} # type: ignore - + _validate_at_scope_initial.metadata = {"url": "/{scope}/providers/Microsoft.Resources/deployments/{deploymentName}/validate"} # type: ignore - @distributed_trace + @overload def begin_validate_at_scope( self, scope: str, deployment_name: str, - parameters: "_models.Deployment", + parameters: _models.Deployment, + *, + content_type: str = "application/json", **kwargs: Any - ) -> LROPoller["_models.DeploymentValidateResult"]: + ) -> LROPoller[_models.DeploymentValidateResult]: """Validates whether the specified template is syntactically correct and will be accepted by Azure Resource Manager.. - :param scope: The resource scope. + :param scope: The resource scope. Required. :type scope: str - :param deployment_name: The name of the deployment. + :param deployment_name: The name of the deployment. Required. :type deployment_name: str - :param parameters: Parameters to validate. + :param parameters: Parameters to validate. Required. :type parameters: ~azure.mgmt.resource.resources.v2020_10_01.models.Deployment + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str :keyword callable cls: A custom type or function that will be passed the direct response :keyword str continuation_token: A continuation token to restart a poller from a saved state. :keyword polling: By default, your polling method will be ARMPolling. Pass in False for this @@ -4133,119 +3565,182 @@ def begin_validate_at_scope( cls(response) :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.resource.resources.v2020_10_01.models.DeploymentValidateResult] - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - api_version = kwargs.pop('api_version', "2020-10-01") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] - polling = kwargs.pop('polling', True) # type: Union[bool, PollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType["_models.DeploymentValidateResult"] - lro_delay = kwargs.pop( - 'polling_interval', - self._config.polling_interval - ) - cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] + + @overload + def begin_validate_at_scope( + self, scope: str, deployment_name: str, parameters: IO, *, content_type: str = "application/json", **kwargs: Any + ) -> LROPoller[_models.DeploymentValidateResult]: + """Validates whether the specified template is syntactically correct and will be accepted by Azure + Resource Manager.. + + :param scope: The resource scope. Required. + :type scope: str + :param deployment_name: The name of the deployment. Required. + :type deployment_name: str + :param parameters: Parameters to validate. Required. + :type parameters: IO + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be ARMPolling. Pass in False for this + operation to not poll, or pass in your own initialized polling object for a personal polling + strategy. + :paramtype polling: bool or ~azure.core.polling.PollingMethod + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of LROPoller that returns either DeploymentValidateResult or the result of + cls(response) + :rtype: + ~azure.core.polling.LROPoller[~azure.mgmt.resource.resources.v2020_10_01.models.DeploymentValidateResult] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace + def begin_validate_at_scope( + self, scope: str, deployment_name: str, parameters: Union[_models.Deployment, IO], **kwargs: Any + ) -> LROPoller[_models.DeploymentValidateResult]: + """Validates whether the specified template is syntactically correct and will be accepted by Azure + Resource Manager.. + + :param scope: The resource scope. Required. + :type scope: str + :param deployment_name: The name of the deployment. Required. + :type deployment_name: str + :param parameters: Parameters to validate. Is either a model type or a IO type. Required. + :type parameters: ~azure.mgmt.resource.resources.v2020_10_01.models.Deployment or IO + :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. + Default value is None. + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be ARMPolling. Pass in False for this + operation to not poll, or pass in your own initialized polling object for a personal polling + strategy. + :paramtype polling: bool or ~azure.core.polling.PollingMethod + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of LROPoller that returns either DeploymentValidateResult or the result of + cls(response) + :rtype: + ~azure.core.polling.LROPoller[~azure.mgmt.resource.resources.v2020_10_01.models.DeploymentValidateResult] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _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", "2020-10-01")) # type: str + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.DeploymentValidateResult] + polling = kwargs.pop("polling", True) # type: Union[bool, PollingMethod] + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token = kwargs.pop("continuation_token", None) # type: Optional[str] if cont_token is None: - raw_result = self._validate_at_scope_initial( + raw_result = self._validate_at_scope_initial( # type: ignore scope=scope, deployment_name=deployment_name, parameters=parameters, api_version=api_version, content_type=content_type, - cls=lambda x,y,z: x, + cls=lambda x, y, z: x, + headers=_headers, + params=_params, **kwargs ) - kwargs.pop('error_map', None) + kwargs.pop("error_map", None) def get_long_running_output(pipeline_response): - response = pipeline_response.http_response - deserialized = self._deserialize('DeploymentValidateResult', pipeline_response) + deserialized = self._deserialize("DeploymentValidateResult", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - - if polling is True: polling_method = ARMPolling(lro_delay, **kwargs) - elif polling is False: polling_method = NoPolling() - else: polling_method = polling + if polling is True: + polling_method = cast(PollingMethod, ARMPolling(lro_delay, **kwargs)) # type: PollingMethod + elif polling is False: + polling_method = cast(PollingMethod, NoPolling()) + else: + polling_method = polling if cont_token: return LROPoller.from_continuation_token( polling_method=polling_method, continuation_token=cont_token, client=self._client, - deserialization_callback=get_long_running_output + deserialization_callback=get_long_running_output, ) return LROPoller(self._client, raw_result, get_long_running_output, polling_method) - begin_validate_at_scope.metadata = {'url': "/{scope}/providers/Microsoft.Resources/deployments/{deploymentName}/validate"} # type: ignore + begin_validate_at_scope.metadata = {"url": "/{scope}/providers/Microsoft.Resources/deployments/{deploymentName}/validate"} # type: ignore @distributed_trace def export_template_at_scope( - self, - scope: str, - deployment_name: str, - **kwargs: Any - ) -> "_models.DeploymentExportResult": + self, scope: str, deployment_name: str, **kwargs: Any + ) -> _models.DeploymentExportResult: """Exports the template used for specified deployment. - :param scope: The resource scope. + :param scope: The resource scope. Required. :type scope: str - :param deployment_name: The name of the deployment. + :param deployment_name: The name of the deployment. Required. :type deployment_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: DeploymentExportResult, or the result of cls(response) + :return: DeploymentExportResult or the result of cls(response) :rtype: ~azure.mgmt.resource.resources.v2020_10_01.models.DeploymentExportResult - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.DeploymentExportResult"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) - api_version = kwargs.pop('api_version', "2020-10-01") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2020-10-01")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[_models.DeploymentExportResult] - request = build_deployments_export_template_at_scope_request( scope=scope, deployment_name=deployment_name, api_version=api_version, - template_url=self.export_template_at_scope.metadata['url'], + template_url=self.export_template_at_scope.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) - deserialized = self._deserialize('DeploymentExportResult', pipeline_response) + deserialized = self._deserialize("DeploymentExportResult", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - export_template_at_scope.metadata = {'url': "/{scope}/providers/Microsoft.Resources/deployments/{deploymentName}/exportTemplate"} # type: ignore - + export_template_at_scope.metadata = {"url": "/{scope}/providers/Microsoft.Resources/deployments/{deploymentName}/exportTemplate"} # type: ignore @distributed_trace def list_at_scope( - self, - scope: str, - filter: Optional[str] = None, - top: Optional[int] = None, - **kwargs: Any - ) -> Iterable["_models.DeploymentListResult"]: + self, scope: str, filter: Optional[str] = None, top: Optional[int] = None, **kwargs: Any + ) -> Iterable["_models.DeploymentExtended"]: """Get all the deployments at the given scope. - :param scope: The resource scope. + :param scope: The resource scope. Required. :type scope: str :param filter: The filter to apply on the operation. For example, you can use $filter=provisioningState eq '{state}'. Default value is None. @@ -4254,40 +3749,48 @@ def list_at_scope( value is None. :type top: int :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either DeploymentListResult or the result of - cls(response) + :return: An iterator like instance of either DeploymentExtended or the result of cls(response) :rtype: - ~azure.core.paging.ItemPaged[~azure.mgmt.resource.resources.v2020_10_01.models.DeploymentListResult] - :raises: ~azure.core.exceptions.HttpResponseError + ~azure.core.paging.ItemPaged[~azure.mgmt.resource.resources.v2020_10_01.models.DeploymentExtended] + :raises ~azure.core.exceptions.HttpResponseError: """ - api_version = kwargs.pop('api_version', "2020-10-01") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2020-10-01")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[_models.DeploymentListResult] - cls = kwargs.pop('cls', None) # type: ClsType["_models.DeploymentListResult"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) + def prepare_request(next_link=None): if not next_link: - + request = build_deployments_list_at_scope_request( scope=scope, - api_version=api_version, filter=filter, top=top, - template_url=self.list_at_scope.metadata['url'], + api_version=api_version, + template_url=self.list_at_scope.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore else: - - request = build_deployments_list_at_scope_request( - scope=scope, - template_url=next_link, - ) + # make call to next link with the client's api-version + _parsed_next_link = urlparse(next_link) + _next_request_params = case_insensitive_dict(parse_qs(_parsed_next_link.query)) + _next_request_params["api-version"] = self._config.api_version + request = HttpRequest("GET", urljoin(next_link, _parsed_next_link.path), params=_next_request_params) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore request.method = "GET" return request @@ -4301,10 +3804,8 @@ def extract_data(pipeline_response): def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) response = pipeline_response.http_response @@ -4314,39 +3815,41 @@ def get_next(next_link=None): return pipeline_response + return ItemPaged(get_next, extract_data) - return ItemPaged( - get_next, extract_data - ) - list_at_scope.metadata = {'url': "/{scope}/providers/Microsoft.Resources/deployments/"} # type: ignore + list_at_scope.metadata = {"url": "/{scope}/providers/Microsoft.Resources/deployments/"} # type: ignore def _delete_at_tenant_scope_initial( # pylint: disable=inconsistent-return-statements - self, - deployment_name: str, - **kwargs: Any + self, deployment_name: str, **kwargs: Any ) -> None: - cls = kwargs.pop('cls', None) # type: ClsType[None] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) - api_version = kwargs.pop('api_version', "2020-10-01") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - request = build_deployments_delete_at_tenant_scope_request_initial( + api_version = kwargs.pop("api_version", _params.pop("api-version", "2020-10-01")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[None] + + request = build_deployments_delete_at_tenant_scope_request( deployment_name=deployment_name, api_version=api_version, - template_url=self._delete_at_tenant_scope_initial.metadata['url'], + template_url=self._delete_at_tenant_scope_initial.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [202, 204]: @@ -4356,15 +3859,10 @@ def _delete_at_tenant_scope_initial( # pylint: disable=inconsistent-return-stat if cls: return cls(pipeline_response, None, {}) - _delete_at_tenant_scope_initial.metadata = {'url': "/providers/Microsoft.Resources/deployments/{deploymentName}"} # type: ignore - + _delete_at_tenant_scope_initial.metadata = {"url": "/providers/Microsoft.Resources/deployments/{deploymentName}"} # type: ignore @distributed_trace - def begin_delete_at_tenant_scope( # pylint: disable=inconsistent-return-statements - self, - deployment_name: str, - **kwargs: Any - ) -> LROPoller[None]: + def begin_delete_at_tenant_scope(self, deployment_name: str, **kwargs: Any) -> LROPoller[None]: """Deletes a deployment from the deployment history. A template deployment that is currently running cannot be deleted. Deleting a template @@ -4375,7 +3873,7 @@ def begin_delete_at_tenant_scope( # pylint: disable=inconsistent-return-stateme process finishes, the URI in the Location header returns a status of 204 on success. If the asynchronous request failed, the URI in the Location header returns an error-level status code. - :param deployment_name: The name of the deployment. + :param deployment_name: The name of the deployment. Required. :type deployment_name: str :keyword callable cls: A custom type or function that will be passed the direct response :keyword str continuation_token: A continuation token to restart a poller from a saved state. @@ -4387,81 +3885,87 @@ def begin_delete_at_tenant_scope( # pylint: disable=inconsistent-return-stateme Retry-After header is present. :return: An instance of LROPoller that returns either None or the result of cls(response) :rtype: ~azure.core.polling.LROPoller[None] - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - api_version = kwargs.pop('api_version', "2020-10-01") # type: str - polling = kwargs.pop('polling', True) # type: Union[bool, PollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType[None] - lro_delay = kwargs.pop( - 'polling_interval', - self._config.polling_interval - ) - cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2020-10-01")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[None] + polling = kwargs.pop("polling", True) # type: Union[bool, PollingMethod] + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token = kwargs.pop("continuation_token", None) # type: Optional[str] if cont_token is None: - raw_result = self._delete_at_tenant_scope_initial( + raw_result = self._delete_at_tenant_scope_initial( # type: ignore deployment_name=deployment_name, api_version=api_version, - cls=lambda x,y,z: x, + cls=lambda x, y, z: x, + headers=_headers, + params=_params, **kwargs ) - kwargs.pop('error_map', None) + kwargs.pop("error_map", None) - def get_long_running_output(pipeline_response): + def get_long_running_output(pipeline_response): # pylint: disable=inconsistent-return-statements if cls: return cls(pipeline_response, None, {}) - - if polling is True: polling_method = ARMPolling(lro_delay, **kwargs) - elif polling is False: polling_method = NoPolling() - else: polling_method = polling + if polling is True: + polling_method = cast(PollingMethod, ARMPolling(lro_delay, **kwargs)) # type: PollingMethod + elif polling is False: + polling_method = cast(PollingMethod, NoPolling()) + else: + polling_method = polling if cont_token: return LROPoller.from_continuation_token( polling_method=polling_method, continuation_token=cont_token, client=self._client, - deserialization_callback=get_long_running_output + deserialization_callback=get_long_running_output, ) return LROPoller(self._client, raw_result, get_long_running_output, polling_method) - begin_delete_at_tenant_scope.metadata = {'url': "/providers/Microsoft.Resources/deployments/{deploymentName}"} # type: ignore + begin_delete_at_tenant_scope.metadata = {"url": "/providers/Microsoft.Resources/deployments/{deploymentName}"} # type: ignore @distributed_trace - def check_existence_at_tenant_scope( - self, - deployment_name: str, - **kwargs: Any - ) -> bool: + def check_existence_at_tenant_scope(self, deployment_name: str, **kwargs: Any) -> bool: """Checks whether the deployment exists. - :param deployment_name: The name of the deployment. + :param deployment_name: The name of the deployment. Required. :type deployment_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: bool, or the result of cls(response) + :return: bool or the result of cls(response) :rtype: bool - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType[None] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) - api_version = kwargs.pop('api_version', "2020-10-01") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2020-10-01")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[None] - request = build_deployments_check_existence_at_tenant_scope_request( deployment_name=deployment_name, api_version=api_version, - template_url=self.check_existence_at_tenant_scope.metadata['url'], + template_url=self.check_existence_at_tenant_scope.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [204, 404]: @@ -4472,41 +3976,51 @@ def check_existence_at_tenant_scope( return cls(pipeline_response, None, {}) return 200 <= response.status_code <= 299 - check_existence_at_tenant_scope.metadata = {'url': "/providers/Microsoft.Resources/deployments/{deploymentName}"} # type: ignore - + check_existence_at_tenant_scope.metadata = {"url": "/providers/Microsoft.Resources/deployments/{deploymentName}"} # type: ignore def _create_or_update_at_tenant_scope_initial( - self, - deployment_name: str, - parameters: "_models.ScopedDeployment", - **kwargs: Any - ) -> "_models.DeploymentExtended": - cls = kwargs.pop('cls', None) # type: ClsType["_models.DeploymentExtended"] + self, deployment_name: str, parameters: Union[_models.ScopedDeployment, IO], **kwargs: Any + ) -> _models.DeploymentExtended: error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) - api_version = kwargs.pop('api_version', "2020-10-01") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - _json = self._serialize.body(parameters, 'ScopedDeployment') + api_version = kwargs.pop("api_version", _params.pop("api-version", "2020-10-01")) # type: str + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.DeploymentExtended] - request = build_deployments_create_or_update_at_tenant_scope_request_initial( + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(parameters, (IO, bytes)): + _content = parameters + else: + _json = self._serialize.body(parameters, "ScopedDeployment") + + request = build_deployments_create_or_update_at_tenant_scope_request( deployment_name=deployment_name, api_version=api_version, content_type=content_type, json=_json, - template_url=self._create_or_update_at_tenant_scope_initial.metadata['url'], + content=_content, + template_url=self._create_or_update_at_tenant_scope_initial.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200, 201]: @@ -4514,34 +4028,38 @@ def _create_or_update_at_tenant_scope_initial( raise HttpResponseError(response=response, error_format=ARMErrorFormat) if response.status_code == 200: - deserialized = self._deserialize('DeploymentExtended', pipeline_response) + deserialized = self._deserialize("DeploymentExtended", pipeline_response) if response.status_code == 201: - deserialized = self._deserialize('DeploymentExtended', pipeline_response) + deserialized = self._deserialize("DeploymentExtended", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - _create_or_update_at_tenant_scope_initial.metadata = {'url': "/providers/Microsoft.Resources/deployments/{deploymentName}"} # type: ignore + _create_or_update_at_tenant_scope_initial.metadata = {"url": "/providers/Microsoft.Resources/deployments/{deploymentName}"} # type: ignore - - @distributed_trace + @overload def begin_create_or_update_at_tenant_scope( self, deployment_name: str, - parameters: "_models.ScopedDeployment", + parameters: _models.ScopedDeployment, + *, + content_type: str = "application/json", **kwargs: Any - ) -> LROPoller["_models.DeploymentExtended"]: + ) -> LROPoller[_models.DeploymentExtended]: """Deploys resources at tenant scope. You can provide the template and parameters directly in the request or link to JSON files. - :param deployment_name: The name of the deployment. + :param deployment_name: The name of the deployment. Required. :type deployment_name: str - :param parameters: Additional parameters supplied to the operation. + :param parameters: Additional parameters supplied to the operation. Required. :type parameters: ~azure.mgmt.resource.resources.v2020_10_01.models.ScopedDeployment + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str :keyword callable cls: A custom type or function that will be passed the direct response :keyword str continuation_token: A continuation token to restart a poller from a saved state. :keyword polling: By default, your polling method will be ARMPolling. Pass in False for this @@ -4554,108 +4072,171 @@ def begin_create_or_update_at_tenant_scope( cls(response) :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.resource.resources.v2020_10_01.models.DeploymentExtended] - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - api_version = kwargs.pop('api_version', "2020-10-01") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] - polling = kwargs.pop('polling', True) # type: Union[bool, PollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType["_models.DeploymentExtended"] - lro_delay = kwargs.pop( - 'polling_interval', - self._config.polling_interval - ) - cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] - if cont_token is None: - raw_result = self._create_or_update_at_tenant_scope_initial( - deployment_name=deployment_name, - parameters=parameters, - api_version=api_version, - content_type=content_type, - cls=lambda x,y,z: x, - **kwargs - ) - kwargs.pop('error_map', None) - def get_long_running_output(pipeline_response): - response = pipeline_response.http_response - deserialized = self._deserialize('DeploymentExtended', pipeline_response) - if cls: - return cls(pipeline_response, deserialized, {}) - return deserialized + @overload + def begin_create_or_update_at_tenant_scope( + self, deployment_name: str, parameters: IO, *, content_type: str = "application/json", **kwargs: Any + ) -> LROPoller[_models.DeploymentExtended]: + """Deploys resources at tenant scope. + + You can provide the template and parameters directly in the request or link to JSON files. + + :param deployment_name: The name of the deployment. Required. + :type deployment_name: str + :param parameters: Additional parameters supplied to the operation. Required. + :type parameters: IO + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be ARMPolling. Pass in False for this + operation to not poll, or pass in your own initialized polling object for a personal polling + strategy. + :paramtype polling: bool or ~azure.core.polling.PollingMethod + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of LROPoller that returns either DeploymentExtended or the result of + cls(response) + :rtype: + ~azure.core.polling.LROPoller[~azure.mgmt.resource.resources.v2020_10_01.models.DeploymentExtended] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace + def begin_create_or_update_at_tenant_scope( + self, deployment_name: str, parameters: Union[_models.ScopedDeployment, IO], **kwargs: Any + ) -> LROPoller[_models.DeploymentExtended]: + """Deploys resources at tenant scope. + + You can provide the template and parameters directly in the request or link to JSON files. + + :param deployment_name: The name of the deployment. Required. + :type deployment_name: str + :param parameters: Additional parameters supplied to the operation. Is either a model type or a + IO type. Required. + :type parameters: ~azure.mgmt.resource.resources.v2020_10_01.models.ScopedDeployment or IO + :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. + Default value is None. + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be ARMPolling. Pass in False for this + operation to not poll, or pass in your own initialized polling object for a personal polling + strategy. + :paramtype polling: bool or ~azure.core.polling.PollingMethod + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of LROPoller that returns either DeploymentExtended or the result of + cls(response) + :rtype: + ~azure.core.polling.LROPoller[~azure.mgmt.resource.resources.v2020_10_01.models.DeploymentExtended] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _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", "2020-10-01")) # type: str + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.DeploymentExtended] + polling = kwargs.pop("polling", True) # type: Union[bool, PollingMethod] + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token = kwargs.pop("continuation_token", None) # type: Optional[str] + if cont_token is None: + raw_result = self._create_or_update_at_tenant_scope_initial( # type: ignore + deployment_name=deployment_name, + parameters=parameters, + api_version=api_version, + content_type=content_type, + cls=lambda x, y, z: x, + headers=_headers, + params=_params, + **kwargs + ) + kwargs.pop("error_map", None) + def get_long_running_output(pipeline_response): + deserialized = self._deserialize("DeploymentExtended", pipeline_response) + if cls: + return cls(pipeline_response, deserialized, {}) + return deserialized - if polling is True: polling_method = ARMPolling(lro_delay, **kwargs) - elif polling is False: polling_method = NoPolling() - else: polling_method = polling + if polling is True: + polling_method = cast(PollingMethod, ARMPolling(lro_delay, **kwargs)) # type: PollingMethod + elif polling is False: + polling_method = cast(PollingMethod, NoPolling()) + else: + polling_method = polling if cont_token: return LROPoller.from_continuation_token( polling_method=polling_method, continuation_token=cont_token, client=self._client, - deserialization_callback=get_long_running_output + deserialization_callback=get_long_running_output, ) return LROPoller(self._client, raw_result, get_long_running_output, polling_method) - begin_create_or_update_at_tenant_scope.metadata = {'url': "/providers/Microsoft.Resources/deployments/{deploymentName}"} # type: ignore + begin_create_or_update_at_tenant_scope.metadata = {"url": "/providers/Microsoft.Resources/deployments/{deploymentName}"} # type: ignore @distributed_trace - def get_at_tenant_scope( - self, - deployment_name: str, - **kwargs: Any - ) -> "_models.DeploymentExtended": + def get_at_tenant_scope(self, deployment_name: str, **kwargs: Any) -> _models.DeploymentExtended: """Gets a deployment. - :param deployment_name: The name of the deployment. + :param deployment_name: The name of the deployment. Required. :type deployment_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: DeploymentExtended, or the result of cls(response) + :return: DeploymentExtended or the result of cls(response) :rtype: ~azure.mgmt.resource.resources.v2020_10_01.models.DeploymentExtended - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.DeploymentExtended"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + 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', "2020-10-01") # type: str + api_version = kwargs.pop("api_version", _params.pop("api-version", "2020-10-01")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[_models.DeploymentExtended] - request = build_deployments_get_at_tenant_scope_request( deployment_name=deployment_name, api_version=api_version, - template_url=self.get_at_tenant_scope.metadata['url'], + template_url=self.get_at_tenant_scope.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) - deserialized = self._deserialize('DeploymentExtended', pipeline_response) + deserialized = self._deserialize("DeploymentExtended", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - get_at_tenant_scope.metadata = {'url': "/providers/Microsoft.Resources/deployments/{deploymentName}"} # type: ignore - + get_at_tenant_scope.metadata = {"url": "/providers/Microsoft.Resources/deployments/{deploymentName}"} # type: ignore @distributed_trace def cancel_at_tenant_scope( # pylint: disable=inconsistent-return-statements - self, - deployment_name: str, - **kwargs: Any + self, deployment_name: str, **kwargs: Any ) -> None: """Cancels a currently running template deployment. @@ -4664,35 +4245,41 @@ def cancel_at_tenant_scope( # pylint: disable=inconsistent-return-statements deployment stops the currently running template deployment and leaves the resources partially deployed. - :param deployment_name: The name of the deployment. + :param deployment_name: The name of the deployment. Required. :type deployment_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: None, or the result of cls(response) + :return: None or the result of cls(response) :rtype: None - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType[None] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + 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', "2020-10-01") # type: str + api_version = kwargs.pop("api_version", _params.pop("api-version", "2020-10-01")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[None] - request = build_deployments_cancel_at_tenant_scope_request( deployment_name=deployment_name, api_version=api_version, - template_url=self.cancel_at_tenant_scope.metadata['url'], + template_url=self.cancel_at_tenant_scope.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [204]: @@ -4702,41 +4289,51 @@ def cancel_at_tenant_scope( # pylint: disable=inconsistent-return-statements if cls: return cls(pipeline_response, None, {}) - cancel_at_tenant_scope.metadata = {'url': "/providers/Microsoft.Resources/deployments/{deploymentName}/cancel"} # type: ignore - + cancel_at_tenant_scope.metadata = {"url": "/providers/Microsoft.Resources/deployments/{deploymentName}/cancel"} # type: ignore def _validate_at_tenant_scope_initial( - self, - deployment_name: str, - parameters: "_models.ScopedDeployment", - **kwargs: Any - ) -> Optional["_models.DeploymentValidateResult"]: - cls = kwargs.pop('cls', None) # type: ClsType[Optional["_models.DeploymentValidateResult"]] + self, deployment_name: str, parameters: Union[_models.ScopedDeployment, IO], **kwargs: Any + ) -> Optional[_models.DeploymentValidateResult]: error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', "2020-10-01") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + api_version = kwargs.pop("api_version", _params.pop("api-version", "2020-10-01")) # type: str + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[Optional[_models.DeploymentValidateResult]] - _json = self._serialize.body(parameters, 'ScopedDeployment') + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(parameters, (IO, bytes)): + _content = parameters + else: + _json = self._serialize.body(parameters, "ScopedDeployment") - request = build_deployments_validate_at_tenant_scope_request_initial( + request = build_deployments_validate_at_tenant_scope_request( deployment_name=deployment_name, api_version=api_version, content_type=content_type, json=_json, - template_url=self._validate_at_tenant_scope_initial.metadata['url'], + content=_content, + template_url=self._validate_at_tenant_scope_initial.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200, 202, 400]: @@ -4745,33 +4342,37 @@ def _validate_at_tenant_scope_initial( deserialized = None if response.status_code == 200: - deserialized = self._deserialize('DeploymentValidateResult', pipeline_response) + deserialized = self._deserialize("DeploymentValidateResult", pipeline_response) if response.status_code == 400: - deserialized = self._deserialize('DeploymentValidateResult', pipeline_response) + deserialized = self._deserialize("DeploymentValidateResult", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - _validate_at_tenant_scope_initial.metadata = {'url': "/providers/Microsoft.Resources/deployments/{deploymentName}/validate"} # type: ignore - + _validate_at_tenant_scope_initial.metadata = {"url": "/providers/Microsoft.Resources/deployments/{deploymentName}/validate"} # type: ignore - @distributed_trace + @overload def begin_validate_at_tenant_scope( self, deployment_name: str, - parameters: "_models.ScopedDeployment", + parameters: _models.ScopedDeployment, + *, + content_type: str = "application/json", **kwargs: Any - ) -> LROPoller["_models.DeploymentValidateResult"]: + ) -> LROPoller[_models.DeploymentValidateResult]: """Validates whether the specified template is syntactically correct and will be accepted by Azure Resource Manager.. - :param deployment_name: The name of the deployment. + :param deployment_name: The name of the deployment. Required. :type deployment_name: str - :param parameters: Parameters to validate. + :param parameters: Parameters to validate. Required. :type parameters: ~azure.mgmt.resource.resources.v2020_10_01.models.ScopedDeployment + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str :keyword callable cls: A custom type or function that will be passed the direct response :keyword str continuation_token: A continuation token to restart a poller from a saved state. :keyword polling: By default, your polling method will be ARMPolling. Pass in False for this @@ -4784,82 +4385,154 @@ def begin_validate_at_tenant_scope( cls(response) :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.resource.resources.v2020_10_01.models.DeploymentValidateResult] - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - api_version = kwargs.pop('api_version', "2020-10-01") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] - polling = kwargs.pop('polling', True) # type: Union[bool, PollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType["_models.DeploymentValidateResult"] - lro_delay = kwargs.pop( - 'polling_interval', - self._config.polling_interval - ) - cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] + + @overload + def begin_validate_at_tenant_scope( + self, deployment_name: str, parameters: IO, *, content_type: str = "application/json", **kwargs: Any + ) -> LROPoller[_models.DeploymentValidateResult]: + """Validates whether the specified template is syntactically correct and will be accepted by Azure + Resource Manager.. + + :param deployment_name: The name of the deployment. Required. + :type deployment_name: str + :param parameters: Parameters to validate. Required. + :type parameters: IO + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be ARMPolling. Pass in False for this + operation to not poll, or pass in your own initialized polling object for a personal polling + strategy. + :paramtype polling: bool or ~azure.core.polling.PollingMethod + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of LROPoller that returns either DeploymentValidateResult or the result of + cls(response) + :rtype: + ~azure.core.polling.LROPoller[~azure.mgmt.resource.resources.v2020_10_01.models.DeploymentValidateResult] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace + def begin_validate_at_tenant_scope( + self, deployment_name: str, parameters: Union[_models.ScopedDeployment, IO], **kwargs: Any + ) -> LROPoller[_models.DeploymentValidateResult]: + """Validates whether the specified template is syntactically correct and will be accepted by Azure + Resource Manager.. + + :param deployment_name: The name of the deployment. Required. + :type deployment_name: str + :param parameters: Parameters to validate. Is either a model type or a IO type. Required. + :type parameters: ~azure.mgmt.resource.resources.v2020_10_01.models.ScopedDeployment or IO + :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. + Default value is None. + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be ARMPolling. Pass in False for this + operation to not poll, or pass in your own initialized polling object for a personal polling + strategy. + :paramtype polling: bool or ~azure.core.polling.PollingMethod + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of LROPoller that returns either DeploymentValidateResult or the result of + cls(response) + :rtype: + ~azure.core.polling.LROPoller[~azure.mgmt.resource.resources.v2020_10_01.models.DeploymentValidateResult] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _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", "2020-10-01")) # type: str + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.DeploymentValidateResult] + polling = kwargs.pop("polling", True) # type: Union[bool, PollingMethod] + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token = kwargs.pop("continuation_token", None) # type: Optional[str] if cont_token is None: - raw_result = self._validate_at_tenant_scope_initial( + raw_result = self._validate_at_tenant_scope_initial( # type: ignore deployment_name=deployment_name, parameters=parameters, api_version=api_version, content_type=content_type, - cls=lambda x,y,z: x, + cls=lambda x, y, z: x, + headers=_headers, + params=_params, **kwargs ) - kwargs.pop('error_map', None) + kwargs.pop("error_map", None) def get_long_running_output(pipeline_response): - response = pipeline_response.http_response - deserialized = self._deserialize('DeploymentValidateResult', pipeline_response) + deserialized = self._deserialize("DeploymentValidateResult", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - - if polling is True: polling_method = ARMPolling(lro_delay, **kwargs) - elif polling is False: polling_method = NoPolling() - else: polling_method = polling + if polling is True: + polling_method = cast(PollingMethod, ARMPolling(lro_delay, **kwargs)) # type: PollingMethod + elif polling is False: + polling_method = cast(PollingMethod, NoPolling()) + else: + polling_method = polling if cont_token: return LROPoller.from_continuation_token( polling_method=polling_method, continuation_token=cont_token, client=self._client, - deserialization_callback=get_long_running_output + deserialization_callback=get_long_running_output, ) return LROPoller(self._client, raw_result, get_long_running_output, polling_method) - begin_validate_at_tenant_scope.metadata = {'url': "/providers/Microsoft.Resources/deployments/{deploymentName}/validate"} # type: ignore + begin_validate_at_tenant_scope.metadata = {"url": "/providers/Microsoft.Resources/deployments/{deploymentName}/validate"} # type: ignore def _what_if_at_tenant_scope_initial( - self, - deployment_name: str, - parameters: "_models.ScopedDeploymentWhatIf", - **kwargs: Any - ) -> Optional["_models.WhatIfOperationResult"]: - cls = kwargs.pop('cls', None) # type: ClsType[Optional["_models.WhatIfOperationResult"]] + self, deployment_name: str, parameters: Union[_models.ScopedDeploymentWhatIf, IO], **kwargs: Any + ) -> Optional[_models.WhatIfOperationResult]: error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', "2020-10-01") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + api_version = kwargs.pop("api_version", _params.pop("api-version", "2020-10-01")) # type: str + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[Optional[_models.WhatIfOperationResult]] - _json = self._serialize.body(parameters, 'ScopedDeploymentWhatIf') + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(parameters, (IO, bytes)): + _content = parameters + else: + _json = self._serialize.body(parameters, "ScopedDeploymentWhatIf") - request = build_deployments_what_if_at_tenant_scope_request_initial( + request = build_deployments_what_if_at_tenant_scope_request( deployment_name=deployment_name, api_version=api_version, content_type=content_type, json=_json, - template_url=self._what_if_at_tenant_scope_initial.metadata['url'], + content=_content, + template_url=self._what_if_at_tenant_scope_initial.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200, 202]: @@ -4869,35 +4542,38 @@ def _what_if_at_tenant_scope_initial( deserialized = None response_headers = {} if response.status_code == 200: - deserialized = self._deserialize('WhatIfOperationResult', pipeline_response) + deserialized = self._deserialize("WhatIfOperationResult", pipeline_response) if response.status_code == 202: - response_headers['Location']=self._deserialize('str', response.headers.get('Location')) - response_headers['Retry-After']=self._deserialize('str', response.headers.get('Retry-After')) - + response_headers["Location"] = self._deserialize("str", response.headers.get("Location")) + response_headers["Retry-After"] = self._deserialize("str", response.headers.get("Retry-After")) if cls: return cls(pipeline_response, deserialized, response_headers) return deserialized - _what_if_at_tenant_scope_initial.metadata = {'url': "/providers/Microsoft.Resources/deployments/{deploymentName}/whatIf"} # type: ignore - + _what_if_at_tenant_scope_initial.metadata = {"url": "/providers/Microsoft.Resources/deployments/{deploymentName}/whatIf"} # type: ignore - @distributed_trace + @overload def begin_what_if_at_tenant_scope( self, deployment_name: str, - parameters: "_models.ScopedDeploymentWhatIf", + parameters: _models.ScopedDeploymentWhatIf, + *, + content_type: str = "application/json", **kwargs: Any - ) -> LROPoller["_models.WhatIfOperationResult"]: + ) -> LROPoller[_models.WhatIfOperationResult]: """Returns changes that will be made by the deployment if executed at the scope of the tenant group. - :param deployment_name: The name of the deployment. + :param deployment_name: The name of the deployment. Required. :type deployment_name: str - :param parameters: Parameters to validate. + :param parameters: Parameters to validate. Required. :type parameters: ~azure.mgmt.resource.resources.v2020_10_01.models.ScopedDeploymentWhatIf + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str :keyword callable cls: A custom type or function that will be passed the direct response :keyword str continuation_token: A continuation token to restart a poller from a saved state. :keyword polling: By default, your polling method will be ARMPolling. Pass in False for this @@ -4910,110 +4586,172 @@ def begin_what_if_at_tenant_scope( cls(response) :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.resource.resources.v2020_10_01.models.WhatIfOperationResult] - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - api_version = kwargs.pop('api_version', "2020-10-01") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] - polling = kwargs.pop('polling', True) # type: Union[bool, PollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType["_models.WhatIfOperationResult"] - lro_delay = kwargs.pop( - 'polling_interval', - self._config.polling_interval - ) - cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] + + @overload + def begin_what_if_at_tenant_scope( + self, deployment_name: str, parameters: IO, *, content_type: str = "application/json", **kwargs: Any + ) -> LROPoller[_models.WhatIfOperationResult]: + """Returns changes that will be made by the deployment if executed at the scope of the tenant + group. + + :param deployment_name: The name of the deployment. Required. + :type deployment_name: str + :param parameters: Parameters to validate. Required. + :type parameters: IO + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be ARMPolling. Pass in False for this + operation to not poll, or pass in your own initialized polling object for a personal polling + strategy. + :paramtype polling: bool or ~azure.core.polling.PollingMethod + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of LROPoller that returns either WhatIfOperationResult or the result of + cls(response) + :rtype: + ~azure.core.polling.LROPoller[~azure.mgmt.resource.resources.v2020_10_01.models.WhatIfOperationResult] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace + def begin_what_if_at_tenant_scope( + self, deployment_name: str, parameters: Union[_models.ScopedDeploymentWhatIf, IO], **kwargs: Any + ) -> LROPoller[_models.WhatIfOperationResult]: + """Returns changes that will be made by the deployment if executed at the scope of the tenant + group. + + :param deployment_name: The name of the deployment. Required. + :type deployment_name: str + :param parameters: Parameters to validate. Is either a model type or a IO type. Required. + :type parameters: ~azure.mgmt.resource.resources.v2020_10_01.models.ScopedDeploymentWhatIf or + IO + :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. + Default value is None. + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be ARMPolling. Pass in False for this + operation to not poll, or pass in your own initialized polling object for a personal polling + strategy. + :paramtype polling: bool or ~azure.core.polling.PollingMethod + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of LROPoller that returns either WhatIfOperationResult or the result of + cls(response) + :rtype: + ~azure.core.polling.LROPoller[~azure.mgmt.resource.resources.v2020_10_01.models.WhatIfOperationResult] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _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", "2020-10-01")) # type: str + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.WhatIfOperationResult] + polling = kwargs.pop("polling", True) # type: Union[bool, PollingMethod] + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token = kwargs.pop("continuation_token", None) # type: Optional[str] if cont_token is None: - raw_result = self._what_if_at_tenant_scope_initial( + raw_result = self._what_if_at_tenant_scope_initial( # type: ignore deployment_name=deployment_name, parameters=parameters, api_version=api_version, content_type=content_type, - cls=lambda x,y,z: x, + cls=lambda x, y, z: x, + headers=_headers, + params=_params, **kwargs ) - kwargs.pop('error_map', None) + kwargs.pop("error_map", None) def get_long_running_output(pipeline_response): - response = pipeline_response.http_response - deserialized = self._deserialize('WhatIfOperationResult', pipeline_response) + deserialized = self._deserialize("WhatIfOperationResult", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - - if polling is True: polling_method = ARMPolling(lro_delay, lro_options={'final-state-via': 'location'}, **kwargs) - elif polling is False: polling_method = NoPolling() - else: polling_method = polling + if polling is True: + polling_method = cast( + PollingMethod, ARMPolling(lro_delay, lro_options={"final-state-via": "location"}, **kwargs) + ) # type: PollingMethod + elif polling is False: + polling_method = cast(PollingMethod, NoPolling()) + else: + polling_method = polling if cont_token: return LROPoller.from_continuation_token( polling_method=polling_method, continuation_token=cont_token, client=self._client, - deserialization_callback=get_long_running_output + deserialization_callback=get_long_running_output, ) return LROPoller(self._client, raw_result, get_long_running_output, polling_method) - begin_what_if_at_tenant_scope.metadata = {'url': "/providers/Microsoft.Resources/deployments/{deploymentName}/whatIf"} # type: ignore + begin_what_if_at_tenant_scope.metadata = {"url": "/providers/Microsoft.Resources/deployments/{deploymentName}/whatIf"} # type: ignore @distributed_trace - def export_template_at_tenant_scope( - self, - deployment_name: str, - **kwargs: Any - ) -> "_models.DeploymentExportResult": + def export_template_at_tenant_scope(self, deployment_name: str, **kwargs: Any) -> _models.DeploymentExportResult: """Exports the template used for specified deployment. - :param deployment_name: The name of the deployment. + :param deployment_name: The name of the deployment. Required. :type deployment_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: DeploymentExportResult, or the result of cls(response) + :return: DeploymentExportResult or the result of cls(response) :rtype: ~azure.mgmt.resource.resources.v2020_10_01.models.DeploymentExportResult - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.DeploymentExportResult"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + 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', "2020-10-01") # type: str + api_version = kwargs.pop("api_version", _params.pop("api-version", "2020-10-01")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[_models.DeploymentExportResult] - request = build_deployments_export_template_at_tenant_scope_request( deployment_name=deployment_name, api_version=api_version, - template_url=self.export_template_at_tenant_scope.metadata['url'], + template_url=self.export_template_at_tenant_scope.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) - deserialized = self._deserialize('DeploymentExportResult', pipeline_response) + deserialized = self._deserialize("DeploymentExportResult", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - export_template_at_tenant_scope.metadata = {'url': "/providers/Microsoft.Resources/deployments/{deploymentName}/exportTemplate"} # type: ignore - + export_template_at_tenant_scope.metadata = {"url": "/providers/Microsoft.Resources/deployments/{deploymentName}/exportTemplate"} # type: ignore @distributed_trace def list_at_tenant_scope( - self, - filter: Optional[str] = None, - top: Optional[int] = None, - **kwargs: Any - ) -> Iterable["_models.DeploymentListResult"]: + self, filter: Optional[str] = None, top: Optional[int] = None, **kwargs: Any + ) -> Iterable["_models.DeploymentExtended"]: """Get all the deployments at the tenant scope. :param filter: The filter to apply on the operation. For example, you can use @@ -5023,38 +4761,47 @@ def list_at_tenant_scope( value is None. :type top: int :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either DeploymentListResult or the result of - cls(response) + :return: An iterator like instance of either DeploymentExtended or the result of cls(response) :rtype: - ~azure.core.paging.ItemPaged[~azure.mgmt.resource.resources.v2020_10_01.models.DeploymentListResult] - :raises: ~azure.core.exceptions.HttpResponseError + ~azure.core.paging.ItemPaged[~azure.mgmt.resource.resources.v2020_10_01.models.DeploymentExtended] + :raises ~azure.core.exceptions.HttpResponseError: """ - api_version = kwargs.pop('api_version', "2020-10-01") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2020-10-01")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[_models.DeploymentListResult] - cls = kwargs.pop('cls', None) # type: ClsType["_models.DeploymentListResult"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) + def prepare_request(next_link=None): if not next_link: - + request = build_deployments_list_at_tenant_scope_request( - api_version=api_version, filter=filter, top=top, - template_url=self.list_at_tenant_scope.metadata['url'], + api_version=api_version, + template_url=self.list_at_tenant_scope.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore else: - - request = build_deployments_list_at_tenant_scope_request( - template_url=next_link, - ) + # make call to next link with the client's api-version + _parsed_next_link = urlparse(next_link) + _next_request_params = case_insensitive_dict(parse_qs(_parsed_next_link.query)) + _next_request_params["api-version"] = self._config.api_version + request = HttpRequest("GET", urljoin(next_link, _parsed_next_link.path), params=_next_request_params) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore request.method = "GET" return request @@ -5068,10 +4815,8 @@ def extract_data(pipeline_response): def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) response = pipeline_response.http_response @@ -5081,41 +4826,42 @@ def get_next(next_link=None): return pipeline_response + return ItemPaged(get_next, extract_data) - return ItemPaged( - get_next, extract_data - ) - list_at_tenant_scope.metadata = {'url': "/providers/Microsoft.Resources/deployments/"} # type: ignore + list_at_tenant_scope.metadata = {"url": "/providers/Microsoft.Resources/deployments/"} # type: ignore def _delete_at_management_group_scope_initial( # pylint: disable=inconsistent-return-statements - self, - group_id: str, - deployment_name: str, - **kwargs: Any + self, group_id: str, deployment_name: str, **kwargs: Any ) -> None: - cls = kwargs.pop('cls', None) # type: ClsType[None] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) - api_version = kwargs.pop('api_version', "2020-10-01") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - request = build_deployments_delete_at_management_group_scope_request_initial( + api_version = kwargs.pop("api_version", _params.pop("api-version", "2020-10-01")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[None] + + request = build_deployments_delete_at_management_group_scope_request( group_id=group_id, deployment_name=deployment_name, api_version=api_version, - template_url=self._delete_at_management_group_scope_initial.metadata['url'], + template_url=self._delete_at_management_group_scope_initial.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [202, 204]: @@ -5125,15 +4871,11 @@ def _delete_at_management_group_scope_initial( # pylint: disable=inconsistent-r if cls: return cls(pipeline_response, None, {}) - _delete_at_management_group_scope_initial.metadata = {'url': "/providers/Microsoft.Management/managementGroups/{groupId}/providers/Microsoft.Resources/deployments/{deploymentName}"} # type: ignore - + _delete_at_management_group_scope_initial.metadata = {"url": "/providers/Microsoft.Management/managementGroups/{groupId}/providers/Microsoft.Resources/deployments/{deploymentName}"} # type: ignore @distributed_trace - def begin_delete_at_management_group_scope( # pylint: disable=inconsistent-return-statements - self, - group_id: str, - deployment_name: str, - **kwargs: Any + def begin_delete_at_management_group_scope( + self, group_id: str, deployment_name: str, **kwargs: Any ) -> LROPoller[None]: """Deletes a deployment from the deployment history. @@ -5145,9 +4887,9 @@ def begin_delete_at_management_group_scope( # pylint: disable=inconsistent-retu process finishes, the URI in the Location header returns a status of 204 on success. If the asynchronous request failed, the URI in the Location header returns an error-level status code. - :param group_id: The management group ID. + :param group_id: The management group ID. Required. :type group_id: str - :param deployment_name: The name of the deployment. + :param deployment_name: The name of the deployment. Required. :type deployment_name: str :keyword callable cls: A custom type or function that will be passed the direct response :keyword str continuation_token: A continuation token to restart a poller from a saved state. @@ -5159,86 +4901,91 @@ def begin_delete_at_management_group_scope( # pylint: disable=inconsistent-retu Retry-After header is present. :return: An instance of LROPoller that returns either None or the result of cls(response) :rtype: ~azure.core.polling.LROPoller[None] - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - api_version = kwargs.pop('api_version', "2020-10-01") # type: str - polling = kwargs.pop('polling', True) # type: Union[bool, PollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType[None] - lro_delay = kwargs.pop( - 'polling_interval', - self._config.polling_interval - ) - cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2020-10-01")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[None] + polling = kwargs.pop("polling", True) # type: Union[bool, PollingMethod] + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token = kwargs.pop("continuation_token", None) # type: Optional[str] if cont_token is None: - raw_result = self._delete_at_management_group_scope_initial( + raw_result = self._delete_at_management_group_scope_initial( # type: ignore group_id=group_id, deployment_name=deployment_name, api_version=api_version, - cls=lambda x,y,z: x, + cls=lambda x, y, z: x, + headers=_headers, + params=_params, **kwargs ) - kwargs.pop('error_map', None) + kwargs.pop("error_map", None) - def get_long_running_output(pipeline_response): + def get_long_running_output(pipeline_response): # pylint: disable=inconsistent-return-statements if cls: return cls(pipeline_response, None, {}) - - if polling is True: polling_method = ARMPolling(lro_delay, **kwargs) - elif polling is False: polling_method = NoPolling() - else: polling_method = polling + if polling is True: + polling_method = cast(PollingMethod, ARMPolling(lro_delay, **kwargs)) # type: PollingMethod + elif polling is False: + polling_method = cast(PollingMethod, NoPolling()) + else: + polling_method = polling if cont_token: return LROPoller.from_continuation_token( polling_method=polling_method, continuation_token=cont_token, client=self._client, - deserialization_callback=get_long_running_output + deserialization_callback=get_long_running_output, ) return LROPoller(self._client, raw_result, get_long_running_output, polling_method) - begin_delete_at_management_group_scope.metadata = {'url': "/providers/Microsoft.Management/managementGroups/{groupId}/providers/Microsoft.Resources/deployments/{deploymentName}"} # type: ignore + begin_delete_at_management_group_scope.metadata = {"url": "/providers/Microsoft.Management/managementGroups/{groupId}/providers/Microsoft.Resources/deployments/{deploymentName}"} # type: ignore @distributed_trace - def check_existence_at_management_group_scope( - self, - group_id: str, - deployment_name: str, - **kwargs: Any - ) -> bool: + def check_existence_at_management_group_scope(self, group_id: str, deployment_name: str, **kwargs: Any) -> bool: """Checks whether the deployment exists. - :param group_id: The management group ID. + :param group_id: The management group ID. Required. :type group_id: str - :param deployment_name: The name of the deployment. + :param deployment_name: The name of the deployment. Required. :type deployment_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: bool, or the result of cls(response) + :return: bool or the result of cls(response) :rtype: bool - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType[None] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + 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', "2020-10-01") # type: str + api_version = kwargs.pop("api_version", _params.pop("api-version", "2020-10-01")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[None] - request = build_deployments_check_existence_at_management_group_scope_request( group_id=group_id, deployment_name=deployment_name, api_version=api_version, - template_url=self.check_existence_at_management_group_scope.metadata['url'], + template_url=self.check_existence_at_management_group_scope.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [204, 404]: @@ -5249,43 +4996,52 @@ def check_existence_at_management_group_scope( return cls(pipeline_response, None, {}) return 200 <= response.status_code <= 299 - check_existence_at_management_group_scope.metadata = {'url': "/providers/Microsoft.Management/managementGroups/{groupId}/providers/Microsoft.Resources/deployments/{deploymentName}"} # type: ignore - + check_existence_at_management_group_scope.metadata = {"url": "/providers/Microsoft.Management/managementGroups/{groupId}/providers/Microsoft.Resources/deployments/{deploymentName}"} # type: ignore def _create_or_update_at_management_group_scope_initial( - self, - group_id: str, - deployment_name: str, - parameters: "_models.ScopedDeployment", - **kwargs: Any - ) -> "_models.DeploymentExtended": - cls = kwargs.pop('cls', None) # type: ClsType["_models.DeploymentExtended"] + self, group_id: str, deployment_name: str, parameters: Union[_models.ScopedDeployment, IO], **kwargs: Any + ) -> _models.DeploymentExtended: error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) - api_version = kwargs.pop('api_version', "2020-10-01") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - _json = self._serialize.body(parameters, 'ScopedDeployment') + api_version = kwargs.pop("api_version", _params.pop("api-version", "2020-10-01")) # type: str + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.DeploymentExtended] - request = build_deployments_create_or_update_at_management_group_scope_request_initial( + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(parameters, (IO, bytes)): + _content = parameters + else: + _json = self._serialize.body(parameters, "ScopedDeployment") + + request = build_deployments_create_or_update_at_management_group_scope_request( group_id=group_id, deployment_name=deployment_name, api_version=api_version, content_type=content_type, json=_json, - template_url=self._create_or_update_at_management_group_scope_initial.metadata['url'], + content=_content, + template_url=self._create_or_update_at_management_group_scope_initial.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200, 201]: @@ -5293,37 +5049,41 @@ def _create_or_update_at_management_group_scope_initial( raise HttpResponseError(response=response, error_format=ARMErrorFormat) if response.status_code == 200: - deserialized = self._deserialize('DeploymentExtended', pipeline_response) + deserialized = self._deserialize("DeploymentExtended", pipeline_response) if response.status_code == 201: - deserialized = self._deserialize('DeploymentExtended', pipeline_response) + deserialized = self._deserialize("DeploymentExtended", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - _create_or_update_at_management_group_scope_initial.metadata = {'url': "/providers/Microsoft.Management/managementGroups/{groupId}/providers/Microsoft.Resources/deployments/{deploymentName}"} # type: ignore + _create_or_update_at_management_group_scope_initial.metadata = {"url": "/providers/Microsoft.Management/managementGroups/{groupId}/providers/Microsoft.Resources/deployments/{deploymentName}"} # type: ignore - - @distributed_trace + @overload def begin_create_or_update_at_management_group_scope( self, group_id: str, deployment_name: str, - parameters: "_models.ScopedDeployment", + parameters: _models.ScopedDeployment, + *, + content_type: str = "application/json", **kwargs: Any - ) -> LROPoller["_models.DeploymentExtended"]: + ) -> LROPoller[_models.DeploymentExtended]: """Deploys resources at management group scope. You can provide the template and parameters directly in the request or link to JSON files. - :param group_id: The management group ID. + :param group_id: The management group ID. Required. :type group_id: str - :param deployment_name: The name of the deployment. + :param deployment_name: The name of the deployment. Required. :type deployment_name: str - :param parameters: Additional parameters supplied to the operation. + :param parameters: Additional parameters supplied to the operation. Required. :type parameters: ~azure.mgmt.resource.resources.v2020_10_01.models.ScopedDeployment + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str :keyword callable cls: A custom type or function that will be passed the direct response :keyword str continuation_token: A continuation token to restart a poller from a saved state. :keyword polling: By default, your polling method will be ARMPolling. Pass in False for this @@ -5336,114 +5096,187 @@ def begin_create_or_update_at_management_group_scope( cls(response) :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.resource.resources.v2020_10_01.models.DeploymentExtended] - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - api_version = kwargs.pop('api_version', "2020-10-01") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] - polling = kwargs.pop('polling', True) # type: Union[bool, PollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType["_models.DeploymentExtended"] - lro_delay = kwargs.pop( - 'polling_interval', - self._config.polling_interval - ) - cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] - if cont_token is None: - raw_result = self._create_or_update_at_management_group_scope_initial( - group_id=group_id, - deployment_name=deployment_name, - parameters=parameters, - api_version=api_version, - content_type=content_type, - cls=lambda x,y,z: x, - **kwargs - ) - kwargs.pop('error_map', None) - - def get_long_running_output(pipeline_response): - response = pipeline_response.http_response - deserialized = self._deserialize('DeploymentExtended', pipeline_response) - if cls: - return cls(pipeline_response, deserialized, {}) - return deserialized - - - if polling is True: polling_method = ARMPolling(lro_delay, **kwargs) - elif polling is False: polling_method = NoPolling() - else: polling_method = polling - if cont_token: - return LROPoller.from_continuation_token( - polling_method=polling_method, - continuation_token=cont_token, - client=self._client, - deserialization_callback=get_long_running_output - ) - return LROPoller(self._client, raw_result, get_long_running_output, polling_method) - begin_create_or_update_at_management_group_scope.metadata = {'url': "/providers/Microsoft.Management/managementGroups/{groupId}/providers/Microsoft.Resources/deployments/{deploymentName}"} # type: ignore - - @distributed_trace - def get_at_management_group_scope( + @overload + def begin_create_or_update_at_management_group_scope( self, group_id: str, deployment_name: str, + parameters: IO, + *, + content_type: str = "application/json", **kwargs: Any - ) -> "_models.DeploymentExtended": - """Gets a deployment. + ) -> LROPoller[_models.DeploymentExtended]: + """Deploys resources at management group scope. + + You can provide the template and parameters directly in the request or link to JSON files. - :param group_id: The management group ID. + :param group_id: The management group ID. Required. :type group_id: str - :param deployment_name: The name of the deployment. + :param deployment_name: The name of the deployment. Required. :type deployment_name: str + :param parameters: Additional parameters supplied to the operation. Required. + :type parameters: IO + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: DeploymentExtended, or the result of cls(response) - :rtype: ~azure.mgmt.resource.resources.v2020_10_01.models.DeploymentExtended - :raises: ~azure.core.exceptions.HttpResponseError - """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.DeploymentExtended"] - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {})) - - api_version = kwargs.pop('api_version', "2020-10-01") # type: str - - - request = build_deployments_get_at_management_group_scope_request( - group_id=group_id, + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be ARMPolling. Pass in False for this + operation to not poll, or pass in your own initialized polling object for a personal polling + strategy. + :paramtype polling: bool or ~azure.core.polling.PollingMethod + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of LROPoller that returns either DeploymentExtended or the result of + cls(response) + :rtype: + ~azure.core.polling.LROPoller[~azure.mgmt.resource.resources.v2020_10_01.models.DeploymentExtended] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace + def begin_create_or_update_at_management_group_scope( + self, group_id: str, deployment_name: str, parameters: Union[_models.ScopedDeployment, IO], **kwargs: Any + ) -> LROPoller[_models.DeploymentExtended]: + """Deploys resources at management group scope. + + You can provide the template and parameters directly in the request or link to JSON files. + + :param group_id: The management group ID. Required. + :type group_id: str + :param deployment_name: The name of the deployment. Required. + :type deployment_name: str + :param parameters: Additional parameters supplied to the operation. Is either a model type or a + IO type. Required. + :type parameters: ~azure.mgmt.resource.resources.v2020_10_01.models.ScopedDeployment or IO + :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. + Default value is None. + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be ARMPolling. Pass in False for this + operation to not poll, or pass in your own initialized polling object for a personal polling + strategy. + :paramtype polling: bool or ~azure.core.polling.PollingMethod + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of LROPoller that returns either DeploymentExtended or the result of + cls(response) + :rtype: + ~azure.core.polling.LROPoller[~azure.mgmt.resource.resources.v2020_10_01.models.DeploymentExtended] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _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", "2020-10-01")) # type: str + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.DeploymentExtended] + polling = kwargs.pop("polling", True) # type: Union[bool, PollingMethod] + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token = kwargs.pop("continuation_token", None) # type: Optional[str] + if cont_token is None: + raw_result = self._create_or_update_at_management_group_scope_initial( # type: ignore + group_id=group_id, + deployment_name=deployment_name, + parameters=parameters, + api_version=api_version, + content_type=content_type, + cls=lambda x, y, z: x, + headers=_headers, + params=_params, + **kwargs + ) + kwargs.pop("error_map", None) + + def get_long_running_output(pipeline_response): + deserialized = self._deserialize("DeploymentExtended", pipeline_response) + if cls: + return cls(pipeline_response, deserialized, {}) + return deserialized + + if polling is True: + polling_method = cast(PollingMethod, ARMPolling(lro_delay, **kwargs)) # type: PollingMethod + elif polling is False: + polling_method = cast(PollingMethod, NoPolling()) + else: + polling_method = polling + if cont_token: + return LROPoller.from_continuation_token( + polling_method=polling_method, + continuation_token=cont_token, + client=self._client, + deserialization_callback=get_long_running_output, + ) + return LROPoller(self._client, raw_result, get_long_running_output, polling_method) + + begin_create_or_update_at_management_group_scope.metadata = {"url": "/providers/Microsoft.Management/managementGroups/{groupId}/providers/Microsoft.Resources/deployments/{deploymentName}"} # type: ignore + + @distributed_trace + def get_at_management_group_scope( + self, group_id: str, deployment_name: str, **kwargs: Any + ) -> _models.DeploymentExtended: + """Gets a deployment. + + :param group_id: The management group ID. Required. + :type group_id: str + :param deployment_name: The name of the deployment. Required. + :type deployment_name: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: DeploymentExtended or the result of cls(response) + :rtype: ~azure.mgmt.resource.resources.v2020_10_01.models.DeploymentExtended + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2020-10-01")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[_models.DeploymentExtended] + + request = build_deployments_get_at_management_group_scope_request( + group_id=group_id, deployment_name=deployment_name, api_version=api_version, - template_url=self.get_at_management_group_scope.metadata['url'], + template_url=self.get_at_management_group_scope.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) - deserialized = self._deserialize('DeploymentExtended', pipeline_response) + deserialized = self._deserialize("DeploymentExtended", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - get_at_management_group_scope.metadata = {'url': "/providers/Microsoft.Management/managementGroups/{groupId}/providers/Microsoft.Resources/deployments/{deploymentName}"} # type: ignore - + get_at_management_group_scope.metadata = {"url": "/providers/Microsoft.Management/managementGroups/{groupId}/providers/Microsoft.Resources/deployments/{deploymentName}"} # type: ignore @distributed_trace def cancel_at_management_group_scope( # pylint: disable=inconsistent-return-statements - self, - group_id: str, - deployment_name: str, - **kwargs: Any + self, group_id: str, deployment_name: str, **kwargs: Any ) -> None: """Cancels a currently running template deployment. @@ -5452,38 +5285,44 @@ def cancel_at_management_group_scope( # pylint: disable=inconsistent-return-sta deployment stops the currently running template deployment and leaves the resources partially deployed. - :param group_id: The management group ID. + :param group_id: The management group ID. Required. :type group_id: str - :param deployment_name: The name of the deployment. + :param deployment_name: The name of the deployment. Required. :type deployment_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: None, or the result of cls(response) + :return: None or the result of cls(response) :rtype: None - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType[None] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) - api_version = kwargs.pop('api_version', "2020-10-01") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2020-10-01")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[None] - request = build_deployments_cancel_at_management_group_scope_request( group_id=group_id, deployment_name=deployment_name, api_version=api_version, - template_url=self.cancel_at_management_group_scope.metadata['url'], + template_url=self.cancel_at_management_group_scope.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [204]: @@ -5493,43 +5332,52 @@ def cancel_at_management_group_scope( # pylint: disable=inconsistent-return-sta if cls: return cls(pipeline_response, None, {}) - cancel_at_management_group_scope.metadata = {'url': "/providers/Microsoft.Management/managementGroups/{groupId}/providers/Microsoft.Resources/deployments/{deploymentName}/cancel"} # type: ignore - + cancel_at_management_group_scope.metadata = {"url": "/providers/Microsoft.Management/managementGroups/{groupId}/providers/Microsoft.Resources/deployments/{deploymentName}/cancel"} # type: ignore def _validate_at_management_group_scope_initial( - self, - group_id: str, - deployment_name: str, - parameters: "_models.ScopedDeployment", - **kwargs: Any - ) -> Optional["_models.DeploymentValidateResult"]: - cls = kwargs.pop('cls', None) # type: ClsType[Optional["_models.DeploymentValidateResult"]] + self, group_id: str, deployment_name: str, parameters: Union[_models.ScopedDeployment, IO], **kwargs: Any + ) -> Optional[_models.DeploymentValidateResult]: error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', "2020-10-01") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + api_version = kwargs.pop("api_version", _params.pop("api-version", "2020-10-01")) # type: str + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[Optional[_models.DeploymentValidateResult]] - _json = self._serialize.body(parameters, 'ScopedDeployment') + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(parameters, (IO, bytes)): + _content = parameters + else: + _json = self._serialize.body(parameters, "ScopedDeployment") - request = build_deployments_validate_at_management_group_scope_request_initial( + request = build_deployments_validate_at_management_group_scope_request( group_id=group_id, deployment_name=deployment_name, api_version=api_version, content_type=content_type, json=_json, - template_url=self._validate_at_management_group_scope_initial.metadata['url'], + content=_content, + template_url=self._validate_at_management_group_scope_initial.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200, 202, 400]: @@ -5538,36 +5386,40 @@ def _validate_at_management_group_scope_initial( deserialized = None if response.status_code == 200: - deserialized = self._deserialize('DeploymentValidateResult', pipeline_response) + deserialized = self._deserialize("DeploymentValidateResult", pipeline_response) if response.status_code == 400: - deserialized = self._deserialize('DeploymentValidateResult', pipeline_response) + deserialized = self._deserialize("DeploymentValidateResult", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - _validate_at_management_group_scope_initial.metadata = {'url': "/providers/Microsoft.Management/managementGroups/{groupId}/providers/Microsoft.Resources/deployments/{deploymentName}/validate"} # type: ignore - + _validate_at_management_group_scope_initial.metadata = {"url": "/providers/Microsoft.Management/managementGroups/{groupId}/providers/Microsoft.Resources/deployments/{deploymentName}/validate"} # type: ignore - @distributed_trace + @overload def begin_validate_at_management_group_scope( self, group_id: str, deployment_name: str, - parameters: "_models.ScopedDeployment", + parameters: _models.ScopedDeployment, + *, + content_type: str = "application/json", **kwargs: Any - ) -> LROPoller["_models.DeploymentValidateResult"]: + ) -> LROPoller[_models.DeploymentValidateResult]: """Validates whether the specified template is syntactically correct and will be accepted by Azure Resource Manager.. - :param group_id: The management group ID. + :param group_id: The management group ID. Required. :type group_id: str - :param deployment_name: The name of the deployment. + :param deployment_name: The name of the deployment. Required. :type deployment_name: str - :param parameters: Parameters to validate. + :param parameters: Parameters to validate. Required. :type parameters: ~azure.mgmt.resource.resources.v2020_10_01.models.ScopedDeployment + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str :keyword callable cls: A custom type or function that will be passed the direct response :keyword str continuation_token: A continuation token to restart a poller from a saved state. :keyword polling: By default, your polling method will be ARMPolling. Pass in False for this @@ -5580,85 +5432,166 @@ def begin_validate_at_management_group_scope( cls(response) :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.resource.resources.v2020_10_01.models.DeploymentValidateResult] - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - api_version = kwargs.pop('api_version', "2020-10-01") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] - polling = kwargs.pop('polling', True) # type: Union[bool, PollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType["_models.DeploymentValidateResult"] - lro_delay = kwargs.pop( - 'polling_interval', - self._config.polling_interval - ) - cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] + + @overload + def begin_validate_at_management_group_scope( + self, + group_id: str, + deployment_name: str, + parameters: IO, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> LROPoller[_models.DeploymentValidateResult]: + """Validates whether the specified template is syntactically correct and will be accepted by Azure + Resource Manager.. + + :param group_id: The management group ID. Required. + :type group_id: str + :param deployment_name: The name of the deployment. Required. + :type deployment_name: str + :param parameters: Parameters to validate. Required. + :type parameters: IO + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be ARMPolling. Pass in False for this + operation to not poll, or pass in your own initialized polling object for a personal polling + strategy. + :paramtype polling: bool or ~azure.core.polling.PollingMethod + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of LROPoller that returns either DeploymentValidateResult or the result of + cls(response) + :rtype: + ~azure.core.polling.LROPoller[~azure.mgmt.resource.resources.v2020_10_01.models.DeploymentValidateResult] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace + def begin_validate_at_management_group_scope( + self, group_id: str, deployment_name: str, parameters: Union[_models.ScopedDeployment, IO], **kwargs: Any + ) -> LROPoller[_models.DeploymentValidateResult]: + """Validates whether the specified template is syntactically correct and will be accepted by Azure + Resource Manager.. + + :param group_id: The management group ID. Required. + :type group_id: str + :param deployment_name: The name of the deployment. Required. + :type deployment_name: str + :param parameters: Parameters to validate. Is either a model type or a IO type. Required. + :type parameters: ~azure.mgmt.resource.resources.v2020_10_01.models.ScopedDeployment or IO + :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. + Default value is None. + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be ARMPolling. Pass in False for this + operation to not poll, or pass in your own initialized polling object for a personal polling + strategy. + :paramtype polling: bool or ~azure.core.polling.PollingMethod + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of LROPoller that returns either DeploymentValidateResult or the result of + cls(response) + :rtype: + ~azure.core.polling.LROPoller[~azure.mgmt.resource.resources.v2020_10_01.models.DeploymentValidateResult] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _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", "2020-10-01")) # type: str + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.DeploymentValidateResult] + polling = kwargs.pop("polling", True) # type: Union[bool, PollingMethod] + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token = kwargs.pop("continuation_token", None) # type: Optional[str] if cont_token is None: - raw_result = self._validate_at_management_group_scope_initial( + raw_result = self._validate_at_management_group_scope_initial( # type: ignore group_id=group_id, deployment_name=deployment_name, parameters=parameters, api_version=api_version, content_type=content_type, - cls=lambda x,y,z: x, + cls=lambda x, y, z: x, + headers=_headers, + params=_params, **kwargs ) - kwargs.pop('error_map', None) + kwargs.pop("error_map", None) def get_long_running_output(pipeline_response): - response = pipeline_response.http_response - deserialized = self._deserialize('DeploymentValidateResult', pipeline_response) + deserialized = self._deserialize("DeploymentValidateResult", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - - if polling is True: polling_method = ARMPolling(lro_delay, **kwargs) - elif polling is False: polling_method = NoPolling() - else: polling_method = polling + if polling is True: + polling_method = cast(PollingMethod, ARMPolling(lro_delay, **kwargs)) # type: PollingMethod + elif polling is False: + polling_method = cast(PollingMethod, NoPolling()) + else: + polling_method = polling if cont_token: return LROPoller.from_continuation_token( polling_method=polling_method, continuation_token=cont_token, client=self._client, - deserialization_callback=get_long_running_output + deserialization_callback=get_long_running_output, ) return LROPoller(self._client, raw_result, get_long_running_output, polling_method) - begin_validate_at_management_group_scope.metadata = {'url': "/providers/Microsoft.Management/managementGroups/{groupId}/providers/Microsoft.Resources/deployments/{deploymentName}/validate"} # type: ignore + begin_validate_at_management_group_scope.metadata = {"url": "/providers/Microsoft.Management/managementGroups/{groupId}/providers/Microsoft.Resources/deployments/{deploymentName}/validate"} # type: ignore def _what_if_at_management_group_scope_initial( - self, - group_id: str, - deployment_name: str, - parameters: "_models.ScopedDeploymentWhatIf", - **kwargs: Any - ) -> Optional["_models.WhatIfOperationResult"]: - cls = kwargs.pop('cls', None) # type: ClsType[Optional["_models.WhatIfOperationResult"]] + self, group_id: str, deployment_name: str, parameters: Union[_models.ScopedDeploymentWhatIf, IO], **kwargs: Any + ) -> Optional[_models.WhatIfOperationResult]: error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) - api_version = kwargs.pop('api_version', "2020-10-01") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - _json = self._serialize.body(parameters, 'ScopedDeploymentWhatIf') + api_version = kwargs.pop("api_version", _params.pop("api-version", "2020-10-01")) # type: str + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[Optional[_models.WhatIfOperationResult]] - request = build_deployments_what_if_at_management_group_scope_request_initial( + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(parameters, (IO, bytes)): + _content = parameters + else: + _json = self._serialize.body(parameters, "ScopedDeploymentWhatIf") + + request = build_deployments_what_if_at_management_group_scope_request( group_id=group_id, deployment_name=deployment_name, api_version=api_version, content_type=content_type, json=_json, - template_url=self._what_if_at_management_group_scope_initial.metadata['url'], + content=_content, + template_url=self._what_if_at_management_group_scope_initial.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200, 202]: @@ -5668,38 +5601,41 @@ def _what_if_at_management_group_scope_initial( deserialized = None response_headers = {} if response.status_code == 200: - deserialized = self._deserialize('WhatIfOperationResult', pipeline_response) + deserialized = self._deserialize("WhatIfOperationResult", pipeline_response) if response.status_code == 202: - response_headers['Location']=self._deserialize('str', response.headers.get('Location')) - response_headers['Retry-After']=self._deserialize('str', response.headers.get('Retry-After')) - + response_headers["Location"] = self._deserialize("str", response.headers.get("Location")) + response_headers["Retry-After"] = self._deserialize("str", response.headers.get("Retry-After")) if cls: return cls(pipeline_response, deserialized, response_headers) return deserialized - _what_if_at_management_group_scope_initial.metadata = {'url': "/providers/Microsoft.Management/managementGroups/{groupId}/providers/Microsoft.Resources/deployments/{deploymentName}/whatIf"} # type: ignore + _what_if_at_management_group_scope_initial.metadata = {"url": "/providers/Microsoft.Management/managementGroups/{groupId}/providers/Microsoft.Resources/deployments/{deploymentName}/whatIf"} # type: ignore - - @distributed_trace + @overload def begin_what_if_at_management_group_scope( self, group_id: str, deployment_name: str, - parameters: "_models.ScopedDeploymentWhatIf", + parameters: _models.ScopedDeploymentWhatIf, + *, + content_type: str = "application/json", **kwargs: Any - ) -> LROPoller["_models.WhatIfOperationResult"]: + ) -> LROPoller[_models.WhatIfOperationResult]: """Returns changes that will be made by the deployment if executed at the scope of the management group. - :param group_id: The management group ID. + :param group_id: The management group ID. Required. :type group_id: str - :param deployment_name: The name of the deployment. + :param deployment_name: The name of the deployment. Required. :type deployment_name: str - :param parameters: Parameters to validate. + :param parameters: Parameters to validate. Required. :type parameters: ~azure.mgmt.resource.resources.v2020_10_01.models.ScopedDeploymentWhatIf + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str :keyword callable cls: A custom type or function that will be passed the direct response :keyword str continuation_token: A continuation token to restart a poller from a saved state. :keyword polling: By default, your polling method will be ARMPolling. Pass in False for this @@ -5712,119 +5648,191 @@ def begin_what_if_at_management_group_scope( cls(response) :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.resource.resources.v2020_10_01.models.WhatIfOperationResult] - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - api_version = kwargs.pop('api_version', "2020-10-01") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] - polling = kwargs.pop('polling', True) # type: Union[bool, PollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType["_models.WhatIfOperationResult"] - lro_delay = kwargs.pop( - 'polling_interval', - self._config.polling_interval - ) - cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] + + @overload + def begin_what_if_at_management_group_scope( + self, + group_id: str, + deployment_name: str, + parameters: IO, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> LROPoller[_models.WhatIfOperationResult]: + """Returns changes that will be made by the deployment if executed at the scope of the management + group. + + :param group_id: The management group ID. Required. + :type group_id: str + :param deployment_name: The name of the deployment. Required. + :type deployment_name: str + :param parameters: Parameters to validate. Required. + :type parameters: IO + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be ARMPolling. Pass in False for this + operation to not poll, or pass in your own initialized polling object for a personal polling + strategy. + :paramtype polling: bool or ~azure.core.polling.PollingMethod + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of LROPoller that returns either WhatIfOperationResult or the result of + cls(response) + :rtype: + ~azure.core.polling.LROPoller[~azure.mgmt.resource.resources.v2020_10_01.models.WhatIfOperationResult] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace + def begin_what_if_at_management_group_scope( + self, group_id: str, deployment_name: str, parameters: Union[_models.ScopedDeploymentWhatIf, IO], **kwargs: Any + ) -> LROPoller[_models.WhatIfOperationResult]: + """Returns changes that will be made by the deployment if executed at the scope of the management + group. + + :param group_id: The management group ID. Required. + :type group_id: str + :param deployment_name: The name of the deployment. Required. + :type deployment_name: str + :param parameters: Parameters to validate. Is either a model type or a IO type. Required. + :type parameters: ~azure.mgmt.resource.resources.v2020_10_01.models.ScopedDeploymentWhatIf or + IO + :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. + Default value is None. + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be ARMPolling. Pass in False for this + operation to not poll, or pass in your own initialized polling object for a personal polling + strategy. + :paramtype polling: bool or ~azure.core.polling.PollingMethod + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of LROPoller that returns either WhatIfOperationResult or the result of + cls(response) + :rtype: + ~azure.core.polling.LROPoller[~azure.mgmt.resource.resources.v2020_10_01.models.WhatIfOperationResult] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _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", "2020-10-01")) # type: str + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.WhatIfOperationResult] + polling = kwargs.pop("polling", True) # type: Union[bool, PollingMethod] + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token = kwargs.pop("continuation_token", None) # type: Optional[str] if cont_token is None: - raw_result = self._what_if_at_management_group_scope_initial( + raw_result = self._what_if_at_management_group_scope_initial( # type: ignore group_id=group_id, deployment_name=deployment_name, parameters=parameters, api_version=api_version, content_type=content_type, - cls=lambda x,y,z: x, + cls=lambda x, y, z: x, + headers=_headers, + params=_params, **kwargs ) - kwargs.pop('error_map', None) + kwargs.pop("error_map", None) def get_long_running_output(pipeline_response): - response = pipeline_response.http_response - deserialized = self._deserialize('WhatIfOperationResult', pipeline_response) + deserialized = self._deserialize("WhatIfOperationResult", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - - if polling is True: polling_method = ARMPolling(lro_delay, lro_options={'final-state-via': 'location'}, **kwargs) - elif polling is False: polling_method = NoPolling() - else: polling_method = polling + if polling is True: + polling_method = cast( + PollingMethod, ARMPolling(lro_delay, lro_options={"final-state-via": "location"}, **kwargs) + ) # type: PollingMethod + elif polling is False: + polling_method = cast(PollingMethod, NoPolling()) + else: + polling_method = polling if cont_token: return LROPoller.from_continuation_token( polling_method=polling_method, continuation_token=cont_token, client=self._client, - deserialization_callback=get_long_running_output + deserialization_callback=get_long_running_output, ) return LROPoller(self._client, raw_result, get_long_running_output, polling_method) - begin_what_if_at_management_group_scope.metadata = {'url': "/providers/Microsoft.Management/managementGroups/{groupId}/providers/Microsoft.Resources/deployments/{deploymentName}/whatIf"} # type: ignore + begin_what_if_at_management_group_scope.metadata = {"url": "/providers/Microsoft.Management/managementGroups/{groupId}/providers/Microsoft.Resources/deployments/{deploymentName}/whatIf"} # type: ignore @distributed_trace def export_template_at_management_group_scope( - self, - group_id: str, - deployment_name: str, - **kwargs: Any - ) -> "_models.DeploymentExportResult": + self, group_id: str, deployment_name: str, **kwargs: Any + ) -> _models.DeploymentExportResult: """Exports the template used for specified deployment. - :param group_id: The management group ID. + :param group_id: The management group ID. Required. :type group_id: str - :param deployment_name: The name of the deployment. + :param deployment_name: The name of the deployment. Required. :type deployment_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: DeploymentExportResult, or the result of cls(response) + :return: DeploymentExportResult or the result of cls(response) :rtype: ~azure.mgmt.resource.resources.v2020_10_01.models.DeploymentExportResult - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.DeploymentExportResult"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + 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', "2020-10-01") # type: str + api_version = kwargs.pop("api_version", _params.pop("api-version", "2020-10-01")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[_models.DeploymentExportResult] - request = build_deployments_export_template_at_management_group_scope_request( group_id=group_id, deployment_name=deployment_name, api_version=api_version, - template_url=self.export_template_at_management_group_scope.metadata['url'], + template_url=self.export_template_at_management_group_scope.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) - deserialized = self._deserialize('DeploymentExportResult', pipeline_response) + deserialized = self._deserialize("DeploymentExportResult", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - export_template_at_management_group_scope.metadata = {'url': "/providers/Microsoft.Management/managementGroups/{groupId}/providers/Microsoft.Resources/deployments/{deploymentName}/exportTemplate"} # type: ignore - + export_template_at_management_group_scope.metadata = {"url": "/providers/Microsoft.Management/managementGroups/{groupId}/providers/Microsoft.Resources/deployments/{deploymentName}/exportTemplate"} # type: ignore @distributed_trace def list_at_management_group_scope( - self, - group_id: str, - filter: Optional[str] = None, - top: Optional[int] = None, - **kwargs: Any - ) -> Iterable["_models.DeploymentListResult"]: + self, group_id: str, filter: Optional[str] = None, top: Optional[int] = None, **kwargs: Any + ) -> Iterable["_models.DeploymentExtended"]: """Get all the deployments for a management group. - :param group_id: The management group ID. + :param group_id: The management group ID. Required. :type group_id: str :param filter: The filter to apply on the operation. For example, you can use $filter=provisioningState eq '{state}'. Default value is None. @@ -5833,40 +5841,48 @@ def list_at_management_group_scope( value is None. :type top: int :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either DeploymentListResult or the result of - cls(response) + :return: An iterator like instance of either DeploymentExtended or the result of cls(response) :rtype: - ~azure.core.paging.ItemPaged[~azure.mgmt.resource.resources.v2020_10_01.models.DeploymentListResult] - :raises: ~azure.core.exceptions.HttpResponseError + ~azure.core.paging.ItemPaged[~azure.mgmt.resource.resources.v2020_10_01.models.DeploymentExtended] + :raises ~azure.core.exceptions.HttpResponseError: """ - api_version = kwargs.pop('api_version', "2020-10-01") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2020-10-01")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[_models.DeploymentListResult] - cls = kwargs.pop('cls', None) # type: ClsType["_models.DeploymentListResult"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) + def prepare_request(next_link=None): if not next_link: - + request = build_deployments_list_at_management_group_scope_request( group_id=group_id, - api_version=api_version, filter=filter, top=top, - template_url=self.list_at_management_group_scope.metadata['url'], + api_version=api_version, + template_url=self.list_at_management_group_scope.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore else: - - request = build_deployments_list_at_management_group_scope_request( - group_id=group_id, - template_url=next_link, - ) + # make call to next link with the client's api-version + _parsed_next_link = urlparse(next_link) + _next_request_params = case_insensitive_dict(parse_qs(_parsed_next_link.query)) + _next_request_params["api-version"] = self._config.api_version + request = HttpRequest("GET", urljoin(next_link, _parsed_next_link.path), params=_next_request_params) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore request.method = "GET" return request @@ -5880,10 +5896,8 @@ def extract_data(pipeline_response): def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) response = pipeline_response.http_response @@ -5893,40 +5907,42 @@ def get_next(next_link=None): return pipeline_response + return ItemPaged(get_next, extract_data) - return ItemPaged( - get_next, extract_data - ) - list_at_management_group_scope.metadata = {'url': "/providers/Microsoft.Management/managementGroups/{groupId}/providers/Microsoft.Resources/deployments/"} # type: ignore + list_at_management_group_scope.metadata = {"url": "/providers/Microsoft.Management/managementGroups/{groupId}/providers/Microsoft.Resources/deployments/"} # type: ignore def _delete_at_subscription_scope_initial( # pylint: disable=inconsistent-return-statements - self, - deployment_name: str, - **kwargs: Any + self, deployment_name: str, **kwargs: Any ) -> None: - cls = kwargs.pop('cls', None) # type: ClsType[None] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + 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', "2020-10-01") # type: str + api_version = kwargs.pop("api_version", _params.pop("api-version", "2020-10-01")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[None] - - request = build_deployments_delete_at_subscription_scope_request_initial( + request = build_deployments_delete_at_subscription_scope_request( deployment_name=deployment_name, subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self._delete_at_subscription_scope_initial.metadata['url'], + template_url=self._delete_at_subscription_scope_initial.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [202, 204]: @@ -5936,15 +5952,10 @@ def _delete_at_subscription_scope_initial( # pylint: disable=inconsistent-retur if cls: return cls(pipeline_response, None, {}) - _delete_at_subscription_scope_initial.metadata = {'url': "/subscriptions/{subscriptionId}/providers/Microsoft.Resources/deployments/{deploymentName}"} # type: ignore - + _delete_at_subscription_scope_initial.metadata = {"url": "/subscriptions/{subscriptionId}/providers/Microsoft.Resources/deployments/{deploymentName}"} # type: ignore @distributed_trace - def begin_delete_at_subscription_scope( # pylint: disable=inconsistent-return-statements - self, - deployment_name: str, - **kwargs: Any - ) -> LROPoller[None]: + def begin_delete_at_subscription_scope(self, deployment_name: str, **kwargs: Any) -> LROPoller[None]: """Deletes a deployment from the deployment history. A template deployment that is currently running cannot be deleted. Deleting a template @@ -5955,7 +5966,7 @@ def begin_delete_at_subscription_scope( # pylint: disable=inconsistent-return-s process finishes, the URI in the Location header returns a status of 204 on success. If the asynchronous request failed, the URI in the Location header returns an error-level status code. - :param deployment_name: The name of the deployment. + :param deployment_name: The name of the deployment. Required. :type deployment_name: str :keyword callable cls: A custom type or function that will be passed the direct response :keyword str continuation_token: A continuation token to restart a poller from a saved state. @@ -5967,82 +5978,88 @@ def begin_delete_at_subscription_scope( # pylint: disable=inconsistent-return-s Retry-After header is present. :return: An instance of LROPoller that returns either None or the result of cls(response) :rtype: ~azure.core.polling.LROPoller[None] - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - api_version = kwargs.pop('api_version', "2020-10-01") # type: str - polling = kwargs.pop('polling', True) # type: Union[bool, PollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType[None] - lro_delay = kwargs.pop( - 'polling_interval', - self._config.polling_interval - ) - cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2020-10-01")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[None] + polling = kwargs.pop("polling", True) # type: Union[bool, PollingMethod] + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token = kwargs.pop("continuation_token", None) # type: Optional[str] if cont_token is None: - raw_result = self._delete_at_subscription_scope_initial( + raw_result = self._delete_at_subscription_scope_initial( # type: ignore deployment_name=deployment_name, api_version=api_version, - cls=lambda x,y,z: x, + cls=lambda x, y, z: x, + headers=_headers, + params=_params, **kwargs ) - kwargs.pop('error_map', None) + kwargs.pop("error_map", None) - def get_long_running_output(pipeline_response): + def get_long_running_output(pipeline_response): # pylint: disable=inconsistent-return-statements if cls: return cls(pipeline_response, None, {}) - - if polling is True: polling_method = ARMPolling(lro_delay, **kwargs) - elif polling is False: polling_method = NoPolling() - else: polling_method = polling + if polling is True: + polling_method = cast(PollingMethod, ARMPolling(lro_delay, **kwargs)) # type: PollingMethod + elif polling is False: + polling_method = cast(PollingMethod, NoPolling()) + else: + polling_method = polling if cont_token: return LROPoller.from_continuation_token( polling_method=polling_method, continuation_token=cont_token, client=self._client, - deserialization_callback=get_long_running_output + deserialization_callback=get_long_running_output, ) return LROPoller(self._client, raw_result, get_long_running_output, polling_method) - begin_delete_at_subscription_scope.metadata = {'url': "/subscriptions/{subscriptionId}/providers/Microsoft.Resources/deployments/{deploymentName}"} # type: ignore + begin_delete_at_subscription_scope.metadata = {"url": "/subscriptions/{subscriptionId}/providers/Microsoft.Resources/deployments/{deploymentName}"} # type: ignore @distributed_trace - def check_existence_at_subscription_scope( - self, - deployment_name: str, - **kwargs: Any - ) -> bool: + def check_existence_at_subscription_scope(self, deployment_name: str, **kwargs: Any) -> bool: """Checks whether the deployment exists. - :param deployment_name: The name of the deployment. + :param deployment_name: The name of the deployment. Required. :type deployment_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: bool, or the result of cls(response) + :return: bool or the result of cls(response) :rtype: bool - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType[None] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + 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', "2020-10-01") # type: str + api_version = kwargs.pop("api_version", _params.pop("api-version", "2020-10-01")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[None] - request = build_deployments_check_existence_at_subscription_scope_request( deployment_name=deployment_name, subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.check_existence_at_subscription_scope.metadata['url'], + template_url=self.check_existence_at_subscription_scope.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [204, 404]: @@ -6053,42 +6070,52 @@ def check_existence_at_subscription_scope( return cls(pipeline_response, None, {}) return 200 <= response.status_code <= 299 - check_existence_at_subscription_scope.metadata = {'url': "/subscriptions/{subscriptionId}/providers/Microsoft.Resources/deployments/{deploymentName}"} # type: ignore - + check_existence_at_subscription_scope.metadata = {"url": "/subscriptions/{subscriptionId}/providers/Microsoft.Resources/deployments/{deploymentName}"} # type: ignore def _create_or_update_at_subscription_scope_initial( - self, - deployment_name: str, - parameters: "_models.Deployment", - **kwargs: Any - ) -> "_models.DeploymentExtended": - cls = kwargs.pop('cls', None) # type: ClsType["_models.DeploymentExtended"] + self, deployment_name: str, parameters: Union[_models.Deployment, IO], **kwargs: Any + ) -> _models.DeploymentExtended: error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', "2020-10-01") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + api_version = kwargs.pop("api_version", _params.pop("api-version", "2020-10-01")) # type: str + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.DeploymentExtended] - _json = self._serialize.body(parameters, 'Deployment') + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(parameters, (IO, bytes)): + _content = parameters + else: + _json = self._serialize.body(parameters, "Deployment") - request = build_deployments_create_or_update_at_subscription_scope_request_initial( + request = build_deployments_create_or_update_at_subscription_scope_request( deployment_name=deployment_name, subscription_id=self._config.subscription_id, api_version=api_version, content_type=content_type, json=_json, - template_url=self._create_or_update_at_subscription_scope_initial.metadata['url'], + content=_content, + template_url=self._create_or_update_at_subscription_scope_initial.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200, 201]: @@ -6096,34 +6123,38 @@ def _create_or_update_at_subscription_scope_initial( raise HttpResponseError(response=response, error_format=ARMErrorFormat) if response.status_code == 200: - deserialized = self._deserialize('DeploymentExtended', pipeline_response) + deserialized = self._deserialize("DeploymentExtended", pipeline_response) if response.status_code == 201: - deserialized = self._deserialize('DeploymentExtended', pipeline_response) + deserialized = self._deserialize("DeploymentExtended", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - _create_or_update_at_subscription_scope_initial.metadata = {'url': "/subscriptions/{subscriptionId}/providers/Microsoft.Resources/deployments/{deploymentName}"} # type: ignore - + _create_or_update_at_subscription_scope_initial.metadata = {"url": "/subscriptions/{subscriptionId}/providers/Microsoft.Resources/deployments/{deploymentName}"} # type: ignore - @distributed_trace + @overload def begin_create_or_update_at_subscription_scope( self, deployment_name: str, - parameters: "_models.Deployment", + parameters: _models.Deployment, + *, + content_type: str = "application/json", **kwargs: Any - ) -> LROPoller["_models.DeploymentExtended"]: + ) -> LROPoller[_models.DeploymentExtended]: """Deploys resources at subscription scope. You can provide the template and parameters directly in the request or link to JSON files. - :param deployment_name: The name of the deployment. + :param deployment_name: The name of the deployment. Required. :type deployment_name: str - :param parameters: Additional parameters supplied to the operation. + :param parameters: Additional parameters supplied to the operation. Required. :type parameters: ~azure.mgmt.resource.resources.v2020_10_01.models.Deployment + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str :keyword callable cls: A custom type or function that will be passed the direct response :keyword str continuation_token: A continuation token to restart a poller from a saved state. :keyword polling: By default, your polling method will be ARMPolling. Pass in False for this @@ -6136,109 +6167,172 @@ def begin_create_or_update_at_subscription_scope( cls(response) :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.resource.resources.v2020_10_01.models.DeploymentExtended] - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - api_version = kwargs.pop('api_version', "2020-10-01") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] - polling = kwargs.pop('polling', True) # type: Union[bool, PollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType["_models.DeploymentExtended"] - lro_delay = kwargs.pop( - 'polling_interval', - self._config.polling_interval - ) - cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] - if cont_token is None: - raw_result = self._create_or_update_at_subscription_scope_initial( - deployment_name=deployment_name, - parameters=parameters, - api_version=api_version, - content_type=content_type, - cls=lambda x,y,z: x, - **kwargs - ) - kwargs.pop('error_map', None) - def get_long_running_output(pipeline_response): - response = pipeline_response.http_response - deserialized = self._deserialize('DeploymentExtended', pipeline_response) + @overload + def begin_create_or_update_at_subscription_scope( + self, deployment_name: str, parameters: IO, *, content_type: str = "application/json", **kwargs: Any + ) -> LROPoller[_models.DeploymentExtended]: + """Deploys resources at subscription scope. + + You can provide the template and parameters directly in the request or link to JSON files. + + :param deployment_name: The name of the deployment. Required. + :type deployment_name: str + :param parameters: Additional parameters supplied to the operation. Required. + :type parameters: IO + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be ARMPolling. Pass in False for this + operation to not poll, or pass in your own initialized polling object for a personal polling + strategy. + :paramtype polling: bool or ~azure.core.polling.PollingMethod + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of LROPoller that returns either DeploymentExtended or the result of + cls(response) + :rtype: + ~azure.core.polling.LROPoller[~azure.mgmt.resource.resources.v2020_10_01.models.DeploymentExtended] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace + def begin_create_or_update_at_subscription_scope( + self, deployment_name: str, parameters: Union[_models.Deployment, IO], **kwargs: Any + ) -> LROPoller[_models.DeploymentExtended]: + """Deploys resources at subscription scope. + + You can provide the template and parameters directly in the request or link to JSON files. + + :param deployment_name: The name of the deployment. Required. + :type deployment_name: str + :param parameters: Additional parameters supplied to the operation. Is either a model type or a + IO type. Required. + :type parameters: ~azure.mgmt.resource.resources.v2020_10_01.models.Deployment or IO + :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. + Default value is None. + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be ARMPolling. Pass in False for this + operation to not poll, or pass in your own initialized polling object for a personal polling + strategy. + :paramtype polling: bool or ~azure.core.polling.PollingMethod + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of LROPoller that returns either DeploymentExtended or the result of + cls(response) + :rtype: + ~azure.core.polling.LROPoller[~azure.mgmt.resource.resources.v2020_10_01.models.DeploymentExtended] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _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", "2020-10-01")) # type: str + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.DeploymentExtended] + polling = kwargs.pop("polling", True) # type: Union[bool, PollingMethod] + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token = kwargs.pop("continuation_token", None) # type: Optional[str] + if cont_token is None: + raw_result = self._create_or_update_at_subscription_scope_initial( # type: ignore + deployment_name=deployment_name, + parameters=parameters, + api_version=api_version, + content_type=content_type, + cls=lambda x, y, z: x, + headers=_headers, + params=_params, + **kwargs + ) + kwargs.pop("error_map", None) + + def get_long_running_output(pipeline_response): + deserialized = self._deserialize("DeploymentExtended", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - - if polling is True: polling_method = ARMPolling(lro_delay, **kwargs) - elif polling is False: polling_method = NoPolling() - else: polling_method = polling + if polling is True: + polling_method = cast(PollingMethod, ARMPolling(lro_delay, **kwargs)) # type: PollingMethod + elif polling is False: + polling_method = cast(PollingMethod, NoPolling()) + else: + polling_method = polling if cont_token: return LROPoller.from_continuation_token( polling_method=polling_method, continuation_token=cont_token, client=self._client, - deserialization_callback=get_long_running_output + deserialization_callback=get_long_running_output, ) return LROPoller(self._client, raw_result, get_long_running_output, polling_method) - begin_create_or_update_at_subscription_scope.metadata = {'url': "/subscriptions/{subscriptionId}/providers/Microsoft.Resources/deployments/{deploymentName}"} # type: ignore + begin_create_or_update_at_subscription_scope.metadata = {"url": "/subscriptions/{subscriptionId}/providers/Microsoft.Resources/deployments/{deploymentName}"} # type: ignore @distributed_trace - def get_at_subscription_scope( - self, - deployment_name: str, - **kwargs: Any - ) -> "_models.DeploymentExtended": + def get_at_subscription_scope(self, deployment_name: str, **kwargs: Any) -> _models.DeploymentExtended: """Gets a deployment. - :param deployment_name: The name of the deployment. + :param deployment_name: The name of the deployment. Required. :type deployment_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: DeploymentExtended, or the result of cls(response) + :return: DeploymentExtended or the result of cls(response) :rtype: ~azure.mgmt.resource.resources.v2020_10_01.models.DeploymentExtended - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.DeploymentExtended"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) - api_version = kwargs.pop('api_version', "2020-10-01") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2020-10-01")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[_models.DeploymentExtended] - request = build_deployments_get_at_subscription_scope_request( deployment_name=deployment_name, subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.get_at_subscription_scope.metadata['url'], + template_url=self.get_at_subscription_scope.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) - deserialized = self._deserialize('DeploymentExtended', pipeline_response) + deserialized = self._deserialize("DeploymentExtended", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - get_at_subscription_scope.metadata = {'url': "/subscriptions/{subscriptionId}/providers/Microsoft.Resources/deployments/{deploymentName}"} # type: ignore - + get_at_subscription_scope.metadata = {"url": "/subscriptions/{subscriptionId}/providers/Microsoft.Resources/deployments/{deploymentName}"} # type: ignore @distributed_trace def cancel_at_subscription_scope( # pylint: disable=inconsistent-return-statements - self, - deployment_name: str, - **kwargs: Any + self, deployment_name: str, **kwargs: Any ) -> None: """Cancels a currently running template deployment. @@ -6247,36 +6341,42 @@ def cancel_at_subscription_scope( # pylint: disable=inconsistent-return-stateme deployment stops the currently running template deployment and leaves the resources partially deployed. - :param deployment_name: The name of the deployment. + :param deployment_name: The name of the deployment. Required. :type deployment_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: None, or the result of cls(response) + :return: None or the result of cls(response) :rtype: None - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType[None] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) - api_version = kwargs.pop('api_version', "2020-10-01") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2020-10-01")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[None] - request = build_deployments_cancel_at_subscription_scope_request( deployment_name=deployment_name, subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.cancel_at_subscription_scope.metadata['url'], + template_url=self.cancel_at_subscription_scope.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [204]: @@ -6286,42 +6386,52 @@ def cancel_at_subscription_scope( # pylint: disable=inconsistent-return-stateme if cls: return cls(pipeline_response, None, {}) - cancel_at_subscription_scope.metadata = {'url': "/subscriptions/{subscriptionId}/providers/Microsoft.Resources/deployments/{deploymentName}/cancel"} # type: ignore - + cancel_at_subscription_scope.metadata = {"url": "/subscriptions/{subscriptionId}/providers/Microsoft.Resources/deployments/{deploymentName}/cancel"} # type: ignore def _validate_at_subscription_scope_initial( - self, - deployment_name: str, - parameters: "_models.Deployment", - **kwargs: Any - ) -> Optional["_models.DeploymentValidateResult"]: - cls = kwargs.pop('cls', None) # type: ClsType[Optional["_models.DeploymentValidateResult"]] + self, deployment_name: str, parameters: Union[_models.Deployment, IO], **kwargs: Any + ) -> Optional[_models.DeploymentValidateResult]: error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) - api_version = kwargs.pop('api_version', "2020-10-01") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - _json = self._serialize.body(parameters, 'Deployment') + api_version = kwargs.pop("api_version", _params.pop("api-version", "2020-10-01")) # type: str + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[Optional[_models.DeploymentValidateResult]] - request = build_deployments_validate_at_subscription_scope_request_initial( + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(parameters, (IO, bytes)): + _content = parameters + else: + _json = self._serialize.body(parameters, "Deployment") + + request = build_deployments_validate_at_subscription_scope_request( deployment_name=deployment_name, subscription_id=self._config.subscription_id, api_version=api_version, content_type=content_type, json=_json, - template_url=self._validate_at_subscription_scope_initial.metadata['url'], + content=_content, + template_url=self._validate_at_subscription_scope_initial.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200, 202, 400]: @@ -6330,33 +6440,37 @@ def _validate_at_subscription_scope_initial( deserialized = None if response.status_code == 200: - deserialized = self._deserialize('DeploymentValidateResult', pipeline_response) + deserialized = self._deserialize("DeploymentValidateResult", pipeline_response) if response.status_code == 400: - deserialized = self._deserialize('DeploymentValidateResult', pipeline_response) + deserialized = self._deserialize("DeploymentValidateResult", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - _validate_at_subscription_scope_initial.metadata = {'url': "/subscriptions/{subscriptionId}/providers/Microsoft.Resources/deployments/{deploymentName}/validate"} # type: ignore + _validate_at_subscription_scope_initial.metadata = {"url": "/subscriptions/{subscriptionId}/providers/Microsoft.Resources/deployments/{deploymentName}/validate"} # type: ignore - - @distributed_trace + @overload def begin_validate_at_subscription_scope( self, deployment_name: str, - parameters: "_models.Deployment", + parameters: _models.Deployment, + *, + content_type: str = "application/json", **kwargs: Any - ) -> LROPoller["_models.DeploymentValidateResult"]: + ) -> LROPoller[_models.DeploymentValidateResult]: """Validates whether the specified template is syntactically correct and will be accepted by Azure Resource Manager.. - :param deployment_name: The name of the deployment. + :param deployment_name: The name of the deployment. Required. :type deployment_name: str - :param parameters: Parameters to validate. + :param parameters: Parameters to validate. Required. :type parameters: ~azure.mgmt.resource.resources.v2020_10_01.models.Deployment + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str :keyword callable cls: A custom type or function that will be passed the direct response :keyword str continuation_token: A continuation token to restart a poller from a saved state. :keyword polling: By default, your polling method will be ARMPolling. Pass in False for this @@ -6369,83 +6483,155 @@ def begin_validate_at_subscription_scope( cls(response) :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.resource.resources.v2020_10_01.models.DeploymentValidateResult] - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - api_version = kwargs.pop('api_version', "2020-10-01") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] - polling = kwargs.pop('polling', True) # type: Union[bool, PollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType["_models.DeploymentValidateResult"] - lro_delay = kwargs.pop( - 'polling_interval', - self._config.polling_interval - ) - cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] + + @overload + def begin_validate_at_subscription_scope( + self, deployment_name: str, parameters: IO, *, content_type: str = "application/json", **kwargs: Any + ) -> LROPoller[_models.DeploymentValidateResult]: + """Validates whether the specified template is syntactically correct and will be accepted by Azure + Resource Manager.. + + :param deployment_name: The name of the deployment. Required. + :type deployment_name: str + :param parameters: Parameters to validate. Required. + :type parameters: IO + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be ARMPolling. Pass in False for this + operation to not poll, or pass in your own initialized polling object for a personal polling + strategy. + :paramtype polling: bool or ~azure.core.polling.PollingMethod + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of LROPoller that returns either DeploymentValidateResult or the result of + cls(response) + :rtype: + ~azure.core.polling.LROPoller[~azure.mgmt.resource.resources.v2020_10_01.models.DeploymentValidateResult] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace + def begin_validate_at_subscription_scope( + self, deployment_name: str, parameters: Union[_models.Deployment, IO], **kwargs: Any + ) -> LROPoller[_models.DeploymentValidateResult]: + """Validates whether the specified template is syntactically correct and will be accepted by Azure + Resource Manager.. + + :param deployment_name: The name of the deployment. Required. + :type deployment_name: str + :param parameters: Parameters to validate. Is either a model type or a IO type. Required. + :type parameters: ~azure.mgmt.resource.resources.v2020_10_01.models.Deployment or IO + :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. + Default value is None. + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be ARMPolling. Pass in False for this + operation to not poll, or pass in your own initialized polling object for a personal polling + strategy. + :paramtype polling: bool or ~azure.core.polling.PollingMethod + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of LROPoller that returns either DeploymentValidateResult or the result of + cls(response) + :rtype: + ~azure.core.polling.LROPoller[~azure.mgmt.resource.resources.v2020_10_01.models.DeploymentValidateResult] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _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", "2020-10-01")) # type: str + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.DeploymentValidateResult] + polling = kwargs.pop("polling", True) # type: Union[bool, PollingMethod] + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token = kwargs.pop("continuation_token", None) # type: Optional[str] if cont_token is None: - raw_result = self._validate_at_subscription_scope_initial( + raw_result = self._validate_at_subscription_scope_initial( # type: ignore deployment_name=deployment_name, parameters=parameters, api_version=api_version, content_type=content_type, - cls=lambda x,y,z: x, + cls=lambda x, y, z: x, + headers=_headers, + params=_params, **kwargs ) - kwargs.pop('error_map', None) + kwargs.pop("error_map", None) def get_long_running_output(pipeline_response): - response = pipeline_response.http_response - deserialized = self._deserialize('DeploymentValidateResult', pipeline_response) + deserialized = self._deserialize("DeploymentValidateResult", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - - if polling is True: polling_method = ARMPolling(lro_delay, **kwargs) - elif polling is False: polling_method = NoPolling() - else: polling_method = polling + if polling is True: + polling_method = cast(PollingMethod, ARMPolling(lro_delay, **kwargs)) # type: PollingMethod + elif polling is False: + polling_method = cast(PollingMethod, NoPolling()) + else: + polling_method = polling if cont_token: return LROPoller.from_continuation_token( polling_method=polling_method, continuation_token=cont_token, client=self._client, - deserialization_callback=get_long_running_output + deserialization_callback=get_long_running_output, ) return LROPoller(self._client, raw_result, get_long_running_output, polling_method) - begin_validate_at_subscription_scope.metadata = {'url': "/subscriptions/{subscriptionId}/providers/Microsoft.Resources/deployments/{deploymentName}/validate"} # type: ignore + begin_validate_at_subscription_scope.metadata = {"url": "/subscriptions/{subscriptionId}/providers/Microsoft.Resources/deployments/{deploymentName}/validate"} # type: ignore def _what_if_at_subscription_scope_initial( - self, - deployment_name: str, - parameters: "_models.DeploymentWhatIf", - **kwargs: Any - ) -> Optional["_models.WhatIfOperationResult"]: - cls = kwargs.pop('cls', None) # type: ClsType[Optional["_models.WhatIfOperationResult"]] + self, deployment_name: str, parameters: Union[_models.DeploymentWhatIf, IO], **kwargs: Any + ) -> Optional[_models.WhatIfOperationResult]: error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) - api_version = kwargs.pop('api_version', "2020-10-01") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - _json = self._serialize.body(parameters, 'DeploymentWhatIf') + api_version = kwargs.pop("api_version", _params.pop("api-version", "2020-10-01")) # type: str + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[Optional[_models.WhatIfOperationResult]] - request = build_deployments_what_if_at_subscription_scope_request_initial( + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(parameters, (IO, bytes)): + _content = parameters + else: + _json = self._serialize.body(parameters, "DeploymentWhatIf") + + request = build_deployments_what_if_at_subscription_scope_request( deployment_name=deployment_name, subscription_id=self._config.subscription_id, api_version=api_version, content_type=content_type, json=_json, - template_url=self._what_if_at_subscription_scope_initial.metadata['url'], + content=_content, + template_url=self._what_if_at_subscription_scope_initial.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200, 202]: @@ -6455,35 +6641,38 @@ def _what_if_at_subscription_scope_initial( deserialized = None response_headers = {} if response.status_code == 200: - deserialized = self._deserialize('WhatIfOperationResult', pipeline_response) + deserialized = self._deserialize("WhatIfOperationResult", pipeline_response) if response.status_code == 202: - response_headers['Location']=self._deserialize('str', response.headers.get('Location')) - response_headers['Retry-After']=self._deserialize('str', response.headers.get('Retry-After')) - + response_headers["Location"] = self._deserialize("str", response.headers.get("Location")) + response_headers["Retry-After"] = self._deserialize("str", response.headers.get("Retry-After")) if cls: return cls(pipeline_response, deserialized, response_headers) return deserialized - _what_if_at_subscription_scope_initial.metadata = {'url': "/subscriptions/{subscriptionId}/providers/Microsoft.Resources/deployments/{deploymentName}/whatIf"} # type: ignore + _what_if_at_subscription_scope_initial.metadata = {"url": "/subscriptions/{subscriptionId}/providers/Microsoft.Resources/deployments/{deploymentName}/whatIf"} # type: ignore - - @distributed_trace + @overload def begin_what_if_at_subscription_scope( self, deployment_name: str, - parameters: "_models.DeploymentWhatIf", + parameters: _models.DeploymentWhatIf, + *, + content_type: str = "application/json", **kwargs: Any - ) -> LROPoller["_models.WhatIfOperationResult"]: + ) -> LROPoller[_models.WhatIfOperationResult]: """Returns changes that will be made by the deployment if executed at the scope of the subscription. - :param deployment_name: The name of the deployment. + :param deployment_name: The name of the deployment. Required. :type deployment_name: str - :param parameters: Parameters to What If. + :param parameters: Parameters to What If. Required. :type parameters: ~azure.mgmt.resource.resources.v2020_10_01.models.DeploymentWhatIf + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str :keyword callable cls: A custom type or function that will be passed the direct response :keyword str continuation_token: A continuation token to restart a poller from a saved state. :keyword polling: By default, your polling method will be ARMPolling. Pass in False for this @@ -6496,111 +6685,174 @@ def begin_what_if_at_subscription_scope( cls(response) :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.resource.resources.v2020_10_01.models.WhatIfOperationResult] - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - api_version = kwargs.pop('api_version', "2020-10-01") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] - polling = kwargs.pop('polling', True) # type: Union[bool, PollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType["_models.WhatIfOperationResult"] - lro_delay = kwargs.pop( - 'polling_interval', - self._config.polling_interval - ) - cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] + + @overload + def begin_what_if_at_subscription_scope( + self, deployment_name: str, parameters: IO, *, content_type: str = "application/json", **kwargs: Any + ) -> LROPoller[_models.WhatIfOperationResult]: + """Returns changes that will be made by the deployment if executed at the scope of the + subscription. + + :param deployment_name: The name of the deployment. Required. + :type deployment_name: str + :param parameters: Parameters to What If. Required. + :type parameters: IO + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be ARMPolling. Pass in False for this + operation to not poll, or pass in your own initialized polling object for a personal polling + strategy. + :paramtype polling: bool or ~azure.core.polling.PollingMethod + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of LROPoller that returns either WhatIfOperationResult or the result of + cls(response) + :rtype: + ~azure.core.polling.LROPoller[~azure.mgmt.resource.resources.v2020_10_01.models.WhatIfOperationResult] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace + def begin_what_if_at_subscription_scope( + self, deployment_name: str, parameters: Union[_models.DeploymentWhatIf, IO], **kwargs: Any + ) -> LROPoller[_models.WhatIfOperationResult]: + """Returns changes that will be made by the deployment if executed at the scope of the + subscription. + + :param deployment_name: The name of the deployment. Required. + :type deployment_name: str + :param parameters: Parameters to What If. Is either a model type or a IO type. Required. + :type parameters: ~azure.mgmt.resource.resources.v2020_10_01.models.DeploymentWhatIf or IO + :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. + Default value is None. + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be ARMPolling. Pass in False for this + operation to not poll, or pass in your own initialized polling object for a personal polling + strategy. + :paramtype polling: bool or ~azure.core.polling.PollingMethod + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of LROPoller that returns either WhatIfOperationResult or the result of + cls(response) + :rtype: + ~azure.core.polling.LROPoller[~azure.mgmt.resource.resources.v2020_10_01.models.WhatIfOperationResult] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _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", "2020-10-01")) # type: str + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.WhatIfOperationResult] + polling = kwargs.pop("polling", True) # type: Union[bool, PollingMethod] + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token = kwargs.pop("continuation_token", None) # type: Optional[str] if cont_token is None: - raw_result = self._what_if_at_subscription_scope_initial( + raw_result = self._what_if_at_subscription_scope_initial( # type: ignore deployment_name=deployment_name, parameters=parameters, api_version=api_version, content_type=content_type, - cls=lambda x,y,z: x, + cls=lambda x, y, z: x, + headers=_headers, + params=_params, **kwargs ) - kwargs.pop('error_map', None) + kwargs.pop("error_map", None) def get_long_running_output(pipeline_response): - response = pipeline_response.http_response - deserialized = self._deserialize('WhatIfOperationResult', pipeline_response) + deserialized = self._deserialize("WhatIfOperationResult", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - - if polling is True: polling_method = ARMPolling(lro_delay, lro_options={'final-state-via': 'location'}, **kwargs) - elif polling is False: polling_method = NoPolling() - else: polling_method = polling + if polling is True: + polling_method = cast( + PollingMethod, ARMPolling(lro_delay, lro_options={"final-state-via": "location"}, **kwargs) + ) # type: PollingMethod + elif polling is False: + polling_method = cast(PollingMethod, NoPolling()) + else: + polling_method = polling if cont_token: return LROPoller.from_continuation_token( polling_method=polling_method, continuation_token=cont_token, client=self._client, - deserialization_callback=get_long_running_output + deserialization_callback=get_long_running_output, ) return LROPoller(self._client, raw_result, get_long_running_output, polling_method) - begin_what_if_at_subscription_scope.metadata = {'url': "/subscriptions/{subscriptionId}/providers/Microsoft.Resources/deployments/{deploymentName}/whatIf"} # type: ignore + begin_what_if_at_subscription_scope.metadata = {"url": "/subscriptions/{subscriptionId}/providers/Microsoft.Resources/deployments/{deploymentName}/whatIf"} # type: ignore @distributed_trace def export_template_at_subscription_scope( - self, - deployment_name: str, - **kwargs: Any - ) -> "_models.DeploymentExportResult": + self, deployment_name: str, **kwargs: Any + ) -> _models.DeploymentExportResult: """Exports the template used for specified deployment. - :param deployment_name: The name of the deployment. + :param deployment_name: The name of the deployment. Required. :type deployment_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: DeploymentExportResult, or the result of cls(response) + :return: DeploymentExportResult or the result of cls(response) :rtype: ~azure.mgmt.resource.resources.v2020_10_01.models.DeploymentExportResult - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.DeploymentExportResult"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) - api_version = kwargs.pop('api_version', "2020-10-01") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2020-10-01")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[_models.DeploymentExportResult] - request = build_deployments_export_template_at_subscription_scope_request( deployment_name=deployment_name, subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.export_template_at_subscription_scope.metadata['url'], + template_url=self.export_template_at_subscription_scope.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) - deserialized = self._deserialize('DeploymentExportResult', pipeline_response) + deserialized = self._deserialize("DeploymentExportResult", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - export_template_at_subscription_scope.metadata = {'url': "/subscriptions/{subscriptionId}/providers/Microsoft.Resources/deployments/{deploymentName}/exportTemplate"} # type: ignore - + export_template_at_subscription_scope.metadata = {"url": "/subscriptions/{subscriptionId}/providers/Microsoft.Resources/deployments/{deploymentName}/exportTemplate"} # type: ignore @distributed_trace def list_at_subscription_scope( - self, - filter: Optional[str] = None, - top: Optional[int] = None, - **kwargs: Any - ) -> Iterable["_models.DeploymentListResult"]: + self, filter: Optional[str] = None, top: Optional[int] = None, **kwargs: Any + ) -> Iterable["_models.DeploymentExtended"]: """Get all the deployments for a subscription. :param filter: The filter to apply on the operation. For example, you can use @@ -6610,40 +6862,48 @@ def list_at_subscription_scope( value is None. :type top: int :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either DeploymentListResult or the result of - cls(response) + :return: An iterator like instance of either DeploymentExtended or the result of cls(response) :rtype: - ~azure.core.paging.ItemPaged[~azure.mgmt.resource.resources.v2020_10_01.models.DeploymentListResult] - :raises: ~azure.core.exceptions.HttpResponseError + ~azure.core.paging.ItemPaged[~azure.mgmt.resource.resources.v2020_10_01.models.DeploymentExtended] + :raises ~azure.core.exceptions.HttpResponseError: """ - api_version = kwargs.pop('api_version', "2020-10-01") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2020-10-01")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[_models.DeploymentListResult] - cls = kwargs.pop('cls', None) # type: ClsType["_models.DeploymentListResult"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) + def prepare_request(next_link=None): if not next_link: - + request = build_deployments_list_at_subscription_scope_request( subscription_id=self._config.subscription_id, - api_version=api_version, filter=filter, top=top, - template_url=self.list_at_subscription_scope.metadata['url'], + api_version=api_version, + template_url=self.list_at_subscription_scope.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore else: - - request = build_deployments_list_at_subscription_scope_request( - subscription_id=self._config.subscription_id, - template_url=next_link, - ) + # make call to next link with the client's api-version + _parsed_next_link = urlparse(next_link) + _next_request_params = case_insensitive_dict(parse_qs(_parsed_next_link.query)) + _next_request_params["api-version"] = self._config.api_version + request = HttpRequest("GET", urljoin(next_link, _parsed_next_link.path), params=_next_request_params) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore request.method = "GET" return request @@ -6657,10 +6917,8 @@ def extract_data(pipeline_response): def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) response = pipeline_response.http_response @@ -6670,42 +6928,43 @@ def get_next(next_link=None): return pipeline_response + return ItemPaged(get_next, extract_data) - return ItemPaged( - get_next, extract_data - ) - list_at_subscription_scope.metadata = {'url': "/subscriptions/{subscriptionId}/providers/Microsoft.Resources/deployments/"} # type: ignore + list_at_subscription_scope.metadata = {"url": "/subscriptions/{subscriptionId}/providers/Microsoft.Resources/deployments/"} # type: ignore def _delete_initial( # pylint: disable=inconsistent-return-statements - self, - resource_group_name: str, - deployment_name: str, - **kwargs: Any + self, resource_group_name: str, deployment_name: str, **kwargs: Any ) -> None: - cls = kwargs.pop('cls', None) # type: ClsType[None] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) - api_version = kwargs.pop('api_version', "2020-10-01") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - request = build_deployments_delete_request_initial( + api_version = kwargs.pop("api_version", _params.pop("api-version", "2020-10-01")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[None] + + request = build_deployments_delete_request( resource_group_name=resource_group_name, deployment_name=deployment_name, subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self._delete_initial.metadata['url'], + template_url=self._delete_initial.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [202, 204]: @@ -6715,16 +6974,10 @@ 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.Resources/deployments/{deploymentName}"} # type: ignore - + _delete_initial.metadata = {"url": "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/Microsoft.Resources/deployments/{deploymentName}"} # type: ignore @distributed_trace - def begin_delete( # pylint: disable=inconsistent-return-statements - self, - resource_group_name: str, - deployment_name: str, - **kwargs: Any - ) -> LROPoller[None]: + def begin_delete(self, resource_group_name: str, deployment_name: str, **kwargs: Any) -> LROPoller[None]: """Deletes a deployment from the deployment history. A template deployment that is currently running cannot be deleted. Deleting a template @@ -6737,9 +6990,9 @@ def begin_delete( # pylint: disable=inconsistent-return-statements asynchronous request failed, the URI in the Location header returns an error-level status code. :param resource_group_name: The name of the resource group with the deployment to delete. The - name is case insensitive. + name is case insensitive. Required. :type resource_group_name: str - :param deployment_name: The name of the deployment. + :param deployment_name: The name of the deployment. Required. :type deployment_name: str :keyword callable cls: A custom type or function that will be passed the direct response :keyword str continuation_token: A continuation token to restart a poller from a saved state. @@ -6751,88 +7004,93 @@ def begin_delete( # pylint: disable=inconsistent-return-statements Retry-After header is present. :return: An instance of LROPoller that returns either None or the result of cls(response) :rtype: ~azure.core.polling.LROPoller[None] - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - api_version = kwargs.pop('api_version', "2020-10-01") # type: str - polling = kwargs.pop('polling', True) # type: Union[bool, PollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType[None] - lro_delay = kwargs.pop( - 'polling_interval', - self._config.polling_interval - ) - cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2020-10-01")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[None] + polling = kwargs.pop("polling", True) # type: Union[bool, PollingMethod] + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token = kwargs.pop("continuation_token", None) # type: Optional[str] if cont_token is None: - raw_result = self._delete_initial( + raw_result = self._delete_initial( # type: ignore resource_group_name=resource_group_name, deployment_name=deployment_name, api_version=api_version, - cls=lambda x,y,z: x, + cls=lambda x, y, z: x, + headers=_headers, + params=_params, **kwargs ) - kwargs.pop('error_map', None) + kwargs.pop("error_map", None) - def get_long_running_output(pipeline_response): + def get_long_running_output(pipeline_response): # pylint: disable=inconsistent-return-statements if cls: return cls(pipeline_response, None, {}) - - if polling is True: polling_method = ARMPolling(lro_delay, **kwargs) - elif polling is False: polling_method = NoPolling() - else: polling_method = polling + if polling is True: + polling_method = cast(PollingMethod, ARMPolling(lro_delay, **kwargs)) # type: PollingMethod + elif polling is False: + polling_method = cast(PollingMethod, NoPolling()) + else: + polling_method = polling if cont_token: return LROPoller.from_continuation_token( polling_method=polling_method, continuation_token=cont_token, client=self._client, - deserialization_callback=get_long_running_output + deserialization_callback=get_long_running_output, ) return LROPoller(self._client, raw_result, get_long_running_output, polling_method) - begin_delete.metadata = {'url': "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/Microsoft.Resources/deployments/{deploymentName}"} # type: ignore + begin_delete.metadata = {"url": "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/Microsoft.Resources/deployments/{deploymentName}"} # type: ignore @distributed_trace - def check_existence( - self, - resource_group_name: str, - deployment_name: str, - **kwargs: Any - ) -> bool: + def check_existence(self, resource_group_name: str, deployment_name: str, **kwargs: Any) -> bool: """Checks whether the deployment exists. :param resource_group_name: The name of the resource group with the deployment to check. The - name is case insensitive. + name is case insensitive. Required. :type resource_group_name: str - :param deployment_name: The name of the deployment. + :param deployment_name: The name of the deployment. Required. :type deployment_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: bool, or the result of cls(response) + :return: bool or the result of cls(response) :rtype: bool - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType[None] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + 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', "2020-10-01") # type: str + api_version = kwargs.pop("api_version", _params.pop("api-version", "2020-10-01")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[None] - request = build_deployments_check_existence_request( resource_group_name=resource_group_name, deployment_name=deployment_name, subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.check_existence.metadata['url'], + template_url=self.check_existence.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [204, 404]: @@ -6843,44 +7101,53 @@ def check_existence( return cls(pipeline_response, None, {}) return 200 <= response.status_code <= 299 - check_existence.metadata = {'url': "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/Microsoft.Resources/deployments/{deploymentName}"} # type: ignore - + check_existence.metadata = {"url": "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/Microsoft.Resources/deployments/{deploymentName}"} # type: ignore def _create_or_update_initial( - self, - resource_group_name: str, - deployment_name: str, - parameters: "_models.Deployment", - **kwargs: Any - ) -> "_models.DeploymentExtended": - cls = kwargs.pop('cls', None) # type: ClsType["_models.DeploymentExtended"] + self, resource_group_name: str, deployment_name: str, parameters: Union[_models.Deployment, IO], **kwargs: Any + ) -> _models.DeploymentExtended: error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) - api_version = kwargs.pop('api_version', "2020-10-01") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - _json = self._serialize.body(parameters, 'Deployment') + api_version = kwargs.pop("api_version", _params.pop("api-version", "2020-10-01")) # type: str + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.DeploymentExtended] - request = build_deployments_create_or_update_request_initial( + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(parameters, (IO, bytes)): + _content = parameters + else: + _json = self._serialize.body(parameters, "Deployment") + + request = build_deployments_create_or_update_request( resource_group_name=resource_group_name, deployment_name=deployment_name, subscription_id=self._config.subscription_id, api_version=api_version, content_type=content_type, json=_json, - template_url=self._create_or_update_initial.metadata['url'], + content=_content, + template_url=self._create_or_update_initial.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200, 201]: @@ -6888,38 +7155,42 @@ def _create_or_update_initial( raise HttpResponseError(response=response, error_format=ARMErrorFormat) if response.status_code == 200: - deserialized = self._deserialize('DeploymentExtended', pipeline_response) + deserialized = self._deserialize("DeploymentExtended", pipeline_response) if response.status_code == 201: - deserialized = self._deserialize('DeploymentExtended', pipeline_response) + deserialized = self._deserialize("DeploymentExtended", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - _create_or_update_initial.metadata = {'url': "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/Microsoft.Resources/deployments/{deploymentName}"} # type: ignore + _create_or_update_initial.metadata = {"url": "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/Microsoft.Resources/deployments/{deploymentName}"} # type: ignore - - @distributed_trace + @overload def begin_create_or_update( self, resource_group_name: str, deployment_name: str, - parameters: "_models.Deployment", + parameters: _models.Deployment, + *, + content_type: str = "application/json", **kwargs: Any - ) -> LROPoller["_models.DeploymentExtended"]: + ) -> LROPoller[_models.DeploymentExtended]: """Deploys resources to a resource group. You can provide the template and parameters directly in the request or link to JSON files. :param resource_group_name: The name of the resource group to deploy the resources to. The name - is case insensitive. The resource group must already exist. + is case insensitive. The resource group must already exist. Required. :type resource_group_name: str - :param deployment_name: The name of the deployment. + :param deployment_name: The name of the deployment. Required. :type deployment_name: str - :param parameters: Additional parameters supplied to the operation. + :param parameters: Additional parameters supplied to the operation. Required. :type parameters: ~azure.mgmt.resource.resources.v2020_10_01.models.Deployment + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str :keyword callable cls: A custom type or function that will be passed the direct response :keyword str continuation_token: A continuation token to restart a poller from a saved state. :keyword polling: By default, your polling method will be ARMPolling. Pass in False for this @@ -6932,115 +7203,189 @@ def begin_create_or_update( cls(response) :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.resource.resources.v2020_10_01.models.DeploymentExtended] - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - api_version = kwargs.pop('api_version', "2020-10-01") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] - polling = kwargs.pop('polling', True) # type: Union[bool, PollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType["_models.DeploymentExtended"] - lro_delay = kwargs.pop( - 'polling_interval', - self._config.polling_interval - ) - cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] - if cont_token is None: - raw_result = self._create_or_update_initial( - resource_group_name=resource_group_name, - deployment_name=deployment_name, - parameters=parameters, - api_version=api_version, - content_type=content_type, - cls=lambda x,y,z: x, - **kwargs - ) - kwargs.pop('error_map', None) - - def get_long_running_output(pipeline_response): - response = pipeline_response.http_response - deserialized = self._deserialize('DeploymentExtended', pipeline_response) - if cls: - return cls(pipeline_response, deserialized, {}) - return deserialized - - - if polling is True: polling_method = ARMPolling(lro_delay, **kwargs) - elif polling is False: polling_method = NoPolling() - else: polling_method = polling - if cont_token: - return LROPoller.from_continuation_token( - polling_method=polling_method, - continuation_token=cont_token, - client=self._client, - deserialization_callback=get_long_running_output - ) - return LROPoller(self._client, raw_result, get_long_running_output, polling_method) - begin_create_or_update.metadata = {'url': "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/Microsoft.Resources/deployments/{deploymentName}"} # type: ignore - - @distributed_trace - def get( + @overload + def begin_create_or_update( self, resource_group_name: str, deployment_name: str, + parameters: IO, + *, + content_type: str = "application/json", **kwargs: Any - ) -> "_models.DeploymentExtended": - """Gets a deployment. + ) -> LROPoller[_models.DeploymentExtended]: + """Deploys resources to a resource group. - :param resource_group_name: The name of the resource group. The name is case insensitive. + You can provide the template and parameters directly in the request or link to JSON files. + + :param resource_group_name: The name of the resource group to deploy the resources to. The name + is case insensitive. The resource group must already exist. Required. :type resource_group_name: str - :param deployment_name: The name of the deployment. + :param deployment_name: The name of the deployment. Required. :type deployment_name: str + :param parameters: Additional parameters supplied to the operation. Required. + :type parameters: IO + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: DeploymentExtended, or the result of cls(response) - :rtype: ~azure.mgmt.resource.resources.v2020_10_01.models.DeploymentExtended - :raises: ~azure.core.exceptions.HttpResponseError - """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.DeploymentExtended"] - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {})) + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be ARMPolling. Pass in False for this + operation to not poll, or pass in your own initialized polling object for a personal polling + strategy. + :paramtype polling: bool or ~azure.core.polling.PollingMethod + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of LROPoller that returns either DeploymentExtended or the result of + cls(response) + :rtype: + ~azure.core.polling.LROPoller[~azure.mgmt.resource.resources.v2020_10_01.models.DeploymentExtended] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace + def begin_create_or_update( + self, resource_group_name: str, deployment_name: str, parameters: Union[_models.Deployment, IO], **kwargs: Any + ) -> LROPoller[_models.DeploymentExtended]: + """Deploys resources to a resource group. + + You can provide the template and parameters directly in the request or link to JSON files. + + :param resource_group_name: The name of the resource group to deploy the resources to. The name + is case insensitive. The resource group must already exist. Required. + :type resource_group_name: str + :param deployment_name: The name of the deployment. Required. + :type deployment_name: str + :param parameters: Additional parameters supplied to the operation. Is either a model type or a + IO type. Required. + :type parameters: ~azure.mgmt.resource.resources.v2020_10_01.models.Deployment or IO + :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. + Default value is None. + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be ARMPolling. Pass in False for this + operation to not poll, or pass in your own initialized polling object for a personal polling + strategy. + :paramtype polling: bool or ~azure.core.polling.PollingMethod + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of LROPoller that returns either DeploymentExtended or the result of + cls(response) + :rtype: + ~azure.core.polling.LROPoller[~azure.mgmt.resource.resources.v2020_10_01.models.DeploymentExtended] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _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", "2020-10-01")) # type: str + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.DeploymentExtended] + polling = kwargs.pop("polling", True) # type: Union[bool, PollingMethod] + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token = kwargs.pop("continuation_token", None) # type: Optional[str] + if cont_token is None: + raw_result = self._create_or_update_initial( # type: ignore + resource_group_name=resource_group_name, + deployment_name=deployment_name, + parameters=parameters, + api_version=api_version, + content_type=content_type, + cls=lambda x, y, z: x, + headers=_headers, + params=_params, + **kwargs + ) + kwargs.pop("error_map", None) + + def get_long_running_output(pipeline_response): + deserialized = self._deserialize("DeploymentExtended", pipeline_response) + if cls: + return cls(pipeline_response, deserialized, {}) + return deserialized + + if polling is True: + polling_method = cast(PollingMethod, ARMPolling(lro_delay, **kwargs)) # type: PollingMethod + elif polling is False: + polling_method = cast(PollingMethod, NoPolling()) + else: + polling_method = polling + if cont_token: + return LROPoller.from_continuation_token( + polling_method=polling_method, + continuation_token=cont_token, + client=self._client, + deserialization_callback=get_long_running_output, + ) + return LROPoller(self._client, raw_result, get_long_running_output, polling_method) + + begin_create_or_update.metadata = {"url": "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/Microsoft.Resources/deployments/{deploymentName}"} # type: ignore + + @distributed_trace + def get(self, resource_group_name: str, deployment_name: str, **kwargs: Any) -> _models.DeploymentExtended: + """Gets a deployment. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param deployment_name: The name of the deployment. Required. + :type deployment_name: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: DeploymentExtended or the result of cls(response) + :rtype: ~azure.mgmt.resource.resources.v2020_10_01.models.DeploymentExtended + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) - api_version = kwargs.pop('api_version', "2020-10-01") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2020-10-01")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[_models.DeploymentExtended] - request = build_deployments_get_request( resource_group_name=resource_group_name, deployment_name=deployment_name, subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.get.metadata['url'], + template_url=self.get.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) - deserialized = self._deserialize('DeploymentExtended', pipeline_response) + deserialized = self._deserialize("DeploymentExtended", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - get.metadata = {'url': "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/Microsoft.Resources/deployments/{deploymentName}"} # type: ignore - + get.metadata = {"url": "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/Microsoft.Resources/deployments/{deploymentName}"} # type: ignore @distributed_trace def cancel( # pylint: disable=inconsistent-return-statements - self, - resource_group_name: str, - deployment_name: str, - **kwargs: Any + self, resource_group_name: str, deployment_name: str, **kwargs: Any ) -> None: """Cancels a currently running template deployment. @@ -7050,38 +7395,45 @@ def cancel( # pylint: disable=inconsistent-return-statements partially deployed. :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. :type resource_group_name: str - :param deployment_name: The name of the deployment. + :param deployment_name: The name of the deployment. Required. :type deployment_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: None, or the result of cls(response) + :return: None or the result of cls(response) :rtype: None - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType[None] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + 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', "2020-10-01") # type: str + api_version = kwargs.pop("api_version", _params.pop("api-version", "2020-10-01")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[None] - request = build_deployments_cancel_request( resource_group_name=resource_group_name, deployment_name=deployment_name, subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.cancel.metadata['url'], + template_url=self.cancel.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [204]: @@ -7091,44 +7443,53 @@ def cancel( # pylint: disable=inconsistent-return-statements if cls: return cls(pipeline_response, None, {}) - cancel.metadata = {'url': "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/Microsoft.Resources/deployments/{deploymentName}/cancel"} # type: ignore - + cancel.metadata = {"url": "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/Microsoft.Resources/deployments/{deploymentName}/cancel"} # type: ignore def _validate_initial( - self, - resource_group_name: str, - deployment_name: str, - parameters: "_models.Deployment", - **kwargs: Any - ) -> Optional["_models.DeploymentValidateResult"]: - cls = kwargs.pop('cls', None) # type: ClsType[Optional["_models.DeploymentValidateResult"]] + self, resource_group_name: str, deployment_name: str, parameters: Union[_models.Deployment, IO], **kwargs: Any + ) -> Optional[_models.DeploymentValidateResult]: error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) - api_version = kwargs.pop('api_version', "2020-10-01") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - _json = self._serialize.body(parameters, 'Deployment') + api_version = kwargs.pop("api_version", _params.pop("api-version", "2020-10-01")) # type: str + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[Optional[_models.DeploymentValidateResult]] - request = build_deployments_validate_request_initial( + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(parameters, (IO, bytes)): + _content = parameters + else: + _json = self._serialize.body(parameters, "Deployment") + + request = build_deployments_validate_request( resource_group_name=resource_group_name, deployment_name=deployment_name, subscription_id=self._config.subscription_id, api_version=api_version, content_type=content_type, json=_json, - template_url=self._validate_initial.metadata['url'], + content=_content, + template_url=self._validate_initial.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200, 202, 400]: @@ -7137,37 +7498,41 @@ def _validate_initial( deserialized = None if response.status_code == 200: - deserialized = self._deserialize('DeploymentValidateResult', pipeline_response) + deserialized = self._deserialize("DeploymentValidateResult", pipeline_response) if response.status_code == 400: - deserialized = self._deserialize('DeploymentValidateResult', pipeline_response) + deserialized = self._deserialize("DeploymentValidateResult", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - _validate_initial.metadata = {'url': "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/Microsoft.Resources/deployments/{deploymentName}/validate"} # type: ignore + _validate_initial.metadata = {"url": "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/Microsoft.Resources/deployments/{deploymentName}/validate"} # type: ignore - - @distributed_trace + @overload def begin_validate( self, resource_group_name: str, deployment_name: str, - parameters: "_models.Deployment", + parameters: _models.Deployment, + *, + content_type: str = "application/json", **kwargs: Any - ) -> LROPoller["_models.DeploymentValidateResult"]: + ) -> LROPoller[_models.DeploymentValidateResult]: """Validates whether the specified template is syntactically correct and will be accepted by Azure Resource Manager.. :param resource_group_name: The name of the resource group the template will be deployed to. - The name is case insensitive. + The name is case insensitive. Required. :type resource_group_name: str - :param deployment_name: The name of the deployment. + :param deployment_name: The name of the deployment. Required. :type deployment_name: str - :param parameters: Parameters to validate. + :param parameters: Parameters to validate. Required. :type parameters: ~azure.mgmt.resource.resources.v2020_10_01.models.Deployment + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str :keyword callable cls: A custom type or function that will be passed the direct response :keyword str continuation_token: A continuation token to restart a poller from a saved state. :keyword polling: By default, your polling method will be ARMPolling. Pass in False for this @@ -7180,86 +7545,173 @@ def begin_validate( cls(response) :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.resource.resources.v2020_10_01.models.DeploymentValidateResult] - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - api_version = kwargs.pop('api_version', "2020-10-01") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] - polling = kwargs.pop('polling', True) # type: Union[bool, PollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType["_models.DeploymentValidateResult"] - lro_delay = kwargs.pop( - 'polling_interval', - self._config.polling_interval - ) - cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] + + @overload + def begin_validate( + self, + resource_group_name: str, + deployment_name: str, + parameters: IO, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> LROPoller[_models.DeploymentValidateResult]: + """Validates whether the specified template is syntactically correct and will be accepted by Azure + Resource Manager.. + + :param resource_group_name: The name of the resource group the template will be deployed to. + The name is case insensitive. Required. + :type resource_group_name: str + :param deployment_name: The name of the deployment. Required. + :type deployment_name: str + :param parameters: Parameters to validate. Required. + :type parameters: IO + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be ARMPolling. Pass in False for this + operation to not poll, or pass in your own initialized polling object for a personal polling + strategy. + :paramtype polling: bool or ~azure.core.polling.PollingMethod + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of LROPoller that returns either DeploymentValidateResult or the result of + cls(response) + :rtype: + ~azure.core.polling.LROPoller[~azure.mgmt.resource.resources.v2020_10_01.models.DeploymentValidateResult] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace + def begin_validate( + self, resource_group_name: str, deployment_name: str, parameters: Union[_models.Deployment, IO], **kwargs: Any + ) -> LROPoller[_models.DeploymentValidateResult]: + """Validates whether the specified template is syntactically correct and will be accepted by Azure + Resource Manager.. + + :param resource_group_name: The name of the resource group the template will be deployed to. + The name is case insensitive. Required. + :type resource_group_name: str + :param deployment_name: The name of the deployment. Required. + :type deployment_name: str + :param parameters: Parameters to validate. Is either a model type or a IO type. Required. + :type parameters: ~azure.mgmt.resource.resources.v2020_10_01.models.Deployment or IO + :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. + Default value is None. + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be ARMPolling. Pass in False for this + operation to not poll, or pass in your own initialized polling object for a personal polling + strategy. + :paramtype polling: bool or ~azure.core.polling.PollingMethod + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of LROPoller that returns either DeploymentValidateResult or the result of + cls(response) + :rtype: + ~azure.core.polling.LROPoller[~azure.mgmt.resource.resources.v2020_10_01.models.DeploymentValidateResult] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _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", "2020-10-01")) # type: str + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.DeploymentValidateResult] + polling = kwargs.pop("polling", True) # type: Union[bool, PollingMethod] + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token = kwargs.pop("continuation_token", None) # type: Optional[str] if cont_token is None: - raw_result = self._validate_initial( + raw_result = self._validate_initial( # type: ignore resource_group_name=resource_group_name, deployment_name=deployment_name, parameters=parameters, api_version=api_version, content_type=content_type, - cls=lambda x,y,z: x, + cls=lambda x, y, z: x, + headers=_headers, + params=_params, **kwargs ) - kwargs.pop('error_map', None) + kwargs.pop("error_map", None) def get_long_running_output(pipeline_response): - response = pipeline_response.http_response - deserialized = self._deserialize('DeploymentValidateResult', pipeline_response) + deserialized = self._deserialize("DeploymentValidateResult", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - - if polling is True: polling_method = ARMPolling(lro_delay, **kwargs) - elif polling is False: polling_method = NoPolling() - else: polling_method = polling + if polling is True: + polling_method = cast(PollingMethod, ARMPolling(lro_delay, **kwargs)) # type: PollingMethod + elif polling is False: + polling_method = cast(PollingMethod, NoPolling()) + else: + polling_method = polling if cont_token: return LROPoller.from_continuation_token( polling_method=polling_method, continuation_token=cont_token, client=self._client, - deserialization_callback=get_long_running_output + deserialization_callback=get_long_running_output, ) return LROPoller(self._client, raw_result, get_long_running_output, polling_method) - begin_validate.metadata = {'url': "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/Microsoft.Resources/deployments/{deploymentName}/validate"} # type: ignore + begin_validate.metadata = {"url": "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/Microsoft.Resources/deployments/{deploymentName}/validate"} # type: ignore def _what_if_initial( self, resource_group_name: str, deployment_name: str, - parameters: "_models.DeploymentWhatIf", + parameters: Union[_models.DeploymentWhatIf, IO], **kwargs: Any - ) -> Optional["_models.WhatIfOperationResult"]: - cls = kwargs.pop('cls', None) # type: ClsType[Optional["_models.WhatIfOperationResult"]] + ) -> Optional[_models.WhatIfOperationResult]: error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', "2020-10-01") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + api_version = kwargs.pop("api_version", _params.pop("api-version", "2020-10-01")) # type: str + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[Optional[_models.WhatIfOperationResult]] - _json = self._serialize.body(parameters, 'DeploymentWhatIf') + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(parameters, (IO, bytes)): + _content = parameters + else: + _json = self._serialize.body(parameters, "DeploymentWhatIf") - request = build_deployments_what_if_request_initial( + request = build_deployments_what_if_request( resource_group_name=resource_group_name, deployment_name=deployment_name, subscription_id=self._config.subscription_id, api_version=api_version, content_type=content_type, json=_json, - template_url=self._what_if_initial.metadata['url'], + content=_content, + template_url=self._what_if_initial.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200, 202]: @@ -7269,39 +7721,116 @@ def _what_if_initial( deserialized = None response_headers = {} if response.status_code == 200: - deserialized = self._deserialize('WhatIfOperationResult', pipeline_response) + deserialized = self._deserialize("WhatIfOperationResult", pipeline_response) if response.status_code == 202: - response_headers['Location']=self._deserialize('str', response.headers.get('Location')) - response_headers['Retry-After']=self._deserialize('str', response.headers.get('Retry-After')) - + response_headers["Location"] = self._deserialize("str", response.headers.get("Location")) + response_headers["Retry-After"] = self._deserialize("str", response.headers.get("Retry-After")) if cls: return cls(pipeline_response, deserialized, response_headers) return deserialized - _what_if_initial.metadata = {'url': "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/Microsoft.Resources/deployments/{deploymentName}/whatIf"} # type: ignore + _what_if_initial.metadata = {"url": "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/Microsoft.Resources/deployments/{deploymentName}/whatIf"} # type: ignore + + @overload + def begin_what_if( + self, + resource_group_name: str, + deployment_name: str, + parameters: _models.DeploymentWhatIf, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> LROPoller[_models.WhatIfOperationResult]: + """Returns changes that will be made by the deployment if executed at the scope of the resource + group. + + :param resource_group_name: The name of the resource group the template will be deployed to. + The name is case insensitive. Required. + :type resource_group_name: str + :param deployment_name: The name of the deployment. Required. + :type deployment_name: str + :param parameters: Parameters to validate. Required. + :type parameters: ~azure.mgmt.resource.resources.v2020_10_01.models.DeploymentWhatIf + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be ARMPolling. Pass in False for this + operation to not poll, or pass in your own initialized polling object for a personal polling + strategy. + :paramtype polling: bool or ~azure.core.polling.PollingMethod + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of LROPoller that returns either WhatIfOperationResult or the result of + cls(response) + :rtype: + ~azure.core.polling.LROPoller[~azure.mgmt.resource.resources.v2020_10_01.models.WhatIfOperationResult] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + def begin_what_if( + self, + resource_group_name: str, + deployment_name: str, + parameters: IO, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> LROPoller[_models.WhatIfOperationResult]: + """Returns changes that will be made by the deployment if executed at the scope of the resource + group. + :param resource_group_name: The name of the resource group the template will be deployed to. + The name is case insensitive. Required. + :type resource_group_name: str + :param deployment_name: The name of the deployment. Required. + :type deployment_name: str + :param parameters: Parameters to validate. Required. + :type parameters: IO + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be ARMPolling. Pass in False for this + operation to not poll, or pass in your own initialized polling object for a personal polling + strategy. + :paramtype polling: bool or ~azure.core.polling.PollingMethod + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of LROPoller that returns either WhatIfOperationResult or the result of + cls(response) + :rtype: + ~azure.core.polling.LROPoller[~azure.mgmt.resource.resources.v2020_10_01.models.WhatIfOperationResult] + :raises ~azure.core.exceptions.HttpResponseError: + """ @distributed_trace def begin_what_if( self, resource_group_name: str, deployment_name: str, - parameters: "_models.DeploymentWhatIf", + parameters: Union[_models.DeploymentWhatIf, IO], **kwargs: Any - ) -> LROPoller["_models.WhatIfOperationResult"]: + ) -> LROPoller[_models.WhatIfOperationResult]: """Returns changes that will be made by the deployment if executed at the scope of the resource group. :param resource_group_name: The name of the resource group the template will be deployed to. - The name is case insensitive. + The name is case insensitive. Required. :type resource_group_name: str - :param deployment_name: The name of the deployment. + :param deployment_name: The name of the deployment. Required. :type deployment_name: str - :param parameters: Parameters to validate. - :type parameters: ~azure.mgmt.resource.resources.v2020_10_01.models.DeploymentWhatIf + :param parameters: Parameters to validate. Is either a model type or a IO type. Required. + :type parameters: ~azure.mgmt.resource.resources.v2020_10_01.models.DeploymentWhatIf or IO + :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. + Default value is None. + :paramtype content_type: str :keyword callable cls: A custom type or function that will be passed the direct response :keyword str continuation_token: A continuation token to restart a poller from a saved state. :keyword polling: By default, your polling method will be ARMPolling. Pass in False for this @@ -7314,121 +7843,125 @@ def begin_what_if( cls(response) :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.resource.resources.v2020_10_01.models.WhatIfOperationResult] - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - api_version = kwargs.pop('api_version', "2020-10-01") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] - polling = kwargs.pop('polling', True) # type: Union[bool, PollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType["_models.WhatIfOperationResult"] - lro_delay = kwargs.pop( - 'polling_interval', - self._config.polling_interval - ) - cont_token = kwargs.pop('continuation_token', None) # type: Optional[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", "2020-10-01")) # type: str + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.WhatIfOperationResult] + polling = kwargs.pop("polling", True) # type: Union[bool, PollingMethod] + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token = kwargs.pop("continuation_token", None) # type: Optional[str] if cont_token is None: - raw_result = self._what_if_initial( + raw_result = self._what_if_initial( # type: ignore resource_group_name=resource_group_name, deployment_name=deployment_name, parameters=parameters, api_version=api_version, content_type=content_type, - cls=lambda x,y,z: x, + cls=lambda x, y, z: x, + headers=_headers, + params=_params, **kwargs ) - kwargs.pop('error_map', None) + kwargs.pop("error_map", None) def get_long_running_output(pipeline_response): - response = pipeline_response.http_response - deserialized = self._deserialize('WhatIfOperationResult', pipeline_response) + deserialized = self._deserialize("WhatIfOperationResult", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - - if polling is True: polling_method = ARMPolling(lro_delay, lro_options={'final-state-via': 'location'}, **kwargs) - elif polling is False: polling_method = NoPolling() - else: polling_method = polling + if polling is True: + polling_method = cast( + PollingMethod, ARMPolling(lro_delay, lro_options={"final-state-via": "location"}, **kwargs) + ) # type: PollingMethod + elif polling is False: + polling_method = cast(PollingMethod, NoPolling()) + else: + polling_method = polling if cont_token: return LROPoller.from_continuation_token( polling_method=polling_method, continuation_token=cont_token, client=self._client, - deserialization_callback=get_long_running_output + deserialization_callback=get_long_running_output, ) return LROPoller(self._client, raw_result, get_long_running_output, polling_method) - begin_what_if.metadata = {'url': "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/Microsoft.Resources/deployments/{deploymentName}/whatIf"} # type: ignore + begin_what_if.metadata = {"url": "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/Microsoft.Resources/deployments/{deploymentName}/whatIf"} # type: ignore @distributed_trace def export_template( - self, - resource_group_name: str, - deployment_name: str, - **kwargs: Any - ) -> "_models.DeploymentExportResult": + self, resource_group_name: str, deployment_name: str, **kwargs: Any + ) -> _models.DeploymentExportResult: """Exports the template used for specified deployment. :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. :type resource_group_name: str - :param deployment_name: The name of the deployment. + :param deployment_name: The name of the deployment. Required. :type deployment_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: DeploymentExportResult, or the result of cls(response) + :return: DeploymentExportResult or the result of cls(response) :rtype: ~azure.mgmt.resource.resources.v2020_10_01.models.DeploymentExportResult - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.DeploymentExportResult"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) - api_version = kwargs.pop('api_version', "2020-10-01") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2020-10-01")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[_models.DeploymentExportResult] - request = build_deployments_export_template_request( resource_group_name=resource_group_name, deployment_name=deployment_name, subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.export_template.metadata['url'], + template_url=self.export_template.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) - deserialized = self._deserialize('DeploymentExportResult', pipeline_response) + deserialized = self._deserialize("DeploymentExportResult", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - export_template.metadata = {'url': "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/Microsoft.Resources/deployments/{deploymentName}/exportTemplate"} # type: ignore - + export_template.metadata = {"url": "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/Microsoft.Resources/deployments/{deploymentName}/exportTemplate"} # type: ignore @distributed_trace def list_by_resource_group( - self, - resource_group_name: str, - filter: Optional[str] = None, - top: Optional[int] = None, - **kwargs: Any - ) -> Iterable["_models.DeploymentListResult"]: + self, resource_group_name: str, filter: Optional[str] = None, top: Optional[int] = None, **kwargs: Any + ) -> Iterable["_models.DeploymentExtended"]: """Get all the deployments for a resource group. :param resource_group_name: The name of the resource group with the deployments to get. The - name is case insensitive. + name is case insensitive. Required. :type resource_group_name: str :param filter: The filter to apply on the operation. For example, you can use $filter=provisioningState eq '{state}'. Default value is None. @@ -7437,42 +7970,49 @@ def list_by_resource_group( value is None. :type top: int :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either DeploymentListResult or the result of - cls(response) + :return: An iterator like instance of either DeploymentExtended or the result of cls(response) :rtype: - ~azure.core.paging.ItemPaged[~azure.mgmt.resource.resources.v2020_10_01.models.DeploymentListResult] - :raises: ~azure.core.exceptions.HttpResponseError + ~azure.core.paging.ItemPaged[~azure.mgmt.resource.resources.v2020_10_01.models.DeploymentExtended] + :raises ~azure.core.exceptions.HttpResponseError: """ - api_version = kwargs.pop('api_version', "2020-10-01") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2020-10-01")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[_models.DeploymentListResult] - cls = kwargs.pop('cls', None) # type: ClsType["_models.DeploymentListResult"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) + def prepare_request(next_link=None): if not next_link: - + request = build_deployments_list_by_resource_group_request( resource_group_name=resource_group_name, subscription_id=self._config.subscription_id, - api_version=api_version, filter=filter, top=top, - template_url=self.list_by_resource_group.metadata['url'], + 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.url = self._client.format_url(request.url) # type: ignore else: - - request = build_deployments_list_by_resource_group_request( - resource_group_name=resource_group_name, - subscription_id=self._config.subscription_id, - template_url=next_link, - ) + # make call to next link with the client's api-version + _parsed_next_link = urlparse(next_link) + _next_request_params = case_insensitive_dict(parse_qs(_parsed_next_link.query)) + _next_request_params["api-version"] = self._config.api_version + request = HttpRequest("GET", urljoin(next_link, _parsed_next_link.path), params=_next_request_params) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore request.method = "GET" return request @@ -7486,10 +8026,8 @@ def extract_data(pipeline_response): def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) response = pipeline_response.http_response @@ -7499,184 +8037,189 @@ def get_next(next_link=None): return pipeline_response + return ItemPaged(get_next, extract_data) - return ItemPaged( - get_next, extract_data - ) - list_by_resource_group.metadata = {'url': "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/Microsoft.Resources/deployments/"} # type: ignore + list_by_resource_group.metadata = {"url": "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/Microsoft.Resources/deployments/"} # type: ignore @distributed_trace - def calculate_template_hash( - self, - template: Any, - **kwargs: Any - ) -> "_models.TemplateHashResult": + def calculate_template_hash(self, template: JSON, **kwargs: Any) -> _models.TemplateHashResult: """Calculate the hash of the given template. - :param template: The template provided to calculate hash. - :type template: any + :param template: The template provided to calculate hash. Required. + :type template: JSON :keyword callable cls: A custom type or function that will be passed the direct response - :return: TemplateHashResult, or the result of cls(response) + :return: TemplateHashResult or the result of cls(response) :rtype: ~azure.mgmt.resource.resources.v2020_10_01.models.TemplateHashResult - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.TemplateHashResult"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) - api_version = kwargs.pop('api_version', "2020-10-01") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - _json = self._serialize.body(template, 'object') + api_version = kwargs.pop("api_version", _params.pop("api-version", "2020-10-01")) # type: str + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", "application/json")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[_models.TemplateHashResult] + + _json = self._serialize.body(template, "object") request = build_deployments_calculate_template_hash_request( api_version=api_version, content_type=content_type, json=_json, - template_url=self.calculate_template_hash.metadata['url'], + template_url=self.calculate_template_hash.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) - deserialized = self._deserialize('TemplateHashResult', pipeline_response) + deserialized = self._deserialize("TemplateHashResult", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - calculate_template_hash.metadata = {'url': "/providers/Microsoft.Resources/calculateTemplateHash"} # type: ignore + calculate_template_hash.metadata = {"url": "/providers/Microsoft.Resources/calculateTemplateHash"} # type: ignore -class ProvidersOperations(object): - """ProvidersOperations operations. - You should not instantiate this class directly. Instead, you should create a Client instance that - instantiates it for you and attaches it as an attribute. +class ProvidersOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. - :ivar models: Alias to model classes used in this operation group. - :type models: ~azure.mgmt.resource.resources.v2020_10_01.models - :param client: Client for service requests. - :param config: Configuration of service client. - :param serializer: An object model serializer. - :param deserializer: An object model deserializer. + Instead, you should access the following operations through + :class:`~azure.mgmt.resource.resources.v2020_10_01.ResourceManagementClient`'s + :attr:`providers` attribute. """ models = _models - def __init__(self, client, config, serializer, deserializer): - self._client = client - self._serialize = serializer - self._deserialize = deserializer - self._config = config + def __init__(self, *args, **kwargs): + input_args = list(args) + self._client = input_args.pop(0) if input_args else kwargs.pop("client") + self._config = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") @distributed_trace - def unregister( - self, - resource_provider_namespace: str, - **kwargs: Any - ) -> "_models.Provider": + def unregister(self, resource_provider_namespace: str, **kwargs: Any) -> _models.Provider: """Unregisters a subscription from a resource provider. :param resource_provider_namespace: The namespace of the resource provider to unregister. + Required. :type resource_provider_namespace: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: Provider, or the result of cls(response) + :return: Provider or the result of cls(response) :rtype: ~azure.mgmt.resource.resources.v2020_10_01.models.Provider - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.Provider"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) - api_version = kwargs.pop('api_version', "2020-10-01") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2020-10-01")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[_models.Provider] - request = build_providers_unregister_request( resource_provider_namespace=resource_provider_namespace, subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.unregister.metadata['url'], + template_url=self.unregister.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) - deserialized = self._deserialize('Provider', pipeline_response) + deserialized = self._deserialize("Provider", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - unregister.metadata = {'url': "/subscriptions/{subscriptionId}/providers/{resourceProviderNamespace}/unregister"} # type: ignore - + unregister.metadata = {"url": "/subscriptions/{subscriptionId}/providers/{resourceProviderNamespace}/unregister"} # type: ignore @distributed_trace def register_at_management_group_scope( # pylint: disable=inconsistent-return-statements - self, - resource_provider_namespace: str, - group_id: str, - **kwargs: Any + self, resource_provider_namespace: str, group_id: str, **kwargs: Any ) -> None: """Registers a management group with a resource provider. :param resource_provider_namespace: The namespace of the resource provider to register. + Required. :type resource_provider_namespace: str - :param group_id: The management group ID. + :param group_id: The management group ID. Required. :type group_id: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: None, or the result of cls(response) + :return: None or the result of cls(response) :rtype: None - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType[None] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + 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', "2020-10-01") # type: str + api_version = kwargs.pop("api_version", _params.pop("api-version", "2020-10-01")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[None] - request = build_providers_register_at_management_group_scope_request( resource_provider_namespace=resource_provider_namespace, group_id=group_id, api_version=api_version, - template_url=self.register_at_management_group_scope.metadata['url'], + template_url=self.register_at_management_group_scope.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200]: @@ -7686,70 +8229,68 @@ def register_at_management_group_scope( # pylint: disable=inconsistent-return-s if cls: return cls(pipeline_response, None, {}) - register_at_management_group_scope.metadata = {'url': "/providers/Microsoft.Management/managementGroups/{groupId}/providers/{resourceProviderNamespace}/register"} # type: ignore - + register_at_management_group_scope.metadata = {"url": "/providers/Microsoft.Management/managementGroups/{groupId}/providers/{resourceProviderNamespace}/register"} # type: ignore @distributed_trace - def register( - self, - resource_provider_namespace: str, - **kwargs: Any - ) -> "_models.Provider": + def register(self, resource_provider_namespace: str, **kwargs: Any) -> _models.Provider: """Registers a subscription with a resource provider. :param resource_provider_namespace: The namespace of the resource provider to register. + Required. :type resource_provider_namespace: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: Provider, or the result of cls(response) + :return: Provider or the result of cls(response) :rtype: ~azure.mgmt.resource.resources.v2020_10_01.models.Provider - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.Provider"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + 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', "2020-10-01") # type: str + api_version = kwargs.pop("api_version", _params.pop("api-version", "2020-10-01")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[_models.Provider] - request = build_providers_register_request( resource_provider_namespace=resource_provider_namespace, subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.register.metadata['url'], + template_url=self.register.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) - deserialized = self._deserialize('Provider', pipeline_response) + deserialized = self._deserialize("Provider", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - register.metadata = {'url': "/subscriptions/{subscriptionId}/providers/{resourceProviderNamespace}/register"} # type: ignore - + register.metadata = {"url": "/subscriptions/{subscriptionId}/providers/{resourceProviderNamespace}/register"} # type: ignore @distributed_trace def list( - self, - top: Optional[int] = None, - expand: Optional[str] = None, - **kwargs: Any - ) -> Iterable["_models.ProviderListResult"]: + self, top: Optional[int] = None, expand: Optional[str] = None, **kwargs: Any + ) -> Iterable["_models.Provider"]: """Gets all resource providers for a subscription. :param top: The number of results to return. If null is passed returns all deployments. Default @@ -7760,39 +8301,48 @@ def list( response, use $expand=resourceTypes/aliases. Default value is None. :type expand: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either ProviderListResult or the result of cls(response) + :return: An iterator like instance of either Provider or the result of cls(response) :rtype: - ~azure.core.paging.ItemPaged[~azure.mgmt.resource.resources.v2020_10_01.models.ProviderListResult] - :raises: ~azure.core.exceptions.HttpResponseError + ~azure.core.paging.ItemPaged[~azure.mgmt.resource.resources.v2020_10_01.models.Provider] + :raises ~azure.core.exceptions.HttpResponseError: """ - api_version = kwargs.pop('api_version', "2020-10-01") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2020-10-01")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[_models.ProviderListResult] - cls = kwargs.pop('cls', None) # type: ClsType["_models.ProviderListResult"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) + def prepare_request(next_link=None): if not next_link: - + request = build_providers_list_request( subscription_id=self._config.subscription_id, - api_version=api_version, top=top, expand=expand, - template_url=self.list.metadata['url'], + 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.url = self._client.format_url(request.url) # type: ignore else: - - request = build_providers_list_request( - subscription_id=self._config.subscription_id, - template_url=next_link, - ) + # make call to next link with the client's api-version + _parsed_next_link = urlparse(next_link) + _next_request_params = case_insensitive_dict(parse_qs(_parsed_next_link.query)) + _next_request_params["api-version"] = self._config.api_version + request = HttpRequest("GET", urljoin(next_link, _parsed_next_link.path), params=_next_request_params) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore request.method = "GET" return request @@ -7806,10 +8356,8 @@ def extract_data(pipeline_response): def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) response = pipeline_response.http_response @@ -7819,19 +8367,14 @@ def get_next(next_link=None): return pipeline_response + return ItemPaged(get_next, extract_data) - return ItemPaged( - get_next, extract_data - ) - list.metadata = {'url': "/subscriptions/{subscriptionId}/providers"} # type: ignore + list.metadata = {"url": "/subscriptions/{subscriptionId}/providers"} # type: ignore @distributed_trace def list_at_tenant_scope( - self, - top: Optional[int] = None, - expand: Optional[str] = None, - **kwargs: Any - ) -> Iterable["_models.ProviderListResult"]: + self, top: Optional[int] = None, expand: Optional[str] = None, **kwargs: Any + ) -> Iterable["_models.Provider"]: """Gets all resource providers for the tenant. :param top: The number of results to return. If null is passed returns all providers. Default @@ -7842,37 +8385,47 @@ def list_at_tenant_scope( response, use $expand=resourceTypes/aliases. Default value is None. :type expand: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either ProviderListResult or the result of cls(response) + :return: An iterator like instance of either Provider or the result of cls(response) :rtype: - ~azure.core.paging.ItemPaged[~azure.mgmt.resource.resources.v2020_10_01.models.ProviderListResult] - :raises: ~azure.core.exceptions.HttpResponseError + ~azure.core.paging.ItemPaged[~azure.mgmt.resource.resources.v2020_10_01.models.Provider] + :raises ~azure.core.exceptions.HttpResponseError: """ - api_version = kwargs.pop('api_version', "2020-10-01") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2020-10-01")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[_models.ProviderListResult] - cls = kwargs.pop('cls', None) # type: ClsType["_models.ProviderListResult"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) + def prepare_request(next_link=None): if not next_link: - + request = build_providers_list_at_tenant_scope_request( - api_version=api_version, top=top, expand=expand, - template_url=self.list_at_tenant_scope.metadata['url'], + api_version=api_version, + template_url=self.list_at_tenant_scope.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore else: - - request = build_providers_list_at_tenant_scope_request( - template_url=next_link, - ) + # make call to next link with the client's api-version + _parsed_next_link = urlparse(next_link) + _next_request_params = case_insensitive_dict(parse_qs(_parsed_next_link.query)) + _next_request_params["api-version"] = self._config.api_version + request = HttpRequest("GET", urljoin(next_link, _parsed_next_link.path), params=_next_request_params) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore request.method = "GET" return request @@ -7886,10 +8439,8 @@ def extract_data(pipeline_response): def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) response = pipeline_response.http_response @@ -7899,229 +8450,229 @@ def get_next(next_link=None): return pipeline_response + return ItemPaged(get_next, extract_data) - return ItemPaged( - get_next, extract_data - ) - list_at_tenant_scope.metadata = {'url': "/providers"} # type: ignore + list_at_tenant_scope.metadata = {"url": "/providers"} # type: ignore @distributed_trace - def get( - self, - resource_provider_namespace: str, - expand: Optional[str] = None, - **kwargs: Any - ) -> "_models.Provider": + def get(self, resource_provider_namespace: str, expand: Optional[str] = None, **kwargs: Any) -> _models.Provider: """Gets the specified resource provider. - :param resource_provider_namespace: The namespace of the resource provider. + :param resource_provider_namespace: The namespace of the resource provider. Required. :type resource_provider_namespace: str :param expand: The $expand query parameter. For example, to include property aliases in response, use $expand=resourceTypes/aliases. Default value is None. :type expand: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: Provider, or the result of cls(response) + :return: Provider or the result of cls(response) :rtype: ~azure.mgmt.resource.resources.v2020_10_01.models.Provider - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.Provider"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) - api_version = kwargs.pop('api_version', "2020-10-01") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2020-10-01")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[_models.Provider] - request = build_providers_get_request( resource_provider_namespace=resource_provider_namespace, subscription_id=self._config.subscription_id, - api_version=api_version, expand=expand, - template_url=self.get.metadata['url'], + api_version=api_version, + template_url=self.get.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) - deserialized = self._deserialize('Provider', pipeline_response) + deserialized = self._deserialize("Provider", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - get.metadata = {'url': "/subscriptions/{subscriptionId}/providers/{resourceProviderNamespace}"} # type: ignore - + get.metadata = {"url": "/subscriptions/{subscriptionId}/providers/{resourceProviderNamespace}"} # type: ignore @distributed_trace def get_at_tenant_scope( - self, - resource_provider_namespace: str, - expand: Optional[str] = None, - **kwargs: Any - ) -> "_models.Provider": + self, resource_provider_namespace: str, expand: Optional[str] = None, **kwargs: Any + ) -> _models.Provider: """Gets the specified resource provider at the tenant level. - :param resource_provider_namespace: The namespace of the resource provider. + :param resource_provider_namespace: The namespace of the resource provider. Required. :type resource_provider_namespace: str :param expand: The $expand query parameter. For example, to include property aliases in response, use $expand=resourceTypes/aliases. Default value is None. :type expand: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: Provider, or the result of cls(response) + :return: Provider or the result of cls(response) :rtype: ~azure.mgmt.resource.resources.v2020_10_01.models.Provider - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.Provider"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + 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', "2020-10-01") # type: str + api_version = kwargs.pop("api_version", _params.pop("api-version", "2020-10-01")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[_models.Provider] - request = build_providers_get_at_tenant_scope_request( resource_provider_namespace=resource_provider_namespace, - api_version=api_version, expand=expand, - template_url=self.get_at_tenant_scope.metadata['url'], + api_version=api_version, + template_url=self.get_at_tenant_scope.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) - deserialized = self._deserialize('Provider', pipeline_response) + deserialized = self._deserialize("Provider", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - get_at_tenant_scope.metadata = {'url': "/providers/{resourceProviderNamespace}"} # type: ignore + get_at_tenant_scope.metadata = {"url": "/providers/{resourceProviderNamespace}"} # type: ignore -class ProviderResourceTypesOperations(object): - """ProviderResourceTypesOperations operations. - You should not instantiate this class directly. Instead, you should create a Client instance that - instantiates it for you and attaches it as an attribute. +class ProviderResourceTypesOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. - :ivar models: Alias to model classes used in this operation group. - :type models: ~azure.mgmt.resource.resources.v2020_10_01.models - :param client: Client for service requests. - :param config: Configuration of service client. - :param serializer: An object model serializer. - :param deserializer: An object model deserializer. + Instead, you should access the following operations through + :class:`~azure.mgmt.resource.resources.v2020_10_01.ResourceManagementClient`'s + :attr:`provider_resource_types` attribute. """ models = _models - def __init__(self, client, config, serializer, deserializer): - self._client = client - self._serialize = serializer - self._deserialize = deserializer - self._config = config + def __init__(self, *args, **kwargs): + input_args = list(args) + self._client = input_args.pop(0) if input_args else kwargs.pop("client") + self._config = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") @distributed_trace def list( - self, - resource_provider_namespace: str, - expand: Optional[str] = None, - **kwargs: Any - ) -> "_models.ProviderResourceTypeListResult": + self, resource_provider_namespace: str, expand: Optional[str] = None, **kwargs: Any + ) -> _models.ProviderResourceTypeListResult: """List the resource types for a specified resource provider. - :param resource_provider_namespace: The namespace of the resource provider. + :param resource_provider_namespace: The namespace of the resource provider. Required. :type resource_provider_namespace: str :param expand: The $expand query parameter. For example, to include property aliases in response, use $expand=resourceTypes/aliases. Default value is None. :type expand: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: ProviderResourceTypeListResult, or the result of cls(response) + :return: ProviderResourceTypeListResult or the result of cls(response) :rtype: ~azure.mgmt.resource.resources.v2020_10_01.models.ProviderResourceTypeListResult - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.ProviderResourceTypeListResult"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) - api_version = kwargs.pop('api_version', "2020-10-01") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2020-10-01")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[_models.ProviderResourceTypeListResult] - request = build_provider_resource_types_list_request( resource_provider_namespace=resource_provider_namespace, subscription_id=self._config.subscription_id, - api_version=api_version, expand=expand, - template_url=self.list.metadata['url'], + 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.url = self._client.format_url(request.url) # type: ignore - pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) - deserialized = self._deserialize('ProviderResourceTypeListResult', pipeline_response) + deserialized = self._deserialize("ProviderResourceTypeListResult", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - list.metadata = {'url': "/subscriptions/{subscriptionId}/providers/{resourceProviderNamespace}/resourceTypes"} # type: ignore + list.metadata = {"url": "/subscriptions/{subscriptionId}/providers/{resourceProviderNamespace}/resourceTypes"} # type: ignore -class ResourcesOperations(object): # pylint: disable=too-many-public-methods - """ResourcesOperations operations. - You should not instantiate this class directly. Instead, you should create a Client instance that - instantiates it for you and attaches it as an attribute. +class ResourcesOperations: # pylint: disable=too-many-public-methods + """ + .. warning:: + **DO NOT** instantiate this class directly. - :ivar models: Alias to model classes used in this operation group. - :type models: ~azure.mgmt.resource.resources.v2020_10_01.models - :param client: Client for service requests. - :param config: Configuration of service client. - :param serializer: An object model serializer. - :param deserializer: An object model deserializer. + Instead, you should access the following operations through + :class:`~azure.mgmt.resource.resources.v2020_10_01.ResourceManagementClient`'s + :attr:`resources` attribute. """ models = _models - def __init__(self, client, config, serializer, deserializer): - self._client = client - self._serialize = serializer - self._deserialize = deserializer - self._config = config + def __init__(self, *args, **kwargs): + input_args = list(args) + self._client = input_args.pop(0) if input_args else kwargs.pop("client") + self._config = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") @distributed_trace def list_by_resource_group( @@ -8131,10 +8682,10 @@ def list_by_resource_group( expand: Optional[str] = None, top: Optional[int] = None, **kwargs: Any - ) -> Iterable["_models.ResourceListResult"]: + ) -> Iterable["_models.GenericResourceExpanded"]: """Get all the resources for a resource group. - :param resource_group_name: The resource group with the resources to get. + :param resource_group_name: The resource group with the resources to get. Required. :type resource_group_name: str :param filter: The filter to apply on the operation.:code:`
`:code:`
`The properties you can use for eq (equals) or ne (not equals) are: location, resourceType, name, resourceGroup, @@ -8160,42 +8711,51 @@ def list_by_resource_group( value is None. :type top: int :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either ResourceListResult or the result of cls(response) + :return: An iterator like instance of either GenericResourceExpanded or the result of + cls(response) :rtype: - ~azure.core.paging.ItemPaged[~azure.mgmt.resource.resources.v2020_10_01.models.ResourceListResult] - :raises: ~azure.core.exceptions.HttpResponseError + ~azure.core.paging.ItemPaged[~azure.mgmt.resource.resources.v2020_10_01.models.GenericResourceExpanded] + :raises ~azure.core.exceptions.HttpResponseError: """ - api_version = kwargs.pop('api_version', "2020-10-01") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2020-10-01")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[_models.ResourceListResult] - cls = kwargs.pop('cls', None) # type: ClsType["_models.ResourceListResult"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) + def prepare_request(next_link=None): if not next_link: - + request = build_resources_list_by_resource_group_request( resource_group_name=resource_group_name, subscription_id=self._config.subscription_id, - api_version=api_version, filter=filter, expand=expand, top=top, - template_url=self.list_by_resource_group.metadata['url'], + 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.url = self._client.format_url(request.url) # type: ignore else: - - request = build_resources_list_by_resource_group_request( - resource_group_name=resource_group_name, - subscription_id=self._config.subscription_id, - template_url=next_link, - ) + # make call to next link with the client's api-version + _parsed_next_link = urlparse(next_link) + _next_request_params = case_insensitive_dict(parse_qs(_parsed_next_link.query)) + _next_request_params["api-version"] = self._config.api_version + request = HttpRequest("GET", urljoin(next_link, _parsed_next_link.path), params=_next_request_params) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore request.method = "GET" return request @@ -8209,10 +8769,8 @@ def extract_data(pipeline_response): def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) response = pipeline_response.http_response @@ -8222,45 +8780,54 @@ def get_next(next_link=None): return pipeline_response + return ItemPaged(get_next, extract_data) - return ItemPaged( - get_next, extract_data - ) - list_by_resource_group.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/resources"} # type: ignore + list_by_resource_group.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/resources"} # type: ignore def _move_resources_initial( # pylint: disable=inconsistent-return-statements - self, - source_resource_group_name: str, - parameters: "_models.ResourcesMoveInfo", - **kwargs: Any + self, source_resource_group_name: str, parameters: Union[_models.ResourcesMoveInfo, IO], **kwargs: Any ) -> None: - cls = kwargs.pop('cls', None) # type: ClsType[None] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) - api_version = kwargs.pop('api_version', "2020-10-01") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - _json = self._serialize.body(parameters, 'ResourcesMoveInfo') + api_version = kwargs.pop("api_version", _params.pop("api-version", "2020-10-01")) # type: str + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[None] - request = build_resources_move_resources_request_initial( + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(parameters, (IO, bytes)): + _content = parameters + else: + _json = self._serialize.body(parameters, "ResourcesMoveInfo") + + request = build_resources_move_resources_request( source_resource_group_name=source_resource_group_name, subscription_id=self._config.subscription_id, api_version=api_version, content_type=content_type, json=_json, - template_url=self._move_resources_initial.metadata['url'], + content=_content, + template_url=self._move_resources_initial.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [202, 204]: @@ -8270,14 +8837,15 @@ def _move_resources_initial( # pylint: disable=inconsistent-return-statements if cls: return cls(pipeline_response, None, {}) - _move_resources_initial.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{sourceResourceGroupName}/moveResources"} # type: ignore + _move_resources_initial.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{sourceResourceGroupName}/moveResources"} # type: ignore - - @distributed_trace - def begin_move_resources( # pylint: disable=inconsistent-return-statements + @overload + def begin_move_resources( self, source_resource_group_name: str, - parameters: "_models.ResourcesMoveInfo", + parameters: _models.ResourcesMoveInfo, + *, + content_type: str = "application/json", **kwargs: Any ) -> LROPoller[None]: """Moves resources from one resource group to another resource group. @@ -8288,10 +8856,13 @@ def begin_move_resources( # pylint: disable=inconsistent-return-statements the groups until the move completes. :param source_resource_group_name: The name of the resource group containing the resources to - move. + move. Required. :type source_resource_group_name: str - :param parameters: Parameters for moving resources. + :param parameters: Parameters for moving resources. Required. :type parameters: ~azure.mgmt.resource.resources.v2020_10_01.models.ResourcesMoveInfo + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str :keyword callable cls: A custom type or function that will be passed the direct response :keyword str continuation_token: A continuation token to restart a poller from a saved state. :keyword polling: By default, your polling method will be ARMPolling. Pass in False for this @@ -8302,80 +8873,160 @@ def begin_move_resources( # pylint: disable=inconsistent-return-statements Retry-After header is present. :return: An instance of LROPoller that returns either None or the result of cls(response) :rtype: ~azure.core.polling.LROPoller[None] - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - api_version = kwargs.pop('api_version', "2020-10-01") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] - polling = kwargs.pop('polling', True) # type: Union[bool, PollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType[None] - lro_delay = kwargs.pop( - 'polling_interval', - self._config.polling_interval - ) - cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] + + @overload + def begin_move_resources( + self, source_resource_group_name: str, parameters: IO, *, content_type: str = "application/json", **kwargs: Any + ) -> LROPoller[None]: + """Moves resources from one resource group to another resource group. + + The resources to move must be in the same source resource group. The target resource group may + be in a different subscription. When moving resources, both the source group and the target + group are locked for the duration of the operation. Write and delete operations are blocked on + the groups until the move completes. + + :param source_resource_group_name: The name of the resource group containing the resources to + move. Required. + :type source_resource_group_name: str + :param parameters: Parameters for moving resources. Required. + :type parameters: IO + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be ARMPolling. Pass in False for this + operation to not poll, or pass in your own initialized polling object for a personal polling + strategy. + :paramtype polling: bool or ~azure.core.polling.PollingMethod + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of LROPoller that returns either None or the result of cls(response) + :rtype: ~azure.core.polling.LROPoller[None] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace + def begin_move_resources( + self, source_resource_group_name: str, parameters: Union[_models.ResourcesMoveInfo, IO], **kwargs: Any + ) -> LROPoller[None]: + """Moves resources from one resource group to another resource group. + + The resources to move must be in the same source resource group. The target resource group may + be in a different subscription. When moving resources, both the source group and the target + group are locked for the duration of the operation. Write and delete operations are blocked on + the groups until the move completes. + + :param source_resource_group_name: The name of the resource group containing the resources to + move. Required. + :type source_resource_group_name: str + :param parameters: Parameters for moving resources. Is either a model type or a IO type. + Required. + :type parameters: ~azure.mgmt.resource.resources.v2020_10_01.models.ResourcesMoveInfo or IO + :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. + Default value is None. + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be ARMPolling. Pass in False for this + operation to not poll, or pass in your own initialized polling object for a personal polling + strategy. + :paramtype polling: bool or ~azure.core.polling.PollingMethod + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of LROPoller that returns either None or the result of cls(response) + :rtype: ~azure.core.polling.LROPoller[None] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _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", "2020-10-01")) # type: str + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[None] + polling = kwargs.pop("polling", True) # type: Union[bool, PollingMethod] + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token = kwargs.pop("continuation_token", None) # type: Optional[str] if cont_token is None: - raw_result = self._move_resources_initial( + raw_result = self._move_resources_initial( # type: ignore source_resource_group_name=source_resource_group_name, parameters=parameters, api_version=api_version, content_type=content_type, - cls=lambda x,y,z: x, + cls=lambda x, y, z: x, + headers=_headers, + params=_params, **kwargs ) - kwargs.pop('error_map', None) + kwargs.pop("error_map", None) - def get_long_running_output(pipeline_response): + def get_long_running_output(pipeline_response): # pylint: disable=inconsistent-return-statements if cls: return cls(pipeline_response, None, {}) - - if polling is True: polling_method = ARMPolling(lro_delay, **kwargs) - elif polling is False: polling_method = NoPolling() - else: polling_method = polling + if polling is True: + polling_method = cast(PollingMethod, ARMPolling(lro_delay, **kwargs)) # type: PollingMethod + elif polling is False: + polling_method = cast(PollingMethod, NoPolling()) + else: + polling_method = polling if cont_token: return LROPoller.from_continuation_token( polling_method=polling_method, continuation_token=cont_token, client=self._client, - deserialization_callback=get_long_running_output + deserialization_callback=get_long_running_output, ) return LROPoller(self._client, raw_result, get_long_running_output, polling_method) - begin_move_resources.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{sourceResourceGroupName}/moveResources"} # type: ignore + begin_move_resources.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{sourceResourceGroupName}/moveResources"} # type: ignore def _validate_move_resources_initial( # pylint: disable=inconsistent-return-statements - self, - source_resource_group_name: str, - parameters: "_models.ResourcesMoveInfo", - **kwargs: Any + self, source_resource_group_name: str, parameters: Union[_models.ResourcesMoveInfo, IO], **kwargs: Any ) -> None: - cls = kwargs.pop('cls', None) # type: ClsType[None] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) - api_version = kwargs.pop('api_version', "2020-10-01") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - _json = self._serialize.body(parameters, 'ResourcesMoveInfo') + api_version = kwargs.pop("api_version", _params.pop("api-version", "2020-10-01")) # type: str + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[None] - request = build_resources_validate_move_resources_request_initial( + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(parameters, (IO, bytes)): + _content = parameters + else: + _json = self._serialize.body(parameters, "ResourcesMoveInfo") + + request = build_resources_validate_move_resources_request( source_resource_group_name=source_resource_group_name, subscription_id=self._config.subscription_id, api_version=api_version, content_type=content_type, json=_json, - template_url=self._validate_move_resources_initial.metadata['url'], + content=_content, + template_url=self._validate_move_resources_initial.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [202, 204]: @@ -8385,14 +9036,15 @@ def _validate_move_resources_initial( # pylint: disable=inconsistent-return-sta if cls: return cls(pipeline_response, None, {}) - _validate_move_resources_initial.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{sourceResourceGroupName}/validateMoveResources"} # type: ignore + _validate_move_resources_initial.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{sourceResourceGroupName}/validateMoveResources"} # type: ignore - - @distributed_trace - def begin_validate_move_resources( # pylint: disable=inconsistent-return-statements + @overload + def begin_validate_move_resources( self, source_resource_group_name: str, - parameters: "_models.ResourcesMoveInfo", + parameters: _models.ResourcesMoveInfo, + *, + content_type: str = "application/json", **kwargs: Any ) -> LROPoller[None]: """Validates whether resources can be moved from one resource group to another resource group. @@ -8405,10 +9057,13 @@ def begin_validate_move_resources( # pylint: disable=inconsistent-return-statem operation. :param source_resource_group_name: The name of the resource group containing the resources to - validate for move. + validate for move. Required. :type source_resource_group_name: str - :param parameters: Parameters for moving resources. + :param parameters: Parameters for moving resources. Required. :type parameters: ~azure.mgmt.resource.resources.v2020_10_01.models.ResourcesMoveInfo + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str :keyword callable cls: A custom type or function that will be passed the direct response :keyword str continuation_token: A continuation token to restart a poller from a saved state. :keyword polling: By default, your polling method will be ARMPolling. Pass in False for this @@ -8419,55 +9074,124 @@ def begin_validate_move_resources( # pylint: disable=inconsistent-return-statem Retry-After header is present. :return: An instance of LROPoller that returns either None or the result of cls(response) :rtype: ~azure.core.polling.LROPoller[None] - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - api_version = kwargs.pop('api_version', "2020-10-01") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] - polling = kwargs.pop('polling', True) # type: Union[bool, PollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType[None] - lro_delay = kwargs.pop( - 'polling_interval', - self._config.polling_interval - ) - cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] + + @overload + def begin_validate_move_resources( + self, source_resource_group_name: str, parameters: IO, *, content_type: str = "application/json", **kwargs: Any + ) -> LROPoller[None]: + """Validates whether resources can be moved from one resource group to another resource group. + + This operation checks whether the specified resources can be moved to the target. The resources + to move must be in the same source resource group. The target resource group may be in a + different subscription. If validation succeeds, it returns HTTP response code 204 (no content). + If validation fails, it returns HTTP response code 409 (Conflict) with an error message. + Retrieve the URL in the Location header value to check the result of the long-running + operation. + + :param source_resource_group_name: The name of the resource group containing the resources to + validate for move. Required. + :type source_resource_group_name: str + :param parameters: Parameters for moving resources. Required. + :type parameters: IO + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be ARMPolling. Pass in False for this + operation to not poll, or pass in your own initialized polling object for a personal polling + strategy. + :paramtype polling: bool or ~azure.core.polling.PollingMethod + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of LROPoller that returns either None or the result of cls(response) + :rtype: ~azure.core.polling.LROPoller[None] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace + def begin_validate_move_resources( + self, source_resource_group_name: str, parameters: Union[_models.ResourcesMoveInfo, IO], **kwargs: Any + ) -> LROPoller[None]: + """Validates whether resources can be moved from one resource group to another resource group. + + This operation checks whether the specified resources can be moved to the target. The resources + to move must be in the same source resource group. The target resource group may be in a + different subscription. If validation succeeds, it returns HTTP response code 204 (no content). + If validation fails, it returns HTTP response code 409 (Conflict) with an error message. + Retrieve the URL in the Location header value to check the result of the long-running + operation. + + :param source_resource_group_name: The name of the resource group containing the resources to + validate for move. Required. + :type source_resource_group_name: str + :param parameters: Parameters for moving resources. Is either a model type or a IO type. + Required. + :type parameters: ~azure.mgmt.resource.resources.v2020_10_01.models.ResourcesMoveInfo or IO + :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. + Default value is None. + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be ARMPolling. Pass in False for this + operation to not poll, or pass in your own initialized polling object for a personal polling + strategy. + :paramtype polling: bool or ~azure.core.polling.PollingMethod + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of LROPoller that returns either None or the result of cls(response) + :rtype: ~azure.core.polling.LROPoller[None] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _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", "2020-10-01")) # type: str + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[None] + polling = kwargs.pop("polling", True) # type: Union[bool, PollingMethod] + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token = kwargs.pop("continuation_token", None) # type: Optional[str] if cont_token is None: - raw_result = self._validate_move_resources_initial( + raw_result = self._validate_move_resources_initial( # type: ignore source_resource_group_name=source_resource_group_name, parameters=parameters, api_version=api_version, content_type=content_type, - cls=lambda x,y,z: x, + cls=lambda x, y, z: x, + headers=_headers, + params=_params, **kwargs ) - kwargs.pop('error_map', None) + kwargs.pop("error_map", None) - def get_long_running_output(pipeline_response): + def get_long_running_output(pipeline_response): # pylint: disable=inconsistent-return-statements if cls: return cls(pipeline_response, None, {}) - - if polling is True: polling_method = ARMPolling(lro_delay, **kwargs) - elif polling is False: polling_method = NoPolling() - else: polling_method = polling + if polling is True: + polling_method = cast(PollingMethod, ARMPolling(lro_delay, **kwargs)) # type: PollingMethod + elif polling is False: + polling_method = cast(PollingMethod, NoPolling()) + else: + polling_method = polling if cont_token: return LROPoller.from_continuation_token( polling_method=polling_method, continuation_token=cont_token, client=self._client, - deserialization_callback=get_long_running_output + deserialization_callback=get_long_running_output, ) return LROPoller(self._client, raw_result, get_long_running_output, polling_method) - begin_validate_move_resources.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{sourceResourceGroupName}/validateMoveResources"} # type: ignore + begin_validate_move_resources.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{sourceResourceGroupName}/validateMoveResources"} # type: ignore @distributed_trace def list( - self, - filter: Optional[str] = None, - expand: Optional[str] = None, - top: Optional[int] = None, - **kwargs: Any - ) -> Iterable["_models.ResourceListResult"]: + self, filter: Optional[str] = None, expand: Optional[str] = None, top: Optional[int] = None, **kwargs: Any + ) -> Iterable["_models.GenericResourceExpanded"]: """Get all the resources in a subscription. :param filter: The filter to apply on the operation.:code:`
`:code:`
`The properties you @@ -8494,40 +9218,50 @@ def list( value is None. :type top: int :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either ResourceListResult or the result of cls(response) + :return: An iterator like instance of either GenericResourceExpanded or the result of + cls(response) :rtype: - ~azure.core.paging.ItemPaged[~azure.mgmt.resource.resources.v2020_10_01.models.ResourceListResult] - :raises: ~azure.core.exceptions.HttpResponseError + ~azure.core.paging.ItemPaged[~azure.mgmt.resource.resources.v2020_10_01.models.GenericResourceExpanded] + :raises ~azure.core.exceptions.HttpResponseError: """ - api_version = kwargs.pop('api_version', "2020-10-01") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2020-10-01")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[_models.ResourceListResult] - cls = kwargs.pop('cls', None) # type: ClsType["_models.ResourceListResult"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) + def prepare_request(next_link=None): if not next_link: - + request = build_resources_list_request( subscription_id=self._config.subscription_id, - api_version=api_version, filter=filter, expand=expand, top=top, - template_url=self.list.metadata['url'], + 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.url = self._client.format_url(request.url) # type: ignore else: - - request = build_resources_list_request( - subscription_id=self._config.subscription_id, - template_url=next_link, - ) + # make call to next link with the client's api-version + _parsed_next_link = urlparse(next_link) + _next_request_params = case_insensitive_dict(parse_qs(_parsed_next_link.query)) + _next_request_params["api-version"] = self._config.api_version + request = HttpRequest("GET", urljoin(next_link, _parsed_next_link.path), params=_next_request_params) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore request.method = "GET" return request @@ -8541,10 +9275,8 @@ def extract_data(pipeline_response): def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) response = pipeline_response.http_response @@ -8554,11 +9286,9 @@ def get_next(next_link=None): return pipeline_response + return ItemPaged(get_next, extract_data) - return ItemPaged( - get_next, extract_data - ) - list.metadata = {'url': "/subscriptions/{subscriptionId}/resources"} # type: ignore + list.metadata = {"url": "/subscriptions/{subscriptionId}/resources"} # type: ignore @distributed_trace def check_existence( @@ -8574,30 +9304,36 @@ def check_existence( """Checks whether a resource exists. :param resource_group_name: The name of the resource group containing the resource to check. - The name is case insensitive. + The name is case insensitive. Required. :type resource_group_name: str - :param resource_provider_namespace: The resource provider of the resource to check. + :param resource_provider_namespace: The resource provider of the resource to check. Required. :type resource_provider_namespace: str - :param parent_resource_path: The parent resource identity. + :param parent_resource_path: The parent resource identity. Required. :type parent_resource_path: str - :param resource_type: The resource type. + :param resource_type: The resource type. Required. :type resource_type: str - :param resource_name: The name of the resource to check whether it exists. + :param resource_name: The name of the resource to check whether it exists. Required. :type resource_name: str - :param api_version: The API version to use for the operation. + :param api_version: The API version to use for the operation. Required. :type api_version: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: bool, or the result of cls(response) + :return: bool or the result of cls(response) :rtype: bool - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType[None] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = kwargs.pop("params", {}) or {} + + cls = kwargs.pop("cls", None) # type: ClsType[None] - request = build_resources_check_existence_request( resource_group_name=resource_group_name, resource_provider_namespace=resource_provider_namespace, @@ -8606,16 +9342,17 @@ def check_existence( resource_name=resource_name, subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.check_existence.metadata['url'], + template_url=self.check_existence.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [204, 404]: @@ -8626,8 +9363,7 @@ def check_existence( return cls(pipeline_response, None, {}) return 200 <= response.status_code <= 299 - check_existence.metadata = {'url': "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{parentResourcePath}/{resourceType}/{resourceName}"} # type: ignore - + check_existence.metadata = {"url": "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{parentResourcePath}/{resourceType}/{resourceName}"} # type: ignore def _delete_initial( # pylint: disable=inconsistent-return-statements self, @@ -8639,14 +9375,20 @@ def _delete_initial( # pylint: disable=inconsistent-return-statements api_version: str, **kwargs: Any ) -> None: - cls = kwargs.pop('cls', None) # type: ClsType[None] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = kwargs.pop("params", {}) or {} - - request = build_resources_delete_request_initial( + cls = kwargs.pop("cls", None) # type: ClsType[None] + + request = build_resources_delete_request( resource_group_name=resource_group_name, resource_provider_namespace=resource_provider_namespace, parent_resource_path=parent_resource_path, @@ -8654,16 +9396,17 @@ def _delete_initial( # pylint: disable=inconsistent-return-statements resource_name=resource_name, subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self._delete_initial.metadata['url'], + template_url=self._delete_initial.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200, 202, 204]: @@ -8673,11 +9416,10 @@ def _delete_initial( # pylint: disable=inconsistent-return-statements if cls: return cls(pipeline_response, None, {}) - _delete_initial.metadata = {'url': "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{parentResourcePath}/{resourceType}/{resourceName}"} # type: ignore - + _delete_initial.metadata = {"url": "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{parentResourcePath}/{resourceType}/{resourceName}"} # type: ignore @distributed_trace - def begin_delete( # pylint: disable=inconsistent-return-statements + def begin_delete( self, resource_group_name: str, resource_provider_namespace: str, @@ -8690,17 +9432,17 @@ def begin_delete( # pylint: disable=inconsistent-return-statements """Deletes a resource. :param resource_group_name: The name of the resource group that contains the resource to - delete. The name is case insensitive. + delete. The name is case insensitive. Required. :type resource_group_name: str - :param resource_provider_namespace: The namespace of the resource provider. + :param resource_provider_namespace: The namespace of the resource provider. Required. :type resource_provider_namespace: str - :param parent_resource_path: The parent resource identity. + :param parent_resource_path: The parent resource identity. Required. :type parent_resource_path: str - :param resource_type: The resource type. + :param resource_type: The resource type. Required. :type resource_type: str - :param resource_name: The name of the resource to delete. + :param resource_name: The name of the resource to delete. Required. :type resource_name: str - :param api_version: The API version to use for the operation. + :param api_version: The API version to use for the operation. Required. :type api_version: str :keyword callable cls: A custom type or function that will be passed the direct response :keyword str continuation_token: A continuation token to restart a poller from a saved state. @@ -8712,46 +9454,50 @@ def begin_delete( # pylint: disable=inconsistent-return-statements Retry-After header is present. :return: An instance of LROPoller that returns either None or the result of cls(response) :rtype: ~azure.core.polling.LROPoller[None] - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - polling = kwargs.pop('polling', True) # type: Union[bool, PollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType[None] - lro_delay = kwargs.pop( - 'polling_interval', - self._config.polling_interval - ) - cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] + _headers = kwargs.pop("headers", {}) or {} + _params = kwargs.pop("params", {}) or {} + + cls = kwargs.pop("cls", None) # type: ClsType[None] + polling = kwargs.pop("polling", True) # type: Union[bool, PollingMethod] + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token = kwargs.pop("continuation_token", None) # type: Optional[str] if cont_token is None: - raw_result = self._delete_initial( + raw_result = self._delete_initial( # type: ignore resource_group_name=resource_group_name, resource_provider_namespace=resource_provider_namespace, parent_resource_path=parent_resource_path, resource_type=resource_type, resource_name=resource_name, api_version=api_version, - cls=lambda x,y,z: x, + cls=lambda x, y, z: x, + headers=_headers, + params=_params, **kwargs ) - kwargs.pop('error_map', None) + kwargs.pop("error_map", None) - def get_long_running_output(pipeline_response): + def get_long_running_output(pipeline_response): # pylint: disable=inconsistent-return-statements if cls: return cls(pipeline_response, None, {}) - - if polling is True: polling_method = ARMPolling(lro_delay, **kwargs) - elif polling is False: polling_method = NoPolling() - else: polling_method = polling + if polling is True: + polling_method = cast(PollingMethod, ARMPolling(lro_delay, **kwargs)) # type: PollingMethod + elif polling is False: + polling_method = cast(PollingMethod, NoPolling()) + else: + polling_method = polling if cont_token: return LROPoller.from_continuation_token( polling_method=polling_method, continuation_token=cont_token, client=self._client, - deserialization_callback=get_long_running_output + deserialization_callback=get_long_running_output, ) return LROPoller(self._client, raw_result, get_long_running_output, polling_method) - begin_delete.metadata = {'url': "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{parentResourcePath}/{resourceType}/{resourceName}"} # type: ignore + begin_delete.metadata = {"url": "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{parentResourcePath}/{resourceType}/{resourceName}"} # type: ignore def _create_or_update_initial( self, @@ -8761,39 +9507,53 @@ def _create_or_update_initial( resource_type: str, resource_name: str, api_version: str, - parameters: "_models.GenericResource", + parameters: Union[_models.GenericResource, IO], **kwargs: Any - ) -> Optional["_models.GenericResource"]: - cls = kwargs.pop('cls', None) # type: ClsType[Optional["_models.GenericResource"]] + ) -> Optional[_models.GenericResource]: error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = kwargs.pop("params", {}) or {} - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[Optional[_models.GenericResource]] - _json = self._serialize.body(parameters, 'GenericResource') + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(parameters, (IO, bytes)): + _content = parameters + else: + _json = self._serialize.body(parameters, "GenericResource") - request = build_resources_create_or_update_request_initial( + request = build_resources_create_or_update_request( resource_group_name=resource_group_name, resource_provider_namespace=resource_provider_namespace, parent_resource_path=parent_resource_path, resource_type=resource_type, resource_name=resource_name, subscription_id=self._config.subscription_id, - content_type=content_type, api_version=api_version, + content_type=content_type, json=_json, - template_url=self._create_or_update_initial.metadata['url'], + content=_content, + template_url=self._create_or_update_initial.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200, 201, 202]: @@ -8802,20 +9562,19 @@ def _create_or_update_initial( deserialized = None if response.status_code == 200: - deserialized = self._deserialize('GenericResource', pipeline_response) + deserialized = self._deserialize("GenericResource", pipeline_response) if response.status_code == 201: - deserialized = self._deserialize('GenericResource', pipeline_response) + deserialized = self._deserialize("GenericResource", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - _create_or_update_initial.metadata = {'url': "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{parentResourcePath}/{resourceType}/{resourceName}"} # type: ignore - + _create_or_update_initial.metadata = {"url": "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{parentResourcePath}/{resourceType}/{resourceName}"} # type: ignore - @distributed_trace + @overload def begin_create_or_update( self, resource_group_name: str, @@ -8824,26 +9583,31 @@ def begin_create_or_update( resource_type: str, resource_name: str, api_version: str, - parameters: "_models.GenericResource", + parameters: _models.GenericResource, + *, + content_type: str = "application/json", **kwargs: Any - ) -> LROPoller["_models.GenericResource"]: + ) -> LROPoller[_models.GenericResource]: """Creates a resource. :param resource_group_name: The name of the resource group for the resource. The name is case - insensitive. + insensitive. Required. :type resource_group_name: str - :param resource_provider_namespace: The namespace of the resource provider. + :param resource_provider_namespace: The namespace of the resource provider. Required. :type resource_provider_namespace: str - :param parent_resource_path: The parent resource identity. + :param parent_resource_path: The parent resource identity. Required. :type parent_resource_path: str - :param resource_type: The resource type of the resource to create. + :param resource_type: The resource type of the resource to create. Required. :type resource_type: str - :param resource_name: The name of the resource to create. + :param resource_name: The name of the resource to create. Required. :type resource_name: str - :param api_version: The API version to use for the operation. + :param api_version: The API version to use for the operation. Required. :type api_version: str - :param parameters: Parameters for creating or updating the resource. + :param parameters: Parameters for creating or updating the resource. Required. :type parameters: ~azure.mgmt.resource.resources.v2020_10_01.models.GenericResource + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str :keyword callable cls: A custom type or function that will be passed the direct response :keyword str continuation_token: A continuation token to restart a poller from a saved state. :keyword polling: By default, your polling method will be ARMPolling. Pass in False for this @@ -8856,54 +9620,11 @@ def begin_create_or_update( cls(response) :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.resource.resources.v2020_10_01.models.GenericResource] - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] - polling = kwargs.pop('polling', True) # type: Union[bool, PollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType["_models.GenericResource"] - lro_delay = kwargs.pop( - 'polling_interval', - self._config.polling_interval - ) - cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] - if cont_token is None: - raw_result = self._create_or_update_initial( - resource_group_name=resource_group_name, - resource_provider_namespace=resource_provider_namespace, - parent_resource_path=parent_resource_path, - resource_type=resource_type, - resource_name=resource_name, - api_version=api_version, - parameters=parameters, - content_type=content_type, - cls=lambda x,y,z: x, - **kwargs - ) - kwargs.pop('error_map', None) - - def get_long_running_output(pipeline_response): - response = pipeline_response.http_response - deserialized = self._deserialize('GenericResource', pipeline_response) - if cls: - return cls(pipeline_response, deserialized, {}) - return deserialized - - if polling is True: polling_method = ARMPolling(lro_delay, **kwargs) - elif polling is False: polling_method = NoPolling() - else: polling_method = polling - if cont_token: - return LROPoller.from_continuation_token( - polling_method=polling_method, - continuation_token=cont_token, - client=self._client, - deserialization_callback=get_long_running_output - ) - return LROPoller(self._client, raw_result, get_long_running_output, polling_method) - - begin_create_or_update.metadata = {'url': "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{parentResourcePath}/{resourceType}/{resourceName}"} # type: ignore - - def _update_initial( + @overload + def begin_create_or_update( self, resource_group_name: str, resource_provider_namespace: str, @@ -8911,56 +9632,310 @@ def _update_initial( resource_type: str, resource_name: str, api_version: str, - parameters: "_models.GenericResource", + parameters: IO, + *, + content_type: str = "application/json", **kwargs: Any - ) -> Optional["_models.GenericResource"]: - cls = kwargs.pop('cls', None) # type: ClsType[Optional["_models.GenericResource"]] - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {})) - - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] - - _json = self._serialize.body(parameters, 'GenericResource') - - request = build_resources_update_request_initial( - resource_group_name=resource_group_name, - resource_provider_namespace=resource_provider_namespace, - parent_resource_path=parent_resource_path, - resource_type=resource_type, - resource_name=resource_name, - subscription_id=self._config.subscription_id, - content_type=content_type, - api_version=api_version, - json=_json, - template_url=self._update_initial.metadata['url'], - ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) - - pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs - ) - response = pipeline_response.http_response + ) -> LROPoller[_models.GenericResource]: + """Creates a resource. - if response.status_code not in [200, 202]: + :param resource_group_name: The name of the resource group for the resource. The name is case + insensitive. Required. + :type resource_group_name: str + :param resource_provider_namespace: The namespace of the resource provider. Required. + :type resource_provider_namespace: str + :param parent_resource_path: The parent resource identity. Required. + :type parent_resource_path: str + :param resource_type: The resource type of the resource to create. Required. + :type resource_type: str + :param resource_name: The name of the resource to create. Required. + :type resource_name: str + :param api_version: The API version to use for the operation. Required. + :type api_version: str + :param parameters: Parameters for creating or updating the resource. Required. + :type parameters: IO + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be ARMPolling. Pass in False for this + operation to not poll, or pass in your own initialized polling object for a personal polling + strategy. + :paramtype polling: bool or ~azure.core.polling.PollingMethod + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of LROPoller that returns either GenericResource or the result of + cls(response) + :rtype: + ~azure.core.polling.LROPoller[~azure.mgmt.resource.resources.v2020_10_01.models.GenericResource] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace + def begin_create_or_update( + self, + resource_group_name: str, + resource_provider_namespace: str, + parent_resource_path: str, + resource_type: str, + resource_name: str, + api_version: str, + parameters: Union[_models.GenericResource, IO], + **kwargs: Any + ) -> LROPoller[_models.GenericResource]: + """Creates a resource. + + :param resource_group_name: The name of the resource group for the resource. The name is case + insensitive. Required. + :type resource_group_name: str + :param resource_provider_namespace: The namespace of the resource provider. Required. + :type resource_provider_namespace: str + :param parent_resource_path: The parent resource identity. Required. + :type parent_resource_path: str + :param resource_type: The resource type of the resource to create. Required. + :type resource_type: str + :param resource_name: The name of the resource to create. Required. + :type resource_name: str + :param api_version: The API version to use for the operation. Required. + :type api_version: str + :param parameters: Parameters for creating or updating the resource. Is either a model type or + a IO type. Required. + :type parameters: ~azure.mgmt.resource.resources.v2020_10_01.models.GenericResource or IO + :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. + Default value is None. + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be ARMPolling. Pass in False for this + operation to not poll, or pass in your own initialized polling object for a personal polling + strategy. + :paramtype polling: bool or ~azure.core.polling.PollingMethod + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of LROPoller that returns either GenericResource or the result of + cls(response) + :rtype: + ~azure.core.polling.LROPoller[~azure.mgmt.resource.resources.v2020_10_01.models.GenericResource] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = kwargs.pop("params", {}) or {} + + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.GenericResource] + polling = kwargs.pop("polling", True) # type: Union[bool, PollingMethod] + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token = kwargs.pop("continuation_token", None) # type: Optional[str] + if cont_token is None: + raw_result = self._create_or_update_initial( # type: ignore + resource_group_name=resource_group_name, + resource_provider_namespace=resource_provider_namespace, + parent_resource_path=parent_resource_path, + resource_type=resource_type, + resource_name=resource_name, + api_version=api_version, + parameters=parameters, + content_type=content_type, + cls=lambda x, y, z: x, + headers=_headers, + params=_params, + **kwargs + ) + kwargs.pop("error_map", None) + + def get_long_running_output(pipeline_response): + deserialized = self._deserialize("GenericResource", pipeline_response) + if cls: + return cls(pipeline_response, deserialized, {}) + return deserialized + + if polling is True: + polling_method = cast(PollingMethod, ARMPolling(lro_delay, **kwargs)) # type: PollingMethod + elif polling is False: + polling_method = cast(PollingMethod, NoPolling()) + else: + polling_method = polling + if cont_token: + return LROPoller.from_continuation_token( + polling_method=polling_method, + continuation_token=cont_token, + client=self._client, + deserialization_callback=get_long_running_output, + ) + return LROPoller(self._client, raw_result, get_long_running_output, polling_method) + + begin_create_or_update.metadata = {"url": "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{parentResourcePath}/{resourceType}/{resourceName}"} # type: ignore + + def _update_initial( + self, + resource_group_name: str, + resource_provider_namespace: str, + parent_resource_path: str, + resource_type: str, + resource_name: str, + api_version: str, + parameters: Union[_models.GenericResource, IO], + **kwargs: Any + ) -> Optional[_models.GenericResource]: + error_map = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = kwargs.pop("params", {}) or {} + + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[Optional[_models.GenericResource]] + + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(parameters, (IO, bytes)): + _content = parameters + else: + _json = self._serialize.body(parameters, "GenericResource") + + request = build_resources_update_request( + resource_group_name=resource_group_name, + resource_provider_namespace=resource_provider_namespace, + parent_resource_path=parent_resource_path, + resource_type=resource_type, + resource_name=resource_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + content_type=content_type, + json=_json, + content=_content, + template_url=self._update_initial.metadata["url"], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore + + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [200, 202]: map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) deserialized = None if response.status_code == 200: - deserialized = self._deserialize('GenericResource', pipeline_response) + deserialized = self._deserialize("GenericResource", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - _update_initial.metadata = {'url': "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{parentResourcePath}/{resourceType}/{resourceName}"} # type: ignore + _update_initial.metadata = {"url": "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{parentResourcePath}/{resourceType}/{resourceName}"} # type: ignore + @overload + def begin_update( + self, + resource_group_name: str, + resource_provider_namespace: str, + parent_resource_path: str, + resource_type: str, + resource_name: str, + api_version: str, + parameters: _models.GenericResource, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> LROPoller[_models.GenericResource]: + """Updates a resource. + + :param resource_group_name: The name of the resource group for the resource. The name is case + insensitive. Required. + :type resource_group_name: str + :param resource_provider_namespace: The namespace of the resource provider. Required. + :type resource_provider_namespace: str + :param parent_resource_path: The parent resource identity. Required. + :type parent_resource_path: str + :param resource_type: The resource type of the resource to update. Required. + :type resource_type: str + :param resource_name: The name of the resource to update. Required. + :type resource_name: str + :param api_version: The API version to use for the operation. Required. + :type api_version: str + :param parameters: Parameters for updating the resource. Required. + :type parameters: ~azure.mgmt.resource.resources.v2020_10_01.models.GenericResource + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be ARMPolling. Pass in False for this + operation to not poll, or pass in your own initialized polling object for a personal polling + strategy. + :paramtype polling: bool or ~azure.core.polling.PollingMethod + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of LROPoller that returns either GenericResource or the result of + cls(response) + :rtype: + ~azure.core.polling.LROPoller[~azure.mgmt.resource.resources.v2020_10_01.models.GenericResource] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + def begin_update( + self, + resource_group_name: str, + resource_provider_namespace: str, + parent_resource_path: str, + resource_type: str, + resource_name: str, + api_version: str, + parameters: IO, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> LROPoller[_models.GenericResource]: + """Updates a resource. + + :param resource_group_name: The name of the resource group for the resource. The name is case + insensitive. Required. + :type resource_group_name: str + :param resource_provider_namespace: The namespace of the resource provider. Required. + :type resource_provider_namespace: str + :param parent_resource_path: The parent resource identity. Required. + :type parent_resource_path: str + :param resource_type: The resource type of the resource to update. Required. + :type resource_type: str + :param resource_name: The name of the resource to update. Required. + :type resource_name: str + :param api_version: The API version to use for the operation. Required. + :type api_version: str + :param parameters: Parameters for updating the resource. Required. + :type parameters: IO + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be ARMPolling. Pass in False for this + operation to not poll, or pass in your own initialized polling object for a personal polling + strategy. + :paramtype polling: bool or ~azure.core.polling.PollingMethod + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of LROPoller that returns either GenericResource or the result of + cls(response) + :rtype: + ~azure.core.polling.LROPoller[~azure.mgmt.resource.resources.v2020_10_01.models.GenericResource] + :raises ~azure.core.exceptions.HttpResponseError: + """ @distributed_trace def begin_update( @@ -8971,26 +9946,30 @@ def begin_update( resource_type: str, resource_name: str, api_version: str, - parameters: "_models.GenericResource", + parameters: Union[_models.GenericResource, IO], **kwargs: Any - ) -> LROPoller["_models.GenericResource"]: + ) -> LROPoller[_models.GenericResource]: """Updates a resource. :param resource_group_name: The name of the resource group for the resource. The name is case - insensitive. + insensitive. Required. :type resource_group_name: str - :param resource_provider_namespace: The namespace of the resource provider. + :param resource_provider_namespace: The namespace of the resource provider. Required. :type resource_provider_namespace: str - :param parent_resource_path: The parent resource identity. + :param parent_resource_path: The parent resource identity. Required. :type parent_resource_path: str - :param resource_type: The resource type of the resource to update. + :param resource_type: The resource type of the resource to update. Required. :type resource_type: str - :param resource_name: The name of the resource to update. + :param resource_name: The name of the resource to update. Required. :type resource_name: str - :param api_version: The API version to use for the operation. + :param api_version: The API version to use for the operation. Required. :type api_version: str - :param parameters: Parameters for updating the resource. - :type parameters: ~azure.mgmt.resource.resources.v2020_10_01.models.GenericResource + :param parameters: Parameters for updating the resource. Is either a model type or a IO type. + Required. + :type parameters: ~azure.mgmt.resource.resources.v2020_10_01.models.GenericResource or IO + :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. + Default value is None. + :paramtype content_type: str :keyword callable cls: A custom type or function that will be passed the direct response :keyword str continuation_token: A continuation token to restart a poller from a saved state. :keyword polling: By default, your polling method will be ARMPolling. Pass in False for this @@ -9003,18 +9982,18 @@ def begin_update( cls(response) :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.resource.resources.v2020_10_01.models.GenericResource] - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] - polling = kwargs.pop('polling', True) # type: Union[bool, PollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType["_models.GenericResource"] - lro_delay = kwargs.pop( - 'polling_interval', - self._config.polling_interval - ) - cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = kwargs.pop("params", {}) or {} + + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.GenericResource] + polling = kwargs.pop("polling", True) # type: Union[bool, PollingMethod] + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token = kwargs.pop("continuation_token", None) # type: Optional[str] if cont_token is None: - raw_result = self._update_initial( + raw_result = self._update_initial( # type: ignore resource_group_name=resource_group_name, resource_provider_namespace=resource_provider_namespace, parent_resource_path=parent_resource_path, @@ -9023,32 +10002,35 @@ def begin_update( api_version=api_version, parameters=parameters, content_type=content_type, - cls=lambda x,y,z: x, + cls=lambda x, y, z: x, + headers=_headers, + params=_params, **kwargs ) - kwargs.pop('error_map', None) + kwargs.pop("error_map", None) def get_long_running_output(pipeline_response): - response = pipeline_response.http_response - deserialized = self._deserialize('GenericResource', pipeline_response) + deserialized = self._deserialize("GenericResource", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - - if polling is True: polling_method = ARMPolling(lro_delay, **kwargs) - elif polling is False: polling_method = NoPolling() - else: polling_method = polling + if polling is True: + polling_method = cast(PollingMethod, ARMPolling(lro_delay, **kwargs)) # type: PollingMethod + elif polling is False: + polling_method = cast(PollingMethod, NoPolling()) + else: + polling_method = polling if cont_token: return LROPoller.from_continuation_token( polling_method=polling_method, continuation_token=cont_token, client=self._client, - deserialization_callback=get_long_running_output + deserialization_callback=get_long_running_output, ) return LROPoller(self._client, raw_result, get_long_running_output, polling_method) - begin_update.metadata = {'url': "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{parentResourcePath}/{resourceType}/{resourceName}"} # type: ignore + begin_update.metadata = {"url": "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{parentResourcePath}/{resourceType}/{resourceName}"} # type: ignore @distributed_trace def get( @@ -9060,34 +10042,40 @@ def get( resource_name: str, api_version: str, **kwargs: Any - ) -> "_models.GenericResource": + ) -> _models.GenericResource: """Gets a resource. :param resource_group_name: The name of the resource group containing the resource to get. The - name is case insensitive. + name is case insensitive. Required. :type resource_group_name: str - :param resource_provider_namespace: The namespace of the resource provider. + :param resource_provider_namespace: The namespace of the resource provider. Required. :type resource_provider_namespace: str - :param parent_resource_path: The parent resource identity. + :param parent_resource_path: The parent resource identity. Required. :type parent_resource_path: str - :param resource_type: The resource type of the resource. + :param resource_type: The resource type of the resource. Required. :type resource_type: str - :param resource_name: The name of the resource to get. + :param resource_name: The name of the resource to get. Required. :type resource_name: str - :param api_version: The API version to use for the operation. + :param api_version: The API version to use for the operation. Required. :type api_version: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: GenericResource, or the result of cls(response) + :return: GenericResource or the result of cls(response) :rtype: ~azure.mgmt.resource.resources.v2020_10_01.models.GenericResource - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.GenericResource"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = kwargs.pop("params", {}) or {} + + cls = kwargs.pop("cls", None) # type: ClsType[_models.GenericResource] - request = build_resources_get_request( resource_group_name=resource_group_name, resource_provider_namespace=resource_provider_namespace, @@ -9096,72 +10084,75 @@ def get( resource_name=resource_name, subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.get.metadata['url'], + template_url=self.get.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) - deserialized = self._deserialize('GenericResource', pipeline_response) + deserialized = self._deserialize("GenericResource", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - get.metadata = {'url': "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{parentResourcePath}/{resourceType}/{resourceName}"} # type: ignore - + get.metadata = {"url": "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{parentResourcePath}/{resourceType}/{resourceName}"} # type: ignore @distributed_trace - def check_existence_by_id( - self, - resource_id: str, - api_version: str, - **kwargs: Any - ) -> bool: + def check_existence_by_id(self, resource_id: str, api_version: str, **kwargs: Any) -> bool: """Checks by ID whether a resource exists. :param resource_id: The fully qualified ID of the resource, including the resource name and resource type. Use the format, /subscriptions/{guid}/resourceGroups/{resource-group-name}/{resource-provider-namespace}/{resource-type}/{resource-name}. + Required. :type resource_id: str - :param api_version: The API version to use for the operation. + :param api_version: The API version to use for the operation. Required. :type api_version: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: bool, or the result of cls(response) + :return: bool or the result of cls(response) :rtype: bool - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType[None] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = kwargs.pop("params", {}) or {} + + cls = kwargs.pop("cls", None) # type: ClsType[None] - request = build_resources_check_existence_by_id_request( resource_id=resource_id, api_version=api_version, - template_url=self.check_existence_by_id.metadata['url'], + template_url=self.check_existence_by_id.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [204, 404]: @@ -9172,35 +10163,38 @@ def check_existence_by_id( return cls(pipeline_response, None, {}) return 200 <= response.status_code <= 299 - check_existence_by_id.metadata = {'url': "/{resourceId}"} # type: ignore - + check_existence_by_id.metadata = {"url": "/{resourceId}"} # type: ignore def _delete_by_id_initial( # pylint: disable=inconsistent-return-statements - self, - resource_id: str, - api_version: str, - **kwargs: Any + self, resource_id: str, api_version: str, **kwargs: Any ) -> None: - cls = kwargs.pop('cls', None) # type: ClsType[None] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = kwargs.pop("params", {}) or {} - - request = build_resources_delete_by_id_request_initial( + cls = kwargs.pop("cls", None) # type: ClsType[None] + + request = build_resources_delete_by_id_request( resource_id=resource_id, api_version=api_version, - template_url=self._delete_by_id_initial.metadata['url'], + template_url=self._delete_by_id_initial.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200, 202, 204]: @@ -9210,23 +10204,18 @@ def _delete_by_id_initial( # pylint: disable=inconsistent-return-statements if cls: return cls(pipeline_response, None, {}) - _delete_by_id_initial.metadata = {'url': "/{resourceId}"} # type: ignore - + _delete_by_id_initial.metadata = {"url": "/{resourceId}"} # type: ignore @distributed_trace - def begin_delete_by_id( # pylint: disable=inconsistent-return-statements - self, - resource_id: str, - api_version: str, - **kwargs: Any - ) -> LROPoller[None]: + def begin_delete_by_id(self, resource_id: str, api_version: str, **kwargs: Any) -> LROPoller[None]: """Deletes a resource by ID. :param resource_id: The fully qualified ID of the resource, including the resource name and resource type. Use the format, /subscriptions/{guid}/resourceGroups/{resource-group-name}/{resource-provider-namespace}/{resource-type}/{resource-name}. + Required. :type resource_id: str - :param api_version: The API version to use for the operation. + :param api_version: The API version to use for the operation. Required. :type api_version: str :keyword callable cls: A custom type or function that will be passed the direct response :keyword str continuation_token: A continuation token to restart a poller from a saved state. @@ -9238,75 +10227,89 @@ def begin_delete_by_id( # pylint: disable=inconsistent-return-statements Retry-After header is present. :return: An instance of LROPoller that returns either None or the result of cls(response) :rtype: ~azure.core.polling.LROPoller[None] - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - polling = kwargs.pop('polling', True) # type: Union[bool, PollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType[None] - lro_delay = kwargs.pop( - 'polling_interval', - self._config.polling_interval - ) - cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] + _headers = kwargs.pop("headers", {}) or {} + _params = kwargs.pop("params", {}) or {} + + cls = kwargs.pop("cls", None) # type: ClsType[None] + polling = kwargs.pop("polling", True) # type: Union[bool, PollingMethod] + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token = kwargs.pop("continuation_token", None) # type: Optional[str] if cont_token is None: - raw_result = self._delete_by_id_initial( + raw_result = self._delete_by_id_initial( # type: ignore resource_id=resource_id, api_version=api_version, - cls=lambda x,y,z: x, + cls=lambda x, y, z: x, + headers=_headers, + params=_params, **kwargs ) - kwargs.pop('error_map', None) + kwargs.pop("error_map", None) - def get_long_running_output(pipeline_response): + def get_long_running_output(pipeline_response): # pylint: disable=inconsistent-return-statements if cls: return cls(pipeline_response, None, {}) - - if polling is True: polling_method = ARMPolling(lro_delay, **kwargs) - elif polling is False: polling_method = NoPolling() - else: polling_method = polling + if polling is True: + polling_method = cast(PollingMethod, ARMPolling(lro_delay, **kwargs)) # type: PollingMethod + elif polling is False: + polling_method = cast(PollingMethod, NoPolling()) + else: + polling_method = polling if cont_token: return LROPoller.from_continuation_token( polling_method=polling_method, continuation_token=cont_token, client=self._client, - deserialization_callback=get_long_running_output + deserialization_callback=get_long_running_output, ) return LROPoller(self._client, raw_result, get_long_running_output, polling_method) - begin_delete_by_id.metadata = {'url': "/{resourceId}"} # type: ignore + begin_delete_by_id.metadata = {"url": "/{resourceId}"} # type: ignore def _create_or_update_by_id_initial( - self, - resource_id: str, - api_version: str, - parameters: "_models.GenericResource", - **kwargs: Any - ) -> Optional["_models.GenericResource"]: - cls = kwargs.pop('cls', None) # type: ClsType[Optional["_models.GenericResource"]] + self, resource_id: str, api_version: str, parameters: Union[_models.GenericResource, IO], **kwargs: Any + ) -> Optional[_models.GenericResource]: error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = kwargs.pop("params", {}) or {} - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[Optional[_models.GenericResource]] - _json = self._serialize.body(parameters, 'GenericResource') + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(parameters, (IO, bytes)): + _content = parameters + else: + _json = self._serialize.body(parameters, "GenericResource") - request = build_resources_create_or_update_by_id_request_initial( + request = build_resources_create_or_update_by_id_request( resource_id=resource_id, - content_type=content_type, api_version=api_version, + content_type=content_type, json=_json, - template_url=self._create_or_update_by_id_initial.metadata['url'], + content=_content, + template_url=self._create_or_update_by_id_initial.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200, 201, 202]: @@ -9315,37 +10318,42 @@ def _create_or_update_by_id_initial( deserialized = None if response.status_code == 200: - deserialized = self._deserialize('GenericResource', pipeline_response) + deserialized = self._deserialize("GenericResource", pipeline_response) if response.status_code == 201: - deserialized = self._deserialize('GenericResource', pipeline_response) + deserialized = self._deserialize("GenericResource", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - _create_or_update_by_id_initial.metadata = {'url': "/{resourceId}"} # type: ignore - + _create_or_update_by_id_initial.metadata = {"url": "/{resourceId}"} # type: ignore - @distributed_trace + @overload def begin_create_or_update_by_id( self, resource_id: str, api_version: str, - parameters: "_models.GenericResource", + parameters: _models.GenericResource, + *, + content_type: str = "application/json", **kwargs: Any - ) -> LROPoller["_models.GenericResource"]: + ) -> LROPoller[_models.GenericResource]: """Create a resource by ID. :param resource_id: The fully qualified ID of the resource, including the resource name and resource type. Use the format, /subscriptions/{guid}/resourceGroups/{resource-group-name}/{resource-provider-namespace}/{resource-type}/{resource-name}. + Required. :type resource_id: str - :param api_version: The API version to use for the operation. + :param api_version: The API version to use for the operation. Required. :type api_version: str - :param parameters: Create or update resource parameters. + :param parameters: Create or update resource parameters. Required. :type parameters: ~azure.mgmt.resource.resources.v2020_10_01.models.GenericResource + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str :keyword callable cls: A custom type or function that will be passed the direct response :keyword str continuation_token: A continuation token to restart a poller from a saved state. :keyword polling: By default, your polling method will be ARMPolling. Pass in False for this @@ -9358,81 +10366,167 @@ def begin_create_or_update_by_id( cls(response) :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.resource.resources.v2020_10_01.models.GenericResource] - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] - polling = kwargs.pop('polling', True) # type: Union[bool, PollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType["_models.GenericResource"] - lro_delay = kwargs.pop( - 'polling_interval', - self._config.polling_interval - ) - cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] + + @overload + def begin_create_or_update_by_id( + self, + resource_id: str, + api_version: str, + parameters: IO, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> LROPoller[_models.GenericResource]: + """Create a resource by ID. + + :param resource_id: The fully qualified ID of the resource, including the resource name and + resource type. Use the format, + /subscriptions/{guid}/resourceGroups/{resource-group-name}/{resource-provider-namespace}/{resource-type}/{resource-name}. + Required. + :type resource_id: str + :param api_version: The API version to use for the operation. Required. + :type api_version: str + :param parameters: Create or update resource parameters. Required. + :type parameters: IO + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be ARMPolling. Pass in False for this + operation to not poll, or pass in your own initialized polling object for a personal polling + strategy. + :paramtype polling: bool or ~azure.core.polling.PollingMethod + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of LROPoller that returns either GenericResource or the result of + cls(response) + :rtype: + ~azure.core.polling.LROPoller[~azure.mgmt.resource.resources.v2020_10_01.models.GenericResource] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace + def begin_create_or_update_by_id( + self, resource_id: str, api_version: str, parameters: Union[_models.GenericResource, IO], **kwargs: Any + ) -> LROPoller[_models.GenericResource]: + """Create a resource by ID. + + :param resource_id: The fully qualified ID of the resource, including the resource name and + resource type. Use the format, + /subscriptions/{guid}/resourceGroups/{resource-group-name}/{resource-provider-namespace}/{resource-type}/{resource-name}. + Required. + :type resource_id: str + :param api_version: The API version to use for the operation. Required. + :type api_version: str + :param parameters: Create or update resource parameters. Is either a model type or a IO type. + Required. + :type parameters: ~azure.mgmt.resource.resources.v2020_10_01.models.GenericResource or IO + :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. + Default value is None. + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be ARMPolling. Pass in False for this + operation to not poll, or pass in your own initialized polling object for a personal polling + strategy. + :paramtype polling: bool or ~azure.core.polling.PollingMethod + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of LROPoller that returns either GenericResource or the result of + cls(response) + :rtype: + ~azure.core.polling.LROPoller[~azure.mgmt.resource.resources.v2020_10_01.models.GenericResource] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = kwargs.pop("params", {}) or {} + + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.GenericResource] + polling = kwargs.pop("polling", True) # type: Union[bool, PollingMethod] + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token = kwargs.pop("continuation_token", None) # type: Optional[str] if cont_token is None: - raw_result = self._create_or_update_by_id_initial( + raw_result = self._create_or_update_by_id_initial( # type: ignore resource_id=resource_id, api_version=api_version, parameters=parameters, content_type=content_type, - cls=lambda x,y,z: x, + cls=lambda x, y, z: x, + headers=_headers, + params=_params, **kwargs ) - kwargs.pop('error_map', None) + kwargs.pop("error_map", None) def get_long_running_output(pipeline_response): - response = pipeline_response.http_response - deserialized = self._deserialize('GenericResource', pipeline_response) + deserialized = self._deserialize("GenericResource", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - - if polling is True: polling_method = ARMPolling(lro_delay, **kwargs) - elif polling is False: polling_method = NoPolling() - else: polling_method = polling + if polling is True: + polling_method = cast(PollingMethod, ARMPolling(lro_delay, **kwargs)) # type: PollingMethod + elif polling is False: + polling_method = cast(PollingMethod, NoPolling()) + else: + polling_method = polling if cont_token: return LROPoller.from_continuation_token( polling_method=polling_method, continuation_token=cont_token, client=self._client, - deserialization_callback=get_long_running_output + deserialization_callback=get_long_running_output, ) return LROPoller(self._client, raw_result, get_long_running_output, polling_method) - begin_create_or_update_by_id.metadata = {'url': "/{resourceId}"} # type: ignore + begin_create_or_update_by_id.metadata = {"url": "/{resourceId}"} # type: ignore def _update_by_id_initial( - self, - resource_id: str, - api_version: str, - parameters: "_models.GenericResource", - **kwargs: Any - ) -> Optional["_models.GenericResource"]: - cls = kwargs.pop('cls', None) # type: ClsType[Optional["_models.GenericResource"]] + self, resource_id: str, api_version: str, parameters: Union[_models.GenericResource, IO], **kwargs: Any + ) -> Optional[_models.GenericResource]: error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = kwargs.pop("params", {}) or {} - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[Optional[_models.GenericResource]] - _json = self._serialize.body(parameters, 'GenericResource') + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(parameters, (IO, bytes)): + _content = parameters + else: + _json = self._serialize.body(parameters, "GenericResource") - request = build_resources_update_by_id_request_initial( + request = build_resources_update_by_id_request( resource_id=resource_id, - content_type=content_type, api_version=api_version, + content_type=content_type, json=_json, - template_url=self._update_by_id_initial.metadata['url'], + content=_content, + template_url=self._update_by_id_initial.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200, 202]: @@ -9441,34 +10535,39 @@ def _update_by_id_initial( deserialized = None if response.status_code == 200: - deserialized = self._deserialize('GenericResource', pipeline_response) + deserialized = self._deserialize("GenericResource", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - _update_by_id_initial.metadata = {'url': "/{resourceId}"} # type: ignore - + _update_by_id_initial.metadata = {"url": "/{resourceId}"} # type: ignore - @distributed_trace + @overload def begin_update_by_id( self, resource_id: str, api_version: str, - parameters: "_models.GenericResource", + parameters: _models.GenericResource, + *, + content_type: str = "application/json", **kwargs: Any - ) -> LROPoller["_models.GenericResource"]: + ) -> LROPoller[_models.GenericResource]: """Updates a resource by ID. :param resource_id: The fully qualified ID of the resource, including the resource name and resource type. Use the format, /subscriptions/{guid}/resourceGroups/{resource-group-name}/{resource-provider-namespace}/{resource-type}/{resource-name}. + Required. :type resource_id: str - :param api_version: The API version to use for the operation. + :param api_version: The API version to use for the operation. Required. :type api_version: str - :param parameters: Update resource parameters. + :param parameters: Update resource parameters. Required. :type parameters: ~azure.mgmt.resource.resources.v2020_10_01.models.GenericResource + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str :keyword callable cls: A custom type or function that will be passed the direct response :keyword str continuation_token: A continuation token to restart a poller from a saved state. :keyword polling: By default, your polling method will be ARMPolling. Pass in False for this @@ -9481,165 +10580,243 @@ def begin_update_by_id( cls(response) :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.resource.resources.v2020_10_01.models.GenericResource] - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] - polling = kwargs.pop('polling', True) # type: Union[bool, PollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType["_models.GenericResource"] - lro_delay = kwargs.pop( - 'polling_interval', - self._config.polling_interval - ) - cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] + + @overload + def begin_update_by_id( + self, + resource_id: str, + api_version: str, + parameters: IO, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> LROPoller[_models.GenericResource]: + """Updates a resource by ID. + + :param resource_id: The fully qualified ID of the resource, including the resource name and + resource type. Use the format, + /subscriptions/{guid}/resourceGroups/{resource-group-name}/{resource-provider-namespace}/{resource-type}/{resource-name}. + Required. + :type resource_id: str + :param api_version: The API version to use for the operation. Required. + :type api_version: str + :param parameters: Update resource parameters. Required. + :type parameters: IO + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be ARMPolling. Pass in False for this + operation to not poll, or pass in your own initialized polling object for a personal polling + strategy. + :paramtype polling: bool or ~azure.core.polling.PollingMethod + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of LROPoller that returns either GenericResource or the result of + cls(response) + :rtype: + ~azure.core.polling.LROPoller[~azure.mgmt.resource.resources.v2020_10_01.models.GenericResource] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace + def begin_update_by_id( + self, resource_id: str, api_version: str, parameters: Union[_models.GenericResource, IO], **kwargs: Any + ) -> LROPoller[_models.GenericResource]: + """Updates a resource by ID. + + :param resource_id: The fully qualified ID of the resource, including the resource name and + resource type. Use the format, + /subscriptions/{guid}/resourceGroups/{resource-group-name}/{resource-provider-namespace}/{resource-type}/{resource-name}. + Required. + :type resource_id: str + :param api_version: The API version to use for the operation. Required. + :type api_version: str + :param parameters: Update resource parameters. Is either a model type or a IO type. Required. + :type parameters: ~azure.mgmt.resource.resources.v2020_10_01.models.GenericResource or IO + :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. + Default value is None. + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be ARMPolling. Pass in False for this + operation to not poll, or pass in your own initialized polling object for a personal polling + strategy. + :paramtype polling: bool or ~azure.core.polling.PollingMethod + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of LROPoller that returns either GenericResource or the result of + cls(response) + :rtype: + ~azure.core.polling.LROPoller[~azure.mgmt.resource.resources.v2020_10_01.models.GenericResource] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = kwargs.pop("params", {}) or {} + + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.GenericResource] + polling = kwargs.pop("polling", True) # type: Union[bool, PollingMethod] + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token = kwargs.pop("continuation_token", None) # type: Optional[str] if cont_token is None: - raw_result = self._update_by_id_initial( + raw_result = self._update_by_id_initial( # type: ignore resource_id=resource_id, api_version=api_version, parameters=parameters, content_type=content_type, - cls=lambda x,y,z: x, + cls=lambda x, y, z: x, + headers=_headers, + params=_params, **kwargs ) - kwargs.pop('error_map', None) + kwargs.pop("error_map", None) def get_long_running_output(pipeline_response): - response = pipeline_response.http_response - deserialized = self._deserialize('GenericResource', pipeline_response) + deserialized = self._deserialize("GenericResource", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - - if polling is True: polling_method = ARMPolling(lro_delay, **kwargs) - elif polling is False: polling_method = NoPolling() - else: polling_method = polling + if polling is True: + polling_method = cast(PollingMethod, ARMPolling(lro_delay, **kwargs)) # type: PollingMethod + elif polling is False: + polling_method = cast(PollingMethod, NoPolling()) + else: + polling_method = polling if cont_token: return LROPoller.from_continuation_token( polling_method=polling_method, continuation_token=cont_token, client=self._client, - deserialization_callback=get_long_running_output + deserialization_callback=get_long_running_output, ) return LROPoller(self._client, raw_result, get_long_running_output, polling_method) - begin_update_by_id.metadata = {'url': "/{resourceId}"} # type: ignore + begin_update_by_id.metadata = {"url": "/{resourceId}"} # type: ignore @distributed_trace - def get_by_id( - self, - resource_id: str, - api_version: str, - **kwargs: Any - ) -> "_models.GenericResource": + def get_by_id(self, resource_id: str, api_version: str, **kwargs: Any) -> _models.GenericResource: """Gets a resource by ID. :param resource_id: The fully qualified ID of the resource, including the resource name and resource type. Use the format, /subscriptions/{guid}/resourceGroups/{resource-group-name}/{resource-provider-namespace}/{resource-type}/{resource-name}. + Required. :type resource_id: str - :param api_version: The API version to use for the operation. + :param api_version: The API version to use for the operation. Required. :type api_version: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: GenericResource, or the result of cls(response) + :return: GenericResource or the result of cls(response) :rtype: ~azure.mgmt.resource.resources.v2020_10_01.models.GenericResource - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.GenericResource"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = kwargs.pop("params", {}) or {} + + cls = kwargs.pop("cls", None) # type: ClsType[_models.GenericResource] - request = build_resources_get_by_id_request( resource_id=resource_id, api_version=api_version, - template_url=self.get_by_id.metadata['url'], + template_url=self.get_by_id.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) - deserialized = self._deserialize('GenericResource', pipeline_response) + deserialized = self._deserialize("GenericResource", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - get_by_id.metadata = {'url': "/{resourceId}"} # type: ignore + get_by_id.metadata = {"url": "/{resourceId}"} # type: ignore -class ResourceGroupsOperations(object): - """ResourceGroupsOperations operations. - You should not instantiate this class directly. Instead, you should create a Client instance that - instantiates it for you and attaches it as an attribute. +class ResourceGroupsOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. - :ivar models: Alias to model classes used in this operation group. - :type models: ~azure.mgmt.resource.resources.v2020_10_01.models - :param client: Client for service requests. - :param config: Configuration of service client. - :param serializer: An object model serializer. - :param deserializer: An object model deserializer. + Instead, you should access the following operations through + :class:`~azure.mgmt.resource.resources.v2020_10_01.ResourceManagementClient`'s + :attr:`resource_groups` attribute. """ models = _models - def __init__(self, client, config, serializer, deserializer): - self._client = client - self._serialize = serializer - self._deserialize = deserializer - self._config = config + def __init__(self, *args, **kwargs): + input_args = list(args) + self._client = input_args.pop(0) if input_args else kwargs.pop("client") + self._config = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") @distributed_trace - def check_existence( - self, - resource_group_name: str, - **kwargs: Any - ) -> bool: + def check_existence(self, resource_group_name: str, **kwargs: Any) -> bool: """Checks whether a resource group exists. :param resource_group_name: The name of the resource group to check. The name is case - insensitive. + insensitive. Required. :type resource_group_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: bool, or the result of cls(response) + :return: bool or the result of cls(response) :rtype: bool - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType[None] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) - api_version = kwargs.pop('api_version', "2020-10-01") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2020-10-01")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[None] - request = build_resource_groups_check_existence_request( resource_group_name=resource_group_name, subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.check_existence.metadata['url'], + template_url=self.check_existence.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [204, 404]: @@ -9650,39 +10827,98 @@ def check_existence( return cls(pipeline_response, None, {}) return 200 <= response.status_code <= 299 - check_existence.metadata = {'url': "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}"} # type: ignore + check_existence.metadata = {"url": "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}"} # type: ignore - - @distributed_trace + @overload def create_or_update( self, resource_group_name: str, - parameters: "_models.ResourceGroup", + parameters: _models.ResourceGroup, + *, + content_type: str = "application/json", **kwargs: Any - ) -> "_models.ResourceGroup": + ) -> _models.ResourceGroup: """Creates or updates a resource group. :param resource_group_name: The name of the resource group to create or update. Can include alphanumeric, underscore, parentheses, hyphen, period (except at end), and Unicode characters - that match the allowed characters. + that match the allowed characters. Required. :type resource_group_name: str - :param parameters: Parameters supplied to the create or update a resource group. + :param parameters: Parameters supplied to the create or update a resource group. Required. :type parameters: ~azure.mgmt.resource.resources.v2020_10_01.models.ResourceGroup + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: ResourceGroup, or the result of cls(response) + :return: ResourceGroup or the result of cls(response) :rtype: ~azure.mgmt.resource.resources.v2020_10_01.models.ResourceGroup - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + def create_or_update( + self, resource_group_name: str, parameters: IO, *, content_type: str = "application/json", **kwargs: Any + ) -> _models.ResourceGroup: + """Creates or updates a resource group. + + :param resource_group_name: The name of the resource group to create or update. Can include + alphanumeric, underscore, parentheses, hyphen, period (except at end), and Unicode characters + that match the allowed characters. Required. + :type resource_group_name: str + :param parameters: Parameters supplied to the create or update a resource group. Required. + :type parameters: IO + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: ResourceGroup or the result of cls(response) + :rtype: ~azure.mgmt.resource.resources.v2020_10_01.models.ResourceGroup + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace + def create_or_update( + self, resource_group_name: str, parameters: Union[_models.ResourceGroup, IO], **kwargs: Any + ) -> _models.ResourceGroup: + """Creates or updates a resource group. + + :param resource_group_name: The name of the resource group to create or update. Can include + alphanumeric, underscore, parentheses, hyphen, period (except at end), and Unicode characters + that match the allowed characters. Required. + :type resource_group_name: str + :param parameters: Parameters supplied to the create or update a resource group. Is either a + model type or a IO type. Required. + :type parameters: ~azure.mgmt.resource.resources.v2020_10_01.models.ResourceGroup or IO + :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. + Default value is None. + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: ResourceGroup or the result of cls(response) + :rtype: ~azure.mgmt.resource.resources.v2020_10_01.models.ResourceGroup + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.ResourceGroup"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) - api_version = kwargs.pop('api_version', "2020-10-01") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - _json = self._serialize.body(parameters, 'ResourceGroup') + api_version = kwargs.pop("api_version", _params.pop("api-version", "2020-10-01")) # type: str + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.ResourceGroup] + + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(parameters, (IO, bytes)): + _content = parameters + else: + _json = self._serialize.body(parameters, "ResourceGroup") request = build_resource_groups_create_or_update_request( resource_group_name=resource_group_name, @@ -9690,16 +10926,18 @@ def create_or_update( api_version=api_version, content_type=content_type, json=_json, - template_url=self.create_or_update.metadata['url'], + content=_content, + template_url=self.create_or_update.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200, 201]: @@ -9707,47 +10945,50 @@ def create_or_update( raise HttpResponseError(response=response, error_format=ARMErrorFormat) if response.status_code == 200: - deserialized = self._deserialize('ResourceGroup', pipeline_response) + deserialized = self._deserialize("ResourceGroup", pipeline_response) if response.status_code == 201: - deserialized = self._deserialize('ResourceGroup', pipeline_response) + deserialized = self._deserialize("ResourceGroup", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - create_or_update.metadata = {'url': "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}"} # type: ignore - + create_or_update.metadata = {"url": "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}"} # type: ignore def _delete_initial( # pylint: disable=inconsistent-return-statements - self, - resource_group_name: str, - **kwargs: Any + self, resource_group_name: str, **kwargs: Any ) -> None: - cls = kwargs.pop('cls', None) # type: ClsType[None] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) - api_version = kwargs.pop('api_version', "2020-10-01") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - request = build_resource_groups_delete_request_initial( + api_version = kwargs.pop("api_version", _params.pop("api-version", "2020-10-01")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[None] + + request = build_resource_groups_delete_request( resource_group_name=resource_group_name, subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self._delete_initial.metadata['url'], + template_url=self._delete_initial.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200, 202]: @@ -9757,22 +10998,17 @@ def _delete_initial( # pylint: disable=inconsistent-return-statements if cls: return cls(pipeline_response, None, {}) - _delete_initial.metadata = {'url': "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}"} # type: ignore - + _delete_initial.metadata = {"url": "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}"} # type: ignore @distributed_trace - def begin_delete( # pylint: disable=inconsistent-return-statements - self, - resource_group_name: str, - **kwargs: Any - ) -> LROPoller[None]: + def begin_delete(self, resource_group_name: str, **kwargs: Any) -> LROPoller[None]: """Deletes a resource group. When you delete a resource group, all of its resources are also deleted. Deleting a resource group deletes all of its template deployments and currently stored operations. :param resource_group_name: The name of the resource group to delete. The name is case - insensitive. + insensitive. Required. :type resource_group_name: str :keyword callable cls: A custom type or function that will be passed the direct response :keyword str continuation_token: A continuation token to restart a poller from a saved state. @@ -9784,106 +11020,113 @@ def begin_delete( # pylint: disable=inconsistent-return-statements Retry-After header is present. :return: An instance of LROPoller that returns either None or the result of cls(response) :rtype: ~azure.core.polling.LROPoller[None] - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - api_version = kwargs.pop('api_version', "2020-10-01") # type: str - polling = kwargs.pop('polling', True) # type: Union[bool, PollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType[None] - lro_delay = kwargs.pop( - 'polling_interval', - self._config.polling_interval - ) - cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2020-10-01")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[None] + polling = kwargs.pop("polling", True) # type: Union[bool, PollingMethod] + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token = kwargs.pop("continuation_token", None) # type: Optional[str] if cont_token is None: - raw_result = self._delete_initial( + raw_result = self._delete_initial( # type: ignore resource_group_name=resource_group_name, api_version=api_version, - cls=lambda x,y,z: x, + cls=lambda x, y, z: x, + headers=_headers, + params=_params, **kwargs ) - kwargs.pop('error_map', None) + kwargs.pop("error_map", None) - def get_long_running_output(pipeline_response): + def get_long_running_output(pipeline_response): # pylint: disable=inconsistent-return-statements if cls: return cls(pipeline_response, None, {}) - - if polling is True: polling_method = ARMPolling(lro_delay, **kwargs) - elif polling is False: polling_method = NoPolling() - else: polling_method = polling + if polling is True: + polling_method = cast(PollingMethod, ARMPolling(lro_delay, **kwargs)) # type: PollingMethod + elif polling is False: + polling_method = cast(PollingMethod, NoPolling()) + else: + polling_method = polling if cont_token: return LROPoller.from_continuation_token( polling_method=polling_method, continuation_token=cont_token, client=self._client, - deserialization_callback=get_long_running_output + deserialization_callback=get_long_running_output, ) return LROPoller(self._client, raw_result, get_long_running_output, polling_method) - begin_delete.metadata = {'url': "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}"} # type: ignore + begin_delete.metadata = {"url": "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}"} # type: ignore @distributed_trace - def get( - self, - resource_group_name: str, - **kwargs: Any - ) -> "_models.ResourceGroup": + def get(self, resource_group_name: str, **kwargs: Any) -> _models.ResourceGroup: """Gets a resource group. :param resource_group_name: The name of the resource group to get. The name is case - insensitive. + insensitive. Required. :type resource_group_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: ResourceGroup, or the result of cls(response) + :return: ResourceGroup or the result of cls(response) :rtype: ~azure.mgmt.resource.resources.v2020_10_01.models.ResourceGroup - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.ResourceGroup"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + 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', "2020-10-01") # type: str + api_version = kwargs.pop("api_version", _params.pop("api-version", "2020-10-01")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[_models.ResourceGroup] - request = build_resource_groups_get_request( resource_group_name=resource_group_name, subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.get.metadata['url'], + template_url=self.get.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) - deserialized = self._deserialize('ResourceGroup', pipeline_response) + deserialized = self._deserialize("ResourceGroup", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - get.metadata = {'url': "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}"} # type: ignore - + get.metadata = {"url": "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}"} # type: ignore - @distributed_trace + @overload def update( self, resource_group_name: str, - parameters: "_models.ResourceGroupPatchable", + parameters: _models.ResourceGroupPatchable, + *, + content_type: str = "application/json", **kwargs: Any - ) -> "_models.ResourceGroup": + ) -> _models.ResourceGroup: """Updates a resource group. Resource groups can be updated through a simple PATCH operation to a group address. The format @@ -9891,25 +11134,90 @@ def update( the current value is retained. :param resource_group_name: The name of the resource group to update. The name is case - insensitive. + insensitive. Required. :type resource_group_name: str - :param parameters: Parameters supplied to update a resource group. + :param parameters: Parameters supplied to update a resource group. Required. :type parameters: ~azure.mgmt.resource.resources.v2020_10_01.models.ResourceGroupPatchable + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: ResourceGroup or the result of cls(response) + :rtype: ~azure.mgmt.resource.resources.v2020_10_01.models.ResourceGroup + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + def update( + self, resource_group_name: str, parameters: IO, *, content_type: str = "application/json", **kwargs: Any + ) -> _models.ResourceGroup: + """Updates a resource group. + + Resource groups can be updated through a simple PATCH operation to a group address. The format + of the request is the same as that for creating a resource group. If a field is unspecified, + the current value is retained. + + :param resource_group_name: The name of the resource group to update. The name is case + insensitive. Required. + :type resource_group_name: str + :param parameters: Parameters supplied to update a resource group. Required. + :type parameters: IO + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: ResourceGroup, or the result of cls(response) + :return: ResourceGroup or the result of cls(response) :rtype: ~azure.mgmt.resource.resources.v2020_10_01.models.ResourceGroup - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace + def update( + self, resource_group_name: str, parameters: Union[_models.ResourceGroupPatchable, IO], **kwargs: Any + ) -> _models.ResourceGroup: + """Updates a resource group. + + Resource groups can be updated through a simple PATCH operation to a group address. The format + of the request is the same as that for creating a resource group. If a field is unspecified, + the current value is retained. + + :param resource_group_name: The name of the resource group to update. The name is case + insensitive. Required. + :type resource_group_name: str + :param parameters: Parameters supplied to update a resource group. Is either a model type or a + IO type. Required. + :type parameters: ~azure.mgmt.resource.resources.v2020_10_01.models.ResourceGroupPatchable or + IO + :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. + Default value is None. + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: ResourceGroup or the result of cls(response) + :rtype: ~azure.mgmt.resource.resources.v2020_10_01.models.ResourceGroup + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.ResourceGroup"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', "2020-10-01") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + api_version = kwargs.pop("api_version", _params.pop("api-version", "2020-10-01")) # type: str + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.ResourceGroup] - _json = self._serialize.body(parameters, 'ResourceGroupPatchable') + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(parameters, (IO, bytes)): + _content = parameters + else: + _json = self._serialize.body(parameters, "ResourceGroupPatchable") request = build_resource_groups_update_request( resource_group_name=resource_group_name, @@ -9917,65 +11225,77 @@ def update( api_version=api_version, content_type=content_type, json=_json, - template_url=self.update.metadata['url'], + content=_content, + template_url=self.update.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) - deserialized = self._deserialize('ResourceGroup', pipeline_response) + deserialized = self._deserialize("ResourceGroup", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - update.metadata = {'url': "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}"} # type: ignore - + update.metadata = {"url": "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}"} # type: ignore def _export_template_initial( - self, - resource_group_name: str, - parameters: "_models.ExportTemplateRequest", - **kwargs: Any - ) -> Optional["_models.ResourceGroupExportResult"]: - cls = kwargs.pop('cls', None) # type: ClsType[Optional["_models.ResourceGroupExportResult"]] + self, resource_group_name: str, parameters: Union[_models.ExportTemplateRequest, IO], **kwargs: Any + ) -> Optional[_models.ResourceGroupExportResult]: error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) - api_version = kwargs.pop('api_version', "2020-10-01") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - _json = self._serialize.body(parameters, 'ExportTemplateRequest') + api_version = kwargs.pop("api_version", _params.pop("api-version", "2020-10-01")) # type: str + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[Optional[_models.ResourceGroupExportResult]] - request = build_resource_groups_export_template_request_initial( - subscription_id=self._config.subscription_id, + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(parameters, (IO, bytes)): + _content = parameters + else: + _json = self._serialize.body(parameters, "ExportTemplateRequest") + + request = build_resource_groups_export_template_request( resource_group_name=resource_group_name, + subscription_id=self._config.subscription_id, api_version=api_version, content_type=content_type, json=_json, - template_url=self._export_template_initial.metadata['url'], + content=_content, + template_url=self._export_template_initial.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200, 202]: @@ -9984,29 +11304,93 @@ def _export_template_initial( deserialized = None if response.status_code == 200: - deserialized = self._deserialize('ResourceGroupExportResult', pipeline_response) + deserialized = self._deserialize("ResourceGroupExportResult", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - _export_template_initial.metadata = {'url': "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/exportTemplate"} # type: ignore + _export_template_initial.metadata = {"url": "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/exportTemplate"} # type: ignore + @overload + def begin_export_template( + self, + resource_group_name: str, + parameters: _models.ExportTemplateRequest, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> LROPoller[_models.ResourceGroupExportResult]: + """Captures the specified resource group as a template. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param parameters: Parameters for exporting the template. Required. + :type parameters: ~azure.mgmt.resource.resources.v2020_10_01.models.ExportTemplateRequest + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be ARMPolling. Pass in False for this + operation to not poll, or pass in your own initialized polling object for a personal polling + strategy. + :paramtype polling: bool or ~azure.core.polling.PollingMethod + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of LROPoller that returns either ResourceGroupExportResult or the result + of cls(response) + :rtype: + ~azure.core.polling.LROPoller[~azure.mgmt.resource.resources.v2020_10_01.models.ResourceGroupExportResult] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + def begin_export_template( + self, resource_group_name: str, parameters: IO, *, content_type: str = "application/json", **kwargs: Any + ) -> LROPoller[_models.ResourceGroupExportResult]: + """Captures the specified resource group as a template. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param parameters: Parameters for exporting the template. Required. + :type parameters: IO + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be ARMPolling. Pass in False for this + operation to not poll, or pass in your own initialized polling object for a personal polling + strategy. + :paramtype polling: bool or ~azure.core.polling.PollingMethod + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of LROPoller that returns either ResourceGroupExportResult or the result + of cls(response) + :rtype: + ~azure.core.polling.LROPoller[~azure.mgmt.resource.resources.v2020_10_01.models.ResourceGroupExportResult] + :raises ~azure.core.exceptions.HttpResponseError: + """ @distributed_trace def begin_export_template( - self, - resource_group_name: str, - parameters: "_models.ExportTemplateRequest", - **kwargs: Any - ) -> LROPoller["_models.ResourceGroupExportResult"]: + self, resource_group_name: str, parameters: Union[_models.ExportTemplateRequest, IO], **kwargs: Any + ) -> LROPoller[_models.ResourceGroupExportResult]: """Captures the specified resource group as a template. :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. :type resource_group_name: str - :param parameters: Parameters for exporting the template. - :type parameters: ~azure.mgmt.resource.resources.v2020_10_01.models.ExportTemplateRequest + :param parameters: Parameters for exporting the template. Is either a model type or a IO type. + Required. + :type parameters: ~azure.mgmt.resource.resources.v2020_10_01.models.ExportTemplateRequest or IO + :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. + Default value is None. + :paramtype content_type: str :keyword callable cls: A custom type or function that will be passed the direct response :keyword str continuation_token: A continuation token to restart a poller from a saved state. :keyword polling: By default, your polling method will be ARMPolling. Pass in False for this @@ -10019,57 +11403,59 @@ def begin_export_template( of cls(response) :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.resource.resources.v2020_10_01.models.ResourceGroupExportResult] - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - api_version = kwargs.pop('api_version', "2020-10-01") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] - polling = kwargs.pop('polling', True) # type: Union[bool, PollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType["_models.ResourceGroupExportResult"] - lro_delay = kwargs.pop( - 'polling_interval', - self._config.polling_interval - ) - cont_token = kwargs.pop('continuation_token', None) # type: Optional[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", "2020-10-01")) # type: str + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.ResourceGroupExportResult] + polling = kwargs.pop("polling", True) # type: Union[bool, PollingMethod] + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token = kwargs.pop("continuation_token", None) # type: Optional[str] if cont_token is None: - raw_result = self._export_template_initial( + raw_result = self._export_template_initial( # type: ignore resource_group_name=resource_group_name, parameters=parameters, api_version=api_version, content_type=content_type, - cls=lambda x,y,z: x, + cls=lambda x, y, z: x, + headers=_headers, + params=_params, **kwargs ) - kwargs.pop('error_map', None) + kwargs.pop("error_map", None) def get_long_running_output(pipeline_response): - response = pipeline_response.http_response - deserialized = self._deserialize('ResourceGroupExportResult', pipeline_response) + deserialized = self._deserialize("ResourceGroupExportResult", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - - if polling is True: polling_method = ARMPolling(lro_delay, lro_options={'final-state-via': 'location'}, **kwargs) - elif polling is False: polling_method = NoPolling() - else: polling_method = polling + if polling is True: + polling_method = cast( + PollingMethod, ARMPolling(lro_delay, lro_options={"final-state-via": "location"}, **kwargs) + ) # type: PollingMethod + elif polling is False: + polling_method = cast(PollingMethod, NoPolling()) + else: + polling_method = polling if cont_token: return LROPoller.from_continuation_token( polling_method=polling_method, continuation_token=cont_token, client=self._client, - deserialization_callback=get_long_running_output + deserialization_callback=get_long_running_output, ) return LROPoller(self._client, raw_result, get_long_running_output, polling_method) - begin_export_template.metadata = {'url': "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/exportTemplate"} # type: ignore + begin_export_template.metadata = {"url": "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/exportTemplate"} # type: ignore @distributed_trace def list( - self, - filter: Optional[str] = None, - top: Optional[int] = None, - **kwargs: Any - ) -> Iterable["_models.ResourceGroupListResult"]: + self, filter: Optional[str] = None, top: Optional[int] = None, **kwargs: Any + ) -> Iterable["_models.ResourceGroup"]: """Gets all the resource groups for a subscription. :param filter: The filter to apply on the operation.:code:`
`:code:`
`You can filter by @@ -10080,40 +11466,48 @@ def list( Default value is None. :type top: int :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either ResourceGroupListResult or the result of - cls(response) + :return: An iterator like instance of either ResourceGroup or the result of cls(response) :rtype: - ~azure.core.paging.ItemPaged[~azure.mgmt.resource.resources.v2020_10_01.models.ResourceGroupListResult] - :raises: ~azure.core.exceptions.HttpResponseError + ~azure.core.paging.ItemPaged[~azure.mgmt.resource.resources.v2020_10_01.models.ResourceGroup] + :raises ~azure.core.exceptions.HttpResponseError: """ - api_version = kwargs.pop('api_version', "2020-10-01") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2020-10-01")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[_models.ResourceGroupListResult] - cls = kwargs.pop('cls', None) # type: ClsType["_models.ResourceGroupListResult"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) + def prepare_request(next_link=None): if not next_link: - + request = build_resource_groups_list_request( subscription_id=self._config.subscription_id, - api_version=api_version, filter=filter, top=top, - template_url=self.list.metadata['url'], + 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.url = self._client.format_url(request.url) # type: ignore else: - - request = build_resource_groups_list_request( - subscription_id=self._config.subscription_id, - template_url=next_link, - ) + # make call to next link with the client's api-version + _parsed_next_link = urlparse(next_link) + _next_request_params = case_insensitive_dict(parse_qs(_parsed_next_link.query)) + _next_request_params["api-version"] = self._config.api_version + request = HttpRequest("GET", urljoin(next_link, _parsed_next_link.path), params=_next_request_params) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore request.method = "GET" return request @@ -10127,10 +11521,8 @@ def extract_data(pipeline_response): def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) response = pipeline_response.http_response @@ -10140,39 +11532,33 @@ def get_next(next_link=None): return pipeline_response + return ItemPaged(get_next, extract_data) - return ItemPaged( - get_next, extract_data - ) - list.metadata = {'url': "/subscriptions/{subscriptionId}/resourcegroups"} # type: ignore -class TagsOperations(object): - """TagsOperations operations. + list.metadata = {"url": "/subscriptions/{subscriptionId}/resourcegroups"} # type: ignore - You should not instantiate this class directly. Instead, you should create a Client instance that - instantiates it for you and attaches it as an attribute. - :ivar models: Alias to model classes used in this operation group. - :type models: ~azure.mgmt.resource.resources.v2020_10_01.models - :param client: Client for service requests. - :param config: Configuration of service client. - :param serializer: An object model serializer. - :param deserializer: An object model deserializer. +class TagsOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. + + Instead, you should access the following operations through + :class:`~azure.mgmt.resource.resources.v2020_10_01.ResourceManagementClient`'s + :attr:`tags` attribute. """ models = _models - def __init__(self, client, config, serializer, deserializer): - self._client = client - self._serialize = serializer - self._deserialize = deserializer - self._config = config + def __init__(self, *args, **kwargs): + input_args = list(args) + self._client = input_args.pop(0) if input_args else kwargs.pop("client") + self._config = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") @distributed_trace def delete_value( # pylint: disable=inconsistent-return-statements - self, - tag_name: str, - tag_value: str, - **kwargs: Any + self, tag_name: str, tag_value: str, **kwargs: Any ) -> None: """Deletes a predefined tag value for a predefined tag name. @@ -10180,39 +11566,45 @@ def delete_value( # pylint: disable=inconsistent-return-statements predefined tag name. The value being deleted must not be in use as a tag value for the given tag name for any resource. - :param tag_name: The name of the tag. + :param tag_name: The name of the tag. Required. :type tag_name: str - :param tag_value: The value of the tag to delete. + :param tag_value: The value of the tag to delete. Required. :type tag_value: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: None, or the result of cls(response) + :return: None or the result of cls(response) :rtype: None - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType[None] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) - api_version = kwargs.pop('api_version', "2020-10-01") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2020-10-01")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[None] - request = build_tags_delete_value_request( tag_name=tag_name, tag_value=tag_value, subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.delete_value.metadata['url'], + template_url=self.delete_value.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200, 204]: @@ -10222,54 +11614,54 @@ def delete_value( # pylint: disable=inconsistent-return-statements if cls: return cls(pipeline_response, None, {}) - delete_value.metadata = {'url': "/subscriptions/{subscriptionId}/tagNames/{tagName}/tagValues/{tagValue}"} # type: ignore - + delete_value.metadata = {"url": "/subscriptions/{subscriptionId}/tagNames/{tagName}/tagValues/{tagValue}"} # type: ignore @distributed_trace - def create_or_update_value( - self, - tag_name: str, - tag_value: str, - **kwargs: Any - ) -> "_models.TagValue": + def create_or_update_value(self, tag_name: str, tag_value: str, **kwargs: Any) -> _models.TagValue: """Creates a predefined value for a predefined tag name. This operation allows adding a value to the list of predefined values for an existing predefined tag name. A tag value can have a maximum of 256 characters. - :param tag_name: The name of the tag. + :param tag_name: The name of the tag. Required. :type tag_name: str - :param tag_value: The value of the tag to create. + :param tag_value: The value of the tag to create. Required. :type tag_value: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: TagValue, or the result of cls(response) + :return: TagValue or the result of cls(response) :rtype: ~azure.mgmt.resource.resources.v2020_10_01.models.TagValue - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.TagValue"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + 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', "2020-10-01") # type: str + api_version = kwargs.pop("api_version", _params.pop("api-version", "2020-10-01")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[_models.TagValue] - request = build_tags_create_or_update_value_request( tag_name=tag_name, tag_value=tag_value, subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.create_or_update_value.metadata['url'], + template_url=self.create_or_update_value.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200, 201]: @@ -10277,25 +11669,20 @@ def create_or_update_value( raise HttpResponseError(response=response, error_format=ARMErrorFormat) if response.status_code == 200: - deserialized = self._deserialize('TagValue', pipeline_response) + deserialized = self._deserialize("TagValue", pipeline_response) if response.status_code == 201: - deserialized = self._deserialize('TagValue', pipeline_response) + deserialized = self._deserialize("TagValue", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - create_or_update_value.metadata = {'url': "/subscriptions/{subscriptionId}/tagNames/{tagName}/tagValues/{tagValue}"} # type: ignore - + create_or_update_value.metadata = {"url": "/subscriptions/{subscriptionId}/tagNames/{tagName}/tagValues/{tagValue}"} # type: ignore @distributed_trace - def create_or_update( - self, - tag_name: str, - **kwargs: Any - ) -> "_models.TagDetails": + def create_or_update(self, tag_name: str, **kwargs: Any) -> _models.TagDetails: """Creates a predefined tag name. This operation allows adding a name to the list of predefined tag names for the given @@ -10303,36 +11690,42 @@ def create_or_update( names cannot have the following prefixes which are reserved for Azure use: 'microsoft', 'azure', 'windows'. - :param tag_name: The name of the tag to create. + :param tag_name: The name of the tag to create. Required. :type tag_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: TagDetails, or the result of cls(response) + :return: TagDetails or the result of cls(response) :rtype: ~azure.mgmt.resource.resources.v2020_10_01.models.TagDetails - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.TagDetails"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + 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', "2020-10-01") # type: str + api_version = kwargs.pop("api_version", _params.pop("api-version", "2020-10-01")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[_models.TagDetails] - request = build_tags_create_or_update_request( tag_name=tag_name, subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.create_or_update.metadata['url'], + template_url=self.create_or_update.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200, 201]: @@ -10340,61 +11733,62 @@ def create_or_update( raise HttpResponseError(response=response, error_format=ARMErrorFormat) if response.status_code == 200: - deserialized = self._deserialize('TagDetails', pipeline_response) + deserialized = self._deserialize("TagDetails", pipeline_response) if response.status_code == 201: - deserialized = self._deserialize('TagDetails', pipeline_response) + deserialized = self._deserialize("TagDetails", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - create_or_update.metadata = {'url': "/subscriptions/{subscriptionId}/tagNames/{tagName}"} # type: ignore - + create_or_update.metadata = {"url": "/subscriptions/{subscriptionId}/tagNames/{tagName}"} # type: ignore @distributed_trace - def delete( # pylint: disable=inconsistent-return-statements - self, - tag_name: str, - **kwargs: Any - ) -> None: + def delete(self, tag_name: str, **kwargs: Any) -> None: # pylint: disable=inconsistent-return-statements """Deletes a predefined tag name. This operation allows deleting a name from the list of predefined tag names for the given subscription. The name being deleted must not be in use as a tag name for any resource. All predefined values for the given name must have already been deleted. - :param tag_name: The name of the tag. + :param tag_name: The name of the tag. Required. :type tag_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: None, or the result of cls(response) + :return: None or the result of cls(response) :rtype: None - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType[None] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + 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', "2020-10-01") # type: str + api_version = kwargs.pop("api_version", _params.pop("api-version", "2020-10-01")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[None] - request = build_tags_delete_request( tag_name=tag_name, subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.delete.metadata['url'], + template_url=self.delete.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200, 204]: @@ -10404,14 +11798,10 @@ def delete( # pylint: disable=inconsistent-return-statements if cls: return cls(pipeline_response, None, {}) - delete.metadata = {'url': "/subscriptions/{subscriptionId}/tagNames/{tagName}"} # type: ignore - + delete.metadata = {"url": "/subscriptions/{subscriptionId}/tagNames/{tagName}"} # type: ignore @distributed_trace - def list( - self, - **kwargs: Any - ) -> Iterable["_models.TagsListResult"]: + def list(self, **kwargs: Any) -> Iterable["_models.TagDetails"]: """Gets a summary of tag usage under the subscription. This operation performs a union of predefined tags, resource tags, resource group tags and @@ -10420,37 +11810,46 @@ def list( result. :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either TagsListResult or the result of cls(response) + :return: An iterator like instance of either TagDetails or the result of cls(response) :rtype: - ~azure.core.paging.ItemPaged[~azure.mgmt.resource.resources.v2020_10_01.models.TagsListResult] - :raises: ~azure.core.exceptions.HttpResponseError + ~azure.core.paging.ItemPaged[~azure.mgmt.resource.resources.v2020_10_01.models.TagDetails] + :raises ~azure.core.exceptions.HttpResponseError: """ - api_version = kwargs.pop('api_version', "2020-10-01") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2020-10-01")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[_models.TagsListResult] - cls = kwargs.pop('cls', None) # type: ClsType["_models.TagsListResult"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) + def prepare_request(next_link=None): if not next_link: - + request = build_tags_list_request( subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.list.metadata['url'], + template_url=self.list.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore else: - - request = build_tags_list_request( - subscription_id=self._config.subscription_id, - template_url=next_link, - ) + # make call to next link with the client's api-version + _parsed_next_link = urlparse(next_link) + _next_request_params = case_insensitive_dict(parse_qs(_parsed_next_link.query)) + _next_request_params["api-version"] = self._config.api_version + request = HttpRequest("GET", urljoin(next_link, _parsed_next_link.path), params=_next_request_params) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore request.method = "GET" return request @@ -10464,10 +11863,8 @@ def extract_data(pipeline_response): def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) response = pipeline_response.http_response @@ -10477,82 +11874,139 @@ def get_next(next_link=None): return pipeline_response + return ItemPaged(get_next, extract_data) - return ItemPaged( - get_next, extract_data - ) - list.metadata = {'url': "/subscriptions/{subscriptionId}/tagNames"} # type: ignore + list.metadata = {"url": "/subscriptions/{subscriptionId}/tagNames"} # type: ignore - @distributed_trace + @overload def create_or_update_at_scope( - self, - scope: str, - parameters: "_models.TagsResource", - **kwargs: Any - ) -> "_models.TagsResource": + self, scope: str, parameters: _models.TagsResource, *, content_type: str = "application/json", **kwargs: Any + ) -> _models.TagsResource: """Creates or updates the entire set of tags on a resource or subscription. This operation allows adding or replacing the entire set of tags on the specified resource or subscription. The specified entity can have a maximum of 50 tags. - :param scope: The resource scope. + :param scope: The resource scope. Required. :type scope: str - :param parameters: + :param parameters: Required. :type parameters: ~azure.mgmt.resource.resources.v2020_10_01.models.TagsResource + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: TagsResource or the result of cls(response) + :rtype: ~azure.mgmt.resource.resources.v2020_10_01.models.TagsResource + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + def create_or_update_at_scope( + self, scope: str, parameters: IO, *, content_type: str = "application/json", **kwargs: Any + ) -> _models.TagsResource: + """Creates or updates the entire set of tags on a resource or subscription. + + This operation allows adding or replacing the entire set of tags on the specified resource or + subscription. The specified entity can have a maximum of 50 tags. + + :param scope: The resource scope. Required. + :type scope: str + :param parameters: Required. + :type parameters: IO + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: TagsResource or the result of cls(response) + :rtype: ~azure.mgmt.resource.resources.v2020_10_01.models.TagsResource + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace + def create_or_update_at_scope( + self, scope: str, parameters: Union[_models.TagsResource, IO], **kwargs: Any + ) -> _models.TagsResource: + """Creates or updates the entire set of tags on a resource or subscription. + + This operation allows adding or replacing the entire set of tags on the specified resource or + subscription. The specified entity can have a maximum of 50 tags. + + :param scope: The resource scope. Required. + :type scope: str + :param parameters: Is either a model type or a IO type. Required. + :type parameters: ~azure.mgmt.resource.resources.v2020_10_01.models.TagsResource or IO + :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. + Default value is None. + :paramtype content_type: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: TagsResource, or the result of cls(response) + :return: TagsResource or the result of cls(response) :rtype: ~azure.mgmt.resource.resources.v2020_10_01.models.TagsResource - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.TagsResource"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', "2020-10-01") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + api_version = kwargs.pop("api_version", _params.pop("api-version", "2020-10-01")) # type: str + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.TagsResource] - _json = self._serialize.body(parameters, 'TagsResource') + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(parameters, (IO, bytes)): + _content = parameters + else: + _json = self._serialize.body(parameters, "TagsResource") request = build_tags_create_or_update_at_scope_request( scope=scope, api_version=api_version, content_type=content_type, json=_json, - template_url=self.create_or_update_at_scope.metadata['url'], + content=_content, + template_url=self.create_or_update_at_scope.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) - deserialized = self._deserialize('TagsResource', pipeline_response) + deserialized = self._deserialize("TagsResource", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - create_or_update_at_scope.metadata = {'url': "/{scope}/providers/Microsoft.Resources/tags/default"} # type: ignore - + create_or_update_at_scope.metadata = {"url": "/{scope}/providers/Microsoft.Resources/tags/default"} # type: ignore - @distributed_trace + @overload def update_at_scope( self, scope: str, - parameters: "_models.TagsPatchResource", + parameters: _models.TagsPatchResource, + *, + content_type: str = "application/json", **kwargs: Any - ) -> "_models.TagsResource": + ) -> _models.TagsResource: """Selectively updates the set of tags on a resource or subscription. This operation allows replacing, merging or selectively deleting tags on the specified resource @@ -10562,151 +12016,222 @@ def update_at_scope( names. The 'delete' option allows selectively deleting tags based on given names or name/value pairs. - :param scope: The resource scope. + :param scope: The resource scope. Required. :type scope: str - :param parameters: + :param parameters: Required. :type parameters: ~azure.mgmt.resource.resources.v2020_10_01.models.TagsPatchResource + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: TagsResource or the result of cls(response) + :rtype: ~azure.mgmt.resource.resources.v2020_10_01.models.TagsResource + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + def update_at_scope( + self, scope: str, parameters: IO, *, content_type: str = "application/json", **kwargs: Any + ) -> _models.TagsResource: + """Selectively updates the set of tags on a resource or subscription. + + This operation allows replacing, merging or selectively deleting tags on the specified resource + or subscription. The specified entity can have a maximum of 50 tags at the end of the + operation. The 'replace' option replaces the entire set of existing tags with a new set. The + 'merge' option allows adding tags with new names and updating the values of tags with existing + names. The 'delete' option allows selectively deleting tags based on given names or name/value + pairs. + + :param scope: The resource scope. Required. + :type scope: str + :param parameters: Required. + :type parameters: IO + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: TagsResource or the result of cls(response) + :rtype: ~azure.mgmt.resource.resources.v2020_10_01.models.TagsResource + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace + def update_at_scope( + self, scope: str, parameters: Union[_models.TagsPatchResource, IO], **kwargs: Any + ) -> _models.TagsResource: + """Selectively updates the set of tags on a resource or subscription. + + This operation allows replacing, merging or selectively deleting tags on the specified resource + or subscription. The specified entity can have a maximum of 50 tags at the end of the + operation. The 'replace' option replaces the entire set of existing tags with a new set. The + 'merge' option allows adding tags with new names and updating the values of tags with existing + names. The 'delete' option allows selectively deleting tags based on given names or name/value + pairs. + + :param scope: The resource scope. Required. + :type scope: str + :param parameters: Is either a model type or a IO type. Required. + :type parameters: ~azure.mgmt.resource.resources.v2020_10_01.models.TagsPatchResource or IO + :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. + Default value is None. + :paramtype content_type: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: TagsResource, or the result of cls(response) + :return: TagsResource or the result of cls(response) :rtype: ~azure.mgmt.resource.resources.v2020_10_01.models.TagsResource - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.TagsResource"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', "2020-10-01") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + api_version = kwargs.pop("api_version", _params.pop("api-version", "2020-10-01")) # type: str + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.TagsResource] - _json = self._serialize.body(parameters, 'TagsPatchResource') + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(parameters, (IO, bytes)): + _content = parameters + else: + _json = self._serialize.body(parameters, "TagsPatchResource") request = build_tags_update_at_scope_request( scope=scope, api_version=api_version, content_type=content_type, json=_json, - template_url=self.update_at_scope.metadata['url'], + content=_content, + template_url=self.update_at_scope.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) - deserialized = self._deserialize('TagsResource', pipeline_response) + deserialized = self._deserialize("TagsResource", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - update_at_scope.metadata = {'url': "/{scope}/providers/Microsoft.Resources/tags/default"} # type: ignore - + update_at_scope.metadata = {"url": "/{scope}/providers/Microsoft.Resources/tags/default"} # type: ignore @distributed_trace - def get_at_scope( - self, - scope: str, - **kwargs: Any - ) -> "_models.TagsResource": + def get_at_scope(self, scope: str, **kwargs: Any) -> _models.TagsResource: """Gets the entire set of tags on a resource or subscription. Gets the entire set of tags on a resource or subscription. - :param scope: The resource scope. + :param scope: The resource scope. Required. :type scope: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: TagsResource, or the result of cls(response) + :return: TagsResource or the result of cls(response) :rtype: ~azure.mgmt.resource.resources.v2020_10_01.models.TagsResource - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.TagsResource"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) - api_version = kwargs.pop('api_version', "2020-10-01") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2020-10-01")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[_models.TagsResource] - request = build_tags_get_at_scope_request( scope=scope, api_version=api_version, - template_url=self.get_at_scope.metadata['url'], + template_url=self.get_at_scope.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) - deserialized = self._deserialize('TagsResource', pipeline_response) + deserialized = self._deserialize("TagsResource", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - get_at_scope.metadata = {'url': "/{scope}/providers/Microsoft.Resources/tags/default"} # type: ignore - + get_at_scope.metadata = {"url": "/{scope}/providers/Microsoft.Resources/tags/default"} # type: ignore @distributed_trace - def delete_at_scope( # pylint: disable=inconsistent-return-statements - self, - scope: str, - **kwargs: Any - ) -> None: + def delete_at_scope(self, scope: str, **kwargs: Any) -> None: # pylint: disable=inconsistent-return-statements """Deletes the entire set of tags on a resource or subscription. Deletes the entire set of tags on a resource or subscription. - :param scope: The resource scope. + :param scope: The resource scope. Required. :type scope: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: None, or the result of cls(response) + :return: None or the result of cls(response) :rtype: None - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType[None] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + 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', "2020-10-01") # type: str + api_version = kwargs.pop("api_version", _params.pop("api-version", "2020-10-01")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[None] - request = build_tags_delete_at_scope_request( scope=scope, api_version=api_version, - template_url=self.delete_at_scope.metadata['url'], + template_url=self.delete_at_scope.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200]: @@ -10716,143 +12241,145 @@ def delete_at_scope( # pylint: disable=inconsistent-return-statements if cls: return cls(pipeline_response, None, {}) - delete_at_scope.metadata = {'url': "/{scope}/providers/Microsoft.Resources/tags/default"} # type: ignore + delete_at_scope.metadata = {"url": "/{scope}/providers/Microsoft.Resources/tags/default"} # type: ignore -class DeploymentOperationsOperations(object): - """DeploymentOperationsOperations operations. - You should not instantiate this class directly. Instead, you should create a Client instance that - instantiates it for you and attaches it as an attribute. +class DeploymentOperationsOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. - :ivar models: Alias to model classes used in this operation group. - :type models: ~azure.mgmt.resource.resources.v2020_10_01.models - :param client: Client for service requests. - :param config: Configuration of service client. - :param serializer: An object model serializer. - :param deserializer: An object model deserializer. + Instead, you should access the following operations through + :class:`~azure.mgmt.resource.resources.v2020_10_01.ResourceManagementClient`'s + :attr:`deployment_operations` attribute. """ models = _models - def __init__(self, client, config, serializer, deserializer): - self._client = client - self._serialize = serializer - self._deserialize = deserializer - self._config = config + def __init__(self, *args, **kwargs): + input_args = list(args) + self._client = input_args.pop(0) if input_args else kwargs.pop("client") + self._config = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") @distributed_trace def get_at_scope( - self, - scope: str, - deployment_name: str, - operation_id: str, - **kwargs: Any - ) -> "_models.DeploymentOperation": + self, scope: str, deployment_name: str, operation_id: str, **kwargs: Any + ) -> _models.DeploymentOperation: """Gets a deployments operation. - :param scope: The resource scope. + :param scope: The resource scope. Required. :type scope: str - :param deployment_name: The name of the deployment. + :param deployment_name: The name of the deployment. Required. :type deployment_name: str - :param operation_id: The ID of the operation to get. + :param operation_id: The ID of the operation to get. Required. :type operation_id: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: DeploymentOperation, or the result of cls(response) + :return: DeploymentOperation or the result of cls(response) :rtype: ~azure.mgmt.resource.resources.v2020_10_01.models.DeploymentOperation - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.DeploymentOperation"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) - api_version = kwargs.pop('api_version', "2020-10-01") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2020-10-01")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[_models.DeploymentOperation] - request = build_deployment_operations_get_at_scope_request( scope=scope, deployment_name=deployment_name, operation_id=operation_id, api_version=api_version, - template_url=self.get_at_scope.metadata['url'], + template_url=self.get_at_scope.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) - deserialized = self._deserialize('DeploymentOperation', pipeline_response) + deserialized = self._deserialize("DeploymentOperation", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - get_at_scope.metadata = {'url': "/{scope}/providers/Microsoft.Resources/deployments/{deploymentName}/operations/{operationId}"} # type: ignore - + get_at_scope.metadata = {"url": "/{scope}/providers/Microsoft.Resources/deployments/{deploymentName}/operations/{operationId}"} # type: ignore @distributed_trace def list_at_scope( - self, - scope: str, - deployment_name: str, - top: Optional[int] = None, - **kwargs: Any - ) -> Iterable["_models.DeploymentOperationsListResult"]: + self, scope: str, deployment_name: str, top: Optional[int] = None, **kwargs: Any + ) -> Iterable["_models.DeploymentOperation"]: """Gets all deployments operations for a deployment. - :param scope: The resource scope. + :param scope: The resource scope. Required. :type scope: str - :param deployment_name: The name of the deployment. + :param deployment_name: The name of the deployment. Required. :type deployment_name: str :param top: The number of results to return. Default value is None. :type top: int :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either DeploymentOperationsListResult or the result of - cls(response) + :return: An iterator like instance of either DeploymentOperation or the result of cls(response) :rtype: - ~azure.core.paging.ItemPaged[~azure.mgmt.resource.resources.v2020_10_01.models.DeploymentOperationsListResult] - :raises: ~azure.core.exceptions.HttpResponseError + ~azure.core.paging.ItemPaged[~azure.mgmt.resource.resources.v2020_10_01.models.DeploymentOperation] + :raises ~azure.core.exceptions.HttpResponseError: """ - api_version = kwargs.pop('api_version', "2020-10-01") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2020-10-01")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[_models.DeploymentOperationsListResult] - cls = kwargs.pop('cls', None) # type: ClsType["_models.DeploymentOperationsListResult"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) + def prepare_request(next_link=None): if not next_link: - + request = build_deployment_operations_list_at_scope_request( scope=scope, deployment_name=deployment_name, - api_version=api_version, top=top, - template_url=self.list_at_scope.metadata['url'], + api_version=api_version, + template_url=self.list_at_scope.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore else: - - request = build_deployment_operations_list_at_scope_request( - scope=scope, - deployment_name=deployment_name, - template_url=next_link, - ) + # make call to next link with the client's api-version + _parsed_next_link = urlparse(next_link) + _next_request_params = case_insensitive_dict(parse_qs(_parsed_next_link.query)) + _next_request_params["api-version"] = self._config.api_version + request = HttpRequest("GET", urljoin(next_link, _parsed_next_link.path), params=_next_request_params) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore request.method = "GET" return request @@ -10866,10 +12393,8 @@ def extract_data(pipeline_response): def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) response = pipeline_response.http_response @@ -10879,116 +12404,121 @@ def get_next(next_link=None): return pipeline_response + return ItemPaged(get_next, extract_data) - return ItemPaged( - get_next, extract_data - ) - list_at_scope.metadata = {'url': "/{scope}/providers/Microsoft.Resources/deployments/{deploymentName}/operations"} # type: ignore + list_at_scope.metadata = {"url": "/{scope}/providers/Microsoft.Resources/deployments/{deploymentName}/operations"} # type: ignore @distributed_trace def get_at_tenant_scope( - self, - deployment_name: str, - operation_id: str, - **kwargs: Any - ) -> "_models.DeploymentOperation": + self, deployment_name: str, operation_id: str, **kwargs: Any + ) -> _models.DeploymentOperation: """Gets a deployments operation. - :param deployment_name: The name of the deployment. + :param deployment_name: The name of the deployment. Required. :type deployment_name: str - :param operation_id: The ID of the operation to get. + :param operation_id: The ID of the operation to get. Required. :type operation_id: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: DeploymentOperation, or the result of cls(response) + :return: DeploymentOperation or the result of cls(response) :rtype: ~azure.mgmt.resource.resources.v2020_10_01.models.DeploymentOperation - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.DeploymentOperation"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + 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', "2020-10-01") # type: str + api_version = kwargs.pop("api_version", _params.pop("api-version", "2020-10-01")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[_models.DeploymentOperation] - request = build_deployment_operations_get_at_tenant_scope_request( deployment_name=deployment_name, operation_id=operation_id, api_version=api_version, - template_url=self.get_at_tenant_scope.metadata['url'], + template_url=self.get_at_tenant_scope.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) - deserialized = self._deserialize('DeploymentOperation', pipeline_response) + deserialized = self._deserialize("DeploymentOperation", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - get_at_tenant_scope.metadata = {'url': "/providers/Microsoft.Resources/deployments/{deploymentName}/operations/{operationId}"} # type: ignore - + get_at_tenant_scope.metadata = {"url": "/providers/Microsoft.Resources/deployments/{deploymentName}/operations/{operationId}"} # type: ignore @distributed_trace def list_at_tenant_scope( - self, - deployment_name: str, - top: Optional[int] = None, - **kwargs: Any - ) -> Iterable["_models.DeploymentOperationsListResult"]: + self, deployment_name: str, top: Optional[int] = None, **kwargs: Any + ) -> Iterable["_models.DeploymentOperation"]: """Gets all deployments operations for a deployment. - :param deployment_name: The name of the deployment. + :param deployment_name: The name of the deployment. Required. :type deployment_name: str :param top: The number of results to return. Default value is None. :type top: int :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either DeploymentOperationsListResult or the result of - cls(response) + :return: An iterator like instance of either DeploymentOperation or the result of cls(response) :rtype: - ~azure.core.paging.ItemPaged[~azure.mgmt.resource.resources.v2020_10_01.models.DeploymentOperationsListResult] - :raises: ~azure.core.exceptions.HttpResponseError + ~azure.core.paging.ItemPaged[~azure.mgmt.resource.resources.v2020_10_01.models.DeploymentOperation] + :raises ~azure.core.exceptions.HttpResponseError: """ - api_version = kwargs.pop('api_version', "2020-10-01") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2020-10-01")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[_models.DeploymentOperationsListResult] - cls = kwargs.pop('cls', None) # type: ClsType["_models.DeploymentOperationsListResult"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) + def prepare_request(next_link=None): if not next_link: - + request = build_deployment_operations_list_at_tenant_scope_request( deployment_name=deployment_name, - api_version=api_version, top=top, - template_url=self.list_at_tenant_scope.metadata['url'], + api_version=api_version, + template_url=self.list_at_tenant_scope.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore else: - - request = build_deployment_operations_list_at_tenant_scope_request( - deployment_name=deployment_name, - template_url=next_link, - ) + # make call to next link with the client's api-version + _parsed_next_link = urlparse(next_link) + _next_request_params = case_insensitive_dict(parse_qs(_parsed_next_link.query)) + _next_request_params["api-version"] = self._config.api_version + request = HttpRequest("GET", urljoin(next_link, _parsed_next_link.path), params=_next_request_params) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore request.method = "GET" return request @@ -11002,10 +12532,8 @@ def extract_data(pipeline_response): def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) response = pipeline_response.http_response @@ -11015,125 +12543,127 @@ def get_next(next_link=None): return pipeline_response + return ItemPaged(get_next, extract_data) - return ItemPaged( - get_next, extract_data - ) - list_at_tenant_scope.metadata = {'url': "/providers/Microsoft.Resources/deployments/{deploymentName}/operations"} # type: ignore + list_at_tenant_scope.metadata = {"url": "/providers/Microsoft.Resources/deployments/{deploymentName}/operations"} # type: ignore @distributed_trace def get_at_management_group_scope( - self, - group_id: str, - deployment_name: str, - operation_id: str, - **kwargs: Any - ) -> "_models.DeploymentOperation": + self, group_id: str, deployment_name: str, operation_id: str, **kwargs: Any + ) -> _models.DeploymentOperation: """Gets a deployments operation. - :param group_id: The management group ID. + :param group_id: The management group ID. Required. :type group_id: str - :param deployment_name: The name of the deployment. + :param deployment_name: The name of the deployment. Required. :type deployment_name: str - :param operation_id: The ID of the operation to get. + :param operation_id: The ID of the operation to get. Required. :type operation_id: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: DeploymentOperation, or the result of cls(response) + :return: DeploymentOperation or the result of cls(response) :rtype: ~azure.mgmt.resource.resources.v2020_10_01.models.DeploymentOperation - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.DeploymentOperation"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + 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', "2020-10-01") # type: str + api_version = kwargs.pop("api_version", _params.pop("api-version", "2020-10-01")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[_models.DeploymentOperation] - request = build_deployment_operations_get_at_management_group_scope_request( group_id=group_id, deployment_name=deployment_name, operation_id=operation_id, api_version=api_version, - template_url=self.get_at_management_group_scope.metadata['url'], + template_url=self.get_at_management_group_scope.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) - deserialized = self._deserialize('DeploymentOperation', pipeline_response) + deserialized = self._deserialize("DeploymentOperation", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - get_at_management_group_scope.metadata = {'url': "/providers/Microsoft.Management/managementGroups/{groupId}/providers/Microsoft.Resources/deployments/{deploymentName}/operations/{operationId}"} # type: ignore - + get_at_management_group_scope.metadata = {"url": "/providers/Microsoft.Management/managementGroups/{groupId}/providers/Microsoft.Resources/deployments/{deploymentName}/operations/{operationId}"} # type: ignore @distributed_trace def list_at_management_group_scope( - self, - group_id: str, - deployment_name: str, - top: Optional[int] = None, - **kwargs: Any - ) -> Iterable["_models.DeploymentOperationsListResult"]: + self, group_id: str, deployment_name: str, top: Optional[int] = None, **kwargs: Any + ) -> Iterable["_models.DeploymentOperation"]: """Gets all deployments operations for a deployment. - :param group_id: The management group ID. + :param group_id: The management group ID. Required. :type group_id: str - :param deployment_name: The name of the deployment. + :param deployment_name: The name of the deployment. Required. :type deployment_name: str :param top: The number of results to return. Default value is None. :type top: int :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either DeploymentOperationsListResult or the result of - cls(response) + :return: An iterator like instance of either DeploymentOperation or the result of cls(response) :rtype: - ~azure.core.paging.ItemPaged[~azure.mgmt.resource.resources.v2020_10_01.models.DeploymentOperationsListResult] - :raises: ~azure.core.exceptions.HttpResponseError + ~azure.core.paging.ItemPaged[~azure.mgmt.resource.resources.v2020_10_01.models.DeploymentOperation] + :raises ~azure.core.exceptions.HttpResponseError: """ - api_version = kwargs.pop('api_version', "2020-10-01") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2020-10-01")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[_models.DeploymentOperationsListResult] - cls = kwargs.pop('cls', None) # type: ClsType["_models.DeploymentOperationsListResult"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) + def prepare_request(next_link=None): if not next_link: - + request = build_deployment_operations_list_at_management_group_scope_request( group_id=group_id, deployment_name=deployment_name, - api_version=api_version, top=top, - template_url=self.list_at_management_group_scope.metadata['url'], + api_version=api_version, + template_url=self.list_at_management_group_scope.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore else: - - request = build_deployment_operations_list_at_management_group_scope_request( - group_id=group_id, - deployment_name=deployment_name, - template_url=next_link, - ) + # make call to next link with the client's api-version + _parsed_next_link = urlparse(next_link) + _next_request_params = case_insensitive_dict(parse_qs(_parsed_next_link.query)) + _next_request_params["api-version"] = self._config.api_version + request = HttpRequest("GET", urljoin(next_link, _parsed_next_link.path), params=_next_request_params) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore request.method = "GET" return request @@ -11147,10 +12677,8 @@ def extract_data(pipeline_response): def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) response = pipeline_response.http_response @@ -11160,119 +12688,123 @@ def get_next(next_link=None): return pipeline_response + return ItemPaged(get_next, extract_data) - return ItemPaged( - get_next, extract_data - ) - list_at_management_group_scope.metadata = {'url': "/providers/Microsoft.Management/managementGroups/{groupId}/providers/Microsoft.Resources/deployments/{deploymentName}/operations"} # type: ignore + list_at_management_group_scope.metadata = {"url": "/providers/Microsoft.Management/managementGroups/{groupId}/providers/Microsoft.Resources/deployments/{deploymentName}/operations"} # type: ignore @distributed_trace def get_at_subscription_scope( - self, - deployment_name: str, - operation_id: str, - **kwargs: Any - ) -> "_models.DeploymentOperation": + self, deployment_name: str, operation_id: str, **kwargs: Any + ) -> _models.DeploymentOperation: """Gets a deployments operation. - :param deployment_name: The name of the deployment. + :param deployment_name: The name of the deployment. Required. :type deployment_name: str - :param operation_id: The ID of the operation to get. + :param operation_id: The ID of the operation to get. Required. :type operation_id: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: DeploymentOperation, or the result of cls(response) + :return: DeploymentOperation or the result of cls(response) :rtype: ~azure.mgmt.resource.resources.v2020_10_01.models.DeploymentOperation - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.DeploymentOperation"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) - api_version = kwargs.pop('api_version', "2020-10-01") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2020-10-01")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[_models.DeploymentOperation] - request = build_deployment_operations_get_at_subscription_scope_request( deployment_name=deployment_name, operation_id=operation_id, subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.get_at_subscription_scope.metadata['url'], + template_url=self.get_at_subscription_scope.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) - deserialized = self._deserialize('DeploymentOperation', pipeline_response) + deserialized = self._deserialize("DeploymentOperation", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - get_at_subscription_scope.metadata = {'url': "/subscriptions/{subscriptionId}/providers/Microsoft.Resources/deployments/{deploymentName}/operations/{operationId}"} # type: ignore - + get_at_subscription_scope.metadata = {"url": "/subscriptions/{subscriptionId}/providers/Microsoft.Resources/deployments/{deploymentName}/operations/{operationId}"} # type: ignore @distributed_trace def list_at_subscription_scope( - self, - deployment_name: str, - top: Optional[int] = None, - **kwargs: Any - ) -> Iterable["_models.DeploymentOperationsListResult"]: + self, deployment_name: str, top: Optional[int] = None, **kwargs: Any + ) -> Iterable["_models.DeploymentOperation"]: """Gets all deployments operations for a deployment. - :param deployment_name: The name of the deployment. + :param deployment_name: The name of the deployment. Required. :type deployment_name: str :param top: The number of results to return. Default value is None. :type top: int :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either DeploymentOperationsListResult or the result of - cls(response) + :return: An iterator like instance of either DeploymentOperation or the result of cls(response) :rtype: - ~azure.core.paging.ItemPaged[~azure.mgmt.resource.resources.v2020_10_01.models.DeploymentOperationsListResult] - :raises: ~azure.core.exceptions.HttpResponseError + ~azure.core.paging.ItemPaged[~azure.mgmt.resource.resources.v2020_10_01.models.DeploymentOperation] + :raises ~azure.core.exceptions.HttpResponseError: """ - api_version = kwargs.pop('api_version', "2020-10-01") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2020-10-01")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[_models.DeploymentOperationsListResult] - cls = kwargs.pop('cls', None) # type: ClsType["_models.DeploymentOperationsListResult"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) + def prepare_request(next_link=None): if not next_link: - + request = build_deployment_operations_list_at_subscription_scope_request( deployment_name=deployment_name, subscription_id=self._config.subscription_id, - api_version=api_version, top=top, - template_url=self.list_at_subscription_scope.metadata['url'], + api_version=api_version, + template_url=self.list_at_subscription_scope.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore else: - - request = build_deployment_operations_list_at_subscription_scope_request( - deployment_name=deployment_name, - subscription_id=self._config.subscription_id, - template_url=next_link, - ) + # make call to next link with the client's api-version + _parsed_next_link = urlparse(next_link) + _next_request_params = case_insensitive_dict(parse_qs(_parsed_next_link.query)) + _next_request_params["api-version"] = self._config.api_version + request = HttpRequest("GET", urljoin(next_link, _parsed_next_link.path), params=_next_request_params) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore request.method = "GET" return request @@ -11286,10 +12818,8 @@ def extract_data(pipeline_response): def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) response = pipeline_response.http_response @@ -11299,128 +12829,131 @@ def get_next(next_link=None): return pipeline_response + return ItemPaged(get_next, extract_data) - return ItemPaged( - get_next, extract_data - ) - list_at_subscription_scope.metadata = {'url': "/subscriptions/{subscriptionId}/providers/Microsoft.Resources/deployments/{deploymentName}/operations"} # type: ignore + list_at_subscription_scope.metadata = {"url": "/subscriptions/{subscriptionId}/providers/Microsoft.Resources/deployments/{deploymentName}/operations"} # type: ignore @distributed_trace def get( - self, - resource_group_name: str, - deployment_name: str, - operation_id: str, - **kwargs: Any - ) -> "_models.DeploymentOperation": + self, resource_group_name: str, deployment_name: str, operation_id: str, **kwargs: Any + ) -> _models.DeploymentOperation: """Gets a deployments operation. :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. :type resource_group_name: str - :param deployment_name: The name of the deployment. + :param deployment_name: The name of the deployment. Required. :type deployment_name: str - :param operation_id: The ID of the operation to get. + :param operation_id: The ID of the operation to get. Required. :type operation_id: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: DeploymentOperation, or the result of cls(response) + :return: DeploymentOperation or the result of cls(response) :rtype: ~azure.mgmt.resource.resources.v2020_10_01.models.DeploymentOperation - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.DeploymentOperation"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + 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', "2020-10-01") # type: str + api_version = kwargs.pop("api_version", _params.pop("api-version", "2020-10-01")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[_models.DeploymentOperation] - request = build_deployment_operations_get_request( resource_group_name=resource_group_name, deployment_name=deployment_name, operation_id=operation_id, subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.get.metadata['url'], + template_url=self.get.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) - deserialized = self._deserialize('DeploymentOperation', pipeline_response) + deserialized = self._deserialize("DeploymentOperation", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - get.metadata = {'url': "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/deployments/{deploymentName}/operations/{operationId}"} # type: ignore - + get.metadata = {"url": "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/deployments/{deploymentName}/operations/{operationId}"} # type: ignore @distributed_trace def list( - self, - resource_group_name: str, - deployment_name: str, - top: Optional[int] = None, - **kwargs: Any - ) -> Iterable["_models.DeploymentOperationsListResult"]: + self, resource_group_name: str, deployment_name: str, top: Optional[int] = None, **kwargs: Any + ) -> Iterable["_models.DeploymentOperation"]: """Gets all deployments operations for a deployment. :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. :type resource_group_name: str - :param deployment_name: The name of the deployment. + :param deployment_name: The name of the deployment. Required. :type deployment_name: str :param top: The number of results to return. Default value is None. :type top: int :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either DeploymentOperationsListResult or the result of - cls(response) + :return: An iterator like instance of either DeploymentOperation or the result of cls(response) :rtype: - ~azure.core.paging.ItemPaged[~azure.mgmt.resource.resources.v2020_10_01.models.DeploymentOperationsListResult] - :raises: ~azure.core.exceptions.HttpResponseError + ~azure.core.paging.ItemPaged[~azure.mgmt.resource.resources.v2020_10_01.models.DeploymentOperation] + :raises ~azure.core.exceptions.HttpResponseError: """ - api_version = kwargs.pop('api_version', "2020-10-01") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2020-10-01")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[_models.DeploymentOperationsListResult] - cls = kwargs.pop('cls', None) # type: ClsType["_models.DeploymentOperationsListResult"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) + def prepare_request(next_link=None): if not next_link: - + request = build_deployment_operations_list_request( resource_group_name=resource_group_name, deployment_name=deployment_name, subscription_id=self._config.subscription_id, - api_version=api_version, top=top, - template_url=self.list.metadata['url'], + 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.url = self._client.format_url(request.url) # type: ignore else: - - request = build_deployment_operations_list_request( - resource_group_name=resource_group_name, - deployment_name=deployment_name, - subscription_id=self._config.subscription_id, - template_url=next_link, - ) + # make call to next link with the client's api-version + _parsed_next_link = urlparse(next_link) + _next_request_params = case_insensitive_dict(parse_qs(_parsed_next_link.query)) + _next_request_params["api-version"] = self._config.api_version + request = HttpRequest("GET", urljoin(next_link, _parsed_next_link.path), params=_next_request_params) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore request.method = "GET" return request @@ -11434,10 +12967,8 @@ def extract_data(pipeline_response): def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) response = pipeline_response.http_response @@ -11447,8 +12978,6 @@ def get_next(next_link=None): return pipeline_response + return ItemPaged(get_next, extract_data) - return ItemPaged( - get_next, extract_data - ) - list.metadata = {'url': "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/deployments/{deploymentName}/operations"} # type: ignore + list.metadata = {"url": "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/deployments/{deploymentName}/operations"} # type: ignore diff --git a/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/resources/v2020_10_01/operations/_patch.py b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/resources/v2020_10_01/operations/_patch.py new file mode 100644 index 0000000000000..f7dd32510333d --- /dev/null +++ b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/resources/v2020_10_01/operations/_patch.py @@ -0,0 +1,20 @@ +# ------------------------------------ +# Copyright (c) Microsoft Corporation. +# Licensed under the MIT License. +# ------------------------------------ +"""Customize generated code here. + +Follow our quickstart for examples: https://aka.ms/azsdk/python/dpcodegen/python/customize +""" +from typing import List + +__all__: List[str] = [] # Add all objects you want publicly available to users at this package level + + +def patch_sdk(): + """Do not remove from this file. + + `patch_sdk` is a last resort escape hatch that allows you to do customizations + you can't accomplish using the techniques described in + https://aka.ms/azsdk/python/dpcodegen/python/customize + """ diff --git a/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/resources/v2021_01_01/__init__.py b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/resources/v2021_01_01/__init__.py index 449220069f2f2..2b201470d075e 100644 --- a/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/resources/v2021_01_01/__init__.py +++ b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/resources/v2021_01_01/__init__.py @@ -10,9 +10,15 @@ from ._version import VERSION __version__ = VERSION -__all__ = ['ResourceManagementClient'] -# `._patch.py` is used for handwritten extensions to the generated code -# Example: https://github.com/Azure/azure-sdk-for-python/blob/main/doc/dev/customize_code/how-to-patch-sdk-code.md -from ._patch import patch_sdk -patch_sdk() +try: + from ._patch import __all__ as _patch_all + from ._patch import * # type: ignore # pylint: disable=unused-wildcard-import +except ImportError: + _patch_all = [] +from ._patch import patch_sdk as _patch_sdk + +__all__ = ["ResourceManagementClient"] +__all__.extend([p for p in _patch_all if p not in __all__]) + +_patch_sdk() diff --git a/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/resources/v2021_01_01/_configuration.py b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/resources/v2021_01_01/_configuration.py index 3b48757783814..80d131d2046a8 100644 --- a/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/resources/v2021_01_01/_configuration.py +++ b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/resources/v2021_01_01/_configuration.py @@ -25,23 +25,18 @@ class ResourceManagementClientConfiguration(Configuration): # pylint: disable=t Note that all parameters used to create this instance are saved as instance attributes. - :param credential: Credential needed for the client to connect to Azure. + :param credential: Credential needed for the client to connect to Azure. Required. :type credential: ~azure.core.credentials.TokenCredential - :param subscription_id: The ID of the target subscription. + :param subscription_id: The ID of the target subscription. Required. :type subscription_id: str :keyword api_version: Api Version. Default value is "2021-01-01". Note that overriding this default value may result in unsupported behavior. :paramtype api_version: str """ - def __init__( - self, - credential: "TokenCredential", - subscription_id: str, - **kwargs: Any - ) -> None: + def __init__(self, credential: "TokenCredential", subscription_id: str, **kwargs: Any) -> None: super(ResourceManagementClientConfiguration, self).__init__(**kwargs) - api_version = kwargs.pop('api_version', "2021-01-01") # type: str + api_version = kwargs.pop("api_version", "2021-01-01") # type: str if credential is None: raise ValueError("Parameter 'credential' must not be None.") @@ -51,23 +46,24 @@ def __init__( self.credential = credential self.subscription_id = subscription_id self.api_version = api_version - self.credential_scopes = kwargs.pop('credential_scopes', ['https://management.azure.com/.default']) - kwargs.setdefault('sdk_moniker', 'mgmt-resource/{}'.format(VERSION)) + self.credential_scopes = kwargs.pop("credential_scopes", ["https://management.azure.com/.default"]) + kwargs.setdefault("sdk_moniker", "mgmt-resource/{}".format(VERSION)) self._configure(**kwargs) def _configure( - self, - **kwargs # type: Any + self, **kwargs # type: Any ): # type: (...) -> 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) - self.logging_policy = kwargs.get('logging_policy') or policies.NetworkTraceLoggingPolicy(**kwargs) - self.http_logging_policy = kwargs.get('http_logging_policy') or ARMHttpLoggingPolicy(**kwargs) - self.retry_policy = kwargs.get('retry_policy') or policies.RetryPolicy(**kwargs) - self.custom_hook_policy = kwargs.get('custom_hook_policy') or policies.CustomHookPolicy(**kwargs) - self.redirect_policy = kwargs.get('redirect_policy') or policies.RedirectPolicy(**kwargs) - self.authentication_policy = kwargs.get('authentication_policy') + 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) + self.logging_policy = kwargs.get("logging_policy") or policies.NetworkTraceLoggingPolicy(**kwargs) + self.http_logging_policy = kwargs.get("http_logging_policy") or ARMHttpLoggingPolicy(**kwargs) + self.retry_policy = kwargs.get("retry_policy") or policies.RetryPolicy(**kwargs) + self.custom_hook_policy = kwargs.get("custom_hook_policy") or policies.CustomHookPolicy(**kwargs) + self.redirect_policy = kwargs.get("redirect_policy") or policies.RedirectPolicy(**kwargs) + self.authentication_policy = kwargs.get("authentication_policy") if self.credential and not self.authentication_policy: - self.authentication_policy = ARMChallengeAuthenticationPolicy(self.credential, *self.credential_scopes, **kwargs) + self.authentication_policy = ARMChallengeAuthenticationPolicy( + self.credential, *self.credential_scopes, **kwargs + ) diff --git a/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/resources/v2021_01_01/_metadata.json b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/resources/v2021_01_01/_metadata.json index 2320064fe3ef4..c5a2d8a3644dc 100644 --- a/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/resources/v2021_01_01/_metadata.json +++ b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/resources/v2021_01_01/_metadata.json @@ -10,20 +10,20 @@ "azure_arm": true, "has_lro_operations": true, "client_side_validation": false, - "sync_imports": "{\"typing\": {\"azurecore\": {\"azure.core.credentials\": [\"TokenCredential\"]}}, \"regular\": {\"azurecore\": {\"azure.profiles\": [\"KnownProfiles\", \"ProfileDefinition\"], \"azure.profiles.multiapiclient\": [\"MultiApiClientMixin\"], \"azure.mgmt.core\": [\"ARMPipelineClient\"]}, \"local\": {\"._configuration\": [\"ResourceManagementClientConfiguration\"]}, \"thirdparty\": {\"msrest\": [\"Deserializer\", \"Serializer\"]}}, \"conditional\": {\"stdlib\": {\"typing\": [\"Any\", \"Optional\"]}}}", - "async_imports": "{\"typing\": {\"azurecore\": {\"azure.core.credentials_async\": [\"AsyncTokenCredential\"], \"azure.core.credentials\": [\"TokenCredential\"]}}, \"regular\": {\"azurecore\": {\"azure.profiles\": [\"KnownProfiles\", \"ProfileDefinition\"], \"azure.profiles.multiapiclient\": [\"MultiApiClientMixin\"], \"azure.mgmt.core\": [\"AsyncARMPipelineClient\"]}, \"local\": {\"._configuration\": [\"ResourceManagementClientConfiguration\"]}, \"thirdparty\": {\"msrest\": [\"Deserializer\", \"Serializer\"]}}, \"conditional\": {\"stdlib\": {\"typing\": [\"Any\", \"Optional\"]}}}" + "sync_imports": "{\"conditional\": {\"stdlib\": {\"typing\": [\"Any\", \"Optional\"]}}, \"regular\": {\"azurecore\": {\"azure.mgmt.core\": [\"ARMPipelineClient\"], \"azure.profiles\": [\"KnownProfiles\", \"ProfileDefinition\"], \"azure.profiles.multiapiclient\": [\"MultiApiClientMixin\"]}, \"local\": {\"._configuration\": [\"ResourceManagementClientConfiguration\"], \".._serialization\": [\"Deserializer\", \"Serializer\"]}}, \"typing\": {\"azurecore\": {\"azure.core.credentials\": [\"TokenCredential\"]}}}", + "async_imports": "{\"conditional\": {\"stdlib\": {\"typing\": [\"Any\", \"Optional\"]}}, \"regular\": {\"azurecore\": {\"azure.mgmt.core\": [\"AsyncARMPipelineClient\"], \"azure.profiles\": [\"KnownProfiles\", \"ProfileDefinition\"], \"azure.profiles.multiapiclient\": [\"MultiApiClientMixin\"]}, \"local\": {\"._configuration\": [\"ResourceManagementClientConfiguration\"], \"..._serialization\": [\"Deserializer\", \"Serializer\"]}}, \"typing\": {\"azurecore\": {\"azure.core.credentials_async\": [\"AsyncTokenCredential\"]}}}" }, "global_parameters": { "sync": { "credential": { - "signature": "credential, # type: \"TokenCredential\"", - "description": "Credential needed for the client to connect to Azure.", + "signature": "credential: \"TokenCredential\",", + "description": "Credential needed for the client to connect to Azure. Required.", "docstring_type": "~azure.core.credentials.TokenCredential", "required": true }, "subscription_id": { - "signature": "subscription_id, # type: str", - "description": "The ID of the target subscription.", + "signature": "subscription_id: str,", + "description": "The ID of the target subscription. Required.", "docstring_type": "str", "required": true } @@ -31,13 +31,13 @@ "async": { "credential": { "signature": "credential: \"AsyncTokenCredential\",", - "description": "Credential needed for the client to connect to Azure.", + "description": "Credential needed for the client to connect to Azure. Required.", "docstring_type": "~azure.core.credentials_async.AsyncTokenCredential", "required": true }, "subscription_id": { "signature": "subscription_id: str,", - "description": "The ID of the target subscription.", + "description": "The ID of the target subscription. Required.", "docstring_type": "str", "required": true } @@ -54,7 +54,7 @@ "required": false }, "base_url": { - "signature": "base_url=\"https://management.azure.com\", # type: str", + "signature": "base_url: str = \"https://management.azure.com\",", "description": "Service URL", "docstring_type": "str", "required": false diff --git a/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/resources/v2021_01_01/_patch.py b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/resources/v2021_01_01/_patch.py index 74e48ecd07cf3..f99e77fef9861 100644 --- a/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/resources/v2021_01_01/_patch.py +++ b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/resources/v2021_01_01/_patch.py @@ -28,4 +28,4 @@ # This file is used for handwritten extensions to the generated code. Example: # https://github.com/Azure/azure-sdk-for-python/blob/main/doc/dev/customize_code/how-to-patch-sdk-code.md def patch_sdk(): - pass \ No newline at end of file + pass diff --git a/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/resources/v2021_01_01/_resource_management_client.py b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/resources/v2021_01_01/_resource_management_client.py index 2a18dcf818d74..21b9542c15e40 100644 --- a/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/resources/v2021_01_01/_resource_management_client.py +++ b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/resources/v2021_01_01/_resource_management_client.py @@ -9,20 +9,29 @@ from copy import deepcopy from typing import Any, TYPE_CHECKING -from msrest import Deserializer, Serializer - from azure.core.rest import HttpRequest, HttpResponse from azure.mgmt.core import ARMPipelineClient from . import models +from .._serialization import Deserializer, Serializer from ._configuration import ResourceManagementClientConfiguration -from .operations import DeploymentOperationsOperations, DeploymentsOperations, Operations, ProviderResourceTypesOperations, ProvidersOperations, ResourceGroupsOperations, ResourcesOperations, TagsOperations +from .operations import ( + DeploymentOperationsOperations, + DeploymentsOperations, + Operations, + ProviderResourceTypesOperations, + ProvidersOperations, + ResourceGroupsOperations, + ResourcesOperations, + TagsOperations, +) if TYPE_CHECKING: # pylint: disable=unused-import,ungrouped-imports from azure.core.credentials import TokenCredential -class ResourceManagementClient: # pylint: disable=too-many-instance-attributes + +class ResourceManagementClient: # pylint: disable=client-accepts-api-version-keyword,too-many-instance-attributes """Provides operations for working with resources and resource groups. :ivar operations: Operations operations @@ -45,9 +54,9 @@ class ResourceManagementClient: # pylint: disable=too-many-instance-attribute :ivar deployment_operations: DeploymentOperationsOperations operations :vartype deployment_operations: azure.mgmt.resource.resources.v2021_01_01.operations.DeploymentOperationsOperations - :param credential: Credential needed for the client to connect to Azure. + :param credential: Credential needed for the client to connect to Azure. Required. :type credential: ~azure.core.credentials.TokenCredential - :param subscription_id: The ID of the target subscription. + :param subscription_id: The ID of the target subscription. Required. :type subscription_id: str :param base_url: Service URL. Default value is "https://management.azure.com". :type base_url: str @@ -65,7 +74,9 @@ def __init__( base_url: str = "https://management.azure.com", **kwargs: Any ) -> None: - self._config = ResourceManagementClientConfiguration(credential=credential, subscription_id=subscription_id, **kwargs) + self._config = ResourceManagementClientConfiguration( + credential=credential, subscription_id=subscription_id, **kwargs + ) self._client = ARMPipelineClient(base_url=base_url, config=self._config, **kwargs) client_models = {k: v for k, v in models.__dict__.items() if isinstance(v, type)} @@ -75,18 +86,17 @@ def __init__( self.operations = Operations(self._client, self._config, self._serialize, self._deserialize) self.deployments = DeploymentsOperations(self._client, self._config, self._serialize, self._deserialize) self.providers = ProvidersOperations(self._client, self._config, self._serialize, self._deserialize) - self.provider_resource_types = ProviderResourceTypesOperations(self._client, self._config, self._serialize, self._deserialize) + self.provider_resource_types = ProviderResourceTypesOperations( + self._client, self._config, self._serialize, self._deserialize + ) self.resources = ResourcesOperations(self._client, self._config, self._serialize, self._deserialize) self.resource_groups = ResourceGroupsOperations(self._client, self._config, self._serialize, self._deserialize) self.tags = TagsOperations(self._client, self._config, self._serialize, self._deserialize) - self.deployment_operations = DeploymentOperationsOperations(self._client, self._config, self._serialize, self._deserialize) - + self.deployment_operations = DeploymentOperationsOperations( + self._client, self._config, self._serialize, self._deserialize + ) - def _send_request( - self, - request: HttpRequest, - **kwargs: Any - ) -> HttpResponse: + def _send_request(self, request: HttpRequest, **kwargs: Any) -> HttpResponse: """Runs the network request through the client's chained policies. >>> from azure.core.rest import HttpRequest @@ -95,7 +105,7 @@ def _send_request( >>> response = client._send_request(request) - For more information on this code flow, see https://aka.ms/azsdk/python/protocol/quickstart + For more information on this code flow, see https://aka.ms/azsdk/dpcodegen/python/send_request :param request: The network request you want to make. Required. :type request: ~azure.core.rest.HttpRequest diff --git a/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/resources/v2021_01_01/_vendor.py b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/resources/v2021_01_01/_vendor.py index 138f663c53a4e..9aad73fc743e7 100644 --- a/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/resources/v2021_01_01/_vendor.py +++ b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/resources/v2021_01_01/_vendor.py @@ -7,6 +7,7 @@ from azure.core.pipeline.transport import HttpRequest + def _convert_request(request, files=None): data = request.content if not files else None request = HttpRequest(method=request.method, url=request.url, headers=request.headers, data=data) @@ -14,6 +15,7 @@ def _convert_request(request, files=None): request.set_formdata_body(files) return request + def _format_url_section(template, **kwargs): components = template.split("/") while components: @@ -21,7 +23,5 @@ def _format_url_section(template, **kwargs): 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 - ] + components = [c for c in formatted_components if "{}".format(key.args[0]) not in c] template = "/".join(components) diff --git a/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/resources/v2021_01_01/_version.py b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/resources/v2021_01_01/_version.py index a012ac01c480c..e5754a47ce68f 100644 --- a/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/resources/v2021_01_01/_version.py +++ b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/resources/v2021_01_01/_version.py @@ -6,4 +6,4 @@ # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -VERSION = "21.1.0" +VERSION = "1.0.0b1" diff --git a/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/resources/v2021_01_01/aio/__init__.py b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/resources/v2021_01_01/aio/__init__.py index c6c3cf64a37a6..98d6782c2530c 100644 --- a/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/resources/v2021_01_01/aio/__init__.py +++ b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/resources/v2021_01_01/aio/__init__.py @@ -7,9 +7,15 @@ # -------------------------------------------------------------------------- from ._resource_management_client import ResourceManagementClient -__all__ = ['ResourceManagementClient'] -# `._patch.py` is used for handwritten extensions to the generated code -# Example: https://github.com/Azure/azure-sdk-for-python/blob/main/doc/dev/customize_code/how-to-patch-sdk-code.md -from ._patch import patch_sdk -patch_sdk() +try: + from ._patch import __all__ as _patch_all + from ._patch import * # type: ignore # pylint: disable=unused-wildcard-import +except ImportError: + _patch_all = [] +from ._patch import patch_sdk as _patch_sdk + +__all__ = ["ResourceManagementClient"] +__all__.extend([p for p in _patch_all if p not in __all__]) + +_patch_sdk() diff --git a/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/resources/v2021_01_01/aio/_configuration.py b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/resources/v2021_01_01/aio/_configuration.py index 340806422483f..8af2e19762711 100644 --- a/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/resources/v2021_01_01/aio/_configuration.py +++ b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/resources/v2021_01_01/aio/_configuration.py @@ -25,23 +25,18 @@ class ResourceManagementClientConfiguration(Configuration): # pylint: disable=t Note that all parameters used to create this instance are saved as instance attributes. - :param credential: Credential needed for the client to connect to Azure. + :param credential: Credential needed for the client to connect to Azure. Required. :type credential: ~azure.core.credentials_async.AsyncTokenCredential - :param subscription_id: The ID of the target subscription. + :param subscription_id: The ID of the target subscription. Required. :type subscription_id: str :keyword api_version: Api Version. Default value is "2021-01-01". Note that overriding this default value may result in unsupported behavior. :paramtype api_version: str """ - def __init__( - self, - credential: "AsyncTokenCredential", - subscription_id: str, - **kwargs: Any - ) -> None: + def __init__(self, credential: "AsyncTokenCredential", subscription_id: str, **kwargs: Any) -> None: super(ResourceManagementClientConfiguration, self).__init__(**kwargs) - api_version = kwargs.pop('api_version', "2021-01-01") # type: str + api_version = kwargs.pop("api_version", "2021-01-01") # type: str if credential is None: raise ValueError("Parameter 'credential' must not be None.") @@ -51,22 +46,21 @@ def __init__( self.credential = credential self.subscription_id = subscription_id self.api_version = api_version - self.credential_scopes = kwargs.pop('credential_scopes', ['https://management.azure.com/.default']) - kwargs.setdefault('sdk_moniker', 'mgmt-resource/{}'.format(VERSION)) + self.credential_scopes = kwargs.pop("credential_scopes", ["https://management.azure.com/.default"]) + kwargs.setdefault("sdk_moniker", "mgmt-resource/{}".format(VERSION)) self._configure(**kwargs) - 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) - self.logging_policy = kwargs.get('logging_policy') or policies.NetworkTraceLoggingPolicy(**kwargs) - self.http_logging_policy = kwargs.get('http_logging_policy') or ARMHttpLoggingPolicy(**kwargs) - self.retry_policy = kwargs.get('retry_policy') or policies.AsyncRetryPolicy(**kwargs) - self.custom_hook_policy = kwargs.get('custom_hook_policy') or policies.CustomHookPolicy(**kwargs) - self.redirect_policy = kwargs.get('redirect_policy') or policies.AsyncRedirectPolicy(**kwargs) - self.authentication_policy = kwargs.get('authentication_policy') + 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) + self.logging_policy = kwargs.get("logging_policy") or policies.NetworkTraceLoggingPolicy(**kwargs) + self.http_logging_policy = kwargs.get("http_logging_policy") or ARMHttpLoggingPolicy(**kwargs) + self.retry_policy = kwargs.get("retry_policy") or policies.AsyncRetryPolicy(**kwargs) + self.custom_hook_policy = kwargs.get("custom_hook_policy") or policies.CustomHookPolicy(**kwargs) + self.redirect_policy = kwargs.get("redirect_policy") or policies.AsyncRedirectPolicy(**kwargs) + self.authentication_policy = kwargs.get("authentication_policy") if self.credential and not self.authentication_policy: - self.authentication_policy = AsyncARMChallengeAuthenticationPolicy(self.credential, *self.credential_scopes, **kwargs) + self.authentication_policy = AsyncARMChallengeAuthenticationPolicy( + self.credential, *self.credential_scopes, **kwargs + ) diff --git a/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/resources/v2021_01_01/aio/_patch.py b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/resources/v2021_01_01/aio/_patch.py index 74e48ecd07cf3..f99e77fef9861 100644 --- a/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/resources/v2021_01_01/aio/_patch.py +++ b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/resources/v2021_01_01/aio/_patch.py @@ -28,4 +28,4 @@ # This file is used for handwritten extensions to the generated code. Example: # https://github.com/Azure/azure-sdk-for-python/blob/main/doc/dev/customize_code/how-to-patch-sdk-code.md def patch_sdk(): - pass \ No newline at end of file + pass diff --git a/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/resources/v2021_01_01/aio/_resource_management_client.py b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/resources/v2021_01_01/aio/_resource_management_client.py index 463e1cbb05710..4f0381f54cb77 100644 --- a/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/resources/v2021_01_01/aio/_resource_management_client.py +++ b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/resources/v2021_01_01/aio/_resource_management_client.py @@ -9,20 +9,29 @@ from copy import deepcopy from typing import Any, Awaitable, TYPE_CHECKING -from msrest import Deserializer, Serializer - from azure.core.rest import AsyncHttpResponse, HttpRequest from azure.mgmt.core import AsyncARMPipelineClient from .. import models +from ..._serialization import Deserializer, Serializer from ._configuration import ResourceManagementClientConfiguration -from .operations import DeploymentOperationsOperations, DeploymentsOperations, Operations, ProviderResourceTypesOperations, ProvidersOperations, ResourceGroupsOperations, ResourcesOperations, TagsOperations +from .operations import ( + DeploymentOperationsOperations, + DeploymentsOperations, + Operations, + ProviderResourceTypesOperations, + ProvidersOperations, + ResourceGroupsOperations, + ResourcesOperations, + TagsOperations, +) if TYPE_CHECKING: # pylint: disable=unused-import,ungrouped-imports from azure.core.credentials_async import AsyncTokenCredential -class ResourceManagementClient: # pylint: disable=too-many-instance-attributes + +class ResourceManagementClient: # pylint: disable=client-accepts-api-version-keyword,too-many-instance-attributes """Provides operations for working with resources and resource groups. :ivar operations: Operations operations @@ -47,9 +56,9 @@ class ResourceManagementClient: # pylint: disable=too-many-instance-attribute :ivar deployment_operations: DeploymentOperationsOperations operations :vartype deployment_operations: azure.mgmt.resource.resources.v2021_01_01.aio.operations.DeploymentOperationsOperations - :param credential: Credential needed for the client to connect to Azure. + :param credential: Credential needed for the client to connect to Azure. Required. :type credential: ~azure.core.credentials_async.AsyncTokenCredential - :param subscription_id: The ID of the target subscription. + :param subscription_id: The ID of the target subscription. Required. :type subscription_id: str :param base_url: Service URL. Default value is "https://management.azure.com". :type base_url: str @@ -67,7 +76,9 @@ def __init__( base_url: str = "https://management.azure.com", **kwargs: Any ) -> None: - self._config = ResourceManagementClientConfiguration(credential=credential, subscription_id=subscription_id, **kwargs) + self._config = ResourceManagementClientConfiguration( + credential=credential, subscription_id=subscription_id, **kwargs + ) self._client = AsyncARMPipelineClient(base_url=base_url, config=self._config, **kwargs) client_models = {k: v for k, v in models.__dict__.items() if isinstance(v, type)} @@ -77,18 +88,17 @@ def __init__( self.operations = Operations(self._client, self._config, self._serialize, self._deserialize) self.deployments = DeploymentsOperations(self._client, self._config, self._serialize, self._deserialize) self.providers = ProvidersOperations(self._client, self._config, self._serialize, self._deserialize) - self.provider_resource_types = ProviderResourceTypesOperations(self._client, self._config, self._serialize, self._deserialize) + self.provider_resource_types = ProviderResourceTypesOperations( + self._client, self._config, self._serialize, self._deserialize + ) self.resources = ResourcesOperations(self._client, self._config, self._serialize, self._deserialize) self.resource_groups = ResourceGroupsOperations(self._client, self._config, self._serialize, self._deserialize) self.tags = TagsOperations(self._client, self._config, self._serialize, self._deserialize) - self.deployment_operations = DeploymentOperationsOperations(self._client, self._config, self._serialize, self._deserialize) - + self.deployment_operations = DeploymentOperationsOperations( + self._client, self._config, self._serialize, self._deserialize + ) - def _send_request( - self, - request: HttpRequest, - **kwargs: Any - ) -> Awaitable[AsyncHttpResponse]: + def _send_request(self, request: HttpRequest, **kwargs: Any) -> Awaitable[AsyncHttpResponse]: """Runs the network request through the client's chained policies. >>> from azure.core.rest import HttpRequest @@ -97,7 +107,7 @@ def _send_request( >>> response = await client._send_request(request) - For more information on this code flow, see https://aka.ms/azsdk/python/protocol/quickstart + For more information on this code flow, see https://aka.ms/azsdk/dpcodegen/python/send_request :param request: The network request you want to make. Required. :type request: ~azure.core.rest.HttpRequest diff --git a/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/resources/v2021_01_01/aio/operations/__init__.py b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/resources/v2021_01_01/aio/operations/__init__.py index f1487609817b6..9e5620e4d286c 100644 --- a/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/resources/v2021_01_01/aio/operations/__init__.py +++ b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/resources/v2021_01_01/aio/operations/__init__.py @@ -15,13 +15,19 @@ from ._operations import TagsOperations from ._operations import DeploymentOperationsOperations +from ._patch import __all__ as _patch_all +from ._patch import * # type: ignore # pylint: disable=unused-wildcard-import +from ._patch import patch_sdk as _patch_sdk + __all__ = [ - 'Operations', - 'DeploymentsOperations', - 'ProvidersOperations', - 'ProviderResourceTypesOperations', - 'ResourcesOperations', - 'ResourceGroupsOperations', - 'TagsOperations', - 'DeploymentOperationsOperations', + "Operations", + "DeploymentsOperations", + "ProvidersOperations", + "ProviderResourceTypesOperations", + "ResourcesOperations", + "ResourceGroupsOperations", + "TagsOperations", + "DeploymentOperationsOperations", ] +__all__.extend([p for p in _patch_all if p not in __all__]) +_patch_sdk() diff --git a/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/resources/v2021_01_01/aio/operations/_operations.py b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/resources/v2021_01_01/aio/operations/_operations.py index 72b12a605ddcc..ef7bfe8705106 100644 --- a/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/resources/v2021_01_01/aio/operations/_operations.py +++ b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/resources/v2021_01_01/aio/operations/_operations.py @@ -6,84 +6,200 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -from typing import Any, AsyncIterable, Callable, Dict, Optional, TypeVar, Union +import sys +from typing import Any, AsyncIterable, Callable, Dict, IO, Optional, TypeVar, Union, cast, overload +from urllib.parse import parse_qs, urljoin, urlparse from azure.core.async_paging import AsyncItemPaged, AsyncList -from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error +from azure.core.exceptions import ( + ClientAuthenticationError, + HttpResponseError, + ResourceExistsError, + ResourceNotFoundError, + ResourceNotModifiedError, + map_error, +) from azure.core.pipeline import PipelineResponse from azure.core.pipeline.transport import AsyncHttpResponse from azure.core.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 from azure.mgmt.core.polling.async_arm_polling import AsyncARMPolling from ... import models as _models from ..._vendor import _convert_request -from ...operations._operations import build_deployment_operations_get_at_management_group_scope_request, build_deployment_operations_get_at_scope_request, build_deployment_operations_get_at_subscription_scope_request, build_deployment_operations_get_at_tenant_scope_request, build_deployment_operations_get_request, build_deployment_operations_list_at_management_group_scope_request, build_deployment_operations_list_at_scope_request, build_deployment_operations_list_at_subscription_scope_request, build_deployment_operations_list_at_tenant_scope_request, build_deployment_operations_list_request, build_deployments_calculate_template_hash_request, build_deployments_cancel_at_management_group_scope_request, build_deployments_cancel_at_scope_request, build_deployments_cancel_at_subscription_scope_request, build_deployments_cancel_at_tenant_scope_request, build_deployments_cancel_request, build_deployments_check_existence_at_management_group_scope_request, build_deployments_check_existence_at_scope_request, build_deployments_check_existence_at_subscription_scope_request, build_deployments_check_existence_at_tenant_scope_request, build_deployments_check_existence_request, build_deployments_create_or_update_at_management_group_scope_request_initial, build_deployments_create_or_update_at_scope_request_initial, build_deployments_create_or_update_at_subscription_scope_request_initial, build_deployments_create_or_update_at_tenant_scope_request_initial, build_deployments_create_or_update_request_initial, build_deployments_delete_at_management_group_scope_request_initial, build_deployments_delete_at_scope_request_initial, build_deployments_delete_at_subscription_scope_request_initial, build_deployments_delete_at_tenant_scope_request_initial, build_deployments_delete_request_initial, build_deployments_export_template_at_management_group_scope_request, build_deployments_export_template_at_scope_request, build_deployments_export_template_at_subscription_scope_request, build_deployments_export_template_at_tenant_scope_request, build_deployments_export_template_request, build_deployments_get_at_management_group_scope_request, build_deployments_get_at_scope_request, build_deployments_get_at_subscription_scope_request, build_deployments_get_at_tenant_scope_request, build_deployments_get_request, build_deployments_list_at_management_group_scope_request, build_deployments_list_at_scope_request, build_deployments_list_at_subscription_scope_request, build_deployments_list_at_tenant_scope_request, build_deployments_list_by_resource_group_request, build_deployments_validate_at_management_group_scope_request_initial, build_deployments_validate_at_scope_request_initial, build_deployments_validate_at_subscription_scope_request_initial, build_deployments_validate_at_tenant_scope_request_initial, build_deployments_validate_request_initial, build_deployments_what_if_at_management_group_scope_request_initial, build_deployments_what_if_at_subscription_scope_request_initial, build_deployments_what_if_at_tenant_scope_request_initial, build_deployments_what_if_request_initial, build_operations_list_request, build_provider_resource_types_list_request, build_providers_get_at_tenant_scope_request, build_providers_get_request, build_providers_list_at_tenant_scope_request, build_providers_list_request, build_providers_register_at_management_group_scope_request, build_providers_register_request, build_providers_unregister_request, build_resource_groups_check_existence_request, build_resource_groups_create_or_update_request, build_resource_groups_delete_request_initial, build_resource_groups_export_template_request_initial, build_resource_groups_get_request, build_resource_groups_list_request, build_resource_groups_update_request, build_resources_check_existence_by_id_request, build_resources_check_existence_request, build_resources_create_or_update_by_id_request_initial, build_resources_create_or_update_request_initial, build_resources_delete_by_id_request_initial, build_resources_delete_request_initial, build_resources_get_by_id_request, build_resources_get_request, build_resources_list_by_resource_group_request, build_resources_list_request, build_resources_move_resources_request_initial, build_resources_update_by_id_request_initial, build_resources_update_request_initial, build_resources_validate_move_resources_request_initial, build_tags_create_or_update_at_scope_request, build_tags_create_or_update_request, build_tags_create_or_update_value_request, build_tags_delete_at_scope_request, build_tags_delete_request, build_tags_delete_value_request, build_tags_get_at_scope_request, build_tags_list_request, build_tags_update_at_scope_request -T = TypeVar('T') +from ...operations._operations import ( + build_deployment_operations_get_at_management_group_scope_request, + build_deployment_operations_get_at_scope_request, + build_deployment_operations_get_at_subscription_scope_request, + build_deployment_operations_get_at_tenant_scope_request, + build_deployment_operations_get_request, + build_deployment_operations_list_at_management_group_scope_request, + build_deployment_operations_list_at_scope_request, + build_deployment_operations_list_at_subscription_scope_request, + build_deployment_operations_list_at_tenant_scope_request, + build_deployment_operations_list_request, + build_deployments_calculate_template_hash_request, + build_deployments_cancel_at_management_group_scope_request, + build_deployments_cancel_at_scope_request, + build_deployments_cancel_at_subscription_scope_request, + build_deployments_cancel_at_tenant_scope_request, + build_deployments_cancel_request, + build_deployments_check_existence_at_management_group_scope_request, + build_deployments_check_existence_at_scope_request, + build_deployments_check_existence_at_subscription_scope_request, + build_deployments_check_existence_at_tenant_scope_request, + build_deployments_check_existence_request, + build_deployments_create_or_update_at_management_group_scope_request, + build_deployments_create_or_update_at_scope_request, + build_deployments_create_or_update_at_subscription_scope_request, + build_deployments_create_or_update_at_tenant_scope_request, + build_deployments_create_or_update_request, + build_deployments_delete_at_management_group_scope_request, + build_deployments_delete_at_scope_request, + build_deployments_delete_at_subscription_scope_request, + build_deployments_delete_at_tenant_scope_request, + build_deployments_delete_request, + build_deployments_export_template_at_management_group_scope_request, + build_deployments_export_template_at_scope_request, + build_deployments_export_template_at_subscription_scope_request, + build_deployments_export_template_at_tenant_scope_request, + build_deployments_export_template_request, + build_deployments_get_at_management_group_scope_request, + build_deployments_get_at_scope_request, + build_deployments_get_at_subscription_scope_request, + build_deployments_get_at_tenant_scope_request, + build_deployments_get_request, + build_deployments_list_at_management_group_scope_request, + build_deployments_list_at_scope_request, + build_deployments_list_at_subscription_scope_request, + build_deployments_list_at_tenant_scope_request, + build_deployments_list_by_resource_group_request, + build_deployments_validate_at_management_group_scope_request, + build_deployments_validate_at_scope_request, + build_deployments_validate_at_subscription_scope_request, + build_deployments_validate_at_tenant_scope_request, + build_deployments_validate_request, + build_deployments_what_if_at_management_group_scope_request, + build_deployments_what_if_at_subscription_scope_request, + build_deployments_what_if_at_tenant_scope_request, + build_deployments_what_if_request, + build_operations_list_request, + build_provider_resource_types_list_request, + build_providers_get_at_tenant_scope_request, + build_providers_get_request, + build_providers_list_at_tenant_scope_request, + build_providers_list_request, + build_providers_register_at_management_group_scope_request, + build_providers_register_request, + build_providers_unregister_request, + build_resource_groups_check_existence_request, + build_resource_groups_create_or_update_request, + build_resource_groups_delete_request, + build_resource_groups_export_template_request, + build_resource_groups_get_request, + build_resource_groups_list_request, + build_resource_groups_update_request, + build_resources_check_existence_by_id_request, + build_resources_check_existence_request, + build_resources_create_or_update_by_id_request, + build_resources_create_or_update_request, + build_resources_delete_by_id_request, + build_resources_delete_request, + build_resources_get_by_id_request, + build_resources_get_request, + build_resources_list_by_resource_group_request, + build_resources_list_request, + build_resources_move_resources_request, + build_resources_update_by_id_request, + build_resources_update_request, + build_resources_validate_move_resources_request, + build_tags_create_or_update_at_scope_request, + build_tags_create_or_update_request, + build_tags_create_or_update_value_request, + build_tags_delete_at_scope_request, + build_tags_delete_request, + build_tags_delete_value_request, + build_tags_get_at_scope_request, + build_tags_list_request, + build_tags_update_at_scope_request, +) + +T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] +if sys.version_info >= (3, 9): + from collections.abc import MutableMapping +else: + from typing import MutableMapping # type: ignore # pylint: disable=ungrouped-imports +JSON = MutableMapping[str, Any] # pylint: disable=unsubscriptable-object -class Operations: - """Operations async operations. - You should not instantiate this class directly. Instead, you should create a Client instance that - instantiates it for you and attaches it as an attribute. +class Operations: + """ + .. warning:: + **DO NOT** instantiate this class directly. - :ivar models: Alias to model classes used in this operation group. - :type models: ~azure.mgmt.resource.resources.v2021_01_01.models - :param client: Client for service requests. - :param config: Configuration of service client. - :param serializer: An object model serializer. - :param deserializer: An object model deserializer. + Instead, you should access the following operations through + :class:`~azure.mgmt.resource.resources.v2021_01_01.aio.ResourceManagementClient`'s + :attr:`operations` attribute. """ models = _models - def __init__(self, client, config, serializer, deserializer) -> None: - self._client = client - self._serialize = serializer - self._deserialize = deserializer - self._config = config + def __init__(self, *args, **kwargs) -> None: + input_args = list(args) + self._client = input_args.pop(0) if input_args else kwargs.pop("client") + self._config = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") @distributed_trace - def list( - self, - **kwargs: Any - ) -> AsyncIterable["_models.OperationListResult"]: + def list(self, **kwargs: Any) -> AsyncIterable["_models.Operation"]: """Lists all of the available Microsoft.Resources REST API operations. :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either OperationListResult or the result of cls(response) + :return: An iterator like instance of either Operation or the result of cls(response) :rtype: - ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.resource.resources.v2021_01_01.models.OperationListResult] - :raises: ~azure.core.exceptions.HttpResponseError + ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.resource.resources.v2021_01_01.models.Operation] + :raises ~azure.core.exceptions.HttpResponseError: """ - api_version = kwargs.pop('api_version', "2021-01-01") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-01-01")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[_models.OperationListResult] - cls = kwargs.pop('cls', None) # type: ClsType["_models.OperationListResult"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) + def prepare_request(next_link=None): if not next_link: - + request = build_operations_list_request( api_version=api_version, - template_url=self.list.metadata['url'], + template_url=self.list.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore else: - - request = build_operations_list_request( - template_url=next_link, - ) + # make call to next link with the client's api-version + _parsed_next_link = urlparse(next_link) + _next_request_params = case_insensitive_dict(parse_qs(_parsed_next_link.query)) + _next_request_params["api-version"] = self._config.api_version + request = HttpRequest("GET", urljoin(next_link, _parsed_next_link.path), params=_next_request_params) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore request.method = "GET" return request @@ -97,10 +213,8 @@ async def extract_data(pipeline_response): async def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) response = pipeline_response.http_response @@ -110,62 +224,62 @@ async def get_next(next_link=None): return pipeline_response + return AsyncItemPaged(get_next, extract_data) - return AsyncItemPaged( - get_next, extract_data - ) - list.metadata = {'url': "/providers/Microsoft.Resources/operations"} # type: ignore -class DeploymentsOperations: # pylint: disable=too-many-public-methods - """DeploymentsOperations async operations. + list.metadata = {"url": "/providers/Microsoft.Resources/operations"} # type: ignore - You should not instantiate this class directly. Instead, you should create a Client instance that - instantiates it for you and attaches it as an attribute. - :ivar models: Alias to model classes used in this operation group. - :type models: ~azure.mgmt.resource.resources.v2021_01_01.models - :param client: Client for service requests. - :param config: Configuration of service client. - :param serializer: An object model serializer. - :param deserializer: An object model deserializer. +class DeploymentsOperations: # pylint: disable=too-many-public-methods + """ + .. warning:: + **DO NOT** instantiate this class directly. + + Instead, you should access the following operations through + :class:`~azure.mgmt.resource.resources.v2021_01_01.aio.ResourceManagementClient`'s + :attr:`deployments` attribute. """ models = _models - def __init__(self, client, config, serializer, deserializer) -> None: - self._client = client - self._serialize = serializer - self._deserialize = deserializer - self._config = config + def __init__(self, *args, **kwargs) -> None: + input_args = list(args) + self._client = input_args.pop(0) if input_args else kwargs.pop("client") + self._config = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") async def _delete_at_scope_initial( # pylint: disable=inconsistent-return-statements - self, - scope: str, - deployment_name: str, - **kwargs: Any + self, scope: str, deployment_name: str, **kwargs: Any ) -> None: - cls = kwargs.pop('cls', None) # type: ClsType[None] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + 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', "2021-01-01") # type: str + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-01-01")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[None] - - request = build_deployments_delete_at_scope_request_initial( + request = build_deployments_delete_at_scope_request( scope=scope, deployment_name=deployment_name, api_version=api_version, - template_url=self._delete_at_scope_initial.metadata['url'], + template_url=self._delete_at_scope_initial.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [202, 204]: @@ -175,16 +289,10 @@ async def _delete_at_scope_initial( # pylint: disable=inconsistent-return-state if cls: return cls(pipeline_response, None, {}) - _delete_at_scope_initial.metadata = {'url': "/{scope}/providers/Microsoft.Resources/deployments/{deploymentName}"} # type: ignore - + _delete_at_scope_initial.metadata = {"url": "/{scope}/providers/Microsoft.Resources/deployments/{deploymentName}"} # type: ignore @distributed_trace_async - async def begin_delete_at_scope( # pylint: disable=inconsistent-return-statements - self, - scope: str, - deployment_name: str, - **kwargs: Any - ) -> AsyncLROPoller[None]: + async def begin_delete_at_scope(self, scope: str, deployment_name: str, **kwargs: Any) -> AsyncLROPoller[None]: """Deletes a deployment from the deployment history. A template deployment that is currently running cannot be deleted. Deleting a template @@ -195,9 +303,9 @@ async def begin_delete_at_scope( # pylint: disable=inconsistent-return-statemen process finishes, the URI in the Location header returns a status of 204 on success. If the asynchronous request failed, the URI in the Location header returns an error-level status code. - :param scope: The resource scope. + :param scope: The resource scope. Required. :type scope: str - :param deployment_name: The name of the deployment. + :param deployment_name: The name of the deployment. Required. :type deployment_name: str :keyword callable cls: A custom type or function that will be passed the direct response :keyword str continuation_token: A continuation token to restart a poller from a saved state. @@ -209,86 +317,91 @@ async def begin_delete_at_scope( # pylint: disable=inconsistent-return-statemen Retry-After header is present. :return: An instance of AsyncLROPoller that returns either None or the result of cls(response) :rtype: ~azure.core.polling.AsyncLROPoller[None] - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - api_version = kwargs.pop('api_version', "2021-01-01") # type: str - polling = kwargs.pop('polling', True) # type: Union[bool, AsyncPollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType[None] - lro_delay = kwargs.pop( - 'polling_interval', - self._config.polling_interval - ) - cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-01-01")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[None] + polling = kwargs.pop("polling", True) # type: Union[bool, AsyncPollingMethod] + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token = kwargs.pop("continuation_token", None) # type: Optional[str] if cont_token is None: - raw_result = await self._delete_at_scope_initial( + raw_result = await self._delete_at_scope_initial( # type: ignore scope=scope, deployment_name=deployment_name, api_version=api_version, - cls=lambda x,y,z: x, + cls=lambda x, y, z: x, + headers=_headers, + params=_params, **kwargs ) - kwargs.pop('error_map', None) + kwargs.pop("error_map", None) - def get_long_running_output(pipeline_response): + def get_long_running_output(pipeline_response): # pylint: disable=inconsistent-return-statements if cls: return cls(pipeline_response, None, {}) - - if polling is True: polling_method = AsyncARMPolling(lro_delay, **kwargs) - elif polling is False: polling_method = AsyncNoPolling() - else: polling_method = polling + if polling is True: + polling_method = cast(AsyncPollingMethod, AsyncARMPolling(lro_delay, **kwargs)) # type: AsyncPollingMethod + elif polling is False: + polling_method = cast(AsyncPollingMethod, AsyncNoPolling()) + else: + polling_method = polling if cont_token: return AsyncLROPoller.from_continuation_token( polling_method=polling_method, continuation_token=cont_token, client=self._client, - deserialization_callback=get_long_running_output + deserialization_callback=get_long_running_output, ) return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) - begin_delete_at_scope.metadata = {'url': "/{scope}/providers/Microsoft.Resources/deployments/{deploymentName}"} # type: ignore + begin_delete_at_scope.metadata = {"url": "/{scope}/providers/Microsoft.Resources/deployments/{deploymentName}"} # type: ignore @distributed_trace_async - async def check_existence_at_scope( - self, - scope: str, - deployment_name: str, - **kwargs: Any - ) -> bool: + async def check_existence_at_scope(self, scope: str, deployment_name: str, **kwargs: Any) -> bool: """Checks whether the deployment exists. - :param scope: The resource scope. + :param scope: The resource scope. Required. :type scope: str - :param deployment_name: The name of the deployment. + :param deployment_name: The name of the deployment. Required. :type deployment_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: bool, or the result of cls(response) + :return: bool or the result of cls(response) :rtype: bool - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType[None] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + 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', "2021-01-01") # type: str + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-01-01")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[None] - request = build_deployments_check_existence_at_scope_request( scope=scope, deployment_name=deployment_name, api_version=api_version, - template_url=self.check_existence_at_scope.metadata['url'], + template_url=self.check_existence_at_scope.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [204, 404]: @@ -299,43 +412,52 @@ async def check_existence_at_scope( return cls(pipeline_response, None, {}) return 200 <= response.status_code <= 299 - check_existence_at_scope.metadata = {'url': "/{scope}/providers/Microsoft.Resources/deployments/{deploymentName}"} # type: ignore - + check_existence_at_scope.metadata = {"url": "/{scope}/providers/Microsoft.Resources/deployments/{deploymentName}"} # type: ignore async def _create_or_update_at_scope_initial( - self, - scope: str, - deployment_name: str, - parameters: "_models.Deployment", - **kwargs: Any - ) -> "_models.DeploymentExtended": - cls = kwargs.pop('cls', None) # type: ClsType["_models.DeploymentExtended"] + self, scope: str, deployment_name: str, parameters: Union[_models.Deployment, IO], **kwargs: Any + ) -> _models.DeploymentExtended: error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) - api_version = kwargs.pop('api_version', "2021-01-01") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - _json = self._serialize.body(parameters, 'Deployment') + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-01-01")) # type: str + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.DeploymentExtended] - request = build_deployments_create_or_update_at_scope_request_initial( + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(parameters, (IO, bytes)): + _content = parameters + else: + _json = self._serialize.body(parameters, "Deployment") + + request = build_deployments_create_or_update_at_scope_request( scope=scope, deployment_name=deployment_name, api_version=api_version, content_type=content_type, json=_json, - template_url=self._create_or_update_at_scope_initial.metadata['url'], + content=_content, + template_url=self._create_or_update_at_scope_initial.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200, 201]: @@ -343,37 +465,41 @@ async def _create_or_update_at_scope_initial( raise HttpResponseError(response=response, error_format=ARMErrorFormat) if response.status_code == 200: - deserialized = self._deserialize('DeploymentExtended', pipeline_response) + deserialized = self._deserialize("DeploymentExtended", pipeline_response) if response.status_code == 201: - deserialized = self._deserialize('DeploymentExtended', pipeline_response) + deserialized = self._deserialize("DeploymentExtended", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - _create_or_update_at_scope_initial.metadata = {'url': "/{scope}/providers/Microsoft.Resources/deployments/{deploymentName}"} # type: ignore + _create_or_update_at_scope_initial.metadata = {"url": "/{scope}/providers/Microsoft.Resources/deployments/{deploymentName}"} # type: ignore - - @distributed_trace_async + @overload async def begin_create_or_update_at_scope( self, scope: str, deployment_name: str, - parameters: "_models.Deployment", + parameters: _models.Deployment, + *, + content_type: str = "application/json", **kwargs: Any - ) -> AsyncLROPoller["_models.DeploymentExtended"]: + ) -> AsyncLROPoller[_models.DeploymentExtended]: """Deploys resources at a given scope. You can provide the template and parameters directly in the request or link to JSON files. - :param scope: The resource scope. + :param scope: The resource scope. Required. :type scope: str - :param deployment_name: The name of the deployment. + :param deployment_name: The name of the deployment. Required. :type deployment_name: str - :param parameters: Additional parameters supplied to the operation. + :param parameters: Additional parameters supplied to the operation. Required. :type parameters: ~azure.mgmt.resource.resources.v2021_01_01.models.Deployment + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str :keyword callable cls: A custom type or function that will be passed the direct response :keyword str continuation_token: A continuation token to restart a poller from a saved state. :keyword polling: By default, your polling method will be AsyncARMPolling. Pass in False for @@ -386,114 +512,179 @@ async def begin_create_or_update_at_scope( cls(response) :rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.resource.resources.v2021_01_01.models.DeploymentExtended] - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - api_version = kwargs.pop('api_version', "2021-01-01") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] - polling = kwargs.pop('polling', True) # type: Union[bool, AsyncPollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType["_models.DeploymentExtended"] - lro_delay = kwargs.pop( - 'polling_interval', - self._config.polling_interval - ) - cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] + + @overload + async def begin_create_or_update_at_scope( + self, scope: str, deployment_name: str, parameters: IO, *, content_type: str = "application/json", **kwargs: Any + ) -> AsyncLROPoller[_models.DeploymentExtended]: + """Deploys resources at a given scope. + + You can provide the template and parameters directly in the request or link to JSON files. + + :param scope: The resource scope. Required. + :type scope: str + :param deployment_name: The name of the deployment. Required. + :type deployment_name: str + :param parameters: Additional parameters supplied to the operation. Required. + :type parameters: IO + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be AsyncARMPolling. Pass in False for + this operation to not poll, or pass in your own initialized polling object for a personal + polling strategy. + :paramtype polling: bool or ~azure.core.polling.AsyncPollingMethod + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of AsyncLROPoller that returns either DeploymentExtended or the result of + cls(response) + :rtype: + ~azure.core.polling.AsyncLROPoller[~azure.mgmt.resource.resources.v2021_01_01.models.DeploymentExtended] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace_async + async def begin_create_or_update_at_scope( + self, scope: str, deployment_name: str, parameters: Union[_models.Deployment, IO], **kwargs: Any + ) -> AsyncLROPoller[_models.DeploymentExtended]: + """Deploys resources at a given scope. + + You can provide the template and parameters directly in the request or link to JSON files. + + :param scope: The resource scope. Required. + :type scope: str + :param deployment_name: The name of the deployment. Required. + :type deployment_name: str + :param parameters: Additional parameters supplied to the operation. Is either a model type or a + IO type. Required. + :type parameters: ~azure.mgmt.resource.resources.v2021_01_01.models.Deployment or IO + :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. + Default value is None. + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be AsyncARMPolling. Pass in False for + this operation to not poll, or pass in your own initialized polling object for a personal + polling strategy. + :paramtype polling: bool or ~azure.core.polling.AsyncPollingMethod + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of AsyncLROPoller that returns either DeploymentExtended or the result of + cls(response) + :rtype: + ~azure.core.polling.AsyncLROPoller[~azure.mgmt.resource.resources.v2021_01_01.models.DeploymentExtended] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _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-01-01")) # type: str + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.DeploymentExtended] + polling = kwargs.pop("polling", True) # type: Union[bool, AsyncPollingMethod] + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token = kwargs.pop("continuation_token", None) # type: Optional[str] if cont_token is None: - raw_result = await self._create_or_update_at_scope_initial( + raw_result = await self._create_or_update_at_scope_initial( # type: ignore scope=scope, deployment_name=deployment_name, parameters=parameters, api_version=api_version, content_type=content_type, - cls=lambda x,y,z: x, + cls=lambda x, y, z: x, + headers=_headers, + params=_params, **kwargs ) - kwargs.pop('error_map', None) + kwargs.pop("error_map", None) def get_long_running_output(pipeline_response): - response = pipeline_response.http_response - deserialized = self._deserialize('DeploymentExtended', pipeline_response) + deserialized = self._deserialize("DeploymentExtended", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - - if polling is True: polling_method = AsyncARMPolling(lro_delay, **kwargs) - elif polling is False: polling_method = AsyncNoPolling() - else: polling_method = polling + if polling is True: + polling_method = cast(AsyncPollingMethod, AsyncARMPolling(lro_delay, **kwargs)) # type: AsyncPollingMethod + elif polling is False: + polling_method = cast(AsyncPollingMethod, AsyncNoPolling()) + else: + polling_method = polling if cont_token: return AsyncLROPoller.from_continuation_token( polling_method=polling_method, continuation_token=cont_token, client=self._client, - deserialization_callback=get_long_running_output + deserialization_callback=get_long_running_output, ) return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) - begin_create_or_update_at_scope.metadata = {'url': "/{scope}/providers/Microsoft.Resources/deployments/{deploymentName}"} # type: ignore + begin_create_or_update_at_scope.metadata = {"url": "/{scope}/providers/Microsoft.Resources/deployments/{deploymentName}"} # type: ignore @distributed_trace_async - async def get_at_scope( - self, - scope: str, - deployment_name: str, - **kwargs: Any - ) -> "_models.DeploymentExtended": + async def get_at_scope(self, scope: str, deployment_name: str, **kwargs: Any) -> _models.DeploymentExtended: """Gets a deployment. - :param scope: The resource scope. + :param scope: The resource scope. Required. :type scope: str - :param deployment_name: The name of the deployment. + :param deployment_name: The name of the deployment. Required. :type deployment_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: DeploymentExtended, or the result of cls(response) + :return: DeploymentExtended or the result of cls(response) :rtype: ~azure.mgmt.resource.resources.v2021_01_01.models.DeploymentExtended - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.DeploymentExtended"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) - api_version = kwargs.pop('api_version', "2021-01-01") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-01-01")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[_models.DeploymentExtended] - request = build_deployments_get_at_scope_request( scope=scope, deployment_name=deployment_name, api_version=api_version, - template_url=self.get_at_scope.metadata['url'], + template_url=self.get_at_scope.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) - deserialized = self._deserialize('DeploymentExtended', pipeline_response) + deserialized = self._deserialize("DeploymentExtended", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - get_at_scope.metadata = {'url': "/{scope}/providers/Microsoft.Resources/deployments/{deploymentName}"} # type: ignore - + get_at_scope.metadata = {"url": "/{scope}/providers/Microsoft.Resources/deployments/{deploymentName}"} # type: ignore @distributed_trace_async async def cancel_at_scope( # pylint: disable=inconsistent-return-statements - self, - scope: str, - deployment_name: str, - **kwargs: Any + self, scope: str, deployment_name: str, **kwargs: Any ) -> None: """Cancels a currently running template deployment. @@ -502,38 +693,44 @@ async def cancel_at_scope( # pylint: disable=inconsistent-return-statements deployment stops the currently running template deployment and leaves the resources partially deployed. - :param scope: The resource scope. + :param scope: The resource scope. Required. :type scope: str - :param deployment_name: The name of the deployment. + :param deployment_name: The name of the deployment. Required. :type deployment_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: None, or the result of cls(response) + :return: None or the result of cls(response) :rtype: None - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType[None] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + 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', "2021-01-01") # type: str + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-01-01")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[None] - request = build_deployments_cancel_at_scope_request( scope=scope, deployment_name=deployment_name, api_version=api_version, - template_url=self.cancel_at_scope.metadata['url'], + template_url=self.cancel_at_scope.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [204]: @@ -543,43 +740,52 @@ async def cancel_at_scope( # pylint: disable=inconsistent-return-statements if cls: return cls(pipeline_response, None, {}) - cancel_at_scope.metadata = {'url': "/{scope}/providers/Microsoft.Resources/deployments/{deploymentName}/cancel"} # type: ignore - + cancel_at_scope.metadata = {"url": "/{scope}/providers/Microsoft.Resources/deployments/{deploymentName}/cancel"} # type: ignore async def _validate_at_scope_initial( - self, - scope: str, - deployment_name: str, - parameters: "_models.Deployment", - **kwargs: Any - ) -> Optional["_models.DeploymentValidateResult"]: - cls = kwargs.pop('cls', None) # type: ClsType[Optional["_models.DeploymentValidateResult"]] + self, scope: str, deployment_name: str, parameters: Union[_models.Deployment, IO], **kwargs: Any + ) -> Optional[_models.DeploymentValidateResult]: error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) - api_version = kwargs.pop('api_version', "2021-01-01") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - _json = self._serialize.body(parameters, 'Deployment') + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-01-01")) # type: str + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[Optional[_models.DeploymentValidateResult]] - request = build_deployments_validate_at_scope_request_initial( + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(parameters, (IO, bytes)): + _content = parameters + else: + _json = self._serialize.body(parameters, "Deployment") + + request = build_deployments_validate_at_scope_request( scope=scope, deployment_name=deployment_name, api_version=api_version, content_type=content_type, json=_json, - template_url=self._validate_at_scope_initial.metadata['url'], + content=_content, + template_url=self._validate_at_scope_initial.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200, 202, 400]: @@ -588,36 +794,40 @@ async def _validate_at_scope_initial( deserialized = None if response.status_code == 200: - deserialized = self._deserialize('DeploymentValidateResult', pipeline_response) + deserialized = self._deserialize("DeploymentValidateResult", pipeline_response) if response.status_code == 400: - deserialized = self._deserialize('DeploymentValidateResult', pipeline_response) + deserialized = self._deserialize("DeploymentValidateResult", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - _validate_at_scope_initial.metadata = {'url': "/{scope}/providers/Microsoft.Resources/deployments/{deploymentName}/validate"} # type: ignore + _validate_at_scope_initial.metadata = {"url": "/{scope}/providers/Microsoft.Resources/deployments/{deploymentName}/validate"} # type: ignore - - @distributed_trace_async + @overload async def begin_validate_at_scope( self, scope: str, deployment_name: str, - parameters: "_models.Deployment", + parameters: _models.Deployment, + *, + content_type: str = "application/json", **kwargs: Any - ) -> AsyncLROPoller["_models.DeploymentValidateResult"]: + ) -> AsyncLROPoller[_models.DeploymentValidateResult]: """Validates whether the specified template is syntactically correct and will be accepted by Azure Resource Manager.. - :param scope: The resource scope. + :param scope: The resource scope. Required. :type scope: str - :param deployment_name: The name of the deployment. + :param deployment_name: The name of the deployment. Required. :type deployment_name: str - :param parameters: Parameters to validate. + :param parameters: Parameters to validate. Required. :type parameters: ~azure.mgmt.resource.resources.v2021_01_01.models.Deployment + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str :keyword callable cls: A custom type or function that will be passed the direct response :keyword str continuation_token: A continuation token to restart a poller from a saved state. :keyword polling: By default, your polling method will be AsyncARMPolling. Pass in False for @@ -630,119 +840,182 @@ async def begin_validate_at_scope( result of cls(response) :rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.resource.resources.v2021_01_01.models.DeploymentValidateResult] - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - api_version = kwargs.pop('api_version', "2021-01-01") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] - polling = kwargs.pop('polling', True) # type: Union[bool, AsyncPollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType["_models.DeploymentValidateResult"] - lro_delay = kwargs.pop( - 'polling_interval', - self._config.polling_interval - ) - cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] + + @overload + async def begin_validate_at_scope( + self, scope: str, deployment_name: str, parameters: IO, *, content_type: str = "application/json", **kwargs: Any + ) -> AsyncLROPoller[_models.DeploymentValidateResult]: + """Validates whether the specified template is syntactically correct and will be accepted by Azure + Resource Manager.. + + :param scope: The resource scope. Required. + :type scope: str + :param deployment_name: The name of the deployment. Required. + :type deployment_name: str + :param parameters: Parameters to validate. Required. + :type parameters: IO + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be AsyncARMPolling. Pass in False for + this operation to not poll, or pass in your own initialized polling object for a personal + polling strategy. + :paramtype polling: bool or ~azure.core.polling.AsyncPollingMethod + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of AsyncLROPoller that returns either DeploymentValidateResult or the + result of cls(response) + :rtype: + ~azure.core.polling.AsyncLROPoller[~azure.mgmt.resource.resources.v2021_01_01.models.DeploymentValidateResult] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace_async + async def begin_validate_at_scope( + self, scope: str, deployment_name: str, parameters: Union[_models.Deployment, IO], **kwargs: Any + ) -> AsyncLROPoller[_models.DeploymentValidateResult]: + """Validates whether the specified template is syntactically correct and will be accepted by Azure + Resource Manager.. + + :param scope: The resource scope. Required. + :type scope: str + :param deployment_name: The name of the deployment. Required. + :type deployment_name: str + :param parameters: Parameters to validate. Is either a model type or a IO type. Required. + :type parameters: ~azure.mgmt.resource.resources.v2021_01_01.models.Deployment or IO + :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. + Default value is None. + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be AsyncARMPolling. Pass in False for + this operation to not poll, or pass in your own initialized polling object for a personal + polling strategy. + :paramtype polling: bool or ~azure.core.polling.AsyncPollingMethod + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of AsyncLROPoller that returns either DeploymentValidateResult or the + result of cls(response) + :rtype: + ~azure.core.polling.AsyncLROPoller[~azure.mgmt.resource.resources.v2021_01_01.models.DeploymentValidateResult] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _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-01-01")) # type: str + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.DeploymentValidateResult] + polling = kwargs.pop("polling", True) # type: Union[bool, AsyncPollingMethod] + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token = kwargs.pop("continuation_token", None) # type: Optional[str] if cont_token is None: - raw_result = await self._validate_at_scope_initial( + raw_result = await self._validate_at_scope_initial( # type: ignore scope=scope, deployment_name=deployment_name, parameters=parameters, api_version=api_version, content_type=content_type, - cls=lambda x,y,z: x, + cls=lambda x, y, z: x, + headers=_headers, + params=_params, **kwargs ) - kwargs.pop('error_map', None) + kwargs.pop("error_map", None) def get_long_running_output(pipeline_response): - response = pipeline_response.http_response - deserialized = self._deserialize('DeploymentValidateResult', pipeline_response) + deserialized = self._deserialize("DeploymentValidateResult", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - - if polling is True: polling_method = AsyncARMPolling(lro_delay, **kwargs) - elif polling is False: polling_method = AsyncNoPolling() - else: polling_method = polling + if polling is True: + polling_method = cast(AsyncPollingMethod, AsyncARMPolling(lro_delay, **kwargs)) # type: AsyncPollingMethod + elif polling is False: + polling_method = cast(AsyncPollingMethod, AsyncNoPolling()) + else: + polling_method = polling if cont_token: return AsyncLROPoller.from_continuation_token( polling_method=polling_method, continuation_token=cont_token, client=self._client, - deserialization_callback=get_long_running_output + deserialization_callback=get_long_running_output, ) return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) - begin_validate_at_scope.metadata = {'url': "/{scope}/providers/Microsoft.Resources/deployments/{deploymentName}/validate"} # type: ignore + begin_validate_at_scope.metadata = {"url": "/{scope}/providers/Microsoft.Resources/deployments/{deploymentName}/validate"} # type: ignore @distributed_trace_async async def export_template_at_scope( - self, - scope: str, - deployment_name: str, - **kwargs: Any - ) -> "_models.DeploymentExportResult": + self, scope: str, deployment_name: str, **kwargs: Any + ) -> _models.DeploymentExportResult: """Exports the template used for specified deployment. - :param scope: The resource scope. + :param scope: The resource scope. Required. :type scope: str - :param deployment_name: The name of the deployment. + :param deployment_name: The name of the deployment. Required. :type deployment_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: DeploymentExportResult, or the result of cls(response) + :return: DeploymentExportResult or the result of cls(response) :rtype: ~azure.mgmt.resource.resources.v2021_01_01.models.DeploymentExportResult - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.DeploymentExportResult"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + 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', "2021-01-01") # type: str + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-01-01")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[_models.DeploymentExportResult] - request = build_deployments_export_template_at_scope_request( scope=scope, deployment_name=deployment_name, api_version=api_version, - template_url=self.export_template_at_scope.metadata['url'], + template_url=self.export_template_at_scope.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) - deserialized = self._deserialize('DeploymentExportResult', pipeline_response) + deserialized = self._deserialize("DeploymentExportResult", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - export_template_at_scope.metadata = {'url': "/{scope}/providers/Microsoft.Resources/deployments/{deploymentName}/exportTemplate"} # type: ignore - + export_template_at_scope.metadata = {"url": "/{scope}/providers/Microsoft.Resources/deployments/{deploymentName}/exportTemplate"} # type: ignore @distributed_trace def list_at_scope( - self, - scope: str, - filter: Optional[str] = None, - top: Optional[int] = None, - **kwargs: Any - ) -> AsyncIterable["_models.DeploymentListResult"]: + self, scope: str, filter: Optional[str] = None, top: Optional[int] = None, **kwargs: Any + ) -> AsyncIterable["_models.DeploymentExtended"]: """Get all the deployments at the given scope. - :param scope: The resource scope. + :param scope: The resource scope. Required. :type scope: str :param filter: The filter to apply on the operation. For example, you can use $filter=provisioningState eq '{state}'. Default value is None. @@ -751,40 +1024,48 @@ def list_at_scope( value is None. :type top: int :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either DeploymentListResult or the result of - cls(response) + :return: An iterator like instance of either DeploymentExtended or the result of cls(response) :rtype: - ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.resource.resources.v2021_01_01.models.DeploymentListResult] - :raises: ~azure.core.exceptions.HttpResponseError + ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.resource.resources.v2021_01_01.models.DeploymentExtended] + :raises ~azure.core.exceptions.HttpResponseError: """ - api_version = kwargs.pop('api_version', "2021-01-01") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-01-01")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[_models.DeploymentListResult] - cls = kwargs.pop('cls', None) # type: ClsType["_models.DeploymentListResult"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) + def prepare_request(next_link=None): if not next_link: - + request = build_deployments_list_at_scope_request( scope=scope, - api_version=api_version, filter=filter, top=top, - template_url=self.list_at_scope.metadata['url'], + api_version=api_version, + template_url=self.list_at_scope.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore else: - - request = build_deployments_list_at_scope_request( - scope=scope, - template_url=next_link, - ) + # make call to next link with the client's api-version + _parsed_next_link = urlparse(next_link) + _next_request_params = case_insensitive_dict(parse_qs(_parsed_next_link.query)) + _next_request_params["api-version"] = self._config.api_version + request = HttpRequest("GET", urljoin(next_link, _parsed_next_link.path), params=_next_request_params) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore request.method = "GET" return request @@ -798,10 +1079,8 @@ async def extract_data(pipeline_response): async def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) response = pipeline_response.http_response @@ -811,39 +1090,41 @@ async def get_next(next_link=None): return pipeline_response + return AsyncItemPaged(get_next, extract_data) - return AsyncItemPaged( - get_next, extract_data - ) - list_at_scope.metadata = {'url': "/{scope}/providers/Microsoft.Resources/deployments/"} # type: ignore + list_at_scope.metadata = {"url": "/{scope}/providers/Microsoft.Resources/deployments/"} # type: ignore async def _delete_at_tenant_scope_initial( # pylint: disable=inconsistent-return-statements - self, - deployment_name: str, - **kwargs: Any + self, deployment_name: str, **kwargs: Any ) -> None: - cls = kwargs.pop('cls', None) # type: ClsType[None] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + 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', "2021-01-01") # type: str + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-01-01")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[None] - - request = build_deployments_delete_at_tenant_scope_request_initial( + request = build_deployments_delete_at_tenant_scope_request( deployment_name=deployment_name, api_version=api_version, - template_url=self._delete_at_tenant_scope_initial.metadata['url'], + template_url=self._delete_at_tenant_scope_initial.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [202, 204]: @@ -853,15 +1134,10 @@ async def _delete_at_tenant_scope_initial( # pylint: disable=inconsistent-retur if cls: return cls(pipeline_response, None, {}) - _delete_at_tenant_scope_initial.metadata = {'url': "/providers/Microsoft.Resources/deployments/{deploymentName}"} # type: ignore - + _delete_at_tenant_scope_initial.metadata = {"url": "/providers/Microsoft.Resources/deployments/{deploymentName}"} # type: ignore @distributed_trace_async - async def begin_delete_at_tenant_scope( # pylint: disable=inconsistent-return-statements - self, - deployment_name: str, - **kwargs: Any - ) -> AsyncLROPoller[None]: + async def begin_delete_at_tenant_scope(self, deployment_name: str, **kwargs: Any) -> AsyncLROPoller[None]: """Deletes a deployment from the deployment history. A template deployment that is currently running cannot be deleted. Deleting a template @@ -872,7 +1148,7 @@ async def begin_delete_at_tenant_scope( # pylint: disable=inconsistent-return-s process finishes, the URI in the Location header returns a status of 204 on success. If the asynchronous request failed, the URI in the Location header returns an error-level status code. - :param deployment_name: The name of the deployment. + :param deployment_name: The name of the deployment. Required. :type deployment_name: str :keyword callable cls: A custom type or function that will be passed the direct response :keyword str continuation_token: A continuation token to restart a poller from a saved state. @@ -884,81 +1160,87 @@ async def begin_delete_at_tenant_scope( # pylint: disable=inconsistent-return-s Retry-After header is present. :return: An instance of AsyncLROPoller that returns either None or the result of cls(response) :rtype: ~azure.core.polling.AsyncLROPoller[None] - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - api_version = kwargs.pop('api_version', "2021-01-01") # type: str - polling = kwargs.pop('polling', True) # type: Union[bool, AsyncPollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType[None] - lro_delay = kwargs.pop( - 'polling_interval', - self._config.polling_interval - ) - cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-01-01")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[None] + polling = kwargs.pop("polling", True) # type: Union[bool, AsyncPollingMethod] + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token = kwargs.pop("continuation_token", None) # type: Optional[str] if cont_token is None: - raw_result = await self._delete_at_tenant_scope_initial( + raw_result = await self._delete_at_tenant_scope_initial( # type: ignore deployment_name=deployment_name, api_version=api_version, - cls=lambda x,y,z: x, + cls=lambda x, y, z: x, + headers=_headers, + params=_params, **kwargs ) - kwargs.pop('error_map', None) + kwargs.pop("error_map", None) - def get_long_running_output(pipeline_response): + def get_long_running_output(pipeline_response): # pylint: disable=inconsistent-return-statements if cls: return cls(pipeline_response, None, {}) - - if polling is True: polling_method = AsyncARMPolling(lro_delay, **kwargs) - elif polling is False: polling_method = AsyncNoPolling() - else: polling_method = polling + if polling is True: + polling_method = cast(AsyncPollingMethod, AsyncARMPolling(lro_delay, **kwargs)) # type: AsyncPollingMethod + elif polling is False: + polling_method = cast(AsyncPollingMethod, AsyncNoPolling()) + else: + polling_method = polling if cont_token: return AsyncLROPoller.from_continuation_token( polling_method=polling_method, continuation_token=cont_token, client=self._client, - deserialization_callback=get_long_running_output + deserialization_callback=get_long_running_output, ) return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) - begin_delete_at_tenant_scope.metadata = {'url': "/providers/Microsoft.Resources/deployments/{deploymentName}"} # type: ignore + begin_delete_at_tenant_scope.metadata = {"url": "/providers/Microsoft.Resources/deployments/{deploymentName}"} # type: ignore @distributed_trace_async - async def check_existence_at_tenant_scope( - self, - deployment_name: str, - **kwargs: Any - ) -> bool: + async def check_existence_at_tenant_scope(self, deployment_name: str, **kwargs: Any) -> bool: """Checks whether the deployment exists. - :param deployment_name: The name of the deployment. + :param deployment_name: The name of the deployment. Required. :type deployment_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: bool, or the result of cls(response) + :return: bool or the result of cls(response) :rtype: bool - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType[None] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + 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', "2021-01-01") # type: str + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-01-01")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[None] - request = build_deployments_check_existence_at_tenant_scope_request( deployment_name=deployment_name, api_version=api_version, - template_url=self.check_existence_at_tenant_scope.metadata['url'], + template_url=self.check_existence_at_tenant_scope.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [204, 404]: @@ -969,41 +1251,51 @@ async def check_existence_at_tenant_scope( return cls(pipeline_response, None, {}) return 200 <= response.status_code <= 299 - check_existence_at_tenant_scope.metadata = {'url': "/providers/Microsoft.Resources/deployments/{deploymentName}"} # type: ignore - + check_existence_at_tenant_scope.metadata = {"url": "/providers/Microsoft.Resources/deployments/{deploymentName}"} # type: ignore async def _create_or_update_at_tenant_scope_initial( - self, - deployment_name: str, - parameters: "_models.ScopedDeployment", - **kwargs: Any - ) -> "_models.DeploymentExtended": - cls = kwargs.pop('cls', None) # type: ClsType["_models.DeploymentExtended"] + self, deployment_name: str, parameters: Union[_models.ScopedDeployment, IO], **kwargs: Any + ) -> _models.DeploymentExtended: error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', "2021-01-01") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-01-01")) # type: str + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.DeploymentExtended] - _json = self._serialize.body(parameters, 'ScopedDeployment') + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(parameters, (IO, bytes)): + _content = parameters + else: + _json = self._serialize.body(parameters, "ScopedDeployment") - request = build_deployments_create_or_update_at_tenant_scope_request_initial( + request = build_deployments_create_or_update_at_tenant_scope_request( deployment_name=deployment_name, api_version=api_version, content_type=content_type, json=_json, - template_url=self._create_or_update_at_tenant_scope_initial.metadata['url'], + content=_content, + template_url=self._create_or_update_at_tenant_scope_initial.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200, 201]: @@ -1011,34 +1303,38 @@ async def _create_or_update_at_tenant_scope_initial( raise HttpResponseError(response=response, error_format=ARMErrorFormat) if response.status_code == 200: - deserialized = self._deserialize('DeploymentExtended', pipeline_response) + deserialized = self._deserialize("DeploymentExtended", pipeline_response) if response.status_code == 201: - deserialized = self._deserialize('DeploymentExtended', pipeline_response) + deserialized = self._deserialize("DeploymentExtended", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - _create_or_update_at_tenant_scope_initial.metadata = {'url': "/providers/Microsoft.Resources/deployments/{deploymentName}"} # type: ignore - + _create_or_update_at_tenant_scope_initial.metadata = {"url": "/providers/Microsoft.Resources/deployments/{deploymentName}"} # type: ignore - @distributed_trace_async + @overload async def begin_create_or_update_at_tenant_scope( self, deployment_name: str, - parameters: "_models.ScopedDeployment", + parameters: _models.ScopedDeployment, + *, + content_type: str = "application/json", **kwargs: Any - ) -> AsyncLROPoller["_models.DeploymentExtended"]: + ) -> AsyncLROPoller[_models.DeploymentExtended]: """Deploys resources at tenant scope. You can provide the template and parameters directly in the request or link to JSON files. - :param deployment_name: The name of the deployment. + :param deployment_name: The name of the deployment. Required. :type deployment_name: str - :param parameters: Additional parameters supplied to the operation. + :param parameters: Additional parameters supplied to the operation. Required. :type parameters: ~azure.mgmt.resource.resources.v2021_01_01.models.ScopedDeployment + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str :keyword callable cls: A custom type or function that will be passed the direct response :keyword str continuation_token: A continuation token to restart a poller from a saved state. :keyword polling: By default, your polling method will be AsyncARMPolling. Pass in False for @@ -1051,108 +1347,171 @@ async def begin_create_or_update_at_tenant_scope( cls(response) :rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.resource.resources.v2021_01_01.models.DeploymentExtended] - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - api_version = kwargs.pop('api_version', "2021-01-01") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] - polling = kwargs.pop('polling', True) # type: Union[bool, AsyncPollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType["_models.DeploymentExtended"] - lro_delay = kwargs.pop( - 'polling_interval', - self._config.polling_interval - ) - cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] + + @overload + async def begin_create_or_update_at_tenant_scope( + self, deployment_name: str, parameters: IO, *, content_type: str = "application/json", **kwargs: Any + ) -> AsyncLROPoller[_models.DeploymentExtended]: + """Deploys resources at tenant scope. + + You can provide the template and parameters directly in the request or link to JSON files. + + :param deployment_name: The name of the deployment. Required. + :type deployment_name: str + :param parameters: Additional parameters supplied to the operation. Required. + :type parameters: IO + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be AsyncARMPolling. Pass in False for + this operation to not poll, or pass in your own initialized polling object for a personal + polling strategy. + :paramtype polling: bool or ~azure.core.polling.AsyncPollingMethod + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of AsyncLROPoller that returns either DeploymentExtended or the result of + cls(response) + :rtype: + ~azure.core.polling.AsyncLROPoller[~azure.mgmt.resource.resources.v2021_01_01.models.DeploymentExtended] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace_async + async def begin_create_or_update_at_tenant_scope( + self, deployment_name: str, parameters: Union[_models.ScopedDeployment, IO], **kwargs: Any + ) -> AsyncLROPoller[_models.DeploymentExtended]: + """Deploys resources at tenant scope. + + You can provide the template and parameters directly in the request or link to JSON files. + + :param deployment_name: The name of the deployment. Required. + :type deployment_name: str + :param parameters: Additional parameters supplied to the operation. Is either a model type or a + IO type. Required. + :type parameters: ~azure.mgmt.resource.resources.v2021_01_01.models.ScopedDeployment or IO + :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. + Default value is None. + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be AsyncARMPolling. Pass in False for + this operation to not poll, or pass in your own initialized polling object for a personal + polling strategy. + :paramtype polling: bool or ~azure.core.polling.AsyncPollingMethod + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of AsyncLROPoller that returns either DeploymentExtended or the result of + cls(response) + :rtype: + ~azure.core.polling.AsyncLROPoller[~azure.mgmt.resource.resources.v2021_01_01.models.DeploymentExtended] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _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-01-01")) # type: str + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.DeploymentExtended] + polling = kwargs.pop("polling", True) # type: Union[bool, AsyncPollingMethod] + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token = kwargs.pop("continuation_token", None) # type: Optional[str] if cont_token is None: - raw_result = await self._create_or_update_at_tenant_scope_initial( + raw_result = await self._create_or_update_at_tenant_scope_initial( # type: ignore deployment_name=deployment_name, parameters=parameters, api_version=api_version, content_type=content_type, - cls=lambda x,y,z: x, + cls=lambda x, y, z: x, + headers=_headers, + params=_params, **kwargs ) - kwargs.pop('error_map', None) + kwargs.pop("error_map", None) def get_long_running_output(pipeline_response): - response = pipeline_response.http_response - deserialized = self._deserialize('DeploymentExtended', pipeline_response) + deserialized = self._deserialize("DeploymentExtended", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - - if polling is True: polling_method = AsyncARMPolling(lro_delay, **kwargs) - elif polling is False: polling_method = AsyncNoPolling() - else: polling_method = polling + if polling is True: + polling_method = cast(AsyncPollingMethod, AsyncARMPolling(lro_delay, **kwargs)) # type: AsyncPollingMethod + elif polling is False: + polling_method = cast(AsyncPollingMethod, AsyncNoPolling()) + else: + polling_method = polling if cont_token: return AsyncLROPoller.from_continuation_token( polling_method=polling_method, continuation_token=cont_token, client=self._client, - deserialization_callback=get_long_running_output + deserialization_callback=get_long_running_output, ) return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) - begin_create_or_update_at_tenant_scope.metadata = {'url': "/providers/Microsoft.Resources/deployments/{deploymentName}"} # type: ignore + begin_create_or_update_at_tenant_scope.metadata = {"url": "/providers/Microsoft.Resources/deployments/{deploymentName}"} # type: ignore @distributed_trace_async - async def get_at_tenant_scope( - self, - deployment_name: str, - **kwargs: Any - ) -> "_models.DeploymentExtended": + async def get_at_tenant_scope(self, deployment_name: str, **kwargs: Any) -> _models.DeploymentExtended: """Gets a deployment. - :param deployment_name: The name of the deployment. + :param deployment_name: The name of the deployment. Required. :type deployment_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: DeploymentExtended, or the result of cls(response) + :return: DeploymentExtended or the result of cls(response) :rtype: ~azure.mgmt.resource.resources.v2021_01_01.models.DeploymentExtended - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.DeploymentExtended"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) - api_version = kwargs.pop('api_version', "2021-01-01") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-01-01")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[_models.DeploymentExtended] - request = build_deployments_get_at_tenant_scope_request( deployment_name=deployment_name, api_version=api_version, - template_url=self.get_at_tenant_scope.metadata['url'], + template_url=self.get_at_tenant_scope.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) - deserialized = self._deserialize('DeploymentExtended', pipeline_response) + deserialized = self._deserialize("DeploymentExtended", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - get_at_tenant_scope.metadata = {'url': "/providers/Microsoft.Resources/deployments/{deploymentName}"} # type: ignore - + get_at_tenant_scope.metadata = {"url": "/providers/Microsoft.Resources/deployments/{deploymentName}"} # type: ignore @distributed_trace_async async def cancel_at_tenant_scope( # pylint: disable=inconsistent-return-statements - self, - deployment_name: str, - **kwargs: Any + self, deployment_name: str, **kwargs: Any ) -> None: """Cancels a currently running template deployment. @@ -1161,35 +1520,41 @@ async def cancel_at_tenant_scope( # pylint: disable=inconsistent-return-stateme deployment stops the currently running template deployment and leaves the resources partially deployed. - :param deployment_name: The name of the deployment. + :param deployment_name: The name of the deployment. Required. :type deployment_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: None, or the result of cls(response) + :return: None or the result of cls(response) :rtype: None - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType[None] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) - api_version = kwargs.pop('api_version', "2021-01-01") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-01-01")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[None] - request = build_deployments_cancel_at_tenant_scope_request( deployment_name=deployment_name, api_version=api_version, - template_url=self.cancel_at_tenant_scope.metadata['url'], + template_url=self.cancel_at_tenant_scope.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [204]: @@ -1199,41 +1564,51 @@ async def cancel_at_tenant_scope( # pylint: disable=inconsistent-return-stateme if cls: return cls(pipeline_response, None, {}) - cancel_at_tenant_scope.metadata = {'url': "/providers/Microsoft.Resources/deployments/{deploymentName}/cancel"} # type: ignore - + cancel_at_tenant_scope.metadata = {"url": "/providers/Microsoft.Resources/deployments/{deploymentName}/cancel"} # type: ignore async def _validate_at_tenant_scope_initial( - self, - deployment_name: str, - parameters: "_models.ScopedDeployment", - **kwargs: Any - ) -> Optional["_models.DeploymentValidateResult"]: - cls = kwargs.pop('cls', None) # type: ClsType[Optional["_models.DeploymentValidateResult"]] + self, deployment_name: str, parameters: Union[_models.ScopedDeployment, IO], **kwargs: Any + ) -> Optional[_models.DeploymentValidateResult]: error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) - api_version = kwargs.pop('api_version', "2021-01-01") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - _json = self._serialize.body(parameters, 'ScopedDeployment') + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-01-01")) # type: str + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[Optional[_models.DeploymentValidateResult]] - request = build_deployments_validate_at_tenant_scope_request_initial( + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(parameters, (IO, bytes)): + _content = parameters + else: + _json = self._serialize.body(parameters, "ScopedDeployment") + + request = build_deployments_validate_at_tenant_scope_request( deployment_name=deployment_name, api_version=api_version, content_type=content_type, json=_json, - template_url=self._validate_at_tenant_scope_initial.metadata['url'], + content=_content, + template_url=self._validate_at_tenant_scope_initial.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200, 202, 400]: @@ -1242,33 +1617,37 @@ async def _validate_at_tenant_scope_initial( deserialized = None if response.status_code == 200: - deserialized = self._deserialize('DeploymentValidateResult', pipeline_response) + deserialized = self._deserialize("DeploymentValidateResult", pipeline_response) if response.status_code == 400: - deserialized = self._deserialize('DeploymentValidateResult', pipeline_response) + deserialized = self._deserialize("DeploymentValidateResult", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - _validate_at_tenant_scope_initial.metadata = {'url': "/providers/Microsoft.Resources/deployments/{deploymentName}/validate"} # type: ignore + _validate_at_tenant_scope_initial.metadata = {"url": "/providers/Microsoft.Resources/deployments/{deploymentName}/validate"} # type: ignore - - @distributed_trace_async + @overload async def begin_validate_at_tenant_scope( self, deployment_name: str, - parameters: "_models.ScopedDeployment", + parameters: _models.ScopedDeployment, + *, + content_type: str = "application/json", **kwargs: Any - ) -> AsyncLROPoller["_models.DeploymentValidateResult"]: + ) -> AsyncLROPoller[_models.DeploymentValidateResult]: """Validates whether the specified template is syntactically correct and will be accepted by Azure Resource Manager.. - :param deployment_name: The name of the deployment. + :param deployment_name: The name of the deployment. Required. :type deployment_name: str - :param parameters: Parameters to validate. + :param parameters: Parameters to validate. Required. :type parameters: ~azure.mgmt.resource.resources.v2021_01_01.models.ScopedDeployment + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str :keyword callable cls: A custom type or function that will be passed the direct response :keyword str continuation_token: A continuation token to restart a poller from a saved state. :keyword polling: By default, your polling method will be AsyncARMPolling. Pass in False for @@ -1281,82 +1660,154 @@ async def begin_validate_at_tenant_scope( result of cls(response) :rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.resource.resources.v2021_01_01.models.DeploymentValidateResult] - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - api_version = kwargs.pop('api_version', "2021-01-01") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] - polling = kwargs.pop('polling', True) # type: Union[bool, AsyncPollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType["_models.DeploymentValidateResult"] - lro_delay = kwargs.pop( - 'polling_interval', - self._config.polling_interval - ) - cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] + + @overload + async def begin_validate_at_tenant_scope( + self, deployment_name: str, parameters: IO, *, content_type: str = "application/json", **kwargs: Any + ) -> AsyncLROPoller[_models.DeploymentValidateResult]: + """Validates whether the specified template is syntactically correct and will be accepted by Azure + Resource Manager.. + + :param deployment_name: The name of the deployment. Required. + :type deployment_name: str + :param parameters: Parameters to validate. Required. + :type parameters: IO + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be AsyncARMPolling. Pass in False for + this operation to not poll, or pass in your own initialized polling object for a personal + polling strategy. + :paramtype polling: bool or ~azure.core.polling.AsyncPollingMethod + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of AsyncLROPoller that returns either DeploymentValidateResult or the + result of cls(response) + :rtype: + ~azure.core.polling.AsyncLROPoller[~azure.mgmt.resource.resources.v2021_01_01.models.DeploymentValidateResult] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace_async + async def begin_validate_at_tenant_scope( + self, deployment_name: str, parameters: Union[_models.ScopedDeployment, IO], **kwargs: Any + ) -> AsyncLROPoller[_models.DeploymentValidateResult]: + """Validates whether the specified template is syntactically correct and will be accepted by Azure + Resource Manager.. + + :param deployment_name: The name of the deployment. Required. + :type deployment_name: str + :param parameters: Parameters to validate. Is either a model type or a IO type. Required. + :type parameters: ~azure.mgmt.resource.resources.v2021_01_01.models.ScopedDeployment or IO + :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. + Default value is None. + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be AsyncARMPolling. Pass in False for + this operation to not poll, or pass in your own initialized polling object for a personal + polling strategy. + :paramtype polling: bool or ~azure.core.polling.AsyncPollingMethod + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of AsyncLROPoller that returns either DeploymentValidateResult or the + result of cls(response) + :rtype: + ~azure.core.polling.AsyncLROPoller[~azure.mgmt.resource.resources.v2021_01_01.models.DeploymentValidateResult] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _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-01-01")) # type: str + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.DeploymentValidateResult] + polling = kwargs.pop("polling", True) # type: Union[bool, AsyncPollingMethod] + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token = kwargs.pop("continuation_token", None) # type: Optional[str] if cont_token is None: - raw_result = await self._validate_at_tenant_scope_initial( + raw_result = await self._validate_at_tenant_scope_initial( # type: ignore deployment_name=deployment_name, parameters=parameters, api_version=api_version, content_type=content_type, - cls=lambda x,y,z: x, + cls=lambda x, y, z: x, + headers=_headers, + params=_params, **kwargs ) - kwargs.pop('error_map', None) + kwargs.pop("error_map", None) def get_long_running_output(pipeline_response): - response = pipeline_response.http_response - deserialized = self._deserialize('DeploymentValidateResult', pipeline_response) + deserialized = self._deserialize("DeploymentValidateResult", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - - if polling is True: polling_method = AsyncARMPolling(lro_delay, **kwargs) - elif polling is False: polling_method = AsyncNoPolling() - else: polling_method = polling + if polling is True: + polling_method = cast(AsyncPollingMethod, AsyncARMPolling(lro_delay, **kwargs)) # type: AsyncPollingMethod + elif polling is False: + polling_method = cast(AsyncPollingMethod, AsyncNoPolling()) + else: + polling_method = polling if cont_token: return AsyncLROPoller.from_continuation_token( polling_method=polling_method, continuation_token=cont_token, client=self._client, - deserialization_callback=get_long_running_output + deserialization_callback=get_long_running_output, ) return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) - begin_validate_at_tenant_scope.metadata = {'url': "/providers/Microsoft.Resources/deployments/{deploymentName}/validate"} # type: ignore + begin_validate_at_tenant_scope.metadata = {"url": "/providers/Microsoft.Resources/deployments/{deploymentName}/validate"} # type: ignore async def _what_if_at_tenant_scope_initial( - self, - deployment_name: str, - parameters: "_models.ScopedDeploymentWhatIf", - **kwargs: Any - ) -> Optional["_models.WhatIfOperationResult"]: - cls = kwargs.pop('cls', None) # type: ClsType[Optional["_models.WhatIfOperationResult"]] + self, deployment_name: str, parameters: Union[_models.ScopedDeploymentWhatIf, IO], **kwargs: Any + ) -> Optional[_models.WhatIfOperationResult]: error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) - api_version = kwargs.pop('api_version', "2021-01-01") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - _json = self._serialize.body(parameters, 'ScopedDeploymentWhatIf') + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-01-01")) # type: str + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[Optional[_models.WhatIfOperationResult]] - request = build_deployments_what_if_at_tenant_scope_request_initial( + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(parameters, (IO, bytes)): + _content = parameters + else: + _json = self._serialize.body(parameters, "ScopedDeploymentWhatIf") + + request = build_deployments_what_if_at_tenant_scope_request( deployment_name=deployment_name, api_version=api_version, content_type=content_type, json=_json, - template_url=self._what_if_at_tenant_scope_initial.metadata['url'], + content=_content, + template_url=self._what_if_at_tenant_scope_initial.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200, 202]: @@ -1366,35 +1817,38 @@ async def _what_if_at_tenant_scope_initial( deserialized = None response_headers = {} if response.status_code == 200: - deserialized = self._deserialize('WhatIfOperationResult', pipeline_response) + deserialized = self._deserialize("WhatIfOperationResult", pipeline_response) if response.status_code == 202: - response_headers['Location']=self._deserialize('str', response.headers.get('Location')) - response_headers['Retry-After']=self._deserialize('str', response.headers.get('Retry-After')) - + response_headers["Location"] = self._deserialize("str", response.headers.get("Location")) + response_headers["Retry-After"] = self._deserialize("str", response.headers.get("Retry-After")) if cls: return cls(pipeline_response, deserialized, response_headers) return deserialized - _what_if_at_tenant_scope_initial.metadata = {'url': "/providers/Microsoft.Resources/deployments/{deploymentName}/whatIf"} # type: ignore + _what_if_at_tenant_scope_initial.metadata = {"url": "/providers/Microsoft.Resources/deployments/{deploymentName}/whatIf"} # type: ignore - - @distributed_trace_async + @overload async def begin_what_if_at_tenant_scope( self, deployment_name: str, - parameters: "_models.ScopedDeploymentWhatIf", + parameters: _models.ScopedDeploymentWhatIf, + *, + content_type: str = "application/json", **kwargs: Any - ) -> AsyncLROPoller["_models.WhatIfOperationResult"]: + ) -> AsyncLROPoller[_models.WhatIfOperationResult]: """Returns changes that will be made by the deployment if executed at the scope of the tenant group. - :param deployment_name: The name of the deployment. + :param deployment_name: The name of the deployment. Required. :type deployment_name: str - :param parameters: Parameters to validate. + :param parameters: Parameters to validate. Required. :type parameters: ~azure.mgmt.resource.resources.v2021_01_01.models.ScopedDeploymentWhatIf + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str :keyword callable cls: A custom type or function that will be passed the direct response :keyword str continuation_token: A continuation token to restart a poller from a saved state. :keyword polling: By default, your polling method will be AsyncARMPolling. Pass in False for @@ -1407,110 +1861,174 @@ async def begin_what_if_at_tenant_scope( of cls(response) :rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.resource.resources.v2021_01_01.models.WhatIfOperationResult] - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - api_version = kwargs.pop('api_version', "2021-01-01") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] - polling = kwargs.pop('polling', True) # type: Union[bool, AsyncPollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType["_models.WhatIfOperationResult"] - lro_delay = kwargs.pop( - 'polling_interval', - self._config.polling_interval - ) - cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] + + @overload + async def begin_what_if_at_tenant_scope( + self, deployment_name: str, parameters: IO, *, content_type: str = "application/json", **kwargs: Any + ) -> AsyncLROPoller[_models.WhatIfOperationResult]: + """Returns changes that will be made by the deployment if executed at the scope of the tenant + group. + + :param deployment_name: The name of the deployment. Required. + :type deployment_name: str + :param parameters: Parameters to validate. Required. + :type parameters: IO + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be AsyncARMPolling. Pass in False for + this operation to not poll, or pass in your own initialized polling object for a personal + polling strategy. + :paramtype polling: bool or ~azure.core.polling.AsyncPollingMethod + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of AsyncLROPoller that returns either WhatIfOperationResult or the result + of cls(response) + :rtype: + ~azure.core.polling.AsyncLROPoller[~azure.mgmt.resource.resources.v2021_01_01.models.WhatIfOperationResult] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace_async + async def begin_what_if_at_tenant_scope( + self, deployment_name: str, parameters: Union[_models.ScopedDeploymentWhatIf, IO], **kwargs: Any + ) -> AsyncLROPoller[_models.WhatIfOperationResult]: + """Returns changes that will be made by the deployment if executed at the scope of the tenant + group. + + :param deployment_name: The name of the deployment. Required. + :type deployment_name: str + :param parameters: Parameters to validate. Is either a model type or a IO type. Required. + :type parameters: ~azure.mgmt.resource.resources.v2021_01_01.models.ScopedDeploymentWhatIf or + IO + :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. + Default value is None. + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be AsyncARMPolling. Pass in False for + this operation to not poll, or pass in your own initialized polling object for a personal + polling strategy. + :paramtype polling: bool or ~azure.core.polling.AsyncPollingMethod + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of AsyncLROPoller that returns either WhatIfOperationResult or the result + of cls(response) + :rtype: + ~azure.core.polling.AsyncLROPoller[~azure.mgmt.resource.resources.v2021_01_01.models.WhatIfOperationResult] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _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-01-01")) # type: str + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.WhatIfOperationResult] + polling = kwargs.pop("polling", True) # type: Union[bool, AsyncPollingMethod] + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token = kwargs.pop("continuation_token", None) # type: Optional[str] if cont_token is None: - raw_result = await self._what_if_at_tenant_scope_initial( + raw_result = await self._what_if_at_tenant_scope_initial( # type: ignore deployment_name=deployment_name, parameters=parameters, api_version=api_version, content_type=content_type, - cls=lambda x,y,z: x, + cls=lambda x, y, z: x, + headers=_headers, + params=_params, **kwargs ) - kwargs.pop('error_map', None) + kwargs.pop("error_map", None) def get_long_running_output(pipeline_response): - response = pipeline_response.http_response - deserialized = self._deserialize('WhatIfOperationResult', pipeline_response) + deserialized = self._deserialize("WhatIfOperationResult", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - - if polling is True: polling_method = AsyncARMPolling(lro_delay, lro_options={'final-state-via': 'location'}, **kwargs) - elif polling is False: polling_method = AsyncNoPolling() - else: polling_method = polling + if polling is True: + polling_method = cast( + AsyncPollingMethod, AsyncARMPolling(lro_delay, lro_options={"final-state-via": "location"}, **kwargs) + ) # type: AsyncPollingMethod + elif polling is False: + polling_method = cast(AsyncPollingMethod, AsyncNoPolling()) + else: + polling_method = polling if cont_token: return AsyncLROPoller.from_continuation_token( polling_method=polling_method, continuation_token=cont_token, client=self._client, - deserialization_callback=get_long_running_output + deserialization_callback=get_long_running_output, ) return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) - begin_what_if_at_tenant_scope.metadata = {'url': "/providers/Microsoft.Resources/deployments/{deploymentName}/whatIf"} # type: ignore + begin_what_if_at_tenant_scope.metadata = {"url": "/providers/Microsoft.Resources/deployments/{deploymentName}/whatIf"} # type: ignore @distributed_trace_async async def export_template_at_tenant_scope( - self, - deployment_name: str, - **kwargs: Any - ) -> "_models.DeploymentExportResult": + self, deployment_name: str, **kwargs: Any + ) -> _models.DeploymentExportResult: """Exports the template used for specified deployment. - :param deployment_name: The name of the deployment. + :param deployment_name: The name of the deployment. Required. :type deployment_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: DeploymentExportResult, or the result of cls(response) + :return: DeploymentExportResult or the result of cls(response) :rtype: ~azure.mgmt.resource.resources.v2021_01_01.models.DeploymentExportResult - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.DeploymentExportResult"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) - api_version = kwargs.pop('api_version', "2021-01-01") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-01-01")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[_models.DeploymentExportResult] - request = build_deployments_export_template_at_tenant_scope_request( deployment_name=deployment_name, api_version=api_version, - template_url=self.export_template_at_tenant_scope.metadata['url'], + template_url=self.export_template_at_tenant_scope.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) - deserialized = self._deserialize('DeploymentExportResult', pipeline_response) + deserialized = self._deserialize("DeploymentExportResult", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - export_template_at_tenant_scope.metadata = {'url': "/providers/Microsoft.Resources/deployments/{deploymentName}/exportTemplate"} # type: ignore - + export_template_at_tenant_scope.metadata = {"url": "/providers/Microsoft.Resources/deployments/{deploymentName}/exportTemplate"} # type: ignore @distributed_trace def list_at_tenant_scope( - self, - filter: Optional[str] = None, - top: Optional[int] = None, - **kwargs: Any - ) -> AsyncIterable["_models.DeploymentListResult"]: + self, filter: Optional[str] = None, top: Optional[int] = None, **kwargs: Any + ) -> AsyncIterable["_models.DeploymentExtended"]: """Get all the deployments at the tenant scope. :param filter: The filter to apply on the operation. For example, you can use @@ -1520,38 +2038,47 @@ def list_at_tenant_scope( value is None. :type top: int :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either DeploymentListResult or the result of - cls(response) + :return: An iterator like instance of either DeploymentExtended or the result of cls(response) :rtype: - ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.resource.resources.v2021_01_01.models.DeploymentListResult] - :raises: ~azure.core.exceptions.HttpResponseError + ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.resource.resources.v2021_01_01.models.DeploymentExtended] + :raises ~azure.core.exceptions.HttpResponseError: """ - api_version = kwargs.pop('api_version', "2021-01-01") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-01-01")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[_models.DeploymentListResult] - cls = kwargs.pop('cls', None) # type: ClsType["_models.DeploymentListResult"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) + def prepare_request(next_link=None): if not next_link: - + request = build_deployments_list_at_tenant_scope_request( - api_version=api_version, filter=filter, top=top, - template_url=self.list_at_tenant_scope.metadata['url'], + api_version=api_version, + template_url=self.list_at_tenant_scope.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore else: - - request = build_deployments_list_at_tenant_scope_request( - template_url=next_link, - ) + # make call to next link with the client's api-version + _parsed_next_link = urlparse(next_link) + _next_request_params = case_insensitive_dict(parse_qs(_parsed_next_link.query)) + _next_request_params["api-version"] = self._config.api_version + request = HttpRequest("GET", urljoin(next_link, _parsed_next_link.path), params=_next_request_params) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore request.method = "GET" return request @@ -1565,10 +2092,8 @@ async def extract_data(pipeline_response): async def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) response = pipeline_response.http_response @@ -1578,41 +2103,42 @@ async def get_next(next_link=None): return pipeline_response + return AsyncItemPaged(get_next, extract_data) - return AsyncItemPaged( - get_next, extract_data - ) - list_at_tenant_scope.metadata = {'url': "/providers/Microsoft.Resources/deployments/"} # type: ignore + list_at_tenant_scope.metadata = {"url": "/providers/Microsoft.Resources/deployments/"} # type: ignore async def _delete_at_management_group_scope_initial( # pylint: disable=inconsistent-return-statements - self, - group_id: str, - deployment_name: str, - **kwargs: Any + self, group_id: str, deployment_name: str, **kwargs: Any ) -> None: - cls = kwargs.pop('cls', None) # type: ClsType[None] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + 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', "2021-01-01") # type: str + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-01-01")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[None] - - request = build_deployments_delete_at_management_group_scope_request_initial( + request = build_deployments_delete_at_management_group_scope_request( group_id=group_id, deployment_name=deployment_name, api_version=api_version, - template_url=self._delete_at_management_group_scope_initial.metadata['url'], + template_url=self._delete_at_management_group_scope_initial.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [202, 204]: @@ -1622,15 +2148,11 @@ async def _delete_at_management_group_scope_initial( # pylint: disable=inconsis if cls: return cls(pipeline_response, None, {}) - _delete_at_management_group_scope_initial.metadata = {'url': "/providers/Microsoft.Management/managementGroups/{groupId}/providers/Microsoft.Resources/deployments/{deploymentName}"} # type: ignore - + _delete_at_management_group_scope_initial.metadata = {"url": "/providers/Microsoft.Management/managementGroups/{groupId}/providers/Microsoft.Resources/deployments/{deploymentName}"} # type: ignore @distributed_trace_async - async def begin_delete_at_management_group_scope( # pylint: disable=inconsistent-return-statements - self, - group_id: str, - deployment_name: str, - **kwargs: Any + async def begin_delete_at_management_group_scope( + self, group_id: str, deployment_name: str, **kwargs: Any ) -> AsyncLROPoller[None]: """Deletes a deployment from the deployment history. @@ -1642,9 +2164,9 @@ async def begin_delete_at_management_group_scope( # pylint: disable=inconsisten process finishes, the URI in the Location header returns a status of 204 on success. If the asynchronous request failed, the URI in the Location header returns an error-level status code. - :param group_id: The management group ID. + :param group_id: The management group ID. Required. :type group_id: str - :param deployment_name: The name of the deployment. + :param deployment_name: The name of the deployment. Required. :type deployment_name: str :keyword callable cls: A custom type or function that will be passed the direct response :keyword str continuation_token: A continuation token to restart a poller from a saved state. @@ -1656,86 +2178,93 @@ async def begin_delete_at_management_group_scope( # pylint: disable=inconsisten Retry-After header is present. :return: An instance of AsyncLROPoller that returns either None or the result of cls(response) :rtype: ~azure.core.polling.AsyncLROPoller[None] - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - api_version = kwargs.pop('api_version', "2021-01-01") # type: str - polling = kwargs.pop('polling', True) # type: Union[bool, AsyncPollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType[None] - lro_delay = kwargs.pop( - 'polling_interval', - self._config.polling_interval - ) - cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-01-01")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[None] + polling = kwargs.pop("polling", True) # type: Union[bool, AsyncPollingMethod] + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token = kwargs.pop("continuation_token", None) # type: Optional[str] if cont_token is None: - raw_result = await self._delete_at_management_group_scope_initial( + raw_result = await self._delete_at_management_group_scope_initial( # type: ignore group_id=group_id, deployment_name=deployment_name, api_version=api_version, - cls=lambda x,y,z: x, + cls=lambda x, y, z: x, + headers=_headers, + params=_params, **kwargs ) - kwargs.pop('error_map', None) + kwargs.pop("error_map", None) - def get_long_running_output(pipeline_response): + def get_long_running_output(pipeline_response): # pylint: disable=inconsistent-return-statements if cls: return cls(pipeline_response, None, {}) - - if polling is True: polling_method = AsyncARMPolling(lro_delay, **kwargs) - elif polling is False: polling_method = AsyncNoPolling() - else: polling_method = polling + if polling is True: + polling_method = cast(AsyncPollingMethod, AsyncARMPolling(lro_delay, **kwargs)) # type: AsyncPollingMethod + elif polling is False: + polling_method = cast(AsyncPollingMethod, AsyncNoPolling()) + else: + polling_method = polling if cont_token: return AsyncLROPoller.from_continuation_token( polling_method=polling_method, continuation_token=cont_token, client=self._client, - deserialization_callback=get_long_running_output + deserialization_callback=get_long_running_output, ) return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) - begin_delete_at_management_group_scope.metadata = {'url': "/providers/Microsoft.Management/managementGroups/{groupId}/providers/Microsoft.Resources/deployments/{deploymentName}"} # type: ignore + begin_delete_at_management_group_scope.metadata = {"url": "/providers/Microsoft.Management/managementGroups/{groupId}/providers/Microsoft.Resources/deployments/{deploymentName}"} # type: ignore @distributed_trace_async async def check_existence_at_management_group_scope( - self, - group_id: str, - deployment_name: str, - **kwargs: Any + self, group_id: str, deployment_name: str, **kwargs: Any ) -> bool: """Checks whether the deployment exists. - :param group_id: The management group ID. + :param group_id: The management group ID. Required. :type group_id: str - :param deployment_name: The name of the deployment. + :param deployment_name: The name of the deployment. Required. :type deployment_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: bool, or the result of cls(response) + :return: bool or the result of cls(response) :rtype: bool - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType[None] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + 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', "2021-01-01") # type: str + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-01-01")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[None] - request = build_deployments_check_existence_at_management_group_scope_request( group_id=group_id, deployment_name=deployment_name, api_version=api_version, - template_url=self.check_existence_at_management_group_scope.metadata['url'], + template_url=self.check_existence_at_management_group_scope.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [204, 404]: @@ -1746,43 +2275,52 @@ async def check_existence_at_management_group_scope( return cls(pipeline_response, None, {}) return 200 <= response.status_code <= 299 - check_existence_at_management_group_scope.metadata = {'url': "/providers/Microsoft.Management/managementGroups/{groupId}/providers/Microsoft.Resources/deployments/{deploymentName}"} # type: ignore - + check_existence_at_management_group_scope.metadata = {"url": "/providers/Microsoft.Management/managementGroups/{groupId}/providers/Microsoft.Resources/deployments/{deploymentName}"} # type: ignore async def _create_or_update_at_management_group_scope_initial( - self, - group_id: str, - deployment_name: str, - parameters: "_models.ScopedDeployment", - **kwargs: Any - ) -> "_models.DeploymentExtended": - cls = kwargs.pop('cls', None) # type: ClsType["_models.DeploymentExtended"] + self, group_id: str, deployment_name: str, parameters: Union[_models.ScopedDeployment, IO], **kwargs: Any + ) -> _models.DeploymentExtended: error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) - api_version = kwargs.pop('api_version', "2021-01-01") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - _json = self._serialize.body(parameters, 'ScopedDeployment') + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-01-01")) # type: str + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.DeploymentExtended] - request = build_deployments_create_or_update_at_management_group_scope_request_initial( + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(parameters, (IO, bytes)): + _content = parameters + else: + _json = self._serialize.body(parameters, "ScopedDeployment") + + request = build_deployments_create_or_update_at_management_group_scope_request( group_id=group_id, deployment_name=deployment_name, api_version=api_version, content_type=content_type, json=_json, - template_url=self._create_or_update_at_management_group_scope_initial.metadata['url'], + content=_content, + template_url=self._create_or_update_at_management_group_scope_initial.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200, 201]: @@ -1790,37 +2328,41 @@ async def _create_or_update_at_management_group_scope_initial( raise HttpResponseError(response=response, error_format=ARMErrorFormat) if response.status_code == 200: - deserialized = self._deserialize('DeploymentExtended', pipeline_response) + deserialized = self._deserialize("DeploymentExtended", pipeline_response) if response.status_code == 201: - deserialized = self._deserialize('DeploymentExtended', pipeline_response) + deserialized = self._deserialize("DeploymentExtended", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - _create_or_update_at_management_group_scope_initial.metadata = {'url': "/providers/Microsoft.Management/managementGroups/{groupId}/providers/Microsoft.Resources/deployments/{deploymentName}"} # type: ignore + _create_or_update_at_management_group_scope_initial.metadata = {"url": "/providers/Microsoft.Management/managementGroups/{groupId}/providers/Microsoft.Resources/deployments/{deploymentName}"} # type: ignore - - @distributed_trace_async + @overload async def begin_create_or_update_at_management_group_scope( self, group_id: str, deployment_name: str, - parameters: "_models.ScopedDeployment", + parameters: _models.ScopedDeployment, + *, + content_type: str = "application/json", **kwargs: Any - ) -> AsyncLROPoller["_models.DeploymentExtended"]: + ) -> AsyncLROPoller[_models.DeploymentExtended]: """Deploys resources at management group scope. You can provide the template and parameters directly in the request or link to JSON files. - :param group_id: The management group ID. + :param group_id: The management group ID. Required. :type group_id: str - :param deployment_name: The name of the deployment. + :param deployment_name: The name of the deployment. Required. :type deployment_name: str - :param parameters: Additional parameters supplied to the operation. + :param parameters: Additional parameters supplied to the operation. Required. :type parameters: ~azure.mgmt.resource.resources.v2021_01_01.models.ScopedDeployment + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str :keyword callable cls: A custom type or function that will be passed the direct response :keyword str continuation_token: A continuation token to restart a poller from a saved state. :keyword polling: By default, your polling method will be AsyncARMPolling. Pass in False for @@ -1833,114 +2375,187 @@ async def begin_create_or_update_at_management_group_scope( cls(response) :rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.resource.resources.v2021_01_01.models.DeploymentExtended] - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - api_version = kwargs.pop('api_version', "2021-01-01") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] - polling = kwargs.pop('polling', True) # type: Union[bool, AsyncPollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType["_models.DeploymentExtended"] - lro_delay = kwargs.pop( - 'polling_interval', - self._config.polling_interval - ) - cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] + + @overload + async def begin_create_or_update_at_management_group_scope( + self, + group_id: str, + deployment_name: str, + parameters: IO, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> AsyncLROPoller[_models.DeploymentExtended]: + """Deploys resources at management group scope. + + You can provide the template and parameters directly in the request or link to JSON files. + + :param group_id: The management group ID. Required. + :type group_id: str + :param deployment_name: The name of the deployment. Required. + :type deployment_name: str + :param parameters: Additional parameters supplied to the operation. Required. + :type parameters: IO + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be AsyncARMPolling. Pass in False for + this operation to not poll, or pass in your own initialized polling object for a personal + polling strategy. + :paramtype polling: bool or ~azure.core.polling.AsyncPollingMethod + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of AsyncLROPoller that returns either DeploymentExtended or the result of + cls(response) + :rtype: + ~azure.core.polling.AsyncLROPoller[~azure.mgmt.resource.resources.v2021_01_01.models.DeploymentExtended] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace_async + async def begin_create_or_update_at_management_group_scope( + self, group_id: str, deployment_name: str, parameters: Union[_models.ScopedDeployment, IO], **kwargs: Any + ) -> AsyncLROPoller[_models.DeploymentExtended]: + """Deploys resources at management group scope. + + You can provide the template and parameters directly in the request or link to JSON files. + + :param group_id: The management group ID. Required. + :type group_id: str + :param deployment_name: The name of the deployment. Required. + :type deployment_name: str + :param parameters: Additional parameters supplied to the operation. Is either a model type or a + IO type. Required. + :type parameters: ~azure.mgmt.resource.resources.v2021_01_01.models.ScopedDeployment or IO + :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. + Default value is None. + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be AsyncARMPolling. Pass in False for + this operation to not poll, or pass in your own initialized polling object for a personal + polling strategy. + :paramtype polling: bool or ~azure.core.polling.AsyncPollingMethod + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of AsyncLROPoller that returns either DeploymentExtended or the result of + cls(response) + :rtype: + ~azure.core.polling.AsyncLROPoller[~azure.mgmt.resource.resources.v2021_01_01.models.DeploymentExtended] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _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-01-01")) # type: str + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.DeploymentExtended] + polling = kwargs.pop("polling", True) # type: Union[bool, AsyncPollingMethod] + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token = kwargs.pop("continuation_token", None) # type: Optional[str] if cont_token is None: - raw_result = await self._create_or_update_at_management_group_scope_initial( + raw_result = await self._create_or_update_at_management_group_scope_initial( # type: ignore group_id=group_id, deployment_name=deployment_name, parameters=parameters, api_version=api_version, content_type=content_type, - cls=lambda x,y,z: x, + cls=lambda x, y, z: x, + headers=_headers, + params=_params, **kwargs ) - kwargs.pop('error_map', None) + kwargs.pop("error_map", None) def get_long_running_output(pipeline_response): - response = pipeline_response.http_response - deserialized = self._deserialize('DeploymentExtended', pipeline_response) + deserialized = self._deserialize("DeploymentExtended", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - - if polling is True: polling_method = AsyncARMPolling(lro_delay, **kwargs) - elif polling is False: polling_method = AsyncNoPolling() - else: polling_method = polling + if polling is True: + polling_method = cast(AsyncPollingMethod, AsyncARMPolling(lro_delay, **kwargs)) # type: AsyncPollingMethod + elif polling is False: + polling_method = cast(AsyncPollingMethod, AsyncNoPolling()) + else: + polling_method = polling if cont_token: return AsyncLROPoller.from_continuation_token( polling_method=polling_method, continuation_token=cont_token, client=self._client, - deserialization_callback=get_long_running_output + deserialization_callback=get_long_running_output, ) return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) - begin_create_or_update_at_management_group_scope.metadata = {'url': "/providers/Microsoft.Management/managementGroups/{groupId}/providers/Microsoft.Resources/deployments/{deploymentName}"} # type: ignore + begin_create_or_update_at_management_group_scope.metadata = {"url": "/providers/Microsoft.Management/managementGroups/{groupId}/providers/Microsoft.Resources/deployments/{deploymentName}"} # type: ignore @distributed_trace_async async def get_at_management_group_scope( - self, - group_id: str, - deployment_name: str, - **kwargs: Any - ) -> "_models.DeploymentExtended": + self, group_id: str, deployment_name: str, **kwargs: Any + ) -> _models.DeploymentExtended: """Gets a deployment. - :param group_id: The management group ID. + :param group_id: The management group ID. Required. :type group_id: str - :param deployment_name: The name of the deployment. + :param deployment_name: The name of the deployment. Required. :type deployment_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: DeploymentExtended, or the result of cls(response) + :return: DeploymentExtended or the result of cls(response) :rtype: ~azure.mgmt.resource.resources.v2021_01_01.models.DeploymentExtended - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.DeploymentExtended"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + 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', "2021-01-01") # type: str + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-01-01")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[_models.DeploymentExtended] - request = build_deployments_get_at_management_group_scope_request( group_id=group_id, deployment_name=deployment_name, api_version=api_version, - template_url=self.get_at_management_group_scope.metadata['url'], + template_url=self.get_at_management_group_scope.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) - deserialized = self._deserialize('DeploymentExtended', pipeline_response) + deserialized = self._deserialize("DeploymentExtended", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - get_at_management_group_scope.metadata = {'url': "/providers/Microsoft.Management/managementGroups/{groupId}/providers/Microsoft.Resources/deployments/{deploymentName}"} # type: ignore - + get_at_management_group_scope.metadata = {"url": "/providers/Microsoft.Management/managementGroups/{groupId}/providers/Microsoft.Resources/deployments/{deploymentName}"} # type: ignore @distributed_trace_async async def cancel_at_management_group_scope( # pylint: disable=inconsistent-return-statements - self, - group_id: str, - deployment_name: str, - **kwargs: Any + self, group_id: str, deployment_name: str, **kwargs: Any ) -> None: """Cancels a currently running template deployment. @@ -1949,38 +2564,44 @@ async def cancel_at_management_group_scope( # pylint: disable=inconsistent-retu deployment stops the currently running template deployment and leaves the resources partially deployed. - :param group_id: The management group ID. + :param group_id: The management group ID. Required. :type group_id: str - :param deployment_name: The name of the deployment. + :param deployment_name: The name of the deployment. Required. :type deployment_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: None, or the result of cls(response) + :return: None or the result of cls(response) :rtype: None - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType[None] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) - api_version = kwargs.pop('api_version', "2021-01-01") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-01-01")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[None] - request = build_deployments_cancel_at_management_group_scope_request( group_id=group_id, deployment_name=deployment_name, api_version=api_version, - template_url=self.cancel_at_management_group_scope.metadata['url'], + template_url=self.cancel_at_management_group_scope.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [204]: @@ -1990,43 +2611,52 @@ async def cancel_at_management_group_scope( # pylint: disable=inconsistent-retu if cls: return cls(pipeline_response, None, {}) - cancel_at_management_group_scope.metadata = {'url': "/providers/Microsoft.Management/managementGroups/{groupId}/providers/Microsoft.Resources/deployments/{deploymentName}/cancel"} # type: ignore - + cancel_at_management_group_scope.metadata = {"url": "/providers/Microsoft.Management/managementGroups/{groupId}/providers/Microsoft.Resources/deployments/{deploymentName}/cancel"} # type: ignore async def _validate_at_management_group_scope_initial( - self, - group_id: str, - deployment_name: str, - parameters: "_models.ScopedDeployment", - **kwargs: Any - ) -> Optional["_models.DeploymentValidateResult"]: - cls = kwargs.pop('cls', None) # type: ClsType[Optional["_models.DeploymentValidateResult"]] + self, group_id: str, deployment_name: str, parameters: Union[_models.ScopedDeployment, IO], **kwargs: Any + ) -> Optional[_models.DeploymentValidateResult]: error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', "2021-01-01") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-01-01")) # type: str + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[Optional[_models.DeploymentValidateResult]] - _json = self._serialize.body(parameters, 'ScopedDeployment') + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(parameters, (IO, bytes)): + _content = parameters + else: + _json = self._serialize.body(parameters, "ScopedDeployment") - request = build_deployments_validate_at_management_group_scope_request_initial( + request = build_deployments_validate_at_management_group_scope_request( group_id=group_id, deployment_name=deployment_name, api_version=api_version, content_type=content_type, json=_json, - template_url=self._validate_at_management_group_scope_initial.metadata['url'], + content=_content, + template_url=self._validate_at_management_group_scope_initial.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200, 202, 400]: @@ -2035,36 +2665,40 @@ async def _validate_at_management_group_scope_initial( deserialized = None if response.status_code == 200: - deserialized = self._deserialize('DeploymentValidateResult', pipeline_response) + deserialized = self._deserialize("DeploymentValidateResult", pipeline_response) if response.status_code == 400: - deserialized = self._deserialize('DeploymentValidateResult', pipeline_response) + deserialized = self._deserialize("DeploymentValidateResult", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - _validate_at_management_group_scope_initial.metadata = {'url': "/providers/Microsoft.Management/managementGroups/{groupId}/providers/Microsoft.Resources/deployments/{deploymentName}/validate"} # type: ignore - + _validate_at_management_group_scope_initial.metadata = {"url": "/providers/Microsoft.Management/managementGroups/{groupId}/providers/Microsoft.Resources/deployments/{deploymentName}/validate"} # type: ignore - @distributed_trace_async + @overload async def begin_validate_at_management_group_scope( self, group_id: str, deployment_name: str, - parameters: "_models.ScopedDeployment", + parameters: _models.ScopedDeployment, + *, + content_type: str = "application/json", **kwargs: Any - ) -> AsyncLROPoller["_models.DeploymentValidateResult"]: + ) -> AsyncLROPoller[_models.DeploymentValidateResult]: """Validates whether the specified template is syntactically correct and will be accepted by Azure Resource Manager.. - :param group_id: The management group ID. + :param group_id: The management group ID. Required. :type group_id: str - :param deployment_name: The name of the deployment. + :param deployment_name: The name of the deployment. Required. :type deployment_name: str - :param parameters: Parameters to validate. + :param parameters: Parameters to validate. Required. :type parameters: ~azure.mgmt.resource.resources.v2021_01_01.models.ScopedDeployment + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str :keyword callable cls: A custom type or function that will be passed the direct response :keyword str continuation_token: A continuation token to restart a poller from a saved state. :keyword polling: By default, your polling method will be AsyncARMPolling. Pass in False for @@ -2077,85 +2711,166 @@ async def begin_validate_at_management_group_scope( result of cls(response) :rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.resource.resources.v2021_01_01.models.DeploymentValidateResult] - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - api_version = kwargs.pop('api_version', "2021-01-01") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] - polling = kwargs.pop('polling', True) # type: Union[bool, AsyncPollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType["_models.DeploymentValidateResult"] - lro_delay = kwargs.pop( - 'polling_interval', - self._config.polling_interval - ) - cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] - if cont_token is None: - raw_result = await self._validate_at_management_group_scope_initial( - group_id=group_id, - deployment_name=deployment_name, - parameters=parameters, - api_version=api_version, - content_type=content_type, - cls=lambda x,y,z: x, - **kwargs - ) - kwargs.pop('error_map', None) - - def get_long_running_output(pipeline_response): - response = pipeline_response.http_response - deserialized = self._deserialize('DeploymentValidateResult', pipeline_response) - if cls: - return cls(pipeline_response, deserialized, {}) - return deserialized - - if polling is True: polling_method = AsyncARMPolling(lro_delay, **kwargs) - elif polling is False: polling_method = AsyncNoPolling() - else: polling_method = polling - if cont_token: - return AsyncLROPoller.from_continuation_token( - polling_method=polling_method, + @overload + async def begin_validate_at_management_group_scope( + self, + group_id: str, + deployment_name: str, + parameters: IO, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> AsyncLROPoller[_models.DeploymentValidateResult]: + """Validates whether the specified template is syntactically correct and will be accepted by Azure + Resource Manager.. + + :param group_id: The management group ID. Required. + :type group_id: str + :param deployment_name: The name of the deployment. Required. + :type deployment_name: str + :param parameters: Parameters to validate. Required. + :type parameters: IO + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be AsyncARMPolling. Pass in False for + this operation to not poll, or pass in your own initialized polling object for a personal + polling strategy. + :paramtype polling: bool or ~azure.core.polling.AsyncPollingMethod + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of AsyncLROPoller that returns either DeploymentValidateResult or the + result of cls(response) + :rtype: + ~azure.core.polling.AsyncLROPoller[~azure.mgmt.resource.resources.v2021_01_01.models.DeploymentValidateResult] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace_async + async def begin_validate_at_management_group_scope( + self, group_id: str, deployment_name: str, parameters: Union[_models.ScopedDeployment, IO], **kwargs: Any + ) -> AsyncLROPoller[_models.DeploymentValidateResult]: + """Validates whether the specified template is syntactically correct and will be accepted by Azure + Resource Manager.. + + :param group_id: The management group ID. Required. + :type group_id: str + :param deployment_name: The name of the deployment. Required. + :type deployment_name: str + :param parameters: Parameters to validate. Is either a model type or a IO type. Required. + :type parameters: ~azure.mgmt.resource.resources.v2021_01_01.models.ScopedDeployment or IO + :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. + Default value is None. + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be AsyncARMPolling. Pass in False for + this operation to not poll, or pass in your own initialized polling object for a personal + polling strategy. + :paramtype polling: bool or ~azure.core.polling.AsyncPollingMethod + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of AsyncLROPoller that returns either DeploymentValidateResult or the + result of cls(response) + :rtype: + ~azure.core.polling.AsyncLROPoller[~azure.mgmt.resource.resources.v2021_01_01.models.DeploymentValidateResult] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _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-01-01")) # type: str + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.DeploymentValidateResult] + polling = kwargs.pop("polling", True) # type: Union[bool, AsyncPollingMethod] + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token = kwargs.pop("continuation_token", None) # type: Optional[str] + if cont_token is None: + raw_result = await self._validate_at_management_group_scope_initial( # type: ignore + group_id=group_id, + deployment_name=deployment_name, + parameters=parameters, + api_version=api_version, + content_type=content_type, + cls=lambda x, y, z: x, + headers=_headers, + params=_params, + **kwargs + ) + kwargs.pop("error_map", None) + + def get_long_running_output(pipeline_response): + deserialized = self._deserialize("DeploymentValidateResult", pipeline_response) + if cls: + return cls(pipeline_response, deserialized, {}) + return deserialized + + if polling is True: + polling_method = cast(AsyncPollingMethod, AsyncARMPolling(lro_delay, **kwargs)) # type: AsyncPollingMethod + elif polling is False: + polling_method = cast(AsyncPollingMethod, AsyncNoPolling()) + else: + polling_method = polling + if cont_token: + return AsyncLROPoller.from_continuation_token( + polling_method=polling_method, continuation_token=cont_token, client=self._client, - deserialization_callback=get_long_running_output + deserialization_callback=get_long_running_output, ) return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) - begin_validate_at_management_group_scope.metadata = {'url': "/providers/Microsoft.Management/managementGroups/{groupId}/providers/Microsoft.Resources/deployments/{deploymentName}/validate"} # type: ignore + begin_validate_at_management_group_scope.metadata = {"url": "/providers/Microsoft.Management/managementGroups/{groupId}/providers/Microsoft.Resources/deployments/{deploymentName}/validate"} # type: ignore async def _what_if_at_management_group_scope_initial( - self, - group_id: str, - deployment_name: str, - parameters: "_models.ScopedDeploymentWhatIf", - **kwargs: Any - ) -> Optional["_models.WhatIfOperationResult"]: - cls = kwargs.pop('cls', None) # type: ClsType[Optional["_models.WhatIfOperationResult"]] + self, group_id: str, deployment_name: str, parameters: Union[_models.ScopedDeploymentWhatIf, IO], **kwargs: Any + ) -> Optional[_models.WhatIfOperationResult]: error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) - api_version = kwargs.pop('api_version', "2021-01-01") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - _json = self._serialize.body(parameters, 'ScopedDeploymentWhatIf') + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-01-01")) # type: str + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[Optional[_models.WhatIfOperationResult]] - request = build_deployments_what_if_at_management_group_scope_request_initial( + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(parameters, (IO, bytes)): + _content = parameters + else: + _json = self._serialize.body(parameters, "ScopedDeploymentWhatIf") + + request = build_deployments_what_if_at_management_group_scope_request( group_id=group_id, deployment_name=deployment_name, api_version=api_version, content_type=content_type, json=_json, - template_url=self._what_if_at_management_group_scope_initial.metadata['url'], + content=_content, + template_url=self._what_if_at_management_group_scope_initial.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200, 202]: @@ -2165,38 +2880,41 @@ async def _what_if_at_management_group_scope_initial( deserialized = None response_headers = {} if response.status_code == 200: - deserialized = self._deserialize('WhatIfOperationResult', pipeline_response) + deserialized = self._deserialize("WhatIfOperationResult", pipeline_response) if response.status_code == 202: - response_headers['Location']=self._deserialize('str', response.headers.get('Location')) - response_headers['Retry-After']=self._deserialize('str', response.headers.get('Retry-After')) - + response_headers["Location"] = self._deserialize("str", response.headers.get("Location")) + response_headers["Retry-After"] = self._deserialize("str", response.headers.get("Retry-After")) if cls: return cls(pipeline_response, deserialized, response_headers) return deserialized - _what_if_at_management_group_scope_initial.metadata = {'url': "/providers/Microsoft.Management/managementGroups/{groupId}/providers/Microsoft.Resources/deployments/{deploymentName}/whatIf"} # type: ignore + _what_if_at_management_group_scope_initial.metadata = {"url": "/providers/Microsoft.Management/managementGroups/{groupId}/providers/Microsoft.Resources/deployments/{deploymentName}/whatIf"} # type: ignore - - @distributed_trace_async + @overload async def begin_what_if_at_management_group_scope( self, group_id: str, deployment_name: str, - parameters: "_models.ScopedDeploymentWhatIf", + parameters: _models.ScopedDeploymentWhatIf, + *, + content_type: str = "application/json", **kwargs: Any - ) -> AsyncLROPoller["_models.WhatIfOperationResult"]: + ) -> AsyncLROPoller[_models.WhatIfOperationResult]: """Returns changes that will be made by the deployment if executed at the scope of the management group. - :param group_id: The management group ID. + :param group_id: The management group ID. Required. :type group_id: str - :param deployment_name: The name of the deployment. + :param deployment_name: The name of the deployment. Required. :type deployment_name: str - :param parameters: Parameters to validate. + :param parameters: Parameters to validate. Required. :type parameters: ~azure.mgmt.resource.resources.v2021_01_01.models.ScopedDeploymentWhatIf + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str :keyword callable cls: A custom type or function that will be passed the direct response :keyword str continuation_token: A continuation token to restart a poller from a saved state. :keyword polling: By default, your polling method will be AsyncARMPolling. Pass in False for @@ -2209,119 +2927,191 @@ async def begin_what_if_at_management_group_scope( of cls(response) :rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.resource.resources.v2021_01_01.models.WhatIfOperationResult] - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - api_version = kwargs.pop('api_version', "2021-01-01") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] - polling = kwargs.pop('polling', True) # type: Union[bool, AsyncPollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType["_models.WhatIfOperationResult"] - lro_delay = kwargs.pop( - 'polling_interval', - self._config.polling_interval - ) - cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] + + @overload + async def begin_what_if_at_management_group_scope( + self, + group_id: str, + deployment_name: str, + parameters: IO, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> AsyncLROPoller[_models.WhatIfOperationResult]: + """Returns changes that will be made by the deployment if executed at the scope of the management + group. + + :param group_id: The management group ID. Required. + :type group_id: str + :param deployment_name: The name of the deployment. Required. + :type deployment_name: str + :param parameters: Parameters to validate. Required. + :type parameters: IO + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be AsyncARMPolling. Pass in False for + this operation to not poll, or pass in your own initialized polling object for a personal + polling strategy. + :paramtype polling: bool or ~azure.core.polling.AsyncPollingMethod + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of AsyncLROPoller that returns either WhatIfOperationResult or the result + of cls(response) + :rtype: + ~azure.core.polling.AsyncLROPoller[~azure.mgmt.resource.resources.v2021_01_01.models.WhatIfOperationResult] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace_async + async def begin_what_if_at_management_group_scope( + self, group_id: str, deployment_name: str, parameters: Union[_models.ScopedDeploymentWhatIf, IO], **kwargs: Any + ) -> AsyncLROPoller[_models.WhatIfOperationResult]: + """Returns changes that will be made by the deployment if executed at the scope of the management + group. + + :param group_id: The management group ID. Required. + :type group_id: str + :param deployment_name: The name of the deployment. Required. + :type deployment_name: str + :param parameters: Parameters to validate. Is either a model type or a IO type. Required. + :type parameters: ~azure.mgmt.resource.resources.v2021_01_01.models.ScopedDeploymentWhatIf or + IO + :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. + Default value is None. + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be AsyncARMPolling. Pass in False for + this operation to not poll, or pass in your own initialized polling object for a personal + polling strategy. + :paramtype polling: bool or ~azure.core.polling.AsyncPollingMethod + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of AsyncLROPoller that returns either WhatIfOperationResult or the result + of cls(response) + :rtype: + ~azure.core.polling.AsyncLROPoller[~azure.mgmt.resource.resources.v2021_01_01.models.WhatIfOperationResult] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _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-01-01")) # type: str + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.WhatIfOperationResult] + polling = kwargs.pop("polling", True) # type: Union[bool, AsyncPollingMethod] + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token = kwargs.pop("continuation_token", None) # type: Optional[str] if cont_token is None: - raw_result = await self._what_if_at_management_group_scope_initial( + raw_result = await self._what_if_at_management_group_scope_initial( # type: ignore group_id=group_id, deployment_name=deployment_name, parameters=parameters, api_version=api_version, content_type=content_type, - cls=lambda x,y,z: x, + cls=lambda x, y, z: x, + headers=_headers, + params=_params, **kwargs ) - kwargs.pop('error_map', None) + kwargs.pop("error_map", None) def get_long_running_output(pipeline_response): - response = pipeline_response.http_response - deserialized = self._deserialize('WhatIfOperationResult', pipeline_response) + deserialized = self._deserialize("WhatIfOperationResult", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - - if polling is True: polling_method = AsyncARMPolling(lro_delay, lro_options={'final-state-via': 'location'}, **kwargs) - elif polling is False: polling_method = AsyncNoPolling() - else: polling_method = polling + if polling is True: + polling_method = cast( + AsyncPollingMethod, AsyncARMPolling(lro_delay, lro_options={"final-state-via": "location"}, **kwargs) + ) # type: AsyncPollingMethod + elif polling is False: + polling_method = cast(AsyncPollingMethod, AsyncNoPolling()) + else: + polling_method = polling if cont_token: return AsyncLROPoller.from_continuation_token( polling_method=polling_method, continuation_token=cont_token, client=self._client, - deserialization_callback=get_long_running_output + deserialization_callback=get_long_running_output, ) return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) - begin_what_if_at_management_group_scope.metadata = {'url': "/providers/Microsoft.Management/managementGroups/{groupId}/providers/Microsoft.Resources/deployments/{deploymentName}/whatIf"} # type: ignore + begin_what_if_at_management_group_scope.metadata = {"url": "/providers/Microsoft.Management/managementGroups/{groupId}/providers/Microsoft.Resources/deployments/{deploymentName}/whatIf"} # type: ignore @distributed_trace_async async def export_template_at_management_group_scope( - self, - group_id: str, - deployment_name: str, - **kwargs: Any - ) -> "_models.DeploymentExportResult": + self, group_id: str, deployment_name: str, **kwargs: Any + ) -> _models.DeploymentExportResult: """Exports the template used for specified deployment. - :param group_id: The management group ID. + :param group_id: The management group ID. Required. :type group_id: str - :param deployment_name: The name of the deployment. + :param deployment_name: The name of the deployment. Required. :type deployment_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: DeploymentExportResult, or the result of cls(response) + :return: DeploymentExportResult or the result of cls(response) :rtype: ~azure.mgmt.resource.resources.v2021_01_01.models.DeploymentExportResult - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.DeploymentExportResult"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + 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', "2021-01-01") # type: str + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-01-01")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[_models.DeploymentExportResult] - request = build_deployments_export_template_at_management_group_scope_request( group_id=group_id, deployment_name=deployment_name, api_version=api_version, - template_url=self.export_template_at_management_group_scope.metadata['url'], + template_url=self.export_template_at_management_group_scope.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) - deserialized = self._deserialize('DeploymentExportResult', pipeline_response) + deserialized = self._deserialize("DeploymentExportResult", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - export_template_at_management_group_scope.metadata = {'url': "/providers/Microsoft.Management/managementGroups/{groupId}/providers/Microsoft.Resources/deployments/{deploymentName}/exportTemplate"} # type: ignore - + export_template_at_management_group_scope.metadata = {"url": "/providers/Microsoft.Management/managementGroups/{groupId}/providers/Microsoft.Resources/deployments/{deploymentName}/exportTemplate"} # type: ignore @distributed_trace def list_at_management_group_scope( - self, - group_id: str, - filter: Optional[str] = None, - top: Optional[int] = None, - **kwargs: Any - ) -> AsyncIterable["_models.DeploymentListResult"]: + self, group_id: str, filter: Optional[str] = None, top: Optional[int] = None, **kwargs: Any + ) -> AsyncIterable["_models.DeploymentExtended"]: """Get all the deployments for a management group. - :param group_id: The management group ID. + :param group_id: The management group ID. Required. :type group_id: str :param filter: The filter to apply on the operation. For example, you can use $filter=provisioningState eq '{state}'. Default value is None. @@ -2330,40 +3120,48 @@ def list_at_management_group_scope( value is None. :type top: int :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either DeploymentListResult or the result of - cls(response) + :return: An iterator like instance of either DeploymentExtended or the result of cls(response) :rtype: - ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.resource.resources.v2021_01_01.models.DeploymentListResult] - :raises: ~azure.core.exceptions.HttpResponseError + ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.resource.resources.v2021_01_01.models.DeploymentExtended] + :raises ~azure.core.exceptions.HttpResponseError: """ - api_version = kwargs.pop('api_version', "2021-01-01") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-01-01")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[_models.DeploymentListResult] - cls = kwargs.pop('cls', None) # type: ClsType["_models.DeploymentListResult"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) + def prepare_request(next_link=None): if not next_link: - + request = build_deployments_list_at_management_group_scope_request( group_id=group_id, - api_version=api_version, filter=filter, top=top, - template_url=self.list_at_management_group_scope.metadata['url'], + api_version=api_version, + template_url=self.list_at_management_group_scope.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore else: - - request = build_deployments_list_at_management_group_scope_request( - group_id=group_id, - template_url=next_link, - ) + # make call to next link with the client's api-version + _parsed_next_link = urlparse(next_link) + _next_request_params = case_insensitive_dict(parse_qs(_parsed_next_link.query)) + _next_request_params["api-version"] = self._config.api_version + request = HttpRequest("GET", urljoin(next_link, _parsed_next_link.path), params=_next_request_params) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore request.method = "GET" return request @@ -2377,10 +3175,8 @@ async def extract_data(pipeline_response): async def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) response = pipeline_response.http_response @@ -2390,40 +3186,42 @@ async def get_next(next_link=None): return pipeline_response + return AsyncItemPaged(get_next, extract_data) - return AsyncItemPaged( - get_next, extract_data - ) - list_at_management_group_scope.metadata = {'url': "/providers/Microsoft.Management/managementGroups/{groupId}/providers/Microsoft.Resources/deployments/"} # type: ignore + list_at_management_group_scope.metadata = {"url": "/providers/Microsoft.Management/managementGroups/{groupId}/providers/Microsoft.Resources/deployments/"} # type: ignore async def _delete_at_subscription_scope_initial( # pylint: disable=inconsistent-return-statements - self, - deployment_name: str, - **kwargs: Any + self, deployment_name: str, **kwargs: Any ) -> None: - cls = kwargs.pop('cls', None) # type: ClsType[None] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + 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', "2021-01-01") # type: str + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-01-01")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[None] - - request = build_deployments_delete_at_subscription_scope_request_initial( + request = build_deployments_delete_at_subscription_scope_request( deployment_name=deployment_name, subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self._delete_at_subscription_scope_initial.metadata['url'], + template_url=self._delete_at_subscription_scope_initial.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [202, 204]: @@ -2433,15 +3231,10 @@ async def _delete_at_subscription_scope_initial( # pylint: disable=inconsistent if cls: return cls(pipeline_response, None, {}) - _delete_at_subscription_scope_initial.metadata = {'url': "/subscriptions/{subscriptionId}/providers/Microsoft.Resources/deployments/{deploymentName}"} # type: ignore - + _delete_at_subscription_scope_initial.metadata = {"url": "/subscriptions/{subscriptionId}/providers/Microsoft.Resources/deployments/{deploymentName}"} # type: ignore @distributed_trace_async - async def begin_delete_at_subscription_scope( # pylint: disable=inconsistent-return-statements - self, - deployment_name: str, - **kwargs: Any - ) -> AsyncLROPoller[None]: + async def begin_delete_at_subscription_scope(self, deployment_name: str, **kwargs: Any) -> AsyncLROPoller[None]: """Deletes a deployment from the deployment history. A template deployment that is currently running cannot be deleted. Deleting a template @@ -2452,7 +3245,7 @@ async def begin_delete_at_subscription_scope( # pylint: disable=inconsistent-re process finishes, the URI in the Location header returns a status of 204 on success. If the asynchronous request failed, the URI in the Location header returns an error-level status code. - :param deployment_name: The name of the deployment. + :param deployment_name: The name of the deployment. Required. :type deployment_name: str :keyword callable cls: A custom type or function that will be passed the direct response :keyword str continuation_token: A continuation token to restart a poller from a saved state. @@ -2464,82 +3257,88 @@ async def begin_delete_at_subscription_scope( # pylint: disable=inconsistent-re Retry-After header is present. :return: An instance of AsyncLROPoller that returns either None or the result of cls(response) :rtype: ~azure.core.polling.AsyncLROPoller[None] - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - api_version = kwargs.pop('api_version', "2021-01-01") # type: str - polling = kwargs.pop('polling', True) # type: Union[bool, AsyncPollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType[None] - lro_delay = kwargs.pop( - 'polling_interval', - self._config.polling_interval - ) - cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-01-01")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[None] + polling = kwargs.pop("polling", True) # type: Union[bool, AsyncPollingMethod] + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token = kwargs.pop("continuation_token", None) # type: Optional[str] if cont_token is None: - raw_result = await self._delete_at_subscription_scope_initial( + raw_result = await self._delete_at_subscription_scope_initial( # type: ignore deployment_name=deployment_name, api_version=api_version, - cls=lambda x,y,z: x, + cls=lambda x, y, z: x, + headers=_headers, + params=_params, **kwargs ) - kwargs.pop('error_map', None) + kwargs.pop("error_map", None) - def get_long_running_output(pipeline_response): + def get_long_running_output(pipeline_response): # pylint: disable=inconsistent-return-statements if cls: return cls(pipeline_response, None, {}) - - if polling is True: polling_method = AsyncARMPolling(lro_delay, **kwargs) - elif polling is False: polling_method = AsyncNoPolling() - else: polling_method = polling + if polling is True: + polling_method = cast(AsyncPollingMethod, AsyncARMPolling(lro_delay, **kwargs)) # type: AsyncPollingMethod + elif polling is False: + polling_method = cast(AsyncPollingMethod, AsyncNoPolling()) + else: + polling_method = polling if cont_token: return AsyncLROPoller.from_continuation_token( polling_method=polling_method, continuation_token=cont_token, client=self._client, - deserialization_callback=get_long_running_output + deserialization_callback=get_long_running_output, ) return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) - begin_delete_at_subscription_scope.metadata = {'url': "/subscriptions/{subscriptionId}/providers/Microsoft.Resources/deployments/{deploymentName}"} # type: ignore + begin_delete_at_subscription_scope.metadata = {"url": "/subscriptions/{subscriptionId}/providers/Microsoft.Resources/deployments/{deploymentName}"} # type: ignore @distributed_trace_async - async def check_existence_at_subscription_scope( - self, - deployment_name: str, - **kwargs: Any - ) -> bool: + async def check_existence_at_subscription_scope(self, deployment_name: str, **kwargs: Any) -> bool: """Checks whether the deployment exists. - :param deployment_name: The name of the deployment. + :param deployment_name: The name of the deployment. Required. :type deployment_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: bool, or the result of cls(response) + :return: bool or the result of cls(response) :rtype: bool - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType[None] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + 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', "2021-01-01") # type: str + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-01-01")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[None] - request = build_deployments_check_existence_at_subscription_scope_request( deployment_name=deployment_name, subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.check_existence_at_subscription_scope.metadata['url'], + template_url=self.check_existence_at_subscription_scope.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [204, 404]: @@ -2550,42 +3349,52 @@ async def check_existence_at_subscription_scope( return cls(pipeline_response, None, {}) return 200 <= response.status_code <= 299 - check_existence_at_subscription_scope.metadata = {'url': "/subscriptions/{subscriptionId}/providers/Microsoft.Resources/deployments/{deploymentName}"} # type: ignore - + check_existence_at_subscription_scope.metadata = {"url": "/subscriptions/{subscriptionId}/providers/Microsoft.Resources/deployments/{deploymentName}"} # type: ignore async def _create_or_update_at_subscription_scope_initial( - self, - deployment_name: str, - parameters: "_models.Deployment", - **kwargs: Any - ) -> "_models.DeploymentExtended": - cls = kwargs.pop('cls', None) # type: ClsType["_models.DeploymentExtended"] + self, deployment_name: str, parameters: Union[_models.Deployment, IO], **kwargs: Any + ) -> _models.DeploymentExtended: error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', "2021-01-01") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-01-01")) # type: str + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.DeploymentExtended] - _json = self._serialize.body(parameters, 'Deployment') + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(parameters, (IO, bytes)): + _content = parameters + else: + _json = self._serialize.body(parameters, "Deployment") - request = build_deployments_create_or_update_at_subscription_scope_request_initial( + request = build_deployments_create_or_update_at_subscription_scope_request( deployment_name=deployment_name, subscription_id=self._config.subscription_id, api_version=api_version, content_type=content_type, json=_json, - template_url=self._create_or_update_at_subscription_scope_initial.metadata['url'], + content=_content, + template_url=self._create_or_update_at_subscription_scope_initial.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200, 201]: @@ -2593,34 +3402,38 @@ async def _create_or_update_at_subscription_scope_initial( raise HttpResponseError(response=response, error_format=ARMErrorFormat) if response.status_code == 200: - deserialized = self._deserialize('DeploymentExtended', pipeline_response) + deserialized = self._deserialize("DeploymentExtended", pipeline_response) if response.status_code == 201: - deserialized = self._deserialize('DeploymentExtended', pipeline_response) + deserialized = self._deserialize("DeploymentExtended", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - _create_or_update_at_subscription_scope_initial.metadata = {'url': "/subscriptions/{subscriptionId}/providers/Microsoft.Resources/deployments/{deploymentName}"} # type: ignore - + _create_or_update_at_subscription_scope_initial.metadata = {"url": "/subscriptions/{subscriptionId}/providers/Microsoft.Resources/deployments/{deploymentName}"} # type: ignore - @distributed_trace_async + @overload async def begin_create_or_update_at_subscription_scope( self, deployment_name: str, - parameters: "_models.Deployment", + parameters: _models.Deployment, + *, + content_type: str = "application/json", **kwargs: Any - ) -> AsyncLROPoller["_models.DeploymentExtended"]: + ) -> AsyncLROPoller[_models.DeploymentExtended]: """Deploys resources at subscription scope. You can provide the template and parameters directly in the request or link to JSON files. - :param deployment_name: The name of the deployment. + :param deployment_name: The name of the deployment. Required. :type deployment_name: str - :param parameters: Additional parameters supplied to the operation. + :param parameters: Additional parameters supplied to the operation. Required. :type parameters: ~azure.mgmt.resource.resources.v2021_01_01.models.Deployment + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str :keyword callable cls: A custom type or function that will be passed the direct response :keyword str continuation_token: A continuation token to restart a poller from a saved state. :keyword polling: By default, your polling method will be AsyncARMPolling. Pass in False for @@ -2633,109 +3446,172 @@ async def begin_create_or_update_at_subscription_scope( cls(response) :rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.resource.resources.v2021_01_01.models.DeploymentExtended] - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - api_version = kwargs.pop('api_version', "2021-01-01") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] - polling = kwargs.pop('polling', True) # type: Union[bool, AsyncPollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType["_models.DeploymentExtended"] - lro_delay = kwargs.pop( - 'polling_interval', - self._config.polling_interval - ) - cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] + + @overload + async def begin_create_or_update_at_subscription_scope( + self, deployment_name: str, parameters: IO, *, content_type: str = "application/json", **kwargs: Any + ) -> AsyncLROPoller[_models.DeploymentExtended]: + """Deploys resources at subscription scope. + + You can provide the template and parameters directly in the request or link to JSON files. + + :param deployment_name: The name of the deployment. Required. + :type deployment_name: str + :param parameters: Additional parameters supplied to the operation. Required. + :type parameters: IO + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be AsyncARMPolling. Pass in False for + this operation to not poll, or pass in your own initialized polling object for a personal + polling strategy. + :paramtype polling: bool or ~azure.core.polling.AsyncPollingMethod + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of AsyncLROPoller that returns either DeploymentExtended or the result of + cls(response) + :rtype: + ~azure.core.polling.AsyncLROPoller[~azure.mgmt.resource.resources.v2021_01_01.models.DeploymentExtended] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace_async + async def begin_create_or_update_at_subscription_scope( + self, deployment_name: str, parameters: Union[_models.Deployment, IO], **kwargs: Any + ) -> AsyncLROPoller[_models.DeploymentExtended]: + """Deploys resources at subscription scope. + + You can provide the template and parameters directly in the request or link to JSON files. + + :param deployment_name: The name of the deployment. Required. + :type deployment_name: str + :param parameters: Additional parameters supplied to the operation. Is either a model type or a + IO type. Required. + :type parameters: ~azure.mgmt.resource.resources.v2021_01_01.models.Deployment or IO + :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. + Default value is None. + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be AsyncARMPolling. Pass in False for + this operation to not poll, or pass in your own initialized polling object for a personal + polling strategy. + :paramtype polling: bool or ~azure.core.polling.AsyncPollingMethod + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of AsyncLROPoller that returns either DeploymentExtended or the result of + cls(response) + :rtype: + ~azure.core.polling.AsyncLROPoller[~azure.mgmt.resource.resources.v2021_01_01.models.DeploymentExtended] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _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-01-01")) # type: str + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.DeploymentExtended] + polling = kwargs.pop("polling", True) # type: Union[bool, AsyncPollingMethod] + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token = kwargs.pop("continuation_token", None) # type: Optional[str] if cont_token is None: - raw_result = await self._create_or_update_at_subscription_scope_initial( + raw_result = await self._create_or_update_at_subscription_scope_initial( # type: ignore deployment_name=deployment_name, parameters=parameters, api_version=api_version, content_type=content_type, - cls=lambda x,y,z: x, + cls=lambda x, y, z: x, + headers=_headers, + params=_params, **kwargs ) - kwargs.pop('error_map', None) + kwargs.pop("error_map", None) def get_long_running_output(pipeline_response): - response = pipeline_response.http_response - deserialized = self._deserialize('DeploymentExtended', pipeline_response) + deserialized = self._deserialize("DeploymentExtended", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - - if polling is True: polling_method = AsyncARMPolling(lro_delay, **kwargs) - elif polling is False: polling_method = AsyncNoPolling() - else: polling_method = polling + if polling is True: + polling_method = cast(AsyncPollingMethod, AsyncARMPolling(lro_delay, **kwargs)) # type: AsyncPollingMethod + elif polling is False: + polling_method = cast(AsyncPollingMethod, AsyncNoPolling()) + else: + polling_method = polling if cont_token: return AsyncLROPoller.from_continuation_token( polling_method=polling_method, continuation_token=cont_token, client=self._client, - deserialization_callback=get_long_running_output + deserialization_callback=get_long_running_output, ) return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) - begin_create_or_update_at_subscription_scope.metadata = {'url': "/subscriptions/{subscriptionId}/providers/Microsoft.Resources/deployments/{deploymentName}"} # type: ignore + begin_create_or_update_at_subscription_scope.metadata = {"url": "/subscriptions/{subscriptionId}/providers/Microsoft.Resources/deployments/{deploymentName}"} # type: ignore @distributed_trace_async - async def get_at_subscription_scope( - self, - deployment_name: str, - **kwargs: Any - ) -> "_models.DeploymentExtended": + async def get_at_subscription_scope(self, deployment_name: str, **kwargs: Any) -> _models.DeploymentExtended: """Gets a deployment. - :param deployment_name: The name of the deployment. + :param deployment_name: The name of the deployment. Required. :type deployment_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: DeploymentExtended, or the result of cls(response) + :return: DeploymentExtended or the result of cls(response) :rtype: ~azure.mgmt.resource.resources.v2021_01_01.models.DeploymentExtended - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.DeploymentExtended"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) - api_version = kwargs.pop('api_version', "2021-01-01") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-01-01")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[_models.DeploymentExtended] - request = build_deployments_get_at_subscription_scope_request( deployment_name=deployment_name, subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.get_at_subscription_scope.metadata['url'], + template_url=self.get_at_subscription_scope.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) - deserialized = self._deserialize('DeploymentExtended', pipeline_response) + deserialized = self._deserialize("DeploymentExtended", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - get_at_subscription_scope.metadata = {'url': "/subscriptions/{subscriptionId}/providers/Microsoft.Resources/deployments/{deploymentName}"} # type: ignore - + get_at_subscription_scope.metadata = {"url": "/subscriptions/{subscriptionId}/providers/Microsoft.Resources/deployments/{deploymentName}"} # type: ignore @distributed_trace_async async def cancel_at_subscription_scope( # pylint: disable=inconsistent-return-statements - self, - deployment_name: str, - **kwargs: Any + self, deployment_name: str, **kwargs: Any ) -> None: """Cancels a currently running template deployment. @@ -2744,36 +3620,42 @@ async def cancel_at_subscription_scope( # pylint: disable=inconsistent-return-s deployment stops the currently running template deployment and leaves the resources partially deployed. - :param deployment_name: The name of the deployment. + :param deployment_name: The name of the deployment. Required. :type deployment_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: None, or the result of cls(response) + :return: None or the result of cls(response) :rtype: None - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType[None] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) - api_version = kwargs.pop('api_version', "2021-01-01") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-01-01")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[None] - request = build_deployments_cancel_at_subscription_scope_request( deployment_name=deployment_name, subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.cancel_at_subscription_scope.metadata['url'], + template_url=self.cancel_at_subscription_scope.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [204]: @@ -2783,42 +3665,52 @@ async def cancel_at_subscription_scope( # pylint: disable=inconsistent-return-s if cls: return cls(pipeline_response, None, {}) - cancel_at_subscription_scope.metadata = {'url': "/subscriptions/{subscriptionId}/providers/Microsoft.Resources/deployments/{deploymentName}/cancel"} # type: ignore - + cancel_at_subscription_scope.metadata = {"url": "/subscriptions/{subscriptionId}/providers/Microsoft.Resources/deployments/{deploymentName}/cancel"} # type: ignore async def _validate_at_subscription_scope_initial( - self, - deployment_name: str, - parameters: "_models.Deployment", - **kwargs: Any - ) -> Optional["_models.DeploymentValidateResult"]: - cls = kwargs.pop('cls', None) # type: ClsType[Optional["_models.DeploymentValidateResult"]] + self, deployment_name: str, parameters: Union[_models.Deployment, IO], **kwargs: Any + ) -> Optional[_models.DeploymentValidateResult]: error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) - api_version = kwargs.pop('api_version', "2021-01-01") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - _json = self._serialize.body(parameters, 'Deployment') + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-01-01")) # type: str + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[Optional[_models.DeploymentValidateResult]] - request = build_deployments_validate_at_subscription_scope_request_initial( + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(parameters, (IO, bytes)): + _content = parameters + else: + _json = self._serialize.body(parameters, "Deployment") + + request = build_deployments_validate_at_subscription_scope_request( deployment_name=deployment_name, subscription_id=self._config.subscription_id, api_version=api_version, content_type=content_type, json=_json, - template_url=self._validate_at_subscription_scope_initial.metadata['url'], + content=_content, + template_url=self._validate_at_subscription_scope_initial.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200, 202, 400]: @@ -2827,33 +3719,37 @@ async def _validate_at_subscription_scope_initial( deserialized = None if response.status_code == 200: - deserialized = self._deserialize('DeploymentValidateResult', pipeline_response) + deserialized = self._deserialize("DeploymentValidateResult", pipeline_response) if response.status_code == 400: - deserialized = self._deserialize('DeploymentValidateResult', pipeline_response) + deserialized = self._deserialize("DeploymentValidateResult", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - _validate_at_subscription_scope_initial.metadata = {'url': "/subscriptions/{subscriptionId}/providers/Microsoft.Resources/deployments/{deploymentName}/validate"} # type: ignore + _validate_at_subscription_scope_initial.metadata = {"url": "/subscriptions/{subscriptionId}/providers/Microsoft.Resources/deployments/{deploymentName}/validate"} # type: ignore - - @distributed_trace_async + @overload async def begin_validate_at_subscription_scope( self, deployment_name: str, - parameters: "_models.Deployment", + parameters: _models.Deployment, + *, + content_type: str = "application/json", **kwargs: Any - ) -> AsyncLROPoller["_models.DeploymentValidateResult"]: + ) -> AsyncLROPoller[_models.DeploymentValidateResult]: """Validates whether the specified template is syntactically correct and will be accepted by Azure Resource Manager.. - :param deployment_name: The name of the deployment. + :param deployment_name: The name of the deployment. Required. :type deployment_name: str - :param parameters: Parameters to validate. + :param parameters: Parameters to validate. Required. :type parameters: ~azure.mgmt.resource.resources.v2021_01_01.models.Deployment + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str :keyword callable cls: A custom type or function that will be passed the direct response :keyword str continuation_token: A continuation token to restart a poller from a saved state. :keyword polling: By default, your polling method will be AsyncARMPolling. Pass in False for @@ -2866,83 +3762,155 @@ async def begin_validate_at_subscription_scope( result of cls(response) :rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.resource.resources.v2021_01_01.models.DeploymentValidateResult] - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - api_version = kwargs.pop('api_version', "2021-01-01") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] - polling = kwargs.pop('polling', True) # type: Union[bool, AsyncPollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType["_models.DeploymentValidateResult"] - lro_delay = kwargs.pop( - 'polling_interval', - self._config.polling_interval - ) - cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] - if cont_token is None: - raw_result = await self._validate_at_subscription_scope_initial( - deployment_name=deployment_name, - parameters=parameters, - api_version=api_version, - content_type=content_type, - cls=lambda x,y,z: x, - **kwargs - ) - kwargs.pop('error_map', None) - - def get_long_running_output(pipeline_response): - response = pipeline_response.http_response - deserialized = self._deserialize('DeploymentValidateResult', pipeline_response) - if cls: - return cls(pipeline_response, deserialized, {}) - return deserialized + @overload + async def begin_validate_at_subscription_scope( + self, deployment_name: str, parameters: IO, *, content_type: str = "application/json", **kwargs: Any + ) -> AsyncLROPoller[_models.DeploymentValidateResult]: + """Validates whether the specified template is syntactically correct and will be accepted by Azure + Resource Manager.. - if polling is True: polling_method = AsyncARMPolling(lro_delay, **kwargs) - elif polling is False: polling_method = AsyncNoPolling() - else: polling_method = polling - if cont_token: - return AsyncLROPoller.from_continuation_token( - polling_method=polling_method, - continuation_token=cont_token, - client=self._client, - deserialization_callback=get_long_running_output + :param deployment_name: The name of the deployment. Required. + :type deployment_name: str + :param parameters: Parameters to validate. Required. + :type parameters: IO + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be AsyncARMPolling. Pass in False for + this operation to not poll, or pass in your own initialized polling object for a personal + polling strategy. + :paramtype polling: bool or ~azure.core.polling.AsyncPollingMethod + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of AsyncLROPoller that returns either DeploymentValidateResult or the + result of cls(response) + :rtype: + ~azure.core.polling.AsyncLROPoller[~azure.mgmt.resource.resources.v2021_01_01.models.DeploymentValidateResult] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace_async + async def begin_validate_at_subscription_scope( + self, deployment_name: str, parameters: Union[_models.Deployment, IO], **kwargs: Any + ) -> AsyncLROPoller[_models.DeploymentValidateResult]: + """Validates whether the specified template is syntactically correct and will be accepted by Azure + Resource Manager.. + + :param deployment_name: The name of the deployment. Required. + :type deployment_name: str + :param parameters: Parameters to validate. Is either a model type or a IO type. Required. + :type parameters: ~azure.mgmt.resource.resources.v2021_01_01.models.Deployment or IO + :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. + Default value is None. + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be AsyncARMPolling. Pass in False for + this operation to not poll, or pass in your own initialized polling object for a personal + polling strategy. + :paramtype polling: bool or ~azure.core.polling.AsyncPollingMethod + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of AsyncLROPoller that returns either DeploymentValidateResult or the + result of cls(response) + :rtype: + ~azure.core.polling.AsyncLROPoller[~azure.mgmt.resource.resources.v2021_01_01.models.DeploymentValidateResult] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _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-01-01")) # type: str + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.DeploymentValidateResult] + polling = kwargs.pop("polling", True) # type: Union[bool, AsyncPollingMethod] + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token = kwargs.pop("continuation_token", None) # type: Optional[str] + if cont_token is None: + raw_result = await self._validate_at_subscription_scope_initial( # type: ignore + deployment_name=deployment_name, + parameters=parameters, + api_version=api_version, + content_type=content_type, + cls=lambda x, y, z: x, + headers=_headers, + params=_params, + **kwargs + ) + kwargs.pop("error_map", None) + + def get_long_running_output(pipeline_response): + deserialized = self._deserialize("DeploymentValidateResult", pipeline_response) + if cls: + return cls(pipeline_response, deserialized, {}) + return deserialized + + if polling is True: + polling_method = cast(AsyncPollingMethod, AsyncARMPolling(lro_delay, **kwargs)) # type: AsyncPollingMethod + elif polling is False: + polling_method = cast(AsyncPollingMethod, AsyncNoPolling()) + else: + polling_method = polling + if cont_token: + return AsyncLROPoller.from_continuation_token( + polling_method=polling_method, + continuation_token=cont_token, + client=self._client, + deserialization_callback=get_long_running_output, ) return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) - begin_validate_at_subscription_scope.metadata = {'url': "/subscriptions/{subscriptionId}/providers/Microsoft.Resources/deployments/{deploymentName}/validate"} # type: ignore + begin_validate_at_subscription_scope.metadata = {"url": "/subscriptions/{subscriptionId}/providers/Microsoft.Resources/deployments/{deploymentName}/validate"} # type: ignore async def _what_if_at_subscription_scope_initial( - self, - deployment_name: str, - parameters: "_models.DeploymentWhatIf", - **kwargs: Any - ) -> Optional["_models.WhatIfOperationResult"]: - cls = kwargs.pop('cls', None) # type: ClsType[Optional["_models.WhatIfOperationResult"]] + self, deployment_name: str, parameters: Union[_models.DeploymentWhatIf, IO], **kwargs: Any + ) -> Optional[_models.WhatIfOperationResult]: error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) - api_version = kwargs.pop('api_version', "2021-01-01") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - _json = self._serialize.body(parameters, 'DeploymentWhatIf') + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-01-01")) # type: str + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[Optional[_models.WhatIfOperationResult]] - request = build_deployments_what_if_at_subscription_scope_request_initial( + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(parameters, (IO, bytes)): + _content = parameters + else: + _json = self._serialize.body(parameters, "DeploymentWhatIf") + + request = build_deployments_what_if_at_subscription_scope_request( deployment_name=deployment_name, subscription_id=self._config.subscription_id, api_version=api_version, content_type=content_type, json=_json, - template_url=self._what_if_at_subscription_scope_initial.metadata['url'], + content=_content, + template_url=self._what_if_at_subscription_scope_initial.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200, 202]: @@ -2952,35 +3920,38 @@ async def _what_if_at_subscription_scope_initial( deserialized = None response_headers = {} if response.status_code == 200: - deserialized = self._deserialize('WhatIfOperationResult', pipeline_response) + deserialized = self._deserialize("WhatIfOperationResult", pipeline_response) if response.status_code == 202: - response_headers['Location']=self._deserialize('str', response.headers.get('Location')) - response_headers['Retry-After']=self._deserialize('str', response.headers.get('Retry-After')) - + response_headers["Location"] = self._deserialize("str", response.headers.get("Location")) + response_headers["Retry-After"] = self._deserialize("str", response.headers.get("Retry-After")) if cls: return cls(pipeline_response, deserialized, response_headers) return deserialized - _what_if_at_subscription_scope_initial.metadata = {'url': "/subscriptions/{subscriptionId}/providers/Microsoft.Resources/deployments/{deploymentName}/whatIf"} # type: ignore + _what_if_at_subscription_scope_initial.metadata = {"url": "/subscriptions/{subscriptionId}/providers/Microsoft.Resources/deployments/{deploymentName}/whatIf"} # type: ignore - - @distributed_trace_async + @overload async def begin_what_if_at_subscription_scope( self, deployment_name: str, - parameters: "_models.DeploymentWhatIf", + parameters: _models.DeploymentWhatIf, + *, + content_type: str = "application/json", **kwargs: Any - ) -> AsyncLROPoller["_models.WhatIfOperationResult"]: + ) -> AsyncLROPoller[_models.WhatIfOperationResult]: """Returns changes that will be made by the deployment if executed at the scope of the subscription. - :param deployment_name: The name of the deployment. + :param deployment_name: The name of the deployment. Required. :type deployment_name: str - :param parameters: Parameters to What If. + :param parameters: Parameters to What If. Required. :type parameters: ~azure.mgmt.resource.resources.v2021_01_01.models.DeploymentWhatIf + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str :keyword callable cls: A custom type or function that will be passed the direct response :keyword str continuation_token: A continuation token to restart a poller from a saved state. :keyword polling: By default, your polling method will be AsyncARMPolling. Pass in False for @@ -2993,111 +3964,174 @@ async def begin_what_if_at_subscription_scope( of cls(response) :rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.resource.resources.v2021_01_01.models.WhatIfOperationResult] - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - api_version = kwargs.pop('api_version', "2021-01-01") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] - polling = kwargs.pop('polling', True) # type: Union[bool, AsyncPollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType["_models.WhatIfOperationResult"] - lro_delay = kwargs.pop( - 'polling_interval', - self._config.polling_interval - ) - cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] + + @overload + async def begin_what_if_at_subscription_scope( + self, deployment_name: str, parameters: IO, *, content_type: str = "application/json", **kwargs: Any + ) -> AsyncLROPoller[_models.WhatIfOperationResult]: + """Returns changes that will be made by the deployment if executed at the scope of the + subscription. + + :param deployment_name: The name of the deployment. Required. + :type deployment_name: str + :param parameters: Parameters to What If. Required. + :type parameters: IO + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be AsyncARMPolling. Pass in False for + this operation to not poll, or pass in your own initialized polling object for a personal + polling strategy. + :paramtype polling: bool or ~azure.core.polling.AsyncPollingMethod + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of AsyncLROPoller that returns either WhatIfOperationResult or the result + of cls(response) + :rtype: + ~azure.core.polling.AsyncLROPoller[~azure.mgmt.resource.resources.v2021_01_01.models.WhatIfOperationResult] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace_async + async def begin_what_if_at_subscription_scope( + self, deployment_name: str, parameters: Union[_models.DeploymentWhatIf, IO], **kwargs: Any + ) -> AsyncLROPoller[_models.WhatIfOperationResult]: + """Returns changes that will be made by the deployment if executed at the scope of the + subscription. + + :param deployment_name: The name of the deployment. Required. + :type deployment_name: str + :param parameters: Parameters to What If. Is either a model type or a IO type. Required. + :type parameters: ~azure.mgmt.resource.resources.v2021_01_01.models.DeploymentWhatIf or IO + :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. + Default value is None. + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be AsyncARMPolling. Pass in False for + this operation to not poll, or pass in your own initialized polling object for a personal + polling strategy. + :paramtype polling: bool or ~azure.core.polling.AsyncPollingMethod + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of AsyncLROPoller that returns either WhatIfOperationResult or the result + of cls(response) + :rtype: + ~azure.core.polling.AsyncLROPoller[~azure.mgmt.resource.resources.v2021_01_01.models.WhatIfOperationResult] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _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-01-01")) # type: str + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.WhatIfOperationResult] + polling = kwargs.pop("polling", True) # type: Union[bool, AsyncPollingMethod] + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token = kwargs.pop("continuation_token", None) # type: Optional[str] if cont_token is None: - raw_result = await self._what_if_at_subscription_scope_initial( + raw_result = await self._what_if_at_subscription_scope_initial( # type: ignore deployment_name=deployment_name, parameters=parameters, api_version=api_version, content_type=content_type, - cls=lambda x,y,z: x, + cls=lambda x, y, z: x, + headers=_headers, + params=_params, **kwargs ) - kwargs.pop('error_map', None) + kwargs.pop("error_map", None) def get_long_running_output(pipeline_response): - response = pipeline_response.http_response - deserialized = self._deserialize('WhatIfOperationResult', pipeline_response) + deserialized = self._deserialize("WhatIfOperationResult", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - - if polling is True: polling_method = AsyncARMPolling(lro_delay, lro_options={'final-state-via': 'location'}, **kwargs) - elif polling is False: polling_method = AsyncNoPolling() - else: polling_method = polling + if polling is True: + polling_method = cast( + AsyncPollingMethod, AsyncARMPolling(lro_delay, lro_options={"final-state-via": "location"}, **kwargs) + ) # type: AsyncPollingMethod + elif polling is False: + polling_method = cast(AsyncPollingMethod, AsyncNoPolling()) + else: + polling_method = polling if cont_token: return AsyncLROPoller.from_continuation_token( polling_method=polling_method, continuation_token=cont_token, client=self._client, - deserialization_callback=get_long_running_output + deserialization_callback=get_long_running_output, ) return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) - begin_what_if_at_subscription_scope.metadata = {'url': "/subscriptions/{subscriptionId}/providers/Microsoft.Resources/deployments/{deploymentName}/whatIf"} # type: ignore + begin_what_if_at_subscription_scope.metadata = {"url": "/subscriptions/{subscriptionId}/providers/Microsoft.Resources/deployments/{deploymentName}/whatIf"} # type: ignore @distributed_trace_async async def export_template_at_subscription_scope( - self, - deployment_name: str, - **kwargs: Any - ) -> "_models.DeploymentExportResult": + self, deployment_name: str, **kwargs: Any + ) -> _models.DeploymentExportResult: """Exports the template used for specified deployment. - :param deployment_name: The name of the deployment. + :param deployment_name: The name of the deployment. Required. :type deployment_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: DeploymentExportResult, or the result of cls(response) + :return: DeploymentExportResult or the result of cls(response) :rtype: ~azure.mgmt.resource.resources.v2021_01_01.models.DeploymentExportResult - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.DeploymentExportResult"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) - api_version = kwargs.pop('api_version', "2021-01-01") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-01-01")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[_models.DeploymentExportResult] - request = build_deployments_export_template_at_subscription_scope_request( deployment_name=deployment_name, subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.export_template_at_subscription_scope.metadata['url'], + template_url=self.export_template_at_subscription_scope.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) - deserialized = self._deserialize('DeploymentExportResult', pipeline_response) + deserialized = self._deserialize("DeploymentExportResult", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - export_template_at_subscription_scope.metadata = {'url': "/subscriptions/{subscriptionId}/providers/Microsoft.Resources/deployments/{deploymentName}/exportTemplate"} # type: ignore - + export_template_at_subscription_scope.metadata = {"url": "/subscriptions/{subscriptionId}/providers/Microsoft.Resources/deployments/{deploymentName}/exportTemplate"} # type: ignore @distributed_trace def list_at_subscription_scope( - self, - filter: Optional[str] = None, - top: Optional[int] = None, - **kwargs: Any - ) -> AsyncIterable["_models.DeploymentListResult"]: + self, filter: Optional[str] = None, top: Optional[int] = None, **kwargs: Any + ) -> AsyncIterable["_models.DeploymentExtended"]: """Get all the deployments for a subscription. :param filter: The filter to apply on the operation. For example, you can use @@ -3107,40 +4141,48 @@ def list_at_subscription_scope( value is None. :type top: int :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either DeploymentListResult or the result of - cls(response) + :return: An iterator like instance of either DeploymentExtended or the result of cls(response) :rtype: - ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.resource.resources.v2021_01_01.models.DeploymentListResult] - :raises: ~azure.core.exceptions.HttpResponseError + ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.resource.resources.v2021_01_01.models.DeploymentExtended] + :raises ~azure.core.exceptions.HttpResponseError: """ - api_version = kwargs.pop('api_version', "2021-01-01") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-01-01")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[_models.DeploymentListResult] - cls = kwargs.pop('cls', None) # type: ClsType["_models.DeploymentListResult"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) + def prepare_request(next_link=None): if not next_link: - + request = build_deployments_list_at_subscription_scope_request( subscription_id=self._config.subscription_id, - api_version=api_version, filter=filter, top=top, - template_url=self.list_at_subscription_scope.metadata['url'], + api_version=api_version, + template_url=self.list_at_subscription_scope.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore else: - - request = build_deployments_list_at_subscription_scope_request( - subscription_id=self._config.subscription_id, - template_url=next_link, - ) + # make call to next link with the client's api-version + _parsed_next_link = urlparse(next_link) + _next_request_params = case_insensitive_dict(parse_qs(_parsed_next_link.query)) + _next_request_params["api-version"] = self._config.api_version + request = HttpRequest("GET", urljoin(next_link, _parsed_next_link.path), params=_next_request_params) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore request.method = "GET" return request @@ -3154,10 +4196,8 @@ async def extract_data(pipeline_response): async def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) response = pipeline_response.http_response @@ -3167,42 +4207,43 @@ async def get_next(next_link=None): return pipeline_response + return AsyncItemPaged(get_next, extract_data) - return AsyncItemPaged( - get_next, extract_data - ) - list_at_subscription_scope.metadata = {'url': "/subscriptions/{subscriptionId}/providers/Microsoft.Resources/deployments/"} # type: ignore + list_at_subscription_scope.metadata = {"url": "/subscriptions/{subscriptionId}/providers/Microsoft.Resources/deployments/"} # type: ignore async def _delete_initial( # pylint: disable=inconsistent-return-statements - self, - resource_group_name: str, - deployment_name: str, - **kwargs: Any + self, resource_group_name: str, deployment_name: str, **kwargs: Any ) -> None: - cls = kwargs.pop('cls', None) # type: ClsType[None] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) - api_version = kwargs.pop('api_version', "2021-01-01") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - request = build_deployments_delete_request_initial( + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-01-01")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[None] + + request = build_deployments_delete_request( resource_group_name=resource_group_name, deployment_name=deployment_name, subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self._delete_initial.metadata['url'], + template_url=self._delete_initial.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [202, 204]: @@ -3212,16 +4253,10 @@ 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.Resources/deployments/{deploymentName}"} # type: ignore - + _delete_initial.metadata = {"url": "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/Microsoft.Resources/deployments/{deploymentName}"} # type: ignore @distributed_trace_async - async def begin_delete( # pylint: disable=inconsistent-return-statements - self, - resource_group_name: str, - deployment_name: str, - **kwargs: Any - ) -> AsyncLROPoller[None]: + async def begin_delete(self, resource_group_name: str, deployment_name: str, **kwargs: Any) -> AsyncLROPoller[None]: """Deletes a deployment from the deployment history. A template deployment that is currently running cannot be deleted. Deleting a template @@ -3234,9 +4269,9 @@ async def begin_delete( # pylint: disable=inconsistent-return-statements asynchronous request failed, the URI in the Location header returns an error-level status code. :param resource_group_name: The name of the resource group with the deployment to delete. The - name is case insensitive. + name is case insensitive. Required. :type resource_group_name: str - :param deployment_name: The name of the deployment. + :param deployment_name: The name of the deployment. Required. :type deployment_name: str :keyword callable cls: A custom type or function that will be passed the direct response :keyword str continuation_token: A continuation token to restart a poller from a saved state. @@ -3248,88 +4283,93 @@ async def begin_delete( # pylint: disable=inconsistent-return-statements Retry-After header is present. :return: An instance of AsyncLROPoller that returns either None or the result of cls(response) :rtype: ~azure.core.polling.AsyncLROPoller[None] - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - api_version = kwargs.pop('api_version', "2021-01-01") # type: str - polling = kwargs.pop('polling', True) # type: Union[bool, AsyncPollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType[None] - lro_delay = kwargs.pop( - 'polling_interval', - self._config.polling_interval - ) - cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-01-01")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[None] + polling = kwargs.pop("polling", True) # type: Union[bool, AsyncPollingMethod] + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token = kwargs.pop("continuation_token", None) # type: Optional[str] if cont_token is None: - raw_result = await self._delete_initial( + raw_result = await self._delete_initial( # type: ignore resource_group_name=resource_group_name, deployment_name=deployment_name, api_version=api_version, - cls=lambda x,y,z: x, + cls=lambda x, y, z: x, + headers=_headers, + params=_params, **kwargs ) - kwargs.pop('error_map', None) + kwargs.pop("error_map", None) - def get_long_running_output(pipeline_response): + def get_long_running_output(pipeline_response): # pylint: disable=inconsistent-return-statements if cls: return cls(pipeline_response, None, {}) - - if polling is True: polling_method = AsyncARMPolling(lro_delay, **kwargs) - elif polling is False: polling_method = AsyncNoPolling() - else: polling_method = polling + if polling is True: + polling_method = cast(AsyncPollingMethod, AsyncARMPolling(lro_delay, **kwargs)) # type: AsyncPollingMethod + elif polling is False: + polling_method = cast(AsyncPollingMethod, AsyncNoPolling()) + else: + polling_method = polling if cont_token: return AsyncLROPoller.from_continuation_token( polling_method=polling_method, continuation_token=cont_token, client=self._client, - deserialization_callback=get_long_running_output + deserialization_callback=get_long_running_output, ) return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) - begin_delete.metadata = {'url': "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/Microsoft.Resources/deployments/{deploymentName}"} # type: ignore + begin_delete.metadata = {"url": "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/Microsoft.Resources/deployments/{deploymentName}"} # type: ignore @distributed_trace_async - async def check_existence( - self, - resource_group_name: str, - deployment_name: str, - **kwargs: Any - ) -> bool: + async def check_existence(self, resource_group_name: str, deployment_name: str, **kwargs: Any) -> bool: """Checks whether the deployment exists. :param resource_group_name: The name of the resource group with the deployment to check. The - name is case insensitive. + name is case insensitive. Required. :type resource_group_name: str - :param deployment_name: The name of the deployment. + :param deployment_name: The name of the deployment. Required. :type deployment_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: bool, or the result of cls(response) + :return: bool or the result of cls(response) :rtype: bool - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType[None] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + 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', "2021-01-01") # type: str + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-01-01")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[None] - request = build_deployments_check_existence_request( resource_group_name=resource_group_name, deployment_name=deployment_name, subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.check_existence.metadata['url'], + template_url=self.check_existence.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [204, 404]: @@ -3340,44 +4380,53 @@ async def check_existence( return cls(pipeline_response, None, {}) return 200 <= response.status_code <= 299 - check_existence.metadata = {'url': "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/Microsoft.Resources/deployments/{deploymentName}"} # type: ignore - + check_existence.metadata = {"url": "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/Microsoft.Resources/deployments/{deploymentName}"} # type: ignore async def _create_or_update_initial( - self, - resource_group_name: str, - deployment_name: str, - parameters: "_models.Deployment", - **kwargs: Any - ) -> "_models.DeploymentExtended": - cls = kwargs.pop('cls', None) # type: ClsType["_models.DeploymentExtended"] + self, resource_group_name: str, deployment_name: str, parameters: Union[_models.Deployment, IO], **kwargs: Any + ) -> _models.DeploymentExtended: error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) - api_version = kwargs.pop('api_version', "2021-01-01") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - _json = self._serialize.body(parameters, 'Deployment') + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-01-01")) # type: str + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.DeploymentExtended] - request = build_deployments_create_or_update_request_initial( + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(parameters, (IO, bytes)): + _content = parameters + else: + _json = self._serialize.body(parameters, "Deployment") + + request = build_deployments_create_or_update_request( resource_group_name=resource_group_name, deployment_name=deployment_name, subscription_id=self._config.subscription_id, api_version=api_version, content_type=content_type, json=_json, - template_url=self._create_or_update_initial.metadata['url'], + content=_content, + template_url=self._create_or_update_initial.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200, 201]: @@ -3385,38 +4434,42 @@ async def _create_or_update_initial( raise HttpResponseError(response=response, error_format=ARMErrorFormat) if response.status_code == 200: - deserialized = self._deserialize('DeploymentExtended', pipeline_response) + deserialized = self._deserialize("DeploymentExtended", pipeline_response) if response.status_code == 201: - deserialized = self._deserialize('DeploymentExtended', pipeline_response) + deserialized = self._deserialize("DeploymentExtended", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - _create_or_update_initial.metadata = {'url': "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/Microsoft.Resources/deployments/{deploymentName}"} # type: ignore + _create_or_update_initial.metadata = {"url": "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/Microsoft.Resources/deployments/{deploymentName}"} # type: ignore - - @distributed_trace_async + @overload async def begin_create_or_update( self, resource_group_name: str, deployment_name: str, - parameters: "_models.Deployment", + parameters: _models.Deployment, + *, + content_type: str = "application/json", **kwargs: Any - ) -> AsyncLROPoller["_models.DeploymentExtended"]: + ) -> AsyncLROPoller[_models.DeploymentExtended]: """Deploys resources to a resource group. You can provide the template and parameters directly in the request or link to JSON files. :param resource_group_name: The name of the resource group to deploy the resources to. The name - is case insensitive. The resource group must already exist. + is case insensitive. The resource group must already exist. Required. :type resource_group_name: str - :param deployment_name: The name of the deployment. + :param deployment_name: The name of the deployment. Required. :type deployment_name: str - :param parameters: Additional parameters supplied to the operation. + :param parameters: Additional parameters supplied to the operation. Required. :type parameters: ~azure.mgmt.resource.resources.v2021_01_01.models.Deployment + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str :keyword callable cls: A custom type or function that will be passed the direct response :keyword str continuation_token: A continuation token to restart a poller from a saved state. :keyword polling: By default, your polling method will be AsyncARMPolling. Pass in False for @@ -3429,115 +4482,189 @@ async def begin_create_or_update( cls(response) :rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.resource.resources.v2021_01_01.models.DeploymentExtended] - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - api_version = kwargs.pop('api_version', "2021-01-01") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] - polling = kwargs.pop('polling', True) # type: Union[bool, AsyncPollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType["_models.DeploymentExtended"] - lro_delay = kwargs.pop( - 'polling_interval', - self._config.polling_interval - ) - cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] + + @overload + async def begin_create_or_update( + self, + resource_group_name: str, + deployment_name: str, + parameters: IO, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> AsyncLROPoller[_models.DeploymentExtended]: + """Deploys resources to a resource group. + + You can provide the template and parameters directly in the request or link to JSON files. + + :param resource_group_name: The name of the resource group to deploy the resources to. The name + is case insensitive. The resource group must already exist. Required. + :type resource_group_name: str + :param deployment_name: The name of the deployment. Required. + :type deployment_name: str + :param parameters: Additional parameters supplied to the operation. Required. + :type parameters: IO + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be AsyncARMPolling. Pass in False for + this operation to not poll, or pass in your own initialized polling object for a personal + polling strategy. + :paramtype polling: bool or ~azure.core.polling.AsyncPollingMethod + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of AsyncLROPoller that returns either DeploymentExtended or the result of + cls(response) + :rtype: + ~azure.core.polling.AsyncLROPoller[~azure.mgmt.resource.resources.v2021_01_01.models.DeploymentExtended] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace_async + async def begin_create_or_update( + self, resource_group_name: str, deployment_name: str, parameters: Union[_models.Deployment, IO], **kwargs: Any + ) -> AsyncLROPoller[_models.DeploymentExtended]: + """Deploys resources to a resource group. + + You can provide the template and parameters directly in the request or link to JSON files. + + :param resource_group_name: The name of the resource group to deploy the resources to. The name + is case insensitive. The resource group must already exist. Required. + :type resource_group_name: str + :param deployment_name: The name of the deployment. Required. + :type deployment_name: str + :param parameters: Additional parameters supplied to the operation. Is either a model type or a + IO type. Required. + :type parameters: ~azure.mgmt.resource.resources.v2021_01_01.models.Deployment or IO + :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. + Default value is None. + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be AsyncARMPolling. Pass in False for + this operation to not poll, or pass in your own initialized polling object for a personal + polling strategy. + :paramtype polling: bool or ~azure.core.polling.AsyncPollingMethod + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of AsyncLROPoller that returns either DeploymentExtended or the result of + cls(response) + :rtype: + ~azure.core.polling.AsyncLROPoller[~azure.mgmt.resource.resources.v2021_01_01.models.DeploymentExtended] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _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-01-01")) # type: str + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.DeploymentExtended] + polling = kwargs.pop("polling", True) # type: Union[bool, AsyncPollingMethod] + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token = kwargs.pop("continuation_token", None) # type: Optional[str] if cont_token is None: - raw_result = await self._create_or_update_initial( + raw_result = await self._create_or_update_initial( # type: ignore resource_group_name=resource_group_name, deployment_name=deployment_name, parameters=parameters, api_version=api_version, content_type=content_type, - cls=lambda x,y,z: x, + cls=lambda x, y, z: x, + headers=_headers, + params=_params, **kwargs ) - kwargs.pop('error_map', None) + kwargs.pop("error_map", None) def get_long_running_output(pipeline_response): - response = pipeline_response.http_response - deserialized = self._deserialize('DeploymentExtended', pipeline_response) + deserialized = self._deserialize("DeploymentExtended", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - - if polling is True: polling_method = AsyncARMPolling(lro_delay, **kwargs) - elif polling is False: polling_method = AsyncNoPolling() - else: polling_method = polling + if polling is True: + polling_method = cast(AsyncPollingMethod, AsyncARMPolling(lro_delay, **kwargs)) # type: AsyncPollingMethod + elif polling is False: + polling_method = cast(AsyncPollingMethod, AsyncNoPolling()) + else: + polling_method = polling if cont_token: return AsyncLROPoller.from_continuation_token( polling_method=polling_method, continuation_token=cont_token, client=self._client, - deserialization_callback=get_long_running_output + deserialization_callback=get_long_running_output, ) return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) - begin_create_or_update.metadata = {'url': "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/Microsoft.Resources/deployments/{deploymentName}"} # type: ignore + begin_create_or_update.metadata = {"url": "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/Microsoft.Resources/deployments/{deploymentName}"} # type: ignore @distributed_trace_async - async def get( - self, - resource_group_name: str, - deployment_name: str, - **kwargs: Any - ) -> "_models.DeploymentExtended": + async def get(self, resource_group_name: str, deployment_name: str, **kwargs: Any) -> _models.DeploymentExtended: """Gets a deployment. :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. :type resource_group_name: str - :param deployment_name: The name of the deployment. + :param deployment_name: The name of the deployment. Required. :type deployment_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: DeploymentExtended, or the result of cls(response) + :return: DeploymentExtended or the result of cls(response) :rtype: ~azure.mgmt.resource.resources.v2021_01_01.models.DeploymentExtended - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.DeploymentExtended"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) - api_version = kwargs.pop('api_version', "2021-01-01") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-01-01")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[_models.DeploymentExtended] - request = build_deployments_get_request( resource_group_name=resource_group_name, deployment_name=deployment_name, subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.get.metadata['url'], + template_url=self.get.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) - deserialized = self._deserialize('DeploymentExtended', pipeline_response) + deserialized = self._deserialize("DeploymentExtended", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - get.metadata = {'url': "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/Microsoft.Resources/deployments/{deploymentName}"} # type: ignore - + get.metadata = {"url": "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/Microsoft.Resources/deployments/{deploymentName}"} # type: ignore @distributed_trace_async async def cancel( # pylint: disable=inconsistent-return-statements - self, - resource_group_name: str, - deployment_name: str, - **kwargs: Any + self, resource_group_name: str, deployment_name: str, **kwargs: Any ) -> None: """Cancels a currently running template deployment. @@ -3547,38 +4674,45 @@ async def cancel( # pylint: disable=inconsistent-return-statements partially deployed. :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. :type resource_group_name: str - :param deployment_name: The name of the deployment. + :param deployment_name: The name of the deployment. Required. :type deployment_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: None, or the result of cls(response) + :return: None or the result of cls(response) :rtype: None - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType[None] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + 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', "2021-01-01") # type: str + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-01-01")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[None] - request = build_deployments_cancel_request( resource_group_name=resource_group_name, deployment_name=deployment_name, subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.cancel.metadata['url'], + template_url=self.cancel.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [204]: @@ -3588,44 +4722,53 @@ async def cancel( # pylint: disable=inconsistent-return-statements if cls: return cls(pipeline_response, None, {}) - cancel.metadata = {'url': "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/Microsoft.Resources/deployments/{deploymentName}/cancel"} # type: ignore - + cancel.metadata = {"url": "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/Microsoft.Resources/deployments/{deploymentName}/cancel"} # type: ignore async def _validate_initial( - self, - resource_group_name: str, - deployment_name: str, - parameters: "_models.Deployment", - **kwargs: Any - ) -> Optional["_models.DeploymentValidateResult"]: - cls = kwargs.pop('cls', None) # type: ClsType[Optional["_models.DeploymentValidateResult"]] + self, resource_group_name: str, deployment_name: str, parameters: Union[_models.Deployment, IO], **kwargs: Any + ) -> Optional[_models.DeploymentValidateResult]: error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) - api_version = kwargs.pop('api_version', "2021-01-01") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - _json = self._serialize.body(parameters, 'Deployment') + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-01-01")) # type: str + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[Optional[_models.DeploymentValidateResult]] - request = build_deployments_validate_request_initial( + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(parameters, (IO, bytes)): + _content = parameters + else: + _json = self._serialize.body(parameters, "Deployment") + + request = build_deployments_validate_request( resource_group_name=resource_group_name, deployment_name=deployment_name, subscription_id=self._config.subscription_id, api_version=api_version, content_type=content_type, json=_json, - template_url=self._validate_initial.metadata['url'], + content=_content, + template_url=self._validate_initial.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200, 202, 400]: @@ -3634,37 +4777,41 @@ async def _validate_initial( deserialized = None if response.status_code == 200: - deserialized = self._deserialize('DeploymentValidateResult', pipeline_response) + deserialized = self._deserialize("DeploymentValidateResult", pipeline_response) if response.status_code == 400: - deserialized = self._deserialize('DeploymentValidateResult', pipeline_response) + deserialized = self._deserialize("DeploymentValidateResult", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - _validate_initial.metadata = {'url': "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/Microsoft.Resources/deployments/{deploymentName}/validate"} # type: ignore + _validate_initial.metadata = {"url": "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/Microsoft.Resources/deployments/{deploymentName}/validate"} # type: ignore - - @distributed_trace_async + @overload async def begin_validate( self, resource_group_name: str, deployment_name: str, - parameters: "_models.Deployment", + parameters: _models.Deployment, + *, + content_type: str = "application/json", **kwargs: Any - ) -> AsyncLROPoller["_models.DeploymentValidateResult"]: + ) -> AsyncLROPoller[_models.DeploymentValidateResult]: """Validates whether the specified template is syntactically correct and will be accepted by Azure Resource Manager.. :param resource_group_name: The name of the resource group the template will be deployed to. - The name is case insensitive. + The name is case insensitive. Required. :type resource_group_name: str - :param deployment_name: The name of the deployment. + :param deployment_name: The name of the deployment. Required. :type deployment_name: str - :param parameters: Parameters to validate. + :param parameters: Parameters to validate. Required. :type parameters: ~azure.mgmt.resource.resources.v2021_01_01.models.Deployment + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str :keyword callable cls: A custom type or function that will be passed the direct response :keyword str continuation_token: A continuation token to restart a poller from a saved state. :keyword polling: By default, your polling method will be AsyncARMPolling. Pass in False for @@ -3677,86 +4824,173 @@ async def begin_validate( result of cls(response) :rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.resource.resources.v2021_01_01.models.DeploymentValidateResult] - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - api_version = kwargs.pop('api_version', "2021-01-01") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] - polling = kwargs.pop('polling', True) # type: Union[bool, AsyncPollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType["_models.DeploymentValidateResult"] - lro_delay = kwargs.pop( - 'polling_interval', - self._config.polling_interval - ) - cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] - if cont_token is None: - raw_result = await self._validate_initial( - resource_group_name=resource_group_name, - deployment_name=deployment_name, - parameters=parameters, - api_version=api_version, - content_type=content_type, - cls=lambda x,y,z: x, - **kwargs - ) - kwargs.pop('error_map', None) - - def get_long_running_output(pipeline_response): - response = pipeline_response.http_response - deserialized = self._deserialize('DeploymentValidateResult', pipeline_response) - if cls: - return cls(pipeline_response, deserialized, {}) - return deserialized + @overload + async def begin_validate( + self, + resource_group_name: str, + deployment_name: str, + parameters: IO, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> AsyncLROPoller[_models.DeploymentValidateResult]: + """Validates whether the specified template is syntactically correct and will be accepted by Azure + Resource Manager.. - if polling is True: polling_method = AsyncARMPolling(lro_delay, **kwargs) - elif polling is False: polling_method = AsyncNoPolling() - else: polling_method = polling - if cont_token: - return AsyncLROPoller.from_continuation_token( + :param resource_group_name: The name of the resource group the template will be deployed to. + The name is case insensitive. Required. + :type resource_group_name: str + :param deployment_name: The name of the deployment. Required. + :type deployment_name: str + :param parameters: Parameters to validate. Required. + :type parameters: IO + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be AsyncARMPolling. Pass in False for + this operation to not poll, or pass in your own initialized polling object for a personal + polling strategy. + :paramtype polling: bool or ~azure.core.polling.AsyncPollingMethod + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of AsyncLROPoller that returns either DeploymentValidateResult or the + result of cls(response) + :rtype: + ~azure.core.polling.AsyncLROPoller[~azure.mgmt.resource.resources.v2021_01_01.models.DeploymentValidateResult] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace_async + async def begin_validate( + self, resource_group_name: str, deployment_name: str, parameters: Union[_models.Deployment, IO], **kwargs: Any + ) -> AsyncLROPoller[_models.DeploymentValidateResult]: + """Validates whether the specified template is syntactically correct and will be accepted by Azure + Resource Manager.. + + :param resource_group_name: The name of the resource group the template will be deployed to. + The name is case insensitive. Required. + :type resource_group_name: str + :param deployment_name: The name of the deployment. Required. + :type deployment_name: str + :param parameters: Parameters to validate. Is either a model type or a IO type. Required. + :type parameters: ~azure.mgmt.resource.resources.v2021_01_01.models.Deployment or IO + :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. + Default value is None. + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be AsyncARMPolling. Pass in False for + this operation to not poll, or pass in your own initialized polling object for a personal + polling strategy. + :paramtype polling: bool or ~azure.core.polling.AsyncPollingMethod + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of AsyncLROPoller that returns either DeploymentValidateResult or the + result of cls(response) + :rtype: + ~azure.core.polling.AsyncLROPoller[~azure.mgmt.resource.resources.v2021_01_01.models.DeploymentValidateResult] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _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-01-01")) # type: str + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.DeploymentValidateResult] + polling = kwargs.pop("polling", True) # type: Union[bool, AsyncPollingMethod] + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token = kwargs.pop("continuation_token", None) # type: Optional[str] + if cont_token is None: + raw_result = await self._validate_initial( # type: ignore + resource_group_name=resource_group_name, + deployment_name=deployment_name, + parameters=parameters, + api_version=api_version, + content_type=content_type, + cls=lambda x, y, z: x, + headers=_headers, + params=_params, + **kwargs + ) + kwargs.pop("error_map", None) + + def get_long_running_output(pipeline_response): + deserialized = self._deserialize("DeploymentValidateResult", pipeline_response) + if cls: + return cls(pipeline_response, deserialized, {}) + return deserialized + + if polling is True: + polling_method = cast(AsyncPollingMethod, AsyncARMPolling(lro_delay, **kwargs)) # type: AsyncPollingMethod + elif polling is False: + polling_method = cast(AsyncPollingMethod, AsyncNoPolling()) + else: + polling_method = polling + if cont_token: + return AsyncLROPoller.from_continuation_token( polling_method=polling_method, continuation_token=cont_token, client=self._client, - deserialization_callback=get_long_running_output + deserialization_callback=get_long_running_output, ) return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) - begin_validate.metadata = {'url': "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/Microsoft.Resources/deployments/{deploymentName}/validate"} # type: ignore + begin_validate.metadata = {"url": "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/Microsoft.Resources/deployments/{deploymentName}/validate"} # type: ignore async def _what_if_initial( self, resource_group_name: str, deployment_name: str, - parameters: "_models.DeploymentWhatIf", + parameters: Union[_models.DeploymentWhatIf, IO], **kwargs: Any - ) -> Optional["_models.WhatIfOperationResult"]: - cls = kwargs.pop('cls', None) # type: ClsType[Optional["_models.WhatIfOperationResult"]] + ) -> Optional[_models.WhatIfOperationResult]: error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', "2021-01-01") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-01-01")) # type: str + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[Optional[_models.WhatIfOperationResult]] - _json = self._serialize.body(parameters, 'DeploymentWhatIf') + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(parameters, (IO, bytes)): + _content = parameters + else: + _json = self._serialize.body(parameters, "DeploymentWhatIf") - request = build_deployments_what_if_request_initial( + request = build_deployments_what_if_request( resource_group_name=resource_group_name, deployment_name=deployment_name, subscription_id=self._config.subscription_id, api_version=api_version, content_type=content_type, json=_json, - template_url=self._what_if_initial.metadata['url'], + content=_content, + template_url=self._what_if_initial.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200, 202]: @@ -3766,39 +5000,116 @@ async def _what_if_initial( deserialized = None response_headers = {} if response.status_code == 200: - deserialized = self._deserialize('WhatIfOperationResult', pipeline_response) + deserialized = self._deserialize("WhatIfOperationResult", pipeline_response) if response.status_code == 202: - response_headers['Location']=self._deserialize('str', response.headers.get('Location')) - response_headers['Retry-After']=self._deserialize('str', response.headers.get('Retry-After')) - + response_headers["Location"] = self._deserialize("str", response.headers.get("Location")) + response_headers["Retry-After"] = self._deserialize("str", response.headers.get("Retry-After")) if cls: return cls(pipeline_response, deserialized, response_headers) return deserialized - _what_if_initial.metadata = {'url': "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/Microsoft.Resources/deployments/{deploymentName}/whatIf"} # type: ignore + _what_if_initial.metadata = {"url": "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/Microsoft.Resources/deployments/{deploymentName}/whatIf"} # type: ignore + + @overload + async def begin_what_if( + self, + resource_group_name: str, + deployment_name: str, + parameters: _models.DeploymentWhatIf, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> AsyncLROPoller[_models.WhatIfOperationResult]: + """Returns changes that will be made by the deployment if executed at the scope of the resource + group. + + :param resource_group_name: The name of the resource group the template will be deployed to. + The name is case insensitive. Required. + :type resource_group_name: str + :param deployment_name: The name of the deployment. Required. + :type deployment_name: str + :param parameters: Parameters to validate. Required. + :type parameters: ~azure.mgmt.resource.resources.v2021_01_01.models.DeploymentWhatIf + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be AsyncARMPolling. Pass in False for + this operation to not poll, or pass in your own initialized polling object for a personal + polling strategy. + :paramtype polling: bool or ~azure.core.polling.AsyncPollingMethod + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of AsyncLROPoller that returns either WhatIfOperationResult or the result + of cls(response) + :rtype: + ~azure.core.polling.AsyncLROPoller[~azure.mgmt.resource.resources.v2021_01_01.models.WhatIfOperationResult] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + async def begin_what_if( + self, + resource_group_name: str, + deployment_name: str, + parameters: IO, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> AsyncLROPoller[_models.WhatIfOperationResult]: + """Returns changes that will be made by the deployment if executed at the scope of the resource + group. + :param resource_group_name: The name of the resource group the template will be deployed to. + The name is case insensitive. Required. + :type resource_group_name: str + :param deployment_name: The name of the deployment. Required. + :type deployment_name: str + :param parameters: Parameters to validate. Required. + :type parameters: IO + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be AsyncARMPolling. Pass in False for + this operation to not poll, or pass in your own initialized polling object for a personal + polling strategy. + :paramtype polling: bool or ~azure.core.polling.AsyncPollingMethod + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of AsyncLROPoller that returns either WhatIfOperationResult or the result + of cls(response) + :rtype: + ~azure.core.polling.AsyncLROPoller[~azure.mgmt.resource.resources.v2021_01_01.models.WhatIfOperationResult] + :raises ~azure.core.exceptions.HttpResponseError: + """ @distributed_trace_async async def begin_what_if( self, resource_group_name: str, deployment_name: str, - parameters: "_models.DeploymentWhatIf", + parameters: Union[_models.DeploymentWhatIf, IO], **kwargs: Any - ) -> AsyncLROPoller["_models.WhatIfOperationResult"]: + ) -> AsyncLROPoller[_models.WhatIfOperationResult]: """Returns changes that will be made by the deployment if executed at the scope of the resource group. :param resource_group_name: The name of the resource group the template will be deployed to. - The name is case insensitive. + The name is case insensitive. Required. :type resource_group_name: str - :param deployment_name: The name of the deployment. + :param deployment_name: The name of the deployment. Required. :type deployment_name: str - :param parameters: Parameters to validate. - :type parameters: ~azure.mgmt.resource.resources.v2021_01_01.models.DeploymentWhatIf + :param parameters: Parameters to validate. Is either a model type or a IO type. Required. + :type parameters: ~azure.mgmt.resource.resources.v2021_01_01.models.DeploymentWhatIf or IO + :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. + Default value is None. + :paramtype content_type: str :keyword callable cls: A custom type or function that will be passed the direct response :keyword str continuation_token: A continuation token to restart a poller from a saved state. :keyword polling: By default, your polling method will be AsyncARMPolling. Pass in False for @@ -3811,121 +5122,125 @@ async def begin_what_if( of cls(response) :rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.resource.resources.v2021_01_01.models.WhatIfOperationResult] - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - api_version = kwargs.pop('api_version', "2021-01-01") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] - polling = kwargs.pop('polling', True) # type: Union[bool, AsyncPollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType["_models.WhatIfOperationResult"] - lro_delay = kwargs.pop( - 'polling_interval', - self._config.polling_interval - ) - cont_token = kwargs.pop('continuation_token', None) # type: Optional[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-01-01")) # type: str + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.WhatIfOperationResult] + polling = kwargs.pop("polling", True) # type: Union[bool, AsyncPollingMethod] + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token = kwargs.pop("continuation_token", None) # type: Optional[str] if cont_token is None: - raw_result = await self._what_if_initial( + raw_result = await self._what_if_initial( # type: ignore resource_group_name=resource_group_name, deployment_name=deployment_name, parameters=parameters, api_version=api_version, content_type=content_type, - cls=lambda x,y,z: x, + cls=lambda x, y, z: x, + headers=_headers, + params=_params, **kwargs ) - kwargs.pop('error_map', None) + kwargs.pop("error_map", None) def get_long_running_output(pipeline_response): - response = pipeline_response.http_response - deserialized = self._deserialize('WhatIfOperationResult', pipeline_response) + deserialized = self._deserialize("WhatIfOperationResult", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - - if polling is True: polling_method = AsyncARMPolling(lro_delay, lro_options={'final-state-via': 'location'}, **kwargs) - elif polling is False: polling_method = AsyncNoPolling() - else: polling_method = polling + if polling is True: + polling_method = cast( + AsyncPollingMethod, AsyncARMPolling(lro_delay, lro_options={"final-state-via": "location"}, **kwargs) + ) # type: AsyncPollingMethod + elif polling is False: + polling_method = cast(AsyncPollingMethod, AsyncNoPolling()) + else: + polling_method = polling if cont_token: return AsyncLROPoller.from_continuation_token( polling_method=polling_method, continuation_token=cont_token, client=self._client, - deserialization_callback=get_long_running_output + deserialization_callback=get_long_running_output, ) return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) - begin_what_if.metadata = {'url': "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/Microsoft.Resources/deployments/{deploymentName}/whatIf"} # type: ignore + begin_what_if.metadata = {"url": "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/Microsoft.Resources/deployments/{deploymentName}/whatIf"} # type: ignore @distributed_trace_async async def export_template( - self, - resource_group_name: str, - deployment_name: str, - **kwargs: Any - ) -> "_models.DeploymentExportResult": + self, resource_group_name: str, deployment_name: str, **kwargs: Any + ) -> _models.DeploymentExportResult: """Exports the template used for specified deployment. :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. :type resource_group_name: str - :param deployment_name: The name of the deployment. + :param deployment_name: The name of the deployment. Required. :type deployment_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: DeploymentExportResult, or the result of cls(response) + :return: DeploymentExportResult or the result of cls(response) :rtype: ~azure.mgmt.resource.resources.v2021_01_01.models.DeploymentExportResult - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.DeploymentExportResult"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) - api_version = kwargs.pop('api_version', "2021-01-01") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-01-01")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[_models.DeploymentExportResult] - request = build_deployments_export_template_request( resource_group_name=resource_group_name, deployment_name=deployment_name, subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.export_template.metadata['url'], + template_url=self.export_template.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) - deserialized = self._deserialize('DeploymentExportResult', pipeline_response) + deserialized = self._deserialize("DeploymentExportResult", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - export_template.metadata = {'url': "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/Microsoft.Resources/deployments/{deploymentName}/exportTemplate"} # type: ignore - + export_template.metadata = {"url": "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/Microsoft.Resources/deployments/{deploymentName}/exportTemplate"} # type: ignore @distributed_trace def list_by_resource_group( - self, - resource_group_name: str, - filter: Optional[str] = None, - top: Optional[int] = None, - **kwargs: Any - ) -> AsyncIterable["_models.DeploymentListResult"]: + self, resource_group_name: str, filter: Optional[str] = None, top: Optional[int] = None, **kwargs: Any + ) -> AsyncIterable["_models.DeploymentExtended"]: """Get all the deployments for a resource group. :param resource_group_name: The name of the resource group with the deployments to get. The - name is case insensitive. + name is case insensitive. Required. :type resource_group_name: str :param filter: The filter to apply on the operation. For example, you can use $filter=provisioningState eq '{state}'. Default value is None. @@ -3934,42 +5249,49 @@ def list_by_resource_group( value is None. :type top: int :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either DeploymentListResult or the result of - cls(response) + :return: An iterator like instance of either DeploymentExtended or the result of cls(response) :rtype: - ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.resource.resources.v2021_01_01.models.DeploymentListResult] - :raises: ~azure.core.exceptions.HttpResponseError + ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.resource.resources.v2021_01_01.models.DeploymentExtended] + :raises ~azure.core.exceptions.HttpResponseError: """ - api_version = kwargs.pop('api_version', "2021-01-01") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-01-01")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[_models.DeploymentListResult] - cls = kwargs.pop('cls', None) # type: ClsType["_models.DeploymentListResult"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) + def prepare_request(next_link=None): if not next_link: - + request = build_deployments_list_by_resource_group_request( resource_group_name=resource_group_name, subscription_id=self._config.subscription_id, - api_version=api_version, filter=filter, top=top, - template_url=self.list_by_resource_group.metadata['url'], + 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.url = self._client.format_url(request.url) # type: ignore else: - - request = build_deployments_list_by_resource_group_request( - resource_group_name=resource_group_name, - subscription_id=self._config.subscription_id, - template_url=next_link, - ) + # make call to next link with the client's api-version + _parsed_next_link = urlparse(next_link) + _next_request_params = case_insensitive_dict(parse_qs(_parsed_next_link.query)) + _next_request_params["api-version"] = self._config.api_version + request = HttpRequest("GET", urljoin(next_link, _parsed_next_link.path), params=_next_request_params) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore request.method = "GET" return request @@ -3983,10 +5305,8 @@ async def extract_data(pipeline_response): async def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) response = pipeline_response.http_response @@ -3996,184 +5316,189 @@ async def get_next(next_link=None): return pipeline_response + return AsyncItemPaged(get_next, extract_data) - return AsyncItemPaged( - get_next, extract_data - ) - list_by_resource_group.metadata = {'url': "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/Microsoft.Resources/deployments/"} # type: ignore + list_by_resource_group.metadata = {"url": "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/Microsoft.Resources/deployments/"} # type: ignore @distributed_trace_async - async def calculate_template_hash( - self, - template: Any, - **kwargs: Any - ) -> "_models.TemplateHashResult": + async def calculate_template_hash(self, template: JSON, **kwargs: Any) -> _models.TemplateHashResult: """Calculate the hash of the given template. - :param template: The template provided to calculate hash. - :type template: any + :param template: The template provided to calculate hash. Required. + :type template: JSON :keyword callable cls: A custom type or function that will be passed the direct response - :return: TemplateHashResult, or the result of cls(response) + :return: TemplateHashResult or the result of cls(response) :rtype: ~azure.mgmt.resource.resources.v2021_01_01.models.TemplateHashResult - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.TemplateHashResult"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) - api_version = kwargs.pop('api_version', "2021-01-01") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - _json = self._serialize.body(template, 'object') + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-01-01")) # type: str + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", "application/json")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[_models.TemplateHashResult] + + _json = self._serialize.body(template, "object") request = build_deployments_calculate_template_hash_request( api_version=api_version, content_type=content_type, json=_json, - template_url=self.calculate_template_hash.metadata['url'], + template_url=self.calculate_template_hash.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) - deserialized = self._deserialize('TemplateHashResult', pipeline_response) + deserialized = self._deserialize("TemplateHashResult", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - calculate_template_hash.metadata = {'url': "/providers/Microsoft.Resources/calculateTemplateHash"} # type: ignore + calculate_template_hash.metadata = {"url": "/providers/Microsoft.Resources/calculateTemplateHash"} # type: ignore -class ProvidersOperations: - """ProvidersOperations async operations. - You should not instantiate this class directly. Instead, you should create a Client instance that - instantiates it for you and attaches it as an attribute. +class ProvidersOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. - :ivar models: Alias to model classes used in this operation group. - :type models: ~azure.mgmt.resource.resources.v2021_01_01.models - :param client: Client for service requests. - :param config: Configuration of service client. - :param serializer: An object model serializer. - :param deserializer: An object model deserializer. + Instead, you should access the following operations through + :class:`~azure.mgmt.resource.resources.v2021_01_01.aio.ResourceManagementClient`'s + :attr:`providers` attribute. """ models = _models - def __init__(self, client, config, serializer, deserializer) -> None: - self._client = client - self._serialize = serializer - self._deserialize = deserializer - self._config = config + def __init__(self, *args, **kwargs) -> None: + input_args = list(args) + self._client = input_args.pop(0) if input_args else kwargs.pop("client") + self._config = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") @distributed_trace_async - async def unregister( - self, - resource_provider_namespace: str, - **kwargs: Any - ) -> "_models.Provider": + async def unregister(self, resource_provider_namespace: str, **kwargs: Any) -> _models.Provider: """Unregisters a subscription from a resource provider. :param resource_provider_namespace: The namespace of the resource provider to unregister. + Required. :type resource_provider_namespace: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: Provider, or the result of cls(response) + :return: Provider or the result of cls(response) :rtype: ~azure.mgmt.resource.resources.v2021_01_01.models.Provider - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.Provider"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) - api_version = kwargs.pop('api_version', "2021-01-01") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-01-01")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[_models.Provider] - request = build_providers_unregister_request( resource_provider_namespace=resource_provider_namespace, subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.unregister.metadata['url'], + template_url=self.unregister.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) - deserialized = self._deserialize('Provider', pipeline_response) + deserialized = self._deserialize("Provider", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - unregister.metadata = {'url': "/subscriptions/{subscriptionId}/providers/{resourceProviderNamespace}/unregister"} # type: ignore - + unregister.metadata = {"url": "/subscriptions/{subscriptionId}/providers/{resourceProviderNamespace}/unregister"} # type: ignore @distributed_trace_async async def register_at_management_group_scope( # pylint: disable=inconsistent-return-statements - self, - resource_provider_namespace: str, - group_id: str, - **kwargs: Any + self, resource_provider_namespace: str, group_id: str, **kwargs: Any ) -> None: """Registers a management group with a resource provider. :param resource_provider_namespace: The namespace of the resource provider to register. + Required. :type resource_provider_namespace: str - :param group_id: The management group ID. + :param group_id: The management group ID. Required. :type group_id: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: None, or the result of cls(response) + :return: None or the result of cls(response) :rtype: None - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType[None] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + 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', "2021-01-01") # type: str + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-01-01")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[None] - request = build_providers_register_at_management_group_scope_request( resource_provider_namespace=resource_provider_namespace, group_id=group_id, api_version=api_version, - template_url=self.register_at_management_group_scope.metadata['url'], + template_url=self.register_at_management_group_scope.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200]: @@ -4183,70 +5508,68 @@ async def register_at_management_group_scope( # pylint: disable=inconsistent-re if cls: return cls(pipeline_response, None, {}) - register_at_management_group_scope.metadata = {'url': "/providers/Microsoft.Management/managementGroups/{groupId}/providers/{resourceProviderNamespace}/register"} # type: ignore - + register_at_management_group_scope.metadata = {"url": "/providers/Microsoft.Management/managementGroups/{groupId}/providers/{resourceProviderNamespace}/register"} # type: ignore @distributed_trace_async - async def register( - self, - resource_provider_namespace: str, - **kwargs: Any - ) -> "_models.Provider": + async def register(self, resource_provider_namespace: str, **kwargs: Any) -> _models.Provider: """Registers a subscription with a resource provider. :param resource_provider_namespace: The namespace of the resource provider to register. + Required. :type resource_provider_namespace: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: Provider, or the result of cls(response) + :return: Provider or the result of cls(response) :rtype: ~azure.mgmt.resource.resources.v2021_01_01.models.Provider - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.Provider"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + 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', "2021-01-01") # type: str + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-01-01")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[_models.Provider] - request = build_providers_register_request( resource_provider_namespace=resource_provider_namespace, subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.register.metadata['url'], + template_url=self.register.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) - deserialized = self._deserialize('Provider', pipeline_response) + deserialized = self._deserialize("Provider", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - register.metadata = {'url': "/subscriptions/{subscriptionId}/providers/{resourceProviderNamespace}/register"} # type: ignore - + register.metadata = {"url": "/subscriptions/{subscriptionId}/providers/{resourceProviderNamespace}/register"} # type: ignore @distributed_trace def list( - self, - top: Optional[int] = None, - expand: Optional[str] = None, - **kwargs: Any - ) -> AsyncIterable["_models.ProviderListResult"]: + self, top: Optional[int] = None, expand: Optional[str] = None, **kwargs: Any + ) -> AsyncIterable["_models.Provider"]: """Gets all resource providers for a subscription. :param top: The number of results to return. If null is passed returns all deployments. Default @@ -4257,39 +5580,48 @@ def list( response, use $expand=resourceTypes/aliases. Default value is None. :type expand: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either ProviderListResult or the result of cls(response) + :return: An iterator like instance of either Provider or the result of cls(response) :rtype: - ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.resource.resources.v2021_01_01.models.ProviderListResult] - :raises: ~azure.core.exceptions.HttpResponseError + ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.resource.resources.v2021_01_01.models.Provider] + :raises ~azure.core.exceptions.HttpResponseError: """ - api_version = kwargs.pop('api_version', "2021-01-01") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-01-01")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[_models.ProviderListResult] - cls = kwargs.pop('cls', None) # type: ClsType["_models.ProviderListResult"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) + def prepare_request(next_link=None): if not next_link: - + request = build_providers_list_request( subscription_id=self._config.subscription_id, - api_version=api_version, top=top, expand=expand, - template_url=self.list.metadata['url'], + 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.url = self._client.format_url(request.url) # type: ignore else: - - request = build_providers_list_request( - subscription_id=self._config.subscription_id, - template_url=next_link, - ) + # make call to next link with the client's api-version + _parsed_next_link = urlparse(next_link) + _next_request_params = case_insensitive_dict(parse_qs(_parsed_next_link.query)) + _next_request_params["api-version"] = self._config.api_version + request = HttpRequest("GET", urljoin(next_link, _parsed_next_link.path), params=_next_request_params) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore request.method = "GET" return request @@ -4303,10 +5635,8 @@ async def extract_data(pipeline_response): async def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) response = pipeline_response.http_response @@ -4316,19 +5646,14 @@ async def get_next(next_link=None): return pipeline_response + return AsyncItemPaged(get_next, extract_data) - return AsyncItemPaged( - get_next, extract_data - ) - list.metadata = {'url': "/subscriptions/{subscriptionId}/providers"} # type: ignore + list.metadata = {"url": "/subscriptions/{subscriptionId}/providers"} # type: ignore @distributed_trace def list_at_tenant_scope( - self, - top: Optional[int] = None, - expand: Optional[str] = None, - **kwargs: Any - ) -> AsyncIterable["_models.ProviderListResult"]: + self, top: Optional[int] = None, expand: Optional[str] = None, **kwargs: Any + ) -> AsyncIterable["_models.Provider"]: """Gets all resource providers for the tenant. :param top: The number of results to return. If null is passed returns all providers. Default @@ -4339,37 +5664,47 @@ def list_at_tenant_scope( response, use $expand=resourceTypes/aliases. Default value is None. :type expand: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either ProviderListResult or the result of cls(response) + :return: An iterator like instance of either Provider or the result of cls(response) :rtype: - ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.resource.resources.v2021_01_01.models.ProviderListResult] - :raises: ~azure.core.exceptions.HttpResponseError + ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.resource.resources.v2021_01_01.models.Provider] + :raises ~azure.core.exceptions.HttpResponseError: """ - api_version = kwargs.pop('api_version', "2021-01-01") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-01-01")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[_models.ProviderListResult] - cls = kwargs.pop('cls', None) # type: ClsType["_models.ProviderListResult"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) + def prepare_request(next_link=None): if not next_link: - + request = build_providers_list_at_tenant_scope_request( - api_version=api_version, top=top, expand=expand, - template_url=self.list_at_tenant_scope.metadata['url'], + api_version=api_version, + template_url=self.list_at_tenant_scope.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore else: - - request = build_providers_list_at_tenant_scope_request( - template_url=next_link, - ) + # make call to next link with the client's api-version + _parsed_next_link = urlparse(next_link) + _next_request_params = case_insensitive_dict(parse_qs(_parsed_next_link.query)) + _next_request_params["api-version"] = self._config.api_version + request = HttpRequest("GET", urljoin(next_link, _parsed_next_link.path), params=_next_request_params) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore request.method = "GET" return request @@ -4383,10 +5718,8 @@ async def extract_data(pipeline_response): async def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) response = pipeline_response.http_response @@ -4396,229 +5729,231 @@ async def get_next(next_link=None): return pipeline_response + return AsyncItemPaged(get_next, extract_data) - return AsyncItemPaged( - get_next, extract_data - ) - list_at_tenant_scope.metadata = {'url': "/providers"} # type: ignore + list_at_tenant_scope.metadata = {"url": "/providers"} # type: ignore @distributed_trace_async async def get( - self, - resource_provider_namespace: str, - expand: Optional[str] = None, - **kwargs: Any - ) -> "_models.Provider": + self, resource_provider_namespace: str, expand: Optional[str] = None, **kwargs: Any + ) -> _models.Provider: """Gets the specified resource provider. - :param resource_provider_namespace: The namespace of the resource provider. + :param resource_provider_namespace: The namespace of the resource provider. Required. :type resource_provider_namespace: str :param expand: The $expand query parameter. For example, to include property aliases in response, use $expand=resourceTypes/aliases. Default value is None. :type expand: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: Provider, or the result of cls(response) + :return: Provider or the result of cls(response) :rtype: ~azure.mgmt.resource.resources.v2021_01_01.models.Provider - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.Provider"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + 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', "2021-01-01") # type: str + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-01-01")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[_models.Provider] - request = build_providers_get_request( resource_provider_namespace=resource_provider_namespace, subscription_id=self._config.subscription_id, - api_version=api_version, expand=expand, - template_url=self.get.metadata['url'], + api_version=api_version, + template_url=self.get.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) - deserialized = self._deserialize('Provider', pipeline_response) + deserialized = self._deserialize("Provider", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - get.metadata = {'url': "/subscriptions/{subscriptionId}/providers/{resourceProviderNamespace}"} # type: ignore - + get.metadata = {"url": "/subscriptions/{subscriptionId}/providers/{resourceProviderNamespace}"} # type: ignore @distributed_trace_async async def get_at_tenant_scope( - self, - resource_provider_namespace: str, - expand: Optional[str] = None, - **kwargs: Any - ) -> "_models.Provider": + self, resource_provider_namespace: str, expand: Optional[str] = None, **kwargs: Any + ) -> _models.Provider: """Gets the specified resource provider at the tenant level. - :param resource_provider_namespace: The namespace of the resource provider. + :param resource_provider_namespace: The namespace of the resource provider. Required. :type resource_provider_namespace: str :param expand: The $expand query parameter. For example, to include property aliases in response, use $expand=resourceTypes/aliases. Default value is None. :type expand: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: Provider, or the result of cls(response) + :return: Provider or the result of cls(response) :rtype: ~azure.mgmt.resource.resources.v2021_01_01.models.Provider - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.Provider"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) - api_version = kwargs.pop('api_version', "2021-01-01") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-01-01")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[_models.Provider] - request = build_providers_get_at_tenant_scope_request( resource_provider_namespace=resource_provider_namespace, - api_version=api_version, expand=expand, - template_url=self.get_at_tenant_scope.metadata['url'], + api_version=api_version, + template_url=self.get_at_tenant_scope.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) - deserialized = self._deserialize('Provider', pipeline_response) + deserialized = self._deserialize("Provider", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - get_at_tenant_scope.metadata = {'url': "/providers/{resourceProviderNamespace}"} # type: ignore + get_at_tenant_scope.metadata = {"url": "/providers/{resourceProviderNamespace}"} # type: ignore -class ProviderResourceTypesOperations: - """ProviderResourceTypesOperations async operations. - You should not instantiate this class directly. Instead, you should create a Client instance that - instantiates it for you and attaches it as an attribute. +class ProviderResourceTypesOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. - :ivar models: Alias to model classes used in this operation group. - :type models: ~azure.mgmt.resource.resources.v2021_01_01.models - :param client: Client for service requests. - :param config: Configuration of service client. - :param serializer: An object model serializer. - :param deserializer: An object model deserializer. + Instead, you should access the following operations through + :class:`~azure.mgmt.resource.resources.v2021_01_01.aio.ResourceManagementClient`'s + :attr:`provider_resource_types` attribute. """ models = _models - def __init__(self, client, config, serializer, deserializer) -> None: - self._client = client - self._serialize = serializer - self._deserialize = deserializer - self._config = config + def __init__(self, *args, **kwargs) -> None: + input_args = list(args) + self._client = input_args.pop(0) if input_args else kwargs.pop("client") + self._config = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") @distributed_trace_async async def list( - self, - resource_provider_namespace: str, - expand: Optional[str] = None, - **kwargs: Any - ) -> "_models.ProviderResourceTypeListResult": + self, resource_provider_namespace: str, expand: Optional[str] = None, **kwargs: Any + ) -> _models.ProviderResourceTypeListResult: """List the resource types for a specified resource provider. - :param resource_provider_namespace: The namespace of the resource provider. + :param resource_provider_namespace: The namespace of the resource provider. Required. :type resource_provider_namespace: str :param expand: The $expand query parameter. For example, to include property aliases in response, use $expand=resourceTypes/aliases. Default value is None. :type expand: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: ProviderResourceTypeListResult, or the result of cls(response) + :return: ProviderResourceTypeListResult or the result of cls(response) :rtype: ~azure.mgmt.resource.resources.v2021_01_01.models.ProviderResourceTypeListResult - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.ProviderResourceTypeListResult"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + 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', "2021-01-01") # type: str + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-01-01")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[_models.ProviderResourceTypeListResult] - request = build_provider_resource_types_list_request( resource_provider_namespace=resource_provider_namespace, subscription_id=self._config.subscription_id, - api_version=api_version, expand=expand, - template_url=self.list.metadata['url'], + 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.url = self._client.format_url(request.url) # type: ignore - pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) - deserialized = self._deserialize('ProviderResourceTypeListResult', pipeline_response) + deserialized = self._deserialize("ProviderResourceTypeListResult", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - list.metadata = {'url': "/subscriptions/{subscriptionId}/providers/{resourceProviderNamespace}/resourceTypes"} # type: ignore + list.metadata = {"url": "/subscriptions/{subscriptionId}/providers/{resourceProviderNamespace}/resourceTypes"} # type: ignore -class ResourcesOperations: # pylint: disable=too-many-public-methods - """ResourcesOperations async operations. - You should not instantiate this class directly. Instead, you should create a Client instance that - instantiates it for you and attaches it as an attribute. +class ResourcesOperations: # pylint: disable=too-many-public-methods + """ + .. warning:: + **DO NOT** instantiate this class directly. - :ivar models: Alias to model classes used in this operation group. - :type models: ~azure.mgmt.resource.resources.v2021_01_01.models - :param client: Client for service requests. - :param config: Configuration of service client. - :param serializer: An object model serializer. - :param deserializer: An object model deserializer. + Instead, you should access the following operations through + :class:`~azure.mgmt.resource.resources.v2021_01_01.aio.ResourceManagementClient`'s + :attr:`resources` attribute. """ models = _models - def __init__(self, client, config, serializer, deserializer) -> None: - self._client = client - self._serialize = serializer - self._deserialize = deserializer - self._config = config + def __init__(self, *args, **kwargs) -> None: + input_args = list(args) + self._client = input_args.pop(0) if input_args else kwargs.pop("client") + self._config = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") @distributed_trace def list_by_resource_group( @@ -4628,10 +5963,10 @@ def list_by_resource_group( expand: Optional[str] = None, top: Optional[int] = None, **kwargs: Any - ) -> AsyncIterable["_models.ResourceListResult"]: + ) -> AsyncIterable["_models.GenericResourceExpanded"]: """Get all the resources for a resource group. - :param resource_group_name: The resource group with the resources to get. + :param resource_group_name: The resource group with the resources to get. Required. :type resource_group_name: str :param filter: The filter to apply on the operation.:code:`
`:code:`
`The properties you can use for eq (equals) or ne (not equals) are: location, resourceType, name, resourceGroup, @@ -4657,42 +5992,51 @@ def list_by_resource_group( value is None. :type top: int :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either ResourceListResult or the result of cls(response) + :return: An iterator like instance of either GenericResourceExpanded or the result of + cls(response) :rtype: - ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.resource.resources.v2021_01_01.models.ResourceListResult] - :raises: ~azure.core.exceptions.HttpResponseError + ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.resource.resources.v2021_01_01.models.GenericResourceExpanded] + :raises ~azure.core.exceptions.HttpResponseError: """ - api_version = kwargs.pop('api_version', "2021-01-01") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-01-01")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[_models.ResourceListResult] - cls = kwargs.pop('cls', None) # type: ClsType["_models.ResourceListResult"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) + def prepare_request(next_link=None): if not next_link: - + request = build_resources_list_by_resource_group_request( resource_group_name=resource_group_name, subscription_id=self._config.subscription_id, - api_version=api_version, filter=filter, expand=expand, top=top, - template_url=self.list_by_resource_group.metadata['url'], + 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.url = self._client.format_url(request.url) # type: ignore else: - - request = build_resources_list_by_resource_group_request( - resource_group_name=resource_group_name, - subscription_id=self._config.subscription_id, - template_url=next_link, - ) + # make call to next link with the client's api-version + _parsed_next_link = urlparse(next_link) + _next_request_params = case_insensitive_dict(parse_qs(_parsed_next_link.query)) + _next_request_params["api-version"] = self._config.api_version + request = HttpRequest("GET", urljoin(next_link, _parsed_next_link.path), params=_next_request_params) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore request.method = "GET" return request @@ -4706,10 +6050,8 @@ async def extract_data(pipeline_response): async def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) response = pipeline_response.http_response @@ -4719,45 +6061,54 @@ async def get_next(next_link=None): return pipeline_response + return AsyncItemPaged(get_next, extract_data) - return AsyncItemPaged( - get_next, extract_data - ) - list_by_resource_group.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/resources"} # type: ignore + list_by_resource_group.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/resources"} # type: ignore async def _move_resources_initial( # pylint: disable=inconsistent-return-statements - self, - source_resource_group_name: str, - parameters: "_models.ResourcesMoveInfo", - **kwargs: Any + self, source_resource_group_name: str, parameters: Union[_models.ResourcesMoveInfo, IO], **kwargs: Any ) -> None: - cls = kwargs.pop('cls', None) # type: ClsType[None] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', "2021-01-01") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-01-01")) # type: str + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[None] - _json = self._serialize.body(parameters, 'ResourcesMoveInfo') + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(parameters, (IO, bytes)): + _content = parameters + else: + _json = self._serialize.body(parameters, "ResourcesMoveInfo") - request = build_resources_move_resources_request_initial( + request = build_resources_move_resources_request( source_resource_group_name=source_resource_group_name, subscription_id=self._config.subscription_id, api_version=api_version, content_type=content_type, json=_json, - template_url=self._move_resources_initial.metadata['url'], + content=_content, + template_url=self._move_resources_initial.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [202, 204]: @@ -4767,14 +6118,15 @@ async def _move_resources_initial( # pylint: disable=inconsistent-return-statem if cls: return cls(pipeline_response, None, {}) - _move_resources_initial.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{sourceResourceGroupName}/moveResources"} # type: ignore - + _move_resources_initial.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{sourceResourceGroupName}/moveResources"} # type: ignore - @distributed_trace_async - async def begin_move_resources( # pylint: disable=inconsistent-return-statements + @overload + async def begin_move_resources( self, source_resource_group_name: str, - parameters: "_models.ResourcesMoveInfo", + parameters: _models.ResourcesMoveInfo, + *, + content_type: str = "application/json", **kwargs: Any ) -> AsyncLROPoller[None]: """Moves resources from one resource group to another resource group. @@ -4785,10 +6137,13 @@ async def begin_move_resources( # pylint: disable=inconsistent-return-statement the groups until the move completes. :param source_resource_group_name: The name of the resource group containing the resources to - move. + move. Required. :type source_resource_group_name: str - :param parameters: Parameters for moving resources. + :param parameters: Parameters for moving resources. Required. :type parameters: ~azure.mgmt.resource.resources.v2021_01_01.models.ResourcesMoveInfo + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str :keyword callable cls: A custom type or function that will be passed the direct response :keyword str continuation_token: A continuation token to restart a poller from a saved state. :keyword polling: By default, your polling method will be AsyncARMPolling. Pass in False for @@ -4799,80 +6154,160 @@ async def begin_move_resources( # pylint: disable=inconsistent-return-statement Retry-After header is present. :return: An instance of AsyncLROPoller that returns either None or the result of cls(response) :rtype: ~azure.core.polling.AsyncLROPoller[None] - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - api_version = kwargs.pop('api_version', "2021-01-01") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] - polling = kwargs.pop('polling', True) # type: Union[bool, AsyncPollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType[None] - lro_delay = kwargs.pop( - 'polling_interval', - self._config.polling_interval - ) - cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] - if cont_token is None: - raw_result = await self._move_resources_initial( - source_resource_group_name=source_resource_group_name, - parameters=parameters, - api_version=api_version, - content_type=content_type, - cls=lambda x,y,z: x, - **kwargs - ) - kwargs.pop('error_map', None) - def get_long_running_output(pipeline_response): - if cls: - return cls(pipeline_response, None, {}) + @overload + async def begin_move_resources( + self, source_resource_group_name: str, parameters: IO, *, content_type: str = "application/json", **kwargs: Any + ) -> AsyncLROPoller[None]: + """Moves resources from one resource group to another resource group. + The resources to move must be in the same source resource group. The target resource group may + be in a different subscription. When moving resources, both the source group and the target + group are locked for the duration of the operation. Write and delete operations are blocked on + the groups until the move completes. - if polling is True: polling_method = AsyncARMPolling(lro_delay, **kwargs) - elif polling is False: polling_method = AsyncNoPolling() - else: polling_method = polling + :param source_resource_group_name: The name of the resource group containing the resources to + move. Required. + :type source_resource_group_name: str + :param parameters: Parameters for moving resources. Required. + :type parameters: IO + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be AsyncARMPolling. Pass in False for + this operation to not poll, or pass in your own initialized polling object for a personal + polling strategy. + :paramtype polling: bool or ~azure.core.polling.AsyncPollingMethod + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of AsyncLROPoller that returns either None or the result of cls(response) + :rtype: ~azure.core.polling.AsyncLROPoller[None] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace_async + async def begin_move_resources( + self, source_resource_group_name: str, parameters: Union[_models.ResourcesMoveInfo, IO], **kwargs: Any + ) -> AsyncLROPoller[None]: + """Moves resources from one resource group to another resource group. + + The resources to move must be in the same source resource group. The target resource group may + be in a different subscription. When moving resources, both the source group and the target + group are locked for the duration of the operation. Write and delete operations are blocked on + the groups until the move completes. + + :param source_resource_group_name: The name of the resource group containing the resources to + move. Required. + :type source_resource_group_name: str + :param parameters: Parameters for moving resources. Is either a model type or a IO type. + Required. + :type parameters: ~azure.mgmt.resource.resources.v2021_01_01.models.ResourcesMoveInfo or IO + :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. + Default value is None. + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be AsyncARMPolling. Pass in False for + this operation to not poll, or pass in your own initialized polling object for a personal + polling strategy. + :paramtype polling: bool or ~azure.core.polling.AsyncPollingMethod + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of AsyncLROPoller that returns either None or the result of cls(response) + :rtype: ~azure.core.polling.AsyncLROPoller[None] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _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-01-01")) # type: str + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[None] + polling = kwargs.pop("polling", True) # type: Union[bool, AsyncPollingMethod] + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token = kwargs.pop("continuation_token", None) # type: Optional[str] + if cont_token is None: + raw_result = await self._move_resources_initial( # type: ignore + source_resource_group_name=source_resource_group_name, + parameters=parameters, + api_version=api_version, + content_type=content_type, + cls=lambda x, y, z: x, + headers=_headers, + params=_params, + **kwargs + ) + kwargs.pop("error_map", None) + + def get_long_running_output(pipeline_response): # pylint: disable=inconsistent-return-statements + if cls: + return cls(pipeline_response, None, {}) + + if polling is True: + polling_method = cast(AsyncPollingMethod, AsyncARMPolling(lro_delay, **kwargs)) # type: AsyncPollingMethod + elif polling is False: + polling_method = cast(AsyncPollingMethod, AsyncNoPolling()) + else: + polling_method = polling if cont_token: return AsyncLROPoller.from_continuation_token( polling_method=polling_method, continuation_token=cont_token, client=self._client, - deserialization_callback=get_long_running_output + deserialization_callback=get_long_running_output, ) return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) - begin_move_resources.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{sourceResourceGroupName}/moveResources"} # type: ignore + begin_move_resources.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{sourceResourceGroupName}/moveResources"} # type: ignore async def _validate_move_resources_initial( # pylint: disable=inconsistent-return-statements - self, - source_resource_group_name: str, - parameters: "_models.ResourcesMoveInfo", - **kwargs: Any + self, source_resource_group_name: str, parameters: Union[_models.ResourcesMoveInfo, IO], **kwargs: Any ) -> None: - cls = kwargs.pop('cls', None) # type: ClsType[None] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', "2021-01-01") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-01-01")) # type: str + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[None] - _json = self._serialize.body(parameters, 'ResourcesMoveInfo') + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(parameters, (IO, bytes)): + _content = parameters + else: + _json = self._serialize.body(parameters, "ResourcesMoveInfo") - request = build_resources_validate_move_resources_request_initial( + request = build_resources_validate_move_resources_request( source_resource_group_name=source_resource_group_name, subscription_id=self._config.subscription_id, api_version=api_version, content_type=content_type, json=_json, - template_url=self._validate_move_resources_initial.metadata['url'], + content=_content, + template_url=self._validate_move_resources_initial.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [202, 204]: @@ -4882,14 +6317,15 @@ async def _validate_move_resources_initial( # pylint: disable=inconsistent-retu if cls: return cls(pipeline_response, None, {}) - _validate_move_resources_initial.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{sourceResourceGroupName}/validateMoveResources"} # type: ignore - + _validate_move_resources_initial.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{sourceResourceGroupName}/validateMoveResources"} # type: ignore - @distributed_trace_async - async def begin_validate_move_resources( # pylint: disable=inconsistent-return-statements + @overload + async def begin_validate_move_resources( self, source_resource_group_name: str, - parameters: "_models.ResourcesMoveInfo", + parameters: _models.ResourcesMoveInfo, + *, + content_type: str = "application/json", **kwargs: Any ) -> AsyncLROPoller[None]: """Validates whether resources can be moved from one resource group to another resource group. @@ -4902,10 +6338,13 @@ async def begin_validate_move_resources( # pylint: disable=inconsistent-return- operation. :param source_resource_group_name: The name of the resource group containing the resources to - validate for move. + validate for move. Required. :type source_resource_group_name: str - :param parameters: Parameters for moving resources. + :param parameters: Parameters for moving resources. Required. :type parameters: ~azure.mgmt.resource.resources.v2021_01_01.models.ResourcesMoveInfo + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str :keyword callable cls: A custom type or function that will be passed the direct response :keyword str continuation_token: A continuation token to restart a poller from a saved state. :keyword polling: By default, your polling method will be AsyncARMPolling. Pass in False for @@ -4916,55 +6355,124 @@ async def begin_validate_move_resources( # pylint: disable=inconsistent-return- Retry-After header is present. :return: An instance of AsyncLROPoller that returns either None or the result of cls(response) :rtype: ~azure.core.polling.AsyncLROPoller[None] - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - api_version = kwargs.pop('api_version', "2021-01-01") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] - polling = kwargs.pop('polling', True) # type: Union[bool, AsyncPollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType[None] - lro_delay = kwargs.pop( - 'polling_interval', - self._config.polling_interval - ) - cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] + + @overload + async def begin_validate_move_resources( + self, source_resource_group_name: str, parameters: IO, *, content_type: str = "application/json", **kwargs: Any + ) -> AsyncLROPoller[None]: + """Validates whether resources can be moved from one resource group to another resource group. + + This operation checks whether the specified resources can be moved to the target. The resources + to move must be in the same source resource group. The target resource group may be in a + different subscription. If validation succeeds, it returns HTTP response code 204 (no content). + If validation fails, it returns HTTP response code 409 (Conflict) with an error message. + Retrieve the URL in the Location header value to check the result of the long-running + operation. + + :param source_resource_group_name: The name of the resource group containing the resources to + validate for move. Required. + :type source_resource_group_name: str + :param parameters: Parameters for moving resources. Required. + :type parameters: IO + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be AsyncARMPolling. Pass in False for + this operation to not poll, or pass in your own initialized polling object for a personal + polling strategy. + :paramtype polling: bool or ~azure.core.polling.AsyncPollingMethod + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of AsyncLROPoller that returns either None or the result of cls(response) + :rtype: ~azure.core.polling.AsyncLROPoller[None] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace_async + async def begin_validate_move_resources( + self, source_resource_group_name: str, parameters: Union[_models.ResourcesMoveInfo, IO], **kwargs: Any + ) -> AsyncLROPoller[None]: + """Validates whether resources can be moved from one resource group to another resource group. + + This operation checks whether the specified resources can be moved to the target. The resources + to move must be in the same source resource group. The target resource group may be in a + different subscription. If validation succeeds, it returns HTTP response code 204 (no content). + If validation fails, it returns HTTP response code 409 (Conflict) with an error message. + Retrieve the URL in the Location header value to check the result of the long-running + operation. + + :param source_resource_group_name: The name of the resource group containing the resources to + validate for move. Required. + :type source_resource_group_name: str + :param parameters: Parameters for moving resources. Is either a model type or a IO type. + Required. + :type parameters: ~azure.mgmt.resource.resources.v2021_01_01.models.ResourcesMoveInfo or IO + :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. + Default value is None. + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be AsyncARMPolling. Pass in False for + this operation to not poll, or pass in your own initialized polling object for a personal + polling strategy. + :paramtype polling: bool or ~azure.core.polling.AsyncPollingMethod + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of AsyncLROPoller that returns either None or the result of cls(response) + :rtype: ~azure.core.polling.AsyncLROPoller[None] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _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-01-01")) # type: str + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[None] + polling = kwargs.pop("polling", True) # type: Union[bool, AsyncPollingMethod] + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token = kwargs.pop("continuation_token", None) # type: Optional[str] if cont_token is None: - raw_result = await self._validate_move_resources_initial( + raw_result = await self._validate_move_resources_initial( # type: ignore source_resource_group_name=source_resource_group_name, parameters=parameters, api_version=api_version, content_type=content_type, - cls=lambda x,y,z: x, + cls=lambda x, y, z: x, + headers=_headers, + params=_params, **kwargs ) - kwargs.pop('error_map', None) + kwargs.pop("error_map", None) - def get_long_running_output(pipeline_response): + def get_long_running_output(pipeline_response): # pylint: disable=inconsistent-return-statements if cls: return cls(pipeline_response, None, {}) - - if polling is True: polling_method = AsyncARMPolling(lro_delay, **kwargs) - elif polling is False: polling_method = AsyncNoPolling() - else: polling_method = polling + if polling is True: + polling_method = cast(AsyncPollingMethod, AsyncARMPolling(lro_delay, **kwargs)) # type: AsyncPollingMethod + elif polling is False: + polling_method = cast(AsyncPollingMethod, AsyncNoPolling()) + else: + polling_method = polling if cont_token: return AsyncLROPoller.from_continuation_token( polling_method=polling_method, continuation_token=cont_token, client=self._client, - deserialization_callback=get_long_running_output + deserialization_callback=get_long_running_output, ) return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) - begin_validate_move_resources.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{sourceResourceGroupName}/validateMoveResources"} # type: ignore + begin_validate_move_resources.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{sourceResourceGroupName}/validateMoveResources"} # type: ignore @distributed_trace def list( - self, - filter: Optional[str] = None, - expand: Optional[str] = None, - top: Optional[int] = None, - **kwargs: Any - ) -> AsyncIterable["_models.ResourceListResult"]: + self, filter: Optional[str] = None, expand: Optional[str] = None, top: Optional[int] = None, **kwargs: Any + ) -> AsyncIterable["_models.GenericResourceExpanded"]: """Get all the resources in a subscription. :param filter: The filter to apply on the operation.:code:`
`:code:`
`The properties you @@ -4991,40 +6499,50 @@ def list( value is None. :type top: int :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either ResourceListResult or the result of cls(response) + :return: An iterator like instance of either GenericResourceExpanded or the result of + cls(response) :rtype: - ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.resource.resources.v2021_01_01.models.ResourceListResult] - :raises: ~azure.core.exceptions.HttpResponseError + ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.resource.resources.v2021_01_01.models.GenericResourceExpanded] + :raises ~azure.core.exceptions.HttpResponseError: """ - api_version = kwargs.pop('api_version', "2021-01-01") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-01-01")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[_models.ResourceListResult] - cls = kwargs.pop('cls', None) # type: ClsType["_models.ResourceListResult"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) + def prepare_request(next_link=None): if not next_link: - + request = build_resources_list_request( subscription_id=self._config.subscription_id, - api_version=api_version, filter=filter, expand=expand, top=top, - template_url=self.list.metadata['url'], + 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.url = self._client.format_url(request.url) # type: ignore else: - - request = build_resources_list_request( - subscription_id=self._config.subscription_id, - template_url=next_link, - ) + # make call to next link with the client's api-version + _parsed_next_link = urlparse(next_link) + _next_request_params = case_insensitive_dict(parse_qs(_parsed_next_link.query)) + _next_request_params["api-version"] = self._config.api_version + request = HttpRequest("GET", urljoin(next_link, _parsed_next_link.path), params=_next_request_params) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore request.method = "GET" return request @@ -5038,10 +6556,8 @@ async def extract_data(pipeline_response): async def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) response = pipeline_response.http_response @@ -5051,11 +6567,9 @@ async def get_next(next_link=None): return pipeline_response + return AsyncItemPaged(get_next, extract_data) - return AsyncItemPaged( - get_next, extract_data - ) - list.metadata = {'url': "/subscriptions/{subscriptionId}/resources"} # type: ignore + list.metadata = {"url": "/subscriptions/{subscriptionId}/resources"} # type: ignore @distributed_trace_async async def check_existence( @@ -5071,30 +6585,36 @@ async def check_existence( """Checks whether a resource exists. :param resource_group_name: The name of the resource group containing the resource to check. - The name is case insensitive. + The name is case insensitive. Required. :type resource_group_name: str - :param resource_provider_namespace: The resource provider of the resource to check. + :param resource_provider_namespace: The resource provider of the resource to check. Required. :type resource_provider_namespace: str - :param parent_resource_path: The parent resource identity. + :param parent_resource_path: The parent resource identity. Required. :type parent_resource_path: str - :param resource_type: The resource type. + :param resource_type: The resource type. Required. :type resource_type: str - :param resource_name: The name of the resource to check whether it exists. + :param resource_name: The name of the resource to check whether it exists. Required. :type resource_name: str - :param api_version: The API version to use for the operation. + :param api_version: The API version to use for the operation. Required. :type api_version: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: bool, or the result of cls(response) + :return: bool or the result of cls(response) :rtype: bool - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType[None] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = kwargs.pop("params", {}) or {} + + cls = kwargs.pop("cls", None) # type: ClsType[None] - request = build_resources_check_existence_request( resource_group_name=resource_group_name, resource_provider_namespace=resource_provider_namespace, @@ -5103,16 +6623,17 @@ async def check_existence( resource_name=resource_name, subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.check_existence.metadata['url'], + template_url=self.check_existence.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [204, 404]: @@ -5123,8 +6644,7 @@ async def check_existence( return cls(pipeline_response, None, {}) return 200 <= response.status_code <= 299 - check_existence.metadata = {'url': "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{parentResourcePath}/{resourceType}/{resourceName}"} # type: ignore - + check_existence.metadata = {"url": "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{parentResourcePath}/{resourceType}/{resourceName}"} # type: ignore async def _delete_initial( # pylint: disable=inconsistent-return-statements self, @@ -5136,14 +6656,20 @@ async def _delete_initial( # pylint: disable=inconsistent-return-statements api_version: str, **kwargs: Any ) -> None: - cls = kwargs.pop('cls', None) # type: ClsType[None] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) - - request = build_resources_delete_request_initial( + _headers = kwargs.pop("headers", {}) or {} + _params = kwargs.pop("params", {}) or {} + + cls = kwargs.pop("cls", None) # type: ClsType[None] + + request = build_resources_delete_request( resource_group_name=resource_group_name, resource_provider_namespace=resource_provider_namespace, parent_resource_path=parent_resource_path, @@ -5151,16 +6677,17 @@ async def _delete_initial( # pylint: disable=inconsistent-return-statements resource_name=resource_name, subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self._delete_initial.metadata['url'], + template_url=self._delete_initial.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200, 202, 204]: @@ -5170,11 +6697,10 @@ 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/{resourceProviderNamespace}/{parentResourcePath}/{resourceType}/{resourceName}"} # type: ignore - + _delete_initial.metadata = {"url": "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{parentResourcePath}/{resourceType}/{resourceName}"} # type: ignore @distributed_trace_async - async def begin_delete( # pylint: disable=inconsistent-return-statements + async def begin_delete( self, resource_group_name: str, resource_provider_namespace: str, @@ -5187,17 +6713,17 @@ async def begin_delete( # pylint: disable=inconsistent-return-statements """Deletes a resource. :param resource_group_name: The name of the resource group that contains the resource to - delete. The name is case insensitive. + delete. The name is case insensitive. Required. :type resource_group_name: str - :param resource_provider_namespace: The namespace of the resource provider. + :param resource_provider_namespace: The namespace of the resource provider. Required. :type resource_provider_namespace: str - :param parent_resource_path: The parent resource identity. + :param parent_resource_path: The parent resource identity. Required. :type parent_resource_path: str - :param resource_type: The resource type. + :param resource_type: The resource type. Required. :type resource_type: str - :param resource_name: The name of the resource to delete. + :param resource_name: The name of the resource to delete. Required. :type resource_name: str - :param api_version: The API version to use for the operation. + :param api_version: The API version to use for the operation. Required. :type api_version: str :keyword callable cls: A custom type or function that will be passed the direct response :keyword str continuation_token: A continuation token to restart a poller from a saved state. @@ -5209,46 +6735,50 @@ async def begin_delete( # pylint: disable=inconsistent-return-statements Retry-After header is present. :return: An instance of AsyncLROPoller that returns either None or the result of cls(response) :rtype: ~azure.core.polling.AsyncLROPoller[None] - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - polling = kwargs.pop('polling', True) # type: Union[bool, AsyncPollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType[None] - lro_delay = kwargs.pop( - 'polling_interval', - self._config.polling_interval - ) - cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] + _headers = kwargs.pop("headers", {}) or {} + _params = kwargs.pop("params", {}) or {} + + cls = kwargs.pop("cls", None) # type: ClsType[None] + polling = kwargs.pop("polling", True) # type: Union[bool, AsyncPollingMethod] + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token = kwargs.pop("continuation_token", None) # type: Optional[str] if cont_token is None: - raw_result = await self._delete_initial( + raw_result = await self._delete_initial( # type: ignore resource_group_name=resource_group_name, resource_provider_namespace=resource_provider_namespace, parent_resource_path=parent_resource_path, resource_type=resource_type, resource_name=resource_name, api_version=api_version, - cls=lambda x,y,z: x, + cls=lambda x, y, z: x, + headers=_headers, + params=_params, **kwargs ) - kwargs.pop('error_map', None) + kwargs.pop("error_map", None) - def get_long_running_output(pipeline_response): + def get_long_running_output(pipeline_response): # pylint: disable=inconsistent-return-statements if cls: return cls(pipeline_response, None, {}) - - if polling is True: polling_method = AsyncARMPolling(lro_delay, **kwargs) - elif polling is False: polling_method = AsyncNoPolling() - else: polling_method = polling + if polling is True: + polling_method = cast(AsyncPollingMethod, AsyncARMPolling(lro_delay, **kwargs)) # type: AsyncPollingMethod + elif polling is False: + polling_method = cast(AsyncPollingMethod, AsyncNoPolling()) + else: + polling_method = polling if cont_token: return AsyncLROPoller.from_continuation_token( polling_method=polling_method, continuation_token=cont_token, client=self._client, - deserialization_callback=get_long_running_output + deserialization_callback=get_long_running_output, ) return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) - begin_delete.metadata = {'url': "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{parentResourcePath}/{resourceType}/{resourceName}"} # type: ignore + begin_delete.metadata = {"url": "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{parentResourcePath}/{resourceType}/{resourceName}"} # type: ignore async def _create_or_update_initial( self, @@ -5258,39 +6788,53 @@ async def _create_or_update_initial( resource_type: str, resource_name: str, api_version: str, - parameters: "_models.GenericResource", + parameters: Union[_models.GenericResource, IO], **kwargs: Any - ) -> Optional["_models.GenericResource"]: - cls = kwargs.pop('cls', None) # type: ClsType[Optional["_models.GenericResource"]] + ) -> Optional[_models.GenericResource]: error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = kwargs.pop("params", {}) or {} - _json = self._serialize.body(parameters, 'GenericResource') + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[Optional[_models.GenericResource]] - request = build_resources_create_or_update_request_initial( + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(parameters, (IO, bytes)): + _content = parameters + else: + _json = self._serialize.body(parameters, "GenericResource") + + request = build_resources_create_or_update_request( resource_group_name=resource_group_name, resource_provider_namespace=resource_provider_namespace, parent_resource_path=parent_resource_path, resource_type=resource_type, resource_name=resource_name, subscription_id=self._config.subscription_id, - content_type=content_type, api_version=api_version, + content_type=content_type, json=_json, - template_url=self._create_or_update_initial.metadata['url'], + content=_content, + template_url=self._create_or_update_initial.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200, 201, 202]: @@ -5299,18 +6843,115 @@ async def _create_or_update_initial( deserialized = None if response.status_code == 200: - deserialized = self._deserialize('GenericResource', pipeline_response) + deserialized = self._deserialize("GenericResource", pipeline_response) if response.status_code == 201: - deserialized = self._deserialize('GenericResource', pipeline_response) + deserialized = self._deserialize("GenericResource", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - _create_or_update_initial.metadata = {'url': "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{parentResourcePath}/{resourceType}/{resourceName}"} # type: ignore + _create_or_update_initial.metadata = {"url": "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{parentResourcePath}/{resourceType}/{resourceName}"} # type: ignore + + @overload + async def begin_create_or_update( + self, + resource_group_name: str, + resource_provider_namespace: str, + parent_resource_path: str, + resource_type: str, + resource_name: str, + api_version: str, + parameters: _models.GenericResource, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> AsyncLROPoller[_models.GenericResource]: + """Creates a resource. + + :param resource_group_name: The name of the resource group for the resource. The name is case + insensitive. Required. + :type resource_group_name: str + :param resource_provider_namespace: The namespace of the resource provider. Required. + :type resource_provider_namespace: str + :param parent_resource_path: The parent resource identity. Required. + :type parent_resource_path: str + :param resource_type: The resource type of the resource to create. Required. + :type resource_type: str + :param resource_name: The name of the resource to create. Required. + :type resource_name: str + :param api_version: The API version to use for the operation. Required. + :type api_version: str + :param parameters: Parameters for creating or updating the resource. Required. + :type parameters: ~azure.mgmt.resource.resources.v2021_01_01.models.GenericResource + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be AsyncARMPolling. Pass in False for + this operation to not poll, or pass in your own initialized polling object for a personal + polling strategy. + :paramtype polling: bool or ~azure.core.polling.AsyncPollingMethod + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of AsyncLROPoller that returns either GenericResource or the result of + cls(response) + :rtype: + ~azure.core.polling.AsyncLROPoller[~azure.mgmt.resource.resources.v2021_01_01.models.GenericResource] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + async def begin_create_or_update( + self, + resource_group_name: str, + resource_provider_namespace: str, + parent_resource_path: str, + resource_type: str, + resource_name: str, + api_version: str, + parameters: IO, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> AsyncLROPoller[_models.GenericResource]: + """Creates a resource. + :param resource_group_name: The name of the resource group for the resource. The name is case + insensitive. Required. + :type resource_group_name: str + :param resource_provider_namespace: The namespace of the resource provider. Required. + :type resource_provider_namespace: str + :param parent_resource_path: The parent resource identity. Required. + :type parent_resource_path: str + :param resource_type: The resource type of the resource to create. Required. + :type resource_type: str + :param resource_name: The name of the resource to create. Required. + :type resource_name: str + :param api_version: The API version to use for the operation. Required. + :type api_version: str + :param parameters: Parameters for creating or updating the resource. Required. + :type parameters: IO + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be AsyncARMPolling. Pass in False for + this operation to not poll, or pass in your own initialized polling object for a personal + polling strategy. + :paramtype polling: bool or ~azure.core.polling.AsyncPollingMethod + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of AsyncLROPoller that returns either GenericResource or the result of + cls(response) + :rtype: + ~azure.core.polling.AsyncLROPoller[~azure.mgmt.resource.resources.v2021_01_01.models.GenericResource] + :raises ~azure.core.exceptions.HttpResponseError: + """ @distributed_trace_async async def begin_create_or_update( @@ -5321,26 +6962,30 @@ async def begin_create_or_update( resource_type: str, resource_name: str, api_version: str, - parameters: "_models.GenericResource", + parameters: Union[_models.GenericResource, IO], **kwargs: Any - ) -> AsyncLROPoller["_models.GenericResource"]: + ) -> AsyncLROPoller[_models.GenericResource]: """Creates a resource. :param resource_group_name: The name of the resource group for the resource. The name is case - insensitive. + insensitive. Required. :type resource_group_name: str - :param resource_provider_namespace: The namespace of the resource provider. + :param resource_provider_namespace: The namespace of the resource provider. Required. :type resource_provider_namespace: str - :param parent_resource_path: The parent resource identity. + :param parent_resource_path: The parent resource identity. Required. :type parent_resource_path: str - :param resource_type: The resource type of the resource to create. + :param resource_type: The resource type of the resource to create. Required. :type resource_type: str - :param resource_name: The name of the resource to create. + :param resource_name: The name of the resource to create. Required. :type resource_name: str - :param api_version: The API version to use for the operation. + :param api_version: The API version to use for the operation. Required. :type api_version: str - :param parameters: Parameters for creating or updating the resource. - :type parameters: ~azure.mgmt.resource.resources.v2021_01_01.models.GenericResource + :param parameters: Parameters for creating or updating the resource. Is either a model type or + a IO type. Required. + :type parameters: ~azure.mgmt.resource.resources.v2021_01_01.models.GenericResource or IO + :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. + Default value is None. + :paramtype content_type: str :keyword callable cls: A custom type or function that will be passed the direct response :keyword str continuation_token: A continuation token to restart a poller from a saved state. :keyword polling: By default, your polling method will be AsyncARMPolling. Pass in False for @@ -5353,18 +6998,18 @@ async def begin_create_or_update( cls(response) :rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.resource.resources.v2021_01_01.models.GenericResource] - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] - polling = kwargs.pop('polling', True) # type: Union[bool, AsyncPollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType["_models.GenericResource"] - lro_delay = kwargs.pop( - 'polling_interval', - self._config.polling_interval - ) - cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = kwargs.pop("params", {}) or {} + + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.GenericResource] + polling = kwargs.pop("polling", True) # type: Union[bool, AsyncPollingMethod] + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token = kwargs.pop("continuation_token", None) # type: Optional[str] if cont_token is None: - raw_result = await self._create_or_update_initial( + raw_result = await self._create_or_update_initial( # type: ignore resource_group_name=resource_group_name, resource_provider_namespace=resource_provider_namespace, parent_resource_path=parent_resource_path, @@ -5373,32 +7018,35 @@ async def begin_create_or_update( api_version=api_version, parameters=parameters, content_type=content_type, - cls=lambda x,y,z: x, + cls=lambda x, y, z: x, + headers=_headers, + params=_params, **kwargs ) - kwargs.pop('error_map', None) + kwargs.pop("error_map", None) def get_long_running_output(pipeline_response): - response = pipeline_response.http_response - deserialized = self._deserialize('GenericResource', pipeline_response) + deserialized = self._deserialize("GenericResource", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - - if polling is True: polling_method = AsyncARMPolling(lro_delay, **kwargs) - elif polling is False: polling_method = AsyncNoPolling() - else: polling_method = polling + if polling is True: + polling_method = cast(AsyncPollingMethod, AsyncARMPolling(lro_delay, **kwargs)) # type: AsyncPollingMethod + elif polling is False: + polling_method = cast(AsyncPollingMethod, AsyncNoPolling()) + else: + polling_method = polling if cont_token: return AsyncLROPoller.from_continuation_token( polling_method=polling_method, continuation_token=cont_token, client=self._client, - deserialization_callback=get_long_running_output + deserialization_callback=get_long_running_output, ) return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) - begin_create_or_update.metadata = {'url': "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{parentResourcePath}/{resourceType}/{resourceName}"} # type: ignore + begin_create_or_update.metadata = {"url": "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{parentResourcePath}/{resourceType}/{resourceName}"} # type: ignore async def _update_initial( self, @@ -5408,39 +7056,53 @@ async def _update_initial( resource_type: str, resource_name: str, api_version: str, - parameters: "_models.GenericResource", + parameters: Union[_models.GenericResource, IO], **kwargs: Any - ) -> Optional["_models.GenericResource"]: - cls = kwargs.pop('cls', None) # type: ClsType[Optional["_models.GenericResource"]] + ) -> Optional[_models.GenericResource]: error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = kwargs.pop("params", {}) or {} - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[Optional[_models.GenericResource]] - _json = self._serialize.body(parameters, 'GenericResource') + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(parameters, (IO, bytes)): + _content = parameters + else: + _json = self._serialize.body(parameters, "GenericResource") - request = build_resources_update_request_initial( + request = build_resources_update_request( resource_group_name=resource_group_name, resource_provider_namespace=resource_provider_namespace, parent_resource_path=parent_resource_path, resource_type=resource_type, resource_name=resource_name, subscription_id=self._config.subscription_id, - content_type=content_type, api_version=api_version, + content_type=content_type, json=_json, - template_url=self._update_initial.metadata['url'], + content=_content, + template_url=self._update_initial.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200, 202]: @@ -5449,17 +7111,16 @@ async def _update_initial( deserialized = None if response.status_code == 200: - deserialized = self._deserialize('GenericResource', pipeline_response) + deserialized = self._deserialize("GenericResource", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - _update_initial.metadata = {'url': "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{parentResourcePath}/{resourceType}/{resourceName}"} # type: ignore - + _update_initial.metadata = {"url": "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{parentResourcePath}/{resourceType}/{resourceName}"} # type: ignore - @distributed_trace_async + @overload async def begin_update( self, resource_group_name: str, @@ -5468,26 +7129,31 @@ async def begin_update( resource_type: str, resource_name: str, api_version: str, - parameters: "_models.GenericResource", + parameters: _models.GenericResource, + *, + content_type: str = "application/json", **kwargs: Any - ) -> AsyncLROPoller["_models.GenericResource"]: + ) -> AsyncLROPoller[_models.GenericResource]: """Updates a resource. :param resource_group_name: The name of the resource group for the resource. The name is case - insensitive. + insensitive. Required. :type resource_group_name: str - :param resource_provider_namespace: The namespace of the resource provider. + :param resource_provider_namespace: The namespace of the resource provider. Required. :type resource_provider_namespace: str - :param parent_resource_path: The parent resource identity. + :param parent_resource_path: The parent resource identity. Required. :type parent_resource_path: str - :param resource_type: The resource type of the resource to update. + :param resource_type: The resource type of the resource to update. Required. :type resource_type: str - :param resource_name: The name of the resource to update. + :param resource_name: The name of the resource to update. Required. :type resource_name: str - :param api_version: The API version to use for the operation. + :param api_version: The API version to use for the operation. Required. :type api_version: str - :param parameters: Parameters for updating the resource. + :param parameters: Parameters for updating the resource. Required. :type parameters: ~azure.mgmt.resource.resources.v2021_01_01.models.GenericResource + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str :keyword callable cls: A custom type or function that will be passed the direct response :keyword str continuation_token: A continuation token to restart a poller from a saved state. :keyword polling: By default, your polling method will be AsyncARMPolling. Pass in False for @@ -5500,55 +7166,11 @@ async def begin_update( cls(response) :rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.resource.resources.v2021_01_01.models.GenericResource] - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] - polling = kwargs.pop('polling', True) # type: Union[bool, AsyncPollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType["_models.GenericResource"] - lro_delay = kwargs.pop( - 'polling_interval', - self._config.polling_interval - ) - cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] - if cont_token is None: - raw_result = await self._update_initial( - resource_group_name=resource_group_name, - resource_provider_namespace=resource_provider_namespace, - parent_resource_path=parent_resource_path, - resource_type=resource_type, - resource_name=resource_name, - api_version=api_version, - parameters=parameters, - content_type=content_type, - cls=lambda x,y,z: x, - **kwargs - ) - kwargs.pop('error_map', None) - - def get_long_running_output(pipeline_response): - response = pipeline_response.http_response - deserialized = self._deserialize('GenericResource', pipeline_response) - if cls: - return cls(pipeline_response, deserialized, {}) - return deserialized - - - if polling is True: polling_method = AsyncARMPolling(lro_delay, **kwargs) - elif polling is False: polling_method = AsyncNoPolling() - else: polling_method = polling - if cont_token: - return AsyncLROPoller.from_continuation_token( - polling_method=polling_method, - continuation_token=cont_token, - client=self._client, - deserialization_callback=get_long_running_output - ) - return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) - begin_update.metadata = {'url': "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{parentResourcePath}/{resourceType}/{resourceName}"} # type: ignore - - @distributed_trace_async - async def get( + @overload + async def begin_update( self, resource_group_name: str, resource_provider_namespace: str, @@ -5556,36 +7178,186 @@ async def get( resource_type: str, resource_name: str, api_version: str, + parameters: IO, + *, + content_type: str = "application/json", **kwargs: Any - ) -> "_models.GenericResource": - """Gets a resource. + ) -> AsyncLROPoller[_models.GenericResource]: + """Updates a resource. - :param resource_group_name: The name of the resource group containing the resource to get. The - name is case insensitive. + :param resource_group_name: The name of the resource group for the resource. The name is case + insensitive. Required. :type resource_group_name: str - :param resource_provider_namespace: The namespace of the resource provider. + :param resource_provider_namespace: The namespace of the resource provider. Required. :type resource_provider_namespace: str - :param parent_resource_path: The parent resource identity. + :param parent_resource_path: The parent resource identity. Required. :type parent_resource_path: str - :param resource_type: The resource type of the resource. + :param resource_type: The resource type of the resource to update. Required. :type resource_type: str - :param resource_name: The name of the resource to get. + :param resource_name: The name of the resource to update. Required. :type resource_name: str - :param api_version: The API version to use for the operation. + :param api_version: The API version to use for the operation. Required. :type api_version: str + :param parameters: Parameters for updating the resource. Required. + :type parameters: IO + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: GenericResource, or the result of cls(response) - :rtype: ~azure.mgmt.resource.resources.v2021_01_01.models.GenericResource - :raises: ~azure.core.exceptions.HttpResponseError - """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.GenericResource"] - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {})) - - - request = build_resources_get_request( + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be AsyncARMPolling. Pass in False for + this operation to not poll, or pass in your own initialized polling object for a personal + polling strategy. + :paramtype polling: bool or ~azure.core.polling.AsyncPollingMethod + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of AsyncLROPoller that returns either GenericResource or the result of + cls(response) + :rtype: + ~azure.core.polling.AsyncLROPoller[~azure.mgmt.resource.resources.v2021_01_01.models.GenericResource] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace_async + async def begin_update( + self, + resource_group_name: str, + resource_provider_namespace: str, + parent_resource_path: str, + resource_type: str, + resource_name: str, + api_version: str, + parameters: Union[_models.GenericResource, IO], + **kwargs: Any + ) -> AsyncLROPoller[_models.GenericResource]: + """Updates a resource. + + :param resource_group_name: The name of the resource group for the resource. The name is case + insensitive. Required. + :type resource_group_name: str + :param resource_provider_namespace: The namespace of the resource provider. Required. + :type resource_provider_namespace: str + :param parent_resource_path: The parent resource identity. Required. + :type parent_resource_path: str + :param resource_type: The resource type of the resource to update. Required. + :type resource_type: str + :param resource_name: The name of the resource to update. Required. + :type resource_name: str + :param api_version: The API version to use for the operation. Required. + :type api_version: str + :param parameters: Parameters for updating the resource. Is either a model type or a IO type. + Required. + :type parameters: ~azure.mgmt.resource.resources.v2021_01_01.models.GenericResource or IO + :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. + Default value is None. + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be AsyncARMPolling. Pass in False for + this operation to not poll, or pass in your own initialized polling object for a personal + polling strategy. + :paramtype polling: bool or ~azure.core.polling.AsyncPollingMethod + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of AsyncLROPoller that returns either GenericResource or the result of + cls(response) + :rtype: + ~azure.core.polling.AsyncLROPoller[~azure.mgmt.resource.resources.v2021_01_01.models.GenericResource] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = kwargs.pop("params", {}) or {} + + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.GenericResource] + polling = kwargs.pop("polling", True) # type: Union[bool, AsyncPollingMethod] + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token = kwargs.pop("continuation_token", None) # type: Optional[str] + if cont_token is None: + raw_result = await self._update_initial( # type: ignore + resource_group_name=resource_group_name, + resource_provider_namespace=resource_provider_namespace, + parent_resource_path=parent_resource_path, + resource_type=resource_type, + resource_name=resource_name, + api_version=api_version, + parameters=parameters, + content_type=content_type, + cls=lambda x, y, z: x, + headers=_headers, + params=_params, + **kwargs + ) + kwargs.pop("error_map", None) + + def get_long_running_output(pipeline_response): + deserialized = self._deserialize("GenericResource", pipeline_response) + if cls: + return cls(pipeline_response, deserialized, {}) + return deserialized + + if polling is True: + polling_method = cast(AsyncPollingMethod, AsyncARMPolling(lro_delay, **kwargs)) # type: AsyncPollingMethod + elif polling is False: + polling_method = cast(AsyncPollingMethod, AsyncNoPolling()) + else: + polling_method = polling + if cont_token: + return AsyncLROPoller.from_continuation_token( + polling_method=polling_method, + continuation_token=cont_token, + client=self._client, + deserialization_callback=get_long_running_output, + ) + return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) + + begin_update.metadata = {"url": "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{parentResourcePath}/{resourceType}/{resourceName}"} # type: ignore + + @distributed_trace_async + async def get( + self, + resource_group_name: str, + resource_provider_namespace: str, + parent_resource_path: str, + resource_type: str, + resource_name: str, + api_version: str, + **kwargs: Any + ) -> _models.GenericResource: + """Gets a resource. + + :param resource_group_name: The name of the resource group containing the resource to get. The + name is case insensitive. Required. + :type resource_group_name: str + :param resource_provider_namespace: The namespace of the resource provider. Required. + :type resource_provider_namespace: str + :param parent_resource_path: The parent resource identity. Required. + :type parent_resource_path: str + :param resource_type: The resource type of the resource. Required. + :type resource_type: str + :param resource_name: The name of the resource to get. Required. + :type resource_name: str + :param api_version: The API version to use for the operation. Required. + :type api_version: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: GenericResource or the result of cls(response) + :rtype: ~azure.mgmt.resource.resources.v2021_01_01.models.GenericResource + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = kwargs.pop("params", {}) or {} + + cls = kwargs.pop("cls", None) # type: ClsType[_models.GenericResource] + + request = build_resources_get_request( resource_group_name=resource_group_name, resource_provider_namespace=resource_provider_namespace, parent_resource_path=parent_resource_path, @@ -5593,72 +7365,75 @@ async def get( resource_name=resource_name, subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.get.metadata['url'], + template_url=self.get.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) - deserialized = self._deserialize('GenericResource', pipeline_response) + deserialized = self._deserialize("GenericResource", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - get.metadata = {'url': "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{parentResourcePath}/{resourceType}/{resourceName}"} # type: ignore - + get.metadata = {"url": "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{parentResourcePath}/{resourceType}/{resourceName}"} # type: ignore @distributed_trace_async - async def check_existence_by_id( - self, - resource_id: str, - api_version: str, - **kwargs: Any - ) -> bool: + async def check_existence_by_id(self, resource_id: str, api_version: str, **kwargs: Any) -> bool: """Checks by ID whether a resource exists. :param resource_id: The fully qualified ID of the resource, including the resource name and resource type. Use the format, /subscriptions/{guid}/resourceGroups/{resource-group-name}/{resource-provider-namespace}/{resource-type}/{resource-name}. + Required. :type resource_id: str - :param api_version: The API version to use for the operation. + :param api_version: The API version to use for the operation. Required. :type api_version: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: bool, or the result of cls(response) + :return: bool or the result of cls(response) :rtype: bool - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType[None] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = kwargs.pop("params", {}) or {} + + cls = kwargs.pop("cls", None) # type: ClsType[None] - request = build_resources_check_existence_by_id_request( resource_id=resource_id, api_version=api_version, - template_url=self.check_existence_by_id.metadata['url'], + template_url=self.check_existence_by_id.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [204, 404]: @@ -5669,35 +7444,38 @@ async def check_existence_by_id( return cls(pipeline_response, None, {}) return 200 <= response.status_code <= 299 - check_existence_by_id.metadata = {'url': "/{resourceId}"} # type: ignore - + check_existence_by_id.metadata = {"url": "/{resourceId}"} # type: ignore async def _delete_by_id_initial( # pylint: disable=inconsistent-return-statements - self, - resource_id: str, - api_version: str, - **kwargs: Any + self, resource_id: str, api_version: str, **kwargs: Any ) -> None: - cls = kwargs.pop('cls', None) # type: ClsType[None] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = kwargs.pop("params", {}) or {} - - request = build_resources_delete_by_id_request_initial( + cls = kwargs.pop("cls", None) # type: ClsType[None] + + request = build_resources_delete_by_id_request( resource_id=resource_id, api_version=api_version, - template_url=self._delete_by_id_initial.metadata['url'], + template_url=self._delete_by_id_initial.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200, 202, 204]: @@ -5707,23 +7485,18 @@ async def _delete_by_id_initial( # pylint: disable=inconsistent-return-statemen if cls: return cls(pipeline_response, None, {}) - _delete_by_id_initial.metadata = {'url': "/{resourceId}"} # type: ignore - + _delete_by_id_initial.metadata = {"url": "/{resourceId}"} # type: ignore @distributed_trace_async - async def begin_delete_by_id( # pylint: disable=inconsistent-return-statements - self, - resource_id: str, - api_version: str, - **kwargs: Any - ) -> AsyncLROPoller[None]: + async def begin_delete_by_id(self, resource_id: str, api_version: str, **kwargs: Any) -> AsyncLROPoller[None]: """Deletes a resource by ID. :param resource_id: The fully qualified ID of the resource, including the resource name and resource type. Use the format, /subscriptions/{guid}/resourceGroups/{resource-group-name}/{resource-provider-namespace}/{resource-type}/{resource-name}. + Required. :type resource_id: str - :param api_version: The API version to use for the operation. + :param api_version: The API version to use for the operation. Required. :type api_version: str :keyword callable cls: A custom type or function that will be passed the direct response :keyword str continuation_token: A continuation token to restart a poller from a saved state. @@ -5735,75 +7508,89 @@ async def begin_delete_by_id( # pylint: disable=inconsistent-return-statements Retry-After header is present. :return: An instance of AsyncLROPoller that returns either None or the result of cls(response) :rtype: ~azure.core.polling.AsyncLROPoller[None] - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - polling = kwargs.pop('polling', True) # type: Union[bool, AsyncPollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType[None] - lro_delay = kwargs.pop( - 'polling_interval', - self._config.polling_interval - ) - cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] + _headers = kwargs.pop("headers", {}) or {} + _params = kwargs.pop("params", {}) or {} + + cls = kwargs.pop("cls", None) # type: ClsType[None] + polling = kwargs.pop("polling", True) # type: Union[bool, AsyncPollingMethod] + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token = kwargs.pop("continuation_token", None) # type: Optional[str] if cont_token is None: - raw_result = await self._delete_by_id_initial( + raw_result = await self._delete_by_id_initial( # type: ignore resource_id=resource_id, api_version=api_version, - cls=lambda x,y,z: x, + cls=lambda x, y, z: x, + headers=_headers, + params=_params, **kwargs ) - kwargs.pop('error_map', None) + kwargs.pop("error_map", None) - def get_long_running_output(pipeline_response): + def get_long_running_output(pipeline_response): # pylint: disable=inconsistent-return-statements if cls: return cls(pipeline_response, None, {}) - - if polling is True: polling_method = AsyncARMPolling(lro_delay, **kwargs) - elif polling is False: polling_method = AsyncNoPolling() - else: polling_method = polling + if polling is True: + polling_method = cast(AsyncPollingMethod, AsyncARMPolling(lro_delay, **kwargs)) # type: AsyncPollingMethod + elif polling is False: + polling_method = cast(AsyncPollingMethod, AsyncNoPolling()) + else: + polling_method = polling if cont_token: return AsyncLROPoller.from_continuation_token( polling_method=polling_method, continuation_token=cont_token, client=self._client, - deserialization_callback=get_long_running_output + deserialization_callback=get_long_running_output, ) return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) - begin_delete_by_id.metadata = {'url': "/{resourceId}"} # type: ignore + begin_delete_by_id.metadata = {"url": "/{resourceId}"} # type: ignore async def _create_or_update_by_id_initial( - self, - resource_id: str, - api_version: str, - parameters: "_models.GenericResource", - **kwargs: Any - ) -> Optional["_models.GenericResource"]: - cls = kwargs.pop('cls', None) # type: ClsType[Optional["_models.GenericResource"]] + self, resource_id: str, api_version: str, parameters: Union[_models.GenericResource, IO], **kwargs: Any + ) -> Optional[_models.GenericResource]: error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = kwargs.pop("params", {}) or {} - _json = self._serialize.body(parameters, 'GenericResource') + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[Optional[_models.GenericResource]] - request = build_resources_create_or_update_by_id_request_initial( + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(parameters, (IO, bytes)): + _content = parameters + else: + _json = self._serialize.body(parameters, "GenericResource") + + request = build_resources_create_or_update_by_id_request( resource_id=resource_id, - content_type=content_type, api_version=api_version, + content_type=content_type, json=_json, - template_url=self._create_or_update_by_id_initial.metadata['url'], + content=_content, + template_url=self._create_or_update_by_id_initial.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200, 201, 202]: @@ -5812,37 +7599,42 @@ async def _create_or_update_by_id_initial( deserialized = None if response.status_code == 200: - deserialized = self._deserialize('GenericResource', pipeline_response) + deserialized = self._deserialize("GenericResource", pipeline_response) if response.status_code == 201: - deserialized = self._deserialize('GenericResource', pipeline_response) + deserialized = self._deserialize("GenericResource", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - _create_or_update_by_id_initial.metadata = {'url': "/{resourceId}"} # type: ignore - + _create_or_update_by_id_initial.metadata = {"url": "/{resourceId}"} # type: ignore - @distributed_trace_async + @overload async def begin_create_or_update_by_id( self, resource_id: str, api_version: str, - parameters: "_models.GenericResource", + parameters: _models.GenericResource, + *, + content_type: str = "application/json", **kwargs: Any - ) -> AsyncLROPoller["_models.GenericResource"]: + ) -> AsyncLROPoller[_models.GenericResource]: """Create a resource by ID. :param resource_id: The fully qualified ID of the resource, including the resource name and resource type. Use the format, /subscriptions/{guid}/resourceGroups/{resource-group-name}/{resource-provider-namespace}/{resource-type}/{resource-name}. + Required. :type resource_id: str - :param api_version: The API version to use for the operation. + :param api_version: The API version to use for the operation. Required. :type api_version: str - :param parameters: Create or update resource parameters. + :param parameters: Create or update resource parameters. Required. :type parameters: ~azure.mgmt.resource.resources.v2021_01_01.models.GenericResource + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str :keyword callable cls: A custom type or function that will be passed the direct response :keyword str continuation_token: A continuation token to restart a poller from a saved state. :keyword polling: By default, your polling method will be AsyncARMPolling. Pass in False for @@ -5855,81 +7647,167 @@ async def begin_create_or_update_by_id( cls(response) :rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.resource.resources.v2021_01_01.models.GenericResource] - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] - polling = kwargs.pop('polling', True) # type: Union[bool, AsyncPollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType["_models.GenericResource"] - lro_delay = kwargs.pop( - 'polling_interval', - self._config.polling_interval - ) - cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] + + @overload + async def begin_create_or_update_by_id( + self, + resource_id: str, + api_version: str, + parameters: IO, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> AsyncLROPoller[_models.GenericResource]: + """Create a resource by ID. + + :param resource_id: The fully qualified ID of the resource, including the resource name and + resource type. Use the format, + /subscriptions/{guid}/resourceGroups/{resource-group-name}/{resource-provider-namespace}/{resource-type}/{resource-name}. + Required. + :type resource_id: str + :param api_version: The API version to use for the operation. Required. + :type api_version: str + :param parameters: Create or update resource parameters. Required. + :type parameters: IO + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be AsyncARMPolling. Pass in False for + this operation to not poll, or pass in your own initialized polling object for a personal + polling strategy. + :paramtype polling: bool or ~azure.core.polling.AsyncPollingMethod + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of AsyncLROPoller that returns either GenericResource or the result of + cls(response) + :rtype: + ~azure.core.polling.AsyncLROPoller[~azure.mgmt.resource.resources.v2021_01_01.models.GenericResource] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace_async + async def begin_create_or_update_by_id( + self, resource_id: str, api_version: str, parameters: Union[_models.GenericResource, IO], **kwargs: Any + ) -> AsyncLROPoller[_models.GenericResource]: + """Create a resource by ID. + + :param resource_id: The fully qualified ID of the resource, including the resource name and + resource type. Use the format, + /subscriptions/{guid}/resourceGroups/{resource-group-name}/{resource-provider-namespace}/{resource-type}/{resource-name}. + Required. + :type resource_id: str + :param api_version: The API version to use for the operation. Required. + :type api_version: str + :param parameters: Create or update resource parameters. Is either a model type or a IO type. + Required. + :type parameters: ~azure.mgmt.resource.resources.v2021_01_01.models.GenericResource or IO + :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. + Default value is None. + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be AsyncARMPolling. Pass in False for + this operation to not poll, or pass in your own initialized polling object for a personal + polling strategy. + :paramtype polling: bool or ~azure.core.polling.AsyncPollingMethod + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of AsyncLROPoller that returns either GenericResource or the result of + cls(response) + :rtype: + ~azure.core.polling.AsyncLROPoller[~azure.mgmt.resource.resources.v2021_01_01.models.GenericResource] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = kwargs.pop("params", {}) or {} + + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.GenericResource] + polling = kwargs.pop("polling", True) # type: Union[bool, AsyncPollingMethod] + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token = kwargs.pop("continuation_token", None) # type: Optional[str] if cont_token is None: - raw_result = await self._create_or_update_by_id_initial( + raw_result = await self._create_or_update_by_id_initial( # type: ignore resource_id=resource_id, api_version=api_version, parameters=parameters, content_type=content_type, - cls=lambda x,y,z: x, + cls=lambda x, y, z: x, + headers=_headers, + params=_params, **kwargs ) - kwargs.pop('error_map', None) + kwargs.pop("error_map", None) def get_long_running_output(pipeline_response): - response = pipeline_response.http_response - deserialized = self._deserialize('GenericResource', pipeline_response) + deserialized = self._deserialize("GenericResource", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - - if polling is True: polling_method = AsyncARMPolling(lro_delay, **kwargs) - elif polling is False: polling_method = AsyncNoPolling() - else: polling_method = polling + if polling is True: + polling_method = cast(AsyncPollingMethod, AsyncARMPolling(lro_delay, **kwargs)) # type: AsyncPollingMethod + elif polling is False: + polling_method = cast(AsyncPollingMethod, AsyncNoPolling()) + else: + polling_method = polling if cont_token: return AsyncLROPoller.from_continuation_token( polling_method=polling_method, continuation_token=cont_token, client=self._client, - deserialization_callback=get_long_running_output + deserialization_callback=get_long_running_output, ) return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) - begin_create_or_update_by_id.metadata = {'url': "/{resourceId}"} # type: ignore + begin_create_or_update_by_id.metadata = {"url": "/{resourceId}"} # type: ignore async def _update_by_id_initial( - self, - resource_id: str, - api_version: str, - parameters: "_models.GenericResource", - **kwargs: Any - ) -> Optional["_models.GenericResource"]: - cls = kwargs.pop('cls', None) # type: ClsType[Optional["_models.GenericResource"]] + self, resource_id: str, api_version: str, parameters: Union[_models.GenericResource, IO], **kwargs: Any + ) -> Optional[_models.GenericResource]: error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = kwargs.pop("params", {}) or {} - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[Optional[_models.GenericResource]] - _json = self._serialize.body(parameters, 'GenericResource') + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(parameters, (IO, bytes)): + _content = parameters + else: + _json = self._serialize.body(parameters, "GenericResource") - request = build_resources_update_by_id_request_initial( + request = build_resources_update_by_id_request( resource_id=resource_id, - content_type=content_type, api_version=api_version, + content_type=content_type, json=_json, - template_url=self._update_by_id_initial.metadata['url'], + content=_content, + template_url=self._update_by_id_initial.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200, 202]: @@ -5938,34 +7816,39 @@ async def _update_by_id_initial( deserialized = None if response.status_code == 200: - deserialized = self._deserialize('GenericResource', pipeline_response) + deserialized = self._deserialize("GenericResource", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - _update_by_id_initial.metadata = {'url': "/{resourceId}"} # type: ignore - + _update_by_id_initial.metadata = {"url": "/{resourceId}"} # type: ignore - @distributed_trace_async + @overload async def begin_update_by_id( self, resource_id: str, api_version: str, - parameters: "_models.GenericResource", + parameters: _models.GenericResource, + *, + content_type: str = "application/json", **kwargs: Any - ) -> AsyncLROPoller["_models.GenericResource"]: + ) -> AsyncLROPoller[_models.GenericResource]: """Updates a resource by ID. :param resource_id: The fully qualified ID of the resource, including the resource name and resource type. Use the format, /subscriptions/{guid}/resourceGroups/{resource-group-name}/{resource-provider-namespace}/{resource-type}/{resource-name}. + Required. :type resource_id: str - :param api_version: The API version to use for the operation. + :param api_version: The API version to use for the operation. Required. :type api_version: str - :param parameters: Update resource parameters. + :param parameters: Update resource parameters. Required. :type parameters: ~azure.mgmt.resource.resources.v2021_01_01.models.GenericResource + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str :keyword callable cls: A custom type or function that will be passed the direct response :keyword str continuation_token: A continuation token to restart a poller from a saved state. :keyword polling: By default, your polling method will be AsyncARMPolling. Pass in False for @@ -5978,165 +7861,243 @@ async def begin_update_by_id( cls(response) :rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.resource.resources.v2021_01_01.models.GenericResource] - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] - polling = kwargs.pop('polling', True) # type: Union[bool, AsyncPollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType["_models.GenericResource"] - lro_delay = kwargs.pop( - 'polling_interval', - self._config.polling_interval - ) - cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] + + @overload + async def begin_update_by_id( + self, + resource_id: str, + api_version: str, + parameters: IO, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> AsyncLROPoller[_models.GenericResource]: + """Updates a resource by ID. + + :param resource_id: The fully qualified ID of the resource, including the resource name and + resource type. Use the format, + /subscriptions/{guid}/resourceGroups/{resource-group-name}/{resource-provider-namespace}/{resource-type}/{resource-name}. + Required. + :type resource_id: str + :param api_version: The API version to use for the operation. Required. + :type api_version: str + :param parameters: Update resource parameters. Required. + :type parameters: IO + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be AsyncARMPolling. Pass in False for + this operation to not poll, or pass in your own initialized polling object for a personal + polling strategy. + :paramtype polling: bool or ~azure.core.polling.AsyncPollingMethod + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of AsyncLROPoller that returns either GenericResource or the result of + cls(response) + :rtype: + ~azure.core.polling.AsyncLROPoller[~azure.mgmt.resource.resources.v2021_01_01.models.GenericResource] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace_async + async def begin_update_by_id( + self, resource_id: str, api_version: str, parameters: Union[_models.GenericResource, IO], **kwargs: Any + ) -> AsyncLROPoller[_models.GenericResource]: + """Updates a resource by ID. + + :param resource_id: The fully qualified ID of the resource, including the resource name and + resource type. Use the format, + /subscriptions/{guid}/resourceGroups/{resource-group-name}/{resource-provider-namespace}/{resource-type}/{resource-name}. + Required. + :type resource_id: str + :param api_version: The API version to use for the operation. Required. + :type api_version: str + :param parameters: Update resource parameters. Is either a model type or a IO type. Required. + :type parameters: ~azure.mgmt.resource.resources.v2021_01_01.models.GenericResource or IO + :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. + Default value is None. + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be AsyncARMPolling. Pass in False for + this operation to not poll, or pass in your own initialized polling object for a personal + polling strategy. + :paramtype polling: bool or ~azure.core.polling.AsyncPollingMethod + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of AsyncLROPoller that returns either GenericResource or the result of + cls(response) + :rtype: + ~azure.core.polling.AsyncLROPoller[~azure.mgmt.resource.resources.v2021_01_01.models.GenericResource] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = kwargs.pop("params", {}) or {} + + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.GenericResource] + polling = kwargs.pop("polling", True) # type: Union[bool, AsyncPollingMethod] + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token = kwargs.pop("continuation_token", None) # type: Optional[str] if cont_token is None: - raw_result = await self._update_by_id_initial( + raw_result = await self._update_by_id_initial( # type: ignore resource_id=resource_id, api_version=api_version, parameters=parameters, content_type=content_type, - cls=lambda x,y,z: x, + cls=lambda x, y, z: x, + headers=_headers, + params=_params, **kwargs ) - kwargs.pop('error_map', None) + kwargs.pop("error_map", None) def get_long_running_output(pipeline_response): - response = pipeline_response.http_response - deserialized = self._deserialize('GenericResource', pipeline_response) + deserialized = self._deserialize("GenericResource", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - - if polling is True: polling_method = AsyncARMPolling(lro_delay, **kwargs) - elif polling is False: polling_method = AsyncNoPolling() - else: polling_method = polling + if polling is True: + polling_method = cast(AsyncPollingMethod, AsyncARMPolling(lro_delay, **kwargs)) # type: AsyncPollingMethod + elif polling is False: + polling_method = cast(AsyncPollingMethod, AsyncNoPolling()) + else: + polling_method = polling if cont_token: return AsyncLROPoller.from_continuation_token( polling_method=polling_method, continuation_token=cont_token, client=self._client, - deserialization_callback=get_long_running_output + deserialization_callback=get_long_running_output, ) return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) - begin_update_by_id.metadata = {'url': "/{resourceId}"} # type: ignore + begin_update_by_id.metadata = {"url": "/{resourceId}"} # type: ignore @distributed_trace_async - async def get_by_id( - self, - resource_id: str, - api_version: str, - **kwargs: Any - ) -> "_models.GenericResource": + async def get_by_id(self, resource_id: str, api_version: str, **kwargs: Any) -> _models.GenericResource: """Gets a resource by ID. :param resource_id: The fully qualified ID of the resource, including the resource name and resource type. Use the format, /subscriptions/{guid}/resourceGroups/{resource-group-name}/{resource-provider-namespace}/{resource-type}/{resource-name}. + Required. :type resource_id: str - :param api_version: The API version to use for the operation. + :param api_version: The API version to use for the operation. Required. :type api_version: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: GenericResource, or the result of cls(response) + :return: GenericResource or the result of cls(response) :rtype: ~azure.mgmt.resource.resources.v2021_01_01.models.GenericResource - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.GenericResource"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = kwargs.pop("params", {}) or {} + + cls = kwargs.pop("cls", None) # type: ClsType[_models.GenericResource] - request = build_resources_get_by_id_request( resource_id=resource_id, api_version=api_version, - template_url=self.get_by_id.metadata['url'], + template_url=self.get_by_id.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) - deserialized = self._deserialize('GenericResource', pipeline_response) + deserialized = self._deserialize("GenericResource", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - get_by_id.metadata = {'url': "/{resourceId}"} # type: ignore + get_by_id.metadata = {"url": "/{resourceId}"} # type: ignore -class ResourceGroupsOperations: - """ResourceGroupsOperations async operations. - You should not instantiate this class directly. Instead, you should create a Client instance that - instantiates it for you and attaches it as an attribute. +class ResourceGroupsOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. - :ivar models: Alias to model classes used in this operation group. - :type models: ~azure.mgmt.resource.resources.v2021_01_01.models - :param client: Client for service requests. - :param config: Configuration of service client. - :param serializer: An object model serializer. - :param deserializer: An object model deserializer. + Instead, you should access the following operations through + :class:`~azure.mgmt.resource.resources.v2021_01_01.aio.ResourceManagementClient`'s + :attr:`resource_groups` attribute. """ models = _models - def __init__(self, client, config, serializer, deserializer) -> None: - self._client = client - self._serialize = serializer - self._deserialize = deserializer - self._config = config + def __init__(self, *args, **kwargs) -> None: + input_args = list(args) + self._client = input_args.pop(0) if input_args else kwargs.pop("client") + self._config = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") @distributed_trace_async - async def check_existence( - self, - resource_group_name: str, - **kwargs: Any - ) -> bool: + async def check_existence(self, resource_group_name: str, **kwargs: Any) -> bool: """Checks whether a resource group exists. :param resource_group_name: The name of the resource group to check. The name is case - insensitive. + insensitive. Required. :type resource_group_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: bool, or the result of cls(response) + :return: bool or the result of cls(response) :rtype: bool - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType[None] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) - api_version = kwargs.pop('api_version', "2021-01-01") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-01-01")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[None] - request = build_resource_groups_check_existence_request( resource_group_name=resource_group_name, subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.check_existence.metadata['url'], + template_url=self.check_existence.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [204, 404]: @@ -6147,39 +8108,98 @@ async def check_existence( return cls(pipeline_response, None, {}) return 200 <= response.status_code <= 299 - check_existence.metadata = {'url': "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}"} # type: ignore - + check_existence.metadata = {"url": "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}"} # type: ignore - @distributed_trace_async + @overload async def create_or_update( self, resource_group_name: str, - parameters: "_models.ResourceGroup", + parameters: _models.ResourceGroup, + *, + content_type: str = "application/json", **kwargs: Any - ) -> "_models.ResourceGroup": + ) -> _models.ResourceGroup: """Creates or updates a resource group. :param resource_group_name: The name of the resource group to create or update. Can include alphanumeric, underscore, parentheses, hyphen, period (except at end), and Unicode characters - that match the allowed characters. + that match the allowed characters. Required. :type resource_group_name: str - :param parameters: Parameters supplied to the create or update a resource group. + :param parameters: Parameters supplied to the create or update a resource group. Required. :type parameters: ~azure.mgmt.resource.resources.v2021_01_01.models.ResourceGroup + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: ResourceGroup or the result of cls(response) + :rtype: ~azure.mgmt.resource.resources.v2021_01_01.models.ResourceGroup + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + async def create_or_update( + self, resource_group_name: str, parameters: IO, *, content_type: str = "application/json", **kwargs: Any + ) -> _models.ResourceGroup: + """Creates or updates a resource group. + + :param resource_group_name: The name of the resource group to create or update. Can include + alphanumeric, underscore, parentheses, hyphen, period (except at end), and Unicode characters + that match the allowed characters. Required. + :type resource_group_name: str + :param parameters: Parameters supplied to the create or update a resource group. Required. + :type parameters: IO + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: ResourceGroup, or the result of cls(response) + :return: ResourceGroup or the result of cls(response) :rtype: ~azure.mgmt.resource.resources.v2021_01_01.models.ResourceGroup - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace_async + async def create_or_update( + self, resource_group_name: str, parameters: Union[_models.ResourceGroup, IO], **kwargs: Any + ) -> _models.ResourceGroup: + """Creates or updates a resource group. + + :param resource_group_name: The name of the resource group to create or update. Can include + alphanumeric, underscore, parentheses, hyphen, period (except at end), and Unicode characters + that match the allowed characters. Required. + :type resource_group_name: str + :param parameters: Parameters supplied to the create or update a resource group. Is either a + model type or a IO type. Required. + :type parameters: ~azure.mgmt.resource.resources.v2021_01_01.models.ResourceGroup or IO + :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. + Default value is None. + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: ResourceGroup or the result of cls(response) + :rtype: ~azure.mgmt.resource.resources.v2021_01_01.models.ResourceGroup + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.ResourceGroup"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', "2021-01-01") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-01-01")) # type: str + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.ResourceGroup] - _json = self._serialize.body(parameters, 'ResourceGroup') + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(parameters, (IO, bytes)): + _content = parameters + else: + _json = self._serialize.body(parameters, "ResourceGroup") request = build_resource_groups_create_or_update_request( resource_group_name=resource_group_name, @@ -6187,16 +8207,18 @@ async def create_or_update( api_version=api_version, content_type=content_type, json=_json, - template_url=self.create_or_update.metadata['url'], + content=_content, + template_url=self.create_or_update.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200, 201]: @@ -6204,49 +8226,51 @@ async def create_or_update( raise HttpResponseError(response=response, error_format=ARMErrorFormat) if response.status_code == 200: - deserialized = self._deserialize('ResourceGroup', pipeline_response) + deserialized = self._deserialize("ResourceGroup", pipeline_response) if response.status_code == 201: - deserialized = self._deserialize('ResourceGroup', pipeline_response) + deserialized = self._deserialize("ResourceGroup", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - create_or_update.metadata = {'url': "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}"} # type: ignore - + create_or_update.metadata = {"url": "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}"} # type: ignore async def _delete_initial( # pylint: disable=inconsistent-return-statements - self, - resource_group_name: str, - force_deletion_types: Optional[str] = None, - **kwargs: Any + self, resource_group_name: str, force_deletion_types: Optional[str] = None, **kwargs: Any ) -> None: - cls = kwargs.pop('cls', None) # type: ClsType[None] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + 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', "2021-01-01") # type: str + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-01-01")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[None] - - request = build_resource_groups_delete_request_initial( + request = build_resource_groups_delete_request( resource_group_name=resource_group_name, subscription_id=self._config.subscription_id, - api_version=api_version, force_deletion_types=force_deletion_types, - template_url=self._delete_initial.metadata['url'], + api_version=api_version, + template_url=self._delete_initial.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200, 202]: @@ -6256,15 +8280,11 @@ async def _delete_initial( # pylint: disable=inconsistent-return-statements if cls: return cls(pipeline_response, None, {}) - _delete_initial.metadata = {'url': "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}"} # type: ignore - + _delete_initial.metadata = {"url": "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}"} # type: ignore @distributed_trace_async - async def begin_delete( # pylint: disable=inconsistent-return-statements - self, - resource_group_name: str, - force_deletion_types: Optional[str] = None, - **kwargs: Any + async def begin_delete( + self, resource_group_name: str, force_deletion_types: Optional[str] = None, **kwargs: Any ) -> AsyncLROPoller[None]: """Deletes a resource group. @@ -6272,7 +8292,7 @@ async def begin_delete( # pylint: disable=inconsistent-return-statements group deletes all of its template deployments and currently stored operations. :param resource_group_name: The name of the resource group to delete. The name is case - insensitive. + insensitive. Required. :type resource_group_name: str :param force_deletion_types: The resource types you want to force delete. Currently, only the following is supported: @@ -6289,107 +8309,114 @@ async def begin_delete( # pylint: disable=inconsistent-return-statements Retry-After header is present. :return: An instance of AsyncLROPoller that returns either None or the result of cls(response) :rtype: ~azure.core.polling.AsyncLROPoller[None] - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - api_version = kwargs.pop('api_version', "2021-01-01") # type: str - polling = kwargs.pop('polling', True) # type: Union[bool, AsyncPollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType[None] - lro_delay = kwargs.pop( - 'polling_interval', - self._config.polling_interval - ) - cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-01-01")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[None] + polling = kwargs.pop("polling", True) # type: Union[bool, AsyncPollingMethod] + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token = kwargs.pop("continuation_token", None) # type: Optional[str] if cont_token is None: - raw_result = await self._delete_initial( + raw_result = await self._delete_initial( # type: ignore resource_group_name=resource_group_name, force_deletion_types=force_deletion_types, api_version=api_version, - cls=lambda x,y,z: x, + cls=lambda x, y, z: x, + headers=_headers, + params=_params, **kwargs ) - kwargs.pop('error_map', None) + kwargs.pop("error_map", None) - def get_long_running_output(pipeline_response): + def get_long_running_output(pipeline_response): # pylint: disable=inconsistent-return-statements if cls: return cls(pipeline_response, None, {}) - - if polling is True: polling_method = AsyncARMPolling(lro_delay, **kwargs) - elif polling is False: polling_method = AsyncNoPolling() - else: polling_method = polling + if polling is True: + polling_method = cast(AsyncPollingMethod, AsyncARMPolling(lro_delay, **kwargs)) # type: AsyncPollingMethod + elif polling is False: + polling_method = cast(AsyncPollingMethod, AsyncNoPolling()) + else: + polling_method = polling if cont_token: return AsyncLROPoller.from_continuation_token( polling_method=polling_method, continuation_token=cont_token, client=self._client, - deserialization_callback=get_long_running_output + deserialization_callback=get_long_running_output, ) return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) - begin_delete.metadata = {'url': "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}"} # type: ignore + begin_delete.metadata = {"url": "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}"} # type: ignore @distributed_trace_async - async def get( - self, - resource_group_name: str, - **kwargs: Any - ) -> "_models.ResourceGroup": + async def get(self, resource_group_name: str, **kwargs: Any) -> _models.ResourceGroup: """Gets a resource group. :param resource_group_name: The name of the resource group to get. The name is case - insensitive. + insensitive. Required. :type resource_group_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: ResourceGroup, or the result of cls(response) + :return: ResourceGroup or the result of cls(response) :rtype: ~azure.mgmt.resource.resources.v2021_01_01.models.ResourceGroup - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.ResourceGroup"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) - api_version = kwargs.pop('api_version', "2021-01-01") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-01-01")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[_models.ResourceGroup] - request = build_resource_groups_get_request( resource_group_name=resource_group_name, subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.get.metadata['url'], + template_url=self.get.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) - deserialized = self._deserialize('ResourceGroup', pipeline_response) + deserialized = self._deserialize("ResourceGroup", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - get.metadata = {'url': "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}"} # type: ignore - + get.metadata = {"url": "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}"} # type: ignore - @distributed_trace_async + @overload async def update( self, resource_group_name: str, - parameters: "_models.ResourceGroupPatchable", + parameters: _models.ResourceGroupPatchable, + *, + content_type: str = "application/json", **kwargs: Any - ) -> "_models.ResourceGroup": + ) -> _models.ResourceGroup: """Updates a resource group. Resource groups can be updated through a simple PATCH operation to a group address. The format @@ -6397,25 +8424,90 @@ async def update( the current value is retained. :param resource_group_name: The name of the resource group to update. The name is case - insensitive. + insensitive. Required. :type resource_group_name: str - :param parameters: Parameters supplied to update a resource group. + :param parameters: Parameters supplied to update a resource group. Required. :type parameters: ~azure.mgmt.resource.resources.v2021_01_01.models.ResourceGroupPatchable + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: ResourceGroup or the result of cls(response) + :rtype: ~azure.mgmt.resource.resources.v2021_01_01.models.ResourceGroup + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + async def update( + self, resource_group_name: str, parameters: IO, *, content_type: str = "application/json", **kwargs: Any + ) -> _models.ResourceGroup: + """Updates a resource group. + + Resource groups can be updated through a simple PATCH operation to a group address. The format + of the request is the same as that for creating a resource group. If a field is unspecified, + the current value is retained. + + :param resource_group_name: The name of the resource group to update. The name is case + insensitive. Required. + :type resource_group_name: str + :param parameters: Parameters supplied to update a resource group. Required. + :type parameters: IO + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: ResourceGroup, or the result of cls(response) + :return: ResourceGroup or the result of cls(response) :rtype: ~azure.mgmt.resource.resources.v2021_01_01.models.ResourceGroup - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace_async + async def update( + self, resource_group_name: str, parameters: Union[_models.ResourceGroupPatchable, IO], **kwargs: Any + ) -> _models.ResourceGroup: + """Updates a resource group. + + Resource groups can be updated through a simple PATCH operation to a group address. The format + of the request is the same as that for creating a resource group. If a field is unspecified, + the current value is retained. + + :param resource_group_name: The name of the resource group to update. The name is case + insensitive. Required. + :type resource_group_name: str + :param parameters: Parameters supplied to update a resource group. Is either a model type or a + IO type. Required. + :type parameters: ~azure.mgmt.resource.resources.v2021_01_01.models.ResourceGroupPatchable or + IO + :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. + Default value is None. + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: ResourceGroup or the result of cls(response) + :rtype: ~azure.mgmt.resource.resources.v2021_01_01.models.ResourceGroup + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.ResourceGroup"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', "2021-01-01") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-01-01")) # type: str + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.ResourceGroup] - _json = self._serialize.body(parameters, 'ResourceGroupPatchable') + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(parameters, (IO, bytes)): + _content = parameters + else: + _json = self._serialize.body(parameters, "ResourceGroupPatchable") request = build_resource_groups_update_request( resource_group_name=resource_group_name, @@ -6423,65 +8515,77 @@ async def update( api_version=api_version, content_type=content_type, json=_json, - template_url=self.update.metadata['url'], + content=_content, + template_url=self.update.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) - deserialized = self._deserialize('ResourceGroup', pipeline_response) + deserialized = self._deserialize("ResourceGroup", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - update.metadata = {'url': "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}"} # type: ignore - + update.metadata = {"url": "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}"} # type: ignore async def _export_template_initial( - self, - resource_group_name: str, - parameters: "_models.ExportTemplateRequest", - **kwargs: Any - ) -> Optional["_models.ResourceGroupExportResult"]: - cls = kwargs.pop('cls', None) # type: ClsType[Optional["_models.ResourceGroupExportResult"]] + self, resource_group_name: str, parameters: Union[_models.ExportTemplateRequest, IO], **kwargs: Any + ) -> Optional[_models.ResourceGroupExportResult]: error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) - api_version = kwargs.pop('api_version', "2021-01-01") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - _json = self._serialize.body(parameters, 'ExportTemplateRequest') + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-01-01")) # type: str + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[Optional[_models.ResourceGroupExportResult]] - request = build_resource_groups_export_template_request_initial( - subscription_id=self._config.subscription_id, + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(parameters, (IO, bytes)): + _content = parameters + else: + _json = self._serialize.body(parameters, "ExportTemplateRequest") + + request = build_resource_groups_export_template_request( resource_group_name=resource_group_name, + subscription_id=self._config.subscription_id, api_version=api_version, content_type=content_type, json=_json, - template_url=self._export_template_initial.metadata['url'], + content=_content, + template_url=self._export_template_initial.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200, 202]: @@ -6490,29 +8594,93 @@ async def _export_template_initial( deserialized = None if response.status_code == 200: - deserialized = self._deserialize('ResourceGroupExportResult', pipeline_response) + deserialized = self._deserialize("ResourceGroupExportResult", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - _export_template_initial.metadata = {'url': "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/exportTemplate"} # type: ignore - + _export_template_initial.metadata = {"url": "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/exportTemplate"} # type: ignore - @distributed_trace_async + @overload async def begin_export_template( self, resource_group_name: str, - parameters: "_models.ExportTemplateRequest", + parameters: _models.ExportTemplateRequest, + *, + content_type: str = "application/json", **kwargs: Any - ) -> AsyncLROPoller["_models.ResourceGroupExportResult"]: + ) -> AsyncLROPoller[_models.ResourceGroupExportResult]: + """Captures the specified resource group as a template. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param parameters: Parameters for exporting the template. Required. + :type parameters: ~azure.mgmt.resource.resources.v2021_01_01.models.ExportTemplateRequest + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be AsyncARMPolling. Pass in False for + this operation to not poll, or pass in your own initialized polling object for a personal + polling strategy. + :paramtype polling: bool or ~azure.core.polling.AsyncPollingMethod + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of AsyncLROPoller that returns either ResourceGroupExportResult or the + result of cls(response) + :rtype: + ~azure.core.polling.AsyncLROPoller[~azure.mgmt.resource.resources.v2021_01_01.models.ResourceGroupExportResult] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + async def begin_export_template( + self, resource_group_name: str, parameters: IO, *, content_type: str = "application/json", **kwargs: Any + ) -> AsyncLROPoller[_models.ResourceGroupExportResult]: + """Captures the specified resource group as a template. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param parameters: Parameters for exporting the template. Required. + :type parameters: IO + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be AsyncARMPolling. Pass in False for + this operation to not poll, or pass in your own initialized polling object for a personal + polling strategy. + :paramtype polling: bool or ~azure.core.polling.AsyncPollingMethod + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of AsyncLROPoller that returns either ResourceGroupExportResult or the + result of cls(response) + :rtype: + ~azure.core.polling.AsyncLROPoller[~azure.mgmt.resource.resources.v2021_01_01.models.ResourceGroupExportResult] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace_async + async def begin_export_template( + self, resource_group_name: str, parameters: Union[_models.ExportTemplateRequest, IO], **kwargs: Any + ) -> AsyncLROPoller[_models.ResourceGroupExportResult]: """Captures the specified resource group as a template. :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. :type resource_group_name: str - :param parameters: Parameters for exporting the template. - :type parameters: ~azure.mgmt.resource.resources.v2021_01_01.models.ExportTemplateRequest + :param parameters: Parameters for exporting the template. Is either a model type or a IO type. + Required. + :type parameters: ~azure.mgmt.resource.resources.v2021_01_01.models.ExportTemplateRequest or IO + :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. + Default value is None. + :paramtype content_type: str :keyword callable cls: A custom type or function that will be passed the direct response :keyword str continuation_token: A continuation token to restart a poller from a saved state. :keyword polling: By default, your polling method will be AsyncARMPolling. Pass in False for @@ -6525,57 +8693,59 @@ async def begin_export_template( result of cls(response) :rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.resource.resources.v2021_01_01.models.ResourceGroupExportResult] - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - api_version = kwargs.pop('api_version', "2021-01-01") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] - polling = kwargs.pop('polling', True) # type: Union[bool, AsyncPollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType["_models.ResourceGroupExportResult"] - lro_delay = kwargs.pop( - 'polling_interval', - self._config.polling_interval - ) - cont_token = kwargs.pop('continuation_token', None) # type: Optional[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-01-01")) # type: str + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.ResourceGroupExportResult] + polling = kwargs.pop("polling", True) # type: Union[bool, AsyncPollingMethod] + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token = kwargs.pop("continuation_token", None) # type: Optional[str] if cont_token is None: - raw_result = await self._export_template_initial( + raw_result = await self._export_template_initial( # type: ignore resource_group_name=resource_group_name, parameters=parameters, api_version=api_version, content_type=content_type, - cls=lambda x,y,z: x, + cls=lambda x, y, z: x, + headers=_headers, + params=_params, **kwargs ) - kwargs.pop('error_map', None) + kwargs.pop("error_map", None) def get_long_running_output(pipeline_response): - response = pipeline_response.http_response - deserialized = self._deserialize('ResourceGroupExportResult', pipeline_response) + deserialized = self._deserialize("ResourceGroupExportResult", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - - if polling is True: polling_method = AsyncARMPolling(lro_delay, lro_options={'final-state-via': 'location'}, **kwargs) - elif polling is False: polling_method = AsyncNoPolling() - else: polling_method = polling + if polling is True: + polling_method = cast( + AsyncPollingMethod, AsyncARMPolling(lro_delay, lro_options={"final-state-via": "location"}, **kwargs) + ) # type: AsyncPollingMethod + elif polling is False: + polling_method = cast(AsyncPollingMethod, AsyncNoPolling()) + else: + polling_method = polling if cont_token: return AsyncLROPoller.from_continuation_token( polling_method=polling_method, continuation_token=cont_token, client=self._client, - deserialization_callback=get_long_running_output + deserialization_callback=get_long_running_output, ) return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) - begin_export_template.metadata = {'url': "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/exportTemplate"} # type: ignore + begin_export_template.metadata = {"url": "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/exportTemplate"} # type: ignore @distributed_trace def list( - self, - filter: Optional[str] = None, - top: Optional[int] = None, - **kwargs: Any - ) -> AsyncIterable["_models.ResourceGroupListResult"]: + self, filter: Optional[str] = None, top: Optional[int] = None, **kwargs: Any + ) -> AsyncIterable["_models.ResourceGroup"]: """Gets all the resource groups for a subscription. :param filter: The filter to apply on the operation.:code:`
`:code:`
`You can filter by @@ -6586,40 +8756,48 @@ def list( Default value is None. :type top: int :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either ResourceGroupListResult or the result of - cls(response) + :return: An iterator like instance of either ResourceGroup or the result of cls(response) :rtype: - ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.resource.resources.v2021_01_01.models.ResourceGroupListResult] - :raises: ~azure.core.exceptions.HttpResponseError + ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.resource.resources.v2021_01_01.models.ResourceGroup] + :raises ~azure.core.exceptions.HttpResponseError: """ - api_version = kwargs.pop('api_version', "2021-01-01") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-01-01")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[_models.ResourceGroupListResult] - cls = kwargs.pop('cls', None) # type: ClsType["_models.ResourceGroupListResult"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) + def prepare_request(next_link=None): if not next_link: - + request = build_resource_groups_list_request( subscription_id=self._config.subscription_id, - api_version=api_version, filter=filter, top=top, - template_url=self.list.metadata['url'], + 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.url = self._client.format_url(request.url) # type: ignore else: - - request = build_resource_groups_list_request( - subscription_id=self._config.subscription_id, - template_url=next_link, - ) + # make call to next link with the client's api-version + _parsed_next_link = urlparse(next_link) + _next_request_params = case_insensitive_dict(parse_qs(_parsed_next_link.query)) + _next_request_params["api-version"] = self._config.api_version + request = HttpRequest("GET", urljoin(next_link, _parsed_next_link.path), params=_next_request_params) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore request.method = "GET" return request @@ -6633,10 +8811,8 @@ async def extract_data(pipeline_response): async def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) response = pipeline_response.http_response @@ -6646,39 +8822,33 @@ async def get_next(next_link=None): return pipeline_response + return AsyncItemPaged(get_next, extract_data) - return AsyncItemPaged( - get_next, extract_data - ) - list.metadata = {'url': "/subscriptions/{subscriptionId}/resourcegroups"} # type: ignore -class TagsOperations: - """TagsOperations async operations. + list.metadata = {"url": "/subscriptions/{subscriptionId}/resourcegroups"} # type: ignore - You should not instantiate this class directly. Instead, you should create a Client instance that - instantiates it for you and attaches it as an attribute. - :ivar models: Alias to model classes used in this operation group. - :type models: ~azure.mgmt.resource.resources.v2021_01_01.models - :param client: Client for service requests. - :param config: Configuration of service client. - :param serializer: An object model serializer. - :param deserializer: An object model deserializer. +class TagsOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. + + Instead, you should access the following operations through + :class:`~azure.mgmt.resource.resources.v2021_01_01.aio.ResourceManagementClient`'s + :attr:`tags` attribute. """ models = _models - def __init__(self, client, config, serializer, deserializer) -> None: - self._client = client - self._serialize = serializer - self._deserialize = deserializer - self._config = config + def __init__(self, *args, **kwargs) -> None: + input_args = list(args) + self._client = input_args.pop(0) if input_args else kwargs.pop("client") + self._config = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") @distributed_trace_async async def delete_value( # pylint: disable=inconsistent-return-statements - self, - tag_name: str, - tag_value: str, - **kwargs: Any + self, tag_name: str, tag_value: str, **kwargs: Any ) -> None: """Deletes a predefined tag value for a predefined tag name. @@ -6686,39 +8856,45 @@ async def delete_value( # pylint: disable=inconsistent-return-statements predefined tag name. The value being deleted must not be in use as a tag value for the given tag name for any resource. - :param tag_name: The name of the tag. + :param tag_name: The name of the tag. Required. :type tag_name: str - :param tag_value: The value of the tag to delete. + :param tag_value: The value of the tag to delete. Required. :type tag_value: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: None, or the result of cls(response) + :return: None or the result of cls(response) :rtype: None - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType[None] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + 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', "2021-01-01") # type: str + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-01-01")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[None] - request = build_tags_delete_value_request( tag_name=tag_name, tag_value=tag_value, subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.delete_value.metadata['url'], + template_url=self.delete_value.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200, 204]: @@ -6728,54 +8904,54 @@ async def delete_value( # pylint: disable=inconsistent-return-statements if cls: return cls(pipeline_response, None, {}) - delete_value.metadata = {'url': "/subscriptions/{subscriptionId}/tagNames/{tagName}/tagValues/{tagValue}"} # type: ignore - + delete_value.metadata = {"url": "/subscriptions/{subscriptionId}/tagNames/{tagName}/tagValues/{tagValue}"} # type: ignore @distributed_trace_async - async def create_or_update_value( - self, - tag_name: str, - tag_value: str, - **kwargs: Any - ) -> "_models.TagValue": + async def create_or_update_value(self, tag_name: str, tag_value: str, **kwargs: Any) -> _models.TagValue: """Creates a predefined value for a predefined tag name. This operation allows adding a value to the list of predefined values for an existing predefined tag name. A tag value can have a maximum of 256 characters. - :param tag_name: The name of the tag. + :param tag_name: The name of the tag. Required. :type tag_name: str - :param tag_value: The value of the tag to create. + :param tag_value: The value of the tag to create. Required. :type tag_value: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: TagValue, or the result of cls(response) + :return: TagValue or the result of cls(response) :rtype: ~azure.mgmt.resource.resources.v2021_01_01.models.TagValue - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.TagValue"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) - api_version = kwargs.pop('api_version', "2021-01-01") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-01-01")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[_models.TagValue] - request = build_tags_create_or_update_value_request( tag_name=tag_name, tag_value=tag_value, subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.create_or_update_value.metadata['url'], + template_url=self.create_or_update_value.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200, 201]: @@ -6783,25 +8959,20 @@ async def create_or_update_value( raise HttpResponseError(response=response, error_format=ARMErrorFormat) if response.status_code == 200: - deserialized = self._deserialize('TagValue', pipeline_response) + deserialized = self._deserialize("TagValue", pipeline_response) if response.status_code == 201: - deserialized = self._deserialize('TagValue', pipeline_response) + deserialized = self._deserialize("TagValue", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - create_or_update_value.metadata = {'url': "/subscriptions/{subscriptionId}/tagNames/{tagName}/tagValues/{tagValue}"} # type: ignore - + create_or_update_value.metadata = {"url": "/subscriptions/{subscriptionId}/tagNames/{tagName}/tagValues/{tagValue}"} # type: ignore @distributed_trace_async - async def create_or_update( - self, - tag_name: str, - **kwargs: Any - ) -> "_models.TagDetails": + async def create_or_update(self, tag_name: str, **kwargs: Any) -> _models.TagDetails: """Creates a predefined tag name. This operation allows adding a name to the list of predefined tag names for the given @@ -6809,36 +8980,42 @@ async def create_or_update( names cannot have the following prefixes which are reserved for Azure use: 'microsoft', 'azure', 'windows'. - :param tag_name: The name of the tag to create. + :param tag_name: The name of the tag to create. Required. :type tag_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: TagDetails, or the result of cls(response) + :return: TagDetails or the result of cls(response) :rtype: ~azure.mgmt.resource.resources.v2021_01_01.models.TagDetails - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.TagDetails"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) - api_version = kwargs.pop('api_version', "2021-01-01") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-01-01")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[_models.TagDetails] - request = build_tags_create_or_update_request( tag_name=tag_name, subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.create_or_update.metadata['url'], + template_url=self.create_or_update.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200, 201]: @@ -6846,61 +9023,62 @@ async def create_or_update( raise HttpResponseError(response=response, error_format=ARMErrorFormat) if response.status_code == 200: - deserialized = self._deserialize('TagDetails', pipeline_response) + deserialized = self._deserialize("TagDetails", pipeline_response) if response.status_code == 201: - deserialized = self._deserialize('TagDetails', pipeline_response) + deserialized = self._deserialize("TagDetails", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - create_or_update.metadata = {'url': "/subscriptions/{subscriptionId}/tagNames/{tagName}"} # type: ignore - + create_or_update.metadata = {"url": "/subscriptions/{subscriptionId}/tagNames/{tagName}"} # type: ignore @distributed_trace_async - async def delete( # pylint: disable=inconsistent-return-statements - self, - tag_name: str, - **kwargs: Any - ) -> None: + async def delete(self, tag_name: str, **kwargs: Any) -> None: # pylint: disable=inconsistent-return-statements """Deletes a predefined tag name. This operation allows deleting a name from the list of predefined tag names for the given subscription. The name being deleted must not be in use as a tag name for any resource. All predefined values for the given name must have already been deleted. - :param tag_name: The name of the tag. + :param tag_name: The name of the tag. Required. :type tag_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: None, or the result of cls(response) + :return: None or the result of cls(response) :rtype: None - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType[None] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) - api_version = kwargs.pop('api_version', "2021-01-01") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-01-01")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[None] - request = build_tags_delete_request( tag_name=tag_name, subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.delete.metadata['url'], + template_url=self.delete.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200, 204]: @@ -6910,14 +9088,10 @@ async def delete( # pylint: disable=inconsistent-return-statements if cls: return cls(pipeline_response, None, {}) - delete.metadata = {'url': "/subscriptions/{subscriptionId}/tagNames/{tagName}"} # type: ignore - + delete.metadata = {"url": "/subscriptions/{subscriptionId}/tagNames/{tagName}"} # type: ignore @distributed_trace - def list( - self, - **kwargs: Any - ) -> AsyncIterable["_models.TagsListResult"]: + def list(self, **kwargs: Any) -> AsyncIterable["_models.TagDetails"]: """Gets a summary of tag usage under the subscription. This operation performs a union of predefined tags, resource tags, resource group tags and @@ -6926,37 +9100,46 @@ def list( result. :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either TagsListResult or the result of cls(response) + :return: An iterator like instance of either TagDetails or the result of cls(response) :rtype: - ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.resource.resources.v2021_01_01.models.TagsListResult] - :raises: ~azure.core.exceptions.HttpResponseError + ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.resource.resources.v2021_01_01.models.TagDetails] + :raises ~azure.core.exceptions.HttpResponseError: """ - api_version = kwargs.pop('api_version', "2021-01-01") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-01-01")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[_models.TagsListResult] - cls = kwargs.pop('cls', None) # type: ClsType["_models.TagsListResult"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) + def prepare_request(next_link=None): if not next_link: - + request = build_tags_list_request( subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.list.metadata['url'], + template_url=self.list.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore else: - - request = build_tags_list_request( - subscription_id=self._config.subscription_id, - template_url=next_link, - ) + # make call to next link with the client's api-version + _parsed_next_link = urlparse(next_link) + _next_request_params = case_insensitive_dict(parse_qs(_parsed_next_link.query)) + _next_request_params["api-version"] = self._config.api_version + request = HttpRequest("GET", urljoin(next_link, _parsed_next_link.path), params=_next_request_params) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore request.method = "GET" return request @@ -6970,10 +9153,8 @@ async def extract_data(pipeline_response): async def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) response = pipeline_response.http_response @@ -6983,82 +9164,139 @@ async def get_next(next_link=None): return pipeline_response + return AsyncItemPaged(get_next, extract_data) - return AsyncItemPaged( - get_next, extract_data - ) - list.metadata = {'url': "/subscriptions/{subscriptionId}/tagNames"} # type: ignore + list.metadata = {"url": "/subscriptions/{subscriptionId}/tagNames"} # type: ignore - @distributed_trace_async + @overload async def create_or_update_at_scope( - self, - scope: str, - parameters: "_models.TagsResource", - **kwargs: Any - ) -> "_models.TagsResource": + self, scope: str, parameters: _models.TagsResource, *, content_type: str = "application/json", **kwargs: Any + ) -> _models.TagsResource: """Creates or updates the entire set of tags on a resource or subscription. This operation allows adding or replacing the entire set of tags on the specified resource or subscription. The specified entity can have a maximum of 50 tags. - :param scope: The resource scope. + :param scope: The resource scope. Required. :type scope: str - :param parameters: + :param parameters: Required. :type parameters: ~azure.mgmt.resource.resources.v2021_01_01.models.TagsResource + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: TagsResource or the result of cls(response) + :rtype: ~azure.mgmt.resource.resources.v2021_01_01.models.TagsResource + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + async def create_or_update_at_scope( + self, scope: str, parameters: IO, *, content_type: str = "application/json", **kwargs: Any + ) -> _models.TagsResource: + """Creates or updates the entire set of tags on a resource or subscription. + + This operation allows adding or replacing the entire set of tags on the specified resource or + subscription. The specified entity can have a maximum of 50 tags. + + :param scope: The resource scope. Required. + :type scope: str + :param parameters: Required. + :type parameters: IO + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: TagsResource or the result of cls(response) + :rtype: ~azure.mgmt.resource.resources.v2021_01_01.models.TagsResource + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace_async + async def create_or_update_at_scope( + self, scope: str, parameters: Union[_models.TagsResource, IO], **kwargs: Any + ) -> _models.TagsResource: + """Creates or updates the entire set of tags on a resource or subscription. + + This operation allows adding or replacing the entire set of tags on the specified resource or + subscription. The specified entity can have a maximum of 50 tags. + + :param scope: The resource scope. Required. + :type scope: str + :param parameters: Is either a model type or a IO type. Required. + :type parameters: ~azure.mgmt.resource.resources.v2021_01_01.models.TagsResource or IO + :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. + Default value is None. + :paramtype content_type: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: TagsResource, or the result of cls(response) + :return: TagsResource or the result of cls(response) :rtype: ~azure.mgmt.resource.resources.v2021_01_01.models.TagsResource - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.TagsResource"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) - api_version = kwargs.pop('api_version', "2021-01-01") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - _json = self._serialize.body(parameters, 'TagsResource') + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-01-01")) # type: str + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.TagsResource] + + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(parameters, (IO, bytes)): + _content = parameters + else: + _json = self._serialize.body(parameters, "TagsResource") request = build_tags_create_or_update_at_scope_request( scope=scope, api_version=api_version, content_type=content_type, json=_json, - template_url=self.create_or_update_at_scope.metadata['url'], + content=_content, + template_url=self.create_or_update_at_scope.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) - deserialized = self._deserialize('TagsResource', pipeline_response) + deserialized = self._deserialize("TagsResource", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - create_or_update_at_scope.metadata = {'url': "/{scope}/providers/Microsoft.Resources/tags/default"} # type: ignore + create_or_update_at_scope.metadata = {"url": "/{scope}/providers/Microsoft.Resources/tags/default"} # type: ignore - - @distributed_trace_async + @overload async def update_at_scope( self, scope: str, - parameters: "_models.TagsPatchResource", + parameters: _models.TagsPatchResource, + *, + content_type: str = "application/json", **kwargs: Any - ) -> "_models.TagsResource": + ) -> _models.TagsResource: """Selectively updates the set of tags on a resource or subscription. This operation allows replacing, merging or selectively deleting tags on the specified resource @@ -7068,151 +9306,224 @@ async def update_at_scope( names. The 'delete' option allows selectively deleting tags based on given names or name/value pairs. - :param scope: The resource scope. + :param scope: The resource scope. Required. :type scope: str - :param parameters: + :param parameters: Required. :type parameters: ~azure.mgmt.resource.resources.v2021_01_01.models.TagsPatchResource + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: TagsResource or the result of cls(response) + :rtype: ~azure.mgmt.resource.resources.v2021_01_01.models.TagsResource + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + async def update_at_scope( + self, scope: str, parameters: IO, *, content_type: str = "application/json", **kwargs: Any + ) -> _models.TagsResource: + """Selectively updates the set of tags on a resource or subscription. + + This operation allows replacing, merging or selectively deleting tags on the specified resource + or subscription. The specified entity can have a maximum of 50 tags at the end of the + operation. The 'replace' option replaces the entire set of existing tags with a new set. The + 'merge' option allows adding tags with new names and updating the values of tags with existing + names. The 'delete' option allows selectively deleting tags based on given names or name/value + pairs. + + :param scope: The resource scope. Required. + :type scope: str + :param parameters: Required. + :type parameters: IO + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: TagsResource or the result of cls(response) + :rtype: ~azure.mgmt.resource.resources.v2021_01_01.models.TagsResource + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace_async + async def update_at_scope( + self, scope: str, parameters: Union[_models.TagsPatchResource, IO], **kwargs: Any + ) -> _models.TagsResource: + """Selectively updates the set of tags on a resource or subscription. + + This operation allows replacing, merging or selectively deleting tags on the specified resource + or subscription. The specified entity can have a maximum of 50 tags at the end of the + operation. The 'replace' option replaces the entire set of existing tags with a new set. The + 'merge' option allows adding tags with new names and updating the values of tags with existing + names. The 'delete' option allows selectively deleting tags based on given names or name/value + pairs. + + :param scope: The resource scope. Required. + :type scope: str + :param parameters: Is either a model type or a IO type. Required. + :type parameters: ~azure.mgmt.resource.resources.v2021_01_01.models.TagsPatchResource or IO + :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. + Default value is None. + :paramtype content_type: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: TagsResource, or the result of cls(response) + :return: TagsResource or the result of cls(response) :rtype: ~azure.mgmt.resource.resources.v2021_01_01.models.TagsResource - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.TagsResource"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) - api_version = kwargs.pop('api_version', "2021-01-01") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - _json = self._serialize.body(parameters, 'TagsPatchResource') + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-01-01")) # type: str + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.TagsResource] + + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(parameters, (IO, bytes)): + _content = parameters + else: + _json = self._serialize.body(parameters, "TagsPatchResource") request = build_tags_update_at_scope_request( scope=scope, api_version=api_version, content_type=content_type, json=_json, - template_url=self.update_at_scope.metadata['url'], + content=_content, + template_url=self.update_at_scope.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) - deserialized = self._deserialize('TagsResource', pipeline_response) + deserialized = self._deserialize("TagsResource", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - update_at_scope.metadata = {'url': "/{scope}/providers/Microsoft.Resources/tags/default"} # type: ignore - + update_at_scope.metadata = {"url": "/{scope}/providers/Microsoft.Resources/tags/default"} # type: ignore @distributed_trace_async - async def get_at_scope( - self, - scope: str, - **kwargs: Any - ) -> "_models.TagsResource": + async def get_at_scope(self, scope: str, **kwargs: Any) -> _models.TagsResource: """Gets the entire set of tags on a resource or subscription. Gets the entire set of tags on a resource or subscription. - :param scope: The resource scope. + :param scope: The resource scope. Required. :type scope: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: TagsResource, or the result of cls(response) + :return: TagsResource or the result of cls(response) :rtype: ~azure.mgmt.resource.resources.v2021_01_01.models.TagsResource - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.TagsResource"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + 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', "2021-01-01") # type: str + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-01-01")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[_models.TagsResource] - request = build_tags_get_at_scope_request( scope=scope, api_version=api_version, - template_url=self.get_at_scope.metadata['url'], + template_url=self.get_at_scope.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) - deserialized = self._deserialize('TagsResource', pipeline_response) + deserialized = self._deserialize("TagsResource", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - get_at_scope.metadata = {'url': "/{scope}/providers/Microsoft.Resources/tags/default"} # type: ignore - + get_at_scope.metadata = {"url": "/{scope}/providers/Microsoft.Resources/tags/default"} # type: ignore @distributed_trace_async async def delete_at_scope( # pylint: disable=inconsistent-return-statements - self, - scope: str, - **kwargs: Any + self, scope: str, **kwargs: Any ) -> None: """Deletes the entire set of tags on a resource or subscription. Deletes the entire set of tags on a resource or subscription. - :param scope: The resource scope. + :param scope: The resource scope. Required. :type scope: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: None, or the result of cls(response) + :return: None or the result of cls(response) :rtype: None - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType[None] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + 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', "2021-01-01") # type: str + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-01-01")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[None] - request = build_tags_delete_at_scope_request( scope=scope, api_version=api_version, - template_url=self.delete_at_scope.metadata['url'], + template_url=self.delete_at_scope.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200]: @@ -7222,143 +9533,145 @@ async def delete_at_scope( # pylint: disable=inconsistent-return-statements if cls: return cls(pipeline_response, None, {}) - delete_at_scope.metadata = {'url': "/{scope}/providers/Microsoft.Resources/tags/default"} # type: ignore + delete_at_scope.metadata = {"url": "/{scope}/providers/Microsoft.Resources/tags/default"} # type: ignore -class DeploymentOperationsOperations: - """DeploymentOperationsOperations async operations. - You should not instantiate this class directly. Instead, you should create a Client instance that - instantiates it for you and attaches it as an attribute. +class DeploymentOperationsOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. - :ivar models: Alias to model classes used in this operation group. - :type models: ~azure.mgmt.resource.resources.v2021_01_01.models - :param client: Client for service requests. - :param config: Configuration of service client. - :param serializer: An object model serializer. - :param deserializer: An object model deserializer. + Instead, you should access the following operations through + :class:`~azure.mgmt.resource.resources.v2021_01_01.aio.ResourceManagementClient`'s + :attr:`deployment_operations` attribute. """ models = _models - def __init__(self, client, config, serializer, deserializer) -> None: - self._client = client - self._serialize = serializer - self._deserialize = deserializer - self._config = config + def __init__(self, *args, **kwargs) -> None: + input_args = list(args) + self._client = input_args.pop(0) if input_args else kwargs.pop("client") + self._config = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") @distributed_trace_async async def get_at_scope( - self, - scope: str, - deployment_name: str, - operation_id: str, - **kwargs: Any - ) -> "_models.DeploymentOperation": + self, scope: str, deployment_name: str, operation_id: str, **kwargs: Any + ) -> _models.DeploymentOperation: """Gets a deployments operation. - :param scope: The resource scope. + :param scope: The resource scope. Required. :type scope: str - :param deployment_name: The name of the deployment. + :param deployment_name: The name of the deployment. Required. :type deployment_name: str - :param operation_id: The ID of the operation to get. + :param operation_id: The ID of the operation to get. Required. :type operation_id: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: DeploymentOperation, or the result of cls(response) + :return: DeploymentOperation or the result of cls(response) :rtype: ~azure.mgmt.resource.resources.v2021_01_01.models.DeploymentOperation - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.DeploymentOperation"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) - api_version = kwargs.pop('api_version', "2021-01-01") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-01-01")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[_models.DeploymentOperation] - request = build_deployment_operations_get_at_scope_request( scope=scope, deployment_name=deployment_name, operation_id=operation_id, api_version=api_version, - template_url=self.get_at_scope.metadata['url'], + template_url=self.get_at_scope.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) - deserialized = self._deserialize('DeploymentOperation', pipeline_response) + deserialized = self._deserialize("DeploymentOperation", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - get_at_scope.metadata = {'url': "/{scope}/providers/Microsoft.Resources/deployments/{deploymentName}/operations/{operationId}"} # type: ignore - + get_at_scope.metadata = {"url": "/{scope}/providers/Microsoft.Resources/deployments/{deploymentName}/operations/{operationId}"} # type: ignore @distributed_trace def list_at_scope( - self, - scope: str, - deployment_name: str, - top: Optional[int] = None, - **kwargs: Any - ) -> AsyncIterable["_models.DeploymentOperationsListResult"]: + self, scope: str, deployment_name: str, top: Optional[int] = None, **kwargs: Any + ) -> AsyncIterable["_models.DeploymentOperation"]: """Gets all deployments operations for a deployment. - :param scope: The resource scope. + :param scope: The resource scope. Required. :type scope: str - :param deployment_name: The name of the deployment. + :param deployment_name: The name of the deployment. Required. :type deployment_name: str :param top: The number of results to return. Default value is None. :type top: int :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either DeploymentOperationsListResult or the result of - cls(response) + :return: An iterator like instance of either DeploymentOperation or the result of cls(response) :rtype: - ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.resource.resources.v2021_01_01.models.DeploymentOperationsListResult] - :raises: ~azure.core.exceptions.HttpResponseError + ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.resource.resources.v2021_01_01.models.DeploymentOperation] + :raises ~azure.core.exceptions.HttpResponseError: """ - api_version = kwargs.pop('api_version', "2021-01-01") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-01-01")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[_models.DeploymentOperationsListResult] - cls = kwargs.pop('cls', None) # type: ClsType["_models.DeploymentOperationsListResult"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) + def prepare_request(next_link=None): if not next_link: - + request = build_deployment_operations_list_at_scope_request( scope=scope, deployment_name=deployment_name, - api_version=api_version, top=top, - template_url=self.list_at_scope.metadata['url'], + api_version=api_version, + template_url=self.list_at_scope.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore else: - - request = build_deployment_operations_list_at_scope_request( - scope=scope, - deployment_name=deployment_name, - template_url=next_link, - ) + # make call to next link with the client's api-version + _parsed_next_link = urlparse(next_link) + _next_request_params = case_insensitive_dict(parse_qs(_parsed_next_link.query)) + _next_request_params["api-version"] = self._config.api_version + request = HttpRequest("GET", urljoin(next_link, _parsed_next_link.path), params=_next_request_params) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore request.method = "GET" return request @@ -7372,10 +9685,8 @@ async def extract_data(pipeline_response): async def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) response = pipeline_response.http_response @@ -7385,116 +9696,121 @@ async def get_next(next_link=None): return pipeline_response + return AsyncItemPaged(get_next, extract_data) - return AsyncItemPaged( - get_next, extract_data - ) - list_at_scope.metadata = {'url': "/{scope}/providers/Microsoft.Resources/deployments/{deploymentName}/operations"} # type: ignore + list_at_scope.metadata = {"url": "/{scope}/providers/Microsoft.Resources/deployments/{deploymentName}/operations"} # type: ignore @distributed_trace_async async def get_at_tenant_scope( - self, - deployment_name: str, - operation_id: str, - **kwargs: Any - ) -> "_models.DeploymentOperation": + self, deployment_name: str, operation_id: str, **kwargs: Any + ) -> _models.DeploymentOperation: """Gets a deployments operation. - :param deployment_name: The name of the deployment. + :param deployment_name: The name of the deployment. Required. :type deployment_name: str - :param operation_id: The ID of the operation to get. + :param operation_id: The ID of the operation to get. Required. :type operation_id: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: DeploymentOperation, or the result of cls(response) + :return: DeploymentOperation or the result of cls(response) :rtype: ~azure.mgmt.resource.resources.v2021_01_01.models.DeploymentOperation - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.DeploymentOperation"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + 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', "2021-01-01") # type: str + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-01-01")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[_models.DeploymentOperation] - request = build_deployment_operations_get_at_tenant_scope_request( deployment_name=deployment_name, operation_id=operation_id, api_version=api_version, - template_url=self.get_at_tenant_scope.metadata['url'], + template_url=self.get_at_tenant_scope.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) - deserialized = self._deserialize('DeploymentOperation', pipeline_response) + deserialized = self._deserialize("DeploymentOperation", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - get_at_tenant_scope.metadata = {'url': "/providers/Microsoft.Resources/deployments/{deploymentName}/operations/{operationId}"} # type: ignore - + get_at_tenant_scope.metadata = {"url": "/providers/Microsoft.Resources/deployments/{deploymentName}/operations/{operationId}"} # type: ignore @distributed_trace def list_at_tenant_scope( - self, - deployment_name: str, - top: Optional[int] = None, - **kwargs: Any - ) -> AsyncIterable["_models.DeploymentOperationsListResult"]: + self, deployment_name: str, top: Optional[int] = None, **kwargs: Any + ) -> AsyncIterable["_models.DeploymentOperation"]: """Gets all deployments operations for a deployment. - :param deployment_name: The name of the deployment. + :param deployment_name: The name of the deployment. Required. :type deployment_name: str :param top: The number of results to return. Default value is None. :type top: int :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either DeploymentOperationsListResult or the result of - cls(response) + :return: An iterator like instance of either DeploymentOperation or the result of cls(response) :rtype: - ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.resource.resources.v2021_01_01.models.DeploymentOperationsListResult] - :raises: ~azure.core.exceptions.HttpResponseError + ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.resource.resources.v2021_01_01.models.DeploymentOperation] + :raises ~azure.core.exceptions.HttpResponseError: """ - api_version = kwargs.pop('api_version', "2021-01-01") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-01-01")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[_models.DeploymentOperationsListResult] - cls = kwargs.pop('cls', None) # type: ClsType["_models.DeploymentOperationsListResult"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) + def prepare_request(next_link=None): if not next_link: - + request = build_deployment_operations_list_at_tenant_scope_request( deployment_name=deployment_name, - api_version=api_version, top=top, - template_url=self.list_at_tenant_scope.metadata['url'], + api_version=api_version, + template_url=self.list_at_tenant_scope.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore else: - - request = build_deployment_operations_list_at_tenant_scope_request( - deployment_name=deployment_name, - template_url=next_link, - ) + # make call to next link with the client's api-version + _parsed_next_link = urlparse(next_link) + _next_request_params = case_insensitive_dict(parse_qs(_parsed_next_link.query)) + _next_request_params["api-version"] = self._config.api_version + request = HttpRequest("GET", urljoin(next_link, _parsed_next_link.path), params=_next_request_params) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore request.method = "GET" return request @@ -7508,10 +9824,8 @@ async def extract_data(pipeline_response): async def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) response = pipeline_response.http_response @@ -7521,125 +9835,127 @@ async def get_next(next_link=None): return pipeline_response + return AsyncItemPaged(get_next, extract_data) - return AsyncItemPaged( - get_next, extract_data - ) - list_at_tenant_scope.metadata = {'url': "/providers/Microsoft.Resources/deployments/{deploymentName}/operations"} # type: ignore + list_at_tenant_scope.metadata = {"url": "/providers/Microsoft.Resources/deployments/{deploymentName}/operations"} # type: ignore @distributed_trace_async async def get_at_management_group_scope( - self, - group_id: str, - deployment_name: str, - operation_id: str, - **kwargs: Any - ) -> "_models.DeploymentOperation": + self, group_id: str, deployment_name: str, operation_id: str, **kwargs: Any + ) -> _models.DeploymentOperation: """Gets a deployments operation. - :param group_id: The management group ID. + :param group_id: The management group ID. Required. :type group_id: str - :param deployment_name: The name of the deployment. + :param deployment_name: The name of the deployment. Required. :type deployment_name: str - :param operation_id: The ID of the operation to get. + :param operation_id: The ID of the operation to get. Required. :type operation_id: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: DeploymentOperation, or the result of cls(response) + :return: DeploymentOperation or the result of cls(response) :rtype: ~azure.mgmt.resource.resources.v2021_01_01.models.DeploymentOperation - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.DeploymentOperation"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + 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', "2021-01-01") # type: str + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-01-01")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[_models.DeploymentOperation] - request = build_deployment_operations_get_at_management_group_scope_request( group_id=group_id, deployment_name=deployment_name, operation_id=operation_id, api_version=api_version, - template_url=self.get_at_management_group_scope.metadata['url'], + template_url=self.get_at_management_group_scope.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) - deserialized = self._deserialize('DeploymentOperation', pipeline_response) + deserialized = self._deserialize("DeploymentOperation", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - get_at_management_group_scope.metadata = {'url': "/providers/Microsoft.Management/managementGroups/{groupId}/providers/Microsoft.Resources/deployments/{deploymentName}/operations/{operationId}"} # type: ignore - + get_at_management_group_scope.metadata = {"url": "/providers/Microsoft.Management/managementGroups/{groupId}/providers/Microsoft.Resources/deployments/{deploymentName}/operations/{operationId}"} # type: ignore @distributed_trace def list_at_management_group_scope( - self, - group_id: str, - deployment_name: str, - top: Optional[int] = None, - **kwargs: Any - ) -> AsyncIterable["_models.DeploymentOperationsListResult"]: + self, group_id: str, deployment_name: str, top: Optional[int] = None, **kwargs: Any + ) -> AsyncIterable["_models.DeploymentOperation"]: """Gets all deployments operations for a deployment. - :param group_id: The management group ID. + :param group_id: The management group ID. Required. :type group_id: str - :param deployment_name: The name of the deployment. + :param deployment_name: The name of the deployment. Required. :type deployment_name: str :param top: The number of results to return. Default value is None. :type top: int :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either DeploymentOperationsListResult or the result of - cls(response) + :return: An iterator like instance of either DeploymentOperation or the result of cls(response) :rtype: - ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.resource.resources.v2021_01_01.models.DeploymentOperationsListResult] - :raises: ~azure.core.exceptions.HttpResponseError + ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.resource.resources.v2021_01_01.models.DeploymentOperation] + :raises ~azure.core.exceptions.HttpResponseError: """ - api_version = kwargs.pop('api_version', "2021-01-01") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-01-01")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[_models.DeploymentOperationsListResult] - cls = kwargs.pop('cls', None) # type: ClsType["_models.DeploymentOperationsListResult"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) + def prepare_request(next_link=None): if not next_link: - + request = build_deployment_operations_list_at_management_group_scope_request( group_id=group_id, deployment_name=deployment_name, - api_version=api_version, top=top, - template_url=self.list_at_management_group_scope.metadata['url'], + api_version=api_version, + template_url=self.list_at_management_group_scope.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore else: - - request = build_deployment_operations_list_at_management_group_scope_request( - group_id=group_id, - deployment_name=deployment_name, - template_url=next_link, - ) + # make call to next link with the client's api-version + _parsed_next_link = urlparse(next_link) + _next_request_params = case_insensitive_dict(parse_qs(_parsed_next_link.query)) + _next_request_params["api-version"] = self._config.api_version + request = HttpRequest("GET", urljoin(next_link, _parsed_next_link.path), params=_next_request_params) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore request.method = "GET" return request @@ -7653,10 +9969,8 @@ async def extract_data(pipeline_response): async def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) response = pipeline_response.http_response @@ -7666,119 +9980,123 @@ async def get_next(next_link=None): return pipeline_response + return AsyncItemPaged(get_next, extract_data) - return AsyncItemPaged( - get_next, extract_data - ) - list_at_management_group_scope.metadata = {'url': "/providers/Microsoft.Management/managementGroups/{groupId}/providers/Microsoft.Resources/deployments/{deploymentName}/operations"} # type: ignore + list_at_management_group_scope.metadata = {"url": "/providers/Microsoft.Management/managementGroups/{groupId}/providers/Microsoft.Resources/deployments/{deploymentName}/operations"} # type: ignore @distributed_trace_async async def get_at_subscription_scope( - self, - deployment_name: str, - operation_id: str, - **kwargs: Any - ) -> "_models.DeploymentOperation": + self, deployment_name: str, operation_id: str, **kwargs: Any + ) -> _models.DeploymentOperation: """Gets a deployments operation. - :param deployment_name: The name of the deployment. + :param deployment_name: The name of the deployment. Required. :type deployment_name: str - :param operation_id: The ID of the operation to get. + :param operation_id: The ID of the operation to get. Required. :type operation_id: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: DeploymentOperation, or the result of cls(response) + :return: DeploymentOperation or the result of cls(response) :rtype: ~azure.mgmt.resource.resources.v2021_01_01.models.DeploymentOperation - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.DeploymentOperation"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) - api_version = kwargs.pop('api_version', "2021-01-01") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-01-01")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[_models.DeploymentOperation] - request = build_deployment_operations_get_at_subscription_scope_request( deployment_name=deployment_name, operation_id=operation_id, subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.get_at_subscription_scope.metadata['url'], + template_url=self.get_at_subscription_scope.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) - deserialized = self._deserialize('DeploymentOperation', pipeline_response) + deserialized = self._deserialize("DeploymentOperation", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - get_at_subscription_scope.metadata = {'url': "/subscriptions/{subscriptionId}/providers/Microsoft.Resources/deployments/{deploymentName}/operations/{operationId}"} # type: ignore - + get_at_subscription_scope.metadata = {"url": "/subscriptions/{subscriptionId}/providers/Microsoft.Resources/deployments/{deploymentName}/operations/{operationId}"} # type: ignore @distributed_trace def list_at_subscription_scope( - self, - deployment_name: str, - top: Optional[int] = None, - **kwargs: Any - ) -> AsyncIterable["_models.DeploymentOperationsListResult"]: + self, deployment_name: str, top: Optional[int] = None, **kwargs: Any + ) -> AsyncIterable["_models.DeploymentOperation"]: """Gets all deployments operations for a deployment. - :param deployment_name: The name of the deployment. + :param deployment_name: The name of the deployment. Required. :type deployment_name: str :param top: The number of results to return. Default value is None. :type top: int :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either DeploymentOperationsListResult or the result of - cls(response) + :return: An iterator like instance of either DeploymentOperation or the result of cls(response) :rtype: - ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.resource.resources.v2021_01_01.models.DeploymentOperationsListResult] - :raises: ~azure.core.exceptions.HttpResponseError + ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.resource.resources.v2021_01_01.models.DeploymentOperation] + :raises ~azure.core.exceptions.HttpResponseError: """ - api_version = kwargs.pop('api_version', "2021-01-01") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-01-01")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[_models.DeploymentOperationsListResult] - cls = kwargs.pop('cls', None) # type: ClsType["_models.DeploymentOperationsListResult"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) + def prepare_request(next_link=None): if not next_link: - + request = build_deployment_operations_list_at_subscription_scope_request( deployment_name=deployment_name, subscription_id=self._config.subscription_id, - api_version=api_version, top=top, - template_url=self.list_at_subscription_scope.metadata['url'], + api_version=api_version, + template_url=self.list_at_subscription_scope.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore else: - - request = build_deployment_operations_list_at_subscription_scope_request( - deployment_name=deployment_name, - subscription_id=self._config.subscription_id, - template_url=next_link, - ) + # make call to next link with the client's api-version + _parsed_next_link = urlparse(next_link) + _next_request_params = case_insensitive_dict(parse_qs(_parsed_next_link.query)) + _next_request_params["api-version"] = self._config.api_version + request = HttpRequest("GET", urljoin(next_link, _parsed_next_link.path), params=_next_request_params) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore request.method = "GET" return request @@ -7792,10 +10110,8 @@ async def extract_data(pipeline_response): async def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) response = pipeline_response.http_response @@ -7805,128 +10121,131 @@ async def get_next(next_link=None): return pipeline_response + return AsyncItemPaged(get_next, extract_data) - return AsyncItemPaged( - get_next, extract_data - ) - list_at_subscription_scope.metadata = {'url': "/subscriptions/{subscriptionId}/providers/Microsoft.Resources/deployments/{deploymentName}/operations"} # type: ignore + list_at_subscription_scope.metadata = {"url": "/subscriptions/{subscriptionId}/providers/Microsoft.Resources/deployments/{deploymentName}/operations"} # type: ignore @distributed_trace_async async def get( - self, - resource_group_name: str, - deployment_name: str, - operation_id: str, - **kwargs: Any - ) -> "_models.DeploymentOperation": + self, resource_group_name: str, deployment_name: str, operation_id: str, **kwargs: Any + ) -> _models.DeploymentOperation: """Gets a deployments operation. :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. :type resource_group_name: str - :param deployment_name: The name of the deployment. + :param deployment_name: The name of the deployment. Required. :type deployment_name: str - :param operation_id: The ID of the operation to get. + :param operation_id: The ID of the operation to get. Required. :type operation_id: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: DeploymentOperation, or the result of cls(response) + :return: DeploymentOperation or the result of cls(response) :rtype: ~azure.mgmt.resource.resources.v2021_01_01.models.DeploymentOperation - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.DeploymentOperation"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + 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', "2021-01-01") # type: str + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-01-01")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[_models.DeploymentOperation] - request = build_deployment_operations_get_request( resource_group_name=resource_group_name, deployment_name=deployment_name, operation_id=operation_id, subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.get.metadata['url'], + template_url=self.get.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) - deserialized = self._deserialize('DeploymentOperation', pipeline_response) + deserialized = self._deserialize("DeploymentOperation", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - get.metadata = {'url': "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/deployments/{deploymentName}/operations/{operationId}"} # type: ignore - + get.metadata = {"url": "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/deployments/{deploymentName}/operations/{operationId}"} # type: ignore @distributed_trace def list( - self, - resource_group_name: str, - deployment_name: str, - top: Optional[int] = None, - **kwargs: Any - ) -> AsyncIterable["_models.DeploymentOperationsListResult"]: + self, resource_group_name: str, deployment_name: str, top: Optional[int] = None, **kwargs: Any + ) -> AsyncIterable["_models.DeploymentOperation"]: """Gets all deployments operations for a deployment. :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. :type resource_group_name: str - :param deployment_name: The name of the deployment. + :param deployment_name: The name of the deployment. Required. :type deployment_name: str :param top: The number of results to return. Default value is None. :type top: int :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either DeploymentOperationsListResult or the result of - cls(response) + :return: An iterator like instance of either DeploymentOperation or the result of cls(response) :rtype: - ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.resource.resources.v2021_01_01.models.DeploymentOperationsListResult] - :raises: ~azure.core.exceptions.HttpResponseError + ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.resource.resources.v2021_01_01.models.DeploymentOperation] + :raises ~azure.core.exceptions.HttpResponseError: """ - api_version = kwargs.pop('api_version', "2021-01-01") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-01-01")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[_models.DeploymentOperationsListResult] - cls = kwargs.pop('cls', None) # type: ClsType["_models.DeploymentOperationsListResult"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) + def prepare_request(next_link=None): if not next_link: - + request = build_deployment_operations_list_request( resource_group_name=resource_group_name, deployment_name=deployment_name, subscription_id=self._config.subscription_id, - api_version=api_version, top=top, - template_url=self.list.metadata['url'], + 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.url = self._client.format_url(request.url) # type: ignore else: - - request = build_deployment_operations_list_request( - resource_group_name=resource_group_name, - deployment_name=deployment_name, - subscription_id=self._config.subscription_id, - template_url=next_link, - ) + # make call to next link with the client's api-version + _parsed_next_link = urlparse(next_link) + _next_request_params = case_insensitive_dict(parse_qs(_parsed_next_link.query)) + _next_request_params["api-version"] = self._config.api_version + request = HttpRequest("GET", urljoin(next_link, _parsed_next_link.path), params=_next_request_params) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore request.method = "GET" return request @@ -7940,10 +10259,8 @@ async def extract_data(pipeline_response): async def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) response = pipeline_response.http_response @@ -7953,8 +10270,6 @@ async def get_next(next_link=None): return pipeline_response + return AsyncItemPaged(get_next, extract_data) - return AsyncItemPaged( - get_next, extract_data - ) - list.metadata = {'url': "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/deployments/{deploymentName}/operations"} # type: ignore + list.metadata = {"url": "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/deployments/{deploymentName}/operations"} # type: ignore diff --git a/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/resources/v2021_01_01/aio/operations/_patch.py b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/resources/v2021_01_01/aio/operations/_patch.py new file mode 100644 index 0000000000000..f7dd32510333d --- /dev/null +++ b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/resources/v2021_01_01/aio/operations/_patch.py @@ -0,0 +1,20 @@ +# ------------------------------------ +# Copyright (c) Microsoft Corporation. +# Licensed under the MIT License. +# ------------------------------------ +"""Customize generated code here. + +Follow our quickstart for examples: https://aka.ms/azsdk/python/dpcodegen/python/customize +""" +from typing import List + +__all__: List[str] = [] # Add all objects you want publicly available to users at this package level + + +def patch_sdk(): + """Do not remove from this file. + + `patch_sdk` is a last resort escape hatch that allows you to do customizations + you can't accomplish using the techniques described in + https://aka.ms/azsdk/python/dpcodegen/python/customize + """ diff --git a/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/resources/v2021_01_01/models/__init__.py b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/resources/v2021_01_01/models/__init__.py index 9a1b6f864dfbe..a81f7db710fc1 100644 --- a/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/resources/v2021_01_01/models/__init__.py +++ b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/resources/v2021_01_01/models/__init__.py @@ -82,114 +82,116 @@ from ._models_py3 import WhatIfPropertyChange from ._models_py3 import ZoneMapping - -from ._resource_management_client_enums import ( - AliasPathAttributes, - AliasPathTokenType, - AliasPatternType, - AliasType, - ChangeType, - DeploymentMode, - ExpressionEvaluationOptionsScopeType, - ExtendedLocationType, - OnErrorDeploymentType, - PropertyChangeType, - ProvisioningOperation, - ProvisioningState, - ResourceIdentityType, - TagsPatchOperation, - WhatIfResultFormat, -) +from ._resource_management_client_enums import AliasPathAttributes +from ._resource_management_client_enums import AliasPathTokenType +from ._resource_management_client_enums import AliasPatternType +from ._resource_management_client_enums import AliasType +from ._resource_management_client_enums import ChangeType +from ._resource_management_client_enums import DeploymentMode +from ._resource_management_client_enums import ExpressionEvaluationOptionsScopeType +from ._resource_management_client_enums import ExtendedLocationType +from ._resource_management_client_enums import OnErrorDeploymentType +from ._resource_management_client_enums import PropertyChangeType +from ._resource_management_client_enums import ProvisioningOperation +from ._resource_management_client_enums import ProvisioningState +from ._resource_management_client_enums import ResourceIdentityType +from ._resource_management_client_enums import TagsPatchOperation +from ._resource_management_client_enums import WhatIfResultFormat +from ._patch import __all__ as _patch_all +from ._patch import * # type: ignore # pylint: disable=unused-wildcard-import +from ._patch import patch_sdk as _patch_sdk __all__ = [ - 'Alias', - 'AliasPath', - 'AliasPathMetadata', - 'AliasPattern', - 'ApiProfile', - 'BasicDependency', - 'DebugSetting', - 'Dependency', - 'Deployment', - 'DeploymentExportResult', - 'DeploymentExtended', - 'DeploymentExtendedFilter', - 'DeploymentListResult', - 'DeploymentOperation', - 'DeploymentOperationProperties', - 'DeploymentOperationsListResult', - 'DeploymentProperties', - 'DeploymentPropertiesExtended', - 'DeploymentValidateResult', - 'DeploymentWhatIf', - 'DeploymentWhatIfProperties', - 'DeploymentWhatIfSettings', - 'ErrorAdditionalInfo', - 'ErrorResponse', - 'ExportTemplateRequest', - 'ExpressionEvaluationOptions', - 'ExtendedLocation', - 'GenericResource', - 'GenericResourceExpanded', - 'GenericResourceFilter', - 'HttpMessage', - 'Identity', - 'IdentityUserAssignedIdentitiesValue', - 'OnErrorDeployment', - 'OnErrorDeploymentExtended', - 'Operation', - 'OperationDisplay', - 'OperationListResult', - 'ParametersLink', - 'Plan', - 'Provider', - 'ProviderExtendedLocation', - 'ProviderListResult', - 'ProviderResourceType', - 'ProviderResourceTypeListResult', - 'Resource', - 'ResourceGroup', - 'ResourceGroupExportResult', - 'ResourceGroupFilter', - 'ResourceGroupListResult', - 'ResourceGroupPatchable', - 'ResourceGroupProperties', - 'ResourceListResult', - 'ResourceProviderOperationDisplayProperties', - 'ResourceReference', - 'ResourcesMoveInfo', - 'ScopedDeployment', - 'ScopedDeploymentWhatIf', - 'Sku', - 'StatusMessage', - 'SubResource', - 'TagCount', - 'TagDetails', - 'TagValue', - 'Tags', - 'TagsListResult', - 'TagsPatchResource', - 'TagsResource', - 'TargetResource', - 'TemplateHashResult', - 'TemplateLink', - 'WhatIfChange', - 'WhatIfOperationResult', - 'WhatIfPropertyChange', - 'ZoneMapping', - 'AliasPathAttributes', - 'AliasPathTokenType', - 'AliasPatternType', - 'AliasType', - 'ChangeType', - 'DeploymentMode', - 'ExpressionEvaluationOptionsScopeType', - 'ExtendedLocationType', - 'OnErrorDeploymentType', - 'PropertyChangeType', - 'ProvisioningOperation', - 'ProvisioningState', - 'ResourceIdentityType', - 'TagsPatchOperation', - 'WhatIfResultFormat', + "Alias", + "AliasPath", + "AliasPathMetadata", + "AliasPattern", + "ApiProfile", + "BasicDependency", + "DebugSetting", + "Dependency", + "Deployment", + "DeploymentExportResult", + "DeploymentExtended", + "DeploymentExtendedFilter", + "DeploymentListResult", + "DeploymentOperation", + "DeploymentOperationProperties", + "DeploymentOperationsListResult", + "DeploymentProperties", + "DeploymentPropertiesExtended", + "DeploymentValidateResult", + "DeploymentWhatIf", + "DeploymentWhatIfProperties", + "DeploymentWhatIfSettings", + "ErrorAdditionalInfo", + "ErrorResponse", + "ExportTemplateRequest", + "ExpressionEvaluationOptions", + "ExtendedLocation", + "GenericResource", + "GenericResourceExpanded", + "GenericResourceFilter", + "HttpMessage", + "Identity", + "IdentityUserAssignedIdentitiesValue", + "OnErrorDeployment", + "OnErrorDeploymentExtended", + "Operation", + "OperationDisplay", + "OperationListResult", + "ParametersLink", + "Plan", + "Provider", + "ProviderExtendedLocation", + "ProviderListResult", + "ProviderResourceType", + "ProviderResourceTypeListResult", + "Resource", + "ResourceGroup", + "ResourceGroupExportResult", + "ResourceGroupFilter", + "ResourceGroupListResult", + "ResourceGroupPatchable", + "ResourceGroupProperties", + "ResourceListResult", + "ResourceProviderOperationDisplayProperties", + "ResourceReference", + "ResourcesMoveInfo", + "ScopedDeployment", + "ScopedDeploymentWhatIf", + "Sku", + "StatusMessage", + "SubResource", + "TagCount", + "TagDetails", + "TagValue", + "Tags", + "TagsListResult", + "TagsPatchResource", + "TagsResource", + "TargetResource", + "TemplateHashResult", + "TemplateLink", + "WhatIfChange", + "WhatIfOperationResult", + "WhatIfPropertyChange", + "ZoneMapping", + "AliasPathAttributes", + "AliasPathTokenType", + "AliasPatternType", + "AliasType", + "ChangeType", + "DeploymentMode", + "ExpressionEvaluationOptionsScopeType", + "ExtendedLocationType", + "OnErrorDeploymentType", + "PropertyChangeType", + "ProvisioningOperation", + "ProvisioningState", + "ResourceIdentityType", + "TagsPatchOperation", + "WhatIfResultFormat", ] +__all__.extend([p for p in _patch_all if p not in __all__]) +_patch_sdk() diff --git a/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/resources/v2021_01_01/models/_models_py3.py b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/resources/v2021_01_01/models/_models_py3.py index a64a665be8a9c..57b5e9962dcd4 100644 --- a/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/resources/v2021_01_01/models/_models_py3.py +++ b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/resources/v2021_01_01/models/_models_py3.py @@ -1,4 +1,5 @@ # coding=utf-8 +# pylint: disable=too-many-lines # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. # Licensed under the MIT License. See License.txt in the project root for license information. @@ -6,14 +7,22 @@ # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -from typing import Any, Dict, List, Optional, Union +import sys +from typing import Any, Dict, List, Optional, TYPE_CHECKING, Union -import msrest.serialization +from ... import _serialization -from ._resource_management_client_enums import * +if TYPE_CHECKING: + # pylint: disable=unused-import,ungrouped-imports + from .. import models as _models +if sys.version_info >= (3, 9): + from collections.abc import MutableMapping +else: + from typing import MutableMapping # type: ignore # pylint: disable=ungrouped-imports +JSON = MutableMapping[str, Any] # pylint: disable=unsubscriptable-object -class Alias(msrest.serialization.Model): +class Alias(_serialization.Model): """The alias type. Variables are only populated by the server, and will be ignored when sending a request. @@ -22,8 +31,7 @@ class Alias(msrest.serialization.Model): :vartype name: str :ivar paths: The paths for an alias. :vartype paths: list[~azure.mgmt.resource.resources.v2021_01_01.models.AliasPath] - :ivar type: The type of the alias. Possible values include: "NotSpecified", "PlainText", - "Mask". + :ivar type: The type of the alias. Known values are: "NotSpecified", "PlainText", and "Mask". :vartype type: str or ~azure.mgmt.resource.resources.v2021_01_01.models.AliasType :ivar default_path: The default path for an alias. :vartype default_path: str @@ -35,26 +43,26 @@ class Alias(msrest.serialization.Model): """ _validation = { - 'default_metadata': {'readonly': True}, + "default_metadata": {"readonly": True}, } _attribute_map = { - 'name': {'key': 'name', 'type': 'str'}, - 'paths': {'key': 'paths', 'type': '[AliasPath]'}, - 'type': {'key': 'type', 'type': 'str'}, - 'default_path': {'key': 'defaultPath', 'type': 'str'}, - 'default_pattern': {'key': 'defaultPattern', 'type': 'AliasPattern'}, - 'default_metadata': {'key': 'defaultMetadata', 'type': 'AliasPathMetadata'}, + "name": {"key": "name", "type": "str"}, + "paths": {"key": "paths", "type": "[AliasPath]"}, + "type": {"key": "type", "type": "str"}, + "default_path": {"key": "defaultPath", "type": "str"}, + "default_pattern": {"key": "defaultPattern", "type": "AliasPattern"}, + "default_metadata": {"key": "defaultMetadata", "type": "AliasPathMetadata"}, } def __init__( self, *, name: Optional[str] = None, - paths: Optional[List["AliasPath"]] = None, - type: Optional[Union[str, "AliasType"]] = None, + paths: Optional[List["_models.AliasPath"]] = None, + type: Optional[Union[str, "_models.AliasType"]] = None, default_path: Optional[str] = None, - default_pattern: Optional["AliasPattern"] = None, + default_pattern: Optional["_models.AliasPattern"] = None, **kwargs ): """ @@ -62,7 +70,7 @@ def __init__( :paramtype name: str :keyword paths: The paths for an alias. :paramtype paths: list[~azure.mgmt.resource.resources.v2021_01_01.models.AliasPath] - :keyword type: The type of the alias. Possible values include: "NotSpecified", "PlainText", + :keyword type: The type of the alias. Known values are: "NotSpecified", "PlainText", and "Mask". :paramtype type: str or ~azure.mgmt.resource.resources.v2021_01_01.models.AliasType :keyword default_path: The default path for an alias. @@ -70,7 +78,7 @@ def __init__( :keyword default_pattern: The default pattern for an alias. :paramtype default_pattern: ~azure.mgmt.resource.resources.v2021_01_01.models.AliasPattern """ - super(Alias, self).__init__(**kwargs) + super().__init__(**kwargs) self.name = name self.paths = paths self.type = type @@ -79,7 +87,7 @@ def __init__( self.default_metadata = None -class AliasPath(msrest.serialization.Model): +class AliasPath(_serialization.Model): """The type of the paths for alias. Variables are only populated by the server, and will be ignored when sending a request. @@ -96,14 +104,14 @@ class AliasPath(msrest.serialization.Model): """ _validation = { - 'metadata': {'readonly': True}, + "metadata": {"readonly": True}, } _attribute_map = { - 'path': {'key': 'path', 'type': 'str'}, - 'api_versions': {'key': 'apiVersions', 'type': '[str]'}, - 'pattern': {'key': 'pattern', 'type': 'AliasPattern'}, - 'metadata': {'key': 'metadata', 'type': 'AliasPathMetadata'}, + "path": {"key": "path", "type": "str"}, + "api_versions": {"key": "apiVersions", "type": "[str]"}, + "pattern": {"key": "pattern", "type": "AliasPattern"}, + "metadata": {"key": "metadata", "type": "AliasPathMetadata"}, } def __init__( @@ -111,7 +119,7 @@ def __init__( *, path: Optional[str] = None, api_versions: Optional[List[str]] = None, - pattern: Optional["AliasPattern"] = None, + pattern: Optional["_models.AliasPattern"] = None, **kwargs ): """ @@ -122,63 +130,59 @@ def __init__( :keyword pattern: The pattern for an alias path. :paramtype pattern: ~azure.mgmt.resource.resources.v2021_01_01.models.AliasPattern """ - super(AliasPath, self).__init__(**kwargs) + super().__init__(**kwargs) self.path = path self.api_versions = api_versions self.pattern = pattern self.metadata = None -class AliasPathMetadata(msrest.serialization.Model): +class AliasPathMetadata(_serialization.Model): """AliasPathMetadata. Variables are only populated by the server, and will be ignored when sending a request. - :ivar type: The type of the token that the alias path is referring to. Possible values include: - "NotSpecified", "Any", "String", "Object", "Array", "Integer", "Number", "Boolean". + :ivar type: The type of the token that the alias path is referring to. Known values are: + "NotSpecified", "Any", "String", "Object", "Array", "Integer", "Number", and "Boolean". :vartype type: str or ~azure.mgmt.resource.resources.v2021_01_01.models.AliasPathTokenType - :ivar attributes: The attributes of the token that the alias path is referring to. Possible - values include: "None", "Modifiable". + :ivar attributes: The attributes of the token that the alias path is referring to. Known values + are: "None" and "Modifiable". :vartype attributes: str or ~azure.mgmt.resource.resources.v2021_01_01.models.AliasPathAttributes """ _validation = { - 'type': {'readonly': True}, - 'attributes': {'readonly': True}, + "type": {"readonly": True}, + "attributes": {"readonly": True}, } _attribute_map = { - 'type': {'key': 'type', 'type': 'str'}, - 'attributes': {'key': 'attributes', 'type': 'str'}, + "type": {"key": "type", "type": "str"}, + "attributes": {"key": "attributes", "type": "str"}, } - def __init__( - self, - **kwargs - ): - """ - """ - super(AliasPathMetadata, self).__init__(**kwargs) + def __init__(self, **kwargs): + """ """ + super().__init__(**kwargs) self.type = None self.attributes = None -class AliasPattern(msrest.serialization.Model): +class AliasPattern(_serialization.Model): """The type of the pattern for an alias path. :ivar phrase: The alias pattern phrase. :vartype phrase: str :ivar variable: The alias pattern variable. :vartype variable: str - :ivar type: The type of alias pattern. Possible values include: "NotSpecified", "Extract". + :ivar type: The type of alias pattern. Known values are: "NotSpecified" and "Extract". :vartype type: str or ~azure.mgmt.resource.resources.v2021_01_01.models.AliasPatternType """ _attribute_map = { - 'phrase': {'key': 'phrase', 'type': 'str'}, - 'variable': {'key': 'variable', 'type': 'str'}, - 'type': {'key': 'type', 'type': 'str'}, + "phrase": {"key": "phrase", "type": "str"}, + "variable": {"key": "variable", "type": "str"}, + "type": {"key": "type", "type": "str"}, } def __init__( @@ -186,7 +190,7 @@ def __init__( *, phrase: Optional[str] = None, variable: Optional[str] = None, - type: Optional[Union[str, "AliasPatternType"]] = None, + type: Optional[Union[str, "_models.AliasPatternType"]] = None, **kwargs ): """ @@ -194,16 +198,16 @@ def __init__( :paramtype phrase: str :keyword variable: The alias pattern variable. :paramtype variable: str - :keyword type: The type of alias pattern. Possible values include: "NotSpecified", "Extract". + :keyword type: The type of alias pattern. Known values are: "NotSpecified" and "Extract". :paramtype type: str or ~azure.mgmt.resource.resources.v2021_01_01.models.AliasPatternType """ - super(AliasPattern, self).__init__(**kwargs) + super().__init__(**kwargs) self.phrase = phrase self.variable = variable self.type = type -class ApiProfile(msrest.serialization.Model): +class ApiProfile(_serialization.Model): """ApiProfile. Variables are only populated by the server, and will be ignored when sending a request. @@ -215,27 +219,23 @@ class ApiProfile(msrest.serialization.Model): """ _validation = { - 'profile_version': {'readonly': True}, - 'api_version': {'readonly': True}, + "profile_version": {"readonly": True}, + "api_version": {"readonly": True}, } _attribute_map = { - 'profile_version': {'key': 'profileVersion', 'type': 'str'}, - 'api_version': {'key': 'apiVersion', 'type': 'str'}, + "profile_version": {"key": "profileVersion", "type": "str"}, + "api_version": {"key": "apiVersion", "type": "str"}, } - def __init__( - self, - **kwargs - ): - """ - """ - super(ApiProfile, self).__init__(**kwargs) + def __init__(self, **kwargs): + """ """ + super().__init__(**kwargs) self.profile_version = None self.api_version = None -class BasicDependency(msrest.serialization.Model): +class BasicDependency(_serialization.Model): """Deployment dependency information. :ivar id: The ID of the dependency. @@ -247,15 +247,15 @@ class BasicDependency(msrest.serialization.Model): """ _attribute_map = { - 'id': {'key': 'id', 'type': 'str'}, - 'resource_type': {'key': 'resourceType', 'type': 'str'}, - 'resource_name': {'key': 'resourceName', 'type': 'str'}, + "id": {"key": "id", "type": "str"}, + "resource_type": {"key": "resourceType", "type": "str"}, + "resource_name": {"key": "resourceName", "type": "str"}, } def __init__( self, *, - id: Optional[str] = None, + id: Optional[str] = None, # pylint: disable=redefined-builtin resource_type: Optional[str] = None, resource_name: Optional[str] = None, **kwargs @@ -268,13 +268,13 @@ def __init__( :keyword resource_name: The dependency resource name. :paramtype resource_name: str """ - super(BasicDependency, self).__init__(**kwargs) + super().__init__(**kwargs) self.id = id self.resource_type = resource_type self.resource_name = resource_name -class DebugSetting(msrest.serialization.Model): +class DebugSetting(_serialization.Model): """The debug setting. :ivar detail_level: Specifies the type of information to log for debugging. The permitted @@ -287,15 +287,10 @@ class DebugSetting(msrest.serialization.Model): """ _attribute_map = { - 'detail_level': {'key': 'detailLevel', 'type': 'str'}, + "detail_level": {"key": "detailLevel", "type": "str"}, } - def __init__( - self, - *, - detail_level: Optional[str] = None, - **kwargs - ): + def __init__(self, *, detail_level: Optional[str] = None, **kwargs): """ :keyword detail_level: Specifies the type of information to log for debugging. The permitted values are none, requestContent, responseContent, or both requestContent and responseContent @@ -305,11 +300,11 @@ def __init__( deployment operations. :paramtype detail_level: str """ - super(DebugSetting, self).__init__(**kwargs) + super().__init__(**kwargs) self.detail_level = detail_level -class Dependency(msrest.serialization.Model): +class Dependency(_serialization.Model): """Deployment dependency information. :ivar depends_on: The list of dependencies. @@ -323,17 +318,17 @@ class Dependency(msrest.serialization.Model): """ _attribute_map = { - 'depends_on': {'key': 'dependsOn', 'type': '[BasicDependency]'}, - 'id': {'key': 'id', 'type': 'str'}, - 'resource_type': {'key': 'resourceType', 'type': 'str'}, - 'resource_name': {'key': 'resourceName', 'type': 'str'}, + "depends_on": {"key": "dependsOn", "type": "[BasicDependency]"}, + "id": {"key": "id", "type": "str"}, + "resource_type": {"key": "resourceType", "type": "str"}, + "resource_name": {"key": "resourceName", "type": "str"}, } def __init__( self, *, - depends_on: Optional[List["BasicDependency"]] = None, - id: Optional[str] = None, + depends_on: Optional[List["_models.BasicDependency"]] = None, + id: Optional[str] = None, # pylint: disable=redefined-builtin resource_type: Optional[str] = None, resource_name: Optional[str] = None, **kwargs @@ -348,40 +343,40 @@ def __init__( :keyword resource_name: The dependency resource name. :paramtype resource_name: str """ - super(Dependency, self).__init__(**kwargs) + super().__init__(**kwargs) self.depends_on = depends_on self.id = id self.resource_type = resource_type self.resource_name = resource_name -class Deployment(msrest.serialization.Model): +class Deployment(_serialization.Model): """Deployment operation parameters. All required parameters must be populated in order to send to Azure. :ivar location: The location to store the deployment data. :vartype location: str - :ivar properties: Required. The deployment properties. + :ivar properties: The deployment properties. Required. :vartype properties: ~azure.mgmt.resource.resources.v2021_01_01.models.DeploymentProperties - :ivar tags: A set of tags. Deployment tags. + :ivar tags: Deployment tags. :vartype tags: dict[str, str] """ _validation = { - 'properties': {'required': True}, + "properties": {"required": True}, } _attribute_map = { - 'location': {'key': 'location', 'type': 'str'}, - 'properties': {'key': 'properties', 'type': 'DeploymentProperties'}, - 'tags': {'key': 'tags', 'type': '{str}'}, + "location": {"key": "location", "type": "str"}, + "properties": {"key": "properties", "type": "DeploymentProperties"}, + "tags": {"key": "tags", "type": "{str}"}, } def __init__( self, *, - properties: "DeploymentProperties", + properties: "_models.DeploymentProperties", location: Optional[str] = None, tags: Optional[Dict[str, str]] = None, **kwargs @@ -389,43 +384,38 @@ def __init__( """ :keyword location: The location to store the deployment data. :paramtype location: str - :keyword properties: Required. The deployment properties. + :keyword properties: The deployment properties. Required. :paramtype properties: ~azure.mgmt.resource.resources.v2021_01_01.models.DeploymentProperties - :keyword tags: A set of tags. Deployment tags. + :keyword tags: Deployment tags. :paramtype tags: dict[str, str] """ - super(Deployment, self).__init__(**kwargs) + super().__init__(**kwargs) self.location = location self.properties = properties self.tags = tags -class DeploymentExportResult(msrest.serialization.Model): +class DeploymentExportResult(_serialization.Model): """The deployment export result. :ivar template: The template content. - :vartype template: any + :vartype template: JSON """ _attribute_map = { - 'template': {'key': 'template', 'type': 'object'}, + "template": {"key": "template", "type": "object"}, } - def __init__( - self, - *, - template: Optional[Any] = None, - **kwargs - ): + def __init__(self, *, template: Optional[JSON] = None, **kwargs): """ :keyword template: The template content. - :paramtype template: any + :paramtype template: JSON """ - super(DeploymentExportResult, self).__init__(**kwargs) + super().__init__(**kwargs) self.template = template -class DeploymentExtended(msrest.serialization.Model): +class DeploymentExtended(_serialization.Model): """Deployment information. Variables are only populated by the server, and will be ignored when sending a request. @@ -441,30 +431,30 @@ class DeploymentExtended(msrest.serialization.Model): :ivar properties: Deployment properties. :vartype properties: ~azure.mgmt.resource.resources.v2021_01_01.models.DeploymentPropertiesExtended - :ivar tags: A set of tags. Deployment tags. + :ivar tags: Deployment tags. :vartype tags: dict[str, str] """ _validation = { - 'id': {'readonly': True}, - 'name': {'readonly': True}, - 'type': {'readonly': True}, + "id": {"readonly": True}, + "name": {"readonly": True}, + "type": {"readonly": True}, } _attribute_map = { - 'id': {'key': 'id', 'type': 'str'}, - 'name': {'key': 'name', 'type': 'str'}, - 'type': {'key': 'type', 'type': 'str'}, - 'location': {'key': 'location', 'type': 'str'}, - 'properties': {'key': 'properties', 'type': 'DeploymentPropertiesExtended'}, - 'tags': {'key': 'tags', 'type': '{str}'}, + "id": {"key": "id", "type": "str"}, + "name": {"key": "name", "type": "str"}, + "type": {"key": "type", "type": "str"}, + "location": {"key": "location", "type": "str"}, + "properties": {"key": "properties", "type": "DeploymentPropertiesExtended"}, + "tags": {"key": "tags", "type": "{str}"}, } def __init__( self, *, location: Optional[str] = None, - properties: Optional["DeploymentPropertiesExtended"] = None, + properties: Optional["_models.DeploymentPropertiesExtended"] = None, tags: Optional[Dict[str, str]] = None, **kwargs ): @@ -474,10 +464,10 @@ def __init__( :keyword properties: Deployment properties. :paramtype properties: ~azure.mgmt.resource.resources.v2021_01_01.models.DeploymentPropertiesExtended - :keyword tags: A set of tags. Deployment tags. + :keyword tags: Deployment tags. :paramtype tags: dict[str, str] """ - super(DeploymentExtended, self).__init__(**kwargs) + super().__init__(**kwargs) self.id = None self.name = None self.type = None @@ -486,7 +476,7 @@ def __init__( self.tags = tags -class DeploymentExtendedFilter(msrest.serialization.Model): +class DeploymentExtendedFilter(_serialization.Model): """Deployment filter. :ivar provisioning_state: The provisioning state. @@ -494,24 +484,19 @@ class DeploymentExtendedFilter(msrest.serialization.Model): """ _attribute_map = { - 'provisioning_state': {'key': 'provisioningState', 'type': 'str'}, + "provisioning_state": {"key": "provisioningState", "type": "str"}, } - def __init__( - self, - *, - provisioning_state: Optional[str] = None, - **kwargs - ): + def __init__(self, *, provisioning_state: Optional[str] = None, **kwargs): """ :keyword provisioning_state: The provisioning state. :paramtype provisioning_state: str """ - super(DeploymentExtendedFilter, self).__init__(**kwargs) + super().__init__(**kwargs) self.provisioning_state = provisioning_state -class DeploymentListResult(msrest.serialization.Model): +class DeploymentListResult(_serialization.Model): """List of deployments. Variables are only populated by the server, and will be ignored when sending a request. @@ -523,30 +508,25 @@ class DeploymentListResult(msrest.serialization.Model): """ _validation = { - 'next_link': {'readonly': True}, + "next_link": {"readonly": True}, } _attribute_map = { - 'value': {'key': 'value', 'type': '[DeploymentExtended]'}, - 'next_link': {'key': 'nextLink', 'type': 'str'}, + "value": {"key": "value", "type": "[DeploymentExtended]"}, + "next_link": {"key": "nextLink", "type": "str"}, } - def __init__( - self, - *, - value: Optional[List["DeploymentExtended"]] = None, - **kwargs - ): + def __init__(self, *, value: Optional[List["_models.DeploymentExtended"]] = None, **kwargs): """ :keyword value: An array of deployments. :paramtype value: list[~azure.mgmt.resource.resources.v2021_01_01.models.DeploymentExtended] """ - super(DeploymentListResult, self).__init__(**kwargs) + super().__init__(**kwargs) self.value = value self.next_link = None -class DeploymentOperation(msrest.serialization.Model): +class DeploymentOperation(_serialization.Model): """Deployment operation information. Variables are only populated by the server, and will be ignored when sending a request. @@ -561,41 +541,36 @@ class DeploymentOperation(msrest.serialization.Model): """ _validation = { - 'id': {'readonly': True}, - 'operation_id': {'readonly': True}, + "id": {"readonly": True}, + "operation_id": {"readonly": True}, } _attribute_map = { - 'id': {'key': 'id', 'type': 'str'}, - 'operation_id': {'key': 'operationId', 'type': 'str'}, - 'properties': {'key': 'properties', 'type': 'DeploymentOperationProperties'}, + "id": {"key": "id", "type": "str"}, + "operation_id": {"key": "operationId", "type": "str"}, + "properties": {"key": "properties", "type": "DeploymentOperationProperties"}, } - def __init__( - self, - *, - properties: Optional["DeploymentOperationProperties"] = None, - **kwargs - ): + def __init__(self, *, properties: Optional["_models.DeploymentOperationProperties"] = None, **kwargs): """ :keyword properties: Deployment properties. :paramtype properties: ~azure.mgmt.resource.resources.v2021_01_01.models.DeploymentOperationProperties """ - super(DeploymentOperation, self).__init__(**kwargs) + super().__init__(**kwargs) self.id = None self.operation_id = None self.properties = properties -class DeploymentOperationProperties(msrest.serialization.Model): +class DeploymentOperationProperties(_serialization.Model): """Deployment operation properties. Variables are only populated by the server, and will be ignored when sending a request. - :ivar provisioning_operation: The name of the current provisioning operation. Possible values - include: "NotSpecified", "Create", "Delete", "Waiting", "AzureAsyncOperationWaiting", - "ResourceCacheWaiting", "Action", "Read", "EvaluateDeploymentOutput", "DeploymentCleanup". + :ivar provisioning_operation: The name of the current provisioning operation. Known values are: + "NotSpecified", "Create", "Delete", "Waiting", "AzureAsyncOperationWaiting", + "ResourceCacheWaiting", "Action", "Read", "EvaluateDeploymentOutput", and "DeploymentCleanup". :vartype provisioning_operation: str or ~azure.mgmt.resource.resources.v2021_01_01.models.ProvisioningOperation :ivar provisioning_state: The state of the provisioning. @@ -621,38 +596,34 @@ class DeploymentOperationProperties(msrest.serialization.Model): """ _validation = { - 'provisioning_operation': {'readonly': True}, - 'provisioning_state': {'readonly': True}, - 'timestamp': {'readonly': True}, - 'duration': {'readonly': True}, - 'service_request_id': {'readonly': True}, - 'status_code': {'readonly': True}, - 'status_message': {'readonly': True}, - 'target_resource': {'readonly': True}, - 'request': {'readonly': True}, - 'response': {'readonly': True}, - } - - _attribute_map = { - 'provisioning_operation': {'key': 'provisioningOperation', 'type': 'str'}, - 'provisioning_state': {'key': 'provisioningState', 'type': 'str'}, - 'timestamp': {'key': 'timestamp', 'type': 'iso-8601'}, - 'duration': {'key': 'duration', 'type': 'str'}, - 'service_request_id': {'key': 'serviceRequestId', 'type': 'str'}, - 'status_code': {'key': 'statusCode', 'type': 'str'}, - 'status_message': {'key': 'statusMessage', 'type': 'StatusMessage'}, - 'target_resource': {'key': 'targetResource', 'type': 'TargetResource'}, - 'request': {'key': 'request', 'type': 'HttpMessage'}, - 'response': {'key': 'response', 'type': 'HttpMessage'}, - } - - def __init__( - self, - **kwargs - ): - """ - """ - super(DeploymentOperationProperties, self).__init__(**kwargs) + "provisioning_operation": {"readonly": True}, + "provisioning_state": {"readonly": True}, + "timestamp": {"readonly": True}, + "duration": {"readonly": True}, + "service_request_id": {"readonly": True}, + "status_code": {"readonly": True}, + "status_message": {"readonly": True}, + "target_resource": {"readonly": True}, + "request": {"readonly": True}, + "response": {"readonly": True}, + } + + _attribute_map = { + "provisioning_operation": {"key": "provisioningOperation", "type": "str"}, + "provisioning_state": {"key": "provisioningState", "type": "str"}, + "timestamp": {"key": "timestamp", "type": "iso-8601"}, + "duration": {"key": "duration", "type": "str"}, + "service_request_id": {"key": "serviceRequestId", "type": "str"}, + "status_code": {"key": "statusCode", "type": "str"}, + "status_message": {"key": "statusMessage", "type": "StatusMessage"}, + "target_resource": {"key": "targetResource", "type": "TargetResource"}, + "request": {"key": "request", "type": "HttpMessage"}, + "response": {"key": "response", "type": "HttpMessage"}, + } + + def __init__(self, **kwargs): + """ """ + super().__init__(**kwargs) self.provisioning_operation = None self.provisioning_state = None self.timestamp = None @@ -665,7 +636,7 @@ def __init__( self.response = None -class DeploymentOperationsListResult(msrest.serialization.Model): +class DeploymentOperationsListResult(_serialization.Model): """List of deployment operations. Variables are only populated by the server, and will be ignored when sending a request. @@ -677,30 +648,25 @@ class DeploymentOperationsListResult(msrest.serialization.Model): """ _validation = { - 'next_link': {'readonly': True}, + "next_link": {"readonly": True}, } _attribute_map = { - 'value': {'key': 'value', 'type': '[DeploymentOperation]'}, - 'next_link': {'key': 'nextLink', 'type': 'str'}, + "value": {"key": "value", "type": "[DeploymentOperation]"}, + "next_link": {"key": "nextLink", "type": "str"}, } - def __init__( - self, - *, - value: Optional[List["DeploymentOperation"]] = None, - **kwargs - ): + def __init__(self, *, value: Optional[List["_models.DeploymentOperation"]] = None, **kwargs): """ :keyword value: An array of deployment operations. :paramtype value: list[~azure.mgmt.resource.resources.v2021_01_01.models.DeploymentOperation] """ - super(DeploymentOperationsListResult, self).__init__(**kwargs) + super().__init__(**kwargs) self.value = value self.next_link = None -class DeploymentProperties(msrest.serialization.Model): +class DeploymentProperties(_serialization.Model): """Deployment properties. All required parameters must be populated in order to send to Azure. @@ -709,7 +675,7 @@ class DeploymentProperties(msrest.serialization.Model): syntax directly in the request rather than link to an existing template. It can be a JObject or well-formed JSON string. Use either the templateLink property or the template property, but not both. - :vartype template: any + :vartype template: JSON :ivar template_link: The URI of the template. Use either the templateLink property or the template property, but not both. :vartype template_link: ~azure.mgmt.resource.resources.v2021_01_01.models.TemplateLink @@ -717,17 +683,17 @@ class DeploymentProperties(msrest.serialization.Model): You use this element when you want to provide the parameter values directly in the request rather than link to an existing parameter file. Use either the parametersLink property or the parameters property, but not both. It can be a JObject or a well formed JSON string. - :vartype parameters: any + :vartype parameters: JSON :ivar parameters_link: The URI of parameters file. You use this element to link to an existing parameters file. Use either the parametersLink property or the parameters property, but not both. :vartype parameters_link: ~azure.mgmt.resource.resources.v2021_01_01.models.ParametersLink - :ivar mode: Required. The mode that is used to deploy resources. This value can be either - Incremental or Complete. In Incremental mode, resources are deployed without deleting existing - resources that are not included in the template. In Complete mode, resources are deployed and - existing resources in the resource group that are not included in the template are deleted. Be - careful when using Complete mode as you may unintentionally delete resources. Possible values - include: "Incremental", "Complete". + :ivar mode: The mode that is used to deploy resources. This value can be either Incremental or + Complete. In Incremental mode, resources are deployed without deleting existing resources that + are not included in the template. In Complete mode, resources are deployed and existing + resources in the resource group that are not included in the template are deleted. Be careful + when using Complete mode as you may unintentionally delete resources. Required. Known values + are: "Incremental" and "Complete". :vartype mode: str or ~azure.mgmt.resource.resources.v2021_01_01.models.DeploymentMode :ivar debug_setting: The debug setting of the deployment. :vartype debug_setting: ~azure.mgmt.resource.resources.v2021_01_01.models.DebugSetting @@ -742,31 +708,31 @@ class DeploymentProperties(msrest.serialization.Model): """ _validation = { - 'mode': {'required': True}, + "mode": {"required": True}, } _attribute_map = { - 'template': {'key': 'template', 'type': 'object'}, - 'template_link': {'key': 'templateLink', 'type': 'TemplateLink'}, - 'parameters': {'key': 'parameters', 'type': 'object'}, - 'parameters_link': {'key': 'parametersLink', 'type': 'ParametersLink'}, - 'mode': {'key': 'mode', 'type': 'str'}, - 'debug_setting': {'key': 'debugSetting', 'type': 'DebugSetting'}, - 'on_error_deployment': {'key': 'onErrorDeployment', 'type': 'OnErrorDeployment'}, - 'expression_evaluation_options': {'key': 'expressionEvaluationOptions', 'type': 'ExpressionEvaluationOptions'}, + "template": {"key": "template", "type": "object"}, + "template_link": {"key": "templateLink", "type": "TemplateLink"}, + "parameters": {"key": "parameters", "type": "object"}, + "parameters_link": {"key": "parametersLink", "type": "ParametersLink"}, + "mode": {"key": "mode", "type": "str"}, + "debug_setting": {"key": "debugSetting", "type": "DebugSetting"}, + "on_error_deployment": {"key": "onErrorDeployment", "type": "OnErrorDeployment"}, + "expression_evaluation_options": {"key": "expressionEvaluationOptions", "type": "ExpressionEvaluationOptions"}, } def __init__( self, *, - mode: Union[str, "DeploymentMode"], - template: Optional[Any] = None, - template_link: Optional["TemplateLink"] = None, - parameters: Optional[Any] = None, - parameters_link: Optional["ParametersLink"] = None, - debug_setting: Optional["DebugSetting"] = None, - on_error_deployment: Optional["OnErrorDeployment"] = None, - expression_evaluation_options: Optional["ExpressionEvaluationOptions"] = None, + mode: Union[str, "_models.DeploymentMode"], + template: Optional[JSON] = None, + template_link: Optional["_models.TemplateLink"] = None, + parameters: Optional[JSON] = None, + parameters_link: Optional["_models.ParametersLink"] = None, + debug_setting: Optional["_models.DebugSetting"] = None, + on_error_deployment: Optional["_models.OnErrorDeployment"] = None, + expression_evaluation_options: Optional["_models.ExpressionEvaluationOptions"] = None, **kwargs ): """ @@ -774,7 +740,7 @@ def __init__( template syntax directly in the request rather than link to an existing template. It can be a JObject or well-formed JSON string. Use either the templateLink property or the template property, but not both. - :paramtype template: any + :paramtype template: JSON :keyword template_link: The URI of the template. Use either the templateLink property or the template property, but not both. :paramtype template_link: ~azure.mgmt.resource.resources.v2021_01_01.models.TemplateLink @@ -782,17 +748,17 @@ def __init__( template. You use this element when you want to provide the parameter values directly in the request rather than link to an existing parameter file. Use either the parametersLink property or the parameters property, but not both. It can be a JObject or a well formed JSON string. - :paramtype parameters: any + :paramtype parameters: JSON :keyword parameters_link: The URI of parameters file. You use this element to link to an existing parameters file. Use either the parametersLink property or the parameters property, but not both. :paramtype parameters_link: ~azure.mgmt.resource.resources.v2021_01_01.models.ParametersLink - :keyword mode: Required. The mode that is used to deploy resources. This value can be either - Incremental or Complete. In Incremental mode, resources are deployed without deleting existing - resources that are not included in the template. In Complete mode, resources are deployed and - existing resources in the resource group that are not included in the template are deleted. Be - careful when using Complete mode as you may unintentionally delete resources. Possible values - include: "Incremental", "Complete". + :keyword mode: The mode that is used to deploy resources. This value can be either Incremental + or Complete. In Incremental mode, resources are deployed without deleting existing resources + that are not included in the template. In Complete mode, resources are deployed and existing + resources in the resource group that are not included in the template are deleted. Be careful + when using Complete mode as you may unintentionally delete resources. Required. Known values + are: "Incremental" and "Complete". :paramtype mode: str or ~azure.mgmt.resource.resources.v2021_01_01.models.DeploymentMode :keyword debug_setting: The debug setting of the deployment. :paramtype debug_setting: ~azure.mgmt.resource.resources.v2021_01_01.models.DebugSetting @@ -805,7 +771,7 @@ def __init__( :paramtype expression_evaluation_options: ~azure.mgmt.resource.resources.v2021_01_01.models.ExpressionEvaluationOptions """ - super(DeploymentProperties, self).__init__(**kwargs) + super().__init__(**kwargs) self.template = template self.template_link = template_link self.parameters = parameters @@ -816,14 +782,14 @@ def __init__( self.expression_evaluation_options = expression_evaluation_options -class DeploymentPropertiesExtended(msrest.serialization.Model): +class DeploymentPropertiesExtended(_serialization.Model): # pylint: disable=too-many-instance-attributes """Deployment properties with additional details. Variables are only populated by the server, and will be ignored when sending a request. - :ivar provisioning_state: Denotes the state of provisioning. Possible values include: - "NotSpecified", "Accepted", "Running", "Ready", "Creating", "Created", "Deleting", "Deleted", - "Canceled", "Failed", "Succeeded", "Updating". + :ivar provisioning_state: Denotes the state of provisioning. Known values are: "NotSpecified", + "Accepted", "Running", "Ready", "Creating", "Created", "Deleting", "Deleted", "Canceled", + "Failed", "Succeeded", and "Updating". :vartype provisioning_state: str or ~azure.mgmt.resource.resources.v2021_01_01.models.ProvisioningState :ivar correlation_id: The correlation ID of the deployment. @@ -833,7 +799,7 @@ class DeploymentPropertiesExtended(msrest.serialization.Model): :ivar duration: The duration of the template deployment. :vartype duration: str :ivar outputs: Key/value pairs that represent deployment output. - :vartype outputs: any + :vartype outputs: JSON :ivar providers: The list of resource providers needed for the deployment. :vartype providers: list[~azure.mgmt.resource.resources.v2021_01_01.models.Provider] :ivar dependencies: The list of deployment dependencies. @@ -841,11 +807,11 @@ class DeploymentPropertiesExtended(msrest.serialization.Model): :ivar template_link: The URI referencing the template. :vartype template_link: ~azure.mgmt.resource.resources.v2021_01_01.models.TemplateLink :ivar parameters: Deployment parameters. - :vartype parameters: any + :vartype parameters: JSON :ivar parameters_link: The URI referencing the parameters. :vartype parameters_link: ~azure.mgmt.resource.resources.v2021_01_01.models.ParametersLink - :ivar mode: The deployment mode. Possible values are Incremental and Complete. Possible values - include: "Incremental", "Complete". + :ivar mode: The deployment mode. Possible values are Incremental and Complete. Known values + are: "Incremental" and "Complete". :vartype mode: str or ~azure.mgmt.resource.resources.v2021_01_01.models.DeploymentMode :ivar debug_setting: The debug setting of the deployment. :vartype debug_setting: ~azure.mgmt.resource.resources.v2021_01_01.models.DebugSetting @@ -865,52 +831,48 @@ class DeploymentPropertiesExtended(msrest.serialization.Model): """ _validation = { - 'provisioning_state': {'readonly': True}, - 'correlation_id': {'readonly': True}, - 'timestamp': {'readonly': True}, - 'duration': {'readonly': True}, - 'outputs': {'readonly': True}, - 'providers': {'readonly': True}, - 'dependencies': {'readonly': True}, - 'template_link': {'readonly': True}, - 'parameters': {'readonly': True}, - 'parameters_link': {'readonly': True}, - 'mode': {'readonly': True}, - 'debug_setting': {'readonly': True}, - 'on_error_deployment': {'readonly': True}, - 'template_hash': {'readonly': True}, - 'output_resources': {'readonly': True}, - 'validated_resources': {'readonly': True}, - 'error': {'readonly': True}, - } - - _attribute_map = { - 'provisioning_state': {'key': 'provisioningState', 'type': 'str'}, - 'correlation_id': {'key': 'correlationId', 'type': 'str'}, - 'timestamp': {'key': 'timestamp', 'type': 'iso-8601'}, - 'duration': {'key': 'duration', 'type': 'str'}, - 'outputs': {'key': 'outputs', 'type': 'object'}, - 'providers': {'key': 'providers', 'type': '[Provider]'}, - 'dependencies': {'key': 'dependencies', 'type': '[Dependency]'}, - 'template_link': {'key': 'templateLink', 'type': 'TemplateLink'}, - 'parameters': {'key': 'parameters', 'type': 'object'}, - 'parameters_link': {'key': 'parametersLink', 'type': 'ParametersLink'}, - 'mode': {'key': 'mode', 'type': 'str'}, - 'debug_setting': {'key': 'debugSetting', 'type': 'DebugSetting'}, - 'on_error_deployment': {'key': 'onErrorDeployment', 'type': 'OnErrorDeploymentExtended'}, - 'template_hash': {'key': 'templateHash', 'type': 'str'}, - 'output_resources': {'key': 'outputResources', 'type': '[ResourceReference]'}, - 'validated_resources': {'key': 'validatedResources', 'type': '[ResourceReference]'}, - 'error': {'key': 'error', 'type': 'ErrorResponse'}, - } - - def __init__( - self, - **kwargs - ): - """ - """ - super(DeploymentPropertiesExtended, self).__init__(**kwargs) + "provisioning_state": {"readonly": True}, + "correlation_id": {"readonly": True}, + "timestamp": {"readonly": True}, + "duration": {"readonly": True}, + "outputs": {"readonly": True}, + "providers": {"readonly": True}, + "dependencies": {"readonly": True}, + "template_link": {"readonly": True}, + "parameters": {"readonly": True}, + "parameters_link": {"readonly": True}, + "mode": {"readonly": True}, + "debug_setting": {"readonly": True}, + "on_error_deployment": {"readonly": True}, + "template_hash": {"readonly": True}, + "output_resources": {"readonly": True}, + "validated_resources": {"readonly": True}, + "error": {"readonly": True}, + } + + _attribute_map = { + "provisioning_state": {"key": "provisioningState", "type": "str"}, + "correlation_id": {"key": "correlationId", "type": "str"}, + "timestamp": {"key": "timestamp", "type": "iso-8601"}, + "duration": {"key": "duration", "type": "str"}, + "outputs": {"key": "outputs", "type": "object"}, + "providers": {"key": "providers", "type": "[Provider]"}, + "dependencies": {"key": "dependencies", "type": "[Dependency]"}, + "template_link": {"key": "templateLink", "type": "TemplateLink"}, + "parameters": {"key": "parameters", "type": "object"}, + "parameters_link": {"key": "parametersLink", "type": "ParametersLink"}, + "mode": {"key": "mode", "type": "str"}, + "debug_setting": {"key": "debugSetting", "type": "DebugSetting"}, + "on_error_deployment": {"key": "onErrorDeployment", "type": "OnErrorDeploymentExtended"}, + "template_hash": {"key": "templateHash", "type": "str"}, + "output_resources": {"key": "outputResources", "type": "[ResourceReference]"}, + "validated_resources": {"key": "validatedResources", "type": "[ResourceReference]"}, + "error": {"key": "error", "type": "ErrorResponse"}, + } + + def __init__(self, **kwargs): + """ """ + super().__init__(**kwargs) self.provisioning_state = None self.correlation_id = None self.timestamp = None @@ -930,7 +892,7 @@ def __init__( self.error = None -class DeploymentValidateResult(msrest.serialization.Model): +class DeploymentValidateResult(_serialization.Model): """Information from validate template deployment response. Variables are only populated by the server, and will be ignored when sending a request. @@ -943,66 +905,55 @@ class DeploymentValidateResult(msrest.serialization.Model): """ _validation = { - 'error': {'readonly': True}, + "error": {"readonly": True}, } _attribute_map = { - 'error': {'key': 'error', 'type': 'ErrorResponse'}, - 'properties': {'key': 'properties', 'type': 'DeploymentPropertiesExtended'}, + "error": {"key": "error", "type": "ErrorResponse"}, + "properties": {"key": "properties", "type": "DeploymentPropertiesExtended"}, } - def __init__( - self, - *, - properties: Optional["DeploymentPropertiesExtended"] = None, - **kwargs - ): + def __init__(self, *, properties: Optional["_models.DeploymentPropertiesExtended"] = None, **kwargs): """ :keyword properties: The template deployment properties. :paramtype properties: ~azure.mgmt.resource.resources.v2021_01_01.models.DeploymentPropertiesExtended """ - super(DeploymentValidateResult, self).__init__(**kwargs) + super().__init__(**kwargs) self.error = None self.properties = properties -class DeploymentWhatIf(msrest.serialization.Model): +class DeploymentWhatIf(_serialization.Model): """Deployment What-if operation parameters. All required parameters must be populated in order to send to Azure. :ivar location: The location to store the deployment data. :vartype location: str - :ivar properties: Required. The deployment properties. + :ivar properties: The deployment properties. Required. :vartype properties: ~azure.mgmt.resource.resources.v2021_01_01.models.DeploymentWhatIfProperties """ _validation = { - 'properties': {'required': True}, + "properties": {"required": True}, } _attribute_map = { - 'location': {'key': 'location', 'type': 'str'}, - 'properties': {'key': 'properties', 'type': 'DeploymentWhatIfProperties'}, + "location": {"key": "location", "type": "str"}, + "properties": {"key": "properties", "type": "DeploymentWhatIfProperties"}, } - def __init__( - self, - *, - properties: "DeploymentWhatIfProperties", - location: Optional[str] = None, - **kwargs - ): + def __init__(self, *, properties: "_models.DeploymentWhatIfProperties", location: Optional[str] = None, **kwargs): """ :keyword location: The location to store the deployment data. :paramtype location: str - :keyword properties: Required. The deployment properties. + :keyword properties: The deployment properties. Required. :paramtype properties: ~azure.mgmt.resource.resources.v2021_01_01.models.DeploymentWhatIfProperties """ - super(DeploymentWhatIf, self).__init__(**kwargs) + super().__init__(**kwargs) self.location = location self.properties = properties @@ -1016,7 +967,7 @@ class DeploymentWhatIfProperties(DeploymentProperties): syntax directly in the request rather than link to an existing template. It can be a JObject or well-formed JSON string. Use either the templateLink property or the template property, but not both. - :vartype template: any + :vartype template: JSON :ivar template_link: The URI of the template. Use either the templateLink property or the template property, but not both. :vartype template_link: ~azure.mgmt.resource.resources.v2021_01_01.models.TemplateLink @@ -1024,17 +975,17 @@ class DeploymentWhatIfProperties(DeploymentProperties): You use this element when you want to provide the parameter values directly in the request rather than link to an existing parameter file. Use either the parametersLink property or the parameters property, but not both. It can be a JObject or a well formed JSON string. - :vartype parameters: any + :vartype parameters: JSON :ivar parameters_link: The URI of parameters file. You use this element to link to an existing parameters file. Use either the parametersLink property or the parameters property, but not both. :vartype parameters_link: ~azure.mgmt.resource.resources.v2021_01_01.models.ParametersLink - :ivar mode: Required. The mode that is used to deploy resources. This value can be either - Incremental or Complete. In Incremental mode, resources are deployed without deleting existing - resources that are not included in the template. In Complete mode, resources are deployed and - existing resources in the resource group that are not included in the template are deleted. Be - careful when using Complete mode as you may unintentionally delete resources. Possible values - include: "Incremental", "Complete". + :ivar mode: The mode that is used to deploy resources. This value can be either Incremental or + Complete. In Incremental mode, resources are deployed without deleting existing resources that + are not included in the template. In Complete mode, resources are deployed and existing + resources in the resource group that are not included in the template are deleted. Be careful + when using Complete mode as you may unintentionally delete resources. Required. Known values + are: "Incremental" and "Complete". :vartype mode: str or ~azure.mgmt.resource.resources.v2021_01_01.models.DeploymentMode :ivar debug_setting: The debug setting of the deployment. :vartype debug_setting: ~azure.mgmt.resource.resources.v2021_01_01.models.DebugSetting @@ -1052,33 +1003,33 @@ class DeploymentWhatIfProperties(DeploymentProperties): """ _validation = { - 'mode': {'required': True}, + "mode": {"required": True}, } _attribute_map = { - 'template': {'key': 'template', 'type': 'object'}, - 'template_link': {'key': 'templateLink', 'type': 'TemplateLink'}, - 'parameters': {'key': 'parameters', 'type': 'object'}, - 'parameters_link': {'key': 'parametersLink', 'type': 'ParametersLink'}, - 'mode': {'key': 'mode', 'type': 'str'}, - 'debug_setting': {'key': 'debugSetting', 'type': 'DebugSetting'}, - 'on_error_deployment': {'key': 'onErrorDeployment', 'type': 'OnErrorDeployment'}, - 'expression_evaluation_options': {'key': 'expressionEvaluationOptions', 'type': 'ExpressionEvaluationOptions'}, - 'what_if_settings': {'key': 'whatIfSettings', 'type': 'DeploymentWhatIfSettings'}, + "template": {"key": "template", "type": "object"}, + "template_link": {"key": "templateLink", "type": "TemplateLink"}, + "parameters": {"key": "parameters", "type": "object"}, + "parameters_link": {"key": "parametersLink", "type": "ParametersLink"}, + "mode": {"key": "mode", "type": "str"}, + "debug_setting": {"key": "debugSetting", "type": "DebugSetting"}, + "on_error_deployment": {"key": "onErrorDeployment", "type": "OnErrorDeployment"}, + "expression_evaluation_options": {"key": "expressionEvaluationOptions", "type": "ExpressionEvaluationOptions"}, + "what_if_settings": {"key": "whatIfSettings", "type": "DeploymentWhatIfSettings"}, } def __init__( self, *, - mode: Union[str, "DeploymentMode"], - template: Optional[Any] = None, - template_link: Optional["TemplateLink"] = None, - parameters: Optional[Any] = None, - parameters_link: Optional["ParametersLink"] = None, - debug_setting: Optional["DebugSetting"] = None, - on_error_deployment: Optional["OnErrorDeployment"] = None, - expression_evaluation_options: Optional["ExpressionEvaluationOptions"] = None, - what_if_settings: Optional["DeploymentWhatIfSettings"] = None, + mode: Union[str, "_models.DeploymentMode"], + template: Optional[JSON] = None, + template_link: Optional["_models.TemplateLink"] = None, + parameters: Optional[JSON] = None, + parameters_link: Optional["_models.ParametersLink"] = None, + debug_setting: Optional["_models.DebugSetting"] = None, + on_error_deployment: Optional["_models.OnErrorDeployment"] = None, + expression_evaluation_options: Optional["_models.ExpressionEvaluationOptions"] = None, + what_if_settings: Optional["_models.DeploymentWhatIfSettings"] = None, **kwargs ): """ @@ -1086,7 +1037,7 @@ def __init__( template syntax directly in the request rather than link to an existing template. It can be a JObject or well-formed JSON string. Use either the templateLink property or the template property, but not both. - :paramtype template: any + :paramtype template: JSON :keyword template_link: The URI of the template. Use either the templateLink property or the template property, but not both. :paramtype template_link: ~azure.mgmt.resource.resources.v2021_01_01.models.TemplateLink @@ -1094,17 +1045,17 @@ def __init__( template. You use this element when you want to provide the parameter values directly in the request rather than link to an existing parameter file. Use either the parametersLink property or the parameters property, but not both. It can be a JObject or a well formed JSON string. - :paramtype parameters: any + :paramtype parameters: JSON :keyword parameters_link: The URI of parameters file. You use this element to link to an existing parameters file. Use either the parametersLink property or the parameters property, but not both. :paramtype parameters_link: ~azure.mgmt.resource.resources.v2021_01_01.models.ParametersLink - :keyword mode: Required. The mode that is used to deploy resources. This value can be either - Incremental or Complete. In Incremental mode, resources are deployed without deleting existing - resources that are not included in the template. In Complete mode, resources are deployed and - existing resources in the resource group that are not included in the template are deleted. Be - careful when using Complete mode as you may unintentionally delete resources. Possible values - include: "Incremental", "Complete". + :keyword mode: The mode that is used to deploy resources. This value can be either Incremental + or Complete. In Incremental mode, resources are deployed without deleting existing resources + that are not included in the template. In Complete mode, resources are deployed and existing + resources in the resource group that are not included in the template are deleted. Be careful + when using Complete mode as you may unintentionally delete resources. Required. Known values + are: "Incremental" and "Complete". :paramtype mode: str or ~azure.mgmt.resource.resources.v2021_01_01.models.DeploymentMode :keyword debug_setting: The debug setting of the deployment. :paramtype debug_setting: ~azure.mgmt.resource.resources.v2021_01_01.models.DebugSetting @@ -1120,40 +1071,45 @@ def __init__( :paramtype what_if_settings: ~azure.mgmt.resource.resources.v2021_01_01.models.DeploymentWhatIfSettings """ - super(DeploymentWhatIfProperties, self).__init__(template=template, template_link=template_link, parameters=parameters, parameters_link=parameters_link, mode=mode, debug_setting=debug_setting, on_error_deployment=on_error_deployment, expression_evaluation_options=expression_evaluation_options, **kwargs) + super().__init__( + template=template, + template_link=template_link, + parameters=parameters, + parameters_link=parameters_link, + mode=mode, + debug_setting=debug_setting, + on_error_deployment=on_error_deployment, + expression_evaluation_options=expression_evaluation_options, + **kwargs + ) self.what_if_settings = what_if_settings -class DeploymentWhatIfSettings(msrest.serialization.Model): +class DeploymentWhatIfSettings(_serialization.Model): """Deployment What-If operation settings. - :ivar result_format: The format of the What-If results. Possible values include: - "ResourceIdOnly", "FullResourcePayloads". + :ivar result_format: The format of the What-If results. Known values are: "ResourceIdOnly" and + "FullResourcePayloads". :vartype result_format: str or ~azure.mgmt.resource.resources.v2021_01_01.models.WhatIfResultFormat """ _attribute_map = { - 'result_format': {'key': 'resultFormat', 'type': 'str'}, + "result_format": {"key": "resultFormat", "type": "str"}, } - def __init__( - self, - *, - result_format: Optional[Union[str, "WhatIfResultFormat"]] = None, - **kwargs - ): + def __init__(self, *, result_format: Optional[Union[str, "_models.WhatIfResultFormat"]] = None, **kwargs): """ - :keyword result_format: The format of the What-If results. Possible values include: - "ResourceIdOnly", "FullResourcePayloads". + :keyword result_format: The format of the What-If results. Known values are: "ResourceIdOnly" + and "FullResourcePayloads". :paramtype result_format: str or ~azure.mgmt.resource.resources.v2021_01_01.models.WhatIfResultFormat """ - super(DeploymentWhatIfSettings, self).__init__(**kwargs) + super().__init__(**kwargs) self.result_format = result_format -class ErrorAdditionalInfo(msrest.serialization.Model): +class ErrorAdditionalInfo(_serialization.Model): """The resource management error additional info. Variables are only populated by the server, and will be ignored when sending a request. @@ -1161,31 +1117,27 @@ class ErrorAdditionalInfo(msrest.serialization.Model): :ivar type: The additional info type. :vartype type: str :ivar info: The additional info. - :vartype info: any + :vartype info: JSON """ _validation = { - 'type': {'readonly': True}, - 'info': {'readonly': True}, + "type": {"readonly": True}, + "info": {"readonly": True}, } _attribute_map = { - 'type': {'key': 'type', 'type': 'str'}, - 'info': {'key': 'info', 'type': 'object'}, + "type": {"key": "type", "type": "str"}, + "info": {"key": "info", "type": "object"}, } - def __init__( - self, - **kwargs - ): - """ - """ - super(ErrorAdditionalInfo, self).__init__(**kwargs) + def __init__(self, **kwargs): + """ """ + super().__init__(**kwargs) self.type = None self.info = None -class ErrorResponse(msrest.serialization.Model): +class ErrorResponse(_serialization.Model): """Common error response for all Azure Resource Manager APIs to return error details for failed operations. (This also follows the OData error response format.). Variables are only populated by the server, and will be ignored when sending a request. @@ -1204,28 +1156,24 @@ class ErrorResponse(msrest.serialization.Model): """ _validation = { - 'code': {'readonly': True}, - 'message': {'readonly': True}, - 'target': {'readonly': True}, - 'details': {'readonly': True}, - 'additional_info': {'readonly': True}, + "code": {"readonly": True}, + "message": {"readonly": True}, + "target": {"readonly": True}, + "details": {"readonly": True}, + "additional_info": {"readonly": True}, } _attribute_map = { - 'code': {'key': 'code', 'type': 'str'}, - 'message': {'key': 'message', 'type': 'str'}, - 'target': {'key': 'target', 'type': 'str'}, - 'details': {'key': 'details', 'type': '[ErrorResponse]'}, - 'additional_info': {'key': 'additionalInfo', 'type': '[ErrorAdditionalInfo]'}, + "code": {"key": "code", "type": "str"}, + "message": {"key": "message", "type": "str"}, + "target": {"key": "target", "type": "str"}, + "details": {"key": "details", "type": "[ErrorResponse]"}, + "additional_info": {"key": "additionalInfo", "type": "[ErrorAdditionalInfo]"}, } - def __init__( - self, - **kwargs - ): - """ - """ - super(ErrorResponse, self).__init__(**kwargs) + def __init__(self, **kwargs): + """ """ + super().__init__(**kwargs) self.code = None self.message = None self.target = None @@ -1233,7 +1181,7 @@ def __init__( self.additional_info = None -class ExportTemplateRequest(msrest.serialization.Model): +class ExportTemplateRequest(_serialization.Model): """Export resource group template request parameters. :ivar resources: The IDs of the resources to filter the export by. To export all resources, @@ -1246,17 +1194,11 @@ class ExportTemplateRequest(msrest.serialization.Model): """ _attribute_map = { - 'resources': {'key': 'resources', 'type': '[str]'}, - 'options': {'key': 'options', 'type': 'str'}, + "resources": {"key": "resources", "type": "[str]"}, + "options": {"key": "options", "type": "str"}, } - def __init__( - self, - *, - resources: Optional[List[str]] = None, - options: Optional[str] = None, - **kwargs - ): + def __init__(self, *, resources: Optional[List[str]] = None, options: Optional[str] = None, **kwargs): """ :keyword resources: The IDs of the resources to filter the export by. To export all resources, supply an array with single entry '*'. @@ -1266,73 +1208,64 @@ def __init__( 'SkipResourceNameParameterization', 'SkipAllParameterization'. :paramtype options: str """ - super(ExportTemplateRequest, self).__init__(**kwargs) + super().__init__(**kwargs) self.resources = resources self.options = options -class ExpressionEvaluationOptions(msrest.serialization.Model): +class ExpressionEvaluationOptions(_serialization.Model): """Specifies whether template expressions are evaluated within the scope of the parent template or nested template. :ivar scope: The scope to be used for evaluation of parameters, variables and functions in a - nested template. Possible values include: "NotSpecified", "Outer", "Inner". + nested template. Known values are: "NotSpecified", "Outer", and "Inner". :vartype scope: str or ~azure.mgmt.resource.resources.v2021_01_01.models.ExpressionEvaluationOptionsScopeType """ _attribute_map = { - 'scope': {'key': 'scope', 'type': 'str'}, + "scope": {"key": "scope", "type": "str"}, } - def __init__( - self, - *, - scope: Optional[Union[str, "ExpressionEvaluationOptionsScopeType"]] = None, - **kwargs - ): + def __init__(self, *, scope: Optional[Union[str, "_models.ExpressionEvaluationOptionsScopeType"]] = None, **kwargs): """ :keyword scope: The scope to be used for evaluation of parameters, variables and functions in a - nested template. Possible values include: "NotSpecified", "Outer", "Inner". + nested template. Known values are: "NotSpecified", "Outer", and "Inner". :paramtype scope: str or ~azure.mgmt.resource.resources.v2021_01_01.models.ExpressionEvaluationOptionsScopeType """ - super(ExpressionEvaluationOptions, self).__init__(**kwargs) + super().__init__(**kwargs) self.scope = scope -class ExtendedLocation(msrest.serialization.Model): +class ExtendedLocation(_serialization.Model): """Resource extended location. - :ivar type: The extended location type. Possible values include: "EdgeZone". + :ivar type: The extended location type. "EdgeZone" :vartype type: str or ~azure.mgmt.resource.resources.v2021_01_01.models.ExtendedLocationType :ivar name: The extended location name. :vartype name: str """ _attribute_map = { - 'type': {'key': 'type', 'type': 'str'}, - 'name': {'key': 'name', 'type': 'str'}, + "type": {"key": "type", "type": "str"}, + "name": {"key": "name", "type": "str"}, } def __init__( - self, - *, - type: Optional[Union[str, "ExtendedLocationType"]] = None, - name: Optional[str] = None, - **kwargs + self, *, type: Optional[Union[str, "_models.ExtendedLocationType"]] = None, name: Optional[str] = None, **kwargs ): """ - :keyword type: The extended location type. Possible values include: "EdgeZone". + :keyword type: The extended location type. "EdgeZone" :paramtype type: str or ~azure.mgmt.resource.resources.v2021_01_01.models.ExtendedLocationType :keyword name: The extended location name. :paramtype name: str """ - super(ExtendedLocation, self).__init__(**kwargs) + super().__init__(**kwargs) self.type = type self.name = name -class Resource(msrest.serialization.Model): +class Resource(_serialization.Model): """Specified resource. Variables are only populated by the server, and will be ignored when sending a request. @@ -1347,30 +1280,30 @@ class Resource(msrest.serialization.Model): :vartype location: str :ivar extended_location: Resource extended location. :vartype extended_location: ~azure.mgmt.resource.resources.v2021_01_01.models.ExtendedLocation - :ivar tags: A set of tags. Resource tags. + :ivar tags: Resource tags. :vartype tags: dict[str, str] """ _validation = { - 'id': {'readonly': True}, - 'name': {'readonly': True}, - 'type': {'readonly': True}, + "id": {"readonly": True}, + "name": {"readonly": True}, + "type": {"readonly": True}, } _attribute_map = { - 'id': {'key': 'id', 'type': 'str'}, - 'name': {'key': 'name', 'type': 'str'}, - 'type': {'key': 'type', 'type': 'str'}, - 'location': {'key': 'location', 'type': 'str'}, - 'extended_location': {'key': 'extendedLocation', 'type': 'ExtendedLocation'}, - 'tags': {'key': 'tags', 'type': '{str}'}, + "id": {"key": "id", "type": "str"}, + "name": {"key": "name", "type": "str"}, + "type": {"key": "type", "type": "str"}, + "location": {"key": "location", "type": "str"}, + "extended_location": {"key": "extendedLocation", "type": "ExtendedLocation"}, + "tags": {"key": "tags", "type": "{str}"}, } def __init__( self, *, location: Optional[str] = None, - extended_location: Optional["ExtendedLocation"] = None, + extended_location: Optional["_models.ExtendedLocation"] = None, tags: Optional[Dict[str, str]] = None, **kwargs ): @@ -1380,10 +1313,10 @@ def __init__( :keyword extended_location: Resource extended location. :paramtype extended_location: ~azure.mgmt.resource.resources.v2021_01_01.models.ExtendedLocation - :keyword tags: A set of tags. Resource tags. + :keyword tags: Resource tags. :paramtype tags: dict[str, str] """ - super(Resource, self).__init__(**kwargs) + super().__init__(**kwargs) self.id = None self.name = None self.type = None @@ -1392,7 +1325,7 @@ def __init__( self.tags = tags -class GenericResource(Resource): +class GenericResource(Resource): # pylint: disable=too-many-instance-attributes """Resource information. Variables are only populated by the server, and will be ignored when sending a request. @@ -1407,12 +1340,12 @@ class GenericResource(Resource): :vartype location: str :ivar extended_location: Resource extended location. :vartype extended_location: ~azure.mgmt.resource.resources.v2021_01_01.models.ExtendedLocation - :ivar tags: A set of tags. Resource tags. + :ivar tags: Resource tags. :vartype tags: dict[str, str] :ivar plan: The plan of the resource. :vartype plan: ~azure.mgmt.resource.resources.v2021_01_01.models.Plan :ivar properties: The resource properties. - :vartype properties: any + :vartype properties: JSON :ivar kind: The kind of the resource. :vartype kind: str :ivar managed_by: ID of the resource that manages this resource. @@ -1424,39 +1357,39 @@ class GenericResource(Resource): """ _validation = { - 'id': {'readonly': True}, - 'name': {'readonly': True}, - 'type': {'readonly': True}, - 'kind': {'pattern': r'^[-\w\._,\(\)]+$'}, + "id": {"readonly": True}, + "name": {"readonly": True}, + "type": {"readonly": True}, + "kind": {"pattern": r"^[-\w\._,\(\)]+$"}, } _attribute_map = { - 'id': {'key': 'id', 'type': 'str'}, - 'name': {'key': 'name', 'type': 'str'}, - 'type': {'key': 'type', 'type': 'str'}, - 'location': {'key': 'location', 'type': 'str'}, - 'extended_location': {'key': 'extendedLocation', 'type': 'ExtendedLocation'}, - 'tags': {'key': 'tags', 'type': '{str}'}, - 'plan': {'key': 'plan', 'type': 'Plan'}, - 'properties': {'key': 'properties', 'type': 'object'}, - 'kind': {'key': 'kind', 'type': 'str'}, - 'managed_by': {'key': 'managedBy', 'type': 'str'}, - 'sku': {'key': 'sku', 'type': 'Sku'}, - 'identity': {'key': 'identity', 'type': 'Identity'}, + "id": {"key": "id", "type": "str"}, + "name": {"key": "name", "type": "str"}, + "type": {"key": "type", "type": "str"}, + "location": {"key": "location", "type": "str"}, + "extended_location": {"key": "extendedLocation", "type": "ExtendedLocation"}, + "tags": {"key": "tags", "type": "{str}"}, + "plan": {"key": "plan", "type": "Plan"}, + "properties": {"key": "properties", "type": "object"}, + "kind": {"key": "kind", "type": "str"}, + "managed_by": {"key": "managedBy", "type": "str"}, + "sku": {"key": "sku", "type": "Sku"}, + "identity": {"key": "identity", "type": "Identity"}, } def __init__( self, *, location: Optional[str] = None, - extended_location: Optional["ExtendedLocation"] = None, + extended_location: Optional["_models.ExtendedLocation"] = None, tags: Optional[Dict[str, str]] = None, - plan: Optional["Plan"] = None, - properties: Optional[Any] = None, + plan: Optional["_models.Plan"] = None, + properties: Optional[JSON] = None, kind: Optional[str] = None, managed_by: Optional[str] = None, - sku: Optional["Sku"] = None, - identity: Optional["Identity"] = None, + sku: Optional["_models.Sku"] = None, + identity: Optional["_models.Identity"] = None, **kwargs ): """ @@ -1465,12 +1398,12 @@ def __init__( :keyword extended_location: Resource extended location. :paramtype extended_location: ~azure.mgmt.resource.resources.v2021_01_01.models.ExtendedLocation - :keyword tags: A set of tags. Resource tags. + :keyword tags: Resource tags. :paramtype tags: dict[str, str] :keyword plan: The plan of the resource. :paramtype plan: ~azure.mgmt.resource.resources.v2021_01_01.models.Plan :keyword properties: The resource properties. - :paramtype properties: any + :paramtype properties: JSON :keyword kind: The kind of the resource. :paramtype kind: str :keyword managed_by: ID of the resource that manages this resource. @@ -1480,7 +1413,7 @@ def __init__( :keyword identity: The identity of the resource. :paramtype identity: ~azure.mgmt.resource.resources.v2021_01_01.models.Identity """ - super(GenericResource, self).__init__(location=location, extended_location=extended_location, tags=tags, **kwargs) + super().__init__(location=location, extended_location=extended_location, tags=tags, **kwargs) self.plan = plan self.properties = properties self.kind = kind @@ -1489,7 +1422,7 @@ def __init__( self.identity = identity -class GenericResourceExpanded(GenericResource): +class GenericResourceExpanded(GenericResource): # pylint: disable=too-many-instance-attributes """Resource information. Variables are only populated by the server, and will be ignored when sending a request. @@ -1504,12 +1437,12 @@ class GenericResourceExpanded(GenericResource): :vartype location: str :ivar extended_location: Resource extended location. :vartype extended_location: ~azure.mgmt.resource.resources.v2021_01_01.models.ExtendedLocation - :ivar tags: A set of tags. Resource tags. + :ivar tags: Resource tags. :vartype tags: dict[str, str] :ivar plan: The plan of the resource. :vartype plan: ~azure.mgmt.resource.resources.v2021_01_01.models.Plan :ivar properties: The resource properties. - :vartype properties: any + :vartype properties: JSON :ivar kind: The kind of the resource. :vartype kind: str :ivar managed_by: ID of the resource that manages this resource. @@ -1530,45 +1463,45 @@ class GenericResourceExpanded(GenericResource): """ _validation = { - 'id': {'readonly': True}, - 'name': {'readonly': True}, - 'type': {'readonly': True}, - 'kind': {'pattern': r'^[-\w\._,\(\)]+$'}, - 'created_time': {'readonly': True}, - 'changed_time': {'readonly': True}, - 'provisioning_state': {'readonly': True}, - } - - _attribute_map = { - 'id': {'key': 'id', 'type': 'str'}, - 'name': {'key': 'name', 'type': 'str'}, - 'type': {'key': 'type', 'type': 'str'}, - 'location': {'key': 'location', 'type': 'str'}, - 'extended_location': {'key': 'extendedLocation', 'type': 'ExtendedLocation'}, - 'tags': {'key': 'tags', 'type': '{str}'}, - 'plan': {'key': 'plan', 'type': 'Plan'}, - 'properties': {'key': 'properties', 'type': 'object'}, - 'kind': {'key': 'kind', 'type': 'str'}, - 'managed_by': {'key': 'managedBy', 'type': 'str'}, - 'sku': {'key': 'sku', 'type': 'Sku'}, - 'identity': {'key': 'identity', 'type': 'Identity'}, - 'created_time': {'key': 'createdTime', 'type': 'iso-8601'}, - 'changed_time': {'key': 'changedTime', 'type': 'iso-8601'}, - 'provisioning_state': {'key': 'provisioningState', 'type': 'str'}, + "id": {"readonly": True}, + "name": {"readonly": True}, + "type": {"readonly": True}, + "kind": {"pattern": r"^[-\w\._,\(\)]+$"}, + "created_time": {"readonly": True}, + "changed_time": {"readonly": True}, + "provisioning_state": {"readonly": True}, + } + + _attribute_map = { + "id": {"key": "id", "type": "str"}, + "name": {"key": "name", "type": "str"}, + "type": {"key": "type", "type": "str"}, + "location": {"key": "location", "type": "str"}, + "extended_location": {"key": "extendedLocation", "type": "ExtendedLocation"}, + "tags": {"key": "tags", "type": "{str}"}, + "plan": {"key": "plan", "type": "Plan"}, + "properties": {"key": "properties", "type": "object"}, + "kind": {"key": "kind", "type": "str"}, + "managed_by": {"key": "managedBy", "type": "str"}, + "sku": {"key": "sku", "type": "Sku"}, + "identity": {"key": "identity", "type": "Identity"}, + "created_time": {"key": "createdTime", "type": "iso-8601"}, + "changed_time": {"key": "changedTime", "type": "iso-8601"}, + "provisioning_state": {"key": "provisioningState", "type": "str"}, } def __init__( self, *, location: Optional[str] = None, - extended_location: Optional["ExtendedLocation"] = None, + extended_location: Optional["_models.ExtendedLocation"] = None, tags: Optional[Dict[str, str]] = None, - plan: Optional["Plan"] = None, - properties: Optional[Any] = None, + plan: Optional["_models.Plan"] = None, + properties: Optional[JSON] = None, kind: Optional[str] = None, managed_by: Optional[str] = None, - sku: Optional["Sku"] = None, - identity: Optional["Identity"] = None, + sku: Optional["_models.Sku"] = None, + identity: Optional["_models.Identity"] = None, **kwargs ): """ @@ -1577,12 +1510,12 @@ def __init__( :keyword extended_location: Resource extended location. :paramtype extended_location: ~azure.mgmt.resource.resources.v2021_01_01.models.ExtendedLocation - :keyword tags: A set of tags. Resource tags. + :keyword tags: Resource tags. :paramtype tags: dict[str, str] :keyword plan: The plan of the resource. :paramtype plan: ~azure.mgmt.resource.resources.v2021_01_01.models.Plan :keyword properties: The resource properties. - :paramtype properties: any + :paramtype properties: JSON :keyword kind: The kind of the resource. :paramtype kind: str :keyword managed_by: ID of the resource that manages this resource. @@ -1592,13 +1525,24 @@ def __init__( :keyword identity: The identity of the resource. :paramtype identity: ~azure.mgmt.resource.resources.v2021_01_01.models.Identity """ - super(GenericResourceExpanded, self).__init__(location=location, extended_location=extended_location, tags=tags, plan=plan, properties=properties, kind=kind, managed_by=managed_by, sku=sku, identity=identity, **kwargs) + super().__init__( + location=location, + extended_location=extended_location, + tags=tags, + plan=plan, + properties=properties, + kind=kind, + managed_by=managed_by, + sku=sku, + identity=identity, + **kwargs + ) self.created_time = None self.changed_time = None self.provisioning_state = None -class GenericResourceFilter(msrest.serialization.Model): +class GenericResourceFilter(_serialization.Model): """Resource filter. :ivar resource_type: The resource type. @@ -1610,9 +1554,9 @@ class GenericResourceFilter(msrest.serialization.Model): """ _attribute_map = { - 'resource_type': {'key': 'resourceType', 'type': 'str'}, - 'tagname': {'key': 'tagname', 'type': 'str'}, - 'tagvalue': {'key': 'tagvalue', 'type': 'str'}, + "resource_type": {"key": "resourceType", "type": "str"}, + "tagname": {"key": "tagname", "type": "str"}, + "tagvalue": {"key": "tagvalue", "type": "str"}, } def __init__( @@ -1631,38 +1575,33 @@ def __init__( :keyword tagvalue: The tag value. :paramtype tagvalue: str """ - super(GenericResourceFilter, self).__init__(**kwargs) + super().__init__(**kwargs) self.resource_type = resource_type self.tagname = tagname self.tagvalue = tagvalue -class HttpMessage(msrest.serialization.Model): +class HttpMessage(_serialization.Model): """HTTP message. :ivar content: HTTP message content. - :vartype content: any + :vartype content: JSON """ _attribute_map = { - 'content': {'key': 'content', 'type': 'object'}, + "content": {"key": "content", "type": "object"}, } - def __init__( - self, - *, - content: Optional[Any] = None, - **kwargs - ): + def __init__(self, *, content: Optional[JSON] = None, **kwargs): """ :keyword content: HTTP message content. - :paramtype content: any + :paramtype content: JSON """ - super(HttpMessage, self).__init__(**kwargs) + super().__init__(**kwargs) self.content = content -class Identity(msrest.serialization.Model): +class Identity(_serialization.Model): """Identity for the resource. Variables are only populated by the server, and will be ignored when sending a request. @@ -1671,8 +1610,8 @@ class Identity(msrest.serialization.Model): :vartype principal_id: str :ivar tenant_id: The tenant ID of resource. :vartype tenant_id: str - :ivar type: The identity type. Possible values include: "SystemAssigned", "UserAssigned", - "SystemAssigned, UserAssigned", "None". + :ivar type: The identity type. Known values are: "SystemAssigned", "UserAssigned", + "SystemAssigned, UserAssigned", and "None". :vartype type: str or ~azure.mgmt.resource.resources.v2021_01_01.models.ResourceIdentityType :ivar user_assigned_identities: The list of user identities associated with the resource. The user identity dictionary key references will be ARM resource ids in the form: @@ -1682,27 +1621,27 @@ class Identity(msrest.serialization.Model): """ _validation = { - 'principal_id': {'readonly': True}, - 'tenant_id': {'readonly': True}, + "principal_id": {"readonly": True}, + "tenant_id": {"readonly": True}, } _attribute_map = { - 'principal_id': {'key': 'principalId', 'type': 'str'}, - 'tenant_id': {'key': 'tenantId', 'type': 'str'}, - 'type': {'key': 'type', 'type': 'str'}, - 'user_assigned_identities': {'key': 'userAssignedIdentities', 'type': '{IdentityUserAssignedIdentitiesValue}'}, + "principal_id": {"key": "principalId", "type": "str"}, + "tenant_id": {"key": "tenantId", "type": "str"}, + "type": {"key": "type", "type": "str"}, + "user_assigned_identities": {"key": "userAssignedIdentities", "type": "{IdentityUserAssignedIdentitiesValue}"}, } def __init__( self, *, - type: Optional[Union[str, "ResourceIdentityType"]] = None, - user_assigned_identities: Optional[Dict[str, "IdentityUserAssignedIdentitiesValue"]] = None, + type: Optional[Union[str, "_models.ResourceIdentityType"]] = None, + user_assigned_identities: Optional[Dict[str, "_models.IdentityUserAssignedIdentitiesValue"]] = None, **kwargs ): """ - :keyword type: The identity type. Possible values include: "SystemAssigned", "UserAssigned", - "SystemAssigned, UserAssigned", "None". + :keyword type: The identity type. Known values are: "SystemAssigned", "UserAssigned", + "SystemAssigned, UserAssigned", and "None". :paramtype type: str or ~azure.mgmt.resource.resources.v2021_01_01.models.ResourceIdentityType :keyword user_assigned_identities: The list of user identities associated with the resource. The user identity dictionary key references will be ARM resource ids in the form: @@ -1710,14 +1649,14 @@ def __init__( :paramtype user_assigned_identities: dict[str, ~azure.mgmt.resource.resources.v2021_01_01.models.IdentityUserAssignedIdentitiesValue] """ - super(Identity, self).__init__(**kwargs) + super().__init__(**kwargs) self.principal_id = None self.tenant_id = None self.type = type self.user_assigned_identities = user_assigned_identities -class IdentityUserAssignedIdentitiesValue(msrest.serialization.Model): +class IdentityUserAssignedIdentitiesValue(_serialization.Model): """IdentityUserAssignedIdentitiesValue. Variables are only populated by the server, and will be ignored when sending a request. @@ -1729,61 +1668,57 @@ class IdentityUserAssignedIdentitiesValue(msrest.serialization.Model): """ _validation = { - 'principal_id': {'readonly': True}, - 'client_id': {'readonly': True}, + "principal_id": {"readonly": True}, + "client_id": {"readonly": True}, } _attribute_map = { - 'principal_id': {'key': 'principalId', 'type': 'str'}, - 'client_id': {'key': 'clientId', 'type': 'str'}, + "principal_id": {"key": "principalId", "type": "str"}, + "client_id": {"key": "clientId", "type": "str"}, } - def __init__( - self, - **kwargs - ): - """ - """ - super(IdentityUserAssignedIdentitiesValue, self).__init__(**kwargs) + def __init__(self, **kwargs): + """ """ + super().__init__(**kwargs) self.principal_id = None self.client_id = None -class OnErrorDeployment(msrest.serialization.Model): +class OnErrorDeployment(_serialization.Model): """Deployment on error behavior. :ivar type: The deployment on error behavior type. Possible values are LastSuccessful and - SpecificDeployment. Possible values include: "LastSuccessful", "SpecificDeployment". + SpecificDeployment. Known values are: "LastSuccessful" and "SpecificDeployment". :vartype type: str or ~azure.mgmt.resource.resources.v2021_01_01.models.OnErrorDeploymentType :ivar deployment_name: The deployment to be used on error case. :vartype deployment_name: str """ _attribute_map = { - 'type': {'key': 'type', 'type': 'str'}, - 'deployment_name': {'key': 'deploymentName', 'type': 'str'}, + "type": {"key": "type", "type": "str"}, + "deployment_name": {"key": "deploymentName", "type": "str"}, } def __init__( self, *, - type: Optional[Union[str, "OnErrorDeploymentType"]] = None, + type: Optional[Union[str, "_models.OnErrorDeploymentType"]] = None, deployment_name: Optional[str] = None, **kwargs ): """ :keyword type: The deployment on error behavior type. Possible values are LastSuccessful and - SpecificDeployment. Possible values include: "LastSuccessful", "SpecificDeployment". + SpecificDeployment. Known values are: "LastSuccessful" and "SpecificDeployment". :paramtype type: str or ~azure.mgmt.resource.resources.v2021_01_01.models.OnErrorDeploymentType :keyword deployment_name: The deployment to be used on error case. :paramtype deployment_name: str """ - super(OnErrorDeployment, self).__init__(**kwargs) + super().__init__(**kwargs) self.type = type self.deployment_name = deployment_name -class OnErrorDeploymentExtended(msrest.serialization.Model): +class OnErrorDeploymentExtended(_serialization.Model): """Deployment on error behavior with additional details. Variables are only populated by the server, and will be ignored when sending a request. @@ -1791,43 +1726,43 @@ class OnErrorDeploymentExtended(msrest.serialization.Model): :ivar provisioning_state: The state of the provisioning for the on error deployment. :vartype provisioning_state: str :ivar type: The deployment on error behavior type. Possible values are LastSuccessful and - SpecificDeployment. Possible values include: "LastSuccessful", "SpecificDeployment". + SpecificDeployment. Known values are: "LastSuccessful" and "SpecificDeployment". :vartype type: str or ~azure.mgmt.resource.resources.v2021_01_01.models.OnErrorDeploymentType :ivar deployment_name: The deployment to be used on error case. :vartype deployment_name: str """ _validation = { - 'provisioning_state': {'readonly': True}, + "provisioning_state": {"readonly": True}, } _attribute_map = { - 'provisioning_state': {'key': 'provisioningState', 'type': 'str'}, - 'type': {'key': 'type', 'type': 'str'}, - 'deployment_name': {'key': 'deploymentName', 'type': 'str'}, + "provisioning_state": {"key": "provisioningState", "type": "str"}, + "type": {"key": "type", "type": "str"}, + "deployment_name": {"key": "deploymentName", "type": "str"}, } def __init__( self, *, - type: Optional[Union[str, "OnErrorDeploymentType"]] = None, + type: Optional[Union[str, "_models.OnErrorDeploymentType"]] = None, deployment_name: Optional[str] = None, **kwargs ): """ :keyword type: The deployment on error behavior type. Possible values are LastSuccessful and - SpecificDeployment. Possible values include: "LastSuccessful", "SpecificDeployment". + SpecificDeployment. Known values are: "LastSuccessful" and "SpecificDeployment". :paramtype type: str or ~azure.mgmt.resource.resources.v2021_01_01.models.OnErrorDeploymentType :keyword deployment_name: The deployment to be used on error case. :paramtype deployment_name: str """ - super(OnErrorDeploymentExtended, self).__init__(**kwargs) + super().__init__(**kwargs) self.provisioning_state = None self.type = type self.deployment_name = deployment_name -class Operation(msrest.serialization.Model): +class Operation(_serialization.Model): """Microsoft.Resources operation. :ivar name: Operation name: {provider}/{resource}/{operation}. @@ -1837,29 +1772,23 @@ class Operation(msrest.serialization.Model): """ _attribute_map = { - 'name': {'key': 'name', 'type': 'str'}, - 'display': {'key': 'display', 'type': 'OperationDisplay'}, + "name": {"key": "name", "type": "str"}, + "display": {"key": "display", "type": "OperationDisplay"}, } - def __init__( - self, - *, - name: Optional[str] = None, - display: Optional["OperationDisplay"] = None, - **kwargs - ): + def __init__(self, *, name: Optional[str] = None, display: Optional["_models.OperationDisplay"] = None, **kwargs): """ :keyword name: Operation name: {provider}/{resource}/{operation}. :paramtype name: str :keyword display: The object that represents the operation. :paramtype display: ~azure.mgmt.resource.resources.v2021_01_01.models.OperationDisplay """ - super(Operation, self).__init__(**kwargs) + super().__init__(**kwargs) self.name = name self.display = display -class OperationDisplay(msrest.serialization.Model): +class OperationDisplay(_serialization.Model): """The object that represents the operation. :ivar provider: Service provider: Microsoft.Resources. @@ -1873,10 +1802,10 @@ class OperationDisplay(msrest.serialization.Model): """ _attribute_map = { - 'provider': {'key': 'provider', 'type': 'str'}, - 'resource': {'key': 'resource', 'type': 'str'}, - 'operation': {'key': 'operation', 'type': 'str'}, - 'description': {'key': 'description', 'type': 'str'}, + "provider": {"key": "provider", "type": "str"}, + "resource": {"key": "resource", "type": "str"}, + "operation": {"key": "operation", "type": "str"}, + "description": {"key": "description", "type": "str"}, } def __init__( @@ -1898,14 +1827,14 @@ def __init__( :keyword description: Description of the operation. :paramtype description: str """ - super(OperationDisplay, self).__init__(**kwargs) + super().__init__(**kwargs) self.provider = provider self.resource = resource self.operation = operation self.description = description -class OperationListResult(msrest.serialization.Model): +class OperationListResult(_serialization.Model): """Result of the request to list Microsoft.Resources operations. It contains a list of operations and a URL link to get the next set of results. :ivar value: List of Microsoft.Resources operations. @@ -1915,67 +1844,55 @@ class OperationListResult(msrest.serialization.Model): """ _attribute_map = { - 'value': {'key': 'value', 'type': '[Operation]'}, - 'next_link': {'key': 'nextLink', 'type': 'str'}, + "value": {"key": "value", "type": "[Operation]"}, + "next_link": {"key": "nextLink", "type": "str"}, } - def __init__( - self, - *, - value: Optional[List["Operation"]] = None, - next_link: Optional[str] = None, - **kwargs - ): + def __init__(self, *, value: Optional[List["_models.Operation"]] = None, next_link: Optional[str] = None, **kwargs): """ :keyword value: List of Microsoft.Resources operations. :paramtype value: list[~azure.mgmt.resource.resources.v2021_01_01.models.Operation] :keyword next_link: URL to get the next set of operation list results if there are any. :paramtype next_link: str """ - super(OperationListResult, self).__init__(**kwargs) + super().__init__(**kwargs) self.value = value self.next_link = next_link -class ParametersLink(msrest.serialization.Model): +class ParametersLink(_serialization.Model): """Entity representing the reference to the deployment parameters. All required parameters must be populated in order to send to Azure. - :ivar uri: Required. The URI of the parameters file. + :ivar uri: The URI of the parameters file. Required. :vartype uri: str :ivar content_version: If included, must match the ContentVersion in the template. :vartype content_version: str """ _validation = { - 'uri': {'required': True}, + "uri": {"required": True}, } _attribute_map = { - 'uri': {'key': 'uri', 'type': 'str'}, - 'content_version': {'key': 'contentVersion', 'type': 'str'}, + "uri": {"key": "uri", "type": "str"}, + "content_version": {"key": "contentVersion", "type": "str"}, } - def __init__( - self, - *, - uri: str, - content_version: Optional[str] = None, - **kwargs - ): + def __init__(self, *, uri: str, content_version: Optional[str] = None, **kwargs): """ - :keyword uri: Required. The URI of the parameters file. + :keyword uri: The URI of the parameters file. Required. :paramtype uri: str :keyword content_version: If included, must match the ContentVersion in the template. :paramtype content_version: str """ - super(ParametersLink, self).__init__(**kwargs) + super().__init__(**kwargs) self.uri = uri self.content_version = content_version -class Plan(msrest.serialization.Model): +class Plan(_serialization.Model): """Plan for the resource. :ivar name: The plan ID. @@ -1991,11 +1908,11 @@ class Plan(msrest.serialization.Model): """ _attribute_map = { - 'name': {'key': 'name', 'type': 'str'}, - 'publisher': {'key': 'publisher', 'type': 'str'}, - 'product': {'key': 'product', 'type': 'str'}, - 'promotion_code': {'key': 'promotionCode', 'type': 'str'}, - 'version': {'key': 'version', 'type': 'str'}, + "name": {"key": "name", "type": "str"}, + "publisher": {"key": "publisher", "type": "str"}, + "product": {"key": "product", "type": "str"}, + "promotion_code": {"key": "promotionCode", "type": "str"}, + "version": {"key": "version", "type": "str"}, } def __init__( @@ -2020,7 +1937,7 @@ def __init__( :keyword version: The plan's version. :paramtype version: str """ - super(Plan, self).__init__(**kwargs) + super().__init__(**kwargs) self.name = name self.publisher = publisher self.product = product @@ -2028,7 +1945,7 @@ def __init__( self.version = version -class Provider(msrest.serialization.Model): +class Provider(_serialization.Model): """Resource provider information. Variables are only populated by the server, and will be ignored when sending a request. @@ -2047,31 +1964,26 @@ class Provider(msrest.serialization.Model): """ _validation = { - 'id': {'readonly': True}, - 'registration_state': {'readonly': True}, - 'registration_policy': {'readonly': True}, - 'resource_types': {'readonly': True}, + "id": {"readonly": True}, + "registration_state": {"readonly": True}, + "registration_policy": {"readonly": True}, + "resource_types": {"readonly": True}, } _attribute_map = { - 'id': {'key': 'id', 'type': 'str'}, - 'namespace': {'key': 'namespace', 'type': 'str'}, - 'registration_state': {'key': 'registrationState', 'type': 'str'}, - 'registration_policy': {'key': 'registrationPolicy', 'type': 'str'}, - 'resource_types': {'key': 'resourceTypes', 'type': '[ProviderResourceType]'}, + "id": {"key": "id", "type": "str"}, + "namespace": {"key": "namespace", "type": "str"}, + "registration_state": {"key": "registrationState", "type": "str"}, + "registration_policy": {"key": "registrationPolicy", "type": "str"}, + "resource_types": {"key": "resourceTypes", "type": "[ProviderResourceType]"}, } - def __init__( - self, - *, - namespace: Optional[str] = None, - **kwargs - ): + def __init__(self, *, namespace: Optional[str] = None, **kwargs): """ :keyword namespace: The namespace of the resource provider. :paramtype namespace: str """ - super(Provider, self).__init__(**kwargs) + super().__init__(**kwargs) self.id = None self.namespace = namespace self.registration_state = None @@ -2079,7 +1991,7 @@ def __init__( self.resource_types = None -class ProviderExtendedLocation(msrest.serialization.Model): +class ProviderExtendedLocation(_serialization.Model): """The provider extended location. :ivar location: The azure location. @@ -2091,9 +2003,9 @@ class ProviderExtendedLocation(msrest.serialization.Model): """ _attribute_map = { - 'location': {'key': 'location', 'type': 'str'}, - 'type': {'key': 'type', 'type': 'str'}, - 'extended_locations': {'key': 'extendedLocations', 'type': '[str]'}, + "location": {"key": "location", "type": "str"}, + "type": {"key": "type", "type": "str"}, + "extended_locations": {"key": "extendedLocations", "type": "[str]"}, } def __init__( @@ -2112,13 +2024,13 @@ def __init__( :keyword extended_locations: The extended locations for the azure location. :paramtype extended_locations: list[str] """ - super(ProviderExtendedLocation, self).__init__(**kwargs) + super().__init__(**kwargs) self.location = location self.type = type self.extended_locations = extended_locations -class ProviderListResult(msrest.serialization.Model): +class ProviderListResult(_serialization.Model): """List of resource providers. Variables are only populated by the server, and will be ignored when sending a request. @@ -2130,30 +2042,25 @@ class ProviderListResult(msrest.serialization.Model): """ _validation = { - 'next_link': {'readonly': True}, + "next_link": {"readonly": True}, } _attribute_map = { - 'value': {'key': 'value', 'type': '[Provider]'}, - 'next_link': {'key': 'nextLink', 'type': 'str'}, + "value": {"key": "value", "type": "[Provider]"}, + "next_link": {"key": "nextLink", "type": "str"}, } - def __init__( - self, - *, - value: Optional[List["Provider"]] = None, - **kwargs - ): + def __init__(self, *, value: Optional[List["_models.Provider"]] = None, **kwargs): """ :keyword value: An array of resource providers. :paramtype value: list[~azure.mgmt.resource.resources.v2021_01_01.models.Provider] """ - super(ProviderListResult, self).__init__(**kwargs) + super().__init__(**kwargs) self.value = value self.next_link = None -class ProviderResourceType(msrest.serialization.Model): +class ProviderResourceType(_serialization.Model): """Resource type managed by the resource provider. Variables are only populated by the server, and will be ignored when sending a request. @@ -2182,21 +2089,21 @@ class ProviderResourceType(msrest.serialization.Model): """ _validation = { - 'default_api_version': {'readonly': True}, - 'api_profiles': {'readonly': True}, + "default_api_version": {"readonly": True}, + "api_profiles": {"readonly": True}, } _attribute_map = { - 'resource_type': {'key': 'resourceType', 'type': 'str'}, - 'locations': {'key': 'locations', 'type': '[str]'}, - 'location_mappings': {'key': 'locationMappings', 'type': '[ProviderExtendedLocation]'}, - 'aliases': {'key': 'aliases', 'type': '[Alias]'}, - 'api_versions': {'key': 'apiVersions', 'type': '[str]'}, - 'default_api_version': {'key': 'defaultApiVersion', 'type': 'str'}, - 'zone_mappings': {'key': 'zoneMappings', 'type': '[ZoneMapping]'}, - 'api_profiles': {'key': 'apiProfiles', 'type': '[ApiProfile]'}, - 'capabilities': {'key': 'capabilities', 'type': 'str'}, - 'properties': {'key': 'properties', 'type': '{str}'}, + "resource_type": {"key": "resourceType", "type": "str"}, + "locations": {"key": "locations", "type": "[str]"}, + "location_mappings": {"key": "locationMappings", "type": "[ProviderExtendedLocation]"}, + "aliases": {"key": "aliases", "type": "[Alias]"}, + "api_versions": {"key": "apiVersions", "type": "[str]"}, + "default_api_version": {"key": "defaultApiVersion", "type": "str"}, + "zone_mappings": {"key": "zoneMappings", "type": "[ZoneMapping]"}, + "api_profiles": {"key": "apiProfiles", "type": "[ApiProfile]"}, + "capabilities": {"key": "capabilities", "type": "str"}, + "properties": {"key": "properties", "type": "{str}"}, } def __init__( @@ -2204,10 +2111,10 @@ def __init__( *, resource_type: Optional[str] = None, locations: Optional[List[str]] = None, - location_mappings: Optional[List["ProviderExtendedLocation"]] = None, - aliases: Optional[List["Alias"]] = None, + location_mappings: Optional[List["_models.ProviderExtendedLocation"]] = None, + aliases: Optional[List["_models.Alias"]] = None, api_versions: Optional[List[str]] = None, - zone_mappings: Optional[List["ZoneMapping"]] = None, + zone_mappings: Optional[List["_models.ZoneMapping"]] = None, capabilities: Optional[str] = None, properties: Optional[Dict[str, str]] = None, **kwargs @@ -2231,7 +2138,7 @@ def __init__( :keyword properties: The properties. :paramtype properties: dict[str, str] """ - super(ProviderResourceType, self).__init__(**kwargs) + super().__init__(**kwargs) self.resource_type = resource_type self.locations = locations self.location_mappings = location_mappings @@ -2244,7 +2151,7 @@ def __init__( self.properties = properties -class ProviderResourceTypeListResult(msrest.serialization.Model): +class ProviderResourceTypeListResult(_serialization.Model): """List of resource types of a resource provider. Variables are only populated by the server, and will be ignored when sending a request. @@ -2256,30 +2163,25 @@ class ProviderResourceTypeListResult(msrest.serialization.Model): """ _validation = { - 'next_link': {'readonly': True}, + "next_link": {"readonly": True}, } _attribute_map = { - 'value': {'key': 'value', 'type': '[ProviderResourceType]'}, - 'next_link': {'key': 'nextLink', 'type': 'str'}, + "value": {"key": "value", "type": "[ProviderResourceType]"}, + "next_link": {"key": "nextLink", "type": "str"}, } - def __init__( - self, - *, - value: Optional[List["ProviderResourceType"]] = None, - **kwargs - ): + def __init__(self, *, value: Optional[List["_models.ProviderResourceType"]] = None, **kwargs): """ :keyword value: An array of resource types. :paramtype value: list[~azure.mgmt.resource.resources.v2021_01_01.models.ProviderResourceType] """ - super(ProviderResourceTypeListResult, self).__init__(**kwargs) + super().__init__(**kwargs) self.value = value self.next_link = None -class ResourceGroup(msrest.serialization.Model): +class ResourceGroup(_serialization.Model): """Resource group information. Variables are only populated by the server, and will be ignored when sending a request. @@ -2294,37 +2196,37 @@ class ResourceGroup(msrest.serialization.Model): :vartype type: str :ivar properties: The resource group properties. :vartype properties: ~azure.mgmt.resource.resources.v2021_01_01.models.ResourceGroupProperties - :ivar location: Required. The location of the resource group. It cannot be changed after the - resource group has been created. It must be one of the supported Azure locations. + :ivar location: The location of the resource group. It cannot be changed after the resource + group has been created. It must be one of the supported Azure locations. Required. :vartype location: str :ivar managed_by: The ID of the resource that manages this resource group. :vartype managed_by: str - :ivar tags: A set of tags. The tags attached to the resource group. + :ivar tags: The tags attached to the resource group. :vartype tags: dict[str, str] """ _validation = { - 'id': {'readonly': True}, - 'name': {'readonly': True}, - 'type': {'readonly': True}, - 'location': {'required': True}, + "id": {"readonly": True}, + "name": {"readonly": True}, + "type": {"readonly": True}, + "location": {"required": True}, } _attribute_map = { - 'id': {'key': 'id', 'type': 'str'}, - 'name': {'key': 'name', 'type': 'str'}, - 'type': {'key': 'type', 'type': 'str'}, - 'properties': {'key': 'properties', 'type': 'ResourceGroupProperties'}, - 'location': {'key': 'location', 'type': 'str'}, - 'managed_by': {'key': 'managedBy', 'type': 'str'}, - 'tags': {'key': 'tags', 'type': '{str}'}, + "id": {"key": "id", "type": "str"}, + "name": {"key": "name", "type": "str"}, + "type": {"key": "type", "type": "str"}, + "properties": {"key": "properties", "type": "ResourceGroupProperties"}, + "location": {"key": "location", "type": "str"}, + "managed_by": {"key": "managedBy", "type": "str"}, + "tags": {"key": "tags", "type": "{str}"}, } def __init__( self, *, location: str, - properties: Optional["ResourceGroupProperties"] = None, + properties: Optional["_models.ResourceGroupProperties"] = None, managed_by: Optional[str] = None, tags: Optional[Dict[str, str]] = None, **kwargs @@ -2333,15 +2235,15 @@ def __init__( :keyword properties: The resource group properties. :paramtype properties: ~azure.mgmt.resource.resources.v2021_01_01.models.ResourceGroupProperties - :keyword location: Required. The location of the resource group. It cannot be changed after the - resource group has been created. It must be one of the supported Azure locations. + :keyword location: The location of the resource group. It cannot be changed after the resource + group has been created. It must be one of the supported Azure locations. Required. :paramtype location: str :keyword managed_by: The ID of the resource that manages this resource group. :paramtype managed_by: str - :keyword tags: A set of tags. The tags attached to the resource group. + :keyword tags: The tags attached to the resource group. :paramtype tags: dict[str, str] """ - super(ResourceGroup, self).__init__(**kwargs) + super().__init__(**kwargs) self.id = None self.name = None self.type = None @@ -2351,39 +2253,33 @@ def __init__( self.tags = tags -class ResourceGroupExportResult(msrest.serialization.Model): +class ResourceGroupExportResult(_serialization.Model): """Resource group export result. :ivar template: The template content. - :vartype template: any + :vartype template: JSON :ivar error: The template export error. :vartype error: ~azure.mgmt.resource.resources.v2021_01_01.models.ErrorResponse """ _attribute_map = { - 'template': {'key': 'template', 'type': 'object'}, - 'error': {'key': 'error', 'type': 'ErrorResponse'}, + "template": {"key": "template", "type": "object"}, + "error": {"key": "error", "type": "ErrorResponse"}, } - def __init__( - self, - *, - template: Optional[Any] = None, - error: Optional["ErrorResponse"] = None, - **kwargs - ): + def __init__(self, *, template: Optional[JSON] = None, error: Optional["_models.ErrorResponse"] = None, **kwargs): """ :keyword template: The template content. - :paramtype template: any + :paramtype template: JSON :keyword error: The template export error. :paramtype error: ~azure.mgmt.resource.resources.v2021_01_01.models.ErrorResponse """ - super(ResourceGroupExportResult, self).__init__(**kwargs) + super().__init__(**kwargs) self.template = template self.error = error -class ResourceGroupFilter(msrest.serialization.Model): +class ResourceGroupFilter(_serialization.Model): """Resource group filter. :ivar tag_name: The tag name. @@ -2393,29 +2289,23 @@ class ResourceGroupFilter(msrest.serialization.Model): """ _attribute_map = { - 'tag_name': {'key': 'tagName', 'type': 'str'}, - 'tag_value': {'key': 'tagValue', 'type': 'str'}, + "tag_name": {"key": "tagName", "type": "str"}, + "tag_value": {"key": "tagValue", "type": "str"}, } - def __init__( - self, - *, - tag_name: Optional[str] = None, - tag_value: Optional[str] = None, - **kwargs - ): + def __init__(self, *, tag_name: Optional[str] = None, tag_value: Optional[str] = None, **kwargs): """ :keyword tag_name: The tag name. :paramtype tag_name: str :keyword tag_value: The tag value. :paramtype tag_value: str """ - super(ResourceGroupFilter, self).__init__(**kwargs) + super().__init__(**kwargs) self.tag_name = tag_name self.tag_value = tag_value -class ResourceGroupListResult(msrest.serialization.Model): +class ResourceGroupListResult(_serialization.Model): """List of resource groups. Variables are only populated by the server, and will be ignored when sending a request. @@ -2427,30 +2317,25 @@ class ResourceGroupListResult(msrest.serialization.Model): """ _validation = { - 'next_link': {'readonly': True}, + "next_link": {"readonly": True}, } _attribute_map = { - 'value': {'key': 'value', 'type': '[ResourceGroup]'}, - 'next_link': {'key': 'nextLink', 'type': 'str'}, + "value": {"key": "value", "type": "[ResourceGroup]"}, + "next_link": {"key": "nextLink", "type": "str"}, } - def __init__( - self, - *, - value: Optional[List["ResourceGroup"]] = None, - **kwargs - ): + def __init__(self, *, value: Optional[List["_models.ResourceGroup"]] = None, **kwargs): """ :keyword value: An array of resource groups. :paramtype value: list[~azure.mgmt.resource.resources.v2021_01_01.models.ResourceGroup] """ - super(ResourceGroupListResult, self).__init__(**kwargs) + super().__init__(**kwargs) self.value = value self.next_link = None -class ResourceGroupPatchable(msrest.serialization.Model): +class ResourceGroupPatchable(_serialization.Model): """Resource group information. :ivar name: The name of the resource group. @@ -2459,22 +2344,22 @@ class ResourceGroupPatchable(msrest.serialization.Model): :vartype properties: ~azure.mgmt.resource.resources.v2021_01_01.models.ResourceGroupProperties :ivar managed_by: The ID of the resource that manages this resource group. :vartype managed_by: str - :ivar tags: A set of tags. The tags attached to the resource group. + :ivar tags: The tags attached to the resource group. :vartype tags: dict[str, str] """ _attribute_map = { - 'name': {'key': 'name', 'type': 'str'}, - 'properties': {'key': 'properties', 'type': 'ResourceGroupProperties'}, - 'managed_by': {'key': 'managedBy', 'type': 'str'}, - 'tags': {'key': 'tags', 'type': '{str}'}, + "name": {"key": "name", "type": "str"}, + "properties": {"key": "properties", "type": "ResourceGroupProperties"}, + "managed_by": {"key": "managedBy", "type": "str"}, + "tags": {"key": "tags", "type": "{str}"}, } def __init__( self, *, name: Optional[str] = None, - properties: Optional["ResourceGroupProperties"] = None, + properties: Optional["_models.ResourceGroupProperties"] = None, managed_by: Optional[str] = None, tags: Optional[Dict[str, str]] = None, **kwargs @@ -2487,17 +2372,17 @@ def __init__( ~azure.mgmt.resource.resources.v2021_01_01.models.ResourceGroupProperties :keyword managed_by: The ID of the resource that manages this resource group. :paramtype managed_by: str - :keyword tags: A set of tags. The tags attached to the resource group. + :keyword tags: The tags attached to the resource group. :paramtype tags: dict[str, str] """ - super(ResourceGroupPatchable, self).__init__(**kwargs) + super().__init__(**kwargs) self.name = name self.properties = properties self.managed_by = managed_by self.tags = tags -class ResourceGroupProperties(msrest.serialization.Model): +class ResourceGroupProperties(_serialization.Model): """The resource group properties. Variables are only populated by the server, and will be ignored when sending a request. @@ -2507,24 +2392,20 @@ class ResourceGroupProperties(msrest.serialization.Model): """ _validation = { - 'provisioning_state': {'readonly': True}, + "provisioning_state": {"readonly": True}, } _attribute_map = { - 'provisioning_state': {'key': 'provisioningState', 'type': 'str'}, + "provisioning_state": {"key": "provisioningState", "type": "str"}, } - def __init__( - self, - **kwargs - ): - """ - """ - super(ResourceGroupProperties, self).__init__(**kwargs) + def __init__(self, **kwargs): + """ """ + super().__init__(**kwargs) self.provisioning_state = None -class ResourceListResult(msrest.serialization.Model): +class ResourceListResult(_serialization.Model): """List of resource groups. Variables are only populated by the server, and will be ignored when sending a request. @@ -2536,31 +2417,26 @@ class ResourceListResult(msrest.serialization.Model): """ _validation = { - 'next_link': {'readonly': True}, + "next_link": {"readonly": True}, } _attribute_map = { - 'value': {'key': 'value', 'type': '[GenericResourceExpanded]'}, - 'next_link': {'key': 'nextLink', 'type': 'str'}, + "value": {"key": "value", "type": "[GenericResourceExpanded]"}, + "next_link": {"key": "nextLink", "type": "str"}, } - def __init__( - self, - *, - value: Optional[List["GenericResourceExpanded"]] = None, - **kwargs - ): + def __init__(self, *, value: Optional[List["_models.GenericResourceExpanded"]] = None, **kwargs): """ :keyword value: An array of resources. :paramtype value: list[~azure.mgmt.resource.resources.v2021_01_01.models.GenericResourceExpanded] """ - super(ResourceListResult, self).__init__(**kwargs) + super().__init__(**kwargs) self.value = value self.next_link = None -class ResourceProviderOperationDisplayProperties(msrest.serialization.Model): +class ResourceProviderOperationDisplayProperties(_serialization.Model): """Resource provider operation's display properties. :ivar publisher: Operation description. @@ -2576,11 +2452,11 @@ class ResourceProviderOperationDisplayProperties(msrest.serialization.Model): """ _attribute_map = { - 'publisher': {'key': 'publisher', 'type': 'str'}, - 'provider': {'key': 'provider', 'type': 'str'}, - 'resource': {'key': 'resource', 'type': 'str'}, - 'operation': {'key': 'operation', 'type': 'str'}, - 'description': {'key': 'description', 'type': 'str'}, + "publisher": {"key": "publisher", "type": "str"}, + "provider": {"key": "provider", "type": "str"}, + "resource": {"key": "resource", "type": "str"}, + "operation": {"key": "operation", "type": "str"}, + "description": {"key": "description", "type": "str"}, } def __init__( @@ -2605,7 +2481,7 @@ def __init__( :keyword description: Operation description. :paramtype description: str """ - super(ResourceProviderOperationDisplayProperties, self).__init__(**kwargs) + super().__init__(**kwargs) self.publisher = publisher self.provider = provider self.resource = resource @@ -2613,7 +2489,7 @@ def __init__( self.description = description -class ResourceReference(msrest.serialization.Model): +class ResourceReference(_serialization.Model): """The resource Id model. Variables are only populated by the server, and will be ignored when sending a request. @@ -2623,24 +2499,20 @@ class ResourceReference(msrest.serialization.Model): """ _validation = { - 'id': {'readonly': True}, + "id": {"readonly": True}, } _attribute_map = { - 'id': {'key': 'id', 'type': 'str'}, + "id": {"key": "id", "type": "str"}, } - def __init__( - self, - **kwargs - ): - """ - """ - super(ResourceReference, self).__init__(**kwargs) + def __init__(self, **kwargs): + """ """ + super().__init__(**kwargs) self.id = None -class ResourcesMoveInfo(msrest.serialization.Model): +class ResourcesMoveInfo(_serialization.Model): """Parameters of move resources. :ivar resources: The IDs of the resources. @@ -2650,116 +2522,104 @@ class ResourcesMoveInfo(msrest.serialization.Model): """ _attribute_map = { - 'resources': {'key': 'resources', 'type': '[str]'}, - 'target_resource_group': {'key': 'targetResourceGroup', 'type': 'str'}, + "resources": {"key": "resources", "type": "[str]"}, + "target_resource_group": {"key": "targetResourceGroup", "type": "str"}, } - def __init__( - self, - *, - resources: Optional[List[str]] = None, - target_resource_group: Optional[str] = None, - **kwargs - ): + def __init__(self, *, resources: Optional[List[str]] = None, target_resource_group: Optional[str] = None, **kwargs): """ :keyword resources: The IDs of the resources. :paramtype resources: list[str] :keyword target_resource_group: The target resource group. :paramtype target_resource_group: str """ - super(ResourcesMoveInfo, self).__init__(**kwargs) + super().__init__(**kwargs) self.resources = resources self.target_resource_group = target_resource_group -class ScopedDeployment(msrest.serialization.Model): +class ScopedDeployment(_serialization.Model): """Deployment operation parameters. All required parameters must be populated in order to send to Azure. - :ivar location: Required. The location to store the deployment data. + :ivar location: The location to store the deployment data. Required. :vartype location: str - :ivar properties: Required. The deployment properties. + :ivar properties: The deployment properties. Required. :vartype properties: ~azure.mgmt.resource.resources.v2021_01_01.models.DeploymentProperties - :ivar tags: A set of tags. Deployment tags. + :ivar tags: Deployment tags. :vartype tags: dict[str, str] """ _validation = { - 'location': {'required': True}, - 'properties': {'required': True}, + "location": {"required": True}, + "properties": {"required": True}, } _attribute_map = { - 'location': {'key': 'location', 'type': 'str'}, - 'properties': {'key': 'properties', 'type': 'DeploymentProperties'}, - 'tags': {'key': 'tags', 'type': '{str}'}, + "location": {"key": "location", "type": "str"}, + "properties": {"key": "properties", "type": "DeploymentProperties"}, + "tags": {"key": "tags", "type": "{str}"}, } def __init__( self, *, location: str, - properties: "DeploymentProperties", + properties: "_models.DeploymentProperties", tags: Optional[Dict[str, str]] = None, **kwargs ): """ - :keyword location: Required. The location to store the deployment data. + :keyword location: The location to store the deployment data. Required. :paramtype location: str - :keyword properties: Required. The deployment properties. + :keyword properties: The deployment properties. Required. :paramtype properties: ~azure.mgmt.resource.resources.v2021_01_01.models.DeploymentProperties - :keyword tags: A set of tags. Deployment tags. + :keyword tags: Deployment tags. :paramtype tags: dict[str, str] """ - super(ScopedDeployment, self).__init__(**kwargs) + super().__init__(**kwargs) self.location = location self.properties = properties self.tags = tags -class ScopedDeploymentWhatIf(msrest.serialization.Model): +class ScopedDeploymentWhatIf(_serialization.Model): """Deployment What-if operation parameters. All required parameters must be populated in order to send to Azure. - :ivar location: Required. The location to store the deployment data. + :ivar location: The location to store the deployment data. Required. :vartype location: str - :ivar properties: Required. The deployment properties. + :ivar properties: The deployment properties. Required. :vartype properties: ~azure.mgmt.resource.resources.v2021_01_01.models.DeploymentWhatIfProperties """ _validation = { - 'location': {'required': True}, - 'properties': {'required': True}, + "location": {"required": True}, + "properties": {"required": True}, } _attribute_map = { - 'location': {'key': 'location', 'type': 'str'}, - 'properties': {'key': 'properties', 'type': 'DeploymentWhatIfProperties'}, + "location": {"key": "location", "type": "str"}, + "properties": {"key": "properties", "type": "DeploymentWhatIfProperties"}, } - def __init__( - self, - *, - location: str, - properties: "DeploymentWhatIfProperties", - **kwargs - ): + def __init__(self, *, location: str, properties: "_models.DeploymentWhatIfProperties", **kwargs): """ - :keyword location: Required. The location to store the deployment data. + :keyword location: The location to store the deployment data. Required. :paramtype location: str - :keyword properties: Required. The deployment properties. + :keyword properties: The deployment properties. Required. :paramtype properties: ~azure.mgmt.resource.resources.v2021_01_01.models.DeploymentWhatIfProperties """ - super(ScopedDeploymentWhatIf, self).__init__(**kwargs) + super().__init__(**kwargs) self.location = location self.properties = properties -class Sku(msrest.serialization.Model): +class Sku(_serialization.Model): """SKU for the resource. :ivar name: The SKU name. @@ -2777,12 +2637,12 @@ class Sku(msrest.serialization.Model): """ _attribute_map = { - 'name': {'key': 'name', 'type': 'str'}, - 'tier': {'key': 'tier', 'type': 'str'}, - 'size': {'key': 'size', 'type': 'str'}, - 'family': {'key': 'family', 'type': 'str'}, - 'model': {'key': 'model', 'type': 'str'}, - 'capacity': {'key': 'capacity', 'type': 'int'}, + "name": {"key": "name", "type": "str"}, + "tier": {"key": "tier", "type": "str"}, + "size": {"key": "size", "type": "str"}, + "family": {"key": "family", "type": "str"}, + "model": {"key": "model", "type": "str"}, + "capacity": {"key": "capacity", "type": "int"}, } def __init__( @@ -2810,7 +2670,7 @@ def __init__( :keyword capacity: The SKU capacity. :paramtype capacity: int """ - super(Sku, self).__init__(**kwargs) + super().__init__(**kwargs) self.name = name self.tier = tier self.size = size @@ -2819,7 +2679,7 @@ def __init__( self.capacity = capacity -class StatusMessage(msrest.serialization.Model): +class StatusMessage(_serialization.Model): """Operation status message object. :ivar status: Status of the deployment operation. @@ -2829,29 +2689,23 @@ class StatusMessage(msrest.serialization.Model): """ _attribute_map = { - 'status': {'key': 'status', 'type': 'str'}, - 'error': {'key': 'error', 'type': 'ErrorResponse'}, + "status": {"key": "status", "type": "str"}, + "error": {"key": "error", "type": "ErrorResponse"}, } - def __init__( - self, - *, - status: Optional[str] = None, - error: Optional["ErrorResponse"] = None, - **kwargs - ): + def __init__(self, *, status: Optional[str] = None, error: Optional["_models.ErrorResponse"] = None, **kwargs): """ :keyword status: Status of the deployment operation. :paramtype status: str :keyword error: The error reported by the operation. :paramtype error: ~azure.mgmt.resource.resources.v2021_01_01.models.ErrorResponse """ - super(StatusMessage, self).__init__(**kwargs) + super().__init__(**kwargs) self.status = status self.error = error -class SubResource(msrest.serialization.Model): +class SubResource(_serialization.Model): """Sub-resource. :ivar id: Resource ID. @@ -2859,24 +2713,19 @@ class SubResource(msrest.serialization.Model): """ _attribute_map = { - 'id': {'key': 'id', 'type': 'str'}, + "id": {"key": "id", "type": "str"}, } - def __init__( - self, - *, - id: Optional[str] = None, - **kwargs - ): + def __init__(self, *, id: Optional[str] = None, **kwargs): # pylint: disable=redefined-builtin """ :keyword id: Resource ID. :paramtype id: str """ - super(SubResource, self).__init__(**kwargs) + super().__init__(**kwargs) self.id = id -class TagCount(msrest.serialization.Model): +class TagCount(_serialization.Model): """Tag count. :ivar type: Type of count. @@ -2886,29 +2735,23 @@ class TagCount(msrest.serialization.Model): """ _attribute_map = { - 'type': {'key': 'type', 'type': 'str'}, - 'value': {'key': 'value', 'type': 'int'}, + "type": {"key": "type", "type": "str"}, + "value": {"key": "value", "type": "int"}, } - def __init__( - self, - *, - type: Optional[str] = None, - value: Optional[int] = None, - **kwargs - ): + def __init__(self, *, type: Optional[str] = None, value: Optional[int] = None, **kwargs): """ :keyword type: Type of count. :paramtype type: str :keyword value: Value of count. :paramtype value: int """ - super(TagCount, self).__init__(**kwargs) + super().__init__(**kwargs) self.type = type self.value = value -class TagDetails(msrest.serialization.Model): +class TagDetails(_serialization.Model): """Tag details. Variables are only populated by the server, and will be ignored when sending a request. @@ -2925,22 +2768,22 @@ class TagDetails(msrest.serialization.Model): """ _validation = { - 'id': {'readonly': True}, + "id": {"readonly": True}, } _attribute_map = { - 'id': {'key': 'id', 'type': 'str'}, - 'tag_name': {'key': 'tagName', 'type': 'str'}, - 'count': {'key': 'count', 'type': 'TagCount'}, - 'values': {'key': 'values', 'type': '[TagValue]'}, + "id": {"key": "id", "type": "str"}, + "tag_name": {"key": "tagName", "type": "str"}, + "count": {"key": "count", "type": "TagCount"}, + "values": {"key": "values", "type": "[TagValue]"}, } def __init__( self, *, tag_name: Optional[str] = None, - count: Optional["TagCount"] = None, - values: Optional[List["TagValue"]] = None, + count: Optional["_models.TagCount"] = None, + values: Optional[List["_models.TagValue"]] = None, **kwargs ): """ @@ -2952,39 +2795,34 @@ def __init__( :keyword values: The list of tag values. :paramtype values: list[~azure.mgmt.resource.resources.v2021_01_01.models.TagValue] """ - super(TagDetails, self).__init__(**kwargs) + super().__init__(**kwargs) self.id = None self.tag_name = tag_name self.count = count self.values = values -class Tags(msrest.serialization.Model): +class Tags(_serialization.Model): """A dictionary of name and value pairs. - :ivar tags: A set of tags. Dictionary of :code:``. + :ivar tags: Dictionary of :code:``. :vartype tags: dict[str, str] """ _attribute_map = { - 'tags': {'key': 'tags', 'type': '{str}'}, + "tags": {"key": "tags", "type": "{str}"}, } - def __init__( - self, - *, - tags: Optional[Dict[str, str]] = None, - **kwargs - ): + def __init__(self, *, tags: Optional[Dict[str, str]] = None, **kwargs): """ - :keyword tags: A set of tags. Dictionary of :code:``. + :keyword tags: Dictionary of :code:``. :paramtype tags: dict[str, str] """ - super(Tags, self).__init__(**kwargs) + super().__init__(**kwargs) self.tags = tags -class TagsListResult(msrest.serialization.Model): +class TagsListResult(_serialization.Model): """List of subscription tags. Variables are only populated by the server, and will be ignored when sending a request. @@ -2996,65 +2834,60 @@ class TagsListResult(msrest.serialization.Model): """ _validation = { - 'next_link': {'readonly': True}, + "next_link": {"readonly": True}, } _attribute_map = { - 'value': {'key': 'value', 'type': '[TagDetails]'}, - 'next_link': {'key': 'nextLink', 'type': 'str'}, + "value": {"key": "value", "type": "[TagDetails]"}, + "next_link": {"key": "nextLink", "type": "str"}, } - def __init__( - self, - *, - value: Optional[List["TagDetails"]] = None, - **kwargs - ): + def __init__(self, *, value: Optional[List["_models.TagDetails"]] = None, **kwargs): """ :keyword value: An array of tags. :paramtype value: list[~azure.mgmt.resource.resources.v2021_01_01.models.TagDetails] """ - super(TagsListResult, self).__init__(**kwargs) + super().__init__(**kwargs) self.value = value self.next_link = None -class TagsPatchResource(msrest.serialization.Model): +class TagsPatchResource(_serialization.Model): """Wrapper resource for tags patch API request only. - :ivar operation: The operation type for the patch API. Possible values include: "Replace", - "Merge", "Delete". + :ivar operation: The operation type for the patch API. Known values are: "Replace", "Merge", + and "Delete". :vartype operation: str or ~azure.mgmt.resource.resources.v2021_01_01.models.TagsPatchOperation :ivar properties: The set of tags. :vartype properties: ~azure.mgmt.resource.resources.v2021_01_01.models.Tags """ _attribute_map = { - 'operation': {'key': 'operation', 'type': 'str'}, - 'properties': {'key': 'properties', 'type': 'Tags'}, + "operation": {"key": "operation", "type": "str"}, + "properties": {"key": "properties", "type": "Tags"}, } def __init__( self, *, - operation: Optional[Union[str, "TagsPatchOperation"]] = None, - properties: Optional["Tags"] = None, + operation: Optional[Union[str, "_models.TagsPatchOperation"]] = None, + properties: Optional["_models.Tags"] = None, **kwargs ): """ - :keyword operation: The operation type for the patch API. Possible values include: "Replace", - "Merge", "Delete". + :keyword operation: The operation type for the patch API. Known values are: "Replace", "Merge", + and "Delete". :paramtype operation: str or ~azure.mgmt.resource.resources.v2021_01_01.models.TagsPatchOperation :keyword properties: The set of tags. :paramtype properties: ~azure.mgmt.resource.resources.v2021_01_01.models.Tags """ - super(TagsPatchResource, self).__init__(**kwargs) + super().__init__(**kwargs) self.operation = operation self.properties = properties -class TagsResource(msrest.serialization.Model): +class TagsResource(_serialization.Model): """Wrapper resource for tags API requests and responses. Variables are only populated by the server, and will be ignored when sending a request. @@ -3067,42 +2900,37 @@ class TagsResource(msrest.serialization.Model): :vartype name: str :ivar type: The type of the tags wrapper resource. :vartype type: str - :ivar properties: Required. The set of tags. + :ivar properties: The set of tags. Required. :vartype properties: ~azure.mgmt.resource.resources.v2021_01_01.models.Tags """ _validation = { - 'id': {'readonly': True}, - 'name': {'readonly': True}, - 'type': {'readonly': True}, - 'properties': {'required': True}, + "id": {"readonly": True}, + "name": {"readonly": True}, + "type": {"readonly": True}, + "properties": {"required": True}, } _attribute_map = { - 'id': {'key': 'id', 'type': 'str'}, - 'name': {'key': 'name', 'type': 'str'}, - 'type': {'key': 'type', 'type': 'str'}, - 'properties': {'key': 'properties', 'type': 'Tags'}, + "id": {"key": "id", "type": "str"}, + "name": {"key": "name", "type": "str"}, + "type": {"key": "type", "type": "str"}, + "properties": {"key": "properties", "type": "Tags"}, } - def __init__( - self, - *, - properties: "Tags", - **kwargs - ): + def __init__(self, *, properties: "_models.Tags", **kwargs): """ - :keyword properties: Required. The set of tags. + :keyword properties: The set of tags. Required. :paramtype properties: ~azure.mgmt.resource.resources.v2021_01_01.models.Tags """ - super(TagsResource, self).__init__(**kwargs) + super().__init__(**kwargs) self.id = None self.name = None self.type = None self.properties = properties -class TagValue(msrest.serialization.Model): +class TagValue(_serialization.Model): """Tag information. Variables are only populated by the server, and will be ignored when sending a request. @@ -3116,35 +2944,29 @@ class TagValue(msrest.serialization.Model): """ _validation = { - 'id': {'readonly': True}, + "id": {"readonly": True}, } _attribute_map = { - 'id': {'key': 'id', 'type': 'str'}, - 'tag_value': {'key': 'tagValue', 'type': 'str'}, - 'count': {'key': 'count', 'type': 'TagCount'}, + "id": {"key": "id", "type": "str"}, + "tag_value": {"key": "tagValue", "type": "str"}, + "count": {"key": "count", "type": "TagCount"}, } - def __init__( - self, - *, - tag_value: Optional[str] = None, - count: Optional["TagCount"] = None, - **kwargs - ): + def __init__(self, *, tag_value: Optional[str] = None, count: Optional["_models.TagCount"] = None, **kwargs): """ :keyword tag_value: The tag value. :paramtype tag_value: str :keyword count: The tag value count. :paramtype count: ~azure.mgmt.resource.resources.v2021_01_01.models.TagCount """ - super(TagValue, self).__init__(**kwargs) + super().__init__(**kwargs) self.id = None self.tag_value = tag_value self.count = count -class TargetResource(msrest.serialization.Model): +class TargetResource(_serialization.Model): """Target resource. :ivar id: The ID of the resource. @@ -3156,15 +2978,15 @@ class TargetResource(msrest.serialization.Model): """ _attribute_map = { - 'id': {'key': 'id', 'type': 'str'}, - 'resource_name': {'key': 'resourceName', 'type': 'str'}, - 'resource_type': {'key': 'resourceType', 'type': 'str'}, + "id": {"key": "id", "type": "str"}, + "resource_name": {"key": "resourceName", "type": "str"}, + "resource_type": {"key": "resourceType", "type": "str"}, } def __init__( self, *, - id: Optional[str] = None, + id: Optional[str] = None, # pylint: disable=redefined-builtin resource_name: Optional[str] = None, resource_type: Optional[str] = None, **kwargs @@ -3177,13 +2999,13 @@ def __init__( :keyword resource_type: The type of the resource. :paramtype resource_type: str """ - super(TargetResource, self).__init__(**kwargs) + super().__init__(**kwargs) self.id = id self.resource_name = resource_name self.resource_type = resource_type -class TemplateHashResult(msrest.serialization.Model): +class TemplateHashResult(_serialization.Model): """Result of the request to calculate template hash. It contains a string of minified template and its hash. :ivar minified_template: The minified template string. @@ -3193,29 +3015,23 @@ class TemplateHashResult(msrest.serialization.Model): """ _attribute_map = { - 'minified_template': {'key': 'minifiedTemplate', 'type': 'str'}, - 'template_hash': {'key': 'templateHash', 'type': 'str'}, + "minified_template": {"key": "minifiedTemplate", "type": "str"}, + "template_hash": {"key": "templateHash", "type": "str"}, } - def __init__( - self, - *, - minified_template: Optional[str] = None, - template_hash: Optional[str] = None, - **kwargs - ): + def __init__(self, *, minified_template: Optional[str] = None, template_hash: Optional[str] = None, **kwargs): """ :keyword minified_template: The minified template string. :paramtype minified_template: str :keyword template_hash: The template hash. :paramtype template_hash: str """ - super(TemplateHashResult, self).__init__(**kwargs) + super().__init__(**kwargs) self.minified_template = minified_template self.template_hash = template_hash -class TemplateLink(msrest.serialization.Model): +class TemplateLink(_serialization.Model): """Entity representing the reference to the template. :ivar uri: The URI of the template to deploy. Use either the uri or id property, but not both. @@ -3235,18 +3051,18 @@ class TemplateLink(msrest.serialization.Model): """ _attribute_map = { - 'uri': {'key': 'uri', 'type': 'str'}, - 'id': {'key': 'id', 'type': 'str'}, - 'relative_path': {'key': 'relativePath', 'type': 'str'}, - 'content_version': {'key': 'contentVersion', 'type': 'str'}, - 'query_string': {'key': 'queryString', 'type': 'str'}, + "uri": {"key": "uri", "type": "str"}, + "id": {"key": "id", "type": "str"}, + "relative_path": {"key": "relativePath", "type": "str"}, + "content_version": {"key": "contentVersion", "type": "str"}, + "query_string": {"key": "queryString", "type": "str"}, } def __init__( self, *, uri: Optional[str] = None, - id: Optional[str] = None, + id: Optional[str] = None, # pylint: disable=redefined-builtin relative_path: Optional[str] = None, content_version: Optional[str] = None, query_string: Optional[str] = None, @@ -3270,7 +3086,7 @@ def __init__( templateLink URI. :paramtype query_string: str """ - super(TemplateLink, self).__init__(**kwargs) + super().__init__(**kwargs) self.uri = uri self.id = id self.relative_path = relative_path @@ -3278,69 +3094,69 @@ def __init__( self.query_string = query_string -class WhatIfChange(msrest.serialization.Model): +class WhatIfChange(_serialization.Model): """Information about a single resource change predicted by What-If operation. All required parameters must be populated in order to send to Azure. - :ivar resource_id: Required. Resource ID. + :ivar resource_id: Resource ID. Required. :vartype resource_id: str - :ivar change_type: Required. Type of change that will be made to the resource when the - deployment is executed. Possible values include: "Create", "Delete", "Ignore", "Deploy", - "NoChange", "Modify", "Unsupported". + :ivar change_type: Type of change that will be made to the resource when the deployment is + executed. Required. Known values are: "Create", "Delete", "Ignore", "Deploy", "NoChange", + "Modify", and "Unsupported". :vartype change_type: str or ~azure.mgmt.resource.resources.v2021_01_01.models.ChangeType :ivar unsupported_reason: The explanation about why the resource is unsupported by What-If. :vartype unsupported_reason: str :ivar before: The snapshot of the resource before the deployment is executed. - :vartype before: any + :vartype before: JSON :ivar after: The predicted snapshot of the resource after the deployment is executed. - :vartype after: any + :vartype after: JSON :ivar delta: The predicted changes to resource properties. :vartype delta: list[~azure.mgmt.resource.resources.v2021_01_01.models.WhatIfPropertyChange] """ _validation = { - 'resource_id': {'required': True}, - 'change_type': {'required': True}, + "resource_id": {"required": True}, + "change_type": {"required": True}, } _attribute_map = { - 'resource_id': {'key': 'resourceId', 'type': 'str'}, - 'change_type': {'key': 'changeType', 'type': 'str'}, - 'unsupported_reason': {'key': 'unsupportedReason', 'type': 'str'}, - 'before': {'key': 'before', 'type': 'object'}, - 'after': {'key': 'after', 'type': 'object'}, - 'delta': {'key': 'delta', 'type': '[WhatIfPropertyChange]'}, + "resource_id": {"key": "resourceId", "type": "str"}, + "change_type": {"key": "changeType", "type": "str"}, + "unsupported_reason": {"key": "unsupportedReason", "type": "str"}, + "before": {"key": "before", "type": "object"}, + "after": {"key": "after", "type": "object"}, + "delta": {"key": "delta", "type": "[WhatIfPropertyChange]"}, } def __init__( self, *, resource_id: str, - change_type: Union[str, "ChangeType"], + change_type: Union[str, "_models.ChangeType"], unsupported_reason: Optional[str] = None, - before: Optional[Any] = None, - after: Optional[Any] = None, - delta: Optional[List["WhatIfPropertyChange"]] = None, + before: Optional[JSON] = None, + after: Optional[JSON] = None, + delta: Optional[List["_models.WhatIfPropertyChange"]] = None, **kwargs ): """ - :keyword resource_id: Required. Resource ID. + :keyword resource_id: Resource ID. Required. :paramtype resource_id: str - :keyword change_type: Required. Type of change that will be made to the resource when the - deployment is executed. Possible values include: "Create", "Delete", "Ignore", "Deploy", - "NoChange", "Modify", "Unsupported". + :keyword change_type: Type of change that will be made to the resource when the deployment is + executed. Required. Known values are: "Create", "Delete", "Ignore", "Deploy", "NoChange", + "Modify", and "Unsupported". :paramtype change_type: str or ~azure.mgmt.resource.resources.v2021_01_01.models.ChangeType :keyword unsupported_reason: The explanation about why the resource is unsupported by What-If. :paramtype unsupported_reason: str :keyword before: The snapshot of the resource before the deployment is executed. - :paramtype before: any + :paramtype before: JSON :keyword after: The predicted snapshot of the resource after the deployment is executed. - :paramtype after: any + :paramtype after: JSON :keyword delta: The predicted changes to resource properties. :paramtype delta: list[~azure.mgmt.resource.resources.v2021_01_01.models.WhatIfPropertyChange] """ - super(WhatIfChange, self).__init__(**kwargs) + super().__init__(**kwargs) self.resource_id = resource_id self.change_type = change_type self.unsupported_reason = unsupported_reason @@ -3349,7 +3165,7 @@ def __init__( self.delta = delta -class WhatIfOperationResult(msrest.serialization.Model): +class WhatIfOperationResult(_serialization.Model): """Result of the What-If operation. Contains a list of predicted changes and a URL link to get to the next set of results. :ivar status: Status of the What-If operation. @@ -3361,17 +3177,17 @@ class WhatIfOperationResult(msrest.serialization.Model): """ _attribute_map = { - 'status': {'key': 'status', 'type': 'str'}, - 'error': {'key': 'error', 'type': 'ErrorResponse'}, - 'changes': {'key': 'properties.changes', 'type': '[WhatIfChange]'}, + "status": {"key": "status", "type": "str"}, + "error": {"key": "error", "type": "ErrorResponse"}, + "changes": {"key": "properties.changes", "type": "[WhatIfChange]"}, } def __init__( self, *, status: Optional[str] = None, - error: Optional["ErrorResponse"] = None, - changes: Optional[List["WhatIfChange"]] = None, + error: Optional["_models.ErrorResponse"] = None, + changes: Optional[List["_models.WhatIfChange"]] = None, **kwargs ): """ @@ -3382,70 +3198,70 @@ def __init__( :keyword changes: List of resource changes predicted by What-If operation. :paramtype changes: list[~azure.mgmt.resource.resources.v2021_01_01.models.WhatIfChange] """ - super(WhatIfOperationResult, self).__init__(**kwargs) + super().__init__(**kwargs) self.status = status self.error = error self.changes = changes -class WhatIfPropertyChange(msrest.serialization.Model): +class WhatIfPropertyChange(_serialization.Model): """The predicted change to the resource property. All required parameters must be populated in order to send to Azure. - :ivar path: Required. The path of the property. + :ivar path: The path of the property. Required. :vartype path: str - :ivar property_change_type: Required. The type of property change. Possible values include: - "Create", "Delete", "Modify", "Array", "NoEffect". + :ivar property_change_type: The type of property change. Required. Known values are: "Create", + "Delete", "Modify", "Array", and "NoEffect". :vartype property_change_type: str or ~azure.mgmt.resource.resources.v2021_01_01.models.PropertyChangeType :ivar before: The value of the property before the deployment is executed. - :vartype before: any + :vartype before: JSON :ivar after: The value of the property after the deployment is executed. - :vartype after: any + :vartype after: JSON :ivar children: Nested property changes. :vartype children: list[~azure.mgmt.resource.resources.v2021_01_01.models.WhatIfPropertyChange] """ _validation = { - 'path': {'required': True}, - 'property_change_type': {'required': True}, + "path": {"required": True}, + "property_change_type": {"required": True}, } _attribute_map = { - 'path': {'key': 'path', 'type': 'str'}, - 'property_change_type': {'key': 'propertyChangeType', 'type': 'str'}, - 'before': {'key': 'before', 'type': 'object'}, - 'after': {'key': 'after', 'type': 'object'}, - 'children': {'key': 'children', 'type': '[WhatIfPropertyChange]'}, + "path": {"key": "path", "type": "str"}, + "property_change_type": {"key": "propertyChangeType", "type": "str"}, + "before": {"key": "before", "type": "object"}, + "after": {"key": "after", "type": "object"}, + "children": {"key": "children", "type": "[WhatIfPropertyChange]"}, } def __init__( self, *, path: str, - property_change_type: Union[str, "PropertyChangeType"], - before: Optional[Any] = None, - after: Optional[Any] = None, - children: Optional[List["WhatIfPropertyChange"]] = None, + property_change_type: Union[str, "_models.PropertyChangeType"], + before: Optional[JSON] = None, + after: Optional[JSON] = None, + children: Optional[List["_models.WhatIfPropertyChange"]] = None, **kwargs ): """ - :keyword path: Required. The path of the property. + :keyword path: The path of the property. Required. :paramtype path: str - :keyword property_change_type: Required. The type of property change. Possible values include: - "Create", "Delete", "Modify", "Array", "NoEffect". + :keyword property_change_type: The type of property change. Required. Known values are: + "Create", "Delete", "Modify", "Array", and "NoEffect". :paramtype property_change_type: str or ~azure.mgmt.resource.resources.v2021_01_01.models.PropertyChangeType :keyword before: The value of the property before the deployment is executed. - :paramtype before: any + :paramtype before: JSON :keyword after: The value of the property after the deployment is executed. - :paramtype after: any + :paramtype after: JSON :keyword children: Nested property changes. :paramtype children: list[~azure.mgmt.resource.resources.v2021_01_01.models.WhatIfPropertyChange] """ - super(WhatIfPropertyChange, self).__init__(**kwargs) + super().__init__(**kwargs) self.path = path self.property_change_type = property_change_type self.before = before @@ -3453,7 +3269,7 @@ def __init__( self.children = children -class ZoneMapping(msrest.serialization.Model): +class ZoneMapping(_serialization.Model): """ZoneMapping. :ivar location: The location of the zone mapping. @@ -3463,23 +3279,17 @@ class ZoneMapping(msrest.serialization.Model): """ _attribute_map = { - 'location': {'key': 'location', 'type': 'str'}, - 'zones': {'key': 'zones', 'type': '[str]'}, + "location": {"key": "location", "type": "str"}, + "zones": {"key": "zones", "type": "[str]"}, } - def __init__( - self, - *, - location: Optional[str] = None, - zones: Optional[List[str]] = None, - **kwargs - ): + def __init__(self, *, location: Optional[str] = None, zones: Optional[List[str]] = None, **kwargs): """ :keyword location: The location of the zone mapping. :paramtype location: str :keyword zones: :paramtype zones: list[str] """ - super(ZoneMapping, self).__init__(**kwargs) + super().__init__(**kwargs) self.location = location self.zones = zones diff --git a/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/resources/v2021_01_01/models/_patch.py b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/resources/v2021_01_01/models/_patch.py new file mode 100644 index 0000000000000..f7dd32510333d --- /dev/null +++ b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/resources/v2021_01_01/models/_patch.py @@ -0,0 +1,20 @@ +# ------------------------------------ +# Copyright (c) Microsoft Corporation. +# Licensed under the MIT License. +# ------------------------------------ +"""Customize generated code here. + +Follow our quickstart for examples: https://aka.ms/azsdk/python/dpcodegen/python/customize +""" +from typing import List + +__all__: List[str] = [] # Add all objects you want publicly available to users at this package level + + +def patch_sdk(): + """Do not remove from this file. + + `patch_sdk` is a last resort escape hatch that allows you to do customizations + you can't accomplish using the techniques described in + https://aka.ms/azsdk/python/dpcodegen/python/customize + """ diff --git a/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/resources/v2021_01_01/models/_resource_management_client_enums.py b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/resources/v2021_01_01/models/_resource_management_client_enums.py index aa2b114ef29b6..0fdf043d680e7 100644 --- a/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/resources/v2021_01_01/models/_resource_management_client_enums.py +++ b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/resources/v2021_01_01/models/_resource_management_client_enums.py @@ -7,22 +7,20 @@ # -------------------------------------------------------------------------- from enum import Enum -from six import with_metaclass from azure.core import CaseInsensitiveEnumMeta -class AliasPathAttributes(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): - """The attributes of the token that the alias path is referring to. - """ +class AliasPathAttributes(str, Enum, metaclass=CaseInsensitiveEnumMeta): + """The attributes of the token that the alias path is referring to.""" #: The token that the alias path is referring to has no attributes. NONE = "None" #: The token that the alias path is referring to is modifiable by policies with 'modify' effect. MODIFIABLE = "Modifiable" -class AliasPathTokenType(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): - """The type of the token that the alias path is referring to. - """ + +class AliasPathTokenType(str, Enum, metaclass=CaseInsensitiveEnumMeta): + """The type of the token that the alias path is referring to.""" #: The token type is not specified. NOT_SPECIFIED = "NotSpecified" @@ -41,18 +39,18 @@ class AliasPathTokenType(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): #: The token type is boolean. BOOLEAN = "Boolean" -class AliasPatternType(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): - """The type of alias pattern - """ + +class AliasPatternType(str, Enum, metaclass=CaseInsensitiveEnumMeta): + """The type of alias pattern.""" #: NotSpecified is not allowed. NOT_SPECIFIED = "NotSpecified" #: Extract is the only allowed value. EXTRACT = "Extract" -class AliasType(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): - """The type of the alias. - """ + +class AliasType(str, Enum, metaclass=CaseInsensitiveEnumMeta): + """The type of the alias.""" #: Alias type is unknown (same as not providing alias type). NOT_SPECIFIED = "NotSpecified" @@ -61,9 +59,9 @@ class AliasType(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): #: Alias value is secret. MASK = "Mask" -class ChangeType(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): - """Type of change that will be made to the resource when the deployment is executed. - """ + +class ChangeType(str, Enum, metaclass=CaseInsensitiveEnumMeta): + """Type of change that will be made to the resource when the deployment is executed.""" #: The resource does not exist in the current state but is present in the desired state. The #: resource will be created when the deployment is executed. @@ -86,7 +84,8 @@ class ChangeType(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): #: The resource is not supported by What-If. UNSUPPORTED = "Unsupported" -class DeploymentMode(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): + +class DeploymentMode(str, Enum, metaclass=CaseInsensitiveEnumMeta): """The mode that is used to deploy resources. This value can be either Incremental or Complete. In Incremental mode, resources are deployed without deleting existing resources that are not included in the template. In Complete mode, resources are deployed and existing resources in @@ -97,7 +96,8 @@ class DeploymentMode(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): INCREMENTAL = "Incremental" COMPLETE = "Complete" -class ExpressionEvaluationOptionsScopeType(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): + +class ExpressionEvaluationOptionsScopeType(str, Enum, metaclass=CaseInsensitiveEnumMeta): """The scope to be used for evaluation of parameters, variables and functions in a nested template. """ @@ -106,13 +106,14 @@ class ExpressionEvaluationOptionsScopeType(with_metaclass(CaseInsensitiveEnumMet OUTER = "Outer" INNER = "Inner" -class ExtendedLocationType(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): - """The extended location type. - """ + +class ExtendedLocationType(str, Enum, metaclass=CaseInsensitiveEnumMeta): + """The extended location type.""" EDGE_ZONE = "EdgeZone" -class OnErrorDeploymentType(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): + +class OnErrorDeploymentType(str, Enum, metaclass=CaseInsensitiveEnumMeta): """The deployment on error behavior type. Possible values are LastSuccessful and SpecificDeployment. """ @@ -120,9 +121,9 @@ class OnErrorDeploymentType(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): LAST_SUCCESSFUL = "LastSuccessful" SPECIFIC_DEPLOYMENT = "SpecificDeployment" -class PropertyChangeType(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): - """The type of property change. - """ + +class PropertyChangeType(str, Enum, metaclass=CaseInsensitiveEnumMeta): + """The type of property change.""" #: The property does not exist in the current state but is present in the desired state. The #: property will be created when the deployment is executed. @@ -138,9 +139,9 @@ class PropertyChangeType(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): #: The property will not be set or updated. NO_EFFECT = "NoEffect" -class ProvisioningOperation(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): - """The name of the current provisioning operation. - """ + +class ProvisioningOperation(str, Enum, metaclass=CaseInsensitiveEnumMeta): + """The name of the current provisioning operation.""" #: The provisioning operation is not specified. NOT_SPECIFIED = "NotSpecified" @@ -164,9 +165,9 @@ class ProvisioningOperation(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): #: deployment. DEPLOYMENT_CLEANUP = "DeploymentCleanup" -class ProvisioningState(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): - """Denotes the state of provisioning. - """ + +class ProvisioningState(str, Enum, metaclass=CaseInsensitiveEnumMeta): + """Denotes the state of provisioning.""" NOT_SPECIFIED = "NotSpecified" ACCEPTED = "Accepted" @@ -181,18 +182,18 @@ class ProvisioningState(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): SUCCEEDED = "Succeeded" UPDATING = "Updating" -class ResourceIdentityType(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): - """The identity type. - """ + +class ResourceIdentityType(str, Enum, metaclass=CaseInsensitiveEnumMeta): + """The identity type.""" SYSTEM_ASSIGNED = "SystemAssigned" USER_ASSIGNED = "UserAssigned" SYSTEM_ASSIGNED_USER_ASSIGNED = "SystemAssigned, UserAssigned" NONE = "None" -class TagsPatchOperation(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): - """The operation type for the patch API. - """ + +class TagsPatchOperation(str, Enum, metaclass=CaseInsensitiveEnumMeta): + """The operation type for the patch API.""" #: The 'replace' option replaces the entire set of existing tags with a new set. REPLACE = "Replace" @@ -202,9 +203,9 @@ class TagsPatchOperation(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): #: The 'delete' option allows selectively deleting tags based on given names or name/value pairs. DELETE = "Delete" -class WhatIfResultFormat(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): - """The format of the What-If results - """ + +class WhatIfResultFormat(str, Enum, metaclass=CaseInsensitiveEnumMeta): + """The format of the What-If results.""" RESOURCE_ID_ONLY = "ResourceIdOnly" FULL_RESOURCE_PAYLOADS = "FullResourcePayloads" diff --git a/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/resources/v2021_01_01/operations/__init__.py b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/resources/v2021_01_01/operations/__init__.py index f1487609817b6..9e5620e4d286c 100644 --- a/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/resources/v2021_01_01/operations/__init__.py +++ b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/resources/v2021_01_01/operations/__init__.py @@ -15,13 +15,19 @@ from ._operations import TagsOperations from ._operations import DeploymentOperationsOperations +from ._patch import __all__ as _patch_all +from ._patch import * # type: ignore # pylint: disable=unused-wildcard-import +from ._patch import patch_sdk as _patch_sdk + __all__ = [ - 'Operations', - 'DeploymentsOperations', - 'ProvidersOperations', - 'ProviderResourceTypesOperations', - 'ResourcesOperations', - 'ResourceGroupsOperations', - 'TagsOperations', - 'DeploymentOperationsOperations', + "Operations", + "DeploymentsOperations", + "ProvidersOperations", + "ProviderResourceTypesOperations", + "ResourcesOperations", + "ResourceGroupsOperations", + "TagsOperations", + "DeploymentOperationsOperations", ] +__all__.extend([p for p in _patch_all if p not in __all__]) +_patch_sdk() diff --git a/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/resources/v2021_01_01/operations/_operations.py b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/resources/v2021_01_01/operations/_operations.py index f3119404794b4..45c4659a79dc3 100644 --- a/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/resources/v2021_01_01/operations/_operations.py +++ b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/resources/v2021_01_01/operations/_operations.py @@ -6,1641 +6,1408 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -from typing import Any, Callable, Dict, Iterable, Optional, TypeVar, Union - -from msrest import Serializer - -from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error +import sys +from typing import Any, Callable, Dict, IO, Iterable, Optional, TypeVar, Union, cast, overload +from urllib.parse import parse_qs, urljoin, urlparse + +from azure.core.exceptions import ( + ClientAuthenticationError, + HttpResponseError, + ResourceExistsError, + ResourceNotFoundError, + ResourceNotModifiedError, + map_error, +) from azure.core.paging import ItemPaged from azure.core.pipeline import PipelineResponse from azure.core.pipeline.transport import HttpResponse from azure.core.polling import LROPoller, NoPolling, PollingMethod from azure.core.rest import HttpRequest from azure.core.tracing.decorator import distributed_trace +from azure.core.utils import case_insensitive_dict from azure.mgmt.core.exceptions import ARMErrorFormat from azure.mgmt.core.polling.arm_polling import ARMPolling from .. import models as _models +from ..._serialization import Serializer from .._vendor import _convert_request, _format_url_section -T = TypeVar('T') + +T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] -JSONType = Any +if sys.version_info >= (3, 9): + from collections.abc import MutableMapping +else: + from typing import MutableMapping # type: ignore # pylint: disable=ungrouped-imports +JSON = MutableMapping[str, Any] # pylint: disable=unsubscriptable-object _SERIALIZER = Serializer() _SERIALIZER.client_side_validation = False -def build_operations_list_request( - **kwargs: Any -) -> HttpRequest: - api_version = kwargs.pop('api_version', "2021-01-01") # type: str - accept = "application/json" +def build_operations_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-01-01")) # type: str + accept = _headers.pop("Accept", "application/json") + # Construct URL _url = kwargs.pop("template_url", "/providers/Microsoft.Resources/operations") # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') - - return HttpRequest( - method="GET", - url=_url, - params=_query_parameters, - headers=_header_parameters, - **kwargs - ) + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) -def build_deployments_delete_at_scope_request_initial( - scope: str, - deployment_name: str, - **kwargs: Any -) -> HttpRequest: - api_version = kwargs.pop('api_version', "2021-01-01") # type: str - accept = "application/json" +def build_deployments_delete_at_scope_request(scope: str, deployment_name: 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-01-01")) # type: str + accept = _headers.pop("Accept", "application/json") + # Construct URL _url = kwargs.pop("template_url", "/{scope}/providers/Microsoft.Resources/deployments/{deploymentName}") path_format_arguments = { - "scope": _SERIALIZER.url("scope", scope, 'str', skip_quote=True), - "deploymentName": _SERIALIZER.url("deployment_name", deployment_name, 'str', max_length=64, min_length=1, pattern=r'^[-\w\._\(\)]+$'), + "scope": _SERIALIZER.url("scope", scope, "str", skip_quote=True), + "deploymentName": _SERIALIZER.url( + "deployment_name", deployment_name, "str", max_length=64, min_length=1, pattern=r"^[-\w\._\(\)]+$" + ), } _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') - - return HttpRequest( - method="DELETE", - url=_url, - params=_query_parameters, - headers=_header_parameters, - **kwargs - ) + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + return HttpRequest(method="DELETE", url=_url, params=_params, headers=_headers, **kwargs) -def build_deployments_check_existence_at_scope_request( - scope: str, - deployment_name: str, - **kwargs: Any -) -> HttpRequest: - api_version = kwargs.pop('api_version', "2021-01-01") # type: str - accept = "application/json" +def build_deployments_check_existence_at_scope_request(scope: str, deployment_name: 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-01-01")) # type: str + accept = _headers.pop("Accept", "application/json") + # Construct URL _url = kwargs.pop("template_url", "/{scope}/providers/Microsoft.Resources/deployments/{deploymentName}") path_format_arguments = { - "scope": _SERIALIZER.url("scope", scope, 'str', skip_quote=True), - "deploymentName": _SERIALIZER.url("deployment_name", deployment_name, 'str', max_length=64, min_length=1, pattern=r'^[-\w\._\(\)]+$'), + "scope": _SERIALIZER.url("scope", scope, "str", skip_quote=True), + "deploymentName": _SERIALIZER.url( + "deployment_name", deployment_name, "str", max_length=64, min_length=1, pattern=r"^[-\w\._\(\)]+$" + ), } _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') - - return HttpRequest( - method="HEAD", - url=_url, - params=_query_parameters, - headers=_header_parameters, - **kwargs - ) + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + return HttpRequest(method="HEAD", url=_url, params=_params, headers=_headers, **kwargs) -def build_deployments_create_or_update_at_scope_request_initial( - scope: str, - deployment_name: str, - *, - json: JSONType = None, - content: Any = None, - **kwargs: Any -) -> HttpRequest: - api_version = kwargs.pop('api_version', "2021-01-01") # type: str - content_type = kwargs.pop('content_type', None) # type: Optional[str] - accept = "application/json" +def build_deployments_create_or_update_at_scope_request(scope: str, deployment_name: 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-01-01")) # type: str + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + accept = _headers.pop("Accept", "application/json") + # Construct URL _url = kwargs.pop("template_url", "/{scope}/providers/Microsoft.Resources/deployments/{deploymentName}") path_format_arguments = { - "scope": _SERIALIZER.url("scope", scope, 'str', skip_quote=True), - "deploymentName": _SERIALIZER.url("deployment_name", deployment_name, 'str', max_length=64, min_length=1, pattern=r'^[-\w\._\(\)]+$'), + "scope": _SERIALIZER.url("scope", scope, "str", skip_quote=True), + "deploymentName": _SERIALIZER.url( + "deployment_name", deployment_name, "str", max_length=64, min_length=1, pattern=r"^[-\w\._\(\)]+$" + ), } _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] if content_type is not None: - _header_parameters['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') - _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') - - return HttpRequest( - method="PUT", - url=_url, - params=_query_parameters, - headers=_header_parameters, - json=json, - content=content, - **kwargs - ) + _headers["Content-Type"] = _SERIALIZER.header("content_type", content_type, "str") + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + return HttpRequest(method="PUT", url=_url, params=_params, headers=_headers, **kwargs) -def build_deployments_get_at_scope_request( - scope: str, - deployment_name: str, - **kwargs: Any -) -> HttpRequest: - api_version = kwargs.pop('api_version', "2021-01-01") # type: str - accept = "application/json" +def build_deployments_get_at_scope_request(scope: str, deployment_name: 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-01-01")) # type: str + accept = _headers.pop("Accept", "application/json") + # Construct URL _url = kwargs.pop("template_url", "/{scope}/providers/Microsoft.Resources/deployments/{deploymentName}") path_format_arguments = { - "scope": _SERIALIZER.url("scope", scope, 'str', skip_quote=True), - "deploymentName": _SERIALIZER.url("deployment_name", deployment_name, 'str', max_length=64, min_length=1, pattern=r'^[-\w\._\(\)]+$'), + "scope": _SERIALIZER.url("scope", scope, "str", skip_quote=True), + "deploymentName": _SERIALIZER.url( + "deployment_name", deployment_name, "str", max_length=64, min_length=1, pattern=r"^[-\w\._\(\)]+$" + ), } _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') - - return HttpRequest( - method="GET", - url=_url, - params=_query_parameters, - headers=_header_parameters, - **kwargs - ) + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) -def build_deployments_cancel_at_scope_request( - scope: str, - deployment_name: str, - **kwargs: Any -) -> HttpRequest: - api_version = kwargs.pop('api_version', "2021-01-01") # type: str - accept = "application/json" +def build_deployments_cancel_at_scope_request(scope: str, deployment_name: 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-01-01")) # type: str + accept = _headers.pop("Accept", "application/json") + # Construct URL _url = kwargs.pop("template_url", "/{scope}/providers/Microsoft.Resources/deployments/{deploymentName}/cancel") path_format_arguments = { - "scope": _SERIALIZER.url("scope", scope, 'str', skip_quote=True), - "deploymentName": _SERIALIZER.url("deployment_name", deployment_name, 'str', max_length=64, min_length=1, pattern=r'^[-\w\._\(\)]+$'), + "scope": _SERIALIZER.url("scope", scope, "str", skip_quote=True), + "deploymentName": _SERIALIZER.url( + "deployment_name", deployment_name, "str", max_length=64, min_length=1, pattern=r"^[-\w\._\(\)]+$" + ), } _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') - - return HttpRequest( - method="POST", - url=_url, - params=_query_parameters, - headers=_header_parameters, - **kwargs - ) + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + return HttpRequest(method="POST", url=_url, params=_params, headers=_headers, **kwargs) -def build_deployments_validate_at_scope_request_initial( - scope: str, - deployment_name: str, - *, - json: JSONType = None, - content: Any = None, - **kwargs: Any -) -> HttpRequest: - api_version = kwargs.pop('api_version', "2021-01-01") # type: str - content_type = kwargs.pop('content_type', None) # type: Optional[str] - accept = "application/json" +def build_deployments_validate_at_scope_request(scope: str, deployment_name: 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-01-01")) # type: str + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + accept = _headers.pop("Accept", "application/json") + # Construct URL _url = kwargs.pop("template_url", "/{scope}/providers/Microsoft.Resources/deployments/{deploymentName}/validate") path_format_arguments = { - "scope": _SERIALIZER.url("scope", scope, 'str', skip_quote=True), - "deploymentName": _SERIALIZER.url("deployment_name", deployment_name, 'str', max_length=64, min_length=1, pattern=r'^[-\w\._\(\)]+$'), + "scope": _SERIALIZER.url("scope", scope, "str", skip_quote=True), + "deploymentName": _SERIALIZER.url( + "deployment_name", deployment_name, "str", max_length=64, min_length=1, pattern=r"^[-\w\._\(\)]+$" + ), } _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] if content_type is not None: - _header_parameters['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') - _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') - - return HttpRequest( - method="POST", - url=_url, - params=_query_parameters, - headers=_header_parameters, - json=json, - content=content, - **kwargs - ) + _headers["Content-Type"] = _SERIALIZER.header("content_type", content_type, "str") + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + return HttpRequest(method="POST", url=_url, params=_params, headers=_headers, **kwargs) -def build_deployments_export_template_at_scope_request( - scope: str, - deployment_name: str, - **kwargs: Any -) -> HttpRequest: - api_version = kwargs.pop('api_version', "2021-01-01") # type: str - accept = "application/json" +def build_deployments_export_template_at_scope_request(scope: str, deployment_name: 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-01-01")) # type: str + accept = _headers.pop("Accept", "application/json") + # Construct URL - _url = kwargs.pop("template_url", "/{scope}/providers/Microsoft.Resources/deployments/{deploymentName}/exportTemplate") + _url = kwargs.pop( + "template_url", "/{scope}/providers/Microsoft.Resources/deployments/{deploymentName}/exportTemplate" + ) path_format_arguments = { - "scope": _SERIALIZER.url("scope", scope, 'str', skip_quote=True), - "deploymentName": _SERIALIZER.url("deployment_name", deployment_name, 'str', max_length=64, min_length=1, pattern=r'^[-\w\._\(\)]+$'), + "scope": _SERIALIZER.url("scope", scope, "str", skip_quote=True), + "deploymentName": _SERIALIZER.url( + "deployment_name", deployment_name, "str", max_length=64, min_length=1, pattern=r"^[-\w\._\(\)]+$" + ), } _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') - - return HttpRequest( - method="POST", - url=_url, - params=_query_parameters, - headers=_header_parameters, - **kwargs - ) + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="POST", url=_url, params=_params, headers=_headers, **kwargs) def build_deployments_list_at_scope_request( - scope: str, - *, - filter: Optional[str] = None, - top: Optional[int] = None, - **kwargs: Any + scope: str, *, filter: Optional[str] = None, top: Optional[int] = None, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2021-01-01") # type: 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-01-01")) # type: str + accept = _headers.pop("Accept", "application/json") - accept = "application/json" # Construct URL _url = kwargs.pop("template_url", "/{scope}/providers/Microsoft.Resources/deployments/") path_format_arguments = { - "scope": _SERIALIZER.url("scope", scope, 'str', skip_quote=True), + "scope": _SERIALIZER.url("scope", scope, "str", skip_quote=True), } _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] if filter is not None: - _query_parameters['$filter'] = _SERIALIZER.query("filter", filter, 'str') + _params["$filter"] = _SERIALIZER.query("filter", filter, "str") if top is not None: - _query_parameters['$top'] = _SERIALIZER.query("top", top, 'int') - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["$top"] = _SERIALIZER.query("top", top, "int") + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') - - return HttpRequest( - method="GET", - url=_url, - params=_query_parameters, - headers=_header_parameters, - **kwargs - ) + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) -def build_deployments_delete_at_tenant_scope_request_initial( - deployment_name: str, - **kwargs: Any -) -> HttpRequest: - api_version = kwargs.pop('api_version', "2021-01-01") # type: str - accept = "application/json" +def build_deployments_delete_at_tenant_scope_request(deployment_name: 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-01-01")) # type: str + accept = _headers.pop("Accept", "application/json") + # Construct URL _url = kwargs.pop("template_url", "/providers/Microsoft.Resources/deployments/{deploymentName}") path_format_arguments = { - "deploymentName": _SERIALIZER.url("deployment_name", deployment_name, 'str', max_length=64, min_length=1, pattern=r'^[-\w\._\(\)]+$'), + "deploymentName": _SERIALIZER.url( + "deployment_name", deployment_name, "str", max_length=64, min_length=1, pattern=r"^[-\w\._\(\)]+$" + ), } _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') - - return HttpRequest( - method="DELETE", - url=_url, - params=_query_parameters, - headers=_header_parameters, - **kwargs - ) + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + return HttpRequest(method="DELETE", url=_url, params=_params, headers=_headers, **kwargs) -def build_deployments_check_existence_at_tenant_scope_request( - deployment_name: str, - **kwargs: Any -) -> HttpRequest: - api_version = kwargs.pop('api_version', "2021-01-01") # type: str - accept = "application/json" +def build_deployments_check_existence_at_tenant_scope_request(deployment_name: 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-01-01")) # type: str + accept = _headers.pop("Accept", "application/json") + # Construct URL _url = kwargs.pop("template_url", "/providers/Microsoft.Resources/deployments/{deploymentName}") path_format_arguments = { - "deploymentName": _SERIALIZER.url("deployment_name", deployment_name, 'str', max_length=64, min_length=1, pattern=r'^[-\w\._\(\)]+$'), + "deploymentName": _SERIALIZER.url( + "deployment_name", deployment_name, "str", max_length=64, min_length=1, pattern=r"^[-\w\._\(\)]+$" + ), } _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') - - return HttpRequest( - method="HEAD", - url=_url, - params=_query_parameters, - headers=_header_parameters, - **kwargs - ) + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + return HttpRequest(method="HEAD", url=_url, params=_params, headers=_headers, **kwargs) -def build_deployments_create_or_update_at_tenant_scope_request_initial( - deployment_name: str, - *, - json: JSONType = None, - content: Any = None, - **kwargs: Any -) -> HttpRequest: - api_version = kwargs.pop('api_version', "2021-01-01") # type: str - content_type = kwargs.pop('content_type', None) # type: Optional[str] - accept = "application/json" +def build_deployments_create_or_update_at_tenant_scope_request(deployment_name: 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-01-01")) # type: str + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + accept = _headers.pop("Accept", "application/json") + # Construct URL _url = kwargs.pop("template_url", "/providers/Microsoft.Resources/deployments/{deploymentName}") path_format_arguments = { - "deploymentName": _SERIALIZER.url("deployment_name", deployment_name, 'str', max_length=64, min_length=1, pattern=r'^[-\w\._\(\)]+$'), + "deploymentName": _SERIALIZER.url( + "deployment_name", deployment_name, "str", max_length=64, min_length=1, pattern=r"^[-\w\._\(\)]+$" + ), } _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] if content_type is not None: - _header_parameters['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') - _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') - - return HttpRequest( - method="PUT", - url=_url, - params=_query_parameters, - headers=_header_parameters, - json=json, - content=content, - **kwargs - ) + _headers["Content-Type"] = _SERIALIZER.header("content_type", content_type, "str") + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + return HttpRequest(method="PUT", url=_url, params=_params, headers=_headers, **kwargs) -def build_deployments_get_at_tenant_scope_request( - deployment_name: str, - **kwargs: Any -) -> HttpRequest: - api_version = kwargs.pop('api_version', "2021-01-01") # type: str - accept = "application/json" +def build_deployments_get_at_tenant_scope_request(deployment_name: 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-01-01")) # type: str + accept = _headers.pop("Accept", "application/json") + # Construct URL _url = kwargs.pop("template_url", "/providers/Microsoft.Resources/deployments/{deploymentName}") path_format_arguments = { - "deploymentName": _SERIALIZER.url("deployment_name", deployment_name, 'str', max_length=64, min_length=1, pattern=r'^[-\w\._\(\)]+$'), + "deploymentName": _SERIALIZER.url( + "deployment_name", deployment_name, "str", max_length=64, min_length=1, pattern=r"^[-\w\._\(\)]+$" + ), } _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') - - return HttpRequest( - method="GET", - url=_url, - params=_query_parameters, - headers=_header_parameters, - **kwargs - ) + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) -def build_deployments_cancel_at_tenant_scope_request( - deployment_name: str, - **kwargs: Any -) -> HttpRequest: - api_version = kwargs.pop('api_version', "2021-01-01") # type: str - accept = "application/json" +def build_deployments_cancel_at_tenant_scope_request(deployment_name: 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-01-01")) # type: str + accept = _headers.pop("Accept", "application/json") + # Construct URL _url = kwargs.pop("template_url", "/providers/Microsoft.Resources/deployments/{deploymentName}/cancel") path_format_arguments = { - "deploymentName": _SERIALIZER.url("deployment_name", deployment_name, 'str', max_length=64, min_length=1, pattern=r'^[-\w\._\(\)]+$'), + "deploymentName": _SERIALIZER.url( + "deployment_name", deployment_name, "str", max_length=64, min_length=1, pattern=r"^[-\w\._\(\)]+$" + ), } _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') - - return HttpRequest( - method="POST", - url=_url, - params=_query_parameters, - headers=_header_parameters, - **kwargs - ) + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + return HttpRequest(method="POST", url=_url, params=_params, headers=_headers, **kwargs) -def build_deployments_validate_at_tenant_scope_request_initial( - deployment_name: str, - *, - json: JSONType = None, - content: Any = None, - **kwargs: Any -) -> HttpRequest: - api_version = kwargs.pop('api_version', "2021-01-01") # type: str - content_type = kwargs.pop('content_type', None) # type: Optional[str] - accept = "application/json" +def build_deployments_validate_at_tenant_scope_request(deployment_name: 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-01-01")) # type: str + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + accept = _headers.pop("Accept", "application/json") + # Construct URL _url = kwargs.pop("template_url", "/providers/Microsoft.Resources/deployments/{deploymentName}/validate") path_format_arguments = { - "deploymentName": _SERIALIZER.url("deployment_name", deployment_name, 'str', max_length=64, min_length=1, pattern=r'^[-\w\._\(\)]+$'), + "deploymentName": _SERIALIZER.url( + "deployment_name", deployment_name, "str", max_length=64, min_length=1, pattern=r"^[-\w\._\(\)]+$" + ), } _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] if content_type is not None: - _header_parameters['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') - _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') - - return HttpRequest( - method="POST", - url=_url, - params=_query_parameters, - headers=_header_parameters, - json=json, - content=content, - **kwargs - ) + _headers["Content-Type"] = _SERIALIZER.header("content_type", content_type, "str") + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + return HttpRequest(method="POST", url=_url, params=_params, headers=_headers, **kwargs) -def build_deployments_what_if_at_tenant_scope_request_initial( - deployment_name: str, - *, - json: JSONType = None, - content: Any = None, - **kwargs: Any -) -> HttpRequest: - api_version = kwargs.pop('api_version', "2021-01-01") # type: str - content_type = kwargs.pop('content_type', None) # type: Optional[str] - accept = "application/json" +def build_deployments_what_if_at_tenant_scope_request(deployment_name: 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-01-01")) # type: str + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + accept = _headers.pop("Accept", "application/json") + # Construct URL _url = kwargs.pop("template_url", "/providers/Microsoft.Resources/deployments/{deploymentName}/whatIf") path_format_arguments = { - "deploymentName": _SERIALIZER.url("deployment_name", deployment_name, 'str', max_length=64, min_length=1, pattern=r'^[-\w\._\(\)]+$'), + "deploymentName": _SERIALIZER.url( + "deployment_name", deployment_name, "str", max_length=64, min_length=1, pattern=r"^[-\w\._\(\)]+$" + ), } _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] if content_type is not None: - _header_parameters['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') - _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') - - return HttpRequest( - method="POST", - url=_url, - params=_query_parameters, - headers=_header_parameters, - json=json, - content=content, - **kwargs - ) + _headers["Content-Type"] = _SERIALIZER.header("content_type", content_type, "str") + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + return HttpRequest(method="POST", url=_url, params=_params, headers=_headers, **kwargs) -def build_deployments_export_template_at_tenant_scope_request( - deployment_name: str, - **kwargs: Any -) -> HttpRequest: - api_version = kwargs.pop('api_version', "2021-01-01") # type: str - accept = "application/json" +def build_deployments_export_template_at_tenant_scope_request(deployment_name: 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-01-01")) # type: str + accept = _headers.pop("Accept", "application/json") + # Construct URL _url = kwargs.pop("template_url", "/providers/Microsoft.Resources/deployments/{deploymentName}/exportTemplate") path_format_arguments = { - "deploymentName": _SERIALIZER.url("deployment_name", deployment_name, 'str', max_length=64, min_length=1, pattern=r'^[-\w\._\(\)]+$'), + "deploymentName": _SERIALIZER.url( + "deployment_name", deployment_name, "str", max_length=64, min_length=1, pattern=r"^[-\w\._\(\)]+$" + ), } _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') - - return HttpRequest( - method="POST", - url=_url, - params=_query_parameters, - headers=_header_parameters, - **kwargs - ) + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="POST", url=_url, params=_params, headers=_headers, **kwargs) def build_deployments_list_at_tenant_scope_request( - *, - filter: Optional[str] = None, - top: Optional[int] = None, - **kwargs: Any + *, filter: Optional[str] = None, top: Optional[int] = None, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2021-01-01") # type: 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-01-01")) # type: str + accept = _headers.pop("Accept", "application/json") - accept = "application/json" # Construct URL _url = kwargs.pop("template_url", "/providers/Microsoft.Resources/deployments/") # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] if filter is not None: - _query_parameters['$filter'] = _SERIALIZER.query("filter", filter, 'str') + _params["$filter"] = _SERIALIZER.query("filter", filter, "str") if top is not None: - _query_parameters['$top'] = _SERIALIZER.query("top", top, 'int') - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["$top"] = _SERIALIZER.query("top", top, "int") + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') - - return HttpRequest( - method="GET", - url=_url, - params=_query_parameters, - headers=_header_parameters, - **kwargs - ) + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) -def build_deployments_delete_at_management_group_scope_request_initial( - group_id: str, - deployment_name: str, - **kwargs: Any + +def build_deployments_delete_at_management_group_scope_request( + group_id: str, deployment_name: str, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2021-01-01") # type: 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-01-01")) # type: str + accept = _headers.pop("Accept", "application/json") - accept = "application/json" # Construct URL - _url = kwargs.pop("template_url", "/providers/Microsoft.Management/managementGroups/{groupId}/providers/Microsoft.Resources/deployments/{deploymentName}") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", + "/providers/Microsoft.Management/managementGroups/{groupId}/providers/Microsoft.Resources/deployments/{deploymentName}", + ) # pylint: disable=line-too-long path_format_arguments = { - "groupId": _SERIALIZER.url("group_id", group_id, 'str', max_length=90, min_length=1), - "deploymentName": _SERIALIZER.url("deployment_name", deployment_name, 'str', max_length=64, min_length=1, pattern=r'^[-\w\._\(\)]+$'), + "groupId": _SERIALIZER.url("group_id", group_id, "str", max_length=90, min_length=1), + "deploymentName": _SERIALIZER.url( + "deployment_name", deployment_name, "str", max_length=64, min_length=1, pattern=r"^[-\w\._\(\)]+$" + ), } _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') - - return HttpRequest( - method="DELETE", - url=_url, - params=_query_parameters, - headers=_header_parameters, - **kwargs - ) + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="DELETE", url=_url, params=_params, headers=_headers, **kwargs) def build_deployments_check_existence_at_management_group_scope_request( - group_id: str, - deployment_name: str, - **kwargs: Any + group_id: str, deployment_name: str, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2021-01-01") # type: 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-01-01")) # type: str + accept = _headers.pop("Accept", "application/json") - accept = "application/json" # Construct URL - _url = kwargs.pop("template_url", "/providers/Microsoft.Management/managementGroups/{groupId}/providers/Microsoft.Resources/deployments/{deploymentName}") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", + "/providers/Microsoft.Management/managementGroups/{groupId}/providers/Microsoft.Resources/deployments/{deploymentName}", + ) # pylint: disable=line-too-long path_format_arguments = { - "groupId": _SERIALIZER.url("group_id", group_id, 'str', max_length=90, min_length=1), - "deploymentName": _SERIALIZER.url("deployment_name", deployment_name, 'str', max_length=64, min_length=1, pattern=r'^[-\w\._\(\)]+$'), + "groupId": _SERIALIZER.url("group_id", group_id, "str", max_length=90, min_length=1), + "deploymentName": _SERIALIZER.url( + "deployment_name", deployment_name, "str", max_length=64, min_length=1, pattern=r"^[-\w\._\(\)]+$" + ), } _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') - - return HttpRequest( - method="HEAD", - url=_url, - params=_query_parameters, - headers=_header_parameters, - **kwargs - ) + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + return HttpRequest(method="HEAD", url=_url, params=_params, headers=_headers, **kwargs) -def build_deployments_create_or_update_at_management_group_scope_request_initial( - group_id: str, - deployment_name: str, - *, - json: JSONType = None, - content: Any = None, - **kwargs: Any + +def build_deployments_create_or_update_at_management_group_scope_request( + group_id: str, deployment_name: str, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2021-01-01") # type: str - content_type = kwargs.pop('content_type', None) # type: Optional[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-01-01")) # type: str + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + accept = _headers.pop("Accept", "application/json") - accept = "application/json" # Construct URL - _url = kwargs.pop("template_url", "/providers/Microsoft.Management/managementGroups/{groupId}/providers/Microsoft.Resources/deployments/{deploymentName}") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", + "/providers/Microsoft.Management/managementGroups/{groupId}/providers/Microsoft.Resources/deployments/{deploymentName}", + ) # pylint: disable=line-too-long path_format_arguments = { - "groupId": _SERIALIZER.url("group_id", group_id, 'str', max_length=90, min_length=1), - "deploymentName": _SERIALIZER.url("deployment_name", deployment_name, 'str', max_length=64, min_length=1, pattern=r'^[-\w\._\(\)]+$'), + "groupId": _SERIALIZER.url("group_id", group_id, "str", max_length=90, min_length=1), + "deploymentName": _SERIALIZER.url( + "deployment_name", deployment_name, "str", max_length=64, min_length=1, pattern=r"^[-\w\._\(\)]+$" + ), } _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] if content_type is not None: - _header_parameters['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') - _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') - - return HttpRequest( - method="PUT", - url=_url, - params=_query_parameters, - headers=_header_parameters, - json=json, - content=content, - **kwargs - ) + _headers["Content-Type"] = _SERIALIZER.header("content_type", content_type, "str") + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="PUT", url=_url, params=_params, headers=_headers, **kwargs) def build_deployments_get_at_management_group_scope_request( - group_id: str, - deployment_name: str, - **kwargs: Any + group_id: str, deployment_name: str, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2021-01-01") # type: 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-01-01")) # type: str + accept = _headers.pop("Accept", "application/json") - accept = "application/json" # Construct URL - _url = kwargs.pop("template_url", "/providers/Microsoft.Management/managementGroups/{groupId}/providers/Microsoft.Resources/deployments/{deploymentName}") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", + "/providers/Microsoft.Management/managementGroups/{groupId}/providers/Microsoft.Resources/deployments/{deploymentName}", + ) # pylint: disable=line-too-long path_format_arguments = { - "groupId": _SERIALIZER.url("group_id", group_id, 'str', max_length=90, min_length=1), - "deploymentName": _SERIALIZER.url("deployment_name", deployment_name, 'str', max_length=64, min_length=1, pattern=r'^[-\w\._\(\)]+$'), + "groupId": _SERIALIZER.url("group_id", group_id, "str", max_length=90, min_length=1), + "deploymentName": _SERIALIZER.url( + "deployment_name", deployment_name, "str", max_length=64, min_length=1, pattern=r"^[-\w\._\(\)]+$" + ), } _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') - - return HttpRequest( - method="GET", - url=_url, - params=_query_parameters, - headers=_header_parameters, - **kwargs - ) + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) def build_deployments_cancel_at_management_group_scope_request( - group_id: str, - deployment_name: str, - **kwargs: Any + group_id: str, deployment_name: str, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2021-01-01") # type: 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-01-01")) # type: str + accept = _headers.pop("Accept", "application/json") - accept = "application/json" # Construct URL - _url = kwargs.pop("template_url", "/providers/Microsoft.Management/managementGroups/{groupId}/providers/Microsoft.Resources/deployments/{deploymentName}/cancel") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", + "/providers/Microsoft.Management/managementGroups/{groupId}/providers/Microsoft.Resources/deployments/{deploymentName}/cancel", + ) # pylint: disable=line-too-long path_format_arguments = { - "groupId": _SERIALIZER.url("group_id", group_id, 'str', max_length=90, min_length=1), - "deploymentName": _SERIALIZER.url("deployment_name", deployment_name, 'str', max_length=64, min_length=1, pattern=r'^[-\w\._\(\)]+$'), + "groupId": _SERIALIZER.url("group_id", group_id, "str", max_length=90, min_length=1), + "deploymentName": _SERIALIZER.url( + "deployment_name", deployment_name, "str", max_length=64, min_length=1, pattern=r"^[-\w\._\(\)]+$" + ), } _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') - - return HttpRequest( - method="POST", - url=_url, - params=_query_parameters, - headers=_header_parameters, - **kwargs - ) + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + return HttpRequest(method="POST", url=_url, params=_params, headers=_headers, **kwargs) -def build_deployments_validate_at_management_group_scope_request_initial( - group_id: str, - deployment_name: str, - *, - json: JSONType = None, - content: Any = None, - **kwargs: Any + +def build_deployments_validate_at_management_group_scope_request( + group_id: str, deployment_name: str, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2021-01-01") # type: str - content_type = kwargs.pop('content_type', None) # type: Optional[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-01-01")) # type: str + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + accept = _headers.pop("Accept", "application/json") - accept = "application/json" # Construct URL - _url = kwargs.pop("template_url", "/providers/Microsoft.Management/managementGroups/{groupId}/providers/Microsoft.Resources/deployments/{deploymentName}/validate") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", + "/providers/Microsoft.Management/managementGroups/{groupId}/providers/Microsoft.Resources/deployments/{deploymentName}/validate", + ) # pylint: disable=line-too-long path_format_arguments = { - "groupId": _SERIALIZER.url("group_id", group_id, 'str', max_length=90, min_length=1), - "deploymentName": _SERIALIZER.url("deployment_name", deployment_name, 'str', max_length=64, min_length=1, pattern=r'^[-\w\._\(\)]+$'), + "groupId": _SERIALIZER.url("group_id", group_id, "str", max_length=90, min_length=1), + "deploymentName": _SERIALIZER.url( + "deployment_name", deployment_name, "str", max_length=64, min_length=1, pattern=r"^[-\w\._\(\)]+$" + ), } _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] if content_type is not None: - _header_parameters['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') - _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') - - return HttpRequest( - method="POST", - url=_url, - params=_query_parameters, - headers=_header_parameters, - json=json, - content=content, - **kwargs - ) + _headers["Content-Type"] = _SERIALIZER.header("content_type", content_type, "str") + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + return HttpRequest(method="POST", url=_url, params=_params, headers=_headers, **kwargs) -def build_deployments_what_if_at_management_group_scope_request_initial( - group_id: str, - deployment_name: str, - *, - json: JSONType = None, - content: Any = None, - **kwargs: Any + +def build_deployments_what_if_at_management_group_scope_request( + group_id: str, deployment_name: str, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2021-01-01") # type: str - content_type = kwargs.pop('content_type', None) # type: Optional[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-01-01")) # type: str + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + accept = _headers.pop("Accept", "application/json") - accept = "application/json" # Construct URL - _url = kwargs.pop("template_url", "/providers/Microsoft.Management/managementGroups/{groupId}/providers/Microsoft.Resources/deployments/{deploymentName}/whatIf") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", + "/providers/Microsoft.Management/managementGroups/{groupId}/providers/Microsoft.Resources/deployments/{deploymentName}/whatIf", + ) # pylint: disable=line-too-long path_format_arguments = { - "groupId": _SERIALIZER.url("group_id", group_id, 'str', max_length=90, min_length=1), - "deploymentName": _SERIALIZER.url("deployment_name", deployment_name, 'str', max_length=64, min_length=1, pattern=r'^[-\w\._\(\)]+$'), + "groupId": _SERIALIZER.url("group_id", group_id, "str", max_length=90, min_length=1), + "deploymentName": _SERIALIZER.url( + "deployment_name", deployment_name, "str", max_length=64, min_length=1, pattern=r"^[-\w\._\(\)]+$" + ), } _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] if content_type is not None: - _header_parameters['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') - _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') - - return HttpRequest( - method="POST", - url=_url, - params=_query_parameters, - headers=_header_parameters, - json=json, - content=content, - **kwargs - ) + _headers["Content-Type"] = _SERIALIZER.header("content_type", content_type, "str") + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="POST", url=_url, params=_params, headers=_headers, **kwargs) def build_deployments_export_template_at_management_group_scope_request( - group_id: str, - deployment_name: str, - **kwargs: Any + group_id: str, deployment_name: str, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2021-01-01") # type: 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-01-01")) # type: str + accept = _headers.pop("Accept", "application/json") - accept = "application/json" # Construct URL - _url = kwargs.pop("template_url", "/providers/Microsoft.Management/managementGroups/{groupId}/providers/Microsoft.Resources/deployments/{deploymentName}/exportTemplate") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", + "/providers/Microsoft.Management/managementGroups/{groupId}/providers/Microsoft.Resources/deployments/{deploymentName}/exportTemplate", + ) # pylint: disable=line-too-long path_format_arguments = { - "groupId": _SERIALIZER.url("group_id", group_id, 'str', max_length=90, min_length=1), - "deploymentName": _SERIALIZER.url("deployment_name", deployment_name, 'str', max_length=64, min_length=1, pattern=r'^[-\w\._\(\)]+$'), + "groupId": _SERIALIZER.url("group_id", group_id, "str", max_length=90, min_length=1), + "deploymentName": _SERIALIZER.url( + "deployment_name", deployment_name, "str", max_length=64, min_length=1, pattern=r"^[-\w\._\(\)]+$" + ), } _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') - - return HttpRequest( - method="POST", - url=_url, - params=_query_parameters, - headers=_header_parameters, - **kwargs - ) + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="POST", url=_url, params=_params, headers=_headers, **kwargs) def build_deployments_list_at_management_group_scope_request( - group_id: str, - *, - filter: Optional[str] = None, - top: Optional[int] = None, - **kwargs: Any + group_id: str, *, filter: Optional[str] = None, top: Optional[int] = None, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2021-01-01") # type: 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-01-01")) # type: str + accept = _headers.pop("Accept", "application/json") - accept = "application/json" # Construct URL - _url = kwargs.pop("template_url", "/providers/Microsoft.Management/managementGroups/{groupId}/providers/Microsoft.Resources/deployments/") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", + "/providers/Microsoft.Management/managementGroups/{groupId}/providers/Microsoft.Resources/deployments/", + ) # pylint: disable=line-too-long path_format_arguments = { - "groupId": _SERIALIZER.url("group_id", group_id, 'str', max_length=90, min_length=1), + "groupId": _SERIALIZER.url("group_id", group_id, "str", max_length=90, min_length=1), } _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] if filter is not None: - _query_parameters['$filter'] = _SERIALIZER.query("filter", filter, 'str') + _params["$filter"] = _SERIALIZER.query("filter", filter, "str") if top is not None: - _query_parameters['$top'] = _SERIALIZER.query("top", top, 'int') - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["$top"] = _SERIALIZER.query("top", top, "int") + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') - - return HttpRequest( - method="GET", - url=_url, - params=_query_parameters, - headers=_header_parameters, - **kwargs - ) + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) -def build_deployments_delete_at_subscription_scope_request_initial( - deployment_name: str, - subscription_id: str, - **kwargs: Any + +def build_deployments_delete_at_subscription_scope_request( + deployment_name: str, subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2021-01-01") # type: 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-01-01")) # type: str + accept = _headers.pop("Accept", "application/json") - accept = "application/json" # Construct URL - _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/providers/Microsoft.Resources/deployments/{deploymentName}") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", "/subscriptions/{subscriptionId}/providers/Microsoft.Resources/deployments/{deploymentName}" + ) # pylint: disable=line-too-long path_format_arguments = { - "deploymentName": _SERIALIZER.url("deployment_name", deployment_name, 'str', max_length=64, min_length=1, pattern=r'^[-\w\._\(\)]+$'), - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), + "deploymentName": _SERIALIZER.url( + "deployment_name", deployment_name, "str", max_length=64, min_length=1, pattern=r"^[-\w\._\(\)]+$" + ), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), } _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') - - return HttpRequest( - method="DELETE", - url=_url, - params=_query_parameters, - headers=_header_parameters, - **kwargs - ) + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="DELETE", url=_url, params=_params, headers=_headers, **kwargs) def build_deployments_check_existence_at_subscription_scope_request( - deployment_name: str, - subscription_id: str, - **kwargs: Any + deployment_name: str, subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2021-01-01") # type: 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-01-01")) # type: str + accept = _headers.pop("Accept", "application/json") - accept = "application/json" # Construct URL - _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/providers/Microsoft.Resources/deployments/{deploymentName}") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", "/subscriptions/{subscriptionId}/providers/Microsoft.Resources/deployments/{deploymentName}" + ) # pylint: disable=line-too-long path_format_arguments = { - "deploymentName": _SERIALIZER.url("deployment_name", deployment_name, 'str', max_length=64, min_length=1, pattern=r'^[-\w\._\(\)]+$'), - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), + "deploymentName": _SERIALIZER.url( + "deployment_name", deployment_name, "str", max_length=64, min_length=1, pattern=r"^[-\w\._\(\)]+$" + ), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), } _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') - - return HttpRequest( - method="HEAD", - url=_url, - params=_query_parameters, - headers=_header_parameters, - **kwargs - ) + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + return HttpRequest(method="HEAD", url=_url, params=_params, headers=_headers, **kwargs) -def build_deployments_create_or_update_at_subscription_scope_request_initial( - deployment_name: str, - subscription_id: str, - *, - json: JSONType = None, - content: Any = None, - **kwargs: Any + +def build_deployments_create_or_update_at_subscription_scope_request( + deployment_name: str, subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2021-01-01") # type: str - content_type = kwargs.pop('content_type', None) # type: Optional[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-01-01")) # type: str + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + accept = _headers.pop("Accept", "application/json") - accept = "application/json" # Construct URL - _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/providers/Microsoft.Resources/deployments/{deploymentName}") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", "/subscriptions/{subscriptionId}/providers/Microsoft.Resources/deployments/{deploymentName}" + ) # pylint: disable=line-too-long path_format_arguments = { - "deploymentName": _SERIALIZER.url("deployment_name", deployment_name, 'str', max_length=64, min_length=1, pattern=r'^[-\w\._\(\)]+$'), - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), + "deploymentName": _SERIALIZER.url( + "deployment_name", deployment_name, "str", max_length=64, min_length=1, pattern=r"^[-\w\._\(\)]+$" + ), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), } _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] if content_type is not None: - _header_parameters['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') - _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') - - return HttpRequest( - method="PUT", - url=_url, - params=_query_parameters, - headers=_header_parameters, - json=json, - content=content, - **kwargs - ) + _headers["Content-Type"] = _SERIALIZER.header("content_type", content_type, "str") + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="PUT", url=_url, params=_params, headers=_headers, **kwargs) def build_deployments_get_at_subscription_scope_request( - deployment_name: str, - subscription_id: str, - **kwargs: Any + deployment_name: str, subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2021-01-01") # type: 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-01-01")) # type: str + accept = _headers.pop("Accept", "application/json") - accept = "application/json" # Construct URL - _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/providers/Microsoft.Resources/deployments/{deploymentName}") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", "/subscriptions/{subscriptionId}/providers/Microsoft.Resources/deployments/{deploymentName}" + ) # pylint: disable=line-too-long path_format_arguments = { - "deploymentName": _SERIALIZER.url("deployment_name", deployment_name, 'str', max_length=64, min_length=1, pattern=r'^[-\w\._\(\)]+$'), - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), + "deploymentName": _SERIALIZER.url( + "deployment_name", deployment_name, "str", max_length=64, min_length=1, pattern=r"^[-\w\._\(\)]+$" + ), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), } _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') - - return HttpRequest( - method="GET", - url=_url, - params=_query_parameters, - headers=_header_parameters, - **kwargs - ) + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) def build_deployments_cancel_at_subscription_scope_request( - deployment_name: str, - subscription_id: str, - **kwargs: Any + deployment_name: str, subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2021-01-01") # type: 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-01-01")) # type: str + accept = _headers.pop("Accept", "application/json") - accept = "application/json" # Construct URL - _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/providers/Microsoft.Resources/deployments/{deploymentName}/cancel") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/providers/Microsoft.Resources/deployments/{deploymentName}/cancel", + ) # pylint: disable=line-too-long path_format_arguments = { - "deploymentName": _SERIALIZER.url("deployment_name", deployment_name, 'str', max_length=64, min_length=1, pattern=r'^[-\w\._\(\)]+$'), - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), + "deploymentName": _SERIALIZER.url( + "deployment_name", deployment_name, "str", max_length=64, min_length=1, pattern=r"^[-\w\._\(\)]+$" + ), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), } _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') - - return HttpRequest( - method="POST", - url=_url, - params=_query_parameters, - headers=_header_parameters, - **kwargs - ) + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + return HttpRequest(method="POST", url=_url, params=_params, headers=_headers, **kwargs) -def build_deployments_validate_at_subscription_scope_request_initial( - deployment_name: str, - subscription_id: str, - *, - json: JSONType = None, - content: Any = None, - **kwargs: Any + +def build_deployments_validate_at_subscription_scope_request( + deployment_name: str, subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2021-01-01") # type: str - content_type = kwargs.pop('content_type', None) # type: Optional[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-01-01")) # type: str + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + accept = _headers.pop("Accept", "application/json") - accept = "application/json" # Construct URL - _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/providers/Microsoft.Resources/deployments/{deploymentName}/validate") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/providers/Microsoft.Resources/deployments/{deploymentName}/validate", + ) # pylint: disable=line-too-long path_format_arguments = { - "deploymentName": _SERIALIZER.url("deployment_name", deployment_name, 'str', max_length=64, min_length=1, pattern=r'^[-\w\._\(\)]+$'), - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), + "deploymentName": _SERIALIZER.url( + "deployment_name", deployment_name, "str", max_length=64, min_length=1, pattern=r"^[-\w\._\(\)]+$" + ), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), } _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] if content_type is not None: - _header_parameters['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') - _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') - - return HttpRequest( - method="POST", - url=_url, - params=_query_parameters, - headers=_header_parameters, - json=json, - content=content, - **kwargs - ) + _headers["Content-Type"] = _SERIALIZER.header("content_type", content_type, "str") + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + return HttpRequest(method="POST", url=_url, params=_params, headers=_headers, **kwargs) -def build_deployments_what_if_at_subscription_scope_request_initial( - deployment_name: str, - subscription_id: str, - *, - json: JSONType = None, - content: Any = None, - **kwargs: Any + +def build_deployments_what_if_at_subscription_scope_request( + deployment_name: str, subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2021-01-01") # type: str - content_type = kwargs.pop('content_type', None) # type: Optional[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-01-01")) # type: str + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + accept = _headers.pop("Accept", "application/json") - accept = "application/json" # Construct URL - _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/providers/Microsoft.Resources/deployments/{deploymentName}/whatIf") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/providers/Microsoft.Resources/deployments/{deploymentName}/whatIf", + ) # pylint: disable=line-too-long path_format_arguments = { - "deploymentName": _SERIALIZER.url("deployment_name", deployment_name, 'str', max_length=64, min_length=1, pattern=r'^[-\w\._\(\)]+$'), - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), + "deploymentName": _SERIALIZER.url( + "deployment_name", deployment_name, "str", max_length=64, min_length=1, pattern=r"^[-\w\._\(\)]+$" + ), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), } _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] if content_type is not None: - _header_parameters['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') - _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') - - return HttpRequest( - method="POST", - url=_url, - params=_query_parameters, - headers=_header_parameters, - json=json, - content=content, - **kwargs - ) + _headers["Content-Type"] = _SERIALIZER.header("content_type", content_type, "str") + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="POST", url=_url, params=_params, headers=_headers, **kwargs) def build_deployments_export_template_at_subscription_scope_request( - deployment_name: str, - subscription_id: str, - **kwargs: Any + deployment_name: str, subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2021-01-01") # type: 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-01-01")) # type: str + accept = _headers.pop("Accept", "application/json") - accept = "application/json" # Construct URL - _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/providers/Microsoft.Resources/deployments/{deploymentName}/exportTemplate") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/providers/Microsoft.Resources/deployments/{deploymentName}/exportTemplate", + ) # pylint: disable=line-too-long path_format_arguments = { - "deploymentName": _SERIALIZER.url("deployment_name", deployment_name, 'str', max_length=64, min_length=1, pattern=r'^[-\w\._\(\)]+$'), - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), + "deploymentName": _SERIALIZER.url( + "deployment_name", deployment_name, "str", max_length=64, min_length=1, pattern=r"^[-\w\._\(\)]+$" + ), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), } _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') - - return HttpRequest( - method="POST", - url=_url, - params=_query_parameters, - headers=_header_parameters, - **kwargs - ) + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="POST", url=_url, params=_params, headers=_headers, **kwargs) def build_deployments_list_at_subscription_scope_request( - subscription_id: str, - *, - filter: Optional[str] = None, - top: Optional[int] = None, - **kwargs: Any + subscription_id: str, *, filter: Optional[str] = None, top: Optional[int] = None, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2021-01-01") # type: 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-01-01")) # type: str + accept = _headers.pop("Accept", "application/json") - accept = "application/json" # Construct URL _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/providers/Microsoft.Resources/deployments/") path_format_arguments = { - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), } _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] if filter is not None: - _query_parameters['$filter'] = _SERIALIZER.query("filter", filter, 'str') + _params["$filter"] = _SERIALIZER.query("filter", filter, "str") if top is not None: - _query_parameters['$top'] = _SERIALIZER.query("top", top, 'int') - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["$top"] = _SERIALIZER.query("top", top, "int") + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') - - return HttpRequest( - method="GET", - url=_url, - params=_query_parameters, - headers=_header_parameters, - **kwargs - ) + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) -def build_deployments_delete_request_initial( - resource_group_name: str, - deployment_name: str, - subscription_id: str, - **kwargs: Any + +def build_deployments_delete_request( + resource_group_name: str, deployment_name: str, subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2021-01-01") # type: 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-01-01")) # type: str + accept = _headers.pop("Accept", "application/json") - accept = "application/json" # Construct URL - _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/Microsoft.Resources/deployments/{deploymentName}") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/Microsoft.Resources/deployments/{deploymentName}", + ) # pylint: disable=line-too-long path_format_arguments = { - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._\(\)]+$'), - "deploymentName": _SERIALIZER.url("deployment_name", deployment_name, 'str', max_length=64, min_length=1, pattern=r'^[-\w\._\(\)]+$'), - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), + "resourceGroupName": _SERIALIZER.url( + "resource_group_name", resource_group_name, "str", max_length=90, min_length=1, pattern=r"^[-\w\._\(\)]+$" + ), + "deploymentName": _SERIALIZER.url( + "deployment_name", deployment_name, "str", max_length=64, min_length=1, pattern=r"^[-\w\._\(\)]+$" + ), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), } _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') - - return HttpRequest( - method="DELETE", - url=_url, - params=_query_parameters, - headers=_header_parameters, - **kwargs - ) + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="DELETE", url=_url, params=_params, headers=_headers, **kwargs) def build_deployments_check_existence_request( - resource_group_name: str, - deployment_name: str, - subscription_id: str, - **kwargs: Any + resource_group_name: str, deployment_name: str, subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2021-01-01") # type: 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-01-01")) # type: str + accept = _headers.pop("Accept", "application/json") - accept = "application/json" # Construct URL - _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/Microsoft.Resources/deployments/{deploymentName}") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/Microsoft.Resources/deployments/{deploymentName}", + ) # pylint: disable=line-too-long path_format_arguments = { - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._\(\)]+$'), - "deploymentName": _SERIALIZER.url("deployment_name", deployment_name, 'str', max_length=64, min_length=1, pattern=r'^[-\w\._\(\)]+$'), - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), + "resourceGroupName": _SERIALIZER.url( + "resource_group_name", resource_group_name, "str", max_length=90, min_length=1, pattern=r"^[-\w\._\(\)]+$" + ), + "deploymentName": _SERIALIZER.url( + "deployment_name", deployment_name, "str", max_length=64, min_length=1, pattern=r"^[-\w\._\(\)]+$" + ), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), } _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') - - return HttpRequest( - method="HEAD", - url=_url, - params=_query_parameters, - headers=_header_parameters, - **kwargs - ) + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + return HttpRequest(method="HEAD", url=_url, params=_params, headers=_headers, **kwargs) -def build_deployments_create_or_update_request_initial( - resource_group_name: str, - deployment_name: str, - subscription_id: str, - *, - json: JSONType = None, - content: Any = None, - **kwargs: Any + +def build_deployments_create_or_update_request( + resource_group_name: str, deployment_name: str, subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2021-01-01") # type: str - content_type = kwargs.pop('content_type', None) # type: Optional[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-01-01")) # type: str + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + accept = _headers.pop("Accept", "application/json") - accept = "application/json" # Construct URL - _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/Microsoft.Resources/deployments/{deploymentName}") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/Microsoft.Resources/deployments/{deploymentName}", + ) # pylint: disable=line-too-long path_format_arguments = { - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._\(\)]+$'), - "deploymentName": _SERIALIZER.url("deployment_name", deployment_name, 'str', max_length=64, min_length=1, pattern=r'^[-\w\._\(\)]+$'), - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), + "resourceGroupName": _SERIALIZER.url( + "resource_group_name", resource_group_name, "str", max_length=90, min_length=1, pattern=r"^[-\w\._\(\)]+$" + ), + "deploymentName": _SERIALIZER.url( + "deployment_name", deployment_name, "str", max_length=64, min_length=1, pattern=r"^[-\w\._\(\)]+$" + ), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), } _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] if content_type is not None: - _header_parameters['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') - _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') - - return HttpRequest( - method="PUT", - url=_url, - params=_query_parameters, - headers=_header_parameters, - json=json, - content=content, - **kwargs - ) + _headers["Content-Type"] = _SERIALIZER.header("content_type", content_type, "str") + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="PUT", url=_url, params=_params, headers=_headers, **kwargs) def build_deployments_get_request( - resource_group_name: str, - deployment_name: str, - subscription_id: str, - **kwargs: Any + resource_group_name: str, deployment_name: str, subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2021-01-01") # type: 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-01-01")) # type: str + accept = _headers.pop("Accept", "application/json") - accept = "application/json" # Construct URL - _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/Microsoft.Resources/deployments/{deploymentName}") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/Microsoft.Resources/deployments/{deploymentName}", + ) # pylint: disable=line-too-long path_format_arguments = { - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._\(\)]+$'), - "deploymentName": _SERIALIZER.url("deployment_name", deployment_name, 'str', max_length=64, min_length=1, pattern=r'^[-\w\._\(\)]+$'), - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), + "resourceGroupName": _SERIALIZER.url( + "resource_group_name", resource_group_name, "str", max_length=90, min_length=1, pattern=r"^[-\w\._\(\)]+$" + ), + "deploymentName": _SERIALIZER.url( + "deployment_name", deployment_name, "str", max_length=64, min_length=1, pattern=r"^[-\w\._\(\)]+$" + ), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), } _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') - - return HttpRequest( - method="GET", - url=_url, - params=_query_parameters, - headers=_header_parameters, - **kwargs - ) + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) def build_deployments_cancel_request( - resource_group_name: str, - deployment_name: str, - subscription_id: str, - **kwargs: Any + resource_group_name: str, deployment_name: str, subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2021-01-01") # type: 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-01-01")) # type: str + accept = _headers.pop("Accept", "application/json") - accept = "application/json" # Construct URL - _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/Microsoft.Resources/deployments/{deploymentName}/cancel") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/Microsoft.Resources/deployments/{deploymentName}/cancel", + ) # pylint: disable=line-too-long path_format_arguments = { - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._\(\)]+$'), - "deploymentName": _SERIALIZER.url("deployment_name", deployment_name, 'str', max_length=64, min_length=1, pattern=r'^[-\w\._\(\)]+$'), - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), + "resourceGroupName": _SERIALIZER.url( + "resource_group_name", resource_group_name, "str", max_length=90, min_length=1, pattern=r"^[-\w\._\(\)]+$" + ), + "deploymentName": _SERIALIZER.url( + "deployment_name", deployment_name, "str", max_length=64, min_length=1, pattern=r"^[-\w\._\(\)]+$" + ), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), } _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') - - return HttpRequest( - method="POST", - url=_url, - params=_query_parameters, - headers=_header_parameters, - **kwargs - ) + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + return HttpRequest(method="POST", url=_url, params=_params, headers=_headers, **kwargs) -def build_deployments_validate_request_initial( - resource_group_name: str, - deployment_name: str, - subscription_id: str, - *, - json: JSONType = None, - content: Any = None, - **kwargs: Any + +def build_deployments_validate_request( + resource_group_name: str, deployment_name: str, subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2021-01-01") # type: str - content_type = kwargs.pop('content_type', None) # type: Optional[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-01-01")) # type: str + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + accept = _headers.pop("Accept", "application/json") - accept = "application/json" # Construct URL - _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/Microsoft.Resources/deployments/{deploymentName}/validate") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/Microsoft.Resources/deployments/{deploymentName}/validate", + ) # pylint: disable=line-too-long path_format_arguments = { - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._\(\)]+$'), - "deploymentName": _SERIALIZER.url("deployment_name", deployment_name, 'str', max_length=64, min_length=1, pattern=r'^[-\w\._\(\)]+$'), - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), + "resourceGroupName": _SERIALIZER.url( + "resource_group_name", resource_group_name, "str", max_length=90, min_length=1, pattern=r"^[-\w\._\(\)]+$" + ), + "deploymentName": _SERIALIZER.url( + "deployment_name", deployment_name, "str", max_length=64, min_length=1, pattern=r"^[-\w\._\(\)]+$" + ), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), } _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] if content_type is not None: - _header_parameters['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') - _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') - - return HttpRequest( - method="POST", - url=_url, - params=_query_parameters, - headers=_header_parameters, - json=json, - content=content, - **kwargs - ) + _headers["Content-Type"] = _SERIALIZER.header("content_type", content_type, "str") + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + return HttpRequest(method="POST", url=_url, params=_params, headers=_headers, **kwargs) -def build_deployments_what_if_request_initial( - resource_group_name: str, - deployment_name: str, - subscription_id: str, - *, - json: JSONType = None, - content: Any = None, - **kwargs: Any + +def build_deployments_what_if_request( + resource_group_name: str, deployment_name: str, subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2021-01-01") # type: str - content_type = kwargs.pop('content_type', None) # type: Optional[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-01-01")) # type: str + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + accept = _headers.pop("Accept", "application/json") - accept = "application/json" # Construct URL - _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/Microsoft.Resources/deployments/{deploymentName}/whatIf") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/Microsoft.Resources/deployments/{deploymentName}/whatIf", + ) # pylint: disable=line-too-long path_format_arguments = { - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._\(\)]+$'), - "deploymentName": _SERIALIZER.url("deployment_name", deployment_name, 'str', max_length=64, min_length=1, pattern=r'^[-\w\._\(\)]+$'), - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), + "resourceGroupName": _SERIALIZER.url( + "resource_group_name", resource_group_name, "str", max_length=90, min_length=1, pattern=r"^[-\w\._\(\)]+$" + ), + "deploymentName": _SERIALIZER.url( + "deployment_name", deployment_name, "str", max_length=64, min_length=1, pattern=r"^[-\w\._\(\)]+$" + ), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), } _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] if content_type is not None: - _header_parameters['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') - _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') - - return HttpRequest( - method="POST", - url=_url, - params=_query_parameters, - headers=_header_parameters, - json=json, - content=content, - **kwargs - ) + _headers["Content-Type"] = _SERIALIZER.header("content_type", content_type, "str") + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="POST", url=_url, params=_params, headers=_headers, **kwargs) def build_deployments_export_template_request( - resource_group_name: str, - deployment_name: str, - subscription_id: str, - **kwargs: Any + resource_group_name: str, deployment_name: str, subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2021-01-01") # type: 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-01-01")) # type: str + accept = _headers.pop("Accept", "application/json") - accept = "application/json" # Construct URL - _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/Microsoft.Resources/deployments/{deploymentName}/exportTemplate") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/Microsoft.Resources/deployments/{deploymentName}/exportTemplate", + ) # pylint: disable=line-too-long path_format_arguments = { - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._\(\)]+$'), - "deploymentName": _SERIALIZER.url("deployment_name", deployment_name, 'str', max_length=64, min_length=1, pattern=r'^[-\w\._\(\)]+$'), - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), + "resourceGroupName": _SERIALIZER.url( + "resource_group_name", resource_group_name, "str", max_length=90, min_length=1, pattern=r"^[-\w\._\(\)]+$" + ), + "deploymentName": _SERIALIZER.url( + "deployment_name", deployment_name, "str", max_length=64, min_length=1, pattern=r"^[-\w\._\(\)]+$" + ), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), } _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') - - return HttpRequest( - method="POST", - url=_url, - params=_query_parameters, - headers=_header_parameters, - **kwargs - ) + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="POST", url=_url, params=_params, headers=_headers, **kwargs) def build_deployments_list_by_resource_group_request( @@ -1651,357 +1418,288 @@ def build_deployments_list_by_resource_group_request( top: Optional[int] = None, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2021-01-01") # type: 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-01-01")) # type: str + accept = _headers.pop("Accept", "application/json") - accept = "application/json" # Construct URL - _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/Microsoft.Resources/deployments/") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/Microsoft.Resources/deployments/", + ) # pylint: disable=line-too-long path_format_arguments = { - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._\(\)]+$'), - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), + "resourceGroupName": _SERIALIZER.url( + "resource_group_name", resource_group_name, "str", max_length=90, min_length=1, pattern=r"^[-\w\._\(\)]+$" + ), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), } _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] if filter is not None: - _query_parameters['$filter'] = _SERIALIZER.query("filter", filter, 'str') + _params["$filter"] = _SERIALIZER.query("filter", filter, "str") if top is not None: - _query_parameters['$top'] = _SERIALIZER.query("top", top, 'int') - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["$top"] = _SERIALIZER.query("top", top, "int") + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') - - return HttpRequest( - method="GET", - url=_url, - params=_query_parameters, - headers=_header_parameters, - **kwargs - ) + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) -def build_deployments_calculate_template_hash_request( - *, - json: JSONType = None, - content: Any = None, - **kwargs: Any -) -> HttpRequest: - api_version = kwargs.pop('api_version', "2021-01-01") # type: str - content_type = kwargs.pop('content_type', None) # type: Optional[str] - accept = "application/json" +def build_deployments_calculate_template_hash_request(*, json: JSON, **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-01-01")) # type: str + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + accept = _headers.pop("Accept", "application/json") + # Construct URL _url = kwargs.pop("template_url", "/providers/Microsoft.Resources/calculateTemplateHash") # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] if content_type is not None: - _header_parameters['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') - _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') - - return HttpRequest( - method="POST", - url=_url, - params=_query_parameters, - headers=_header_parameters, - json=json, - content=content, - **kwargs - ) + _headers["Content-Type"] = _SERIALIZER.header("content_type", content_type, "str") + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="POST", url=_url, params=_params, headers=_headers, json=json, **kwargs) def build_providers_unregister_request( - resource_provider_namespace: str, - subscription_id: str, - **kwargs: Any + resource_provider_namespace: str, subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2021-01-01") # type: 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-01-01")) # type: str + accept = _headers.pop("Accept", "application/json") - accept = "application/json" # Construct URL - _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/providers/{resourceProviderNamespace}/unregister") + _url = kwargs.pop( + "template_url", "/subscriptions/{subscriptionId}/providers/{resourceProviderNamespace}/unregister" + ) path_format_arguments = { - "resourceProviderNamespace": _SERIALIZER.url("resource_provider_namespace", resource_provider_namespace, 'str'), - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), + "resourceProviderNamespace": _SERIALIZER.url("resource_provider_namespace", resource_provider_namespace, "str"), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), } _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') - - return HttpRequest( - method="POST", - url=_url, - params=_query_parameters, - headers=_header_parameters, - **kwargs - ) + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="POST", url=_url, params=_params, headers=_headers, **kwargs) def build_providers_register_at_management_group_scope_request( - resource_provider_namespace: str, - group_id: str, - **kwargs: Any + resource_provider_namespace: str, group_id: str, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2021-01-01") # type: 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-01-01")) # type: str + accept = _headers.pop("Accept", "application/json") - accept = "application/json" # Construct URL - _url = kwargs.pop("template_url", "/providers/Microsoft.Management/managementGroups/{groupId}/providers/{resourceProviderNamespace}/register") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", + "/providers/Microsoft.Management/managementGroups/{groupId}/providers/{resourceProviderNamespace}/register", + ) # pylint: disable=line-too-long path_format_arguments = { - "resourceProviderNamespace": _SERIALIZER.url("resource_provider_namespace", resource_provider_namespace, 'str'), - "groupId": _SERIALIZER.url("group_id", group_id, 'str', max_length=90, min_length=1), + "resourceProviderNamespace": _SERIALIZER.url("resource_provider_namespace", resource_provider_namespace, "str"), + "groupId": _SERIALIZER.url("group_id", group_id, "str", max_length=90, min_length=1), } _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') - - return HttpRequest( - method="POST", - url=_url, - params=_query_parameters, - headers=_header_parameters, - **kwargs - ) + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="POST", url=_url, params=_params, headers=_headers, **kwargs) def build_providers_register_request( - resource_provider_namespace: str, - subscription_id: str, - **kwargs: Any + resource_provider_namespace: str, subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2021-01-01") # type: 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-01-01")) # type: str + accept = _headers.pop("Accept", "application/json") - accept = "application/json" # Construct URL _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/providers/{resourceProviderNamespace}/register") path_format_arguments = { - "resourceProviderNamespace": _SERIALIZER.url("resource_provider_namespace", resource_provider_namespace, 'str'), - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), + "resourceProviderNamespace": _SERIALIZER.url("resource_provider_namespace", resource_provider_namespace, "str"), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), } _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') - - return HttpRequest( - method="POST", - url=_url, - params=_query_parameters, - headers=_header_parameters, - **kwargs - ) + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="POST", url=_url, params=_params, headers=_headers, **kwargs) def build_providers_list_request( - subscription_id: str, - *, - top: Optional[int] = None, - expand: Optional[str] = None, - **kwargs: Any + subscription_id: str, *, top: Optional[int] = None, expand: Optional[str] = None, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2021-01-01") # type: 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-01-01")) # type: str + accept = _headers.pop("Accept", "application/json") - accept = "application/json" # Construct URL _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/providers") path_format_arguments = { - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), } _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] if top is not None: - _query_parameters['$top'] = _SERIALIZER.query("top", top, 'int') + _params["$top"] = _SERIALIZER.query("top", top, "int") if expand is not None: - _query_parameters['$expand'] = _SERIALIZER.query("expand", expand, 'str') - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["$expand"] = _SERIALIZER.query("expand", expand, "str") + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') - - return HttpRequest( - method="GET", - url=_url, - params=_query_parameters, - headers=_header_parameters, - **kwargs - ) + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) def build_providers_list_at_tenant_scope_request( - *, - top: Optional[int] = None, - expand: Optional[str] = None, - **kwargs: Any + *, top: Optional[int] = None, expand: Optional[str] = None, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2021-01-01") # type: 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-01-01")) # type: str + accept = _headers.pop("Accept", "application/json") - accept = "application/json" # Construct URL _url = kwargs.pop("template_url", "/providers") # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] if top is not None: - _query_parameters['$top'] = _SERIALIZER.query("top", top, 'int') + _params["$top"] = _SERIALIZER.query("top", top, "int") if expand is not None: - _query_parameters['$expand'] = _SERIALIZER.query("expand", expand, 'str') - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["$expand"] = _SERIALIZER.query("expand", expand, "str") + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') - - return HttpRequest( - method="GET", - url=_url, - params=_query_parameters, - headers=_header_parameters, - **kwargs - ) + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) def build_providers_get_request( - resource_provider_namespace: str, - subscription_id: str, - *, - expand: Optional[str] = None, - **kwargs: Any + resource_provider_namespace: str, subscription_id: str, *, expand: Optional[str] = None, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2021-01-01") # type: 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-01-01")) # type: str + accept = _headers.pop("Accept", "application/json") - accept = "application/json" # Construct URL _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/providers/{resourceProviderNamespace}") path_format_arguments = { - "resourceProviderNamespace": _SERIALIZER.url("resource_provider_namespace", resource_provider_namespace, 'str'), - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), + "resourceProviderNamespace": _SERIALIZER.url("resource_provider_namespace", resource_provider_namespace, "str"), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), } _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] if expand is not None: - _query_parameters['$expand'] = _SERIALIZER.query("expand", expand, 'str') - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["$expand"] = _SERIALIZER.query("expand", expand, "str") + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') - - return HttpRequest( - method="GET", - url=_url, - params=_query_parameters, - headers=_header_parameters, - **kwargs - ) + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) def build_providers_get_at_tenant_scope_request( - resource_provider_namespace: str, - *, - expand: Optional[str] = None, - **kwargs: Any + resource_provider_namespace: str, *, expand: Optional[str] = None, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2021-01-01") # type: 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-01-01")) # type: str + accept = _headers.pop("Accept", "application/json") - accept = "application/json" # Construct URL _url = kwargs.pop("template_url", "/providers/{resourceProviderNamespace}") path_format_arguments = { - "resourceProviderNamespace": _SERIALIZER.url("resource_provider_namespace", resource_provider_namespace, 'str'), + "resourceProviderNamespace": _SERIALIZER.url("resource_provider_namespace", resource_provider_namespace, "str"), } _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] if expand is not None: - _query_parameters['$expand'] = _SERIALIZER.query("expand", expand, 'str') - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["$expand"] = _SERIALIZER.query("expand", expand, "str") + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') - - return HttpRequest( - method="GET", - url=_url, - params=_query_parameters, - headers=_header_parameters, - **kwargs - ) + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) def build_provider_resource_types_list_request( - resource_provider_namespace: str, - subscription_id: str, - *, - expand: Optional[str] = None, - **kwargs: Any + resource_provider_namespace: str, subscription_id: str, *, expand: Optional[str] = None, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2021-01-01") # type: 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-01-01")) # type: str + accept = _headers.pop("Accept", "application/json") - accept = "application/json" # Construct URL - _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/providers/{resourceProviderNamespace}/resourceTypes") + _url = kwargs.pop( + "template_url", "/subscriptions/{subscriptionId}/providers/{resourceProviderNamespace}/resourceTypes" + ) path_format_arguments = { - "resourceProviderNamespace": _SERIALIZER.url("resource_provider_namespace", resource_provider_namespace, 'str'), - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), + "resourceProviderNamespace": _SERIALIZER.url("resource_provider_namespace", resource_provider_namespace, "str"), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), } _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] if expand is not None: - _query_parameters['$expand'] = _SERIALIZER.query("expand", expand, 'str') - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["$expand"] = _SERIALIZER.query("expand", expand, "str") + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') - - return HttpRequest( - method="GET", - url=_url, - params=_query_parameters, - headers=_header_parameters, - **kwargs - ) + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) def build_resources_list_by_resource_group_request( @@ -2013,123 +1711,114 @@ def build_resources_list_by_resource_group_request( top: Optional[int] = None, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2021-01-01") # type: 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-01-01")) # type: str + accept = _headers.pop("Accept", "application/json") - accept = "application/json" # Construct URL _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/resources") path_format_arguments = { - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._\(\)]+$'), - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), + "resourceGroupName": _SERIALIZER.url( + "resource_group_name", resource_group_name, "str", max_length=90, min_length=1, pattern=r"^[-\w\._\(\)]+$" + ), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), } _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] if filter is not None: - _query_parameters['$filter'] = _SERIALIZER.query("filter", filter, 'str') + _params["$filter"] = _SERIALIZER.query("filter", filter, "str") if expand is not None: - _query_parameters['$expand'] = _SERIALIZER.query("expand", expand, 'str') + _params["$expand"] = _SERIALIZER.query("expand", expand, "str") if top is not None: - _query_parameters['$top'] = _SERIALIZER.query("top", top, 'int') - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["$top"] = _SERIALIZER.query("top", top, "int") + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') - - return HttpRequest( - method="GET", - url=_url, - params=_query_parameters, - headers=_header_parameters, - **kwargs - ) + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) -def build_resources_move_resources_request_initial( - source_resource_group_name: str, - subscription_id: str, - *, - json: JSONType = None, - content: Any = None, - **kwargs: Any + +def build_resources_move_resources_request( + source_resource_group_name: str, subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2021-01-01") # type: str - content_type = kwargs.pop('content_type', None) # type: Optional[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-01-01")) # type: str + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + accept = _headers.pop("Accept", "application/json") - accept = "application/json" # Construct URL - _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{sourceResourceGroupName}/moveResources") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", "/subscriptions/{subscriptionId}/resourceGroups/{sourceResourceGroupName}/moveResources" + ) # pylint: disable=line-too-long path_format_arguments = { - "sourceResourceGroupName": _SERIALIZER.url("source_resource_group_name", source_resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._\(\)]+$'), - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), + "sourceResourceGroupName": _SERIALIZER.url( + "source_resource_group_name", + source_resource_group_name, + "str", + max_length=90, + min_length=1, + pattern=r"^[-\w\._\(\)]+$", + ), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), } _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] if content_type is not None: - _header_parameters['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') - _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') - - return HttpRequest( - method="POST", - url=_url, - params=_query_parameters, - headers=_header_parameters, - json=json, - content=content, - **kwargs - ) + _headers["Content-Type"] = _SERIALIZER.header("content_type", content_type, "str") + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + return HttpRequest(method="POST", url=_url, params=_params, headers=_headers, **kwargs) -def build_resources_validate_move_resources_request_initial( - source_resource_group_name: str, - subscription_id: str, - *, - json: JSONType = None, - content: Any = None, - **kwargs: Any + +def build_resources_validate_move_resources_request( + source_resource_group_name: str, subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2021-01-01") # type: str - content_type = kwargs.pop('content_type', None) # type: Optional[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-01-01")) # type: str + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + accept = _headers.pop("Accept", "application/json") - accept = "application/json" # Construct URL - _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{sourceResourceGroupName}/validateMoveResources") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", "/subscriptions/{subscriptionId}/resourceGroups/{sourceResourceGroupName}/validateMoveResources" + ) # pylint: disable=line-too-long path_format_arguments = { - "sourceResourceGroupName": _SERIALIZER.url("source_resource_group_name", source_resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._\(\)]+$'), - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), + "sourceResourceGroupName": _SERIALIZER.url( + "source_resource_group_name", + source_resource_group_name, + "str", + max_length=90, + min_length=1, + pattern=r"^[-\w\._\(\)]+$", + ), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), } _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] if content_type is not None: - _header_parameters['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') - _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') - - return HttpRequest( - method="POST", - url=_url, - params=_query_parameters, - headers=_header_parameters, - json=json, - content=content, - **kwargs - ) + _headers["Content-Type"] = _SERIALIZER.header("content_type", content_type, "str") + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="POST", url=_url, params=_params, headers=_headers, **kwargs) def build_resources_list_request( @@ -2140,38 +1829,33 @@ def build_resources_list_request( top: Optional[int] = None, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2021-01-01") # type: 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-01-01")) # type: str + accept = _headers.pop("Accept", "application/json") - accept = "application/json" # Construct URL _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resources") path_format_arguments = { - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), } _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] if filter is not None: - _query_parameters['$filter'] = _SERIALIZER.query("filter", filter, 'str') + _params["$filter"] = _SERIALIZER.query("filter", filter, "str") if expand is not None: - _query_parameters['$expand'] = _SERIALIZER.query("expand", expand, 'str') + _params["$expand"] = _SERIALIZER.query("expand", expand, "str") if top is not None: - _query_parameters['$top'] = _SERIALIZER.query("top", top, 'int') - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["$top"] = _SERIALIZER.query("top", top, "int") + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') - - return HttpRequest( - method="GET", - url=_url, - params=_query_parameters, - headers=_header_parameters, - **kwargs - ) + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) def build_resources_check_existence_request( @@ -2185,38 +1869,39 @@ def build_resources_check_existence_request( api_version: str, **kwargs: Any ) -> HttpRequest: - accept = "application/json" + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + accept = _headers.pop("Accept", "application/json") + # Construct URL - _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{parentResourcePath}/{resourceType}/{resourceName}") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{parentResourcePath}/{resourceType}/{resourceName}", + ) # pylint: disable=line-too-long path_format_arguments = { - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._\(\)]+$'), - "resourceProviderNamespace": _SERIALIZER.url("resource_provider_namespace", resource_provider_namespace, 'str'), - "parentResourcePath": _SERIALIZER.url("parent_resource_path", parent_resource_path, 'str', skip_quote=True), - "resourceType": _SERIALIZER.url("resource_type", resource_type, 'str', skip_quote=True), - "resourceName": _SERIALIZER.url("resource_name", resource_name, 'str'), - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), + "resourceGroupName": _SERIALIZER.url( + "resource_group_name", resource_group_name, "str", max_length=90, min_length=1, pattern=r"^[-\w\._\(\)]+$" + ), + "resourceProviderNamespace": _SERIALIZER.url("resource_provider_namespace", resource_provider_namespace, "str"), + "parentResourcePath": _SERIALIZER.url("parent_resource_path", parent_resource_path, "str", skip_quote=True), + "resourceType": _SERIALIZER.url("resource_type", resource_type, "str", skip_quote=True), + "resourceName": _SERIALIZER.url("resource_name", resource_name, "str"), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), } _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') - - return HttpRequest( - method="HEAD", - url=_url, - params=_query_parameters, - headers=_header_parameters, - **kwargs - ) + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="HEAD", url=_url, params=_params, headers=_headers, **kwargs) -def build_resources_delete_request_initial( +def build_resources_delete_request( resource_group_name: str, resource_provider_namespace: str, parent_resource_path: str, @@ -2227,38 +1912,39 @@ def build_resources_delete_request_initial( api_version: str, **kwargs: Any ) -> HttpRequest: - accept = "application/json" + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + accept = _headers.pop("Accept", "application/json") + # Construct URL - _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{parentResourcePath}/{resourceType}/{resourceName}") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{parentResourcePath}/{resourceType}/{resourceName}", + ) # pylint: disable=line-too-long path_format_arguments = { - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._\(\)]+$'), - "resourceProviderNamespace": _SERIALIZER.url("resource_provider_namespace", resource_provider_namespace, 'str'), - "parentResourcePath": _SERIALIZER.url("parent_resource_path", parent_resource_path, 'str', skip_quote=True), - "resourceType": _SERIALIZER.url("resource_type", resource_type, 'str', skip_quote=True), - "resourceName": _SERIALIZER.url("resource_name", resource_name, 'str'), - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), + "resourceGroupName": _SERIALIZER.url( + "resource_group_name", resource_group_name, "str", max_length=90, min_length=1, pattern=r"^[-\w\._\(\)]+$" + ), + "resourceProviderNamespace": _SERIALIZER.url("resource_provider_namespace", resource_provider_namespace, "str"), + "parentResourcePath": _SERIALIZER.url("parent_resource_path", parent_resource_path, "str", skip_quote=True), + "resourceType": _SERIALIZER.url("resource_type", resource_type, "str", skip_quote=True), + "resourceName": _SERIALIZER.url("resource_name", resource_name, "str"), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), } _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') - - return HttpRequest( - method="DELETE", - url=_url, - params=_query_parameters, - headers=_header_parameters, - **kwargs - ) + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="DELETE", url=_url, params=_params, headers=_headers, **kwargs) -def build_resources_create_or_update_request_initial( +def build_resources_create_or_update_request( resource_group_name: str, resource_provider_namespace: str, parent_resource_path: str, @@ -2267,48 +1953,44 @@ def build_resources_create_or_update_request_initial( subscription_id: str, *, api_version: str, - json: JSONType = None, - content: Any = None, **kwargs: Any ) -> HttpRequest: - content_type = kwargs.pop('content_type', None) # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + accept = _headers.pop("Accept", "application/json") - accept = "application/json" # Construct URL - _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{parentResourcePath}/{resourceType}/{resourceName}") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{parentResourcePath}/{resourceType}/{resourceName}", + ) # pylint: disable=line-too-long path_format_arguments = { - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._\(\)]+$'), - "resourceProviderNamespace": _SERIALIZER.url("resource_provider_namespace", resource_provider_namespace, 'str'), - "parentResourcePath": _SERIALIZER.url("parent_resource_path", parent_resource_path, 'str', skip_quote=True), - "resourceType": _SERIALIZER.url("resource_type", resource_type, 'str', skip_quote=True), - "resourceName": _SERIALIZER.url("resource_name", resource_name, 'str'), - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), + "resourceGroupName": _SERIALIZER.url( + "resource_group_name", resource_group_name, "str", max_length=90, min_length=1, pattern=r"^[-\w\._\(\)]+$" + ), + "resourceProviderNamespace": _SERIALIZER.url("resource_provider_namespace", resource_provider_namespace, "str"), + "parentResourcePath": _SERIALIZER.url("parent_resource_path", parent_resource_path, "str", skip_quote=True), + "resourceType": _SERIALIZER.url("resource_type", resource_type, "str", skip_quote=True), + "resourceName": _SERIALIZER.url("resource_name", resource_name, "str"), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), } _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] if content_type is not None: - _header_parameters['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') - _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') - - return HttpRequest( - method="PUT", - url=_url, - params=_query_parameters, - headers=_header_parameters, - json=json, - content=content, - **kwargs - ) + _headers["Content-Type"] = _SERIALIZER.header("content_type", content_type, "str") + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + return HttpRequest(method="PUT", url=_url, params=_params, headers=_headers, **kwargs) -def build_resources_update_request_initial( + +def build_resources_update_request( resource_group_name: str, resource_provider_namespace: str, parent_resource_path: str, @@ -2317,45 +1999,41 @@ def build_resources_update_request_initial( subscription_id: str, *, api_version: str, - json: JSONType = None, - content: Any = None, **kwargs: Any ) -> HttpRequest: - content_type = kwargs.pop('content_type', None) # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + accept = _headers.pop("Accept", "application/json") - accept = "application/json" # Construct URL - _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{parentResourcePath}/{resourceType}/{resourceName}") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{parentResourcePath}/{resourceType}/{resourceName}", + ) # pylint: disable=line-too-long path_format_arguments = { - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._\(\)]+$'), - "resourceProviderNamespace": _SERIALIZER.url("resource_provider_namespace", resource_provider_namespace, 'str'), - "parentResourcePath": _SERIALIZER.url("parent_resource_path", parent_resource_path, 'str', skip_quote=True), - "resourceType": _SERIALIZER.url("resource_type", resource_type, 'str', skip_quote=True), - "resourceName": _SERIALIZER.url("resource_name", resource_name, 'str'), - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), + "resourceGroupName": _SERIALIZER.url( + "resource_group_name", resource_group_name, "str", max_length=90, min_length=1, pattern=r"^[-\w\._\(\)]+$" + ), + "resourceProviderNamespace": _SERIALIZER.url("resource_provider_namespace", resource_provider_namespace, "str"), + "parentResourcePath": _SERIALIZER.url("parent_resource_path", parent_resource_path, "str", skip_quote=True), + "resourceType": _SERIALIZER.url("resource_type", resource_type, "str", skip_quote=True), + "resourceName": _SERIALIZER.url("resource_name", resource_name, "str"), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), } _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] if content_type is not None: - _header_parameters['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') - _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') - - return HttpRequest( - method="PATCH", - url=_url, - params=_query_parameters, - headers=_header_parameters, - json=json, - content=content, - **kwargs - ) + _headers["Content-Type"] = _SERIALIZER.header("content_type", content_type, "str") + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="PATCH", url=_url, params=_params, headers=_headers, **kwargs) def build_resources_get_request( @@ -2369,1228 +2047,996 @@ def build_resources_get_request( api_version: str, **kwargs: Any ) -> HttpRequest: - accept = "application/json" + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + accept = _headers.pop("Accept", "application/json") + # Construct URL - _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{parentResourcePath}/{resourceType}/{resourceName}") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{parentResourcePath}/{resourceType}/{resourceName}", + ) # pylint: disable=line-too-long path_format_arguments = { - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._\(\)]+$'), - "resourceProviderNamespace": _SERIALIZER.url("resource_provider_namespace", resource_provider_namespace, 'str'), - "parentResourcePath": _SERIALIZER.url("parent_resource_path", parent_resource_path, 'str', skip_quote=True), - "resourceType": _SERIALIZER.url("resource_type", resource_type, 'str', skip_quote=True), - "resourceName": _SERIALIZER.url("resource_name", resource_name, 'str'), - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), + "resourceGroupName": _SERIALIZER.url( + "resource_group_name", resource_group_name, "str", max_length=90, min_length=1, pattern=r"^[-\w\._\(\)]+$" + ), + "resourceProviderNamespace": _SERIALIZER.url("resource_provider_namespace", resource_provider_namespace, "str"), + "parentResourcePath": _SERIALIZER.url("parent_resource_path", parent_resource_path, "str", skip_quote=True), + "resourceType": _SERIALIZER.url("resource_type", resource_type, "str", skip_quote=True), + "resourceName": _SERIALIZER.url("resource_name", resource_name, "str"), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), } _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') - - return HttpRequest( - method="GET", - url=_url, - params=_query_parameters, - headers=_header_parameters, - **kwargs - ) + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) + + +def build_resources_check_existence_by_id_request(resource_id: str, *, api_version: str, **kwargs: Any) -> HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + accept = _headers.pop("Accept", "application/json") -def build_resources_check_existence_by_id_request( - resource_id: str, - *, - api_version: str, - **kwargs: Any -) -> HttpRequest: - accept = "application/json" # Construct URL _url = kwargs.pop("template_url", "/{resourceId}") path_format_arguments = { - "resourceId": _SERIALIZER.url("resource_id", resource_id, 'str', skip_quote=True), + "resourceId": _SERIALIZER.url("resource_id", resource_id, "str", skip_quote=True), } _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') - - return HttpRequest( - method="HEAD", - url=_url, - params=_query_parameters, - headers=_header_parameters, - **kwargs - ) + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + return HttpRequest(method="HEAD", url=_url, params=_params, headers=_headers, **kwargs) + + +def build_resources_delete_by_id_request(resource_id: str, *, api_version: str, **kwargs: Any) -> HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + accept = _headers.pop("Accept", "application/json") -def build_resources_delete_by_id_request_initial( - resource_id: str, - *, - api_version: str, - **kwargs: Any -) -> HttpRequest: - accept = "application/json" # Construct URL _url = kwargs.pop("template_url", "/{resourceId}") path_format_arguments = { - "resourceId": _SERIALIZER.url("resource_id", resource_id, 'str', skip_quote=True), + "resourceId": _SERIALIZER.url("resource_id", resource_id, "str", skip_quote=True), } _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') - - return HttpRequest( - method="DELETE", - url=_url, - params=_query_parameters, - headers=_header_parameters, - **kwargs - ) + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + return HttpRequest(method="DELETE", url=_url, params=_params, headers=_headers, **kwargs) -def build_resources_create_or_update_by_id_request_initial( - resource_id: str, - *, - api_version: str, - json: JSONType = None, - content: Any = None, - **kwargs: Any -) -> HttpRequest: - content_type = kwargs.pop('content_type', None) # type: Optional[str] - accept = "application/json" +def build_resources_create_or_update_by_id_request(resource_id: str, *, api_version: str, **kwargs: Any) -> HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + accept = _headers.pop("Accept", "application/json") + # Construct URL _url = kwargs.pop("template_url", "/{resourceId}") path_format_arguments = { - "resourceId": _SERIALIZER.url("resource_id", resource_id, 'str', skip_quote=True), + "resourceId": _SERIALIZER.url("resource_id", resource_id, "str", skip_quote=True), } _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] if content_type is not None: - _header_parameters['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') - _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') - - return HttpRequest( - method="PUT", - url=_url, - params=_query_parameters, - headers=_header_parameters, - json=json, - content=content, - **kwargs - ) + _headers["Content-Type"] = _SERIALIZER.header("content_type", content_type, "str") + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + return HttpRequest(method="PUT", url=_url, params=_params, headers=_headers, **kwargs) -def build_resources_update_by_id_request_initial( - resource_id: str, - *, - api_version: str, - json: JSONType = None, - content: Any = None, - **kwargs: Any -) -> HttpRequest: - content_type = kwargs.pop('content_type', None) # type: Optional[str] - accept = "application/json" +def build_resources_update_by_id_request(resource_id: str, *, api_version: str, **kwargs: Any) -> HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + accept = _headers.pop("Accept", "application/json") + # Construct URL _url = kwargs.pop("template_url", "/{resourceId}") path_format_arguments = { - "resourceId": _SERIALIZER.url("resource_id", resource_id, 'str', skip_quote=True), + "resourceId": _SERIALIZER.url("resource_id", resource_id, "str", skip_quote=True), } _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] if content_type is not None: - _header_parameters['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') - _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') - - return HttpRequest( - method="PATCH", - url=_url, - params=_query_parameters, - headers=_header_parameters, - json=json, - content=content, - **kwargs - ) + _headers["Content-Type"] = _SERIALIZER.header("content_type", content_type, "str") + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + return HttpRequest(method="PATCH", url=_url, params=_params, headers=_headers, **kwargs) + + +def build_resources_get_by_id_request(resource_id: str, *, api_version: str, **kwargs: Any) -> HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + accept = _headers.pop("Accept", "application/json") -def build_resources_get_by_id_request( - resource_id: str, - *, - api_version: str, - **kwargs: Any -) -> HttpRequest: - accept = "application/json" # Construct URL _url = kwargs.pop("template_url", "/{resourceId}") path_format_arguments = { - "resourceId": _SERIALIZER.url("resource_id", resource_id, 'str', skip_quote=True), + "resourceId": _SERIALIZER.url("resource_id", resource_id, "str", skip_quote=True), } _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') - - return HttpRequest( - method="GET", - url=_url, - params=_query_parameters, - headers=_header_parameters, - **kwargs - ) + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) def build_resource_groups_check_existence_request( - resource_group_name: str, - subscription_id: str, - **kwargs: Any + resource_group_name: str, subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2021-01-01") # type: 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-01-01")) # type: str + accept = _headers.pop("Accept", "application/json") - accept = "application/json" # Construct URL _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}") path_format_arguments = { - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._\(\)]+$'), - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), + "resourceGroupName": _SERIALIZER.url( + "resource_group_name", resource_group_name, "str", max_length=90, min_length=1, pattern=r"^[-\w\._\(\)]+$" + ), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), } _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') - - return HttpRequest( - method="HEAD", - url=_url, - params=_query_parameters, - headers=_header_parameters, - **kwargs - ) + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="HEAD", url=_url, params=_params, headers=_headers, **kwargs) def build_resource_groups_create_or_update_request( - resource_group_name: str, - subscription_id: str, - *, - json: JSONType = None, - content: Any = None, - **kwargs: Any + resource_group_name: str, subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2021-01-01") # type: str - content_type = kwargs.pop('content_type', None) # type: Optional[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-01-01")) # type: str + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + accept = _headers.pop("Accept", "application/json") - accept = "application/json" # Construct URL _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}") path_format_arguments = { - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._\(\)]+$'), - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), + "resourceGroupName": _SERIALIZER.url( + "resource_group_name", resource_group_name, "str", max_length=90, min_length=1, pattern=r"^[-\w\._\(\)]+$" + ), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), } _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] if content_type is not None: - _header_parameters['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') - _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') - - return HttpRequest( - method="PUT", - url=_url, - params=_query_parameters, - headers=_header_parameters, - json=json, - content=content, - **kwargs - ) + _headers["Content-Type"] = _SERIALIZER.header("content_type", content_type, "str") + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + return HttpRequest(method="PUT", url=_url, params=_params, headers=_headers, **kwargs) -def build_resource_groups_delete_request_initial( - resource_group_name: str, - subscription_id: str, - *, - force_deletion_types: Optional[str] = None, - **kwargs: Any + +def build_resource_groups_delete_request( + resource_group_name: str, subscription_id: str, *, force_deletion_types: Optional[str] = None, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2021-01-01") # type: 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-01-01")) # type: str + accept = _headers.pop("Accept", "application/json") - accept = "application/json" # Construct URL _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}") path_format_arguments = { - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._\(\)]+$'), - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), + "resourceGroupName": _SERIALIZER.url( + "resource_group_name", resource_group_name, "str", max_length=90, min_length=1, pattern=r"^[-\w\._\(\)]+$" + ), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), } _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] if force_deletion_types is not None: - _query_parameters['forceDeletionTypes'] = _SERIALIZER.query("force_deletion_types", force_deletion_types, 'str') - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["forceDeletionTypes"] = _SERIALIZER.query("force_deletion_types", force_deletion_types, "str") + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') - - return HttpRequest( - method="DELETE", - url=_url, - params=_query_parameters, - headers=_header_parameters, - **kwargs - ) + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + return HttpRequest(method="DELETE", url=_url, params=_params, headers=_headers, **kwargs) -def build_resource_groups_get_request( - resource_group_name: str, - subscription_id: str, - **kwargs: Any -) -> HttpRequest: - api_version = kwargs.pop('api_version', "2021-01-01") # type: str - accept = "application/json" +def build_resource_groups_get_request(resource_group_name: str, subscription_id: str, **kwargs: Any) -> HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-01-01")) # type: str + accept = _headers.pop("Accept", "application/json") + # Construct URL _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}") path_format_arguments = { - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._\(\)]+$'), - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), + "resourceGroupName": _SERIALIZER.url( + "resource_group_name", resource_group_name, "str", max_length=90, min_length=1, pattern=r"^[-\w\._\(\)]+$" + ), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), } _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') - - return HttpRequest( - method="GET", - url=_url, - params=_query_parameters, - headers=_header_parameters, - **kwargs - ) + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) -def build_resource_groups_update_request( - resource_group_name: str, - subscription_id: str, - *, - json: JSONType = None, - content: Any = None, - **kwargs: Any -) -> HttpRequest: - api_version = kwargs.pop('api_version', "2021-01-01") # type: str - content_type = kwargs.pop('content_type', None) # type: Optional[str] - accept = "application/json" +def build_resource_groups_update_request(resource_group_name: str, subscription_id: str, **kwargs: Any) -> HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-01-01")) # type: str + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + accept = _headers.pop("Accept", "application/json") + # Construct URL _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}") path_format_arguments = { - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._\(\)]+$'), - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), + "resourceGroupName": _SERIALIZER.url( + "resource_group_name", resource_group_name, "str", max_length=90, min_length=1, pattern=r"^[-\w\._\(\)]+$" + ), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), } _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] if content_type is not None: - _header_parameters['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') - _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') - - return HttpRequest( - method="PATCH", - url=_url, - params=_query_parameters, - headers=_header_parameters, - json=json, - content=content, - **kwargs - ) + _headers["Content-Type"] = _SERIALIZER.header("content_type", content_type, "str") + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + return HttpRequest(method="PATCH", url=_url, params=_params, headers=_headers, **kwargs) -def build_resource_groups_export_template_request_initial( - subscription_id: str, - resource_group_name: str, - *, - json: JSONType = None, - content: Any = None, - **kwargs: Any + +def build_resource_groups_export_template_request( + resource_group_name: str, subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2021-01-01") # type: str - content_type = kwargs.pop('content_type', None) # type: Optional[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-01-01")) # type: str + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + accept = _headers.pop("Accept", "application/json") - accept = "application/json" # Construct URL - _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/exportTemplate") + _url = kwargs.pop( + "template_url", "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/exportTemplate" + ) path_format_arguments = { - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url( + "resource_group_name", resource_group_name, "str", max_length=90, min_length=1 + ), } _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] if content_type is not None: - _header_parameters['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') - _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') - - return HttpRequest( - method="POST", - url=_url, - params=_query_parameters, - headers=_header_parameters, - json=json, - content=content, - **kwargs - ) + _headers["Content-Type"] = _SERIALIZER.header("content_type", content_type, "str") + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="POST", url=_url, params=_params, headers=_headers, **kwargs) def build_resource_groups_list_request( - subscription_id: str, - *, - filter: Optional[str] = None, - top: Optional[int] = None, - **kwargs: Any + subscription_id: str, *, filter: Optional[str] = None, top: Optional[int] = None, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2021-01-01") # type: 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-01-01")) # type: str + accept = _headers.pop("Accept", "application/json") - accept = "application/json" # Construct URL _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourcegroups") path_format_arguments = { - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), } _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] if filter is not None: - _query_parameters['$filter'] = _SERIALIZER.query("filter", filter, 'str') + _params["$filter"] = _SERIALIZER.query("filter", filter, "str") if top is not None: - _query_parameters['$top'] = _SERIALIZER.query("top", top, 'int') - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["$top"] = _SERIALIZER.query("top", top, "int") + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') - - return HttpRequest( - method="GET", - url=_url, - params=_query_parameters, - headers=_header_parameters, - **kwargs - ) + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) -def build_tags_delete_value_request( - tag_name: str, - tag_value: str, - subscription_id: str, - **kwargs: Any -) -> HttpRequest: - api_version = kwargs.pop('api_version', "2021-01-01") # type: str - accept = "application/json" +def build_tags_delete_value_request(tag_name: str, tag_value: str, subscription_id: str, **kwargs: Any) -> HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-01-01")) # type: str + accept = _headers.pop("Accept", "application/json") + # Construct URL _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/tagNames/{tagName}/tagValues/{tagValue}") path_format_arguments = { - "tagName": _SERIALIZER.url("tag_name", tag_name, 'str'), - "tagValue": _SERIALIZER.url("tag_value", tag_value, 'str'), - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), + "tagName": _SERIALIZER.url("tag_name", tag_name, "str"), + "tagValue": _SERIALIZER.url("tag_value", tag_value, "str"), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), } _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') - - return HttpRequest( - method="DELETE", - url=_url, - params=_query_parameters, - headers=_header_parameters, - **kwargs - ) + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="DELETE", url=_url, params=_params, headers=_headers, **kwargs) def build_tags_create_or_update_value_request( - tag_name: str, - tag_value: str, - subscription_id: str, - **kwargs: Any + tag_name: str, tag_value: str, subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2021-01-01") # type: 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-01-01")) # type: str + accept = _headers.pop("Accept", "application/json") - accept = "application/json" # Construct URL _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/tagNames/{tagName}/tagValues/{tagValue}") path_format_arguments = { - "tagName": _SERIALIZER.url("tag_name", tag_name, 'str'), - "tagValue": _SERIALIZER.url("tag_value", tag_value, 'str'), - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), + "tagName": _SERIALIZER.url("tag_name", tag_name, "str"), + "tagValue": _SERIALIZER.url("tag_value", tag_value, "str"), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), } _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') - - return HttpRequest( - method="PUT", - url=_url, - params=_query_parameters, - headers=_header_parameters, - **kwargs - ) + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + return HttpRequest(method="PUT", url=_url, params=_params, headers=_headers, **kwargs) -def build_tags_create_or_update_request( - tag_name: str, - subscription_id: str, - **kwargs: Any -) -> HttpRequest: - api_version = kwargs.pop('api_version', "2021-01-01") # type: str - accept = "application/json" +def build_tags_create_or_update_request(tag_name: str, subscription_id: str, **kwargs: Any) -> HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-01-01")) # type: str + accept = _headers.pop("Accept", "application/json") + # Construct URL _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/tagNames/{tagName}") path_format_arguments = { - "tagName": _SERIALIZER.url("tag_name", tag_name, 'str'), - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), + "tagName": _SERIALIZER.url("tag_name", tag_name, "str"), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), } _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') - - return HttpRequest( - method="PUT", - url=_url, - params=_query_parameters, - headers=_header_parameters, - **kwargs - ) + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + return HttpRequest(method="PUT", url=_url, params=_params, headers=_headers, **kwargs) -def build_tags_delete_request( - tag_name: str, - subscription_id: str, - **kwargs: Any -) -> HttpRequest: - api_version = kwargs.pop('api_version', "2021-01-01") # type: str - accept = "application/json" +def build_tags_delete_request(tag_name: str, subscription_id: str, **kwargs: Any) -> HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-01-01")) # type: str + accept = _headers.pop("Accept", "application/json") + # Construct URL _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/tagNames/{tagName}") path_format_arguments = { - "tagName": _SERIALIZER.url("tag_name", tag_name, 'str'), - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), + "tagName": _SERIALIZER.url("tag_name", tag_name, "str"), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), } _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') - - return HttpRequest( - method="DELETE", - url=_url, - params=_query_parameters, - headers=_header_parameters, - **kwargs - ) + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + return HttpRequest(method="DELETE", url=_url, params=_params, headers=_headers, **kwargs) -def build_tags_list_request( - subscription_id: str, - **kwargs: Any -) -> HttpRequest: - api_version = kwargs.pop('api_version', "2021-01-01") # type: str - accept = "application/json" +def build_tags_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-01-01")) # type: str + accept = _headers.pop("Accept", "application/json") + # Construct URL _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/tagNames") path_format_arguments = { - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), } _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') - - return HttpRequest( - method="GET", - url=_url, - params=_query_parameters, - headers=_header_parameters, - **kwargs - ) + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) -def build_tags_create_or_update_at_scope_request( - scope: str, - *, - json: JSONType = None, - content: Any = None, - **kwargs: Any -) -> HttpRequest: - api_version = kwargs.pop('api_version', "2021-01-01") # type: str - content_type = kwargs.pop('content_type', None) # type: Optional[str] - accept = "application/json" +def build_tags_create_or_update_at_scope_request(scope: 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-01-01")) # type: str + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + accept = _headers.pop("Accept", "application/json") + # Construct URL _url = kwargs.pop("template_url", "/{scope}/providers/Microsoft.Resources/tags/default") path_format_arguments = { - "scope": _SERIALIZER.url("scope", scope, 'str', skip_quote=True), + "scope": _SERIALIZER.url("scope", scope, "str", skip_quote=True), } _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] if content_type is not None: - _header_parameters['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') - _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') - - return HttpRequest( - method="PUT", - url=_url, - params=_query_parameters, - headers=_header_parameters, - json=json, - content=content, - **kwargs - ) + _headers["Content-Type"] = _SERIALIZER.header("content_type", content_type, "str") + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + return HttpRequest(method="PUT", url=_url, params=_params, headers=_headers, **kwargs) -def build_tags_update_at_scope_request( - scope: str, - *, - json: JSONType = None, - content: Any = None, - **kwargs: Any -) -> HttpRequest: - api_version = kwargs.pop('api_version', "2021-01-01") # type: str - content_type = kwargs.pop('content_type', None) # type: Optional[str] - accept = "application/json" +def build_tags_update_at_scope_request(scope: 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-01-01")) # type: str + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + accept = _headers.pop("Accept", "application/json") + # Construct URL _url = kwargs.pop("template_url", "/{scope}/providers/Microsoft.Resources/tags/default") path_format_arguments = { - "scope": _SERIALIZER.url("scope", scope, 'str', skip_quote=True), + "scope": _SERIALIZER.url("scope", scope, "str", skip_quote=True), } _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] if content_type is not None: - _header_parameters['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') - _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') - - return HttpRequest( - method="PATCH", - url=_url, - params=_query_parameters, - headers=_header_parameters, - json=json, - content=content, - **kwargs - ) + _headers["Content-Type"] = _SERIALIZER.header("content_type", content_type, "str") + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + return HttpRequest(method="PATCH", url=_url, params=_params, headers=_headers, **kwargs) -def build_tags_get_at_scope_request( - scope: str, - **kwargs: Any -) -> HttpRequest: - api_version = kwargs.pop('api_version', "2021-01-01") # type: str - accept = "application/json" +def build_tags_get_at_scope_request(scope: 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-01-01")) # type: str + accept = _headers.pop("Accept", "application/json") + # Construct URL _url = kwargs.pop("template_url", "/{scope}/providers/Microsoft.Resources/tags/default") path_format_arguments = { - "scope": _SERIALIZER.url("scope", scope, 'str', skip_quote=True), + "scope": _SERIALIZER.url("scope", scope, "str", skip_quote=True), } _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') - - return HttpRequest( - method="GET", - url=_url, - params=_query_parameters, - headers=_header_parameters, - **kwargs - ) + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) -def build_tags_delete_at_scope_request( - scope: str, - **kwargs: Any -) -> HttpRequest: - api_version = kwargs.pop('api_version', "2021-01-01") # type: str - accept = "application/json" +def build_tags_delete_at_scope_request(scope: 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-01-01")) # type: str + accept = _headers.pop("Accept", "application/json") + # Construct URL _url = kwargs.pop("template_url", "/{scope}/providers/Microsoft.Resources/tags/default") path_format_arguments = { - "scope": _SERIALIZER.url("scope", scope, 'str', skip_quote=True), + "scope": _SERIALIZER.url("scope", scope, "str", skip_quote=True), } _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') - - return HttpRequest( - method="DELETE", - url=_url, - params=_query_parameters, - headers=_header_parameters, - **kwargs - ) + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="DELETE", url=_url, params=_params, headers=_headers, **kwargs) def build_deployment_operations_get_at_scope_request( - scope: str, - deployment_name: str, - operation_id: str, - **kwargs: Any + scope: str, deployment_name: str, operation_id: str, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2021-01-01") # type: 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-01-01")) # type: str + accept = _headers.pop("Accept", "application/json") - accept = "application/json" # Construct URL - _url = kwargs.pop("template_url", "/{scope}/providers/Microsoft.Resources/deployments/{deploymentName}/operations/{operationId}") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", "/{scope}/providers/Microsoft.Resources/deployments/{deploymentName}/operations/{operationId}" + ) # pylint: disable=line-too-long path_format_arguments = { - "scope": _SERIALIZER.url("scope", scope, 'str', skip_quote=True), - "deploymentName": _SERIALIZER.url("deployment_name", deployment_name, 'str', max_length=64, min_length=1, pattern=r'^[-\w\._\(\)]+$'), - "operationId": _SERIALIZER.url("operation_id", operation_id, 'str'), + "scope": _SERIALIZER.url("scope", scope, "str", skip_quote=True), + "deploymentName": _SERIALIZER.url( + "deployment_name", deployment_name, "str", max_length=64, min_length=1, pattern=r"^[-\w\._\(\)]+$" + ), + "operationId": _SERIALIZER.url("operation_id", operation_id, "str"), } _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') - - return HttpRequest( - method="GET", - url=_url, - params=_query_parameters, - headers=_header_parameters, - **kwargs - ) + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) def build_deployment_operations_list_at_scope_request( - scope: str, - deployment_name: str, - *, - top: Optional[int] = None, - **kwargs: Any + scope: str, deployment_name: str, *, top: Optional[int] = None, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2021-01-01") # type: 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-01-01")) # type: str + accept = _headers.pop("Accept", "application/json") - accept = "application/json" # Construct URL _url = kwargs.pop("template_url", "/{scope}/providers/Microsoft.Resources/deployments/{deploymentName}/operations") path_format_arguments = { - "scope": _SERIALIZER.url("scope", scope, 'str', skip_quote=True), - "deploymentName": _SERIALIZER.url("deployment_name", deployment_name, 'str', max_length=64, min_length=1, pattern=r'^[-\w\._\(\)]+$'), + "scope": _SERIALIZER.url("scope", scope, "str", skip_quote=True), + "deploymentName": _SERIALIZER.url( + "deployment_name", deployment_name, "str", max_length=64, min_length=1, pattern=r"^[-\w\._\(\)]+$" + ), } _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] if top is not None: - _query_parameters['$top'] = _SERIALIZER.query("top", top, 'int') - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["$top"] = _SERIALIZER.query("top", top, "int") + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') - - return HttpRequest( - method="GET", - url=_url, - params=_query_parameters, - headers=_header_parameters, - **kwargs - ) + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) def build_deployment_operations_get_at_tenant_scope_request( - deployment_name: str, - operation_id: str, - **kwargs: Any + deployment_name: str, operation_id: str, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2021-01-01") # type: 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-01-01")) # type: str + accept = _headers.pop("Accept", "application/json") - accept = "application/json" # Construct URL - _url = kwargs.pop("template_url", "/providers/Microsoft.Resources/deployments/{deploymentName}/operations/{operationId}") + _url = kwargs.pop( + "template_url", "/providers/Microsoft.Resources/deployments/{deploymentName}/operations/{operationId}" + ) path_format_arguments = { - "deploymentName": _SERIALIZER.url("deployment_name", deployment_name, 'str', max_length=64, min_length=1, pattern=r'^[-\w\._\(\)]+$'), - "operationId": _SERIALIZER.url("operation_id", operation_id, 'str'), + "deploymentName": _SERIALIZER.url( + "deployment_name", deployment_name, "str", max_length=64, min_length=1, pattern=r"^[-\w\._\(\)]+$" + ), + "operationId": _SERIALIZER.url("operation_id", operation_id, "str"), } _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') - - return HttpRequest( - method="GET", - url=_url, - params=_query_parameters, - headers=_header_parameters, - **kwargs - ) + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) def build_deployment_operations_list_at_tenant_scope_request( - deployment_name: str, - *, - top: Optional[int] = None, - **kwargs: Any + deployment_name: str, *, top: Optional[int] = None, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2021-01-01") # type: 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-01-01")) # type: str + accept = _headers.pop("Accept", "application/json") - accept = "application/json" # Construct URL _url = kwargs.pop("template_url", "/providers/Microsoft.Resources/deployments/{deploymentName}/operations") path_format_arguments = { - "deploymentName": _SERIALIZER.url("deployment_name", deployment_name, 'str', max_length=64, min_length=1, pattern=r'^[-\w\._\(\)]+$'), + "deploymentName": _SERIALIZER.url( + "deployment_name", deployment_name, "str", max_length=64, min_length=1, pattern=r"^[-\w\._\(\)]+$" + ), } _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] if top is not None: - _query_parameters['$top'] = _SERIALIZER.query("top", top, 'int') - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["$top"] = _SERIALIZER.query("top", top, "int") + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') - - return HttpRequest( - method="GET", - url=_url, - params=_query_parameters, - headers=_header_parameters, - **kwargs - ) + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) def build_deployment_operations_get_at_management_group_scope_request( - group_id: str, - deployment_name: str, - operation_id: str, - **kwargs: Any + group_id: str, deployment_name: str, operation_id: str, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2021-01-01") # type: 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-01-01")) # type: str + accept = _headers.pop("Accept", "application/json") - accept = "application/json" # Construct URL - _url = kwargs.pop("template_url", "/providers/Microsoft.Management/managementGroups/{groupId}/providers/Microsoft.Resources/deployments/{deploymentName}/operations/{operationId}") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", + "/providers/Microsoft.Management/managementGroups/{groupId}/providers/Microsoft.Resources/deployments/{deploymentName}/operations/{operationId}", + ) # pylint: disable=line-too-long path_format_arguments = { - "groupId": _SERIALIZER.url("group_id", group_id, 'str', max_length=90, min_length=1), - "deploymentName": _SERIALIZER.url("deployment_name", deployment_name, 'str', max_length=64, min_length=1, pattern=r'^[-\w\._\(\)]+$'), - "operationId": _SERIALIZER.url("operation_id", operation_id, 'str'), + "groupId": _SERIALIZER.url("group_id", group_id, "str", max_length=90, min_length=1), + "deploymentName": _SERIALIZER.url( + "deployment_name", deployment_name, "str", max_length=64, min_length=1, pattern=r"^[-\w\._\(\)]+$" + ), + "operationId": _SERIALIZER.url("operation_id", operation_id, "str"), } _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') - - return HttpRequest( - method="GET", - url=_url, - params=_query_parameters, - headers=_header_parameters, - **kwargs - ) + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) def build_deployment_operations_list_at_management_group_scope_request( - group_id: str, - deployment_name: str, - *, - top: Optional[int] = None, - **kwargs: Any + group_id: str, deployment_name: str, *, top: Optional[int] = None, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2021-01-01") # type: 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-01-01")) # type: str + accept = _headers.pop("Accept", "application/json") - accept = "application/json" # Construct URL - _url = kwargs.pop("template_url", "/providers/Microsoft.Management/managementGroups/{groupId}/providers/Microsoft.Resources/deployments/{deploymentName}/operations") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", + "/providers/Microsoft.Management/managementGroups/{groupId}/providers/Microsoft.Resources/deployments/{deploymentName}/operations", + ) # pylint: disable=line-too-long path_format_arguments = { - "groupId": _SERIALIZER.url("group_id", group_id, 'str', max_length=90, min_length=1), - "deploymentName": _SERIALIZER.url("deployment_name", deployment_name, 'str', max_length=64, min_length=1, pattern=r'^[-\w\._\(\)]+$'), + "groupId": _SERIALIZER.url("group_id", group_id, "str", max_length=90, min_length=1), + "deploymentName": _SERIALIZER.url( + "deployment_name", deployment_name, "str", max_length=64, min_length=1, pattern=r"^[-\w\._\(\)]+$" + ), } _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] if top is not None: - _query_parameters['$top'] = _SERIALIZER.query("top", top, 'int') - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["$top"] = _SERIALIZER.query("top", top, "int") + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') - - return HttpRequest( - method="GET", - url=_url, - params=_query_parameters, - headers=_header_parameters, - **kwargs - ) + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) def build_deployment_operations_get_at_subscription_scope_request( - deployment_name: str, - operation_id: str, - subscription_id: str, - **kwargs: Any + deployment_name: str, operation_id: str, subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2021-01-01") # type: 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-01-01")) # type: str + accept = _headers.pop("Accept", "application/json") - accept = "application/json" # Construct URL - _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/providers/Microsoft.Resources/deployments/{deploymentName}/operations/{operationId}") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/providers/Microsoft.Resources/deployments/{deploymentName}/operations/{operationId}", + ) # pylint: disable=line-too-long path_format_arguments = { - "deploymentName": _SERIALIZER.url("deployment_name", deployment_name, 'str', max_length=64, min_length=1, pattern=r'^[-\w\._\(\)]+$'), - "operationId": _SERIALIZER.url("operation_id", operation_id, 'str'), - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), + "deploymentName": _SERIALIZER.url( + "deployment_name", deployment_name, "str", max_length=64, min_length=1, pattern=r"^[-\w\._\(\)]+$" + ), + "operationId": _SERIALIZER.url("operation_id", operation_id, "str"), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), } _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') - - return HttpRequest( - method="GET", - url=_url, - params=_query_parameters, - headers=_header_parameters, - **kwargs - ) + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) def build_deployment_operations_list_at_subscription_scope_request( - deployment_name: str, - subscription_id: str, - *, - top: Optional[int] = None, - **kwargs: Any + deployment_name: str, subscription_id: str, *, top: Optional[int] = None, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2021-01-01") # type: 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-01-01")) # type: str + accept = _headers.pop("Accept", "application/json") - accept = "application/json" # Construct URL - _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/providers/Microsoft.Resources/deployments/{deploymentName}/operations") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/providers/Microsoft.Resources/deployments/{deploymentName}/operations", + ) # pylint: disable=line-too-long path_format_arguments = { - "deploymentName": _SERIALIZER.url("deployment_name", deployment_name, 'str', max_length=64, min_length=1, pattern=r'^[-\w\._\(\)]+$'), - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), + "deploymentName": _SERIALIZER.url( + "deployment_name", deployment_name, "str", max_length=64, min_length=1, pattern=r"^[-\w\._\(\)]+$" + ), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), } _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] if top is not None: - _query_parameters['$top'] = _SERIALIZER.query("top", top, 'int') - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["$top"] = _SERIALIZER.query("top", top, "int") + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') - - return HttpRequest( - method="GET", - url=_url, - params=_query_parameters, - headers=_header_parameters, - **kwargs - ) + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) def build_deployment_operations_get_request( - resource_group_name: str, - deployment_name: str, - operation_id: str, - subscription_id: str, - **kwargs: Any + resource_group_name: str, deployment_name: str, operation_id: str, subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2021-01-01") # type: 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-01-01")) # type: str + accept = _headers.pop("Accept", "application/json") - accept = "application/json" # Construct URL - _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/deployments/{deploymentName}/operations/{operationId}") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/deployments/{deploymentName}/operations/{operationId}", + ) # pylint: disable=line-too-long path_format_arguments = { - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._\(\)]+$'), - "deploymentName": _SERIALIZER.url("deployment_name", deployment_name, 'str', max_length=64, min_length=1, pattern=r'^[-\w\._\(\)]+$'), - "operationId": _SERIALIZER.url("operation_id", operation_id, 'str'), - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), + "resourceGroupName": _SERIALIZER.url( + "resource_group_name", resource_group_name, "str", max_length=90, min_length=1, pattern=r"^[-\w\._\(\)]+$" + ), + "deploymentName": _SERIALIZER.url( + "deployment_name", deployment_name, "str", max_length=64, min_length=1, pattern=r"^[-\w\._\(\)]+$" + ), + "operationId": _SERIALIZER.url("operation_id", operation_id, "str"), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), } _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') - - return HttpRequest( - method="GET", - url=_url, - params=_query_parameters, - headers=_header_parameters, - **kwargs - ) + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) def build_deployment_operations_list_request( - resource_group_name: str, - deployment_name: str, - subscription_id: str, - *, - top: Optional[int] = None, - **kwargs: Any + resource_group_name: str, deployment_name: str, subscription_id: str, *, top: Optional[int] = None, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2021-01-01") # type: 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-01-01")) # type: str + accept = _headers.pop("Accept", "application/json") - accept = "application/json" # Construct URL - _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/deployments/{deploymentName}/operations") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/deployments/{deploymentName}/operations", + ) # pylint: disable=line-too-long path_format_arguments = { - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._\(\)]+$'), - "deploymentName": _SERIALIZER.url("deployment_name", deployment_name, 'str', max_length=64, min_length=1, pattern=r'^[-\w\._\(\)]+$'), - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), + "resourceGroupName": _SERIALIZER.url( + "resource_group_name", resource_group_name, "str", max_length=90, min_length=1, pattern=r"^[-\w\._\(\)]+$" + ), + "deploymentName": _SERIALIZER.url( + "deployment_name", deployment_name, "str", max_length=64, min_length=1, pattern=r"^[-\w\._\(\)]+$" + ), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), } _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] if top is not None: - _query_parameters['$top'] = _SERIALIZER.query("top", top, 'int') - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["$top"] = _SERIALIZER.query("top", top, "int") + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') - - return HttpRequest( - method="GET", - url=_url, - params=_query_parameters, - headers=_header_parameters, - **kwargs - ) + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") -class Operations(object): - """Operations operations. + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) - You should not instantiate this class directly. Instead, you should create a Client instance that - instantiates it for you and attaches it as an attribute. - :ivar models: Alias to model classes used in this operation group. - :type models: ~azure.mgmt.resource.resources.v2021_01_01.models - :param client: Client for service requests. - :param config: Configuration of service client. - :param serializer: An object model serializer. - :param deserializer: An object model deserializer. +class Operations: + """ + .. warning:: + **DO NOT** instantiate this class directly. + + Instead, you should access the following operations through + :class:`~azure.mgmt.resource.resources.v2021_01_01.ResourceManagementClient`'s + :attr:`operations` attribute. """ models = _models - def __init__(self, client, config, serializer, deserializer): - self._client = client - self._serialize = serializer - self._deserialize = deserializer - self._config = config + def __init__(self, *args, **kwargs): + input_args = list(args) + self._client = input_args.pop(0) if input_args else kwargs.pop("client") + self._config = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") @distributed_trace - def list( - self, - **kwargs: Any - ) -> Iterable["_models.OperationListResult"]: + def list(self, **kwargs: Any) -> Iterable["_models.Operation"]: """Lists all of the available Microsoft.Resources REST API operations. :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either OperationListResult or the result of cls(response) + :return: An iterator like instance of either Operation or the result of cls(response) :rtype: - ~azure.core.paging.ItemPaged[~azure.mgmt.resource.resources.v2021_01_01.models.OperationListResult] - :raises: ~azure.core.exceptions.HttpResponseError + ~azure.core.paging.ItemPaged[~azure.mgmt.resource.resources.v2021_01_01.models.Operation] + :raises ~azure.core.exceptions.HttpResponseError: """ - api_version = kwargs.pop('api_version', "2021-01-01") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-01-01")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[_models.OperationListResult] - cls = kwargs.pop('cls', None) # type: ClsType["_models.OperationListResult"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) + def prepare_request(next_link=None): if not next_link: - + request = build_operations_list_request( api_version=api_version, - template_url=self.list.metadata['url'], + template_url=self.list.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore else: - - request = build_operations_list_request( - template_url=next_link, - ) + # make call to next link with the client's api-version + _parsed_next_link = urlparse(next_link) + _next_request_params = case_insensitive_dict(parse_qs(_parsed_next_link.query)) + _next_request_params["api-version"] = self._config.api_version + request = HttpRequest("GET", urljoin(next_link, _parsed_next_link.path), params=_next_request_params) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore request.method = "GET" return request @@ -3604,10 +3050,8 @@ def extract_data(pipeline_response): def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) response = pipeline_response.http_response @@ -3617,62 +3061,62 @@ def get_next(next_link=None): return pipeline_response + return ItemPaged(get_next, extract_data) - return ItemPaged( - get_next, extract_data - ) - list.metadata = {'url': "/providers/Microsoft.Resources/operations"} # type: ignore -class DeploymentsOperations(object): # pylint: disable=too-many-public-methods - """DeploymentsOperations operations. + list.metadata = {"url": "/providers/Microsoft.Resources/operations"} # type: ignore - You should not instantiate this class directly. Instead, you should create a Client instance that - instantiates it for you and attaches it as an attribute. - :ivar models: Alias to model classes used in this operation group. - :type models: ~azure.mgmt.resource.resources.v2021_01_01.models - :param client: Client for service requests. - :param config: Configuration of service client. - :param serializer: An object model serializer. - :param deserializer: An object model deserializer. +class DeploymentsOperations: # pylint: disable=too-many-public-methods + """ + .. warning:: + **DO NOT** instantiate this class directly. + + Instead, you should access the following operations through + :class:`~azure.mgmt.resource.resources.v2021_01_01.ResourceManagementClient`'s + :attr:`deployments` attribute. """ models = _models - def __init__(self, client, config, serializer, deserializer): - self._client = client - self._serialize = serializer - self._deserialize = deserializer - self._config = config + def __init__(self, *args, **kwargs): + input_args = list(args) + self._client = input_args.pop(0) if input_args else kwargs.pop("client") + self._config = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") def _delete_at_scope_initial( # pylint: disable=inconsistent-return-statements - self, - scope: str, - deployment_name: str, - **kwargs: Any + self, scope: str, deployment_name: str, **kwargs: Any ) -> None: - cls = kwargs.pop('cls', None) # type: ClsType[None] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) - api_version = kwargs.pop('api_version', "2021-01-01") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - request = build_deployments_delete_at_scope_request_initial( + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-01-01")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[None] + + request = build_deployments_delete_at_scope_request( scope=scope, deployment_name=deployment_name, api_version=api_version, - template_url=self._delete_at_scope_initial.metadata['url'], + template_url=self._delete_at_scope_initial.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [202, 204]: @@ -3682,16 +3126,10 @@ def _delete_at_scope_initial( # pylint: disable=inconsistent-return-statements if cls: return cls(pipeline_response, None, {}) - _delete_at_scope_initial.metadata = {'url': "/{scope}/providers/Microsoft.Resources/deployments/{deploymentName}"} # type: ignore - + _delete_at_scope_initial.metadata = {"url": "/{scope}/providers/Microsoft.Resources/deployments/{deploymentName}"} # type: ignore @distributed_trace - def begin_delete_at_scope( # pylint: disable=inconsistent-return-statements - self, - scope: str, - deployment_name: str, - **kwargs: Any - ) -> LROPoller[None]: + def begin_delete_at_scope(self, scope: str, deployment_name: str, **kwargs: Any) -> LROPoller[None]: """Deletes a deployment from the deployment history. A template deployment that is currently running cannot be deleted. Deleting a template @@ -3702,9 +3140,9 @@ def begin_delete_at_scope( # pylint: disable=inconsistent-return-statements process finishes, the URI in the Location header returns a status of 204 on success. If the asynchronous request failed, the URI in the Location header returns an error-level status code. - :param scope: The resource scope. + :param scope: The resource scope. Required. :type scope: str - :param deployment_name: The name of the deployment. + :param deployment_name: The name of the deployment. Required. :type deployment_name: str :keyword callable cls: A custom type or function that will be passed the direct response :keyword str continuation_token: A continuation token to restart a poller from a saved state. @@ -3716,86 +3154,91 @@ def begin_delete_at_scope( # pylint: disable=inconsistent-return-statements Retry-After header is present. :return: An instance of LROPoller that returns either None or the result of cls(response) :rtype: ~azure.core.polling.LROPoller[None] - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - api_version = kwargs.pop('api_version', "2021-01-01") # type: str - polling = kwargs.pop('polling', True) # type: Union[bool, PollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType[None] - lro_delay = kwargs.pop( - 'polling_interval', - self._config.polling_interval - ) - cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-01-01")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[None] + polling = kwargs.pop("polling", True) # type: Union[bool, PollingMethod] + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token = kwargs.pop("continuation_token", None) # type: Optional[str] if cont_token is None: - raw_result = self._delete_at_scope_initial( + raw_result = self._delete_at_scope_initial( # type: ignore scope=scope, deployment_name=deployment_name, api_version=api_version, - cls=lambda x,y,z: x, + cls=lambda x, y, z: x, + headers=_headers, + params=_params, **kwargs ) - kwargs.pop('error_map', None) + kwargs.pop("error_map", None) - def get_long_running_output(pipeline_response): + def get_long_running_output(pipeline_response): # pylint: disable=inconsistent-return-statements if cls: return cls(pipeline_response, None, {}) - - if polling is True: polling_method = ARMPolling(lro_delay, **kwargs) - elif polling is False: polling_method = NoPolling() - else: polling_method = polling + if polling is True: + polling_method = cast(PollingMethod, ARMPolling(lro_delay, **kwargs)) # type: PollingMethod + elif polling is False: + polling_method = cast(PollingMethod, NoPolling()) + else: + polling_method = polling if cont_token: return LROPoller.from_continuation_token( polling_method=polling_method, continuation_token=cont_token, client=self._client, - deserialization_callback=get_long_running_output + deserialization_callback=get_long_running_output, ) return LROPoller(self._client, raw_result, get_long_running_output, polling_method) - begin_delete_at_scope.metadata = {'url': "/{scope}/providers/Microsoft.Resources/deployments/{deploymentName}"} # type: ignore + begin_delete_at_scope.metadata = {"url": "/{scope}/providers/Microsoft.Resources/deployments/{deploymentName}"} # type: ignore @distributed_trace - def check_existence_at_scope( - self, - scope: str, - deployment_name: str, - **kwargs: Any - ) -> bool: + def check_existence_at_scope(self, scope: str, deployment_name: str, **kwargs: Any) -> bool: """Checks whether the deployment exists. - :param scope: The resource scope. + :param scope: The resource scope. Required. :type scope: str - :param deployment_name: The name of the deployment. + :param deployment_name: The name of the deployment. Required. :type deployment_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: bool, or the result of cls(response) + :return: bool or the result of cls(response) :rtype: bool - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType[None] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) - api_version = kwargs.pop('api_version', "2021-01-01") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-01-01")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[None] - request = build_deployments_check_existence_at_scope_request( scope=scope, deployment_name=deployment_name, api_version=api_version, - template_url=self.check_existence_at_scope.metadata['url'], + template_url=self.check_existence_at_scope.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [204, 404]: @@ -3806,43 +3249,52 @@ def check_existence_at_scope( return cls(pipeline_response, None, {}) return 200 <= response.status_code <= 299 - check_existence_at_scope.metadata = {'url': "/{scope}/providers/Microsoft.Resources/deployments/{deploymentName}"} # type: ignore - + check_existence_at_scope.metadata = {"url": "/{scope}/providers/Microsoft.Resources/deployments/{deploymentName}"} # type: ignore def _create_or_update_at_scope_initial( - self, - scope: str, - deployment_name: str, - parameters: "_models.Deployment", - **kwargs: Any - ) -> "_models.DeploymentExtended": - cls = kwargs.pop('cls', None) # type: ClsType["_models.DeploymentExtended"] + self, scope: str, deployment_name: str, parameters: Union[_models.Deployment, IO], **kwargs: Any + ) -> _models.DeploymentExtended: error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', "2021-01-01") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-01-01")) # type: str + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.DeploymentExtended] - _json = self._serialize.body(parameters, 'Deployment') + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(parameters, (IO, bytes)): + _content = parameters + else: + _json = self._serialize.body(parameters, "Deployment") - request = build_deployments_create_or_update_at_scope_request_initial( + request = build_deployments_create_or_update_at_scope_request( scope=scope, deployment_name=deployment_name, api_version=api_version, content_type=content_type, json=_json, - template_url=self._create_or_update_at_scope_initial.metadata['url'], + content=_content, + template_url=self._create_or_update_at_scope_initial.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200, 201]: @@ -3850,37 +3302,41 @@ def _create_or_update_at_scope_initial( raise HttpResponseError(response=response, error_format=ARMErrorFormat) if response.status_code == 200: - deserialized = self._deserialize('DeploymentExtended', pipeline_response) + deserialized = self._deserialize("DeploymentExtended", pipeline_response) if response.status_code == 201: - deserialized = self._deserialize('DeploymentExtended', pipeline_response) + deserialized = self._deserialize("DeploymentExtended", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - _create_or_update_at_scope_initial.metadata = {'url': "/{scope}/providers/Microsoft.Resources/deployments/{deploymentName}"} # type: ignore - + _create_or_update_at_scope_initial.metadata = {"url": "/{scope}/providers/Microsoft.Resources/deployments/{deploymentName}"} # type: ignore - @distributed_trace + @overload def begin_create_or_update_at_scope( self, scope: str, deployment_name: str, - parameters: "_models.Deployment", + parameters: _models.Deployment, + *, + content_type: str = "application/json", **kwargs: Any - ) -> LROPoller["_models.DeploymentExtended"]: + ) -> LROPoller[_models.DeploymentExtended]: """Deploys resources at a given scope. You can provide the template and parameters directly in the request or link to JSON files. - :param scope: The resource scope. + :param scope: The resource scope. Required. :type scope: str - :param deployment_name: The name of the deployment. + :param deployment_name: The name of the deployment. Required. :type deployment_name: str - :param parameters: Additional parameters supplied to the operation. + :param parameters: Additional parameters supplied to the operation. Required. :type parameters: ~azure.mgmt.resource.resources.v2021_01_01.models.Deployment + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str :keyword callable cls: A custom type or function that will be passed the direct response :keyword str continuation_token: A continuation token to restart a poller from a saved state. :keyword polling: By default, your polling method will be ARMPolling. Pass in False for this @@ -3893,114 +3349,179 @@ def begin_create_or_update_at_scope( cls(response) :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.resource.resources.v2021_01_01.models.DeploymentExtended] - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - api_version = kwargs.pop('api_version', "2021-01-01") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] - polling = kwargs.pop('polling', True) # type: Union[bool, PollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType["_models.DeploymentExtended"] - lro_delay = kwargs.pop( - 'polling_interval', - self._config.polling_interval - ) - cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] + + @overload + def begin_create_or_update_at_scope( + self, scope: str, deployment_name: str, parameters: IO, *, content_type: str = "application/json", **kwargs: Any + ) -> LROPoller[_models.DeploymentExtended]: + """Deploys resources at a given scope. + + You can provide the template and parameters directly in the request or link to JSON files. + + :param scope: The resource scope. Required. + :type scope: str + :param deployment_name: The name of the deployment. Required. + :type deployment_name: str + :param parameters: Additional parameters supplied to the operation. Required. + :type parameters: IO + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be ARMPolling. Pass in False for this + operation to not poll, or pass in your own initialized polling object for a personal polling + strategy. + :paramtype polling: bool or ~azure.core.polling.PollingMethod + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of LROPoller that returns either DeploymentExtended or the result of + cls(response) + :rtype: + ~azure.core.polling.LROPoller[~azure.mgmt.resource.resources.v2021_01_01.models.DeploymentExtended] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace + def begin_create_or_update_at_scope( + self, scope: str, deployment_name: str, parameters: Union[_models.Deployment, IO], **kwargs: Any + ) -> LROPoller[_models.DeploymentExtended]: + """Deploys resources at a given scope. + + You can provide the template and parameters directly in the request or link to JSON files. + + :param scope: The resource scope. Required. + :type scope: str + :param deployment_name: The name of the deployment. Required. + :type deployment_name: str + :param parameters: Additional parameters supplied to the operation. Is either a model type or a + IO type. Required. + :type parameters: ~azure.mgmt.resource.resources.v2021_01_01.models.Deployment or IO + :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. + Default value is None. + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be ARMPolling. Pass in False for this + operation to not poll, or pass in your own initialized polling object for a personal polling + strategy. + :paramtype polling: bool or ~azure.core.polling.PollingMethod + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of LROPoller that returns either DeploymentExtended or the result of + cls(response) + :rtype: + ~azure.core.polling.LROPoller[~azure.mgmt.resource.resources.v2021_01_01.models.DeploymentExtended] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _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-01-01")) # type: str + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.DeploymentExtended] + polling = kwargs.pop("polling", True) # type: Union[bool, PollingMethod] + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token = kwargs.pop("continuation_token", None) # type: Optional[str] if cont_token is None: - raw_result = self._create_or_update_at_scope_initial( + raw_result = self._create_or_update_at_scope_initial( # type: ignore scope=scope, deployment_name=deployment_name, parameters=parameters, api_version=api_version, content_type=content_type, - cls=lambda x,y,z: x, + cls=lambda x, y, z: x, + headers=_headers, + params=_params, **kwargs ) - kwargs.pop('error_map', None) + kwargs.pop("error_map", None) def get_long_running_output(pipeline_response): - response = pipeline_response.http_response - deserialized = self._deserialize('DeploymentExtended', pipeline_response) + deserialized = self._deserialize("DeploymentExtended", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - - if polling is True: polling_method = ARMPolling(lro_delay, **kwargs) - elif polling is False: polling_method = NoPolling() - else: polling_method = polling + if polling is True: + polling_method = cast(PollingMethod, ARMPolling(lro_delay, **kwargs)) # type: PollingMethod + elif polling is False: + polling_method = cast(PollingMethod, NoPolling()) + else: + polling_method = polling if cont_token: return LROPoller.from_continuation_token( polling_method=polling_method, continuation_token=cont_token, client=self._client, - deserialization_callback=get_long_running_output + deserialization_callback=get_long_running_output, ) return LROPoller(self._client, raw_result, get_long_running_output, polling_method) - begin_create_or_update_at_scope.metadata = {'url': "/{scope}/providers/Microsoft.Resources/deployments/{deploymentName}"} # type: ignore + begin_create_or_update_at_scope.metadata = {"url": "/{scope}/providers/Microsoft.Resources/deployments/{deploymentName}"} # type: ignore @distributed_trace - def get_at_scope( - self, - scope: str, - deployment_name: str, - **kwargs: Any - ) -> "_models.DeploymentExtended": + def get_at_scope(self, scope: str, deployment_name: str, **kwargs: Any) -> _models.DeploymentExtended: """Gets a deployment. - :param scope: The resource scope. + :param scope: The resource scope. Required. :type scope: str - :param deployment_name: The name of the deployment. + :param deployment_name: The name of the deployment. Required. :type deployment_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: DeploymentExtended, or the result of cls(response) + :return: DeploymentExtended or the result of cls(response) :rtype: ~azure.mgmt.resource.resources.v2021_01_01.models.DeploymentExtended - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.DeploymentExtended"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + 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', "2021-01-01") # type: str + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-01-01")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[_models.DeploymentExtended] - request = build_deployments_get_at_scope_request( scope=scope, deployment_name=deployment_name, api_version=api_version, - template_url=self.get_at_scope.metadata['url'], + template_url=self.get_at_scope.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) - deserialized = self._deserialize('DeploymentExtended', pipeline_response) + deserialized = self._deserialize("DeploymentExtended", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - get_at_scope.metadata = {'url': "/{scope}/providers/Microsoft.Resources/deployments/{deploymentName}"} # type: ignore - + get_at_scope.metadata = {"url": "/{scope}/providers/Microsoft.Resources/deployments/{deploymentName}"} # type: ignore @distributed_trace def cancel_at_scope( # pylint: disable=inconsistent-return-statements - self, - scope: str, - deployment_name: str, - **kwargs: Any + self, scope: str, deployment_name: str, **kwargs: Any ) -> None: """Cancels a currently running template deployment. @@ -4009,38 +3530,44 @@ def cancel_at_scope( # pylint: disable=inconsistent-return-statements deployment stops the currently running template deployment and leaves the resources partially deployed. - :param scope: The resource scope. + :param scope: The resource scope. Required. :type scope: str - :param deployment_name: The name of the deployment. + :param deployment_name: The name of the deployment. Required. :type deployment_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: None, or the result of cls(response) + :return: None or the result of cls(response) :rtype: None - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType[None] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) - api_version = kwargs.pop('api_version', "2021-01-01") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-01-01")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[None] - request = build_deployments_cancel_at_scope_request( scope=scope, deployment_name=deployment_name, api_version=api_version, - template_url=self.cancel_at_scope.metadata['url'], + template_url=self.cancel_at_scope.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [204]: @@ -4050,43 +3577,52 @@ def cancel_at_scope( # pylint: disable=inconsistent-return-statements if cls: return cls(pipeline_response, None, {}) - cancel_at_scope.metadata = {'url': "/{scope}/providers/Microsoft.Resources/deployments/{deploymentName}/cancel"} # type: ignore - + cancel_at_scope.metadata = {"url": "/{scope}/providers/Microsoft.Resources/deployments/{deploymentName}/cancel"} # type: ignore def _validate_at_scope_initial( - self, - scope: str, - deployment_name: str, - parameters: "_models.Deployment", - **kwargs: Any - ) -> Optional["_models.DeploymentValidateResult"]: - cls = kwargs.pop('cls', None) # type: ClsType[Optional["_models.DeploymentValidateResult"]] + self, scope: str, deployment_name: str, parameters: Union[_models.Deployment, IO], **kwargs: Any + ) -> Optional[_models.DeploymentValidateResult]: error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', "2021-01-01") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-01-01")) # type: str + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[Optional[_models.DeploymentValidateResult]] - _json = self._serialize.body(parameters, 'Deployment') + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(parameters, (IO, bytes)): + _content = parameters + else: + _json = self._serialize.body(parameters, "Deployment") - request = build_deployments_validate_at_scope_request_initial( + request = build_deployments_validate_at_scope_request( scope=scope, deployment_name=deployment_name, api_version=api_version, content_type=content_type, json=_json, - template_url=self._validate_at_scope_initial.metadata['url'], + content=_content, + template_url=self._validate_at_scope_initial.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200, 202, 400]: @@ -4095,36 +3631,40 @@ def _validate_at_scope_initial( deserialized = None if response.status_code == 200: - deserialized = self._deserialize('DeploymentValidateResult', pipeline_response) + deserialized = self._deserialize("DeploymentValidateResult", pipeline_response) if response.status_code == 400: - deserialized = self._deserialize('DeploymentValidateResult', pipeline_response) + deserialized = self._deserialize("DeploymentValidateResult", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - _validate_at_scope_initial.metadata = {'url': "/{scope}/providers/Microsoft.Resources/deployments/{deploymentName}/validate"} # type: ignore - + _validate_at_scope_initial.metadata = {"url": "/{scope}/providers/Microsoft.Resources/deployments/{deploymentName}/validate"} # type: ignore - @distributed_trace + @overload def begin_validate_at_scope( self, scope: str, deployment_name: str, - parameters: "_models.Deployment", + parameters: _models.Deployment, + *, + content_type: str = "application/json", **kwargs: Any - ) -> LROPoller["_models.DeploymentValidateResult"]: + ) -> LROPoller[_models.DeploymentValidateResult]: """Validates whether the specified template is syntactically correct and will be accepted by Azure Resource Manager.. - :param scope: The resource scope. + :param scope: The resource scope. Required. :type scope: str - :param deployment_name: The name of the deployment. + :param deployment_name: The name of the deployment. Required. :type deployment_name: str - :param parameters: Parameters to validate. + :param parameters: Parameters to validate. Required. :type parameters: ~azure.mgmt.resource.resources.v2021_01_01.models.Deployment + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str :keyword callable cls: A custom type or function that will be passed the direct response :keyword str continuation_token: A continuation token to restart a poller from a saved state. :keyword polling: By default, your polling method will be ARMPolling. Pass in False for this @@ -4137,119 +3677,182 @@ def begin_validate_at_scope( cls(response) :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.resource.resources.v2021_01_01.models.DeploymentValidateResult] - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - api_version = kwargs.pop('api_version', "2021-01-01") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] - polling = kwargs.pop('polling', True) # type: Union[bool, PollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType["_models.DeploymentValidateResult"] - lro_delay = kwargs.pop( - 'polling_interval', - self._config.polling_interval - ) - cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] + + @overload + def begin_validate_at_scope( + self, scope: str, deployment_name: str, parameters: IO, *, content_type: str = "application/json", **kwargs: Any + ) -> LROPoller[_models.DeploymentValidateResult]: + """Validates whether the specified template is syntactically correct and will be accepted by Azure + Resource Manager.. + + :param scope: The resource scope. Required. + :type scope: str + :param deployment_name: The name of the deployment. Required. + :type deployment_name: str + :param parameters: Parameters to validate. Required. + :type parameters: IO + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be ARMPolling. Pass in False for this + operation to not poll, or pass in your own initialized polling object for a personal polling + strategy. + :paramtype polling: bool or ~azure.core.polling.PollingMethod + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of LROPoller that returns either DeploymentValidateResult or the result of + cls(response) + :rtype: + ~azure.core.polling.LROPoller[~azure.mgmt.resource.resources.v2021_01_01.models.DeploymentValidateResult] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace + def begin_validate_at_scope( + self, scope: str, deployment_name: str, parameters: Union[_models.Deployment, IO], **kwargs: Any + ) -> LROPoller[_models.DeploymentValidateResult]: + """Validates whether the specified template is syntactically correct and will be accepted by Azure + Resource Manager.. + + :param scope: The resource scope. Required. + :type scope: str + :param deployment_name: The name of the deployment. Required. + :type deployment_name: str + :param parameters: Parameters to validate. Is either a model type or a IO type. Required. + :type parameters: ~azure.mgmt.resource.resources.v2021_01_01.models.Deployment or IO + :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. + Default value is None. + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be ARMPolling. Pass in False for this + operation to not poll, or pass in your own initialized polling object for a personal polling + strategy. + :paramtype polling: bool or ~azure.core.polling.PollingMethod + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of LROPoller that returns either DeploymentValidateResult or the result of + cls(response) + :rtype: + ~azure.core.polling.LROPoller[~azure.mgmt.resource.resources.v2021_01_01.models.DeploymentValidateResult] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _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-01-01")) # type: str + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.DeploymentValidateResult] + polling = kwargs.pop("polling", True) # type: Union[bool, PollingMethod] + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token = kwargs.pop("continuation_token", None) # type: Optional[str] if cont_token is None: - raw_result = self._validate_at_scope_initial( + raw_result = self._validate_at_scope_initial( # type: ignore scope=scope, deployment_name=deployment_name, parameters=parameters, api_version=api_version, content_type=content_type, - cls=lambda x,y,z: x, + cls=lambda x, y, z: x, + headers=_headers, + params=_params, **kwargs ) - kwargs.pop('error_map', None) + kwargs.pop("error_map", None) def get_long_running_output(pipeline_response): - response = pipeline_response.http_response - deserialized = self._deserialize('DeploymentValidateResult', pipeline_response) + deserialized = self._deserialize("DeploymentValidateResult", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - - if polling is True: polling_method = ARMPolling(lro_delay, **kwargs) - elif polling is False: polling_method = NoPolling() - else: polling_method = polling + if polling is True: + polling_method = cast(PollingMethod, ARMPolling(lro_delay, **kwargs)) # type: PollingMethod + elif polling is False: + polling_method = cast(PollingMethod, NoPolling()) + else: + polling_method = polling if cont_token: return LROPoller.from_continuation_token( polling_method=polling_method, continuation_token=cont_token, client=self._client, - deserialization_callback=get_long_running_output + deserialization_callback=get_long_running_output, ) return LROPoller(self._client, raw_result, get_long_running_output, polling_method) - begin_validate_at_scope.metadata = {'url': "/{scope}/providers/Microsoft.Resources/deployments/{deploymentName}/validate"} # type: ignore + begin_validate_at_scope.metadata = {"url": "/{scope}/providers/Microsoft.Resources/deployments/{deploymentName}/validate"} # type: ignore @distributed_trace def export_template_at_scope( - self, - scope: str, - deployment_name: str, - **kwargs: Any - ) -> "_models.DeploymentExportResult": + self, scope: str, deployment_name: str, **kwargs: Any + ) -> _models.DeploymentExportResult: """Exports the template used for specified deployment. - :param scope: The resource scope. + :param scope: The resource scope. Required. :type scope: str - :param deployment_name: The name of the deployment. + :param deployment_name: The name of the deployment. Required. :type deployment_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: DeploymentExportResult, or the result of cls(response) + :return: DeploymentExportResult or the result of cls(response) :rtype: ~azure.mgmt.resource.resources.v2021_01_01.models.DeploymentExportResult - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.DeploymentExportResult"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) - api_version = kwargs.pop('api_version', "2021-01-01") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-01-01")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[_models.DeploymentExportResult] - request = build_deployments_export_template_at_scope_request( scope=scope, deployment_name=deployment_name, api_version=api_version, - template_url=self.export_template_at_scope.metadata['url'], + template_url=self.export_template_at_scope.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) - deserialized = self._deserialize('DeploymentExportResult', pipeline_response) + deserialized = self._deserialize("DeploymentExportResult", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - export_template_at_scope.metadata = {'url': "/{scope}/providers/Microsoft.Resources/deployments/{deploymentName}/exportTemplate"} # type: ignore - + export_template_at_scope.metadata = {"url": "/{scope}/providers/Microsoft.Resources/deployments/{deploymentName}/exportTemplate"} # type: ignore @distributed_trace def list_at_scope( - self, - scope: str, - filter: Optional[str] = None, - top: Optional[int] = None, - **kwargs: Any - ) -> Iterable["_models.DeploymentListResult"]: + self, scope: str, filter: Optional[str] = None, top: Optional[int] = None, **kwargs: Any + ) -> Iterable["_models.DeploymentExtended"]: """Get all the deployments at the given scope. - :param scope: The resource scope. + :param scope: The resource scope. Required. :type scope: str :param filter: The filter to apply on the operation. For example, you can use $filter=provisioningState eq '{state}'. Default value is None. @@ -4258,40 +3861,48 @@ def list_at_scope( value is None. :type top: int :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either DeploymentListResult or the result of - cls(response) + :return: An iterator like instance of either DeploymentExtended or the result of cls(response) :rtype: - ~azure.core.paging.ItemPaged[~azure.mgmt.resource.resources.v2021_01_01.models.DeploymentListResult] - :raises: ~azure.core.exceptions.HttpResponseError + ~azure.core.paging.ItemPaged[~azure.mgmt.resource.resources.v2021_01_01.models.DeploymentExtended] + :raises ~azure.core.exceptions.HttpResponseError: """ - api_version = kwargs.pop('api_version', "2021-01-01") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-01-01")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[_models.DeploymentListResult] - cls = kwargs.pop('cls', None) # type: ClsType["_models.DeploymentListResult"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) + def prepare_request(next_link=None): if not next_link: - + request = build_deployments_list_at_scope_request( scope=scope, - api_version=api_version, filter=filter, top=top, - template_url=self.list_at_scope.metadata['url'], + api_version=api_version, + template_url=self.list_at_scope.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore else: - - request = build_deployments_list_at_scope_request( - scope=scope, - template_url=next_link, - ) + # make call to next link with the client's api-version + _parsed_next_link = urlparse(next_link) + _next_request_params = case_insensitive_dict(parse_qs(_parsed_next_link.query)) + _next_request_params["api-version"] = self._config.api_version + request = HttpRequest("GET", urljoin(next_link, _parsed_next_link.path), params=_next_request_params) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore request.method = "GET" return request @@ -4305,10 +3916,8 @@ def extract_data(pipeline_response): def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) response = pipeline_response.http_response @@ -4318,39 +3927,41 @@ def get_next(next_link=None): return pipeline_response + return ItemPaged(get_next, extract_data) - return ItemPaged( - get_next, extract_data - ) - list_at_scope.metadata = {'url': "/{scope}/providers/Microsoft.Resources/deployments/"} # type: ignore + list_at_scope.metadata = {"url": "/{scope}/providers/Microsoft.Resources/deployments/"} # type: ignore def _delete_at_tenant_scope_initial( # pylint: disable=inconsistent-return-statements - self, - deployment_name: str, - **kwargs: Any + self, deployment_name: str, **kwargs: Any ) -> None: - cls = kwargs.pop('cls', None) # type: ClsType[None] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) - api_version = kwargs.pop('api_version', "2021-01-01") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - request = build_deployments_delete_at_tenant_scope_request_initial( + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-01-01")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[None] + + request = build_deployments_delete_at_tenant_scope_request( deployment_name=deployment_name, api_version=api_version, - template_url=self._delete_at_tenant_scope_initial.metadata['url'], + template_url=self._delete_at_tenant_scope_initial.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [202, 204]: @@ -4360,15 +3971,10 @@ def _delete_at_tenant_scope_initial( # pylint: disable=inconsistent-return-stat if cls: return cls(pipeline_response, None, {}) - _delete_at_tenant_scope_initial.metadata = {'url': "/providers/Microsoft.Resources/deployments/{deploymentName}"} # type: ignore - + _delete_at_tenant_scope_initial.metadata = {"url": "/providers/Microsoft.Resources/deployments/{deploymentName}"} # type: ignore @distributed_trace - def begin_delete_at_tenant_scope( # pylint: disable=inconsistent-return-statements - self, - deployment_name: str, - **kwargs: Any - ) -> LROPoller[None]: + def begin_delete_at_tenant_scope(self, deployment_name: str, **kwargs: Any) -> LROPoller[None]: """Deletes a deployment from the deployment history. A template deployment that is currently running cannot be deleted. Deleting a template @@ -4379,7 +3985,7 @@ def begin_delete_at_tenant_scope( # pylint: disable=inconsistent-return-stateme process finishes, the URI in the Location header returns a status of 204 on success. If the asynchronous request failed, the URI in the Location header returns an error-level status code. - :param deployment_name: The name of the deployment. + :param deployment_name: The name of the deployment. Required. :type deployment_name: str :keyword callable cls: A custom type or function that will be passed the direct response :keyword str continuation_token: A continuation token to restart a poller from a saved state. @@ -4391,81 +3997,87 @@ def begin_delete_at_tenant_scope( # pylint: disable=inconsistent-return-stateme Retry-After header is present. :return: An instance of LROPoller that returns either None or the result of cls(response) :rtype: ~azure.core.polling.LROPoller[None] - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - api_version = kwargs.pop('api_version', "2021-01-01") # type: str - polling = kwargs.pop('polling', True) # type: Union[bool, PollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType[None] - lro_delay = kwargs.pop( - 'polling_interval', - self._config.polling_interval - ) - cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-01-01")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[None] + polling = kwargs.pop("polling", True) # type: Union[bool, PollingMethod] + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token = kwargs.pop("continuation_token", None) # type: Optional[str] if cont_token is None: - raw_result = self._delete_at_tenant_scope_initial( + raw_result = self._delete_at_tenant_scope_initial( # type: ignore deployment_name=deployment_name, api_version=api_version, - cls=lambda x,y,z: x, + cls=lambda x, y, z: x, + headers=_headers, + params=_params, **kwargs ) - kwargs.pop('error_map', None) + kwargs.pop("error_map", None) - def get_long_running_output(pipeline_response): + def get_long_running_output(pipeline_response): # pylint: disable=inconsistent-return-statements if cls: return cls(pipeline_response, None, {}) - - if polling is True: polling_method = ARMPolling(lro_delay, **kwargs) - elif polling is False: polling_method = NoPolling() - else: polling_method = polling + if polling is True: + polling_method = cast(PollingMethod, ARMPolling(lro_delay, **kwargs)) # type: PollingMethod + elif polling is False: + polling_method = cast(PollingMethod, NoPolling()) + else: + polling_method = polling if cont_token: return LROPoller.from_continuation_token( polling_method=polling_method, continuation_token=cont_token, client=self._client, - deserialization_callback=get_long_running_output + deserialization_callback=get_long_running_output, ) return LROPoller(self._client, raw_result, get_long_running_output, polling_method) - begin_delete_at_tenant_scope.metadata = {'url': "/providers/Microsoft.Resources/deployments/{deploymentName}"} # type: ignore + begin_delete_at_tenant_scope.metadata = {"url": "/providers/Microsoft.Resources/deployments/{deploymentName}"} # type: ignore @distributed_trace - def check_existence_at_tenant_scope( - self, - deployment_name: str, - **kwargs: Any - ) -> bool: + def check_existence_at_tenant_scope(self, deployment_name: str, **kwargs: Any) -> bool: """Checks whether the deployment exists. - :param deployment_name: The name of the deployment. + :param deployment_name: The name of the deployment. Required. :type deployment_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: bool, or the result of cls(response) + :return: bool or the result of cls(response) :rtype: bool - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType[None] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) - api_version = kwargs.pop('api_version', "2021-01-01") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-01-01")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[None] - request = build_deployments_check_existence_at_tenant_scope_request( deployment_name=deployment_name, api_version=api_version, - template_url=self.check_existence_at_tenant_scope.metadata['url'], + template_url=self.check_existence_at_tenant_scope.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [204, 404]: @@ -4476,41 +4088,51 @@ def check_existence_at_tenant_scope( return cls(pipeline_response, None, {}) return 200 <= response.status_code <= 299 - check_existence_at_tenant_scope.metadata = {'url': "/providers/Microsoft.Resources/deployments/{deploymentName}"} # type: ignore - + check_existence_at_tenant_scope.metadata = {"url": "/providers/Microsoft.Resources/deployments/{deploymentName}"} # type: ignore def _create_or_update_at_tenant_scope_initial( - self, - deployment_name: str, - parameters: "_models.ScopedDeployment", - **kwargs: Any - ) -> "_models.DeploymentExtended": - cls = kwargs.pop('cls', None) # type: ClsType["_models.DeploymentExtended"] + self, deployment_name: str, parameters: Union[_models.ScopedDeployment, IO], **kwargs: Any + ) -> _models.DeploymentExtended: error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) - api_version = kwargs.pop('api_version', "2021-01-01") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - _json = self._serialize.body(parameters, 'ScopedDeployment') + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-01-01")) # type: str + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.DeploymentExtended] - request = build_deployments_create_or_update_at_tenant_scope_request_initial( + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(parameters, (IO, bytes)): + _content = parameters + else: + _json = self._serialize.body(parameters, "ScopedDeployment") + + request = build_deployments_create_or_update_at_tenant_scope_request( deployment_name=deployment_name, api_version=api_version, content_type=content_type, json=_json, - template_url=self._create_or_update_at_tenant_scope_initial.metadata['url'], + content=_content, + template_url=self._create_or_update_at_tenant_scope_initial.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200, 201]: @@ -4518,34 +4140,38 @@ def _create_or_update_at_tenant_scope_initial( raise HttpResponseError(response=response, error_format=ARMErrorFormat) if response.status_code == 200: - deserialized = self._deserialize('DeploymentExtended', pipeline_response) + deserialized = self._deserialize("DeploymentExtended", pipeline_response) if response.status_code == 201: - deserialized = self._deserialize('DeploymentExtended', pipeline_response) + deserialized = self._deserialize("DeploymentExtended", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - _create_or_update_at_tenant_scope_initial.metadata = {'url': "/providers/Microsoft.Resources/deployments/{deploymentName}"} # type: ignore + _create_or_update_at_tenant_scope_initial.metadata = {"url": "/providers/Microsoft.Resources/deployments/{deploymentName}"} # type: ignore - - @distributed_trace + @overload def begin_create_or_update_at_tenant_scope( self, deployment_name: str, - parameters: "_models.ScopedDeployment", + parameters: _models.ScopedDeployment, + *, + content_type: str = "application/json", **kwargs: Any - ) -> LROPoller["_models.DeploymentExtended"]: + ) -> LROPoller[_models.DeploymentExtended]: """Deploys resources at tenant scope. You can provide the template and parameters directly in the request or link to JSON files. - :param deployment_name: The name of the deployment. + :param deployment_name: The name of the deployment. Required. :type deployment_name: str - :param parameters: Additional parameters supplied to the operation. + :param parameters: Additional parameters supplied to the operation. Required. :type parameters: ~azure.mgmt.resource.resources.v2021_01_01.models.ScopedDeployment + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str :keyword callable cls: A custom type or function that will be passed the direct response :keyword str continuation_token: A continuation token to restart a poller from a saved state. :keyword polling: By default, your polling method will be ARMPolling. Pass in False for this @@ -4558,108 +4184,171 @@ def begin_create_or_update_at_tenant_scope( cls(response) :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.resource.resources.v2021_01_01.models.DeploymentExtended] - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - api_version = kwargs.pop('api_version', "2021-01-01") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] - polling = kwargs.pop('polling', True) # type: Union[bool, PollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType["_models.DeploymentExtended"] - lro_delay = kwargs.pop( - 'polling_interval', - self._config.polling_interval - ) - cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] - if cont_token is None: - raw_result = self._create_or_update_at_tenant_scope_initial( - deployment_name=deployment_name, - parameters=parameters, - api_version=api_version, - content_type=content_type, - cls=lambda x,y,z: x, - **kwargs - ) - kwargs.pop('error_map', None) - def get_long_running_output(pipeline_response): - response = pipeline_response.http_response - deserialized = self._deserialize('DeploymentExtended', pipeline_response) - if cls: - return cls(pipeline_response, deserialized, {}) - return deserialized + @overload + def begin_create_or_update_at_tenant_scope( + self, deployment_name: str, parameters: IO, *, content_type: str = "application/json", **kwargs: Any + ) -> LROPoller[_models.DeploymentExtended]: + """Deploys resources at tenant scope. + + You can provide the template and parameters directly in the request or link to JSON files. + + :param deployment_name: The name of the deployment. Required. + :type deployment_name: str + :param parameters: Additional parameters supplied to the operation. Required. + :type parameters: IO + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be ARMPolling. Pass in False for this + operation to not poll, or pass in your own initialized polling object for a personal polling + strategy. + :paramtype polling: bool or ~azure.core.polling.PollingMethod + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of LROPoller that returns either DeploymentExtended or the result of + cls(response) + :rtype: + ~azure.core.polling.LROPoller[~azure.mgmt.resource.resources.v2021_01_01.models.DeploymentExtended] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace + def begin_create_or_update_at_tenant_scope( + self, deployment_name: str, parameters: Union[_models.ScopedDeployment, IO], **kwargs: Any + ) -> LROPoller[_models.DeploymentExtended]: + """Deploys resources at tenant scope. + + You can provide the template and parameters directly in the request or link to JSON files. + + :param deployment_name: The name of the deployment. Required. + :type deployment_name: str + :param parameters: Additional parameters supplied to the operation. Is either a model type or a + IO type. Required. + :type parameters: ~azure.mgmt.resource.resources.v2021_01_01.models.ScopedDeployment or IO + :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. + Default value is None. + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be ARMPolling. Pass in False for this + operation to not poll, or pass in your own initialized polling object for a personal polling + strategy. + :paramtype polling: bool or ~azure.core.polling.PollingMethod + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of LROPoller that returns either DeploymentExtended or the result of + cls(response) + :rtype: + ~azure.core.polling.LROPoller[~azure.mgmt.resource.resources.v2021_01_01.models.DeploymentExtended] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _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-01-01")) # type: str + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.DeploymentExtended] + polling = kwargs.pop("polling", True) # type: Union[bool, PollingMethod] + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token = kwargs.pop("continuation_token", None) # type: Optional[str] + if cont_token is None: + raw_result = self._create_or_update_at_tenant_scope_initial( # type: ignore + deployment_name=deployment_name, + parameters=parameters, + api_version=api_version, + content_type=content_type, + cls=lambda x, y, z: x, + headers=_headers, + params=_params, + **kwargs + ) + kwargs.pop("error_map", None) + def get_long_running_output(pipeline_response): + deserialized = self._deserialize("DeploymentExtended", pipeline_response) + if cls: + return cls(pipeline_response, deserialized, {}) + return deserialized - if polling is True: polling_method = ARMPolling(lro_delay, **kwargs) - elif polling is False: polling_method = NoPolling() - else: polling_method = polling + if polling is True: + polling_method = cast(PollingMethod, ARMPolling(lro_delay, **kwargs)) # type: PollingMethod + elif polling is False: + polling_method = cast(PollingMethod, NoPolling()) + else: + polling_method = polling if cont_token: return LROPoller.from_continuation_token( polling_method=polling_method, continuation_token=cont_token, client=self._client, - deserialization_callback=get_long_running_output + deserialization_callback=get_long_running_output, ) return LROPoller(self._client, raw_result, get_long_running_output, polling_method) - begin_create_or_update_at_tenant_scope.metadata = {'url': "/providers/Microsoft.Resources/deployments/{deploymentName}"} # type: ignore + begin_create_or_update_at_tenant_scope.metadata = {"url": "/providers/Microsoft.Resources/deployments/{deploymentName}"} # type: ignore @distributed_trace - def get_at_tenant_scope( - self, - deployment_name: str, - **kwargs: Any - ) -> "_models.DeploymentExtended": + def get_at_tenant_scope(self, deployment_name: str, **kwargs: Any) -> _models.DeploymentExtended: """Gets a deployment. - :param deployment_name: The name of the deployment. + :param deployment_name: The name of the deployment. Required. :type deployment_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: DeploymentExtended, or the result of cls(response) + :return: DeploymentExtended or the result of cls(response) :rtype: ~azure.mgmt.resource.resources.v2021_01_01.models.DeploymentExtended - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.DeploymentExtended"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + 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', "2021-01-01") # type: str + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-01-01")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[_models.DeploymentExtended] - request = build_deployments_get_at_tenant_scope_request( deployment_name=deployment_name, api_version=api_version, - template_url=self.get_at_tenant_scope.metadata['url'], + template_url=self.get_at_tenant_scope.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) - deserialized = self._deserialize('DeploymentExtended', pipeline_response) + deserialized = self._deserialize("DeploymentExtended", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - get_at_tenant_scope.metadata = {'url': "/providers/Microsoft.Resources/deployments/{deploymentName}"} # type: ignore - + get_at_tenant_scope.metadata = {"url": "/providers/Microsoft.Resources/deployments/{deploymentName}"} # type: ignore @distributed_trace def cancel_at_tenant_scope( # pylint: disable=inconsistent-return-statements - self, - deployment_name: str, - **kwargs: Any + self, deployment_name: str, **kwargs: Any ) -> None: """Cancels a currently running template deployment. @@ -4668,35 +4357,41 @@ def cancel_at_tenant_scope( # pylint: disable=inconsistent-return-statements deployment stops the currently running template deployment and leaves the resources partially deployed. - :param deployment_name: The name of the deployment. + :param deployment_name: The name of the deployment. Required. :type deployment_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: None, or the result of cls(response) + :return: None or the result of cls(response) :rtype: None - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType[None] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + 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', "2021-01-01") # type: str + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-01-01")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[None] - request = build_deployments_cancel_at_tenant_scope_request( deployment_name=deployment_name, api_version=api_version, - template_url=self.cancel_at_tenant_scope.metadata['url'], + template_url=self.cancel_at_tenant_scope.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [204]: @@ -4706,41 +4401,51 @@ def cancel_at_tenant_scope( # pylint: disable=inconsistent-return-statements if cls: return cls(pipeline_response, None, {}) - cancel_at_tenant_scope.metadata = {'url': "/providers/Microsoft.Resources/deployments/{deploymentName}/cancel"} # type: ignore - + cancel_at_tenant_scope.metadata = {"url": "/providers/Microsoft.Resources/deployments/{deploymentName}/cancel"} # type: ignore def _validate_at_tenant_scope_initial( - self, - deployment_name: str, - parameters: "_models.ScopedDeployment", - **kwargs: Any - ) -> Optional["_models.DeploymentValidateResult"]: - cls = kwargs.pop('cls', None) # type: ClsType[Optional["_models.DeploymentValidateResult"]] + self, deployment_name: str, parameters: Union[_models.ScopedDeployment, IO], **kwargs: Any + ) -> Optional[_models.DeploymentValidateResult]: error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', "2021-01-01") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-01-01")) # type: str + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[Optional[_models.DeploymentValidateResult]] - _json = self._serialize.body(parameters, 'ScopedDeployment') + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(parameters, (IO, bytes)): + _content = parameters + else: + _json = self._serialize.body(parameters, "ScopedDeployment") - request = build_deployments_validate_at_tenant_scope_request_initial( + request = build_deployments_validate_at_tenant_scope_request( deployment_name=deployment_name, api_version=api_version, content_type=content_type, json=_json, - template_url=self._validate_at_tenant_scope_initial.metadata['url'], + content=_content, + template_url=self._validate_at_tenant_scope_initial.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200, 202, 400]: @@ -4749,33 +4454,37 @@ def _validate_at_tenant_scope_initial( deserialized = None if response.status_code == 200: - deserialized = self._deserialize('DeploymentValidateResult', pipeline_response) + deserialized = self._deserialize("DeploymentValidateResult", pipeline_response) if response.status_code == 400: - deserialized = self._deserialize('DeploymentValidateResult', pipeline_response) + deserialized = self._deserialize("DeploymentValidateResult", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - _validate_at_tenant_scope_initial.metadata = {'url': "/providers/Microsoft.Resources/deployments/{deploymentName}/validate"} # type: ignore - + _validate_at_tenant_scope_initial.metadata = {"url": "/providers/Microsoft.Resources/deployments/{deploymentName}/validate"} # type: ignore - @distributed_trace + @overload def begin_validate_at_tenant_scope( self, deployment_name: str, - parameters: "_models.ScopedDeployment", + parameters: _models.ScopedDeployment, + *, + content_type: str = "application/json", **kwargs: Any - ) -> LROPoller["_models.DeploymentValidateResult"]: + ) -> LROPoller[_models.DeploymentValidateResult]: """Validates whether the specified template is syntactically correct and will be accepted by Azure Resource Manager.. - :param deployment_name: The name of the deployment. + :param deployment_name: The name of the deployment. Required. :type deployment_name: str - :param parameters: Parameters to validate. + :param parameters: Parameters to validate. Required. :type parameters: ~azure.mgmt.resource.resources.v2021_01_01.models.ScopedDeployment + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str :keyword callable cls: A custom type or function that will be passed the direct response :keyword str continuation_token: A continuation token to restart a poller from a saved state. :keyword polling: By default, your polling method will be ARMPolling. Pass in False for this @@ -4788,82 +4497,154 @@ def begin_validate_at_tenant_scope( cls(response) :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.resource.resources.v2021_01_01.models.DeploymentValidateResult] - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - api_version = kwargs.pop('api_version', "2021-01-01") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] - polling = kwargs.pop('polling', True) # type: Union[bool, PollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType["_models.DeploymentValidateResult"] - lro_delay = kwargs.pop( - 'polling_interval', - self._config.polling_interval - ) - cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] + + @overload + def begin_validate_at_tenant_scope( + self, deployment_name: str, parameters: IO, *, content_type: str = "application/json", **kwargs: Any + ) -> LROPoller[_models.DeploymentValidateResult]: + """Validates whether the specified template is syntactically correct and will be accepted by Azure + Resource Manager.. + + :param deployment_name: The name of the deployment. Required. + :type deployment_name: str + :param parameters: Parameters to validate. Required. + :type parameters: IO + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be ARMPolling. Pass in False for this + operation to not poll, or pass in your own initialized polling object for a personal polling + strategy. + :paramtype polling: bool or ~azure.core.polling.PollingMethod + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of LROPoller that returns either DeploymentValidateResult or the result of + cls(response) + :rtype: + ~azure.core.polling.LROPoller[~azure.mgmt.resource.resources.v2021_01_01.models.DeploymentValidateResult] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace + def begin_validate_at_tenant_scope( + self, deployment_name: str, parameters: Union[_models.ScopedDeployment, IO], **kwargs: Any + ) -> LROPoller[_models.DeploymentValidateResult]: + """Validates whether the specified template is syntactically correct and will be accepted by Azure + Resource Manager.. + + :param deployment_name: The name of the deployment. Required. + :type deployment_name: str + :param parameters: Parameters to validate. Is either a model type or a IO type. Required. + :type parameters: ~azure.mgmt.resource.resources.v2021_01_01.models.ScopedDeployment or IO + :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. + Default value is None. + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be ARMPolling. Pass in False for this + operation to not poll, or pass in your own initialized polling object for a personal polling + strategy. + :paramtype polling: bool or ~azure.core.polling.PollingMethod + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of LROPoller that returns either DeploymentValidateResult or the result of + cls(response) + :rtype: + ~azure.core.polling.LROPoller[~azure.mgmt.resource.resources.v2021_01_01.models.DeploymentValidateResult] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _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-01-01")) # type: str + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.DeploymentValidateResult] + polling = kwargs.pop("polling", True) # type: Union[bool, PollingMethod] + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token = kwargs.pop("continuation_token", None) # type: Optional[str] if cont_token is None: - raw_result = self._validate_at_tenant_scope_initial( + raw_result = self._validate_at_tenant_scope_initial( # type: ignore deployment_name=deployment_name, parameters=parameters, api_version=api_version, content_type=content_type, - cls=lambda x,y,z: x, + cls=lambda x, y, z: x, + headers=_headers, + params=_params, **kwargs ) - kwargs.pop('error_map', None) + kwargs.pop("error_map", None) def get_long_running_output(pipeline_response): - response = pipeline_response.http_response - deserialized = self._deserialize('DeploymentValidateResult', pipeline_response) + deserialized = self._deserialize("DeploymentValidateResult", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - - if polling is True: polling_method = ARMPolling(lro_delay, **kwargs) - elif polling is False: polling_method = NoPolling() - else: polling_method = polling + if polling is True: + polling_method = cast(PollingMethod, ARMPolling(lro_delay, **kwargs)) # type: PollingMethod + elif polling is False: + polling_method = cast(PollingMethod, NoPolling()) + else: + polling_method = polling if cont_token: return LROPoller.from_continuation_token( polling_method=polling_method, continuation_token=cont_token, client=self._client, - deserialization_callback=get_long_running_output + deserialization_callback=get_long_running_output, ) return LROPoller(self._client, raw_result, get_long_running_output, polling_method) - begin_validate_at_tenant_scope.metadata = {'url': "/providers/Microsoft.Resources/deployments/{deploymentName}/validate"} # type: ignore + begin_validate_at_tenant_scope.metadata = {"url": "/providers/Microsoft.Resources/deployments/{deploymentName}/validate"} # type: ignore def _what_if_at_tenant_scope_initial( - self, - deployment_name: str, - parameters: "_models.ScopedDeploymentWhatIf", - **kwargs: Any - ) -> Optional["_models.WhatIfOperationResult"]: - cls = kwargs.pop('cls', None) # type: ClsType[Optional["_models.WhatIfOperationResult"]] + self, deployment_name: str, parameters: Union[_models.ScopedDeploymentWhatIf, IO], **kwargs: Any + ) -> Optional[_models.WhatIfOperationResult]: error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', "2021-01-01") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-01-01")) # type: str + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[Optional[_models.WhatIfOperationResult]] - _json = self._serialize.body(parameters, 'ScopedDeploymentWhatIf') + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(parameters, (IO, bytes)): + _content = parameters + else: + _json = self._serialize.body(parameters, "ScopedDeploymentWhatIf") - request = build_deployments_what_if_at_tenant_scope_request_initial( + request = build_deployments_what_if_at_tenant_scope_request( deployment_name=deployment_name, api_version=api_version, content_type=content_type, json=_json, - template_url=self._what_if_at_tenant_scope_initial.metadata['url'], + content=_content, + template_url=self._what_if_at_tenant_scope_initial.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200, 202]: @@ -4873,35 +4654,38 @@ def _what_if_at_tenant_scope_initial( deserialized = None response_headers = {} if response.status_code == 200: - deserialized = self._deserialize('WhatIfOperationResult', pipeline_response) + deserialized = self._deserialize("WhatIfOperationResult", pipeline_response) if response.status_code == 202: - response_headers['Location']=self._deserialize('str', response.headers.get('Location')) - response_headers['Retry-After']=self._deserialize('str', response.headers.get('Retry-After')) - + response_headers["Location"] = self._deserialize("str", response.headers.get("Location")) + response_headers["Retry-After"] = self._deserialize("str", response.headers.get("Retry-After")) if cls: return cls(pipeline_response, deserialized, response_headers) return deserialized - _what_if_at_tenant_scope_initial.metadata = {'url': "/providers/Microsoft.Resources/deployments/{deploymentName}/whatIf"} # type: ignore - + _what_if_at_tenant_scope_initial.metadata = {"url": "/providers/Microsoft.Resources/deployments/{deploymentName}/whatIf"} # type: ignore - @distributed_trace + @overload def begin_what_if_at_tenant_scope( self, deployment_name: str, - parameters: "_models.ScopedDeploymentWhatIf", + parameters: _models.ScopedDeploymentWhatIf, + *, + content_type: str = "application/json", **kwargs: Any - ) -> LROPoller["_models.WhatIfOperationResult"]: + ) -> LROPoller[_models.WhatIfOperationResult]: """Returns changes that will be made by the deployment if executed at the scope of the tenant group. - :param deployment_name: The name of the deployment. + :param deployment_name: The name of the deployment. Required. :type deployment_name: str - :param parameters: Parameters to validate. + :param parameters: Parameters to validate. Required. :type parameters: ~azure.mgmt.resource.resources.v2021_01_01.models.ScopedDeploymentWhatIf + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str :keyword callable cls: A custom type or function that will be passed the direct response :keyword str continuation_token: A continuation token to restart a poller from a saved state. :keyword polling: By default, your polling method will be ARMPolling. Pass in False for this @@ -4914,110 +4698,172 @@ def begin_what_if_at_tenant_scope( cls(response) :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.resource.resources.v2021_01_01.models.WhatIfOperationResult] - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - api_version = kwargs.pop('api_version', "2021-01-01") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] - polling = kwargs.pop('polling', True) # type: Union[bool, PollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType["_models.WhatIfOperationResult"] - lro_delay = kwargs.pop( - 'polling_interval', - self._config.polling_interval - ) - cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] + + @overload + def begin_what_if_at_tenant_scope( + self, deployment_name: str, parameters: IO, *, content_type: str = "application/json", **kwargs: Any + ) -> LROPoller[_models.WhatIfOperationResult]: + """Returns changes that will be made by the deployment if executed at the scope of the tenant + group. + + :param deployment_name: The name of the deployment. Required. + :type deployment_name: str + :param parameters: Parameters to validate. Required. + :type parameters: IO + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be ARMPolling. Pass in False for this + operation to not poll, or pass in your own initialized polling object for a personal polling + strategy. + :paramtype polling: bool or ~azure.core.polling.PollingMethod + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of LROPoller that returns either WhatIfOperationResult or the result of + cls(response) + :rtype: + ~azure.core.polling.LROPoller[~azure.mgmt.resource.resources.v2021_01_01.models.WhatIfOperationResult] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace + def begin_what_if_at_tenant_scope( + self, deployment_name: str, parameters: Union[_models.ScopedDeploymentWhatIf, IO], **kwargs: Any + ) -> LROPoller[_models.WhatIfOperationResult]: + """Returns changes that will be made by the deployment if executed at the scope of the tenant + group. + + :param deployment_name: The name of the deployment. Required. + :type deployment_name: str + :param parameters: Parameters to validate. Is either a model type or a IO type. Required. + :type parameters: ~azure.mgmt.resource.resources.v2021_01_01.models.ScopedDeploymentWhatIf or + IO + :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. + Default value is None. + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be ARMPolling. Pass in False for this + operation to not poll, or pass in your own initialized polling object for a personal polling + strategy. + :paramtype polling: bool or ~azure.core.polling.PollingMethod + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of LROPoller that returns either WhatIfOperationResult or the result of + cls(response) + :rtype: + ~azure.core.polling.LROPoller[~azure.mgmt.resource.resources.v2021_01_01.models.WhatIfOperationResult] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _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-01-01")) # type: str + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.WhatIfOperationResult] + polling = kwargs.pop("polling", True) # type: Union[bool, PollingMethod] + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token = kwargs.pop("continuation_token", None) # type: Optional[str] if cont_token is None: - raw_result = self._what_if_at_tenant_scope_initial( + raw_result = self._what_if_at_tenant_scope_initial( # type: ignore deployment_name=deployment_name, parameters=parameters, api_version=api_version, content_type=content_type, - cls=lambda x,y,z: x, + cls=lambda x, y, z: x, + headers=_headers, + params=_params, **kwargs ) - kwargs.pop('error_map', None) + kwargs.pop("error_map", None) def get_long_running_output(pipeline_response): - response = pipeline_response.http_response - deserialized = self._deserialize('WhatIfOperationResult', pipeline_response) + deserialized = self._deserialize("WhatIfOperationResult", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - - if polling is True: polling_method = ARMPolling(lro_delay, lro_options={'final-state-via': 'location'}, **kwargs) - elif polling is False: polling_method = NoPolling() - else: polling_method = polling + if polling is True: + polling_method = cast( + PollingMethod, ARMPolling(lro_delay, lro_options={"final-state-via": "location"}, **kwargs) + ) # type: PollingMethod + elif polling is False: + polling_method = cast(PollingMethod, NoPolling()) + else: + polling_method = polling if cont_token: return LROPoller.from_continuation_token( polling_method=polling_method, continuation_token=cont_token, client=self._client, - deserialization_callback=get_long_running_output + deserialization_callback=get_long_running_output, ) return LROPoller(self._client, raw_result, get_long_running_output, polling_method) - begin_what_if_at_tenant_scope.metadata = {'url': "/providers/Microsoft.Resources/deployments/{deploymentName}/whatIf"} # type: ignore + begin_what_if_at_tenant_scope.metadata = {"url": "/providers/Microsoft.Resources/deployments/{deploymentName}/whatIf"} # type: ignore @distributed_trace - def export_template_at_tenant_scope( - self, - deployment_name: str, - **kwargs: Any - ) -> "_models.DeploymentExportResult": + def export_template_at_tenant_scope(self, deployment_name: str, **kwargs: Any) -> _models.DeploymentExportResult: """Exports the template used for specified deployment. - :param deployment_name: The name of the deployment. + :param deployment_name: The name of the deployment. Required. :type deployment_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: DeploymentExportResult, or the result of cls(response) + :return: DeploymentExportResult or the result of cls(response) :rtype: ~azure.mgmt.resource.resources.v2021_01_01.models.DeploymentExportResult - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.DeploymentExportResult"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + 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', "2021-01-01") # type: str + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-01-01")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[_models.DeploymentExportResult] - request = build_deployments_export_template_at_tenant_scope_request( deployment_name=deployment_name, api_version=api_version, - template_url=self.export_template_at_tenant_scope.metadata['url'], + template_url=self.export_template_at_tenant_scope.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) - deserialized = self._deserialize('DeploymentExportResult', pipeline_response) + deserialized = self._deserialize("DeploymentExportResult", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - export_template_at_tenant_scope.metadata = {'url': "/providers/Microsoft.Resources/deployments/{deploymentName}/exportTemplate"} # type: ignore - + export_template_at_tenant_scope.metadata = {"url": "/providers/Microsoft.Resources/deployments/{deploymentName}/exportTemplate"} # type: ignore @distributed_trace def list_at_tenant_scope( - self, - filter: Optional[str] = None, - top: Optional[int] = None, - **kwargs: Any - ) -> Iterable["_models.DeploymentListResult"]: + self, filter: Optional[str] = None, top: Optional[int] = None, **kwargs: Any + ) -> Iterable["_models.DeploymentExtended"]: """Get all the deployments at the tenant scope. :param filter: The filter to apply on the operation. For example, you can use @@ -5027,38 +4873,47 @@ def list_at_tenant_scope( value is None. :type top: int :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either DeploymentListResult or the result of - cls(response) + :return: An iterator like instance of either DeploymentExtended or the result of cls(response) :rtype: - ~azure.core.paging.ItemPaged[~azure.mgmt.resource.resources.v2021_01_01.models.DeploymentListResult] - :raises: ~azure.core.exceptions.HttpResponseError + ~azure.core.paging.ItemPaged[~azure.mgmt.resource.resources.v2021_01_01.models.DeploymentExtended] + :raises ~azure.core.exceptions.HttpResponseError: """ - api_version = kwargs.pop('api_version', "2021-01-01") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-01-01")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[_models.DeploymentListResult] - cls = kwargs.pop('cls', None) # type: ClsType["_models.DeploymentListResult"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) + def prepare_request(next_link=None): if not next_link: - + request = build_deployments_list_at_tenant_scope_request( - api_version=api_version, filter=filter, top=top, - template_url=self.list_at_tenant_scope.metadata['url'], + api_version=api_version, + template_url=self.list_at_tenant_scope.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore else: - - request = build_deployments_list_at_tenant_scope_request( - template_url=next_link, - ) + # make call to next link with the client's api-version + _parsed_next_link = urlparse(next_link) + _next_request_params = case_insensitive_dict(parse_qs(_parsed_next_link.query)) + _next_request_params["api-version"] = self._config.api_version + request = HttpRequest("GET", urljoin(next_link, _parsed_next_link.path), params=_next_request_params) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore request.method = "GET" return request @@ -5072,10 +4927,8 @@ def extract_data(pipeline_response): def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) response = pipeline_response.http_response @@ -5085,41 +4938,42 @@ def get_next(next_link=None): return pipeline_response + return ItemPaged(get_next, extract_data) - return ItemPaged( - get_next, extract_data - ) - list_at_tenant_scope.metadata = {'url': "/providers/Microsoft.Resources/deployments/"} # type: ignore + list_at_tenant_scope.metadata = {"url": "/providers/Microsoft.Resources/deployments/"} # type: ignore def _delete_at_management_group_scope_initial( # pylint: disable=inconsistent-return-statements - self, - group_id: str, - deployment_name: str, - **kwargs: Any + self, group_id: str, deployment_name: str, **kwargs: Any ) -> None: - cls = kwargs.pop('cls', None) # type: ClsType[None] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) - api_version = kwargs.pop('api_version', "2021-01-01") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - request = build_deployments_delete_at_management_group_scope_request_initial( + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-01-01")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[None] + + request = build_deployments_delete_at_management_group_scope_request( group_id=group_id, deployment_name=deployment_name, api_version=api_version, - template_url=self._delete_at_management_group_scope_initial.metadata['url'], + template_url=self._delete_at_management_group_scope_initial.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [202, 204]: @@ -5129,15 +4983,11 @@ def _delete_at_management_group_scope_initial( # pylint: disable=inconsistent-r if cls: return cls(pipeline_response, None, {}) - _delete_at_management_group_scope_initial.metadata = {'url': "/providers/Microsoft.Management/managementGroups/{groupId}/providers/Microsoft.Resources/deployments/{deploymentName}"} # type: ignore - + _delete_at_management_group_scope_initial.metadata = {"url": "/providers/Microsoft.Management/managementGroups/{groupId}/providers/Microsoft.Resources/deployments/{deploymentName}"} # type: ignore @distributed_trace - def begin_delete_at_management_group_scope( # pylint: disable=inconsistent-return-statements - self, - group_id: str, - deployment_name: str, - **kwargs: Any + def begin_delete_at_management_group_scope( + self, group_id: str, deployment_name: str, **kwargs: Any ) -> LROPoller[None]: """Deletes a deployment from the deployment history. @@ -5149,9 +4999,9 @@ def begin_delete_at_management_group_scope( # pylint: disable=inconsistent-retu process finishes, the URI in the Location header returns a status of 204 on success. If the asynchronous request failed, the URI in the Location header returns an error-level status code. - :param group_id: The management group ID. + :param group_id: The management group ID. Required. :type group_id: str - :param deployment_name: The name of the deployment. + :param deployment_name: The name of the deployment. Required. :type deployment_name: str :keyword callable cls: A custom type or function that will be passed the direct response :keyword str continuation_token: A continuation token to restart a poller from a saved state. @@ -5163,86 +5013,91 @@ def begin_delete_at_management_group_scope( # pylint: disable=inconsistent-retu Retry-After header is present. :return: An instance of LROPoller that returns either None or the result of cls(response) :rtype: ~azure.core.polling.LROPoller[None] - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - api_version = kwargs.pop('api_version', "2021-01-01") # type: str - polling = kwargs.pop('polling', True) # type: Union[bool, PollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType[None] - lro_delay = kwargs.pop( - 'polling_interval', - self._config.polling_interval - ) - cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-01-01")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[None] + polling = kwargs.pop("polling", True) # type: Union[bool, PollingMethod] + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token = kwargs.pop("continuation_token", None) # type: Optional[str] if cont_token is None: - raw_result = self._delete_at_management_group_scope_initial( + raw_result = self._delete_at_management_group_scope_initial( # type: ignore group_id=group_id, deployment_name=deployment_name, api_version=api_version, - cls=lambda x,y,z: x, + cls=lambda x, y, z: x, + headers=_headers, + params=_params, **kwargs ) - kwargs.pop('error_map', None) + kwargs.pop("error_map", None) - def get_long_running_output(pipeline_response): + def get_long_running_output(pipeline_response): # pylint: disable=inconsistent-return-statements if cls: return cls(pipeline_response, None, {}) - - if polling is True: polling_method = ARMPolling(lro_delay, **kwargs) - elif polling is False: polling_method = NoPolling() - else: polling_method = polling + if polling is True: + polling_method = cast(PollingMethod, ARMPolling(lro_delay, **kwargs)) # type: PollingMethod + elif polling is False: + polling_method = cast(PollingMethod, NoPolling()) + else: + polling_method = polling if cont_token: return LROPoller.from_continuation_token( polling_method=polling_method, continuation_token=cont_token, client=self._client, - deserialization_callback=get_long_running_output + deserialization_callback=get_long_running_output, ) return LROPoller(self._client, raw_result, get_long_running_output, polling_method) - begin_delete_at_management_group_scope.metadata = {'url': "/providers/Microsoft.Management/managementGroups/{groupId}/providers/Microsoft.Resources/deployments/{deploymentName}"} # type: ignore + begin_delete_at_management_group_scope.metadata = {"url": "/providers/Microsoft.Management/managementGroups/{groupId}/providers/Microsoft.Resources/deployments/{deploymentName}"} # type: ignore @distributed_trace - def check_existence_at_management_group_scope( - self, - group_id: str, - deployment_name: str, - **kwargs: Any - ) -> bool: + def check_existence_at_management_group_scope(self, group_id: str, deployment_name: str, **kwargs: Any) -> bool: """Checks whether the deployment exists. - :param group_id: The management group ID. + :param group_id: The management group ID. Required. :type group_id: str - :param deployment_name: The name of the deployment. + :param deployment_name: The name of the deployment. Required. :type deployment_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: bool, or the result of cls(response) + :return: bool or the result of cls(response) :rtype: bool - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType[None] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + 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', "2021-01-01") # type: str + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-01-01")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[None] - request = build_deployments_check_existence_at_management_group_scope_request( group_id=group_id, deployment_name=deployment_name, api_version=api_version, - template_url=self.check_existence_at_management_group_scope.metadata['url'], + template_url=self.check_existence_at_management_group_scope.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [204, 404]: @@ -5253,43 +5108,52 @@ def check_existence_at_management_group_scope( return cls(pipeline_response, None, {}) return 200 <= response.status_code <= 299 - check_existence_at_management_group_scope.metadata = {'url': "/providers/Microsoft.Management/managementGroups/{groupId}/providers/Microsoft.Resources/deployments/{deploymentName}"} # type: ignore - + check_existence_at_management_group_scope.metadata = {"url": "/providers/Microsoft.Management/managementGroups/{groupId}/providers/Microsoft.Resources/deployments/{deploymentName}"} # type: ignore def _create_or_update_at_management_group_scope_initial( - self, - group_id: str, - deployment_name: str, - parameters: "_models.ScopedDeployment", - **kwargs: Any - ) -> "_models.DeploymentExtended": - cls = kwargs.pop('cls', None) # type: ClsType["_models.DeploymentExtended"] + self, group_id: str, deployment_name: str, parameters: Union[_models.ScopedDeployment, IO], **kwargs: Any + ) -> _models.DeploymentExtended: error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) - api_version = kwargs.pop('api_version', "2021-01-01") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - _json = self._serialize.body(parameters, 'ScopedDeployment') + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-01-01")) # type: str + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.DeploymentExtended] - request = build_deployments_create_or_update_at_management_group_scope_request_initial( + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(parameters, (IO, bytes)): + _content = parameters + else: + _json = self._serialize.body(parameters, "ScopedDeployment") + + request = build_deployments_create_or_update_at_management_group_scope_request( group_id=group_id, deployment_name=deployment_name, api_version=api_version, content_type=content_type, json=_json, - template_url=self._create_or_update_at_management_group_scope_initial.metadata['url'], + content=_content, + template_url=self._create_or_update_at_management_group_scope_initial.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200, 201]: @@ -5297,37 +5161,41 @@ def _create_or_update_at_management_group_scope_initial( raise HttpResponseError(response=response, error_format=ARMErrorFormat) if response.status_code == 200: - deserialized = self._deserialize('DeploymentExtended', pipeline_response) + deserialized = self._deserialize("DeploymentExtended", pipeline_response) if response.status_code == 201: - deserialized = self._deserialize('DeploymentExtended', pipeline_response) + deserialized = self._deserialize("DeploymentExtended", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - _create_or_update_at_management_group_scope_initial.metadata = {'url': "/providers/Microsoft.Management/managementGroups/{groupId}/providers/Microsoft.Resources/deployments/{deploymentName}"} # type: ignore + _create_or_update_at_management_group_scope_initial.metadata = {"url": "/providers/Microsoft.Management/managementGroups/{groupId}/providers/Microsoft.Resources/deployments/{deploymentName}"} # type: ignore - - @distributed_trace + @overload def begin_create_or_update_at_management_group_scope( self, group_id: str, deployment_name: str, - parameters: "_models.ScopedDeployment", + parameters: _models.ScopedDeployment, + *, + content_type: str = "application/json", **kwargs: Any - ) -> LROPoller["_models.DeploymentExtended"]: + ) -> LROPoller[_models.DeploymentExtended]: """Deploys resources at management group scope. You can provide the template and parameters directly in the request or link to JSON files. - :param group_id: The management group ID. + :param group_id: The management group ID. Required. :type group_id: str - :param deployment_name: The name of the deployment. + :param deployment_name: The name of the deployment. Required. :type deployment_name: str - :param parameters: Additional parameters supplied to the operation. + :param parameters: Additional parameters supplied to the operation. Required. :type parameters: ~azure.mgmt.resource.resources.v2021_01_01.models.ScopedDeployment + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str :keyword callable cls: A custom type or function that will be passed the direct response :keyword str continuation_token: A continuation token to restart a poller from a saved state. :keyword polling: By default, your polling method will be ARMPolling. Pass in False for this @@ -5340,114 +5208,187 @@ def begin_create_or_update_at_management_group_scope( cls(response) :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.resource.resources.v2021_01_01.models.DeploymentExtended] - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - api_version = kwargs.pop('api_version', "2021-01-01") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] - polling = kwargs.pop('polling', True) # type: Union[bool, PollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType["_models.DeploymentExtended"] - lro_delay = kwargs.pop( - 'polling_interval', - self._config.polling_interval - ) - cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] - if cont_token is None: - raw_result = self._create_or_update_at_management_group_scope_initial( - group_id=group_id, - deployment_name=deployment_name, - parameters=parameters, - api_version=api_version, - content_type=content_type, - cls=lambda x,y,z: x, - **kwargs - ) - kwargs.pop('error_map', None) - - def get_long_running_output(pipeline_response): - response = pipeline_response.http_response - deserialized = self._deserialize('DeploymentExtended', pipeline_response) - if cls: - return cls(pipeline_response, deserialized, {}) - return deserialized - - - if polling is True: polling_method = ARMPolling(lro_delay, **kwargs) - elif polling is False: polling_method = NoPolling() - else: polling_method = polling - if cont_token: - return LROPoller.from_continuation_token( - polling_method=polling_method, - continuation_token=cont_token, - client=self._client, - deserialization_callback=get_long_running_output - ) - return LROPoller(self._client, raw_result, get_long_running_output, polling_method) - begin_create_or_update_at_management_group_scope.metadata = {'url': "/providers/Microsoft.Management/managementGroups/{groupId}/providers/Microsoft.Resources/deployments/{deploymentName}"} # type: ignore - - @distributed_trace - def get_at_management_group_scope( + @overload + def begin_create_or_update_at_management_group_scope( self, group_id: str, deployment_name: str, + parameters: IO, + *, + content_type: str = "application/json", **kwargs: Any - ) -> "_models.DeploymentExtended": - """Gets a deployment. + ) -> LROPoller[_models.DeploymentExtended]: + """Deploys resources at management group scope. + + You can provide the template and parameters directly in the request or link to JSON files. - :param group_id: The management group ID. + :param group_id: The management group ID. Required. :type group_id: str - :param deployment_name: The name of the deployment. + :param deployment_name: The name of the deployment. Required. :type deployment_name: str + :param parameters: Additional parameters supplied to the operation. Required. + :type parameters: IO + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: DeploymentExtended, or the result of cls(response) - :rtype: ~azure.mgmt.resource.resources.v2021_01_01.models.DeploymentExtended - :raises: ~azure.core.exceptions.HttpResponseError - """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.DeploymentExtended"] - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {})) - - api_version = kwargs.pop('api_version', "2021-01-01") # type: str - - - request = build_deployments_get_at_management_group_scope_request( - group_id=group_id, + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be ARMPolling. Pass in False for this + operation to not poll, or pass in your own initialized polling object for a personal polling + strategy. + :paramtype polling: bool or ~azure.core.polling.PollingMethod + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of LROPoller that returns either DeploymentExtended or the result of + cls(response) + :rtype: + ~azure.core.polling.LROPoller[~azure.mgmt.resource.resources.v2021_01_01.models.DeploymentExtended] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace + def begin_create_or_update_at_management_group_scope( + self, group_id: str, deployment_name: str, parameters: Union[_models.ScopedDeployment, IO], **kwargs: Any + ) -> LROPoller[_models.DeploymentExtended]: + """Deploys resources at management group scope. + + You can provide the template and parameters directly in the request or link to JSON files. + + :param group_id: The management group ID. Required. + :type group_id: str + :param deployment_name: The name of the deployment. Required. + :type deployment_name: str + :param parameters: Additional parameters supplied to the operation. Is either a model type or a + IO type. Required. + :type parameters: ~azure.mgmt.resource.resources.v2021_01_01.models.ScopedDeployment or IO + :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. + Default value is None. + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be ARMPolling. Pass in False for this + operation to not poll, or pass in your own initialized polling object for a personal polling + strategy. + :paramtype polling: bool or ~azure.core.polling.PollingMethod + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of LROPoller that returns either DeploymentExtended or the result of + cls(response) + :rtype: + ~azure.core.polling.LROPoller[~azure.mgmt.resource.resources.v2021_01_01.models.DeploymentExtended] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _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-01-01")) # type: str + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.DeploymentExtended] + polling = kwargs.pop("polling", True) # type: Union[bool, PollingMethod] + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token = kwargs.pop("continuation_token", None) # type: Optional[str] + if cont_token is None: + raw_result = self._create_or_update_at_management_group_scope_initial( # type: ignore + group_id=group_id, + deployment_name=deployment_name, + parameters=parameters, + api_version=api_version, + content_type=content_type, + cls=lambda x, y, z: x, + headers=_headers, + params=_params, + **kwargs + ) + kwargs.pop("error_map", None) + + def get_long_running_output(pipeline_response): + deserialized = self._deserialize("DeploymentExtended", pipeline_response) + if cls: + return cls(pipeline_response, deserialized, {}) + return deserialized + + if polling is True: + polling_method = cast(PollingMethod, ARMPolling(lro_delay, **kwargs)) # type: PollingMethod + elif polling is False: + polling_method = cast(PollingMethod, NoPolling()) + else: + polling_method = polling + if cont_token: + return LROPoller.from_continuation_token( + polling_method=polling_method, + continuation_token=cont_token, + client=self._client, + deserialization_callback=get_long_running_output, + ) + return LROPoller(self._client, raw_result, get_long_running_output, polling_method) + + begin_create_or_update_at_management_group_scope.metadata = {"url": "/providers/Microsoft.Management/managementGroups/{groupId}/providers/Microsoft.Resources/deployments/{deploymentName}"} # type: ignore + + @distributed_trace + def get_at_management_group_scope( + self, group_id: str, deployment_name: str, **kwargs: Any + ) -> _models.DeploymentExtended: + """Gets a deployment. + + :param group_id: The management group ID. Required. + :type group_id: str + :param deployment_name: The name of the deployment. Required. + :type deployment_name: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: DeploymentExtended or the result of cls(response) + :rtype: ~azure.mgmt.resource.resources.v2021_01_01.models.DeploymentExtended + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-01-01")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[_models.DeploymentExtended] + + request = build_deployments_get_at_management_group_scope_request( + group_id=group_id, deployment_name=deployment_name, api_version=api_version, - template_url=self.get_at_management_group_scope.metadata['url'], + template_url=self.get_at_management_group_scope.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) - deserialized = self._deserialize('DeploymentExtended', pipeline_response) + deserialized = self._deserialize("DeploymentExtended", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - get_at_management_group_scope.metadata = {'url': "/providers/Microsoft.Management/managementGroups/{groupId}/providers/Microsoft.Resources/deployments/{deploymentName}"} # type: ignore - + get_at_management_group_scope.metadata = {"url": "/providers/Microsoft.Management/managementGroups/{groupId}/providers/Microsoft.Resources/deployments/{deploymentName}"} # type: ignore @distributed_trace def cancel_at_management_group_scope( # pylint: disable=inconsistent-return-statements - self, - group_id: str, - deployment_name: str, - **kwargs: Any + self, group_id: str, deployment_name: str, **kwargs: Any ) -> None: """Cancels a currently running template deployment. @@ -5456,38 +5397,44 @@ def cancel_at_management_group_scope( # pylint: disable=inconsistent-return-sta deployment stops the currently running template deployment and leaves the resources partially deployed. - :param group_id: The management group ID. + :param group_id: The management group ID. Required. :type group_id: str - :param deployment_name: The name of the deployment. + :param deployment_name: The name of the deployment. Required. :type deployment_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: None, or the result of cls(response) + :return: None or the result of cls(response) :rtype: None - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType[None] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) - api_version = kwargs.pop('api_version', "2021-01-01") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-01-01")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[None] - request = build_deployments_cancel_at_management_group_scope_request( group_id=group_id, deployment_name=deployment_name, api_version=api_version, - template_url=self.cancel_at_management_group_scope.metadata['url'], + template_url=self.cancel_at_management_group_scope.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [204]: @@ -5497,43 +5444,52 @@ def cancel_at_management_group_scope( # pylint: disable=inconsistent-return-sta if cls: return cls(pipeline_response, None, {}) - cancel_at_management_group_scope.metadata = {'url': "/providers/Microsoft.Management/managementGroups/{groupId}/providers/Microsoft.Resources/deployments/{deploymentName}/cancel"} # type: ignore - + cancel_at_management_group_scope.metadata = {"url": "/providers/Microsoft.Management/managementGroups/{groupId}/providers/Microsoft.Resources/deployments/{deploymentName}/cancel"} # type: ignore def _validate_at_management_group_scope_initial( - self, - group_id: str, - deployment_name: str, - parameters: "_models.ScopedDeployment", - **kwargs: Any - ) -> Optional["_models.DeploymentValidateResult"]: - cls = kwargs.pop('cls', None) # type: ClsType[Optional["_models.DeploymentValidateResult"]] + self, group_id: str, deployment_name: str, parameters: Union[_models.ScopedDeployment, IO], **kwargs: Any + ) -> Optional[_models.DeploymentValidateResult]: error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', "2021-01-01") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-01-01")) # type: str + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[Optional[_models.DeploymentValidateResult]] - _json = self._serialize.body(parameters, 'ScopedDeployment') + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(parameters, (IO, bytes)): + _content = parameters + else: + _json = self._serialize.body(parameters, "ScopedDeployment") - request = build_deployments_validate_at_management_group_scope_request_initial( + request = build_deployments_validate_at_management_group_scope_request( group_id=group_id, deployment_name=deployment_name, api_version=api_version, content_type=content_type, json=_json, - template_url=self._validate_at_management_group_scope_initial.metadata['url'], + content=_content, + template_url=self._validate_at_management_group_scope_initial.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200, 202, 400]: @@ -5542,36 +5498,40 @@ def _validate_at_management_group_scope_initial( deserialized = None if response.status_code == 200: - deserialized = self._deserialize('DeploymentValidateResult', pipeline_response) + deserialized = self._deserialize("DeploymentValidateResult", pipeline_response) if response.status_code == 400: - deserialized = self._deserialize('DeploymentValidateResult', pipeline_response) + deserialized = self._deserialize("DeploymentValidateResult", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - _validate_at_management_group_scope_initial.metadata = {'url': "/providers/Microsoft.Management/managementGroups/{groupId}/providers/Microsoft.Resources/deployments/{deploymentName}/validate"} # type: ignore - + _validate_at_management_group_scope_initial.metadata = {"url": "/providers/Microsoft.Management/managementGroups/{groupId}/providers/Microsoft.Resources/deployments/{deploymentName}/validate"} # type: ignore - @distributed_trace + @overload def begin_validate_at_management_group_scope( self, group_id: str, deployment_name: str, - parameters: "_models.ScopedDeployment", + parameters: _models.ScopedDeployment, + *, + content_type: str = "application/json", **kwargs: Any - ) -> LROPoller["_models.DeploymentValidateResult"]: + ) -> LROPoller[_models.DeploymentValidateResult]: """Validates whether the specified template is syntactically correct and will be accepted by Azure Resource Manager.. - :param group_id: The management group ID. + :param group_id: The management group ID. Required. :type group_id: str - :param deployment_name: The name of the deployment. + :param deployment_name: The name of the deployment. Required. :type deployment_name: str - :param parameters: Parameters to validate. + :param parameters: Parameters to validate. Required. :type parameters: ~azure.mgmt.resource.resources.v2021_01_01.models.ScopedDeployment + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str :keyword callable cls: A custom type or function that will be passed the direct response :keyword str continuation_token: A continuation token to restart a poller from a saved state. :keyword polling: By default, your polling method will be ARMPolling. Pass in False for this @@ -5584,85 +5544,166 @@ def begin_validate_at_management_group_scope( cls(response) :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.resource.resources.v2021_01_01.models.DeploymentValidateResult] - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - api_version = kwargs.pop('api_version', "2021-01-01") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] - polling = kwargs.pop('polling', True) # type: Union[bool, PollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType["_models.DeploymentValidateResult"] - lro_delay = kwargs.pop( - 'polling_interval', - self._config.polling_interval - ) - cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] + + @overload + def begin_validate_at_management_group_scope( + self, + group_id: str, + deployment_name: str, + parameters: IO, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> LROPoller[_models.DeploymentValidateResult]: + """Validates whether the specified template is syntactically correct and will be accepted by Azure + Resource Manager.. + + :param group_id: The management group ID. Required. + :type group_id: str + :param deployment_name: The name of the deployment. Required. + :type deployment_name: str + :param parameters: Parameters to validate. Required. + :type parameters: IO + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be ARMPolling. Pass in False for this + operation to not poll, or pass in your own initialized polling object for a personal polling + strategy. + :paramtype polling: bool or ~azure.core.polling.PollingMethod + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of LROPoller that returns either DeploymentValidateResult or the result of + cls(response) + :rtype: + ~azure.core.polling.LROPoller[~azure.mgmt.resource.resources.v2021_01_01.models.DeploymentValidateResult] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace + def begin_validate_at_management_group_scope( + self, group_id: str, deployment_name: str, parameters: Union[_models.ScopedDeployment, IO], **kwargs: Any + ) -> LROPoller[_models.DeploymentValidateResult]: + """Validates whether the specified template is syntactically correct and will be accepted by Azure + Resource Manager.. + + :param group_id: The management group ID. Required. + :type group_id: str + :param deployment_name: The name of the deployment. Required. + :type deployment_name: str + :param parameters: Parameters to validate. Is either a model type or a IO type. Required. + :type parameters: ~azure.mgmt.resource.resources.v2021_01_01.models.ScopedDeployment or IO + :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. + Default value is None. + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be ARMPolling. Pass in False for this + operation to not poll, or pass in your own initialized polling object for a personal polling + strategy. + :paramtype polling: bool or ~azure.core.polling.PollingMethod + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of LROPoller that returns either DeploymentValidateResult or the result of + cls(response) + :rtype: + ~azure.core.polling.LROPoller[~azure.mgmt.resource.resources.v2021_01_01.models.DeploymentValidateResult] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _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-01-01")) # type: str + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.DeploymentValidateResult] + polling = kwargs.pop("polling", True) # type: Union[bool, PollingMethod] + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token = kwargs.pop("continuation_token", None) # type: Optional[str] if cont_token is None: - raw_result = self._validate_at_management_group_scope_initial( + raw_result = self._validate_at_management_group_scope_initial( # type: ignore group_id=group_id, deployment_name=deployment_name, parameters=parameters, api_version=api_version, content_type=content_type, - cls=lambda x,y,z: x, + cls=lambda x, y, z: x, + headers=_headers, + params=_params, **kwargs ) - kwargs.pop('error_map', None) + kwargs.pop("error_map", None) def get_long_running_output(pipeline_response): - response = pipeline_response.http_response - deserialized = self._deserialize('DeploymentValidateResult', pipeline_response) + deserialized = self._deserialize("DeploymentValidateResult", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - - if polling is True: polling_method = ARMPolling(lro_delay, **kwargs) - elif polling is False: polling_method = NoPolling() - else: polling_method = polling + if polling is True: + polling_method = cast(PollingMethod, ARMPolling(lro_delay, **kwargs)) # type: PollingMethod + elif polling is False: + polling_method = cast(PollingMethod, NoPolling()) + else: + polling_method = polling if cont_token: return LROPoller.from_continuation_token( polling_method=polling_method, continuation_token=cont_token, client=self._client, - deserialization_callback=get_long_running_output + deserialization_callback=get_long_running_output, ) return LROPoller(self._client, raw_result, get_long_running_output, polling_method) - begin_validate_at_management_group_scope.metadata = {'url': "/providers/Microsoft.Management/managementGroups/{groupId}/providers/Microsoft.Resources/deployments/{deploymentName}/validate"} # type: ignore + begin_validate_at_management_group_scope.metadata = {"url": "/providers/Microsoft.Management/managementGroups/{groupId}/providers/Microsoft.Resources/deployments/{deploymentName}/validate"} # type: ignore def _what_if_at_management_group_scope_initial( - self, - group_id: str, - deployment_name: str, - parameters: "_models.ScopedDeploymentWhatIf", - **kwargs: Any - ) -> Optional["_models.WhatIfOperationResult"]: - cls = kwargs.pop('cls', None) # type: ClsType[Optional["_models.WhatIfOperationResult"]] + self, group_id: str, deployment_name: str, parameters: Union[_models.ScopedDeploymentWhatIf, IO], **kwargs: Any + ) -> Optional[_models.WhatIfOperationResult]: error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) - api_version = kwargs.pop('api_version', "2021-01-01") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - _json = self._serialize.body(parameters, 'ScopedDeploymentWhatIf') + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-01-01")) # type: str + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[Optional[_models.WhatIfOperationResult]] - request = build_deployments_what_if_at_management_group_scope_request_initial( + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(parameters, (IO, bytes)): + _content = parameters + else: + _json = self._serialize.body(parameters, "ScopedDeploymentWhatIf") + + request = build_deployments_what_if_at_management_group_scope_request( group_id=group_id, deployment_name=deployment_name, api_version=api_version, content_type=content_type, json=_json, - template_url=self._what_if_at_management_group_scope_initial.metadata['url'], + content=_content, + template_url=self._what_if_at_management_group_scope_initial.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200, 202]: @@ -5672,38 +5713,41 @@ def _what_if_at_management_group_scope_initial( deserialized = None response_headers = {} if response.status_code == 200: - deserialized = self._deserialize('WhatIfOperationResult', pipeline_response) + deserialized = self._deserialize("WhatIfOperationResult", pipeline_response) if response.status_code == 202: - response_headers['Location']=self._deserialize('str', response.headers.get('Location')) - response_headers['Retry-After']=self._deserialize('str', response.headers.get('Retry-After')) - + response_headers["Location"] = self._deserialize("str", response.headers.get("Location")) + response_headers["Retry-After"] = self._deserialize("str", response.headers.get("Retry-After")) if cls: return cls(pipeline_response, deserialized, response_headers) return deserialized - _what_if_at_management_group_scope_initial.metadata = {'url': "/providers/Microsoft.Management/managementGroups/{groupId}/providers/Microsoft.Resources/deployments/{deploymentName}/whatIf"} # type: ignore + _what_if_at_management_group_scope_initial.metadata = {"url": "/providers/Microsoft.Management/managementGroups/{groupId}/providers/Microsoft.Resources/deployments/{deploymentName}/whatIf"} # type: ignore - - @distributed_trace + @overload def begin_what_if_at_management_group_scope( self, group_id: str, deployment_name: str, - parameters: "_models.ScopedDeploymentWhatIf", + parameters: _models.ScopedDeploymentWhatIf, + *, + content_type: str = "application/json", **kwargs: Any - ) -> LROPoller["_models.WhatIfOperationResult"]: + ) -> LROPoller[_models.WhatIfOperationResult]: """Returns changes that will be made by the deployment if executed at the scope of the management group. - :param group_id: The management group ID. + :param group_id: The management group ID. Required. :type group_id: str - :param deployment_name: The name of the deployment. + :param deployment_name: The name of the deployment. Required. :type deployment_name: str - :param parameters: Parameters to validate. + :param parameters: Parameters to validate. Required. :type parameters: ~azure.mgmt.resource.resources.v2021_01_01.models.ScopedDeploymentWhatIf + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str :keyword callable cls: A custom type or function that will be passed the direct response :keyword str continuation_token: A continuation token to restart a poller from a saved state. :keyword polling: By default, your polling method will be ARMPolling. Pass in False for this @@ -5716,119 +5760,191 @@ def begin_what_if_at_management_group_scope( cls(response) :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.resource.resources.v2021_01_01.models.WhatIfOperationResult] - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - api_version = kwargs.pop('api_version', "2021-01-01") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] - polling = kwargs.pop('polling', True) # type: Union[bool, PollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType["_models.WhatIfOperationResult"] - lro_delay = kwargs.pop( - 'polling_interval', - self._config.polling_interval - ) - cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] + + @overload + def begin_what_if_at_management_group_scope( + self, + group_id: str, + deployment_name: str, + parameters: IO, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> LROPoller[_models.WhatIfOperationResult]: + """Returns changes that will be made by the deployment if executed at the scope of the management + group. + + :param group_id: The management group ID. Required. + :type group_id: str + :param deployment_name: The name of the deployment. Required. + :type deployment_name: str + :param parameters: Parameters to validate. Required. + :type parameters: IO + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be ARMPolling. Pass in False for this + operation to not poll, or pass in your own initialized polling object for a personal polling + strategy. + :paramtype polling: bool or ~azure.core.polling.PollingMethod + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of LROPoller that returns either WhatIfOperationResult or the result of + cls(response) + :rtype: + ~azure.core.polling.LROPoller[~azure.mgmt.resource.resources.v2021_01_01.models.WhatIfOperationResult] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace + def begin_what_if_at_management_group_scope( + self, group_id: str, deployment_name: str, parameters: Union[_models.ScopedDeploymentWhatIf, IO], **kwargs: Any + ) -> LROPoller[_models.WhatIfOperationResult]: + """Returns changes that will be made by the deployment if executed at the scope of the management + group. + + :param group_id: The management group ID. Required. + :type group_id: str + :param deployment_name: The name of the deployment. Required. + :type deployment_name: str + :param parameters: Parameters to validate. Is either a model type or a IO type. Required. + :type parameters: ~azure.mgmt.resource.resources.v2021_01_01.models.ScopedDeploymentWhatIf or + IO + :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. + Default value is None. + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be ARMPolling. Pass in False for this + operation to not poll, or pass in your own initialized polling object for a personal polling + strategy. + :paramtype polling: bool or ~azure.core.polling.PollingMethod + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of LROPoller that returns either WhatIfOperationResult or the result of + cls(response) + :rtype: + ~azure.core.polling.LROPoller[~azure.mgmt.resource.resources.v2021_01_01.models.WhatIfOperationResult] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _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-01-01")) # type: str + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.WhatIfOperationResult] + polling = kwargs.pop("polling", True) # type: Union[bool, PollingMethod] + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token = kwargs.pop("continuation_token", None) # type: Optional[str] if cont_token is None: - raw_result = self._what_if_at_management_group_scope_initial( + raw_result = self._what_if_at_management_group_scope_initial( # type: ignore group_id=group_id, deployment_name=deployment_name, parameters=parameters, api_version=api_version, content_type=content_type, - cls=lambda x,y,z: x, + cls=lambda x, y, z: x, + headers=_headers, + params=_params, **kwargs ) - kwargs.pop('error_map', None) + kwargs.pop("error_map", None) def get_long_running_output(pipeline_response): - response = pipeline_response.http_response - deserialized = self._deserialize('WhatIfOperationResult', pipeline_response) + deserialized = self._deserialize("WhatIfOperationResult", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - - if polling is True: polling_method = ARMPolling(lro_delay, lro_options={'final-state-via': 'location'}, **kwargs) - elif polling is False: polling_method = NoPolling() - else: polling_method = polling + if polling is True: + polling_method = cast( + PollingMethod, ARMPolling(lro_delay, lro_options={"final-state-via": "location"}, **kwargs) + ) # type: PollingMethod + elif polling is False: + polling_method = cast(PollingMethod, NoPolling()) + else: + polling_method = polling if cont_token: return LROPoller.from_continuation_token( polling_method=polling_method, continuation_token=cont_token, client=self._client, - deserialization_callback=get_long_running_output + deserialization_callback=get_long_running_output, ) return LROPoller(self._client, raw_result, get_long_running_output, polling_method) - begin_what_if_at_management_group_scope.metadata = {'url': "/providers/Microsoft.Management/managementGroups/{groupId}/providers/Microsoft.Resources/deployments/{deploymentName}/whatIf"} # type: ignore + begin_what_if_at_management_group_scope.metadata = {"url": "/providers/Microsoft.Management/managementGroups/{groupId}/providers/Microsoft.Resources/deployments/{deploymentName}/whatIf"} # type: ignore @distributed_trace def export_template_at_management_group_scope( - self, - group_id: str, - deployment_name: str, - **kwargs: Any - ) -> "_models.DeploymentExportResult": + self, group_id: str, deployment_name: str, **kwargs: Any + ) -> _models.DeploymentExportResult: """Exports the template used for specified deployment. - :param group_id: The management group ID. + :param group_id: The management group ID. Required. :type group_id: str - :param deployment_name: The name of the deployment. + :param deployment_name: The name of the deployment. Required. :type deployment_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: DeploymentExportResult, or the result of cls(response) + :return: DeploymentExportResult or the result of cls(response) :rtype: ~azure.mgmt.resource.resources.v2021_01_01.models.DeploymentExportResult - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.DeploymentExportResult"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + 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', "2021-01-01") # type: str + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-01-01")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[_models.DeploymentExportResult] - request = build_deployments_export_template_at_management_group_scope_request( group_id=group_id, deployment_name=deployment_name, api_version=api_version, - template_url=self.export_template_at_management_group_scope.metadata['url'], + template_url=self.export_template_at_management_group_scope.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) - deserialized = self._deserialize('DeploymentExportResult', pipeline_response) + deserialized = self._deserialize("DeploymentExportResult", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - export_template_at_management_group_scope.metadata = {'url': "/providers/Microsoft.Management/managementGroups/{groupId}/providers/Microsoft.Resources/deployments/{deploymentName}/exportTemplate"} # type: ignore - + export_template_at_management_group_scope.metadata = {"url": "/providers/Microsoft.Management/managementGroups/{groupId}/providers/Microsoft.Resources/deployments/{deploymentName}/exportTemplate"} # type: ignore @distributed_trace def list_at_management_group_scope( - self, - group_id: str, - filter: Optional[str] = None, - top: Optional[int] = None, - **kwargs: Any - ) -> Iterable["_models.DeploymentListResult"]: + self, group_id: str, filter: Optional[str] = None, top: Optional[int] = None, **kwargs: Any + ) -> Iterable["_models.DeploymentExtended"]: """Get all the deployments for a management group. - :param group_id: The management group ID. + :param group_id: The management group ID. Required. :type group_id: str :param filter: The filter to apply on the operation. For example, you can use $filter=provisioningState eq '{state}'. Default value is None. @@ -5837,40 +5953,48 @@ def list_at_management_group_scope( value is None. :type top: int :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either DeploymentListResult or the result of - cls(response) + :return: An iterator like instance of either DeploymentExtended or the result of cls(response) :rtype: - ~azure.core.paging.ItemPaged[~azure.mgmt.resource.resources.v2021_01_01.models.DeploymentListResult] - :raises: ~azure.core.exceptions.HttpResponseError + ~azure.core.paging.ItemPaged[~azure.mgmt.resource.resources.v2021_01_01.models.DeploymentExtended] + :raises ~azure.core.exceptions.HttpResponseError: """ - api_version = kwargs.pop('api_version', "2021-01-01") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-01-01")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[_models.DeploymentListResult] - cls = kwargs.pop('cls', None) # type: ClsType["_models.DeploymentListResult"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) + def prepare_request(next_link=None): if not next_link: - + request = build_deployments_list_at_management_group_scope_request( group_id=group_id, - api_version=api_version, filter=filter, top=top, - template_url=self.list_at_management_group_scope.metadata['url'], + api_version=api_version, + template_url=self.list_at_management_group_scope.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore else: - - request = build_deployments_list_at_management_group_scope_request( - group_id=group_id, - template_url=next_link, - ) + # make call to next link with the client's api-version + _parsed_next_link = urlparse(next_link) + _next_request_params = case_insensitive_dict(parse_qs(_parsed_next_link.query)) + _next_request_params["api-version"] = self._config.api_version + request = HttpRequest("GET", urljoin(next_link, _parsed_next_link.path), params=_next_request_params) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore request.method = "GET" return request @@ -5884,10 +6008,8 @@ def extract_data(pipeline_response): def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) response = pipeline_response.http_response @@ -5897,40 +6019,42 @@ def get_next(next_link=None): return pipeline_response + return ItemPaged(get_next, extract_data) - return ItemPaged( - get_next, extract_data - ) - list_at_management_group_scope.metadata = {'url': "/providers/Microsoft.Management/managementGroups/{groupId}/providers/Microsoft.Resources/deployments/"} # type: ignore + list_at_management_group_scope.metadata = {"url": "/providers/Microsoft.Management/managementGroups/{groupId}/providers/Microsoft.Resources/deployments/"} # type: ignore def _delete_at_subscription_scope_initial( # pylint: disable=inconsistent-return-statements - self, - deployment_name: str, - **kwargs: Any + self, deployment_name: str, **kwargs: Any ) -> None: - cls = kwargs.pop('cls', None) # type: ClsType[None] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + 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', "2021-01-01") # type: str + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-01-01")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[None] - - request = build_deployments_delete_at_subscription_scope_request_initial( + request = build_deployments_delete_at_subscription_scope_request( deployment_name=deployment_name, subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self._delete_at_subscription_scope_initial.metadata['url'], + template_url=self._delete_at_subscription_scope_initial.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [202, 204]: @@ -5940,15 +6064,10 @@ def _delete_at_subscription_scope_initial( # pylint: disable=inconsistent-retur if cls: return cls(pipeline_response, None, {}) - _delete_at_subscription_scope_initial.metadata = {'url': "/subscriptions/{subscriptionId}/providers/Microsoft.Resources/deployments/{deploymentName}"} # type: ignore - + _delete_at_subscription_scope_initial.metadata = {"url": "/subscriptions/{subscriptionId}/providers/Microsoft.Resources/deployments/{deploymentName}"} # type: ignore @distributed_trace - def begin_delete_at_subscription_scope( # pylint: disable=inconsistent-return-statements - self, - deployment_name: str, - **kwargs: Any - ) -> LROPoller[None]: + def begin_delete_at_subscription_scope(self, deployment_name: str, **kwargs: Any) -> LROPoller[None]: """Deletes a deployment from the deployment history. A template deployment that is currently running cannot be deleted. Deleting a template @@ -5959,7 +6078,7 @@ def begin_delete_at_subscription_scope( # pylint: disable=inconsistent-return-s process finishes, the URI in the Location header returns a status of 204 on success. If the asynchronous request failed, the URI in the Location header returns an error-level status code. - :param deployment_name: The name of the deployment. + :param deployment_name: The name of the deployment. Required. :type deployment_name: str :keyword callable cls: A custom type or function that will be passed the direct response :keyword str continuation_token: A continuation token to restart a poller from a saved state. @@ -5971,82 +6090,88 @@ def begin_delete_at_subscription_scope( # pylint: disable=inconsistent-return-s Retry-After header is present. :return: An instance of LROPoller that returns either None or the result of cls(response) :rtype: ~azure.core.polling.LROPoller[None] - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - api_version = kwargs.pop('api_version', "2021-01-01") # type: str - polling = kwargs.pop('polling', True) # type: Union[bool, PollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType[None] - lro_delay = kwargs.pop( - 'polling_interval', - self._config.polling_interval - ) - cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-01-01")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[None] + polling = kwargs.pop("polling", True) # type: Union[bool, PollingMethod] + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token = kwargs.pop("continuation_token", None) # type: Optional[str] if cont_token is None: - raw_result = self._delete_at_subscription_scope_initial( + raw_result = self._delete_at_subscription_scope_initial( # type: ignore deployment_name=deployment_name, api_version=api_version, - cls=lambda x,y,z: x, + cls=lambda x, y, z: x, + headers=_headers, + params=_params, **kwargs ) - kwargs.pop('error_map', None) + kwargs.pop("error_map", None) - def get_long_running_output(pipeline_response): + def get_long_running_output(pipeline_response): # pylint: disable=inconsistent-return-statements if cls: return cls(pipeline_response, None, {}) - - if polling is True: polling_method = ARMPolling(lro_delay, **kwargs) - elif polling is False: polling_method = NoPolling() - else: polling_method = polling + if polling is True: + polling_method = cast(PollingMethod, ARMPolling(lro_delay, **kwargs)) # type: PollingMethod + elif polling is False: + polling_method = cast(PollingMethod, NoPolling()) + else: + polling_method = polling if cont_token: return LROPoller.from_continuation_token( polling_method=polling_method, continuation_token=cont_token, client=self._client, - deserialization_callback=get_long_running_output + deserialization_callback=get_long_running_output, ) return LROPoller(self._client, raw_result, get_long_running_output, polling_method) - begin_delete_at_subscription_scope.metadata = {'url': "/subscriptions/{subscriptionId}/providers/Microsoft.Resources/deployments/{deploymentName}"} # type: ignore + begin_delete_at_subscription_scope.metadata = {"url": "/subscriptions/{subscriptionId}/providers/Microsoft.Resources/deployments/{deploymentName}"} # type: ignore @distributed_trace - def check_existence_at_subscription_scope( - self, - deployment_name: str, - **kwargs: Any - ) -> bool: + def check_existence_at_subscription_scope(self, deployment_name: str, **kwargs: Any) -> bool: """Checks whether the deployment exists. - :param deployment_name: The name of the deployment. + :param deployment_name: The name of the deployment. Required. :type deployment_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: bool, or the result of cls(response) + :return: bool or the result of cls(response) :rtype: bool - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType[None] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + 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', "2021-01-01") # type: str + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-01-01")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[None] - request = build_deployments_check_existence_at_subscription_scope_request( deployment_name=deployment_name, subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.check_existence_at_subscription_scope.metadata['url'], + template_url=self.check_existence_at_subscription_scope.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [204, 404]: @@ -6057,42 +6182,52 @@ def check_existence_at_subscription_scope( return cls(pipeline_response, None, {}) return 200 <= response.status_code <= 299 - check_existence_at_subscription_scope.metadata = {'url': "/subscriptions/{subscriptionId}/providers/Microsoft.Resources/deployments/{deploymentName}"} # type: ignore - + check_existence_at_subscription_scope.metadata = {"url": "/subscriptions/{subscriptionId}/providers/Microsoft.Resources/deployments/{deploymentName}"} # type: ignore def _create_or_update_at_subscription_scope_initial( - self, - deployment_name: str, - parameters: "_models.Deployment", - **kwargs: Any - ) -> "_models.DeploymentExtended": - cls = kwargs.pop('cls', None) # type: ClsType["_models.DeploymentExtended"] + self, deployment_name: str, parameters: Union[_models.Deployment, IO], **kwargs: Any + ) -> _models.DeploymentExtended: error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', "2021-01-01") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-01-01")) # type: str + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.DeploymentExtended] - _json = self._serialize.body(parameters, 'Deployment') + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(parameters, (IO, bytes)): + _content = parameters + else: + _json = self._serialize.body(parameters, "Deployment") - request = build_deployments_create_or_update_at_subscription_scope_request_initial( + request = build_deployments_create_or_update_at_subscription_scope_request( deployment_name=deployment_name, subscription_id=self._config.subscription_id, api_version=api_version, content_type=content_type, json=_json, - template_url=self._create_or_update_at_subscription_scope_initial.metadata['url'], + content=_content, + template_url=self._create_or_update_at_subscription_scope_initial.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200, 201]: @@ -6100,34 +6235,38 @@ def _create_or_update_at_subscription_scope_initial( raise HttpResponseError(response=response, error_format=ARMErrorFormat) if response.status_code == 200: - deserialized = self._deserialize('DeploymentExtended', pipeline_response) + deserialized = self._deserialize("DeploymentExtended", pipeline_response) if response.status_code == 201: - deserialized = self._deserialize('DeploymentExtended', pipeline_response) + deserialized = self._deserialize("DeploymentExtended", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - _create_or_update_at_subscription_scope_initial.metadata = {'url': "/subscriptions/{subscriptionId}/providers/Microsoft.Resources/deployments/{deploymentName}"} # type: ignore - + _create_or_update_at_subscription_scope_initial.metadata = {"url": "/subscriptions/{subscriptionId}/providers/Microsoft.Resources/deployments/{deploymentName}"} # type: ignore - @distributed_trace + @overload def begin_create_or_update_at_subscription_scope( self, deployment_name: str, - parameters: "_models.Deployment", + parameters: _models.Deployment, + *, + content_type: str = "application/json", **kwargs: Any - ) -> LROPoller["_models.DeploymentExtended"]: + ) -> LROPoller[_models.DeploymentExtended]: """Deploys resources at subscription scope. You can provide the template and parameters directly in the request or link to JSON files. - :param deployment_name: The name of the deployment. + :param deployment_name: The name of the deployment. Required. :type deployment_name: str - :param parameters: Additional parameters supplied to the operation. + :param parameters: Additional parameters supplied to the operation. Required. :type parameters: ~azure.mgmt.resource.resources.v2021_01_01.models.Deployment + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str :keyword callable cls: A custom type or function that will be passed the direct response :keyword str continuation_token: A continuation token to restart a poller from a saved state. :keyword polling: By default, your polling method will be ARMPolling. Pass in False for this @@ -6140,109 +6279,172 @@ def begin_create_or_update_at_subscription_scope( cls(response) :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.resource.resources.v2021_01_01.models.DeploymentExtended] - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - api_version = kwargs.pop('api_version', "2021-01-01") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] - polling = kwargs.pop('polling', True) # type: Union[bool, PollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType["_models.DeploymentExtended"] - lro_delay = kwargs.pop( - 'polling_interval', - self._config.polling_interval - ) - cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] - if cont_token is None: - raw_result = self._create_or_update_at_subscription_scope_initial( - deployment_name=deployment_name, - parameters=parameters, - api_version=api_version, - content_type=content_type, - cls=lambda x,y,z: x, - **kwargs - ) - kwargs.pop('error_map', None) - def get_long_running_output(pipeline_response): - response = pipeline_response.http_response - deserialized = self._deserialize('DeploymentExtended', pipeline_response) + @overload + def begin_create_or_update_at_subscription_scope( + self, deployment_name: str, parameters: IO, *, content_type: str = "application/json", **kwargs: Any + ) -> LROPoller[_models.DeploymentExtended]: + """Deploys resources at subscription scope. + + You can provide the template and parameters directly in the request or link to JSON files. + + :param deployment_name: The name of the deployment. Required. + :type deployment_name: str + :param parameters: Additional parameters supplied to the operation. Required. + :type parameters: IO + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be ARMPolling. Pass in False for this + operation to not poll, or pass in your own initialized polling object for a personal polling + strategy. + :paramtype polling: bool or ~azure.core.polling.PollingMethod + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of LROPoller that returns either DeploymentExtended or the result of + cls(response) + :rtype: + ~azure.core.polling.LROPoller[~azure.mgmt.resource.resources.v2021_01_01.models.DeploymentExtended] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace + def begin_create_or_update_at_subscription_scope( + self, deployment_name: str, parameters: Union[_models.Deployment, IO], **kwargs: Any + ) -> LROPoller[_models.DeploymentExtended]: + """Deploys resources at subscription scope. + + You can provide the template and parameters directly in the request or link to JSON files. + + :param deployment_name: The name of the deployment. Required. + :type deployment_name: str + :param parameters: Additional parameters supplied to the operation. Is either a model type or a + IO type. Required. + :type parameters: ~azure.mgmt.resource.resources.v2021_01_01.models.Deployment or IO + :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. + Default value is None. + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be ARMPolling. Pass in False for this + operation to not poll, or pass in your own initialized polling object for a personal polling + strategy. + :paramtype polling: bool or ~azure.core.polling.PollingMethod + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of LROPoller that returns either DeploymentExtended or the result of + cls(response) + :rtype: + ~azure.core.polling.LROPoller[~azure.mgmt.resource.resources.v2021_01_01.models.DeploymentExtended] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _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-01-01")) # type: str + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.DeploymentExtended] + polling = kwargs.pop("polling", True) # type: Union[bool, PollingMethod] + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token = kwargs.pop("continuation_token", None) # type: Optional[str] + if cont_token is None: + raw_result = self._create_or_update_at_subscription_scope_initial( # type: ignore + deployment_name=deployment_name, + parameters=parameters, + api_version=api_version, + content_type=content_type, + cls=lambda x, y, z: x, + headers=_headers, + params=_params, + **kwargs + ) + kwargs.pop("error_map", None) + + def get_long_running_output(pipeline_response): + deserialized = self._deserialize("DeploymentExtended", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - - if polling is True: polling_method = ARMPolling(lro_delay, **kwargs) - elif polling is False: polling_method = NoPolling() - else: polling_method = polling + if polling is True: + polling_method = cast(PollingMethod, ARMPolling(lro_delay, **kwargs)) # type: PollingMethod + elif polling is False: + polling_method = cast(PollingMethod, NoPolling()) + else: + polling_method = polling if cont_token: return LROPoller.from_continuation_token( polling_method=polling_method, continuation_token=cont_token, client=self._client, - deserialization_callback=get_long_running_output + deserialization_callback=get_long_running_output, ) return LROPoller(self._client, raw_result, get_long_running_output, polling_method) - begin_create_or_update_at_subscription_scope.metadata = {'url': "/subscriptions/{subscriptionId}/providers/Microsoft.Resources/deployments/{deploymentName}"} # type: ignore + begin_create_or_update_at_subscription_scope.metadata = {"url": "/subscriptions/{subscriptionId}/providers/Microsoft.Resources/deployments/{deploymentName}"} # type: ignore @distributed_trace - def get_at_subscription_scope( - self, - deployment_name: str, - **kwargs: Any - ) -> "_models.DeploymentExtended": + def get_at_subscription_scope(self, deployment_name: str, **kwargs: Any) -> _models.DeploymentExtended: """Gets a deployment. - :param deployment_name: The name of the deployment. + :param deployment_name: The name of the deployment. Required. :type deployment_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: DeploymentExtended, or the result of cls(response) + :return: DeploymentExtended or the result of cls(response) :rtype: ~azure.mgmt.resource.resources.v2021_01_01.models.DeploymentExtended - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.DeploymentExtended"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) - api_version = kwargs.pop('api_version', "2021-01-01") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-01-01")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[_models.DeploymentExtended] - request = build_deployments_get_at_subscription_scope_request( deployment_name=deployment_name, subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.get_at_subscription_scope.metadata['url'], + template_url=self.get_at_subscription_scope.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) - deserialized = self._deserialize('DeploymentExtended', pipeline_response) + deserialized = self._deserialize("DeploymentExtended", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - get_at_subscription_scope.metadata = {'url': "/subscriptions/{subscriptionId}/providers/Microsoft.Resources/deployments/{deploymentName}"} # type: ignore - + get_at_subscription_scope.metadata = {"url": "/subscriptions/{subscriptionId}/providers/Microsoft.Resources/deployments/{deploymentName}"} # type: ignore @distributed_trace def cancel_at_subscription_scope( # pylint: disable=inconsistent-return-statements - self, - deployment_name: str, - **kwargs: Any + self, deployment_name: str, **kwargs: Any ) -> None: """Cancels a currently running template deployment. @@ -6251,36 +6453,42 @@ def cancel_at_subscription_scope( # pylint: disable=inconsistent-return-stateme deployment stops the currently running template deployment and leaves the resources partially deployed. - :param deployment_name: The name of the deployment. + :param deployment_name: The name of the deployment. Required. :type deployment_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: None, or the result of cls(response) + :return: None or the result of cls(response) :rtype: None - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType[None] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) - api_version = kwargs.pop('api_version', "2021-01-01") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-01-01")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[None] - request = build_deployments_cancel_at_subscription_scope_request( deployment_name=deployment_name, subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.cancel_at_subscription_scope.metadata['url'], + template_url=self.cancel_at_subscription_scope.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [204]: @@ -6290,42 +6498,52 @@ def cancel_at_subscription_scope( # pylint: disable=inconsistent-return-stateme if cls: return cls(pipeline_response, None, {}) - cancel_at_subscription_scope.metadata = {'url': "/subscriptions/{subscriptionId}/providers/Microsoft.Resources/deployments/{deploymentName}/cancel"} # type: ignore - + cancel_at_subscription_scope.metadata = {"url": "/subscriptions/{subscriptionId}/providers/Microsoft.Resources/deployments/{deploymentName}/cancel"} # type: ignore def _validate_at_subscription_scope_initial( - self, - deployment_name: str, - parameters: "_models.Deployment", - **kwargs: Any - ) -> Optional["_models.DeploymentValidateResult"]: - cls = kwargs.pop('cls', None) # type: ClsType[Optional["_models.DeploymentValidateResult"]] + self, deployment_name: str, parameters: Union[_models.Deployment, IO], **kwargs: Any + ) -> Optional[_models.DeploymentValidateResult]: error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) - api_version = kwargs.pop('api_version', "2021-01-01") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - _json = self._serialize.body(parameters, 'Deployment') + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-01-01")) # type: str + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[Optional[_models.DeploymentValidateResult]] - request = build_deployments_validate_at_subscription_scope_request_initial( + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(parameters, (IO, bytes)): + _content = parameters + else: + _json = self._serialize.body(parameters, "Deployment") + + request = build_deployments_validate_at_subscription_scope_request( deployment_name=deployment_name, subscription_id=self._config.subscription_id, api_version=api_version, content_type=content_type, json=_json, - template_url=self._validate_at_subscription_scope_initial.metadata['url'], + content=_content, + template_url=self._validate_at_subscription_scope_initial.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200, 202, 400]: @@ -6334,33 +6552,37 @@ def _validate_at_subscription_scope_initial( deserialized = None if response.status_code == 200: - deserialized = self._deserialize('DeploymentValidateResult', pipeline_response) + deserialized = self._deserialize("DeploymentValidateResult", pipeline_response) if response.status_code == 400: - deserialized = self._deserialize('DeploymentValidateResult', pipeline_response) + deserialized = self._deserialize("DeploymentValidateResult", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - _validate_at_subscription_scope_initial.metadata = {'url': "/subscriptions/{subscriptionId}/providers/Microsoft.Resources/deployments/{deploymentName}/validate"} # type: ignore + _validate_at_subscription_scope_initial.metadata = {"url": "/subscriptions/{subscriptionId}/providers/Microsoft.Resources/deployments/{deploymentName}/validate"} # type: ignore - - @distributed_trace + @overload def begin_validate_at_subscription_scope( self, deployment_name: str, - parameters: "_models.Deployment", + parameters: _models.Deployment, + *, + content_type: str = "application/json", **kwargs: Any - ) -> LROPoller["_models.DeploymentValidateResult"]: + ) -> LROPoller[_models.DeploymentValidateResult]: """Validates whether the specified template is syntactically correct and will be accepted by Azure Resource Manager.. - :param deployment_name: The name of the deployment. + :param deployment_name: The name of the deployment. Required. :type deployment_name: str - :param parameters: Parameters to validate. + :param parameters: Parameters to validate. Required. :type parameters: ~azure.mgmt.resource.resources.v2021_01_01.models.Deployment + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str :keyword callable cls: A custom type or function that will be passed the direct response :keyword str continuation_token: A continuation token to restart a poller from a saved state. :keyword polling: By default, your polling method will be ARMPolling. Pass in False for this @@ -6373,83 +6595,155 @@ def begin_validate_at_subscription_scope( cls(response) :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.resource.resources.v2021_01_01.models.DeploymentValidateResult] - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - api_version = kwargs.pop('api_version', "2021-01-01") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] - polling = kwargs.pop('polling', True) # type: Union[bool, PollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType["_models.DeploymentValidateResult"] - lro_delay = kwargs.pop( - 'polling_interval', - self._config.polling_interval - ) - cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] + + @overload + def begin_validate_at_subscription_scope( + self, deployment_name: str, parameters: IO, *, content_type: str = "application/json", **kwargs: Any + ) -> LROPoller[_models.DeploymentValidateResult]: + """Validates whether the specified template is syntactically correct and will be accepted by Azure + Resource Manager.. + + :param deployment_name: The name of the deployment. Required. + :type deployment_name: str + :param parameters: Parameters to validate. Required. + :type parameters: IO + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be ARMPolling. Pass in False for this + operation to not poll, or pass in your own initialized polling object for a personal polling + strategy. + :paramtype polling: bool or ~azure.core.polling.PollingMethod + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of LROPoller that returns either DeploymentValidateResult or the result of + cls(response) + :rtype: + ~azure.core.polling.LROPoller[~azure.mgmt.resource.resources.v2021_01_01.models.DeploymentValidateResult] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace + def begin_validate_at_subscription_scope( + self, deployment_name: str, parameters: Union[_models.Deployment, IO], **kwargs: Any + ) -> LROPoller[_models.DeploymentValidateResult]: + """Validates whether the specified template is syntactically correct and will be accepted by Azure + Resource Manager.. + + :param deployment_name: The name of the deployment. Required. + :type deployment_name: str + :param parameters: Parameters to validate. Is either a model type or a IO type. Required. + :type parameters: ~azure.mgmt.resource.resources.v2021_01_01.models.Deployment or IO + :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. + Default value is None. + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be ARMPolling. Pass in False for this + operation to not poll, or pass in your own initialized polling object for a personal polling + strategy. + :paramtype polling: bool or ~azure.core.polling.PollingMethod + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of LROPoller that returns either DeploymentValidateResult or the result of + cls(response) + :rtype: + ~azure.core.polling.LROPoller[~azure.mgmt.resource.resources.v2021_01_01.models.DeploymentValidateResult] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _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-01-01")) # type: str + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.DeploymentValidateResult] + polling = kwargs.pop("polling", True) # type: Union[bool, PollingMethod] + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token = kwargs.pop("continuation_token", None) # type: Optional[str] if cont_token is None: - raw_result = self._validate_at_subscription_scope_initial( + raw_result = self._validate_at_subscription_scope_initial( # type: ignore deployment_name=deployment_name, parameters=parameters, api_version=api_version, content_type=content_type, - cls=lambda x,y,z: x, + cls=lambda x, y, z: x, + headers=_headers, + params=_params, **kwargs ) - kwargs.pop('error_map', None) + kwargs.pop("error_map", None) def get_long_running_output(pipeline_response): - response = pipeline_response.http_response - deserialized = self._deserialize('DeploymentValidateResult', pipeline_response) + deserialized = self._deserialize("DeploymentValidateResult", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - - if polling is True: polling_method = ARMPolling(lro_delay, **kwargs) - elif polling is False: polling_method = NoPolling() - else: polling_method = polling + if polling is True: + polling_method = cast(PollingMethod, ARMPolling(lro_delay, **kwargs)) # type: PollingMethod + elif polling is False: + polling_method = cast(PollingMethod, NoPolling()) + else: + polling_method = polling if cont_token: return LROPoller.from_continuation_token( polling_method=polling_method, continuation_token=cont_token, client=self._client, - deserialization_callback=get_long_running_output + deserialization_callback=get_long_running_output, ) return LROPoller(self._client, raw_result, get_long_running_output, polling_method) - begin_validate_at_subscription_scope.metadata = {'url': "/subscriptions/{subscriptionId}/providers/Microsoft.Resources/deployments/{deploymentName}/validate"} # type: ignore + begin_validate_at_subscription_scope.metadata = {"url": "/subscriptions/{subscriptionId}/providers/Microsoft.Resources/deployments/{deploymentName}/validate"} # type: ignore def _what_if_at_subscription_scope_initial( - self, - deployment_name: str, - parameters: "_models.DeploymentWhatIf", - **kwargs: Any - ) -> Optional["_models.WhatIfOperationResult"]: - cls = kwargs.pop('cls', None) # type: ClsType[Optional["_models.WhatIfOperationResult"]] + self, deployment_name: str, parameters: Union[_models.DeploymentWhatIf, IO], **kwargs: Any + ) -> Optional[_models.WhatIfOperationResult]: error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) - api_version = kwargs.pop('api_version', "2021-01-01") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - _json = self._serialize.body(parameters, 'DeploymentWhatIf') + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-01-01")) # type: str + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[Optional[_models.WhatIfOperationResult]] - request = build_deployments_what_if_at_subscription_scope_request_initial( + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(parameters, (IO, bytes)): + _content = parameters + else: + _json = self._serialize.body(parameters, "DeploymentWhatIf") + + request = build_deployments_what_if_at_subscription_scope_request( deployment_name=deployment_name, subscription_id=self._config.subscription_id, api_version=api_version, content_type=content_type, json=_json, - template_url=self._what_if_at_subscription_scope_initial.metadata['url'], + content=_content, + template_url=self._what_if_at_subscription_scope_initial.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200, 202]: @@ -6459,35 +6753,38 @@ def _what_if_at_subscription_scope_initial( deserialized = None response_headers = {} if response.status_code == 200: - deserialized = self._deserialize('WhatIfOperationResult', pipeline_response) + deserialized = self._deserialize("WhatIfOperationResult", pipeline_response) if response.status_code == 202: - response_headers['Location']=self._deserialize('str', response.headers.get('Location')) - response_headers['Retry-After']=self._deserialize('str', response.headers.get('Retry-After')) - + response_headers["Location"] = self._deserialize("str", response.headers.get("Location")) + response_headers["Retry-After"] = self._deserialize("str", response.headers.get("Retry-After")) if cls: return cls(pipeline_response, deserialized, response_headers) return deserialized - _what_if_at_subscription_scope_initial.metadata = {'url': "/subscriptions/{subscriptionId}/providers/Microsoft.Resources/deployments/{deploymentName}/whatIf"} # type: ignore + _what_if_at_subscription_scope_initial.metadata = {"url": "/subscriptions/{subscriptionId}/providers/Microsoft.Resources/deployments/{deploymentName}/whatIf"} # type: ignore - - @distributed_trace + @overload def begin_what_if_at_subscription_scope( self, deployment_name: str, - parameters: "_models.DeploymentWhatIf", + parameters: _models.DeploymentWhatIf, + *, + content_type: str = "application/json", **kwargs: Any - ) -> LROPoller["_models.WhatIfOperationResult"]: + ) -> LROPoller[_models.WhatIfOperationResult]: """Returns changes that will be made by the deployment if executed at the scope of the subscription. - :param deployment_name: The name of the deployment. + :param deployment_name: The name of the deployment. Required. :type deployment_name: str - :param parameters: Parameters to What If. + :param parameters: Parameters to What If. Required. :type parameters: ~azure.mgmt.resource.resources.v2021_01_01.models.DeploymentWhatIf + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str :keyword callable cls: A custom type or function that will be passed the direct response :keyword str continuation_token: A continuation token to restart a poller from a saved state. :keyword polling: By default, your polling method will be ARMPolling. Pass in False for this @@ -6500,111 +6797,174 @@ def begin_what_if_at_subscription_scope( cls(response) :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.resource.resources.v2021_01_01.models.WhatIfOperationResult] - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - api_version = kwargs.pop('api_version', "2021-01-01") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] - polling = kwargs.pop('polling', True) # type: Union[bool, PollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType["_models.WhatIfOperationResult"] - lro_delay = kwargs.pop( - 'polling_interval', - self._config.polling_interval - ) - cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] + + @overload + def begin_what_if_at_subscription_scope( + self, deployment_name: str, parameters: IO, *, content_type: str = "application/json", **kwargs: Any + ) -> LROPoller[_models.WhatIfOperationResult]: + """Returns changes that will be made by the deployment if executed at the scope of the + subscription. + + :param deployment_name: The name of the deployment. Required. + :type deployment_name: str + :param parameters: Parameters to What If. Required. + :type parameters: IO + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be ARMPolling. Pass in False for this + operation to not poll, or pass in your own initialized polling object for a personal polling + strategy. + :paramtype polling: bool or ~azure.core.polling.PollingMethod + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of LROPoller that returns either WhatIfOperationResult or the result of + cls(response) + :rtype: + ~azure.core.polling.LROPoller[~azure.mgmt.resource.resources.v2021_01_01.models.WhatIfOperationResult] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace + def begin_what_if_at_subscription_scope( + self, deployment_name: str, parameters: Union[_models.DeploymentWhatIf, IO], **kwargs: Any + ) -> LROPoller[_models.WhatIfOperationResult]: + """Returns changes that will be made by the deployment if executed at the scope of the + subscription. + + :param deployment_name: The name of the deployment. Required. + :type deployment_name: str + :param parameters: Parameters to What If. Is either a model type or a IO type. Required. + :type parameters: ~azure.mgmt.resource.resources.v2021_01_01.models.DeploymentWhatIf or IO + :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. + Default value is None. + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be ARMPolling. Pass in False for this + operation to not poll, or pass in your own initialized polling object for a personal polling + strategy. + :paramtype polling: bool or ~azure.core.polling.PollingMethod + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of LROPoller that returns either WhatIfOperationResult or the result of + cls(response) + :rtype: + ~azure.core.polling.LROPoller[~azure.mgmt.resource.resources.v2021_01_01.models.WhatIfOperationResult] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _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-01-01")) # type: str + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.WhatIfOperationResult] + polling = kwargs.pop("polling", True) # type: Union[bool, PollingMethod] + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token = kwargs.pop("continuation_token", None) # type: Optional[str] if cont_token is None: - raw_result = self._what_if_at_subscription_scope_initial( + raw_result = self._what_if_at_subscription_scope_initial( # type: ignore deployment_name=deployment_name, parameters=parameters, api_version=api_version, content_type=content_type, - cls=lambda x,y,z: x, + cls=lambda x, y, z: x, + headers=_headers, + params=_params, **kwargs ) - kwargs.pop('error_map', None) + kwargs.pop("error_map", None) def get_long_running_output(pipeline_response): - response = pipeline_response.http_response - deserialized = self._deserialize('WhatIfOperationResult', pipeline_response) + deserialized = self._deserialize("WhatIfOperationResult", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - - if polling is True: polling_method = ARMPolling(lro_delay, lro_options={'final-state-via': 'location'}, **kwargs) - elif polling is False: polling_method = NoPolling() - else: polling_method = polling + if polling is True: + polling_method = cast( + PollingMethod, ARMPolling(lro_delay, lro_options={"final-state-via": "location"}, **kwargs) + ) # type: PollingMethod + elif polling is False: + polling_method = cast(PollingMethod, NoPolling()) + else: + polling_method = polling if cont_token: return LROPoller.from_continuation_token( polling_method=polling_method, continuation_token=cont_token, client=self._client, - deserialization_callback=get_long_running_output + deserialization_callback=get_long_running_output, ) return LROPoller(self._client, raw_result, get_long_running_output, polling_method) - begin_what_if_at_subscription_scope.metadata = {'url': "/subscriptions/{subscriptionId}/providers/Microsoft.Resources/deployments/{deploymentName}/whatIf"} # type: ignore + begin_what_if_at_subscription_scope.metadata = {"url": "/subscriptions/{subscriptionId}/providers/Microsoft.Resources/deployments/{deploymentName}/whatIf"} # type: ignore @distributed_trace def export_template_at_subscription_scope( - self, - deployment_name: str, - **kwargs: Any - ) -> "_models.DeploymentExportResult": + self, deployment_name: str, **kwargs: Any + ) -> _models.DeploymentExportResult: """Exports the template used for specified deployment. - :param deployment_name: The name of the deployment. + :param deployment_name: The name of the deployment. Required. :type deployment_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: DeploymentExportResult, or the result of cls(response) + :return: DeploymentExportResult or the result of cls(response) :rtype: ~azure.mgmt.resource.resources.v2021_01_01.models.DeploymentExportResult - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.DeploymentExportResult"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) - api_version = kwargs.pop('api_version', "2021-01-01") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-01-01")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[_models.DeploymentExportResult] - request = build_deployments_export_template_at_subscription_scope_request( deployment_name=deployment_name, subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.export_template_at_subscription_scope.metadata['url'], + template_url=self.export_template_at_subscription_scope.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) - deserialized = self._deserialize('DeploymentExportResult', pipeline_response) + deserialized = self._deserialize("DeploymentExportResult", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - export_template_at_subscription_scope.metadata = {'url': "/subscriptions/{subscriptionId}/providers/Microsoft.Resources/deployments/{deploymentName}/exportTemplate"} # type: ignore - + export_template_at_subscription_scope.metadata = {"url": "/subscriptions/{subscriptionId}/providers/Microsoft.Resources/deployments/{deploymentName}/exportTemplate"} # type: ignore @distributed_trace def list_at_subscription_scope( - self, - filter: Optional[str] = None, - top: Optional[int] = None, - **kwargs: Any - ) -> Iterable["_models.DeploymentListResult"]: + self, filter: Optional[str] = None, top: Optional[int] = None, **kwargs: Any + ) -> Iterable["_models.DeploymentExtended"]: """Get all the deployments for a subscription. :param filter: The filter to apply on the operation. For example, you can use @@ -6614,40 +6974,48 @@ def list_at_subscription_scope( value is None. :type top: int :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either DeploymentListResult or the result of - cls(response) + :return: An iterator like instance of either DeploymentExtended or the result of cls(response) :rtype: - ~azure.core.paging.ItemPaged[~azure.mgmt.resource.resources.v2021_01_01.models.DeploymentListResult] - :raises: ~azure.core.exceptions.HttpResponseError + ~azure.core.paging.ItemPaged[~azure.mgmt.resource.resources.v2021_01_01.models.DeploymentExtended] + :raises ~azure.core.exceptions.HttpResponseError: """ - api_version = kwargs.pop('api_version', "2021-01-01") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-01-01")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[_models.DeploymentListResult] - cls = kwargs.pop('cls', None) # type: ClsType["_models.DeploymentListResult"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) + def prepare_request(next_link=None): if not next_link: - + request = build_deployments_list_at_subscription_scope_request( subscription_id=self._config.subscription_id, - api_version=api_version, filter=filter, top=top, - template_url=self.list_at_subscription_scope.metadata['url'], + api_version=api_version, + template_url=self.list_at_subscription_scope.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore else: - - request = build_deployments_list_at_subscription_scope_request( - subscription_id=self._config.subscription_id, - template_url=next_link, - ) + # make call to next link with the client's api-version + _parsed_next_link = urlparse(next_link) + _next_request_params = case_insensitive_dict(parse_qs(_parsed_next_link.query)) + _next_request_params["api-version"] = self._config.api_version + request = HttpRequest("GET", urljoin(next_link, _parsed_next_link.path), params=_next_request_params) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore request.method = "GET" return request @@ -6661,10 +7029,8 @@ def extract_data(pipeline_response): def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) response = pipeline_response.http_response @@ -6674,42 +7040,43 @@ def get_next(next_link=None): return pipeline_response + return ItemPaged(get_next, extract_data) - return ItemPaged( - get_next, extract_data - ) - list_at_subscription_scope.metadata = {'url': "/subscriptions/{subscriptionId}/providers/Microsoft.Resources/deployments/"} # type: ignore + list_at_subscription_scope.metadata = {"url": "/subscriptions/{subscriptionId}/providers/Microsoft.Resources/deployments/"} # type: ignore def _delete_initial( # pylint: disable=inconsistent-return-statements - self, - resource_group_name: str, - deployment_name: str, - **kwargs: Any + self, resource_group_name: str, deployment_name: str, **kwargs: Any ) -> None: - cls = kwargs.pop('cls', None) # type: ClsType[None] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) - api_version = kwargs.pop('api_version', "2021-01-01") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - request = build_deployments_delete_request_initial( + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-01-01")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[None] + + request = build_deployments_delete_request( resource_group_name=resource_group_name, deployment_name=deployment_name, subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self._delete_initial.metadata['url'], + template_url=self._delete_initial.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [202, 204]: @@ -6719,16 +7086,10 @@ 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.Resources/deployments/{deploymentName}"} # type: ignore - + _delete_initial.metadata = {"url": "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/Microsoft.Resources/deployments/{deploymentName}"} # type: ignore @distributed_trace - def begin_delete( # pylint: disable=inconsistent-return-statements - self, - resource_group_name: str, - deployment_name: str, - **kwargs: Any - ) -> LROPoller[None]: + def begin_delete(self, resource_group_name: str, deployment_name: str, **kwargs: Any) -> LROPoller[None]: """Deletes a deployment from the deployment history. A template deployment that is currently running cannot be deleted. Deleting a template @@ -6741,9 +7102,9 @@ def begin_delete( # pylint: disable=inconsistent-return-statements asynchronous request failed, the URI in the Location header returns an error-level status code. :param resource_group_name: The name of the resource group with the deployment to delete. The - name is case insensitive. + name is case insensitive. Required. :type resource_group_name: str - :param deployment_name: The name of the deployment. + :param deployment_name: The name of the deployment. Required. :type deployment_name: str :keyword callable cls: A custom type or function that will be passed the direct response :keyword str continuation_token: A continuation token to restart a poller from a saved state. @@ -6755,88 +7116,93 @@ def begin_delete( # pylint: disable=inconsistent-return-statements Retry-After header is present. :return: An instance of LROPoller that returns either None or the result of cls(response) :rtype: ~azure.core.polling.LROPoller[None] - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - api_version = kwargs.pop('api_version', "2021-01-01") # type: str - polling = kwargs.pop('polling', True) # type: Union[bool, PollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType[None] - lro_delay = kwargs.pop( - 'polling_interval', - self._config.polling_interval - ) - cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-01-01")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[None] + polling = kwargs.pop("polling", True) # type: Union[bool, PollingMethod] + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token = kwargs.pop("continuation_token", None) # type: Optional[str] if cont_token is None: - raw_result = self._delete_initial( + raw_result = self._delete_initial( # type: ignore resource_group_name=resource_group_name, deployment_name=deployment_name, api_version=api_version, - cls=lambda x,y,z: x, + cls=lambda x, y, z: x, + headers=_headers, + params=_params, **kwargs ) - kwargs.pop('error_map', None) + kwargs.pop("error_map", None) - def get_long_running_output(pipeline_response): + def get_long_running_output(pipeline_response): # pylint: disable=inconsistent-return-statements if cls: return cls(pipeline_response, None, {}) - - if polling is True: polling_method = ARMPolling(lro_delay, **kwargs) - elif polling is False: polling_method = NoPolling() - else: polling_method = polling + if polling is True: + polling_method = cast(PollingMethod, ARMPolling(lro_delay, **kwargs)) # type: PollingMethod + elif polling is False: + polling_method = cast(PollingMethod, NoPolling()) + else: + polling_method = polling if cont_token: return LROPoller.from_continuation_token( polling_method=polling_method, continuation_token=cont_token, client=self._client, - deserialization_callback=get_long_running_output + deserialization_callback=get_long_running_output, ) return LROPoller(self._client, raw_result, get_long_running_output, polling_method) - begin_delete.metadata = {'url': "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/Microsoft.Resources/deployments/{deploymentName}"} # type: ignore + begin_delete.metadata = {"url": "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/Microsoft.Resources/deployments/{deploymentName}"} # type: ignore @distributed_trace - def check_existence( - self, - resource_group_name: str, - deployment_name: str, - **kwargs: Any - ) -> bool: + def check_existence(self, resource_group_name: str, deployment_name: str, **kwargs: Any) -> bool: """Checks whether the deployment exists. :param resource_group_name: The name of the resource group with the deployment to check. The - name is case insensitive. + name is case insensitive. Required. :type resource_group_name: str - :param deployment_name: The name of the deployment. + :param deployment_name: The name of the deployment. Required. :type deployment_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: bool, or the result of cls(response) + :return: bool or the result of cls(response) :rtype: bool - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType[None] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + 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', "2021-01-01") # type: str + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-01-01")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[None] - request = build_deployments_check_existence_request( resource_group_name=resource_group_name, deployment_name=deployment_name, subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.check_existence.metadata['url'], + template_url=self.check_existence.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [204, 404]: @@ -6847,44 +7213,53 @@ def check_existence( return cls(pipeline_response, None, {}) return 200 <= response.status_code <= 299 - check_existence.metadata = {'url': "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/Microsoft.Resources/deployments/{deploymentName}"} # type: ignore - + check_existence.metadata = {"url": "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/Microsoft.Resources/deployments/{deploymentName}"} # type: ignore def _create_or_update_initial( - self, - resource_group_name: str, - deployment_name: str, - parameters: "_models.Deployment", - **kwargs: Any - ) -> "_models.DeploymentExtended": - cls = kwargs.pop('cls', None) # type: ClsType["_models.DeploymentExtended"] + self, resource_group_name: str, deployment_name: str, parameters: Union[_models.Deployment, IO], **kwargs: Any + ) -> _models.DeploymentExtended: error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) - api_version = kwargs.pop('api_version', "2021-01-01") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - _json = self._serialize.body(parameters, 'Deployment') + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-01-01")) # type: str + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.DeploymentExtended] - request = build_deployments_create_or_update_request_initial( + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(parameters, (IO, bytes)): + _content = parameters + else: + _json = self._serialize.body(parameters, "Deployment") + + request = build_deployments_create_or_update_request( resource_group_name=resource_group_name, deployment_name=deployment_name, subscription_id=self._config.subscription_id, api_version=api_version, content_type=content_type, json=_json, - template_url=self._create_or_update_initial.metadata['url'], + content=_content, + template_url=self._create_or_update_initial.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200, 201]: @@ -6892,38 +7267,42 @@ def _create_or_update_initial( raise HttpResponseError(response=response, error_format=ARMErrorFormat) if response.status_code == 200: - deserialized = self._deserialize('DeploymentExtended', pipeline_response) + deserialized = self._deserialize("DeploymentExtended", pipeline_response) if response.status_code == 201: - deserialized = self._deserialize('DeploymentExtended', pipeline_response) + deserialized = self._deserialize("DeploymentExtended", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - _create_or_update_initial.metadata = {'url': "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/Microsoft.Resources/deployments/{deploymentName}"} # type: ignore + _create_or_update_initial.metadata = {"url": "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/Microsoft.Resources/deployments/{deploymentName}"} # type: ignore - - @distributed_trace + @overload def begin_create_or_update( self, resource_group_name: str, deployment_name: str, - parameters: "_models.Deployment", + parameters: _models.Deployment, + *, + content_type: str = "application/json", **kwargs: Any - ) -> LROPoller["_models.DeploymentExtended"]: + ) -> LROPoller[_models.DeploymentExtended]: """Deploys resources to a resource group. You can provide the template and parameters directly in the request or link to JSON files. :param resource_group_name: The name of the resource group to deploy the resources to. The name - is case insensitive. The resource group must already exist. + is case insensitive. The resource group must already exist. Required. :type resource_group_name: str - :param deployment_name: The name of the deployment. + :param deployment_name: The name of the deployment. Required. :type deployment_name: str - :param parameters: Additional parameters supplied to the operation. + :param parameters: Additional parameters supplied to the operation. Required. :type parameters: ~azure.mgmt.resource.resources.v2021_01_01.models.Deployment + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str :keyword callable cls: A custom type or function that will be passed the direct response :keyword str continuation_token: A continuation token to restart a poller from a saved state. :keyword polling: By default, your polling method will be ARMPolling. Pass in False for this @@ -6936,115 +7315,189 @@ def begin_create_or_update( cls(response) :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.resource.resources.v2021_01_01.models.DeploymentExtended] - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - api_version = kwargs.pop('api_version', "2021-01-01") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] - polling = kwargs.pop('polling', True) # type: Union[bool, PollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType["_models.DeploymentExtended"] - lro_delay = kwargs.pop( - 'polling_interval', - self._config.polling_interval - ) - cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] - if cont_token is None: - raw_result = self._create_or_update_initial( - resource_group_name=resource_group_name, - deployment_name=deployment_name, - parameters=parameters, - api_version=api_version, - content_type=content_type, - cls=lambda x,y,z: x, - **kwargs - ) - kwargs.pop('error_map', None) - - def get_long_running_output(pipeline_response): - response = pipeline_response.http_response - deserialized = self._deserialize('DeploymentExtended', pipeline_response) - if cls: - return cls(pipeline_response, deserialized, {}) - return deserialized - - - if polling is True: polling_method = ARMPolling(lro_delay, **kwargs) - elif polling is False: polling_method = NoPolling() - else: polling_method = polling - if cont_token: - return LROPoller.from_continuation_token( - polling_method=polling_method, - continuation_token=cont_token, - client=self._client, - deserialization_callback=get_long_running_output - ) - return LROPoller(self._client, raw_result, get_long_running_output, polling_method) - begin_create_or_update.metadata = {'url': "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/Microsoft.Resources/deployments/{deploymentName}"} # type: ignore - - @distributed_trace - def get( + @overload + def begin_create_or_update( self, resource_group_name: str, deployment_name: str, + parameters: IO, + *, + content_type: str = "application/json", **kwargs: Any - ) -> "_models.DeploymentExtended": - """Gets a deployment. + ) -> LROPoller[_models.DeploymentExtended]: + """Deploys resources to a resource group. - :param resource_group_name: The name of the resource group. The name is case insensitive. + You can provide the template and parameters directly in the request or link to JSON files. + + :param resource_group_name: The name of the resource group to deploy the resources to. The name + is case insensitive. The resource group must already exist. Required. :type resource_group_name: str - :param deployment_name: The name of the deployment. + :param deployment_name: The name of the deployment. Required. :type deployment_name: str + :param parameters: Additional parameters supplied to the operation. Required. + :type parameters: IO + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: DeploymentExtended, or the result of cls(response) - :rtype: ~azure.mgmt.resource.resources.v2021_01_01.models.DeploymentExtended - :raises: ~azure.core.exceptions.HttpResponseError - """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.DeploymentExtended"] - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {})) + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be ARMPolling. Pass in False for this + operation to not poll, or pass in your own initialized polling object for a personal polling + strategy. + :paramtype polling: bool or ~azure.core.polling.PollingMethod + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of LROPoller that returns either DeploymentExtended or the result of + cls(response) + :rtype: + ~azure.core.polling.LROPoller[~azure.mgmt.resource.resources.v2021_01_01.models.DeploymentExtended] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace + def begin_create_or_update( + self, resource_group_name: str, deployment_name: str, parameters: Union[_models.Deployment, IO], **kwargs: Any + ) -> LROPoller[_models.DeploymentExtended]: + """Deploys resources to a resource group. + + You can provide the template and parameters directly in the request or link to JSON files. + + :param resource_group_name: The name of the resource group to deploy the resources to. The name + is case insensitive. The resource group must already exist. Required. + :type resource_group_name: str + :param deployment_name: The name of the deployment. Required. + :type deployment_name: str + :param parameters: Additional parameters supplied to the operation. Is either a model type or a + IO type. Required. + :type parameters: ~azure.mgmt.resource.resources.v2021_01_01.models.Deployment or IO + :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. + Default value is None. + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be ARMPolling. Pass in False for this + operation to not poll, or pass in your own initialized polling object for a personal polling + strategy. + :paramtype polling: bool or ~azure.core.polling.PollingMethod + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of LROPoller that returns either DeploymentExtended or the result of + cls(response) + :rtype: + ~azure.core.polling.LROPoller[~azure.mgmt.resource.resources.v2021_01_01.models.DeploymentExtended] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _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-01-01")) # type: str + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.DeploymentExtended] + polling = kwargs.pop("polling", True) # type: Union[bool, PollingMethod] + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token = kwargs.pop("continuation_token", None) # type: Optional[str] + if cont_token is None: + raw_result = self._create_or_update_initial( # type: ignore + resource_group_name=resource_group_name, + deployment_name=deployment_name, + parameters=parameters, + api_version=api_version, + content_type=content_type, + cls=lambda x, y, z: x, + headers=_headers, + params=_params, + **kwargs + ) + kwargs.pop("error_map", None) + + def get_long_running_output(pipeline_response): + deserialized = self._deserialize("DeploymentExtended", pipeline_response) + if cls: + return cls(pipeline_response, deserialized, {}) + return deserialized + + if polling is True: + polling_method = cast(PollingMethod, ARMPolling(lro_delay, **kwargs)) # type: PollingMethod + elif polling is False: + polling_method = cast(PollingMethod, NoPolling()) + else: + polling_method = polling + if cont_token: + return LROPoller.from_continuation_token( + polling_method=polling_method, + continuation_token=cont_token, + client=self._client, + deserialization_callback=get_long_running_output, + ) + return LROPoller(self._client, raw_result, get_long_running_output, polling_method) + + begin_create_or_update.metadata = {"url": "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/Microsoft.Resources/deployments/{deploymentName}"} # type: ignore + + @distributed_trace + def get(self, resource_group_name: str, deployment_name: str, **kwargs: Any) -> _models.DeploymentExtended: + """Gets a deployment. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param deployment_name: The name of the deployment. Required. + :type deployment_name: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: DeploymentExtended or the result of cls(response) + :rtype: ~azure.mgmt.resource.resources.v2021_01_01.models.DeploymentExtended + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) - api_version = kwargs.pop('api_version', "2021-01-01") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-01-01")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[_models.DeploymentExtended] - request = build_deployments_get_request( resource_group_name=resource_group_name, deployment_name=deployment_name, subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.get.metadata['url'], + template_url=self.get.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) - deserialized = self._deserialize('DeploymentExtended', pipeline_response) + deserialized = self._deserialize("DeploymentExtended", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - get.metadata = {'url': "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/Microsoft.Resources/deployments/{deploymentName}"} # type: ignore - + get.metadata = {"url": "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/Microsoft.Resources/deployments/{deploymentName}"} # type: ignore @distributed_trace def cancel( # pylint: disable=inconsistent-return-statements - self, - resource_group_name: str, - deployment_name: str, - **kwargs: Any + self, resource_group_name: str, deployment_name: str, **kwargs: Any ) -> None: """Cancels a currently running template deployment. @@ -7054,38 +7507,45 @@ def cancel( # pylint: disable=inconsistent-return-statements partially deployed. :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. :type resource_group_name: str - :param deployment_name: The name of the deployment. + :param deployment_name: The name of the deployment. Required. :type deployment_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: None, or the result of cls(response) + :return: None or the result of cls(response) :rtype: None - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType[None] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + 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', "2021-01-01") # type: str + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-01-01")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[None] - request = build_deployments_cancel_request( resource_group_name=resource_group_name, deployment_name=deployment_name, subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.cancel.metadata['url'], + template_url=self.cancel.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [204]: @@ -7095,44 +7555,53 @@ def cancel( # pylint: disable=inconsistent-return-statements if cls: return cls(pipeline_response, None, {}) - cancel.metadata = {'url': "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/Microsoft.Resources/deployments/{deploymentName}/cancel"} # type: ignore - + cancel.metadata = {"url": "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/Microsoft.Resources/deployments/{deploymentName}/cancel"} # type: ignore def _validate_initial( - self, - resource_group_name: str, - deployment_name: str, - parameters: "_models.Deployment", - **kwargs: Any - ) -> Optional["_models.DeploymentValidateResult"]: - cls = kwargs.pop('cls', None) # type: ClsType[Optional["_models.DeploymentValidateResult"]] + self, resource_group_name: str, deployment_name: str, parameters: Union[_models.Deployment, IO], **kwargs: Any + ) -> Optional[_models.DeploymentValidateResult]: error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) - api_version = kwargs.pop('api_version', "2021-01-01") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - _json = self._serialize.body(parameters, 'Deployment') + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-01-01")) # type: str + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[Optional[_models.DeploymentValidateResult]] - request = build_deployments_validate_request_initial( + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(parameters, (IO, bytes)): + _content = parameters + else: + _json = self._serialize.body(parameters, "Deployment") + + request = build_deployments_validate_request( resource_group_name=resource_group_name, deployment_name=deployment_name, subscription_id=self._config.subscription_id, api_version=api_version, content_type=content_type, json=_json, - template_url=self._validate_initial.metadata['url'], + content=_content, + template_url=self._validate_initial.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200, 202, 400]: @@ -7141,37 +7610,41 @@ def _validate_initial( deserialized = None if response.status_code == 200: - deserialized = self._deserialize('DeploymentValidateResult', pipeline_response) + deserialized = self._deserialize("DeploymentValidateResult", pipeline_response) if response.status_code == 400: - deserialized = self._deserialize('DeploymentValidateResult', pipeline_response) + deserialized = self._deserialize("DeploymentValidateResult", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - _validate_initial.metadata = {'url': "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/Microsoft.Resources/deployments/{deploymentName}/validate"} # type: ignore + _validate_initial.metadata = {"url": "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/Microsoft.Resources/deployments/{deploymentName}/validate"} # type: ignore - - @distributed_trace + @overload def begin_validate( self, resource_group_name: str, deployment_name: str, - parameters: "_models.Deployment", + parameters: _models.Deployment, + *, + content_type: str = "application/json", **kwargs: Any - ) -> LROPoller["_models.DeploymentValidateResult"]: + ) -> LROPoller[_models.DeploymentValidateResult]: """Validates whether the specified template is syntactically correct and will be accepted by Azure Resource Manager.. :param resource_group_name: The name of the resource group the template will be deployed to. - The name is case insensitive. + The name is case insensitive. Required. :type resource_group_name: str - :param deployment_name: The name of the deployment. + :param deployment_name: The name of the deployment. Required. :type deployment_name: str - :param parameters: Parameters to validate. + :param parameters: Parameters to validate. Required. :type parameters: ~azure.mgmt.resource.resources.v2021_01_01.models.Deployment + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str :keyword callable cls: A custom type or function that will be passed the direct response :keyword str continuation_token: A continuation token to restart a poller from a saved state. :keyword polling: By default, your polling method will be ARMPolling. Pass in False for this @@ -7184,86 +7657,173 @@ def begin_validate( cls(response) :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.resource.resources.v2021_01_01.models.DeploymentValidateResult] - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - api_version = kwargs.pop('api_version', "2021-01-01") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] - polling = kwargs.pop('polling', True) # type: Union[bool, PollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType["_models.DeploymentValidateResult"] - lro_delay = kwargs.pop( - 'polling_interval', - self._config.polling_interval - ) - cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] + + @overload + def begin_validate( + self, + resource_group_name: str, + deployment_name: str, + parameters: IO, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> LROPoller[_models.DeploymentValidateResult]: + """Validates whether the specified template is syntactically correct and will be accepted by Azure + Resource Manager.. + + :param resource_group_name: The name of the resource group the template will be deployed to. + The name is case insensitive. Required. + :type resource_group_name: str + :param deployment_name: The name of the deployment. Required. + :type deployment_name: str + :param parameters: Parameters to validate. Required. + :type parameters: IO + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be ARMPolling. Pass in False for this + operation to not poll, or pass in your own initialized polling object for a personal polling + strategy. + :paramtype polling: bool or ~azure.core.polling.PollingMethod + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of LROPoller that returns either DeploymentValidateResult or the result of + cls(response) + :rtype: + ~azure.core.polling.LROPoller[~azure.mgmt.resource.resources.v2021_01_01.models.DeploymentValidateResult] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace + def begin_validate( + self, resource_group_name: str, deployment_name: str, parameters: Union[_models.Deployment, IO], **kwargs: Any + ) -> LROPoller[_models.DeploymentValidateResult]: + """Validates whether the specified template is syntactically correct and will be accepted by Azure + Resource Manager.. + + :param resource_group_name: The name of the resource group the template will be deployed to. + The name is case insensitive. Required. + :type resource_group_name: str + :param deployment_name: The name of the deployment. Required. + :type deployment_name: str + :param parameters: Parameters to validate. Is either a model type or a IO type. Required. + :type parameters: ~azure.mgmt.resource.resources.v2021_01_01.models.Deployment or IO + :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. + Default value is None. + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be ARMPolling. Pass in False for this + operation to not poll, or pass in your own initialized polling object for a personal polling + strategy. + :paramtype polling: bool or ~azure.core.polling.PollingMethod + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of LROPoller that returns either DeploymentValidateResult or the result of + cls(response) + :rtype: + ~azure.core.polling.LROPoller[~azure.mgmt.resource.resources.v2021_01_01.models.DeploymentValidateResult] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _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-01-01")) # type: str + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.DeploymentValidateResult] + polling = kwargs.pop("polling", True) # type: Union[bool, PollingMethod] + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token = kwargs.pop("continuation_token", None) # type: Optional[str] if cont_token is None: - raw_result = self._validate_initial( + raw_result = self._validate_initial( # type: ignore resource_group_name=resource_group_name, deployment_name=deployment_name, parameters=parameters, api_version=api_version, content_type=content_type, - cls=lambda x,y,z: x, + cls=lambda x, y, z: x, + headers=_headers, + params=_params, **kwargs ) - kwargs.pop('error_map', None) + kwargs.pop("error_map", None) def get_long_running_output(pipeline_response): - response = pipeline_response.http_response - deserialized = self._deserialize('DeploymentValidateResult', pipeline_response) + deserialized = self._deserialize("DeploymentValidateResult", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - - if polling is True: polling_method = ARMPolling(lro_delay, **kwargs) - elif polling is False: polling_method = NoPolling() - else: polling_method = polling + if polling is True: + polling_method = cast(PollingMethod, ARMPolling(lro_delay, **kwargs)) # type: PollingMethod + elif polling is False: + polling_method = cast(PollingMethod, NoPolling()) + else: + polling_method = polling if cont_token: return LROPoller.from_continuation_token( polling_method=polling_method, continuation_token=cont_token, client=self._client, - deserialization_callback=get_long_running_output + deserialization_callback=get_long_running_output, ) return LROPoller(self._client, raw_result, get_long_running_output, polling_method) - begin_validate.metadata = {'url': "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/Microsoft.Resources/deployments/{deploymentName}/validate"} # type: ignore + begin_validate.metadata = {"url": "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/Microsoft.Resources/deployments/{deploymentName}/validate"} # type: ignore def _what_if_initial( self, resource_group_name: str, deployment_name: str, - parameters: "_models.DeploymentWhatIf", + parameters: Union[_models.DeploymentWhatIf, IO], **kwargs: Any - ) -> Optional["_models.WhatIfOperationResult"]: - cls = kwargs.pop('cls', None) # type: ClsType[Optional["_models.WhatIfOperationResult"]] + ) -> Optional[_models.WhatIfOperationResult]: error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', "2021-01-01") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-01-01")) # type: str + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[Optional[_models.WhatIfOperationResult]] - _json = self._serialize.body(parameters, 'DeploymentWhatIf') + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(parameters, (IO, bytes)): + _content = parameters + else: + _json = self._serialize.body(parameters, "DeploymentWhatIf") - request = build_deployments_what_if_request_initial( + request = build_deployments_what_if_request( resource_group_name=resource_group_name, deployment_name=deployment_name, subscription_id=self._config.subscription_id, api_version=api_version, content_type=content_type, json=_json, - template_url=self._what_if_initial.metadata['url'], + content=_content, + template_url=self._what_if_initial.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200, 202]: @@ -7273,39 +7833,116 @@ def _what_if_initial( deserialized = None response_headers = {} if response.status_code == 200: - deserialized = self._deserialize('WhatIfOperationResult', pipeline_response) + deserialized = self._deserialize("WhatIfOperationResult", pipeline_response) if response.status_code == 202: - response_headers['Location']=self._deserialize('str', response.headers.get('Location')) - response_headers['Retry-After']=self._deserialize('str', response.headers.get('Retry-After')) - + response_headers["Location"] = self._deserialize("str", response.headers.get("Location")) + response_headers["Retry-After"] = self._deserialize("str", response.headers.get("Retry-After")) if cls: return cls(pipeline_response, deserialized, response_headers) return deserialized - _what_if_initial.metadata = {'url': "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/Microsoft.Resources/deployments/{deploymentName}/whatIf"} # type: ignore + _what_if_initial.metadata = {"url": "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/Microsoft.Resources/deployments/{deploymentName}/whatIf"} # type: ignore + + @overload + def begin_what_if( + self, + resource_group_name: str, + deployment_name: str, + parameters: _models.DeploymentWhatIf, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> LROPoller[_models.WhatIfOperationResult]: + """Returns changes that will be made by the deployment if executed at the scope of the resource + group. + + :param resource_group_name: The name of the resource group the template will be deployed to. + The name is case insensitive. Required. + :type resource_group_name: str + :param deployment_name: The name of the deployment. Required. + :type deployment_name: str + :param parameters: Parameters to validate. Required. + :type parameters: ~azure.mgmt.resource.resources.v2021_01_01.models.DeploymentWhatIf + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be ARMPolling. Pass in False for this + operation to not poll, or pass in your own initialized polling object for a personal polling + strategy. + :paramtype polling: bool or ~azure.core.polling.PollingMethod + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of LROPoller that returns either WhatIfOperationResult or the result of + cls(response) + :rtype: + ~azure.core.polling.LROPoller[~azure.mgmt.resource.resources.v2021_01_01.models.WhatIfOperationResult] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + def begin_what_if( + self, + resource_group_name: str, + deployment_name: str, + parameters: IO, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> LROPoller[_models.WhatIfOperationResult]: + """Returns changes that will be made by the deployment if executed at the scope of the resource + group. + :param resource_group_name: The name of the resource group the template will be deployed to. + The name is case insensitive. Required. + :type resource_group_name: str + :param deployment_name: The name of the deployment. Required. + :type deployment_name: str + :param parameters: Parameters to validate. Required. + :type parameters: IO + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be ARMPolling. Pass in False for this + operation to not poll, or pass in your own initialized polling object for a personal polling + strategy. + :paramtype polling: bool or ~azure.core.polling.PollingMethod + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of LROPoller that returns either WhatIfOperationResult or the result of + cls(response) + :rtype: + ~azure.core.polling.LROPoller[~azure.mgmt.resource.resources.v2021_01_01.models.WhatIfOperationResult] + :raises ~azure.core.exceptions.HttpResponseError: + """ @distributed_trace def begin_what_if( self, resource_group_name: str, deployment_name: str, - parameters: "_models.DeploymentWhatIf", + parameters: Union[_models.DeploymentWhatIf, IO], **kwargs: Any - ) -> LROPoller["_models.WhatIfOperationResult"]: + ) -> LROPoller[_models.WhatIfOperationResult]: """Returns changes that will be made by the deployment if executed at the scope of the resource group. :param resource_group_name: The name of the resource group the template will be deployed to. - The name is case insensitive. + The name is case insensitive. Required. :type resource_group_name: str - :param deployment_name: The name of the deployment. + :param deployment_name: The name of the deployment. Required. :type deployment_name: str - :param parameters: Parameters to validate. - :type parameters: ~azure.mgmt.resource.resources.v2021_01_01.models.DeploymentWhatIf + :param parameters: Parameters to validate. Is either a model type or a IO type. Required. + :type parameters: ~azure.mgmt.resource.resources.v2021_01_01.models.DeploymentWhatIf or IO + :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. + Default value is None. + :paramtype content_type: str :keyword callable cls: A custom type or function that will be passed the direct response :keyword str continuation_token: A continuation token to restart a poller from a saved state. :keyword polling: By default, your polling method will be ARMPolling. Pass in False for this @@ -7318,121 +7955,125 @@ def begin_what_if( cls(response) :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.resource.resources.v2021_01_01.models.WhatIfOperationResult] - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - api_version = kwargs.pop('api_version', "2021-01-01") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] - polling = kwargs.pop('polling', True) # type: Union[bool, PollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType["_models.WhatIfOperationResult"] - lro_delay = kwargs.pop( - 'polling_interval', - self._config.polling_interval - ) - cont_token = kwargs.pop('continuation_token', None) # type: Optional[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-01-01")) # type: str + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.WhatIfOperationResult] + polling = kwargs.pop("polling", True) # type: Union[bool, PollingMethod] + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token = kwargs.pop("continuation_token", None) # type: Optional[str] if cont_token is None: - raw_result = self._what_if_initial( + raw_result = self._what_if_initial( # type: ignore resource_group_name=resource_group_name, deployment_name=deployment_name, parameters=parameters, api_version=api_version, content_type=content_type, - cls=lambda x,y,z: x, + cls=lambda x, y, z: x, + headers=_headers, + params=_params, **kwargs ) - kwargs.pop('error_map', None) + kwargs.pop("error_map", None) def get_long_running_output(pipeline_response): - response = pipeline_response.http_response - deserialized = self._deserialize('WhatIfOperationResult', pipeline_response) + deserialized = self._deserialize("WhatIfOperationResult", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - - if polling is True: polling_method = ARMPolling(lro_delay, lro_options={'final-state-via': 'location'}, **kwargs) - elif polling is False: polling_method = NoPolling() - else: polling_method = polling + if polling is True: + polling_method = cast( + PollingMethod, ARMPolling(lro_delay, lro_options={"final-state-via": "location"}, **kwargs) + ) # type: PollingMethod + elif polling is False: + polling_method = cast(PollingMethod, NoPolling()) + else: + polling_method = polling if cont_token: return LROPoller.from_continuation_token( polling_method=polling_method, continuation_token=cont_token, client=self._client, - deserialization_callback=get_long_running_output + deserialization_callback=get_long_running_output, ) return LROPoller(self._client, raw_result, get_long_running_output, polling_method) - begin_what_if.metadata = {'url': "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/Microsoft.Resources/deployments/{deploymentName}/whatIf"} # type: ignore + begin_what_if.metadata = {"url": "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/Microsoft.Resources/deployments/{deploymentName}/whatIf"} # type: ignore @distributed_trace def export_template( - self, - resource_group_name: str, - deployment_name: str, - **kwargs: Any - ) -> "_models.DeploymentExportResult": + self, resource_group_name: str, deployment_name: str, **kwargs: Any + ) -> _models.DeploymentExportResult: """Exports the template used for specified deployment. :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. :type resource_group_name: str - :param deployment_name: The name of the deployment. + :param deployment_name: The name of the deployment. Required. :type deployment_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: DeploymentExportResult, or the result of cls(response) + :return: DeploymentExportResult or the result of cls(response) :rtype: ~azure.mgmt.resource.resources.v2021_01_01.models.DeploymentExportResult - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.DeploymentExportResult"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) - api_version = kwargs.pop('api_version', "2021-01-01") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-01-01")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[_models.DeploymentExportResult] - request = build_deployments_export_template_request( resource_group_name=resource_group_name, deployment_name=deployment_name, subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.export_template.metadata['url'], + template_url=self.export_template.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) - deserialized = self._deserialize('DeploymentExportResult', pipeline_response) + deserialized = self._deserialize("DeploymentExportResult", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - export_template.metadata = {'url': "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/Microsoft.Resources/deployments/{deploymentName}/exportTemplate"} # type: ignore - + export_template.metadata = {"url": "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/Microsoft.Resources/deployments/{deploymentName}/exportTemplate"} # type: ignore @distributed_trace def list_by_resource_group( - self, - resource_group_name: str, - filter: Optional[str] = None, - top: Optional[int] = None, - **kwargs: Any - ) -> Iterable["_models.DeploymentListResult"]: + self, resource_group_name: str, filter: Optional[str] = None, top: Optional[int] = None, **kwargs: Any + ) -> Iterable["_models.DeploymentExtended"]: """Get all the deployments for a resource group. :param resource_group_name: The name of the resource group with the deployments to get. The - name is case insensitive. + name is case insensitive. Required. :type resource_group_name: str :param filter: The filter to apply on the operation. For example, you can use $filter=provisioningState eq '{state}'. Default value is None. @@ -7441,42 +8082,49 @@ def list_by_resource_group( value is None. :type top: int :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either DeploymentListResult or the result of - cls(response) + :return: An iterator like instance of either DeploymentExtended or the result of cls(response) :rtype: - ~azure.core.paging.ItemPaged[~azure.mgmt.resource.resources.v2021_01_01.models.DeploymentListResult] - :raises: ~azure.core.exceptions.HttpResponseError + ~azure.core.paging.ItemPaged[~azure.mgmt.resource.resources.v2021_01_01.models.DeploymentExtended] + :raises ~azure.core.exceptions.HttpResponseError: """ - api_version = kwargs.pop('api_version', "2021-01-01") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-01-01")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[_models.DeploymentListResult] - cls = kwargs.pop('cls', None) # type: ClsType["_models.DeploymentListResult"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) + def prepare_request(next_link=None): if not next_link: - + request = build_deployments_list_by_resource_group_request( resource_group_name=resource_group_name, subscription_id=self._config.subscription_id, - api_version=api_version, filter=filter, top=top, - template_url=self.list_by_resource_group.metadata['url'], + 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.url = self._client.format_url(request.url) # type: ignore else: - - request = build_deployments_list_by_resource_group_request( - resource_group_name=resource_group_name, - subscription_id=self._config.subscription_id, - template_url=next_link, - ) + # make call to next link with the client's api-version + _parsed_next_link = urlparse(next_link) + _next_request_params = case_insensitive_dict(parse_qs(_parsed_next_link.query)) + _next_request_params["api-version"] = self._config.api_version + request = HttpRequest("GET", urljoin(next_link, _parsed_next_link.path), params=_next_request_params) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore request.method = "GET" return request @@ -7490,10 +8138,8 @@ def extract_data(pipeline_response): def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) response = pipeline_response.http_response @@ -7503,184 +8149,189 @@ def get_next(next_link=None): return pipeline_response + return ItemPaged(get_next, extract_data) - return ItemPaged( - get_next, extract_data - ) - list_by_resource_group.metadata = {'url': "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/Microsoft.Resources/deployments/"} # type: ignore + list_by_resource_group.metadata = {"url": "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/Microsoft.Resources/deployments/"} # type: ignore @distributed_trace - def calculate_template_hash( - self, - template: Any, - **kwargs: Any - ) -> "_models.TemplateHashResult": + def calculate_template_hash(self, template: JSON, **kwargs: Any) -> _models.TemplateHashResult: """Calculate the hash of the given template. - :param template: The template provided to calculate hash. - :type template: any + :param template: The template provided to calculate hash. Required. + :type template: JSON :keyword callable cls: A custom type or function that will be passed the direct response - :return: TemplateHashResult, or the result of cls(response) + :return: TemplateHashResult or the result of cls(response) :rtype: ~azure.mgmt.resource.resources.v2021_01_01.models.TemplateHashResult - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.TemplateHashResult"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) - api_version = kwargs.pop('api_version', "2021-01-01") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - _json = self._serialize.body(template, 'object') + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-01-01")) # type: str + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", "application/json")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[_models.TemplateHashResult] + + _json = self._serialize.body(template, "object") request = build_deployments_calculate_template_hash_request( api_version=api_version, content_type=content_type, json=_json, - template_url=self.calculate_template_hash.metadata['url'], + template_url=self.calculate_template_hash.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) - deserialized = self._deserialize('TemplateHashResult', pipeline_response) + deserialized = self._deserialize("TemplateHashResult", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - calculate_template_hash.metadata = {'url': "/providers/Microsoft.Resources/calculateTemplateHash"} # type: ignore + calculate_template_hash.metadata = {"url": "/providers/Microsoft.Resources/calculateTemplateHash"} # type: ignore -class ProvidersOperations(object): - """ProvidersOperations operations. - You should not instantiate this class directly. Instead, you should create a Client instance that - instantiates it for you and attaches it as an attribute. +class ProvidersOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. - :ivar models: Alias to model classes used in this operation group. - :type models: ~azure.mgmt.resource.resources.v2021_01_01.models - :param client: Client for service requests. - :param config: Configuration of service client. - :param serializer: An object model serializer. - :param deserializer: An object model deserializer. + Instead, you should access the following operations through + :class:`~azure.mgmt.resource.resources.v2021_01_01.ResourceManagementClient`'s + :attr:`providers` attribute. """ models = _models - def __init__(self, client, config, serializer, deserializer): - self._client = client - self._serialize = serializer - self._deserialize = deserializer - self._config = config + def __init__(self, *args, **kwargs): + input_args = list(args) + self._client = input_args.pop(0) if input_args else kwargs.pop("client") + self._config = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") @distributed_trace - def unregister( - self, - resource_provider_namespace: str, - **kwargs: Any - ) -> "_models.Provider": + def unregister(self, resource_provider_namespace: str, **kwargs: Any) -> _models.Provider: """Unregisters a subscription from a resource provider. :param resource_provider_namespace: The namespace of the resource provider to unregister. + Required. :type resource_provider_namespace: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: Provider, or the result of cls(response) + :return: Provider or the result of cls(response) :rtype: ~azure.mgmt.resource.resources.v2021_01_01.models.Provider - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.Provider"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) - api_version = kwargs.pop('api_version', "2021-01-01") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-01-01")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[_models.Provider] - request = build_providers_unregister_request( resource_provider_namespace=resource_provider_namespace, subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.unregister.metadata['url'], + template_url=self.unregister.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) - deserialized = self._deserialize('Provider', pipeline_response) + deserialized = self._deserialize("Provider", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - unregister.metadata = {'url': "/subscriptions/{subscriptionId}/providers/{resourceProviderNamespace}/unregister"} # type: ignore - + unregister.metadata = {"url": "/subscriptions/{subscriptionId}/providers/{resourceProviderNamespace}/unregister"} # type: ignore @distributed_trace def register_at_management_group_scope( # pylint: disable=inconsistent-return-statements - self, - resource_provider_namespace: str, - group_id: str, - **kwargs: Any + self, resource_provider_namespace: str, group_id: str, **kwargs: Any ) -> None: """Registers a management group with a resource provider. :param resource_provider_namespace: The namespace of the resource provider to register. + Required. :type resource_provider_namespace: str - :param group_id: The management group ID. + :param group_id: The management group ID. Required. :type group_id: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: None, or the result of cls(response) + :return: None or the result of cls(response) :rtype: None - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType[None] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + 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', "2021-01-01") # type: str + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-01-01")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[None] - request = build_providers_register_at_management_group_scope_request( resource_provider_namespace=resource_provider_namespace, group_id=group_id, api_version=api_version, - template_url=self.register_at_management_group_scope.metadata['url'], + template_url=self.register_at_management_group_scope.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200]: @@ -7690,70 +8341,68 @@ def register_at_management_group_scope( # pylint: disable=inconsistent-return-s if cls: return cls(pipeline_response, None, {}) - register_at_management_group_scope.metadata = {'url': "/providers/Microsoft.Management/managementGroups/{groupId}/providers/{resourceProviderNamespace}/register"} # type: ignore - + register_at_management_group_scope.metadata = {"url": "/providers/Microsoft.Management/managementGroups/{groupId}/providers/{resourceProviderNamespace}/register"} # type: ignore @distributed_trace - def register( - self, - resource_provider_namespace: str, - **kwargs: Any - ) -> "_models.Provider": + def register(self, resource_provider_namespace: str, **kwargs: Any) -> _models.Provider: """Registers a subscription with a resource provider. :param resource_provider_namespace: The namespace of the resource provider to register. + Required. :type resource_provider_namespace: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: Provider, or the result of cls(response) + :return: Provider or the result of cls(response) :rtype: ~azure.mgmt.resource.resources.v2021_01_01.models.Provider - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.Provider"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + 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', "2021-01-01") # type: str + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-01-01")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[_models.Provider] - request = build_providers_register_request( resource_provider_namespace=resource_provider_namespace, subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.register.metadata['url'], + template_url=self.register.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) - deserialized = self._deserialize('Provider', pipeline_response) + deserialized = self._deserialize("Provider", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - register.metadata = {'url': "/subscriptions/{subscriptionId}/providers/{resourceProviderNamespace}/register"} # type: ignore - + register.metadata = {"url": "/subscriptions/{subscriptionId}/providers/{resourceProviderNamespace}/register"} # type: ignore @distributed_trace def list( - self, - top: Optional[int] = None, - expand: Optional[str] = None, - **kwargs: Any - ) -> Iterable["_models.ProviderListResult"]: + self, top: Optional[int] = None, expand: Optional[str] = None, **kwargs: Any + ) -> Iterable["_models.Provider"]: """Gets all resource providers for a subscription. :param top: The number of results to return. If null is passed returns all deployments. Default @@ -7764,39 +8413,48 @@ def list( response, use $expand=resourceTypes/aliases. Default value is None. :type expand: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either ProviderListResult or the result of cls(response) + :return: An iterator like instance of either Provider or the result of cls(response) :rtype: - ~azure.core.paging.ItemPaged[~azure.mgmt.resource.resources.v2021_01_01.models.ProviderListResult] - :raises: ~azure.core.exceptions.HttpResponseError + ~azure.core.paging.ItemPaged[~azure.mgmt.resource.resources.v2021_01_01.models.Provider] + :raises ~azure.core.exceptions.HttpResponseError: """ - api_version = kwargs.pop('api_version', "2021-01-01") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-01-01")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[_models.ProviderListResult] - cls = kwargs.pop('cls', None) # type: ClsType["_models.ProviderListResult"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) + def prepare_request(next_link=None): if not next_link: - + request = build_providers_list_request( subscription_id=self._config.subscription_id, - api_version=api_version, top=top, expand=expand, - template_url=self.list.metadata['url'], + 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.url = self._client.format_url(request.url) # type: ignore else: - - request = build_providers_list_request( - subscription_id=self._config.subscription_id, - template_url=next_link, - ) + # make call to next link with the client's api-version + _parsed_next_link = urlparse(next_link) + _next_request_params = case_insensitive_dict(parse_qs(_parsed_next_link.query)) + _next_request_params["api-version"] = self._config.api_version + request = HttpRequest("GET", urljoin(next_link, _parsed_next_link.path), params=_next_request_params) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore request.method = "GET" return request @@ -7810,10 +8468,8 @@ def extract_data(pipeline_response): def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) response = pipeline_response.http_response @@ -7823,19 +8479,14 @@ def get_next(next_link=None): return pipeline_response + return ItemPaged(get_next, extract_data) - return ItemPaged( - get_next, extract_data - ) - list.metadata = {'url': "/subscriptions/{subscriptionId}/providers"} # type: ignore + list.metadata = {"url": "/subscriptions/{subscriptionId}/providers"} # type: ignore @distributed_trace def list_at_tenant_scope( - self, - top: Optional[int] = None, - expand: Optional[str] = None, - **kwargs: Any - ) -> Iterable["_models.ProviderListResult"]: + self, top: Optional[int] = None, expand: Optional[str] = None, **kwargs: Any + ) -> Iterable["_models.Provider"]: """Gets all resource providers for the tenant. :param top: The number of results to return. If null is passed returns all providers. Default @@ -7846,37 +8497,47 @@ def list_at_tenant_scope( response, use $expand=resourceTypes/aliases. Default value is None. :type expand: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either ProviderListResult or the result of cls(response) + :return: An iterator like instance of either Provider or the result of cls(response) :rtype: - ~azure.core.paging.ItemPaged[~azure.mgmt.resource.resources.v2021_01_01.models.ProviderListResult] - :raises: ~azure.core.exceptions.HttpResponseError + ~azure.core.paging.ItemPaged[~azure.mgmt.resource.resources.v2021_01_01.models.Provider] + :raises ~azure.core.exceptions.HttpResponseError: """ - api_version = kwargs.pop('api_version', "2021-01-01") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-01-01")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[_models.ProviderListResult] - cls = kwargs.pop('cls', None) # type: ClsType["_models.ProviderListResult"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) + def prepare_request(next_link=None): if not next_link: - + request = build_providers_list_at_tenant_scope_request( - api_version=api_version, top=top, expand=expand, - template_url=self.list_at_tenant_scope.metadata['url'], + api_version=api_version, + template_url=self.list_at_tenant_scope.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore else: - - request = build_providers_list_at_tenant_scope_request( - template_url=next_link, - ) + # make call to next link with the client's api-version + _parsed_next_link = urlparse(next_link) + _next_request_params = case_insensitive_dict(parse_qs(_parsed_next_link.query)) + _next_request_params["api-version"] = self._config.api_version + request = HttpRequest("GET", urljoin(next_link, _parsed_next_link.path), params=_next_request_params) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore request.method = "GET" return request @@ -7890,10 +8551,8 @@ def extract_data(pipeline_response): def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) response = pipeline_response.http_response @@ -7903,229 +8562,229 @@ def get_next(next_link=None): return pipeline_response + return ItemPaged(get_next, extract_data) - return ItemPaged( - get_next, extract_data - ) - list_at_tenant_scope.metadata = {'url': "/providers"} # type: ignore + list_at_tenant_scope.metadata = {"url": "/providers"} # type: ignore @distributed_trace - def get( - self, - resource_provider_namespace: str, - expand: Optional[str] = None, - **kwargs: Any - ) -> "_models.Provider": + def get(self, resource_provider_namespace: str, expand: Optional[str] = None, **kwargs: Any) -> _models.Provider: """Gets the specified resource provider. - :param resource_provider_namespace: The namespace of the resource provider. + :param resource_provider_namespace: The namespace of the resource provider. Required. :type resource_provider_namespace: str :param expand: The $expand query parameter. For example, to include property aliases in response, use $expand=resourceTypes/aliases. Default value is None. :type expand: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: Provider, or the result of cls(response) + :return: Provider or the result of cls(response) :rtype: ~azure.mgmt.resource.resources.v2021_01_01.models.Provider - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.Provider"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) - api_version = kwargs.pop('api_version', "2021-01-01") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-01-01")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[_models.Provider] - request = build_providers_get_request( resource_provider_namespace=resource_provider_namespace, subscription_id=self._config.subscription_id, - api_version=api_version, expand=expand, - template_url=self.get.metadata['url'], + api_version=api_version, + template_url=self.get.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) - deserialized = self._deserialize('Provider', pipeline_response) + deserialized = self._deserialize("Provider", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - get.metadata = {'url': "/subscriptions/{subscriptionId}/providers/{resourceProviderNamespace}"} # type: ignore - + get.metadata = {"url": "/subscriptions/{subscriptionId}/providers/{resourceProviderNamespace}"} # type: ignore @distributed_trace def get_at_tenant_scope( - self, - resource_provider_namespace: str, - expand: Optional[str] = None, - **kwargs: Any - ) -> "_models.Provider": + self, resource_provider_namespace: str, expand: Optional[str] = None, **kwargs: Any + ) -> _models.Provider: """Gets the specified resource provider at the tenant level. - :param resource_provider_namespace: The namespace of the resource provider. + :param resource_provider_namespace: The namespace of the resource provider. Required. :type resource_provider_namespace: str :param expand: The $expand query parameter. For example, to include property aliases in response, use $expand=resourceTypes/aliases. Default value is None. :type expand: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: Provider, or the result of cls(response) + :return: Provider or the result of cls(response) :rtype: ~azure.mgmt.resource.resources.v2021_01_01.models.Provider - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.Provider"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + 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', "2021-01-01") # type: str + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-01-01")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[_models.Provider] - request = build_providers_get_at_tenant_scope_request( resource_provider_namespace=resource_provider_namespace, - api_version=api_version, expand=expand, - template_url=self.get_at_tenant_scope.metadata['url'], + api_version=api_version, + template_url=self.get_at_tenant_scope.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) - deserialized = self._deserialize('Provider', pipeline_response) + deserialized = self._deserialize("Provider", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - get_at_tenant_scope.metadata = {'url': "/providers/{resourceProviderNamespace}"} # type: ignore + get_at_tenant_scope.metadata = {"url": "/providers/{resourceProviderNamespace}"} # type: ignore -class ProviderResourceTypesOperations(object): - """ProviderResourceTypesOperations operations. - You should not instantiate this class directly. Instead, you should create a Client instance that - instantiates it for you and attaches it as an attribute. +class ProviderResourceTypesOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. - :ivar models: Alias to model classes used in this operation group. - :type models: ~azure.mgmt.resource.resources.v2021_01_01.models - :param client: Client for service requests. - :param config: Configuration of service client. - :param serializer: An object model serializer. - :param deserializer: An object model deserializer. + Instead, you should access the following operations through + :class:`~azure.mgmt.resource.resources.v2021_01_01.ResourceManagementClient`'s + :attr:`provider_resource_types` attribute. """ models = _models - def __init__(self, client, config, serializer, deserializer): - self._client = client - self._serialize = serializer - self._deserialize = deserializer - self._config = config + def __init__(self, *args, **kwargs): + input_args = list(args) + self._client = input_args.pop(0) if input_args else kwargs.pop("client") + self._config = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") @distributed_trace def list( - self, - resource_provider_namespace: str, - expand: Optional[str] = None, - **kwargs: Any - ) -> "_models.ProviderResourceTypeListResult": + self, resource_provider_namespace: str, expand: Optional[str] = None, **kwargs: Any + ) -> _models.ProviderResourceTypeListResult: """List the resource types for a specified resource provider. - :param resource_provider_namespace: The namespace of the resource provider. + :param resource_provider_namespace: The namespace of the resource provider. Required. :type resource_provider_namespace: str :param expand: The $expand query parameter. For example, to include property aliases in response, use $expand=resourceTypes/aliases. Default value is None. :type expand: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: ProviderResourceTypeListResult, or the result of cls(response) + :return: ProviderResourceTypeListResult or the result of cls(response) :rtype: ~azure.mgmt.resource.resources.v2021_01_01.models.ProviderResourceTypeListResult - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.ProviderResourceTypeListResult"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) - api_version = kwargs.pop('api_version', "2021-01-01") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-01-01")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[_models.ProviderResourceTypeListResult] - request = build_provider_resource_types_list_request( resource_provider_namespace=resource_provider_namespace, subscription_id=self._config.subscription_id, - api_version=api_version, expand=expand, - template_url=self.list.metadata['url'], + 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.url = self._client.format_url(request.url) # type: ignore - pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) - deserialized = self._deserialize('ProviderResourceTypeListResult', pipeline_response) + deserialized = self._deserialize("ProviderResourceTypeListResult", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - list.metadata = {'url': "/subscriptions/{subscriptionId}/providers/{resourceProviderNamespace}/resourceTypes"} # type: ignore + list.metadata = {"url": "/subscriptions/{subscriptionId}/providers/{resourceProviderNamespace}/resourceTypes"} # type: ignore -class ResourcesOperations(object): # pylint: disable=too-many-public-methods - """ResourcesOperations operations. - You should not instantiate this class directly. Instead, you should create a Client instance that - instantiates it for you and attaches it as an attribute. +class ResourcesOperations: # pylint: disable=too-many-public-methods + """ + .. warning:: + **DO NOT** instantiate this class directly. - :ivar models: Alias to model classes used in this operation group. - :type models: ~azure.mgmt.resource.resources.v2021_01_01.models - :param client: Client for service requests. - :param config: Configuration of service client. - :param serializer: An object model serializer. - :param deserializer: An object model deserializer. + Instead, you should access the following operations through + :class:`~azure.mgmt.resource.resources.v2021_01_01.ResourceManagementClient`'s + :attr:`resources` attribute. """ models = _models - def __init__(self, client, config, serializer, deserializer): - self._client = client - self._serialize = serializer - self._deserialize = deserializer - self._config = config + def __init__(self, *args, **kwargs): + input_args = list(args) + self._client = input_args.pop(0) if input_args else kwargs.pop("client") + self._config = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") @distributed_trace def list_by_resource_group( @@ -8135,10 +8794,10 @@ def list_by_resource_group( expand: Optional[str] = None, top: Optional[int] = None, **kwargs: Any - ) -> Iterable["_models.ResourceListResult"]: + ) -> Iterable["_models.GenericResourceExpanded"]: """Get all the resources for a resource group. - :param resource_group_name: The resource group with the resources to get. + :param resource_group_name: The resource group with the resources to get. Required. :type resource_group_name: str :param filter: The filter to apply on the operation.:code:`
`:code:`
`The properties you can use for eq (equals) or ne (not equals) are: location, resourceType, name, resourceGroup, @@ -8164,42 +8823,51 @@ def list_by_resource_group( value is None. :type top: int :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either ResourceListResult or the result of cls(response) + :return: An iterator like instance of either GenericResourceExpanded or the result of + cls(response) :rtype: - ~azure.core.paging.ItemPaged[~azure.mgmt.resource.resources.v2021_01_01.models.ResourceListResult] - :raises: ~azure.core.exceptions.HttpResponseError + ~azure.core.paging.ItemPaged[~azure.mgmt.resource.resources.v2021_01_01.models.GenericResourceExpanded] + :raises ~azure.core.exceptions.HttpResponseError: """ - api_version = kwargs.pop('api_version', "2021-01-01") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-01-01")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[_models.ResourceListResult] - cls = kwargs.pop('cls', None) # type: ClsType["_models.ResourceListResult"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) + def prepare_request(next_link=None): if not next_link: - + request = build_resources_list_by_resource_group_request( resource_group_name=resource_group_name, subscription_id=self._config.subscription_id, - api_version=api_version, filter=filter, expand=expand, top=top, - template_url=self.list_by_resource_group.metadata['url'], + 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.url = self._client.format_url(request.url) # type: ignore else: - - request = build_resources_list_by_resource_group_request( - resource_group_name=resource_group_name, - subscription_id=self._config.subscription_id, - template_url=next_link, - ) + # make call to next link with the client's api-version + _parsed_next_link = urlparse(next_link) + _next_request_params = case_insensitive_dict(parse_qs(_parsed_next_link.query)) + _next_request_params["api-version"] = self._config.api_version + request = HttpRequest("GET", urljoin(next_link, _parsed_next_link.path), params=_next_request_params) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore request.method = "GET" return request @@ -8213,10 +8881,8 @@ def extract_data(pipeline_response): def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) response = pipeline_response.http_response @@ -8226,45 +8892,54 @@ def get_next(next_link=None): return pipeline_response + return ItemPaged(get_next, extract_data) - return ItemPaged( - get_next, extract_data - ) - list_by_resource_group.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/resources"} # type: ignore + list_by_resource_group.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/resources"} # type: ignore def _move_resources_initial( # pylint: disable=inconsistent-return-statements - self, - source_resource_group_name: str, - parameters: "_models.ResourcesMoveInfo", - **kwargs: Any + self, source_resource_group_name: str, parameters: Union[_models.ResourcesMoveInfo, IO], **kwargs: Any ) -> None: - cls = kwargs.pop('cls', None) # type: ClsType[None] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) - api_version = kwargs.pop('api_version', "2021-01-01") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - _json = self._serialize.body(parameters, 'ResourcesMoveInfo') + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-01-01")) # type: str + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[None] - request = build_resources_move_resources_request_initial( + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(parameters, (IO, bytes)): + _content = parameters + else: + _json = self._serialize.body(parameters, "ResourcesMoveInfo") + + request = build_resources_move_resources_request( source_resource_group_name=source_resource_group_name, subscription_id=self._config.subscription_id, api_version=api_version, content_type=content_type, json=_json, - template_url=self._move_resources_initial.metadata['url'], + content=_content, + template_url=self._move_resources_initial.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [202, 204]: @@ -8274,14 +8949,15 @@ def _move_resources_initial( # pylint: disable=inconsistent-return-statements if cls: return cls(pipeline_response, None, {}) - _move_resources_initial.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{sourceResourceGroupName}/moveResources"} # type: ignore + _move_resources_initial.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{sourceResourceGroupName}/moveResources"} # type: ignore - - @distributed_trace - def begin_move_resources( # pylint: disable=inconsistent-return-statements + @overload + def begin_move_resources( self, source_resource_group_name: str, - parameters: "_models.ResourcesMoveInfo", + parameters: _models.ResourcesMoveInfo, + *, + content_type: str = "application/json", **kwargs: Any ) -> LROPoller[None]: """Moves resources from one resource group to another resource group. @@ -8292,10 +8968,13 @@ def begin_move_resources( # pylint: disable=inconsistent-return-statements the groups until the move completes. :param source_resource_group_name: The name of the resource group containing the resources to - move. + move. Required. :type source_resource_group_name: str - :param parameters: Parameters for moving resources. + :param parameters: Parameters for moving resources. Required. :type parameters: ~azure.mgmt.resource.resources.v2021_01_01.models.ResourcesMoveInfo + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str :keyword callable cls: A custom type or function that will be passed the direct response :keyword str continuation_token: A continuation token to restart a poller from a saved state. :keyword polling: By default, your polling method will be ARMPolling. Pass in False for this @@ -8306,80 +8985,160 @@ def begin_move_resources( # pylint: disable=inconsistent-return-statements Retry-After header is present. :return: An instance of LROPoller that returns either None or the result of cls(response) :rtype: ~azure.core.polling.LROPoller[None] - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - api_version = kwargs.pop('api_version', "2021-01-01") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] - polling = kwargs.pop('polling', True) # type: Union[bool, PollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType[None] - lro_delay = kwargs.pop( - 'polling_interval', - self._config.polling_interval - ) - cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] + + @overload + def begin_move_resources( + self, source_resource_group_name: str, parameters: IO, *, content_type: str = "application/json", **kwargs: Any + ) -> LROPoller[None]: + """Moves resources from one resource group to another resource group. + + The resources to move must be in the same source resource group. The target resource group may + be in a different subscription. When moving resources, both the source group and the target + group are locked for the duration of the operation. Write and delete operations are blocked on + the groups until the move completes. + + :param source_resource_group_name: The name of the resource group containing the resources to + move. Required. + :type source_resource_group_name: str + :param parameters: Parameters for moving resources. Required. + :type parameters: IO + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be ARMPolling. Pass in False for this + operation to not poll, or pass in your own initialized polling object for a personal polling + strategy. + :paramtype polling: bool or ~azure.core.polling.PollingMethod + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of LROPoller that returns either None or the result of cls(response) + :rtype: ~azure.core.polling.LROPoller[None] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace + def begin_move_resources( + self, source_resource_group_name: str, parameters: Union[_models.ResourcesMoveInfo, IO], **kwargs: Any + ) -> LROPoller[None]: + """Moves resources from one resource group to another resource group. + + The resources to move must be in the same source resource group. The target resource group may + be in a different subscription. When moving resources, both the source group and the target + group are locked for the duration of the operation. Write and delete operations are blocked on + the groups until the move completes. + + :param source_resource_group_name: The name of the resource group containing the resources to + move. Required. + :type source_resource_group_name: str + :param parameters: Parameters for moving resources. Is either a model type or a IO type. + Required. + :type parameters: ~azure.mgmt.resource.resources.v2021_01_01.models.ResourcesMoveInfo or IO + :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. + Default value is None. + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be ARMPolling. Pass in False for this + operation to not poll, or pass in your own initialized polling object for a personal polling + strategy. + :paramtype polling: bool or ~azure.core.polling.PollingMethod + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of LROPoller that returns either None or the result of cls(response) + :rtype: ~azure.core.polling.LROPoller[None] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _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-01-01")) # type: str + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[None] + polling = kwargs.pop("polling", True) # type: Union[bool, PollingMethod] + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token = kwargs.pop("continuation_token", None) # type: Optional[str] if cont_token is None: - raw_result = self._move_resources_initial( + raw_result = self._move_resources_initial( # type: ignore source_resource_group_name=source_resource_group_name, parameters=parameters, api_version=api_version, content_type=content_type, - cls=lambda x,y,z: x, + cls=lambda x, y, z: x, + headers=_headers, + params=_params, **kwargs ) - kwargs.pop('error_map', None) + kwargs.pop("error_map", None) - def get_long_running_output(pipeline_response): + def get_long_running_output(pipeline_response): # pylint: disable=inconsistent-return-statements if cls: return cls(pipeline_response, None, {}) - - if polling is True: polling_method = ARMPolling(lro_delay, **kwargs) - elif polling is False: polling_method = NoPolling() - else: polling_method = polling + if polling is True: + polling_method = cast(PollingMethod, ARMPolling(lro_delay, **kwargs)) # type: PollingMethod + elif polling is False: + polling_method = cast(PollingMethod, NoPolling()) + else: + polling_method = polling if cont_token: return LROPoller.from_continuation_token( polling_method=polling_method, continuation_token=cont_token, client=self._client, - deserialization_callback=get_long_running_output + deserialization_callback=get_long_running_output, ) return LROPoller(self._client, raw_result, get_long_running_output, polling_method) - begin_move_resources.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{sourceResourceGroupName}/moveResources"} # type: ignore + begin_move_resources.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{sourceResourceGroupName}/moveResources"} # type: ignore def _validate_move_resources_initial( # pylint: disable=inconsistent-return-statements - self, - source_resource_group_name: str, - parameters: "_models.ResourcesMoveInfo", - **kwargs: Any + self, source_resource_group_name: str, parameters: Union[_models.ResourcesMoveInfo, IO], **kwargs: Any ) -> None: - cls = kwargs.pop('cls', None) # type: ClsType[None] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) - api_version = kwargs.pop('api_version', "2021-01-01") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - _json = self._serialize.body(parameters, 'ResourcesMoveInfo') + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-01-01")) # type: str + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[None] - request = build_resources_validate_move_resources_request_initial( + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(parameters, (IO, bytes)): + _content = parameters + else: + _json = self._serialize.body(parameters, "ResourcesMoveInfo") + + request = build_resources_validate_move_resources_request( source_resource_group_name=source_resource_group_name, subscription_id=self._config.subscription_id, api_version=api_version, content_type=content_type, json=_json, - template_url=self._validate_move_resources_initial.metadata['url'], + content=_content, + template_url=self._validate_move_resources_initial.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [202, 204]: @@ -8389,14 +9148,15 @@ def _validate_move_resources_initial( # pylint: disable=inconsistent-return-sta if cls: return cls(pipeline_response, None, {}) - _validate_move_resources_initial.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{sourceResourceGroupName}/validateMoveResources"} # type: ignore + _validate_move_resources_initial.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{sourceResourceGroupName}/validateMoveResources"} # type: ignore - - @distributed_trace - def begin_validate_move_resources( # pylint: disable=inconsistent-return-statements + @overload + def begin_validate_move_resources( self, source_resource_group_name: str, - parameters: "_models.ResourcesMoveInfo", + parameters: _models.ResourcesMoveInfo, + *, + content_type: str = "application/json", **kwargs: Any ) -> LROPoller[None]: """Validates whether resources can be moved from one resource group to another resource group. @@ -8409,10 +9169,13 @@ def begin_validate_move_resources( # pylint: disable=inconsistent-return-statem operation. :param source_resource_group_name: The name of the resource group containing the resources to - validate for move. + validate for move. Required. :type source_resource_group_name: str - :param parameters: Parameters for moving resources. + :param parameters: Parameters for moving resources. Required. :type parameters: ~azure.mgmt.resource.resources.v2021_01_01.models.ResourcesMoveInfo + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str :keyword callable cls: A custom type or function that will be passed the direct response :keyword str continuation_token: A continuation token to restart a poller from a saved state. :keyword polling: By default, your polling method will be ARMPolling. Pass in False for this @@ -8423,55 +9186,124 @@ def begin_validate_move_resources( # pylint: disable=inconsistent-return-statem Retry-After header is present. :return: An instance of LROPoller that returns either None or the result of cls(response) :rtype: ~azure.core.polling.LROPoller[None] - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - api_version = kwargs.pop('api_version', "2021-01-01") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] - polling = kwargs.pop('polling', True) # type: Union[bool, PollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType[None] - lro_delay = kwargs.pop( - 'polling_interval', - self._config.polling_interval - ) - cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] + + @overload + def begin_validate_move_resources( + self, source_resource_group_name: str, parameters: IO, *, content_type: str = "application/json", **kwargs: Any + ) -> LROPoller[None]: + """Validates whether resources can be moved from one resource group to another resource group. + + This operation checks whether the specified resources can be moved to the target. The resources + to move must be in the same source resource group. The target resource group may be in a + different subscription. If validation succeeds, it returns HTTP response code 204 (no content). + If validation fails, it returns HTTP response code 409 (Conflict) with an error message. + Retrieve the URL in the Location header value to check the result of the long-running + operation. + + :param source_resource_group_name: The name of the resource group containing the resources to + validate for move. Required. + :type source_resource_group_name: str + :param parameters: Parameters for moving resources. Required. + :type parameters: IO + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be ARMPolling. Pass in False for this + operation to not poll, or pass in your own initialized polling object for a personal polling + strategy. + :paramtype polling: bool or ~azure.core.polling.PollingMethod + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of LROPoller that returns either None or the result of cls(response) + :rtype: ~azure.core.polling.LROPoller[None] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace + def begin_validate_move_resources( + self, source_resource_group_name: str, parameters: Union[_models.ResourcesMoveInfo, IO], **kwargs: Any + ) -> LROPoller[None]: + """Validates whether resources can be moved from one resource group to another resource group. + + This operation checks whether the specified resources can be moved to the target. The resources + to move must be in the same source resource group. The target resource group may be in a + different subscription. If validation succeeds, it returns HTTP response code 204 (no content). + If validation fails, it returns HTTP response code 409 (Conflict) with an error message. + Retrieve the URL in the Location header value to check the result of the long-running + operation. + + :param source_resource_group_name: The name of the resource group containing the resources to + validate for move. Required. + :type source_resource_group_name: str + :param parameters: Parameters for moving resources. Is either a model type or a IO type. + Required. + :type parameters: ~azure.mgmt.resource.resources.v2021_01_01.models.ResourcesMoveInfo or IO + :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. + Default value is None. + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be ARMPolling. Pass in False for this + operation to not poll, or pass in your own initialized polling object for a personal polling + strategy. + :paramtype polling: bool or ~azure.core.polling.PollingMethod + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of LROPoller that returns either None or the result of cls(response) + :rtype: ~azure.core.polling.LROPoller[None] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _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-01-01")) # type: str + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[None] + polling = kwargs.pop("polling", True) # type: Union[bool, PollingMethod] + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token = kwargs.pop("continuation_token", None) # type: Optional[str] if cont_token is None: - raw_result = self._validate_move_resources_initial( + raw_result = self._validate_move_resources_initial( # type: ignore source_resource_group_name=source_resource_group_name, parameters=parameters, api_version=api_version, content_type=content_type, - cls=lambda x,y,z: x, + cls=lambda x, y, z: x, + headers=_headers, + params=_params, **kwargs ) - kwargs.pop('error_map', None) + kwargs.pop("error_map", None) - def get_long_running_output(pipeline_response): + def get_long_running_output(pipeline_response): # pylint: disable=inconsistent-return-statements if cls: return cls(pipeline_response, None, {}) - - if polling is True: polling_method = ARMPolling(lro_delay, **kwargs) - elif polling is False: polling_method = NoPolling() - else: polling_method = polling + if polling is True: + polling_method = cast(PollingMethod, ARMPolling(lro_delay, **kwargs)) # type: PollingMethod + elif polling is False: + polling_method = cast(PollingMethod, NoPolling()) + else: + polling_method = polling if cont_token: return LROPoller.from_continuation_token( polling_method=polling_method, continuation_token=cont_token, client=self._client, - deserialization_callback=get_long_running_output + deserialization_callback=get_long_running_output, ) return LROPoller(self._client, raw_result, get_long_running_output, polling_method) - begin_validate_move_resources.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{sourceResourceGroupName}/validateMoveResources"} # type: ignore + begin_validate_move_resources.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{sourceResourceGroupName}/validateMoveResources"} # type: ignore @distributed_trace def list( - self, - filter: Optional[str] = None, - expand: Optional[str] = None, - top: Optional[int] = None, - **kwargs: Any - ) -> Iterable["_models.ResourceListResult"]: + self, filter: Optional[str] = None, expand: Optional[str] = None, top: Optional[int] = None, **kwargs: Any + ) -> Iterable["_models.GenericResourceExpanded"]: """Get all the resources in a subscription. :param filter: The filter to apply on the operation.:code:`
`:code:`
`The properties you @@ -8498,40 +9330,50 @@ def list( value is None. :type top: int :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either ResourceListResult or the result of cls(response) + :return: An iterator like instance of either GenericResourceExpanded or the result of + cls(response) :rtype: - ~azure.core.paging.ItemPaged[~azure.mgmt.resource.resources.v2021_01_01.models.ResourceListResult] - :raises: ~azure.core.exceptions.HttpResponseError + ~azure.core.paging.ItemPaged[~azure.mgmt.resource.resources.v2021_01_01.models.GenericResourceExpanded] + :raises ~azure.core.exceptions.HttpResponseError: """ - api_version = kwargs.pop('api_version', "2021-01-01") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-01-01")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[_models.ResourceListResult] - cls = kwargs.pop('cls', None) # type: ClsType["_models.ResourceListResult"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) + def prepare_request(next_link=None): if not next_link: - + request = build_resources_list_request( subscription_id=self._config.subscription_id, - api_version=api_version, filter=filter, expand=expand, top=top, - template_url=self.list.metadata['url'], + 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.url = self._client.format_url(request.url) # type: ignore else: - - request = build_resources_list_request( - subscription_id=self._config.subscription_id, - template_url=next_link, - ) + # make call to next link with the client's api-version + _parsed_next_link = urlparse(next_link) + _next_request_params = case_insensitive_dict(parse_qs(_parsed_next_link.query)) + _next_request_params["api-version"] = self._config.api_version + request = HttpRequest("GET", urljoin(next_link, _parsed_next_link.path), params=_next_request_params) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore request.method = "GET" return request @@ -8545,10 +9387,8 @@ def extract_data(pipeline_response): def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) response = pipeline_response.http_response @@ -8558,11 +9398,9 @@ def get_next(next_link=None): return pipeline_response + return ItemPaged(get_next, extract_data) - return ItemPaged( - get_next, extract_data - ) - list.metadata = {'url': "/subscriptions/{subscriptionId}/resources"} # type: ignore + list.metadata = {"url": "/subscriptions/{subscriptionId}/resources"} # type: ignore @distributed_trace def check_existence( @@ -8578,30 +9416,36 @@ def check_existence( """Checks whether a resource exists. :param resource_group_name: The name of the resource group containing the resource to check. - The name is case insensitive. + The name is case insensitive. Required. :type resource_group_name: str - :param resource_provider_namespace: The resource provider of the resource to check. + :param resource_provider_namespace: The resource provider of the resource to check. Required. :type resource_provider_namespace: str - :param parent_resource_path: The parent resource identity. + :param parent_resource_path: The parent resource identity. Required. :type parent_resource_path: str - :param resource_type: The resource type. + :param resource_type: The resource type. Required. :type resource_type: str - :param resource_name: The name of the resource to check whether it exists. + :param resource_name: The name of the resource to check whether it exists. Required. :type resource_name: str - :param api_version: The API version to use for the operation. + :param api_version: The API version to use for the operation. Required. :type api_version: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: bool, or the result of cls(response) + :return: bool or the result of cls(response) :rtype: bool - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType[None] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = kwargs.pop("params", {}) or {} + + cls = kwargs.pop("cls", None) # type: ClsType[None] - request = build_resources_check_existence_request( resource_group_name=resource_group_name, resource_provider_namespace=resource_provider_namespace, @@ -8610,16 +9454,17 @@ def check_existence( resource_name=resource_name, subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.check_existence.metadata['url'], + template_url=self.check_existence.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [204, 404]: @@ -8630,8 +9475,7 @@ def check_existence( return cls(pipeline_response, None, {}) return 200 <= response.status_code <= 299 - check_existence.metadata = {'url': "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{parentResourcePath}/{resourceType}/{resourceName}"} # type: ignore - + check_existence.metadata = {"url": "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{parentResourcePath}/{resourceType}/{resourceName}"} # type: ignore def _delete_initial( # pylint: disable=inconsistent-return-statements self, @@ -8643,14 +9487,20 @@ def _delete_initial( # pylint: disable=inconsistent-return-statements api_version: str, **kwargs: Any ) -> None: - cls = kwargs.pop('cls', None) # type: ClsType[None] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = kwargs.pop("params", {}) or {} - - request = build_resources_delete_request_initial( + cls = kwargs.pop("cls", None) # type: ClsType[None] + + request = build_resources_delete_request( resource_group_name=resource_group_name, resource_provider_namespace=resource_provider_namespace, parent_resource_path=parent_resource_path, @@ -8658,16 +9508,17 @@ def _delete_initial( # pylint: disable=inconsistent-return-statements resource_name=resource_name, subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self._delete_initial.metadata['url'], + template_url=self._delete_initial.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200, 202, 204]: @@ -8677,11 +9528,10 @@ def _delete_initial( # pylint: disable=inconsistent-return-statements if cls: return cls(pipeline_response, None, {}) - _delete_initial.metadata = {'url': "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{parentResourcePath}/{resourceType}/{resourceName}"} # type: ignore - + _delete_initial.metadata = {"url": "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{parentResourcePath}/{resourceType}/{resourceName}"} # type: ignore @distributed_trace - def begin_delete( # pylint: disable=inconsistent-return-statements + def begin_delete( self, resource_group_name: str, resource_provider_namespace: str, @@ -8694,17 +9544,17 @@ def begin_delete( # pylint: disable=inconsistent-return-statements """Deletes a resource. :param resource_group_name: The name of the resource group that contains the resource to - delete. The name is case insensitive. + delete. The name is case insensitive. Required. :type resource_group_name: str - :param resource_provider_namespace: The namespace of the resource provider. + :param resource_provider_namespace: The namespace of the resource provider. Required. :type resource_provider_namespace: str - :param parent_resource_path: The parent resource identity. + :param parent_resource_path: The parent resource identity. Required. :type parent_resource_path: str - :param resource_type: The resource type. + :param resource_type: The resource type. Required. :type resource_type: str - :param resource_name: The name of the resource to delete. + :param resource_name: The name of the resource to delete. Required. :type resource_name: str - :param api_version: The API version to use for the operation. + :param api_version: The API version to use for the operation. Required. :type api_version: str :keyword callable cls: A custom type or function that will be passed the direct response :keyword str continuation_token: A continuation token to restart a poller from a saved state. @@ -8716,46 +9566,50 @@ def begin_delete( # pylint: disable=inconsistent-return-statements Retry-After header is present. :return: An instance of LROPoller that returns either None or the result of cls(response) :rtype: ~azure.core.polling.LROPoller[None] - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - polling = kwargs.pop('polling', True) # type: Union[bool, PollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType[None] - lro_delay = kwargs.pop( - 'polling_interval', - self._config.polling_interval - ) - cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] + _headers = kwargs.pop("headers", {}) or {} + _params = kwargs.pop("params", {}) or {} + + cls = kwargs.pop("cls", None) # type: ClsType[None] + polling = kwargs.pop("polling", True) # type: Union[bool, PollingMethod] + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token = kwargs.pop("continuation_token", None) # type: Optional[str] if cont_token is None: - raw_result = self._delete_initial( + raw_result = self._delete_initial( # type: ignore resource_group_name=resource_group_name, resource_provider_namespace=resource_provider_namespace, parent_resource_path=parent_resource_path, resource_type=resource_type, resource_name=resource_name, api_version=api_version, - cls=lambda x,y,z: x, + cls=lambda x, y, z: x, + headers=_headers, + params=_params, **kwargs ) - kwargs.pop('error_map', None) + kwargs.pop("error_map", None) - def get_long_running_output(pipeline_response): + def get_long_running_output(pipeline_response): # pylint: disable=inconsistent-return-statements if cls: return cls(pipeline_response, None, {}) - - if polling is True: polling_method = ARMPolling(lro_delay, **kwargs) - elif polling is False: polling_method = NoPolling() - else: polling_method = polling + if polling is True: + polling_method = cast(PollingMethod, ARMPolling(lro_delay, **kwargs)) # type: PollingMethod + elif polling is False: + polling_method = cast(PollingMethod, NoPolling()) + else: + polling_method = polling if cont_token: return LROPoller.from_continuation_token( polling_method=polling_method, continuation_token=cont_token, client=self._client, - deserialization_callback=get_long_running_output + deserialization_callback=get_long_running_output, ) return LROPoller(self._client, raw_result, get_long_running_output, polling_method) - begin_delete.metadata = {'url': "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{parentResourcePath}/{resourceType}/{resourceName}"} # type: ignore + begin_delete.metadata = {"url": "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{parentResourcePath}/{resourceType}/{resourceName}"} # type: ignore def _create_or_update_initial( self, @@ -8765,39 +9619,53 @@ def _create_or_update_initial( resource_type: str, resource_name: str, api_version: str, - parameters: "_models.GenericResource", + parameters: Union[_models.GenericResource, IO], **kwargs: Any - ) -> Optional["_models.GenericResource"]: - cls = kwargs.pop('cls', None) # type: ClsType[Optional["_models.GenericResource"]] + ) -> Optional[_models.GenericResource]: error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = kwargs.pop("params", {}) or {} - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[Optional[_models.GenericResource]] - _json = self._serialize.body(parameters, 'GenericResource') + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(parameters, (IO, bytes)): + _content = parameters + else: + _json = self._serialize.body(parameters, "GenericResource") - request = build_resources_create_or_update_request_initial( + request = build_resources_create_or_update_request( resource_group_name=resource_group_name, resource_provider_namespace=resource_provider_namespace, parent_resource_path=parent_resource_path, resource_type=resource_type, resource_name=resource_name, subscription_id=self._config.subscription_id, - content_type=content_type, api_version=api_version, + content_type=content_type, json=_json, - template_url=self._create_or_update_initial.metadata['url'], + content=_content, + template_url=self._create_or_update_initial.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200, 201, 202]: @@ -8806,20 +9674,19 @@ def _create_or_update_initial( deserialized = None if response.status_code == 200: - deserialized = self._deserialize('GenericResource', pipeline_response) + deserialized = self._deserialize("GenericResource", pipeline_response) if response.status_code == 201: - deserialized = self._deserialize('GenericResource', pipeline_response) + deserialized = self._deserialize("GenericResource", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - _create_or_update_initial.metadata = {'url': "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{parentResourcePath}/{resourceType}/{resourceName}"} # type: ignore - + _create_or_update_initial.metadata = {"url": "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{parentResourcePath}/{resourceType}/{resourceName}"} # type: ignore - @distributed_trace + @overload def begin_create_or_update( self, resource_group_name: str, @@ -8828,26 +9695,31 @@ def begin_create_or_update( resource_type: str, resource_name: str, api_version: str, - parameters: "_models.GenericResource", + parameters: _models.GenericResource, + *, + content_type: str = "application/json", **kwargs: Any - ) -> LROPoller["_models.GenericResource"]: + ) -> LROPoller[_models.GenericResource]: """Creates a resource. :param resource_group_name: The name of the resource group for the resource. The name is case - insensitive. + insensitive. Required. :type resource_group_name: str - :param resource_provider_namespace: The namespace of the resource provider. + :param resource_provider_namespace: The namespace of the resource provider. Required. :type resource_provider_namespace: str - :param parent_resource_path: The parent resource identity. + :param parent_resource_path: The parent resource identity. Required. :type parent_resource_path: str - :param resource_type: The resource type of the resource to create. + :param resource_type: The resource type of the resource to create. Required. :type resource_type: str - :param resource_name: The name of the resource to create. + :param resource_name: The name of the resource to create. Required. :type resource_name: str - :param api_version: The API version to use for the operation. + :param api_version: The API version to use for the operation. Required. :type api_version: str - :param parameters: Parameters for creating or updating the resource. + :param parameters: Parameters for creating or updating the resource. Required. :type parameters: ~azure.mgmt.resource.resources.v2021_01_01.models.GenericResource + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str :keyword callable cls: A custom type or function that will be passed the direct response :keyword str continuation_token: A continuation token to restart a poller from a saved state. :keyword polling: By default, your polling method will be ARMPolling. Pass in False for this @@ -8860,54 +9732,11 @@ def begin_create_or_update( cls(response) :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.resource.resources.v2021_01_01.models.GenericResource] - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] - polling = kwargs.pop('polling', True) # type: Union[bool, PollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType["_models.GenericResource"] - lro_delay = kwargs.pop( - 'polling_interval', - self._config.polling_interval - ) - cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] - if cont_token is None: - raw_result = self._create_or_update_initial( - resource_group_name=resource_group_name, - resource_provider_namespace=resource_provider_namespace, - parent_resource_path=parent_resource_path, - resource_type=resource_type, - resource_name=resource_name, - api_version=api_version, - parameters=parameters, - content_type=content_type, - cls=lambda x,y,z: x, - **kwargs - ) - kwargs.pop('error_map', None) - - def get_long_running_output(pipeline_response): - response = pipeline_response.http_response - deserialized = self._deserialize('GenericResource', pipeline_response) - if cls: - return cls(pipeline_response, deserialized, {}) - return deserialized - - if polling is True: polling_method = ARMPolling(lro_delay, **kwargs) - elif polling is False: polling_method = NoPolling() - else: polling_method = polling - if cont_token: - return LROPoller.from_continuation_token( - polling_method=polling_method, - continuation_token=cont_token, - client=self._client, - deserialization_callback=get_long_running_output - ) - return LROPoller(self._client, raw_result, get_long_running_output, polling_method) - - begin_create_or_update.metadata = {'url': "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{parentResourcePath}/{resourceType}/{resourceName}"} # type: ignore - - def _update_initial( + @overload + def begin_create_or_update( self, resource_group_name: str, resource_provider_namespace: str, @@ -8915,56 +9744,310 @@ def _update_initial( resource_type: str, resource_name: str, api_version: str, - parameters: "_models.GenericResource", + parameters: IO, + *, + content_type: str = "application/json", **kwargs: Any - ) -> Optional["_models.GenericResource"]: - cls = kwargs.pop('cls', None) # type: ClsType[Optional["_models.GenericResource"]] - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {})) - - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] - - _json = self._serialize.body(parameters, 'GenericResource') - - request = build_resources_update_request_initial( - resource_group_name=resource_group_name, - resource_provider_namespace=resource_provider_namespace, - parent_resource_path=parent_resource_path, - resource_type=resource_type, - resource_name=resource_name, - subscription_id=self._config.subscription_id, - content_type=content_type, - api_version=api_version, - json=_json, - template_url=self._update_initial.metadata['url'], - ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) - - pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs - ) - response = pipeline_response.http_response + ) -> LROPoller[_models.GenericResource]: + """Creates a resource. - if response.status_code not in [200, 202]: + :param resource_group_name: The name of the resource group for the resource. The name is case + insensitive. Required. + :type resource_group_name: str + :param resource_provider_namespace: The namespace of the resource provider. Required. + :type resource_provider_namespace: str + :param parent_resource_path: The parent resource identity. Required. + :type parent_resource_path: str + :param resource_type: The resource type of the resource to create. Required. + :type resource_type: str + :param resource_name: The name of the resource to create. Required. + :type resource_name: str + :param api_version: The API version to use for the operation. Required. + :type api_version: str + :param parameters: Parameters for creating or updating the resource. Required. + :type parameters: IO + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be ARMPolling. Pass in False for this + operation to not poll, or pass in your own initialized polling object for a personal polling + strategy. + :paramtype polling: bool or ~azure.core.polling.PollingMethod + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of LROPoller that returns either GenericResource or the result of + cls(response) + :rtype: + ~azure.core.polling.LROPoller[~azure.mgmt.resource.resources.v2021_01_01.models.GenericResource] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace + def begin_create_or_update( + self, + resource_group_name: str, + resource_provider_namespace: str, + parent_resource_path: str, + resource_type: str, + resource_name: str, + api_version: str, + parameters: Union[_models.GenericResource, IO], + **kwargs: Any + ) -> LROPoller[_models.GenericResource]: + """Creates a resource. + + :param resource_group_name: The name of the resource group for the resource. The name is case + insensitive. Required. + :type resource_group_name: str + :param resource_provider_namespace: The namespace of the resource provider. Required. + :type resource_provider_namespace: str + :param parent_resource_path: The parent resource identity. Required. + :type parent_resource_path: str + :param resource_type: The resource type of the resource to create. Required. + :type resource_type: str + :param resource_name: The name of the resource to create. Required. + :type resource_name: str + :param api_version: The API version to use for the operation. Required. + :type api_version: str + :param parameters: Parameters for creating or updating the resource. Is either a model type or + a IO type. Required. + :type parameters: ~azure.mgmt.resource.resources.v2021_01_01.models.GenericResource or IO + :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. + Default value is None. + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be ARMPolling. Pass in False for this + operation to not poll, or pass in your own initialized polling object for a personal polling + strategy. + :paramtype polling: bool or ~azure.core.polling.PollingMethod + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of LROPoller that returns either GenericResource or the result of + cls(response) + :rtype: + ~azure.core.polling.LROPoller[~azure.mgmt.resource.resources.v2021_01_01.models.GenericResource] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = kwargs.pop("params", {}) or {} + + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.GenericResource] + polling = kwargs.pop("polling", True) # type: Union[bool, PollingMethod] + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token = kwargs.pop("continuation_token", None) # type: Optional[str] + if cont_token is None: + raw_result = self._create_or_update_initial( # type: ignore + resource_group_name=resource_group_name, + resource_provider_namespace=resource_provider_namespace, + parent_resource_path=parent_resource_path, + resource_type=resource_type, + resource_name=resource_name, + api_version=api_version, + parameters=parameters, + content_type=content_type, + cls=lambda x, y, z: x, + headers=_headers, + params=_params, + **kwargs + ) + kwargs.pop("error_map", None) + + def get_long_running_output(pipeline_response): + deserialized = self._deserialize("GenericResource", pipeline_response) + if cls: + return cls(pipeline_response, deserialized, {}) + return deserialized + + if polling is True: + polling_method = cast(PollingMethod, ARMPolling(lro_delay, **kwargs)) # type: PollingMethod + elif polling is False: + polling_method = cast(PollingMethod, NoPolling()) + else: + polling_method = polling + if cont_token: + return LROPoller.from_continuation_token( + polling_method=polling_method, + continuation_token=cont_token, + client=self._client, + deserialization_callback=get_long_running_output, + ) + return LROPoller(self._client, raw_result, get_long_running_output, polling_method) + + begin_create_or_update.metadata = {"url": "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{parentResourcePath}/{resourceType}/{resourceName}"} # type: ignore + + def _update_initial( + self, + resource_group_name: str, + resource_provider_namespace: str, + parent_resource_path: str, + resource_type: str, + resource_name: str, + api_version: str, + parameters: Union[_models.GenericResource, IO], + **kwargs: Any + ) -> Optional[_models.GenericResource]: + error_map = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = kwargs.pop("params", {}) or {} + + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[Optional[_models.GenericResource]] + + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(parameters, (IO, bytes)): + _content = parameters + else: + _json = self._serialize.body(parameters, "GenericResource") + + request = build_resources_update_request( + resource_group_name=resource_group_name, + resource_provider_namespace=resource_provider_namespace, + parent_resource_path=parent_resource_path, + resource_type=resource_type, + resource_name=resource_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + content_type=content_type, + json=_json, + content=_content, + template_url=self._update_initial.metadata["url"], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore + + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [200, 202]: map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) deserialized = None if response.status_code == 200: - deserialized = self._deserialize('GenericResource', pipeline_response) + deserialized = self._deserialize("GenericResource", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - _update_initial.metadata = {'url': "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{parentResourcePath}/{resourceType}/{resourceName}"} # type: ignore + _update_initial.metadata = {"url": "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{parentResourcePath}/{resourceType}/{resourceName}"} # type: ignore + + @overload + def begin_update( + self, + resource_group_name: str, + resource_provider_namespace: str, + parent_resource_path: str, + resource_type: str, + resource_name: str, + api_version: str, + parameters: _models.GenericResource, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> LROPoller[_models.GenericResource]: + """Updates a resource. + + :param resource_group_name: The name of the resource group for the resource. The name is case + insensitive. Required. + :type resource_group_name: str + :param resource_provider_namespace: The namespace of the resource provider. Required. + :type resource_provider_namespace: str + :param parent_resource_path: The parent resource identity. Required. + :type parent_resource_path: str + :param resource_type: The resource type of the resource to update. Required. + :type resource_type: str + :param resource_name: The name of the resource to update. Required. + :type resource_name: str + :param api_version: The API version to use for the operation. Required. + :type api_version: str + :param parameters: Parameters for updating the resource. Required. + :type parameters: ~azure.mgmt.resource.resources.v2021_01_01.models.GenericResource + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be ARMPolling. Pass in False for this + operation to not poll, or pass in your own initialized polling object for a personal polling + strategy. + :paramtype polling: bool or ~azure.core.polling.PollingMethod + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of LROPoller that returns either GenericResource or the result of + cls(response) + :rtype: + ~azure.core.polling.LROPoller[~azure.mgmt.resource.resources.v2021_01_01.models.GenericResource] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + def begin_update( + self, + resource_group_name: str, + resource_provider_namespace: str, + parent_resource_path: str, + resource_type: str, + resource_name: str, + api_version: str, + parameters: IO, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> LROPoller[_models.GenericResource]: + """Updates a resource. + :param resource_group_name: The name of the resource group for the resource. The name is case + insensitive. Required. + :type resource_group_name: str + :param resource_provider_namespace: The namespace of the resource provider. Required. + :type resource_provider_namespace: str + :param parent_resource_path: The parent resource identity. Required. + :type parent_resource_path: str + :param resource_type: The resource type of the resource to update. Required. + :type resource_type: str + :param resource_name: The name of the resource to update. Required. + :type resource_name: str + :param api_version: The API version to use for the operation. Required. + :type api_version: str + :param parameters: Parameters for updating the resource. Required. + :type parameters: IO + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be ARMPolling. Pass in False for this + operation to not poll, or pass in your own initialized polling object for a personal polling + strategy. + :paramtype polling: bool or ~azure.core.polling.PollingMethod + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of LROPoller that returns either GenericResource or the result of + cls(response) + :rtype: + ~azure.core.polling.LROPoller[~azure.mgmt.resource.resources.v2021_01_01.models.GenericResource] + :raises ~azure.core.exceptions.HttpResponseError: + """ @distributed_trace def begin_update( @@ -8975,26 +10058,30 @@ def begin_update( resource_type: str, resource_name: str, api_version: str, - parameters: "_models.GenericResource", + parameters: Union[_models.GenericResource, IO], **kwargs: Any - ) -> LROPoller["_models.GenericResource"]: + ) -> LROPoller[_models.GenericResource]: """Updates a resource. :param resource_group_name: The name of the resource group for the resource. The name is case - insensitive. + insensitive. Required. :type resource_group_name: str - :param resource_provider_namespace: The namespace of the resource provider. + :param resource_provider_namespace: The namespace of the resource provider. Required. :type resource_provider_namespace: str - :param parent_resource_path: The parent resource identity. + :param parent_resource_path: The parent resource identity. Required. :type parent_resource_path: str - :param resource_type: The resource type of the resource to update. + :param resource_type: The resource type of the resource to update. Required. :type resource_type: str - :param resource_name: The name of the resource to update. + :param resource_name: The name of the resource to update. Required. :type resource_name: str - :param api_version: The API version to use for the operation. + :param api_version: The API version to use for the operation. Required. :type api_version: str - :param parameters: Parameters for updating the resource. - :type parameters: ~azure.mgmt.resource.resources.v2021_01_01.models.GenericResource + :param parameters: Parameters for updating the resource. Is either a model type or a IO type. + Required. + :type parameters: ~azure.mgmt.resource.resources.v2021_01_01.models.GenericResource or IO + :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. + Default value is None. + :paramtype content_type: str :keyword callable cls: A custom type or function that will be passed the direct response :keyword str continuation_token: A continuation token to restart a poller from a saved state. :keyword polling: By default, your polling method will be ARMPolling. Pass in False for this @@ -9007,18 +10094,18 @@ def begin_update( cls(response) :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.resource.resources.v2021_01_01.models.GenericResource] - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] - polling = kwargs.pop('polling', True) # type: Union[bool, PollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType["_models.GenericResource"] - lro_delay = kwargs.pop( - 'polling_interval', - self._config.polling_interval - ) - cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = kwargs.pop("params", {}) or {} + + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.GenericResource] + polling = kwargs.pop("polling", True) # type: Union[bool, PollingMethod] + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token = kwargs.pop("continuation_token", None) # type: Optional[str] if cont_token is None: - raw_result = self._update_initial( + raw_result = self._update_initial( # type: ignore resource_group_name=resource_group_name, resource_provider_namespace=resource_provider_namespace, parent_resource_path=parent_resource_path, @@ -9027,32 +10114,35 @@ def begin_update( api_version=api_version, parameters=parameters, content_type=content_type, - cls=lambda x,y,z: x, + cls=lambda x, y, z: x, + headers=_headers, + params=_params, **kwargs ) - kwargs.pop('error_map', None) + kwargs.pop("error_map", None) def get_long_running_output(pipeline_response): - response = pipeline_response.http_response - deserialized = self._deserialize('GenericResource', pipeline_response) + deserialized = self._deserialize("GenericResource", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - - if polling is True: polling_method = ARMPolling(lro_delay, **kwargs) - elif polling is False: polling_method = NoPolling() - else: polling_method = polling + if polling is True: + polling_method = cast(PollingMethod, ARMPolling(lro_delay, **kwargs)) # type: PollingMethod + elif polling is False: + polling_method = cast(PollingMethod, NoPolling()) + else: + polling_method = polling if cont_token: return LROPoller.from_continuation_token( polling_method=polling_method, continuation_token=cont_token, client=self._client, - deserialization_callback=get_long_running_output + deserialization_callback=get_long_running_output, ) return LROPoller(self._client, raw_result, get_long_running_output, polling_method) - begin_update.metadata = {'url': "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{parentResourcePath}/{resourceType}/{resourceName}"} # type: ignore + begin_update.metadata = {"url": "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{parentResourcePath}/{resourceType}/{resourceName}"} # type: ignore @distributed_trace def get( @@ -9064,34 +10154,40 @@ def get( resource_name: str, api_version: str, **kwargs: Any - ) -> "_models.GenericResource": + ) -> _models.GenericResource: """Gets a resource. :param resource_group_name: The name of the resource group containing the resource to get. The - name is case insensitive. + name is case insensitive. Required. :type resource_group_name: str - :param resource_provider_namespace: The namespace of the resource provider. + :param resource_provider_namespace: The namespace of the resource provider. Required. :type resource_provider_namespace: str - :param parent_resource_path: The parent resource identity. + :param parent_resource_path: The parent resource identity. Required. :type parent_resource_path: str - :param resource_type: The resource type of the resource. + :param resource_type: The resource type of the resource. Required. :type resource_type: str - :param resource_name: The name of the resource to get. + :param resource_name: The name of the resource to get. Required. :type resource_name: str - :param api_version: The API version to use for the operation. + :param api_version: The API version to use for the operation. Required. :type api_version: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: GenericResource, or the result of cls(response) + :return: GenericResource or the result of cls(response) :rtype: ~azure.mgmt.resource.resources.v2021_01_01.models.GenericResource - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.GenericResource"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = kwargs.pop("params", {}) or {} + + cls = kwargs.pop("cls", None) # type: ClsType[_models.GenericResource] - request = build_resources_get_request( resource_group_name=resource_group_name, resource_provider_namespace=resource_provider_namespace, @@ -9100,72 +10196,75 @@ def get( resource_name=resource_name, subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.get.metadata['url'], + template_url=self.get.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) - deserialized = self._deserialize('GenericResource', pipeline_response) + deserialized = self._deserialize("GenericResource", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - get.metadata = {'url': "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{parentResourcePath}/{resourceType}/{resourceName}"} # type: ignore - + get.metadata = {"url": "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{parentResourcePath}/{resourceType}/{resourceName}"} # type: ignore @distributed_trace - def check_existence_by_id( - self, - resource_id: str, - api_version: str, - **kwargs: Any - ) -> bool: + def check_existence_by_id(self, resource_id: str, api_version: str, **kwargs: Any) -> bool: """Checks by ID whether a resource exists. :param resource_id: The fully qualified ID of the resource, including the resource name and resource type. Use the format, /subscriptions/{guid}/resourceGroups/{resource-group-name}/{resource-provider-namespace}/{resource-type}/{resource-name}. + Required. :type resource_id: str - :param api_version: The API version to use for the operation. + :param api_version: The API version to use for the operation. Required. :type api_version: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: bool, or the result of cls(response) + :return: bool or the result of cls(response) :rtype: bool - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType[None] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = kwargs.pop("params", {}) or {} + + cls = kwargs.pop("cls", None) # type: ClsType[None] - request = build_resources_check_existence_by_id_request( resource_id=resource_id, api_version=api_version, - template_url=self.check_existence_by_id.metadata['url'], + template_url=self.check_existence_by_id.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [204, 404]: @@ -9176,35 +10275,38 @@ def check_existence_by_id( return cls(pipeline_response, None, {}) return 200 <= response.status_code <= 299 - check_existence_by_id.metadata = {'url': "/{resourceId}"} # type: ignore - + check_existence_by_id.metadata = {"url": "/{resourceId}"} # type: ignore def _delete_by_id_initial( # pylint: disable=inconsistent-return-statements - self, - resource_id: str, - api_version: str, - **kwargs: Any + self, resource_id: str, api_version: str, **kwargs: Any ) -> None: - cls = kwargs.pop('cls', None) # type: ClsType[None] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = kwargs.pop("params", {}) or {} - - request = build_resources_delete_by_id_request_initial( + cls = kwargs.pop("cls", None) # type: ClsType[None] + + request = build_resources_delete_by_id_request( resource_id=resource_id, api_version=api_version, - template_url=self._delete_by_id_initial.metadata['url'], + template_url=self._delete_by_id_initial.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200, 202, 204]: @@ -9214,23 +10316,18 @@ def _delete_by_id_initial( # pylint: disable=inconsistent-return-statements if cls: return cls(pipeline_response, None, {}) - _delete_by_id_initial.metadata = {'url': "/{resourceId}"} # type: ignore - + _delete_by_id_initial.metadata = {"url": "/{resourceId}"} # type: ignore @distributed_trace - def begin_delete_by_id( # pylint: disable=inconsistent-return-statements - self, - resource_id: str, - api_version: str, - **kwargs: Any - ) -> LROPoller[None]: + def begin_delete_by_id(self, resource_id: str, api_version: str, **kwargs: Any) -> LROPoller[None]: """Deletes a resource by ID. :param resource_id: The fully qualified ID of the resource, including the resource name and resource type. Use the format, /subscriptions/{guid}/resourceGroups/{resource-group-name}/{resource-provider-namespace}/{resource-type}/{resource-name}. + Required. :type resource_id: str - :param api_version: The API version to use for the operation. + :param api_version: The API version to use for the operation. Required. :type api_version: str :keyword callable cls: A custom type or function that will be passed the direct response :keyword str continuation_token: A continuation token to restart a poller from a saved state. @@ -9242,75 +10339,89 @@ def begin_delete_by_id( # pylint: disable=inconsistent-return-statements Retry-After header is present. :return: An instance of LROPoller that returns either None or the result of cls(response) :rtype: ~azure.core.polling.LROPoller[None] - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - polling = kwargs.pop('polling', True) # type: Union[bool, PollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType[None] - lro_delay = kwargs.pop( - 'polling_interval', - self._config.polling_interval - ) - cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] + _headers = kwargs.pop("headers", {}) or {} + _params = kwargs.pop("params", {}) or {} + + cls = kwargs.pop("cls", None) # type: ClsType[None] + polling = kwargs.pop("polling", True) # type: Union[bool, PollingMethod] + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token = kwargs.pop("continuation_token", None) # type: Optional[str] if cont_token is None: - raw_result = self._delete_by_id_initial( + raw_result = self._delete_by_id_initial( # type: ignore resource_id=resource_id, api_version=api_version, - cls=lambda x,y,z: x, + cls=lambda x, y, z: x, + headers=_headers, + params=_params, **kwargs ) - kwargs.pop('error_map', None) + kwargs.pop("error_map", None) - def get_long_running_output(pipeline_response): + def get_long_running_output(pipeline_response): # pylint: disable=inconsistent-return-statements if cls: return cls(pipeline_response, None, {}) - - if polling is True: polling_method = ARMPolling(lro_delay, **kwargs) - elif polling is False: polling_method = NoPolling() - else: polling_method = polling + if polling is True: + polling_method = cast(PollingMethod, ARMPolling(lro_delay, **kwargs)) # type: PollingMethod + elif polling is False: + polling_method = cast(PollingMethod, NoPolling()) + else: + polling_method = polling if cont_token: return LROPoller.from_continuation_token( polling_method=polling_method, continuation_token=cont_token, client=self._client, - deserialization_callback=get_long_running_output + deserialization_callback=get_long_running_output, ) return LROPoller(self._client, raw_result, get_long_running_output, polling_method) - begin_delete_by_id.metadata = {'url': "/{resourceId}"} # type: ignore + begin_delete_by_id.metadata = {"url": "/{resourceId}"} # type: ignore def _create_or_update_by_id_initial( - self, - resource_id: str, - api_version: str, - parameters: "_models.GenericResource", - **kwargs: Any - ) -> Optional["_models.GenericResource"]: - cls = kwargs.pop('cls', None) # type: ClsType[Optional["_models.GenericResource"]] + self, resource_id: str, api_version: str, parameters: Union[_models.GenericResource, IO], **kwargs: Any + ) -> Optional[_models.GenericResource]: error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = kwargs.pop("params", {}) or {} - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[Optional[_models.GenericResource]] - _json = self._serialize.body(parameters, 'GenericResource') + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(parameters, (IO, bytes)): + _content = parameters + else: + _json = self._serialize.body(parameters, "GenericResource") - request = build_resources_create_or_update_by_id_request_initial( + request = build_resources_create_or_update_by_id_request( resource_id=resource_id, - content_type=content_type, api_version=api_version, + content_type=content_type, json=_json, - template_url=self._create_or_update_by_id_initial.metadata['url'], + content=_content, + template_url=self._create_or_update_by_id_initial.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200, 201, 202]: @@ -9319,37 +10430,42 @@ def _create_or_update_by_id_initial( deserialized = None if response.status_code == 200: - deserialized = self._deserialize('GenericResource', pipeline_response) + deserialized = self._deserialize("GenericResource", pipeline_response) if response.status_code == 201: - deserialized = self._deserialize('GenericResource', pipeline_response) + deserialized = self._deserialize("GenericResource", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - _create_or_update_by_id_initial.metadata = {'url': "/{resourceId}"} # type: ignore - + _create_or_update_by_id_initial.metadata = {"url": "/{resourceId}"} # type: ignore - @distributed_trace + @overload def begin_create_or_update_by_id( self, resource_id: str, api_version: str, - parameters: "_models.GenericResource", + parameters: _models.GenericResource, + *, + content_type: str = "application/json", **kwargs: Any - ) -> LROPoller["_models.GenericResource"]: + ) -> LROPoller[_models.GenericResource]: """Create a resource by ID. :param resource_id: The fully qualified ID of the resource, including the resource name and resource type. Use the format, /subscriptions/{guid}/resourceGroups/{resource-group-name}/{resource-provider-namespace}/{resource-type}/{resource-name}. + Required. :type resource_id: str - :param api_version: The API version to use for the operation. + :param api_version: The API version to use for the operation. Required. :type api_version: str - :param parameters: Create or update resource parameters. + :param parameters: Create or update resource parameters. Required. :type parameters: ~azure.mgmt.resource.resources.v2021_01_01.models.GenericResource + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str :keyword callable cls: A custom type or function that will be passed the direct response :keyword str continuation_token: A continuation token to restart a poller from a saved state. :keyword polling: By default, your polling method will be ARMPolling. Pass in False for this @@ -9362,81 +10478,167 @@ def begin_create_or_update_by_id( cls(response) :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.resource.resources.v2021_01_01.models.GenericResource] - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] - polling = kwargs.pop('polling', True) # type: Union[bool, PollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType["_models.GenericResource"] - lro_delay = kwargs.pop( - 'polling_interval', - self._config.polling_interval - ) - cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] + + @overload + def begin_create_or_update_by_id( + self, + resource_id: str, + api_version: str, + parameters: IO, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> LROPoller[_models.GenericResource]: + """Create a resource by ID. + + :param resource_id: The fully qualified ID of the resource, including the resource name and + resource type. Use the format, + /subscriptions/{guid}/resourceGroups/{resource-group-name}/{resource-provider-namespace}/{resource-type}/{resource-name}. + Required. + :type resource_id: str + :param api_version: The API version to use for the operation. Required. + :type api_version: str + :param parameters: Create or update resource parameters. Required. + :type parameters: IO + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be ARMPolling. Pass in False for this + operation to not poll, or pass in your own initialized polling object for a personal polling + strategy. + :paramtype polling: bool or ~azure.core.polling.PollingMethod + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of LROPoller that returns either GenericResource or the result of + cls(response) + :rtype: + ~azure.core.polling.LROPoller[~azure.mgmt.resource.resources.v2021_01_01.models.GenericResource] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace + def begin_create_or_update_by_id( + self, resource_id: str, api_version: str, parameters: Union[_models.GenericResource, IO], **kwargs: Any + ) -> LROPoller[_models.GenericResource]: + """Create a resource by ID. + + :param resource_id: The fully qualified ID of the resource, including the resource name and + resource type. Use the format, + /subscriptions/{guid}/resourceGroups/{resource-group-name}/{resource-provider-namespace}/{resource-type}/{resource-name}. + Required. + :type resource_id: str + :param api_version: The API version to use for the operation. Required. + :type api_version: str + :param parameters: Create or update resource parameters. Is either a model type or a IO type. + Required. + :type parameters: ~azure.mgmt.resource.resources.v2021_01_01.models.GenericResource or IO + :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. + Default value is None. + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be ARMPolling. Pass in False for this + operation to not poll, or pass in your own initialized polling object for a personal polling + strategy. + :paramtype polling: bool or ~azure.core.polling.PollingMethod + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of LROPoller that returns either GenericResource or the result of + cls(response) + :rtype: + ~azure.core.polling.LROPoller[~azure.mgmt.resource.resources.v2021_01_01.models.GenericResource] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = kwargs.pop("params", {}) or {} + + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.GenericResource] + polling = kwargs.pop("polling", True) # type: Union[bool, PollingMethod] + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token = kwargs.pop("continuation_token", None) # type: Optional[str] if cont_token is None: - raw_result = self._create_or_update_by_id_initial( + raw_result = self._create_or_update_by_id_initial( # type: ignore resource_id=resource_id, api_version=api_version, parameters=parameters, content_type=content_type, - cls=lambda x,y,z: x, + cls=lambda x, y, z: x, + headers=_headers, + params=_params, **kwargs ) - kwargs.pop('error_map', None) + kwargs.pop("error_map", None) def get_long_running_output(pipeline_response): - response = pipeline_response.http_response - deserialized = self._deserialize('GenericResource', pipeline_response) + deserialized = self._deserialize("GenericResource", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - - if polling is True: polling_method = ARMPolling(lro_delay, **kwargs) - elif polling is False: polling_method = NoPolling() - else: polling_method = polling + if polling is True: + polling_method = cast(PollingMethod, ARMPolling(lro_delay, **kwargs)) # type: PollingMethod + elif polling is False: + polling_method = cast(PollingMethod, NoPolling()) + else: + polling_method = polling if cont_token: return LROPoller.from_continuation_token( polling_method=polling_method, continuation_token=cont_token, client=self._client, - deserialization_callback=get_long_running_output + deserialization_callback=get_long_running_output, ) return LROPoller(self._client, raw_result, get_long_running_output, polling_method) - begin_create_or_update_by_id.metadata = {'url': "/{resourceId}"} # type: ignore + begin_create_or_update_by_id.metadata = {"url": "/{resourceId}"} # type: ignore def _update_by_id_initial( - self, - resource_id: str, - api_version: str, - parameters: "_models.GenericResource", - **kwargs: Any - ) -> Optional["_models.GenericResource"]: - cls = kwargs.pop('cls', None) # type: ClsType[Optional["_models.GenericResource"]] + self, resource_id: str, api_version: str, parameters: Union[_models.GenericResource, IO], **kwargs: Any + ) -> Optional[_models.GenericResource]: error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = kwargs.pop("params", {}) or {} - _json = self._serialize.body(parameters, 'GenericResource') + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[Optional[_models.GenericResource]] - request = build_resources_update_by_id_request_initial( + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(parameters, (IO, bytes)): + _content = parameters + else: + _json = self._serialize.body(parameters, "GenericResource") + + request = build_resources_update_by_id_request( resource_id=resource_id, - content_type=content_type, api_version=api_version, + content_type=content_type, json=_json, - template_url=self._update_by_id_initial.metadata['url'], + content=_content, + template_url=self._update_by_id_initial.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200, 202]: @@ -9445,34 +10647,39 @@ def _update_by_id_initial( deserialized = None if response.status_code == 200: - deserialized = self._deserialize('GenericResource', pipeline_response) + deserialized = self._deserialize("GenericResource", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - _update_by_id_initial.metadata = {'url': "/{resourceId}"} # type: ignore + _update_by_id_initial.metadata = {"url": "/{resourceId}"} # type: ignore - - @distributed_trace + @overload def begin_update_by_id( self, resource_id: str, api_version: str, - parameters: "_models.GenericResource", + parameters: _models.GenericResource, + *, + content_type: str = "application/json", **kwargs: Any - ) -> LROPoller["_models.GenericResource"]: + ) -> LROPoller[_models.GenericResource]: """Updates a resource by ID. :param resource_id: The fully qualified ID of the resource, including the resource name and resource type. Use the format, /subscriptions/{guid}/resourceGroups/{resource-group-name}/{resource-provider-namespace}/{resource-type}/{resource-name}. + Required. :type resource_id: str - :param api_version: The API version to use for the operation. + :param api_version: The API version to use for the operation. Required. :type api_version: str - :param parameters: Update resource parameters. + :param parameters: Update resource parameters. Required. :type parameters: ~azure.mgmt.resource.resources.v2021_01_01.models.GenericResource + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str :keyword callable cls: A custom type or function that will be passed the direct response :keyword str continuation_token: A continuation token to restart a poller from a saved state. :keyword polling: By default, your polling method will be ARMPolling. Pass in False for this @@ -9485,165 +10692,243 @@ def begin_update_by_id( cls(response) :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.resource.resources.v2021_01_01.models.GenericResource] - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] - polling = kwargs.pop('polling', True) # type: Union[bool, PollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType["_models.GenericResource"] - lro_delay = kwargs.pop( - 'polling_interval', - self._config.polling_interval - ) - cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] + + @overload + def begin_update_by_id( + self, + resource_id: str, + api_version: str, + parameters: IO, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> LROPoller[_models.GenericResource]: + """Updates a resource by ID. + + :param resource_id: The fully qualified ID of the resource, including the resource name and + resource type. Use the format, + /subscriptions/{guid}/resourceGroups/{resource-group-name}/{resource-provider-namespace}/{resource-type}/{resource-name}. + Required. + :type resource_id: str + :param api_version: The API version to use for the operation. Required. + :type api_version: str + :param parameters: Update resource parameters. Required. + :type parameters: IO + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be ARMPolling. Pass in False for this + operation to not poll, or pass in your own initialized polling object for a personal polling + strategy. + :paramtype polling: bool or ~azure.core.polling.PollingMethod + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of LROPoller that returns either GenericResource or the result of + cls(response) + :rtype: + ~azure.core.polling.LROPoller[~azure.mgmt.resource.resources.v2021_01_01.models.GenericResource] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace + def begin_update_by_id( + self, resource_id: str, api_version: str, parameters: Union[_models.GenericResource, IO], **kwargs: Any + ) -> LROPoller[_models.GenericResource]: + """Updates a resource by ID. + + :param resource_id: The fully qualified ID of the resource, including the resource name and + resource type. Use the format, + /subscriptions/{guid}/resourceGroups/{resource-group-name}/{resource-provider-namespace}/{resource-type}/{resource-name}. + Required. + :type resource_id: str + :param api_version: The API version to use for the operation. Required. + :type api_version: str + :param parameters: Update resource parameters. Is either a model type or a IO type. Required. + :type parameters: ~azure.mgmt.resource.resources.v2021_01_01.models.GenericResource or IO + :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. + Default value is None. + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be ARMPolling. Pass in False for this + operation to not poll, or pass in your own initialized polling object for a personal polling + strategy. + :paramtype polling: bool or ~azure.core.polling.PollingMethod + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of LROPoller that returns either GenericResource or the result of + cls(response) + :rtype: + ~azure.core.polling.LROPoller[~azure.mgmt.resource.resources.v2021_01_01.models.GenericResource] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = kwargs.pop("params", {}) or {} + + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.GenericResource] + polling = kwargs.pop("polling", True) # type: Union[bool, PollingMethod] + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token = kwargs.pop("continuation_token", None) # type: Optional[str] if cont_token is None: - raw_result = self._update_by_id_initial( + raw_result = self._update_by_id_initial( # type: ignore resource_id=resource_id, api_version=api_version, parameters=parameters, content_type=content_type, - cls=lambda x,y,z: x, + cls=lambda x, y, z: x, + headers=_headers, + params=_params, **kwargs ) - kwargs.pop('error_map', None) + kwargs.pop("error_map", None) def get_long_running_output(pipeline_response): - response = pipeline_response.http_response - deserialized = self._deserialize('GenericResource', pipeline_response) + deserialized = self._deserialize("GenericResource", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - - if polling is True: polling_method = ARMPolling(lro_delay, **kwargs) - elif polling is False: polling_method = NoPolling() - else: polling_method = polling + if polling is True: + polling_method = cast(PollingMethod, ARMPolling(lro_delay, **kwargs)) # type: PollingMethod + elif polling is False: + polling_method = cast(PollingMethod, NoPolling()) + else: + polling_method = polling if cont_token: return LROPoller.from_continuation_token( polling_method=polling_method, continuation_token=cont_token, client=self._client, - deserialization_callback=get_long_running_output + deserialization_callback=get_long_running_output, ) return LROPoller(self._client, raw_result, get_long_running_output, polling_method) - begin_update_by_id.metadata = {'url': "/{resourceId}"} # type: ignore + begin_update_by_id.metadata = {"url": "/{resourceId}"} # type: ignore @distributed_trace - def get_by_id( - self, - resource_id: str, - api_version: str, - **kwargs: Any - ) -> "_models.GenericResource": + def get_by_id(self, resource_id: str, api_version: str, **kwargs: Any) -> _models.GenericResource: """Gets a resource by ID. :param resource_id: The fully qualified ID of the resource, including the resource name and resource type. Use the format, /subscriptions/{guid}/resourceGroups/{resource-group-name}/{resource-provider-namespace}/{resource-type}/{resource-name}. + Required. :type resource_id: str - :param api_version: The API version to use for the operation. + :param api_version: The API version to use for the operation. Required. :type api_version: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: GenericResource, or the result of cls(response) + :return: GenericResource or the result of cls(response) :rtype: ~azure.mgmt.resource.resources.v2021_01_01.models.GenericResource - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.GenericResource"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = kwargs.pop("params", {}) or {} + + cls = kwargs.pop("cls", None) # type: ClsType[_models.GenericResource] - request = build_resources_get_by_id_request( resource_id=resource_id, api_version=api_version, - template_url=self.get_by_id.metadata['url'], + template_url=self.get_by_id.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) - deserialized = self._deserialize('GenericResource', pipeline_response) + deserialized = self._deserialize("GenericResource", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - get_by_id.metadata = {'url': "/{resourceId}"} # type: ignore + get_by_id.metadata = {"url": "/{resourceId}"} # type: ignore -class ResourceGroupsOperations(object): - """ResourceGroupsOperations operations. - You should not instantiate this class directly. Instead, you should create a Client instance that - instantiates it for you and attaches it as an attribute. +class ResourceGroupsOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. - :ivar models: Alias to model classes used in this operation group. - :type models: ~azure.mgmt.resource.resources.v2021_01_01.models - :param client: Client for service requests. - :param config: Configuration of service client. - :param serializer: An object model serializer. - :param deserializer: An object model deserializer. + Instead, you should access the following operations through + :class:`~azure.mgmt.resource.resources.v2021_01_01.ResourceManagementClient`'s + :attr:`resource_groups` attribute. """ models = _models - def __init__(self, client, config, serializer, deserializer): - self._client = client - self._serialize = serializer - self._deserialize = deserializer - self._config = config + def __init__(self, *args, **kwargs): + input_args = list(args) + self._client = input_args.pop(0) if input_args else kwargs.pop("client") + self._config = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") @distributed_trace - def check_existence( - self, - resource_group_name: str, - **kwargs: Any - ) -> bool: + def check_existence(self, resource_group_name: str, **kwargs: Any) -> bool: """Checks whether a resource group exists. :param resource_group_name: The name of the resource group to check. The name is case - insensitive. + insensitive. Required. :type resource_group_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: bool, or the result of cls(response) + :return: bool or the result of cls(response) :rtype: bool - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType[None] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + 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', "2021-01-01") # type: str + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-01-01")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[None] - request = build_resource_groups_check_existence_request( resource_group_name=resource_group_name, subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.check_existence.metadata['url'], + template_url=self.check_existence.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [204, 404]: @@ -9654,39 +10939,98 @@ def check_existence( return cls(pipeline_response, None, {}) return 200 <= response.status_code <= 299 - check_existence.metadata = {'url': "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}"} # type: ignore - + check_existence.metadata = {"url": "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}"} # type: ignore - @distributed_trace + @overload def create_or_update( self, resource_group_name: str, - parameters: "_models.ResourceGroup", + parameters: _models.ResourceGroup, + *, + content_type: str = "application/json", **kwargs: Any - ) -> "_models.ResourceGroup": + ) -> _models.ResourceGroup: """Creates or updates a resource group. :param resource_group_name: The name of the resource group to create or update. Can include alphanumeric, underscore, parentheses, hyphen, period (except at end), and Unicode characters - that match the allowed characters. + that match the allowed characters. Required. :type resource_group_name: str - :param parameters: Parameters supplied to the create or update a resource group. + :param parameters: Parameters supplied to the create or update a resource group. Required. :type parameters: ~azure.mgmt.resource.resources.v2021_01_01.models.ResourceGroup + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: ResourceGroup, or the result of cls(response) + :return: ResourceGroup or the result of cls(response) :rtype: ~azure.mgmt.resource.resources.v2021_01_01.models.ResourceGroup - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + def create_or_update( + self, resource_group_name: str, parameters: IO, *, content_type: str = "application/json", **kwargs: Any + ) -> _models.ResourceGroup: + """Creates or updates a resource group. + + :param resource_group_name: The name of the resource group to create or update. Can include + alphanumeric, underscore, parentheses, hyphen, period (except at end), and Unicode characters + that match the allowed characters. Required. + :type resource_group_name: str + :param parameters: Parameters supplied to the create or update a resource group. Required. + :type parameters: IO + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: ResourceGroup or the result of cls(response) + :rtype: ~azure.mgmt.resource.resources.v2021_01_01.models.ResourceGroup + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace + def create_or_update( + self, resource_group_name: str, parameters: Union[_models.ResourceGroup, IO], **kwargs: Any + ) -> _models.ResourceGroup: + """Creates or updates a resource group. + + :param resource_group_name: The name of the resource group to create or update. Can include + alphanumeric, underscore, parentheses, hyphen, period (except at end), and Unicode characters + that match the allowed characters. Required. + :type resource_group_name: str + :param parameters: Parameters supplied to the create or update a resource group. Is either a + model type or a IO type. Required. + :type parameters: ~azure.mgmt.resource.resources.v2021_01_01.models.ResourceGroup or IO + :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. + Default value is None. + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: ResourceGroup or the result of cls(response) + :rtype: ~azure.mgmt.resource.resources.v2021_01_01.models.ResourceGroup + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.ResourceGroup"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', "2021-01-01") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-01-01")) # type: str + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.ResourceGroup] - _json = self._serialize.body(parameters, 'ResourceGroup') + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(parameters, (IO, bytes)): + _content = parameters + else: + _json = self._serialize.body(parameters, "ResourceGroup") request = build_resource_groups_create_or_update_request( resource_group_name=resource_group_name, @@ -9694,16 +11038,18 @@ def create_or_update( api_version=api_version, content_type=content_type, json=_json, - template_url=self.create_or_update.metadata['url'], + content=_content, + template_url=self.create_or_update.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200, 201]: @@ -9711,49 +11057,51 @@ def create_or_update( raise HttpResponseError(response=response, error_format=ARMErrorFormat) if response.status_code == 200: - deserialized = self._deserialize('ResourceGroup', pipeline_response) + deserialized = self._deserialize("ResourceGroup", pipeline_response) if response.status_code == 201: - deserialized = self._deserialize('ResourceGroup', pipeline_response) + deserialized = self._deserialize("ResourceGroup", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - create_or_update.metadata = {'url': "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}"} # type: ignore - + create_or_update.metadata = {"url": "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}"} # type: ignore def _delete_initial( # pylint: disable=inconsistent-return-statements - self, - resource_group_name: str, - force_deletion_types: Optional[str] = None, - **kwargs: Any + self, resource_group_name: str, force_deletion_types: Optional[str] = None, **kwargs: Any ) -> None: - cls = kwargs.pop('cls', None) # type: ClsType[None] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + 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', "2021-01-01") # type: str + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-01-01")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[None] - - request = build_resource_groups_delete_request_initial( + request = build_resource_groups_delete_request( resource_group_name=resource_group_name, subscription_id=self._config.subscription_id, - api_version=api_version, force_deletion_types=force_deletion_types, - template_url=self._delete_initial.metadata['url'], + api_version=api_version, + template_url=self._delete_initial.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200, 202]: @@ -9763,15 +11111,11 @@ def _delete_initial( # pylint: disable=inconsistent-return-statements if cls: return cls(pipeline_response, None, {}) - _delete_initial.metadata = {'url': "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}"} # type: ignore - + _delete_initial.metadata = {"url": "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}"} # type: ignore @distributed_trace - def begin_delete( # pylint: disable=inconsistent-return-statements - self, - resource_group_name: str, - force_deletion_types: Optional[str] = None, - **kwargs: Any + def begin_delete( + self, resource_group_name: str, force_deletion_types: Optional[str] = None, **kwargs: Any ) -> LROPoller[None]: """Deletes a resource group. @@ -9779,7 +11123,7 @@ def begin_delete( # pylint: disable=inconsistent-return-statements group deletes all of its template deployments and currently stored operations. :param resource_group_name: The name of the resource group to delete. The name is case - insensitive. + insensitive. Required. :type resource_group_name: str :param force_deletion_types: The resource types you want to force delete. Currently, only the following is supported: @@ -9796,107 +11140,114 @@ def begin_delete( # pylint: disable=inconsistent-return-statements Retry-After header is present. :return: An instance of LROPoller that returns either None or the result of cls(response) :rtype: ~azure.core.polling.LROPoller[None] - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - api_version = kwargs.pop('api_version', "2021-01-01") # type: str - polling = kwargs.pop('polling', True) # type: Union[bool, PollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType[None] - lro_delay = kwargs.pop( - 'polling_interval', - self._config.polling_interval - ) - cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-01-01")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[None] + polling = kwargs.pop("polling", True) # type: Union[bool, PollingMethod] + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token = kwargs.pop("continuation_token", None) # type: Optional[str] if cont_token is None: - raw_result = self._delete_initial( + raw_result = self._delete_initial( # type: ignore resource_group_name=resource_group_name, force_deletion_types=force_deletion_types, api_version=api_version, - cls=lambda x,y,z: x, + cls=lambda x, y, z: x, + headers=_headers, + params=_params, **kwargs ) - kwargs.pop('error_map', None) + kwargs.pop("error_map", None) - def get_long_running_output(pipeline_response): + def get_long_running_output(pipeline_response): # pylint: disable=inconsistent-return-statements if cls: return cls(pipeline_response, None, {}) - - if polling is True: polling_method = ARMPolling(lro_delay, **kwargs) - elif polling is False: polling_method = NoPolling() - else: polling_method = polling + if polling is True: + polling_method = cast(PollingMethod, ARMPolling(lro_delay, **kwargs)) # type: PollingMethod + elif polling is False: + polling_method = cast(PollingMethod, NoPolling()) + else: + polling_method = polling if cont_token: return LROPoller.from_continuation_token( polling_method=polling_method, continuation_token=cont_token, client=self._client, - deserialization_callback=get_long_running_output + deserialization_callback=get_long_running_output, ) return LROPoller(self._client, raw_result, get_long_running_output, polling_method) - begin_delete.metadata = {'url': "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}"} # type: ignore + begin_delete.metadata = {"url": "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}"} # type: ignore @distributed_trace - def get( - self, - resource_group_name: str, - **kwargs: Any - ) -> "_models.ResourceGroup": + def get(self, resource_group_name: str, **kwargs: Any) -> _models.ResourceGroup: """Gets a resource group. :param resource_group_name: The name of the resource group to get. The name is case - insensitive. + insensitive. Required. :type resource_group_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: ResourceGroup, or the result of cls(response) + :return: ResourceGroup or the result of cls(response) :rtype: ~azure.mgmt.resource.resources.v2021_01_01.models.ResourceGroup - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.ResourceGroup"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + 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', "2021-01-01") # type: str + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-01-01")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[_models.ResourceGroup] - request = build_resource_groups_get_request( resource_group_name=resource_group_name, subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.get.metadata['url'], + template_url=self.get.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) - deserialized = self._deserialize('ResourceGroup', pipeline_response) + deserialized = self._deserialize("ResourceGroup", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - get.metadata = {'url': "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}"} # type: ignore - + get.metadata = {"url": "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}"} # type: ignore - @distributed_trace + @overload def update( self, resource_group_name: str, - parameters: "_models.ResourceGroupPatchable", + parameters: _models.ResourceGroupPatchable, + *, + content_type: str = "application/json", **kwargs: Any - ) -> "_models.ResourceGroup": + ) -> _models.ResourceGroup: """Updates a resource group. Resource groups can be updated through a simple PATCH operation to a group address. The format @@ -9904,25 +11255,90 @@ def update( the current value is retained. :param resource_group_name: The name of the resource group to update. The name is case - insensitive. + insensitive. Required. :type resource_group_name: str - :param parameters: Parameters supplied to update a resource group. + :param parameters: Parameters supplied to update a resource group. Required. :type parameters: ~azure.mgmt.resource.resources.v2021_01_01.models.ResourceGroupPatchable + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: ResourceGroup or the result of cls(response) + :rtype: ~azure.mgmt.resource.resources.v2021_01_01.models.ResourceGroup + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + def update( + self, resource_group_name: str, parameters: IO, *, content_type: str = "application/json", **kwargs: Any + ) -> _models.ResourceGroup: + """Updates a resource group. + + Resource groups can be updated through a simple PATCH operation to a group address. The format + of the request is the same as that for creating a resource group. If a field is unspecified, + the current value is retained. + + :param resource_group_name: The name of the resource group to update. The name is case + insensitive. Required. + :type resource_group_name: str + :param parameters: Parameters supplied to update a resource group. Required. + :type parameters: IO + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: ResourceGroup, or the result of cls(response) + :return: ResourceGroup or the result of cls(response) :rtype: ~azure.mgmt.resource.resources.v2021_01_01.models.ResourceGroup - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace + def update( + self, resource_group_name: str, parameters: Union[_models.ResourceGroupPatchable, IO], **kwargs: Any + ) -> _models.ResourceGroup: + """Updates a resource group. + + Resource groups can be updated through a simple PATCH operation to a group address. The format + of the request is the same as that for creating a resource group. If a field is unspecified, + the current value is retained. + + :param resource_group_name: The name of the resource group to update. The name is case + insensitive. Required. + :type resource_group_name: str + :param parameters: Parameters supplied to update a resource group. Is either a model type or a + IO type. Required. + :type parameters: ~azure.mgmt.resource.resources.v2021_01_01.models.ResourceGroupPatchable or + IO + :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. + Default value is None. + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: ResourceGroup or the result of cls(response) + :rtype: ~azure.mgmt.resource.resources.v2021_01_01.models.ResourceGroup + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.ResourceGroup"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', "2021-01-01") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-01-01")) # type: str + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.ResourceGroup] - _json = self._serialize.body(parameters, 'ResourceGroupPatchable') + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(parameters, (IO, bytes)): + _content = parameters + else: + _json = self._serialize.body(parameters, "ResourceGroupPatchable") request = build_resource_groups_update_request( resource_group_name=resource_group_name, @@ -9930,65 +11346,77 @@ def update( api_version=api_version, content_type=content_type, json=_json, - template_url=self.update.metadata['url'], + content=_content, + template_url=self.update.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) - deserialized = self._deserialize('ResourceGroup', pipeline_response) + deserialized = self._deserialize("ResourceGroup", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - update.metadata = {'url': "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}"} # type: ignore - + update.metadata = {"url": "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}"} # type: ignore def _export_template_initial( - self, - resource_group_name: str, - parameters: "_models.ExportTemplateRequest", - **kwargs: Any - ) -> Optional["_models.ResourceGroupExportResult"]: - cls = kwargs.pop('cls', None) # type: ClsType[Optional["_models.ResourceGroupExportResult"]] + self, resource_group_name: str, parameters: Union[_models.ExportTemplateRequest, IO], **kwargs: Any + ) -> Optional[_models.ResourceGroupExportResult]: error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) - api_version = kwargs.pop('api_version', "2021-01-01") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - _json = self._serialize.body(parameters, 'ExportTemplateRequest') + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-01-01")) # type: str + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[Optional[_models.ResourceGroupExportResult]] - request = build_resource_groups_export_template_request_initial( - subscription_id=self._config.subscription_id, + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(parameters, (IO, bytes)): + _content = parameters + else: + _json = self._serialize.body(parameters, "ExportTemplateRequest") + + request = build_resource_groups_export_template_request( resource_group_name=resource_group_name, + subscription_id=self._config.subscription_id, api_version=api_version, content_type=content_type, json=_json, - template_url=self._export_template_initial.metadata['url'], + content=_content, + template_url=self._export_template_initial.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200, 202]: @@ -9997,29 +11425,93 @@ def _export_template_initial( deserialized = None if response.status_code == 200: - deserialized = self._deserialize('ResourceGroupExportResult', pipeline_response) + deserialized = self._deserialize("ResourceGroupExportResult", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - _export_template_initial.metadata = {'url': "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/exportTemplate"} # type: ignore + _export_template_initial.metadata = {"url": "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/exportTemplate"} # type: ignore + @overload + def begin_export_template( + self, + resource_group_name: str, + parameters: _models.ExportTemplateRequest, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> LROPoller[_models.ResourceGroupExportResult]: + """Captures the specified resource group as a template. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param parameters: Parameters for exporting the template. Required. + :type parameters: ~azure.mgmt.resource.resources.v2021_01_01.models.ExportTemplateRequest + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be ARMPolling. Pass in False for this + operation to not poll, or pass in your own initialized polling object for a personal polling + strategy. + :paramtype polling: bool or ~azure.core.polling.PollingMethod + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of LROPoller that returns either ResourceGroupExportResult or the result + of cls(response) + :rtype: + ~azure.core.polling.LROPoller[~azure.mgmt.resource.resources.v2021_01_01.models.ResourceGroupExportResult] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + def begin_export_template( + self, resource_group_name: str, parameters: IO, *, content_type: str = "application/json", **kwargs: Any + ) -> LROPoller[_models.ResourceGroupExportResult]: + """Captures the specified resource group as a template. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param parameters: Parameters for exporting the template. Required. + :type parameters: IO + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be ARMPolling. Pass in False for this + operation to not poll, or pass in your own initialized polling object for a personal polling + strategy. + :paramtype polling: bool or ~azure.core.polling.PollingMethod + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of LROPoller that returns either ResourceGroupExportResult or the result + of cls(response) + :rtype: + ~azure.core.polling.LROPoller[~azure.mgmt.resource.resources.v2021_01_01.models.ResourceGroupExportResult] + :raises ~azure.core.exceptions.HttpResponseError: + """ @distributed_trace def begin_export_template( - self, - resource_group_name: str, - parameters: "_models.ExportTemplateRequest", - **kwargs: Any - ) -> LROPoller["_models.ResourceGroupExportResult"]: + self, resource_group_name: str, parameters: Union[_models.ExportTemplateRequest, IO], **kwargs: Any + ) -> LROPoller[_models.ResourceGroupExportResult]: """Captures the specified resource group as a template. :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. :type resource_group_name: str - :param parameters: Parameters for exporting the template. - :type parameters: ~azure.mgmt.resource.resources.v2021_01_01.models.ExportTemplateRequest + :param parameters: Parameters for exporting the template. Is either a model type or a IO type. + Required. + :type parameters: ~azure.mgmt.resource.resources.v2021_01_01.models.ExportTemplateRequest or IO + :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. + Default value is None. + :paramtype content_type: str :keyword callable cls: A custom type or function that will be passed the direct response :keyword str continuation_token: A continuation token to restart a poller from a saved state. :keyword polling: By default, your polling method will be ARMPolling. Pass in False for this @@ -10032,57 +11524,59 @@ def begin_export_template( of cls(response) :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.resource.resources.v2021_01_01.models.ResourceGroupExportResult] - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - api_version = kwargs.pop('api_version', "2021-01-01") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] - polling = kwargs.pop('polling', True) # type: Union[bool, PollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType["_models.ResourceGroupExportResult"] - lro_delay = kwargs.pop( - 'polling_interval', - self._config.polling_interval - ) - cont_token = kwargs.pop('continuation_token', None) # type: Optional[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-01-01")) # type: str + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.ResourceGroupExportResult] + polling = kwargs.pop("polling", True) # type: Union[bool, PollingMethod] + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token = kwargs.pop("continuation_token", None) # type: Optional[str] if cont_token is None: - raw_result = self._export_template_initial( + raw_result = self._export_template_initial( # type: ignore resource_group_name=resource_group_name, parameters=parameters, api_version=api_version, content_type=content_type, - cls=lambda x,y,z: x, + cls=lambda x, y, z: x, + headers=_headers, + params=_params, **kwargs ) - kwargs.pop('error_map', None) + kwargs.pop("error_map", None) def get_long_running_output(pipeline_response): - response = pipeline_response.http_response - deserialized = self._deserialize('ResourceGroupExportResult', pipeline_response) + deserialized = self._deserialize("ResourceGroupExportResult", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - - if polling is True: polling_method = ARMPolling(lro_delay, lro_options={'final-state-via': 'location'}, **kwargs) - elif polling is False: polling_method = NoPolling() - else: polling_method = polling + if polling is True: + polling_method = cast( + PollingMethod, ARMPolling(lro_delay, lro_options={"final-state-via": "location"}, **kwargs) + ) # type: PollingMethod + elif polling is False: + polling_method = cast(PollingMethod, NoPolling()) + else: + polling_method = polling if cont_token: return LROPoller.from_continuation_token( polling_method=polling_method, continuation_token=cont_token, client=self._client, - deserialization_callback=get_long_running_output + deserialization_callback=get_long_running_output, ) return LROPoller(self._client, raw_result, get_long_running_output, polling_method) - begin_export_template.metadata = {'url': "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/exportTemplate"} # type: ignore + begin_export_template.metadata = {"url": "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/exportTemplate"} # type: ignore @distributed_trace def list( - self, - filter: Optional[str] = None, - top: Optional[int] = None, - **kwargs: Any - ) -> Iterable["_models.ResourceGroupListResult"]: + self, filter: Optional[str] = None, top: Optional[int] = None, **kwargs: Any + ) -> Iterable["_models.ResourceGroup"]: """Gets all the resource groups for a subscription. :param filter: The filter to apply on the operation.:code:`
`:code:`
`You can filter by @@ -10093,40 +11587,48 @@ def list( Default value is None. :type top: int :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either ResourceGroupListResult or the result of - cls(response) + :return: An iterator like instance of either ResourceGroup or the result of cls(response) :rtype: - ~azure.core.paging.ItemPaged[~azure.mgmt.resource.resources.v2021_01_01.models.ResourceGroupListResult] - :raises: ~azure.core.exceptions.HttpResponseError + ~azure.core.paging.ItemPaged[~azure.mgmt.resource.resources.v2021_01_01.models.ResourceGroup] + :raises ~azure.core.exceptions.HttpResponseError: """ - api_version = kwargs.pop('api_version', "2021-01-01") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-01-01")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[_models.ResourceGroupListResult] - cls = kwargs.pop('cls', None) # type: ClsType["_models.ResourceGroupListResult"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) + def prepare_request(next_link=None): if not next_link: - + request = build_resource_groups_list_request( subscription_id=self._config.subscription_id, - api_version=api_version, filter=filter, top=top, - template_url=self.list.metadata['url'], + 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.url = self._client.format_url(request.url) # type: ignore else: - - request = build_resource_groups_list_request( - subscription_id=self._config.subscription_id, - template_url=next_link, - ) + # make call to next link with the client's api-version + _parsed_next_link = urlparse(next_link) + _next_request_params = case_insensitive_dict(parse_qs(_parsed_next_link.query)) + _next_request_params["api-version"] = self._config.api_version + request = HttpRequest("GET", urljoin(next_link, _parsed_next_link.path), params=_next_request_params) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore request.method = "GET" return request @@ -10140,10 +11642,8 @@ def extract_data(pipeline_response): def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) response = pipeline_response.http_response @@ -10153,39 +11653,33 @@ def get_next(next_link=None): return pipeline_response + return ItemPaged(get_next, extract_data) - return ItemPaged( - get_next, extract_data - ) - list.metadata = {'url': "/subscriptions/{subscriptionId}/resourcegroups"} # type: ignore -class TagsOperations(object): - """TagsOperations operations. + list.metadata = {"url": "/subscriptions/{subscriptionId}/resourcegroups"} # type: ignore - You should not instantiate this class directly. Instead, you should create a Client instance that - instantiates it for you and attaches it as an attribute. - :ivar models: Alias to model classes used in this operation group. - :type models: ~azure.mgmt.resource.resources.v2021_01_01.models - :param client: Client for service requests. - :param config: Configuration of service client. - :param serializer: An object model serializer. - :param deserializer: An object model deserializer. +class TagsOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. + + Instead, you should access the following operations through + :class:`~azure.mgmt.resource.resources.v2021_01_01.ResourceManagementClient`'s + :attr:`tags` attribute. """ models = _models - def __init__(self, client, config, serializer, deserializer): - self._client = client - self._serialize = serializer - self._deserialize = deserializer - self._config = config + def __init__(self, *args, **kwargs): + input_args = list(args) + self._client = input_args.pop(0) if input_args else kwargs.pop("client") + self._config = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") @distributed_trace def delete_value( # pylint: disable=inconsistent-return-statements - self, - tag_name: str, - tag_value: str, - **kwargs: Any + self, tag_name: str, tag_value: str, **kwargs: Any ) -> None: """Deletes a predefined tag value for a predefined tag name. @@ -10193,39 +11687,45 @@ def delete_value( # pylint: disable=inconsistent-return-statements predefined tag name. The value being deleted must not be in use as a tag value for the given tag name for any resource. - :param tag_name: The name of the tag. + :param tag_name: The name of the tag. Required. :type tag_name: str - :param tag_value: The value of the tag to delete. + :param tag_value: The value of the tag to delete. Required. :type tag_value: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: None, or the result of cls(response) + :return: None or the result of cls(response) :rtype: None - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType[None] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) - api_version = kwargs.pop('api_version', "2021-01-01") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-01-01")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[None] - request = build_tags_delete_value_request( tag_name=tag_name, tag_value=tag_value, subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.delete_value.metadata['url'], + template_url=self.delete_value.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200, 204]: @@ -10235,54 +11735,54 @@ def delete_value( # pylint: disable=inconsistent-return-statements if cls: return cls(pipeline_response, None, {}) - delete_value.metadata = {'url': "/subscriptions/{subscriptionId}/tagNames/{tagName}/tagValues/{tagValue}"} # type: ignore - + delete_value.metadata = {"url": "/subscriptions/{subscriptionId}/tagNames/{tagName}/tagValues/{tagValue}"} # type: ignore @distributed_trace - def create_or_update_value( - self, - tag_name: str, - tag_value: str, - **kwargs: Any - ) -> "_models.TagValue": + def create_or_update_value(self, tag_name: str, tag_value: str, **kwargs: Any) -> _models.TagValue: """Creates a predefined value for a predefined tag name. This operation allows adding a value to the list of predefined values for an existing predefined tag name. A tag value can have a maximum of 256 characters. - :param tag_name: The name of the tag. + :param tag_name: The name of the tag. Required. :type tag_name: str - :param tag_value: The value of the tag to create. + :param tag_value: The value of the tag to create. Required. :type tag_value: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: TagValue, or the result of cls(response) + :return: TagValue or the result of cls(response) :rtype: ~azure.mgmt.resource.resources.v2021_01_01.models.TagValue - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.TagValue"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + 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', "2021-01-01") # type: str + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-01-01")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[_models.TagValue] - request = build_tags_create_or_update_value_request( tag_name=tag_name, tag_value=tag_value, subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.create_or_update_value.metadata['url'], + template_url=self.create_or_update_value.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200, 201]: @@ -10290,25 +11790,20 @@ def create_or_update_value( raise HttpResponseError(response=response, error_format=ARMErrorFormat) if response.status_code == 200: - deserialized = self._deserialize('TagValue', pipeline_response) + deserialized = self._deserialize("TagValue", pipeline_response) if response.status_code == 201: - deserialized = self._deserialize('TagValue', pipeline_response) + deserialized = self._deserialize("TagValue", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - create_or_update_value.metadata = {'url': "/subscriptions/{subscriptionId}/tagNames/{tagName}/tagValues/{tagValue}"} # type: ignore - + create_or_update_value.metadata = {"url": "/subscriptions/{subscriptionId}/tagNames/{tagName}/tagValues/{tagValue}"} # type: ignore @distributed_trace - def create_or_update( - self, - tag_name: str, - **kwargs: Any - ) -> "_models.TagDetails": + def create_or_update(self, tag_name: str, **kwargs: Any) -> _models.TagDetails: """Creates a predefined tag name. This operation allows adding a name to the list of predefined tag names for the given @@ -10316,36 +11811,42 @@ def create_or_update( names cannot have the following prefixes which are reserved for Azure use: 'microsoft', 'azure', 'windows'. - :param tag_name: The name of the tag to create. + :param tag_name: The name of the tag to create. Required. :type tag_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: TagDetails, or the result of cls(response) + :return: TagDetails or the result of cls(response) :rtype: ~azure.mgmt.resource.resources.v2021_01_01.models.TagDetails - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.TagDetails"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + 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', "2021-01-01") # type: str + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-01-01")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[_models.TagDetails] - request = build_tags_create_or_update_request( tag_name=tag_name, subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.create_or_update.metadata['url'], + template_url=self.create_or_update.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200, 201]: @@ -10353,61 +11854,62 @@ def create_or_update( raise HttpResponseError(response=response, error_format=ARMErrorFormat) if response.status_code == 200: - deserialized = self._deserialize('TagDetails', pipeline_response) + deserialized = self._deserialize("TagDetails", pipeline_response) if response.status_code == 201: - deserialized = self._deserialize('TagDetails', pipeline_response) + deserialized = self._deserialize("TagDetails", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - create_or_update.metadata = {'url': "/subscriptions/{subscriptionId}/tagNames/{tagName}"} # type: ignore - + create_or_update.metadata = {"url": "/subscriptions/{subscriptionId}/tagNames/{tagName}"} # type: ignore @distributed_trace - def delete( # pylint: disable=inconsistent-return-statements - self, - tag_name: str, - **kwargs: Any - ) -> None: + def delete(self, tag_name: str, **kwargs: Any) -> None: # pylint: disable=inconsistent-return-statements """Deletes a predefined tag name. This operation allows deleting a name from the list of predefined tag names for the given subscription. The name being deleted must not be in use as a tag name for any resource. All predefined values for the given name must have already been deleted. - :param tag_name: The name of the tag. + :param tag_name: The name of the tag. Required. :type tag_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: None, or the result of cls(response) + :return: None or the result of cls(response) :rtype: None - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType[None] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + 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', "2021-01-01") # type: str + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-01-01")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[None] - request = build_tags_delete_request( tag_name=tag_name, subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.delete.metadata['url'], + template_url=self.delete.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200, 204]: @@ -10417,14 +11919,10 @@ def delete( # pylint: disable=inconsistent-return-statements if cls: return cls(pipeline_response, None, {}) - delete.metadata = {'url': "/subscriptions/{subscriptionId}/tagNames/{tagName}"} # type: ignore - + delete.metadata = {"url": "/subscriptions/{subscriptionId}/tagNames/{tagName}"} # type: ignore @distributed_trace - def list( - self, - **kwargs: Any - ) -> Iterable["_models.TagsListResult"]: + def list(self, **kwargs: Any) -> Iterable["_models.TagDetails"]: """Gets a summary of tag usage under the subscription. This operation performs a union of predefined tags, resource tags, resource group tags and @@ -10433,37 +11931,46 @@ def list( result. :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either TagsListResult or the result of cls(response) + :return: An iterator like instance of either TagDetails or the result of cls(response) :rtype: - ~azure.core.paging.ItemPaged[~azure.mgmt.resource.resources.v2021_01_01.models.TagsListResult] - :raises: ~azure.core.exceptions.HttpResponseError + ~azure.core.paging.ItemPaged[~azure.mgmt.resource.resources.v2021_01_01.models.TagDetails] + :raises ~azure.core.exceptions.HttpResponseError: """ - api_version = kwargs.pop('api_version', "2021-01-01") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-01-01")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[_models.TagsListResult] - cls = kwargs.pop('cls', None) # type: ClsType["_models.TagsListResult"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) + def prepare_request(next_link=None): if not next_link: - + request = build_tags_list_request( subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.list.metadata['url'], + template_url=self.list.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore else: - - request = build_tags_list_request( - subscription_id=self._config.subscription_id, - template_url=next_link, - ) + # make call to next link with the client's api-version + _parsed_next_link = urlparse(next_link) + _next_request_params = case_insensitive_dict(parse_qs(_parsed_next_link.query)) + _next_request_params["api-version"] = self._config.api_version + request = HttpRequest("GET", urljoin(next_link, _parsed_next_link.path), params=_next_request_params) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore request.method = "GET" return request @@ -10477,10 +11984,8 @@ def extract_data(pipeline_response): def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) response = pipeline_response.http_response @@ -10490,82 +11995,139 @@ def get_next(next_link=None): return pipeline_response + return ItemPaged(get_next, extract_data) - return ItemPaged( - get_next, extract_data - ) - list.metadata = {'url': "/subscriptions/{subscriptionId}/tagNames"} # type: ignore + list.metadata = {"url": "/subscriptions/{subscriptionId}/tagNames"} # type: ignore - @distributed_trace + @overload def create_or_update_at_scope( - self, - scope: str, - parameters: "_models.TagsResource", - **kwargs: Any - ) -> "_models.TagsResource": + self, scope: str, parameters: _models.TagsResource, *, content_type: str = "application/json", **kwargs: Any + ) -> _models.TagsResource: """Creates or updates the entire set of tags on a resource or subscription. This operation allows adding or replacing the entire set of tags on the specified resource or subscription. The specified entity can have a maximum of 50 tags. - :param scope: The resource scope. + :param scope: The resource scope. Required. :type scope: str - :param parameters: + :param parameters: Required. :type parameters: ~azure.mgmt.resource.resources.v2021_01_01.models.TagsResource + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: TagsResource or the result of cls(response) + :rtype: ~azure.mgmt.resource.resources.v2021_01_01.models.TagsResource + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + def create_or_update_at_scope( + self, scope: str, parameters: IO, *, content_type: str = "application/json", **kwargs: Any + ) -> _models.TagsResource: + """Creates or updates the entire set of tags on a resource or subscription. + + This operation allows adding or replacing the entire set of tags on the specified resource or + subscription. The specified entity can have a maximum of 50 tags. + + :param scope: The resource scope. Required. + :type scope: str + :param parameters: Required. + :type parameters: IO + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: TagsResource or the result of cls(response) + :rtype: ~azure.mgmt.resource.resources.v2021_01_01.models.TagsResource + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace + def create_or_update_at_scope( + self, scope: str, parameters: Union[_models.TagsResource, IO], **kwargs: Any + ) -> _models.TagsResource: + """Creates or updates the entire set of tags on a resource or subscription. + + This operation allows adding or replacing the entire set of tags on the specified resource or + subscription. The specified entity can have a maximum of 50 tags. + + :param scope: The resource scope. Required. + :type scope: str + :param parameters: Is either a model type or a IO type. Required. + :type parameters: ~azure.mgmt.resource.resources.v2021_01_01.models.TagsResource or IO + :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. + Default value is None. + :paramtype content_type: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: TagsResource, or the result of cls(response) + :return: TagsResource or the result of cls(response) :rtype: ~azure.mgmt.resource.resources.v2021_01_01.models.TagsResource - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.TagsResource"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', "2021-01-01") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-01-01")) # type: str + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.TagsResource] - _json = self._serialize.body(parameters, 'TagsResource') + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(parameters, (IO, bytes)): + _content = parameters + else: + _json = self._serialize.body(parameters, "TagsResource") request = build_tags_create_or_update_at_scope_request( scope=scope, api_version=api_version, content_type=content_type, json=_json, - template_url=self.create_or_update_at_scope.metadata['url'], + content=_content, + template_url=self.create_or_update_at_scope.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) - deserialized = self._deserialize('TagsResource', pipeline_response) + deserialized = self._deserialize("TagsResource", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - create_or_update_at_scope.metadata = {'url': "/{scope}/providers/Microsoft.Resources/tags/default"} # type: ignore - + create_or_update_at_scope.metadata = {"url": "/{scope}/providers/Microsoft.Resources/tags/default"} # type: ignore - @distributed_trace + @overload def update_at_scope( self, scope: str, - parameters: "_models.TagsPatchResource", + parameters: _models.TagsPatchResource, + *, + content_type: str = "application/json", **kwargs: Any - ) -> "_models.TagsResource": + ) -> _models.TagsResource: """Selectively updates the set of tags on a resource or subscription. This operation allows replacing, merging or selectively deleting tags on the specified resource @@ -10575,151 +12137,222 @@ def update_at_scope( names. The 'delete' option allows selectively deleting tags based on given names or name/value pairs. - :param scope: The resource scope. + :param scope: The resource scope. Required. :type scope: str - :param parameters: + :param parameters: Required. :type parameters: ~azure.mgmt.resource.resources.v2021_01_01.models.TagsPatchResource + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: TagsResource or the result of cls(response) + :rtype: ~azure.mgmt.resource.resources.v2021_01_01.models.TagsResource + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + def update_at_scope( + self, scope: str, parameters: IO, *, content_type: str = "application/json", **kwargs: Any + ) -> _models.TagsResource: + """Selectively updates the set of tags on a resource or subscription. + + This operation allows replacing, merging or selectively deleting tags on the specified resource + or subscription. The specified entity can have a maximum of 50 tags at the end of the + operation. The 'replace' option replaces the entire set of existing tags with a new set. The + 'merge' option allows adding tags with new names and updating the values of tags with existing + names. The 'delete' option allows selectively deleting tags based on given names or name/value + pairs. + + :param scope: The resource scope. Required. + :type scope: str + :param parameters: Required. + :type parameters: IO + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: TagsResource or the result of cls(response) + :rtype: ~azure.mgmt.resource.resources.v2021_01_01.models.TagsResource + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace + def update_at_scope( + self, scope: str, parameters: Union[_models.TagsPatchResource, IO], **kwargs: Any + ) -> _models.TagsResource: + """Selectively updates the set of tags on a resource or subscription. + + This operation allows replacing, merging or selectively deleting tags on the specified resource + or subscription. The specified entity can have a maximum of 50 tags at the end of the + operation. The 'replace' option replaces the entire set of existing tags with a new set. The + 'merge' option allows adding tags with new names and updating the values of tags with existing + names. The 'delete' option allows selectively deleting tags based on given names or name/value + pairs. + + :param scope: The resource scope. Required. + :type scope: str + :param parameters: Is either a model type or a IO type. Required. + :type parameters: ~azure.mgmt.resource.resources.v2021_01_01.models.TagsPatchResource or IO + :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. + Default value is None. + :paramtype content_type: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: TagsResource, or the result of cls(response) + :return: TagsResource or the result of cls(response) :rtype: ~azure.mgmt.resource.resources.v2021_01_01.models.TagsResource - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.TagsResource"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', "2021-01-01") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-01-01")) # type: str + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.TagsResource] - _json = self._serialize.body(parameters, 'TagsPatchResource') + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(parameters, (IO, bytes)): + _content = parameters + else: + _json = self._serialize.body(parameters, "TagsPatchResource") request = build_tags_update_at_scope_request( scope=scope, api_version=api_version, content_type=content_type, json=_json, - template_url=self.update_at_scope.metadata['url'], + content=_content, + template_url=self.update_at_scope.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) - deserialized = self._deserialize('TagsResource', pipeline_response) + deserialized = self._deserialize("TagsResource", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - update_at_scope.metadata = {'url': "/{scope}/providers/Microsoft.Resources/tags/default"} # type: ignore - + update_at_scope.metadata = {"url": "/{scope}/providers/Microsoft.Resources/tags/default"} # type: ignore @distributed_trace - def get_at_scope( - self, - scope: str, - **kwargs: Any - ) -> "_models.TagsResource": + def get_at_scope(self, scope: str, **kwargs: Any) -> _models.TagsResource: """Gets the entire set of tags on a resource or subscription. Gets the entire set of tags on a resource or subscription. - :param scope: The resource scope. + :param scope: The resource scope. Required. :type scope: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: TagsResource, or the result of cls(response) + :return: TagsResource or the result of cls(response) :rtype: ~azure.mgmt.resource.resources.v2021_01_01.models.TagsResource - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.TagsResource"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) - api_version = kwargs.pop('api_version', "2021-01-01") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-01-01")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[_models.TagsResource] - request = build_tags_get_at_scope_request( scope=scope, api_version=api_version, - template_url=self.get_at_scope.metadata['url'], + template_url=self.get_at_scope.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) - deserialized = self._deserialize('TagsResource', pipeline_response) + deserialized = self._deserialize("TagsResource", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - get_at_scope.metadata = {'url': "/{scope}/providers/Microsoft.Resources/tags/default"} # type: ignore - + get_at_scope.metadata = {"url": "/{scope}/providers/Microsoft.Resources/tags/default"} # type: ignore @distributed_trace - def delete_at_scope( # pylint: disable=inconsistent-return-statements - self, - scope: str, - **kwargs: Any - ) -> None: + def delete_at_scope(self, scope: str, **kwargs: Any) -> None: # pylint: disable=inconsistent-return-statements """Deletes the entire set of tags on a resource or subscription. Deletes the entire set of tags on a resource or subscription. - :param scope: The resource scope. + :param scope: The resource scope. Required. :type scope: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: None, or the result of cls(response) + :return: None or the result of cls(response) :rtype: None - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType[None] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + 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', "2021-01-01") # type: str + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-01-01")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[None] - request = build_tags_delete_at_scope_request( scope=scope, api_version=api_version, - template_url=self.delete_at_scope.metadata['url'], + template_url=self.delete_at_scope.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200]: @@ -10729,143 +12362,145 @@ def delete_at_scope( # pylint: disable=inconsistent-return-statements if cls: return cls(pipeline_response, None, {}) - delete_at_scope.metadata = {'url': "/{scope}/providers/Microsoft.Resources/tags/default"} # type: ignore + delete_at_scope.metadata = {"url": "/{scope}/providers/Microsoft.Resources/tags/default"} # type: ignore -class DeploymentOperationsOperations(object): - """DeploymentOperationsOperations operations. - You should not instantiate this class directly. Instead, you should create a Client instance that - instantiates it for you and attaches it as an attribute. +class DeploymentOperationsOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. - :ivar models: Alias to model classes used in this operation group. - :type models: ~azure.mgmt.resource.resources.v2021_01_01.models - :param client: Client for service requests. - :param config: Configuration of service client. - :param serializer: An object model serializer. - :param deserializer: An object model deserializer. + Instead, you should access the following operations through + :class:`~azure.mgmt.resource.resources.v2021_01_01.ResourceManagementClient`'s + :attr:`deployment_operations` attribute. """ models = _models - def __init__(self, client, config, serializer, deserializer): - self._client = client - self._serialize = serializer - self._deserialize = deserializer - self._config = config + def __init__(self, *args, **kwargs): + input_args = list(args) + self._client = input_args.pop(0) if input_args else kwargs.pop("client") + self._config = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") @distributed_trace def get_at_scope( - self, - scope: str, - deployment_name: str, - operation_id: str, - **kwargs: Any - ) -> "_models.DeploymentOperation": + self, scope: str, deployment_name: str, operation_id: str, **kwargs: Any + ) -> _models.DeploymentOperation: """Gets a deployments operation. - :param scope: The resource scope. + :param scope: The resource scope. Required. :type scope: str - :param deployment_name: The name of the deployment. + :param deployment_name: The name of the deployment. Required. :type deployment_name: str - :param operation_id: The ID of the operation to get. + :param operation_id: The ID of the operation to get. Required. :type operation_id: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: DeploymentOperation, or the result of cls(response) + :return: DeploymentOperation or the result of cls(response) :rtype: ~azure.mgmt.resource.resources.v2021_01_01.models.DeploymentOperation - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.DeploymentOperation"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) - api_version = kwargs.pop('api_version', "2021-01-01") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-01-01")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[_models.DeploymentOperation] - request = build_deployment_operations_get_at_scope_request( scope=scope, deployment_name=deployment_name, operation_id=operation_id, api_version=api_version, - template_url=self.get_at_scope.metadata['url'], + template_url=self.get_at_scope.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) - deserialized = self._deserialize('DeploymentOperation', pipeline_response) + deserialized = self._deserialize("DeploymentOperation", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - get_at_scope.metadata = {'url': "/{scope}/providers/Microsoft.Resources/deployments/{deploymentName}/operations/{operationId}"} # type: ignore - + get_at_scope.metadata = {"url": "/{scope}/providers/Microsoft.Resources/deployments/{deploymentName}/operations/{operationId}"} # type: ignore @distributed_trace def list_at_scope( - self, - scope: str, - deployment_name: str, - top: Optional[int] = None, - **kwargs: Any - ) -> Iterable["_models.DeploymentOperationsListResult"]: + self, scope: str, deployment_name: str, top: Optional[int] = None, **kwargs: Any + ) -> Iterable["_models.DeploymentOperation"]: """Gets all deployments operations for a deployment. - :param scope: The resource scope. + :param scope: The resource scope. Required. :type scope: str - :param deployment_name: The name of the deployment. + :param deployment_name: The name of the deployment. Required. :type deployment_name: str :param top: The number of results to return. Default value is None. :type top: int :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either DeploymentOperationsListResult or the result of - cls(response) + :return: An iterator like instance of either DeploymentOperation or the result of cls(response) :rtype: - ~azure.core.paging.ItemPaged[~azure.mgmt.resource.resources.v2021_01_01.models.DeploymentOperationsListResult] - :raises: ~azure.core.exceptions.HttpResponseError + ~azure.core.paging.ItemPaged[~azure.mgmt.resource.resources.v2021_01_01.models.DeploymentOperation] + :raises ~azure.core.exceptions.HttpResponseError: """ - api_version = kwargs.pop('api_version', "2021-01-01") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-01-01")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[_models.DeploymentOperationsListResult] - cls = kwargs.pop('cls', None) # type: ClsType["_models.DeploymentOperationsListResult"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) + def prepare_request(next_link=None): if not next_link: - + request = build_deployment_operations_list_at_scope_request( scope=scope, deployment_name=deployment_name, - api_version=api_version, top=top, - template_url=self.list_at_scope.metadata['url'], + api_version=api_version, + template_url=self.list_at_scope.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore else: - - request = build_deployment_operations_list_at_scope_request( - scope=scope, - deployment_name=deployment_name, - template_url=next_link, - ) + # make call to next link with the client's api-version + _parsed_next_link = urlparse(next_link) + _next_request_params = case_insensitive_dict(parse_qs(_parsed_next_link.query)) + _next_request_params["api-version"] = self._config.api_version + request = HttpRequest("GET", urljoin(next_link, _parsed_next_link.path), params=_next_request_params) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore request.method = "GET" return request @@ -10879,10 +12514,8 @@ def extract_data(pipeline_response): def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) response = pipeline_response.http_response @@ -10892,116 +12525,121 @@ def get_next(next_link=None): return pipeline_response + return ItemPaged(get_next, extract_data) - return ItemPaged( - get_next, extract_data - ) - list_at_scope.metadata = {'url': "/{scope}/providers/Microsoft.Resources/deployments/{deploymentName}/operations"} # type: ignore + list_at_scope.metadata = {"url": "/{scope}/providers/Microsoft.Resources/deployments/{deploymentName}/operations"} # type: ignore @distributed_trace def get_at_tenant_scope( - self, - deployment_name: str, - operation_id: str, - **kwargs: Any - ) -> "_models.DeploymentOperation": + self, deployment_name: str, operation_id: str, **kwargs: Any + ) -> _models.DeploymentOperation: """Gets a deployments operation. - :param deployment_name: The name of the deployment. + :param deployment_name: The name of the deployment. Required. :type deployment_name: str - :param operation_id: The ID of the operation to get. + :param operation_id: The ID of the operation to get. Required. :type operation_id: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: DeploymentOperation, or the result of cls(response) + :return: DeploymentOperation or the result of cls(response) :rtype: ~azure.mgmt.resource.resources.v2021_01_01.models.DeploymentOperation - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.DeploymentOperation"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + 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', "2021-01-01") # type: str + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-01-01")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[_models.DeploymentOperation] - request = build_deployment_operations_get_at_tenant_scope_request( deployment_name=deployment_name, operation_id=operation_id, api_version=api_version, - template_url=self.get_at_tenant_scope.metadata['url'], + template_url=self.get_at_tenant_scope.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) - deserialized = self._deserialize('DeploymentOperation', pipeline_response) + deserialized = self._deserialize("DeploymentOperation", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - get_at_tenant_scope.metadata = {'url': "/providers/Microsoft.Resources/deployments/{deploymentName}/operations/{operationId}"} # type: ignore - + get_at_tenant_scope.metadata = {"url": "/providers/Microsoft.Resources/deployments/{deploymentName}/operations/{operationId}"} # type: ignore @distributed_trace def list_at_tenant_scope( - self, - deployment_name: str, - top: Optional[int] = None, - **kwargs: Any - ) -> Iterable["_models.DeploymentOperationsListResult"]: + self, deployment_name: str, top: Optional[int] = None, **kwargs: Any + ) -> Iterable["_models.DeploymentOperation"]: """Gets all deployments operations for a deployment. - :param deployment_name: The name of the deployment. + :param deployment_name: The name of the deployment. Required. :type deployment_name: str :param top: The number of results to return. Default value is None. :type top: int :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either DeploymentOperationsListResult or the result of - cls(response) + :return: An iterator like instance of either DeploymentOperation or the result of cls(response) :rtype: - ~azure.core.paging.ItemPaged[~azure.mgmt.resource.resources.v2021_01_01.models.DeploymentOperationsListResult] - :raises: ~azure.core.exceptions.HttpResponseError + ~azure.core.paging.ItemPaged[~azure.mgmt.resource.resources.v2021_01_01.models.DeploymentOperation] + :raises ~azure.core.exceptions.HttpResponseError: """ - api_version = kwargs.pop('api_version', "2021-01-01") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-01-01")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[_models.DeploymentOperationsListResult] - cls = kwargs.pop('cls', None) # type: ClsType["_models.DeploymentOperationsListResult"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) + def prepare_request(next_link=None): if not next_link: - + request = build_deployment_operations_list_at_tenant_scope_request( deployment_name=deployment_name, - api_version=api_version, top=top, - template_url=self.list_at_tenant_scope.metadata['url'], + api_version=api_version, + template_url=self.list_at_tenant_scope.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore else: - - request = build_deployment_operations_list_at_tenant_scope_request( - deployment_name=deployment_name, - template_url=next_link, - ) + # make call to next link with the client's api-version + _parsed_next_link = urlparse(next_link) + _next_request_params = case_insensitive_dict(parse_qs(_parsed_next_link.query)) + _next_request_params["api-version"] = self._config.api_version + request = HttpRequest("GET", urljoin(next_link, _parsed_next_link.path), params=_next_request_params) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore request.method = "GET" return request @@ -11015,10 +12653,8 @@ def extract_data(pipeline_response): def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) response = pipeline_response.http_response @@ -11028,125 +12664,127 @@ def get_next(next_link=None): return pipeline_response + return ItemPaged(get_next, extract_data) - return ItemPaged( - get_next, extract_data - ) - list_at_tenant_scope.metadata = {'url': "/providers/Microsoft.Resources/deployments/{deploymentName}/operations"} # type: ignore + list_at_tenant_scope.metadata = {"url": "/providers/Microsoft.Resources/deployments/{deploymentName}/operations"} # type: ignore @distributed_trace def get_at_management_group_scope( - self, - group_id: str, - deployment_name: str, - operation_id: str, - **kwargs: Any - ) -> "_models.DeploymentOperation": + self, group_id: str, deployment_name: str, operation_id: str, **kwargs: Any + ) -> _models.DeploymentOperation: """Gets a deployments operation. - :param group_id: The management group ID. + :param group_id: The management group ID. Required. :type group_id: str - :param deployment_name: The name of the deployment. + :param deployment_name: The name of the deployment. Required. :type deployment_name: str - :param operation_id: The ID of the operation to get. + :param operation_id: The ID of the operation to get. Required. :type operation_id: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: DeploymentOperation, or the result of cls(response) + :return: DeploymentOperation or the result of cls(response) :rtype: ~azure.mgmt.resource.resources.v2021_01_01.models.DeploymentOperation - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.DeploymentOperation"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + 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', "2021-01-01") # type: str + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-01-01")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[_models.DeploymentOperation] - request = build_deployment_operations_get_at_management_group_scope_request( group_id=group_id, deployment_name=deployment_name, operation_id=operation_id, api_version=api_version, - template_url=self.get_at_management_group_scope.metadata['url'], + template_url=self.get_at_management_group_scope.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) - deserialized = self._deserialize('DeploymentOperation', pipeline_response) + deserialized = self._deserialize("DeploymentOperation", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - get_at_management_group_scope.metadata = {'url': "/providers/Microsoft.Management/managementGroups/{groupId}/providers/Microsoft.Resources/deployments/{deploymentName}/operations/{operationId}"} # type: ignore - + get_at_management_group_scope.metadata = {"url": "/providers/Microsoft.Management/managementGroups/{groupId}/providers/Microsoft.Resources/deployments/{deploymentName}/operations/{operationId}"} # type: ignore @distributed_trace def list_at_management_group_scope( - self, - group_id: str, - deployment_name: str, - top: Optional[int] = None, - **kwargs: Any - ) -> Iterable["_models.DeploymentOperationsListResult"]: + self, group_id: str, deployment_name: str, top: Optional[int] = None, **kwargs: Any + ) -> Iterable["_models.DeploymentOperation"]: """Gets all deployments operations for a deployment. - :param group_id: The management group ID. + :param group_id: The management group ID. Required. :type group_id: str - :param deployment_name: The name of the deployment. + :param deployment_name: The name of the deployment. Required. :type deployment_name: str :param top: The number of results to return. Default value is None. :type top: int :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either DeploymentOperationsListResult or the result of - cls(response) + :return: An iterator like instance of either DeploymentOperation or the result of cls(response) :rtype: - ~azure.core.paging.ItemPaged[~azure.mgmt.resource.resources.v2021_01_01.models.DeploymentOperationsListResult] - :raises: ~azure.core.exceptions.HttpResponseError + ~azure.core.paging.ItemPaged[~azure.mgmt.resource.resources.v2021_01_01.models.DeploymentOperation] + :raises ~azure.core.exceptions.HttpResponseError: """ - api_version = kwargs.pop('api_version', "2021-01-01") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-01-01")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[_models.DeploymentOperationsListResult] - cls = kwargs.pop('cls', None) # type: ClsType["_models.DeploymentOperationsListResult"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) + def prepare_request(next_link=None): if not next_link: - + request = build_deployment_operations_list_at_management_group_scope_request( group_id=group_id, deployment_name=deployment_name, - api_version=api_version, top=top, - template_url=self.list_at_management_group_scope.metadata['url'], + api_version=api_version, + template_url=self.list_at_management_group_scope.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore else: - - request = build_deployment_operations_list_at_management_group_scope_request( - group_id=group_id, - deployment_name=deployment_name, - template_url=next_link, - ) + # make call to next link with the client's api-version + _parsed_next_link = urlparse(next_link) + _next_request_params = case_insensitive_dict(parse_qs(_parsed_next_link.query)) + _next_request_params["api-version"] = self._config.api_version + request = HttpRequest("GET", urljoin(next_link, _parsed_next_link.path), params=_next_request_params) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore request.method = "GET" return request @@ -11160,10 +12798,8 @@ def extract_data(pipeline_response): def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) response = pipeline_response.http_response @@ -11173,119 +12809,123 @@ def get_next(next_link=None): return pipeline_response + return ItemPaged(get_next, extract_data) - return ItemPaged( - get_next, extract_data - ) - list_at_management_group_scope.metadata = {'url': "/providers/Microsoft.Management/managementGroups/{groupId}/providers/Microsoft.Resources/deployments/{deploymentName}/operations"} # type: ignore + list_at_management_group_scope.metadata = {"url": "/providers/Microsoft.Management/managementGroups/{groupId}/providers/Microsoft.Resources/deployments/{deploymentName}/operations"} # type: ignore @distributed_trace def get_at_subscription_scope( - self, - deployment_name: str, - operation_id: str, - **kwargs: Any - ) -> "_models.DeploymentOperation": + self, deployment_name: str, operation_id: str, **kwargs: Any + ) -> _models.DeploymentOperation: """Gets a deployments operation. - :param deployment_name: The name of the deployment. + :param deployment_name: The name of the deployment. Required. :type deployment_name: str - :param operation_id: The ID of the operation to get. + :param operation_id: The ID of the operation to get. Required. :type operation_id: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: DeploymentOperation, or the result of cls(response) + :return: DeploymentOperation or the result of cls(response) :rtype: ~azure.mgmt.resource.resources.v2021_01_01.models.DeploymentOperation - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.DeploymentOperation"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) - api_version = kwargs.pop('api_version', "2021-01-01") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-01-01")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[_models.DeploymentOperation] - request = build_deployment_operations_get_at_subscription_scope_request( deployment_name=deployment_name, operation_id=operation_id, subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.get_at_subscription_scope.metadata['url'], + template_url=self.get_at_subscription_scope.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) - deserialized = self._deserialize('DeploymentOperation', pipeline_response) + deserialized = self._deserialize("DeploymentOperation", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - get_at_subscription_scope.metadata = {'url': "/subscriptions/{subscriptionId}/providers/Microsoft.Resources/deployments/{deploymentName}/operations/{operationId}"} # type: ignore - + get_at_subscription_scope.metadata = {"url": "/subscriptions/{subscriptionId}/providers/Microsoft.Resources/deployments/{deploymentName}/operations/{operationId}"} # type: ignore @distributed_trace def list_at_subscription_scope( - self, - deployment_name: str, - top: Optional[int] = None, - **kwargs: Any - ) -> Iterable["_models.DeploymentOperationsListResult"]: + self, deployment_name: str, top: Optional[int] = None, **kwargs: Any + ) -> Iterable["_models.DeploymentOperation"]: """Gets all deployments operations for a deployment. - :param deployment_name: The name of the deployment. + :param deployment_name: The name of the deployment. Required. :type deployment_name: str :param top: The number of results to return. Default value is None. :type top: int :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either DeploymentOperationsListResult or the result of - cls(response) + :return: An iterator like instance of either DeploymentOperation or the result of cls(response) :rtype: - ~azure.core.paging.ItemPaged[~azure.mgmt.resource.resources.v2021_01_01.models.DeploymentOperationsListResult] - :raises: ~azure.core.exceptions.HttpResponseError + ~azure.core.paging.ItemPaged[~azure.mgmt.resource.resources.v2021_01_01.models.DeploymentOperation] + :raises ~azure.core.exceptions.HttpResponseError: """ - api_version = kwargs.pop('api_version', "2021-01-01") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-01-01")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[_models.DeploymentOperationsListResult] - cls = kwargs.pop('cls', None) # type: ClsType["_models.DeploymentOperationsListResult"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) + def prepare_request(next_link=None): if not next_link: - + request = build_deployment_operations_list_at_subscription_scope_request( deployment_name=deployment_name, subscription_id=self._config.subscription_id, - api_version=api_version, top=top, - template_url=self.list_at_subscription_scope.metadata['url'], + api_version=api_version, + template_url=self.list_at_subscription_scope.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore else: - - request = build_deployment_operations_list_at_subscription_scope_request( - deployment_name=deployment_name, - subscription_id=self._config.subscription_id, - template_url=next_link, - ) + # make call to next link with the client's api-version + _parsed_next_link = urlparse(next_link) + _next_request_params = case_insensitive_dict(parse_qs(_parsed_next_link.query)) + _next_request_params["api-version"] = self._config.api_version + request = HttpRequest("GET", urljoin(next_link, _parsed_next_link.path), params=_next_request_params) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore request.method = "GET" return request @@ -11299,10 +12939,8 @@ def extract_data(pipeline_response): def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) response = pipeline_response.http_response @@ -11312,128 +12950,131 @@ def get_next(next_link=None): return pipeline_response + return ItemPaged(get_next, extract_data) - return ItemPaged( - get_next, extract_data - ) - list_at_subscription_scope.metadata = {'url': "/subscriptions/{subscriptionId}/providers/Microsoft.Resources/deployments/{deploymentName}/operations"} # type: ignore + list_at_subscription_scope.metadata = {"url": "/subscriptions/{subscriptionId}/providers/Microsoft.Resources/deployments/{deploymentName}/operations"} # type: ignore @distributed_trace def get( - self, - resource_group_name: str, - deployment_name: str, - operation_id: str, - **kwargs: Any - ) -> "_models.DeploymentOperation": + self, resource_group_name: str, deployment_name: str, operation_id: str, **kwargs: Any + ) -> _models.DeploymentOperation: """Gets a deployments operation. :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. :type resource_group_name: str - :param deployment_name: The name of the deployment. + :param deployment_name: The name of the deployment. Required. :type deployment_name: str - :param operation_id: The ID of the operation to get. + :param operation_id: The ID of the operation to get. Required. :type operation_id: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: DeploymentOperation, or the result of cls(response) + :return: DeploymentOperation or the result of cls(response) :rtype: ~azure.mgmt.resource.resources.v2021_01_01.models.DeploymentOperation - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.DeploymentOperation"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + 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', "2021-01-01") # type: str + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-01-01")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[_models.DeploymentOperation] - request = build_deployment_operations_get_request( resource_group_name=resource_group_name, deployment_name=deployment_name, operation_id=operation_id, subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.get.metadata['url'], + template_url=self.get.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) - deserialized = self._deserialize('DeploymentOperation', pipeline_response) + deserialized = self._deserialize("DeploymentOperation", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - get.metadata = {'url': "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/deployments/{deploymentName}/operations/{operationId}"} # type: ignore - + get.metadata = {"url": "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/deployments/{deploymentName}/operations/{operationId}"} # type: ignore @distributed_trace def list( - self, - resource_group_name: str, - deployment_name: str, - top: Optional[int] = None, - **kwargs: Any - ) -> Iterable["_models.DeploymentOperationsListResult"]: + self, resource_group_name: str, deployment_name: str, top: Optional[int] = None, **kwargs: Any + ) -> Iterable["_models.DeploymentOperation"]: """Gets all deployments operations for a deployment. :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. :type resource_group_name: str - :param deployment_name: The name of the deployment. + :param deployment_name: The name of the deployment. Required. :type deployment_name: str :param top: The number of results to return. Default value is None. :type top: int :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either DeploymentOperationsListResult or the result of - cls(response) + :return: An iterator like instance of either DeploymentOperation or the result of cls(response) :rtype: - ~azure.core.paging.ItemPaged[~azure.mgmt.resource.resources.v2021_01_01.models.DeploymentOperationsListResult] - :raises: ~azure.core.exceptions.HttpResponseError + ~azure.core.paging.ItemPaged[~azure.mgmt.resource.resources.v2021_01_01.models.DeploymentOperation] + :raises ~azure.core.exceptions.HttpResponseError: """ - api_version = kwargs.pop('api_version', "2021-01-01") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-01-01")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[_models.DeploymentOperationsListResult] - cls = kwargs.pop('cls', None) # type: ClsType["_models.DeploymentOperationsListResult"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) + def prepare_request(next_link=None): if not next_link: - + request = build_deployment_operations_list_request( resource_group_name=resource_group_name, deployment_name=deployment_name, subscription_id=self._config.subscription_id, - api_version=api_version, top=top, - template_url=self.list.metadata['url'], + 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.url = self._client.format_url(request.url) # type: ignore else: - - request = build_deployment_operations_list_request( - resource_group_name=resource_group_name, - deployment_name=deployment_name, - subscription_id=self._config.subscription_id, - template_url=next_link, - ) + # make call to next link with the client's api-version + _parsed_next_link = urlparse(next_link) + _next_request_params = case_insensitive_dict(parse_qs(_parsed_next_link.query)) + _next_request_params["api-version"] = self._config.api_version + request = HttpRequest("GET", urljoin(next_link, _parsed_next_link.path), params=_next_request_params) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore request.method = "GET" return request @@ -11447,10 +13088,8 @@ def extract_data(pipeline_response): def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) response = pipeline_response.http_response @@ -11460,8 +13099,6 @@ def get_next(next_link=None): return pipeline_response + return ItemPaged(get_next, extract_data) - return ItemPaged( - get_next, extract_data - ) - list.metadata = {'url': "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/deployments/{deploymentName}/operations"} # type: ignore + list.metadata = {"url": "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/deployments/{deploymentName}/operations"} # type: ignore diff --git a/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/resources/v2021_01_01/operations/_patch.py b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/resources/v2021_01_01/operations/_patch.py new file mode 100644 index 0000000000000..f7dd32510333d --- /dev/null +++ b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/resources/v2021_01_01/operations/_patch.py @@ -0,0 +1,20 @@ +# ------------------------------------ +# Copyright (c) Microsoft Corporation. +# Licensed under the MIT License. +# ------------------------------------ +"""Customize generated code here. + +Follow our quickstart for examples: https://aka.ms/azsdk/python/dpcodegen/python/customize +""" +from typing import List + +__all__: List[str] = [] # Add all objects you want publicly available to users at this package level + + +def patch_sdk(): + """Do not remove from this file. + + `patch_sdk` is a last resort escape hatch that allows you to do customizations + you can't accomplish using the techniques described in + https://aka.ms/azsdk/python/dpcodegen/python/customize + """ diff --git a/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/resources/v2021_04_01/__init__.py b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/resources/v2021_04_01/__init__.py index 449220069f2f2..2b201470d075e 100644 --- a/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/resources/v2021_04_01/__init__.py +++ b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/resources/v2021_04_01/__init__.py @@ -10,9 +10,15 @@ from ._version import VERSION __version__ = VERSION -__all__ = ['ResourceManagementClient'] -# `._patch.py` is used for handwritten extensions to the generated code -# Example: https://github.com/Azure/azure-sdk-for-python/blob/main/doc/dev/customize_code/how-to-patch-sdk-code.md -from ._patch import patch_sdk -patch_sdk() +try: + from ._patch import __all__ as _patch_all + from ._patch import * # type: ignore # pylint: disable=unused-wildcard-import +except ImportError: + _patch_all = [] +from ._patch import patch_sdk as _patch_sdk + +__all__ = ["ResourceManagementClient"] +__all__.extend([p for p in _patch_all if p not in __all__]) + +_patch_sdk() diff --git a/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/resources/v2021_04_01/_configuration.py b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/resources/v2021_04_01/_configuration.py index 162dce2f9b2e8..f576b5443d4fe 100644 --- a/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/resources/v2021_04_01/_configuration.py +++ b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/resources/v2021_04_01/_configuration.py @@ -25,23 +25,18 @@ class ResourceManagementClientConfiguration(Configuration): # pylint: disable=t Note that all parameters used to create this instance are saved as instance attributes. - :param credential: Credential needed for the client to connect to Azure. + :param credential: Credential needed for the client to connect to Azure. Required. :type credential: ~azure.core.credentials.TokenCredential - :param subscription_id: The Microsoft Azure subscription ID. + :param subscription_id: The Microsoft Azure subscription ID. Required. :type subscription_id: str :keyword api_version: Api Version. Default value is "2021-04-01". Note that overriding this default value may result in unsupported behavior. :paramtype api_version: str """ - def __init__( - self, - credential: "TokenCredential", - subscription_id: str, - **kwargs: Any - ) -> None: + def __init__(self, credential: "TokenCredential", subscription_id: str, **kwargs: Any) -> None: super(ResourceManagementClientConfiguration, self).__init__(**kwargs) - api_version = kwargs.pop('api_version', "2021-04-01") # type: str + api_version = kwargs.pop("api_version", "2021-04-01") # type: str if credential is None: raise ValueError("Parameter 'credential' must not be None.") @@ -51,23 +46,24 @@ def __init__( self.credential = credential self.subscription_id = subscription_id self.api_version = api_version - self.credential_scopes = kwargs.pop('credential_scopes', ['https://management.azure.com/.default']) - kwargs.setdefault('sdk_moniker', 'mgmt-resource/{}'.format(VERSION)) + self.credential_scopes = kwargs.pop("credential_scopes", ["https://management.azure.com/.default"]) + kwargs.setdefault("sdk_moniker", "mgmt-resource/{}".format(VERSION)) self._configure(**kwargs) def _configure( - self, - **kwargs # type: Any + self, **kwargs # type: Any ): # type: (...) -> 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) - self.logging_policy = kwargs.get('logging_policy') or policies.NetworkTraceLoggingPolicy(**kwargs) - self.http_logging_policy = kwargs.get('http_logging_policy') or ARMHttpLoggingPolicy(**kwargs) - self.retry_policy = kwargs.get('retry_policy') or policies.RetryPolicy(**kwargs) - self.custom_hook_policy = kwargs.get('custom_hook_policy') or policies.CustomHookPolicy(**kwargs) - self.redirect_policy = kwargs.get('redirect_policy') or policies.RedirectPolicy(**kwargs) - self.authentication_policy = kwargs.get('authentication_policy') + 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) + self.logging_policy = kwargs.get("logging_policy") or policies.NetworkTraceLoggingPolicy(**kwargs) + self.http_logging_policy = kwargs.get("http_logging_policy") or ARMHttpLoggingPolicy(**kwargs) + self.retry_policy = kwargs.get("retry_policy") or policies.RetryPolicy(**kwargs) + self.custom_hook_policy = kwargs.get("custom_hook_policy") or policies.CustomHookPolicy(**kwargs) + self.redirect_policy = kwargs.get("redirect_policy") or policies.RedirectPolicy(**kwargs) + self.authentication_policy = kwargs.get("authentication_policy") if self.credential and not self.authentication_policy: - self.authentication_policy = ARMChallengeAuthenticationPolicy(self.credential, *self.credential_scopes, **kwargs) + self.authentication_policy = ARMChallengeAuthenticationPolicy( + self.credential, *self.credential_scopes, **kwargs + ) diff --git a/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/resources/v2021_04_01/_metadata.json b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/resources/v2021_04_01/_metadata.json index 641d2f7ffb462..514fb3ac6324b 100644 --- a/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/resources/v2021_04_01/_metadata.json +++ b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/resources/v2021_04_01/_metadata.json @@ -10,20 +10,20 @@ "azure_arm": true, "has_lro_operations": true, "client_side_validation": false, - "sync_imports": "{\"typing\": {\"azurecore\": {\"azure.core.credentials\": [\"TokenCredential\"]}}, \"regular\": {\"azurecore\": {\"azure.profiles\": [\"KnownProfiles\", \"ProfileDefinition\"], \"azure.profiles.multiapiclient\": [\"MultiApiClientMixin\"], \"azure.mgmt.core\": [\"ARMPipelineClient\"]}, \"local\": {\"._configuration\": [\"ResourceManagementClientConfiguration\"]}, \"thirdparty\": {\"msrest\": [\"Deserializer\", \"Serializer\"]}}, \"conditional\": {\"stdlib\": {\"typing\": [\"Any\", \"Optional\"]}}}", - "async_imports": "{\"typing\": {\"azurecore\": {\"azure.core.credentials_async\": [\"AsyncTokenCredential\"], \"azure.core.credentials\": [\"TokenCredential\"]}}, \"regular\": {\"azurecore\": {\"azure.profiles\": [\"KnownProfiles\", \"ProfileDefinition\"], \"azure.profiles.multiapiclient\": [\"MultiApiClientMixin\"], \"azure.mgmt.core\": [\"AsyncARMPipelineClient\"]}, \"local\": {\"._configuration\": [\"ResourceManagementClientConfiguration\"]}, \"thirdparty\": {\"msrest\": [\"Deserializer\", \"Serializer\"]}}, \"conditional\": {\"stdlib\": {\"typing\": [\"Any\", \"Optional\"]}}}" + "sync_imports": "{\"conditional\": {\"stdlib\": {\"typing\": [\"Any\", \"Optional\"]}}, \"regular\": {\"azurecore\": {\"azure.mgmt.core\": [\"ARMPipelineClient\"], \"azure.profiles\": [\"KnownProfiles\", \"ProfileDefinition\"], \"azure.profiles.multiapiclient\": [\"MultiApiClientMixin\"]}, \"local\": {\"._configuration\": [\"ResourceManagementClientConfiguration\"], \".._serialization\": [\"Deserializer\", \"Serializer\"]}}, \"typing\": {\"azurecore\": {\"azure.core.credentials\": [\"TokenCredential\"]}}}", + "async_imports": "{\"conditional\": {\"stdlib\": {\"typing\": [\"Any\", \"Optional\"]}}, \"regular\": {\"azurecore\": {\"azure.mgmt.core\": [\"AsyncARMPipelineClient\"], \"azure.profiles\": [\"KnownProfiles\", \"ProfileDefinition\"], \"azure.profiles.multiapiclient\": [\"MultiApiClientMixin\"]}, \"local\": {\"._configuration\": [\"ResourceManagementClientConfiguration\"], \"..._serialization\": [\"Deserializer\", \"Serializer\"]}}, \"typing\": {\"azurecore\": {\"azure.core.credentials_async\": [\"AsyncTokenCredential\"]}}}" }, "global_parameters": { "sync": { "credential": { - "signature": "credential, # type: \"TokenCredential\"", - "description": "Credential needed for the client to connect to Azure.", + "signature": "credential: \"TokenCredential\",", + "description": "Credential needed for the client to connect to Azure. Required.", "docstring_type": "~azure.core.credentials.TokenCredential", "required": true }, "subscription_id": { - "signature": "subscription_id, # type: str", - "description": "The Microsoft Azure subscription ID.", + "signature": "subscription_id: str,", + "description": "The Microsoft Azure subscription ID. Required.", "docstring_type": "str", "required": true } @@ -31,13 +31,13 @@ "async": { "credential": { "signature": "credential: \"AsyncTokenCredential\",", - "description": "Credential needed for the client to connect to Azure.", + "description": "Credential needed for the client to connect to Azure. Required.", "docstring_type": "~azure.core.credentials_async.AsyncTokenCredential", "required": true }, "subscription_id": { "signature": "subscription_id: str,", - "description": "The Microsoft Azure subscription ID.", + "description": "The Microsoft Azure subscription ID. Required.", "docstring_type": "str", "required": true } @@ -54,7 +54,7 @@ "required": false }, "base_url": { - "signature": "base_url=\"https://management.azure.com\", # type: str", + "signature": "base_url: str = \"https://management.azure.com\",", "description": "Service URL", "docstring_type": "str", "required": false diff --git a/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/resources/v2021_04_01/_patch.py b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/resources/v2021_04_01/_patch.py index 74e48ecd07cf3..f99e77fef9861 100644 --- a/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/resources/v2021_04_01/_patch.py +++ b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/resources/v2021_04_01/_patch.py @@ -28,4 +28,4 @@ # This file is used for handwritten extensions to the generated code. Example: # https://github.com/Azure/azure-sdk-for-python/blob/main/doc/dev/customize_code/how-to-patch-sdk-code.md def patch_sdk(): - pass \ No newline at end of file + pass diff --git a/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/resources/v2021_04_01/_resource_management_client.py b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/resources/v2021_04_01/_resource_management_client.py index 7be44f358912e..136930c0847bc 100644 --- a/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/resources/v2021_04_01/_resource_management_client.py +++ b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/resources/v2021_04_01/_resource_management_client.py @@ -9,20 +9,29 @@ from copy import deepcopy from typing import Any, TYPE_CHECKING -from msrest import Deserializer, Serializer - from azure.core.rest import HttpRequest, HttpResponse from azure.mgmt.core import ARMPipelineClient from . import models +from .._serialization import Deserializer, Serializer from ._configuration import ResourceManagementClientConfiguration -from .operations import DeploymentOperationsOperations, DeploymentsOperations, Operations, ProviderResourceTypesOperations, ProvidersOperations, ResourceGroupsOperations, ResourcesOperations, TagsOperations +from .operations import ( + DeploymentOperationsOperations, + DeploymentsOperations, + Operations, + ProviderResourceTypesOperations, + ProvidersOperations, + ResourceGroupsOperations, + ResourcesOperations, + TagsOperations, +) if TYPE_CHECKING: # pylint: disable=unused-import,ungrouped-imports from azure.core.credentials import TokenCredential -class ResourceManagementClient: # pylint: disable=too-many-instance-attributes + +class ResourceManagementClient: # pylint: disable=client-accepts-api-version-keyword,too-many-instance-attributes """Provides operations for working with resources and resource groups. :ivar operations: Operations operations @@ -45,9 +54,9 @@ class ResourceManagementClient: # pylint: disable=too-many-instance-attribute :ivar deployment_operations: DeploymentOperationsOperations operations :vartype deployment_operations: azure.mgmt.resource.resources.v2021_04_01.operations.DeploymentOperationsOperations - :param credential: Credential needed for the client to connect to Azure. + :param credential: Credential needed for the client to connect to Azure. Required. :type credential: ~azure.core.credentials.TokenCredential - :param subscription_id: The Microsoft Azure subscription ID. + :param subscription_id: The Microsoft Azure subscription ID. Required. :type subscription_id: str :param base_url: Service URL. Default value is "https://management.azure.com". :type base_url: str @@ -65,7 +74,9 @@ def __init__( base_url: str = "https://management.azure.com", **kwargs: Any ) -> None: - self._config = ResourceManagementClientConfiguration(credential=credential, subscription_id=subscription_id, **kwargs) + self._config = ResourceManagementClientConfiguration( + credential=credential, subscription_id=subscription_id, **kwargs + ) self._client = ARMPipelineClient(base_url=base_url, config=self._config, **kwargs) client_models = {k: v for k, v in models.__dict__.items() if isinstance(v, type)} @@ -75,18 +86,17 @@ def __init__( self.operations = Operations(self._client, self._config, self._serialize, self._deserialize) self.deployments = DeploymentsOperations(self._client, self._config, self._serialize, self._deserialize) self.providers = ProvidersOperations(self._client, self._config, self._serialize, self._deserialize) - self.provider_resource_types = ProviderResourceTypesOperations(self._client, self._config, self._serialize, self._deserialize) + self.provider_resource_types = ProviderResourceTypesOperations( + self._client, self._config, self._serialize, self._deserialize + ) self.resources = ResourcesOperations(self._client, self._config, self._serialize, self._deserialize) self.resource_groups = ResourceGroupsOperations(self._client, self._config, self._serialize, self._deserialize) self.tags = TagsOperations(self._client, self._config, self._serialize, self._deserialize) - self.deployment_operations = DeploymentOperationsOperations(self._client, self._config, self._serialize, self._deserialize) - + self.deployment_operations = DeploymentOperationsOperations( + self._client, self._config, self._serialize, self._deserialize + ) - def _send_request( - self, - request: HttpRequest, - **kwargs: Any - ) -> HttpResponse: + def _send_request(self, request: HttpRequest, **kwargs: Any) -> HttpResponse: """Runs the network request through the client's chained policies. >>> from azure.core.rest import HttpRequest @@ -95,7 +105,7 @@ def _send_request( >>> response = client._send_request(request) - For more information on this code flow, see https://aka.ms/azsdk/python/protocol/quickstart + For more information on this code flow, see https://aka.ms/azsdk/dpcodegen/python/send_request :param request: The network request you want to make. Required. :type request: ~azure.core.rest.HttpRequest diff --git a/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/resources/v2021_04_01/_vendor.py b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/resources/v2021_04_01/_vendor.py index 138f663c53a4e..9aad73fc743e7 100644 --- a/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/resources/v2021_04_01/_vendor.py +++ b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/resources/v2021_04_01/_vendor.py @@ -7,6 +7,7 @@ from azure.core.pipeline.transport import HttpRequest + def _convert_request(request, files=None): data = request.content if not files else None request = HttpRequest(method=request.method, url=request.url, headers=request.headers, data=data) @@ -14,6 +15,7 @@ def _convert_request(request, files=None): request.set_formdata_body(files) return request + def _format_url_section(template, **kwargs): components = template.split("/") while components: @@ -21,7 +23,5 @@ def _format_url_section(template, **kwargs): 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 - ] + components = [c for c in formatted_components if "{}".format(key.args[0]) not in c] template = "/".join(components) diff --git a/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/resources/v2021_04_01/_version.py b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/resources/v2021_04_01/_version.py index a012ac01c480c..e5754a47ce68f 100644 --- a/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/resources/v2021_04_01/_version.py +++ b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/resources/v2021_04_01/_version.py @@ -6,4 +6,4 @@ # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -VERSION = "21.1.0" +VERSION = "1.0.0b1" diff --git a/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/resources/v2021_04_01/aio/__init__.py b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/resources/v2021_04_01/aio/__init__.py index c6c3cf64a37a6..98d6782c2530c 100644 --- a/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/resources/v2021_04_01/aio/__init__.py +++ b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/resources/v2021_04_01/aio/__init__.py @@ -7,9 +7,15 @@ # -------------------------------------------------------------------------- from ._resource_management_client import ResourceManagementClient -__all__ = ['ResourceManagementClient'] -# `._patch.py` is used for handwritten extensions to the generated code -# Example: https://github.com/Azure/azure-sdk-for-python/blob/main/doc/dev/customize_code/how-to-patch-sdk-code.md -from ._patch import patch_sdk -patch_sdk() +try: + from ._patch import __all__ as _patch_all + from ._patch import * # type: ignore # pylint: disable=unused-wildcard-import +except ImportError: + _patch_all = [] +from ._patch import patch_sdk as _patch_sdk + +__all__ = ["ResourceManagementClient"] +__all__.extend([p for p in _patch_all if p not in __all__]) + +_patch_sdk() diff --git a/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/resources/v2021_04_01/aio/_configuration.py b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/resources/v2021_04_01/aio/_configuration.py index 4e7d52700aae7..0e08ae35f43e9 100644 --- a/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/resources/v2021_04_01/aio/_configuration.py +++ b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/resources/v2021_04_01/aio/_configuration.py @@ -25,23 +25,18 @@ class ResourceManagementClientConfiguration(Configuration): # pylint: disable=t Note that all parameters used to create this instance are saved as instance attributes. - :param credential: Credential needed for the client to connect to Azure. + :param credential: Credential needed for the client to connect to Azure. Required. :type credential: ~azure.core.credentials_async.AsyncTokenCredential - :param subscription_id: The Microsoft Azure subscription ID. + :param subscription_id: The Microsoft Azure subscription ID. Required. :type subscription_id: str :keyword api_version: Api Version. Default value is "2021-04-01". Note that overriding this default value may result in unsupported behavior. :paramtype api_version: str """ - def __init__( - self, - credential: "AsyncTokenCredential", - subscription_id: str, - **kwargs: Any - ) -> None: + def __init__(self, credential: "AsyncTokenCredential", subscription_id: str, **kwargs: Any) -> None: super(ResourceManagementClientConfiguration, self).__init__(**kwargs) - api_version = kwargs.pop('api_version', "2021-04-01") # type: str + api_version = kwargs.pop("api_version", "2021-04-01") # type: str if credential is None: raise ValueError("Parameter 'credential' must not be None.") @@ -51,22 +46,21 @@ def __init__( self.credential = credential self.subscription_id = subscription_id self.api_version = api_version - self.credential_scopes = kwargs.pop('credential_scopes', ['https://management.azure.com/.default']) - kwargs.setdefault('sdk_moniker', 'mgmt-resource/{}'.format(VERSION)) + self.credential_scopes = kwargs.pop("credential_scopes", ["https://management.azure.com/.default"]) + kwargs.setdefault("sdk_moniker", "mgmt-resource/{}".format(VERSION)) self._configure(**kwargs) - 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) - self.logging_policy = kwargs.get('logging_policy') or policies.NetworkTraceLoggingPolicy(**kwargs) - self.http_logging_policy = kwargs.get('http_logging_policy') or ARMHttpLoggingPolicy(**kwargs) - self.retry_policy = kwargs.get('retry_policy') or policies.AsyncRetryPolicy(**kwargs) - self.custom_hook_policy = kwargs.get('custom_hook_policy') or policies.CustomHookPolicy(**kwargs) - self.redirect_policy = kwargs.get('redirect_policy') or policies.AsyncRedirectPolicy(**kwargs) - self.authentication_policy = kwargs.get('authentication_policy') + 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) + self.logging_policy = kwargs.get("logging_policy") or policies.NetworkTraceLoggingPolicy(**kwargs) + self.http_logging_policy = kwargs.get("http_logging_policy") or ARMHttpLoggingPolicy(**kwargs) + self.retry_policy = kwargs.get("retry_policy") or policies.AsyncRetryPolicy(**kwargs) + self.custom_hook_policy = kwargs.get("custom_hook_policy") or policies.CustomHookPolicy(**kwargs) + self.redirect_policy = kwargs.get("redirect_policy") or policies.AsyncRedirectPolicy(**kwargs) + self.authentication_policy = kwargs.get("authentication_policy") if self.credential and not self.authentication_policy: - self.authentication_policy = AsyncARMChallengeAuthenticationPolicy(self.credential, *self.credential_scopes, **kwargs) + self.authentication_policy = AsyncARMChallengeAuthenticationPolicy( + self.credential, *self.credential_scopes, **kwargs + ) diff --git a/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/resources/v2021_04_01/aio/_patch.py b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/resources/v2021_04_01/aio/_patch.py index 74e48ecd07cf3..f99e77fef9861 100644 --- a/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/resources/v2021_04_01/aio/_patch.py +++ b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/resources/v2021_04_01/aio/_patch.py @@ -28,4 +28,4 @@ # This file is used for handwritten extensions to the generated code. Example: # https://github.com/Azure/azure-sdk-for-python/blob/main/doc/dev/customize_code/how-to-patch-sdk-code.md def patch_sdk(): - pass \ No newline at end of file + pass diff --git a/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/resources/v2021_04_01/aio/_resource_management_client.py b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/resources/v2021_04_01/aio/_resource_management_client.py index 151b707af56da..1d963a7efa90b 100644 --- a/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/resources/v2021_04_01/aio/_resource_management_client.py +++ b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/resources/v2021_04_01/aio/_resource_management_client.py @@ -9,20 +9,29 @@ from copy import deepcopy from typing import Any, Awaitable, TYPE_CHECKING -from msrest import Deserializer, Serializer - from azure.core.rest import AsyncHttpResponse, HttpRequest from azure.mgmt.core import AsyncARMPipelineClient from .. import models +from ..._serialization import Deserializer, Serializer from ._configuration import ResourceManagementClientConfiguration -from .operations import DeploymentOperationsOperations, DeploymentsOperations, Operations, ProviderResourceTypesOperations, ProvidersOperations, ResourceGroupsOperations, ResourcesOperations, TagsOperations +from .operations import ( + DeploymentOperationsOperations, + DeploymentsOperations, + Operations, + ProviderResourceTypesOperations, + ProvidersOperations, + ResourceGroupsOperations, + ResourcesOperations, + TagsOperations, +) if TYPE_CHECKING: # pylint: disable=unused-import,ungrouped-imports from azure.core.credentials_async import AsyncTokenCredential -class ResourceManagementClient: # pylint: disable=too-many-instance-attributes + +class ResourceManagementClient: # pylint: disable=client-accepts-api-version-keyword,too-many-instance-attributes """Provides operations for working with resources and resource groups. :ivar operations: Operations operations @@ -47,9 +56,9 @@ class ResourceManagementClient: # pylint: disable=too-many-instance-attribute :ivar deployment_operations: DeploymentOperationsOperations operations :vartype deployment_operations: azure.mgmt.resource.resources.v2021_04_01.aio.operations.DeploymentOperationsOperations - :param credential: Credential needed for the client to connect to Azure. + :param credential: Credential needed for the client to connect to Azure. Required. :type credential: ~azure.core.credentials_async.AsyncTokenCredential - :param subscription_id: The Microsoft Azure subscription ID. + :param subscription_id: The Microsoft Azure subscription ID. Required. :type subscription_id: str :param base_url: Service URL. Default value is "https://management.azure.com". :type base_url: str @@ -67,7 +76,9 @@ def __init__( base_url: str = "https://management.azure.com", **kwargs: Any ) -> None: - self._config = ResourceManagementClientConfiguration(credential=credential, subscription_id=subscription_id, **kwargs) + self._config = ResourceManagementClientConfiguration( + credential=credential, subscription_id=subscription_id, **kwargs + ) self._client = AsyncARMPipelineClient(base_url=base_url, config=self._config, **kwargs) client_models = {k: v for k, v in models.__dict__.items() if isinstance(v, type)} @@ -77,18 +88,17 @@ def __init__( self.operations = Operations(self._client, self._config, self._serialize, self._deserialize) self.deployments = DeploymentsOperations(self._client, self._config, self._serialize, self._deserialize) self.providers = ProvidersOperations(self._client, self._config, self._serialize, self._deserialize) - self.provider_resource_types = ProviderResourceTypesOperations(self._client, self._config, self._serialize, self._deserialize) + self.provider_resource_types = ProviderResourceTypesOperations( + self._client, self._config, self._serialize, self._deserialize + ) self.resources = ResourcesOperations(self._client, self._config, self._serialize, self._deserialize) self.resource_groups = ResourceGroupsOperations(self._client, self._config, self._serialize, self._deserialize) self.tags = TagsOperations(self._client, self._config, self._serialize, self._deserialize) - self.deployment_operations = DeploymentOperationsOperations(self._client, self._config, self._serialize, self._deserialize) - + self.deployment_operations = DeploymentOperationsOperations( + self._client, self._config, self._serialize, self._deserialize + ) - def _send_request( - self, - request: HttpRequest, - **kwargs: Any - ) -> Awaitable[AsyncHttpResponse]: + def _send_request(self, request: HttpRequest, **kwargs: Any) -> Awaitable[AsyncHttpResponse]: """Runs the network request through the client's chained policies. >>> from azure.core.rest import HttpRequest @@ -97,7 +107,7 @@ def _send_request( >>> response = await client._send_request(request) - For more information on this code flow, see https://aka.ms/azsdk/python/protocol/quickstart + For more information on this code flow, see https://aka.ms/azsdk/dpcodegen/python/send_request :param request: The network request you want to make. Required. :type request: ~azure.core.rest.HttpRequest diff --git a/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/resources/v2021_04_01/aio/operations/__init__.py b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/resources/v2021_04_01/aio/operations/__init__.py index f1487609817b6..9e5620e4d286c 100644 --- a/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/resources/v2021_04_01/aio/operations/__init__.py +++ b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/resources/v2021_04_01/aio/operations/__init__.py @@ -15,13 +15,19 @@ from ._operations import TagsOperations from ._operations import DeploymentOperationsOperations +from ._patch import __all__ as _patch_all +from ._patch import * # type: ignore # pylint: disable=unused-wildcard-import +from ._patch import patch_sdk as _patch_sdk + __all__ = [ - 'Operations', - 'DeploymentsOperations', - 'ProvidersOperations', - 'ProviderResourceTypesOperations', - 'ResourcesOperations', - 'ResourceGroupsOperations', - 'TagsOperations', - 'DeploymentOperationsOperations', + "Operations", + "DeploymentsOperations", + "ProvidersOperations", + "ProviderResourceTypesOperations", + "ResourcesOperations", + "ResourceGroupsOperations", + "TagsOperations", + "DeploymentOperationsOperations", ] +__all__.extend([p for p in _patch_all if p not in __all__]) +_patch_sdk() diff --git a/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/resources/v2021_04_01/aio/operations/_operations.py b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/resources/v2021_04_01/aio/operations/_operations.py index c9928c174f853..722acaff178b8 100644 --- a/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/resources/v2021_04_01/aio/operations/_operations.py +++ b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/resources/v2021_04_01/aio/operations/_operations.py @@ -6,84 +6,201 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -from typing import Any, AsyncIterable, Callable, Dict, Optional, TypeVar, Union +import sys +from typing import Any, AsyncIterable, Callable, Dict, IO, Optional, TypeVar, Union, cast, overload +from urllib.parse import parse_qs, urljoin, urlparse from azure.core.async_paging import AsyncItemPaged, AsyncList -from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error +from azure.core.exceptions import ( + ClientAuthenticationError, + HttpResponseError, + ResourceExistsError, + ResourceNotFoundError, + ResourceNotModifiedError, + map_error, +) from azure.core.pipeline import PipelineResponse from azure.core.pipeline.transport import AsyncHttpResponse from azure.core.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 from azure.mgmt.core.polling.async_arm_polling import AsyncARMPolling from ... import models as _models from ..._vendor import _convert_request -from ...operations._operations import build_deployment_operations_get_at_management_group_scope_request, build_deployment_operations_get_at_scope_request, build_deployment_operations_get_at_subscription_scope_request, build_deployment_operations_get_at_tenant_scope_request, build_deployment_operations_get_request, build_deployment_operations_list_at_management_group_scope_request, build_deployment_operations_list_at_scope_request, build_deployment_operations_list_at_subscription_scope_request, build_deployment_operations_list_at_tenant_scope_request, build_deployment_operations_list_request, build_deployments_calculate_template_hash_request, build_deployments_cancel_at_management_group_scope_request, build_deployments_cancel_at_scope_request, build_deployments_cancel_at_subscription_scope_request, build_deployments_cancel_at_tenant_scope_request, build_deployments_cancel_request, build_deployments_check_existence_at_management_group_scope_request, build_deployments_check_existence_at_scope_request, build_deployments_check_existence_at_subscription_scope_request, build_deployments_check_existence_at_tenant_scope_request, build_deployments_check_existence_request, build_deployments_create_or_update_at_management_group_scope_request_initial, build_deployments_create_or_update_at_scope_request_initial, build_deployments_create_or_update_at_subscription_scope_request_initial, build_deployments_create_or_update_at_tenant_scope_request_initial, build_deployments_create_or_update_request_initial, build_deployments_delete_at_management_group_scope_request_initial, build_deployments_delete_at_scope_request_initial, build_deployments_delete_at_subscription_scope_request_initial, build_deployments_delete_at_tenant_scope_request_initial, build_deployments_delete_request_initial, build_deployments_export_template_at_management_group_scope_request, build_deployments_export_template_at_scope_request, build_deployments_export_template_at_subscription_scope_request, build_deployments_export_template_at_tenant_scope_request, build_deployments_export_template_request, build_deployments_get_at_management_group_scope_request, build_deployments_get_at_scope_request, build_deployments_get_at_subscription_scope_request, build_deployments_get_at_tenant_scope_request, build_deployments_get_request, build_deployments_list_at_management_group_scope_request, build_deployments_list_at_scope_request, build_deployments_list_at_subscription_scope_request, build_deployments_list_at_tenant_scope_request, build_deployments_list_by_resource_group_request, build_deployments_validate_at_management_group_scope_request_initial, build_deployments_validate_at_scope_request_initial, build_deployments_validate_at_subscription_scope_request_initial, build_deployments_validate_at_tenant_scope_request_initial, build_deployments_validate_request_initial, build_deployments_what_if_at_management_group_scope_request_initial, build_deployments_what_if_at_subscription_scope_request_initial, build_deployments_what_if_at_tenant_scope_request_initial, build_deployments_what_if_request_initial, build_operations_list_request, build_provider_resource_types_list_request, build_providers_get_at_tenant_scope_request, build_providers_get_request, build_providers_list_at_tenant_scope_request, build_providers_list_request, build_providers_provider_permissions_request, build_providers_register_at_management_group_scope_request, build_providers_register_request, build_providers_unregister_request, build_resource_groups_check_existence_request, build_resource_groups_create_or_update_request, build_resource_groups_delete_request_initial, build_resource_groups_export_template_request_initial, build_resource_groups_get_request, build_resource_groups_list_request, build_resource_groups_update_request, build_resources_check_existence_by_id_request, build_resources_check_existence_request, build_resources_create_or_update_by_id_request_initial, build_resources_create_or_update_request_initial, build_resources_delete_by_id_request_initial, build_resources_delete_request_initial, build_resources_get_by_id_request, build_resources_get_request, build_resources_list_by_resource_group_request, build_resources_list_request, build_resources_move_resources_request_initial, build_resources_update_by_id_request_initial, build_resources_update_request_initial, build_resources_validate_move_resources_request_initial, build_tags_create_or_update_at_scope_request, build_tags_create_or_update_request, build_tags_create_or_update_value_request, build_tags_delete_at_scope_request, build_tags_delete_request, build_tags_delete_value_request, build_tags_get_at_scope_request, build_tags_list_request, build_tags_update_at_scope_request -T = TypeVar('T') +from ...operations._operations import ( + build_deployment_operations_get_at_management_group_scope_request, + build_deployment_operations_get_at_scope_request, + build_deployment_operations_get_at_subscription_scope_request, + build_deployment_operations_get_at_tenant_scope_request, + build_deployment_operations_get_request, + build_deployment_operations_list_at_management_group_scope_request, + build_deployment_operations_list_at_scope_request, + build_deployment_operations_list_at_subscription_scope_request, + build_deployment_operations_list_at_tenant_scope_request, + build_deployment_operations_list_request, + build_deployments_calculate_template_hash_request, + build_deployments_cancel_at_management_group_scope_request, + build_deployments_cancel_at_scope_request, + build_deployments_cancel_at_subscription_scope_request, + build_deployments_cancel_at_tenant_scope_request, + build_deployments_cancel_request, + build_deployments_check_existence_at_management_group_scope_request, + build_deployments_check_existence_at_scope_request, + build_deployments_check_existence_at_subscription_scope_request, + build_deployments_check_existence_at_tenant_scope_request, + build_deployments_check_existence_request, + build_deployments_create_or_update_at_management_group_scope_request, + build_deployments_create_or_update_at_scope_request, + build_deployments_create_or_update_at_subscription_scope_request, + build_deployments_create_or_update_at_tenant_scope_request, + build_deployments_create_or_update_request, + build_deployments_delete_at_management_group_scope_request, + build_deployments_delete_at_scope_request, + build_deployments_delete_at_subscription_scope_request, + build_deployments_delete_at_tenant_scope_request, + build_deployments_delete_request, + build_deployments_export_template_at_management_group_scope_request, + build_deployments_export_template_at_scope_request, + build_deployments_export_template_at_subscription_scope_request, + build_deployments_export_template_at_tenant_scope_request, + build_deployments_export_template_request, + build_deployments_get_at_management_group_scope_request, + build_deployments_get_at_scope_request, + build_deployments_get_at_subscription_scope_request, + build_deployments_get_at_tenant_scope_request, + build_deployments_get_request, + build_deployments_list_at_management_group_scope_request, + build_deployments_list_at_scope_request, + build_deployments_list_at_subscription_scope_request, + build_deployments_list_at_tenant_scope_request, + build_deployments_list_by_resource_group_request, + build_deployments_validate_at_management_group_scope_request, + build_deployments_validate_at_scope_request, + build_deployments_validate_at_subscription_scope_request, + build_deployments_validate_at_tenant_scope_request, + build_deployments_validate_request, + build_deployments_what_if_at_management_group_scope_request, + build_deployments_what_if_at_subscription_scope_request, + build_deployments_what_if_at_tenant_scope_request, + build_deployments_what_if_request, + build_operations_list_request, + build_provider_resource_types_list_request, + build_providers_get_at_tenant_scope_request, + build_providers_get_request, + build_providers_list_at_tenant_scope_request, + build_providers_list_request, + build_providers_provider_permissions_request, + build_providers_register_at_management_group_scope_request, + build_providers_register_request, + build_providers_unregister_request, + build_resource_groups_check_existence_request, + build_resource_groups_create_or_update_request, + build_resource_groups_delete_request, + build_resource_groups_export_template_request, + build_resource_groups_get_request, + build_resource_groups_list_request, + build_resource_groups_update_request, + build_resources_check_existence_by_id_request, + build_resources_check_existence_request, + build_resources_create_or_update_by_id_request, + build_resources_create_or_update_request, + build_resources_delete_by_id_request, + build_resources_delete_request, + build_resources_get_by_id_request, + build_resources_get_request, + build_resources_list_by_resource_group_request, + build_resources_list_request, + build_resources_move_resources_request, + build_resources_update_by_id_request, + build_resources_update_request, + build_resources_validate_move_resources_request, + build_tags_create_or_update_at_scope_request, + build_tags_create_or_update_request, + build_tags_create_or_update_value_request, + build_tags_delete_at_scope_request, + build_tags_delete_request, + build_tags_delete_value_request, + build_tags_get_at_scope_request, + build_tags_list_request, + build_tags_update_at_scope_request, +) + +T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] +if sys.version_info >= (3, 9): + from collections.abc import MutableMapping +else: + from typing import MutableMapping # type: ignore # pylint: disable=ungrouped-imports +JSON = MutableMapping[str, Any] # pylint: disable=unsubscriptable-object -class Operations: - """Operations async operations. - You should not instantiate this class directly. Instead, you should create a Client instance that - instantiates it for you and attaches it as an attribute. +class Operations: + """ + .. warning:: + **DO NOT** instantiate this class directly. - :ivar models: Alias to model classes used in this operation group. - :type models: ~azure.mgmt.resource.resources.v2021_04_01.models - :param client: Client for service requests. - :param config: Configuration of service client. - :param serializer: An object model serializer. - :param deserializer: An object model deserializer. + Instead, you should access the following operations through + :class:`~azure.mgmt.resource.resources.v2021_04_01.aio.ResourceManagementClient`'s + :attr:`operations` attribute. """ models = _models - def __init__(self, client, config, serializer, deserializer) -> None: - self._client = client - self._serialize = serializer - self._deserialize = deserializer - self._config = config + def __init__(self, *args, **kwargs) -> None: + input_args = list(args) + self._client = input_args.pop(0) if input_args else kwargs.pop("client") + self._config = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") @distributed_trace - def list( - self, - **kwargs: Any - ) -> AsyncIterable["_models.OperationListResult"]: + def list(self, **kwargs: Any) -> AsyncIterable["_models.Operation"]: """Lists all of the available Microsoft.Resources REST API operations. :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either OperationListResult or the result of cls(response) + :return: An iterator like instance of either Operation or the result of cls(response) :rtype: - ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.resource.resources.v2021_04_01.models.OperationListResult] - :raises: ~azure.core.exceptions.HttpResponseError + ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.resource.resources.v2021_04_01.models.Operation] + :raises ~azure.core.exceptions.HttpResponseError: """ - api_version = kwargs.pop('api_version', "2021-04-01") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-04-01")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[_models.OperationListResult] - cls = kwargs.pop('cls', None) # type: ClsType["_models.OperationListResult"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) + def prepare_request(next_link=None): if not next_link: - + request = build_operations_list_request( api_version=api_version, - template_url=self.list.metadata['url'], + template_url=self.list.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore else: - - request = build_operations_list_request( - template_url=next_link, - ) + # make call to next link with the client's api-version + _parsed_next_link = urlparse(next_link) + _next_request_params = case_insensitive_dict(parse_qs(_parsed_next_link.query)) + _next_request_params["api-version"] = self._config.api_version + request = HttpRequest("GET", urljoin(next_link, _parsed_next_link.path), params=_next_request_params) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore request.method = "GET" return request @@ -97,10 +214,8 @@ async def extract_data(pipeline_response): async def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) response = pipeline_response.http_response @@ -110,62 +225,62 @@ async def get_next(next_link=None): return pipeline_response + return AsyncItemPaged(get_next, extract_data) - return AsyncItemPaged( - get_next, extract_data - ) - list.metadata = {'url': "/providers/Microsoft.Resources/operations"} # type: ignore -class DeploymentsOperations: # pylint: disable=too-many-public-methods - """DeploymentsOperations async operations. + list.metadata = {"url": "/providers/Microsoft.Resources/operations"} # type: ignore - You should not instantiate this class directly. Instead, you should create a Client instance that - instantiates it for you and attaches it as an attribute. - :ivar models: Alias to model classes used in this operation group. - :type models: ~azure.mgmt.resource.resources.v2021_04_01.models - :param client: Client for service requests. - :param config: Configuration of service client. - :param serializer: An object model serializer. - :param deserializer: An object model deserializer. +class DeploymentsOperations: # pylint: disable=too-many-public-methods + """ + .. warning:: + **DO NOT** instantiate this class directly. + + Instead, you should access the following operations through + :class:`~azure.mgmt.resource.resources.v2021_04_01.aio.ResourceManagementClient`'s + :attr:`deployments` attribute. """ models = _models - def __init__(self, client, config, serializer, deserializer) -> None: - self._client = client - self._serialize = serializer - self._deserialize = deserializer - self._config = config + def __init__(self, *args, **kwargs) -> None: + input_args = list(args) + self._client = input_args.pop(0) if input_args else kwargs.pop("client") + self._config = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") async def _delete_at_scope_initial( # pylint: disable=inconsistent-return-statements - self, - scope: str, - deployment_name: str, - **kwargs: Any + self, scope: str, deployment_name: str, **kwargs: Any ) -> None: - cls = kwargs.pop('cls', None) # type: ClsType[None] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + 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', "2021-04-01") # type: str + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-04-01")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[None] - - request = build_deployments_delete_at_scope_request_initial( + request = build_deployments_delete_at_scope_request( scope=scope, deployment_name=deployment_name, api_version=api_version, - template_url=self._delete_at_scope_initial.metadata['url'], + template_url=self._delete_at_scope_initial.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [202, 204]: @@ -175,16 +290,10 @@ async def _delete_at_scope_initial( # pylint: disable=inconsistent-return-state if cls: return cls(pipeline_response, None, {}) - _delete_at_scope_initial.metadata = {'url': "/{scope}/providers/Microsoft.Resources/deployments/{deploymentName}"} # type: ignore - + _delete_at_scope_initial.metadata = {"url": "/{scope}/providers/Microsoft.Resources/deployments/{deploymentName}"} # type: ignore @distributed_trace_async - async def begin_delete_at_scope( # pylint: disable=inconsistent-return-statements - self, - scope: str, - deployment_name: str, - **kwargs: Any - ) -> AsyncLROPoller[None]: + async def begin_delete_at_scope(self, scope: str, deployment_name: str, **kwargs: Any) -> AsyncLROPoller[None]: """Deletes a deployment from the deployment history. A template deployment that is currently running cannot be deleted. Deleting a template @@ -195,9 +304,9 @@ async def begin_delete_at_scope( # pylint: disable=inconsistent-return-statemen process finishes, the URI in the Location header returns a status of 204 on success. If the asynchronous request failed, the URI in the Location header returns an error-level status code. - :param scope: The resource scope. + :param scope: The resource scope. Required. :type scope: str - :param deployment_name: The name of the deployment. + :param deployment_name: The name of the deployment. Required. :type deployment_name: str :keyword callable cls: A custom type or function that will be passed the direct response :keyword str continuation_token: A continuation token to restart a poller from a saved state. @@ -209,86 +318,91 @@ async def begin_delete_at_scope( # pylint: disable=inconsistent-return-statemen Retry-After header is present. :return: An instance of AsyncLROPoller that returns either None or the result of cls(response) :rtype: ~azure.core.polling.AsyncLROPoller[None] - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - api_version = kwargs.pop('api_version', "2021-04-01") # type: str - polling = kwargs.pop('polling', True) # type: Union[bool, AsyncPollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType[None] - lro_delay = kwargs.pop( - 'polling_interval', - self._config.polling_interval - ) - cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-04-01")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[None] + polling = kwargs.pop("polling", True) # type: Union[bool, AsyncPollingMethod] + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token = kwargs.pop("continuation_token", None) # type: Optional[str] if cont_token is None: - raw_result = await self._delete_at_scope_initial( + raw_result = await self._delete_at_scope_initial( # type: ignore scope=scope, deployment_name=deployment_name, api_version=api_version, - cls=lambda x,y,z: x, + cls=lambda x, y, z: x, + headers=_headers, + params=_params, **kwargs ) - kwargs.pop('error_map', None) + kwargs.pop("error_map", None) - def get_long_running_output(pipeline_response): + def get_long_running_output(pipeline_response): # pylint: disable=inconsistent-return-statements if cls: return cls(pipeline_response, None, {}) - - if polling is True: polling_method = AsyncARMPolling(lro_delay, **kwargs) - elif polling is False: polling_method = AsyncNoPolling() - else: polling_method = polling + if polling is True: + polling_method = cast(AsyncPollingMethod, AsyncARMPolling(lro_delay, **kwargs)) # type: AsyncPollingMethod + elif polling is False: + polling_method = cast(AsyncPollingMethod, AsyncNoPolling()) + else: + polling_method = polling if cont_token: return AsyncLROPoller.from_continuation_token( polling_method=polling_method, continuation_token=cont_token, client=self._client, - deserialization_callback=get_long_running_output + deserialization_callback=get_long_running_output, ) return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) - begin_delete_at_scope.metadata = {'url': "/{scope}/providers/Microsoft.Resources/deployments/{deploymentName}"} # type: ignore + begin_delete_at_scope.metadata = {"url": "/{scope}/providers/Microsoft.Resources/deployments/{deploymentName}"} # type: ignore @distributed_trace_async - async def check_existence_at_scope( - self, - scope: str, - deployment_name: str, - **kwargs: Any - ) -> bool: + async def check_existence_at_scope(self, scope: str, deployment_name: str, **kwargs: Any) -> bool: """Checks whether the deployment exists. - :param scope: The resource scope. + :param scope: The resource scope. Required. :type scope: str - :param deployment_name: The name of the deployment. + :param deployment_name: The name of the deployment. Required. :type deployment_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: bool, or the result of cls(response) + :return: bool or the result of cls(response) :rtype: bool - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType[None] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) - api_version = kwargs.pop('api_version', "2021-04-01") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-04-01")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[None] - request = build_deployments_check_existence_at_scope_request( scope=scope, deployment_name=deployment_name, api_version=api_version, - template_url=self.check_existence_at_scope.metadata['url'], + template_url=self.check_existence_at_scope.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [204, 404]: @@ -299,43 +413,52 @@ async def check_existence_at_scope( return cls(pipeline_response, None, {}) return 200 <= response.status_code <= 299 - check_existence_at_scope.metadata = {'url': "/{scope}/providers/Microsoft.Resources/deployments/{deploymentName}"} # type: ignore - + check_existence_at_scope.metadata = {"url": "/{scope}/providers/Microsoft.Resources/deployments/{deploymentName}"} # type: ignore async def _create_or_update_at_scope_initial( - self, - scope: str, - deployment_name: str, - parameters: "_models.Deployment", - **kwargs: Any - ) -> "_models.DeploymentExtended": - cls = kwargs.pop('cls', None) # type: ClsType["_models.DeploymentExtended"] + self, scope: str, deployment_name: str, parameters: Union[_models.Deployment, IO], **kwargs: Any + ) -> _models.DeploymentExtended: error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', "2021-04-01") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-04-01")) # type: str + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.DeploymentExtended] - _json = self._serialize.body(parameters, 'Deployment') + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(parameters, (IO, bytes)): + _content = parameters + else: + _json = self._serialize.body(parameters, "Deployment") - request = build_deployments_create_or_update_at_scope_request_initial( + request = build_deployments_create_or_update_at_scope_request( scope=scope, deployment_name=deployment_name, api_version=api_version, content_type=content_type, json=_json, - template_url=self._create_or_update_at_scope_initial.metadata['url'], + content=_content, + template_url=self._create_or_update_at_scope_initial.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200, 201]: @@ -343,37 +466,41 @@ async def _create_or_update_at_scope_initial( raise HttpResponseError(response=response, error_format=ARMErrorFormat) if response.status_code == 200: - deserialized = self._deserialize('DeploymentExtended', pipeline_response) + deserialized = self._deserialize("DeploymentExtended", pipeline_response) if response.status_code == 201: - deserialized = self._deserialize('DeploymentExtended', pipeline_response) + deserialized = self._deserialize("DeploymentExtended", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - _create_or_update_at_scope_initial.metadata = {'url': "/{scope}/providers/Microsoft.Resources/deployments/{deploymentName}"} # type: ignore + _create_or_update_at_scope_initial.metadata = {"url": "/{scope}/providers/Microsoft.Resources/deployments/{deploymentName}"} # type: ignore - - @distributed_trace_async + @overload async def begin_create_or_update_at_scope( self, scope: str, deployment_name: str, - parameters: "_models.Deployment", + parameters: _models.Deployment, + *, + content_type: str = "application/json", **kwargs: Any - ) -> AsyncLROPoller["_models.DeploymentExtended"]: + ) -> AsyncLROPoller[_models.DeploymentExtended]: """Deploys resources at a given scope. You can provide the template and parameters directly in the request or link to JSON files. - :param scope: The resource scope. + :param scope: The resource scope. Required. :type scope: str - :param deployment_name: The name of the deployment. + :param deployment_name: The name of the deployment. Required. :type deployment_name: str - :param parameters: Additional parameters supplied to the operation. + :param parameters: Additional parameters supplied to the operation. Required. :type parameters: ~azure.mgmt.resource.resources.v2021_04_01.models.Deployment + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str :keyword callable cls: A custom type or function that will be passed the direct response :keyword str continuation_token: A continuation token to restart a poller from a saved state. :keyword polling: By default, your polling method will be AsyncARMPolling. Pass in False for @@ -386,114 +513,179 @@ async def begin_create_or_update_at_scope( cls(response) :rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.resource.resources.v2021_04_01.models.DeploymentExtended] - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - api_version = kwargs.pop('api_version', "2021-04-01") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] - polling = kwargs.pop('polling', True) # type: Union[bool, AsyncPollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType["_models.DeploymentExtended"] - lro_delay = kwargs.pop( - 'polling_interval', - self._config.polling_interval - ) - cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] + + @overload + async def begin_create_or_update_at_scope( + self, scope: str, deployment_name: str, parameters: IO, *, content_type: str = "application/json", **kwargs: Any + ) -> AsyncLROPoller[_models.DeploymentExtended]: + """Deploys resources at a given scope. + + You can provide the template and parameters directly in the request or link to JSON files. + + :param scope: The resource scope. Required. + :type scope: str + :param deployment_name: The name of the deployment. Required. + :type deployment_name: str + :param parameters: Additional parameters supplied to the operation. Required. + :type parameters: IO + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be AsyncARMPolling. Pass in False for + this operation to not poll, or pass in your own initialized polling object for a personal + polling strategy. + :paramtype polling: bool or ~azure.core.polling.AsyncPollingMethod + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of AsyncLROPoller that returns either DeploymentExtended or the result of + cls(response) + :rtype: + ~azure.core.polling.AsyncLROPoller[~azure.mgmt.resource.resources.v2021_04_01.models.DeploymentExtended] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace_async + async def begin_create_or_update_at_scope( + self, scope: str, deployment_name: str, parameters: Union[_models.Deployment, IO], **kwargs: Any + ) -> AsyncLROPoller[_models.DeploymentExtended]: + """Deploys resources at a given scope. + + You can provide the template and parameters directly in the request or link to JSON files. + + :param scope: The resource scope. Required. + :type scope: str + :param deployment_name: The name of the deployment. Required. + :type deployment_name: str + :param parameters: Additional parameters supplied to the operation. Is either a model type or a + IO type. Required. + :type parameters: ~azure.mgmt.resource.resources.v2021_04_01.models.Deployment or IO + :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. + Default value is None. + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be AsyncARMPolling. Pass in False for + this operation to not poll, or pass in your own initialized polling object for a personal + polling strategy. + :paramtype polling: bool or ~azure.core.polling.AsyncPollingMethod + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of AsyncLROPoller that returns either DeploymentExtended or the result of + cls(response) + :rtype: + ~azure.core.polling.AsyncLROPoller[~azure.mgmt.resource.resources.v2021_04_01.models.DeploymentExtended] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _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-04-01")) # type: str + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.DeploymentExtended] + polling = kwargs.pop("polling", True) # type: Union[bool, AsyncPollingMethod] + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token = kwargs.pop("continuation_token", None) # type: Optional[str] if cont_token is None: - raw_result = await self._create_or_update_at_scope_initial( + raw_result = await self._create_or_update_at_scope_initial( # type: ignore scope=scope, deployment_name=deployment_name, parameters=parameters, api_version=api_version, content_type=content_type, - cls=lambda x,y,z: x, + cls=lambda x, y, z: x, + headers=_headers, + params=_params, **kwargs ) - kwargs.pop('error_map', None) + kwargs.pop("error_map", None) def get_long_running_output(pipeline_response): - response = pipeline_response.http_response - deserialized = self._deserialize('DeploymentExtended', pipeline_response) + deserialized = self._deserialize("DeploymentExtended", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - - if polling is True: polling_method = AsyncARMPolling(lro_delay, **kwargs) - elif polling is False: polling_method = AsyncNoPolling() - else: polling_method = polling + if polling is True: + polling_method = cast(AsyncPollingMethod, AsyncARMPolling(lro_delay, **kwargs)) # type: AsyncPollingMethod + elif polling is False: + polling_method = cast(AsyncPollingMethod, AsyncNoPolling()) + else: + polling_method = polling if cont_token: return AsyncLROPoller.from_continuation_token( polling_method=polling_method, continuation_token=cont_token, client=self._client, - deserialization_callback=get_long_running_output + deserialization_callback=get_long_running_output, ) return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) - begin_create_or_update_at_scope.metadata = {'url': "/{scope}/providers/Microsoft.Resources/deployments/{deploymentName}"} # type: ignore + begin_create_or_update_at_scope.metadata = {"url": "/{scope}/providers/Microsoft.Resources/deployments/{deploymentName}"} # type: ignore @distributed_trace_async - async def get_at_scope( - self, - scope: str, - deployment_name: str, - **kwargs: Any - ) -> "_models.DeploymentExtended": + async def get_at_scope(self, scope: str, deployment_name: str, **kwargs: Any) -> _models.DeploymentExtended: """Gets a deployment. - :param scope: The resource scope. + :param scope: The resource scope. Required. :type scope: str - :param deployment_name: The name of the deployment. + :param deployment_name: The name of the deployment. Required. :type deployment_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: DeploymentExtended, or the result of cls(response) + :return: DeploymentExtended or the result of cls(response) :rtype: ~azure.mgmt.resource.resources.v2021_04_01.models.DeploymentExtended - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.DeploymentExtended"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + 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', "2021-04-01") # type: str + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-04-01")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[_models.DeploymentExtended] - request = build_deployments_get_at_scope_request( scope=scope, deployment_name=deployment_name, api_version=api_version, - template_url=self.get_at_scope.metadata['url'], + template_url=self.get_at_scope.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) - deserialized = self._deserialize('DeploymentExtended', pipeline_response) + deserialized = self._deserialize("DeploymentExtended", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - get_at_scope.metadata = {'url': "/{scope}/providers/Microsoft.Resources/deployments/{deploymentName}"} # type: ignore - + get_at_scope.metadata = {"url": "/{scope}/providers/Microsoft.Resources/deployments/{deploymentName}"} # type: ignore @distributed_trace_async async def cancel_at_scope( # pylint: disable=inconsistent-return-statements - self, - scope: str, - deployment_name: str, - **kwargs: Any + self, scope: str, deployment_name: str, **kwargs: Any ) -> None: """Cancels a currently running template deployment. @@ -502,38 +694,44 @@ async def cancel_at_scope( # pylint: disable=inconsistent-return-statements deployment stops the currently running template deployment and leaves the resources partially deployed. - :param scope: The resource scope. + :param scope: The resource scope. Required. :type scope: str - :param deployment_name: The name of the deployment. + :param deployment_name: The name of the deployment. Required. :type deployment_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: None, or the result of cls(response) + :return: None or the result of cls(response) :rtype: None - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType[None] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) - api_version = kwargs.pop('api_version', "2021-04-01") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-04-01")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[None] - request = build_deployments_cancel_at_scope_request( scope=scope, deployment_name=deployment_name, api_version=api_version, - template_url=self.cancel_at_scope.metadata['url'], + template_url=self.cancel_at_scope.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [204]: @@ -543,43 +741,52 @@ async def cancel_at_scope( # pylint: disable=inconsistent-return-statements if cls: return cls(pipeline_response, None, {}) - cancel_at_scope.metadata = {'url': "/{scope}/providers/Microsoft.Resources/deployments/{deploymentName}/cancel"} # type: ignore - + cancel_at_scope.metadata = {"url": "/{scope}/providers/Microsoft.Resources/deployments/{deploymentName}/cancel"} # type: ignore async def _validate_at_scope_initial( - self, - scope: str, - deployment_name: str, - parameters: "_models.Deployment", - **kwargs: Any - ) -> Optional["_models.DeploymentValidateResult"]: - cls = kwargs.pop('cls', None) # type: ClsType[Optional["_models.DeploymentValidateResult"]] + self, scope: str, deployment_name: str, parameters: Union[_models.Deployment, IO], **kwargs: Any + ) -> Optional[_models.DeploymentValidateResult]: error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', "2021-04-01") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-04-01")) # type: str + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[Optional[_models.DeploymentValidateResult]] - _json = self._serialize.body(parameters, 'Deployment') + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(parameters, (IO, bytes)): + _content = parameters + else: + _json = self._serialize.body(parameters, "Deployment") - request = build_deployments_validate_at_scope_request_initial( + request = build_deployments_validate_at_scope_request( scope=scope, deployment_name=deployment_name, api_version=api_version, content_type=content_type, json=_json, - template_url=self._validate_at_scope_initial.metadata['url'], + content=_content, + template_url=self._validate_at_scope_initial.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200, 202, 400]: @@ -588,36 +795,40 @@ async def _validate_at_scope_initial( deserialized = None if response.status_code == 200: - deserialized = self._deserialize('DeploymentValidateResult', pipeline_response) + deserialized = self._deserialize("DeploymentValidateResult", pipeline_response) if response.status_code == 400: - deserialized = self._deserialize('DeploymentValidateResult', pipeline_response) + deserialized = self._deserialize("DeploymentValidateResult", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - _validate_at_scope_initial.metadata = {'url': "/{scope}/providers/Microsoft.Resources/deployments/{deploymentName}/validate"} # type: ignore + _validate_at_scope_initial.metadata = {"url": "/{scope}/providers/Microsoft.Resources/deployments/{deploymentName}/validate"} # type: ignore - - @distributed_trace_async + @overload async def begin_validate_at_scope( self, scope: str, deployment_name: str, - parameters: "_models.Deployment", + parameters: _models.Deployment, + *, + content_type: str = "application/json", **kwargs: Any - ) -> AsyncLROPoller["_models.DeploymentValidateResult"]: + ) -> AsyncLROPoller[_models.DeploymentValidateResult]: """Validates whether the specified template is syntactically correct and will be accepted by Azure Resource Manager.. - :param scope: The resource scope. + :param scope: The resource scope. Required. :type scope: str - :param deployment_name: The name of the deployment. + :param deployment_name: The name of the deployment. Required. :type deployment_name: str - :param parameters: Parameters to validate. + :param parameters: Parameters to validate. Required. :type parameters: ~azure.mgmt.resource.resources.v2021_04_01.models.Deployment + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str :keyword callable cls: A custom type or function that will be passed the direct response :keyword str continuation_token: A continuation token to restart a poller from a saved state. :keyword polling: By default, your polling method will be AsyncARMPolling. Pass in False for @@ -630,119 +841,182 @@ async def begin_validate_at_scope( result of cls(response) :rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.resource.resources.v2021_04_01.models.DeploymentValidateResult] - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - api_version = kwargs.pop('api_version', "2021-04-01") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] - polling = kwargs.pop('polling', True) # type: Union[bool, AsyncPollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType["_models.DeploymentValidateResult"] - lro_delay = kwargs.pop( - 'polling_interval', - self._config.polling_interval - ) - cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] + + @overload + async def begin_validate_at_scope( + self, scope: str, deployment_name: str, parameters: IO, *, content_type: str = "application/json", **kwargs: Any + ) -> AsyncLROPoller[_models.DeploymentValidateResult]: + """Validates whether the specified template is syntactically correct and will be accepted by Azure + Resource Manager.. + + :param scope: The resource scope. Required. + :type scope: str + :param deployment_name: The name of the deployment. Required. + :type deployment_name: str + :param parameters: Parameters to validate. Required. + :type parameters: IO + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be AsyncARMPolling. Pass in False for + this operation to not poll, or pass in your own initialized polling object for a personal + polling strategy. + :paramtype polling: bool or ~azure.core.polling.AsyncPollingMethod + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of AsyncLROPoller that returns either DeploymentValidateResult or the + result of cls(response) + :rtype: + ~azure.core.polling.AsyncLROPoller[~azure.mgmt.resource.resources.v2021_04_01.models.DeploymentValidateResult] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace_async + async def begin_validate_at_scope( + self, scope: str, deployment_name: str, parameters: Union[_models.Deployment, IO], **kwargs: Any + ) -> AsyncLROPoller[_models.DeploymentValidateResult]: + """Validates whether the specified template is syntactically correct and will be accepted by Azure + Resource Manager.. + + :param scope: The resource scope. Required. + :type scope: str + :param deployment_name: The name of the deployment. Required. + :type deployment_name: str + :param parameters: Parameters to validate. Is either a model type or a IO type. Required. + :type parameters: ~azure.mgmt.resource.resources.v2021_04_01.models.Deployment or IO + :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. + Default value is None. + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be AsyncARMPolling. Pass in False for + this operation to not poll, or pass in your own initialized polling object for a personal + polling strategy. + :paramtype polling: bool or ~azure.core.polling.AsyncPollingMethod + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of AsyncLROPoller that returns either DeploymentValidateResult or the + result of cls(response) + :rtype: + ~azure.core.polling.AsyncLROPoller[~azure.mgmt.resource.resources.v2021_04_01.models.DeploymentValidateResult] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _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-04-01")) # type: str + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.DeploymentValidateResult] + polling = kwargs.pop("polling", True) # type: Union[bool, AsyncPollingMethod] + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token = kwargs.pop("continuation_token", None) # type: Optional[str] if cont_token is None: - raw_result = await self._validate_at_scope_initial( + raw_result = await self._validate_at_scope_initial( # type: ignore scope=scope, deployment_name=deployment_name, parameters=parameters, api_version=api_version, content_type=content_type, - cls=lambda x,y,z: x, + cls=lambda x, y, z: x, + headers=_headers, + params=_params, **kwargs ) - kwargs.pop('error_map', None) + kwargs.pop("error_map", None) def get_long_running_output(pipeline_response): - response = pipeline_response.http_response - deserialized = self._deserialize('DeploymentValidateResult', pipeline_response) + deserialized = self._deserialize("DeploymentValidateResult", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - - if polling is True: polling_method = AsyncARMPolling(lro_delay, **kwargs) - elif polling is False: polling_method = AsyncNoPolling() - else: polling_method = polling + if polling is True: + polling_method = cast(AsyncPollingMethod, AsyncARMPolling(lro_delay, **kwargs)) # type: AsyncPollingMethod + elif polling is False: + polling_method = cast(AsyncPollingMethod, AsyncNoPolling()) + else: + polling_method = polling if cont_token: return AsyncLROPoller.from_continuation_token( polling_method=polling_method, continuation_token=cont_token, client=self._client, - deserialization_callback=get_long_running_output + deserialization_callback=get_long_running_output, ) return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) - begin_validate_at_scope.metadata = {'url': "/{scope}/providers/Microsoft.Resources/deployments/{deploymentName}/validate"} # type: ignore + begin_validate_at_scope.metadata = {"url": "/{scope}/providers/Microsoft.Resources/deployments/{deploymentName}/validate"} # type: ignore @distributed_trace_async async def export_template_at_scope( - self, - scope: str, - deployment_name: str, - **kwargs: Any - ) -> "_models.DeploymentExportResult": + self, scope: str, deployment_name: str, **kwargs: Any + ) -> _models.DeploymentExportResult: """Exports the template used for specified deployment. - :param scope: The resource scope. + :param scope: The resource scope. Required. :type scope: str - :param deployment_name: The name of the deployment. + :param deployment_name: The name of the deployment. Required. :type deployment_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: DeploymentExportResult, or the result of cls(response) + :return: DeploymentExportResult or the result of cls(response) :rtype: ~azure.mgmt.resource.resources.v2021_04_01.models.DeploymentExportResult - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.DeploymentExportResult"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) - api_version = kwargs.pop('api_version', "2021-04-01") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-04-01")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[_models.DeploymentExportResult] - request = build_deployments_export_template_at_scope_request( scope=scope, deployment_name=deployment_name, api_version=api_version, - template_url=self.export_template_at_scope.metadata['url'], + template_url=self.export_template_at_scope.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) - deserialized = self._deserialize('DeploymentExportResult', pipeline_response) + deserialized = self._deserialize("DeploymentExportResult", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - export_template_at_scope.metadata = {'url': "/{scope}/providers/Microsoft.Resources/deployments/{deploymentName}/exportTemplate"} # type: ignore - + export_template_at_scope.metadata = {"url": "/{scope}/providers/Microsoft.Resources/deployments/{deploymentName}/exportTemplate"} # type: ignore @distributed_trace def list_at_scope( - self, - scope: str, - filter: Optional[str] = None, - top: Optional[int] = None, - **kwargs: Any - ) -> AsyncIterable["_models.DeploymentListResult"]: + self, scope: str, filter: Optional[str] = None, top: Optional[int] = None, **kwargs: Any + ) -> AsyncIterable["_models.DeploymentExtended"]: """Get all the deployments at the given scope. - :param scope: The resource scope. + :param scope: The resource scope. Required. :type scope: str :param filter: The filter to apply on the operation. For example, you can use $filter=provisioningState eq '{state}'. Default value is None. @@ -751,40 +1025,48 @@ def list_at_scope( value is None. :type top: int :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either DeploymentListResult or the result of - cls(response) + :return: An iterator like instance of either DeploymentExtended or the result of cls(response) :rtype: - ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.resource.resources.v2021_04_01.models.DeploymentListResult] - :raises: ~azure.core.exceptions.HttpResponseError + ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.resource.resources.v2021_04_01.models.DeploymentExtended] + :raises ~azure.core.exceptions.HttpResponseError: """ - api_version = kwargs.pop('api_version', "2021-04-01") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-04-01")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[_models.DeploymentListResult] - cls = kwargs.pop('cls', None) # type: ClsType["_models.DeploymentListResult"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) + def prepare_request(next_link=None): if not next_link: - + request = build_deployments_list_at_scope_request( scope=scope, - api_version=api_version, filter=filter, top=top, - template_url=self.list_at_scope.metadata['url'], + api_version=api_version, + template_url=self.list_at_scope.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore else: - - request = build_deployments_list_at_scope_request( - scope=scope, - template_url=next_link, - ) + # make call to next link with the client's api-version + _parsed_next_link = urlparse(next_link) + _next_request_params = case_insensitive_dict(parse_qs(_parsed_next_link.query)) + _next_request_params["api-version"] = self._config.api_version + request = HttpRequest("GET", urljoin(next_link, _parsed_next_link.path), params=_next_request_params) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore request.method = "GET" return request @@ -798,10 +1080,8 @@ async def extract_data(pipeline_response): async def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) response = pipeline_response.http_response @@ -811,39 +1091,41 @@ async def get_next(next_link=None): return pipeline_response + return AsyncItemPaged(get_next, extract_data) - return AsyncItemPaged( - get_next, extract_data - ) - list_at_scope.metadata = {'url': "/{scope}/providers/Microsoft.Resources/deployments/"} # type: ignore + list_at_scope.metadata = {"url": "/{scope}/providers/Microsoft.Resources/deployments/"} # type: ignore async def _delete_at_tenant_scope_initial( # pylint: disable=inconsistent-return-statements - self, - deployment_name: str, - **kwargs: Any + self, deployment_name: str, **kwargs: Any ) -> None: - cls = kwargs.pop('cls', None) # type: ClsType[None] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) - api_version = kwargs.pop('api_version', "2021-04-01") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - request = build_deployments_delete_at_tenant_scope_request_initial( + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-04-01")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[None] + + request = build_deployments_delete_at_tenant_scope_request( deployment_name=deployment_name, api_version=api_version, - template_url=self._delete_at_tenant_scope_initial.metadata['url'], + template_url=self._delete_at_tenant_scope_initial.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [202, 204]: @@ -853,15 +1135,10 @@ async def _delete_at_tenant_scope_initial( # pylint: disable=inconsistent-retur if cls: return cls(pipeline_response, None, {}) - _delete_at_tenant_scope_initial.metadata = {'url': "/providers/Microsoft.Resources/deployments/{deploymentName}"} # type: ignore - + _delete_at_tenant_scope_initial.metadata = {"url": "/providers/Microsoft.Resources/deployments/{deploymentName}"} # type: ignore @distributed_trace_async - async def begin_delete_at_tenant_scope( # pylint: disable=inconsistent-return-statements - self, - deployment_name: str, - **kwargs: Any - ) -> AsyncLROPoller[None]: + async def begin_delete_at_tenant_scope(self, deployment_name: str, **kwargs: Any) -> AsyncLROPoller[None]: """Deletes a deployment from the deployment history. A template deployment that is currently running cannot be deleted. Deleting a template @@ -872,7 +1149,7 @@ async def begin_delete_at_tenant_scope( # pylint: disable=inconsistent-return-s process finishes, the URI in the Location header returns a status of 204 on success. If the asynchronous request failed, the URI in the Location header returns an error-level status code. - :param deployment_name: The name of the deployment. + :param deployment_name: The name of the deployment. Required. :type deployment_name: str :keyword callable cls: A custom type or function that will be passed the direct response :keyword str continuation_token: A continuation token to restart a poller from a saved state. @@ -884,81 +1161,87 @@ async def begin_delete_at_tenant_scope( # pylint: disable=inconsistent-return-s Retry-After header is present. :return: An instance of AsyncLROPoller that returns either None or the result of cls(response) :rtype: ~azure.core.polling.AsyncLROPoller[None] - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - api_version = kwargs.pop('api_version', "2021-04-01") # type: str - polling = kwargs.pop('polling', True) # type: Union[bool, AsyncPollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType[None] - lro_delay = kwargs.pop( - 'polling_interval', - self._config.polling_interval - ) - cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-04-01")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[None] + polling = kwargs.pop("polling", True) # type: Union[bool, AsyncPollingMethod] + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token = kwargs.pop("continuation_token", None) # type: Optional[str] if cont_token is None: - raw_result = await self._delete_at_tenant_scope_initial( + raw_result = await self._delete_at_tenant_scope_initial( # type: ignore deployment_name=deployment_name, api_version=api_version, - cls=lambda x,y,z: x, + cls=lambda x, y, z: x, + headers=_headers, + params=_params, **kwargs ) - kwargs.pop('error_map', None) + kwargs.pop("error_map", None) - def get_long_running_output(pipeline_response): + def get_long_running_output(pipeline_response): # pylint: disable=inconsistent-return-statements if cls: return cls(pipeline_response, None, {}) - - if polling is True: polling_method = AsyncARMPolling(lro_delay, **kwargs) - elif polling is False: polling_method = AsyncNoPolling() - else: polling_method = polling + if polling is True: + polling_method = cast(AsyncPollingMethod, AsyncARMPolling(lro_delay, **kwargs)) # type: AsyncPollingMethod + elif polling is False: + polling_method = cast(AsyncPollingMethod, AsyncNoPolling()) + else: + polling_method = polling if cont_token: return AsyncLROPoller.from_continuation_token( polling_method=polling_method, continuation_token=cont_token, client=self._client, - deserialization_callback=get_long_running_output + deserialization_callback=get_long_running_output, ) return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) - begin_delete_at_tenant_scope.metadata = {'url': "/providers/Microsoft.Resources/deployments/{deploymentName}"} # type: ignore + begin_delete_at_tenant_scope.metadata = {"url": "/providers/Microsoft.Resources/deployments/{deploymentName}"} # type: ignore @distributed_trace_async - async def check_existence_at_tenant_scope( - self, - deployment_name: str, - **kwargs: Any - ) -> bool: + async def check_existence_at_tenant_scope(self, deployment_name: str, **kwargs: Any) -> bool: """Checks whether the deployment exists. - :param deployment_name: The name of the deployment. + :param deployment_name: The name of the deployment. Required. :type deployment_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: bool, or the result of cls(response) + :return: bool or the result of cls(response) :rtype: bool - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType[None] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + 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', "2021-04-01") # type: str + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-04-01")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[None] - request = build_deployments_check_existence_at_tenant_scope_request( deployment_name=deployment_name, api_version=api_version, - template_url=self.check_existence_at_tenant_scope.metadata['url'], + template_url=self.check_existence_at_tenant_scope.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [204, 404]: @@ -969,41 +1252,51 @@ async def check_existence_at_tenant_scope( return cls(pipeline_response, None, {}) return 200 <= response.status_code <= 299 - check_existence_at_tenant_scope.metadata = {'url': "/providers/Microsoft.Resources/deployments/{deploymentName}"} # type: ignore - + check_existence_at_tenant_scope.metadata = {"url": "/providers/Microsoft.Resources/deployments/{deploymentName}"} # type: ignore async def _create_or_update_at_tenant_scope_initial( - self, - deployment_name: str, - parameters: "_models.ScopedDeployment", - **kwargs: Any - ) -> "_models.DeploymentExtended": - cls = kwargs.pop('cls', None) # type: ClsType["_models.DeploymentExtended"] + self, deployment_name: str, parameters: Union[_models.ScopedDeployment, IO], **kwargs: Any + ) -> _models.DeploymentExtended: error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', "2021-04-01") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-04-01")) # type: str + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.DeploymentExtended] - _json = self._serialize.body(parameters, 'ScopedDeployment') + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(parameters, (IO, bytes)): + _content = parameters + else: + _json = self._serialize.body(parameters, "ScopedDeployment") - request = build_deployments_create_or_update_at_tenant_scope_request_initial( + request = build_deployments_create_or_update_at_tenant_scope_request( deployment_name=deployment_name, api_version=api_version, content_type=content_type, json=_json, - template_url=self._create_or_update_at_tenant_scope_initial.metadata['url'], + content=_content, + template_url=self._create_or_update_at_tenant_scope_initial.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200, 201]: @@ -1011,34 +1304,38 @@ async def _create_or_update_at_tenant_scope_initial( raise HttpResponseError(response=response, error_format=ARMErrorFormat) if response.status_code == 200: - deserialized = self._deserialize('DeploymentExtended', pipeline_response) + deserialized = self._deserialize("DeploymentExtended", pipeline_response) if response.status_code == 201: - deserialized = self._deserialize('DeploymentExtended', pipeline_response) + deserialized = self._deserialize("DeploymentExtended", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - _create_or_update_at_tenant_scope_initial.metadata = {'url': "/providers/Microsoft.Resources/deployments/{deploymentName}"} # type: ignore + _create_or_update_at_tenant_scope_initial.metadata = {"url": "/providers/Microsoft.Resources/deployments/{deploymentName}"} # type: ignore - - @distributed_trace_async + @overload async def begin_create_or_update_at_tenant_scope( self, deployment_name: str, - parameters: "_models.ScopedDeployment", + parameters: _models.ScopedDeployment, + *, + content_type: str = "application/json", **kwargs: Any - ) -> AsyncLROPoller["_models.DeploymentExtended"]: + ) -> AsyncLROPoller[_models.DeploymentExtended]: """Deploys resources at tenant scope. You can provide the template and parameters directly in the request or link to JSON files. - :param deployment_name: The name of the deployment. + :param deployment_name: The name of the deployment. Required. :type deployment_name: str - :param parameters: Additional parameters supplied to the operation. + :param parameters: Additional parameters supplied to the operation. Required. :type parameters: ~azure.mgmt.resource.resources.v2021_04_01.models.ScopedDeployment + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str :keyword callable cls: A custom type or function that will be passed the direct response :keyword str continuation_token: A continuation token to restart a poller from a saved state. :keyword polling: By default, your polling method will be AsyncARMPolling. Pass in False for @@ -1051,108 +1348,171 @@ async def begin_create_or_update_at_tenant_scope( cls(response) :rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.resource.resources.v2021_04_01.models.DeploymentExtended] - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - api_version = kwargs.pop('api_version', "2021-04-01") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] - polling = kwargs.pop('polling', True) # type: Union[bool, AsyncPollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType["_models.DeploymentExtended"] - lro_delay = kwargs.pop( - 'polling_interval', - self._config.polling_interval - ) - cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] - if cont_token is None: - raw_result = await self._create_or_update_at_tenant_scope_initial( - deployment_name=deployment_name, - parameters=parameters, - api_version=api_version, - content_type=content_type, - cls=lambda x,y,z: x, - **kwargs - ) - kwargs.pop('error_map', None) - - def get_long_running_output(pipeline_response): - response = pipeline_response.http_response - deserialized = self._deserialize('DeploymentExtended', pipeline_response) - if cls: - return cls(pipeline_response, deserialized, {}) - return deserialized - - - if polling is True: polling_method = AsyncARMPolling(lro_delay, **kwargs) - elif polling is False: polling_method = AsyncNoPolling() - else: polling_method = polling - if cont_token: - return AsyncLROPoller.from_continuation_token( - polling_method=polling_method, - continuation_token=cont_token, - client=self._client, - deserialization_callback=get_long_running_output - ) - return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) - begin_create_or_update_at_tenant_scope.metadata = {'url': "/providers/Microsoft.Resources/deployments/{deploymentName}"} # type: ignore + @overload + async def begin_create_or_update_at_tenant_scope( + self, deployment_name: str, parameters: IO, *, content_type: str = "application/json", **kwargs: Any + ) -> AsyncLROPoller[_models.DeploymentExtended]: + """Deploys resources at tenant scope. - @distributed_trace_async - async def get_at_tenant_scope( - self, - deployment_name: str, - **kwargs: Any - ) -> "_models.DeploymentExtended": - """Gets a deployment. + You can provide the template and parameters directly in the request or link to JSON files. - :param deployment_name: The name of the deployment. + :param deployment_name: The name of the deployment. Required. :type deployment_name: str + :param parameters: Additional parameters supplied to the operation. Required. + :type parameters: IO + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: DeploymentExtended, or the result of cls(response) - :rtype: ~azure.mgmt.resource.resources.v2021_04_01.models.DeploymentExtended - :raises: ~azure.core.exceptions.HttpResponseError - """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.DeploymentExtended"] - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {})) + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be AsyncARMPolling. Pass in False for + this operation to not poll, or pass in your own initialized polling object for a personal + polling strategy. + :paramtype polling: bool or ~azure.core.polling.AsyncPollingMethod + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of AsyncLROPoller that returns either DeploymentExtended or the result of + cls(response) + :rtype: + ~azure.core.polling.AsyncLROPoller[~azure.mgmt.resource.resources.v2021_04_01.models.DeploymentExtended] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace_async + async def begin_create_or_update_at_tenant_scope( + self, deployment_name: str, parameters: Union[_models.ScopedDeployment, IO], **kwargs: Any + ) -> AsyncLROPoller[_models.DeploymentExtended]: + """Deploys resources at tenant scope. + + You can provide the template and parameters directly in the request or link to JSON files. + + :param deployment_name: The name of the deployment. Required. + :type deployment_name: str + :param parameters: Additional parameters supplied to the operation. Is either a model type or a + IO type. Required. + :type parameters: ~azure.mgmt.resource.resources.v2021_04_01.models.ScopedDeployment or IO + :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. + Default value is None. + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be AsyncARMPolling. Pass in False for + this operation to not poll, or pass in your own initialized polling object for a personal + polling strategy. + :paramtype polling: bool or ~azure.core.polling.AsyncPollingMethod + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of AsyncLROPoller that returns either DeploymentExtended or the result of + cls(response) + :rtype: + ~azure.core.polling.AsyncLROPoller[~azure.mgmt.resource.resources.v2021_04_01.models.DeploymentExtended] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _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-04-01")) # type: str + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.DeploymentExtended] + polling = kwargs.pop("polling", True) # type: Union[bool, AsyncPollingMethod] + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token = kwargs.pop("continuation_token", None) # type: Optional[str] + if cont_token is None: + raw_result = await self._create_or_update_at_tenant_scope_initial( # type: ignore + deployment_name=deployment_name, + parameters=parameters, + api_version=api_version, + content_type=content_type, + cls=lambda x, y, z: x, + headers=_headers, + params=_params, + **kwargs + ) + kwargs.pop("error_map", None) + + def get_long_running_output(pipeline_response): + deserialized = self._deserialize("DeploymentExtended", pipeline_response) + if cls: + return cls(pipeline_response, deserialized, {}) + return deserialized + + if polling is True: + polling_method = cast(AsyncPollingMethod, AsyncARMPolling(lro_delay, **kwargs)) # type: AsyncPollingMethod + elif polling is False: + polling_method = cast(AsyncPollingMethod, AsyncNoPolling()) + else: + polling_method = polling + if cont_token: + return AsyncLROPoller.from_continuation_token( + polling_method=polling_method, + continuation_token=cont_token, + client=self._client, + deserialization_callback=get_long_running_output, + ) + return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) + + begin_create_or_update_at_tenant_scope.metadata = {"url": "/providers/Microsoft.Resources/deployments/{deploymentName}"} # type: ignore + + @distributed_trace_async + async def get_at_tenant_scope(self, deployment_name: str, **kwargs: Any) -> _models.DeploymentExtended: + """Gets a deployment. + + :param deployment_name: The name of the deployment. Required. + :type deployment_name: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: DeploymentExtended or the result of cls(response) + :rtype: ~azure.mgmt.resource.resources.v2021_04_01.models.DeploymentExtended + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) - api_version = kwargs.pop('api_version', "2021-04-01") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-04-01")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[_models.DeploymentExtended] - request = build_deployments_get_at_tenant_scope_request( deployment_name=deployment_name, api_version=api_version, - template_url=self.get_at_tenant_scope.metadata['url'], + template_url=self.get_at_tenant_scope.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) - deserialized = self._deserialize('DeploymentExtended', pipeline_response) + deserialized = self._deserialize("DeploymentExtended", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - get_at_tenant_scope.metadata = {'url': "/providers/Microsoft.Resources/deployments/{deploymentName}"} # type: ignore - + get_at_tenant_scope.metadata = {"url": "/providers/Microsoft.Resources/deployments/{deploymentName}"} # type: ignore @distributed_trace_async async def cancel_at_tenant_scope( # pylint: disable=inconsistent-return-statements - self, - deployment_name: str, - **kwargs: Any + self, deployment_name: str, **kwargs: Any ) -> None: """Cancels a currently running template deployment. @@ -1161,35 +1521,41 @@ async def cancel_at_tenant_scope( # pylint: disable=inconsistent-return-stateme deployment stops the currently running template deployment and leaves the resources partially deployed. - :param deployment_name: The name of the deployment. + :param deployment_name: The name of the deployment. Required. :type deployment_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: None, or the result of cls(response) + :return: None or the result of cls(response) :rtype: None - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType[None] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) - api_version = kwargs.pop('api_version', "2021-04-01") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-04-01")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[None] - request = build_deployments_cancel_at_tenant_scope_request( deployment_name=deployment_name, api_version=api_version, - template_url=self.cancel_at_tenant_scope.metadata['url'], + template_url=self.cancel_at_tenant_scope.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [204]: @@ -1199,41 +1565,51 @@ async def cancel_at_tenant_scope( # pylint: disable=inconsistent-return-stateme if cls: return cls(pipeline_response, None, {}) - cancel_at_tenant_scope.metadata = {'url': "/providers/Microsoft.Resources/deployments/{deploymentName}/cancel"} # type: ignore - + cancel_at_tenant_scope.metadata = {"url": "/providers/Microsoft.Resources/deployments/{deploymentName}/cancel"} # type: ignore async def _validate_at_tenant_scope_initial( - self, - deployment_name: str, - parameters: "_models.ScopedDeployment", - **kwargs: Any - ) -> Optional["_models.DeploymentValidateResult"]: - cls = kwargs.pop('cls', None) # type: ClsType[Optional["_models.DeploymentValidateResult"]] + self, deployment_name: str, parameters: Union[_models.ScopedDeployment, IO], **kwargs: Any + ) -> Optional[_models.DeploymentValidateResult]: error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) - api_version = kwargs.pop('api_version', "2021-04-01") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - _json = self._serialize.body(parameters, 'ScopedDeployment') + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-04-01")) # type: str + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[Optional[_models.DeploymentValidateResult]] + + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(parameters, (IO, bytes)): + _content = parameters + else: + _json = self._serialize.body(parameters, "ScopedDeployment") - request = build_deployments_validate_at_tenant_scope_request_initial( + request = build_deployments_validate_at_tenant_scope_request( deployment_name=deployment_name, api_version=api_version, content_type=content_type, json=_json, - template_url=self._validate_at_tenant_scope_initial.metadata['url'], + content=_content, + template_url=self._validate_at_tenant_scope_initial.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200, 202, 400]: @@ -1242,33 +1618,37 @@ async def _validate_at_tenant_scope_initial( deserialized = None if response.status_code == 200: - deserialized = self._deserialize('DeploymentValidateResult', pipeline_response) + deserialized = self._deserialize("DeploymentValidateResult", pipeline_response) if response.status_code == 400: - deserialized = self._deserialize('DeploymentValidateResult', pipeline_response) + deserialized = self._deserialize("DeploymentValidateResult", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - _validate_at_tenant_scope_initial.metadata = {'url': "/providers/Microsoft.Resources/deployments/{deploymentName}/validate"} # type: ignore - + _validate_at_tenant_scope_initial.metadata = {"url": "/providers/Microsoft.Resources/deployments/{deploymentName}/validate"} # type: ignore - @distributed_trace_async + @overload async def begin_validate_at_tenant_scope( self, deployment_name: str, - parameters: "_models.ScopedDeployment", + parameters: _models.ScopedDeployment, + *, + content_type: str = "application/json", **kwargs: Any - ) -> AsyncLROPoller["_models.DeploymentValidateResult"]: + ) -> AsyncLROPoller[_models.DeploymentValidateResult]: """Validates whether the specified template is syntactically correct and will be accepted by Azure Resource Manager.. - :param deployment_name: The name of the deployment. + :param deployment_name: The name of the deployment. Required. :type deployment_name: str - :param parameters: Parameters to validate. + :param parameters: Parameters to validate. Required. :type parameters: ~azure.mgmt.resource.resources.v2021_04_01.models.ScopedDeployment + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str :keyword callable cls: A custom type or function that will be passed the direct response :keyword str continuation_token: A continuation token to restart a poller from a saved state. :keyword polling: By default, your polling method will be AsyncARMPolling. Pass in False for @@ -1281,82 +1661,154 @@ async def begin_validate_at_tenant_scope( result of cls(response) :rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.resource.resources.v2021_04_01.models.DeploymentValidateResult] - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - api_version = kwargs.pop('api_version', "2021-04-01") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] - polling = kwargs.pop('polling', True) # type: Union[bool, AsyncPollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType["_models.DeploymentValidateResult"] - lro_delay = kwargs.pop( - 'polling_interval', - self._config.polling_interval - ) - cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] + + @overload + async def begin_validate_at_tenant_scope( + self, deployment_name: str, parameters: IO, *, content_type: str = "application/json", **kwargs: Any + ) -> AsyncLROPoller[_models.DeploymentValidateResult]: + """Validates whether the specified template is syntactically correct and will be accepted by Azure + Resource Manager.. + + :param deployment_name: The name of the deployment. Required. + :type deployment_name: str + :param parameters: Parameters to validate. Required. + :type parameters: IO + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be AsyncARMPolling. Pass in False for + this operation to not poll, or pass in your own initialized polling object for a personal + polling strategy. + :paramtype polling: bool or ~azure.core.polling.AsyncPollingMethod + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of AsyncLROPoller that returns either DeploymentValidateResult or the + result of cls(response) + :rtype: + ~azure.core.polling.AsyncLROPoller[~azure.mgmt.resource.resources.v2021_04_01.models.DeploymentValidateResult] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace_async + async def begin_validate_at_tenant_scope( + self, deployment_name: str, parameters: Union[_models.ScopedDeployment, IO], **kwargs: Any + ) -> AsyncLROPoller[_models.DeploymentValidateResult]: + """Validates whether the specified template is syntactically correct and will be accepted by Azure + Resource Manager.. + + :param deployment_name: The name of the deployment. Required. + :type deployment_name: str + :param parameters: Parameters to validate. Is either a model type or a IO type. Required. + :type parameters: ~azure.mgmt.resource.resources.v2021_04_01.models.ScopedDeployment or IO + :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. + Default value is None. + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be AsyncARMPolling. Pass in False for + this operation to not poll, or pass in your own initialized polling object for a personal + polling strategy. + :paramtype polling: bool or ~azure.core.polling.AsyncPollingMethod + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of AsyncLROPoller that returns either DeploymentValidateResult or the + result of cls(response) + :rtype: + ~azure.core.polling.AsyncLROPoller[~azure.mgmt.resource.resources.v2021_04_01.models.DeploymentValidateResult] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _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-04-01")) # type: str + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.DeploymentValidateResult] + polling = kwargs.pop("polling", True) # type: Union[bool, AsyncPollingMethod] + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token = kwargs.pop("continuation_token", None) # type: Optional[str] if cont_token is None: - raw_result = await self._validate_at_tenant_scope_initial( + raw_result = await self._validate_at_tenant_scope_initial( # type: ignore deployment_name=deployment_name, parameters=parameters, api_version=api_version, content_type=content_type, - cls=lambda x,y,z: x, + cls=lambda x, y, z: x, + headers=_headers, + params=_params, **kwargs ) - kwargs.pop('error_map', None) + kwargs.pop("error_map", None) def get_long_running_output(pipeline_response): - response = pipeline_response.http_response - deserialized = self._deserialize('DeploymentValidateResult', pipeline_response) + deserialized = self._deserialize("DeploymentValidateResult", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - - if polling is True: polling_method = AsyncARMPolling(lro_delay, **kwargs) - elif polling is False: polling_method = AsyncNoPolling() - else: polling_method = polling + if polling is True: + polling_method = cast(AsyncPollingMethod, AsyncARMPolling(lro_delay, **kwargs)) # type: AsyncPollingMethod + elif polling is False: + polling_method = cast(AsyncPollingMethod, AsyncNoPolling()) + else: + polling_method = polling if cont_token: return AsyncLROPoller.from_continuation_token( polling_method=polling_method, continuation_token=cont_token, client=self._client, - deserialization_callback=get_long_running_output + deserialization_callback=get_long_running_output, ) return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) - begin_validate_at_tenant_scope.metadata = {'url': "/providers/Microsoft.Resources/deployments/{deploymentName}/validate"} # type: ignore + begin_validate_at_tenant_scope.metadata = {"url": "/providers/Microsoft.Resources/deployments/{deploymentName}/validate"} # type: ignore async def _what_if_at_tenant_scope_initial( - self, - deployment_name: str, - parameters: "_models.ScopedDeploymentWhatIf", - **kwargs: Any - ) -> Optional["_models.WhatIfOperationResult"]: - cls = kwargs.pop('cls', None) # type: ClsType[Optional["_models.WhatIfOperationResult"]] + self, deployment_name: str, parameters: Union[_models.ScopedDeploymentWhatIf, IO], **kwargs: Any + ) -> Optional[_models.WhatIfOperationResult]: error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) - api_version = kwargs.pop('api_version', "2021-04-01") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - _json = self._serialize.body(parameters, 'ScopedDeploymentWhatIf') + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-04-01")) # type: str + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[Optional[_models.WhatIfOperationResult]] + + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(parameters, (IO, bytes)): + _content = parameters + else: + _json = self._serialize.body(parameters, "ScopedDeploymentWhatIf") - request = build_deployments_what_if_at_tenant_scope_request_initial( + request = build_deployments_what_if_at_tenant_scope_request( deployment_name=deployment_name, api_version=api_version, content_type=content_type, json=_json, - template_url=self._what_if_at_tenant_scope_initial.metadata['url'], + content=_content, + template_url=self._what_if_at_tenant_scope_initial.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200, 202]: @@ -1366,35 +1818,38 @@ async def _what_if_at_tenant_scope_initial( deserialized = None response_headers = {} if response.status_code == 200: - deserialized = self._deserialize('WhatIfOperationResult', pipeline_response) + deserialized = self._deserialize("WhatIfOperationResult", pipeline_response) if response.status_code == 202: - response_headers['Location']=self._deserialize('str', response.headers.get('Location')) - response_headers['Retry-After']=self._deserialize('str', response.headers.get('Retry-After')) - + response_headers["Location"] = self._deserialize("str", response.headers.get("Location")) + response_headers["Retry-After"] = self._deserialize("str", response.headers.get("Retry-After")) if cls: return cls(pipeline_response, deserialized, response_headers) return deserialized - _what_if_at_tenant_scope_initial.metadata = {'url': "/providers/Microsoft.Resources/deployments/{deploymentName}/whatIf"} # type: ignore - + _what_if_at_tenant_scope_initial.metadata = {"url": "/providers/Microsoft.Resources/deployments/{deploymentName}/whatIf"} # type: ignore - @distributed_trace_async + @overload async def begin_what_if_at_tenant_scope( self, deployment_name: str, - parameters: "_models.ScopedDeploymentWhatIf", + parameters: _models.ScopedDeploymentWhatIf, + *, + content_type: str = "application/json", **kwargs: Any - ) -> AsyncLROPoller["_models.WhatIfOperationResult"]: + ) -> AsyncLROPoller[_models.WhatIfOperationResult]: """Returns changes that will be made by the deployment if executed at the scope of the tenant group. - :param deployment_name: The name of the deployment. + :param deployment_name: The name of the deployment. Required. :type deployment_name: str - :param parameters: Parameters to validate. + :param parameters: Parameters to validate. Required. :type parameters: ~azure.mgmt.resource.resources.v2021_04_01.models.ScopedDeploymentWhatIf + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str :keyword callable cls: A custom type or function that will be passed the direct response :keyword str continuation_token: A continuation token to restart a poller from a saved state. :keyword polling: By default, your polling method will be AsyncARMPolling. Pass in False for @@ -1407,110 +1862,174 @@ async def begin_what_if_at_tenant_scope( of cls(response) :rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.resource.resources.v2021_04_01.models.WhatIfOperationResult] - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - api_version = kwargs.pop('api_version', "2021-04-01") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] - polling = kwargs.pop('polling', True) # type: Union[bool, AsyncPollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType["_models.WhatIfOperationResult"] - lro_delay = kwargs.pop( - 'polling_interval', - self._config.polling_interval - ) - cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] + + @overload + async def begin_what_if_at_tenant_scope( + self, deployment_name: str, parameters: IO, *, content_type: str = "application/json", **kwargs: Any + ) -> AsyncLROPoller[_models.WhatIfOperationResult]: + """Returns changes that will be made by the deployment if executed at the scope of the tenant + group. + + :param deployment_name: The name of the deployment. Required. + :type deployment_name: str + :param parameters: Parameters to validate. Required. + :type parameters: IO + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be AsyncARMPolling. Pass in False for + this operation to not poll, or pass in your own initialized polling object for a personal + polling strategy. + :paramtype polling: bool or ~azure.core.polling.AsyncPollingMethod + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of AsyncLROPoller that returns either WhatIfOperationResult or the result + of cls(response) + :rtype: + ~azure.core.polling.AsyncLROPoller[~azure.mgmt.resource.resources.v2021_04_01.models.WhatIfOperationResult] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace_async + async def begin_what_if_at_tenant_scope( + self, deployment_name: str, parameters: Union[_models.ScopedDeploymentWhatIf, IO], **kwargs: Any + ) -> AsyncLROPoller[_models.WhatIfOperationResult]: + """Returns changes that will be made by the deployment if executed at the scope of the tenant + group. + + :param deployment_name: The name of the deployment. Required. + :type deployment_name: str + :param parameters: Parameters to validate. Is either a model type or a IO type. Required. + :type parameters: ~azure.mgmt.resource.resources.v2021_04_01.models.ScopedDeploymentWhatIf or + IO + :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. + Default value is None. + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be AsyncARMPolling. Pass in False for + this operation to not poll, or pass in your own initialized polling object for a personal + polling strategy. + :paramtype polling: bool or ~azure.core.polling.AsyncPollingMethod + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of AsyncLROPoller that returns either WhatIfOperationResult or the result + of cls(response) + :rtype: + ~azure.core.polling.AsyncLROPoller[~azure.mgmt.resource.resources.v2021_04_01.models.WhatIfOperationResult] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _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-04-01")) # type: str + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.WhatIfOperationResult] + polling = kwargs.pop("polling", True) # type: Union[bool, AsyncPollingMethod] + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token = kwargs.pop("continuation_token", None) # type: Optional[str] if cont_token is None: - raw_result = await self._what_if_at_tenant_scope_initial( + raw_result = await self._what_if_at_tenant_scope_initial( # type: ignore deployment_name=deployment_name, parameters=parameters, api_version=api_version, content_type=content_type, - cls=lambda x,y,z: x, + cls=lambda x, y, z: x, + headers=_headers, + params=_params, **kwargs ) - kwargs.pop('error_map', None) + kwargs.pop("error_map", None) def get_long_running_output(pipeline_response): - response = pipeline_response.http_response - deserialized = self._deserialize('WhatIfOperationResult', pipeline_response) + deserialized = self._deserialize("WhatIfOperationResult", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - - if polling is True: polling_method = AsyncARMPolling(lro_delay, lro_options={'final-state-via': 'location'}, **kwargs) - elif polling is False: polling_method = AsyncNoPolling() - else: polling_method = polling + if polling is True: + polling_method = cast( + AsyncPollingMethod, AsyncARMPolling(lro_delay, lro_options={"final-state-via": "location"}, **kwargs) + ) # type: AsyncPollingMethod + elif polling is False: + polling_method = cast(AsyncPollingMethod, AsyncNoPolling()) + else: + polling_method = polling if cont_token: return AsyncLROPoller.from_continuation_token( polling_method=polling_method, continuation_token=cont_token, client=self._client, - deserialization_callback=get_long_running_output + deserialization_callback=get_long_running_output, ) return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) - begin_what_if_at_tenant_scope.metadata = {'url': "/providers/Microsoft.Resources/deployments/{deploymentName}/whatIf"} # type: ignore + begin_what_if_at_tenant_scope.metadata = {"url": "/providers/Microsoft.Resources/deployments/{deploymentName}/whatIf"} # type: ignore @distributed_trace_async async def export_template_at_tenant_scope( - self, - deployment_name: str, - **kwargs: Any - ) -> "_models.DeploymentExportResult": + self, deployment_name: str, **kwargs: Any + ) -> _models.DeploymentExportResult: """Exports the template used for specified deployment. - :param deployment_name: The name of the deployment. + :param deployment_name: The name of the deployment. Required. :type deployment_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: DeploymentExportResult, or the result of cls(response) + :return: DeploymentExportResult or the result of cls(response) :rtype: ~azure.mgmt.resource.resources.v2021_04_01.models.DeploymentExportResult - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.DeploymentExportResult"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) - api_version = kwargs.pop('api_version', "2021-04-01") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-04-01")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[_models.DeploymentExportResult] - request = build_deployments_export_template_at_tenant_scope_request( deployment_name=deployment_name, api_version=api_version, - template_url=self.export_template_at_tenant_scope.metadata['url'], + template_url=self.export_template_at_tenant_scope.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) - deserialized = self._deserialize('DeploymentExportResult', pipeline_response) + deserialized = self._deserialize("DeploymentExportResult", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - export_template_at_tenant_scope.metadata = {'url': "/providers/Microsoft.Resources/deployments/{deploymentName}/exportTemplate"} # type: ignore - + export_template_at_tenant_scope.metadata = {"url": "/providers/Microsoft.Resources/deployments/{deploymentName}/exportTemplate"} # type: ignore @distributed_trace def list_at_tenant_scope( - self, - filter: Optional[str] = None, - top: Optional[int] = None, - **kwargs: Any - ) -> AsyncIterable["_models.DeploymentListResult"]: + self, filter: Optional[str] = None, top: Optional[int] = None, **kwargs: Any + ) -> AsyncIterable["_models.DeploymentExtended"]: """Get all the deployments at the tenant scope. :param filter: The filter to apply on the operation. For example, you can use @@ -1520,38 +2039,47 @@ def list_at_tenant_scope( value is None. :type top: int :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either DeploymentListResult or the result of - cls(response) + :return: An iterator like instance of either DeploymentExtended or the result of cls(response) :rtype: - ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.resource.resources.v2021_04_01.models.DeploymentListResult] - :raises: ~azure.core.exceptions.HttpResponseError + ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.resource.resources.v2021_04_01.models.DeploymentExtended] + :raises ~azure.core.exceptions.HttpResponseError: """ - api_version = kwargs.pop('api_version', "2021-04-01") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-04-01")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[_models.DeploymentListResult] - cls = kwargs.pop('cls', None) # type: ClsType["_models.DeploymentListResult"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) + def prepare_request(next_link=None): if not next_link: - + request = build_deployments_list_at_tenant_scope_request( - api_version=api_version, filter=filter, top=top, - template_url=self.list_at_tenant_scope.metadata['url'], + api_version=api_version, + template_url=self.list_at_tenant_scope.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore else: - - request = build_deployments_list_at_tenant_scope_request( - template_url=next_link, - ) + # make call to next link with the client's api-version + _parsed_next_link = urlparse(next_link) + _next_request_params = case_insensitive_dict(parse_qs(_parsed_next_link.query)) + _next_request_params["api-version"] = self._config.api_version + request = HttpRequest("GET", urljoin(next_link, _parsed_next_link.path), params=_next_request_params) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore request.method = "GET" return request @@ -1565,10 +2093,8 @@ async def extract_data(pipeline_response): async def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) response = pipeline_response.http_response @@ -1578,41 +2104,42 @@ async def get_next(next_link=None): return pipeline_response + return AsyncItemPaged(get_next, extract_data) - return AsyncItemPaged( - get_next, extract_data - ) - list_at_tenant_scope.metadata = {'url': "/providers/Microsoft.Resources/deployments/"} # type: ignore + list_at_tenant_scope.metadata = {"url": "/providers/Microsoft.Resources/deployments/"} # type: ignore async def _delete_at_management_group_scope_initial( # pylint: disable=inconsistent-return-statements - self, - group_id: str, - deployment_name: str, - **kwargs: Any + self, group_id: str, deployment_name: str, **kwargs: Any ) -> None: - cls = kwargs.pop('cls', None) # type: ClsType[None] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + 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', "2021-04-01") # type: str + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-04-01")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[None] - - request = build_deployments_delete_at_management_group_scope_request_initial( + request = build_deployments_delete_at_management_group_scope_request( group_id=group_id, deployment_name=deployment_name, api_version=api_version, - template_url=self._delete_at_management_group_scope_initial.metadata['url'], + template_url=self._delete_at_management_group_scope_initial.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [202, 204]: @@ -1622,15 +2149,11 @@ async def _delete_at_management_group_scope_initial( # pylint: disable=inconsis if cls: return cls(pipeline_response, None, {}) - _delete_at_management_group_scope_initial.metadata = {'url': "/providers/Microsoft.Management/managementGroups/{groupId}/providers/Microsoft.Resources/deployments/{deploymentName}"} # type: ignore - + _delete_at_management_group_scope_initial.metadata = {"url": "/providers/Microsoft.Management/managementGroups/{groupId}/providers/Microsoft.Resources/deployments/{deploymentName}"} # type: ignore @distributed_trace_async - async def begin_delete_at_management_group_scope( # pylint: disable=inconsistent-return-statements - self, - group_id: str, - deployment_name: str, - **kwargs: Any + async def begin_delete_at_management_group_scope( + self, group_id: str, deployment_name: str, **kwargs: Any ) -> AsyncLROPoller[None]: """Deletes a deployment from the deployment history. @@ -1642,9 +2165,9 @@ async def begin_delete_at_management_group_scope( # pylint: disable=inconsisten process finishes, the URI in the Location header returns a status of 204 on success. If the asynchronous request failed, the URI in the Location header returns an error-level status code. - :param group_id: The management group ID. + :param group_id: The management group ID. Required. :type group_id: str - :param deployment_name: The name of the deployment. + :param deployment_name: The name of the deployment. Required. :type deployment_name: str :keyword callable cls: A custom type or function that will be passed the direct response :keyword str continuation_token: A continuation token to restart a poller from a saved state. @@ -1656,86 +2179,93 @@ async def begin_delete_at_management_group_scope( # pylint: disable=inconsisten Retry-After header is present. :return: An instance of AsyncLROPoller that returns either None or the result of cls(response) :rtype: ~azure.core.polling.AsyncLROPoller[None] - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - api_version = kwargs.pop('api_version', "2021-04-01") # type: str - polling = kwargs.pop('polling', True) # type: Union[bool, AsyncPollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType[None] - lro_delay = kwargs.pop( - 'polling_interval', - self._config.polling_interval - ) - cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-04-01")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[None] + polling = kwargs.pop("polling", True) # type: Union[bool, AsyncPollingMethod] + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token = kwargs.pop("continuation_token", None) # type: Optional[str] if cont_token is None: - raw_result = await self._delete_at_management_group_scope_initial( + raw_result = await self._delete_at_management_group_scope_initial( # type: ignore group_id=group_id, deployment_name=deployment_name, api_version=api_version, - cls=lambda x,y,z: x, + cls=lambda x, y, z: x, + headers=_headers, + params=_params, **kwargs ) - kwargs.pop('error_map', None) + kwargs.pop("error_map", None) - def get_long_running_output(pipeline_response): + def get_long_running_output(pipeline_response): # pylint: disable=inconsistent-return-statements if cls: return cls(pipeline_response, None, {}) - - if polling is True: polling_method = AsyncARMPolling(lro_delay, **kwargs) - elif polling is False: polling_method = AsyncNoPolling() - else: polling_method = polling + if polling is True: + polling_method = cast(AsyncPollingMethod, AsyncARMPolling(lro_delay, **kwargs)) # type: AsyncPollingMethod + elif polling is False: + polling_method = cast(AsyncPollingMethod, AsyncNoPolling()) + else: + polling_method = polling if cont_token: return AsyncLROPoller.from_continuation_token( polling_method=polling_method, continuation_token=cont_token, client=self._client, - deserialization_callback=get_long_running_output + deserialization_callback=get_long_running_output, ) return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) - begin_delete_at_management_group_scope.metadata = {'url': "/providers/Microsoft.Management/managementGroups/{groupId}/providers/Microsoft.Resources/deployments/{deploymentName}"} # type: ignore + begin_delete_at_management_group_scope.metadata = {"url": "/providers/Microsoft.Management/managementGroups/{groupId}/providers/Microsoft.Resources/deployments/{deploymentName}"} # type: ignore @distributed_trace_async async def check_existence_at_management_group_scope( - self, - group_id: str, - deployment_name: str, - **kwargs: Any + self, group_id: str, deployment_name: str, **kwargs: Any ) -> bool: """Checks whether the deployment exists. - :param group_id: The management group ID. + :param group_id: The management group ID. Required. :type group_id: str - :param deployment_name: The name of the deployment. + :param deployment_name: The name of the deployment. Required. :type deployment_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: bool, or the result of cls(response) + :return: bool or the result of cls(response) :rtype: bool - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType[None] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) - api_version = kwargs.pop('api_version', "2021-04-01") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-04-01")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[None] - request = build_deployments_check_existence_at_management_group_scope_request( group_id=group_id, deployment_name=deployment_name, api_version=api_version, - template_url=self.check_existence_at_management_group_scope.metadata['url'], + template_url=self.check_existence_at_management_group_scope.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [204, 404]: @@ -1746,43 +2276,52 @@ async def check_existence_at_management_group_scope( return cls(pipeline_response, None, {}) return 200 <= response.status_code <= 299 - check_existence_at_management_group_scope.metadata = {'url': "/providers/Microsoft.Management/managementGroups/{groupId}/providers/Microsoft.Resources/deployments/{deploymentName}"} # type: ignore - + check_existence_at_management_group_scope.metadata = {"url": "/providers/Microsoft.Management/managementGroups/{groupId}/providers/Microsoft.Resources/deployments/{deploymentName}"} # type: ignore async def _create_or_update_at_management_group_scope_initial( - self, - group_id: str, - deployment_name: str, - parameters: "_models.ScopedDeployment", - **kwargs: Any - ) -> "_models.DeploymentExtended": - cls = kwargs.pop('cls', None) # type: ClsType["_models.DeploymentExtended"] + self, group_id: str, deployment_name: str, parameters: Union[_models.ScopedDeployment, IO], **kwargs: Any + ) -> _models.DeploymentExtended: error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', "2021-04-01") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-04-01")) # type: str + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.DeploymentExtended] - _json = self._serialize.body(parameters, 'ScopedDeployment') + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(parameters, (IO, bytes)): + _content = parameters + else: + _json = self._serialize.body(parameters, "ScopedDeployment") - request = build_deployments_create_or_update_at_management_group_scope_request_initial( + request = build_deployments_create_or_update_at_management_group_scope_request( group_id=group_id, deployment_name=deployment_name, api_version=api_version, content_type=content_type, json=_json, - template_url=self._create_or_update_at_management_group_scope_initial.metadata['url'], + content=_content, + template_url=self._create_or_update_at_management_group_scope_initial.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200, 201]: @@ -1790,37 +2329,41 @@ async def _create_or_update_at_management_group_scope_initial( raise HttpResponseError(response=response, error_format=ARMErrorFormat) if response.status_code == 200: - deserialized = self._deserialize('DeploymentExtended', pipeline_response) + deserialized = self._deserialize("DeploymentExtended", pipeline_response) if response.status_code == 201: - deserialized = self._deserialize('DeploymentExtended', pipeline_response) + deserialized = self._deserialize("DeploymentExtended", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - _create_or_update_at_management_group_scope_initial.metadata = {'url': "/providers/Microsoft.Management/managementGroups/{groupId}/providers/Microsoft.Resources/deployments/{deploymentName}"} # type: ignore + _create_or_update_at_management_group_scope_initial.metadata = {"url": "/providers/Microsoft.Management/managementGroups/{groupId}/providers/Microsoft.Resources/deployments/{deploymentName}"} # type: ignore - - @distributed_trace_async + @overload async def begin_create_or_update_at_management_group_scope( self, group_id: str, deployment_name: str, - parameters: "_models.ScopedDeployment", + parameters: _models.ScopedDeployment, + *, + content_type: str = "application/json", **kwargs: Any - ) -> AsyncLROPoller["_models.DeploymentExtended"]: + ) -> AsyncLROPoller[_models.DeploymentExtended]: """Deploys resources at management group scope. You can provide the template and parameters directly in the request or link to JSON files. - :param group_id: The management group ID. + :param group_id: The management group ID. Required. :type group_id: str - :param deployment_name: The name of the deployment. + :param deployment_name: The name of the deployment. Required. :type deployment_name: str - :param parameters: Additional parameters supplied to the operation. + :param parameters: Additional parameters supplied to the operation. Required. :type parameters: ~azure.mgmt.resource.resources.v2021_04_01.models.ScopedDeployment + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str :keyword callable cls: A custom type or function that will be passed the direct response :keyword str continuation_token: A continuation token to restart a poller from a saved state. :keyword polling: By default, your polling method will be AsyncARMPolling. Pass in False for @@ -1833,114 +2376,187 @@ async def begin_create_or_update_at_management_group_scope( cls(response) :rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.resource.resources.v2021_04_01.models.DeploymentExtended] - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - api_version = kwargs.pop('api_version', "2021-04-01") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] - polling = kwargs.pop('polling', True) # type: Union[bool, AsyncPollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType["_models.DeploymentExtended"] - lro_delay = kwargs.pop( - 'polling_interval', - self._config.polling_interval - ) - cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] - if cont_token is None: - raw_result = await self._create_or_update_at_management_group_scope_initial( - group_id=group_id, - deployment_name=deployment_name, - parameters=parameters, - api_version=api_version, - content_type=content_type, - cls=lambda x,y,z: x, - **kwargs - ) - kwargs.pop('error_map', None) - def get_long_running_output(pipeline_response): - response = pipeline_response.http_response - deserialized = self._deserialize('DeploymentExtended', pipeline_response) - if cls: - return cls(pipeline_response, deserialized, {}) - return deserialized + @overload + async def begin_create_or_update_at_management_group_scope( + self, + group_id: str, + deployment_name: str, + parameters: IO, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> AsyncLROPoller[_models.DeploymentExtended]: + """Deploys resources at management group scope. + You can provide the template and parameters directly in the request or link to JSON files. - if polling is True: polling_method = AsyncARMPolling(lro_delay, **kwargs) - elif polling is False: polling_method = AsyncNoPolling() - else: polling_method = polling - if cont_token: - return AsyncLROPoller.from_continuation_token( - polling_method=polling_method, - continuation_token=cont_token, - client=self._client, - deserialization_callback=get_long_running_output + :param group_id: The management group ID. Required. + :type group_id: str + :param deployment_name: The name of the deployment. Required. + :type deployment_name: str + :param parameters: Additional parameters supplied to the operation. Required. + :type parameters: IO + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be AsyncARMPolling. Pass in False for + this operation to not poll, or pass in your own initialized polling object for a personal + polling strategy. + :paramtype polling: bool or ~azure.core.polling.AsyncPollingMethod + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of AsyncLROPoller that returns either DeploymentExtended or the result of + cls(response) + :rtype: + ~azure.core.polling.AsyncLROPoller[~azure.mgmt.resource.resources.v2021_04_01.models.DeploymentExtended] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace_async + async def begin_create_or_update_at_management_group_scope( + self, group_id: str, deployment_name: str, parameters: Union[_models.ScopedDeployment, IO], **kwargs: Any + ) -> AsyncLROPoller[_models.DeploymentExtended]: + """Deploys resources at management group scope. + + You can provide the template and parameters directly in the request or link to JSON files. + + :param group_id: The management group ID. Required. + :type group_id: str + :param deployment_name: The name of the deployment. Required. + :type deployment_name: str + :param parameters: Additional parameters supplied to the operation. Is either a model type or a + IO type. Required. + :type parameters: ~azure.mgmt.resource.resources.v2021_04_01.models.ScopedDeployment or IO + :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. + Default value is None. + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be AsyncARMPolling. Pass in False for + this operation to not poll, or pass in your own initialized polling object for a personal + polling strategy. + :paramtype polling: bool or ~azure.core.polling.AsyncPollingMethod + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of AsyncLROPoller that returns either DeploymentExtended or the result of + cls(response) + :rtype: + ~azure.core.polling.AsyncLROPoller[~azure.mgmt.resource.resources.v2021_04_01.models.DeploymentExtended] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _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-04-01")) # type: str + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.DeploymentExtended] + polling = kwargs.pop("polling", True) # type: Union[bool, AsyncPollingMethod] + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token = kwargs.pop("continuation_token", None) # type: Optional[str] + if cont_token is None: + raw_result = await self._create_or_update_at_management_group_scope_initial( # type: ignore + group_id=group_id, + deployment_name=deployment_name, + parameters=parameters, + api_version=api_version, + content_type=content_type, + cls=lambda x, y, z: x, + headers=_headers, + params=_params, + **kwargs + ) + kwargs.pop("error_map", None) + + def get_long_running_output(pipeline_response): + deserialized = self._deserialize("DeploymentExtended", pipeline_response) + if cls: + return cls(pipeline_response, deserialized, {}) + return deserialized + + if polling is True: + polling_method = cast(AsyncPollingMethod, AsyncARMPolling(lro_delay, **kwargs)) # type: AsyncPollingMethod + elif polling is False: + polling_method = cast(AsyncPollingMethod, AsyncNoPolling()) + else: + polling_method = polling + if cont_token: + return AsyncLROPoller.from_continuation_token( + polling_method=polling_method, + continuation_token=cont_token, + client=self._client, + deserialization_callback=get_long_running_output, ) return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) - begin_create_or_update_at_management_group_scope.metadata = {'url': "/providers/Microsoft.Management/managementGroups/{groupId}/providers/Microsoft.Resources/deployments/{deploymentName}"} # type: ignore + begin_create_or_update_at_management_group_scope.metadata = {"url": "/providers/Microsoft.Management/managementGroups/{groupId}/providers/Microsoft.Resources/deployments/{deploymentName}"} # type: ignore @distributed_trace_async async def get_at_management_group_scope( - self, - group_id: str, - deployment_name: str, - **kwargs: Any - ) -> "_models.DeploymentExtended": + self, group_id: str, deployment_name: str, **kwargs: Any + ) -> _models.DeploymentExtended: """Gets a deployment. - :param group_id: The management group ID. + :param group_id: The management group ID. Required. :type group_id: str - :param deployment_name: The name of the deployment. + :param deployment_name: The name of the deployment. Required. :type deployment_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: DeploymentExtended, or the result of cls(response) + :return: DeploymentExtended or the result of cls(response) :rtype: ~azure.mgmt.resource.resources.v2021_04_01.models.DeploymentExtended - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.DeploymentExtended"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) - api_version = kwargs.pop('api_version', "2021-04-01") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-04-01")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[_models.DeploymentExtended] - request = build_deployments_get_at_management_group_scope_request( group_id=group_id, deployment_name=deployment_name, api_version=api_version, - template_url=self.get_at_management_group_scope.metadata['url'], + template_url=self.get_at_management_group_scope.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) - deserialized = self._deserialize('DeploymentExtended', pipeline_response) + deserialized = self._deserialize("DeploymentExtended", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - get_at_management_group_scope.metadata = {'url': "/providers/Microsoft.Management/managementGroups/{groupId}/providers/Microsoft.Resources/deployments/{deploymentName}"} # type: ignore - + get_at_management_group_scope.metadata = {"url": "/providers/Microsoft.Management/managementGroups/{groupId}/providers/Microsoft.Resources/deployments/{deploymentName}"} # type: ignore @distributed_trace_async async def cancel_at_management_group_scope( # pylint: disable=inconsistent-return-statements - self, - group_id: str, - deployment_name: str, - **kwargs: Any + self, group_id: str, deployment_name: str, **kwargs: Any ) -> None: """Cancels a currently running template deployment. @@ -1949,38 +2565,44 @@ async def cancel_at_management_group_scope( # pylint: disable=inconsistent-retu deployment stops the currently running template deployment and leaves the resources partially deployed. - :param group_id: The management group ID. + :param group_id: The management group ID. Required. :type group_id: str - :param deployment_name: The name of the deployment. + :param deployment_name: The name of the deployment. Required. :type deployment_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: None, or the result of cls(response) + :return: None or the result of cls(response) :rtype: None - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType[None] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + 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', "2021-04-01") # type: str + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-04-01")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[None] - request = build_deployments_cancel_at_management_group_scope_request( group_id=group_id, deployment_name=deployment_name, api_version=api_version, - template_url=self.cancel_at_management_group_scope.metadata['url'], + template_url=self.cancel_at_management_group_scope.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [204]: @@ -1990,43 +2612,52 @@ async def cancel_at_management_group_scope( # pylint: disable=inconsistent-retu if cls: return cls(pipeline_response, None, {}) - cancel_at_management_group_scope.metadata = {'url': "/providers/Microsoft.Management/managementGroups/{groupId}/providers/Microsoft.Resources/deployments/{deploymentName}/cancel"} # type: ignore - + cancel_at_management_group_scope.metadata = {"url": "/providers/Microsoft.Management/managementGroups/{groupId}/providers/Microsoft.Resources/deployments/{deploymentName}/cancel"} # type: ignore async def _validate_at_management_group_scope_initial( - self, - group_id: str, - deployment_name: str, - parameters: "_models.ScopedDeployment", - **kwargs: Any - ) -> Optional["_models.DeploymentValidateResult"]: - cls = kwargs.pop('cls', None) # type: ClsType[Optional["_models.DeploymentValidateResult"]] + self, group_id: str, deployment_name: str, parameters: Union[_models.ScopedDeployment, IO], **kwargs: Any + ) -> Optional[_models.DeploymentValidateResult]: error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) - api_version = kwargs.pop('api_version', "2021-04-01") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - _json = self._serialize.body(parameters, 'ScopedDeployment') + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-04-01")) # type: str + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[Optional[_models.DeploymentValidateResult]] - request = build_deployments_validate_at_management_group_scope_request_initial( + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(parameters, (IO, bytes)): + _content = parameters + else: + _json = self._serialize.body(parameters, "ScopedDeployment") + + request = build_deployments_validate_at_management_group_scope_request( group_id=group_id, deployment_name=deployment_name, api_version=api_version, content_type=content_type, json=_json, - template_url=self._validate_at_management_group_scope_initial.metadata['url'], + content=_content, + template_url=self._validate_at_management_group_scope_initial.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200, 202, 400]: @@ -2035,36 +2666,40 @@ async def _validate_at_management_group_scope_initial( deserialized = None if response.status_code == 200: - deserialized = self._deserialize('DeploymentValidateResult', pipeline_response) + deserialized = self._deserialize("DeploymentValidateResult", pipeline_response) if response.status_code == 400: - deserialized = self._deserialize('DeploymentValidateResult', pipeline_response) + deserialized = self._deserialize("DeploymentValidateResult", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - _validate_at_management_group_scope_initial.metadata = {'url': "/providers/Microsoft.Management/managementGroups/{groupId}/providers/Microsoft.Resources/deployments/{deploymentName}/validate"} # type: ignore - + _validate_at_management_group_scope_initial.metadata = {"url": "/providers/Microsoft.Management/managementGroups/{groupId}/providers/Microsoft.Resources/deployments/{deploymentName}/validate"} # type: ignore - @distributed_trace_async + @overload async def begin_validate_at_management_group_scope( self, group_id: str, deployment_name: str, - parameters: "_models.ScopedDeployment", + parameters: _models.ScopedDeployment, + *, + content_type: str = "application/json", **kwargs: Any - ) -> AsyncLROPoller["_models.DeploymentValidateResult"]: + ) -> AsyncLROPoller[_models.DeploymentValidateResult]: """Validates whether the specified template is syntactically correct and will be accepted by Azure Resource Manager.. - :param group_id: The management group ID. + :param group_id: The management group ID. Required. :type group_id: str - :param deployment_name: The name of the deployment. + :param deployment_name: The name of the deployment. Required. :type deployment_name: str - :param parameters: Parameters to validate. + :param parameters: Parameters to validate. Required. :type parameters: ~azure.mgmt.resource.resources.v2021_04_01.models.ScopedDeployment + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str :keyword callable cls: A custom type or function that will be passed the direct response :keyword str continuation_token: A continuation token to restart a poller from a saved state. :keyword polling: By default, your polling method will be AsyncARMPolling. Pass in False for @@ -2077,85 +2712,166 @@ async def begin_validate_at_management_group_scope( result of cls(response) :rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.resource.resources.v2021_04_01.models.DeploymentValidateResult] - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - api_version = kwargs.pop('api_version', "2021-04-01") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] - polling = kwargs.pop('polling', True) # type: Union[bool, AsyncPollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType["_models.DeploymentValidateResult"] - lro_delay = kwargs.pop( - 'polling_interval', - self._config.polling_interval - ) - cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] + + @overload + async def begin_validate_at_management_group_scope( + self, + group_id: str, + deployment_name: str, + parameters: IO, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> AsyncLROPoller[_models.DeploymentValidateResult]: + """Validates whether the specified template is syntactically correct and will be accepted by Azure + Resource Manager.. + + :param group_id: The management group ID. Required. + :type group_id: str + :param deployment_name: The name of the deployment. Required. + :type deployment_name: str + :param parameters: Parameters to validate. Required. + :type parameters: IO + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be AsyncARMPolling. Pass in False for + this operation to not poll, or pass in your own initialized polling object for a personal + polling strategy. + :paramtype polling: bool or ~azure.core.polling.AsyncPollingMethod + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of AsyncLROPoller that returns either DeploymentValidateResult or the + result of cls(response) + :rtype: + ~azure.core.polling.AsyncLROPoller[~azure.mgmt.resource.resources.v2021_04_01.models.DeploymentValidateResult] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace_async + async def begin_validate_at_management_group_scope( + self, group_id: str, deployment_name: str, parameters: Union[_models.ScopedDeployment, IO], **kwargs: Any + ) -> AsyncLROPoller[_models.DeploymentValidateResult]: + """Validates whether the specified template is syntactically correct and will be accepted by Azure + Resource Manager.. + + :param group_id: The management group ID. Required. + :type group_id: str + :param deployment_name: The name of the deployment. Required. + :type deployment_name: str + :param parameters: Parameters to validate. Is either a model type or a IO type. Required. + :type parameters: ~azure.mgmt.resource.resources.v2021_04_01.models.ScopedDeployment or IO + :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. + Default value is None. + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be AsyncARMPolling. Pass in False for + this operation to not poll, or pass in your own initialized polling object for a personal + polling strategy. + :paramtype polling: bool or ~azure.core.polling.AsyncPollingMethod + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of AsyncLROPoller that returns either DeploymentValidateResult or the + result of cls(response) + :rtype: + ~azure.core.polling.AsyncLROPoller[~azure.mgmt.resource.resources.v2021_04_01.models.DeploymentValidateResult] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _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-04-01")) # type: str + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.DeploymentValidateResult] + polling = kwargs.pop("polling", True) # type: Union[bool, AsyncPollingMethod] + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token = kwargs.pop("continuation_token", None) # type: Optional[str] if cont_token is None: - raw_result = await self._validate_at_management_group_scope_initial( + raw_result = await self._validate_at_management_group_scope_initial( # type: ignore group_id=group_id, deployment_name=deployment_name, parameters=parameters, api_version=api_version, content_type=content_type, - cls=lambda x,y,z: x, + cls=lambda x, y, z: x, + headers=_headers, + params=_params, **kwargs ) - kwargs.pop('error_map', None) + kwargs.pop("error_map", None) def get_long_running_output(pipeline_response): - response = pipeline_response.http_response - deserialized = self._deserialize('DeploymentValidateResult', pipeline_response) + deserialized = self._deserialize("DeploymentValidateResult", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - - if polling is True: polling_method = AsyncARMPolling(lro_delay, **kwargs) - elif polling is False: polling_method = AsyncNoPolling() - else: polling_method = polling + if polling is True: + polling_method = cast(AsyncPollingMethod, AsyncARMPolling(lro_delay, **kwargs)) # type: AsyncPollingMethod + elif polling is False: + polling_method = cast(AsyncPollingMethod, AsyncNoPolling()) + else: + polling_method = polling if cont_token: return AsyncLROPoller.from_continuation_token( polling_method=polling_method, continuation_token=cont_token, client=self._client, - deserialization_callback=get_long_running_output + deserialization_callback=get_long_running_output, ) return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) - begin_validate_at_management_group_scope.metadata = {'url': "/providers/Microsoft.Management/managementGroups/{groupId}/providers/Microsoft.Resources/deployments/{deploymentName}/validate"} # type: ignore + begin_validate_at_management_group_scope.metadata = {"url": "/providers/Microsoft.Management/managementGroups/{groupId}/providers/Microsoft.Resources/deployments/{deploymentName}/validate"} # type: ignore async def _what_if_at_management_group_scope_initial( - self, - group_id: str, - deployment_name: str, - parameters: "_models.ScopedDeploymentWhatIf", - **kwargs: Any - ) -> Optional["_models.WhatIfOperationResult"]: - cls = kwargs.pop('cls', None) # type: ClsType[Optional["_models.WhatIfOperationResult"]] + self, group_id: str, deployment_name: str, parameters: Union[_models.ScopedDeploymentWhatIf, IO], **kwargs: Any + ) -> Optional[_models.WhatIfOperationResult]: error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', "2021-04-01") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-04-01")) # type: str + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[Optional[_models.WhatIfOperationResult]] - _json = self._serialize.body(parameters, 'ScopedDeploymentWhatIf') + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(parameters, (IO, bytes)): + _content = parameters + else: + _json = self._serialize.body(parameters, "ScopedDeploymentWhatIf") - request = build_deployments_what_if_at_management_group_scope_request_initial( + request = build_deployments_what_if_at_management_group_scope_request( group_id=group_id, deployment_name=deployment_name, api_version=api_version, content_type=content_type, json=_json, - template_url=self._what_if_at_management_group_scope_initial.metadata['url'], + content=_content, + template_url=self._what_if_at_management_group_scope_initial.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200, 202]: @@ -2165,38 +2881,41 @@ async def _what_if_at_management_group_scope_initial( deserialized = None response_headers = {} if response.status_code == 200: - deserialized = self._deserialize('WhatIfOperationResult', pipeline_response) + deserialized = self._deserialize("WhatIfOperationResult", pipeline_response) if response.status_code == 202: - response_headers['Location']=self._deserialize('str', response.headers.get('Location')) - response_headers['Retry-After']=self._deserialize('str', response.headers.get('Retry-After')) - + response_headers["Location"] = self._deserialize("str", response.headers.get("Location")) + response_headers["Retry-After"] = self._deserialize("str", response.headers.get("Retry-After")) if cls: return cls(pipeline_response, deserialized, response_headers) return deserialized - _what_if_at_management_group_scope_initial.metadata = {'url': "/providers/Microsoft.Management/managementGroups/{groupId}/providers/Microsoft.Resources/deployments/{deploymentName}/whatIf"} # type: ignore + _what_if_at_management_group_scope_initial.metadata = {"url": "/providers/Microsoft.Management/managementGroups/{groupId}/providers/Microsoft.Resources/deployments/{deploymentName}/whatIf"} # type: ignore - - @distributed_trace_async + @overload async def begin_what_if_at_management_group_scope( self, group_id: str, deployment_name: str, - parameters: "_models.ScopedDeploymentWhatIf", + parameters: _models.ScopedDeploymentWhatIf, + *, + content_type: str = "application/json", **kwargs: Any - ) -> AsyncLROPoller["_models.WhatIfOperationResult"]: + ) -> AsyncLROPoller[_models.WhatIfOperationResult]: """Returns changes that will be made by the deployment if executed at the scope of the management group. - :param group_id: The management group ID. + :param group_id: The management group ID. Required. :type group_id: str - :param deployment_name: The name of the deployment. + :param deployment_name: The name of the deployment. Required. :type deployment_name: str - :param parameters: Parameters to validate. + :param parameters: Parameters to validate. Required. :type parameters: ~azure.mgmt.resource.resources.v2021_04_01.models.ScopedDeploymentWhatIf + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str :keyword callable cls: A custom type or function that will be passed the direct response :keyword str continuation_token: A continuation token to restart a poller from a saved state. :keyword polling: By default, your polling method will be AsyncARMPolling. Pass in False for @@ -2209,119 +2928,191 @@ async def begin_what_if_at_management_group_scope( of cls(response) :rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.resource.resources.v2021_04_01.models.WhatIfOperationResult] - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - api_version = kwargs.pop('api_version', "2021-04-01") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] - polling = kwargs.pop('polling', True) # type: Union[bool, AsyncPollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType["_models.WhatIfOperationResult"] - lro_delay = kwargs.pop( - 'polling_interval', - self._config.polling_interval - ) - cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] + + @overload + async def begin_what_if_at_management_group_scope( + self, + group_id: str, + deployment_name: str, + parameters: IO, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> AsyncLROPoller[_models.WhatIfOperationResult]: + """Returns changes that will be made by the deployment if executed at the scope of the management + group. + + :param group_id: The management group ID. Required. + :type group_id: str + :param deployment_name: The name of the deployment. Required. + :type deployment_name: str + :param parameters: Parameters to validate. Required. + :type parameters: IO + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be AsyncARMPolling. Pass in False for + this operation to not poll, or pass in your own initialized polling object for a personal + polling strategy. + :paramtype polling: bool or ~azure.core.polling.AsyncPollingMethod + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of AsyncLROPoller that returns either WhatIfOperationResult or the result + of cls(response) + :rtype: + ~azure.core.polling.AsyncLROPoller[~azure.mgmt.resource.resources.v2021_04_01.models.WhatIfOperationResult] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace_async + async def begin_what_if_at_management_group_scope( + self, group_id: str, deployment_name: str, parameters: Union[_models.ScopedDeploymentWhatIf, IO], **kwargs: Any + ) -> AsyncLROPoller[_models.WhatIfOperationResult]: + """Returns changes that will be made by the deployment if executed at the scope of the management + group. + + :param group_id: The management group ID. Required. + :type group_id: str + :param deployment_name: The name of the deployment. Required. + :type deployment_name: str + :param parameters: Parameters to validate. Is either a model type or a IO type. Required. + :type parameters: ~azure.mgmt.resource.resources.v2021_04_01.models.ScopedDeploymentWhatIf or + IO + :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. + Default value is None. + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be AsyncARMPolling. Pass in False for + this operation to not poll, or pass in your own initialized polling object for a personal + polling strategy. + :paramtype polling: bool or ~azure.core.polling.AsyncPollingMethod + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of AsyncLROPoller that returns either WhatIfOperationResult or the result + of cls(response) + :rtype: + ~azure.core.polling.AsyncLROPoller[~azure.mgmt.resource.resources.v2021_04_01.models.WhatIfOperationResult] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _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-04-01")) # type: str + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.WhatIfOperationResult] + polling = kwargs.pop("polling", True) # type: Union[bool, AsyncPollingMethod] + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token = kwargs.pop("continuation_token", None) # type: Optional[str] if cont_token is None: - raw_result = await self._what_if_at_management_group_scope_initial( + raw_result = await self._what_if_at_management_group_scope_initial( # type: ignore group_id=group_id, deployment_name=deployment_name, parameters=parameters, api_version=api_version, content_type=content_type, - cls=lambda x,y,z: x, + cls=lambda x, y, z: x, + headers=_headers, + params=_params, **kwargs ) - kwargs.pop('error_map', None) + kwargs.pop("error_map", None) def get_long_running_output(pipeline_response): - response = pipeline_response.http_response - deserialized = self._deserialize('WhatIfOperationResult', pipeline_response) + deserialized = self._deserialize("WhatIfOperationResult", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - - if polling is True: polling_method = AsyncARMPolling(lro_delay, lro_options={'final-state-via': 'location'}, **kwargs) - elif polling is False: polling_method = AsyncNoPolling() - else: polling_method = polling + if polling is True: + polling_method = cast( + AsyncPollingMethod, AsyncARMPolling(lro_delay, lro_options={"final-state-via": "location"}, **kwargs) + ) # type: AsyncPollingMethod + elif polling is False: + polling_method = cast(AsyncPollingMethod, AsyncNoPolling()) + else: + polling_method = polling if cont_token: return AsyncLROPoller.from_continuation_token( polling_method=polling_method, continuation_token=cont_token, client=self._client, - deserialization_callback=get_long_running_output + deserialization_callback=get_long_running_output, ) return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) - begin_what_if_at_management_group_scope.metadata = {'url': "/providers/Microsoft.Management/managementGroups/{groupId}/providers/Microsoft.Resources/deployments/{deploymentName}/whatIf"} # type: ignore + begin_what_if_at_management_group_scope.metadata = {"url": "/providers/Microsoft.Management/managementGroups/{groupId}/providers/Microsoft.Resources/deployments/{deploymentName}/whatIf"} # type: ignore @distributed_trace_async async def export_template_at_management_group_scope( - self, - group_id: str, - deployment_name: str, - **kwargs: Any - ) -> "_models.DeploymentExportResult": + self, group_id: str, deployment_name: str, **kwargs: Any + ) -> _models.DeploymentExportResult: """Exports the template used for specified deployment. - :param group_id: The management group ID. + :param group_id: The management group ID. Required. :type group_id: str - :param deployment_name: The name of the deployment. + :param deployment_name: The name of the deployment. Required. :type deployment_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: DeploymentExportResult, or the result of cls(response) + :return: DeploymentExportResult or the result of cls(response) :rtype: ~azure.mgmt.resource.resources.v2021_04_01.models.DeploymentExportResult - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.DeploymentExportResult"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) - api_version = kwargs.pop('api_version', "2021-04-01") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-04-01")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[_models.DeploymentExportResult] - request = build_deployments_export_template_at_management_group_scope_request( group_id=group_id, deployment_name=deployment_name, api_version=api_version, - template_url=self.export_template_at_management_group_scope.metadata['url'], + template_url=self.export_template_at_management_group_scope.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) - deserialized = self._deserialize('DeploymentExportResult', pipeline_response) + deserialized = self._deserialize("DeploymentExportResult", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - export_template_at_management_group_scope.metadata = {'url': "/providers/Microsoft.Management/managementGroups/{groupId}/providers/Microsoft.Resources/deployments/{deploymentName}/exportTemplate"} # type: ignore - + export_template_at_management_group_scope.metadata = {"url": "/providers/Microsoft.Management/managementGroups/{groupId}/providers/Microsoft.Resources/deployments/{deploymentName}/exportTemplate"} # type: ignore @distributed_trace def list_at_management_group_scope( - self, - group_id: str, - filter: Optional[str] = None, - top: Optional[int] = None, - **kwargs: Any - ) -> AsyncIterable["_models.DeploymentListResult"]: + self, group_id: str, filter: Optional[str] = None, top: Optional[int] = None, **kwargs: Any + ) -> AsyncIterable["_models.DeploymentExtended"]: """Get all the deployments for a management group. - :param group_id: The management group ID. + :param group_id: The management group ID. Required. :type group_id: str :param filter: The filter to apply on the operation. For example, you can use $filter=provisioningState eq '{state}'. Default value is None. @@ -2330,40 +3121,48 @@ def list_at_management_group_scope( value is None. :type top: int :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either DeploymentListResult or the result of - cls(response) + :return: An iterator like instance of either DeploymentExtended or the result of cls(response) :rtype: - ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.resource.resources.v2021_04_01.models.DeploymentListResult] - :raises: ~azure.core.exceptions.HttpResponseError + ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.resource.resources.v2021_04_01.models.DeploymentExtended] + :raises ~azure.core.exceptions.HttpResponseError: """ - api_version = kwargs.pop('api_version', "2021-04-01") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-04-01")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[_models.DeploymentListResult] - cls = kwargs.pop('cls', None) # type: ClsType["_models.DeploymentListResult"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) + def prepare_request(next_link=None): if not next_link: - + request = build_deployments_list_at_management_group_scope_request( group_id=group_id, - api_version=api_version, filter=filter, top=top, - template_url=self.list_at_management_group_scope.metadata['url'], + api_version=api_version, + template_url=self.list_at_management_group_scope.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore else: - - request = build_deployments_list_at_management_group_scope_request( - group_id=group_id, - template_url=next_link, - ) + # make call to next link with the client's api-version + _parsed_next_link = urlparse(next_link) + _next_request_params = case_insensitive_dict(parse_qs(_parsed_next_link.query)) + _next_request_params["api-version"] = self._config.api_version + request = HttpRequest("GET", urljoin(next_link, _parsed_next_link.path), params=_next_request_params) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore request.method = "GET" return request @@ -2377,10 +3176,8 @@ async def extract_data(pipeline_response): async def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) response = pipeline_response.http_response @@ -2390,40 +3187,42 @@ async def get_next(next_link=None): return pipeline_response + return AsyncItemPaged(get_next, extract_data) - return AsyncItemPaged( - get_next, extract_data - ) - list_at_management_group_scope.metadata = {'url': "/providers/Microsoft.Management/managementGroups/{groupId}/providers/Microsoft.Resources/deployments/"} # type: ignore + list_at_management_group_scope.metadata = {"url": "/providers/Microsoft.Management/managementGroups/{groupId}/providers/Microsoft.Resources/deployments/"} # type: ignore async def _delete_at_subscription_scope_initial( # pylint: disable=inconsistent-return-statements - self, - deployment_name: str, - **kwargs: Any + self, deployment_name: str, **kwargs: Any ) -> None: - cls = kwargs.pop('cls', None) # type: ClsType[None] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) - api_version = kwargs.pop('api_version', "2021-04-01") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - request = build_deployments_delete_at_subscription_scope_request_initial( + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-04-01")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[None] + + request = build_deployments_delete_at_subscription_scope_request( deployment_name=deployment_name, subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self._delete_at_subscription_scope_initial.metadata['url'], + template_url=self._delete_at_subscription_scope_initial.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [202, 204]: @@ -2433,15 +3232,10 @@ async def _delete_at_subscription_scope_initial( # pylint: disable=inconsistent if cls: return cls(pipeline_response, None, {}) - _delete_at_subscription_scope_initial.metadata = {'url': "/subscriptions/{subscriptionId}/providers/Microsoft.Resources/deployments/{deploymentName}"} # type: ignore - + _delete_at_subscription_scope_initial.metadata = {"url": "/subscriptions/{subscriptionId}/providers/Microsoft.Resources/deployments/{deploymentName}"} # type: ignore @distributed_trace_async - async def begin_delete_at_subscription_scope( # pylint: disable=inconsistent-return-statements - self, - deployment_name: str, - **kwargs: Any - ) -> AsyncLROPoller[None]: + async def begin_delete_at_subscription_scope(self, deployment_name: str, **kwargs: Any) -> AsyncLROPoller[None]: """Deletes a deployment from the deployment history. A template deployment that is currently running cannot be deleted. Deleting a template @@ -2452,7 +3246,7 @@ async def begin_delete_at_subscription_scope( # pylint: disable=inconsistent-re process finishes, the URI in the Location header returns a status of 204 on success. If the asynchronous request failed, the URI in the Location header returns an error-level status code. - :param deployment_name: The name of the deployment. + :param deployment_name: The name of the deployment. Required. :type deployment_name: str :keyword callable cls: A custom type or function that will be passed the direct response :keyword str continuation_token: A continuation token to restart a poller from a saved state. @@ -2464,82 +3258,88 @@ async def begin_delete_at_subscription_scope( # pylint: disable=inconsistent-re Retry-After header is present. :return: An instance of AsyncLROPoller that returns either None or the result of cls(response) :rtype: ~azure.core.polling.AsyncLROPoller[None] - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - api_version = kwargs.pop('api_version', "2021-04-01") # type: str - polling = kwargs.pop('polling', True) # type: Union[bool, AsyncPollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType[None] - lro_delay = kwargs.pop( - 'polling_interval', - self._config.polling_interval - ) - cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-04-01")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[None] + polling = kwargs.pop("polling", True) # type: Union[bool, AsyncPollingMethod] + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token = kwargs.pop("continuation_token", None) # type: Optional[str] if cont_token is None: - raw_result = await self._delete_at_subscription_scope_initial( + raw_result = await self._delete_at_subscription_scope_initial( # type: ignore deployment_name=deployment_name, api_version=api_version, - cls=lambda x,y,z: x, + cls=lambda x, y, z: x, + headers=_headers, + params=_params, **kwargs ) - kwargs.pop('error_map', None) + kwargs.pop("error_map", None) - def get_long_running_output(pipeline_response): + def get_long_running_output(pipeline_response): # pylint: disable=inconsistent-return-statements if cls: return cls(pipeline_response, None, {}) - - if polling is True: polling_method = AsyncARMPolling(lro_delay, **kwargs) - elif polling is False: polling_method = AsyncNoPolling() - else: polling_method = polling + if polling is True: + polling_method = cast(AsyncPollingMethod, AsyncARMPolling(lro_delay, **kwargs)) # type: AsyncPollingMethod + elif polling is False: + polling_method = cast(AsyncPollingMethod, AsyncNoPolling()) + else: + polling_method = polling if cont_token: return AsyncLROPoller.from_continuation_token( polling_method=polling_method, continuation_token=cont_token, client=self._client, - deserialization_callback=get_long_running_output + deserialization_callback=get_long_running_output, ) return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) - begin_delete_at_subscription_scope.metadata = {'url': "/subscriptions/{subscriptionId}/providers/Microsoft.Resources/deployments/{deploymentName}"} # type: ignore + begin_delete_at_subscription_scope.metadata = {"url": "/subscriptions/{subscriptionId}/providers/Microsoft.Resources/deployments/{deploymentName}"} # type: ignore @distributed_trace_async - async def check_existence_at_subscription_scope( - self, - deployment_name: str, - **kwargs: Any - ) -> bool: + async def check_existence_at_subscription_scope(self, deployment_name: str, **kwargs: Any) -> bool: """Checks whether the deployment exists. - :param deployment_name: The name of the deployment. + :param deployment_name: The name of the deployment. Required. :type deployment_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: bool, or the result of cls(response) + :return: bool or the result of cls(response) :rtype: bool - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType[None] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + 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', "2021-04-01") # type: str + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-04-01")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[None] - request = build_deployments_check_existence_at_subscription_scope_request( deployment_name=deployment_name, subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.check_existence_at_subscription_scope.metadata['url'], + template_url=self.check_existence_at_subscription_scope.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [204, 404]: @@ -2550,42 +3350,52 @@ async def check_existence_at_subscription_scope( return cls(pipeline_response, None, {}) return 200 <= response.status_code <= 299 - check_existence_at_subscription_scope.metadata = {'url': "/subscriptions/{subscriptionId}/providers/Microsoft.Resources/deployments/{deploymentName}"} # type: ignore - + check_existence_at_subscription_scope.metadata = {"url": "/subscriptions/{subscriptionId}/providers/Microsoft.Resources/deployments/{deploymentName}"} # type: ignore async def _create_or_update_at_subscription_scope_initial( - self, - deployment_name: str, - parameters: "_models.Deployment", - **kwargs: Any - ) -> "_models.DeploymentExtended": - cls = kwargs.pop('cls', None) # type: ClsType["_models.DeploymentExtended"] + self, deployment_name: str, parameters: Union[_models.Deployment, IO], **kwargs: Any + ) -> _models.DeploymentExtended: error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', "2021-04-01") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-04-01")) # type: str + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.DeploymentExtended] - _json = self._serialize.body(parameters, 'Deployment') + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(parameters, (IO, bytes)): + _content = parameters + else: + _json = self._serialize.body(parameters, "Deployment") - request = build_deployments_create_or_update_at_subscription_scope_request_initial( + request = build_deployments_create_or_update_at_subscription_scope_request( deployment_name=deployment_name, subscription_id=self._config.subscription_id, api_version=api_version, content_type=content_type, json=_json, - template_url=self._create_or_update_at_subscription_scope_initial.metadata['url'], + content=_content, + template_url=self._create_or_update_at_subscription_scope_initial.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200, 201]: @@ -2593,34 +3403,38 @@ async def _create_or_update_at_subscription_scope_initial( raise HttpResponseError(response=response, error_format=ARMErrorFormat) if response.status_code == 200: - deserialized = self._deserialize('DeploymentExtended', pipeline_response) + deserialized = self._deserialize("DeploymentExtended", pipeline_response) if response.status_code == 201: - deserialized = self._deserialize('DeploymentExtended', pipeline_response) + deserialized = self._deserialize("DeploymentExtended", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - _create_or_update_at_subscription_scope_initial.metadata = {'url': "/subscriptions/{subscriptionId}/providers/Microsoft.Resources/deployments/{deploymentName}"} # type: ignore + _create_or_update_at_subscription_scope_initial.metadata = {"url": "/subscriptions/{subscriptionId}/providers/Microsoft.Resources/deployments/{deploymentName}"} # type: ignore - - @distributed_trace_async + @overload async def begin_create_or_update_at_subscription_scope( self, deployment_name: str, - parameters: "_models.Deployment", + parameters: _models.Deployment, + *, + content_type: str = "application/json", **kwargs: Any - ) -> AsyncLROPoller["_models.DeploymentExtended"]: + ) -> AsyncLROPoller[_models.DeploymentExtended]: """Deploys resources at subscription scope. You can provide the template and parameters directly in the request or link to JSON files. - :param deployment_name: The name of the deployment. + :param deployment_name: The name of the deployment. Required. :type deployment_name: str - :param parameters: Additional parameters supplied to the operation. + :param parameters: Additional parameters supplied to the operation. Required. :type parameters: ~azure.mgmt.resource.resources.v2021_04_01.models.Deployment + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str :keyword callable cls: A custom type or function that will be passed the direct response :keyword str continuation_token: A continuation token to restart a poller from a saved state. :keyword polling: By default, your polling method will be AsyncARMPolling. Pass in False for @@ -2633,109 +3447,172 @@ async def begin_create_or_update_at_subscription_scope( cls(response) :rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.resource.resources.v2021_04_01.models.DeploymentExtended] - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - api_version = kwargs.pop('api_version', "2021-04-01") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] - polling = kwargs.pop('polling', True) # type: Union[bool, AsyncPollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType["_models.DeploymentExtended"] - lro_delay = kwargs.pop( - 'polling_interval', - self._config.polling_interval - ) - cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] - if cont_token is None: - raw_result = await self._create_or_update_at_subscription_scope_initial( - deployment_name=deployment_name, - parameters=parameters, - api_version=api_version, - content_type=content_type, - cls=lambda x,y,z: x, - **kwargs - ) - kwargs.pop('error_map', None) - - def get_long_running_output(pipeline_response): - response = pipeline_response.http_response - deserialized = self._deserialize('DeploymentExtended', pipeline_response) - if cls: - return cls(pipeline_response, deserialized, {}) - return deserialized + @overload + async def begin_create_or_update_at_subscription_scope( + self, deployment_name: str, parameters: IO, *, content_type: str = "application/json", **kwargs: Any + ) -> AsyncLROPoller[_models.DeploymentExtended]: + """Deploys resources at subscription scope. + + You can provide the template and parameters directly in the request or link to JSON files. + + :param deployment_name: The name of the deployment. Required. + :type deployment_name: str + :param parameters: Additional parameters supplied to the operation. Required. + :type parameters: IO + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be AsyncARMPolling. Pass in False for + this operation to not poll, or pass in your own initialized polling object for a personal + polling strategy. + :paramtype polling: bool or ~azure.core.polling.AsyncPollingMethod + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of AsyncLROPoller that returns either DeploymentExtended or the result of + cls(response) + :rtype: + ~azure.core.polling.AsyncLROPoller[~azure.mgmt.resource.resources.v2021_04_01.models.DeploymentExtended] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace_async + async def begin_create_or_update_at_subscription_scope( + self, deployment_name: str, parameters: Union[_models.Deployment, IO], **kwargs: Any + ) -> AsyncLROPoller[_models.DeploymentExtended]: + """Deploys resources at subscription scope. + + You can provide the template and parameters directly in the request or link to JSON files. + + :param deployment_name: The name of the deployment. Required. + :type deployment_name: str + :param parameters: Additional parameters supplied to the operation. Is either a model type or a + IO type. Required. + :type parameters: ~azure.mgmt.resource.resources.v2021_04_01.models.Deployment or IO + :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. + Default value is None. + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be AsyncARMPolling. Pass in False for + this operation to not poll, or pass in your own initialized polling object for a personal + polling strategy. + :paramtype polling: bool or ~azure.core.polling.AsyncPollingMethod + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of AsyncLROPoller that returns either DeploymentExtended or the result of + cls(response) + :rtype: + ~azure.core.polling.AsyncLROPoller[~azure.mgmt.resource.resources.v2021_04_01.models.DeploymentExtended] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _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-04-01")) # type: str + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.DeploymentExtended] + polling = kwargs.pop("polling", True) # type: Union[bool, AsyncPollingMethod] + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token = kwargs.pop("continuation_token", None) # type: Optional[str] + if cont_token is None: + raw_result = await self._create_or_update_at_subscription_scope_initial( # type: ignore + deployment_name=deployment_name, + parameters=parameters, + api_version=api_version, + content_type=content_type, + cls=lambda x, y, z: x, + headers=_headers, + params=_params, + **kwargs + ) + kwargs.pop("error_map", None) - if polling is True: polling_method = AsyncARMPolling(lro_delay, **kwargs) - elif polling is False: polling_method = AsyncNoPolling() - else: polling_method = polling + def get_long_running_output(pipeline_response): + deserialized = self._deserialize("DeploymentExtended", pipeline_response) + if cls: + return cls(pipeline_response, deserialized, {}) + return deserialized + + if polling is True: + polling_method = cast(AsyncPollingMethod, AsyncARMPolling(lro_delay, **kwargs)) # type: AsyncPollingMethod + elif polling is False: + polling_method = cast(AsyncPollingMethod, AsyncNoPolling()) + else: + polling_method = polling if cont_token: return AsyncLROPoller.from_continuation_token( polling_method=polling_method, continuation_token=cont_token, client=self._client, - deserialization_callback=get_long_running_output + deserialization_callback=get_long_running_output, ) return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) - begin_create_or_update_at_subscription_scope.metadata = {'url': "/subscriptions/{subscriptionId}/providers/Microsoft.Resources/deployments/{deploymentName}"} # type: ignore + begin_create_or_update_at_subscription_scope.metadata = {"url": "/subscriptions/{subscriptionId}/providers/Microsoft.Resources/deployments/{deploymentName}"} # type: ignore @distributed_trace_async - async def get_at_subscription_scope( - self, - deployment_name: str, - **kwargs: Any - ) -> "_models.DeploymentExtended": + async def get_at_subscription_scope(self, deployment_name: str, **kwargs: Any) -> _models.DeploymentExtended: """Gets a deployment. - :param deployment_name: The name of the deployment. + :param deployment_name: The name of the deployment. Required. :type deployment_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: DeploymentExtended, or the result of cls(response) + :return: DeploymentExtended or the result of cls(response) :rtype: ~azure.mgmt.resource.resources.v2021_04_01.models.DeploymentExtended - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.DeploymentExtended"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) - api_version = kwargs.pop('api_version', "2021-04-01") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-04-01")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[_models.DeploymentExtended] - request = build_deployments_get_at_subscription_scope_request( deployment_name=deployment_name, subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.get_at_subscription_scope.metadata['url'], + template_url=self.get_at_subscription_scope.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) - deserialized = self._deserialize('DeploymentExtended', pipeline_response) + deserialized = self._deserialize("DeploymentExtended", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - get_at_subscription_scope.metadata = {'url': "/subscriptions/{subscriptionId}/providers/Microsoft.Resources/deployments/{deploymentName}"} # type: ignore - + get_at_subscription_scope.metadata = {"url": "/subscriptions/{subscriptionId}/providers/Microsoft.Resources/deployments/{deploymentName}"} # type: ignore @distributed_trace_async async def cancel_at_subscription_scope( # pylint: disable=inconsistent-return-statements - self, - deployment_name: str, - **kwargs: Any + self, deployment_name: str, **kwargs: Any ) -> None: """Cancels a currently running template deployment. @@ -2744,36 +3621,42 @@ async def cancel_at_subscription_scope( # pylint: disable=inconsistent-return-s deployment stops the currently running template deployment and leaves the resources partially deployed. - :param deployment_name: The name of the deployment. + :param deployment_name: The name of the deployment. Required. :type deployment_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: None, or the result of cls(response) + :return: None or the result of cls(response) :rtype: None - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType[None] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) - api_version = kwargs.pop('api_version', "2021-04-01") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-04-01")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[None] - request = build_deployments_cancel_at_subscription_scope_request( deployment_name=deployment_name, subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.cancel_at_subscription_scope.metadata['url'], + template_url=self.cancel_at_subscription_scope.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [204]: @@ -2783,42 +3666,52 @@ async def cancel_at_subscription_scope( # pylint: disable=inconsistent-return-s if cls: return cls(pipeline_response, None, {}) - cancel_at_subscription_scope.metadata = {'url': "/subscriptions/{subscriptionId}/providers/Microsoft.Resources/deployments/{deploymentName}/cancel"} # type: ignore - + cancel_at_subscription_scope.metadata = {"url": "/subscriptions/{subscriptionId}/providers/Microsoft.Resources/deployments/{deploymentName}/cancel"} # type: ignore async def _validate_at_subscription_scope_initial( - self, - deployment_name: str, - parameters: "_models.Deployment", - **kwargs: Any - ) -> Optional["_models.DeploymentValidateResult"]: - cls = kwargs.pop('cls', None) # type: ClsType[Optional["_models.DeploymentValidateResult"]] + self, deployment_name: str, parameters: Union[_models.Deployment, IO], **kwargs: Any + ) -> Optional[_models.DeploymentValidateResult]: error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) - api_version = kwargs.pop('api_version', "2021-04-01") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - _json = self._serialize.body(parameters, 'Deployment') + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-04-01")) # type: str + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[Optional[_models.DeploymentValidateResult]] + + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(parameters, (IO, bytes)): + _content = parameters + else: + _json = self._serialize.body(parameters, "Deployment") - request = build_deployments_validate_at_subscription_scope_request_initial( + request = build_deployments_validate_at_subscription_scope_request( deployment_name=deployment_name, subscription_id=self._config.subscription_id, api_version=api_version, content_type=content_type, json=_json, - template_url=self._validate_at_subscription_scope_initial.metadata['url'], + content=_content, + template_url=self._validate_at_subscription_scope_initial.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200, 202, 400]: @@ -2827,33 +3720,37 @@ async def _validate_at_subscription_scope_initial( deserialized = None if response.status_code == 200: - deserialized = self._deserialize('DeploymentValidateResult', pipeline_response) + deserialized = self._deserialize("DeploymentValidateResult", pipeline_response) if response.status_code == 400: - deserialized = self._deserialize('DeploymentValidateResult', pipeline_response) + deserialized = self._deserialize("DeploymentValidateResult", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - _validate_at_subscription_scope_initial.metadata = {'url': "/subscriptions/{subscriptionId}/providers/Microsoft.Resources/deployments/{deploymentName}/validate"} # type: ignore - + _validate_at_subscription_scope_initial.metadata = {"url": "/subscriptions/{subscriptionId}/providers/Microsoft.Resources/deployments/{deploymentName}/validate"} # type: ignore - @distributed_trace_async + @overload async def begin_validate_at_subscription_scope( self, deployment_name: str, - parameters: "_models.Deployment", + parameters: _models.Deployment, + *, + content_type: str = "application/json", **kwargs: Any - ) -> AsyncLROPoller["_models.DeploymentValidateResult"]: + ) -> AsyncLROPoller[_models.DeploymentValidateResult]: """Validates whether the specified template is syntactically correct and will be accepted by Azure Resource Manager.. - :param deployment_name: The name of the deployment. + :param deployment_name: The name of the deployment. Required. :type deployment_name: str - :param parameters: Parameters to validate. + :param parameters: Parameters to validate. Required. :type parameters: ~azure.mgmt.resource.resources.v2021_04_01.models.Deployment + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str :keyword callable cls: A custom type or function that will be passed the direct response :keyword str continuation_token: A continuation token to restart a poller from a saved state. :keyword polling: By default, your polling method will be AsyncARMPolling. Pass in False for @@ -2866,83 +3763,155 @@ async def begin_validate_at_subscription_scope( result of cls(response) :rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.resource.resources.v2021_04_01.models.DeploymentValidateResult] - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - api_version = kwargs.pop('api_version', "2021-04-01") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] - polling = kwargs.pop('polling', True) # type: Union[bool, AsyncPollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType["_models.DeploymentValidateResult"] - lro_delay = kwargs.pop( - 'polling_interval', - self._config.polling_interval - ) - cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] + + @overload + async def begin_validate_at_subscription_scope( + self, deployment_name: str, parameters: IO, *, content_type: str = "application/json", **kwargs: Any + ) -> AsyncLROPoller[_models.DeploymentValidateResult]: + """Validates whether the specified template is syntactically correct and will be accepted by Azure + Resource Manager.. + + :param deployment_name: The name of the deployment. Required. + :type deployment_name: str + :param parameters: Parameters to validate. Required. + :type parameters: IO + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be AsyncARMPolling. Pass in False for + this operation to not poll, or pass in your own initialized polling object for a personal + polling strategy. + :paramtype polling: bool or ~azure.core.polling.AsyncPollingMethod + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of AsyncLROPoller that returns either DeploymentValidateResult or the + result of cls(response) + :rtype: + ~azure.core.polling.AsyncLROPoller[~azure.mgmt.resource.resources.v2021_04_01.models.DeploymentValidateResult] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace_async + async def begin_validate_at_subscription_scope( + self, deployment_name: str, parameters: Union[_models.Deployment, IO], **kwargs: Any + ) -> AsyncLROPoller[_models.DeploymentValidateResult]: + """Validates whether the specified template is syntactically correct and will be accepted by Azure + Resource Manager.. + + :param deployment_name: The name of the deployment. Required. + :type deployment_name: str + :param parameters: Parameters to validate. Is either a model type or a IO type. Required. + :type parameters: ~azure.mgmt.resource.resources.v2021_04_01.models.Deployment or IO + :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. + Default value is None. + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be AsyncARMPolling. Pass in False for + this operation to not poll, or pass in your own initialized polling object for a personal + polling strategy. + :paramtype polling: bool or ~azure.core.polling.AsyncPollingMethod + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of AsyncLROPoller that returns either DeploymentValidateResult or the + result of cls(response) + :rtype: + ~azure.core.polling.AsyncLROPoller[~azure.mgmt.resource.resources.v2021_04_01.models.DeploymentValidateResult] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _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-04-01")) # type: str + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.DeploymentValidateResult] + polling = kwargs.pop("polling", True) # type: Union[bool, AsyncPollingMethod] + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token = kwargs.pop("continuation_token", None) # type: Optional[str] if cont_token is None: - raw_result = await self._validate_at_subscription_scope_initial( + raw_result = await self._validate_at_subscription_scope_initial( # type: ignore deployment_name=deployment_name, parameters=parameters, api_version=api_version, content_type=content_type, - cls=lambda x,y,z: x, + cls=lambda x, y, z: x, + headers=_headers, + params=_params, **kwargs ) - kwargs.pop('error_map', None) + kwargs.pop("error_map", None) def get_long_running_output(pipeline_response): - response = pipeline_response.http_response - deserialized = self._deserialize('DeploymentValidateResult', pipeline_response) + deserialized = self._deserialize("DeploymentValidateResult", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - - if polling is True: polling_method = AsyncARMPolling(lro_delay, **kwargs) - elif polling is False: polling_method = AsyncNoPolling() - else: polling_method = polling + if polling is True: + polling_method = cast(AsyncPollingMethod, AsyncARMPolling(lro_delay, **kwargs)) # type: AsyncPollingMethod + elif polling is False: + polling_method = cast(AsyncPollingMethod, AsyncNoPolling()) + else: + polling_method = polling if cont_token: return AsyncLROPoller.from_continuation_token( polling_method=polling_method, continuation_token=cont_token, client=self._client, - deserialization_callback=get_long_running_output + deserialization_callback=get_long_running_output, ) return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) - begin_validate_at_subscription_scope.metadata = {'url': "/subscriptions/{subscriptionId}/providers/Microsoft.Resources/deployments/{deploymentName}/validate"} # type: ignore + begin_validate_at_subscription_scope.metadata = {"url": "/subscriptions/{subscriptionId}/providers/Microsoft.Resources/deployments/{deploymentName}/validate"} # type: ignore async def _what_if_at_subscription_scope_initial( - self, - deployment_name: str, - parameters: "_models.DeploymentWhatIf", - **kwargs: Any - ) -> Optional["_models.WhatIfOperationResult"]: - cls = kwargs.pop('cls', None) # type: ClsType[Optional["_models.WhatIfOperationResult"]] + self, deployment_name: str, parameters: Union[_models.DeploymentWhatIf, IO], **kwargs: Any + ) -> Optional[_models.WhatIfOperationResult]: error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) - api_version = kwargs.pop('api_version', "2021-04-01") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - _json = self._serialize.body(parameters, 'DeploymentWhatIf') + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-04-01")) # type: str + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[Optional[_models.WhatIfOperationResult]] + + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(parameters, (IO, bytes)): + _content = parameters + else: + _json = self._serialize.body(parameters, "DeploymentWhatIf") - request = build_deployments_what_if_at_subscription_scope_request_initial( + request = build_deployments_what_if_at_subscription_scope_request( deployment_name=deployment_name, subscription_id=self._config.subscription_id, api_version=api_version, content_type=content_type, json=_json, - template_url=self._what_if_at_subscription_scope_initial.metadata['url'], + content=_content, + template_url=self._what_if_at_subscription_scope_initial.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200, 202]: @@ -2952,35 +3921,38 @@ async def _what_if_at_subscription_scope_initial( deserialized = None response_headers = {} if response.status_code == 200: - deserialized = self._deserialize('WhatIfOperationResult', pipeline_response) + deserialized = self._deserialize("WhatIfOperationResult", pipeline_response) if response.status_code == 202: - response_headers['Location']=self._deserialize('str', response.headers.get('Location')) - response_headers['Retry-After']=self._deserialize('str', response.headers.get('Retry-After')) - + response_headers["Location"] = self._deserialize("str", response.headers.get("Location")) + response_headers["Retry-After"] = self._deserialize("str", response.headers.get("Retry-After")) if cls: return cls(pipeline_response, deserialized, response_headers) return deserialized - _what_if_at_subscription_scope_initial.metadata = {'url': "/subscriptions/{subscriptionId}/providers/Microsoft.Resources/deployments/{deploymentName}/whatIf"} # type: ignore - + _what_if_at_subscription_scope_initial.metadata = {"url": "/subscriptions/{subscriptionId}/providers/Microsoft.Resources/deployments/{deploymentName}/whatIf"} # type: ignore - @distributed_trace_async + @overload async def begin_what_if_at_subscription_scope( self, deployment_name: str, - parameters: "_models.DeploymentWhatIf", + parameters: _models.DeploymentWhatIf, + *, + content_type: str = "application/json", **kwargs: Any - ) -> AsyncLROPoller["_models.WhatIfOperationResult"]: + ) -> AsyncLROPoller[_models.WhatIfOperationResult]: """Returns changes that will be made by the deployment if executed at the scope of the subscription. - :param deployment_name: The name of the deployment. + :param deployment_name: The name of the deployment. Required. :type deployment_name: str - :param parameters: Parameters to What If. + :param parameters: Parameters to What If. Required. :type parameters: ~azure.mgmt.resource.resources.v2021_04_01.models.DeploymentWhatIf + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str :keyword callable cls: A custom type or function that will be passed the direct response :keyword str continuation_token: A continuation token to restart a poller from a saved state. :keyword polling: By default, your polling method will be AsyncARMPolling. Pass in False for @@ -2993,111 +3965,174 @@ async def begin_what_if_at_subscription_scope( of cls(response) :rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.resource.resources.v2021_04_01.models.WhatIfOperationResult] - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - api_version = kwargs.pop('api_version', "2021-04-01") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] - polling = kwargs.pop('polling', True) # type: Union[bool, AsyncPollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType["_models.WhatIfOperationResult"] - lro_delay = kwargs.pop( - 'polling_interval', - self._config.polling_interval - ) - cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] + + @overload + async def begin_what_if_at_subscription_scope( + self, deployment_name: str, parameters: IO, *, content_type: str = "application/json", **kwargs: Any + ) -> AsyncLROPoller[_models.WhatIfOperationResult]: + """Returns changes that will be made by the deployment if executed at the scope of the + subscription. + + :param deployment_name: The name of the deployment. Required. + :type deployment_name: str + :param parameters: Parameters to What If. Required. + :type parameters: IO + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be AsyncARMPolling. Pass in False for + this operation to not poll, or pass in your own initialized polling object for a personal + polling strategy. + :paramtype polling: bool or ~azure.core.polling.AsyncPollingMethod + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of AsyncLROPoller that returns either WhatIfOperationResult or the result + of cls(response) + :rtype: + ~azure.core.polling.AsyncLROPoller[~azure.mgmt.resource.resources.v2021_04_01.models.WhatIfOperationResult] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace_async + async def begin_what_if_at_subscription_scope( + self, deployment_name: str, parameters: Union[_models.DeploymentWhatIf, IO], **kwargs: Any + ) -> AsyncLROPoller[_models.WhatIfOperationResult]: + """Returns changes that will be made by the deployment if executed at the scope of the + subscription. + + :param deployment_name: The name of the deployment. Required. + :type deployment_name: str + :param parameters: Parameters to What If. Is either a model type or a IO type. Required. + :type parameters: ~azure.mgmt.resource.resources.v2021_04_01.models.DeploymentWhatIf or IO + :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. + Default value is None. + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be AsyncARMPolling. Pass in False for + this operation to not poll, or pass in your own initialized polling object for a personal + polling strategy. + :paramtype polling: bool or ~azure.core.polling.AsyncPollingMethod + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of AsyncLROPoller that returns either WhatIfOperationResult or the result + of cls(response) + :rtype: + ~azure.core.polling.AsyncLROPoller[~azure.mgmt.resource.resources.v2021_04_01.models.WhatIfOperationResult] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _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-04-01")) # type: str + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.WhatIfOperationResult] + polling = kwargs.pop("polling", True) # type: Union[bool, AsyncPollingMethod] + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token = kwargs.pop("continuation_token", None) # type: Optional[str] if cont_token is None: - raw_result = await self._what_if_at_subscription_scope_initial( + raw_result = await self._what_if_at_subscription_scope_initial( # type: ignore deployment_name=deployment_name, parameters=parameters, api_version=api_version, content_type=content_type, - cls=lambda x,y,z: x, + cls=lambda x, y, z: x, + headers=_headers, + params=_params, **kwargs ) - kwargs.pop('error_map', None) + kwargs.pop("error_map", None) def get_long_running_output(pipeline_response): - response = pipeline_response.http_response - deserialized = self._deserialize('WhatIfOperationResult', pipeline_response) + deserialized = self._deserialize("WhatIfOperationResult", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - - if polling is True: polling_method = AsyncARMPolling(lro_delay, lro_options={'final-state-via': 'location'}, **kwargs) - elif polling is False: polling_method = AsyncNoPolling() - else: polling_method = polling + if polling is True: + polling_method = cast( + AsyncPollingMethod, AsyncARMPolling(lro_delay, lro_options={"final-state-via": "location"}, **kwargs) + ) # type: AsyncPollingMethod + elif polling is False: + polling_method = cast(AsyncPollingMethod, AsyncNoPolling()) + else: + polling_method = polling if cont_token: return AsyncLROPoller.from_continuation_token( polling_method=polling_method, continuation_token=cont_token, client=self._client, - deserialization_callback=get_long_running_output + deserialization_callback=get_long_running_output, ) return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) - begin_what_if_at_subscription_scope.metadata = {'url': "/subscriptions/{subscriptionId}/providers/Microsoft.Resources/deployments/{deploymentName}/whatIf"} # type: ignore + begin_what_if_at_subscription_scope.metadata = {"url": "/subscriptions/{subscriptionId}/providers/Microsoft.Resources/deployments/{deploymentName}/whatIf"} # type: ignore @distributed_trace_async async def export_template_at_subscription_scope( - self, - deployment_name: str, - **kwargs: Any - ) -> "_models.DeploymentExportResult": + self, deployment_name: str, **kwargs: Any + ) -> _models.DeploymentExportResult: """Exports the template used for specified deployment. - :param deployment_name: The name of the deployment. + :param deployment_name: The name of the deployment. Required. :type deployment_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: DeploymentExportResult, or the result of cls(response) + :return: DeploymentExportResult or the result of cls(response) :rtype: ~azure.mgmt.resource.resources.v2021_04_01.models.DeploymentExportResult - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.DeploymentExportResult"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) - api_version = kwargs.pop('api_version', "2021-04-01") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-04-01")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[_models.DeploymentExportResult] - request = build_deployments_export_template_at_subscription_scope_request( deployment_name=deployment_name, subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.export_template_at_subscription_scope.metadata['url'], + template_url=self.export_template_at_subscription_scope.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) - deserialized = self._deserialize('DeploymentExportResult', pipeline_response) + deserialized = self._deserialize("DeploymentExportResult", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - export_template_at_subscription_scope.metadata = {'url': "/subscriptions/{subscriptionId}/providers/Microsoft.Resources/deployments/{deploymentName}/exportTemplate"} # type: ignore - + export_template_at_subscription_scope.metadata = {"url": "/subscriptions/{subscriptionId}/providers/Microsoft.Resources/deployments/{deploymentName}/exportTemplate"} # type: ignore @distributed_trace def list_at_subscription_scope( - self, - filter: Optional[str] = None, - top: Optional[int] = None, - **kwargs: Any - ) -> AsyncIterable["_models.DeploymentListResult"]: + self, filter: Optional[str] = None, top: Optional[int] = None, **kwargs: Any + ) -> AsyncIterable["_models.DeploymentExtended"]: """Get all the deployments for a subscription. :param filter: The filter to apply on the operation. For example, you can use @@ -3107,40 +4142,48 @@ def list_at_subscription_scope( value is None. :type top: int :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either DeploymentListResult or the result of - cls(response) + :return: An iterator like instance of either DeploymentExtended or the result of cls(response) :rtype: - ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.resource.resources.v2021_04_01.models.DeploymentListResult] - :raises: ~azure.core.exceptions.HttpResponseError + ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.resource.resources.v2021_04_01.models.DeploymentExtended] + :raises ~azure.core.exceptions.HttpResponseError: """ - api_version = kwargs.pop('api_version', "2021-04-01") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-04-01")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[_models.DeploymentListResult] - cls = kwargs.pop('cls', None) # type: ClsType["_models.DeploymentListResult"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) + def prepare_request(next_link=None): if not next_link: - + request = build_deployments_list_at_subscription_scope_request( subscription_id=self._config.subscription_id, - api_version=api_version, filter=filter, top=top, - template_url=self.list_at_subscription_scope.metadata['url'], + api_version=api_version, + template_url=self.list_at_subscription_scope.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore else: - - request = build_deployments_list_at_subscription_scope_request( - subscription_id=self._config.subscription_id, - template_url=next_link, - ) + # make call to next link with the client's api-version + _parsed_next_link = urlparse(next_link) + _next_request_params = case_insensitive_dict(parse_qs(_parsed_next_link.query)) + _next_request_params["api-version"] = self._config.api_version + request = HttpRequest("GET", urljoin(next_link, _parsed_next_link.path), params=_next_request_params) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore request.method = "GET" return request @@ -3154,10 +4197,8 @@ async def extract_data(pipeline_response): async def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) response = pipeline_response.http_response @@ -3167,42 +4208,43 @@ async def get_next(next_link=None): return pipeline_response + return AsyncItemPaged(get_next, extract_data) - return AsyncItemPaged( - get_next, extract_data - ) - list_at_subscription_scope.metadata = {'url': "/subscriptions/{subscriptionId}/providers/Microsoft.Resources/deployments/"} # type: ignore + list_at_subscription_scope.metadata = {"url": "/subscriptions/{subscriptionId}/providers/Microsoft.Resources/deployments/"} # type: ignore async def _delete_initial( # pylint: disable=inconsistent-return-statements - self, - resource_group_name: str, - deployment_name: str, - **kwargs: Any + self, resource_group_name: str, deployment_name: str, **kwargs: Any ) -> None: - cls = kwargs.pop('cls', None) # type: ClsType[None] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) - api_version = kwargs.pop('api_version', "2021-04-01") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - request = build_deployments_delete_request_initial( + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-04-01")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[None] + + request = build_deployments_delete_request( resource_group_name=resource_group_name, deployment_name=deployment_name, subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self._delete_initial.metadata['url'], + template_url=self._delete_initial.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [202, 204]: @@ -3212,16 +4254,10 @@ 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.Resources/deployments/{deploymentName}"} # type: ignore - + _delete_initial.metadata = {"url": "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/Microsoft.Resources/deployments/{deploymentName}"} # type: ignore @distributed_trace_async - async def begin_delete( # pylint: disable=inconsistent-return-statements - self, - resource_group_name: str, - deployment_name: str, - **kwargs: Any - ) -> AsyncLROPoller[None]: + async def begin_delete(self, resource_group_name: str, deployment_name: str, **kwargs: Any) -> AsyncLROPoller[None]: """Deletes a deployment from the deployment history. A template deployment that is currently running cannot be deleted. Deleting a template @@ -3234,9 +4270,9 @@ async def begin_delete( # pylint: disable=inconsistent-return-statements asynchronous request failed, the URI in the Location header returns an error-level status code. :param resource_group_name: The name of the resource group with the deployment to delete. The - name is case insensitive. + name is case insensitive. Required. :type resource_group_name: str - :param deployment_name: The name of the deployment. + :param deployment_name: The name of the deployment. Required. :type deployment_name: str :keyword callable cls: A custom type or function that will be passed the direct response :keyword str continuation_token: A continuation token to restart a poller from a saved state. @@ -3248,88 +4284,93 @@ async def begin_delete( # pylint: disable=inconsistent-return-statements Retry-After header is present. :return: An instance of AsyncLROPoller that returns either None or the result of cls(response) :rtype: ~azure.core.polling.AsyncLROPoller[None] - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - api_version = kwargs.pop('api_version', "2021-04-01") # type: str - polling = kwargs.pop('polling', True) # type: Union[bool, AsyncPollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType[None] - lro_delay = kwargs.pop( - 'polling_interval', - self._config.polling_interval - ) - cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-04-01")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[None] + polling = kwargs.pop("polling", True) # type: Union[bool, AsyncPollingMethod] + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token = kwargs.pop("continuation_token", None) # type: Optional[str] if cont_token is None: - raw_result = await self._delete_initial( + raw_result = await self._delete_initial( # type: ignore resource_group_name=resource_group_name, deployment_name=deployment_name, api_version=api_version, - cls=lambda x,y,z: x, + cls=lambda x, y, z: x, + headers=_headers, + params=_params, **kwargs ) - kwargs.pop('error_map', None) + kwargs.pop("error_map", None) - def get_long_running_output(pipeline_response): + def get_long_running_output(pipeline_response): # pylint: disable=inconsistent-return-statements if cls: return cls(pipeline_response, None, {}) - - if polling is True: polling_method = AsyncARMPolling(lro_delay, **kwargs) - elif polling is False: polling_method = AsyncNoPolling() - else: polling_method = polling + if polling is True: + polling_method = cast(AsyncPollingMethod, AsyncARMPolling(lro_delay, **kwargs)) # type: AsyncPollingMethod + elif polling is False: + polling_method = cast(AsyncPollingMethod, AsyncNoPolling()) + else: + polling_method = polling if cont_token: return AsyncLROPoller.from_continuation_token( polling_method=polling_method, continuation_token=cont_token, client=self._client, - deserialization_callback=get_long_running_output + deserialization_callback=get_long_running_output, ) return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) - begin_delete.metadata = {'url': "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/Microsoft.Resources/deployments/{deploymentName}"} # type: ignore + begin_delete.metadata = {"url": "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/Microsoft.Resources/deployments/{deploymentName}"} # type: ignore @distributed_trace_async - async def check_existence( - self, - resource_group_name: str, - deployment_name: str, - **kwargs: Any - ) -> bool: + async def check_existence(self, resource_group_name: str, deployment_name: str, **kwargs: Any) -> bool: """Checks whether the deployment exists. :param resource_group_name: The name of the resource group with the deployment to check. The - name is case insensitive. + name is case insensitive. Required. :type resource_group_name: str - :param deployment_name: The name of the deployment. + :param deployment_name: The name of the deployment. Required. :type deployment_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: bool, or the result of cls(response) + :return: bool or the result of cls(response) :rtype: bool - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType[None] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) - api_version = kwargs.pop('api_version', "2021-04-01") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-04-01")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[None] - request = build_deployments_check_existence_request( resource_group_name=resource_group_name, deployment_name=deployment_name, subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.check_existence.metadata['url'], + template_url=self.check_existence.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [204, 404]: @@ -3340,44 +4381,53 @@ async def check_existence( return cls(pipeline_response, None, {}) return 200 <= response.status_code <= 299 - check_existence.metadata = {'url': "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/Microsoft.Resources/deployments/{deploymentName}"} # type: ignore - + check_existence.metadata = {"url": "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/Microsoft.Resources/deployments/{deploymentName}"} # type: ignore async def _create_or_update_initial( - self, - resource_group_name: str, - deployment_name: str, - parameters: "_models.Deployment", - **kwargs: Any - ) -> "_models.DeploymentExtended": - cls = kwargs.pop('cls', None) # type: ClsType["_models.DeploymentExtended"] + self, resource_group_name: str, deployment_name: str, parameters: Union[_models.Deployment, IO], **kwargs: Any + ) -> _models.DeploymentExtended: error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', "2021-04-01") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-04-01")) # type: str + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.DeploymentExtended] - _json = self._serialize.body(parameters, 'Deployment') + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(parameters, (IO, bytes)): + _content = parameters + else: + _json = self._serialize.body(parameters, "Deployment") - request = build_deployments_create_or_update_request_initial( + request = build_deployments_create_or_update_request( resource_group_name=resource_group_name, deployment_name=deployment_name, subscription_id=self._config.subscription_id, api_version=api_version, content_type=content_type, json=_json, - template_url=self._create_or_update_initial.metadata['url'], + content=_content, + template_url=self._create_or_update_initial.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200, 201]: @@ -3385,38 +4435,42 @@ async def _create_or_update_initial( raise HttpResponseError(response=response, error_format=ARMErrorFormat) if response.status_code == 200: - deserialized = self._deserialize('DeploymentExtended', pipeline_response) + deserialized = self._deserialize("DeploymentExtended", pipeline_response) if response.status_code == 201: - deserialized = self._deserialize('DeploymentExtended', pipeline_response) + deserialized = self._deserialize("DeploymentExtended", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - _create_or_update_initial.metadata = {'url': "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/Microsoft.Resources/deployments/{deploymentName}"} # type: ignore + _create_or_update_initial.metadata = {"url": "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/Microsoft.Resources/deployments/{deploymentName}"} # type: ignore - - @distributed_trace_async + @overload async def begin_create_or_update( self, resource_group_name: str, deployment_name: str, - parameters: "_models.Deployment", + parameters: _models.Deployment, + *, + content_type: str = "application/json", **kwargs: Any - ) -> AsyncLROPoller["_models.DeploymentExtended"]: + ) -> AsyncLROPoller[_models.DeploymentExtended]: """Deploys resources to a resource group. You can provide the template and parameters directly in the request or link to JSON files. :param resource_group_name: The name of the resource group to deploy the resources to. The name - is case insensitive. The resource group must already exist. + is case insensitive. The resource group must already exist. Required. :type resource_group_name: str - :param deployment_name: The name of the deployment. + :param deployment_name: The name of the deployment. Required. :type deployment_name: str - :param parameters: Additional parameters supplied to the operation. + :param parameters: Additional parameters supplied to the operation. Required. :type parameters: ~azure.mgmt.resource.resources.v2021_04_01.models.Deployment + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str :keyword callable cls: A custom type or function that will be passed the direct response :keyword str continuation_token: A continuation token to restart a poller from a saved state. :keyword polling: By default, your polling method will be AsyncARMPolling. Pass in False for @@ -3429,115 +4483,189 @@ async def begin_create_or_update( cls(response) :rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.resource.resources.v2021_04_01.models.DeploymentExtended] - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - api_version = kwargs.pop('api_version', "2021-04-01") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] - polling = kwargs.pop('polling', True) # type: Union[bool, AsyncPollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType["_models.DeploymentExtended"] - lro_delay = kwargs.pop( - 'polling_interval', - self._config.polling_interval - ) - cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] - if cont_token is None: - raw_result = await self._create_or_update_initial( - resource_group_name=resource_group_name, - deployment_name=deployment_name, - parameters=parameters, - api_version=api_version, - content_type=content_type, - cls=lambda x,y,z: x, - **kwargs - ) - kwargs.pop('error_map', None) - - def get_long_running_output(pipeline_response): - response = pipeline_response.http_response - deserialized = self._deserialize('DeploymentExtended', pipeline_response) - if cls: - return cls(pipeline_response, deserialized, {}) - return deserialized - - - if polling is True: polling_method = AsyncARMPolling(lro_delay, **kwargs) - elif polling is False: polling_method = AsyncNoPolling() - else: polling_method = polling - if cont_token: - return AsyncLROPoller.from_continuation_token( - polling_method=polling_method, - continuation_token=cont_token, - client=self._client, - deserialization_callback=get_long_running_output - ) - return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) - begin_create_or_update.metadata = {'url': "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/Microsoft.Resources/deployments/{deploymentName}"} # type: ignore - - @distributed_trace_async - async def get( + @overload + async def begin_create_or_update( self, resource_group_name: str, deployment_name: str, + parameters: IO, + *, + content_type: str = "application/json", **kwargs: Any - ) -> "_models.DeploymentExtended": - """Gets a deployment. + ) -> AsyncLROPoller[_models.DeploymentExtended]: + """Deploys resources to a resource group. + + You can provide the template and parameters directly in the request or link to JSON files. + + :param resource_group_name: The name of the resource group to deploy the resources to. The name + is case insensitive. The resource group must already exist. Required. + :type resource_group_name: str + :param deployment_name: The name of the deployment. Required. + :type deployment_name: str + :param parameters: Additional parameters supplied to the operation. Required. + :type parameters: IO + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be AsyncARMPolling. Pass in False for + this operation to not poll, or pass in your own initialized polling object for a personal + polling strategy. + :paramtype polling: bool or ~azure.core.polling.AsyncPollingMethod + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of AsyncLROPoller that returns either DeploymentExtended or the result of + cls(response) + :rtype: + ~azure.core.polling.AsyncLROPoller[~azure.mgmt.resource.resources.v2021_04_01.models.DeploymentExtended] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace_async + async def begin_create_or_update( + self, resource_group_name: str, deployment_name: str, parameters: Union[_models.Deployment, IO], **kwargs: Any + ) -> AsyncLROPoller[_models.DeploymentExtended]: + """Deploys resources to a resource group. + + You can provide the template and parameters directly in the request or link to JSON files. + + :param resource_group_name: The name of the resource group to deploy the resources to. The name + is case insensitive. The resource group must already exist. Required. + :type resource_group_name: str + :param deployment_name: The name of the deployment. Required. + :type deployment_name: str + :param parameters: Additional parameters supplied to the operation. Is either a model type or a + IO type. Required. + :type parameters: ~azure.mgmt.resource.resources.v2021_04_01.models.Deployment or IO + :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. + Default value is None. + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be AsyncARMPolling. Pass in False for + this operation to not poll, or pass in your own initialized polling object for a personal + polling strategy. + :paramtype polling: bool or ~azure.core.polling.AsyncPollingMethod + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of AsyncLROPoller that returns either DeploymentExtended or the result of + cls(response) + :rtype: + ~azure.core.polling.AsyncLROPoller[~azure.mgmt.resource.resources.v2021_04_01.models.DeploymentExtended] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _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-04-01")) # type: str + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.DeploymentExtended] + polling = kwargs.pop("polling", True) # type: Union[bool, AsyncPollingMethod] + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token = kwargs.pop("continuation_token", None) # type: Optional[str] + if cont_token is None: + raw_result = await self._create_or_update_initial( # type: ignore + resource_group_name=resource_group_name, + deployment_name=deployment_name, + parameters=parameters, + api_version=api_version, + content_type=content_type, + cls=lambda x, y, z: x, + headers=_headers, + params=_params, + **kwargs + ) + kwargs.pop("error_map", None) + + def get_long_running_output(pipeline_response): + deserialized = self._deserialize("DeploymentExtended", pipeline_response) + if cls: + return cls(pipeline_response, deserialized, {}) + return deserialized + + if polling is True: + polling_method = cast(AsyncPollingMethod, AsyncARMPolling(lro_delay, **kwargs)) # type: AsyncPollingMethod + elif polling is False: + polling_method = cast(AsyncPollingMethod, AsyncNoPolling()) + else: + polling_method = polling + if cont_token: + return AsyncLROPoller.from_continuation_token( + polling_method=polling_method, + continuation_token=cont_token, + client=self._client, + deserialization_callback=get_long_running_output, + ) + return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) + + begin_create_or_update.metadata = {"url": "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/Microsoft.Resources/deployments/{deploymentName}"} # type: ignore + + @distributed_trace_async + async def get(self, resource_group_name: str, deployment_name: str, **kwargs: Any) -> _models.DeploymentExtended: + """Gets a deployment. :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. :type resource_group_name: str - :param deployment_name: The name of the deployment. + :param deployment_name: The name of the deployment. Required. :type deployment_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: DeploymentExtended, or the result of cls(response) + :return: DeploymentExtended or the result of cls(response) :rtype: ~azure.mgmt.resource.resources.v2021_04_01.models.DeploymentExtended - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.DeploymentExtended"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + 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', "2021-04-01") # type: str + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-04-01")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[_models.DeploymentExtended] - request = build_deployments_get_request( resource_group_name=resource_group_name, deployment_name=deployment_name, subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.get.metadata['url'], + template_url=self.get.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) - deserialized = self._deserialize('DeploymentExtended', pipeline_response) + deserialized = self._deserialize("DeploymentExtended", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - get.metadata = {'url': "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/Microsoft.Resources/deployments/{deploymentName}"} # type: ignore - + get.metadata = {"url": "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/Microsoft.Resources/deployments/{deploymentName}"} # type: ignore @distributed_trace_async async def cancel( # pylint: disable=inconsistent-return-statements - self, - resource_group_name: str, - deployment_name: str, - **kwargs: Any + self, resource_group_name: str, deployment_name: str, **kwargs: Any ) -> None: """Cancels a currently running template deployment. @@ -3547,38 +4675,45 @@ async def cancel( # pylint: disable=inconsistent-return-statements partially deployed. :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. :type resource_group_name: str - :param deployment_name: The name of the deployment. + :param deployment_name: The name of the deployment. Required. :type deployment_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: None, or the result of cls(response) + :return: None or the result of cls(response) :rtype: None - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType[None] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) - api_version = kwargs.pop('api_version', "2021-04-01") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-04-01")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[None] - request = build_deployments_cancel_request( resource_group_name=resource_group_name, deployment_name=deployment_name, subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.cancel.metadata['url'], + template_url=self.cancel.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [204]: @@ -3588,44 +4723,53 @@ async def cancel( # pylint: disable=inconsistent-return-statements if cls: return cls(pipeline_response, None, {}) - cancel.metadata = {'url': "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/Microsoft.Resources/deployments/{deploymentName}/cancel"} # type: ignore - + cancel.metadata = {"url": "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/Microsoft.Resources/deployments/{deploymentName}/cancel"} # type: ignore async def _validate_initial( - self, - resource_group_name: str, - deployment_name: str, - parameters: "_models.Deployment", - **kwargs: Any - ) -> Optional["_models.DeploymentValidateResult"]: - cls = kwargs.pop('cls', None) # type: ClsType[Optional["_models.DeploymentValidateResult"]] + self, resource_group_name: str, deployment_name: str, parameters: Union[_models.Deployment, IO], **kwargs: Any + ) -> Optional[_models.DeploymentValidateResult]: error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', "2021-04-01") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-04-01")) # type: str + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[Optional[_models.DeploymentValidateResult]] - _json = self._serialize.body(parameters, 'Deployment') + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(parameters, (IO, bytes)): + _content = parameters + else: + _json = self._serialize.body(parameters, "Deployment") - request = build_deployments_validate_request_initial( + request = build_deployments_validate_request( resource_group_name=resource_group_name, deployment_name=deployment_name, subscription_id=self._config.subscription_id, api_version=api_version, content_type=content_type, json=_json, - template_url=self._validate_initial.metadata['url'], + content=_content, + template_url=self._validate_initial.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200, 202, 400]: @@ -3634,37 +4778,41 @@ async def _validate_initial( deserialized = None if response.status_code == 200: - deserialized = self._deserialize('DeploymentValidateResult', pipeline_response) + deserialized = self._deserialize("DeploymentValidateResult", pipeline_response) if response.status_code == 400: - deserialized = self._deserialize('DeploymentValidateResult', pipeline_response) + deserialized = self._deserialize("DeploymentValidateResult", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - _validate_initial.metadata = {'url': "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/Microsoft.Resources/deployments/{deploymentName}/validate"} # type: ignore + _validate_initial.metadata = {"url": "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/Microsoft.Resources/deployments/{deploymentName}/validate"} # type: ignore - - @distributed_trace_async + @overload async def begin_validate( self, resource_group_name: str, deployment_name: str, - parameters: "_models.Deployment", + parameters: _models.Deployment, + *, + content_type: str = "application/json", **kwargs: Any - ) -> AsyncLROPoller["_models.DeploymentValidateResult"]: + ) -> AsyncLROPoller[_models.DeploymentValidateResult]: """Validates whether the specified template is syntactically correct and will be accepted by Azure Resource Manager.. :param resource_group_name: The name of the resource group the template will be deployed to. - The name is case insensitive. + The name is case insensitive. Required. :type resource_group_name: str - :param deployment_name: The name of the deployment. + :param deployment_name: The name of the deployment. Required. :type deployment_name: str - :param parameters: Parameters to validate. + :param parameters: Parameters to validate. Required. :type parameters: ~azure.mgmt.resource.resources.v2021_04_01.models.Deployment + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str :keyword callable cls: A custom type or function that will be passed the direct response :keyword str continuation_token: A continuation token to restart a poller from a saved state. :keyword polling: By default, your polling method will be AsyncARMPolling. Pass in False for @@ -3677,86 +4825,173 @@ async def begin_validate( result of cls(response) :rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.resource.resources.v2021_04_01.models.DeploymentValidateResult] - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - api_version = kwargs.pop('api_version', "2021-04-01") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] - polling = kwargs.pop('polling', True) # type: Union[bool, AsyncPollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType["_models.DeploymentValidateResult"] - lro_delay = kwargs.pop( - 'polling_interval', - self._config.polling_interval - ) - cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] + + @overload + async def begin_validate( + self, + resource_group_name: str, + deployment_name: str, + parameters: IO, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> AsyncLROPoller[_models.DeploymentValidateResult]: + """Validates whether the specified template is syntactically correct and will be accepted by Azure + Resource Manager.. + + :param resource_group_name: The name of the resource group the template will be deployed to. + The name is case insensitive. Required. + :type resource_group_name: str + :param deployment_name: The name of the deployment. Required. + :type deployment_name: str + :param parameters: Parameters to validate. Required. + :type parameters: IO + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be AsyncARMPolling. Pass in False for + this operation to not poll, or pass in your own initialized polling object for a personal + polling strategy. + :paramtype polling: bool or ~azure.core.polling.AsyncPollingMethod + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of AsyncLROPoller that returns either DeploymentValidateResult or the + result of cls(response) + :rtype: + ~azure.core.polling.AsyncLROPoller[~azure.mgmt.resource.resources.v2021_04_01.models.DeploymentValidateResult] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace_async + async def begin_validate( + self, resource_group_name: str, deployment_name: str, parameters: Union[_models.Deployment, IO], **kwargs: Any + ) -> AsyncLROPoller[_models.DeploymentValidateResult]: + """Validates whether the specified template is syntactically correct and will be accepted by Azure + Resource Manager.. + + :param resource_group_name: The name of the resource group the template will be deployed to. + The name is case insensitive. Required. + :type resource_group_name: str + :param deployment_name: The name of the deployment. Required. + :type deployment_name: str + :param parameters: Parameters to validate. Is either a model type or a IO type. Required. + :type parameters: ~azure.mgmt.resource.resources.v2021_04_01.models.Deployment or IO + :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. + Default value is None. + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be AsyncARMPolling. Pass in False for + this operation to not poll, or pass in your own initialized polling object for a personal + polling strategy. + :paramtype polling: bool or ~azure.core.polling.AsyncPollingMethod + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of AsyncLROPoller that returns either DeploymentValidateResult or the + result of cls(response) + :rtype: + ~azure.core.polling.AsyncLROPoller[~azure.mgmt.resource.resources.v2021_04_01.models.DeploymentValidateResult] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _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-04-01")) # type: str + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.DeploymentValidateResult] + polling = kwargs.pop("polling", True) # type: Union[bool, AsyncPollingMethod] + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token = kwargs.pop("continuation_token", None) # type: Optional[str] if cont_token is None: - raw_result = await self._validate_initial( + raw_result = await self._validate_initial( # type: ignore resource_group_name=resource_group_name, deployment_name=deployment_name, parameters=parameters, api_version=api_version, content_type=content_type, - cls=lambda x,y,z: x, + cls=lambda x, y, z: x, + headers=_headers, + params=_params, **kwargs ) - kwargs.pop('error_map', None) + kwargs.pop("error_map", None) def get_long_running_output(pipeline_response): - response = pipeline_response.http_response - deserialized = self._deserialize('DeploymentValidateResult', pipeline_response) + deserialized = self._deserialize("DeploymentValidateResult", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - - if polling is True: polling_method = AsyncARMPolling(lro_delay, **kwargs) - elif polling is False: polling_method = AsyncNoPolling() - else: polling_method = polling + if polling is True: + polling_method = cast(AsyncPollingMethod, AsyncARMPolling(lro_delay, **kwargs)) # type: AsyncPollingMethod + elif polling is False: + polling_method = cast(AsyncPollingMethod, AsyncNoPolling()) + else: + polling_method = polling if cont_token: return AsyncLROPoller.from_continuation_token( polling_method=polling_method, continuation_token=cont_token, client=self._client, - deserialization_callback=get_long_running_output + deserialization_callback=get_long_running_output, ) return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) - begin_validate.metadata = {'url': "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/Microsoft.Resources/deployments/{deploymentName}/validate"} # type: ignore + begin_validate.metadata = {"url": "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/Microsoft.Resources/deployments/{deploymentName}/validate"} # type: ignore async def _what_if_initial( self, resource_group_name: str, deployment_name: str, - parameters: "_models.DeploymentWhatIf", + parameters: Union[_models.DeploymentWhatIf, IO], **kwargs: Any - ) -> Optional["_models.WhatIfOperationResult"]: - cls = kwargs.pop('cls', None) # type: ClsType[Optional["_models.WhatIfOperationResult"]] + ) -> Optional[_models.WhatIfOperationResult]: error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) - api_version = kwargs.pop('api_version', "2021-04-01") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - _json = self._serialize.body(parameters, 'DeploymentWhatIf') + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-04-01")) # type: str + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[Optional[_models.WhatIfOperationResult]] - request = build_deployments_what_if_request_initial( + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(parameters, (IO, bytes)): + _content = parameters + else: + _json = self._serialize.body(parameters, "DeploymentWhatIf") + + request = build_deployments_what_if_request( resource_group_name=resource_group_name, deployment_name=deployment_name, subscription_id=self._config.subscription_id, api_version=api_version, content_type=content_type, json=_json, - template_url=self._what_if_initial.metadata['url'], + content=_content, + template_url=self._what_if_initial.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200, 202]: @@ -3766,39 +5001,116 @@ async def _what_if_initial( deserialized = None response_headers = {} if response.status_code == 200: - deserialized = self._deserialize('WhatIfOperationResult', pipeline_response) + deserialized = self._deserialize("WhatIfOperationResult", pipeline_response) if response.status_code == 202: - response_headers['Location']=self._deserialize('str', response.headers.get('Location')) - response_headers['Retry-After']=self._deserialize('str', response.headers.get('Retry-After')) - + response_headers["Location"] = self._deserialize("str", response.headers.get("Location")) + response_headers["Retry-After"] = self._deserialize("str", response.headers.get("Retry-After")) if cls: return cls(pipeline_response, deserialized, response_headers) return deserialized - _what_if_initial.metadata = {'url': "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/Microsoft.Resources/deployments/{deploymentName}/whatIf"} # type: ignore + _what_if_initial.metadata = {"url": "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/Microsoft.Resources/deployments/{deploymentName}/whatIf"} # type: ignore + + @overload + async def begin_what_if( + self, + resource_group_name: str, + deployment_name: str, + parameters: _models.DeploymentWhatIf, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> AsyncLROPoller[_models.WhatIfOperationResult]: + """Returns changes that will be made by the deployment if executed at the scope of the resource + group. + + :param resource_group_name: The name of the resource group the template will be deployed to. + The name is case insensitive. Required. + :type resource_group_name: str + :param deployment_name: The name of the deployment. Required. + :type deployment_name: str + :param parameters: Parameters to validate. Required. + :type parameters: ~azure.mgmt.resource.resources.v2021_04_01.models.DeploymentWhatIf + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be AsyncARMPolling. Pass in False for + this operation to not poll, or pass in your own initialized polling object for a personal + polling strategy. + :paramtype polling: bool or ~azure.core.polling.AsyncPollingMethod + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of AsyncLROPoller that returns either WhatIfOperationResult or the result + of cls(response) + :rtype: + ~azure.core.polling.AsyncLROPoller[~azure.mgmt.resource.resources.v2021_04_01.models.WhatIfOperationResult] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + async def begin_what_if( + self, + resource_group_name: str, + deployment_name: str, + parameters: IO, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> AsyncLROPoller[_models.WhatIfOperationResult]: + """Returns changes that will be made by the deployment if executed at the scope of the resource + group. + :param resource_group_name: The name of the resource group the template will be deployed to. + The name is case insensitive. Required. + :type resource_group_name: str + :param deployment_name: The name of the deployment. Required. + :type deployment_name: str + :param parameters: Parameters to validate. Required. + :type parameters: IO + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be AsyncARMPolling. Pass in False for + this operation to not poll, or pass in your own initialized polling object for a personal + polling strategy. + :paramtype polling: bool or ~azure.core.polling.AsyncPollingMethod + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of AsyncLROPoller that returns either WhatIfOperationResult or the result + of cls(response) + :rtype: + ~azure.core.polling.AsyncLROPoller[~azure.mgmt.resource.resources.v2021_04_01.models.WhatIfOperationResult] + :raises ~azure.core.exceptions.HttpResponseError: + """ @distributed_trace_async async def begin_what_if( self, resource_group_name: str, deployment_name: str, - parameters: "_models.DeploymentWhatIf", + parameters: Union[_models.DeploymentWhatIf, IO], **kwargs: Any - ) -> AsyncLROPoller["_models.WhatIfOperationResult"]: + ) -> AsyncLROPoller[_models.WhatIfOperationResult]: """Returns changes that will be made by the deployment if executed at the scope of the resource group. :param resource_group_name: The name of the resource group the template will be deployed to. - The name is case insensitive. + The name is case insensitive. Required. :type resource_group_name: str - :param deployment_name: The name of the deployment. + :param deployment_name: The name of the deployment. Required. :type deployment_name: str - :param parameters: Parameters to validate. - :type parameters: ~azure.mgmt.resource.resources.v2021_04_01.models.DeploymentWhatIf + :param parameters: Parameters to validate. Is either a model type or a IO type. Required. + :type parameters: ~azure.mgmt.resource.resources.v2021_04_01.models.DeploymentWhatIf or IO + :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. + Default value is None. + :paramtype content_type: str :keyword callable cls: A custom type or function that will be passed the direct response :keyword str continuation_token: A continuation token to restart a poller from a saved state. :keyword polling: By default, your polling method will be AsyncARMPolling. Pass in False for @@ -3811,121 +5123,125 @@ async def begin_what_if( of cls(response) :rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.resource.resources.v2021_04_01.models.WhatIfOperationResult] - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - api_version = kwargs.pop('api_version', "2021-04-01") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] - polling = kwargs.pop('polling', True) # type: Union[bool, AsyncPollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType["_models.WhatIfOperationResult"] - lro_delay = kwargs.pop( - 'polling_interval', - self._config.polling_interval - ) - cont_token = kwargs.pop('continuation_token', None) # type: Optional[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-04-01")) # type: str + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.WhatIfOperationResult] + polling = kwargs.pop("polling", True) # type: Union[bool, AsyncPollingMethod] + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token = kwargs.pop("continuation_token", None) # type: Optional[str] if cont_token is None: - raw_result = await self._what_if_initial( + raw_result = await self._what_if_initial( # type: ignore resource_group_name=resource_group_name, deployment_name=deployment_name, parameters=parameters, api_version=api_version, content_type=content_type, - cls=lambda x,y,z: x, + cls=lambda x, y, z: x, + headers=_headers, + params=_params, **kwargs ) - kwargs.pop('error_map', None) + kwargs.pop("error_map", None) def get_long_running_output(pipeline_response): - response = pipeline_response.http_response - deserialized = self._deserialize('WhatIfOperationResult', pipeline_response) + deserialized = self._deserialize("WhatIfOperationResult", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - - if polling is True: polling_method = AsyncARMPolling(lro_delay, lro_options={'final-state-via': 'location'}, **kwargs) - elif polling is False: polling_method = AsyncNoPolling() - else: polling_method = polling + if polling is True: + polling_method = cast( + AsyncPollingMethod, AsyncARMPolling(lro_delay, lro_options={"final-state-via": "location"}, **kwargs) + ) # type: AsyncPollingMethod + elif polling is False: + polling_method = cast(AsyncPollingMethod, AsyncNoPolling()) + else: + polling_method = polling if cont_token: return AsyncLROPoller.from_continuation_token( polling_method=polling_method, continuation_token=cont_token, client=self._client, - deserialization_callback=get_long_running_output + deserialization_callback=get_long_running_output, ) return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) - begin_what_if.metadata = {'url': "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/Microsoft.Resources/deployments/{deploymentName}/whatIf"} # type: ignore + begin_what_if.metadata = {"url": "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/Microsoft.Resources/deployments/{deploymentName}/whatIf"} # type: ignore @distributed_trace_async async def export_template( - self, - resource_group_name: str, - deployment_name: str, - **kwargs: Any - ) -> "_models.DeploymentExportResult": + self, resource_group_name: str, deployment_name: str, **kwargs: Any + ) -> _models.DeploymentExportResult: """Exports the template used for specified deployment. :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. :type resource_group_name: str - :param deployment_name: The name of the deployment. + :param deployment_name: The name of the deployment. Required. :type deployment_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: DeploymentExportResult, or the result of cls(response) + :return: DeploymentExportResult or the result of cls(response) :rtype: ~azure.mgmt.resource.resources.v2021_04_01.models.DeploymentExportResult - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.DeploymentExportResult"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + 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', "2021-04-01") # type: str + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-04-01")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[_models.DeploymentExportResult] - request = build_deployments_export_template_request( resource_group_name=resource_group_name, deployment_name=deployment_name, subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.export_template.metadata['url'], + template_url=self.export_template.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) - deserialized = self._deserialize('DeploymentExportResult', pipeline_response) + deserialized = self._deserialize("DeploymentExportResult", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - export_template.metadata = {'url': "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/Microsoft.Resources/deployments/{deploymentName}/exportTemplate"} # type: ignore - + export_template.metadata = {"url": "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/Microsoft.Resources/deployments/{deploymentName}/exportTemplate"} # type: ignore @distributed_trace def list_by_resource_group( - self, - resource_group_name: str, - filter: Optional[str] = None, - top: Optional[int] = None, - **kwargs: Any - ) -> AsyncIterable["_models.DeploymentListResult"]: + self, resource_group_name: str, filter: Optional[str] = None, top: Optional[int] = None, **kwargs: Any + ) -> AsyncIterable["_models.DeploymentExtended"]: """Get all the deployments for a resource group. :param resource_group_name: The name of the resource group with the deployments to get. The - name is case insensitive. + name is case insensitive. Required. :type resource_group_name: str :param filter: The filter to apply on the operation. For example, you can use $filter=provisioningState eq '{state}'. Default value is None. @@ -3934,42 +5250,49 @@ def list_by_resource_group( value is None. :type top: int :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either DeploymentListResult or the result of - cls(response) + :return: An iterator like instance of either DeploymentExtended or the result of cls(response) :rtype: - ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.resource.resources.v2021_04_01.models.DeploymentListResult] - :raises: ~azure.core.exceptions.HttpResponseError + ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.resource.resources.v2021_04_01.models.DeploymentExtended] + :raises ~azure.core.exceptions.HttpResponseError: """ - api_version = kwargs.pop('api_version', "2021-04-01") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-04-01")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[_models.DeploymentListResult] - cls = kwargs.pop('cls', None) # type: ClsType["_models.DeploymentListResult"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) + def prepare_request(next_link=None): if not next_link: - + request = build_deployments_list_by_resource_group_request( resource_group_name=resource_group_name, subscription_id=self._config.subscription_id, - api_version=api_version, filter=filter, top=top, - template_url=self.list_by_resource_group.metadata['url'], + 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.url = self._client.format_url(request.url) # type: ignore else: - - request = build_deployments_list_by_resource_group_request( - resource_group_name=resource_group_name, - subscription_id=self._config.subscription_id, - template_url=next_link, - ) + # make call to next link with the client's api-version + _parsed_next_link = urlparse(next_link) + _next_request_params = case_insensitive_dict(parse_qs(_parsed_next_link.query)) + _next_request_params["api-version"] = self._config.api_version + request = HttpRequest("GET", urljoin(next_link, _parsed_next_link.path), params=_next_request_params) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore request.method = "GET" return request @@ -3983,10 +5306,8 @@ async def extract_data(pipeline_response): async def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) response = pipeline_response.http_response @@ -3996,184 +5317,192 @@ async def get_next(next_link=None): return pipeline_response + return AsyncItemPaged(get_next, extract_data) - return AsyncItemPaged( - get_next, extract_data - ) - list_by_resource_group.metadata = {'url': "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/Microsoft.Resources/deployments/"} # type: ignore + list_by_resource_group.metadata = {"url": "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/Microsoft.Resources/deployments/"} # type: ignore @distributed_trace_async - async def calculate_template_hash( - self, - template: Any, - **kwargs: Any - ) -> "_models.TemplateHashResult": + async def calculate_template_hash(self, template: JSON, **kwargs: Any) -> _models.TemplateHashResult: """Calculate the hash of the given template. - :param template: The template provided to calculate hash. - :type template: any + :param template: The template provided to calculate hash. Required. + :type template: JSON :keyword callable cls: A custom type or function that will be passed the direct response - :return: TemplateHashResult, or the result of cls(response) + :return: TemplateHashResult or the result of cls(response) :rtype: ~azure.mgmt.resource.resources.v2021_04_01.models.TemplateHashResult - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.TemplateHashResult"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', "2021-04-01") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-04-01")) # type: str + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", "application/json")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[_models.TemplateHashResult] - _json = self._serialize.body(template, 'object') + _json = self._serialize.body(template, "object") request = build_deployments_calculate_template_hash_request( api_version=api_version, content_type=content_type, json=_json, - template_url=self.calculate_template_hash.metadata['url'], + template_url=self.calculate_template_hash.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) - deserialized = self._deserialize('TemplateHashResult', pipeline_response) + deserialized = self._deserialize("TemplateHashResult", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - calculate_template_hash.metadata = {'url': "/providers/Microsoft.Resources/calculateTemplateHash"} # type: ignore + calculate_template_hash.metadata = {"url": "/providers/Microsoft.Resources/calculateTemplateHash"} # type: ignore -class ProvidersOperations: - """ProvidersOperations async operations. - You should not instantiate this class directly. Instead, you should create a Client instance that - instantiates it for you and attaches it as an attribute. +class ProvidersOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. - :ivar models: Alias to model classes used in this operation group. - :type models: ~azure.mgmt.resource.resources.v2021_04_01.models - :param client: Client for service requests. - :param config: Configuration of service client. - :param serializer: An object model serializer. - :param deserializer: An object model deserializer. + Instead, you should access the following operations through + :class:`~azure.mgmt.resource.resources.v2021_04_01.aio.ResourceManagementClient`'s + :attr:`providers` attribute. """ models = _models - def __init__(self, client, config, serializer, deserializer) -> None: - self._client = client - self._serialize = serializer - self._deserialize = deserializer - self._config = config + def __init__(self, *args, **kwargs) -> None: + input_args = list(args) + self._client = input_args.pop(0) if input_args else kwargs.pop("client") + self._config = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") @distributed_trace_async - async def unregister( - self, - resource_provider_namespace: str, - **kwargs: Any - ) -> "_models.Provider": + async def unregister(self, resource_provider_namespace: str, **kwargs: Any) -> _models.Provider: """Unregisters a subscription from a resource provider. :param resource_provider_namespace: The namespace of the resource provider to unregister. + Required. :type resource_provider_namespace: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: Provider, or the result of cls(response) + :return: Provider or the result of cls(response) :rtype: ~azure.mgmt.resource.resources.v2021_04_01.models.Provider - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.Provider"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + 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', "2021-04-01") # type: str + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-04-01")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[_models.Provider] - request = build_providers_unregister_request( resource_provider_namespace=resource_provider_namespace, subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.unregister.metadata['url'], + template_url=self.unregister.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) - deserialized = self._deserialize('Provider', pipeline_response) + deserialized = self._deserialize("Provider", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - unregister.metadata = {'url': "/subscriptions/{subscriptionId}/providers/{resourceProviderNamespace}/unregister"} # type: ignore - + unregister.metadata = {"url": "/subscriptions/{subscriptionId}/providers/{resourceProviderNamespace}/unregister"} # type: ignore @distributed_trace_async async def register_at_management_group_scope( # pylint: disable=inconsistent-return-statements - self, - resource_provider_namespace: str, - group_id: str, - **kwargs: Any + self, resource_provider_namespace: str, group_id: str, **kwargs: Any ) -> None: - """Registers a management group with a resource provider. + """Registers a management group with a resource provider. Use this operation to register a + resource provider with resource types that can be deployed at the management group scope. It + does not recursively register subscriptions within the management group. Instead, you must + register subscriptions individually. :param resource_provider_namespace: The namespace of the resource provider to register. + Required. :type resource_provider_namespace: str - :param group_id: The management group ID. + :param group_id: The management group ID. Required. :type group_id: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: None, or the result of cls(response) + :return: None or the result of cls(response) :rtype: None - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType[None] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) - api_version = kwargs.pop('api_version', "2021-04-01") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-04-01")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[None] - request = build_providers_register_at_management_group_scope_request( resource_provider_namespace=resource_provider_namespace, group_id=group_id, api_version=api_version, - template_url=self.register_at_management_group_scope.metadata['url'], + template_url=self.register_at_management_group_scope.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200]: @@ -4183,133 +5512,200 @@ async def register_at_management_group_scope( # pylint: disable=inconsistent-re if cls: return cls(pipeline_response, None, {}) - register_at_management_group_scope.metadata = {'url': "/providers/Microsoft.Management/managementGroups/{groupId}/providers/{resourceProviderNamespace}/register"} # type: ignore - + register_at_management_group_scope.metadata = {"url": "/providers/Microsoft.Management/managementGroups/{groupId}/providers/{resourceProviderNamespace}/register"} # type: ignore @distributed_trace_async async def provider_permissions( - self, - resource_provider_namespace: str, - **kwargs: Any - ) -> "_models.ProviderPermissionListResult": + self, resource_provider_namespace: str, **kwargs: Any + ) -> _models.ProviderPermissionListResult: """Get the provider permissions. - :param resource_provider_namespace: The namespace of the resource provider. + :param resource_provider_namespace: The namespace of the resource provider. Required. :type resource_provider_namespace: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: ProviderPermissionListResult, or the result of cls(response) + :return: ProviderPermissionListResult or the result of cls(response) :rtype: ~azure.mgmt.resource.resources.v2021_04_01.models.ProviderPermissionListResult - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.ProviderPermissionListResult"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) - api_version = kwargs.pop('api_version', "2021-04-01") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-04-01")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[_models.ProviderPermissionListResult] - request = build_providers_provider_permissions_request( resource_provider_namespace=resource_provider_namespace, subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.provider_permissions.metadata['url'], + template_url=self.provider_permissions.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) - deserialized = self._deserialize('ProviderPermissionListResult', pipeline_response) + deserialized = self._deserialize("ProviderPermissionListResult", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - provider_permissions.metadata = {'url': "/subscriptions/{subscriptionId}/providers/{resourceProviderNamespace}/providerPermissions"} # type: ignore + provider_permissions.metadata = {"url": "/subscriptions/{subscriptionId}/providers/{resourceProviderNamespace}/providerPermissions"} # type: ignore - - @distributed_trace_async + @overload async def register( self, resource_provider_namespace: str, - properties: Optional["_models.ProviderRegistrationRequest"] = None, + properties: Optional[_models.ProviderRegistrationRequest] = None, + *, + content_type: str = "application/json", **kwargs: Any - ) -> "_models.Provider": + ) -> _models.Provider: """Registers a subscription with a resource provider. :param resource_provider_namespace: The namespace of the resource provider to register. + Required. :type resource_provider_namespace: str :param properties: The third party consent for S2S. Default value is None. :type properties: ~azure.mgmt.resource.resources.v2021_04_01.models.ProviderRegistrationRequest + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: Provider, or the result of cls(response) + :return: Provider or the result of cls(response) :rtype: ~azure.mgmt.resource.resources.v2021_04_01.models.Provider - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.Provider"] - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {})) - api_version = kwargs.pop('api_version', "2021-04-01") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] - - if properties is not None: - _json = self._serialize.body(properties, 'ProviderRegistrationRequest') - else: - _json = None - - request = build_providers_register_request( + @overload + async def register( + self, + resource_provider_namespace: str, + properties: Optional[IO] = None, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.Provider: + """Registers a subscription with a resource provider. + + :param resource_provider_namespace: The namespace of the resource provider to register. + Required. + :type resource_provider_namespace: str + :param properties: The third party consent for S2S. Default value is None. + :type properties: IO + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: Provider or the result of cls(response) + :rtype: ~azure.mgmt.resource.resources.v2021_04_01.models.Provider + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace_async + async def register( + self, + resource_provider_namespace: str, + properties: Optional[Union[_models.ProviderRegistrationRequest, IO]] = None, + **kwargs: Any + ) -> _models.Provider: + """Registers a subscription with a resource provider. + + :param resource_provider_namespace: The namespace of the resource provider to register. + Required. + :type resource_provider_namespace: str + :param properties: The third party consent for S2S. Is either a model type or a IO type. + Default value is None. + :type properties: ~azure.mgmt.resource.resources.v2021_04_01.models.ProviderRegistrationRequest + or IO + :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. + Default value is None. + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: Provider or the result of cls(response) + :rtype: ~azure.mgmt.resource.resources.v2021_04_01.models.Provider + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-04-01")) # type: str + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.Provider] + + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(properties, (IO, bytes)): + _content = properties + else: + if properties is not None: + _json = self._serialize.body(properties, "ProviderRegistrationRequest") + else: + _json = None + + request = build_providers_register_request( resource_provider_namespace=resource_provider_namespace, subscription_id=self._config.subscription_id, api_version=api_version, content_type=content_type, json=_json, - template_url=self.register.metadata['url'], + content=_content, + template_url=self.register.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) - deserialized = self._deserialize('Provider', pipeline_response) + deserialized = self._deserialize("Provider", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - register.metadata = {'url': "/subscriptions/{subscriptionId}/providers/{resourceProviderNamespace}/register"} # type: ignore - + register.metadata = {"url": "/subscriptions/{subscriptionId}/providers/{resourceProviderNamespace}/register"} # type: ignore @distributed_trace - def list( - self, - expand: Optional[str] = None, - **kwargs: Any - ) -> AsyncIterable["_models.ProviderListResult"]: + def list(self, expand: Optional[str] = None, **kwargs: Any) -> AsyncIterable["_models.Provider"]: """Gets all resource providers for a subscription. :param expand: The properties to include in the results. For example, use &$expand=metadata in @@ -4317,38 +5713,47 @@ def list( response, use $expand=resourceTypes/aliases. Default value is None. :type expand: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either ProviderListResult or the result of cls(response) + :return: An iterator like instance of either Provider or the result of cls(response) :rtype: - ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.resource.resources.v2021_04_01.models.ProviderListResult] - :raises: ~azure.core.exceptions.HttpResponseError + ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.resource.resources.v2021_04_01.models.Provider] + :raises ~azure.core.exceptions.HttpResponseError: """ - api_version = kwargs.pop('api_version', "2021-04-01") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-04-01")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[_models.ProviderListResult] - cls = kwargs.pop('cls', None) # type: ClsType["_models.ProviderListResult"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) + def prepare_request(next_link=None): if not next_link: - + request = build_providers_list_request( subscription_id=self._config.subscription_id, - api_version=api_version, expand=expand, - template_url=self.list.metadata['url'], + 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.url = self._client.format_url(request.url) # type: ignore else: - - request = build_providers_list_request( - subscription_id=self._config.subscription_id, - template_url=next_link, - ) + # make call to next link with the client's api-version + _parsed_next_link = urlparse(next_link) + _next_request_params = case_insensitive_dict(parse_qs(_parsed_next_link.query)) + _next_request_params["api-version"] = self._config.api_version + request = HttpRequest("GET", urljoin(next_link, _parsed_next_link.path), params=_next_request_params) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore request.method = "GET" return request @@ -4362,10 +5767,8 @@ async def extract_data(pipeline_response): async def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) response = pipeline_response.http_response @@ -4375,18 +5778,12 @@ async def get_next(next_link=None): return pipeline_response + return AsyncItemPaged(get_next, extract_data) - return AsyncItemPaged( - get_next, extract_data - ) - list.metadata = {'url': "/subscriptions/{subscriptionId}/providers"} # type: ignore + list.metadata = {"url": "/subscriptions/{subscriptionId}/providers"} # type: ignore @distributed_trace - def list_at_tenant_scope( - self, - expand: Optional[str] = None, - **kwargs: Any - ) -> AsyncIterable["_models.ProviderListResult"]: + def list_at_tenant_scope(self, expand: Optional[str] = None, **kwargs: Any) -> AsyncIterable["_models.Provider"]: """Gets all resource providers for the tenant. :param expand: The properties to include in the results. For example, use &$expand=metadata in @@ -4394,36 +5791,46 @@ def list_at_tenant_scope( response, use $expand=resourceTypes/aliases. Default value is None. :type expand: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either ProviderListResult or the result of cls(response) + :return: An iterator like instance of either Provider or the result of cls(response) :rtype: - ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.resource.resources.v2021_04_01.models.ProviderListResult] - :raises: ~azure.core.exceptions.HttpResponseError + ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.resource.resources.v2021_04_01.models.Provider] + :raises ~azure.core.exceptions.HttpResponseError: """ - api_version = kwargs.pop('api_version', "2021-04-01") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-04-01")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[_models.ProviderListResult] - cls = kwargs.pop('cls', None) # type: ClsType["_models.ProviderListResult"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) + def prepare_request(next_link=None): if not next_link: - + request = build_providers_list_at_tenant_scope_request( - api_version=api_version, expand=expand, - template_url=self.list_at_tenant_scope.metadata['url'], + api_version=api_version, + template_url=self.list_at_tenant_scope.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore else: - - request = build_providers_list_at_tenant_scope_request( - template_url=next_link, - ) + # make call to next link with the client's api-version + _parsed_next_link = urlparse(next_link) + _next_request_params = case_insensitive_dict(parse_qs(_parsed_next_link.query)) + _next_request_params["api-version"] = self._config.api_version + request = HttpRequest("GET", urljoin(next_link, _parsed_next_link.path), params=_next_request_params) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore request.method = "GET" return request @@ -4437,10 +5844,8 @@ async def extract_data(pipeline_response): async def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) response = pipeline_response.http_response @@ -4450,229 +5855,231 @@ async def get_next(next_link=None): return pipeline_response + return AsyncItemPaged(get_next, extract_data) - return AsyncItemPaged( - get_next, extract_data - ) - list_at_tenant_scope.metadata = {'url': "/providers"} # type: ignore + list_at_tenant_scope.metadata = {"url": "/providers"} # type: ignore @distributed_trace_async async def get( - self, - resource_provider_namespace: str, - expand: Optional[str] = None, - **kwargs: Any - ) -> "_models.Provider": + self, resource_provider_namespace: str, expand: Optional[str] = None, **kwargs: Any + ) -> _models.Provider: """Gets the specified resource provider. - :param resource_provider_namespace: The namespace of the resource provider. + :param resource_provider_namespace: The namespace of the resource provider. Required. :type resource_provider_namespace: str :param expand: The $expand query parameter. For example, to include property aliases in response, use $expand=resourceTypes/aliases. Default value is None. :type expand: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: Provider, or the result of cls(response) + :return: Provider or the result of cls(response) :rtype: ~azure.mgmt.resource.resources.v2021_04_01.models.Provider - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.Provider"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) - api_version = kwargs.pop('api_version', "2021-04-01") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-04-01")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[_models.Provider] - request = build_providers_get_request( resource_provider_namespace=resource_provider_namespace, subscription_id=self._config.subscription_id, - api_version=api_version, expand=expand, - template_url=self.get.metadata['url'], + api_version=api_version, + template_url=self.get.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) - deserialized = self._deserialize('Provider', pipeline_response) + deserialized = self._deserialize("Provider", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - get.metadata = {'url': "/subscriptions/{subscriptionId}/providers/{resourceProviderNamespace}"} # type: ignore - + get.metadata = {"url": "/subscriptions/{subscriptionId}/providers/{resourceProviderNamespace}"} # type: ignore @distributed_trace_async async def get_at_tenant_scope( - self, - resource_provider_namespace: str, - expand: Optional[str] = None, - **kwargs: Any - ) -> "_models.Provider": + self, resource_provider_namespace: str, expand: Optional[str] = None, **kwargs: Any + ) -> _models.Provider: """Gets the specified resource provider at the tenant level. - :param resource_provider_namespace: The namespace of the resource provider. + :param resource_provider_namespace: The namespace of the resource provider. Required. :type resource_provider_namespace: str :param expand: The $expand query parameter. For example, to include property aliases in response, use $expand=resourceTypes/aliases. Default value is None. :type expand: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: Provider, or the result of cls(response) + :return: Provider or the result of cls(response) :rtype: ~azure.mgmt.resource.resources.v2021_04_01.models.Provider - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.Provider"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + 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', "2021-04-01") # type: str + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-04-01")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[_models.Provider] - request = build_providers_get_at_tenant_scope_request( resource_provider_namespace=resource_provider_namespace, - api_version=api_version, expand=expand, - template_url=self.get_at_tenant_scope.metadata['url'], + api_version=api_version, + template_url=self.get_at_tenant_scope.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) - deserialized = self._deserialize('Provider', pipeline_response) + deserialized = self._deserialize("Provider", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - get_at_tenant_scope.metadata = {'url': "/providers/{resourceProviderNamespace}"} # type: ignore + get_at_tenant_scope.metadata = {"url": "/providers/{resourceProviderNamespace}"} # type: ignore -class ProviderResourceTypesOperations: - """ProviderResourceTypesOperations async operations. - You should not instantiate this class directly. Instead, you should create a Client instance that - instantiates it for you and attaches it as an attribute. +class ProviderResourceTypesOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. - :ivar models: Alias to model classes used in this operation group. - :type models: ~azure.mgmt.resource.resources.v2021_04_01.models - :param client: Client for service requests. - :param config: Configuration of service client. - :param serializer: An object model serializer. - :param deserializer: An object model deserializer. + Instead, you should access the following operations through + :class:`~azure.mgmt.resource.resources.v2021_04_01.aio.ResourceManagementClient`'s + :attr:`provider_resource_types` attribute. """ models = _models - def __init__(self, client, config, serializer, deserializer) -> None: - self._client = client - self._serialize = serializer - self._deserialize = deserializer - self._config = config + def __init__(self, *args, **kwargs) -> None: + input_args = list(args) + self._client = input_args.pop(0) if input_args else kwargs.pop("client") + self._config = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") @distributed_trace_async async def list( - self, - resource_provider_namespace: str, - expand: Optional[str] = None, - **kwargs: Any - ) -> "_models.ProviderResourceTypeListResult": + self, resource_provider_namespace: str, expand: Optional[str] = None, **kwargs: Any + ) -> _models.ProviderResourceTypeListResult: """List the resource types for a specified resource provider. - :param resource_provider_namespace: The namespace of the resource provider. + :param resource_provider_namespace: The namespace of the resource provider. Required. :type resource_provider_namespace: str :param expand: The $expand query parameter. For example, to include property aliases in response, use $expand=resourceTypes/aliases. Default value is None. :type expand: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: ProviderResourceTypeListResult, or the result of cls(response) + :return: ProviderResourceTypeListResult or the result of cls(response) :rtype: ~azure.mgmt.resource.resources.v2021_04_01.models.ProviderResourceTypeListResult - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.ProviderResourceTypeListResult"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) - api_version = kwargs.pop('api_version', "2021-04-01") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-04-01")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[_models.ProviderResourceTypeListResult] - request = build_provider_resource_types_list_request( resource_provider_namespace=resource_provider_namespace, subscription_id=self._config.subscription_id, - api_version=api_version, expand=expand, - template_url=self.list.metadata['url'], + 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.url = self._client.format_url(request.url) # type: ignore - pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) - deserialized = self._deserialize('ProviderResourceTypeListResult', pipeline_response) + deserialized = self._deserialize("ProviderResourceTypeListResult", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - list.metadata = {'url': "/subscriptions/{subscriptionId}/providers/{resourceProviderNamespace}/resourceTypes"} # type: ignore + list.metadata = {"url": "/subscriptions/{subscriptionId}/providers/{resourceProviderNamespace}/resourceTypes"} # type: ignore -class ResourcesOperations: # pylint: disable=too-many-public-methods - """ResourcesOperations async operations. - You should not instantiate this class directly. Instead, you should create a Client instance that - instantiates it for you and attaches it as an attribute. +class ResourcesOperations: # pylint: disable=too-many-public-methods + """ + .. warning:: + **DO NOT** instantiate this class directly. - :ivar models: Alias to model classes used in this operation group. - :type models: ~azure.mgmt.resource.resources.v2021_04_01.models - :param client: Client for service requests. - :param config: Configuration of service client. - :param serializer: An object model serializer. - :param deserializer: An object model deserializer. + Instead, you should access the following operations through + :class:`~azure.mgmt.resource.resources.v2021_04_01.aio.ResourceManagementClient`'s + :attr:`resources` attribute. """ models = _models - def __init__(self, client, config, serializer, deserializer) -> None: - self._client = client - self._serialize = serializer - self._deserialize = deserializer - self._config = config + def __init__(self, *args, **kwargs) -> None: + input_args = list(args) + self._client = input_args.pop(0) if input_args else kwargs.pop("client") + self._config = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") @distributed_trace def list_by_resource_group( @@ -4682,10 +6089,10 @@ def list_by_resource_group( expand: Optional[str] = None, top: Optional[int] = None, **kwargs: Any - ) -> AsyncIterable["_models.ResourceListResult"]: + ) -> AsyncIterable["_models.GenericResourceExpanded"]: """Get all the resources for a resource group. - :param resource_group_name: The resource group with the resources to get. + :param resource_group_name: The resource group with the resources to get. Required. :type resource_group_name: str :param filter: The filter to apply on the operation.:code:`
`:code:`
`The properties you can use for eq (equals) or ne (not equals) are: location, resourceType, name, resourceGroup, @@ -4711,42 +6118,51 @@ def list_by_resource_group( value is None. :type top: int :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either ResourceListResult or the result of cls(response) + :return: An iterator like instance of either GenericResourceExpanded or the result of + cls(response) :rtype: - ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.resource.resources.v2021_04_01.models.ResourceListResult] - :raises: ~azure.core.exceptions.HttpResponseError + ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.resource.resources.v2021_04_01.models.GenericResourceExpanded] + :raises ~azure.core.exceptions.HttpResponseError: """ - api_version = kwargs.pop('api_version', "2021-04-01") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-04-01")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[_models.ResourceListResult] - cls = kwargs.pop('cls', None) # type: ClsType["_models.ResourceListResult"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) + def prepare_request(next_link=None): if not next_link: - + request = build_resources_list_by_resource_group_request( resource_group_name=resource_group_name, subscription_id=self._config.subscription_id, - api_version=api_version, filter=filter, expand=expand, top=top, - template_url=self.list_by_resource_group.metadata['url'], + 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.url = self._client.format_url(request.url) # type: ignore else: - - request = build_resources_list_by_resource_group_request( - resource_group_name=resource_group_name, - subscription_id=self._config.subscription_id, - template_url=next_link, - ) + # make call to next link with the client's api-version + _parsed_next_link = urlparse(next_link) + _next_request_params = case_insensitive_dict(parse_qs(_parsed_next_link.query)) + _next_request_params["api-version"] = self._config.api_version + request = HttpRequest("GET", urljoin(next_link, _parsed_next_link.path), params=_next_request_params) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore request.method = "GET" return request @@ -4760,10 +6176,8 @@ async def extract_data(pipeline_response): async def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) response = pipeline_response.http_response @@ -4773,45 +6187,54 @@ async def get_next(next_link=None): return pipeline_response + return AsyncItemPaged(get_next, extract_data) - return AsyncItemPaged( - get_next, extract_data - ) - list_by_resource_group.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/resources"} # type: ignore + list_by_resource_group.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/resources"} # type: ignore async def _move_resources_initial( # pylint: disable=inconsistent-return-statements - self, - source_resource_group_name: str, - parameters: "_models.ResourcesMoveInfo", - **kwargs: Any + self, source_resource_group_name: str, parameters: Union[_models.ResourcesMoveInfo, IO], **kwargs: Any ) -> None: - cls = kwargs.pop('cls', None) # type: ClsType[None] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) - api_version = kwargs.pop('api_version', "2021-04-01") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - _json = self._serialize.body(parameters, 'ResourcesMoveInfo') + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-04-01")) # type: str + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[None] - request = build_resources_move_resources_request_initial( + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(parameters, (IO, bytes)): + _content = parameters + else: + _json = self._serialize.body(parameters, "ResourcesMoveInfo") + + request = build_resources_move_resources_request( source_resource_group_name=source_resource_group_name, subscription_id=self._config.subscription_id, api_version=api_version, content_type=content_type, json=_json, - template_url=self._move_resources_initial.metadata['url'], + content=_content, + template_url=self._move_resources_initial.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [202, 204]: @@ -4821,14 +6244,15 @@ async def _move_resources_initial( # pylint: disable=inconsistent-return-statem if cls: return cls(pipeline_response, None, {}) - _move_resources_initial.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{sourceResourceGroupName}/moveResources"} # type: ignore - + _move_resources_initial.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{sourceResourceGroupName}/moveResources"} # type: ignore - @distributed_trace_async - async def begin_move_resources( # pylint: disable=inconsistent-return-statements + @overload + async def begin_move_resources( self, source_resource_group_name: str, - parameters: "_models.ResourcesMoveInfo", + parameters: _models.ResourcesMoveInfo, + *, + content_type: str = "application/json", **kwargs: Any ) -> AsyncLROPoller[None]: """Moves resources from one resource group to another resource group. @@ -4839,10 +6263,13 @@ async def begin_move_resources( # pylint: disable=inconsistent-return-statement operation. Write and delete operations are blocked on the groups until the move completes. :param source_resource_group_name: The name of the resource group from the source subscription - containing the resources to be moved. + containing the resources to be moved. Required. :type source_resource_group_name: str - :param parameters: Parameters for moving resources. + :param parameters: Parameters for moving resources. Required. :type parameters: ~azure.mgmt.resource.resources.v2021_04_01.models.ResourcesMoveInfo + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str :keyword callable cls: A custom type or function that will be passed the direct response :keyword str continuation_token: A continuation token to restart a poller from a saved state. :keyword polling: By default, your polling method will be AsyncARMPolling. Pass in False for @@ -4853,80 +6280,160 @@ async def begin_move_resources( # pylint: disable=inconsistent-return-statement Retry-After header is present. :return: An instance of AsyncLROPoller that returns either None or the result of cls(response) :rtype: ~azure.core.polling.AsyncLROPoller[None] - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - api_version = kwargs.pop('api_version', "2021-04-01") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] - polling = kwargs.pop('polling', True) # type: Union[bool, AsyncPollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType[None] - lro_delay = kwargs.pop( - 'polling_interval', - self._config.polling_interval - ) - cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] + + @overload + async def begin_move_resources( + self, source_resource_group_name: str, parameters: IO, *, content_type: str = "application/json", **kwargs: Any + ) -> AsyncLROPoller[None]: + """Moves resources from one resource group to another resource group. + + The resources to be moved must be in the same source resource group in the source subscription + being used. The target resource group may be in a different subscription. When moving + resources, both the source group and the target group are locked for the duration of the + operation. Write and delete operations are blocked on the groups until the move completes. + + :param source_resource_group_name: The name of the resource group from the source subscription + containing the resources to be moved. Required. + :type source_resource_group_name: str + :param parameters: Parameters for moving resources. Required. + :type parameters: IO + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be AsyncARMPolling. Pass in False for + this operation to not poll, or pass in your own initialized polling object for a personal + polling strategy. + :paramtype polling: bool or ~azure.core.polling.AsyncPollingMethod + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of AsyncLROPoller that returns either None or the result of cls(response) + :rtype: ~azure.core.polling.AsyncLROPoller[None] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace_async + async def begin_move_resources( + self, source_resource_group_name: str, parameters: Union[_models.ResourcesMoveInfo, IO], **kwargs: Any + ) -> AsyncLROPoller[None]: + """Moves resources from one resource group to another resource group. + + The resources to be moved must be in the same source resource group in the source subscription + being used. The target resource group may be in a different subscription. When moving + resources, both the source group and the target group are locked for the duration of the + operation. Write and delete operations are blocked on the groups until the move completes. + + :param source_resource_group_name: The name of the resource group from the source subscription + containing the resources to be moved. Required. + :type source_resource_group_name: str + :param parameters: Parameters for moving resources. Is either a model type or a IO type. + Required. + :type parameters: ~azure.mgmt.resource.resources.v2021_04_01.models.ResourcesMoveInfo or IO + :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. + Default value is None. + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be AsyncARMPolling. Pass in False for + this operation to not poll, or pass in your own initialized polling object for a personal + polling strategy. + :paramtype polling: bool or ~azure.core.polling.AsyncPollingMethod + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of AsyncLROPoller that returns either None or the result of cls(response) + :rtype: ~azure.core.polling.AsyncLROPoller[None] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _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-04-01")) # type: str + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[None] + polling = kwargs.pop("polling", True) # type: Union[bool, AsyncPollingMethod] + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token = kwargs.pop("continuation_token", None) # type: Optional[str] if cont_token is None: - raw_result = await self._move_resources_initial( + raw_result = await self._move_resources_initial( # type: ignore source_resource_group_name=source_resource_group_name, parameters=parameters, api_version=api_version, content_type=content_type, - cls=lambda x,y,z: x, + cls=lambda x, y, z: x, + headers=_headers, + params=_params, **kwargs ) - kwargs.pop('error_map', None) + kwargs.pop("error_map", None) - def get_long_running_output(pipeline_response): + def get_long_running_output(pipeline_response): # pylint: disable=inconsistent-return-statements if cls: return cls(pipeline_response, None, {}) - - if polling is True: polling_method = AsyncARMPolling(lro_delay, **kwargs) - elif polling is False: polling_method = AsyncNoPolling() - else: polling_method = polling + if polling is True: + polling_method = cast(AsyncPollingMethod, AsyncARMPolling(lro_delay, **kwargs)) # type: AsyncPollingMethod + elif polling is False: + polling_method = cast(AsyncPollingMethod, AsyncNoPolling()) + else: + polling_method = polling if cont_token: return AsyncLROPoller.from_continuation_token( polling_method=polling_method, continuation_token=cont_token, client=self._client, - deserialization_callback=get_long_running_output + deserialization_callback=get_long_running_output, ) return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) - begin_move_resources.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{sourceResourceGroupName}/moveResources"} # type: ignore + begin_move_resources.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{sourceResourceGroupName}/moveResources"} # type: ignore async def _validate_move_resources_initial( # pylint: disable=inconsistent-return-statements - self, - source_resource_group_name: str, - parameters: "_models.ResourcesMoveInfo", - **kwargs: Any + self, source_resource_group_name: str, parameters: Union[_models.ResourcesMoveInfo, IO], **kwargs: Any ) -> None: - cls = kwargs.pop('cls', None) # type: ClsType[None] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) - api_version = kwargs.pop('api_version', "2021-04-01") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - _json = self._serialize.body(parameters, 'ResourcesMoveInfo') + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-04-01")) # type: str + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[None] + + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(parameters, (IO, bytes)): + _content = parameters + else: + _json = self._serialize.body(parameters, "ResourcesMoveInfo") - request = build_resources_validate_move_resources_request_initial( + request = build_resources_validate_move_resources_request( source_resource_group_name=source_resource_group_name, subscription_id=self._config.subscription_id, api_version=api_version, content_type=content_type, json=_json, - template_url=self._validate_move_resources_initial.metadata['url'], + content=_content, + template_url=self._validate_move_resources_initial.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [202, 204]: @@ -4936,14 +6443,15 @@ async def _validate_move_resources_initial( # pylint: disable=inconsistent-retu if cls: return cls(pipeline_response, None, {}) - _validate_move_resources_initial.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{sourceResourceGroupName}/validateMoveResources"} # type: ignore - + _validate_move_resources_initial.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{sourceResourceGroupName}/validateMoveResources"} # type: ignore - @distributed_trace_async - async def begin_validate_move_resources( # pylint: disable=inconsistent-return-statements + @overload + async def begin_validate_move_resources( self, source_resource_group_name: str, - parameters: "_models.ResourcesMoveInfo", + parameters: _models.ResourcesMoveInfo, + *, + content_type: str = "application/json", **kwargs: Any ) -> AsyncLROPoller[None]: """Validates whether resources can be moved from one resource group to another resource group. @@ -4956,10 +6464,13 @@ async def begin_validate_move_resources( # pylint: disable=inconsistent-return- the result of the long-running operation. :param source_resource_group_name: The name of the resource group from the source subscription - containing the resources to be validated for move. + containing the resources to be validated for move. Required. :type source_resource_group_name: str - :param parameters: Parameters for moving resources. + :param parameters: Parameters for moving resources. Required. :type parameters: ~azure.mgmt.resource.resources.v2021_04_01.models.ResourcesMoveInfo + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str :keyword callable cls: A custom type or function that will be passed the direct response :keyword str continuation_token: A continuation token to restart a poller from a saved state. :keyword polling: By default, your polling method will be AsyncARMPolling. Pass in False for @@ -4970,55 +6481,124 @@ async def begin_validate_move_resources( # pylint: disable=inconsistent-return- Retry-After header is present. :return: An instance of AsyncLROPoller that returns either None or the result of cls(response) :rtype: ~azure.core.polling.AsyncLROPoller[None] - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - api_version = kwargs.pop('api_version', "2021-04-01") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] - polling = kwargs.pop('polling', True) # type: Union[bool, AsyncPollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType[None] - lro_delay = kwargs.pop( - 'polling_interval', - self._config.polling_interval - ) - cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] + + @overload + async def begin_validate_move_resources( + self, source_resource_group_name: str, parameters: IO, *, content_type: str = "application/json", **kwargs: Any + ) -> AsyncLROPoller[None]: + """Validates whether resources can be moved from one resource group to another resource group. + + This operation checks whether the specified resources can be moved to the target. The resources + to be moved must be in the same source resource group in the source subscription being used. + The target resource group may be in a different subscription. If validation succeeds, it + returns HTTP response code 204 (no content). If validation fails, it returns HTTP response code + 409 (Conflict) with an error message. Retrieve the URL in the Location header value to check + the result of the long-running operation. + + :param source_resource_group_name: The name of the resource group from the source subscription + containing the resources to be validated for move. Required. + :type source_resource_group_name: str + :param parameters: Parameters for moving resources. Required. + :type parameters: IO + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be AsyncARMPolling. Pass in False for + this operation to not poll, or pass in your own initialized polling object for a personal + polling strategy. + :paramtype polling: bool or ~azure.core.polling.AsyncPollingMethod + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of AsyncLROPoller that returns either None or the result of cls(response) + :rtype: ~azure.core.polling.AsyncLROPoller[None] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace_async + async def begin_validate_move_resources( + self, source_resource_group_name: str, parameters: Union[_models.ResourcesMoveInfo, IO], **kwargs: Any + ) -> AsyncLROPoller[None]: + """Validates whether resources can be moved from one resource group to another resource group. + + This operation checks whether the specified resources can be moved to the target. The resources + to be moved must be in the same source resource group in the source subscription being used. + The target resource group may be in a different subscription. If validation succeeds, it + returns HTTP response code 204 (no content). If validation fails, it returns HTTP response code + 409 (Conflict) with an error message. Retrieve the URL in the Location header value to check + the result of the long-running operation. + + :param source_resource_group_name: The name of the resource group from the source subscription + containing the resources to be validated for move. Required. + :type source_resource_group_name: str + :param parameters: Parameters for moving resources. Is either a model type or a IO type. + Required. + :type parameters: ~azure.mgmt.resource.resources.v2021_04_01.models.ResourcesMoveInfo or IO + :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. + Default value is None. + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be AsyncARMPolling. Pass in False for + this operation to not poll, or pass in your own initialized polling object for a personal + polling strategy. + :paramtype polling: bool or ~azure.core.polling.AsyncPollingMethod + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of AsyncLROPoller that returns either None or the result of cls(response) + :rtype: ~azure.core.polling.AsyncLROPoller[None] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _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-04-01")) # type: str + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[None] + polling = kwargs.pop("polling", True) # type: Union[bool, AsyncPollingMethod] + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token = kwargs.pop("continuation_token", None) # type: Optional[str] if cont_token is None: - raw_result = await self._validate_move_resources_initial( + raw_result = await self._validate_move_resources_initial( # type: ignore source_resource_group_name=source_resource_group_name, parameters=parameters, api_version=api_version, content_type=content_type, - cls=lambda x,y,z: x, + cls=lambda x, y, z: x, + headers=_headers, + params=_params, **kwargs ) - kwargs.pop('error_map', None) + kwargs.pop("error_map", None) - def get_long_running_output(pipeline_response): + def get_long_running_output(pipeline_response): # pylint: disable=inconsistent-return-statements if cls: return cls(pipeline_response, None, {}) - - if polling is True: polling_method = AsyncARMPolling(lro_delay, **kwargs) - elif polling is False: polling_method = AsyncNoPolling() - else: polling_method = polling + if polling is True: + polling_method = cast(AsyncPollingMethod, AsyncARMPolling(lro_delay, **kwargs)) # type: AsyncPollingMethod + elif polling is False: + polling_method = cast(AsyncPollingMethod, AsyncNoPolling()) + else: + polling_method = polling if cont_token: return AsyncLROPoller.from_continuation_token( polling_method=polling_method, continuation_token=cont_token, client=self._client, - deserialization_callback=get_long_running_output + deserialization_callback=get_long_running_output, ) return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) - begin_validate_move_resources.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{sourceResourceGroupName}/validateMoveResources"} # type: ignore + begin_validate_move_resources.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{sourceResourceGroupName}/validateMoveResources"} # type: ignore @distributed_trace def list( - self, - filter: Optional[str] = None, - expand: Optional[str] = None, - top: Optional[int] = None, - **kwargs: Any - ) -> AsyncIterable["_models.ResourceListResult"]: + self, filter: Optional[str] = None, expand: Optional[str] = None, top: Optional[int] = None, **kwargs: Any + ) -> AsyncIterable["_models.GenericResourceExpanded"]: """Get all the resources in a subscription. :param filter: The filter to apply on the operation.:code:`
`:code:`
`Filter comparison @@ -5051,44 +6631,54 @@ def list( Valid values include ``createdTime``\ , ``changedTime`` and ``provisioningState``. For example, ``$expand=createdTime,changedTime``. Default value is None. :type expand: str - :param top: The number of results to return. If null is passed, returns all resources. Default - value is None. + :param top: The number of recommendations per page if a paged version of this API is being + used. Default value is None. :type top: int :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either ResourceListResult or the result of cls(response) + :return: An iterator like instance of either GenericResourceExpanded or the result of + cls(response) :rtype: - ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.resource.resources.v2021_04_01.models.ResourceListResult] - :raises: ~azure.core.exceptions.HttpResponseError + ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.resource.resources.v2021_04_01.models.GenericResourceExpanded] + :raises ~azure.core.exceptions.HttpResponseError: """ - api_version = kwargs.pop('api_version', "2021-04-01") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-04-01")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[_models.ResourceListResult] - cls = kwargs.pop('cls', None) # type: ClsType["_models.ResourceListResult"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) + def prepare_request(next_link=None): if not next_link: - + request = build_resources_list_request( subscription_id=self._config.subscription_id, - api_version=api_version, filter=filter, expand=expand, top=top, - template_url=self.list.metadata['url'], + 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.url = self._client.format_url(request.url) # type: ignore else: - - request = build_resources_list_request( - subscription_id=self._config.subscription_id, - template_url=next_link, - ) + # make call to next link with the client's api-version + _parsed_next_link = urlparse(next_link) + _next_request_params = case_insensitive_dict(parse_qs(_parsed_next_link.query)) + _next_request_params["api-version"] = self._config.api_version + request = HttpRequest("GET", urljoin(next_link, _parsed_next_link.path), params=_next_request_params) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore request.method = "GET" return request @@ -5102,10 +6692,8 @@ async def extract_data(pipeline_response): async def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) response = pipeline_response.http_response @@ -5115,11 +6703,9 @@ async def get_next(next_link=None): return pipeline_response + return AsyncItemPaged(get_next, extract_data) - return AsyncItemPaged( - get_next, extract_data - ) - list.metadata = {'url': "/subscriptions/{subscriptionId}/resources"} # type: ignore + list.metadata = {"url": "/subscriptions/{subscriptionId}/resources"} # type: ignore @distributed_trace_async async def check_existence( @@ -5135,30 +6721,36 @@ async def check_existence( """Checks whether a resource exists. :param resource_group_name: The name of the resource group containing the resource to check. - The name is case insensitive. + The name is case insensitive. Required. :type resource_group_name: str - :param resource_provider_namespace: The resource provider of the resource to check. + :param resource_provider_namespace: The resource provider of the resource to check. Required. :type resource_provider_namespace: str - :param parent_resource_path: The parent resource identity. + :param parent_resource_path: The parent resource identity. Required. :type parent_resource_path: str - :param resource_type: The resource type. + :param resource_type: The resource type. Required. :type resource_type: str - :param resource_name: The name of the resource to check whether it exists. + :param resource_name: The name of the resource to check whether it exists. Required. :type resource_name: str - :param api_version: The API version to use for the operation. + :param api_version: The API version to use for the operation. Required. :type api_version: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: bool, or the result of cls(response) + :return: bool or the result of cls(response) :rtype: bool - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType[None] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = kwargs.pop("params", {}) or {} + + cls = kwargs.pop("cls", None) # type: ClsType[None] - request = build_resources_check_existence_request( resource_group_name=resource_group_name, resource_provider_namespace=resource_provider_namespace, @@ -5167,16 +6759,17 @@ async def check_existence( resource_name=resource_name, subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.check_existence.metadata['url'], + template_url=self.check_existence.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [204, 404]: @@ -5187,8 +6780,7 @@ async def check_existence( return cls(pipeline_response, None, {}) return 200 <= response.status_code <= 299 - check_existence.metadata = {'url': "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{parentResourcePath}/{resourceType}/{resourceName}"} # type: ignore - + check_existence.metadata = {"url": "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{parentResourcePath}/{resourceType}/{resourceName}"} # type: ignore async def _delete_initial( # pylint: disable=inconsistent-return-statements self, @@ -5200,14 +6792,20 @@ async def _delete_initial( # pylint: disable=inconsistent-return-statements api_version: str, **kwargs: Any ) -> None: - cls = kwargs.pop('cls', None) # type: ClsType[None] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = kwargs.pop("params", {}) or {} - - request = build_resources_delete_request_initial( + cls = kwargs.pop("cls", None) # type: ClsType[None] + + request = build_resources_delete_request( resource_group_name=resource_group_name, resource_provider_namespace=resource_provider_namespace, parent_resource_path=parent_resource_path, @@ -5215,16 +6813,17 @@ async def _delete_initial( # pylint: disable=inconsistent-return-statements resource_name=resource_name, subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self._delete_initial.metadata['url'], + template_url=self._delete_initial.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200, 202, 204]: @@ -5234,11 +6833,10 @@ 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/{resourceProviderNamespace}/{parentResourcePath}/{resourceType}/{resourceName}"} # type: ignore - + _delete_initial.metadata = {"url": "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{parentResourcePath}/{resourceType}/{resourceName}"} # type: ignore @distributed_trace_async - async def begin_delete( # pylint: disable=inconsistent-return-statements + async def begin_delete( self, resource_group_name: str, resource_provider_namespace: str, @@ -5251,17 +6849,17 @@ async def begin_delete( # pylint: disable=inconsistent-return-statements """Deletes a resource. :param resource_group_name: The name of the resource group that contains the resource to - delete. The name is case insensitive. + delete. The name is case insensitive. Required. :type resource_group_name: str - :param resource_provider_namespace: The namespace of the resource provider. + :param resource_provider_namespace: The namespace of the resource provider. Required. :type resource_provider_namespace: str - :param parent_resource_path: The parent resource identity. + :param parent_resource_path: The parent resource identity. Required. :type parent_resource_path: str - :param resource_type: The resource type. + :param resource_type: The resource type. Required. :type resource_type: str - :param resource_name: The name of the resource to delete. + :param resource_name: The name of the resource to delete. Required. :type resource_name: str - :param api_version: The API version to use for the operation. + :param api_version: The API version to use for the operation. Required. :type api_version: str :keyword callable cls: A custom type or function that will be passed the direct response :keyword str continuation_token: A continuation token to restart a poller from a saved state. @@ -5273,46 +6871,50 @@ async def begin_delete( # pylint: disable=inconsistent-return-statements Retry-After header is present. :return: An instance of AsyncLROPoller that returns either None or the result of cls(response) :rtype: ~azure.core.polling.AsyncLROPoller[None] - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - polling = kwargs.pop('polling', True) # type: Union[bool, AsyncPollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType[None] - lro_delay = kwargs.pop( - 'polling_interval', - self._config.polling_interval - ) - cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] + _headers = kwargs.pop("headers", {}) or {} + _params = kwargs.pop("params", {}) or {} + + cls = kwargs.pop("cls", None) # type: ClsType[None] + polling = kwargs.pop("polling", True) # type: Union[bool, AsyncPollingMethod] + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token = kwargs.pop("continuation_token", None) # type: Optional[str] if cont_token is None: - raw_result = await self._delete_initial( + raw_result = await self._delete_initial( # type: ignore resource_group_name=resource_group_name, resource_provider_namespace=resource_provider_namespace, parent_resource_path=parent_resource_path, resource_type=resource_type, resource_name=resource_name, api_version=api_version, - cls=lambda x,y,z: x, + cls=lambda x, y, z: x, + headers=_headers, + params=_params, **kwargs ) - kwargs.pop('error_map', None) + kwargs.pop("error_map", None) - def get_long_running_output(pipeline_response): + def get_long_running_output(pipeline_response): # pylint: disable=inconsistent-return-statements if cls: return cls(pipeline_response, None, {}) - - if polling is True: polling_method = AsyncARMPolling(lro_delay, **kwargs) - elif polling is False: polling_method = AsyncNoPolling() - else: polling_method = polling + if polling is True: + polling_method = cast(AsyncPollingMethod, AsyncARMPolling(lro_delay, **kwargs)) # type: AsyncPollingMethod + elif polling is False: + polling_method = cast(AsyncPollingMethod, AsyncNoPolling()) + else: + polling_method = polling if cont_token: return AsyncLROPoller.from_continuation_token( polling_method=polling_method, continuation_token=cont_token, client=self._client, - deserialization_callback=get_long_running_output + deserialization_callback=get_long_running_output, ) return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) - begin_delete.metadata = {'url': "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{parentResourcePath}/{resourceType}/{resourceName}"} # type: ignore + begin_delete.metadata = {"url": "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{parentResourcePath}/{resourceType}/{resourceName}"} # type: ignore async def _create_or_update_initial( self, @@ -5322,39 +6924,53 @@ async def _create_or_update_initial( resource_type: str, resource_name: str, api_version: str, - parameters: "_models.GenericResource", + parameters: Union[_models.GenericResource, IO], **kwargs: Any - ) -> Optional["_models.GenericResource"]: - cls = kwargs.pop('cls', None) # type: ClsType[Optional["_models.GenericResource"]] + ) -> Optional[_models.GenericResource]: error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = kwargs.pop("params", {}) or {} - _json = self._serialize.body(parameters, 'GenericResource') + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[Optional[_models.GenericResource]] - request = build_resources_create_or_update_request_initial( + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(parameters, (IO, bytes)): + _content = parameters + else: + _json = self._serialize.body(parameters, "GenericResource") + + request = build_resources_create_or_update_request( resource_group_name=resource_group_name, resource_provider_namespace=resource_provider_namespace, parent_resource_path=parent_resource_path, resource_type=resource_type, resource_name=resource_name, subscription_id=self._config.subscription_id, - content_type=content_type, api_version=api_version, + content_type=content_type, json=_json, - template_url=self._create_or_update_initial.metadata['url'], + content=_content, + template_url=self._create_or_update_initial.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200, 201, 202]: @@ -5363,18 +6979,115 @@ async def _create_or_update_initial( deserialized = None if response.status_code == 200: - deserialized = self._deserialize('GenericResource', pipeline_response) + deserialized = self._deserialize("GenericResource", pipeline_response) if response.status_code == 201: - deserialized = self._deserialize('GenericResource', pipeline_response) + deserialized = self._deserialize("GenericResource", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - _create_or_update_initial.metadata = {'url': "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{parentResourcePath}/{resourceType}/{resourceName}"} # type: ignore + _create_or_update_initial.metadata = {"url": "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{parentResourcePath}/{resourceType}/{resourceName}"} # type: ignore + @overload + async def begin_create_or_update( + self, + resource_group_name: str, + resource_provider_namespace: str, + parent_resource_path: str, + resource_type: str, + resource_name: str, + api_version: str, + parameters: _models.GenericResource, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> AsyncLROPoller[_models.GenericResource]: + """Creates a resource. + + :param resource_group_name: The name of the resource group for the resource. The name is case + insensitive. Required. + :type resource_group_name: str + :param resource_provider_namespace: The namespace of the resource provider. Required. + :type resource_provider_namespace: str + :param parent_resource_path: The parent resource identity. Required. + :type parent_resource_path: str + :param resource_type: The resource type of the resource to create. Required. + :type resource_type: str + :param resource_name: The name of the resource to create. Required. + :type resource_name: str + :param api_version: The API version to use for the operation. Required. + :type api_version: str + :param parameters: Parameters for creating or updating the resource. Required. + :type parameters: ~azure.mgmt.resource.resources.v2021_04_01.models.GenericResource + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be AsyncARMPolling. Pass in False for + this operation to not poll, or pass in your own initialized polling object for a personal + polling strategy. + :paramtype polling: bool or ~azure.core.polling.AsyncPollingMethod + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of AsyncLROPoller that returns either GenericResource or the result of + cls(response) + :rtype: + ~azure.core.polling.AsyncLROPoller[~azure.mgmt.resource.resources.v2021_04_01.models.GenericResource] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + async def begin_create_or_update( + self, + resource_group_name: str, + resource_provider_namespace: str, + parent_resource_path: str, + resource_type: str, + resource_name: str, + api_version: str, + parameters: IO, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> AsyncLROPoller[_models.GenericResource]: + """Creates a resource. + + :param resource_group_name: The name of the resource group for the resource. The name is case + insensitive. Required. + :type resource_group_name: str + :param resource_provider_namespace: The namespace of the resource provider. Required. + :type resource_provider_namespace: str + :param parent_resource_path: The parent resource identity. Required. + :type parent_resource_path: str + :param resource_type: The resource type of the resource to create. Required. + :type resource_type: str + :param resource_name: The name of the resource to create. Required. + :type resource_name: str + :param api_version: The API version to use for the operation. Required. + :type api_version: str + :param parameters: Parameters for creating or updating the resource. Required. + :type parameters: IO + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be AsyncARMPolling. Pass in False for + this operation to not poll, or pass in your own initialized polling object for a personal + polling strategy. + :paramtype polling: bool or ~azure.core.polling.AsyncPollingMethod + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of AsyncLROPoller that returns either GenericResource or the result of + cls(response) + :rtype: + ~azure.core.polling.AsyncLROPoller[~azure.mgmt.resource.resources.v2021_04_01.models.GenericResource] + :raises ~azure.core.exceptions.HttpResponseError: + """ @distributed_trace_async async def begin_create_or_update( @@ -5385,26 +7098,30 @@ async def begin_create_or_update( resource_type: str, resource_name: str, api_version: str, - parameters: "_models.GenericResource", + parameters: Union[_models.GenericResource, IO], **kwargs: Any - ) -> AsyncLROPoller["_models.GenericResource"]: + ) -> AsyncLROPoller[_models.GenericResource]: """Creates a resource. :param resource_group_name: The name of the resource group for the resource. The name is case - insensitive. + insensitive. Required. :type resource_group_name: str - :param resource_provider_namespace: The namespace of the resource provider. + :param resource_provider_namespace: The namespace of the resource provider. Required. :type resource_provider_namespace: str - :param parent_resource_path: The parent resource identity. + :param parent_resource_path: The parent resource identity. Required. :type parent_resource_path: str - :param resource_type: The resource type of the resource to create. + :param resource_type: The resource type of the resource to create. Required. :type resource_type: str - :param resource_name: The name of the resource to create. + :param resource_name: The name of the resource to create. Required. :type resource_name: str - :param api_version: The API version to use for the operation. + :param api_version: The API version to use for the operation. Required. :type api_version: str - :param parameters: Parameters for creating or updating the resource. - :type parameters: ~azure.mgmt.resource.resources.v2021_04_01.models.GenericResource + :param parameters: Parameters for creating or updating the resource. Is either a model type or + a IO type. Required. + :type parameters: ~azure.mgmt.resource.resources.v2021_04_01.models.GenericResource or IO + :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. + Default value is None. + :paramtype content_type: str :keyword callable cls: A custom type or function that will be passed the direct response :keyword str continuation_token: A continuation token to restart a poller from a saved state. :keyword polling: By default, your polling method will be AsyncARMPolling. Pass in False for @@ -5417,18 +7134,18 @@ async def begin_create_or_update( cls(response) :rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.resource.resources.v2021_04_01.models.GenericResource] - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] - polling = kwargs.pop('polling', True) # type: Union[bool, AsyncPollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType["_models.GenericResource"] - lro_delay = kwargs.pop( - 'polling_interval', - self._config.polling_interval - ) - cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = kwargs.pop("params", {}) or {} + + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.GenericResource] + polling = kwargs.pop("polling", True) # type: Union[bool, AsyncPollingMethod] + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token = kwargs.pop("continuation_token", None) # type: Optional[str] if cont_token is None: - raw_result = await self._create_or_update_initial( + raw_result = await self._create_or_update_initial( # type: ignore resource_group_name=resource_group_name, resource_provider_namespace=resource_provider_namespace, parent_resource_path=parent_resource_path, @@ -5437,32 +7154,35 @@ async def begin_create_or_update( api_version=api_version, parameters=parameters, content_type=content_type, - cls=lambda x,y,z: x, + cls=lambda x, y, z: x, + headers=_headers, + params=_params, **kwargs ) - kwargs.pop('error_map', None) + kwargs.pop("error_map", None) def get_long_running_output(pipeline_response): - response = pipeline_response.http_response - deserialized = self._deserialize('GenericResource', pipeline_response) + deserialized = self._deserialize("GenericResource", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - - if polling is True: polling_method = AsyncARMPolling(lro_delay, **kwargs) - elif polling is False: polling_method = AsyncNoPolling() - else: polling_method = polling + if polling is True: + polling_method = cast(AsyncPollingMethod, AsyncARMPolling(lro_delay, **kwargs)) # type: AsyncPollingMethod + elif polling is False: + polling_method = cast(AsyncPollingMethod, AsyncNoPolling()) + else: + polling_method = polling if cont_token: return AsyncLROPoller.from_continuation_token( polling_method=polling_method, continuation_token=cont_token, client=self._client, - deserialization_callback=get_long_running_output + deserialization_callback=get_long_running_output, ) return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) - begin_create_or_update.metadata = {'url': "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{parentResourcePath}/{resourceType}/{resourceName}"} # type: ignore + begin_create_or_update.metadata = {"url": "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{parentResourcePath}/{resourceType}/{resourceName}"} # type: ignore async def _update_initial( self, @@ -5472,39 +7192,53 @@ async def _update_initial( resource_type: str, resource_name: str, api_version: str, - parameters: "_models.GenericResource", + parameters: Union[_models.GenericResource, IO], **kwargs: Any - ) -> Optional["_models.GenericResource"]: - cls = kwargs.pop('cls', None) # type: ClsType[Optional["_models.GenericResource"]] + ) -> Optional[_models.GenericResource]: error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = kwargs.pop("params", {}) or {} - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[Optional[_models.GenericResource]] - _json = self._serialize.body(parameters, 'GenericResource') + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(parameters, (IO, bytes)): + _content = parameters + else: + _json = self._serialize.body(parameters, "GenericResource") - request = build_resources_update_request_initial( + request = build_resources_update_request( resource_group_name=resource_group_name, resource_provider_namespace=resource_provider_namespace, parent_resource_path=parent_resource_path, resource_type=resource_type, resource_name=resource_name, subscription_id=self._config.subscription_id, - content_type=content_type, api_version=api_version, + content_type=content_type, json=_json, - template_url=self._update_initial.metadata['url'], + content=_content, + template_url=self._update_initial.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200, 202]: @@ -5513,15 +7247,112 @@ async def _update_initial( deserialized = None if response.status_code == 200: - deserialized = self._deserialize('GenericResource', pipeline_response) + deserialized = self._deserialize("GenericResource", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - _update_initial.metadata = {'url': "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{parentResourcePath}/{resourceType}/{resourceName}"} # type: ignore + _update_initial.metadata = {"url": "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{parentResourcePath}/{resourceType}/{resourceName}"} # type: ignore + + @overload + async def begin_update( + self, + resource_group_name: str, + resource_provider_namespace: str, + parent_resource_path: str, + resource_type: str, + resource_name: str, + api_version: str, + parameters: _models.GenericResource, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> AsyncLROPoller[_models.GenericResource]: + """Updates a resource. + :param resource_group_name: The name of the resource group for the resource. The name is case + insensitive. Required. + :type resource_group_name: str + :param resource_provider_namespace: The namespace of the resource provider. Required. + :type resource_provider_namespace: str + :param parent_resource_path: The parent resource identity. Required. + :type parent_resource_path: str + :param resource_type: The resource type of the resource to update. Required. + :type resource_type: str + :param resource_name: The name of the resource to update. Required. + :type resource_name: str + :param api_version: The API version to use for the operation. Required. + :type api_version: str + :param parameters: Parameters for updating the resource. Required. + :type parameters: ~azure.mgmt.resource.resources.v2021_04_01.models.GenericResource + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be AsyncARMPolling. Pass in False for + this operation to not poll, or pass in your own initialized polling object for a personal + polling strategy. + :paramtype polling: bool or ~azure.core.polling.AsyncPollingMethod + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of AsyncLROPoller that returns either GenericResource or the result of + cls(response) + :rtype: + ~azure.core.polling.AsyncLROPoller[~azure.mgmt.resource.resources.v2021_04_01.models.GenericResource] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + async def begin_update( + self, + resource_group_name: str, + resource_provider_namespace: str, + parent_resource_path: str, + resource_type: str, + resource_name: str, + api_version: str, + parameters: IO, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> AsyncLROPoller[_models.GenericResource]: + """Updates a resource. + + :param resource_group_name: The name of the resource group for the resource. The name is case + insensitive. Required. + :type resource_group_name: str + :param resource_provider_namespace: The namespace of the resource provider. Required. + :type resource_provider_namespace: str + :param parent_resource_path: The parent resource identity. Required. + :type parent_resource_path: str + :param resource_type: The resource type of the resource to update. Required. + :type resource_type: str + :param resource_name: The name of the resource to update. Required. + :type resource_name: str + :param api_version: The API version to use for the operation. Required. + :type api_version: str + :param parameters: Parameters for updating the resource. Required. + :type parameters: IO + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be AsyncARMPolling. Pass in False for + this operation to not poll, or pass in your own initialized polling object for a personal + polling strategy. + :paramtype polling: bool or ~azure.core.polling.AsyncPollingMethod + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of AsyncLROPoller that returns either GenericResource or the result of + cls(response) + :rtype: + ~azure.core.polling.AsyncLROPoller[~azure.mgmt.resource.resources.v2021_04_01.models.GenericResource] + :raises ~azure.core.exceptions.HttpResponseError: + """ @distributed_trace_async async def begin_update( @@ -5532,26 +7363,30 @@ async def begin_update( resource_type: str, resource_name: str, api_version: str, - parameters: "_models.GenericResource", + parameters: Union[_models.GenericResource, IO], **kwargs: Any - ) -> AsyncLROPoller["_models.GenericResource"]: + ) -> AsyncLROPoller[_models.GenericResource]: """Updates a resource. :param resource_group_name: The name of the resource group for the resource. The name is case - insensitive. + insensitive. Required. :type resource_group_name: str - :param resource_provider_namespace: The namespace of the resource provider. + :param resource_provider_namespace: The namespace of the resource provider. Required. :type resource_provider_namespace: str - :param parent_resource_path: The parent resource identity. + :param parent_resource_path: The parent resource identity. Required. :type parent_resource_path: str - :param resource_type: The resource type of the resource to update. + :param resource_type: The resource type of the resource to update. Required. :type resource_type: str - :param resource_name: The name of the resource to update. + :param resource_name: The name of the resource to update. Required. :type resource_name: str - :param api_version: The API version to use for the operation. + :param api_version: The API version to use for the operation. Required. :type api_version: str - :param parameters: Parameters for updating the resource. - :type parameters: ~azure.mgmt.resource.resources.v2021_04_01.models.GenericResource + :param parameters: Parameters for updating the resource. Is either a model type or a IO type. + Required. + :type parameters: ~azure.mgmt.resource.resources.v2021_04_01.models.GenericResource or IO + :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. + Default value is None. + :paramtype content_type: str :keyword callable cls: A custom type or function that will be passed the direct response :keyword str continuation_token: A continuation token to restart a poller from a saved state. :keyword polling: By default, your polling method will be AsyncARMPolling. Pass in False for @@ -5564,18 +7399,18 @@ async def begin_update( cls(response) :rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.resource.resources.v2021_04_01.models.GenericResource] - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] - polling = kwargs.pop('polling', True) # type: Union[bool, AsyncPollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType["_models.GenericResource"] - lro_delay = kwargs.pop( - 'polling_interval', - self._config.polling_interval - ) - cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = kwargs.pop("params", {}) or {} + + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.GenericResource] + polling = kwargs.pop("polling", True) # type: Union[bool, AsyncPollingMethod] + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token = kwargs.pop("continuation_token", None) # type: Optional[str] if cont_token is None: - raw_result = await self._update_initial( + raw_result = await self._update_initial( # type: ignore resource_group_name=resource_group_name, resource_provider_namespace=resource_provider_namespace, parent_resource_path=parent_resource_path, @@ -5584,32 +7419,35 @@ async def begin_update( api_version=api_version, parameters=parameters, content_type=content_type, - cls=lambda x,y,z: x, + cls=lambda x, y, z: x, + headers=_headers, + params=_params, **kwargs ) - kwargs.pop('error_map', None) + kwargs.pop("error_map", None) def get_long_running_output(pipeline_response): - response = pipeline_response.http_response - deserialized = self._deserialize('GenericResource', pipeline_response) + deserialized = self._deserialize("GenericResource", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - - if polling is True: polling_method = AsyncARMPolling(lro_delay, **kwargs) - elif polling is False: polling_method = AsyncNoPolling() - else: polling_method = polling + if polling is True: + polling_method = cast(AsyncPollingMethod, AsyncARMPolling(lro_delay, **kwargs)) # type: AsyncPollingMethod + elif polling is False: + polling_method = cast(AsyncPollingMethod, AsyncNoPolling()) + else: + polling_method = polling if cont_token: return AsyncLROPoller.from_continuation_token( polling_method=polling_method, continuation_token=cont_token, client=self._client, - deserialization_callback=get_long_running_output + deserialization_callback=get_long_running_output, ) return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) - begin_update.metadata = {'url': "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{parentResourcePath}/{resourceType}/{resourceName}"} # type: ignore + begin_update.metadata = {"url": "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{parentResourcePath}/{resourceType}/{resourceName}"} # type: ignore @distributed_trace_async async def get( @@ -5621,34 +7459,40 @@ async def get( resource_name: str, api_version: str, **kwargs: Any - ) -> "_models.GenericResource": + ) -> _models.GenericResource: """Gets a resource. :param resource_group_name: The name of the resource group containing the resource to get. The - name is case insensitive. + name is case insensitive. Required. :type resource_group_name: str - :param resource_provider_namespace: The namespace of the resource provider. + :param resource_provider_namespace: The namespace of the resource provider. Required. :type resource_provider_namespace: str - :param parent_resource_path: The parent resource identity. + :param parent_resource_path: The parent resource identity. Required. :type parent_resource_path: str - :param resource_type: The resource type of the resource. + :param resource_type: The resource type of the resource. Required. :type resource_type: str - :param resource_name: The name of the resource to get. + :param resource_name: The name of the resource to get. Required. :type resource_name: str - :param api_version: The API version to use for the operation. + :param api_version: The API version to use for the operation. Required. :type api_version: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: GenericResource, or the result of cls(response) + :return: GenericResource or the result of cls(response) :rtype: ~azure.mgmt.resource.resources.v2021_04_01.models.GenericResource - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.GenericResource"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = kwargs.pop("params", {}) or {} + + cls = kwargs.pop("cls", None) # type: ClsType[_models.GenericResource] - request = build_resources_get_request( resource_group_name=resource_group_name, resource_provider_namespace=resource_provider_namespace, @@ -5657,72 +7501,78 @@ async def get( resource_name=resource_name, subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.get.metadata['url'], + template_url=self.get.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) - deserialized = self._deserialize('GenericResource', pipeline_response) + deserialized = self._deserialize("GenericResource", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - get.metadata = {'url': "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{parentResourcePath}/{resourceType}/{resourceName}"} # type: ignore - + get.metadata = {"url": "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{parentResourcePath}/{resourceType}/{resourceName}"} # type: ignore @distributed_trace_async - async def check_existence_by_id( - self, - resource_id: str, - api_version: str, - **kwargs: Any - ) -> bool: - """Checks by ID whether a resource exists. + async def check_existence_by_id(self, resource_id: str, api_version: str, **kwargs: Any) -> bool: + """Checks by ID whether a resource exists. This API currently works only for a limited set of + Resource providers. In the event that a Resource provider does not implement this API, ARM will + respond with a 405. The alternative then is to use the GET API to check for the existence of + the resource. :param resource_id: The fully qualified ID of the resource, including the resource name and resource type. Use the format, /subscriptions/{guid}/resourceGroups/{resource-group-name}/{resource-provider-namespace}/{resource-type}/{resource-name}. + Required. :type resource_id: str - :param api_version: The API version to use for the operation. + :param api_version: The API version to use for the operation. Required. :type api_version: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: bool, or the result of cls(response) + :return: bool or the result of cls(response) :rtype: bool - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType[None] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = kwargs.pop("params", {}) or {} + + cls = kwargs.pop("cls", None) # type: ClsType[None] - request = build_resources_check_existence_by_id_request( resource_id=resource_id, api_version=api_version, - template_url=self.check_existence_by_id.metadata['url'], + template_url=self.check_existence_by_id.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [204, 404]: @@ -5733,35 +7583,38 @@ async def check_existence_by_id( return cls(pipeline_response, None, {}) return 200 <= response.status_code <= 299 - check_existence_by_id.metadata = {'url': "/{resourceId}"} # type: ignore - + check_existence_by_id.metadata = {"url": "/{resourceId}"} # type: ignore async def _delete_by_id_initial( # pylint: disable=inconsistent-return-statements - self, - resource_id: str, - api_version: str, - **kwargs: Any + self, resource_id: str, api_version: str, **kwargs: Any ) -> None: - cls = kwargs.pop('cls', None) # type: ClsType[None] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = kwargs.pop("params", {}) or {} - - request = build_resources_delete_by_id_request_initial( + cls = kwargs.pop("cls", None) # type: ClsType[None] + + request = build_resources_delete_by_id_request( resource_id=resource_id, api_version=api_version, - template_url=self._delete_by_id_initial.metadata['url'], + template_url=self._delete_by_id_initial.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200, 202, 204]: @@ -5771,23 +7624,18 @@ async def _delete_by_id_initial( # pylint: disable=inconsistent-return-statemen if cls: return cls(pipeline_response, None, {}) - _delete_by_id_initial.metadata = {'url': "/{resourceId}"} # type: ignore - + _delete_by_id_initial.metadata = {"url": "/{resourceId}"} # type: ignore @distributed_trace_async - async def begin_delete_by_id( # pylint: disable=inconsistent-return-statements - self, - resource_id: str, - api_version: str, - **kwargs: Any - ) -> AsyncLROPoller[None]: + async def begin_delete_by_id(self, resource_id: str, api_version: str, **kwargs: Any) -> AsyncLROPoller[None]: """Deletes a resource by ID. :param resource_id: The fully qualified ID of the resource, including the resource name and resource type. Use the format, /subscriptions/{guid}/resourceGroups/{resource-group-name}/{resource-provider-namespace}/{resource-type}/{resource-name}. + Required. :type resource_id: str - :param api_version: The API version to use for the operation. + :param api_version: The API version to use for the operation. Required. :type api_version: str :keyword callable cls: A custom type or function that will be passed the direct response :keyword str continuation_token: A continuation token to restart a poller from a saved state. @@ -5799,75 +7647,89 @@ async def begin_delete_by_id( # pylint: disable=inconsistent-return-statements Retry-After header is present. :return: An instance of AsyncLROPoller that returns either None or the result of cls(response) :rtype: ~azure.core.polling.AsyncLROPoller[None] - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - polling = kwargs.pop('polling', True) # type: Union[bool, AsyncPollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType[None] - lro_delay = kwargs.pop( - 'polling_interval', - self._config.polling_interval - ) - cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] + _headers = kwargs.pop("headers", {}) or {} + _params = kwargs.pop("params", {}) or {} + + cls = kwargs.pop("cls", None) # type: ClsType[None] + polling = kwargs.pop("polling", True) # type: Union[bool, AsyncPollingMethod] + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token = kwargs.pop("continuation_token", None) # type: Optional[str] if cont_token is None: - raw_result = await self._delete_by_id_initial( + raw_result = await self._delete_by_id_initial( # type: ignore resource_id=resource_id, api_version=api_version, - cls=lambda x,y,z: x, + cls=lambda x, y, z: x, + headers=_headers, + params=_params, **kwargs ) - kwargs.pop('error_map', None) + kwargs.pop("error_map", None) - def get_long_running_output(pipeline_response): + def get_long_running_output(pipeline_response): # pylint: disable=inconsistent-return-statements if cls: return cls(pipeline_response, None, {}) - - if polling is True: polling_method = AsyncARMPolling(lro_delay, **kwargs) - elif polling is False: polling_method = AsyncNoPolling() - else: polling_method = polling + if polling is True: + polling_method = cast(AsyncPollingMethod, AsyncARMPolling(lro_delay, **kwargs)) # type: AsyncPollingMethod + elif polling is False: + polling_method = cast(AsyncPollingMethod, AsyncNoPolling()) + else: + polling_method = polling if cont_token: return AsyncLROPoller.from_continuation_token( polling_method=polling_method, continuation_token=cont_token, client=self._client, - deserialization_callback=get_long_running_output + deserialization_callback=get_long_running_output, ) return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) - begin_delete_by_id.metadata = {'url': "/{resourceId}"} # type: ignore + begin_delete_by_id.metadata = {"url": "/{resourceId}"} # type: ignore async def _create_or_update_by_id_initial( - self, - resource_id: str, - api_version: str, - parameters: "_models.GenericResource", - **kwargs: Any - ) -> Optional["_models.GenericResource"]: - cls = kwargs.pop('cls', None) # type: ClsType[Optional["_models.GenericResource"]] + self, resource_id: str, api_version: str, parameters: Union[_models.GenericResource, IO], **kwargs: Any + ) -> Optional[_models.GenericResource]: error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = kwargs.pop("params", {}) or {} - _json = self._serialize.body(parameters, 'GenericResource') + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[Optional[_models.GenericResource]] - request = build_resources_create_or_update_by_id_request_initial( + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(parameters, (IO, bytes)): + _content = parameters + else: + _json = self._serialize.body(parameters, "GenericResource") + + request = build_resources_create_or_update_by_id_request( resource_id=resource_id, - content_type=content_type, api_version=api_version, + content_type=content_type, json=_json, - template_url=self._create_or_update_by_id_initial.metadata['url'], + content=_content, + template_url=self._create_or_update_by_id_initial.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200, 201, 202]: @@ -5876,37 +7738,42 @@ async def _create_or_update_by_id_initial( deserialized = None if response.status_code == 200: - deserialized = self._deserialize('GenericResource', pipeline_response) + deserialized = self._deserialize("GenericResource", pipeline_response) if response.status_code == 201: - deserialized = self._deserialize('GenericResource', pipeline_response) + deserialized = self._deserialize("GenericResource", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - _create_or_update_by_id_initial.metadata = {'url': "/{resourceId}"} # type: ignore + _create_or_update_by_id_initial.metadata = {"url": "/{resourceId}"} # type: ignore - - @distributed_trace_async + @overload async def begin_create_or_update_by_id( self, resource_id: str, api_version: str, - parameters: "_models.GenericResource", + parameters: _models.GenericResource, + *, + content_type: str = "application/json", **kwargs: Any - ) -> AsyncLROPoller["_models.GenericResource"]: + ) -> AsyncLROPoller[_models.GenericResource]: """Create a resource by ID. :param resource_id: The fully qualified ID of the resource, including the resource name and resource type. Use the format, /subscriptions/{guid}/resourceGroups/{resource-group-name}/{resource-provider-namespace}/{resource-type}/{resource-name}. + Required. :type resource_id: str - :param api_version: The API version to use for the operation. + :param api_version: The API version to use for the operation. Required. :type api_version: str - :param parameters: Create or update resource parameters. + :param parameters: Create or update resource parameters. Required. :type parameters: ~azure.mgmt.resource.resources.v2021_04_01.models.GenericResource + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str :keyword callable cls: A custom type or function that will be passed the direct response :keyword str continuation_token: A continuation token to restart a poller from a saved state. :keyword polling: By default, your polling method will be AsyncARMPolling. Pass in False for @@ -5919,81 +7786,167 @@ async def begin_create_or_update_by_id( cls(response) :rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.resource.resources.v2021_04_01.models.GenericResource] - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] - polling = kwargs.pop('polling', True) # type: Union[bool, AsyncPollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType["_models.GenericResource"] - lro_delay = kwargs.pop( - 'polling_interval', - self._config.polling_interval - ) - cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] + + @overload + async def begin_create_or_update_by_id( + self, + resource_id: str, + api_version: str, + parameters: IO, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> AsyncLROPoller[_models.GenericResource]: + """Create a resource by ID. + + :param resource_id: The fully qualified ID of the resource, including the resource name and + resource type. Use the format, + /subscriptions/{guid}/resourceGroups/{resource-group-name}/{resource-provider-namespace}/{resource-type}/{resource-name}. + Required. + :type resource_id: str + :param api_version: The API version to use for the operation. Required. + :type api_version: str + :param parameters: Create or update resource parameters. Required. + :type parameters: IO + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be AsyncARMPolling. Pass in False for + this operation to not poll, or pass in your own initialized polling object for a personal + polling strategy. + :paramtype polling: bool or ~azure.core.polling.AsyncPollingMethod + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of AsyncLROPoller that returns either GenericResource or the result of + cls(response) + :rtype: + ~azure.core.polling.AsyncLROPoller[~azure.mgmt.resource.resources.v2021_04_01.models.GenericResource] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace_async + async def begin_create_or_update_by_id( + self, resource_id: str, api_version: str, parameters: Union[_models.GenericResource, IO], **kwargs: Any + ) -> AsyncLROPoller[_models.GenericResource]: + """Create a resource by ID. + + :param resource_id: The fully qualified ID of the resource, including the resource name and + resource type. Use the format, + /subscriptions/{guid}/resourceGroups/{resource-group-name}/{resource-provider-namespace}/{resource-type}/{resource-name}. + Required. + :type resource_id: str + :param api_version: The API version to use for the operation. Required. + :type api_version: str + :param parameters: Create or update resource parameters. Is either a model type or a IO type. + Required. + :type parameters: ~azure.mgmt.resource.resources.v2021_04_01.models.GenericResource or IO + :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. + Default value is None. + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be AsyncARMPolling. Pass in False for + this operation to not poll, or pass in your own initialized polling object for a personal + polling strategy. + :paramtype polling: bool or ~azure.core.polling.AsyncPollingMethod + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of AsyncLROPoller that returns either GenericResource or the result of + cls(response) + :rtype: + ~azure.core.polling.AsyncLROPoller[~azure.mgmt.resource.resources.v2021_04_01.models.GenericResource] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = kwargs.pop("params", {}) or {} + + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.GenericResource] + polling = kwargs.pop("polling", True) # type: Union[bool, AsyncPollingMethod] + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token = kwargs.pop("continuation_token", None) # type: Optional[str] if cont_token is None: - raw_result = await self._create_or_update_by_id_initial( + raw_result = await self._create_or_update_by_id_initial( # type: ignore resource_id=resource_id, api_version=api_version, parameters=parameters, content_type=content_type, - cls=lambda x,y,z: x, + cls=lambda x, y, z: x, + headers=_headers, + params=_params, **kwargs ) - kwargs.pop('error_map', None) + kwargs.pop("error_map", None) def get_long_running_output(pipeline_response): - response = pipeline_response.http_response - deserialized = self._deserialize('GenericResource', pipeline_response) + deserialized = self._deserialize("GenericResource", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - - if polling is True: polling_method = AsyncARMPolling(lro_delay, **kwargs) - elif polling is False: polling_method = AsyncNoPolling() - else: polling_method = polling + if polling is True: + polling_method = cast(AsyncPollingMethod, AsyncARMPolling(lro_delay, **kwargs)) # type: AsyncPollingMethod + elif polling is False: + polling_method = cast(AsyncPollingMethod, AsyncNoPolling()) + else: + polling_method = polling if cont_token: return AsyncLROPoller.from_continuation_token( polling_method=polling_method, continuation_token=cont_token, client=self._client, - deserialization_callback=get_long_running_output + deserialization_callback=get_long_running_output, ) return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) - begin_create_or_update_by_id.metadata = {'url': "/{resourceId}"} # type: ignore + begin_create_or_update_by_id.metadata = {"url": "/{resourceId}"} # type: ignore async def _update_by_id_initial( - self, - resource_id: str, - api_version: str, - parameters: "_models.GenericResource", - **kwargs: Any - ) -> Optional["_models.GenericResource"]: - cls = kwargs.pop('cls', None) # type: ClsType[Optional["_models.GenericResource"]] + self, resource_id: str, api_version: str, parameters: Union[_models.GenericResource, IO], **kwargs: Any + ) -> Optional[_models.GenericResource]: error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = kwargs.pop("params", {}) or {} - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[Optional[_models.GenericResource]] - _json = self._serialize.body(parameters, 'GenericResource') + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(parameters, (IO, bytes)): + _content = parameters + else: + _json = self._serialize.body(parameters, "GenericResource") - request = build_resources_update_by_id_request_initial( + request = build_resources_update_by_id_request( resource_id=resource_id, - content_type=content_type, api_version=api_version, + content_type=content_type, json=_json, - template_url=self._update_by_id_initial.metadata['url'], + content=_content, + template_url=self._update_by_id_initial.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200, 202]: @@ -6002,34 +7955,39 @@ async def _update_by_id_initial( deserialized = None if response.status_code == 200: - deserialized = self._deserialize('GenericResource', pipeline_response) + deserialized = self._deserialize("GenericResource", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - _update_by_id_initial.metadata = {'url': "/{resourceId}"} # type: ignore + _update_by_id_initial.metadata = {"url": "/{resourceId}"} # type: ignore - - @distributed_trace_async + @overload async def begin_update_by_id( self, resource_id: str, api_version: str, - parameters: "_models.GenericResource", + parameters: _models.GenericResource, + *, + content_type: str = "application/json", **kwargs: Any - ) -> AsyncLROPoller["_models.GenericResource"]: + ) -> AsyncLROPoller[_models.GenericResource]: """Updates a resource by ID. :param resource_id: The fully qualified ID of the resource, including the resource name and resource type. Use the format, /subscriptions/{guid}/resourceGroups/{resource-group-name}/{resource-provider-namespace}/{resource-type}/{resource-name}. + Required. :type resource_id: str - :param api_version: The API version to use for the operation. + :param api_version: The API version to use for the operation. Required. :type api_version: str - :param parameters: Update resource parameters. + :param parameters: Update resource parameters. Required. :type parameters: ~azure.mgmt.resource.resources.v2021_04_01.models.GenericResource + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str :keyword callable cls: A custom type or function that will be passed the direct response :keyword str continuation_token: A continuation token to restart a poller from a saved state. :keyword polling: By default, your polling method will be AsyncARMPolling. Pass in False for @@ -6042,165 +8000,243 @@ async def begin_update_by_id( cls(response) :rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.resource.resources.v2021_04_01.models.GenericResource] - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] - polling = kwargs.pop('polling', True) # type: Union[bool, AsyncPollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType["_models.GenericResource"] - lro_delay = kwargs.pop( - 'polling_interval', - self._config.polling_interval - ) - cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] + + @overload + async def begin_update_by_id( + self, + resource_id: str, + api_version: str, + parameters: IO, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> AsyncLROPoller[_models.GenericResource]: + """Updates a resource by ID. + + :param resource_id: The fully qualified ID of the resource, including the resource name and + resource type. Use the format, + /subscriptions/{guid}/resourceGroups/{resource-group-name}/{resource-provider-namespace}/{resource-type}/{resource-name}. + Required. + :type resource_id: str + :param api_version: The API version to use for the operation. Required. + :type api_version: str + :param parameters: Update resource parameters. Required. + :type parameters: IO + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be AsyncARMPolling. Pass in False for + this operation to not poll, or pass in your own initialized polling object for a personal + polling strategy. + :paramtype polling: bool or ~azure.core.polling.AsyncPollingMethod + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of AsyncLROPoller that returns either GenericResource or the result of + cls(response) + :rtype: + ~azure.core.polling.AsyncLROPoller[~azure.mgmt.resource.resources.v2021_04_01.models.GenericResource] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace_async + async def begin_update_by_id( + self, resource_id: str, api_version: str, parameters: Union[_models.GenericResource, IO], **kwargs: Any + ) -> AsyncLROPoller[_models.GenericResource]: + """Updates a resource by ID. + + :param resource_id: The fully qualified ID of the resource, including the resource name and + resource type. Use the format, + /subscriptions/{guid}/resourceGroups/{resource-group-name}/{resource-provider-namespace}/{resource-type}/{resource-name}. + Required. + :type resource_id: str + :param api_version: The API version to use for the operation. Required. + :type api_version: str + :param parameters: Update resource parameters. Is either a model type or a IO type. Required. + :type parameters: ~azure.mgmt.resource.resources.v2021_04_01.models.GenericResource or IO + :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. + Default value is None. + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be AsyncARMPolling. Pass in False for + this operation to not poll, or pass in your own initialized polling object for a personal + polling strategy. + :paramtype polling: bool or ~azure.core.polling.AsyncPollingMethod + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of AsyncLROPoller that returns either GenericResource or the result of + cls(response) + :rtype: + ~azure.core.polling.AsyncLROPoller[~azure.mgmt.resource.resources.v2021_04_01.models.GenericResource] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = kwargs.pop("params", {}) or {} + + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.GenericResource] + polling = kwargs.pop("polling", True) # type: Union[bool, AsyncPollingMethod] + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token = kwargs.pop("continuation_token", None) # type: Optional[str] if cont_token is None: - raw_result = await self._update_by_id_initial( + raw_result = await self._update_by_id_initial( # type: ignore resource_id=resource_id, api_version=api_version, parameters=parameters, content_type=content_type, - cls=lambda x,y,z: x, + cls=lambda x, y, z: x, + headers=_headers, + params=_params, **kwargs ) - kwargs.pop('error_map', None) + kwargs.pop("error_map", None) def get_long_running_output(pipeline_response): - response = pipeline_response.http_response - deserialized = self._deserialize('GenericResource', pipeline_response) + deserialized = self._deserialize("GenericResource", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - - if polling is True: polling_method = AsyncARMPolling(lro_delay, **kwargs) - elif polling is False: polling_method = AsyncNoPolling() - else: polling_method = polling + if polling is True: + polling_method = cast(AsyncPollingMethod, AsyncARMPolling(lro_delay, **kwargs)) # type: AsyncPollingMethod + elif polling is False: + polling_method = cast(AsyncPollingMethod, AsyncNoPolling()) + else: + polling_method = polling if cont_token: return AsyncLROPoller.from_continuation_token( polling_method=polling_method, continuation_token=cont_token, client=self._client, - deserialization_callback=get_long_running_output + deserialization_callback=get_long_running_output, ) return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) - begin_update_by_id.metadata = {'url': "/{resourceId}"} # type: ignore + begin_update_by_id.metadata = {"url": "/{resourceId}"} # type: ignore @distributed_trace_async - async def get_by_id( - self, - resource_id: str, - api_version: str, - **kwargs: Any - ) -> "_models.GenericResource": + async def get_by_id(self, resource_id: str, api_version: str, **kwargs: Any) -> _models.GenericResource: """Gets a resource by ID. :param resource_id: The fully qualified ID of the resource, including the resource name and resource type. Use the format, /subscriptions/{guid}/resourceGroups/{resource-group-name}/{resource-provider-namespace}/{resource-type}/{resource-name}. + Required. :type resource_id: str - :param api_version: The API version to use for the operation. + :param api_version: The API version to use for the operation. Required. :type api_version: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: GenericResource, or the result of cls(response) + :return: GenericResource or the result of cls(response) :rtype: ~azure.mgmt.resource.resources.v2021_04_01.models.GenericResource - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.GenericResource"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = kwargs.pop("params", {}) or {} + + cls = kwargs.pop("cls", None) # type: ClsType[_models.GenericResource] - request = build_resources_get_by_id_request( resource_id=resource_id, api_version=api_version, - template_url=self.get_by_id.metadata['url'], + template_url=self.get_by_id.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) - deserialized = self._deserialize('GenericResource', pipeline_response) + deserialized = self._deserialize("GenericResource", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - get_by_id.metadata = {'url': "/{resourceId}"} # type: ignore + get_by_id.metadata = {"url": "/{resourceId}"} # type: ignore -class ResourceGroupsOperations: - """ResourceGroupsOperations async operations. - You should not instantiate this class directly. Instead, you should create a Client instance that - instantiates it for you and attaches it as an attribute. +class ResourceGroupsOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. - :ivar models: Alias to model classes used in this operation group. - :type models: ~azure.mgmt.resource.resources.v2021_04_01.models - :param client: Client for service requests. - :param config: Configuration of service client. - :param serializer: An object model serializer. - :param deserializer: An object model deserializer. + Instead, you should access the following operations through + :class:`~azure.mgmt.resource.resources.v2021_04_01.aio.ResourceManagementClient`'s + :attr:`resource_groups` attribute. """ models = _models - def __init__(self, client, config, serializer, deserializer) -> None: - self._client = client - self._serialize = serializer - self._deserialize = deserializer - self._config = config + def __init__(self, *args, **kwargs) -> None: + input_args = list(args) + self._client = input_args.pop(0) if input_args else kwargs.pop("client") + self._config = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") @distributed_trace_async - async def check_existence( - self, - resource_group_name: str, - **kwargs: Any - ) -> bool: + async def check_existence(self, resource_group_name: str, **kwargs: Any) -> bool: """Checks whether a resource group exists. :param resource_group_name: The name of the resource group to check. The name is case - insensitive. + insensitive. Required. :type resource_group_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: bool, or the result of cls(response) + :return: bool or the result of cls(response) :rtype: bool - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType[None] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) - api_version = kwargs.pop('api_version', "2021-04-01") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-04-01")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[None] - request = build_resource_groups_check_existence_request( resource_group_name=resource_group_name, subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.check_existence.metadata['url'], + template_url=self.check_existence.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [204, 404]: @@ -6211,39 +8247,98 @@ async def check_existence( return cls(pipeline_response, None, {}) return 200 <= response.status_code <= 299 - check_existence.metadata = {'url': "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}"} # type: ignore + check_existence.metadata = {"url": "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}"} # type: ignore - - @distributed_trace_async + @overload async def create_or_update( self, resource_group_name: str, - parameters: "_models.ResourceGroup", + parameters: _models.ResourceGroup, + *, + content_type: str = "application/json", **kwargs: Any - ) -> "_models.ResourceGroup": + ) -> _models.ResourceGroup: """Creates or updates a resource group. :param resource_group_name: The name of the resource group to create or update. Can include alphanumeric, underscore, parentheses, hyphen, period (except at end), and Unicode characters - that match the allowed characters. + that match the allowed characters. Required. :type resource_group_name: str - :param parameters: Parameters supplied to the create or update a resource group. + :param parameters: Parameters supplied to the create or update a resource group. Required. :type parameters: ~azure.mgmt.resource.resources.v2021_04_01.models.ResourceGroup + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: ResourceGroup or the result of cls(response) + :rtype: ~azure.mgmt.resource.resources.v2021_04_01.models.ResourceGroup + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + async def create_or_update( + self, resource_group_name: str, parameters: IO, *, content_type: str = "application/json", **kwargs: Any + ) -> _models.ResourceGroup: + """Creates or updates a resource group. + + :param resource_group_name: The name of the resource group to create or update. Can include + alphanumeric, underscore, parentheses, hyphen, period (except at end), and Unicode characters + that match the allowed characters. Required. + :type resource_group_name: str + :param parameters: Parameters supplied to the create or update a resource group. Required. + :type parameters: IO + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: ResourceGroup or the result of cls(response) + :rtype: ~azure.mgmt.resource.resources.v2021_04_01.models.ResourceGroup + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace_async + async def create_or_update( + self, resource_group_name: str, parameters: Union[_models.ResourceGroup, IO], **kwargs: Any + ) -> _models.ResourceGroup: + """Creates or updates a resource group. + + :param resource_group_name: The name of the resource group to create or update. Can include + alphanumeric, underscore, parentheses, hyphen, period (except at end), and Unicode characters + that match the allowed characters. Required. + :type resource_group_name: str + :param parameters: Parameters supplied to the create or update a resource group. Is either a + model type or a IO type. Required. + :type parameters: ~azure.mgmt.resource.resources.v2021_04_01.models.ResourceGroup or IO + :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. + Default value is None. + :paramtype content_type: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: ResourceGroup, or the result of cls(response) + :return: ResourceGroup or the result of cls(response) :rtype: ~azure.mgmt.resource.resources.v2021_04_01.models.ResourceGroup - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.ResourceGroup"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) - api_version = kwargs.pop('api_version', "2021-04-01") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - _json = self._serialize.body(parameters, 'ResourceGroup') + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-04-01")) # type: str + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.ResourceGroup] + + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(parameters, (IO, bytes)): + _content = parameters + else: + _json = self._serialize.body(parameters, "ResourceGroup") request = build_resource_groups_create_or_update_request( resource_group_name=resource_group_name, @@ -6251,16 +8346,18 @@ async def create_or_update( api_version=api_version, content_type=content_type, json=_json, - template_url=self.create_or_update.metadata['url'], + content=_content, + template_url=self.create_or_update.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200, 201]: @@ -6268,49 +8365,51 @@ async def create_or_update( raise HttpResponseError(response=response, error_format=ARMErrorFormat) if response.status_code == 200: - deserialized = self._deserialize('ResourceGroup', pipeline_response) + deserialized = self._deserialize("ResourceGroup", pipeline_response) if response.status_code == 201: - deserialized = self._deserialize('ResourceGroup', pipeline_response) + deserialized = self._deserialize("ResourceGroup", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - create_or_update.metadata = {'url': "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}"} # type: ignore - + create_or_update.metadata = {"url": "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}"} # type: ignore async def _delete_initial( # pylint: disable=inconsistent-return-statements - self, - resource_group_name: str, - force_deletion_types: Optional[str] = None, - **kwargs: Any + self, resource_group_name: str, force_deletion_types: Optional[str] = None, **kwargs: Any ) -> None: - cls = kwargs.pop('cls', None) # type: ClsType[None] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + 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', "2021-04-01") # type: str + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-04-01")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[None] - - request = build_resource_groups_delete_request_initial( + request = build_resource_groups_delete_request( resource_group_name=resource_group_name, subscription_id=self._config.subscription_id, - api_version=api_version, force_deletion_types=force_deletion_types, - template_url=self._delete_initial.metadata['url'], + api_version=api_version, + template_url=self._delete_initial.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200, 202]: @@ -6320,15 +8419,11 @@ async def _delete_initial( # pylint: disable=inconsistent-return-statements if cls: return cls(pipeline_response, None, {}) - _delete_initial.metadata = {'url': "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}"} # type: ignore - + _delete_initial.metadata = {"url": "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}"} # type: ignore @distributed_trace_async - async def begin_delete( # pylint: disable=inconsistent-return-statements - self, - resource_group_name: str, - force_deletion_types: Optional[str] = None, - **kwargs: Any + async def begin_delete( + self, resource_group_name: str, force_deletion_types: Optional[str] = None, **kwargs: Any ) -> AsyncLROPoller[None]: """Deletes a resource group. @@ -6336,7 +8431,7 @@ async def begin_delete( # pylint: disable=inconsistent-return-statements group deletes all of its template deployments and currently stored operations. :param resource_group_name: The name of the resource group to delete. The name is case - insensitive. + insensitive. Required. :type resource_group_name: str :param force_deletion_types: The resource types you want to force delete. Currently, only the following is supported: @@ -6353,107 +8448,114 @@ async def begin_delete( # pylint: disable=inconsistent-return-statements Retry-After header is present. :return: An instance of AsyncLROPoller that returns either None or the result of cls(response) :rtype: ~azure.core.polling.AsyncLROPoller[None] - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - api_version = kwargs.pop('api_version', "2021-04-01") # type: str - polling = kwargs.pop('polling', True) # type: Union[bool, AsyncPollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType[None] - lro_delay = kwargs.pop( - 'polling_interval', - self._config.polling_interval - ) - cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-04-01")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[None] + polling = kwargs.pop("polling", True) # type: Union[bool, AsyncPollingMethod] + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token = kwargs.pop("continuation_token", None) # type: Optional[str] if cont_token is None: - raw_result = await self._delete_initial( + raw_result = await self._delete_initial( # type: ignore resource_group_name=resource_group_name, force_deletion_types=force_deletion_types, api_version=api_version, - cls=lambda x,y,z: x, + cls=lambda x, y, z: x, + headers=_headers, + params=_params, **kwargs ) - kwargs.pop('error_map', None) + kwargs.pop("error_map", None) - def get_long_running_output(pipeline_response): + def get_long_running_output(pipeline_response): # pylint: disable=inconsistent-return-statements if cls: return cls(pipeline_response, None, {}) - - if polling is True: polling_method = AsyncARMPolling(lro_delay, **kwargs) - elif polling is False: polling_method = AsyncNoPolling() - else: polling_method = polling + if polling is True: + polling_method = cast(AsyncPollingMethod, AsyncARMPolling(lro_delay, **kwargs)) # type: AsyncPollingMethod + elif polling is False: + polling_method = cast(AsyncPollingMethod, AsyncNoPolling()) + else: + polling_method = polling if cont_token: return AsyncLROPoller.from_continuation_token( polling_method=polling_method, continuation_token=cont_token, client=self._client, - deserialization_callback=get_long_running_output + deserialization_callback=get_long_running_output, ) return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) - begin_delete.metadata = {'url': "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}"} # type: ignore + begin_delete.metadata = {"url": "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}"} # type: ignore @distributed_trace_async - async def get( - self, - resource_group_name: str, - **kwargs: Any - ) -> "_models.ResourceGroup": + async def get(self, resource_group_name: str, **kwargs: Any) -> _models.ResourceGroup: """Gets a resource group. :param resource_group_name: The name of the resource group to get. The name is case - insensitive. + insensitive. Required. :type resource_group_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: ResourceGroup, or the result of cls(response) + :return: ResourceGroup or the result of cls(response) :rtype: ~azure.mgmt.resource.resources.v2021_04_01.models.ResourceGroup - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.ResourceGroup"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + 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', "2021-04-01") # type: str + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-04-01")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[_models.ResourceGroup] - request = build_resource_groups_get_request( resource_group_name=resource_group_name, subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.get.metadata['url'], + template_url=self.get.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) - deserialized = self._deserialize('ResourceGroup', pipeline_response) + deserialized = self._deserialize("ResourceGroup", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - get.metadata = {'url': "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}"} # type: ignore - + get.metadata = {"url": "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}"} # type: ignore - @distributed_trace_async + @overload async def update( self, resource_group_name: str, - parameters: "_models.ResourceGroupPatchable", + parameters: _models.ResourceGroupPatchable, + *, + content_type: str = "application/json", **kwargs: Any - ) -> "_models.ResourceGroup": + ) -> _models.ResourceGroup: """Updates a resource group. Resource groups can be updated through a simple PATCH operation to a group address. The format @@ -6461,25 +8563,90 @@ async def update( the current value is retained. :param resource_group_name: The name of the resource group to update. The name is case - insensitive. + insensitive. Required. :type resource_group_name: str - :param parameters: Parameters supplied to update a resource group. + :param parameters: Parameters supplied to update a resource group. Required. :type parameters: ~azure.mgmt.resource.resources.v2021_04_01.models.ResourceGroupPatchable + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: ResourceGroup or the result of cls(response) + :rtype: ~azure.mgmt.resource.resources.v2021_04_01.models.ResourceGroup + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + async def update( + self, resource_group_name: str, parameters: IO, *, content_type: str = "application/json", **kwargs: Any + ) -> _models.ResourceGroup: + """Updates a resource group. + + Resource groups can be updated through a simple PATCH operation to a group address. The format + of the request is the same as that for creating a resource group. If a field is unspecified, + the current value is retained. + + :param resource_group_name: The name of the resource group to update. The name is case + insensitive. Required. + :type resource_group_name: str + :param parameters: Parameters supplied to update a resource group. Required. + :type parameters: IO + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: ResourceGroup or the result of cls(response) + :rtype: ~azure.mgmt.resource.resources.v2021_04_01.models.ResourceGroup + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace_async + async def update( + self, resource_group_name: str, parameters: Union[_models.ResourceGroupPatchable, IO], **kwargs: Any + ) -> _models.ResourceGroup: + """Updates a resource group. + + Resource groups can be updated through a simple PATCH operation to a group address. The format + of the request is the same as that for creating a resource group. If a field is unspecified, + the current value is retained. + + :param resource_group_name: The name of the resource group to update. The name is case + insensitive. Required. + :type resource_group_name: str + :param parameters: Parameters supplied to update a resource group. Is either a model type or a + IO type. Required. + :type parameters: ~azure.mgmt.resource.resources.v2021_04_01.models.ResourceGroupPatchable or + IO + :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. + Default value is None. + :paramtype content_type: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: ResourceGroup, or the result of cls(response) + :return: ResourceGroup or the result of cls(response) :rtype: ~azure.mgmt.resource.resources.v2021_04_01.models.ResourceGroup - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.ResourceGroup"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) - api_version = kwargs.pop('api_version', "2021-04-01") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - _json = self._serialize.body(parameters, 'ResourceGroupPatchable') + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-04-01")) # type: str + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.ResourceGroup] + + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(parameters, (IO, bytes)): + _content = parameters + else: + _json = self._serialize.body(parameters, "ResourceGroupPatchable") request = build_resource_groups_update_request( resource_group_name=resource_group_name, @@ -6487,65 +8654,77 @@ async def update( api_version=api_version, content_type=content_type, json=_json, - template_url=self.update.metadata['url'], + content=_content, + template_url=self.update.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) - deserialized = self._deserialize('ResourceGroup', pipeline_response) + deserialized = self._deserialize("ResourceGroup", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - update.metadata = {'url': "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}"} # type: ignore - + update.metadata = {"url": "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}"} # type: ignore async def _export_template_initial( - self, - resource_group_name: str, - parameters: "_models.ExportTemplateRequest", - **kwargs: Any - ) -> Optional["_models.ResourceGroupExportResult"]: - cls = kwargs.pop('cls', None) # type: ClsType[Optional["_models.ResourceGroupExportResult"]] + self, resource_group_name: str, parameters: Union[_models.ExportTemplateRequest, IO], **kwargs: Any + ) -> Optional[_models.ResourceGroupExportResult]: error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) - api_version = kwargs.pop('api_version', "2021-04-01") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - _json = self._serialize.body(parameters, 'ExportTemplateRequest') + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-04-01")) # type: str + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[Optional[_models.ResourceGroupExportResult]] - request = build_resource_groups_export_template_request_initial( - subscription_id=self._config.subscription_id, + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(parameters, (IO, bytes)): + _content = parameters + else: + _json = self._serialize.body(parameters, "ExportTemplateRequest") + + request = build_resource_groups_export_template_request( resource_group_name=resource_group_name, + subscription_id=self._config.subscription_id, api_version=api_version, content_type=content_type, json=_json, - template_url=self._export_template_initial.metadata['url'], + content=_content, + template_url=self._export_template_initial.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200, 202]: @@ -6554,29 +8733,93 @@ async def _export_template_initial( deserialized = None if response.status_code == 200: - deserialized = self._deserialize('ResourceGroupExportResult', pipeline_response) + deserialized = self._deserialize("ResourceGroupExportResult", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - _export_template_initial.metadata = {'url': "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/exportTemplate"} # type: ignore - + _export_template_initial.metadata = {"url": "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/exportTemplate"} # type: ignore - @distributed_trace_async + @overload async def begin_export_template( self, resource_group_name: str, - parameters: "_models.ExportTemplateRequest", + parameters: _models.ExportTemplateRequest, + *, + content_type: str = "application/json", **kwargs: Any - ) -> AsyncLROPoller["_models.ResourceGroupExportResult"]: + ) -> AsyncLROPoller[_models.ResourceGroupExportResult]: """Captures the specified resource group as a template. :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. :type resource_group_name: str - :param parameters: Parameters for exporting the template. + :param parameters: Parameters for exporting the template. Required. :type parameters: ~azure.mgmt.resource.resources.v2021_04_01.models.ExportTemplateRequest + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be AsyncARMPolling. Pass in False for + this operation to not poll, or pass in your own initialized polling object for a personal + polling strategy. + :paramtype polling: bool or ~azure.core.polling.AsyncPollingMethod + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of AsyncLROPoller that returns either ResourceGroupExportResult or the + result of cls(response) + :rtype: + ~azure.core.polling.AsyncLROPoller[~azure.mgmt.resource.resources.v2021_04_01.models.ResourceGroupExportResult] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + async def begin_export_template( + self, resource_group_name: str, parameters: IO, *, content_type: str = "application/json", **kwargs: Any + ) -> AsyncLROPoller[_models.ResourceGroupExportResult]: + """Captures the specified resource group as a template. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param parameters: Parameters for exporting the template. Required. + :type parameters: IO + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be AsyncARMPolling. Pass in False for + this operation to not poll, or pass in your own initialized polling object for a personal + polling strategy. + :paramtype polling: bool or ~azure.core.polling.AsyncPollingMethod + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of AsyncLROPoller that returns either ResourceGroupExportResult or the + result of cls(response) + :rtype: + ~azure.core.polling.AsyncLROPoller[~azure.mgmt.resource.resources.v2021_04_01.models.ResourceGroupExportResult] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace_async + async def begin_export_template( + self, resource_group_name: str, parameters: Union[_models.ExportTemplateRequest, IO], **kwargs: Any + ) -> AsyncLROPoller[_models.ResourceGroupExportResult]: + """Captures the specified resource group as a template. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param parameters: Parameters for exporting the template. Is either a model type or a IO type. + Required. + :type parameters: ~azure.mgmt.resource.resources.v2021_04_01.models.ExportTemplateRequest or IO + :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. + Default value is None. + :paramtype content_type: str :keyword callable cls: A custom type or function that will be passed the direct response :keyword str continuation_token: A continuation token to restart a poller from a saved state. :keyword polling: By default, your polling method will be AsyncARMPolling. Pass in False for @@ -6589,57 +8832,59 @@ async def begin_export_template( result of cls(response) :rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.resource.resources.v2021_04_01.models.ResourceGroupExportResult] - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - api_version = kwargs.pop('api_version', "2021-04-01") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] - polling = kwargs.pop('polling', True) # type: Union[bool, AsyncPollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType["_models.ResourceGroupExportResult"] - lro_delay = kwargs.pop( - 'polling_interval', - self._config.polling_interval - ) - cont_token = kwargs.pop('continuation_token', None) # type: Optional[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-04-01")) # type: str + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.ResourceGroupExportResult] + polling = kwargs.pop("polling", True) # type: Union[bool, AsyncPollingMethod] + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token = kwargs.pop("continuation_token", None) # type: Optional[str] if cont_token is None: - raw_result = await self._export_template_initial( + raw_result = await self._export_template_initial( # type: ignore resource_group_name=resource_group_name, parameters=parameters, api_version=api_version, content_type=content_type, - cls=lambda x,y,z: x, + cls=lambda x, y, z: x, + headers=_headers, + params=_params, **kwargs ) - kwargs.pop('error_map', None) + kwargs.pop("error_map", None) def get_long_running_output(pipeline_response): - response = pipeline_response.http_response - deserialized = self._deserialize('ResourceGroupExportResult', pipeline_response) + deserialized = self._deserialize("ResourceGroupExportResult", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - - if polling is True: polling_method = AsyncARMPolling(lro_delay, lro_options={'final-state-via': 'location'}, **kwargs) - elif polling is False: polling_method = AsyncNoPolling() - else: polling_method = polling + if polling is True: + polling_method = cast( + AsyncPollingMethod, AsyncARMPolling(lro_delay, lro_options={"final-state-via": "location"}, **kwargs) + ) # type: AsyncPollingMethod + elif polling is False: + polling_method = cast(AsyncPollingMethod, AsyncNoPolling()) + else: + polling_method = polling if cont_token: return AsyncLROPoller.from_continuation_token( polling_method=polling_method, continuation_token=cont_token, client=self._client, - deserialization_callback=get_long_running_output + deserialization_callback=get_long_running_output, ) return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) - begin_export_template.metadata = {'url': "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/exportTemplate"} # type: ignore + begin_export_template.metadata = {"url": "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/exportTemplate"} # type: ignore @distributed_trace def list( - self, - filter: Optional[str] = None, - top: Optional[int] = None, - **kwargs: Any - ) -> AsyncIterable["_models.ResourceGroupListResult"]: + self, filter: Optional[str] = None, top: Optional[int] = None, **kwargs: Any + ) -> AsyncIterable["_models.ResourceGroup"]: """Gets all the resource groups for a subscription. :param filter: The filter to apply on the operation.:code:`
`:code:`
`You can filter by @@ -6650,40 +8895,48 @@ def list( Default value is None. :type top: int :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either ResourceGroupListResult or the result of - cls(response) + :return: An iterator like instance of either ResourceGroup or the result of cls(response) :rtype: - ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.resource.resources.v2021_04_01.models.ResourceGroupListResult] - :raises: ~azure.core.exceptions.HttpResponseError + ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.resource.resources.v2021_04_01.models.ResourceGroup] + :raises ~azure.core.exceptions.HttpResponseError: """ - api_version = kwargs.pop('api_version', "2021-04-01") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-04-01")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[_models.ResourceGroupListResult] - cls = kwargs.pop('cls', None) # type: ClsType["_models.ResourceGroupListResult"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) + def prepare_request(next_link=None): if not next_link: - + request = build_resource_groups_list_request( subscription_id=self._config.subscription_id, - api_version=api_version, filter=filter, top=top, - template_url=self.list.metadata['url'], + 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.url = self._client.format_url(request.url) # type: ignore else: - - request = build_resource_groups_list_request( - subscription_id=self._config.subscription_id, - template_url=next_link, - ) + # make call to next link with the client's api-version + _parsed_next_link = urlparse(next_link) + _next_request_params = case_insensitive_dict(parse_qs(_parsed_next_link.query)) + _next_request_params["api-version"] = self._config.api_version + request = HttpRequest("GET", urljoin(next_link, _parsed_next_link.path), params=_next_request_params) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore request.method = "GET" return request @@ -6697,10 +8950,8 @@ async def extract_data(pipeline_response): async def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) response = pipeline_response.http_response @@ -6710,39 +8961,33 @@ async def get_next(next_link=None): return pipeline_response + return AsyncItemPaged(get_next, extract_data) - return AsyncItemPaged( - get_next, extract_data - ) - list.metadata = {'url': "/subscriptions/{subscriptionId}/resourcegroups"} # type: ignore -class TagsOperations: - """TagsOperations async operations. + list.metadata = {"url": "/subscriptions/{subscriptionId}/resourcegroups"} # type: ignore - You should not instantiate this class directly. Instead, you should create a Client instance that - instantiates it for you and attaches it as an attribute. - :ivar models: Alias to model classes used in this operation group. - :type models: ~azure.mgmt.resource.resources.v2021_04_01.models - :param client: Client for service requests. - :param config: Configuration of service client. - :param serializer: An object model serializer. - :param deserializer: An object model deserializer. +class TagsOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. + + Instead, you should access the following operations through + :class:`~azure.mgmt.resource.resources.v2021_04_01.aio.ResourceManagementClient`'s + :attr:`tags` attribute. """ models = _models - def __init__(self, client, config, serializer, deserializer) -> None: - self._client = client - self._serialize = serializer - self._deserialize = deserializer - self._config = config + def __init__(self, *args, **kwargs) -> None: + input_args = list(args) + self._client = input_args.pop(0) if input_args else kwargs.pop("client") + self._config = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") @distributed_trace_async async def delete_value( # pylint: disable=inconsistent-return-statements - self, - tag_name: str, - tag_value: str, - **kwargs: Any + self, tag_name: str, tag_value: str, **kwargs: Any ) -> None: """Deletes a predefined tag value for a predefined tag name. @@ -6750,39 +8995,45 @@ async def delete_value( # pylint: disable=inconsistent-return-statements predefined tag name. The value being deleted must not be in use as a tag value for the given tag name for any resource. - :param tag_name: The name of the tag. + :param tag_name: The name of the tag. Required. :type tag_name: str - :param tag_value: The value of the tag to delete. + :param tag_value: The value of the tag to delete. Required. :type tag_value: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: None, or the result of cls(response) + :return: None or the result of cls(response) :rtype: None - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType[None] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + 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', "2021-04-01") # type: str + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-04-01")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[None] - request = build_tags_delete_value_request( tag_name=tag_name, tag_value=tag_value, subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.delete_value.metadata['url'], + template_url=self.delete_value.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200, 204]: @@ -6792,54 +9043,54 @@ async def delete_value( # pylint: disable=inconsistent-return-statements if cls: return cls(pipeline_response, None, {}) - delete_value.metadata = {'url': "/subscriptions/{subscriptionId}/tagNames/{tagName}/tagValues/{tagValue}"} # type: ignore - + delete_value.metadata = {"url": "/subscriptions/{subscriptionId}/tagNames/{tagName}/tagValues/{tagValue}"} # type: ignore @distributed_trace_async - async def create_or_update_value( - self, - tag_name: str, - tag_value: str, - **kwargs: Any - ) -> "_models.TagValue": + async def create_or_update_value(self, tag_name: str, tag_value: str, **kwargs: Any) -> _models.TagValue: """Creates a predefined value for a predefined tag name. This operation allows adding a value to the list of predefined values for an existing predefined tag name. A tag value can have a maximum of 256 characters. - :param tag_name: The name of the tag. + :param tag_name: The name of the tag. Required. :type tag_name: str - :param tag_value: The value of the tag to create. + :param tag_value: The value of the tag to create. Required. :type tag_value: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: TagValue, or the result of cls(response) + :return: TagValue or the result of cls(response) :rtype: ~azure.mgmt.resource.resources.v2021_04_01.models.TagValue - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.TagValue"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) - api_version = kwargs.pop('api_version', "2021-04-01") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-04-01")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[_models.TagValue] - request = build_tags_create_or_update_value_request( tag_name=tag_name, tag_value=tag_value, subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.create_or_update_value.metadata['url'], + template_url=self.create_or_update_value.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200, 201]: @@ -6847,25 +9098,20 @@ async def create_or_update_value( raise HttpResponseError(response=response, error_format=ARMErrorFormat) if response.status_code == 200: - deserialized = self._deserialize('TagValue', pipeline_response) + deserialized = self._deserialize("TagValue", pipeline_response) if response.status_code == 201: - deserialized = self._deserialize('TagValue', pipeline_response) + deserialized = self._deserialize("TagValue", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - create_or_update_value.metadata = {'url': "/subscriptions/{subscriptionId}/tagNames/{tagName}/tagValues/{tagValue}"} # type: ignore - + create_or_update_value.metadata = {"url": "/subscriptions/{subscriptionId}/tagNames/{tagName}/tagValues/{tagValue}"} # type: ignore @distributed_trace_async - async def create_or_update( - self, - tag_name: str, - **kwargs: Any - ) -> "_models.TagDetails": + async def create_or_update(self, tag_name: str, **kwargs: Any) -> _models.TagDetails: """Creates a predefined tag name. This operation allows adding a name to the list of predefined tag names for the given @@ -6873,36 +9119,42 @@ async def create_or_update( names cannot have the following prefixes which are reserved for Azure use: 'microsoft', 'azure', 'windows'. - :param tag_name: The name of the tag to create. + :param tag_name: The name of the tag to create. Required. :type tag_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: TagDetails, or the result of cls(response) + :return: TagDetails or the result of cls(response) :rtype: ~azure.mgmt.resource.resources.v2021_04_01.models.TagDetails - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.TagDetails"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) - api_version = kwargs.pop('api_version', "2021-04-01") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-04-01")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[_models.TagDetails] - request = build_tags_create_or_update_request( tag_name=tag_name, subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.create_or_update.metadata['url'], + template_url=self.create_or_update.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200, 201]: @@ -6910,61 +9162,62 @@ async def create_or_update( raise HttpResponseError(response=response, error_format=ARMErrorFormat) if response.status_code == 200: - deserialized = self._deserialize('TagDetails', pipeline_response) + deserialized = self._deserialize("TagDetails", pipeline_response) if response.status_code == 201: - deserialized = self._deserialize('TagDetails', pipeline_response) + deserialized = self._deserialize("TagDetails", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - create_or_update.metadata = {'url': "/subscriptions/{subscriptionId}/tagNames/{tagName}"} # type: ignore - + create_or_update.metadata = {"url": "/subscriptions/{subscriptionId}/tagNames/{tagName}"} # type: ignore @distributed_trace_async - async def delete( # pylint: disable=inconsistent-return-statements - self, - tag_name: str, - **kwargs: Any - ) -> None: + async def delete(self, tag_name: str, **kwargs: Any) -> None: # pylint: disable=inconsistent-return-statements """Deletes a predefined tag name. This operation allows deleting a name from the list of predefined tag names for the given subscription. The name being deleted must not be in use as a tag name for any resource. All predefined values for the given name must have already been deleted. - :param tag_name: The name of the tag. + :param tag_name: The name of the tag. Required. :type tag_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: None, or the result of cls(response) + :return: None or the result of cls(response) :rtype: None - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType[None] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) - api_version = kwargs.pop('api_version', "2021-04-01") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-04-01")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[None] - request = build_tags_delete_request( tag_name=tag_name, subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.delete.metadata['url'], + template_url=self.delete.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200, 204]: @@ -6974,14 +9227,10 @@ async def delete( # pylint: disable=inconsistent-return-statements if cls: return cls(pipeline_response, None, {}) - delete.metadata = {'url': "/subscriptions/{subscriptionId}/tagNames/{tagName}"} # type: ignore - + delete.metadata = {"url": "/subscriptions/{subscriptionId}/tagNames/{tagName}"} # type: ignore @distributed_trace - def list( - self, - **kwargs: Any - ) -> AsyncIterable["_models.TagsListResult"]: + def list(self, **kwargs: Any) -> AsyncIterable["_models.TagDetails"]: """Gets a summary of tag usage under the subscription. This operation performs a union of predefined tags, resource tags, resource group tags and @@ -6990,37 +9239,46 @@ def list( result. :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either TagsListResult or the result of cls(response) + :return: An iterator like instance of either TagDetails or the result of cls(response) :rtype: - ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.resource.resources.v2021_04_01.models.TagsListResult] - :raises: ~azure.core.exceptions.HttpResponseError + ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.resource.resources.v2021_04_01.models.TagDetails] + :raises ~azure.core.exceptions.HttpResponseError: """ - api_version = kwargs.pop('api_version', "2021-04-01") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-04-01")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[_models.TagsListResult] - cls = kwargs.pop('cls', None) # type: ClsType["_models.TagsListResult"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) + def prepare_request(next_link=None): if not next_link: - + request = build_tags_list_request( subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.list.metadata['url'], + template_url=self.list.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore else: - - request = build_tags_list_request( - subscription_id=self._config.subscription_id, - template_url=next_link, - ) + # make call to next link with the client's api-version + _parsed_next_link = urlparse(next_link) + _next_request_params = case_insensitive_dict(parse_qs(_parsed_next_link.query)) + _next_request_params["api-version"] = self._config.api_version + request = HttpRequest("GET", urljoin(next_link, _parsed_next_link.path), params=_next_request_params) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore request.method = "GET" return request @@ -7034,10 +9292,8 @@ async def extract_data(pipeline_response): async def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) response = pipeline_response.http_response @@ -7047,82 +9303,139 @@ async def get_next(next_link=None): return pipeline_response + return AsyncItemPaged(get_next, extract_data) - return AsyncItemPaged( - get_next, extract_data - ) - list.metadata = {'url': "/subscriptions/{subscriptionId}/tagNames"} # type: ignore + list.metadata = {"url": "/subscriptions/{subscriptionId}/tagNames"} # type: ignore - @distributed_trace_async + @overload async def create_or_update_at_scope( - self, - scope: str, - parameters: "_models.TagsResource", - **kwargs: Any - ) -> "_models.TagsResource": + self, scope: str, parameters: _models.TagsResource, *, content_type: str = "application/json", **kwargs: Any + ) -> _models.TagsResource: """Creates or updates the entire set of tags on a resource or subscription. This operation allows adding or replacing the entire set of tags on the specified resource or subscription. The specified entity can have a maximum of 50 tags. - :param scope: The resource scope. + :param scope: The resource scope. Required. :type scope: str - :param parameters: + :param parameters: Required. :type parameters: ~azure.mgmt.resource.resources.v2021_04_01.models.TagsResource + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: TagsResource or the result of cls(response) + :rtype: ~azure.mgmt.resource.resources.v2021_04_01.models.TagsResource + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + async def create_or_update_at_scope( + self, scope: str, parameters: IO, *, content_type: str = "application/json", **kwargs: Any + ) -> _models.TagsResource: + """Creates or updates the entire set of tags on a resource or subscription. + + This operation allows adding or replacing the entire set of tags on the specified resource or + subscription. The specified entity can have a maximum of 50 tags. + + :param scope: The resource scope. Required. + :type scope: str + :param parameters: Required. + :type parameters: IO + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: TagsResource or the result of cls(response) + :rtype: ~azure.mgmt.resource.resources.v2021_04_01.models.TagsResource + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace_async + async def create_or_update_at_scope( + self, scope: str, parameters: Union[_models.TagsResource, IO], **kwargs: Any + ) -> _models.TagsResource: + """Creates or updates the entire set of tags on a resource or subscription. + + This operation allows adding or replacing the entire set of tags on the specified resource or + subscription. The specified entity can have a maximum of 50 tags. + + :param scope: The resource scope. Required. + :type scope: str + :param parameters: Is either a model type or a IO type. Required. + :type parameters: ~azure.mgmt.resource.resources.v2021_04_01.models.TagsResource or IO + :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. + Default value is None. + :paramtype content_type: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: TagsResource, or the result of cls(response) + :return: TagsResource or the result of cls(response) :rtype: ~azure.mgmt.resource.resources.v2021_04_01.models.TagsResource - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.TagsResource"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) - api_version = kwargs.pop('api_version', "2021-04-01") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - _json = self._serialize.body(parameters, 'TagsResource') + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-04-01")) # type: str + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.TagsResource] + + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(parameters, (IO, bytes)): + _content = parameters + else: + _json = self._serialize.body(parameters, "TagsResource") request = build_tags_create_or_update_at_scope_request( scope=scope, api_version=api_version, content_type=content_type, json=_json, - template_url=self.create_or_update_at_scope.metadata['url'], + content=_content, + template_url=self.create_or_update_at_scope.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) - deserialized = self._deserialize('TagsResource', pipeline_response) + deserialized = self._deserialize("TagsResource", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - create_or_update_at_scope.metadata = {'url': "/{scope}/providers/Microsoft.Resources/tags/default"} # type: ignore - + create_or_update_at_scope.metadata = {"url": "/{scope}/providers/Microsoft.Resources/tags/default"} # type: ignore - @distributed_trace_async + @overload async def update_at_scope( self, scope: str, - parameters: "_models.TagsPatchResource", + parameters: _models.TagsPatchResource, + *, + content_type: str = "application/json", **kwargs: Any - ) -> "_models.TagsResource": + ) -> _models.TagsResource: """Selectively updates the set of tags on a resource or subscription. This operation allows replacing, merging or selectively deleting tags on the specified resource @@ -7132,151 +9445,224 @@ async def update_at_scope( names. The 'delete' option allows selectively deleting tags based on given names or name/value pairs. - :param scope: The resource scope. + :param scope: The resource scope. Required. :type scope: str - :param parameters: + :param parameters: Required. :type parameters: ~azure.mgmt.resource.resources.v2021_04_01.models.TagsPatchResource + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: TagsResource or the result of cls(response) + :rtype: ~azure.mgmt.resource.resources.v2021_04_01.models.TagsResource + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + async def update_at_scope( + self, scope: str, parameters: IO, *, content_type: str = "application/json", **kwargs: Any + ) -> _models.TagsResource: + """Selectively updates the set of tags on a resource or subscription. + + This operation allows replacing, merging or selectively deleting tags on the specified resource + or subscription. The specified entity can have a maximum of 50 tags at the end of the + operation. The 'replace' option replaces the entire set of existing tags with a new set. The + 'merge' option allows adding tags with new names and updating the values of tags with existing + names. The 'delete' option allows selectively deleting tags based on given names or name/value + pairs. + + :param scope: The resource scope. Required. + :type scope: str + :param parameters: Required. + :type parameters: IO + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: TagsResource or the result of cls(response) + :rtype: ~azure.mgmt.resource.resources.v2021_04_01.models.TagsResource + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace_async + async def update_at_scope( + self, scope: str, parameters: Union[_models.TagsPatchResource, IO], **kwargs: Any + ) -> _models.TagsResource: + """Selectively updates the set of tags on a resource or subscription. + + This operation allows replacing, merging or selectively deleting tags on the specified resource + or subscription. The specified entity can have a maximum of 50 tags at the end of the + operation. The 'replace' option replaces the entire set of existing tags with a new set. The + 'merge' option allows adding tags with new names and updating the values of tags with existing + names. The 'delete' option allows selectively deleting tags based on given names or name/value + pairs. + + :param scope: The resource scope. Required. + :type scope: str + :param parameters: Is either a model type or a IO type. Required. + :type parameters: ~azure.mgmt.resource.resources.v2021_04_01.models.TagsPatchResource or IO + :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. + Default value is None. + :paramtype content_type: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: TagsResource, or the result of cls(response) + :return: TagsResource or the result of cls(response) :rtype: ~azure.mgmt.resource.resources.v2021_04_01.models.TagsResource - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.TagsResource"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', "2021-04-01") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-04-01")) # type: str + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.TagsResource] - _json = self._serialize.body(parameters, 'TagsPatchResource') + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(parameters, (IO, bytes)): + _content = parameters + else: + _json = self._serialize.body(parameters, "TagsPatchResource") request = build_tags_update_at_scope_request( scope=scope, api_version=api_version, content_type=content_type, json=_json, - template_url=self.update_at_scope.metadata['url'], + content=_content, + template_url=self.update_at_scope.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) - deserialized = self._deserialize('TagsResource', pipeline_response) + deserialized = self._deserialize("TagsResource", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - update_at_scope.metadata = {'url': "/{scope}/providers/Microsoft.Resources/tags/default"} # type: ignore - + update_at_scope.metadata = {"url": "/{scope}/providers/Microsoft.Resources/tags/default"} # type: ignore @distributed_trace_async - async def get_at_scope( - self, - scope: str, - **kwargs: Any - ) -> "_models.TagsResource": + async def get_at_scope(self, scope: str, **kwargs: Any) -> _models.TagsResource: """Gets the entire set of tags on a resource or subscription. Gets the entire set of tags on a resource or subscription. - :param scope: The resource scope. + :param scope: The resource scope. Required. :type scope: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: TagsResource, or the result of cls(response) + :return: TagsResource or the result of cls(response) :rtype: ~azure.mgmt.resource.resources.v2021_04_01.models.TagsResource - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.TagsResource"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + 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', "2021-04-01") # type: str + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-04-01")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[_models.TagsResource] - request = build_tags_get_at_scope_request( scope=scope, api_version=api_version, - template_url=self.get_at_scope.metadata['url'], + template_url=self.get_at_scope.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) - deserialized = self._deserialize('TagsResource', pipeline_response) + deserialized = self._deserialize("TagsResource", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - get_at_scope.metadata = {'url': "/{scope}/providers/Microsoft.Resources/tags/default"} # type: ignore - + get_at_scope.metadata = {"url": "/{scope}/providers/Microsoft.Resources/tags/default"} # type: ignore @distributed_trace_async async def delete_at_scope( # pylint: disable=inconsistent-return-statements - self, - scope: str, - **kwargs: Any + self, scope: str, **kwargs: Any ) -> None: """Deletes the entire set of tags on a resource or subscription. Deletes the entire set of tags on a resource or subscription. - :param scope: The resource scope. + :param scope: The resource scope. Required. :type scope: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: None, or the result of cls(response) + :return: None or the result of cls(response) :rtype: None - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType[None] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + 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', "2021-04-01") # type: str + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-04-01")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[None] - request = build_tags_delete_at_scope_request( scope=scope, api_version=api_version, - template_url=self.delete_at_scope.metadata['url'], + template_url=self.delete_at_scope.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200]: @@ -7286,143 +9672,145 @@ async def delete_at_scope( # pylint: disable=inconsistent-return-statements if cls: return cls(pipeline_response, None, {}) - delete_at_scope.metadata = {'url': "/{scope}/providers/Microsoft.Resources/tags/default"} # type: ignore + delete_at_scope.metadata = {"url": "/{scope}/providers/Microsoft.Resources/tags/default"} # type: ignore -class DeploymentOperationsOperations: - """DeploymentOperationsOperations async operations. - You should not instantiate this class directly. Instead, you should create a Client instance that - instantiates it for you and attaches it as an attribute. +class DeploymentOperationsOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. - :ivar models: Alias to model classes used in this operation group. - :type models: ~azure.mgmt.resource.resources.v2021_04_01.models - :param client: Client for service requests. - :param config: Configuration of service client. - :param serializer: An object model serializer. - :param deserializer: An object model deserializer. + Instead, you should access the following operations through + :class:`~azure.mgmt.resource.resources.v2021_04_01.aio.ResourceManagementClient`'s + :attr:`deployment_operations` attribute. """ models = _models - def __init__(self, client, config, serializer, deserializer) -> None: - self._client = client - self._serialize = serializer - self._deserialize = deserializer - self._config = config + def __init__(self, *args, **kwargs) -> None: + input_args = list(args) + self._client = input_args.pop(0) if input_args else kwargs.pop("client") + self._config = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") @distributed_trace_async async def get_at_scope( - self, - scope: str, - deployment_name: str, - operation_id: str, - **kwargs: Any - ) -> "_models.DeploymentOperation": + self, scope: str, deployment_name: str, operation_id: str, **kwargs: Any + ) -> _models.DeploymentOperation: """Gets a deployments operation. - :param scope: The resource scope. + :param scope: The resource scope. Required. :type scope: str - :param deployment_name: The name of the deployment. + :param deployment_name: The name of the deployment. Required. :type deployment_name: str - :param operation_id: The ID of the operation to get. + :param operation_id: The ID of the operation to get. Required. :type operation_id: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: DeploymentOperation, or the result of cls(response) + :return: DeploymentOperation or the result of cls(response) :rtype: ~azure.mgmt.resource.resources.v2021_04_01.models.DeploymentOperation - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.DeploymentOperation"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) - api_version = kwargs.pop('api_version', "2021-04-01") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-04-01")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[_models.DeploymentOperation] - request = build_deployment_operations_get_at_scope_request( scope=scope, deployment_name=deployment_name, operation_id=operation_id, api_version=api_version, - template_url=self.get_at_scope.metadata['url'], + template_url=self.get_at_scope.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) - deserialized = self._deserialize('DeploymentOperation', pipeline_response) + deserialized = self._deserialize("DeploymentOperation", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - get_at_scope.metadata = {'url': "/{scope}/providers/Microsoft.Resources/deployments/{deploymentName}/operations/{operationId}"} # type: ignore - + get_at_scope.metadata = {"url": "/{scope}/providers/Microsoft.Resources/deployments/{deploymentName}/operations/{operationId}"} # type: ignore @distributed_trace def list_at_scope( - self, - scope: str, - deployment_name: str, - top: Optional[int] = None, - **kwargs: Any - ) -> AsyncIterable["_models.DeploymentOperationsListResult"]: + self, scope: str, deployment_name: str, top: Optional[int] = None, **kwargs: Any + ) -> AsyncIterable["_models.DeploymentOperation"]: """Gets all deployments operations for a deployment. - :param scope: The resource scope. + :param scope: The resource scope. Required. :type scope: str - :param deployment_name: The name of the deployment. + :param deployment_name: The name of the deployment. Required. :type deployment_name: str :param top: The number of results to return. Default value is None. :type top: int :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either DeploymentOperationsListResult or the result of - cls(response) + :return: An iterator like instance of either DeploymentOperation or the result of cls(response) :rtype: - ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.resource.resources.v2021_04_01.models.DeploymentOperationsListResult] - :raises: ~azure.core.exceptions.HttpResponseError + ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.resource.resources.v2021_04_01.models.DeploymentOperation] + :raises ~azure.core.exceptions.HttpResponseError: """ - api_version = kwargs.pop('api_version', "2021-04-01") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-04-01")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[_models.DeploymentOperationsListResult] - cls = kwargs.pop('cls', None) # type: ClsType["_models.DeploymentOperationsListResult"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) + def prepare_request(next_link=None): if not next_link: - + request = build_deployment_operations_list_at_scope_request( scope=scope, deployment_name=deployment_name, - api_version=api_version, top=top, - template_url=self.list_at_scope.metadata['url'], + api_version=api_version, + template_url=self.list_at_scope.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore else: - - request = build_deployment_operations_list_at_scope_request( - scope=scope, - deployment_name=deployment_name, - template_url=next_link, - ) + # make call to next link with the client's api-version + _parsed_next_link = urlparse(next_link) + _next_request_params = case_insensitive_dict(parse_qs(_parsed_next_link.query)) + _next_request_params["api-version"] = self._config.api_version + request = HttpRequest("GET", urljoin(next_link, _parsed_next_link.path), params=_next_request_params) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore request.method = "GET" return request @@ -7436,10 +9824,8 @@ async def extract_data(pipeline_response): async def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) response = pipeline_response.http_response @@ -7449,116 +9835,121 @@ async def get_next(next_link=None): return pipeline_response + return AsyncItemPaged(get_next, extract_data) - return AsyncItemPaged( - get_next, extract_data - ) - list_at_scope.metadata = {'url': "/{scope}/providers/Microsoft.Resources/deployments/{deploymentName}/operations"} # type: ignore + list_at_scope.metadata = {"url": "/{scope}/providers/Microsoft.Resources/deployments/{deploymentName}/operations"} # type: ignore @distributed_trace_async async def get_at_tenant_scope( - self, - deployment_name: str, - operation_id: str, - **kwargs: Any - ) -> "_models.DeploymentOperation": + self, deployment_name: str, operation_id: str, **kwargs: Any + ) -> _models.DeploymentOperation: """Gets a deployments operation. - :param deployment_name: The name of the deployment. + :param deployment_name: The name of the deployment. Required. :type deployment_name: str - :param operation_id: The ID of the operation to get. + :param operation_id: The ID of the operation to get. Required. :type operation_id: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: DeploymentOperation, or the result of cls(response) + :return: DeploymentOperation or the result of cls(response) :rtype: ~azure.mgmt.resource.resources.v2021_04_01.models.DeploymentOperation - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.DeploymentOperation"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + 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', "2021-04-01") # type: str + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-04-01")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[_models.DeploymentOperation] - request = build_deployment_operations_get_at_tenant_scope_request( deployment_name=deployment_name, operation_id=operation_id, api_version=api_version, - template_url=self.get_at_tenant_scope.metadata['url'], + template_url=self.get_at_tenant_scope.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) - deserialized = self._deserialize('DeploymentOperation', pipeline_response) + deserialized = self._deserialize("DeploymentOperation", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - get_at_tenant_scope.metadata = {'url': "/providers/Microsoft.Resources/deployments/{deploymentName}/operations/{operationId}"} # type: ignore - + get_at_tenant_scope.metadata = {"url": "/providers/Microsoft.Resources/deployments/{deploymentName}/operations/{operationId}"} # type: ignore @distributed_trace def list_at_tenant_scope( - self, - deployment_name: str, - top: Optional[int] = None, - **kwargs: Any - ) -> AsyncIterable["_models.DeploymentOperationsListResult"]: + self, deployment_name: str, top: Optional[int] = None, **kwargs: Any + ) -> AsyncIterable["_models.DeploymentOperation"]: """Gets all deployments operations for a deployment. - :param deployment_name: The name of the deployment. + :param deployment_name: The name of the deployment. Required. :type deployment_name: str :param top: The number of results to return. Default value is None. :type top: int :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either DeploymentOperationsListResult or the result of - cls(response) + :return: An iterator like instance of either DeploymentOperation or the result of cls(response) :rtype: - ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.resource.resources.v2021_04_01.models.DeploymentOperationsListResult] - :raises: ~azure.core.exceptions.HttpResponseError + ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.resource.resources.v2021_04_01.models.DeploymentOperation] + :raises ~azure.core.exceptions.HttpResponseError: """ - api_version = kwargs.pop('api_version', "2021-04-01") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-04-01")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[_models.DeploymentOperationsListResult] - cls = kwargs.pop('cls', None) # type: ClsType["_models.DeploymentOperationsListResult"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) + def prepare_request(next_link=None): if not next_link: - + request = build_deployment_operations_list_at_tenant_scope_request( deployment_name=deployment_name, - api_version=api_version, top=top, - template_url=self.list_at_tenant_scope.metadata['url'], + api_version=api_version, + template_url=self.list_at_tenant_scope.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore else: - - request = build_deployment_operations_list_at_tenant_scope_request( - deployment_name=deployment_name, - template_url=next_link, - ) + # make call to next link with the client's api-version + _parsed_next_link = urlparse(next_link) + _next_request_params = case_insensitive_dict(parse_qs(_parsed_next_link.query)) + _next_request_params["api-version"] = self._config.api_version + request = HttpRequest("GET", urljoin(next_link, _parsed_next_link.path), params=_next_request_params) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore request.method = "GET" return request @@ -7572,10 +9963,8 @@ async def extract_data(pipeline_response): async def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) response = pipeline_response.http_response @@ -7585,125 +9974,127 @@ async def get_next(next_link=None): return pipeline_response + return AsyncItemPaged(get_next, extract_data) - return AsyncItemPaged( - get_next, extract_data - ) - list_at_tenant_scope.metadata = {'url': "/providers/Microsoft.Resources/deployments/{deploymentName}/operations"} # type: ignore + list_at_tenant_scope.metadata = {"url": "/providers/Microsoft.Resources/deployments/{deploymentName}/operations"} # type: ignore @distributed_trace_async async def get_at_management_group_scope( - self, - group_id: str, - deployment_name: str, - operation_id: str, - **kwargs: Any - ) -> "_models.DeploymentOperation": + self, group_id: str, deployment_name: str, operation_id: str, **kwargs: Any + ) -> _models.DeploymentOperation: """Gets a deployments operation. - :param group_id: The management group ID. + :param group_id: The management group ID. Required. :type group_id: str - :param deployment_name: The name of the deployment. + :param deployment_name: The name of the deployment. Required. :type deployment_name: str - :param operation_id: The ID of the operation to get. + :param operation_id: The ID of the operation to get. Required. :type operation_id: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: DeploymentOperation, or the result of cls(response) + :return: DeploymentOperation or the result of cls(response) :rtype: ~azure.mgmt.resource.resources.v2021_04_01.models.DeploymentOperation - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.DeploymentOperation"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + 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', "2021-04-01") # type: str + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-04-01")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[_models.DeploymentOperation] - request = build_deployment_operations_get_at_management_group_scope_request( group_id=group_id, deployment_name=deployment_name, operation_id=operation_id, api_version=api_version, - template_url=self.get_at_management_group_scope.metadata['url'], + template_url=self.get_at_management_group_scope.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) - deserialized = self._deserialize('DeploymentOperation', pipeline_response) + deserialized = self._deserialize("DeploymentOperation", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - get_at_management_group_scope.metadata = {'url': "/providers/Microsoft.Management/managementGroups/{groupId}/providers/Microsoft.Resources/deployments/{deploymentName}/operations/{operationId}"} # type: ignore - + get_at_management_group_scope.metadata = {"url": "/providers/Microsoft.Management/managementGroups/{groupId}/providers/Microsoft.Resources/deployments/{deploymentName}/operations/{operationId}"} # type: ignore @distributed_trace def list_at_management_group_scope( - self, - group_id: str, - deployment_name: str, - top: Optional[int] = None, - **kwargs: Any - ) -> AsyncIterable["_models.DeploymentOperationsListResult"]: + self, group_id: str, deployment_name: str, top: Optional[int] = None, **kwargs: Any + ) -> AsyncIterable["_models.DeploymentOperation"]: """Gets all deployments operations for a deployment. - :param group_id: The management group ID. + :param group_id: The management group ID. Required. :type group_id: str - :param deployment_name: The name of the deployment. + :param deployment_name: The name of the deployment. Required. :type deployment_name: str :param top: The number of results to return. Default value is None. :type top: int :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either DeploymentOperationsListResult or the result of - cls(response) + :return: An iterator like instance of either DeploymentOperation or the result of cls(response) :rtype: - ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.resource.resources.v2021_04_01.models.DeploymentOperationsListResult] - :raises: ~azure.core.exceptions.HttpResponseError + ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.resource.resources.v2021_04_01.models.DeploymentOperation] + :raises ~azure.core.exceptions.HttpResponseError: """ - api_version = kwargs.pop('api_version', "2021-04-01") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-04-01")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[_models.DeploymentOperationsListResult] - cls = kwargs.pop('cls', None) # type: ClsType["_models.DeploymentOperationsListResult"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) + def prepare_request(next_link=None): if not next_link: - + request = build_deployment_operations_list_at_management_group_scope_request( group_id=group_id, deployment_name=deployment_name, - api_version=api_version, top=top, - template_url=self.list_at_management_group_scope.metadata['url'], + api_version=api_version, + template_url=self.list_at_management_group_scope.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore else: - - request = build_deployment_operations_list_at_management_group_scope_request( - group_id=group_id, - deployment_name=deployment_name, - template_url=next_link, - ) + # make call to next link with the client's api-version + _parsed_next_link = urlparse(next_link) + _next_request_params = case_insensitive_dict(parse_qs(_parsed_next_link.query)) + _next_request_params["api-version"] = self._config.api_version + request = HttpRequest("GET", urljoin(next_link, _parsed_next_link.path), params=_next_request_params) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore request.method = "GET" return request @@ -7717,10 +10108,8 @@ async def extract_data(pipeline_response): async def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) response = pipeline_response.http_response @@ -7730,119 +10119,123 @@ async def get_next(next_link=None): return pipeline_response + return AsyncItemPaged(get_next, extract_data) - return AsyncItemPaged( - get_next, extract_data - ) - list_at_management_group_scope.metadata = {'url': "/providers/Microsoft.Management/managementGroups/{groupId}/providers/Microsoft.Resources/deployments/{deploymentName}/operations"} # type: ignore + list_at_management_group_scope.metadata = {"url": "/providers/Microsoft.Management/managementGroups/{groupId}/providers/Microsoft.Resources/deployments/{deploymentName}/operations"} # type: ignore @distributed_trace_async async def get_at_subscription_scope( - self, - deployment_name: str, - operation_id: str, - **kwargs: Any - ) -> "_models.DeploymentOperation": + self, deployment_name: str, operation_id: str, **kwargs: Any + ) -> _models.DeploymentOperation: """Gets a deployments operation. - :param deployment_name: The name of the deployment. + :param deployment_name: The name of the deployment. Required. :type deployment_name: str - :param operation_id: The ID of the operation to get. + :param operation_id: The ID of the operation to get. Required. :type operation_id: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: DeploymentOperation, or the result of cls(response) + :return: DeploymentOperation or the result of cls(response) :rtype: ~azure.mgmt.resource.resources.v2021_04_01.models.DeploymentOperation - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.DeploymentOperation"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) - api_version = kwargs.pop('api_version', "2021-04-01") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-04-01")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[_models.DeploymentOperation] - request = build_deployment_operations_get_at_subscription_scope_request( deployment_name=deployment_name, operation_id=operation_id, subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.get_at_subscription_scope.metadata['url'], + template_url=self.get_at_subscription_scope.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) - deserialized = self._deserialize('DeploymentOperation', pipeline_response) + deserialized = self._deserialize("DeploymentOperation", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - get_at_subscription_scope.metadata = {'url': "/subscriptions/{subscriptionId}/providers/Microsoft.Resources/deployments/{deploymentName}/operations/{operationId}"} # type: ignore - + get_at_subscription_scope.metadata = {"url": "/subscriptions/{subscriptionId}/providers/Microsoft.Resources/deployments/{deploymentName}/operations/{operationId}"} # type: ignore @distributed_trace def list_at_subscription_scope( - self, - deployment_name: str, - top: Optional[int] = None, - **kwargs: Any - ) -> AsyncIterable["_models.DeploymentOperationsListResult"]: + self, deployment_name: str, top: Optional[int] = None, **kwargs: Any + ) -> AsyncIterable["_models.DeploymentOperation"]: """Gets all deployments operations for a deployment. - :param deployment_name: The name of the deployment. + :param deployment_name: The name of the deployment. Required. :type deployment_name: str :param top: The number of results to return. Default value is None. :type top: int :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either DeploymentOperationsListResult or the result of - cls(response) + :return: An iterator like instance of either DeploymentOperation or the result of cls(response) :rtype: - ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.resource.resources.v2021_04_01.models.DeploymentOperationsListResult] - :raises: ~azure.core.exceptions.HttpResponseError + ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.resource.resources.v2021_04_01.models.DeploymentOperation] + :raises ~azure.core.exceptions.HttpResponseError: """ - api_version = kwargs.pop('api_version', "2021-04-01") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-04-01")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[_models.DeploymentOperationsListResult] - cls = kwargs.pop('cls', None) # type: ClsType["_models.DeploymentOperationsListResult"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) + def prepare_request(next_link=None): if not next_link: - + request = build_deployment_operations_list_at_subscription_scope_request( deployment_name=deployment_name, subscription_id=self._config.subscription_id, - api_version=api_version, top=top, - template_url=self.list_at_subscription_scope.metadata['url'], + api_version=api_version, + template_url=self.list_at_subscription_scope.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore else: - - request = build_deployment_operations_list_at_subscription_scope_request( - deployment_name=deployment_name, - subscription_id=self._config.subscription_id, - template_url=next_link, - ) + # make call to next link with the client's api-version + _parsed_next_link = urlparse(next_link) + _next_request_params = case_insensitive_dict(parse_qs(_parsed_next_link.query)) + _next_request_params["api-version"] = self._config.api_version + request = HttpRequest("GET", urljoin(next_link, _parsed_next_link.path), params=_next_request_params) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore request.method = "GET" return request @@ -7856,10 +10249,8 @@ async def extract_data(pipeline_response): async def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) response = pipeline_response.http_response @@ -7869,128 +10260,131 @@ async def get_next(next_link=None): return pipeline_response + return AsyncItemPaged(get_next, extract_data) - return AsyncItemPaged( - get_next, extract_data - ) - list_at_subscription_scope.metadata = {'url': "/subscriptions/{subscriptionId}/providers/Microsoft.Resources/deployments/{deploymentName}/operations"} # type: ignore + list_at_subscription_scope.metadata = {"url": "/subscriptions/{subscriptionId}/providers/Microsoft.Resources/deployments/{deploymentName}/operations"} # type: ignore @distributed_trace_async async def get( - self, - resource_group_name: str, - deployment_name: str, - operation_id: str, - **kwargs: Any - ) -> "_models.DeploymentOperation": + self, resource_group_name: str, deployment_name: str, operation_id: str, **kwargs: Any + ) -> _models.DeploymentOperation: """Gets a deployments operation. :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. :type resource_group_name: str - :param deployment_name: The name of the deployment. + :param deployment_name: The name of the deployment. Required. :type deployment_name: str - :param operation_id: The ID of the operation to get. + :param operation_id: The ID of the operation to get. Required. :type operation_id: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: DeploymentOperation, or the result of cls(response) + :return: DeploymentOperation or the result of cls(response) :rtype: ~azure.mgmt.resource.resources.v2021_04_01.models.DeploymentOperation - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.DeploymentOperation"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + 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', "2021-04-01") # type: str + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-04-01")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[_models.DeploymentOperation] - request = build_deployment_operations_get_request( resource_group_name=resource_group_name, deployment_name=deployment_name, operation_id=operation_id, subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.get.metadata['url'], + template_url=self.get.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) - deserialized = self._deserialize('DeploymentOperation', pipeline_response) + deserialized = self._deserialize("DeploymentOperation", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - get.metadata = {'url': "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/deployments/{deploymentName}/operations/{operationId}"} # type: ignore - + get.metadata = {"url": "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/deployments/{deploymentName}/operations/{operationId}"} # type: ignore @distributed_trace def list( - self, - resource_group_name: str, - deployment_name: str, - top: Optional[int] = None, - **kwargs: Any - ) -> AsyncIterable["_models.DeploymentOperationsListResult"]: + self, resource_group_name: str, deployment_name: str, top: Optional[int] = None, **kwargs: Any + ) -> AsyncIterable["_models.DeploymentOperation"]: """Gets all deployments operations for a deployment. :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. :type resource_group_name: str - :param deployment_name: The name of the deployment. + :param deployment_name: The name of the deployment. Required. :type deployment_name: str :param top: The number of results to return. Default value is None. :type top: int :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either DeploymentOperationsListResult or the result of - cls(response) + :return: An iterator like instance of either DeploymentOperation or the result of cls(response) :rtype: - ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.resource.resources.v2021_04_01.models.DeploymentOperationsListResult] - :raises: ~azure.core.exceptions.HttpResponseError + ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.resource.resources.v2021_04_01.models.DeploymentOperation] + :raises ~azure.core.exceptions.HttpResponseError: """ - api_version = kwargs.pop('api_version', "2021-04-01") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-04-01")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[_models.DeploymentOperationsListResult] - cls = kwargs.pop('cls', None) # type: ClsType["_models.DeploymentOperationsListResult"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) + def prepare_request(next_link=None): if not next_link: - + request = build_deployment_operations_list_request( resource_group_name=resource_group_name, deployment_name=deployment_name, subscription_id=self._config.subscription_id, - api_version=api_version, top=top, - template_url=self.list.metadata['url'], + 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.url = self._client.format_url(request.url) # type: ignore else: - - request = build_deployment_operations_list_request( - resource_group_name=resource_group_name, - deployment_name=deployment_name, - subscription_id=self._config.subscription_id, - template_url=next_link, - ) + # make call to next link with the client's api-version + _parsed_next_link = urlparse(next_link) + _next_request_params = case_insensitive_dict(parse_qs(_parsed_next_link.query)) + _next_request_params["api-version"] = self._config.api_version + request = HttpRequest("GET", urljoin(next_link, _parsed_next_link.path), params=_next_request_params) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore request.method = "GET" return request @@ -8004,10 +10398,8 @@ async def extract_data(pipeline_response): async def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) response = pipeline_response.http_response @@ -8017,8 +10409,6 @@ async def get_next(next_link=None): return pipeline_response + return AsyncItemPaged(get_next, extract_data) - return AsyncItemPaged( - get_next, extract_data - ) - list.metadata = {'url': "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/deployments/{deploymentName}/operations"} # type: ignore + list.metadata = {"url": "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/deployments/{deploymentName}/operations"} # type: ignore diff --git a/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/resources/v2021_04_01/aio/operations/_patch.py b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/resources/v2021_04_01/aio/operations/_patch.py new file mode 100644 index 0000000000000..f7dd32510333d --- /dev/null +++ b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/resources/v2021_04_01/aio/operations/_patch.py @@ -0,0 +1,20 @@ +# ------------------------------------ +# Copyright (c) Microsoft Corporation. +# Licensed under the MIT License. +# ------------------------------------ +"""Customize generated code here. + +Follow our quickstart for examples: https://aka.ms/azsdk/python/dpcodegen/python/customize +""" +from typing import List + +__all__: List[str] = [] # Add all objects you want publicly available to users at this package level + + +def patch_sdk(): + """Do not remove from this file. + + `patch_sdk` is a last resort escape hatch that allows you to do customizations + you can't accomplish using the techniques described in + https://aka.ms/azsdk/python/dpcodegen/python/customize + """ diff --git a/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/resources/v2021_04_01/models/__init__.py b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/resources/v2021_04_01/models/__init__.py index c72ff6e2f2257..bdec9c08172c1 100644 --- a/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/resources/v2021_04_01/models/__init__.py +++ b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/resources/v2021_04_01/models/__init__.py @@ -88,122 +88,124 @@ from ._models_py3 import WhatIfPropertyChange from ._models_py3 import ZoneMapping - -from ._resource_management_client_enums import ( - AliasPathAttributes, - AliasPathTokenType, - AliasPatternType, - AliasType, - ChangeType, - DeploymentMode, - ExpressionEvaluationOptionsScopeType, - ExtendedLocationType, - OnErrorDeploymentType, - PropertyChangeType, - ProviderAuthorizationConsentState, - ProvisioningOperation, - ProvisioningState, - ResourceIdentityType, - TagsPatchOperation, - WhatIfResultFormat, -) +from ._resource_management_client_enums import AliasPathAttributes +from ._resource_management_client_enums import AliasPathTokenType +from ._resource_management_client_enums import AliasPatternType +from ._resource_management_client_enums import AliasType +from ._resource_management_client_enums import ChangeType +from ._resource_management_client_enums import DeploymentMode +from ._resource_management_client_enums import ExpressionEvaluationOptionsScopeType +from ._resource_management_client_enums import ExtendedLocationType +from ._resource_management_client_enums import OnErrorDeploymentType +from ._resource_management_client_enums import PropertyChangeType +from ._resource_management_client_enums import ProviderAuthorizationConsentState +from ._resource_management_client_enums import ProvisioningOperation +from ._resource_management_client_enums import ProvisioningState +from ._resource_management_client_enums import ResourceIdentityType +from ._resource_management_client_enums import TagsPatchOperation +from ._resource_management_client_enums import WhatIfResultFormat +from ._patch import __all__ as _patch_all +from ._patch import * # type: ignore # pylint: disable=unused-wildcard-import +from ._patch import patch_sdk as _patch_sdk __all__ = [ - 'Alias', - 'AliasPath', - 'AliasPathMetadata', - 'AliasPattern', - 'ApiProfile', - 'BasicDependency', - 'DebugSetting', - 'Dependency', - 'Deployment', - 'DeploymentExportResult', - 'DeploymentExtended', - 'DeploymentExtendedFilter', - 'DeploymentListResult', - 'DeploymentOperation', - 'DeploymentOperationProperties', - 'DeploymentOperationsListResult', - 'DeploymentProperties', - 'DeploymentPropertiesExtended', - 'DeploymentValidateResult', - 'DeploymentWhatIf', - 'DeploymentWhatIfProperties', - 'DeploymentWhatIfSettings', - 'ErrorAdditionalInfo', - 'ErrorResponse', - 'ExportTemplateRequest', - 'ExpressionEvaluationOptions', - 'ExtendedLocation', - 'GenericResource', - 'GenericResourceExpanded', - 'GenericResourceFilter', - 'HttpMessage', - 'Identity', - 'IdentityUserAssignedIdentitiesValue', - 'OnErrorDeployment', - 'OnErrorDeploymentExtended', - 'Operation', - 'OperationDisplay', - 'OperationListResult', - 'ParametersLink', - 'Permission', - 'Plan', - 'Provider', - 'ProviderConsentDefinition', - 'ProviderExtendedLocation', - 'ProviderListResult', - 'ProviderPermission', - 'ProviderPermissionListResult', - 'ProviderRegistrationRequest', - 'ProviderResourceType', - 'ProviderResourceTypeListResult', - 'Resource', - 'ResourceGroup', - 'ResourceGroupExportResult', - 'ResourceGroupFilter', - 'ResourceGroupListResult', - 'ResourceGroupPatchable', - 'ResourceGroupProperties', - 'ResourceListResult', - 'ResourceProviderOperationDisplayProperties', - 'ResourceReference', - 'ResourcesMoveInfo', - 'RoleDefinition', - 'ScopedDeployment', - 'ScopedDeploymentWhatIf', - 'Sku', - 'StatusMessage', - 'SubResource', - 'TagCount', - 'TagDetails', - 'TagValue', - 'Tags', - 'TagsListResult', - 'TagsPatchResource', - 'TagsResource', - 'TargetResource', - 'TemplateHashResult', - 'TemplateLink', - 'WhatIfChange', - 'WhatIfOperationResult', - 'WhatIfPropertyChange', - 'ZoneMapping', - 'AliasPathAttributes', - 'AliasPathTokenType', - 'AliasPatternType', - 'AliasType', - 'ChangeType', - 'DeploymentMode', - 'ExpressionEvaluationOptionsScopeType', - 'ExtendedLocationType', - 'OnErrorDeploymentType', - 'PropertyChangeType', - 'ProviderAuthorizationConsentState', - 'ProvisioningOperation', - 'ProvisioningState', - 'ResourceIdentityType', - 'TagsPatchOperation', - 'WhatIfResultFormat', + "Alias", + "AliasPath", + "AliasPathMetadata", + "AliasPattern", + "ApiProfile", + "BasicDependency", + "DebugSetting", + "Dependency", + "Deployment", + "DeploymentExportResult", + "DeploymentExtended", + "DeploymentExtendedFilter", + "DeploymentListResult", + "DeploymentOperation", + "DeploymentOperationProperties", + "DeploymentOperationsListResult", + "DeploymentProperties", + "DeploymentPropertiesExtended", + "DeploymentValidateResult", + "DeploymentWhatIf", + "DeploymentWhatIfProperties", + "DeploymentWhatIfSettings", + "ErrorAdditionalInfo", + "ErrorResponse", + "ExportTemplateRequest", + "ExpressionEvaluationOptions", + "ExtendedLocation", + "GenericResource", + "GenericResourceExpanded", + "GenericResourceFilter", + "HttpMessage", + "Identity", + "IdentityUserAssignedIdentitiesValue", + "OnErrorDeployment", + "OnErrorDeploymentExtended", + "Operation", + "OperationDisplay", + "OperationListResult", + "ParametersLink", + "Permission", + "Plan", + "Provider", + "ProviderConsentDefinition", + "ProviderExtendedLocation", + "ProviderListResult", + "ProviderPermission", + "ProviderPermissionListResult", + "ProviderRegistrationRequest", + "ProviderResourceType", + "ProviderResourceTypeListResult", + "Resource", + "ResourceGroup", + "ResourceGroupExportResult", + "ResourceGroupFilter", + "ResourceGroupListResult", + "ResourceGroupPatchable", + "ResourceGroupProperties", + "ResourceListResult", + "ResourceProviderOperationDisplayProperties", + "ResourceReference", + "ResourcesMoveInfo", + "RoleDefinition", + "ScopedDeployment", + "ScopedDeploymentWhatIf", + "Sku", + "StatusMessage", + "SubResource", + "TagCount", + "TagDetails", + "TagValue", + "Tags", + "TagsListResult", + "TagsPatchResource", + "TagsResource", + "TargetResource", + "TemplateHashResult", + "TemplateLink", + "WhatIfChange", + "WhatIfOperationResult", + "WhatIfPropertyChange", + "ZoneMapping", + "AliasPathAttributes", + "AliasPathTokenType", + "AliasPatternType", + "AliasType", + "ChangeType", + "DeploymentMode", + "ExpressionEvaluationOptionsScopeType", + "ExtendedLocationType", + "OnErrorDeploymentType", + "PropertyChangeType", + "ProviderAuthorizationConsentState", + "ProvisioningOperation", + "ProvisioningState", + "ResourceIdentityType", + "TagsPatchOperation", + "WhatIfResultFormat", ] +__all__.extend([p for p in _patch_all if p not in __all__]) +_patch_sdk() diff --git a/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/resources/v2021_04_01/models/_models_py3.py b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/resources/v2021_04_01/models/_models_py3.py index c00a82795685b..1119e71ef54da 100644 --- a/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/resources/v2021_04_01/models/_models_py3.py +++ b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/resources/v2021_04_01/models/_models_py3.py @@ -1,4 +1,5 @@ # coding=utf-8 +# pylint: disable=too-many-lines # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. # Licensed under the MIT License. See License.txt in the project root for license information. @@ -6,14 +7,22 @@ # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -from typing import Any, Dict, List, Optional, Union +import sys +from typing import Any, Dict, List, Optional, TYPE_CHECKING, Union -import msrest.serialization +from ... import _serialization -from ._resource_management_client_enums import * +if TYPE_CHECKING: + # pylint: disable=unused-import,ungrouped-imports + from .. import models as _models +if sys.version_info >= (3, 9): + from collections.abc import MutableMapping +else: + from typing import MutableMapping # type: ignore # pylint: disable=ungrouped-imports +JSON = MutableMapping[str, Any] # pylint: disable=unsubscriptable-object -class Alias(msrest.serialization.Model): +class Alias(_serialization.Model): """The alias type. Variables are only populated by the server, and will be ignored when sending a request. @@ -22,8 +31,7 @@ class Alias(msrest.serialization.Model): :vartype name: str :ivar paths: The paths for an alias. :vartype paths: list[~azure.mgmt.resource.resources.v2021_04_01.models.AliasPath] - :ivar type: The type of the alias. Possible values include: "NotSpecified", "PlainText", - "Mask". + :ivar type: The type of the alias. Known values are: "NotSpecified", "PlainText", and "Mask". :vartype type: str or ~azure.mgmt.resource.resources.v2021_04_01.models.AliasType :ivar default_path: The default path for an alias. :vartype default_path: str @@ -35,26 +43,26 @@ class Alias(msrest.serialization.Model): """ _validation = { - 'default_metadata': {'readonly': True}, + "default_metadata": {"readonly": True}, } _attribute_map = { - 'name': {'key': 'name', 'type': 'str'}, - 'paths': {'key': 'paths', 'type': '[AliasPath]'}, - 'type': {'key': 'type', 'type': 'str'}, - 'default_path': {'key': 'defaultPath', 'type': 'str'}, - 'default_pattern': {'key': 'defaultPattern', 'type': 'AliasPattern'}, - 'default_metadata': {'key': 'defaultMetadata', 'type': 'AliasPathMetadata'}, + "name": {"key": "name", "type": "str"}, + "paths": {"key": "paths", "type": "[AliasPath]"}, + "type": {"key": "type", "type": "str"}, + "default_path": {"key": "defaultPath", "type": "str"}, + "default_pattern": {"key": "defaultPattern", "type": "AliasPattern"}, + "default_metadata": {"key": "defaultMetadata", "type": "AliasPathMetadata"}, } def __init__( self, *, name: Optional[str] = None, - paths: Optional[List["AliasPath"]] = None, - type: Optional[Union[str, "AliasType"]] = None, + paths: Optional[List["_models.AliasPath"]] = None, + type: Optional[Union[str, "_models.AliasType"]] = None, default_path: Optional[str] = None, - default_pattern: Optional["AliasPattern"] = None, + default_pattern: Optional["_models.AliasPattern"] = None, **kwargs ): """ @@ -62,7 +70,7 @@ def __init__( :paramtype name: str :keyword paths: The paths for an alias. :paramtype paths: list[~azure.mgmt.resource.resources.v2021_04_01.models.AliasPath] - :keyword type: The type of the alias. Possible values include: "NotSpecified", "PlainText", + :keyword type: The type of the alias. Known values are: "NotSpecified", "PlainText", and "Mask". :paramtype type: str or ~azure.mgmt.resource.resources.v2021_04_01.models.AliasType :keyword default_path: The default path for an alias. @@ -70,7 +78,7 @@ def __init__( :keyword default_pattern: The default pattern for an alias. :paramtype default_pattern: ~azure.mgmt.resource.resources.v2021_04_01.models.AliasPattern """ - super(Alias, self).__init__(**kwargs) + super().__init__(**kwargs) self.name = name self.paths = paths self.type = type @@ -79,7 +87,7 @@ def __init__( self.default_metadata = None -class AliasPath(msrest.serialization.Model): +class AliasPath(_serialization.Model): """The type of the paths for alias. Variables are only populated by the server, and will be ignored when sending a request. @@ -96,14 +104,14 @@ class AliasPath(msrest.serialization.Model): """ _validation = { - 'metadata': {'readonly': True}, + "metadata": {"readonly": True}, } _attribute_map = { - 'path': {'key': 'path', 'type': 'str'}, - 'api_versions': {'key': 'apiVersions', 'type': '[str]'}, - 'pattern': {'key': 'pattern', 'type': 'AliasPattern'}, - 'metadata': {'key': 'metadata', 'type': 'AliasPathMetadata'}, + "path": {"key": "path", "type": "str"}, + "api_versions": {"key": "apiVersions", "type": "[str]"}, + "pattern": {"key": "pattern", "type": "AliasPattern"}, + "metadata": {"key": "metadata", "type": "AliasPathMetadata"}, } def __init__( @@ -111,7 +119,7 @@ def __init__( *, path: Optional[str] = None, api_versions: Optional[List[str]] = None, - pattern: Optional["AliasPattern"] = None, + pattern: Optional["_models.AliasPattern"] = None, **kwargs ): """ @@ -122,63 +130,59 @@ def __init__( :keyword pattern: The pattern for an alias path. :paramtype pattern: ~azure.mgmt.resource.resources.v2021_04_01.models.AliasPattern """ - super(AliasPath, self).__init__(**kwargs) + super().__init__(**kwargs) self.path = path self.api_versions = api_versions self.pattern = pattern self.metadata = None -class AliasPathMetadata(msrest.serialization.Model): +class AliasPathMetadata(_serialization.Model): """AliasPathMetadata. Variables are only populated by the server, and will be ignored when sending a request. - :ivar type: The type of the token that the alias path is referring to. Possible values include: - "NotSpecified", "Any", "String", "Object", "Array", "Integer", "Number", "Boolean". + :ivar type: The type of the token that the alias path is referring to. Known values are: + "NotSpecified", "Any", "String", "Object", "Array", "Integer", "Number", and "Boolean". :vartype type: str or ~azure.mgmt.resource.resources.v2021_04_01.models.AliasPathTokenType - :ivar attributes: The attributes of the token that the alias path is referring to. Possible - values include: "None", "Modifiable". + :ivar attributes: The attributes of the token that the alias path is referring to. Known values + are: "None" and "Modifiable". :vartype attributes: str or ~azure.mgmt.resource.resources.v2021_04_01.models.AliasPathAttributes """ _validation = { - 'type': {'readonly': True}, - 'attributes': {'readonly': True}, + "type": {"readonly": True}, + "attributes": {"readonly": True}, } _attribute_map = { - 'type': {'key': 'type', 'type': 'str'}, - 'attributes': {'key': 'attributes', 'type': 'str'}, + "type": {"key": "type", "type": "str"}, + "attributes": {"key": "attributes", "type": "str"}, } - def __init__( - self, - **kwargs - ): - """ - """ - super(AliasPathMetadata, self).__init__(**kwargs) + def __init__(self, **kwargs): + """ """ + super().__init__(**kwargs) self.type = None self.attributes = None -class AliasPattern(msrest.serialization.Model): +class AliasPattern(_serialization.Model): """The type of the pattern for an alias path. :ivar phrase: The alias pattern phrase. :vartype phrase: str :ivar variable: The alias pattern variable. :vartype variable: str - :ivar type: The type of alias pattern. Possible values include: "NotSpecified", "Extract". + :ivar type: The type of alias pattern. Known values are: "NotSpecified" and "Extract". :vartype type: str or ~azure.mgmt.resource.resources.v2021_04_01.models.AliasPatternType """ _attribute_map = { - 'phrase': {'key': 'phrase', 'type': 'str'}, - 'variable': {'key': 'variable', 'type': 'str'}, - 'type': {'key': 'type', 'type': 'str'}, + "phrase": {"key": "phrase", "type": "str"}, + "variable": {"key": "variable", "type": "str"}, + "type": {"key": "type", "type": "str"}, } def __init__( @@ -186,7 +190,7 @@ def __init__( *, phrase: Optional[str] = None, variable: Optional[str] = None, - type: Optional[Union[str, "AliasPatternType"]] = None, + type: Optional[Union[str, "_models.AliasPatternType"]] = None, **kwargs ): """ @@ -194,16 +198,16 @@ def __init__( :paramtype phrase: str :keyword variable: The alias pattern variable. :paramtype variable: str - :keyword type: The type of alias pattern. Possible values include: "NotSpecified", "Extract". + :keyword type: The type of alias pattern. Known values are: "NotSpecified" and "Extract". :paramtype type: str or ~azure.mgmt.resource.resources.v2021_04_01.models.AliasPatternType """ - super(AliasPattern, self).__init__(**kwargs) + super().__init__(**kwargs) self.phrase = phrase self.variable = variable self.type = type -class ApiProfile(msrest.serialization.Model): +class ApiProfile(_serialization.Model): """ApiProfile. Variables are only populated by the server, and will be ignored when sending a request. @@ -215,27 +219,23 @@ class ApiProfile(msrest.serialization.Model): """ _validation = { - 'profile_version': {'readonly': True}, - 'api_version': {'readonly': True}, + "profile_version": {"readonly": True}, + "api_version": {"readonly": True}, } _attribute_map = { - 'profile_version': {'key': 'profileVersion', 'type': 'str'}, - 'api_version': {'key': 'apiVersion', 'type': 'str'}, + "profile_version": {"key": "profileVersion", "type": "str"}, + "api_version": {"key": "apiVersion", "type": "str"}, } - def __init__( - self, - **kwargs - ): - """ - """ - super(ApiProfile, self).__init__(**kwargs) + def __init__(self, **kwargs): + """ """ + super().__init__(**kwargs) self.profile_version = None self.api_version = None -class BasicDependency(msrest.serialization.Model): +class BasicDependency(_serialization.Model): """Deployment dependency information. :ivar id: The ID of the dependency. @@ -247,15 +247,15 @@ class BasicDependency(msrest.serialization.Model): """ _attribute_map = { - 'id': {'key': 'id', 'type': 'str'}, - 'resource_type': {'key': 'resourceType', 'type': 'str'}, - 'resource_name': {'key': 'resourceName', 'type': 'str'}, + "id": {"key": "id", "type": "str"}, + "resource_type": {"key": "resourceType", "type": "str"}, + "resource_name": {"key": "resourceName", "type": "str"}, } def __init__( self, *, - id: Optional[str] = None, + id: Optional[str] = None, # pylint: disable=redefined-builtin resource_type: Optional[str] = None, resource_name: Optional[str] = None, **kwargs @@ -268,13 +268,13 @@ def __init__( :keyword resource_name: The dependency resource name. :paramtype resource_name: str """ - super(BasicDependency, self).__init__(**kwargs) + super().__init__(**kwargs) self.id = id self.resource_type = resource_type self.resource_name = resource_name -class DebugSetting(msrest.serialization.Model): +class DebugSetting(_serialization.Model): """The debug setting. :ivar detail_level: Specifies the type of information to log for debugging. The permitted @@ -287,15 +287,10 @@ class DebugSetting(msrest.serialization.Model): """ _attribute_map = { - 'detail_level': {'key': 'detailLevel', 'type': 'str'}, + "detail_level": {"key": "detailLevel", "type": "str"}, } - def __init__( - self, - *, - detail_level: Optional[str] = None, - **kwargs - ): + def __init__(self, *, detail_level: Optional[str] = None, **kwargs): """ :keyword detail_level: Specifies the type of information to log for debugging. The permitted values are none, requestContent, responseContent, or both requestContent and responseContent @@ -305,11 +300,11 @@ def __init__( deployment operations. :paramtype detail_level: str """ - super(DebugSetting, self).__init__(**kwargs) + super().__init__(**kwargs) self.detail_level = detail_level -class Dependency(msrest.serialization.Model): +class Dependency(_serialization.Model): """Deployment dependency information. :ivar depends_on: The list of dependencies. @@ -323,17 +318,17 @@ class Dependency(msrest.serialization.Model): """ _attribute_map = { - 'depends_on': {'key': 'dependsOn', 'type': '[BasicDependency]'}, - 'id': {'key': 'id', 'type': 'str'}, - 'resource_type': {'key': 'resourceType', 'type': 'str'}, - 'resource_name': {'key': 'resourceName', 'type': 'str'}, + "depends_on": {"key": "dependsOn", "type": "[BasicDependency]"}, + "id": {"key": "id", "type": "str"}, + "resource_type": {"key": "resourceType", "type": "str"}, + "resource_name": {"key": "resourceName", "type": "str"}, } def __init__( self, *, - depends_on: Optional[List["BasicDependency"]] = None, - id: Optional[str] = None, + depends_on: Optional[List["_models.BasicDependency"]] = None, + id: Optional[str] = None, # pylint: disable=redefined-builtin resource_type: Optional[str] = None, resource_name: Optional[str] = None, **kwargs @@ -348,40 +343,40 @@ def __init__( :keyword resource_name: The dependency resource name. :paramtype resource_name: str """ - super(Dependency, self).__init__(**kwargs) + super().__init__(**kwargs) self.depends_on = depends_on self.id = id self.resource_type = resource_type self.resource_name = resource_name -class Deployment(msrest.serialization.Model): +class Deployment(_serialization.Model): """Deployment operation parameters. All required parameters must be populated in order to send to Azure. :ivar location: The location to store the deployment data. :vartype location: str - :ivar properties: Required. The deployment properties. + :ivar properties: The deployment properties. Required. :vartype properties: ~azure.mgmt.resource.resources.v2021_04_01.models.DeploymentProperties - :ivar tags: A set of tags. Deployment tags. + :ivar tags: Deployment tags. :vartype tags: dict[str, str] """ _validation = { - 'properties': {'required': True}, + "properties": {"required": True}, } _attribute_map = { - 'location': {'key': 'location', 'type': 'str'}, - 'properties': {'key': 'properties', 'type': 'DeploymentProperties'}, - 'tags': {'key': 'tags', 'type': '{str}'}, + "location": {"key": "location", "type": "str"}, + "properties": {"key": "properties", "type": "DeploymentProperties"}, + "tags": {"key": "tags", "type": "{str}"}, } def __init__( self, *, - properties: "DeploymentProperties", + properties: "_models.DeploymentProperties", location: Optional[str] = None, tags: Optional[Dict[str, str]] = None, **kwargs @@ -389,43 +384,38 @@ def __init__( """ :keyword location: The location to store the deployment data. :paramtype location: str - :keyword properties: Required. The deployment properties. + :keyword properties: The deployment properties. Required. :paramtype properties: ~azure.mgmt.resource.resources.v2021_04_01.models.DeploymentProperties - :keyword tags: A set of tags. Deployment tags. + :keyword tags: Deployment tags. :paramtype tags: dict[str, str] """ - super(Deployment, self).__init__(**kwargs) + super().__init__(**kwargs) self.location = location self.properties = properties self.tags = tags -class DeploymentExportResult(msrest.serialization.Model): +class DeploymentExportResult(_serialization.Model): """The deployment export result. :ivar template: The template content. - :vartype template: any + :vartype template: JSON """ _attribute_map = { - 'template': {'key': 'template', 'type': 'object'}, + "template": {"key": "template", "type": "object"}, } - def __init__( - self, - *, - template: Optional[Any] = None, - **kwargs - ): + def __init__(self, *, template: Optional[JSON] = None, **kwargs): """ :keyword template: The template content. - :paramtype template: any + :paramtype template: JSON """ - super(DeploymentExportResult, self).__init__(**kwargs) + super().__init__(**kwargs) self.template = template -class DeploymentExtended(msrest.serialization.Model): +class DeploymentExtended(_serialization.Model): """Deployment information. Variables are only populated by the server, and will be ignored when sending a request. @@ -441,30 +431,30 @@ class DeploymentExtended(msrest.serialization.Model): :ivar properties: Deployment properties. :vartype properties: ~azure.mgmt.resource.resources.v2021_04_01.models.DeploymentPropertiesExtended - :ivar tags: A set of tags. Deployment tags. + :ivar tags: Deployment tags. :vartype tags: dict[str, str] """ _validation = { - 'id': {'readonly': True}, - 'name': {'readonly': True}, - 'type': {'readonly': True}, + "id": {"readonly": True}, + "name": {"readonly": True}, + "type": {"readonly": True}, } _attribute_map = { - 'id': {'key': 'id', 'type': 'str'}, - 'name': {'key': 'name', 'type': 'str'}, - 'type': {'key': 'type', 'type': 'str'}, - 'location': {'key': 'location', 'type': 'str'}, - 'properties': {'key': 'properties', 'type': 'DeploymentPropertiesExtended'}, - 'tags': {'key': 'tags', 'type': '{str}'}, + "id": {"key": "id", "type": "str"}, + "name": {"key": "name", "type": "str"}, + "type": {"key": "type", "type": "str"}, + "location": {"key": "location", "type": "str"}, + "properties": {"key": "properties", "type": "DeploymentPropertiesExtended"}, + "tags": {"key": "tags", "type": "{str}"}, } def __init__( self, *, location: Optional[str] = None, - properties: Optional["DeploymentPropertiesExtended"] = None, + properties: Optional["_models.DeploymentPropertiesExtended"] = None, tags: Optional[Dict[str, str]] = None, **kwargs ): @@ -474,10 +464,10 @@ def __init__( :keyword properties: Deployment properties. :paramtype properties: ~azure.mgmt.resource.resources.v2021_04_01.models.DeploymentPropertiesExtended - :keyword tags: A set of tags. Deployment tags. + :keyword tags: Deployment tags. :paramtype tags: dict[str, str] """ - super(DeploymentExtended, self).__init__(**kwargs) + super().__init__(**kwargs) self.id = None self.name = None self.type = None @@ -486,7 +476,7 @@ def __init__( self.tags = tags -class DeploymentExtendedFilter(msrest.serialization.Model): +class DeploymentExtendedFilter(_serialization.Model): """Deployment filter. :ivar provisioning_state: The provisioning state. @@ -494,24 +484,19 @@ class DeploymentExtendedFilter(msrest.serialization.Model): """ _attribute_map = { - 'provisioning_state': {'key': 'provisioningState', 'type': 'str'}, + "provisioning_state": {"key": "provisioningState", "type": "str"}, } - def __init__( - self, - *, - provisioning_state: Optional[str] = None, - **kwargs - ): + def __init__(self, *, provisioning_state: Optional[str] = None, **kwargs): """ :keyword provisioning_state: The provisioning state. :paramtype provisioning_state: str """ - super(DeploymentExtendedFilter, self).__init__(**kwargs) + super().__init__(**kwargs) self.provisioning_state = provisioning_state -class DeploymentListResult(msrest.serialization.Model): +class DeploymentListResult(_serialization.Model): """List of deployments. Variables are only populated by the server, and will be ignored when sending a request. @@ -523,30 +508,25 @@ class DeploymentListResult(msrest.serialization.Model): """ _validation = { - 'next_link': {'readonly': True}, + "next_link": {"readonly": True}, } _attribute_map = { - 'value': {'key': 'value', 'type': '[DeploymentExtended]'}, - 'next_link': {'key': 'nextLink', 'type': 'str'}, + "value": {"key": "value", "type": "[DeploymentExtended]"}, + "next_link": {"key": "nextLink", "type": "str"}, } - def __init__( - self, - *, - value: Optional[List["DeploymentExtended"]] = None, - **kwargs - ): + def __init__(self, *, value: Optional[List["_models.DeploymentExtended"]] = None, **kwargs): """ :keyword value: An array of deployments. :paramtype value: list[~azure.mgmt.resource.resources.v2021_04_01.models.DeploymentExtended] """ - super(DeploymentListResult, self).__init__(**kwargs) + super().__init__(**kwargs) self.value = value self.next_link = None -class DeploymentOperation(msrest.serialization.Model): +class DeploymentOperation(_serialization.Model): """Deployment operation information. Variables are only populated by the server, and will be ignored when sending a request. @@ -561,41 +541,36 @@ class DeploymentOperation(msrest.serialization.Model): """ _validation = { - 'id': {'readonly': True}, - 'operation_id': {'readonly': True}, + "id": {"readonly": True}, + "operation_id": {"readonly": True}, } _attribute_map = { - 'id': {'key': 'id', 'type': 'str'}, - 'operation_id': {'key': 'operationId', 'type': 'str'}, - 'properties': {'key': 'properties', 'type': 'DeploymentOperationProperties'}, + "id": {"key": "id", "type": "str"}, + "operation_id": {"key": "operationId", "type": "str"}, + "properties": {"key": "properties", "type": "DeploymentOperationProperties"}, } - def __init__( - self, - *, - properties: Optional["DeploymentOperationProperties"] = None, - **kwargs - ): + def __init__(self, *, properties: Optional["_models.DeploymentOperationProperties"] = None, **kwargs): """ :keyword properties: Deployment properties. :paramtype properties: ~azure.mgmt.resource.resources.v2021_04_01.models.DeploymentOperationProperties """ - super(DeploymentOperation, self).__init__(**kwargs) + super().__init__(**kwargs) self.id = None self.operation_id = None self.properties = properties -class DeploymentOperationProperties(msrest.serialization.Model): +class DeploymentOperationProperties(_serialization.Model): """Deployment operation properties. Variables are only populated by the server, and will be ignored when sending a request. - :ivar provisioning_operation: The name of the current provisioning operation. Possible values - include: "NotSpecified", "Create", "Delete", "Waiting", "AzureAsyncOperationWaiting", - "ResourceCacheWaiting", "Action", "Read", "EvaluateDeploymentOutput", "DeploymentCleanup". + :ivar provisioning_operation: The name of the current provisioning operation. Known values are: + "NotSpecified", "Create", "Delete", "Waiting", "AzureAsyncOperationWaiting", + "ResourceCacheWaiting", "Action", "Read", "EvaluateDeploymentOutput", and "DeploymentCleanup". :vartype provisioning_operation: str or ~azure.mgmt.resource.resources.v2021_04_01.models.ProvisioningOperation :ivar provisioning_state: The state of the provisioning. @@ -621,38 +596,34 @@ class DeploymentOperationProperties(msrest.serialization.Model): """ _validation = { - 'provisioning_operation': {'readonly': True}, - 'provisioning_state': {'readonly': True}, - 'timestamp': {'readonly': True}, - 'duration': {'readonly': True}, - 'service_request_id': {'readonly': True}, - 'status_code': {'readonly': True}, - 'status_message': {'readonly': True}, - 'target_resource': {'readonly': True}, - 'request': {'readonly': True}, - 'response': {'readonly': True}, - } - - _attribute_map = { - 'provisioning_operation': {'key': 'provisioningOperation', 'type': 'str'}, - 'provisioning_state': {'key': 'provisioningState', 'type': 'str'}, - 'timestamp': {'key': 'timestamp', 'type': 'iso-8601'}, - 'duration': {'key': 'duration', 'type': 'str'}, - 'service_request_id': {'key': 'serviceRequestId', 'type': 'str'}, - 'status_code': {'key': 'statusCode', 'type': 'str'}, - 'status_message': {'key': 'statusMessage', 'type': 'StatusMessage'}, - 'target_resource': {'key': 'targetResource', 'type': 'TargetResource'}, - 'request': {'key': 'request', 'type': 'HttpMessage'}, - 'response': {'key': 'response', 'type': 'HttpMessage'}, - } - - def __init__( - self, - **kwargs - ): - """ - """ - super(DeploymentOperationProperties, self).__init__(**kwargs) + "provisioning_operation": {"readonly": True}, + "provisioning_state": {"readonly": True}, + "timestamp": {"readonly": True}, + "duration": {"readonly": True}, + "service_request_id": {"readonly": True}, + "status_code": {"readonly": True}, + "status_message": {"readonly": True}, + "target_resource": {"readonly": True}, + "request": {"readonly": True}, + "response": {"readonly": True}, + } + + _attribute_map = { + "provisioning_operation": {"key": "provisioningOperation", "type": "str"}, + "provisioning_state": {"key": "provisioningState", "type": "str"}, + "timestamp": {"key": "timestamp", "type": "iso-8601"}, + "duration": {"key": "duration", "type": "str"}, + "service_request_id": {"key": "serviceRequestId", "type": "str"}, + "status_code": {"key": "statusCode", "type": "str"}, + "status_message": {"key": "statusMessage", "type": "StatusMessage"}, + "target_resource": {"key": "targetResource", "type": "TargetResource"}, + "request": {"key": "request", "type": "HttpMessage"}, + "response": {"key": "response", "type": "HttpMessage"}, + } + + def __init__(self, **kwargs): + """ """ + super().__init__(**kwargs) self.provisioning_operation = None self.provisioning_state = None self.timestamp = None @@ -665,7 +636,7 @@ def __init__( self.response = None -class DeploymentOperationsListResult(msrest.serialization.Model): +class DeploymentOperationsListResult(_serialization.Model): """List of deployment operations. Variables are only populated by the server, and will be ignored when sending a request. @@ -677,30 +648,25 @@ class DeploymentOperationsListResult(msrest.serialization.Model): """ _validation = { - 'next_link': {'readonly': True}, + "next_link": {"readonly": True}, } _attribute_map = { - 'value': {'key': 'value', 'type': '[DeploymentOperation]'}, - 'next_link': {'key': 'nextLink', 'type': 'str'}, + "value": {"key": "value", "type": "[DeploymentOperation]"}, + "next_link": {"key": "nextLink", "type": "str"}, } - def __init__( - self, - *, - value: Optional[List["DeploymentOperation"]] = None, - **kwargs - ): + def __init__(self, *, value: Optional[List["_models.DeploymentOperation"]] = None, **kwargs): """ :keyword value: An array of deployment operations. :paramtype value: list[~azure.mgmt.resource.resources.v2021_04_01.models.DeploymentOperation] """ - super(DeploymentOperationsListResult, self).__init__(**kwargs) + super().__init__(**kwargs) self.value = value self.next_link = None -class DeploymentProperties(msrest.serialization.Model): +class DeploymentProperties(_serialization.Model): """Deployment properties. All required parameters must be populated in order to send to Azure. @@ -709,7 +675,7 @@ class DeploymentProperties(msrest.serialization.Model): syntax directly in the request rather than link to an existing template. It can be a JObject or well-formed JSON string. Use either the templateLink property or the template property, but not both. - :vartype template: any + :vartype template: JSON :ivar template_link: The URI of the template. Use either the templateLink property or the template property, but not both. :vartype template_link: ~azure.mgmt.resource.resources.v2021_04_01.models.TemplateLink @@ -717,17 +683,17 @@ class DeploymentProperties(msrest.serialization.Model): You use this element when you want to provide the parameter values directly in the request rather than link to an existing parameter file. Use either the parametersLink property or the parameters property, but not both. It can be a JObject or a well formed JSON string. - :vartype parameters: any + :vartype parameters: JSON :ivar parameters_link: The URI of parameters file. You use this element to link to an existing parameters file. Use either the parametersLink property or the parameters property, but not both. :vartype parameters_link: ~azure.mgmt.resource.resources.v2021_04_01.models.ParametersLink - :ivar mode: Required. The mode that is used to deploy resources. This value can be either - Incremental or Complete. In Incremental mode, resources are deployed without deleting existing - resources that are not included in the template. In Complete mode, resources are deployed and - existing resources in the resource group that are not included in the template are deleted. Be - careful when using Complete mode as you may unintentionally delete resources. Possible values - include: "Incremental", "Complete". + :ivar mode: The mode that is used to deploy resources. This value can be either Incremental or + Complete. In Incremental mode, resources are deployed without deleting existing resources that + are not included in the template. In Complete mode, resources are deployed and existing + resources in the resource group that are not included in the template are deleted. Be careful + when using Complete mode as you may unintentionally delete resources. Required. Known values + are: "Incremental" and "Complete". :vartype mode: str or ~azure.mgmt.resource.resources.v2021_04_01.models.DeploymentMode :ivar debug_setting: The debug setting of the deployment. :vartype debug_setting: ~azure.mgmt.resource.resources.v2021_04_01.models.DebugSetting @@ -742,31 +708,31 @@ class DeploymentProperties(msrest.serialization.Model): """ _validation = { - 'mode': {'required': True}, + "mode": {"required": True}, } _attribute_map = { - 'template': {'key': 'template', 'type': 'object'}, - 'template_link': {'key': 'templateLink', 'type': 'TemplateLink'}, - 'parameters': {'key': 'parameters', 'type': 'object'}, - 'parameters_link': {'key': 'parametersLink', 'type': 'ParametersLink'}, - 'mode': {'key': 'mode', 'type': 'str'}, - 'debug_setting': {'key': 'debugSetting', 'type': 'DebugSetting'}, - 'on_error_deployment': {'key': 'onErrorDeployment', 'type': 'OnErrorDeployment'}, - 'expression_evaluation_options': {'key': 'expressionEvaluationOptions', 'type': 'ExpressionEvaluationOptions'}, + "template": {"key": "template", "type": "object"}, + "template_link": {"key": "templateLink", "type": "TemplateLink"}, + "parameters": {"key": "parameters", "type": "object"}, + "parameters_link": {"key": "parametersLink", "type": "ParametersLink"}, + "mode": {"key": "mode", "type": "str"}, + "debug_setting": {"key": "debugSetting", "type": "DebugSetting"}, + "on_error_deployment": {"key": "onErrorDeployment", "type": "OnErrorDeployment"}, + "expression_evaluation_options": {"key": "expressionEvaluationOptions", "type": "ExpressionEvaluationOptions"}, } def __init__( self, *, - mode: Union[str, "DeploymentMode"], - template: Optional[Any] = None, - template_link: Optional["TemplateLink"] = None, - parameters: Optional[Any] = None, - parameters_link: Optional["ParametersLink"] = None, - debug_setting: Optional["DebugSetting"] = None, - on_error_deployment: Optional["OnErrorDeployment"] = None, - expression_evaluation_options: Optional["ExpressionEvaluationOptions"] = None, + mode: Union[str, "_models.DeploymentMode"], + template: Optional[JSON] = None, + template_link: Optional["_models.TemplateLink"] = None, + parameters: Optional[JSON] = None, + parameters_link: Optional["_models.ParametersLink"] = None, + debug_setting: Optional["_models.DebugSetting"] = None, + on_error_deployment: Optional["_models.OnErrorDeployment"] = None, + expression_evaluation_options: Optional["_models.ExpressionEvaluationOptions"] = None, **kwargs ): """ @@ -774,7 +740,7 @@ def __init__( template syntax directly in the request rather than link to an existing template. It can be a JObject or well-formed JSON string. Use either the templateLink property or the template property, but not both. - :paramtype template: any + :paramtype template: JSON :keyword template_link: The URI of the template. Use either the templateLink property or the template property, but not both. :paramtype template_link: ~azure.mgmt.resource.resources.v2021_04_01.models.TemplateLink @@ -782,17 +748,17 @@ def __init__( template. You use this element when you want to provide the parameter values directly in the request rather than link to an existing parameter file. Use either the parametersLink property or the parameters property, but not both. It can be a JObject or a well formed JSON string. - :paramtype parameters: any + :paramtype parameters: JSON :keyword parameters_link: The URI of parameters file. You use this element to link to an existing parameters file. Use either the parametersLink property or the parameters property, but not both. :paramtype parameters_link: ~azure.mgmt.resource.resources.v2021_04_01.models.ParametersLink - :keyword mode: Required. The mode that is used to deploy resources. This value can be either - Incremental or Complete. In Incremental mode, resources are deployed without deleting existing - resources that are not included in the template. In Complete mode, resources are deployed and - existing resources in the resource group that are not included in the template are deleted. Be - careful when using Complete mode as you may unintentionally delete resources. Possible values - include: "Incremental", "Complete". + :keyword mode: The mode that is used to deploy resources. This value can be either Incremental + or Complete. In Incremental mode, resources are deployed without deleting existing resources + that are not included in the template. In Complete mode, resources are deployed and existing + resources in the resource group that are not included in the template are deleted. Be careful + when using Complete mode as you may unintentionally delete resources. Required. Known values + are: "Incremental" and "Complete". :paramtype mode: str or ~azure.mgmt.resource.resources.v2021_04_01.models.DeploymentMode :keyword debug_setting: The debug setting of the deployment. :paramtype debug_setting: ~azure.mgmt.resource.resources.v2021_04_01.models.DebugSetting @@ -805,7 +771,7 @@ def __init__( :paramtype expression_evaluation_options: ~azure.mgmt.resource.resources.v2021_04_01.models.ExpressionEvaluationOptions """ - super(DeploymentProperties, self).__init__(**kwargs) + super().__init__(**kwargs) self.template = template self.template_link = template_link self.parameters = parameters @@ -816,14 +782,14 @@ def __init__( self.expression_evaluation_options = expression_evaluation_options -class DeploymentPropertiesExtended(msrest.serialization.Model): +class DeploymentPropertiesExtended(_serialization.Model): # pylint: disable=too-many-instance-attributes """Deployment properties with additional details. Variables are only populated by the server, and will be ignored when sending a request. - :ivar provisioning_state: Denotes the state of provisioning. Possible values include: - "NotSpecified", "Accepted", "Running", "Ready", "Creating", "Created", "Deleting", "Deleted", - "Canceled", "Failed", "Succeeded", "Updating". + :ivar provisioning_state: Denotes the state of provisioning. Known values are: "NotSpecified", + "Accepted", "Running", "Ready", "Creating", "Created", "Deleting", "Deleted", "Canceled", + "Failed", "Succeeded", and "Updating". :vartype provisioning_state: str or ~azure.mgmt.resource.resources.v2021_04_01.models.ProvisioningState :ivar correlation_id: The correlation ID of the deployment. @@ -833,7 +799,7 @@ class DeploymentPropertiesExtended(msrest.serialization.Model): :ivar duration: The duration of the template deployment. :vartype duration: str :ivar outputs: Key/value pairs that represent deployment output. - :vartype outputs: any + :vartype outputs: JSON :ivar providers: The list of resource providers needed for the deployment. :vartype providers: list[~azure.mgmt.resource.resources.v2021_04_01.models.Provider] :ivar dependencies: The list of deployment dependencies. @@ -841,11 +807,11 @@ class DeploymentPropertiesExtended(msrest.serialization.Model): :ivar template_link: The URI referencing the template. :vartype template_link: ~azure.mgmt.resource.resources.v2021_04_01.models.TemplateLink :ivar parameters: Deployment parameters. - :vartype parameters: any + :vartype parameters: JSON :ivar parameters_link: The URI referencing the parameters. :vartype parameters_link: ~azure.mgmt.resource.resources.v2021_04_01.models.ParametersLink - :ivar mode: The deployment mode. Possible values are Incremental and Complete. Possible values - include: "Incremental", "Complete". + :ivar mode: The deployment mode. Possible values are Incremental and Complete. Known values + are: "Incremental" and "Complete". :vartype mode: str or ~azure.mgmt.resource.resources.v2021_04_01.models.DeploymentMode :ivar debug_setting: The debug setting of the deployment. :vartype debug_setting: ~azure.mgmt.resource.resources.v2021_04_01.models.DebugSetting @@ -865,52 +831,48 @@ class DeploymentPropertiesExtended(msrest.serialization.Model): """ _validation = { - 'provisioning_state': {'readonly': True}, - 'correlation_id': {'readonly': True}, - 'timestamp': {'readonly': True}, - 'duration': {'readonly': True}, - 'outputs': {'readonly': True}, - 'providers': {'readonly': True}, - 'dependencies': {'readonly': True}, - 'template_link': {'readonly': True}, - 'parameters': {'readonly': True}, - 'parameters_link': {'readonly': True}, - 'mode': {'readonly': True}, - 'debug_setting': {'readonly': True}, - 'on_error_deployment': {'readonly': True}, - 'template_hash': {'readonly': True}, - 'output_resources': {'readonly': True}, - 'validated_resources': {'readonly': True}, - 'error': {'readonly': True}, - } - - _attribute_map = { - 'provisioning_state': {'key': 'provisioningState', 'type': 'str'}, - 'correlation_id': {'key': 'correlationId', 'type': 'str'}, - 'timestamp': {'key': 'timestamp', 'type': 'iso-8601'}, - 'duration': {'key': 'duration', 'type': 'str'}, - 'outputs': {'key': 'outputs', 'type': 'object'}, - 'providers': {'key': 'providers', 'type': '[Provider]'}, - 'dependencies': {'key': 'dependencies', 'type': '[Dependency]'}, - 'template_link': {'key': 'templateLink', 'type': 'TemplateLink'}, - 'parameters': {'key': 'parameters', 'type': 'object'}, - 'parameters_link': {'key': 'parametersLink', 'type': 'ParametersLink'}, - 'mode': {'key': 'mode', 'type': 'str'}, - 'debug_setting': {'key': 'debugSetting', 'type': 'DebugSetting'}, - 'on_error_deployment': {'key': 'onErrorDeployment', 'type': 'OnErrorDeploymentExtended'}, - 'template_hash': {'key': 'templateHash', 'type': 'str'}, - 'output_resources': {'key': 'outputResources', 'type': '[ResourceReference]'}, - 'validated_resources': {'key': 'validatedResources', 'type': '[ResourceReference]'}, - 'error': {'key': 'error', 'type': 'ErrorResponse'}, - } - - def __init__( - self, - **kwargs - ): - """ - """ - super(DeploymentPropertiesExtended, self).__init__(**kwargs) + "provisioning_state": {"readonly": True}, + "correlation_id": {"readonly": True}, + "timestamp": {"readonly": True}, + "duration": {"readonly": True}, + "outputs": {"readonly": True}, + "providers": {"readonly": True}, + "dependencies": {"readonly": True}, + "template_link": {"readonly": True}, + "parameters": {"readonly": True}, + "parameters_link": {"readonly": True}, + "mode": {"readonly": True}, + "debug_setting": {"readonly": True}, + "on_error_deployment": {"readonly": True}, + "template_hash": {"readonly": True}, + "output_resources": {"readonly": True}, + "validated_resources": {"readonly": True}, + "error": {"readonly": True}, + } + + _attribute_map = { + "provisioning_state": {"key": "provisioningState", "type": "str"}, + "correlation_id": {"key": "correlationId", "type": "str"}, + "timestamp": {"key": "timestamp", "type": "iso-8601"}, + "duration": {"key": "duration", "type": "str"}, + "outputs": {"key": "outputs", "type": "object"}, + "providers": {"key": "providers", "type": "[Provider]"}, + "dependencies": {"key": "dependencies", "type": "[Dependency]"}, + "template_link": {"key": "templateLink", "type": "TemplateLink"}, + "parameters": {"key": "parameters", "type": "object"}, + "parameters_link": {"key": "parametersLink", "type": "ParametersLink"}, + "mode": {"key": "mode", "type": "str"}, + "debug_setting": {"key": "debugSetting", "type": "DebugSetting"}, + "on_error_deployment": {"key": "onErrorDeployment", "type": "OnErrorDeploymentExtended"}, + "template_hash": {"key": "templateHash", "type": "str"}, + "output_resources": {"key": "outputResources", "type": "[ResourceReference]"}, + "validated_resources": {"key": "validatedResources", "type": "[ResourceReference]"}, + "error": {"key": "error", "type": "ErrorResponse"}, + } + + def __init__(self, **kwargs): + """ """ + super().__init__(**kwargs) self.provisioning_state = None self.correlation_id = None self.timestamp = None @@ -930,7 +892,7 @@ def __init__( self.error = None -class DeploymentValidateResult(msrest.serialization.Model): +class DeploymentValidateResult(_serialization.Model): """Information from validate template deployment response. Variables are only populated by the server, and will be ignored when sending a request. @@ -943,66 +905,55 @@ class DeploymentValidateResult(msrest.serialization.Model): """ _validation = { - 'error': {'readonly': True}, + "error": {"readonly": True}, } _attribute_map = { - 'error': {'key': 'error', 'type': 'ErrorResponse'}, - 'properties': {'key': 'properties', 'type': 'DeploymentPropertiesExtended'}, + "error": {"key": "error", "type": "ErrorResponse"}, + "properties": {"key": "properties", "type": "DeploymentPropertiesExtended"}, } - def __init__( - self, - *, - properties: Optional["DeploymentPropertiesExtended"] = None, - **kwargs - ): + def __init__(self, *, properties: Optional["_models.DeploymentPropertiesExtended"] = None, **kwargs): """ :keyword properties: The template deployment properties. :paramtype properties: ~azure.mgmt.resource.resources.v2021_04_01.models.DeploymentPropertiesExtended """ - super(DeploymentValidateResult, self).__init__(**kwargs) + super().__init__(**kwargs) self.error = None self.properties = properties -class DeploymentWhatIf(msrest.serialization.Model): +class DeploymentWhatIf(_serialization.Model): """Deployment What-if operation parameters. All required parameters must be populated in order to send to Azure. :ivar location: The location to store the deployment data. :vartype location: str - :ivar properties: Required. The deployment properties. + :ivar properties: The deployment properties. Required. :vartype properties: ~azure.mgmt.resource.resources.v2021_04_01.models.DeploymentWhatIfProperties """ _validation = { - 'properties': {'required': True}, + "properties": {"required": True}, } _attribute_map = { - 'location': {'key': 'location', 'type': 'str'}, - 'properties': {'key': 'properties', 'type': 'DeploymentWhatIfProperties'}, + "location": {"key": "location", "type": "str"}, + "properties": {"key": "properties", "type": "DeploymentWhatIfProperties"}, } - def __init__( - self, - *, - properties: "DeploymentWhatIfProperties", - location: Optional[str] = None, - **kwargs - ): + def __init__(self, *, properties: "_models.DeploymentWhatIfProperties", location: Optional[str] = None, **kwargs): """ :keyword location: The location to store the deployment data. :paramtype location: str - :keyword properties: Required. The deployment properties. + :keyword properties: The deployment properties. Required. :paramtype properties: ~azure.mgmt.resource.resources.v2021_04_01.models.DeploymentWhatIfProperties """ - super(DeploymentWhatIf, self).__init__(**kwargs) + super().__init__(**kwargs) self.location = location self.properties = properties @@ -1016,7 +967,7 @@ class DeploymentWhatIfProperties(DeploymentProperties): syntax directly in the request rather than link to an existing template. It can be a JObject or well-formed JSON string. Use either the templateLink property or the template property, but not both. - :vartype template: any + :vartype template: JSON :ivar template_link: The URI of the template. Use either the templateLink property or the template property, but not both. :vartype template_link: ~azure.mgmt.resource.resources.v2021_04_01.models.TemplateLink @@ -1024,17 +975,17 @@ class DeploymentWhatIfProperties(DeploymentProperties): You use this element when you want to provide the parameter values directly in the request rather than link to an existing parameter file. Use either the parametersLink property or the parameters property, but not both. It can be a JObject or a well formed JSON string. - :vartype parameters: any + :vartype parameters: JSON :ivar parameters_link: The URI of parameters file. You use this element to link to an existing parameters file. Use either the parametersLink property or the parameters property, but not both. :vartype parameters_link: ~azure.mgmt.resource.resources.v2021_04_01.models.ParametersLink - :ivar mode: Required. The mode that is used to deploy resources. This value can be either - Incremental or Complete. In Incremental mode, resources are deployed without deleting existing - resources that are not included in the template. In Complete mode, resources are deployed and - existing resources in the resource group that are not included in the template are deleted. Be - careful when using Complete mode as you may unintentionally delete resources. Possible values - include: "Incremental", "Complete". + :ivar mode: The mode that is used to deploy resources. This value can be either Incremental or + Complete. In Incremental mode, resources are deployed without deleting existing resources that + are not included in the template. In Complete mode, resources are deployed and existing + resources in the resource group that are not included in the template are deleted. Be careful + when using Complete mode as you may unintentionally delete resources. Required. Known values + are: "Incremental" and "Complete". :vartype mode: str or ~azure.mgmt.resource.resources.v2021_04_01.models.DeploymentMode :ivar debug_setting: The debug setting of the deployment. :vartype debug_setting: ~azure.mgmt.resource.resources.v2021_04_01.models.DebugSetting @@ -1052,33 +1003,33 @@ class DeploymentWhatIfProperties(DeploymentProperties): """ _validation = { - 'mode': {'required': True}, + "mode": {"required": True}, } _attribute_map = { - 'template': {'key': 'template', 'type': 'object'}, - 'template_link': {'key': 'templateLink', 'type': 'TemplateLink'}, - 'parameters': {'key': 'parameters', 'type': 'object'}, - 'parameters_link': {'key': 'parametersLink', 'type': 'ParametersLink'}, - 'mode': {'key': 'mode', 'type': 'str'}, - 'debug_setting': {'key': 'debugSetting', 'type': 'DebugSetting'}, - 'on_error_deployment': {'key': 'onErrorDeployment', 'type': 'OnErrorDeployment'}, - 'expression_evaluation_options': {'key': 'expressionEvaluationOptions', 'type': 'ExpressionEvaluationOptions'}, - 'what_if_settings': {'key': 'whatIfSettings', 'type': 'DeploymentWhatIfSettings'}, + "template": {"key": "template", "type": "object"}, + "template_link": {"key": "templateLink", "type": "TemplateLink"}, + "parameters": {"key": "parameters", "type": "object"}, + "parameters_link": {"key": "parametersLink", "type": "ParametersLink"}, + "mode": {"key": "mode", "type": "str"}, + "debug_setting": {"key": "debugSetting", "type": "DebugSetting"}, + "on_error_deployment": {"key": "onErrorDeployment", "type": "OnErrorDeployment"}, + "expression_evaluation_options": {"key": "expressionEvaluationOptions", "type": "ExpressionEvaluationOptions"}, + "what_if_settings": {"key": "whatIfSettings", "type": "DeploymentWhatIfSettings"}, } def __init__( self, *, - mode: Union[str, "DeploymentMode"], - template: Optional[Any] = None, - template_link: Optional["TemplateLink"] = None, - parameters: Optional[Any] = None, - parameters_link: Optional["ParametersLink"] = None, - debug_setting: Optional["DebugSetting"] = None, - on_error_deployment: Optional["OnErrorDeployment"] = None, - expression_evaluation_options: Optional["ExpressionEvaluationOptions"] = None, - what_if_settings: Optional["DeploymentWhatIfSettings"] = None, + mode: Union[str, "_models.DeploymentMode"], + template: Optional[JSON] = None, + template_link: Optional["_models.TemplateLink"] = None, + parameters: Optional[JSON] = None, + parameters_link: Optional["_models.ParametersLink"] = None, + debug_setting: Optional["_models.DebugSetting"] = None, + on_error_deployment: Optional["_models.OnErrorDeployment"] = None, + expression_evaluation_options: Optional["_models.ExpressionEvaluationOptions"] = None, + what_if_settings: Optional["_models.DeploymentWhatIfSettings"] = None, **kwargs ): """ @@ -1086,7 +1037,7 @@ def __init__( template syntax directly in the request rather than link to an existing template. It can be a JObject or well-formed JSON string. Use either the templateLink property or the template property, but not both. - :paramtype template: any + :paramtype template: JSON :keyword template_link: The URI of the template. Use either the templateLink property or the template property, but not both. :paramtype template_link: ~azure.mgmt.resource.resources.v2021_04_01.models.TemplateLink @@ -1094,17 +1045,17 @@ def __init__( template. You use this element when you want to provide the parameter values directly in the request rather than link to an existing parameter file. Use either the parametersLink property or the parameters property, but not both. It can be a JObject or a well formed JSON string. - :paramtype parameters: any + :paramtype parameters: JSON :keyword parameters_link: The URI of parameters file. You use this element to link to an existing parameters file. Use either the parametersLink property or the parameters property, but not both. :paramtype parameters_link: ~azure.mgmt.resource.resources.v2021_04_01.models.ParametersLink - :keyword mode: Required. The mode that is used to deploy resources. This value can be either - Incremental or Complete. In Incremental mode, resources are deployed without deleting existing - resources that are not included in the template. In Complete mode, resources are deployed and - existing resources in the resource group that are not included in the template are deleted. Be - careful when using Complete mode as you may unintentionally delete resources. Possible values - include: "Incremental", "Complete". + :keyword mode: The mode that is used to deploy resources. This value can be either Incremental + or Complete. In Incremental mode, resources are deployed without deleting existing resources + that are not included in the template. In Complete mode, resources are deployed and existing + resources in the resource group that are not included in the template are deleted. Be careful + when using Complete mode as you may unintentionally delete resources. Required. Known values + are: "Incremental" and "Complete". :paramtype mode: str or ~azure.mgmt.resource.resources.v2021_04_01.models.DeploymentMode :keyword debug_setting: The debug setting of the deployment. :paramtype debug_setting: ~azure.mgmt.resource.resources.v2021_04_01.models.DebugSetting @@ -1120,40 +1071,45 @@ def __init__( :paramtype what_if_settings: ~azure.mgmt.resource.resources.v2021_04_01.models.DeploymentWhatIfSettings """ - super(DeploymentWhatIfProperties, self).__init__(template=template, template_link=template_link, parameters=parameters, parameters_link=parameters_link, mode=mode, debug_setting=debug_setting, on_error_deployment=on_error_deployment, expression_evaluation_options=expression_evaluation_options, **kwargs) + super().__init__( + template=template, + template_link=template_link, + parameters=parameters, + parameters_link=parameters_link, + mode=mode, + debug_setting=debug_setting, + on_error_deployment=on_error_deployment, + expression_evaluation_options=expression_evaluation_options, + **kwargs + ) self.what_if_settings = what_if_settings -class DeploymentWhatIfSettings(msrest.serialization.Model): +class DeploymentWhatIfSettings(_serialization.Model): """Deployment What-If operation settings. - :ivar result_format: The format of the What-If results. Possible values include: - "ResourceIdOnly", "FullResourcePayloads". + :ivar result_format: The format of the What-If results. Known values are: "ResourceIdOnly" and + "FullResourcePayloads". :vartype result_format: str or ~azure.mgmt.resource.resources.v2021_04_01.models.WhatIfResultFormat """ _attribute_map = { - 'result_format': {'key': 'resultFormat', 'type': 'str'}, + "result_format": {"key": "resultFormat", "type": "str"}, } - def __init__( - self, - *, - result_format: Optional[Union[str, "WhatIfResultFormat"]] = None, - **kwargs - ): + def __init__(self, *, result_format: Optional[Union[str, "_models.WhatIfResultFormat"]] = None, **kwargs): """ - :keyword result_format: The format of the What-If results. Possible values include: - "ResourceIdOnly", "FullResourcePayloads". + :keyword result_format: The format of the What-If results. Known values are: "ResourceIdOnly" + and "FullResourcePayloads". :paramtype result_format: str or ~azure.mgmt.resource.resources.v2021_04_01.models.WhatIfResultFormat """ - super(DeploymentWhatIfSettings, self).__init__(**kwargs) + super().__init__(**kwargs) self.result_format = result_format -class ErrorAdditionalInfo(msrest.serialization.Model): +class ErrorAdditionalInfo(_serialization.Model): """The resource management error additional info. Variables are only populated by the server, and will be ignored when sending a request. @@ -1161,31 +1117,27 @@ class ErrorAdditionalInfo(msrest.serialization.Model): :ivar type: The additional info type. :vartype type: str :ivar info: The additional info. - :vartype info: any + :vartype info: JSON """ _validation = { - 'type': {'readonly': True}, - 'info': {'readonly': True}, + "type": {"readonly": True}, + "info": {"readonly": True}, } _attribute_map = { - 'type': {'key': 'type', 'type': 'str'}, - 'info': {'key': 'info', 'type': 'object'}, + "type": {"key": "type", "type": "str"}, + "info": {"key": "info", "type": "object"}, } - def __init__( - self, - **kwargs - ): - """ - """ - super(ErrorAdditionalInfo, self).__init__(**kwargs) + def __init__(self, **kwargs): + """ """ + super().__init__(**kwargs) self.type = None self.info = None -class ErrorResponse(msrest.serialization.Model): +class ErrorResponse(_serialization.Model): """Common error response for all Azure Resource Manager APIs to return error details for failed operations. (This also follows the OData error response format.). Variables are only populated by the server, and will be ignored when sending a request. @@ -1204,28 +1156,24 @@ class ErrorResponse(msrest.serialization.Model): """ _validation = { - 'code': {'readonly': True}, - 'message': {'readonly': True}, - 'target': {'readonly': True}, - 'details': {'readonly': True}, - 'additional_info': {'readonly': True}, + "code": {"readonly": True}, + "message": {"readonly": True}, + "target": {"readonly": True}, + "details": {"readonly": True}, + "additional_info": {"readonly": True}, } _attribute_map = { - 'code': {'key': 'code', 'type': 'str'}, - 'message': {'key': 'message', 'type': 'str'}, - 'target': {'key': 'target', 'type': 'str'}, - 'details': {'key': 'details', 'type': '[ErrorResponse]'}, - 'additional_info': {'key': 'additionalInfo', 'type': '[ErrorAdditionalInfo]'}, + "code": {"key": "code", "type": "str"}, + "message": {"key": "message", "type": "str"}, + "target": {"key": "target", "type": "str"}, + "details": {"key": "details", "type": "[ErrorResponse]"}, + "additional_info": {"key": "additionalInfo", "type": "[ErrorAdditionalInfo]"}, } - def __init__( - self, - **kwargs - ): - """ - """ - super(ErrorResponse, self).__init__(**kwargs) + def __init__(self, **kwargs): + """ """ + super().__init__(**kwargs) self.code = None self.message = None self.target = None @@ -1233,7 +1181,7 @@ def __init__( self.additional_info = None -class ExportTemplateRequest(msrest.serialization.Model): +class ExportTemplateRequest(_serialization.Model): """Export resource group template request parameters. :ivar resources: The IDs of the resources to filter the export by. To export all resources, @@ -1246,17 +1194,11 @@ class ExportTemplateRequest(msrest.serialization.Model): """ _attribute_map = { - 'resources': {'key': 'resources', 'type': '[str]'}, - 'options': {'key': 'options', 'type': 'str'}, + "resources": {"key": "resources", "type": "[str]"}, + "options": {"key": "options", "type": "str"}, } - def __init__( - self, - *, - resources: Optional[List[str]] = None, - options: Optional[str] = None, - **kwargs - ): + def __init__(self, *, resources: Optional[List[str]] = None, options: Optional[str] = None, **kwargs): """ :keyword resources: The IDs of the resources to filter the export by. To export all resources, supply an array with single entry '*'. @@ -1266,73 +1208,64 @@ def __init__( 'SkipResourceNameParameterization', 'SkipAllParameterization'. :paramtype options: str """ - super(ExportTemplateRequest, self).__init__(**kwargs) + super().__init__(**kwargs) self.resources = resources self.options = options -class ExpressionEvaluationOptions(msrest.serialization.Model): +class ExpressionEvaluationOptions(_serialization.Model): """Specifies whether template expressions are evaluated within the scope of the parent template or nested template. :ivar scope: The scope to be used for evaluation of parameters, variables and functions in a - nested template. Possible values include: "NotSpecified", "Outer", "Inner". + nested template. Known values are: "NotSpecified", "Outer", and "Inner". :vartype scope: str or ~azure.mgmt.resource.resources.v2021_04_01.models.ExpressionEvaluationOptionsScopeType """ _attribute_map = { - 'scope': {'key': 'scope', 'type': 'str'}, + "scope": {"key": "scope", "type": "str"}, } - def __init__( - self, - *, - scope: Optional[Union[str, "ExpressionEvaluationOptionsScopeType"]] = None, - **kwargs - ): + def __init__(self, *, scope: Optional[Union[str, "_models.ExpressionEvaluationOptionsScopeType"]] = None, **kwargs): """ :keyword scope: The scope to be used for evaluation of parameters, variables and functions in a - nested template. Possible values include: "NotSpecified", "Outer", "Inner". + nested template. Known values are: "NotSpecified", "Outer", and "Inner". :paramtype scope: str or ~azure.mgmt.resource.resources.v2021_04_01.models.ExpressionEvaluationOptionsScopeType """ - super(ExpressionEvaluationOptions, self).__init__(**kwargs) + super().__init__(**kwargs) self.scope = scope -class ExtendedLocation(msrest.serialization.Model): +class ExtendedLocation(_serialization.Model): """Resource extended location. - :ivar type: The extended location type. Possible values include: "EdgeZone". + :ivar type: The extended location type. "EdgeZone" :vartype type: str or ~azure.mgmt.resource.resources.v2021_04_01.models.ExtendedLocationType :ivar name: The extended location name. :vartype name: str """ _attribute_map = { - 'type': {'key': 'type', 'type': 'str'}, - 'name': {'key': 'name', 'type': 'str'}, + "type": {"key": "type", "type": "str"}, + "name": {"key": "name", "type": "str"}, } def __init__( - self, - *, - type: Optional[Union[str, "ExtendedLocationType"]] = None, - name: Optional[str] = None, - **kwargs + self, *, type: Optional[Union[str, "_models.ExtendedLocationType"]] = None, name: Optional[str] = None, **kwargs ): """ - :keyword type: The extended location type. Possible values include: "EdgeZone". + :keyword type: The extended location type. "EdgeZone" :paramtype type: str or ~azure.mgmt.resource.resources.v2021_04_01.models.ExtendedLocationType :keyword name: The extended location name. :paramtype name: str """ - super(ExtendedLocation, self).__init__(**kwargs) + super().__init__(**kwargs) self.type = type self.name = name -class Resource(msrest.serialization.Model): +class Resource(_serialization.Model): """Specified resource. Variables are only populated by the server, and will be ignored when sending a request. @@ -1347,30 +1280,30 @@ class Resource(msrest.serialization.Model): :vartype location: str :ivar extended_location: Resource extended location. :vartype extended_location: ~azure.mgmt.resource.resources.v2021_04_01.models.ExtendedLocation - :ivar tags: A set of tags. Resource tags. + :ivar tags: Resource tags. :vartype tags: dict[str, str] """ _validation = { - 'id': {'readonly': True}, - 'name': {'readonly': True}, - 'type': {'readonly': True}, + "id": {"readonly": True}, + "name": {"readonly": True}, + "type": {"readonly": True}, } _attribute_map = { - 'id': {'key': 'id', 'type': 'str'}, - 'name': {'key': 'name', 'type': 'str'}, - 'type': {'key': 'type', 'type': 'str'}, - 'location': {'key': 'location', 'type': 'str'}, - 'extended_location': {'key': 'extendedLocation', 'type': 'ExtendedLocation'}, - 'tags': {'key': 'tags', 'type': '{str}'}, + "id": {"key": "id", "type": "str"}, + "name": {"key": "name", "type": "str"}, + "type": {"key": "type", "type": "str"}, + "location": {"key": "location", "type": "str"}, + "extended_location": {"key": "extendedLocation", "type": "ExtendedLocation"}, + "tags": {"key": "tags", "type": "{str}"}, } def __init__( self, *, location: Optional[str] = None, - extended_location: Optional["ExtendedLocation"] = None, + extended_location: Optional["_models.ExtendedLocation"] = None, tags: Optional[Dict[str, str]] = None, **kwargs ): @@ -1380,10 +1313,10 @@ def __init__( :keyword extended_location: Resource extended location. :paramtype extended_location: ~azure.mgmt.resource.resources.v2021_04_01.models.ExtendedLocation - :keyword tags: A set of tags. Resource tags. + :keyword tags: Resource tags. :paramtype tags: dict[str, str] """ - super(Resource, self).__init__(**kwargs) + super().__init__(**kwargs) self.id = None self.name = None self.type = None @@ -1392,7 +1325,7 @@ def __init__( self.tags = tags -class GenericResource(Resource): +class GenericResource(Resource): # pylint: disable=too-many-instance-attributes """Resource information. Variables are only populated by the server, and will be ignored when sending a request. @@ -1407,12 +1340,12 @@ class GenericResource(Resource): :vartype location: str :ivar extended_location: Resource extended location. :vartype extended_location: ~azure.mgmt.resource.resources.v2021_04_01.models.ExtendedLocation - :ivar tags: A set of tags. Resource tags. + :ivar tags: Resource tags. :vartype tags: dict[str, str] :ivar plan: The plan of the resource. :vartype plan: ~azure.mgmt.resource.resources.v2021_04_01.models.Plan :ivar properties: The resource properties. - :vartype properties: any + :vartype properties: JSON :ivar kind: The kind of the resource. :vartype kind: str :ivar managed_by: ID of the resource that manages this resource. @@ -1424,39 +1357,39 @@ class GenericResource(Resource): """ _validation = { - 'id': {'readonly': True}, - 'name': {'readonly': True}, - 'type': {'readonly': True}, - 'kind': {'pattern': r'^[-\w\._,\(\)]+$'}, + "id": {"readonly": True}, + "name": {"readonly": True}, + "type": {"readonly": True}, + "kind": {"pattern": r"^[-\w\._,\(\)]+$"}, } _attribute_map = { - 'id': {'key': 'id', 'type': 'str'}, - 'name': {'key': 'name', 'type': 'str'}, - 'type': {'key': 'type', 'type': 'str'}, - 'location': {'key': 'location', 'type': 'str'}, - 'extended_location': {'key': 'extendedLocation', 'type': 'ExtendedLocation'}, - 'tags': {'key': 'tags', 'type': '{str}'}, - 'plan': {'key': 'plan', 'type': 'Plan'}, - 'properties': {'key': 'properties', 'type': 'object'}, - 'kind': {'key': 'kind', 'type': 'str'}, - 'managed_by': {'key': 'managedBy', 'type': 'str'}, - 'sku': {'key': 'sku', 'type': 'Sku'}, - 'identity': {'key': 'identity', 'type': 'Identity'}, + "id": {"key": "id", "type": "str"}, + "name": {"key": "name", "type": "str"}, + "type": {"key": "type", "type": "str"}, + "location": {"key": "location", "type": "str"}, + "extended_location": {"key": "extendedLocation", "type": "ExtendedLocation"}, + "tags": {"key": "tags", "type": "{str}"}, + "plan": {"key": "plan", "type": "Plan"}, + "properties": {"key": "properties", "type": "object"}, + "kind": {"key": "kind", "type": "str"}, + "managed_by": {"key": "managedBy", "type": "str"}, + "sku": {"key": "sku", "type": "Sku"}, + "identity": {"key": "identity", "type": "Identity"}, } def __init__( self, *, location: Optional[str] = None, - extended_location: Optional["ExtendedLocation"] = None, + extended_location: Optional["_models.ExtendedLocation"] = None, tags: Optional[Dict[str, str]] = None, - plan: Optional["Plan"] = None, - properties: Optional[Any] = None, + plan: Optional["_models.Plan"] = None, + properties: Optional[JSON] = None, kind: Optional[str] = None, managed_by: Optional[str] = None, - sku: Optional["Sku"] = None, - identity: Optional["Identity"] = None, + sku: Optional["_models.Sku"] = None, + identity: Optional["_models.Identity"] = None, **kwargs ): """ @@ -1465,12 +1398,12 @@ def __init__( :keyword extended_location: Resource extended location. :paramtype extended_location: ~azure.mgmt.resource.resources.v2021_04_01.models.ExtendedLocation - :keyword tags: A set of tags. Resource tags. + :keyword tags: Resource tags. :paramtype tags: dict[str, str] :keyword plan: The plan of the resource. :paramtype plan: ~azure.mgmt.resource.resources.v2021_04_01.models.Plan :keyword properties: The resource properties. - :paramtype properties: any + :paramtype properties: JSON :keyword kind: The kind of the resource. :paramtype kind: str :keyword managed_by: ID of the resource that manages this resource. @@ -1480,7 +1413,7 @@ def __init__( :keyword identity: The identity of the resource. :paramtype identity: ~azure.mgmt.resource.resources.v2021_04_01.models.Identity """ - super(GenericResource, self).__init__(location=location, extended_location=extended_location, tags=tags, **kwargs) + super().__init__(location=location, extended_location=extended_location, tags=tags, **kwargs) self.plan = plan self.properties = properties self.kind = kind @@ -1489,7 +1422,7 @@ def __init__( self.identity = identity -class GenericResourceExpanded(GenericResource): +class GenericResourceExpanded(GenericResource): # pylint: disable=too-many-instance-attributes """Resource information. Variables are only populated by the server, and will be ignored when sending a request. @@ -1504,12 +1437,12 @@ class GenericResourceExpanded(GenericResource): :vartype location: str :ivar extended_location: Resource extended location. :vartype extended_location: ~azure.mgmt.resource.resources.v2021_04_01.models.ExtendedLocation - :ivar tags: A set of tags. Resource tags. + :ivar tags: Resource tags. :vartype tags: dict[str, str] :ivar plan: The plan of the resource. :vartype plan: ~azure.mgmt.resource.resources.v2021_04_01.models.Plan :ivar properties: The resource properties. - :vartype properties: any + :vartype properties: JSON :ivar kind: The kind of the resource. :vartype kind: str :ivar managed_by: ID of the resource that manages this resource. @@ -1530,45 +1463,45 @@ class GenericResourceExpanded(GenericResource): """ _validation = { - 'id': {'readonly': True}, - 'name': {'readonly': True}, - 'type': {'readonly': True}, - 'kind': {'pattern': r'^[-\w\._,\(\)]+$'}, - 'created_time': {'readonly': True}, - 'changed_time': {'readonly': True}, - 'provisioning_state': {'readonly': True}, - } - - _attribute_map = { - 'id': {'key': 'id', 'type': 'str'}, - 'name': {'key': 'name', 'type': 'str'}, - 'type': {'key': 'type', 'type': 'str'}, - 'location': {'key': 'location', 'type': 'str'}, - 'extended_location': {'key': 'extendedLocation', 'type': 'ExtendedLocation'}, - 'tags': {'key': 'tags', 'type': '{str}'}, - 'plan': {'key': 'plan', 'type': 'Plan'}, - 'properties': {'key': 'properties', 'type': 'object'}, - 'kind': {'key': 'kind', 'type': 'str'}, - 'managed_by': {'key': 'managedBy', 'type': 'str'}, - 'sku': {'key': 'sku', 'type': 'Sku'}, - 'identity': {'key': 'identity', 'type': 'Identity'}, - 'created_time': {'key': 'createdTime', 'type': 'iso-8601'}, - 'changed_time': {'key': 'changedTime', 'type': 'iso-8601'}, - 'provisioning_state': {'key': 'provisioningState', 'type': 'str'}, + "id": {"readonly": True}, + "name": {"readonly": True}, + "type": {"readonly": True}, + "kind": {"pattern": r"^[-\w\._,\(\)]+$"}, + "created_time": {"readonly": True}, + "changed_time": {"readonly": True}, + "provisioning_state": {"readonly": True}, + } + + _attribute_map = { + "id": {"key": "id", "type": "str"}, + "name": {"key": "name", "type": "str"}, + "type": {"key": "type", "type": "str"}, + "location": {"key": "location", "type": "str"}, + "extended_location": {"key": "extendedLocation", "type": "ExtendedLocation"}, + "tags": {"key": "tags", "type": "{str}"}, + "plan": {"key": "plan", "type": "Plan"}, + "properties": {"key": "properties", "type": "object"}, + "kind": {"key": "kind", "type": "str"}, + "managed_by": {"key": "managedBy", "type": "str"}, + "sku": {"key": "sku", "type": "Sku"}, + "identity": {"key": "identity", "type": "Identity"}, + "created_time": {"key": "createdTime", "type": "iso-8601"}, + "changed_time": {"key": "changedTime", "type": "iso-8601"}, + "provisioning_state": {"key": "provisioningState", "type": "str"}, } def __init__( self, *, location: Optional[str] = None, - extended_location: Optional["ExtendedLocation"] = None, + extended_location: Optional["_models.ExtendedLocation"] = None, tags: Optional[Dict[str, str]] = None, - plan: Optional["Plan"] = None, - properties: Optional[Any] = None, + plan: Optional["_models.Plan"] = None, + properties: Optional[JSON] = None, kind: Optional[str] = None, managed_by: Optional[str] = None, - sku: Optional["Sku"] = None, - identity: Optional["Identity"] = None, + sku: Optional["_models.Sku"] = None, + identity: Optional["_models.Identity"] = None, **kwargs ): """ @@ -1577,12 +1510,12 @@ def __init__( :keyword extended_location: Resource extended location. :paramtype extended_location: ~azure.mgmt.resource.resources.v2021_04_01.models.ExtendedLocation - :keyword tags: A set of tags. Resource tags. + :keyword tags: Resource tags. :paramtype tags: dict[str, str] :keyword plan: The plan of the resource. :paramtype plan: ~azure.mgmt.resource.resources.v2021_04_01.models.Plan :keyword properties: The resource properties. - :paramtype properties: any + :paramtype properties: JSON :keyword kind: The kind of the resource. :paramtype kind: str :keyword managed_by: ID of the resource that manages this resource. @@ -1592,13 +1525,24 @@ def __init__( :keyword identity: The identity of the resource. :paramtype identity: ~azure.mgmt.resource.resources.v2021_04_01.models.Identity """ - super(GenericResourceExpanded, self).__init__(location=location, extended_location=extended_location, tags=tags, plan=plan, properties=properties, kind=kind, managed_by=managed_by, sku=sku, identity=identity, **kwargs) + super().__init__( + location=location, + extended_location=extended_location, + tags=tags, + plan=plan, + properties=properties, + kind=kind, + managed_by=managed_by, + sku=sku, + identity=identity, + **kwargs + ) self.created_time = None self.changed_time = None self.provisioning_state = None -class GenericResourceFilter(msrest.serialization.Model): +class GenericResourceFilter(_serialization.Model): """Resource filter. :ivar resource_type: The resource type. @@ -1610,9 +1554,9 @@ class GenericResourceFilter(msrest.serialization.Model): """ _attribute_map = { - 'resource_type': {'key': 'resourceType', 'type': 'str'}, - 'tagname': {'key': 'tagname', 'type': 'str'}, - 'tagvalue': {'key': 'tagvalue', 'type': 'str'}, + "resource_type": {"key": "resourceType", "type": "str"}, + "tagname": {"key": "tagname", "type": "str"}, + "tagvalue": {"key": "tagvalue", "type": "str"}, } def __init__( @@ -1631,38 +1575,33 @@ def __init__( :keyword tagvalue: The tag value. :paramtype tagvalue: str """ - super(GenericResourceFilter, self).__init__(**kwargs) + super().__init__(**kwargs) self.resource_type = resource_type self.tagname = tagname self.tagvalue = tagvalue -class HttpMessage(msrest.serialization.Model): +class HttpMessage(_serialization.Model): """HTTP message. :ivar content: HTTP message content. - :vartype content: any + :vartype content: JSON """ _attribute_map = { - 'content': {'key': 'content', 'type': 'object'}, + "content": {"key": "content", "type": "object"}, } - def __init__( - self, - *, - content: Optional[Any] = None, - **kwargs - ): + def __init__(self, *, content: Optional[JSON] = None, **kwargs): """ :keyword content: HTTP message content. - :paramtype content: any + :paramtype content: JSON """ - super(HttpMessage, self).__init__(**kwargs) + super().__init__(**kwargs) self.content = content -class Identity(msrest.serialization.Model): +class Identity(_serialization.Model): """Identity for the resource. Variables are only populated by the server, and will be ignored when sending a request. @@ -1671,8 +1610,8 @@ class Identity(msrest.serialization.Model): :vartype principal_id: str :ivar tenant_id: The tenant ID of resource. :vartype tenant_id: str - :ivar type: The identity type. Possible values include: "SystemAssigned", "UserAssigned", - "SystemAssigned, UserAssigned", "None". + :ivar type: The identity type. Known values are: "SystemAssigned", "UserAssigned", + "SystemAssigned, UserAssigned", and "None". :vartype type: str or ~azure.mgmt.resource.resources.v2021_04_01.models.ResourceIdentityType :ivar user_assigned_identities: The list of user identities associated with the resource. The user identity dictionary key references will be ARM resource ids in the form: @@ -1682,27 +1621,27 @@ class Identity(msrest.serialization.Model): """ _validation = { - 'principal_id': {'readonly': True}, - 'tenant_id': {'readonly': True}, + "principal_id": {"readonly": True}, + "tenant_id": {"readonly": True}, } _attribute_map = { - 'principal_id': {'key': 'principalId', 'type': 'str'}, - 'tenant_id': {'key': 'tenantId', 'type': 'str'}, - 'type': {'key': 'type', 'type': 'str'}, - 'user_assigned_identities': {'key': 'userAssignedIdentities', 'type': '{IdentityUserAssignedIdentitiesValue}'}, + "principal_id": {"key": "principalId", "type": "str"}, + "tenant_id": {"key": "tenantId", "type": "str"}, + "type": {"key": "type", "type": "str"}, + "user_assigned_identities": {"key": "userAssignedIdentities", "type": "{IdentityUserAssignedIdentitiesValue}"}, } def __init__( self, *, - type: Optional[Union[str, "ResourceIdentityType"]] = None, - user_assigned_identities: Optional[Dict[str, "IdentityUserAssignedIdentitiesValue"]] = None, + type: Optional[Union[str, "_models.ResourceIdentityType"]] = None, + user_assigned_identities: Optional[Dict[str, "_models.IdentityUserAssignedIdentitiesValue"]] = None, **kwargs ): """ - :keyword type: The identity type. Possible values include: "SystemAssigned", "UserAssigned", - "SystemAssigned, UserAssigned", "None". + :keyword type: The identity type. Known values are: "SystemAssigned", "UserAssigned", + "SystemAssigned, UserAssigned", and "None". :paramtype type: str or ~azure.mgmt.resource.resources.v2021_04_01.models.ResourceIdentityType :keyword user_assigned_identities: The list of user identities associated with the resource. The user identity dictionary key references will be ARM resource ids in the form: @@ -1710,14 +1649,14 @@ def __init__( :paramtype user_assigned_identities: dict[str, ~azure.mgmt.resource.resources.v2021_04_01.models.IdentityUserAssignedIdentitiesValue] """ - super(Identity, self).__init__(**kwargs) + super().__init__(**kwargs) self.principal_id = None self.tenant_id = None self.type = type self.user_assigned_identities = user_assigned_identities -class IdentityUserAssignedIdentitiesValue(msrest.serialization.Model): +class IdentityUserAssignedIdentitiesValue(_serialization.Model): """IdentityUserAssignedIdentitiesValue. Variables are only populated by the server, and will be ignored when sending a request. @@ -1729,61 +1668,57 @@ class IdentityUserAssignedIdentitiesValue(msrest.serialization.Model): """ _validation = { - 'principal_id': {'readonly': True}, - 'client_id': {'readonly': True}, + "principal_id": {"readonly": True}, + "client_id": {"readonly": True}, } _attribute_map = { - 'principal_id': {'key': 'principalId', 'type': 'str'}, - 'client_id': {'key': 'clientId', 'type': 'str'}, + "principal_id": {"key": "principalId", "type": "str"}, + "client_id": {"key": "clientId", "type": "str"}, } - def __init__( - self, - **kwargs - ): - """ - """ - super(IdentityUserAssignedIdentitiesValue, self).__init__(**kwargs) + def __init__(self, **kwargs): + """ """ + super().__init__(**kwargs) self.principal_id = None self.client_id = None -class OnErrorDeployment(msrest.serialization.Model): +class OnErrorDeployment(_serialization.Model): """Deployment on error behavior. :ivar type: The deployment on error behavior type. Possible values are LastSuccessful and - SpecificDeployment. Possible values include: "LastSuccessful", "SpecificDeployment". + SpecificDeployment. Known values are: "LastSuccessful" and "SpecificDeployment". :vartype type: str or ~azure.mgmt.resource.resources.v2021_04_01.models.OnErrorDeploymentType :ivar deployment_name: The deployment to be used on error case. :vartype deployment_name: str """ _attribute_map = { - 'type': {'key': 'type', 'type': 'str'}, - 'deployment_name': {'key': 'deploymentName', 'type': 'str'}, + "type": {"key": "type", "type": "str"}, + "deployment_name": {"key": "deploymentName", "type": "str"}, } def __init__( self, *, - type: Optional[Union[str, "OnErrorDeploymentType"]] = None, + type: Optional[Union[str, "_models.OnErrorDeploymentType"]] = None, deployment_name: Optional[str] = None, **kwargs ): """ :keyword type: The deployment on error behavior type. Possible values are LastSuccessful and - SpecificDeployment. Possible values include: "LastSuccessful", "SpecificDeployment". + SpecificDeployment. Known values are: "LastSuccessful" and "SpecificDeployment". :paramtype type: str or ~azure.mgmt.resource.resources.v2021_04_01.models.OnErrorDeploymentType :keyword deployment_name: The deployment to be used on error case. :paramtype deployment_name: str """ - super(OnErrorDeployment, self).__init__(**kwargs) + super().__init__(**kwargs) self.type = type self.deployment_name = deployment_name -class OnErrorDeploymentExtended(msrest.serialization.Model): +class OnErrorDeploymentExtended(_serialization.Model): """Deployment on error behavior with additional details. Variables are only populated by the server, and will be ignored when sending a request. @@ -1791,43 +1726,43 @@ class OnErrorDeploymentExtended(msrest.serialization.Model): :ivar provisioning_state: The state of the provisioning for the on error deployment. :vartype provisioning_state: str :ivar type: The deployment on error behavior type. Possible values are LastSuccessful and - SpecificDeployment. Possible values include: "LastSuccessful", "SpecificDeployment". + SpecificDeployment. Known values are: "LastSuccessful" and "SpecificDeployment". :vartype type: str or ~azure.mgmt.resource.resources.v2021_04_01.models.OnErrorDeploymentType :ivar deployment_name: The deployment to be used on error case. :vartype deployment_name: str """ _validation = { - 'provisioning_state': {'readonly': True}, + "provisioning_state": {"readonly": True}, } _attribute_map = { - 'provisioning_state': {'key': 'provisioningState', 'type': 'str'}, - 'type': {'key': 'type', 'type': 'str'}, - 'deployment_name': {'key': 'deploymentName', 'type': 'str'}, + "provisioning_state": {"key": "provisioningState", "type": "str"}, + "type": {"key": "type", "type": "str"}, + "deployment_name": {"key": "deploymentName", "type": "str"}, } def __init__( self, *, - type: Optional[Union[str, "OnErrorDeploymentType"]] = None, + type: Optional[Union[str, "_models.OnErrorDeploymentType"]] = None, deployment_name: Optional[str] = None, **kwargs ): """ :keyword type: The deployment on error behavior type. Possible values are LastSuccessful and - SpecificDeployment. Possible values include: "LastSuccessful", "SpecificDeployment". + SpecificDeployment. Known values are: "LastSuccessful" and "SpecificDeployment". :paramtype type: str or ~azure.mgmt.resource.resources.v2021_04_01.models.OnErrorDeploymentType :keyword deployment_name: The deployment to be used on error case. :paramtype deployment_name: str """ - super(OnErrorDeploymentExtended, self).__init__(**kwargs) + super().__init__(**kwargs) self.provisioning_state = None self.type = type self.deployment_name = deployment_name -class Operation(msrest.serialization.Model): +class Operation(_serialization.Model): """Microsoft.Resources operation. :ivar name: Operation name: {provider}/{resource}/{operation}. @@ -1837,29 +1772,23 @@ class Operation(msrest.serialization.Model): """ _attribute_map = { - 'name': {'key': 'name', 'type': 'str'}, - 'display': {'key': 'display', 'type': 'OperationDisplay'}, + "name": {"key": "name", "type": "str"}, + "display": {"key": "display", "type": "OperationDisplay"}, } - def __init__( - self, - *, - name: Optional[str] = None, - display: Optional["OperationDisplay"] = None, - **kwargs - ): + def __init__(self, *, name: Optional[str] = None, display: Optional["_models.OperationDisplay"] = None, **kwargs): """ :keyword name: Operation name: {provider}/{resource}/{operation}. :paramtype name: str :keyword display: The object that represents the operation. :paramtype display: ~azure.mgmt.resource.resources.v2021_04_01.models.OperationDisplay """ - super(Operation, self).__init__(**kwargs) + super().__init__(**kwargs) self.name = name self.display = display -class OperationDisplay(msrest.serialization.Model): +class OperationDisplay(_serialization.Model): """The object that represents the operation. :ivar provider: Service provider: Microsoft.Resources. @@ -1873,10 +1802,10 @@ class OperationDisplay(msrest.serialization.Model): """ _attribute_map = { - 'provider': {'key': 'provider', 'type': 'str'}, - 'resource': {'key': 'resource', 'type': 'str'}, - 'operation': {'key': 'operation', 'type': 'str'}, - 'description': {'key': 'description', 'type': 'str'}, + "provider": {"key": "provider", "type": "str"}, + "resource": {"key": "resource", "type": "str"}, + "operation": {"key": "operation", "type": "str"}, + "description": {"key": "description", "type": "str"}, } def __init__( @@ -1898,14 +1827,14 @@ def __init__( :keyword description: Description of the operation. :paramtype description: str """ - super(OperationDisplay, self).__init__(**kwargs) + super().__init__(**kwargs) self.provider = provider self.resource = resource self.operation = operation self.description = description -class OperationListResult(msrest.serialization.Model): +class OperationListResult(_serialization.Model): """Result of the request to list Microsoft.Resources operations. It contains a list of operations and a URL link to get the next set of results. :ivar value: List of Microsoft.Resources operations. @@ -1915,67 +1844,55 @@ class OperationListResult(msrest.serialization.Model): """ _attribute_map = { - 'value': {'key': 'value', 'type': '[Operation]'}, - 'next_link': {'key': 'nextLink', 'type': 'str'}, + "value": {"key": "value", "type": "[Operation]"}, + "next_link": {"key": "nextLink", "type": "str"}, } - def __init__( - self, - *, - value: Optional[List["Operation"]] = None, - next_link: Optional[str] = None, - **kwargs - ): + def __init__(self, *, value: Optional[List["_models.Operation"]] = None, next_link: Optional[str] = None, **kwargs): """ :keyword value: List of Microsoft.Resources operations. :paramtype value: list[~azure.mgmt.resource.resources.v2021_04_01.models.Operation] :keyword next_link: URL to get the next set of operation list results if there are any. :paramtype next_link: str """ - super(OperationListResult, self).__init__(**kwargs) + super().__init__(**kwargs) self.value = value self.next_link = next_link -class ParametersLink(msrest.serialization.Model): +class ParametersLink(_serialization.Model): """Entity representing the reference to the deployment parameters. All required parameters must be populated in order to send to Azure. - :ivar uri: Required. The URI of the parameters file. + :ivar uri: The URI of the parameters file. Required. :vartype uri: str :ivar content_version: If included, must match the ContentVersion in the template. :vartype content_version: str """ _validation = { - 'uri': {'required': True}, + "uri": {"required": True}, } _attribute_map = { - 'uri': {'key': 'uri', 'type': 'str'}, - 'content_version': {'key': 'contentVersion', 'type': 'str'}, + "uri": {"key": "uri", "type": "str"}, + "content_version": {"key": "contentVersion", "type": "str"}, } - def __init__( - self, - *, - uri: str, - content_version: Optional[str] = None, - **kwargs - ): + def __init__(self, *, uri: str, content_version: Optional[str] = None, **kwargs): """ - :keyword uri: Required. The URI of the parameters file. + :keyword uri: The URI of the parameters file. Required. :paramtype uri: str :keyword content_version: If included, must match the ContentVersion in the template. :paramtype content_version: str """ - super(ParametersLink, self).__init__(**kwargs) + super().__init__(**kwargs) self.uri = uri self.content_version = content_version -class Permission(msrest.serialization.Model): +class Permission(_serialization.Model): """Role definition permissions. :ivar actions: Allowed actions. @@ -1989,10 +1906,10 @@ class Permission(msrest.serialization.Model): """ _attribute_map = { - 'actions': {'key': 'actions', 'type': '[str]'}, - 'not_actions': {'key': 'notActions', 'type': '[str]'}, - 'data_actions': {'key': 'dataActions', 'type': '[str]'}, - 'not_data_actions': {'key': 'notDataActions', 'type': '[str]'}, + "actions": {"key": "actions", "type": "[str]"}, + "not_actions": {"key": "notActions", "type": "[str]"}, + "data_actions": {"key": "dataActions", "type": "[str]"}, + "not_data_actions": {"key": "notDataActions", "type": "[str]"}, } def __init__( @@ -2014,14 +1931,14 @@ def __init__( :keyword not_data_actions: Denied Data actions. :paramtype not_data_actions: list[str] """ - super(Permission, self).__init__(**kwargs) + super().__init__(**kwargs) self.actions = actions self.not_actions = not_actions self.data_actions = data_actions self.not_data_actions = not_data_actions -class Plan(msrest.serialization.Model): +class Plan(_serialization.Model): """Plan for the resource. :ivar name: The plan ID. @@ -2037,11 +1954,11 @@ class Plan(msrest.serialization.Model): """ _attribute_map = { - 'name': {'key': 'name', 'type': 'str'}, - 'publisher': {'key': 'publisher', 'type': 'str'}, - 'product': {'key': 'product', 'type': 'str'}, - 'promotion_code': {'key': 'promotionCode', 'type': 'str'}, - 'version': {'key': 'version', 'type': 'str'}, + "name": {"key": "name", "type": "str"}, + "publisher": {"key": "publisher", "type": "str"}, + "product": {"key": "product", "type": "str"}, + "promotion_code": {"key": "promotionCode", "type": "str"}, + "version": {"key": "version", "type": "str"}, } def __init__( @@ -2066,7 +1983,7 @@ def __init__( :keyword version: The plan's version. :paramtype version: str """ - super(Plan, self).__init__(**kwargs) + super().__init__(**kwargs) self.name = name self.publisher = publisher self.product = product @@ -2074,7 +1991,7 @@ def __init__( self.version = version -class Provider(msrest.serialization.Model): +class Provider(_serialization.Model): """Resource provider information. Variables are only populated by the server, and will be ignored when sending a request. @@ -2090,44 +2007,44 @@ class Provider(msrest.serialization.Model): :ivar resource_types: The collection of provider resource types. :vartype resource_types: list[~azure.mgmt.resource.resources.v2021_04_01.models.ProviderResourceType] - :ivar provider_authorization_consent_state: The provider authorization consent state. Possible - values include: "NotSpecified", "Required", "NotRequired", "Consented". + :ivar provider_authorization_consent_state: The provider authorization consent state. Known + values are: "NotSpecified", "Required", "NotRequired", and "Consented". :vartype provider_authorization_consent_state: str or ~azure.mgmt.resource.resources.v2021_04_01.models.ProviderAuthorizationConsentState """ _validation = { - 'id': {'readonly': True}, - 'registration_state': {'readonly': True}, - 'registration_policy': {'readonly': True}, - 'resource_types': {'readonly': True}, + "id": {"readonly": True}, + "registration_state": {"readonly": True}, + "registration_policy": {"readonly": True}, + "resource_types": {"readonly": True}, } _attribute_map = { - 'id': {'key': 'id', 'type': 'str'}, - 'namespace': {'key': 'namespace', 'type': 'str'}, - 'registration_state': {'key': 'registrationState', 'type': 'str'}, - 'registration_policy': {'key': 'registrationPolicy', 'type': 'str'}, - 'resource_types': {'key': 'resourceTypes', 'type': '[ProviderResourceType]'}, - 'provider_authorization_consent_state': {'key': 'providerAuthorizationConsentState', 'type': 'str'}, + "id": {"key": "id", "type": "str"}, + "namespace": {"key": "namespace", "type": "str"}, + "registration_state": {"key": "registrationState", "type": "str"}, + "registration_policy": {"key": "registrationPolicy", "type": "str"}, + "resource_types": {"key": "resourceTypes", "type": "[ProviderResourceType]"}, + "provider_authorization_consent_state": {"key": "providerAuthorizationConsentState", "type": "str"}, } def __init__( self, *, namespace: Optional[str] = None, - provider_authorization_consent_state: Optional[Union[str, "ProviderAuthorizationConsentState"]] = None, + provider_authorization_consent_state: Optional[Union[str, "_models.ProviderAuthorizationConsentState"]] = None, **kwargs ): """ :keyword namespace: The namespace of the resource provider. :paramtype namespace: str - :keyword provider_authorization_consent_state: The provider authorization consent state. - Possible values include: "NotSpecified", "Required", "NotRequired", "Consented". + :keyword provider_authorization_consent_state: The provider authorization consent state. Known + values are: "NotSpecified", "Required", "NotRequired", and "Consented". :paramtype provider_authorization_consent_state: str or ~azure.mgmt.resource.resources.v2021_04_01.models.ProviderAuthorizationConsentState """ - super(Provider, self).__init__(**kwargs) + super().__init__(**kwargs) self.id = None self.namespace = namespace self.registration_state = None @@ -2136,7 +2053,7 @@ def __init__( self.provider_authorization_consent_state = provider_authorization_consent_state -class ProviderConsentDefinition(msrest.serialization.Model): +class ProviderConsentDefinition(_serialization.Model): """The provider consent. :ivar consent_to_authorization: A value indicating whether authorization is consented or not. @@ -2144,25 +2061,20 @@ class ProviderConsentDefinition(msrest.serialization.Model): """ _attribute_map = { - 'consent_to_authorization': {'key': 'consentToAuthorization', 'type': 'bool'}, + "consent_to_authorization": {"key": "consentToAuthorization", "type": "bool"}, } - def __init__( - self, - *, - consent_to_authorization: Optional[bool] = None, - **kwargs - ): + def __init__(self, *, consent_to_authorization: Optional[bool] = None, **kwargs): """ :keyword consent_to_authorization: A value indicating whether authorization is consented or not. :paramtype consent_to_authorization: bool """ - super(ProviderConsentDefinition, self).__init__(**kwargs) + super().__init__(**kwargs) self.consent_to_authorization = consent_to_authorization -class ProviderExtendedLocation(msrest.serialization.Model): +class ProviderExtendedLocation(_serialization.Model): """The provider extended location. :ivar location: The azure location. @@ -2174,9 +2086,9 @@ class ProviderExtendedLocation(msrest.serialization.Model): """ _attribute_map = { - 'location': {'key': 'location', 'type': 'str'}, - 'type': {'key': 'type', 'type': 'str'}, - 'extended_locations': {'key': 'extendedLocations', 'type': '[str]'}, + "location": {"key": "location", "type": "str"}, + "type": {"key": "type", "type": "str"}, + "extended_locations": {"key": "extendedLocations", "type": "[str]"}, } def __init__( @@ -2195,13 +2107,13 @@ def __init__( :keyword extended_locations: The extended locations for the azure location. :paramtype extended_locations: list[str] """ - super(ProviderExtendedLocation, self).__init__(**kwargs) + super().__init__(**kwargs) self.location = location self.type = type self.extended_locations = extended_locations -class ProviderListResult(msrest.serialization.Model): +class ProviderListResult(_serialization.Model): """List of resource providers. Variables are only populated by the server, and will be ignored when sending a request. @@ -2213,30 +2125,25 @@ class ProviderListResult(msrest.serialization.Model): """ _validation = { - 'next_link': {'readonly': True}, + "next_link": {"readonly": True}, } _attribute_map = { - 'value': {'key': 'value', 'type': '[Provider]'}, - 'next_link': {'key': 'nextLink', 'type': 'str'}, + "value": {"key": "value", "type": "[Provider]"}, + "next_link": {"key": "nextLink", "type": "str"}, } - def __init__( - self, - *, - value: Optional[List["Provider"]] = None, - **kwargs - ): + def __init__(self, *, value: Optional[List["_models.Provider"]] = None, **kwargs): """ :keyword value: An array of resource providers. :paramtype value: list[~azure.mgmt.resource.resources.v2021_04_01.models.Provider] """ - super(ProviderListResult, self).__init__(**kwargs) + super().__init__(**kwargs) self.value = value self.next_link = None -class ProviderPermission(msrest.serialization.Model): +class ProviderPermission(_serialization.Model): """The provider permission. :ivar application_id: The application id. @@ -2246,26 +2153,26 @@ class ProviderPermission(msrest.serialization.Model): :ivar managed_by_role_definition: Role definition properties. :vartype managed_by_role_definition: ~azure.mgmt.resource.resources.v2021_04_01.models.RoleDefinition - :ivar provider_authorization_consent_state: The provider authorization consent state. Possible - values include: "NotSpecified", "Required", "NotRequired", "Consented". + :ivar provider_authorization_consent_state: The provider authorization consent state. Known + values are: "NotSpecified", "Required", "NotRequired", and "Consented". :vartype provider_authorization_consent_state: str or ~azure.mgmt.resource.resources.v2021_04_01.models.ProviderAuthorizationConsentState """ _attribute_map = { - 'application_id': {'key': 'applicationId', 'type': 'str'}, - 'role_definition': {'key': 'roleDefinition', 'type': 'RoleDefinition'}, - 'managed_by_role_definition': {'key': 'managedByRoleDefinition', 'type': 'RoleDefinition'}, - 'provider_authorization_consent_state': {'key': 'providerAuthorizationConsentState', 'type': 'str'}, + "application_id": {"key": "applicationId", "type": "str"}, + "role_definition": {"key": "roleDefinition", "type": "RoleDefinition"}, + "managed_by_role_definition": {"key": "managedByRoleDefinition", "type": "RoleDefinition"}, + "provider_authorization_consent_state": {"key": "providerAuthorizationConsentState", "type": "str"}, } def __init__( self, *, application_id: Optional[str] = None, - role_definition: Optional["RoleDefinition"] = None, - managed_by_role_definition: Optional["RoleDefinition"] = None, - provider_authorization_consent_state: Optional[Union[str, "ProviderAuthorizationConsentState"]] = None, + role_definition: Optional["_models.RoleDefinition"] = None, + managed_by_role_definition: Optional["_models.RoleDefinition"] = None, + provider_authorization_consent_state: Optional[Union[str, "_models.ProviderAuthorizationConsentState"]] = None, **kwargs ): """ @@ -2276,19 +2183,19 @@ def __init__( :keyword managed_by_role_definition: Role definition properties. :paramtype managed_by_role_definition: ~azure.mgmt.resource.resources.v2021_04_01.models.RoleDefinition - :keyword provider_authorization_consent_state: The provider authorization consent state. - Possible values include: "NotSpecified", "Required", "NotRequired", "Consented". + :keyword provider_authorization_consent_state: The provider authorization consent state. Known + values are: "NotSpecified", "Required", "NotRequired", and "Consented". :paramtype provider_authorization_consent_state: str or ~azure.mgmt.resource.resources.v2021_04_01.models.ProviderAuthorizationConsentState """ - super(ProviderPermission, self).__init__(**kwargs) + super().__init__(**kwargs) self.application_id = application_id self.role_definition = role_definition self.managed_by_role_definition = managed_by_role_definition self.provider_authorization_consent_state = provider_authorization_consent_state -class ProviderPermissionListResult(msrest.serialization.Model): +class ProviderPermissionListResult(_serialization.Model): """List of provider permissions. Variables are only populated by the server, and will be ignored when sending a request. @@ -2300,30 +2207,25 @@ class ProviderPermissionListResult(msrest.serialization.Model): """ _validation = { - 'next_link': {'readonly': True}, + "next_link": {"readonly": True}, } _attribute_map = { - 'value': {'key': 'value', 'type': '[ProviderPermission]'}, - 'next_link': {'key': 'nextLink', 'type': 'str'}, + "value": {"key": "value", "type": "[ProviderPermission]"}, + "next_link": {"key": "nextLink", "type": "str"}, } - def __init__( - self, - *, - value: Optional[List["ProviderPermission"]] = None, - **kwargs - ): + def __init__(self, *, value: Optional[List["_models.ProviderPermission"]] = None, **kwargs): """ :keyword value: An array of provider permissions. :paramtype value: list[~azure.mgmt.resource.resources.v2021_04_01.models.ProviderPermission] """ - super(ProviderPermissionListResult, self).__init__(**kwargs) + super().__init__(**kwargs) self.value = value self.next_link = None -class ProviderRegistrationRequest(msrest.serialization.Model): +class ProviderRegistrationRequest(_serialization.Model): """The provider registration definition. :ivar third_party_provider_consent: The provider consent. @@ -2332,25 +2234,20 @@ class ProviderRegistrationRequest(msrest.serialization.Model): """ _attribute_map = { - 'third_party_provider_consent': {'key': 'thirdPartyProviderConsent', 'type': 'ProviderConsentDefinition'}, + "third_party_provider_consent": {"key": "thirdPartyProviderConsent", "type": "ProviderConsentDefinition"}, } - def __init__( - self, - *, - third_party_provider_consent: Optional["ProviderConsentDefinition"] = None, - **kwargs - ): + def __init__(self, *, third_party_provider_consent: Optional["_models.ProviderConsentDefinition"] = None, **kwargs): """ :keyword third_party_provider_consent: The provider consent. :paramtype third_party_provider_consent: ~azure.mgmt.resource.resources.v2021_04_01.models.ProviderConsentDefinition """ - super(ProviderRegistrationRequest, self).__init__(**kwargs) + super().__init__(**kwargs) self.third_party_provider_consent = third_party_provider_consent -class ProviderResourceType(msrest.serialization.Model): +class ProviderResourceType(_serialization.Model): """Resource type managed by the resource provider. Variables are only populated by the server, and will be ignored when sending a request. @@ -2379,21 +2276,21 @@ class ProviderResourceType(msrest.serialization.Model): """ _validation = { - 'default_api_version': {'readonly': True}, - 'api_profiles': {'readonly': True}, + "default_api_version": {"readonly": True}, + "api_profiles": {"readonly": True}, } _attribute_map = { - 'resource_type': {'key': 'resourceType', 'type': 'str'}, - 'locations': {'key': 'locations', 'type': '[str]'}, - 'location_mappings': {'key': 'locationMappings', 'type': '[ProviderExtendedLocation]'}, - 'aliases': {'key': 'aliases', 'type': '[Alias]'}, - 'api_versions': {'key': 'apiVersions', 'type': '[str]'}, - 'default_api_version': {'key': 'defaultApiVersion', 'type': 'str'}, - 'zone_mappings': {'key': 'zoneMappings', 'type': '[ZoneMapping]'}, - 'api_profiles': {'key': 'apiProfiles', 'type': '[ApiProfile]'}, - 'capabilities': {'key': 'capabilities', 'type': 'str'}, - 'properties': {'key': 'properties', 'type': '{str}'}, + "resource_type": {"key": "resourceType", "type": "str"}, + "locations": {"key": "locations", "type": "[str]"}, + "location_mappings": {"key": "locationMappings", "type": "[ProviderExtendedLocation]"}, + "aliases": {"key": "aliases", "type": "[Alias]"}, + "api_versions": {"key": "apiVersions", "type": "[str]"}, + "default_api_version": {"key": "defaultApiVersion", "type": "str"}, + "zone_mappings": {"key": "zoneMappings", "type": "[ZoneMapping]"}, + "api_profiles": {"key": "apiProfiles", "type": "[ApiProfile]"}, + "capabilities": {"key": "capabilities", "type": "str"}, + "properties": {"key": "properties", "type": "{str}"}, } def __init__( @@ -2401,10 +2298,10 @@ def __init__( *, resource_type: Optional[str] = None, locations: Optional[List[str]] = None, - location_mappings: Optional[List["ProviderExtendedLocation"]] = None, - aliases: Optional[List["Alias"]] = None, + location_mappings: Optional[List["_models.ProviderExtendedLocation"]] = None, + aliases: Optional[List["_models.Alias"]] = None, api_versions: Optional[List[str]] = None, - zone_mappings: Optional[List["ZoneMapping"]] = None, + zone_mappings: Optional[List["_models.ZoneMapping"]] = None, capabilities: Optional[str] = None, properties: Optional[Dict[str, str]] = None, **kwargs @@ -2428,7 +2325,7 @@ def __init__( :keyword properties: The properties. :paramtype properties: dict[str, str] """ - super(ProviderResourceType, self).__init__(**kwargs) + super().__init__(**kwargs) self.resource_type = resource_type self.locations = locations self.location_mappings = location_mappings @@ -2441,7 +2338,7 @@ def __init__( self.properties = properties -class ProviderResourceTypeListResult(msrest.serialization.Model): +class ProviderResourceTypeListResult(_serialization.Model): """List of resource types of a resource provider. Variables are only populated by the server, and will be ignored when sending a request. @@ -2453,30 +2350,25 @@ class ProviderResourceTypeListResult(msrest.serialization.Model): """ _validation = { - 'next_link': {'readonly': True}, + "next_link": {"readonly": True}, } _attribute_map = { - 'value': {'key': 'value', 'type': '[ProviderResourceType]'}, - 'next_link': {'key': 'nextLink', 'type': 'str'}, + "value": {"key": "value", "type": "[ProviderResourceType]"}, + "next_link": {"key": "nextLink", "type": "str"}, } - def __init__( - self, - *, - value: Optional[List["ProviderResourceType"]] = None, - **kwargs - ): + def __init__(self, *, value: Optional[List["_models.ProviderResourceType"]] = None, **kwargs): """ :keyword value: An array of resource types. :paramtype value: list[~azure.mgmt.resource.resources.v2021_04_01.models.ProviderResourceType] """ - super(ProviderResourceTypeListResult, self).__init__(**kwargs) + super().__init__(**kwargs) self.value = value self.next_link = None -class ResourceGroup(msrest.serialization.Model): +class ResourceGroup(_serialization.Model): """Resource group information. Variables are only populated by the server, and will be ignored when sending a request. @@ -2491,37 +2383,37 @@ class ResourceGroup(msrest.serialization.Model): :vartype type: str :ivar properties: The resource group properties. :vartype properties: ~azure.mgmt.resource.resources.v2021_04_01.models.ResourceGroupProperties - :ivar location: Required. The location of the resource group. It cannot be changed after the - resource group has been created. It must be one of the supported Azure locations. + :ivar location: The location of the resource group. It cannot be changed after the resource + group has been created. It must be one of the supported Azure locations. Required. :vartype location: str :ivar managed_by: The ID of the resource that manages this resource group. :vartype managed_by: str - :ivar tags: A set of tags. The tags attached to the resource group. + :ivar tags: The tags attached to the resource group. :vartype tags: dict[str, str] """ _validation = { - 'id': {'readonly': True}, - 'name': {'readonly': True}, - 'type': {'readonly': True}, - 'location': {'required': True}, + "id": {"readonly": True}, + "name": {"readonly": True}, + "type": {"readonly": True}, + "location": {"required": True}, } _attribute_map = { - 'id': {'key': 'id', 'type': 'str'}, - 'name': {'key': 'name', 'type': 'str'}, - 'type': {'key': 'type', 'type': 'str'}, - 'properties': {'key': 'properties', 'type': 'ResourceGroupProperties'}, - 'location': {'key': 'location', 'type': 'str'}, - 'managed_by': {'key': 'managedBy', 'type': 'str'}, - 'tags': {'key': 'tags', 'type': '{str}'}, + "id": {"key": "id", "type": "str"}, + "name": {"key": "name", "type": "str"}, + "type": {"key": "type", "type": "str"}, + "properties": {"key": "properties", "type": "ResourceGroupProperties"}, + "location": {"key": "location", "type": "str"}, + "managed_by": {"key": "managedBy", "type": "str"}, + "tags": {"key": "tags", "type": "{str}"}, } def __init__( self, *, location: str, - properties: Optional["ResourceGroupProperties"] = None, + properties: Optional["_models.ResourceGroupProperties"] = None, managed_by: Optional[str] = None, tags: Optional[Dict[str, str]] = None, **kwargs @@ -2530,15 +2422,15 @@ def __init__( :keyword properties: The resource group properties. :paramtype properties: ~azure.mgmt.resource.resources.v2021_04_01.models.ResourceGroupProperties - :keyword location: Required. The location of the resource group. It cannot be changed after the - resource group has been created. It must be one of the supported Azure locations. + :keyword location: The location of the resource group. It cannot be changed after the resource + group has been created. It must be one of the supported Azure locations. Required. :paramtype location: str :keyword managed_by: The ID of the resource that manages this resource group. :paramtype managed_by: str - :keyword tags: A set of tags. The tags attached to the resource group. + :keyword tags: The tags attached to the resource group. :paramtype tags: dict[str, str] """ - super(ResourceGroup, self).__init__(**kwargs) + super().__init__(**kwargs) self.id = None self.name = None self.type = None @@ -2548,39 +2440,33 @@ def __init__( self.tags = tags -class ResourceGroupExportResult(msrest.serialization.Model): +class ResourceGroupExportResult(_serialization.Model): """Resource group export result. :ivar template: The template content. - :vartype template: any + :vartype template: JSON :ivar error: The template export error. :vartype error: ~azure.mgmt.resource.resources.v2021_04_01.models.ErrorResponse """ _attribute_map = { - 'template': {'key': 'template', 'type': 'object'}, - 'error': {'key': 'error', 'type': 'ErrorResponse'}, + "template": {"key": "template", "type": "object"}, + "error": {"key": "error", "type": "ErrorResponse"}, } - def __init__( - self, - *, - template: Optional[Any] = None, - error: Optional["ErrorResponse"] = None, - **kwargs - ): + def __init__(self, *, template: Optional[JSON] = None, error: Optional["_models.ErrorResponse"] = None, **kwargs): """ :keyword template: The template content. - :paramtype template: any + :paramtype template: JSON :keyword error: The template export error. :paramtype error: ~azure.mgmt.resource.resources.v2021_04_01.models.ErrorResponse """ - super(ResourceGroupExportResult, self).__init__(**kwargs) + super().__init__(**kwargs) self.template = template self.error = error -class ResourceGroupFilter(msrest.serialization.Model): +class ResourceGroupFilter(_serialization.Model): """Resource group filter. :ivar tag_name: The tag name. @@ -2590,29 +2476,23 @@ class ResourceGroupFilter(msrest.serialization.Model): """ _attribute_map = { - 'tag_name': {'key': 'tagName', 'type': 'str'}, - 'tag_value': {'key': 'tagValue', 'type': 'str'}, + "tag_name": {"key": "tagName", "type": "str"}, + "tag_value": {"key": "tagValue", "type": "str"}, } - def __init__( - self, - *, - tag_name: Optional[str] = None, - tag_value: Optional[str] = None, - **kwargs - ): + def __init__(self, *, tag_name: Optional[str] = None, tag_value: Optional[str] = None, **kwargs): """ :keyword tag_name: The tag name. :paramtype tag_name: str :keyword tag_value: The tag value. :paramtype tag_value: str """ - super(ResourceGroupFilter, self).__init__(**kwargs) + super().__init__(**kwargs) self.tag_name = tag_name self.tag_value = tag_value -class ResourceGroupListResult(msrest.serialization.Model): +class ResourceGroupListResult(_serialization.Model): """List of resource groups. Variables are only populated by the server, and will be ignored when sending a request. @@ -2624,30 +2504,25 @@ class ResourceGroupListResult(msrest.serialization.Model): """ _validation = { - 'next_link': {'readonly': True}, + "next_link": {"readonly": True}, } _attribute_map = { - 'value': {'key': 'value', 'type': '[ResourceGroup]'}, - 'next_link': {'key': 'nextLink', 'type': 'str'}, + "value": {"key": "value", "type": "[ResourceGroup]"}, + "next_link": {"key": "nextLink", "type": "str"}, } - def __init__( - self, - *, - value: Optional[List["ResourceGroup"]] = None, - **kwargs - ): + def __init__(self, *, value: Optional[List["_models.ResourceGroup"]] = None, **kwargs): """ :keyword value: An array of resource groups. :paramtype value: list[~azure.mgmt.resource.resources.v2021_04_01.models.ResourceGroup] """ - super(ResourceGroupListResult, self).__init__(**kwargs) + super().__init__(**kwargs) self.value = value self.next_link = None -class ResourceGroupPatchable(msrest.serialization.Model): +class ResourceGroupPatchable(_serialization.Model): """Resource group information. :ivar name: The name of the resource group. @@ -2656,22 +2531,22 @@ class ResourceGroupPatchable(msrest.serialization.Model): :vartype properties: ~azure.mgmt.resource.resources.v2021_04_01.models.ResourceGroupProperties :ivar managed_by: The ID of the resource that manages this resource group. :vartype managed_by: str - :ivar tags: A set of tags. The tags attached to the resource group. + :ivar tags: The tags attached to the resource group. :vartype tags: dict[str, str] """ _attribute_map = { - 'name': {'key': 'name', 'type': 'str'}, - 'properties': {'key': 'properties', 'type': 'ResourceGroupProperties'}, - 'managed_by': {'key': 'managedBy', 'type': 'str'}, - 'tags': {'key': 'tags', 'type': '{str}'}, + "name": {"key": "name", "type": "str"}, + "properties": {"key": "properties", "type": "ResourceGroupProperties"}, + "managed_by": {"key": "managedBy", "type": "str"}, + "tags": {"key": "tags", "type": "{str}"}, } def __init__( self, *, name: Optional[str] = None, - properties: Optional["ResourceGroupProperties"] = None, + properties: Optional["_models.ResourceGroupProperties"] = None, managed_by: Optional[str] = None, tags: Optional[Dict[str, str]] = None, **kwargs @@ -2684,17 +2559,17 @@ def __init__( ~azure.mgmt.resource.resources.v2021_04_01.models.ResourceGroupProperties :keyword managed_by: The ID of the resource that manages this resource group. :paramtype managed_by: str - :keyword tags: A set of tags. The tags attached to the resource group. + :keyword tags: The tags attached to the resource group. :paramtype tags: dict[str, str] """ - super(ResourceGroupPatchable, self).__init__(**kwargs) + super().__init__(**kwargs) self.name = name self.properties = properties self.managed_by = managed_by self.tags = tags -class ResourceGroupProperties(msrest.serialization.Model): +class ResourceGroupProperties(_serialization.Model): """The resource group properties. Variables are only populated by the server, and will be ignored when sending a request. @@ -2704,24 +2579,20 @@ class ResourceGroupProperties(msrest.serialization.Model): """ _validation = { - 'provisioning_state': {'readonly': True}, + "provisioning_state": {"readonly": True}, } _attribute_map = { - 'provisioning_state': {'key': 'provisioningState', 'type': 'str'}, + "provisioning_state": {"key": "provisioningState", "type": "str"}, } - def __init__( - self, - **kwargs - ): - """ - """ - super(ResourceGroupProperties, self).__init__(**kwargs) + def __init__(self, **kwargs): + """ """ + super().__init__(**kwargs) self.provisioning_state = None -class ResourceListResult(msrest.serialization.Model): +class ResourceListResult(_serialization.Model): """List of resource groups. Variables are only populated by the server, and will be ignored when sending a request. @@ -2733,31 +2604,26 @@ class ResourceListResult(msrest.serialization.Model): """ _validation = { - 'next_link': {'readonly': True}, + "next_link": {"readonly": True}, } _attribute_map = { - 'value': {'key': 'value', 'type': '[GenericResourceExpanded]'}, - 'next_link': {'key': 'nextLink', 'type': 'str'}, + "value": {"key": "value", "type": "[GenericResourceExpanded]"}, + "next_link": {"key": "nextLink", "type": "str"}, } - def __init__( - self, - *, - value: Optional[List["GenericResourceExpanded"]] = None, - **kwargs - ): + def __init__(self, *, value: Optional[List["_models.GenericResourceExpanded"]] = None, **kwargs): """ :keyword value: An array of resources. :paramtype value: list[~azure.mgmt.resource.resources.v2021_04_01.models.GenericResourceExpanded] """ - super(ResourceListResult, self).__init__(**kwargs) + super().__init__(**kwargs) self.value = value self.next_link = None -class ResourceProviderOperationDisplayProperties(msrest.serialization.Model): +class ResourceProviderOperationDisplayProperties(_serialization.Model): """Resource provider operation's display properties. :ivar publisher: Operation description. @@ -2773,11 +2639,11 @@ class ResourceProviderOperationDisplayProperties(msrest.serialization.Model): """ _attribute_map = { - 'publisher': {'key': 'publisher', 'type': 'str'}, - 'provider': {'key': 'provider', 'type': 'str'}, - 'resource': {'key': 'resource', 'type': 'str'}, - 'operation': {'key': 'operation', 'type': 'str'}, - 'description': {'key': 'description', 'type': 'str'}, + "publisher": {"key": "publisher", "type": "str"}, + "provider": {"key": "provider", "type": "str"}, + "resource": {"key": "resource", "type": "str"}, + "operation": {"key": "operation", "type": "str"}, + "description": {"key": "description", "type": "str"}, } def __init__( @@ -2802,7 +2668,7 @@ def __init__( :keyword description: Operation description. :paramtype description: str """ - super(ResourceProviderOperationDisplayProperties, self).__init__(**kwargs) + super().__init__(**kwargs) self.publisher = publisher self.provider = provider self.resource = resource @@ -2810,7 +2676,7 @@ def __init__( self.description = description -class ResourceReference(msrest.serialization.Model): +class ResourceReference(_serialization.Model): """The resource Id model. Variables are only populated by the server, and will be ignored when sending a request. @@ -2820,24 +2686,20 @@ class ResourceReference(msrest.serialization.Model): """ _validation = { - 'id': {'readonly': True}, + "id": {"readonly": True}, } _attribute_map = { - 'id': {'key': 'id', 'type': 'str'}, + "id": {"key": "id", "type": "str"}, } - def __init__( - self, - **kwargs - ): - """ - """ - super(ResourceReference, self).__init__(**kwargs) + def __init__(self, **kwargs): + """ """ + super().__init__(**kwargs) self.id = None -class ResourcesMoveInfo(msrest.serialization.Model): +class ResourcesMoveInfo(_serialization.Model): """Parameters of move resources. :ivar resources: The IDs of the resources. @@ -2847,29 +2709,23 @@ class ResourcesMoveInfo(msrest.serialization.Model): """ _attribute_map = { - 'resources': {'key': 'resources', 'type': '[str]'}, - 'target_resource_group': {'key': 'targetResourceGroup', 'type': 'str'}, + "resources": {"key": "resources", "type": "[str]"}, + "target_resource_group": {"key": "targetResourceGroup", "type": "str"}, } - def __init__( - self, - *, - resources: Optional[List[str]] = None, - target_resource_group: Optional[str] = None, - **kwargs - ): + def __init__(self, *, resources: Optional[List[str]] = None, target_resource_group: Optional[str] = None, **kwargs): """ :keyword resources: The IDs of the resources. :paramtype resources: list[str] :keyword target_resource_group: The target resource group. :paramtype target_resource_group: str """ - super(ResourcesMoveInfo, self).__init__(**kwargs) + super().__init__(**kwargs) self.resources = resources self.target_resource_group = target_resource_group -class RoleDefinition(msrest.serialization.Model): +class RoleDefinition(_serialization.Model): """Role definition properties. :ivar id: The role definition ID. @@ -2885,20 +2741,20 @@ class RoleDefinition(msrest.serialization.Model): """ _attribute_map = { - 'id': {'key': 'id', 'type': 'str'}, - 'name': {'key': 'name', 'type': 'str'}, - 'is_service_role': {'key': 'isServiceRole', 'type': 'bool'}, - 'permissions': {'key': 'permissions', 'type': '[Permission]'}, - 'scopes': {'key': 'scopes', 'type': '[str]'}, + "id": {"key": "id", "type": "str"}, + "name": {"key": "name", "type": "str"}, + "is_service_role": {"key": "isServiceRole", "type": "bool"}, + "permissions": {"key": "permissions", "type": "[Permission]"}, + "scopes": {"key": "scopes", "type": "[str]"}, } def __init__( self, *, - id: Optional[str] = None, + id: Optional[str] = None, # pylint: disable=redefined-builtin name: Optional[str] = None, is_service_role: Optional[bool] = None, - permissions: Optional[List["Permission"]] = None, + permissions: Optional[List["_models.Permission"]] = None, scopes: Optional[List[str]] = None, **kwargs ): @@ -2914,7 +2770,7 @@ def __init__( :keyword scopes: Role definition assignable scopes. :paramtype scopes: list[str] """ - super(RoleDefinition, self).__init__(**kwargs) + super().__init__(**kwargs) self.id = id self.name = name self.is_service_role = is_service_role @@ -2922,94 +2778,88 @@ def __init__( self.scopes = scopes -class ScopedDeployment(msrest.serialization.Model): +class ScopedDeployment(_serialization.Model): """Deployment operation parameters. All required parameters must be populated in order to send to Azure. - :ivar location: Required. The location to store the deployment data. + :ivar location: The location to store the deployment data. Required. :vartype location: str - :ivar properties: Required. The deployment properties. + :ivar properties: The deployment properties. Required. :vartype properties: ~azure.mgmt.resource.resources.v2021_04_01.models.DeploymentProperties - :ivar tags: A set of tags. Deployment tags. + :ivar tags: Deployment tags. :vartype tags: dict[str, str] """ _validation = { - 'location': {'required': True}, - 'properties': {'required': True}, + "location": {"required": True}, + "properties": {"required": True}, } _attribute_map = { - 'location': {'key': 'location', 'type': 'str'}, - 'properties': {'key': 'properties', 'type': 'DeploymentProperties'}, - 'tags': {'key': 'tags', 'type': '{str}'}, + "location": {"key": "location", "type": "str"}, + "properties": {"key": "properties", "type": "DeploymentProperties"}, + "tags": {"key": "tags", "type": "{str}"}, } def __init__( self, *, location: str, - properties: "DeploymentProperties", + properties: "_models.DeploymentProperties", tags: Optional[Dict[str, str]] = None, **kwargs ): """ - :keyword location: Required. The location to store the deployment data. + :keyword location: The location to store the deployment data. Required. :paramtype location: str - :keyword properties: Required. The deployment properties. + :keyword properties: The deployment properties. Required. :paramtype properties: ~azure.mgmt.resource.resources.v2021_04_01.models.DeploymentProperties - :keyword tags: A set of tags. Deployment tags. + :keyword tags: Deployment tags. :paramtype tags: dict[str, str] """ - super(ScopedDeployment, self).__init__(**kwargs) + super().__init__(**kwargs) self.location = location self.properties = properties self.tags = tags -class ScopedDeploymentWhatIf(msrest.serialization.Model): +class ScopedDeploymentWhatIf(_serialization.Model): """Deployment What-if operation parameters. All required parameters must be populated in order to send to Azure. - :ivar location: Required. The location to store the deployment data. + :ivar location: The location to store the deployment data. Required. :vartype location: str - :ivar properties: Required. The deployment properties. + :ivar properties: The deployment properties. Required. :vartype properties: ~azure.mgmt.resource.resources.v2021_04_01.models.DeploymentWhatIfProperties """ _validation = { - 'location': {'required': True}, - 'properties': {'required': True}, + "location": {"required": True}, + "properties": {"required": True}, } _attribute_map = { - 'location': {'key': 'location', 'type': 'str'}, - 'properties': {'key': 'properties', 'type': 'DeploymentWhatIfProperties'}, + "location": {"key": "location", "type": "str"}, + "properties": {"key": "properties", "type": "DeploymentWhatIfProperties"}, } - def __init__( - self, - *, - location: str, - properties: "DeploymentWhatIfProperties", - **kwargs - ): + def __init__(self, *, location: str, properties: "_models.DeploymentWhatIfProperties", **kwargs): """ - :keyword location: Required. The location to store the deployment data. + :keyword location: The location to store the deployment data. Required. :paramtype location: str - :keyword properties: Required. The deployment properties. + :keyword properties: The deployment properties. Required. :paramtype properties: ~azure.mgmt.resource.resources.v2021_04_01.models.DeploymentWhatIfProperties """ - super(ScopedDeploymentWhatIf, self).__init__(**kwargs) + super().__init__(**kwargs) self.location = location self.properties = properties -class Sku(msrest.serialization.Model): +class Sku(_serialization.Model): """SKU for the resource. :ivar name: The SKU name. @@ -3027,12 +2877,12 @@ class Sku(msrest.serialization.Model): """ _attribute_map = { - 'name': {'key': 'name', 'type': 'str'}, - 'tier': {'key': 'tier', 'type': 'str'}, - 'size': {'key': 'size', 'type': 'str'}, - 'family': {'key': 'family', 'type': 'str'}, - 'model': {'key': 'model', 'type': 'str'}, - 'capacity': {'key': 'capacity', 'type': 'int'}, + "name": {"key": "name", "type": "str"}, + "tier": {"key": "tier", "type": "str"}, + "size": {"key": "size", "type": "str"}, + "family": {"key": "family", "type": "str"}, + "model": {"key": "model", "type": "str"}, + "capacity": {"key": "capacity", "type": "int"}, } def __init__( @@ -3060,7 +2910,7 @@ def __init__( :keyword capacity: The SKU capacity. :paramtype capacity: int """ - super(Sku, self).__init__(**kwargs) + super().__init__(**kwargs) self.name = name self.tier = tier self.size = size @@ -3069,7 +2919,7 @@ def __init__( self.capacity = capacity -class StatusMessage(msrest.serialization.Model): +class StatusMessage(_serialization.Model): """Operation status message object. :ivar status: Status of the deployment operation. @@ -3079,29 +2929,23 @@ class StatusMessage(msrest.serialization.Model): """ _attribute_map = { - 'status': {'key': 'status', 'type': 'str'}, - 'error': {'key': 'error', 'type': 'ErrorResponse'}, + "status": {"key": "status", "type": "str"}, + "error": {"key": "error", "type": "ErrorResponse"}, } - def __init__( - self, - *, - status: Optional[str] = None, - error: Optional["ErrorResponse"] = None, - **kwargs - ): + def __init__(self, *, status: Optional[str] = None, error: Optional["_models.ErrorResponse"] = None, **kwargs): """ :keyword status: Status of the deployment operation. :paramtype status: str :keyword error: The error reported by the operation. :paramtype error: ~azure.mgmt.resource.resources.v2021_04_01.models.ErrorResponse """ - super(StatusMessage, self).__init__(**kwargs) + super().__init__(**kwargs) self.status = status self.error = error -class SubResource(msrest.serialization.Model): +class SubResource(_serialization.Model): """Sub-resource. :ivar id: Resource ID. @@ -3109,24 +2953,19 @@ class SubResource(msrest.serialization.Model): """ _attribute_map = { - 'id': {'key': 'id', 'type': 'str'}, + "id": {"key": "id", "type": "str"}, } - def __init__( - self, - *, - id: Optional[str] = None, - **kwargs - ): + def __init__(self, *, id: Optional[str] = None, **kwargs): # pylint: disable=redefined-builtin """ :keyword id: Resource ID. :paramtype id: str """ - super(SubResource, self).__init__(**kwargs) + super().__init__(**kwargs) self.id = id -class TagCount(msrest.serialization.Model): +class TagCount(_serialization.Model): """Tag count. :ivar type: Type of count. @@ -3136,29 +2975,23 @@ class TagCount(msrest.serialization.Model): """ _attribute_map = { - 'type': {'key': 'type', 'type': 'str'}, - 'value': {'key': 'value', 'type': 'int'}, + "type": {"key": "type", "type": "str"}, + "value": {"key": "value", "type": "int"}, } - def __init__( - self, - *, - type: Optional[str] = None, - value: Optional[int] = None, - **kwargs - ): + def __init__(self, *, type: Optional[str] = None, value: Optional[int] = None, **kwargs): """ :keyword type: Type of count. :paramtype type: str :keyword value: Value of count. :paramtype value: int """ - super(TagCount, self).__init__(**kwargs) + super().__init__(**kwargs) self.type = type self.value = value -class TagDetails(msrest.serialization.Model): +class TagDetails(_serialization.Model): """Tag details. Variables are only populated by the server, and will be ignored when sending a request. @@ -3175,22 +3008,22 @@ class TagDetails(msrest.serialization.Model): """ _validation = { - 'id': {'readonly': True}, + "id": {"readonly": True}, } _attribute_map = { - 'id': {'key': 'id', 'type': 'str'}, - 'tag_name': {'key': 'tagName', 'type': 'str'}, - 'count': {'key': 'count', 'type': 'TagCount'}, - 'values': {'key': 'values', 'type': '[TagValue]'}, + "id": {"key": "id", "type": "str"}, + "tag_name": {"key": "tagName", "type": "str"}, + "count": {"key": "count", "type": "TagCount"}, + "values": {"key": "values", "type": "[TagValue]"}, } def __init__( self, *, tag_name: Optional[str] = None, - count: Optional["TagCount"] = None, - values: Optional[List["TagValue"]] = None, + count: Optional["_models.TagCount"] = None, + values: Optional[List["_models.TagValue"]] = None, **kwargs ): """ @@ -3202,39 +3035,34 @@ def __init__( :keyword values: The list of tag values. :paramtype values: list[~azure.mgmt.resource.resources.v2021_04_01.models.TagValue] """ - super(TagDetails, self).__init__(**kwargs) + super().__init__(**kwargs) self.id = None self.tag_name = tag_name self.count = count self.values = values -class Tags(msrest.serialization.Model): +class Tags(_serialization.Model): """A dictionary of name and value pairs. - :ivar tags: A set of tags. Dictionary of :code:``. + :ivar tags: Dictionary of :code:``. :vartype tags: dict[str, str] """ _attribute_map = { - 'tags': {'key': 'tags', 'type': '{str}'}, + "tags": {"key": "tags", "type": "{str}"}, } - def __init__( - self, - *, - tags: Optional[Dict[str, str]] = None, - **kwargs - ): + def __init__(self, *, tags: Optional[Dict[str, str]] = None, **kwargs): """ - :keyword tags: A set of tags. Dictionary of :code:``. + :keyword tags: Dictionary of :code:``. :paramtype tags: dict[str, str] """ - super(Tags, self).__init__(**kwargs) + super().__init__(**kwargs) self.tags = tags -class TagsListResult(msrest.serialization.Model): +class TagsListResult(_serialization.Model): """List of subscription tags. Variables are only populated by the server, and will be ignored when sending a request. @@ -3246,65 +3074,60 @@ class TagsListResult(msrest.serialization.Model): """ _validation = { - 'next_link': {'readonly': True}, + "next_link": {"readonly": True}, } _attribute_map = { - 'value': {'key': 'value', 'type': '[TagDetails]'}, - 'next_link': {'key': 'nextLink', 'type': 'str'}, + "value": {"key": "value", "type": "[TagDetails]"}, + "next_link": {"key": "nextLink", "type": "str"}, } - def __init__( - self, - *, - value: Optional[List["TagDetails"]] = None, - **kwargs - ): + def __init__(self, *, value: Optional[List["_models.TagDetails"]] = None, **kwargs): """ :keyword value: An array of tags. :paramtype value: list[~azure.mgmt.resource.resources.v2021_04_01.models.TagDetails] """ - super(TagsListResult, self).__init__(**kwargs) + super().__init__(**kwargs) self.value = value self.next_link = None -class TagsPatchResource(msrest.serialization.Model): +class TagsPatchResource(_serialization.Model): """Wrapper resource for tags patch API request only. - :ivar operation: The operation type for the patch API. Possible values include: "Replace", - "Merge", "Delete". + :ivar operation: The operation type for the patch API. Known values are: "Replace", "Merge", + and "Delete". :vartype operation: str or ~azure.mgmt.resource.resources.v2021_04_01.models.TagsPatchOperation :ivar properties: The set of tags. :vartype properties: ~azure.mgmt.resource.resources.v2021_04_01.models.Tags """ _attribute_map = { - 'operation': {'key': 'operation', 'type': 'str'}, - 'properties': {'key': 'properties', 'type': 'Tags'}, + "operation": {"key": "operation", "type": "str"}, + "properties": {"key": "properties", "type": "Tags"}, } def __init__( self, *, - operation: Optional[Union[str, "TagsPatchOperation"]] = None, - properties: Optional["Tags"] = None, + operation: Optional[Union[str, "_models.TagsPatchOperation"]] = None, + properties: Optional["_models.Tags"] = None, **kwargs ): """ - :keyword operation: The operation type for the patch API. Possible values include: "Replace", - "Merge", "Delete". + :keyword operation: The operation type for the patch API. Known values are: "Replace", "Merge", + and "Delete". :paramtype operation: str or ~azure.mgmt.resource.resources.v2021_04_01.models.TagsPatchOperation :keyword properties: The set of tags. :paramtype properties: ~azure.mgmt.resource.resources.v2021_04_01.models.Tags """ - super(TagsPatchResource, self).__init__(**kwargs) + super().__init__(**kwargs) self.operation = operation self.properties = properties -class TagsResource(msrest.serialization.Model): +class TagsResource(_serialization.Model): """Wrapper resource for tags API requests and responses. Variables are only populated by the server, and will be ignored when sending a request. @@ -3317,42 +3140,37 @@ class TagsResource(msrest.serialization.Model): :vartype name: str :ivar type: The type of the tags wrapper resource. :vartype type: str - :ivar properties: Required. The set of tags. + :ivar properties: The set of tags. Required. :vartype properties: ~azure.mgmt.resource.resources.v2021_04_01.models.Tags """ _validation = { - 'id': {'readonly': True}, - 'name': {'readonly': True}, - 'type': {'readonly': True}, - 'properties': {'required': True}, + "id": {"readonly": True}, + "name": {"readonly": True}, + "type": {"readonly": True}, + "properties": {"required": True}, } _attribute_map = { - 'id': {'key': 'id', 'type': 'str'}, - 'name': {'key': 'name', 'type': 'str'}, - 'type': {'key': 'type', 'type': 'str'}, - 'properties': {'key': 'properties', 'type': 'Tags'}, + "id": {"key": "id", "type": "str"}, + "name": {"key": "name", "type": "str"}, + "type": {"key": "type", "type": "str"}, + "properties": {"key": "properties", "type": "Tags"}, } - def __init__( - self, - *, - properties: "Tags", - **kwargs - ): + def __init__(self, *, properties: "_models.Tags", **kwargs): """ - :keyword properties: Required. The set of tags. + :keyword properties: The set of tags. Required. :paramtype properties: ~azure.mgmt.resource.resources.v2021_04_01.models.Tags """ - super(TagsResource, self).__init__(**kwargs) + super().__init__(**kwargs) self.id = None self.name = None self.type = None self.properties = properties -class TagValue(msrest.serialization.Model): +class TagValue(_serialization.Model): """Tag information. Variables are only populated by the server, and will be ignored when sending a request. @@ -3366,35 +3184,29 @@ class TagValue(msrest.serialization.Model): """ _validation = { - 'id': {'readonly': True}, + "id": {"readonly": True}, } _attribute_map = { - 'id': {'key': 'id', 'type': 'str'}, - 'tag_value': {'key': 'tagValue', 'type': 'str'}, - 'count': {'key': 'count', 'type': 'TagCount'}, + "id": {"key": "id", "type": "str"}, + "tag_value": {"key": "tagValue", "type": "str"}, + "count": {"key": "count", "type": "TagCount"}, } - def __init__( - self, - *, - tag_value: Optional[str] = None, - count: Optional["TagCount"] = None, - **kwargs - ): + def __init__(self, *, tag_value: Optional[str] = None, count: Optional["_models.TagCount"] = None, **kwargs): """ :keyword tag_value: The tag value. :paramtype tag_value: str :keyword count: The tag value count. :paramtype count: ~azure.mgmt.resource.resources.v2021_04_01.models.TagCount """ - super(TagValue, self).__init__(**kwargs) + super().__init__(**kwargs) self.id = None self.tag_value = tag_value self.count = count -class TargetResource(msrest.serialization.Model): +class TargetResource(_serialization.Model): """Target resource. :ivar id: The ID of the resource. @@ -3406,15 +3218,15 @@ class TargetResource(msrest.serialization.Model): """ _attribute_map = { - 'id': {'key': 'id', 'type': 'str'}, - 'resource_name': {'key': 'resourceName', 'type': 'str'}, - 'resource_type': {'key': 'resourceType', 'type': 'str'}, + "id": {"key": "id", "type": "str"}, + "resource_name": {"key": "resourceName", "type": "str"}, + "resource_type": {"key": "resourceType", "type": "str"}, } def __init__( self, *, - id: Optional[str] = None, + id: Optional[str] = None, # pylint: disable=redefined-builtin resource_name: Optional[str] = None, resource_type: Optional[str] = None, **kwargs @@ -3427,13 +3239,13 @@ def __init__( :keyword resource_type: The type of the resource. :paramtype resource_type: str """ - super(TargetResource, self).__init__(**kwargs) + super().__init__(**kwargs) self.id = id self.resource_name = resource_name self.resource_type = resource_type -class TemplateHashResult(msrest.serialization.Model): +class TemplateHashResult(_serialization.Model): """Result of the request to calculate template hash. It contains a string of minified template and its hash. :ivar minified_template: The minified template string. @@ -3443,29 +3255,23 @@ class TemplateHashResult(msrest.serialization.Model): """ _attribute_map = { - 'minified_template': {'key': 'minifiedTemplate', 'type': 'str'}, - 'template_hash': {'key': 'templateHash', 'type': 'str'}, + "minified_template": {"key": "minifiedTemplate", "type": "str"}, + "template_hash": {"key": "templateHash", "type": "str"}, } - def __init__( - self, - *, - minified_template: Optional[str] = None, - template_hash: Optional[str] = None, - **kwargs - ): + def __init__(self, *, minified_template: Optional[str] = None, template_hash: Optional[str] = None, **kwargs): """ :keyword minified_template: The minified template string. :paramtype minified_template: str :keyword template_hash: The template hash. :paramtype template_hash: str """ - super(TemplateHashResult, self).__init__(**kwargs) + super().__init__(**kwargs) self.minified_template = minified_template self.template_hash = template_hash -class TemplateLink(msrest.serialization.Model): +class TemplateLink(_serialization.Model): """Entity representing the reference to the template. :ivar uri: The URI of the template to deploy. Use either the uri or id property, but not both. @@ -3485,18 +3291,18 @@ class TemplateLink(msrest.serialization.Model): """ _attribute_map = { - 'uri': {'key': 'uri', 'type': 'str'}, - 'id': {'key': 'id', 'type': 'str'}, - 'relative_path': {'key': 'relativePath', 'type': 'str'}, - 'content_version': {'key': 'contentVersion', 'type': 'str'}, - 'query_string': {'key': 'queryString', 'type': 'str'}, + "uri": {"key": "uri", "type": "str"}, + "id": {"key": "id", "type": "str"}, + "relative_path": {"key": "relativePath", "type": "str"}, + "content_version": {"key": "contentVersion", "type": "str"}, + "query_string": {"key": "queryString", "type": "str"}, } def __init__( self, *, uri: Optional[str] = None, - id: Optional[str] = None, + id: Optional[str] = None, # pylint: disable=redefined-builtin relative_path: Optional[str] = None, content_version: Optional[str] = None, query_string: Optional[str] = None, @@ -3520,7 +3326,7 @@ def __init__( templateLink URI. :paramtype query_string: str """ - super(TemplateLink, self).__init__(**kwargs) + super().__init__(**kwargs) self.uri = uri self.id = id self.relative_path = relative_path @@ -3528,69 +3334,69 @@ def __init__( self.query_string = query_string -class WhatIfChange(msrest.serialization.Model): +class WhatIfChange(_serialization.Model): """Information about a single resource change predicted by What-If operation. All required parameters must be populated in order to send to Azure. - :ivar resource_id: Required. Resource ID. + :ivar resource_id: Resource ID. Required. :vartype resource_id: str - :ivar change_type: Required. Type of change that will be made to the resource when the - deployment is executed. Possible values include: "Create", "Delete", "Ignore", "Deploy", - "NoChange", "Modify", "Unsupported". + :ivar change_type: Type of change that will be made to the resource when the deployment is + executed. Required. Known values are: "Create", "Delete", "Ignore", "Deploy", "NoChange", + "Modify", and "Unsupported". :vartype change_type: str or ~azure.mgmt.resource.resources.v2021_04_01.models.ChangeType :ivar unsupported_reason: The explanation about why the resource is unsupported by What-If. :vartype unsupported_reason: str :ivar before: The snapshot of the resource before the deployment is executed. - :vartype before: any + :vartype before: JSON :ivar after: The predicted snapshot of the resource after the deployment is executed. - :vartype after: any + :vartype after: JSON :ivar delta: The predicted changes to resource properties. :vartype delta: list[~azure.mgmt.resource.resources.v2021_04_01.models.WhatIfPropertyChange] """ _validation = { - 'resource_id': {'required': True}, - 'change_type': {'required': True}, + "resource_id": {"required": True}, + "change_type": {"required": True}, } _attribute_map = { - 'resource_id': {'key': 'resourceId', 'type': 'str'}, - 'change_type': {'key': 'changeType', 'type': 'str'}, - 'unsupported_reason': {'key': 'unsupportedReason', 'type': 'str'}, - 'before': {'key': 'before', 'type': 'object'}, - 'after': {'key': 'after', 'type': 'object'}, - 'delta': {'key': 'delta', 'type': '[WhatIfPropertyChange]'}, + "resource_id": {"key": "resourceId", "type": "str"}, + "change_type": {"key": "changeType", "type": "str"}, + "unsupported_reason": {"key": "unsupportedReason", "type": "str"}, + "before": {"key": "before", "type": "object"}, + "after": {"key": "after", "type": "object"}, + "delta": {"key": "delta", "type": "[WhatIfPropertyChange]"}, } def __init__( self, *, resource_id: str, - change_type: Union[str, "ChangeType"], + change_type: Union[str, "_models.ChangeType"], unsupported_reason: Optional[str] = None, - before: Optional[Any] = None, - after: Optional[Any] = None, - delta: Optional[List["WhatIfPropertyChange"]] = None, + before: Optional[JSON] = None, + after: Optional[JSON] = None, + delta: Optional[List["_models.WhatIfPropertyChange"]] = None, **kwargs ): """ - :keyword resource_id: Required. Resource ID. + :keyword resource_id: Resource ID. Required. :paramtype resource_id: str - :keyword change_type: Required. Type of change that will be made to the resource when the - deployment is executed. Possible values include: "Create", "Delete", "Ignore", "Deploy", - "NoChange", "Modify", "Unsupported". + :keyword change_type: Type of change that will be made to the resource when the deployment is + executed. Required. Known values are: "Create", "Delete", "Ignore", "Deploy", "NoChange", + "Modify", and "Unsupported". :paramtype change_type: str or ~azure.mgmt.resource.resources.v2021_04_01.models.ChangeType :keyword unsupported_reason: The explanation about why the resource is unsupported by What-If. :paramtype unsupported_reason: str :keyword before: The snapshot of the resource before the deployment is executed. - :paramtype before: any + :paramtype before: JSON :keyword after: The predicted snapshot of the resource after the deployment is executed. - :paramtype after: any + :paramtype after: JSON :keyword delta: The predicted changes to resource properties. :paramtype delta: list[~azure.mgmt.resource.resources.v2021_04_01.models.WhatIfPropertyChange] """ - super(WhatIfChange, self).__init__(**kwargs) + super().__init__(**kwargs) self.resource_id = resource_id self.change_type = change_type self.unsupported_reason = unsupported_reason @@ -3599,7 +3405,7 @@ def __init__( self.delta = delta -class WhatIfOperationResult(msrest.serialization.Model): +class WhatIfOperationResult(_serialization.Model): """Result of the What-If operation. Contains a list of predicted changes and a URL link to get to the next set of results. :ivar status: Status of the What-If operation. @@ -3611,17 +3417,17 @@ class WhatIfOperationResult(msrest.serialization.Model): """ _attribute_map = { - 'status': {'key': 'status', 'type': 'str'}, - 'error': {'key': 'error', 'type': 'ErrorResponse'}, - 'changes': {'key': 'properties.changes', 'type': '[WhatIfChange]'}, + "status": {"key": "status", "type": "str"}, + "error": {"key": "error", "type": "ErrorResponse"}, + "changes": {"key": "properties.changes", "type": "[WhatIfChange]"}, } def __init__( self, *, status: Optional[str] = None, - error: Optional["ErrorResponse"] = None, - changes: Optional[List["WhatIfChange"]] = None, + error: Optional["_models.ErrorResponse"] = None, + changes: Optional[List["_models.WhatIfChange"]] = None, **kwargs ): """ @@ -3632,70 +3438,70 @@ def __init__( :keyword changes: List of resource changes predicted by What-If operation. :paramtype changes: list[~azure.mgmt.resource.resources.v2021_04_01.models.WhatIfChange] """ - super(WhatIfOperationResult, self).__init__(**kwargs) + super().__init__(**kwargs) self.status = status self.error = error self.changes = changes -class WhatIfPropertyChange(msrest.serialization.Model): +class WhatIfPropertyChange(_serialization.Model): """The predicted change to the resource property. All required parameters must be populated in order to send to Azure. - :ivar path: Required. The path of the property. + :ivar path: The path of the property. Required. :vartype path: str - :ivar property_change_type: Required. The type of property change. Possible values include: - "Create", "Delete", "Modify", "Array", "NoEffect". + :ivar property_change_type: The type of property change. Required. Known values are: "Create", + "Delete", "Modify", "Array", and "NoEffect". :vartype property_change_type: str or ~azure.mgmt.resource.resources.v2021_04_01.models.PropertyChangeType :ivar before: The value of the property before the deployment is executed. - :vartype before: any + :vartype before: JSON :ivar after: The value of the property after the deployment is executed. - :vartype after: any + :vartype after: JSON :ivar children: Nested property changes. :vartype children: list[~azure.mgmt.resource.resources.v2021_04_01.models.WhatIfPropertyChange] """ _validation = { - 'path': {'required': True}, - 'property_change_type': {'required': True}, + "path": {"required": True}, + "property_change_type": {"required": True}, } _attribute_map = { - 'path': {'key': 'path', 'type': 'str'}, - 'property_change_type': {'key': 'propertyChangeType', 'type': 'str'}, - 'before': {'key': 'before', 'type': 'object'}, - 'after': {'key': 'after', 'type': 'object'}, - 'children': {'key': 'children', 'type': '[WhatIfPropertyChange]'}, + "path": {"key": "path", "type": "str"}, + "property_change_type": {"key": "propertyChangeType", "type": "str"}, + "before": {"key": "before", "type": "object"}, + "after": {"key": "after", "type": "object"}, + "children": {"key": "children", "type": "[WhatIfPropertyChange]"}, } def __init__( self, *, path: str, - property_change_type: Union[str, "PropertyChangeType"], - before: Optional[Any] = None, - after: Optional[Any] = None, - children: Optional[List["WhatIfPropertyChange"]] = None, + property_change_type: Union[str, "_models.PropertyChangeType"], + before: Optional[JSON] = None, + after: Optional[JSON] = None, + children: Optional[List["_models.WhatIfPropertyChange"]] = None, **kwargs ): """ - :keyword path: Required. The path of the property. + :keyword path: The path of the property. Required. :paramtype path: str - :keyword property_change_type: Required. The type of property change. Possible values include: - "Create", "Delete", "Modify", "Array", "NoEffect". + :keyword property_change_type: The type of property change. Required. Known values are: + "Create", "Delete", "Modify", "Array", and "NoEffect". :paramtype property_change_type: str or ~azure.mgmt.resource.resources.v2021_04_01.models.PropertyChangeType :keyword before: The value of the property before the deployment is executed. - :paramtype before: any + :paramtype before: JSON :keyword after: The value of the property after the deployment is executed. - :paramtype after: any + :paramtype after: JSON :keyword children: Nested property changes. :paramtype children: list[~azure.mgmt.resource.resources.v2021_04_01.models.WhatIfPropertyChange] """ - super(WhatIfPropertyChange, self).__init__(**kwargs) + super().__init__(**kwargs) self.path = path self.property_change_type = property_change_type self.before = before @@ -3703,7 +3509,7 @@ def __init__( self.children = children -class ZoneMapping(msrest.serialization.Model): +class ZoneMapping(_serialization.Model): """ZoneMapping. :ivar location: The location of the zone mapping. @@ -3713,23 +3519,17 @@ class ZoneMapping(msrest.serialization.Model): """ _attribute_map = { - 'location': {'key': 'location', 'type': 'str'}, - 'zones': {'key': 'zones', 'type': '[str]'}, + "location": {"key": "location", "type": "str"}, + "zones": {"key": "zones", "type": "[str]"}, } - def __init__( - self, - *, - location: Optional[str] = None, - zones: Optional[List[str]] = None, - **kwargs - ): + def __init__(self, *, location: Optional[str] = None, zones: Optional[List[str]] = None, **kwargs): """ :keyword location: The location of the zone mapping. :paramtype location: str :keyword zones: :paramtype zones: list[str] """ - super(ZoneMapping, self).__init__(**kwargs) + super().__init__(**kwargs) self.location = location self.zones = zones diff --git a/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/resources/v2021_04_01/models/_patch.py b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/resources/v2021_04_01/models/_patch.py new file mode 100644 index 0000000000000..f7dd32510333d --- /dev/null +++ b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/resources/v2021_04_01/models/_patch.py @@ -0,0 +1,20 @@ +# ------------------------------------ +# Copyright (c) Microsoft Corporation. +# Licensed under the MIT License. +# ------------------------------------ +"""Customize generated code here. + +Follow our quickstart for examples: https://aka.ms/azsdk/python/dpcodegen/python/customize +""" +from typing import List + +__all__: List[str] = [] # Add all objects you want publicly available to users at this package level + + +def patch_sdk(): + """Do not remove from this file. + + `patch_sdk` is a last resort escape hatch that allows you to do customizations + you can't accomplish using the techniques described in + https://aka.ms/azsdk/python/dpcodegen/python/customize + """ diff --git a/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/resources/v2021_04_01/models/_resource_management_client_enums.py b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/resources/v2021_04_01/models/_resource_management_client_enums.py index c04261605d14e..2778267e7da43 100644 --- a/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/resources/v2021_04_01/models/_resource_management_client_enums.py +++ b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/resources/v2021_04_01/models/_resource_management_client_enums.py @@ -7,22 +7,20 @@ # -------------------------------------------------------------------------- from enum import Enum -from six import with_metaclass from azure.core import CaseInsensitiveEnumMeta -class AliasPathAttributes(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): - """The attributes of the token that the alias path is referring to. - """ +class AliasPathAttributes(str, Enum, metaclass=CaseInsensitiveEnumMeta): + """The attributes of the token that the alias path is referring to.""" #: The token that the alias path is referring to has no attributes. NONE = "None" #: The token that the alias path is referring to is modifiable by policies with 'modify' effect. MODIFIABLE = "Modifiable" -class AliasPathTokenType(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): - """The type of the token that the alias path is referring to. - """ + +class AliasPathTokenType(str, Enum, metaclass=CaseInsensitiveEnumMeta): + """The type of the token that the alias path is referring to.""" #: The token type is not specified. NOT_SPECIFIED = "NotSpecified" @@ -41,18 +39,18 @@ class AliasPathTokenType(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): #: The token type is boolean. BOOLEAN = "Boolean" -class AliasPatternType(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): - """The type of alias pattern - """ + +class AliasPatternType(str, Enum, metaclass=CaseInsensitiveEnumMeta): + """The type of alias pattern.""" #: NotSpecified is not allowed. NOT_SPECIFIED = "NotSpecified" #: Extract is the only allowed value. EXTRACT = "Extract" -class AliasType(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): - """The type of the alias. - """ + +class AliasType(str, Enum, metaclass=CaseInsensitiveEnumMeta): + """The type of the alias.""" #: Alias type is unknown (same as not providing alias type). NOT_SPECIFIED = "NotSpecified" @@ -61,9 +59,9 @@ class AliasType(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): #: Alias value is secret. MASK = "Mask" -class ChangeType(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): - """Type of change that will be made to the resource when the deployment is executed. - """ + +class ChangeType(str, Enum, metaclass=CaseInsensitiveEnumMeta): + """Type of change that will be made to the resource when the deployment is executed.""" #: The resource does not exist in the current state but is present in the desired state. The #: resource will be created when the deployment is executed. @@ -86,7 +84,8 @@ class ChangeType(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): #: The resource is not supported by What-If. UNSUPPORTED = "Unsupported" -class DeploymentMode(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): + +class DeploymentMode(str, Enum, metaclass=CaseInsensitiveEnumMeta): """The mode that is used to deploy resources. This value can be either Incremental or Complete. In Incremental mode, resources are deployed without deleting existing resources that are not included in the template. In Complete mode, resources are deployed and existing resources in @@ -97,7 +96,8 @@ class DeploymentMode(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): INCREMENTAL = "Incremental" COMPLETE = "Complete" -class ExpressionEvaluationOptionsScopeType(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): + +class ExpressionEvaluationOptionsScopeType(str, Enum, metaclass=CaseInsensitiveEnumMeta): """The scope to be used for evaluation of parameters, variables and functions in a nested template. """ @@ -106,13 +106,14 @@ class ExpressionEvaluationOptionsScopeType(with_metaclass(CaseInsensitiveEnumMet OUTER = "Outer" INNER = "Inner" -class ExtendedLocationType(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): - """The extended location type. - """ + +class ExtendedLocationType(str, Enum, metaclass=CaseInsensitiveEnumMeta): + """The extended location type.""" EDGE_ZONE = "EdgeZone" -class OnErrorDeploymentType(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): + +class OnErrorDeploymentType(str, Enum, metaclass=CaseInsensitiveEnumMeta): """The deployment on error behavior type. Possible values are LastSuccessful and SpecificDeployment. """ @@ -120,9 +121,9 @@ class OnErrorDeploymentType(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): LAST_SUCCESSFUL = "LastSuccessful" SPECIFIC_DEPLOYMENT = "SpecificDeployment" -class PropertyChangeType(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): - """The type of property change. - """ + +class PropertyChangeType(str, Enum, metaclass=CaseInsensitiveEnumMeta): + """The type of property change.""" #: The property does not exist in the current state but is present in the desired state. The #: property will be created when the deployment is executed. @@ -138,18 +139,18 @@ class PropertyChangeType(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): #: The property will not be set or updated. NO_EFFECT = "NoEffect" -class ProviderAuthorizationConsentState(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): - """The provider authorization consent state. - """ + +class ProviderAuthorizationConsentState(str, Enum, metaclass=CaseInsensitiveEnumMeta): + """The provider authorization consent state.""" NOT_SPECIFIED = "NotSpecified" REQUIRED = "Required" NOT_REQUIRED = "NotRequired" CONSENTED = "Consented" -class ProvisioningOperation(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): - """The name of the current provisioning operation. - """ + +class ProvisioningOperation(str, Enum, metaclass=CaseInsensitiveEnumMeta): + """The name of the current provisioning operation.""" #: The provisioning operation is not specified. NOT_SPECIFIED = "NotSpecified" @@ -173,9 +174,9 @@ class ProvisioningOperation(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): #: deployment. DEPLOYMENT_CLEANUP = "DeploymentCleanup" -class ProvisioningState(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): - """Denotes the state of provisioning. - """ + +class ProvisioningState(str, Enum, metaclass=CaseInsensitiveEnumMeta): + """Denotes the state of provisioning.""" NOT_SPECIFIED = "NotSpecified" ACCEPTED = "Accepted" @@ -190,18 +191,18 @@ class ProvisioningState(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): SUCCEEDED = "Succeeded" UPDATING = "Updating" -class ResourceIdentityType(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): - """The identity type. - """ + +class ResourceIdentityType(str, Enum, metaclass=CaseInsensitiveEnumMeta): + """The identity type.""" SYSTEM_ASSIGNED = "SystemAssigned" USER_ASSIGNED = "UserAssigned" SYSTEM_ASSIGNED_USER_ASSIGNED = "SystemAssigned, UserAssigned" NONE = "None" -class TagsPatchOperation(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): - """The operation type for the patch API. - """ + +class TagsPatchOperation(str, Enum, metaclass=CaseInsensitiveEnumMeta): + """The operation type for the patch API.""" #: The 'replace' option replaces the entire set of existing tags with a new set. REPLACE = "Replace" @@ -211,9 +212,9 @@ class TagsPatchOperation(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): #: The 'delete' option allows selectively deleting tags based on given names or name/value pairs. DELETE = "Delete" -class WhatIfResultFormat(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): - """The format of the What-If results - """ + +class WhatIfResultFormat(str, Enum, metaclass=CaseInsensitiveEnumMeta): + """The format of the What-If results.""" RESOURCE_ID_ONLY = "ResourceIdOnly" FULL_RESOURCE_PAYLOADS = "FullResourcePayloads" diff --git a/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/resources/v2021_04_01/operations/__init__.py b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/resources/v2021_04_01/operations/__init__.py index f1487609817b6..9e5620e4d286c 100644 --- a/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/resources/v2021_04_01/operations/__init__.py +++ b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/resources/v2021_04_01/operations/__init__.py @@ -15,13 +15,19 @@ from ._operations import TagsOperations from ._operations import DeploymentOperationsOperations +from ._patch import __all__ as _patch_all +from ._patch import * # type: ignore # pylint: disable=unused-wildcard-import +from ._patch import patch_sdk as _patch_sdk + __all__ = [ - 'Operations', - 'DeploymentsOperations', - 'ProvidersOperations', - 'ProviderResourceTypesOperations', - 'ResourcesOperations', - 'ResourceGroupsOperations', - 'TagsOperations', - 'DeploymentOperationsOperations', + "Operations", + "DeploymentsOperations", + "ProvidersOperations", + "ProviderResourceTypesOperations", + "ResourcesOperations", + "ResourceGroupsOperations", + "TagsOperations", + "DeploymentOperationsOperations", ] +__all__.extend([p for p in _patch_all if p not in __all__]) +_patch_sdk() diff --git a/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/resources/v2021_04_01/operations/_operations.py b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/resources/v2021_04_01/operations/_operations.py index 08c0ef50dd842..7aba2e4725e82 100644 --- a/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/resources/v2021_04_01/operations/_operations.py +++ b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/resources/v2021_04_01/operations/_operations.py @@ -6,1641 +6,1408 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -from typing import Any, Callable, Dict, Iterable, Optional, TypeVar, Union - -from msrest import Serializer - -from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error +import sys +from typing import Any, Callable, Dict, IO, Iterable, Optional, TypeVar, Union, cast, overload +from urllib.parse import parse_qs, urljoin, urlparse + +from azure.core.exceptions import ( + ClientAuthenticationError, + HttpResponseError, + ResourceExistsError, + ResourceNotFoundError, + ResourceNotModifiedError, + map_error, +) from azure.core.paging import ItemPaged from azure.core.pipeline import PipelineResponse from azure.core.pipeline.transport import HttpResponse from azure.core.polling import LROPoller, NoPolling, PollingMethod from azure.core.rest import HttpRequest from azure.core.tracing.decorator import distributed_trace +from azure.core.utils import case_insensitive_dict from azure.mgmt.core.exceptions import ARMErrorFormat from azure.mgmt.core.polling.arm_polling import ARMPolling from .. import models as _models +from ..._serialization import Serializer from .._vendor import _convert_request, _format_url_section -T = TypeVar('T') + +T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] -JSONType = Any +if sys.version_info >= (3, 9): + from collections.abc import MutableMapping +else: + from typing import MutableMapping # type: ignore # pylint: disable=ungrouped-imports +JSON = MutableMapping[str, Any] # pylint: disable=unsubscriptable-object _SERIALIZER = Serializer() _SERIALIZER.client_side_validation = False -def build_operations_list_request( - **kwargs: Any -) -> HttpRequest: - api_version = kwargs.pop('api_version', "2021-04-01") # type: str - accept = "application/json" +def build_operations_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-04-01")) # type: str + accept = _headers.pop("Accept", "application/json") + # Construct URL _url = kwargs.pop("template_url", "/providers/Microsoft.Resources/operations") # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') - - return HttpRequest( - method="GET", - url=_url, - params=_query_parameters, - headers=_header_parameters, - **kwargs - ) + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) -def build_deployments_delete_at_scope_request_initial( - scope: str, - deployment_name: str, - **kwargs: Any -) -> HttpRequest: - api_version = kwargs.pop('api_version', "2021-04-01") # type: str - accept = "application/json" +def build_deployments_delete_at_scope_request(scope: str, deployment_name: 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-04-01")) # type: str + accept = _headers.pop("Accept", "application/json") + # Construct URL _url = kwargs.pop("template_url", "/{scope}/providers/Microsoft.Resources/deployments/{deploymentName}") path_format_arguments = { - "scope": _SERIALIZER.url("scope", scope, 'str', skip_quote=True), - "deploymentName": _SERIALIZER.url("deployment_name", deployment_name, 'str', max_length=64, min_length=1, pattern=r'^[-\w\._\(\)]+$'), + "scope": _SERIALIZER.url("scope", scope, "str", skip_quote=True), + "deploymentName": _SERIALIZER.url( + "deployment_name", deployment_name, "str", max_length=64, min_length=1, pattern=r"^[-\w\._\(\)]+$" + ), } _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') - - return HttpRequest( - method="DELETE", - url=_url, - params=_query_parameters, - headers=_header_parameters, - **kwargs - ) + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + return HttpRequest(method="DELETE", url=_url, params=_params, headers=_headers, **kwargs) -def build_deployments_check_existence_at_scope_request( - scope: str, - deployment_name: str, - **kwargs: Any -) -> HttpRequest: - api_version = kwargs.pop('api_version', "2021-04-01") # type: str - accept = "application/json" +def build_deployments_check_existence_at_scope_request(scope: str, deployment_name: 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-04-01")) # type: str + accept = _headers.pop("Accept", "application/json") + # Construct URL _url = kwargs.pop("template_url", "/{scope}/providers/Microsoft.Resources/deployments/{deploymentName}") path_format_arguments = { - "scope": _SERIALIZER.url("scope", scope, 'str', skip_quote=True), - "deploymentName": _SERIALIZER.url("deployment_name", deployment_name, 'str', max_length=64, min_length=1, pattern=r'^[-\w\._\(\)]+$'), + "scope": _SERIALIZER.url("scope", scope, "str", skip_quote=True), + "deploymentName": _SERIALIZER.url( + "deployment_name", deployment_name, "str", max_length=64, min_length=1, pattern=r"^[-\w\._\(\)]+$" + ), } _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') - - return HttpRequest( - method="HEAD", - url=_url, - params=_query_parameters, - headers=_header_parameters, - **kwargs - ) + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + return HttpRequest(method="HEAD", url=_url, params=_params, headers=_headers, **kwargs) -def build_deployments_create_or_update_at_scope_request_initial( - scope: str, - deployment_name: str, - *, - json: JSONType = None, - content: Any = None, - **kwargs: Any -) -> HttpRequest: - api_version = kwargs.pop('api_version', "2021-04-01") # type: str - content_type = kwargs.pop('content_type', None) # type: Optional[str] - accept = "application/json" +def build_deployments_create_or_update_at_scope_request(scope: str, deployment_name: 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-04-01")) # type: str + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + accept = _headers.pop("Accept", "application/json") + # Construct URL _url = kwargs.pop("template_url", "/{scope}/providers/Microsoft.Resources/deployments/{deploymentName}") path_format_arguments = { - "scope": _SERIALIZER.url("scope", scope, 'str', skip_quote=True), - "deploymentName": _SERIALIZER.url("deployment_name", deployment_name, 'str', max_length=64, min_length=1, pattern=r'^[-\w\._\(\)]+$'), + "scope": _SERIALIZER.url("scope", scope, "str", skip_quote=True), + "deploymentName": _SERIALIZER.url( + "deployment_name", deployment_name, "str", max_length=64, min_length=1, pattern=r"^[-\w\._\(\)]+$" + ), } _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] if content_type is not None: - _header_parameters['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') - _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') - - return HttpRequest( - method="PUT", - url=_url, - params=_query_parameters, - headers=_header_parameters, - json=json, - content=content, - **kwargs - ) + _headers["Content-Type"] = _SERIALIZER.header("content_type", content_type, "str") + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + return HttpRequest(method="PUT", url=_url, params=_params, headers=_headers, **kwargs) -def build_deployments_get_at_scope_request( - scope: str, - deployment_name: str, - **kwargs: Any -) -> HttpRequest: - api_version = kwargs.pop('api_version', "2021-04-01") # type: str - accept = "application/json" +def build_deployments_get_at_scope_request(scope: str, deployment_name: 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-04-01")) # type: str + accept = _headers.pop("Accept", "application/json") + # Construct URL _url = kwargs.pop("template_url", "/{scope}/providers/Microsoft.Resources/deployments/{deploymentName}") path_format_arguments = { - "scope": _SERIALIZER.url("scope", scope, 'str', skip_quote=True), - "deploymentName": _SERIALIZER.url("deployment_name", deployment_name, 'str', max_length=64, min_length=1, pattern=r'^[-\w\._\(\)]+$'), + "scope": _SERIALIZER.url("scope", scope, "str", skip_quote=True), + "deploymentName": _SERIALIZER.url( + "deployment_name", deployment_name, "str", max_length=64, min_length=1, pattern=r"^[-\w\._\(\)]+$" + ), } _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') - - return HttpRequest( - method="GET", - url=_url, - params=_query_parameters, - headers=_header_parameters, - **kwargs - ) + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) -def build_deployments_cancel_at_scope_request( - scope: str, - deployment_name: str, - **kwargs: Any -) -> HttpRequest: - api_version = kwargs.pop('api_version', "2021-04-01") # type: str - accept = "application/json" +def build_deployments_cancel_at_scope_request(scope: str, deployment_name: 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-04-01")) # type: str + accept = _headers.pop("Accept", "application/json") + # Construct URL _url = kwargs.pop("template_url", "/{scope}/providers/Microsoft.Resources/deployments/{deploymentName}/cancel") path_format_arguments = { - "scope": _SERIALIZER.url("scope", scope, 'str', skip_quote=True), - "deploymentName": _SERIALIZER.url("deployment_name", deployment_name, 'str', max_length=64, min_length=1, pattern=r'^[-\w\._\(\)]+$'), + "scope": _SERIALIZER.url("scope", scope, "str", skip_quote=True), + "deploymentName": _SERIALIZER.url( + "deployment_name", deployment_name, "str", max_length=64, min_length=1, pattern=r"^[-\w\._\(\)]+$" + ), } _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') - - return HttpRequest( - method="POST", - url=_url, - params=_query_parameters, - headers=_header_parameters, - **kwargs - ) + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + return HttpRequest(method="POST", url=_url, params=_params, headers=_headers, **kwargs) -def build_deployments_validate_at_scope_request_initial( - scope: str, - deployment_name: str, - *, - json: JSONType = None, - content: Any = None, - **kwargs: Any -) -> HttpRequest: - api_version = kwargs.pop('api_version', "2021-04-01") # type: str - content_type = kwargs.pop('content_type', None) # type: Optional[str] - accept = "application/json" +def build_deployments_validate_at_scope_request(scope: str, deployment_name: 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-04-01")) # type: str + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + accept = _headers.pop("Accept", "application/json") + # Construct URL _url = kwargs.pop("template_url", "/{scope}/providers/Microsoft.Resources/deployments/{deploymentName}/validate") path_format_arguments = { - "scope": _SERIALIZER.url("scope", scope, 'str', skip_quote=True), - "deploymentName": _SERIALIZER.url("deployment_name", deployment_name, 'str', max_length=64, min_length=1, pattern=r'^[-\w\._\(\)]+$'), + "scope": _SERIALIZER.url("scope", scope, "str", skip_quote=True), + "deploymentName": _SERIALIZER.url( + "deployment_name", deployment_name, "str", max_length=64, min_length=1, pattern=r"^[-\w\._\(\)]+$" + ), } _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] if content_type is not None: - _header_parameters['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') - _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') - - return HttpRequest( - method="POST", - url=_url, - params=_query_parameters, - headers=_header_parameters, - json=json, - content=content, - **kwargs - ) + _headers["Content-Type"] = _SERIALIZER.header("content_type", content_type, "str") + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + return HttpRequest(method="POST", url=_url, params=_params, headers=_headers, **kwargs) -def build_deployments_export_template_at_scope_request( - scope: str, - deployment_name: str, - **kwargs: Any -) -> HttpRequest: - api_version = kwargs.pop('api_version', "2021-04-01") # type: str - accept = "application/json" +def build_deployments_export_template_at_scope_request(scope: str, deployment_name: 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-04-01")) # type: str + accept = _headers.pop("Accept", "application/json") + # Construct URL - _url = kwargs.pop("template_url", "/{scope}/providers/Microsoft.Resources/deployments/{deploymentName}/exportTemplate") + _url = kwargs.pop( + "template_url", "/{scope}/providers/Microsoft.Resources/deployments/{deploymentName}/exportTemplate" + ) path_format_arguments = { - "scope": _SERIALIZER.url("scope", scope, 'str', skip_quote=True), - "deploymentName": _SERIALIZER.url("deployment_name", deployment_name, 'str', max_length=64, min_length=1, pattern=r'^[-\w\._\(\)]+$'), + "scope": _SERIALIZER.url("scope", scope, "str", skip_quote=True), + "deploymentName": _SERIALIZER.url( + "deployment_name", deployment_name, "str", max_length=64, min_length=1, pattern=r"^[-\w\._\(\)]+$" + ), } _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') - - return HttpRequest( - method="POST", - url=_url, - params=_query_parameters, - headers=_header_parameters, - **kwargs - ) + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="POST", url=_url, params=_params, headers=_headers, **kwargs) def build_deployments_list_at_scope_request( - scope: str, - *, - filter: Optional[str] = None, - top: Optional[int] = None, - **kwargs: Any + scope: str, *, filter: Optional[str] = None, top: Optional[int] = None, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2021-04-01") # type: 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-04-01")) # type: str + accept = _headers.pop("Accept", "application/json") - accept = "application/json" # Construct URL _url = kwargs.pop("template_url", "/{scope}/providers/Microsoft.Resources/deployments/") path_format_arguments = { - "scope": _SERIALIZER.url("scope", scope, 'str', skip_quote=True), + "scope": _SERIALIZER.url("scope", scope, "str", skip_quote=True), } _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] if filter is not None: - _query_parameters['$filter'] = _SERIALIZER.query("filter", filter, 'str') + _params["$filter"] = _SERIALIZER.query("filter", filter, "str") if top is not None: - _query_parameters['$top'] = _SERIALIZER.query("top", top, 'int') - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["$top"] = _SERIALIZER.query("top", top, "int") + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') - - return HttpRequest( - method="GET", - url=_url, - params=_query_parameters, - headers=_header_parameters, - **kwargs - ) + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) -def build_deployments_delete_at_tenant_scope_request_initial( - deployment_name: str, - **kwargs: Any -) -> HttpRequest: - api_version = kwargs.pop('api_version', "2021-04-01") # type: str - accept = "application/json" +def build_deployments_delete_at_tenant_scope_request(deployment_name: 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-04-01")) # type: str + accept = _headers.pop("Accept", "application/json") + # Construct URL _url = kwargs.pop("template_url", "/providers/Microsoft.Resources/deployments/{deploymentName}") path_format_arguments = { - "deploymentName": _SERIALIZER.url("deployment_name", deployment_name, 'str', max_length=64, min_length=1, pattern=r'^[-\w\._\(\)]+$'), + "deploymentName": _SERIALIZER.url( + "deployment_name", deployment_name, "str", max_length=64, min_length=1, pattern=r"^[-\w\._\(\)]+$" + ), } _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') - - return HttpRequest( - method="DELETE", - url=_url, - params=_query_parameters, - headers=_header_parameters, - **kwargs - ) + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + return HttpRequest(method="DELETE", url=_url, params=_params, headers=_headers, **kwargs) -def build_deployments_check_existence_at_tenant_scope_request( - deployment_name: str, - **kwargs: Any -) -> HttpRequest: - api_version = kwargs.pop('api_version', "2021-04-01") # type: str - accept = "application/json" +def build_deployments_check_existence_at_tenant_scope_request(deployment_name: 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-04-01")) # type: str + accept = _headers.pop("Accept", "application/json") + # Construct URL _url = kwargs.pop("template_url", "/providers/Microsoft.Resources/deployments/{deploymentName}") path_format_arguments = { - "deploymentName": _SERIALIZER.url("deployment_name", deployment_name, 'str', max_length=64, min_length=1, pattern=r'^[-\w\._\(\)]+$'), + "deploymentName": _SERIALIZER.url( + "deployment_name", deployment_name, "str", max_length=64, min_length=1, pattern=r"^[-\w\._\(\)]+$" + ), } _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') - - return HttpRequest( - method="HEAD", - url=_url, - params=_query_parameters, - headers=_header_parameters, - **kwargs - ) + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + return HttpRequest(method="HEAD", url=_url, params=_params, headers=_headers, **kwargs) -def build_deployments_create_or_update_at_tenant_scope_request_initial( - deployment_name: str, - *, - json: JSONType = None, - content: Any = None, - **kwargs: Any -) -> HttpRequest: - api_version = kwargs.pop('api_version', "2021-04-01") # type: str - content_type = kwargs.pop('content_type', None) # type: Optional[str] - accept = "application/json" +def build_deployments_create_or_update_at_tenant_scope_request(deployment_name: 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-04-01")) # type: str + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + accept = _headers.pop("Accept", "application/json") + # Construct URL _url = kwargs.pop("template_url", "/providers/Microsoft.Resources/deployments/{deploymentName}") path_format_arguments = { - "deploymentName": _SERIALIZER.url("deployment_name", deployment_name, 'str', max_length=64, min_length=1, pattern=r'^[-\w\._\(\)]+$'), + "deploymentName": _SERIALIZER.url( + "deployment_name", deployment_name, "str", max_length=64, min_length=1, pattern=r"^[-\w\._\(\)]+$" + ), } _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] if content_type is not None: - _header_parameters['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') - _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') - - return HttpRequest( - method="PUT", - url=_url, - params=_query_parameters, - headers=_header_parameters, - json=json, - content=content, - **kwargs - ) + _headers["Content-Type"] = _SERIALIZER.header("content_type", content_type, "str") + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + return HttpRequest(method="PUT", url=_url, params=_params, headers=_headers, **kwargs) -def build_deployments_get_at_tenant_scope_request( - deployment_name: str, - **kwargs: Any -) -> HttpRequest: - api_version = kwargs.pop('api_version', "2021-04-01") # type: str - accept = "application/json" +def build_deployments_get_at_tenant_scope_request(deployment_name: 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-04-01")) # type: str + accept = _headers.pop("Accept", "application/json") + # Construct URL _url = kwargs.pop("template_url", "/providers/Microsoft.Resources/deployments/{deploymentName}") path_format_arguments = { - "deploymentName": _SERIALIZER.url("deployment_name", deployment_name, 'str', max_length=64, min_length=1, pattern=r'^[-\w\._\(\)]+$'), + "deploymentName": _SERIALIZER.url( + "deployment_name", deployment_name, "str", max_length=64, min_length=1, pattern=r"^[-\w\._\(\)]+$" + ), } _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') - - return HttpRequest( - method="GET", - url=_url, - params=_query_parameters, - headers=_header_parameters, - **kwargs - ) + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) -def build_deployments_cancel_at_tenant_scope_request( - deployment_name: str, - **kwargs: Any -) -> HttpRequest: - api_version = kwargs.pop('api_version', "2021-04-01") # type: str - accept = "application/json" +def build_deployments_cancel_at_tenant_scope_request(deployment_name: 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-04-01")) # type: str + accept = _headers.pop("Accept", "application/json") + # Construct URL _url = kwargs.pop("template_url", "/providers/Microsoft.Resources/deployments/{deploymentName}/cancel") path_format_arguments = { - "deploymentName": _SERIALIZER.url("deployment_name", deployment_name, 'str', max_length=64, min_length=1, pattern=r'^[-\w\._\(\)]+$'), + "deploymentName": _SERIALIZER.url( + "deployment_name", deployment_name, "str", max_length=64, min_length=1, pattern=r"^[-\w\._\(\)]+$" + ), } _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') - - return HttpRequest( - method="POST", - url=_url, - params=_query_parameters, - headers=_header_parameters, - **kwargs - ) + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + return HttpRequest(method="POST", url=_url, params=_params, headers=_headers, **kwargs) -def build_deployments_validate_at_tenant_scope_request_initial( - deployment_name: str, - *, - json: JSONType = None, - content: Any = None, - **kwargs: Any -) -> HttpRequest: - api_version = kwargs.pop('api_version', "2021-04-01") # type: str - content_type = kwargs.pop('content_type', None) # type: Optional[str] - accept = "application/json" +def build_deployments_validate_at_tenant_scope_request(deployment_name: 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-04-01")) # type: str + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + accept = _headers.pop("Accept", "application/json") + # Construct URL _url = kwargs.pop("template_url", "/providers/Microsoft.Resources/deployments/{deploymentName}/validate") path_format_arguments = { - "deploymentName": _SERIALIZER.url("deployment_name", deployment_name, 'str', max_length=64, min_length=1, pattern=r'^[-\w\._\(\)]+$'), + "deploymentName": _SERIALIZER.url( + "deployment_name", deployment_name, "str", max_length=64, min_length=1, pattern=r"^[-\w\._\(\)]+$" + ), } _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] if content_type is not None: - _header_parameters['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') - _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') - - return HttpRequest( - method="POST", - url=_url, - params=_query_parameters, - headers=_header_parameters, - json=json, - content=content, - **kwargs - ) + _headers["Content-Type"] = _SERIALIZER.header("content_type", content_type, "str") + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + return HttpRequest(method="POST", url=_url, params=_params, headers=_headers, **kwargs) -def build_deployments_what_if_at_tenant_scope_request_initial( - deployment_name: str, - *, - json: JSONType = None, - content: Any = None, - **kwargs: Any -) -> HttpRequest: - api_version = kwargs.pop('api_version', "2021-04-01") # type: str - content_type = kwargs.pop('content_type', None) # type: Optional[str] - accept = "application/json" +def build_deployments_what_if_at_tenant_scope_request(deployment_name: 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-04-01")) # type: str + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + accept = _headers.pop("Accept", "application/json") + # Construct URL _url = kwargs.pop("template_url", "/providers/Microsoft.Resources/deployments/{deploymentName}/whatIf") path_format_arguments = { - "deploymentName": _SERIALIZER.url("deployment_name", deployment_name, 'str', max_length=64, min_length=1, pattern=r'^[-\w\._\(\)]+$'), + "deploymentName": _SERIALIZER.url( + "deployment_name", deployment_name, "str", max_length=64, min_length=1, pattern=r"^[-\w\._\(\)]+$" + ), } _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] if content_type is not None: - _header_parameters['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') - _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') - - return HttpRequest( - method="POST", - url=_url, - params=_query_parameters, - headers=_header_parameters, - json=json, - content=content, - **kwargs - ) + _headers["Content-Type"] = _SERIALIZER.header("content_type", content_type, "str") + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + return HttpRequest(method="POST", url=_url, params=_params, headers=_headers, **kwargs) -def build_deployments_export_template_at_tenant_scope_request( - deployment_name: str, - **kwargs: Any -) -> HttpRequest: - api_version = kwargs.pop('api_version', "2021-04-01") # type: str - accept = "application/json" +def build_deployments_export_template_at_tenant_scope_request(deployment_name: 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-04-01")) # type: str + accept = _headers.pop("Accept", "application/json") + # Construct URL _url = kwargs.pop("template_url", "/providers/Microsoft.Resources/deployments/{deploymentName}/exportTemplate") path_format_arguments = { - "deploymentName": _SERIALIZER.url("deployment_name", deployment_name, 'str', max_length=64, min_length=1, pattern=r'^[-\w\._\(\)]+$'), + "deploymentName": _SERIALIZER.url( + "deployment_name", deployment_name, "str", max_length=64, min_length=1, pattern=r"^[-\w\._\(\)]+$" + ), } _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') - - return HttpRequest( - method="POST", - url=_url, - params=_query_parameters, - headers=_header_parameters, - **kwargs - ) + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="POST", url=_url, params=_params, headers=_headers, **kwargs) def build_deployments_list_at_tenant_scope_request( - *, - filter: Optional[str] = None, - top: Optional[int] = None, - **kwargs: Any + *, filter: Optional[str] = None, top: Optional[int] = None, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2021-04-01") # type: 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-04-01")) # type: str + accept = _headers.pop("Accept", "application/json") - accept = "application/json" # Construct URL _url = kwargs.pop("template_url", "/providers/Microsoft.Resources/deployments/") # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] if filter is not None: - _query_parameters['$filter'] = _SERIALIZER.query("filter", filter, 'str') + _params["$filter"] = _SERIALIZER.query("filter", filter, "str") if top is not None: - _query_parameters['$top'] = _SERIALIZER.query("top", top, 'int') - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["$top"] = _SERIALIZER.query("top", top, "int") + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') - - return HttpRequest( - method="GET", - url=_url, - params=_query_parameters, - headers=_header_parameters, - **kwargs - ) + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) -def build_deployments_delete_at_management_group_scope_request_initial( - group_id: str, - deployment_name: str, - **kwargs: Any + +def build_deployments_delete_at_management_group_scope_request( + group_id: str, deployment_name: str, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2021-04-01") # type: 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-04-01")) # type: str + accept = _headers.pop("Accept", "application/json") - accept = "application/json" # Construct URL - _url = kwargs.pop("template_url", "/providers/Microsoft.Management/managementGroups/{groupId}/providers/Microsoft.Resources/deployments/{deploymentName}") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", + "/providers/Microsoft.Management/managementGroups/{groupId}/providers/Microsoft.Resources/deployments/{deploymentName}", + ) # pylint: disable=line-too-long path_format_arguments = { - "groupId": _SERIALIZER.url("group_id", group_id, 'str', max_length=90, min_length=1), - "deploymentName": _SERIALIZER.url("deployment_name", deployment_name, 'str', max_length=64, min_length=1, pattern=r'^[-\w\._\(\)]+$'), + "groupId": _SERIALIZER.url("group_id", group_id, "str", max_length=90, min_length=1), + "deploymentName": _SERIALIZER.url( + "deployment_name", deployment_name, "str", max_length=64, min_length=1, pattern=r"^[-\w\._\(\)]+$" + ), } _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') - - return HttpRequest( - method="DELETE", - url=_url, - params=_query_parameters, - headers=_header_parameters, - **kwargs - ) + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="DELETE", url=_url, params=_params, headers=_headers, **kwargs) def build_deployments_check_existence_at_management_group_scope_request( - group_id: str, - deployment_name: str, - **kwargs: Any + group_id: str, deployment_name: str, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2021-04-01") # type: 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-04-01")) # type: str + accept = _headers.pop("Accept", "application/json") - accept = "application/json" # Construct URL - _url = kwargs.pop("template_url", "/providers/Microsoft.Management/managementGroups/{groupId}/providers/Microsoft.Resources/deployments/{deploymentName}") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", + "/providers/Microsoft.Management/managementGroups/{groupId}/providers/Microsoft.Resources/deployments/{deploymentName}", + ) # pylint: disable=line-too-long path_format_arguments = { - "groupId": _SERIALIZER.url("group_id", group_id, 'str', max_length=90, min_length=1), - "deploymentName": _SERIALIZER.url("deployment_name", deployment_name, 'str', max_length=64, min_length=1, pattern=r'^[-\w\._\(\)]+$'), + "groupId": _SERIALIZER.url("group_id", group_id, "str", max_length=90, min_length=1), + "deploymentName": _SERIALIZER.url( + "deployment_name", deployment_name, "str", max_length=64, min_length=1, pattern=r"^[-\w\._\(\)]+$" + ), } _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') - - return HttpRequest( - method="HEAD", - url=_url, - params=_query_parameters, - headers=_header_parameters, - **kwargs - ) + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + return HttpRequest(method="HEAD", url=_url, params=_params, headers=_headers, **kwargs) -def build_deployments_create_or_update_at_management_group_scope_request_initial( - group_id: str, - deployment_name: str, - *, - json: JSONType = None, - content: Any = None, - **kwargs: Any + +def build_deployments_create_or_update_at_management_group_scope_request( + group_id: str, deployment_name: str, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2021-04-01") # type: str - content_type = kwargs.pop('content_type', None) # type: Optional[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-04-01")) # type: str + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + accept = _headers.pop("Accept", "application/json") - accept = "application/json" # Construct URL - _url = kwargs.pop("template_url", "/providers/Microsoft.Management/managementGroups/{groupId}/providers/Microsoft.Resources/deployments/{deploymentName}") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", + "/providers/Microsoft.Management/managementGroups/{groupId}/providers/Microsoft.Resources/deployments/{deploymentName}", + ) # pylint: disable=line-too-long path_format_arguments = { - "groupId": _SERIALIZER.url("group_id", group_id, 'str', max_length=90, min_length=1), - "deploymentName": _SERIALIZER.url("deployment_name", deployment_name, 'str', max_length=64, min_length=1, pattern=r'^[-\w\._\(\)]+$'), + "groupId": _SERIALIZER.url("group_id", group_id, "str", max_length=90, min_length=1), + "deploymentName": _SERIALIZER.url( + "deployment_name", deployment_name, "str", max_length=64, min_length=1, pattern=r"^[-\w\._\(\)]+$" + ), } _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] if content_type is not None: - _header_parameters['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') - _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') - - return HttpRequest( - method="PUT", - url=_url, - params=_query_parameters, - headers=_header_parameters, - json=json, - content=content, - **kwargs - ) + _headers["Content-Type"] = _SERIALIZER.header("content_type", content_type, "str") + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="PUT", url=_url, params=_params, headers=_headers, **kwargs) def build_deployments_get_at_management_group_scope_request( - group_id: str, - deployment_name: str, - **kwargs: Any + group_id: str, deployment_name: str, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2021-04-01") # type: 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-04-01")) # type: str + accept = _headers.pop("Accept", "application/json") - accept = "application/json" # Construct URL - _url = kwargs.pop("template_url", "/providers/Microsoft.Management/managementGroups/{groupId}/providers/Microsoft.Resources/deployments/{deploymentName}") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", + "/providers/Microsoft.Management/managementGroups/{groupId}/providers/Microsoft.Resources/deployments/{deploymentName}", + ) # pylint: disable=line-too-long path_format_arguments = { - "groupId": _SERIALIZER.url("group_id", group_id, 'str', max_length=90, min_length=1), - "deploymentName": _SERIALIZER.url("deployment_name", deployment_name, 'str', max_length=64, min_length=1, pattern=r'^[-\w\._\(\)]+$'), + "groupId": _SERIALIZER.url("group_id", group_id, "str", max_length=90, min_length=1), + "deploymentName": _SERIALIZER.url( + "deployment_name", deployment_name, "str", max_length=64, min_length=1, pattern=r"^[-\w\._\(\)]+$" + ), } _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') - - return HttpRequest( - method="GET", - url=_url, - params=_query_parameters, - headers=_header_parameters, - **kwargs - ) + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) def build_deployments_cancel_at_management_group_scope_request( - group_id: str, - deployment_name: str, - **kwargs: Any + group_id: str, deployment_name: str, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2021-04-01") # type: 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-04-01")) # type: str + accept = _headers.pop("Accept", "application/json") - accept = "application/json" # Construct URL - _url = kwargs.pop("template_url", "/providers/Microsoft.Management/managementGroups/{groupId}/providers/Microsoft.Resources/deployments/{deploymentName}/cancel") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", + "/providers/Microsoft.Management/managementGroups/{groupId}/providers/Microsoft.Resources/deployments/{deploymentName}/cancel", + ) # pylint: disable=line-too-long path_format_arguments = { - "groupId": _SERIALIZER.url("group_id", group_id, 'str', max_length=90, min_length=1), - "deploymentName": _SERIALIZER.url("deployment_name", deployment_name, 'str', max_length=64, min_length=1, pattern=r'^[-\w\._\(\)]+$'), + "groupId": _SERIALIZER.url("group_id", group_id, "str", max_length=90, min_length=1), + "deploymentName": _SERIALIZER.url( + "deployment_name", deployment_name, "str", max_length=64, min_length=1, pattern=r"^[-\w\._\(\)]+$" + ), } _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') - - return HttpRequest( - method="POST", - url=_url, - params=_query_parameters, - headers=_header_parameters, - **kwargs - ) + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + return HttpRequest(method="POST", url=_url, params=_params, headers=_headers, **kwargs) -def build_deployments_validate_at_management_group_scope_request_initial( - group_id: str, - deployment_name: str, - *, - json: JSONType = None, - content: Any = None, - **kwargs: Any + +def build_deployments_validate_at_management_group_scope_request( + group_id: str, deployment_name: str, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2021-04-01") # type: str - content_type = kwargs.pop('content_type', None) # type: Optional[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-04-01")) # type: str + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + accept = _headers.pop("Accept", "application/json") - accept = "application/json" # Construct URL - _url = kwargs.pop("template_url", "/providers/Microsoft.Management/managementGroups/{groupId}/providers/Microsoft.Resources/deployments/{deploymentName}/validate") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", + "/providers/Microsoft.Management/managementGroups/{groupId}/providers/Microsoft.Resources/deployments/{deploymentName}/validate", + ) # pylint: disable=line-too-long path_format_arguments = { - "groupId": _SERIALIZER.url("group_id", group_id, 'str', max_length=90, min_length=1), - "deploymentName": _SERIALIZER.url("deployment_name", deployment_name, 'str', max_length=64, min_length=1, pattern=r'^[-\w\._\(\)]+$'), + "groupId": _SERIALIZER.url("group_id", group_id, "str", max_length=90, min_length=1), + "deploymentName": _SERIALIZER.url( + "deployment_name", deployment_name, "str", max_length=64, min_length=1, pattern=r"^[-\w\._\(\)]+$" + ), } _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] if content_type is not None: - _header_parameters['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') - _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') - - return HttpRequest( - method="POST", - url=_url, - params=_query_parameters, - headers=_header_parameters, - json=json, - content=content, - **kwargs - ) + _headers["Content-Type"] = _SERIALIZER.header("content_type", content_type, "str") + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + return HttpRequest(method="POST", url=_url, params=_params, headers=_headers, **kwargs) -def build_deployments_what_if_at_management_group_scope_request_initial( - group_id: str, - deployment_name: str, - *, - json: JSONType = None, - content: Any = None, - **kwargs: Any + +def build_deployments_what_if_at_management_group_scope_request( + group_id: str, deployment_name: str, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2021-04-01") # type: str - content_type = kwargs.pop('content_type', None) # type: Optional[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-04-01")) # type: str + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + accept = _headers.pop("Accept", "application/json") - accept = "application/json" # Construct URL - _url = kwargs.pop("template_url", "/providers/Microsoft.Management/managementGroups/{groupId}/providers/Microsoft.Resources/deployments/{deploymentName}/whatIf") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", + "/providers/Microsoft.Management/managementGroups/{groupId}/providers/Microsoft.Resources/deployments/{deploymentName}/whatIf", + ) # pylint: disable=line-too-long path_format_arguments = { - "groupId": _SERIALIZER.url("group_id", group_id, 'str', max_length=90, min_length=1), - "deploymentName": _SERIALIZER.url("deployment_name", deployment_name, 'str', max_length=64, min_length=1, pattern=r'^[-\w\._\(\)]+$'), + "groupId": _SERIALIZER.url("group_id", group_id, "str", max_length=90, min_length=1), + "deploymentName": _SERIALIZER.url( + "deployment_name", deployment_name, "str", max_length=64, min_length=1, pattern=r"^[-\w\._\(\)]+$" + ), } _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] if content_type is not None: - _header_parameters['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') - _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') - - return HttpRequest( - method="POST", - url=_url, - params=_query_parameters, - headers=_header_parameters, - json=json, - content=content, - **kwargs - ) + _headers["Content-Type"] = _SERIALIZER.header("content_type", content_type, "str") + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="POST", url=_url, params=_params, headers=_headers, **kwargs) def build_deployments_export_template_at_management_group_scope_request( - group_id: str, - deployment_name: str, - **kwargs: Any + group_id: str, deployment_name: str, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2021-04-01") # type: 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-04-01")) # type: str + accept = _headers.pop("Accept", "application/json") - accept = "application/json" # Construct URL - _url = kwargs.pop("template_url", "/providers/Microsoft.Management/managementGroups/{groupId}/providers/Microsoft.Resources/deployments/{deploymentName}/exportTemplate") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", + "/providers/Microsoft.Management/managementGroups/{groupId}/providers/Microsoft.Resources/deployments/{deploymentName}/exportTemplate", + ) # pylint: disable=line-too-long path_format_arguments = { - "groupId": _SERIALIZER.url("group_id", group_id, 'str', max_length=90, min_length=1), - "deploymentName": _SERIALIZER.url("deployment_name", deployment_name, 'str', max_length=64, min_length=1, pattern=r'^[-\w\._\(\)]+$'), + "groupId": _SERIALIZER.url("group_id", group_id, "str", max_length=90, min_length=1), + "deploymentName": _SERIALIZER.url( + "deployment_name", deployment_name, "str", max_length=64, min_length=1, pattern=r"^[-\w\._\(\)]+$" + ), } _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') - - return HttpRequest( - method="POST", - url=_url, - params=_query_parameters, - headers=_header_parameters, - **kwargs - ) + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="POST", url=_url, params=_params, headers=_headers, **kwargs) def build_deployments_list_at_management_group_scope_request( - group_id: str, - *, - filter: Optional[str] = None, - top: Optional[int] = None, - **kwargs: Any + group_id: str, *, filter: Optional[str] = None, top: Optional[int] = None, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2021-04-01") # type: 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-04-01")) # type: str + accept = _headers.pop("Accept", "application/json") - accept = "application/json" # Construct URL - _url = kwargs.pop("template_url", "/providers/Microsoft.Management/managementGroups/{groupId}/providers/Microsoft.Resources/deployments/") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", + "/providers/Microsoft.Management/managementGroups/{groupId}/providers/Microsoft.Resources/deployments/", + ) # pylint: disable=line-too-long path_format_arguments = { - "groupId": _SERIALIZER.url("group_id", group_id, 'str', max_length=90, min_length=1), + "groupId": _SERIALIZER.url("group_id", group_id, "str", max_length=90, min_length=1), } _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] if filter is not None: - _query_parameters['$filter'] = _SERIALIZER.query("filter", filter, 'str') + _params["$filter"] = _SERIALIZER.query("filter", filter, "str") if top is not None: - _query_parameters['$top'] = _SERIALIZER.query("top", top, 'int') - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["$top"] = _SERIALIZER.query("top", top, "int") + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') - - return HttpRequest( - method="GET", - url=_url, - params=_query_parameters, - headers=_header_parameters, - **kwargs - ) + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) -def build_deployments_delete_at_subscription_scope_request_initial( - deployment_name: str, - subscription_id: str, - **kwargs: Any + +def build_deployments_delete_at_subscription_scope_request( + deployment_name: str, subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2021-04-01") # type: 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-04-01")) # type: str + accept = _headers.pop("Accept", "application/json") - accept = "application/json" # Construct URL - _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/providers/Microsoft.Resources/deployments/{deploymentName}") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", "/subscriptions/{subscriptionId}/providers/Microsoft.Resources/deployments/{deploymentName}" + ) # pylint: disable=line-too-long path_format_arguments = { - "deploymentName": _SERIALIZER.url("deployment_name", deployment_name, 'str', max_length=64, min_length=1, pattern=r'^[-\w\._\(\)]+$'), - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), + "deploymentName": _SERIALIZER.url( + "deployment_name", deployment_name, "str", max_length=64, min_length=1, pattern=r"^[-\w\._\(\)]+$" + ), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), } _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') - - return HttpRequest( - method="DELETE", - url=_url, - params=_query_parameters, - headers=_header_parameters, - **kwargs - ) + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="DELETE", url=_url, params=_params, headers=_headers, **kwargs) def build_deployments_check_existence_at_subscription_scope_request( - deployment_name: str, - subscription_id: str, - **kwargs: Any + deployment_name: str, subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2021-04-01") # type: 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-04-01")) # type: str + accept = _headers.pop("Accept", "application/json") - accept = "application/json" # Construct URL - _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/providers/Microsoft.Resources/deployments/{deploymentName}") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", "/subscriptions/{subscriptionId}/providers/Microsoft.Resources/deployments/{deploymentName}" + ) # pylint: disable=line-too-long path_format_arguments = { - "deploymentName": _SERIALIZER.url("deployment_name", deployment_name, 'str', max_length=64, min_length=1, pattern=r'^[-\w\._\(\)]+$'), - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), + "deploymentName": _SERIALIZER.url( + "deployment_name", deployment_name, "str", max_length=64, min_length=1, pattern=r"^[-\w\._\(\)]+$" + ), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), } _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') - - return HttpRequest( - method="HEAD", - url=_url, - params=_query_parameters, - headers=_header_parameters, - **kwargs - ) + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + return HttpRequest(method="HEAD", url=_url, params=_params, headers=_headers, **kwargs) -def build_deployments_create_or_update_at_subscription_scope_request_initial( - deployment_name: str, - subscription_id: str, - *, - json: JSONType = None, - content: Any = None, - **kwargs: Any + +def build_deployments_create_or_update_at_subscription_scope_request( + deployment_name: str, subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2021-04-01") # type: str - content_type = kwargs.pop('content_type', None) # type: Optional[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-04-01")) # type: str + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + accept = _headers.pop("Accept", "application/json") - accept = "application/json" # Construct URL - _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/providers/Microsoft.Resources/deployments/{deploymentName}") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", "/subscriptions/{subscriptionId}/providers/Microsoft.Resources/deployments/{deploymentName}" + ) # pylint: disable=line-too-long path_format_arguments = { - "deploymentName": _SERIALIZER.url("deployment_name", deployment_name, 'str', max_length=64, min_length=1, pattern=r'^[-\w\._\(\)]+$'), - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), + "deploymentName": _SERIALIZER.url( + "deployment_name", deployment_name, "str", max_length=64, min_length=1, pattern=r"^[-\w\._\(\)]+$" + ), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), } _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] if content_type is not None: - _header_parameters['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') - _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') - - return HttpRequest( - method="PUT", - url=_url, - params=_query_parameters, - headers=_header_parameters, - json=json, - content=content, - **kwargs - ) + _headers["Content-Type"] = _SERIALIZER.header("content_type", content_type, "str") + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="PUT", url=_url, params=_params, headers=_headers, **kwargs) def build_deployments_get_at_subscription_scope_request( - deployment_name: str, - subscription_id: str, - **kwargs: Any + deployment_name: str, subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2021-04-01") # type: 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-04-01")) # type: str + accept = _headers.pop("Accept", "application/json") - accept = "application/json" # Construct URL - _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/providers/Microsoft.Resources/deployments/{deploymentName}") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", "/subscriptions/{subscriptionId}/providers/Microsoft.Resources/deployments/{deploymentName}" + ) # pylint: disable=line-too-long path_format_arguments = { - "deploymentName": _SERIALIZER.url("deployment_name", deployment_name, 'str', max_length=64, min_length=1, pattern=r'^[-\w\._\(\)]+$'), - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), + "deploymentName": _SERIALIZER.url( + "deployment_name", deployment_name, "str", max_length=64, min_length=1, pattern=r"^[-\w\._\(\)]+$" + ), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), } _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') - - return HttpRequest( - method="GET", - url=_url, - params=_query_parameters, - headers=_header_parameters, - **kwargs - ) + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) def build_deployments_cancel_at_subscription_scope_request( - deployment_name: str, - subscription_id: str, - **kwargs: Any + deployment_name: str, subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2021-04-01") # type: 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-04-01")) # type: str + accept = _headers.pop("Accept", "application/json") - accept = "application/json" # Construct URL - _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/providers/Microsoft.Resources/deployments/{deploymentName}/cancel") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/providers/Microsoft.Resources/deployments/{deploymentName}/cancel", + ) # pylint: disable=line-too-long path_format_arguments = { - "deploymentName": _SERIALIZER.url("deployment_name", deployment_name, 'str', max_length=64, min_length=1, pattern=r'^[-\w\._\(\)]+$'), - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), + "deploymentName": _SERIALIZER.url( + "deployment_name", deployment_name, "str", max_length=64, min_length=1, pattern=r"^[-\w\._\(\)]+$" + ), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), } _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') - - return HttpRequest( - method="POST", - url=_url, - params=_query_parameters, - headers=_header_parameters, - **kwargs - ) + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + return HttpRequest(method="POST", url=_url, params=_params, headers=_headers, **kwargs) -def build_deployments_validate_at_subscription_scope_request_initial( - deployment_name: str, - subscription_id: str, - *, - json: JSONType = None, - content: Any = None, - **kwargs: Any + +def build_deployments_validate_at_subscription_scope_request( + deployment_name: str, subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2021-04-01") # type: str - content_type = kwargs.pop('content_type', None) # type: Optional[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-04-01")) # type: str + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + accept = _headers.pop("Accept", "application/json") - accept = "application/json" # Construct URL - _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/providers/Microsoft.Resources/deployments/{deploymentName}/validate") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/providers/Microsoft.Resources/deployments/{deploymentName}/validate", + ) # pylint: disable=line-too-long path_format_arguments = { - "deploymentName": _SERIALIZER.url("deployment_name", deployment_name, 'str', max_length=64, min_length=1, pattern=r'^[-\w\._\(\)]+$'), - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), + "deploymentName": _SERIALIZER.url( + "deployment_name", deployment_name, "str", max_length=64, min_length=1, pattern=r"^[-\w\._\(\)]+$" + ), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), } _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] if content_type is not None: - _header_parameters['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') - _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') - - return HttpRequest( - method="POST", - url=_url, - params=_query_parameters, - headers=_header_parameters, - json=json, - content=content, - **kwargs - ) + _headers["Content-Type"] = _SERIALIZER.header("content_type", content_type, "str") + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + return HttpRequest(method="POST", url=_url, params=_params, headers=_headers, **kwargs) -def build_deployments_what_if_at_subscription_scope_request_initial( - deployment_name: str, - subscription_id: str, - *, - json: JSONType = None, - content: Any = None, - **kwargs: Any + +def build_deployments_what_if_at_subscription_scope_request( + deployment_name: str, subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2021-04-01") # type: str - content_type = kwargs.pop('content_type', None) # type: Optional[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-04-01")) # type: str + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + accept = _headers.pop("Accept", "application/json") - accept = "application/json" # Construct URL - _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/providers/Microsoft.Resources/deployments/{deploymentName}/whatIf") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/providers/Microsoft.Resources/deployments/{deploymentName}/whatIf", + ) # pylint: disable=line-too-long path_format_arguments = { - "deploymentName": _SERIALIZER.url("deployment_name", deployment_name, 'str', max_length=64, min_length=1, pattern=r'^[-\w\._\(\)]+$'), - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), + "deploymentName": _SERIALIZER.url( + "deployment_name", deployment_name, "str", max_length=64, min_length=1, pattern=r"^[-\w\._\(\)]+$" + ), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), } _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] if content_type is not None: - _header_parameters['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') - _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') - - return HttpRequest( - method="POST", - url=_url, - params=_query_parameters, - headers=_header_parameters, - json=json, - content=content, - **kwargs - ) + _headers["Content-Type"] = _SERIALIZER.header("content_type", content_type, "str") + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="POST", url=_url, params=_params, headers=_headers, **kwargs) def build_deployments_export_template_at_subscription_scope_request( - deployment_name: str, - subscription_id: str, - **kwargs: Any + deployment_name: str, subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2021-04-01") # type: 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-04-01")) # type: str + accept = _headers.pop("Accept", "application/json") - accept = "application/json" # Construct URL - _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/providers/Microsoft.Resources/deployments/{deploymentName}/exportTemplate") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/providers/Microsoft.Resources/deployments/{deploymentName}/exportTemplate", + ) # pylint: disable=line-too-long path_format_arguments = { - "deploymentName": _SERIALIZER.url("deployment_name", deployment_name, 'str', max_length=64, min_length=1, pattern=r'^[-\w\._\(\)]+$'), - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), + "deploymentName": _SERIALIZER.url( + "deployment_name", deployment_name, "str", max_length=64, min_length=1, pattern=r"^[-\w\._\(\)]+$" + ), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), } _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') - - return HttpRequest( - method="POST", - url=_url, - params=_query_parameters, - headers=_header_parameters, - **kwargs - ) + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="POST", url=_url, params=_params, headers=_headers, **kwargs) def build_deployments_list_at_subscription_scope_request( - subscription_id: str, - *, - filter: Optional[str] = None, - top: Optional[int] = None, - **kwargs: Any + subscription_id: str, *, filter: Optional[str] = None, top: Optional[int] = None, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2021-04-01") # type: 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-04-01")) # type: str + accept = _headers.pop("Accept", "application/json") - accept = "application/json" # Construct URL _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/providers/Microsoft.Resources/deployments/") path_format_arguments = { - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), } _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] if filter is not None: - _query_parameters['$filter'] = _SERIALIZER.query("filter", filter, 'str') + _params["$filter"] = _SERIALIZER.query("filter", filter, "str") if top is not None: - _query_parameters['$top'] = _SERIALIZER.query("top", top, 'int') - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["$top"] = _SERIALIZER.query("top", top, "int") + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') - - return HttpRequest( - method="GET", - url=_url, - params=_query_parameters, - headers=_header_parameters, - **kwargs - ) + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) -def build_deployments_delete_request_initial( - resource_group_name: str, - deployment_name: str, - subscription_id: str, - **kwargs: Any + +def build_deployments_delete_request( + resource_group_name: str, deployment_name: str, subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2021-04-01") # type: 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-04-01")) # type: str + accept = _headers.pop("Accept", "application/json") - accept = "application/json" # Construct URL - _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/Microsoft.Resources/deployments/{deploymentName}") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/Microsoft.Resources/deployments/{deploymentName}", + ) # pylint: disable=line-too-long path_format_arguments = { - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._\(\)]+$'), - "deploymentName": _SERIALIZER.url("deployment_name", deployment_name, 'str', max_length=64, min_length=1, pattern=r'^[-\w\._\(\)]+$'), - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), + "resourceGroupName": _SERIALIZER.url( + "resource_group_name", resource_group_name, "str", max_length=90, min_length=1, pattern=r"^[-\w\._\(\)]+$" + ), + "deploymentName": _SERIALIZER.url( + "deployment_name", deployment_name, "str", max_length=64, min_length=1, pattern=r"^[-\w\._\(\)]+$" + ), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), } _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') - - return HttpRequest( - method="DELETE", - url=_url, - params=_query_parameters, - headers=_header_parameters, - **kwargs - ) + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="DELETE", url=_url, params=_params, headers=_headers, **kwargs) def build_deployments_check_existence_request( - resource_group_name: str, - deployment_name: str, - subscription_id: str, - **kwargs: Any + resource_group_name: str, deployment_name: str, subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2021-04-01") # type: 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-04-01")) # type: str + accept = _headers.pop("Accept", "application/json") - accept = "application/json" # Construct URL - _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/Microsoft.Resources/deployments/{deploymentName}") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/Microsoft.Resources/deployments/{deploymentName}", + ) # pylint: disable=line-too-long path_format_arguments = { - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._\(\)]+$'), - "deploymentName": _SERIALIZER.url("deployment_name", deployment_name, 'str', max_length=64, min_length=1, pattern=r'^[-\w\._\(\)]+$'), - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), + "resourceGroupName": _SERIALIZER.url( + "resource_group_name", resource_group_name, "str", max_length=90, min_length=1, pattern=r"^[-\w\._\(\)]+$" + ), + "deploymentName": _SERIALIZER.url( + "deployment_name", deployment_name, "str", max_length=64, min_length=1, pattern=r"^[-\w\._\(\)]+$" + ), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), } _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') - - return HttpRequest( - method="HEAD", - url=_url, - params=_query_parameters, - headers=_header_parameters, - **kwargs - ) + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + return HttpRequest(method="HEAD", url=_url, params=_params, headers=_headers, **kwargs) -def build_deployments_create_or_update_request_initial( - resource_group_name: str, - deployment_name: str, - subscription_id: str, - *, - json: JSONType = None, - content: Any = None, - **kwargs: Any + +def build_deployments_create_or_update_request( + resource_group_name: str, deployment_name: str, subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2021-04-01") # type: str - content_type = kwargs.pop('content_type', None) # type: Optional[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-04-01")) # type: str + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + accept = _headers.pop("Accept", "application/json") - accept = "application/json" # Construct URL - _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/Microsoft.Resources/deployments/{deploymentName}") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/Microsoft.Resources/deployments/{deploymentName}", + ) # pylint: disable=line-too-long path_format_arguments = { - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._\(\)]+$'), - "deploymentName": _SERIALIZER.url("deployment_name", deployment_name, 'str', max_length=64, min_length=1, pattern=r'^[-\w\._\(\)]+$'), - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), + "resourceGroupName": _SERIALIZER.url( + "resource_group_name", resource_group_name, "str", max_length=90, min_length=1, pattern=r"^[-\w\._\(\)]+$" + ), + "deploymentName": _SERIALIZER.url( + "deployment_name", deployment_name, "str", max_length=64, min_length=1, pattern=r"^[-\w\._\(\)]+$" + ), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), } _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] if content_type is not None: - _header_parameters['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') - _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') - - return HttpRequest( - method="PUT", - url=_url, - params=_query_parameters, - headers=_header_parameters, - json=json, - content=content, - **kwargs - ) + _headers["Content-Type"] = _SERIALIZER.header("content_type", content_type, "str") + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="PUT", url=_url, params=_params, headers=_headers, **kwargs) def build_deployments_get_request( - resource_group_name: str, - deployment_name: str, - subscription_id: str, - **kwargs: Any + resource_group_name: str, deployment_name: str, subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2021-04-01") # type: 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-04-01")) # type: str + accept = _headers.pop("Accept", "application/json") - accept = "application/json" # Construct URL - _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/Microsoft.Resources/deployments/{deploymentName}") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/Microsoft.Resources/deployments/{deploymentName}", + ) # pylint: disable=line-too-long path_format_arguments = { - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._\(\)]+$'), - "deploymentName": _SERIALIZER.url("deployment_name", deployment_name, 'str', max_length=64, min_length=1, pattern=r'^[-\w\._\(\)]+$'), - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), + "resourceGroupName": _SERIALIZER.url( + "resource_group_name", resource_group_name, "str", max_length=90, min_length=1, pattern=r"^[-\w\._\(\)]+$" + ), + "deploymentName": _SERIALIZER.url( + "deployment_name", deployment_name, "str", max_length=64, min_length=1, pattern=r"^[-\w\._\(\)]+$" + ), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), } _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') - - return HttpRequest( - method="GET", - url=_url, - params=_query_parameters, - headers=_header_parameters, - **kwargs - ) + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) def build_deployments_cancel_request( - resource_group_name: str, - deployment_name: str, - subscription_id: str, - **kwargs: Any + resource_group_name: str, deployment_name: str, subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2021-04-01") # type: 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-04-01")) # type: str + accept = _headers.pop("Accept", "application/json") - accept = "application/json" # Construct URL - _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/Microsoft.Resources/deployments/{deploymentName}/cancel") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/Microsoft.Resources/deployments/{deploymentName}/cancel", + ) # pylint: disable=line-too-long path_format_arguments = { - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._\(\)]+$'), - "deploymentName": _SERIALIZER.url("deployment_name", deployment_name, 'str', max_length=64, min_length=1, pattern=r'^[-\w\._\(\)]+$'), - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), + "resourceGroupName": _SERIALIZER.url( + "resource_group_name", resource_group_name, "str", max_length=90, min_length=1, pattern=r"^[-\w\._\(\)]+$" + ), + "deploymentName": _SERIALIZER.url( + "deployment_name", deployment_name, "str", max_length=64, min_length=1, pattern=r"^[-\w\._\(\)]+$" + ), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), } _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') - - return HttpRequest( - method="POST", - url=_url, - params=_query_parameters, - headers=_header_parameters, - **kwargs - ) + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + return HttpRequest(method="POST", url=_url, params=_params, headers=_headers, **kwargs) -def build_deployments_validate_request_initial( - resource_group_name: str, - deployment_name: str, - subscription_id: str, - *, - json: JSONType = None, - content: Any = None, - **kwargs: Any + +def build_deployments_validate_request( + resource_group_name: str, deployment_name: str, subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2021-04-01") # type: str - content_type = kwargs.pop('content_type', None) # type: Optional[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-04-01")) # type: str + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + accept = _headers.pop("Accept", "application/json") - accept = "application/json" # Construct URL - _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/Microsoft.Resources/deployments/{deploymentName}/validate") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/Microsoft.Resources/deployments/{deploymentName}/validate", + ) # pylint: disable=line-too-long path_format_arguments = { - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._\(\)]+$'), - "deploymentName": _SERIALIZER.url("deployment_name", deployment_name, 'str', max_length=64, min_length=1, pattern=r'^[-\w\._\(\)]+$'), - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), + "resourceGroupName": _SERIALIZER.url( + "resource_group_name", resource_group_name, "str", max_length=90, min_length=1, pattern=r"^[-\w\._\(\)]+$" + ), + "deploymentName": _SERIALIZER.url( + "deployment_name", deployment_name, "str", max_length=64, min_length=1, pattern=r"^[-\w\._\(\)]+$" + ), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), } _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] if content_type is not None: - _header_parameters['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') - _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') - - return HttpRequest( - method="POST", - url=_url, - params=_query_parameters, - headers=_header_parameters, - json=json, - content=content, - **kwargs - ) + _headers["Content-Type"] = _SERIALIZER.header("content_type", content_type, "str") + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + return HttpRequest(method="POST", url=_url, params=_params, headers=_headers, **kwargs) -def build_deployments_what_if_request_initial( - resource_group_name: str, - deployment_name: str, - subscription_id: str, - *, - json: JSONType = None, - content: Any = None, - **kwargs: Any + +def build_deployments_what_if_request( + resource_group_name: str, deployment_name: str, subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2021-04-01") # type: str - content_type = kwargs.pop('content_type', None) # type: Optional[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-04-01")) # type: str + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + accept = _headers.pop("Accept", "application/json") - accept = "application/json" # Construct URL - _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/Microsoft.Resources/deployments/{deploymentName}/whatIf") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/Microsoft.Resources/deployments/{deploymentName}/whatIf", + ) # pylint: disable=line-too-long path_format_arguments = { - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._\(\)]+$'), - "deploymentName": _SERIALIZER.url("deployment_name", deployment_name, 'str', max_length=64, min_length=1, pattern=r'^[-\w\._\(\)]+$'), - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), + "resourceGroupName": _SERIALIZER.url( + "resource_group_name", resource_group_name, "str", max_length=90, min_length=1, pattern=r"^[-\w\._\(\)]+$" + ), + "deploymentName": _SERIALIZER.url( + "deployment_name", deployment_name, "str", max_length=64, min_length=1, pattern=r"^[-\w\._\(\)]+$" + ), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), } _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] if content_type is not None: - _header_parameters['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') - _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') - - return HttpRequest( - method="POST", - url=_url, - params=_query_parameters, - headers=_header_parameters, - json=json, - content=content, - **kwargs - ) + _headers["Content-Type"] = _SERIALIZER.header("content_type", content_type, "str") + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="POST", url=_url, params=_params, headers=_headers, **kwargs) def build_deployments_export_template_request( - resource_group_name: str, - deployment_name: str, - subscription_id: str, - **kwargs: Any + resource_group_name: str, deployment_name: str, subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2021-04-01") # type: 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-04-01")) # type: str + accept = _headers.pop("Accept", "application/json") - accept = "application/json" # Construct URL - _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/Microsoft.Resources/deployments/{deploymentName}/exportTemplate") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/Microsoft.Resources/deployments/{deploymentName}/exportTemplate", + ) # pylint: disable=line-too-long path_format_arguments = { - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._\(\)]+$'), - "deploymentName": _SERIALIZER.url("deployment_name", deployment_name, 'str', max_length=64, min_length=1, pattern=r'^[-\w\._\(\)]+$'), - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), + "resourceGroupName": _SERIALIZER.url( + "resource_group_name", resource_group_name, "str", max_length=90, min_length=1, pattern=r"^[-\w\._\(\)]+$" + ), + "deploymentName": _SERIALIZER.url( + "deployment_name", deployment_name, "str", max_length=64, min_length=1, pattern=r"^[-\w\._\(\)]+$" + ), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), } _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') - - return HttpRequest( - method="POST", - url=_url, - params=_query_parameters, - headers=_header_parameters, - **kwargs - ) + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="POST", url=_url, params=_params, headers=_headers, **kwargs) def build_deployments_list_by_resource_group_request( @@ -1651,393 +1418,312 @@ def build_deployments_list_by_resource_group_request( top: Optional[int] = None, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2021-04-01") # type: 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-04-01")) # type: str + accept = _headers.pop("Accept", "application/json") - accept = "application/json" # Construct URL - _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/Microsoft.Resources/deployments/") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/Microsoft.Resources/deployments/", + ) # pylint: disable=line-too-long path_format_arguments = { - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._\(\)]+$'), - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), + "resourceGroupName": _SERIALIZER.url( + "resource_group_name", resource_group_name, "str", max_length=90, min_length=1, pattern=r"^[-\w\._\(\)]+$" + ), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), } _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] if filter is not None: - _query_parameters['$filter'] = _SERIALIZER.query("filter", filter, 'str') + _params["$filter"] = _SERIALIZER.query("filter", filter, "str") if top is not None: - _query_parameters['$top'] = _SERIALIZER.query("top", top, 'int') - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["$top"] = _SERIALIZER.query("top", top, "int") + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') - - return HttpRequest( - method="GET", - url=_url, - params=_query_parameters, - headers=_header_parameters, - **kwargs - ) + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) -def build_deployments_calculate_template_hash_request( - *, - json: JSONType = None, - content: Any = None, - **kwargs: Any -) -> HttpRequest: - api_version = kwargs.pop('api_version', "2021-04-01") # type: str - content_type = kwargs.pop('content_type', None) # type: Optional[str] - accept = "application/json" +def build_deployments_calculate_template_hash_request(*, json: JSON, **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-04-01")) # type: str + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + accept = _headers.pop("Accept", "application/json") + # Construct URL _url = kwargs.pop("template_url", "/providers/Microsoft.Resources/calculateTemplateHash") # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] if content_type is not None: - _header_parameters['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') - _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') - - return HttpRequest( - method="POST", - url=_url, - params=_query_parameters, - headers=_header_parameters, - json=json, - content=content, - **kwargs - ) + _headers["Content-Type"] = _SERIALIZER.header("content_type", content_type, "str") + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="POST", url=_url, params=_params, headers=_headers, json=json, **kwargs) def build_providers_unregister_request( - resource_provider_namespace: str, - subscription_id: str, - **kwargs: Any + resource_provider_namespace: str, subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2021-04-01") # type: 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-04-01")) # type: str + accept = _headers.pop("Accept", "application/json") - accept = "application/json" # Construct URL - _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/providers/{resourceProviderNamespace}/unregister") + _url = kwargs.pop( + "template_url", "/subscriptions/{subscriptionId}/providers/{resourceProviderNamespace}/unregister" + ) path_format_arguments = { - "resourceProviderNamespace": _SERIALIZER.url("resource_provider_namespace", resource_provider_namespace, 'str'), - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), + "resourceProviderNamespace": _SERIALIZER.url("resource_provider_namespace", resource_provider_namespace, "str"), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), } _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') - - return HttpRequest( - method="POST", - url=_url, - params=_query_parameters, - headers=_header_parameters, - **kwargs - ) + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="POST", url=_url, params=_params, headers=_headers, **kwargs) def build_providers_register_at_management_group_scope_request( - resource_provider_namespace: str, - group_id: str, - **kwargs: Any + resource_provider_namespace: str, group_id: str, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2021-04-01") # type: 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-04-01")) # type: str + accept = _headers.pop("Accept", "application/json") - accept = "application/json" # Construct URL - _url = kwargs.pop("template_url", "/providers/Microsoft.Management/managementGroups/{groupId}/providers/{resourceProviderNamespace}/register") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", + "/providers/Microsoft.Management/managementGroups/{groupId}/providers/{resourceProviderNamespace}/register", + ) # pylint: disable=line-too-long path_format_arguments = { - "resourceProviderNamespace": _SERIALIZER.url("resource_provider_namespace", resource_provider_namespace, 'str'), - "groupId": _SERIALIZER.url("group_id", group_id, 'str', max_length=90, min_length=1), + "resourceProviderNamespace": _SERIALIZER.url("resource_provider_namespace", resource_provider_namespace, "str"), + "groupId": _SERIALIZER.url("group_id", group_id, "str", max_length=90, min_length=1), } _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') - - return HttpRequest( - method="POST", - url=_url, - params=_query_parameters, - headers=_header_parameters, - **kwargs - ) + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="POST", url=_url, params=_params, headers=_headers, **kwargs) def build_providers_provider_permissions_request( - resource_provider_namespace: str, - subscription_id: str, - **kwargs: Any + resource_provider_namespace: str, subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2021-04-01") # type: 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-04-01")) # type: str + accept = _headers.pop("Accept", "application/json") - accept = "application/json" # Construct URL - _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/providers/{resourceProviderNamespace}/providerPermissions") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", "/subscriptions/{subscriptionId}/providers/{resourceProviderNamespace}/providerPermissions" + ) # pylint: disable=line-too-long path_format_arguments = { - "resourceProviderNamespace": _SERIALIZER.url("resource_provider_namespace", resource_provider_namespace, 'str'), - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), + "resourceProviderNamespace": _SERIALIZER.url("resource_provider_namespace", resource_provider_namespace, "str"), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), } _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') - - return HttpRequest( - method="GET", - url=_url, - params=_query_parameters, - headers=_header_parameters, - **kwargs - ) + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) def build_providers_register_request( - resource_provider_namespace: str, - subscription_id: str, - *, - json: JSONType = None, - content: Any = None, - **kwargs: Any + resource_provider_namespace: str, subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2021-04-01") # type: str - content_type = kwargs.pop('content_type', None) # type: Optional[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-04-01")) # type: str + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + accept = _headers.pop("Accept", "application/json") - accept = "application/json" # Construct URL _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/providers/{resourceProviderNamespace}/register") path_format_arguments = { - "resourceProviderNamespace": _SERIALIZER.url("resource_provider_namespace", resource_provider_namespace, 'str'), - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), + "resourceProviderNamespace": _SERIALIZER.url("resource_provider_namespace", resource_provider_namespace, "str"), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), } _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] if content_type is not None: - _header_parameters['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') - _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') - - return HttpRequest( - method="POST", - url=_url, - params=_query_parameters, - headers=_header_parameters, - json=json, - content=content, - **kwargs - ) + _headers["Content-Type"] = _SERIALIZER.header("content_type", content_type, "str") + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + return HttpRequest(method="POST", url=_url, params=_params, headers=_headers, **kwargs) -def build_providers_list_request( - subscription_id: str, - *, - expand: Optional[str] = None, - **kwargs: Any -) -> HttpRequest: - api_version = kwargs.pop('api_version', "2021-04-01") # type: str - accept = "application/json" +def build_providers_list_request(subscription_id: str, *, expand: Optional[str] = None, **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-04-01")) # type: str + accept = _headers.pop("Accept", "application/json") + # Construct URL _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/providers") path_format_arguments = { - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), } _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] if expand is not None: - _query_parameters['$expand'] = _SERIALIZER.query("expand", expand, 'str') - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["$expand"] = _SERIALIZER.query("expand", expand, "str") + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') - - return HttpRequest( - method="GET", - url=_url, - params=_query_parameters, - headers=_header_parameters, - **kwargs - ) + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) -def build_providers_list_at_tenant_scope_request( - *, - expand: Optional[str] = None, - **kwargs: Any -) -> HttpRequest: - api_version = kwargs.pop('api_version', "2021-04-01") # type: str - accept = "application/json" +def build_providers_list_at_tenant_scope_request(*, expand: Optional[str] = None, **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-04-01")) # type: str + accept = _headers.pop("Accept", "application/json") + # Construct URL _url = kwargs.pop("template_url", "/providers") # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] if expand is not None: - _query_parameters['$expand'] = _SERIALIZER.query("expand", expand, 'str') - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["$expand"] = _SERIALIZER.query("expand", expand, "str") + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') - - return HttpRequest( - method="GET", - url=_url, - params=_query_parameters, - headers=_header_parameters, - **kwargs - ) + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) def build_providers_get_request( - resource_provider_namespace: str, - subscription_id: str, - *, - expand: Optional[str] = None, - **kwargs: Any + resource_provider_namespace: str, subscription_id: str, *, expand: Optional[str] = None, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2021-04-01") # type: 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-04-01")) # type: str + accept = _headers.pop("Accept", "application/json") - accept = "application/json" # Construct URL _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/providers/{resourceProviderNamespace}") path_format_arguments = { - "resourceProviderNamespace": _SERIALIZER.url("resource_provider_namespace", resource_provider_namespace, 'str'), - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), + "resourceProviderNamespace": _SERIALIZER.url("resource_provider_namespace", resource_provider_namespace, "str"), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), } _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] if expand is not None: - _query_parameters['$expand'] = _SERIALIZER.query("expand", expand, 'str') - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["$expand"] = _SERIALIZER.query("expand", expand, "str") + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') - - return HttpRequest( - method="GET", - url=_url, - params=_query_parameters, - headers=_header_parameters, - **kwargs - ) + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) def build_providers_get_at_tenant_scope_request( - resource_provider_namespace: str, - *, - expand: Optional[str] = None, - **kwargs: Any + resource_provider_namespace: str, *, expand: Optional[str] = None, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2021-04-01") # type: 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-04-01")) # type: str + accept = _headers.pop("Accept", "application/json") - accept = "application/json" # Construct URL _url = kwargs.pop("template_url", "/providers/{resourceProviderNamespace}") path_format_arguments = { - "resourceProviderNamespace": _SERIALIZER.url("resource_provider_namespace", resource_provider_namespace, 'str'), + "resourceProviderNamespace": _SERIALIZER.url("resource_provider_namespace", resource_provider_namespace, "str"), } _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] if expand is not None: - _query_parameters['$expand'] = _SERIALIZER.query("expand", expand, 'str') - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["$expand"] = _SERIALIZER.query("expand", expand, "str") + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') - - return HttpRequest( - method="GET", - url=_url, - params=_query_parameters, - headers=_header_parameters, - **kwargs - ) + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) def build_provider_resource_types_list_request( - resource_provider_namespace: str, - subscription_id: str, - *, - expand: Optional[str] = None, - **kwargs: Any + resource_provider_namespace: str, subscription_id: str, *, expand: Optional[str] = None, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2021-04-01") # type: 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-04-01")) # type: str + accept = _headers.pop("Accept", "application/json") - accept = "application/json" # Construct URL - _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/providers/{resourceProviderNamespace}/resourceTypes") + _url = kwargs.pop( + "template_url", "/subscriptions/{subscriptionId}/providers/{resourceProviderNamespace}/resourceTypes" + ) path_format_arguments = { - "resourceProviderNamespace": _SERIALIZER.url("resource_provider_namespace", resource_provider_namespace, 'str'), - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), + "resourceProviderNamespace": _SERIALIZER.url("resource_provider_namespace", resource_provider_namespace, "str"), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), } _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] if expand is not None: - _query_parameters['$expand'] = _SERIALIZER.query("expand", expand, 'str') - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["$expand"] = _SERIALIZER.query("expand", expand, "str") + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') - - return HttpRequest( - method="GET", - url=_url, - params=_query_parameters, - headers=_header_parameters, - **kwargs - ) + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) def build_resources_list_by_resource_group_request( @@ -2049,123 +1735,114 @@ def build_resources_list_by_resource_group_request( top: Optional[int] = None, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2021-04-01") # type: 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-04-01")) # type: str + accept = _headers.pop("Accept", "application/json") - accept = "application/json" # Construct URL _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/resources") path_format_arguments = { - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._\(\)]+$'), - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), + "resourceGroupName": _SERIALIZER.url( + "resource_group_name", resource_group_name, "str", max_length=90, min_length=1, pattern=r"^[-\w\._\(\)]+$" + ), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), } _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] if filter is not None: - _query_parameters['$filter'] = _SERIALIZER.query("filter", filter, 'str') + _params["$filter"] = _SERIALIZER.query("filter", filter, "str") if expand is not None: - _query_parameters['$expand'] = _SERIALIZER.query("expand", expand, 'str') + _params["$expand"] = _SERIALIZER.query("expand", expand, "str") if top is not None: - _query_parameters['$top'] = _SERIALIZER.query("top", top, 'int') - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["$top"] = _SERIALIZER.query("top", top, "int") + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') - - return HttpRequest( - method="GET", - url=_url, - params=_query_parameters, - headers=_header_parameters, - **kwargs - ) + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) -def build_resources_move_resources_request_initial( - source_resource_group_name: str, - subscription_id: str, - *, - json: JSONType = None, - content: Any = None, - **kwargs: Any + +def build_resources_move_resources_request( + source_resource_group_name: str, subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2021-04-01") # type: str - content_type = kwargs.pop('content_type', None) # type: Optional[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-04-01")) # type: str + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + accept = _headers.pop("Accept", "application/json") - accept = "application/json" # Construct URL - _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{sourceResourceGroupName}/moveResources") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", "/subscriptions/{subscriptionId}/resourceGroups/{sourceResourceGroupName}/moveResources" + ) # pylint: disable=line-too-long path_format_arguments = { - "sourceResourceGroupName": _SERIALIZER.url("source_resource_group_name", source_resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._\(\)]+$'), - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), + "sourceResourceGroupName": _SERIALIZER.url( + "source_resource_group_name", + source_resource_group_name, + "str", + max_length=90, + min_length=1, + pattern=r"^[-\w\._\(\)]+$", + ), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), } _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] if content_type is not None: - _header_parameters['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') - _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') - - return HttpRequest( - method="POST", - url=_url, - params=_query_parameters, - headers=_header_parameters, - json=json, - content=content, - **kwargs - ) + _headers["Content-Type"] = _SERIALIZER.header("content_type", content_type, "str") + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + return HttpRequest(method="POST", url=_url, params=_params, headers=_headers, **kwargs) -def build_resources_validate_move_resources_request_initial( - source_resource_group_name: str, - subscription_id: str, - *, - json: JSONType = None, - content: Any = None, - **kwargs: Any + +def build_resources_validate_move_resources_request( + source_resource_group_name: str, subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2021-04-01") # type: str - content_type = kwargs.pop('content_type', None) # type: Optional[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-04-01")) # type: str + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + accept = _headers.pop("Accept", "application/json") - accept = "application/json" # Construct URL - _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{sourceResourceGroupName}/validateMoveResources") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", "/subscriptions/{subscriptionId}/resourceGroups/{sourceResourceGroupName}/validateMoveResources" + ) # pylint: disable=line-too-long path_format_arguments = { - "sourceResourceGroupName": _SERIALIZER.url("source_resource_group_name", source_resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._\(\)]+$'), - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), + "sourceResourceGroupName": _SERIALIZER.url( + "source_resource_group_name", + source_resource_group_name, + "str", + max_length=90, + min_length=1, + pattern=r"^[-\w\._\(\)]+$", + ), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), } _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] if content_type is not None: - _header_parameters['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') - _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') - - return HttpRequest( - method="POST", - url=_url, - params=_query_parameters, - headers=_header_parameters, - json=json, - content=content, - **kwargs - ) + _headers["Content-Type"] = _SERIALIZER.header("content_type", content_type, "str") + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="POST", url=_url, params=_params, headers=_headers, **kwargs) def build_resources_list_request( @@ -2176,38 +1853,33 @@ def build_resources_list_request( top: Optional[int] = None, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2021-04-01") # type: 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-04-01")) # type: str + accept = _headers.pop("Accept", "application/json") - accept = "application/json" # Construct URL _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resources") path_format_arguments = { - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), } _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] if filter is not None: - _query_parameters['$filter'] = _SERIALIZER.query("filter", filter, 'str') + _params["$filter"] = _SERIALIZER.query("filter", filter, "str") if expand is not None: - _query_parameters['$expand'] = _SERIALIZER.query("expand", expand, 'str') + _params["$expand"] = _SERIALIZER.query("expand", expand, "str") if top is not None: - _query_parameters['$top'] = _SERIALIZER.query("top", top, 'int') - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["$top"] = _SERIALIZER.query("top", top, "int") + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') - - return HttpRequest( - method="GET", - url=_url, - params=_query_parameters, - headers=_header_parameters, - **kwargs - ) + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) def build_resources_check_existence_request( @@ -2221,38 +1893,39 @@ def build_resources_check_existence_request( api_version: str, **kwargs: Any ) -> HttpRequest: - accept = "application/json" + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + accept = _headers.pop("Accept", "application/json") + # Construct URL - _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{parentResourcePath}/{resourceType}/{resourceName}") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{parentResourcePath}/{resourceType}/{resourceName}", + ) # pylint: disable=line-too-long path_format_arguments = { - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._\(\)]+$'), - "resourceProviderNamespace": _SERIALIZER.url("resource_provider_namespace", resource_provider_namespace, 'str'), - "parentResourcePath": _SERIALIZER.url("parent_resource_path", parent_resource_path, 'str', skip_quote=True), - "resourceType": _SERIALIZER.url("resource_type", resource_type, 'str', skip_quote=True), - "resourceName": _SERIALIZER.url("resource_name", resource_name, 'str'), - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), + "resourceGroupName": _SERIALIZER.url( + "resource_group_name", resource_group_name, "str", max_length=90, min_length=1, pattern=r"^[-\w\._\(\)]+$" + ), + "resourceProviderNamespace": _SERIALIZER.url("resource_provider_namespace", resource_provider_namespace, "str"), + "parentResourcePath": _SERIALIZER.url("parent_resource_path", parent_resource_path, "str", skip_quote=True), + "resourceType": _SERIALIZER.url("resource_type", resource_type, "str", skip_quote=True), + "resourceName": _SERIALIZER.url("resource_name", resource_name, "str"), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), } _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') - - return HttpRequest( - method="HEAD", - url=_url, - params=_query_parameters, - headers=_header_parameters, - **kwargs - ) + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + return HttpRequest(method="HEAD", url=_url, params=_params, headers=_headers, **kwargs) -def build_resources_delete_request_initial( + +def build_resources_delete_request( resource_group_name: str, resource_provider_namespace: str, parent_resource_path: str, @@ -2263,38 +1936,39 @@ def build_resources_delete_request_initial( api_version: str, **kwargs: Any ) -> HttpRequest: - accept = "application/json" + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + accept = _headers.pop("Accept", "application/json") + # Construct URL - _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{parentResourcePath}/{resourceType}/{resourceName}") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{parentResourcePath}/{resourceType}/{resourceName}", + ) # pylint: disable=line-too-long path_format_arguments = { - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._\(\)]+$'), - "resourceProviderNamespace": _SERIALIZER.url("resource_provider_namespace", resource_provider_namespace, 'str'), - "parentResourcePath": _SERIALIZER.url("parent_resource_path", parent_resource_path, 'str', skip_quote=True), - "resourceType": _SERIALIZER.url("resource_type", resource_type, 'str', skip_quote=True), - "resourceName": _SERIALIZER.url("resource_name", resource_name, 'str'), - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), + "resourceGroupName": _SERIALIZER.url( + "resource_group_name", resource_group_name, "str", max_length=90, min_length=1, pattern=r"^[-\w\._\(\)]+$" + ), + "resourceProviderNamespace": _SERIALIZER.url("resource_provider_namespace", resource_provider_namespace, "str"), + "parentResourcePath": _SERIALIZER.url("parent_resource_path", parent_resource_path, "str", skip_quote=True), + "resourceType": _SERIALIZER.url("resource_type", resource_type, "str", skip_quote=True), + "resourceName": _SERIALIZER.url("resource_name", resource_name, "str"), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), } _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') - - return HttpRequest( - method="DELETE", - url=_url, - params=_query_parameters, - headers=_header_parameters, - **kwargs - ) + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + return HttpRequest(method="DELETE", url=_url, params=_params, headers=_headers, **kwargs) -def build_resources_create_or_update_request_initial( + +def build_resources_create_or_update_request( resource_group_name: str, resource_provider_namespace: str, parent_resource_path: str, @@ -2303,48 +1977,44 @@ def build_resources_create_or_update_request_initial( subscription_id: str, *, api_version: str, - json: JSONType = None, - content: Any = None, **kwargs: Any ) -> HttpRequest: - content_type = kwargs.pop('content_type', None) # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + accept = _headers.pop("Accept", "application/json") - accept = "application/json" # Construct URL - _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{parentResourcePath}/{resourceType}/{resourceName}") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{parentResourcePath}/{resourceType}/{resourceName}", + ) # pylint: disable=line-too-long path_format_arguments = { - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._\(\)]+$'), - "resourceProviderNamespace": _SERIALIZER.url("resource_provider_namespace", resource_provider_namespace, 'str'), - "parentResourcePath": _SERIALIZER.url("parent_resource_path", parent_resource_path, 'str', skip_quote=True), - "resourceType": _SERIALIZER.url("resource_type", resource_type, 'str', skip_quote=True), - "resourceName": _SERIALIZER.url("resource_name", resource_name, 'str'), - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), + "resourceGroupName": _SERIALIZER.url( + "resource_group_name", resource_group_name, "str", max_length=90, min_length=1, pattern=r"^[-\w\._\(\)]+$" + ), + "resourceProviderNamespace": _SERIALIZER.url("resource_provider_namespace", resource_provider_namespace, "str"), + "parentResourcePath": _SERIALIZER.url("parent_resource_path", parent_resource_path, "str", skip_quote=True), + "resourceType": _SERIALIZER.url("resource_type", resource_type, "str", skip_quote=True), + "resourceName": _SERIALIZER.url("resource_name", resource_name, "str"), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), } _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] if content_type is not None: - _header_parameters['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') - _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') - - return HttpRequest( - method="PUT", - url=_url, - params=_query_parameters, - headers=_header_parameters, - json=json, - content=content, - **kwargs - ) + _headers["Content-Type"] = _SERIALIZER.header("content_type", content_type, "str") + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="PUT", url=_url, params=_params, headers=_headers, **kwargs) -def build_resources_update_request_initial( +def build_resources_update_request( resource_group_name: str, resource_provider_namespace: str, parent_resource_path: str, @@ -2353,45 +2023,41 @@ def build_resources_update_request_initial( subscription_id: str, *, api_version: str, - json: JSONType = None, - content: Any = None, **kwargs: Any ) -> HttpRequest: - content_type = kwargs.pop('content_type', None) # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + accept = _headers.pop("Accept", "application/json") - accept = "application/json" # Construct URL - _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{parentResourcePath}/{resourceType}/{resourceName}") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{parentResourcePath}/{resourceType}/{resourceName}", + ) # pylint: disable=line-too-long path_format_arguments = { - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._\(\)]+$'), - "resourceProviderNamespace": _SERIALIZER.url("resource_provider_namespace", resource_provider_namespace, 'str'), - "parentResourcePath": _SERIALIZER.url("parent_resource_path", parent_resource_path, 'str', skip_quote=True), - "resourceType": _SERIALIZER.url("resource_type", resource_type, 'str', skip_quote=True), - "resourceName": _SERIALIZER.url("resource_name", resource_name, 'str'), - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), + "resourceGroupName": _SERIALIZER.url( + "resource_group_name", resource_group_name, "str", max_length=90, min_length=1, pattern=r"^[-\w\._\(\)]+$" + ), + "resourceProviderNamespace": _SERIALIZER.url("resource_provider_namespace", resource_provider_namespace, "str"), + "parentResourcePath": _SERIALIZER.url("parent_resource_path", parent_resource_path, "str", skip_quote=True), + "resourceType": _SERIALIZER.url("resource_type", resource_type, "str", skip_quote=True), + "resourceName": _SERIALIZER.url("resource_name", resource_name, "str"), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), } _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] if content_type is not None: - _header_parameters['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') - _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') - - return HttpRequest( - method="PATCH", - url=_url, - params=_query_parameters, - headers=_header_parameters, - json=json, - content=content, - **kwargs - ) + _headers["Content-Type"] = _SERIALIZER.header("content_type", content_type, "str") + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="PATCH", url=_url, params=_params, headers=_headers, **kwargs) def build_resources_get_request( @@ -2405,1228 +2071,996 @@ def build_resources_get_request( api_version: str, **kwargs: Any ) -> HttpRequest: - accept = "application/json" + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + accept = _headers.pop("Accept", "application/json") + # Construct URL - _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{parentResourcePath}/{resourceType}/{resourceName}") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{parentResourcePath}/{resourceType}/{resourceName}", + ) # pylint: disable=line-too-long path_format_arguments = { - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._\(\)]+$'), - "resourceProviderNamespace": _SERIALIZER.url("resource_provider_namespace", resource_provider_namespace, 'str'), - "parentResourcePath": _SERIALIZER.url("parent_resource_path", parent_resource_path, 'str', skip_quote=True), - "resourceType": _SERIALIZER.url("resource_type", resource_type, 'str', skip_quote=True), - "resourceName": _SERIALIZER.url("resource_name", resource_name, 'str'), - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), + "resourceGroupName": _SERIALIZER.url( + "resource_group_name", resource_group_name, "str", max_length=90, min_length=1, pattern=r"^[-\w\._\(\)]+$" + ), + "resourceProviderNamespace": _SERIALIZER.url("resource_provider_namespace", resource_provider_namespace, "str"), + "parentResourcePath": _SERIALIZER.url("parent_resource_path", parent_resource_path, "str", skip_quote=True), + "resourceType": _SERIALIZER.url("resource_type", resource_type, "str", skip_quote=True), + "resourceName": _SERIALIZER.url("resource_name", resource_name, "str"), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), } _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') - - return HttpRequest( - method="GET", - url=_url, - params=_query_parameters, - headers=_header_parameters, - **kwargs - ) + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) + + +def build_resources_check_existence_by_id_request(resource_id: str, *, api_version: str, **kwargs: Any) -> HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + accept = _headers.pop("Accept", "application/json") -def build_resources_check_existence_by_id_request( - resource_id: str, - *, - api_version: str, - **kwargs: Any -) -> HttpRequest: - accept = "application/json" # Construct URL _url = kwargs.pop("template_url", "/{resourceId}") path_format_arguments = { - "resourceId": _SERIALIZER.url("resource_id", resource_id, 'str', skip_quote=True), + "resourceId": _SERIALIZER.url("resource_id", resource_id, "str", skip_quote=True), } _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') - - return HttpRequest( - method="HEAD", - url=_url, - params=_query_parameters, - headers=_header_parameters, - **kwargs - ) + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + return HttpRequest(method="HEAD", url=_url, params=_params, headers=_headers, **kwargs) + + +def build_resources_delete_by_id_request(resource_id: str, *, api_version: str, **kwargs: Any) -> HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + accept = _headers.pop("Accept", "application/json") -def build_resources_delete_by_id_request_initial( - resource_id: str, - *, - api_version: str, - **kwargs: Any -) -> HttpRequest: - accept = "application/json" # Construct URL _url = kwargs.pop("template_url", "/{resourceId}") path_format_arguments = { - "resourceId": _SERIALIZER.url("resource_id", resource_id, 'str', skip_quote=True), + "resourceId": _SERIALIZER.url("resource_id", resource_id, "str", skip_quote=True), } _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') - - return HttpRequest( - method="DELETE", - url=_url, - params=_query_parameters, - headers=_header_parameters, - **kwargs - ) + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + return HttpRequest(method="DELETE", url=_url, params=_params, headers=_headers, **kwargs) -def build_resources_create_or_update_by_id_request_initial( - resource_id: str, - *, - api_version: str, - json: JSONType = None, - content: Any = None, - **kwargs: Any -) -> HttpRequest: - content_type = kwargs.pop('content_type', None) # type: Optional[str] - accept = "application/json" +def build_resources_create_or_update_by_id_request(resource_id: str, *, api_version: str, **kwargs: Any) -> HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + accept = _headers.pop("Accept", "application/json") + # Construct URL _url = kwargs.pop("template_url", "/{resourceId}") path_format_arguments = { - "resourceId": _SERIALIZER.url("resource_id", resource_id, 'str', skip_quote=True), + "resourceId": _SERIALIZER.url("resource_id", resource_id, "str", skip_quote=True), } _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] if content_type is not None: - _header_parameters['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') - _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') - - return HttpRequest( - method="PUT", - url=_url, - params=_query_parameters, - headers=_header_parameters, - json=json, - content=content, - **kwargs - ) + _headers["Content-Type"] = _SERIALIZER.header("content_type", content_type, "str") + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + return HttpRequest(method="PUT", url=_url, params=_params, headers=_headers, **kwargs) -def build_resources_update_by_id_request_initial( - resource_id: str, - *, - api_version: str, - json: JSONType = None, - content: Any = None, - **kwargs: Any -) -> HttpRequest: - content_type = kwargs.pop('content_type', None) # type: Optional[str] - accept = "application/json" +def build_resources_update_by_id_request(resource_id: str, *, api_version: str, **kwargs: Any) -> HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + accept = _headers.pop("Accept", "application/json") + # Construct URL _url = kwargs.pop("template_url", "/{resourceId}") path_format_arguments = { - "resourceId": _SERIALIZER.url("resource_id", resource_id, 'str', skip_quote=True), + "resourceId": _SERIALIZER.url("resource_id", resource_id, "str", skip_quote=True), } _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] if content_type is not None: - _header_parameters['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') - _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') - - return HttpRequest( - method="PATCH", - url=_url, - params=_query_parameters, - headers=_header_parameters, - json=json, - content=content, - **kwargs - ) + _headers["Content-Type"] = _SERIALIZER.header("content_type", content_type, "str") + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + return HttpRequest(method="PATCH", url=_url, params=_params, headers=_headers, **kwargs) + + +def build_resources_get_by_id_request(resource_id: str, *, api_version: str, **kwargs: Any) -> HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + accept = _headers.pop("Accept", "application/json") -def build_resources_get_by_id_request( - resource_id: str, - *, - api_version: str, - **kwargs: Any -) -> HttpRequest: - accept = "application/json" # Construct URL _url = kwargs.pop("template_url", "/{resourceId}") path_format_arguments = { - "resourceId": _SERIALIZER.url("resource_id", resource_id, 'str', skip_quote=True), + "resourceId": _SERIALIZER.url("resource_id", resource_id, "str", skip_quote=True), } _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') - - return HttpRequest( - method="GET", - url=_url, - params=_query_parameters, - headers=_header_parameters, - **kwargs - ) + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) def build_resource_groups_check_existence_request( - resource_group_name: str, - subscription_id: str, - **kwargs: Any + resource_group_name: str, subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2021-04-01") # type: 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-04-01")) # type: str + accept = _headers.pop("Accept", "application/json") - accept = "application/json" # Construct URL _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}") path_format_arguments = { - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._\(\)]+$'), - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), + "resourceGroupName": _SERIALIZER.url( + "resource_group_name", resource_group_name, "str", max_length=90, min_length=1, pattern=r"^[-\w\._\(\)]+$" + ), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), } _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') - - return HttpRequest( - method="HEAD", - url=_url, - params=_query_parameters, - headers=_header_parameters, - **kwargs - ) + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="HEAD", url=_url, params=_params, headers=_headers, **kwargs) def build_resource_groups_create_or_update_request( - resource_group_name: str, - subscription_id: str, - *, - json: JSONType = None, - content: Any = None, - **kwargs: Any + resource_group_name: str, subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2021-04-01") # type: str - content_type = kwargs.pop('content_type', None) # type: Optional[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-04-01")) # type: str + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + accept = _headers.pop("Accept", "application/json") - accept = "application/json" # Construct URL _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}") path_format_arguments = { - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._\(\)]+$'), - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), + "resourceGroupName": _SERIALIZER.url( + "resource_group_name", resource_group_name, "str", max_length=90, min_length=1, pattern=r"^[-\w\._\(\)]+$" + ), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), } _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] if content_type is not None: - _header_parameters['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') - _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') - - return HttpRequest( - method="PUT", - url=_url, - params=_query_parameters, - headers=_header_parameters, - json=json, - content=content, - **kwargs - ) + _headers["Content-Type"] = _SERIALIZER.header("content_type", content_type, "str") + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + return HttpRequest(method="PUT", url=_url, params=_params, headers=_headers, **kwargs) -def build_resource_groups_delete_request_initial( - resource_group_name: str, - subscription_id: str, - *, - force_deletion_types: Optional[str] = None, - **kwargs: Any + +def build_resource_groups_delete_request( + resource_group_name: str, subscription_id: str, *, force_deletion_types: Optional[str] = None, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2021-04-01") # type: 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-04-01")) # type: str + accept = _headers.pop("Accept", "application/json") - accept = "application/json" # Construct URL _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}") path_format_arguments = { - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._\(\)]+$'), - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), + "resourceGroupName": _SERIALIZER.url( + "resource_group_name", resource_group_name, "str", max_length=90, min_length=1, pattern=r"^[-\w\._\(\)]+$" + ), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), } _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] if force_deletion_types is not None: - _query_parameters['forceDeletionTypes'] = _SERIALIZER.query("force_deletion_types", force_deletion_types, 'str') - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["forceDeletionTypes"] = _SERIALIZER.query("force_deletion_types", force_deletion_types, "str") + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') - - return HttpRequest( - method="DELETE", - url=_url, - params=_query_parameters, - headers=_header_parameters, - **kwargs - ) + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + return HttpRequest(method="DELETE", url=_url, params=_params, headers=_headers, **kwargs) -def build_resource_groups_get_request( - resource_group_name: str, - subscription_id: str, - **kwargs: Any -) -> HttpRequest: - api_version = kwargs.pop('api_version', "2021-04-01") # type: str - accept = "application/json" +def build_resource_groups_get_request(resource_group_name: str, subscription_id: str, **kwargs: Any) -> HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-04-01")) # type: str + accept = _headers.pop("Accept", "application/json") + # Construct URL _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}") path_format_arguments = { - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._\(\)]+$'), - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), + "resourceGroupName": _SERIALIZER.url( + "resource_group_name", resource_group_name, "str", max_length=90, min_length=1, pattern=r"^[-\w\._\(\)]+$" + ), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), } _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') - - return HttpRequest( - method="GET", - url=_url, - params=_query_parameters, - headers=_header_parameters, - **kwargs - ) + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) -def build_resource_groups_update_request( - resource_group_name: str, - subscription_id: str, - *, - json: JSONType = None, - content: Any = None, - **kwargs: Any -) -> HttpRequest: - api_version = kwargs.pop('api_version', "2021-04-01") # type: str - content_type = kwargs.pop('content_type', None) # type: Optional[str] - accept = "application/json" +def build_resource_groups_update_request(resource_group_name: str, subscription_id: str, **kwargs: Any) -> HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-04-01")) # type: str + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + accept = _headers.pop("Accept", "application/json") + # Construct URL _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}") path_format_arguments = { - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._\(\)]+$'), - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), + "resourceGroupName": _SERIALIZER.url( + "resource_group_name", resource_group_name, "str", max_length=90, min_length=1, pattern=r"^[-\w\._\(\)]+$" + ), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), } _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] if content_type is not None: - _header_parameters['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') - _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') - - return HttpRequest( - method="PATCH", - url=_url, - params=_query_parameters, - headers=_header_parameters, - json=json, - content=content, - **kwargs - ) + _headers["Content-Type"] = _SERIALIZER.header("content_type", content_type, "str") + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + return HttpRequest(method="PATCH", url=_url, params=_params, headers=_headers, **kwargs) -def build_resource_groups_export_template_request_initial( - subscription_id: str, - resource_group_name: str, - *, - json: JSONType = None, - content: Any = None, - **kwargs: Any + +def build_resource_groups_export_template_request( + resource_group_name: str, subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2021-04-01") # type: str - content_type = kwargs.pop('content_type', None) # type: Optional[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-04-01")) # type: str + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + accept = _headers.pop("Accept", "application/json") - accept = "application/json" # Construct URL - _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/exportTemplate") + _url = kwargs.pop( + "template_url", "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/exportTemplate" + ) path_format_arguments = { - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url( + "resource_group_name", resource_group_name, "str", max_length=90, min_length=1 + ), } _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] if content_type is not None: - _header_parameters['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') - _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') - - return HttpRequest( - method="POST", - url=_url, - params=_query_parameters, - headers=_header_parameters, - json=json, - content=content, - **kwargs - ) + _headers["Content-Type"] = _SERIALIZER.header("content_type", content_type, "str") + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="POST", url=_url, params=_params, headers=_headers, **kwargs) def build_resource_groups_list_request( - subscription_id: str, - *, - filter: Optional[str] = None, - top: Optional[int] = None, - **kwargs: Any + subscription_id: str, *, filter: Optional[str] = None, top: Optional[int] = None, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2021-04-01") # type: 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-04-01")) # type: str + accept = _headers.pop("Accept", "application/json") - accept = "application/json" # Construct URL _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourcegroups") path_format_arguments = { - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), } _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] if filter is not None: - _query_parameters['$filter'] = _SERIALIZER.query("filter", filter, 'str') + _params["$filter"] = _SERIALIZER.query("filter", filter, "str") if top is not None: - _query_parameters['$top'] = _SERIALIZER.query("top", top, 'int') - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["$top"] = _SERIALIZER.query("top", top, "int") + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') - - return HttpRequest( - method="GET", - url=_url, - params=_query_parameters, - headers=_header_parameters, - **kwargs - ) + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) -def build_tags_delete_value_request( - tag_name: str, - tag_value: str, - subscription_id: str, - **kwargs: Any -) -> HttpRequest: - api_version = kwargs.pop('api_version', "2021-04-01") # type: str - accept = "application/json" +def build_tags_delete_value_request(tag_name: str, tag_value: str, subscription_id: str, **kwargs: Any) -> HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-04-01")) # type: str + accept = _headers.pop("Accept", "application/json") + # Construct URL _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/tagNames/{tagName}/tagValues/{tagValue}") path_format_arguments = { - "tagName": _SERIALIZER.url("tag_name", tag_name, 'str'), - "tagValue": _SERIALIZER.url("tag_value", tag_value, 'str'), - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), + "tagName": _SERIALIZER.url("tag_name", tag_name, "str"), + "tagValue": _SERIALIZER.url("tag_value", tag_value, "str"), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), } _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') - - return HttpRequest( - method="DELETE", - url=_url, - params=_query_parameters, - headers=_header_parameters, - **kwargs - ) + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="DELETE", url=_url, params=_params, headers=_headers, **kwargs) def build_tags_create_or_update_value_request( - tag_name: str, - tag_value: str, - subscription_id: str, - **kwargs: Any + tag_name: str, tag_value: str, subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2021-04-01") # type: 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-04-01")) # type: str + accept = _headers.pop("Accept", "application/json") - accept = "application/json" # Construct URL _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/tagNames/{tagName}/tagValues/{tagValue}") path_format_arguments = { - "tagName": _SERIALIZER.url("tag_name", tag_name, 'str'), - "tagValue": _SERIALIZER.url("tag_value", tag_value, 'str'), - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), + "tagName": _SERIALIZER.url("tag_name", tag_name, "str"), + "tagValue": _SERIALIZER.url("tag_value", tag_value, "str"), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), } _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') - - return HttpRequest( - method="PUT", - url=_url, - params=_query_parameters, - headers=_header_parameters, - **kwargs - ) + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + return HttpRequest(method="PUT", url=_url, params=_params, headers=_headers, **kwargs) -def build_tags_create_or_update_request( - tag_name: str, - subscription_id: str, - **kwargs: Any -) -> HttpRequest: - api_version = kwargs.pop('api_version', "2021-04-01") # type: str - accept = "application/json" +def build_tags_create_or_update_request(tag_name: str, subscription_id: str, **kwargs: Any) -> HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-04-01")) # type: str + accept = _headers.pop("Accept", "application/json") + # Construct URL _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/tagNames/{tagName}") path_format_arguments = { - "tagName": _SERIALIZER.url("tag_name", tag_name, 'str'), - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), + "tagName": _SERIALIZER.url("tag_name", tag_name, "str"), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), } _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') - - return HttpRequest( - method="PUT", - url=_url, - params=_query_parameters, - headers=_header_parameters, - **kwargs - ) + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + return HttpRequest(method="PUT", url=_url, params=_params, headers=_headers, **kwargs) -def build_tags_delete_request( - tag_name: str, - subscription_id: str, - **kwargs: Any -) -> HttpRequest: - api_version = kwargs.pop('api_version', "2021-04-01") # type: str - accept = "application/json" +def build_tags_delete_request(tag_name: str, subscription_id: str, **kwargs: Any) -> HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-04-01")) # type: str + accept = _headers.pop("Accept", "application/json") + # Construct URL _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/tagNames/{tagName}") path_format_arguments = { - "tagName": _SERIALIZER.url("tag_name", tag_name, 'str'), - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), + "tagName": _SERIALIZER.url("tag_name", tag_name, "str"), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), } _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') - - return HttpRequest( - method="DELETE", - url=_url, - params=_query_parameters, - headers=_header_parameters, - **kwargs - ) + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + return HttpRequest(method="DELETE", url=_url, params=_params, headers=_headers, **kwargs) -def build_tags_list_request( - subscription_id: str, - **kwargs: Any -) -> HttpRequest: - api_version = kwargs.pop('api_version', "2021-04-01") # type: str - accept = "application/json" +def build_tags_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-04-01")) # type: str + accept = _headers.pop("Accept", "application/json") + # Construct URL _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/tagNames") path_format_arguments = { - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), } _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') - - return HttpRequest( - method="GET", - url=_url, - params=_query_parameters, - headers=_header_parameters, - **kwargs - ) + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) -def build_tags_create_or_update_at_scope_request( - scope: str, - *, - json: JSONType = None, - content: Any = None, - **kwargs: Any -) -> HttpRequest: - api_version = kwargs.pop('api_version', "2021-04-01") # type: str - content_type = kwargs.pop('content_type', None) # type: Optional[str] - accept = "application/json" +def build_tags_create_or_update_at_scope_request(scope: 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-04-01")) # type: str + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + accept = _headers.pop("Accept", "application/json") + # Construct URL _url = kwargs.pop("template_url", "/{scope}/providers/Microsoft.Resources/tags/default") path_format_arguments = { - "scope": _SERIALIZER.url("scope", scope, 'str', skip_quote=True), + "scope": _SERIALIZER.url("scope", scope, "str", skip_quote=True), } _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] if content_type is not None: - _header_parameters['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') - _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') - - return HttpRequest( - method="PUT", - url=_url, - params=_query_parameters, - headers=_header_parameters, - json=json, - content=content, - **kwargs - ) + _headers["Content-Type"] = _SERIALIZER.header("content_type", content_type, "str") + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + return HttpRequest(method="PUT", url=_url, params=_params, headers=_headers, **kwargs) -def build_tags_update_at_scope_request( - scope: str, - *, - json: JSONType = None, - content: Any = None, - **kwargs: Any -) -> HttpRequest: - api_version = kwargs.pop('api_version', "2021-04-01") # type: str - content_type = kwargs.pop('content_type', None) # type: Optional[str] - accept = "application/json" +def build_tags_update_at_scope_request(scope: 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-04-01")) # type: str + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + accept = _headers.pop("Accept", "application/json") + # Construct URL _url = kwargs.pop("template_url", "/{scope}/providers/Microsoft.Resources/tags/default") path_format_arguments = { - "scope": _SERIALIZER.url("scope", scope, 'str', skip_quote=True), + "scope": _SERIALIZER.url("scope", scope, "str", skip_quote=True), } _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] if content_type is not None: - _header_parameters['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') - _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') - - return HttpRequest( - method="PATCH", - url=_url, - params=_query_parameters, - headers=_header_parameters, - json=json, - content=content, - **kwargs - ) + _headers["Content-Type"] = _SERIALIZER.header("content_type", content_type, "str") + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + return HttpRequest(method="PATCH", url=_url, params=_params, headers=_headers, **kwargs) -def build_tags_get_at_scope_request( - scope: str, - **kwargs: Any -) -> HttpRequest: - api_version = kwargs.pop('api_version', "2021-04-01") # type: str - accept = "application/json" +def build_tags_get_at_scope_request(scope: 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-04-01")) # type: str + accept = _headers.pop("Accept", "application/json") + # Construct URL _url = kwargs.pop("template_url", "/{scope}/providers/Microsoft.Resources/tags/default") path_format_arguments = { - "scope": _SERIALIZER.url("scope", scope, 'str', skip_quote=True), + "scope": _SERIALIZER.url("scope", scope, "str", skip_quote=True), } _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') - - return HttpRequest( - method="GET", - url=_url, - params=_query_parameters, - headers=_header_parameters, - **kwargs - ) + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) -def build_tags_delete_at_scope_request( - scope: str, - **kwargs: Any -) -> HttpRequest: - api_version = kwargs.pop('api_version', "2021-04-01") # type: str - accept = "application/json" +def build_tags_delete_at_scope_request(scope: 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-04-01")) # type: str + accept = _headers.pop("Accept", "application/json") + # Construct URL _url = kwargs.pop("template_url", "/{scope}/providers/Microsoft.Resources/tags/default") path_format_arguments = { - "scope": _SERIALIZER.url("scope", scope, 'str', skip_quote=True), + "scope": _SERIALIZER.url("scope", scope, "str", skip_quote=True), } _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') - - return HttpRequest( - method="DELETE", - url=_url, - params=_query_parameters, - headers=_header_parameters, - **kwargs - ) + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="DELETE", url=_url, params=_params, headers=_headers, **kwargs) def build_deployment_operations_get_at_scope_request( - scope: str, - deployment_name: str, - operation_id: str, - **kwargs: Any + scope: str, deployment_name: str, operation_id: str, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2021-04-01") # type: 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-04-01")) # type: str + accept = _headers.pop("Accept", "application/json") - accept = "application/json" # Construct URL - _url = kwargs.pop("template_url", "/{scope}/providers/Microsoft.Resources/deployments/{deploymentName}/operations/{operationId}") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", "/{scope}/providers/Microsoft.Resources/deployments/{deploymentName}/operations/{operationId}" + ) # pylint: disable=line-too-long path_format_arguments = { - "scope": _SERIALIZER.url("scope", scope, 'str', skip_quote=True), - "deploymentName": _SERIALIZER.url("deployment_name", deployment_name, 'str', max_length=64, min_length=1, pattern=r'^[-\w\._\(\)]+$'), - "operationId": _SERIALIZER.url("operation_id", operation_id, 'str'), + "scope": _SERIALIZER.url("scope", scope, "str", skip_quote=True), + "deploymentName": _SERIALIZER.url( + "deployment_name", deployment_name, "str", max_length=64, min_length=1, pattern=r"^[-\w\._\(\)]+$" + ), + "operationId": _SERIALIZER.url("operation_id", operation_id, "str"), } _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') - - return HttpRequest( - method="GET", - url=_url, - params=_query_parameters, - headers=_header_parameters, - **kwargs - ) + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) def build_deployment_operations_list_at_scope_request( - scope: str, - deployment_name: str, - *, - top: Optional[int] = None, - **kwargs: Any + scope: str, deployment_name: str, *, top: Optional[int] = None, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2021-04-01") # type: 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-04-01")) # type: str + accept = _headers.pop("Accept", "application/json") - accept = "application/json" # Construct URL _url = kwargs.pop("template_url", "/{scope}/providers/Microsoft.Resources/deployments/{deploymentName}/operations") path_format_arguments = { - "scope": _SERIALIZER.url("scope", scope, 'str', skip_quote=True), - "deploymentName": _SERIALIZER.url("deployment_name", deployment_name, 'str', max_length=64, min_length=1, pattern=r'^[-\w\._\(\)]+$'), + "scope": _SERIALIZER.url("scope", scope, "str", skip_quote=True), + "deploymentName": _SERIALIZER.url( + "deployment_name", deployment_name, "str", max_length=64, min_length=1, pattern=r"^[-\w\._\(\)]+$" + ), } _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] if top is not None: - _query_parameters['$top'] = _SERIALIZER.query("top", top, 'int') - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["$top"] = _SERIALIZER.query("top", top, "int") + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') - - return HttpRequest( - method="GET", - url=_url, - params=_query_parameters, - headers=_header_parameters, - **kwargs - ) + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) def build_deployment_operations_get_at_tenant_scope_request( - deployment_name: str, - operation_id: str, - **kwargs: Any + deployment_name: str, operation_id: str, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2021-04-01") # type: 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-04-01")) # type: str + accept = _headers.pop("Accept", "application/json") - accept = "application/json" # Construct URL - _url = kwargs.pop("template_url", "/providers/Microsoft.Resources/deployments/{deploymentName}/operations/{operationId}") + _url = kwargs.pop( + "template_url", "/providers/Microsoft.Resources/deployments/{deploymentName}/operations/{operationId}" + ) path_format_arguments = { - "deploymentName": _SERIALIZER.url("deployment_name", deployment_name, 'str', max_length=64, min_length=1, pattern=r'^[-\w\._\(\)]+$'), - "operationId": _SERIALIZER.url("operation_id", operation_id, 'str'), + "deploymentName": _SERIALIZER.url( + "deployment_name", deployment_name, "str", max_length=64, min_length=1, pattern=r"^[-\w\._\(\)]+$" + ), + "operationId": _SERIALIZER.url("operation_id", operation_id, "str"), } _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') - - return HttpRequest( - method="GET", - url=_url, - params=_query_parameters, - headers=_header_parameters, - **kwargs - ) + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) def build_deployment_operations_list_at_tenant_scope_request( - deployment_name: str, - *, - top: Optional[int] = None, - **kwargs: Any + deployment_name: str, *, top: Optional[int] = None, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2021-04-01") # type: 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-04-01")) # type: str + accept = _headers.pop("Accept", "application/json") - accept = "application/json" # Construct URL _url = kwargs.pop("template_url", "/providers/Microsoft.Resources/deployments/{deploymentName}/operations") path_format_arguments = { - "deploymentName": _SERIALIZER.url("deployment_name", deployment_name, 'str', max_length=64, min_length=1, pattern=r'^[-\w\._\(\)]+$'), + "deploymentName": _SERIALIZER.url( + "deployment_name", deployment_name, "str", max_length=64, min_length=1, pattern=r"^[-\w\._\(\)]+$" + ), } _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] if top is not None: - _query_parameters['$top'] = _SERIALIZER.query("top", top, 'int') - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["$top"] = _SERIALIZER.query("top", top, "int") + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') - - return HttpRequest( - method="GET", - url=_url, - params=_query_parameters, - headers=_header_parameters, - **kwargs - ) + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) def build_deployment_operations_get_at_management_group_scope_request( - group_id: str, - deployment_name: str, - operation_id: str, - **kwargs: Any + group_id: str, deployment_name: str, operation_id: str, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2021-04-01") # type: 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-04-01")) # type: str + accept = _headers.pop("Accept", "application/json") - accept = "application/json" # Construct URL - _url = kwargs.pop("template_url", "/providers/Microsoft.Management/managementGroups/{groupId}/providers/Microsoft.Resources/deployments/{deploymentName}/operations/{operationId}") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", + "/providers/Microsoft.Management/managementGroups/{groupId}/providers/Microsoft.Resources/deployments/{deploymentName}/operations/{operationId}", + ) # pylint: disable=line-too-long path_format_arguments = { - "groupId": _SERIALIZER.url("group_id", group_id, 'str', max_length=90, min_length=1), - "deploymentName": _SERIALIZER.url("deployment_name", deployment_name, 'str', max_length=64, min_length=1, pattern=r'^[-\w\._\(\)]+$'), - "operationId": _SERIALIZER.url("operation_id", operation_id, 'str'), + "groupId": _SERIALIZER.url("group_id", group_id, "str", max_length=90, min_length=1), + "deploymentName": _SERIALIZER.url( + "deployment_name", deployment_name, "str", max_length=64, min_length=1, pattern=r"^[-\w\._\(\)]+$" + ), + "operationId": _SERIALIZER.url("operation_id", operation_id, "str"), } _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') - - return HttpRequest( - method="GET", - url=_url, - params=_query_parameters, - headers=_header_parameters, - **kwargs - ) + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) def build_deployment_operations_list_at_management_group_scope_request( - group_id: str, - deployment_name: str, - *, - top: Optional[int] = None, - **kwargs: Any + group_id: str, deployment_name: str, *, top: Optional[int] = None, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2021-04-01") # type: 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-04-01")) # type: str + accept = _headers.pop("Accept", "application/json") - accept = "application/json" # Construct URL - _url = kwargs.pop("template_url", "/providers/Microsoft.Management/managementGroups/{groupId}/providers/Microsoft.Resources/deployments/{deploymentName}/operations") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", + "/providers/Microsoft.Management/managementGroups/{groupId}/providers/Microsoft.Resources/deployments/{deploymentName}/operations", + ) # pylint: disable=line-too-long path_format_arguments = { - "groupId": _SERIALIZER.url("group_id", group_id, 'str', max_length=90, min_length=1), - "deploymentName": _SERIALIZER.url("deployment_name", deployment_name, 'str', max_length=64, min_length=1, pattern=r'^[-\w\._\(\)]+$'), + "groupId": _SERIALIZER.url("group_id", group_id, "str", max_length=90, min_length=1), + "deploymentName": _SERIALIZER.url( + "deployment_name", deployment_name, "str", max_length=64, min_length=1, pattern=r"^[-\w\._\(\)]+$" + ), } _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] if top is not None: - _query_parameters['$top'] = _SERIALIZER.query("top", top, 'int') - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["$top"] = _SERIALIZER.query("top", top, "int") + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') - - return HttpRequest( - method="GET", - url=_url, - params=_query_parameters, - headers=_header_parameters, - **kwargs - ) + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) def build_deployment_operations_get_at_subscription_scope_request( - deployment_name: str, - operation_id: str, - subscription_id: str, - **kwargs: Any + deployment_name: str, operation_id: str, subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2021-04-01") # type: 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-04-01")) # type: str + accept = _headers.pop("Accept", "application/json") - accept = "application/json" # Construct URL - _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/providers/Microsoft.Resources/deployments/{deploymentName}/operations/{operationId}") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/providers/Microsoft.Resources/deployments/{deploymentName}/operations/{operationId}", + ) # pylint: disable=line-too-long path_format_arguments = { - "deploymentName": _SERIALIZER.url("deployment_name", deployment_name, 'str', max_length=64, min_length=1, pattern=r'^[-\w\._\(\)]+$'), - "operationId": _SERIALIZER.url("operation_id", operation_id, 'str'), - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), + "deploymentName": _SERIALIZER.url( + "deployment_name", deployment_name, "str", max_length=64, min_length=1, pattern=r"^[-\w\._\(\)]+$" + ), + "operationId": _SERIALIZER.url("operation_id", operation_id, "str"), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), } _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') - - return HttpRequest( - method="GET", - url=_url, - params=_query_parameters, - headers=_header_parameters, - **kwargs - ) + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) def build_deployment_operations_list_at_subscription_scope_request( - deployment_name: str, - subscription_id: str, - *, - top: Optional[int] = None, - **kwargs: Any + deployment_name: str, subscription_id: str, *, top: Optional[int] = None, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2021-04-01") # type: 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-04-01")) # type: str + accept = _headers.pop("Accept", "application/json") - accept = "application/json" # Construct URL - _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/providers/Microsoft.Resources/deployments/{deploymentName}/operations") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/providers/Microsoft.Resources/deployments/{deploymentName}/operations", + ) # pylint: disable=line-too-long path_format_arguments = { - "deploymentName": _SERIALIZER.url("deployment_name", deployment_name, 'str', max_length=64, min_length=1, pattern=r'^[-\w\._\(\)]+$'), - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), + "deploymentName": _SERIALIZER.url( + "deployment_name", deployment_name, "str", max_length=64, min_length=1, pattern=r"^[-\w\._\(\)]+$" + ), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), } _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] if top is not None: - _query_parameters['$top'] = _SERIALIZER.query("top", top, 'int') - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["$top"] = _SERIALIZER.query("top", top, "int") + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') - - return HttpRequest( - method="GET", - url=_url, - params=_query_parameters, - headers=_header_parameters, - **kwargs - ) + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) def build_deployment_operations_get_request( - resource_group_name: str, - deployment_name: str, - operation_id: str, - subscription_id: str, - **kwargs: Any + resource_group_name: str, deployment_name: str, operation_id: str, subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2021-04-01") # type: 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-04-01")) # type: str + accept = _headers.pop("Accept", "application/json") - accept = "application/json" # Construct URL - _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/deployments/{deploymentName}/operations/{operationId}") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/deployments/{deploymentName}/operations/{operationId}", + ) # pylint: disable=line-too-long path_format_arguments = { - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._\(\)]+$'), - "deploymentName": _SERIALIZER.url("deployment_name", deployment_name, 'str', max_length=64, min_length=1, pattern=r'^[-\w\._\(\)]+$'), - "operationId": _SERIALIZER.url("operation_id", operation_id, 'str'), - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), + "resourceGroupName": _SERIALIZER.url( + "resource_group_name", resource_group_name, "str", max_length=90, min_length=1, pattern=r"^[-\w\._\(\)]+$" + ), + "deploymentName": _SERIALIZER.url( + "deployment_name", deployment_name, "str", max_length=64, min_length=1, pattern=r"^[-\w\._\(\)]+$" + ), + "operationId": _SERIALIZER.url("operation_id", operation_id, "str"), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), } _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') - - return HttpRequest( - method="GET", - url=_url, - params=_query_parameters, - headers=_header_parameters, - **kwargs - ) + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) def build_deployment_operations_list_request( - resource_group_name: str, - deployment_name: str, - subscription_id: str, - *, - top: Optional[int] = None, - **kwargs: Any + resource_group_name: str, deployment_name: str, subscription_id: str, *, top: Optional[int] = None, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2021-04-01") # type: 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-04-01")) # type: str + accept = _headers.pop("Accept", "application/json") - accept = "application/json" # Construct URL - _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/deployments/{deploymentName}/operations") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/deployments/{deploymentName}/operations", + ) # pylint: disable=line-too-long path_format_arguments = { - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._\(\)]+$'), - "deploymentName": _SERIALIZER.url("deployment_name", deployment_name, 'str', max_length=64, min_length=1, pattern=r'^[-\w\._\(\)]+$'), - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), + "resourceGroupName": _SERIALIZER.url( + "resource_group_name", resource_group_name, "str", max_length=90, min_length=1, pattern=r"^[-\w\._\(\)]+$" + ), + "deploymentName": _SERIALIZER.url( + "deployment_name", deployment_name, "str", max_length=64, min_length=1, pattern=r"^[-\w\._\(\)]+$" + ), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), } _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] if top is not None: - _query_parameters['$top'] = _SERIALIZER.query("top", top, 'int') - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["$top"] = _SERIALIZER.query("top", top, "int") + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') - - return HttpRequest( - method="GET", - url=_url, - params=_query_parameters, - headers=_header_parameters, - **kwargs - ) + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) -class Operations(object): - """Operations operations. - You should not instantiate this class directly. Instead, you should create a Client instance that - instantiates it for you and attaches it as an attribute. +class Operations: + """ + .. warning:: + **DO NOT** instantiate this class directly. - :ivar models: Alias to model classes used in this operation group. - :type models: ~azure.mgmt.resource.resources.v2021_04_01.models - :param client: Client for service requests. - :param config: Configuration of service client. - :param serializer: An object model serializer. - :param deserializer: An object model deserializer. + Instead, you should access the following operations through + :class:`~azure.mgmt.resource.resources.v2021_04_01.ResourceManagementClient`'s + :attr:`operations` attribute. """ models = _models - def __init__(self, client, config, serializer, deserializer): - self._client = client - self._serialize = serializer - self._deserialize = deserializer - self._config = config + def __init__(self, *args, **kwargs): + input_args = list(args) + self._client = input_args.pop(0) if input_args else kwargs.pop("client") + self._config = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") @distributed_trace - def list( - self, - **kwargs: Any - ) -> Iterable["_models.OperationListResult"]: + def list(self, **kwargs: Any) -> Iterable["_models.Operation"]: """Lists all of the available Microsoft.Resources REST API operations. :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either OperationListResult or the result of cls(response) + :return: An iterator like instance of either Operation or the result of cls(response) :rtype: - ~azure.core.paging.ItemPaged[~azure.mgmt.resource.resources.v2021_04_01.models.OperationListResult] - :raises: ~azure.core.exceptions.HttpResponseError + ~azure.core.paging.ItemPaged[~azure.mgmt.resource.resources.v2021_04_01.models.Operation] + :raises ~azure.core.exceptions.HttpResponseError: """ - api_version = kwargs.pop('api_version', "2021-04-01") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-04-01")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[_models.OperationListResult] - cls = kwargs.pop('cls', None) # type: ClsType["_models.OperationListResult"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) + def prepare_request(next_link=None): if not next_link: - + request = build_operations_list_request( api_version=api_version, - template_url=self.list.metadata['url'], + template_url=self.list.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore else: - - request = build_operations_list_request( - template_url=next_link, - ) + # make call to next link with the client's api-version + _parsed_next_link = urlparse(next_link) + _next_request_params = case_insensitive_dict(parse_qs(_parsed_next_link.query)) + _next_request_params["api-version"] = self._config.api_version + request = HttpRequest("GET", urljoin(next_link, _parsed_next_link.path), params=_next_request_params) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore request.method = "GET" return request @@ -3640,10 +3074,8 @@ def extract_data(pipeline_response): def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) response = pipeline_response.http_response @@ -3653,62 +3085,62 @@ def get_next(next_link=None): return pipeline_response + return ItemPaged(get_next, extract_data) + + list.metadata = {"url": "/providers/Microsoft.Resources/operations"} # type: ignore - return ItemPaged( - get_next, extract_data - ) - list.metadata = {'url': "/providers/Microsoft.Resources/operations"} # type: ignore -class DeploymentsOperations(object): # pylint: disable=too-many-public-methods - """DeploymentsOperations operations. - You should not instantiate this class directly. Instead, you should create a Client instance that - instantiates it for you and attaches it as an attribute. +class DeploymentsOperations: # pylint: disable=too-many-public-methods + """ + .. warning:: + **DO NOT** instantiate this class directly. - :ivar models: Alias to model classes used in this operation group. - :type models: ~azure.mgmt.resource.resources.v2021_04_01.models - :param client: Client for service requests. - :param config: Configuration of service client. - :param serializer: An object model serializer. - :param deserializer: An object model deserializer. + Instead, you should access the following operations through + :class:`~azure.mgmt.resource.resources.v2021_04_01.ResourceManagementClient`'s + :attr:`deployments` attribute. """ models = _models - def __init__(self, client, config, serializer, deserializer): - self._client = client - self._serialize = serializer - self._deserialize = deserializer - self._config = config + def __init__(self, *args, **kwargs): + input_args = list(args) + self._client = input_args.pop(0) if input_args else kwargs.pop("client") + self._config = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") def _delete_at_scope_initial( # pylint: disable=inconsistent-return-statements - self, - scope: str, - deployment_name: str, - **kwargs: Any + self, scope: str, deployment_name: str, **kwargs: Any ) -> None: - cls = kwargs.pop('cls', None) # type: ClsType[None] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + 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', "2021-04-01") # type: str + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-04-01")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[None] - - request = build_deployments_delete_at_scope_request_initial( + request = build_deployments_delete_at_scope_request( scope=scope, deployment_name=deployment_name, api_version=api_version, - template_url=self._delete_at_scope_initial.metadata['url'], + template_url=self._delete_at_scope_initial.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [202, 204]: @@ -3718,16 +3150,10 @@ def _delete_at_scope_initial( # pylint: disable=inconsistent-return-statements if cls: return cls(pipeline_response, None, {}) - _delete_at_scope_initial.metadata = {'url': "/{scope}/providers/Microsoft.Resources/deployments/{deploymentName}"} # type: ignore - + _delete_at_scope_initial.metadata = {"url": "/{scope}/providers/Microsoft.Resources/deployments/{deploymentName}"} # type: ignore @distributed_trace - def begin_delete_at_scope( # pylint: disable=inconsistent-return-statements - self, - scope: str, - deployment_name: str, - **kwargs: Any - ) -> LROPoller[None]: + def begin_delete_at_scope(self, scope: str, deployment_name: str, **kwargs: Any) -> LROPoller[None]: """Deletes a deployment from the deployment history. A template deployment that is currently running cannot be deleted. Deleting a template @@ -3738,9 +3164,9 @@ def begin_delete_at_scope( # pylint: disable=inconsistent-return-statements process finishes, the URI in the Location header returns a status of 204 on success. If the asynchronous request failed, the URI in the Location header returns an error-level status code. - :param scope: The resource scope. + :param scope: The resource scope. Required. :type scope: str - :param deployment_name: The name of the deployment. + :param deployment_name: The name of the deployment. Required. :type deployment_name: str :keyword callable cls: A custom type or function that will be passed the direct response :keyword str continuation_token: A continuation token to restart a poller from a saved state. @@ -3752,86 +3178,91 @@ def begin_delete_at_scope( # pylint: disable=inconsistent-return-statements Retry-After header is present. :return: An instance of LROPoller that returns either None or the result of cls(response) :rtype: ~azure.core.polling.LROPoller[None] - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - api_version = kwargs.pop('api_version', "2021-04-01") # type: str - polling = kwargs.pop('polling', True) # type: Union[bool, PollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType[None] - lro_delay = kwargs.pop( - 'polling_interval', - self._config.polling_interval - ) - cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-04-01")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[None] + polling = kwargs.pop("polling", True) # type: Union[bool, PollingMethod] + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token = kwargs.pop("continuation_token", None) # type: Optional[str] if cont_token is None: - raw_result = self._delete_at_scope_initial( + raw_result = self._delete_at_scope_initial( # type: ignore scope=scope, deployment_name=deployment_name, api_version=api_version, - cls=lambda x,y,z: x, + cls=lambda x, y, z: x, + headers=_headers, + params=_params, **kwargs ) - kwargs.pop('error_map', None) + kwargs.pop("error_map", None) - def get_long_running_output(pipeline_response): + def get_long_running_output(pipeline_response): # pylint: disable=inconsistent-return-statements if cls: return cls(pipeline_response, None, {}) - - if polling is True: polling_method = ARMPolling(lro_delay, **kwargs) - elif polling is False: polling_method = NoPolling() - else: polling_method = polling + if polling is True: + polling_method = cast(PollingMethod, ARMPolling(lro_delay, **kwargs)) # type: PollingMethod + elif polling is False: + polling_method = cast(PollingMethod, NoPolling()) + else: + polling_method = polling if cont_token: return LROPoller.from_continuation_token( polling_method=polling_method, continuation_token=cont_token, client=self._client, - deserialization_callback=get_long_running_output + deserialization_callback=get_long_running_output, ) return LROPoller(self._client, raw_result, get_long_running_output, polling_method) - begin_delete_at_scope.metadata = {'url': "/{scope}/providers/Microsoft.Resources/deployments/{deploymentName}"} # type: ignore + begin_delete_at_scope.metadata = {"url": "/{scope}/providers/Microsoft.Resources/deployments/{deploymentName}"} # type: ignore @distributed_trace - def check_existence_at_scope( - self, - scope: str, - deployment_name: str, - **kwargs: Any - ) -> bool: + def check_existence_at_scope(self, scope: str, deployment_name: str, **kwargs: Any) -> bool: """Checks whether the deployment exists. - :param scope: The resource scope. + :param scope: The resource scope. Required. :type scope: str - :param deployment_name: The name of the deployment. + :param deployment_name: The name of the deployment. Required. :type deployment_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: bool, or the result of cls(response) + :return: bool or the result of cls(response) :rtype: bool - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType[None] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) - api_version = kwargs.pop('api_version', "2021-04-01") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-04-01")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[None] - request = build_deployments_check_existence_at_scope_request( scope=scope, deployment_name=deployment_name, api_version=api_version, - template_url=self.check_existence_at_scope.metadata['url'], + template_url=self.check_existence_at_scope.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [204, 404]: @@ -3842,43 +3273,52 @@ def check_existence_at_scope( return cls(pipeline_response, None, {}) return 200 <= response.status_code <= 299 - check_existence_at_scope.metadata = {'url': "/{scope}/providers/Microsoft.Resources/deployments/{deploymentName}"} # type: ignore - + check_existence_at_scope.metadata = {"url": "/{scope}/providers/Microsoft.Resources/deployments/{deploymentName}"} # type: ignore def _create_or_update_at_scope_initial( - self, - scope: str, - deployment_name: str, - parameters: "_models.Deployment", - **kwargs: Any - ) -> "_models.DeploymentExtended": - cls = kwargs.pop('cls', None) # type: ClsType["_models.DeploymentExtended"] + self, scope: str, deployment_name: str, parameters: Union[_models.Deployment, IO], **kwargs: Any + ) -> _models.DeploymentExtended: error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', "2021-04-01") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-04-01")) # type: str + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.DeploymentExtended] - _json = self._serialize.body(parameters, 'Deployment') + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(parameters, (IO, bytes)): + _content = parameters + else: + _json = self._serialize.body(parameters, "Deployment") - request = build_deployments_create_or_update_at_scope_request_initial( + request = build_deployments_create_or_update_at_scope_request( scope=scope, deployment_name=deployment_name, api_version=api_version, content_type=content_type, json=_json, - template_url=self._create_or_update_at_scope_initial.metadata['url'], + content=_content, + template_url=self._create_or_update_at_scope_initial.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200, 201]: @@ -3886,37 +3326,41 @@ def _create_or_update_at_scope_initial( raise HttpResponseError(response=response, error_format=ARMErrorFormat) if response.status_code == 200: - deserialized = self._deserialize('DeploymentExtended', pipeline_response) + deserialized = self._deserialize("DeploymentExtended", pipeline_response) if response.status_code == 201: - deserialized = self._deserialize('DeploymentExtended', pipeline_response) + deserialized = self._deserialize("DeploymentExtended", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - _create_or_update_at_scope_initial.metadata = {'url': "/{scope}/providers/Microsoft.Resources/deployments/{deploymentName}"} # type: ignore + _create_or_update_at_scope_initial.metadata = {"url": "/{scope}/providers/Microsoft.Resources/deployments/{deploymentName}"} # type: ignore - - @distributed_trace + @overload def begin_create_or_update_at_scope( self, scope: str, deployment_name: str, - parameters: "_models.Deployment", + parameters: _models.Deployment, + *, + content_type: str = "application/json", **kwargs: Any - ) -> LROPoller["_models.DeploymentExtended"]: + ) -> LROPoller[_models.DeploymentExtended]: """Deploys resources at a given scope. You can provide the template and parameters directly in the request or link to JSON files. - :param scope: The resource scope. + :param scope: The resource scope. Required. :type scope: str - :param deployment_name: The name of the deployment. + :param deployment_name: The name of the deployment. Required. :type deployment_name: str - :param parameters: Additional parameters supplied to the operation. + :param parameters: Additional parameters supplied to the operation. Required. :type parameters: ~azure.mgmt.resource.resources.v2021_04_01.models.Deployment + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str :keyword callable cls: A custom type or function that will be passed the direct response :keyword str continuation_token: A continuation token to restart a poller from a saved state. :keyword polling: By default, your polling method will be ARMPolling. Pass in False for this @@ -3929,114 +3373,179 @@ def begin_create_or_update_at_scope( cls(response) :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.resource.resources.v2021_04_01.models.DeploymentExtended] - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - api_version = kwargs.pop('api_version', "2021-04-01") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] - polling = kwargs.pop('polling', True) # type: Union[bool, PollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType["_models.DeploymentExtended"] - lro_delay = kwargs.pop( - 'polling_interval', - self._config.polling_interval - ) - cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] + + @overload + def begin_create_or_update_at_scope( + self, scope: str, deployment_name: str, parameters: IO, *, content_type: str = "application/json", **kwargs: Any + ) -> LROPoller[_models.DeploymentExtended]: + """Deploys resources at a given scope. + + You can provide the template and parameters directly in the request or link to JSON files. + + :param scope: The resource scope. Required. + :type scope: str + :param deployment_name: The name of the deployment. Required. + :type deployment_name: str + :param parameters: Additional parameters supplied to the operation. Required. + :type parameters: IO + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be ARMPolling. Pass in False for this + operation to not poll, or pass in your own initialized polling object for a personal polling + strategy. + :paramtype polling: bool or ~azure.core.polling.PollingMethod + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of LROPoller that returns either DeploymentExtended or the result of + cls(response) + :rtype: + ~azure.core.polling.LROPoller[~azure.mgmt.resource.resources.v2021_04_01.models.DeploymentExtended] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace + def begin_create_or_update_at_scope( + self, scope: str, deployment_name: str, parameters: Union[_models.Deployment, IO], **kwargs: Any + ) -> LROPoller[_models.DeploymentExtended]: + """Deploys resources at a given scope. + + You can provide the template and parameters directly in the request or link to JSON files. + + :param scope: The resource scope. Required. + :type scope: str + :param deployment_name: The name of the deployment. Required. + :type deployment_name: str + :param parameters: Additional parameters supplied to the operation. Is either a model type or a + IO type. Required. + :type parameters: ~azure.mgmt.resource.resources.v2021_04_01.models.Deployment or IO + :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. + Default value is None. + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be ARMPolling. Pass in False for this + operation to not poll, or pass in your own initialized polling object for a personal polling + strategy. + :paramtype polling: bool or ~azure.core.polling.PollingMethod + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of LROPoller that returns either DeploymentExtended or the result of + cls(response) + :rtype: + ~azure.core.polling.LROPoller[~azure.mgmt.resource.resources.v2021_04_01.models.DeploymentExtended] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _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-04-01")) # type: str + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.DeploymentExtended] + polling = kwargs.pop("polling", True) # type: Union[bool, PollingMethod] + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token = kwargs.pop("continuation_token", None) # type: Optional[str] if cont_token is None: - raw_result = self._create_or_update_at_scope_initial( + raw_result = self._create_or_update_at_scope_initial( # type: ignore scope=scope, deployment_name=deployment_name, parameters=parameters, api_version=api_version, content_type=content_type, - cls=lambda x,y,z: x, + cls=lambda x, y, z: x, + headers=_headers, + params=_params, **kwargs ) - kwargs.pop('error_map', None) + kwargs.pop("error_map", None) def get_long_running_output(pipeline_response): - response = pipeline_response.http_response - deserialized = self._deserialize('DeploymentExtended', pipeline_response) + deserialized = self._deserialize("DeploymentExtended", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - - if polling is True: polling_method = ARMPolling(lro_delay, **kwargs) - elif polling is False: polling_method = NoPolling() - else: polling_method = polling + if polling is True: + polling_method = cast(PollingMethod, ARMPolling(lro_delay, **kwargs)) # type: PollingMethod + elif polling is False: + polling_method = cast(PollingMethod, NoPolling()) + else: + polling_method = polling if cont_token: return LROPoller.from_continuation_token( polling_method=polling_method, continuation_token=cont_token, client=self._client, - deserialization_callback=get_long_running_output + deserialization_callback=get_long_running_output, ) return LROPoller(self._client, raw_result, get_long_running_output, polling_method) - begin_create_or_update_at_scope.metadata = {'url': "/{scope}/providers/Microsoft.Resources/deployments/{deploymentName}"} # type: ignore + begin_create_or_update_at_scope.metadata = {"url": "/{scope}/providers/Microsoft.Resources/deployments/{deploymentName}"} # type: ignore @distributed_trace - def get_at_scope( - self, - scope: str, - deployment_name: str, - **kwargs: Any - ) -> "_models.DeploymentExtended": + def get_at_scope(self, scope: str, deployment_name: str, **kwargs: Any) -> _models.DeploymentExtended: """Gets a deployment. - :param scope: The resource scope. + :param scope: The resource scope. Required. :type scope: str - :param deployment_name: The name of the deployment. + :param deployment_name: The name of the deployment. Required. :type deployment_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: DeploymentExtended, or the result of cls(response) + :return: DeploymentExtended or the result of cls(response) :rtype: ~azure.mgmt.resource.resources.v2021_04_01.models.DeploymentExtended - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.DeploymentExtended"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + 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', "2021-04-01") # type: str + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-04-01")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[_models.DeploymentExtended] - request = build_deployments_get_at_scope_request( scope=scope, deployment_name=deployment_name, api_version=api_version, - template_url=self.get_at_scope.metadata['url'], + template_url=self.get_at_scope.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) - deserialized = self._deserialize('DeploymentExtended', pipeline_response) + deserialized = self._deserialize("DeploymentExtended", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - get_at_scope.metadata = {'url': "/{scope}/providers/Microsoft.Resources/deployments/{deploymentName}"} # type: ignore - + get_at_scope.metadata = {"url": "/{scope}/providers/Microsoft.Resources/deployments/{deploymentName}"} # type: ignore @distributed_trace def cancel_at_scope( # pylint: disable=inconsistent-return-statements - self, - scope: str, - deployment_name: str, - **kwargs: Any + self, scope: str, deployment_name: str, **kwargs: Any ) -> None: """Cancels a currently running template deployment. @@ -4045,38 +3554,44 @@ def cancel_at_scope( # pylint: disable=inconsistent-return-statements deployment stops the currently running template deployment and leaves the resources partially deployed. - :param scope: The resource scope. + :param scope: The resource scope. Required. :type scope: str - :param deployment_name: The name of the deployment. + :param deployment_name: The name of the deployment. Required. :type deployment_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: None, or the result of cls(response) + :return: None or the result of cls(response) :rtype: None - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType[None] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) - api_version = kwargs.pop('api_version', "2021-04-01") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-04-01")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[None] - request = build_deployments_cancel_at_scope_request( scope=scope, deployment_name=deployment_name, api_version=api_version, - template_url=self.cancel_at_scope.metadata['url'], + template_url=self.cancel_at_scope.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [204]: @@ -4086,43 +3601,52 @@ def cancel_at_scope( # pylint: disable=inconsistent-return-statements if cls: return cls(pipeline_response, None, {}) - cancel_at_scope.metadata = {'url': "/{scope}/providers/Microsoft.Resources/deployments/{deploymentName}/cancel"} # type: ignore - + cancel_at_scope.metadata = {"url": "/{scope}/providers/Microsoft.Resources/deployments/{deploymentName}/cancel"} # type: ignore def _validate_at_scope_initial( - self, - scope: str, - deployment_name: str, - parameters: "_models.Deployment", - **kwargs: Any - ) -> Optional["_models.DeploymentValidateResult"]: - cls = kwargs.pop('cls', None) # type: ClsType[Optional["_models.DeploymentValidateResult"]] + self, scope: str, deployment_name: str, parameters: Union[_models.Deployment, IO], **kwargs: Any + ) -> Optional[_models.DeploymentValidateResult]: error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', "2021-04-01") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-04-01")) # type: str + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[Optional[_models.DeploymentValidateResult]] - _json = self._serialize.body(parameters, 'Deployment') + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(parameters, (IO, bytes)): + _content = parameters + else: + _json = self._serialize.body(parameters, "Deployment") - request = build_deployments_validate_at_scope_request_initial( + request = build_deployments_validate_at_scope_request( scope=scope, deployment_name=deployment_name, api_version=api_version, content_type=content_type, json=_json, - template_url=self._validate_at_scope_initial.metadata['url'], + content=_content, + template_url=self._validate_at_scope_initial.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200, 202, 400]: @@ -4131,36 +3655,40 @@ def _validate_at_scope_initial( deserialized = None if response.status_code == 200: - deserialized = self._deserialize('DeploymentValidateResult', pipeline_response) + deserialized = self._deserialize("DeploymentValidateResult", pipeline_response) if response.status_code == 400: - deserialized = self._deserialize('DeploymentValidateResult', pipeline_response) + deserialized = self._deserialize("DeploymentValidateResult", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - _validate_at_scope_initial.metadata = {'url': "/{scope}/providers/Microsoft.Resources/deployments/{deploymentName}/validate"} # type: ignore + _validate_at_scope_initial.metadata = {"url": "/{scope}/providers/Microsoft.Resources/deployments/{deploymentName}/validate"} # type: ignore - - @distributed_trace + @overload def begin_validate_at_scope( self, scope: str, deployment_name: str, - parameters: "_models.Deployment", + parameters: _models.Deployment, + *, + content_type: str = "application/json", **kwargs: Any - ) -> LROPoller["_models.DeploymentValidateResult"]: + ) -> LROPoller[_models.DeploymentValidateResult]: """Validates whether the specified template is syntactically correct and will be accepted by Azure Resource Manager.. - :param scope: The resource scope. + :param scope: The resource scope. Required. :type scope: str - :param deployment_name: The name of the deployment. + :param deployment_name: The name of the deployment. Required. :type deployment_name: str - :param parameters: Parameters to validate. + :param parameters: Parameters to validate. Required. :type parameters: ~azure.mgmt.resource.resources.v2021_04_01.models.Deployment + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str :keyword callable cls: A custom type or function that will be passed the direct response :keyword str continuation_token: A continuation token to restart a poller from a saved state. :keyword polling: By default, your polling method will be ARMPolling. Pass in False for this @@ -4173,119 +3701,182 @@ def begin_validate_at_scope( cls(response) :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.resource.resources.v2021_04_01.models.DeploymentValidateResult] - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - api_version = kwargs.pop('api_version', "2021-04-01") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] - polling = kwargs.pop('polling', True) # type: Union[bool, PollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType["_models.DeploymentValidateResult"] - lro_delay = kwargs.pop( - 'polling_interval', - self._config.polling_interval - ) - cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] + + @overload + def begin_validate_at_scope( + self, scope: str, deployment_name: str, parameters: IO, *, content_type: str = "application/json", **kwargs: Any + ) -> LROPoller[_models.DeploymentValidateResult]: + """Validates whether the specified template is syntactically correct and will be accepted by Azure + Resource Manager.. + + :param scope: The resource scope. Required. + :type scope: str + :param deployment_name: The name of the deployment. Required. + :type deployment_name: str + :param parameters: Parameters to validate. Required. + :type parameters: IO + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be ARMPolling. Pass in False for this + operation to not poll, or pass in your own initialized polling object for a personal polling + strategy. + :paramtype polling: bool or ~azure.core.polling.PollingMethod + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of LROPoller that returns either DeploymentValidateResult or the result of + cls(response) + :rtype: + ~azure.core.polling.LROPoller[~azure.mgmt.resource.resources.v2021_04_01.models.DeploymentValidateResult] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace + def begin_validate_at_scope( + self, scope: str, deployment_name: str, parameters: Union[_models.Deployment, IO], **kwargs: Any + ) -> LROPoller[_models.DeploymentValidateResult]: + """Validates whether the specified template is syntactically correct and will be accepted by Azure + Resource Manager.. + + :param scope: The resource scope. Required. + :type scope: str + :param deployment_name: The name of the deployment. Required. + :type deployment_name: str + :param parameters: Parameters to validate. Is either a model type or a IO type. Required. + :type parameters: ~azure.mgmt.resource.resources.v2021_04_01.models.Deployment or IO + :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. + Default value is None. + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be ARMPolling. Pass in False for this + operation to not poll, or pass in your own initialized polling object for a personal polling + strategy. + :paramtype polling: bool or ~azure.core.polling.PollingMethod + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of LROPoller that returns either DeploymentValidateResult or the result of + cls(response) + :rtype: + ~azure.core.polling.LROPoller[~azure.mgmt.resource.resources.v2021_04_01.models.DeploymentValidateResult] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _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-04-01")) # type: str + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.DeploymentValidateResult] + polling = kwargs.pop("polling", True) # type: Union[bool, PollingMethod] + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token = kwargs.pop("continuation_token", None) # type: Optional[str] if cont_token is None: - raw_result = self._validate_at_scope_initial( + raw_result = self._validate_at_scope_initial( # type: ignore scope=scope, deployment_name=deployment_name, parameters=parameters, api_version=api_version, content_type=content_type, - cls=lambda x,y,z: x, + cls=lambda x, y, z: x, + headers=_headers, + params=_params, **kwargs ) - kwargs.pop('error_map', None) + kwargs.pop("error_map", None) def get_long_running_output(pipeline_response): - response = pipeline_response.http_response - deserialized = self._deserialize('DeploymentValidateResult', pipeline_response) + deserialized = self._deserialize("DeploymentValidateResult", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - - if polling is True: polling_method = ARMPolling(lro_delay, **kwargs) - elif polling is False: polling_method = NoPolling() - else: polling_method = polling + if polling is True: + polling_method = cast(PollingMethod, ARMPolling(lro_delay, **kwargs)) # type: PollingMethod + elif polling is False: + polling_method = cast(PollingMethod, NoPolling()) + else: + polling_method = polling if cont_token: return LROPoller.from_continuation_token( polling_method=polling_method, continuation_token=cont_token, client=self._client, - deserialization_callback=get_long_running_output + deserialization_callback=get_long_running_output, ) return LROPoller(self._client, raw_result, get_long_running_output, polling_method) - begin_validate_at_scope.metadata = {'url': "/{scope}/providers/Microsoft.Resources/deployments/{deploymentName}/validate"} # type: ignore + begin_validate_at_scope.metadata = {"url": "/{scope}/providers/Microsoft.Resources/deployments/{deploymentName}/validate"} # type: ignore @distributed_trace def export_template_at_scope( - self, - scope: str, - deployment_name: str, - **kwargs: Any - ) -> "_models.DeploymentExportResult": + self, scope: str, deployment_name: str, **kwargs: Any + ) -> _models.DeploymentExportResult: """Exports the template used for specified deployment. - :param scope: The resource scope. + :param scope: The resource scope. Required. :type scope: str - :param deployment_name: The name of the deployment. + :param deployment_name: The name of the deployment. Required. :type deployment_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: DeploymentExportResult, or the result of cls(response) + :return: DeploymentExportResult or the result of cls(response) :rtype: ~azure.mgmt.resource.resources.v2021_04_01.models.DeploymentExportResult - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.DeploymentExportResult"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) - api_version = kwargs.pop('api_version', "2021-04-01") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-04-01")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[_models.DeploymentExportResult] - request = build_deployments_export_template_at_scope_request( scope=scope, deployment_name=deployment_name, api_version=api_version, - template_url=self.export_template_at_scope.metadata['url'], + template_url=self.export_template_at_scope.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) - deserialized = self._deserialize('DeploymentExportResult', pipeline_response) + deserialized = self._deserialize("DeploymentExportResult", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - export_template_at_scope.metadata = {'url': "/{scope}/providers/Microsoft.Resources/deployments/{deploymentName}/exportTemplate"} # type: ignore - + export_template_at_scope.metadata = {"url": "/{scope}/providers/Microsoft.Resources/deployments/{deploymentName}/exportTemplate"} # type: ignore @distributed_trace def list_at_scope( - self, - scope: str, - filter: Optional[str] = None, - top: Optional[int] = None, - **kwargs: Any - ) -> Iterable["_models.DeploymentListResult"]: + self, scope: str, filter: Optional[str] = None, top: Optional[int] = None, **kwargs: Any + ) -> Iterable["_models.DeploymentExtended"]: """Get all the deployments at the given scope. - :param scope: The resource scope. + :param scope: The resource scope. Required. :type scope: str :param filter: The filter to apply on the operation. For example, you can use $filter=provisioningState eq '{state}'. Default value is None. @@ -4294,40 +3885,48 @@ def list_at_scope( value is None. :type top: int :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either DeploymentListResult or the result of - cls(response) + :return: An iterator like instance of either DeploymentExtended or the result of cls(response) :rtype: - ~azure.core.paging.ItemPaged[~azure.mgmt.resource.resources.v2021_04_01.models.DeploymentListResult] - :raises: ~azure.core.exceptions.HttpResponseError + ~azure.core.paging.ItemPaged[~azure.mgmt.resource.resources.v2021_04_01.models.DeploymentExtended] + :raises ~azure.core.exceptions.HttpResponseError: """ - api_version = kwargs.pop('api_version', "2021-04-01") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-04-01")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[_models.DeploymentListResult] - cls = kwargs.pop('cls', None) # type: ClsType["_models.DeploymentListResult"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) + def prepare_request(next_link=None): if not next_link: - + request = build_deployments_list_at_scope_request( scope=scope, - api_version=api_version, filter=filter, top=top, - template_url=self.list_at_scope.metadata['url'], + api_version=api_version, + template_url=self.list_at_scope.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore else: - - request = build_deployments_list_at_scope_request( - scope=scope, - template_url=next_link, - ) + # make call to next link with the client's api-version + _parsed_next_link = urlparse(next_link) + _next_request_params = case_insensitive_dict(parse_qs(_parsed_next_link.query)) + _next_request_params["api-version"] = self._config.api_version + request = HttpRequest("GET", urljoin(next_link, _parsed_next_link.path), params=_next_request_params) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore request.method = "GET" return request @@ -4341,10 +3940,8 @@ def extract_data(pipeline_response): def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) response = pipeline_response.http_response @@ -4354,39 +3951,41 @@ def get_next(next_link=None): return pipeline_response + return ItemPaged(get_next, extract_data) - return ItemPaged( - get_next, extract_data - ) - list_at_scope.metadata = {'url': "/{scope}/providers/Microsoft.Resources/deployments/"} # type: ignore + list_at_scope.metadata = {"url": "/{scope}/providers/Microsoft.Resources/deployments/"} # type: ignore def _delete_at_tenant_scope_initial( # pylint: disable=inconsistent-return-statements - self, - deployment_name: str, - **kwargs: Any + self, deployment_name: str, **kwargs: Any ) -> None: - cls = kwargs.pop('cls', None) # type: ClsType[None] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) - api_version = kwargs.pop('api_version', "2021-04-01") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - request = build_deployments_delete_at_tenant_scope_request_initial( + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-04-01")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[None] + + request = build_deployments_delete_at_tenant_scope_request( deployment_name=deployment_name, api_version=api_version, - template_url=self._delete_at_tenant_scope_initial.metadata['url'], + template_url=self._delete_at_tenant_scope_initial.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [202, 204]: @@ -4396,15 +3995,10 @@ def _delete_at_tenant_scope_initial( # pylint: disable=inconsistent-return-stat if cls: return cls(pipeline_response, None, {}) - _delete_at_tenant_scope_initial.metadata = {'url': "/providers/Microsoft.Resources/deployments/{deploymentName}"} # type: ignore - + _delete_at_tenant_scope_initial.metadata = {"url": "/providers/Microsoft.Resources/deployments/{deploymentName}"} # type: ignore @distributed_trace - def begin_delete_at_tenant_scope( # pylint: disable=inconsistent-return-statements - self, - deployment_name: str, - **kwargs: Any - ) -> LROPoller[None]: + def begin_delete_at_tenant_scope(self, deployment_name: str, **kwargs: Any) -> LROPoller[None]: """Deletes a deployment from the deployment history. A template deployment that is currently running cannot be deleted. Deleting a template @@ -4415,7 +4009,7 @@ def begin_delete_at_tenant_scope( # pylint: disable=inconsistent-return-stateme process finishes, the URI in the Location header returns a status of 204 on success. If the asynchronous request failed, the URI in the Location header returns an error-level status code. - :param deployment_name: The name of the deployment. + :param deployment_name: The name of the deployment. Required. :type deployment_name: str :keyword callable cls: A custom type or function that will be passed the direct response :keyword str continuation_token: A continuation token to restart a poller from a saved state. @@ -4427,81 +4021,87 @@ def begin_delete_at_tenant_scope( # pylint: disable=inconsistent-return-stateme Retry-After header is present. :return: An instance of LROPoller that returns either None or the result of cls(response) :rtype: ~azure.core.polling.LROPoller[None] - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - api_version = kwargs.pop('api_version', "2021-04-01") # type: str - polling = kwargs.pop('polling', True) # type: Union[bool, PollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType[None] - lro_delay = kwargs.pop( - 'polling_interval', - self._config.polling_interval - ) - cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-04-01")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[None] + polling = kwargs.pop("polling", True) # type: Union[bool, PollingMethod] + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token = kwargs.pop("continuation_token", None) # type: Optional[str] if cont_token is None: - raw_result = self._delete_at_tenant_scope_initial( + raw_result = self._delete_at_tenant_scope_initial( # type: ignore deployment_name=deployment_name, api_version=api_version, - cls=lambda x,y,z: x, + cls=lambda x, y, z: x, + headers=_headers, + params=_params, **kwargs ) - kwargs.pop('error_map', None) + kwargs.pop("error_map", None) - def get_long_running_output(pipeline_response): + def get_long_running_output(pipeline_response): # pylint: disable=inconsistent-return-statements if cls: return cls(pipeline_response, None, {}) - - if polling is True: polling_method = ARMPolling(lro_delay, **kwargs) - elif polling is False: polling_method = NoPolling() - else: polling_method = polling + if polling is True: + polling_method = cast(PollingMethod, ARMPolling(lro_delay, **kwargs)) # type: PollingMethod + elif polling is False: + polling_method = cast(PollingMethod, NoPolling()) + else: + polling_method = polling if cont_token: return LROPoller.from_continuation_token( polling_method=polling_method, continuation_token=cont_token, client=self._client, - deserialization_callback=get_long_running_output + deserialization_callback=get_long_running_output, ) return LROPoller(self._client, raw_result, get_long_running_output, polling_method) - begin_delete_at_tenant_scope.metadata = {'url': "/providers/Microsoft.Resources/deployments/{deploymentName}"} # type: ignore + begin_delete_at_tenant_scope.metadata = {"url": "/providers/Microsoft.Resources/deployments/{deploymentName}"} # type: ignore @distributed_trace - def check_existence_at_tenant_scope( - self, - deployment_name: str, - **kwargs: Any - ) -> bool: + def check_existence_at_tenant_scope(self, deployment_name: str, **kwargs: Any) -> bool: """Checks whether the deployment exists. - :param deployment_name: The name of the deployment. + :param deployment_name: The name of the deployment. Required. :type deployment_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: bool, or the result of cls(response) + :return: bool or the result of cls(response) :rtype: bool - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType[None] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + 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', "2021-04-01") # type: str + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-04-01")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[None] - request = build_deployments_check_existence_at_tenant_scope_request( deployment_name=deployment_name, api_version=api_version, - template_url=self.check_existence_at_tenant_scope.metadata['url'], + template_url=self.check_existence_at_tenant_scope.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [204, 404]: @@ -4512,41 +4112,51 @@ def check_existence_at_tenant_scope( return cls(pipeline_response, None, {}) return 200 <= response.status_code <= 299 - check_existence_at_tenant_scope.metadata = {'url': "/providers/Microsoft.Resources/deployments/{deploymentName}"} # type: ignore - + check_existence_at_tenant_scope.metadata = {"url": "/providers/Microsoft.Resources/deployments/{deploymentName}"} # type: ignore def _create_or_update_at_tenant_scope_initial( - self, - deployment_name: str, - parameters: "_models.ScopedDeployment", - **kwargs: Any - ) -> "_models.DeploymentExtended": - cls = kwargs.pop('cls', None) # type: ClsType["_models.DeploymentExtended"] + self, deployment_name: str, parameters: Union[_models.ScopedDeployment, IO], **kwargs: Any + ) -> _models.DeploymentExtended: error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', "2021-04-01") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-04-01")) # type: str + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.DeploymentExtended] - _json = self._serialize.body(parameters, 'ScopedDeployment') + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(parameters, (IO, bytes)): + _content = parameters + else: + _json = self._serialize.body(parameters, "ScopedDeployment") - request = build_deployments_create_or_update_at_tenant_scope_request_initial( + request = build_deployments_create_or_update_at_tenant_scope_request( deployment_name=deployment_name, api_version=api_version, content_type=content_type, json=_json, - template_url=self._create_or_update_at_tenant_scope_initial.metadata['url'], + content=_content, + template_url=self._create_or_update_at_tenant_scope_initial.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200, 201]: @@ -4554,34 +4164,38 @@ def _create_or_update_at_tenant_scope_initial( raise HttpResponseError(response=response, error_format=ARMErrorFormat) if response.status_code == 200: - deserialized = self._deserialize('DeploymentExtended', pipeline_response) + deserialized = self._deserialize("DeploymentExtended", pipeline_response) if response.status_code == 201: - deserialized = self._deserialize('DeploymentExtended', pipeline_response) + deserialized = self._deserialize("DeploymentExtended", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - _create_or_update_at_tenant_scope_initial.metadata = {'url': "/providers/Microsoft.Resources/deployments/{deploymentName}"} # type: ignore + _create_or_update_at_tenant_scope_initial.metadata = {"url": "/providers/Microsoft.Resources/deployments/{deploymentName}"} # type: ignore - - @distributed_trace + @overload def begin_create_or_update_at_tenant_scope( self, deployment_name: str, - parameters: "_models.ScopedDeployment", + parameters: _models.ScopedDeployment, + *, + content_type: str = "application/json", **kwargs: Any - ) -> LROPoller["_models.DeploymentExtended"]: + ) -> LROPoller[_models.DeploymentExtended]: """Deploys resources at tenant scope. You can provide the template and parameters directly in the request or link to JSON files. - :param deployment_name: The name of the deployment. + :param deployment_name: The name of the deployment. Required. :type deployment_name: str - :param parameters: Additional parameters supplied to the operation. + :param parameters: Additional parameters supplied to the operation. Required. :type parameters: ~azure.mgmt.resource.resources.v2021_04_01.models.ScopedDeployment + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str :keyword callable cls: A custom type or function that will be passed the direct response :keyword str continuation_token: A continuation token to restart a poller from a saved state. :keyword polling: By default, your polling method will be ARMPolling. Pass in False for this @@ -4594,108 +4208,171 @@ def begin_create_or_update_at_tenant_scope( cls(response) :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.resource.resources.v2021_04_01.models.DeploymentExtended] - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - api_version = kwargs.pop('api_version', "2021-04-01") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] - polling = kwargs.pop('polling', True) # type: Union[bool, PollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType["_models.DeploymentExtended"] - lro_delay = kwargs.pop( - 'polling_interval', - self._config.polling_interval - ) - cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] + + @overload + def begin_create_or_update_at_tenant_scope( + self, deployment_name: str, parameters: IO, *, content_type: str = "application/json", **kwargs: Any + ) -> LROPoller[_models.DeploymentExtended]: + """Deploys resources at tenant scope. + + You can provide the template and parameters directly in the request or link to JSON files. + + :param deployment_name: The name of the deployment. Required. + :type deployment_name: str + :param parameters: Additional parameters supplied to the operation. Required. + :type parameters: IO + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be ARMPolling. Pass in False for this + operation to not poll, or pass in your own initialized polling object for a personal polling + strategy. + :paramtype polling: bool or ~azure.core.polling.PollingMethod + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of LROPoller that returns either DeploymentExtended or the result of + cls(response) + :rtype: + ~azure.core.polling.LROPoller[~azure.mgmt.resource.resources.v2021_04_01.models.DeploymentExtended] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace + def begin_create_or_update_at_tenant_scope( + self, deployment_name: str, parameters: Union[_models.ScopedDeployment, IO], **kwargs: Any + ) -> LROPoller[_models.DeploymentExtended]: + """Deploys resources at tenant scope. + + You can provide the template and parameters directly in the request or link to JSON files. + + :param deployment_name: The name of the deployment. Required. + :type deployment_name: str + :param parameters: Additional parameters supplied to the operation. Is either a model type or a + IO type. Required. + :type parameters: ~azure.mgmt.resource.resources.v2021_04_01.models.ScopedDeployment or IO + :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. + Default value is None. + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be ARMPolling. Pass in False for this + operation to not poll, or pass in your own initialized polling object for a personal polling + strategy. + :paramtype polling: bool or ~azure.core.polling.PollingMethod + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of LROPoller that returns either DeploymentExtended or the result of + cls(response) + :rtype: + ~azure.core.polling.LROPoller[~azure.mgmt.resource.resources.v2021_04_01.models.DeploymentExtended] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _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-04-01")) # type: str + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.DeploymentExtended] + polling = kwargs.pop("polling", True) # type: Union[bool, PollingMethod] + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token = kwargs.pop("continuation_token", None) # type: Optional[str] if cont_token is None: - raw_result = self._create_or_update_at_tenant_scope_initial( + raw_result = self._create_or_update_at_tenant_scope_initial( # type: ignore deployment_name=deployment_name, parameters=parameters, api_version=api_version, content_type=content_type, - cls=lambda x,y,z: x, + cls=lambda x, y, z: x, + headers=_headers, + params=_params, **kwargs ) - kwargs.pop('error_map', None) + kwargs.pop("error_map", None) def get_long_running_output(pipeline_response): - response = pipeline_response.http_response - deserialized = self._deserialize('DeploymentExtended', pipeline_response) + deserialized = self._deserialize("DeploymentExtended", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - - if polling is True: polling_method = ARMPolling(lro_delay, **kwargs) - elif polling is False: polling_method = NoPolling() - else: polling_method = polling + if polling is True: + polling_method = cast(PollingMethod, ARMPolling(lro_delay, **kwargs)) # type: PollingMethod + elif polling is False: + polling_method = cast(PollingMethod, NoPolling()) + else: + polling_method = polling if cont_token: return LROPoller.from_continuation_token( polling_method=polling_method, continuation_token=cont_token, client=self._client, - deserialization_callback=get_long_running_output + deserialization_callback=get_long_running_output, ) return LROPoller(self._client, raw_result, get_long_running_output, polling_method) - begin_create_or_update_at_tenant_scope.metadata = {'url': "/providers/Microsoft.Resources/deployments/{deploymentName}"} # type: ignore + begin_create_or_update_at_tenant_scope.metadata = {"url": "/providers/Microsoft.Resources/deployments/{deploymentName}"} # type: ignore @distributed_trace - def get_at_tenant_scope( - self, - deployment_name: str, - **kwargs: Any - ) -> "_models.DeploymentExtended": + def get_at_tenant_scope(self, deployment_name: str, **kwargs: Any) -> _models.DeploymentExtended: """Gets a deployment. - :param deployment_name: The name of the deployment. + :param deployment_name: The name of the deployment. Required. :type deployment_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: DeploymentExtended, or the result of cls(response) + :return: DeploymentExtended or the result of cls(response) :rtype: ~azure.mgmt.resource.resources.v2021_04_01.models.DeploymentExtended - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.DeploymentExtended"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) - api_version = kwargs.pop('api_version', "2021-04-01") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-04-01")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[_models.DeploymentExtended] - request = build_deployments_get_at_tenant_scope_request( deployment_name=deployment_name, api_version=api_version, - template_url=self.get_at_tenant_scope.metadata['url'], + template_url=self.get_at_tenant_scope.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) - deserialized = self._deserialize('DeploymentExtended', pipeline_response) + deserialized = self._deserialize("DeploymentExtended", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - get_at_tenant_scope.metadata = {'url': "/providers/Microsoft.Resources/deployments/{deploymentName}"} # type: ignore - + get_at_tenant_scope.metadata = {"url": "/providers/Microsoft.Resources/deployments/{deploymentName}"} # type: ignore @distributed_trace def cancel_at_tenant_scope( # pylint: disable=inconsistent-return-statements - self, - deployment_name: str, - **kwargs: Any + self, deployment_name: str, **kwargs: Any ) -> None: """Cancels a currently running template deployment. @@ -4704,35 +4381,41 @@ def cancel_at_tenant_scope( # pylint: disable=inconsistent-return-statements deployment stops the currently running template deployment and leaves the resources partially deployed. - :param deployment_name: The name of the deployment. + :param deployment_name: The name of the deployment. Required. :type deployment_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: None, or the result of cls(response) + :return: None or the result of cls(response) :rtype: None - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType[None] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) - api_version = kwargs.pop('api_version', "2021-04-01") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-04-01")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[None] - request = build_deployments_cancel_at_tenant_scope_request( deployment_name=deployment_name, api_version=api_version, - template_url=self.cancel_at_tenant_scope.metadata['url'], + template_url=self.cancel_at_tenant_scope.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [204]: @@ -4742,41 +4425,51 @@ def cancel_at_tenant_scope( # pylint: disable=inconsistent-return-statements if cls: return cls(pipeline_response, None, {}) - cancel_at_tenant_scope.metadata = {'url': "/providers/Microsoft.Resources/deployments/{deploymentName}/cancel"} # type: ignore - + cancel_at_tenant_scope.metadata = {"url": "/providers/Microsoft.Resources/deployments/{deploymentName}/cancel"} # type: ignore def _validate_at_tenant_scope_initial( - self, - deployment_name: str, - parameters: "_models.ScopedDeployment", - **kwargs: Any - ) -> Optional["_models.DeploymentValidateResult"]: - cls = kwargs.pop('cls', None) # type: ClsType[Optional["_models.DeploymentValidateResult"]] + self, deployment_name: str, parameters: Union[_models.ScopedDeployment, IO], **kwargs: Any + ) -> Optional[_models.DeploymentValidateResult]: error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) - api_version = kwargs.pop('api_version', "2021-04-01") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - _json = self._serialize.body(parameters, 'ScopedDeployment') + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-04-01")) # type: str + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[Optional[_models.DeploymentValidateResult]] - request = build_deployments_validate_at_tenant_scope_request_initial( + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(parameters, (IO, bytes)): + _content = parameters + else: + _json = self._serialize.body(parameters, "ScopedDeployment") + + request = build_deployments_validate_at_tenant_scope_request( deployment_name=deployment_name, api_version=api_version, content_type=content_type, json=_json, - template_url=self._validate_at_tenant_scope_initial.metadata['url'], + content=_content, + template_url=self._validate_at_tenant_scope_initial.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200, 202, 400]: @@ -4785,33 +4478,37 @@ def _validate_at_tenant_scope_initial( deserialized = None if response.status_code == 200: - deserialized = self._deserialize('DeploymentValidateResult', pipeline_response) + deserialized = self._deserialize("DeploymentValidateResult", pipeline_response) if response.status_code == 400: - deserialized = self._deserialize('DeploymentValidateResult', pipeline_response) + deserialized = self._deserialize("DeploymentValidateResult", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - _validate_at_tenant_scope_initial.metadata = {'url': "/providers/Microsoft.Resources/deployments/{deploymentName}/validate"} # type: ignore - + _validate_at_tenant_scope_initial.metadata = {"url": "/providers/Microsoft.Resources/deployments/{deploymentName}/validate"} # type: ignore - @distributed_trace + @overload def begin_validate_at_tenant_scope( self, deployment_name: str, - parameters: "_models.ScopedDeployment", + parameters: _models.ScopedDeployment, + *, + content_type: str = "application/json", **kwargs: Any - ) -> LROPoller["_models.DeploymentValidateResult"]: + ) -> LROPoller[_models.DeploymentValidateResult]: """Validates whether the specified template is syntactically correct and will be accepted by Azure Resource Manager.. - :param deployment_name: The name of the deployment. + :param deployment_name: The name of the deployment. Required. :type deployment_name: str - :param parameters: Parameters to validate. + :param parameters: Parameters to validate. Required. :type parameters: ~azure.mgmt.resource.resources.v2021_04_01.models.ScopedDeployment + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str :keyword callable cls: A custom type or function that will be passed the direct response :keyword str continuation_token: A continuation token to restart a poller from a saved state. :keyword polling: By default, your polling method will be ARMPolling. Pass in False for this @@ -4824,82 +4521,154 @@ def begin_validate_at_tenant_scope( cls(response) :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.resource.resources.v2021_04_01.models.DeploymentValidateResult] - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - api_version = kwargs.pop('api_version', "2021-04-01") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] - polling = kwargs.pop('polling', True) # type: Union[bool, PollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType["_models.DeploymentValidateResult"] - lro_delay = kwargs.pop( - 'polling_interval', - self._config.polling_interval - ) - cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] + + @overload + def begin_validate_at_tenant_scope( + self, deployment_name: str, parameters: IO, *, content_type: str = "application/json", **kwargs: Any + ) -> LROPoller[_models.DeploymentValidateResult]: + """Validates whether the specified template is syntactically correct and will be accepted by Azure + Resource Manager.. + + :param deployment_name: The name of the deployment. Required. + :type deployment_name: str + :param parameters: Parameters to validate. Required. + :type parameters: IO + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be ARMPolling. Pass in False for this + operation to not poll, or pass in your own initialized polling object for a personal polling + strategy. + :paramtype polling: bool or ~azure.core.polling.PollingMethod + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of LROPoller that returns either DeploymentValidateResult or the result of + cls(response) + :rtype: + ~azure.core.polling.LROPoller[~azure.mgmt.resource.resources.v2021_04_01.models.DeploymentValidateResult] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace + def begin_validate_at_tenant_scope( + self, deployment_name: str, parameters: Union[_models.ScopedDeployment, IO], **kwargs: Any + ) -> LROPoller[_models.DeploymentValidateResult]: + """Validates whether the specified template is syntactically correct and will be accepted by Azure + Resource Manager.. + + :param deployment_name: The name of the deployment. Required. + :type deployment_name: str + :param parameters: Parameters to validate. Is either a model type or a IO type. Required. + :type parameters: ~azure.mgmt.resource.resources.v2021_04_01.models.ScopedDeployment or IO + :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. + Default value is None. + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be ARMPolling. Pass in False for this + operation to not poll, or pass in your own initialized polling object for a personal polling + strategy. + :paramtype polling: bool or ~azure.core.polling.PollingMethod + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of LROPoller that returns either DeploymentValidateResult or the result of + cls(response) + :rtype: + ~azure.core.polling.LROPoller[~azure.mgmt.resource.resources.v2021_04_01.models.DeploymentValidateResult] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _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-04-01")) # type: str + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.DeploymentValidateResult] + polling = kwargs.pop("polling", True) # type: Union[bool, PollingMethod] + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token = kwargs.pop("continuation_token", None) # type: Optional[str] if cont_token is None: - raw_result = self._validate_at_tenant_scope_initial( + raw_result = self._validate_at_tenant_scope_initial( # type: ignore deployment_name=deployment_name, parameters=parameters, api_version=api_version, content_type=content_type, - cls=lambda x,y,z: x, + cls=lambda x, y, z: x, + headers=_headers, + params=_params, **kwargs ) - kwargs.pop('error_map', None) + kwargs.pop("error_map", None) def get_long_running_output(pipeline_response): - response = pipeline_response.http_response - deserialized = self._deserialize('DeploymentValidateResult', pipeline_response) + deserialized = self._deserialize("DeploymentValidateResult", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - - if polling is True: polling_method = ARMPolling(lro_delay, **kwargs) - elif polling is False: polling_method = NoPolling() - else: polling_method = polling + if polling is True: + polling_method = cast(PollingMethod, ARMPolling(lro_delay, **kwargs)) # type: PollingMethod + elif polling is False: + polling_method = cast(PollingMethod, NoPolling()) + else: + polling_method = polling if cont_token: return LROPoller.from_continuation_token( polling_method=polling_method, continuation_token=cont_token, client=self._client, - deserialization_callback=get_long_running_output + deserialization_callback=get_long_running_output, ) return LROPoller(self._client, raw_result, get_long_running_output, polling_method) - begin_validate_at_tenant_scope.metadata = {'url': "/providers/Microsoft.Resources/deployments/{deploymentName}/validate"} # type: ignore + begin_validate_at_tenant_scope.metadata = {"url": "/providers/Microsoft.Resources/deployments/{deploymentName}/validate"} # type: ignore def _what_if_at_tenant_scope_initial( - self, - deployment_name: str, - parameters: "_models.ScopedDeploymentWhatIf", - **kwargs: Any - ) -> Optional["_models.WhatIfOperationResult"]: - cls = kwargs.pop('cls', None) # type: ClsType[Optional["_models.WhatIfOperationResult"]] + self, deployment_name: str, parameters: Union[_models.ScopedDeploymentWhatIf, IO], **kwargs: Any + ) -> Optional[_models.WhatIfOperationResult]: error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) - api_version = kwargs.pop('api_version', "2021-04-01") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - _json = self._serialize.body(parameters, 'ScopedDeploymentWhatIf') + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-04-01")) # type: str + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[Optional[_models.WhatIfOperationResult]] - request = build_deployments_what_if_at_tenant_scope_request_initial( + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(parameters, (IO, bytes)): + _content = parameters + else: + _json = self._serialize.body(parameters, "ScopedDeploymentWhatIf") + + request = build_deployments_what_if_at_tenant_scope_request( deployment_name=deployment_name, api_version=api_version, content_type=content_type, json=_json, - template_url=self._what_if_at_tenant_scope_initial.metadata['url'], + content=_content, + template_url=self._what_if_at_tenant_scope_initial.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200, 202]: @@ -4909,35 +4678,38 @@ def _what_if_at_tenant_scope_initial( deserialized = None response_headers = {} if response.status_code == 200: - deserialized = self._deserialize('WhatIfOperationResult', pipeline_response) + deserialized = self._deserialize("WhatIfOperationResult", pipeline_response) if response.status_code == 202: - response_headers['Location']=self._deserialize('str', response.headers.get('Location')) - response_headers['Retry-After']=self._deserialize('str', response.headers.get('Retry-After')) - + response_headers["Location"] = self._deserialize("str", response.headers.get("Location")) + response_headers["Retry-After"] = self._deserialize("str", response.headers.get("Retry-After")) if cls: return cls(pipeline_response, deserialized, response_headers) return deserialized - _what_if_at_tenant_scope_initial.metadata = {'url': "/providers/Microsoft.Resources/deployments/{deploymentName}/whatIf"} # type: ignore - + _what_if_at_tenant_scope_initial.metadata = {"url": "/providers/Microsoft.Resources/deployments/{deploymentName}/whatIf"} # type: ignore - @distributed_trace + @overload def begin_what_if_at_tenant_scope( self, deployment_name: str, - parameters: "_models.ScopedDeploymentWhatIf", + parameters: _models.ScopedDeploymentWhatIf, + *, + content_type: str = "application/json", **kwargs: Any - ) -> LROPoller["_models.WhatIfOperationResult"]: + ) -> LROPoller[_models.WhatIfOperationResult]: """Returns changes that will be made by the deployment if executed at the scope of the tenant group. - :param deployment_name: The name of the deployment. + :param deployment_name: The name of the deployment. Required. :type deployment_name: str - :param parameters: Parameters to validate. + :param parameters: Parameters to validate. Required. :type parameters: ~azure.mgmt.resource.resources.v2021_04_01.models.ScopedDeploymentWhatIf + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str :keyword callable cls: A custom type or function that will be passed the direct response :keyword str continuation_token: A continuation token to restart a poller from a saved state. :keyword polling: By default, your polling method will be ARMPolling. Pass in False for this @@ -4950,110 +4722,172 @@ def begin_what_if_at_tenant_scope( cls(response) :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.resource.resources.v2021_04_01.models.WhatIfOperationResult] - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - api_version = kwargs.pop('api_version', "2021-04-01") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] - polling = kwargs.pop('polling', True) # type: Union[bool, PollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType["_models.WhatIfOperationResult"] - lro_delay = kwargs.pop( - 'polling_interval', - self._config.polling_interval - ) - cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] + + @overload + def begin_what_if_at_tenant_scope( + self, deployment_name: str, parameters: IO, *, content_type: str = "application/json", **kwargs: Any + ) -> LROPoller[_models.WhatIfOperationResult]: + """Returns changes that will be made by the deployment if executed at the scope of the tenant + group. + + :param deployment_name: The name of the deployment. Required. + :type deployment_name: str + :param parameters: Parameters to validate. Required. + :type parameters: IO + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be ARMPolling. Pass in False for this + operation to not poll, or pass in your own initialized polling object for a personal polling + strategy. + :paramtype polling: bool or ~azure.core.polling.PollingMethod + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of LROPoller that returns either WhatIfOperationResult or the result of + cls(response) + :rtype: + ~azure.core.polling.LROPoller[~azure.mgmt.resource.resources.v2021_04_01.models.WhatIfOperationResult] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace + def begin_what_if_at_tenant_scope( + self, deployment_name: str, parameters: Union[_models.ScopedDeploymentWhatIf, IO], **kwargs: Any + ) -> LROPoller[_models.WhatIfOperationResult]: + """Returns changes that will be made by the deployment if executed at the scope of the tenant + group. + + :param deployment_name: The name of the deployment. Required. + :type deployment_name: str + :param parameters: Parameters to validate. Is either a model type or a IO type. Required. + :type parameters: ~azure.mgmt.resource.resources.v2021_04_01.models.ScopedDeploymentWhatIf or + IO + :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. + Default value is None. + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be ARMPolling. Pass in False for this + operation to not poll, or pass in your own initialized polling object for a personal polling + strategy. + :paramtype polling: bool or ~azure.core.polling.PollingMethod + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of LROPoller that returns either WhatIfOperationResult or the result of + cls(response) + :rtype: + ~azure.core.polling.LROPoller[~azure.mgmt.resource.resources.v2021_04_01.models.WhatIfOperationResult] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _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-04-01")) # type: str + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.WhatIfOperationResult] + polling = kwargs.pop("polling", True) # type: Union[bool, PollingMethod] + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token = kwargs.pop("continuation_token", None) # type: Optional[str] if cont_token is None: - raw_result = self._what_if_at_tenant_scope_initial( + raw_result = self._what_if_at_tenant_scope_initial( # type: ignore deployment_name=deployment_name, parameters=parameters, api_version=api_version, content_type=content_type, - cls=lambda x,y,z: x, + cls=lambda x, y, z: x, + headers=_headers, + params=_params, **kwargs ) - kwargs.pop('error_map', None) + kwargs.pop("error_map", None) def get_long_running_output(pipeline_response): - response = pipeline_response.http_response - deserialized = self._deserialize('WhatIfOperationResult', pipeline_response) + deserialized = self._deserialize("WhatIfOperationResult", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - - if polling is True: polling_method = ARMPolling(lro_delay, lro_options={'final-state-via': 'location'}, **kwargs) - elif polling is False: polling_method = NoPolling() - else: polling_method = polling + if polling is True: + polling_method = cast( + PollingMethod, ARMPolling(lro_delay, lro_options={"final-state-via": "location"}, **kwargs) + ) # type: PollingMethod + elif polling is False: + polling_method = cast(PollingMethod, NoPolling()) + else: + polling_method = polling if cont_token: return LROPoller.from_continuation_token( polling_method=polling_method, continuation_token=cont_token, client=self._client, - deserialization_callback=get_long_running_output + deserialization_callback=get_long_running_output, ) return LROPoller(self._client, raw_result, get_long_running_output, polling_method) - begin_what_if_at_tenant_scope.metadata = {'url': "/providers/Microsoft.Resources/deployments/{deploymentName}/whatIf"} # type: ignore + begin_what_if_at_tenant_scope.metadata = {"url": "/providers/Microsoft.Resources/deployments/{deploymentName}/whatIf"} # type: ignore @distributed_trace - def export_template_at_tenant_scope( - self, - deployment_name: str, - **kwargs: Any - ) -> "_models.DeploymentExportResult": + def export_template_at_tenant_scope(self, deployment_name: str, **kwargs: Any) -> _models.DeploymentExportResult: """Exports the template used for specified deployment. - :param deployment_name: The name of the deployment. + :param deployment_name: The name of the deployment. Required. :type deployment_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: DeploymentExportResult, or the result of cls(response) + :return: DeploymentExportResult or the result of cls(response) :rtype: ~azure.mgmt.resource.resources.v2021_04_01.models.DeploymentExportResult - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.DeploymentExportResult"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) - api_version = kwargs.pop('api_version', "2021-04-01") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-04-01")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[_models.DeploymentExportResult] - request = build_deployments_export_template_at_tenant_scope_request( deployment_name=deployment_name, api_version=api_version, - template_url=self.export_template_at_tenant_scope.metadata['url'], + template_url=self.export_template_at_tenant_scope.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) - deserialized = self._deserialize('DeploymentExportResult', pipeline_response) + deserialized = self._deserialize("DeploymentExportResult", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - export_template_at_tenant_scope.metadata = {'url': "/providers/Microsoft.Resources/deployments/{deploymentName}/exportTemplate"} # type: ignore - + export_template_at_tenant_scope.metadata = {"url": "/providers/Microsoft.Resources/deployments/{deploymentName}/exportTemplate"} # type: ignore @distributed_trace def list_at_tenant_scope( - self, - filter: Optional[str] = None, - top: Optional[int] = None, - **kwargs: Any - ) -> Iterable["_models.DeploymentListResult"]: + self, filter: Optional[str] = None, top: Optional[int] = None, **kwargs: Any + ) -> Iterable["_models.DeploymentExtended"]: """Get all the deployments at the tenant scope. :param filter: The filter to apply on the operation. For example, you can use @@ -5063,38 +4897,47 @@ def list_at_tenant_scope( value is None. :type top: int :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either DeploymentListResult or the result of - cls(response) + :return: An iterator like instance of either DeploymentExtended or the result of cls(response) :rtype: - ~azure.core.paging.ItemPaged[~azure.mgmt.resource.resources.v2021_04_01.models.DeploymentListResult] - :raises: ~azure.core.exceptions.HttpResponseError + ~azure.core.paging.ItemPaged[~azure.mgmt.resource.resources.v2021_04_01.models.DeploymentExtended] + :raises ~azure.core.exceptions.HttpResponseError: """ - api_version = kwargs.pop('api_version', "2021-04-01") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-04-01")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[_models.DeploymentListResult] - cls = kwargs.pop('cls', None) # type: ClsType["_models.DeploymentListResult"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) + def prepare_request(next_link=None): if not next_link: - + request = build_deployments_list_at_tenant_scope_request( - api_version=api_version, filter=filter, top=top, - template_url=self.list_at_tenant_scope.metadata['url'], + api_version=api_version, + template_url=self.list_at_tenant_scope.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore else: - - request = build_deployments_list_at_tenant_scope_request( - template_url=next_link, - ) + # make call to next link with the client's api-version + _parsed_next_link = urlparse(next_link) + _next_request_params = case_insensitive_dict(parse_qs(_parsed_next_link.query)) + _next_request_params["api-version"] = self._config.api_version + request = HttpRequest("GET", urljoin(next_link, _parsed_next_link.path), params=_next_request_params) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore request.method = "GET" return request @@ -5108,10 +4951,8 @@ def extract_data(pipeline_response): def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) response = pipeline_response.http_response @@ -5121,41 +4962,42 @@ def get_next(next_link=None): return pipeline_response + return ItemPaged(get_next, extract_data) - return ItemPaged( - get_next, extract_data - ) - list_at_tenant_scope.metadata = {'url': "/providers/Microsoft.Resources/deployments/"} # type: ignore + list_at_tenant_scope.metadata = {"url": "/providers/Microsoft.Resources/deployments/"} # type: ignore def _delete_at_management_group_scope_initial( # pylint: disable=inconsistent-return-statements - self, - group_id: str, - deployment_name: str, - **kwargs: Any + self, group_id: str, deployment_name: str, **kwargs: Any ) -> None: - cls = kwargs.pop('cls', None) # type: ClsType[None] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + 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', "2021-04-01") # type: str + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-04-01")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[None] - - request = build_deployments_delete_at_management_group_scope_request_initial( + request = build_deployments_delete_at_management_group_scope_request( group_id=group_id, deployment_name=deployment_name, api_version=api_version, - template_url=self._delete_at_management_group_scope_initial.metadata['url'], + template_url=self._delete_at_management_group_scope_initial.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [202, 204]: @@ -5165,15 +5007,11 @@ def _delete_at_management_group_scope_initial( # pylint: disable=inconsistent-r if cls: return cls(pipeline_response, None, {}) - _delete_at_management_group_scope_initial.metadata = {'url': "/providers/Microsoft.Management/managementGroups/{groupId}/providers/Microsoft.Resources/deployments/{deploymentName}"} # type: ignore - + _delete_at_management_group_scope_initial.metadata = {"url": "/providers/Microsoft.Management/managementGroups/{groupId}/providers/Microsoft.Resources/deployments/{deploymentName}"} # type: ignore @distributed_trace - def begin_delete_at_management_group_scope( # pylint: disable=inconsistent-return-statements - self, - group_id: str, - deployment_name: str, - **kwargs: Any + def begin_delete_at_management_group_scope( + self, group_id: str, deployment_name: str, **kwargs: Any ) -> LROPoller[None]: """Deletes a deployment from the deployment history. @@ -5185,9 +5023,9 @@ def begin_delete_at_management_group_scope( # pylint: disable=inconsistent-retu process finishes, the URI in the Location header returns a status of 204 on success. If the asynchronous request failed, the URI in the Location header returns an error-level status code. - :param group_id: The management group ID. + :param group_id: The management group ID. Required. :type group_id: str - :param deployment_name: The name of the deployment. + :param deployment_name: The name of the deployment. Required. :type deployment_name: str :keyword callable cls: A custom type or function that will be passed the direct response :keyword str continuation_token: A continuation token to restart a poller from a saved state. @@ -5199,86 +5037,91 @@ def begin_delete_at_management_group_scope( # pylint: disable=inconsistent-retu Retry-After header is present. :return: An instance of LROPoller that returns either None or the result of cls(response) :rtype: ~azure.core.polling.LROPoller[None] - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - api_version = kwargs.pop('api_version', "2021-04-01") # type: str - polling = kwargs.pop('polling', True) # type: Union[bool, PollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType[None] - lro_delay = kwargs.pop( - 'polling_interval', - self._config.polling_interval - ) - cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-04-01")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[None] + polling = kwargs.pop("polling", True) # type: Union[bool, PollingMethod] + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token = kwargs.pop("continuation_token", None) # type: Optional[str] if cont_token is None: - raw_result = self._delete_at_management_group_scope_initial( + raw_result = self._delete_at_management_group_scope_initial( # type: ignore group_id=group_id, deployment_name=deployment_name, api_version=api_version, - cls=lambda x,y,z: x, + cls=lambda x, y, z: x, + headers=_headers, + params=_params, **kwargs ) - kwargs.pop('error_map', None) + kwargs.pop("error_map", None) - def get_long_running_output(pipeline_response): + def get_long_running_output(pipeline_response): # pylint: disable=inconsistent-return-statements if cls: return cls(pipeline_response, None, {}) - - if polling is True: polling_method = ARMPolling(lro_delay, **kwargs) - elif polling is False: polling_method = NoPolling() - else: polling_method = polling + if polling is True: + polling_method = cast(PollingMethod, ARMPolling(lro_delay, **kwargs)) # type: PollingMethod + elif polling is False: + polling_method = cast(PollingMethod, NoPolling()) + else: + polling_method = polling if cont_token: return LROPoller.from_continuation_token( polling_method=polling_method, continuation_token=cont_token, client=self._client, - deserialization_callback=get_long_running_output + deserialization_callback=get_long_running_output, ) return LROPoller(self._client, raw_result, get_long_running_output, polling_method) - begin_delete_at_management_group_scope.metadata = {'url': "/providers/Microsoft.Management/managementGroups/{groupId}/providers/Microsoft.Resources/deployments/{deploymentName}"} # type: ignore + begin_delete_at_management_group_scope.metadata = {"url": "/providers/Microsoft.Management/managementGroups/{groupId}/providers/Microsoft.Resources/deployments/{deploymentName}"} # type: ignore @distributed_trace - def check_existence_at_management_group_scope( - self, - group_id: str, - deployment_name: str, - **kwargs: Any - ) -> bool: + def check_existence_at_management_group_scope(self, group_id: str, deployment_name: str, **kwargs: Any) -> bool: """Checks whether the deployment exists. - :param group_id: The management group ID. + :param group_id: The management group ID. Required. :type group_id: str - :param deployment_name: The name of the deployment. + :param deployment_name: The name of the deployment. Required. :type deployment_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: bool, or the result of cls(response) + :return: bool or the result of cls(response) :rtype: bool - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType[None] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + 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', "2021-04-01") # type: str + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-04-01")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[None] - request = build_deployments_check_existence_at_management_group_scope_request( group_id=group_id, deployment_name=deployment_name, api_version=api_version, - template_url=self.check_existence_at_management_group_scope.metadata['url'], + template_url=self.check_existence_at_management_group_scope.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [204, 404]: @@ -5289,43 +5132,52 @@ def check_existence_at_management_group_scope( return cls(pipeline_response, None, {}) return 200 <= response.status_code <= 299 - check_existence_at_management_group_scope.metadata = {'url': "/providers/Microsoft.Management/managementGroups/{groupId}/providers/Microsoft.Resources/deployments/{deploymentName}"} # type: ignore - + check_existence_at_management_group_scope.metadata = {"url": "/providers/Microsoft.Management/managementGroups/{groupId}/providers/Microsoft.Resources/deployments/{deploymentName}"} # type: ignore def _create_or_update_at_management_group_scope_initial( - self, - group_id: str, - deployment_name: str, - parameters: "_models.ScopedDeployment", - **kwargs: Any - ) -> "_models.DeploymentExtended": - cls = kwargs.pop('cls', None) # type: ClsType["_models.DeploymentExtended"] + self, group_id: str, deployment_name: str, parameters: Union[_models.ScopedDeployment, IO], **kwargs: Any + ) -> _models.DeploymentExtended: error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) - api_version = kwargs.pop('api_version', "2021-04-01") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - _json = self._serialize.body(parameters, 'ScopedDeployment') + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-04-01")) # type: str + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.DeploymentExtended] - request = build_deployments_create_or_update_at_management_group_scope_request_initial( + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(parameters, (IO, bytes)): + _content = parameters + else: + _json = self._serialize.body(parameters, "ScopedDeployment") + + request = build_deployments_create_or_update_at_management_group_scope_request( group_id=group_id, deployment_name=deployment_name, api_version=api_version, content_type=content_type, json=_json, - template_url=self._create_or_update_at_management_group_scope_initial.metadata['url'], + content=_content, + template_url=self._create_or_update_at_management_group_scope_initial.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200, 201]: @@ -5333,37 +5185,41 @@ def _create_or_update_at_management_group_scope_initial( raise HttpResponseError(response=response, error_format=ARMErrorFormat) if response.status_code == 200: - deserialized = self._deserialize('DeploymentExtended', pipeline_response) + deserialized = self._deserialize("DeploymentExtended", pipeline_response) if response.status_code == 201: - deserialized = self._deserialize('DeploymentExtended', pipeline_response) + deserialized = self._deserialize("DeploymentExtended", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - _create_or_update_at_management_group_scope_initial.metadata = {'url': "/providers/Microsoft.Management/managementGroups/{groupId}/providers/Microsoft.Resources/deployments/{deploymentName}"} # type: ignore - + _create_or_update_at_management_group_scope_initial.metadata = {"url": "/providers/Microsoft.Management/managementGroups/{groupId}/providers/Microsoft.Resources/deployments/{deploymentName}"} # type: ignore - @distributed_trace + @overload def begin_create_or_update_at_management_group_scope( self, group_id: str, deployment_name: str, - parameters: "_models.ScopedDeployment", + parameters: _models.ScopedDeployment, + *, + content_type: str = "application/json", **kwargs: Any - ) -> LROPoller["_models.DeploymentExtended"]: + ) -> LROPoller[_models.DeploymentExtended]: """Deploys resources at management group scope. You can provide the template and parameters directly in the request or link to JSON files. - :param group_id: The management group ID. + :param group_id: The management group ID. Required. :type group_id: str - :param deployment_name: The name of the deployment. + :param deployment_name: The name of the deployment. Required. :type deployment_name: str - :param parameters: Additional parameters supplied to the operation. + :param parameters: Additional parameters supplied to the operation. Required. :type parameters: ~azure.mgmt.resource.resources.v2021_04_01.models.ScopedDeployment + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str :keyword callable cls: A custom type or function that will be passed the direct response :keyword str continuation_token: A continuation token to restart a poller from a saved state. :keyword polling: By default, your polling method will be ARMPolling. Pass in False for this @@ -5376,114 +5232,187 @@ def begin_create_or_update_at_management_group_scope( cls(response) :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.resource.resources.v2021_04_01.models.DeploymentExtended] - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - api_version = kwargs.pop('api_version', "2021-04-01") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] - polling = kwargs.pop('polling', True) # type: Union[bool, PollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType["_models.DeploymentExtended"] - lro_delay = kwargs.pop( - 'polling_interval', - self._config.polling_interval - ) - cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] - if cont_token is None: - raw_result = self._create_or_update_at_management_group_scope_initial( - group_id=group_id, - deployment_name=deployment_name, - parameters=parameters, - api_version=api_version, - content_type=content_type, - cls=lambda x,y,z: x, - **kwargs - ) - kwargs.pop('error_map', None) - - def get_long_running_output(pipeline_response): - response = pipeline_response.http_response - deserialized = self._deserialize('DeploymentExtended', pipeline_response) - if cls: - return cls(pipeline_response, deserialized, {}) - return deserialized - - - if polling is True: polling_method = ARMPolling(lro_delay, **kwargs) - elif polling is False: polling_method = NoPolling() - else: polling_method = polling - if cont_token: - return LROPoller.from_continuation_token( - polling_method=polling_method, - continuation_token=cont_token, - client=self._client, - deserialization_callback=get_long_running_output - ) - return LROPoller(self._client, raw_result, get_long_running_output, polling_method) - - begin_create_or_update_at_management_group_scope.metadata = {'url': "/providers/Microsoft.Management/managementGroups/{groupId}/providers/Microsoft.Resources/deployments/{deploymentName}"} # type: ignore - @distributed_trace - def get_at_management_group_scope( + @overload + def begin_create_or_update_at_management_group_scope( self, group_id: str, deployment_name: str, + parameters: IO, + *, + content_type: str = "application/json", **kwargs: Any - ) -> "_models.DeploymentExtended": - """Gets a deployment. + ) -> LROPoller[_models.DeploymentExtended]: + """Deploys resources at management group scope. + + You can provide the template and parameters directly in the request or link to JSON files. - :param group_id: The management group ID. + :param group_id: The management group ID. Required. :type group_id: str - :param deployment_name: The name of the deployment. + :param deployment_name: The name of the deployment. Required. :type deployment_name: str + :param parameters: Additional parameters supplied to the operation. Required. + :type parameters: IO + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: DeploymentExtended, or the result of cls(response) - :rtype: ~azure.mgmt.resource.resources.v2021_04_01.models.DeploymentExtended - :raises: ~azure.core.exceptions.HttpResponseError - """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.DeploymentExtended"] - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {})) - - api_version = kwargs.pop('api_version', "2021-04-01") # type: str - - - request = build_deployments_get_at_management_group_scope_request( + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be ARMPolling. Pass in False for this + operation to not poll, or pass in your own initialized polling object for a personal polling + strategy. + :paramtype polling: bool or ~azure.core.polling.PollingMethod + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of LROPoller that returns either DeploymentExtended or the result of + cls(response) + :rtype: + ~azure.core.polling.LROPoller[~azure.mgmt.resource.resources.v2021_04_01.models.DeploymentExtended] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace + def begin_create_or_update_at_management_group_scope( + self, group_id: str, deployment_name: str, parameters: Union[_models.ScopedDeployment, IO], **kwargs: Any + ) -> LROPoller[_models.DeploymentExtended]: + """Deploys resources at management group scope. + + You can provide the template and parameters directly in the request or link to JSON files. + + :param group_id: The management group ID. Required. + :type group_id: str + :param deployment_name: The name of the deployment. Required. + :type deployment_name: str + :param parameters: Additional parameters supplied to the operation. Is either a model type or a + IO type. Required. + :type parameters: ~azure.mgmt.resource.resources.v2021_04_01.models.ScopedDeployment or IO + :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. + Default value is None. + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be ARMPolling. Pass in False for this + operation to not poll, or pass in your own initialized polling object for a personal polling + strategy. + :paramtype polling: bool or ~azure.core.polling.PollingMethod + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of LROPoller that returns either DeploymentExtended or the result of + cls(response) + :rtype: + ~azure.core.polling.LROPoller[~azure.mgmt.resource.resources.v2021_04_01.models.DeploymentExtended] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _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-04-01")) # type: str + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.DeploymentExtended] + polling = kwargs.pop("polling", True) # type: Union[bool, PollingMethod] + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token = kwargs.pop("continuation_token", None) # type: Optional[str] + if cont_token is None: + raw_result = self._create_or_update_at_management_group_scope_initial( # type: ignore + group_id=group_id, + deployment_name=deployment_name, + parameters=parameters, + api_version=api_version, + content_type=content_type, + cls=lambda x, y, z: x, + headers=_headers, + params=_params, + **kwargs + ) + kwargs.pop("error_map", None) + + def get_long_running_output(pipeline_response): + deserialized = self._deserialize("DeploymentExtended", pipeline_response) + if cls: + return cls(pipeline_response, deserialized, {}) + return deserialized + + if polling is True: + polling_method = cast(PollingMethod, ARMPolling(lro_delay, **kwargs)) # type: PollingMethod + elif polling is False: + polling_method = cast(PollingMethod, NoPolling()) + else: + polling_method = polling + if cont_token: + return LROPoller.from_continuation_token( + polling_method=polling_method, + continuation_token=cont_token, + client=self._client, + deserialization_callback=get_long_running_output, + ) + return LROPoller(self._client, raw_result, get_long_running_output, polling_method) + + begin_create_or_update_at_management_group_scope.metadata = {"url": "/providers/Microsoft.Management/managementGroups/{groupId}/providers/Microsoft.Resources/deployments/{deploymentName}"} # type: ignore + + @distributed_trace + def get_at_management_group_scope( + self, group_id: str, deployment_name: str, **kwargs: Any + ) -> _models.DeploymentExtended: + """Gets a deployment. + + :param group_id: The management group ID. Required. + :type group_id: str + :param deployment_name: The name of the deployment. Required. + :type deployment_name: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: DeploymentExtended or the result of cls(response) + :rtype: ~azure.mgmt.resource.resources.v2021_04_01.models.DeploymentExtended + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-04-01")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[_models.DeploymentExtended] + + request = build_deployments_get_at_management_group_scope_request( group_id=group_id, deployment_name=deployment_name, api_version=api_version, - template_url=self.get_at_management_group_scope.metadata['url'], + template_url=self.get_at_management_group_scope.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) - deserialized = self._deserialize('DeploymentExtended', pipeline_response) + deserialized = self._deserialize("DeploymentExtended", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - get_at_management_group_scope.metadata = {'url': "/providers/Microsoft.Management/managementGroups/{groupId}/providers/Microsoft.Resources/deployments/{deploymentName}"} # type: ignore - + get_at_management_group_scope.metadata = {"url": "/providers/Microsoft.Management/managementGroups/{groupId}/providers/Microsoft.Resources/deployments/{deploymentName}"} # type: ignore @distributed_trace def cancel_at_management_group_scope( # pylint: disable=inconsistent-return-statements - self, - group_id: str, - deployment_name: str, - **kwargs: Any + self, group_id: str, deployment_name: str, **kwargs: Any ) -> None: """Cancels a currently running template deployment. @@ -5492,38 +5421,44 @@ def cancel_at_management_group_scope( # pylint: disable=inconsistent-return-sta deployment stops the currently running template deployment and leaves the resources partially deployed. - :param group_id: The management group ID. + :param group_id: The management group ID. Required. :type group_id: str - :param deployment_name: The name of the deployment. + :param deployment_name: The name of the deployment. Required. :type deployment_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: None, or the result of cls(response) + :return: None or the result of cls(response) :rtype: None - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType[None] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) - api_version = kwargs.pop('api_version', "2021-04-01") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-04-01")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[None] - request = build_deployments_cancel_at_management_group_scope_request( group_id=group_id, deployment_name=deployment_name, api_version=api_version, - template_url=self.cancel_at_management_group_scope.metadata['url'], + template_url=self.cancel_at_management_group_scope.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [204]: @@ -5533,43 +5468,52 @@ def cancel_at_management_group_scope( # pylint: disable=inconsistent-return-sta if cls: return cls(pipeline_response, None, {}) - cancel_at_management_group_scope.metadata = {'url': "/providers/Microsoft.Management/managementGroups/{groupId}/providers/Microsoft.Resources/deployments/{deploymentName}/cancel"} # type: ignore - + cancel_at_management_group_scope.metadata = {"url": "/providers/Microsoft.Management/managementGroups/{groupId}/providers/Microsoft.Resources/deployments/{deploymentName}/cancel"} # type: ignore def _validate_at_management_group_scope_initial( - self, - group_id: str, - deployment_name: str, - parameters: "_models.ScopedDeployment", - **kwargs: Any - ) -> Optional["_models.DeploymentValidateResult"]: - cls = kwargs.pop('cls', None) # type: ClsType[Optional["_models.DeploymentValidateResult"]] + self, group_id: str, deployment_name: str, parameters: Union[_models.ScopedDeployment, IO], **kwargs: Any + ) -> Optional[_models.DeploymentValidateResult]: error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', "2021-04-01") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-04-01")) # type: str + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[Optional[_models.DeploymentValidateResult]] - _json = self._serialize.body(parameters, 'ScopedDeployment') + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(parameters, (IO, bytes)): + _content = parameters + else: + _json = self._serialize.body(parameters, "ScopedDeployment") - request = build_deployments_validate_at_management_group_scope_request_initial( + request = build_deployments_validate_at_management_group_scope_request( group_id=group_id, deployment_name=deployment_name, api_version=api_version, content_type=content_type, json=_json, - template_url=self._validate_at_management_group_scope_initial.metadata['url'], + content=_content, + template_url=self._validate_at_management_group_scope_initial.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200, 202, 400]: @@ -5578,36 +5522,40 @@ def _validate_at_management_group_scope_initial( deserialized = None if response.status_code == 200: - deserialized = self._deserialize('DeploymentValidateResult', pipeline_response) + deserialized = self._deserialize("DeploymentValidateResult", pipeline_response) if response.status_code == 400: - deserialized = self._deserialize('DeploymentValidateResult', pipeline_response) + deserialized = self._deserialize("DeploymentValidateResult", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - _validate_at_management_group_scope_initial.metadata = {'url': "/providers/Microsoft.Management/managementGroups/{groupId}/providers/Microsoft.Resources/deployments/{deploymentName}/validate"} # type: ignore + _validate_at_management_group_scope_initial.metadata = {"url": "/providers/Microsoft.Management/managementGroups/{groupId}/providers/Microsoft.Resources/deployments/{deploymentName}/validate"} # type: ignore - - @distributed_trace + @overload def begin_validate_at_management_group_scope( self, group_id: str, deployment_name: str, - parameters: "_models.ScopedDeployment", + parameters: _models.ScopedDeployment, + *, + content_type: str = "application/json", **kwargs: Any - ) -> LROPoller["_models.DeploymentValidateResult"]: + ) -> LROPoller[_models.DeploymentValidateResult]: """Validates whether the specified template is syntactically correct and will be accepted by Azure Resource Manager.. - :param group_id: The management group ID. + :param group_id: The management group ID. Required. :type group_id: str - :param deployment_name: The name of the deployment. + :param deployment_name: The name of the deployment. Required. :type deployment_name: str - :param parameters: Parameters to validate. + :param parameters: Parameters to validate. Required. :type parameters: ~azure.mgmt.resource.resources.v2021_04_01.models.ScopedDeployment + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str :keyword callable cls: A custom type or function that will be passed the direct response :keyword str continuation_token: A continuation token to restart a poller from a saved state. :keyword polling: By default, your polling method will be ARMPolling. Pass in False for this @@ -5620,85 +5568,166 @@ def begin_validate_at_management_group_scope( cls(response) :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.resource.resources.v2021_04_01.models.DeploymentValidateResult] - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - api_version = kwargs.pop('api_version', "2021-04-01") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] - polling = kwargs.pop('polling', True) # type: Union[bool, PollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType["_models.DeploymentValidateResult"] - lro_delay = kwargs.pop( - 'polling_interval', - self._config.polling_interval - ) - cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] + + @overload + def begin_validate_at_management_group_scope( + self, + group_id: str, + deployment_name: str, + parameters: IO, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> LROPoller[_models.DeploymentValidateResult]: + """Validates whether the specified template is syntactically correct and will be accepted by Azure + Resource Manager.. + + :param group_id: The management group ID. Required. + :type group_id: str + :param deployment_name: The name of the deployment. Required. + :type deployment_name: str + :param parameters: Parameters to validate. Required. + :type parameters: IO + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be ARMPolling. Pass in False for this + operation to not poll, or pass in your own initialized polling object for a personal polling + strategy. + :paramtype polling: bool or ~azure.core.polling.PollingMethod + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of LROPoller that returns either DeploymentValidateResult or the result of + cls(response) + :rtype: + ~azure.core.polling.LROPoller[~azure.mgmt.resource.resources.v2021_04_01.models.DeploymentValidateResult] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace + def begin_validate_at_management_group_scope( + self, group_id: str, deployment_name: str, parameters: Union[_models.ScopedDeployment, IO], **kwargs: Any + ) -> LROPoller[_models.DeploymentValidateResult]: + """Validates whether the specified template is syntactically correct and will be accepted by Azure + Resource Manager.. + + :param group_id: The management group ID. Required. + :type group_id: str + :param deployment_name: The name of the deployment. Required. + :type deployment_name: str + :param parameters: Parameters to validate. Is either a model type or a IO type. Required. + :type parameters: ~azure.mgmt.resource.resources.v2021_04_01.models.ScopedDeployment or IO + :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. + Default value is None. + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be ARMPolling. Pass in False for this + operation to not poll, or pass in your own initialized polling object for a personal polling + strategy. + :paramtype polling: bool or ~azure.core.polling.PollingMethod + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of LROPoller that returns either DeploymentValidateResult or the result of + cls(response) + :rtype: + ~azure.core.polling.LROPoller[~azure.mgmt.resource.resources.v2021_04_01.models.DeploymentValidateResult] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _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-04-01")) # type: str + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.DeploymentValidateResult] + polling = kwargs.pop("polling", True) # type: Union[bool, PollingMethod] + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token = kwargs.pop("continuation_token", None) # type: Optional[str] if cont_token is None: - raw_result = self._validate_at_management_group_scope_initial( + raw_result = self._validate_at_management_group_scope_initial( # type: ignore group_id=group_id, deployment_name=deployment_name, parameters=parameters, api_version=api_version, content_type=content_type, - cls=lambda x,y,z: x, + cls=lambda x, y, z: x, + headers=_headers, + params=_params, **kwargs ) - kwargs.pop('error_map', None) + kwargs.pop("error_map", None) def get_long_running_output(pipeline_response): - response = pipeline_response.http_response - deserialized = self._deserialize('DeploymentValidateResult', pipeline_response) + deserialized = self._deserialize("DeploymentValidateResult", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - - if polling is True: polling_method = ARMPolling(lro_delay, **kwargs) - elif polling is False: polling_method = NoPolling() - else: polling_method = polling + if polling is True: + polling_method = cast(PollingMethod, ARMPolling(lro_delay, **kwargs)) # type: PollingMethod + elif polling is False: + polling_method = cast(PollingMethod, NoPolling()) + else: + polling_method = polling if cont_token: return LROPoller.from_continuation_token( polling_method=polling_method, continuation_token=cont_token, client=self._client, - deserialization_callback=get_long_running_output + deserialization_callback=get_long_running_output, ) return LROPoller(self._client, raw_result, get_long_running_output, polling_method) - begin_validate_at_management_group_scope.metadata = {'url': "/providers/Microsoft.Management/managementGroups/{groupId}/providers/Microsoft.Resources/deployments/{deploymentName}/validate"} # type: ignore + begin_validate_at_management_group_scope.metadata = {"url": "/providers/Microsoft.Management/managementGroups/{groupId}/providers/Microsoft.Resources/deployments/{deploymentName}/validate"} # type: ignore def _what_if_at_management_group_scope_initial( - self, - group_id: str, - deployment_name: str, - parameters: "_models.ScopedDeploymentWhatIf", - **kwargs: Any - ) -> Optional["_models.WhatIfOperationResult"]: - cls = kwargs.pop('cls', None) # type: ClsType[Optional["_models.WhatIfOperationResult"]] + self, group_id: str, deployment_name: str, parameters: Union[_models.ScopedDeploymentWhatIf, IO], **kwargs: Any + ) -> Optional[_models.WhatIfOperationResult]: error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) - api_version = kwargs.pop('api_version', "2021-04-01") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - _json = self._serialize.body(parameters, 'ScopedDeploymentWhatIf') + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-04-01")) # type: str + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[Optional[_models.WhatIfOperationResult]] + + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(parameters, (IO, bytes)): + _content = parameters + else: + _json = self._serialize.body(parameters, "ScopedDeploymentWhatIf") - request = build_deployments_what_if_at_management_group_scope_request_initial( + request = build_deployments_what_if_at_management_group_scope_request( group_id=group_id, deployment_name=deployment_name, api_version=api_version, content_type=content_type, json=_json, - template_url=self._what_if_at_management_group_scope_initial.metadata['url'], + content=_content, + template_url=self._what_if_at_management_group_scope_initial.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200, 202]: @@ -5708,38 +5737,41 @@ def _what_if_at_management_group_scope_initial( deserialized = None response_headers = {} if response.status_code == 200: - deserialized = self._deserialize('WhatIfOperationResult', pipeline_response) + deserialized = self._deserialize("WhatIfOperationResult", pipeline_response) if response.status_code == 202: - response_headers['Location']=self._deserialize('str', response.headers.get('Location')) - response_headers['Retry-After']=self._deserialize('str', response.headers.get('Retry-After')) - + response_headers["Location"] = self._deserialize("str", response.headers.get("Location")) + response_headers["Retry-After"] = self._deserialize("str", response.headers.get("Retry-After")) if cls: return cls(pipeline_response, deserialized, response_headers) return deserialized - _what_if_at_management_group_scope_initial.metadata = {'url': "/providers/Microsoft.Management/managementGroups/{groupId}/providers/Microsoft.Resources/deployments/{deploymentName}/whatIf"} # type: ignore - + _what_if_at_management_group_scope_initial.metadata = {"url": "/providers/Microsoft.Management/managementGroups/{groupId}/providers/Microsoft.Resources/deployments/{deploymentName}/whatIf"} # type: ignore - @distributed_trace + @overload def begin_what_if_at_management_group_scope( self, group_id: str, deployment_name: str, - parameters: "_models.ScopedDeploymentWhatIf", + parameters: _models.ScopedDeploymentWhatIf, + *, + content_type: str = "application/json", **kwargs: Any - ) -> LROPoller["_models.WhatIfOperationResult"]: + ) -> LROPoller[_models.WhatIfOperationResult]: """Returns changes that will be made by the deployment if executed at the scope of the management group. - :param group_id: The management group ID. + :param group_id: The management group ID. Required. :type group_id: str - :param deployment_name: The name of the deployment. + :param deployment_name: The name of the deployment. Required. :type deployment_name: str - :param parameters: Parameters to validate. + :param parameters: Parameters to validate. Required. :type parameters: ~azure.mgmt.resource.resources.v2021_04_01.models.ScopedDeploymentWhatIf + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str :keyword callable cls: A custom type or function that will be passed the direct response :keyword str continuation_token: A continuation token to restart a poller from a saved state. :keyword polling: By default, your polling method will be ARMPolling. Pass in False for this @@ -5752,119 +5784,191 @@ def begin_what_if_at_management_group_scope( cls(response) :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.resource.resources.v2021_04_01.models.WhatIfOperationResult] - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - api_version = kwargs.pop('api_version', "2021-04-01") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] - polling = kwargs.pop('polling', True) # type: Union[bool, PollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType["_models.WhatIfOperationResult"] - lro_delay = kwargs.pop( - 'polling_interval', - self._config.polling_interval - ) - cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] + + @overload + def begin_what_if_at_management_group_scope( + self, + group_id: str, + deployment_name: str, + parameters: IO, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> LROPoller[_models.WhatIfOperationResult]: + """Returns changes that will be made by the deployment if executed at the scope of the management + group. + + :param group_id: The management group ID. Required. + :type group_id: str + :param deployment_name: The name of the deployment. Required. + :type deployment_name: str + :param parameters: Parameters to validate. Required. + :type parameters: IO + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be ARMPolling. Pass in False for this + operation to not poll, or pass in your own initialized polling object for a personal polling + strategy. + :paramtype polling: bool or ~azure.core.polling.PollingMethod + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of LROPoller that returns either WhatIfOperationResult or the result of + cls(response) + :rtype: + ~azure.core.polling.LROPoller[~azure.mgmt.resource.resources.v2021_04_01.models.WhatIfOperationResult] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace + def begin_what_if_at_management_group_scope( + self, group_id: str, deployment_name: str, parameters: Union[_models.ScopedDeploymentWhatIf, IO], **kwargs: Any + ) -> LROPoller[_models.WhatIfOperationResult]: + """Returns changes that will be made by the deployment if executed at the scope of the management + group. + + :param group_id: The management group ID. Required. + :type group_id: str + :param deployment_name: The name of the deployment. Required. + :type deployment_name: str + :param parameters: Parameters to validate. Is either a model type or a IO type. Required. + :type parameters: ~azure.mgmt.resource.resources.v2021_04_01.models.ScopedDeploymentWhatIf or + IO + :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. + Default value is None. + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be ARMPolling. Pass in False for this + operation to not poll, or pass in your own initialized polling object for a personal polling + strategy. + :paramtype polling: bool or ~azure.core.polling.PollingMethod + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of LROPoller that returns either WhatIfOperationResult or the result of + cls(response) + :rtype: + ~azure.core.polling.LROPoller[~azure.mgmt.resource.resources.v2021_04_01.models.WhatIfOperationResult] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _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-04-01")) # type: str + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.WhatIfOperationResult] + polling = kwargs.pop("polling", True) # type: Union[bool, PollingMethod] + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token = kwargs.pop("continuation_token", None) # type: Optional[str] if cont_token is None: - raw_result = self._what_if_at_management_group_scope_initial( + raw_result = self._what_if_at_management_group_scope_initial( # type: ignore group_id=group_id, deployment_name=deployment_name, parameters=parameters, api_version=api_version, content_type=content_type, - cls=lambda x,y,z: x, + cls=lambda x, y, z: x, + headers=_headers, + params=_params, **kwargs ) - kwargs.pop('error_map', None) + kwargs.pop("error_map", None) def get_long_running_output(pipeline_response): - response = pipeline_response.http_response - deserialized = self._deserialize('WhatIfOperationResult', pipeline_response) + deserialized = self._deserialize("WhatIfOperationResult", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - - if polling is True: polling_method = ARMPolling(lro_delay, lro_options={'final-state-via': 'location'}, **kwargs) - elif polling is False: polling_method = NoPolling() - else: polling_method = polling + if polling is True: + polling_method = cast( + PollingMethod, ARMPolling(lro_delay, lro_options={"final-state-via": "location"}, **kwargs) + ) # type: PollingMethod + elif polling is False: + polling_method = cast(PollingMethod, NoPolling()) + else: + polling_method = polling if cont_token: return LROPoller.from_continuation_token( polling_method=polling_method, continuation_token=cont_token, client=self._client, - deserialization_callback=get_long_running_output + deserialization_callback=get_long_running_output, ) return LROPoller(self._client, raw_result, get_long_running_output, polling_method) - begin_what_if_at_management_group_scope.metadata = {'url': "/providers/Microsoft.Management/managementGroups/{groupId}/providers/Microsoft.Resources/deployments/{deploymentName}/whatIf"} # type: ignore + begin_what_if_at_management_group_scope.metadata = {"url": "/providers/Microsoft.Management/managementGroups/{groupId}/providers/Microsoft.Resources/deployments/{deploymentName}/whatIf"} # type: ignore @distributed_trace def export_template_at_management_group_scope( - self, - group_id: str, - deployment_name: str, - **kwargs: Any - ) -> "_models.DeploymentExportResult": + self, group_id: str, deployment_name: str, **kwargs: Any + ) -> _models.DeploymentExportResult: """Exports the template used for specified deployment. - :param group_id: The management group ID. + :param group_id: The management group ID. Required. :type group_id: str - :param deployment_name: The name of the deployment. + :param deployment_name: The name of the deployment. Required. :type deployment_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: DeploymentExportResult, or the result of cls(response) + :return: DeploymentExportResult or the result of cls(response) :rtype: ~azure.mgmt.resource.resources.v2021_04_01.models.DeploymentExportResult - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.DeploymentExportResult"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + 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', "2021-04-01") # type: str + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-04-01")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[_models.DeploymentExportResult] - request = build_deployments_export_template_at_management_group_scope_request( group_id=group_id, deployment_name=deployment_name, api_version=api_version, - template_url=self.export_template_at_management_group_scope.metadata['url'], + template_url=self.export_template_at_management_group_scope.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) - deserialized = self._deserialize('DeploymentExportResult', pipeline_response) + deserialized = self._deserialize("DeploymentExportResult", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - export_template_at_management_group_scope.metadata = {'url': "/providers/Microsoft.Management/managementGroups/{groupId}/providers/Microsoft.Resources/deployments/{deploymentName}/exportTemplate"} # type: ignore - + export_template_at_management_group_scope.metadata = {"url": "/providers/Microsoft.Management/managementGroups/{groupId}/providers/Microsoft.Resources/deployments/{deploymentName}/exportTemplate"} # type: ignore @distributed_trace def list_at_management_group_scope( - self, - group_id: str, - filter: Optional[str] = None, - top: Optional[int] = None, - **kwargs: Any - ) -> Iterable["_models.DeploymentListResult"]: + self, group_id: str, filter: Optional[str] = None, top: Optional[int] = None, **kwargs: Any + ) -> Iterable["_models.DeploymentExtended"]: """Get all the deployments for a management group. - :param group_id: The management group ID. + :param group_id: The management group ID. Required. :type group_id: str :param filter: The filter to apply on the operation. For example, you can use $filter=provisioningState eq '{state}'. Default value is None. @@ -5873,40 +5977,48 @@ def list_at_management_group_scope( value is None. :type top: int :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either DeploymentListResult or the result of - cls(response) + :return: An iterator like instance of either DeploymentExtended or the result of cls(response) :rtype: - ~azure.core.paging.ItemPaged[~azure.mgmt.resource.resources.v2021_04_01.models.DeploymentListResult] - :raises: ~azure.core.exceptions.HttpResponseError + ~azure.core.paging.ItemPaged[~azure.mgmt.resource.resources.v2021_04_01.models.DeploymentExtended] + :raises ~azure.core.exceptions.HttpResponseError: """ - api_version = kwargs.pop('api_version', "2021-04-01") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-04-01")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[_models.DeploymentListResult] - cls = kwargs.pop('cls', None) # type: ClsType["_models.DeploymentListResult"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) + def prepare_request(next_link=None): if not next_link: - + request = build_deployments_list_at_management_group_scope_request( group_id=group_id, - api_version=api_version, filter=filter, top=top, - template_url=self.list_at_management_group_scope.metadata['url'], + api_version=api_version, + template_url=self.list_at_management_group_scope.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore else: - - request = build_deployments_list_at_management_group_scope_request( - group_id=group_id, - template_url=next_link, - ) + # make call to next link with the client's api-version + _parsed_next_link = urlparse(next_link) + _next_request_params = case_insensitive_dict(parse_qs(_parsed_next_link.query)) + _next_request_params["api-version"] = self._config.api_version + request = HttpRequest("GET", urljoin(next_link, _parsed_next_link.path), params=_next_request_params) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore request.method = "GET" return request @@ -5920,10 +6032,8 @@ def extract_data(pipeline_response): def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) response = pipeline_response.http_response @@ -5933,40 +6043,42 @@ def get_next(next_link=None): return pipeline_response + return ItemPaged(get_next, extract_data) - return ItemPaged( - get_next, extract_data - ) - list_at_management_group_scope.metadata = {'url': "/providers/Microsoft.Management/managementGroups/{groupId}/providers/Microsoft.Resources/deployments/"} # type: ignore + list_at_management_group_scope.metadata = {"url": "/providers/Microsoft.Management/managementGroups/{groupId}/providers/Microsoft.Resources/deployments/"} # type: ignore def _delete_at_subscription_scope_initial( # pylint: disable=inconsistent-return-statements - self, - deployment_name: str, - **kwargs: Any + self, deployment_name: str, **kwargs: Any ) -> None: - cls = kwargs.pop('cls', None) # type: ClsType[None] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + 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', "2021-04-01") # type: str + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-04-01")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[None] - - request = build_deployments_delete_at_subscription_scope_request_initial( + request = build_deployments_delete_at_subscription_scope_request( deployment_name=deployment_name, subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self._delete_at_subscription_scope_initial.metadata['url'], + template_url=self._delete_at_subscription_scope_initial.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [202, 204]: @@ -5976,15 +6088,10 @@ def _delete_at_subscription_scope_initial( # pylint: disable=inconsistent-retur if cls: return cls(pipeline_response, None, {}) - _delete_at_subscription_scope_initial.metadata = {'url': "/subscriptions/{subscriptionId}/providers/Microsoft.Resources/deployments/{deploymentName}"} # type: ignore - + _delete_at_subscription_scope_initial.metadata = {"url": "/subscriptions/{subscriptionId}/providers/Microsoft.Resources/deployments/{deploymentName}"} # type: ignore @distributed_trace - def begin_delete_at_subscription_scope( # pylint: disable=inconsistent-return-statements - self, - deployment_name: str, - **kwargs: Any - ) -> LROPoller[None]: + def begin_delete_at_subscription_scope(self, deployment_name: str, **kwargs: Any) -> LROPoller[None]: """Deletes a deployment from the deployment history. A template deployment that is currently running cannot be deleted. Deleting a template @@ -5995,7 +6102,7 @@ def begin_delete_at_subscription_scope( # pylint: disable=inconsistent-return-s process finishes, the URI in the Location header returns a status of 204 on success. If the asynchronous request failed, the URI in the Location header returns an error-level status code. - :param deployment_name: The name of the deployment. + :param deployment_name: The name of the deployment. Required. :type deployment_name: str :keyword callable cls: A custom type or function that will be passed the direct response :keyword str continuation_token: A continuation token to restart a poller from a saved state. @@ -6007,82 +6114,88 @@ def begin_delete_at_subscription_scope( # pylint: disable=inconsistent-return-s Retry-After header is present. :return: An instance of LROPoller that returns either None or the result of cls(response) :rtype: ~azure.core.polling.LROPoller[None] - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - api_version = kwargs.pop('api_version', "2021-04-01") # type: str - polling = kwargs.pop('polling', True) # type: Union[bool, PollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType[None] - lro_delay = kwargs.pop( - 'polling_interval', - self._config.polling_interval - ) - cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-04-01")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[None] + polling = kwargs.pop("polling", True) # type: Union[bool, PollingMethod] + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token = kwargs.pop("continuation_token", None) # type: Optional[str] if cont_token is None: - raw_result = self._delete_at_subscription_scope_initial( + raw_result = self._delete_at_subscription_scope_initial( # type: ignore deployment_name=deployment_name, api_version=api_version, - cls=lambda x,y,z: x, + cls=lambda x, y, z: x, + headers=_headers, + params=_params, **kwargs ) - kwargs.pop('error_map', None) + kwargs.pop("error_map", None) - def get_long_running_output(pipeline_response): + def get_long_running_output(pipeline_response): # pylint: disable=inconsistent-return-statements if cls: return cls(pipeline_response, None, {}) - - if polling is True: polling_method = ARMPolling(lro_delay, **kwargs) - elif polling is False: polling_method = NoPolling() - else: polling_method = polling + if polling is True: + polling_method = cast(PollingMethod, ARMPolling(lro_delay, **kwargs)) # type: PollingMethod + elif polling is False: + polling_method = cast(PollingMethod, NoPolling()) + else: + polling_method = polling if cont_token: return LROPoller.from_continuation_token( polling_method=polling_method, continuation_token=cont_token, client=self._client, - deserialization_callback=get_long_running_output + deserialization_callback=get_long_running_output, ) return LROPoller(self._client, raw_result, get_long_running_output, polling_method) - begin_delete_at_subscription_scope.metadata = {'url': "/subscriptions/{subscriptionId}/providers/Microsoft.Resources/deployments/{deploymentName}"} # type: ignore + begin_delete_at_subscription_scope.metadata = {"url": "/subscriptions/{subscriptionId}/providers/Microsoft.Resources/deployments/{deploymentName}"} # type: ignore @distributed_trace - def check_existence_at_subscription_scope( - self, - deployment_name: str, - **kwargs: Any - ) -> bool: + def check_existence_at_subscription_scope(self, deployment_name: str, **kwargs: Any) -> bool: """Checks whether the deployment exists. - :param deployment_name: The name of the deployment. + :param deployment_name: The name of the deployment. Required. :type deployment_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: bool, or the result of cls(response) + :return: bool or the result of cls(response) :rtype: bool - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType[None] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) - api_version = kwargs.pop('api_version', "2021-04-01") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-04-01")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[None] - request = build_deployments_check_existence_at_subscription_scope_request( deployment_name=deployment_name, subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.check_existence_at_subscription_scope.metadata['url'], + template_url=self.check_existence_at_subscription_scope.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [204, 404]: @@ -6093,42 +6206,52 @@ def check_existence_at_subscription_scope( return cls(pipeline_response, None, {}) return 200 <= response.status_code <= 299 - check_existence_at_subscription_scope.metadata = {'url': "/subscriptions/{subscriptionId}/providers/Microsoft.Resources/deployments/{deploymentName}"} # type: ignore - + check_existence_at_subscription_scope.metadata = {"url": "/subscriptions/{subscriptionId}/providers/Microsoft.Resources/deployments/{deploymentName}"} # type: ignore def _create_or_update_at_subscription_scope_initial( - self, - deployment_name: str, - parameters: "_models.Deployment", - **kwargs: Any - ) -> "_models.DeploymentExtended": - cls = kwargs.pop('cls', None) # type: ClsType["_models.DeploymentExtended"] + self, deployment_name: str, parameters: Union[_models.Deployment, IO], **kwargs: Any + ) -> _models.DeploymentExtended: error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) - api_version = kwargs.pop('api_version', "2021-04-01") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - _json = self._serialize.body(parameters, 'Deployment') + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-04-01")) # type: str + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.DeploymentExtended] - request = build_deployments_create_or_update_at_subscription_scope_request_initial( + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(parameters, (IO, bytes)): + _content = parameters + else: + _json = self._serialize.body(parameters, "Deployment") + + request = build_deployments_create_or_update_at_subscription_scope_request( deployment_name=deployment_name, subscription_id=self._config.subscription_id, api_version=api_version, content_type=content_type, json=_json, - template_url=self._create_or_update_at_subscription_scope_initial.metadata['url'], + content=_content, + template_url=self._create_or_update_at_subscription_scope_initial.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200, 201]: @@ -6136,34 +6259,38 @@ def _create_or_update_at_subscription_scope_initial( raise HttpResponseError(response=response, error_format=ARMErrorFormat) if response.status_code == 200: - deserialized = self._deserialize('DeploymentExtended', pipeline_response) + deserialized = self._deserialize("DeploymentExtended", pipeline_response) if response.status_code == 201: - deserialized = self._deserialize('DeploymentExtended', pipeline_response) + deserialized = self._deserialize("DeploymentExtended", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - _create_or_update_at_subscription_scope_initial.metadata = {'url': "/subscriptions/{subscriptionId}/providers/Microsoft.Resources/deployments/{deploymentName}"} # type: ignore - + _create_or_update_at_subscription_scope_initial.metadata = {"url": "/subscriptions/{subscriptionId}/providers/Microsoft.Resources/deployments/{deploymentName}"} # type: ignore - @distributed_trace + @overload def begin_create_or_update_at_subscription_scope( self, deployment_name: str, - parameters: "_models.Deployment", + parameters: _models.Deployment, + *, + content_type: str = "application/json", **kwargs: Any - ) -> LROPoller["_models.DeploymentExtended"]: + ) -> LROPoller[_models.DeploymentExtended]: """Deploys resources at subscription scope. You can provide the template and parameters directly in the request or link to JSON files. - :param deployment_name: The name of the deployment. + :param deployment_name: The name of the deployment. Required. :type deployment_name: str - :param parameters: Additional parameters supplied to the operation. + :param parameters: Additional parameters supplied to the operation. Required. :type parameters: ~azure.mgmt.resource.resources.v2021_04_01.models.Deployment + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str :keyword callable cls: A custom type or function that will be passed the direct response :keyword str continuation_token: A continuation token to restart a poller from a saved state. :keyword polling: By default, your polling method will be ARMPolling. Pass in False for this @@ -6176,109 +6303,172 @@ def begin_create_or_update_at_subscription_scope( cls(response) :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.resource.resources.v2021_04_01.models.DeploymentExtended] - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - api_version = kwargs.pop('api_version', "2021-04-01") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] - polling = kwargs.pop('polling', True) # type: Union[bool, PollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType["_models.DeploymentExtended"] - lro_delay = kwargs.pop( - 'polling_interval', - self._config.polling_interval - ) - cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] - if cont_token is None: - raw_result = self._create_or_update_at_subscription_scope_initial( - deployment_name=deployment_name, + + @overload + def begin_create_or_update_at_subscription_scope( + self, deployment_name: str, parameters: IO, *, content_type: str = "application/json", **kwargs: Any + ) -> LROPoller[_models.DeploymentExtended]: + """Deploys resources at subscription scope. + + You can provide the template and parameters directly in the request or link to JSON files. + + :param deployment_name: The name of the deployment. Required. + :type deployment_name: str + :param parameters: Additional parameters supplied to the operation. Required. + :type parameters: IO + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be ARMPolling. Pass in False for this + operation to not poll, or pass in your own initialized polling object for a personal polling + strategy. + :paramtype polling: bool or ~azure.core.polling.PollingMethod + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of LROPoller that returns either DeploymentExtended or the result of + cls(response) + :rtype: + ~azure.core.polling.LROPoller[~azure.mgmt.resource.resources.v2021_04_01.models.DeploymentExtended] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace + def begin_create_or_update_at_subscription_scope( + self, deployment_name: str, parameters: Union[_models.Deployment, IO], **kwargs: Any + ) -> LROPoller[_models.DeploymentExtended]: + """Deploys resources at subscription scope. + + You can provide the template and parameters directly in the request or link to JSON files. + + :param deployment_name: The name of the deployment. Required. + :type deployment_name: str + :param parameters: Additional parameters supplied to the operation. Is either a model type or a + IO type. Required. + :type parameters: ~azure.mgmt.resource.resources.v2021_04_01.models.Deployment or IO + :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. + Default value is None. + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be ARMPolling. Pass in False for this + operation to not poll, or pass in your own initialized polling object for a personal polling + strategy. + :paramtype polling: bool or ~azure.core.polling.PollingMethod + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of LROPoller that returns either DeploymentExtended or the result of + cls(response) + :rtype: + ~azure.core.polling.LROPoller[~azure.mgmt.resource.resources.v2021_04_01.models.DeploymentExtended] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _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-04-01")) # type: str + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.DeploymentExtended] + polling = kwargs.pop("polling", True) # type: Union[bool, PollingMethod] + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token = kwargs.pop("continuation_token", None) # type: Optional[str] + if cont_token is None: + raw_result = self._create_or_update_at_subscription_scope_initial( # type: ignore + deployment_name=deployment_name, parameters=parameters, api_version=api_version, content_type=content_type, - cls=lambda x,y,z: x, + cls=lambda x, y, z: x, + headers=_headers, + params=_params, **kwargs ) - kwargs.pop('error_map', None) + kwargs.pop("error_map", None) def get_long_running_output(pipeline_response): - response = pipeline_response.http_response - deserialized = self._deserialize('DeploymentExtended', pipeline_response) + deserialized = self._deserialize("DeploymentExtended", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - - if polling is True: polling_method = ARMPolling(lro_delay, **kwargs) - elif polling is False: polling_method = NoPolling() - else: polling_method = polling + if polling is True: + polling_method = cast(PollingMethod, ARMPolling(lro_delay, **kwargs)) # type: PollingMethod + elif polling is False: + polling_method = cast(PollingMethod, NoPolling()) + else: + polling_method = polling if cont_token: return LROPoller.from_continuation_token( polling_method=polling_method, continuation_token=cont_token, client=self._client, - deserialization_callback=get_long_running_output + deserialization_callback=get_long_running_output, ) return LROPoller(self._client, raw_result, get_long_running_output, polling_method) - begin_create_or_update_at_subscription_scope.metadata = {'url': "/subscriptions/{subscriptionId}/providers/Microsoft.Resources/deployments/{deploymentName}"} # type: ignore + begin_create_or_update_at_subscription_scope.metadata = {"url": "/subscriptions/{subscriptionId}/providers/Microsoft.Resources/deployments/{deploymentName}"} # type: ignore @distributed_trace - def get_at_subscription_scope( - self, - deployment_name: str, - **kwargs: Any - ) -> "_models.DeploymentExtended": + def get_at_subscription_scope(self, deployment_name: str, **kwargs: Any) -> _models.DeploymentExtended: """Gets a deployment. - :param deployment_name: The name of the deployment. + :param deployment_name: The name of the deployment. Required. :type deployment_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: DeploymentExtended, or the result of cls(response) + :return: DeploymentExtended or the result of cls(response) :rtype: ~azure.mgmt.resource.resources.v2021_04_01.models.DeploymentExtended - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.DeploymentExtended"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + 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', "2021-04-01") # type: str + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-04-01")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[_models.DeploymentExtended] - request = build_deployments_get_at_subscription_scope_request( deployment_name=deployment_name, subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.get_at_subscription_scope.metadata['url'], + template_url=self.get_at_subscription_scope.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) - deserialized = self._deserialize('DeploymentExtended', pipeline_response) + deserialized = self._deserialize("DeploymentExtended", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - get_at_subscription_scope.metadata = {'url': "/subscriptions/{subscriptionId}/providers/Microsoft.Resources/deployments/{deploymentName}"} # type: ignore - + get_at_subscription_scope.metadata = {"url": "/subscriptions/{subscriptionId}/providers/Microsoft.Resources/deployments/{deploymentName}"} # type: ignore @distributed_trace def cancel_at_subscription_scope( # pylint: disable=inconsistent-return-statements - self, - deployment_name: str, - **kwargs: Any + self, deployment_name: str, **kwargs: Any ) -> None: """Cancels a currently running template deployment. @@ -6287,36 +6477,42 @@ def cancel_at_subscription_scope( # pylint: disable=inconsistent-return-stateme deployment stops the currently running template deployment and leaves the resources partially deployed. - :param deployment_name: The name of the deployment. + :param deployment_name: The name of the deployment. Required. :type deployment_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: None, or the result of cls(response) + :return: None or the result of cls(response) :rtype: None - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType[None] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + 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', "2021-04-01") # type: str + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-04-01")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[None] - request = build_deployments_cancel_at_subscription_scope_request( deployment_name=deployment_name, subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.cancel_at_subscription_scope.metadata['url'], + template_url=self.cancel_at_subscription_scope.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [204]: @@ -6326,42 +6522,52 @@ def cancel_at_subscription_scope( # pylint: disable=inconsistent-return-stateme if cls: return cls(pipeline_response, None, {}) - cancel_at_subscription_scope.metadata = {'url': "/subscriptions/{subscriptionId}/providers/Microsoft.Resources/deployments/{deploymentName}/cancel"} # type: ignore - + cancel_at_subscription_scope.metadata = {"url": "/subscriptions/{subscriptionId}/providers/Microsoft.Resources/deployments/{deploymentName}/cancel"} # type: ignore def _validate_at_subscription_scope_initial( - self, - deployment_name: str, - parameters: "_models.Deployment", - **kwargs: Any - ) -> Optional["_models.DeploymentValidateResult"]: - cls = kwargs.pop('cls', None) # type: ClsType[Optional["_models.DeploymentValidateResult"]] + self, deployment_name: str, parameters: Union[_models.Deployment, IO], **kwargs: Any + ) -> Optional[_models.DeploymentValidateResult]: error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', "2021-04-01") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-04-01")) # type: str + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[Optional[_models.DeploymentValidateResult]] - _json = self._serialize.body(parameters, 'Deployment') + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(parameters, (IO, bytes)): + _content = parameters + else: + _json = self._serialize.body(parameters, "Deployment") - request = build_deployments_validate_at_subscription_scope_request_initial( + request = build_deployments_validate_at_subscription_scope_request( deployment_name=deployment_name, subscription_id=self._config.subscription_id, api_version=api_version, content_type=content_type, json=_json, - template_url=self._validate_at_subscription_scope_initial.metadata['url'], + content=_content, + template_url=self._validate_at_subscription_scope_initial.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200, 202, 400]: @@ -6370,33 +6576,37 @@ def _validate_at_subscription_scope_initial( deserialized = None if response.status_code == 200: - deserialized = self._deserialize('DeploymentValidateResult', pipeline_response) + deserialized = self._deserialize("DeploymentValidateResult", pipeline_response) if response.status_code == 400: - deserialized = self._deserialize('DeploymentValidateResult', pipeline_response) + deserialized = self._deserialize("DeploymentValidateResult", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - _validate_at_subscription_scope_initial.metadata = {'url': "/subscriptions/{subscriptionId}/providers/Microsoft.Resources/deployments/{deploymentName}/validate"} # type: ignore + _validate_at_subscription_scope_initial.metadata = {"url": "/subscriptions/{subscriptionId}/providers/Microsoft.Resources/deployments/{deploymentName}/validate"} # type: ignore - - @distributed_trace + @overload def begin_validate_at_subscription_scope( self, deployment_name: str, - parameters: "_models.Deployment", + parameters: _models.Deployment, + *, + content_type: str = "application/json", **kwargs: Any - ) -> LROPoller["_models.DeploymentValidateResult"]: + ) -> LROPoller[_models.DeploymentValidateResult]: """Validates whether the specified template is syntactically correct and will be accepted by Azure Resource Manager.. - :param deployment_name: The name of the deployment. + :param deployment_name: The name of the deployment. Required. :type deployment_name: str - :param parameters: Parameters to validate. + :param parameters: Parameters to validate. Required. :type parameters: ~azure.mgmt.resource.resources.v2021_04_01.models.Deployment + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str :keyword callable cls: A custom type or function that will be passed the direct response :keyword str continuation_token: A continuation token to restart a poller from a saved state. :keyword polling: By default, your polling method will be ARMPolling. Pass in False for this @@ -6409,83 +6619,155 @@ def begin_validate_at_subscription_scope( cls(response) :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.resource.resources.v2021_04_01.models.DeploymentValidateResult] - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - api_version = kwargs.pop('api_version', "2021-04-01") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] - polling = kwargs.pop('polling', True) # type: Union[bool, PollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType["_models.DeploymentValidateResult"] - lro_delay = kwargs.pop( - 'polling_interval', - self._config.polling_interval - ) - cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] + + @overload + def begin_validate_at_subscription_scope( + self, deployment_name: str, parameters: IO, *, content_type: str = "application/json", **kwargs: Any + ) -> LROPoller[_models.DeploymentValidateResult]: + """Validates whether the specified template is syntactically correct and will be accepted by Azure + Resource Manager.. + + :param deployment_name: The name of the deployment. Required. + :type deployment_name: str + :param parameters: Parameters to validate. Required. + :type parameters: IO + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be ARMPolling. Pass in False for this + operation to not poll, or pass in your own initialized polling object for a personal polling + strategy. + :paramtype polling: bool or ~azure.core.polling.PollingMethod + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of LROPoller that returns either DeploymentValidateResult or the result of + cls(response) + :rtype: + ~azure.core.polling.LROPoller[~azure.mgmt.resource.resources.v2021_04_01.models.DeploymentValidateResult] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace + def begin_validate_at_subscription_scope( + self, deployment_name: str, parameters: Union[_models.Deployment, IO], **kwargs: Any + ) -> LROPoller[_models.DeploymentValidateResult]: + """Validates whether the specified template is syntactically correct and will be accepted by Azure + Resource Manager.. + + :param deployment_name: The name of the deployment. Required. + :type deployment_name: str + :param parameters: Parameters to validate. Is either a model type or a IO type. Required. + :type parameters: ~azure.mgmt.resource.resources.v2021_04_01.models.Deployment or IO + :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. + Default value is None. + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be ARMPolling. Pass in False for this + operation to not poll, or pass in your own initialized polling object for a personal polling + strategy. + :paramtype polling: bool or ~azure.core.polling.PollingMethod + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of LROPoller that returns either DeploymentValidateResult or the result of + cls(response) + :rtype: + ~azure.core.polling.LROPoller[~azure.mgmt.resource.resources.v2021_04_01.models.DeploymentValidateResult] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _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-04-01")) # type: str + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.DeploymentValidateResult] + polling = kwargs.pop("polling", True) # type: Union[bool, PollingMethod] + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token = kwargs.pop("continuation_token", None) # type: Optional[str] if cont_token is None: - raw_result = self._validate_at_subscription_scope_initial( + raw_result = self._validate_at_subscription_scope_initial( # type: ignore deployment_name=deployment_name, parameters=parameters, api_version=api_version, content_type=content_type, - cls=lambda x,y,z: x, + cls=lambda x, y, z: x, + headers=_headers, + params=_params, **kwargs ) - kwargs.pop('error_map', None) + kwargs.pop("error_map", None) def get_long_running_output(pipeline_response): - response = pipeline_response.http_response - deserialized = self._deserialize('DeploymentValidateResult', pipeline_response) + deserialized = self._deserialize("DeploymentValidateResult", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - - if polling is True: polling_method = ARMPolling(lro_delay, **kwargs) - elif polling is False: polling_method = NoPolling() - else: polling_method = polling + if polling is True: + polling_method = cast(PollingMethod, ARMPolling(lro_delay, **kwargs)) # type: PollingMethod + elif polling is False: + polling_method = cast(PollingMethod, NoPolling()) + else: + polling_method = polling if cont_token: return LROPoller.from_continuation_token( polling_method=polling_method, continuation_token=cont_token, client=self._client, - deserialization_callback=get_long_running_output + deserialization_callback=get_long_running_output, ) return LROPoller(self._client, raw_result, get_long_running_output, polling_method) - begin_validate_at_subscription_scope.metadata = {'url': "/subscriptions/{subscriptionId}/providers/Microsoft.Resources/deployments/{deploymentName}/validate"} # type: ignore + begin_validate_at_subscription_scope.metadata = {"url": "/subscriptions/{subscriptionId}/providers/Microsoft.Resources/deployments/{deploymentName}/validate"} # type: ignore def _what_if_at_subscription_scope_initial( - self, - deployment_name: str, - parameters: "_models.DeploymentWhatIf", - **kwargs: Any - ) -> Optional["_models.WhatIfOperationResult"]: - cls = kwargs.pop('cls', None) # type: ClsType[Optional["_models.WhatIfOperationResult"]] + self, deployment_name: str, parameters: Union[_models.DeploymentWhatIf, IO], **kwargs: Any + ) -> Optional[_models.WhatIfOperationResult]: error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', "2021-04-01") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-04-01")) # type: str + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[Optional[_models.WhatIfOperationResult]] - _json = self._serialize.body(parameters, 'DeploymentWhatIf') + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(parameters, (IO, bytes)): + _content = parameters + else: + _json = self._serialize.body(parameters, "DeploymentWhatIf") - request = build_deployments_what_if_at_subscription_scope_request_initial( + request = build_deployments_what_if_at_subscription_scope_request( deployment_name=deployment_name, subscription_id=self._config.subscription_id, api_version=api_version, content_type=content_type, json=_json, - template_url=self._what_if_at_subscription_scope_initial.metadata['url'], + content=_content, + template_url=self._what_if_at_subscription_scope_initial.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200, 202]: @@ -6495,35 +6777,38 @@ def _what_if_at_subscription_scope_initial( deserialized = None response_headers = {} if response.status_code == 200: - deserialized = self._deserialize('WhatIfOperationResult', pipeline_response) + deserialized = self._deserialize("WhatIfOperationResult", pipeline_response) if response.status_code == 202: - response_headers['Location']=self._deserialize('str', response.headers.get('Location')) - response_headers['Retry-After']=self._deserialize('str', response.headers.get('Retry-After')) - + response_headers["Location"] = self._deserialize("str", response.headers.get("Location")) + response_headers["Retry-After"] = self._deserialize("str", response.headers.get("Retry-After")) if cls: return cls(pipeline_response, deserialized, response_headers) return deserialized - _what_if_at_subscription_scope_initial.metadata = {'url': "/subscriptions/{subscriptionId}/providers/Microsoft.Resources/deployments/{deploymentName}/whatIf"} # type: ignore + _what_if_at_subscription_scope_initial.metadata = {"url": "/subscriptions/{subscriptionId}/providers/Microsoft.Resources/deployments/{deploymentName}/whatIf"} # type: ignore - - @distributed_trace + @overload def begin_what_if_at_subscription_scope( self, deployment_name: str, - parameters: "_models.DeploymentWhatIf", + parameters: _models.DeploymentWhatIf, + *, + content_type: str = "application/json", **kwargs: Any - ) -> LROPoller["_models.WhatIfOperationResult"]: + ) -> LROPoller[_models.WhatIfOperationResult]: """Returns changes that will be made by the deployment if executed at the scope of the subscription. - :param deployment_name: The name of the deployment. + :param deployment_name: The name of the deployment. Required. :type deployment_name: str - :param parameters: Parameters to What If. + :param parameters: Parameters to What If. Required. :type parameters: ~azure.mgmt.resource.resources.v2021_04_01.models.DeploymentWhatIf + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str :keyword callable cls: A custom type or function that will be passed the direct response :keyword str continuation_token: A continuation token to restart a poller from a saved state. :keyword polling: By default, your polling method will be ARMPolling. Pass in False for this @@ -6536,111 +6821,174 @@ def begin_what_if_at_subscription_scope( cls(response) :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.resource.resources.v2021_04_01.models.WhatIfOperationResult] - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - api_version = kwargs.pop('api_version', "2021-04-01") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] - polling = kwargs.pop('polling', True) # type: Union[bool, PollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType["_models.WhatIfOperationResult"] - lro_delay = kwargs.pop( - 'polling_interval', - self._config.polling_interval - ) - cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] + + @overload + def begin_what_if_at_subscription_scope( + self, deployment_name: str, parameters: IO, *, content_type: str = "application/json", **kwargs: Any + ) -> LROPoller[_models.WhatIfOperationResult]: + """Returns changes that will be made by the deployment if executed at the scope of the + subscription. + + :param deployment_name: The name of the deployment. Required. + :type deployment_name: str + :param parameters: Parameters to What If. Required. + :type parameters: IO + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be ARMPolling. Pass in False for this + operation to not poll, or pass in your own initialized polling object for a personal polling + strategy. + :paramtype polling: bool or ~azure.core.polling.PollingMethod + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of LROPoller that returns either WhatIfOperationResult or the result of + cls(response) + :rtype: + ~azure.core.polling.LROPoller[~azure.mgmt.resource.resources.v2021_04_01.models.WhatIfOperationResult] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace + def begin_what_if_at_subscription_scope( + self, deployment_name: str, parameters: Union[_models.DeploymentWhatIf, IO], **kwargs: Any + ) -> LROPoller[_models.WhatIfOperationResult]: + """Returns changes that will be made by the deployment if executed at the scope of the + subscription. + + :param deployment_name: The name of the deployment. Required. + :type deployment_name: str + :param parameters: Parameters to What If. Is either a model type or a IO type. Required. + :type parameters: ~azure.mgmt.resource.resources.v2021_04_01.models.DeploymentWhatIf or IO + :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. + Default value is None. + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be ARMPolling. Pass in False for this + operation to not poll, or pass in your own initialized polling object for a personal polling + strategy. + :paramtype polling: bool or ~azure.core.polling.PollingMethod + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of LROPoller that returns either WhatIfOperationResult or the result of + cls(response) + :rtype: + ~azure.core.polling.LROPoller[~azure.mgmt.resource.resources.v2021_04_01.models.WhatIfOperationResult] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _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-04-01")) # type: str + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.WhatIfOperationResult] + polling = kwargs.pop("polling", True) # type: Union[bool, PollingMethod] + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token = kwargs.pop("continuation_token", None) # type: Optional[str] if cont_token is None: - raw_result = self._what_if_at_subscription_scope_initial( + raw_result = self._what_if_at_subscription_scope_initial( # type: ignore deployment_name=deployment_name, parameters=parameters, api_version=api_version, content_type=content_type, - cls=lambda x,y,z: x, + cls=lambda x, y, z: x, + headers=_headers, + params=_params, **kwargs ) - kwargs.pop('error_map', None) + kwargs.pop("error_map", None) def get_long_running_output(pipeline_response): - response = pipeline_response.http_response - deserialized = self._deserialize('WhatIfOperationResult', pipeline_response) + deserialized = self._deserialize("WhatIfOperationResult", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - - if polling is True: polling_method = ARMPolling(lro_delay, lro_options={'final-state-via': 'location'}, **kwargs) - elif polling is False: polling_method = NoPolling() - else: polling_method = polling + if polling is True: + polling_method = cast( + PollingMethod, ARMPolling(lro_delay, lro_options={"final-state-via": "location"}, **kwargs) + ) # type: PollingMethod + elif polling is False: + polling_method = cast(PollingMethod, NoPolling()) + else: + polling_method = polling if cont_token: return LROPoller.from_continuation_token( polling_method=polling_method, continuation_token=cont_token, client=self._client, - deserialization_callback=get_long_running_output + deserialization_callback=get_long_running_output, ) return LROPoller(self._client, raw_result, get_long_running_output, polling_method) - begin_what_if_at_subscription_scope.metadata = {'url': "/subscriptions/{subscriptionId}/providers/Microsoft.Resources/deployments/{deploymentName}/whatIf"} # type: ignore + begin_what_if_at_subscription_scope.metadata = {"url": "/subscriptions/{subscriptionId}/providers/Microsoft.Resources/deployments/{deploymentName}/whatIf"} # type: ignore @distributed_trace def export_template_at_subscription_scope( - self, - deployment_name: str, - **kwargs: Any - ) -> "_models.DeploymentExportResult": + self, deployment_name: str, **kwargs: Any + ) -> _models.DeploymentExportResult: """Exports the template used for specified deployment. - :param deployment_name: The name of the deployment. + :param deployment_name: The name of the deployment. Required. :type deployment_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: DeploymentExportResult, or the result of cls(response) + :return: DeploymentExportResult or the result of cls(response) :rtype: ~azure.mgmt.resource.resources.v2021_04_01.models.DeploymentExportResult - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.DeploymentExportResult"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + 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', "2021-04-01") # type: str + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-04-01")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[_models.DeploymentExportResult] - request = build_deployments_export_template_at_subscription_scope_request( deployment_name=deployment_name, subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.export_template_at_subscription_scope.metadata['url'], + template_url=self.export_template_at_subscription_scope.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) - deserialized = self._deserialize('DeploymentExportResult', pipeline_response) + deserialized = self._deserialize("DeploymentExportResult", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - export_template_at_subscription_scope.metadata = {'url': "/subscriptions/{subscriptionId}/providers/Microsoft.Resources/deployments/{deploymentName}/exportTemplate"} # type: ignore - + export_template_at_subscription_scope.metadata = {"url": "/subscriptions/{subscriptionId}/providers/Microsoft.Resources/deployments/{deploymentName}/exportTemplate"} # type: ignore @distributed_trace def list_at_subscription_scope( - self, - filter: Optional[str] = None, - top: Optional[int] = None, - **kwargs: Any - ) -> Iterable["_models.DeploymentListResult"]: + self, filter: Optional[str] = None, top: Optional[int] = None, **kwargs: Any + ) -> Iterable["_models.DeploymentExtended"]: """Get all the deployments for a subscription. :param filter: The filter to apply on the operation. For example, you can use @@ -6650,40 +6998,48 @@ def list_at_subscription_scope( value is None. :type top: int :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either DeploymentListResult or the result of - cls(response) + :return: An iterator like instance of either DeploymentExtended or the result of cls(response) :rtype: - ~azure.core.paging.ItemPaged[~azure.mgmt.resource.resources.v2021_04_01.models.DeploymentListResult] - :raises: ~azure.core.exceptions.HttpResponseError + ~azure.core.paging.ItemPaged[~azure.mgmt.resource.resources.v2021_04_01.models.DeploymentExtended] + :raises ~azure.core.exceptions.HttpResponseError: """ - api_version = kwargs.pop('api_version', "2021-04-01") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-04-01")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[_models.DeploymentListResult] - cls = kwargs.pop('cls', None) # type: ClsType["_models.DeploymentListResult"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) + def prepare_request(next_link=None): if not next_link: - + request = build_deployments_list_at_subscription_scope_request( subscription_id=self._config.subscription_id, - api_version=api_version, filter=filter, top=top, - template_url=self.list_at_subscription_scope.metadata['url'], + api_version=api_version, + template_url=self.list_at_subscription_scope.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore else: - - request = build_deployments_list_at_subscription_scope_request( - subscription_id=self._config.subscription_id, - template_url=next_link, - ) + # make call to next link with the client's api-version + _parsed_next_link = urlparse(next_link) + _next_request_params = case_insensitive_dict(parse_qs(_parsed_next_link.query)) + _next_request_params["api-version"] = self._config.api_version + request = HttpRequest("GET", urljoin(next_link, _parsed_next_link.path), params=_next_request_params) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore request.method = "GET" return request @@ -6697,10 +7053,8 @@ def extract_data(pipeline_response): def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) response = pipeline_response.http_response @@ -6710,42 +7064,43 @@ def get_next(next_link=None): return pipeline_response + return ItemPaged(get_next, extract_data) - return ItemPaged( - get_next, extract_data - ) - list_at_subscription_scope.metadata = {'url': "/subscriptions/{subscriptionId}/providers/Microsoft.Resources/deployments/"} # type: ignore + list_at_subscription_scope.metadata = {"url": "/subscriptions/{subscriptionId}/providers/Microsoft.Resources/deployments/"} # type: ignore def _delete_initial( # pylint: disable=inconsistent-return-statements - self, - resource_group_name: str, - deployment_name: str, - **kwargs: Any + self, resource_group_name: str, deployment_name: str, **kwargs: Any ) -> None: - cls = kwargs.pop('cls', None) # type: ClsType[None] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + 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', "2021-04-01") # type: str + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-04-01")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[None] - - request = build_deployments_delete_request_initial( + request = build_deployments_delete_request( resource_group_name=resource_group_name, deployment_name=deployment_name, subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self._delete_initial.metadata['url'], + template_url=self._delete_initial.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [202, 204]: @@ -6755,16 +7110,10 @@ 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.Resources/deployments/{deploymentName}"} # type: ignore - + _delete_initial.metadata = {"url": "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/Microsoft.Resources/deployments/{deploymentName}"} # type: ignore @distributed_trace - def begin_delete( # pylint: disable=inconsistent-return-statements - self, - resource_group_name: str, - deployment_name: str, - **kwargs: Any - ) -> LROPoller[None]: + def begin_delete(self, resource_group_name: str, deployment_name: str, **kwargs: Any) -> LROPoller[None]: """Deletes a deployment from the deployment history. A template deployment that is currently running cannot be deleted. Deleting a template @@ -6777,9 +7126,9 @@ def begin_delete( # pylint: disable=inconsistent-return-statements asynchronous request failed, the URI in the Location header returns an error-level status code. :param resource_group_name: The name of the resource group with the deployment to delete. The - name is case insensitive. + name is case insensitive. Required. :type resource_group_name: str - :param deployment_name: The name of the deployment. + :param deployment_name: The name of the deployment. Required. :type deployment_name: str :keyword callable cls: A custom type or function that will be passed the direct response :keyword str continuation_token: A continuation token to restart a poller from a saved state. @@ -6791,88 +7140,93 @@ def begin_delete( # pylint: disable=inconsistent-return-statements Retry-After header is present. :return: An instance of LROPoller that returns either None or the result of cls(response) :rtype: ~azure.core.polling.LROPoller[None] - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - api_version = kwargs.pop('api_version', "2021-04-01") # type: str - polling = kwargs.pop('polling', True) # type: Union[bool, PollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType[None] - lro_delay = kwargs.pop( - 'polling_interval', - self._config.polling_interval - ) - cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-04-01")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[None] + polling = kwargs.pop("polling", True) # type: Union[bool, PollingMethod] + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token = kwargs.pop("continuation_token", None) # type: Optional[str] if cont_token is None: - raw_result = self._delete_initial( + raw_result = self._delete_initial( # type: ignore resource_group_name=resource_group_name, deployment_name=deployment_name, api_version=api_version, - cls=lambda x,y,z: x, + cls=lambda x, y, z: x, + headers=_headers, + params=_params, **kwargs ) - kwargs.pop('error_map', None) + kwargs.pop("error_map", None) - def get_long_running_output(pipeline_response): + def get_long_running_output(pipeline_response): # pylint: disable=inconsistent-return-statements if cls: return cls(pipeline_response, None, {}) - - if polling is True: polling_method = ARMPolling(lro_delay, **kwargs) - elif polling is False: polling_method = NoPolling() - else: polling_method = polling + if polling is True: + polling_method = cast(PollingMethod, ARMPolling(lro_delay, **kwargs)) # type: PollingMethod + elif polling is False: + polling_method = cast(PollingMethod, NoPolling()) + else: + polling_method = polling if cont_token: return LROPoller.from_continuation_token( polling_method=polling_method, continuation_token=cont_token, client=self._client, - deserialization_callback=get_long_running_output + deserialization_callback=get_long_running_output, ) return LROPoller(self._client, raw_result, get_long_running_output, polling_method) - begin_delete.metadata = {'url': "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/Microsoft.Resources/deployments/{deploymentName}"} # type: ignore + begin_delete.metadata = {"url": "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/Microsoft.Resources/deployments/{deploymentName}"} # type: ignore @distributed_trace - def check_existence( - self, - resource_group_name: str, - deployment_name: str, - **kwargs: Any - ) -> bool: + def check_existence(self, resource_group_name: str, deployment_name: str, **kwargs: Any) -> bool: """Checks whether the deployment exists. :param resource_group_name: The name of the resource group with the deployment to check. The - name is case insensitive. + name is case insensitive. Required. :type resource_group_name: str - :param deployment_name: The name of the deployment. + :param deployment_name: The name of the deployment. Required. :type deployment_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: bool, or the result of cls(response) + :return: bool or the result of cls(response) :rtype: bool - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType[None] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + 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', "2021-04-01") # type: str + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-04-01")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[None] - request = build_deployments_check_existence_request( resource_group_name=resource_group_name, deployment_name=deployment_name, subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.check_existence.metadata['url'], + template_url=self.check_existence.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [204, 404]: @@ -6883,44 +7237,53 @@ def check_existence( return cls(pipeline_response, None, {}) return 200 <= response.status_code <= 299 - check_existence.metadata = {'url': "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/Microsoft.Resources/deployments/{deploymentName}"} # type: ignore - + check_existence.metadata = {"url": "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/Microsoft.Resources/deployments/{deploymentName}"} # type: ignore def _create_or_update_initial( - self, - resource_group_name: str, - deployment_name: str, - parameters: "_models.Deployment", - **kwargs: Any - ) -> "_models.DeploymentExtended": - cls = kwargs.pop('cls', None) # type: ClsType["_models.DeploymentExtended"] + self, resource_group_name: str, deployment_name: str, parameters: Union[_models.Deployment, IO], **kwargs: Any + ) -> _models.DeploymentExtended: error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) - api_version = kwargs.pop('api_version', "2021-04-01") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - _json = self._serialize.body(parameters, 'Deployment') + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-04-01")) # type: str + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.DeploymentExtended] + + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(parameters, (IO, bytes)): + _content = parameters + else: + _json = self._serialize.body(parameters, "Deployment") - request = build_deployments_create_or_update_request_initial( + request = build_deployments_create_or_update_request( resource_group_name=resource_group_name, deployment_name=deployment_name, subscription_id=self._config.subscription_id, api_version=api_version, content_type=content_type, json=_json, - template_url=self._create_or_update_initial.metadata['url'], + content=_content, + template_url=self._create_or_update_initial.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200, 201]: @@ -6928,38 +7291,42 @@ def _create_or_update_initial( raise HttpResponseError(response=response, error_format=ARMErrorFormat) if response.status_code == 200: - deserialized = self._deserialize('DeploymentExtended', pipeline_response) + deserialized = self._deserialize("DeploymentExtended", pipeline_response) if response.status_code == 201: - deserialized = self._deserialize('DeploymentExtended', pipeline_response) + deserialized = self._deserialize("DeploymentExtended", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - _create_or_update_initial.metadata = {'url': "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/Microsoft.Resources/deployments/{deploymentName}"} # type: ignore - + _create_or_update_initial.metadata = {"url": "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/Microsoft.Resources/deployments/{deploymentName}"} # type: ignore - @distributed_trace + @overload def begin_create_or_update( self, resource_group_name: str, deployment_name: str, - parameters: "_models.Deployment", + parameters: _models.Deployment, + *, + content_type: str = "application/json", **kwargs: Any - ) -> LROPoller["_models.DeploymentExtended"]: + ) -> LROPoller[_models.DeploymentExtended]: """Deploys resources to a resource group. You can provide the template and parameters directly in the request or link to JSON files. :param resource_group_name: The name of the resource group to deploy the resources to. The name - is case insensitive. The resource group must already exist. + is case insensitive. The resource group must already exist. Required. :type resource_group_name: str - :param deployment_name: The name of the deployment. + :param deployment_name: The name of the deployment. Required. :type deployment_name: str - :param parameters: Additional parameters supplied to the operation. + :param parameters: Additional parameters supplied to the operation. Required. :type parameters: ~azure.mgmt.resource.resources.v2021_04_01.models.Deployment + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str :keyword callable cls: A custom type or function that will be passed the direct response :keyword str continuation_token: A continuation token to restart a poller from a saved state. :keyword polling: By default, your polling method will be ARMPolling. Pass in False for this @@ -6972,115 +7339,189 @@ def begin_create_or_update( cls(response) :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.resource.resources.v2021_04_01.models.DeploymentExtended] - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - api_version = kwargs.pop('api_version', "2021-04-01") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] - polling = kwargs.pop('polling', True) # type: Union[bool, PollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType["_models.DeploymentExtended"] - lro_delay = kwargs.pop( - 'polling_interval', - self._config.polling_interval - ) - cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] - if cont_token is None: - raw_result = self._create_or_update_initial( - resource_group_name=resource_group_name, - deployment_name=deployment_name, - parameters=parameters, - api_version=api_version, - content_type=content_type, - cls=lambda x,y,z: x, - **kwargs - ) - kwargs.pop('error_map', None) - - def get_long_running_output(pipeline_response): - response = pipeline_response.http_response - deserialized = self._deserialize('DeploymentExtended', pipeline_response) - if cls: - return cls(pipeline_response, deserialized, {}) - return deserialized - - - if polling is True: polling_method = ARMPolling(lro_delay, **kwargs) - elif polling is False: polling_method = NoPolling() - else: polling_method = polling - if cont_token: - return LROPoller.from_continuation_token( - polling_method=polling_method, - continuation_token=cont_token, - client=self._client, - deserialization_callback=get_long_running_output - ) - return LROPoller(self._client, raw_result, get_long_running_output, polling_method) - - begin_create_or_update.metadata = {'url': "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/Microsoft.Resources/deployments/{deploymentName}"} # type: ignore - @distributed_trace - def get( + @overload + def begin_create_or_update( self, resource_group_name: str, deployment_name: str, + parameters: IO, + *, + content_type: str = "application/json", **kwargs: Any - ) -> "_models.DeploymentExtended": - """Gets a deployment. + ) -> LROPoller[_models.DeploymentExtended]: + """Deploys resources to a resource group. - :param resource_group_name: The name of the resource group. The name is case insensitive. + You can provide the template and parameters directly in the request or link to JSON files. + + :param resource_group_name: The name of the resource group to deploy the resources to. The name + is case insensitive. The resource group must already exist. Required. :type resource_group_name: str - :param deployment_name: The name of the deployment. + :param deployment_name: The name of the deployment. Required. :type deployment_name: str + :param parameters: Additional parameters supplied to the operation. Required. + :type parameters: IO + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: DeploymentExtended, or the result of cls(response) - :rtype: ~azure.mgmt.resource.resources.v2021_04_01.models.DeploymentExtended - :raises: ~azure.core.exceptions.HttpResponseError - """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.DeploymentExtended"] - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be ARMPolling. Pass in False for this + operation to not poll, or pass in your own initialized polling object for a personal polling + strategy. + :paramtype polling: bool or ~azure.core.polling.PollingMethod + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of LROPoller that returns either DeploymentExtended or the result of + cls(response) + :rtype: + ~azure.core.polling.LROPoller[~azure.mgmt.resource.resources.v2021_04_01.models.DeploymentExtended] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace + def begin_create_or_update( + self, resource_group_name: str, deployment_name: str, parameters: Union[_models.Deployment, IO], **kwargs: Any + ) -> LROPoller[_models.DeploymentExtended]: + """Deploys resources to a resource group. + + You can provide the template and parameters directly in the request or link to JSON files. + + :param resource_group_name: The name of the resource group to deploy the resources to. The name + is case insensitive. The resource group must already exist. Required. + :type resource_group_name: str + :param deployment_name: The name of the deployment. Required. + :type deployment_name: str + :param parameters: Additional parameters supplied to the operation. Is either a model type or a + IO type. Required. + :type parameters: ~azure.mgmt.resource.resources.v2021_04_01.models.Deployment or IO + :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. + Default value is None. + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be ARMPolling. Pass in False for this + operation to not poll, or pass in your own initialized polling object for a personal polling + strategy. + :paramtype polling: bool or ~azure.core.polling.PollingMethod + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of LROPoller that returns either DeploymentExtended or the result of + cls(response) + :rtype: + ~azure.core.polling.LROPoller[~azure.mgmt.resource.resources.v2021_04_01.models.DeploymentExtended] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _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-04-01")) # type: str + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.DeploymentExtended] + polling = kwargs.pop("polling", True) # type: Union[bool, PollingMethod] + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token = kwargs.pop("continuation_token", None) # type: Optional[str] + if cont_token is None: + raw_result = self._create_or_update_initial( # type: ignore + resource_group_name=resource_group_name, + deployment_name=deployment_name, + parameters=parameters, + api_version=api_version, + content_type=content_type, + cls=lambda x, y, z: x, + headers=_headers, + params=_params, + **kwargs + ) + kwargs.pop("error_map", None) + + def get_long_running_output(pipeline_response): + deserialized = self._deserialize("DeploymentExtended", pipeline_response) + if cls: + return cls(pipeline_response, deserialized, {}) + return deserialized + + if polling is True: + polling_method = cast(PollingMethod, ARMPolling(lro_delay, **kwargs)) # type: PollingMethod + elif polling is False: + polling_method = cast(PollingMethod, NoPolling()) + else: + polling_method = polling + if cont_token: + return LROPoller.from_continuation_token( + polling_method=polling_method, + continuation_token=cont_token, + client=self._client, + deserialization_callback=get_long_running_output, + ) + return LROPoller(self._client, raw_result, get_long_running_output, polling_method) + + begin_create_or_update.metadata = {"url": "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/Microsoft.Resources/deployments/{deploymentName}"} # type: ignore + + @distributed_trace + def get(self, resource_group_name: str, deployment_name: str, **kwargs: Any) -> _models.DeploymentExtended: + """Gets a deployment. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param deployment_name: The name of the deployment. Required. + :type deployment_name: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: DeploymentExtended or the result of cls(response) + :rtype: ~azure.mgmt.resource.resources.v2021_04_01.models.DeploymentExtended + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) - api_version = kwargs.pop('api_version', "2021-04-01") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-04-01")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[_models.DeploymentExtended] - request = build_deployments_get_request( resource_group_name=resource_group_name, deployment_name=deployment_name, subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.get.metadata['url'], + template_url=self.get.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) - deserialized = self._deserialize('DeploymentExtended', pipeline_response) + deserialized = self._deserialize("DeploymentExtended", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - get.metadata = {'url': "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/Microsoft.Resources/deployments/{deploymentName}"} # type: ignore - + get.metadata = {"url": "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/Microsoft.Resources/deployments/{deploymentName}"} # type: ignore @distributed_trace def cancel( # pylint: disable=inconsistent-return-statements - self, - resource_group_name: str, - deployment_name: str, - **kwargs: Any + self, resource_group_name: str, deployment_name: str, **kwargs: Any ) -> None: """Cancels a currently running template deployment. @@ -7090,38 +7531,45 @@ def cancel( # pylint: disable=inconsistent-return-statements partially deployed. :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. :type resource_group_name: str - :param deployment_name: The name of the deployment. + :param deployment_name: The name of the deployment. Required. :type deployment_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: None, or the result of cls(response) + :return: None or the result of cls(response) :rtype: None - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType[None] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + 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', "2021-04-01") # type: str + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-04-01")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[None] - request = build_deployments_cancel_request( resource_group_name=resource_group_name, deployment_name=deployment_name, subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.cancel.metadata['url'], + template_url=self.cancel.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [204]: @@ -7131,44 +7579,53 @@ def cancel( # pylint: disable=inconsistent-return-statements if cls: return cls(pipeline_response, None, {}) - cancel.metadata = {'url': "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/Microsoft.Resources/deployments/{deploymentName}/cancel"} # type: ignore - + cancel.metadata = {"url": "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/Microsoft.Resources/deployments/{deploymentName}/cancel"} # type: ignore def _validate_initial( - self, - resource_group_name: str, - deployment_name: str, - parameters: "_models.Deployment", - **kwargs: Any - ) -> Optional["_models.DeploymentValidateResult"]: - cls = kwargs.pop('cls', None) # type: ClsType[Optional["_models.DeploymentValidateResult"]] + self, resource_group_name: str, deployment_name: str, parameters: Union[_models.Deployment, IO], **kwargs: Any + ) -> Optional[_models.DeploymentValidateResult]: error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) - api_version = kwargs.pop('api_version', "2021-04-01") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - _json = self._serialize.body(parameters, 'Deployment') + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-04-01")) # type: str + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[Optional[_models.DeploymentValidateResult]] - request = build_deployments_validate_request_initial( + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(parameters, (IO, bytes)): + _content = parameters + else: + _json = self._serialize.body(parameters, "Deployment") + + request = build_deployments_validate_request( resource_group_name=resource_group_name, deployment_name=deployment_name, subscription_id=self._config.subscription_id, api_version=api_version, content_type=content_type, json=_json, - template_url=self._validate_initial.metadata['url'], + content=_content, + template_url=self._validate_initial.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200, 202, 400]: @@ -7177,37 +7634,41 @@ def _validate_initial( deserialized = None if response.status_code == 200: - deserialized = self._deserialize('DeploymentValidateResult', pipeline_response) + deserialized = self._deserialize("DeploymentValidateResult", pipeline_response) if response.status_code == 400: - deserialized = self._deserialize('DeploymentValidateResult', pipeline_response) + deserialized = self._deserialize("DeploymentValidateResult", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - _validate_initial.metadata = {'url': "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/Microsoft.Resources/deployments/{deploymentName}/validate"} # type: ignore - + _validate_initial.metadata = {"url": "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/Microsoft.Resources/deployments/{deploymentName}/validate"} # type: ignore - @distributed_trace + @overload def begin_validate( self, resource_group_name: str, deployment_name: str, - parameters: "_models.Deployment", + parameters: _models.Deployment, + *, + content_type: str = "application/json", **kwargs: Any - ) -> LROPoller["_models.DeploymentValidateResult"]: + ) -> LROPoller[_models.DeploymentValidateResult]: """Validates whether the specified template is syntactically correct and will be accepted by Azure Resource Manager.. :param resource_group_name: The name of the resource group the template will be deployed to. - The name is case insensitive. + The name is case insensitive. Required. :type resource_group_name: str - :param deployment_name: The name of the deployment. + :param deployment_name: The name of the deployment. Required. :type deployment_name: str - :param parameters: Parameters to validate. + :param parameters: Parameters to validate. Required. :type parameters: ~azure.mgmt.resource.resources.v2021_04_01.models.Deployment + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str :keyword callable cls: A custom type or function that will be passed the direct response :keyword str continuation_token: A continuation token to restart a poller from a saved state. :keyword polling: By default, your polling method will be ARMPolling. Pass in False for this @@ -7220,86 +7681,173 @@ def begin_validate( cls(response) :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.resource.resources.v2021_04_01.models.DeploymentValidateResult] - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - api_version = kwargs.pop('api_version', "2021-04-01") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] - polling = kwargs.pop('polling', True) # type: Union[bool, PollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType["_models.DeploymentValidateResult"] - lro_delay = kwargs.pop( - 'polling_interval', - self._config.polling_interval - ) - cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] + + @overload + def begin_validate( + self, + resource_group_name: str, + deployment_name: str, + parameters: IO, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> LROPoller[_models.DeploymentValidateResult]: + """Validates whether the specified template is syntactically correct and will be accepted by Azure + Resource Manager.. + + :param resource_group_name: The name of the resource group the template will be deployed to. + The name is case insensitive. Required. + :type resource_group_name: str + :param deployment_name: The name of the deployment. Required. + :type deployment_name: str + :param parameters: Parameters to validate. Required. + :type parameters: IO + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be ARMPolling. Pass in False for this + operation to not poll, or pass in your own initialized polling object for a personal polling + strategy. + :paramtype polling: bool or ~azure.core.polling.PollingMethod + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of LROPoller that returns either DeploymentValidateResult or the result of + cls(response) + :rtype: + ~azure.core.polling.LROPoller[~azure.mgmt.resource.resources.v2021_04_01.models.DeploymentValidateResult] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace + def begin_validate( + self, resource_group_name: str, deployment_name: str, parameters: Union[_models.Deployment, IO], **kwargs: Any + ) -> LROPoller[_models.DeploymentValidateResult]: + """Validates whether the specified template is syntactically correct and will be accepted by Azure + Resource Manager.. + + :param resource_group_name: The name of the resource group the template will be deployed to. + The name is case insensitive. Required. + :type resource_group_name: str + :param deployment_name: The name of the deployment. Required. + :type deployment_name: str + :param parameters: Parameters to validate. Is either a model type or a IO type. Required. + :type parameters: ~azure.mgmt.resource.resources.v2021_04_01.models.Deployment or IO + :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. + Default value is None. + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be ARMPolling. Pass in False for this + operation to not poll, or pass in your own initialized polling object for a personal polling + strategy. + :paramtype polling: bool or ~azure.core.polling.PollingMethod + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of LROPoller that returns either DeploymentValidateResult or the result of + cls(response) + :rtype: + ~azure.core.polling.LROPoller[~azure.mgmt.resource.resources.v2021_04_01.models.DeploymentValidateResult] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _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-04-01")) # type: str + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.DeploymentValidateResult] + polling = kwargs.pop("polling", True) # type: Union[bool, PollingMethod] + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token = kwargs.pop("continuation_token", None) # type: Optional[str] if cont_token is None: - raw_result = self._validate_initial( + raw_result = self._validate_initial( # type: ignore resource_group_name=resource_group_name, deployment_name=deployment_name, parameters=parameters, api_version=api_version, content_type=content_type, - cls=lambda x,y,z: x, + cls=lambda x, y, z: x, + headers=_headers, + params=_params, **kwargs ) - kwargs.pop('error_map', None) + kwargs.pop("error_map", None) def get_long_running_output(pipeline_response): - response = pipeline_response.http_response - deserialized = self._deserialize('DeploymentValidateResult', pipeline_response) + deserialized = self._deserialize("DeploymentValidateResult", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - - if polling is True: polling_method = ARMPolling(lro_delay, **kwargs) - elif polling is False: polling_method = NoPolling() - else: polling_method = polling + if polling is True: + polling_method = cast(PollingMethod, ARMPolling(lro_delay, **kwargs)) # type: PollingMethod + elif polling is False: + polling_method = cast(PollingMethod, NoPolling()) + else: + polling_method = polling if cont_token: return LROPoller.from_continuation_token( polling_method=polling_method, continuation_token=cont_token, client=self._client, - deserialization_callback=get_long_running_output + deserialization_callback=get_long_running_output, ) return LROPoller(self._client, raw_result, get_long_running_output, polling_method) - begin_validate.metadata = {'url': "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/Microsoft.Resources/deployments/{deploymentName}/validate"} # type: ignore + begin_validate.metadata = {"url": "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/Microsoft.Resources/deployments/{deploymentName}/validate"} # type: ignore def _what_if_initial( self, resource_group_name: str, deployment_name: str, - parameters: "_models.DeploymentWhatIf", + parameters: Union[_models.DeploymentWhatIf, IO], **kwargs: Any - ) -> Optional["_models.WhatIfOperationResult"]: - cls = kwargs.pop('cls', None) # type: ClsType[Optional["_models.WhatIfOperationResult"]] + ) -> Optional[_models.WhatIfOperationResult]: error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', "2021-04-01") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-04-01")) # type: str + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[Optional[_models.WhatIfOperationResult]] - _json = self._serialize.body(parameters, 'DeploymentWhatIf') + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(parameters, (IO, bytes)): + _content = parameters + else: + _json = self._serialize.body(parameters, "DeploymentWhatIf") - request = build_deployments_what_if_request_initial( + request = build_deployments_what_if_request( resource_group_name=resource_group_name, deployment_name=deployment_name, subscription_id=self._config.subscription_id, api_version=api_version, content_type=content_type, json=_json, - template_url=self._what_if_initial.metadata['url'], + content=_content, + template_url=self._what_if_initial.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200, 202]: @@ -7309,39 +7857,116 @@ def _what_if_initial( deserialized = None response_headers = {} if response.status_code == 200: - deserialized = self._deserialize('WhatIfOperationResult', pipeline_response) + deserialized = self._deserialize("WhatIfOperationResult", pipeline_response) if response.status_code == 202: - response_headers['Location']=self._deserialize('str', response.headers.get('Location')) - response_headers['Retry-After']=self._deserialize('str', response.headers.get('Retry-After')) - + response_headers["Location"] = self._deserialize("str", response.headers.get("Location")) + response_headers["Retry-After"] = self._deserialize("str", response.headers.get("Retry-After")) if cls: return cls(pipeline_response, deserialized, response_headers) return deserialized - _what_if_initial.metadata = {'url': "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/Microsoft.Resources/deployments/{deploymentName}/whatIf"} # type: ignore + _what_if_initial.metadata = {"url": "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/Microsoft.Resources/deployments/{deploymentName}/whatIf"} # type: ignore + + @overload + def begin_what_if( + self, + resource_group_name: str, + deployment_name: str, + parameters: _models.DeploymentWhatIf, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> LROPoller[_models.WhatIfOperationResult]: + """Returns changes that will be made by the deployment if executed at the scope of the resource + group. + + :param resource_group_name: The name of the resource group the template will be deployed to. + The name is case insensitive. Required. + :type resource_group_name: str + :param deployment_name: The name of the deployment. Required. + :type deployment_name: str + :param parameters: Parameters to validate. Required. + :type parameters: ~azure.mgmt.resource.resources.v2021_04_01.models.DeploymentWhatIf + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be ARMPolling. Pass in False for this + operation to not poll, or pass in your own initialized polling object for a personal polling + strategy. + :paramtype polling: bool or ~azure.core.polling.PollingMethod + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of LROPoller that returns either WhatIfOperationResult or the result of + cls(response) + :rtype: + ~azure.core.polling.LROPoller[~azure.mgmt.resource.resources.v2021_04_01.models.WhatIfOperationResult] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + def begin_what_if( + self, + resource_group_name: str, + deployment_name: str, + parameters: IO, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> LROPoller[_models.WhatIfOperationResult]: + """Returns changes that will be made by the deployment if executed at the scope of the resource + group. + :param resource_group_name: The name of the resource group the template will be deployed to. + The name is case insensitive. Required. + :type resource_group_name: str + :param deployment_name: The name of the deployment. Required. + :type deployment_name: str + :param parameters: Parameters to validate. Required. + :type parameters: IO + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be ARMPolling. Pass in False for this + operation to not poll, or pass in your own initialized polling object for a personal polling + strategy. + :paramtype polling: bool or ~azure.core.polling.PollingMethod + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of LROPoller that returns either WhatIfOperationResult or the result of + cls(response) + :rtype: + ~azure.core.polling.LROPoller[~azure.mgmt.resource.resources.v2021_04_01.models.WhatIfOperationResult] + :raises ~azure.core.exceptions.HttpResponseError: + """ @distributed_trace def begin_what_if( self, resource_group_name: str, deployment_name: str, - parameters: "_models.DeploymentWhatIf", + parameters: Union[_models.DeploymentWhatIf, IO], **kwargs: Any - ) -> LROPoller["_models.WhatIfOperationResult"]: + ) -> LROPoller[_models.WhatIfOperationResult]: """Returns changes that will be made by the deployment if executed at the scope of the resource group. :param resource_group_name: The name of the resource group the template will be deployed to. - The name is case insensitive. + The name is case insensitive. Required. :type resource_group_name: str - :param deployment_name: The name of the deployment. + :param deployment_name: The name of the deployment. Required. :type deployment_name: str - :param parameters: Parameters to validate. - :type parameters: ~azure.mgmt.resource.resources.v2021_04_01.models.DeploymentWhatIf + :param parameters: Parameters to validate. Is either a model type or a IO type. Required. + :type parameters: ~azure.mgmt.resource.resources.v2021_04_01.models.DeploymentWhatIf or IO + :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. + Default value is None. + :paramtype content_type: str :keyword callable cls: A custom type or function that will be passed the direct response :keyword str continuation_token: A continuation token to restart a poller from a saved state. :keyword polling: By default, your polling method will be ARMPolling. Pass in False for this @@ -7354,121 +7979,125 @@ def begin_what_if( cls(response) :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.resource.resources.v2021_04_01.models.WhatIfOperationResult] - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - api_version = kwargs.pop('api_version', "2021-04-01") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] - polling = kwargs.pop('polling', True) # type: Union[bool, PollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType["_models.WhatIfOperationResult"] - lro_delay = kwargs.pop( - 'polling_interval', - self._config.polling_interval - ) - cont_token = kwargs.pop('continuation_token', None) # type: Optional[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-04-01")) # type: str + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.WhatIfOperationResult] + polling = kwargs.pop("polling", True) # type: Union[bool, PollingMethod] + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token = kwargs.pop("continuation_token", None) # type: Optional[str] if cont_token is None: - raw_result = self._what_if_initial( + raw_result = self._what_if_initial( # type: ignore resource_group_name=resource_group_name, deployment_name=deployment_name, parameters=parameters, api_version=api_version, content_type=content_type, - cls=lambda x,y,z: x, + cls=lambda x, y, z: x, + headers=_headers, + params=_params, **kwargs ) - kwargs.pop('error_map', None) + kwargs.pop("error_map", None) def get_long_running_output(pipeline_response): - response = pipeline_response.http_response - deserialized = self._deserialize('WhatIfOperationResult', pipeline_response) + deserialized = self._deserialize("WhatIfOperationResult", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - - if polling is True: polling_method = ARMPolling(lro_delay, lro_options={'final-state-via': 'location'}, **kwargs) - elif polling is False: polling_method = NoPolling() - else: polling_method = polling + if polling is True: + polling_method = cast( + PollingMethod, ARMPolling(lro_delay, lro_options={"final-state-via": "location"}, **kwargs) + ) # type: PollingMethod + elif polling is False: + polling_method = cast(PollingMethod, NoPolling()) + else: + polling_method = polling if cont_token: return LROPoller.from_continuation_token( polling_method=polling_method, continuation_token=cont_token, client=self._client, - deserialization_callback=get_long_running_output + deserialization_callback=get_long_running_output, ) return LROPoller(self._client, raw_result, get_long_running_output, polling_method) - begin_what_if.metadata = {'url': "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/Microsoft.Resources/deployments/{deploymentName}/whatIf"} # type: ignore + begin_what_if.metadata = {"url": "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/Microsoft.Resources/deployments/{deploymentName}/whatIf"} # type: ignore @distributed_trace def export_template( - self, - resource_group_name: str, - deployment_name: str, - **kwargs: Any - ) -> "_models.DeploymentExportResult": + self, resource_group_name: str, deployment_name: str, **kwargs: Any + ) -> _models.DeploymentExportResult: """Exports the template used for specified deployment. :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. :type resource_group_name: str - :param deployment_name: The name of the deployment. + :param deployment_name: The name of the deployment. Required. :type deployment_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: DeploymentExportResult, or the result of cls(response) + :return: DeploymentExportResult or the result of cls(response) :rtype: ~azure.mgmt.resource.resources.v2021_04_01.models.DeploymentExportResult - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.DeploymentExportResult"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) - api_version = kwargs.pop('api_version', "2021-04-01") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-04-01")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[_models.DeploymentExportResult] - request = build_deployments_export_template_request( resource_group_name=resource_group_name, deployment_name=deployment_name, subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.export_template.metadata['url'], + template_url=self.export_template.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) - deserialized = self._deserialize('DeploymentExportResult', pipeline_response) + deserialized = self._deserialize("DeploymentExportResult", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - export_template.metadata = {'url': "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/Microsoft.Resources/deployments/{deploymentName}/exportTemplate"} # type: ignore - + export_template.metadata = {"url": "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/Microsoft.Resources/deployments/{deploymentName}/exportTemplate"} # type: ignore @distributed_trace def list_by_resource_group( - self, - resource_group_name: str, - filter: Optional[str] = None, - top: Optional[int] = None, - **kwargs: Any - ) -> Iterable["_models.DeploymentListResult"]: + self, resource_group_name: str, filter: Optional[str] = None, top: Optional[int] = None, **kwargs: Any + ) -> Iterable["_models.DeploymentExtended"]: """Get all the deployments for a resource group. :param resource_group_name: The name of the resource group with the deployments to get. The - name is case insensitive. + name is case insensitive. Required. :type resource_group_name: str :param filter: The filter to apply on the operation. For example, you can use $filter=provisioningState eq '{state}'. Default value is None. @@ -7477,42 +8106,49 @@ def list_by_resource_group( value is None. :type top: int :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either DeploymentListResult or the result of - cls(response) + :return: An iterator like instance of either DeploymentExtended or the result of cls(response) :rtype: - ~azure.core.paging.ItemPaged[~azure.mgmt.resource.resources.v2021_04_01.models.DeploymentListResult] - :raises: ~azure.core.exceptions.HttpResponseError + ~azure.core.paging.ItemPaged[~azure.mgmt.resource.resources.v2021_04_01.models.DeploymentExtended] + :raises ~azure.core.exceptions.HttpResponseError: """ - api_version = kwargs.pop('api_version', "2021-04-01") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-04-01")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[_models.DeploymentListResult] - cls = kwargs.pop('cls', None) # type: ClsType["_models.DeploymentListResult"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) + def prepare_request(next_link=None): if not next_link: - + request = build_deployments_list_by_resource_group_request( resource_group_name=resource_group_name, subscription_id=self._config.subscription_id, - api_version=api_version, filter=filter, top=top, - template_url=self.list_by_resource_group.metadata['url'], + 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.url = self._client.format_url(request.url) # type: ignore else: - - request = build_deployments_list_by_resource_group_request( - resource_group_name=resource_group_name, - subscription_id=self._config.subscription_id, - template_url=next_link, - ) + # make call to next link with the client's api-version + _parsed_next_link = urlparse(next_link) + _next_request_params = case_insensitive_dict(parse_qs(_parsed_next_link.query)) + _next_request_params["api-version"] = self._config.api_version + request = HttpRequest("GET", urljoin(next_link, _parsed_next_link.path), params=_next_request_params) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore request.method = "GET" return request @@ -7526,10 +8162,8 @@ def extract_data(pipeline_response): def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) response = pipeline_response.http_response @@ -7539,184 +8173,192 @@ def get_next(next_link=None): return pipeline_response + return ItemPaged(get_next, extract_data) - return ItemPaged( - get_next, extract_data - ) - list_by_resource_group.metadata = {'url': "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/Microsoft.Resources/deployments/"} # type: ignore + list_by_resource_group.metadata = {"url": "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/Microsoft.Resources/deployments/"} # type: ignore @distributed_trace - def calculate_template_hash( - self, - template: Any, - **kwargs: Any - ) -> "_models.TemplateHashResult": + def calculate_template_hash(self, template: JSON, **kwargs: Any) -> _models.TemplateHashResult: """Calculate the hash of the given template. - :param template: The template provided to calculate hash. - :type template: any + :param template: The template provided to calculate hash. Required. + :type template: JSON :keyword callable cls: A custom type or function that will be passed the direct response - :return: TemplateHashResult, or the result of cls(response) + :return: TemplateHashResult or the result of cls(response) :rtype: ~azure.mgmt.resource.resources.v2021_04_01.models.TemplateHashResult - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.TemplateHashResult"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) - api_version = kwargs.pop('api_version', "2021-04-01") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - _json = self._serialize.body(template, 'object') + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-04-01")) # type: str + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", "application/json")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[_models.TemplateHashResult] + + _json = self._serialize.body(template, "object") request = build_deployments_calculate_template_hash_request( api_version=api_version, content_type=content_type, json=_json, - template_url=self.calculate_template_hash.metadata['url'], + template_url=self.calculate_template_hash.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) - deserialized = self._deserialize('TemplateHashResult', pipeline_response) + deserialized = self._deserialize("TemplateHashResult", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - calculate_template_hash.metadata = {'url': "/providers/Microsoft.Resources/calculateTemplateHash"} # type: ignore + calculate_template_hash.metadata = {"url": "/providers/Microsoft.Resources/calculateTemplateHash"} # type: ignore -class ProvidersOperations(object): - """ProvidersOperations operations. - You should not instantiate this class directly. Instead, you should create a Client instance that - instantiates it for you and attaches it as an attribute. +class ProvidersOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. - :ivar models: Alias to model classes used in this operation group. - :type models: ~azure.mgmt.resource.resources.v2021_04_01.models - :param client: Client for service requests. - :param config: Configuration of service client. - :param serializer: An object model serializer. - :param deserializer: An object model deserializer. + Instead, you should access the following operations through + :class:`~azure.mgmt.resource.resources.v2021_04_01.ResourceManagementClient`'s + :attr:`providers` attribute. """ models = _models - def __init__(self, client, config, serializer, deserializer): - self._client = client - self._serialize = serializer - self._deserialize = deserializer - self._config = config + def __init__(self, *args, **kwargs): + input_args = list(args) + self._client = input_args.pop(0) if input_args else kwargs.pop("client") + self._config = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") @distributed_trace - def unregister( - self, - resource_provider_namespace: str, - **kwargs: Any - ) -> "_models.Provider": + def unregister(self, resource_provider_namespace: str, **kwargs: Any) -> _models.Provider: """Unregisters a subscription from a resource provider. :param resource_provider_namespace: The namespace of the resource provider to unregister. + Required. :type resource_provider_namespace: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: Provider, or the result of cls(response) + :return: Provider or the result of cls(response) :rtype: ~azure.mgmt.resource.resources.v2021_04_01.models.Provider - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.Provider"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) - api_version = kwargs.pop('api_version', "2021-04-01") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-04-01")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[_models.Provider] - request = build_providers_unregister_request( resource_provider_namespace=resource_provider_namespace, subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.unregister.metadata['url'], + template_url=self.unregister.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) - deserialized = self._deserialize('Provider', pipeline_response) + deserialized = self._deserialize("Provider", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - unregister.metadata = {'url': "/subscriptions/{subscriptionId}/providers/{resourceProviderNamespace}/unregister"} # type: ignore - + unregister.metadata = {"url": "/subscriptions/{subscriptionId}/providers/{resourceProviderNamespace}/unregister"} # type: ignore @distributed_trace def register_at_management_group_scope( # pylint: disable=inconsistent-return-statements - self, - resource_provider_namespace: str, - group_id: str, - **kwargs: Any + self, resource_provider_namespace: str, group_id: str, **kwargs: Any ) -> None: - """Registers a management group with a resource provider. + """Registers a management group with a resource provider. Use this operation to register a + resource provider with resource types that can be deployed at the management group scope. It + does not recursively register subscriptions within the management group. Instead, you must + register subscriptions individually. :param resource_provider_namespace: The namespace of the resource provider to register. + Required. :type resource_provider_namespace: str - :param group_id: The management group ID. + :param group_id: The management group ID. Required. :type group_id: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: None, or the result of cls(response) + :return: None or the result of cls(response) :rtype: None - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType[None] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + 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', "2021-04-01") # type: str + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-04-01")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[None] - request = build_providers_register_at_management_group_scope_request( resource_provider_namespace=resource_provider_namespace, group_id=group_id, api_version=api_version, - template_url=self.register_at_management_group_scope.metadata['url'], + template_url=self.register_at_management_group_scope.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200]: @@ -7726,94 +8368,164 @@ def register_at_management_group_scope( # pylint: disable=inconsistent-return-s if cls: return cls(pipeline_response, None, {}) - register_at_management_group_scope.metadata = {'url': "/providers/Microsoft.Management/managementGroups/{groupId}/providers/{resourceProviderNamespace}/register"} # type: ignore - + register_at_management_group_scope.metadata = {"url": "/providers/Microsoft.Management/managementGroups/{groupId}/providers/{resourceProviderNamespace}/register"} # type: ignore @distributed_trace def provider_permissions( - self, - resource_provider_namespace: str, - **kwargs: Any - ) -> "_models.ProviderPermissionListResult": + self, resource_provider_namespace: str, **kwargs: Any + ) -> _models.ProviderPermissionListResult: """Get the provider permissions. - :param resource_provider_namespace: The namespace of the resource provider. + :param resource_provider_namespace: The namespace of the resource provider. Required. :type resource_provider_namespace: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: ProviderPermissionListResult, or the result of cls(response) + :return: ProviderPermissionListResult or the result of cls(response) :rtype: ~azure.mgmt.resource.resources.v2021_04_01.models.ProviderPermissionListResult - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.ProviderPermissionListResult"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + 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', "2021-04-01") # type: str + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-04-01")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[_models.ProviderPermissionListResult] - request = build_providers_provider_permissions_request( resource_provider_namespace=resource_provider_namespace, subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.provider_permissions.metadata['url'], + template_url=self.provider_permissions.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) - deserialized = self._deserialize('ProviderPermissionListResult', pipeline_response) + deserialized = self._deserialize("ProviderPermissionListResult", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - provider_permissions.metadata = {'url': "/subscriptions/{subscriptionId}/providers/{resourceProviderNamespace}/providerPermissions"} # type: ignore - + provider_permissions.metadata = {"url": "/subscriptions/{subscriptionId}/providers/{resourceProviderNamespace}/providerPermissions"} # type: ignore - @distributed_trace + @overload def register( self, resource_provider_namespace: str, - properties: Optional["_models.ProviderRegistrationRequest"] = None, + properties: Optional[_models.ProviderRegistrationRequest] = None, + *, + content_type: str = "application/json", **kwargs: Any - ) -> "_models.Provider": + ) -> _models.Provider: """Registers a subscription with a resource provider. :param resource_provider_namespace: The namespace of the resource provider to register. + Required. :type resource_provider_namespace: str :param properties: The third party consent for S2S. Default value is None. :type properties: ~azure.mgmt.resource.resources.v2021_04_01.models.ProviderRegistrationRequest + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: Provider, or the result of cls(response) + :return: Provider or the result of cls(response) :rtype: ~azure.mgmt.resource.resources.v2021_04_01.models.Provider - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.Provider"] - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {})) - api_version = kwargs.pop('api_version', "2021-04-01") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + @overload + def register( + self, + resource_provider_namespace: str, + properties: Optional[IO] = None, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.Provider: + """Registers a subscription with a resource provider. - if properties is not None: - _json = self._serialize.body(properties, 'ProviderRegistrationRequest') + :param resource_provider_namespace: The namespace of the resource provider to register. + Required. + :type resource_provider_namespace: str + :param properties: The third party consent for S2S. Default value is None. + :type properties: IO + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: Provider or the result of cls(response) + :rtype: ~azure.mgmt.resource.resources.v2021_04_01.models.Provider + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace + def register( + self, + resource_provider_namespace: str, + properties: Optional[Union[_models.ProviderRegistrationRequest, IO]] = None, + **kwargs: Any + ) -> _models.Provider: + """Registers a subscription with a resource provider. + + :param resource_provider_namespace: The namespace of the resource provider to register. + Required. + :type resource_provider_namespace: str + :param properties: The third party consent for S2S. Is either a model type or a IO type. + Default value is None. + :type properties: ~azure.mgmt.resource.resources.v2021_04_01.models.ProviderRegistrationRequest + or IO + :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. + Default value is None. + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: Provider or the result of cls(response) + :rtype: ~azure.mgmt.resource.resources.v2021_04_01.models.Provider + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-04-01")) # type: str + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.Provider] + + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(properties, (IO, bytes)): + _content = properties else: - _json = None + if properties is not None: + _json = self._serialize.body(properties, "ProviderRegistrationRequest") + else: + _json = None request = build_providers_register_request( resource_provider_namespace=resource_provider_namespace, @@ -7821,38 +8533,35 @@ def register( api_version=api_version, content_type=content_type, json=_json, - template_url=self.register.metadata['url'], + content=_content, + template_url=self.register.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) - deserialized = self._deserialize('Provider', pipeline_response) + deserialized = self._deserialize("Provider", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - register.metadata = {'url': "/subscriptions/{subscriptionId}/providers/{resourceProviderNamespace}/register"} # type: ignore - + register.metadata = {"url": "/subscriptions/{subscriptionId}/providers/{resourceProviderNamespace}/register"} # type: ignore @distributed_trace - def list( - self, - expand: Optional[str] = None, - **kwargs: Any - ) -> Iterable["_models.ProviderListResult"]: + def list(self, expand: Optional[str] = None, **kwargs: Any) -> Iterable["_models.Provider"]: """Gets all resource providers for a subscription. :param expand: The properties to include in the results. For example, use &$expand=metadata in @@ -7860,38 +8569,47 @@ def list( response, use $expand=resourceTypes/aliases. Default value is None. :type expand: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either ProviderListResult or the result of cls(response) + :return: An iterator like instance of either Provider or the result of cls(response) :rtype: - ~azure.core.paging.ItemPaged[~azure.mgmt.resource.resources.v2021_04_01.models.ProviderListResult] - :raises: ~azure.core.exceptions.HttpResponseError + ~azure.core.paging.ItemPaged[~azure.mgmt.resource.resources.v2021_04_01.models.Provider] + :raises ~azure.core.exceptions.HttpResponseError: """ - api_version = kwargs.pop('api_version', "2021-04-01") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-04-01")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[_models.ProviderListResult] - cls = kwargs.pop('cls', None) # type: ClsType["_models.ProviderListResult"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) + def prepare_request(next_link=None): if not next_link: - + request = build_providers_list_request( subscription_id=self._config.subscription_id, - api_version=api_version, expand=expand, - template_url=self.list.metadata['url'], + 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.url = self._client.format_url(request.url) # type: ignore else: - - request = build_providers_list_request( - subscription_id=self._config.subscription_id, - template_url=next_link, - ) + # make call to next link with the client's api-version + _parsed_next_link = urlparse(next_link) + _next_request_params = case_insensitive_dict(parse_qs(_parsed_next_link.query)) + _next_request_params["api-version"] = self._config.api_version + request = HttpRequest("GET", urljoin(next_link, _parsed_next_link.path), params=_next_request_params) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore request.method = "GET" return request @@ -7905,10 +8623,8 @@ def extract_data(pipeline_response): def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) response = pipeline_response.http_response @@ -7918,18 +8634,12 @@ def get_next(next_link=None): return pipeline_response + return ItemPaged(get_next, extract_data) - return ItemPaged( - get_next, extract_data - ) - list.metadata = {'url': "/subscriptions/{subscriptionId}/providers"} # type: ignore + list.metadata = {"url": "/subscriptions/{subscriptionId}/providers"} # type: ignore @distributed_trace - def list_at_tenant_scope( - self, - expand: Optional[str] = None, - **kwargs: Any - ) -> Iterable["_models.ProviderListResult"]: + def list_at_tenant_scope(self, expand: Optional[str] = None, **kwargs: Any) -> Iterable["_models.Provider"]: """Gets all resource providers for the tenant. :param expand: The properties to include in the results. For example, use &$expand=metadata in @@ -7937,36 +8647,46 @@ def list_at_tenant_scope( response, use $expand=resourceTypes/aliases. Default value is None. :type expand: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either ProviderListResult or the result of cls(response) + :return: An iterator like instance of either Provider or the result of cls(response) :rtype: - ~azure.core.paging.ItemPaged[~azure.mgmt.resource.resources.v2021_04_01.models.ProviderListResult] - :raises: ~azure.core.exceptions.HttpResponseError + ~azure.core.paging.ItemPaged[~azure.mgmt.resource.resources.v2021_04_01.models.Provider] + :raises ~azure.core.exceptions.HttpResponseError: """ - api_version = kwargs.pop('api_version', "2021-04-01") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-04-01")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[_models.ProviderListResult] - cls = kwargs.pop('cls', None) # type: ClsType["_models.ProviderListResult"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) + def prepare_request(next_link=None): if not next_link: - + request = build_providers_list_at_tenant_scope_request( - api_version=api_version, expand=expand, - template_url=self.list_at_tenant_scope.metadata['url'], + api_version=api_version, + template_url=self.list_at_tenant_scope.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore else: - - request = build_providers_list_at_tenant_scope_request( - template_url=next_link, - ) + # make call to next link with the client's api-version + _parsed_next_link = urlparse(next_link) + _next_request_params = case_insensitive_dict(parse_qs(_parsed_next_link.query)) + _next_request_params["api-version"] = self._config.api_version + request = HttpRequest("GET", urljoin(next_link, _parsed_next_link.path), params=_next_request_params) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore request.method = "GET" return request @@ -7980,10 +8700,8 @@ def extract_data(pipeline_response): def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) response = pipeline_response.http_response @@ -7993,229 +8711,229 @@ def get_next(next_link=None): return pipeline_response + return ItemPaged(get_next, extract_data) - return ItemPaged( - get_next, extract_data - ) - list_at_tenant_scope.metadata = {'url': "/providers"} # type: ignore + list_at_tenant_scope.metadata = {"url": "/providers"} # type: ignore @distributed_trace - def get( - self, - resource_provider_namespace: str, - expand: Optional[str] = None, - **kwargs: Any - ) -> "_models.Provider": + def get(self, resource_provider_namespace: str, expand: Optional[str] = None, **kwargs: Any) -> _models.Provider: """Gets the specified resource provider. - :param resource_provider_namespace: The namespace of the resource provider. + :param resource_provider_namespace: The namespace of the resource provider. Required. :type resource_provider_namespace: str :param expand: The $expand query parameter. For example, to include property aliases in response, use $expand=resourceTypes/aliases. Default value is None. :type expand: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: Provider, or the result of cls(response) + :return: Provider or the result of cls(response) :rtype: ~azure.mgmt.resource.resources.v2021_04_01.models.Provider - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.Provider"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) - api_version = kwargs.pop('api_version', "2021-04-01") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-04-01")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[_models.Provider] - request = build_providers_get_request( resource_provider_namespace=resource_provider_namespace, subscription_id=self._config.subscription_id, - api_version=api_version, expand=expand, - template_url=self.get.metadata['url'], + api_version=api_version, + template_url=self.get.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) - deserialized = self._deserialize('Provider', pipeline_response) + deserialized = self._deserialize("Provider", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - get.metadata = {'url': "/subscriptions/{subscriptionId}/providers/{resourceProviderNamespace}"} # type: ignore - + get.metadata = {"url": "/subscriptions/{subscriptionId}/providers/{resourceProviderNamespace}"} # type: ignore @distributed_trace def get_at_tenant_scope( - self, - resource_provider_namespace: str, - expand: Optional[str] = None, - **kwargs: Any - ) -> "_models.Provider": + self, resource_provider_namespace: str, expand: Optional[str] = None, **kwargs: Any + ) -> _models.Provider: """Gets the specified resource provider at the tenant level. - :param resource_provider_namespace: The namespace of the resource provider. + :param resource_provider_namespace: The namespace of the resource provider. Required. :type resource_provider_namespace: str :param expand: The $expand query parameter. For example, to include property aliases in response, use $expand=resourceTypes/aliases. Default value is None. :type expand: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: Provider, or the result of cls(response) + :return: Provider or the result of cls(response) :rtype: ~azure.mgmt.resource.resources.v2021_04_01.models.Provider - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.Provider"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + 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', "2021-04-01") # type: str + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-04-01")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[_models.Provider] - request = build_providers_get_at_tenant_scope_request( resource_provider_namespace=resource_provider_namespace, - api_version=api_version, expand=expand, - template_url=self.get_at_tenant_scope.metadata['url'], + api_version=api_version, + template_url=self.get_at_tenant_scope.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) - deserialized = self._deserialize('Provider', pipeline_response) + deserialized = self._deserialize("Provider", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - get_at_tenant_scope.metadata = {'url': "/providers/{resourceProviderNamespace}"} # type: ignore + get_at_tenant_scope.metadata = {"url": "/providers/{resourceProviderNamespace}"} # type: ignore -class ProviderResourceTypesOperations(object): - """ProviderResourceTypesOperations operations. - You should not instantiate this class directly. Instead, you should create a Client instance that - instantiates it for you and attaches it as an attribute. +class ProviderResourceTypesOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. - :ivar models: Alias to model classes used in this operation group. - :type models: ~azure.mgmt.resource.resources.v2021_04_01.models - :param client: Client for service requests. - :param config: Configuration of service client. - :param serializer: An object model serializer. - :param deserializer: An object model deserializer. + Instead, you should access the following operations through + :class:`~azure.mgmt.resource.resources.v2021_04_01.ResourceManagementClient`'s + :attr:`provider_resource_types` attribute. """ models = _models - def __init__(self, client, config, serializer, deserializer): - self._client = client - self._serialize = serializer - self._deserialize = deserializer - self._config = config + def __init__(self, *args, **kwargs): + input_args = list(args) + self._client = input_args.pop(0) if input_args else kwargs.pop("client") + self._config = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") @distributed_trace def list( - self, - resource_provider_namespace: str, - expand: Optional[str] = None, - **kwargs: Any - ) -> "_models.ProviderResourceTypeListResult": + self, resource_provider_namespace: str, expand: Optional[str] = None, **kwargs: Any + ) -> _models.ProviderResourceTypeListResult: """List the resource types for a specified resource provider. - :param resource_provider_namespace: The namespace of the resource provider. + :param resource_provider_namespace: The namespace of the resource provider. Required. :type resource_provider_namespace: str :param expand: The $expand query parameter. For example, to include property aliases in response, use $expand=resourceTypes/aliases. Default value is None. :type expand: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: ProviderResourceTypeListResult, or the result of cls(response) + :return: ProviderResourceTypeListResult or the result of cls(response) :rtype: ~azure.mgmt.resource.resources.v2021_04_01.models.ProviderResourceTypeListResult - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.ProviderResourceTypeListResult"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) - api_version = kwargs.pop('api_version', "2021-04-01") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-04-01")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[_models.ProviderResourceTypeListResult] - request = build_provider_resource_types_list_request( resource_provider_namespace=resource_provider_namespace, subscription_id=self._config.subscription_id, - api_version=api_version, expand=expand, - template_url=self.list.metadata['url'], + 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.url = self._client.format_url(request.url) # type: ignore - pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) - deserialized = self._deserialize('ProviderResourceTypeListResult', pipeline_response) + deserialized = self._deserialize("ProviderResourceTypeListResult", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - list.metadata = {'url': "/subscriptions/{subscriptionId}/providers/{resourceProviderNamespace}/resourceTypes"} # type: ignore + list.metadata = {"url": "/subscriptions/{subscriptionId}/providers/{resourceProviderNamespace}/resourceTypes"} # type: ignore -class ResourcesOperations(object): # pylint: disable=too-many-public-methods - """ResourcesOperations operations. - You should not instantiate this class directly. Instead, you should create a Client instance that - instantiates it for you and attaches it as an attribute. +class ResourcesOperations: # pylint: disable=too-many-public-methods + """ + .. warning:: + **DO NOT** instantiate this class directly. - :ivar models: Alias to model classes used in this operation group. - :type models: ~azure.mgmt.resource.resources.v2021_04_01.models - :param client: Client for service requests. - :param config: Configuration of service client. - :param serializer: An object model serializer. - :param deserializer: An object model deserializer. + Instead, you should access the following operations through + :class:`~azure.mgmt.resource.resources.v2021_04_01.ResourceManagementClient`'s + :attr:`resources` attribute. """ models = _models - def __init__(self, client, config, serializer, deserializer): - self._client = client - self._serialize = serializer - self._deserialize = deserializer - self._config = config + def __init__(self, *args, **kwargs): + input_args = list(args) + self._client = input_args.pop(0) if input_args else kwargs.pop("client") + self._config = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") @distributed_trace def list_by_resource_group( @@ -8225,10 +8943,10 @@ def list_by_resource_group( expand: Optional[str] = None, top: Optional[int] = None, **kwargs: Any - ) -> Iterable["_models.ResourceListResult"]: + ) -> Iterable["_models.GenericResourceExpanded"]: """Get all the resources for a resource group. - :param resource_group_name: The resource group with the resources to get. + :param resource_group_name: The resource group with the resources to get. Required. :type resource_group_name: str :param filter: The filter to apply on the operation.:code:`
`:code:`
`The properties you can use for eq (equals) or ne (not equals) are: location, resourceType, name, resourceGroup, @@ -8254,42 +8972,51 @@ def list_by_resource_group( value is None. :type top: int :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either ResourceListResult or the result of cls(response) + :return: An iterator like instance of either GenericResourceExpanded or the result of + cls(response) :rtype: - ~azure.core.paging.ItemPaged[~azure.mgmt.resource.resources.v2021_04_01.models.ResourceListResult] - :raises: ~azure.core.exceptions.HttpResponseError + ~azure.core.paging.ItemPaged[~azure.mgmt.resource.resources.v2021_04_01.models.GenericResourceExpanded] + :raises ~azure.core.exceptions.HttpResponseError: """ - api_version = kwargs.pop('api_version', "2021-04-01") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-04-01")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[_models.ResourceListResult] - cls = kwargs.pop('cls', None) # type: ClsType["_models.ResourceListResult"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) + def prepare_request(next_link=None): if not next_link: - + request = build_resources_list_by_resource_group_request( resource_group_name=resource_group_name, subscription_id=self._config.subscription_id, - api_version=api_version, filter=filter, expand=expand, top=top, - template_url=self.list_by_resource_group.metadata['url'], + 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.url = self._client.format_url(request.url) # type: ignore else: - - request = build_resources_list_by_resource_group_request( - resource_group_name=resource_group_name, - subscription_id=self._config.subscription_id, - template_url=next_link, - ) + # make call to next link with the client's api-version + _parsed_next_link = urlparse(next_link) + _next_request_params = case_insensitive_dict(parse_qs(_parsed_next_link.query)) + _next_request_params["api-version"] = self._config.api_version + request = HttpRequest("GET", urljoin(next_link, _parsed_next_link.path), params=_next_request_params) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore request.method = "GET" return request @@ -8303,10 +9030,8 @@ def extract_data(pipeline_response): def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) response = pipeline_response.http_response @@ -8316,45 +9041,54 @@ def get_next(next_link=None): return pipeline_response + return ItemPaged(get_next, extract_data) - return ItemPaged( - get_next, extract_data - ) - list_by_resource_group.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/resources"} # type: ignore + list_by_resource_group.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/resources"} # type: ignore def _move_resources_initial( # pylint: disable=inconsistent-return-statements - self, - source_resource_group_name: str, - parameters: "_models.ResourcesMoveInfo", - **kwargs: Any + self, source_resource_group_name: str, parameters: Union[_models.ResourcesMoveInfo, IO], **kwargs: Any ) -> None: - cls = kwargs.pop('cls', None) # type: ClsType[None] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) - api_version = kwargs.pop('api_version', "2021-04-01") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - _json = self._serialize.body(parameters, 'ResourcesMoveInfo') + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-04-01")) # type: str + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[None] - request = build_resources_move_resources_request_initial( + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(parameters, (IO, bytes)): + _content = parameters + else: + _json = self._serialize.body(parameters, "ResourcesMoveInfo") + + request = build_resources_move_resources_request( source_resource_group_name=source_resource_group_name, subscription_id=self._config.subscription_id, api_version=api_version, content_type=content_type, json=_json, - template_url=self._move_resources_initial.metadata['url'], + content=_content, + template_url=self._move_resources_initial.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [202, 204]: @@ -8364,14 +9098,15 @@ def _move_resources_initial( # pylint: disable=inconsistent-return-statements if cls: return cls(pipeline_response, None, {}) - _move_resources_initial.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{sourceResourceGroupName}/moveResources"} # type: ignore - + _move_resources_initial.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{sourceResourceGroupName}/moveResources"} # type: ignore - @distributed_trace - def begin_move_resources( # pylint: disable=inconsistent-return-statements + @overload + def begin_move_resources( self, source_resource_group_name: str, - parameters: "_models.ResourcesMoveInfo", + parameters: _models.ResourcesMoveInfo, + *, + content_type: str = "application/json", **kwargs: Any ) -> LROPoller[None]: """Moves resources from one resource group to another resource group. @@ -8382,10 +9117,13 @@ def begin_move_resources( # pylint: disable=inconsistent-return-statements operation. Write and delete operations are blocked on the groups until the move completes. :param source_resource_group_name: The name of the resource group from the source subscription - containing the resources to be moved. + containing the resources to be moved. Required. :type source_resource_group_name: str - :param parameters: Parameters for moving resources. + :param parameters: Parameters for moving resources. Required. :type parameters: ~azure.mgmt.resource.resources.v2021_04_01.models.ResourcesMoveInfo + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str :keyword callable cls: A custom type or function that will be passed the direct response :keyword str continuation_token: A continuation token to restart a poller from a saved state. :keyword polling: By default, your polling method will be ARMPolling. Pass in False for this @@ -8396,80 +9134,160 @@ def begin_move_resources( # pylint: disable=inconsistent-return-statements Retry-After header is present. :return: An instance of LROPoller that returns either None or the result of cls(response) :rtype: ~azure.core.polling.LROPoller[None] - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - api_version = kwargs.pop('api_version', "2021-04-01") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] - polling = kwargs.pop('polling', True) # type: Union[bool, PollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType[None] - lro_delay = kwargs.pop( - 'polling_interval', - self._config.polling_interval - ) - cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] + + @overload + def begin_move_resources( + self, source_resource_group_name: str, parameters: IO, *, content_type: str = "application/json", **kwargs: Any + ) -> LROPoller[None]: + """Moves resources from one resource group to another resource group. + + The resources to be moved must be in the same source resource group in the source subscription + being used. The target resource group may be in a different subscription. When moving + resources, both the source group and the target group are locked for the duration of the + operation. Write and delete operations are blocked on the groups until the move completes. + + :param source_resource_group_name: The name of the resource group from the source subscription + containing the resources to be moved. Required. + :type source_resource_group_name: str + :param parameters: Parameters for moving resources. Required. + :type parameters: IO + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be ARMPolling. Pass in False for this + operation to not poll, or pass in your own initialized polling object for a personal polling + strategy. + :paramtype polling: bool or ~azure.core.polling.PollingMethod + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of LROPoller that returns either None or the result of cls(response) + :rtype: ~azure.core.polling.LROPoller[None] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace + def begin_move_resources( + self, source_resource_group_name: str, parameters: Union[_models.ResourcesMoveInfo, IO], **kwargs: Any + ) -> LROPoller[None]: + """Moves resources from one resource group to another resource group. + + The resources to be moved must be in the same source resource group in the source subscription + being used. The target resource group may be in a different subscription. When moving + resources, both the source group and the target group are locked for the duration of the + operation. Write and delete operations are blocked on the groups until the move completes. + + :param source_resource_group_name: The name of the resource group from the source subscription + containing the resources to be moved. Required. + :type source_resource_group_name: str + :param parameters: Parameters for moving resources. Is either a model type or a IO type. + Required. + :type parameters: ~azure.mgmt.resource.resources.v2021_04_01.models.ResourcesMoveInfo or IO + :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. + Default value is None. + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be ARMPolling. Pass in False for this + operation to not poll, or pass in your own initialized polling object for a personal polling + strategy. + :paramtype polling: bool or ~azure.core.polling.PollingMethod + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of LROPoller that returns either None or the result of cls(response) + :rtype: ~azure.core.polling.LROPoller[None] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _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-04-01")) # type: str + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[None] + polling = kwargs.pop("polling", True) # type: Union[bool, PollingMethod] + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token = kwargs.pop("continuation_token", None) # type: Optional[str] if cont_token is None: - raw_result = self._move_resources_initial( + raw_result = self._move_resources_initial( # type: ignore source_resource_group_name=source_resource_group_name, parameters=parameters, api_version=api_version, content_type=content_type, - cls=lambda x,y,z: x, + cls=lambda x, y, z: x, + headers=_headers, + params=_params, **kwargs ) - kwargs.pop('error_map', None) + kwargs.pop("error_map", None) - def get_long_running_output(pipeline_response): + def get_long_running_output(pipeline_response): # pylint: disable=inconsistent-return-statements if cls: return cls(pipeline_response, None, {}) - - if polling is True: polling_method = ARMPolling(lro_delay, **kwargs) - elif polling is False: polling_method = NoPolling() - else: polling_method = polling + if polling is True: + polling_method = cast(PollingMethod, ARMPolling(lro_delay, **kwargs)) # type: PollingMethod + elif polling is False: + polling_method = cast(PollingMethod, NoPolling()) + else: + polling_method = polling if cont_token: return LROPoller.from_continuation_token( polling_method=polling_method, continuation_token=cont_token, client=self._client, - deserialization_callback=get_long_running_output + deserialization_callback=get_long_running_output, ) return LROPoller(self._client, raw_result, get_long_running_output, polling_method) - begin_move_resources.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{sourceResourceGroupName}/moveResources"} # type: ignore + begin_move_resources.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{sourceResourceGroupName}/moveResources"} # type: ignore def _validate_move_resources_initial( # pylint: disable=inconsistent-return-statements - self, - source_resource_group_name: str, - parameters: "_models.ResourcesMoveInfo", - **kwargs: Any + self, source_resource_group_name: str, parameters: Union[_models.ResourcesMoveInfo, IO], **kwargs: Any ) -> None: - cls = kwargs.pop('cls', None) # type: ClsType[None] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) - api_version = kwargs.pop('api_version', "2021-04-01") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - _json = self._serialize.body(parameters, 'ResourcesMoveInfo') + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-04-01")) # type: str + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[None] + + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(parameters, (IO, bytes)): + _content = parameters + else: + _json = self._serialize.body(parameters, "ResourcesMoveInfo") - request = build_resources_validate_move_resources_request_initial( + request = build_resources_validate_move_resources_request( source_resource_group_name=source_resource_group_name, subscription_id=self._config.subscription_id, api_version=api_version, content_type=content_type, json=_json, - template_url=self._validate_move_resources_initial.metadata['url'], + content=_content, + template_url=self._validate_move_resources_initial.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [202, 204]: @@ -8479,14 +9297,15 @@ def _validate_move_resources_initial( # pylint: disable=inconsistent-return-sta if cls: return cls(pipeline_response, None, {}) - _validate_move_resources_initial.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{sourceResourceGroupName}/validateMoveResources"} # type: ignore - + _validate_move_resources_initial.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{sourceResourceGroupName}/validateMoveResources"} # type: ignore - @distributed_trace - def begin_validate_move_resources( # pylint: disable=inconsistent-return-statements + @overload + def begin_validate_move_resources( self, source_resource_group_name: str, - parameters: "_models.ResourcesMoveInfo", + parameters: _models.ResourcesMoveInfo, + *, + content_type: str = "application/json", **kwargs: Any ) -> LROPoller[None]: """Validates whether resources can be moved from one resource group to another resource group. @@ -8499,10 +9318,13 @@ def begin_validate_move_resources( # pylint: disable=inconsistent-return-statem the result of the long-running operation. :param source_resource_group_name: The name of the resource group from the source subscription - containing the resources to be validated for move. + containing the resources to be validated for move. Required. :type source_resource_group_name: str - :param parameters: Parameters for moving resources. + :param parameters: Parameters for moving resources. Required. :type parameters: ~azure.mgmt.resource.resources.v2021_04_01.models.ResourcesMoveInfo + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str :keyword callable cls: A custom type or function that will be passed the direct response :keyword str continuation_token: A continuation token to restart a poller from a saved state. :keyword polling: By default, your polling method will be ARMPolling. Pass in False for this @@ -8513,55 +9335,124 @@ def begin_validate_move_resources( # pylint: disable=inconsistent-return-statem Retry-After header is present. :return: An instance of LROPoller that returns either None or the result of cls(response) :rtype: ~azure.core.polling.LROPoller[None] - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - api_version = kwargs.pop('api_version', "2021-04-01") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] - polling = kwargs.pop('polling', True) # type: Union[bool, PollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType[None] - lro_delay = kwargs.pop( - 'polling_interval', - self._config.polling_interval - ) - cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] + + @overload + def begin_validate_move_resources( + self, source_resource_group_name: str, parameters: IO, *, content_type: str = "application/json", **kwargs: Any + ) -> LROPoller[None]: + """Validates whether resources can be moved from one resource group to another resource group. + + This operation checks whether the specified resources can be moved to the target. The resources + to be moved must be in the same source resource group in the source subscription being used. + The target resource group may be in a different subscription. If validation succeeds, it + returns HTTP response code 204 (no content). If validation fails, it returns HTTP response code + 409 (Conflict) with an error message. Retrieve the URL in the Location header value to check + the result of the long-running operation. + + :param source_resource_group_name: The name of the resource group from the source subscription + containing the resources to be validated for move. Required. + :type source_resource_group_name: str + :param parameters: Parameters for moving resources. Required. + :type parameters: IO + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be ARMPolling. Pass in False for this + operation to not poll, or pass in your own initialized polling object for a personal polling + strategy. + :paramtype polling: bool or ~azure.core.polling.PollingMethod + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of LROPoller that returns either None or the result of cls(response) + :rtype: ~azure.core.polling.LROPoller[None] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace + def begin_validate_move_resources( + self, source_resource_group_name: str, parameters: Union[_models.ResourcesMoveInfo, IO], **kwargs: Any + ) -> LROPoller[None]: + """Validates whether resources can be moved from one resource group to another resource group. + + This operation checks whether the specified resources can be moved to the target. The resources + to be moved must be in the same source resource group in the source subscription being used. + The target resource group may be in a different subscription. If validation succeeds, it + returns HTTP response code 204 (no content). If validation fails, it returns HTTP response code + 409 (Conflict) with an error message. Retrieve the URL in the Location header value to check + the result of the long-running operation. + + :param source_resource_group_name: The name of the resource group from the source subscription + containing the resources to be validated for move. Required. + :type source_resource_group_name: str + :param parameters: Parameters for moving resources. Is either a model type or a IO type. + Required. + :type parameters: ~azure.mgmt.resource.resources.v2021_04_01.models.ResourcesMoveInfo or IO + :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. + Default value is None. + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be ARMPolling. Pass in False for this + operation to not poll, or pass in your own initialized polling object for a personal polling + strategy. + :paramtype polling: bool or ~azure.core.polling.PollingMethod + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of LROPoller that returns either None or the result of cls(response) + :rtype: ~azure.core.polling.LROPoller[None] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _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-04-01")) # type: str + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[None] + polling = kwargs.pop("polling", True) # type: Union[bool, PollingMethod] + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token = kwargs.pop("continuation_token", None) # type: Optional[str] if cont_token is None: - raw_result = self._validate_move_resources_initial( + raw_result = self._validate_move_resources_initial( # type: ignore source_resource_group_name=source_resource_group_name, parameters=parameters, api_version=api_version, content_type=content_type, - cls=lambda x,y,z: x, + cls=lambda x, y, z: x, + headers=_headers, + params=_params, **kwargs ) - kwargs.pop('error_map', None) + kwargs.pop("error_map", None) - def get_long_running_output(pipeline_response): + def get_long_running_output(pipeline_response): # pylint: disable=inconsistent-return-statements if cls: return cls(pipeline_response, None, {}) - - if polling is True: polling_method = ARMPolling(lro_delay, **kwargs) - elif polling is False: polling_method = NoPolling() - else: polling_method = polling + if polling is True: + polling_method = cast(PollingMethod, ARMPolling(lro_delay, **kwargs)) # type: PollingMethod + elif polling is False: + polling_method = cast(PollingMethod, NoPolling()) + else: + polling_method = polling if cont_token: return LROPoller.from_continuation_token( polling_method=polling_method, continuation_token=cont_token, client=self._client, - deserialization_callback=get_long_running_output + deserialization_callback=get_long_running_output, ) return LROPoller(self._client, raw_result, get_long_running_output, polling_method) - begin_validate_move_resources.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{sourceResourceGroupName}/validateMoveResources"} # type: ignore + begin_validate_move_resources.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{sourceResourceGroupName}/validateMoveResources"} # type: ignore @distributed_trace def list( - self, - filter: Optional[str] = None, - expand: Optional[str] = None, - top: Optional[int] = None, - **kwargs: Any - ) -> Iterable["_models.ResourceListResult"]: + self, filter: Optional[str] = None, expand: Optional[str] = None, top: Optional[int] = None, **kwargs: Any + ) -> Iterable["_models.GenericResourceExpanded"]: """Get all the resources in a subscription. :param filter: The filter to apply on the operation.:code:`
`:code:`
`Filter comparison @@ -8594,44 +9485,54 @@ def list( Valid values include ``createdTime``\ , ``changedTime`` and ``provisioningState``. For example, ``$expand=createdTime,changedTime``. Default value is None. :type expand: str - :param top: The number of results to return. If null is passed, returns all resources. Default - value is None. + :param top: The number of recommendations per page if a paged version of this API is being + used. Default value is None. :type top: int :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either ResourceListResult or the result of cls(response) + :return: An iterator like instance of either GenericResourceExpanded or the result of + cls(response) :rtype: - ~azure.core.paging.ItemPaged[~azure.mgmt.resource.resources.v2021_04_01.models.ResourceListResult] - :raises: ~azure.core.exceptions.HttpResponseError + ~azure.core.paging.ItemPaged[~azure.mgmt.resource.resources.v2021_04_01.models.GenericResourceExpanded] + :raises ~azure.core.exceptions.HttpResponseError: """ - api_version = kwargs.pop('api_version', "2021-04-01") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-04-01")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[_models.ResourceListResult] - cls = kwargs.pop('cls', None) # type: ClsType["_models.ResourceListResult"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) + def prepare_request(next_link=None): if not next_link: - + request = build_resources_list_request( subscription_id=self._config.subscription_id, - api_version=api_version, filter=filter, expand=expand, top=top, - template_url=self.list.metadata['url'], + 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.url = self._client.format_url(request.url) # type: ignore else: - - request = build_resources_list_request( - subscription_id=self._config.subscription_id, - template_url=next_link, - ) + # make call to next link with the client's api-version + _parsed_next_link = urlparse(next_link) + _next_request_params = case_insensitive_dict(parse_qs(_parsed_next_link.query)) + _next_request_params["api-version"] = self._config.api_version + request = HttpRequest("GET", urljoin(next_link, _parsed_next_link.path), params=_next_request_params) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore request.method = "GET" return request @@ -8645,10 +9546,8 @@ def extract_data(pipeline_response): def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) response = pipeline_response.http_response @@ -8658,11 +9557,9 @@ def get_next(next_link=None): return pipeline_response + return ItemPaged(get_next, extract_data) - return ItemPaged( - get_next, extract_data - ) - list.metadata = {'url': "/subscriptions/{subscriptionId}/resources"} # type: ignore + list.metadata = {"url": "/subscriptions/{subscriptionId}/resources"} # type: ignore @distributed_trace def check_existence( @@ -8678,30 +9575,36 @@ def check_existence( """Checks whether a resource exists. :param resource_group_name: The name of the resource group containing the resource to check. - The name is case insensitive. + The name is case insensitive. Required. :type resource_group_name: str - :param resource_provider_namespace: The resource provider of the resource to check. + :param resource_provider_namespace: The resource provider of the resource to check. Required. :type resource_provider_namespace: str - :param parent_resource_path: The parent resource identity. + :param parent_resource_path: The parent resource identity. Required. :type parent_resource_path: str - :param resource_type: The resource type. + :param resource_type: The resource type. Required. :type resource_type: str - :param resource_name: The name of the resource to check whether it exists. + :param resource_name: The name of the resource to check whether it exists. Required. :type resource_name: str - :param api_version: The API version to use for the operation. + :param api_version: The API version to use for the operation. Required. :type api_version: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: bool, or the result of cls(response) + :return: bool or the result of cls(response) :rtype: bool - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType[None] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = kwargs.pop("params", {}) or {} + + cls = kwargs.pop("cls", None) # type: ClsType[None] - request = build_resources_check_existence_request( resource_group_name=resource_group_name, resource_provider_namespace=resource_provider_namespace, @@ -8710,16 +9613,17 @@ def check_existence( resource_name=resource_name, subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.check_existence.metadata['url'], + template_url=self.check_existence.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [204, 404]: @@ -8730,8 +9634,7 @@ def check_existence( return cls(pipeline_response, None, {}) return 200 <= response.status_code <= 299 - check_existence.metadata = {'url': "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{parentResourcePath}/{resourceType}/{resourceName}"} # type: ignore - + check_existence.metadata = {"url": "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{parentResourcePath}/{resourceType}/{resourceName}"} # type: ignore def _delete_initial( # pylint: disable=inconsistent-return-statements self, @@ -8743,14 +9646,20 @@ def _delete_initial( # pylint: disable=inconsistent-return-statements api_version: str, **kwargs: Any ) -> None: - cls = kwargs.pop('cls', None) # type: ClsType[None] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = kwargs.pop("params", {}) or {} - - request = build_resources_delete_request_initial( + cls = kwargs.pop("cls", None) # type: ClsType[None] + + request = build_resources_delete_request( resource_group_name=resource_group_name, resource_provider_namespace=resource_provider_namespace, parent_resource_path=parent_resource_path, @@ -8758,16 +9667,17 @@ def _delete_initial( # pylint: disable=inconsistent-return-statements resource_name=resource_name, subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self._delete_initial.metadata['url'], + template_url=self._delete_initial.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200, 202, 204]: @@ -8777,11 +9687,10 @@ def _delete_initial( # pylint: disable=inconsistent-return-statements if cls: return cls(pipeline_response, None, {}) - _delete_initial.metadata = {'url': "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{parentResourcePath}/{resourceType}/{resourceName}"} # type: ignore - + _delete_initial.metadata = {"url": "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{parentResourcePath}/{resourceType}/{resourceName}"} # type: ignore @distributed_trace - def begin_delete( # pylint: disable=inconsistent-return-statements + def begin_delete( self, resource_group_name: str, resource_provider_namespace: str, @@ -8794,17 +9703,17 @@ def begin_delete( # pylint: disable=inconsistent-return-statements """Deletes a resource. :param resource_group_name: The name of the resource group that contains the resource to - delete. The name is case insensitive. + delete. The name is case insensitive. Required. :type resource_group_name: str - :param resource_provider_namespace: The namespace of the resource provider. + :param resource_provider_namespace: The namespace of the resource provider. Required. :type resource_provider_namespace: str - :param parent_resource_path: The parent resource identity. + :param parent_resource_path: The parent resource identity. Required. :type parent_resource_path: str - :param resource_type: The resource type. + :param resource_type: The resource type. Required. :type resource_type: str - :param resource_name: The name of the resource to delete. + :param resource_name: The name of the resource to delete. Required. :type resource_name: str - :param api_version: The API version to use for the operation. + :param api_version: The API version to use for the operation. Required. :type api_version: str :keyword callable cls: A custom type or function that will be passed the direct response :keyword str continuation_token: A continuation token to restart a poller from a saved state. @@ -8816,46 +9725,50 @@ def begin_delete( # pylint: disable=inconsistent-return-statements Retry-After header is present. :return: An instance of LROPoller that returns either None or the result of cls(response) :rtype: ~azure.core.polling.LROPoller[None] - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - polling = kwargs.pop('polling', True) # type: Union[bool, PollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType[None] - lro_delay = kwargs.pop( - 'polling_interval', - self._config.polling_interval - ) - cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] + _headers = kwargs.pop("headers", {}) or {} + _params = kwargs.pop("params", {}) or {} + + cls = kwargs.pop("cls", None) # type: ClsType[None] + polling = kwargs.pop("polling", True) # type: Union[bool, PollingMethod] + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token = kwargs.pop("continuation_token", None) # type: Optional[str] if cont_token is None: - raw_result = self._delete_initial( + raw_result = self._delete_initial( # type: ignore resource_group_name=resource_group_name, resource_provider_namespace=resource_provider_namespace, parent_resource_path=parent_resource_path, resource_type=resource_type, resource_name=resource_name, api_version=api_version, - cls=lambda x,y,z: x, + cls=lambda x, y, z: x, + headers=_headers, + params=_params, **kwargs ) - kwargs.pop('error_map', None) + kwargs.pop("error_map", None) - def get_long_running_output(pipeline_response): + def get_long_running_output(pipeline_response): # pylint: disable=inconsistent-return-statements if cls: return cls(pipeline_response, None, {}) - - if polling is True: polling_method = ARMPolling(lro_delay, **kwargs) - elif polling is False: polling_method = NoPolling() - else: polling_method = polling + if polling is True: + polling_method = cast(PollingMethod, ARMPolling(lro_delay, **kwargs)) # type: PollingMethod + elif polling is False: + polling_method = cast(PollingMethod, NoPolling()) + else: + polling_method = polling if cont_token: return LROPoller.from_continuation_token( polling_method=polling_method, continuation_token=cont_token, client=self._client, - deserialization_callback=get_long_running_output + deserialization_callback=get_long_running_output, ) return LROPoller(self._client, raw_result, get_long_running_output, polling_method) - begin_delete.metadata = {'url': "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{parentResourcePath}/{resourceType}/{resourceName}"} # type: ignore + begin_delete.metadata = {"url": "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{parentResourcePath}/{resourceType}/{resourceName}"} # type: ignore def _create_or_update_initial( self, @@ -8865,39 +9778,53 @@ def _create_or_update_initial( resource_type: str, resource_name: str, api_version: str, - parameters: "_models.GenericResource", + parameters: Union[_models.GenericResource, IO], **kwargs: Any - ) -> Optional["_models.GenericResource"]: - cls = kwargs.pop('cls', None) # type: ClsType[Optional["_models.GenericResource"]] + ) -> Optional[_models.GenericResource]: error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = kwargs.pop("params", {}) or {} - _json = self._serialize.body(parameters, 'GenericResource') + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[Optional[_models.GenericResource]] - request = build_resources_create_or_update_request_initial( + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(parameters, (IO, bytes)): + _content = parameters + else: + _json = self._serialize.body(parameters, "GenericResource") + + request = build_resources_create_or_update_request( resource_group_name=resource_group_name, resource_provider_namespace=resource_provider_namespace, parent_resource_path=parent_resource_path, resource_type=resource_type, resource_name=resource_name, subscription_id=self._config.subscription_id, - content_type=content_type, api_version=api_version, + content_type=content_type, json=_json, - template_url=self._create_or_update_initial.metadata['url'], + content=_content, + template_url=self._create_or_update_initial.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200, 201, 202]: @@ -8906,20 +9833,19 @@ def _create_or_update_initial( deserialized = None if response.status_code == 200: - deserialized = self._deserialize('GenericResource', pipeline_response) + deserialized = self._deserialize("GenericResource", pipeline_response) if response.status_code == 201: - deserialized = self._deserialize('GenericResource', pipeline_response) + deserialized = self._deserialize("GenericResource", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - _create_or_update_initial.metadata = {'url': "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{parentResourcePath}/{resourceType}/{resourceName}"} # type: ignore - + _create_or_update_initial.metadata = {"url": "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{parentResourcePath}/{resourceType}/{resourceName}"} # type: ignore - @distributed_trace + @overload def begin_create_or_update( self, resource_group_name: str, @@ -8928,26 +9854,31 @@ def begin_create_or_update( resource_type: str, resource_name: str, api_version: str, - parameters: "_models.GenericResource", + parameters: _models.GenericResource, + *, + content_type: str = "application/json", **kwargs: Any - ) -> LROPoller["_models.GenericResource"]: + ) -> LROPoller[_models.GenericResource]: """Creates a resource. :param resource_group_name: The name of the resource group for the resource. The name is case - insensitive. + insensitive. Required. :type resource_group_name: str - :param resource_provider_namespace: The namespace of the resource provider. + :param resource_provider_namespace: The namespace of the resource provider. Required. :type resource_provider_namespace: str - :param parent_resource_path: The parent resource identity. + :param parent_resource_path: The parent resource identity. Required. :type parent_resource_path: str - :param resource_type: The resource type of the resource to create. + :param resource_type: The resource type of the resource to create. Required. :type resource_type: str - :param resource_name: The name of the resource to create. + :param resource_name: The name of the resource to create. Required. :type resource_name: str - :param api_version: The API version to use for the operation. + :param api_version: The API version to use for the operation. Required. :type api_version: str - :param parameters: Parameters for creating or updating the resource. + :param parameters: Parameters for creating or updating the resource. Required. :type parameters: ~azure.mgmt.resource.resources.v2021_04_01.models.GenericResource + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str :keyword callable cls: A custom type or function that will be passed the direct response :keyword str continuation_token: A continuation token to restart a poller from a saved state. :keyword polling: By default, your polling method will be ARMPolling. Pass in False for this @@ -8960,18 +9891,115 @@ def begin_create_or_update( cls(response) :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.resource.resources.v2021_04_01.models.GenericResource] - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] - polling = kwargs.pop('polling', True) # type: Union[bool, PollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType["_models.GenericResource"] - lro_delay = kwargs.pop( - 'polling_interval', - self._config.polling_interval - ) - cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] + + @overload + def begin_create_or_update( + self, + resource_group_name: str, + resource_provider_namespace: str, + parent_resource_path: str, + resource_type: str, + resource_name: str, + api_version: str, + parameters: IO, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> LROPoller[_models.GenericResource]: + """Creates a resource. + + :param resource_group_name: The name of the resource group for the resource. The name is case + insensitive. Required. + :type resource_group_name: str + :param resource_provider_namespace: The namespace of the resource provider. Required. + :type resource_provider_namespace: str + :param parent_resource_path: The parent resource identity. Required. + :type parent_resource_path: str + :param resource_type: The resource type of the resource to create. Required. + :type resource_type: str + :param resource_name: The name of the resource to create. Required. + :type resource_name: str + :param api_version: The API version to use for the operation. Required. + :type api_version: str + :param parameters: Parameters for creating or updating the resource. Required. + :type parameters: IO + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be ARMPolling. Pass in False for this + operation to not poll, or pass in your own initialized polling object for a personal polling + strategy. + :paramtype polling: bool or ~azure.core.polling.PollingMethod + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of LROPoller that returns either GenericResource or the result of + cls(response) + :rtype: + ~azure.core.polling.LROPoller[~azure.mgmt.resource.resources.v2021_04_01.models.GenericResource] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace + def begin_create_or_update( + self, + resource_group_name: str, + resource_provider_namespace: str, + parent_resource_path: str, + resource_type: str, + resource_name: str, + api_version: str, + parameters: Union[_models.GenericResource, IO], + **kwargs: Any + ) -> LROPoller[_models.GenericResource]: + """Creates a resource. + + :param resource_group_name: The name of the resource group for the resource. The name is case + insensitive. Required. + :type resource_group_name: str + :param resource_provider_namespace: The namespace of the resource provider. Required. + :type resource_provider_namespace: str + :param parent_resource_path: The parent resource identity. Required. + :type parent_resource_path: str + :param resource_type: The resource type of the resource to create. Required. + :type resource_type: str + :param resource_name: The name of the resource to create. Required. + :type resource_name: str + :param api_version: The API version to use for the operation. Required. + :type api_version: str + :param parameters: Parameters for creating or updating the resource. Is either a model type or + a IO type. Required. + :type parameters: ~azure.mgmt.resource.resources.v2021_04_01.models.GenericResource or IO + :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. + Default value is None. + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be ARMPolling. Pass in False for this + operation to not poll, or pass in your own initialized polling object for a personal polling + strategy. + :paramtype polling: bool or ~azure.core.polling.PollingMethod + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of LROPoller that returns either GenericResource or the result of + cls(response) + :rtype: + ~azure.core.polling.LROPoller[~azure.mgmt.resource.resources.v2021_04_01.models.GenericResource] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = kwargs.pop("params", {}) or {} + + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.GenericResource] + polling = kwargs.pop("polling", True) # type: Union[bool, PollingMethod] + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token = kwargs.pop("continuation_token", None) # type: Optional[str] if cont_token is None: - raw_result = self._create_or_update_initial( + raw_result = self._create_or_update_initial( # type: ignore resource_group_name=resource_group_name, resource_provider_namespace=resource_provider_namespace, parent_resource_path=parent_resource_path, @@ -8980,32 +10008,35 @@ def begin_create_or_update( api_version=api_version, parameters=parameters, content_type=content_type, - cls=lambda x,y,z: x, + cls=lambda x, y, z: x, + headers=_headers, + params=_params, **kwargs ) - kwargs.pop('error_map', None) + kwargs.pop("error_map", None) def get_long_running_output(pipeline_response): - response = pipeline_response.http_response - deserialized = self._deserialize('GenericResource', pipeline_response) + deserialized = self._deserialize("GenericResource", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - - if polling is True: polling_method = ARMPolling(lro_delay, **kwargs) - elif polling is False: polling_method = NoPolling() - else: polling_method = polling + if polling is True: + polling_method = cast(PollingMethod, ARMPolling(lro_delay, **kwargs)) # type: PollingMethod + elif polling is False: + polling_method = cast(PollingMethod, NoPolling()) + else: + polling_method = polling if cont_token: return LROPoller.from_continuation_token( polling_method=polling_method, continuation_token=cont_token, client=self._client, - deserialization_callback=get_long_running_output + deserialization_callback=get_long_running_output, ) return LROPoller(self._client, raw_result, get_long_running_output, polling_method) - begin_create_or_update.metadata = {'url': "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{parentResourcePath}/{resourceType}/{resourceName}"} # type: ignore + begin_create_or_update.metadata = {"url": "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{parentResourcePath}/{resourceType}/{resourceName}"} # type: ignore def _update_initial( self, @@ -9015,39 +10046,53 @@ def _update_initial( resource_type: str, resource_name: str, api_version: str, - parameters: "_models.GenericResource", + parameters: Union[_models.GenericResource, IO], **kwargs: Any - ) -> Optional["_models.GenericResource"]: - cls = kwargs.pop('cls', None) # type: ClsType[Optional["_models.GenericResource"]] + ) -> Optional[_models.GenericResource]: error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = kwargs.pop("params", {}) or {} - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[Optional[_models.GenericResource]] - _json = self._serialize.body(parameters, 'GenericResource') + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(parameters, (IO, bytes)): + _content = parameters + else: + _json = self._serialize.body(parameters, "GenericResource") - request = build_resources_update_request_initial( + request = build_resources_update_request( resource_group_name=resource_group_name, resource_provider_namespace=resource_provider_namespace, parent_resource_path=parent_resource_path, resource_type=resource_type, resource_name=resource_name, subscription_id=self._config.subscription_id, - content_type=content_type, api_version=api_version, + content_type=content_type, json=_json, - template_url=self._update_initial.metadata['url'], + content=_content, + template_url=self._update_initial.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200, 202]: @@ -9056,15 +10101,112 @@ def _update_initial( deserialized = None if response.status_code == 200: - deserialized = self._deserialize('GenericResource', pipeline_response) + deserialized = self._deserialize("GenericResource", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - _update_initial.metadata = {'url': "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{parentResourcePath}/{resourceType}/{resourceName}"} # type: ignore + _update_initial.metadata = {"url": "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{parentResourcePath}/{resourceType}/{resourceName}"} # type: ignore + + @overload + def begin_update( + self, + resource_group_name: str, + resource_provider_namespace: str, + parent_resource_path: str, + resource_type: str, + resource_name: str, + api_version: str, + parameters: _models.GenericResource, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> LROPoller[_models.GenericResource]: + """Updates a resource. + + :param resource_group_name: The name of the resource group for the resource. The name is case + insensitive. Required. + :type resource_group_name: str + :param resource_provider_namespace: The namespace of the resource provider. Required. + :type resource_provider_namespace: str + :param parent_resource_path: The parent resource identity. Required. + :type parent_resource_path: str + :param resource_type: The resource type of the resource to update. Required. + :type resource_type: str + :param resource_name: The name of the resource to update. Required. + :type resource_name: str + :param api_version: The API version to use for the operation. Required. + :type api_version: str + :param parameters: Parameters for updating the resource. Required. + :type parameters: ~azure.mgmt.resource.resources.v2021_04_01.models.GenericResource + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be ARMPolling. Pass in False for this + operation to not poll, or pass in your own initialized polling object for a personal polling + strategy. + :paramtype polling: bool or ~azure.core.polling.PollingMethod + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of LROPoller that returns either GenericResource or the result of + cls(response) + :rtype: + ~azure.core.polling.LROPoller[~azure.mgmt.resource.resources.v2021_04_01.models.GenericResource] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + def begin_update( + self, + resource_group_name: str, + resource_provider_namespace: str, + parent_resource_path: str, + resource_type: str, + resource_name: str, + api_version: str, + parameters: IO, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> LROPoller[_models.GenericResource]: + """Updates a resource. + :param resource_group_name: The name of the resource group for the resource. The name is case + insensitive. Required. + :type resource_group_name: str + :param resource_provider_namespace: The namespace of the resource provider. Required. + :type resource_provider_namespace: str + :param parent_resource_path: The parent resource identity. Required. + :type parent_resource_path: str + :param resource_type: The resource type of the resource to update. Required. + :type resource_type: str + :param resource_name: The name of the resource to update. Required. + :type resource_name: str + :param api_version: The API version to use for the operation. Required. + :type api_version: str + :param parameters: Parameters for updating the resource. Required. + :type parameters: IO + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be ARMPolling. Pass in False for this + operation to not poll, or pass in your own initialized polling object for a personal polling + strategy. + :paramtype polling: bool or ~azure.core.polling.PollingMethod + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of LROPoller that returns either GenericResource or the result of + cls(response) + :rtype: + ~azure.core.polling.LROPoller[~azure.mgmt.resource.resources.v2021_04_01.models.GenericResource] + :raises ~azure.core.exceptions.HttpResponseError: + """ @distributed_trace def begin_update( @@ -9075,26 +10217,30 @@ def begin_update( resource_type: str, resource_name: str, api_version: str, - parameters: "_models.GenericResource", + parameters: Union[_models.GenericResource, IO], **kwargs: Any - ) -> LROPoller["_models.GenericResource"]: + ) -> LROPoller[_models.GenericResource]: """Updates a resource. :param resource_group_name: The name of the resource group for the resource. The name is case - insensitive. + insensitive. Required. :type resource_group_name: str - :param resource_provider_namespace: The namespace of the resource provider. + :param resource_provider_namespace: The namespace of the resource provider. Required. :type resource_provider_namespace: str - :param parent_resource_path: The parent resource identity. + :param parent_resource_path: The parent resource identity. Required. :type parent_resource_path: str - :param resource_type: The resource type of the resource to update. + :param resource_type: The resource type of the resource to update. Required. :type resource_type: str - :param resource_name: The name of the resource to update. + :param resource_name: The name of the resource to update. Required. :type resource_name: str - :param api_version: The API version to use for the operation. + :param api_version: The API version to use for the operation. Required. :type api_version: str - :param parameters: Parameters for updating the resource. - :type parameters: ~azure.mgmt.resource.resources.v2021_04_01.models.GenericResource + :param parameters: Parameters for updating the resource. Is either a model type or a IO type. + Required. + :type parameters: ~azure.mgmt.resource.resources.v2021_04_01.models.GenericResource or IO + :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. + Default value is None. + :paramtype content_type: str :keyword callable cls: A custom type or function that will be passed the direct response :keyword str continuation_token: A continuation token to restart a poller from a saved state. :keyword polling: By default, your polling method will be ARMPolling. Pass in False for this @@ -9107,18 +10253,18 @@ def begin_update( cls(response) :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.resource.resources.v2021_04_01.models.GenericResource] - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] - polling = kwargs.pop('polling', True) # type: Union[bool, PollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType["_models.GenericResource"] - lro_delay = kwargs.pop( - 'polling_interval', - self._config.polling_interval - ) - cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = kwargs.pop("params", {}) or {} + + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.GenericResource] + polling = kwargs.pop("polling", True) # type: Union[bool, PollingMethod] + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token = kwargs.pop("continuation_token", None) # type: Optional[str] if cont_token is None: - raw_result = self._update_initial( + raw_result = self._update_initial( # type: ignore resource_group_name=resource_group_name, resource_provider_namespace=resource_provider_namespace, parent_resource_path=parent_resource_path, @@ -9127,32 +10273,35 @@ def begin_update( api_version=api_version, parameters=parameters, content_type=content_type, - cls=lambda x,y,z: x, + cls=lambda x, y, z: x, + headers=_headers, + params=_params, **kwargs ) - kwargs.pop('error_map', None) + kwargs.pop("error_map", None) def get_long_running_output(pipeline_response): - response = pipeline_response.http_response - deserialized = self._deserialize('GenericResource', pipeline_response) + deserialized = self._deserialize("GenericResource", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - - if polling is True: polling_method = ARMPolling(lro_delay, **kwargs) - elif polling is False: polling_method = NoPolling() - else: polling_method = polling + if polling is True: + polling_method = cast(PollingMethod, ARMPolling(lro_delay, **kwargs)) # type: PollingMethod + elif polling is False: + polling_method = cast(PollingMethod, NoPolling()) + else: + polling_method = polling if cont_token: return LROPoller.from_continuation_token( polling_method=polling_method, continuation_token=cont_token, client=self._client, - deserialization_callback=get_long_running_output + deserialization_callback=get_long_running_output, ) return LROPoller(self._client, raw_result, get_long_running_output, polling_method) - begin_update.metadata = {'url': "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{parentResourcePath}/{resourceType}/{resourceName}"} # type: ignore + begin_update.metadata = {"url": "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{parentResourcePath}/{resourceType}/{resourceName}"} # type: ignore @distributed_trace def get( @@ -9164,34 +10313,40 @@ def get( resource_name: str, api_version: str, **kwargs: Any - ) -> "_models.GenericResource": + ) -> _models.GenericResource: """Gets a resource. :param resource_group_name: The name of the resource group containing the resource to get. The - name is case insensitive. + name is case insensitive. Required. :type resource_group_name: str - :param resource_provider_namespace: The namespace of the resource provider. + :param resource_provider_namespace: The namespace of the resource provider. Required. :type resource_provider_namespace: str - :param parent_resource_path: The parent resource identity. + :param parent_resource_path: The parent resource identity. Required. :type parent_resource_path: str - :param resource_type: The resource type of the resource. + :param resource_type: The resource type of the resource. Required. :type resource_type: str - :param resource_name: The name of the resource to get. + :param resource_name: The name of the resource to get. Required. :type resource_name: str - :param api_version: The API version to use for the operation. + :param api_version: The API version to use for the operation. Required. :type api_version: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: GenericResource, or the result of cls(response) + :return: GenericResource or the result of cls(response) :rtype: ~azure.mgmt.resource.resources.v2021_04_01.models.GenericResource - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.GenericResource"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = kwargs.pop("params", {}) or {} + + cls = kwargs.pop("cls", None) # type: ClsType[_models.GenericResource] - request = build_resources_get_request( resource_group_name=resource_group_name, resource_provider_namespace=resource_provider_namespace, @@ -9200,72 +10355,78 @@ def get( resource_name=resource_name, subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.get.metadata['url'], + template_url=self.get.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) - deserialized = self._deserialize('GenericResource', pipeline_response) + deserialized = self._deserialize("GenericResource", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - get.metadata = {'url': "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{parentResourcePath}/{resourceType}/{resourceName}"} # type: ignore - + get.metadata = {"url": "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{parentResourcePath}/{resourceType}/{resourceName}"} # type: ignore @distributed_trace - def check_existence_by_id( - self, - resource_id: str, - api_version: str, - **kwargs: Any - ) -> bool: - """Checks by ID whether a resource exists. + def check_existence_by_id(self, resource_id: str, api_version: str, **kwargs: Any) -> bool: + """Checks by ID whether a resource exists. This API currently works only for a limited set of + Resource providers. In the event that a Resource provider does not implement this API, ARM will + respond with a 405. The alternative then is to use the GET API to check for the existence of + the resource. :param resource_id: The fully qualified ID of the resource, including the resource name and resource type. Use the format, /subscriptions/{guid}/resourceGroups/{resource-group-name}/{resource-provider-namespace}/{resource-type}/{resource-name}. + Required. :type resource_id: str - :param api_version: The API version to use for the operation. + :param api_version: The API version to use for the operation. Required. :type api_version: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: bool, or the result of cls(response) + :return: bool or the result of cls(response) :rtype: bool - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType[None] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = kwargs.pop("params", {}) or {} + + cls = kwargs.pop("cls", None) # type: ClsType[None] - request = build_resources_check_existence_by_id_request( resource_id=resource_id, api_version=api_version, - template_url=self.check_existence_by_id.metadata['url'], + template_url=self.check_existence_by_id.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [204, 404]: @@ -9276,35 +10437,38 @@ def check_existence_by_id( return cls(pipeline_response, None, {}) return 200 <= response.status_code <= 299 - check_existence_by_id.metadata = {'url': "/{resourceId}"} # type: ignore - + check_existence_by_id.metadata = {"url": "/{resourceId}"} # type: ignore def _delete_by_id_initial( # pylint: disable=inconsistent-return-statements - self, - resource_id: str, - api_version: str, - **kwargs: Any + self, resource_id: str, api_version: str, **kwargs: Any ) -> None: - cls = kwargs.pop('cls', None) # type: ClsType[None] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = kwargs.pop("params", {}) or {} + + cls = kwargs.pop("cls", None) # type: ClsType[None] - - request = build_resources_delete_by_id_request_initial( + request = build_resources_delete_by_id_request( resource_id=resource_id, api_version=api_version, - template_url=self._delete_by_id_initial.metadata['url'], + template_url=self._delete_by_id_initial.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200, 202, 204]: @@ -9314,23 +10478,18 @@ def _delete_by_id_initial( # pylint: disable=inconsistent-return-statements if cls: return cls(pipeline_response, None, {}) - _delete_by_id_initial.metadata = {'url': "/{resourceId}"} # type: ignore - + _delete_by_id_initial.metadata = {"url": "/{resourceId}"} # type: ignore @distributed_trace - def begin_delete_by_id( # pylint: disable=inconsistent-return-statements - self, - resource_id: str, - api_version: str, - **kwargs: Any - ) -> LROPoller[None]: + def begin_delete_by_id(self, resource_id: str, api_version: str, **kwargs: Any) -> LROPoller[None]: """Deletes a resource by ID. :param resource_id: The fully qualified ID of the resource, including the resource name and resource type. Use the format, /subscriptions/{guid}/resourceGroups/{resource-group-name}/{resource-provider-namespace}/{resource-type}/{resource-name}. + Required. :type resource_id: str - :param api_version: The API version to use for the operation. + :param api_version: The API version to use for the operation. Required. :type api_version: str :keyword callable cls: A custom type or function that will be passed the direct response :keyword str continuation_token: A continuation token to restart a poller from a saved state. @@ -9342,75 +10501,89 @@ def begin_delete_by_id( # pylint: disable=inconsistent-return-statements Retry-After header is present. :return: An instance of LROPoller that returns either None or the result of cls(response) :rtype: ~azure.core.polling.LROPoller[None] - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - polling = kwargs.pop('polling', True) # type: Union[bool, PollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType[None] - lro_delay = kwargs.pop( - 'polling_interval', - self._config.polling_interval - ) - cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] + _headers = kwargs.pop("headers", {}) or {} + _params = kwargs.pop("params", {}) or {} + + cls = kwargs.pop("cls", None) # type: ClsType[None] + polling = kwargs.pop("polling", True) # type: Union[bool, PollingMethod] + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token = kwargs.pop("continuation_token", None) # type: Optional[str] if cont_token is None: - raw_result = self._delete_by_id_initial( + raw_result = self._delete_by_id_initial( # type: ignore resource_id=resource_id, api_version=api_version, - cls=lambda x,y,z: x, + cls=lambda x, y, z: x, + headers=_headers, + params=_params, **kwargs ) - kwargs.pop('error_map', None) + kwargs.pop("error_map", None) - def get_long_running_output(pipeline_response): + def get_long_running_output(pipeline_response): # pylint: disable=inconsistent-return-statements if cls: return cls(pipeline_response, None, {}) - - if polling is True: polling_method = ARMPolling(lro_delay, **kwargs) - elif polling is False: polling_method = NoPolling() - else: polling_method = polling + if polling is True: + polling_method = cast(PollingMethod, ARMPolling(lro_delay, **kwargs)) # type: PollingMethod + elif polling is False: + polling_method = cast(PollingMethod, NoPolling()) + else: + polling_method = polling if cont_token: return LROPoller.from_continuation_token( polling_method=polling_method, continuation_token=cont_token, client=self._client, - deserialization_callback=get_long_running_output + deserialization_callback=get_long_running_output, ) return LROPoller(self._client, raw_result, get_long_running_output, polling_method) - begin_delete_by_id.metadata = {'url': "/{resourceId}"} # type: ignore + begin_delete_by_id.metadata = {"url": "/{resourceId}"} # type: ignore def _create_or_update_by_id_initial( - self, - resource_id: str, - api_version: str, - parameters: "_models.GenericResource", - **kwargs: Any - ) -> Optional["_models.GenericResource"]: - cls = kwargs.pop('cls', None) # type: ClsType[Optional["_models.GenericResource"]] + self, resource_id: str, api_version: str, parameters: Union[_models.GenericResource, IO], **kwargs: Any + ) -> Optional[_models.GenericResource]: error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = kwargs.pop("params", {}) or {} - _json = self._serialize.body(parameters, 'GenericResource') + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[Optional[_models.GenericResource]] + + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(parameters, (IO, bytes)): + _content = parameters + else: + _json = self._serialize.body(parameters, "GenericResource") - request = build_resources_create_or_update_by_id_request_initial( + request = build_resources_create_or_update_by_id_request( resource_id=resource_id, - content_type=content_type, api_version=api_version, + content_type=content_type, json=_json, - template_url=self._create_or_update_by_id_initial.metadata['url'], + content=_content, + template_url=self._create_or_update_by_id_initial.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200, 201, 202]: @@ -9419,37 +10592,42 @@ def _create_or_update_by_id_initial( deserialized = None if response.status_code == 200: - deserialized = self._deserialize('GenericResource', pipeline_response) + deserialized = self._deserialize("GenericResource", pipeline_response) if response.status_code == 201: - deserialized = self._deserialize('GenericResource', pipeline_response) + deserialized = self._deserialize("GenericResource", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - _create_or_update_by_id_initial.metadata = {'url': "/{resourceId}"} # type: ignore + _create_or_update_by_id_initial.metadata = {"url": "/{resourceId}"} # type: ignore - - @distributed_trace + @overload def begin_create_or_update_by_id( self, resource_id: str, api_version: str, - parameters: "_models.GenericResource", + parameters: _models.GenericResource, + *, + content_type: str = "application/json", **kwargs: Any - ) -> LROPoller["_models.GenericResource"]: + ) -> LROPoller[_models.GenericResource]: """Create a resource by ID. :param resource_id: The fully qualified ID of the resource, including the resource name and resource type. Use the format, /subscriptions/{guid}/resourceGroups/{resource-group-name}/{resource-provider-namespace}/{resource-type}/{resource-name}. + Required. :type resource_id: str - :param api_version: The API version to use for the operation. + :param api_version: The API version to use for the operation. Required. :type api_version: str - :param parameters: Create or update resource parameters. + :param parameters: Create or update resource parameters. Required. :type parameters: ~azure.mgmt.resource.resources.v2021_04_01.models.GenericResource + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str :keyword callable cls: A custom type or function that will be passed the direct response :keyword str continuation_token: A continuation token to restart a poller from a saved state. :keyword polling: By default, your polling method will be ARMPolling. Pass in False for this @@ -9462,81 +10640,167 @@ def begin_create_or_update_by_id( cls(response) :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.resource.resources.v2021_04_01.models.GenericResource] - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] - polling = kwargs.pop('polling', True) # type: Union[bool, PollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType["_models.GenericResource"] - lro_delay = kwargs.pop( - 'polling_interval', - self._config.polling_interval - ) - cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] + + @overload + def begin_create_or_update_by_id( + self, + resource_id: str, + api_version: str, + parameters: IO, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> LROPoller[_models.GenericResource]: + """Create a resource by ID. + + :param resource_id: The fully qualified ID of the resource, including the resource name and + resource type. Use the format, + /subscriptions/{guid}/resourceGroups/{resource-group-name}/{resource-provider-namespace}/{resource-type}/{resource-name}. + Required. + :type resource_id: str + :param api_version: The API version to use for the operation. Required. + :type api_version: str + :param parameters: Create or update resource parameters. Required. + :type parameters: IO + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be ARMPolling. Pass in False for this + operation to not poll, or pass in your own initialized polling object for a personal polling + strategy. + :paramtype polling: bool or ~azure.core.polling.PollingMethod + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of LROPoller that returns either GenericResource or the result of + cls(response) + :rtype: + ~azure.core.polling.LROPoller[~azure.mgmt.resource.resources.v2021_04_01.models.GenericResource] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace + def begin_create_or_update_by_id( + self, resource_id: str, api_version: str, parameters: Union[_models.GenericResource, IO], **kwargs: Any + ) -> LROPoller[_models.GenericResource]: + """Create a resource by ID. + + :param resource_id: The fully qualified ID of the resource, including the resource name and + resource type. Use the format, + /subscriptions/{guid}/resourceGroups/{resource-group-name}/{resource-provider-namespace}/{resource-type}/{resource-name}. + Required. + :type resource_id: str + :param api_version: The API version to use for the operation. Required. + :type api_version: str + :param parameters: Create or update resource parameters. Is either a model type or a IO type. + Required. + :type parameters: ~azure.mgmt.resource.resources.v2021_04_01.models.GenericResource or IO + :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. + Default value is None. + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be ARMPolling. Pass in False for this + operation to not poll, or pass in your own initialized polling object for a personal polling + strategy. + :paramtype polling: bool or ~azure.core.polling.PollingMethod + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of LROPoller that returns either GenericResource or the result of + cls(response) + :rtype: + ~azure.core.polling.LROPoller[~azure.mgmt.resource.resources.v2021_04_01.models.GenericResource] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = kwargs.pop("params", {}) or {} + + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.GenericResource] + polling = kwargs.pop("polling", True) # type: Union[bool, PollingMethod] + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token = kwargs.pop("continuation_token", None) # type: Optional[str] if cont_token is None: - raw_result = self._create_or_update_by_id_initial( + raw_result = self._create_or_update_by_id_initial( # type: ignore resource_id=resource_id, api_version=api_version, parameters=parameters, content_type=content_type, - cls=lambda x,y,z: x, + cls=lambda x, y, z: x, + headers=_headers, + params=_params, **kwargs ) - kwargs.pop('error_map', None) + kwargs.pop("error_map", None) def get_long_running_output(pipeline_response): - response = pipeline_response.http_response - deserialized = self._deserialize('GenericResource', pipeline_response) + deserialized = self._deserialize("GenericResource", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - - if polling is True: polling_method = ARMPolling(lro_delay, **kwargs) - elif polling is False: polling_method = NoPolling() - else: polling_method = polling + if polling is True: + polling_method = cast(PollingMethod, ARMPolling(lro_delay, **kwargs)) # type: PollingMethod + elif polling is False: + polling_method = cast(PollingMethod, NoPolling()) + else: + polling_method = polling if cont_token: return LROPoller.from_continuation_token( polling_method=polling_method, continuation_token=cont_token, client=self._client, - deserialization_callback=get_long_running_output + deserialization_callback=get_long_running_output, ) return LROPoller(self._client, raw_result, get_long_running_output, polling_method) - begin_create_or_update_by_id.metadata = {'url': "/{resourceId}"} # type: ignore + begin_create_or_update_by_id.metadata = {"url": "/{resourceId}"} # type: ignore def _update_by_id_initial( - self, - resource_id: str, - api_version: str, - parameters: "_models.GenericResource", - **kwargs: Any - ) -> Optional["_models.GenericResource"]: - cls = kwargs.pop('cls', None) # type: ClsType[Optional["_models.GenericResource"]] + self, resource_id: str, api_version: str, parameters: Union[_models.GenericResource, IO], **kwargs: Any + ) -> Optional[_models.GenericResource]: error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = kwargs.pop("params", {}) or {} - _json = self._serialize.body(parameters, 'GenericResource') + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[Optional[_models.GenericResource]] - request = build_resources_update_by_id_request_initial( + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(parameters, (IO, bytes)): + _content = parameters + else: + _json = self._serialize.body(parameters, "GenericResource") + + request = build_resources_update_by_id_request( resource_id=resource_id, - content_type=content_type, api_version=api_version, + content_type=content_type, json=_json, - template_url=self._update_by_id_initial.metadata['url'], + content=_content, + template_url=self._update_by_id_initial.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200, 202]: @@ -9545,34 +10809,39 @@ def _update_by_id_initial( deserialized = None if response.status_code == 200: - deserialized = self._deserialize('GenericResource', pipeline_response) + deserialized = self._deserialize("GenericResource", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - _update_by_id_initial.metadata = {'url': "/{resourceId}"} # type: ignore - + _update_by_id_initial.metadata = {"url": "/{resourceId}"} # type: ignore - @distributed_trace + @overload def begin_update_by_id( self, resource_id: str, api_version: str, - parameters: "_models.GenericResource", + parameters: _models.GenericResource, + *, + content_type: str = "application/json", **kwargs: Any - ) -> LROPoller["_models.GenericResource"]: + ) -> LROPoller[_models.GenericResource]: """Updates a resource by ID. :param resource_id: The fully qualified ID of the resource, including the resource name and resource type. Use the format, /subscriptions/{guid}/resourceGroups/{resource-group-name}/{resource-provider-namespace}/{resource-type}/{resource-name}. + Required. :type resource_id: str - :param api_version: The API version to use for the operation. + :param api_version: The API version to use for the operation. Required. :type api_version: str - :param parameters: Update resource parameters. + :param parameters: Update resource parameters. Required. :type parameters: ~azure.mgmt.resource.resources.v2021_04_01.models.GenericResource + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str :keyword callable cls: A custom type or function that will be passed the direct response :keyword str continuation_token: A continuation token to restart a poller from a saved state. :keyword polling: By default, your polling method will be ARMPolling. Pass in False for this @@ -9585,165 +10854,243 @@ def begin_update_by_id( cls(response) :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.resource.resources.v2021_04_01.models.GenericResource] - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] - polling = kwargs.pop('polling', True) # type: Union[bool, PollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType["_models.GenericResource"] - lro_delay = kwargs.pop( - 'polling_interval', - self._config.polling_interval - ) - cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] + + @overload + def begin_update_by_id( + self, + resource_id: str, + api_version: str, + parameters: IO, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> LROPoller[_models.GenericResource]: + """Updates a resource by ID. + + :param resource_id: The fully qualified ID of the resource, including the resource name and + resource type. Use the format, + /subscriptions/{guid}/resourceGroups/{resource-group-name}/{resource-provider-namespace}/{resource-type}/{resource-name}. + Required. + :type resource_id: str + :param api_version: The API version to use for the operation. Required. + :type api_version: str + :param parameters: Update resource parameters. Required. + :type parameters: IO + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be ARMPolling. Pass in False for this + operation to not poll, or pass in your own initialized polling object for a personal polling + strategy. + :paramtype polling: bool or ~azure.core.polling.PollingMethod + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of LROPoller that returns either GenericResource or the result of + cls(response) + :rtype: + ~azure.core.polling.LROPoller[~azure.mgmt.resource.resources.v2021_04_01.models.GenericResource] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace + def begin_update_by_id( + self, resource_id: str, api_version: str, parameters: Union[_models.GenericResource, IO], **kwargs: Any + ) -> LROPoller[_models.GenericResource]: + """Updates a resource by ID. + + :param resource_id: The fully qualified ID of the resource, including the resource name and + resource type. Use the format, + /subscriptions/{guid}/resourceGroups/{resource-group-name}/{resource-provider-namespace}/{resource-type}/{resource-name}. + Required. + :type resource_id: str + :param api_version: The API version to use for the operation. Required. + :type api_version: str + :param parameters: Update resource parameters. Is either a model type or a IO type. Required. + :type parameters: ~azure.mgmt.resource.resources.v2021_04_01.models.GenericResource or IO + :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. + Default value is None. + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be ARMPolling. Pass in False for this + operation to not poll, or pass in your own initialized polling object for a personal polling + strategy. + :paramtype polling: bool or ~azure.core.polling.PollingMethod + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of LROPoller that returns either GenericResource or the result of + cls(response) + :rtype: + ~azure.core.polling.LROPoller[~azure.mgmt.resource.resources.v2021_04_01.models.GenericResource] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = kwargs.pop("params", {}) or {} + + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.GenericResource] + polling = kwargs.pop("polling", True) # type: Union[bool, PollingMethod] + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token = kwargs.pop("continuation_token", None) # type: Optional[str] if cont_token is None: - raw_result = self._update_by_id_initial( + raw_result = self._update_by_id_initial( # type: ignore resource_id=resource_id, api_version=api_version, parameters=parameters, content_type=content_type, - cls=lambda x,y,z: x, + cls=lambda x, y, z: x, + headers=_headers, + params=_params, **kwargs ) - kwargs.pop('error_map', None) + kwargs.pop("error_map", None) def get_long_running_output(pipeline_response): - response = pipeline_response.http_response - deserialized = self._deserialize('GenericResource', pipeline_response) + deserialized = self._deserialize("GenericResource", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - - if polling is True: polling_method = ARMPolling(lro_delay, **kwargs) - elif polling is False: polling_method = NoPolling() - else: polling_method = polling + if polling is True: + polling_method = cast(PollingMethod, ARMPolling(lro_delay, **kwargs)) # type: PollingMethod + elif polling is False: + polling_method = cast(PollingMethod, NoPolling()) + else: + polling_method = polling if cont_token: return LROPoller.from_continuation_token( polling_method=polling_method, continuation_token=cont_token, client=self._client, - deserialization_callback=get_long_running_output + deserialization_callback=get_long_running_output, ) return LROPoller(self._client, raw_result, get_long_running_output, polling_method) - begin_update_by_id.metadata = {'url': "/{resourceId}"} # type: ignore + begin_update_by_id.metadata = {"url": "/{resourceId}"} # type: ignore @distributed_trace - def get_by_id( - self, - resource_id: str, - api_version: str, - **kwargs: Any - ) -> "_models.GenericResource": + def get_by_id(self, resource_id: str, api_version: str, **kwargs: Any) -> _models.GenericResource: """Gets a resource by ID. :param resource_id: The fully qualified ID of the resource, including the resource name and resource type. Use the format, /subscriptions/{guid}/resourceGroups/{resource-group-name}/{resource-provider-namespace}/{resource-type}/{resource-name}. + Required. :type resource_id: str - :param api_version: The API version to use for the operation. + :param api_version: The API version to use for the operation. Required. :type api_version: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: GenericResource, or the result of cls(response) + :return: GenericResource or the result of cls(response) :rtype: ~azure.mgmt.resource.resources.v2021_04_01.models.GenericResource - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.GenericResource"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = kwargs.pop("params", {}) or {} + + cls = kwargs.pop("cls", None) # type: ClsType[_models.GenericResource] - request = build_resources_get_by_id_request( resource_id=resource_id, api_version=api_version, - template_url=self.get_by_id.metadata['url'], + template_url=self.get_by_id.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) - deserialized = self._deserialize('GenericResource', pipeline_response) + deserialized = self._deserialize("GenericResource", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - get_by_id.metadata = {'url': "/{resourceId}"} # type: ignore + get_by_id.metadata = {"url": "/{resourceId}"} # type: ignore -class ResourceGroupsOperations(object): - """ResourceGroupsOperations operations. - You should not instantiate this class directly. Instead, you should create a Client instance that - instantiates it for you and attaches it as an attribute. +class ResourceGroupsOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. - :ivar models: Alias to model classes used in this operation group. - :type models: ~azure.mgmt.resource.resources.v2021_04_01.models - :param client: Client for service requests. - :param config: Configuration of service client. - :param serializer: An object model serializer. - :param deserializer: An object model deserializer. + Instead, you should access the following operations through + :class:`~azure.mgmt.resource.resources.v2021_04_01.ResourceManagementClient`'s + :attr:`resource_groups` attribute. """ models = _models - def __init__(self, client, config, serializer, deserializer): - self._client = client - self._serialize = serializer - self._deserialize = deserializer - self._config = config + def __init__(self, *args, **kwargs): + input_args = list(args) + self._client = input_args.pop(0) if input_args else kwargs.pop("client") + self._config = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") @distributed_trace - def check_existence( - self, - resource_group_name: str, - **kwargs: Any - ) -> bool: + def check_existence(self, resource_group_name: str, **kwargs: Any) -> bool: """Checks whether a resource group exists. :param resource_group_name: The name of the resource group to check. The name is case - insensitive. + insensitive. Required. :type resource_group_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: bool, or the result of cls(response) + :return: bool or the result of cls(response) :rtype: bool - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType[None] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) - api_version = kwargs.pop('api_version', "2021-04-01") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-04-01")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[None] - request = build_resource_groups_check_existence_request( resource_group_name=resource_group_name, subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.check_existence.metadata['url'], + template_url=self.check_existence.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [204, 404]: @@ -9754,39 +11101,98 @@ def check_existence( return cls(pipeline_response, None, {}) return 200 <= response.status_code <= 299 - check_existence.metadata = {'url': "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}"} # type: ignore + check_existence.metadata = {"url": "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}"} # type: ignore - - @distributed_trace + @overload def create_or_update( self, resource_group_name: str, - parameters: "_models.ResourceGroup", + parameters: _models.ResourceGroup, + *, + content_type: str = "application/json", **kwargs: Any - ) -> "_models.ResourceGroup": + ) -> _models.ResourceGroup: """Creates or updates a resource group. :param resource_group_name: The name of the resource group to create or update. Can include alphanumeric, underscore, parentheses, hyphen, period (except at end), and Unicode characters - that match the allowed characters. + that match the allowed characters. Required. :type resource_group_name: str - :param parameters: Parameters supplied to the create or update a resource group. + :param parameters: Parameters supplied to the create or update a resource group. Required. :type parameters: ~azure.mgmt.resource.resources.v2021_04_01.models.ResourceGroup + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: ResourceGroup or the result of cls(response) + :rtype: ~azure.mgmt.resource.resources.v2021_04_01.models.ResourceGroup + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + def create_or_update( + self, resource_group_name: str, parameters: IO, *, content_type: str = "application/json", **kwargs: Any + ) -> _models.ResourceGroup: + """Creates or updates a resource group. + + :param resource_group_name: The name of the resource group to create or update. Can include + alphanumeric, underscore, parentheses, hyphen, period (except at end), and Unicode characters + that match the allowed characters. Required. + :type resource_group_name: str + :param parameters: Parameters supplied to the create or update a resource group. Required. + :type parameters: IO + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: ResourceGroup or the result of cls(response) + :rtype: ~azure.mgmt.resource.resources.v2021_04_01.models.ResourceGroup + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace + def create_or_update( + self, resource_group_name: str, parameters: Union[_models.ResourceGroup, IO], **kwargs: Any + ) -> _models.ResourceGroup: + """Creates or updates a resource group. + + :param resource_group_name: The name of the resource group to create or update. Can include + alphanumeric, underscore, parentheses, hyphen, period (except at end), and Unicode characters + that match the allowed characters. Required. + :type resource_group_name: str + :param parameters: Parameters supplied to the create or update a resource group. Is either a + model type or a IO type. Required. + :type parameters: ~azure.mgmt.resource.resources.v2021_04_01.models.ResourceGroup or IO + :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. + Default value is None. + :paramtype content_type: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: ResourceGroup, or the result of cls(response) + :return: ResourceGroup or the result of cls(response) :rtype: ~azure.mgmt.resource.resources.v2021_04_01.models.ResourceGroup - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.ResourceGroup"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', "2021-04-01") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-04-01")) # type: str + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.ResourceGroup] - _json = self._serialize.body(parameters, 'ResourceGroup') + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(parameters, (IO, bytes)): + _content = parameters + else: + _json = self._serialize.body(parameters, "ResourceGroup") request = build_resource_groups_create_or_update_request( resource_group_name=resource_group_name, @@ -9794,16 +11200,18 @@ def create_or_update( api_version=api_version, content_type=content_type, json=_json, - template_url=self.create_or_update.metadata['url'], + content=_content, + template_url=self.create_or_update.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200, 201]: @@ -9811,49 +11219,51 @@ def create_or_update( raise HttpResponseError(response=response, error_format=ARMErrorFormat) if response.status_code == 200: - deserialized = self._deserialize('ResourceGroup', pipeline_response) + deserialized = self._deserialize("ResourceGroup", pipeline_response) if response.status_code == 201: - deserialized = self._deserialize('ResourceGroup', pipeline_response) + deserialized = self._deserialize("ResourceGroup", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - create_or_update.metadata = {'url': "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}"} # type: ignore - + create_or_update.metadata = {"url": "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}"} # type: ignore def _delete_initial( # pylint: disable=inconsistent-return-statements - self, - resource_group_name: str, - force_deletion_types: Optional[str] = None, - **kwargs: Any + self, resource_group_name: str, force_deletion_types: Optional[str] = None, **kwargs: Any ) -> None: - cls = kwargs.pop('cls', None) # type: ClsType[None] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) - api_version = kwargs.pop('api_version', "2021-04-01") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - request = build_resource_groups_delete_request_initial( + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-04-01")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[None] + + request = build_resource_groups_delete_request( resource_group_name=resource_group_name, subscription_id=self._config.subscription_id, - api_version=api_version, force_deletion_types=force_deletion_types, - template_url=self._delete_initial.metadata['url'], + api_version=api_version, + template_url=self._delete_initial.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200, 202]: @@ -9863,15 +11273,11 @@ def _delete_initial( # pylint: disable=inconsistent-return-statements if cls: return cls(pipeline_response, None, {}) - _delete_initial.metadata = {'url': "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}"} # type: ignore - + _delete_initial.metadata = {"url": "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}"} # type: ignore @distributed_trace - def begin_delete( # pylint: disable=inconsistent-return-statements - self, - resource_group_name: str, - force_deletion_types: Optional[str] = None, - **kwargs: Any + def begin_delete( + self, resource_group_name: str, force_deletion_types: Optional[str] = None, **kwargs: Any ) -> LROPoller[None]: """Deletes a resource group. @@ -9879,7 +11285,7 @@ def begin_delete( # pylint: disable=inconsistent-return-statements group deletes all of its template deployments and currently stored operations. :param resource_group_name: The name of the resource group to delete. The name is case - insensitive. + insensitive. Required. :type resource_group_name: str :param force_deletion_types: The resource types you want to force delete. Currently, only the following is supported: @@ -9896,107 +11302,114 @@ def begin_delete( # pylint: disable=inconsistent-return-statements Retry-After header is present. :return: An instance of LROPoller that returns either None or the result of cls(response) :rtype: ~azure.core.polling.LROPoller[None] - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - api_version = kwargs.pop('api_version', "2021-04-01") # type: str - polling = kwargs.pop('polling', True) # type: Union[bool, PollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType[None] - lro_delay = kwargs.pop( - 'polling_interval', - self._config.polling_interval - ) - cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-04-01")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[None] + polling = kwargs.pop("polling", True) # type: Union[bool, PollingMethod] + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token = kwargs.pop("continuation_token", None) # type: Optional[str] if cont_token is None: - raw_result = self._delete_initial( + raw_result = self._delete_initial( # type: ignore resource_group_name=resource_group_name, force_deletion_types=force_deletion_types, api_version=api_version, - cls=lambda x,y,z: x, + cls=lambda x, y, z: x, + headers=_headers, + params=_params, **kwargs ) - kwargs.pop('error_map', None) + kwargs.pop("error_map", None) - def get_long_running_output(pipeline_response): + def get_long_running_output(pipeline_response): # pylint: disable=inconsistent-return-statements if cls: return cls(pipeline_response, None, {}) - - if polling is True: polling_method = ARMPolling(lro_delay, **kwargs) - elif polling is False: polling_method = NoPolling() - else: polling_method = polling + if polling is True: + polling_method = cast(PollingMethod, ARMPolling(lro_delay, **kwargs)) # type: PollingMethod + elif polling is False: + polling_method = cast(PollingMethod, NoPolling()) + else: + polling_method = polling if cont_token: return LROPoller.from_continuation_token( polling_method=polling_method, continuation_token=cont_token, client=self._client, - deserialization_callback=get_long_running_output + deserialization_callback=get_long_running_output, ) return LROPoller(self._client, raw_result, get_long_running_output, polling_method) - begin_delete.metadata = {'url': "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}"} # type: ignore + begin_delete.metadata = {"url": "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}"} # type: ignore @distributed_trace - def get( - self, - resource_group_name: str, - **kwargs: Any - ) -> "_models.ResourceGroup": + def get(self, resource_group_name: str, **kwargs: Any) -> _models.ResourceGroup: """Gets a resource group. :param resource_group_name: The name of the resource group to get. The name is case - insensitive. + insensitive. Required. :type resource_group_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: ResourceGroup, or the result of cls(response) + :return: ResourceGroup or the result of cls(response) :rtype: ~azure.mgmt.resource.resources.v2021_04_01.models.ResourceGroup - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.ResourceGroup"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + 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', "2021-04-01") # type: str + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-04-01")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[_models.ResourceGroup] - request = build_resource_groups_get_request( resource_group_name=resource_group_name, subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.get.metadata['url'], + template_url=self.get.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) - deserialized = self._deserialize('ResourceGroup', pipeline_response) + deserialized = self._deserialize("ResourceGroup", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - get.metadata = {'url': "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}"} # type: ignore - + get.metadata = {"url": "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}"} # type: ignore - @distributed_trace + @overload def update( self, resource_group_name: str, - parameters: "_models.ResourceGroupPatchable", + parameters: _models.ResourceGroupPatchable, + *, + content_type: str = "application/json", **kwargs: Any - ) -> "_models.ResourceGroup": + ) -> _models.ResourceGroup: """Updates a resource group. Resource groups can be updated through a simple PATCH operation to a group address. The format @@ -10004,25 +11417,90 @@ def update( the current value is retained. :param resource_group_name: The name of the resource group to update. The name is case - insensitive. + insensitive. Required. :type resource_group_name: str - :param parameters: Parameters supplied to update a resource group. + :param parameters: Parameters supplied to update a resource group. Required. :type parameters: ~azure.mgmt.resource.resources.v2021_04_01.models.ResourceGroupPatchable + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: ResourceGroup or the result of cls(response) + :rtype: ~azure.mgmt.resource.resources.v2021_04_01.models.ResourceGroup + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + def update( + self, resource_group_name: str, parameters: IO, *, content_type: str = "application/json", **kwargs: Any + ) -> _models.ResourceGroup: + """Updates a resource group. + + Resource groups can be updated through a simple PATCH operation to a group address. The format + of the request is the same as that for creating a resource group. If a field is unspecified, + the current value is retained. + + :param resource_group_name: The name of the resource group to update. The name is case + insensitive. Required. + :type resource_group_name: str + :param parameters: Parameters supplied to update a resource group. Required. + :type parameters: IO + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: ResourceGroup, or the result of cls(response) + :return: ResourceGroup or the result of cls(response) :rtype: ~azure.mgmt.resource.resources.v2021_04_01.models.ResourceGroup - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace + def update( + self, resource_group_name: str, parameters: Union[_models.ResourceGroupPatchable, IO], **kwargs: Any + ) -> _models.ResourceGroup: + """Updates a resource group. + + Resource groups can be updated through a simple PATCH operation to a group address. The format + of the request is the same as that for creating a resource group. If a field is unspecified, + the current value is retained. + + :param resource_group_name: The name of the resource group to update. The name is case + insensitive. Required. + :type resource_group_name: str + :param parameters: Parameters supplied to update a resource group. Is either a model type or a + IO type. Required. + :type parameters: ~azure.mgmt.resource.resources.v2021_04_01.models.ResourceGroupPatchable or + IO + :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. + Default value is None. + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: ResourceGroup or the result of cls(response) + :rtype: ~azure.mgmt.resource.resources.v2021_04_01.models.ResourceGroup + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.ResourceGroup"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) - api_version = kwargs.pop('api_version', "2021-04-01") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - _json = self._serialize.body(parameters, 'ResourceGroupPatchable') + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-04-01")) # type: str + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.ResourceGroup] + + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(parameters, (IO, bytes)): + _content = parameters + else: + _json = self._serialize.body(parameters, "ResourceGroupPatchable") request = build_resource_groups_update_request( resource_group_name=resource_group_name, @@ -10030,65 +11508,77 @@ def update( api_version=api_version, content_type=content_type, json=_json, - template_url=self.update.metadata['url'], + content=_content, + template_url=self.update.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) - deserialized = self._deserialize('ResourceGroup', pipeline_response) + deserialized = self._deserialize("ResourceGroup", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - update.metadata = {'url': "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}"} # type: ignore - + update.metadata = {"url": "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}"} # type: ignore def _export_template_initial( - self, - resource_group_name: str, - parameters: "_models.ExportTemplateRequest", - **kwargs: Any - ) -> Optional["_models.ResourceGroupExportResult"]: - cls = kwargs.pop('cls', None) # type: ClsType[Optional["_models.ResourceGroupExportResult"]] + self, resource_group_name: str, parameters: Union[_models.ExportTemplateRequest, IO], **kwargs: Any + ) -> Optional[_models.ResourceGroupExportResult]: error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) - api_version = kwargs.pop('api_version', "2021-04-01") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - _json = self._serialize.body(parameters, 'ExportTemplateRequest') + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-04-01")) # type: str + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[Optional[_models.ResourceGroupExportResult]] - request = build_resource_groups_export_template_request_initial( - subscription_id=self._config.subscription_id, + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(parameters, (IO, bytes)): + _content = parameters + else: + _json = self._serialize.body(parameters, "ExportTemplateRequest") + + request = build_resource_groups_export_template_request( resource_group_name=resource_group_name, + subscription_id=self._config.subscription_id, api_version=api_version, content_type=content_type, json=_json, - template_url=self._export_template_initial.metadata['url'], + content=_content, + template_url=self._export_template_initial.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200, 202]: @@ -10097,29 +11587,93 @@ def _export_template_initial( deserialized = None if response.status_code == 200: - deserialized = self._deserialize('ResourceGroupExportResult', pipeline_response) + deserialized = self._deserialize("ResourceGroupExportResult", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - _export_template_initial.metadata = {'url': "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/exportTemplate"} # type: ignore - + _export_template_initial.metadata = {"url": "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/exportTemplate"} # type: ignore - @distributed_trace + @overload def begin_export_template( self, resource_group_name: str, - parameters: "_models.ExportTemplateRequest", + parameters: _models.ExportTemplateRequest, + *, + content_type: str = "application/json", **kwargs: Any - ) -> LROPoller["_models.ResourceGroupExportResult"]: + ) -> LROPoller[_models.ResourceGroupExportResult]: + """Captures the specified resource group as a template. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param parameters: Parameters for exporting the template. Required. + :type parameters: ~azure.mgmt.resource.resources.v2021_04_01.models.ExportTemplateRequest + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be ARMPolling. Pass in False for this + operation to not poll, or pass in your own initialized polling object for a personal polling + strategy. + :paramtype polling: bool or ~azure.core.polling.PollingMethod + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of LROPoller that returns either ResourceGroupExportResult or the result + of cls(response) + :rtype: + ~azure.core.polling.LROPoller[~azure.mgmt.resource.resources.v2021_04_01.models.ResourceGroupExportResult] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + def begin_export_template( + self, resource_group_name: str, parameters: IO, *, content_type: str = "application/json", **kwargs: Any + ) -> LROPoller[_models.ResourceGroupExportResult]: + """Captures the specified resource group as a template. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param parameters: Parameters for exporting the template. Required. + :type parameters: IO + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be ARMPolling. Pass in False for this + operation to not poll, or pass in your own initialized polling object for a personal polling + strategy. + :paramtype polling: bool or ~azure.core.polling.PollingMethod + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of LROPoller that returns either ResourceGroupExportResult or the result + of cls(response) + :rtype: + ~azure.core.polling.LROPoller[~azure.mgmt.resource.resources.v2021_04_01.models.ResourceGroupExportResult] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace + def begin_export_template( + self, resource_group_name: str, parameters: Union[_models.ExportTemplateRequest, IO], **kwargs: Any + ) -> LROPoller[_models.ResourceGroupExportResult]: """Captures the specified resource group as a template. :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. :type resource_group_name: str - :param parameters: Parameters for exporting the template. - :type parameters: ~azure.mgmt.resource.resources.v2021_04_01.models.ExportTemplateRequest + :param parameters: Parameters for exporting the template. Is either a model type or a IO type. + Required. + :type parameters: ~azure.mgmt.resource.resources.v2021_04_01.models.ExportTemplateRequest or IO + :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. + Default value is None. + :paramtype content_type: str :keyword callable cls: A custom type or function that will be passed the direct response :keyword str continuation_token: A continuation token to restart a poller from a saved state. :keyword polling: By default, your polling method will be ARMPolling. Pass in False for this @@ -10132,57 +11686,59 @@ def begin_export_template( of cls(response) :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.resource.resources.v2021_04_01.models.ResourceGroupExportResult] - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - api_version = kwargs.pop('api_version', "2021-04-01") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] - polling = kwargs.pop('polling', True) # type: Union[bool, PollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType["_models.ResourceGroupExportResult"] - lro_delay = kwargs.pop( - 'polling_interval', - self._config.polling_interval - ) - cont_token = kwargs.pop('continuation_token', None) # type: Optional[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-04-01")) # type: str + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.ResourceGroupExportResult] + polling = kwargs.pop("polling", True) # type: Union[bool, PollingMethod] + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token = kwargs.pop("continuation_token", None) # type: Optional[str] if cont_token is None: - raw_result = self._export_template_initial( + raw_result = self._export_template_initial( # type: ignore resource_group_name=resource_group_name, parameters=parameters, api_version=api_version, content_type=content_type, - cls=lambda x,y,z: x, + cls=lambda x, y, z: x, + headers=_headers, + params=_params, **kwargs ) - kwargs.pop('error_map', None) + kwargs.pop("error_map", None) def get_long_running_output(pipeline_response): - response = pipeline_response.http_response - deserialized = self._deserialize('ResourceGroupExportResult', pipeline_response) + deserialized = self._deserialize("ResourceGroupExportResult", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - - if polling is True: polling_method = ARMPolling(lro_delay, lro_options={'final-state-via': 'location'}, **kwargs) - elif polling is False: polling_method = NoPolling() - else: polling_method = polling + if polling is True: + polling_method = cast( + PollingMethod, ARMPolling(lro_delay, lro_options={"final-state-via": "location"}, **kwargs) + ) # type: PollingMethod + elif polling is False: + polling_method = cast(PollingMethod, NoPolling()) + else: + polling_method = polling if cont_token: return LROPoller.from_continuation_token( polling_method=polling_method, continuation_token=cont_token, client=self._client, - deserialization_callback=get_long_running_output + deserialization_callback=get_long_running_output, ) return LROPoller(self._client, raw_result, get_long_running_output, polling_method) - begin_export_template.metadata = {'url': "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/exportTemplate"} # type: ignore + begin_export_template.metadata = {"url": "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/exportTemplate"} # type: ignore @distributed_trace def list( - self, - filter: Optional[str] = None, - top: Optional[int] = None, - **kwargs: Any - ) -> Iterable["_models.ResourceGroupListResult"]: + self, filter: Optional[str] = None, top: Optional[int] = None, **kwargs: Any + ) -> Iterable["_models.ResourceGroup"]: """Gets all the resource groups for a subscription. :param filter: The filter to apply on the operation.:code:`
`:code:`
`You can filter by @@ -10193,40 +11749,48 @@ def list( Default value is None. :type top: int :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either ResourceGroupListResult or the result of - cls(response) + :return: An iterator like instance of either ResourceGroup or the result of cls(response) :rtype: - ~azure.core.paging.ItemPaged[~azure.mgmt.resource.resources.v2021_04_01.models.ResourceGroupListResult] - :raises: ~azure.core.exceptions.HttpResponseError + ~azure.core.paging.ItemPaged[~azure.mgmt.resource.resources.v2021_04_01.models.ResourceGroup] + :raises ~azure.core.exceptions.HttpResponseError: """ - api_version = kwargs.pop('api_version', "2021-04-01") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-04-01")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[_models.ResourceGroupListResult] - cls = kwargs.pop('cls', None) # type: ClsType["_models.ResourceGroupListResult"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) + def prepare_request(next_link=None): if not next_link: - + request = build_resource_groups_list_request( subscription_id=self._config.subscription_id, - api_version=api_version, filter=filter, top=top, - template_url=self.list.metadata['url'], + 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.url = self._client.format_url(request.url) # type: ignore else: - - request = build_resource_groups_list_request( - subscription_id=self._config.subscription_id, - template_url=next_link, - ) + # make call to next link with the client's api-version + _parsed_next_link = urlparse(next_link) + _next_request_params = case_insensitive_dict(parse_qs(_parsed_next_link.query)) + _next_request_params["api-version"] = self._config.api_version + request = HttpRequest("GET", urljoin(next_link, _parsed_next_link.path), params=_next_request_params) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore request.method = "GET" return request @@ -10240,10 +11804,8 @@ def extract_data(pipeline_response): def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) response = pipeline_response.http_response @@ -10253,39 +11815,33 @@ def get_next(next_link=None): return pipeline_response + return ItemPaged(get_next, extract_data) - return ItemPaged( - get_next, extract_data - ) - list.metadata = {'url': "/subscriptions/{subscriptionId}/resourcegroups"} # type: ignore -class TagsOperations(object): - """TagsOperations operations. + list.metadata = {"url": "/subscriptions/{subscriptionId}/resourcegroups"} # type: ignore - You should not instantiate this class directly. Instead, you should create a Client instance that - instantiates it for you and attaches it as an attribute. - :ivar models: Alias to model classes used in this operation group. - :type models: ~azure.mgmt.resource.resources.v2021_04_01.models - :param client: Client for service requests. - :param config: Configuration of service client. - :param serializer: An object model serializer. - :param deserializer: An object model deserializer. +class TagsOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. + + Instead, you should access the following operations through + :class:`~azure.mgmt.resource.resources.v2021_04_01.ResourceManagementClient`'s + :attr:`tags` attribute. """ models = _models - def __init__(self, client, config, serializer, deserializer): - self._client = client - self._serialize = serializer - self._deserialize = deserializer - self._config = config + def __init__(self, *args, **kwargs): + input_args = list(args) + self._client = input_args.pop(0) if input_args else kwargs.pop("client") + self._config = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") @distributed_trace def delete_value( # pylint: disable=inconsistent-return-statements - self, - tag_name: str, - tag_value: str, - **kwargs: Any + self, tag_name: str, tag_value: str, **kwargs: Any ) -> None: """Deletes a predefined tag value for a predefined tag name. @@ -10293,39 +11849,45 @@ def delete_value( # pylint: disable=inconsistent-return-statements predefined tag name. The value being deleted must not be in use as a tag value for the given tag name for any resource. - :param tag_name: The name of the tag. + :param tag_name: The name of the tag. Required. :type tag_name: str - :param tag_value: The value of the tag to delete. + :param tag_value: The value of the tag to delete. Required. :type tag_value: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: None, or the result of cls(response) + :return: None or the result of cls(response) :rtype: None - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType[None] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) - api_version = kwargs.pop('api_version', "2021-04-01") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-04-01")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[None] - request = build_tags_delete_value_request( tag_name=tag_name, tag_value=tag_value, subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.delete_value.metadata['url'], + template_url=self.delete_value.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200, 204]: @@ -10335,54 +11897,54 @@ def delete_value( # pylint: disable=inconsistent-return-statements if cls: return cls(pipeline_response, None, {}) - delete_value.metadata = {'url': "/subscriptions/{subscriptionId}/tagNames/{tagName}/tagValues/{tagValue}"} # type: ignore - + delete_value.metadata = {"url": "/subscriptions/{subscriptionId}/tagNames/{tagName}/tagValues/{tagValue}"} # type: ignore @distributed_trace - def create_or_update_value( - self, - tag_name: str, - tag_value: str, - **kwargs: Any - ) -> "_models.TagValue": + def create_or_update_value(self, tag_name: str, tag_value: str, **kwargs: Any) -> _models.TagValue: """Creates a predefined value for a predefined tag name. This operation allows adding a value to the list of predefined values for an existing predefined tag name. A tag value can have a maximum of 256 characters. - :param tag_name: The name of the tag. + :param tag_name: The name of the tag. Required. :type tag_name: str - :param tag_value: The value of the tag to create. + :param tag_value: The value of the tag to create. Required. :type tag_value: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: TagValue, or the result of cls(response) + :return: TagValue or the result of cls(response) :rtype: ~azure.mgmt.resource.resources.v2021_04_01.models.TagValue - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.TagValue"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + 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', "2021-04-01") # type: str + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-04-01")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[_models.TagValue] - request = build_tags_create_or_update_value_request( tag_name=tag_name, tag_value=tag_value, subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.create_or_update_value.metadata['url'], + template_url=self.create_or_update_value.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200, 201]: @@ -10390,25 +11952,20 @@ def create_or_update_value( raise HttpResponseError(response=response, error_format=ARMErrorFormat) if response.status_code == 200: - deserialized = self._deserialize('TagValue', pipeline_response) + deserialized = self._deserialize("TagValue", pipeline_response) if response.status_code == 201: - deserialized = self._deserialize('TagValue', pipeline_response) + deserialized = self._deserialize("TagValue", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - create_or_update_value.metadata = {'url': "/subscriptions/{subscriptionId}/tagNames/{tagName}/tagValues/{tagValue}"} # type: ignore - + create_or_update_value.metadata = {"url": "/subscriptions/{subscriptionId}/tagNames/{tagName}/tagValues/{tagValue}"} # type: ignore @distributed_trace - def create_or_update( - self, - tag_name: str, - **kwargs: Any - ) -> "_models.TagDetails": + def create_or_update(self, tag_name: str, **kwargs: Any) -> _models.TagDetails: """Creates a predefined tag name. This operation allows adding a name to the list of predefined tag names for the given @@ -10416,36 +11973,42 @@ def create_or_update( names cannot have the following prefixes which are reserved for Azure use: 'microsoft', 'azure', 'windows'. - :param tag_name: The name of the tag to create. + :param tag_name: The name of the tag to create. Required. :type tag_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: TagDetails, or the result of cls(response) + :return: TagDetails or the result of cls(response) :rtype: ~azure.mgmt.resource.resources.v2021_04_01.models.TagDetails - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.TagDetails"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + 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', "2021-04-01") # type: str + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-04-01")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[_models.TagDetails] - request = build_tags_create_or_update_request( tag_name=tag_name, subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.create_or_update.metadata['url'], + template_url=self.create_or_update.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200, 201]: @@ -10453,61 +12016,62 @@ def create_or_update( raise HttpResponseError(response=response, error_format=ARMErrorFormat) if response.status_code == 200: - deserialized = self._deserialize('TagDetails', pipeline_response) + deserialized = self._deserialize("TagDetails", pipeline_response) if response.status_code == 201: - deserialized = self._deserialize('TagDetails', pipeline_response) + deserialized = self._deserialize("TagDetails", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - create_or_update.metadata = {'url': "/subscriptions/{subscriptionId}/tagNames/{tagName}"} # type: ignore - + create_or_update.metadata = {"url": "/subscriptions/{subscriptionId}/tagNames/{tagName}"} # type: ignore @distributed_trace - def delete( # pylint: disable=inconsistent-return-statements - self, - tag_name: str, - **kwargs: Any - ) -> None: + def delete(self, tag_name: str, **kwargs: Any) -> None: # pylint: disable=inconsistent-return-statements """Deletes a predefined tag name. This operation allows deleting a name from the list of predefined tag names for the given subscription. The name being deleted must not be in use as a tag name for any resource. All predefined values for the given name must have already been deleted. - :param tag_name: The name of the tag. + :param tag_name: The name of the tag. Required. :type tag_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: None, or the result of cls(response) + :return: None or the result of cls(response) :rtype: None - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType[None] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + 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', "2021-04-01") # type: str + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-04-01")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[None] - request = build_tags_delete_request( tag_name=tag_name, subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.delete.metadata['url'], + template_url=self.delete.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200, 204]: @@ -10517,14 +12081,10 @@ def delete( # pylint: disable=inconsistent-return-statements if cls: return cls(pipeline_response, None, {}) - delete.metadata = {'url': "/subscriptions/{subscriptionId}/tagNames/{tagName}"} # type: ignore - + delete.metadata = {"url": "/subscriptions/{subscriptionId}/tagNames/{tagName}"} # type: ignore @distributed_trace - def list( - self, - **kwargs: Any - ) -> Iterable["_models.TagsListResult"]: + def list(self, **kwargs: Any) -> Iterable["_models.TagDetails"]: """Gets a summary of tag usage under the subscription. This operation performs a union of predefined tags, resource tags, resource group tags and @@ -10533,37 +12093,46 @@ def list( result. :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either TagsListResult or the result of cls(response) + :return: An iterator like instance of either TagDetails or the result of cls(response) :rtype: - ~azure.core.paging.ItemPaged[~azure.mgmt.resource.resources.v2021_04_01.models.TagsListResult] - :raises: ~azure.core.exceptions.HttpResponseError + ~azure.core.paging.ItemPaged[~azure.mgmt.resource.resources.v2021_04_01.models.TagDetails] + :raises ~azure.core.exceptions.HttpResponseError: """ - api_version = kwargs.pop('api_version', "2021-04-01") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-04-01")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[_models.TagsListResult] - cls = kwargs.pop('cls', None) # type: ClsType["_models.TagsListResult"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) + def prepare_request(next_link=None): if not next_link: - + request = build_tags_list_request( subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.list.metadata['url'], + template_url=self.list.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore else: - - request = build_tags_list_request( - subscription_id=self._config.subscription_id, - template_url=next_link, - ) + # make call to next link with the client's api-version + _parsed_next_link = urlparse(next_link) + _next_request_params = case_insensitive_dict(parse_qs(_parsed_next_link.query)) + _next_request_params["api-version"] = self._config.api_version + request = HttpRequest("GET", urljoin(next_link, _parsed_next_link.path), params=_next_request_params) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore request.method = "GET" return request @@ -10577,10 +12146,8 @@ def extract_data(pipeline_response): def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) response = pipeline_response.http_response @@ -10590,82 +12157,139 @@ def get_next(next_link=None): return pipeline_response + return ItemPaged(get_next, extract_data) - return ItemPaged( - get_next, extract_data - ) - list.metadata = {'url': "/subscriptions/{subscriptionId}/tagNames"} # type: ignore + list.metadata = {"url": "/subscriptions/{subscriptionId}/tagNames"} # type: ignore - @distributed_trace + @overload def create_or_update_at_scope( - self, - scope: str, - parameters: "_models.TagsResource", - **kwargs: Any - ) -> "_models.TagsResource": + self, scope: str, parameters: _models.TagsResource, *, content_type: str = "application/json", **kwargs: Any + ) -> _models.TagsResource: """Creates or updates the entire set of tags on a resource or subscription. This operation allows adding or replacing the entire set of tags on the specified resource or subscription. The specified entity can have a maximum of 50 tags. - :param scope: The resource scope. + :param scope: The resource scope. Required. :type scope: str - :param parameters: + :param parameters: Required. :type parameters: ~azure.mgmt.resource.resources.v2021_04_01.models.TagsResource + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: TagsResource or the result of cls(response) + :rtype: ~azure.mgmt.resource.resources.v2021_04_01.models.TagsResource + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + def create_or_update_at_scope( + self, scope: str, parameters: IO, *, content_type: str = "application/json", **kwargs: Any + ) -> _models.TagsResource: + """Creates or updates the entire set of tags on a resource or subscription. + + This operation allows adding or replacing the entire set of tags on the specified resource or + subscription. The specified entity can have a maximum of 50 tags. + + :param scope: The resource scope. Required. + :type scope: str + :param parameters: Required. + :type parameters: IO + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: TagsResource or the result of cls(response) + :rtype: ~azure.mgmt.resource.resources.v2021_04_01.models.TagsResource + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace + def create_or_update_at_scope( + self, scope: str, parameters: Union[_models.TagsResource, IO], **kwargs: Any + ) -> _models.TagsResource: + """Creates or updates the entire set of tags on a resource or subscription. + + This operation allows adding or replacing the entire set of tags on the specified resource or + subscription. The specified entity can have a maximum of 50 tags. + + :param scope: The resource scope. Required. + :type scope: str + :param parameters: Is either a model type or a IO type. Required. + :type parameters: ~azure.mgmt.resource.resources.v2021_04_01.models.TagsResource or IO + :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. + Default value is None. + :paramtype content_type: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: TagsResource, or the result of cls(response) + :return: TagsResource or the result of cls(response) :rtype: ~azure.mgmt.resource.resources.v2021_04_01.models.TagsResource - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.TagsResource"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', "2021-04-01") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-04-01")) # type: str + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.TagsResource] - _json = self._serialize.body(parameters, 'TagsResource') + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(parameters, (IO, bytes)): + _content = parameters + else: + _json = self._serialize.body(parameters, "TagsResource") request = build_tags_create_or_update_at_scope_request( scope=scope, api_version=api_version, content_type=content_type, json=_json, - template_url=self.create_or_update_at_scope.metadata['url'], + content=_content, + template_url=self.create_or_update_at_scope.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) - deserialized = self._deserialize('TagsResource', pipeline_response) + deserialized = self._deserialize("TagsResource", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - create_or_update_at_scope.metadata = {'url': "/{scope}/providers/Microsoft.Resources/tags/default"} # type: ignore + create_or_update_at_scope.metadata = {"url": "/{scope}/providers/Microsoft.Resources/tags/default"} # type: ignore - - @distributed_trace + @overload def update_at_scope( self, scope: str, - parameters: "_models.TagsPatchResource", + parameters: _models.TagsPatchResource, + *, + content_type: str = "application/json", **kwargs: Any - ) -> "_models.TagsResource": + ) -> _models.TagsResource: """Selectively updates the set of tags on a resource or subscription. This operation allows replacing, merging or selectively deleting tags on the specified resource @@ -10675,151 +12299,222 @@ def update_at_scope( names. The 'delete' option allows selectively deleting tags based on given names or name/value pairs. - :param scope: The resource scope. + :param scope: The resource scope. Required. :type scope: str - :param parameters: + :param parameters: Required. :type parameters: ~azure.mgmt.resource.resources.v2021_04_01.models.TagsPatchResource + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: TagsResource or the result of cls(response) + :rtype: ~azure.mgmt.resource.resources.v2021_04_01.models.TagsResource + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + def update_at_scope( + self, scope: str, parameters: IO, *, content_type: str = "application/json", **kwargs: Any + ) -> _models.TagsResource: + """Selectively updates the set of tags on a resource or subscription. + + This operation allows replacing, merging or selectively deleting tags on the specified resource + or subscription. The specified entity can have a maximum of 50 tags at the end of the + operation. The 'replace' option replaces the entire set of existing tags with a new set. The + 'merge' option allows adding tags with new names and updating the values of tags with existing + names. The 'delete' option allows selectively deleting tags based on given names or name/value + pairs. + + :param scope: The resource scope. Required. + :type scope: str + :param parameters: Required. + :type parameters: IO + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: TagsResource or the result of cls(response) + :rtype: ~azure.mgmt.resource.resources.v2021_04_01.models.TagsResource + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace + def update_at_scope( + self, scope: str, parameters: Union[_models.TagsPatchResource, IO], **kwargs: Any + ) -> _models.TagsResource: + """Selectively updates the set of tags on a resource or subscription. + + This operation allows replacing, merging or selectively deleting tags on the specified resource + or subscription. The specified entity can have a maximum of 50 tags at the end of the + operation. The 'replace' option replaces the entire set of existing tags with a new set. The + 'merge' option allows adding tags with new names and updating the values of tags with existing + names. The 'delete' option allows selectively deleting tags based on given names or name/value + pairs. + + :param scope: The resource scope. Required. + :type scope: str + :param parameters: Is either a model type or a IO type. Required. + :type parameters: ~azure.mgmt.resource.resources.v2021_04_01.models.TagsPatchResource or IO + :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. + Default value is None. + :paramtype content_type: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: TagsResource, or the result of cls(response) + :return: TagsResource or the result of cls(response) :rtype: ~azure.mgmt.resource.resources.v2021_04_01.models.TagsResource - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.TagsResource"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) - api_version = kwargs.pop('api_version', "2021-04-01") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - _json = self._serialize.body(parameters, 'TagsPatchResource') + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-04-01")) # type: str + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.TagsResource] + + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(parameters, (IO, bytes)): + _content = parameters + else: + _json = self._serialize.body(parameters, "TagsPatchResource") request = build_tags_update_at_scope_request( scope=scope, api_version=api_version, content_type=content_type, json=_json, - template_url=self.update_at_scope.metadata['url'], + content=_content, + template_url=self.update_at_scope.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) - deserialized = self._deserialize('TagsResource', pipeline_response) + deserialized = self._deserialize("TagsResource", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - update_at_scope.metadata = {'url': "/{scope}/providers/Microsoft.Resources/tags/default"} # type: ignore - + update_at_scope.metadata = {"url": "/{scope}/providers/Microsoft.Resources/tags/default"} # type: ignore @distributed_trace - def get_at_scope( - self, - scope: str, - **kwargs: Any - ) -> "_models.TagsResource": + def get_at_scope(self, scope: str, **kwargs: Any) -> _models.TagsResource: """Gets the entire set of tags on a resource or subscription. Gets the entire set of tags on a resource or subscription. - :param scope: The resource scope. + :param scope: The resource scope. Required. :type scope: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: TagsResource, or the result of cls(response) + :return: TagsResource or the result of cls(response) :rtype: ~azure.mgmt.resource.resources.v2021_04_01.models.TagsResource - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.TagsResource"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) - api_version = kwargs.pop('api_version', "2021-04-01") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-04-01")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[_models.TagsResource] - request = build_tags_get_at_scope_request( scope=scope, api_version=api_version, - template_url=self.get_at_scope.metadata['url'], + template_url=self.get_at_scope.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) - deserialized = self._deserialize('TagsResource', pipeline_response) + deserialized = self._deserialize("TagsResource", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - get_at_scope.metadata = {'url': "/{scope}/providers/Microsoft.Resources/tags/default"} # type: ignore - + get_at_scope.metadata = {"url": "/{scope}/providers/Microsoft.Resources/tags/default"} # type: ignore @distributed_trace - def delete_at_scope( # pylint: disable=inconsistent-return-statements - self, - scope: str, - **kwargs: Any - ) -> None: + def delete_at_scope(self, scope: str, **kwargs: Any) -> None: # pylint: disable=inconsistent-return-statements """Deletes the entire set of tags on a resource or subscription. Deletes the entire set of tags on a resource or subscription. - :param scope: The resource scope. + :param scope: The resource scope. Required. :type scope: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: None, or the result of cls(response) + :return: None or the result of cls(response) :rtype: None - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType[None] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + 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', "2021-04-01") # type: str + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-04-01")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[None] - request = build_tags_delete_at_scope_request( scope=scope, api_version=api_version, - template_url=self.delete_at_scope.metadata['url'], + template_url=self.delete_at_scope.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200]: @@ -10829,143 +12524,145 @@ def delete_at_scope( # pylint: disable=inconsistent-return-statements if cls: return cls(pipeline_response, None, {}) - delete_at_scope.metadata = {'url': "/{scope}/providers/Microsoft.Resources/tags/default"} # type: ignore + delete_at_scope.metadata = {"url": "/{scope}/providers/Microsoft.Resources/tags/default"} # type: ignore -class DeploymentOperationsOperations(object): - """DeploymentOperationsOperations operations. - You should not instantiate this class directly. Instead, you should create a Client instance that - instantiates it for you and attaches it as an attribute. +class DeploymentOperationsOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. - :ivar models: Alias to model classes used in this operation group. - :type models: ~azure.mgmt.resource.resources.v2021_04_01.models - :param client: Client for service requests. - :param config: Configuration of service client. - :param serializer: An object model serializer. - :param deserializer: An object model deserializer. + Instead, you should access the following operations through + :class:`~azure.mgmt.resource.resources.v2021_04_01.ResourceManagementClient`'s + :attr:`deployment_operations` attribute. """ models = _models - def __init__(self, client, config, serializer, deserializer): - self._client = client - self._serialize = serializer - self._deserialize = deserializer - self._config = config + def __init__(self, *args, **kwargs): + input_args = list(args) + self._client = input_args.pop(0) if input_args else kwargs.pop("client") + self._config = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") @distributed_trace def get_at_scope( - self, - scope: str, - deployment_name: str, - operation_id: str, - **kwargs: Any - ) -> "_models.DeploymentOperation": + self, scope: str, deployment_name: str, operation_id: str, **kwargs: Any + ) -> _models.DeploymentOperation: """Gets a deployments operation. - :param scope: The resource scope. + :param scope: The resource scope. Required. :type scope: str - :param deployment_name: The name of the deployment. + :param deployment_name: The name of the deployment. Required. :type deployment_name: str - :param operation_id: The ID of the operation to get. + :param operation_id: The ID of the operation to get. Required. :type operation_id: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: DeploymentOperation, or the result of cls(response) + :return: DeploymentOperation or the result of cls(response) :rtype: ~azure.mgmt.resource.resources.v2021_04_01.models.DeploymentOperation - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.DeploymentOperation"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) - api_version = kwargs.pop('api_version', "2021-04-01") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-04-01")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[_models.DeploymentOperation] - request = build_deployment_operations_get_at_scope_request( scope=scope, deployment_name=deployment_name, operation_id=operation_id, api_version=api_version, - template_url=self.get_at_scope.metadata['url'], + template_url=self.get_at_scope.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) - deserialized = self._deserialize('DeploymentOperation', pipeline_response) + deserialized = self._deserialize("DeploymentOperation", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - get_at_scope.metadata = {'url': "/{scope}/providers/Microsoft.Resources/deployments/{deploymentName}/operations/{operationId}"} # type: ignore - + get_at_scope.metadata = {"url": "/{scope}/providers/Microsoft.Resources/deployments/{deploymentName}/operations/{operationId}"} # type: ignore @distributed_trace def list_at_scope( - self, - scope: str, - deployment_name: str, - top: Optional[int] = None, - **kwargs: Any - ) -> Iterable["_models.DeploymentOperationsListResult"]: + self, scope: str, deployment_name: str, top: Optional[int] = None, **kwargs: Any + ) -> Iterable["_models.DeploymentOperation"]: """Gets all deployments operations for a deployment. - :param scope: The resource scope. + :param scope: The resource scope. Required. :type scope: str - :param deployment_name: The name of the deployment. + :param deployment_name: The name of the deployment. Required. :type deployment_name: str :param top: The number of results to return. Default value is None. :type top: int :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either DeploymentOperationsListResult or the result of - cls(response) + :return: An iterator like instance of either DeploymentOperation or the result of cls(response) :rtype: - ~azure.core.paging.ItemPaged[~azure.mgmt.resource.resources.v2021_04_01.models.DeploymentOperationsListResult] - :raises: ~azure.core.exceptions.HttpResponseError + ~azure.core.paging.ItemPaged[~azure.mgmt.resource.resources.v2021_04_01.models.DeploymentOperation] + :raises ~azure.core.exceptions.HttpResponseError: """ - api_version = kwargs.pop('api_version', "2021-04-01") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-04-01")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[_models.DeploymentOperationsListResult] - cls = kwargs.pop('cls', None) # type: ClsType["_models.DeploymentOperationsListResult"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) + def prepare_request(next_link=None): if not next_link: - + request = build_deployment_operations_list_at_scope_request( scope=scope, deployment_name=deployment_name, - api_version=api_version, top=top, - template_url=self.list_at_scope.metadata['url'], + api_version=api_version, + template_url=self.list_at_scope.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore else: - - request = build_deployment_operations_list_at_scope_request( - scope=scope, - deployment_name=deployment_name, - template_url=next_link, - ) + # make call to next link with the client's api-version + _parsed_next_link = urlparse(next_link) + _next_request_params = case_insensitive_dict(parse_qs(_parsed_next_link.query)) + _next_request_params["api-version"] = self._config.api_version + request = HttpRequest("GET", urljoin(next_link, _parsed_next_link.path), params=_next_request_params) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore request.method = "GET" return request @@ -10979,10 +12676,8 @@ def extract_data(pipeline_response): def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) response = pipeline_response.http_response @@ -10992,116 +12687,121 @@ def get_next(next_link=None): return pipeline_response + return ItemPaged(get_next, extract_data) - return ItemPaged( - get_next, extract_data - ) - list_at_scope.metadata = {'url': "/{scope}/providers/Microsoft.Resources/deployments/{deploymentName}/operations"} # type: ignore + list_at_scope.metadata = {"url": "/{scope}/providers/Microsoft.Resources/deployments/{deploymentName}/operations"} # type: ignore @distributed_trace def get_at_tenant_scope( - self, - deployment_name: str, - operation_id: str, - **kwargs: Any - ) -> "_models.DeploymentOperation": + self, deployment_name: str, operation_id: str, **kwargs: Any + ) -> _models.DeploymentOperation: """Gets a deployments operation. - :param deployment_name: The name of the deployment. + :param deployment_name: The name of the deployment. Required. :type deployment_name: str - :param operation_id: The ID of the operation to get. + :param operation_id: The ID of the operation to get. Required. :type operation_id: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: DeploymentOperation, or the result of cls(response) + :return: DeploymentOperation or the result of cls(response) :rtype: ~azure.mgmt.resource.resources.v2021_04_01.models.DeploymentOperation - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.DeploymentOperation"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + 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', "2021-04-01") # type: str + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-04-01")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[_models.DeploymentOperation] - request = build_deployment_operations_get_at_tenant_scope_request( deployment_name=deployment_name, operation_id=operation_id, api_version=api_version, - template_url=self.get_at_tenant_scope.metadata['url'], + template_url=self.get_at_tenant_scope.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) - deserialized = self._deserialize('DeploymentOperation', pipeline_response) + deserialized = self._deserialize("DeploymentOperation", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - get_at_tenant_scope.metadata = {'url': "/providers/Microsoft.Resources/deployments/{deploymentName}/operations/{operationId}"} # type: ignore - + get_at_tenant_scope.metadata = {"url": "/providers/Microsoft.Resources/deployments/{deploymentName}/operations/{operationId}"} # type: ignore @distributed_trace def list_at_tenant_scope( - self, - deployment_name: str, - top: Optional[int] = None, - **kwargs: Any - ) -> Iterable["_models.DeploymentOperationsListResult"]: + self, deployment_name: str, top: Optional[int] = None, **kwargs: Any + ) -> Iterable["_models.DeploymentOperation"]: """Gets all deployments operations for a deployment. - :param deployment_name: The name of the deployment. + :param deployment_name: The name of the deployment. Required. :type deployment_name: str :param top: The number of results to return. Default value is None. :type top: int :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either DeploymentOperationsListResult or the result of - cls(response) + :return: An iterator like instance of either DeploymentOperation or the result of cls(response) :rtype: - ~azure.core.paging.ItemPaged[~azure.mgmt.resource.resources.v2021_04_01.models.DeploymentOperationsListResult] - :raises: ~azure.core.exceptions.HttpResponseError + ~azure.core.paging.ItemPaged[~azure.mgmt.resource.resources.v2021_04_01.models.DeploymentOperation] + :raises ~azure.core.exceptions.HttpResponseError: """ - api_version = kwargs.pop('api_version', "2021-04-01") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-04-01")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[_models.DeploymentOperationsListResult] - cls = kwargs.pop('cls', None) # type: ClsType["_models.DeploymentOperationsListResult"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) + def prepare_request(next_link=None): if not next_link: - + request = build_deployment_operations_list_at_tenant_scope_request( deployment_name=deployment_name, - api_version=api_version, top=top, - template_url=self.list_at_tenant_scope.metadata['url'], + api_version=api_version, + template_url=self.list_at_tenant_scope.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore else: - - request = build_deployment_operations_list_at_tenant_scope_request( - deployment_name=deployment_name, - template_url=next_link, - ) + # make call to next link with the client's api-version + _parsed_next_link = urlparse(next_link) + _next_request_params = case_insensitive_dict(parse_qs(_parsed_next_link.query)) + _next_request_params["api-version"] = self._config.api_version + request = HttpRequest("GET", urljoin(next_link, _parsed_next_link.path), params=_next_request_params) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore request.method = "GET" return request @@ -11115,10 +12815,8 @@ def extract_data(pipeline_response): def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) response = pipeline_response.http_response @@ -11128,125 +12826,127 @@ def get_next(next_link=None): return pipeline_response + return ItemPaged(get_next, extract_data) - return ItemPaged( - get_next, extract_data - ) - list_at_tenant_scope.metadata = {'url': "/providers/Microsoft.Resources/deployments/{deploymentName}/operations"} # type: ignore + list_at_tenant_scope.metadata = {"url": "/providers/Microsoft.Resources/deployments/{deploymentName}/operations"} # type: ignore @distributed_trace def get_at_management_group_scope( - self, - group_id: str, - deployment_name: str, - operation_id: str, - **kwargs: Any - ) -> "_models.DeploymentOperation": + self, group_id: str, deployment_name: str, operation_id: str, **kwargs: Any + ) -> _models.DeploymentOperation: """Gets a deployments operation. - :param group_id: The management group ID. + :param group_id: The management group ID. Required. :type group_id: str - :param deployment_name: The name of the deployment. + :param deployment_name: The name of the deployment. Required. :type deployment_name: str - :param operation_id: The ID of the operation to get. + :param operation_id: The ID of the operation to get. Required. :type operation_id: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: DeploymentOperation, or the result of cls(response) + :return: DeploymentOperation or the result of cls(response) :rtype: ~azure.mgmt.resource.resources.v2021_04_01.models.DeploymentOperation - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.DeploymentOperation"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + 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', "2021-04-01") # type: str + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-04-01")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[_models.DeploymentOperation] - request = build_deployment_operations_get_at_management_group_scope_request( group_id=group_id, deployment_name=deployment_name, operation_id=operation_id, api_version=api_version, - template_url=self.get_at_management_group_scope.metadata['url'], + template_url=self.get_at_management_group_scope.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) - deserialized = self._deserialize('DeploymentOperation', pipeline_response) + deserialized = self._deserialize("DeploymentOperation", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - get_at_management_group_scope.metadata = {'url': "/providers/Microsoft.Management/managementGroups/{groupId}/providers/Microsoft.Resources/deployments/{deploymentName}/operations/{operationId}"} # type: ignore - + get_at_management_group_scope.metadata = {"url": "/providers/Microsoft.Management/managementGroups/{groupId}/providers/Microsoft.Resources/deployments/{deploymentName}/operations/{operationId}"} # type: ignore @distributed_trace def list_at_management_group_scope( - self, - group_id: str, - deployment_name: str, - top: Optional[int] = None, - **kwargs: Any - ) -> Iterable["_models.DeploymentOperationsListResult"]: + self, group_id: str, deployment_name: str, top: Optional[int] = None, **kwargs: Any + ) -> Iterable["_models.DeploymentOperation"]: """Gets all deployments operations for a deployment. - :param group_id: The management group ID. + :param group_id: The management group ID. Required. :type group_id: str - :param deployment_name: The name of the deployment. + :param deployment_name: The name of the deployment. Required. :type deployment_name: str :param top: The number of results to return. Default value is None. :type top: int :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either DeploymentOperationsListResult or the result of - cls(response) + :return: An iterator like instance of either DeploymentOperation or the result of cls(response) :rtype: - ~azure.core.paging.ItemPaged[~azure.mgmt.resource.resources.v2021_04_01.models.DeploymentOperationsListResult] - :raises: ~azure.core.exceptions.HttpResponseError + ~azure.core.paging.ItemPaged[~azure.mgmt.resource.resources.v2021_04_01.models.DeploymentOperation] + :raises ~azure.core.exceptions.HttpResponseError: """ - api_version = kwargs.pop('api_version', "2021-04-01") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-04-01")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[_models.DeploymentOperationsListResult] - cls = kwargs.pop('cls', None) # type: ClsType["_models.DeploymentOperationsListResult"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) + def prepare_request(next_link=None): if not next_link: - + request = build_deployment_operations_list_at_management_group_scope_request( group_id=group_id, deployment_name=deployment_name, - api_version=api_version, top=top, - template_url=self.list_at_management_group_scope.metadata['url'], + api_version=api_version, + template_url=self.list_at_management_group_scope.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore else: - - request = build_deployment_operations_list_at_management_group_scope_request( - group_id=group_id, - deployment_name=deployment_name, - template_url=next_link, - ) + # make call to next link with the client's api-version + _parsed_next_link = urlparse(next_link) + _next_request_params = case_insensitive_dict(parse_qs(_parsed_next_link.query)) + _next_request_params["api-version"] = self._config.api_version + request = HttpRequest("GET", urljoin(next_link, _parsed_next_link.path), params=_next_request_params) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore request.method = "GET" return request @@ -11260,10 +12960,8 @@ def extract_data(pipeline_response): def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) response = pipeline_response.http_response @@ -11273,119 +12971,123 @@ def get_next(next_link=None): return pipeline_response + return ItemPaged(get_next, extract_data) - return ItemPaged( - get_next, extract_data - ) - list_at_management_group_scope.metadata = {'url': "/providers/Microsoft.Management/managementGroups/{groupId}/providers/Microsoft.Resources/deployments/{deploymentName}/operations"} # type: ignore + list_at_management_group_scope.metadata = {"url": "/providers/Microsoft.Management/managementGroups/{groupId}/providers/Microsoft.Resources/deployments/{deploymentName}/operations"} # type: ignore @distributed_trace def get_at_subscription_scope( - self, - deployment_name: str, - operation_id: str, - **kwargs: Any - ) -> "_models.DeploymentOperation": + self, deployment_name: str, operation_id: str, **kwargs: Any + ) -> _models.DeploymentOperation: """Gets a deployments operation. - :param deployment_name: The name of the deployment. + :param deployment_name: The name of the deployment. Required. :type deployment_name: str - :param operation_id: The ID of the operation to get. + :param operation_id: The ID of the operation to get. Required. :type operation_id: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: DeploymentOperation, or the result of cls(response) + :return: DeploymentOperation or the result of cls(response) :rtype: ~azure.mgmt.resource.resources.v2021_04_01.models.DeploymentOperation - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.DeploymentOperation"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) - api_version = kwargs.pop('api_version', "2021-04-01") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-04-01")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[_models.DeploymentOperation] - request = build_deployment_operations_get_at_subscription_scope_request( deployment_name=deployment_name, operation_id=operation_id, subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.get_at_subscription_scope.metadata['url'], + template_url=self.get_at_subscription_scope.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) - deserialized = self._deserialize('DeploymentOperation', pipeline_response) + deserialized = self._deserialize("DeploymentOperation", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - get_at_subscription_scope.metadata = {'url': "/subscriptions/{subscriptionId}/providers/Microsoft.Resources/deployments/{deploymentName}/operations/{operationId}"} # type: ignore - + get_at_subscription_scope.metadata = {"url": "/subscriptions/{subscriptionId}/providers/Microsoft.Resources/deployments/{deploymentName}/operations/{operationId}"} # type: ignore @distributed_trace def list_at_subscription_scope( - self, - deployment_name: str, - top: Optional[int] = None, - **kwargs: Any - ) -> Iterable["_models.DeploymentOperationsListResult"]: + self, deployment_name: str, top: Optional[int] = None, **kwargs: Any + ) -> Iterable["_models.DeploymentOperation"]: """Gets all deployments operations for a deployment. - :param deployment_name: The name of the deployment. + :param deployment_name: The name of the deployment. Required. :type deployment_name: str :param top: The number of results to return. Default value is None. :type top: int :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either DeploymentOperationsListResult or the result of - cls(response) + :return: An iterator like instance of either DeploymentOperation or the result of cls(response) :rtype: - ~azure.core.paging.ItemPaged[~azure.mgmt.resource.resources.v2021_04_01.models.DeploymentOperationsListResult] - :raises: ~azure.core.exceptions.HttpResponseError + ~azure.core.paging.ItemPaged[~azure.mgmt.resource.resources.v2021_04_01.models.DeploymentOperation] + :raises ~azure.core.exceptions.HttpResponseError: """ - api_version = kwargs.pop('api_version', "2021-04-01") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-04-01")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[_models.DeploymentOperationsListResult] - cls = kwargs.pop('cls', None) # type: ClsType["_models.DeploymentOperationsListResult"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) + def prepare_request(next_link=None): if not next_link: - + request = build_deployment_operations_list_at_subscription_scope_request( deployment_name=deployment_name, subscription_id=self._config.subscription_id, - api_version=api_version, top=top, - template_url=self.list_at_subscription_scope.metadata['url'], + api_version=api_version, + template_url=self.list_at_subscription_scope.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore else: - - request = build_deployment_operations_list_at_subscription_scope_request( - deployment_name=deployment_name, - subscription_id=self._config.subscription_id, - template_url=next_link, - ) + # make call to next link with the client's api-version + _parsed_next_link = urlparse(next_link) + _next_request_params = case_insensitive_dict(parse_qs(_parsed_next_link.query)) + _next_request_params["api-version"] = self._config.api_version + request = HttpRequest("GET", urljoin(next_link, _parsed_next_link.path), params=_next_request_params) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore request.method = "GET" return request @@ -11399,10 +13101,8 @@ def extract_data(pipeline_response): def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) response = pipeline_response.http_response @@ -11412,128 +13112,131 @@ def get_next(next_link=None): return pipeline_response + return ItemPaged(get_next, extract_data) - return ItemPaged( - get_next, extract_data - ) - list_at_subscription_scope.metadata = {'url': "/subscriptions/{subscriptionId}/providers/Microsoft.Resources/deployments/{deploymentName}/operations"} # type: ignore + list_at_subscription_scope.metadata = {"url": "/subscriptions/{subscriptionId}/providers/Microsoft.Resources/deployments/{deploymentName}/operations"} # type: ignore @distributed_trace def get( - self, - resource_group_name: str, - deployment_name: str, - operation_id: str, - **kwargs: Any - ) -> "_models.DeploymentOperation": + self, resource_group_name: str, deployment_name: str, operation_id: str, **kwargs: Any + ) -> _models.DeploymentOperation: """Gets a deployments operation. :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. :type resource_group_name: str - :param deployment_name: The name of the deployment. + :param deployment_name: The name of the deployment. Required. :type deployment_name: str - :param operation_id: The ID of the operation to get. + :param operation_id: The ID of the operation to get. Required. :type operation_id: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: DeploymentOperation, or the result of cls(response) + :return: DeploymentOperation or the result of cls(response) :rtype: ~azure.mgmt.resource.resources.v2021_04_01.models.DeploymentOperation - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.DeploymentOperation"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + 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', "2021-04-01") # type: str + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-04-01")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[_models.DeploymentOperation] - request = build_deployment_operations_get_request( resource_group_name=resource_group_name, deployment_name=deployment_name, operation_id=operation_id, subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.get.metadata['url'], + template_url=self.get.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) - deserialized = self._deserialize('DeploymentOperation', pipeline_response) + deserialized = self._deserialize("DeploymentOperation", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - get.metadata = {'url': "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/deployments/{deploymentName}/operations/{operationId}"} # type: ignore - + get.metadata = {"url": "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/deployments/{deploymentName}/operations/{operationId}"} # type: ignore @distributed_trace def list( - self, - resource_group_name: str, - deployment_name: str, - top: Optional[int] = None, - **kwargs: Any - ) -> Iterable["_models.DeploymentOperationsListResult"]: + self, resource_group_name: str, deployment_name: str, top: Optional[int] = None, **kwargs: Any + ) -> Iterable["_models.DeploymentOperation"]: """Gets all deployments operations for a deployment. :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. :type resource_group_name: str - :param deployment_name: The name of the deployment. + :param deployment_name: The name of the deployment. Required. :type deployment_name: str :param top: The number of results to return. Default value is None. :type top: int :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either DeploymentOperationsListResult or the result of - cls(response) + :return: An iterator like instance of either DeploymentOperation or the result of cls(response) :rtype: - ~azure.core.paging.ItemPaged[~azure.mgmt.resource.resources.v2021_04_01.models.DeploymentOperationsListResult] - :raises: ~azure.core.exceptions.HttpResponseError + ~azure.core.paging.ItemPaged[~azure.mgmt.resource.resources.v2021_04_01.models.DeploymentOperation] + :raises ~azure.core.exceptions.HttpResponseError: """ - api_version = kwargs.pop('api_version', "2021-04-01") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-04-01")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[_models.DeploymentOperationsListResult] - cls = kwargs.pop('cls', None) # type: ClsType["_models.DeploymentOperationsListResult"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) + def prepare_request(next_link=None): if not next_link: - + request = build_deployment_operations_list_request( resource_group_name=resource_group_name, deployment_name=deployment_name, subscription_id=self._config.subscription_id, - api_version=api_version, top=top, - template_url=self.list.metadata['url'], + 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.url = self._client.format_url(request.url) # type: ignore else: - - request = build_deployment_operations_list_request( - resource_group_name=resource_group_name, - deployment_name=deployment_name, - subscription_id=self._config.subscription_id, - template_url=next_link, - ) + # make call to next link with the client's api-version + _parsed_next_link = urlparse(next_link) + _next_request_params = case_insensitive_dict(parse_qs(_parsed_next_link.query)) + _next_request_params["api-version"] = self._config.api_version + request = HttpRequest("GET", urljoin(next_link, _parsed_next_link.path), params=_next_request_params) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore request.method = "GET" return request @@ -11547,10 +13250,8 @@ def extract_data(pipeline_response): def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) response = pipeline_response.http_response @@ -11560,8 +13261,6 @@ def get_next(next_link=None): return pipeline_response + return ItemPaged(get_next, extract_data) - return ItemPaged( - get_next, extract_data - ) - list.metadata = {'url': "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/deployments/{deploymentName}/operations"} # type: ignore + list.metadata = {"url": "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/deployments/{deploymentName}/operations"} # type: ignore diff --git a/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/resources/v2021_04_01/operations/_patch.py b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/resources/v2021_04_01/operations/_patch.py new file mode 100644 index 0000000000000..f7dd32510333d --- /dev/null +++ b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/resources/v2021_04_01/operations/_patch.py @@ -0,0 +1,20 @@ +# ------------------------------------ +# Copyright (c) Microsoft Corporation. +# Licensed under the MIT License. +# ------------------------------------ +"""Customize generated code here. + +Follow our quickstart for examples: https://aka.ms/azsdk/python/dpcodegen/python/customize +""" +from typing import List + +__all__: List[str] = [] # Add all objects you want publicly available to users at this package level + + +def patch_sdk(): + """Do not remove from this file. + + `patch_sdk` is a last resort escape hatch that allows you to do customizations + you can't accomplish using the techniques described in + https://aka.ms/azsdk/python/dpcodegen/python/customize + """ diff --git a/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/subscriptions/__init__.py b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/subscriptions/__init__.py index a1d3eed7425fc..b82a521ff5e11 100644 --- a/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/subscriptions/__init__.py +++ b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/subscriptions/__init__.py @@ -14,3 +14,7 @@ patch_sdk() except ImportError: pass + +from ._version import VERSION + +__version__ = VERSION diff --git a/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/subscriptions/_configuration.py b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/subscriptions/_configuration.py index 1b8231b4efc0b..a1b4252dc3933 100644 --- a/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/subscriptions/_configuration.py +++ b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/subscriptions/_configuration.py @@ -8,7 +8,7 @@ # Changes may cause incorrect behavior and will be lost if the code is # regenerated. # -------------------------------------------------------------------------- -from typing import TYPE_CHECKING +from typing import Any, TYPE_CHECKING from azure.core.configuration import Configuration from azure.core.pipeline import policies @@ -18,8 +18,6 @@ if TYPE_CHECKING: # pylint: disable=unused-import,ungrouped-imports - from typing import Any - from azure.core.credentials import TokenCredential class SubscriptionClientConfiguration(Configuration): @@ -28,13 +26,13 @@ class SubscriptionClientConfiguration(Configuration): Note that all parameters used to create this instance are saved as instance attributes. - :param credential: Credential needed for the client to connect to Azure. + :param credential: Credential needed for the client to connect to Azure. Required. :type credential: ~azure.core.credentials.TokenCredential """ def __init__( self, - credential, # type: "TokenCredential" + credential: "TokenCredential", **kwargs # type: Any ): # type: (...) -> None diff --git a/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/subscriptions/_operations_mixin.py b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/subscriptions/_operations_mixin.py index a6064592c49d2..ca8f325f53377 100644 --- a/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/subscriptions/_operations_mixin.py +++ b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/subscriptions/_operations_mixin.py @@ -8,35 +8,35 @@ # Changes may cause incorrect behavior and will be lost if the code is # regenerated. # -------------------------------------------------------------------------- -from msrest import Serializer, Deserializer -from typing import TYPE_CHECKING +from ._serialization import Serializer, Deserializer +from typing import Any, IO, Optional, Union -if TYPE_CHECKING: - # pylint: disable=unused-import,ungrouped-imports - from typing import Any, Optional +from . import models as _models class SubscriptionClientOperationsMixin(object): def check_resource_name( self, - resource_name_definition=None, # type: Optional["_models.ResourceName"] - **kwargs # type: Any - ): - # type: (...) -> "_models.CheckResourceNameResult" + resource_name_definition: Optional[Union[_models.ResourceName, IO]] = None, + **kwargs: Any + ) -> _models.CheckResourceNameResult: """Checks resource name validity. A resource name is valid if it is not a reserved word, does not contains a reserved word and does not start with a reserved word. :param resource_name_definition: Resource object with values for resource name and resource - type. Default value is None. + type. Is either a model type or a IO type. Default value is None. :type resource_name_definition: - ~azure.mgmt.resource.subscriptions.v2021_01_01.models.ResourceName + ~azure.mgmt.resource.subscriptions.v2021_01_01.models.ResourceName or IO + :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. + Default value is None. + :paramtype content_type: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: CheckResourceNameResult, or the result of cls(response) + :return: CheckResourceNameResult or the result of cls(response) :rtype: ~azure.mgmt.resource.subscriptions.v2021_01_01.models.CheckResourceNameResult - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ api_version = self._get_api_version('check_resource_name') if api_version == '2016-06-01': diff --git a/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/subscriptions/_serialization.py b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/subscriptions/_serialization.py new file mode 100644 index 0000000000000..240df16c57f3c --- /dev/null +++ b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/subscriptions/_serialization.py @@ -0,0 +1,2006 @@ +# -------------------------------------------------------------------------- +# +# Copyright (c) Microsoft Corporation. All rights reserved. +# +# The MIT License (MIT) +# +# Permission is hereby granted, free of charge, to any person obtaining a copy +# of this software and associated documentation files (the ""Software""), to +# deal in the Software without restriction, including without limitation the +# rights to use, copy, modify, merge, publish, distribute, sublicense, and/or +# sell copies of the Software, and to permit persons to whom the Software is +# furnished to do so, subject to the following conditions: +# +# The above copyright notice and this permission notice shall be included in +# all copies or substantial portions of the Software. +# +# THE SOFTWARE IS PROVIDED *AS IS*, WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING +# FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS +# IN THE SOFTWARE. +# +# -------------------------------------------------------------------------- + +# pylint: skip-file + +from base64 import b64decode, b64encode +import calendar +import datetime +import decimal +import email +from enum import Enum +import json +import logging +import re +import sys +import codecs +try: + from urllib import quote # type: ignore +except ImportError: + from urllib.parse import quote # type: ignore +import xml.etree.ElementTree as ET + +import isodate + +from typing import Dict, Any, cast, TYPE_CHECKING + +from azure.core.exceptions import DeserializationError, SerializationError, raise_with_traceback + +_BOM = codecs.BOM_UTF8.decode(encoding='utf-8') + +if TYPE_CHECKING: + from typing import Optional, Union, AnyStr, IO, Mapping + +class RawDeserializer: + + # Accept "text" because we're open minded people... + JSON_REGEXP = re.compile(r'^(application|text)/([a-z+.]+\+)?json$') + + # Name used in context + CONTEXT_NAME = "deserialized_data" + + @classmethod + def deserialize_from_text(cls, data, content_type=None): + # type: (Optional[Union[AnyStr, IO]], Optional[str]) -> Any + """Decode data according to content-type. + + Accept a stream of data as well, but will be load at once in memory for now. + + If no content-type, will return the string version (not bytes, not stream) + + :param data: Input, could be bytes or stream (will be decoded with UTF8) or text + :type data: str or bytes or IO + :param str content_type: The content type. + """ + if hasattr(data, 'read'): + # Assume a stream + data = cast(IO, data).read() + + if isinstance(data, bytes): + data_as_str = data.decode(encoding='utf-8-sig') + else: + # Explain to mypy the correct type. + data_as_str = cast(str, data) + + # Remove Byte Order Mark if present in string + data_as_str = data_as_str.lstrip(_BOM) + + if content_type is None: + return data + + if cls.JSON_REGEXP.match(content_type): + try: + return json.loads(data_as_str) + except ValueError as err: + raise DeserializationError("JSON is invalid: {}".format(err), err) + elif "xml" in (content_type or []): + try: + + try: + if isinstance(data, unicode): # type: ignore + # If I'm Python 2.7 and unicode XML will scream if I try a "fromstring" on unicode string + data_as_str = data_as_str.encode(encoding="utf-8") # type: ignore + except NameError: + pass + + return ET.fromstring(data_as_str) # nosec + except ET.ParseError: + # It might be because the server has an issue, and returned JSON with + # content-type XML.... + # So let's try a JSON load, and if it's still broken + # let's flow the initial exception + def _json_attemp(data): + try: + return True, json.loads(data) + except ValueError: + return False, None # Don't care about this one + success, json_result = _json_attemp(data) + if success: + return json_result + # If i'm here, it's not JSON, it's not XML, let's scream + # and raise the last context in this block (the XML exception) + # The function hack is because Py2.7 messes up with exception + # context otherwise. + _LOGGER.critical("Wasn't XML not JSON, failing") + raise_with_traceback(DeserializationError, "XML is invalid") + 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 + """Deserialize from HTTP response. + + Use bytes and headers to NOT use any requests/aiohttp or whatever + specific implementation. + Headers will tested for "content-type" + """ + # Try to use content-type from headers if available + content_type = None + if 'content-type' in headers: + content_type = headers['content-type'].split(";")[0].strip().lower() + # Ouch, this server did not declare what it sent... + # Let's guess it's JSON... + # Also, since Autorest was considering that an empty body was a valid JSON, + # need that test as well.... + else: + content_type = "application/json" + + if body_bytes: + return cls.deserialize_from_text(body_bytes, content_type) + return None + +try: + basestring # type: ignore + unicode_str = unicode # type: ignore +except NameError: + basestring = str # type: ignore + unicode_str = str # type: ignore + +_LOGGER = logging.getLogger(__name__) + +try: + _long_type = long # type: ignore +except NameError: + _long_type = int + +class UTC(datetime.tzinfo): + """Time Zone info for handling UTC""" + + def utcoffset(self, dt): + """UTF offset for UTC is 0.""" + return datetime.timedelta(0) + + def tzname(self, dt): + """Timestamp representation.""" + return "Z" + + def dst(self, dt): + """No daylight saving for UTC.""" + return datetime.timedelta(hours=1) + +try: + from datetime import timezone as _FixedOffset +except ImportError: # Python 2.7 + class _FixedOffset(datetime.tzinfo): # type: ignore + """Fixed offset in minutes east from UTC. + Copy/pasted from Python doc + :param datetime.timedelta offset: offset in timedelta format + """ + + def __init__(self, offset): + self.__offset = offset + + def utcoffset(self, dt): + return self.__offset + + def tzname(self, dt): + return str(self.__offset.total_seconds()/3600) + + def __repr__(self): + return "".format(self.tzname(None)) + + def dst(self, dt): + return datetime.timedelta(0) + + def __getinitargs__(self): + return (self.__offset,) + +try: + from datetime import timezone + TZ_UTC = timezone.utc # type: ignore +except ImportError: + TZ_UTC = UTC() # type: ignore + +_FLATTEN = re.compile(r"(? y, + "minimum": lambda x, y: x < y, + "maximum": lambda x, y: x > y, + "minimum_ex": lambda x, y: x <= y, + "maximum_ex": lambda x, y: x >= y, + "min_items": lambda x, y: len(x) < y, + "max_items": lambda x, y: len(x) > y, + "pattern": lambda x, y: not re.match(y, x, re.UNICODE), + "unique": lambda x, y: len(x) != len(set(x)), + "multiple": lambda x, y: x % y != 0 + } + + def __init__(self, classes=None): + self.serialize_type = { + 'iso-8601': Serializer.serialize_iso, + 'rfc-1123': Serializer.serialize_rfc, + 'unix-time': Serializer.serialize_unix, + 'duration': Serializer.serialize_duration, + 'date': Serializer.serialize_date, + 'time': Serializer.serialize_time, + 'decimal': Serializer.serialize_decimal, + 'long': Serializer.serialize_long, + 'bytearray': Serializer.serialize_bytearray, + 'base64': Serializer.serialize_base64, + 'object': self.serialize_object, + '[]': self.serialize_iter, + '{}': self.serialize_dict + } + self.dependencies = dict(classes) if classes else {} + self.key_transformer = full_restapi_key_transformer + self.client_side_validation = True + + def _serialize(self, target_obj, data_type=None, **kwargs): + """Serialize data into a string according to type. + + :param target_obj: The data to be serialized. + :param str data_type: The type to be serialized from. + :rtype: str, dict + :raises: SerializationError if serialization fails. + """ + key_transformer = kwargs.get("key_transformer", self.key_transformer) + keep_readonly = kwargs.get("keep_readonly", False) + if target_obj is None: + return None + + attr_name = None + class_name = target_obj.__class__.__name__ + + if data_type: + return self.serialize_data( + target_obj, data_type, **kwargs) + + if not hasattr(target_obj, "_attribute_map"): + data_type = type(target_obj).__name__ + if data_type in self.basic_types.values(): + return self.serialize_data( + target_obj, data_type, **kwargs) + + # Force "is_xml" kwargs if we detect a XML model + try: + is_xml_model_serialization = kwargs["is_xml"] + except KeyError: + is_xml_model_serialization = kwargs.setdefault("is_xml", target_obj.is_xml_model()) + + serialized = {} + if is_xml_model_serialization: + serialized = target_obj._create_xml_node() + try: + attributes = target_obj._attribute_map + for attr, attr_desc in attributes.items(): + attr_name = attr + if not keep_readonly and target_obj._validation.get(attr_name, {}).get('readonly', False): + continue + + if attr_name == "additional_properties" and attr_desc["key"] == '': + if target_obj.additional_properties is not None: + serialized.update(target_obj.additional_properties) + continue + try: + + orig_attr = getattr(target_obj, attr) + if is_xml_model_serialization: + pass # Don't provide "transformer" for XML for now. Keep "orig_attr" + else: # JSON + keys, orig_attr = key_transformer(attr, attr_desc.copy(), orig_attr) + keys = keys if isinstance(keys, list) else [keys] + + + kwargs["serialization_ctxt"] = attr_desc + new_attr = self.serialize_data(orig_attr, attr_desc['type'], **kwargs) + + + if is_xml_model_serialization: + xml_desc = attr_desc.get('xml', {}) + xml_name = xml_desc.get('name', attr_desc['key']) + xml_prefix = xml_desc.get('prefix', None) + xml_ns = xml_desc.get('ns', None) + 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) + continue + if xml_desc.get("text", False): + serialized.text = new_attr + continue + if isinstance(new_attr, list): + serialized.extend(new_attr) + 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', {}): + splitted_tag = new_attr.tag.split("}") + if len(splitted_tag) == 2: # Namespace + new_attr.tag = "}".join([splitted_tag[0], xml_name]) + else: + new_attr.tag = xml_name + serialized.append(new_attr) + 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) + else: # JSON + for k in reversed(keys): + unflattened = {k: new_attr} + new_attr = unflattened + + _new_attr = new_attr + _serialized = serialized + for k in keys: + if k not in _serialized: + _serialized.update(_new_attr) + _new_attr = _new_attr[k] + _serialized = _serialized[k] + except ValueError: + continue + + except (AttributeError, KeyError, TypeError) as err: + msg = "Attribute {} in object {} cannot be serialized.\n{}".format( + attr_name, class_name, str(target_obj)) + raise_with_traceback(SerializationError, msg, err) + else: + return serialized + + def body(self, data, data_type, **kwargs): + """Serialize data intended for a request body. + + :param data: The data to be serialized. + :param str data_type: The type to be serialized from. + :rtype: dict + :raises: SerializationError if serialization fails. + :raises: ValueError if data is None + """ + + # Just in case this is a dict + internal_data_type = data_type.strip('[]{}') + internal_data_type = self.dependencies.get(internal_data_type, None) + try: + is_xml_model_serialization = kwargs["is_xml"] + except KeyError: + if internal_data_type and issubclass(internal_data_type, Model): + is_xml_model_serialization = kwargs.setdefault("is_xml", internal_data_type.is_xml_model()) + else: + is_xml_model_serialization = False + if internal_data_type and not isinstance(internal_data_type, Enum): + try: + deserializer = Deserializer(self.dependencies) + # Since it's on serialization, it's almost sure that format is not JSON REST + # We're not able to deal with additional properties for now. + deserializer.additional_properties_detection = False + if is_xml_model_serialization: + deserializer.key_extractors = [ + attribute_key_case_insensitive_extractor, + ] + else: + deserializer.key_extractors = [ + rest_key_case_insensitive_extractor, + attribute_key_case_insensitive_extractor, + last_rest_key_case_insensitive_extractor + ] + data = deserializer._deserialize(data_type, data) + except DeserializationError as err: + raise_with_traceback( + SerializationError, "Unable to build a model: "+str(err), err) + + return self._serialize(data, data_type, **kwargs) + + def url(self, name, data, data_type, **kwargs): + """Serialize data intended for a URL path. + + :param data: The data to be serialized. + :param str data_type: The type to be serialized from. + :rtype: str + :raises: TypeError if serialization fails. + :raises: ValueError if data is None + """ + try: + output = self.serialize_data(data, data_type, **kwargs) + if data_type == 'bool': + output = json.dumps(output) + + if kwargs.get('skip_quote') is True: + output = str(output) + else: + output = quote(str(output), safe='') + except SerializationError: + raise TypeError("{} must be type {}.".format(name, data_type)) + else: + return output + + def query(self, name, data, data_type, **kwargs): + """Serialize data intended for a URL query. + + :param data: The data to be serialized. + :param str data_type: The type to be serialized from. + :rtype: str + :raises: TypeError if serialization fails. + :raises: ValueError if data is None + """ + try: + # 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)) + + # Not a list, regular serialization + output = self.serialize_data(data, data_type, **kwargs) + if data_type == 'bool': + output = json.dumps(output) + if kwargs.get('skip_quote') is True: + output = str(output) + else: + output = quote(str(output), safe='') + except SerializationError: + raise TypeError("{} must be type {}.".format(name, data_type)) + else: + return str(output) + + def header(self, name, data, data_type, **kwargs): + """Serialize data intended for a request header. + + :param data: The data to be serialized. + :param str data_type: The type to be serialized from. + :rtype: str + :raises: TypeError if serialization fails. + :raises: ValueError if data is None + """ + try: + if data_type in ['[str]']: + data = ["" if d is None else d for d in data] + + output = self.serialize_data(data, data_type, **kwargs) + if data_type == 'bool': + output = json.dumps(output) + except SerializationError: + raise TypeError("{} must be type {}.".format(name, data_type)) + else: + return str(output) + + def serialize_data(self, data, data_type, **kwargs): + """Serialize generic data according to supplied data type. + + :param data: The data to be serialized. + :param str data_type: The type to be serialized from. + :param bool required: Whether it's essential that the data not be + empty or None + :raises: AttributeError if required data is None. + :raises: ValueError if data is None + :raises: SerializationError if serialization fails. + """ + if data is None: + raise ValueError("No value for given attribute") + + try: + if data_type in self.basic_types.values(): + return self.serialize_basic(data, data_type, **kwargs) + + elif data_type in self.serialize_type: + return self.serialize_type[data_type](data, **kwargs) + + # If dependencies is empty, try with current data class + # It has to be a subclass of Enum anyway + enum_type = self.dependencies.get(data_type, data.__class__) + if issubclass(enum_type, Enum): + return Serializer.serialize_enum(data, enum_obj=enum_type) + + iter_type = data_type[0] + data_type[-1] + if iter_type in self.serialize_type: + return self.serialize_type[iter_type]( + data, data_type[1:-1], **kwargs) + + except (ValueError, TypeError) as err: + msg = "Unable to serialize value: {!r} as type: {!r}." + raise_with_traceback( + SerializationError, msg.format(data, data_type), err) + else: + return self._serialize(data, **kwargs) + + @classmethod + def _get_custom_serializers(cls, data_type, **kwargs): + custom_serializer = kwargs.get("basic_types_serializers", {}).get(data_type) + if custom_serializer: + return custom_serializer + if kwargs.get("is_xml", False): + return cls._xml_basic_types_serializers.get(data_type) + + @classmethod + def serialize_basic(cls, data, data_type, **kwargs): + """Serialize basic builting data type. + Serializes objects to str, int, float or bool. + + Possible kwargs: + - basic_types_serializers dict[str, callable] : If set, use the callable as serializer + - is_xml bool : If set, use xml_basic_types_serializers + + :param data: Object to be serialized. + :param str data_type: Type of object in the iterable. + """ + custom_serializer = cls._get_custom_serializers(data_type, **kwargs) + if custom_serializer: + return custom_serializer(data) + if data_type == 'str': + return cls.serialize_unicode(data) + return eval(data_type)(data) # nosec + + @classmethod + def serialize_unicode(cls, data): + """Special handling for serializing unicode strings in Py2. + Encode to UTF-8 if unicode, otherwise handle as a str. + + :param data: Object to be serialized. + :rtype: str + """ + try: # If I received an enum, return its value + return data.value + except AttributeError: + pass + + try: + if isinstance(data, unicode): + # Don't change it, JSON and XML ElementTree are totally able + # to serialize correctly u'' strings + return data + except NameError: + return str(data) + else: + return str(data) + + def serialize_iter(self, data, iter_type, div=None, **kwargs): + """Serialize iterable. + + Supported kwargs: + - serialization_ctxt dict : The current entry of _attribute_map, or same format. + serialization_ctxt['type'] should be same as data_type. + - is_xml bool : If set, serialize as XML + + :param list attr: Object to be serialized. + :param str iter_type: Type of object in the iterable. + :param bool required: Whether the objects in the iterable must + not be None or empty. + :param str div: If set, this str will be used to combine the elements + in the iterable into a combined string. Default is 'None'. + :rtype: list, str + """ + if isinstance(data, str): + raise SerializationError("Refuse str type as a valid iter type.") + + serialization_ctxt = kwargs.get("serialization_ctxt", {}) + is_xml = kwargs.get("is_xml", False) + + serialized = [] + for d in data: + try: + serialized.append(self.serialize_data(d, iter_type, **kwargs)) + except ValueError: + serialized.append(None) + + if div: + serialized = ['' if s is None else str(s) for s in serialized] + serialized = div.join(serialized) + + if 'xml' in serialization_ctxt or is_xml: + # XML serialization is more complicated + xml_desc = serialization_ctxt.get('xml', {}) + xml_name = xml_desc.get('name') + if not xml_name: + xml_name = serialization_ctxt['key'] + + # Create a wrap node if necessary (use the fact that Element and list have "append") + is_wrapped = xml_desc.get("wrapped", False) + node_name = xml_desc.get("itemsName", xml_name) + if is_wrapped: + final_result = _create_xml_node( + xml_name, + xml_desc.get('prefix', None), + xml_desc.get('ns', None) + ) + else: + final_result = [] + # All list elements to "local_node" + for el in serialized: + if isinstance(el, ET.Element): + el_node = el + else: + el_node = _create_xml_node( + node_name, + xml_desc.get('prefix', None), + xml_desc.get('ns', None) + ) + if el is not None: # Otherwise it writes "None" :-p + el_node.text = str(el) + final_result.append(el_node) + return final_result + return serialized + + def serialize_dict(self, attr, dict_type, **kwargs): + """Serialize a dictionary of objects. + + :param dict attr: Object to be serialized. + :param str dict_type: Type of object in the dictionary. + :param bool required: Whether the objects in the dictionary must + not be None or empty. + :rtype: dict + """ + serialization_ctxt = kwargs.get("serialization_ctxt", {}) + serialized = {} + for key, value in attr.items(): + try: + serialized[self.serialize_unicode(key)] = self.serialize_data( + value, dict_type, **kwargs) + except ValueError: + serialized[self.serialize_unicode(key)] = None + + if 'xml' in serialization_ctxt: + # XML serialization is more complicated + xml_desc = serialization_ctxt['xml'] + xml_name = xml_desc['name'] + + final_result = _create_xml_node( + xml_name, + xml_desc.get('prefix', None), + xml_desc.get('ns', None) + ) + for key, value in serialized.items(): + ET.SubElement(final_result, key).text = value + return final_result + + return serialized + + def serialize_object(self, attr, **kwargs): + """Serialize a generic object. + This will be handled as a dictionary. If object passed in is not + a basic type (str, int, float, dict, list) it will simply be + cast to str. + + :param dict attr: Object to be serialized. + :rtype: dict or str + """ + if attr is None: + return None + if isinstance(attr, ET.Element): + return attr + obj_type = type(attr) + if obj_type in self.basic_types: + return self.serialize_basic(attr, self.basic_types[obj_type], **kwargs) + if obj_type is _long_type: + return self.serialize_long(attr) + if obj_type is unicode_str: + return self.serialize_unicode(attr) + if obj_type is datetime.datetime: + return self.serialize_iso(attr) + if obj_type is datetime.date: + return self.serialize_date(attr) + if obj_type is datetime.time: + return self.serialize_time(attr) + if obj_type is datetime.timedelta: + return self.serialize_duration(attr) + if obj_type is decimal.Decimal: + return self.serialize_decimal(attr) + + # If it's a model or I know this dependency, serialize as a Model + elif obj_type in self.dependencies.values() or isinstance(attr, Model): + return self._serialize(attr) + + if obj_type == dict: + serialized = {} + for key, value in attr.items(): + try: + serialized[self.serialize_unicode(key)] = self.serialize_object( + value, **kwargs) + except ValueError: + serialized[self.serialize_unicode(key)] = None + return serialized + + if obj_type == list: + serialized = [] + for obj in attr: + try: + serialized.append(self.serialize_object( + obj, **kwargs)) + except ValueError: + pass + return serialized + return str(attr) + + @staticmethod + def serialize_enum(attr, enum_obj=None): + try: + result = attr.value + except AttributeError: + result = attr + try: + enum_obj(result) + return result + except ValueError: + for enum_value in enum_obj: + if enum_value.value.lower() == str(attr).lower(): + return enum_value.value + error = "{!r} is not valid value for enum {!r}" + raise SerializationError(error.format(attr, enum_obj)) + + @staticmethod + def serialize_bytearray(attr, **kwargs): + """Serialize bytearray into base-64 string. + + :param attr: Object to be serialized. + :rtype: str + """ + return b64encode(attr).decode() + + @staticmethod + def serialize_base64(attr, **kwargs): + """Serialize str into base-64 string. + + :param attr: Object to be serialized. + :rtype: str + """ + encoded = b64encode(attr).decode('ascii') + return encoded.strip('=').replace('+', '-').replace('/', '_') + + @staticmethod + def serialize_decimal(attr, **kwargs): + """Serialize Decimal object to float. + + :param attr: Object to be serialized. + :rtype: float + """ + return float(attr) + + @staticmethod + def serialize_long(attr, **kwargs): + """Serialize long (Py2) or int (Py3). + + :param attr: Object to be serialized. + :rtype: int/long + """ + return _long_type(attr) + + @staticmethod + def serialize_date(attr, **kwargs): + """Serialize Date object into ISO-8601 formatted string. + + :param Date attr: Object to be serialized. + :rtype: str + """ + if isinstance(attr, str): + attr = isodate.parse_date(attr) + t = "{:04}-{:02}-{:02}".format(attr.year, attr.month, attr.day) + return t + + @staticmethod + def serialize_time(attr, **kwargs): + """Serialize Time object into ISO-8601 formatted string. + + :param datetime.time attr: Object to be serialized. + :rtype: str + """ + if isinstance(attr, str): + attr = isodate.parse_time(attr) + t = "{:02}:{:02}:{:02}".format(attr.hour, attr.minute, attr.second) + if attr.microsecond: + t += ".{:02}".format(attr.microsecond) + return t + + @staticmethod + def serialize_duration(attr, **kwargs): + """Serialize TimeDelta object into ISO-8601 formatted string. + + :param TimeDelta attr: Object to be serialized. + :rtype: str + """ + if isinstance(attr, str): + attr = isodate.parse_duration(attr) + return isodate.duration_isoformat(attr) + + @staticmethod + def serialize_rfc(attr, **kwargs): + """Serialize Datetime object into RFC-1123 formatted string. + + :param Datetime attr: Object to be serialized. + :rtype: str + :raises: TypeError if format invalid. + """ + try: + if not attr.tzinfo: + _LOGGER.warning( + "Datetime with no tzinfo will be considered UTC.") + utc = attr.utctimetuple() + except AttributeError: + raise TypeError("RFC1123 object must be valid Datetime object.") + + return "{}, {:02} {} {:04} {:02}:{:02}:{:02} GMT".format( + Serializer.days[utc.tm_wday], utc.tm_mday, + Serializer.months[utc.tm_mon], utc.tm_year, + utc.tm_hour, utc.tm_min, utc.tm_sec) + + @staticmethod + def serialize_iso(attr, **kwargs): + """Serialize Datetime object into ISO-8601 formatted string. + + :param Datetime attr: Object to be serialized. + :rtype: str + :raises: SerializationError if format invalid. + """ + if isinstance(attr, str): + attr = isodate.parse_datetime(attr) + try: + if not attr.tzinfo: + _LOGGER.warning( + "Datetime with no tzinfo will be considered UTC.") + utc = attr.utctimetuple() + if utc.tm_year > 9999 or utc.tm_year < 1: + raise OverflowError("Hit max or min date") + + microseconds = str(attr.microsecond).rjust(6,'0').rstrip('0').ljust(3, '0') + if microseconds: + microseconds = '.'+microseconds + date = "{:04}-{:02}-{:02}T{:02}:{:02}:{:02}".format( + utc.tm_year, utc.tm_mon, utc.tm_mday, + utc.tm_hour, utc.tm_min, utc.tm_sec) + return date + microseconds + 'Z' + except (ValueError, OverflowError) as err: + msg = "Unable to serialize datetime object." + raise_with_traceback(SerializationError, msg, err) + except AttributeError as err: + msg = "ISO-8601 object must be valid Datetime object." + raise_with_traceback(TypeError, msg, err) + + @staticmethod + def serialize_unix(attr, **kwargs): + """Serialize Datetime object into IntTime format. + This is represented as seconds. + + :param Datetime attr: Object to be serialized. + :rtype: int + :raises: SerializationError if format invalid + """ + if isinstance(attr, int): + return attr + try: + if not attr.tzinfo: + _LOGGER.warning( + "Datetime with no tzinfo will be considered UTC.") + return int(calendar.timegm(attr.utctimetuple())) + except AttributeError: + raise TypeError("Unix time object must be valid Datetime object.") + +def rest_key_extractor(attr, attr_desc, data): + key = attr_desc['key'] + working_data = data + + while '.' in key: + dict_keys = _FLATTEN.split(key) + if len(dict_keys) == 1: + key = _decode_attribute_map_key(dict_keys[0]) + break + working_key = _decode_attribute_map_key(dict_keys[0]) + working_data = working_data.get(working_key, data) + if working_data is None: + # If at any point while following flatten JSON path see None, it means + # that all properties under are None as well + # https://github.com/Azure/msrest-for-python/issues/197 + return None + key = '.'.join(dict_keys[1:]) + + return working_data.get(key) + +def rest_key_case_insensitive_extractor(attr, attr_desc, data): + key = attr_desc['key'] + working_data = data + + while '.' in key: + dict_keys = _FLATTEN.split(key) + if len(dict_keys) == 1: + key = _decode_attribute_map_key(dict_keys[0]) + break + working_key = _decode_attribute_map_key(dict_keys[0]) + working_data = attribute_key_case_insensitive_extractor(working_key, None, working_data) + if working_data is None: + # If at any point while following flatten JSON path see None, it means + # that all properties under are None as well + # https://github.com/Azure/msrest-for-python/issues/197 + return None + key = '.'.join(dict_keys[1:]) + + if working_data: + return attribute_key_case_insensitive_extractor(key, None, working_data) + +def last_rest_key_extractor(attr, attr_desc, data): + """Extract the attribute in "data" based on the last part of the JSON path key. + """ + key = attr_desc['key'] + dict_keys = _FLATTEN.split(key) + return attribute_key_extractor(dict_keys[-1], None, data) + +def last_rest_key_case_insensitive_extractor(attr, attr_desc, data): + """Extract the attribute in "data" based on the last part of the JSON path key. + + This is the case insensitive version of "last_rest_key_extractor" + """ + key = attr_desc['key'] + dict_keys = _FLATTEN.split(key) + return attribute_key_case_insensitive_extractor(dict_keys[-1], None, data) + +def attribute_key_extractor(attr, _, data): + return data.get(attr) + +def attribute_key_case_insensitive_extractor(attr, _, data): + found_key = None + lower_attr = attr.lower() + for key in data: + if lower_attr == key.lower(): + found_key = key + break + + return data.get(found_key) + +def _extract_name_from_internal_type(internal_type): + """Given an internal type XML description, extract correct XML name with namespace. + + :param dict internal_type: An model type + :rtype: tuple + :returns: A tuple XML name + namespace dict + """ + internal_type_xml_map = getattr(internal_type, "_xml_map", {}) + 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) + return xml_name + + +def xml_key_extractor(attr, attr_desc, data): + if isinstance(data, dict): + return None + + # Test if this model is XML ready first + if not isinstance(data, ET.Element): + return None + + xml_desc = attr_desc.get('xml', {}) + xml_name = xml_desc.get('name', attr_desc['key']) + + # Look for a children + is_iter_type = attr_desc['type'].startswith("[") + is_wrapped = xml_desc.get("wrapped", False) + internal_type = attr_desc.get("internalType", None) + internal_type_xml_map = getattr(internal_type, "_xml_map", {}) + + # 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) + + # If it's an attribute, that's simple + if xml_desc.get("attr", False): + return data.get(xml_name) + + # If it's x-ms-text, that's simple too + if xml_desc.get("text", False): + return data.text + + # Scenario where I take the local name: + # - Wrapped node + # - Internal type is an enum (considered basic types) + # - Internal type has no XML/Name node + if is_wrapped or (internal_type and (issubclass(internal_type, Enum) or 'name' not in internal_type_xml_map)): + children = data.findall(xml_name) + # If internal type has a local name and it's not a list, I use that name + elif not is_iter_type and internal_type and 'name' in internal_type_xml_map: + xml_name = _extract_name_from_internal_type(internal_type) + children = data.findall(xml_name) + # That's an array + else: + if internal_type: # Complex type, ignore itemsName and use the complex type name + items_name = _extract_name_from_internal_type(internal_type) + else: + items_name = xml_desc.get("itemsName", xml_name) + children = data.findall(items_name) + + if len(children) == 0: + if is_iter_type: + if is_wrapped: + return None # is_wrapped no node, we want None + else: + return [] # not wrapped, assume empty list + return None # Assume it's not there, maybe an optional node. + + # If is_iter_type and not wrapped, return all found children + if is_iter_type: + if not is_wrapped: + return children + else: # Iter and wrapped, should have found one node only (the wrap one) + if len(children) != 1: + raise DeserializationError( + "Tried to deserialize an array not wrapped, and found several nodes '{}'. Maybe you should declare this array as wrapped?".format( + xml_name + )) + return list(children[0]) # Might be empty list and that's ok. + + # Here it's not a itertype, we should have found one element only or empty + if len(children) > 1: + raise DeserializationError("Find several XML '{}' where it was not expected".format(xml_name)) + return children[0] + +class Deserializer(object): + """Response object model deserializer. + + :param dict classes: Class type dictionary for deserializing complex types. + :ivar list key_extractors: Ordered list of extractors to be used by this deserializer. + """ + + basic_types = {str: 'str', int: 'int', bool: 'bool', float: 'float'} + + valid_date = re.compile( + r'\d{4}[-]\d{2}[-]\d{2}T\d{2}:\d{2}:\d{2}' + r'\.?\d*Z?[-+]?[\d{2}]?:?[\d{2}]?') + + def __init__(self, classes=None): + self.deserialize_type = { + 'iso-8601': Deserializer.deserialize_iso, + 'rfc-1123': Deserializer.deserialize_rfc, + 'unix-time': Deserializer.deserialize_unix, + 'duration': Deserializer.deserialize_duration, + 'date': Deserializer.deserialize_date, + 'time': Deserializer.deserialize_time, + 'decimal': Deserializer.deserialize_decimal, + 'long': Deserializer.deserialize_long, + 'bytearray': Deserializer.deserialize_bytearray, + 'base64': Deserializer.deserialize_base64, + 'object': self.deserialize_object, + '[]': self.deserialize_iter, + '{}': self.deserialize_dict + } + self.deserialize_expected_types = { + 'duration': (isodate.Duration, datetime.timedelta), + 'iso-8601': (datetime.datetime) + } + self.dependencies = 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 + # complicated, with no real scenario for now. + # So adding a flag to disable additional properties detection. This flag should be + # used if your expect the deserialization to NOT come from a JSON REST syntax. + # Otherwise, result are unexpected + self.additional_properties_detection = True + + def __call__(self, target_obj, response_data, content_type=None): + """Call the deserializer to process a REST response. + + :param str target_obj: Target data type to deserialize to. + :param requests.Response response_data: REST response object. + :param str content_type: Swagger "produces" if available. + :raises: DeserializationError if deserialization fails. + :return: Deserialized object. + """ + data = self._unpack_content(response_data, content_type) + return self._deserialize(target_obj, data) + + def _deserialize(self, target_obj, data): + """Call the deserializer on a model. + + Data needs to be already deserialized as JSON or XML ElementTree + + :param str target_obj: Target data type to deserialize to. + :param object data: Object to deserialize. + :raises: DeserializationError if deserialization fails. + :return: Deserialized object. + """ + # This is already a model, go recursive just in case + if hasattr(data, "_attribute_map"): + constants = [name for name, config in getattr(data, '_validation', {}).items() + if config.get('constant')] + try: + for attr, mapconfig in data._attribute_map.items(): + if attr in constants: + continue + value = getattr(data, attr) + if value is None: + continue + local_type = mapconfig['type'] + internal_data_type = local_type.strip('[]{}') + if internal_data_type not in self.dependencies or isinstance(internal_data_type, Enum): + continue + setattr( + data, + attr, + self._deserialize(local_type, value) + ) + return data + except AttributeError: + return + + response, class_name = self._classify_target(target_obj, data) + + if isinstance(response, basestring): + return self.deserialize_data(data, response) + elif isinstance(response, type) and issubclass(response, Enum): + return self.deserialize_enum(data, response) + + if data is None: + return data + try: + attributes = response._attribute_map + d_attrs = {} + for attr, attr_desc in attributes.items(): + # Check empty string. If it's not empty, someone has a real "additionalProperties"... + if attr == "additional_properties" and attr_desc["key"] == '': + continue + raw_value = None + # Enhance attr_desc with some dynamic data + attr_desc = attr_desc.copy() # Do a copy, do not change the real one + internal_data_type = attr_desc["type"].strip('[]{}') + if internal_data_type in self.dependencies: + attr_desc["internalType"] = self.dependencies[internal_data_type] + + for key_extractor in self.key_extractors: + found_value = key_extractor(attr, attr_desc, data) + if found_value is not None: + if raw_value is not None and raw_value != found_value: + msg = ("Ignoring extracted value '%s' from %s for key '%s'" + " (duplicate extraction, follow extractors order)" ) + _LOGGER.warning( + msg, + found_value, + key_extractor, + attr + ) + continue + raw_value = found_value + + 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 + raise_with_traceback(DeserializationError, msg, err) + else: + additional_properties = self._build_additional_properties(attributes, data) + return self._instantiate_model(response, d_attrs, additional_properties) + + def _build_additional_properties(self, attribute_map, data): + if not self.additional_properties_detection: + return None + if "additional_properties" in attribute_map and attribute_map.get("additional_properties", {}).get("key") != '': + # Check empty string. If it's not empty, someone has a real "additionalProperties" + return None + if isinstance(data, ET.Element): + data = {el.tag: el.text for el in data} + + known_keys = {_decode_attribute_map_key(_FLATTEN.split(desc['key'])[0]) + for desc in attribute_map.values() if desc['key'] != ''} + present_keys = set(data.keys()) + missing_keys = present_keys - known_keys + return {key: data[key] for key in missing_keys} + + def _classify_target(self, target, data): + """Check to see whether the deserialization target object can + be classified into a subclass. + 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. + """ + if target is None: + return None, None + + if isinstance(target, basestring): + try: + target = self.dependencies[target] + except KeyError: + return target, target + + try: + target = target._classify(data, self.dependencies) + except AttributeError: + pass # Target is not a Model, no classify + return target, target.__class__.__name__ + + def failsafe_deserialize(self, target_obj, data, content_type=None): + """Ignores any errors encountered in deserialization, + and falls back to not deserializing the object. Recommended + for use in error deserialization, as we want to return the + HttpResponseError to users, and not have them deal with + 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 content_type: Swagger "produces" if available. + """ + try: + return self(target_obj, data, content_type=content_type) + except: + _LOGGER.debug( + "Ran into a deserialization error. Ignoring since this is failsafe deserialization", + exc_info=True + ) + return None + + @staticmethod + def _unpack_content(raw_data, content_type=None): + """Extract the correct structure for deserialization. + + If raw_data is a PipelineResponse, try to extract the result of RawDeserializer. + if we can't, raise. Your Pipeline should have a RawDeserializer. + + If not a pipeline response and raw_data is bytes or string, use content-type + to decode it. If no content-type, try JSON. + + If raw_data is something else, bypass all logic and return it directly. + + :param raw_data: Data to be processed. + :param content_type: How to parse if raw_data is a string/bytes. + :raises JSONDecodeError: If JSON is requested and parsing is impossible. + :raises UnicodeDecodeError: If bytes is not UTF8 + """ + # Assume this is enough to detect a Pipeline Response without importing it + context = getattr(raw_data, "context", {}) + if context: + if RawDeserializer.CONTEXT_NAME in context: + return context[RawDeserializer.CONTEXT_NAME] + raise ValueError("This pipeline didn't have the RawDeserializer policy; can't deserialize") + + #Assume this is enough to recognize universal_http.ClientResponse without importing it + if hasattr(raw_data, "body"): + return RawDeserializer.deserialize_from_http_generics( + raw_data.text(), + raw_data.headers + ) + + # Assume this enough to recognize requests.Response without importing it. + if hasattr(raw_data, '_content_consumed'): + 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 raw_data + + def _instantiate_model(self, response, attrs, additional_properties=None): + """Instantiate a response model passing in deserialized args. + + :param response: The response model class. + :param d_attrs: The deserialized response attributes. + """ + if callable(response): + subtype = getattr(response, '_subtype_map', {}) + try: + readonly = [k for k, v in response._validation.items() + if v.get('readonly')] + const = [k for k, v in response._validation.items() + if v.get('constant')] + kwargs = {k: v for k, v in attrs.items() + if k not in subtype and k not in readonly + const} + response_obj = response(**kwargs) + for attr in readonly: + setattr(response_obj, attr, attrs.get(attr)) + if additional_properties: + response_obj.additional_properties = additional_properties + return response_obj + except TypeError as err: + msg = "Unable to deserialize {} into model {}. ".format( + kwargs, response) + raise DeserializationError(msg + str(err)) + else: + try: + for attr, value in attrs.items(): + setattr(response, attr, value) + return response + except Exception as exp: + msg = "Unable to populate response model. " + msg += "Type: {}, Error: {}".format(type(response), exp) + raise DeserializationError(msg) + + def deserialize_data(self, data, data_type): + """Process data for deserialization according to data type. + + :param str data: The response string to be deserialized. + :param str data_type: The type to deserialize to. + :raises: DeserializationError if deserialization fails. + :return: Deserialized object. + """ + if data is None: + return data + + try: + if not data_type: + return data + if data_type in self.basic_types.values(): + return self.deserialize_basic(data, data_type) + if data_type in self.deserialize_type: + if isinstance(data, self.deserialize_expected_types.get(data_type, tuple())): + return data + + is_a_text_parsing_type = lambda x: x not in ["object", "[]", r"{}"] + if isinstance(data, ET.Element) and is_a_text_parsing_type(data_type) and not data.text: + return None + data_val = self.deserialize_type[data_type](data) + return data_val + + iter_type = data_type[0] + data_type[-1] + if iter_type in self.deserialize_type: + return self.deserialize_type[iter_type](data, data_type[1:-1]) + + obj_type = self.dependencies[data_type] + if issubclass(obj_type, Enum): + if isinstance(data, ET.Element): + data = data.text + return self.deserialize_enum(data, obj_type) + + except (ValueError, TypeError, AttributeError) as err: + msg = "Unable to deserialize response data." + msg += " Data: {}, {}".format(data, data_type) + raise_with_traceback(DeserializationError, msg, err) + else: + return self._deserialize(obj_type, data) + + def deserialize_iter(self, attr, iter_type): + """Deserialize an iterable. + + :param list attr: Iterable to be deserialized. + :param str iter_type: The type of object in the iterable. + :rtype: list + """ + if attr is None: + return None + if isinstance(attr, ET.Element): # If I receive an element here, get the children + attr = list(attr) + if not isinstance(attr, (list, set)): + raise DeserializationError("Cannot deserialize as [{}] an object of type {}".format( + iter_type, + type(attr) + )) + return [self.deserialize_data(a, iter_type) for a in attr] + + def deserialize_dict(self, attr, dict_type): + """Deserialize a dictionary. + + :param dict/list attr: Dictionary to be deserialized. Also accepts + a list of key, value pairs. + :param str dict_type: The object type of the items in the dictionary. + :rtype: dict + """ + if isinstance(attr, list): + return {x['key']: self.deserialize_data(x['value'], dict_type) for x in attr} + + if isinstance(attr, ET.Element): + # Transform value into {"Key": "value"} + attr = {el.tag: el.text for el in attr} + return {k: self.deserialize_data(v, dict_type) for k, v in attr.items()} + + def deserialize_object(self, attr, **kwargs): + """Deserialize a generic object. + This will be handled as a dictionary. + + :param dict attr: Dictionary to be deserialized. + :rtype: dict + :raises: TypeError if non-builtin datatype encountered. + """ + if attr is None: + return None + if isinstance(attr, ET.Element): + # Do no recurse on XML, just return the tree as-is + return attr + if isinstance(attr, basestring): + return self.deserialize_basic(attr, 'str') + obj_type = type(attr) + if obj_type in self.basic_types: + return self.deserialize_basic(attr, self.basic_types[obj_type]) + if obj_type is _long_type: + return self.deserialize_long(attr) + + if obj_type == dict: + deserialized = {} + for key, value in attr.items(): + try: + deserialized[key] = self.deserialize_object( + value, **kwargs) + except ValueError: + deserialized[key] = None + return deserialized + + if obj_type == list: + deserialized = [] + for obj in attr: + try: + deserialized.append(self.deserialize_object( + obj, **kwargs)) + except ValueError: + pass + return deserialized + + else: + error = "Cannot deserialize generic object with type: " + raise TypeError(error + str(obj_type)) + + def deserialize_basic(self, attr, data_type): + """Deserialize basic builtin data type from string. + Will attempt to convert to str, int, float and bool. + This function will also accept '1', '0', 'true' and 'false' as + valid bool values. + + :param str attr: response string to be deserialized. + :param str data_type: deserialization data type. + :rtype: str, int, float or bool + :raises: TypeError if string format is not valid. + """ + # If we're here, data is supposed to be a basic type. + # If it's still an XML node, take the text + if isinstance(attr, ET.Element): + attr = attr.text + if not attr: + if data_type == "str": + # None or '', node
is empty string. + return '' + else: + # None or '', node with a strong type is None. + # Don't try to model "empty bool" or "empty int" + return None + + if data_type == 'bool': + if attr in [True, False, 1, 0]: + return bool(attr) + elif isinstance(attr, basestring): + if attr.lower() in ['true', '1']: + return True + elif attr.lower() in ['false', '0']: + return False + raise TypeError("Invalid boolean value: {}".format(attr)) + + if data_type == 'str': + return self.deserialize_unicode(attr) + return eval(data_type)(attr) # nosec + + @staticmethod + def deserialize_unicode(data): + """Preserve unicode objects in Python 2, otherwise return data + as a string. + + :param str data: response string to be deserialized. + :rtype: str or unicode + """ + # We might be here because we have an enum modeled as string, + # and we try to deserialize a partial dict with enum inside + if isinstance(data, Enum): + return data + + # Consider this is real string + try: + if isinstance(data, unicode): + return data + except NameError: + return str(data) + else: + return str(data) + + @staticmethod + def deserialize_enum(data, enum_obj): + """Deserialize string into enum object. + + If the string is not a valid enum value it will be returned as-is + and a warning will be logged. + + :param str data: Response string to be deserialized. If this value is + None or invalid it will be returned as-is. + :param Enum enum_obj: Enum object to deserialize to. + :rtype: Enum + """ + if isinstance(data, enum_obj) or data is None: + return data + if isinstance(data, Enum): + data = data.value + if isinstance(data, int): + # Workaround. We might consider remove it in the future. + # https://github.com/Azure/azure-rest-api-specs/issues/141 + try: + return list(enum_obj.__members__.values())[data] + except IndexError: + error = "{!r} is not a valid index for enum {!r}" + raise DeserializationError(error.format(data, enum_obj)) + try: + return enum_obj(str(data)) + except ValueError: + for enum_value in enum_obj: + if enum_value.value.lower() == str(data).lower(): + return enum_value + # We don't fail anymore for unknown value, we deserialize as a string + _LOGGER.warning("Deserializer is not able to find %s as valid enum in %s", data, enum_obj) + return Deserializer.deserialize_unicode(data) + + @staticmethod + def deserialize_bytearray(attr): + """Deserialize string into bytearray. + + :param str attr: response string to be deserialized. + :rtype: bytearray + :raises: TypeError if string format invalid. + """ + if isinstance(attr, ET.Element): + attr = attr.text + return bytearray(b64decode(attr)) + + @staticmethod + def deserialize_base64(attr): + """Deserialize base64 encoded string into string. + + :param str attr: response string to be deserialized. + :rtype: bytearray + :raises: TypeError if string format invalid. + """ + if isinstance(attr, ET.Element): + attr = attr.text + padding = '=' * (3 - (len(attr) + 3) % 4) + attr = attr + padding + encoded = attr.replace('-', '+').replace('_', '/') + return b64decode(encoded) + + @staticmethod + def deserialize_decimal(attr): + """Deserialize string into Decimal object. + + :param str attr: response string to be deserialized. + :rtype: Decimal + :raises: DeserializationError if string format invalid. + """ + if isinstance(attr, ET.Element): + attr = attr.text + try: + return decimal.Decimal(attr) + except decimal.DecimalException as err: + msg = "Invalid decimal {}".format(attr) + raise_with_traceback(DeserializationError, msg, err) + + @staticmethod + def deserialize_long(attr): + """Deserialize string into long (Py2) or int (Py3). + + :param str attr: response string to be deserialized. + :rtype: long or int + :raises: ValueError if string format invalid. + """ + if isinstance(attr, ET.Element): + attr = attr.text + return _long_type(attr) + + @staticmethod + def deserialize_duration(attr): + """Deserialize ISO-8601 formatted string into TimeDelta object. + + :param str attr: response string to be deserialized. + :rtype: TimeDelta + :raises: DeserializationError if string format invalid. + """ + if isinstance(attr, ET.Element): + attr = attr.text + try: + duration = isodate.parse_duration(attr) + except(ValueError, OverflowError, AttributeError) as err: + msg = "Cannot deserialize duration object." + raise_with_traceback(DeserializationError, msg, err) + else: + return duration + + @staticmethod + def deserialize_date(attr): + """Deserialize ISO-8601 formatted string into Date object. + + :param str attr: response string to be deserialized. + :rtype: Date + :raises: DeserializationError if string format invalid. + """ + if isinstance(attr, ET.Element): + attr = attr.text + if re.search(r"[^\W\d_]", attr, re.I + re.U): + 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) + + @staticmethod + def deserialize_time(attr): + """Deserialize ISO-8601 formatted string into time object. + + :param str attr: response string to be deserialized. + :rtype: datetime.time + :raises: DeserializationError if string format invalid. + """ + if isinstance(attr, ET.Element): + attr = attr.text + if re.search(r"[^\W\d_]", attr, re.I + re.U): + raise DeserializationError("Date must have only digits and -. Received: %s" % attr) + return isodate.parse_time(attr) + + @staticmethod + def deserialize_rfc(attr): + """Deserialize RFC-1123 formatted string into Datetime object. + + :param str attr: response string to be deserialized. + :rtype: Datetime + :raises: DeserializationError if string format invalid. + """ + if isinstance(attr, ET.Element): + attr = attr.text + try: + parsed_date = email.utils.parsedate_tz(attr) + date_obj = datetime.datetime( + *parsed_date[:6], + tzinfo=_FixedOffset(datetime.timedelta(minutes=(parsed_date[9] or 0)/60)) + ) + if not date_obj.tzinfo: + date_obj = date_obj.astimezone(tz=TZ_UTC) + except ValueError as err: + msg = "Cannot deserialize to rfc datetime object." + raise_with_traceback(DeserializationError, msg, err) + else: + return date_obj + + @staticmethod + def deserialize_iso(attr): + """Deserialize ISO-8601 formatted string into Datetime object. + + :param str attr: response string to be deserialized. + :rtype: Datetime + :raises: DeserializationError if string format invalid. + """ + if isinstance(attr, ET.Element): + attr = attr.text + try: + attr = attr.upper() + match = Deserializer.valid_date.match(attr) + if not match: + raise ValueError("Invalid datetime string: " + attr) + + check_decimal = attr.split('.') + if len(check_decimal) > 1: + decimal_str = "" + for digit in check_decimal[1]: + if digit.isdigit(): + decimal_str += digit + else: + break + if len(decimal_str) > 6: + attr = attr.replace(decimal_str, decimal_str[0:6]) + + date_obj = isodate.parse_datetime(attr) + test_utc = date_obj.utctimetuple() + if test_utc.tm_year > 9999 or test_utc.tm_year < 1: + raise OverflowError("Hit max or min date") + except(ValueError, OverflowError, AttributeError) as err: + msg = "Cannot deserialize datetime object." + raise_with_traceback(DeserializationError, msg, err) + else: + return date_obj + + @staticmethod + def deserialize_unix(attr): + """Serialize Datetime object into IntTime format. + This is represented as seconds. + + :param int attr: Object to be serialized. + :rtype: Datetime + :raises: DeserializationError if format invalid + """ + if isinstance(attr, ET.Element): + attr = int(attr.text) + try: + date_obj = datetime.datetime.fromtimestamp(attr, TZ_UTC) + except ValueError as err: + msg = "Cannot deserialize to unix datetime object." + raise_with_traceback(DeserializationError, msg, err) + else: + return date_obj diff --git a/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/subscriptions/_subscription_client.py b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/subscriptions/_subscription_client.py index 29cbb14d1432c..7e1c52e940bc3 100644 --- a/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/subscriptions/_subscription_client.py +++ b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/subscriptions/_subscription_client.py @@ -9,9 +9,7 @@ # regenerated. # -------------------------------------------------------------------------- -from typing import TYPE_CHECKING - -from msrest import Deserializer, Serializer +from typing import Any, Optional, TYPE_CHECKING from azure.mgmt.core import ARMPipelineClient from azure.profiles import KnownProfiles, ProfileDefinition @@ -19,11 +17,10 @@ from ._configuration import SubscriptionClientConfiguration from ._operations_mixin import SubscriptionClientOperationsMixin +from ._serialization import Deserializer, Serializer if TYPE_CHECKING: # pylint: disable=unused-import,ungrouped-imports - from typing import Any, Optional - from azure.core.credentials import TokenCredential class _SDKClient(object): @@ -44,7 +41,7 @@ class SubscriptionClient(SubscriptionClientOperationsMixin, MultiApiClientMixin, The api-version parameter sets the default API version if the operation group is not described in the profile. - :param credential: Credential needed for the client to connect to Azure. + :param credential: Credential needed for the client to connect to Azure. Required. :type credential: ~azure.core.credentials.TokenCredential :param api_version: API version to use if no profile is provided, or if missing in profile. :type api_version: str @@ -66,9 +63,9 @@ class SubscriptionClient(SubscriptionClientOperationsMixin, MultiApiClientMixin, def __init__( self, - credential, # type: "TokenCredential" + credential: "TokenCredential", api_version=None, # type: Optional[str] - base_url="https://management.azure.com", # type: str + base_url: str = "https://management.azure.com", profile=KnownProfiles.default, # type: KnownProfiles **kwargs # type: Any ): diff --git a/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/subscriptions/aio/_configuration.py b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/subscriptions/aio/_configuration.py index d27af02f17ccd..39e5b111d72c9 100644 --- a/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/subscriptions/aio/_configuration.py +++ b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/subscriptions/aio/_configuration.py @@ -26,7 +26,7 @@ class SubscriptionClientConfiguration(Configuration): Note that all parameters used to create this instance are saved as instance attributes. - :param credential: Credential needed for the client to connect to Azure. + :param credential: Credential needed for the client to connect to Azure. Required. :type credential: ~azure.core.credentials_async.AsyncTokenCredential """ diff --git a/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/subscriptions/aio/_operations_mixin.py b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/subscriptions/aio/_operations_mixin.py index f31f616db992e..703c20dcae884 100644 --- a/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/subscriptions/aio/_operations_mixin.py +++ b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/subscriptions/aio/_operations_mixin.py @@ -8,30 +8,35 @@ # Changes may cause incorrect behavior and will be lost if the code is # regenerated. # -------------------------------------------------------------------------- -from msrest import Serializer, Deserializer -from typing import Any, Optional +from .._serialization import Serializer, Deserializer +from typing import Any, IO, Optional, Union + +from .. import models as _models class SubscriptionClientOperationsMixin(object): async def check_resource_name( self, - resource_name_definition: Optional["_models.ResourceName"] = None, + resource_name_definition: Optional[Union[_models.ResourceName, IO]] = None, **kwargs: Any - ) -> "_models.CheckResourceNameResult": + ) -> _models.CheckResourceNameResult: """Checks resource name validity. A resource name is valid if it is not a reserved word, does not contains a reserved word and does not start with a reserved word. :param resource_name_definition: Resource object with values for resource name and resource - type. Default value is None. + type. Is either a model type or a IO type. Default value is None. :type resource_name_definition: - ~azure.mgmt.resource.subscriptions.v2021_01_01.models.ResourceName + ~azure.mgmt.resource.subscriptions.v2021_01_01.models.ResourceName or IO + :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. + Default value is None. + :paramtype content_type: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: CheckResourceNameResult, or the result of cls(response) + :return: CheckResourceNameResult or the result of cls(response) :rtype: ~azure.mgmt.resource.subscriptions.v2021_01_01.models.CheckResourceNameResult - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ api_version = self._get_api_version('check_resource_name') if api_version == '2016-06-01': diff --git a/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/subscriptions/aio/_subscription_client.py b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/subscriptions/aio/_subscription_client.py index c18371e33ea72..98d80b2920607 100644 --- a/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/subscriptions/aio/_subscription_client.py +++ b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/subscriptions/aio/_subscription_client.py @@ -11,18 +11,16 @@ from typing import Any, Optional, TYPE_CHECKING -from msrest import Deserializer, Serializer - from azure.mgmt.core import AsyncARMPipelineClient from azure.profiles import KnownProfiles, ProfileDefinition from azure.profiles.multiapiclient import MultiApiClientMixin +from .._serialization import Deserializer, Serializer from ._configuration import SubscriptionClientConfiguration from ._operations_mixin import SubscriptionClientOperationsMixin if TYPE_CHECKING: # pylint: disable=unused-import,ungrouped-imports - from azure.core.credentials import TokenCredential from azure.core.credentials_async import AsyncTokenCredential class _SDKClient(object): @@ -43,7 +41,7 @@ class SubscriptionClient(SubscriptionClientOperationsMixin, MultiApiClientMixin, The api-version parameter sets the default API version if the operation group is not described in the profile. - :param credential: Credential needed for the client to connect to Azure. + :param credential: Credential needed for the client to connect to Azure. Required. :type credential: ~azure.core.credentials_async.AsyncTokenCredential :param api_version: API version to use if no profile is provided, or if missing in profile. :type api_version: str diff --git a/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/subscriptions/v2016_06_01/__init__.py b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/subscriptions/v2016_06_01/__init__.py index abd8e21f33387..d5d8e357d6a54 100644 --- a/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/subscriptions/v2016_06_01/__init__.py +++ b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/subscriptions/v2016_06_01/__init__.py @@ -10,9 +10,15 @@ from ._version import VERSION __version__ = VERSION -__all__ = ['SubscriptionClient'] -# `._patch.py` is used for handwritten extensions to the generated code -# Example: https://github.com/Azure/azure-sdk-for-python/blob/main/doc/dev/customize_code/how-to-patch-sdk-code.md -from ._patch import patch_sdk -patch_sdk() +try: + from ._patch import __all__ as _patch_all + from ._patch import * # type: ignore # pylint: disable=unused-wildcard-import +except ImportError: + _patch_all = [] +from ._patch import patch_sdk as _patch_sdk + +__all__ = ["SubscriptionClient"] +__all__.extend([p for p in _patch_all if p not in __all__]) + +_patch_sdk() diff --git a/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/subscriptions/v2016_06_01/_configuration.py b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/subscriptions/v2016_06_01/_configuration.py index 38d76dd9bbbb6..384d9deb61a3e 100644 --- a/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/subscriptions/v2016_06_01/_configuration.py +++ b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/subscriptions/v2016_06_01/_configuration.py @@ -25,43 +25,40 @@ class SubscriptionClientConfiguration(Configuration): # pylint: disable=too-man Note that all parameters used to create this instance are saved as instance attributes. - :param credential: Credential needed for the client to connect to Azure. + :param credential: Credential needed for the client to connect to Azure. Required. :type credential: ~azure.core.credentials.TokenCredential :keyword api_version: Api Version. Default value is "2016-06-01". Note that overriding this default value may result in unsupported behavior. :paramtype api_version: str """ - def __init__( - self, - credential: "TokenCredential", - **kwargs: Any - ) -> None: + def __init__(self, credential: "TokenCredential", **kwargs: Any) -> None: super(SubscriptionClientConfiguration, self).__init__(**kwargs) - api_version = kwargs.pop('api_version', "2016-06-01") # type: str + api_version = kwargs.pop("api_version", "2016-06-01") # type: str if credential is None: raise ValueError("Parameter 'credential' must not be None.") self.credential = credential self.api_version = api_version - self.credential_scopes = kwargs.pop('credential_scopes', ['https://management.azure.com/.default']) - kwargs.setdefault('sdk_moniker', 'mgmt-resource/{}'.format(VERSION)) + self.credential_scopes = kwargs.pop("credential_scopes", ["https://management.azure.com/.default"]) + kwargs.setdefault("sdk_moniker", "mgmt-resource/{}".format(VERSION)) self._configure(**kwargs) def _configure( - self, - **kwargs # type: Any + self, **kwargs # type: Any ): # type: (...) -> 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) - self.logging_policy = kwargs.get('logging_policy') or policies.NetworkTraceLoggingPolicy(**kwargs) - self.http_logging_policy = kwargs.get('http_logging_policy') or ARMHttpLoggingPolicy(**kwargs) - self.retry_policy = kwargs.get('retry_policy') or policies.RetryPolicy(**kwargs) - self.custom_hook_policy = kwargs.get('custom_hook_policy') or policies.CustomHookPolicy(**kwargs) - self.redirect_policy = kwargs.get('redirect_policy') or policies.RedirectPolicy(**kwargs) - self.authentication_policy = kwargs.get('authentication_policy') + 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) + self.logging_policy = kwargs.get("logging_policy") or policies.NetworkTraceLoggingPolicy(**kwargs) + self.http_logging_policy = kwargs.get("http_logging_policy") or ARMHttpLoggingPolicy(**kwargs) + self.retry_policy = kwargs.get("retry_policy") or policies.RetryPolicy(**kwargs) + self.custom_hook_policy = kwargs.get("custom_hook_policy") or policies.CustomHookPolicy(**kwargs) + self.redirect_policy = kwargs.get("redirect_policy") or policies.RedirectPolicy(**kwargs) + self.authentication_policy = kwargs.get("authentication_policy") if self.credential and not self.authentication_policy: - self.authentication_policy = ARMChallengeAuthenticationPolicy(self.credential, *self.credential_scopes, **kwargs) + self.authentication_policy = ARMChallengeAuthenticationPolicy( + self.credential, *self.credential_scopes, **kwargs + ) diff --git a/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/subscriptions/v2016_06_01/_metadata.json b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/subscriptions/v2016_06_01/_metadata.json index 7c1f36f9b361a..7c3277e81f307 100644 --- a/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/subscriptions/v2016_06_01/_metadata.json +++ b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/subscriptions/v2016_06_01/_metadata.json @@ -10,14 +10,14 @@ "azure_arm": true, "has_lro_operations": false, "client_side_validation": false, - "sync_imports": "{\"typing\": {\"azurecore\": {\"azure.core.credentials\": [\"TokenCredential\"]}}, \"regular\": {\"azurecore\": {\"azure.profiles\": [\"KnownProfiles\", \"ProfileDefinition\"], \"azure.profiles.multiapiclient\": [\"MultiApiClientMixin\"], \"azure.mgmt.core\": [\"ARMPipelineClient\"]}, \"local\": {\"._configuration\": [\"SubscriptionClientConfiguration\"], \"._operations_mixin\": [\"SubscriptionClientOperationsMixin\"]}, \"thirdparty\": {\"msrest\": [\"Deserializer\", \"Serializer\"]}}, \"conditional\": {\"stdlib\": {\"typing\": [\"Any\", \"Optional\"]}}}", - "async_imports": "{\"typing\": {\"azurecore\": {\"azure.core.credentials_async\": [\"AsyncTokenCredential\"], \"azure.core.credentials\": [\"TokenCredential\"]}}, \"regular\": {\"azurecore\": {\"azure.profiles\": [\"KnownProfiles\", \"ProfileDefinition\"], \"azure.profiles.multiapiclient\": [\"MultiApiClientMixin\"], \"azure.mgmt.core\": [\"AsyncARMPipelineClient\"]}, \"local\": {\"._configuration\": [\"SubscriptionClientConfiguration\"], \"._operations_mixin\": [\"SubscriptionClientOperationsMixin\"]}, \"thirdparty\": {\"msrest\": [\"Deserializer\", \"Serializer\"]}}, \"conditional\": {\"stdlib\": {\"typing\": [\"Any\", \"Optional\"]}}}" + "sync_imports": "{\"conditional\": {\"stdlib\": {\"typing\": [\"Any\", \"Optional\"]}}, \"regular\": {\"azurecore\": {\"azure.mgmt.core\": [\"ARMPipelineClient\"], \"azure.profiles\": [\"KnownProfiles\", \"ProfileDefinition\"], \"azure.profiles.multiapiclient\": [\"MultiApiClientMixin\"]}, \"local\": {\"._configuration\": [\"SubscriptionClientConfiguration\"], \".._serialization\": [\"Deserializer\", \"Serializer\"], \"._operations_mixin\": [\"SubscriptionClientOperationsMixin\"]}}, \"typing\": {\"azurecore\": {\"azure.core.credentials\": [\"TokenCredential\"]}}}", + "async_imports": "{\"conditional\": {\"stdlib\": {\"typing\": [\"Any\", \"Optional\"]}}, \"regular\": {\"azurecore\": {\"azure.mgmt.core\": [\"AsyncARMPipelineClient\"], \"azure.profiles\": [\"KnownProfiles\", \"ProfileDefinition\"], \"azure.profiles.multiapiclient\": [\"MultiApiClientMixin\"]}, \"local\": {\"._configuration\": [\"SubscriptionClientConfiguration\"], \"..._serialization\": [\"Deserializer\", \"Serializer\"], \"._operations_mixin\": [\"SubscriptionClientOperationsMixin\"]}}, \"typing\": {\"azurecore\": {\"azure.core.credentials_async\": [\"AsyncTokenCredential\"]}}}" }, "global_parameters": { "sync": { "credential": { - "signature": "credential, # type: \"TokenCredential\"", - "description": "Credential needed for the client to connect to Azure.", + "signature": "credential: \"TokenCredential\",", + "description": "Credential needed for the client to connect to Azure. Required.", "docstring_type": "~azure.core.credentials.TokenCredential", "required": true } @@ -25,7 +25,7 @@ "async": { "credential": { "signature": "credential: \"AsyncTokenCredential\",", - "description": "Credential needed for the client to connect to Azure.", + "description": "Credential needed for the client to connect to Azure. Required.", "docstring_type": "~azure.core.credentials_async.AsyncTokenCredential", "required": true } @@ -42,7 +42,7 @@ "required": false }, "base_url": { - "signature": "base_url=\"https://management.azure.com\", # type: str", + "signature": "base_url: str = \"https://management.azure.com\",", "description": "Service URL", "docstring_type": "str", "required": false @@ -90,20 +90,21 @@ "tenants": "TenantsOperations" }, "operation_mixins": { - "sync_imports": "{\"conditional\": {\"stdlib\": {\"typing\": [\"Any\", \"Optional\"]}}}", - "async_imports": "{\"conditional\": {\"stdlib\": {\"typing\": [\"Any\", \"Optional\"]}}}", + "sync_imports": "{\"conditional\": {\"stdlib\": {\"typing\": [\"Any\"]}}, \"regular\": {\"local\": {\".\": [[\"models\", \"_models\"]]}, \"stdlib\": {\"typing\": [\"IO\", \"Optional\", \"Union\"]}}}", + "async_imports": "{\"conditional\": {\"stdlib\": {\"typing\": [\"Any\"]}}, \"regular\": {\"local\": {\"..\": [[\"models\", \"_models\"]]}, \"stdlib\": {\"typing\": [\"IO\", \"Optional\", \"Union\"]}}}", "operations": { "check_resource_name" : { "sync": { - "signature": "def check_resource_name(\n self,\n resource_name_definition=None, # type: Optional[\"_models.ResourceName\"]\n **kwargs # type: Any\n):\n # type: (...) -\u003e \"_models.CheckResourceNameResult\"\n", - "doc": "\"\"\"Checks resource name validity.\n\nA resource name is valid if it is not a reserved word, does not contains a reserved word and\ndoes not start with a reserved word.\n\n:param resource_name_definition: Resource object with values for resource name and resource\n type. Default value is None.\n:type resource_name_definition:\n ~azure.mgmt.resource.subscriptions.v2016_06_01.models.ResourceName\n:keyword callable cls: A custom type or function that will be passed the direct response\n:return: CheckResourceNameResult, or the result of cls(response)\n:rtype: ~azure.mgmt.resource.subscriptions.v2016_06_01.models.CheckResourceNameResult\n:raises: ~azure.core.exceptions.HttpResponseError\n\"\"\"" + "signature": "def check_resource_name(\n self,\n resource_name_definition: Optional[Union[_models.ResourceName, IO]] = None,\n **kwargs: Any\n) -\u003e _models.CheckResourceNameResult:\n", + "doc": "\"\"\"Checks resource name validity.\n\nA resource name is valid if it is not a reserved word, does not contains a reserved word and\ndoes not start with a reserved word.\n\n:param resource_name_definition: Resource object with values for resource name and resource\n type. Is either a model type or a IO type. Default value is None.\n:type resource_name_definition:\n ~azure.mgmt.resource.subscriptions.v2016_06_01.models.ResourceName or IO\n:keyword content_type: Body Parameter content-type. Known values are: \u0027application/json\u0027.\n Default value is None.\n:paramtype content_type: str\n:keyword callable cls: A custom type or function that will be passed the direct response\n:return: CheckResourceNameResult or the result of cls(response)\n:rtype: ~azure.mgmt.resource.subscriptions.v2016_06_01.models.CheckResourceNameResult\n:raises ~azure.core.exceptions.HttpResponseError:\n\"\"\"", + "call": "resource_name_definition, **kwargs" }, "async": { "coroutine": true, - "signature": "async def check_resource_name(\n self,\n resource_name_definition: Optional[\"_models.ResourceName\"] = None,\n **kwargs: Any\n) -\u003e \"_models.CheckResourceNameResult\":\n", - "doc": "\"\"\"Checks resource name validity.\n\nA resource name is valid if it is not a reserved word, does not contains a reserved word and\ndoes not start with a reserved word.\n\n:param resource_name_definition: Resource object with values for resource name and resource\n type. Default value is None.\n:type resource_name_definition:\n ~azure.mgmt.resource.subscriptions.v2016_06_01.models.ResourceName\n:keyword callable cls: A custom type or function that will be passed the direct response\n:return: CheckResourceNameResult, or the result of cls(response)\n:rtype: ~azure.mgmt.resource.subscriptions.v2016_06_01.models.CheckResourceNameResult\n:raises: ~azure.core.exceptions.HttpResponseError\n\"\"\"" - }, - "call": "resource_name_definition" + "signature": "async def check_resource_name(\n self,\n resource_name_definition: Optional[Union[_models.ResourceName, IO]] = None,\n **kwargs: Any\n) -\u003e _models.CheckResourceNameResult:\n", + "doc": "\"\"\"Checks resource name validity.\n\nA resource name is valid if it is not a reserved word, does not contains a reserved word and\ndoes not start with a reserved word.\n\n:param resource_name_definition: Resource object with values for resource name and resource\n type. Is either a model type or a IO type. Default value is None.\n:type resource_name_definition:\n ~azure.mgmt.resource.subscriptions.v2016_06_01.models.ResourceName or IO\n:keyword content_type: Body Parameter content-type. Known values are: \u0027application/json\u0027.\n Default value is None.\n:paramtype content_type: str\n:keyword callable cls: A custom type or function that will be passed the direct response\n:return: CheckResourceNameResult or the result of cls(response)\n:rtype: ~azure.mgmt.resource.subscriptions.v2016_06_01.models.CheckResourceNameResult\n:raises ~azure.core.exceptions.HttpResponseError:\n\"\"\"", + "call": "resource_name_definition, **kwargs" + } } } } diff --git a/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/subscriptions/v2016_06_01/_patch.py b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/subscriptions/v2016_06_01/_patch.py index 74e48ecd07cf3..f99e77fef9861 100644 --- a/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/subscriptions/v2016_06_01/_patch.py +++ b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/subscriptions/v2016_06_01/_patch.py @@ -28,4 +28,4 @@ # This file is used for handwritten extensions to the generated code. Example: # https://github.com/Azure/azure-sdk-for-python/blob/main/doc/dev/customize_code/how-to-patch-sdk-code.md def patch_sdk(): - pass \ No newline at end of file + pass diff --git a/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/subscriptions/v2016_06_01/_subscription_client.py b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/subscriptions/v2016_06_01/_subscription_client.py index 8cfea7e138572..05ad1b2cdc7c0 100644 --- a/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/subscriptions/v2016_06_01/_subscription_client.py +++ b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/subscriptions/v2016_06_01/_subscription_client.py @@ -9,12 +9,11 @@ from copy import deepcopy from typing import Any, TYPE_CHECKING -from msrest import Deserializer, Serializer - from azure.core.rest import HttpRequest, HttpResponse from azure.mgmt.core import ARMPipelineClient from . import models +from .._serialization import Deserializer, Serializer from ._configuration import SubscriptionClientConfiguration from .operations import Operations, SubscriptionClientOperationsMixin, SubscriptionsOperations, TenantsOperations @@ -22,7 +21,8 @@ # pylint: disable=unused-import,ungrouped-imports from azure.core.credentials import TokenCredential -class SubscriptionClient(SubscriptionClientOperationsMixin): + +class SubscriptionClient(SubscriptionClientOperationsMixin): # pylint: disable=client-accepts-api-version-keyword """All resource groups and resources exist within subscriptions. These operation enable you get information about your subscriptions and tenants. A tenant is a dedicated instance of Azure Active Directory (Azure AD) for your organization. @@ -34,7 +34,7 @@ class SubscriptionClient(SubscriptionClientOperationsMixin): azure.mgmt.resource.subscriptions.v2016_06_01.operations.SubscriptionsOperations :ivar tenants: TenantsOperations operations :vartype tenants: azure.mgmt.resource.subscriptions.v2016_06_01.operations.TenantsOperations - :param credential: Credential needed for the client to connect to Azure. + :param credential: Credential needed for the client to connect to Azure. Required. :type credential: ~azure.core.credentials.TokenCredential :param base_url: Service URL. Default value is "https://management.azure.com". :type base_url: str @@ -44,10 +44,7 @@ class SubscriptionClient(SubscriptionClientOperationsMixin): """ def __init__( - self, - credential: "TokenCredential", - base_url: str = "https://management.azure.com", - **kwargs: Any + self, credential: "TokenCredential", base_url: str = "https://management.azure.com", **kwargs: Any ) -> None: self._config = SubscriptionClientConfiguration(credential=credential, **kwargs) self._client = ARMPipelineClient(base_url=base_url, config=self._config, **kwargs) @@ -60,12 +57,7 @@ def __init__( self.subscriptions = SubscriptionsOperations(self._client, self._config, self._serialize, self._deserialize) self.tenants = TenantsOperations(self._client, self._config, self._serialize, self._deserialize) - - def _send_request( - self, - request: HttpRequest, - **kwargs: Any - ) -> HttpResponse: + def _send_request(self, request: HttpRequest, **kwargs: Any) -> HttpResponse: """Runs the network request through the client's chained policies. >>> from azure.core.rest import HttpRequest @@ -74,7 +66,7 @@ def _send_request( >>> response = client._send_request(request) - For more information on this code flow, see https://aka.ms/azsdk/python/protocol/quickstart + For more information on this code flow, see https://aka.ms/azsdk/dpcodegen/python/send_request :param request: The network request you want to make. Required. :type request: ~azure.core.rest.HttpRequest diff --git a/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/subscriptions/v2016_06_01/_vendor.py b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/subscriptions/v2016_06_01/_vendor.py index 138f663c53a4e..71418db2686e7 100644 --- a/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/subscriptions/v2016_06_01/_vendor.py +++ b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/subscriptions/v2016_06_01/_vendor.py @@ -5,8 +5,20 @@ # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- +from abc import ABC +from typing import TYPE_CHECKING + from azure.core.pipeline.transport import HttpRequest +from ._configuration import SubscriptionClientConfiguration + +if TYPE_CHECKING: + # pylint: disable=unused-import,ungrouped-imports + from azure.core import PipelineClient + + from .._serialization import Deserializer, Serializer + + def _convert_request(request, files=None): data = request.content if not files else None request = HttpRequest(method=request.method, url=request.url, headers=request.headers, data=data) @@ -14,6 +26,7 @@ def _convert_request(request, files=None): request.set_formdata_body(files) return request + def _format_url_section(template, **kwargs): components = template.split("/") while components: @@ -21,7 +34,14 @@ def _format_url_section(template, **kwargs): 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 - ] + components = [c for c in formatted_components if "{}".format(key.args[0]) not in c] template = "/".join(components) + + +class MixinABC(ABC): + """DO NOT use this class. It is for internal typing use only.""" + + _client: "PipelineClient" + _config: SubscriptionClientConfiguration + _serialize: "Serializer" + _deserialize: "Deserializer" diff --git a/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/subscriptions/v2016_06_01/_version.py b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/subscriptions/v2016_06_01/_version.py index a012ac01c480c..e5754a47ce68f 100644 --- a/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/subscriptions/v2016_06_01/_version.py +++ b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/subscriptions/v2016_06_01/_version.py @@ -6,4 +6,4 @@ # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -VERSION = "21.1.0" +VERSION = "1.0.0b1" diff --git a/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/subscriptions/v2016_06_01/aio/__init__.py b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/subscriptions/v2016_06_01/aio/__init__.py index e95939087d442..5cfdafc74d6db 100644 --- a/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/subscriptions/v2016_06_01/aio/__init__.py +++ b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/subscriptions/v2016_06_01/aio/__init__.py @@ -7,9 +7,15 @@ # -------------------------------------------------------------------------- from ._subscription_client import SubscriptionClient -__all__ = ['SubscriptionClient'] -# `._patch.py` is used for handwritten extensions to the generated code -# Example: https://github.com/Azure/azure-sdk-for-python/blob/main/doc/dev/customize_code/how-to-patch-sdk-code.md -from ._patch import patch_sdk -patch_sdk() +try: + from ._patch import __all__ as _patch_all + from ._patch import * # type: ignore # pylint: disable=unused-wildcard-import +except ImportError: + _patch_all = [] +from ._patch import patch_sdk as _patch_sdk + +__all__ = ["SubscriptionClient"] +__all__.extend([p for p in _patch_all if p not in __all__]) + +_patch_sdk() diff --git a/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/subscriptions/v2016_06_01/aio/_configuration.py b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/subscriptions/v2016_06_01/aio/_configuration.py index de30c34e8a1cc..2423fe5024090 100644 --- a/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/subscriptions/v2016_06_01/aio/_configuration.py +++ b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/subscriptions/v2016_06_01/aio/_configuration.py @@ -25,42 +25,37 @@ class SubscriptionClientConfiguration(Configuration): # pylint: disable=too-man Note that all parameters used to create this instance are saved as instance attributes. - :param credential: Credential needed for the client to connect to Azure. + :param credential: Credential needed for the client to connect to Azure. Required. :type credential: ~azure.core.credentials_async.AsyncTokenCredential :keyword api_version: Api Version. Default value is "2016-06-01". Note that overriding this default value may result in unsupported behavior. :paramtype api_version: str """ - def __init__( - self, - credential: "AsyncTokenCredential", - **kwargs: Any - ) -> None: + def __init__(self, credential: "AsyncTokenCredential", **kwargs: Any) -> None: super(SubscriptionClientConfiguration, self).__init__(**kwargs) - api_version = kwargs.pop('api_version', "2016-06-01") # type: str + api_version = kwargs.pop("api_version", "2016-06-01") # type: str if credential is None: raise ValueError("Parameter 'credential' must not be None.") self.credential = credential self.api_version = api_version - self.credential_scopes = kwargs.pop('credential_scopes', ['https://management.azure.com/.default']) - kwargs.setdefault('sdk_moniker', 'mgmt-resource/{}'.format(VERSION)) + self.credential_scopes = kwargs.pop("credential_scopes", ["https://management.azure.com/.default"]) + kwargs.setdefault("sdk_moniker", "mgmt-resource/{}".format(VERSION)) self._configure(**kwargs) - 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) - self.logging_policy = kwargs.get('logging_policy') or policies.NetworkTraceLoggingPolicy(**kwargs) - self.http_logging_policy = kwargs.get('http_logging_policy') or ARMHttpLoggingPolicy(**kwargs) - self.retry_policy = kwargs.get('retry_policy') or policies.AsyncRetryPolicy(**kwargs) - self.custom_hook_policy = kwargs.get('custom_hook_policy') or policies.CustomHookPolicy(**kwargs) - self.redirect_policy = kwargs.get('redirect_policy') or policies.AsyncRedirectPolicy(**kwargs) - self.authentication_policy = kwargs.get('authentication_policy') + 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) + self.logging_policy = kwargs.get("logging_policy") or policies.NetworkTraceLoggingPolicy(**kwargs) + self.http_logging_policy = kwargs.get("http_logging_policy") or ARMHttpLoggingPolicy(**kwargs) + self.retry_policy = kwargs.get("retry_policy") or policies.AsyncRetryPolicy(**kwargs) + self.custom_hook_policy = kwargs.get("custom_hook_policy") or policies.CustomHookPolicy(**kwargs) + self.redirect_policy = kwargs.get("redirect_policy") or policies.AsyncRedirectPolicy(**kwargs) + self.authentication_policy = kwargs.get("authentication_policy") if self.credential and not self.authentication_policy: - self.authentication_policy = AsyncARMChallengeAuthenticationPolicy(self.credential, *self.credential_scopes, **kwargs) + self.authentication_policy = AsyncARMChallengeAuthenticationPolicy( + self.credential, *self.credential_scopes, **kwargs + ) diff --git a/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/subscriptions/v2016_06_01/aio/_patch.py b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/subscriptions/v2016_06_01/aio/_patch.py index 74e48ecd07cf3..f99e77fef9861 100644 --- a/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/subscriptions/v2016_06_01/aio/_patch.py +++ b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/subscriptions/v2016_06_01/aio/_patch.py @@ -28,4 +28,4 @@ # This file is used for handwritten extensions to the generated code. Example: # https://github.com/Azure/azure-sdk-for-python/blob/main/doc/dev/customize_code/how-to-patch-sdk-code.md def patch_sdk(): - pass \ No newline at end of file + pass diff --git a/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/subscriptions/v2016_06_01/aio/_subscription_client.py b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/subscriptions/v2016_06_01/aio/_subscription_client.py index 16e8fb5bde79f..d2cf894b498c2 100644 --- a/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/subscriptions/v2016_06_01/aio/_subscription_client.py +++ b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/subscriptions/v2016_06_01/aio/_subscription_client.py @@ -9,12 +9,11 @@ from copy import deepcopy from typing import Any, Awaitable, TYPE_CHECKING -from msrest import Deserializer, Serializer - from azure.core.rest import AsyncHttpResponse, HttpRequest from azure.mgmt.core import AsyncARMPipelineClient from .. import models +from ..._serialization import Deserializer, Serializer from ._configuration import SubscriptionClientConfiguration from .operations import Operations, SubscriptionClientOperationsMixin, SubscriptionsOperations, TenantsOperations @@ -22,7 +21,8 @@ # pylint: disable=unused-import,ungrouped-imports from azure.core.credentials_async import AsyncTokenCredential -class SubscriptionClient(SubscriptionClientOperationsMixin): + +class SubscriptionClient(SubscriptionClientOperationsMixin): # pylint: disable=client-accepts-api-version-keyword """All resource groups and resources exist within subscriptions. These operation enable you get information about your subscriptions and tenants. A tenant is a dedicated instance of Azure Active Directory (Azure AD) for your organization. @@ -35,7 +35,7 @@ class SubscriptionClient(SubscriptionClientOperationsMixin): :ivar tenants: TenantsOperations operations :vartype tenants: azure.mgmt.resource.subscriptions.v2016_06_01.aio.operations.TenantsOperations - :param credential: Credential needed for the client to connect to Azure. + :param credential: Credential needed for the client to connect to Azure. Required. :type credential: ~azure.core.credentials_async.AsyncTokenCredential :param base_url: Service URL. Default value is "https://management.azure.com". :type base_url: str @@ -45,10 +45,7 @@ class SubscriptionClient(SubscriptionClientOperationsMixin): """ def __init__( - self, - credential: "AsyncTokenCredential", - base_url: str = "https://management.azure.com", - **kwargs: Any + self, credential: "AsyncTokenCredential", base_url: str = "https://management.azure.com", **kwargs: Any ) -> None: self._config = SubscriptionClientConfiguration(credential=credential, **kwargs) self._client = AsyncARMPipelineClient(base_url=base_url, config=self._config, **kwargs) @@ -61,12 +58,7 @@ def __init__( self.subscriptions = SubscriptionsOperations(self._client, self._config, self._serialize, self._deserialize) self.tenants = TenantsOperations(self._client, self._config, self._serialize, self._deserialize) - - def _send_request( - self, - request: HttpRequest, - **kwargs: Any - ) -> Awaitable[AsyncHttpResponse]: + def _send_request(self, request: HttpRequest, **kwargs: Any) -> Awaitable[AsyncHttpResponse]: """Runs the network request through the client's chained policies. >>> from azure.core.rest import HttpRequest @@ -75,7 +67,7 @@ def _send_request( >>> response = await client._send_request(request) - For more information on this code flow, see https://aka.ms/azsdk/python/protocol/quickstart + For more information on this code flow, see https://aka.ms/azsdk/dpcodegen/python/send_request :param request: The network request you want to make. Required. :type request: ~azure.core.rest.HttpRequest diff --git a/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/subscriptions/v2016_06_01/aio/_vendor.py b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/subscriptions/v2016_06_01/aio/_vendor.py new file mode 100644 index 0000000000000..3c42eb44b5a3e --- /dev/null +++ b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/subscriptions/v2016_06_01/aio/_vendor.py @@ -0,0 +1,28 @@ +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- + +from abc import ABC +from typing import TYPE_CHECKING + +from azure.core.pipeline.transport import HttpRequest + +from ._configuration import SubscriptionClientConfiguration + +if TYPE_CHECKING: + # pylint: disable=unused-import,ungrouped-imports + from azure.core import AsyncPipelineClient + + from ..._serialization import Deserializer, Serializer + + +class MixinABC(ABC): + """DO NOT use this class. It is for internal typing use only.""" + + _client: "AsyncPipelineClient" + _config: SubscriptionClientConfiguration + _serialize: "Serializer" + _deserialize: "Deserializer" diff --git a/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/subscriptions/v2016_06_01/aio/operations/__init__.py b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/subscriptions/v2016_06_01/aio/operations/__init__.py index 437b49e23548f..1066cb67ea911 100644 --- a/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/subscriptions/v2016_06_01/aio/operations/__init__.py +++ b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/subscriptions/v2016_06_01/aio/operations/__init__.py @@ -11,9 +11,15 @@ from ._operations import TenantsOperations from ._operations import SubscriptionClientOperationsMixin +from ._patch import __all__ as _patch_all +from ._patch import * # type: ignore # pylint: disable=unused-wildcard-import +from ._patch import patch_sdk as _patch_sdk + __all__ = [ - 'Operations', - 'SubscriptionsOperations', - 'TenantsOperations', - 'SubscriptionClientOperationsMixin', + "Operations", + "SubscriptionsOperations", + "TenantsOperations", + "SubscriptionClientOperationsMixin", ] +__all__.extend([p for p in _patch_all if p not in __all__]) +_patch_sdk() diff --git a/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/subscriptions/v2016_06_01/aio/operations/_operations.py b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/subscriptions/v2016_06_01/aio/operations/_operations.py index c1f8057dc540f..3502e04fe4ec7 100644 --- a/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/subscriptions/v2016_06_01/aio/operations/_operations.py +++ b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/subscriptions/v2016_06_01/aio/operations/_operations.py @@ -6,82 +6,106 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -from typing import Any, AsyncIterable, Callable, Dict, Optional, TypeVar +from typing import Any, AsyncIterable, Callable, Dict, IO, Optional, TypeVar, Union, overload +from urllib.parse import parse_qs, urljoin, urlparse from azure.core.async_paging import AsyncItemPaged, AsyncList -from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error +from azure.core.exceptions import ( + ClientAuthenticationError, + HttpResponseError, + ResourceExistsError, + ResourceNotFoundError, + ResourceNotModifiedError, + map_error, +) from azure.core.pipeline import PipelineResponse from azure.core.pipeline.transport import AsyncHttpResponse from azure.core.rest import HttpRequest from azure.core.tracing.decorator import distributed_trace from azure.core.tracing.decorator_async import distributed_trace_async +from azure.core.utils import case_insensitive_dict from azure.mgmt.core.exceptions import ARMErrorFormat from ... import models as _models from ..._vendor import _convert_request -from ...operations._operations import build_check_resource_name_request, build_operations_list_request, build_subscriptions_check_zone_peers_request, build_subscriptions_get_request, build_subscriptions_list_locations_request, build_subscriptions_list_request, build_tenants_list_request -T = TypeVar('T') +from ...operations._operations import ( + build_check_resource_name_request, + build_operations_list_request, + build_subscriptions_check_zone_peers_request, + build_subscriptions_get_request, + build_subscriptions_list_locations_request, + build_subscriptions_list_request, + build_tenants_list_request, +) +from .._vendor import MixinABC + +T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] -class Operations: - """Operations async operations. - You should not instantiate this class directly. Instead, you should create a Client instance that - instantiates it for you and attaches it as an attribute. +class Operations: + """ + .. warning:: + **DO NOT** instantiate this class directly. - :ivar models: Alias to model classes used in this operation group. - :type models: ~azure.mgmt.resource.subscriptions.v2016_06_01.models - :param client: Client for service requests. - :param config: Configuration of service client. - :param serializer: An object model serializer. - :param deserializer: An object model deserializer. + Instead, you should access the following operations through + :class:`~azure.mgmt.resource.subscriptions.v2016_06_01.aio.SubscriptionClient`'s + :attr:`operations` attribute. """ models = _models - def __init__(self, client, config, serializer, deserializer) -> None: - self._client = client - self._serialize = serializer - self._deserialize = deserializer - self._config = config + def __init__(self, *args, **kwargs) -> None: + input_args = list(args) + self._client = input_args.pop(0) if input_args else kwargs.pop("client") + self._config = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") @distributed_trace - def list( - self, - **kwargs: Any - ) -> AsyncIterable["_models.OperationListResult"]: + def list(self, **kwargs: Any) -> AsyncIterable["_models.Operation"]: """Lists all of the available Microsoft.Resources REST API operations. :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either OperationListResult or the result of cls(response) + :return: An iterator like instance of either Operation or the result of cls(response) :rtype: - ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.resource.subscriptions.v2016_06_01.models.OperationListResult] - :raises: ~azure.core.exceptions.HttpResponseError + ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.resource.subscriptions.v2016_06_01.models.Operation] + :raises ~azure.core.exceptions.HttpResponseError: """ - api_version = kwargs.pop('api_version', "2016-06-01") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2016-06-01")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[_models.OperationListResult] - cls = kwargs.pop('cls', None) # type: ClsType["_models.OperationListResult"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) + def prepare_request(next_link=None): if not next_link: - + request = build_operations_list_request( api_version=api_version, - template_url=self.list.metadata['url'], + template_url=self.list.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore else: - - request = build_operations_list_request( - template_url=next_link, - ) + # make call to next link with the client's api-version + _parsed_next_link = urlparse(next_link) + _next_request_params = case_insensitive_dict(parse_qs(_parsed_next_link.query)) + _next_request_params["api-version"] = self._config.api_version + request = HttpRequest("GET", urljoin(next_link, _parsed_next_link.path), params=_next_request_params) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore request.method = "GET" return request @@ -95,10 +119,8 @@ async def extract_data(pipeline_response): async def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) response = pipeline_response.http_response @@ -108,78 +130,80 @@ async def get_next(next_link=None): return pipeline_response + return AsyncItemPaged(get_next, extract_data) + + list.metadata = {"url": "/providers/Microsoft.Resources/operations"} # type: ignore - return AsyncItemPaged( - get_next, extract_data - ) - list.metadata = {'url': "/providers/Microsoft.Resources/operations"} # type: ignore -class SubscriptionsOperations: - """SubscriptionsOperations async operations. - You should not instantiate this class directly. Instead, you should create a Client instance that - instantiates it for you and attaches it as an attribute. +class SubscriptionsOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. - :ivar models: Alias to model classes used in this operation group. - :type models: ~azure.mgmt.resource.subscriptions.v2016_06_01.models - :param client: Client for service requests. - :param config: Configuration of service client. - :param serializer: An object model serializer. - :param deserializer: An object model deserializer. + Instead, you should access the following operations through + :class:`~azure.mgmt.resource.subscriptions.v2016_06_01.aio.SubscriptionClient`'s + :attr:`subscriptions` attribute. """ models = _models - def __init__(self, client, config, serializer, deserializer) -> None: - self._client = client - self._serialize = serializer - self._deserialize = deserializer - self._config = config + def __init__(self, *args, **kwargs) -> None: + input_args = list(args) + self._client = input_args.pop(0) if input_args else kwargs.pop("client") + self._config = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") @distributed_trace - def list_locations( - self, - subscription_id: str, - **kwargs: Any - ) -> AsyncIterable["_models.LocationListResult"]: + def list_locations(self, subscription_id: str, **kwargs: Any) -> AsyncIterable["_models.Location"]: """Gets all available geo-locations. This operation provides all the locations that are available for resource providers; however, each resource provider may support a subset of this list. - :param subscription_id: The ID of the target subscription. + :param subscription_id: The ID of the target subscription. Required. :type subscription_id: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either LocationListResult or the result of cls(response) + :return: An iterator like instance of either Location or the result of cls(response) :rtype: - ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.resource.subscriptions.v2016_06_01.models.LocationListResult] - :raises: ~azure.core.exceptions.HttpResponseError + ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.resource.subscriptions.v2016_06_01.models.Location] + :raises ~azure.core.exceptions.HttpResponseError: """ - api_version = kwargs.pop('api_version', "2016-06-01") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2016-06-01")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[_models.LocationListResult] - cls = kwargs.pop('cls', None) # type: ClsType["_models.LocationListResult"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) + def prepare_request(next_link=None): if not next_link: - + request = build_subscriptions_list_locations_request( subscription_id=subscription_id, api_version=api_version, - template_url=self.list_locations.metadata['url'], + template_url=self.list_locations.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore else: - - request = build_subscriptions_list_locations_request( - subscription_id=subscription_id, - template_url=next_link, - ) + # make call to next link with the client's api-version + _parsed_next_link = urlparse(next_link) + _next_request_params = case_insensitive_dict(parse_qs(_parsed_next_link.query)) + _next_request_params["api-version"] = self._config.api_version + request = HttpRequest("GET", urljoin(next_link, _parsed_next_link.path), params=_next_request_params) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore request.method = "GET" return request @@ -193,10 +217,8 @@ async def extract_data(pipeline_response): async def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) response = pipeline_response.http_response @@ -206,103 +228,108 @@ async def get_next(next_link=None): return pipeline_response + return AsyncItemPaged(get_next, extract_data) - return AsyncItemPaged( - get_next, extract_data - ) - list_locations.metadata = {'url': "/subscriptions/{subscriptionId}/locations"} # type: ignore + list_locations.metadata = {"url": "/subscriptions/{subscriptionId}/locations"} # type: ignore @distributed_trace_async - async def get( - self, - subscription_id: str, - **kwargs: Any - ) -> "_models.Subscription": + async def get(self, subscription_id: str, **kwargs: Any) -> _models.Subscription: """Gets details about a specified subscription. - :param subscription_id: The ID of the target subscription. + :param subscription_id: The ID of the target subscription. Required. :type subscription_id: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: Subscription, or the result of cls(response) + :return: Subscription or the result of cls(response) :rtype: ~azure.mgmt.resource.subscriptions.v2016_06_01.models.Subscription - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.Subscription"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) - api_version = kwargs.pop('api_version', "2016-06-01") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2016-06-01")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[_models.Subscription] - request = build_subscriptions_get_request( subscription_id=subscription_id, api_version=api_version, - template_url=self.get.metadata['url'], + template_url=self.get.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) - deserialized = self._deserialize('Subscription', pipeline_response) + deserialized = self._deserialize("Subscription", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - get.metadata = {'url': "/subscriptions/{subscriptionId}"} # type: ignore - + get.metadata = {"url": "/subscriptions/{subscriptionId}"} # type: ignore @distributed_trace - def list( - self, - **kwargs: Any - ) -> AsyncIterable["_models.SubscriptionListResult"]: + def list(self, **kwargs: Any) -> AsyncIterable["_models.Subscription"]: """Gets all subscriptions for a tenant. :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either SubscriptionListResult or the result of - cls(response) + :return: An iterator like instance of either Subscription or the result of cls(response) :rtype: - ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.resource.subscriptions.v2016_06_01.models.SubscriptionListResult] - :raises: ~azure.core.exceptions.HttpResponseError + ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.resource.subscriptions.v2016_06_01.models.Subscription] + :raises ~azure.core.exceptions.HttpResponseError: """ - api_version = kwargs.pop('api_version', "2016-06-01") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2016-06-01")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[_models.SubscriptionListResult] - cls = kwargs.pop('cls', None) # type: ClsType["_models.SubscriptionListResult"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) + def prepare_request(next_link=None): if not next_link: - + request = build_subscriptions_list_request( api_version=api_version, - template_url=self.list.metadata['url'], + template_url=self.list.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore else: - - request = build_subscriptions_list_request( - template_url=next_link, - ) + # make call to next link with the client's api-version + _parsed_next_link = urlparse(next_link) + _next_request_params = case_insensitive_dict(parse_qs(_parsed_next_link.query)) + _next_request_params["api-version"] = self._config.api_version + request = HttpRequest("GET", urljoin(next_link, _parsed_next_link.path), params=_next_request_params) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore request.method = "GET" return request @@ -316,10 +343,8 @@ async def extract_data(pipeline_response): async def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) response = pipeline_response.http_response @@ -329,56 +354,113 @@ async def get_next(next_link=None): return pipeline_response + return AsyncItemPaged(get_next, extract_data) - return AsyncItemPaged( - get_next, extract_data - ) - list.metadata = {'url': "/subscriptions"} # type: ignore + list.metadata = {"url": "/subscriptions"} # type: ignore - @distributed_trace_async + @overload async def check_zone_peers( self, subscription_id: str, - parameters: "_models.CheckZonePeersRequest", + parameters: _models.CheckZonePeersRequest, + *, + content_type: str = "application/json", **kwargs: Any - ) -> "_models.CheckZonePeersResult": + ) -> _models.CheckZonePeersResult: """Compares a subscriptions logical zone mapping. - :param subscription_id: The ID of the target subscription. + :param subscription_id: The ID of the target subscription. Required. :type subscription_id: str - :param parameters: Parameters for checking zone peers. + :param parameters: Parameters for checking zone peers. Required. :type parameters: ~azure.mgmt.resource.subscriptions.v2016_06_01.models.CheckZonePeersRequest + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: CheckZonePeersResult, or the result of cls(response) + :return: CheckZonePeersResult or the result of cls(response) :rtype: ~azure.mgmt.resource.subscriptions.v2016_06_01.models.CheckZonePeersResult - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + async def check_zone_peers( + self, subscription_id: str, parameters: IO, *, content_type: str = "application/json", **kwargs: Any + ) -> _models.CheckZonePeersResult: + """Compares a subscriptions logical zone mapping. + + :param subscription_id: The ID of the target subscription. Required. + :type subscription_id: str + :param parameters: Parameters for checking zone peers. Required. + :type parameters: IO + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: CheckZonePeersResult or the result of cls(response) + :rtype: ~azure.mgmt.resource.subscriptions.v2016_06_01.models.CheckZonePeersResult + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace_async + async def check_zone_peers( + self, subscription_id: str, parameters: Union[_models.CheckZonePeersRequest, IO], **kwargs: Any + ) -> _models.CheckZonePeersResult: + """Compares a subscriptions logical zone mapping. + + :param subscription_id: The ID of the target subscription. Required. + :type subscription_id: str + :param parameters: Parameters for checking zone peers. Is either a model type or a IO type. + Required. + :type parameters: ~azure.mgmt.resource.subscriptions.v2016_06_01.models.CheckZonePeersRequest + or IO + :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. + Default value is None. + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: CheckZonePeersResult or the result of cls(response) + :rtype: ~azure.mgmt.resource.subscriptions.v2016_06_01.models.CheckZonePeersResult + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.CheckZonePeersResult"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) - api_version = kwargs.pop('api_version', "2016-06-01") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - _json = self._serialize.body(parameters, 'CheckZonePeersRequest') + api_version = kwargs.pop("api_version", _params.pop("api-version", "2016-06-01")) # type: str + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.CheckZonePeersResult] + + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(parameters, (IO, bytes)): + _content = parameters + else: + _json = self._serialize.body(parameters, "CheckZonePeersRequest") request = build_subscriptions_check_zone_peers_request( subscription_id=subscription_id, api_version=api_version, content_type=content_type, json=_json, - template_url=self.check_zone_peers.metadata['url'], + content=_content, + template_url=self.check_zone_peers.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200]: @@ -386,74 +468,79 @@ async def check_zone_peers( error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - deserialized = self._deserialize('CheckZonePeersResult', pipeline_response) + deserialized = self._deserialize("CheckZonePeersResult", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - check_zone_peers.metadata = {'url': "/subscriptions/{subscriptionId}/providers/Microsoft.Resources/checkZonePeers/"} # type: ignore + check_zone_peers.metadata = {"url": "/subscriptions/{subscriptionId}/providers/Microsoft.Resources/checkZonePeers/"} # type: ignore -class TenantsOperations: - """TenantsOperations async operations. - You should not instantiate this class directly. Instead, you should create a Client instance that - instantiates it for you and attaches it as an attribute. +class TenantsOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. - :ivar models: Alias to model classes used in this operation group. - :type models: ~azure.mgmt.resource.subscriptions.v2016_06_01.models - :param client: Client for service requests. - :param config: Configuration of service client. - :param serializer: An object model serializer. - :param deserializer: An object model deserializer. + Instead, you should access the following operations through + :class:`~azure.mgmt.resource.subscriptions.v2016_06_01.aio.SubscriptionClient`'s + :attr:`tenants` attribute. """ models = _models - def __init__(self, client, config, serializer, deserializer) -> None: - self._client = client - self._serialize = serializer - self._deserialize = deserializer - self._config = config + def __init__(self, *args, **kwargs) -> None: + input_args = list(args) + self._client = input_args.pop(0) if input_args else kwargs.pop("client") + self._config = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") @distributed_trace - def list( - self, - **kwargs: Any - ) -> AsyncIterable["_models.TenantListResult"]: + def list(self, **kwargs: Any) -> AsyncIterable["_models.TenantIdDescription"]: """Gets the tenants for your account. :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either TenantListResult or the result of cls(response) + :return: An iterator like instance of either TenantIdDescription or the result of cls(response) :rtype: - ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.resource.subscriptions.v2016_06_01.models.TenantListResult] - :raises: ~azure.core.exceptions.HttpResponseError + ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.resource.subscriptions.v2016_06_01.models.TenantIdDescription] + :raises ~azure.core.exceptions.HttpResponseError: """ - api_version = kwargs.pop('api_version', "2016-06-01") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2016-06-01")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[_models.TenantListResult] - cls = kwargs.pop('cls', None) # type: ClsType["_models.TenantListResult"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) + def prepare_request(next_link=None): if not next_link: - + request = build_tenants_list_request( api_version=api_version, - template_url=self.list.metadata['url'], + template_url=self.list.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore else: - - request = build_tenants_list_request( - template_url=next_link, - ) + # make call to next link with the client's api-version + _parsed_next_link = urlparse(next_link) + _next_request_params = case_insensitive_dict(parse_qs(_parsed_next_link.query)) + _next_request_params["api-version"] = self._config.api_version + request = HttpRequest("GET", urljoin(next_link, _parsed_next_link.path), params=_next_request_params) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore request.method = "GET" return request @@ -467,10 +554,8 @@ async def extract_data(pipeline_response): async def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) response = pipeline_response.http_response @@ -480,19 +565,20 @@ async def get_next(next_link=None): return pipeline_response + return AsyncItemPaged(get_next, extract_data) - return AsyncItemPaged( - get_next, extract_data - ) - list.metadata = {'url': "/tenants"} # type: ignore -class SubscriptionClientOperationsMixin: + list.metadata = {"url": "/tenants"} # type: ignore - @distributed_trace_async + +class SubscriptionClientOperationsMixin(MixinABC): + @overload async def check_resource_name( self, - resource_name_definition: Optional["_models.ResourceName"] = None, + resource_name_definition: Optional[_models.ResourceName] = None, + *, + content_type: str = "application/json", **kwargs: Any - ) -> "_models.CheckResourceNameResult": + ) -> _models.CheckResourceNameResult: """Checks resource name validity. A resource name is valid if it is not a reserved word, does not contains a reserved word and @@ -502,39 +588,99 @@ async def check_resource_name( type. Default value is None. :type resource_name_definition: ~azure.mgmt.resource.subscriptions.v2016_06_01.models.ResourceName + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: CheckResourceNameResult, or the result of cls(response) + :return: CheckResourceNameResult or the result of cls(response) :rtype: ~azure.mgmt.resource.subscriptions.v2016_06_01.models.CheckResourceNameResult - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + async def check_resource_name( + self, resource_name_definition: Optional[IO] = None, *, content_type: str = "application/json", **kwargs: Any + ) -> _models.CheckResourceNameResult: + """Checks resource name validity. + + A resource name is valid if it is not a reserved word, does not contains a reserved word and + does not start with a reserved word. + + :param resource_name_definition: Resource object with values for resource name and resource + type. Default value is None. + :type resource_name_definition: IO + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: CheckResourceNameResult or the result of cls(response) + :rtype: ~azure.mgmt.resource.subscriptions.v2016_06_01.models.CheckResourceNameResult + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace_async + async def check_resource_name( + self, resource_name_definition: Optional[Union[_models.ResourceName, IO]] = None, **kwargs: Any + ) -> _models.CheckResourceNameResult: + """Checks resource name validity. + + A resource name is valid if it is not a reserved word, does not contains a reserved word and + does not start with a reserved word. + + :param resource_name_definition: Resource object with values for resource name and resource + type. Is either a model type or a IO type. Default value is None. + :type resource_name_definition: + ~azure.mgmt.resource.subscriptions.v2016_06_01.models.ResourceName or IO + :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. + Default value is None. + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: CheckResourceNameResult or the result of cls(response) + :rtype: ~azure.mgmt.resource.subscriptions.v2016_06_01.models.CheckResourceNameResult + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.CheckResourceNameResult"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', "2016-06-01") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + api_version = kwargs.pop("api_version", _params.pop("api-version", "2016-06-01")) # type: str + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.CheckResourceNameResult] - if resource_name_definition is not None: - _json = self._serialize.body(resource_name_definition, 'ResourceName') + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(resource_name_definition, (IO, bytes)): + _content = resource_name_definition else: - _json = None + if resource_name_definition is not None: + _json = self._serialize.body(resource_name_definition, "ResourceName") + else: + _json = None request = build_check_resource_name_request( api_version=api_version, content_type=content_type, json=_json, - template_url=self.check_resource_name.metadata['url'], + content=_content, + template_url=self.check_resource_name.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200]: @@ -542,12 +688,11 @@ async def check_resource_name( error = self._deserialize.failsafe_deserialize(_models.ErrorResponseAutoGenerated, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - deserialized = self._deserialize('CheckResourceNameResult', pipeline_response) + deserialized = self._deserialize("CheckResourceNameResult", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - check_resource_name.metadata = {'url': "/providers/Microsoft.Resources/checkResourceName"} # type: ignore - + check_resource_name.metadata = {"url": "/providers/Microsoft.Resources/checkResourceName"} # type: ignore diff --git a/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/subscriptions/v2016_06_01/aio/operations/_patch.py b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/subscriptions/v2016_06_01/aio/operations/_patch.py new file mode 100644 index 0000000000000..f7dd32510333d --- /dev/null +++ b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/subscriptions/v2016_06_01/aio/operations/_patch.py @@ -0,0 +1,20 @@ +# ------------------------------------ +# Copyright (c) Microsoft Corporation. +# Licensed under the MIT License. +# ------------------------------------ +"""Customize generated code here. + +Follow our quickstart for examples: https://aka.ms/azsdk/python/dpcodegen/python/customize +""" +from typing import List + +__all__: List[str] = [] # Add all objects you want publicly available to users at this package level + + +def patch_sdk(): + """Do not remove from this file. + + `patch_sdk` is a last resort escape hatch that allows you to do customizations + you can't accomplish using the techniques described in + https://aka.ms/azsdk/python/dpcodegen/python/customize + """ diff --git a/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/subscriptions/v2016_06_01/models/__init__.py b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/subscriptions/v2016_06_01/models/__init__.py index acb6558a04e63..53f378de6e79f 100644 --- a/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/subscriptions/v2016_06_01/models/__init__.py +++ b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/subscriptions/v2016_06_01/models/__init__.py @@ -28,36 +28,38 @@ from ._models_py3 import TenantIdDescription from ._models_py3 import TenantListResult - -from ._subscription_client_enums import ( - ResourceNameStatus, - SpendingLimit, - SubscriptionState, -) +from ._subscription_client_enums import ResourceNameStatus +from ._subscription_client_enums import SpendingLimit +from ._subscription_client_enums import SubscriptionState +from ._patch import __all__ as _patch_all +from ._patch import * # type: ignore # pylint: disable=unused-wildcard-import +from ._patch import patch_sdk as _patch_sdk __all__ = [ - 'AvailabilityZonePeers', - 'CheckResourceNameResult', - 'CheckZonePeersRequest', - 'CheckZonePeersResult', - 'ErrorAdditionalInfo', - 'ErrorDefinition', - 'ErrorDetail', - 'ErrorResponse', - 'ErrorResponseAutoGenerated', - 'Location', - 'LocationListResult', - 'Operation', - 'OperationDisplay', - 'OperationListResult', - 'Peers', - 'ResourceName', - 'Subscription', - 'SubscriptionListResult', - 'SubscriptionPolicies', - 'TenantIdDescription', - 'TenantListResult', - 'ResourceNameStatus', - 'SpendingLimit', - 'SubscriptionState', + "AvailabilityZonePeers", + "CheckResourceNameResult", + "CheckZonePeersRequest", + "CheckZonePeersResult", + "ErrorAdditionalInfo", + "ErrorDefinition", + "ErrorDetail", + "ErrorResponse", + "ErrorResponseAutoGenerated", + "Location", + "LocationListResult", + "Operation", + "OperationDisplay", + "OperationListResult", + "Peers", + "ResourceName", + "Subscription", + "SubscriptionListResult", + "SubscriptionPolicies", + "TenantIdDescription", + "TenantListResult", + "ResourceNameStatus", + "SpendingLimit", + "SubscriptionState", ] +__all__.extend([p for p in _patch_all if p not in __all__]) +_patch_sdk() diff --git a/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/subscriptions/v2016_06_01/models/_models_py3.py b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/subscriptions/v2016_06_01/models/_models_py3.py index 89c25b7eac01b..8ec7fb23dc3ac 100644 --- a/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/subscriptions/v2016_06_01/models/_models_py3.py +++ b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/subscriptions/v2016_06_01/models/_models_py3.py @@ -1,4 +1,5 @@ # coding=utf-8 +# pylint: disable=too-many-lines # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. # Licensed under the MIT License. See License.txt in the project root for license information. @@ -6,15 +7,16 @@ # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -from typing import List, Optional, Union +from typing import List, Optional, TYPE_CHECKING, Union -from azure.core.exceptions import HttpResponseError -import msrest.serialization +from ... import _serialization -from ._subscription_client_enums import * +if TYPE_CHECKING: + # pylint: disable=unused-import,ungrouped-imports + from .. import models as _models -class AvailabilityZonePeers(msrest.serialization.Model): +class AvailabilityZonePeers(_serialization.Model): """List of availability zones shared by the subscriptions. Variables are only populated by the server, and will be ignored when sending a request. @@ -26,46 +28,41 @@ class AvailabilityZonePeers(msrest.serialization.Model): """ _validation = { - 'availability_zone': {'readonly': True}, + "availability_zone": {"readonly": True}, } _attribute_map = { - 'availability_zone': {'key': 'availabilityZone', 'type': 'str'}, - 'peers': {'key': 'peers', 'type': '[Peers]'}, + "availability_zone": {"key": "availabilityZone", "type": "str"}, + "peers": {"key": "peers", "type": "[Peers]"}, } - def __init__( - self, - *, - peers: Optional[List["Peers"]] = None, - **kwargs - ): + def __init__(self, *, peers: Optional[List["_models.Peers"]] = None, **kwargs): """ :keyword peers: Details of shared availability zone. :paramtype peers: list[~azure.mgmt.resource.subscriptions.v2016_06_01.models.Peers] """ - super(AvailabilityZonePeers, self).__init__(**kwargs) + super().__init__(**kwargs) self.availability_zone = None self.peers = peers -class CheckResourceNameResult(msrest.serialization.Model): +class CheckResourceNameResult(_serialization.Model): """Resource Name valid if not a reserved word, does not contain a reserved word and does not start with a reserved word. :ivar name: Name of Resource. :vartype name: str :ivar type: Type of Resource. :vartype type: str - :ivar status: Is the resource name Allowed or Reserved. Possible values include: "Allowed", + :ivar status: Is the resource name Allowed or Reserved. Known values are: "Allowed" and "Reserved". :vartype status: str or ~azure.mgmt.resource.subscriptions.v2016_06_01.models.ResourceNameStatus """ _attribute_map = { - 'name': {'key': 'name', 'type': 'str'}, - 'type': {'key': 'type', 'type': 'str'}, - 'status': {'key': 'status', 'type': 'str'}, + "name": {"key": "name", "type": "str"}, + "type": {"key": "type", "type": "str"}, + "status": {"key": "status", "type": "str"}, } def __init__( @@ -73,7 +70,7 @@ def __init__( *, name: Optional[str] = None, type: Optional[str] = None, - status: Optional[Union[str, "ResourceNameStatus"]] = None, + status: Optional[Union[str, "_models.ResourceNameStatus"]] = None, **kwargs ): """ @@ -81,18 +78,18 @@ def __init__( :paramtype name: str :keyword type: Type of Resource. :paramtype type: str - :keyword status: Is the resource name Allowed or Reserved. Possible values include: "Allowed", + :keyword status: Is the resource name Allowed or Reserved. Known values are: "Allowed" and "Reserved". :paramtype status: str or ~azure.mgmt.resource.subscriptions.v2016_06_01.models.ResourceNameStatus """ - super(CheckResourceNameResult, self).__init__(**kwargs) + super().__init__(**kwargs) self.name = name self.type = type self.status = status -class CheckZonePeersRequest(msrest.serialization.Model): +class CheckZonePeersRequest(_serialization.Model): """Check zone peers request parameters. :ivar location: The Microsoft location. @@ -102,29 +99,23 @@ class CheckZonePeersRequest(msrest.serialization.Model): """ _attribute_map = { - 'location': {'key': 'location', 'type': 'str'}, - 'subscription_ids': {'key': 'subscriptionIds', 'type': '[str]'}, + "location": {"key": "location", "type": "str"}, + "subscription_ids": {"key": "subscriptionIds", "type": "[str]"}, } - def __init__( - self, - *, - location: Optional[str] = None, - subscription_ids: Optional[List[str]] = None, - **kwargs - ): + def __init__(self, *, location: Optional[str] = None, subscription_ids: Optional[List[str]] = None, **kwargs): """ :keyword location: The Microsoft location. :paramtype location: str :keyword subscription_ids: The peer Microsoft Azure subscription ID. :paramtype subscription_ids: list[str] """ - super(CheckZonePeersRequest, self).__init__(**kwargs) + super().__init__(**kwargs) self.location = location self.subscription_ids = subscription_ids -class CheckZonePeersResult(msrest.serialization.Model): +class CheckZonePeersResult(_serialization.Model): """Result of the Check zone peers operation. Variables are only populated by the server, and will be ignored when sending a request. @@ -139,20 +130,20 @@ class CheckZonePeersResult(msrest.serialization.Model): """ _validation = { - 'subscription_id': {'readonly': True}, + "subscription_id": {"readonly": True}, } _attribute_map = { - 'subscription_id': {'key': 'subscriptionId', 'type': 'str'}, - 'location': {'key': 'location', 'type': 'str'}, - 'availability_zone_peers': {'key': 'availabilityZonePeers', 'type': '[AvailabilityZonePeers]'}, + "subscription_id": {"key": "subscriptionId", "type": "str"}, + "location": {"key": "location", "type": "str"}, + "availability_zone_peers": {"key": "availabilityZonePeers", "type": "[AvailabilityZonePeers]"}, } def __init__( self, *, location: Optional[str] = None, - availability_zone_peers: Optional[List["AvailabilityZonePeers"]] = None, + availability_zone_peers: Optional[List["_models.AvailabilityZonePeers"]] = None, **kwargs ): """ @@ -162,13 +153,13 @@ def __init__( :paramtype availability_zone_peers: list[~azure.mgmt.resource.subscriptions.v2016_06_01.models.AvailabilityZonePeers] """ - super(CheckZonePeersResult, self).__init__(**kwargs) + super().__init__(**kwargs) self.subscription_id = None self.location = location self.availability_zone_peers = availability_zone_peers -class ErrorAdditionalInfo(msrest.serialization.Model): +class ErrorAdditionalInfo(_serialization.Model): """The resource management error additional info. Variables are only populated by the server, and will be ignored when sending a request. @@ -176,31 +167,27 @@ class ErrorAdditionalInfo(msrest.serialization.Model): :ivar type: The additional info type. :vartype type: str :ivar info: The additional info. - :vartype info: any + :vartype info: JSON """ _validation = { - 'type': {'readonly': True}, - 'info': {'readonly': True}, + "type": {"readonly": True}, + "info": {"readonly": True}, } _attribute_map = { - 'type': {'key': 'type', 'type': 'str'}, - 'info': {'key': 'info', 'type': 'object'}, + "type": {"key": "type", "type": "str"}, + "info": {"key": "info", "type": "object"}, } - def __init__( - self, - **kwargs - ): - """ - """ - super(ErrorAdditionalInfo, self).__init__(**kwargs) + def __init__(self, **kwargs): + """ """ + super().__init__(**kwargs) self.type = None self.info = None -class ErrorDefinition(msrest.serialization.Model): +class ErrorDefinition(_serialization.Model): """Error description and code explaining why resource name is invalid. :ivar message: Description of the error. @@ -210,29 +197,23 @@ class ErrorDefinition(msrest.serialization.Model): """ _attribute_map = { - 'message': {'key': 'message', 'type': 'str'}, - 'code': {'key': 'code', 'type': 'str'}, + "message": {"key": "message", "type": "str"}, + "code": {"key": "code", "type": "str"}, } - def __init__( - self, - *, - message: Optional[str] = None, - code: Optional[str] = None, - **kwargs - ): + def __init__(self, *, message: Optional[str] = None, code: Optional[str] = None, **kwargs): """ :keyword message: Description of the error. :paramtype message: str :keyword code: Code of the error. :paramtype code: str """ - super(ErrorDefinition, self).__init__(**kwargs) + super().__init__(**kwargs) self.message = message self.code = code -class ErrorDetail(msrest.serialization.Model): +class ErrorDetail(_serialization.Model): """The error detail. Variables are only populated by the server, and will be ignored when sending a request. @@ -251,28 +232,24 @@ class ErrorDetail(msrest.serialization.Model): """ _validation = { - 'code': {'readonly': True}, - 'message': {'readonly': True}, - 'target': {'readonly': True}, - 'details': {'readonly': True}, - 'additional_info': {'readonly': True}, + "code": {"readonly": True}, + "message": {"readonly": True}, + "target": {"readonly": True}, + "details": {"readonly": True}, + "additional_info": {"readonly": True}, } _attribute_map = { - 'code': {'key': 'code', 'type': 'str'}, - 'message': {'key': 'message', 'type': 'str'}, - 'target': {'key': 'target', 'type': 'str'}, - 'details': {'key': 'details', 'type': '[ErrorDetail]'}, - 'additional_info': {'key': 'additionalInfo', 'type': '[ErrorAdditionalInfo]'}, + "code": {"key": "code", "type": "str"}, + "message": {"key": "message", "type": "str"}, + "target": {"key": "target", "type": "str"}, + "details": {"key": "details", "type": "[ErrorDetail]"}, + "additional_info": {"key": "additionalInfo", "type": "[ErrorAdditionalInfo]"}, } - def __init__( - self, - **kwargs - ): - """ - """ - super(ErrorDetail, self).__init__(**kwargs) + def __init__(self, **kwargs): + """ """ + super().__init__(**kwargs) self.code = None self.message = None self.target = None @@ -280,7 +257,7 @@ def __init__( self.additional_info = None -class ErrorResponse(msrest.serialization.Model): +class ErrorResponse(_serialization.Model): """Common error response for all Azure Resource Manager APIs to return error details for failed operations. (This also follows the OData error response format.). :ivar error: The error object. @@ -288,24 +265,19 @@ class ErrorResponse(msrest.serialization.Model): """ _attribute_map = { - 'error': {'key': 'error', 'type': 'ErrorDetail'}, + "error": {"key": "error", "type": "ErrorDetail"}, } - def __init__( - self, - *, - error: Optional["ErrorDetail"] = None, - **kwargs - ): + def __init__(self, *, error: Optional["_models.ErrorDetail"] = None, **kwargs): """ :keyword error: The error object. :paramtype error: ~azure.mgmt.resource.subscriptions.v2016_06_01.models.ErrorDetail """ - super(ErrorResponse, self).__init__(**kwargs) + super().__init__(**kwargs) self.error = error -class ErrorResponseAutoGenerated(msrest.serialization.Model): +class ErrorResponseAutoGenerated(_serialization.Model): """Error response. :ivar error: The error details. @@ -313,24 +285,19 @@ class ErrorResponseAutoGenerated(msrest.serialization.Model): """ _attribute_map = { - 'error': {'key': 'error', 'type': 'ErrorDefinition'}, + "error": {"key": "error", "type": "ErrorDefinition"}, } - def __init__( - self, - *, - error: Optional["ErrorDefinition"] = None, - **kwargs - ): + def __init__(self, *, error: Optional["_models.ErrorDefinition"] = None, **kwargs): """ :keyword error: The error details. :paramtype error: ~azure.mgmt.resource.subscriptions.v2016_06_01.models.ErrorDefinition """ - super(ErrorResponseAutoGenerated, self).__init__(**kwargs) + super().__init__(**kwargs) self.error = error -class Location(msrest.serialization.Model): +class Location(_serialization.Model): """Location information. Variables are only populated by the server, and will be ignored when sending a request. @@ -351,30 +318,26 @@ class Location(msrest.serialization.Model): """ _validation = { - 'id': {'readonly': True}, - 'subscription_id': {'readonly': True}, - 'name': {'readonly': True}, - 'display_name': {'readonly': True}, - 'latitude': {'readonly': True}, - 'longitude': {'readonly': True}, + "id": {"readonly": True}, + "subscription_id": {"readonly": True}, + "name": {"readonly": True}, + "display_name": {"readonly": True}, + "latitude": {"readonly": True}, + "longitude": {"readonly": True}, } _attribute_map = { - 'id': {'key': 'id', 'type': 'str'}, - 'subscription_id': {'key': 'subscriptionId', 'type': 'str'}, - 'name': {'key': 'name', 'type': 'str'}, - 'display_name': {'key': 'displayName', 'type': 'str'}, - 'latitude': {'key': 'latitude', 'type': 'str'}, - 'longitude': {'key': 'longitude', 'type': 'str'}, + "id": {"key": "id", "type": "str"}, + "subscription_id": {"key": "subscriptionId", "type": "str"}, + "name": {"key": "name", "type": "str"}, + "display_name": {"key": "displayName", "type": "str"}, + "latitude": {"key": "latitude", "type": "str"}, + "longitude": {"key": "longitude", "type": "str"}, } - def __init__( - self, - **kwargs - ): - """ - """ - super(Location, self).__init__(**kwargs) + def __init__(self, **kwargs): + """ """ + super().__init__(**kwargs) self.id = None self.subscription_id = None self.name = None @@ -383,7 +346,7 @@ def __init__( self.longitude = None -class LocationListResult(msrest.serialization.Model): +class LocationListResult(_serialization.Model): """Location list operation response. :ivar value: An array of locations. @@ -391,24 +354,19 @@ class LocationListResult(msrest.serialization.Model): """ _attribute_map = { - 'value': {'key': 'value', 'type': '[Location]'}, + "value": {"key": "value", "type": "[Location]"}, } - def __init__( - self, - *, - value: Optional[List["Location"]] = None, - **kwargs - ): + def __init__(self, *, value: Optional[List["_models.Location"]] = None, **kwargs): """ :keyword value: An array of locations. :paramtype value: list[~azure.mgmt.resource.subscriptions.v2016_06_01.models.Location] """ - super(LocationListResult, self).__init__(**kwargs) + super().__init__(**kwargs) self.value = value -class Operation(msrest.serialization.Model): +class Operation(_serialization.Model): """Microsoft.Resources operation. :ivar name: Operation name: {provider}/{resource}/{operation}. @@ -418,29 +376,23 @@ class Operation(msrest.serialization.Model): """ _attribute_map = { - 'name': {'key': 'name', 'type': 'str'}, - 'display': {'key': 'display', 'type': 'OperationDisplay'}, + "name": {"key": "name", "type": "str"}, + "display": {"key": "display", "type": "OperationDisplay"}, } - def __init__( - self, - *, - name: Optional[str] = None, - display: Optional["OperationDisplay"] = None, - **kwargs - ): + def __init__(self, *, name: Optional[str] = None, display: Optional["_models.OperationDisplay"] = None, **kwargs): """ :keyword name: Operation name: {provider}/{resource}/{operation}. :paramtype name: str :keyword display: The object that represents the operation. :paramtype display: ~azure.mgmt.resource.subscriptions.v2016_06_01.models.OperationDisplay """ - super(Operation, self).__init__(**kwargs) + super().__init__(**kwargs) self.name = name self.display = display -class OperationDisplay(msrest.serialization.Model): +class OperationDisplay(_serialization.Model): """The object that represents the operation. :ivar provider: Service provider: Microsoft.Resources. @@ -454,10 +406,10 @@ class OperationDisplay(msrest.serialization.Model): """ _attribute_map = { - 'provider': {'key': 'provider', 'type': 'str'}, - 'resource': {'key': 'resource', 'type': 'str'}, - 'operation': {'key': 'operation', 'type': 'str'}, - 'description': {'key': 'description', 'type': 'str'}, + "provider": {"key": "provider", "type": "str"}, + "resource": {"key": "resource", "type": "str"}, + "operation": {"key": "operation", "type": "str"}, + "description": {"key": "description", "type": "str"}, } def __init__( @@ -479,14 +431,14 @@ def __init__( :keyword description: Description of the operation. :paramtype description: str """ - super(OperationDisplay, self).__init__(**kwargs) + super().__init__(**kwargs) self.provider = provider self.resource = resource self.operation = operation self.description = description -class OperationListResult(msrest.serialization.Model): +class OperationListResult(_serialization.Model): """Result of the request to list Microsoft.Resources operations. It contains a list of operations and a URL link to get the next set of results. :ivar value: List of Microsoft.Resources operations. @@ -496,29 +448,23 @@ class OperationListResult(msrest.serialization.Model): """ _attribute_map = { - 'value': {'key': 'value', 'type': '[Operation]'}, - 'next_link': {'key': 'nextLink', 'type': 'str'}, + "value": {"key": "value", "type": "[Operation]"}, + "next_link": {"key": "nextLink", "type": "str"}, } - def __init__( - self, - *, - value: Optional[List["Operation"]] = None, - next_link: Optional[str] = None, - **kwargs - ): + def __init__(self, *, value: Optional[List["_models.Operation"]] = None, next_link: Optional[str] = None, **kwargs): """ :keyword value: List of Microsoft.Resources operations. :paramtype value: list[~azure.mgmt.resource.subscriptions.v2016_06_01.models.Operation] :keyword next_link: URL to get the next set of operation list results if there are any. :paramtype next_link: str """ - super(OperationListResult, self).__init__(**kwargs) + super().__init__(**kwargs) self.value = value self.next_link = next_link -class Peers(msrest.serialization.Model): +class Peers(_serialization.Model): """Information about shared availability zone. Variables are only populated by the server, and will be ignored when sending a request. @@ -530,66 +476,56 @@ class Peers(msrest.serialization.Model): """ _validation = { - 'subscription_id': {'readonly': True}, - 'availability_zone': {'readonly': True}, + "subscription_id": {"readonly": True}, + "availability_zone": {"readonly": True}, } _attribute_map = { - 'subscription_id': {'key': 'subscriptionId', 'type': 'str'}, - 'availability_zone': {'key': 'availabilityZone', 'type': 'str'}, + "subscription_id": {"key": "subscriptionId", "type": "str"}, + "availability_zone": {"key": "availabilityZone", "type": "str"}, } - def __init__( - self, - **kwargs - ): - """ - """ - super(Peers, self).__init__(**kwargs) + def __init__(self, **kwargs): + """ """ + super().__init__(**kwargs) self.subscription_id = None self.availability_zone = None -class ResourceName(msrest.serialization.Model): +class ResourceName(_serialization.Model): """Name and Type of the Resource. All required parameters must be populated in order to send to Azure. - :ivar name: Required. Name of the resource. + :ivar name: Name of the resource. Required. :vartype name: str - :ivar type: Required. The type of the resource. + :ivar type: The type of the resource. Required. :vartype type: str """ _validation = { - 'name': {'required': True}, - 'type': {'required': True}, + "name": {"required": True}, + "type": {"required": True}, } _attribute_map = { - 'name': {'key': 'name', 'type': 'str'}, - 'type': {'key': 'type', 'type': 'str'}, + "name": {"key": "name", "type": "str"}, + "type": {"key": "type", "type": "str"}, } - def __init__( - self, - *, - name: str, - type: str, - **kwargs - ): + def __init__(self, *, name: str, type: str, **kwargs): """ - :keyword name: Required. Name of the resource. + :keyword name: Name of the resource. Required. :paramtype name: str - :keyword type: Required. The type of the resource. + :keyword type: The type of the resource. Required. :paramtype type: str """ - super(ResourceName, self).__init__(**kwargs) + super().__init__(**kwargs) self.name = name self.type = type -class Subscription(msrest.serialization.Model): +class Subscription(_serialization.Model): """Subscription information. Variables are only populated by the server, and will be ignored when sending a request. @@ -602,7 +538,7 @@ class Subscription(msrest.serialization.Model): :ivar display_name: The subscription display name. :vartype display_name: str :ivar state: The subscription state. Possible values are Enabled, Warned, PastDue, Disabled, - and Deleted. Possible values include: "Enabled", "Warned", "PastDue", "Disabled", "Deleted". + and Deleted. Known values are: "Enabled", "Warned", "PastDue", "Disabled", and "Deleted". :vartype state: str or ~azure.mgmt.resource.subscriptions.v2016_06_01.models.SubscriptionState :ivar subscription_policies: The subscription policies. :vartype subscription_policies: @@ -614,25 +550,25 @@ class Subscription(msrest.serialization.Model): """ _validation = { - 'id': {'readonly': True}, - 'subscription_id': {'readonly': True}, - 'display_name': {'readonly': True}, - 'state': {'readonly': True}, + "id": {"readonly": True}, + "subscription_id": {"readonly": True}, + "display_name": {"readonly": True}, + "state": {"readonly": True}, } _attribute_map = { - 'id': {'key': 'id', 'type': 'str'}, - 'subscription_id': {'key': 'subscriptionId', 'type': 'str'}, - 'display_name': {'key': 'displayName', 'type': 'str'}, - 'state': {'key': 'state', 'type': 'str'}, - 'subscription_policies': {'key': 'subscriptionPolicies', 'type': 'SubscriptionPolicies'}, - 'authorization_source': {'key': 'authorizationSource', 'type': 'str'}, + "id": {"key": "id", "type": "str"}, + "subscription_id": {"key": "subscriptionId", "type": "str"}, + "display_name": {"key": "displayName", "type": "str"}, + "state": {"key": "state", "type": "str"}, + "subscription_policies": {"key": "subscriptionPolicies", "type": "SubscriptionPolicies"}, + "authorization_source": {"key": "authorizationSource", "type": "str"}, } def __init__( self, *, - subscription_policies: Optional["SubscriptionPolicies"] = None, + subscription_policies: Optional["_models.SubscriptionPolicies"] = None, authorization_source: Optional[str] = None, **kwargs ): @@ -645,7 +581,7 @@ def __init__( RoleBased'. :paramtype authorization_source: str """ - super(Subscription, self).__init__(**kwargs) + super().__init__(**kwargs) self.id = None self.subscription_id = None self.display_name = None @@ -654,45 +590,39 @@ def __init__( self.authorization_source = authorization_source -class SubscriptionListResult(msrest.serialization.Model): +class SubscriptionListResult(_serialization.Model): """Subscription list operation response. All required parameters must be populated in order to send to Azure. :ivar value: An array of subscriptions. :vartype value: list[~azure.mgmt.resource.subscriptions.v2016_06_01.models.Subscription] - :ivar next_link: Required. The URL to get the next set of results. + :ivar next_link: The URL to get the next set of results. Required. :vartype next_link: str """ _validation = { - 'next_link': {'required': True}, + "next_link": {"required": True}, } _attribute_map = { - 'value': {'key': 'value', 'type': '[Subscription]'}, - 'next_link': {'key': 'nextLink', 'type': 'str'}, + "value": {"key": "value", "type": "[Subscription]"}, + "next_link": {"key": "nextLink", "type": "str"}, } - def __init__( - self, - *, - next_link: str, - value: Optional[List["Subscription"]] = None, - **kwargs - ): + def __init__(self, *, next_link: str, value: Optional[List["_models.Subscription"]] = None, **kwargs): """ :keyword value: An array of subscriptions. :paramtype value: list[~azure.mgmt.resource.subscriptions.v2016_06_01.models.Subscription] - :keyword next_link: Required. The URL to get the next set of results. + :keyword next_link: The URL to get the next set of results. Required. :paramtype next_link: str """ - super(SubscriptionListResult, self).__init__(**kwargs) + super().__init__(**kwargs) self.value = value self.next_link = next_link -class SubscriptionPolicies(msrest.serialization.Model): +class SubscriptionPolicies(_serialization.Model): """Subscription policies. Variables are only populated by the server, and will be ignored when sending a request. @@ -703,37 +633,33 @@ class SubscriptionPolicies(msrest.serialization.Model): :vartype location_placement_id: str :ivar quota_id: The subscription quota ID. :vartype quota_id: str - :ivar spending_limit: The subscription spending limit. Possible values include: "On", "Off", + :ivar spending_limit: The subscription spending limit. Known values are: "On", "Off", and "CurrentPeriodOff". :vartype spending_limit: str or ~azure.mgmt.resource.subscriptions.v2016_06_01.models.SpendingLimit """ _validation = { - 'location_placement_id': {'readonly': True}, - 'quota_id': {'readonly': True}, - 'spending_limit': {'readonly': True}, + "location_placement_id": {"readonly": True}, + "quota_id": {"readonly": True}, + "spending_limit": {"readonly": True}, } _attribute_map = { - 'location_placement_id': {'key': 'locationPlacementId', 'type': 'str'}, - 'quota_id': {'key': 'quotaId', 'type': 'str'}, - 'spending_limit': {'key': 'spendingLimit', 'type': 'str'}, + "location_placement_id": {"key": "locationPlacementId", "type": "str"}, + "quota_id": {"key": "quotaId", "type": "str"}, + "spending_limit": {"key": "spendingLimit", "type": "str"}, } - def __init__( - self, - **kwargs - ): - """ - """ - super(SubscriptionPolicies, self).__init__(**kwargs) + def __init__(self, **kwargs): + """ """ + super().__init__(**kwargs) self.location_placement_id = None self.quota_id = None self.spending_limit = None -class TenantIdDescription(msrest.serialization.Model): +class TenantIdDescription(_serialization.Model): """Tenant Id information. Variables are only populated by the server, and will be ignored when sending a request. @@ -746,60 +672,50 @@ class TenantIdDescription(msrest.serialization.Model): """ _validation = { - 'id': {'readonly': True}, - 'tenant_id': {'readonly': True}, + "id": {"readonly": True}, + "tenant_id": {"readonly": True}, } _attribute_map = { - 'id': {'key': 'id', 'type': 'str'}, - 'tenant_id': {'key': 'tenantId', 'type': 'str'}, + "id": {"key": "id", "type": "str"}, + "tenant_id": {"key": "tenantId", "type": "str"}, } - def __init__( - self, - **kwargs - ): - """ - """ - super(TenantIdDescription, self).__init__(**kwargs) + def __init__(self, **kwargs): + """ """ + super().__init__(**kwargs) self.id = None self.tenant_id = None -class TenantListResult(msrest.serialization.Model): +class TenantListResult(_serialization.Model): """Tenant Ids information. All required parameters must be populated in order to send to Azure. :ivar value: An array of tenants. :vartype value: list[~azure.mgmt.resource.subscriptions.v2016_06_01.models.TenantIdDescription] - :ivar next_link: Required. The URL to use for getting the next set of results. + :ivar next_link: The URL to use for getting the next set of results. Required. :vartype next_link: str """ _validation = { - 'next_link': {'required': True}, + "next_link": {"required": True}, } _attribute_map = { - 'value': {'key': 'value', 'type': '[TenantIdDescription]'}, - 'next_link': {'key': 'nextLink', 'type': 'str'}, + "value": {"key": "value", "type": "[TenantIdDescription]"}, + "next_link": {"key": "nextLink", "type": "str"}, } - def __init__( - self, - *, - next_link: str, - value: Optional[List["TenantIdDescription"]] = None, - **kwargs - ): + def __init__(self, *, next_link: str, value: Optional[List["_models.TenantIdDescription"]] = None, **kwargs): """ :keyword value: An array of tenants. :paramtype value: list[~azure.mgmt.resource.subscriptions.v2016_06_01.models.TenantIdDescription] - :keyword next_link: Required. The URL to use for getting the next set of results. + :keyword next_link: The URL to use for getting the next set of results. Required. :paramtype next_link: str """ - super(TenantListResult, self).__init__(**kwargs) + super().__init__(**kwargs) self.value = value self.next_link = next_link diff --git a/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/subscriptions/v2016_06_01/models/_patch.py b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/subscriptions/v2016_06_01/models/_patch.py new file mode 100644 index 0000000000000..f7dd32510333d --- /dev/null +++ b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/subscriptions/v2016_06_01/models/_patch.py @@ -0,0 +1,20 @@ +# ------------------------------------ +# Copyright (c) Microsoft Corporation. +# Licensed under the MIT License. +# ------------------------------------ +"""Customize generated code here. + +Follow our quickstart for examples: https://aka.ms/azsdk/python/dpcodegen/python/customize +""" +from typing import List + +__all__: List[str] = [] # Add all objects you want publicly available to users at this package level + + +def patch_sdk(): + """Do not remove from this file. + + `patch_sdk` is a last resort escape hatch that allows you to do customizations + you can't accomplish using the techniques described in + https://aka.ms/azsdk/python/dpcodegen/python/customize + """ diff --git a/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/subscriptions/v2016_06_01/models/_subscription_client_enums.py b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/subscriptions/v2016_06_01/models/_subscription_client_enums.py index 6465a926ff236..2ed8f2018d081 100644 --- a/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/subscriptions/v2016_06_01/models/_subscription_client_enums.py +++ b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/subscriptions/v2016_06_01/models/_subscription_client_enums.py @@ -7,28 +7,26 @@ # -------------------------------------------------------------------------- from enum import Enum -from six import with_metaclass from azure.core import CaseInsensitiveEnumMeta -class ResourceNameStatus(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): - """Is the resource name Allowed or Reserved - """ +class ResourceNameStatus(str, Enum, metaclass=CaseInsensitiveEnumMeta): + """Is the resource name Allowed or Reserved.""" ALLOWED = "Allowed" RESERVED = "Reserved" -class SpendingLimit(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): - """The subscription spending limit. - """ + +class SpendingLimit(str, Enum, metaclass=CaseInsensitiveEnumMeta): + """The subscription spending limit.""" ON = "On" OFF = "Off" CURRENT_PERIOD_OFF = "CurrentPeriodOff" -class SubscriptionState(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): - """The subscription state. Possible values are Enabled, Warned, PastDue, Disabled, and Deleted. - """ + +class SubscriptionState(str, Enum, metaclass=CaseInsensitiveEnumMeta): + """The subscription state. Possible values are Enabled, Warned, PastDue, Disabled, and Deleted.""" ENABLED = "Enabled" WARNED = "Warned" diff --git a/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/subscriptions/v2016_06_01/operations/__init__.py b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/subscriptions/v2016_06_01/operations/__init__.py index 437b49e23548f..1066cb67ea911 100644 --- a/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/subscriptions/v2016_06_01/operations/__init__.py +++ b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/subscriptions/v2016_06_01/operations/__init__.py @@ -11,9 +11,15 @@ from ._operations import TenantsOperations from ._operations import SubscriptionClientOperationsMixin +from ._patch import __all__ as _patch_all +from ._patch import * # type: ignore # pylint: disable=unused-wildcard-import +from ._patch import patch_sdk as _patch_sdk + __all__ = [ - 'Operations', - 'SubscriptionsOperations', - 'TenantsOperations', - 'SubscriptionClientOperationsMixin', + "Operations", + "SubscriptionsOperations", + "TenantsOperations", + "SubscriptionClientOperationsMixin", ] +__all__.extend([p for p in _patch_all if p not in __all__]) +_patch_sdk() diff --git a/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/subscriptions/v2016_06_01/operations/_operations.py b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/subscriptions/v2016_06_01/operations/_operations.py index b13666869e17f..97342f83dca56 100644 --- a/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/subscriptions/v2016_06_01/operations/_operations.py +++ b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/subscriptions/v2016_06_01/operations/_operations.py @@ -6,301 +6,253 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -from typing import Any, Callable, Dict, Iterable, Optional, TypeVar - -from msrest import Serializer - -from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error +from typing import Any, Callable, Dict, IO, Iterable, Optional, TypeVar, Union, overload +from urllib.parse import parse_qs, urljoin, urlparse + +from azure.core.exceptions import ( + ClientAuthenticationError, + HttpResponseError, + ResourceExistsError, + ResourceNotFoundError, + ResourceNotModifiedError, + map_error, +) from azure.core.paging import ItemPaged from azure.core.pipeline import PipelineResponse from azure.core.pipeline.transport import HttpResponse from azure.core.rest import HttpRequest from azure.core.tracing.decorator import distributed_trace +from azure.core.utils import case_insensitive_dict from azure.mgmt.core.exceptions import ARMErrorFormat from .. import models as _models -from .._vendor import _convert_request, _format_url_section -T = TypeVar('T') +from ..._serialization import Serializer +from .._vendor import MixinABC, _convert_request, _format_url_section + +T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] -JSONType = Any _SERIALIZER = Serializer() _SERIALIZER.client_side_validation = False -def build_operations_list_request( - **kwargs: Any -) -> HttpRequest: - api_version = kwargs.pop('api_version', "2016-06-01") # type: str - accept = "application/json" +def build_operations_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", "2016-06-01")) # type: str + accept = _headers.pop("Accept", "application/json") + # Construct URL _url = kwargs.pop("template_url", "/providers/Microsoft.Resources/operations") # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) - return HttpRequest( - method="GET", - url=_url, - params=_query_parameters, - headers=_header_parameters, - **kwargs - ) +def build_subscriptions_list_locations_request(subscription_id: str, **kwargs: Any) -> HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) -def build_subscriptions_list_locations_request( - subscription_id: str, - **kwargs: Any -) -> HttpRequest: - api_version = kwargs.pop('api_version', "2016-06-01") # type: str + api_version = kwargs.pop("api_version", _params.pop("api-version", "2016-06-01")) # type: str + accept = _headers.pop("Accept", "application/json") - accept = "application/json" # Construct URL _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/locations") path_format_arguments = { - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), } _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - return HttpRequest( - method="GET", - url=_url, - params=_query_parameters, - headers=_header_parameters, - **kwargs - ) + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) -def build_subscriptions_get_request( - subscription_id: str, - **kwargs: Any -) -> HttpRequest: - api_version = kwargs.pop('api_version', "2016-06-01") # type: str +def build_subscriptions_get_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", "2016-06-01")) # type: str + accept = _headers.pop("Accept", "application/json") - accept = "application/json" # Construct URL _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}") path_format_arguments = { - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), } _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) - return HttpRequest( - method="GET", - url=_url, - params=_query_parameters, - headers=_header_parameters, - **kwargs - ) +def build_subscriptions_list_request(**kwargs: Any) -> HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) -def build_subscriptions_list_request( - **kwargs: Any -) -> HttpRequest: - api_version = kwargs.pop('api_version', "2016-06-01") # type: str + api_version = kwargs.pop("api_version", _params.pop("api-version", "2016-06-01")) # type: str + accept = _headers.pop("Accept", "application/json") - accept = "application/json" # Construct URL _url = kwargs.pop("template_url", "/subscriptions") # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') - - return HttpRequest( - method="GET", - url=_url, - params=_query_parameters, - headers=_header_parameters, - **kwargs - ) - - -def build_subscriptions_check_zone_peers_request( - subscription_id: str, - *, - json: JSONType = None, - content: Any = None, - **kwargs: Any -) -> HttpRequest: - api_version = kwargs.pop('api_version', "2016-06-01") # type: str - content_type = kwargs.pop('content_type', None) # type: Optional[str] - - accept = "application/json" + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) + + +def build_subscriptions_check_zone_peers_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", "2016-06-01")) # type: str + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + accept = _headers.pop("Accept", "application/json") + # Construct URL _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/providers/Microsoft.Resources/checkZonePeers/") path_format_arguments = { - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), } _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] if content_type is not None: - _header_parameters['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') - _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') - - return HttpRequest( - method="POST", - url=_url, - params=_query_parameters, - headers=_header_parameters, - json=json, - content=content, - **kwargs - ) - - -def build_tenants_list_request( - **kwargs: Any -) -> HttpRequest: - api_version = kwargs.pop('api_version', "2016-06-01") # type: str - - accept = "application/json" + _headers["Content-Type"] = _SERIALIZER.header("content_type", content_type, "str") + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="POST", url=_url, params=_params, headers=_headers, **kwargs) + + +def build_tenants_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", "2016-06-01")) # type: str + accept = _headers.pop("Accept", "application/json") + # Construct URL _url = kwargs.pop("template_url", "/tenants") # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') - - return HttpRequest( - method="GET", - url=_url, - params=_query_parameters, - headers=_header_parameters, - **kwargs - ) - - -def build_check_resource_name_request( - *, - json: JSONType = None, - content: Any = None, - **kwargs: Any -) -> HttpRequest: - api_version = kwargs.pop('api_version', "2016-06-01") # type: str - content_type = kwargs.pop('content_type', None) # type: Optional[str] - - accept = "application/json" + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) + + +def build_check_resource_name_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", "2016-06-01")) # type: str + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + accept = _headers.pop("Accept", "application/json") + # Construct URL _url = kwargs.pop("template_url", "/providers/Microsoft.Resources/checkResourceName") # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] if content_type is not None: - _header_parameters['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') - _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') - - return HttpRequest( - method="POST", - url=_url, - params=_query_parameters, - headers=_header_parameters, - json=json, - content=content, - **kwargs - ) - -class Operations(object): - """Operations operations. - - You should not instantiate this class directly. Instead, you should create a Client instance that - instantiates it for you and attaches it as an attribute. - - :ivar models: Alias to model classes used in this operation group. - :type models: ~azure.mgmt.resource.subscriptions.v2016_06_01.models - :param client: Client for service requests. - :param config: Configuration of service client. - :param serializer: An object model serializer. - :param deserializer: An object model deserializer. + _headers["Content-Type"] = _SERIALIZER.header("content_type", content_type, "str") + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="POST", url=_url, params=_params, headers=_headers, **kwargs) + + +class Operations: + """ + .. warning:: + **DO NOT** instantiate this class directly. + + Instead, you should access the following operations through + :class:`~azure.mgmt.resource.subscriptions.v2016_06_01.SubscriptionClient`'s + :attr:`operations` attribute. """ models = _models - def __init__(self, client, config, serializer, deserializer): - self._client = client - self._serialize = serializer - self._deserialize = deserializer - self._config = config + def __init__(self, *args, **kwargs): + input_args = list(args) + self._client = input_args.pop(0) if input_args else kwargs.pop("client") + self._config = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") @distributed_trace - def list( - self, - **kwargs: Any - ) -> Iterable["_models.OperationListResult"]: + def list(self, **kwargs: Any) -> Iterable["_models.Operation"]: """Lists all of the available Microsoft.Resources REST API operations. :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either OperationListResult or the result of cls(response) + :return: An iterator like instance of either Operation or the result of cls(response) :rtype: - ~azure.core.paging.ItemPaged[~azure.mgmt.resource.subscriptions.v2016_06_01.models.OperationListResult] - :raises: ~azure.core.exceptions.HttpResponseError + ~azure.core.paging.ItemPaged[~azure.mgmt.resource.subscriptions.v2016_06_01.models.Operation] + :raises ~azure.core.exceptions.HttpResponseError: """ - api_version = kwargs.pop('api_version', "2016-06-01") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2016-06-01")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[_models.OperationListResult] - cls = kwargs.pop('cls', None) # type: ClsType["_models.OperationListResult"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) + def prepare_request(next_link=None): if not next_link: - + request = build_operations_list_request( api_version=api_version, - template_url=self.list.metadata['url'], + template_url=self.list.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore else: - - request = build_operations_list_request( - template_url=next_link, - ) + # make call to next link with the client's api-version + _parsed_next_link = urlparse(next_link) + _next_request_params = case_insensitive_dict(parse_qs(_parsed_next_link.query)) + _next_request_params["api-version"] = self._config.api_version + request = HttpRequest("GET", urljoin(next_link, _parsed_next_link.path), params=_next_request_params) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore request.method = "GET" return request @@ -314,10 +266,8 @@ def extract_data(pipeline_response): def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) response = pipeline_response.http_response @@ -327,78 +277,80 @@ def get_next(next_link=None): return pipeline_response + return ItemPaged(get_next, extract_data) - return ItemPaged( - get_next, extract_data - ) - list.metadata = {'url': "/providers/Microsoft.Resources/operations"} # type: ignore -class SubscriptionsOperations(object): - """SubscriptionsOperations operations. - - You should not instantiate this class directly. Instead, you should create a Client instance that - instantiates it for you and attaches it as an attribute. - - :ivar models: Alias to model classes used in this operation group. - :type models: ~azure.mgmt.resource.subscriptions.v2016_06_01.models - :param client: Client for service requests. - :param config: Configuration of service client. - :param serializer: An object model serializer. - :param deserializer: An object model deserializer. + list.metadata = {"url": "/providers/Microsoft.Resources/operations"} # type: ignore + + +class SubscriptionsOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. + + Instead, you should access the following operations through + :class:`~azure.mgmt.resource.subscriptions.v2016_06_01.SubscriptionClient`'s + :attr:`subscriptions` attribute. """ models = _models - def __init__(self, client, config, serializer, deserializer): - self._client = client - self._serialize = serializer - self._deserialize = deserializer - self._config = config + def __init__(self, *args, **kwargs): + input_args = list(args) + self._client = input_args.pop(0) if input_args else kwargs.pop("client") + self._config = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") @distributed_trace - def list_locations( - self, - subscription_id: str, - **kwargs: Any - ) -> Iterable["_models.LocationListResult"]: + def list_locations(self, subscription_id: str, **kwargs: Any) -> Iterable["_models.Location"]: """Gets all available geo-locations. This operation provides all the locations that are available for resource providers; however, each resource provider may support a subset of this list. - :param subscription_id: The ID of the target subscription. + :param subscription_id: The ID of the target subscription. Required. :type subscription_id: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either LocationListResult or the result of cls(response) + :return: An iterator like instance of either Location or the result of cls(response) :rtype: - ~azure.core.paging.ItemPaged[~azure.mgmt.resource.subscriptions.v2016_06_01.models.LocationListResult] - :raises: ~azure.core.exceptions.HttpResponseError + ~azure.core.paging.ItemPaged[~azure.mgmt.resource.subscriptions.v2016_06_01.models.Location] + :raises ~azure.core.exceptions.HttpResponseError: """ - api_version = kwargs.pop('api_version', "2016-06-01") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2016-06-01")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[_models.LocationListResult] - cls = kwargs.pop('cls', None) # type: ClsType["_models.LocationListResult"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) + def prepare_request(next_link=None): if not next_link: - + request = build_subscriptions_list_locations_request( subscription_id=subscription_id, api_version=api_version, - template_url=self.list_locations.metadata['url'], + template_url=self.list_locations.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore else: - - request = build_subscriptions_list_locations_request( - subscription_id=subscription_id, - template_url=next_link, - ) + # make call to next link with the client's api-version + _parsed_next_link = urlparse(next_link) + _next_request_params = case_insensitive_dict(parse_qs(_parsed_next_link.query)) + _next_request_params["api-version"] = self._config.api_version + request = HttpRequest("GET", urljoin(next_link, _parsed_next_link.path), params=_next_request_params) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore request.method = "GET" return request @@ -412,10 +364,8 @@ def extract_data(pipeline_response): def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) response = pipeline_response.http_response @@ -425,103 +375,108 @@ def get_next(next_link=None): return pipeline_response + return ItemPaged(get_next, extract_data) - return ItemPaged( - get_next, extract_data - ) - list_locations.metadata = {'url': "/subscriptions/{subscriptionId}/locations"} # type: ignore + list_locations.metadata = {"url": "/subscriptions/{subscriptionId}/locations"} # type: ignore @distributed_trace - def get( - self, - subscription_id: str, - **kwargs: Any - ) -> "_models.Subscription": + def get(self, subscription_id: str, **kwargs: Any) -> _models.Subscription: """Gets details about a specified subscription. - :param subscription_id: The ID of the target subscription. + :param subscription_id: The ID of the target subscription. Required. :type subscription_id: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: Subscription, or the result of cls(response) + :return: Subscription or the result of cls(response) :rtype: ~azure.mgmt.resource.subscriptions.v2016_06_01.models.Subscription - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.Subscription"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + 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', "2016-06-01") # type: str + api_version = kwargs.pop("api_version", _params.pop("api-version", "2016-06-01")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[_models.Subscription] - request = build_subscriptions_get_request( subscription_id=subscription_id, api_version=api_version, - template_url=self.get.metadata['url'], + template_url=self.get.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) - deserialized = self._deserialize('Subscription', pipeline_response) + deserialized = self._deserialize("Subscription", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - get.metadata = {'url': "/subscriptions/{subscriptionId}"} # type: ignore - + get.metadata = {"url": "/subscriptions/{subscriptionId}"} # type: ignore @distributed_trace - def list( - self, - **kwargs: Any - ) -> Iterable["_models.SubscriptionListResult"]: + def list(self, **kwargs: Any) -> Iterable["_models.Subscription"]: """Gets all subscriptions for a tenant. :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either SubscriptionListResult or the result of - cls(response) + :return: An iterator like instance of either Subscription or the result of cls(response) :rtype: - ~azure.core.paging.ItemPaged[~azure.mgmt.resource.subscriptions.v2016_06_01.models.SubscriptionListResult] - :raises: ~azure.core.exceptions.HttpResponseError + ~azure.core.paging.ItemPaged[~azure.mgmt.resource.subscriptions.v2016_06_01.models.Subscription] + :raises ~azure.core.exceptions.HttpResponseError: """ - api_version = kwargs.pop('api_version', "2016-06-01") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2016-06-01")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[_models.SubscriptionListResult] - cls = kwargs.pop('cls', None) # type: ClsType["_models.SubscriptionListResult"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) + def prepare_request(next_link=None): if not next_link: - + request = build_subscriptions_list_request( api_version=api_version, - template_url=self.list.metadata['url'], + template_url=self.list.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore else: - - request = build_subscriptions_list_request( - template_url=next_link, - ) + # make call to next link with the client's api-version + _parsed_next_link = urlparse(next_link) + _next_request_params = case_insensitive_dict(parse_qs(_parsed_next_link.query)) + _next_request_params["api-version"] = self._config.api_version + request = HttpRequest("GET", urljoin(next_link, _parsed_next_link.path), params=_next_request_params) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore request.method = "GET" return request @@ -535,10 +490,8 @@ def extract_data(pipeline_response): def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) response = pipeline_response.http_response @@ -548,56 +501,113 @@ def get_next(next_link=None): return pipeline_response + return ItemPaged(get_next, extract_data) - return ItemPaged( - get_next, extract_data - ) - list.metadata = {'url': "/subscriptions"} # type: ignore + list.metadata = {"url": "/subscriptions"} # type: ignore - @distributed_trace + @overload def check_zone_peers( self, subscription_id: str, - parameters: "_models.CheckZonePeersRequest", + parameters: _models.CheckZonePeersRequest, + *, + content_type: str = "application/json", **kwargs: Any - ) -> "_models.CheckZonePeersResult": + ) -> _models.CheckZonePeersResult: + """Compares a subscriptions logical zone mapping. + + :param subscription_id: The ID of the target subscription. Required. + :type subscription_id: str + :param parameters: Parameters for checking zone peers. Required. + :type parameters: ~azure.mgmt.resource.subscriptions.v2016_06_01.models.CheckZonePeersRequest + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: CheckZonePeersResult or the result of cls(response) + :rtype: ~azure.mgmt.resource.subscriptions.v2016_06_01.models.CheckZonePeersResult + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + def check_zone_peers( + self, subscription_id: str, parameters: IO, *, content_type: str = "application/json", **kwargs: Any + ) -> _models.CheckZonePeersResult: + """Compares a subscriptions logical zone mapping. + + :param subscription_id: The ID of the target subscription. Required. + :type subscription_id: str + :param parameters: Parameters for checking zone peers. Required. + :type parameters: IO + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: CheckZonePeersResult or the result of cls(response) + :rtype: ~azure.mgmt.resource.subscriptions.v2016_06_01.models.CheckZonePeersResult + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace + def check_zone_peers( + self, subscription_id: str, parameters: Union[_models.CheckZonePeersRequest, IO], **kwargs: Any + ) -> _models.CheckZonePeersResult: """Compares a subscriptions logical zone mapping. - :param subscription_id: The ID of the target subscription. + :param subscription_id: The ID of the target subscription. Required. :type subscription_id: str - :param parameters: Parameters for checking zone peers. + :param parameters: Parameters for checking zone peers. Is either a model type or a IO type. + Required. :type parameters: ~azure.mgmt.resource.subscriptions.v2016_06_01.models.CheckZonePeersRequest + or IO + :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. + Default value is None. + :paramtype content_type: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: CheckZonePeersResult, or the result of cls(response) + :return: CheckZonePeersResult or the result of cls(response) :rtype: ~azure.mgmt.resource.subscriptions.v2016_06_01.models.CheckZonePeersResult - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.CheckZonePeersResult"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) - api_version = kwargs.pop('api_version', "2016-06-01") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - _json = self._serialize.body(parameters, 'CheckZonePeersRequest') + api_version = kwargs.pop("api_version", _params.pop("api-version", "2016-06-01")) # type: str + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.CheckZonePeersResult] + + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(parameters, (IO, bytes)): + _content = parameters + else: + _json = self._serialize.body(parameters, "CheckZonePeersRequest") request = build_subscriptions_check_zone_peers_request( subscription_id=subscription_id, api_version=api_version, content_type=content_type, json=_json, - template_url=self.check_zone_peers.metadata['url'], + content=_content, + template_url=self.check_zone_peers.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200]: @@ -605,74 +615,79 @@ def check_zone_peers( error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - deserialized = self._deserialize('CheckZonePeersResult', pipeline_response) + deserialized = self._deserialize("CheckZonePeersResult", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - check_zone_peers.metadata = {'url': "/subscriptions/{subscriptionId}/providers/Microsoft.Resources/checkZonePeers/"} # type: ignore + check_zone_peers.metadata = {"url": "/subscriptions/{subscriptionId}/providers/Microsoft.Resources/checkZonePeers/"} # type: ignore -class TenantsOperations(object): - """TenantsOperations operations. - You should not instantiate this class directly. Instead, you should create a Client instance that - instantiates it for you and attaches it as an attribute. +class TenantsOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. - :ivar models: Alias to model classes used in this operation group. - :type models: ~azure.mgmt.resource.subscriptions.v2016_06_01.models - :param client: Client for service requests. - :param config: Configuration of service client. - :param serializer: An object model serializer. - :param deserializer: An object model deserializer. + Instead, you should access the following operations through + :class:`~azure.mgmt.resource.subscriptions.v2016_06_01.SubscriptionClient`'s + :attr:`tenants` attribute. """ models = _models - def __init__(self, client, config, serializer, deserializer): - self._client = client - self._serialize = serializer - self._deserialize = deserializer - self._config = config + def __init__(self, *args, **kwargs): + input_args = list(args) + self._client = input_args.pop(0) if input_args else kwargs.pop("client") + self._config = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") @distributed_trace - def list( - self, - **kwargs: Any - ) -> Iterable["_models.TenantListResult"]: + def list(self, **kwargs: Any) -> Iterable["_models.TenantIdDescription"]: """Gets the tenants for your account. :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either TenantListResult or the result of cls(response) + :return: An iterator like instance of either TenantIdDescription or the result of cls(response) :rtype: - ~azure.core.paging.ItemPaged[~azure.mgmt.resource.subscriptions.v2016_06_01.models.TenantListResult] - :raises: ~azure.core.exceptions.HttpResponseError + ~azure.core.paging.ItemPaged[~azure.mgmt.resource.subscriptions.v2016_06_01.models.TenantIdDescription] + :raises ~azure.core.exceptions.HttpResponseError: """ - api_version = kwargs.pop('api_version', "2016-06-01") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2016-06-01")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[_models.TenantListResult] - cls = kwargs.pop('cls', None) # type: ClsType["_models.TenantListResult"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) + def prepare_request(next_link=None): if not next_link: - + request = build_tenants_list_request( api_version=api_version, - template_url=self.list.metadata['url'], + template_url=self.list.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore else: - - request = build_tenants_list_request( - template_url=next_link, - ) + # make call to next link with the client's api-version + _parsed_next_link = urlparse(next_link) + _next_request_params = case_insensitive_dict(parse_qs(_parsed_next_link.query)) + _next_request_params["api-version"] = self._config.api_version + request = HttpRequest("GET", urljoin(next_link, _parsed_next_link.path), params=_next_request_params) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore request.method = "GET" return request @@ -686,10 +701,8 @@ def extract_data(pipeline_response): def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) response = pipeline_response.http_response @@ -699,19 +712,20 @@ def get_next(next_link=None): return pipeline_response + return ItemPaged(get_next, extract_data) - return ItemPaged( - get_next, extract_data - ) - list.metadata = {'url': "/tenants"} # type: ignore -class SubscriptionClientOperationsMixin(object): + list.metadata = {"url": "/tenants"} # type: ignore - @distributed_trace + +class SubscriptionClientOperationsMixin(MixinABC): + @overload def check_resource_name( self, - resource_name_definition: Optional["_models.ResourceName"] = None, + resource_name_definition: Optional[_models.ResourceName] = None, + *, + content_type: str = "application/json", **kwargs: Any - ) -> "_models.CheckResourceNameResult": + ) -> _models.CheckResourceNameResult: """Checks resource name validity. A resource name is valid if it is not a reserved word, does not contains a reserved word and @@ -721,39 +735,99 @@ def check_resource_name( type. Default value is None. :type resource_name_definition: ~azure.mgmt.resource.subscriptions.v2016_06_01.models.ResourceName + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: CheckResourceNameResult or the result of cls(response) + :rtype: ~azure.mgmt.resource.subscriptions.v2016_06_01.models.CheckResourceNameResult + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + def check_resource_name( + self, resource_name_definition: Optional[IO] = None, *, content_type: str = "application/json", **kwargs: Any + ) -> _models.CheckResourceNameResult: + """Checks resource name validity. + + A resource name is valid if it is not a reserved word, does not contains a reserved word and + does not start with a reserved word. + + :param resource_name_definition: Resource object with values for resource name and resource + type. Default value is None. + :type resource_name_definition: IO + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: CheckResourceNameResult, or the result of cls(response) + :return: CheckResourceNameResult or the result of cls(response) :rtype: ~azure.mgmt.resource.subscriptions.v2016_06_01.models.CheckResourceNameResult - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace + def check_resource_name( + self, resource_name_definition: Optional[Union[_models.ResourceName, IO]] = None, **kwargs: Any + ) -> _models.CheckResourceNameResult: + """Checks resource name validity. + + A resource name is valid if it is not a reserved word, does not contains a reserved word and + does not start with a reserved word. + + :param resource_name_definition: Resource object with values for resource name and resource + type. Is either a model type or a IO type. Default value is None. + :type resource_name_definition: + ~azure.mgmt.resource.subscriptions.v2016_06_01.models.ResourceName or IO + :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. + Default value is None. + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: CheckResourceNameResult or the result of cls(response) + :rtype: ~azure.mgmt.resource.subscriptions.v2016_06_01.models.CheckResourceNameResult + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.CheckResourceNameResult"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', "2016-06-01") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + api_version = kwargs.pop("api_version", _params.pop("api-version", "2016-06-01")) # type: str + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.CheckResourceNameResult] - if resource_name_definition is not None: - _json = self._serialize.body(resource_name_definition, 'ResourceName') + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(resource_name_definition, (IO, bytes)): + _content = resource_name_definition else: - _json = None + if resource_name_definition is not None: + _json = self._serialize.body(resource_name_definition, "ResourceName") + else: + _json = None request = build_check_resource_name_request( api_version=api_version, content_type=content_type, json=_json, - template_url=self.check_resource_name.metadata['url'], + content=_content, + template_url=self.check_resource_name.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200]: @@ -761,12 +835,11 @@ def check_resource_name( error = self._deserialize.failsafe_deserialize(_models.ErrorResponseAutoGenerated, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - deserialized = self._deserialize('CheckResourceNameResult', pipeline_response) + deserialized = self._deserialize("CheckResourceNameResult", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - check_resource_name.metadata = {'url': "/providers/Microsoft.Resources/checkResourceName"} # type: ignore - + check_resource_name.metadata = {"url": "/providers/Microsoft.Resources/checkResourceName"} # type: ignore diff --git a/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/subscriptions/v2016_06_01/operations/_patch.py b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/subscriptions/v2016_06_01/operations/_patch.py new file mode 100644 index 0000000000000..f7dd32510333d --- /dev/null +++ b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/subscriptions/v2016_06_01/operations/_patch.py @@ -0,0 +1,20 @@ +# ------------------------------------ +# Copyright (c) Microsoft Corporation. +# Licensed under the MIT License. +# ------------------------------------ +"""Customize generated code here. + +Follow our quickstart for examples: https://aka.ms/azsdk/python/dpcodegen/python/customize +""" +from typing import List + +__all__: List[str] = [] # Add all objects you want publicly available to users at this package level + + +def patch_sdk(): + """Do not remove from this file. + + `patch_sdk` is a last resort escape hatch that allows you to do customizations + you can't accomplish using the techniques described in + https://aka.ms/azsdk/python/dpcodegen/python/customize + """ diff --git a/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/subscriptions/v2018_06_01/__init__.py b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/subscriptions/v2018_06_01/__init__.py index abd8e21f33387..d5d8e357d6a54 100644 --- a/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/subscriptions/v2018_06_01/__init__.py +++ b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/subscriptions/v2018_06_01/__init__.py @@ -10,9 +10,15 @@ from ._version import VERSION __version__ = VERSION -__all__ = ['SubscriptionClient'] -# `._patch.py` is used for handwritten extensions to the generated code -# Example: https://github.com/Azure/azure-sdk-for-python/blob/main/doc/dev/customize_code/how-to-patch-sdk-code.md -from ._patch import patch_sdk -patch_sdk() +try: + from ._patch import __all__ as _patch_all + from ._patch import * # type: ignore # pylint: disable=unused-wildcard-import +except ImportError: + _patch_all = [] +from ._patch import patch_sdk as _patch_sdk + +__all__ = ["SubscriptionClient"] +__all__.extend([p for p in _patch_all if p not in __all__]) + +_patch_sdk() diff --git a/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/subscriptions/v2018_06_01/_configuration.py b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/subscriptions/v2018_06_01/_configuration.py index fcb9cdf74ebae..020767bdb3801 100644 --- a/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/subscriptions/v2018_06_01/_configuration.py +++ b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/subscriptions/v2018_06_01/_configuration.py @@ -25,43 +25,40 @@ class SubscriptionClientConfiguration(Configuration): # pylint: disable=too-man Note that all parameters used to create this instance are saved as instance attributes. - :param credential: Credential needed for the client to connect to Azure. + :param credential: Credential needed for the client to connect to Azure. Required. :type credential: ~azure.core.credentials.TokenCredential :keyword api_version: Api Version. Default value is "2018-06-01". Note that overriding this default value may result in unsupported behavior. :paramtype api_version: str """ - def __init__( - self, - credential: "TokenCredential", - **kwargs: Any - ) -> None: + def __init__(self, credential: "TokenCredential", **kwargs: Any) -> None: super(SubscriptionClientConfiguration, self).__init__(**kwargs) - api_version = kwargs.pop('api_version', "2018-06-01") # type: str + api_version = kwargs.pop("api_version", "2018-06-01") # type: str if credential is None: raise ValueError("Parameter 'credential' must not be None.") self.credential = credential self.api_version = api_version - self.credential_scopes = kwargs.pop('credential_scopes', ['https://management.azure.com/.default']) - kwargs.setdefault('sdk_moniker', 'mgmt-resource/{}'.format(VERSION)) + self.credential_scopes = kwargs.pop("credential_scopes", ["https://management.azure.com/.default"]) + kwargs.setdefault("sdk_moniker", "mgmt-resource/{}".format(VERSION)) self._configure(**kwargs) def _configure( - self, - **kwargs # type: Any + self, **kwargs # type: Any ): # type: (...) -> 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) - self.logging_policy = kwargs.get('logging_policy') or policies.NetworkTraceLoggingPolicy(**kwargs) - self.http_logging_policy = kwargs.get('http_logging_policy') or ARMHttpLoggingPolicy(**kwargs) - self.retry_policy = kwargs.get('retry_policy') or policies.RetryPolicy(**kwargs) - self.custom_hook_policy = kwargs.get('custom_hook_policy') or policies.CustomHookPolicy(**kwargs) - self.redirect_policy = kwargs.get('redirect_policy') or policies.RedirectPolicy(**kwargs) - self.authentication_policy = kwargs.get('authentication_policy') + 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) + self.logging_policy = kwargs.get("logging_policy") or policies.NetworkTraceLoggingPolicy(**kwargs) + self.http_logging_policy = kwargs.get("http_logging_policy") or ARMHttpLoggingPolicy(**kwargs) + self.retry_policy = kwargs.get("retry_policy") or policies.RetryPolicy(**kwargs) + self.custom_hook_policy = kwargs.get("custom_hook_policy") or policies.CustomHookPolicy(**kwargs) + self.redirect_policy = kwargs.get("redirect_policy") or policies.RedirectPolicy(**kwargs) + self.authentication_policy = kwargs.get("authentication_policy") if self.credential and not self.authentication_policy: - self.authentication_policy = ARMChallengeAuthenticationPolicy(self.credential, *self.credential_scopes, **kwargs) + self.authentication_policy = ARMChallengeAuthenticationPolicy( + self.credential, *self.credential_scopes, **kwargs + ) diff --git a/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/subscriptions/v2018_06_01/_metadata.json b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/subscriptions/v2018_06_01/_metadata.json index 7717e704e2b89..de41a49c9557d 100644 --- a/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/subscriptions/v2018_06_01/_metadata.json +++ b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/subscriptions/v2018_06_01/_metadata.json @@ -10,14 +10,14 @@ "azure_arm": true, "has_lro_operations": false, "client_side_validation": false, - "sync_imports": "{\"typing\": {\"azurecore\": {\"azure.core.credentials\": [\"TokenCredential\"]}}, \"regular\": {\"azurecore\": {\"azure.profiles\": [\"KnownProfiles\", \"ProfileDefinition\"], \"azure.profiles.multiapiclient\": [\"MultiApiClientMixin\"], \"azure.mgmt.core\": [\"ARMPipelineClient\"]}, \"local\": {\"._configuration\": [\"SubscriptionClientConfiguration\"], \"._operations_mixin\": [\"SubscriptionClientOperationsMixin\"]}, \"thirdparty\": {\"msrest\": [\"Deserializer\", \"Serializer\"]}}, \"conditional\": {\"stdlib\": {\"typing\": [\"Any\", \"Optional\"]}}}", - "async_imports": "{\"typing\": {\"azurecore\": {\"azure.core.credentials_async\": [\"AsyncTokenCredential\"], \"azure.core.credentials\": [\"TokenCredential\"]}}, \"regular\": {\"azurecore\": {\"azure.profiles\": [\"KnownProfiles\", \"ProfileDefinition\"], \"azure.profiles.multiapiclient\": [\"MultiApiClientMixin\"], \"azure.mgmt.core\": [\"AsyncARMPipelineClient\"]}, \"local\": {\"._configuration\": [\"SubscriptionClientConfiguration\"], \"._operations_mixin\": [\"SubscriptionClientOperationsMixin\"]}, \"thirdparty\": {\"msrest\": [\"Deserializer\", \"Serializer\"]}}, \"conditional\": {\"stdlib\": {\"typing\": [\"Any\", \"Optional\"]}}}" + "sync_imports": "{\"conditional\": {\"stdlib\": {\"typing\": [\"Any\", \"Optional\"]}}, \"regular\": {\"azurecore\": {\"azure.mgmt.core\": [\"ARMPipelineClient\"], \"azure.profiles\": [\"KnownProfiles\", \"ProfileDefinition\"], \"azure.profiles.multiapiclient\": [\"MultiApiClientMixin\"]}, \"local\": {\"._configuration\": [\"SubscriptionClientConfiguration\"], \".._serialization\": [\"Deserializer\", \"Serializer\"], \"._operations_mixin\": [\"SubscriptionClientOperationsMixin\"]}}, \"typing\": {\"azurecore\": {\"azure.core.credentials\": [\"TokenCredential\"]}}}", + "async_imports": "{\"conditional\": {\"stdlib\": {\"typing\": [\"Any\", \"Optional\"]}}, \"regular\": {\"azurecore\": {\"azure.mgmt.core\": [\"AsyncARMPipelineClient\"], \"azure.profiles\": [\"KnownProfiles\", \"ProfileDefinition\"], \"azure.profiles.multiapiclient\": [\"MultiApiClientMixin\"]}, \"local\": {\"._configuration\": [\"SubscriptionClientConfiguration\"], \"..._serialization\": [\"Deserializer\", \"Serializer\"], \"._operations_mixin\": [\"SubscriptionClientOperationsMixin\"]}}, \"typing\": {\"azurecore\": {\"azure.core.credentials_async\": [\"AsyncTokenCredential\"]}}}" }, "global_parameters": { "sync": { "credential": { - "signature": "credential, # type: \"TokenCredential\"", - "description": "Credential needed for the client to connect to Azure.", + "signature": "credential: \"TokenCredential\",", + "description": "Credential needed for the client to connect to Azure. Required.", "docstring_type": "~azure.core.credentials.TokenCredential", "required": true } @@ -25,7 +25,7 @@ "async": { "credential": { "signature": "credential: \"AsyncTokenCredential\",", - "description": "Credential needed for the client to connect to Azure.", + "description": "Credential needed for the client to connect to Azure. Required.", "docstring_type": "~azure.core.credentials_async.AsyncTokenCredential", "required": true } @@ -42,7 +42,7 @@ "required": false }, "base_url": { - "signature": "base_url=\"https://management.azure.com\", # type: str", + "signature": "base_url: str = \"https://management.azure.com\",", "description": "Service URL", "docstring_type": "str", "required": false @@ -90,20 +90,21 @@ "tenants": "TenantsOperations" }, "operation_mixins": { - "sync_imports": "{\"conditional\": {\"stdlib\": {\"typing\": [\"Any\", \"Optional\"]}}}", - "async_imports": "{\"conditional\": {\"stdlib\": {\"typing\": [\"Any\", \"Optional\"]}}}", + "sync_imports": "{\"conditional\": {\"stdlib\": {\"typing\": [\"Any\"]}}, \"regular\": {\"local\": {\".\": [[\"models\", \"_models\"]]}, \"stdlib\": {\"typing\": [\"IO\", \"Optional\", \"Union\"]}}}", + "async_imports": "{\"conditional\": {\"stdlib\": {\"typing\": [\"Any\"]}}, \"regular\": {\"local\": {\"..\": [[\"models\", \"_models\"]]}, \"stdlib\": {\"typing\": [\"IO\", \"Optional\", \"Union\"]}}}", "operations": { "check_resource_name" : { "sync": { - "signature": "def check_resource_name(\n self,\n resource_name_definition=None, # type: Optional[\"_models.ResourceName\"]\n **kwargs # type: Any\n):\n # type: (...) -\u003e \"_models.CheckResourceNameResult\"\n", - "doc": "\"\"\"Checks resource name validity.\n\nA resource name is valid if it is not a reserved word, does not contains a reserved word and\ndoes not start with a reserved word.\n\n:param resource_name_definition: Resource object with values for resource name and resource\n type. Default value is None.\n:type resource_name_definition:\n ~azure.mgmt.resource.subscriptions.v2018_06_01.models.ResourceName\n:keyword callable cls: A custom type or function that will be passed the direct response\n:return: CheckResourceNameResult, or the result of cls(response)\n:rtype: ~azure.mgmt.resource.subscriptions.v2018_06_01.models.CheckResourceNameResult\n:raises: ~azure.core.exceptions.HttpResponseError\n\"\"\"" + "signature": "def check_resource_name(\n self,\n resource_name_definition: Optional[Union[_models.ResourceName, IO]] = None,\n **kwargs: Any\n) -\u003e _models.CheckResourceNameResult:\n", + "doc": "\"\"\"Checks resource name validity.\n\nA resource name is valid if it is not a reserved word, does not contains a reserved word and\ndoes not start with a reserved word.\n\n:param resource_name_definition: Resource object with values for resource name and resource\n type. Is either a model type or a IO type. Default value is None.\n:type resource_name_definition:\n ~azure.mgmt.resource.subscriptions.v2018_06_01.models.ResourceName or IO\n:keyword content_type: Body Parameter content-type. Known values are: \u0027application/json\u0027.\n Default value is None.\n:paramtype content_type: str\n:keyword callable cls: A custom type or function that will be passed the direct response\n:return: CheckResourceNameResult or the result of cls(response)\n:rtype: ~azure.mgmt.resource.subscriptions.v2018_06_01.models.CheckResourceNameResult\n:raises ~azure.core.exceptions.HttpResponseError:\n\"\"\"", + "call": "resource_name_definition, **kwargs" }, "async": { "coroutine": true, - "signature": "async def check_resource_name(\n self,\n resource_name_definition: Optional[\"_models.ResourceName\"] = None,\n **kwargs: Any\n) -\u003e \"_models.CheckResourceNameResult\":\n", - "doc": "\"\"\"Checks resource name validity.\n\nA resource name is valid if it is not a reserved word, does not contains a reserved word and\ndoes not start with a reserved word.\n\n:param resource_name_definition: Resource object with values for resource name and resource\n type. Default value is None.\n:type resource_name_definition:\n ~azure.mgmt.resource.subscriptions.v2018_06_01.models.ResourceName\n:keyword callable cls: A custom type or function that will be passed the direct response\n:return: CheckResourceNameResult, or the result of cls(response)\n:rtype: ~azure.mgmt.resource.subscriptions.v2018_06_01.models.CheckResourceNameResult\n:raises: ~azure.core.exceptions.HttpResponseError\n\"\"\"" - }, - "call": "resource_name_definition" + "signature": "async def check_resource_name(\n self,\n resource_name_definition: Optional[Union[_models.ResourceName, IO]] = None,\n **kwargs: Any\n) -\u003e _models.CheckResourceNameResult:\n", + "doc": "\"\"\"Checks resource name validity.\n\nA resource name is valid if it is not a reserved word, does not contains a reserved word and\ndoes not start with a reserved word.\n\n:param resource_name_definition: Resource object with values for resource name and resource\n type. Is either a model type or a IO type. Default value is None.\n:type resource_name_definition:\n ~azure.mgmt.resource.subscriptions.v2018_06_01.models.ResourceName or IO\n:keyword content_type: Body Parameter content-type. Known values are: \u0027application/json\u0027.\n Default value is None.\n:paramtype content_type: str\n:keyword callable cls: A custom type or function that will be passed the direct response\n:return: CheckResourceNameResult or the result of cls(response)\n:rtype: ~azure.mgmt.resource.subscriptions.v2018_06_01.models.CheckResourceNameResult\n:raises ~azure.core.exceptions.HttpResponseError:\n\"\"\"", + "call": "resource_name_definition, **kwargs" + } } } } diff --git a/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/subscriptions/v2018_06_01/_patch.py b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/subscriptions/v2018_06_01/_patch.py index 74e48ecd07cf3..f99e77fef9861 100644 --- a/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/subscriptions/v2018_06_01/_patch.py +++ b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/subscriptions/v2018_06_01/_patch.py @@ -28,4 +28,4 @@ # This file is used for handwritten extensions to the generated code. Example: # https://github.com/Azure/azure-sdk-for-python/blob/main/doc/dev/customize_code/how-to-patch-sdk-code.md def patch_sdk(): - pass \ No newline at end of file + pass diff --git a/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/subscriptions/v2018_06_01/_subscription_client.py b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/subscriptions/v2018_06_01/_subscription_client.py index ebc9586bffb92..33405afa01a76 100644 --- a/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/subscriptions/v2018_06_01/_subscription_client.py +++ b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/subscriptions/v2018_06_01/_subscription_client.py @@ -9,12 +9,11 @@ from copy import deepcopy from typing import Any, TYPE_CHECKING -from msrest import Deserializer, Serializer - from azure.core.rest import HttpRequest, HttpResponse from azure.mgmt.core import ARMPipelineClient from . import models +from .._serialization import Deserializer, Serializer from ._configuration import SubscriptionClientConfiguration from .operations import Operations, SubscriptionClientOperationsMixin, SubscriptionsOperations, TenantsOperations @@ -22,7 +21,8 @@ # pylint: disable=unused-import,ungrouped-imports from azure.core.credentials import TokenCredential -class SubscriptionClient(SubscriptionClientOperationsMixin): + +class SubscriptionClient(SubscriptionClientOperationsMixin): # pylint: disable=client-accepts-api-version-keyword """All resource groups and resources exist within subscriptions. These operation enable you get information about your subscriptions and tenants. A tenant is a dedicated instance of Azure Active Directory (Azure AD) for your organization. @@ -34,7 +34,7 @@ class SubscriptionClient(SubscriptionClientOperationsMixin): azure.mgmt.resource.subscriptions.v2018_06_01.operations.SubscriptionsOperations :ivar tenants: TenantsOperations operations :vartype tenants: azure.mgmt.resource.subscriptions.v2018_06_01.operations.TenantsOperations - :param credential: Credential needed for the client to connect to Azure. + :param credential: Credential needed for the client to connect to Azure. Required. :type credential: ~azure.core.credentials.TokenCredential :param base_url: Service URL. Default value is "https://management.azure.com". :type base_url: str @@ -44,10 +44,7 @@ class SubscriptionClient(SubscriptionClientOperationsMixin): """ def __init__( - self, - credential: "TokenCredential", - base_url: str = "https://management.azure.com", - **kwargs: Any + self, credential: "TokenCredential", base_url: str = "https://management.azure.com", **kwargs: Any ) -> None: self._config = SubscriptionClientConfiguration(credential=credential, **kwargs) self._client = ARMPipelineClient(base_url=base_url, config=self._config, **kwargs) @@ -60,12 +57,7 @@ def __init__( self.subscriptions = SubscriptionsOperations(self._client, self._config, self._serialize, self._deserialize) self.tenants = TenantsOperations(self._client, self._config, self._serialize, self._deserialize) - - def _send_request( - self, - request: HttpRequest, - **kwargs: Any - ) -> HttpResponse: + def _send_request(self, request: HttpRequest, **kwargs: Any) -> HttpResponse: """Runs the network request through the client's chained policies. >>> from azure.core.rest import HttpRequest @@ -74,7 +66,7 @@ def _send_request( >>> response = client._send_request(request) - For more information on this code flow, see https://aka.ms/azsdk/python/protocol/quickstart + For more information on this code flow, see https://aka.ms/azsdk/dpcodegen/python/send_request :param request: The network request you want to make. Required. :type request: ~azure.core.rest.HttpRequest diff --git a/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/subscriptions/v2018_06_01/_vendor.py b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/subscriptions/v2018_06_01/_vendor.py index 138f663c53a4e..71418db2686e7 100644 --- a/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/subscriptions/v2018_06_01/_vendor.py +++ b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/subscriptions/v2018_06_01/_vendor.py @@ -5,8 +5,20 @@ # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- +from abc import ABC +from typing import TYPE_CHECKING + from azure.core.pipeline.transport import HttpRequest +from ._configuration import SubscriptionClientConfiguration + +if TYPE_CHECKING: + # pylint: disable=unused-import,ungrouped-imports + from azure.core import PipelineClient + + from .._serialization import Deserializer, Serializer + + def _convert_request(request, files=None): data = request.content if not files else None request = HttpRequest(method=request.method, url=request.url, headers=request.headers, data=data) @@ -14,6 +26,7 @@ def _convert_request(request, files=None): request.set_formdata_body(files) return request + def _format_url_section(template, **kwargs): components = template.split("/") while components: @@ -21,7 +34,14 @@ def _format_url_section(template, **kwargs): 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 - ] + components = [c for c in formatted_components if "{}".format(key.args[0]) not in c] template = "/".join(components) + + +class MixinABC(ABC): + """DO NOT use this class. It is for internal typing use only.""" + + _client: "PipelineClient" + _config: SubscriptionClientConfiguration + _serialize: "Serializer" + _deserialize: "Deserializer" diff --git a/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/subscriptions/v2018_06_01/_version.py b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/subscriptions/v2018_06_01/_version.py index a012ac01c480c..e5754a47ce68f 100644 --- a/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/subscriptions/v2018_06_01/_version.py +++ b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/subscriptions/v2018_06_01/_version.py @@ -6,4 +6,4 @@ # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -VERSION = "21.1.0" +VERSION = "1.0.0b1" diff --git a/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/subscriptions/v2018_06_01/aio/__init__.py b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/subscriptions/v2018_06_01/aio/__init__.py index e95939087d442..5cfdafc74d6db 100644 --- a/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/subscriptions/v2018_06_01/aio/__init__.py +++ b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/subscriptions/v2018_06_01/aio/__init__.py @@ -7,9 +7,15 @@ # -------------------------------------------------------------------------- from ._subscription_client import SubscriptionClient -__all__ = ['SubscriptionClient'] -# `._patch.py` is used for handwritten extensions to the generated code -# Example: https://github.com/Azure/azure-sdk-for-python/blob/main/doc/dev/customize_code/how-to-patch-sdk-code.md -from ._patch import patch_sdk -patch_sdk() +try: + from ._patch import __all__ as _patch_all + from ._patch import * # type: ignore # pylint: disable=unused-wildcard-import +except ImportError: + _patch_all = [] +from ._patch import patch_sdk as _patch_sdk + +__all__ = ["SubscriptionClient"] +__all__.extend([p for p in _patch_all if p not in __all__]) + +_patch_sdk() diff --git a/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/subscriptions/v2018_06_01/aio/_configuration.py b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/subscriptions/v2018_06_01/aio/_configuration.py index cb294db438564..8bda2cc272494 100644 --- a/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/subscriptions/v2018_06_01/aio/_configuration.py +++ b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/subscriptions/v2018_06_01/aio/_configuration.py @@ -25,42 +25,37 @@ class SubscriptionClientConfiguration(Configuration): # pylint: disable=too-man Note that all parameters used to create this instance are saved as instance attributes. - :param credential: Credential needed for the client to connect to Azure. + :param credential: Credential needed for the client to connect to Azure. Required. :type credential: ~azure.core.credentials_async.AsyncTokenCredential :keyword api_version: Api Version. Default value is "2018-06-01". Note that overriding this default value may result in unsupported behavior. :paramtype api_version: str """ - def __init__( - self, - credential: "AsyncTokenCredential", - **kwargs: Any - ) -> None: + def __init__(self, credential: "AsyncTokenCredential", **kwargs: Any) -> None: super(SubscriptionClientConfiguration, self).__init__(**kwargs) - api_version = kwargs.pop('api_version', "2018-06-01") # type: str + api_version = kwargs.pop("api_version", "2018-06-01") # type: str if credential is None: raise ValueError("Parameter 'credential' must not be None.") self.credential = credential self.api_version = api_version - self.credential_scopes = kwargs.pop('credential_scopes', ['https://management.azure.com/.default']) - kwargs.setdefault('sdk_moniker', 'mgmt-resource/{}'.format(VERSION)) + self.credential_scopes = kwargs.pop("credential_scopes", ["https://management.azure.com/.default"]) + kwargs.setdefault("sdk_moniker", "mgmt-resource/{}".format(VERSION)) self._configure(**kwargs) - 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) - self.logging_policy = kwargs.get('logging_policy') or policies.NetworkTraceLoggingPolicy(**kwargs) - self.http_logging_policy = kwargs.get('http_logging_policy') or ARMHttpLoggingPolicy(**kwargs) - self.retry_policy = kwargs.get('retry_policy') or policies.AsyncRetryPolicy(**kwargs) - self.custom_hook_policy = kwargs.get('custom_hook_policy') or policies.CustomHookPolicy(**kwargs) - self.redirect_policy = kwargs.get('redirect_policy') or policies.AsyncRedirectPolicy(**kwargs) - self.authentication_policy = kwargs.get('authentication_policy') + 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) + self.logging_policy = kwargs.get("logging_policy") or policies.NetworkTraceLoggingPolicy(**kwargs) + self.http_logging_policy = kwargs.get("http_logging_policy") or ARMHttpLoggingPolicy(**kwargs) + self.retry_policy = kwargs.get("retry_policy") or policies.AsyncRetryPolicy(**kwargs) + self.custom_hook_policy = kwargs.get("custom_hook_policy") or policies.CustomHookPolicy(**kwargs) + self.redirect_policy = kwargs.get("redirect_policy") or policies.AsyncRedirectPolicy(**kwargs) + self.authentication_policy = kwargs.get("authentication_policy") if self.credential and not self.authentication_policy: - self.authentication_policy = AsyncARMChallengeAuthenticationPolicy(self.credential, *self.credential_scopes, **kwargs) + self.authentication_policy = AsyncARMChallengeAuthenticationPolicy( + self.credential, *self.credential_scopes, **kwargs + ) diff --git a/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/subscriptions/v2018_06_01/aio/_patch.py b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/subscriptions/v2018_06_01/aio/_patch.py index 74e48ecd07cf3..f99e77fef9861 100644 --- a/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/subscriptions/v2018_06_01/aio/_patch.py +++ b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/subscriptions/v2018_06_01/aio/_patch.py @@ -28,4 +28,4 @@ # This file is used for handwritten extensions to the generated code. Example: # https://github.com/Azure/azure-sdk-for-python/blob/main/doc/dev/customize_code/how-to-patch-sdk-code.md def patch_sdk(): - pass \ No newline at end of file + pass diff --git a/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/subscriptions/v2018_06_01/aio/_subscription_client.py b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/subscriptions/v2018_06_01/aio/_subscription_client.py index 58450a20fb13a..f7ba109c37986 100644 --- a/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/subscriptions/v2018_06_01/aio/_subscription_client.py +++ b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/subscriptions/v2018_06_01/aio/_subscription_client.py @@ -9,12 +9,11 @@ from copy import deepcopy from typing import Any, Awaitable, TYPE_CHECKING -from msrest import Deserializer, Serializer - from azure.core.rest import AsyncHttpResponse, HttpRequest from azure.mgmt.core import AsyncARMPipelineClient from .. import models +from ..._serialization import Deserializer, Serializer from ._configuration import SubscriptionClientConfiguration from .operations import Operations, SubscriptionClientOperationsMixin, SubscriptionsOperations, TenantsOperations @@ -22,7 +21,8 @@ # pylint: disable=unused-import,ungrouped-imports from azure.core.credentials_async import AsyncTokenCredential -class SubscriptionClient(SubscriptionClientOperationsMixin): + +class SubscriptionClient(SubscriptionClientOperationsMixin): # pylint: disable=client-accepts-api-version-keyword """All resource groups and resources exist within subscriptions. These operation enable you get information about your subscriptions and tenants. A tenant is a dedicated instance of Azure Active Directory (Azure AD) for your organization. @@ -35,7 +35,7 @@ class SubscriptionClient(SubscriptionClientOperationsMixin): :ivar tenants: TenantsOperations operations :vartype tenants: azure.mgmt.resource.subscriptions.v2018_06_01.aio.operations.TenantsOperations - :param credential: Credential needed for the client to connect to Azure. + :param credential: Credential needed for the client to connect to Azure. Required. :type credential: ~azure.core.credentials_async.AsyncTokenCredential :param base_url: Service URL. Default value is "https://management.azure.com". :type base_url: str @@ -45,10 +45,7 @@ class SubscriptionClient(SubscriptionClientOperationsMixin): """ def __init__( - self, - credential: "AsyncTokenCredential", - base_url: str = "https://management.azure.com", - **kwargs: Any + self, credential: "AsyncTokenCredential", base_url: str = "https://management.azure.com", **kwargs: Any ) -> None: self._config = SubscriptionClientConfiguration(credential=credential, **kwargs) self._client = AsyncARMPipelineClient(base_url=base_url, config=self._config, **kwargs) @@ -61,12 +58,7 @@ def __init__( self.subscriptions = SubscriptionsOperations(self._client, self._config, self._serialize, self._deserialize) self.tenants = TenantsOperations(self._client, self._config, self._serialize, self._deserialize) - - def _send_request( - self, - request: HttpRequest, - **kwargs: Any - ) -> Awaitable[AsyncHttpResponse]: + def _send_request(self, request: HttpRequest, **kwargs: Any) -> Awaitable[AsyncHttpResponse]: """Runs the network request through the client's chained policies. >>> from azure.core.rest import HttpRequest @@ -75,7 +67,7 @@ def _send_request( >>> response = await client._send_request(request) - For more information on this code flow, see https://aka.ms/azsdk/python/protocol/quickstart + For more information on this code flow, see https://aka.ms/azsdk/dpcodegen/python/send_request :param request: The network request you want to make. Required. :type request: ~azure.core.rest.HttpRequest diff --git a/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/subscriptions/v2018_06_01/aio/_vendor.py b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/subscriptions/v2018_06_01/aio/_vendor.py new file mode 100644 index 0000000000000..3c42eb44b5a3e --- /dev/null +++ b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/subscriptions/v2018_06_01/aio/_vendor.py @@ -0,0 +1,28 @@ +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- + +from abc import ABC +from typing import TYPE_CHECKING + +from azure.core.pipeline.transport import HttpRequest + +from ._configuration import SubscriptionClientConfiguration + +if TYPE_CHECKING: + # pylint: disable=unused-import,ungrouped-imports + from azure.core import AsyncPipelineClient + + from ..._serialization import Deserializer, Serializer + + +class MixinABC(ABC): + """DO NOT use this class. It is for internal typing use only.""" + + _client: "AsyncPipelineClient" + _config: SubscriptionClientConfiguration + _serialize: "Serializer" + _deserialize: "Deserializer" diff --git a/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/subscriptions/v2018_06_01/aio/operations/__init__.py b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/subscriptions/v2018_06_01/aio/operations/__init__.py index 437b49e23548f..1066cb67ea911 100644 --- a/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/subscriptions/v2018_06_01/aio/operations/__init__.py +++ b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/subscriptions/v2018_06_01/aio/operations/__init__.py @@ -11,9 +11,15 @@ from ._operations import TenantsOperations from ._operations import SubscriptionClientOperationsMixin +from ._patch import __all__ as _patch_all +from ._patch import * # type: ignore # pylint: disable=unused-wildcard-import +from ._patch import patch_sdk as _patch_sdk + __all__ = [ - 'Operations', - 'SubscriptionsOperations', - 'TenantsOperations', - 'SubscriptionClientOperationsMixin', + "Operations", + "SubscriptionsOperations", + "TenantsOperations", + "SubscriptionClientOperationsMixin", ] +__all__.extend([p for p in _patch_all if p not in __all__]) +_patch_sdk() diff --git a/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/subscriptions/v2018_06_01/aio/operations/_operations.py b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/subscriptions/v2018_06_01/aio/operations/_operations.py index b507ab97f5708..a6326360285ae 100644 --- a/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/subscriptions/v2018_06_01/aio/operations/_operations.py +++ b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/subscriptions/v2018_06_01/aio/operations/_operations.py @@ -6,82 +6,106 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -from typing import Any, AsyncIterable, Callable, Dict, Optional, TypeVar +from typing import Any, AsyncIterable, Callable, Dict, IO, Optional, TypeVar, Union, overload +from urllib.parse import parse_qs, urljoin, urlparse from azure.core.async_paging import AsyncItemPaged, AsyncList -from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error +from azure.core.exceptions import ( + ClientAuthenticationError, + HttpResponseError, + ResourceExistsError, + ResourceNotFoundError, + ResourceNotModifiedError, + map_error, +) from azure.core.pipeline import PipelineResponse from azure.core.pipeline.transport import AsyncHttpResponse from azure.core.rest import HttpRequest from azure.core.tracing.decorator import distributed_trace from azure.core.tracing.decorator_async import distributed_trace_async +from azure.core.utils import case_insensitive_dict from azure.mgmt.core.exceptions import ARMErrorFormat from ... import models as _models from ..._vendor import _convert_request -from ...operations._operations import build_check_resource_name_request, build_operations_list_request, build_subscriptions_check_zone_peers_request, build_subscriptions_get_request, build_subscriptions_list_locations_request, build_subscriptions_list_request, build_tenants_list_request -T = TypeVar('T') +from ...operations._operations import ( + build_check_resource_name_request, + build_operations_list_request, + build_subscriptions_check_zone_peers_request, + build_subscriptions_get_request, + build_subscriptions_list_locations_request, + build_subscriptions_list_request, + build_tenants_list_request, +) +from .._vendor import MixinABC + +T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] -class Operations: - """Operations async operations. - You should not instantiate this class directly. Instead, you should create a Client instance that - instantiates it for you and attaches it as an attribute. +class Operations: + """ + .. warning:: + **DO NOT** instantiate this class directly. - :ivar models: Alias to model classes used in this operation group. - :type models: ~azure.mgmt.resource.subscriptions.v2018_06_01.models - :param client: Client for service requests. - :param config: Configuration of service client. - :param serializer: An object model serializer. - :param deserializer: An object model deserializer. + Instead, you should access the following operations through + :class:`~azure.mgmt.resource.subscriptions.v2018_06_01.aio.SubscriptionClient`'s + :attr:`operations` attribute. """ models = _models - def __init__(self, client, config, serializer, deserializer) -> None: - self._client = client - self._serialize = serializer - self._deserialize = deserializer - self._config = config + def __init__(self, *args, **kwargs) -> None: + input_args = list(args) + self._client = input_args.pop(0) if input_args else kwargs.pop("client") + self._config = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") @distributed_trace - def list( - self, - **kwargs: Any - ) -> AsyncIterable["_models.OperationListResult"]: + def list(self, **kwargs: Any) -> AsyncIterable["_models.Operation"]: """Lists all of the available Microsoft.Resources REST API operations. :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either OperationListResult or the result of cls(response) + :return: An iterator like instance of either Operation or the result of cls(response) :rtype: - ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.resource.subscriptions.v2018_06_01.models.OperationListResult] - :raises: ~azure.core.exceptions.HttpResponseError + ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.resource.subscriptions.v2018_06_01.models.Operation] + :raises ~azure.core.exceptions.HttpResponseError: """ - api_version = kwargs.pop('api_version', "2018-06-01") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2018-06-01")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[_models.OperationListResult] - cls = kwargs.pop('cls', None) # type: ClsType["_models.OperationListResult"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) + def prepare_request(next_link=None): if not next_link: - + request = build_operations_list_request( api_version=api_version, - template_url=self.list.metadata['url'], + template_url=self.list.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore else: - - request = build_operations_list_request( - template_url=next_link, - ) + # make call to next link with the client's api-version + _parsed_next_link = urlparse(next_link) + _next_request_params = case_insensitive_dict(parse_qs(_parsed_next_link.query)) + _next_request_params["api-version"] = self._config.api_version + request = HttpRequest("GET", urljoin(next_link, _parsed_next_link.path), params=_next_request_params) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore request.method = "GET" return request @@ -95,10 +119,8 @@ async def extract_data(pipeline_response): async def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) response = pipeline_response.http_response @@ -108,78 +130,80 @@ async def get_next(next_link=None): return pipeline_response + return AsyncItemPaged(get_next, extract_data) + + list.metadata = {"url": "/providers/Microsoft.Resources/operations"} # type: ignore - return AsyncItemPaged( - get_next, extract_data - ) - list.metadata = {'url': "/providers/Microsoft.Resources/operations"} # type: ignore -class SubscriptionsOperations: - """SubscriptionsOperations async operations. - You should not instantiate this class directly. Instead, you should create a Client instance that - instantiates it for you and attaches it as an attribute. +class SubscriptionsOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. - :ivar models: Alias to model classes used in this operation group. - :type models: ~azure.mgmt.resource.subscriptions.v2018_06_01.models - :param client: Client for service requests. - :param config: Configuration of service client. - :param serializer: An object model serializer. - :param deserializer: An object model deserializer. + Instead, you should access the following operations through + :class:`~azure.mgmt.resource.subscriptions.v2018_06_01.aio.SubscriptionClient`'s + :attr:`subscriptions` attribute. """ models = _models - def __init__(self, client, config, serializer, deserializer) -> None: - self._client = client - self._serialize = serializer - self._deserialize = deserializer - self._config = config + def __init__(self, *args, **kwargs) -> None: + input_args = list(args) + self._client = input_args.pop(0) if input_args else kwargs.pop("client") + self._config = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") @distributed_trace - def list_locations( - self, - subscription_id: str, - **kwargs: Any - ) -> AsyncIterable["_models.LocationListResult"]: + def list_locations(self, subscription_id: str, **kwargs: Any) -> AsyncIterable["_models.Location"]: """Gets all available geo-locations. This operation provides all the locations that are available for resource providers; however, each resource provider may support a subset of this list. - :param subscription_id: The ID of the target subscription. + :param subscription_id: The ID of the target subscription. Required. :type subscription_id: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either LocationListResult or the result of cls(response) + :return: An iterator like instance of either Location or the result of cls(response) :rtype: - ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.resource.subscriptions.v2018_06_01.models.LocationListResult] - :raises: ~azure.core.exceptions.HttpResponseError + ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.resource.subscriptions.v2018_06_01.models.Location] + :raises ~azure.core.exceptions.HttpResponseError: """ - api_version = kwargs.pop('api_version', "2018-06-01") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2018-06-01")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[_models.LocationListResult] - cls = kwargs.pop('cls', None) # type: ClsType["_models.LocationListResult"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) + def prepare_request(next_link=None): if not next_link: - + request = build_subscriptions_list_locations_request( subscription_id=subscription_id, api_version=api_version, - template_url=self.list_locations.metadata['url'], + template_url=self.list_locations.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore else: - - request = build_subscriptions_list_locations_request( - subscription_id=subscription_id, - template_url=next_link, - ) + # make call to next link with the client's api-version + _parsed_next_link = urlparse(next_link) + _next_request_params = case_insensitive_dict(parse_qs(_parsed_next_link.query)) + _next_request_params["api-version"] = self._config.api_version + request = HttpRequest("GET", urljoin(next_link, _parsed_next_link.path), params=_next_request_params) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore request.method = "GET" return request @@ -193,10 +217,8 @@ async def extract_data(pipeline_response): async def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) response = pipeline_response.http_response @@ -206,103 +228,108 @@ async def get_next(next_link=None): return pipeline_response + return AsyncItemPaged(get_next, extract_data) - return AsyncItemPaged( - get_next, extract_data - ) - list_locations.metadata = {'url': "/subscriptions/{subscriptionId}/locations"} # type: ignore + list_locations.metadata = {"url": "/subscriptions/{subscriptionId}/locations"} # type: ignore @distributed_trace_async - async def get( - self, - subscription_id: str, - **kwargs: Any - ) -> "_models.Subscription": + async def get(self, subscription_id: str, **kwargs: Any) -> _models.Subscription: """Gets details about a specified subscription. - :param subscription_id: The ID of the target subscription. + :param subscription_id: The ID of the target subscription. Required. :type subscription_id: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: Subscription, or the result of cls(response) + :return: Subscription or the result of cls(response) :rtype: ~azure.mgmt.resource.subscriptions.v2018_06_01.models.Subscription - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.Subscription"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) - api_version = kwargs.pop('api_version', "2018-06-01") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2018-06-01")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[_models.Subscription] - request = build_subscriptions_get_request( subscription_id=subscription_id, api_version=api_version, - template_url=self.get.metadata['url'], + template_url=self.get.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) - deserialized = self._deserialize('Subscription', pipeline_response) + deserialized = self._deserialize("Subscription", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - get.metadata = {'url': "/subscriptions/{subscriptionId}"} # type: ignore - + get.metadata = {"url": "/subscriptions/{subscriptionId}"} # type: ignore @distributed_trace - def list( - self, - **kwargs: Any - ) -> AsyncIterable["_models.SubscriptionListResult"]: + def list(self, **kwargs: Any) -> AsyncIterable["_models.Subscription"]: """Gets all subscriptions for a tenant. :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either SubscriptionListResult or the result of - cls(response) + :return: An iterator like instance of either Subscription or the result of cls(response) :rtype: - ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.resource.subscriptions.v2018_06_01.models.SubscriptionListResult] - :raises: ~azure.core.exceptions.HttpResponseError + ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.resource.subscriptions.v2018_06_01.models.Subscription] + :raises ~azure.core.exceptions.HttpResponseError: """ - api_version = kwargs.pop('api_version', "2018-06-01") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2018-06-01")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[_models.SubscriptionListResult] - cls = kwargs.pop('cls', None) # type: ClsType["_models.SubscriptionListResult"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) + def prepare_request(next_link=None): if not next_link: - + request = build_subscriptions_list_request( api_version=api_version, - template_url=self.list.metadata['url'], + template_url=self.list.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore else: - - request = build_subscriptions_list_request( - template_url=next_link, - ) + # make call to next link with the client's api-version + _parsed_next_link = urlparse(next_link) + _next_request_params = case_insensitive_dict(parse_qs(_parsed_next_link.query)) + _next_request_params["api-version"] = self._config.api_version + request = HttpRequest("GET", urljoin(next_link, _parsed_next_link.path), params=_next_request_params) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore request.method = "GET" return request @@ -316,10 +343,8 @@ async def extract_data(pipeline_response): async def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) response = pipeline_response.http_response @@ -329,56 +354,113 @@ async def get_next(next_link=None): return pipeline_response + return AsyncItemPaged(get_next, extract_data) - return AsyncItemPaged( - get_next, extract_data - ) - list.metadata = {'url': "/subscriptions"} # type: ignore + list.metadata = {"url": "/subscriptions"} # type: ignore - @distributed_trace_async + @overload async def check_zone_peers( self, subscription_id: str, - parameters: "_models.CheckZonePeersRequest", + parameters: _models.CheckZonePeersRequest, + *, + content_type: str = "application/json", **kwargs: Any - ) -> "_models.CheckZonePeersResult": + ) -> _models.CheckZonePeersResult: """Compares a subscriptions logical zone mapping. - :param subscription_id: The ID of the target subscription. + :param subscription_id: The ID of the target subscription. Required. :type subscription_id: str - :param parameters: Parameters for checking zone peers. + :param parameters: Parameters for checking zone peers. Required. :type parameters: ~azure.mgmt.resource.subscriptions.v2018_06_01.models.CheckZonePeersRequest + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: CheckZonePeersResult, or the result of cls(response) + :return: CheckZonePeersResult or the result of cls(response) :rtype: ~azure.mgmt.resource.subscriptions.v2018_06_01.models.CheckZonePeersResult - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + async def check_zone_peers( + self, subscription_id: str, parameters: IO, *, content_type: str = "application/json", **kwargs: Any + ) -> _models.CheckZonePeersResult: + """Compares a subscriptions logical zone mapping. + + :param subscription_id: The ID of the target subscription. Required. + :type subscription_id: str + :param parameters: Parameters for checking zone peers. Required. + :type parameters: IO + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: CheckZonePeersResult or the result of cls(response) + :rtype: ~azure.mgmt.resource.subscriptions.v2018_06_01.models.CheckZonePeersResult + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace_async + async def check_zone_peers( + self, subscription_id: str, parameters: Union[_models.CheckZonePeersRequest, IO], **kwargs: Any + ) -> _models.CheckZonePeersResult: + """Compares a subscriptions logical zone mapping. + + :param subscription_id: The ID of the target subscription. Required. + :type subscription_id: str + :param parameters: Parameters for checking zone peers. Is either a model type or a IO type. + Required. + :type parameters: ~azure.mgmt.resource.subscriptions.v2018_06_01.models.CheckZonePeersRequest + or IO + :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. + Default value is None. + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: CheckZonePeersResult or the result of cls(response) + :rtype: ~azure.mgmt.resource.subscriptions.v2018_06_01.models.CheckZonePeersResult + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.CheckZonePeersResult"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) - api_version = kwargs.pop('api_version', "2018-06-01") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - _json = self._serialize.body(parameters, 'CheckZonePeersRequest') + api_version = kwargs.pop("api_version", _params.pop("api-version", "2018-06-01")) # type: str + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.CheckZonePeersResult] + + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(parameters, (IO, bytes)): + _content = parameters + else: + _json = self._serialize.body(parameters, "CheckZonePeersRequest") request = build_subscriptions_check_zone_peers_request( subscription_id=subscription_id, api_version=api_version, content_type=content_type, json=_json, - template_url=self.check_zone_peers.metadata['url'], + content=_content, + template_url=self.check_zone_peers.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200]: @@ -386,74 +468,79 @@ async def check_zone_peers( error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - deserialized = self._deserialize('CheckZonePeersResult', pipeline_response) + deserialized = self._deserialize("CheckZonePeersResult", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - check_zone_peers.metadata = {'url': "/subscriptions/{subscriptionId}/providers/Microsoft.Resources/checkZonePeers/"} # type: ignore + check_zone_peers.metadata = {"url": "/subscriptions/{subscriptionId}/providers/Microsoft.Resources/checkZonePeers/"} # type: ignore -class TenantsOperations: - """TenantsOperations async operations. - You should not instantiate this class directly. Instead, you should create a Client instance that - instantiates it for you and attaches it as an attribute. +class TenantsOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. - :ivar models: Alias to model classes used in this operation group. - :type models: ~azure.mgmt.resource.subscriptions.v2018_06_01.models - :param client: Client for service requests. - :param config: Configuration of service client. - :param serializer: An object model serializer. - :param deserializer: An object model deserializer. + Instead, you should access the following operations through + :class:`~azure.mgmt.resource.subscriptions.v2018_06_01.aio.SubscriptionClient`'s + :attr:`tenants` attribute. """ models = _models - def __init__(self, client, config, serializer, deserializer) -> None: - self._client = client - self._serialize = serializer - self._deserialize = deserializer - self._config = config + def __init__(self, *args, **kwargs) -> None: + input_args = list(args) + self._client = input_args.pop(0) if input_args else kwargs.pop("client") + self._config = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") @distributed_trace - def list( - self, - **kwargs: Any - ) -> AsyncIterable["_models.TenantListResult"]: + def list(self, **kwargs: Any) -> AsyncIterable["_models.TenantIdDescription"]: """Gets the tenants for your account. :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either TenantListResult or the result of cls(response) + :return: An iterator like instance of either TenantIdDescription or the result of cls(response) :rtype: - ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.resource.subscriptions.v2018_06_01.models.TenantListResult] - :raises: ~azure.core.exceptions.HttpResponseError + ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.resource.subscriptions.v2018_06_01.models.TenantIdDescription] + :raises ~azure.core.exceptions.HttpResponseError: """ - api_version = kwargs.pop('api_version', "2018-06-01") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2018-06-01")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[_models.TenantListResult] - cls = kwargs.pop('cls', None) # type: ClsType["_models.TenantListResult"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) + def prepare_request(next_link=None): if not next_link: - + request = build_tenants_list_request( api_version=api_version, - template_url=self.list.metadata['url'], + template_url=self.list.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore else: - - request = build_tenants_list_request( - template_url=next_link, - ) + # make call to next link with the client's api-version + _parsed_next_link = urlparse(next_link) + _next_request_params = case_insensitive_dict(parse_qs(_parsed_next_link.query)) + _next_request_params["api-version"] = self._config.api_version + request = HttpRequest("GET", urljoin(next_link, _parsed_next_link.path), params=_next_request_params) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore request.method = "GET" return request @@ -467,10 +554,8 @@ async def extract_data(pipeline_response): async def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) response = pipeline_response.http_response @@ -480,19 +565,20 @@ async def get_next(next_link=None): return pipeline_response + return AsyncItemPaged(get_next, extract_data) - return AsyncItemPaged( - get_next, extract_data - ) - list.metadata = {'url': "/tenants"} # type: ignore -class SubscriptionClientOperationsMixin: + list.metadata = {"url": "/tenants"} # type: ignore - @distributed_trace_async + +class SubscriptionClientOperationsMixin(MixinABC): + @overload async def check_resource_name( self, - resource_name_definition: Optional["_models.ResourceName"] = None, + resource_name_definition: Optional[_models.ResourceName] = None, + *, + content_type: str = "application/json", **kwargs: Any - ) -> "_models.CheckResourceNameResult": + ) -> _models.CheckResourceNameResult: """Checks resource name validity. A resource name is valid if it is not a reserved word, does not contains a reserved word and @@ -502,39 +588,99 @@ async def check_resource_name( type. Default value is None. :type resource_name_definition: ~azure.mgmt.resource.subscriptions.v2018_06_01.models.ResourceName + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: CheckResourceNameResult, or the result of cls(response) + :return: CheckResourceNameResult or the result of cls(response) :rtype: ~azure.mgmt.resource.subscriptions.v2018_06_01.models.CheckResourceNameResult - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + async def check_resource_name( + self, resource_name_definition: Optional[IO] = None, *, content_type: str = "application/json", **kwargs: Any + ) -> _models.CheckResourceNameResult: + """Checks resource name validity. + + A resource name is valid if it is not a reserved word, does not contains a reserved word and + does not start with a reserved word. + + :param resource_name_definition: Resource object with values for resource name and resource + type. Default value is None. + :type resource_name_definition: IO + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: CheckResourceNameResult or the result of cls(response) + :rtype: ~azure.mgmt.resource.subscriptions.v2018_06_01.models.CheckResourceNameResult + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace_async + async def check_resource_name( + self, resource_name_definition: Optional[Union[_models.ResourceName, IO]] = None, **kwargs: Any + ) -> _models.CheckResourceNameResult: + """Checks resource name validity. + + A resource name is valid if it is not a reserved word, does not contains a reserved word and + does not start with a reserved word. + + :param resource_name_definition: Resource object with values for resource name and resource + type. Is either a model type or a IO type. Default value is None. + :type resource_name_definition: + ~azure.mgmt.resource.subscriptions.v2018_06_01.models.ResourceName or IO + :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. + Default value is None. + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: CheckResourceNameResult or the result of cls(response) + :rtype: ~azure.mgmt.resource.subscriptions.v2018_06_01.models.CheckResourceNameResult + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.CheckResourceNameResult"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', "2018-06-01") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + api_version = kwargs.pop("api_version", _params.pop("api-version", "2018-06-01")) # type: str + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.CheckResourceNameResult] - if resource_name_definition is not None: - _json = self._serialize.body(resource_name_definition, 'ResourceName') + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(resource_name_definition, (IO, bytes)): + _content = resource_name_definition else: - _json = None + if resource_name_definition is not None: + _json = self._serialize.body(resource_name_definition, "ResourceName") + else: + _json = None request = build_check_resource_name_request( api_version=api_version, content_type=content_type, json=_json, - template_url=self.check_resource_name.metadata['url'], + content=_content, + template_url=self.check_resource_name.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200]: @@ -542,12 +688,11 @@ async def check_resource_name( error = self._deserialize.failsafe_deserialize(_models.ErrorResponseAutoGenerated, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - deserialized = self._deserialize('CheckResourceNameResult', pipeline_response) + deserialized = self._deserialize("CheckResourceNameResult", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - check_resource_name.metadata = {'url': "/providers/Microsoft.Resources/checkResourceName"} # type: ignore - + check_resource_name.metadata = {"url": "/providers/Microsoft.Resources/checkResourceName"} # type: ignore diff --git a/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/subscriptions/v2018_06_01/aio/operations/_patch.py b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/subscriptions/v2018_06_01/aio/operations/_patch.py new file mode 100644 index 0000000000000..f7dd32510333d --- /dev/null +++ b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/subscriptions/v2018_06_01/aio/operations/_patch.py @@ -0,0 +1,20 @@ +# ------------------------------------ +# Copyright (c) Microsoft Corporation. +# Licensed under the MIT License. +# ------------------------------------ +"""Customize generated code here. + +Follow our quickstart for examples: https://aka.ms/azsdk/python/dpcodegen/python/customize +""" +from typing import List + +__all__: List[str] = [] # Add all objects you want publicly available to users at this package level + + +def patch_sdk(): + """Do not remove from this file. + + `patch_sdk` is a last resort escape hatch that allows you to do customizations + you can't accomplish using the techniques described in + https://aka.ms/azsdk/python/dpcodegen/python/customize + """ diff --git a/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/subscriptions/v2018_06_01/models/__init__.py b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/subscriptions/v2018_06_01/models/__init__.py index acb6558a04e63..53f378de6e79f 100644 --- a/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/subscriptions/v2018_06_01/models/__init__.py +++ b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/subscriptions/v2018_06_01/models/__init__.py @@ -28,36 +28,38 @@ from ._models_py3 import TenantIdDescription from ._models_py3 import TenantListResult - -from ._subscription_client_enums import ( - ResourceNameStatus, - SpendingLimit, - SubscriptionState, -) +from ._subscription_client_enums import ResourceNameStatus +from ._subscription_client_enums import SpendingLimit +from ._subscription_client_enums import SubscriptionState +from ._patch import __all__ as _patch_all +from ._patch import * # type: ignore # pylint: disable=unused-wildcard-import +from ._patch import patch_sdk as _patch_sdk __all__ = [ - 'AvailabilityZonePeers', - 'CheckResourceNameResult', - 'CheckZonePeersRequest', - 'CheckZonePeersResult', - 'ErrorAdditionalInfo', - 'ErrorDefinition', - 'ErrorDetail', - 'ErrorResponse', - 'ErrorResponseAutoGenerated', - 'Location', - 'LocationListResult', - 'Operation', - 'OperationDisplay', - 'OperationListResult', - 'Peers', - 'ResourceName', - 'Subscription', - 'SubscriptionListResult', - 'SubscriptionPolicies', - 'TenantIdDescription', - 'TenantListResult', - 'ResourceNameStatus', - 'SpendingLimit', - 'SubscriptionState', + "AvailabilityZonePeers", + "CheckResourceNameResult", + "CheckZonePeersRequest", + "CheckZonePeersResult", + "ErrorAdditionalInfo", + "ErrorDefinition", + "ErrorDetail", + "ErrorResponse", + "ErrorResponseAutoGenerated", + "Location", + "LocationListResult", + "Operation", + "OperationDisplay", + "OperationListResult", + "Peers", + "ResourceName", + "Subscription", + "SubscriptionListResult", + "SubscriptionPolicies", + "TenantIdDescription", + "TenantListResult", + "ResourceNameStatus", + "SpendingLimit", + "SubscriptionState", ] +__all__.extend([p for p in _patch_all if p not in __all__]) +_patch_sdk() diff --git a/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/subscriptions/v2018_06_01/models/_models_py3.py b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/subscriptions/v2018_06_01/models/_models_py3.py index 08800f591202a..ca3f3def15b5d 100644 --- a/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/subscriptions/v2018_06_01/models/_models_py3.py +++ b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/subscriptions/v2018_06_01/models/_models_py3.py @@ -1,4 +1,5 @@ # coding=utf-8 +# pylint: disable=too-many-lines # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. # Licensed under the MIT License. See License.txt in the project root for license information. @@ -6,15 +7,16 @@ # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -from typing import List, Optional, Union +from typing import List, Optional, TYPE_CHECKING, Union -from azure.core.exceptions import HttpResponseError -import msrest.serialization +from ... import _serialization -from ._subscription_client_enums import * +if TYPE_CHECKING: + # pylint: disable=unused-import,ungrouped-imports + from .. import models as _models -class AvailabilityZonePeers(msrest.serialization.Model): +class AvailabilityZonePeers(_serialization.Model): """List of availability zones shared by the subscriptions. Variables are only populated by the server, and will be ignored when sending a request. @@ -26,46 +28,41 @@ class AvailabilityZonePeers(msrest.serialization.Model): """ _validation = { - 'availability_zone': {'readonly': True}, + "availability_zone": {"readonly": True}, } _attribute_map = { - 'availability_zone': {'key': 'availabilityZone', 'type': 'str'}, - 'peers': {'key': 'peers', 'type': '[Peers]'}, + "availability_zone": {"key": "availabilityZone", "type": "str"}, + "peers": {"key": "peers", "type": "[Peers]"}, } - def __init__( - self, - *, - peers: Optional[List["Peers"]] = None, - **kwargs - ): + def __init__(self, *, peers: Optional[List["_models.Peers"]] = None, **kwargs): """ :keyword peers: Details of shared availability zone. :paramtype peers: list[~azure.mgmt.resource.subscriptions.v2018_06_01.models.Peers] """ - super(AvailabilityZonePeers, self).__init__(**kwargs) + super().__init__(**kwargs) self.availability_zone = None self.peers = peers -class CheckResourceNameResult(msrest.serialization.Model): +class CheckResourceNameResult(_serialization.Model): """Resource Name valid if not a reserved word, does not contain a reserved word and does not start with a reserved word. :ivar name: Name of Resource. :vartype name: str :ivar type: Type of Resource. :vartype type: str - :ivar status: Is the resource name Allowed or Reserved. Possible values include: "Allowed", + :ivar status: Is the resource name Allowed or Reserved. Known values are: "Allowed" and "Reserved". :vartype status: str or ~azure.mgmt.resource.subscriptions.v2018_06_01.models.ResourceNameStatus """ _attribute_map = { - 'name': {'key': 'name', 'type': 'str'}, - 'type': {'key': 'type', 'type': 'str'}, - 'status': {'key': 'status', 'type': 'str'}, + "name": {"key": "name", "type": "str"}, + "type": {"key": "type", "type": "str"}, + "status": {"key": "status", "type": "str"}, } def __init__( @@ -73,7 +70,7 @@ def __init__( *, name: Optional[str] = None, type: Optional[str] = None, - status: Optional[Union[str, "ResourceNameStatus"]] = None, + status: Optional[Union[str, "_models.ResourceNameStatus"]] = None, **kwargs ): """ @@ -81,18 +78,18 @@ def __init__( :paramtype name: str :keyword type: Type of Resource. :paramtype type: str - :keyword status: Is the resource name Allowed or Reserved. Possible values include: "Allowed", + :keyword status: Is the resource name Allowed or Reserved. Known values are: "Allowed" and "Reserved". :paramtype status: str or ~azure.mgmt.resource.subscriptions.v2018_06_01.models.ResourceNameStatus """ - super(CheckResourceNameResult, self).__init__(**kwargs) + super().__init__(**kwargs) self.name = name self.type = type self.status = status -class CheckZonePeersRequest(msrest.serialization.Model): +class CheckZonePeersRequest(_serialization.Model): """Check zone peers request parameters. :ivar location: The Microsoft location. @@ -102,29 +99,23 @@ class CheckZonePeersRequest(msrest.serialization.Model): """ _attribute_map = { - 'location': {'key': 'location', 'type': 'str'}, - 'subscription_ids': {'key': 'subscriptionIds', 'type': '[str]'}, + "location": {"key": "location", "type": "str"}, + "subscription_ids": {"key": "subscriptionIds", "type": "[str]"}, } - def __init__( - self, - *, - location: Optional[str] = None, - subscription_ids: Optional[List[str]] = None, - **kwargs - ): + def __init__(self, *, location: Optional[str] = None, subscription_ids: Optional[List[str]] = None, **kwargs): """ :keyword location: The Microsoft location. :paramtype location: str :keyword subscription_ids: The peer Microsoft Azure subscription ID. :paramtype subscription_ids: list[str] """ - super(CheckZonePeersRequest, self).__init__(**kwargs) + super().__init__(**kwargs) self.location = location self.subscription_ids = subscription_ids -class CheckZonePeersResult(msrest.serialization.Model): +class CheckZonePeersResult(_serialization.Model): """Result of the Check zone peers operation. Variables are only populated by the server, and will be ignored when sending a request. @@ -139,20 +130,20 @@ class CheckZonePeersResult(msrest.serialization.Model): """ _validation = { - 'subscription_id': {'readonly': True}, + "subscription_id": {"readonly": True}, } _attribute_map = { - 'subscription_id': {'key': 'subscriptionId', 'type': 'str'}, - 'location': {'key': 'location', 'type': 'str'}, - 'availability_zone_peers': {'key': 'availabilityZonePeers', 'type': '[AvailabilityZonePeers]'}, + "subscription_id": {"key": "subscriptionId", "type": "str"}, + "location": {"key": "location", "type": "str"}, + "availability_zone_peers": {"key": "availabilityZonePeers", "type": "[AvailabilityZonePeers]"}, } def __init__( self, *, location: Optional[str] = None, - availability_zone_peers: Optional[List["AvailabilityZonePeers"]] = None, + availability_zone_peers: Optional[List["_models.AvailabilityZonePeers"]] = None, **kwargs ): """ @@ -162,13 +153,13 @@ def __init__( :paramtype availability_zone_peers: list[~azure.mgmt.resource.subscriptions.v2018_06_01.models.AvailabilityZonePeers] """ - super(CheckZonePeersResult, self).__init__(**kwargs) + super().__init__(**kwargs) self.subscription_id = None self.location = location self.availability_zone_peers = availability_zone_peers -class ErrorAdditionalInfo(msrest.serialization.Model): +class ErrorAdditionalInfo(_serialization.Model): """The resource management error additional info. Variables are only populated by the server, and will be ignored when sending a request. @@ -176,31 +167,27 @@ class ErrorAdditionalInfo(msrest.serialization.Model): :ivar type: The additional info type. :vartype type: str :ivar info: The additional info. - :vartype info: any + :vartype info: JSON """ _validation = { - 'type': {'readonly': True}, - 'info': {'readonly': True}, + "type": {"readonly": True}, + "info": {"readonly": True}, } _attribute_map = { - 'type': {'key': 'type', 'type': 'str'}, - 'info': {'key': 'info', 'type': 'object'}, + "type": {"key": "type", "type": "str"}, + "info": {"key": "info", "type": "object"}, } - def __init__( - self, - **kwargs - ): - """ - """ - super(ErrorAdditionalInfo, self).__init__(**kwargs) + def __init__(self, **kwargs): + """ """ + super().__init__(**kwargs) self.type = None self.info = None -class ErrorDefinition(msrest.serialization.Model): +class ErrorDefinition(_serialization.Model): """Error description and code explaining why resource name is invalid. :ivar message: Description of the error. @@ -210,29 +197,23 @@ class ErrorDefinition(msrest.serialization.Model): """ _attribute_map = { - 'message': {'key': 'message', 'type': 'str'}, - 'code': {'key': 'code', 'type': 'str'}, + "message": {"key": "message", "type": "str"}, + "code": {"key": "code", "type": "str"}, } - def __init__( - self, - *, - message: Optional[str] = None, - code: Optional[str] = None, - **kwargs - ): + def __init__(self, *, message: Optional[str] = None, code: Optional[str] = None, **kwargs): """ :keyword message: Description of the error. :paramtype message: str :keyword code: Code of the error. :paramtype code: str """ - super(ErrorDefinition, self).__init__(**kwargs) + super().__init__(**kwargs) self.message = message self.code = code -class ErrorDetail(msrest.serialization.Model): +class ErrorDetail(_serialization.Model): """The error detail. Variables are only populated by the server, and will be ignored when sending a request. @@ -251,28 +232,24 @@ class ErrorDetail(msrest.serialization.Model): """ _validation = { - 'code': {'readonly': True}, - 'message': {'readonly': True}, - 'target': {'readonly': True}, - 'details': {'readonly': True}, - 'additional_info': {'readonly': True}, + "code": {"readonly": True}, + "message": {"readonly": True}, + "target": {"readonly": True}, + "details": {"readonly": True}, + "additional_info": {"readonly": True}, } _attribute_map = { - 'code': {'key': 'code', 'type': 'str'}, - 'message': {'key': 'message', 'type': 'str'}, - 'target': {'key': 'target', 'type': 'str'}, - 'details': {'key': 'details', 'type': '[ErrorDetail]'}, - 'additional_info': {'key': 'additionalInfo', 'type': '[ErrorAdditionalInfo]'}, + "code": {"key": "code", "type": "str"}, + "message": {"key": "message", "type": "str"}, + "target": {"key": "target", "type": "str"}, + "details": {"key": "details", "type": "[ErrorDetail]"}, + "additional_info": {"key": "additionalInfo", "type": "[ErrorAdditionalInfo]"}, } - def __init__( - self, - **kwargs - ): - """ - """ - super(ErrorDetail, self).__init__(**kwargs) + def __init__(self, **kwargs): + """ """ + super().__init__(**kwargs) self.code = None self.message = None self.target = None @@ -280,7 +257,7 @@ def __init__( self.additional_info = None -class ErrorResponse(msrest.serialization.Model): +class ErrorResponse(_serialization.Model): """Common error response for all Azure Resource Manager APIs to return error details for failed operations. (This also follows the OData error response format.). :ivar error: The error object. @@ -288,24 +265,19 @@ class ErrorResponse(msrest.serialization.Model): """ _attribute_map = { - 'error': {'key': 'error', 'type': 'ErrorDetail'}, + "error": {"key": "error", "type": "ErrorDetail"}, } - def __init__( - self, - *, - error: Optional["ErrorDetail"] = None, - **kwargs - ): + def __init__(self, *, error: Optional["_models.ErrorDetail"] = None, **kwargs): """ :keyword error: The error object. :paramtype error: ~azure.mgmt.resource.subscriptions.v2018_06_01.models.ErrorDetail """ - super(ErrorResponse, self).__init__(**kwargs) + super().__init__(**kwargs) self.error = error -class ErrorResponseAutoGenerated(msrest.serialization.Model): +class ErrorResponseAutoGenerated(_serialization.Model): """Error response. :ivar error: The error details. @@ -313,24 +285,19 @@ class ErrorResponseAutoGenerated(msrest.serialization.Model): """ _attribute_map = { - 'error': {'key': 'error', 'type': 'ErrorDefinition'}, + "error": {"key": "error", "type": "ErrorDefinition"}, } - def __init__( - self, - *, - error: Optional["ErrorDefinition"] = None, - **kwargs - ): + def __init__(self, *, error: Optional["_models.ErrorDefinition"] = None, **kwargs): """ :keyword error: The error details. :paramtype error: ~azure.mgmt.resource.subscriptions.v2018_06_01.models.ErrorDefinition """ - super(ErrorResponseAutoGenerated, self).__init__(**kwargs) + super().__init__(**kwargs) self.error = error -class Location(msrest.serialization.Model): +class Location(_serialization.Model): """Location information. Variables are only populated by the server, and will be ignored when sending a request. @@ -351,30 +318,26 @@ class Location(msrest.serialization.Model): """ _validation = { - 'id': {'readonly': True}, - 'subscription_id': {'readonly': True}, - 'name': {'readonly': True}, - 'display_name': {'readonly': True}, - 'latitude': {'readonly': True}, - 'longitude': {'readonly': True}, + "id": {"readonly": True}, + "subscription_id": {"readonly": True}, + "name": {"readonly": True}, + "display_name": {"readonly": True}, + "latitude": {"readonly": True}, + "longitude": {"readonly": True}, } _attribute_map = { - 'id': {'key': 'id', 'type': 'str'}, - 'subscription_id': {'key': 'subscriptionId', 'type': 'str'}, - 'name': {'key': 'name', 'type': 'str'}, - 'display_name': {'key': 'displayName', 'type': 'str'}, - 'latitude': {'key': 'latitude', 'type': 'str'}, - 'longitude': {'key': 'longitude', 'type': 'str'}, + "id": {"key": "id", "type": "str"}, + "subscription_id": {"key": "subscriptionId", "type": "str"}, + "name": {"key": "name", "type": "str"}, + "display_name": {"key": "displayName", "type": "str"}, + "latitude": {"key": "latitude", "type": "str"}, + "longitude": {"key": "longitude", "type": "str"}, } - def __init__( - self, - **kwargs - ): - """ - """ - super(Location, self).__init__(**kwargs) + def __init__(self, **kwargs): + """ """ + super().__init__(**kwargs) self.id = None self.subscription_id = None self.name = None @@ -383,7 +346,7 @@ def __init__( self.longitude = None -class LocationListResult(msrest.serialization.Model): +class LocationListResult(_serialization.Model): """Location list operation response. :ivar value: An array of locations. @@ -391,24 +354,19 @@ class LocationListResult(msrest.serialization.Model): """ _attribute_map = { - 'value': {'key': 'value', 'type': '[Location]'}, + "value": {"key": "value", "type": "[Location]"}, } - def __init__( - self, - *, - value: Optional[List["Location"]] = None, - **kwargs - ): + def __init__(self, *, value: Optional[List["_models.Location"]] = None, **kwargs): """ :keyword value: An array of locations. :paramtype value: list[~azure.mgmt.resource.subscriptions.v2018_06_01.models.Location] """ - super(LocationListResult, self).__init__(**kwargs) + super().__init__(**kwargs) self.value = value -class Operation(msrest.serialization.Model): +class Operation(_serialization.Model): """Microsoft.Resources operation. :ivar name: Operation name: {provider}/{resource}/{operation}. @@ -418,29 +376,23 @@ class Operation(msrest.serialization.Model): """ _attribute_map = { - 'name': {'key': 'name', 'type': 'str'}, - 'display': {'key': 'display', 'type': 'OperationDisplay'}, + "name": {"key": "name", "type": "str"}, + "display": {"key": "display", "type": "OperationDisplay"}, } - def __init__( - self, - *, - name: Optional[str] = None, - display: Optional["OperationDisplay"] = None, - **kwargs - ): + def __init__(self, *, name: Optional[str] = None, display: Optional["_models.OperationDisplay"] = None, **kwargs): """ :keyword name: Operation name: {provider}/{resource}/{operation}. :paramtype name: str :keyword display: The object that represents the operation. :paramtype display: ~azure.mgmt.resource.subscriptions.v2018_06_01.models.OperationDisplay """ - super(Operation, self).__init__(**kwargs) + super().__init__(**kwargs) self.name = name self.display = display -class OperationDisplay(msrest.serialization.Model): +class OperationDisplay(_serialization.Model): """The object that represents the operation. :ivar provider: Service provider: Microsoft.Resources. @@ -454,10 +406,10 @@ class OperationDisplay(msrest.serialization.Model): """ _attribute_map = { - 'provider': {'key': 'provider', 'type': 'str'}, - 'resource': {'key': 'resource', 'type': 'str'}, - 'operation': {'key': 'operation', 'type': 'str'}, - 'description': {'key': 'description', 'type': 'str'}, + "provider": {"key": "provider", "type": "str"}, + "resource": {"key": "resource", "type": "str"}, + "operation": {"key": "operation", "type": "str"}, + "description": {"key": "description", "type": "str"}, } def __init__( @@ -479,14 +431,14 @@ def __init__( :keyword description: Description of the operation. :paramtype description: str """ - super(OperationDisplay, self).__init__(**kwargs) + super().__init__(**kwargs) self.provider = provider self.resource = resource self.operation = operation self.description = description -class OperationListResult(msrest.serialization.Model): +class OperationListResult(_serialization.Model): """Result of the request to list Microsoft.Resources operations. It contains a list of operations and a URL link to get the next set of results. :ivar value: List of Microsoft.Resources operations. @@ -496,29 +448,23 @@ class OperationListResult(msrest.serialization.Model): """ _attribute_map = { - 'value': {'key': 'value', 'type': '[Operation]'}, - 'next_link': {'key': 'nextLink', 'type': 'str'}, + "value": {"key": "value", "type": "[Operation]"}, + "next_link": {"key": "nextLink", "type": "str"}, } - def __init__( - self, - *, - value: Optional[List["Operation"]] = None, - next_link: Optional[str] = None, - **kwargs - ): + def __init__(self, *, value: Optional[List["_models.Operation"]] = None, next_link: Optional[str] = None, **kwargs): """ :keyword value: List of Microsoft.Resources operations. :paramtype value: list[~azure.mgmt.resource.subscriptions.v2018_06_01.models.Operation] :keyword next_link: URL to get the next set of operation list results if there are any. :paramtype next_link: str """ - super(OperationListResult, self).__init__(**kwargs) + super().__init__(**kwargs) self.value = value self.next_link = next_link -class Peers(msrest.serialization.Model): +class Peers(_serialization.Model): """Information about shared availability zone. Variables are only populated by the server, and will be ignored when sending a request. @@ -530,66 +476,56 @@ class Peers(msrest.serialization.Model): """ _validation = { - 'subscription_id': {'readonly': True}, - 'availability_zone': {'readonly': True}, + "subscription_id": {"readonly": True}, + "availability_zone": {"readonly": True}, } _attribute_map = { - 'subscription_id': {'key': 'subscriptionId', 'type': 'str'}, - 'availability_zone': {'key': 'availabilityZone', 'type': 'str'}, + "subscription_id": {"key": "subscriptionId", "type": "str"}, + "availability_zone": {"key": "availabilityZone", "type": "str"}, } - def __init__( - self, - **kwargs - ): - """ - """ - super(Peers, self).__init__(**kwargs) + def __init__(self, **kwargs): + """ """ + super().__init__(**kwargs) self.subscription_id = None self.availability_zone = None -class ResourceName(msrest.serialization.Model): +class ResourceName(_serialization.Model): """Name and Type of the Resource. All required parameters must be populated in order to send to Azure. - :ivar name: Required. Name of the resource. + :ivar name: Name of the resource. Required. :vartype name: str - :ivar type: Required. The type of the resource. + :ivar type: The type of the resource. Required. :vartype type: str """ _validation = { - 'name': {'required': True}, - 'type': {'required': True}, + "name": {"required": True}, + "type": {"required": True}, } _attribute_map = { - 'name': {'key': 'name', 'type': 'str'}, - 'type': {'key': 'type', 'type': 'str'}, + "name": {"key": "name", "type": "str"}, + "type": {"key": "type", "type": "str"}, } - def __init__( - self, - *, - name: str, - type: str, - **kwargs - ): + def __init__(self, *, name: str, type: str, **kwargs): """ - :keyword name: Required. Name of the resource. + :keyword name: Name of the resource. Required. :paramtype name: str - :keyword type: Required. The type of the resource. + :keyword type: The type of the resource. Required. :paramtype type: str """ - super(ResourceName, self).__init__(**kwargs) + super().__init__(**kwargs) self.name = name self.type = type -class Subscription(msrest.serialization.Model): +class Subscription(_serialization.Model): """Subscription information. Variables are only populated by the server, and will be ignored when sending a request. @@ -604,7 +540,7 @@ class Subscription(msrest.serialization.Model): :ivar tenant_id: The subscription tenant ID. :vartype tenant_id: str :ivar state: The subscription state. Possible values are Enabled, Warned, PastDue, Disabled, - and Deleted. Possible values include: "Enabled", "Warned", "PastDue", "Disabled", "Deleted". + and Deleted. Known values are: "Enabled", "Warned", "PastDue", "Disabled", and "Deleted". :vartype state: str or ~azure.mgmt.resource.subscriptions.v2018_06_01.models.SubscriptionState :ivar subscription_policies: The subscription policies. :vartype subscription_policies: @@ -616,27 +552,27 @@ class Subscription(msrest.serialization.Model): """ _validation = { - 'id': {'readonly': True}, - 'subscription_id': {'readonly': True}, - 'display_name': {'readonly': True}, - 'tenant_id': {'readonly': True}, - 'state': {'readonly': True}, + "id": {"readonly": True}, + "subscription_id": {"readonly": True}, + "display_name": {"readonly": True}, + "tenant_id": {"readonly": True}, + "state": {"readonly": True}, } _attribute_map = { - 'id': {'key': 'id', 'type': 'str'}, - 'subscription_id': {'key': 'subscriptionId', 'type': 'str'}, - 'display_name': {'key': 'displayName', 'type': 'str'}, - 'tenant_id': {'key': 'tenantId', 'type': 'str'}, - 'state': {'key': 'state', 'type': 'str'}, - 'subscription_policies': {'key': 'subscriptionPolicies', 'type': 'SubscriptionPolicies'}, - 'authorization_source': {'key': 'authorizationSource', 'type': 'str'}, + "id": {"key": "id", "type": "str"}, + "subscription_id": {"key": "subscriptionId", "type": "str"}, + "display_name": {"key": "displayName", "type": "str"}, + "tenant_id": {"key": "tenantId", "type": "str"}, + "state": {"key": "state", "type": "str"}, + "subscription_policies": {"key": "subscriptionPolicies", "type": "SubscriptionPolicies"}, + "authorization_source": {"key": "authorizationSource", "type": "str"}, } def __init__( self, *, - subscription_policies: Optional["SubscriptionPolicies"] = None, + subscription_policies: Optional["_models.SubscriptionPolicies"] = None, authorization_source: Optional[str] = None, **kwargs ): @@ -649,7 +585,7 @@ def __init__( RoleBased'. :paramtype authorization_source: str """ - super(Subscription, self).__init__(**kwargs) + super().__init__(**kwargs) self.id = None self.subscription_id = None self.display_name = None @@ -659,45 +595,39 @@ def __init__( self.authorization_source = authorization_source -class SubscriptionListResult(msrest.serialization.Model): +class SubscriptionListResult(_serialization.Model): """Subscription list operation response. All required parameters must be populated in order to send to Azure. :ivar value: An array of subscriptions. :vartype value: list[~azure.mgmt.resource.subscriptions.v2018_06_01.models.Subscription] - :ivar next_link: Required. The URL to get the next set of results. + :ivar next_link: The URL to get the next set of results. Required. :vartype next_link: str """ _validation = { - 'next_link': {'required': True}, + "next_link": {"required": True}, } _attribute_map = { - 'value': {'key': 'value', 'type': '[Subscription]'}, - 'next_link': {'key': 'nextLink', 'type': 'str'}, + "value": {"key": "value", "type": "[Subscription]"}, + "next_link": {"key": "nextLink", "type": "str"}, } - def __init__( - self, - *, - next_link: str, - value: Optional[List["Subscription"]] = None, - **kwargs - ): + def __init__(self, *, next_link: str, value: Optional[List["_models.Subscription"]] = None, **kwargs): """ :keyword value: An array of subscriptions. :paramtype value: list[~azure.mgmt.resource.subscriptions.v2018_06_01.models.Subscription] - :keyword next_link: Required. The URL to get the next set of results. + :keyword next_link: The URL to get the next set of results. Required. :paramtype next_link: str """ - super(SubscriptionListResult, self).__init__(**kwargs) + super().__init__(**kwargs) self.value = value self.next_link = next_link -class SubscriptionPolicies(msrest.serialization.Model): +class SubscriptionPolicies(_serialization.Model): """Subscription policies. Variables are only populated by the server, and will be ignored when sending a request. @@ -708,37 +638,33 @@ class SubscriptionPolicies(msrest.serialization.Model): :vartype location_placement_id: str :ivar quota_id: The subscription quota ID. :vartype quota_id: str - :ivar spending_limit: The subscription spending limit. Possible values include: "On", "Off", + :ivar spending_limit: The subscription spending limit. Known values are: "On", "Off", and "CurrentPeriodOff". :vartype spending_limit: str or ~azure.mgmt.resource.subscriptions.v2018_06_01.models.SpendingLimit """ _validation = { - 'location_placement_id': {'readonly': True}, - 'quota_id': {'readonly': True}, - 'spending_limit': {'readonly': True}, + "location_placement_id": {"readonly": True}, + "quota_id": {"readonly": True}, + "spending_limit": {"readonly": True}, } _attribute_map = { - 'location_placement_id': {'key': 'locationPlacementId', 'type': 'str'}, - 'quota_id': {'key': 'quotaId', 'type': 'str'}, - 'spending_limit': {'key': 'spendingLimit', 'type': 'str'}, + "location_placement_id": {"key": "locationPlacementId", "type": "str"}, + "quota_id": {"key": "quotaId", "type": "str"}, + "spending_limit": {"key": "spendingLimit", "type": "str"}, } - def __init__( - self, - **kwargs - ): - """ - """ - super(SubscriptionPolicies, self).__init__(**kwargs) + def __init__(self, **kwargs): + """ """ + super().__init__(**kwargs) self.location_placement_id = None self.quota_id = None self.spending_limit = None -class TenantIdDescription(msrest.serialization.Model): +class TenantIdDescription(_serialization.Model): """Tenant Id information. Variables are only populated by the server, and will be ignored when sending a request. @@ -759,30 +685,26 @@ class TenantIdDescription(msrest.serialization.Model): """ _validation = { - 'id': {'readonly': True}, - 'tenant_id': {'readonly': True}, - 'country': {'readonly': True}, - 'country_code': {'readonly': True}, - 'display_name': {'readonly': True}, - 'domains': {'readonly': True}, + "id": {"readonly": True}, + "tenant_id": {"readonly": True}, + "country": {"readonly": True}, + "country_code": {"readonly": True}, + "display_name": {"readonly": True}, + "domains": {"readonly": True}, } _attribute_map = { - 'id': {'key': 'id', 'type': 'str'}, - 'tenant_id': {'key': 'tenantId', 'type': 'str'}, - 'country': {'key': 'country', 'type': 'str'}, - 'country_code': {'key': 'countryCode', 'type': 'str'}, - 'display_name': {'key': 'displayName', 'type': 'str'}, - 'domains': {'key': 'domains', 'type': '[str]'}, + "id": {"key": "id", "type": "str"}, + "tenant_id": {"key": "tenantId", "type": "str"}, + "country": {"key": "country", "type": "str"}, + "country_code": {"key": "countryCode", "type": "str"}, + "display_name": {"key": "displayName", "type": "str"}, + "domains": {"key": "domains", "type": "[str]"}, } - def __init__( - self, - **kwargs - ): - """ - """ - super(TenantIdDescription, self).__init__(**kwargs) + def __init__(self, **kwargs): + """ """ + super().__init__(**kwargs) self.id = None self.tenant_id = None self.country = None @@ -791,40 +713,34 @@ def __init__( self.domains = None -class TenantListResult(msrest.serialization.Model): +class TenantListResult(_serialization.Model): """Tenant Ids information. All required parameters must be populated in order to send to Azure. :ivar value: An array of tenants. :vartype value: list[~azure.mgmt.resource.subscriptions.v2018_06_01.models.TenantIdDescription] - :ivar next_link: Required. The URL to use for getting the next set of results. + :ivar next_link: The URL to use for getting the next set of results. Required. :vartype next_link: str """ _validation = { - 'next_link': {'required': True}, + "next_link": {"required": True}, } _attribute_map = { - 'value': {'key': 'value', 'type': '[TenantIdDescription]'}, - 'next_link': {'key': 'nextLink', 'type': 'str'}, + "value": {"key": "value", "type": "[TenantIdDescription]"}, + "next_link": {"key": "nextLink", "type": "str"}, } - def __init__( - self, - *, - next_link: str, - value: Optional[List["TenantIdDescription"]] = None, - **kwargs - ): + def __init__(self, *, next_link: str, value: Optional[List["_models.TenantIdDescription"]] = None, **kwargs): """ :keyword value: An array of tenants. :paramtype value: list[~azure.mgmt.resource.subscriptions.v2018_06_01.models.TenantIdDescription] - :keyword next_link: Required. The URL to use for getting the next set of results. + :keyword next_link: The URL to use for getting the next set of results. Required. :paramtype next_link: str """ - super(TenantListResult, self).__init__(**kwargs) + super().__init__(**kwargs) self.value = value self.next_link = next_link diff --git a/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/subscriptions/v2018_06_01/models/_patch.py b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/subscriptions/v2018_06_01/models/_patch.py new file mode 100644 index 0000000000000..f7dd32510333d --- /dev/null +++ b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/subscriptions/v2018_06_01/models/_patch.py @@ -0,0 +1,20 @@ +# ------------------------------------ +# Copyright (c) Microsoft Corporation. +# Licensed under the MIT License. +# ------------------------------------ +"""Customize generated code here. + +Follow our quickstart for examples: https://aka.ms/azsdk/python/dpcodegen/python/customize +""" +from typing import List + +__all__: List[str] = [] # Add all objects you want publicly available to users at this package level + + +def patch_sdk(): + """Do not remove from this file. + + `patch_sdk` is a last resort escape hatch that allows you to do customizations + you can't accomplish using the techniques described in + https://aka.ms/azsdk/python/dpcodegen/python/customize + """ diff --git a/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/subscriptions/v2018_06_01/models/_subscription_client_enums.py b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/subscriptions/v2018_06_01/models/_subscription_client_enums.py index 6465a926ff236..2ed8f2018d081 100644 --- a/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/subscriptions/v2018_06_01/models/_subscription_client_enums.py +++ b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/subscriptions/v2018_06_01/models/_subscription_client_enums.py @@ -7,28 +7,26 @@ # -------------------------------------------------------------------------- from enum import Enum -from six import with_metaclass from azure.core import CaseInsensitiveEnumMeta -class ResourceNameStatus(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): - """Is the resource name Allowed or Reserved - """ +class ResourceNameStatus(str, Enum, metaclass=CaseInsensitiveEnumMeta): + """Is the resource name Allowed or Reserved.""" ALLOWED = "Allowed" RESERVED = "Reserved" -class SpendingLimit(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): - """The subscription spending limit. - """ + +class SpendingLimit(str, Enum, metaclass=CaseInsensitiveEnumMeta): + """The subscription spending limit.""" ON = "On" OFF = "Off" CURRENT_PERIOD_OFF = "CurrentPeriodOff" -class SubscriptionState(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): - """The subscription state. Possible values are Enabled, Warned, PastDue, Disabled, and Deleted. - """ + +class SubscriptionState(str, Enum, metaclass=CaseInsensitiveEnumMeta): + """The subscription state. Possible values are Enabled, Warned, PastDue, Disabled, and Deleted.""" ENABLED = "Enabled" WARNED = "Warned" diff --git a/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/subscriptions/v2018_06_01/operations/__init__.py b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/subscriptions/v2018_06_01/operations/__init__.py index 437b49e23548f..1066cb67ea911 100644 --- a/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/subscriptions/v2018_06_01/operations/__init__.py +++ b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/subscriptions/v2018_06_01/operations/__init__.py @@ -11,9 +11,15 @@ from ._operations import TenantsOperations from ._operations import SubscriptionClientOperationsMixin +from ._patch import __all__ as _patch_all +from ._patch import * # type: ignore # pylint: disable=unused-wildcard-import +from ._patch import patch_sdk as _patch_sdk + __all__ = [ - 'Operations', - 'SubscriptionsOperations', - 'TenantsOperations', - 'SubscriptionClientOperationsMixin', + "Operations", + "SubscriptionsOperations", + "TenantsOperations", + "SubscriptionClientOperationsMixin", ] +__all__.extend([p for p in _patch_all if p not in __all__]) +_patch_sdk() diff --git a/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/subscriptions/v2018_06_01/operations/_operations.py b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/subscriptions/v2018_06_01/operations/_operations.py index 5e74b87b52272..ceb0136a64ea5 100644 --- a/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/subscriptions/v2018_06_01/operations/_operations.py +++ b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/subscriptions/v2018_06_01/operations/_operations.py @@ -6,301 +6,253 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -from typing import Any, Callable, Dict, Iterable, Optional, TypeVar - -from msrest import Serializer - -from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error +from typing import Any, Callable, Dict, IO, Iterable, Optional, TypeVar, Union, overload +from urllib.parse import parse_qs, urljoin, urlparse + +from azure.core.exceptions import ( + ClientAuthenticationError, + HttpResponseError, + ResourceExistsError, + ResourceNotFoundError, + ResourceNotModifiedError, + map_error, +) from azure.core.paging import ItemPaged from azure.core.pipeline import PipelineResponse from azure.core.pipeline.transport import HttpResponse from azure.core.rest import HttpRequest from azure.core.tracing.decorator import distributed_trace +from azure.core.utils import case_insensitive_dict from azure.mgmt.core.exceptions import ARMErrorFormat from .. import models as _models -from .._vendor import _convert_request, _format_url_section -T = TypeVar('T') +from ..._serialization import Serializer +from .._vendor import MixinABC, _convert_request, _format_url_section + +T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] -JSONType = Any _SERIALIZER = Serializer() _SERIALIZER.client_side_validation = False -def build_operations_list_request( - **kwargs: Any -) -> HttpRequest: - api_version = kwargs.pop('api_version', "2018-06-01") # type: str - accept = "application/json" +def build_operations_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", "2018-06-01")) # type: str + accept = _headers.pop("Accept", "application/json") + # Construct URL _url = kwargs.pop("template_url", "/providers/Microsoft.Resources/operations") # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) - return HttpRequest( - method="GET", - url=_url, - params=_query_parameters, - headers=_header_parameters, - **kwargs - ) +def build_subscriptions_list_locations_request(subscription_id: str, **kwargs: Any) -> HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) -def build_subscriptions_list_locations_request( - subscription_id: str, - **kwargs: Any -) -> HttpRequest: - api_version = kwargs.pop('api_version', "2018-06-01") # type: str + api_version = kwargs.pop("api_version", _params.pop("api-version", "2018-06-01")) # type: str + accept = _headers.pop("Accept", "application/json") - accept = "application/json" # Construct URL _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/locations") path_format_arguments = { - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), } _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - return HttpRequest( - method="GET", - url=_url, - params=_query_parameters, - headers=_header_parameters, - **kwargs - ) + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) -def build_subscriptions_get_request( - subscription_id: str, - **kwargs: Any -) -> HttpRequest: - api_version = kwargs.pop('api_version', "2018-06-01") # type: str +def build_subscriptions_get_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", "2018-06-01")) # type: str + accept = _headers.pop("Accept", "application/json") - accept = "application/json" # Construct URL _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}") path_format_arguments = { - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), } _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) - return HttpRequest( - method="GET", - url=_url, - params=_query_parameters, - headers=_header_parameters, - **kwargs - ) +def build_subscriptions_list_request(**kwargs: Any) -> HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) -def build_subscriptions_list_request( - **kwargs: Any -) -> HttpRequest: - api_version = kwargs.pop('api_version', "2018-06-01") # type: str + api_version = kwargs.pop("api_version", _params.pop("api-version", "2018-06-01")) # type: str + accept = _headers.pop("Accept", "application/json") - accept = "application/json" # Construct URL _url = kwargs.pop("template_url", "/subscriptions") # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') - - return HttpRequest( - method="GET", - url=_url, - params=_query_parameters, - headers=_header_parameters, - **kwargs - ) - - -def build_subscriptions_check_zone_peers_request( - subscription_id: str, - *, - json: JSONType = None, - content: Any = None, - **kwargs: Any -) -> HttpRequest: - api_version = kwargs.pop('api_version', "2018-06-01") # type: str - content_type = kwargs.pop('content_type', None) # type: Optional[str] - - accept = "application/json" + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) + + +def build_subscriptions_check_zone_peers_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", "2018-06-01")) # type: str + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + accept = _headers.pop("Accept", "application/json") + # Construct URL _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/providers/Microsoft.Resources/checkZonePeers/") path_format_arguments = { - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), } _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] if content_type is not None: - _header_parameters['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') - _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') - - return HttpRequest( - method="POST", - url=_url, - params=_query_parameters, - headers=_header_parameters, - json=json, - content=content, - **kwargs - ) - - -def build_tenants_list_request( - **kwargs: Any -) -> HttpRequest: - api_version = kwargs.pop('api_version', "2018-06-01") # type: str - - accept = "application/json" + _headers["Content-Type"] = _SERIALIZER.header("content_type", content_type, "str") + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="POST", url=_url, params=_params, headers=_headers, **kwargs) + + +def build_tenants_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", "2018-06-01")) # type: str + accept = _headers.pop("Accept", "application/json") + # Construct URL _url = kwargs.pop("template_url", "/tenants") # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') - - return HttpRequest( - method="GET", - url=_url, - params=_query_parameters, - headers=_header_parameters, - **kwargs - ) - - -def build_check_resource_name_request( - *, - json: JSONType = None, - content: Any = None, - **kwargs: Any -) -> HttpRequest: - api_version = kwargs.pop('api_version', "2018-06-01") # type: str - content_type = kwargs.pop('content_type', None) # type: Optional[str] - - accept = "application/json" + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) + + +def build_check_resource_name_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", "2018-06-01")) # type: str + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + accept = _headers.pop("Accept", "application/json") + # Construct URL _url = kwargs.pop("template_url", "/providers/Microsoft.Resources/checkResourceName") # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] if content_type is not None: - _header_parameters['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') - _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') - - return HttpRequest( - method="POST", - url=_url, - params=_query_parameters, - headers=_header_parameters, - json=json, - content=content, - **kwargs - ) - -class Operations(object): - """Operations operations. - - You should not instantiate this class directly. Instead, you should create a Client instance that - instantiates it for you and attaches it as an attribute. - - :ivar models: Alias to model classes used in this operation group. - :type models: ~azure.mgmt.resource.subscriptions.v2018_06_01.models - :param client: Client for service requests. - :param config: Configuration of service client. - :param serializer: An object model serializer. - :param deserializer: An object model deserializer. + _headers["Content-Type"] = _SERIALIZER.header("content_type", content_type, "str") + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="POST", url=_url, params=_params, headers=_headers, **kwargs) + + +class Operations: + """ + .. warning:: + **DO NOT** instantiate this class directly. + + Instead, you should access the following operations through + :class:`~azure.mgmt.resource.subscriptions.v2018_06_01.SubscriptionClient`'s + :attr:`operations` attribute. """ models = _models - def __init__(self, client, config, serializer, deserializer): - self._client = client - self._serialize = serializer - self._deserialize = deserializer - self._config = config + def __init__(self, *args, **kwargs): + input_args = list(args) + self._client = input_args.pop(0) if input_args else kwargs.pop("client") + self._config = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") @distributed_trace - def list( - self, - **kwargs: Any - ) -> Iterable["_models.OperationListResult"]: + def list(self, **kwargs: Any) -> Iterable["_models.Operation"]: """Lists all of the available Microsoft.Resources REST API operations. :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either OperationListResult or the result of cls(response) + :return: An iterator like instance of either Operation or the result of cls(response) :rtype: - ~azure.core.paging.ItemPaged[~azure.mgmt.resource.subscriptions.v2018_06_01.models.OperationListResult] - :raises: ~azure.core.exceptions.HttpResponseError + ~azure.core.paging.ItemPaged[~azure.mgmt.resource.subscriptions.v2018_06_01.models.Operation] + :raises ~azure.core.exceptions.HttpResponseError: """ - api_version = kwargs.pop('api_version', "2018-06-01") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2018-06-01")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[_models.OperationListResult] - cls = kwargs.pop('cls', None) # type: ClsType["_models.OperationListResult"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) + def prepare_request(next_link=None): if not next_link: - + request = build_operations_list_request( api_version=api_version, - template_url=self.list.metadata['url'], + template_url=self.list.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore else: - - request = build_operations_list_request( - template_url=next_link, - ) + # make call to next link with the client's api-version + _parsed_next_link = urlparse(next_link) + _next_request_params = case_insensitive_dict(parse_qs(_parsed_next_link.query)) + _next_request_params["api-version"] = self._config.api_version + request = HttpRequest("GET", urljoin(next_link, _parsed_next_link.path), params=_next_request_params) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore request.method = "GET" return request @@ -314,10 +266,8 @@ def extract_data(pipeline_response): def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) response = pipeline_response.http_response @@ -327,78 +277,80 @@ def get_next(next_link=None): return pipeline_response + return ItemPaged(get_next, extract_data) - return ItemPaged( - get_next, extract_data - ) - list.metadata = {'url': "/providers/Microsoft.Resources/operations"} # type: ignore -class SubscriptionsOperations(object): - """SubscriptionsOperations operations. - - You should not instantiate this class directly. Instead, you should create a Client instance that - instantiates it for you and attaches it as an attribute. - - :ivar models: Alias to model classes used in this operation group. - :type models: ~azure.mgmt.resource.subscriptions.v2018_06_01.models - :param client: Client for service requests. - :param config: Configuration of service client. - :param serializer: An object model serializer. - :param deserializer: An object model deserializer. + list.metadata = {"url": "/providers/Microsoft.Resources/operations"} # type: ignore + + +class SubscriptionsOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. + + Instead, you should access the following operations through + :class:`~azure.mgmt.resource.subscriptions.v2018_06_01.SubscriptionClient`'s + :attr:`subscriptions` attribute. """ models = _models - def __init__(self, client, config, serializer, deserializer): - self._client = client - self._serialize = serializer - self._deserialize = deserializer - self._config = config + def __init__(self, *args, **kwargs): + input_args = list(args) + self._client = input_args.pop(0) if input_args else kwargs.pop("client") + self._config = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") @distributed_trace - def list_locations( - self, - subscription_id: str, - **kwargs: Any - ) -> Iterable["_models.LocationListResult"]: + def list_locations(self, subscription_id: str, **kwargs: Any) -> Iterable["_models.Location"]: """Gets all available geo-locations. This operation provides all the locations that are available for resource providers; however, each resource provider may support a subset of this list. - :param subscription_id: The ID of the target subscription. + :param subscription_id: The ID of the target subscription. Required. :type subscription_id: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either LocationListResult or the result of cls(response) + :return: An iterator like instance of either Location or the result of cls(response) :rtype: - ~azure.core.paging.ItemPaged[~azure.mgmt.resource.subscriptions.v2018_06_01.models.LocationListResult] - :raises: ~azure.core.exceptions.HttpResponseError + ~azure.core.paging.ItemPaged[~azure.mgmt.resource.subscriptions.v2018_06_01.models.Location] + :raises ~azure.core.exceptions.HttpResponseError: """ - api_version = kwargs.pop('api_version', "2018-06-01") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2018-06-01")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[_models.LocationListResult] - cls = kwargs.pop('cls', None) # type: ClsType["_models.LocationListResult"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) + def prepare_request(next_link=None): if not next_link: - + request = build_subscriptions_list_locations_request( subscription_id=subscription_id, api_version=api_version, - template_url=self.list_locations.metadata['url'], + template_url=self.list_locations.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore else: - - request = build_subscriptions_list_locations_request( - subscription_id=subscription_id, - template_url=next_link, - ) + # make call to next link with the client's api-version + _parsed_next_link = urlparse(next_link) + _next_request_params = case_insensitive_dict(parse_qs(_parsed_next_link.query)) + _next_request_params["api-version"] = self._config.api_version + request = HttpRequest("GET", urljoin(next_link, _parsed_next_link.path), params=_next_request_params) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore request.method = "GET" return request @@ -412,10 +364,8 @@ def extract_data(pipeline_response): def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) response = pipeline_response.http_response @@ -425,103 +375,108 @@ def get_next(next_link=None): return pipeline_response + return ItemPaged(get_next, extract_data) - return ItemPaged( - get_next, extract_data - ) - list_locations.metadata = {'url': "/subscriptions/{subscriptionId}/locations"} # type: ignore + list_locations.metadata = {"url": "/subscriptions/{subscriptionId}/locations"} # type: ignore @distributed_trace - def get( - self, - subscription_id: str, - **kwargs: Any - ) -> "_models.Subscription": + def get(self, subscription_id: str, **kwargs: Any) -> _models.Subscription: """Gets details about a specified subscription. - :param subscription_id: The ID of the target subscription. + :param subscription_id: The ID of the target subscription. Required. :type subscription_id: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: Subscription, or the result of cls(response) + :return: Subscription or the result of cls(response) :rtype: ~azure.mgmt.resource.subscriptions.v2018_06_01.models.Subscription - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.Subscription"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + 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', "2018-06-01") # type: str + api_version = kwargs.pop("api_version", _params.pop("api-version", "2018-06-01")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[_models.Subscription] - request = build_subscriptions_get_request( subscription_id=subscription_id, api_version=api_version, - template_url=self.get.metadata['url'], + template_url=self.get.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) - deserialized = self._deserialize('Subscription', pipeline_response) + deserialized = self._deserialize("Subscription", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - get.metadata = {'url': "/subscriptions/{subscriptionId}"} # type: ignore - + get.metadata = {"url": "/subscriptions/{subscriptionId}"} # type: ignore @distributed_trace - def list( - self, - **kwargs: Any - ) -> Iterable["_models.SubscriptionListResult"]: + def list(self, **kwargs: Any) -> Iterable["_models.Subscription"]: """Gets all subscriptions for a tenant. :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either SubscriptionListResult or the result of - cls(response) + :return: An iterator like instance of either Subscription or the result of cls(response) :rtype: - ~azure.core.paging.ItemPaged[~azure.mgmt.resource.subscriptions.v2018_06_01.models.SubscriptionListResult] - :raises: ~azure.core.exceptions.HttpResponseError + ~azure.core.paging.ItemPaged[~azure.mgmt.resource.subscriptions.v2018_06_01.models.Subscription] + :raises ~azure.core.exceptions.HttpResponseError: """ - api_version = kwargs.pop('api_version', "2018-06-01") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2018-06-01")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[_models.SubscriptionListResult] - cls = kwargs.pop('cls', None) # type: ClsType["_models.SubscriptionListResult"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) + def prepare_request(next_link=None): if not next_link: - + request = build_subscriptions_list_request( api_version=api_version, - template_url=self.list.metadata['url'], + template_url=self.list.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore else: - - request = build_subscriptions_list_request( - template_url=next_link, - ) + # make call to next link with the client's api-version + _parsed_next_link = urlparse(next_link) + _next_request_params = case_insensitive_dict(parse_qs(_parsed_next_link.query)) + _next_request_params["api-version"] = self._config.api_version + request = HttpRequest("GET", urljoin(next_link, _parsed_next_link.path), params=_next_request_params) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore request.method = "GET" return request @@ -535,10 +490,8 @@ def extract_data(pipeline_response): def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) response = pipeline_response.http_response @@ -548,56 +501,113 @@ def get_next(next_link=None): return pipeline_response + return ItemPaged(get_next, extract_data) - return ItemPaged( - get_next, extract_data - ) - list.metadata = {'url': "/subscriptions"} # type: ignore + list.metadata = {"url": "/subscriptions"} # type: ignore - @distributed_trace + @overload def check_zone_peers( self, subscription_id: str, - parameters: "_models.CheckZonePeersRequest", + parameters: _models.CheckZonePeersRequest, + *, + content_type: str = "application/json", **kwargs: Any - ) -> "_models.CheckZonePeersResult": + ) -> _models.CheckZonePeersResult: + """Compares a subscriptions logical zone mapping. + + :param subscription_id: The ID of the target subscription. Required. + :type subscription_id: str + :param parameters: Parameters for checking zone peers. Required. + :type parameters: ~azure.mgmt.resource.subscriptions.v2018_06_01.models.CheckZonePeersRequest + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: CheckZonePeersResult or the result of cls(response) + :rtype: ~azure.mgmt.resource.subscriptions.v2018_06_01.models.CheckZonePeersResult + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + def check_zone_peers( + self, subscription_id: str, parameters: IO, *, content_type: str = "application/json", **kwargs: Any + ) -> _models.CheckZonePeersResult: + """Compares a subscriptions logical zone mapping. + + :param subscription_id: The ID of the target subscription. Required. + :type subscription_id: str + :param parameters: Parameters for checking zone peers. Required. + :type parameters: IO + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: CheckZonePeersResult or the result of cls(response) + :rtype: ~azure.mgmt.resource.subscriptions.v2018_06_01.models.CheckZonePeersResult + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace + def check_zone_peers( + self, subscription_id: str, parameters: Union[_models.CheckZonePeersRequest, IO], **kwargs: Any + ) -> _models.CheckZonePeersResult: """Compares a subscriptions logical zone mapping. - :param subscription_id: The ID of the target subscription. + :param subscription_id: The ID of the target subscription. Required. :type subscription_id: str - :param parameters: Parameters for checking zone peers. + :param parameters: Parameters for checking zone peers. Is either a model type or a IO type. + Required. :type parameters: ~azure.mgmt.resource.subscriptions.v2018_06_01.models.CheckZonePeersRequest + or IO + :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. + Default value is None. + :paramtype content_type: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: CheckZonePeersResult, or the result of cls(response) + :return: CheckZonePeersResult or the result of cls(response) :rtype: ~azure.mgmt.resource.subscriptions.v2018_06_01.models.CheckZonePeersResult - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.CheckZonePeersResult"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) - api_version = kwargs.pop('api_version', "2018-06-01") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - _json = self._serialize.body(parameters, 'CheckZonePeersRequest') + api_version = kwargs.pop("api_version", _params.pop("api-version", "2018-06-01")) # type: str + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.CheckZonePeersResult] + + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(parameters, (IO, bytes)): + _content = parameters + else: + _json = self._serialize.body(parameters, "CheckZonePeersRequest") request = build_subscriptions_check_zone_peers_request( subscription_id=subscription_id, api_version=api_version, content_type=content_type, json=_json, - template_url=self.check_zone_peers.metadata['url'], + content=_content, + template_url=self.check_zone_peers.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200]: @@ -605,74 +615,79 @@ def check_zone_peers( error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - deserialized = self._deserialize('CheckZonePeersResult', pipeline_response) + deserialized = self._deserialize("CheckZonePeersResult", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - check_zone_peers.metadata = {'url': "/subscriptions/{subscriptionId}/providers/Microsoft.Resources/checkZonePeers/"} # type: ignore + check_zone_peers.metadata = {"url": "/subscriptions/{subscriptionId}/providers/Microsoft.Resources/checkZonePeers/"} # type: ignore -class TenantsOperations(object): - """TenantsOperations operations. - You should not instantiate this class directly. Instead, you should create a Client instance that - instantiates it for you and attaches it as an attribute. +class TenantsOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. - :ivar models: Alias to model classes used in this operation group. - :type models: ~azure.mgmt.resource.subscriptions.v2018_06_01.models - :param client: Client for service requests. - :param config: Configuration of service client. - :param serializer: An object model serializer. - :param deserializer: An object model deserializer. + Instead, you should access the following operations through + :class:`~azure.mgmt.resource.subscriptions.v2018_06_01.SubscriptionClient`'s + :attr:`tenants` attribute. """ models = _models - def __init__(self, client, config, serializer, deserializer): - self._client = client - self._serialize = serializer - self._deserialize = deserializer - self._config = config + def __init__(self, *args, **kwargs): + input_args = list(args) + self._client = input_args.pop(0) if input_args else kwargs.pop("client") + self._config = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") @distributed_trace - def list( - self, - **kwargs: Any - ) -> Iterable["_models.TenantListResult"]: + def list(self, **kwargs: Any) -> Iterable["_models.TenantIdDescription"]: """Gets the tenants for your account. :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either TenantListResult or the result of cls(response) + :return: An iterator like instance of either TenantIdDescription or the result of cls(response) :rtype: - ~azure.core.paging.ItemPaged[~azure.mgmt.resource.subscriptions.v2018_06_01.models.TenantListResult] - :raises: ~azure.core.exceptions.HttpResponseError + ~azure.core.paging.ItemPaged[~azure.mgmt.resource.subscriptions.v2018_06_01.models.TenantIdDescription] + :raises ~azure.core.exceptions.HttpResponseError: """ - api_version = kwargs.pop('api_version', "2018-06-01") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2018-06-01")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[_models.TenantListResult] - cls = kwargs.pop('cls', None) # type: ClsType["_models.TenantListResult"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) + def prepare_request(next_link=None): if not next_link: - + request = build_tenants_list_request( api_version=api_version, - template_url=self.list.metadata['url'], + template_url=self.list.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore else: - - request = build_tenants_list_request( - template_url=next_link, - ) + # make call to next link with the client's api-version + _parsed_next_link = urlparse(next_link) + _next_request_params = case_insensitive_dict(parse_qs(_parsed_next_link.query)) + _next_request_params["api-version"] = self._config.api_version + request = HttpRequest("GET", urljoin(next_link, _parsed_next_link.path), params=_next_request_params) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore request.method = "GET" return request @@ -686,10 +701,8 @@ def extract_data(pipeline_response): def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) response = pipeline_response.http_response @@ -699,19 +712,20 @@ def get_next(next_link=None): return pipeline_response + return ItemPaged(get_next, extract_data) - return ItemPaged( - get_next, extract_data - ) - list.metadata = {'url': "/tenants"} # type: ignore -class SubscriptionClientOperationsMixin(object): + list.metadata = {"url": "/tenants"} # type: ignore - @distributed_trace + +class SubscriptionClientOperationsMixin(MixinABC): + @overload def check_resource_name( self, - resource_name_definition: Optional["_models.ResourceName"] = None, + resource_name_definition: Optional[_models.ResourceName] = None, + *, + content_type: str = "application/json", **kwargs: Any - ) -> "_models.CheckResourceNameResult": + ) -> _models.CheckResourceNameResult: """Checks resource name validity. A resource name is valid if it is not a reserved word, does not contains a reserved word and @@ -721,39 +735,99 @@ def check_resource_name( type. Default value is None. :type resource_name_definition: ~azure.mgmt.resource.subscriptions.v2018_06_01.models.ResourceName + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: CheckResourceNameResult or the result of cls(response) + :rtype: ~azure.mgmt.resource.subscriptions.v2018_06_01.models.CheckResourceNameResult + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + def check_resource_name( + self, resource_name_definition: Optional[IO] = None, *, content_type: str = "application/json", **kwargs: Any + ) -> _models.CheckResourceNameResult: + """Checks resource name validity. + + A resource name is valid if it is not a reserved word, does not contains a reserved word and + does not start with a reserved word. + + :param resource_name_definition: Resource object with values for resource name and resource + type. Default value is None. + :type resource_name_definition: IO + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: CheckResourceNameResult, or the result of cls(response) + :return: CheckResourceNameResult or the result of cls(response) :rtype: ~azure.mgmt.resource.subscriptions.v2018_06_01.models.CheckResourceNameResult - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace + def check_resource_name( + self, resource_name_definition: Optional[Union[_models.ResourceName, IO]] = None, **kwargs: Any + ) -> _models.CheckResourceNameResult: + """Checks resource name validity. + + A resource name is valid if it is not a reserved word, does not contains a reserved word and + does not start with a reserved word. + + :param resource_name_definition: Resource object with values for resource name and resource + type. Is either a model type or a IO type. Default value is None. + :type resource_name_definition: + ~azure.mgmt.resource.subscriptions.v2018_06_01.models.ResourceName or IO + :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. + Default value is None. + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: CheckResourceNameResult or the result of cls(response) + :rtype: ~azure.mgmt.resource.subscriptions.v2018_06_01.models.CheckResourceNameResult + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.CheckResourceNameResult"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', "2018-06-01") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + api_version = kwargs.pop("api_version", _params.pop("api-version", "2018-06-01")) # type: str + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.CheckResourceNameResult] - if resource_name_definition is not None: - _json = self._serialize.body(resource_name_definition, 'ResourceName') + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(resource_name_definition, (IO, bytes)): + _content = resource_name_definition else: - _json = None + if resource_name_definition is not None: + _json = self._serialize.body(resource_name_definition, "ResourceName") + else: + _json = None request = build_check_resource_name_request( api_version=api_version, content_type=content_type, json=_json, - template_url=self.check_resource_name.metadata['url'], + content=_content, + template_url=self.check_resource_name.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200]: @@ -761,12 +835,11 @@ def check_resource_name( error = self._deserialize.failsafe_deserialize(_models.ErrorResponseAutoGenerated, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - deserialized = self._deserialize('CheckResourceNameResult', pipeline_response) + deserialized = self._deserialize("CheckResourceNameResult", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - check_resource_name.metadata = {'url': "/providers/Microsoft.Resources/checkResourceName"} # type: ignore - + check_resource_name.metadata = {"url": "/providers/Microsoft.Resources/checkResourceName"} # type: ignore diff --git a/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/subscriptions/v2018_06_01/operations/_patch.py b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/subscriptions/v2018_06_01/operations/_patch.py new file mode 100644 index 0000000000000..f7dd32510333d --- /dev/null +++ b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/subscriptions/v2018_06_01/operations/_patch.py @@ -0,0 +1,20 @@ +# ------------------------------------ +# Copyright (c) Microsoft Corporation. +# Licensed under the MIT License. +# ------------------------------------ +"""Customize generated code here. + +Follow our quickstart for examples: https://aka.ms/azsdk/python/dpcodegen/python/customize +""" +from typing import List + +__all__: List[str] = [] # Add all objects you want publicly available to users at this package level + + +def patch_sdk(): + """Do not remove from this file. + + `patch_sdk` is a last resort escape hatch that allows you to do customizations + you can't accomplish using the techniques described in + https://aka.ms/azsdk/python/dpcodegen/python/customize + """ diff --git a/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/subscriptions/v2019_06_01/__init__.py b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/subscriptions/v2019_06_01/__init__.py index abd8e21f33387..d5d8e357d6a54 100644 --- a/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/subscriptions/v2019_06_01/__init__.py +++ b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/subscriptions/v2019_06_01/__init__.py @@ -10,9 +10,15 @@ from ._version import VERSION __version__ = VERSION -__all__ = ['SubscriptionClient'] -# `._patch.py` is used for handwritten extensions to the generated code -# Example: https://github.com/Azure/azure-sdk-for-python/blob/main/doc/dev/customize_code/how-to-patch-sdk-code.md -from ._patch import patch_sdk -patch_sdk() +try: + from ._patch import __all__ as _patch_all + from ._patch import * # type: ignore # pylint: disable=unused-wildcard-import +except ImportError: + _patch_all = [] +from ._patch import patch_sdk as _patch_sdk + +__all__ = ["SubscriptionClient"] +__all__.extend([p for p in _patch_all if p not in __all__]) + +_patch_sdk() diff --git a/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/subscriptions/v2019_06_01/_configuration.py b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/subscriptions/v2019_06_01/_configuration.py index 0ce20c2358e9b..29ba01884b2d2 100644 --- a/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/subscriptions/v2019_06_01/_configuration.py +++ b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/subscriptions/v2019_06_01/_configuration.py @@ -25,43 +25,40 @@ class SubscriptionClientConfiguration(Configuration): # pylint: disable=too-man Note that all parameters used to create this instance are saved as instance attributes. - :param credential: Credential needed for the client to connect to Azure. + :param credential: Credential needed for the client to connect to Azure. Required. :type credential: ~azure.core.credentials.TokenCredential :keyword api_version: Api Version. Default value is "2019-06-01". Note that overriding this default value may result in unsupported behavior. :paramtype api_version: str """ - def __init__( - self, - credential: "TokenCredential", - **kwargs: Any - ) -> None: + def __init__(self, credential: "TokenCredential", **kwargs: Any) -> None: super(SubscriptionClientConfiguration, self).__init__(**kwargs) - api_version = kwargs.pop('api_version', "2019-06-01") # type: str + api_version = kwargs.pop("api_version", "2019-06-01") # type: str if credential is None: raise ValueError("Parameter 'credential' must not be None.") self.credential = credential self.api_version = api_version - self.credential_scopes = kwargs.pop('credential_scopes', ['https://management.azure.com/.default']) - kwargs.setdefault('sdk_moniker', 'mgmt-resource/{}'.format(VERSION)) + self.credential_scopes = kwargs.pop("credential_scopes", ["https://management.azure.com/.default"]) + kwargs.setdefault("sdk_moniker", "mgmt-resource/{}".format(VERSION)) self._configure(**kwargs) def _configure( - self, - **kwargs # type: Any + self, **kwargs # type: Any ): # type: (...) -> 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) - self.logging_policy = kwargs.get('logging_policy') or policies.NetworkTraceLoggingPolicy(**kwargs) - self.http_logging_policy = kwargs.get('http_logging_policy') or ARMHttpLoggingPolicy(**kwargs) - self.retry_policy = kwargs.get('retry_policy') or policies.RetryPolicy(**kwargs) - self.custom_hook_policy = kwargs.get('custom_hook_policy') or policies.CustomHookPolicy(**kwargs) - self.redirect_policy = kwargs.get('redirect_policy') or policies.RedirectPolicy(**kwargs) - self.authentication_policy = kwargs.get('authentication_policy') + 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) + self.logging_policy = kwargs.get("logging_policy") or policies.NetworkTraceLoggingPolicy(**kwargs) + self.http_logging_policy = kwargs.get("http_logging_policy") or ARMHttpLoggingPolicy(**kwargs) + self.retry_policy = kwargs.get("retry_policy") or policies.RetryPolicy(**kwargs) + self.custom_hook_policy = kwargs.get("custom_hook_policy") or policies.CustomHookPolicy(**kwargs) + self.redirect_policy = kwargs.get("redirect_policy") or policies.RedirectPolicy(**kwargs) + self.authentication_policy = kwargs.get("authentication_policy") if self.credential and not self.authentication_policy: - self.authentication_policy = ARMChallengeAuthenticationPolicy(self.credential, *self.credential_scopes, **kwargs) + self.authentication_policy = ARMChallengeAuthenticationPolicy( + self.credential, *self.credential_scopes, **kwargs + ) diff --git a/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/subscriptions/v2019_06_01/_metadata.json b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/subscriptions/v2019_06_01/_metadata.json index 7e637c44b47b5..fc4a1b3a08662 100644 --- a/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/subscriptions/v2019_06_01/_metadata.json +++ b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/subscriptions/v2019_06_01/_metadata.json @@ -10,14 +10,14 @@ "azure_arm": true, "has_lro_operations": false, "client_side_validation": false, - "sync_imports": "{\"typing\": {\"azurecore\": {\"azure.core.credentials\": [\"TokenCredential\"]}}, \"regular\": {\"azurecore\": {\"azure.profiles\": [\"KnownProfiles\", \"ProfileDefinition\"], \"azure.profiles.multiapiclient\": [\"MultiApiClientMixin\"], \"azure.mgmt.core\": [\"ARMPipelineClient\"]}, \"local\": {\"._configuration\": [\"SubscriptionClientConfiguration\"], \"._operations_mixin\": [\"SubscriptionClientOperationsMixin\"]}, \"thirdparty\": {\"msrest\": [\"Deserializer\", \"Serializer\"]}}, \"conditional\": {\"stdlib\": {\"typing\": [\"Any\", \"Optional\"]}}}", - "async_imports": "{\"typing\": {\"azurecore\": {\"azure.core.credentials_async\": [\"AsyncTokenCredential\"], \"azure.core.credentials\": [\"TokenCredential\"]}}, \"regular\": {\"azurecore\": {\"azure.profiles\": [\"KnownProfiles\", \"ProfileDefinition\"], \"azure.profiles.multiapiclient\": [\"MultiApiClientMixin\"], \"azure.mgmt.core\": [\"AsyncARMPipelineClient\"]}, \"local\": {\"._configuration\": [\"SubscriptionClientConfiguration\"], \"._operations_mixin\": [\"SubscriptionClientOperationsMixin\"]}, \"thirdparty\": {\"msrest\": [\"Deserializer\", \"Serializer\"]}}, \"conditional\": {\"stdlib\": {\"typing\": [\"Any\", \"Optional\"]}}}" + "sync_imports": "{\"conditional\": {\"stdlib\": {\"typing\": [\"Any\", \"Optional\"]}}, \"regular\": {\"azurecore\": {\"azure.mgmt.core\": [\"ARMPipelineClient\"], \"azure.profiles\": [\"KnownProfiles\", \"ProfileDefinition\"], \"azure.profiles.multiapiclient\": [\"MultiApiClientMixin\"]}, \"local\": {\"._configuration\": [\"SubscriptionClientConfiguration\"], \".._serialization\": [\"Deserializer\", \"Serializer\"], \"._operations_mixin\": [\"SubscriptionClientOperationsMixin\"]}}, \"typing\": {\"azurecore\": {\"azure.core.credentials\": [\"TokenCredential\"]}}}", + "async_imports": "{\"conditional\": {\"stdlib\": {\"typing\": [\"Any\", \"Optional\"]}}, \"regular\": {\"azurecore\": {\"azure.mgmt.core\": [\"AsyncARMPipelineClient\"], \"azure.profiles\": [\"KnownProfiles\", \"ProfileDefinition\"], \"azure.profiles.multiapiclient\": [\"MultiApiClientMixin\"]}, \"local\": {\"._configuration\": [\"SubscriptionClientConfiguration\"], \"..._serialization\": [\"Deserializer\", \"Serializer\"], \"._operations_mixin\": [\"SubscriptionClientOperationsMixin\"]}}, \"typing\": {\"azurecore\": {\"azure.core.credentials_async\": [\"AsyncTokenCredential\"]}}}" }, "global_parameters": { "sync": { "credential": { - "signature": "credential, # type: \"TokenCredential\"", - "description": "Credential needed for the client to connect to Azure.", + "signature": "credential: \"TokenCredential\",", + "description": "Credential needed for the client to connect to Azure. Required.", "docstring_type": "~azure.core.credentials.TokenCredential", "required": true } @@ -25,7 +25,7 @@ "async": { "credential": { "signature": "credential: \"AsyncTokenCredential\",", - "description": "Credential needed for the client to connect to Azure.", + "description": "Credential needed for the client to connect to Azure. Required.", "docstring_type": "~azure.core.credentials_async.AsyncTokenCredential", "required": true } @@ -42,7 +42,7 @@ "required": false }, "base_url": { - "signature": "base_url=\"https://management.azure.com\", # type: str", + "signature": "base_url: str = \"https://management.azure.com\",", "description": "Service URL", "docstring_type": "str", "required": false @@ -90,20 +90,21 @@ "tenants": "TenantsOperations" }, "operation_mixins": { - "sync_imports": "{\"conditional\": {\"stdlib\": {\"typing\": [\"Any\", \"Optional\"]}}}", - "async_imports": "{\"conditional\": {\"stdlib\": {\"typing\": [\"Any\", \"Optional\"]}}}", + "sync_imports": "{\"conditional\": {\"stdlib\": {\"typing\": [\"Any\"]}}, \"regular\": {\"local\": {\".\": [[\"models\", \"_models\"]]}, \"stdlib\": {\"typing\": [\"IO\", \"Optional\", \"Union\"]}}}", + "async_imports": "{\"conditional\": {\"stdlib\": {\"typing\": [\"Any\"]}}, \"regular\": {\"local\": {\"..\": [[\"models\", \"_models\"]]}, \"stdlib\": {\"typing\": [\"IO\", \"Optional\", \"Union\"]}}}", "operations": { "check_resource_name" : { "sync": { - "signature": "def check_resource_name(\n self,\n resource_name_definition=None, # type: Optional[\"_models.ResourceName\"]\n **kwargs # type: Any\n):\n # type: (...) -\u003e \"_models.CheckResourceNameResult\"\n", - "doc": "\"\"\"Checks resource name validity.\n\nA resource name is valid if it is not a reserved word, does not contains a reserved word and\ndoes not start with a reserved word.\n\n:param resource_name_definition: Resource object with values for resource name and resource\n type. Default value is None.\n:type resource_name_definition:\n ~azure.mgmt.resource.subscriptions.v2019_06_01.models.ResourceName\n:keyword callable cls: A custom type or function that will be passed the direct response\n:return: CheckResourceNameResult, or the result of cls(response)\n:rtype: ~azure.mgmt.resource.subscriptions.v2019_06_01.models.CheckResourceNameResult\n:raises: ~azure.core.exceptions.HttpResponseError\n\"\"\"" + "signature": "def check_resource_name(\n self,\n resource_name_definition: Optional[Union[_models.ResourceName, IO]] = None,\n **kwargs: Any\n) -\u003e _models.CheckResourceNameResult:\n", + "doc": "\"\"\"Checks resource name validity.\n\nA resource name is valid if it is not a reserved word, does not contains a reserved word and\ndoes not start with a reserved word.\n\n:param resource_name_definition: Resource object with values for resource name and resource\n type. Is either a model type or a IO type. Default value is None.\n:type resource_name_definition:\n ~azure.mgmt.resource.subscriptions.v2019_06_01.models.ResourceName or IO\n:keyword content_type: Body Parameter content-type. Known values are: \u0027application/json\u0027.\n Default value is None.\n:paramtype content_type: str\n:keyword callable cls: A custom type or function that will be passed the direct response\n:return: CheckResourceNameResult or the result of cls(response)\n:rtype: ~azure.mgmt.resource.subscriptions.v2019_06_01.models.CheckResourceNameResult\n:raises ~azure.core.exceptions.HttpResponseError:\n\"\"\"", + "call": "resource_name_definition, **kwargs" }, "async": { "coroutine": true, - "signature": "async def check_resource_name(\n self,\n resource_name_definition: Optional[\"_models.ResourceName\"] = None,\n **kwargs: Any\n) -\u003e \"_models.CheckResourceNameResult\":\n", - "doc": "\"\"\"Checks resource name validity.\n\nA resource name is valid if it is not a reserved word, does not contains a reserved word and\ndoes not start with a reserved word.\n\n:param resource_name_definition: Resource object with values for resource name and resource\n type. Default value is None.\n:type resource_name_definition:\n ~azure.mgmt.resource.subscriptions.v2019_06_01.models.ResourceName\n:keyword callable cls: A custom type or function that will be passed the direct response\n:return: CheckResourceNameResult, or the result of cls(response)\n:rtype: ~azure.mgmt.resource.subscriptions.v2019_06_01.models.CheckResourceNameResult\n:raises: ~azure.core.exceptions.HttpResponseError\n\"\"\"" - }, - "call": "resource_name_definition" + "signature": "async def check_resource_name(\n self,\n resource_name_definition: Optional[Union[_models.ResourceName, IO]] = None,\n **kwargs: Any\n) -\u003e _models.CheckResourceNameResult:\n", + "doc": "\"\"\"Checks resource name validity.\n\nA resource name is valid if it is not a reserved word, does not contains a reserved word and\ndoes not start with a reserved word.\n\n:param resource_name_definition: Resource object with values for resource name and resource\n type. Is either a model type or a IO type. Default value is None.\n:type resource_name_definition:\n ~azure.mgmt.resource.subscriptions.v2019_06_01.models.ResourceName or IO\n:keyword content_type: Body Parameter content-type. Known values are: \u0027application/json\u0027.\n Default value is None.\n:paramtype content_type: str\n:keyword callable cls: A custom type or function that will be passed the direct response\n:return: CheckResourceNameResult or the result of cls(response)\n:rtype: ~azure.mgmt.resource.subscriptions.v2019_06_01.models.CheckResourceNameResult\n:raises ~azure.core.exceptions.HttpResponseError:\n\"\"\"", + "call": "resource_name_definition, **kwargs" + } } } } diff --git a/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/subscriptions/v2019_06_01/_patch.py b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/subscriptions/v2019_06_01/_patch.py index 74e48ecd07cf3..f99e77fef9861 100644 --- a/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/subscriptions/v2019_06_01/_patch.py +++ b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/subscriptions/v2019_06_01/_patch.py @@ -28,4 +28,4 @@ # This file is used for handwritten extensions to the generated code. Example: # https://github.com/Azure/azure-sdk-for-python/blob/main/doc/dev/customize_code/how-to-patch-sdk-code.md def patch_sdk(): - pass \ No newline at end of file + pass diff --git a/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/subscriptions/v2019_06_01/_subscription_client.py b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/subscriptions/v2019_06_01/_subscription_client.py index 6063090dcfd73..cd6c9d78f1d87 100644 --- a/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/subscriptions/v2019_06_01/_subscription_client.py +++ b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/subscriptions/v2019_06_01/_subscription_client.py @@ -9,12 +9,11 @@ from copy import deepcopy from typing import Any, TYPE_CHECKING -from msrest import Deserializer, Serializer - from azure.core.rest import HttpRequest, HttpResponse from azure.mgmt.core import ARMPipelineClient from . import models +from .._serialization import Deserializer, Serializer from ._configuration import SubscriptionClientConfiguration from .operations import Operations, SubscriptionClientOperationsMixin, SubscriptionsOperations, TenantsOperations @@ -22,7 +21,8 @@ # pylint: disable=unused-import,ungrouped-imports from azure.core.credentials import TokenCredential -class SubscriptionClient(SubscriptionClientOperationsMixin): + +class SubscriptionClient(SubscriptionClientOperationsMixin): # pylint: disable=client-accepts-api-version-keyword """All resource groups and resources exist within subscriptions. These operation enable you get information about your subscriptions and tenants. A tenant is a dedicated instance of Azure Active Directory (Azure AD) for your organization. @@ -34,7 +34,7 @@ class SubscriptionClient(SubscriptionClientOperationsMixin): azure.mgmt.resource.subscriptions.v2019_06_01.operations.SubscriptionsOperations :ivar tenants: TenantsOperations operations :vartype tenants: azure.mgmt.resource.subscriptions.v2019_06_01.operations.TenantsOperations - :param credential: Credential needed for the client to connect to Azure. + :param credential: Credential needed for the client to connect to Azure. Required. :type credential: ~azure.core.credentials.TokenCredential :param base_url: Service URL. Default value is "https://management.azure.com". :type base_url: str @@ -44,10 +44,7 @@ class SubscriptionClient(SubscriptionClientOperationsMixin): """ def __init__( - self, - credential: "TokenCredential", - base_url: str = "https://management.azure.com", - **kwargs: Any + self, credential: "TokenCredential", base_url: str = "https://management.azure.com", **kwargs: Any ) -> None: self._config = SubscriptionClientConfiguration(credential=credential, **kwargs) self._client = ARMPipelineClient(base_url=base_url, config=self._config, **kwargs) @@ -60,12 +57,7 @@ def __init__( self.subscriptions = SubscriptionsOperations(self._client, self._config, self._serialize, self._deserialize) self.tenants = TenantsOperations(self._client, self._config, self._serialize, self._deserialize) - - def _send_request( - self, - request: HttpRequest, - **kwargs: Any - ) -> HttpResponse: + def _send_request(self, request: HttpRequest, **kwargs: Any) -> HttpResponse: """Runs the network request through the client's chained policies. >>> from azure.core.rest import HttpRequest @@ -74,7 +66,7 @@ def _send_request( >>> response = client._send_request(request) - For more information on this code flow, see https://aka.ms/azsdk/python/protocol/quickstart + For more information on this code flow, see https://aka.ms/azsdk/dpcodegen/python/send_request :param request: The network request you want to make. Required. :type request: ~azure.core.rest.HttpRequest diff --git a/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/subscriptions/v2019_06_01/_vendor.py b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/subscriptions/v2019_06_01/_vendor.py index 138f663c53a4e..71418db2686e7 100644 --- a/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/subscriptions/v2019_06_01/_vendor.py +++ b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/subscriptions/v2019_06_01/_vendor.py @@ -5,8 +5,20 @@ # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- +from abc import ABC +from typing import TYPE_CHECKING + from azure.core.pipeline.transport import HttpRequest +from ._configuration import SubscriptionClientConfiguration + +if TYPE_CHECKING: + # pylint: disable=unused-import,ungrouped-imports + from azure.core import PipelineClient + + from .._serialization import Deserializer, Serializer + + def _convert_request(request, files=None): data = request.content if not files else None request = HttpRequest(method=request.method, url=request.url, headers=request.headers, data=data) @@ -14,6 +26,7 @@ def _convert_request(request, files=None): request.set_formdata_body(files) return request + def _format_url_section(template, **kwargs): components = template.split("/") while components: @@ -21,7 +34,14 @@ def _format_url_section(template, **kwargs): 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 - ] + components = [c for c in formatted_components if "{}".format(key.args[0]) not in c] template = "/".join(components) + + +class MixinABC(ABC): + """DO NOT use this class. It is for internal typing use only.""" + + _client: "PipelineClient" + _config: SubscriptionClientConfiguration + _serialize: "Serializer" + _deserialize: "Deserializer" diff --git a/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/subscriptions/v2019_06_01/_version.py b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/subscriptions/v2019_06_01/_version.py index a012ac01c480c..e5754a47ce68f 100644 --- a/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/subscriptions/v2019_06_01/_version.py +++ b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/subscriptions/v2019_06_01/_version.py @@ -6,4 +6,4 @@ # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -VERSION = "21.1.0" +VERSION = "1.0.0b1" diff --git a/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/subscriptions/v2019_06_01/aio/__init__.py b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/subscriptions/v2019_06_01/aio/__init__.py index e95939087d442..5cfdafc74d6db 100644 --- a/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/subscriptions/v2019_06_01/aio/__init__.py +++ b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/subscriptions/v2019_06_01/aio/__init__.py @@ -7,9 +7,15 @@ # -------------------------------------------------------------------------- from ._subscription_client import SubscriptionClient -__all__ = ['SubscriptionClient'] -# `._patch.py` is used for handwritten extensions to the generated code -# Example: https://github.com/Azure/azure-sdk-for-python/blob/main/doc/dev/customize_code/how-to-patch-sdk-code.md -from ._patch import patch_sdk -patch_sdk() +try: + from ._patch import __all__ as _patch_all + from ._patch import * # type: ignore # pylint: disable=unused-wildcard-import +except ImportError: + _patch_all = [] +from ._patch import patch_sdk as _patch_sdk + +__all__ = ["SubscriptionClient"] +__all__.extend([p for p in _patch_all if p not in __all__]) + +_patch_sdk() diff --git a/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/subscriptions/v2019_06_01/aio/_configuration.py b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/subscriptions/v2019_06_01/aio/_configuration.py index f492c4719a5eb..59a332610fae5 100644 --- a/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/subscriptions/v2019_06_01/aio/_configuration.py +++ b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/subscriptions/v2019_06_01/aio/_configuration.py @@ -25,42 +25,37 @@ class SubscriptionClientConfiguration(Configuration): # pylint: disable=too-man Note that all parameters used to create this instance are saved as instance attributes. - :param credential: Credential needed for the client to connect to Azure. + :param credential: Credential needed for the client to connect to Azure. Required. :type credential: ~azure.core.credentials_async.AsyncTokenCredential :keyword api_version: Api Version. Default value is "2019-06-01". Note that overriding this default value may result in unsupported behavior. :paramtype api_version: str """ - def __init__( - self, - credential: "AsyncTokenCredential", - **kwargs: Any - ) -> None: + def __init__(self, credential: "AsyncTokenCredential", **kwargs: Any) -> None: super(SubscriptionClientConfiguration, self).__init__(**kwargs) - api_version = kwargs.pop('api_version', "2019-06-01") # type: str + api_version = kwargs.pop("api_version", "2019-06-01") # type: str if credential is None: raise ValueError("Parameter 'credential' must not be None.") self.credential = credential self.api_version = api_version - self.credential_scopes = kwargs.pop('credential_scopes', ['https://management.azure.com/.default']) - kwargs.setdefault('sdk_moniker', 'mgmt-resource/{}'.format(VERSION)) + self.credential_scopes = kwargs.pop("credential_scopes", ["https://management.azure.com/.default"]) + kwargs.setdefault("sdk_moniker", "mgmt-resource/{}".format(VERSION)) self._configure(**kwargs) - 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) - self.logging_policy = kwargs.get('logging_policy') or policies.NetworkTraceLoggingPolicy(**kwargs) - self.http_logging_policy = kwargs.get('http_logging_policy') or ARMHttpLoggingPolicy(**kwargs) - self.retry_policy = kwargs.get('retry_policy') or policies.AsyncRetryPolicy(**kwargs) - self.custom_hook_policy = kwargs.get('custom_hook_policy') or policies.CustomHookPolicy(**kwargs) - self.redirect_policy = kwargs.get('redirect_policy') or policies.AsyncRedirectPolicy(**kwargs) - self.authentication_policy = kwargs.get('authentication_policy') + 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) + self.logging_policy = kwargs.get("logging_policy") or policies.NetworkTraceLoggingPolicy(**kwargs) + self.http_logging_policy = kwargs.get("http_logging_policy") or ARMHttpLoggingPolicy(**kwargs) + self.retry_policy = kwargs.get("retry_policy") or policies.AsyncRetryPolicy(**kwargs) + self.custom_hook_policy = kwargs.get("custom_hook_policy") or policies.CustomHookPolicy(**kwargs) + self.redirect_policy = kwargs.get("redirect_policy") or policies.AsyncRedirectPolicy(**kwargs) + self.authentication_policy = kwargs.get("authentication_policy") if self.credential and not self.authentication_policy: - self.authentication_policy = AsyncARMChallengeAuthenticationPolicy(self.credential, *self.credential_scopes, **kwargs) + self.authentication_policy = AsyncARMChallengeAuthenticationPolicy( + self.credential, *self.credential_scopes, **kwargs + ) diff --git a/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/subscriptions/v2019_06_01/aio/_patch.py b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/subscriptions/v2019_06_01/aio/_patch.py index 74e48ecd07cf3..f99e77fef9861 100644 --- a/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/subscriptions/v2019_06_01/aio/_patch.py +++ b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/subscriptions/v2019_06_01/aio/_patch.py @@ -28,4 +28,4 @@ # This file is used for handwritten extensions to the generated code. Example: # https://github.com/Azure/azure-sdk-for-python/blob/main/doc/dev/customize_code/how-to-patch-sdk-code.md def patch_sdk(): - pass \ No newline at end of file + pass diff --git a/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/subscriptions/v2019_06_01/aio/_subscription_client.py b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/subscriptions/v2019_06_01/aio/_subscription_client.py index aa6bc19a8b752..4c78047228820 100644 --- a/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/subscriptions/v2019_06_01/aio/_subscription_client.py +++ b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/subscriptions/v2019_06_01/aio/_subscription_client.py @@ -9,12 +9,11 @@ from copy import deepcopy from typing import Any, Awaitable, TYPE_CHECKING -from msrest import Deserializer, Serializer - from azure.core.rest import AsyncHttpResponse, HttpRequest from azure.mgmt.core import AsyncARMPipelineClient from .. import models +from ..._serialization import Deserializer, Serializer from ._configuration import SubscriptionClientConfiguration from .operations import Operations, SubscriptionClientOperationsMixin, SubscriptionsOperations, TenantsOperations @@ -22,7 +21,8 @@ # pylint: disable=unused-import,ungrouped-imports from azure.core.credentials_async import AsyncTokenCredential -class SubscriptionClient(SubscriptionClientOperationsMixin): + +class SubscriptionClient(SubscriptionClientOperationsMixin): # pylint: disable=client-accepts-api-version-keyword """All resource groups and resources exist within subscriptions. These operation enable you get information about your subscriptions and tenants. A tenant is a dedicated instance of Azure Active Directory (Azure AD) for your organization. @@ -35,7 +35,7 @@ class SubscriptionClient(SubscriptionClientOperationsMixin): :ivar tenants: TenantsOperations operations :vartype tenants: azure.mgmt.resource.subscriptions.v2019_06_01.aio.operations.TenantsOperations - :param credential: Credential needed for the client to connect to Azure. + :param credential: Credential needed for the client to connect to Azure. Required. :type credential: ~azure.core.credentials_async.AsyncTokenCredential :param base_url: Service URL. Default value is "https://management.azure.com". :type base_url: str @@ -45,10 +45,7 @@ class SubscriptionClient(SubscriptionClientOperationsMixin): """ def __init__( - self, - credential: "AsyncTokenCredential", - base_url: str = "https://management.azure.com", - **kwargs: Any + self, credential: "AsyncTokenCredential", base_url: str = "https://management.azure.com", **kwargs: Any ) -> None: self._config = SubscriptionClientConfiguration(credential=credential, **kwargs) self._client = AsyncARMPipelineClient(base_url=base_url, config=self._config, **kwargs) @@ -61,12 +58,7 @@ def __init__( self.subscriptions = SubscriptionsOperations(self._client, self._config, self._serialize, self._deserialize) self.tenants = TenantsOperations(self._client, self._config, self._serialize, self._deserialize) - - def _send_request( - self, - request: HttpRequest, - **kwargs: Any - ) -> Awaitable[AsyncHttpResponse]: + def _send_request(self, request: HttpRequest, **kwargs: Any) -> Awaitable[AsyncHttpResponse]: """Runs the network request through the client's chained policies. >>> from azure.core.rest import HttpRequest @@ -75,7 +67,7 @@ def _send_request( >>> response = await client._send_request(request) - For more information on this code flow, see https://aka.ms/azsdk/python/protocol/quickstart + For more information on this code flow, see https://aka.ms/azsdk/dpcodegen/python/send_request :param request: The network request you want to make. Required. :type request: ~azure.core.rest.HttpRequest diff --git a/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/subscriptions/v2019_06_01/aio/_vendor.py b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/subscriptions/v2019_06_01/aio/_vendor.py new file mode 100644 index 0000000000000..3c42eb44b5a3e --- /dev/null +++ b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/subscriptions/v2019_06_01/aio/_vendor.py @@ -0,0 +1,28 @@ +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- + +from abc import ABC +from typing import TYPE_CHECKING + +from azure.core.pipeline.transport import HttpRequest + +from ._configuration import SubscriptionClientConfiguration + +if TYPE_CHECKING: + # pylint: disable=unused-import,ungrouped-imports + from azure.core import AsyncPipelineClient + + from ..._serialization import Deserializer, Serializer + + +class MixinABC(ABC): + """DO NOT use this class. It is for internal typing use only.""" + + _client: "AsyncPipelineClient" + _config: SubscriptionClientConfiguration + _serialize: "Serializer" + _deserialize: "Deserializer" diff --git a/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/subscriptions/v2019_06_01/aio/operations/__init__.py b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/subscriptions/v2019_06_01/aio/operations/__init__.py index 437b49e23548f..1066cb67ea911 100644 --- a/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/subscriptions/v2019_06_01/aio/operations/__init__.py +++ b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/subscriptions/v2019_06_01/aio/operations/__init__.py @@ -11,9 +11,15 @@ from ._operations import TenantsOperations from ._operations import SubscriptionClientOperationsMixin +from ._patch import __all__ as _patch_all +from ._patch import * # type: ignore # pylint: disable=unused-wildcard-import +from ._patch import patch_sdk as _patch_sdk + __all__ = [ - 'Operations', - 'SubscriptionsOperations', - 'TenantsOperations', - 'SubscriptionClientOperationsMixin', + "Operations", + "SubscriptionsOperations", + "TenantsOperations", + "SubscriptionClientOperationsMixin", ] +__all__.extend([p for p in _patch_all if p not in __all__]) +_patch_sdk() diff --git a/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/subscriptions/v2019_06_01/aio/operations/_operations.py b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/subscriptions/v2019_06_01/aio/operations/_operations.py index 0ebdcb9baed26..ea861ec13e9e7 100644 --- a/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/subscriptions/v2019_06_01/aio/operations/_operations.py +++ b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/subscriptions/v2019_06_01/aio/operations/_operations.py @@ -6,82 +6,106 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -from typing import Any, AsyncIterable, Callable, Dict, Optional, TypeVar +from typing import Any, AsyncIterable, Callable, Dict, IO, Optional, TypeVar, Union, overload +from urllib.parse import parse_qs, urljoin, urlparse from azure.core.async_paging import AsyncItemPaged, AsyncList -from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error +from azure.core.exceptions import ( + ClientAuthenticationError, + HttpResponseError, + ResourceExistsError, + ResourceNotFoundError, + ResourceNotModifiedError, + map_error, +) from azure.core.pipeline import PipelineResponse from azure.core.pipeline.transport import AsyncHttpResponse from azure.core.rest import HttpRequest from azure.core.tracing.decorator import distributed_trace from azure.core.tracing.decorator_async import distributed_trace_async +from azure.core.utils import case_insensitive_dict from azure.mgmt.core.exceptions import ARMErrorFormat from ... import models as _models from ..._vendor import _convert_request -from ...operations._operations import build_check_resource_name_request, build_operations_list_request, build_subscriptions_check_zone_peers_request, build_subscriptions_get_request, build_subscriptions_list_locations_request, build_subscriptions_list_request, build_tenants_list_request -T = TypeVar('T') +from ...operations._operations import ( + build_check_resource_name_request, + build_operations_list_request, + build_subscriptions_check_zone_peers_request, + build_subscriptions_get_request, + build_subscriptions_list_locations_request, + build_subscriptions_list_request, + build_tenants_list_request, +) +from .._vendor import MixinABC + +T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] -class Operations: - """Operations async operations. - You should not instantiate this class directly. Instead, you should create a Client instance that - instantiates it for you and attaches it as an attribute. +class Operations: + """ + .. warning:: + **DO NOT** instantiate this class directly. - :ivar models: Alias to model classes used in this operation group. - :type models: ~azure.mgmt.resource.subscriptions.v2019_06_01.models - :param client: Client for service requests. - :param config: Configuration of service client. - :param serializer: An object model serializer. - :param deserializer: An object model deserializer. + Instead, you should access the following operations through + :class:`~azure.mgmt.resource.subscriptions.v2019_06_01.aio.SubscriptionClient`'s + :attr:`operations` attribute. """ models = _models - def __init__(self, client, config, serializer, deserializer) -> None: - self._client = client - self._serialize = serializer - self._deserialize = deserializer - self._config = config + def __init__(self, *args, **kwargs) -> None: + input_args = list(args) + self._client = input_args.pop(0) if input_args else kwargs.pop("client") + self._config = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") @distributed_trace - def list( - self, - **kwargs: Any - ) -> AsyncIterable["_models.OperationListResult"]: + def list(self, **kwargs: Any) -> AsyncIterable["_models.Operation"]: """Lists all of the available Microsoft.Resources REST API operations. :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either OperationListResult or the result of cls(response) + :return: An iterator like instance of either Operation or the result of cls(response) :rtype: - ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.resource.subscriptions.v2019_06_01.models.OperationListResult] - :raises: ~azure.core.exceptions.HttpResponseError + ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.resource.subscriptions.v2019_06_01.models.Operation] + :raises ~azure.core.exceptions.HttpResponseError: """ - api_version = kwargs.pop('api_version', "2019-06-01") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2019-06-01")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[_models.OperationListResult] - cls = kwargs.pop('cls', None) # type: ClsType["_models.OperationListResult"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) + def prepare_request(next_link=None): if not next_link: - + request = build_operations_list_request( api_version=api_version, - template_url=self.list.metadata['url'], + template_url=self.list.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore else: - - request = build_operations_list_request( - template_url=next_link, - ) + # make call to next link with the client's api-version + _parsed_next_link = urlparse(next_link) + _next_request_params = case_insensitive_dict(parse_qs(_parsed_next_link.query)) + _next_request_params["api-version"] = self._config.api_version + request = HttpRequest("GET", urljoin(next_link, _parsed_next_link.path), params=_next_request_params) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore request.method = "GET" return request @@ -95,10 +119,8 @@ async def extract_data(pipeline_response): async def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) response = pipeline_response.http_response @@ -108,78 +130,80 @@ async def get_next(next_link=None): return pipeline_response + return AsyncItemPaged(get_next, extract_data) + + list.metadata = {"url": "/providers/Microsoft.Resources/operations"} # type: ignore - return AsyncItemPaged( - get_next, extract_data - ) - list.metadata = {'url': "/providers/Microsoft.Resources/operations"} # type: ignore -class SubscriptionsOperations: - """SubscriptionsOperations async operations. - You should not instantiate this class directly. Instead, you should create a Client instance that - instantiates it for you and attaches it as an attribute. +class SubscriptionsOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. - :ivar models: Alias to model classes used in this operation group. - :type models: ~azure.mgmt.resource.subscriptions.v2019_06_01.models - :param client: Client for service requests. - :param config: Configuration of service client. - :param serializer: An object model serializer. - :param deserializer: An object model deserializer. + Instead, you should access the following operations through + :class:`~azure.mgmt.resource.subscriptions.v2019_06_01.aio.SubscriptionClient`'s + :attr:`subscriptions` attribute. """ models = _models - def __init__(self, client, config, serializer, deserializer) -> None: - self._client = client - self._serialize = serializer - self._deserialize = deserializer - self._config = config + def __init__(self, *args, **kwargs) -> None: + input_args = list(args) + self._client = input_args.pop(0) if input_args else kwargs.pop("client") + self._config = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") @distributed_trace - def list_locations( - self, - subscription_id: str, - **kwargs: Any - ) -> AsyncIterable["_models.LocationListResult"]: + def list_locations(self, subscription_id: str, **kwargs: Any) -> AsyncIterable["_models.Location"]: """Gets all available geo-locations. This operation provides all the locations that are available for resource providers; however, each resource provider may support a subset of this list. - :param subscription_id: The ID of the target subscription. + :param subscription_id: The ID of the target subscription. Required. :type subscription_id: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either LocationListResult or the result of cls(response) + :return: An iterator like instance of either Location or the result of cls(response) :rtype: - ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.resource.subscriptions.v2019_06_01.models.LocationListResult] - :raises: ~azure.core.exceptions.HttpResponseError + ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.resource.subscriptions.v2019_06_01.models.Location] + :raises ~azure.core.exceptions.HttpResponseError: """ - api_version = kwargs.pop('api_version', "2019-06-01") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2019-06-01")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[_models.LocationListResult] - cls = kwargs.pop('cls', None) # type: ClsType["_models.LocationListResult"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) + def prepare_request(next_link=None): if not next_link: - + request = build_subscriptions_list_locations_request( subscription_id=subscription_id, api_version=api_version, - template_url=self.list_locations.metadata['url'], + template_url=self.list_locations.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore else: - - request = build_subscriptions_list_locations_request( - subscription_id=subscription_id, - template_url=next_link, - ) + # make call to next link with the client's api-version + _parsed_next_link = urlparse(next_link) + _next_request_params = case_insensitive_dict(parse_qs(_parsed_next_link.query)) + _next_request_params["api-version"] = self._config.api_version + request = HttpRequest("GET", urljoin(next_link, _parsed_next_link.path), params=_next_request_params) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore request.method = "GET" return request @@ -193,10 +217,8 @@ async def extract_data(pipeline_response): async def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) response = pipeline_response.http_response @@ -206,103 +228,108 @@ async def get_next(next_link=None): return pipeline_response + return AsyncItemPaged(get_next, extract_data) - return AsyncItemPaged( - get_next, extract_data - ) - list_locations.metadata = {'url': "/subscriptions/{subscriptionId}/locations"} # type: ignore + list_locations.metadata = {"url": "/subscriptions/{subscriptionId}/locations"} # type: ignore @distributed_trace_async - async def get( - self, - subscription_id: str, - **kwargs: Any - ) -> "_models.Subscription": + async def get(self, subscription_id: str, **kwargs: Any) -> _models.Subscription: """Gets details about a specified subscription. - :param subscription_id: The ID of the target subscription. + :param subscription_id: The ID of the target subscription. Required. :type subscription_id: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: Subscription, or the result of cls(response) + :return: Subscription or the result of cls(response) :rtype: ~azure.mgmt.resource.subscriptions.v2019_06_01.models.Subscription - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.Subscription"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) - api_version = kwargs.pop('api_version', "2019-06-01") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2019-06-01")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[_models.Subscription] - request = build_subscriptions_get_request( subscription_id=subscription_id, api_version=api_version, - template_url=self.get.metadata['url'], + template_url=self.get.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) - deserialized = self._deserialize('Subscription', pipeline_response) + deserialized = self._deserialize("Subscription", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - get.metadata = {'url': "/subscriptions/{subscriptionId}"} # type: ignore - + get.metadata = {"url": "/subscriptions/{subscriptionId}"} # type: ignore @distributed_trace - def list( - self, - **kwargs: Any - ) -> AsyncIterable["_models.SubscriptionListResult"]: + def list(self, **kwargs: Any) -> AsyncIterable["_models.Subscription"]: """Gets all subscriptions for a tenant. :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either SubscriptionListResult or the result of - cls(response) + :return: An iterator like instance of either Subscription or the result of cls(response) :rtype: - ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.resource.subscriptions.v2019_06_01.models.SubscriptionListResult] - :raises: ~azure.core.exceptions.HttpResponseError + ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.resource.subscriptions.v2019_06_01.models.Subscription] + :raises ~azure.core.exceptions.HttpResponseError: """ - api_version = kwargs.pop('api_version', "2019-06-01") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2019-06-01")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[_models.SubscriptionListResult] - cls = kwargs.pop('cls', None) # type: ClsType["_models.SubscriptionListResult"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) + def prepare_request(next_link=None): if not next_link: - + request = build_subscriptions_list_request( api_version=api_version, - template_url=self.list.metadata['url'], + template_url=self.list.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore else: - - request = build_subscriptions_list_request( - template_url=next_link, - ) + # make call to next link with the client's api-version + _parsed_next_link = urlparse(next_link) + _next_request_params = case_insensitive_dict(parse_qs(_parsed_next_link.query)) + _next_request_params["api-version"] = self._config.api_version + request = HttpRequest("GET", urljoin(next_link, _parsed_next_link.path), params=_next_request_params) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore request.method = "GET" return request @@ -316,10 +343,8 @@ async def extract_data(pipeline_response): async def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) response = pipeline_response.http_response @@ -329,56 +354,113 @@ async def get_next(next_link=None): return pipeline_response + return AsyncItemPaged(get_next, extract_data) - return AsyncItemPaged( - get_next, extract_data - ) - list.metadata = {'url': "/subscriptions"} # type: ignore + list.metadata = {"url": "/subscriptions"} # type: ignore - @distributed_trace_async + @overload async def check_zone_peers( self, subscription_id: str, - parameters: "_models.CheckZonePeersRequest", + parameters: _models.CheckZonePeersRequest, + *, + content_type: str = "application/json", **kwargs: Any - ) -> "_models.CheckZonePeersResult": + ) -> _models.CheckZonePeersResult: """Compares a subscriptions logical zone mapping. - :param subscription_id: The ID of the target subscription. + :param subscription_id: The ID of the target subscription. Required. :type subscription_id: str - :param parameters: Parameters for checking zone peers. + :param parameters: Parameters for checking zone peers. Required. :type parameters: ~azure.mgmt.resource.subscriptions.v2019_06_01.models.CheckZonePeersRequest + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: CheckZonePeersResult, or the result of cls(response) + :return: CheckZonePeersResult or the result of cls(response) :rtype: ~azure.mgmt.resource.subscriptions.v2019_06_01.models.CheckZonePeersResult - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + async def check_zone_peers( + self, subscription_id: str, parameters: IO, *, content_type: str = "application/json", **kwargs: Any + ) -> _models.CheckZonePeersResult: + """Compares a subscriptions logical zone mapping. + + :param subscription_id: The ID of the target subscription. Required. + :type subscription_id: str + :param parameters: Parameters for checking zone peers. Required. + :type parameters: IO + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: CheckZonePeersResult or the result of cls(response) + :rtype: ~azure.mgmt.resource.subscriptions.v2019_06_01.models.CheckZonePeersResult + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace_async + async def check_zone_peers( + self, subscription_id: str, parameters: Union[_models.CheckZonePeersRequest, IO], **kwargs: Any + ) -> _models.CheckZonePeersResult: + """Compares a subscriptions logical zone mapping. + + :param subscription_id: The ID of the target subscription. Required. + :type subscription_id: str + :param parameters: Parameters for checking zone peers. Is either a model type or a IO type. + Required. + :type parameters: ~azure.mgmt.resource.subscriptions.v2019_06_01.models.CheckZonePeersRequest + or IO + :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. + Default value is None. + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: CheckZonePeersResult or the result of cls(response) + :rtype: ~azure.mgmt.resource.subscriptions.v2019_06_01.models.CheckZonePeersResult + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.CheckZonePeersResult"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) - api_version = kwargs.pop('api_version', "2019-06-01") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - _json = self._serialize.body(parameters, 'CheckZonePeersRequest') + api_version = kwargs.pop("api_version", _params.pop("api-version", "2019-06-01")) # type: str + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.CheckZonePeersResult] + + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(parameters, (IO, bytes)): + _content = parameters + else: + _json = self._serialize.body(parameters, "CheckZonePeersRequest") request = build_subscriptions_check_zone_peers_request( subscription_id=subscription_id, api_version=api_version, content_type=content_type, json=_json, - template_url=self.check_zone_peers.metadata['url'], + content=_content, + template_url=self.check_zone_peers.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200]: @@ -386,74 +468,79 @@ async def check_zone_peers( error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - deserialized = self._deserialize('CheckZonePeersResult', pipeline_response) + deserialized = self._deserialize("CheckZonePeersResult", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - check_zone_peers.metadata = {'url': "/subscriptions/{subscriptionId}/providers/Microsoft.Resources/checkZonePeers/"} # type: ignore + check_zone_peers.metadata = {"url": "/subscriptions/{subscriptionId}/providers/Microsoft.Resources/checkZonePeers/"} # type: ignore -class TenantsOperations: - """TenantsOperations async operations. - You should not instantiate this class directly. Instead, you should create a Client instance that - instantiates it for you and attaches it as an attribute. +class TenantsOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. - :ivar models: Alias to model classes used in this operation group. - :type models: ~azure.mgmt.resource.subscriptions.v2019_06_01.models - :param client: Client for service requests. - :param config: Configuration of service client. - :param serializer: An object model serializer. - :param deserializer: An object model deserializer. + Instead, you should access the following operations through + :class:`~azure.mgmt.resource.subscriptions.v2019_06_01.aio.SubscriptionClient`'s + :attr:`tenants` attribute. """ models = _models - def __init__(self, client, config, serializer, deserializer) -> None: - self._client = client - self._serialize = serializer - self._deserialize = deserializer - self._config = config + def __init__(self, *args, **kwargs) -> None: + input_args = list(args) + self._client = input_args.pop(0) if input_args else kwargs.pop("client") + self._config = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") @distributed_trace - def list( - self, - **kwargs: Any - ) -> AsyncIterable["_models.TenantListResult"]: + def list(self, **kwargs: Any) -> AsyncIterable["_models.TenantIdDescription"]: """Gets the tenants for your account. :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either TenantListResult or the result of cls(response) + :return: An iterator like instance of either TenantIdDescription or the result of cls(response) :rtype: - ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.resource.subscriptions.v2019_06_01.models.TenantListResult] - :raises: ~azure.core.exceptions.HttpResponseError + ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.resource.subscriptions.v2019_06_01.models.TenantIdDescription] + :raises ~azure.core.exceptions.HttpResponseError: """ - api_version = kwargs.pop('api_version', "2019-06-01") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2019-06-01")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[_models.TenantListResult] - cls = kwargs.pop('cls', None) # type: ClsType["_models.TenantListResult"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) + def prepare_request(next_link=None): if not next_link: - + request = build_tenants_list_request( api_version=api_version, - template_url=self.list.metadata['url'], + template_url=self.list.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore else: - - request = build_tenants_list_request( - template_url=next_link, - ) + # make call to next link with the client's api-version + _parsed_next_link = urlparse(next_link) + _next_request_params = case_insensitive_dict(parse_qs(_parsed_next_link.query)) + _next_request_params["api-version"] = self._config.api_version + request = HttpRequest("GET", urljoin(next_link, _parsed_next_link.path), params=_next_request_params) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore request.method = "GET" return request @@ -467,10 +554,8 @@ async def extract_data(pipeline_response): async def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) response = pipeline_response.http_response @@ -480,19 +565,20 @@ async def get_next(next_link=None): return pipeline_response + return AsyncItemPaged(get_next, extract_data) - return AsyncItemPaged( - get_next, extract_data - ) - list.metadata = {'url': "/tenants"} # type: ignore -class SubscriptionClientOperationsMixin: + list.metadata = {"url": "/tenants"} # type: ignore - @distributed_trace_async + +class SubscriptionClientOperationsMixin(MixinABC): + @overload async def check_resource_name( self, - resource_name_definition: Optional["_models.ResourceName"] = None, + resource_name_definition: Optional[_models.ResourceName] = None, + *, + content_type: str = "application/json", **kwargs: Any - ) -> "_models.CheckResourceNameResult": + ) -> _models.CheckResourceNameResult: """Checks resource name validity. A resource name is valid if it is not a reserved word, does not contains a reserved word and @@ -502,39 +588,99 @@ async def check_resource_name( type. Default value is None. :type resource_name_definition: ~azure.mgmt.resource.subscriptions.v2019_06_01.models.ResourceName + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: CheckResourceNameResult, or the result of cls(response) + :return: CheckResourceNameResult or the result of cls(response) :rtype: ~azure.mgmt.resource.subscriptions.v2019_06_01.models.CheckResourceNameResult - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + async def check_resource_name( + self, resource_name_definition: Optional[IO] = None, *, content_type: str = "application/json", **kwargs: Any + ) -> _models.CheckResourceNameResult: + """Checks resource name validity. + + A resource name is valid if it is not a reserved word, does not contains a reserved word and + does not start with a reserved word. + + :param resource_name_definition: Resource object with values for resource name and resource + type. Default value is None. + :type resource_name_definition: IO + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: CheckResourceNameResult or the result of cls(response) + :rtype: ~azure.mgmt.resource.subscriptions.v2019_06_01.models.CheckResourceNameResult + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace_async + async def check_resource_name( + self, resource_name_definition: Optional[Union[_models.ResourceName, IO]] = None, **kwargs: Any + ) -> _models.CheckResourceNameResult: + """Checks resource name validity. + + A resource name is valid if it is not a reserved word, does not contains a reserved word and + does not start with a reserved word. + + :param resource_name_definition: Resource object with values for resource name and resource + type. Is either a model type or a IO type. Default value is None. + :type resource_name_definition: + ~azure.mgmt.resource.subscriptions.v2019_06_01.models.ResourceName or IO + :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. + Default value is None. + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: CheckResourceNameResult or the result of cls(response) + :rtype: ~azure.mgmt.resource.subscriptions.v2019_06_01.models.CheckResourceNameResult + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.CheckResourceNameResult"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', "2019-06-01") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + api_version = kwargs.pop("api_version", _params.pop("api-version", "2019-06-01")) # type: str + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.CheckResourceNameResult] - if resource_name_definition is not None: - _json = self._serialize.body(resource_name_definition, 'ResourceName') + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(resource_name_definition, (IO, bytes)): + _content = resource_name_definition else: - _json = None + if resource_name_definition is not None: + _json = self._serialize.body(resource_name_definition, "ResourceName") + else: + _json = None request = build_check_resource_name_request( api_version=api_version, content_type=content_type, json=_json, - template_url=self.check_resource_name.metadata['url'], + content=_content, + template_url=self.check_resource_name.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200]: @@ -542,12 +688,11 @@ async def check_resource_name( error = self._deserialize.failsafe_deserialize(_models.ErrorResponseAutoGenerated, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - deserialized = self._deserialize('CheckResourceNameResult', pipeline_response) + deserialized = self._deserialize("CheckResourceNameResult", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - check_resource_name.metadata = {'url': "/providers/Microsoft.Resources/checkResourceName"} # type: ignore - + check_resource_name.metadata = {"url": "/providers/Microsoft.Resources/checkResourceName"} # type: ignore diff --git a/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/subscriptions/v2019_06_01/aio/operations/_patch.py b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/subscriptions/v2019_06_01/aio/operations/_patch.py new file mode 100644 index 0000000000000..f7dd32510333d --- /dev/null +++ b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/subscriptions/v2019_06_01/aio/operations/_patch.py @@ -0,0 +1,20 @@ +# ------------------------------------ +# Copyright (c) Microsoft Corporation. +# Licensed under the MIT License. +# ------------------------------------ +"""Customize generated code here. + +Follow our quickstart for examples: https://aka.ms/azsdk/python/dpcodegen/python/customize +""" +from typing import List + +__all__: List[str] = [] # Add all objects you want publicly available to users at this package level + + +def patch_sdk(): + """Do not remove from this file. + + `patch_sdk` is a last resort escape hatch that allows you to do customizations + you can't accomplish using the techniques described in + https://aka.ms/azsdk/python/dpcodegen/python/customize + """ diff --git a/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/subscriptions/v2019_06_01/models/__init__.py b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/subscriptions/v2019_06_01/models/__init__.py index b7bff9b0b5e27..0858454b7c265 100644 --- a/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/subscriptions/v2019_06_01/models/__init__.py +++ b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/subscriptions/v2019_06_01/models/__init__.py @@ -29,39 +29,41 @@ from ._models_py3 import TenantIdDescription from ._models_py3 import TenantListResult - -from ._subscription_client_enums import ( - ResourceNameStatus, - SpendingLimit, - SubscriptionState, - TenantCategory, -) +from ._subscription_client_enums import ResourceNameStatus +from ._subscription_client_enums import SpendingLimit +from ._subscription_client_enums import SubscriptionState +from ._subscription_client_enums import TenantCategory +from ._patch import __all__ as _patch_all +from ._patch import * # type: ignore # pylint: disable=unused-wildcard-import +from ._patch import patch_sdk as _patch_sdk __all__ = [ - 'AvailabilityZonePeers', - 'CheckResourceNameResult', - 'CheckZonePeersRequest', - 'CheckZonePeersResult', - 'ErrorAdditionalInfo', - 'ErrorDefinition', - 'ErrorDetail', - 'ErrorResponse', - 'ErrorResponseAutoGenerated', - 'Location', - 'LocationListResult', - 'ManagedByTenant', - 'Operation', - 'OperationDisplay', - 'OperationListResult', - 'Peers', - 'ResourceName', - 'Subscription', - 'SubscriptionListResult', - 'SubscriptionPolicies', - 'TenantIdDescription', - 'TenantListResult', - 'ResourceNameStatus', - 'SpendingLimit', - 'SubscriptionState', - 'TenantCategory', + "AvailabilityZonePeers", + "CheckResourceNameResult", + "CheckZonePeersRequest", + "CheckZonePeersResult", + "ErrorAdditionalInfo", + "ErrorDefinition", + "ErrorDetail", + "ErrorResponse", + "ErrorResponseAutoGenerated", + "Location", + "LocationListResult", + "ManagedByTenant", + "Operation", + "OperationDisplay", + "OperationListResult", + "Peers", + "ResourceName", + "Subscription", + "SubscriptionListResult", + "SubscriptionPolicies", + "TenantIdDescription", + "TenantListResult", + "ResourceNameStatus", + "SpendingLimit", + "SubscriptionState", + "TenantCategory", ] +__all__.extend([p for p in _patch_all if p not in __all__]) +_patch_sdk() diff --git a/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/subscriptions/v2019_06_01/models/_models_py3.py b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/subscriptions/v2019_06_01/models/_models_py3.py index d3e9311443c35..1693d87ce420f 100644 --- a/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/subscriptions/v2019_06_01/models/_models_py3.py +++ b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/subscriptions/v2019_06_01/models/_models_py3.py @@ -1,4 +1,5 @@ # coding=utf-8 +# pylint: disable=too-many-lines # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. # Licensed under the MIT License. See License.txt in the project root for license information. @@ -6,15 +7,16 @@ # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -from typing import List, Optional, Union +from typing import List, Optional, TYPE_CHECKING, Union -from azure.core.exceptions import HttpResponseError -import msrest.serialization +from ... import _serialization -from ._subscription_client_enums import * +if TYPE_CHECKING: + # pylint: disable=unused-import,ungrouped-imports + from .. import models as _models -class AvailabilityZonePeers(msrest.serialization.Model): +class AvailabilityZonePeers(_serialization.Model): """List of availability zones shared by the subscriptions. Variables are only populated by the server, and will be ignored when sending a request. @@ -26,46 +28,41 @@ class AvailabilityZonePeers(msrest.serialization.Model): """ _validation = { - 'availability_zone': {'readonly': True}, + "availability_zone": {"readonly": True}, } _attribute_map = { - 'availability_zone': {'key': 'availabilityZone', 'type': 'str'}, - 'peers': {'key': 'peers', 'type': '[Peers]'}, + "availability_zone": {"key": "availabilityZone", "type": "str"}, + "peers": {"key": "peers", "type": "[Peers]"}, } - def __init__( - self, - *, - peers: Optional[List["Peers"]] = None, - **kwargs - ): + def __init__(self, *, peers: Optional[List["_models.Peers"]] = None, **kwargs): """ :keyword peers: Details of shared availability zone. :paramtype peers: list[~azure.mgmt.resource.subscriptions.v2019_06_01.models.Peers] """ - super(AvailabilityZonePeers, self).__init__(**kwargs) + super().__init__(**kwargs) self.availability_zone = None self.peers = peers -class CheckResourceNameResult(msrest.serialization.Model): +class CheckResourceNameResult(_serialization.Model): """Resource Name valid if not a reserved word, does not contain a reserved word and does not start with a reserved word. :ivar name: Name of Resource. :vartype name: str :ivar type: Type of Resource. :vartype type: str - :ivar status: Is the resource name Allowed or Reserved. Possible values include: "Allowed", + :ivar status: Is the resource name Allowed or Reserved. Known values are: "Allowed" and "Reserved". :vartype status: str or ~azure.mgmt.resource.subscriptions.v2019_06_01.models.ResourceNameStatus """ _attribute_map = { - 'name': {'key': 'name', 'type': 'str'}, - 'type': {'key': 'type', 'type': 'str'}, - 'status': {'key': 'status', 'type': 'str'}, + "name": {"key": "name", "type": "str"}, + "type": {"key": "type", "type": "str"}, + "status": {"key": "status", "type": "str"}, } def __init__( @@ -73,7 +70,7 @@ def __init__( *, name: Optional[str] = None, type: Optional[str] = None, - status: Optional[Union[str, "ResourceNameStatus"]] = None, + status: Optional[Union[str, "_models.ResourceNameStatus"]] = None, **kwargs ): """ @@ -81,18 +78,18 @@ def __init__( :paramtype name: str :keyword type: Type of Resource. :paramtype type: str - :keyword status: Is the resource name Allowed or Reserved. Possible values include: "Allowed", + :keyword status: Is the resource name Allowed or Reserved. Known values are: "Allowed" and "Reserved". :paramtype status: str or ~azure.mgmt.resource.subscriptions.v2019_06_01.models.ResourceNameStatus """ - super(CheckResourceNameResult, self).__init__(**kwargs) + super().__init__(**kwargs) self.name = name self.type = type self.status = status -class CheckZonePeersRequest(msrest.serialization.Model): +class CheckZonePeersRequest(_serialization.Model): """Check zone peers request parameters. :ivar location: The Microsoft location. @@ -102,29 +99,23 @@ class CheckZonePeersRequest(msrest.serialization.Model): """ _attribute_map = { - 'location': {'key': 'location', 'type': 'str'}, - 'subscription_ids': {'key': 'subscriptionIds', 'type': '[str]'}, + "location": {"key": "location", "type": "str"}, + "subscription_ids": {"key": "subscriptionIds", "type": "[str]"}, } - def __init__( - self, - *, - location: Optional[str] = None, - subscription_ids: Optional[List[str]] = None, - **kwargs - ): + def __init__(self, *, location: Optional[str] = None, subscription_ids: Optional[List[str]] = None, **kwargs): """ :keyword location: The Microsoft location. :paramtype location: str :keyword subscription_ids: The peer Microsoft Azure subscription ID. :paramtype subscription_ids: list[str] """ - super(CheckZonePeersRequest, self).__init__(**kwargs) + super().__init__(**kwargs) self.location = location self.subscription_ids = subscription_ids -class CheckZonePeersResult(msrest.serialization.Model): +class CheckZonePeersResult(_serialization.Model): """Result of the Check zone peers operation. Variables are only populated by the server, and will be ignored when sending a request. @@ -139,20 +130,20 @@ class CheckZonePeersResult(msrest.serialization.Model): """ _validation = { - 'subscription_id': {'readonly': True}, + "subscription_id": {"readonly": True}, } _attribute_map = { - 'subscription_id': {'key': 'subscriptionId', 'type': 'str'}, - 'location': {'key': 'location', 'type': 'str'}, - 'availability_zone_peers': {'key': 'availabilityZonePeers', 'type': '[AvailabilityZonePeers]'}, + "subscription_id": {"key": "subscriptionId", "type": "str"}, + "location": {"key": "location", "type": "str"}, + "availability_zone_peers": {"key": "availabilityZonePeers", "type": "[AvailabilityZonePeers]"}, } def __init__( self, *, location: Optional[str] = None, - availability_zone_peers: Optional[List["AvailabilityZonePeers"]] = None, + availability_zone_peers: Optional[List["_models.AvailabilityZonePeers"]] = None, **kwargs ): """ @@ -162,13 +153,13 @@ def __init__( :paramtype availability_zone_peers: list[~azure.mgmt.resource.subscriptions.v2019_06_01.models.AvailabilityZonePeers] """ - super(CheckZonePeersResult, self).__init__(**kwargs) + super().__init__(**kwargs) self.subscription_id = None self.location = location self.availability_zone_peers = availability_zone_peers -class ErrorAdditionalInfo(msrest.serialization.Model): +class ErrorAdditionalInfo(_serialization.Model): """The resource management error additional info. Variables are only populated by the server, and will be ignored when sending a request. @@ -176,31 +167,27 @@ class ErrorAdditionalInfo(msrest.serialization.Model): :ivar type: The additional info type. :vartype type: str :ivar info: The additional info. - :vartype info: any + :vartype info: JSON """ _validation = { - 'type': {'readonly': True}, - 'info': {'readonly': True}, + "type": {"readonly": True}, + "info": {"readonly": True}, } _attribute_map = { - 'type': {'key': 'type', 'type': 'str'}, - 'info': {'key': 'info', 'type': 'object'}, + "type": {"key": "type", "type": "str"}, + "info": {"key": "info", "type": "object"}, } - def __init__( - self, - **kwargs - ): - """ - """ - super(ErrorAdditionalInfo, self).__init__(**kwargs) + def __init__(self, **kwargs): + """ """ + super().__init__(**kwargs) self.type = None self.info = None -class ErrorDefinition(msrest.serialization.Model): +class ErrorDefinition(_serialization.Model): """Error description and code explaining why resource name is invalid. :ivar message: Description of the error. @@ -210,29 +197,23 @@ class ErrorDefinition(msrest.serialization.Model): """ _attribute_map = { - 'message': {'key': 'message', 'type': 'str'}, - 'code': {'key': 'code', 'type': 'str'}, + "message": {"key": "message", "type": "str"}, + "code": {"key": "code", "type": "str"}, } - def __init__( - self, - *, - message: Optional[str] = None, - code: Optional[str] = None, - **kwargs - ): + def __init__(self, *, message: Optional[str] = None, code: Optional[str] = None, **kwargs): """ :keyword message: Description of the error. :paramtype message: str :keyword code: Code of the error. :paramtype code: str """ - super(ErrorDefinition, self).__init__(**kwargs) + super().__init__(**kwargs) self.message = message self.code = code -class ErrorDetail(msrest.serialization.Model): +class ErrorDetail(_serialization.Model): """The error detail. Variables are only populated by the server, and will be ignored when sending a request. @@ -251,28 +232,24 @@ class ErrorDetail(msrest.serialization.Model): """ _validation = { - 'code': {'readonly': True}, - 'message': {'readonly': True}, - 'target': {'readonly': True}, - 'details': {'readonly': True}, - 'additional_info': {'readonly': True}, + "code": {"readonly": True}, + "message": {"readonly": True}, + "target": {"readonly": True}, + "details": {"readonly": True}, + "additional_info": {"readonly": True}, } _attribute_map = { - 'code': {'key': 'code', 'type': 'str'}, - 'message': {'key': 'message', 'type': 'str'}, - 'target': {'key': 'target', 'type': 'str'}, - 'details': {'key': 'details', 'type': '[ErrorDetail]'}, - 'additional_info': {'key': 'additionalInfo', 'type': '[ErrorAdditionalInfo]'}, + "code": {"key": "code", "type": "str"}, + "message": {"key": "message", "type": "str"}, + "target": {"key": "target", "type": "str"}, + "details": {"key": "details", "type": "[ErrorDetail]"}, + "additional_info": {"key": "additionalInfo", "type": "[ErrorAdditionalInfo]"}, } - def __init__( - self, - **kwargs - ): - """ - """ - super(ErrorDetail, self).__init__(**kwargs) + def __init__(self, **kwargs): + """ """ + super().__init__(**kwargs) self.code = None self.message = None self.target = None @@ -280,7 +257,7 @@ def __init__( self.additional_info = None -class ErrorResponse(msrest.serialization.Model): +class ErrorResponse(_serialization.Model): """Common error response for all Azure Resource Manager APIs to return error details for failed operations. (This also follows the OData error response format.). :ivar error: The error object. @@ -288,24 +265,19 @@ class ErrorResponse(msrest.serialization.Model): """ _attribute_map = { - 'error': {'key': 'error', 'type': 'ErrorDetail'}, + "error": {"key": "error", "type": "ErrorDetail"}, } - def __init__( - self, - *, - error: Optional["ErrorDetail"] = None, - **kwargs - ): + def __init__(self, *, error: Optional["_models.ErrorDetail"] = None, **kwargs): """ :keyword error: The error object. :paramtype error: ~azure.mgmt.resource.subscriptions.v2019_06_01.models.ErrorDetail """ - super(ErrorResponse, self).__init__(**kwargs) + super().__init__(**kwargs) self.error = error -class ErrorResponseAutoGenerated(msrest.serialization.Model): +class ErrorResponseAutoGenerated(_serialization.Model): """Error response. :ivar error: The error details. @@ -313,24 +285,19 @@ class ErrorResponseAutoGenerated(msrest.serialization.Model): """ _attribute_map = { - 'error': {'key': 'error', 'type': 'ErrorDefinition'}, + "error": {"key": "error", "type": "ErrorDefinition"}, } - def __init__( - self, - *, - error: Optional["ErrorDefinition"] = None, - **kwargs - ): + def __init__(self, *, error: Optional["_models.ErrorDefinition"] = None, **kwargs): """ :keyword error: The error details. :paramtype error: ~azure.mgmt.resource.subscriptions.v2019_06_01.models.ErrorDefinition """ - super(ErrorResponseAutoGenerated, self).__init__(**kwargs) + super().__init__(**kwargs) self.error = error -class Location(msrest.serialization.Model): +class Location(_serialization.Model): """Location information. Variables are only populated by the server, and will be ignored when sending a request. @@ -351,30 +318,26 @@ class Location(msrest.serialization.Model): """ _validation = { - 'id': {'readonly': True}, - 'subscription_id': {'readonly': True}, - 'name': {'readonly': True}, - 'display_name': {'readonly': True}, - 'latitude': {'readonly': True}, - 'longitude': {'readonly': True}, + "id": {"readonly": True}, + "subscription_id": {"readonly": True}, + "name": {"readonly": True}, + "display_name": {"readonly": True}, + "latitude": {"readonly": True}, + "longitude": {"readonly": True}, } _attribute_map = { - 'id': {'key': 'id', 'type': 'str'}, - 'subscription_id': {'key': 'subscriptionId', 'type': 'str'}, - 'name': {'key': 'name', 'type': 'str'}, - 'display_name': {'key': 'displayName', 'type': 'str'}, - 'latitude': {'key': 'latitude', 'type': 'str'}, - 'longitude': {'key': 'longitude', 'type': 'str'}, + "id": {"key": "id", "type": "str"}, + "subscription_id": {"key": "subscriptionId", "type": "str"}, + "name": {"key": "name", "type": "str"}, + "display_name": {"key": "displayName", "type": "str"}, + "latitude": {"key": "latitude", "type": "str"}, + "longitude": {"key": "longitude", "type": "str"}, } - def __init__( - self, - **kwargs - ): - """ - """ - super(Location, self).__init__(**kwargs) + def __init__(self, **kwargs): + """ """ + super().__init__(**kwargs) self.id = None self.subscription_id = None self.name = None @@ -383,7 +346,7 @@ def __init__( self.longitude = None -class LocationListResult(msrest.serialization.Model): +class LocationListResult(_serialization.Model): """Location list operation response. :ivar value: An array of locations. @@ -391,24 +354,19 @@ class LocationListResult(msrest.serialization.Model): """ _attribute_map = { - 'value': {'key': 'value', 'type': '[Location]'}, + "value": {"key": "value", "type": "[Location]"}, } - def __init__( - self, - *, - value: Optional[List["Location"]] = None, - **kwargs - ): + def __init__(self, *, value: Optional[List["_models.Location"]] = None, **kwargs): """ :keyword value: An array of locations. :paramtype value: list[~azure.mgmt.resource.subscriptions.v2019_06_01.models.Location] """ - super(LocationListResult, self).__init__(**kwargs) + super().__init__(**kwargs) self.value = value -class ManagedByTenant(msrest.serialization.Model): +class ManagedByTenant(_serialization.Model): """Information about a tenant managing the subscription. Variables are only populated by the server, and will be ignored when sending a request. @@ -418,24 +376,20 @@ class ManagedByTenant(msrest.serialization.Model): """ _validation = { - 'tenant_id': {'readonly': True}, + "tenant_id": {"readonly": True}, } _attribute_map = { - 'tenant_id': {'key': 'tenantId', 'type': 'str'}, + "tenant_id": {"key": "tenantId", "type": "str"}, } - def __init__( - self, - **kwargs - ): - """ - """ - super(ManagedByTenant, self).__init__(**kwargs) + def __init__(self, **kwargs): + """ """ + super().__init__(**kwargs) self.tenant_id = None -class Operation(msrest.serialization.Model): +class Operation(_serialization.Model): """Microsoft.Resources operation. :ivar name: Operation name: {provider}/{resource}/{operation}. @@ -445,29 +399,23 @@ class Operation(msrest.serialization.Model): """ _attribute_map = { - 'name': {'key': 'name', 'type': 'str'}, - 'display': {'key': 'display', 'type': 'OperationDisplay'}, + "name": {"key": "name", "type": "str"}, + "display": {"key": "display", "type": "OperationDisplay"}, } - def __init__( - self, - *, - name: Optional[str] = None, - display: Optional["OperationDisplay"] = None, - **kwargs - ): + def __init__(self, *, name: Optional[str] = None, display: Optional["_models.OperationDisplay"] = None, **kwargs): """ :keyword name: Operation name: {provider}/{resource}/{operation}. :paramtype name: str :keyword display: The object that represents the operation. :paramtype display: ~azure.mgmt.resource.subscriptions.v2019_06_01.models.OperationDisplay """ - super(Operation, self).__init__(**kwargs) + super().__init__(**kwargs) self.name = name self.display = display -class OperationDisplay(msrest.serialization.Model): +class OperationDisplay(_serialization.Model): """The object that represents the operation. :ivar provider: Service provider: Microsoft.Resources. @@ -481,10 +429,10 @@ class OperationDisplay(msrest.serialization.Model): """ _attribute_map = { - 'provider': {'key': 'provider', 'type': 'str'}, - 'resource': {'key': 'resource', 'type': 'str'}, - 'operation': {'key': 'operation', 'type': 'str'}, - 'description': {'key': 'description', 'type': 'str'}, + "provider": {"key": "provider", "type": "str"}, + "resource": {"key": "resource", "type": "str"}, + "operation": {"key": "operation", "type": "str"}, + "description": {"key": "description", "type": "str"}, } def __init__( @@ -506,14 +454,14 @@ def __init__( :keyword description: Description of the operation. :paramtype description: str """ - super(OperationDisplay, self).__init__(**kwargs) + super().__init__(**kwargs) self.provider = provider self.resource = resource self.operation = operation self.description = description -class OperationListResult(msrest.serialization.Model): +class OperationListResult(_serialization.Model): """Result of the request to list Microsoft.Resources operations. It contains a list of operations and a URL link to get the next set of results. :ivar value: List of Microsoft.Resources operations. @@ -523,29 +471,23 @@ class OperationListResult(msrest.serialization.Model): """ _attribute_map = { - 'value': {'key': 'value', 'type': '[Operation]'}, - 'next_link': {'key': 'nextLink', 'type': 'str'}, + "value": {"key": "value", "type": "[Operation]"}, + "next_link": {"key": "nextLink", "type": "str"}, } - def __init__( - self, - *, - value: Optional[List["Operation"]] = None, - next_link: Optional[str] = None, - **kwargs - ): + def __init__(self, *, value: Optional[List["_models.Operation"]] = None, next_link: Optional[str] = None, **kwargs): """ :keyword value: List of Microsoft.Resources operations. :paramtype value: list[~azure.mgmt.resource.subscriptions.v2019_06_01.models.Operation] :keyword next_link: URL to get the next set of operation list results if there are any. :paramtype next_link: str """ - super(OperationListResult, self).__init__(**kwargs) + super().__init__(**kwargs) self.value = value self.next_link = next_link -class Peers(msrest.serialization.Model): +class Peers(_serialization.Model): """Information about shared availability zone. Variables are only populated by the server, and will be ignored when sending a request. @@ -557,66 +499,56 @@ class Peers(msrest.serialization.Model): """ _validation = { - 'subscription_id': {'readonly': True}, - 'availability_zone': {'readonly': True}, + "subscription_id": {"readonly": True}, + "availability_zone": {"readonly": True}, } _attribute_map = { - 'subscription_id': {'key': 'subscriptionId', 'type': 'str'}, - 'availability_zone': {'key': 'availabilityZone', 'type': 'str'}, + "subscription_id": {"key": "subscriptionId", "type": "str"}, + "availability_zone": {"key": "availabilityZone", "type": "str"}, } - def __init__( - self, - **kwargs - ): - """ - """ - super(Peers, self).__init__(**kwargs) + def __init__(self, **kwargs): + """ """ + super().__init__(**kwargs) self.subscription_id = None self.availability_zone = None -class ResourceName(msrest.serialization.Model): +class ResourceName(_serialization.Model): """Name and Type of the Resource. All required parameters must be populated in order to send to Azure. - :ivar name: Required. Name of the resource. + :ivar name: Name of the resource. Required. :vartype name: str - :ivar type: Required. The type of the resource. + :ivar type: The type of the resource. Required. :vartype type: str """ _validation = { - 'name': {'required': True}, - 'type': {'required': True}, + "name": {"required": True}, + "type": {"required": True}, } _attribute_map = { - 'name': {'key': 'name', 'type': 'str'}, - 'type': {'key': 'type', 'type': 'str'}, + "name": {"key": "name", "type": "str"}, + "type": {"key": "type", "type": "str"}, } - def __init__( - self, - *, - name: str, - type: str, - **kwargs - ): + def __init__(self, *, name: str, type: str, **kwargs): """ - :keyword name: Required. Name of the resource. + :keyword name: Name of the resource. Required. :paramtype name: str - :keyword type: Required. The type of the resource. + :keyword type: The type of the resource. Required. :paramtype type: str """ - super(ResourceName, self).__init__(**kwargs) + super().__init__(**kwargs) self.name = name self.type = type -class Subscription(msrest.serialization.Model): +class Subscription(_serialization.Model): """Subscription information. Variables are only populated by the server, and will be ignored when sending a request. @@ -631,7 +563,7 @@ class Subscription(msrest.serialization.Model): :ivar tenant_id: The subscription tenant ID. :vartype tenant_id: str :ivar state: The subscription state. Possible values are Enabled, Warned, PastDue, Disabled, - and Deleted. Possible values include: "Enabled", "Warned", "PastDue", "Disabled", "Deleted". + and Deleted. Known values are: "Enabled", "Warned", "PastDue", "Disabled", and "Deleted". :vartype state: str or ~azure.mgmt.resource.subscriptions.v2019_06_01.models.SubscriptionState :ivar subscription_policies: The subscription policies. :vartype subscription_policies: @@ -646,30 +578,30 @@ class Subscription(msrest.serialization.Model): """ _validation = { - 'id': {'readonly': True}, - 'subscription_id': {'readonly': True}, - 'display_name': {'readonly': True}, - 'tenant_id': {'readonly': True}, - 'state': {'readonly': True}, + "id": {"readonly": True}, + "subscription_id": {"readonly": True}, + "display_name": {"readonly": True}, + "tenant_id": {"readonly": True}, + "state": {"readonly": True}, } _attribute_map = { - 'id': {'key': 'id', 'type': 'str'}, - 'subscription_id': {'key': 'subscriptionId', 'type': 'str'}, - 'display_name': {'key': 'displayName', 'type': 'str'}, - 'tenant_id': {'key': 'tenantId', 'type': 'str'}, - 'state': {'key': 'state', 'type': 'str'}, - 'subscription_policies': {'key': 'subscriptionPolicies', 'type': 'SubscriptionPolicies'}, - 'authorization_source': {'key': 'authorizationSource', 'type': 'str'}, - 'managed_by_tenants': {'key': 'managedByTenants', 'type': '[ManagedByTenant]'}, + "id": {"key": "id", "type": "str"}, + "subscription_id": {"key": "subscriptionId", "type": "str"}, + "display_name": {"key": "displayName", "type": "str"}, + "tenant_id": {"key": "tenantId", "type": "str"}, + "state": {"key": "state", "type": "str"}, + "subscription_policies": {"key": "subscriptionPolicies", "type": "SubscriptionPolicies"}, + "authorization_source": {"key": "authorizationSource", "type": "str"}, + "managed_by_tenants": {"key": "managedByTenants", "type": "[ManagedByTenant]"}, } def __init__( self, *, - subscription_policies: Optional["SubscriptionPolicies"] = None, + subscription_policies: Optional["_models.SubscriptionPolicies"] = None, authorization_source: Optional[str] = None, - managed_by_tenants: Optional[List["ManagedByTenant"]] = None, + managed_by_tenants: Optional[List["_models.ManagedByTenant"]] = None, **kwargs ): """ @@ -684,7 +616,7 @@ def __init__( :paramtype managed_by_tenants: list[~azure.mgmt.resource.subscriptions.v2019_06_01.models.ManagedByTenant] """ - super(Subscription, self).__init__(**kwargs) + super().__init__(**kwargs) self.id = None self.subscription_id = None self.display_name = None @@ -695,45 +627,39 @@ def __init__( self.managed_by_tenants = managed_by_tenants -class SubscriptionListResult(msrest.serialization.Model): +class SubscriptionListResult(_serialization.Model): """Subscription list operation response. All required parameters must be populated in order to send to Azure. :ivar value: An array of subscriptions. :vartype value: list[~azure.mgmt.resource.subscriptions.v2019_06_01.models.Subscription] - :ivar next_link: Required. The URL to get the next set of results. + :ivar next_link: The URL to get the next set of results. Required. :vartype next_link: str """ _validation = { - 'next_link': {'required': True}, + "next_link": {"required": True}, } _attribute_map = { - 'value': {'key': 'value', 'type': '[Subscription]'}, - 'next_link': {'key': 'nextLink', 'type': 'str'}, + "value": {"key": "value", "type": "[Subscription]"}, + "next_link": {"key": "nextLink", "type": "str"}, } - def __init__( - self, - *, - next_link: str, - value: Optional[List["Subscription"]] = None, - **kwargs - ): + def __init__(self, *, next_link: str, value: Optional[List["_models.Subscription"]] = None, **kwargs): """ :keyword value: An array of subscriptions. :paramtype value: list[~azure.mgmt.resource.subscriptions.v2019_06_01.models.Subscription] - :keyword next_link: Required. The URL to get the next set of results. + :keyword next_link: The URL to get the next set of results. Required. :paramtype next_link: str """ - super(SubscriptionListResult, self).__init__(**kwargs) + super().__init__(**kwargs) self.value = value self.next_link = next_link -class SubscriptionPolicies(msrest.serialization.Model): +class SubscriptionPolicies(_serialization.Model): """Subscription policies. Variables are only populated by the server, and will be ignored when sending a request. @@ -744,37 +670,33 @@ class SubscriptionPolicies(msrest.serialization.Model): :vartype location_placement_id: str :ivar quota_id: The subscription quota ID. :vartype quota_id: str - :ivar spending_limit: The subscription spending limit. Possible values include: "On", "Off", + :ivar spending_limit: The subscription spending limit. Known values are: "On", "Off", and "CurrentPeriodOff". :vartype spending_limit: str or ~azure.mgmt.resource.subscriptions.v2019_06_01.models.SpendingLimit """ _validation = { - 'location_placement_id': {'readonly': True}, - 'quota_id': {'readonly': True}, - 'spending_limit': {'readonly': True}, + "location_placement_id": {"readonly": True}, + "quota_id": {"readonly": True}, + "spending_limit": {"readonly": True}, } _attribute_map = { - 'location_placement_id': {'key': 'locationPlacementId', 'type': 'str'}, - 'quota_id': {'key': 'quotaId', 'type': 'str'}, - 'spending_limit': {'key': 'spendingLimit', 'type': 'str'}, + "location_placement_id": {"key": "locationPlacementId", "type": "str"}, + "quota_id": {"key": "quotaId", "type": "str"}, + "spending_limit": {"key": "spendingLimit", "type": "str"}, } - def __init__( - self, - **kwargs - ): - """ - """ - super(SubscriptionPolicies, self).__init__(**kwargs) + def __init__(self, **kwargs): + """ """ + super().__init__(**kwargs) self.location_placement_id = None self.quota_id = None self.spending_limit = None -class TenantIdDescription(msrest.serialization.Model): +class TenantIdDescription(_serialization.Model): """Tenant Id information. Variables are only populated by the server, and will be ignored when sending a request. @@ -784,7 +706,7 @@ class TenantIdDescription(msrest.serialization.Model): :vartype id: str :ivar tenant_id: The tenant ID. For example, 00000000-0000-0000-0000-000000000000. :vartype tenant_id: str - :ivar tenant_category: The tenant category. Possible values include: "Home", "ProjectedBy", + :ivar tenant_category: The tenant category. Known values are: "Home", "ProjectedBy", and "ManagedBy". :vartype tenant_category: str or ~azure.mgmt.resource.subscriptions.v2019_06_01.models.TenantCategory @@ -799,32 +721,28 @@ class TenantIdDescription(msrest.serialization.Model): """ _validation = { - 'id': {'readonly': True}, - 'tenant_id': {'readonly': True}, - 'tenant_category': {'readonly': True}, - 'country': {'readonly': True}, - 'country_code': {'readonly': True}, - 'display_name': {'readonly': True}, - 'domains': {'readonly': True}, + "id": {"readonly": True}, + "tenant_id": {"readonly": True}, + "tenant_category": {"readonly": True}, + "country": {"readonly": True}, + "country_code": {"readonly": True}, + "display_name": {"readonly": True}, + "domains": {"readonly": True}, } _attribute_map = { - 'id': {'key': 'id', 'type': 'str'}, - 'tenant_id': {'key': 'tenantId', 'type': 'str'}, - 'tenant_category': {'key': 'tenantCategory', 'type': 'str'}, - 'country': {'key': 'country', 'type': 'str'}, - 'country_code': {'key': 'countryCode', 'type': 'str'}, - 'display_name': {'key': 'displayName', 'type': 'str'}, - 'domains': {'key': 'domains', 'type': '[str]'}, - } - - def __init__( - self, - **kwargs - ): - """ - """ - super(TenantIdDescription, self).__init__(**kwargs) + "id": {"key": "id", "type": "str"}, + "tenant_id": {"key": "tenantId", "type": "str"}, + "tenant_category": {"key": "tenantCategory", "type": "str"}, + "country": {"key": "country", "type": "str"}, + "country_code": {"key": "countryCode", "type": "str"}, + "display_name": {"key": "displayName", "type": "str"}, + "domains": {"key": "domains", "type": "[str]"}, + } + + def __init__(self, **kwargs): + """ """ + super().__init__(**kwargs) self.id = None self.tenant_id = None self.tenant_category = None @@ -834,40 +752,34 @@ def __init__( self.domains = None -class TenantListResult(msrest.serialization.Model): +class TenantListResult(_serialization.Model): """Tenant Ids information. All required parameters must be populated in order to send to Azure. :ivar value: An array of tenants. :vartype value: list[~azure.mgmt.resource.subscriptions.v2019_06_01.models.TenantIdDescription] - :ivar next_link: Required. The URL to use for getting the next set of results. + :ivar next_link: The URL to use for getting the next set of results. Required. :vartype next_link: str """ _validation = { - 'next_link': {'required': True}, + "next_link": {"required": True}, } _attribute_map = { - 'value': {'key': 'value', 'type': '[TenantIdDescription]'}, - 'next_link': {'key': 'nextLink', 'type': 'str'}, + "value": {"key": "value", "type": "[TenantIdDescription]"}, + "next_link": {"key": "nextLink", "type": "str"}, } - def __init__( - self, - *, - next_link: str, - value: Optional[List["TenantIdDescription"]] = None, - **kwargs - ): + def __init__(self, *, next_link: str, value: Optional[List["_models.TenantIdDescription"]] = None, **kwargs): """ :keyword value: An array of tenants. :paramtype value: list[~azure.mgmt.resource.subscriptions.v2019_06_01.models.TenantIdDescription] - :keyword next_link: Required. The URL to use for getting the next set of results. + :keyword next_link: The URL to use for getting the next set of results. Required. :paramtype next_link: str """ - super(TenantListResult, self).__init__(**kwargs) + super().__init__(**kwargs) self.value = value self.next_link = next_link diff --git a/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/subscriptions/v2019_06_01/models/_patch.py b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/subscriptions/v2019_06_01/models/_patch.py new file mode 100644 index 0000000000000..f7dd32510333d --- /dev/null +++ b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/subscriptions/v2019_06_01/models/_patch.py @@ -0,0 +1,20 @@ +# ------------------------------------ +# Copyright (c) Microsoft Corporation. +# Licensed under the MIT License. +# ------------------------------------ +"""Customize generated code here. + +Follow our quickstart for examples: https://aka.ms/azsdk/python/dpcodegen/python/customize +""" +from typing import List + +__all__: List[str] = [] # Add all objects you want publicly available to users at this package level + + +def patch_sdk(): + """Do not remove from this file. + + `patch_sdk` is a last resort escape hatch that allows you to do customizations + you can't accomplish using the techniques described in + https://aka.ms/azsdk/python/dpcodegen/python/customize + """ diff --git a/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/subscriptions/v2019_06_01/models/_subscription_client_enums.py b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/subscriptions/v2019_06_01/models/_subscription_client_enums.py index cf21cf34210ce..b441071f6e620 100644 --- a/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/subscriptions/v2019_06_01/models/_subscription_client_enums.py +++ b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/subscriptions/v2019_06_01/models/_subscription_client_enums.py @@ -7,28 +7,26 @@ # -------------------------------------------------------------------------- from enum import Enum -from six import with_metaclass from azure.core import CaseInsensitiveEnumMeta -class ResourceNameStatus(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): - """Is the resource name Allowed or Reserved - """ +class ResourceNameStatus(str, Enum, metaclass=CaseInsensitiveEnumMeta): + """Is the resource name Allowed or Reserved.""" ALLOWED = "Allowed" RESERVED = "Reserved" -class SpendingLimit(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): - """The subscription spending limit. - """ + +class SpendingLimit(str, Enum, metaclass=CaseInsensitiveEnumMeta): + """The subscription spending limit.""" ON = "On" OFF = "Off" CURRENT_PERIOD_OFF = "CurrentPeriodOff" -class SubscriptionState(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): - """The subscription state. Possible values are Enabled, Warned, PastDue, Disabled, and Deleted. - """ + +class SubscriptionState(str, Enum, metaclass=CaseInsensitiveEnumMeta): + """The subscription state. Possible values are Enabled, Warned, PastDue, Disabled, and Deleted.""" ENABLED = "Enabled" WARNED = "Warned" @@ -36,9 +34,9 @@ class SubscriptionState(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): DISABLED = "Disabled" DELETED = "Deleted" -class TenantCategory(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): - """The tenant category. - """ + +class TenantCategory(str, Enum, metaclass=CaseInsensitiveEnumMeta): + """The tenant category.""" HOME = "Home" PROJECTED_BY = "ProjectedBy" diff --git a/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/subscriptions/v2019_06_01/operations/__init__.py b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/subscriptions/v2019_06_01/operations/__init__.py index 437b49e23548f..1066cb67ea911 100644 --- a/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/subscriptions/v2019_06_01/operations/__init__.py +++ b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/subscriptions/v2019_06_01/operations/__init__.py @@ -11,9 +11,15 @@ from ._operations import TenantsOperations from ._operations import SubscriptionClientOperationsMixin +from ._patch import __all__ as _patch_all +from ._patch import * # type: ignore # pylint: disable=unused-wildcard-import +from ._patch import patch_sdk as _patch_sdk + __all__ = [ - 'Operations', - 'SubscriptionsOperations', - 'TenantsOperations', - 'SubscriptionClientOperationsMixin', + "Operations", + "SubscriptionsOperations", + "TenantsOperations", + "SubscriptionClientOperationsMixin", ] +__all__.extend([p for p in _patch_all if p not in __all__]) +_patch_sdk() diff --git a/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/subscriptions/v2019_06_01/operations/_operations.py b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/subscriptions/v2019_06_01/operations/_operations.py index 1c94679eea8f6..82f03b2fcb3b9 100644 --- a/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/subscriptions/v2019_06_01/operations/_operations.py +++ b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/subscriptions/v2019_06_01/operations/_operations.py @@ -6,301 +6,253 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -from typing import Any, Callable, Dict, Iterable, Optional, TypeVar - -from msrest import Serializer - -from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error +from typing import Any, Callable, Dict, IO, Iterable, Optional, TypeVar, Union, overload +from urllib.parse import parse_qs, urljoin, urlparse + +from azure.core.exceptions import ( + ClientAuthenticationError, + HttpResponseError, + ResourceExistsError, + ResourceNotFoundError, + ResourceNotModifiedError, + map_error, +) from azure.core.paging import ItemPaged from azure.core.pipeline import PipelineResponse from azure.core.pipeline.transport import HttpResponse from azure.core.rest import HttpRequest from azure.core.tracing.decorator import distributed_trace +from azure.core.utils import case_insensitive_dict from azure.mgmt.core.exceptions import ARMErrorFormat from .. import models as _models -from .._vendor import _convert_request, _format_url_section -T = TypeVar('T') +from ..._serialization import Serializer +from .._vendor import MixinABC, _convert_request, _format_url_section + +T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] -JSONType = Any _SERIALIZER = Serializer() _SERIALIZER.client_side_validation = False -def build_operations_list_request( - **kwargs: Any -) -> HttpRequest: - api_version = kwargs.pop('api_version', "2019-06-01") # type: str - accept = "application/json" +def build_operations_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", "2019-06-01")) # type: str + accept = _headers.pop("Accept", "application/json") + # Construct URL _url = kwargs.pop("template_url", "/providers/Microsoft.Resources/operations") # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) - return HttpRequest( - method="GET", - url=_url, - params=_query_parameters, - headers=_header_parameters, - **kwargs - ) +def build_subscriptions_list_locations_request(subscription_id: str, **kwargs: Any) -> HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) -def build_subscriptions_list_locations_request( - subscription_id: str, - **kwargs: Any -) -> HttpRequest: - api_version = kwargs.pop('api_version', "2019-06-01") # type: str + api_version = kwargs.pop("api_version", _params.pop("api-version", "2019-06-01")) # type: str + accept = _headers.pop("Accept", "application/json") - accept = "application/json" # Construct URL _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/locations") path_format_arguments = { - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), } _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - return HttpRequest( - method="GET", - url=_url, - params=_query_parameters, - headers=_header_parameters, - **kwargs - ) + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) -def build_subscriptions_get_request( - subscription_id: str, - **kwargs: Any -) -> HttpRequest: - api_version = kwargs.pop('api_version', "2019-06-01") # type: str +def build_subscriptions_get_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", "2019-06-01")) # type: str + accept = _headers.pop("Accept", "application/json") - accept = "application/json" # Construct URL _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}") path_format_arguments = { - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), } _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) - return HttpRequest( - method="GET", - url=_url, - params=_query_parameters, - headers=_header_parameters, - **kwargs - ) +def build_subscriptions_list_request(**kwargs: Any) -> HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) -def build_subscriptions_list_request( - **kwargs: Any -) -> HttpRequest: - api_version = kwargs.pop('api_version', "2019-06-01") # type: str + api_version = kwargs.pop("api_version", _params.pop("api-version", "2019-06-01")) # type: str + accept = _headers.pop("Accept", "application/json") - accept = "application/json" # Construct URL _url = kwargs.pop("template_url", "/subscriptions") # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') - - return HttpRequest( - method="GET", - url=_url, - params=_query_parameters, - headers=_header_parameters, - **kwargs - ) - - -def build_subscriptions_check_zone_peers_request( - subscription_id: str, - *, - json: JSONType = None, - content: Any = None, - **kwargs: Any -) -> HttpRequest: - api_version = kwargs.pop('api_version', "2019-06-01") # type: str - content_type = kwargs.pop('content_type', None) # type: Optional[str] - - accept = "application/json" + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) + + +def build_subscriptions_check_zone_peers_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", "2019-06-01")) # type: str + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + accept = _headers.pop("Accept", "application/json") + # Construct URL _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/providers/Microsoft.Resources/checkZonePeers/") path_format_arguments = { - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), } _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] if content_type is not None: - _header_parameters['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') - _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') - - return HttpRequest( - method="POST", - url=_url, - params=_query_parameters, - headers=_header_parameters, - json=json, - content=content, - **kwargs - ) - - -def build_tenants_list_request( - **kwargs: Any -) -> HttpRequest: - api_version = kwargs.pop('api_version', "2019-06-01") # type: str - - accept = "application/json" + _headers["Content-Type"] = _SERIALIZER.header("content_type", content_type, "str") + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="POST", url=_url, params=_params, headers=_headers, **kwargs) + + +def build_tenants_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", "2019-06-01")) # type: str + accept = _headers.pop("Accept", "application/json") + # Construct URL _url = kwargs.pop("template_url", "/tenants") # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') - - return HttpRequest( - method="GET", - url=_url, - params=_query_parameters, - headers=_header_parameters, - **kwargs - ) - - -def build_check_resource_name_request( - *, - json: JSONType = None, - content: Any = None, - **kwargs: Any -) -> HttpRequest: - api_version = kwargs.pop('api_version', "2019-06-01") # type: str - content_type = kwargs.pop('content_type', None) # type: Optional[str] - - accept = "application/json" + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) + + +def build_check_resource_name_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", "2019-06-01")) # type: str + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + accept = _headers.pop("Accept", "application/json") + # Construct URL _url = kwargs.pop("template_url", "/providers/Microsoft.Resources/checkResourceName") # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] if content_type is not None: - _header_parameters['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') - _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') - - return HttpRequest( - method="POST", - url=_url, - params=_query_parameters, - headers=_header_parameters, - json=json, - content=content, - **kwargs - ) - -class Operations(object): - """Operations operations. - - You should not instantiate this class directly. Instead, you should create a Client instance that - instantiates it for you and attaches it as an attribute. - - :ivar models: Alias to model classes used in this operation group. - :type models: ~azure.mgmt.resource.subscriptions.v2019_06_01.models - :param client: Client for service requests. - :param config: Configuration of service client. - :param serializer: An object model serializer. - :param deserializer: An object model deserializer. + _headers["Content-Type"] = _SERIALIZER.header("content_type", content_type, "str") + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="POST", url=_url, params=_params, headers=_headers, **kwargs) + + +class Operations: + """ + .. warning:: + **DO NOT** instantiate this class directly. + + Instead, you should access the following operations through + :class:`~azure.mgmt.resource.subscriptions.v2019_06_01.SubscriptionClient`'s + :attr:`operations` attribute. """ models = _models - def __init__(self, client, config, serializer, deserializer): - self._client = client - self._serialize = serializer - self._deserialize = deserializer - self._config = config + def __init__(self, *args, **kwargs): + input_args = list(args) + self._client = input_args.pop(0) if input_args else kwargs.pop("client") + self._config = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") @distributed_trace - def list( - self, - **kwargs: Any - ) -> Iterable["_models.OperationListResult"]: + def list(self, **kwargs: Any) -> Iterable["_models.Operation"]: """Lists all of the available Microsoft.Resources REST API operations. :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either OperationListResult or the result of cls(response) + :return: An iterator like instance of either Operation or the result of cls(response) :rtype: - ~azure.core.paging.ItemPaged[~azure.mgmt.resource.subscriptions.v2019_06_01.models.OperationListResult] - :raises: ~azure.core.exceptions.HttpResponseError + ~azure.core.paging.ItemPaged[~azure.mgmt.resource.subscriptions.v2019_06_01.models.Operation] + :raises ~azure.core.exceptions.HttpResponseError: """ - api_version = kwargs.pop('api_version', "2019-06-01") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2019-06-01")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[_models.OperationListResult] - cls = kwargs.pop('cls', None) # type: ClsType["_models.OperationListResult"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) + def prepare_request(next_link=None): if not next_link: - + request = build_operations_list_request( api_version=api_version, - template_url=self.list.metadata['url'], + template_url=self.list.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore else: - - request = build_operations_list_request( - template_url=next_link, - ) + # make call to next link with the client's api-version + _parsed_next_link = urlparse(next_link) + _next_request_params = case_insensitive_dict(parse_qs(_parsed_next_link.query)) + _next_request_params["api-version"] = self._config.api_version + request = HttpRequest("GET", urljoin(next_link, _parsed_next_link.path), params=_next_request_params) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore request.method = "GET" return request @@ -314,10 +266,8 @@ def extract_data(pipeline_response): def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) response = pipeline_response.http_response @@ -327,78 +277,80 @@ def get_next(next_link=None): return pipeline_response + return ItemPaged(get_next, extract_data) - return ItemPaged( - get_next, extract_data - ) - list.metadata = {'url': "/providers/Microsoft.Resources/operations"} # type: ignore -class SubscriptionsOperations(object): - """SubscriptionsOperations operations. - - You should not instantiate this class directly. Instead, you should create a Client instance that - instantiates it for you and attaches it as an attribute. - - :ivar models: Alias to model classes used in this operation group. - :type models: ~azure.mgmt.resource.subscriptions.v2019_06_01.models - :param client: Client for service requests. - :param config: Configuration of service client. - :param serializer: An object model serializer. - :param deserializer: An object model deserializer. + list.metadata = {"url": "/providers/Microsoft.Resources/operations"} # type: ignore + + +class SubscriptionsOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. + + Instead, you should access the following operations through + :class:`~azure.mgmt.resource.subscriptions.v2019_06_01.SubscriptionClient`'s + :attr:`subscriptions` attribute. """ models = _models - def __init__(self, client, config, serializer, deserializer): - self._client = client - self._serialize = serializer - self._deserialize = deserializer - self._config = config + def __init__(self, *args, **kwargs): + input_args = list(args) + self._client = input_args.pop(0) if input_args else kwargs.pop("client") + self._config = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") @distributed_trace - def list_locations( - self, - subscription_id: str, - **kwargs: Any - ) -> Iterable["_models.LocationListResult"]: + def list_locations(self, subscription_id: str, **kwargs: Any) -> Iterable["_models.Location"]: """Gets all available geo-locations. This operation provides all the locations that are available for resource providers; however, each resource provider may support a subset of this list. - :param subscription_id: The ID of the target subscription. + :param subscription_id: The ID of the target subscription. Required. :type subscription_id: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either LocationListResult or the result of cls(response) + :return: An iterator like instance of either Location or the result of cls(response) :rtype: - ~azure.core.paging.ItemPaged[~azure.mgmt.resource.subscriptions.v2019_06_01.models.LocationListResult] - :raises: ~azure.core.exceptions.HttpResponseError + ~azure.core.paging.ItemPaged[~azure.mgmt.resource.subscriptions.v2019_06_01.models.Location] + :raises ~azure.core.exceptions.HttpResponseError: """ - api_version = kwargs.pop('api_version', "2019-06-01") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2019-06-01")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[_models.LocationListResult] - cls = kwargs.pop('cls', None) # type: ClsType["_models.LocationListResult"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) + def prepare_request(next_link=None): if not next_link: - + request = build_subscriptions_list_locations_request( subscription_id=subscription_id, api_version=api_version, - template_url=self.list_locations.metadata['url'], + template_url=self.list_locations.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore else: - - request = build_subscriptions_list_locations_request( - subscription_id=subscription_id, - template_url=next_link, - ) + # make call to next link with the client's api-version + _parsed_next_link = urlparse(next_link) + _next_request_params = case_insensitive_dict(parse_qs(_parsed_next_link.query)) + _next_request_params["api-version"] = self._config.api_version + request = HttpRequest("GET", urljoin(next_link, _parsed_next_link.path), params=_next_request_params) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore request.method = "GET" return request @@ -412,10 +364,8 @@ def extract_data(pipeline_response): def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) response = pipeline_response.http_response @@ -425,103 +375,108 @@ def get_next(next_link=None): return pipeline_response + return ItemPaged(get_next, extract_data) - return ItemPaged( - get_next, extract_data - ) - list_locations.metadata = {'url': "/subscriptions/{subscriptionId}/locations"} # type: ignore + list_locations.metadata = {"url": "/subscriptions/{subscriptionId}/locations"} # type: ignore @distributed_trace - def get( - self, - subscription_id: str, - **kwargs: Any - ) -> "_models.Subscription": + def get(self, subscription_id: str, **kwargs: Any) -> _models.Subscription: """Gets details about a specified subscription. - :param subscription_id: The ID of the target subscription. + :param subscription_id: The ID of the target subscription. Required. :type subscription_id: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: Subscription, or the result of cls(response) + :return: Subscription or the result of cls(response) :rtype: ~azure.mgmt.resource.subscriptions.v2019_06_01.models.Subscription - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.Subscription"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + 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', "2019-06-01") # type: str + api_version = kwargs.pop("api_version", _params.pop("api-version", "2019-06-01")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[_models.Subscription] - request = build_subscriptions_get_request( subscription_id=subscription_id, api_version=api_version, - template_url=self.get.metadata['url'], + template_url=self.get.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) - deserialized = self._deserialize('Subscription', pipeline_response) + deserialized = self._deserialize("Subscription", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - get.metadata = {'url': "/subscriptions/{subscriptionId}"} # type: ignore - + get.metadata = {"url": "/subscriptions/{subscriptionId}"} # type: ignore @distributed_trace - def list( - self, - **kwargs: Any - ) -> Iterable["_models.SubscriptionListResult"]: + def list(self, **kwargs: Any) -> Iterable["_models.Subscription"]: """Gets all subscriptions for a tenant. :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either SubscriptionListResult or the result of - cls(response) + :return: An iterator like instance of either Subscription or the result of cls(response) :rtype: - ~azure.core.paging.ItemPaged[~azure.mgmt.resource.subscriptions.v2019_06_01.models.SubscriptionListResult] - :raises: ~azure.core.exceptions.HttpResponseError + ~azure.core.paging.ItemPaged[~azure.mgmt.resource.subscriptions.v2019_06_01.models.Subscription] + :raises ~azure.core.exceptions.HttpResponseError: """ - api_version = kwargs.pop('api_version', "2019-06-01") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2019-06-01")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[_models.SubscriptionListResult] - cls = kwargs.pop('cls', None) # type: ClsType["_models.SubscriptionListResult"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) + def prepare_request(next_link=None): if not next_link: - + request = build_subscriptions_list_request( api_version=api_version, - template_url=self.list.metadata['url'], + template_url=self.list.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore else: - - request = build_subscriptions_list_request( - template_url=next_link, - ) + # make call to next link with the client's api-version + _parsed_next_link = urlparse(next_link) + _next_request_params = case_insensitive_dict(parse_qs(_parsed_next_link.query)) + _next_request_params["api-version"] = self._config.api_version + request = HttpRequest("GET", urljoin(next_link, _parsed_next_link.path), params=_next_request_params) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore request.method = "GET" return request @@ -535,10 +490,8 @@ def extract_data(pipeline_response): def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) response = pipeline_response.http_response @@ -548,56 +501,113 @@ def get_next(next_link=None): return pipeline_response + return ItemPaged(get_next, extract_data) - return ItemPaged( - get_next, extract_data - ) - list.metadata = {'url': "/subscriptions"} # type: ignore + list.metadata = {"url": "/subscriptions"} # type: ignore - @distributed_trace + @overload def check_zone_peers( self, subscription_id: str, - parameters: "_models.CheckZonePeersRequest", + parameters: _models.CheckZonePeersRequest, + *, + content_type: str = "application/json", **kwargs: Any - ) -> "_models.CheckZonePeersResult": + ) -> _models.CheckZonePeersResult: + """Compares a subscriptions logical zone mapping. + + :param subscription_id: The ID of the target subscription. Required. + :type subscription_id: str + :param parameters: Parameters for checking zone peers. Required. + :type parameters: ~azure.mgmt.resource.subscriptions.v2019_06_01.models.CheckZonePeersRequest + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: CheckZonePeersResult or the result of cls(response) + :rtype: ~azure.mgmt.resource.subscriptions.v2019_06_01.models.CheckZonePeersResult + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + def check_zone_peers( + self, subscription_id: str, parameters: IO, *, content_type: str = "application/json", **kwargs: Any + ) -> _models.CheckZonePeersResult: + """Compares a subscriptions logical zone mapping. + + :param subscription_id: The ID of the target subscription. Required. + :type subscription_id: str + :param parameters: Parameters for checking zone peers. Required. + :type parameters: IO + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: CheckZonePeersResult or the result of cls(response) + :rtype: ~azure.mgmt.resource.subscriptions.v2019_06_01.models.CheckZonePeersResult + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace + def check_zone_peers( + self, subscription_id: str, parameters: Union[_models.CheckZonePeersRequest, IO], **kwargs: Any + ) -> _models.CheckZonePeersResult: """Compares a subscriptions logical zone mapping. - :param subscription_id: The ID of the target subscription. + :param subscription_id: The ID of the target subscription. Required. :type subscription_id: str - :param parameters: Parameters for checking zone peers. + :param parameters: Parameters for checking zone peers. Is either a model type or a IO type. + Required. :type parameters: ~azure.mgmt.resource.subscriptions.v2019_06_01.models.CheckZonePeersRequest + or IO + :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. + Default value is None. + :paramtype content_type: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: CheckZonePeersResult, or the result of cls(response) + :return: CheckZonePeersResult or the result of cls(response) :rtype: ~azure.mgmt.resource.subscriptions.v2019_06_01.models.CheckZonePeersResult - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.CheckZonePeersResult"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) - api_version = kwargs.pop('api_version', "2019-06-01") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - _json = self._serialize.body(parameters, 'CheckZonePeersRequest') + api_version = kwargs.pop("api_version", _params.pop("api-version", "2019-06-01")) # type: str + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.CheckZonePeersResult] + + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(parameters, (IO, bytes)): + _content = parameters + else: + _json = self._serialize.body(parameters, "CheckZonePeersRequest") request = build_subscriptions_check_zone_peers_request( subscription_id=subscription_id, api_version=api_version, content_type=content_type, json=_json, - template_url=self.check_zone_peers.metadata['url'], + content=_content, + template_url=self.check_zone_peers.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200]: @@ -605,74 +615,79 @@ def check_zone_peers( error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - deserialized = self._deserialize('CheckZonePeersResult', pipeline_response) + deserialized = self._deserialize("CheckZonePeersResult", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - check_zone_peers.metadata = {'url': "/subscriptions/{subscriptionId}/providers/Microsoft.Resources/checkZonePeers/"} # type: ignore + check_zone_peers.metadata = {"url": "/subscriptions/{subscriptionId}/providers/Microsoft.Resources/checkZonePeers/"} # type: ignore -class TenantsOperations(object): - """TenantsOperations operations. - You should not instantiate this class directly. Instead, you should create a Client instance that - instantiates it for you and attaches it as an attribute. +class TenantsOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. - :ivar models: Alias to model classes used in this operation group. - :type models: ~azure.mgmt.resource.subscriptions.v2019_06_01.models - :param client: Client for service requests. - :param config: Configuration of service client. - :param serializer: An object model serializer. - :param deserializer: An object model deserializer. + Instead, you should access the following operations through + :class:`~azure.mgmt.resource.subscriptions.v2019_06_01.SubscriptionClient`'s + :attr:`tenants` attribute. """ models = _models - def __init__(self, client, config, serializer, deserializer): - self._client = client - self._serialize = serializer - self._deserialize = deserializer - self._config = config + def __init__(self, *args, **kwargs): + input_args = list(args) + self._client = input_args.pop(0) if input_args else kwargs.pop("client") + self._config = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") @distributed_trace - def list( - self, - **kwargs: Any - ) -> Iterable["_models.TenantListResult"]: + def list(self, **kwargs: Any) -> Iterable["_models.TenantIdDescription"]: """Gets the tenants for your account. :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either TenantListResult or the result of cls(response) + :return: An iterator like instance of either TenantIdDescription or the result of cls(response) :rtype: - ~azure.core.paging.ItemPaged[~azure.mgmt.resource.subscriptions.v2019_06_01.models.TenantListResult] - :raises: ~azure.core.exceptions.HttpResponseError + ~azure.core.paging.ItemPaged[~azure.mgmt.resource.subscriptions.v2019_06_01.models.TenantIdDescription] + :raises ~azure.core.exceptions.HttpResponseError: """ - api_version = kwargs.pop('api_version', "2019-06-01") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2019-06-01")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[_models.TenantListResult] - cls = kwargs.pop('cls', None) # type: ClsType["_models.TenantListResult"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) + def prepare_request(next_link=None): if not next_link: - + request = build_tenants_list_request( api_version=api_version, - template_url=self.list.metadata['url'], + template_url=self.list.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore else: - - request = build_tenants_list_request( - template_url=next_link, - ) + # make call to next link with the client's api-version + _parsed_next_link = urlparse(next_link) + _next_request_params = case_insensitive_dict(parse_qs(_parsed_next_link.query)) + _next_request_params["api-version"] = self._config.api_version + request = HttpRequest("GET", urljoin(next_link, _parsed_next_link.path), params=_next_request_params) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore request.method = "GET" return request @@ -686,10 +701,8 @@ def extract_data(pipeline_response): def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) response = pipeline_response.http_response @@ -699,19 +712,20 @@ def get_next(next_link=None): return pipeline_response + return ItemPaged(get_next, extract_data) - return ItemPaged( - get_next, extract_data - ) - list.metadata = {'url': "/tenants"} # type: ignore -class SubscriptionClientOperationsMixin(object): + list.metadata = {"url": "/tenants"} # type: ignore - @distributed_trace + +class SubscriptionClientOperationsMixin(MixinABC): + @overload def check_resource_name( self, - resource_name_definition: Optional["_models.ResourceName"] = None, + resource_name_definition: Optional[_models.ResourceName] = None, + *, + content_type: str = "application/json", **kwargs: Any - ) -> "_models.CheckResourceNameResult": + ) -> _models.CheckResourceNameResult: """Checks resource name validity. A resource name is valid if it is not a reserved word, does not contains a reserved word and @@ -721,39 +735,99 @@ def check_resource_name( type. Default value is None. :type resource_name_definition: ~azure.mgmt.resource.subscriptions.v2019_06_01.models.ResourceName + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: CheckResourceNameResult or the result of cls(response) + :rtype: ~azure.mgmt.resource.subscriptions.v2019_06_01.models.CheckResourceNameResult + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + def check_resource_name( + self, resource_name_definition: Optional[IO] = None, *, content_type: str = "application/json", **kwargs: Any + ) -> _models.CheckResourceNameResult: + """Checks resource name validity. + + A resource name is valid if it is not a reserved word, does not contains a reserved word and + does not start with a reserved word. + + :param resource_name_definition: Resource object with values for resource name and resource + type. Default value is None. + :type resource_name_definition: IO + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: CheckResourceNameResult, or the result of cls(response) + :return: CheckResourceNameResult or the result of cls(response) :rtype: ~azure.mgmt.resource.subscriptions.v2019_06_01.models.CheckResourceNameResult - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace + def check_resource_name( + self, resource_name_definition: Optional[Union[_models.ResourceName, IO]] = None, **kwargs: Any + ) -> _models.CheckResourceNameResult: + """Checks resource name validity. + + A resource name is valid if it is not a reserved word, does not contains a reserved word and + does not start with a reserved word. + + :param resource_name_definition: Resource object with values for resource name and resource + type. Is either a model type or a IO type. Default value is None. + :type resource_name_definition: + ~azure.mgmt.resource.subscriptions.v2019_06_01.models.ResourceName or IO + :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. + Default value is None. + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: CheckResourceNameResult or the result of cls(response) + :rtype: ~azure.mgmt.resource.subscriptions.v2019_06_01.models.CheckResourceNameResult + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.CheckResourceNameResult"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', "2019-06-01") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + api_version = kwargs.pop("api_version", _params.pop("api-version", "2019-06-01")) # type: str + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.CheckResourceNameResult] - if resource_name_definition is not None: - _json = self._serialize.body(resource_name_definition, 'ResourceName') + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(resource_name_definition, (IO, bytes)): + _content = resource_name_definition else: - _json = None + if resource_name_definition is not None: + _json = self._serialize.body(resource_name_definition, "ResourceName") + else: + _json = None request = build_check_resource_name_request( api_version=api_version, content_type=content_type, json=_json, - template_url=self.check_resource_name.metadata['url'], + content=_content, + template_url=self.check_resource_name.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200]: @@ -761,12 +835,11 @@ def check_resource_name( error = self._deserialize.failsafe_deserialize(_models.ErrorResponseAutoGenerated, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - deserialized = self._deserialize('CheckResourceNameResult', pipeline_response) + deserialized = self._deserialize("CheckResourceNameResult", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - check_resource_name.metadata = {'url': "/providers/Microsoft.Resources/checkResourceName"} # type: ignore - + check_resource_name.metadata = {"url": "/providers/Microsoft.Resources/checkResourceName"} # type: ignore diff --git a/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/subscriptions/v2019_06_01/operations/_patch.py b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/subscriptions/v2019_06_01/operations/_patch.py new file mode 100644 index 0000000000000..f7dd32510333d --- /dev/null +++ b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/subscriptions/v2019_06_01/operations/_patch.py @@ -0,0 +1,20 @@ +# ------------------------------------ +# Copyright (c) Microsoft Corporation. +# Licensed under the MIT License. +# ------------------------------------ +"""Customize generated code here. + +Follow our quickstart for examples: https://aka.ms/azsdk/python/dpcodegen/python/customize +""" +from typing import List + +__all__: List[str] = [] # Add all objects you want publicly available to users at this package level + + +def patch_sdk(): + """Do not remove from this file. + + `patch_sdk` is a last resort escape hatch that allows you to do customizations + you can't accomplish using the techniques described in + https://aka.ms/azsdk/python/dpcodegen/python/customize + """ diff --git a/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/subscriptions/v2019_11_01/__init__.py b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/subscriptions/v2019_11_01/__init__.py index abd8e21f33387..d5d8e357d6a54 100644 --- a/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/subscriptions/v2019_11_01/__init__.py +++ b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/subscriptions/v2019_11_01/__init__.py @@ -10,9 +10,15 @@ from ._version import VERSION __version__ = VERSION -__all__ = ['SubscriptionClient'] -# `._patch.py` is used for handwritten extensions to the generated code -# Example: https://github.com/Azure/azure-sdk-for-python/blob/main/doc/dev/customize_code/how-to-patch-sdk-code.md -from ._patch import patch_sdk -patch_sdk() +try: + from ._patch import __all__ as _patch_all + from ._patch import * # type: ignore # pylint: disable=unused-wildcard-import +except ImportError: + _patch_all = [] +from ._patch import patch_sdk as _patch_sdk + +__all__ = ["SubscriptionClient"] +__all__.extend([p for p in _patch_all if p not in __all__]) + +_patch_sdk() diff --git a/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/subscriptions/v2019_11_01/_configuration.py b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/subscriptions/v2019_11_01/_configuration.py index 41cde36513234..86178c55e1476 100644 --- a/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/subscriptions/v2019_11_01/_configuration.py +++ b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/subscriptions/v2019_11_01/_configuration.py @@ -25,43 +25,40 @@ class SubscriptionClientConfiguration(Configuration): # pylint: disable=too-man Note that all parameters used to create this instance are saved as instance attributes. - :param credential: Credential needed for the client to connect to Azure. + :param credential: Credential needed for the client to connect to Azure. Required. :type credential: ~azure.core.credentials.TokenCredential :keyword api_version: Api Version. Default value is "2019-11-01". Note that overriding this default value may result in unsupported behavior. :paramtype api_version: str """ - def __init__( - self, - credential: "TokenCredential", - **kwargs: Any - ) -> None: + def __init__(self, credential: "TokenCredential", **kwargs: Any) -> None: super(SubscriptionClientConfiguration, self).__init__(**kwargs) - api_version = kwargs.pop('api_version', "2019-11-01") # type: str + api_version = kwargs.pop("api_version", "2019-11-01") # type: str if credential is None: raise ValueError("Parameter 'credential' must not be None.") self.credential = credential self.api_version = api_version - self.credential_scopes = kwargs.pop('credential_scopes', ['https://management.azure.com/.default']) - kwargs.setdefault('sdk_moniker', 'mgmt-resource/{}'.format(VERSION)) + self.credential_scopes = kwargs.pop("credential_scopes", ["https://management.azure.com/.default"]) + kwargs.setdefault("sdk_moniker", "mgmt-resource/{}".format(VERSION)) self._configure(**kwargs) def _configure( - self, - **kwargs # type: Any + self, **kwargs # type: Any ): # type: (...) -> 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) - self.logging_policy = kwargs.get('logging_policy') or policies.NetworkTraceLoggingPolicy(**kwargs) - self.http_logging_policy = kwargs.get('http_logging_policy') or ARMHttpLoggingPolicy(**kwargs) - self.retry_policy = kwargs.get('retry_policy') or policies.RetryPolicy(**kwargs) - self.custom_hook_policy = kwargs.get('custom_hook_policy') or policies.CustomHookPolicy(**kwargs) - self.redirect_policy = kwargs.get('redirect_policy') or policies.RedirectPolicy(**kwargs) - self.authentication_policy = kwargs.get('authentication_policy') + 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) + self.logging_policy = kwargs.get("logging_policy") or policies.NetworkTraceLoggingPolicy(**kwargs) + self.http_logging_policy = kwargs.get("http_logging_policy") or ARMHttpLoggingPolicy(**kwargs) + self.retry_policy = kwargs.get("retry_policy") or policies.RetryPolicy(**kwargs) + self.custom_hook_policy = kwargs.get("custom_hook_policy") or policies.CustomHookPolicy(**kwargs) + self.redirect_policy = kwargs.get("redirect_policy") or policies.RedirectPolicy(**kwargs) + self.authentication_policy = kwargs.get("authentication_policy") if self.credential and not self.authentication_policy: - self.authentication_policy = ARMChallengeAuthenticationPolicy(self.credential, *self.credential_scopes, **kwargs) + self.authentication_policy = ARMChallengeAuthenticationPolicy( + self.credential, *self.credential_scopes, **kwargs + ) diff --git a/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/subscriptions/v2019_11_01/_metadata.json b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/subscriptions/v2019_11_01/_metadata.json index bccd9d15e38ed..a7c7b075ff40c 100644 --- a/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/subscriptions/v2019_11_01/_metadata.json +++ b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/subscriptions/v2019_11_01/_metadata.json @@ -10,14 +10,14 @@ "azure_arm": true, "has_lro_operations": false, "client_side_validation": false, - "sync_imports": "{\"typing\": {\"azurecore\": {\"azure.core.credentials\": [\"TokenCredential\"]}}, \"regular\": {\"azurecore\": {\"azure.profiles\": [\"KnownProfiles\", \"ProfileDefinition\"], \"azure.profiles.multiapiclient\": [\"MultiApiClientMixin\"], \"azure.mgmt.core\": [\"ARMPipelineClient\"]}, \"local\": {\"._configuration\": [\"SubscriptionClientConfiguration\"], \"._operations_mixin\": [\"SubscriptionClientOperationsMixin\"]}, \"thirdparty\": {\"msrest\": [\"Deserializer\", \"Serializer\"]}}, \"conditional\": {\"stdlib\": {\"typing\": [\"Any\", \"Optional\"]}}}", - "async_imports": "{\"typing\": {\"azurecore\": {\"azure.core.credentials_async\": [\"AsyncTokenCredential\"], \"azure.core.credentials\": [\"TokenCredential\"]}}, \"regular\": {\"azurecore\": {\"azure.profiles\": [\"KnownProfiles\", \"ProfileDefinition\"], \"azure.profiles.multiapiclient\": [\"MultiApiClientMixin\"], \"azure.mgmt.core\": [\"AsyncARMPipelineClient\"]}, \"local\": {\"._configuration\": [\"SubscriptionClientConfiguration\"], \"._operations_mixin\": [\"SubscriptionClientOperationsMixin\"]}, \"thirdparty\": {\"msrest\": [\"Deserializer\", \"Serializer\"]}}, \"conditional\": {\"stdlib\": {\"typing\": [\"Any\", \"Optional\"]}}}" + "sync_imports": "{\"conditional\": {\"stdlib\": {\"typing\": [\"Any\", \"Optional\"]}}, \"regular\": {\"azurecore\": {\"azure.mgmt.core\": [\"ARMPipelineClient\"], \"azure.profiles\": [\"KnownProfiles\", \"ProfileDefinition\"], \"azure.profiles.multiapiclient\": [\"MultiApiClientMixin\"]}, \"local\": {\"._configuration\": [\"SubscriptionClientConfiguration\"], \".._serialization\": [\"Deserializer\", \"Serializer\"], \"._operations_mixin\": [\"SubscriptionClientOperationsMixin\"]}}, \"typing\": {\"azurecore\": {\"azure.core.credentials\": [\"TokenCredential\"]}}}", + "async_imports": "{\"conditional\": {\"stdlib\": {\"typing\": [\"Any\", \"Optional\"]}}, \"regular\": {\"azurecore\": {\"azure.mgmt.core\": [\"AsyncARMPipelineClient\"], \"azure.profiles\": [\"KnownProfiles\", \"ProfileDefinition\"], \"azure.profiles.multiapiclient\": [\"MultiApiClientMixin\"]}, \"local\": {\"._configuration\": [\"SubscriptionClientConfiguration\"], \"..._serialization\": [\"Deserializer\", \"Serializer\"], \"._operations_mixin\": [\"SubscriptionClientOperationsMixin\"]}}, \"typing\": {\"azurecore\": {\"azure.core.credentials_async\": [\"AsyncTokenCredential\"]}}}" }, "global_parameters": { "sync": { "credential": { - "signature": "credential, # type: \"TokenCredential\"", - "description": "Credential needed for the client to connect to Azure.", + "signature": "credential: \"TokenCredential\",", + "description": "Credential needed for the client to connect to Azure. Required.", "docstring_type": "~azure.core.credentials.TokenCredential", "required": true } @@ -25,7 +25,7 @@ "async": { "credential": { "signature": "credential: \"AsyncTokenCredential\",", - "description": "Credential needed for the client to connect to Azure.", + "description": "Credential needed for the client to connect to Azure. Required.", "docstring_type": "~azure.core.credentials_async.AsyncTokenCredential", "required": true } @@ -42,7 +42,7 @@ "required": false }, "base_url": { - "signature": "base_url=\"https://management.azure.com\", # type: str", + "signature": "base_url: str = \"https://management.azure.com\",", "description": "Service URL", "docstring_type": "str", "required": false @@ -90,20 +90,21 @@ "tenants": "TenantsOperations" }, "operation_mixins": { - "sync_imports": "{\"conditional\": {\"stdlib\": {\"typing\": [\"Any\", \"Optional\"]}}}", - "async_imports": "{\"conditional\": {\"stdlib\": {\"typing\": [\"Any\", \"Optional\"]}}}", + "sync_imports": "{\"conditional\": {\"stdlib\": {\"typing\": [\"Any\"]}}, \"regular\": {\"local\": {\".\": [[\"models\", \"_models\"]]}, \"stdlib\": {\"typing\": [\"IO\", \"Optional\", \"Union\"]}}}", + "async_imports": "{\"conditional\": {\"stdlib\": {\"typing\": [\"Any\"]}}, \"regular\": {\"local\": {\"..\": [[\"models\", \"_models\"]]}, \"stdlib\": {\"typing\": [\"IO\", \"Optional\", \"Union\"]}}}", "operations": { "check_resource_name" : { "sync": { - "signature": "def check_resource_name(\n self,\n resource_name_definition=None, # type: Optional[\"_models.ResourceName\"]\n **kwargs # type: Any\n):\n # type: (...) -\u003e \"_models.CheckResourceNameResult\"\n", - "doc": "\"\"\"Checks resource name validity.\n\nA resource name is valid if it is not a reserved word, does not contains a reserved word and\ndoes not start with a reserved word.\n\n:param resource_name_definition: Resource object with values for resource name and resource\n type. Default value is None.\n:type resource_name_definition:\n ~azure.mgmt.resource.subscriptions.v2019_11_01.models.ResourceName\n:keyword callable cls: A custom type or function that will be passed the direct response\n:return: CheckResourceNameResult, or the result of cls(response)\n:rtype: ~azure.mgmt.resource.subscriptions.v2019_11_01.models.CheckResourceNameResult\n:raises: ~azure.core.exceptions.HttpResponseError\n\"\"\"" + "signature": "def check_resource_name(\n self,\n resource_name_definition: Optional[Union[_models.ResourceName, IO]] = None,\n **kwargs: Any\n) -\u003e _models.CheckResourceNameResult:\n", + "doc": "\"\"\"Checks resource name validity.\n\nA resource name is valid if it is not a reserved word, does not contains a reserved word and\ndoes not start with a reserved word.\n\n:param resource_name_definition: Resource object with values for resource name and resource\n type. Is either a model type or a IO type. Default value is None.\n:type resource_name_definition:\n ~azure.mgmt.resource.subscriptions.v2019_11_01.models.ResourceName or IO\n:keyword content_type: Body Parameter content-type. Known values are: \u0027application/json\u0027.\n Default value is None.\n:paramtype content_type: str\n:keyword callable cls: A custom type or function that will be passed the direct response\n:return: CheckResourceNameResult or the result of cls(response)\n:rtype: ~azure.mgmt.resource.subscriptions.v2019_11_01.models.CheckResourceNameResult\n:raises ~azure.core.exceptions.HttpResponseError:\n\"\"\"", + "call": "resource_name_definition, **kwargs" }, "async": { "coroutine": true, - "signature": "async def check_resource_name(\n self,\n resource_name_definition: Optional[\"_models.ResourceName\"] = None,\n **kwargs: Any\n) -\u003e \"_models.CheckResourceNameResult\":\n", - "doc": "\"\"\"Checks resource name validity.\n\nA resource name is valid if it is not a reserved word, does not contains a reserved word and\ndoes not start with a reserved word.\n\n:param resource_name_definition: Resource object with values for resource name and resource\n type. Default value is None.\n:type resource_name_definition:\n ~azure.mgmt.resource.subscriptions.v2019_11_01.models.ResourceName\n:keyword callable cls: A custom type or function that will be passed the direct response\n:return: CheckResourceNameResult, or the result of cls(response)\n:rtype: ~azure.mgmt.resource.subscriptions.v2019_11_01.models.CheckResourceNameResult\n:raises: ~azure.core.exceptions.HttpResponseError\n\"\"\"" - }, - "call": "resource_name_definition" + "signature": "async def check_resource_name(\n self,\n resource_name_definition: Optional[Union[_models.ResourceName, IO]] = None,\n **kwargs: Any\n) -\u003e _models.CheckResourceNameResult:\n", + "doc": "\"\"\"Checks resource name validity.\n\nA resource name is valid if it is not a reserved word, does not contains a reserved word and\ndoes not start with a reserved word.\n\n:param resource_name_definition: Resource object with values for resource name and resource\n type. Is either a model type or a IO type. Default value is None.\n:type resource_name_definition:\n ~azure.mgmt.resource.subscriptions.v2019_11_01.models.ResourceName or IO\n:keyword content_type: Body Parameter content-type. Known values are: \u0027application/json\u0027.\n Default value is None.\n:paramtype content_type: str\n:keyword callable cls: A custom type or function that will be passed the direct response\n:return: CheckResourceNameResult or the result of cls(response)\n:rtype: ~azure.mgmt.resource.subscriptions.v2019_11_01.models.CheckResourceNameResult\n:raises ~azure.core.exceptions.HttpResponseError:\n\"\"\"", + "call": "resource_name_definition, **kwargs" + } } } } diff --git a/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/subscriptions/v2019_11_01/_patch.py b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/subscriptions/v2019_11_01/_patch.py index 74e48ecd07cf3..f99e77fef9861 100644 --- a/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/subscriptions/v2019_11_01/_patch.py +++ b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/subscriptions/v2019_11_01/_patch.py @@ -28,4 +28,4 @@ # This file is used for handwritten extensions to the generated code. Example: # https://github.com/Azure/azure-sdk-for-python/blob/main/doc/dev/customize_code/how-to-patch-sdk-code.md def patch_sdk(): - pass \ No newline at end of file + pass diff --git a/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/subscriptions/v2019_11_01/_subscription_client.py b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/subscriptions/v2019_11_01/_subscription_client.py index 11f5a0120e31b..ea143a33a4cd3 100644 --- a/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/subscriptions/v2019_11_01/_subscription_client.py +++ b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/subscriptions/v2019_11_01/_subscription_client.py @@ -9,12 +9,11 @@ from copy import deepcopy from typing import Any, TYPE_CHECKING -from msrest import Deserializer, Serializer - from azure.core.rest import HttpRequest, HttpResponse from azure.mgmt.core import ARMPipelineClient from . import models +from .._serialization import Deserializer, Serializer from ._configuration import SubscriptionClientConfiguration from .operations import Operations, SubscriptionClientOperationsMixin, SubscriptionsOperations, TenantsOperations @@ -22,7 +21,8 @@ # pylint: disable=unused-import,ungrouped-imports from azure.core.credentials import TokenCredential -class SubscriptionClient(SubscriptionClientOperationsMixin): + +class SubscriptionClient(SubscriptionClientOperationsMixin): # pylint: disable=client-accepts-api-version-keyword """All resource groups and resources exist within subscriptions. These operation enable you get information about your subscriptions and tenants. A tenant is a dedicated instance of Azure Active Directory (Azure AD) for your organization. @@ -34,7 +34,7 @@ class SubscriptionClient(SubscriptionClientOperationsMixin): azure.mgmt.resource.subscriptions.v2019_11_01.operations.SubscriptionsOperations :ivar tenants: TenantsOperations operations :vartype tenants: azure.mgmt.resource.subscriptions.v2019_11_01.operations.TenantsOperations - :param credential: Credential needed for the client to connect to Azure. + :param credential: Credential needed for the client to connect to Azure. Required. :type credential: ~azure.core.credentials.TokenCredential :param base_url: Service URL. Default value is "https://management.azure.com". :type base_url: str @@ -44,10 +44,7 @@ class SubscriptionClient(SubscriptionClientOperationsMixin): """ def __init__( - self, - credential: "TokenCredential", - base_url: str = "https://management.azure.com", - **kwargs: Any + self, credential: "TokenCredential", base_url: str = "https://management.azure.com", **kwargs: Any ) -> None: self._config = SubscriptionClientConfiguration(credential=credential, **kwargs) self._client = ARMPipelineClient(base_url=base_url, config=self._config, **kwargs) @@ -60,12 +57,7 @@ def __init__( self.subscriptions = SubscriptionsOperations(self._client, self._config, self._serialize, self._deserialize) self.tenants = TenantsOperations(self._client, self._config, self._serialize, self._deserialize) - - def _send_request( - self, - request: HttpRequest, - **kwargs: Any - ) -> HttpResponse: + def _send_request(self, request: HttpRequest, **kwargs: Any) -> HttpResponse: """Runs the network request through the client's chained policies. >>> from azure.core.rest import HttpRequest @@ -74,7 +66,7 @@ def _send_request( >>> response = client._send_request(request) - For more information on this code flow, see https://aka.ms/azsdk/python/protocol/quickstart + For more information on this code flow, see https://aka.ms/azsdk/dpcodegen/python/send_request :param request: The network request you want to make. Required. :type request: ~azure.core.rest.HttpRequest diff --git a/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/subscriptions/v2019_11_01/_vendor.py b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/subscriptions/v2019_11_01/_vendor.py index 138f663c53a4e..71418db2686e7 100644 --- a/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/subscriptions/v2019_11_01/_vendor.py +++ b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/subscriptions/v2019_11_01/_vendor.py @@ -5,8 +5,20 @@ # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- +from abc import ABC +from typing import TYPE_CHECKING + from azure.core.pipeline.transport import HttpRequest +from ._configuration import SubscriptionClientConfiguration + +if TYPE_CHECKING: + # pylint: disable=unused-import,ungrouped-imports + from azure.core import PipelineClient + + from .._serialization import Deserializer, Serializer + + def _convert_request(request, files=None): data = request.content if not files else None request = HttpRequest(method=request.method, url=request.url, headers=request.headers, data=data) @@ -14,6 +26,7 @@ def _convert_request(request, files=None): request.set_formdata_body(files) return request + def _format_url_section(template, **kwargs): components = template.split("/") while components: @@ -21,7 +34,14 @@ def _format_url_section(template, **kwargs): 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 - ] + components = [c for c in formatted_components if "{}".format(key.args[0]) not in c] template = "/".join(components) + + +class MixinABC(ABC): + """DO NOT use this class. It is for internal typing use only.""" + + _client: "PipelineClient" + _config: SubscriptionClientConfiguration + _serialize: "Serializer" + _deserialize: "Deserializer" diff --git a/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/subscriptions/v2019_11_01/_version.py b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/subscriptions/v2019_11_01/_version.py index a012ac01c480c..e5754a47ce68f 100644 --- a/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/subscriptions/v2019_11_01/_version.py +++ b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/subscriptions/v2019_11_01/_version.py @@ -6,4 +6,4 @@ # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -VERSION = "21.1.0" +VERSION = "1.0.0b1" diff --git a/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/subscriptions/v2019_11_01/aio/__init__.py b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/subscriptions/v2019_11_01/aio/__init__.py index e95939087d442..5cfdafc74d6db 100644 --- a/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/subscriptions/v2019_11_01/aio/__init__.py +++ b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/subscriptions/v2019_11_01/aio/__init__.py @@ -7,9 +7,15 @@ # -------------------------------------------------------------------------- from ._subscription_client import SubscriptionClient -__all__ = ['SubscriptionClient'] -# `._patch.py` is used for handwritten extensions to the generated code -# Example: https://github.com/Azure/azure-sdk-for-python/blob/main/doc/dev/customize_code/how-to-patch-sdk-code.md -from ._patch import patch_sdk -patch_sdk() +try: + from ._patch import __all__ as _patch_all + from ._patch import * # type: ignore # pylint: disable=unused-wildcard-import +except ImportError: + _patch_all = [] +from ._patch import patch_sdk as _patch_sdk + +__all__ = ["SubscriptionClient"] +__all__.extend([p for p in _patch_all if p not in __all__]) + +_patch_sdk() diff --git a/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/subscriptions/v2019_11_01/aio/_configuration.py b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/subscriptions/v2019_11_01/aio/_configuration.py index 0f5c50995148c..fa6bcbe118c74 100644 --- a/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/subscriptions/v2019_11_01/aio/_configuration.py +++ b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/subscriptions/v2019_11_01/aio/_configuration.py @@ -25,42 +25,37 @@ class SubscriptionClientConfiguration(Configuration): # pylint: disable=too-man Note that all parameters used to create this instance are saved as instance attributes. - :param credential: Credential needed for the client to connect to Azure. + :param credential: Credential needed for the client to connect to Azure. Required. :type credential: ~azure.core.credentials_async.AsyncTokenCredential :keyword api_version: Api Version. Default value is "2019-11-01". Note that overriding this default value may result in unsupported behavior. :paramtype api_version: str """ - def __init__( - self, - credential: "AsyncTokenCredential", - **kwargs: Any - ) -> None: + def __init__(self, credential: "AsyncTokenCredential", **kwargs: Any) -> None: super(SubscriptionClientConfiguration, self).__init__(**kwargs) - api_version = kwargs.pop('api_version', "2019-11-01") # type: str + api_version = kwargs.pop("api_version", "2019-11-01") # type: str if credential is None: raise ValueError("Parameter 'credential' must not be None.") self.credential = credential self.api_version = api_version - self.credential_scopes = kwargs.pop('credential_scopes', ['https://management.azure.com/.default']) - kwargs.setdefault('sdk_moniker', 'mgmt-resource/{}'.format(VERSION)) + self.credential_scopes = kwargs.pop("credential_scopes", ["https://management.azure.com/.default"]) + kwargs.setdefault("sdk_moniker", "mgmt-resource/{}".format(VERSION)) self._configure(**kwargs) - 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) - self.logging_policy = kwargs.get('logging_policy') or policies.NetworkTraceLoggingPolicy(**kwargs) - self.http_logging_policy = kwargs.get('http_logging_policy') or ARMHttpLoggingPolicy(**kwargs) - self.retry_policy = kwargs.get('retry_policy') or policies.AsyncRetryPolicy(**kwargs) - self.custom_hook_policy = kwargs.get('custom_hook_policy') or policies.CustomHookPolicy(**kwargs) - self.redirect_policy = kwargs.get('redirect_policy') or policies.AsyncRedirectPolicy(**kwargs) - self.authentication_policy = kwargs.get('authentication_policy') + 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) + self.logging_policy = kwargs.get("logging_policy") or policies.NetworkTraceLoggingPolicy(**kwargs) + self.http_logging_policy = kwargs.get("http_logging_policy") or ARMHttpLoggingPolicy(**kwargs) + self.retry_policy = kwargs.get("retry_policy") or policies.AsyncRetryPolicy(**kwargs) + self.custom_hook_policy = kwargs.get("custom_hook_policy") or policies.CustomHookPolicy(**kwargs) + self.redirect_policy = kwargs.get("redirect_policy") or policies.AsyncRedirectPolicy(**kwargs) + self.authentication_policy = kwargs.get("authentication_policy") if self.credential and not self.authentication_policy: - self.authentication_policy = AsyncARMChallengeAuthenticationPolicy(self.credential, *self.credential_scopes, **kwargs) + self.authentication_policy = AsyncARMChallengeAuthenticationPolicy( + self.credential, *self.credential_scopes, **kwargs + ) diff --git a/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/subscriptions/v2019_11_01/aio/_patch.py b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/subscriptions/v2019_11_01/aio/_patch.py index 74e48ecd07cf3..f99e77fef9861 100644 --- a/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/subscriptions/v2019_11_01/aio/_patch.py +++ b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/subscriptions/v2019_11_01/aio/_patch.py @@ -28,4 +28,4 @@ # This file is used for handwritten extensions to the generated code. Example: # https://github.com/Azure/azure-sdk-for-python/blob/main/doc/dev/customize_code/how-to-patch-sdk-code.md def patch_sdk(): - pass \ No newline at end of file + pass diff --git a/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/subscriptions/v2019_11_01/aio/_subscription_client.py b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/subscriptions/v2019_11_01/aio/_subscription_client.py index 71c23eb4f5a50..7d98305efdab9 100644 --- a/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/subscriptions/v2019_11_01/aio/_subscription_client.py +++ b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/subscriptions/v2019_11_01/aio/_subscription_client.py @@ -9,12 +9,11 @@ from copy import deepcopy from typing import Any, Awaitable, TYPE_CHECKING -from msrest import Deserializer, Serializer - from azure.core.rest import AsyncHttpResponse, HttpRequest from azure.mgmt.core import AsyncARMPipelineClient from .. import models +from ..._serialization import Deserializer, Serializer from ._configuration import SubscriptionClientConfiguration from .operations import Operations, SubscriptionClientOperationsMixin, SubscriptionsOperations, TenantsOperations @@ -22,7 +21,8 @@ # pylint: disable=unused-import,ungrouped-imports from azure.core.credentials_async import AsyncTokenCredential -class SubscriptionClient(SubscriptionClientOperationsMixin): + +class SubscriptionClient(SubscriptionClientOperationsMixin): # pylint: disable=client-accepts-api-version-keyword """All resource groups and resources exist within subscriptions. These operation enable you get information about your subscriptions and tenants. A tenant is a dedicated instance of Azure Active Directory (Azure AD) for your organization. @@ -35,7 +35,7 @@ class SubscriptionClient(SubscriptionClientOperationsMixin): :ivar tenants: TenantsOperations operations :vartype tenants: azure.mgmt.resource.subscriptions.v2019_11_01.aio.operations.TenantsOperations - :param credential: Credential needed for the client to connect to Azure. + :param credential: Credential needed for the client to connect to Azure. Required. :type credential: ~azure.core.credentials_async.AsyncTokenCredential :param base_url: Service URL. Default value is "https://management.azure.com". :type base_url: str @@ -45,10 +45,7 @@ class SubscriptionClient(SubscriptionClientOperationsMixin): """ def __init__( - self, - credential: "AsyncTokenCredential", - base_url: str = "https://management.azure.com", - **kwargs: Any + self, credential: "AsyncTokenCredential", base_url: str = "https://management.azure.com", **kwargs: Any ) -> None: self._config = SubscriptionClientConfiguration(credential=credential, **kwargs) self._client = AsyncARMPipelineClient(base_url=base_url, config=self._config, **kwargs) @@ -61,12 +58,7 @@ def __init__( self.subscriptions = SubscriptionsOperations(self._client, self._config, self._serialize, self._deserialize) self.tenants = TenantsOperations(self._client, self._config, self._serialize, self._deserialize) - - def _send_request( - self, - request: HttpRequest, - **kwargs: Any - ) -> Awaitable[AsyncHttpResponse]: + def _send_request(self, request: HttpRequest, **kwargs: Any) -> Awaitable[AsyncHttpResponse]: """Runs the network request through the client's chained policies. >>> from azure.core.rest import HttpRequest @@ -75,7 +67,7 @@ def _send_request( >>> response = await client._send_request(request) - For more information on this code flow, see https://aka.ms/azsdk/python/protocol/quickstart + For more information on this code flow, see https://aka.ms/azsdk/dpcodegen/python/send_request :param request: The network request you want to make. Required. :type request: ~azure.core.rest.HttpRequest diff --git a/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/subscriptions/v2019_11_01/aio/_vendor.py b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/subscriptions/v2019_11_01/aio/_vendor.py new file mode 100644 index 0000000000000..3c42eb44b5a3e --- /dev/null +++ b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/subscriptions/v2019_11_01/aio/_vendor.py @@ -0,0 +1,28 @@ +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- + +from abc import ABC +from typing import TYPE_CHECKING + +from azure.core.pipeline.transport import HttpRequest + +from ._configuration import SubscriptionClientConfiguration + +if TYPE_CHECKING: + # pylint: disable=unused-import,ungrouped-imports + from azure.core import AsyncPipelineClient + + from ..._serialization import Deserializer, Serializer + + +class MixinABC(ABC): + """DO NOT use this class. It is for internal typing use only.""" + + _client: "AsyncPipelineClient" + _config: SubscriptionClientConfiguration + _serialize: "Serializer" + _deserialize: "Deserializer" diff --git a/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/subscriptions/v2019_11_01/aio/operations/__init__.py b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/subscriptions/v2019_11_01/aio/operations/__init__.py index 437b49e23548f..1066cb67ea911 100644 --- a/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/subscriptions/v2019_11_01/aio/operations/__init__.py +++ b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/subscriptions/v2019_11_01/aio/operations/__init__.py @@ -11,9 +11,15 @@ from ._operations import TenantsOperations from ._operations import SubscriptionClientOperationsMixin +from ._patch import __all__ as _patch_all +from ._patch import * # type: ignore # pylint: disable=unused-wildcard-import +from ._patch import patch_sdk as _patch_sdk + __all__ = [ - 'Operations', - 'SubscriptionsOperations', - 'TenantsOperations', - 'SubscriptionClientOperationsMixin', + "Operations", + "SubscriptionsOperations", + "TenantsOperations", + "SubscriptionClientOperationsMixin", ] +__all__.extend([p for p in _patch_all if p not in __all__]) +_patch_sdk() diff --git a/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/subscriptions/v2019_11_01/aio/operations/_operations.py b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/subscriptions/v2019_11_01/aio/operations/_operations.py index 37a8ac05ec78c..3e062155546c5 100644 --- a/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/subscriptions/v2019_11_01/aio/operations/_operations.py +++ b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/subscriptions/v2019_11_01/aio/operations/_operations.py @@ -6,82 +6,106 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -from typing import Any, AsyncIterable, Callable, Dict, Optional, TypeVar +from typing import Any, AsyncIterable, Callable, Dict, IO, Optional, TypeVar, Union, overload +from urllib.parse import parse_qs, urljoin, urlparse from azure.core.async_paging import AsyncItemPaged, AsyncList -from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error +from azure.core.exceptions import ( + ClientAuthenticationError, + HttpResponseError, + ResourceExistsError, + ResourceNotFoundError, + ResourceNotModifiedError, + map_error, +) from azure.core.pipeline import PipelineResponse from azure.core.pipeline.transport import AsyncHttpResponse from azure.core.rest import HttpRequest from azure.core.tracing.decorator import distributed_trace from azure.core.tracing.decorator_async import distributed_trace_async +from azure.core.utils import case_insensitive_dict from azure.mgmt.core.exceptions import ARMErrorFormat from ... import models as _models from ..._vendor import _convert_request -from ...operations._operations import build_check_resource_name_request, build_operations_list_request, build_subscriptions_check_zone_peers_request, build_subscriptions_get_request, build_subscriptions_list_locations_request, build_subscriptions_list_request, build_tenants_list_request -T = TypeVar('T') +from ...operations._operations import ( + build_check_resource_name_request, + build_operations_list_request, + build_subscriptions_check_zone_peers_request, + build_subscriptions_get_request, + build_subscriptions_list_locations_request, + build_subscriptions_list_request, + build_tenants_list_request, +) +from .._vendor import MixinABC + +T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] -class Operations: - """Operations async operations. - You should not instantiate this class directly. Instead, you should create a Client instance that - instantiates it for you and attaches it as an attribute. +class Operations: + """ + .. warning:: + **DO NOT** instantiate this class directly. - :ivar models: Alias to model classes used in this operation group. - :type models: ~azure.mgmt.resource.subscriptions.v2019_11_01.models - :param client: Client for service requests. - :param config: Configuration of service client. - :param serializer: An object model serializer. - :param deserializer: An object model deserializer. + Instead, you should access the following operations through + :class:`~azure.mgmt.resource.subscriptions.v2019_11_01.aio.SubscriptionClient`'s + :attr:`operations` attribute. """ models = _models - def __init__(self, client, config, serializer, deserializer) -> None: - self._client = client - self._serialize = serializer - self._deserialize = deserializer - self._config = config + def __init__(self, *args, **kwargs) -> None: + input_args = list(args) + self._client = input_args.pop(0) if input_args else kwargs.pop("client") + self._config = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") @distributed_trace - def list( - self, - **kwargs: Any - ) -> AsyncIterable["_models.OperationListResult"]: + def list(self, **kwargs: Any) -> AsyncIterable["_models.Operation"]: """Lists all of the available Microsoft.Resources REST API operations. :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either OperationListResult or the result of cls(response) + :return: An iterator like instance of either Operation or the result of cls(response) :rtype: - ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.resource.subscriptions.v2019_11_01.models.OperationListResult] - :raises: ~azure.core.exceptions.HttpResponseError + ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.resource.subscriptions.v2019_11_01.models.Operation] + :raises ~azure.core.exceptions.HttpResponseError: """ - api_version = kwargs.pop('api_version', "2019-11-01") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2019-11-01")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[_models.OperationListResult] - cls = kwargs.pop('cls', None) # type: ClsType["_models.OperationListResult"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) + def prepare_request(next_link=None): if not next_link: - + request = build_operations_list_request( api_version=api_version, - template_url=self.list.metadata['url'], + template_url=self.list.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore else: - - request = build_operations_list_request( - template_url=next_link, - ) + # make call to next link with the client's api-version + _parsed_next_link = urlparse(next_link) + _next_request_params = case_insensitive_dict(parse_qs(_parsed_next_link.query)) + _next_request_params["api-version"] = self._config.api_version + request = HttpRequest("GET", urljoin(next_link, _parsed_next_link.path), params=_next_request_params) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore request.method = "GET" return request @@ -95,10 +119,8 @@ async def extract_data(pipeline_response): async def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) response = pipeline_response.http_response @@ -108,78 +130,80 @@ async def get_next(next_link=None): return pipeline_response + return AsyncItemPaged(get_next, extract_data) + + list.metadata = {"url": "/providers/Microsoft.Resources/operations"} # type: ignore - return AsyncItemPaged( - get_next, extract_data - ) - list.metadata = {'url': "/providers/Microsoft.Resources/operations"} # type: ignore -class SubscriptionsOperations: - """SubscriptionsOperations async operations. - You should not instantiate this class directly. Instead, you should create a Client instance that - instantiates it for you and attaches it as an attribute. +class SubscriptionsOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. - :ivar models: Alias to model classes used in this operation group. - :type models: ~azure.mgmt.resource.subscriptions.v2019_11_01.models - :param client: Client for service requests. - :param config: Configuration of service client. - :param serializer: An object model serializer. - :param deserializer: An object model deserializer. + Instead, you should access the following operations through + :class:`~azure.mgmt.resource.subscriptions.v2019_11_01.aio.SubscriptionClient`'s + :attr:`subscriptions` attribute. """ models = _models - def __init__(self, client, config, serializer, deserializer) -> None: - self._client = client - self._serialize = serializer - self._deserialize = deserializer - self._config = config + def __init__(self, *args, **kwargs) -> None: + input_args = list(args) + self._client = input_args.pop(0) if input_args else kwargs.pop("client") + self._config = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") @distributed_trace - def list_locations( - self, - subscription_id: str, - **kwargs: Any - ) -> AsyncIterable["_models.LocationListResult"]: + def list_locations(self, subscription_id: str, **kwargs: Any) -> AsyncIterable["_models.Location"]: """Gets all available geo-locations. This operation provides all the locations that are available for resource providers; however, each resource provider may support a subset of this list. - :param subscription_id: The ID of the target subscription. + :param subscription_id: The ID of the target subscription. Required. :type subscription_id: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either LocationListResult or the result of cls(response) + :return: An iterator like instance of either Location or the result of cls(response) :rtype: - ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.resource.subscriptions.v2019_11_01.models.LocationListResult] - :raises: ~azure.core.exceptions.HttpResponseError + ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.resource.subscriptions.v2019_11_01.models.Location] + :raises ~azure.core.exceptions.HttpResponseError: """ - api_version = kwargs.pop('api_version', "2019-11-01") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2019-11-01")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[_models.LocationListResult] - cls = kwargs.pop('cls', None) # type: ClsType["_models.LocationListResult"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) + def prepare_request(next_link=None): if not next_link: - + request = build_subscriptions_list_locations_request( subscription_id=subscription_id, api_version=api_version, - template_url=self.list_locations.metadata['url'], + template_url=self.list_locations.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore else: - - request = build_subscriptions_list_locations_request( - subscription_id=subscription_id, - template_url=next_link, - ) + # make call to next link with the client's api-version + _parsed_next_link = urlparse(next_link) + _next_request_params = case_insensitive_dict(parse_qs(_parsed_next_link.query)) + _next_request_params["api-version"] = self._config.api_version + request = HttpRequest("GET", urljoin(next_link, _parsed_next_link.path), params=_next_request_params) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore request.method = "GET" return request @@ -193,10 +217,8 @@ async def extract_data(pipeline_response): async def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) response = pipeline_response.http_response @@ -206,103 +228,108 @@ async def get_next(next_link=None): return pipeline_response + return AsyncItemPaged(get_next, extract_data) - return AsyncItemPaged( - get_next, extract_data - ) - list_locations.metadata = {'url': "/subscriptions/{subscriptionId}/locations"} # type: ignore + list_locations.metadata = {"url": "/subscriptions/{subscriptionId}/locations"} # type: ignore @distributed_trace_async - async def get( - self, - subscription_id: str, - **kwargs: Any - ) -> "_models.Subscription": + async def get(self, subscription_id: str, **kwargs: Any) -> _models.Subscription: """Gets details about a specified subscription. - :param subscription_id: The ID of the target subscription. + :param subscription_id: The ID of the target subscription. Required. :type subscription_id: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: Subscription, or the result of cls(response) + :return: Subscription or the result of cls(response) :rtype: ~azure.mgmt.resource.subscriptions.v2019_11_01.models.Subscription - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.Subscription"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) - api_version = kwargs.pop('api_version', "2019-11-01") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2019-11-01")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[_models.Subscription] - request = build_subscriptions_get_request( subscription_id=subscription_id, api_version=api_version, - template_url=self.get.metadata['url'], + template_url=self.get.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) - deserialized = self._deserialize('Subscription', pipeline_response) + deserialized = self._deserialize("Subscription", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - get.metadata = {'url': "/subscriptions/{subscriptionId}"} # type: ignore - + get.metadata = {"url": "/subscriptions/{subscriptionId}"} # type: ignore @distributed_trace - def list( - self, - **kwargs: Any - ) -> AsyncIterable["_models.SubscriptionListResult"]: + def list(self, **kwargs: Any) -> AsyncIterable["_models.Subscription"]: """Gets all subscriptions for a tenant. :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either SubscriptionListResult or the result of - cls(response) + :return: An iterator like instance of either Subscription or the result of cls(response) :rtype: - ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.resource.subscriptions.v2019_11_01.models.SubscriptionListResult] - :raises: ~azure.core.exceptions.HttpResponseError + ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.resource.subscriptions.v2019_11_01.models.Subscription] + :raises ~azure.core.exceptions.HttpResponseError: """ - api_version = kwargs.pop('api_version', "2019-11-01") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2019-11-01")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[_models.SubscriptionListResult] - cls = kwargs.pop('cls', None) # type: ClsType["_models.SubscriptionListResult"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) + def prepare_request(next_link=None): if not next_link: - + request = build_subscriptions_list_request( api_version=api_version, - template_url=self.list.metadata['url'], + template_url=self.list.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore else: - - request = build_subscriptions_list_request( - template_url=next_link, - ) + # make call to next link with the client's api-version + _parsed_next_link = urlparse(next_link) + _next_request_params = case_insensitive_dict(parse_qs(_parsed_next_link.query)) + _next_request_params["api-version"] = self._config.api_version + request = HttpRequest("GET", urljoin(next_link, _parsed_next_link.path), params=_next_request_params) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore request.method = "GET" return request @@ -316,10 +343,8 @@ async def extract_data(pipeline_response): async def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) response = pipeline_response.http_response @@ -329,56 +354,113 @@ async def get_next(next_link=None): return pipeline_response + return AsyncItemPaged(get_next, extract_data) - return AsyncItemPaged( - get_next, extract_data - ) - list.metadata = {'url': "/subscriptions"} # type: ignore + list.metadata = {"url": "/subscriptions"} # type: ignore - @distributed_trace_async + @overload async def check_zone_peers( self, subscription_id: str, - parameters: "_models.CheckZonePeersRequest", + parameters: _models.CheckZonePeersRequest, + *, + content_type: str = "application/json", **kwargs: Any - ) -> "_models.CheckZonePeersResult": + ) -> _models.CheckZonePeersResult: """Compares a subscriptions logical zone mapping. - :param subscription_id: The ID of the target subscription. + :param subscription_id: The ID of the target subscription. Required. :type subscription_id: str - :param parameters: Parameters for checking zone peers. + :param parameters: Parameters for checking zone peers. Required. :type parameters: ~azure.mgmt.resource.subscriptions.v2019_11_01.models.CheckZonePeersRequest + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: CheckZonePeersResult, or the result of cls(response) + :return: CheckZonePeersResult or the result of cls(response) :rtype: ~azure.mgmt.resource.subscriptions.v2019_11_01.models.CheckZonePeersResult - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + async def check_zone_peers( + self, subscription_id: str, parameters: IO, *, content_type: str = "application/json", **kwargs: Any + ) -> _models.CheckZonePeersResult: + """Compares a subscriptions logical zone mapping. + + :param subscription_id: The ID of the target subscription. Required. + :type subscription_id: str + :param parameters: Parameters for checking zone peers. Required. + :type parameters: IO + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: CheckZonePeersResult or the result of cls(response) + :rtype: ~azure.mgmt.resource.subscriptions.v2019_11_01.models.CheckZonePeersResult + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace_async + async def check_zone_peers( + self, subscription_id: str, parameters: Union[_models.CheckZonePeersRequest, IO], **kwargs: Any + ) -> _models.CheckZonePeersResult: + """Compares a subscriptions logical zone mapping. + + :param subscription_id: The ID of the target subscription. Required. + :type subscription_id: str + :param parameters: Parameters for checking zone peers. Is either a model type or a IO type. + Required. + :type parameters: ~azure.mgmt.resource.subscriptions.v2019_11_01.models.CheckZonePeersRequest + or IO + :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. + Default value is None. + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: CheckZonePeersResult or the result of cls(response) + :rtype: ~azure.mgmt.resource.subscriptions.v2019_11_01.models.CheckZonePeersResult + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.CheckZonePeersResult"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) - api_version = kwargs.pop('api_version', "2019-11-01") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - _json = self._serialize.body(parameters, 'CheckZonePeersRequest') + api_version = kwargs.pop("api_version", _params.pop("api-version", "2019-11-01")) # type: str + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.CheckZonePeersResult] + + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(parameters, (IO, bytes)): + _content = parameters + else: + _json = self._serialize.body(parameters, "CheckZonePeersRequest") request = build_subscriptions_check_zone_peers_request( subscription_id=subscription_id, api_version=api_version, content_type=content_type, json=_json, - template_url=self.check_zone_peers.metadata['url'], + content=_content, + template_url=self.check_zone_peers.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200]: @@ -386,74 +468,79 @@ async def check_zone_peers( error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - deserialized = self._deserialize('CheckZonePeersResult', pipeline_response) + deserialized = self._deserialize("CheckZonePeersResult", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - check_zone_peers.metadata = {'url': "/subscriptions/{subscriptionId}/providers/Microsoft.Resources/checkZonePeers/"} # type: ignore + check_zone_peers.metadata = {"url": "/subscriptions/{subscriptionId}/providers/Microsoft.Resources/checkZonePeers/"} # type: ignore -class TenantsOperations: - """TenantsOperations async operations. - You should not instantiate this class directly. Instead, you should create a Client instance that - instantiates it for you and attaches it as an attribute. +class TenantsOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. - :ivar models: Alias to model classes used in this operation group. - :type models: ~azure.mgmt.resource.subscriptions.v2019_11_01.models - :param client: Client for service requests. - :param config: Configuration of service client. - :param serializer: An object model serializer. - :param deserializer: An object model deserializer. + Instead, you should access the following operations through + :class:`~azure.mgmt.resource.subscriptions.v2019_11_01.aio.SubscriptionClient`'s + :attr:`tenants` attribute. """ models = _models - def __init__(self, client, config, serializer, deserializer) -> None: - self._client = client - self._serialize = serializer - self._deserialize = deserializer - self._config = config + def __init__(self, *args, **kwargs) -> None: + input_args = list(args) + self._client = input_args.pop(0) if input_args else kwargs.pop("client") + self._config = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") @distributed_trace - def list( - self, - **kwargs: Any - ) -> AsyncIterable["_models.TenantListResult"]: + def list(self, **kwargs: Any) -> AsyncIterable["_models.TenantIdDescription"]: """Gets the tenants for your account. :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either TenantListResult or the result of cls(response) + :return: An iterator like instance of either TenantIdDescription or the result of cls(response) :rtype: - ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.resource.subscriptions.v2019_11_01.models.TenantListResult] - :raises: ~azure.core.exceptions.HttpResponseError + ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.resource.subscriptions.v2019_11_01.models.TenantIdDescription] + :raises ~azure.core.exceptions.HttpResponseError: """ - api_version = kwargs.pop('api_version', "2019-11-01") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2019-11-01")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[_models.TenantListResult] - cls = kwargs.pop('cls', None) # type: ClsType["_models.TenantListResult"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) + def prepare_request(next_link=None): if not next_link: - + request = build_tenants_list_request( api_version=api_version, - template_url=self.list.metadata['url'], + template_url=self.list.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore else: - - request = build_tenants_list_request( - template_url=next_link, - ) + # make call to next link with the client's api-version + _parsed_next_link = urlparse(next_link) + _next_request_params = case_insensitive_dict(parse_qs(_parsed_next_link.query)) + _next_request_params["api-version"] = self._config.api_version + request = HttpRequest("GET", urljoin(next_link, _parsed_next_link.path), params=_next_request_params) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore request.method = "GET" return request @@ -467,10 +554,8 @@ async def extract_data(pipeline_response): async def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) response = pipeline_response.http_response @@ -480,19 +565,20 @@ async def get_next(next_link=None): return pipeline_response + return AsyncItemPaged(get_next, extract_data) - return AsyncItemPaged( - get_next, extract_data - ) - list.metadata = {'url': "/tenants"} # type: ignore -class SubscriptionClientOperationsMixin: + list.metadata = {"url": "/tenants"} # type: ignore - @distributed_trace_async + +class SubscriptionClientOperationsMixin(MixinABC): + @overload async def check_resource_name( self, - resource_name_definition: Optional["_models.ResourceName"] = None, + resource_name_definition: Optional[_models.ResourceName] = None, + *, + content_type: str = "application/json", **kwargs: Any - ) -> "_models.CheckResourceNameResult": + ) -> _models.CheckResourceNameResult: """Checks resource name validity. A resource name is valid if it is not a reserved word, does not contains a reserved word and @@ -502,39 +588,99 @@ async def check_resource_name( type. Default value is None. :type resource_name_definition: ~azure.mgmt.resource.subscriptions.v2019_11_01.models.ResourceName + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: CheckResourceNameResult, or the result of cls(response) + :return: CheckResourceNameResult or the result of cls(response) :rtype: ~azure.mgmt.resource.subscriptions.v2019_11_01.models.CheckResourceNameResult - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + async def check_resource_name( + self, resource_name_definition: Optional[IO] = None, *, content_type: str = "application/json", **kwargs: Any + ) -> _models.CheckResourceNameResult: + """Checks resource name validity. + + A resource name is valid if it is not a reserved word, does not contains a reserved word and + does not start with a reserved word. + + :param resource_name_definition: Resource object with values for resource name and resource + type. Default value is None. + :type resource_name_definition: IO + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: CheckResourceNameResult or the result of cls(response) + :rtype: ~azure.mgmt.resource.subscriptions.v2019_11_01.models.CheckResourceNameResult + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace_async + async def check_resource_name( + self, resource_name_definition: Optional[Union[_models.ResourceName, IO]] = None, **kwargs: Any + ) -> _models.CheckResourceNameResult: + """Checks resource name validity. + + A resource name is valid if it is not a reserved word, does not contains a reserved word and + does not start with a reserved word. + + :param resource_name_definition: Resource object with values for resource name and resource + type. Is either a model type or a IO type. Default value is None. + :type resource_name_definition: + ~azure.mgmt.resource.subscriptions.v2019_11_01.models.ResourceName or IO + :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. + Default value is None. + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: CheckResourceNameResult or the result of cls(response) + :rtype: ~azure.mgmt.resource.subscriptions.v2019_11_01.models.CheckResourceNameResult + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.CheckResourceNameResult"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', "2019-11-01") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + api_version = kwargs.pop("api_version", _params.pop("api-version", "2019-11-01")) # type: str + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.CheckResourceNameResult] - if resource_name_definition is not None: - _json = self._serialize.body(resource_name_definition, 'ResourceName') + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(resource_name_definition, (IO, bytes)): + _content = resource_name_definition else: - _json = None + if resource_name_definition is not None: + _json = self._serialize.body(resource_name_definition, "ResourceName") + else: + _json = None request = build_check_resource_name_request( api_version=api_version, content_type=content_type, json=_json, - template_url=self.check_resource_name.metadata['url'], + content=_content, + template_url=self.check_resource_name.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200]: @@ -542,12 +688,11 @@ async def check_resource_name( error = self._deserialize.failsafe_deserialize(_models.ErrorResponseAutoGenerated, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - deserialized = self._deserialize('CheckResourceNameResult', pipeline_response) + deserialized = self._deserialize("CheckResourceNameResult", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - check_resource_name.metadata = {'url': "/providers/Microsoft.Resources/checkResourceName"} # type: ignore - + check_resource_name.metadata = {"url": "/providers/Microsoft.Resources/checkResourceName"} # type: ignore diff --git a/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/subscriptions/v2019_11_01/aio/operations/_patch.py b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/subscriptions/v2019_11_01/aio/operations/_patch.py new file mode 100644 index 0000000000000..f7dd32510333d --- /dev/null +++ b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/subscriptions/v2019_11_01/aio/operations/_patch.py @@ -0,0 +1,20 @@ +# ------------------------------------ +# Copyright (c) Microsoft Corporation. +# Licensed under the MIT License. +# ------------------------------------ +"""Customize generated code here. + +Follow our quickstart for examples: https://aka.ms/azsdk/python/dpcodegen/python/customize +""" +from typing import List + +__all__: List[str] = [] # Add all objects you want publicly available to users at this package level + + +def patch_sdk(): + """Do not remove from this file. + + `patch_sdk` is a last resort escape hatch that allows you to do customizations + you can't accomplish using the techniques described in + https://aka.ms/azsdk/python/dpcodegen/python/customize + """ diff --git a/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/subscriptions/v2019_11_01/models/__init__.py b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/subscriptions/v2019_11_01/models/__init__.py index e8b83ae6bb53f..8285337325230 100644 --- a/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/subscriptions/v2019_11_01/models/__init__.py +++ b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/subscriptions/v2019_11_01/models/__init__.py @@ -31,45 +31,47 @@ from ._models_py3 import TenantIdDescription from ._models_py3 import TenantListResult - -from ._subscription_client_enums import ( - RegionCategory, - RegionType, - ResourceNameStatus, - SpendingLimit, - SubscriptionState, - TenantCategory, -) +from ._subscription_client_enums import RegionCategory +from ._subscription_client_enums import RegionType +from ._subscription_client_enums import ResourceNameStatus +from ._subscription_client_enums import SpendingLimit +from ._subscription_client_enums import SubscriptionState +from ._subscription_client_enums import TenantCategory +from ._patch import __all__ as _patch_all +from ._patch import * # type: ignore # pylint: disable=unused-wildcard-import +from ._patch import patch_sdk as _patch_sdk __all__ = [ - 'AvailabilityZonePeers', - 'CheckResourceNameResult', - 'CheckZonePeersRequest', - 'CheckZonePeersResult', - 'ErrorAdditionalInfo', - 'ErrorDefinition', - 'ErrorDetail', - 'ErrorResponse', - 'ErrorResponseAutoGenerated', - 'Location', - 'LocationListResult', - 'LocationMetadata', - 'ManagedByTenant', - 'Operation', - 'OperationDisplay', - 'OperationListResult', - 'PairedRegion', - 'Peers', - 'ResourceName', - 'Subscription', - 'SubscriptionListResult', - 'SubscriptionPolicies', - 'TenantIdDescription', - 'TenantListResult', - 'RegionCategory', - 'RegionType', - 'ResourceNameStatus', - 'SpendingLimit', - 'SubscriptionState', - 'TenantCategory', + "AvailabilityZonePeers", + "CheckResourceNameResult", + "CheckZonePeersRequest", + "CheckZonePeersResult", + "ErrorAdditionalInfo", + "ErrorDefinition", + "ErrorDetail", + "ErrorResponse", + "ErrorResponseAutoGenerated", + "Location", + "LocationListResult", + "LocationMetadata", + "ManagedByTenant", + "Operation", + "OperationDisplay", + "OperationListResult", + "PairedRegion", + "Peers", + "ResourceName", + "Subscription", + "SubscriptionListResult", + "SubscriptionPolicies", + "TenantIdDescription", + "TenantListResult", + "RegionCategory", + "RegionType", + "ResourceNameStatus", + "SpendingLimit", + "SubscriptionState", + "TenantCategory", ] +__all__.extend([p for p in _patch_all if p not in __all__]) +_patch_sdk() diff --git a/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/subscriptions/v2019_11_01/models/_models_py3.py b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/subscriptions/v2019_11_01/models/_models_py3.py index 9682bdb98cfb2..867ad4850f249 100644 --- a/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/subscriptions/v2019_11_01/models/_models_py3.py +++ b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/subscriptions/v2019_11_01/models/_models_py3.py @@ -1,4 +1,5 @@ # coding=utf-8 +# pylint: disable=too-many-lines # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. # Licensed under the MIT License. See License.txt in the project root for license information. @@ -6,15 +7,16 @@ # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -from typing import Dict, List, Optional, Union +from typing import Dict, List, Optional, TYPE_CHECKING, Union -from azure.core.exceptions import HttpResponseError -import msrest.serialization +from ... import _serialization -from ._subscription_client_enums import * +if TYPE_CHECKING: + # pylint: disable=unused-import,ungrouped-imports + from .. import models as _models -class AvailabilityZonePeers(msrest.serialization.Model): +class AvailabilityZonePeers(_serialization.Model): """List of availability zones shared by the subscriptions. Variables are only populated by the server, and will be ignored when sending a request. @@ -26,46 +28,41 @@ class AvailabilityZonePeers(msrest.serialization.Model): """ _validation = { - 'availability_zone': {'readonly': True}, + "availability_zone": {"readonly": True}, } _attribute_map = { - 'availability_zone': {'key': 'availabilityZone', 'type': 'str'}, - 'peers': {'key': 'peers', 'type': '[Peers]'}, + "availability_zone": {"key": "availabilityZone", "type": "str"}, + "peers": {"key": "peers", "type": "[Peers]"}, } - def __init__( - self, - *, - peers: Optional[List["Peers"]] = None, - **kwargs - ): + def __init__(self, *, peers: Optional[List["_models.Peers"]] = None, **kwargs): """ :keyword peers: Details of shared availability zone. :paramtype peers: list[~azure.mgmt.resource.subscriptions.v2019_11_01.models.Peers] """ - super(AvailabilityZonePeers, self).__init__(**kwargs) + super().__init__(**kwargs) self.availability_zone = None self.peers = peers -class CheckResourceNameResult(msrest.serialization.Model): +class CheckResourceNameResult(_serialization.Model): """Resource Name valid if not a reserved word, does not contain a reserved word and does not start with a reserved word. :ivar name: Name of Resource. :vartype name: str :ivar type: Type of Resource. :vartype type: str - :ivar status: Is the resource name Allowed or Reserved. Possible values include: "Allowed", + :ivar status: Is the resource name Allowed or Reserved. Known values are: "Allowed" and "Reserved". :vartype status: str or ~azure.mgmt.resource.subscriptions.v2019_11_01.models.ResourceNameStatus """ _attribute_map = { - 'name': {'key': 'name', 'type': 'str'}, - 'type': {'key': 'type', 'type': 'str'}, - 'status': {'key': 'status', 'type': 'str'}, + "name": {"key": "name", "type": "str"}, + "type": {"key": "type", "type": "str"}, + "status": {"key": "status", "type": "str"}, } def __init__( @@ -73,7 +70,7 @@ def __init__( *, name: Optional[str] = None, type: Optional[str] = None, - status: Optional[Union[str, "ResourceNameStatus"]] = None, + status: Optional[Union[str, "_models.ResourceNameStatus"]] = None, **kwargs ): """ @@ -81,18 +78,18 @@ def __init__( :paramtype name: str :keyword type: Type of Resource. :paramtype type: str - :keyword status: Is the resource name Allowed or Reserved. Possible values include: "Allowed", + :keyword status: Is the resource name Allowed or Reserved. Known values are: "Allowed" and "Reserved". :paramtype status: str or ~azure.mgmt.resource.subscriptions.v2019_11_01.models.ResourceNameStatus """ - super(CheckResourceNameResult, self).__init__(**kwargs) + super().__init__(**kwargs) self.name = name self.type = type self.status = status -class CheckZonePeersRequest(msrest.serialization.Model): +class CheckZonePeersRequest(_serialization.Model): """Check zone peers request parameters. :ivar location: The Microsoft location. @@ -102,29 +99,23 @@ class CheckZonePeersRequest(msrest.serialization.Model): """ _attribute_map = { - 'location': {'key': 'location', 'type': 'str'}, - 'subscription_ids': {'key': 'subscriptionIds', 'type': '[str]'}, + "location": {"key": "location", "type": "str"}, + "subscription_ids": {"key": "subscriptionIds", "type": "[str]"}, } - def __init__( - self, - *, - location: Optional[str] = None, - subscription_ids: Optional[List[str]] = None, - **kwargs - ): + def __init__(self, *, location: Optional[str] = None, subscription_ids: Optional[List[str]] = None, **kwargs): """ :keyword location: The Microsoft location. :paramtype location: str :keyword subscription_ids: The peer Microsoft Azure subscription ID. :paramtype subscription_ids: list[str] """ - super(CheckZonePeersRequest, self).__init__(**kwargs) + super().__init__(**kwargs) self.location = location self.subscription_ids = subscription_ids -class CheckZonePeersResult(msrest.serialization.Model): +class CheckZonePeersResult(_serialization.Model): """Result of the Check zone peers operation. Variables are only populated by the server, and will be ignored when sending a request. @@ -139,20 +130,20 @@ class CheckZonePeersResult(msrest.serialization.Model): """ _validation = { - 'subscription_id': {'readonly': True}, + "subscription_id": {"readonly": True}, } _attribute_map = { - 'subscription_id': {'key': 'subscriptionId', 'type': 'str'}, - 'location': {'key': 'location', 'type': 'str'}, - 'availability_zone_peers': {'key': 'availabilityZonePeers', 'type': '[AvailabilityZonePeers]'}, + "subscription_id": {"key": "subscriptionId", "type": "str"}, + "location": {"key": "location", "type": "str"}, + "availability_zone_peers": {"key": "availabilityZonePeers", "type": "[AvailabilityZonePeers]"}, } def __init__( self, *, location: Optional[str] = None, - availability_zone_peers: Optional[List["AvailabilityZonePeers"]] = None, + availability_zone_peers: Optional[List["_models.AvailabilityZonePeers"]] = None, **kwargs ): """ @@ -162,13 +153,13 @@ def __init__( :paramtype availability_zone_peers: list[~azure.mgmt.resource.subscriptions.v2019_11_01.models.AvailabilityZonePeers] """ - super(CheckZonePeersResult, self).__init__(**kwargs) + super().__init__(**kwargs) self.subscription_id = None self.location = location self.availability_zone_peers = availability_zone_peers -class ErrorAdditionalInfo(msrest.serialization.Model): +class ErrorAdditionalInfo(_serialization.Model): """The resource management error additional info. Variables are only populated by the server, and will be ignored when sending a request. @@ -176,31 +167,27 @@ class ErrorAdditionalInfo(msrest.serialization.Model): :ivar type: The additional info type. :vartype type: str :ivar info: The additional info. - :vartype info: any + :vartype info: JSON """ _validation = { - 'type': {'readonly': True}, - 'info': {'readonly': True}, + "type": {"readonly": True}, + "info": {"readonly": True}, } _attribute_map = { - 'type': {'key': 'type', 'type': 'str'}, - 'info': {'key': 'info', 'type': 'object'}, + "type": {"key": "type", "type": "str"}, + "info": {"key": "info", "type": "object"}, } - def __init__( - self, - **kwargs - ): - """ - """ - super(ErrorAdditionalInfo, self).__init__(**kwargs) + def __init__(self, **kwargs): + """ """ + super().__init__(**kwargs) self.type = None self.info = None -class ErrorDefinition(msrest.serialization.Model): +class ErrorDefinition(_serialization.Model): """Error description and code explaining why resource name is invalid. :ivar message: Description of the error. @@ -210,29 +197,23 @@ class ErrorDefinition(msrest.serialization.Model): """ _attribute_map = { - 'message': {'key': 'message', 'type': 'str'}, - 'code': {'key': 'code', 'type': 'str'}, + "message": {"key": "message", "type": "str"}, + "code": {"key": "code", "type": "str"}, } - def __init__( - self, - *, - message: Optional[str] = None, - code: Optional[str] = None, - **kwargs - ): + def __init__(self, *, message: Optional[str] = None, code: Optional[str] = None, **kwargs): """ :keyword message: Description of the error. :paramtype message: str :keyword code: Code of the error. :paramtype code: str """ - super(ErrorDefinition, self).__init__(**kwargs) + super().__init__(**kwargs) self.message = message self.code = code -class ErrorDetail(msrest.serialization.Model): +class ErrorDetail(_serialization.Model): """The error detail. Variables are only populated by the server, and will be ignored when sending a request. @@ -251,28 +232,24 @@ class ErrorDetail(msrest.serialization.Model): """ _validation = { - 'code': {'readonly': True}, - 'message': {'readonly': True}, - 'target': {'readonly': True}, - 'details': {'readonly': True}, - 'additional_info': {'readonly': True}, + "code": {"readonly": True}, + "message": {"readonly": True}, + "target": {"readonly": True}, + "details": {"readonly": True}, + "additional_info": {"readonly": True}, } _attribute_map = { - 'code': {'key': 'code', 'type': 'str'}, - 'message': {'key': 'message', 'type': 'str'}, - 'target': {'key': 'target', 'type': 'str'}, - 'details': {'key': 'details', 'type': '[ErrorDetail]'}, - 'additional_info': {'key': 'additionalInfo', 'type': '[ErrorAdditionalInfo]'}, + "code": {"key": "code", "type": "str"}, + "message": {"key": "message", "type": "str"}, + "target": {"key": "target", "type": "str"}, + "details": {"key": "details", "type": "[ErrorDetail]"}, + "additional_info": {"key": "additionalInfo", "type": "[ErrorAdditionalInfo]"}, } - def __init__( - self, - **kwargs - ): - """ - """ - super(ErrorDetail, self).__init__(**kwargs) + def __init__(self, **kwargs): + """ """ + super().__init__(**kwargs) self.code = None self.message = None self.target = None @@ -280,7 +257,7 @@ def __init__( self.additional_info = None -class ErrorResponse(msrest.serialization.Model): +class ErrorResponse(_serialization.Model): """Common error response for all Azure Resource Manager APIs to return error details for failed operations. (This also follows the OData error response format.). :ivar error: The error object. @@ -288,24 +265,19 @@ class ErrorResponse(msrest.serialization.Model): """ _attribute_map = { - 'error': {'key': 'error', 'type': 'ErrorDetail'}, + "error": {"key": "error", "type": "ErrorDetail"}, } - def __init__( - self, - *, - error: Optional["ErrorDetail"] = None, - **kwargs - ): + def __init__(self, *, error: Optional["_models.ErrorDetail"] = None, **kwargs): """ :keyword error: The error object. :paramtype error: ~azure.mgmt.resource.subscriptions.v2019_11_01.models.ErrorDetail """ - super(ErrorResponse, self).__init__(**kwargs) + super().__init__(**kwargs) self.error = error -class ErrorResponseAutoGenerated(msrest.serialization.Model): +class ErrorResponseAutoGenerated(_serialization.Model): """Error response. :ivar error: The error details. @@ -313,24 +285,19 @@ class ErrorResponseAutoGenerated(msrest.serialization.Model): """ _attribute_map = { - 'error': {'key': 'error', 'type': 'ErrorDefinition'}, + "error": {"key": "error", "type": "ErrorDefinition"}, } - def __init__( - self, - *, - error: Optional["ErrorDefinition"] = None, - **kwargs - ): + def __init__(self, *, error: Optional["_models.ErrorDefinition"] = None, **kwargs): """ :keyword error: The error details. :paramtype error: ~azure.mgmt.resource.subscriptions.v2019_11_01.models.ErrorDefinition """ - super(ErrorResponseAutoGenerated, self).__init__(**kwargs) + super().__init__(**kwargs) self.error = error -class Location(msrest.serialization.Model): +class Location(_serialization.Model): """Location information. Variables are only populated by the server, and will be ignored when sending a request. @@ -351,33 +318,28 @@ class Location(msrest.serialization.Model): """ _validation = { - 'id': {'readonly': True}, - 'subscription_id': {'readonly': True}, - 'name': {'readonly': True}, - 'display_name': {'readonly': True}, - 'regional_display_name': {'readonly': True}, + "id": {"readonly": True}, + "subscription_id": {"readonly": True}, + "name": {"readonly": True}, + "display_name": {"readonly": True}, + "regional_display_name": {"readonly": True}, } _attribute_map = { - 'id': {'key': 'id', 'type': 'str'}, - 'subscription_id': {'key': 'subscriptionId', 'type': 'str'}, - 'name': {'key': 'name', 'type': 'str'}, - 'display_name': {'key': 'displayName', 'type': 'str'}, - 'regional_display_name': {'key': 'regionalDisplayName', 'type': 'str'}, - 'metadata': {'key': 'metadata', 'type': 'LocationMetadata'}, + "id": {"key": "id", "type": "str"}, + "subscription_id": {"key": "subscriptionId", "type": "str"}, + "name": {"key": "name", "type": "str"}, + "display_name": {"key": "displayName", "type": "str"}, + "regional_display_name": {"key": "regionalDisplayName", "type": "str"}, + "metadata": {"key": "metadata", "type": "LocationMetadata"}, } - def __init__( - self, - *, - metadata: Optional["LocationMetadata"] = None, - **kwargs - ): + def __init__(self, *, metadata: Optional["_models.LocationMetadata"] = None, **kwargs): """ :keyword metadata: Metadata of the location, such as lat/long, paired region, and others. :paramtype metadata: ~azure.mgmt.resource.subscriptions.v2019_11_01.models.LocationMetadata """ - super(Location, self).__init__(**kwargs) + super().__init__(**kwargs) self.id = None self.subscription_id = None self.name = None @@ -386,7 +348,7 @@ def __init__( self.metadata = metadata -class LocationListResult(msrest.serialization.Model): +class LocationListResult(_serialization.Model): """Location list operation response. :ivar value: An array of locations. @@ -394,32 +356,26 @@ class LocationListResult(msrest.serialization.Model): """ _attribute_map = { - 'value': {'key': 'value', 'type': '[Location]'}, + "value": {"key": "value", "type": "[Location]"}, } - def __init__( - self, - *, - value: Optional[List["Location"]] = None, - **kwargs - ): + def __init__(self, *, value: Optional[List["_models.Location"]] = None, **kwargs): """ :keyword value: An array of locations. :paramtype value: list[~azure.mgmt.resource.subscriptions.v2019_11_01.models.Location] """ - super(LocationListResult, self).__init__(**kwargs) + super().__init__(**kwargs) self.value = value -class LocationMetadata(msrest.serialization.Model): +class LocationMetadata(_serialization.Model): """Location metadata information. Variables are only populated by the server, and will be ignored when sending a request. - :ivar region_type: The type of the region. Possible values include: "Physical", "Logical". + :ivar region_type: The type of the region. Known values are: "Physical" and "Logical". :vartype region_type: str or ~azure.mgmt.resource.subscriptions.v2019_11_01.models.RegionType - :ivar region_category: The category of the region. Possible values include: "Recommended", - "Other". + :ivar region_category: The category of the region. Known values are: "Recommended" and "Other". :vartype region_category: str or ~azure.mgmt.resource.subscriptions.v2019_11_01.models.RegionCategory :ivar geography_group: The geography group of the location. @@ -436,36 +392,31 @@ class LocationMetadata(msrest.serialization.Model): """ _validation = { - 'region_type': {'readonly': True}, - 'region_category': {'readonly': True}, - 'geography_group': {'readonly': True}, - 'longitude': {'readonly': True}, - 'latitude': {'readonly': True}, - 'physical_location': {'readonly': True}, + "region_type": {"readonly": True}, + "region_category": {"readonly": True}, + "geography_group": {"readonly": True}, + "longitude": {"readonly": True}, + "latitude": {"readonly": True}, + "physical_location": {"readonly": True}, } _attribute_map = { - 'region_type': {'key': 'regionType', 'type': 'str'}, - 'region_category': {'key': 'regionCategory', 'type': 'str'}, - 'geography_group': {'key': 'geographyGroup', 'type': 'str'}, - 'longitude': {'key': 'longitude', 'type': 'str'}, - 'latitude': {'key': 'latitude', 'type': 'str'}, - 'physical_location': {'key': 'physicalLocation', 'type': 'str'}, - 'paired_region': {'key': 'pairedRegion', 'type': '[PairedRegion]'}, + "region_type": {"key": "regionType", "type": "str"}, + "region_category": {"key": "regionCategory", "type": "str"}, + "geography_group": {"key": "geographyGroup", "type": "str"}, + "longitude": {"key": "longitude", "type": "str"}, + "latitude": {"key": "latitude", "type": "str"}, + "physical_location": {"key": "physicalLocation", "type": "str"}, + "paired_region": {"key": "pairedRegion", "type": "[PairedRegion]"}, } - def __init__( - self, - *, - paired_region: Optional[List["PairedRegion"]] = None, - **kwargs - ): + def __init__(self, *, paired_region: Optional[List["_models.PairedRegion"]] = None, **kwargs): """ :keyword paired_region: The regions paired to this region. :paramtype paired_region: list[~azure.mgmt.resource.subscriptions.v2019_11_01.models.PairedRegion] """ - super(LocationMetadata, self).__init__(**kwargs) + super().__init__(**kwargs) self.region_type = None self.region_category = None self.geography_group = None @@ -475,7 +426,7 @@ def __init__( self.paired_region = paired_region -class ManagedByTenant(msrest.serialization.Model): +class ManagedByTenant(_serialization.Model): """Information about a tenant managing the subscription. Variables are only populated by the server, and will be ignored when sending a request. @@ -485,24 +436,20 @@ class ManagedByTenant(msrest.serialization.Model): """ _validation = { - 'tenant_id': {'readonly': True}, + "tenant_id": {"readonly": True}, } _attribute_map = { - 'tenant_id': {'key': 'tenantId', 'type': 'str'}, + "tenant_id": {"key": "tenantId", "type": "str"}, } - def __init__( - self, - **kwargs - ): - """ - """ - super(ManagedByTenant, self).__init__(**kwargs) + def __init__(self, **kwargs): + """ """ + super().__init__(**kwargs) self.tenant_id = None -class Operation(msrest.serialization.Model): +class Operation(_serialization.Model): """Microsoft.Resources operation. :ivar name: Operation name: {provider}/{resource}/{operation}. @@ -512,29 +459,23 @@ class Operation(msrest.serialization.Model): """ _attribute_map = { - 'name': {'key': 'name', 'type': 'str'}, - 'display': {'key': 'display', 'type': 'OperationDisplay'}, + "name": {"key": "name", "type": "str"}, + "display": {"key": "display", "type": "OperationDisplay"}, } - def __init__( - self, - *, - name: Optional[str] = None, - display: Optional["OperationDisplay"] = None, - **kwargs - ): + def __init__(self, *, name: Optional[str] = None, display: Optional["_models.OperationDisplay"] = None, **kwargs): """ :keyword name: Operation name: {provider}/{resource}/{operation}. :paramtype name: str :keyword display: The object that represents the operation. :paramtype display: ~azure.mgmt.resource.subscriptions.v2019_11_01.models.OperationDisplay """ - super(Operation, self).__init__(**kwargs) + super().__init__(**kwargs) self.name = name self.display = display -class OperationDisplay(msrest.serialization.Model): +class OperationDisplay(_serialization.Model): """The object that represents the operation. :ivar provider: Service provider: Microsoft.Resources. @@ -548,10 +489,10 @@ class OperationDisplay(msrest.serialization.Model): """ _attribute_map = { - 'provider': {'key': 'provider', 'type': 'str'}, - 'resource': {'key': 'resource', 'type': 'str'}, - 'operation': {'key': 'operation', 'type': 'str'}, - 'description': {'key': 'description', 'type': 'str'}, + "provider": {"key": "provider", "type": "str"}, + "resource": {"key": "resource", "type": "str"}, + "operation": {"key": "operation", "type": "str"}, + "description": {"key": "description", "type": "str"}, } def __init__( @@ -573,14 +514,14 @@ def __init__( :keyword description: Description of the operation. :paramtype description: str """ - super(OperationDisplay, self).__init__(**kwargs) + super().__init__(**kwargs) self.provider = provider self.resource = resource self.operation = operation self.description = description -class OperationListResult(msrest.serialization.Model): +class OperationListResult(_serialization.Model): """Result of the request to list Microsoft.Resources operations. It contains a list of operations and a URL link to get the next set of results. :ivar value: List of Microsoft.Resources operations. @@ -590,29 +531,23 @@ class OperationListResult(msrest.serialization.Model): """ _attribute_map = { - 'value': {'key': 'value', 'type': '[Operation]'}, - 'next_link': {'key': 'nextLink', 'type': 'str'}, + "value": {"key": "value", "type": "[Operation]"}, + "next_link": {"key": "nextLink", "type": "str"}, } - def __init__( - self, - *, - value: Optional[List["Operation"]] = None, - next_link: Optional[str] = None, - **kwargs - ): + def __init__(self, *, value: Optional[List["_models.Operation"]] = None, next_link: Optional[str] = None, **kwargs): """ :keyword value: List of Microsoft.Resources operations. :paramtype value: list[~azure.mgmt.resource.subscriptions.v2019_11_01.models.Operation] :keyword next_link: URL to get the next set of operation list results if there are any. :paramtype next_link: str """ - super(OperationListResult, self).__init__(**kwargs) + super().__init__(**kwargs) self.value = value self.next_link = next_link -class PairedRegion(msrest.serialization.Model): +class PairedRegion(_serialization.Model): """Information regarding paired region. Variables are only populated by the server, and will be ignored when sending a request. @@ -627,30 +562,26 @@ class PairedRegion(msrest.serialization.Model): """ _validation = { - 'name': {'readonly': True}, - 'id': {'readonly': True}, - 'subscription_id': {'readonly': True}, + "name": {"readonly": True}, + "id": {"readonly": True}, + "subscription_id": {"readonly": True}, } _attribute_map = { - 'name': {'key': 'name', 'type': 'str'}, - 'id': {'key': 'id', 'type': 'str'}, - 'subscription_id': {'key': 'subscriptionId', 'type': 'str'}, + "name": {"key": "name", "type": "str"}, + "id": {"key": "id", "type": "str"}, + "subscription_id": {"key": "subscriptionId", "type": "str"}, } - def __init__( - self, - **kwargs - ): - """ - """ - super(PairedRegion, self).__init__(**kwargs) + def __init__(self, **kwargs): + """ """ + super().__init__(**kwargs) self.name = None self.id = None self.subscription_id = None -class Peers(msrest.serialization.Model): +class Peers(_serialization.Model): """Information about shared availability zone. Variables are only populated by the server, and will be ignored when sending a request. @@ -662,66 +593,56 @@ class Peers(msrest.serialization.Model): """ _validation = { - 'subscription_id': {'readonly': True}, - 'availability_zone': {'readonly': True}, + "subscription_id": {"readonly": True}, + "availability_zone": {"readonly": True}, } _attribute_map = { - 'subscription_id': {'key': 'subscriptionId', 'type': 'str'}, - 'availability_zone': {'key': 'availabilityZone', 'type': 'str'}, + "subscription_id": {"key": "subscriptionId", "type": "str"}, + "availability_zone": {"key": "availabilityZone", "type": "str"}, } - def __init__( - self, - **kwargs - ): - """ - """ - super(Peers, self).__init__(**kwargs) + def __init__(self, **kwargs): + """ """ + super().__init__(**kwargs) self.subscription_id = None self.availability_zone = None -class ResourceName(msrest.serialization.Model): +class ResourceName(_serialization.Model): """Name and Type of the Resource. All required parameters must be populated in order to send to Azure. - :ivar name: Required. Name of the resource. + :ivar name: Name of the resource. Required. :vartype name: str - :ivar type: Required. The type of the resource. + :ivar type: The type of the resource. Required. :vartype type: str """ _validation = { - 'name': {'required': True}, - 'type': {'required': True}, + "name": {"required": True}, + "type": {"required": True}, } _attribute_map = { - 'name': {'key': 'name', 'type': 'str'}, - 'type': {'key': 'type', 'type': 'str'}, + "name": {"key": "name", "type": "str"}, + "type": {"key": "type", "type": "str"}, } - def __init__( - self, - *, - name: str, - type: str, - **kwargs - ): + def __init__(self, *, name: str, type: str, **kwargs): """ - :keyword name: Required. Name of the resource. + :keyword name: Name of the resource. Required. :paramtype name: str - :keyword type: Required. The type of the resource. + :keyword type: The type of the resource. Required. :paramtype type: str """ - super(ResourceName, self).__init__(**kwargs) + super().__init__(**kwargs) self.name = name self.type = type -class Subscription(msrest.serialization.Model): +class Subscription(_serialization.Model): """Subscription information. Variables are only populated by the server, and will be ignored when sending a request. @@ -736,7 +657,7 @@ class Subscription(msrest.serialization.Model): :ivar tenant_id: The subscription tenant ID. :vartype tenant_id: str :ivar state: The subscription state. Possible values are Enabled, Warned, PastDue, Disabled, - and Deleted. Possible values include: "Enabled", "Warned", "PastDue", "Disabled", "Deleted". + and Deleted. Known values are: "Enabled", "Warned", "PastDue", "Disabled", and "Deleted". :vartype state: str or ~azure.mgmt.resource.subscriptions.v2019_11_01.models.SubscriptionState :ivar subscription_policies: The subscription policies. :vartype subscription_policies: @@ -748,36 +669,36 @@ class Subscription(msrest.serialization.Model): :ivar managed_by_tenants: An array containing the tenants managing the subscription. :vartype managed_by_tenants: list[~azure.mgmt.resource.subscriptions.v2019_11_01.models.ManagedByTenant] - :ivar tags: A set of tags. The tags attached to the subscription. + :ivar tags: The tags attached to the subscription. :vartype tags: dict[str, str] """ _validation = { - 'id': {'readonly': True}, - 'subscription_id': {'readonly': True}, - 'display_name': {'readonly': True}, - 'tenant_id': {'readonly': True}, - 'state': {'readonly': True}, + "id": {"readonly": True}, + "subscription_id": {"readonly": True}, + "display_name": {"readonly": True}, + "tenant_id": {"readonly": True}, + "state": {"readonly": True}, } _attribute_map = { - 'id': {'key': 'id', 'type': 'str'}, - 'subscription_id': {'key': 'subscriptionId', 'type': 'str'}, - 'display_name': {'key': 'displayName', 'type': 'str'}, - 'tenant_id': {'key': 'tenantId', 'type': 'str'}, - 'state': {'key': 'state', 'type': 'str'}, - 'subscription_policies': {'key': 'subscriptionPolicies', 'type': 'SubscriptionPolicies'}, - 'authorization_source': {'key': 'authorizationSource', 'type': 'str'}, - 'managed_by_tenants': {'key': 'managedByTenants', 'type': '[ManagedByTenant]'}, - 'tags': {'key': 'tags', 'type': '{str}'}, + "id": {"key": "id", "type": "str"}, + "subscription_id": {"key": "subscriptionId", "type": "str"}, + "display_name": {"key": "displayName", "type": "str"}, + "tenant_id": {"key": "tenantId", "type": "str"}, + "state": {"key": "state", "type": "str"}, + "subscription_policies": {"key": "subscriptionPolicies", "type": "SubscriptionPolicies"}, + "authorization_source": {"key": "authorizationSource", "type": "str"}, + "managed_by_tenants": {"key": "managedByTenants", "type": "[ManagedByTenant]"}, + "tags": {"key": "tags", "type": "{str}"}, } def __init__( self, *, - subscription_policies: Optional["SubscriptionPolicies"] = None, + subscription_policies: Optional["_models.SubscriptionPolicies"] = None, authorization_source: Optional[str] = None, - managed_by_tenants: Optional[List["ManagedByTenant"]] = None, + managed_by_tenants: Optional[List["_models.ManagedByTenant"]] = None, tags: Optional[Dict[str, str]] = None, **kwargs ): @@ -792,10 +713,10 @@ def __init__( :keyword managed_by_tenants: An array containing the tenants managing the subscription. :paramtype managed_by_tenants: list[~azure.mgmt.resource.subscriptions.v2019_11_01.models.ManagedByTenant] - :keyword tags: A set of tags. The tags attached to the subscription. + :keyword tags: The tags attached to the subscription. :paramtype tags: dict[str, str] """ - super(Subscription, self).__init__(**kwargs) + super().__init__(**kwargs) self.id = None self.subscription_id = None self.display_name = None @@ -807,45 +728,39 @@ def __init__( self.tags = tags -class SubscriptionListResult(msrest.serialization.Model): +class SubscriptionListResult(_serialization.Model): """Subscription list operation response. All required parameters must be populated in order to send to Azure. :ivar value: An array of subscriptions. :vartype value: list[~azure.mgmt.resource.subscriptions.v2019_11_01.models.Subscription] - :ivar next_link: Required. The URL to get the next set of results. + :ivar next_link: The URL to get the next set of results. Required. :vartype next_link: str """ _validation = { - 'next_link': {'required': True}, + "next_link": {"required": True}, } _attribute_map = { - 'value': {'key': 'value', 'type': '[Subscription]'}, - 'next_link': {'key': 'nextLink', 'type': 'str'}, + "value": {"key": "value", "type": "[Subscription]"}, + "next_link": {"key": "nextLink", "type": "str"}, } - def __init__( - self, - *, - next_link: str, - value: Optional[List["Subscription"]] = None, - **kwargs - ): + def __init__(self, *, next_link: str, value: Optional[List["_models.Subscription"]] = None, **kwargs): """ :keyword value: An array of subscriptions. :paramtype value: list[~azure.mgmt.resource.subscriptions.v2019_11_01.models.Subscription] - :keyword next_link: Required. The URL to get the next set of results. + :keyword next_link: The URL to get the next set of results. Required. :paramtype next_link: str """ - super(SubscriptionListResult, self).__init__(**kwargs) + super().__init__(**kwargs) self.value = value self.next_link = next_link -class SubscriptionPolicies(msrest.serialization.Model): +class SubscriptionPolicies(_serialization.Model): """Subscription policies. Variables are only populated by the server, and will be ignored when sending a request. @@ -856,37 +771,33 @@ class SubscriptionPolicies(msrest.serialization.Model): :vartype location_placement_id: str :ivar quota_id: The subscription quota ID. :vartype quota_id: str - :ivar spending_limit: The subscription spending limit. Possible values include: "On", "Off", + :ivar spending_limit: The subscription spending limit. Known values are: "On", "Off", and "CurrentPeriodOff". :vartype spending_limit: str or ~azure.mgmt.resource.subscriptions.v2019_11_01.models.SpendingLimit """ _validation = { - 'location_placement_id': {'readonly': True}, - 'quota_id': {'readonly': True}, - 'spending_limit': {'readonly': True}, + "location_placement_id": {"readonly": True}, + "quota_id": {"readonly": True}, + "spending_limit": {"readonly": True}, } _attribute_map = { - 'location_placement_id': {'key': 'locationPlacementId', 'type': 'str'}, - 'quota_id': {'key': 'quotaId', 'type': 'str'}, - 'spending_limit': {'key': 'spendingLimit', 'type': 'str'}, + "location_placement_id": {"key": "locationPlacementId", "type": "str"}, + "quota_id": {"key": "quotaId", "type": "str"}, + "spending_limit": {"key": "spendingLimit", "type": "str"}, } - def __init__( - self, - **kwargs - ): - """ - """ - super(SubscriptionPolicies, self).__init__(**kwargs) + def __init__(self, **kwargs): + """ """ + super().__init__(**kwargs) self.location_placement_id = None self.quota_id = None self.spending_limit = None -class TenantIdDescription(msrest.serialization.Model): +class TenantIdDescription(_serialization.Model): """Tenant Id information. Variables are only populated by the server, and will be ignored when sending a request. @@ -896,7 +807,7 @@ class TenantIdDescription(msrest.serialization.Model): :vartype id: str :ivar tenant_id: The tenant ID. For example, 00000000-0000-0000-0000-000000000000. :vartype tenant_id: str - :ivar tenant_category: Category of the tenant. Possible values include: "Home", "ProjectedBy", + :ivar tenant_category: Category of the tenant. Known values are: "Home", "ProjectedBy", and "ManagedBy". :vartype tenant_category: str or ~azure.mgmt.resource.subscriptions.v2019_11_01.models.TenantCategory @@ -911,32 +822,28 @@ class TenantIdDescription(msrest.serialization.Model): """ _validation = { - 'id': {'readonly': True}, - 'tenant_id': {'readonly': True}, - 'tenant_category': {'readonly': True}, - 'country': {'readonly': True}, - 'country_code': {'readonly': True}, - 'display_name': {'readonly': True}, - 'domains': {'readonly': True}, + "id": {"readonly": True}, + "tenant_id": {"readonly": True}, + "tenant_category": {"readonly": True}, + "country": {"readonly": True}, + "country_code": {"readonly": True}, + "display_name": {"readonly": True}, + "domains": {"readonly": True}, } _attribute_map = { - 'id': {'key': 'id', 'type': 'str'}, - 'tenant_id': {'key': 'tenantId', 'type': 'str'}, - 'tenant_category': {'key': 'tenantCategory', 'type': 'str'}, - 'country': {'key': 'country', 'type': 'str'}, - 'country_code': {'key': 'countryCode', 'type': 'str'}, - 'display_name': {'key': 'displayName', 'type': 'str'}, - 'domains': {'key': 'domains', 'type': '[str]'}, - } - - def __init__( - self, - **kwargs - ): - """ - """ - super(TenantIdDescription, self).__init__(**kwargs) + "id": {"key": "id", "type": "str"}, + "tenant_id": {"key": "tenantId", "type": "str"}, + "tenant_category": {"key": "tenantCategory", "type": "str"}, + "country": {"key": "country", "type": "str"}, + "country_code": {"key": "countryCode", "type": "str"}, + "display_name": {"key": "displayName", "type": "str"}, + "domains": {"key": "domains", "type": "[str]"}, + } + + def __init__(self, **kwargs): + """ """ + super().__init__(**kwargs) self.id = None self.tenant_id = None self.tenant_category = None @@ -946,40 +853,34 @@ def __init__( self.domains = None -class TenantListResult(msrest.serialization.Model): +class TenantListResult(_serialization.Model): """Tenant Ids information. All required parameters must be populated in order to send to Azure. :ivar value: An array of tenants. :vartype value: list[~azure.mgmt.resource.subscriptions.v2019_11_01.models.TenantIdDescription] - :ivar next_link: Required. The URL to use for getting the next set of results. + :ivar next_link: The URL to use for getting the next set of results. Required. :vartype next_link: str """ _validation = { - 'next_link': {'required': True}, + "next_link": {"required": True}, } _attribute_map = { - 'value': {'key': 'value', 'type': '[TenantIdDescription]'}, - 'next_link': {'key': 'nextLink', 'type': 'str'}, + "value": {"key": "value", "type": "[TenantIdDescription]"}, + "next_link": {"key": "nextLink", "type": "str"}, } - def __init__( - self, - *, - next_link: str, - value: Optional[List["TenantIdDescription"]] = None, - **kwargs - ): + def __init__(self, *, next_link: str, value: Optional[List["_models.TenantIdDescription"]] = None, **kwargs): """ :keyword value: An array of tenants. :paramtype value: list[~azure.mgmt.resource.subscriptions.v2019_11_01.models.TenantIdDescription] - :keyword next_link: Required. The URL to use for getting the next set of results. + :keyword next_link: The URL to use for getting the next set of results. Required. :paramtype next_link: str """ - super(TenantListResult, self).__init__(**kwargs) + super().__init__(**kwargs) self.value = value self.next_link = next_link diff --git a/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/subscriptions/v2019_11_01/models/_patch.py b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/subscriptions/v2019_11_01/models/_patch.py new file mode 100644 index 0000000000000..f7dd32510333d --- /dev/null +++ b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/subscriptions/v2019_11_01/models/_patch.py @@ -0,0 +1,20 @@ +# ------------------------------------ +# Copyright (c) Microsoft Corporation. +# Licensed under the MIT License. +# ------------------------------------ +"""Customize generated code here. + +Follow our quickstart for examples: https://aka.ms/azsdk/python/dpcodegen/python/customize +""" +from typing import List + +__all__: List[str] = [] # Add all objects you want publicly available to users at this package level + + +def patch_sdk(): + """Do not remove from this file. + + `patch_sdk` is a last resort escape hatch that allows you to do customizations + you can't accomplish using the techniques described in + https://aka.ms/azsdk/python/dpcodegen/python/customize + """ diff --git a/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/subscriptions/v2019_11_01/models/_subscription_client_enums.py b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/subscriptions/v2019_11_01/models/_subscription_client_enums.py index 094df5177e457..da953c4ba7940 100644 --- a/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/subscriptions/v2019_11_01/models/_subscription_client_enums.py +++ b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/subscriptions/v2019_11_01/models/_subscription_client_enums.py @@ -7,42 +7,40 @@ # -------------------------------------------------------------------------- from enum import Enum -from six import with_metaclass from azure.core import CaseInsensitiveEnumMeta -class RegionCategory(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): - """The category of the region. - """ +class RegionCategory(str, Enum, metaclass=CaseInsensitiveEnumMeta): + """The category of the region.""" RECOMMENDED = "Recommended" OTHER = "Other" -class RegionType(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): - """The type of the region. - """ + +class RegionType(str, Enum, metaclass=CaseInsensitiveEnumMeta): + """The type of the region.""" PHYSICAL = "Physical" LOGICAL = "Logical" -class ResourceNameStatus(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): - """Is the resource name Allowed or Reserved - """ + +class ResourceNameStatus(str, Enum, metaclass=CaseInsensitiveEnumMeta): + """Is the resource name Allowed or Reserved.""" ALLOWED = "Allowed" RESERVED = "Reserved" -class SpendingLimit(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): - """The subscription spending limit. - """ + +class SpendingLimit(str, Enum, metaclass=CaseInsensitiveEnumMeta): + """The subscription spending limit.""" ON = "On" OFF = "Off" CURRENT_PERIOD_OFF = "CurrentPeriodOff" -class SubscriptionState(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): - """The subscription state. Possible values are Enabled, Warned, PastDue, Disabled, and Deleted. - """ + +class SubscriptionState(str, Enum, metaclass=CaseInsensitiveEnumMeta): + """The subscription state. Possible values are Enabled, Warned, PastDue, Disabled, and Deleted.""" ENABLED = "Enabled" WARNED = "Warned" @@ -50,9 +48,9 @@ class SubscriptionState(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): DISABLED = "Disabled" DELETED = "Deleted" -class TenantCategory(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): - """Category of the tenant. - """ + +class TenantCategory(str, Enum, metaclass=CaseInsensitiveEnumMeta): + """Category of the tenant.""" HOME = "Home" PROJECTED_BY = "ProjectedBy" diff --git a/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/subscriptions/v2019_11_01/operations/__init__.py b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/subscriptions/v2019_11_01/operations/__init__.py index 437b49e23548f..1066cb67ea911 100644 --- a/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/subscriptions/v2019_11_01/operations/__init__.py +++ b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/subscriptions/v2019_11_01/operations/__init__.py @@ -11,9 +11,15 @@ from ._operations import TenantsOperations from ._operations import SubscriptionClientOperationsMixin +from ._patch import __all__ as _patch_all +from ._patch import * # type: ignore # pylint: disable=unused-wildcard-import +from ._patch import patch_sdk as _patch_sdk + __all__ = [ - 'Operations', - 'SubscriptionsOperations', - 'TenantsOperations', - 'SubscriptionClientOperationsMixin', + "Operations", + "SubscriptionsOperations", + "TenantsOperations", + "SubscriptionClientOperationsMixin", ] +__all__.extend([p for p in _patch_all if p not in __all__]) +_patch_sdk() diff --git a/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/subscriptions/v2019_11_01/operations/_operations.py b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/subscriptions/v2019_11_01/operations/_operations.py index 2702c2f82a374..0834d39d131b5 100644 --- a/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/subscriptions/v2019_11_01/operations/_operations.py +++ b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/subscriptions/v2019_11_01/operations/_operations.py @@ -6,301 +6,253 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -from typing import Any, Callable, Dict, Iterable, Optional, TypeVar - -from msrest import Serializer - -from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error +from typing import Any, Callable, Dict, IO, Iterable, Optional, TypeVar, Union, overload +from urllib.parse import parse_qs, urljoin, urlparse + +from azure.core.exceptions import ( + ClientAuthenticationError, + HttpResponseError, + ResourceExistsError, + ResourceNotFoundError, + ResourceNotModifiedError, + map_error, +) from azure.core.paging import ItemPaged from azure.core.pipeline import PipelineResponse from azure.core.pipeline.transport import HttpResponse from azure.core.rest import HttpRequest from azure.core.tracing.decorator import distributed_trace +from azure.core.utils import case_insensitive_dict from azure.mgmt.core.exceptions import ARMErrorFormat from .. import models as _models -from .._vendor import _convert_request, _format_url_section -T = TypeVar('T') +from ..._serialization import Serializer +from .._vendor import MixinABC, _convert_request, _format_url_section + +T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] -JSONType = Any _SERIALIZER = Serializer() _SERIALIZER.client_side_validation = False -def build_operations_list_request( - **kwargs: Any -) -> HttpRequest: - api_version = kwargs.pop('api_version', "2019-11-01") # type: str - accept = "application/json" +def build_operations_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", "2019-11-01")) # type: str + accept = _headers.pop("Accept", "application/json") + # Construct URL _url = kwargs.pop("template_url", "/providers/Microsoft.Resources/operations") # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) - return HttpRequest( - method="GET", - url=_url, - params=_query_parameters, - headers=_header_parameters, - **kwargs - ) +def build_subscriptions_list_locations_request(subscription_id: str, **kwargs: Any) -> HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) -def build_subscriptions_list_locations_request( - subscription_id: str, - **kwargs: Any -) -> HttpRequest: - api_version = kwargs.pop('api_version', "2019-11-01") # type: str + api_version = kwargs.pop("api_version", _params.pop("api-version", "2019-11-01")) # type: str + accept = _headers.pop("Accept", "application/json") - accept = "application/json" # Construct URL _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/locations") path_format_arguments = { - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), } _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - return HttpRequest( - method="GET", - url=_url, - params=_query_parameters, - headers=_header_parameters, - **kwargs - ) + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) -def build_subscriptions_get_request( - subscription_id: str, - **kwargs: Any -) -> HttpRequest: - api_version = kwargs.pop('api_version', "2019-11-01") # type: str +def build_subscriptions_get_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", "2019-11-01")) # type: str + accept = _headers.pop("Accept", "application/json") - accept = "application/json" # Construct URL _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}") path_format_arguments = { - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), } _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) - return HttpRequest( - method="GET", - url=_url, - params=_query_parameters, - headers=_header_parameters, - **kwargs - ) +def build_subscriptions_list_request(**kwargs: Any) -> HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) -def build_subscriptions_list_request( - **kwargs: Any -) -> HttpRequest: - api_version = kwargs.pop('api_version', "2019-11-01") # type: str + api_version = kwargs.pop("api_version", _params.pop("api-version", "2019-11-01")) # type: str + accept = _headers.pop("Accept", "application/json") - accept = "application/json" # Construct URL _url = kwargs.pop("template_url", "/subscriptions") # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') - - return HttpRequest( - method="GET", - url=_url, - params=_query_parameters, - headers=_header_parameters, - **kwargs - ) - - -def build_subscriptions_check_zone_peers_request( - subscription_id: str, - *, - json: JSONType = None, - content: Any = None, - **kwargs: Any -) -> HttpRequest: - api_version = kwargs.pop('api_version', "2019-11-01") # type: str - content_type = kwargs.pop('content_type', None) # type: Optional[str] - - accept = "application/json" + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) + + +def build_subscriptions_check_zone_peers_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", "2019-11-01")) # type: str + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + accept = _headers.pop("Accept", "application/json") + # Construct URL _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/providers/Microsoft.Resources/checkZonePeers/") path_format_arguments = { - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), } _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] if content_type is not None: - _header_parameters['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') - _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') - - return HttpRequest( - method="POST", - url=_url, - params=_query_parameters, - headers=_header_parameters, - json=json, - content=content, - **kwargs - ) - - -def build_tenants_list_request( - **kwargs: Any -) -> HttpRequest: - api_version = kwargs.pop('api_version', "2019-11-01") # type: str - - accept = "application/json" + _headers["Content-Type"] = _SERIALIZER.header("content_type", content_type, "str") + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="POST", url=_url, params=_params, headers=_headers, **kwargs) + + +def build_tenants_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", "2019-11-01")) # type: str + accept = _headers.pop("Accept", "application/json") + # Construct URL _url = kwargs.pop("template_url", "/tenants") # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') - - return HttpRequest( - method="GET", - url=_url, - params=_query_parameters, - headers=_header_parameters, - **kwargs - ) - - -def build_check_resource_name_request( - *, - json: JSONType = None, - content: Any = None, - **kwargs: Any -) -> HttpRequest: - api_version = kwargs.pop('api_version', "2019-11-01") # type: str - content_type = kwargs.pop('content_type', None) # type: Optional[str] - - accept = "application/json" + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) + + +def build_check_resource_name_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", "2019-11-01")) # type: str + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + accept = _headers.pop("Accept", "application/json") + # Construct URL _url = kwargs.pop("template_url", "/providers/Microsoft.Resources/checkResourceName") # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] if content_type is not None: - _header_parameters['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') - _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') - - return HttpRequest( - method="POST", - url=_url, - params=_query_parameters, - headers=_header_parameters, - json=json, - content=content, - **kwargs - ) - -class Operations(object): - """Operations operations. - - You should not instantiate this class directly. Instead, you should create a Client instance that - instantiates it for you and attaches it as an attribute. - - :ivar models: Alias to model classes used in this operation group. - :type models: ~azure.mgmt.resource.subscriptions.v2019_11_01.models - :param client: Client for service requests. - :param config: Configuration of service client. - :param serializer: An object model serializer. - :param deserializer: An object model deserializer. + _headers["Content-Type"] = _SERIALIZER.header("content_type", content_type, "str") + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="POST", url=_url, params=_params, headers=_headers, **kwargs) + + +class Operations: + """ + .. warning:: + **DO NOT** instantiate this class directly. + + Instead, you should access the following operations through + :class:`~azure.mgmt.resource.subscriptions.v2019_11_01.SubscriptionClient`'s + :attr:`operations` attribute. """ models = _models - def __init__(self, client, config, serializer, deserializer): - self._client = client - self._serialize = serializer - self._deserialize = deserializer - self._config = config + def __init__(self, *args, **kwargs): + input_args = list(args) + self._client = input_args.pop(0) if input_args else kwargs.pop("client") + self._config = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") @distributed_trace - def list( - self, - **kwargs: Any - ) -> Iterable["_models.OperationListResult"]: + def list(self, **kwargs: Any) -> Iterable["_models.Operation"]: """Lists all of the available Microsoft.Resources REST API operations. :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either OperationListResult or the result of cls(response) + :return: An iterator like instance of either Operation or the result of cls(response) :rtype: - ~azure.core.paging.ItemPaged[~azure.mgmt.resource.subscriptions.v2019_11_01.models.OperationListResult] - :raises: ~azure.core.exceptions.HttpResponseError + ~azure.core.paging.ItemPaged[~azure.mgmt.resource.subscriptions.v2019_11_01.models.Operation] + :raises ~azure.core.exceptions.HttpResponseError: """ - api_version = kwargs.pop('api_version', "2019-11-01") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2019-11-01")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[_models.OperationListResult] - cls = kwargs.pop('cls', None) # type: ClsType["_models.OperationListResult"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) + def prepare_request(next_link=None): if not next_link: - + request = build_operations_list_request( api_version=api_version, - template_url=self.list.metadata['url'], + template_url=self.list.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore else: - - request = build_operations_list_request( - template_url=next_link, - ) + # make call to next link with the client's api-version + _parsed_next_link = urlparse(next_link) + _next_request_params = case_insensitive_dict(parse_qs(_parsed_next_link.query)) + _next_request_params["api-version"] = self._config.api_version + request = HttpRequest("GET", urljoin(next_link, _parsed_next_link.path), params=_next_request_params) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore request.method = "GET" return request @@ -314,10 +266,8 @@ def extract_data(pipeline_response): def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) response = pipeline_response.http_response @@ -327,78 +277,80 @@ def get_next(next_link=None): return pipeline_response + return ItemPaged(get_next, extract_data) - return ItemPaged( - get_next, extract_data - ) - list.metadata = {'url': "/providers/Microsoft.Resources/operations"} # type: ignore -class SubscriptionsOperations(object): - """SubscriptionsOperations operations. - - You should not instantiate this class directly. Instead, you should create a Client instance that - instantiates it for you and attaches it as an attribute. - - :ivar models: Alias to model classes used in this operation group. - :type models: ~azure.mgmt.resource.subscriptions.v2019_11_01.models - :param client: Client for service requests. - :param config: Configuration of service client. - :param serializer: An object model serializer. - :param deserializer: An object model deserializer. + list.metadata = {"url": "/providers/Microsoft.Resources/operations"} # type: ignore + + +class SubscriptionsOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. + + Instead, you should access the following operations through + :class:`~azure.mgmt.resource.subscriptions.v2019_11_01.SubscriptionClient`'s + :attr:`subscriptions` attribute. """ models = _models - def __init__(self, client, config, serializer, deserializer): - self._client = client - self._serialize = serializer - self._deserialize = deserializer - self._config = config + def __init__(self, *args, **kwargs): + input_args = list(args) + self._client = input_args.pop(0) if input_args else kwargs.pop("client") + self._config = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") @distributed_trace - def list_locations( - self, - subscription_id: str, - **kwargs: Any - ) -> Iterable["_models.LocationListResult"]: + def list_locations(self, subscription_id: str, **kwargs: Any) -> Iterable["_models.Location"]: """Gets all available geo-locations. This operation provides all the locations that are available for resource providers; however, each resource provider may support a subset of this list. - :param subscription_id: The ID of the target subscription. + :param subscription_id: The ID of the target subscription. Required. :type subscription_id: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either LocationListResult or the result of cls(response) + :return: An iterator like instance of either Location or the result of cls(response) :rtype: - ~azure.core.paging.ItemPaged[~azure.mgmt.resource.subscriptions.v2019_11_01.models.LocationListResult] - :raises: ~azure.core.exceptions.HttpResponseError + ~azure.core.paging.ItemPaged[~azure.mgmt.resource.subscriptions.v2019_11_01.models.Location] + :raises ~azure.core.exceptions.HttpResponseError: """ - api_version = kwargs.pop('api_version', "2019-11-01") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2019-11-01")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[_models.LocationListResult] - cls = kwargs.pop('cls', None) # type: ClsType["_models.LocationListResult"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) + def prepare_request(next_link=None): if not next_link: - + request = build_subscriptions_list_locations_request( subscription_id=subscription_id, api_version=api_version, - template_url=self.list_locations.metadata['url'], + template_url=self.list_locations.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore else: - - request = build_subscriptions_list_locations_request( - subscription_id=subscription_id, - template_url=next_link, - ) + # make call to next link with the client's api-version + _parsed_next_link = urlparse(next_link) + _next_request_params = case_insensitive_dict(parse_qs(_parsed_next_link.query)) + _next_request_params["api-version"] = self._config.api_version + request = HttpRequest("GET", urljoin(next_link, _parsed_next_link.path), params=_next_request_params) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore request.method = "GET" return request @@ -412,10 +364,8 @@ def extract_data(pipeline_response): def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) response = pipeline_response.http_response @@ -425,103 +375,108 @@ def get_next(next_link=None): return pipeline_response + return ItemPaged(get_next, extract_data) - return ItemPaged( - get_next, extract_data - ) - list_locations.metadata = {'url': "/subscriptions/{subscriptionId}/locations"} # type: ignore + list_locations.metadata = {"url": "/subscriptions/{subscriptionId}/locations"} # type: ignore @distributed_trace - def get( - self, - subscription_id: str, - **kwargs: Any - ) -> "_models.Subscription": + def get(self, subscription_id: str, **kwargs: Any) -> _models.Subscription: """Gets details about a specified subscription. - :param subscription_id: The ID of the target subscription. + :param subscription_id: The ID of the target subscription. Required. :type subscription_id: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: Subscription, or the result of cls(response) + :return: Subscription or the result of cls(response) :rtype: ~azure.mgmt.resource.subscriptions.v2019_11_01.models.Subscription - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.Subscription"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + 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', "2019-11-01") # type: str + api_version = kwargs.pop("api_version", _params.pop("api-version", "2019-11-01")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[_models.Subscription] - request = build_subscriptions_get_request( subscription_id=subscription_id, api_version=api_version, - template_url=self.get.metadata['url'], + template_url=self.get.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) - deserialized = self._deserialize('Subscription', pipeline_response) + deserialized = self._deserialize("Subscription", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - get.metadata = {'url': "/subscriptions/{subscriptionId}"} # type: ignore - + get.metadata = {"url": "/subscriptions/{subscriptionId}"} # type: ignore @distributed_trace - def list( - self, - **kwargs: Any - ) -> Iterable["_models.SubscriptionListResult"]: + def list(self, **kwargs: Any) -> Iterable["_models.Subscription"]: """Gets all subscriptions for a tenant. :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either SubscriptionListResult or the result of - cls(response) + :return: An iterator like instance of either Subscription or the result of cls(response) :rtype: - ~azure.core.paging.ItemPaged[~azure.mgmt.resource.subscriptions.v2019_11_01.models.SubscriptionListResult] - :raises: ~azure.core.exceptions.HttpResponseError + ~azure.core.paging.ItemPaged[~azure.mgmt.resource.subscriptions.v2019_11_01.models.Subscription] + :raises ~azure.core.exceptions.HttpResponseError: """ - api_version = kwargs.pop('api_version', "2019-11-01") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2019-11-01")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[_models.SubscriptionListResult] - cls = kwargs.pop('cls', None) # type: ClsType["_models.SubscriptionListResult"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) + def prepare_request(next_link=None): if not next_link: - + request = build_subscriptions_list_request( api_version=api_version, - template_url=self.list.metadata['url'], + template_url=self.list.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore else: - - request = build_subscriptions_list_request( - template_url=next_link, - ) + # make call to next link with the client's api-version + _parsed_next_link = urlparse(next_link) + _next_request_params = case_insensitive_dict(parse_qs(_parsed_next_link.query)) + _next_request_params["api-version"] = self._config.api_version + request = HttpRequest("GET", urljoin(next_link, _parsed_next_link.path), params=_next_request_params) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore request.method = "GET" return request @@ -535,10 +490,8 @@ def extract_data(pipeline_response): def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) response = pipeline_response.http_response @@ -548,56 +501,113 @@ def get_next(next_link=None): return pipeline_response + return ItemPaged(get_next, extract_data) - return ItemPaged( - get_next, extract_data - ) - list.metadata = {'url': "/subscriptions"} # type: ignore + list.metadata = {"url": "/subscriptions"} # type: ignore - @distributed_trace + @overload def check_zone_peers( self, subscription_id: str, - parameters: "_models.CheckZonePeersRequest", + parameters: _models.CheckZonePeersRequest, + *, + content_type: str = "application/json", **kwargs: Any - ) -> "_models.CheckZonePeersResult": + ) -> _models.CheckZonePeersResult: + """Compares a subscriptions logical zone mapping. + + :param subscription_id: The ID of the target subscription. Required. + :type subscription_id: str + :param parameters: Parameters for checking zone peers. Required. + :type parameters: ~azure.mgmt.resource.subscriptions.v2019_11_01.models.CheckZonePeersRequest + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: CheckZonePeersResult or the result of cls(response) + :rtype: ~azure.mgmt.resource.subscriptions.v2019_11_01.models.CheckZonePeersResult + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + def check_zone_peers( + self, subscription_id: str, parameters: IO, *, content_type: str = "application/json", **kwargs: Any + ) -> _models.CheckZonePeersResult: + """Compares a subscriptions logical zone mapping. + + :param subscription_id: The ID of the target subscription. Required. + :type subscription_id: str + :param parameters: Parameters for checking zone peers. Required. + :type parameters: IO + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: CheckZonePeersResult or the result of cls(response) + :rtype: ~azure.mgmt.resource.subscriptions.v2019_11_01.models.CheckZonePeersResult + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace + def check_zone_peers( + self, subscription_id: str, parameters: Union[_models.CheckZonePeersRequest, IO], **kwargs: Any + ) -> _models.CheckZonePeersResult: """Compares a subscriptions logical zone mapping. - :param subscription_id: The ID of the target subscription. + :param subscription_id: The ID of the target subscription. Required. :type subscription_id: str - :param parameters: Parameters for checking zone peers. + :param parameters: Parameters for checking zone peers. Is either a model type or a IO type. + Required. :type parameters: ~azure.mgmt.resource.subscriptions.v2019_11_01.models.CheckZonePeersRequest + or IO + :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. + Default value is None. + :paramtype content_type: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: CheckZonePeersResult, or the result of cls(response) + :return: CheckZonePeersResult or the result of cls(response) :rtype: ~azure.mgmt.resource.subscriptions.v2019_11_01.models.CheckZonePeersResult - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.CheckZonePeersResult"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) - api_version = kwargs.pop('api_version', "2019-11-01") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - _json = self._serialize.body(parameters, 'CheckZonePeersRequest') + api_version = kwargs.pop("api_version", _params.pop("api-version", "2019-11-01")) # type: str + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.CheckZonePeersResult] + + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(parameters, (IO, bytes)): + _content = parameters + else: + _json = self._serialize.body(parameters, "CheckZonePeersRequest") request = build_subscriptions_check_zone_peers_request( subscription_id=subscription_id, api_version=api_version, content_type=content_type, json=_json, - template_url=self.check_zone_peers.metadata['url'], + content=_content, + template_url=self.check_zone_peers.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200]: @@ -605,74 +615,79 @@ def check_zone_peers( error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - deserialized = self._deserialize('CheckZonePeersResult', pipeline_response) + deserialized = self._deserialize("CheckZonePeersResult", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - check_zone_peers.metadata = {'url': "/subscriptions/{subscriptionId}/providers/Microsoft.Resources/checkZonePeers/"} # type: ignore + check_zone_peers.metadata = {"url": "/subscriptions/{subscriptionId}/providers/Microsoft.Resources/checkZonePeers/"} # type: ignore -class TenantsOperations(object): - """TenantsOperations operations. - You should not instantiate this class directly. Instead, you should create a Client instance that - instantiates it for you and attaches it as an attribute. +class TenantsOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. - :ivar models: Alias to model classes used in this operation group. - :type models: ~azure.mgmt.resource.subscriptions.v2019_11_01.models - :param client: Client for service requests. - :param config: Configuration of service client. - :param serializer: An object model serializer. - :param deserializer: An object model deserializer. + Instead, you should access the following operations through + :class:`~azure.mgmt.resource.subscriptions.v2019_11_01.SubscriptionClient`'s + :attr:`tenants` attribute. """ models = _models - def __init__(self, client, config, serializer, deserializer): - self._client = client - self._serialize = serializer - self._deserialize = deserializer - self._config = config + def __init__(self, *args, **kwargs): + input_args = list(args) + self._client = input_args.pop(0) if input_args else kwargs.pop("client") + self._config = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") @distributed_trace - def list( - self, - **kwargs: Any - ) -> Iterable["_models.TenantListResult"]: + def list(self, **kwargs: Any) -> Iterable["_models.TenantIdDescription"]: """Gets the tenants for your account. :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either TenantListResult or the result of cls(response) + :return: An iterator like instance of either TenantIdDescription or the result of cls(response) :rtype: - ~azure.core.paging.ItemPaged[~azure.mgmt.resource.subscriptions.v2019_11_01.models.TenantListResult] - :raises: ~azure.core.exceptions.HttpResponseError + ~azure.core.paging.ItemPaged[~azure.mgmt.resource.subscriptions.v2019_11_01.models.TenantIdDescription] + :raises ~azure.core.exceptions.HttpResponseError: """ - api_version = kwargs.pop('api_version', "2019-11-01") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2019-11-01")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[_models.TenantListResult] - cls = kwargs.pop('cls', None) # type: ClsType["_models.TenantListResult"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) + def prepare_request(next_link=None): if not next_link: - + request = build_tenants_list_request( api_version=api_version, - template_url=self.list.metadata['url'], + template_url=self.list.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore else: - - request = build_tenants_list_request( - template_url=next_link, - ) + # make call to next link with the client's api-version + _parsed_next_link = urlparse(next_link) + _next_request_params = case_insensitive_dict(parse_qs(_parsed_next_link.query)) + _next_request_params["api-version"] = self._config.api_version + request = HttpRequest("GET", urljoin(next_link, _parsed_next_link.path), params=_next_request_params) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore request.method = "GET" return request @@ -686,10 +701,8 @@ def extract_data(pipeline_response): def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) response = pipeline_response.http_response @@ -699,19 +712,20 @@ def get_next(next_link=None): return pipeline_response + return ItemPaged(get_next, extract_data) - return ItemPaged( - get_next, extract_data - ) - list.metadata = {'url': "/tenants"} # type: ignore -class SubscriptionClientOperationsMixin(object): + list.metadata = {"url": "/tenants"} # type: ignore - @distributed_trace + +class SubscriptionClientOperationsMixin(MixinABC): + @overload def check_resource_name( self, - resource_name_definition: Optional["_models.ResourceName"] = None, + resource_name_definition: Optional[_models.ResourceName] = None, + *, + content_type: str = "application/json", **kwargs: Any - ) -> "_models.CheckResourceNameResult": + ) -> _models.CheckResourceNameResult: """Checks resource name validity. A resource name is valid if it is not a reserved word, does not contains a reserved word and @@ -721,39 +735,99 @@ def check_resource_name( type. Default value is None. :type resource_name_definition: ~azure.mgmt.resource.subscriptions.v2019_11_01.models.ResourceName + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: CheckResourceNameResult or the result of cls(response) + :rtype: ~azure.mgmt.resource.subscriptions.v2019_11_01.models.CheckResourceNameResult + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + def check_resource_name( + self, resource_name_definition: Optional[IO] = None, *, content_type: str = "application/json", **kwargs: Any + ) -> _models.CheckResourceNameResult: + """Checks resource name validity. + + A resource name is valid if it is not a reserved word, does not contains a reserved word and + does not start with a reserved word. + + :param resource_name_definition: Resource object with values for resource name and resource + type. Default value is None. + :type resource_name_definition: IO + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: CheckResourceNameResult, or the result of cls(response) + :return: CheckResourceNameResult or the result of cls(response) :rtype: ~azure.mgmt.resource.subscriptions.v2019_11_01.models.CheckResourceNameResult - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace + def check_resource_name( + self, resource_name_definition: Optional[Union[_models.ResourceName, IO]] = None, **kwargs: Any + ) -> _models.CheckResourceNameResult: + """Checks resource name validity. + + A resource name is valid if it is not a reserved word, does not contains a reserved word and + does not start with a reserved word. + + :param resource_name_definition: Resource object with values for resource name and resource + type. Is either a model type or a IO type. Default value is None. + :type resource_name_definition: + ~azure.mgmt.resource.subscriptions.v2019_11_01.models.ResourceName or IO + :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. + Default value is None. + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: CheckResourceNameResult or the result of cls(response) + :rtype: ~azure.mgmt.resource.subscriptions.v2019_11_01.models.CheckResourceNameResult + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.CheckResourceNameResult"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', "2019-11-01") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + api_version = kwargs.pop("api_version", _params.pop("api-version", "2019-11-01")) # type: str + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.CheckResourceNameResult] - if resource_name_definition is not None: - _json = self._serialize.body(resource_name_definition, 'ResourceName') + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(resource_name_definition, (IO, bytes)): + _content = resource_name_definition else: - _json = None + if resource_name_definition is not None: + _json = self._serialize.body(resource_name_definition, "ResourceName") + else: + _json = None request = build_check_resource_name_request( api_version=api_version, content_type=content_type, json=_json, - template_url=self.check_resource_name.metadata['url'], + content=_content, + template_url=self.check_resource_name.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200]: @@ -761,12 +835,11 @@ def check_resource_name( error = self._deserialize.failsafe_deserialize(_models.ErrorResponseAutoGenerated, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - deserialized = self._deserialize('CheckResourceNameResult', pipeline_response) + deserialized = self._deserialize("CheckResourceNameResult", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - check_resource_name.metadata = {'url': "/providers/Microsoft.Resources/checkResourceName"} # type: ignore - + check_resource_name.metadata = {"url": "/providers/Microsoft.Resources/checkResourceName"} # type: ignore diff --git a/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/subscriptions/v2019_11_01/operations/_patch.py b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/subscriptions/v2019_11_01/operations/_patch.py new file mode 100644 index 0000000000000..f7dd32510333d --- /dev/null +++ b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/subscriptions/v2019_11_01/operations/_patch.py @@ -0,0 +1,20 @@ +# ------------------------------------ +# Copyright (c) Microsoft Corporation. +# Licensed under the MIT License. +# ------------------------------------ +"""Customize generated code here. + +Follow our quickstart for examples: https://aka.ms/azsdk/python/dpcodegen/python/customize +""" +from typing import List + +__all__: List[str] = [] # Add all objects you want publicly available to users at this package level + + +def patch_sdk(): + """Do not remove from this file. + + `patch_sdk` is a last resort escape hatch that allows you to do customizations + you can't accomplish using the techniques described in + https://aka.ms/azsdk/python/dpcodegen/python/customize + """ diff --git a/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/subscriptions/v2021_01_01/__init__.py b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/subscriptions/v2021_01_01/__init__.py index abd8e21f33387..d5d8e357d6a54 100644 --- a/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/subscriptions/v2021_01_01/__init__.py +++ b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/subscriptions/v2021_01_01/__init__.py @@ -10,9 +10,15 @@ from ._version import VERSION __version__ = VERSION -__all__ = ['SubscriptionClient'] -# `._patch.py` is used for handwritten extensions to the generated code -# Example: https://github.com/Azure/azure-sdk-for-python/blob/main/doc/dev/customize_code/how-to-patch-sdk-code.md -from ._patch import patch_sdk -patch_sdk() +try: + from ._patch import __all__ as _patch_all + from ._patch import * # type: ignore # pylint: disable=unused-wildcard-import +except ImportError: + _patch_all = [] +from ._patch import patch_sdk as _patch_sdk + +__all__ = ["SubscriptionClient"] +__all__.extend([p for p in _patch_all if p not in __all__]) + +_patch_sdk() diff --git a/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/subscriptions/v2021_01_01/_configuration.py b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/subscriptions/v2021_01_01/_configuration.py index dfbf629e5d3b9..b16d766f1eacf 100644 --- a/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/subscriptions/v2021_01_01/_configuration.py +++ b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/subscriptions/v2021_01_01/_configuration.py @@ -25,43 +25,40 @@ class SubscriptionClientConfiguration(Configuration): # pylint: disable=too-man Note that all parameters used to create this instance are saved as instance attributes. - :param credential: Credential needed for the client to connect to Azure. + :param credential: Credential needed for the client to connect to Azure. Required. :type credential: ~azure.core.credentials.TokenCredential :keyword api_version: Api Version. Default value is "2021-01-01". Note that overriding this default value may result in unsupported behavior. :paramtype api_version: str """ - def __init__( - self, - credential: "TokenCredential", - **kwargs: Any - ) -> None: + def __init__(self, credential: "TokenCredential", **kwargs: Any) -> None: super(SubscriptionClientConfiguration, self).__init__(**kwargs) - api_version = kwargs.pop('api_version', "2021-01-01") # type: str + api_version = kwargs.pop("api_version", "2021-01-01") # type: str if credential is None: raise ValueError("Parameter 'credential' must not be None.") self.credential = credential self.api_version = api_version - self.credential_scopes = kwargs.pop('credential_scopes', ['https://management.azure.com/.default']) - kwargs.setdefault('sdk_moniker', 'mgmt-resource/{}'.format(VERSION)) + self.credential_scopes = kwargs.pop("credential_scopes", ["https://management.azure.com/.default"]) + kwargs.setdefault("sdk_moniker", "mgmt-resource/{}".format(VERSION)) self._configure(**kwargs) def _configure( - self, - **kwargs # type: Any + self, **kwargs # type: Any ): # type: (...) -> 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) - self.logging_policy = kwargs.get('logging_policy') or policies.NetworkTraceLoggingPolicy(**kwargs) - self.http_logging_policy = kwargs.get('http_logging_policy') or ARMHttpLoggingPolicy(**kwargs) - self.retry_policy = kwargs.get('retry_policy') or policies.RetryPolicy(**kwargs) - self.custom_hook_policy = kwargs.get('custom_hook_policy') or policies.CustomHookPolicy(**kwargs) - self.redirect_policy = kwargs.get('redirect_policy') or policies.RedirectPolicy(**kwargs) - self.authentication_policy = kwargs.get('authentication_policy') + 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) + self.logging_policy = kwargs.get("logging_policy") or policies.NetworkTraceLoggingPolicy(**kwargs) + self.http_logging_policy = kwargs.get("http_logging_policy") or ARMHttpLoggingPolicy(**kwargs) + self.retry_policy = kwargs.get("retry_policy") or policies.RetryPolicy(**kwargs) + self.custom_hook_policy = kwargs.get("custom_hook_policy") or policies.CustomHookPolicy(**kwargs) + self.redirect_policy = kwargs.get("redirect_policy") or policies.RedirectPolicy(**kwargs) + self.authentication_policy = kwargs.get("authentication_policy") if self.credential and not self.authentication_policy: - self.authentication_policy = ARMChallengeAuthenticationPolicy(self.credential, *self.credential_scopes, **kwargs) + self.authentication_policy = ARMChallengeAuthenticationPolicy( + self.credential, *self.credential_scopes, **kwargs + ) diff --git a/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/subscriptions/v2021_01_01/_metadata.json b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/subscriptions/v2021_01_01/_metadata.json index 3a38bd970e909..6a7ba3c480494 100644 --- a/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/subscriptions/v2021_01_01/_metadata.json +++ b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/subscriptions/v2021_01_01/_metadata.json @@ -10,14 +10,14 @@ "azure_arm": true, "has_lro_operations": false, "client_side_validation": false, - "sync_imports": "{\"typing\": {\"azurecore\": {\"azure.core.credentials\": [\"TokenCredential\"]}}, \"regular\": {\"azurecore\": {\"azure.profiles\": [\"KnownProfiles\", \"ProfileDefinition\"], \"azure.profiles.multiapiclient\": [\"MultiApiClientMixin\"], \"azure.mgmt.core\": [\"ARMPipelineClient\"]}, \"local\": {\"._configuration\": [\"SubscriptionClientConfiguration\"], \"._operations_mixin\": [\"SubscriptionClientOperationsMixin\"]}, \"thirdparty\": {\"msrest\": [\"Deserializer\", \"Serializer\"]}}, \"conditional\": {\"stdlib\": {\"typing\": [\"Any\", \"Optional\"]}}}", - "async_imports": "{\"typing\": {\"azurecore\": {\"azure.core.credentials_async\": [\"AsyncTokenCredential\"], \"azure.core.credentials\": [\"TokenCredential\"]}}, \"regular\": {\"azurecore\": {\"azure.profiles\": [\"KnownProfiles\", \"ProfileDefinition\"], \"azure.profiles.multiapiclient\": [\"MultiApiClientMixin\"], \"azure.mgmt.core\": [\"AsyncARMPipelineClient\"]}, \"local\": {\"._configuration\": [\"SubscriptionClientConfiguration\"], \"._operations_mixin\": [\"SubscriptionClientOperationsMixin\"]}, \"thirdparty\": {\"msrest\": [\"Deserializer\", \"Serializer\"]}}, \"conditional\": {\"stdlib\": {\"typing\": [\"Any\", \"Optional\"]}}}" + "sync_imports": "{\"conditional\": {\"stdlib\": {\"typing\": [\"Any\", \"Optional\"]}}, \"regular\": {\"azurecore\": {\"azure.mgmt.core\": [\"ARMPipelineClient\"], \"azure.profiles\": [\"KnownProfiles\", \"ProfileDefinition\"], \"azure.profiles.multiapiclient\": [\"MultiApiClientMixin\"]}, \"local\": {\"._configuration\": [\"SubscriptionClientConfiguration\"], \".._serialization\": [\"Deserializer\", \"Serializer\"], \"._operations_mixin\": [\"SubscriptionClientOperationsMixin\"]}}, \"typing\": {\"azurecore\": {\"azure.core.credentials\": [\"TokenCredential\"]}}}", + "async_imports": "{\"conditional\": {\"stdlib\": {\"typing\": [\"Any\", \"Optional\"]}}, \"regular\": {\"azurecore\": {\"azure.mgmt.core\": [\"AsyncARMPipelineClient\"], \"azure.profiles\": [\"KnownProfiles\", \"ProfileDefinition\"], \"azure.profiles.multiapiclient\": [\"MultiApiClientMixin\"]}, \"local\": {\"._configuration\": [\"SubscriptionClientConfiguration\"], \"..._serialization\": [\"Deserializer\", \"Serializer\"], \"._operations_mixin\": [\"SubscriptionClientOperationsMixin\"]}}, \"typing\": {\"azurecore\": {\"azure.core.credentials_async\": [\"AsyncTokenCredential\"]}}}" }, "global_parameters": { "sync": { "credential": { - "signature": "credential, # type: \"TokenCredential\"", - "description": "Credential needed for the client to connect to Azure.", + "signature": "credential: \"TokenCredential\",", + "description": "Credential needed for the client to connect to Azure. Required.", "docstring_type": "~azure.core.credentials.TokenCredential", "required": true } @@ -25,7 +25,7 @@ "async": { "credential": { "signature": "credential: \"AsyncTokenCredential\",", - "description": "Credential needed for the client to connect to Azure.", + "description": "Credential needed for the client to connect to Azure. Required.", "docstring_type": "~azure.core.credentials_async.AsyncTokenCredential", "required": true } @@ -42,7 +42,7 @@ "required": false }, "base_url": { - "signature": "base_url=\"https://management.azure.com\", # type: str", + "signature": "base_url: str = \"https://management.azure.com\",", "description": "Service URL", "docstring_type": "str", "required": false @@ -89,20 +89,21 @@ "tenants": "TenantsOperations" }, "operation_mixins": { - "sync_imports": "{\"conditional\": {\"stdlib\": {\"typing\": [\"Any\", \"Optional\"]}}}", - "async_imports": "{\"conditional\": {\"stdlib\": {\"typing\": [\"Any\", \"Optional\"]}}}", + "sync_imports": "{\"conditional\": {\"stdlib\": {\"typing\": [\"Any\"]}}, \"regular\": {\"local\": {\".\": [[\"models\", \"_models\"]]}, \"stdlib\": {\"typing\": [\"IO\", \"Optional\", \"Union\"]}}}", + "async_imports": "{\"conditional\": {\"stdlib\": {\"typing\": [\"Any\"]}}, \"regular\": {\"local\": {\"..\": [[\"models\", \"_models\"]]}, \"stdlib\": {\"typing\": [\"IO\", \"Optional\", \"Union\"]}}}", "operations": { "check_resource_name" : { "sync": { - "signature": "def check_resource_name(\n self,\n resource_name_definition=None, # type: Optional[\"_models.ResourceName\"]\n **kwargs # type: Any\n):\n # type: (...) -\u003e \"_models.CheckResourceNameResult\"\n", - "doc": "\"\"\"Checks resource name validity.\n\nA resource name is valid if it is not a reserved word, does not contains a reserved word and\ndoes not start with a reserved word.\n\n:param resource_name_definition: Resource object with values for resource name and resource\n type. Default value is None.\n:type resource_name_definition:\n ~azure.mgmt.resource.subscriptions.v2021_01_01.models.ResourceName\n:keyword callable cls: A custom type or function that will be passed the direct response\n:return: CheckResourceNameResult, or the result of cls(response)\n:rtype: ~azure.mgmt.resource.subscriptions.v2021_01_01.models.CheckResourceNameResult\n:raises: ~azure.core.exceptions.HttpResponseError\n\"\"\"" + "signature": "def check_resource_name(\n self,\n resource_name_definition: Optional[Union[_models.ResourceName, IO]] = None,\n **kwargs: Any\n) -\u003e _models.CheckResourceNameResult:\n", + "doc": "\"\"\"Checks resource name validity.\n\nA resource name is valid if it is not a reserved word, does not contains a reserved word and\ndoes not start with a reserved word.\n\n:param resource_name_definition: Resource object with values for resource name and resource\n type. Is either a model type or a IO type. Default value is None.\n:type resource_name_definition:\n ~azure.mgmt.resource.subscriptions.v2021_01_01.models.ResourceName or IO\n:keyword content_type: Body Parameter content-type. Known values are: \u0027application/json\u0027.\n Default value is None.\n:paramtype content_type: str\n:keyword callable cls: A custom type or function that will be passed the direct response\n:return: CheckResourceNameResult or the result of cls(response)\n:rtype: ~azure.mgmt.resource.subscriptions.v2021_01_01.models.CheckResourceNameResult\n:raises ~azure.core.exceptions.HttpResponseError:\n\"\"\"", + "call": "resource_name_definition, **kwargs" }, "async": { "coroutine": true, - "signature": "async def check_resource_name(\n self,\n resource_name_definition: Optional[\"_models.ResourceName\"] = None,\n **kwargs: Any\n) -\u003e \"_models.CheckResourceNameResult\":\n", - "doc": "\"\"\"Checks resource name validity.\n\nA resource name is valid if it is not a reserved word, does not contains a reserved word and\ndoes not start with a reserved word.\n\n:param resource_name_definition: Resource object with values for resource name and resource\n type. Default value is None.\n:type resource_name_definition:\n ~azure.mgmt.resource.subscriptions.v2021_01_01.models.ResourceName\n:keyword callable cls: A custom type or function that will be passed the direct response\n:return: CheckResourceNameResult, or the result of cls(response)\n:rtype: ~azure.mgmt.resource.subscriptions.v2021_01_01.models.CheckResourceNameResult\n:raises: ~azure.core.exceptions.HttpResponseError\n\"\"\"" - }, - "call": "resource_name_definition" + "signature": "async def check_resource_name(\n self,\n resource_name_definition: Optional[Union[_models.ResourceName, IO]] = None,\n **kwargs: Any\n) -\u003e _models.CheckResourceNameResult:\n", + "doc": "\"\"\"Checks resource name validity.\n\nA resource name is valid if it is not a reserved word, does not contains a reserved word and\ndoes not start with a reserved word.\n\n:param resource_name_definition: Resource object with values for resource name and resource\n type. Is either a model type or a IO type. Default value is None.\n:type resource_name_definition:\n ~azure.mgmt.resource.subscriptions.v2021_01_01.models.ResourceName or IO\n:keyword content_type: Body Parameter content-type. Known values are: \u0027application/json\u0027.\n Default value is None.\n:paramtype content_type: str\n:keyword callable cls: A custom type or function that will be passed the direct response\n:return: CheckResourceNameResult or the result of cls(response)\n:rtype: ~azure.mgmt.resource.subscriptions.v2021_01_01.models.CheckResourceNameResult\n:raises ~azure.core.exceptions.HttpResponseError:\n\"\"\"", + "call": "resource_name_definition, **kwargs" + } } } } diff --git a/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/subscriptions/v2021_01_01/_patch.py b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/subscriptions/v2021_01_01/_patch.py index 74e48ecd07cf3..f99e77fef9861 100644 --- a/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/subscriptions/v2021_01_01/_patch.py +++ b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/subscriptions/v2021_01_01/_patch.py @@ -28,4 +28,4 @@ # This file is used for handwritten extensions to the generated code. Example: # https://github.com/Azure/azure-sdk-for-python/blob/main/doc/dev/customize_code/how-to-patch-sdk-code.md def patch_sdk(): - pass \ No newline at end of file + pass diff --git a/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/subscriptions/v2021_01_01/_subscription_client.py b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/subscriptions/v2021_01_01/_subscription_client.py index 40b6a4d5a6dec..00489566b2a56 100644 --- a/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/subscriptions/v2021_01_01/_subscription_client.py +++ b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/subscriptions/v2021_01_01/_subscription_client.py @@ -9,12 +9,11 @@ from copy import deepcopy from typing import Any, TYPE_CHECKING -from msrest import Deserializer, Serializer - from azure.core.rest import HttpRequest, HttpResponse from azure.mgmt.core import ARMPipelineClient from . import models +from .._serialization import Deserializer, Serializer from ._configuration import SubscriptionClientConfiguration from .operations import SubscriptionClientOperationsMixin, SubscriptionsOperations, TenantsOperations @@ -22,7 +21,8 @@ # pylint: disable=unused-import,ungrouped-imports from azure.core.credentials import TokenCredential -class SubscriptionClient(SubscriptionClientOperationsMixin): + +class SubscriptionClient(SubscriptionClientOperationsMixin): # pylint: disable=client-accepts-api-version-keyword """All resource groups and resources exist within subscriptions. These operation enable you get information about your subscriptions and tenants. A tenant is a dedicated instance of Azure Active Directory (Azure AD) for your organization. @@ -32,7 +32,7 @@ class SubscriptionClient(SubscriptionClientOperationsMixin): azure.mgmt.resource.subscriptions.v2021_01_01.operations.SubscriptionsOperations :ivar tenants: TenantsOperations operations :vartype tenants: azure.mgmt.resource.subscriptions.v2021_01_01.operations.TenantsOperations - :param credential: Credential needed for the client to connect to Azure. + :param credential: Credential needed for the client to connect to Azure. Required. :type credential: ~azure.core.credentials.TokenCredential :param base_url: Service URL. Default value is "https://management.azure.com". :type base_url: str @@ -42,10 +42,7 @@ class SubscriptionClient(SubscriptionClientOperationsMixin): """ def __init__( - self, - credential: "TokenCredential", - base_url: str = "https://management.azure.com", - **kwargs: Any + self, credential: "TokenCredential", base_url: str = "https://management.azure.com", **kwargs: Any ) -> None: self._config = SubscriptionClientConfiguration(credential=credential, **kwargs) self._client = ARMPipelineClient(base_url=base_url, config=self._config, **kwargs) @@ -57,12 +54,7 @@ def __init__( self.subscriptions = SubscriptionsOperations(self._client, self._config, self._serialize, self._deserialize) self.tenants = TenantsOperations(self._client, self._config, self._serialize, self._deserialize) - - def _send_request( - self, - request: HttpRequest, - **kwargs: Any - ) -> HttpResponse: + def _send_request(self, request: HttpRequest, **kwargs: Any) -> HttpResponse: """Runs the network request through the client's chained policies. >>> from azure.core.rest import HttpRequest @@ -71,7 +63,7 @@ def _send_request( >>> response = client._send_request(request) - For more information on this code flow, see https://aka.ms/azsdk/python/protocol/quickstart + For more information on this code flow, see https://aka.ms/azsdk/dpcodegen/python/send_request :param request: The network request you want to make. Required. :type request: ~azure.core.rest.HttpRequest diff --git a/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/subscriptions/v2021_01_01/_vendor.py b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/subscriptions/v2021_01_01/_vendor.py index 138f663c53a4e..71418db2686e7 100644 --- a/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/subscriptions/v2021_01_01/_vendor.py +++ b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/subscriptions/v2021_01_01/_vendor.py @@ -5,8 +5,20 @@ # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- +from abc import ABC +from typing import TYPE_CHECKING + from azure.core.pipeline.transport import HttpRequest +from ._configuration import SubscriptionClientConfiguration + +if TYPE_CHECKING: + # pylint: disable=unused-import,ungrouped-imports + from azure.core import PipelineClient + + from .._serialization import Deserializer, Serializer + + def _convert_request(request, files=None): data = request.content if not files else None request = HttpRequest(method=request.method, url=request.url, headers=request.headers, data=data) @@ -14,6 +26,7 @@ def _convert_request(request, files=None): request.set_formdata_body(files) return request + def _format_url_section(template, **kwargs): components = template.split("/") while components: @@ -21,7 +34,14 @@ def _format_url_section(template, **kwargs): 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 - ] + components = [c for c in formatted_components if "{}".format(key.args[0]) not in c] template = "/".join(components) + + +class MixinABC(ABC): + """DO NOT use this class. It is for internal typing use only.""" + + _client: "PipelineClient" + _config: SubscriptionClientConfiguration + _serialize: "Serializer" + _deserialize: "Deserializer" diff --git a/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/subscriptions/v2021_01_01/_version.py b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/subscriptions/v2021_01_01/_version.py index a012ac01c480c..e5754a47ce68f 100644 --- a/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/subscriptions/v2021_01_01/_version.py +++ b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/subscriptions/v2021_01_01/_version.py @@ -6,4 +6,4 @@ # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -VERSION = "21.1.0" +VERSION = "1.0.0b1" diff --git a/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/subscriptions/v2021_01_01/aio/__init__.py b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/subscriptions/v2021_01_01/aio/__init__.py index e95939087d442..5cfdafc74d6db 100644 --- a/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/subscriptions/v2021_01_01/aio/__init__.py +++ b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/subscriptions/v2021_01_01/aio/__init__.py @@ -7,9 +7,15 @@ # -------------------------------------------------------------------------- from ._subscription_client import SubscriptionClient -__all__ = ['SubscriptionClient'] -# `._patch.py` is used for handwritten extensions to the generated code -# Example: https://github.com/Azure/azure-sdk-for-python/blob/main/doc/dev/customize_code/how-to-patch-sdk-code.md -from ._patch import patch_sdk -patch_sdk() +try: + from ._patch import __all__ as _patch_all + from ._patch import * # type: ignore # pylint: disable=unused-wildcard-import +except ImportError: + _patch_all = [] +from ._patch import patch_sdk as _patch_sdk + +__all__ = ["SubscriptionClient"] +__all__.extend([p for p in _patch_all if p not in __all__]) + +_patch_sdk() diff --git a/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/subscriptions/v2021_01_01/aio/_configuration.py b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/subscriptions/v2021_01_01/aio/_configuration.py index 9adcb45133de6..0e4bd8ee27a2f 100644 --- a/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/subscriptions/v2021_01_01/aio/_configuration.py +++ b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/subscriptions/v2021_01_01/aio/_configuration.py @@ -25,42 +25,37 @@ class SubscriptionClientConfiguration(Configuration): # pylint: disable=too-man Note that all parameters used to create this instance are saved as instance attributes. - :param credential: Credential needed for the client to connect to Azure. + :param credential: Credential needed for the client to connect to Azure. Required. :type credential: ~azure.core.credentials_async.AsyncTokenCredential :keyword api_version: Api Version. Default value is "2021-01-01". Note that overriding this default value may result in unsupported behavior. :paramtype api_version: str """ - def __init__( - self, - credential: "AsyncTokenCredential", - **kwargs: Any - ) -> None: + def __init__(self, credential: "AsyncTokenCredential", **kwargs: Any) -> None: super(SubscriptionClientConfiguration, self).__init__(**kwargs) - api_version = kwargs.pop('api_version', "2021-01-01") # type: str + api_version = kwargs.pop("api_version", "2021-01-01") # type: str if credential is None: raise ValueError("Parameter 'credential' must not be None.") self.credential = credential self.api_version = api_version - self.credential_scopes = kwargs.pop('credential_scopes', ['https://management.azure.com/.default']) - kwargs.setdefault('sdk_moniker', 'mgmt-resource/{}'.format(VERSION)) + self.credential_scopes = kwargs.pop("credential_scopes", ["https://management.azure.com/.default"]) + kwargs.setdefault("sdk_moniker", "mgmt-resource/{}".format(VERSION)) self._configure(**kwargs) - 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) - self.logging_policy = kwargs.get('logging_policy') or policies.NetworkTraceLoggingPolicy(**kwargs) - self.http_logging_policy = kwargs.get('http_logging_policy') or ARMHttpLoggingPolicy(**kwargs) - self.retry_policy = kwargs.get('retry_policy') or policies.AsyncRetryPolicy(**kwargs) - self.custom_hook_policy = kwargs.get('custom_hook_policy') or policies.CustomHookPolicy(**kwargs) - self.redirect_policy = kwargs.get('redirect_policy') or policies.AsyncRedirectPolicy(**kwargs) - self.authentication_policy = kwargs.get('authentication_policy') + 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) + self.logging_policy = kwargs.get("logging_policy") or policies.NetworkTraceLoggingPolicy(**kwargs) + self.http_logging_policy = kwargs.get("http_logging_policy") or ARMHttpLoggingPolicy(**kwargs) + self.retry_policy = kwargs.get("retry_policy") or policies.AsyncRetryPolicy(**kwargs) + self.custom_hook_policy = kwargs.get("custom_hook_policy") or policies.CustomHookPolicy(**kwargs) + self.redirect_policy = kwargs.get("redirect_policy") or policies.AsyncRedirectPolicy(**kwargs) + self.authentication_policy = kwargs.get("authentication_policy") if self.credential and not self.authentication_policy: - self.authentication_policy = AsyncARMChallengeAuthenticationPolicy(self.credential, *self.credential_scopes, **kwargs) + self.authentication_policy = AsyncARMChallengeAuthenticationPolicy( + self.credential, *self.credential_scopes, **kwargs + ) diff --git a/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/subscriptions/v2021_01_01/aio/_patch.py b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/subscriptions/v2021_01_01/aio/_patch.py index 74e48ecd07cf3..f99e77fef9861 100644 --- a/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/subscriptions/v2021_01_01/aio/_patch.py +++ b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/subscriptions/v2021_01_01/aio/_patch.py @@ -28,4 +28,4 @@ # This file is used for handwritten extensions to the generated code. Example: # https://github.com/Azure/azure-sdk-for-python/blob/main/doc/dev/customize_code/how-to-patch-sdk-code.md def patch_sdk(): - pass \ No newline at end of file + pass diff --git a/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/subscriptions/v2021_01_01/aio/_subscription_client.py b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/subscriptions/v2021_01_01/aio/_subscription_client.py index bab3be1b51a12..8136239577c5e 100644 --- a/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/subscriptions/v2021_01_01/aio/_subscription_client.py +++ b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/subscriptions/v2021_01_01/aio/_subscription_client.py @@ -9,12 +9,11 @@ from copy import deepcopy from typing import Any, Awaitable, TYPE_CHECKING -from msrest import Deserializer, Serializer - from azure.core.rest import AsyncHttpResponse, HttpRequest from azure.mgmt.core import AsyncARMPipelineClient from .. import models +from ..._serialization import Deserializer, Serializer from ._configuration import SubscriptionClientConfiguration from .operations import SubscriptionClientOperationsMixin, SubscriptionsOperations, TenantsOperations @@ -22,7 +21,8 @@ # pylint: disable=unused-import,ungrouped-imports from azure.core.credentials_async import AsyncTokenCredential -class SubscriptionClient(SubscriptionClientOperationsMixin): + +class SubscriptionClient(SubscriptionClientOperationsMixin): # pylint: disable=client-accepts-api-version-keyword """All resource groups and resources exist within subscriptions. These operation enable you get information about your subscriptions and tenants. A tenant is a dedicated instance of Azure Active Directory (Azure AD) for your organization. @@ -33,7 +33,7 @@ class SubscriptionClient(SubscriptionClientOperationsMixin): :ivar tenants: TenantsOperations operations :vartype tenants: azure.mgmt.resource.subscriptions.v2021_01_01.aio.operations.TenantsOperations - :param credential: Credential needed for the client to connect to Azure. + :param credential: Credential needed for the client to connect to Azure. Required. :type credential: ~azure.core.credentials_async.AsyncTokenCredential :param base_url: Service URL. Default value is "https://management.azure.com". :type base_url: str @@ -43,10 +43,7 @@ class SubscriptionClient(SubscriptionClientOperationsMixin): """ def __init__( - self, - credential: "AsyncTokenCredential", - base_url: str = "https://management.azure.com", - **kwargs: Any + self, credential: "AsyncTokenCredential", base_url: str = "https://management.azure.com", **kwargs: Any ) -> None: self._config = SubscriptionClientConfiguration(credential=credential, **kwargs) self._client = AsyncARMPipelineClient(base_url=base_url, config=self._config, **kwargs) @@ -58,12 +55,7 @@ def __init__( self.subscriptions = SubscriptionsOperations(self._client, self._config, self._serialize, self._deserialize) self.tenants = TenantsOperations(self._client, self._config, self._serialize, self._deserialize) - - def _send_request( - self, - request: HttpRequest, - **kwargs: Any - ) -> Awaitable[AsyncHttpResponse]: + def _send_request(self, request: HttpRequest, **kwargs: Any) -> Awaitable[AsyncHttpResponse]: """Runs the network request through the client's chained policies. >>> from azure.core.rest import HttpRequest @@ -72,7 +64,7 @@ def _send_request( >>> response = await client._send_request(request) - For more information on this code flow, see https://aka.ms/azsdk/python/protocol/quickstart + For more information on this code flow, see https://aka.ms/azsdk/dpcodegen/python/send_request :param request: The network request you want to make. Required. :type request: ~azure.core.rest.HttpRequest diff --git a/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/subscriptions/v2021_01_01/aio/_vendor.py b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/subscriptions/v2021_01_01/aio/_vendor.py new file mode 100644 index 0000000000000..3c42eb44b5a3e --- /dev/null +++ b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/subscriptions/v2021_01_01/aio/_vendor.py @@ -0,0 +1,28 @@ +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- + +from abc import ABC +from typing import TYPE_CHECKING + +from azure.core.pipeline.transport import HttpRequest + +from ._configuration import SubscriptionClientConfiguration + +if TYPE_CHECKING: + # pylint: disable=unused-import,ungrouped-imports + from azure.core import AsyncPipelineClient + + from ..._serialization import Deserializer, Serializer + + +class MixinABC(ABC): + """DO NOT use this class. It is for internal typing use only.""" + + _client: "AsyncPipelineClient" + _config: SubscriptionClientConfiguration + _serialize: "Serializer" + _deserialize: "Deserializer" diff --git a/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/subscriptions/v2021_01_01/aio/operations/__init__.py b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/subscriptions/v2021_01_01/aio/operations/__init__.py index 686ea095d73e8..299b233e62c99 100644 --- a/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/subscriptions/v2021_01_01/aio/operations/__init__.py +++ b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/subscriptions/v2021_01_01/aio/operations/__init__.py @@ -10,8 +10,14 @@ from ._operations import TenantsOperations from ._operations import SubscriptionClientOperationsMixin +from ._patch import __all__ as _patch_all +from ._patch import * # type: ignore # pylint: disable=unused-wildcard-import +from ._patch import patch_sdk as _patch_sdk + __all__ = [ - 'SubscriptionsOperations', - 'TenantsOperations', - 'SubscriptionClientOperationsMixin', + "SubscriptionsOperations", + "TenantsOperations", + "SubscriptionClientOperationsMixin", ] +__all__.extend([p for p in _patch_all if p not in __all__]) +_patch_sdk() diff --git a/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/subscriptions/v2021_01_01/aio/operations/_operations.py b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/subscriptions/v2021_01_01/aio/operations/_operations.py index df40c715875e8..06619fc0b0953 100644 --- a/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/subscriptions/v2021_01_01/aio/operations/_operations.py +++ b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/subscriptions/v2021_01_01/aio/operations/_operations.py @@ -6,95 +6,117 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -from typing import Any, AsyncIterable, Callable, Dict, Optional, TypeVar +from typing import Any, AsyncIterable, Callable, Dict, IO, Optional, TypeVar, Union, overload +from urllib.parse import parse_qs, urljoin, urlparse from azure.core.async_paging import AsyncItemPaged, AsyncList -from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error +from azure.core.exceptions import ( + ClientAuthenticationError, + HttpResponseError, + ResourceExistsError, + ResourceNotFoundError, + ResourceNotModifiedError, + map_error, +) from azure.core.pipeline import PipelineResponse from azure.core.pipeline.transport import AsyncHttpResponse from azure.core.rest import HttpRequest from azure.core.tracing.decorator import distributed_trace from azure.core.tracing.decorator_async import distributed_trace_async +from azure.core.utils import case_insensitive_dict from azure.mgmt.core.exceptions import ARMErrorFormat from ... import models as _models from ..._vendor import _convert_request -from ...operations._operations import build_check_resource_name_request, build_subscriptions_check_zone_peers_request, build_subscriptions_get_request, build_subscriptions_list_locations_request, build_subscriptions_list_request, build_tenants_list_request -T = TypeVar('T') +from ...operations._operations import ( + build_check_resource_name_request, + build_subscriptions_check_zone_peers_request, + build_subscriptions_get_request, + build_subscriptions_list_locations_request, + build_subscriptions_list_request, + build_tenants_list_request, +) +from .._vendor import MixinABC + +T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] -class SubscriptionsOperations: - """SubscriptionsOperations async operations. - You should not instantiate this class directly. Instead, you should create a Client instance that - instantiates it for you and attaches it as an attribute. +class SubscriptionsOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. - :ivar models: Alias to model classes used in this operation group. - :type models: ~azure.mgmt.resource.subscriptions.v2021_01_01.models - :param client: Client for service requests. - :param config: Configuration of service client. - :param serializer: An object model serializer. - :param deserializer: An object model deserializer. + Instead, you should access the following operations through + :class:`~azure.mgmt.resource.subscriptions.v2021_01_01.aio.SubscriptionClient`'s + :attr:`subscriptions` attribute. """ models = _models - def __init__(self, client, config, serializer, deserializer) -> None: - self._client = client - self._serialize = serializer - self._deserialize = deserializer - self._config = config + def __init__(self, *args, **kwargs) -> None: + input_args = list(args) + self._client = input_args.pop(0) if input_args else kwargs.pop("client") + self._config = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") @distributed_trace def list_locations( - self, - subscription_id: str, - include_extended_locations: Optional[bool] = None, - **kwargs: Any - ) -> AsyncIterable["_models.LocationListResult"]: + self, subscription_id: str, include_extended_locations: Optional[bool] = None, **kwargs: Any + ) -> AsyncIterable["_models.Location"]: """Gets all available geo-locations. This operation provides all the locations that are available for resource providers; however, each resource provider may support a subset of this list. - :param subscription_id: The ID of the target subscription. + :param subscription_id: The ID of the target subscription. Required. :type subscription_id: str :param include_extended_locations: Whether to include extended locations. Default value is None. :type include_extended_locations: bool :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either LocationListResult or the result of cls(response) + :return: An iterator like instance of either Location or the result of cls(response) :rtype: - ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.resource.subscriptions.v2021_01_01.models.LocationListResult] - :raises: ~azure.core.exceptions.HttpResponseError + ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.resource.subscriptions.v2021_01_01.models.Location] + :raises ~azure.core.exceptions.HttpResponseError: """ - api_version = kwargs.pop('api_version', "2021-01-01") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-01-01")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[_models.LocationListResult] - cls = kwargs.pop('cls', None) # type: ClsType["_models.LocationListResult"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) + def prepare_request(next_link=None): if not next_link: - + request = build_subscriptions_list_locations_request( subscription_id=subscription_id, - api_version=api_version, include_extended_locations=include_extended_locations, - template_url=self.list_locations.metadata['url'], + api_version=api_version, + template_url=self.list_locations.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore else: - - request = build_subscriptions_list_locations_request( - subscription_id=subscription_id, - template_url=next_link, - ) + # make call to next link with the client's api-version + _parsed_next_link = urlparse(next_link) + _next_request_params = case_insensitive_dict(parse_qs(_parsed_next_link.query)) + _next_request_params["api-version"] = self._config.api_version + request = HttpRequest("GET", urljoin(next_link, _parsed_next_link.path), params=_next_request_params) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore request.method = "GET" return request @@ -108,10 +130,8 @@ async def extract_data(pipeline_response): async def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) response = pipeline_response.http_response @@ -121,103 +141,108 @@ async def get_next(next_link=None): return pipeline_response + return AsyncItemPaged(get_next, extract_data) - return AsyncItemPaged( - get_next, extract_data - ) - list_locations.metadata = {'url': "/subscriptions/{subscriptionId}/locations"} # type: ignore + list_locations.metadata = {"url": "/subscriptions/{subscriptionId}/locations"} # type: ignore @distributed_trace_async - async def get( - self, - subscription_id: str, - **kwargs: Any - ) -> "_models.Subscription": + async def get(self, subscription_id: str, **kwargs: Any) -> _models.Subscription: """Gets details about a specified subscription. - :param subscription_id: The ID of the target subscription. + :param subscription_id: The ID of the target subscription. Required. :type subscription_id: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: Subscription, or the result of cls(response) + :return: Subscription or the result of cls(response) :rtype: ~azure.mgmt.resource.subscriptions.v2021_01_01.models.Subscription - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.Subscription"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) - api_version = kwargs.pop('api_version', "2021-01-01") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-01-01")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[_models.Subscription] - request = build_subscriptions_get_request( subscription_id=subscription_id, api_version=api_version, - template_url=self.get.metadata['url'], + template_url=self.get.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) - deserialized = self._deserialize('Subscription', pipeline_response) + deserialized = self._deserialize("Subscription", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - get.metadata = {'url': "/subscriptions/{subscriptionId}"} # type: ignore - + get.metadata = {"url": "/subscriptions/{subscriptionId}"} # type: ignore @distributed_trace - def list( - self, - **kwargs: Any - ) -> AsyncIterable["_models.SubscriptionListResult"]: + def list(self, **kwargs: Any) -> AsyncIterable["_models.Subscription"]: """Gets all subscriptions for a tenant. :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either SubscriptionListResult or the result of - cls(response) + :return: An iterator like instance of either Subscription or the result of cls(response) :rtype: - ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.resource.subscriptions.v2021_01_01.models.SubscriptionListResult] - :raises: ~azure.core.exceptions.HttpResponseError + ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.resource.subscriptions.v2021_01_01.models.Subscription] + :raises ~azure.core.exceptions.HttpResponseError: """ - api_version = kwargs.pop('api_version', "2021-01-01") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-01-01")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[_models.SubscriptionListResult] - cls = kwargs.pop('cls', None) # type: ClsType["_models.SubscriptionListResult"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) + def prepare_request(next_link=None): if not next_link: - + request = build_subscriptions_list_request( api_version=api_version, - template_url=self.list.metadata['url'], + template_url=self.list.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore else: - - request = build_subscriptions_list_request( - template_url=next_link, - ) + # make call to next link with the client's api-version + _parsed_next_link = urlparse(next_link) + _next_request_params = case_insensitive_dict(parse_qs(_parsed_next_link.query)) + _next_request_params["api-version"] = self._config.api_version + request = HttpRequest("GET", urljoin(next_link, _parsed_next_link.path), params=_next_request_params) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore request.method = "GET" return request @@ -231,10 +256,8 @@ async def extract_data(pipeline_response): async def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) response = pipeline_response.http_response @@ -244,56 +267,113 @@ async def get_next(next_link=None): return pipeline_response + return AsyncItemPaged(get_next, extract_data) - return AsyncItemPaged( - get_next, extract_data - ) - list.metadata = {'url': "/subscriptions"} # type: ignore + list.metadata = {"url": "/subscriptions"} # type: ignore - @distributed_trace_async + @overload async def check_zone_peers( self, subscription_id: str, - parameters: "_models.CheckZonePeersRequest", + parameters: _models.CheckZonePeersRequest, + *, + content_type: str = "application/json", **kwargs: Any - ) -> "_models.CheckZonePeersResult": + ) -> _models.CheckZonePeersResult: """Compares a subscriptions logical zone mapping. - :param subscription_id: The ID of the target subscription. + :param subscription_id: The ID of the target subscription. Required. :type subscription_id: str - :param parameters: Parameters for checking zone peers. + :param parameters: Parameters for checking zone peers. Required. :type parameters: ~azure.mgmt.resource.subscriptions.v2021_01_01.models.CheckZonePeersRequest + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: CheckZonePeersResult, or the result of cls(response) + :return: CheckZonePeersResult or the result of cls(response) :rtype: ~azure.mgmt.resource.subscriptions.v2021_01_01.models.CheckZonePeersResult - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + async def check_zone_peers( + self, subscription_id: str, parameters: IO, *, content_type: str = "application/json", **kwargs: Any + ) -> _models.CheckZonePeersResult: + """Compares a subscriptions logical zone mapping. + + :param subscription_id: The ID of the target subscription. Required. + :type subscription_id: str + :param parameters: Parameters for checking zone peers. Required. + :type parameters: IO + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: CheckZonePeersResult or the result of cls(response) + :rtype: ~azure.mgmt.resource.subscriptions.v2021_01_01.models.CheckZonePeersResult + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace_async + async def check_zone_peers( + self, subscription_id: str, parameters: Union[_models.CheckZonePeersRequest, IO], **kwargs: Any + ) -> _models.CheckZonePeersResult: + """Compares a subscriptions logical zone mapping. + + :param subscription_id: The ID of the target subscription. Required. + :type subscription_id: str + :param parameters: Parameters for checking zone peers. Is either a model type or a IO type. + Required. + :type parameters: ~azure.mgmt.resource.subscriptions.v2021_01_01.models.CheckZonePeersRequest + or IO + :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. + Default value is None. + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: CheckZonePeersResult or the result of cls(response) + :rtype: ~azure.mgmt.resource.subscriptions.v2021_01_01.models.CheckZonePeersResult + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.CheckZonePeersResult"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', "2021-01-01") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-01-01")) # type: str + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.CheckZonePeersResult] - _json = self._serialize.body(parameters, 'CheckZonePeersRequest') + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(parameters, (IO, bytes)): + _content = parameters + else: + _json = self._serialize.body(parameters, "CheckZonePeersRequest") request = build_subscriptions_check_zone_peers_request( subscription_id=subscription_id, api_version=api_version, content_type=content_type, json=_json, - template_url=self.check_zone_peers.metadata['url'], + content=_content, + template_url=self.check_zone_peers.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200]: @@ -301,74 +381,79 @@ async def check_zone_peers( error = self._deserialize.failsafe_deserialize(_models.ErrorResponseAutoGenerated, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - deserialized = self._deserialize('CheckZonePeersResult', pipeline_response) + deserialized = self._deserialize("CheckZonePeersResult", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - check_zone_peers.metadata = {'url': "/subscriptions/{subscriptionId}/providers/Microsoft.Resources/checkZonePeers/"} # type: ignore + check_zone_peers.metadata = {"url": "/subscriptions/{subscriptionId}/providers/Microsoft.Resources/checkZonePeers/"} # type: ignore -class TenantsOperations: - """TenantsOperations async operations. - You should not instantiate this class directly. Instead, you should create a Client instance that - instantiates it for you and attaches it as an attribute. +class TenantsOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. - :ivar models: Alias to model classes used in this operation group. - :type models: ~azure.mgmt.resource.subscriptions.v2021_01_01.models - :param client: Client for service requests. - :param config: Configuration of service client. - :param serializer: An object model serializer. - :param deserializer: An object model deserializer. + Instead, you should access the following operations through + :class:`~azure.mgmt.resource.subscriptions.v2021_01_01.aio.SubscriptionClient`'s + :attr:`tenants` attribute. """ models = _models - def __init__(self, client, config, serializer, deserializer) -> None: - self._client = client - self._serialize = serializer - self._deserialize = deserializer - self._config = config + def __init__(self, *args, **kwargs) -> None: + input_args = list(args) + self._client = input_args.pop(0) if input_args else kwargs.pop("client") + self._config = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") @distributed_trace - def list( - self, - **kwargs: Any - ) -> AsyncIterable["_models.TenantListResult"]: + def list(self, **kwargs: Any) -> AsyncIterable["_models.TenantIdDescription"]: """Gets the tenants for your account. :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either TenantListResult or the result of cls(response) + :return: An iterator like instance of either TenantIdDescription or the result of cls(response) :rtype: - ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.resource.subscriptions.v2021_01_01.models.TenantListResult] - :raises: ~azure.core.exceptions.HttpResponseError + ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.resource.subscriptions.v2021_01_01.models.TenantIdDescription] + :raises ~azure.core.exceptions.HttpResponseError: """ - api_version = kwargs.pop('api_version', "2021-01-01") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-01-01")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[_models.TenantListResult] - cls = kwargs.pop('cls', None) # type: ClsType["_models.TenantListResult"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) + def prepare_request(next_link=None): if not next_link: - + request = build_tenants_list_request( api_version=api_version, - template_url=self.list.metadata['url'], + template_url=self.list.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore else: - - request = build_tenants_list_request( - template_url=next_link, - ) + # make call to next link with the client's api-version + _parsed_next_link = urlparse(next_link) + _next_request_params = case_insensitive_dict(parse_qs(_parsed_next_link.query)) + _next_request_params["api-version"] = self._config.api_version + request = HttpRequest("GET", urljoin(next_link, _parsed_next_link.path), params=_next_request_params) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore request.method = "GET" return request @@ -382,10 +467,8 @@ async def extract_data(pipeline_response): async def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) response = pipeline_response.http_response @@ -395,19 +478,20 @@ async def get_next(next_link=None): return pipeline_response + return AsyncItemPaged(get_next, extract_data) - return AsyncItemPaged( - get_next, extract_data - ) - list.metadata = {'url': "/tenants"} # type: ignore -class SubscriptionClientOperationsMixin: + list.metadata = {"url": "/tenants"} # type: ignore - @distributed_trace_async + +class SubscriptionClientOperationsMixin(MixinABC): + @overload async def check_resource_name( self, - resource_name_definition: Optional["_models.ResourceName"] = None, + resource_name_definition: Optional[_models.ResourceName] = None, + *, + content_type: str = "application/json", **kwargs: Any - ) -> "_models.CheckResourceNameResult": + ) -> _models.CheckResourceNameResult: """Checks resource name validity. A resource name is valid if it is not a reserved word, does not contains a reserved word and @@ -417,51 +501,110 @@ async def check_resource_name( type. Default value is None. :type resource_name_definition: ~azure.mgmt.resource.subscriptions.v2021_01_01.models.ResourceName + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: CheckResourceNameResult or the result of cls(response) + :rtype: ~azure.mgmt.resource.subscriptions.v2021_01_01.models.CheckResourceNameResult + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + async def check_resource_name( + self, resource_name_definition: Optional[IO] = None, *, content_type: str = "application/json", **kwargs: Any + ) -> _models.CheckResourceNameResult: + """Checks resource name validity. + + A resource name is valid if it is not a reserved word, does not contains a reserved word and + does not start with a reserved word. + + :param resource_name_definition: Resource object with values for resource name and resource + type. Default value is None. + :type resource_name_definition: IO + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: CheckResourceNameResult, or the result of cls(response) + :return: CheckResourceNameResult or the result of cls(response) :rtype: ~azure.mgmt.resource.subscriptions.v2021_01_01.models.CheckResourceNameResult - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace_async + async def check_resource_name( + self, resource_name_definition: Optional[Union[_models.ResourceName, IO]] = None, **kwargs: Any + ) -> _models.CheckResourceNameResult: + """Checks resource name validity. + + A resource name is valid if it is not a reserved word, does not contains a reserved word and + does not start with a reserved word. + + :param resource_name_definition: Resource object with values for resource name and resource + type. Is either a model type or a IO type. Default value is None. + :type resource_name_definition: + ~azure.mgmt.resource.subscriptions.v2021_01_01.models.ResourceName or IO + :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. + Default value is None. + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: CheckResourceNameResult or the result of cls(response) + :rtype: ~azure.mgmt.resource.subscriptions.v2021_01_01.models.CheckResourceNameResult + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.CheckResourceNameResult"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', "2021-01-01") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-01-01")) # type: str + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.CheckResourceNameResult] - if resource_name_definition is not None: - _json = self._serialize.body(resource_name_definition, 'ResourceName') + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(resource_name_definition, (IO, bytes)): + _content = resource_name_definition else: - _json = None + if resource_name_definition is not None: + _json = self._serialize.body(resource_name_definition, "ResourceName") + else: + _json = None request = build_check_resource_name_request( api_version=api_version, content_type=content_type, json=_json, - template_url=self.check_resource_name.metadata['url'], + content=_content, + template_url=self.check_resource_name.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) - deserialized = self._deserialize('CheckResourceNameResult', pipeline_response) + deserialized = self._deserialize("CheckResourceNameResult", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - check_resource_name.metadata = {'url': "/providers/Microsoft.Resources/checkResourceName"} # type: ignore - + check_resource_name.metadata = {"url": "/providers/Microsoft.Resources/checkResourceName"} # type: ignore diff --git a/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/subscriptions/v2021_01_01/aio/operations/_patch.py b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/subscriptions/v2021_01_01/aio/operations/_patch.py new file mode 100644 index 0000000000000..f7dd32510333d --- /dev/null +++ b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/subscriptions/v2021_01_01/aio/operations/_patch.py @@ -0,0 +1,20 @@ +# ------------------------------------ +# Copyright (c) Microsoft Corporation. +# Licensed under the MIT License. +# ------------------------------------ +"""Customize generated code here. + +Follow our quickstart for examples: https://aka.ms/azsdk/python/dpcodegen/python/customize +""" +from typing import List + +__all__: List[str] = [] # Add all objects you want publicly available to users at this package level + + +def patch_sdk(): + """Do not remove from this file. + + `patch_sdk` is a last resort escape hatch that allows you to do customizations + you can't accomplish using the techniques described in + https://aka.ms/azsdk/python/dpcodegen/python/customize + """ diff --git a/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/subscriptions/v2021_01_01/models/__init__.py b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/subscriptions/v2021_01_01/models/__init__.py index 102c92164d9a1..5afce33ac81b9 100644 --- a/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/subscriptions/v2021_01_01/models/__init__.py +++ b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/subscriptions/v2021_01_01/models/__init__.py @@ -30,46 +30,48 @@ from ._models_py3 import TenantIdDescription from ._models_py3 import TenantListResult - -from ._subscription_client_enums import ( - LocationType, - RegionCategory, - RegionType, - ResourceNameStatus, - SpendingLimit, - SubscriptionState, - TenantCategory, -) +from ._subscription_client_enums import LocationType +from ._subscription_client_enums import RegionCategory +from ._subscription_client_enums import RegionType +from ._subscription_client_enums import ResourceNameStatus +from ._subscription_client_enums import SpendingLimit +from ._subscription_client_enums import SubscriptionState +from ._subscription_client_enums import TenantCategory +from ._patch import __all__ as _patch_all +from ._patch import * # type: ignore # pylint: disable=unused-wildcard-import +from ._patch import patch_sdk as _patch_sdk __all__ = [ - 'AvailabilityZonePeers', - 'CheckResourceNameResult', - 'CheckZonePeersRequest', - 'CheckZonePeersResult', - 'ErrorAdditionalInfo', - 'ErrorDetail', - 'ErrorResponse', - 'ErrorResponseAutoGenerated', - 'Location', - 'LocationListResult', - 'LocationMetadata', - 'ManagedByTenant', - 'Operation', - 'OperationDisplay', - 'OperationListResult', - 'PairedRegion', - 'Peers', - 'ResourceName', - 'Subscription', - 'SubscriptionListResult', - 'SubscriptionPolicies', - 'TenantIdDescription', - 'TenantListResult', - 'LocationType', - 'RegionCategory', - 'RegionType', - 'ResourceNameStatus', - 'SpendingLimit', - 'SubscriptionState', - 'TenantCategory', + "AvailabilityZonePeers", + "CheckResourceNameResult", + "CheckZonePeersRequest", + "CheckZonePeersResult", + "ErrorAdditionalInfo", + "ErrorDetail", + "ErrorResponse", + "ErrorResponseAutoGenerated", + "Location", + "LocationListResult", + "LocationMetadata", + "ManagedByTenant", + "Operation", + "OperationDisplay", + "OperationListResult", + "PairedRegion", + "Peers", + "ResourceName", + "Subscription", + "SubscriptionListResult", + "SubscriptionPolicies", + "TenantIdDescription", + "TenantListResult", + "LocationType", + "RegionCategory", + "RegionType", + "ResourceNameStatus", + "SpendingLimit", + "SubscriptionState", + "TenantCategory", ] +__all__.extend([p for p in _patch_all if p not in __all__]) +_patch_sdk() diff --git a/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/subscriptions/v2021_01_01/models/_models_py3.py b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/subscriptions/v2021_01_01/models/_models_py3.py index db2bc68126036..1c74327346011 100644 --- a/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/subscriptions/v2021_01_01/models/_models_py3.py +++ b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/subscriptions/v2021_01_01/models/_models_py3.py @@ -1,4 +1,5 @@ # coding=utf-8 +# pylint: disable=too-many-lines # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. # Licensed under the MIT License. See License.txt in the project root for license information. @@ -6,15 +7,16 @@ # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -from typing import Dict, List, Optional, Union +from typing import Dict, List, Optional, TYPE_CHECKING, Union -from azure.core.exceptions import HttpResponseError -import msrest.serialization +from ... import _serialization -from ._subscription_client_enums import * +if TYPE_CHECKING: + # pylint: disable=unused-import,ungrouped-imports + from .. import models as _models -class AvailabilityZonePeers(msrest.serialization.Model): +class AvailabilityZonePeers(_serialization.Model): """List of availability zones shared by the subscriptions. Variables are only populated by the server, and will be ignored when sending a request. @@ -26,46 +28,41 @@ class AvailabilityZonePeers(msrest.serialization.Model): """ _validation = { - 'availability_zone': {'readonly': True}, + "availability_zone": {"readonly": True}, } _attribute_map = { - 'availability_zone': {'key': 'availabilityZone', 'type': 'str'}, - 'peers': {'key': 'peers', 'type': '[Peers]'}, + "availability_zone": {"key": "availabilityZone", "type": "str"}, + "peers": {"key": "peers", "type": "[Peers]"}, } - def __init__( - self, - *, - peers: Optional[List["Peers"]] = None, - **kwargs - ): + def __init__(self, *, peers: Optional[List["_models.Peers"]] = None, **kwargs): """ :keyword peers: Details of shared availability zone. :paramtype peers: list[~azure.mgmt.resource.subscriptions.v2021_01_01.models.Peers] """ - super(AvailabilityZonePeers, self).__init__(**kwargs) + super().__init__(**kwargs) self.availability_zone = None self.peers = peers -class CheckResourceNameResult(msrest.serialization.Model): +class CheckResourceNameResult(_serialization.Model): """Resource Name valid if not a reserved word, does not contain a reserved word and does not start with a reserved word. :ivar name: Name of Resource. :vartype name: str :ivar type: Type of Resource. :vartype type: str - :ivar status: Is the resource name Allowed or Reserved. Possible values include: "Allowed", + :ivar status: Is the resource name Allowed or Reserved. Known values are: "Allowed" and "Reserved". :vartype status: str or ~azure.mgmt.resource.subscriptions.v2021_01_01.models.ResourceNameStatus """ _attribute_map = { - 'name': {'key': 'name', 'type': 'str'}, - 'type': {'key': 'type', 'type': 'str'}, - 'status': {'key': 'status', 'type': 'str'}, + "name": {"key": "name", "type": "str"}, + "type": {"key": "type", "type": "str"}, + "status": {"key": "status", "type": "str"}, } def __init__( @@ -73,7 +70,7 @@ def __init__( *, name: Optional[str] = None, type: Optional[str] = None, - status: Optional[Union[str, "ResourceNameStatus"]] = None, + status: Optional[Union[str, "_models.ResourceNameStatus"]] = None, **kwargs ): """ @@ -81,18 +78,18 @@ def __init__( :paramtype name: str :keyword type: Type of Resource. :paramtype type: str - :keyword status: Is the resource name Allowed or Reserved. Possible values include: "Allowed", + :keyword status: Is the resource name Allowed or Reserved. Known values are: "Allowed" and "Reserved". :paramtype status: str or ~azure.mgmt.resource.subscriptions.v2021_01_01.models.ResourceNameStatus """ - super(CheckResourceNameResult, self).__init__(**kwargs) + super().__init__(**kwargs) self.name = name self.type = type self.status = status -class CheckZonePeersRequest(msrest.serialization.Model): +class CheckZonePeersRequest(_serialization.Model): """Check zone peers request parameters. :ivar location: The Microsoft location. @@ -102,29 +99,23 @@ class CheckZonePeersRequest(msrest.serialization.Model): """ _attribute_map = { - 'location': {'key': 'location', 'type': 'str'}, - 'subscription_ids': {'key': 'subscriptionIds', 'type': '[str]'}, + "location": {"key": "location", "type": "str"}, + "subscription_ids": {"key": "subscriptionIds", "type": "[str]"}, } - def __init__( - self, - *, - location: Optional[str] = None, - subscription_ids: Optional[List[str]] = None, - **kwargs - ): + def __init__(self, *, location: Optional[str] = None, subscription_ids: Optional[List[str]] = None, **kwargs): """ :keyword location: The Microsoft location. :paramtype location: str :keyword subscription_ids: The peer Microsoft Azure subscription ID. :paramtype subscription_ids: list[str] """ - super(CheckZonePeersRequest, self).__init__(**kwargs) + super().__init__(**kwargs) self.location = location self.subscription_ids = subscription_ids -class CheckZonePeersResult(msrest.serialization.Model): +class CheckZonePeersResult(_serialization.Model): """Result of the Check zone peers operation. Variables are only populated by the server, and will be ignored when sending a request. @@ -139,20 +130,20 @@ class CheckZonePeersResult(msrest.serialization.Model): """ _validation = { - 'subscription_id': {'readonly': True}, + "subscription_id": {"readonly": True}, } _attribute_map = { - 'subscription_id': {'key': 'subscriptionId', 'type': 'str'}, - 'location': {'key': 'location', 'type': 'str'}, - 'availability_zone_peers': {'key': 'availabilityZonePeers', 'type': '[AvailabilityZonePeers]'}, + "subscription_id": {"key": "subscriptionId", "type": "str"}, + "location": {"key": "location", "type": "str"}, + "availability_zone_peers": {"key": "availabilityZonePeers", "type": "[AvailabilityZonePeers]"}, } def __init__( self, *, location: Optional[str] = None, - availability_zone_peers: Optional[List["AvailabilityZonePeers"]] = None, + availability_zone_peers: Optional[List["_models.AvailabilityZonePeers"]] = None, **kwargs ): """ @@ -162,13 +153,13 @@ def __init__( :paramtype availability_zone_peers: list[~azure.mgmt.resource.subscriptions.v2021_01_01.models.AvailabilityZonePeers] """ - super(CheckZonePeersResult, self).__init__(**kwargs) + super().__init__(**kwargs) self.subscription_id = None self.location = location self.availability_zone_peers = availability_zone_peers -class ErrorAdditionalInfo(msrest.serialization.Model): +class ErrorAdditionalInfo(_serialization.Model): """The resource management error additional info. Variables are only populated by the server, and will be ignored when sending a request. @@ -176,31 +167,27 @@ class ErrorAdditionalInfo(msrest.serialization.Model): :ivar type: The additional info type. :vartype type: str :ivar info: The additional info. - :vartype info: any + :vartype info: JSON """ _validation = { - 'type': {'readonly': True}, - 'info': {'readonly': True}, + "type": {"readonly": True}, + "info": {"readonly": True}, } _attribute_map = { - 'type': {'key': 'type', 'type': 'str'}, - 'info': {'key': 'info', 'type': 'object'}, + "type": {"key": "type", "type": "str"}, + "info": {"key": "info", "type": "object"}, } - def __init__( - self, - **kwargs - ): - """ - """ - super(ErrorAdditionalInfo, self).__init__(**kwargs) + def __init__(self, **kwargs): + """ """ + super().__init__(**kwargs) self.type = None self.info = None -class ErrorDetail(msrest.serialization.Model): +class ErrorDetail(_serialization.Model): """The error detail. Variables are only populated by the server, and will be ignored when sending a request. @@ -219,28 +206,24 @@ class ErrorDetail(msrest.serialization.Model): """ _validation = { - 'code': {'readonly': True}, - 'message': {'readonly': True}, - 'target': {'readonly': True}, - 'details': {'readonly': True}, - 'additional_info': {'readonly': True}, + "code": {"readonly": True}, + "message": {"readonly": True}, + "target": {"readonly": True}, + "details": {"readonly": True}, + "additional_info": {"readonly": True}, } _attribute_map = { - 'code': {'key': 'code', 'type': 'str'}, - 'message': {'key': 'message', 'type': 'str'}, - 'target': {'key': 'target', 'type': 'str'}, - 'details': {'key': 'details', 'type': '[ErrorDetail]'}, - 'additional_info': {'key': 'additionalInfo', 'type': '[ErrorAdditionalInfo]'}, + "code": {"key": "code", "type": "str"}, + "message": {"key": "message", "type": "str"}, + "target": {"key": "target", "type": "str"}, + "details": {"key": "details", "type": "[ErrorDetail]"}, + "additional_info": {"key": "additionalInfo", "type": "[ErrorAdditionalInfo]"}, } - def __init__( - self, - **kwargs - ): - """ - """ - super(ErrorDetail, self).__init__(**kwargs) + def __init__(self, **kwargs): + """ """ + super().__init__(**kwargs) self.code = None self.message = None self.target = None @@ -248,7 +231,7 @@ def __init__( self.additional_info = None -class ErrorResponse(msrest.serialization.Model): +class ErrorResponse(_serialization.Model): """Common error response for all Azure Resource Manager APIs to return error details for failed operations. (This also follows the OData error response format.). Variables are only populated by the server, and will be ignored when sending a request. @@ -267,28 +250,24 @@ class ErrorResponse(msrest.serialization.Model): """ _validation = { - 'code': {'readonly': True}, - 'message': {'readonly': True}, - 'target': {'readonly': True}, - 'details': {'readonly': True}, - 'additional_info': {'readonly': True}, + "code": {"readonly": True}, + "message": {"readonly": True}, + "target": {"readonly": True}, + "details": {"readonly": True}, + "additional_info": {"readonly": True}, } _attribute_map = { - 'code': {'key': 'code', 'type': 'str'}, - 'message': {'key': 'message', 'type': 'str'}, - 'target': {'key': 'target', 'type': 'str'}, - 'details': {'key': 'details', 'type': '[ErrorResponse]'}, - 'additional_info': {'key': 'additionalInfo', 'type': '[ErrorAdditionalInfo]'}, + "code": {"key": "code", "type": "str"}, + "message": {"key": "message", "type": "str"}, + "target": {"key": "target", "type": "str"}, + "details": {"key": "details", "type": "[ErrorResponse]"}, + "additional_info": {"key": "additionalInfo", "type": "[ErrorAdditionalInfo]"}, } - def __init__( - self, - **kwargs - ): - """ - """ - super(ErrorResponse, self).__init__(**kwargs) + def __init__(self, **kwargs): + """ """ + super().__init__(**kwargs) self.code = None self.message = None self.target = None @@ -296,7 +275,7 @@ def __init__( self.additional_info = None -class ErrorResponseAutoGenerated(msrest.serialization.Model): +class ErrorResponseAutoGenerated(_serialization.Model): """Common error response for all Azure Resource Manager APIs to return error details for failed operations. (This also follows the OData error response format.). :ivar error: The error object. @@ -304,24 +283,19 @@ class ErrorResponseAutoGenerated(msrest.serialization.Model): """ _attribute_map = { - 'error': {'key': 'error', 'type': 'ErrorDetail'}, + "error": {"key": "error", "type": "ErrorDetail"}, } - def __init__( - self, - *, - error: Optional["ErrorDetail"] = None, - **kwargs - ): + def __init__(self, *, error: Optional["_models.ErrorDetail"] = None, **kwargs): """ :keyword error: The error object. :paramtype error: ~azure.mgmt.resource.subscriptions.v2021_01_01.models.ErrorDetail """ - super(ErrorResponseAutoGenerated, self).__init__(**kwargs) + super().__init__(**kwargs) self.error = error -class Location(msrest.serialization.Model): +class Location(_serialization.Model): """Location information. Variables are only populated by the server, and will be ignored when sending a request. @@ -333,7 +307,7 @@ class Location(msrest.serialization.Model): :vartype subscription_id: str :ivar name: The location name. :vartype name: str - :ivar type: The location type. Possible values include: "Region", "EdgeZone". + :ivar type: The location type. Known values are: "Region" and "EdgeZone". :vartype type: str or ~azure.mgmt.resource.subscriptions.v2021_01_01.models.LocationType :ivar display_name: The display name of the location. :vartype display_name: str @@ -344,35 +318,30 @@ class Location(msrest.serialization.Model): """ _validation = { - 'id': {'readonly': True}, - 'subscription_id': {'readonly': True}, - 'name': {'readonly': True}, - 'type': {'readonly': True}, - 'display_name': {'readonly': True}, - 'regional_display_name': {'readonly': True}, + "id": {"readonly": True}, + "subscription_id": {"readonly": True}, + "name": {"readonly": True}, + "type": {"readonly": True}, + "display_name": {"readonly": True}, + "regional_display_name": {"readonly": True}, } _attribute_map = { - 'id': {'key': 'id', 'type': 'str'}, - 'subscription_id': {'key': 'subscriptionId', 'type': 'str'}, - 'name': {'key': 'name', 'type': 'str'}, - 'type': {'key': 'type', 'type': 'str'}, - 'display_name': {'key': 'displayName', 'type': 'str'}, - 'regional_display_name': {'key': 'regionalDisplayName', 'type': 'str'}, - 'metadata': {'key': 'metadata', 'type': 'LocationMetadata'}, + "id": {"key": "id", "type": "str"}, + "subscription_id": {"key": "subscriptionId", "type": "str"}, + "name": {"key": "name", "type": "str"}, + "type": {"key": "type", "type": "str"}, + "display_name": {"key": "displayName", "type": "str"}, + "regional_display_name": {"key": "regionalDisplayName", "type": "str"}, + "metadata": {"key": "metadata", "type": "LocationMetadata"}, } - def __init__( - self, - *, - metadata: Optional["LocationMetadata"] = None, - **kwargs - ): + def __init__(self, *, metadata: Optional["_models.LocationMetadata"] = None, **kwargs): """ :keyword metadata: Metadata of the location, such as lat/long, paired region, and others. :paramtype metadata: ~azure.mgmt.resource.subscriptions.v2021_01_01.models.LocationMetadata """ - super(Location, self).__init__(**kwargs) + super().__init__(**kwargs) self.id = None self.subscription_id = None self.name = None @@ -382,7 +351,7 @@ def __init__( self.metadata = metadata -class LocationListResult(msrest.serialization.Model): +class LocationListResult(_serialization.Model): """Location list operation response. :ivar value: An array of locations. @@ -390,32 +359,27 @@ class LocationListResult(msrest.serialization.Model): """ _attribute_map = { - 'value': {'key': 'value', 'type': '[Location]'}, + "value": {"key": "value", "type": "[Location]"}, } - def __init__( - self, - *, - value: Optional[List["Location"]] = None, - **kwargs - ): + def __init__(self, *, value: Optional[List["_models.Location"]] = None, **kwargs): """ :keyword value: An array of locations. :paramtype value: list[~azure.mgmt.resource.subscriptions.v2021_01_01.models.Location] """ - super(LocationListResult, self).__init__(**kwargs) + super().__init__(**kwargs) self.value = value -class LocationMetadata(msrest.serialization.Model): +class LocationMetadata(_serialization.Model): """Location metadata information. Variables are only populated by the server, and will be ignored when sending a request. - :ivar region_type: The type of the region. Possible values include: "Physical", "Logical". + :ivar region_type: The type of the region. Known values are: "Physical" and "Logical". :vartype region_type: str or ~azure.mgmt.resource.subscriptions.v2021_01_01.models.RegionType - :ivar region_category: The category of the region. Possible values include: "Recommended", - "Extended", "Other". + :ivar region_category: The category of the region. Known values are: "Recommended", "Extended", + and "Other". :vartype region_category: str or ~azure.mgmt.resource.subscriptions.v2021_01_01.models.RegionCategory :ivar geography_group: The geography group of the location. @@ -434,38 +398,33 @@ class LocationMetadata(msrest.serialization.Model): """ _validation = { - 'region_type': {'readonly': True}, - 'region_category': {'readonly': True}, - 'geography_group': {'readonly': True}, - 'longitude': {'readonly': True}, - 'latitude': {'readonly': True}, - 'physical_location': {'readonly': True}, - 'home_location': {'readonly': True}, + "region_type": {"readonly": True}, + "region_category": {"readonly": True}, + "geography_group": {"readonly": True}, + "longitude": {"readonly": True}, + "latitude": {"readonly": True}, + "physical_location": {"readonly": True}, + "home_location": {"readonly": True}, } _attribute_map = { - 'region_type': {'key': 'regionType', 'type': 'str'}, - 'region_category': {'key': 'regionCategory', 'type': 'str'}, - 'geography_group': {'key': 'geographyGroup', 'type': 'str'}, - 'longitude': {'key': 'longitude', 'type': 'str'}, - 'latitude': {'key': 'latitude', 'type': 'str'}, - 'physical_location': {'key': 'physicalLocation', 'type': 'str'}, - 'paired_region': {'key': 'pairedRegion', 'type': '[PairedRegion]'}, - 'home_location': {'key': 'homeLocation', 'type': 'str'}, + "region_type": {"key": "regionType", "type": "str"}, + "region_category": {"key": "regionCategory", "type": "str"}, + "geography_group": {"key": "geographyGroup", "type": "str"}, + "longitude": {"key": "longitude", "type": "str"}, + "latitude": {"key": "latitude", "type": "str"}, + "physical_location": {"key": "physicalLocation", "type": "str"}, + "paired_region": {"key": "pairedRegion", "type": "[PairedRegion]"}, + "home_location": {"key": "homeLocation", "type": "str"}, } - def __init__( - self, - *, - paired_region: Optional[List["PairedRegion"]] = None, - **kwargs - ): + def __init__(self, *, paired_region: Optional[List["_models.PairedRegion"]] = None, **kwargs): """ :keyword paired_region: The regions paired to this region. :paramtype paired_region: list[~azure.mgmt.resource.subscriptions.v2021_01_01.models.PairedRegion] """ - super(LocationMetadata, self).__init__(**kwargs) + super().__init__(**kwargs) self.region_type = None self.region_category = None self.geography_group = None @@ -476,7 +435,7 @@ def __init__( self.home_location = None -class ManagedByTenant(msrest.serialization.Model): +class ManagedByTenant(_serialization.Model): """Information about a tenant managing the subscription. Variables are only populated by the server, and will be ignored when sending a request. @@ -486,24 +445,20 @@ class ManagedByTenant(msrest.serialization.Model): """ _validation = { - 'tenant_id': {'readonly': True}, + "tenant_id": {"readonly": True}, } _attribute_map = { - 'tenant_id': {'key': 'tenantId', 'type': 'str'}, + "tenant_id": {"key": "tenantId", "type": "str"}, } - def __init__( - self, - **kwargs - ): - """ - """ - super(ManagedByTenant, self).__init__(**kwargs) + def __init__(self, **kwargs): + """ """ + super().__init__(**kwargs) self.tenant_id = None -class Operation(msrest.serialization.Model): +class Operation(_serialization.Model): """Microsoft.Resources operation. :ivar name: Operation name: {provider}/{resource}/{operation}. @@ -513,29 +468,23 @@ class Operation(msrest.serialization.Model): """ _attribute_map = { - 'name': {'key': 'name', 'type': 'str'}, - 'display': {'key': 'display', 'type': 'OperationDisplay'}, + "name": {"key": "name", "type": "str"}, + "display": {"key": "display", "type": "OperationDisplay"}, } - def __init__( - self, - *, - name: Optional[str] = None, - display: Optional["OperationDisplay"] = None, - **kwargs - ): + def __init__(self, *, name: Optional[str] = None, display: Optional["_models.OperationDisplay"] = None, **kwargs): """ :keyword name: Operation name: {provider}/{resource}/{operation}. :paramtype name: str :keyword display: The object that represents the operation. :paramtype display: ~azure.mgmt.resource.subscriptions.v2021_01_01.models.OperationDisplay """ - super(Operation, self).__init__(**kwargs) + super().__init__(**kwargs) self.name = name self.display = display -class OperationDisplay(msrest.serialization.Model): +class OperationDisplay(_serialization.Model): """The object that represents the operation. :ivar provider: Service provider: Microsoft.Resources. @@ -549,10 +498,10 @@ class OperationDisplay(msrest.serialization.Model): """ _attribute_map = { - 'provider': {'key': 'provider', 'type': 'str'}, - 'resource': {'key': 'resource', 'type': 'str'}, - 'operation': {'key': 'operation', 'type': 'str'}, - 'description': {'key': 'description', 'type': 'str'}, + "provider": {"key": "provider", "type": "str"}, + "resource": {"key": "resource", "type": "str"}, + "operation": {"key": "operation", "type": "str"}, + "description": {"key": "description", "type": "str"}, } def __init__( @@ -574,14 +523,14 @@ def __init__( :keyword description: Description of the operation. :paramtype description: str """ - super(OperationDisplay, self).__init__(**kwargs) + super().__init__(**kwargs) self.provider = provider self.resource = resource self.operation = operation self.description = description -class OperationListResult(msrest.serialization.Model): +class OperationListResult(_serialization.Model): """Result of the request to list Microsoft.Resources operations. It contains a list of operations and a URL link to get the next set of results. :ivar value: List of Microsoft.Resources operations. @@ -591,29 +540,23 @@ class OperationListResult(msrest.serialization.Model): """ _attribute_map = { - 'value': {'key': 'value', 'type': '[Operation]'}, - 'next_link': {'key': 'nextLink', 'type': 'str'}, + "value": {"key": "value", "type": "[Operation]"}, + "next_link": {"key": "nextLink", "type": "str"}, } - def __init__( - self, - *, - value: Optional[List["Operation"]] = None, - next_link: Optional[str] = None, - **kwargs - ): + def __init__(self, *, value: Optional[List["_models.Operation"]] = None, next_link: Optional[str] = None, **kwargs): """ :keyword value: List of Microsoft.Resources operations. :paramtype value: list[~azure.mgmt.resource.subscriptions.v2021_01_01.models.Operation] :keyword next_link: URL to get the next set of operation list results if there are any. :paramtype next_link: str """ - super(OperationListResult, self).__init__(**kwargs) + super().__init__(**kwargs) self.value = value self.next_link = next_link -class PairedRegion(msrest.serialization.Model): +class PairedRegion(_serialization.Model): """Information regarding paired region. Variables are only populated by the server, and will be ignored when sending a request. @@ -628,30 +571,26 @@ class PairedRegion(msrest.serialization.Model): """ _validation = { - 'name': {'readonly': True}, - 'id': {'readonly': True}, - 'subscription_id': {'readonly': True}, + "name": {"readonly": True}, + "id": {"readonly": True}, + "subscription_id": {"readonly": True}, } _attribute_map = { - 'name': {'key': 'name', 'type': 'str'}, - 'id': {'key': 'id', 'type': 'str'}, - 'subscription_id': {'key': 'subscriptionId', 'type': 'str'}, + "name": {"key": "name", "type": "str"}, + "id": {"key": "id", "type": "str"}, + "subscription_id": {"key": "subscriptionId", "type": "str"}, } - def __init__( - self, - **kwargs - ): - """ - """ - super(PairedRegion, self).__init__(**kwargs) + def __init__(self, **kwargs): + """ """ + super().__init__(**kwargs) self.name = None self.id = None self.subscription_id = None -class Peers(msrest.serialization.Model): +class Peers(_serialization.Model): """Information about shared availability zone. Variables are only populated by the server, and will be ignored when sending a request. @@ -663,66 +602,56 @@ class Peers(msrest.serialization.Model): """ _validation = { - 'subscription_id': {'readonly': True}, - 'availability_zone': {'readonly': True}, + "subscription_id": {"readonly": True}, + "availability_zone": {"readonly": True}, } _attribute_map = { - 'subscription_id': {'key': 'subscriptionId', 'type': 'str'}, - 'availability_zone': {'key': 'availabilityZone', 'type': 'str'}, + "subscription_id": {"key": "subscriptionId", "type": "str"}, + "availability_zone": {"key": "availabilityZone", "type": "str"}, } - def __init__( - self, - **kwargs - ): - """ - """ - super(Peers, self).__init__(**kwargs) + def __init__(self, **kwargs): + """ """ + super().__init__(**kwargs) self.subscription_id = None self.availability_zone = None -class ResourceName(msrest.serialization.Model): +class ResourceName(_serialization.Model): """Name and Type of the Resource. All required parameters must be populated in order to send to Azure. - :ivar name: Required. Name of the resource. + :ivar name: Name of the resource. Required. :vartype name: str - :ivar type: Required. The type of the resource. + :ivar type: The type of the resource. Required. :vartype type: str """ _validation = { - 'name': {'required': True}, - 'type': {'required': True}, + "name": {"required": True}, + "type": {"required": True}, } _attribute_map = { - 'name': {'key': 'name', 'type': 'str'}, - 'type': {'key': 'type', 'type': 'str'}, + "name": {"key": "name", "type": "str"}, + "type": {"key": "type", "type": "str"}, } - def __init__( - self, - *, - name: str, - type: str, - **kwargs - ): + def __init__(self, *, name: str, type: str, **kwargs): """ - :keyword name: Required. Name of the resource. + :keyword name: Name of the resource. Required. :paramtype name: str - :keyword type: Required. The type of the resource. + :keyword type: The type of the resource. Required. :paramtype type: str """ - super(ResourceName, self).__init__(**kwargs) + super().__init__(**kwargs) self.name = name self.type = type -class Subscription(msrest.serialization.Model): +class Subscription(_serialization.Model): """Subscription information. Variables are only populated by the server, and will be ignored when sending a request. @@ -737,7 +666,7 @@ class Subscription(msrest.serialization.Model): :ivar tenant_id: The subscription tenant ID. :vartype tenant_id: str :ivar state: The subscription state. Possible values are Enabled, Warned, PastDue, Disabled, - and Deleted. Possible values include: "Enabled", "Warned", "PastDue", "Disabled", "Deleted". + and Deleted. Known values are: "Enabled", "Warned", "PastDue", "Disabled", and "Deleted". :vartype state: str or ~azure.mgmt.resource.subscriptions.v2021_01_01.models.SubscriptionState :ivar subscription_policies: The subscription policies. :vartype subscription_policies: @@ -749,36 +678,36 @@ class Subscription(msrest.serialization.Model): :ivar managed_by_tenants: An array containing the tenants managing the subscription. :vartype managed_by_tenants: list[~azure.mgmt.resource.subscriptions.v2021_01_01.models.ManagedByTenant] - :ivar tags: A set of tags. The tags attached to the subscription. + :ivar tags: The tags attached to the subscription. :vartype tags: dict[str, str] """ _validation = { - 'id': {'readonly': True}, - 'subscription_id': {'readonly': True}, - 'display_name': {'readonly': True}, - 'tenant_id': {'readonly': True}, - 'state': {'readonly': True}, + "id": {"readonly": True}, + "subscription_id": {"readonly": True}, + "display_name": {"readonly": True}, + "tenant_id": {"readonly": True}, + "state": {"readonly": True}, } _attribute_map = { - 'id': {'key': 'id', 'type': 'str'}, - 'subscription_id': {'key': 'subscriptionId', 'type': 'str'}, - 'display_name': {'key': 'displayName', 'type': 'str'}, - 'tenant_id': {'key': 'tenantId', 'type': 'str'}, - 'state': {'key': 'state', 'type': 'str'}, - 'subscription_policies': {'key': 'subscriptionPolicies', 'type': 'SubscriptionPolicies'}, - 'authorization_source': {'key': 'authorizationSource', 'type': 'str'}, - 'managed_by_tenants': {'key': 'managedByTenants', 'type': '[ManagedByTenant]'}, - 'tags': {'key': 'tags', 'type': '{str}'}, + "id": {"key": "id", "type": "str"}, + "subscription_id": {"key": "subscriptionId", "type": "str"}, + "display_name": {"key": "displayName", "type": "str"}, + "tenant_id": {"key": "tenantId", "type": "str"}, + "state": {"key": "state", "type": "str"}, + "subscription_policies": {"key": "subscriptionPolicies", "type": "SubscriptionPolicies"}, + "authorization_source": {"key": "authorizationSource", "type": "str"}, + "managed_by_tenants": {"key": "managedByTenants", "type": "[ManagedByTenant]"}, + "tags": {"key": "tags", "type": "{str}"}, } def __init__( self, *, - subscription_policies: Optional["SubscriptionPolicies"] = None, + subscription_policies: Optional["_models.SubscriptionPolicies"] = None, authorization_source: Optional[str] = None, - managed_by_tenants: Optional[List["ManagedByTenant"]] = None, + managed_by_tenants: Optional[List["_models.ManagedByTenant"]] = None, tags: Optional[Dict[str, str]] = None, **kwargs ): @@ -793,10 +722,10 @@ def __init__( :keyword managed_by_tenants: An array containing the tenants managing the subscription. :paramtype managed_by_tenants: list[~azure.mgmt.resource.subscriptions.v2021_01_01.models.ManagedByTenant] - :keyword tags: A set of tags. The tags attached to the subscription. + :keyword tags: The tags attached to the subscription. :paramtype tags: dict[str, str] """ - super(Subscription, self).__init__(**kwargs) + super().__init__(**kwargs) self.id = None self.subscription_id = None self.display_name = None @@ -808,45 +737,39 @@ def __init__( self.tags = tags -class SubscriptionListResult(msrest.serialization.Model): +class SubscriptionListResult(_serialization.Model): """Subscription list operation response. All required parameters must be populated in order to send to Azure. :ivar value: An array of subscriptions. :vartype value: list[~azure.mgmt.resource.subscriptions.v2021_01_01.models.Subscription] - :ivar next_link: Required. The URL to get the next set of results. + :ivar next_link: The URL to get the next set of results. Required. :vartype next_link: str """ _validation = { - 'next_link': {'required': True}, + "next_link": {"required": True}, } _attribute_map = { - 'value': {'key': 'value', 'type': '[Subscription]'}, - 'next_link': {'key': 'nextLink', 'type': 'str'}, + "value": {"key": "value", "type": "[Subscription]"}, + "next_link": {"key": "nextLink", "type": "str"}, } - def __init__( - self, - *, - next_link: str, - value: Optional[List["Subscription"]] = None, - **kwargs - ): + def __init__(self, *, next_link: str, value: Optional[List["_models.Subscription"]] = None, **kwargs): """ :keyword value: An array of subscriptions. :paramtype value: list[~azure.mgmt.resource.subscriptions.v2021_01_01.models.Subscription] - :keyword next_link: Required. The URL to get the next set of results. + :keyword next_link: The URL to get the next set of results. Required. :paramtype next_link: str """ - super(SubscriptionListResult, self).__init__(**kwargs) + super().__init__(**kwargs) self.value = value self.next_link = next_link -class SubscriptionPolicies(msrest.serialization.Model): +class SubscriptionPolicies(_serialization.Model): """Subscription policies. Variables are only populated by the server, and will be ignored when sending a request. @@ -857,37 +780,33 @@ class SubscriptionPolicies(msrest.serialization.Model): :vartype location_placement_id: str :ivar quota_id: The subscription quota ID. :vartype quota_id: str - :ivar spending_limit: The subscription spending limit. Possible values include: "On", "Off", + :ivar spending_limit: The subscription spending limit. Known values are: "On", "Off", and "CurrentPeriodOff". :vartype spending_limit: str or ~azure.mgmt.resource.subscriptions.v2021_01_01.models.SpendingLimit """ _validation = { - 'location_placement_id': {'readonly': True}, - 'quota_id': {'readonly': True}, - 'spending_limit': {'readonly': True}, + "location_placement_id": {"readonly": True}, + "quota_id": {"readonly": True}, + "spending_limit": {"readonly": True}, } _attribute_map = { - 'location_placement_id': {'key': 'locationPlacementId', 'type': 'str'}, - 'quota_id': {'key': 'quotaId', 'type': 'str'}, - 'spending_limit': {'key': 'spendingLimit', 'type': 'str'}, + "location_placement_id": {"key": "locationPlacementId", "type": "str"}, + "quota_id": {"key": "quotaId", "type": "str"}, + "spending_limit": {"key": "spendingLimit", "type": "str"}, } - def __init__( - self, - **kwargs - ): - """ - """ - super(SubscriptionPolicies, self).__init__(**kwargs) + def __init__(self, **kwargs): + """ """ + super().__init__(**kwargs) self.location_placement_id = None self.quota_id = None self.spending_limit = None -class TenantIdDescription(msrest.serialization.Model): +class TenantIdDescription(_serialization.Model): """Tenant Id information. Variables are only populated by the server, and will be ignored when sending a request. @@ -897,7 +816,7 @@ class TenantIdDescription(msrest.serialization.Model): :vartype id: str :ivar tenant_id: The tenant ID. For example, 00000000-0000-0000-0000-000000000000. :vartype tenant_id: str - :ivar tenant_category: Category of the tenant. Possible values include: "Home", "ProjectedBy", + :ivar tenant_category: Category of the tenant. Known values are: "Home", "ProjectedBy", and "ManagedBy". :vartype tenant_category: str or ~azure.mgmt.resource.subscriptions.v2021_01_01.models.TenantCategory @@ -919,38 +838,34 @@ class TenantIdDescription(msrest.serialization.Model): """ _validation = { - 'id': {'readonly': True}, - 'tenant_id': {'readonly': True}, - 'tenant_category': {'readonly': True}, - 'country': {'readonly': True}, - 'country_code': {'readonly': True}, - 'display_name': {'readonly': True}, - 'domains': {'readonly': True}, - 'default_domain': {'readonly': True}, - 'tenant_type': {'readonly': True}, - 'tenant_branding_logo_url': {'readonly': True}, + "id": {"readonly": True}, + "tenant_id": {"readonly": True}, + "tenant_category": {"readonly": True}, + "country": {"readonly": True}, + "country_code": {"readonly": True}, + "display_name": {"readonly": True}, + "domains": {"readonly": True}, + "default_domain": {"readonly": True}, + "tenant_type": {"readonly": True}, + "tenant_branding_logo_url": {"readonly": True}, } _attribute_map = { - 'id': {'key': 'id', 'type': 'str'}, - 'tenant_id': {'key': 'tenantId', 'type': 'str'}, - 'tenant_category': {'key': 'tenantCategory', 'type': 'str'}, - 'country': {'key': 'country', 'type': 'str'}, - 'country_code': {'key': 'countryCode', 'type': 'str'}, - 'display_name': {'key': 'displayName', 'type': 'str'}, - 'domains': {'key': 'domains', 'type': '[str]'}, - 'default_domain': {'key': 'defaultDomain', 'type': 'str'}, - 'tenant_type': {'key': 'tenantType', 'type': 'str'}, - 'tenant_branding_logo_url': {'key': 'tenantBrandingLogoUrl', 'type': 'str'}, - } - - def __init__( - self, - **kwargs - ): - """ - """ - super(TenantIdDescription, self).__init__(**kwargs) + "id": {"key": "id", "type": "str"}, + "tenant_id": {"key": "tenantId", "type": "str"}, + "tenant_category": {"key": "tenantCategory", "type": "str"}, + "country": {"key": "country", "type": "str"}, + "country_code": {"key": "countryCode", "type": "str"}, + "display_name": {"key": "displayName", "type": "str"}, + "domains": {"key": "domains", "type": "[str]"}, + "default_domain": {"key": "defaultDomain", "type": "str"}, + "tenant_type": {"key": "tenantType", "type": "str"}, + "tenant_branding_logo_url": {"key": "tenantBrandingLogoUrl", "type": "str"}, + } + + def __init__(self, **kwargs): + """ """ + super().__init__(**kwargs) self.id = None self.tenant_id = None self.tenant_category = None @@ -963,40 +878,34 @@ def __init__( self.tenant_branding_logo_url = None -class TenantListResult(msrest.serialization.Model): +class TenantListResult(_serialization.Model): """Tenant Ids information. All required parameters must be populated in order to send to Azure. :ivar value: An array of tenants. :vartype value: list[~azure.mgmt.resource.subscriptions.v2021_01_01.models.TenantIdDescription] - :ivar next_link: Required. The URL to use for getting the next set of results. + :ivar next_link: The URL to use for getting the next set of results. Required. :vartype next_link: str """ _validation = { - 'next_link': {'required': True}, + "next_link": {"required": True}, } _attribute_map = { - 'value': {'key': 'value', 'type': '[TenantIdDescription]'}, - 'next_link': {'key': 'nextLink', 'type': 'str'}, + "value": {"key": "value", "type": "[TenantIdDescription]"}, + "next_link": {"key": "nextLink", "type": "str"}, } - def __init__( - self, - *, - next_link: str, - value: Optional[List["TenantIdDescription"]] = None, - **kwargs - ): + def __init__(self, *, next_link: str, value: Optional[List["_models.TenantIdDescription"]] = None, **kwargs): """ :keyword value: An array of tenants. :paramtype value: list[~azure.mgmt.resource.subscriptions.v2021_01_01.models.TenantIdDescription] - :keyword next_link: Required. The URL to use for getting the next set of results. + :keyword next_link: The URL to use for getting the next set of results. Required. :paramtype next_link: str """ - super(TenantListResult, self).__init__(**kwargs) + super().__init__(**kwargs) self.value = value self.next_link = next_link diff --git a/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/subscriptions/v2021_01_01/models/_patch.py b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/subscriptions/v2021_01_01/models/_patch.py new file mode 100644 index 0000000000000..f7dd32510333d --- /dev/null +++ b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/subscriptions/v2021_01_01/models/_patch.py @@ -0,0 +1,20 @@ +# ------------------------------------ +# Copyright (c) Microsoft Corporation. +# Licensed under the MIT License. +# ------------------------------------ +"""Customize generated code here. + +Follow our quickstart for examples: https://aka.ms/azsdk/python/dpcodegen/python/customize +""" +from typing import List + +__all__: List[str] = [] # Add all objects you want publicly available to users at this package level + + +def patch_sdk(): + """Do not remove from this file. + + `patch_sdk` is a last resort escape hatch that allows you to do customizations + you can't accomplish using the techniques described in + https://aka.ms/azsdk/python/dpcodegen/python/customize + """ diff --git a/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/subscriptions/v2021_01_01/models/_subscription_client_enums.py b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/subscriptions/v2021_01_01/models/_subscription_client_enums.py index 121fb33aee80c..a598c42da4a4b 100644 --- a/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/subscriptions/v2021_01_01/models/_subscription_client_enums.py +++ b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/subscriptions/v2021_01_01/models/_subscription_client_enums.py @@ -7,50 +7,48 @@ # -------------------------------------------------------------------------- from enum import Enum -from six import with_metaclass from azure.core import CaseInsensitiveEnumMeta -class LocationType(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): - """The location type. - """ +class LocationType(str, Enum, metaclass=CaseInsensitiveEnumMeta): + """The location type.""" REGION = "Region" EDGE_ZONE = "EdgeZone" -class RegionCategory(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): - """The category of the region. - """ + +class RegionCategory(str, Enum, metaclass=CaseInsensitiveEnumMeta): + """The category of the region.""" RECOMMENDED = "Recommended" EXTENDED = "Extended" OTHER = "Other" -class RegionType(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): - """The type of the region. - """ + +class RegionType(str, Enum, metaclass=CaseInsensitiveEnumMeta): + """The type of the region.""" PHYSICAL = "Physical" LOGICAL = "Logical" -class ResourceNameStatus(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): - """Is the resource name Allowed or Reserved - """ + +class ResourceNameStatus(str, Enum, metaclass=CaseInsensitiveEnumMeta): + """Is the resource name Allowed or Reserved.""" ALLOWED = "Allowed" RESERVED = "Reserved" -class SpendingLimit(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): - """The subscription spending limit. - """ + +class SpendingLimit(str, Enum, metaclass=CaseInsensitiveEnumMeta): + """The subscription spending limit.""" ON = "On" OFF = "Off" CURRENT_PERIOD_OFF = "CurrentPeriodOff" -class SubscriptionState(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): - """The subscription state. Possible values are Enabled, Warned, PastDue, Disabled, and Deleted. - """ + +class SubscriptionState(str, Enum, metaclass=CaseInsensitiveEnumMeta): + """The subscription state. Possible values are Enabled, Warned, PastDue, Disabled, and Deleted.""" ENABLED = "Enabled" WARNED = "Warned" @@ -58,9 +56,9 @@ class SubscriptionState(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): DISABLED = "Disabled" DELETED = "Deleted" -class TenantCategory(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): - """Category of the tenant. - """ + +class TenantCategory(str, Enum, metaclass=CaseInsensitiveEnumMeta): + """Category of the tenant.""" HOME = "Home" PROJECTED_BY = "ProjectedBy" diff --git a/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/subscriptions/v2021_01_01/operations/__init__.py b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/subscriptions/v2021_01_01/operations/__init__.py index 686ea095d73e8..299b233e62c99 100644 --- a/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/subscriptions/v2021_01_01/operations/__init__.py +++ b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/subscriptions/v2021_01_01/operations/__init__.py @@ -10,8 +10,14 @@ from ._operations import TenantsOperations from ._operations import SubscriptionClientOperationsMixin +from ._patch import __all__ as _patch_all +from ._patch import * # type: ignore # pylint: disable=unused-wildcard-import +from ._patch import patch_sdk as _patch_sdk + __all__ = [ - 'SubscriptionsOperations', - 'TenantsOperations', - 'SubscriptionClientOperationsMixin', + "SubscriptionsOperations", + "TenantsOperations", + "SubscriptionClientOperationsMixin", ] +__all__.extend([p for p in _patch_all if p not in __all__]) +_patch_sdk() diff --git a/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/subscriptions/v2021_01_01/operations/_operations.py b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/subscriptions/v2021_01_01/operations/_operations.py index 2977f5a73869a..7955267eedf1d 100644 --- a/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/subscriptions/v2021_01_01/operations/_operations.py +++ b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/subscriptions/v2021_01_01/operations/_operations.py @@ -6,292 +6,252 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -from typing import Any, Callable, Dict, Iterable, Optional, TypeVar - -from msrest import Serializer - -from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error +from typing import Any, Callable, Dict, IO, Iterable, Optional, TypeVar, Union, overload +from urllib.parse import parse_qs, urljoin, urlparse + +from azure.core.exceptions import ( + ClientAuthenticationError, + HttpResponseError, + ResourceExistsError, + ResourceNotFoundError, + ResourceNotModifiedError, + map_error, +) from azure.core.paging import ItemPaged from azure.core.pipeline import PipelineResponse from azure.core.pipeline.transport import HttpResponse from azure.core.rest import HttpRequest from azure.core.tracing.decorator import distributed_trace +from azure.core.utils import case_insensitive_dict from azure.mgmt.core.exceptions import ARMErrorFormat from .. import models as _models -from .._vendor import _convert_request, _format_url_section -T = TypeVar('T') -JSONType = Any +from ..._serialization import Serializer +from .._vendor import MixinABC, _convert_request, _format_url_section + +T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] _SERIALIZER = Serializer() _SERIALIZER.client_side_validation = False + def build_subscriptions_list_locations_request( - subscription_id: str, - *, - include_extended_locations: Optional[bool] = None, - **kwargs: Any + subscription_id: str, *, include_extended_locations: Optional[bool] = None, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2021-01-01") # type: 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-01-01")) # type: str + accept = _headers.pop("Accept", "application/json") - accept = "application/json" # Construct URL _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/locations") path_format_arguments = { - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), } _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") if include_extended_locations is not None: - _query_parameters['includeExtendedLocations'] = _SERIALIZER.query("include_extended_locations", include_extended_locations, 'bool') + _params["includeExtendedLocations"] = _SERIALIZER.query( + "include_extended_locations", include_extended_locations, "bool" + ) # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - return HttpRequest( - method="GET", - url=_url, - params=_query_parameters, - headers=_header_parameters, - **kwargs - ) + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) -def build_subscriptions_get_request( - subscription_id: str, - **kwargs: Any -) -> HttpRequest: - api_version = kwargs.pop('api_version', "2021-01-01") # type: str +def build_subscriptions_get_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-01-01")) # type: str + accept = _headers.pop("Accept", "application/json") - accept = "application/json" # Construct URL _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}") path_format_arguments = { - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), } _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - return HttpRequest( - method="GET", - url=_url, - params=_query_parameters, - headers=_header_parameters, - **kwargs - ) + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) -def build_subscriptions_list_request( - **kwargs: Any -) -> HttpRequest: - api_version = kwargs.pop('api_version', "2021-01-01") # type: str +def build_subscriptions_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-01-01")) # type: str + accept = _headers.pop("Accept", "application/json") - accept = "application/json" # Construct URL _url = kwargs.pop("template_url", "/subscriptions") # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') - - return HttpRequest( - method="GET", - url=_url, - params=_query_parameters, - headers=_header_parameters, - **kwargs - ) - - -def build_subscriptions_check_zone_peers_request( - subscription_id: str, - *, - json: JSONType = None, - content: Any = None, - **kwargs: Any -) -> HttpRequest: - api_version = kwargs.pop('api_version', "2021-01-01") # type: str - content_type = kwargs.pop('content_type', None) # type: Optional[str] + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) + + +def build_subscriptions_check_zone_peers_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-01-01")) # type: str + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + accept = _headers.pop("Accept", "application/json") - accept = "application/json" # Construct URL _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/providers/Microsoft.Resources/checkZonePeers/") path_format_arguments = { - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), } _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] if content_type is not None: - _header_parameters['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') - _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') - - return HttpRequest( - method="POST", - url=_url, - params=_query_parameters, - headers=_header_parameters, - json=json, - content=content, - **kwargs - ) - - -def build_tenants_list_request( - **kwargs: Any -) -> HttpRequest: - api_version = kwargs.pop('api_version', "2021-01-01") # type: str + _headers["Content-Type"] = _SERIALIZER.header("content_type", content_type, "str") + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="POST", url=_url, params=_params, headers=_headers, **kwargs) + + +def build_tenants_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-01-01")) # type: str + accept = _headers.pop("Accept", "application/json") - accept = "application/json" # Construct URL _url = kwargs.pop("template_url", "/tenants") # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') - - return HttpRequest( - method="GET", - url=_url, - params=_query_parameters, - headers=_header_parameters, - **kwargs - ) - - -def build_check_resource_name_request( - *, - json: JSONType = None, - content: Any = None, - **kwargs: Any -) -> HttpRequest: - api_version = kwargs.pop('api_version', "2021-01-01") # type: str - content_type = kwargs.pop('content_type', None) # type: Optional[str] + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) + + +def build_check_resource_name_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-01-01")) # type: str + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + accept = _headers.pop("Accept", "application/json") - accept = "application/json" # Construct URL _url = kwargs.pop("template_url", "/providers/Microsoft.Resources/checkResourceName") # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] if content_type is not None: - _header_parameters['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') - _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') - - return HttpRequest( - method="POST", - url=_url, - params=_query_parameters, - headers=_header_parameters, - json=json, - content=content, - **kwargs - ) - -class SubscriptionsOperations(object): - """SubscriptionsOperations operations. - - You should not instantiate this class directly. Instead, you should create a Client instance that - instantiates it for you and attaches it as an attribute. - - :ivar models: Alias to model classes used in this operation group. - :type models: ~azure.mgmt.resource.subscriptions.v2021_01_01.models - :param client: Client for service requests. - :param config: Configuration of service client. - :param serializer: An object model serializer. - :param deserializer: An object model deserializer. + _headers["Content-Type"] = _SERIALIZER.header("content_type", content_type, "str") + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="POST", url=_url, params=_params, headers=_headers, **kwargs) + + +class SubscriptionsOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. + + Instead, you should access the following operations through + :class:`~azure.mgmt.resource.subscriptions.v2021_01_01.SubscriptionClient`'s + :attr:`subscriptions` attribute. """ models = _models - def __init__(self, client, config, serializer, deserializer): - self._client = client - self._serialize = serializer - self._deserialize = deserializer - self._config = config + def __init__(self, *args, **kwargs): + input_args = list(args) + self._client = input_args.pop(0) if input_args else kwargs.pop("client") + self._config = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") @distributed_trace def list_locations( - self, - subscription_id: str, - include_extended_locations: Optional[bool] = None, - **kwargs: Any - ) -> Iterable["_models.LocationListResult"]: + self, subscription_id: str, include_extended_locations: Optional[bool] = None, **kwargs: Any + ) -> Iterable["_models.Location"]: """Gets all available geo-locations. This operation provides all the locations that are available for resource providers; however, each resource provider may support a subset of this list. - :param subscription_id: The ID of the target subscription. + :param subscription_id: The ID of the target subscription. Required. :type subscription_id: str :param include_extended_locations: Whether to include extended locations. Default value is None. :type include_extended_locations: bool :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either LocationListResult or the result of cls(response) + :return: An iterator like instance of either Location or the result of cls(response) :rtype: - ~azure.core.paging.ItemPaged[~azure.mgmt.resource.subscriptions.v2021_01_01.models.LocationListResult] - :raises: ~azure.core.exceptions.HttpResponseError + ~azure.core.paging.ItemPaged[~azure.mgmt.resource.subscriptions.v2021_01_01.models.Location] + :raises ~azure.core.exceptions.HttpResponseError: """ - api_version = kwargs.pop('api_version', "2021-01-01") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-01-01")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[_models.LocationListResult] - cls = kwargs.pop('cls', None) # type: ClsType["_models.LocationListResult"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) + def prepare_request(next_link=None): if not next_link: - + request = build_subscriptions_list_locations_request( subscription_id=subscription_id, - api_version=api_version, include_extended_locations=include_extended_locations, - template_url=self.list_locations.metadata['url'], + api_version=api_version, + template_url=self.list_locations.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore else: - - request = build_subscriptions_list_locations_request( - subscription_id=subscription_id, - template_url=next_link, - ) + # make call to next link with the client's api-version + _parsed_next_link = urlparse(next_link) + _next_request_params = case_insensitive_dict(parse_qs(_parsed_next_link.query)) + _next_request_params["api-version"] = self._config.api_version + request = HttpRequest("GET", urljoin(next_link, _parsed_next_link.path), params=_next_request_params) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore request.method = "GET" return request @@ -305,10 +265,8 @@ def extract_data(pipeline_response): def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) response = pipeline_response.http_response @@ -318,103 +276,108 @@ def get_next(next_link=None): return pipeline_response + return ItemPaged(get_next, extract_data) - return ItemPaged( - get_next, extract_data - ) - list_locations.metadata = {'url': "/subscriptions/{subscriptionId}/locations"} # type: ignore + list_locations.metadata = {"url": "/subscriptions/{subscriptionId}/locations"} # type: ignore @distributed_trace - def get( - self, - subscription_id: str, - **kwargs: Any - ) -> "_models.Subscription": + def get(self, subscription_id: str, **kwargs: Any) -> _models.Subscription: """Gets details about a specified subscription. - :param subscription_id: The ID of the target subscription. + :param subscription_id: The ID of the target subscription. Required. :type subscription_id: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: Subscription, or the result of cls(response) + :return: Subscription or the result of cls(response) :rtype: ~azure.mgmt.resource.subscriptions.v2021_01_01.models.Subscription - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.Subscription"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) - api_version = kwargs.pop('api_version', "2021-01-01") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-01-01")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[_models.Subscription] - request = build_subscriptions_get_request( subscription_id=subscription_id, api_version=api_version, - template_url=self.get.metadata['url'], + template_url=self.get.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) - deserialized = self._deserialize('Subscription', pipeline_response) + deserialized = self._deserialize("Subscription", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - get.metadata = {'url': "/subscriptions/{subscriptionId}"} # type: ignore - + get.metadata = {"url": "/subscriptions/{subscriptionId}"} # type: ignore @distributed_trace - def list( - self, - **kwargs: Any - ) -> Iterable["_models.SubscriptionListResult"]: + def list(self, **kwargs: Any) -> Iterable["_models.Subscription"]: """Gets all subscriptions for a tenant. :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either SubscriptionListResult or the result of - cls(response) + :return: An iterator like instance of either Subscription or the result of cls(response) :rtype: - ~azure.core.paging.ItemPaged[~azure.mgmt.resource.subscriptions.v2021_01_01.models.SubscriptionListResult] - :raises: ~azure.core.exceptions.HttpResponseError + ~azure.core.paging.ItemPaged[~azure.mgmt.resource.subscriptions.v2021_01_01.models.Subscription] + :raises ~azure.core.exceptions.HttpResponseError: """ - api_version = kwargs.pop('api_version', "2021-01-01") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-01-01")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[_models.SubscriptionListResult] - cls = kwargs.pop('cls', None) # type: ClsType["_models.SubscriptionListResult"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) + def prepare_request(next_link=None): if not next_link: - + request = build_subscriptions_list_request( api_version=api_version, - template_url=self.list.metadata['url'], + template_url=self.list.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore else: - - request = build_subscriptions_list_request( - template_url=next_link, - ) + # make call to next link with the client's api-version + _parsed_next_link = urlparse(next_link) + _next_request_params = case_insensitive_dict(parse_qs(_parsed_next_link.query)) + _next_request_params["api-version"] = self._config.api_version + request = HttpRequest("GET", urljoin(next_link, _parsed_next_link.path), params=_next_request_params) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore request.method = "GET" return request @@ -428,10 +391,8 @@ def extract_data(pipeline_response): def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) response = pipeline_response.http_response @@ -441,56 +402,113 @@ def get_next(next_link=None): return pipeline_response + return ItemPaged(get_next, extract_data) - return ItemPaged( - get_next, extract_data - ) - list.metadata = {'url': "/subscriptions"} # type: ignore + list.metadata = {"url": "/subscriptions"} # type: ignore - @distributed_trace + @overload def check_zone_peers( self, subscription_id: str, - parameters: "_models.CheckZonePeersRequest", + parameters: _models.CheckZonePeersRequest, + *, + content_type: str = "application/json", **kwargs: Any - ) -> "_models.CheckZonePeersResult": + ) -> _models.CheckZonePeersResult: + """Compares a subscriptions logical zone mapping. + + :param subscription_id: The ID of the target subscription. Required. + :type subscription_id: str + :param parameters: Parameters for checking zone peers. Required. + :type parameters: ~azure.mgmt.resource.subscriptions.v2021_01_01.models.CheckZonePeersRequest + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: CheckZonePeersResult or the result of cls(response) + :rtype: ~azure.mgmt.resource.subscriptions.v2021_01_01.models.CheckZonePeersResult + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + def check_zone_peers( + self, subscription_id: str, parameters: IO, *, content_type: str = "application/json", **kwargs: Any + ) -> _models.CheckZonePeersResult: + """Compares a subscriptions logical zone mapping. + + :param subscription_id: The ID of the target subscription. Required. + :type subscription_id: str + :param parameters: Parameters for checking zone peers. Required. + :type parameters: IO + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: CheckZonePeersResult or the result of cls(response) + :rtype: ~azure.mgmt.resource.subscriptions.v2021_01_01.models.CheckZonePeersResult + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace + def check_zone_peers( + self, subscription_id: str, parameters: Union[_models.CheckZonePeersRequest, IO], **kwargs: Any + ) -> _models.CheckZonePeersResult: """Compares a subscriptions logical zone mapping. - :param subscription_id: The ID of the target subscription. + :param subscription_id: The ID of the target subscription. Required. :type subscription_id: str - :param parameters: Parameters for checking zone peers. + :param parameters: Parameters for checking zone peers. Is either a model type or a IO type. + Required. :type parameters: ~azure.mgmt.resource.subscriptions.v2021_01_01.models.CheckZonePeersRequest + or IO + :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. + Default value is None. + :paramtype content_type: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: CheckZonePeersResult, or the result of cls(response) + :return: CheckZonePeersResult or the result of cls(response) :rtype: ~azure.mgmt.resource.subscriptions.v2021_01_01.models.CheckZonePeersResult - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.CheckZonePeersResult"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', "2021-01-01") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-01-01")) # type: str + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.CheckZonePeersResult] - _json = self._serialize.body(parameters, 'CheckZonePeersRequest') + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(parameters, (IO, bytes)): + _content = parameters + else: + _json = self._serialize.body(parameters, "CheckZonePeersRequest") request = build_subscriptions_check_zone_peers_request( subscription_id=subscription_id, api_version=api_version, content_type=content_type, json=_json, - template_url=self.check_zone_peers.metadata['url'], + content=_content, + template_url=self.check_zone_peers.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200]: @@ -498,74 +516,79 @@ def check_zone_peers( error = self._deserialize.failsafe_deserialize(_models.ErrorResponseAutoGenerated, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - deserialized = self._deserialize('CheckZonePeersResult', pipeline_response) + deserialized = self._deserialize("CheckZonePeersResult", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - check_zone_peers.metadata = {'url': "/subscriptions/{subscriptionId}/providers/Microsoft.Resources/checkZonePeers/"} # type: ignore + check_zone_peers.metadata = {"url": "/subscriptions/{subscriptionId}/providers/Microsoft.Resources/checkZonePeers/"} # type: ignore -class TenantsOperations(object): - """TenantsOperations operations. - You should not instantiate this class directly. Instead, you should create a Client instance that - instantiates it for you and attaches it as an attribute. +class TenantsOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. - :ivar models: Alias to model classes used in this operation group. - :type models: ~azure.mgmt.resource.subscriptions.v2021_01_01.models - :param client: Client for service requests. - :param config: Configuration of service client. - :param serializer: An object model serializer. - :param deserializer: An object model deserializer. + Instead, you should access the following operations through + :class:`~azure.mgmt.resource.subscriptions.v2021_01_01.SubscriptionClient`'s + :attr:`tenants` attribute. """ models = _models - def __init__(self, client, config, serializer, deserializer): - self._client = client - self._serialize = serializer - self._deserialize = deserializer - self._config = config + def __init__(self, *args, **kwargs): + input_args = list(args) + self._client = input_args.pop(0) if input_args else kwargs.pop("client") + self._config = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") @distributed_trace - def list( - self, - **kwargs: Any - ) -> Iterable["_models.TenantListResult"]: + def list(self, **kwargs: Any) -> Iterable["_models.TenantIdDescription"]: """Gets the tenants for your account. :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either TenantListResult or the result of cls(response) + :return: An iterator like instance of either TenantIdDescription or the result of cls(response) :rtype: - ~azure.core.paging.ItemPaged[~azure.mgmt.resource.subscriptions.v2021_01_01.models.TenantListResult] - :raises: ~azure.core.exceptions.HttpResponseError + ~azure.core.paging.ItemPaged[~azure.mgmt.resource.subscriptions.v2021_01_01.models.TenantIdDescription] + :raises ~azure.core.exceptions.HttpResponseError: """ - api_version = kwargs.pop('api_version', "2021-01-01") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-01-01")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[_models.TenantListResult] - cls = kwargs.pop('cls', None) # type: ClsType["_models.TenantListResult"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) + def prepare_request(next_link=None): if not next_link: - + request = build_tenants_list_request( api_version=api_version, - template_url=self.list.metadata['url'], + template_url=self.list.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore else: - - request = build_tenants_list_request( - template_url=next_link, - ) + # make call to next link with the client's api-version + _parsed_next_link = urlparse(next_link) + _next_request_params = case_insensitive_dict(parse_qs(_parsed_next_link.query)) + _next_request_params["api-version"] = self._config.api_version + request = HttpRequest("GET", urljoin(next_link, _parsed_next_link.path), params=_next_request_params) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore request.method = "GET" return request @@ -579,10 +602,8 @@ def extract_data(pipeline_response): def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) response = pipeline_response.http_response @@ -592,19 +613,20 @@ def get_next(next_link=None): return pipeline_response + return ItemPaged(get_next, extract_data) - return ItemPaged( - get_next, extract_data - ) - list.metadata = {'url': "/tenants"} # type: ignore -class SubscriptionClientOperationsMixin(object): + list.metadata = {"url": "/tenants"} # type: ignore - @distributed_trace + +class SubscriptionClientOperationsMixin(MixinABC): + @overload def check_resource_name( self, - resource_name_definition: Optional["_models.ResourceName"] = None, + resource_name_definition: Optional[_models.ResourceName] = None, + *, + content_type: str = "application/json", **kwargs: Any - ) -> "_models.CheckResourceNameResult": + ) -> _models.CheckResourceNameResult: """Checks resource name validity. A resource name is valid if it is not a reserved word, does not contains a reserved word and @@ -614,51 +636,110 @@ def check_resource_name( type. Default value is None. :type resource_name_definition: ~azure.mgmt.resource.subscriptions.v2021_01_01.models.ResourceName + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: CheckResourceNameResult, or the result of cls(response) + :return: CheckResourceNameResult or the result of cls(response) :rtype: ~azure.mgmt.resource.subscriptions.v2021_01_01.models.CheckResourceNameResult - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + def check_resource_name( + self, resource_name_definition: Optional[IO] = None, *, content_type: str = "application/json", **kwargs: Any + ) -> _models.CheckResourceNameResult: + """Checks resource name validity. + + A resource name is valid if it is not a reserved word, does not contains a reserved word and + does not start with a reserved word. + + :param resource_name_definition: Resource object with values for resource name and resource + type. Default value is None. + :type resource_name_definition: IO + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: CheckResourceNameResult or the result of cls(response) + :rtype: ~azure.mgmt.resource.subscriptions.v2021_01_01.models.CheckResourceNameResult + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace + def check_resource_name( + self, resource_name_definition: Optional[Union[_models.ResourceName, IO]] = None, **kwargs: Any + ) -> _models.CheckResourceNameResult: + """Checks resource name validity. + + A resource name is valid if it is not a reserved word, does not contains a reserved word and + does not start with a reserved word. + + :param resource_name_definition: Resource object with values for resource name and resource + type. Is either a model type or a IO type. Default value is None. + :type resource_name_definition: + ~azure.mgmt.resource.subscriptions.v2021_01_01.models.ResourceName or IO + :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. + Default value is None. + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: CheckResourceNameResult or the result of cls(response) + :rtype: ~azure.mgmt.resource.subscriptions.v2021_01_01.models.CheckResourceNameResult + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.CheckResourceNameResult"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', "2021-01-01") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-01-01")) # type: str + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.CheckResourceNameResult] - if resource_name_definition is not None: - _json = self._serialize.body(resource_name_definition, 'ResourceName') + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(resource_name_definition, (IO, bytes)): + _content = resource_name_definition else: - _json = None + if resource_name_definition is not None: + _json = self._serialize.body(resource_name_definition, "ResourceName") + else: + _json = None request = build_check_resource_name_request( api_version=api_version, content_type=content_type, json=_json, - template_url=self.check_resource_name.metadata['url'], + content=_content, + template_url=self.check_resource_name.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) - deserialized = self._deserialize('CheckResourceNameResult', pipeline_response) + deserialized = self._deserialize("CheckResourceNameResult", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - check_resource_name.metadata = {'url': "/providers/Microsoft.Resources/checkResourceName"} # type: ignore - + check_resource_name.metadata = {"url": "/providers/Microsoft.Resources/checkResourceName"} # type: ignore diff --git a/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/subscriptions/v2021_01_01/operations/_patch.py b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/subscriptions/v2021_01_01/operations/_patch.py new file mode 100644 index 0000000000000..f7dd32510333d --- /dev/null +++ b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/subscriptions/v2021_01_01/operations/_patch.py @@ -0,0 +1,20 @@ +# ------------------------------------ +# Copyright (c) Microsoft Corporation. +# Licensed under the MIT License. +# ------------------------------------ +"""Customize generated code here. + +Follow our quickstart for examples: https://aka.ms/azsdk/python/dpcodegen/python/customize +""" +from typing import List + +__all__: List[str] = [] # Add all objects you want publicly available to users at this package level + + +def patch_sdk(): + """Do not remove from this file. + + `patch_sdk` is a last resort escape hatch that allows you to do customizations + you can't accomplish using the techniques described in + https://aka.ms/azsdk/python/dpcodegen/python/customize + """ diff --git a/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/templatespecs/__init__.py b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/templatespecs/__init__.py index 3ec925bedadc1..784a67e4746b0 100644 --- a/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/templatespecs/__init__.py +++ b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/templatespecs/__init__.py @@ -14,3 +14,7 @@ patch_sdk() except ImportError: pass + +from ._version import VERSION + +__version__ = VERSION diff --git a/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/templatespecs/_configuration.py b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/templatespecs/_configuration.py index 5e59494673b31..f8f5b642f9570 100644 --- a/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/templatespecs/_configuration.py +++ b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/templatespecs/_configuration.py @@ -8,7 +8,7 @@ # Changes may cause incorrect behavior and will be lost if the code is # regenerated. # -------------------------------------------------------------------------- -from typing import TYPE_CHECKING +from typing import Any, TYPE_CHECKING from azure.core.configuration import Configuration from azure.core.pipeline import policies @@ -18,8 +18,6 @@ if TYPE_CHECKING: # pylint: disable=unused-import,ungrouped-imports - from typing import Any - from azure.core.credentials import TokenCredential class TemplateSpecsClientConfiguration(Configuration): @@ -28,16 +26,16 @@ class TemplateSpecsClientConfiguration(Configuration): Note that all parameters used to create this instance are saved as instance attributes. - :param credential: Credential needed for the client to connect to Azure. + :param credential: Credential needed for the client to connect to Azure. Required. :type credential: ~azure.core.credentials.TokenCredential - :param subscription_id: Subscription Id which forms part of the URI for every service call. + :param subscription_id: Subscription Id which forms part of the URI for every service call. Required. :type subscription_id: str """ def __init__( self, - credential, # type: "TokenCredential" - subscription_id, # type: str + credential: "TokenCredential", + subscription_id: str, **kwargs # type: Any ): # type: (...) -> None diff --git a/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/templatespecs/_serialization.py b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/templatespecs/_serialization.py new file mode 100644 index 0000000000000..240df16c57f3c --- /dev/null +++ b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/templatespecs/_serialization.py @@ -0,0 +1,2006 @@ +# -------------------------------------------------------------------------- +# +# Copyright (c) Microsoft Corporation. All rights reserved. +# +# The MIT License (MIT) +# +# Permission is hereby granted, free of charge, to any person obtaining a copy +# of this software and associated documentation files (the ""Software""), to +# deal in the Software without restriction, including without limitation the +# rights to use, copy, modify, merge, publish, distribute, sublicense, and/or +# sell copies of the Software, and to permit persons to whom the Software is +# furnished to do so, subject to the following conditions: +# +# The above copyright notice and this permission notice shall be included in +# all copies or substantial portions of the Software. +# +# THE SOFTWARE IS PROVIDED *AS IS*, WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING +# FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS +# IN THE SOFTWARE. +# +# -------------------------------------------------------------------------- + +# pylint: skip-file + +from base64 import b64decode, b64encode +import calendar +import datetime +import decimal +import email +from enum import Enum +import json +import logging +import re +import sys +import codecs +try: + from urllib import quote # type: ignore +except ImportError: + from urllib.parse import quote # type: ignore +import xml.etree.ElementTree as ET + +import isodate + +from typing import Dict, Any, cast, TYPE_CHECKING + +from azure.core.exceptions import DeserializationError, SerializationError, raise_with_traceback + +_BOM = codecs.BOM_UTF8.decode(encoding='utf-8') + +if TYPE_CHECKING: + from typing import Optional, Union, AnyStr, IO, Mapping + +class RawDeserializer: + + # Accept "text" because we're open minded people... + JSON_REGEXP = re.compile(r'^(application|text)/([a-z+.]+\+)?json$') + + # Name used in context + CONTEXT_NAME = "deserialized_data" + + @classmethod + def deserialize_from_text(cls, data, content_type=None): + # type: (Optional[Union[AnyStr, IO]], Optional[str]) -> Any + """Decode data according to content-type. + + Accept a stream of data as well, but will be load at once in memory for now. + + If no content-type, will return the string version (not bytes, not stream) + + :param data: Input, could be bytes or stream (will be decoded with UTF8) or text + :type data: str or bytes or IO + :param str content_type: The content type. + """ + if hasattr(data, 'read'): + # Assume a stream + data = cast(IO, data).read() + + if isinstance(data, bytes): + data_as_str = data.decode(encoding='utf-8-sig') + else: + # Explain to mypy the correct type. + data_as_str = cast(str, data) + + # Remove Byte Order Mark if present in string + data_as_str = data_as_str.lstrip(_BOM) + + if content_type is None: + return data + + if cls.JSON_REGEXP.match(content_type): + try: + return json.loads(data_as_str) + except ValueError as err: + raise DeserializationError("JSON is invalid: {}".format(err), err) + elif "xml" in (content_type or []): + try: + + try: + if isinstance(data, unicode): # type: ignore + # If I'm Python 2.7 and unicode XML will scream if I try a "fromstring" on unicode string + data_as_str = data_as_str.encode(encoding="utf-8") # type: ignore + except NameError: + pass + + return ET.fromstring(data_as_str) # nosec + except ET.ParseError: + # It might be because the server has an issue, and returned JSON with + # content-type XML.... + # So let's try a JSON load, and if it's still broken + # let's flow the initial exception + def _json_attemp(data): + try: + return True, json.loads(data) + except ValueError: + return False, None # Don't care about this one + success, json_result = _json_attemp(data) + if success: + return json_result + # If i'm here, it's not JSON, it's not XML, let's scream + # and raise the last context in this block (the XML exception) + # The function hack is because Py2.7 messes up with exception + # context otherwise. + _LOGGER.critical("Wasn't XML not JSON, failing") + raise_with_traceback(DeserializationError, "XML is invalid") + 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 + """Deserialize from HTTP response. + + Use bytes and headers to NOT use any requests/aiohttp or whatever + specific implementation. + Headers will tested for "content-type" + """ + # Try to use content-type from headers if available + content_type = None + if 'content-type' in headers: + content_type = headers['content-type'].split(";")[0].strip().lower() + # Ouch, this server did not declare what it sent... + # Let's guess it's JSON... + # Also, since Autorest was considering that an empty body was a valid JSON, + # need that test as well.... + else: + content_type = "application/json" + + if body_bytes: + return cls.deserialize_from_text(body_bytes, content_type) + return None + +try: + basestring # type: ignore + unicode_str = unicode # type: ignore +except NameError: + basestring = str # type: ignore + unicode_str = str # type: ignore + +_LOGGER = logging.getLogger(__name__) + +try: + _long_type = long # type: ignore +except NameError: + _long_type = int + +class UTC(datetime.tzinfo): + """Time Zone info for handling UTC""" + + def utcoffset(self, dt): + """UTF offset for UTC is 0.""" + return datetime.timedelta(0) + + def tzname(self, dt): + """Timestamp representation.""" + return "Z" + + def dst(self, dt): + """No daylight saving for UTC.""" + return datetime.timedelta(hours=1) + +try: + from datetime import timezone as _FixedOffset +except ImportError: # Python 2.7 + class _FixedOffset(datetime.tzinfo): # type: ignore + """Fixed offset in minutes east from UTC. + Copy/pasted from Python doc + :param datetime.timedelta offset: offset in timedelta format + """ + + def __init__(self, offset): + self.__offset = offset + + def utcoffset(self, dt): + return self.__offset + + def tzname(self, dt): + return str(self.__offset.total_seconds()/3600) + + def __repr__(self): + return "".format(self.tzname(None)) + + def dst(self, dt): + return datetime.timedelta(0) + + def __getinitargs__(self): + return (self.__offset,) + +try: + from datetime import timezone + TZ_UTC = timezone.utc # type: ignore +except ImportError: + TZ_UTC = UTC() # type: ignore + +_FLATTEN = re.compile(r"(? y, + "minimum": lambda x, y: x < y, + "maximum": lambda x, y: x > y, + "minimum_ex": lambda x, y: x <= y, + "maximum_ex": lambda x, y: x >= y, + "min_items": lambda x, y: len(x) < y, + "max_items": lambda x, y: len(x) > y, + "pattern": lambda x, y: not re.match(y, x, re.UNICODE), + "unique": lambda x, y: len(x) != len(set(x)), + "multiple": lambda x, y: x % y != 0 + } + + def __init__(self, classes=None): + self.serialize_type = { + 'iso-8601': Serializer.serialize_iso, + 'rfc-1123': Serializer.serialize_rfc, + 'unix-time': Serializer.serialize_unix, + 'duration': Serializer.serialize_duration, + 'date': Serializer.serialize_date, + 'time': Serializer.serialize_time, + 'decimal': Serializer.serialize_decimal, + 'long': Serializer.serialize_long, + 'bytearray': Serializer.serialize_bytearray, + 'base64': Serializer.serialize_base64, + 'object': self.serialize_object, + '[]': self.serialize_iter, + '{}': self.serialize_dict + } + self.dependencies = dict(classes) if classes else {} + self.key_transformer = full_restapi_key_transformer + self.client_side_validation = True + + def _serialize(self, target_obj, data_type=None, **kwargs): + """Serialize data into a string according to type. + + :param target_obj: The data to be serialized. + :param str data_type: The type to be serialized from. + :rtype: str, dict + :raises: SerializationError if serialization fails. + """ + key_transformer = kwargs.get("key_transformer", self.key_transformer) + keep_readonly = kwargs.get("keep_readonly", False) + if target_obj is None: + return None + + attr_name = None + class_name = target_obj.__class__.__name__ + + if data_type: + return self.serialize_data( + target_obj, data_type, **kwargs) + + if not hasattr(target_obj, "_attribute_map"): + data_type = type(target_obj).__name__ + if data_type in self.basic_types.values(): + return self.serialize_data( + target_obj, data_type, **kwargs) + + # Force "is_xml" kwargs if we detect a XML model + try: + is_xml_model_serialization = kwargs["is_xml"] + except KeyError: + is_xml_model_serialization = kwargs.setdefault("is_xml", target_obj.is_xml_model()) + + serialized = {} + if is_xml_model_serialization: + serialized = target_obj._create_xml_node() + try: + attributes = target_obj._attribute_map + for attr, attr_desc in attributes.items(): + attr_name = attr + if not keep_readonly and target_obj._validation.get(attr_name, {}).get('readonly', False): + continue + + if attr_name == "additional_properties" and attr_desc["key"] == '': + if target_obj.additional_properties is not None: + serialized.update(target_obj.additional_properties) + continue + try: + + orig_attr = getattr(target_obj, attr) + if is_xml_model_serialization: + pass # Don't provide "transformer" for XML for now. Keep "orig_attr" + else: # JSON + keys, orig_attr = key_transformer(attr, attr_desc.copy(), orig_attr) + keys = keys if isinstance(keys, list) else [keys] + + + kwargs["serialization_ctxt"] = attr_desc + new_attr = self.serialize_data(orig_attr, attr_desc['type'], **kwargs) + + + if is_xml_model_serialization: + xml_desc = attr_desc.get('xml', {}) + xml_name = xml_desc.get('name', attr_desc['key']) + xml_prefix = xml_desc.get('prefix', None) + xml_ns = xml_desc.get('ns', None) + 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) + continue + if xml_desc.get("text", False): + serialized.text = new_attr + continue + if isinstance(new_attr, list): + serialized.extend(new_attr) + 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', {}): + splitted_tag = new_attr.tag.split("}") + if len(splitted_tag) == 2: # Namespace + new_attr.tag = "}".join([splitted_tag[0], xml_name]) + else: + new_attr.tag = xml_name + serialized.append(new_attr) + 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) + else: # JSON + for k in reversed(keys): + unflattened = {k: new_attr} + new_attr = unflattened + + _new_attr = new_attr + _serialized = serialized + for k in keys: + if k not in _serialized: + _serialized.update(_new_attr) + _new_attr = _new_attr[k] + _serialized = _serialized[k] + except ValueError: + continue + + except (AttributeError, KeyError, TypeError) as err: + msg = "Attribute {} in object {} cannot be serialized.\n{}".format( + attr_name, class_name, str(target_obj)) + raise_with_traceback(SerializationError, msg, err) + else: + return serialized + + def body(self, data, data_type, **kwargs): + """Serialize data intended for a request body. + + :param data: The data to be serialized. + :param str data_type: The type to be serialized from. + :rtype: dict + :raises: SerializationError if serialization fails. + :raises: ValueError if data is None + """ + + # Just in case this is a dict + internal_data_type = data_type.strip('[]{}') + internal_data_type = self.dependencies.get(internal_data_type, None) + try: + is_xml_model_serialization = kwargs["is_xml"] + except KeyError: + if internal_data_type and issubclass(internal_data_type, Model): + is_xml_model_serialization = kwargs.setdefault("is_xml", internal_data_type.is_xml_model()) + else: + is_xml_model_serialization = False + if internal_data_type and not isinstance(internal_data_type, Enum): + try: + deserializer = Deserializer(self.dependencies) + # Since it's on serialization, it's almost sure that format is not JSON REST + # We're not able to deal with additional properties for now. + deserializer.additional_properties_detection = False + if is_xml_model_serialization: + deserializer.key_extractors = [ + attribute_key_case_insensitive_extractor, + ] + else: + deserializer.key_extractors = [ + rest_key_case_insensitive_extractor, + attribute_key_case_insensitive_extractor, + last_rest_key_case_insensitive_extractor + ] + data = deserializer._deserialize(data_type, data) + except DeserializationError as err: + raise_with_traceback( + SerializationError, "Unable to build a model: "+str(err), err) + + return self._serialize(data, data_type, **kwargs) + + def url(self, name, data, data_type, **kwargs): + """Serialize data intended for a URL path. + + :param data: The data to be serialized. + :param str data_type: The type to be serialized from. + :rtype: str + :raises: TypeError if serialization fails. + :raises: ValueError if data is None + """ + try: + output = self.serialize_data(data, data_type, **kwargs) + if data_type == 'bool': + output = json.dumps(output) + + if kwargs.get('skip_quote') is True: + output = str(output) + else: + output = quote(str(output), safe='') + except SerializationError: + raise TypeError("{} must be type {}.".format(name, data_type)) + else: + return output + + def query(self, name, data, data_type, **kwargs): + """Serialize data intended for a URL query. + + :param data: The data to be serialized. + :param str data_type: The type to be serialized from. + :rtype: str + :raises: TypeError if serialization fails. + :raises: ValueError if data is None + """ + try: + # 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)) + + # Not a list, regular serialization + output = self.serialize_data(data, data_type, **kwargs) + if data_type == 'bool': + output = json.dumps(output) + if kwargs.get('skip_quote') is True: + output = str(output) + else: + output = quote(str(output), safe='') + except SerializationError: + raise TypeError("{} must be type {}.".format(name, data_type)) + else: + return str(output) + + def header(self, name, data, data_type, **kwargs): + """Serialize data intended for a request header. + + :param data: The data to be serialized. + :param str data_type: The type to be serialized from. + :rtype: str + :raises: TypeError if serialization fails. + :raises: ValueError if data is None + """ + try: + if data_type in ['[str]']: + data = ["" if d is None else d for d in data] + + output = self.serialize_data(data, data_type, **kwargs) + if data_type == 'bool': + output = json.dumps(output) + except SerializationError: + raise TypeError("{} must be type {}.".format(name, data_type)) + else: + return str(output) + + def serialize_data(self, data, data_type, **kwargs): + """Serialize generic data according to supplied data type. + + :param data: The data to be serialized. + :param str data_type: The type to be serialized from. + :param bool required: Whether it's essential that the data not be + empty or None + :raises: AttributeError if required data is None. + :raises: ValueError if data is None + :raises: SerializationError if serialization fails. + """ + if data is None: + raise ValueError("No value for given attribute") + + try: + if data_type in self.basic_types.values(): + return self.serialize_basic(data, data_type, **kwargs) + + elif data_type in self.serialize_type: + return self.serialize_type[data_type](data, **kwargs) + + # If dependencies is empty, try with current data class + # It has to be a subclass of Enum anyway + enum_type = self.dependencies.get(data_type, data.__class__) + if issubclass(enum_type, Enum): + return Serializer.serialize_enum(data, enum_obj=enum_type) + + iter_type = data_type[0] + data_type[-1] + if iter_type in self.serialize_type: + return self.serialize_type[iter_type]( + data, data_type[1:-1], **kwargs) + + except (ValueError, TypeError) as err: + msg = "Unable to serialize value: {!r} as type: {!r}." + raise_with_traceback( + SerializationError, msg.format(data, data_type), err) + else: + return self._serialize(data, **kwargs) + + @classmethod + def _get_custom_serializers(cls, data_type, **kwargs): + custom_serializer = kwargs.get("basic_types_serializers", {}).get(data_type) + if custom_serializer: + return custom_serializer + if kwargs.get("is_xml", False): + return cls._xml_basic_types_serializers.get(data_type) + + @classmethod + def serialize_basic(cls, data, data_type, **kwargs): + """Serialize basic builting data type. + Serializes objects to str, int, float or bool. + + Possible kwargs: + - basic_types_serializers dict[str, callable] : If set, use the callable as serializer + - is_xml bool : If set, use xml_basic_types_serializers + + :param data: Object to be serialized. + :param str data_type: Type of object in the iterable. + """ + custom_serializer = cls._get_custom_serializers(data_type, **kwargs) + if custom_serializer: + return custom_serializer(data) + if data_type == 'str': + return cls.serialize_unicode(data) + return eval(data_type)(data) # nosec + + @classmethod + def serialize_unicode(cls, data): + """Special handling for serializing unicode strings in Py2. + Encode to UTF-8 if unicode, otherwise handle as a str. + + :param data: Object to be serialized. + :rtype: str + """ + try: # If I received an enum, return its value + return data.value + except AttributeError: + pass + + try: + if isinstance(data, unicode): + # Don't change it, JSON and XML ElementTree are totally able + # to serialize correctly u'' strings + return data + except NameError: + return str(data) + else: + return str(data) + + def serialize_iter(self, data, iter_type, div=None, **kwargs): + """Serialize iterable. + + Supported kwargs: + - serialization_ctxt dict : The current entry of _attribute_map, or same format. + serialization_ctxt['type'] should be same as data_type. + - is_xml bool : If set, serialize as XML + + :param list attr: Object to be serialized. + :param str iter_type: Type of object in the iterable. + :param bool required: Whether the objects in the iterable must + not be None or empty. + :param str div: If set, this str will be used to combine the elements + in the iterable into a combined string. Default is 'None'. + :rtype: list, str + """ + if isinstance(data, str): + raise SerializationError("Refuse str type as a valid iter type.") + + serialization_ctxt = kwargs.get("serialization_ctxt", {}) + is_xml = kwargs.get("is_xml", False) + + serialized = [] + for d in data: + try: + serialized.append(self.serialize_data(d, iter_type, **kwargs)) + except ValueError: + serialized.append(None) + + if div: + serialized = ['' if s is None else str(s) for s in serialized] + serialized = div.join(serialized) + + if 'xml' in serialization_ctxt or is_xml: + # XML serialization is more complicated + xml_desc = serialization_ctxt.get('xml', {}) + xml_name = xml_desc.get('name') + if not xml_name: + xml_name = serialization_ctxt['key'] + + # Create a wrap node if necessary (use the fact that Element and list have "append") + is_wrapped = xml_desc.get("wrapped", False) + node_name = xml_desc.get("itemsName", xml_name) + if is_wrapped: + final_result = _create_xml_node( + xml_name, + xml_desc.get('prefix', None), + xml_desc.get('ns', None) + ) + else: + final_result = [] + # All list elements to "local_node" + for el in serialized: + if isinstance(el, ET.Element): + el_node = el + else: + el_node = _create_xml_node( + node_name, + xml_desc.get('prefix', None), + xml_desc.get('ns', None) + ) + if el is not None: # Otherwise it writes "None" :-p + el_node.text = str(el) + final_result.append(el_node) + return final_result + return serialized + + def serialize_dict(self, attr, dict_type, **kwargs): + """Serialize a dictionary of objects. + + :param dict attr: Object to be serialized. + :param str dict_type: Type of object in the dictionary. + :param bool required: Whether the objects in the dictionary must + not be None or empty. + :rtype: dict + """ + serialization_ctxt = kwargs.get("serialization_ctxt", {}) + serialized = {} + for key, value in attr.items(): + try: + serialized[self.serialize_unicode(key)] = self.serialize_data( + value, dict_type, **kwargs) + except ValueError: + serialized[self.serialize_unicode(key)] = None + + if 'xml' in serialization_ctxt: + # XML serialization is more complicated + xml_desc = serialization_ctxt['xml'] + xml_name = xml_desc['name'] + + final_result = _create_xml_node( + xml_name, + xml_desc.get('prefix', None), + xml_desc.get('ns', None) + ) + for key, value in serialized.items(): + ET.SubElement(final_result, key).text = value + return final_result + + return serialized + + def serialize_object(self, attr, **kwargs): + """Serialize a generic object. + This will be handled as a dictionary. If object passed in is not + a basic type (str, int, float, dict, list) it will simply be + cast to str. + + :param dict attr: Object to be serialized. + :rtype: dict or str + """ + if attr is None: + return None + if isinstance(attr, ET.Element): + return attr + obj_type = type(attr) + if obj_type in self.basic_types: + return self.serialize_basic(attr, self.basic_types[obj_type], **kwargs) + if obj_type is _long_type: + return self.serialize_long(attr) + if obj_type is unicode_str: + return self.serialize_unicode(attr) + if obj_type is datetime.datetime: + return self.serialize_iso(attr) + if obj_type is datetime.date: + return self.serialize_date(attr) + if obj_type is datetime.time: + return self.serialize_time(attr) + if obj_type is datetime.timedelta: + return self.serialize_duration(attr) + if obj_type is decimal.Decimal: + return self.serialize_decimal(attr) + + # If it's a model or I know this dependency, serialize as a Model + elif obj_type in self.dependencies.values() or isinstance(attr, Model): + return self._serialize(attr) + + if obj_type == dict: + serialized = {} + for key, value in attr.items(): + try: + serialized[self.serialize_unicode(key)] = self.serialize_object( + value, **kwargs) + except ValueError: + serialized[self.serialize_unicode(key)] = None + return serialized + + if obj_type == list: + serialized = [] + for obj in attr: + try: + serialized.append(self.serialize_object( + obj, **kwargs)) + except ValueError: + pass + return serialized + return str(attr) + + @staticmethod + def serialize_enum(attr, enum_obj=None): + try: + result = attr.value + except AttributeError: + result = attr + try: + enum_obj(result) + return result + except ValueError: + for enum_value in enum_obj: + if enum_value.value.lower() == str(attr).lower(): + return enum_value.value + error = "{!r} is not valid value for enum {!r}" + raise SerializationError(error.format(attr, enum_obj)) + + @staticmethod + def serialize_bytearray(attr, **kwargs): + """Serialize bytearray into base-64 string. + + :param attr: Object to be serialized. + :rtype: str + """ + return b64encode(attr).decode() + + @staticmethod + def serialize_base64(attr, **kwargs): + """Serialize str into base-64 string. + + :param attr: Object to be serialized. + :rtype: str + """ + encoded = b64encode(attr).decode('ascii') + return encoded.strip('=').replace('+', '-').replace('/', '_') + + @staticmethod + def serialize_decimal(attr, **kwargs): + """Serialize Decimal object to float. + + :param attr: Object to be serialized. + :rtype: float + """ + return float(attr) + + @staticmethod + def serialize_long(attr, **kwargs): + """Serialize long (Py2) or int (Py3). + + :param attr: Object to be serialized. + :rtype: int/long + """ + return _long_type(attr) + + @staticmethod + def serialize_date(attr, **kwargs): + """Serialize Date object into ISO-8601 formatted string. + + :param Date attr: Object to be serialized. + :rtype: str + """ + if isinstance(attr, str): + attr = isodate.parse_date(attr) + t = "{:04}-{:02}-{:02}".format(attr.year, attr.month, attr.day) + return t + + @staticmethod + def serialize_time(attr, **kwargs): + """Serialize Time object into ISO-8601 formatted string. + + :param datetime.time attr: Object to be serialized. + :rtype: str + """ + if isinstance(attr, str): + attr = isodate.parse_time(attr) + t = "{:02}:{:02}:{:02}".format(attr.hour, attr.minute, attr.second) + if attr.microsecond: + t += ".{:02}".format(attr.microsecond) + return t + + @staticmethod + def serialize_duration(attr, **kwargs): + """Serialize TimeDelta object into ISO-8601 formatted string. + + :param TimeDelta attr: Object to be serialized. + :rtype: str + """ + if isinstance(attr, str): + attr = isodate.parse_duration(attr) + return isodate.duration_isoformat(attr) + + @staticmethod + def serialize_rfc(attr, **kwargs): + """Serialize Datetime object into RFC-1123 formatted string. + + :param Datetime attr: Object to be serialized. + :rtype: str + :raises: TypeError if format invalid. + """ + try: + if not attr.tzinfo: + _LOGGER.warning( + "Datetime with no tzinfo will be considered UTC.") + utc = attr.utctimetuple() + except AttributeError: + raise TypeError("RFC1123 object must be valid Datetime object.") + + return "{}, {:02} {} {:04} {:02}:{:02}:{:02} GMT".format( + Serializer.days[utc.tm_wday], utc.tm_mday, + Serializer.months[utc.tm_mon], utc.tm_year, + utc.tm_hour, utc.tm_min, utc.tm_sec) + + @staticmethod + def serialize_iso(attr, **kwargs): + """Serialize Datetime object into ISO-8601 formatted string. + + :param Datetime attr: Object to be serialized. + :rtype: str + :raises: SerializationError if format invalid. + """ + if isinstance(attr, str): + attr = isodate.parse_datetime(attr) + try: + if not attr.tzinfo: + _LOGGER.warning( + "Datetime with no tzinfo will be considered UTC.") + utc = attr.utctimetuple() + if utc.tm_year > 9999 or utc.tm_year < 1: + raise OverflowError("Hit max or min date") + + microseconds = str(attr.microsecond).rjust(6,'0').rstrip('0').ljust(3, '0') + if microseconds: + microseconds = '.'+microseconds + date = "{:04}-{:02}-{:02}T{:02}:{:02}:{:02}".format( + utc.tm_year, utc.tm_mon, utc.tm_mday, + utc.tm_hour, utc.tm_min, utc.tm_sec) + return date + microseconds + 'Z' + except (ValueError, OverflowError) as err: + msg = "Unable to serialize datetime object." + raise_with_traceback(SerializationError, msg, err) + except AttributeError as err: + msg = "ISO-8601 object must be valid Datetime object." + raise_with_traceback(TypeError, msg, err) + + @staticmethod + def serialize_unix(attr, **kwargs): + """Serialize Datetime object into IntTime format. + This is represented as seconds. + + :param Datetime attr: Object to be serialized. + :rtype: int + :raises: SerializationError if format invalid + """ + if isinstance(attr, int): + return attr + try: + if not attr.tzinfo: + _LOGGER.warning( + "Datetime with no tzinfo will be considered UTC.") + return int(calendar.timegm(attr.utctimetuple())) + except AttributeError: + raise TypeError("Unix time object must be valid Datetime object.") + +def rest_key_extractor(attr, attr_desc, data): + key = attr_desc['key'] + working_data = data + + while '.' in key: + dict_keys = _FLATTEN.split(key) + if len(dict_keys) == 1: + key = _decode_attribute_map_key(dict_keys[0]) + break + working_key = _decode_attribute_map_key(dict_keys[0]) + working_data = working_data.get(working_key, data) + if working_data is None: + # If at any point while following flatten JSON path see None, it means + # that all properties under are None as well + # https://github.com/Azure/msrest-for-python/issues/197 + return None + key = '.'.join(dict_keys[1:]) + + return working_data.get(key) + +def rest_key_case_insensitive_extractor(attr, attr_desc, data): + key = attr_desc['key'] + working_data = data + + while '.' in key: + dict_keys = _FLATTEN.split(key) + if len(dict_keys) == 1: + key = _decode_attribute_map_key(dict_keys[0]) + break + working_key = _decode_attribute_map_key(dict_keys[0]) + working_data = attribute_key_case_insensitive_extractor(working_key, None, working_data) + if working_data is None: + # If at any point while following flatten JSON path see None, it means + # that all properties under are None as well + # https://github.com/Azure/msrest-for-python/issues/197 + return None + key = '.'.join(dict_keys[1:]) + + if working_data: + return attribute_key_case_insensitive_extractor(key, None, working_data) + +def last_rest_key_extractor(attr, attr_desc, data): + """Extract the attribute in "data" based on the last part of the JSON path key. + """ + key = attr_desc['key'] + dict_keys = _FLATTEN.split(key) + return attribute_key_extractor(dict_keys[-1], None, data) + +def last_rest_key_case_insensitive_extractor(attr, attr_desc, data): + """Extract the attribute in "data" based on the last part of the JSON path key. + + This is the case insensitive version of "last_rest_key_extractor" + """ + key = attr_desc['key'] + dict_keys = _FLATTEN.split(key) + return attribute_key_case_insensitive_extractor(dict_keys[-1], None, data) + +def attribute_key_extractor(attr, _, data): + return data.get(attr) + +def attribute_key_case_insensitive_extractor(attr, _, data): + found_key = None + lower_attr = attr.lower() + for key in data: + if lower_attr == key.lower(): + found_key = key + break + + return data.get(found_key) + +def _extract_name_from_internal_type(internal_type): + """Given an internal type XML description, extract correct XML name with namespace. + + :param dict internal_type: An model type + :rtype: tuple + :returns: A tuple XML name + namespace dict + """ + internal_type_xml_map = getattr(internal_type, "_xml_map", {}) + 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) + return xml_name + + +def xml_key_extractor(attr, attr_desc, data): + if isinstance(data, dict): + return None + + # Test if this model is XML ready first + if not isinstance(data, ET.Element): + return None + + xml_desc = attr_desc.get('xml', {}) + xml_name = xml_desc.get('name', attr_desc['key']) + + # Look for a children + is_iter_type = attr_desc['type'].startswith("[") + is_wrapped = xml_desc.get("wrapped", False) + internal_type = attr_desc.get("internalType", None) + internal_type_xml_map = getattr(internal_type, "_xml_map", {}) + + # 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) + + # If it's an attribute, that's simple + if xml_desc.get("attr", False): + return data.get(xml_name) + + # If it's x-ms-text, that's simple too + if xml_desc.get("text", False): + return data.text + + # Scenario where I take the local name: + # - Wrapped node + # - Internal type is an enum (considered basic types) + # - Internal type has no XML/Name node + if is_wrapped or (internal_type and (issubclass(internal_type, Enum) or 'name' not in internal_type_xml_map)): + children = data.findall(xml_name) + # If internal type has a local name and it's not a list, I use that name + elif not is_iter_type and internal_type and 'name' in internal_type_xml_map: + xml_name = _extract_name_from_internal_type(internal_type) + children = data.findall(xml_name) + # That's an array + else: + if internal_type: # Complex type, ignore itemsName and use the complex type name + items_name = _extract_name_from_internal_type(internal_type) + else: + items_name = xml_desc.get("itemsName", xml_name) + children = data.findall(items_name) + + if len(children) == 0: + if is_iter_type: + if is_wrapped: + return None # is_wrapped no node, we want None + else: + return [] # not wrapped, assume empty list + return None # Assume it's not there, maybe an optional node. + + # If is_iter_type and not wrapped, return all found children + if is_iter_type: + if not is_wrapped: + return children + else: # Iter and wrapped, should have found one node only (the wrap one) + if len(children) != 1: + raise DeserializationError( + "Tried to deserialize an array not wrapped, and found several nodes '{}'. Maybe you should declare this array as wrapped?".format( + xml_name + )) + return list(children[0]) # Might be empty list and that's ok. + + # Here it's not a itertype, we should have found one element only or empty + if len(children) > 1: + raise DeserializationError("Find several XML '{}' where it was not expected".format(xml_name)) + return children[0] + +class Deserializer(object): + """Response object model deserializer. + + :param dict classes: Class type dictionary for deserializing complex types. + :ivar list key_extractors: Ordered list of extractors to be used by this deserializer. + """ + + basic_types = {str: 'str', int: 'int', bool: 'bool', float: 'float'} + + valid_date = re.compile( + r'\d{4}[-]\d{2}[-]\d{2}T\d{2}:\d{2}:\d{2}' + r'\.?\d*Z?[-+]?[\d{2}]?:?[\d{2}]?') + + def __init__(self, classes=None): + self.deserialize_type = { + 'iso-8601': Deserializer.deserialize_iso, + 'rfc-1123': Deserializer.deserialize_rfc, + 'unix-time': Deserializer.deserialize_unix, + 'duration': Deserializer.deserialize_duration, + 'date': Deserializer.deserialize_date, + 'time': Deserializer.deserialize_time, + 'decimal': Deserializer.deserialize_decimal, + 'long': Deserializer.deserialize_long, + 'bytearray': Deserializer.deserialize_bytearray, + 'base64': Deserializer.deserialize_base64, + 'object': self.deserialize_object, + '[]': self.deserialize_iter, + '{}': self.deserialize_dict + } + self.deserialize_expected_types = { + 'duration': (isodate.Duration, datetime.timedelta), + 'iso-8601': (datetime.datetime) + } + self.dependencies = 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 + # complicated, with no real scenario for now. + # So adding a flag to disable additional properties detection. This flag should be + # used if your expect the deserialization to NOT come from a JSON REST syntax. + # Otherwise, result are unexpected + self.additional_properties_detection = True + + def __call__(self, target_obj, response_data, content_type=None): + """Call the deserializer to process a REST response. + + :param str target_obj: Target data type to deserialize to. + :param requests.Response response_data: REST response object. + :param str content_type: Swagger "produces" if available. + :raises: DeserializationError if deserialization fails. + :return: Deserialized object. + """ + data = self._unpack_content(response_data, content_type) + return self._deserialize(target_obj, data) + + def _deserialize(self, target_obj, data): + """Call the deserializer on a model. + + Data needs to be already deserialized as JSON or XML ElementTree + + :param str target_obj: Target data type to deserialize to. + :param object data: Object to deserialize. + :raises: DeserializationError if deserialization fails. + :return: Deserialized object. + """ + # This is already a model, go recursive just in case + if hasattr(data, "_attribute_map"): + constants = [name for name, config in getattr(data, '_validation', {}).items() + if config.get('constant')] + try: + for attr, mapconfig in data._attribute_map.items(): + if attr in constants: + continue + value = getattr(data, attr) + if value is None: + continue + local_type = mapconfig['type'] + internal_data_type = local_type.strip('[]{}') + if internal_data_type not in self.dependencies or isinstance(internal_data_type, Enum): + continue + setattr( + data, + attr, + self._deserialize(local_type, value) + ) + return data + except AttributeError: + return + + response, class_name = self._classify_target(target_obj, data) + + if isinstance(response, basestring): + return self.deserialize_data(data, response) + elif isinstance(response, type) and issubclass(response, Enum): + return self.deserialize_enum(data, response) + + if data is None: + return data + try: + attributes = response._attribute_map + d_attrs = {} + for attr, attr_desc in attributes.items(): + # Check empty string. If it's not empty, someone has a real "additionalProperties"... + if attr == "additional_properties" and attr_desc["key"] == '': + continue + raw_value = None + # Enhance attr_desc with some dynamic data + attr_desc = attr_desc.copy() # Do a copy, do not change the real one + internal_data_type = attr_desc["type"].strip('[]{}') + if internal_data_type in self.dependencies: + attr_desc["internalType"] = self.dependencies[internal_data_type] + + for key_extractor in self.key_extractors: + found_value = key_extractor(attr, attr_desc, data) + if found_value is not None: + if raw_value is not None and raw_value != found_value: + msg = ("Ignoring extracted value '%s' from %s for key '%s'" + " (duplicate extraction, follow extractors order)" ) + _LOGGER.warning( + msg, + found_value, + key_extractor, + attr + ) + continue + raw_value = found_value + + 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 + raise_with_traceback(DeserializationError, msg, err) + else: + additional_properties = self._build_additional_properties(attributes, data) + return self._instantiate_model(response, d_attrs, additional_properties) + + def _build_additional_properties(self, attribute_map, data): + if not self.additional_properties_detection: + return None + if "additional_properties" in attribute_map and attribute_map.get("additional_properties", {}).get("key") != '': + # Check empty string. If it's not empty, someone has a real "additionalProperties" + return None + if isinstance(data, ET.Element): + data = {el.tag: el.text for el in data} + + known_keys = {_decode_attribute_map_key(_FLATTEN.split(desc['key'])[0]) + for desc in attribute_map.values() if desc['key'] != ''} + present_keys = set(data.keys()) + missing_keys = present_keys - known_keys + return {key: data[key] for key in missing_keys} + + def _classify_target(self, target, data): + """Check to see whether the deserialization target object can + be classified into a subclass. + 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. + """ + if target is None: + return None, None + + if isinstance(target, basestring): + try: + target = self.dependencies[target] + except KeyError: + return target, target + + try: + target = target._classify(data, self.dependencies) + except AttributeError: + pass # Target is not a Model, no classify + return target, target.__class__.__name__ + + def failsafe_deserialize(self, target_obj, data, content_type=None): + """Ignores any errors encountered in deserialization, + and falls back to not deserializing the object. Recommended + for use in error deserialization, as we want to return the + HttpResponseError to users, and not have them deal with + 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 content_type: Swagger "produces" if available. + """ + try: + return self(target_obj, data, content_type=content_type) + except: + _LOGGER.debug( + "Ran into a deserialization error. Ignoring since this is failsafe deserialization", + exc_info=True + ) + return None + + @staticmethod + def _unpack_content(raw_data, content_type=None): + """Extract the correct structure for deserialization. + + If raw_data is a PipelineResponse, try to extract the result of RawDeserializer. + if we can't, raise. Your Pipeline should have a RawDeserializer. + + If not a pipeline response and raw_data is bytes or string, use content-type + to decode it. If no content-type, try JSON. + + If raw_data is something else, bypass all logic and return it directly. + + :param raw_data: Data to be processed. + :param content_type: How to parse if raw_data is a string/bytes. + :raises JSONDecodeError: If JSON is requested and parsing is impossible. + :raises UnicodeDecodeError: If bytes is not UTF8 + """ + # Assume this is enough to detect a Pipeline Response without importing it + context = getattr(raw_data, "context", {}) + if context: + if RawDeserializer.CONTEXT_NAME in context: + return context[RawDeserializer.CONTEXT_NAME] + raise ValueError("This pipeline didn't have the RawDeserializer policy; can't deserialize") + + #Assume this is enough to recognize universal_http.ClientResponse without importing it + if hasattr(raw_data, "body"): + return RawDeserializer.deserialize_from_http_generics( + raw_data.text(), + raw_data.headers + ) + + # Assume this enough to recognize requests.Response without importing it. + if hasattr(raw_data, '_content_consumed'): + 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 raw_data + + def _instantiate_model(self, response, attrs, additional_properties=None): + """Instantiate a response model passing in deserialized args. + + :param response: The response model class. + :param d_attrs: The deserialized response attributes. + """ + if callable(response): + subtype = getattr(response, '_subtype_map', {}) + try: + readonly = [k for k, v in response._validation.items() + if v.get('readonly')] + const = [k for k, v in response._validation.items() + if v.get('constant')] + kwargs = {k: v for k, v in attrs.items() + if k not in subtype and k not in readonly + const} + response_obj = response(**kwargs) + for attr in readonly: + setattr(response_obj, attr, attrs.get(attr)) + if additional_properties: + response_obj.additional_properties = additional_properties + return response_obj + except TypeError as err: + msg = "Unable to deserialize {} into model {}. ".format( + kwargs, response) + raise DeserializationError(msg + str(err)) + else: + try: + for attr, value in attrs.items(): + setattr(response, attr, value) + return response + except Exception as exp: + msg = "Unable to populate response model. " + msg += "Type: {}, Error: {}".format(type(response), exp) + raise DeserializationError(msg) + + def deserialize_data(self, data, data_type): + """Process data for deserialization according to data type. + + :param str data: The response string to be deserialized. + :param str data_type: The type to deserialize to. + :raises: DeserializationError if deserialization fails. + :return: Deserialized object. + """ + if data is None: + return data + + try: + if not data_type: + return data + if data_type in self.basic_types.values(): + return self.deserialize_basic(data, data_type) + if data_type in self.deserialize_type: + if isinstance(data, self.deserialize_expected_types.get(data_type, tuple())): + return data + + is_a_text_parsing_type = lambda x: x not in ["object", "[]", r"{}"] + if isinstance(data, ET.Element) and is_a_text_parsing_type(data_type) and not data.text: + return None + data_val = self.deserialize_type[data_type](data) + return data_val + + iter_type = data_type[0] + data_type[-1] + if iter_type in self.deserialize_type: + return self.deserialize_type[iter_type](data, data_type[1:-1]) + + obj_type = self.dependencies[data_type] + if issubclass(obj_type, Enum): + if isinstance(data, ET.Element): + data = data.text + return self.deserialize_enum(data, obj_type) + + except (ValueError, TypeError, AttributeError) as err: + msg = "Unable to deserialize response data." + msg += " Data: {}, {}".format(data, data_type) + raise_with_traceback(DeserializationError, msg, err) + else: + return self._deserialize(obj_type, data) + + def deserialize_iter(self, attr, iter_type): + """Deserialize an iterable. + + :param list attr: Iterable to be deserialized. + :param str iter_type: The type of object in the iterable. + :rtype: list + """ + if attr is None: + return None + if isinstance(attr, ET.Element): # If I receive an element here, get the children + attr = list(attr) + if not isinstance(attr, (list, set)): + raise DeserializationError("Cannot deserialize as [{}] an object of type {}".format( + iter_type, + type(attr) + )) + return [self.deserialize_data(a, iter_type) for a in attr] + + def deserialize_dict(self, attr, dict_type): + """Deserialize a dictionary. + + :param dict/list attr: Dictionary to be deserialized. Also accepts + a list of key, value pairs. + :param str dict_type: The object type of the items in the dictionary. + :rtype: dict + """ + if isinstance(attr, list): + return {x['key']: self.deserialize_data(x['value'], dict_type) for x in attr} + + if isinstance(attr, ET.Element): + # Transform value into {"Key": "value"} + attr = {el.tag: el.text for el in attr} + return {k: self.deserialize_data(v, dict_type) for k, v in attr.items()} + + def deserialize_object(self, attr, **kwargs): + """Deserialize a generic object. + This will be handled as a dictionary. + + :param dict attr: Dictionary to be deserialized. + :rtype: dict + :raises: TypeError if non-builtin datatype encountered. + """ + if attr is None: + return None + if isinstance(attr, ET.Element): + # Do no recurse on XML, just return the tree as-is + return attr + if isinstance(attr, basestring): + return self.deserialize_basic(attr, 'str') + obj_type = type(attr) + if obj_type in self.basic_types: + return self.deserialize_basic(attr, self.basic_types[obj_type]) + if obj_type is _long_type: + return self.deserialize_long(attr) + + if obj_type == dict: + deserialized = {} + for key, value in attr.items(): + try: + deserialized[key] = self.deserialize_object( + value, **kwargs) + except ValueError: + deserialized[key] = None + return deserialized + + if obj_type == list: + deserialized = [] + for obj in attr: + try: + deserialized.append(self.deserialize_object( + obj, **kwargs)) + except ValueError: + pass + return deserialized + + else: + error = "Cannot deserialize generic object with type: " + raise TypeError(error + str(obj_type)) + + def deserialize_basic(self, attr, data_type): + """Deserialize basic builtin data type from string. + Will attempt to convert to str, int, float and bool. + This function will also accept '1', '0', 'true' and 'false' as + valid bool values. + + :param str attr: response string to be deserialized. + :param str data_type: deserialization data type. + :rtype: str, int, float or bool + :raises: TypeError if string format is not valid. + """ + # If we're here, data is supposed to be a basic type. + # If it's still an XML node, take the text + if isinstance(attr, ET.Element): + attr = attr.text + if not attr: + if data_type == "str": + # None or '', node is empty string. + return '' + else: + # None or '', node with a strong type is None. + # Don't try to model "empty bool" or "empty int" + return None + + if data_type == 'bool': + if attr in [True, False, 1, 0]: + return bool(attr) + elif isinstance(attr, basestring): + if attr.lower() in ['true', '1']: + return True + elif attr.lower() in ['false', '0']: + return False + raise TypeError("Invalid boolean value: {}".format(attr)) + + if data_type == 'str': + return self.deserialize_unicode(attr) + return eval(data_type)(attr) # nosec + + @staticmethod + def deserialize_unicode(data): + """Preserve unicode objects in Python 2, otherwise return data + as a string. + + :param str data: response string to be deserialized. + :rtype: str or unicode + """ + # We might be here because we have an enum modeled as string, + # and we try to deserialize a partial dict with enum inside + if isinstance(data, Enum): + return data + + # Consider this is real string + try: + if isinstance(data, unicode): + return data + except NameError: + return str(data) + else: + return str(data) + + @staticmethod + def deserialize_enum(data, enum_obj): + """Deserialize string into enum object. + + If the string is not a valid enum value it will be returned as-is + and a warning will be logged. + + :param str data: Response string to be deserialized. If this value is + None or invalid it will be returned as-is. + :param Enum enum_obj: Enum object to deserialize to. + :rtype: Enum + """ + if isinstance(data, enum_obj) or data is None: + return data + if isinstance(data, Enum): + data = data.value + if isinstance(data, int): + # Workaround. We might consider remove it in the future. + # https://github.com/Azure/azure-rest-api-specs/issues/141 + try: + return list(enum_obj.__members__.values())[data] + except IndexError: + error = "{!r} is not a valid index for enum {!r}" + raise DeserializationError(error.format(data, enum_obj)) + try: + return enum_obj(str(data)) + except ValueError: + for enum_value in enum_obj: + if enum_value.value.lower() == str(data).lower(): + return enum_value + # We don't fail anymore for unknown value, we deserialize as a string + _LOGGER.warning("Deserializer is not able to find %s as valid enum in %s", data, enum_obj) + return Deserializer.deserialize_unicode(data) + + @staticmethod + def deserialize_bytearray(attr): + """Deserialize string into bytearray. + + :param str attr: response string to be deserialized. + :rtype: bytearray + :raises: TypeError if string format invalid. + """ + if isinstance(attr, ET.Element): + attr = attr.text + return bytearray(b64decode(attr)) + + @staticmethod + def deserialize_base64(attr): + """Deserialize base64 encoded string into string. + + :param str attr: response string to be deserialized. + :rtype: bytearray + :raises: TypeError if string format invalid. + """ + if isinstance(attr, ET.Element): + attr = attr.text + padding = '=' * (3 - (len(attr) + 3) % 4) + attr = attr + padding + encoded = attr.replace('-', '+').replace('_', '/') + return b64decode(encoded) + + @staticmethod + def deserialize_decimal(attr): + """Deserialize string into Decimal object. + + :param str attr: response string to be deserialized. + :rtype: Decimal + :raises: DeserializationError if string format invalid. + """ + if isinstance(attr, ET.Element): + attr = attr.text + try: + return decimal.Decimal(attr) + except decimal.DecimalException as err: + msg = "Invalid decimal {}".format(attr) + raise_with_traceback(DeserializationError, msg, err) + + @staticmethod + def deserialize_long(attr): + """Deserialize string into long (Py2) or int (Py3). + + :param str attr: response string to be deserialized. + :rtype: long or int + :raises: ValueError if string format invalid. + """ + if isinstance(attr, ET.Element): + attr = attr.text + return _long_type(attr) + + @staticmethod + def deserialize_duration(attr): + """Deserialize ISO-8601 formatted string into TimeDelta object. + + :param str attr: response string to be deserialized. + :rtype: TimeDelta + :raises: DeserializationError if string format invalid. + """ + if isinstance(attr, ET.Element): + attr = attr.text + try: + duration = isodate.parse_duration(attr) + except(ValueError, OverflowError, AttributeError) as err: + msg = "Cannot deserialize duration object." + raise_with_traceback(DeserializationError, msg, err) + else: + return duration + + @staticmethod + def deserialize_date(attr): + """Deserialize ISO-8601 formatted string into Date object. + + :param str attr: response string to be deserialized. + :rtype: Date + :raises: DeserializationError if string format invalid. + """ + if isinstance(attr, ET.Element): + attr = attr.text + if re.search(r"[^\W\d_]", attr, re.I + re.U): + 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) + + @staticmethod + def deserialize_time(attr): + """Deserialize ISO-8601 formatted string into time object. + + :param str attr: response string to be deserialized. + :rtype: datetime.time + :raises: DeserializationError if string format invalid. + """ + if isinstance(attr, ET.Element): + attr = attr.text + if re.search(r"[^\W\d_]", attr, re.I + re.U): + raise DeserializationError("Date must have only digits and -. Received: %s" % attr) + return isodate.parse_time(attr) + + @staticmethod + def deserialize_rfc(attr): + """Deserialize RFC-1123 formatted string into Datetime object. + + :param str attr: response string to be deserialized. + :rtype: Datetime + :raises: DeserializationError if string format invalid. + """ + if isinstance(attr, ET.Element): + attr = attr.text + try: + parsed_date = email.utils.parsedate_tz(attr) + date_obj = datetime.datetime( + *parsed_date[:6], + tzinfo=_FixedOffset(datetime.timedelta(minutes=(parsed_date[9] or 0)/60)) + ) + if not date_obj.tzinfo: + date_obj = date_obj.astimezone(tz=TZ_UTC) + except ValueError as err: + msg = "Cannot deserialize to rfc datetime object." + raise_with_traceback(DeserializationError, msg, err) + else: + return date_obj + + @staticmethod + def deserialize_iso(attr): + """Deserialize ISO-8601 formatted string into Datetime object. + + :param str attr: response string to be deserialized. + :rtype: Datetime + :raises: DeserializationError if string format invalid. + """ + if isinstance(attr, ET.Element): + attr = attr.text + try: + attr = attr.upper() + match = Deserializer.valid_date.match(attr) + if not match: + raise ValueError("Invalid datetime string: " + attr) + + check_decimal = attr.split('.') + if len(check_decimal) > 1: + decimal_str = "" + for digit in check_decimal[1]: + if digit.isdigit(): + decimal_str += digit + else: + break + if len(decimal_str) > 6: + attr = attr.replace(decimal_str, decimal_str[0:6]) + + date_obj = isodate.parse_datetime(attr) + test_utc = date_obj.utctimetuple() + if test_utc.tm_year > 9999 or test_utc.tm_year < 1: + raise OverflowError("Hit max or min date") + except(ValueError, OverflowError, AttributeError) as err: + msg = "Cannot deserialize datetime object." + raise_with_traceback(DeserializationError, msg, err) + else: + return date_obj + + @staticmethod + def deserialize_unix(attr): + """Serialize Datetime object into IntTime format. + This is represented as seconds. + + :param int attr: Object to be serialized. + :rtype: Datetime + :raises: DeserializationError if format invalid + """ + if isinstance(attr, ET.Element): + attr = int(attr.text) + try: + date_obj = datetime.datetime.fromtimestamp(attr, TZ_UTC) + except ValueError as err: + msg = "Cannot deserialize to unix datetime object." + raise_with_traceback(DeserializationError, msg, err) + else: + return date_obj diff --git a/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/templatespecs/_template_specs_client.py b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/templatespecs/_template_specs_client.py index ebf54ec2e3814..97a66ad3e7a38 100644 --- a/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/templatespecs/_template_specs_client.py +++ b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/templatespecs/_template_specs_client.py @@ -9,20 +9,17 @@ # regenerated. # -------------------------------------------------------------------------- -from typing import TYPE_CHECKING - -from msrest import Deserializer, Serializer +from typing import Any, Optional, TYPE_CHECKING from azure.mgmt.core import ARMPipelineClient from azure.profiles import KnownProfiles, ProfileDefinition from azure.profiles.multiapiclient import MultiApiClientMixin from ._configuration import TemplateSpecsClientConfiguration +from ._serialization import Deserializer, Serializer if TYPE_CHECKING: # pylint: disable=unused-import,ungrouped-imports - from typing import Any, Optional - from azure.core.credentials import TokenCredential class _SDKClient(object): @@ -43,9 +40,9 @@ class TemplateSpecsClient(MultiApiClientMixin, _SDKClient): The api-version parameter sets the default API version if the operation group is not described in the profile. - :param credential: Credential needed for the client to connect to Azure. + :param credential: Credential needed for the client to connect to Azure. Required. :type credential: ~azure.core.credentials.TokenCredential - :param subscription_id: Subscription Id which forms part of the URI for every service call. + :param subscription_id: Subscription Id which forms part of the URI for every service call. Required. :type subscription_id: str :param api_version: API version to use if no profile is provided, or if missing in profile. :type api_version: str @@ -66,10 +63,10 @@ class TemplateSpecsClient(MultiApiClientMixin, _SDKClient): def __init__( self, - credential, # type: "TokenCredential" - subscription_id, # type: str + credential: "TokenCredential", + subscription_id: str, api_version=None, # type: Optional[str] - base_url="https://management.azure.com", # type: str + base_url: str = "https://management.azure.com", profile=KnownProfiles.default, # type: KnownProfiles **kwargs # type: Any ): diff --git a/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/templatespecs/aio/_configuration.py b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/templatespecs/aio/_configuration.py index 332b210851ed6..1c943740847ae 100644 --- a/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/templatespecs/aio/_configuration.py +++ b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/templatespecs/aio/_configuration.py @@ -26,9 +26,9 @@ class TemplateSpecsClientConfiguration(Configuration): Note that all parameters used to create this instance are saved as instance attributes. - :param credential: Credential needed for the client to connect to Azure. + :param credential: Credential needed for the client to connect to Azure. Required. :type credential: ~azure.core.credentials_async.AsyncTokenCredential - :param subscription_id: Subscription Id which forms part of the URI for every service call. + :param subscription_id: Subscription Id which forms part of the URI for every service call. Required. :type subscription_id: str """ diff --git a/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/templatespecs/aio/_template_specs_client.py b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/templatespecs/aio/_template_specs_client.py index 8fc59bf168174..a16159448af99 100644 --- a/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/templatespecs/aio/_template_specs_client.py +++ b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/templatespecs/aio/_template_specs_client.py @@ -11,17 +11,15 @@ from typing import Any, Optional, TYPE_CHECKING -from msrest import Deserializer, Serializer - from azure.mgmt.core import AsyncARMPipelineClient from azure.profiles import KnownProfiles, ProfileDefinition from azure.profiles.multiapiclient import MultiApiClientMixin +from .._serialization import Deserializer, Serializer from ._configuration import TemplateSpecsClientConfiguration if TYPE_CHECKING: # pylint: disable=unused-import,ungrouped-imports - from azure.core.credentials import TokenCredential from azure.core.credentials_async import AsyncTokenCredential class _SDKClient(object): @@ -42,9 +40,9 @@ class TemplateSpecsClient(MultiApiClientMixin, _SDKClient): The api-version parameter sets the default API version if the operation group is not described in the profile. - :param credential: Credential needed for the client to connect to Azure. + :param credential: Credential needed for the client to connect to Azure. Required. :type credential: ~azure.core.credentials_async.AsyncTokenCredential - :param subscription_id: Subscription Id which forms part of the URI for every service call. + :param subscription_id: Subscription Id which forms part of the URI for every service call. Required. :type subscription_id: str :param api_version: API version to use if no profile is provided, or if missing in profile. :type api_version: str diff --git a/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/templatespecs/v2019_06_01_preview/__init__.py b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/templatespecs/v2019_06_01_preview/__init__.py index 4005d4a7201ea..1d05585f5c592 100644 --- a/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/templatespecs/v2019_06_01_preview/__init__.py +++ b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/templatespecs/v2019_06_01_preview/__init__.py @@ -10,9 +10,15 @@ from ._version import VERSION __version__ = VERSION -__all__ = ['TemplateSpecsClient'] -# `._patch.py` is used for handwritten extensions to the generated code -# Example: https://github.com/Azure/azure-sdk-for-python/blob/main/doc/dev/customize_code/how-to-patch-sdk-code.md -from ._patch import patch_sdk -patch_sdk() +try: + from ._patch import __all__ as _patch_all + from ._patch import * # type: ignore # pylint: disable=unused-wildcard-import +except ImportError: + _patch_all = [] +from ._patch import patch_sdk as _patch_sdk + +__all__ = ["TemplateSpecsClient"] +__all__.extend([p for p in _patch_all if p not in __all__]) + +_patch_sdk() diff --git a/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/templatespecs/v2019_06_01_preview/_configuration.py b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/templatespecs/v2019_06_01_preview/_configuration.py index 57dbdd5bf855a..3fb8307ac827c 100644 --- a/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/templatespecs/v2019_06_01_preview/_configuration.py +++ b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/templatespecs/v2019_06_01_preview/_configuration.py @@ -25,23 +25,19 @@ class TemplateSpecsClientConfiguration(Configuration): # pylint: disable=too-ma Note that all parameters used to create this instance are saved as instance attributes. - :param credential: Credential needed for the client to connect to Azure. + :param credential: Credential needed for the client to connect to Azure. Required. :type credential: ~azure.core.credentials.TokenCredential :param subscription_id: Subscription Id which forms part of the URI for every service call. + Required. :type subscription_id: str :keyword api_version: Api Version. Default value is "2019-06-01-preview". Note that overriding this default value may result in unsupported behavior. :paramtype api_version: str """ - def __init__( - self, - credential: "TokenCredential", - subscription_id: str, - **kwargs: Any - ) -> None: + def __init__(self, credential: "TokenCredential", subscription_id: str, **kwargs: Any) -> None: super(TemplateSpecsClientConfiguration, self).__init__(**kwargs) - api_version = kwargs.pop('api_version', "2019-06-01-preview") # type: str + api_version = kwargs.pop("api_version", "2019-06-01-preview") # type: str if credential is None: raise ValueError("Parameter 'credential' must not be None.") @@ -51,23 +47,24 @@ def __init__( self.credential = credential self.subscription_id = subscription_id self.api_version = api_version - self.credential_scopes = kwargs.pop('credential_scopes', ['https://management.azure.com/.default']) - kwargs.setdefault('sdk_moniker', 'mgmt-resource/{}'.format(VERSION)) + self.credential_scopes = kwargs.pop("credential_scopes", ["https://management.azure.com/.default"]) + kwargs.setdefault("sdk_moniker", "mgmt-resource/{}".format(VERSION)) self._configure(**kwargs) def _configure( - self, - **kwargs # type: Any + self, **kwargs # type: Any ): # type: (...) -> 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) - self.logging_policy = kwargs.get('logging_policy') or policies.NetworkTraceLoggingPolicy(**kwargs) - self.http_logging_policy = kwargs.get('http_logging_policy') or ARMHttpLoggingPolicy(**kwargs) - self.retry_policy = kwargs.get('retry_policy') or policies.RetryPolicy(**kwargs) - self.custom_hook_policy = kwargs.get('custom_hook_policy') or policies.CustomHookPolicy(**kwargs) - self.redirect_policy = kwargs.get('redirect_policy') or policies.RedirectPolicy(**kwargs) - self.authentication_policy = kwargs.get('authentication_policy') + 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) + self.logging_policy = kwargs.get("logging_policy") or policies.NetworkTraceLoggingPolicy(**kwargs) + self.http_logging_policy = kwargs.get("http_logging_policy") or ARMHttpLoggingPolicy(**kwargs) + self.retry_policy = kwargs.get("retry_policy") or policies.RetryPolicy(**kwargs) + self.custom_hook_policy = kwargs.get("custom_hook_policy") or policies.CustomHookPolicy(**kwargs) + self.redirect_policy = kwargs.get("redirect_policy") or policies.RedirectPolicy(**kwargs) + self.authentication_policy = kwargs.get("authentication_policy") if self.credential and not self.authentication_policy: - self.authentication_policy = ARMChallengeAuthenticationPolicy(self.credential, *self.credential_scopes, **kwargs) + self.authentication_policy = ARMChallengeAuthenticationPolicy( + self.credential, *self.credential_scopes, **kwargs + ) diff --git a/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/templatespecs/v2019_06_01_preview/_metadata.json b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/templatespecs/v2019_06_01_preview/_metadata.json index 8aaeedacf3334..85e51b048c9f6 100644 --- a/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/templatespecs/v2019_06_01_preview/_metadata.json +++ b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/templatespecs/v2019_06_01_preview/_metadata.json @@ -10,20 +10,20 @@ "azure_arm": true, "has_lro_operations": false, "client_side_validation": false, - "sync_imports": "{\"typing\": {\"azurecore\": {\"azure.core.credentials\": [\"TokenCredential\"]}}, \"regular\": {\"azurecore\": {\"azure.profiles\": [\"KnownProfiles\", \"ProfileDefinition\"], \"azure.profiles.multiapiclient\": [\"MultiApiClientMixin\"], \"azure.mgmt.core\": [\"ARMPipelineClient\"]}, \"local\": {\"._configuration\": [\"TemplateSpecsClientConfiguration\"]}, \"thirdparty\": {\"msrest\": [\"Deserializer\", \"Serializer\"]}}, \"conditional\": {\"stdlib\": {\"typing\": [\"Any\", \"Optional\"]}}}", - "async_imports": "{\"typing\": {\"azurecore\": {\"azure.core.credentials_async\": [\"AsyncTokenCredential\"], \"azure.core.credentials\": [\"TokenCredential\"]}}, \"regular\": {\"azurecore\": {\"azure.profiles\": [\"KnownProfiles\", \"ProfileDefinition\"], \"azure.profiles.multiapiclient\": [\"MultiApiClientMixin\"], \"azure.mgmt.core\": [\"AsyncARMPipelineClient\"]}, \"local\": {\"._configuration\": [\"TemplateSpecsClientConfiguration\"]}, \"thirdparty\": {\"msrest\": [\"Deserializer\", \"Serializer\"]}}, \"conditional\": {\"stdlib\": {\"typing\": [\"Any\", \"Optional\"]}}}" + "sync_imports": "{\"conditional\": {\"stdlib\": {\"typing\": [\"Any\", \"Optional\"]}}, \"regular\": {\"azurecore\": {\"azure.mgmt.core\": [\"ARMPipelineClient\"], \"azure.profiles\": [\"KnownProfiles\", \"ProfileDefinition\"], \"azure.profiles.multiapiclient\": [\"MultiApiClientMixin\"]}, \"local\": {\"._configuration\": [\"TemplateSpecsClientConfiguration\"], \".._serialization\": [\"Deserializer\", \"Serializer\"]}}, \"typing\": {\"azurecore\": {\"azure.core.credentials\": [\"TokenCredential\"]}}}", + "async_imports": "{\"conditional\": {\"stdlib\": {\"typing\": [\"Any\", \"Optional\"]}}, \"regular\": {\"azurecore\": {\"azure.mgmt.core\": [\"AsyncARMPipelineClient\"], \"azure.profiles\": [\"KnownProfiles\", \"ProfileDefinition\"], \"azure.profiles.multiapiclient\": [\"MultiApiClientMixin\"]}, \"local\": {\"._configuration\": [\"TemplateSpecsClientConfiguration\"], \"..._serialization\": [\"Deserializer\", \"Serializer\"]}}, \"typing\": {\"azurecore\": {\"azure.core.credentials_async\": [\"AsyncTokenCredential\"]}}}" }, "global_parameters": { "sync": { "credential": { - "signature": "credential, # type: \"TokenCredential\"", - "description": "Credential needed for the client to connect to Azure.", + "signature": "credential: \"TokenCredential\",", + "description": "Credential needed for the client to connect to Azure. Required.", "docstring_type": "~azure.core.credentials.TokenCredential", "required": true }, "subscription_id": { - "signature": "subscription_id, # type: str", - "description": "Subscription Id which forms part of the URI for every service call.", + "signature": "subscription_id: str,", + "description": "Subscription Id which forms part of the URI for every service call. Required.", "docstring_type": "str", "required": true } @@ -31,13 +31,13 @@ "async": { "credential": { "signature": "credential: \"AsyncTokenCredential\",", - "description": "Credential needed for the client to connect to Azure.", + "description": "Credential needed for the client to connect to Azure. Required.", "docstring_type": "~azure.core.credentials_async.AsyncTokenCredential", "required": true }, "subscription_id": { "signature": "subscription_id: str,", - "description": "Subscription Id which forms part of the URI for every service call.", + "description": "Subscription Id which forms part of the URI for every service call. Required.", "docstring_type": "str", "required": true } @@ -54,7 +54,7 @@ "required": false }, "base_url": { - "signature": "base_url=\"https://management.azure.com\", # type: str", + "signature": "base_url: str = \"https://management.azure.com\",", "description": "Service URL", "docstring_type": "str", "required": false diff --git a/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/templatespecs/v2019_06_01_preview/_patch.py b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/templatespecs/v2019_06_01_preview/_patch.py index 74e48ecd07cf3..f99e77fef9861 100644 --- a/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/templatespecs/v2019_06_01_preview/_patch.py +++ b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/templatespecs/v2019_06_01_preview/_patch.py @@ -28,4 +28,4 @@ # This file is used for handwritten extensions to the generated code. Example: # https://github.com/Azure/azure-sdk-for-python/blob/main/doc/dev/customize_code/how-to-patch-sdk-code.md def patch_sdk(): - pass \ No newline at end of file + pass diff --git a/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/templatespecs/v2019_06_01_preview/_template_specs_client.py b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/templatespecs/v2019_06_01_preview/_template_specs_client.py index 4c36361219bad..836289c693224 100644 --- a/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/templatespecs/v2019_06_01_preview/_template_specs_client.py +++ b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/templatespecs/v2019_06_01_preview/_template_specs_client.py @@ -9,12 +9,11 @@ from copy import deepcopy from typing import Any, TYPE_CHECKING -from msrest import Deserializer, Serializer - from azure.core.rest import HttpRequest, HttpResponse from azure.mgmt.core import ARMPipelineClient from . import models +from .._serialization import Deserializer, Serializer from ._configuration import TemplateSpecsClientConfiguration from .operations import TemplateSpecVersionsOperations, TemplateSpecsOperations @@ -22,7 +21,8 @@ # pylint: disable=unused-import,ungrouped-imports from azure.core.credentials import TokenCredential -class TemplateSpecsClient: + +class TemplateSpecsClient: # pylint: disable=client-accepts-api-version-keyword """The APIs listed in this specification can be used to manage Template Spec resources through the Azure Resource Manager. @@ -32,9 +32,10 @@ class TemplateSpecsClient: :ivar template_spec_versions: TemplateSpecVersionsOperations operations :vartype template_spec_versions: azure.mgmt.resource.templatespecs.v2019_06_01_preview.operations.TemplateSpecVersionsOperations - :param credential: Credential needed for the client to connect to Azure. + :param credential: Credential needed for the client to connect to Azure. Required. :type credential: ~azure.core.credentials.TokenCredential :param subscription_id: Subscription Id which forms part of the URI for every service call. + Required. :type subscription_id: str :param base_url: Service URL. Default value is "https://management.azure.com". :type base_url: str @@ -50,7 +51,9 @@ def __init__( base_url: str = "https://management.azure.com", **kwargs: Any ) -> None: - self._config = TemplateSpecsClientConfiguration(credential=credential, subscription_id=subscription_id, **kwargs) + self._config = TemplateSpecsClientConfiguration( + credential=credential, subscription_id=subscription_id, **kwargs + ) self._client = ARMPipelineClient(base_url=base_url, config=self._config, **kwargs) client_models = {k: v for k, v in models.__dict__.items() if isinstance(v, type)} @@ -58,14 +61,11 @@ def __init__( self._deserialize = Deserializer(client_models) self._serialize.client_side_validation = False self.template_specs = TemplateSpecsOperations(self._client, self._config, self._serialize, self._deserialize) - self.template_spec_versions = TemplateSpecVersionsOperations(self._client, self._config, self._serialize, self._deserialize) - + self.template_spec_versions = TemplateSpecVersionsOperations( + self._client, self._config, self._serialize, self._deserialize + ) - def _send_request( - self, - request: HttpRequest, - **kwargs: Any - ) -> HttpResponse: + def _send_request(self, request: HttpRequest, **kwargs: Any) -> HttpResponse: """Runs the network request through the client's chained policies. >>> from azure.core.rest import HttpRequest @@ -74,7 +74,7 @@ def _send_request( >>> response = client._send_request(request) - For more information on this code flow, see https://aka.ms/azsdk/python/protocol/quickstart + For more information on this code flow, see https://aka.ms/azsdk/dpcodegen/python/send_request :param request: The network request you want to make. Required. :type request: ~azure.core.rest.HttpRequest diff --git a/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/templatespecs/v2019_06_01_preview/_vendor.py b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/templatespecs/v2019_06_01_preview/_vendor.py index 138f663c53a4e..9aad73fc743e7 100644 --- a/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/templatespecs/v2019_06_01_preview/_vendor.py +++ b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/templatespecs/v2019_06_01_preview/_vendor.py @@ -7,6 +7,7 @@ from azure.core.pipeline.transport import HttpRequest + def _convert_request(request, files=None): data = request.content if not files else None request = HttpRequest(method=request.method, url=request.url, headers=request.headers, data=data) @@ -14,6 +15,7 @@ def _convert_request(request, files=None): request.set_formdata_body(files) return request + def _format_url_section(template, **kwargs): components = template.split("/") while components: @@ -21,7 +23,5 @@ def _format_url_section(template, **kwargs): 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 - ] + components = [c for c in formatted_components if "{}".format(key.args[0]) not in c] template = "/".join(components) diff --git a/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/templatespecs/v2019_06_01_preview/_version.py b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/templatespecs/v2019_06_01_preview/_version.py index a012ac01c480c..e5754a47ce68f 100644 --- a/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/templatespecs/v2019_06_01_preview/_version.py +++ b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/templatespecs/v2019_06_01_preview/_version.py @@ -6,4 +6,4 @@ # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -VERSION = "21.1.0" +VERSION = "1.0.0b1" diff --git a/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/templatespecs/v2019_06_01_preview/aio/__init__.py b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/templatespecs/v2019_06_01_preview/aio/__init__.py index 9c8e93c3f82aa..c5e1e112f0111 100644 --- a/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/templatespecs/v2019_06_01_preview/aio/__init__.py +++ b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/templatespecs/v2019_06_01_preview/aio/__init__.py @@ -7,9 +7,15 @@ # -------------------------------------------------------------------------- from ._template_specs_client import TemplateSpecsClient -__all__ = ['TemplateSpecsClient'] -# `._patch.py` is used for handwritten extensions to the generated code -# Example: https://github.com/Azure/azure-sdk-for-python/blob/main/doc/dev/customize_code/how-to-patch-sdk-code.md -from ._patch import patch_sdk -patch_sdk() +try: + from ._patch import __all__ as _patch_all + from ._patch import * # type: ignore # pylint: disable=unused-wildcard-import +except ImportError: + _patch_all = [] +from ._patch import patch_sdk as _patch_sdk + +__all__ = ["TemplateSpecsClient"] +__all__.extend([p for p in _patch_all if p not in __all__]) + +_patch_sdk() diff --git a/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/templatespecs/v2019_06_01_preview/aio/_configuration.py b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/templatespecs/v2019_06_01_preview/aio/_configuration.py index 875e26e0c62cc..6bf6a7ab6dbde 100644 --- a/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/templatespecs/v2019_06_01_preview/aio/_configuration.py +++ b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/templatespecs/v2019_06_01_preview/aio/_configuration.py @@ -25,23 +25,19 @@ class TemplateSpecsClientConfiguration(Configuration): # pylint: disable=too-ma Note that all parameters used to create this instance are saved as instance attributes. - :param credential: Credential needed for the client to connect to Azure. + :param credential: Credential needed for the client to connect to Azure. Required. :type credential: ~azure.core.credentials_async.AsyncTokenCredential :param subscription_id: Subscription Id which forms part of the URI for every service call. + Required. :type subscription_id: str :keyword api_version: Api Version. Default value is "2019-06-01-preview". Note that overriding this default value may result in unsupported behavior. :paramtype api_version: str """ - def __init__( - self, - credential: "AsyncTokenCredential", - subscription_id: str, - **kwargs: Any - ) -> None: + def __init__(self, credential: "AsyncTokenCredential", subscription_id: str, **kwargs: Any) -> None: super(TemplateSpecsClientConfiguration, self).__init__(**kwargs) - api_version = kwargs.pop('api_version', "2019-06-01-preview") # type: str + api_version = kwargs.pop("api_version", "2019-06-01-preview") # type: str if credential is None: raise ValueError("Parameter 'credential' must not be None.") @@ -51,22 +47,21 @@ def __init__( self.credential = credential self.subscription_id = subscription_id self.api_version = api_version - self.credential_scopes = kwargs.pop('credential_scopes', ['https://management.azure.com/.default']) - kwargs.setdefault('sdk_moniker', 'mgmt-resource/{}'.format(VERSION)) + self.credential_scopes = kwargs.pop("credential_scopes", ["https://management.azure.com/.default"]) + kwargs.setdefault("sdk_moniker", "mgmt-resource/{}".format(VERSION)) self._configure(**kwargs) - 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) - self.logging_policy = kwargs.get('logging_policy') or policies.NetworkTraceLoggingPolicy(**kwargs) - self.http_logging_policy = kwargs.get('http_logging_policy') or ARMHttpLoggingPolicy(**kwargs) - self.retry_policy = kwargs.get('retry_policy') or policies.AsyncRetryPolicy(**kwargs) - self.custom_hook_policy = kwargs.get('custom_hook_policy') or policies.CustomHookPolicy(**kwargs) - self.redirect_policy = kwargs.get('redirect_policy') or policies.AsyncRedirectPolicy(**kwargs) - self.authentication_policy = kwargs.get('authentication_policy') + 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) + self.logging_policy = kwargs.get("logging_policy") or policies.NetworkTraceLoggingPolicy(**kwargs) + self.http_logging_policy = kwargs.get("http_logging_policy") or ARMHttpLoggingPolicy(**kwargs) + self.retry_policy = kwargs.get("retry_policy") or policies.AsyncRetryPolicy(**kwargs) + self.custom_hook_policy = kwargs.get("custom_hook_policy") or policies.CustomHookPolicy(**kwargs) + self.redirect_policy = kwargs.get("redirect_policy") or policies.AsyncRedirectPolicy(**kwargs) + self.authentication_policy = kwargs.get("authentication_policy") if self.credential and not self.authentication_policy: - self.authentication_policy = AsyncARMChallengeAuthenticationPolicy(self.credential, *self.credential_scopes, **kwargs) + self.authentication_policy = AsyncARMChallengeAuthenticationPolicy( + self.credential, *self.credential_scopes, **kwargs + ) diff --git a/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/templatespecs/v2019_06_01_preview/aio/_patch.py b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/templatespecs/v2019_06_01_preview/aio/_patch.py index 74e48ecd07cf3..f99e77fef9861 100644 --- a/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/templatespecs/v2019_06_01_preview/aio/_patch.py +++ b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/templatespecs/v2019_06_01_preview/aio/_patch.py @@ -28,4 +28,4 @@ # This file is used for handwritten extensions to the generated code. Example: # https://github.com/Azure/azure-sdk-for-python/blob/main/doc/dev/customize_code/how-to-patch-sdk-code.md def patch_sdk(): - pass \ No newline at end of file + pass diff --git a/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/templatespecs/v2019_06_01_preview/aio/_template_specs_client.py b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/templatespecs/v2019_06_01_preview/aio/_template_specs_client.py index 2cc1cd9a0767a..e15e90ce5d46a 100644 --- a/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/templatespecs/v2019_06_01_preview/aio/_template_specs_client.py +++ b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/templatespecs/v2019_06_01_preview/aio/_template_specs_client.py @@ -9,12 +9,11 @@ from copy import deepcopy from typing import Any, Awaitable, TYPE_CHECKING -from msrest import Deserializer, Serializer - from azure.core.rest import AsyncHttpResponse, HttpRequest from azure.mgmt.core import AsyncARMPipelineClient from .. import models +from ..._serialization import Deserializer, Serializer from ._configuration import TemplateSpecsClientConfiguration from .operations import TemplateSpecVersionsOperations, TemplateSpecsOperations @@ -22,7 +21,8 @@ # pylint: disable=unused-import,ungrouped-imports from azure.core.credentials_async import AsyncTokenCredential -class TemplateSpecsClient: + +class TemplateSpecsClient: # pylint: disable=client-accepts-api-version-keyword """The APIs listed in this specification can be used to manage Template Spec resources through the Azure Resource Manager. @@ -32,9 +32,10 @@ class TemplateSpecsClient: :ivar template_spec_versions: TemplateSpecVersionsOperations operations :vartype template_spec_versions: azure.mgmt.resource.templatespecs.v2019_06_01_preview.aio.operations.TemplateSpecVersionsOperations - :param credential: Credential needed for the client to connect to Azure. + :param credential: Credential needed for the client to connect to Azure. Required. :type credential: ~azure.core.credentials_async.AsyncTokenCredential :param subscription_id: Subscription Id which forms part of the URI for every service call. + Required. :type subscription_id: str :param base_url: Service URL. Default value is "https://management.azure.com". :type base_url: str @@ -50,7 +51,9 @@ def __init__( base_url: str = "https://management.azure.com", **kwargs: Any ) -> None: - self._config = TemplateSpecsClientConfiguration(credential=credential, subscription_id=subscription_id, **kwargs) + self._config = TemplateSpecsClientConfiguration( + credential=credential, subscription_id=subscription_id, **kwargs + ) self._client = AsyncARMPipelineClient(base_url=base_url, config=self._config, **kwargs) client_models = {k: v for k, v in models.__dict__.items() if isinstance(v, type)} @@ -58,14 +61,11 @@ def __init__( self._deserialize = Deserializer(client_models) self._serialize.client_side_validation = False self.template_specs = TemplateSpecsOperations(self._client, self._config, self._serialize, self._deserialize) - self.template_spec_versions = TemplateSpecVersionsOperations(self._client, self._config, self._serialize, self._deserialize) - + self.template_spec_versions = TemplateSpecVersionsOperations( + self._client, self._config, self._serialize, self._deserialize + ) - def _send_request( - self, - request: HttpRequest, - **kwargs: Any - ) -> Awaitable[AsyncHttpResponse]: + def _send_request(self, request: HttpRequest, **kwargs: Any) -> Awaitable[AsyncHttpResponse]: """Runs the network request through the client's chained policies. >>> from azure.core.rest import HttpRequest @@ -74,7 +74,7 @@ def _send_request( >>> response = await client._send_request(request) - For more information on this code flow, see https://aka.ms/azsdk/python/protocol/quickstart + For more information on this code flow, see https://aka.ms/azsdk/dpcodegen/python/send_request :param request: The network request you want to make. Required. :type request: ~azure.core.rest.HttpRequest diff --git a/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/templatespecs/v2019_06_01_preview/aio/operations/__init__.py b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/templatespecs/v2019_06_01_preview/aio/operations/__init__.py index cb4936f69ad57..1f6058ba55acd 100644 --- a/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/templatespecs/v2019_06_01_preview/aio/operations/__init__.py +++ b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/templatespecs/v2019_06_01_preview/aio/operations/__init__.py @@ -9,7 +9,13 @@ from ._operations import TemplateSpecsOperations from ._operations import TemplateSpecVersionsOperations +from ._patch import __all__ as _patch_all +from ._patch import * # type: ignore # pylint: disable=unused-wildcard-import +from ._patch import patch_sdk as _patch_sdk + __all__ = [ - 'TemplateSpecsOperations', - 'TemplateSpecVersionsOperations', + "TemplateSpecsOperations", + "TemplateSpecVersionsOperations", ] +__all__.extend([p for p in _patch_all if p not in __all__]) +_patch_sdk() diff --git a/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/templatespecs/v2019_06_01_preview/aio/operations/_operations.py b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/templatespecs/v2019_06_01_preview/aio/operations/_operations.py index 6524ba0bd5800..0e45bdcf3a9b8 100644 --- a/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/templatespecs/v2019_06_01_preview/aio/operations/_operations.py +++ b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/templatespecs/v2019_06_01_preview/aio/operations/_operations.py @@ -6,94 +6,190 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -from typing import Any, AsyncIterable, Callable, Dict, Optional, TypeVar, Union +from typing import Any, AsyncIterable, Callable, Dict, IO, Optional, TypeVar, Union, overload +from urllib.parse import parse_qs, urljoin, urlparse from azure.core.async_paging import AsyncItemPaged, AsyncList -from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error +from azure.core.exceptions import ( + ClientAuthenticationError, + HttpResponseError, + ResourceExistsError, + ResourceNotFoundError, + ResourceNotModifiedError, + map_error, +) from azure.core.pipeline import PipelineResponse from azure.core.pipeline.transport import AsyncHttpResponse from azure.core.rest import HttpRequest from azure.core.tracing.decorator import distributed_trace from azure.core.tracing.decorator_async import distributed_trace_async +from azure.core.utils import case_insensitive_dict from azure.mgmt.core.exceptions import ARMErrorFormat from ... import models as _models from ..._vendor import _convert_request -from ...operations._operations import build_template_spec_versions_create_or_update_request, build_template_spec_versions_delete_request, build_template_spec_versions_get_request, build_template_spec_versions_list_request, build_template_spec_versions_update_request, build_template_specs_create_or_update_request, build_template_specs_delete_request, build_template_specs_get_request, build_template_specs_list_by_resource_group_request, build_template_specs_list_by_subscription_request, build_template_specs_update_request -T = TypeVar('T') +from ...operations._operations import ( + build_template_spec_versions_create_or_update_request, + build_template_spec_versions_delete_request, + build_template_spec_versions_get_request, + build_template_spec_versions_list_request, + build_template_spec_versions_update_request, + build_template_specs_create_or_update_request, + build_template_specs_delete_request, + build_template_specs_get_request, + build_template_specs_list_by_resource_group_request, + build_template_specs_list_by_subscription_request, + build_template_specs_update_request, +) + +T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] -class TemplateSpecsOperations: - """TemplateSpecsOperations async operations. - You should not instantiate this class directly. Instead, you should create a Client instance that - instantiates it for you and attaches it as an attribute. +class TemplateSpecsOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. - :ivar models: Alias to model classes used in this operation group. - :type models: ~azure.mgmt.resource.templatespecs.v2019_06_01_preview.models - :param client: Client for service requests. - :param config: Configuration of service client. - :param serializer: An object model serializer. - :param deserializer: An object model deserializer. + Instead, you should access the following operations through + :class:`~azure.mgmt.resource.templatespecs.v2019_06_01_preview.aio.TemplateSpecsClient`'s + :attr:`template_specs` attribute. """ models = _models - def __init__(self, client, config, serializer, deserializer) -> None: - self._client = client - self._serialize = serializer - self._deserialize = deserializer - self._config = config + def __init__(self, *args, **kwargs) -> None: + input_args = list(args) + self._client = input_args.pop(0) if input_args else kwargs.pop("client") + self._config = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") + + @overload + async def create_or_update( + self, + resource_group_name: str, + template_spec_name: str, + template_spec: _models.TemplateSpec, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.TemplateSpec: + """Creates or updates a Template Spec. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param template_spec_name: Name of the Template Spec. Required. + :type template_spec_name: str + :param template_spec: Template Spec supplied to the operation. Required. + :type template_spec: ~azure.mgmt.resource.templatespecs.v2019_06_01_preview.models.TemplateSpec + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: TemplateSpec or the result of cls(response) + :rtype: ~azure.mgmt.resource.templatespecs.v2019_06_01_preview.models.TemplateSpec + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + async def create_or_update( + self, + resource_group_name: str, + template_spec_name: str, + template_spec: IO, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.TemplateSpec: + """Creates or updates a Template Spec. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param template_spec_name: Name of the Template Spec. Required. + :type template_spec_name: str + :param template_spec: Template Spec supplied to the operation. Required. + :type template_spec: IO + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: TemplateSpec or the result of cls(response) + :rtype: ~azure.mgmt.resource.templatespecs.v2019_06_01_preview.models.TemplateSpec + :raises ~azure.core.exceptions.HttpResponseError: + """ @distributed_trace_async async def create_or_update( self, resource_group_name: str, template_spec_name: str, - template_spec: "_models.TemplateSpec", + template_spec: Union[_models.TemplateSpec, IO], **kwargs: Any - ) -> "_models.TemplateSpec": + ) -> _models.TemplateSpec: """Creates or updates a Template Spec. :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. :type resource_group_name: str - :param template_spec_name: Name of the Template Spec. + :param template_spec_name: Name of the Template Spec. Required. :type template_spec_name: str - :param template_spec: Template Spec supplied to the operation. + :param template_spec: Template Spec supplied to the operation. Is either a model type or a IO + type. Required. :type template_spec: ~azure.mgmt.resource.templatespecs.v2019_06_01_preview.models.TemplateSpec + or IO + :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. + Default value is None. + :paramtype content_type: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: TemplateSpec, or the result of cls(response) + :return: TemplateSpec or the result of cls(response) :rtype: ~azure.mgmt.resource.templatespecs.v2019_06_01_preview.models.TemplateSpec - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.TemplateSpec"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', "2019-06-01-preview") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + api_version = kwargs.pop("api_version", _params.pop("api-version", "2019-06-01-preview")) # type: str + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.TemplateSpec] - _json = self._serialize.body(template_spec, 'TemplateSpec') + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(template_spec, (IO, bytes)): + _content = template_spec + else: + _json = self._serialize.body(template_spec, "TemplateSpec") request = build_template_specs_create_or_update_request( - subscription_id=self._config.subscription_id, resource_group_name=resource_group_name, template_spec_name=template_spec_name, + subscription_id=self._config.subscription_id, api_version=api_version, content_type=content_type, json=_json, - template_url=self.create_or_update.metadata['url'], + content=_content, + template_url=self.create_or_update.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200, 201]: @@ -102,73 +198,149 @@ async def create_or_update( raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) if response.status_code == 200: - deserialized = self._deserialize('TemplateSpec', pipeline_response) + deserialized = self._deserialize("TemplateSpec", pipeline_response) if response.status_code == 201: - deserialized = self._deserialize('TemplateSpec', pipeline_response) + deserialized = self._deserialize("TemplateSpec", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - create_or_update.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Resources/templateSpecs/{templateSpecName}"} # type: ignore + create_or_update.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Resources/templateSpecs/{templateSpecName}"} # type: ignore - - @distributed_trace_async + @overload async def update( self, resource_group_name: str, template_spec_name: str, - template_spec: Optional["_models.TemplateSpecUpdateModel"] = None, + template_spec: Optional[_models.TemplateSpecUpdateModel] = None, + *, + content_type: str = "application/json", **kwargs: Any - ) -> "_models.TemplateSpec": + ) -> _models.TemplateSpec: """Updates Template Spec tags with specified values. :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. :type resource_group_name: str - :param template_spec_name: Name of the Template Spec. + :param template_spec_name: Name of the Template Spec. Required. :type template_spec_name: str :param template_spec: Template Spec resource with the tags to be updated. Default value is None. :type template_spec: ~azure.mgmt.resource.templatespecs.v2019_06_01_preview.models.TemplateSpecUpdateModel + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: TemplateSpec or the result of cls(response) + :rtype: ~azure.mgmt.resource.templatespecs.v2019_06_01_preview.models.TemplateSpec + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + async def update( + self, + resource_group_name: str, + template_spec_name: str, + template_spec: Optional[IO] = None, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.TemplateSpec: + """Updates Template Spec tags with specified values. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param template_spec_name: Name of the Template Spec. Required. + :type template_spec_name: str + :param template_spec: Template Spec resource with the tags to be updated. Default value is + None. + :type template_spec: IO + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: TemplateSpec, or the result of cls(response) + :return: TemplateSpec or the result of cls(response) :rtype: ~azure.mgmt.resource.templatespecs.v2019_06_01_preview.models.TemplateSpec - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace_async + async def update( + self, + resource_group_name: str, + template_spec_name: str, + template_spec: Optional[Union[_models.TemplateSpecUpdateModel, IO]] = None, + **kwargs: Any + ) -> _models.TemplateSpec: + """Updates Template Spec tags with specified values. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param template_spec_name: Name of the Template Spec. Required. + :type template_spec_name: str + :param template_spec: Template Spec resource with the tags to be updated. Is either a model + type or a IO type. Default value is None. + :type template_spec: + ~azure.mgmt.resource.templatespecs.v2019_06_01_preview.models.TemplateSpecUpdateModel or IO + :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. + Default value is None. + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: TemplateSpec or the result of cls(response) + :rtype: ~azure.mgmt.resource.templatespecs.v2019_06_01_preview.models.TemplateSpec + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.TemplateSpec"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) - api_version = kwargs.pop('api_version', "2019-06-01-preview") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - if template_spec is not None: - _json = self._serialize.body(template_spec, 'TemplateSpecUpdateModel') + api_version = kwargs.pop("api_version", _params.pop("api-version", "2019-06-01-preview")) # type: str + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.TemplateSpec] + + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(template_spec, (IO, bytes)): + _content = template_spec else: - _json = None + if template_spec is not None: + _json = self._serialize.body(template_spec, "TemplateSpecUpdateModel") + else: + _json = None request = build_template_specs_update_request( - subscription_id=self._config.subscription_id, resource_group_name=resource_group_name, template_spec_name=template_spec_name, + subscription_id=self._config.subscription_id, api_version=api_version, content_type=content_type, json=_json, - template_url=self.update.metadata['url'], + content=_content, + template_url=self.update.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200]: @@ -176,15 +348,14 @@ async def update( error = self._deserialize.failsafe_deserialize(_models.TemplateSpecsError, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - deserialized = self._deserialize('TemplateSpec', pipeline_response) + deserialized = self._deserialize("TemplateSpec", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - update.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Resources/templateSpecs/{templateSpecName}"} # type: ignore - + update.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Resources/templateSpecs/{templateSpecName}"} # type: ignore @distributed_trace_async async def get( @@ -193,47 +364,54 @@ async def get( template_spec_name: str, expand: Optional[Union[str, "_models.TemplateSpecExpandKind"]] = None, **kwargs: Any - ) -> "_models.TemplateSpec": + ) -> _models.TemplateSpec: """Gets a Template Spec with a given name. :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. :type resource_group_name: str - :param template_spec_name: Name of the Template Spec. + :param template_spec_name: Name of the Template Spec. Required. :type template_spec_name: str :param expand: Allows for expansion of additional Template Spec details in the response. - Optional. Default value is None. + Optional. "versions" Default value is None. :type expand: str or ~azure.mgmt.resource.templatespecs.v2019_06_01_preview.models.TemplateSpecExpandKind :keyword callable cls: A custom type or function that will be passed the direct response - :return: TemplateSpec, or the result of cls(response) + :return: TemplateSpec or the result of cls(response) :rtype: ~azure.mgmt.resource.templatespecs.v2019_06_01_preview.models.TemplateSpec - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.TemplateSpec"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + 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', "2019-06-01-preview") # type: str + api_version = kwargs.pop("api_version", _params.pop("api-version", "2019-06-01-preview")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[_models.TemplateSpec] - request = build_template_specs_get_request( - subscription_id=self._config.subscription_id, resource_group_name=resource_group_name, template_spec_name=template_spec_name, - api_version=api_version, + subscription_id=self._config.subscription_id, expand=expand, - template_url=self.get.metadata['url'], + api_version=api_version, + template_url=self.get.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200]: @@ -241,59 +419,62 @@ async def get( error = self._deserialize.failsafe_deserialize(_models.TemplateSpecsError, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - deserialized = self._deserialize('TemplateSpec', pipeline_response) + deserialized = self._deserialize("TemplateSpec", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - get.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Resources/templateSpecs/{templateSpecName}"} # type: ignore - + get.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Resources/templateSpecs/{templateSpecName}"} # type: ignore @distributed_trace_async async def delete( # pylint: disable=inconsistent-return-statements - self, - resource_group_name: str, - template_spec_name: str, - **kwargs: Any + self, resource_group_name: str, template_spec_name: str, **kwargs: Any ) -> None: """Deletes a Template Spec by name. When operation completes, status code 200 returned without content. :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. :type resource_group_name: str - :param template_spec_name: Name of the Template Spec. + :param template_spec_name: Name of the Template Spec. Required. :type template_spec_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: None, or the result of cls(response) + :return: None or the result of cls(response) :rtype: None - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType[None] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) - api_version = kwargs.pop('api_version', "2019-06-01-preview") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2019-06-01-preview")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[None] - request = build_template_specs_delete_request( - subscription_id=self._config.subscription_id, resource_group_name=resource_group_name, template_spec_name=template_spec_name, + subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.delete.metadata['url'], + template_url=self.delete.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200, 204]: @@ -304,55 +485,60 @@ async def delete( # pylint: disable=inconsistent-return-statements if cls: return cls(pipeline_response, None, {}) - delete.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Resources/templateSpecs/{templateSpecName}"} # type: ignore - + delete.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Resources/templateSpecs/{templateSpecName}"} # type: ignore @distributed_trace def list_by_subscription( - self, - expand: Optional[Union[str, "_models.TemplateSpecExpandKind"]] = None, - **kwargs: Any - ) -> AsyncIterable["_models.TemplateSpecsListResult"]: + self, expand: Optional[Union[str, "_models.TemplateSpecExpandKind"]] = None, **kwargs: Any + ) -> AsyncIterable["_models.TemplateSpec"]: """Lists all the Template Specs within the specified subscriptions. :param expand: Allows for expansion of additional Template Spec details in the response. - Optional. Default value is None. + Optional. "versions" Default value is None. :type expand: str or ~azure.mgmt.resource.templatespecs.v2019_06_01_preview.models.TemplateSpecExpandKind :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either TemplateSpecsListResult or the result of - cls(response) + :return: An iterator like instance of either TemplateSpec or the result of cls(response) :rtype: - ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.resource.templatespecs.v2019_06_01_preview.models.TemplateSpecsListResult] - :raises: ~azure.core.exceptions.HttpResponseError + ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.resource.templatespecs.v2019_06_01_preview.models.TemplateSpec] + :raises ~azure.core.exceptions.HttpResponseError: """ - api_version = kwargs.pop('api_version', "2019-06-01-preview") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2019-06-01-preview")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[_models.TemplateSpecsListResult] - cls = kwargs.pop('cls', None) # type: ClsType["_models.TemplateSpecsListResult"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) + def prepare_request(next_link=None): if not next_link: - + request = build_template_specs_list_by_subscription_request( subscription_id=self._config.subscription_id, - api_version=api_version, expand=expand, - template_url=self.list_by_subscription.metadata['url'], + api_version=api_version, + template_url=self.list_by_subscription.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore else: - - request = build_template_specs_list_by_subscription_request( - subscription_id=self._config.subscription_id, - template_url=next_link, - ) + # make call to next link with the client's api-version + _parsed_next_link = urlparse(next_link) + _next_request_params = case_insensitive_dict(parse_qs(_parsed_next_link.query)) + _next_request_params["api-version"] = self._config.api_version + request = HttpRequest("GET", urljoin(next_link, _parsed_next_link.path), params=_next_request_params) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore request.method = "GET" return request @@ -366,10 +552,8 @@ async def extract_data(pipeline_response): async def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) response = pipeline_response.http_response @@ -380,11 +564,9 @@ async def get_next(next_link=None): return pipeline_response + return AsyncItemPaged(get_next, extract_data) - return AsyncItemPaged( - get_next, extract_data - ) - list_by_subscription.metadata = {'url': "/subscriptions/{subscriptionId}/providers/Microsoft.Resources/templateSpecs/"} # type: ignore + list_by_subscription.metadata = {"url": "/subscriptions/{subscriptionId}/providers/Microsoft.Resources/templateSpecs/"} # type: ignore @distributed_trace def list_by_resource_group( @@ -392,51 +574,59 @@ def list_by_resource_group( resource_group_name: str, expand: Optional[Union[str, "_models.TemplateSpecExpandKind"]] = None, **kwargs: Any - ) -> AsyncIterable["_models.TemplateSpecsListResult"]: + ) -> AsyncIterable["_models.TemplateSpec"]: """Lists all the Template Specs within the specified resource group. :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. :type resource_group_name: str :param expand: Allows for expansion of additional Template Spec details in the response. - Optional. Default value is None. + Optional. "versions" Default value is None. :type expand: str or ~azure.mgmt.resource.templatespecs.v2019_06_01_preview.models.TemplateSpecExpandKind :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either TemplateSpecsListResult or the result of - cls(response) + :return: An iterator like instance of either TemplateSpec or the result of cls(response) :rtype: - ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.resource.templatespecs.v2019_06_01_preview.models.TemplateSpecsListResult] - :raises: ~azure.core.exceptions.HttpResponseError + ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.resource.templatespecs.v2019_06_01_preview.models.TemplateSpec] + :raises ~azure.core.exceptions.HttpResponseError: """ - api_version = kwargs.pop('api_version', "2019-06-01-preview") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2019-06-01-preview")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[_models.TemplateSpecsListResult] - cls = kwargs.pop('cls', None) # type: ClsType["_models.TemplateSpecsListResult"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) + def prepare_request(next_link=None): if not next_link: - + request = build_template_specs_list_by_resource_group_request( - subscription_id=self._config.subscription_id, resource_group_name=resource_group_name, - api_version=api_version, + subscription_id=self._config.subscription_id, expand=expand, - template_url=self.list_by_resource_group.metadata['url'], + 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.url = self._client.format_url(request.url) # type: ignore else: - - request = build_template_specs_list_by_resource_group_request( - subscription_id=self._config.subscription_id, - resource_group_name=resource_group_name, - template_url=next_link, - ) + # make call to next link with the client's api-version + _parsed_next_link = urlparse(next_link) + _next_request_params = case_insensitive_dict(parse_qs(_parsed_next_link.query)) + _next_request_params["api-version"] = self._config.api_version + request = HttpRequest("GET", urljoin(next_link, _parsed_next_link.path), params=_next_request_params) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore request.method = "GET" return request @@ -450,10 +640,8 @@ async def extract_data(pipeline_response): async def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) response = pipeline_response.http_response @@ -464,87 +652,166 @@ async def get_next(next_link=None): return pipeline_response + return AsyncItemPaged(get_next, extract_data) - return AsyncItemPaged( - get_next, extract_data - ) - list_by_resource_group.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Resources/templateSpecs/"} # type: ignore -class TemplateSpecVersionsOperations: - """TemplateSpecVersionsOperations async operations. + list_by_resource_group.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Resources/templateSpecs/"} # type: ignore - You should not instantiate this class directly. Instead, you should create a Client instance that - instantiates it for you and attaches it as an attribute. - :ivar models: Alias to model classes used in this operation group. - :type models: ~azure.mgmt.resource.templatespecs.v2019_06_01_preview.models - :param client: Client for service requests. - :param config: Configuration of service client. - :param serializer: An object model serializer. - :param deserializer: An object model deserializer. +class TemplateSpecVersionsOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. + + Instead, you should access the following operations through + :class:`~azure.mgmt.resource.templatespecs.v2019_06_01_preview.aio.TemplateSpecsClient`'s + :attr:`template_spec_versions` attribute. """ models = _models - def __init__(self, client, config, serializer, deserializer) -> None: - self._client = client - self._serialize = serializer - self._deserialize = deserializer - self._config = config + def __init__(self, *args, **kwargs) -> None: + input_args = list(args) + self._client = input_args.pop(0) if input_args else kwargs.pop("client") + self._config = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") - @distributed_trace_async + @overload async def create_or_update( self, resource_group_name: str, template_spec_name: str, template_spec_version: str, - template_spec_version_model: "_models.TemplateSpecVersion", + template_spec_version_model: _models.TemplateSpecVersion, + *, + content_type: str = "application/json", **kwargs: Any - ) -> "_models.TemplateSpecVersion": + ) -> _models.TemplateSpecVersion: """Creates or updates a Template Spec version. :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. :type resource_group_name: str - :param template_spec_name: Name of the Template Spec. + :param template_spec_name: Name of the Template Spec. Required. :type template_spec_name: str - :param template_spec_version: The version of the Template Spec. + :param template_spec_version: The version of the Template Spec. Required. :type template_spec_version: str - :param template_spec_version_model: Template Spec Version supplied to the operation. + :param template_spec_version_model: Template Spec Version supplied to the operation. Required. :type template_spec_version_model: ~azure.mgmt.resource.templatespecs.v2019_06_01_preview.models.TemplateSpecVersion + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: TemplateSpecVersion or the result of cls(response) + :rtype: ~azure.mgmt.resource.templatespecs.v2019_06_01_preview.models.TemplateSpecVersion + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + async def create_or_update( + self, + resource_group_name: str, + template_spec_name: str, + template_spec_version: str, + template_spec_version_model: IO, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.TemplateSpecVersion: + """Creates or updates a Template Spec version. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param template_spec_name: Name of the Template Spec. Required. + :type template_spec_name: str + :param template_spec_version: The version of the Template Spec. Required. + :type template_spec_version: str + :param template_spec_version_model: Template Spec Version supplied to the operation. Required. + :type template_spec_version_model: IO + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: TemplateSpecVersion or the result of cls(response) + :rtype: ~azure.mgmt.resource.templatespecs.v2019_06_01_preview.models.TemplateSpecVersion + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace_async + async def create_or_update( + self, + resource_group_name: str, + template_spec_name: str, + template_spec_version: str, + template_spec_version_model: Union[_models.TemplateSpecVersion, IO], + **kwargs: Any + ) -> _models.TemplateSpecVersion: + """Creates or updates a Template Spec version. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param template_spec_name: Name of the Template Spec. Required. + :type template_spec_name: str + :param template_spec_version: The version of the Template Spec. Required. + :type template_spec_version: str + :param template_spec_version_model: Template Spec Version supplied to the operation. Is either + a model type or a IO type. Required. + :type template_spec_version_model: + ~azure.mgmt.resource.templatespecs.v2019_06_01_preview.models.TemplateSpecVersion or IO + :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. + Default value is None. + :paramtype content_type: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: TemplateSpecVersion, or the result of cls(response) + :return: TemplateSpecVersion or the result of cls(response) :rtype: ~azure.mgmt.resource.templatespecs.v2019_06_01_preview.models.TemplateSpecVersion - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.TemplateSpecVersion"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', "2019-06-01-preview") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + api_version = kwargs.pop("api_version", _params.pop("api-version", "2019-06-01-preview")) # type: str + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.TemplateSpecVersion] - _json = self._serialize.body(template_spec_version_model, 'TemplateSpecVersion') + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(template_spec_version_model, (IO, bytes)): + _content = template_spec_version_model + else: + _json = self._serialize.body(template_spec_version_model, "TemplateSpecVersion") request = build_template_spec_versions_create_or_update_request( - subscription_id=self._config.subscription_id, resource_group_name=resource_group_name, template_spec_name=template_spec_name, template_spec_version=template_spec_version, + subscription_id=self._config.subscription_id, api_version=api_version, content_type=content_type, json=_json, - template_url=self.create_or_update.metadata['url'], + content=_content, + template_url=self.create_or_update.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200, 201]: @@ -553,77 +820,160 @@ async def create_or_update( raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) if response.status_code == 200: - deserialized = self._deserialize('TemplateSpecVersion', pipeline_response) + deserialized = self._deserialize("TemplateSpecVersion", pipeline_response) if response.status_code == 201: - deserialized = self._deserialize('TemplateSpecVersion', pipeline_response) + deserialized = self._deserialize("TemplateSpecVersion", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - create_or_update.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Resources/templateSpecs/{templateSpecName}/versions/{templateSpecVersion}"} # type: ignore + create_or_update.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Resources/templateSpecs/{templateSpecName}/versions/{templateSpecVersion}"} # type: ignore - - @distributed_trace_async + @overload async def update( self, resource_group_name: str, template_spec_name: str, template_spec_version: str, - template_spec_version_update_model: Optional["_models.TemplateSpecVersionUpdateModel"] = None, + template_spec_version_update_model: Optional[_models.TemplateSpecVersionUpdateModel] = None, + *, + content_type: str = "application/json", **kwargs: Any - ) -> "_models.TemplateSpecVersion": + ) -> _models.TemplateSpecVersion: """Updates Template Spec Version tags with specified values. :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. :type resource_group_name: str - :param template_spec_name: Name of the Template Spec. + :param template_spec_name: Name of the Template Spec. Required. :type template_spec_name: str - :param template_spec_version: The version of the Template Spec. + :param template_spec_version: The version of the Template Spec. Required. :type template_spec_version: str :param template_spec_version_update_model: Template Spec Version resource with the tags to be updated. Default value is None. :type template_spec_version_update_model: ~azure.mgmt.resource.templatespecs.v2019_06_01_preview.models.TemplateSpecVersionUpdateModel + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: TemplateSpecVersion or the result of cls(response) + :rtype: ~azure.mgmt.resource.templatespecs.v2019_06_01_preview.models.TemplateSpecVersion + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + async def update( + self, + resource_group_name: str, + template_spec_name: str, + template_spec_version: str, + template_spec_version_update_model: Optional[IO] = None, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.TemplateSpecVersion: + """Updates Template Spec Version tags with specified values. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param template_spec_name: Name of the Template Spec. Required. + :type template_spec_name: str + :param template_spec_version: The version of the Template Spec. Required. + :type template_spec_version: str + :param template_spec_version_update_model: Template Spec Version resource with the tags to be + updated. Default value is None. + :type template_spec_version_update_model: IO + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: TemplateSpecVersion, or the result of cls(response) + :return: TemplateSpecVersion or the result of cls(response) :rtype: ~azure.mgmt.resource.templatespecs.v2019_06_01_preview.models.TemplateSpecVersion - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace_async + async def update( + self, + resource_group_name: str, + template_spec_name: str, + template_spec_version: str, + template_spec_version_update_model: Optional[Union[_models.TemplateSpecVersionUpdateModel, IO]] = None, + **kwargs: Any + ) -> _models.TemplateSpecVersion: + """Updates Template Spec Version tags with specified values. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param template_spec_name: Name of the Template Spec. Required. + :type template_spec_name: str + :param template_spec_version: The version of the Template Spec. Required. + :type template_spec_version: str + :param template_spec_version_update_model: Template Spec Version resource with the tags to be + updated. Is either a model type or a IO type. Default value is None. + :type template_spec_version_update_model: + ~azure.mgmt.resource.templatespecs.v2019_06_01_preview.models.TemplateSpecVersionUpdateModel or + IO + :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. + Default value is None. + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: TemplateSpecVersion or the result of cls(response) + :rtype: ~azure.mgmt.resource.templatespecs.v2019_06_01_preview.models.TemplateSpecVersion + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.TemplateSpecVersion"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) - api_version = kwargs.pop('api_version', "2019-06-01-preview") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - if template_spec_version_update_model is not None: - _json = self._serialize.body(template_spec_version_update_model, 'TemplateSpecVersionUpdateModel') + api_version = kwargs.pop("api_version", _params.pop("api-version", "2019-06-01-preview")) # type: str + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.TemplateSpecVersion] + + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(template_spec_version_update_model, (IO, bytes)): + _content = template_spec_version_update_model else: - _json = None + if template_spec_version_update_model is not None: + _json = self._serialize.body(template_spec_version_update_model, "TemplateSpecVersionUpdateModel") + else: + _json = None request = build_template_spec_versions_update_request( - subscription_id=self._config.subscription_id, resource_group_name=resource_group_name, template_spec_name=template_spec_name, template_spec_version=template_spec_version, + subscription_id=self._config.subscription_id, api_version=api_version, content_type=content_type, json=_json, - template_url=self.update.metadata['url'], + content=_content, + template_url=self.update.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200]: @@ -631,62 +981,64 @@ async def update( error = self._deserialize.failsafe_deserialize(_models.TemplateSpecsError, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - deserialized = self._deserialize('TemplateSpecVersion', pipeline_response) + deserialized = self._deserialize("TemplateSpecVersion", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - update.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Resources/templateSpecs/{templateSpecName}/versions/{templateSpecVersion}"} # type: ignore - + update.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Resources/templateSpecs/{templateSpecName}/versions/{templateSpecVersion}"} # type: ignore @distributed_trace_async async def get( - self, - resource_group_name: str, - template_spec_name: str, - template_spec_version: str, - **kwargs: Any - ) -> "_models.TemplateSpecVersion": + self, resource_group_name: str, template_spec_name: str, template_spec_version: str, **kwargs: Any + ) -> _models.TemplateSpecVersion: """Gets a Template Spec version from a specific Template Spec. :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. :type resource_group_name: str - :param template_spec_name: Name of the Template Spec. + :param template_spec_name: Name of the Template Spec. Required. :type template_spec_name: str - :param template_spec_version: The version of the Template Spec. + :param template_spec_version: The version of the Template Spec. Required. :type template_spec_version: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: TemplateSpecVersion, or the result of cls(response) + :return: TemplateSpecVersion or the result of cls(response) :rtype: ~azure.mgmt.resource.templatespecs.v2019_06_01_preview.models.TemplateSpecVersion - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.TemplateSpecVersion"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) - api_version = kwargs.pop('api_version', "2019-06-01-preview") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2019-06-01-preview")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[_models.TemplateSpecVersion] - request = build_template_spec_versions_get_request( - subscription_id=self._config.subscription_id, resource_group_name=resource_group_name, template_spec_name=template_spec_name, template_spec_version=template_spec_version, + subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.get.metadata['url'], + template_url=self.get.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200]: @@ -694,63 +1046,65 @@ async def get( error = self._deserialize.failsafe_deserialize(_models.TemplateSpecsError, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - deserialized = self._deserialize('TemplateSpecVersion', pipeline_response) + deserialized = self._deserialize("TemplateSpecVersion", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - get.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Resources/templateSpecs/{templateSpecName}/versions/{templateSpecVersion}"} # type: ignore - + get.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Resources/templateSpecs/{templateSpecName}/versions/{templateSpecVersion}"} # type: ignore @distributed_trace_async async def delete( # pylint: disable=inconsistent-return-statements - self, - resource_group_name: str, - template_spec_name: str, - template_spec_version: str, - **kwargs: Any + self, resource_group_name: str, template_spec_name: str, template_spec_version: str, **kwargs: Any ) -> None: """Deletes a specific version from a Template Spec. When operation completes, status code 200 returned without content. :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. :type resource_group_name: str - :param template_spec_name: Name of the Template Spec. + :param template_spec_name: Name of the Template Spec. Required. :type template_spec_name: str - :param template_spec_version: The version of the Template Spec. + :param template_spec_version: The version of the Template Spec. Required. :type template_spec_version: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: None, or the result of cls(response) + :return: None or the result of cls(response) :rtype: None - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType[None] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) - api_version = kwargs.pop('api_version', "2019-06-01-preview") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2019-06-01-preview")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[None] - request = build_template_spec_versions_delete_request( - subscription_id=self._config.subscription_id, resource_group_name=resource_group_name, template_spec_name=template_spec_name, template_spec_version=template_spec_version, + subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.delete.metadata['url'], + template_url=self.delete.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200, 204]: @@ -761,59 +1115,62 @@ async def delete( # pylint: disable=inconsistent-return-statements if cls: return cls(pipeline_response, None, {}) - delete.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Resources/templateSpecs/{templateSpecName}/versions/{templateSpecVersion}"} # type: ignore - + delete.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Resources/templateSpecs/{templateSpecName}/versions/{templateSpecVersion}"} # type: ignore @distributed_trace def list( - self, - resource_group_name: str, - template_spec_name: str, - **kwargs: Any - ) -> AsyncIterable["_models.TemplateSpecVersionsListResult"]: + self, resource_group_name: str, template_spec_name: str, **kwargs: Any + ) -> AsyncIterable["_models.TemplateSpecVersion"]: """Lists all the Template Spec versions in the specified Template Spec. :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. :type resource_group_name: str - :param template_spec_name: Name of the Template Spec. + :param template_spec_name: Name of the Template Spec. Required. :type template_spec_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either TemplateSpecVersionsListResult or the result of - cls(response) + :return: An iterator like instance of either TemplateSpecVersion or the result of cls(response) :rtype: - ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.resource.templatespecs.v2019_06_01_preview.models.TemplateSpecVersionsListResult] - :raises: ~azure.core.exceptions.HttpResponseError + ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.resource.templatespecs.v2019_06_01_preview.models.TemplateSpecVersion] + :raises ~azure.core.exceptions.HttpResponseError: """ - api_version = kwargs.pop('api_version', "2019-06-01-preview") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2019-06-01-preview")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[_models.TemplateSpecVersionsListResult] - cls = kwargs.pop('cls', None) # type: ClsType["_models.TemplateSpecVersionsListResult"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) + def prepare_request(next_link=None): if not next_link: - + request = build_template_spec_versions_list_request( - subscription_id=self._config.subscription_id, resource_group_name=resource_group_name, template_spec_name=template_spec_name, + subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.list.metadata['url'], + template_url=self.list.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore else: - - request = build_template_spec_versions_list_request( - subscription_id=self._config.subscription_id, - resource_group_name=resource_group_name, - template_spec_name=template_spec_name, - template_url=next_link, - ) + # make call to next link with the client's api-version + _parsed_next_link = urlparse(next_link) + _next_request_params = case_insensitive_dict(parse_qs(_parsed_next_link.query)) + _next_request_params["api-version"] = self._config.api_version + request = HttpRequest("GET", urljoin(next_link, _parsed_next_link.path), params=_next_request_params) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore request.method = "GET" return request @@ -827,10 +1184,8 @@ async def extract_data(pipeline_response): async def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) response = pipeline_response.http_response @@ -841,8 +1196,6 @@ async def get_next(next_link=None): return pipeline_response + return AsyncItemPaged(get_next, extract_data) - return AsyncItemPaged( - get_next, extract_data - ) - list.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Resources/templateSpecs/{templateSpecName}/versions"} # type: ignore + list.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Resources/templateSpecs/{templateSpecName}/versions"} # type: ignore diff --git a/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/templatespecs/v2019_06_01_preview/aio/operations/_patch.py b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/templatespecs/v2019_06_01_preview/aio/operations/_patch.py new file mode 100644 index 0000000000000..f7dd32510333d --- /dev/null +++ b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/templatespecs/v2019_06_01_preview/aio/operations/_patch.py @@ -0,0 +1,20 @@ +# ------------------------------------ +# Copyright (c) Microsoft Corporation. +# Licensed under the MIT License. +# ------------------------------------ +"""Customize generated code here. + +Follow our quickstart for examples: https://aka.ms/azsdk/python/dpcodegen/python/customize +""" +from typing import List + +__all__: List[str] = [] # Add all objects you want publicly available to users at this package level + + +def patch_sdk(): + """Do not remove from this file. + + `patch_sdk` is a last resort escape hatch that allows you to do customizations + you can't accomplish using the techniques described in + https://aka.ms/azsdk/python/dpcodegen/python/customize + """ diff --git a/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/templatespecs/v2019_06_01_preview/models/__init__.py b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/templatespecs/v2019_06_01_preview/models/__init__.py index 5abe2b0c1b851..a880ad4d5381d 100644 --- a/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/templatespecs/v2019_06_01_preview/models/__init__.py +++ b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/templatespecs/v2019_06_01_preview/models/__init__.py @@ -21,29 +21,31 @@ from ._models_py3 import TemplateSpecsError from ._models_py3 import TemplateSpecsListResult - -from ._template_specs_client_enums import ( - CreatedByType, - TemplateSpecArtifactKind, - TemplateSpecExpandKind, -) +from ._template_specs_client_enums import CreatedByType +from ._template_specs_client_enums import TemplateSpecArtifactKind +from ._template_specs_client_enums import TemplateSpecExpandKind +from ._patch import __all__ as _patch_all +from ._patch import * # type: ignore # pylint: disable=unused-wildcard-import +from ._patch import patch_sdk as _patch_sdk __all__ = [ - 'AzureResourceBase', - 'ErrorAdditionalInfo', - 'ErrorResponse', - 'SystemData', - 'TemplateSpec', - 'TemplateSpecArtifact', - 'TemplateSpecTemplateArtifact', - 'TemplateSpecUpdateModel', - 'TemplateSpecVersion', - 'TemplateSpecVersionInfo', - 'TemplateSpecVersionUpdateModel', - 'TemplateSpecVersionsListResult', - 'TemplateSpecsError', - 'TemplateSpecsListResult', - 'CreatedByType', - 'TemplateSpecArtifactKind', - 'TemplateSpecExpandKind', + "AzureResourceBase", + "ErrorAdditionalInfo", + "ErrorResponse", + "SystemData", + "TemplateSpec", + "TemplateSpecArtifact", + "TemplateSpecTemplateArtifact", + "TemplateSpecUpdateModel", + "TemplateSpecVersion", + "TemplateSpecVersionInfo", + "TemplateSpecVersionUpdateModel", + "TemplateSpecVersionsListResult", + "TemplateSpecsError", + "TemplateSpecsListResult", + "CreatedByType", + "TemplateSpecArtifactKind", + "TemplateSpecExpandKind", ] +__all__.extend([p for p in _patch_all if p not in __all__]) +_patch_sdk() diff --git a/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/templatespecs/v2019_06_01_preview/models/_models_py3.py b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/templatespecs/v2019_06_01_preview/models/_models_py3.py index 39ad37533c5b5..5220bcc36a952 100644 --- a/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/templatespecs/v2019_06_01_preview/models/_models_py3.py +++ b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/templatespecs/v2019_06_01_preview/models/_models_py3.py @@ -1,4 +1,5 @@ # coding=utf-8 +# pylint: disable=too-many-lines # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. # Licensed under the MIT License. See License.txt in the project root for license information. @@ -7,15 +8,22 @@ # -------------------------------------------------------------------------- import datetime -from typing import Any, Dict, List, Optional, Union +import sys +from typing import Any, Dict, List, Optional, TYPE_CHECKING, Union -from azure.core.exceptions import HttpResponseError -import msrest.serialization +from ... import _serialization -from ._template_specs_client_enums import * +if TYPE_CHECKING: + # pylint: disable=unused-import,ungrouped-imports + from .. import models as _models +if sys.version_info >= (3, 9): + from collections.abc import MutableMapping +else: + from typing import MutableMapping # type: ignore # pylint: disable=ungrouped-imports +JSON = MutableMapping[str, Any] # pylint: disable=unsubscriptable-object -class AzureResourceBase(msrest.serialization.Model): +class AzureResourceBase(_serialization.Model): """Common properties for all Azure resources. Variables are only populated by the server, and will be ignored when sending a request. @@ -32,33 +40,29 @@ class AzureResourceBase(msrest.serialization.Model): """ _validation = { - 'id': {'readonly': True}, - 'name': {'readonly': True}, - 'type': {'readonly': True}, - 'system_data': {'readonly': True}, + "id": {"readonly": True}, + "name": {"readonly": True}, + "type": {"readonly": True}, + "system_data": {"readonly": True}, } _attribute_map = { - 'id': {'key': 'id', 'type': 'str'}, - 'name': {'key': 'name', 'type': 'str'}, - 'type': {'key': 'type', 'type': 'str'}, - 'system_data': {'key': 'systemData', 'type': 'SystemData'}, + "id": {"key": "id", "type": "str"}, + "name": {"key": "name", "type": "str"}, + "type": {"key": "type", "type": "str"}, + "system_data": {"key": "systemData", "type": "SystemData"}, } - def __init__( - self, - **kwargs - ): - """ - """ - super(AzureResourceBase, self).__init__(**kwargs) + def __init__(self, **kwargs): + """ """ + super().__init__(**kwargs) self.id = None self.name = None self.type = None self.system_data = None -class ErrorAdditionalInfo(msrest.serialization.Model): +class ErrorAdditionalInfo(_serialization.Model): """The resource management error additional info. Variables are only populated by the server, and will be ignored when sending a request. @@ -66,31 +70,27 @@ class ErrorAdditionalInfo(msrest.serialization.Model): :ivar type: The additional info type. :vartype type: str :ivar info: The additional info. - :vartype info: any + :vartype info: JSON """ _validation = { - 'type': {'readonly': True}, - 'info': {'readonly': True}, + "type": {"readonly": True}, + "info": {"readonly": True}, } _attribute_map = { - 'type': {'key': 'type', 'type': 'str'}, - 'info': {'key': 'info', 'type': 'object'}, + "type": {"key": "type", "type": "str"}, + "info": {"key": "info", "type": "object"}, } - def __init__( - self, - **kwargs - ): - """ - """ - super(ErrorAdditionalInfo, self).__init__(**kwargs) + def __init__(self, **kwargs): + """ """ + super().__init__(**kwargs) self.type = None self.info = None -class ErrorResponse(msrest.serialization.Model): +class ErrorResponse(_serialization.Model): """Common error response for all Azure Resource Manager APIs to return error details for failed operations. (This also follows the OData error response format.). Variables are only populated by the server, and will be ignored when sending a request. @@ -110,28 +110,24 @@ class ErrorResponse(msrest.serialization.Model): """ _validation = { - 'code': {'readonly': True}, - 'message': {'readonly': True}, - 'target': {'readonly': True}, - 'details': {'readonly': True}, - 'additional_info': {'readonly': True}, + "code": {"readonly": True}, + "message": {"readonly": True}, + "target": {"readonly": True}, + "details": {"readonly": True}, + "additional_info": {"readonly": True}, } _attribute_map = { - 'code': {'key': 'code', 'type': 'str'}, - 'message': {'key': 'message', 'type': 'str'}, - 'target': {'key': 'target', 'type': 'str'}, - 'details': {'key': 'details', 'type': '[ErrorResponse]'}, - 'additional_info': {'key': 'additionalInfo', 'type': '[ErrorAdditionalInfo]'}, + "code": {"key": "code", "type": "str"}, + "message": {"key": "message", "type": "str"}, + "target": {"key": "target", "type": "str"}, + "details": {"key": "details", "type": "[ErrorResponse]"}, + "additional_info": {"key": "additionalInfo", "type": "[ErrorAdditionalInfo]"}, } - def __init__( - self, - **kwargs - ): - """ - """ - super(ErrorResponse, self).__init__(**kwargs) + def __init__(self, **kwargs): + """ """ + super().__init__(**kwargs) self.code = None self.message = None self.target = None @@ -139,21 +135,21 @@ def __init__( self.additional_info = None -class SystemData(msrest.serialization.Model): +class SystemData(_serialization.Model): """Metadata pertaining to creation and last modification of the resource. :ivar created_by: The identity that created the resource. :vartype created_by: str - :ivar created_by_type: The type of identity that created the resource. Possible values include: - "User", "Application", "ManagedIdentity", "Key". + :ivar created_by_type: The type of identity that created the resource. Known values are: + "User", "Application", "ManagedIdentity", and "Key". :vartype created_by_type: str or ~azure.mgmt.resource.templatespecs.v2019_06_01_preview.models.CreatedByType :ivar created_at: The timestamp of resource creation (UTC). :vartype created_at: ~datetime.datetime :ivar last_modified_by: The identity that last modified the resource. :vartype last_modified_by: str - :ivar last_modified_by_type: The type of identity that last modified the resource. Possible - values include: "User", "Application", "ManagedIdentity", "Key". + :ivar last_modified_by_type: The type of identity that last modified the resource. Known values + are: "User", "Application", "ManagedIdentity", and "Key". :vartype last_modified_by_type: str or ~azure.mgmt.resource.templatespecs.v2019_06_01_preview.models.CreatedByType :ivar last_modified_at: The timestamp of resource last modification (UTC). @@ -161,44 +157,44 @@ class SystemData(msrest.serialization.Model): """ _attribute_map = { - 'created_by': {'key': 'createdBy', 'type': 'str'}, - 'created_by_type': {'key': 'createdByType', 'type': 'str'}, - 'created_at': {'key': 'createdAt', 'type': 'iso-8601'}, - 'last_modified_by': {'key': 'lastModifiedBy', 'type': 'str'}, - 'last_modified_by_type': {'key': 'lastModifiedByType', 'type': 'str'}, - 'last_modified_at': {'key': 'lastModifiedAt', 'type': 'iso-8601'}, + "created_by": {"key": "createdBy", "type": "str"}, + "created_by_type": {"key": "createdByType", "type": "str"}, + "created_at": {"key": "createdAt", "type": "iso-8601"}, + "last_modified_by": {"key": "lastModifiedBy", "type": "str"}, + "last_modified_by_type": {"key": "lastModifiedByType", "type": "str"}, + "last_modified_at": {"key": "lastModifiedAt", "type": "iso-8601"}, } def __init__( self, *, created_by: Optional[str] = None, - created_by_type: Optional[Union[str, "CreatedByType"]] = None, + created_by_type: Optional[Union[str, "_models.CreatedByType"]] = None, created_at: Optional[datetime.datetime] = None, last_modified_by: Optional[str] = None, - last_modified_by_type: Optional[Union[str, "CreatedByType"]] = None, + last_modified_by_type: Optional[Union[str, "_models.CreatedByType"]] = None, last_modified_at: Optional[datetime.datetime] = None, **kwargs ): """ :keyword created_by: The identity that created the resource. :paramtype created_by: str - :keyword created_by_type: The type of identity that created the resource. Possible values - include: "User", "Application", "ManagedIdentity", "Key". + :keyword created_by_type: The type of identity that created the resource. Known values are: + "User", "Application", "ManagedIdentity", and "Key". :paramtype created_by_type: str or ~azure.mgmt.resource.templatespecs.v2019_06_01_preview.models.CreatedByType :keyword created_at: The timestamp of resource creation (UTC). :paramtype created_at: ~datetime.datetime :keyword last_modified_by: The identity that last modified the resource. :paramtype last_modified_by: str - :keyword last_modified_by_type: The type of identity that last modified the resource. Possible - values include: "User", "Application", "ManagedIdentity", "Key". + :keyword last_modified_by_type: The type of identity that last modified the resource. Known + values are: "User", "Application", "ManagedIdentity", and "Key". :paramtype last_modified_by_type: str or ~azure.mgmt.resource.templatespecs.v2019_06_01_preview.models.CreatedByType :keyword last_modified_at: The timestamp of resource last modification (UTC). :paramtype last_modified_at: ~datetime.datetime """ - super(SystemData, self).__init__(**kwargs) + super().__init__(**kwargs) self.created_by = created_by self.created_by_type = created_by_type self.created_at = created_at @@ -223,10 +219,10 @@ class TemplateSpec(AzureResourceBase): :ivar system_data: Azure Resource Manager metadata containing createdBy and modifiedBy information. :vartype system_data: ~azure.mgmt.resource.templatespecs.v2019_06_01_preview.models.SystemData - :ivar location: Required. The location of the Template Spec. It cannot be changed after - Template Spec creation. It must be one of the supported Azure locations. + :ivar location: The location of the Template Spec. It cannot be changed after Template Spec + creation. It must be one of the supported Azure locations. Required. :vartype location: str - :ivar tags: A set of tags. Resource tags. + :ivar tags: Resource tags. :vartype tags: dict[str, str] :ivar description: Template Spec description. :vartype description: str @@ -239,26 +235,26 @@ class TemplateSpec(AzureResourceBase): """ _validation = { - 'id': {'readonly': True}, - 'name': {'readonly': True}, - 'type': {'readonly': True}, - 'system_data': {'readonly': True}, - 'location': {'required': True}, - 'description': {'max_length': 4096, 'min_length': 0}, - 'display_name': {'max_length': 64, 'min_length': 0}, - 'versions': {'readonly': True}, + "id": {"readonly": True}, + "name": {"readonly": True}, + "type": {"readonly": True}, + "system_data": {"readonly": True}, + "location": {"required": True}, + "description": {"max_length": 4096}, + "display_name": {"max_length": 64}, + "versions": {"readonly": True}, } _attribute_map = { - 'id': {'key': 'id', 'type': 'str'}, - 'name': {'key': 'name', 'type': 'str'}, - 'type': {'key': 'type', 'type': 'str'}, - 'system_data': {'key': 'systemData', 'type': 'SystemData'}, - 'location': {'key': 'location', 'type': 'str'}, - 'tags': {'key': 'tags', 'type': '{str}'}, - 'description': {'key': 'properties.description', 'type': 'str'}, - 'display_name': {'key': 'properties.displayName', 'type': 'str'}, - 'versions': {'key': 'properties.versions', 'type': '{TemplateSpecVersionInfo}'}, + "id": {"key": "id", "type": "str"}, + "name": {"key": "name", "type": "str"}, + "type": {"key": "type", "type": "str"}, + "system_data": {"key": "systemData", "type": "SystemData"}, + "location": {"key": "location", "type": "str"}, + "tags": {"key": "tags", "type": "{str}"}, + "description": {"key": "properties.description", "type": "str"}, + "display_name": {"key": "properties.displayName", "type": "str"}, + "versions": {"key": "properties.versions", "type": "{TemplateSpecVersionInfo}"}, } def __init__( @@ -271,17 +267,17 @@ def __init__( **kwargs ): """ - :keyword location: Required. The location of the Template Spec. It cannot be changed after - Template Spec creation. It must be one of the supported Azure locations. + :keyword location: The location of the Template Spec. It cannot be changed after Template Spec + creation. It must be one of the supported Azure locations. Required. :paramtype location: str - :keyword tags: A set of tags. Resource tags. + :keyword tags: Resource tags. :paramtype tags: dict[str, str] :keyword description: Template Spec description. :paramtype description: str :keyword display_name: Template Spec display name. :paramtype display_name: str """ - super(TemplateSpec, self).__init__(**kwargs) + super().__init__(**kwargs) self.location = location self.tags = tags self.description = description @@ -289,52 +285,44 @@ def __init__( self.versions = None -class TemplateSpecArtifact(msrest.serialization.Model): +class TemplateSpecArtifact(_serialization.Model): """Represents a Template Spec artifact. - You probably want to use the sub-classes and not this class directly. Known - sub-classes are: TemplateSpecTemplateArtifact. + You probably want to use the sub-classes and not this class directly. Known sub-classes are: + TemplateSpecTemplateArtifact All required parameters must be populated in order to send to Azure. - :ivar path: Required. A filesystem safe relative path of the artifact. + :ivar path: A filesystem safe relative path of the artifact. Required. :vartype path: str - :ivar kind: Required. The kind of artifact.Constant filled by server. Possible values include: - "template". + :ivar kind: The kind of artifact. Required. "template" :vartype kind: str or ~azure.mgmt.resource.templatespecs.v2019_06_01_preview.models.TemplateSpecArtifactKind """ _validation = { - 'path': {'required': True}, - 'kind': {'required': True}, + "path": {"required": True}, + "kind": {"required": True}, } _attribute_map = { - 'path': {'key': 'path', 'type': 'str'}, - 'kind': {'key': 'kind', 'type': 'str'}, + "path": {"key": "path", "type": "str"}, + "kind": {"key": "kind", "type": "str"}, } - _subtype_map = { - 'kind': {'template': 'TemplateSpecTemplateArtifact'} - } + _subtype_map = {"kind": {"template": "TemplateSpecTemplateArtifact"}} - def __init__( - self, - *, - path: str, - **kwargs - ): + def __init__(self, *, path: str, **kwargs): """ - :keyword path: Required. A filesystem safe relative path of the artifact. + :keyword path: A filesystem safe relative path of the artifact. Required. :paramtype path: str """ - super(TemplateSpecArtifact, self).__init__(**kwargs) + super().__init__(**kwargs) self.path = path self.kind = None # type: Optional[str] -class TemplateSpecsError(msrest.serialization.Model): +class TemplateSpecsError(_serialization.Model): """Template Specs error response. :ivar error: Common error response for all Azure Resource Manager APIs to return error details @@ -343,25 +331,20 @@ class TemplateSpecsError(msrest.serialization.Model): """ _attribute_map = { - 'error': {'key': 'error', 'type': 'ErrorResponse'}, + "error": {"key": "error", "type": "ErrorResponse"}, } - def __init__( - self, - *, - error: Optional["ErrorResponse"] = None, - **kwargs - ): + def __init__(self, *, error: Optional["_models.ErrorResponse"] = None, **kwargs): """ :keyword error: Common error response for all Azure Resource Manager APIs to return error details for failed operations. (This also follows the OData error response format.). :paramtype error: ~azure.mgmt.resource.templatespecs.v2019_06_01_preview.models.ErrorResponse """ - super(TemplateSpecsError, self).__init__(**kwargs) + super().__init__(**kwargs) self.error = error -class TemplateSpecsListResult(msrest.serialization.Model): +class TemplateSpecsListResult(_serialization.Model): """List of Template Specs. Variables are only populated by the server, and will be ignored when sending a request. @@ -374,26 +357,21 @@ class TemplateSpecsListResult(msrest.serialization.Model): """ _validation = { - 'next_link': {'readonly': True}, + "next_link": {"readonly": True}, } _attribute_map = { - 'value': {'key': 'value', 'type': '[TemplateSpec]'}, - 'next_link': {'key': 'nextLink', 'type': 'str'}, + "value": {"key": "value", "type": "[TemplateSpec]"}, + "next_link": {"key": "nextLink", "type": "str"}, } - def __init__( - self, - *, - value: Optional[List["TemplateSpec"]] = None, - **kwargs - ): + def __init__(self, *, value: Optional[List["_models.TemplateSpec"]] = None, **kwargs): """ :keyword value: An array of Template Specs. :paramtype value: list[~azure.mgmt.resource.templatespecs.v2019_06_01_preview.models.TemplateSpec] """ - super(TemplateSpecsListResult, self).__init__(**kwargs) + super().__init__(**kwargs) self.value = value self.next_link = None @@ -403,43 +381,36 @@ class TemplateSpecTemplateArtifact(TemplateSpecArtifact): All required parameters must be populated in order to send to Azure. - :ivar path: Required. A filesystem safe relative path of the artifact. + :ivar path: A filesystem safe relative path of the artifact. Required. :vartype path: str - :ivar kind: Required. The kind of artifact.Constant filled by server. Possible values include: - "template". + :ivar kind: The kind of artifact. Required. "template" :vartype kind: str or ~azure.mgmt.resource.templatespecs.v2019_06_01_preview.models.TemplateSpecArtifactKind - :ivar template: Required. The Azure Resource Manager template. - :vartype template: any + :ivar template: The Azure Resource Manager template. Required. + :vartype template: JSON """ _validation = { - 'path': {'required': True}, - 'kind': {'required': True}, - 'template': {'required': True}, + "path": {"required": True}, + "kind": {"required": True}, + "template": {"required": True}, } _attribute_map = { - 'path': {'key': 'path', 'type': 'str'}, - 'kind': {'key': 'kind', 'type': 'str'}, - 'template': {'key': 'template', 'type': 'object'}, + "path": {"key": "path", "type": "str"}, + "kind": {"key": "kind", "type": "str"}, + "template": {"key": "template", "type": "object"}, } - def __init__( - self, - *, - path: str, - template: Any, - **kwargs - ): + def __init__(self, *, path: str, template: JSON, **kwargs): """ - :keyword path: Required. A filesystem safe relative path of the artifact. + :keyword path: A filesystem safe relative path of the artifact. Required. :paramtype path: str - :keyword template: Required. The Azure Resource Manager template. - :paramtype template: any + :keyword template: The Azure Resource Manager template. Required. + :paramtype template: JSON """ - super(TemplateSpecTemplateArtifact, self).__init__(path=path, **kwargs) - self.kind = 'template' # type: str + super().__init__(path=path, **kwargs) + self.kind = "template" # type: str self.template = template @@ -457,36 +428,31 @@ class TemplateSpecUpdateModel(AzureResourceBase): :ivar system_data: Azure Resource Manager metadata containing createdBy and modifiedBy information. :vartype system_data: ~azure.mgmt.resource.templatespecs.v2019_06_01_preview.models.SystemData - :ivar tags: A set of tags. Resource tags. + :ivar tags: Resource tags. :vartype tags: dict[str, str] """ _validation = { - 'id': {'readonly': True}, - 'name': {'readonly': True}, - 'type': {'readonly': True}, - 'system_data': {'readonly': True}, + "id": {"readonly": True}, + "name": {"readonly": True}, + "type": {"readonly": True}, + "system_data": {"readonly": True}, } _attribute_map = { - 'id': {'key': 'id', 'type': 'str'}, - 'name': {'key': 'name', 'type': 'str'}, - 'type': {'key': 'type', 'type': 'str'}, - 'system_data': {'key': 'systemData', 'type': 'SystemData'}, - 'tags': {'key': 'tags', 'type': '{str}'}, + "id": {"key": "id", "type": "str"}, + "name": {"key": "name", "type": "str"}, + "type": {"key": "type", "type": "str"}, + "system_data": {"key": "systemData", "type": "SystemData"}, + "tags": {"key": "tags", "type": "{str}"}, } - def __init__( - self, - *, - tags: Optional[Dict[str, str]] = None, - **kwargs - ): + def __init__(self, *, tags: Optional[Dict[str, str]] = None, **kwargs): """ - :keyword tags: A set of tags. Resource tags. + :keyword tags: Resource tags. :paramtype tags: dict[str, str] """ - super(TemplateSpecUpdateModel, self).__init__(**kwargs) + super().__init__(**kwargs) self.tags = tags @@ -506,10 +472,10 @@ class TemplateSpecVersion(AzureResourceBase): :ivar system_data: Azure Resource Manager metadata containing createdBy and modifiedBy information. :vartype system_data: ~azure.mgmt.resource.templatespecs.v2019_06_01_preview.models.SystemData - :ivar location: Required. The location of the Template Spec Version. It must match the location - of the parent Template Spec. + :ivar location: The location of the Template Spec Version. It must match the location of the + parent Template Spec. Required. :vartype location: str - :ivar tags: A set of tags. Resource tags. + :ivar tags: Resource tags. :vartype tags: dict[str, str] :ivar artifacts: An array of Template Spec artifacts. :vartype artifacts: @@ -517,28 +483,28 @@ class TemplateSpecVersion(AzureResourceBase): :ivar description: Template Spec version description. :vartype description: str :ivar template: The Azure Resource Manager template content. - :vartype template: any + :vartype template: JSON """ _validation = { - 'id': {'readonly': True}, - 'name': {'readonly': True}, - 'type': {'readonly': True}, - 'system_data': {'readonly': True}, - 'location': {'required': True}, - 'description': {'max_length': 4096, 'min_length': 0}, + "id": {"readonly": True}, + "name": {"readonly": True}, + "type": {"readonly": True}, + "system_data": {"readonly": True}, + "location": {"required": True}, + "description": {"max_length": 4096}, } _attribute_map = { - 'id': {'key': 'id', 'type': 'str'}, - 'name': {'key': 'name', 'type': 'str'}, - 'type': {'key': 'type', 'type': 'str'}, - 'system_data': {'key': 'systemData', 'type': 'SystemData'}, - 'location': {'key': 'location', 'type': 'str'}, - 'tags': {'key': 'tags', 'type': '{str}'}, - 'artifacts': {'key': 'properties.artifacts', 'type': '[TemplateSpecArtifact]'}, - 'description': {'key': 'properties.description', 'type': 'str'}, - 'template': {'key': 'properties.template', 'type': 'object'}, + "id": {"key": "id", "type": "str"}, + "name": {"key": "name", "type": "str"}, + "type": {"key": "type", "type": "str"}, + "system_data": {"key": "systemData", "type": "SystemData"}, + "location": {"key": "location", "type": "str"}, + "tags": {"key": "tags", "type": "{str}"}, + "artifacts": {"key": "properties.artifacts", "type": "[TemplateSpecArtifact]"}, + "description": {"key": "properties.description", "type": "str"}, + "template": {"key": "properties.template", "type": "object"}, } def __init__( @@ -546,16 +512,16 @@ def __init__( *, location: str, tags: Optional[Dict[str, str]] = None, - artifacts: Optional[List["TemplateSpecArtifact"]] = None, + artifacts: Optional[List["_models.TemplateSpecArtifact"]] = None, description: Optional[str] = None, - template: Optional[Any] = None, + template: Optional[JSON] = None, **kwargs ): """ - :keyword location: Required. The location of the Template Spec Version. It must match the - location of the parent Template Spec. + :keyword location: The location of the Template Spec Version. It must match the location of the + parent Template Spec. Required. :paramtype location: str - :keyword tags: A set of tags. Resource tags. + :keyword tags: Resource tags. :paramtype tags: dict[str, str] :keyword artifacts: An array of Template Spec artifacts. :paramtype artifacts: @@ -563,9 +529,9 @@ def __init__( :keyword description: Template Spec version description. :paramtype description: str :keyword template: The Azure Resource Manager template content. - :paramtype template: any + :paramtype template: JSON """ - super(TemplateSpecVersion, self).__init__(**kwargs) + super().__init__(**kwargs) self.location = location self.tags = tags self.artifacts = artifacts @@ -573,7 +539,7 @@ def __init__( self.template = template -class TemplateSpecVersionInfo(msrest.serialization.Model): +class TemplateSpecVersionInfo(_serialization.Model): """High-level information about a Template Spec version. Variables are only populated by the server, and will be ignored when sending a request. @@ -587,30 +553,26 @@ class TemplateSpecVersionInfo(msrest.serialization.Model): """ _validation = { - 'description': {'readonly': True}, - 'time_created': {'readonly': True}, - 'time_modified': {'readonly': True}, + "description": {"readonly": True}, + "time_created": {"readonly": True}, + "time_modified": {"readonly": True}, } _attribute_map = { - 'description': {'key': 'description', 'type': 'str'}, - 'time_created': {'key': 'timeCreated', 'type': 'iso-8601'}, - 'time_modified': {'key': 'timeModified', 'type': 'iso-8601'}, + "description": {"key": "description", "type": "str"}, + "time_created": {"key": "timeCreated", "type": "iso-8601"}, + "time_modified": {"key": "timeModified", "type": "iso-8601"}, } - def __init__( - self, - **kwargs - ): - """ - """ - super(TemplateSpecVersionInfo, self).__init__(**kwargs) + def __init__(self, **kwargs): + """ """ + super().__init__(**kwargs) self.description = None self.time_created = None self.time_modified = None -class TemplateSpecVersionsListResult(msrest.serialization.Model): +class TemplateSpecVersionsListResult(_serialization.Model): """List of Template Specs versions. Variables are only populated by the server, and will be ignored when sending a request. @@ -623,26 +585,21 @@ class TemplateSpecVersionsListResult(msrest.serialization.Model): """ _validation = { - 'next_link': {'readonly': True}, + "next_link": {"readonly": True}, } _attribute_map = { - 'value': {'key': 'value', 'type': '[TemplateSpecVersion]'}, - 'next_link': {'key': 'nextLink', 'type': 'str'}, + "value": {"key": "value", "type": "[TemplateSpecVersion]"}, + "next_link": {"key": "nextLink", "type": "str"}, } - def __init__( - self, - *, - value: Optional[List["TemplateSpecVersion"]] = None, - **kwargs - ): + def __init__(self, *, value: Optional[List["_models.TemplateSpecVersion"]] = None, **kwargs): """ :keyword value: An array of Template Spec versions. :paramtype value: list[~azure.mgmt.resource.templatespecs.v2019_06_01_preview.models.TemplateSpecVersion] """ - super(TemplateSpecVersionsListResult, self).__init__(**kwargs) + super().__init__(**kwargs) self.value = value self.next_link = None @@ -661,34 +618,29 @@ class TemplateSpecVersionUpdateModel(AzureResourceBase): :ivar system_data: Azure Resource Manager metadata containing createdBy and modifiedBy information. :vartype system_data: ~azure.mgmt.resource.templatespecs.v2019_06_01_preview.models.SystemData - :ivar tags: A set of tags. Resource tags. + :ivar tags: Resource tags. :vartype tags: dict[str, str] """ _validation = { - 'id': {'readonly': True}, - 'name': {'readonly': True}, - 'type': {'readonly': True}, - 'system_data': {'readonly': True}, + "id": {"readonly": True}, + "name": {"readonly": True}, + "type": {"readonly": True}, + "system_data": {"readonly": True}, } _attribute_map = { - 'id': {'key': 'id', 'type': 'str'}, - 'name': {'key': 'name', 'type': 'str'}, - 'type': {'key': 'type', 'type': 'str'}, - 'system_data': {'key': 'systemData', 'type': 'SystemData'}, - 'tags': {'key': 'tags', 'type': '{str}'}, + "id": {"key": "id", "type": "str"}, + "name": {"key": "name", "type": "str"}, + "type": {"key": "type", "type": "str"}, + "system_data": {"key": "systemData", "type": "SystemData"}, + "tags": {"key": "tags", "type": "{str}"}, } - def __init__( - self, - *, - tags: Optional[Dict[str, str]] = None, - **kwargs - ): + def __init__(self, *, tags: Optional[Dict[str, str]] = None, **kwargs): """ - :keyword tags: A set of tags. Resource tags. + :keyword tags: Resource tags. :paramtype tags: dict[str, str] """ - super(TemplateSpecVersionUpdateModel, self).__init__(**kwargs) + super().__init__(**kwargs) self.tags = tags diff --git a/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/templatespecs/v2019_06_01_preview/models/_patch.py b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/templatespecs/v2019_06_01_preview/models/_patch.py new file mode 100644 index 0000000000000..f7dd32510333d --- /dev/null +++ b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/templatespecs/v2019_06_01_preview/models/_patch.py @@ -0,0 +1,20 @@ +# ------------------------------------ +# Copyright (c) Microsoft Corporation. +# Licensed under the MIT License. +# ------------------------------------ +"""Customize generated code here. + +Follow our quickstart for examples: https://aka.ms/azsdk/python/dpcodegen/python/customize +""" +from typing import List + +__all__: List[str] = [] # Add all objects you want publicly available to users at this package level + + +def patch_sdk(): + """Do not remove from this file. + + `patch_sdk` is a last resort escape hatch that allows you to do customizations + you can't accomplish using the techniques described in + https://aka.ms/azsdk/python/dpcodegen/python/customize + """ diff --git a/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/templatespecs/v2019_06_01_preview/models/_template_specs_client_enums.py b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/templatespecs/v2019_06_01_preview/models/_template_specs_client_enums.py index 1d5ac8d4ff08a..2d5ab2574dfe3 100644 --- a/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/templatespecs/v2019_06_01_preview/models/_template_specs_client_enums.py +++ b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/templatespecs/v2019_06_01_preview/models/_template_specs_client_enums.py @@ -7,27 +7,27 @@ # -------------------------------------------------------------------------- from enum import Enum -from six import with_metaclass from azure.core import CaseInsensitiveEnumMeta -class CreatedByType(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): - """The type of identity that created the resource. - """ +class CreatedByType(str, Enum, metaclass=CaseInsensitiveEnumMeta): + """The type of identity that created the resource.""" USER = "User" APPLICATION = "Application" MANAGED_IDENTITY = "ManagedIdentity" KEY = "Key" -class TemplateSpecArtifactKind(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): - """The kind of artifact. - """ + +class TemplateSpecArtifactKind(str, Enum, metaclass=CaseInsensitiveEnumMeta): + """The kind of artifact.""" #: The artifact represents an embedded Azure Resource Manager template. TEMPLATE = "template" -class TemplateSpecExpandKind(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): + +class TemplateSpecExpandKind(str, Enum, metaclass=CaseInsensitiveEnumMeta): + """TemplateSpecExpandKind.""" #: Includes version information with the Template Spec. VERSIONS = "versions" diff --git a/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/templatespecs/v2019_06_01_preview/operations/__init__.py b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/templatespecs/v2019_06_01_preview/operations/__init__.py index cb4936f69ad57..1f6058ba55acd 100644 --- a/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/templatespecs/v2019_06_01_preview/operations/__init__.py +++ b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/templatespecs/v2019_06_01_preview/operations/__init__.py @@ -9,7 +9,13 @@ from ._operations import TemplateSpecsOperations from ._operations import TemplateSpecVersionsOperations +from ._patch import __all__ as _patch_all +from ._patch import * # type: ignore # pylint: disable=unused-wildcard-import +from ._patch import patch_sdk as _patch_sdk + __all__ = [ - 'TemplateSpecsOperations', - 'TemplateSpecVersionsOperations', + "TemplateSpecsOperations", + "TemplateSpecVersionsOperations", ] +__all__.extend([p for p in _patch_all if p not in __all__]) +_patch_sdk() diff --git a/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/templatespecs/v2019_06_01_preview/operations/_operations.py b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/templatespecs/v2019_06_01_preview/operations/_operations.py index e768301ffe87c..a3c6926594db0 100644 --- a/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/templatespecs/v2019_06_01_preview/operations/_operations.py +++ b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/templatespecs/v2019_06_01_preview/operations/_operations.py @@ -6,539 +6,612 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -from typing import Any, Callable, Dict, Iterable, Optional, TypeVar, Union - -from msrest import Serializer - -from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error +from typing import Any, Callable, Dict, IO, Iterable, Optional, TypeVar, Union, overload +from urllib.parse import parse_qs, urljoin, urlparse + +from azure.core.exceptions import ( + ClientAuthenticationError, + HttpResponseError, + ResourceExistsError, + ResourceNotFoundError, + ResourceNotModifiedError, + map_error, +) from azure.core.paging import ItemPaged from azure.core.pipeline import PipelineResponse from azure.core.pipeline.transport import HttpResponse from azure.core.rest import HttpRequest from azure.core.tracing.decorator import distributed_trace +from azure.core.utils import case_insensitive_dict from azure.mgmt.core.exceptions import ARMErrorFormat from .. import models as _models +from ..._serialization import Serializer from .._vendor import _convert_request, _format_url_section -T = TypeVar('T') -JSONType = Any + +T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] _SERIALIZER = Serializer() _SERIALIZER.client_side_validation = False + def build_template_specs_create_or_update_request( - subscription_id: str, - resource_group_name: str, - template_spec_name: str, - *, - json: JSONType = None, - content: Any = None, - **kwargs: Any + resource_group_name: str, template_spec_name: str, subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2019-06-01-preview") # type: str - content_type = kwargs.pop('content_type', None) # type: Optional[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", "2019-06-01-preview")) # type: str + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + accept = _headers.pop("Accept", "application/json") - accept = "application/json" # Construct URL - _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Resources/templateSpecs/{templateSpecName}") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Resources/templateSpecs/{templateSpecName}", + ) # pylint: disable=line-too-long path_format_arguments = { - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._\(\)]+$'), - "templateSpecName": _SERIALIZER.url("template_spec_name", template_spec_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._\(\)]+$'), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url( + "resource_group_name", resource_group_name, "str", max_length=90, min_length=1, pattern=r"^[-\w\._\(\)]+$" + ), + "templateSpecName": _SERIALIZER.url( + "template_spec_name", template_spec_name, "str", max_length=90, min_length=1, pattern=r"^[-\w\._\(\)]+$" + ), } _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] if content_type is not None: - _header_parameters['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') - _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers["Content-Type"] = _SERIALIZER.header("content_type", content_type, "str") + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - return HttpRequest( - method="PUT", - url=_url, - params=_query_parameters, - headers=_header_parameters, - json=json, - content=content, - **kwargs - ) + return HttpRequest(method="PUT", url=_url, params=_params, headers=_headers, **kwargs) def build_template_specs_update_request( - subscription_id: str, - resource_group_name: str, - template_spec_name: str, - *, - json: JSONType = None, - content: Any = None, - **kwargs: Any + resource_group_name: str, template_spec_name: str, subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2019-06-01-preview") # type: str - content_type = kwargs.pop('content_type', None) # type: Optional[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", "2019-06-01-preview")) # type: str + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + accept = _headers.pop("Accept", "application/json") - accept = "application/json" # Construct URL - _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Resources/templateSpecs/{templateSpecName}") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Resources/templateSpecs/{templateSpecName}", + ) # pylint: disable=line-too-long path_format_arguments = { - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._\(\)]+$'), - "templateSpecName": _SERIALIZER.url("template_spec_name", template_spec_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._\(\)]+$'), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url( + "resource_group_name", resource_group_name, "str", max_length=90, min_length=1, pattern=r"^[-\w\._\(\)]+$" + ), + "templateSpecName": _SERIALIZER.url( + "template_spec_name", template_spec_name, "str", max_length=90, min_length=1, pattern=r"^[-\w\._\(\)]+$" + ), } _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] if content_type is not None: - _header_parameters['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') - _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers["Content-Type"] = _SERIALIZER.header("content_type", content_type, "str") + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - return HttpRequest( - method="PATCH", - url=_url, - params=_query_parameters, - headers=_header_parameters, - json=json, - content=content, - **kwargs - ) + return HttpRequest(method="PATCH", url=_url, params=_params, headers=_headers, **kwargs) def build_template_specs_get_request( - subscription_id: str, resource_group_name: str, template_spec_name: str, + subscription_id: str, *, expand: Optional[Union[str, "_models.TemplateSpecExpandKind"]] = None, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2019-06-01-preview") # type: 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", "2019-06-01-preview")) # type: str + accept = _headers.pop("Accept", "application/json") - accept = "application/json" # Construct URL - _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Resources/templateSpecs/{templateSpecName}") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Resources/templateSpecs/{templateSpecName}", + ) # pylint: disable=line-too-long path_format_arguments = { - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._\(\)]+$'), - "templateSpecName": _SERIALIZER.url("template_spec_name", template_spec_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._\(\)]+$'), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url( + "resource_group_name", resource_group_name, "str", max_length=90, min_length=1, pattern=r"^[-\w\._\(\)]+$" + ), + "templateSpecName": _SERIALIZER.url( + "template_spec_name", template_spec_name, "str", max_length=90, min_length=1, pattern=r"^[-\w\._\(\)]+$" + ), } _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] if expand is not None: - _query_parameters['$expand'] = _SERIALIZER.query("expand", expand, 'str') - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["$expand"] = _SERIALIZER.query("expand", expand, "str") + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - return HttpRequest( - method="GET", - url=_url, - params=_query_parameters, - headers=_header_parameters, - **kwargs - ) + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) def build_template_specs_delete_request( - subscription_id: str, - resource_group_name: str, - template_spec_name: str, - **kwargs: Any + resource_group_name: str, template_spec_name: str, subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2019-06-01-preview") # type: 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", "2019-06-01-preview")) # type: str + accept = _headers.pop("Accept", "application/json") - accept = "application/json" # Construct URL - _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Resources/templateSpecs/{templateSpecName}") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Resources/templateSpecs/{templateSpecName}", + ) # pylint: disable=line-too-long path_format_arguments = { - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._\(\)]+$'), - "templateSpecName": _SERIALIZER.url("template_spec_name", template_spec_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._\(\)]+$'), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url( + "resource_group_name", resource_group_name, "str", max_length=90, min_length=1, pattern=r"^[-\w\._\(\)]+$" + ), + "templateSpecName": _SERIALIZER.url( + "template_spec_name", template_spec_name, "str", max_length=90, min_length=1, pattern=r"^[-\w\._\(\)]+$" + ), } _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - return HttpRequest( - method="DELETE", - url=_url, - params=_query_parameters, - headers=_header_parameters, - **kwargs - ) + return HttpRequest(method="DELETE", url=_url, params=_params, headers=_headers, **kwargs) def build_template_specs_list_by_subscription_request( - subscription_id: str, - *, - expand: Optional[Union[str, "_models.TemplateSpecExpandKind"]] = None, - **kwargs: Any + subscription_id: str, *, expand: Optional[Union[str, "_models.TemplateSpecExpandKind"]] = None, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2019-06-01-preview") # type: 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", "2019-06-01-preview")) # type: str + accept = _headers.pop("Accept", "application/json") - accept = "application/json" # Construct URL _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/providers/Microsoft.Resources/templateSpecs/") path_format_arguments = { - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), } _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] if expand is not None: - _query_parameters['$expand'] = _SERIALIZER.query("expand", expand, 'str') - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["$expand"] = _SERIALIZER.query("expand", expand, "str") + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - return HttpRequest( - method="GET", - url=_url, - params=_query_parameters, - headers=_header_parameters, - **kwargs - ) + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) def build_template_specs_list_by_resource_group_request( - subscription_id: str, resource_group_name: str, + subscription_id: str, *, expand: Optional[Union[str, "_models.TemplateSpecExpandKind"]] = None, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2019-06-01-preview") # type: 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", "2019-06-01-preview")) # type: str + accept = _headers.pop("Accept", "application/json") - accept = "application/json" # Construct URL - _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Resources/templateSpecs/") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Resources/templateSpecs/", + ) # pylint: disable=line-too-long path_format_arguments = { - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._\(\)]+$'), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url( + "resource_group_name", resource_group_name, "str", max_length=90, min_length=1, pattern=r"^[-\w\._\(\)]+$" + ), } _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] if expand is not None: - _query_parameters['$expand'] = _SERIALIZER.query("expand", expand, 'str') - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["$expand"] = _SERIALIZER.query("expand", expand, "str") + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - return HttpRequest( - method="GET", - url=_url, - params=_query_parameters, - headers=_header_parameters, - **kwargs - ) + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) def build_template_spec_versions_create_or_update_request( - subscription_id: str, - resource_group_name: str, - template_spec_name: str, - template_spec_version: str, - *, - json: JSONType = None, - content: Any = None, - **kwargs: Any + resource_group_name: str, template_spec_name: str, template_spec_version: str, subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2019-06-01-preview") # type: str - content_type = kwargs.pop('content_type', None) # type: Optional[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", "2019-06-01-preview")) # type: str + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + accept = _headers.pop("Accept", "application/json") - accept = "application/json" # Construct URL - _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Resources/templateSpecs/{templateSpecName}/versions/{templateSpecVersion}") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Resources/templateSpecs/{templateSpecName}/versions/{templateSpecVersion}", + ) # pylint: disable=line-too-long path_format_arguments = { - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._\(\)]+$'), - "templateSpecName": _SERIALIZER.url("template_spec_name", template_spec_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._\(\)]+$'), - "templateSpecVersion": _SERIALIZER.url("template_spec_version", template_spec_version, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._\(\)]+$'), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url( + "resource_group_name", resource_group_name, "str", max_length=90, min_length=1, pattern=r"^[-\w\._\(\)]+$" + ), + "templateSpecName": _SERIALIZER.url( + "template_spec_name", template_spec_name, "str", max_length=90, min_length=1, pattern=r"^[-\w\._\(\)]+$" + ), + "templateSpecVersion": _SERIALIZER.url( + "template_spec_version", + template_spec_version, + "str", + max_length=90, + min_length=1, + pattern=r"^[-\w\._\(\)]+$", + ), } _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] if content_type is not None: - _header_parameters['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') - _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers["Content-Type"] = _SERIALIZER.header("content_type", content_type, "str") + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - return HttpRequest( - method="PUT", - url=_url, - params=_query_parameters, - headers=_header_parameters, - json=json, - content=content, - **kwargs - ) + return HttpRequest(method="PUT", url=_url, params=_params, headers=_headers, **kwargs) def build_template_spec_versions_update_request( - subscription_id: str, - resource_group_name: str, - template_spec_name: str, - template_spec_version: str, - *, - json: JSONType = None, - content: Any = None, - **kwargs: Any + resource_group_name: str, template_spec_name: str, template_spec_version: str, subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2019-06-01-preview") # type: str - content_type = kwargs.pop('content_type', None) # type: Optional[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", "2019-06-01-preview")) # type: str + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + accept = _headers.pop("Accept", "application/json") - accept = "application/json" # Construct URL - _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Resources/templateSpecs/{templateSpecName}/versions/{templateSpecVersion}") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Resources/templateSpecs/{templateSpecName}/versions/{templateSpecVersion}", + ) # pylint: disable=line-too-long path_format_arguments = { - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._\(\)]+$'), - "templateSpecName": _SERIALIZER.url("template_spec_name", template_spec_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._\(\)]+$'), - "templateSpecVersion": _SERIALIZER.url("template_spec_version", template_spec_version, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._\(\)]+$'), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url( + "resource_group_name", resource_group_name, "str", max_length=90, min_length=1, pattern=r"^[-\w\._\(\)]+$" + ), + "templateSpecName": _SERIALIZER.url( + "template_spec_name", template_spec_name, "str", max_length=90, min_length=1, pattern=r"^[-\w\._\(\)]+$" + ), + "templateSpecVersion": _SERIALIZER.url( + "template_spec_version", + template_spec_version, + "str", + max_length=90, + min_length=1, + pattern=r"^[-\w\._\(\)]+$", + ), } _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] if content_type is not None: - _header_parameters['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') - _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers["Content-Type"] = _SERIALIZER.header("content_type", content_type, "str") + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - return HttpRequest( - method="PATCH", - url=_url, - params=_query_parameters, - headers=_header_parameters, - json=json, - content=content, - **kwargs - ) + return HttpRequest(method="PATCH", url=_url, params=_params, headers=_headers, **kwargs) def build_template_spec_versions_get_request( - subscription_id: str, - resource_group_name: str, - template_spec_name: str, - template_spec_version: str, - **kwargs: Any + resource_group_name: str, template_spec_name: str, template_spec_version: str, subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2019-06-01-preview") # type: 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", "2019-06-01-preview")) # type: str + accept = _headers.pop("Accept", "application/json") - accept = "application/json" # Construct URL - _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Resources/templateSpecs/{templateSpecName}/versions/{templateSpecVersion}") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Resources/templateSpecs/{templateSpecName}/versions/{templateSpecVersion}", + ) # pylint: disable=line-too-long path_format_arguments = { - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._\(\)]+$'), - "templateSpecName": _SERIALIZER.url("template_spec_name", template_spec_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._\(\)]+$'), - "templateSpecVersion": _SERIALIZER.url("template_spec_version", template_spec_version, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._\(\)]+$'), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url( + "resource_group_name", resource_group_name, "str", max_length=90, min_length=1, pattern=r"^[-\w\._\(\)]+$" + ), + "templateSpecName": _SERIALIZER.url( + "template_spec_name", template_spec_name, "str", max_length=90, min_length=1, pattern=r"^[-\w\._\(\)]+$" + ), + "templateSpecVersion": _SERIALIZER.url( + "template_spec_version", + template_spec_version, + "str", + max_length=90, + min_length=1, + pattern=r"^[-\w\._\(\)]+$", + ), } _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - return HttpRequest( - method="GET", - url=_url, - params=_query_parameters, - headers=_header_parameters, - **kwargs - ) + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) def build_template_spec_versions_delete_request( - subscription_id: str, - resource_group_name: str, - template_spec_name: str, - template_spec_version: str, - **kwargs: Any + resource_group_name: str, template_spec_name: str, template_spec_version: str, subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2019-06-01-preview") # type: 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", "2019-06-01-preview")) # type: str + accept = _headers.pop("Accept", "application/json") - accept = "application/json" # Construct URL - _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Resources/templateSpecs/{templateSpecName}/versions/{templateSpecVersion}") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Resources/templateSpecs/{templateSpecName}/versions/{templateSpecVersion}", + ) # pylint: disable=line-too-long path_format_arguments = { - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._\(\)]+$'), - "templateSpecName": _SERIALIZER.url("template_spec_name", template_spec_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._\(\)]+$'), - "templateSpecVersion": _SERIALIZER.url("template_spec_version", template_spec_version, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._\(\)]+$'), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url( + "resource_group_name", resource_group_name, "str", max_length=90, min_length=1, pattern=r"^[-\w\._\(\)]+$" + ), + "templateSpecName": _SERIALIZER.url( + "template_spec_name", template_spec_name, "str", max_length=90, min_length=1, pattern=r"^[-\w\._\(\)]+$" + ), + "templateSpecVersion": _SERIALIZER.url( + "template_spec_version", + template_spec_version, + "str", + max_length=90, + min_length=1, + pattern=r"^[-\w\._\(\)]+$", + ), } _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - return HttpRequest( - method="DELETE", - url=_url, - params=_query_parameters, - headers=_header_parameters, - **kwargs - ) + return HttpRequest(method="DELETE", url=_url, params=_params, headers=_headers, **kwargs) def build_template_spec_versions_list_request( - subscription_id: str, - resource_group_name: str, - template_spec_name: str, - **kwargs: Any + resource_group_name: str, template_spec_name: str, subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2019-06-01-preview") # type: 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", "2019-06-01-preview")) # type: str + accept = _headers.pop("Accept", "application/json") - accept = "application/json" # Construct URL - _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Resources/templateSpecs/{templateSpecName}/versions") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Resources/templateSpecs/{templateSpecName}/versions", + ) # pylint: disable=line-too-long path_format_arguments = { - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._\(\)]+$'), - "templateSpecName": _SERIALIZER.url("template_spec_name", template_spec_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._\(\)]+$'), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url( + "resource_group_name", resource_group_name, "str", max_length=90, min_length=1, pattern=r"^[-\w\._\(\)]+$" + ), + "templateSpecName": _SERIALIZER.url( + "template_spec_name", template_spec_name, "str", max_length=90, min_length=1, pattern=r"^[-\w\._\(\)]+$" + ), } _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') - - return HttpRequest( - method="GET", - url=_url, - params=_query_parameters, - headers=_header_parameters, - **kwargs - ) - -class TemplateSpecsOperations(object): - """TemplateSpecsOperations operations. - - You should not instantiate this class directly. Instead, you should create a Client instance that - instantiates it for you and attaches it as an attribute. - - :ivar models: Alias to model classes used in this operation group. - :type models: ~azure.mgmt.resource.templatespecs.v2019_06_01_preview.models - :param client: Client for service requests. - :param config: Configuration of service client. - :param serializer: An object model serializer. - :param deserializer: An object model deserializer. + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) + + +class TemplateSpecsOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. + + Instead, you should access the following operations through + :class:`~azure.mgmt.resource.templatespecs.v2019_06_01_preview.TemplateSpecsClient`'s + :attr:`template_specs` attribute. """ models = _models - def __init__(self, client, config, serializer, deserializer): - self._client = client - self._serialize = serializer - self._deserialize = deserializer - self._config = config + def __init__(self, *args, **kwargs): + input_args = list(args) + self._client = input_args.pop(0) if input_args else kwargs.pop("client") + self._config = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") + + @overload + def create_or_update( + self, + resource_group_name: str, + template_spec_name: str, + template_spec: _models.TemplateSpec, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.TemplateSpec: + """Creates or updates a Template Spec. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param template_spec_name: Name of the Template Spec. Required. + :type template_spec_name: str + :param template_spec: Template Spec supplied to the operation. Required. + :type template_spec: ~azure.mgmt.resource.templatespecs.v2019_06_01_preview.models.TemplateSpec + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: TemplateSpec or the result of cls(response) + :rtype: ~azure.mgmt.resource.templatespecs.v2019_06_01_preview.models.TemplateSpec + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + def create_or_update( + self, + resource_group_name: str, + template_spec_name: str, + template_spec: IO, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.TemplateSpec: + """Creates or updates a Template Spec. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param template_spec_name: Name of the Template Spec. Required. + :type template_spec_name: str + :param template_spec: Template Spec supplied to the operation. Required. + :type template_spec: IO + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: TemplateSpec or the result of cls(response) + :rtype: ~azure.mgmt.resource.templatespecs.v2019_06_01_preview.models.TemplateSpec + :raises ~azure.core.exceptions.HttpResponseError: + """ @distributed_trace def create_or_update( self, resource_group_name: str, template_spec_name: str, - template_spec: "_models.TemplateSpec", + template_spec: Union[_models.TemplateSpec, IO], **kwargs: Any - ) -> "_models.TemplateSpec": + ) -> _models.TemplateSpec: """Creates or updates a Template Spec. :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. :type resource_group_name: str - :param template_spec_name: Name of the Template Spec. + :param template_spec_name: Name of the Template Spec. Required. :type template_spec_name: str - :param template_spec: Template Spec supplied to the operation. + :param template_spec: Template Spec supplied to the operation. Is either a model type or a IO + type. Required. :type template_spec: ~azure.mgmt.resource.templatespecs.v2019_06_01_preview.models.TemplateSpec + or IO + :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. + Default value is None. + :paramtype content_type: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: TemplateSpec, or the result of cls(response) + :return: TemplateSpec or the result of cls(response) :rtype: ~azure.mgmt.resource.templatespecs.v2019_06_01_preview.models.TemplateSpec - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.TemplateSpec"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) - api_version = kwargs.pop('api_version', "2019-06-01-preview") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - _json = self._serialize.body(template_spec, 'TemplateSpec') + api_version = kwargs.pop("api_version", _params.pop("api-version", "2019-06-01-preview")) # type: str + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.TemplateSpec] + + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(template_spec, (IO, bytes)): + _content = template_spec + else: + _json = self._serialize.body(template_spec, "TemplateSpec") request = build_template_specs_create_or_update_request( - subscription_id=self._config.subscription_id, resource_group_name=resource_group_name, template_spec_name=template_spec_name, + subscription_id=self._config.subscription_id, api_version=api_version, content_type=content_type, json=_json, - template_url=self.create_or_update.metadata['url'], + content=_content, + template_url=self.create_or_update.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200, 201]: @@ -547,73 +620,149 @@ def create_or_update( raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) if response.status_code == 200: - deserialized = self._deserialize('TemplateSpec', pipeline_response) + deserialized = self._deserialize("TemplateSpec", pipeline_response) if response.status_code == 201: - deserialized = self._deserialize('TemplateSpec', pipeline_response) + deserialized = self._deserialize("TemplateSpec", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - create_or_update.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Resources/templateSpecs/{templateSpecName}"} # type: ignore + create_or_update.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Resources/templateSpecs/{templateSpecName}"} # type: ignore - - @distributed_trace + @overload def update( self, resource_group_name: str, template_spec_name: str, - template_spec: Optional["_models.TemplateSpecUpdateModel"] = None, + template_spec: Optional[_models.TemplateSpecUpdateModel] = None, + *, + content_type: str = "application/json", **kwargs: Any - ) -> "_models.TemplateSpec": + ) -> _models.TemplateSpec: """Updates Template Spec tags with specified values. :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. :type resource_group_name: str - :param template_spec_name: Name of the Template Spec. + :param template_spec_name: Name of the Template Spec. Required. :type template_spec_name: str :param template_spec: Template Spec resource with the tags to be updated. Default value is None. :type template_spec: ~azure.mgmt.resource.templatespecs.v2019_06_01_preview.models.TemplateSpecUpdateModel + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: TemplateSpec, or the result of cls(response) + :return: TemplateSpec or the result of cls(response) :rtype: ~azure.mgmt.resource.templatespecs.v2019_06_01_preview.models.TemplateSpec - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + def update( + self, + resource_group_name: str, + template_spec_name: str, + template_spec: Optional[IO] = None, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.TemplateSpec: + """Updates Template Spec tags with specified values. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param template_spec_name: Name of the Template Spec. Required. + :type template_spec_name: str + :param template_spec: Template Spec resource with the tags to be updated. Default value is + None. + :type template_spec: IO + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: TemplateSpec or the result of cls(response) + :rtype: ~azure.mgmt.resource.templatespecs.v2019_06_01_preview.models.TemplateSpec + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace + def update( + self, + resource_group_name: str, + template_spec_name: str, + template_spec: Optional[Union[_models.TemplateSpecUpdateModel, IO]] = None, + **kwargs: Any + ) -> _models.TemplateSpec: + """Updates Template Spec tags with specified values. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param template_spec_name: Name of the Template Spec. Required. + :type template_spec_name: str + :param template_spec: Template Spec resource with the tags to be updated. Is either a model + type or a IO type. Default value is None. + :type template_spec: + ~azure.mgmt.resource.templatespecs.v2019_06_01_preview.models.TemplateSpecUpdateModel or IO + :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. + Default value is None. + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: TemplateSpec or the result of cls(response) + :rtype: ~azure.mgmt.resource.templatespecs.v2019_06_01_preview.models.TemplateSpec + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.TemplateSpec"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', "2019-06-01-preview") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + api_version = kwargs.pop("api_version", _params.pop("api-version", "2019-06-01-preview")) # type: str + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.TemplateSpec] - if template_spec is not None: - _json = self._serialize.body(template_spec, 'TemplateSpecUpdateModel') + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(template_spec, (IO, bytes)): + _content = template_spec else: - _json = None + if template_spec is not None: + _json = self._serialize.body(template_spec, "TemplateSpecUpdateModel") + else: + _json = None request = build_template_specs_update_request( - subscription_id=self._config.subscription_id, resource_group_name=resource_group_name, template_spec_name=template_spec_name, + subscription_id=self._config.subscription_id, api_version=api_version, content_type=content_type, json=_json, - template_url=self.update.metadata['url'], + content=_content, + template_url=self.update.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200]: @@ -621,15 +770,14 @@ def update( error = self._deserialize.failsafe_deserialize(_models.TemplateSpecsError, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - deserialized = self._deserialize('TemplateSpec', pipeline_response) + deserialized = self._deserialize("TemplateSpec", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - update.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Resources/templateSpecs/{templateSpecName}"} # type: ignore - + update.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Resources/templateSpecs/{templateSpecName}"} # type: ignore @distributed_trace def get( @@ -638,47 +786,54 @@ def get( template_spec_name: str, expand: Optional[Union[str, "_models.TemplateSpecExpandKind"]] = None, **kwargs: Any - ) -> "_models.TemplateSpec": + ) -> _models.TemplateSpec: """Gets a Template Spec with a given name. :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. :type resource_group_name: str - :param template_spec_name: Name of the Template Spec. + :param template_spec_name: Name of the Template Spec. Required. :type template_spec_name: str :param expand: Allows for expansion of additional Template Spec details in the response. - Optional. Default value is None. + Optional. "versions" Default value is None. :type expand: str or ~azure.mgmt.resource.templatespecs.v2019_06_01_preview.models.TemplateSpecExpandKind :keyword callable cls: A custom type or function that will be passed the direct response - :return: TemplateSpec, or the result of cls(response) + :return: TemplateSpec or the result of cls(response) :rtype: ~azure.mgmt.resource.templatespecs.v2019_06_01_preview.models.TemplateSpec - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.TemplateSpec"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) - api_version = kwargs.pop('api_version', "2019-06-01-preview") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2019-06-01-preview")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[_models.TemplateSpec] - request = build_template_specs_get_request( - subscription_id=self._config.subscription_id, resource_group_name=resource_group_name, template_spec_name=template_spec_name, - api_version=api_version, + subscription_id=self._config.subscription_id, expand=expand, - template_url=self.get.metadata['url'], + api_version=api_version, + template_url=self.get.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200]: @@ -686,59 +841,62 @@ def get( error = self._deserialize.failsafe_deserialize(_models.TemplateSpecsError, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - deserialized = self._deserialize('TemplateSpec', pipeline_response) + deserialized = self._deserialize("TemplateSpec", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - get.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Resources/templateSpecs/{templateSpecName}"} # type: ignore - + get.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Resources/templateSpecs/{templateSpecName}"} # type: ignore @distributed_trace def delete( # pylint: disable=inconsistent-return-statements - self, - resource_group_name: str, - template_spec_name: str, - **kwargs: Any + self, resource_group_name: str, template_spec_name: str, **kwargs: Any ) -> None: """Deletes a Template Spec by name. When operation completes, status code 200 returned without content. :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. :type resource_group_name: str - :param template_spec_name: Name of the Template Spec. + :param template_spec_name: Name of the Template Spec. Required. :type template_spec_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: None, or the result of cls(response) + :return: None or the result of cls(response) :rtype: None - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType[None] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) - api_version = kwargs.pop('api_version', "2019-06-01-preview") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2019-06-01-preview")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[None] - request = build_template_specs_delete_request( - subscription_id=self._config.subscription_id, resource_group_name=resource_group_name, template_spec_name=template_spec_name, + subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.delete.metadata['url'], + template_url=self.delete.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200, 204]: @@ -749,55 +907,60 @@ def delete( # pylint: disable=inconsistent-return-statements if cls: return cls(pipeline_response, None, {}) - delete.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Resources/templateSpecs/{templateSpecName}"} # type: ignore - + delete.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Resources/templateSpecs/{templateSpecName}"} # type: ignore @distributed_trace def list_by_subscription( - self, - expand: Optional[Union[str, "_models.TemplateSpecExpandKind"]] = None, - **kwargs: Any - ) -> Iterable["_models.TemplateSpecsListResult"]: + self, expand: Optional[Union[str, "_models.TemplateSpecExpandKind"]] = None, **kwargs: Any + ) -> Iterable["_models.TemplateSpec"]: """Lists all the Template Specs within the specified subscriptions. :param expand: Allows for expansion of additional Template Spec details in the response. - Optional. Default value is None. + Optional. "versions" Default value is None. :type expand: str or ~azure.mgmt.resource.templatespecs.v2019_06_01_preview.models.TemplateSpecExpandKind :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either TemplateSpecsListResult or the result of - cls(response) + :return: An iterator like instance of either TemplateSpec or the result of cls(response) :rtype: - ~azure.core.paging.ItemPaged[~azure.mgmt.resource.templatespecs.v2019_06_01_preview.models.TemplateSpecsListResult] - :raises: ~azure.core.exceptions.HttpResponseError + ~azure.core.paging.ItemPaged[~azure.mgmt.resource.templatespecs.v2019_06_01_preview.models.TemplateSpec] + :raises ~azure.core.exceptions.HttpResponseError: """ - api_version = kwargs.pop('api_version', "2019-06-01-preview") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2019-06-01-preview")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[_models.TemplateSpecsListResult] - cls = kwargs.pop('cls', None) # type: ClsType["_models.TemplateSpecsListResult"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) + def prepare_request(next_link=None): if not next_link: - + request = build_template_specs_list_by_subscription_request( subscription_id=self._config.subscription_id, - api_version=api_version, expand=expand, - template_url=self.list_by_subscription.metadata['url'], + api_version=api_version, + template_url=self.list_by_subscription.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore else: - - request = build_template_specs_list_by_subscription_request( - subscription_id=self._config.subscription_id, - template_url=next_link, - ) + # make call to next link with the client's api-version + _parsed_next_link = urlparse(next_link) + _next_request_params = case_insensitive_dict(parse_qs(_parsed_next_link.query)) + _next_request_params["api-version"] = self._config.api_version + request = HttpRequest("GET", urljoin(next_link, _parsed_next_link.path), params=_next_request_params) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore request.method = "GET" return request @@ -811,10 +974,8 @@ def extract_data(pipeline_response): def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) response = pipeline_response.http_response @@ -825,11 +986,9 @@ def get_next(next_link=None): return pipeline_response + return ItemPaged(get_next, extract_data) - return ItemPaged( - get_next, extract_data - ) - list_by_subscription.metadata = {'url': "/subscriptions/{subscriptionId}/providers/Microsoft.Resources/templateSpecs/"} # type: ignore + list_by_subscription.metadata = {"url": "/subscriptions/{subscriptionId}/providers/Microsoft.Resources/templateSpecs/"} # type: ignore @distributed_trace def list_by_resource_group( @@ -837,51 +996,59 @@ def list_by_resource_group( resource_group_name: str, expand: Optional[Union[str, "_models.TemplateSpecExpandKind"]] = None, **kwargs: Any - ) -> Iterable["_models.TemplateSpecsListResult"]: + ) -> Iterable["_models.TemplateSpec"]: """Lists all the Template Specs within the specified resource group. :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. :type resource_group_name: str :param expand: Allows for expansion of additional Template Spec details in the response. - Optional. Default value is None. + Optional. "versions" Default value is None. :type expand: str or ~azure.mgmt.resource.templatespecs.v2019_06_01_preview.models.TemplateSpecExpandKind :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either TemplateSpecsListResult or the result of - cls(response) + :return: An iterator like instance of either TemplateSpec or the result of cls(response) :rtype: - ~azure.core.paging.ItemPaged[~azure.mgmt.resource.templatespecs.v2019_06_01_preview.models.TemplateSpecsListResult] - :raises: ~azure.core.exceptions.HttpResponseError + ~azure.core.paging.ItemPaged[~azure.mgmt.resource.templatespecs.v2019_06_01_preview.models.TemplateSpec] + :raises ~azure.core.exceptions.HttpResponseError: """ - api_version = kwargs.pop('api_version', "2019-06-01-preview") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2019-06-01-preview")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[_models.TemplateSpecsListResult] - cls = kwargs.pop('cls', None) # type: ClsType["_models.TemplateSpecsListResult"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) + def prepare_request(next_link=None): if not next_link: - + request = build_template_specs_list_by_resource_group_request( - subscription_id=self._config.subscription_id, resource_group_name=resource_group_name, - api_version=api_version, + subscription_id=self._config.subscription_id, expand=expand, - template_url=self.list_by_resource_group.metadata['url'], + 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.url = self._client.format_url(request.url) # type: ignore else: - - request = build_template_specs_list_by_resource_group_request( - subscription_id=self._config.subscription_id, - resource_group_name=resource_group_name, - template_url=next_link, - ) + # make call to next link with the client's api-version + _parsed_next_link = urlparse(next_link) + _next_request_params = case_insensitive_dict(parse_qs(_parsed_next_link.query)) + _next_request_params["api-version"] = self._config.api_version + request = HttpRequest("GET", urljoin(next_link, _parsed_next_link.path), params=_next_request_params) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore request.method = "GET" return request @@ -895,10 +1062,8 @@ def extract_data(pipeline_response): def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) response = pipeline_response.http_response @@ -909,87 +1074,166 @@ def get_next(next_link=None): return pipeline_response + return ItemPaged(get_next, extract_data) - return ItemPaged( - get_next, extract_data - ) - list_by_resource_group.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Resources/templateSpecs/"} # type: ignore -class TemplateSpecVersionsOperations(object): - """TemplateSpecVersionsOperations operations. - - You should not instantiate this class directly. Instead, you should create a Client instance that - instantiates it for you and attaches it as an attribute. - - :ivar models: Alias to model classes used in this operation group. - :type models: ~azure.mgmt.resource.templatespecs.v2019_06_01_preview.models - :param client: Client for service requests. - :param config: Configuration of service client. - :param serializer: An object model serializer. - :param deserializer: An object model deserializer. + list_by_resource_group.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Resources/templateSpecs/"} # type: ignore + + +class TemplateSpecVersionsOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. + + Instead, you should access the following operations through + :class:`~azure.mgmt.resource.templatespecs.v2019_06_01_preview.TemplateSpecsClient`'s + :attr:`template_spec_versions` attribute. """ models = _models - def __init__(self, client, config, serializer, deserializer): - self._client = client - self._serialize = serializer - self._deserialize = deserializer - self._config = config + def __init__(self, *args, **kwargs): + input_args = list(args) + self._client = input_args.pop(0) if input_args else kwargs.pop("client") + self._config = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") - @distributed_trace + @overload def create_or_update( self, resource_group_name: str, template_spec_name: str, template_spec_version: str, - template_spec_version_model: "_models.TemplateSpecVersion", + template_spec_version_model: _models.TemplateSpecVersion, + *, + content_type: str = "application/json", **kwargs: Any - ) -> "_models.TemplateSpecVersion": + ) -> _models.TemplateSpecVersion: """Creates or updates a Template Spec version. :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. :type resource_group_name: str - :param template_spec_name: Name of the Template Spec. + :param template_spec_name: Name of the Template Spec. Required. :type template_spec_name: str - :param template_spec_version: The version of the Template Spec. + :param template_spec_version: The version of the Template Spec. Required. :type template_spec_version: str - :param template_spec_version_model: Template Spec Version supplied to the operation. + :param template_spec_version_model: Template Spec Version supplied to the operation. Required. :type template_spec_version_model: ~azure.mgmt.resource.templatespecs.v2019_06_01_preview.models.TemplateSpecVersion + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: TemplateSpecVersion or the result of cls(response) + :rtype: ~azure.mgmt.resource.templatespecs.v2019_06_01_preview.models.TemplateSpecVersion + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + def create_or_update( + self, + resource_group_name: str, + template_spec_name: str, + template_spec_version: str, + template_spec_version_model: IO, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.TemplateSpecVersion: + """Creates or updates a Template Spec version. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param template_spec_name: Name of the Template Spec. Required. + :type template_spec_name: str + :param template_spec_version: The version of the Template Spec. Required. + :type template_spec_version: str + :param template_spec_version_model: Template Spec Version supplied to the operation. Required. + :type template_spec_version_model: IO + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: TemplateSpecVersion or the result of cls(response) + :rtype: ~azure.mgmt.resource.templatespecs.v2019_06_01_preview.models.TemplateSpecVersion + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace + def create_or_update( + self, + resource_group_name: str, + template_spec_name: str, + template_spec_version: str, + template_spec_version_model: Union[_models.TemplateSpecVersion, IO], + **kwargs: Any + ) -> _models.TemplateSpecVersion: + """Creates or updates a Template Spec version. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param template_spec_name: Name of the Template Spec. Required. + :type template_spec_name: str + :param template_spec_version: The version of the Template Spec. Required. + :type template_spec_version: str + :param template_spec_version_model: Template Spec Version supplied to the operation. Is either + a model type or a IO type. Required. + :type template_spec_version_model: + ~azure.mgmt.resource.templatespecs.v2019_06_01_preview.models.TemplateSpecVersion or IO + :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. + Default value is None. + :paramtype content_type: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: TemplateSpecVersion, or the result of cls(response) + :return: TemplateSpecVersion or the result of cls(response) :rtype: ~azure.mgmt.resource.templatespecs.v2019_06_01_preview.models.TemplateSpecVersion - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.TemplateSpecVersion"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) - api_version = kwargs.pop('api_version', "2019-06-01-preview") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - _json = self._serialize.body(template_spec_version_model, 'TemplateSpecVersion') + api_version = kwargs.pop("api_version", _params.pop("api-version", "2019-06-01-preview")) # type: str + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.TemplateSpecVersion] + + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(template_spec_version_model, (IO, bytes)): + _content = template_spec_version_model + else: + _json = self._serialize.body(template_spec_version_model, "TemplateSpecVersion") request = build_template_spec_versions_create_or_update_request( - subscription_id=self._config.subscription_id, resource_group_name=resource_group_name, template_spec_name=template_spec_name, template_spec_version=template_spec_version, + subscription_id=self._config.subscription_id, api_version=api_version, content_type=content_type, json=_json, - template_url=self.create_or_update.metadata['url'], + content=_content, + template_url=self.create_or_update.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200, 201]: @@ -998,77 +1242,160 @@ def create_or_update( raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) if response.status_code == 200: - deserialized = self._deserialize('TemplateSpecVersion', pipeline_response) + deserialized = self._deserialize("TemplateSpecVersion", pipeline_response) if response.status_code == 201: - deserialized = self._deserialize('TemplateSpecVersion', pipeline_response) + deserialized = self._deserialize("TemplateSpecVersion", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - create_or_update.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Resources/templateSpecs/{templateSpecName}/versions/{templateSpecVersion}"} # type: ignore - + create_or_update.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Resources/templateSpecs/{templateSpecName}/versions/{templateSpecVersion}"} # type: ignore - @distributed_trace + @overload def update( self, resource_group_name: str, template_spec_name: str, template_spec_version: str, - template_spec_version_update_model: Optional["_models.TemplateSpecVersionUpdateModel"] = None, + template_spec_version_update_model: Optional[_models.TemplateSpecVersionUpdateModel] = None, + *, + content_type: str = "application/json", **kwargs: Any - ) -> "_models.TemplateSpecVersion": + ) -> _models.TemplateSpecVersion: """Updates Template Spec Version tags with specified values. :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. :type resource_group_name: str - :param template_spec_name: Name of the Template Spec. + :param template_spec_name: Name of the Template Spec. Required. :type template_spec_name: str - :param template_spec_version: The version of the Template Spec. + :param template_spec_version: The version of the Template Spec. Required. :type template_spec_version: str :param template_spec_version_update_model: Template Spec Version resource with the tags to be updated. Default value is None. :type template_spec_version_update_model: ~azure.mgmt.resource.templatespecs.v2019_06_01_preview.models.TemplateSpecVersionUpdateModel + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: TemplateSpecVersion, or the result of cls(response) + :return: TemplateSpecVersion or the result of cls(response) :rtype: ~azure.mgmt.resource.templatespecs.v2019_06_01_preview.models.TemplateSpecVersion - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + def update( + self, + resource_group_name: str, + template_spec_name: str, + template_spec_version: str, + template_spec_version_update_model: Optional[IO] = None, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.TemplateSpecVersion: + """Updates Template Spec Version tags with specified values. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param template_spec_name: Name of the Template Spec. Required. + :type template_spec_name: str + :param template_spec_version: The version of the Template Spec. Required. + :type template_spec_version: str + :param template_spec_version_update_model: Template Spec Version resource with the tags to be + updated. Default value is None. + :type template_spec_version_update_model: IO + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: TemplateSpecVersion or the result of cls(response) + :rtype: ~azure.mgmt.resource.templatespecs.v2019_06_01_preview.models.TemplateSpecVersion + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace + def update( + self, + resource_group_name: str, + template_spec_name: str, + template_spec_version: str, + template_spec_version_update_model: Optional[Union[_models.TemplateSpecVersionUpdateModel, IO]] = None, + **kwargs: Any + ) -> _models.TemplateSpecVersion: + """Updates Template Spec Version tags with specified values. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param template_spec_name: Name of the Template Spec. Required. + :type template_spec_name: str + :param template_spec_version: The version of the Template Spec. Required. + :type template_spec_version: str + :param template_spec_version_update_model: Template Spec Version resource with the tags to be + updated. Is either a model type or a IO type. Default value is None. + :type template_spec_version_update_model: + ~azure.mgmt.resource.templatespecs.v2019_06_01_preview.models.TemplateSpecVersionUpdateModel or + IO + :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. + Default value is None. + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: TemplateSpecVersion or the result of cls(response) + :rtype: ~azure.mgmt.resource.templatespecs.v2019_06_01_preview.models.TemplateSpecVersion + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.TemplateSpecVersion"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) - api_version = kwargs.pop('api_version', "2019-06-01-preview") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - if template_spec_version_update_model is not None: - _json = self._serialize.body(template_spec_version_update_model, 'TemplateSpecVersionUpdateModel') + api_version = kwargs.pop("api_version", _params.pop("api-version", "2019-06-01-preview")) # type: str + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.TemplateSpecVersion] + + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(template_spec_version_update_model, (IO, bytes)): + _content = template_spec_version_update_model else: - _json = None + if template_spec_version_update_model is not None: + _json = self._serialize.body(template_spec_version_update_model, "TemplateSpecVersionUpdateModel") + else: + _json = None request = build_template_spec_versions_update_request( - subscription_id=self._config.subscription_id, resource_group_name=resource_group_name, template_spec_name=template_spec_name, template_spec_version=template_spec_version, + subscription_id=self._config.subscription_id, api_version=api_version, content_type=content_type, json=_json, - template_url=self.update.metadata['url'], + content=_content, + template_url=self.update.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200]: @@ -1076,62 +1403,64 @@ def update( error = self._deserialize.failsafe_deserialize(_models.TemplateSpecsError, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - deserialized = self._deserialize('TemplateSpecVersion', pipeline_response) + deserialized = self._deserialize("TemplateSpecVersion", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - update.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Resources/templateSpecs/{templateSpecName}/versions/{templateSpecVersion}"} # type: ignore - + update.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Resources/templateSpecs/{templateSpecName}/versions/{templateSpecVersion}"} # type: ignore @distributed_trace def get( - self, - resource_group_name: str, - template_spec_name: str, - template_spec_version: str, - **kwargs: Any - ) -> "_models.TemplateSpecVersion": + self, resource_group_name: str, template_spec_name: str, template_spec_version: str, **kwargs: Any + ) -> _models.TemplateSpecVersion: """Gets a Template Spec version from a specific Template Spec. :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. :type resource_group_name: str - :param template_spec_name: Name of the Template Spec. + :param template_spec_name: Name of the Template Spec. Required. :type template_spec_name: str - :param template_spec_version: The version of the Template Spec. + :param template_spec_version: The version of the Template Spec. Required. :type template_spec_version: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: TemplateSpecVersion, or the result of cls(response) + :return: TemplateSpecVersion or the result of cls(response) :rtype: ~azure.mgmt.resource.templatespecs.v2019_06_01_preview.models.TemplateSpecVersion - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.TemplateSpecVersion"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + 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', "2019-06-01-preview") # type: str + api_version = kwargs.pop("api_version", _params.pop("api-version", "2019-06-01-preview")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[_models.TemplateSpecVersion] - request = build_template_spec_versions_get_request( - subscription_id=self._config.subscription_id, resource_group_name=resource_group_name, template_spec_name=template_spec_name, template_spec_version=template_spec_version, + subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.get.metadata['url'], + template_url=self.get.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200]: @@ -1139,63 +1468,65 @@ def get( error = self._deserialize.failsafe_deserialize(_models.TemplateSpecsError, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - deserialized = self._deserialize('TemplateSpecVersion', pipeline_response) + deserialized = self._deserialize("TemplateSpecVersion", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - get.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Resources/templateSpecs/{templateSpecName}/versions/{templateSpecVersion}"} # type: ignore - + get.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Resources/templateSpecs/{templateSpecName}/versions/{templateSpecVersion}"} # type: ignore @distributed_trace def delete( # pylint: disable=inconsistent-return-statements - self, - resource_group_name: str, - template_spec_name: str, - template_spec_version: str, - **kwargs: Any + self, resource_group_name: str, template_spec_name: str, template_spec_version: str, **kwargs: Any ) -> None: """Deletes a specific version from a Template Spec. When operation completes, status code 200 returned without content. :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. :type resource_group_name: str - :param template_spec_name: Name of the Template Spec. + :param template_spec_name: Name of the Template Spec. Required. :type template_spec_name: str - :param template_spec_version: The version of the Template Spec. + :param template_spec_version: The version of the Template Spec. Required. :type template_spec_version: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: None, or the result of cls(response) + :return: None or the result of cls(response) :rtype: None - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType[None] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) - api_version = kwargs.pop('api_version', "2019-06-01-preview") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2019-06-01-preview")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[None] - request = build_template_spec_versions_delete_request( - subscription_id=self._config.subscription_id, resource_group_name=resource_group_name, template_spec_name=template_spec_name, template_spec_version=template_spec_version, + subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.delete.metadata['url'], + template_url=self.delete.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200, 204]: @@ -1206,59 +1537,62 @@ def delete( # pylint: disable=inconsistent-return-statements if cls: return cls(pipeline_response, None, {}) - delete.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Resources/templateSpecs/{templateSpecName}/versions/{templateSpecVersion}"} # type: ignore - + delete.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Resources/templateSpecs/{templateSpecName}/versions/{templateSpecVersion}"} # type: ignore @distributed_trace def list( - self, - resource_group_name: str, - template_spec_name: str, - **kwargs: Any - ) -> Iterable["_models.TemplateSpecVersionsListResult"]: + self, resource_group_name: str, template_spec_name: str, **kwargs: Any + ) -> Iterable["_models.TemplateSpecVersion"]: """Lists all the Template Spec versions in the specified Template Spec. :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. :type resource_group_name: str - :param template_spec_name: Name of the Template Spec. + :param template_spec_name: Name of the Template Spec. Required. :type template_spec_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either TemplateSpecVersionsListResult or the result of - cls(response) + :return: An iterator like instance of either TemplateSpecVersion or the result of cls(response) :rtype: - ~azure.core.paging.ItemPaged[~azure.mgmt.resource.templatespecs.v2019_06_01_preview.models.TemplateSpecVersionsListResult] - :raises: ~azure.core.exceptions.HttpResponseError + ~azure.core.paging.ItemPaged[~azure.mgmt.resource.templatespecs.v2019_06_01_preview.models.TemplateSpecVersion] + :raises ~azure.core.exceptions.HttpResponseError: """ - api_version = kwargs.pop('api_version', "2019-06-01-preview") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2019-06-01-preview")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[_models.TemplateSpecVersionsListResult] - cls = kwargs.pop('cls', None) # type: ClsType["_models.TemplateSpecVersionsListResult"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) + def prepare_request(next_link=None): if not next_link: - + request = build_template_spec_versions_list_request( - subscription_id=self._config.subscription_id, resource_group_name=resource_group_name, template_spec_name=template_spec_name, + subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.list.metadata['url'], + template_url=self.list.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore else: - - request = build_template_spec_versions_list_request( - subscription_id=self._config.subscription_id, - resource_group_name=resource_group_name, - template_spec_name=template_spec_name, - template_url=next_link, - ) + # make call to next link with the client's api-version + _parsed_next_link = urlparse(next_link) + _next_request_params = case_insensitive_dict(parse_qs(_parsed_next_link.query)) + _next_request_params["api-version"] = self._config.api_version + request = HttpRequest("GET", urljoin(next_link, _parsed_next_link.path), params=_next_request_params) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore request.method = "GET" return request @@ -1272,10 +1606,8 @@ def extract_data(pipeline_response): def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) response = pipeline_response.http_response @@ -1286,8 +1618,6 @@ def get_next(next_link=None): return pipeline_response + return ItemPaged(get_next, extract_data) - return ItemPaged( - get_next, extract_data - ) - list.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Resources/templateSpecs/{templateSpecName}/versions"} # type: ignore + list.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Resources/templateSpecs/{templateSpecName}/versions"} # type: ignore diff --git a/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/templatespecs/v2019_06_01_preview/operations/_patch.py b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/templatespecs/v2019_06_01_preview/operations/_patch.py new file mode 100644 index 0000000000000..f7dd32510333d --- /dev/null +++ b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/templatespecs/v2019_06_01_preview/operations/_patch.py @@ -0,0 +1,20 @@ +# ------------------------------------ +# Copyright (c) Microsoft Corporation. +# Licensed under the MIT License. +# ------------------------------------ +"""Customize generated code here. + +Follow our quickstart for examples: https://aka.ms/azsdk/python/dpcodegen/python/customize +""" +from typing import List + +__all__: List[str] = [] # Add all objects you want publicly available to users at this package level + + +def patch_sdk(): + """Do not remove from this file. + + `patch_sdk` is a last resort escape hatch that allows you to do customizations + you can't accomplish using the techniques described in + https://aka.ms/azsdk/python/dpcodegen/python/customize + """ diff --git a/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/templatespecs/v2021_03_01_preview/__init__.py b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/templatespecs/v2021_03_01_preview/__init__.py index 4005d4a7201ea..1d05585f5c592 100644 --- a/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/templatespecs/v2021_03_01_preview/__init__.py +++ b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/templatespecs/v2021_03_01_preview/__init__.py @@ -10,9 +10,15 @@ from ._version import VERSION __version__ = VERSION -__all__ = ['TemplateSpecsClient'] -# `._patch.py` is used for handwritten extensions to the generated code -# Example: https://github.com/Azure/azure-sdk-for-python/blob/main/doc/dev/customize_code/how-to-patch-sdk-code.md -from ._patch import patch_sdk -patch_sdk() +try: + from ._patch import __all__ as _patch_all + from ._patch import * # type: ignore # pylint: disable=unused-wildcard-import +except ImportError: + _patch_all = [] +from ._patch import patch_sdk as _patch_sdk + +__all__ = ["TemplateSpecsClient"] +__all__.extend([p for p in _patch_all if p not in __all__]) + +_patch_sdk() diff --git a/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/templatespecs/v2021_03_01_preview/_configuration.py b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/templatespecs/v2021_03_01_preview/_configuration.py index a4daec102cbe6..dd697c7ed3a0a 100644 --- a/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/templatespecs/v2021_03_01_preview/_configuration.py +++ b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/templatespecs/v2021_03_01_preview/_configuration.py @@ -25,23 +25,19 @@ class TemplateSpecsClientConfiguration(Configuration): # pylint: disable=too-ma Note that all parameters used to create this instance are saved as instance attributes. - :param credential: Credential needed for the client to connect to Azure. + :param credential: Credential needed for the client to connect to Azure. Required. :type credential: ~azure.core.credentials.TokenCredential :param subscription_id: Subscription Id which forms part of the URI for every service call. + Required. :type subscription_id: str :keyword api_version: Api Version. Default value is "2021-03-01-preview". Note that overriding this default value may result in unsupported behavior. :paramtype api_version: str """ - def __init__( - self, - credential: "TokenCredential", - subscription_id: str, - **kwargs: Any - ) -> None: + def __init__(self, credential: "TokenCredential", subscription_id: str, **kwargs: Any) -> None: super(TemplateSpecsClientConfiguration, self).__init__(**kwargs) - api_version = kwargs.pop('api_version', "2021-03-01-preview") # type: str + api_version = kwargs.pop("api_version", "2021-03-01-preview") # type: str if credential is None: raise ValueError("Parameter 'credential' must not be None.") @@ -51,23 +47,24 @@ def __init__( self.credential = credential self.subscription_id = subscription_id self.api_version = api_version - self.credential_scopes = kwargs.pop('credential_scopes', ['https://management.azure.com/.default']) - kwargs.setdefault('sdk_moniker', 'mgmt-resource/{}'.format(VERSION)) + self.credential_scopes = kwargs.pop("credential_scopes", ["https://management.azure.com/.default"]) + kwargs.setdefault("sdk_moniker", "mgmt-resource/{}".format(VERSION)) self._configure(**kwargs) def _configure( - self, - **kwargs # type: Any + self, **kwargs # type: Any ): # type: (...) -> 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) - self.logging_policy = kwargs.get('logging_policy') or policies.NetworkTraceLoggingPolicy(**kwargs) - self.http_logging_policy = kwargs.get('http_logging_policy') or ARMHttpLoggingPolicy(**kwargs) - self.retry_policy = kwargs.get('retry_policy') or policies.RetryPolicy(**kwargs) - self.custom_hook_policy = kwargs.get('custom_hook_policy') or policies.CustomHookPolicy(**kwargs) - self.redirect_policy = kwargs.get('redirect_policy') or policies.RedirectPolicy(**kwargs) - self.authentication_policy = kwargs.get('authentication_policy') + 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) + self.logging_policy = kwargs.get("logging_policy") or policies.NetworkTraceLoggingPolicy(**kwargs) + self.http_logging_policy = kwargs.get("http_logging_policy") or ARMHttpLoggingPolicy(**kwargs) + self.retry_policy = kwargs.get("retry_policy") or policies.RetryPolicy(**kwargs) + self.custom_hook_policy = kwargs.get("custom_hook_policy") or policies.CustomHookPolicy(**kwargs) + self.redirect_policy = kwargs.get("redirect_policy") or policies.RedirectPolicy(**kwargs) + self.authentication_policy = kwargs.get("authentication_policy") if self.credential and not self.authentication_policy: - self.authentication_policy = ARMChallengeAuthenticationPolicy(self.credential, *self.credential_scopes, **kwargs) + self.authentication_policy = ARMChallengeAuthenticationPolicy( + self.credential, *self.credential_scopes, **kwargs + ) diff --git a/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/templatespecs/v2021_03_01_preview/_metadata.json b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/templatespecs/v2021_03_01_preview/_metadata.json index b1bf14b74559a..972a9bba630aa 100644 --- a/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/templatespecs/v2021_03_01_preview/_metadata.json +++ b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/templatespecs/v2021_03_01_preview/_metadata.json @@ -10,20 +10,20 @@ "azure_arm": true, "has_lro_operations": false, "client_side_validation": false, - "sync_imports": "{\"typing\": {\"azurecore\": {\"azure.core.credentials\": [\"TokenCredential\"]}}, \"regular\": {\"azurecore\": {\"azure.profiles\": [\"KnownProfiles\", \"ProfileDefinition\"], \"azure.profiles.multiapiclient\": [\"MultiApiClientMixin\"], \"azure.mgmt.core\": [\"ARMPipelineClient\"]}, \"local\": {\"._configuration\": [\"TemplateSpecsClientConfiguration\"]}, \"thirdparty\": {\"msrest\": [\"Deserializer\", \"Serializer\"]}}, \"conditional\": {\"stdlib\": {\"typing\": [\"Any\", \"Optional\"]}}}", - "async_imports": "{\"typing\": {\"azurecore\": {\"azure.core.credentials_async\": [\"AsyncTokenCredential\"], \"azure.core.credentials\": [\"TokenCredential\"]}}, \"regular\": {\"azurecore\": {\"azure.profiles\": [\"KnownProfiles\", \"ProfileDefinition\"], \"azure.profiles.multiapiclient\": [\"MultiApiClientMixin\"], \"azure.mgmt.core\": [\"AsyncARMPipelineClient\"]}, \"local\": {\"._configuration\": [\"TemplateSpecsClientConfiguration\"]}, \"thirdparty\": {\"msrest\": [\"Deserializer\", \"Serializer\"]}}, \"conditional\": {\"stdlib\": {\"typing\": [\"Any\", \"Optional\"]}}}" + "sync_imports": "{\"conditional\": {\"stdlib\": {\"typing\": [\"Any\", \"Optional\"]}}, \"regular\": {\"azurecore\": {\"azure.mgmt.core\": [\"ARMPipelineClient\"], \"azure.profiles\": [\"KnownProfiles\", \"ProfileDefinition\"], \"azure.profiles.multiapiclient\": [\"MultiApiClientMixin\"]}, \"local\": {\"._configuration\": [\"TemplateSpecsClientConfiguration\"], \".._serialization\": [\"Deserializer\", \"Serializer\"]}}, \"typing\": {\"azurecore\": {\"azure.core.credentials\": [\"TokenCredential\"]}}}", + "async_imports": "{\"conditional\": {\"stdlib\": {\"typing\": [\"Any\", \"Optional\"]}}, \"regular\": {\"azurecore\": {\"azure.mgmt.core\": [\"AsyncARMPipelineClient\"], \"azure.profiles\": [\"KnownProfiles\", \"ProfileDefinition\"], \"azure.profiles.multiapiclient\": [\"MultiApiClientMixin\"]}, \"local\": {\"._configuration\": [\"TemplateSpecsClientConfiguration\"], \"..._serialization\": [\"Deserializer\", \"Serializer\"]}}, \"typing\": {\"azurecore\": {\"azure.core.credentials_async\": [\"AsyncTokenCredential\"]}}}" }, "global_parameters": { "sync": { "credential": { - "signature": "credential, # type: \"TokenCredential\"", - "description": "Credential needed for the client to connect to Azure.", + "signature": "credential: \"TokenCredential\",", + "description": "Credential needed for the client to connect to Azure. Required.", "docstring_type": "~azure.core.credentials.TokenCredential", "required": true }, "subscription_id": { - "signature": "subscription_id, # type: str", - "description": "Subscription Id which forms part of the URI for every service call.", + "signature": "subscription_id: str,", + "description": "Subscription Id which forms part of the URI for every service call. Required.", "docstring_type": "str", "required": true } @@ -31,13 +31,13 @@ "async": { "credential": { "signature": "credential: \"AsyncTokenCredential\",", - "description": "Credential needed for the client to connect to Azure.", + "description": "Credential needed for the client to connect to Azure. Required.", "docstring_type": "~azure.core.credentials_async.AsyncTokenCredential", "required": true }, "subscription_id": { "signature": "subscription_id: str,", - "description": "Subscription Id which forms part of the URI for every service call.", + "description": "Subscription Id which forms part of the URI for every service call. Required.", "docstring_type": "str", "required": true } @@ -54,7 +54,7 @@ "required": false }, "base_url": { - "signature": "base_url=\"https://management.azure.com\", # type: str", + "signature": "base_url: str = \"https://management.azure.com\",", "description": "Service URL", "docstring_type": "str", "required": false diff --git a/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/templatespecs/v2021_03_01_preview/_patch.py b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/templatespecs/v2021_03_01_preview/_patch.py index 74e48ecd07cf3..f99e77fef9861 100644 --- a/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/templatespecs/v2021_03_01_preview/_patch.py +++ b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/templatespecs/v2021_03_01_preview/_patch.py @@ -28,4 +28,4 @@ # This file is used for handwritten extensions to the generated code. Example: # https://github.com/Azure/azure-sdk-for-python/blob/main/doc/dev/customize_code/how-to-patch-sdk-code.md def patch_sdk(): - pass \ No newline at end of file + pass diff --git a/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/templatespecs/v2021_03_01_preview/_template_specs_client.py b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/templatespecs/v2021_03_01_preview/_template_specs_client.py index 6ffe7867c7ba0..27da289dd70fb 100644 --- a/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/templatespecs/v2021_03_01_preview/_template_specs_client.py +++ b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/templatespecs/v2021_03_01_preview/_template_specs_client.py @@ -9,12 +9,11 @@ from copy import deepcopy from typing import Any, TYPE_CHECKING -from msrest import Deserializer, Serializer - from azure.core.rest import HttpRequest, HttpResponse from azure.mgmt.core import ARMPipelineClient from . import models +from .._serialization import Deserializer, Serializer from ._configuration import TemplateSpecsClientConfiguration from .operations import TemplateSpecVersionsOperations, TemplateSpecsOperations @@ -22,7 +21,8 @@ # pylint: disable=unused-import,ungrouped-imports from azure.core.credentials import TokenCredential -class TemplateSpecsClient: + +class TemplateSpecsClient: # pylint: disable=client-accepts-api-version-keyword """The APIs listed in this specification can be used to manage Template Spec resources through the Azure Resource Manager. @@ -32,9 +32,10 @@ class TemplateSpecsClient: :ivar template_spec_versions: TemplateSpecVersionsOperations operations :vartype template_spec_versions: azure.mgmt.resource.templatespecs.v2021_03_01_preview.operations.TemplateSpecVersionsOperations - :param credential: Credential needed for the client to connect to Azure. + :param credential: Credential needed for the client to connect to Azure. Required. :type credential: ~azure.core.credentials.TokenCredential :param subscription_id: Subscription Id which forms part of the URI for every service call. + Required. :type subscription_id: str :param base_url: Service URL. Default value is "https://management.azure.com". :type base_url: str @@ -50,7 +51,9 @@ def __init__( base_url: str = "https://management.azure.com", **kwargs: Any ) -> None: - self._config = TemplateSpecsClientConfiguration(credential=credential, subscription_id=subscription_id, **kwargs) + self._config = TemplateSpecsClientConfiguration( + credential=credential, subscription_id=subscription_id, **kwargs + ) self._client = ARMPipelineClient(base_url=base_url, config=self._config, **kwargs) client_models = {k: v for k, v in models.__dict__.items() if isinstance(v, type)} @@ -58,14 +61,11 @@ def __init__( self._deserialize = Deserializer(client_models) self._serialize.client_side_validation = False self.template_specs = TemplateSpecsOperations(self._client, self._config, self._serialize, self._deserialize) - self.template_spec_versions = TemplateSpecVersionsOperations(self._client, self._config, self._serialize, self._deserialize) - + self.template_spec_versions = TemplateSpecVersionsOperations( + self._client, self._config, self._serialize, self._deserialize + ) - def _send_request( - self, - request: HttpRequest, - **kwargs: Any - ) -> HttpResponse: + def _send_request(self, request: HttpRequest, **kwargs: Any) -> HttpResponse: """Runs the network request through the client's chained policies. >>> from azure.core.rest import HttpRequest @@ -74,7 +74,7 @@ def _send_request( >>> response = client._send_request(request) - For more information on this code flow, see https://aka.ms/azsdk/python/protocol/quickstart + For more information on this code flow, see https://aka.ms/azsdk/dpcodegen/python/send_request :param request: The network request you want to make. Required. :type request: ~azure.core.rest.HttpRequest diff --git a/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/templatespecs/v2021_03_01_preview/_vendor.py b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/templatespecs/v2021_03_01_preview/_vendor.py index 138f663c53a4e..9aad73fc743e7 100644 --- a/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/templatespecs/v2021_03_01_preview/_vendor.py +++ b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/templatespecs/v2021_03_01_preview/_vendor.py @@ -7,6 +7,7 @@ from azure.core.pipeline.transport import HttpRequest + def _convert_request(request, files=None): data = request.content if not files else None request = HttpRequest(method=request.method, url=request.url, headers=request.headers, data=data) @@ -14,6 +15,7 @@ def _convert_request(request, files=None): request.set_formdata_body(files) return request + def _format_url_section(template, **kwargs): components = template.split("/") while components: @@ -21,7 +23,5 @@ def _format_url_section(template, **kwargs): 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 - ] + components = [c for c in formatted_components if "{}".format(key.args[0]) not in c] template = "/".join(components) diff --git a/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/templatespecs/v2021_03_01_preview/_version.py b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/templatespecs/v2021_03_01_preview/_version.py index a012ac01c480c..e5754a47ce68f 100644 --- a/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/templatespecs/v2021_03_01_preview/_version.py +++ b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/templatespecs/v2021_03_01_preview/_version.py @@ -6,4 +6,4 @@ # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -VERSION = "21.1.0" +VERSION = "1.0.0b1" diff --git a/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/templatespecs/v2021_03_01_preview/aio/__init__.py b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/templatespecs/v2021_03_01_preview/aio/__init__.py index 9c8e93c3f82aa..c5e1e112f0111 100644 --- a/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/templatespecs/v2021_03_01_preview/aio/__init__.py +++ b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/templatespecs/v2021_03_01_preview/aio/__init__.py @@ -7,9 +7,15 @@ # -------------------------------------------------------------------------- from ._template_specs_client import TemplateSpecsClient -__all__ = ['TemplateSpecsClient'] -# `._patch.py` is used for handwritten extensions to the generated code -# Example: https://github.com/Azure/azure-sdk-for-python/blob/main/doc/dev/customize_code/how-to-patch-sdk-code.md -from ._patch import patch_sdk -patch_sdk() +try: + from ._patch import __all__ as _patch_all + from ._patch import * # type: ignore # pylint: disable=unused-wildcard-import +except ImportError: + _patch_all = [] +from ._patch import patch_sdk as _patch_sdk + +__all__ = ["TemplateSpecsClient"] +__all__.extend([p for p in _patch_all if p not in __all__]) + +_patch_sdk() diff --git a/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/templatespecs/v2021_03_01_preview/aio/_configuration.py b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/templatespecs/v2021_03_01_preview/aio/_configuration.py index f57b9c69af05e..cd54de80a958d 100644 --- a/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/templatespecs/v2021_03_01_preview/aio/_configuration.py +++ b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/templatespecs/v2021_03_01_preview/aio/_configuration.py @@ -25,23 +25,19 @@ class TemplateSpecsClientConfiguration(Configuration): # pylint: disable=too-ma Note that all parameters used to create this instance are saved as instance attributes. - :param credential: Credential needed for the client to connect to Azure. + :param credential: Credential needed for the client to connect to Azure. Required. :type credential: ~azure.core.credentials_async.AsyncTokenCredential :param subscription_id: Subscription Id which forms part of the URI for every service call. + Required. :type subscription_id: str :keyword api_version: Api Version. Default value is "2021-03-01-preview". Note that overriding this default value may result in unsupported behavior. :paramtype api_version: str """ - def __init__( - self, - credential: "AsyncTokenCredential", - subscription_id: str, - **kwargs: Any - ) -> None: + def __init__(self, credential: "AsyncTokenCredential", subscription_id: str, **kwargs: Any) -> None: super(TemplateSpecsClientConfiguration, self).__init__(**kwargs) - api_version = kwargs.pop('api_version', "2021-03-01-preview") # type: str + api_version = kwargs.pop("api_version", "2021-03-01-preview") # type: str if credential is None: raise ValueError("Parameter 'credential' must not be None.") @@ -51,22 +47,21 @@ def __init__( self.credential = credential self.subscription_id = subscription_id self.api_version = api_version - self.credential_scopes = kwargs.pop('credential_scopes', ['https://management.azure.com/.default']) - kwargs.setdefault('sdk_moniker', 'mgmt-resource/{}'.format(VERSION)) + self.credential_scopes = kwargs.pop("credential_scopes", ["https://management.azure.com/.default"]) + kwargs.setdefault("sdk_moniker", "mgmt-resource/{}".format(VERSION)) self._configure(**kwargs) - 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) - self.logging_policy = kwargs.get('logging_policy') or policies.NetworkTraceLoggingPolicy(**kwargs) - self.http_logging_policy = kwargs.get('http_logging_policy') or ARMHttpLoggingPolicy(**kwargs) - self.retry_policy = kwargs.get('retry_policy') or policies.AsyncRetryPolicy(**kwargs) - self.custom_hook_policy = kwargs.get('custom_hook_policy') or policies.CustomHookPolicy(**kwargs) - self.redirect_policy = kwargs.get('redirect_policy') or policies.AsyncRedirectPolicy(**kwargs) - self.authentication_policy = kwargs.get('authentication_policy') + 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) + self.logging_policy = kwargs.get("logging_policy") or policies.NetworkTraceLoggingPolicy(**kwargs) + self.http_logging_policy = kwargs.get("http_logging_policy") or ARMHttpLoggingPolicy(**kwargs) + self.retry_policy = kwargs.get("retry_policy") or policies.AsyncRetryPolicy(**kwargs) + self.custom_hook_policy = kwargs.get("custom_hook_policy") or policies.CustomHookPolicy(**kwargs) + self.redirect_policy = kwargs.get("redirect_policy") or policies.AsyncRedirectPolicy(**kwargs) + self.authentication_policy = kwargs.get("authentication_policy") if self.credential and not self.authentication_policy: - self.authentication_policy = AsyncARMChallengeAuthenticationPolicy(self.credential, *self.credential_scopes, **kwargs) + self.authentication_policy = AsyncARMChallengeAuthenticationPolicy( + self.credential, *self.credential_scopes, **kwargs + ) diff --git a/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/templatespecs/v2021_03_01_preview/aio/_patch.py b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/templatespecs/v2021_03_01_preview/aio/_patch.py index 74e48ecd07cf3..f99e77fef9861 100644 --- a/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/templatespecs/v2021_03_01_preview/aio/_patch.py +++ b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/templatespecs/v2021_03_01_preview/aio/_patch.py @@ -28,4 +28,4 @@ # This file is used for handwritten extensions to the generated code. Example: # https://github.com/Azure/azure-sdk-for-python/blob/main/doc/dev/customize_code/how-to-patch-sdk-code.md def patch_sdk(): - pass \ No newline at end of file + pass diff --git a/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/templatespecs/v2021_03_01_preview/aio/_template_specs_client.py b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/templatespecs/v2021_03_01_preview/aio/_template_specs_client.py index 6159c1de49c1c..3c074989590dc 100644 --- a/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/templatespecs/v2021_03_01_preview/aio/_template_specs_client.py +++ b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/templatespecs/v2021_03_01_preview/aio/_template_specs_client.py @@ -9,12 +9,11 @@ from copy import deepcopy from typing import Any, Awaitable, TYPE_CHECKING -from msrest import Deserializer, Serializer - from azure.core.rest import AsyncHttpResponse, HttpRequest from azure.mgmt.core import AsyncARMPipelineClient from .. import models +from ..._serialization import Deserializer, Serializer from ._configuration import TemplateSpecsClientConfiguration from .operations import TemplateSpecVersionsOperations, TemplateSpecsOperations @@ -22,7 +21,8 @@ # pylint: disable=unused-import,ungrouped-imports from azure.core.credentials_async import AsyncTokenCredential -class TemplateSpecsClient: + +class TemplateSpecsClient: # pylint: disable=client-accepts-api-version-keyword """The APIs listed in this specification can be used to manage Template Spec resources through the Azure Resource Manager. @@ -32,9 +32,10 @@ class TemplateSpecsClient: :ivar template_spec_versions: TemplateSpecVersionsOperations operations :vartype template_spec_versions: azure.mgmt.resource.templatespecs.v2021_03_01_preview.aio.operations.TemplateSpecVersionsOperations - :param credential: Credential needed for the client to connect to Azure. + :param credential: Credential needed for the client to connect to Azure. Required. :type credential: ~azure.core.credentials_async.AsyncTokenCredential :param subscription_id: Subscription Id which forms part of the URI for every service call. + Required. :type subscription_id: str :param base_url: Service URL. Default value is "https://management.azure.com". :type base_url: str @@ -50,7 +51,9 @@ def __init__( base_url: str = "https://management.azure.com", **kwargs: Any ) -> None: - self._config = TemplateSpecsClientConfiguration(credential=credential, subscription_id=subscription_id, **kwargs) + self._config = TemplateSpecsClientConfiguration( + credential=credential, subscription_id=subscription_id, **kwargs + ) self._client = AsyncARMPipelineClient(base_url=base_url, config=self._config, **kwargs) client_models = {k: v for k, v in models.__dict__.items() if isinstance(v, type)} @@ -58,14 +61,11 @@ def __init__( self._deserialize = Deserializer(client_models) self._serialize.client_side_validation = False self.template_specs = TemplateSpecsOperations(self._client, self._config, self._serialize, self._deserialize) - self.template_spec_versions = TemplateSpecVersionsOperations(self._client, self._config, self._serialize, self._deserialize) - + self.template_spec_versions = TemplateSpecVersionsOperations( + self._client, self._config, self._serialize, self._deserialize + ) - def _send_request( - self, - request: HttpRequest, - **kwargs: Any - ) -> Awaitable[AsyncHttpResponse]: + def _send_request(self, request: HttpRequest, **kwargs: Any) -> Awaitable[AsyncHttpResponse]: """Runs the network request through the client's chained policies. >>> from azure.core.rest import HttpRequest @@ -74,7 +74,7 @@ def _send_request( >>> response = await client._send_request(request) - For more information on this code flow, see https://aka.ms/azsdk/python/protocol/quickstart + For more information on this code flow, see https://aka.ms/azsdk/dpcodegen/python/send_request :param request: The network request you want to make. Required. :type request: ~azure.core.rest.HttpRequest diff --git a/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/templatespecs/v2021_03_01_preview/aio/operations/__init__.py b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/templatespecs/v2021_03_01_preview/aio/operations/__init__.py index cb4936f69ad57..1f6058ba55acd 100644 --- a/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/templatespecs/v2021_03_01_preview/aio/operations/__init__.py +++ b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/templatespecs/v2021_03_01_preview/aio/operations/__init__.py @@ -9,7 +9,13 @@ from ._operations import TemplateSpecsOperations from ._operations import TemplateSpecVersionsOperations +from ._patch import __all__ as _patch_all +from ._patch import * # type: ignore # pylint: disable=unused-wildcard-import +from ._patch import patch_sdk as _patch_sdk + __all__ = [ - 'TemplateSpecsOperations', - 'TemplateSpecVersionsOperations', + "TemplateSpecsOperations", + "TemplateSpecVersionsOperations", ] +__all__.extend([p for p in _patch_all if p not in __all__]) +_patch_sdk() diff --git a/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/templatespecs/v2021_03_01_preview/aio/operations/_operations.py b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/templatespecs/v2021_03_01_preview/aio/operations/_operations.py index f3b49bffd7ee9..555eca89c5c79 100644 --- a/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/templatespecs/v2021_03_01_preview/aio/operations/_operations.py +++ b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/templatespecs/v2021_03_01_preview/aio/operations/_operations.py @@ -6,94 +6,190 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -from typing import Any, AsyncIterable, Callable, Dict, Optional, TypeVar, Union +from typing import Any, AsyncIterable, Callable, Dict, IO, Optional, TypeVar, Union, overload +from urllib.parse import parse_qs, urljoin, urlparse from azure.core.async_paging import AsyncItemPaged, AsyncList -from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error +from azure.core.exceptions import ( + ClientAuthenticationError, + HttpResponseError, + ResourceExistsError, + ResourceNotFoundError, + ResourceNotModifiedError, + map_error, +) from azure.core.pipeline import PipelineResponse from azure.core.pipeline.transport import AsyncHttpResponse from azure.core.rest import HttpRequest from azure.core.tracing.decorator import distributed_trace from azure.core.tracing.decorator_async import distributed_trace_async +from azure.core.utils import case_insensitive_dict from azure.mgmt.core.exceptions import ARMErrorFormat from ... import models as _models from ..._vendor import _convert_request -from ...operations._operations import build_template_spec_versions_create_or_update_request, build_template_spec_versions_delete_request, build_template_spec_versions_get_request, build_template_spec_versions_list_request, build_template_spec_versions_update_request, build_template_specs_create_or_update_request, build_template_specs_delete_request, build_template_specs_get_request, build_template_specs_list_by_resource_group_request, build_template_specs_list_by_subscription_request, build_template_specs_update_request -T = TypeVar('T') +from ...operations._operations import ( + build_template_spec_versions_create_or_update_request, + build_template_spec_versions_delete_request, + build_template_spec_versions_get_request, + build_template_spec_versions_list_request, + build_template_spec_versions_update_request, + build_template_specs_create_or_update_request, + build_template_specs_delete_request, + build_template_specs_get_request, + build_template_specs_list_by_resource_group_request, + build_template_specs_list_by_subscription_request, + build_template_specs_update_request, +) + +T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] -class TemplateSpecsOperations: - """TemplateSpecsOperations async operations. - You should not instantiate this class directly. Instead, you should create a Client instance that - instantiates it for you and attaches it as an attribute. +class TemplateSpecsOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. - :ivar models: Alias to model classes used in this operation group. - :type models: ~azure.mgmt.resource.templatespecs.v2021_03_01_preview.models - :param client: Client for service requests. - :param config: Configuration of service client. - :param serializer: An object model serializer. - :param deserializer: An object model deserializer. + Instead, you should access the following operations through + :class:`~azure.mgmt.resource.templatespecs.v2021_03_01_preview.aio.TemplateSpecsClient`'s + :attr:`template_specs` attribute. """ models = _models - def __init__(self, client, config, serializer, deserializer) -> None: - self._client = client - self._serialize = serializer - self._deserialize = deserializer - self._config = config + def __init__(self, *args, **kwargs) -> None: + input_args = list(args) + self._client = input_args.pop(0) if input_args else kwargs.pop("client") + self._config = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") + + @overload + async def create_or_update( + self, + resource_group_name: str, + template_spec_name: str, + template_spec: _models.TemplateSpec, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.TemplateSpec: + """Creates or updates a Template Spec. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param template_spec_name: Name of the Template Spec. Required. + :type template_spec_name: str + :param template_spec: Template Spec supplied to the operation. Required. + :type template_spec: ~azure.mgmt.resource.templatespecs.v2021_03_01_preview.models.TemplateSpec + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: TemplateSpec or the result of cls(response) + :rtype: ~azure.mgmt.resource.templatespecs.v2021_03_01_preview.models.TemplateSpec + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + async def create_or_update( + self, + resource_group_name: str, + template_spec_name: str, + template_spec: IO, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.TemplateSpec: + """Creates or updates a Template Spec. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param template_spec_name: Name of the Template Spec. Required. + :type template_spec_name: str + :param template_spec: Template Spec supplied to the operation. Required. + :type template_spec: IO + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: TemplateSpec or the result of cls(response) + :rtype: ~azure.mgmt.resource.templatespecs.v2021_03_01_preview.models.TemplateSpec + :raises ~azure.core.exceptions.HttpResponseError: + """ @distributed_trace_async async def create_or_update( self, resource_group_name: str, template_spec_name: str, - template_spec: "_models.TemplateSpec", + template_spec: Union[_models.TemplateSpec, IO], **kwargs: Any - ) -> "_models.TemplateSpec": + ) -> _models.TemplateSpec: """Creates or updates a Template Spec. :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. :type resource_group_name: str - :param template_spec_name: Name of the Template Spec. + :param template_spec_name: Name of the Template Spec. Required. :type template_spec_name: str - :param template_spec: Template Spec supplied to the operation. + :param template_spec: Template Spec supplied to the operation. Is either a model type or a IO + type. Required. :type template_spec: ~azure.mgmt.resource.templatespecs.v2021_03_01_preview.models.TemplateSpec + or IO + :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. + Default value is None. + :paramtype content_type: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: TemplateSpec, or the result of cls(response) + :return: TemplateSpec or the result of cls(response) :rtype: ~azure.mgmt.resource.templatespecs.v2021_03_01_preview.models.TemplateSpec - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.TemplateSpec"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', "2021-03-01-preview") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-03-01-preview")) # type: str + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.TemplateSpec] - _json = self._serialize.body(template_spec, 'TemplateSpec') + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(template_spec, (IO, bytes)): + _content = template_spec + else: + _json = self._serialize.body(template_spec, "TemplateSpec") request = build_template_specs_create_or_update_request( - subscription_id=self._config.subscription_id, resource_group_name=resource_group_name, template_spec_name=template_spec_name, + subscription_id=self._config.subscription_id, api_version=api_version, content_type=content_type, json=_json, - template_url=self.create_or_update.metadata['url'], + content=_content, + template_url=self.create_or_update.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200, 201]: @@ -102,73 +198,149 @@ async def create_or_update( raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) if response.status_code == 200: - deserialized = self._deserialize('TemplateSpec', pipeline_response) + deserialized = self._deserialize("TemplateSpec", pipeline_response) if response.status_code == 201: - deserialized = self._deserialize('TemplateSpec', pipeline_response) + deserialized = self._deserialize("TemplateSpec", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - create_or_update.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Resources/templateSpecs/{templateSpecName}"} # type: ignore + create_or_update.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Resources/templateSpecs/{templateSpecName}"} # type: ignore - - @distributed_trace_async + @overload async def update( self, resource_group_name: str, template_spec_name: str, - template_spec: Optional["_models.TemplateSpecUpdateModel"] = None, + template_spec: Optional[_models.TemplateSpecUpdateModel] = None, + *, + content_type: str = "application/json", **kwargs: Any - ) -> "_models.TemplateSpec": + ) -> _models.TemplateSpec: """Updates Template Spec tags with specified values. :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. :type resource_group_name: str - :param template_spec_name: Name of the Template Spec. + :param template_spec_name: Name of the Template Spec. Required. :type template_spec_name: str :param template_spec: Template Spec resource with the tags to be updated. Default value is None. :type template_spec: ~azure.mgmt.resource.templatespecs.v2021_03_01_preview.models.TemplateSpecUpdateModel + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: TemplateSpec or the result of cls(response) + :rtype: ~azure.mgmt.resource.templatespecs.v2021_03_01_preview.models.TemplateSpec + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + async def update( + self, + resource_group_name: str, + template_spec_name: str, + template_spec: Optional[IO] = None, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.TemplateSpec: + """Updates Template Spec tags with specified values. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param template_spec_name: Name of the Template Spec. Required. + :type template_spec_name: str + :param template_spec: Template Spec resource with the tags to be updated. Default value is + None. + :type template_spec: IO + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: TemplateSpec, or the result of cls(response) + :return: TemplateSpec or the result of cls(response) :rtype: ~azure.mgmt.resource.templatespecs.v2021_03_01_preview.models.TemplateSpec - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace_async + async def update( + self, + resource_group_name: str, + template_spec_name: str, + template_spec: Optional[Union[_models.TemplateSpecUpdateModel, IO]] = None, + **kwargs: Any + ) -> _models.TemplateSpec: + """Updates Template Spec tags with specified values. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param template_spec_name: Name of the Template Spec. Required. + :type template_spec_name: str + :param template_spec: Template Spec resource with the tags to be updated. Is either a model + type or a IO type. Default value is None. + :type template_spec: + ~azure.mgmt.resource.templatespecs.v2021_03_01_preview.models.TemplateSpecUpdateModel or IO + :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. + Default value is None. + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: TemplateSpec or the result of cls(response) + :rtype: ~azure.mgmt.resource.templatespecs.v2021_03_01_preview.models.TemplateSpec + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.TemplateSpec"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) - api_version = kwargs.pop('api_version', "2021-03-01-preview") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - if template_spec is not None: - _json = self._serialize.body(template_spec, 'TemplateSpecUpdateModel') + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-03-01-preview")) # type: str + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.TemplateSpec] + + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(template_spec, (IO, bytes)): + _content = template_spec else: - _json = None + if template_spec is not None: + _json = self._serialize.body(template_spec, "TemplateSpecUpdateModel") + else: + _json = None request = build_template_specs_update_request( - subscription_id=self._config.subscription_id, resource_group_name=resource_group_name, template_spec_name=template_spec_name, + subscription_id=self._config.subscription_id, api_version=api_version, content_type=content_type, json=_json, - template_url=self.update.metadata['url'], + content=_content, + template_url=self.update.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200]: @@ -176,15 +348,14 @@ async def update( error = self._deserialize.failsafe_deserialize(_models.TemplateSpecsError, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - deserialized = self._deserialize('TemplateSpec', pipeline_response) + deserialized = self._deserialize("TemplateSpec", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - update.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Resources/templateSpecs/{templateSpecName}"} # type: ignore - + update.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Resources/templateSpecs/{templateSpecName}"} # type: ignore @distributed_trace_async async def get( @@ -193,47 +364,54 @@ async def get( template_spec_name: str, expand: Optional[Union[str, "_models.TemplateSpecExpandKind"]] = None, **kwargs: Any - ) -> "_models.TemplateSpec": + ) -> _models.TemplateSpec: """Gets a Template Spec with a given name. :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. :type resource_group_name: str - :param template_spec_name: Name of the Template Spec. + :param template_spec_name: Name of the Template Spec. Required. :type template_spec_name: str :param expand: Allows for expansion of additional Template Spec details in the response. - Optional. Default value is None. + Optional. "versions" Default value is None. :type expand: str or ~azure.mgmt.resource.templatespecs.v2021_03_01_preview.models.TemplateSpecExpandKind :keyword callable cls: A custom type or function that will be passed the direct response - :return: TemplateSpec, or the result of cls(response) + :return: TemplateSpec or the result of cls(response) :rtype: ~azure.mgmt.resource.templatespecs.v2021_03_01_preview.models.TemplateSpec - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.TemplateSpec"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + 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', "2021-03-01-preview") # type: str + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-03-01-preview")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[_models.TemplateSpec] - request = build_template_specs_get_request( - subscription_id=self._config.subscription_id, resource_group_name=resource_group_name, template_spec_name=template_spec_name, - api_version=api_version, + subscription_id=self._config.subscription_id, expand=expand, - template_url=self.get.metadata['url'], + api_version=api_version, + template_url=self.get.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200]: @@ -241,59 +419,62 @@ async def get( error = self._deserialize.failsafe_deserialize(_models.TemplateSpecsError, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - deserialized = self._deserialize('TemplateSpec', pipeline_response) + deserialized = self._deserialize("TemplateSpec", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - get.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Resources/templateSpecs/{templateSpecName}"} # type: ignore - + get.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Resources/templateSpecs/{templateSpecName}"} # type: ignore @distributed_trace_async async def delete( # pylint: disable=inconsistent-return-statements - self, - resource_group_name: str, - template_spec_name: str, - **kwargs: Any + self, resource_group_name: str, template_spec_name: str, **kwargs: Any ) -> None: """Deletes a Template Spec by name. When operation completes, status code 200 returned without content. :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. :type resource_group_name: str - :param template_spec_name: Name of the Template Spec. + :param template_spec_name: Name of the Template Spec. Required. :type template_spec_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: None, or the result of cls(response) + :return: None or the result of cls(response) :rtype: None - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType[None] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) - api_version = kwargs.pop('api_version', "2021-03-01-preview") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-03-01-preview")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[None] - request = build_template_specs_delete_request( - subscription_id=self._config.subscription_id, resource_group_name=resource_group_name, template_spec_name=template_spec_name, + subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.delete.metadata['url'], + template_url=self.delete.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200, 204]: @@ -304,55 +485,60 @@ async def delete( # pylint: disable=inconsistent-return-statements if cls: return cls(pipeline_response, None, {}) - delete.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Resources/templateSpecs/{templateSpecName}"} # type: ignore - + delete.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Resources/templateSpecs/{templateSpecName}"} # type: ignore @distributed_trace def list_by_subscription( - self, - expand: Optional[Union[str, "_models.TemplateSpecExpandKind"]] = None, - **kwargs: Any - ) -> AsyncIterable["_models.TemplateSpecsListResult"]: + self, expand: Optional[Union[str, "_models.TemplateSpecExpandKind"]] = None, **kwargs: Any + ) -> AsyncIterable["_models.TemplateSpec"]: """Lists all the Template Specs within the specified subscriptions. :param expand: Allows for expansion of additional Template Spec details in the response. - Optional. Default value is None. + Optional. "versions" Default value is None. :type expand: str or ~azure.mgmt.resource.templatespecs.v2021_03_01_preview.models.TemplateSpecExpandKind :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either TemplateSpecsListResult or the result of - cls(response) + :return: An iterator like instance of either TemplateSpec or the result of cls(response) :rtype: - ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.resource.templatespecs.v2021_03_01_preview.models.TemplateSpecsListResult] - :raises: ~azure.core.exceptions.HttpResponseError + ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.resource.templatespecs.v2021_03_01_preview.models.TemplateSpec] + :raises ~azure.core.exceptions.HttpResponseError: """ - api_version = kwargs.pop('api_version', "2021-03-01-preview") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-03-01-preview")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[_models.TemplateSpecsListResult] - cls = kwargs.pop('cls', None) # type: ClsType["_models.TemplateSpecsListResult"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) + def prepare_request(next_link=None): if not next_link: - + request = build_template_specs_list_by_subscription_request( subscription_id=self._config.subscription_id, - api_version=api_version, expand=expand, - template_url=self.list_by_subscription.metadata['url'], + api_version=api_version, + template_url=self.list_by_subscription.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore else: - - request = build_template_specs_list_by_subscription_request( - subscription_id=self._config.subscription_id, - template_url=next_link, - ) + # make call to next link with the client's api-version + _parsed_next_link = urlparse(next_link) + _next_request_params = case_insensitive_dict(parse_qs(_parsed_next_link.query)) + _next_request_params["api-version"] = self._config.api_version + request = HttpRequest("GET", urljoin(next_link, _parsed_next_link.path), params=_next_request_params) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore request.method = "GET" return request @@ -366,10 +552,8 @@ async def extract_data(pipeline_response): async def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) response = pipeline_response.http_response @@ -380,11 +564,9 @@ async def get_next(next_link=None): return pipeline_response + return AsyncItemPaged(get_next, extract_data) - return AsyncItemPaged( - get_next, extract_data - ) - list_by_subscription.metadata = {'url': "/subscriptions/{subscriptionId}/providers/Microsoft.Resources/templateSpecs/"} # type: ignore + list_by_subscription.metadata = {"url": "/subscriptions/{subscriptionId}/providers/Microsoft.Resources/templateSpecs/"} # type: ignore @distributed_trace def list_by_resource_group( @@ -392,51 +574,59 @@ def list_by_resource_group( resource_group_name: str, expand: Optional[Union[str, "_models.TemplateSpecExpandKind"]] = None, **kwargs: Any - ) -> AsyncIterable["_models.TemplateSpecsListResult"]: + ) -> AsyncIterable["_models.TemplateSpec"]: """Lists all the Template Specs within the specified resource group. :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. :type resource_group_name: str :param expand: Allows for expansion of additional Template Spec details in the response. - Optional. Default value is None. + Optional. "versions" Default value is None. :type expand: str or ~azure.mgmt.resource.templatespecs.v2021_03_01_preview.models.TemplateSpecExpandKind :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either TemplateSpecsListResult or the result of - cls(response) + :return: An iterator like instance of either TemplateSpec or the result of cls(response) :rtype: - ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.resource.templatespecs.v2021_03_01_preview.models.TemplateSpecsListResult] - :raises: ~azure.core.exceptions.HttpResponseError + ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.resource.templatespecs.v2021_03_01_preview.models.TemplateSpec] + :raises ~azure.core.exceptions.HttpResponseError: """ - api_version = kwargs.pop('api_version', "2021-03-01-preview") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-03-01-preview")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[_models.TemplateSpecsListResult] - cls = kwargs.pop('cls', None) # type: ClsType["_models.TemplateSpecsListResult"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) + def prepare_request(next_link=None): if not next_link: - + request = build_template_specs_list_by_resource_group_request( - subscription_id=self._config.subscription_id, resource_group_name=resource_group_name, - api_version=api_version, + subscription_id=self._config.subscription_id, expand=expand, - template_url=self.list_by_resource_group.metadata['url'], + 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.url = self._client.format_url(request.url) # type: ignore else: - - request = build_template_specs_list_by_resource_group_request( - subscription_id=self._config.subscription_id, - resource_group_name=resource_group_name, - template_url=next_link, - ) + # make call to next link with the client's api-version + _parsed_next_link = urlparse(next_link) + _next_request_params = case_insensitive_dict(parse_qs(_parsed_next_link.query)) + _next_request_params["api-version"] = self._config.api_version + request = HttpRequest("GET", urljoin(next_link, _parsed_next_link.path), params=_next_request_params) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore request.method = "GET" return request @@ -450,10 +640,8 @@ async def extract_data(pipeline_response): async def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) response = pipeline_response.http_response @@ -464,87 +652,166 @@ async def get_next(next_link=None): return pipeline_response + return AsyncItemPaged(get_next, extract_data) - return AsyncItemPaged( - get_next, extract_data - ) - list_by_resource_group.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Resources/templateSpecs/"} # type: ignore -class TemplateSpecVersionsOperations: - """TemplateSpecVersionsOperations async operations. + list_by_resource_group.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Resources/templateSpecs/"} # type: ignore - You should not instantiate this class directly. Instead, you should create a Client instance that - instantiates it for you and attaches it as an attribute. - :ivar models: Alias to model classes used in this operation group. - :type models: ~azure.mgmt.resource.templatespecs.v2021_03_01_preview.models - :param client: Client for service requests. - :param config: Configuration of service client. - :param serializer: An object model serializer. - :param deserializer: An object model deserializer. +class TemplateSpecVersionsOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. + + Instead, you should access the following operations through + :class:`~azure.mgmt.resource.templatespecs.v2021_03_01_preview.aio.TemplateSpecsClient`'s + :attr:`template_spec_versions` attribute. """ models = _models - def __init__(self, client, config, serializer, deserializer) -> None: - self._client = client - self._serialize = serializer - self._deserialize = deserializer - self._config = config + def __init__(self, *args, **kwargs) -> None: + input_args = list(args) + self._client = input_args.pop(0) if input_args else kwargs.pop("client") + self._config = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") - @distributed_trace_async + @overload async def create_or_update( self, resource_group_name: str, template_spec_name: str, template_spec_version: str, - template_spec_version_model: "_models.TemplateSpecVersion", + template_spec_version_model: _models.TemplateSpecVersion, + *, + content_type: str = "application/json", **kwargs: Any - ) -> "_models.TemplateSpecVersion": + ) -> _models.TemplateSpecVersion: """Creates or updates a Template Spec version. :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. :type resource_group_name: str - :param template_spec_name: Name of the Template Spec. + :param template_spec_name: Name of the Template Spec. Required. :type template_spec_name: str - :param template_spec_version: The version of the Template Spec. + :param template_spec_version: The version of the Template Spec. Required. :type template_spec_version: str - :param template_spec_version_model: Template Spec Version supplied to the operation. + :param template_spec_version_model: Template Spec Version supplied to the operation. Required. :type template_spec_version_model: ~azure.mgmt.resource.templatespecs.v2021_03_01_preview.models.TemplateSpecVersion + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: TemplateSpecVersion or the result of cls(response) + :rtype: ~azure.mgmt.resource.templatespecs.v2021_03_01_preview.models.TemplateSpecVersion + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + async def create_or_update( + self, + resource_group_name: str, + template_spec_name: str, + template_spec_version: str, + template_spec_version_model: IO, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.TemplateSpecVersion: + """Creates or updates a Template Spec version. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param template_spec_name: Name of the Template Spec. Required. + :type template_spec_name: str + :param template_spec_version: The version of the Template Spec. Required. + :type template_spec_version: str + :param template_spec_version_model: Template Spec Version supplied to the operation. Required. + :type template_spec_version_model: IO + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: TemplateSpecVersion or the result of cls(response) + :rtype: ~azure.mgmt.resource.templatespecs.v2021_03_01_preview.models.TemplateSpecVersion + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace_async + async def create_or_update( + self, + resource_group_name: str, + template_spec_name: str, + template_spec_version: str, + template_spec_version_model: Union[_models.TemplateSpecVersion, IO], + **kwargs: Any + ) -> _models.TemplateSpecVersion: + """Creates or updates a Template Spec version. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param template_spec_name: Name of the Template Spec. Required. + :type template_spec_name: str + :param template_spec_version: The version of the Template Spec. Required. + :type template_spec_version: str + :param template_spec_version_model: Template Spec Version supplied to the operation. Is either + a model type or a IO type. Required. + :type template_spec_version_model: + ~azure.mgmt.resource.templatespecs.v2021_03_01_preview.models.TemplateSpecVersion or IO + :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. + Default value is None. + :paramtype content_type: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: TemplateSpecVersion, or the result of cls(response) + :return: TemplateSpecVersion or the result of cls(response) :rtype: ~azure.mgmt.resource.templatespecs.v2021_03_01_preview.models.TemplateSpecVersion - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.TemplateSpecVersion"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', "2021-03-01-preview") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-03-01-preview")) # type: str + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.TemplateSpecVersion] - _json = self._serialize.body(template_spec_version_model, 'TemplateSpecVersion') + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(template_spec_version_model, (IO, bytes)): + _content = template_spec_version_model + else: + _json = self._serialize.body(template_spec_version_model, "TemplateSpecVersion") request = build_template_spec_versions_create_or_update_request( - subscription_id=self._config.subscription_id, resource_group_name=resource_group_name, template_spec_name=template_spec_name, template_spec_version=template_spec_version, + subscription_id=self._config.subscription_id, api_version=api_version, content_type=content_type, json=_json, - template_url=self.create_or_update.metadata['url'], + content=_content, + template_url=self.create_or_update.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200, 201]: @@ -553,77 +820,160 @@ async def create_or_update( raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) if response.status_code == 200: - deserialized = self._deserialize('TemplateSpecVersion', pipeline_response) + deserialized = self._deserialize("TemplateSpecVersion", pipeline_response) if response.status_code == 201: - deserialized = self._deserialize('TemplateSpecVersion', pipeline_response) + deserialized = self._deserialize("TemplateSpecVersion", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - create_or_update.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Resources/templateSpecs/{templateSpecName}/versions/{templateSpecVersion}"} # type: ignore + create_or_update.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Resources/templateSpecs/{templateSpecName}/versions/{templateSpecVersion}"} # type: ignore - - @distributed_trace_async + @overload async def update( self, resource_group_name: str, template_spec_name: str, template_spec_version: str, - template_spec_version_update_model: Optional["_models.TemplateSpecVersionUpdateModel"] = None, + template_spec_version_update_model: Optional[_models.TemplateSpecVersionUpdateModel] = None, + *, + content_type: str = "application/json", **kwargs: Any - ) -> "_models.TemplateSpecVersion": + ) -> _models.TemplateSpecVersion: """Updates Template Spec Version tags with specified values. :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. :type resource_group_name: str - :param template_spec_name: Name of the Template Spec. + :param template_spec_name: Name of the Template Spec. Required. :type template_spec_name: str - :param template_spec_version: The version of the Template Spec. + :param template_spec_version: The version of the Template Spec. Required. :type template_spec_version: str :param template_spec_version_update_model: Template Spec Version resource with the tags to be updated. Default value is None. :type template_spec_version_update_model: ~azure.mgmt.resource.templatespecs.v2021_03_01_preview.models.TemplateSpecVersionUpdateModel + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: TemplateSpecVersion or the result of cls(response) + :rtype: ~azure.mgmt.resource.templatespecs.v2021_03_01_preview.models.TemplateSpecVersion + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + async def update( + self, + resource_group_name: str, + template_spec_name: str, + template_spec_version: str, + template_spec_version_update_model: Optional[IO] = None, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.TemplateSpecVersion: + """Updates Template Spec Version tags with specified values. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param template_spec_name: Name of the Template Spec. Required. + :type template_spec_name: str + :param template_spec_version: The version of the Template Spec. Required. + :type template_spec_version: str + :param template_spec_version_update_model: Template Spec Version resource with the tags to be + updated. Default value is None. + :type template_spec_version_update_model: IO + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: TemplateSpecVersion, or the result of cls(response) + :return: TemplateSpecVersion or the result of cls(response) :rtype: ~azure.mgmt.resource.templatespecs.v2021_03_01_preview.models.TemplateSpecVersion - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace_async + async def update( + self, + resource_group_name: str, + template_spec_name: str, + template_spec_version: str, + template_spec_version_update_model: Optional[Union[_models.TemplateSpecVersionUpdateModel, IO]] = None, + **kwargs: Any + ) -> _models.TemplateSpecVersion: + """Updates Template Spec Version tags with specified values. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param template_spec_name: Name of the Template Spec. Required. + :type template_spec_name: str + :param template_spec_version: The version of the Template Spec. Required. + :type template_spec_version: str + :param template_spec_version_update_model: Template Spec Version resource with the tags to be + updated. Is either a model type or a IO type. Default value is None. + :type template_spec_version_update_model: + ~azure.mgmt.resource.templatespecs.v2021_03_01_preview.models.TemplateSpecVersionUpdateModel or + IO + :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. + Default value is None. + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: TemplateSpecVersion or the result of cls(response) + :rtype: ~azure.mgmt.resource.templatespecs.v2021_03_01_preview.models.TemplateSpecVersion + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.TemplateSpecVersion"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) - api_version = kwargs.pop('api_version', "2021-03-01-preview") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - if template_spec_version_update_model is not None: - _json = self._serialize.body(template_spec_version_update_model, 'TemplateSpecVersionUpdateModel') + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-03-01-preview")) # type: str + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.TemplateSpecVersion] + + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(template_spec_version_update_model, (IO, bytes)): + _content = template_spec_version_update_model else: - _json = None + if template_spec_version_update_model is not None: + _json = self._serialize.body(template_spec_version_update_model, "TemplateSpecVersionUpdateModel") + else: + _json = None request = build_template_spec_versions_update_request( - subscription_id=self._config.subscription_id, resource_group_name=resource_group_name, template_spec_name=template_spec_name, template_spec_version=template_spec_version, + subscription_id=self._config.subscription_id, api_version=api_version, content_type=content_type, json=_json, - template_url=self.update.metadata['url'], + content=_content, + template_url=self.update.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200]: @@ -631,62 +981,64 @@ async def update( error = self._deserialize.failsafe_deserialize(_models.TemplateSpecsError, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - deserialized = self._deserialize('TemplateSpecVersion', pipeline_response) + deserialized = self._deserialize("TemplateSpecVersion", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - update.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Resources/templateSpecs/{templateSpecName}/versions/{templateSpecVersion}"} # type: ignore - + update.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Resources/templateSpecs/{templateSpecName}/versions/{templateSpecVersion}"} # type: ignore @distributed_trace_async async def get( - self, - resource_group_name: str, - template_spec_name: str, - template_spec_version: str, - **kwargs: Any - ) -> "_models.TemplateSpecVersion": + self, resource_group_name: str, template_spec_name: str, template_spec_version: str, **kwargs: Any + ) -> _models.TemplateSpecVersion: """Gets a Template Spec version from a specific Template Spec. :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. :type resource_group_name: str - :param template_spec_name: Name of the Template Spec. + :param template_spec_name: Name of the Template Spec. Required. :type template_spec_name: str - :param template_spec_version: The version of the Template Spec. + :param template_spec_version: The version of the Template Spec. Required. :type template_spec_version: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: TemplateSpecVersion, or the result of cls(response) + :return: TemplateSpecVersion or the result of cls(response) :rtype: ~azure.mgmt.resource.templatespecs.v2021_03_01_preview.models.TemplateSpecVersion - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.TemplateSpecVersion"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) - api_version = kwargs.pop('api_version', "2021-03-01-preview") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-03-01-preview")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[_models.TemplateSpecVersion] - request = build_template_spec_versions_get_request( - subscription_id=self._config.subscription_id, resource_group_name=resource_group_name, template_spec_name=template_spec_name, template_spec_version=template_spec_version, + subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.get.metadata['url'], + template_url=self.get.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200]: @@ -694,63 +1046,65 @@ async def get( error = self._deserialize.failsafe_deserialize(_models.TemplateSpecsError, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - deserialized = self._deserialize('TemplateSpecVersion', pipeline_response) + deserialized = self._deserialize("TemplateSpecVersion", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - get.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Resources/templateSpecs/{templateSpecName}/versions/{templateSpecVersion}"} # type: ignore - + get.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Resources/templateSpecs/{templateSpecName}/versions/{templateSpecVersion}"} # type: ignore @distributed_trace_async async def delete( # pylint: disable=inconsistent-return-statements - self, - resource_group_name: str, - template_spec_name: str, - template_spec_version: str, - **kwargs: Any + self, resource_group_name: str, template_spec_name: str, template_spec_version: str, **kwargs: Any ) -> None: """Deletes a specific version from a Template Spec. When operation completes, status code 200 returned without content. :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. :type resource_group_name: str - :param template_spec_name: Name of the Template Spec. + :param template_spec_name: Name of the Template Spec. Required. :type template_spec_name: str - :param template_spec_version: The version of the Template Spec. + :param template_spec_version: The version of the Template Spec. Required. :type template_spec_version: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: None, or the result of cls(response) + :return: None or the result of cls(response) :rtype: None - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType[None] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) - api_version = kwargs.pop('api_version', "2021-03-01-preview") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-03-01-preview")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[None] - request = build_template_spec_versions_delete_request( - subscription_id=self._config.subscription_id, resource_group_name=resource_group_name, template_spec_name=template_spec_name, template_spec_version=template_spec_version, + subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.delete.metadata['url'], + template_url=self.delete.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200, 204]: @@ -761,59 +1115,62 @@ async def delete( # pylint: disable=inconsistent-return-statements if cls: return cls(pipeline_response, None, {}) - delete.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Resources/templateSpecs/{templateSpecName}/versions/{templateSpecVersion}"} # type: ignore - + delete.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Resources/templateSpecs/{templateSpecName}/versions/{templateSpecVersion}"} # type: ignore @distributed_trace def list( - self, - resource_group_name: str, - template_spec_name: str, - **kwargs: Any - ) -> AsyncIterable["_models.TemplateSpecVersionsListResult"]: + self, resource_group_name: str, template_spec_name: str, **kwargs: Any + ) -> AsyncIterable["_models.TemplateSpecVersion"]: """Lists all the Template Spec versions in the specified Template Spec. :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. :type resource_group_name: str - :param template_spec_name: Name of the Template Spec. + :param template_spec_name: Name of the Template Spec. Required. :type template_spec_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either TemplateSpecVersionsListResult or the result of - cls(response) + :return: An iterator like instance of either TemplateSpecVersion or the result of cls(response) :rtype: - ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.resource.templatespecs.v2021_03_01_preview.models.TemplateSpecVersionsListResult] - :raises: ~azure.core.exceptions.HttpResponseError + ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.resource.templatespecs.v2021_03_01_preview.models.TemplateSpecVersion] + :raises ~azure.core.exceptions.HttpResponseError: """ - api_version = kwargs.pop('api_version', "2021-03-01-preview") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-03-01-preview")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[_models.TemplateSpecVersionsListResult] - cls = kwargs.pop('cls', None) # type: ClsType["_models.TemplateSpecVersionsListResult"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) + def prepare_request(next_link=None): if not next_link: - + request = build_template_spec_versions_list_request( - subscription_id=self._config.subscription_id, resource_group_name=resource_group_name, template_spec_name=template_spec_name, + subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.list.metadata['url'], + template_url=self.list.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore else: - - request = build_template_spec_versions_list_request( - subscription_id=self._config.subscription_id, - resource_group_name=resource_group_name, - template_spec_name=template_spec_name, - template_url=next_link, - ) + # make call to next link with the client's api-version + _parsed_next_link = urlparse(next_link) + _next_request_params = case_insensitive_dict(parse_qs(_parsed_next_link.query)) + _next_request_params["api-version"] = self._config.api_version + request = HttpRequest("GET", urljoin(next_link, _parsed_next_link.path), params=_next_request_params) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore request.method = "GET" return request @@ -827,10 +1184,8 @@ async def extract_data(pipeline_response): async def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) response = pipeline_response.http_response @@ -841,8 +1196,6 @@ async def get_next(next_link=None): return pipeline_response + return AsyncItemPaged(get_next, extract_data) - return AsyncItemPaged( - get_next, extract_data - ) - list.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Resources/templateSpecs/{templateSpecName}/versions"} # type: ignore + list.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Resources/templateSpecs/{templateSpecName}/versions"} # type: ignore diff --git a/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/templatespecs/v2021_03_01_preview/aio/operations/_patch.py b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/templatespecs/v2021_03_01_preview/aio/operations/_patch.py new file mode 100644 index 0000000000000..f7dd32510333d --- /dev/null +++ b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/templatespecs/v2021_03_01_preview/aio/operations/_patch.py @@ -0,0 +1,20 @@ +# ------------------------------------ +# Copyright (c) Microsoft Corporation. +# Licensed under the MIT License. +# ------------------------------------ +"""Customize generated code here. + +Follow our quickstart for examples: https://aka.ms/azsdk/python/dpcodegen/python/customize +""" +from typing import List + +__all__: List[str] = [] # Add all objects you want publicly available to users at this package level + + +def patch_sdk(): + """Do not remove from this file. + + `patch_sdk` is a last resort escape hatch that allows you to do customizations + you can't accomplish using the techniques described in + https://aka.ms/azsdk/python/dpcodegen/python/customize + """ diff --git a/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/templatespecs/v2021_03_01_preview/models/__init__.py b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/templatespecs/v2021_03_01_preview/models/__init__.py index 2b966fa1d8bbf..641cfe9fca945 100644 --- a/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/templatespecs/v2021_03_01_preview/models/__init__.py +++ b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/templatespecs/v2021_03_01_preview/models/__init__.py @@ -20,26 +20,28 @@ from ._models_py3 import TemplateSpecsError from ._models_py3 import TemplateSpecsListResult - -from ._template_specs_client_enums import ( - CreatedByType, - TemplateSpecExpandKind, -) +from ._template_specs_client_enums import CreatedByType +from ._template_specs_client_enums import TemplateSpecExpandKind +from ._patch import __all__ as _patch_all +from ._patch import * # type: ignore # pylint: disable=unused-wildcard-import +from ._patch import patch_sdk as _patch_sdk __all__ = [ - 'AzureResourceBase', - 'ErrorAdditionalInfo', - 'ErrorResponse', - 'LinkedTemplateArtifact', - 'SystemData', - 'TemplateSpec', - 'TemplateSpecUpdateModel', - 'TemplateSpecVersion', - 'TemplateSpecVersionInfo', - 'TemplateSpecVersionUpdateModel', - 'TemplateSpecVersionsListResult', - 'TemplateSpecsError', - 'TemplateSpecsListResult', - 'CreatedByType', - 'TemplateSpecExpandKind', + "AzureResourceBase", + "ErrorAdditionalInfo", + "ErrorResponse", + "LinkedTemplateArtifact", + "SystemData", + "TemplateSpec", + "TemplateSpecUpdateModel", + "TemplateSpecVersion", + "TemplateSpecVersionInfo", + "TemplateSpecVersionUpdateModel", + "TemplateSpecVersionsListResult", + "TemplateSpecsError", + "TemplateSpecsListResult", + "CreatedByType", + "TemplateSpecExpandKind", ] +__all__.extend([p for p in _patch_all if p not in __all__]) +_patch_sdk() diff --git a/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/templatespecs/v2021_03_01_preview/models/_models_py3.py b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/templatespecs/v2021_03_01_preview/models/_models_py3.py index 0ca7a984d7554..b02e62c11e8c2 100644 --- a/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/templatespecs/v2021_03_01_preview/models/_models_py3.py +++ b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/templatespecs/v2021_03_01_preview/models/_models_py3.py @@ -1,4 +1,5 @@ # coding=utf-8 +# pylint: disable=too-many-lines # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. # Licensed under the MIT License. See License.txt in the project root for license information. @@ -7,15 +8,22 @@ # -------------------------------------------------------------------------- import datetime -from typing import Any, Dict, List, Optional, Union +import sys +from typing import Any, Dict, List, Optional, TYPE_CHECKING, Union -from azure.core.exceptions import HttpResponseError -import msrest.serialization +from ... import _serialization -from ._template_specs_client_enums import * +if TYPE_CHECKING: + # pylint: disable=unused-import,ungrouped-imports + from .. import models as _models +if sys.version_info >= (3, 9): + from collections.abc import MutableMapping +else: + from typing import MutableMapping # type: ignore # pylint: disable=ungrouped-imports +JSON = MutableMapping[str, Any] # pylint: disable=unsubscriptable-object -class AzureResourceBase(msrest.serialization.Model): +class AzureResourceBase(_serialization.Model): """Common properties for all Azure resources. Variables are only populated by the server, and will be ignored when sending a request. @@ -32,33 +40,29 @@ class AzureResourceBase(msrest.serialization.Model): """ _validation = { - 'id': {'readonly': True}, - 'name': {'readonly': True}, - 'type': {'readonly': True}, - 'system_data': {'readonly': True}, + "id": {"readonly": True}, + "name": {"readonly": True}, + "type": {"readonly": True}, + "system_data": {"readonly": True}, } _attribute_map = { - 'id': {'key': 'id', 'type': 'str'}, - 'name': {'key': 'name', 'type': 'str'}, - 'type': {'key': 'type', 'type': 'str'}, - 'system_data': {'key': 'systemData', 'type': 'SystemData'}, + "id": {"key": "id", "type": "str"}, + "name": {"key": "name", "type": "str"}, + "type": {"key": "type", "type": "str"}, + "system_data": {"key": "systemData", "type": "SystemData"}, } - def __init__( - self, - **kwargs - ): - """ - """ - super(AzureResourceBase, self).__init__(**kwargs) + def __init__(self, **kwargs): + """ """ + super().__init__(**kwargs) self.id = None self.name = None self.type = None self.system_data = None -class ErrorAdditionalInfo(msrest.serialization.Model): +class ErrorAdditionalInfo(_serialization.Model): """The resource management error additional info. Variables are only populated by the server, and will be ignored when sending a request. @@ -66,31 +70,27 @@ class ErrorAdditionalInfo(msrest.serialization.Model): :ivar type: The additional info type. :vartype type: str :ivar info: The additional info. - :vartype info: any + :vartype info: JSON """ _validation = { - 'type': {'readonly': True}, - 'info': {'readonly': True}, + "type": {"readonly": True}, + "info": {"readonly": True}, } _attribute_map = { - 'type': {'key': 'type', 'type': 'str'}, - 'info': {'key': 'info', 'type': 'object'}, + "type": {"key": "type", "type": "str"}, + "info": {"key": "info", "type": "object"}, } - def __init__( - self, - **kwargs - ): - """ - """ - super(ErrorAdditionalInfo, self).__init__(**kwargs) + def __init__(self, **kwargs): + """ """ + super().__init__(**kwargs) self.type = None self.info = None -class ErrorResponse(msrest.serialization.Model): +class ErrorResponse(_serialization.Model): """Common error response for all Azure Resource Manager APIs to return error details for failed operations. (This also follows the OData error response format.). Variables are only populated by the server, and will be ignored when sending a request. @@ -110,28 +110,24 @@ class ErrorResponse(msrest.serialization.Model): """ _validation = { - 'code': {'readonly': True}, - 'message': {'readonly': True}, - 'target': {'readonly': True}, - 'details': {'readonly': True}, - 'additional_info': {'readonly': True}, + "code": {"readonly": True}, + "message": {"readonly": True}, + "target": {"readonly": True}, + "details": {"readonly": True}, + "additional_info": {"readonly": True}, } _attribute_map = { - 'code': {'key': 'code', 'type': 'str'}, - 'message': {'key': 'message', 'type': 'str'}, - 'target': {'key': 'target', 'type': 'str'}, - 'details': {'key': 'details', 'type': '[ErrorResponse]'}, - 'additional_info': {'key': 'additionalInfo', 'type': '[ErrorAdditionalInfo]'}, + "code": {"key": "code", "type": "str"}, + "message": {"key": "message", "type": "str"}, + "target": {"key": "target", "type": "str"}, + "details": {"key": "details", "type": "[ErrorResponse]"}, + "additional_info": {"key": "additionalInfo", "type": "[ErrorAdditionalInfo]"}, } - def __init__( - self, - **kwargs - ): - """ - """ - super(ErrorResponse, self).__init__(**kwargs) + def __init__(self, **kwargs): + """ """ + super().__init__(**kwargs) self.code = None self.message = None self.target = None @@ -139,60 +135,54 @@ def __init__( self.additional_info = None -class LinkedTemplateArtifact(msrest.serialization.Model): +class LinkedTemplateArtifact(_serialization.Model): """Represents a Template Spec artifact containing an embedded Azure Resource Manager template for use as a linked template. All required parameters must be populated in order to send to Azure. - :ivar path: Required. A filesystem safe relative path of the artifact. + :ivar path: A filesystem safe relative path of the artifact. Required. :vartype path: str - :ivar template: Required. The Azure Resource Manager template. - :vartype template: any + :ivar template: The Azure Resource Manager template. Required. + :vartype template: JSON """ _validation = { - 'path': {'required': True}, - 'template': {'required': True}, + "path": {"required": True}, + "template": {"required": True}, } _attribute_map = { - 'path': {'key': 'path', 'type': 'str'}, - 'template': {'key': 'template', 'type': 'object'}, + "path": {"key": "path", "type": "str"}, + "template": {"key": "template", "type": "object"}, } - def __init__( - self, - *, - path: str, - template: Any, - **kwargs - ): + def __init__(self, *, path: str, template: JSON, **kwargs): """ - :keyword path: Required. A filesystem safe relative path of the artifact. + :keyword path: A filesystem safe relative path of the artifact. Required. :paramtype path: str - :keyword template: Required. The Azure Resource Manager template. - :paramtype template: any + :keyword template: The Azure Resource Manager template. Required. + :paramtype template: JSON """ - super(LinkedTemplateArtifact, self).__init__(**kwargs) + super().__init__(**kwargs) self.path = path self.template = template -class SystemData(msrest.serialization.Model): +class SystemData(_serialization.Model): """Metadata pertaining to creation and last modification of the resource. :ivar created_by: The identity that created the resource. :vartype created_by: str - :ivar created_by_type: The type of identity that created the resource. Possible values include: - "User", "Application", "ManagedIdentity", "Key". + :ivar created_by_type: The type of identity that created the resource. Known values are: + "User", "Application", "ManagedIdentity", and "Key". :vartype created_by_type: str or ~azure.mgmt.resource.templatespecs.v2021_03_01_preview.models.CreatedByType :ivar created_at: The timestamp of resource creation (UTC). :vartype created_at: ~datetime.datetime :ivar last_modified_by: The identity that last modified the resource. :vartype last_modified_by: str - :ivar last_modified_by_type: The type of identity that last modified the resource. Possible - values include: "User", "Application", "ManagedIdentity", "Key". + :ivar last_modified_by_type: The type of identity that last modified the resource. Known values + are: "User", "Application", "ManagedIdentity", and "Key". :vartype last_modified_by_type: str or ~azure.mgmt.resource.templatespecs.v2021_03_01_preview.models.CreatedByType :ivar last_modified_at: The timestamp of resource last modification (UTC). @@ -200,44 +190,44 @@ class SystemData(msrest.serialization.Model): """ _attribute_map = { - 'created_by': {'key': 'createdBy', 'type': 'str'}, - 'created_by_type': {'key': 'createdByType', 'type': 'str'}, - 'created_at': {'key': 'createdAt', 'type': 'iso-8601'}, - 'last_modified_by': {'key': 'lastModifiedBy', 'type': 'str'}, - 'last_modified_by_type': {'key': 'lastModifiedByType', 'type': 'str'}, - 'last_modified_at': {'key': 'lastModifiedAt', 'type': 'iso-8601'}, + "created_by": {"key": "createdBy", "type": "str"}, + "created_by_type": {"key": "createdByType", "type": "str"}, + "created_at": {"key": "createdAt", "type": "iso-8601"}, + "last_modified_by": {"key": "lastModifiedBy", "type": "str"}, + "last_modified_by_type": {"key": "lastModifiedByType", "type": "str"}, + "last_modified_at": {"key": "lastModifiedAt", "type": "iso-8601"}, } def __init__( self, *, created_by: Optional[str] = None, - created_by_type: Optional[Union[str, "CreatedByType"]] = None, + created_by_type: Optional[Union[str, "_models.CreatedByType"]] = None, created_at: Optional[datetime.datetime] = None, last_modified_by: Optional[str] = None, - last_modified_by_type: Optional[Union[str, "CreatedByType"]] = None, + last_modified_by_type: Optional[Union[str, "_models.CreatedByType"]] = None, last_modified_at: Optional[datetime.datetime] = None, **kwargs ): """ :keyword created_by: The identity that created the resource. :paramtype created_by: str - :keyword created_by_type: The type of identity that created the resource. Possible values - include: "User", "Application", "ManagedIdentity", "Key". + :keyword created_by_type: The type of identity that created the resource. Known values are: + "User", "Application", "ManagedIdentity", and "Key". :paramtype created_by_type: str or ~azure.mgmt.resource.templatespecs.v2021_03_01_preview.models.CreatedByType :keyword created_at: The timestamp of resource creation (UTC). :paramtype created_at: ~datetime.datetime :keyword last_modified_by: The identity that last modified the resource. :paramtype last_modified_by: str - :keyword last_modified_by_type: The type of identity that last modified the resource. Possible - values include: "User", "Application", "ManagedIdentity", "Key". + :keyword last_modified_by_type: The type of identity that last modified the resource. Known + values are: "User", "Application", "ManagedIdentity", and "Key". :paramtype last_modified_by_type: str or ~azure.mgmt.resource.templatespecs.v2021_03_01_preview.models.CreatedByType :keyword last_modified_at: The timestamp of resource last modification (UTC). :paramtype last_modified_at: ~datetime.datetime """ - super(SystemData, self).__init__(**kwargs) + super().__init__(**kwargs) self.created_by = created_by self.created_by_type = created_by_type self.created_at = created_at @@ -262,10 +252,10 @@ class TemplateSpec(AzureResourceBase): :ivar system_data: Azure Resource Manager metadata containing createdBy and modifiedBy information. :vartype system_data: ~azure.mgmt.resource.templatespecs.v2021_03_01_preview.models.SystemData - :ivar location: Required. The location of the Template Spec. It cannot be changed after - Template Spec creation. It must be one of the supported Azure locations. + :ivar location: The location of the Template Spec. It cannot be changed after Template Spec + creation. It must be one of the supported Azure locations. Required. :vartype location: str - :ivar tags: A set of tags. Resource tags. + :ivar tags: Resource tags. :vartype tags: dict[str, str] :ivar description: Template Spec description. :vartype description: str @@ -273,7 +263,7 @@ class TemplateSpec(AzureResourceBase): :vartype display_name: str :ivar metadata: The Template Spec metadata. Metadata is an open-ended object and is typically a collection of key-value pairs. - :vartype metadata: any + :vartype metadata: JSON :ivar versions: High-level information about the versions within this Template Spec. The keys are the version names. Only populated if the $expand query parameter is set to 'versions'. :vartype versions: dict[str, @@ -281,27 +271,27 @@ class TemplateSpec(AzureResourceBase): """ _validation = { - 'id': {'readonly': True}, - 'name': {'readonly': True}, - 'type': {'readonly': True}, - 'system_data': {'readonly': True}, - 'location': {'required': True}, - 'description': {'max_length': 4096, 'min_length': 0}, - 'display_name': {'max_length': 64, 'min_length': 0}, - 'versions': {'readonly': True}, + "id": {"readonly": True}, + "name": {"readonly": True}, + "type": {"readonly": True}, + "system_data": {"readonly": True}, + "location": {"required": True}, + "description": {"max_length": 4096}, + "display_name": {"max_length": 64}, + "versions": {"readonly": True}, } _attribute_map = { - 'id': {'key': 'id', 'type': 'str'}, - 'name': {'key': 'name', 'type': 'str'}, - 'type': {'key': 'type', 'type': 'str'}, - 'system_data': {'key': 'systemData', 'type': 'SystemData'}, - 'location': {'key': 'location', 'type': 'str'}, - 'tags': {'key': 'tags', 'type': '{str}'}, - 'description': {'key': 'properties.description', 'type': 'str'}, - 'display_name': {'key': 'properties.displayName', 'type': 'str'}, - 'metadata': {'key': 'properties.metadata', 'type': 'object'}, - 'versions': {'key': 'properties.versions', 'type': '{TemplateSpecVersionInfo}'}, + "id": {"key": "id", "type": "str"}, + "name": {"key": "name", "type": "str"}, + "type": {"key": "type", "type": "str"}, + "system_data": {"key": "systemData", "type": "SystemData"}, + "location": {"key": "location", "type": "str"}, + "tags": {"key": "tags", "type": "{str}"}, + "description": {"key": "properties.description", "type": "str"}, + "display_name": {"key": "properties.displayName", "type": "str"}, + "metadata": {"key": "properties.metadata", "type": "object"}, + "versions": {"key": "properties.versions", "type": "{TemplateSpecVersionInfo}"}, } def __init__( @@ -311,14 +301,14 @@ def __init__( tags: Optional[Dict[str, str]] = None, description: Optional[str] = None, display_name: Optional[str] = None, - metadata: Optional[Any] = None, + metadata: Optional[JSON] = None, **kwargs ): """ - :keyword location: Required. The location of the Template Spec. It cannot be changed after - Template Spec creation. It must be one of the supported Azure locations. + :keyword location: The location of the Template Spec. It cannot be changed after Template Spec + creation. It must be one of the supported Azure locations. Required. :paramtype location: str - :keyword tags: A set of tags. Resource tags. + :keyword tags: Resource tags. :paramtype tags: dict[str, str] :keyword description: Template Spec description. :paramtype description: str @@ -326,9 +316,9 @@ def __init__( :paramtype display_name: str :keyword metadata: The Template Spec metadata. Metadata is an open-ended object and is typically a collection of key-value pairs. - :paramtype metadata: any + :paramtype metadata: JSON """ - super(TemplateSpec, self).__init__(**kwargs) + super().__init__(**kwargs) self.location = location self.tags = tags self.description = description @@ -337,7 +327,7 @@ def __init__( self.versions = None -class TemplateSpecsError(msrest.serialization.Model): +class TemplateSpecsError(_serialization.Model): """Template Specs error response. :ivar error: Common error response for all Azure Resource Manager APIs to return error details @@ -346,25 +336,20 @@ class TemplateSpecsError(msrest.serialization.Model): """ _attribute_map = { - 'error': {'key': 'error', 'type': 'ErrorResponse'}, + "error": {"key": "error", "type": "ErrorResponse"}, } - def __init__( - self, - *, - error: Optional["ErrorResponse"] = None, - **kwargs - ): + def __init__(self, *, error: Optional["_models.ErrorResponse"] = None, **kwargs): """ :keyword error: Common error response for all Azure Resource Manager APIs to return error details for failed operations. (This also follows the OData error response format.). :paramtype error: ~azure.mgmt.resource.templatespecs.v2021_03_01_preview.models.ErrorResponse """ - super(TemplateSpecsError, self).__init__(**kwargs) + super().__init__(**kwargs) self.error = error -class TemplateSpecsListResult(msrest.serialization.Model): +class TemplateSpecsListResult(_serialization.Model): """List of Template Specs. Variables are only populated by the server, and will be ignored when sending a request. @@ -377,26 +362,21 @@ class TemplateSpecsListResult(msrest.serialization.Model): """ _validation = { - 'next_link': {'readonly': True}, + "next_link": {"readonly": True}, } _attribute_map = { - 'value': {'key': 'value', 'type': '[TemplateSpec]'}, - 'next_link': {'key': 'nextLink', 'type': 'str'}, + "value": {"key": "value", "type": "[TemplateSpec]"}, + "next_link": {"key": "nextLink", "type": "str"}, } - def __init__( - self, - *, - value: Optional[List["TemplateSpec"]] = None, - **kwargs - ): + def __init__(self, *, value: Optional[List["_models.TemplateSpec"]] = None, **kwargs): """ :keyword value: An array of Template Specs. :paramtype value: list[~azure.mgmt.resource.templatespecs.v2021_03_01_preview.models.TemplateSpec] """ - super(TemplateSpecsListResult, self).__init__(**kwargs) + super().__init__(**kwargs) self.value = value self.next_link = None @@ -415,40 +395,35 @@ class TemplateSpecUpdateModel(AzureResourceBase): :ivar system_data: Azure Resource Manager metadata containing createdBy and modifiedBy information. :vartype system_data: ~azure.mgmt.resource.templatespecs.v2021_03_01_preview.models.SystemData - :ivar tags: A set of tags. Resource tags. + :ivar tags: Resource tags. :vartype tags: dict[str, str] """ _validation = { - 'id': {'readonly': True}, - 'name': {'readonly': True}, - 'type': {'readonly': True}, - 'system_data': {'readonly': True}, + "id": {"readonly": True}, + "name": {"readonly": True}, + "type": {"readonly": True}, + "system_data": {"readonly": True}, } _attribute_map = { - 'id': {'key': 'id', 'type': 'str'}, - 'name': {'key': 'name', 'type': 'str'}, - 'type': {'key': 'type', 'type': 'str'}, - 'system_data': {'key': 'systemData', 'type': 'SystemData'}, - 'tags': {'key': 'tags', 'type': '{str}'}, + "id": {"key": "id", "type": "str"}, + "name": {"key": "name", "type": "str"}, + "type": {"key": "type", "type": "str"}, + "system_data": {"key": "systemData", "type": "SystemData"}, + "tags": {"key": "tags", "type": "{str}"}, } - def __init__( - self, - *, - tags: Optional[Dict[str, str]] = None, - **kwargs - ): + def __init__(self, *, tags: Optional[Dict[str, str]] = None, **kwargs): """ - :keyword tags: A set of tags. Resource tags. + :keyword tags: Resource tags. :paramtype tags: dict[str, str] """ - super(TemplateSpecUpdateModel, self).__init__(**kwargs) + super().__init__(**kwargs) self.tags = tags -class TemplateSpecVersion(AzureResourceBase): +class TemplateSpecVersion(AzureResourceBase): # pylint: disable=too-many-instance-attributes """Template Spec Version object. Variables are only populated by the server, and will be ignored when sending a request. @@ -464,10 +439,10 @@ class TemplateSpecVersion(AzureResourceBase): :ivar system_data: Azure Resource Manager metadata containing createdBy and modifiedBy information. :vartype system_data: ~azure.mgmt.resource.templatespecs.v2021_03_01_preview.models.SystemData - :ivar location: Required. The location of the Template Spec Version. It must match the location - of the parent Template Spec. + :ivar location: The location of the Template Spec Version. It must match the location of the + parent Template Spec. Required. :vartype location: str - :ivar tags: A set of tags. Resource tags. + :ivar tags: Resource tags. :vartype tags: dict[str, str] :ivar description: Template Spec version description. :vartype description: str @@ -476,34 +451,34 @@ class TemplateSpecVersion(AzureResourceBase): list[~azure.mgmt.resource.templatespecs.v2021_03_01_preview.models.LinkedTemplateArtifact] :ivar metadata: The version metadata. Metadata is an open-ended object and is typically a collection of key-value pairs. - :vartype metadata: any + :vartype metadata: JSON :ivar main_template: The main Azure Resource Manager template content. - :vartype main_template: any + :vartype main_template: JSON :ivar ui_form_definition: The Azure Resource Manager template UI definition content. - :vartype ui_form_definition: any + :vartype ui_form_definition: JSON """ _validation = { - 'id': {'readonly': True}, - 'name': {'readonly': True}, - 'type': {'readonly': True}, - 'system_data': {'readonly': True}, - 'location': {'required': True}, - 'description': {'max_length': 4096, 'min_length': 0}, + "id": {"readonly": True}, + "name": {"readonly": True}, + "type": {"readonly": True}, + "system_data": {"readonly": True}, + "location": {"required": True}, + "description": {"max_length": 4096}, } _attribute_map = { - 'id': {'key': 'id', 'type': 'str'}, - 'name': {'key': 'name', 'type': 'str'}, - 'type': {'key': 'type', 'type': 'str'}, - 'system_data': {'key': 'systemData', 'type': 'SystemData'}, - 'location': {'key': 'location', 'type': 'str'}, - 'tags': {'key': 'tags', 'type': '{str}'}, - 'description': {'key': 'properties.description', 'type': 'str'}, - 'linked_templates': {'key': 'properties.linkedTemplates', 'type': '[LinkedTemplateArtifact]'}, - 'metadata': {'key': 'properties.metadata', 'type': 'object'}, - 'main_template': {'key': 'properties.mainTemplate', 'type': 'object'}, - 'ui_form_definition': {'key': 'properties.uiFormDefinition', 'type': 'object'}, + "id": {"key": "id", "type": "str"}, + "name": {"key": "name", "type": "str"}, + "type": {"key": "type", "type": "str"}, + "system_data": {"key": "systemData", "type": "SystemData"}, + "location": {"key": "location", "type": "str"}, + "tags": {"key": "tags", "type": "{str}"}, + "description": {"key": "properties.description", "type": "str"}, + "linked_templates": {"key": "properties.linkedTemplates", "type": "[LinkedTemplateArtifact]"}, + "metadata": {"key": "properties.metadata", "type": "object"}, + "main_template": {"key": "properties.mainTemplate", "type": "object"}, + "ui_form_definition": {"key": "properties.uiFormDefinition", "type": "object"}, } def __init__( @@ -512,17 +487,17 @@ def __init__( location: str, tags: Optional[Dict[str, str]] = None, description: Optional[str] = None, - linked_templates: Optional[List["LinkedTemplateArtifact"]] = None, - metadata: Optional[Any] = None, - main_template: Optional[Any] = None, - ui_form_definition: Optional[Any] = None, + linked_templates: Optional[List["_models.LinkedTemplateArtifact"]] = None, + metadata: Optional[JSON] = None, + main_template: Optional[JSON] = None, + ui_form_definition: Optional[JSON] = None, **kwargs ): """ - :keyword location: Required. The location of the Template Spec Version. It must match the - location of the parent Template Spec. + :keyword location: The location of the Template Spec Version. It must match the location of the + parent Template Spec. Required. :paramtype location: str - :keyword tags: A set of tags. Resource tags. + :keyword tags: Resource tags. :paramtype tags: dict[str, str] :keyword description: Template Spec version description. :paramtype description: str @@ -531,13 +506,13 @@ def __init__( list[~azure.mgmt.resource.templatespecs.v2021_03_01_preview.models.LinkedTemplateArtifact] :keyword metadata: The version metadata. Metadata is an open-ended object and is typically a collection of key-value pairs. - :paramtype metadata: any + :paramtype metadata: JSON :keyword main_template: The main Azure Resource Manager template content. - :paramtype main_template: any + :paramtype main_template: JSON :keyword ui_form_definition: The Azure Resource Manager template UI definition content. - :paramtype ui_form_definition: any + :paramtype ui_form_definition: JSON """ - super(TemplateSpecVersion, self).__init__(**kwargs) + super().__init__(**kwargs) self.location = location self.tags = tags self.description = description @@ -547,7 +522,7 @@ def __init__( self.ui_form_definition = ui_form_definition -class TemplateSpecVersionInfo(msrest.serialization.Model): +class TemplateSpecVersionInfo(_serialization.Model): """High-level information about a Template Spec version. Variables are only populated by the server, and will be ignored when sending a request. @@ -561,30 +536,26 @@ class TemplateSpecVersionInfo(msrest.serialization.Model): """ _validation = { - 'description': {'readonly': True}, - 'time_created': {'readonly': True}, - 'time_modified': {'readonly': True}, + "description": {"readonly": True}, + "time_created": {"readonly": True}, + "time_modified": {"readonly": True}, } _attribute_map = { - 'description': {'key': 'description', 'type': 'str'}, - 'time_created': {'key': 'timeCreated', 'type': 'iso-8601'}, - 'time_modified': {'key': 'timeModified', 'type': 'iso-8601'}, + "description": {"key": "description", "type": "str"}, + "time_created": {"key": "timeCreated", "type": "iso-8601"}, + "time_modified": {"key": "timeModified", "type": "iso-8601"}, } - def __init__( - self, - **kwargs - ): - """ - """ - super(TemplateSpecVersionInfo, self).__init__(**kwargs) + def __init__(self, **kwargs): + """ """ + super().__init__(**kwargs) self.description = None self.time_created = None self.time_modified = None -class TemplateSpecVersionsListResult(msrest.serialization.Model): +class TemplateSpecVersionsListResult(_serialization.Model): """List of Template Specs versions. Variables are only populated by the server, and will be ignored when sending a request. @@ -597,26 +568,21 @@ class TemplateSpecVersionsListResult(msrest.serialization.Model): """ _validation = { - 'next_link': {'readonly': True}, + "next_link": {"readonly": True}, } _attribute_map = { - 'value': {'key': 'value', 'type': '[TemplateSpecVersion]'}, - 'next_link': {'key': 'nextLink', 'type': 'str'}, + "value": {"key": "value", "type": "[TemplateSpecVersion]"}, + "next_link": {"key": "nextLink", "type": "str"}, } - def __init__( - self, - *, - value: Optional[List["TemplateSpecVersion"]] = None, - **kwargs - ): + def __init__(self, *, value: Optional[List["_models.TemplateSpecVersion"]] = None, **kwargs): """ :keyword value: An array of Template Spec versions. :paramtype value: list[~azure.mgmt.resource.templatespecs.v2021_03_01_preview.models.TemplateSpecVersion] """ - super(TemplateSpecVersionsListResult, self).__init__(**kwargs) + super().__init__(**kwargs) self.value = value self.next_link = None @@ -635,34 +601,29 @@ class TemplateSpecVersionUpdateModel(AzureResourceBase): :ivar system_data: Azure Resource Manager metadata containing createdBy and modifiedBy information. :vartype system_data: ~azure.mgmt.resource.templatespecs.v2021_03_01_preview.models.SystemData - :ivar tags: A set of tags. Resource tags. + :ivar tags: Resource tags. :vartype tags: dict[str, str] """ _validation = { - 'id': {'readonly': True}, - 'name': {'readonly': True}, - 'type': {'readonly': True}, - 'system_data': {'readonly': True}, + "id": {"readonly": True}, + "name": {"readonly": True}, + "type": {"readonly": True}, + "system_data": {"readonly": True}, } _attribute_map = { - 'id': {'key': 'id', 'type': 'str'}, - 'name': {'key': 'name', 'type': 'str'}, - 'type': {'key': 'type', 'type': 'str'}, - 'system_data': {'key': 'systemData', 'type': 'SystemData'}, - 'tags': {'key': 'tags', 'type': '{str}'}, + "id": {"key": "id", "type": "str"}, + "name": {"key": "name", "type": "str"}, + "type": {"key": "type", "type": "str"}, + "system_data": {"key": "systemData", "type": "SystemData"}, + "tags": {"key": "tags", "type": "{str}"}, } - def __init__( - self, - *, - tags: Optional[Dict[str, str]] = None, - **kwargs - ): + def __init__(self, *, tags: Optional[Dict[str, str]] = None, **kwargs): """ - :keyword tags: A set of tags. Resource tags. + :keyword tags: Resource tags. :paramtype tags: dict[str, str] """ - super(TemplateSpecVersionUpdateModel, self).__init__(**kwargs) + super().__init__(**kwargs) self.tags = tags diff --git a/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/templatespecs/v2021_03_01_preview/models/_patch.py b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/templatespecs/v2021_03_01_preview/models/_patch.py new file mode 100644 index 0000000000000..f7dd32510333d --- /dev/null +++ b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/templatespecs/v2021_03_01_preview/models/_patch.py @@ -0,0 +1,20 @@ +# ------------------------------------ +# Copyright (c) Microsoft Corporation. +# Licensed under the MIT License. +# ------------------------------------ +"""Customize generated code here. + +Follow our quickstart for examples: https://aka.ms/azsdk/python/dpcodegen/python/customize +""" +from typing import List + +__all__: List[str] = [] # Add all objects you want publicly available to users at this package level + + +def patch_sdk(): + """Do not remove from this file. + + `patch_sdk` is a last resort escape hatch that allows you to do customizations + you can't accomplish using the techniques described in + https://aka.ms/azsdk/python/dpcodegen/python/customize + """ diff --git a/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/templatespecs/v2021_03_01_preview/models/_template_specs_client_enums.py b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/templatespecs/v2021_03_01_preview/models/_template_specs_client_enums.py index ef8823668c7ee..ec0f6b2bc39a4 100644 --- a/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/templatespecs/v2021_03_01_preview/models/_template_specs_client_enums.py +++ b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/templatespecs/v2021_03_01_preview/models/_template_specs_client_enums.py @@ -7,20 +7,20 @@ # -------------------------------------------------------------------------- from enum import Enum -from six import with_metaclass from azure.core import CaseInsensitiveEnumMeta -class CreatedByType(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): - """The type of identity that created the resource. - """ +class CreatedByType(str, Enum, metaclass=CaseInsensitiveEnumMeta): + """The type of identity that created the resource.""" USER = "User" APPLICATION = "Application" MANAGED_IDENTITY = "ManagedIdentity" KEY = "Key" -class TemplateSpecExpandKind(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): + +class TemplateSpecExpandKind(str, Enum, metaclass=CaseInsensitiveEnumMeta): + """TemplateSpecExpandKind.""" #: Includes version information with the Template Spec. VERSIONS = "versions" diff --git a/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/templatespecs/v2021_03_01_preview/operations/__init__.py b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/templatespecs/v2021_03_01_preview/operations/__init__.py index cb4936f69ad57..1f6058ba55acd 100644 --- a/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/templatespecs/v2021_03_01_preview/operations/__init__.py +++ b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/templatespecs/v2021_03_01_preview/operations/__init__.py @@ -9,7 +9,13 @@ from ._operations import TemplateSpecsOperations from ._operations import TemplateSpecVersionsOperations +from ._patch import __all__ as _patch_all +from ._patch import * # type: ignore # pylint: disable=unused-wildcard-import +from ._patch import patch_sdk as _patch_sdk + __all__ = [ - 'TemplateSpecsOperations', - 'TemplateSpecVersionsOperations', + "TemplateSpecsOperations", + "TemplateSpecVersionsOperations", ] +__all__.extend([p for p in _patch_all if p not in __all__]) +_patch_sdk() diff --git a/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/templatespecs/v2021_03_01_preview/operations/_operations.py b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/templatespecs/v2021_03_01_preview/operations/_operations.py index 14a7fd8e02adb..79aab8e0caaf8 100644 --- a/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/templatespecs/v2021_03_01_preview/operations/_operations.py +++ b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/templatespecs/v2021_03_01_preview/operations/_operations.py @@ -6,539 +6,612 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -from typing import Any, Callable, Dict, Iterable, Optional, TypeVar, Union - -from msrest import Serializer - -from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error +from typing import Any, Callable, Dict, IO, Iterable, Optional, TypeVar, Union, overload +from urllib.parse import parse_qs, urljoin, urlparse + +from azure.core.exceptions import ( + ClientAuthenticationError, + HttpResponseError, + ResourceExistsError, + ResourceNotFoundError, + ResourceNotModifiedError, + map_error, +) from azure.core.paging import ItemPaged from azure.core.pipeline import PipelineResponse from azure.core.pipeline.transport import HttpResponse from azure.core.rest import HttpRequest from azure.core.tracing.decorator import distributed_trace +from azure.core.utils import case_insensitive_dict from azure.mgmt.core.exceptions import ARMErrorFormat from .. import models as _models +from ..._serialization import Serializer from .._vendor import _convert_request, _format_url_section -T = TypeVar('T') -JSONType = Any + +T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] _SERIALIZER = Serializer() _SERIALIZER.client_side_validation = False + def build_template_specs_create_or_update_request( - subscription_id: str, - resource_group_name: str, - template_spec_name: str, - *, - json: JSONType = None, - content: Any = None, - **kwargs: Any + resource_group_name: str, template_spec_name: str, subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2021-03-01-preview") # type: str - content_type = kwargs.pop('content_type', None) # type: Optional[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-03-01-preview")) # type: str + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + accept = _headers.pop("Accept", "application/json") - accept = "application/json" # Construct URL - _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Resources/templateSpecs/{templateSpecName}") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Resources/templateSpecs/{templateSpecName}", + ) # pylint: disable=line-too-long path_format_arguments = { - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._\(\)]+$'), - "templateSpecName": _SERIALIZER.url("template_spec_name", template_spec_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._\(\)]+$'), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url( + "resource_group_name", resource_group_name, "str", max_length=90, min_length=1, pattern=r"^[-\w\._\(\)]+$" + ), + "templateSpecName": _SERIALIZER.url( + "template_spec_name", template_spec_name, "str", max_length=90, min_length=1, pattern=r"^[-\w\._\(\)]+$" + ), } _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] if content_type is not None: - _header_parameters['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') - _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers["Content-Type"] = _SERIALIZER.header("content_type", content_type, "str") + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - return HttpRequest( - method="PUT", - url=_url, - params=_query_parameters, - headers=_header_parameters, - json=json, - content=content, - **kwargs - ) + return HttpRequest(method="PUT", url=_url, params=_params, headers=_headers, **kwargs) def build_template_specs_update_request( - subscription_id: str, - resource_group_name: str, - template_spec_name: str, - *, - json: JSONType = None, - content: Any = None, - **kwargs: Any + resource_group_name: str, template_spec_name: str, subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2021-03-01-preview") # type: str - content_type = kwargs.pop('content_type', None) # type: Optional[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-03-01-preview")) # type: str + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + accept = _headers.pop("Accept", "application/json") - accept = "application/json" # Construct URL - _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Resources/templateSpecs/{templateSpecName}") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Resources/templateSpecs/{templateSpecName}", + ) # pylint: disable=line-too-long path_format_arguments = { - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._\(\)]+$'), - "templateSpecName": _SERIALIZER.url("template_spec_name", template_spec_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._\(\)]+$'), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url( + "resource_group_name", resource_group_name, "str", max_length=90, min_length=1, pattern=r"^[-\w\._\(\)]+$" + ), + "templateSpecName": _SERIALIZER.url( + "template_spec_name", template_spec_name, "str", max_length=90, min_length=1, pattern=r"^[-\w\._\(\)]+$" + ), } _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] if content_type is not None: - _header_parameters['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') - _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers["Content-Type"] = _SERIALIZER.header("content_type", content_type, "str") + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - return HttpRequest( - method="PATCH", - url=_url, - params=_query_parameters, - headers=_header_parameters, - json=json, - content=content, - **kwargs - ) + return HttpRequest(method="PATCH", url=_url, params=_params, headers=_headers, **kwargs) def build_template_specs_get_request( - subscription_id: str, resource_group_name: str, template_spec_name: str, + subscription_id: str, *, expand: Optional[Union[str, "_models.TemplateSpecExpandKind"]] = None, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2021-03-01-preview") # type: 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-03-01-preview")) # type: str + accept = _headers.pop("Accept", "application/json") - accept = "application/json" # Construct URL - _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Resources/templateSpecs/{templateSpecName}") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Resources/templateSpecs/{templateSpecName}", + ) # pylint: disable=line-too-long path_format_arguments = { - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._\(\)]+$'), - "templateSpecName": _SERIALIZER.url("template_spec_name", template_spec_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._\(\)]+$'), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url( + "resource_group_name", resource_group_name, "str", max_length=90, min_length=1, pattern=r"^[-\w\._\(\)]+$" + ), + "templateSpecName": _SERIALIZER.url( + "template_spec_name", template_spec_name, "str", max_length=90, min_length=1, pattern=r"^[-\w\._\(\)]+$" + ), } _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] if expand is not None: - _query_parameters['$expand'] = _SERIALIZER.query("expand", expand, 'str') - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["$expand"] = _SERIALIZER.query("expand", expand, "str") + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - return HttpRequest( - method="GET", - url=_url, - params=_query_parameters, - headers=_header_parameters, - **kwargs - ) + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) def build_template_specs_delete_request( - subscription_id: str, - resource_group_name: str, - template_spec_name: str, - **kwargs: Any + resource_group_name: str, template_spec_name: str, subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2021-03-01-preview") # type: 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-03-01-preview")) # type: str + accept = _headers.pop("Accept", "application/json") - accept = "application/json" # Construct URL - _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Resources/templateSpecs/{templateSpecName}") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Resources/templateSpecs/{templateSpecName}", + ) # pylint: disable=line-too-long path_format_arguments = { - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._\(\)]+$'), - "templateSpecName": _SERIALIZER.url("template_spec_name", template_spec_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._\(\)]+$'), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url( + "resource_group_name", resource_group_name, "str", max_length=90, min_length=1, pattern=r"^[-\w\._\(\)]+$" + ), + "templateSpecName": _SERIALIZER.url( + "template_spec_name", template_spec_name, "str", max_length=90, min_length=1, pattern=r"^[-\w\._\(\)]+$" + ), } _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - return HttpRequest( - method="DELETE", - url=_url, - params=_query_parameters, - headers=_header_parameters, - **kwargs - ) + return HttpRequest(method="DELETE", url=_url, params=_params, headers=_headers, **kwargs) def build_template_specs_list_by_subscription_request( - subscription_id: str, - *, - expand: Optional[Union[str, "_models.TemplateSpecExpandKind"]] = None, - **kwargs: Any + subscription_id: str, *, expand: Optional[Union[str, "_models.TemplateSpecExpandKind"]] = None, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2021-03-01-preview") # type: 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-03-01-preview")) # type: str + accept = _headers.pop("Accept", "application/json") - accept = "application/json" # Construct URL _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/providers/Microsoft.Resources/templateSpecs/") path_format_arguments = { - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), } _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] if expand is not None: - _query_parameters['$expand'] = _SERIALIZER.query("expand", expand, 'str') - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["$expand"] = _SERIALIZER.query("expand", expand, "str") + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - return HttpRequest( - method="GET", - url=_url, - params=_query_parameters, - headers=_header_parameters, - **kwargs - ) + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) def build_template_specs_list_by_resource_group_request( - subscription_id: str, resource_group_name: str, + subscription_id: str, *, expand: Optional[Union[str, "_models.TemplateSpecExpandKind"]] = None, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2021-03-01-preview") # type: 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-03-01-preview")) # type: str + accept = _headers.pop("Accept", "application/json") - accept = "application/json" # Construct URL - _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Resources/templateSpecs/") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Resources/templateSpecs/", + ) # pylint: disable=line-too-long path_format_arguments = { - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._\(\)]+$'), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url( + "resource_group_name", resource_group_name, "str", max_length=90, min_length=1, pattern=r"^[-\w\._\(\)]+$" + ), } _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] if expand is not None: - _query_parameters['$expand'] = _SERIALIZER.query("expand", expand, 'str') - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["$expand"] = _SERIALIZER.query("expand", expand, "str") + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - return HttpRequest( - method="GET", - url=_url, - params=_query_parameters, - headers=_header_parameters, - **kwargs - ) + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) def build_template_spec_versions_create_or_update_request( - subscription_id: str, - resource_group_name: str, - template_spec_name: str, - template_spec_version: str, - *, - json: JSONType = None, - content: Any = None, - **kwargs: Any + resource_group_name: str, template_spec_name: str, template_spec_version: str, subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2021-03-01-preview") # type: str - content_type = kwargs.pop('content_type', None) # type: Optional[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-03-01-preview")) # type: str + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + accept = _headers.pop("Accept", "application/json") - accept = "application/json" # Construct URL - _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Resources/templateSpecs/{templateSpecName}/versions/{templateSpecVersion}") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Resources/templateSpecs/{templateSpecName}/versions/{templateSpecVersion}", + ) # pylint: disable=line-too-long path_format_arguments = { - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._\(\)]+$'), - "templateSpecName": _SERIALIZER.url("template_spec_name", template_spec_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._\(\)]+$'), - "templateSpecVersion": _SERIALIZER.url("template_spec_version", template_spec_version, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._\(\)]+$'), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url( + "resource_group_name", resource_group_name, "str", max_length=90, min_length=1, pattern=r"^[-\w\._\(\)]+$" + ), + "templateSpecName": _SERIALIZER.url( + "template_spec_name", template_spec_name, "str", max_length=90, min_length=1, pattern=r"^[-\w\._\(\)]+$" + ), + "templateSpecVersion": _SERIALIZER.url( + "template_spec_version", + template_spec_version, + "str", + max_length=90, + min_length=1, + pattern=r"^[-\w\._\(\)]+$", + ), } _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] if content_type is not None: - _header_parameters['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') - _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers["Content-Type"] = _SERIALIZER.header("content_type", content_type, "str") + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - return HttpRequest( - method="PUT", - url=_url, - params=_query_parameters, - headers=_header_parameters, - json=json, - content=content, - **kwargs - ) + return HttpRequest(method="PUT", url=_url, params=_params, headers=_headers, **kwargs) def build_template_spec_versions_update_request( - subscription_id: str, - resource_group_name: str, - template_spec_name: str, - template_spec_version: str, - *, - json: JSONType = None, - content: Any = None, - **kwargs: Any + resource_group_name: str, template_spec_name: str, template_spec_version: str, subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2021-03-01-preview") # type: str - content_type = kwargs.pop('content_type', None) # type: Optional[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-03-01-preview")) # type: str + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + accept = _headers.pop("Accept", "application/json") - accept = "application/json" # Construct URL - _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Resources/templateSpecs/{templateSpecName}/versions/{templateSpecVersion}") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Resources/templateSpecs/{templateSpecName}/versions/{templateSpecVersion}", + ) # pylint: disable=line-too-long path_format_arguments = { - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._\(\)]+$'), - "templateSpecName": _SERIALIZER.url("template_spec_name", template_spec_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._\(\)]+$'), - "templateSpecVersion": _SERIALIZER.url("template_spec_version", template_spec_version, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._\(\)]+$'), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url( + "resource_group_name", resource_group_name, "str", max_length=90, min_length=1, pattern=r"^[-\w\._\(\)]+$" + ), + "templateSpecName": _SERIALIZER.url( + "template_spec_name", template_spec_name, "str", max_length=90, min_length=1, pattern=r"^[-\w\._\(\)]+$" + ), + "templateSpecVersion": _SERIALIZER.url( + "template_spec_version", + template_spec_version, + "str", + max_length=90, + min_length=1, + pattern=r"^[-\w\._\(\)]+$", + ), } _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] if content_type is not None: - _header_parameters['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') - _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers["Content-Type"] = _SERIALIZER.header("content_type", content_type, "str") + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - return HttpRequest( - method="PATCH", - url=_url, - params=_query_parameters, - headers=_header_parameters, - json=json, - content=content, - **kwargs - ) + return HttpRequest(method="PATCH", url=_url, params=_params, headers=_headers, **kwargs) def build_template_spec_versions_get_request( - subscription_id: str, - resource_group_name: str, - template_spec_name: str, - template_spec_version: str, - **kwargs: Any + resource_group_name: str, template_spec_name: str, template_spec_version: str, subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2021-03-01-preview") # type: 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-03-01-preview")) # type: str + accept = _headers.pop("Accept", "application/json") - accept = "application/json" # Construct URL - _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Resources/templateSpecs/{templateSpecName}/versions/{templateSpecVersion}") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Resources/templateSpecs/{templateSpecName}/versions/{templateSpecVersion}", + ) # pylint: disable=line-too-long path_format_arguments = { - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._\(\)]+$'), - "templateSpecName": _SERIALIZER.url("template_spec_name", template_spec_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._\(\)]+$'), - "templateSpecVersion": _SERIALIZER.url("template_spec_version", template_spec_version, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._\(\)]+$'), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url( + "resource_group_name", resource_group_name, "str", max_length=90, min_length=1, pattern=r"^[-\w\._\(\)]+$" + ), + "templateSpecName": _SERIALIZER.url( + "template_spec_name", template_spec_name, "str", max_length=90, min_length=1, pattern=r"^[-\w\._\(\)]+$" + ), + "templateSpecVersion": _SERIALIZER.url( + "template_spec_version", + template_spec_version, + "str", + max_length=90, + min_length=1, + pattern=r"^[-\w\._\(\)]+$", + ), } _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - return HttpRequest( - method="GET", - url=_url, - params=_query_parameters, - headers=_header_parameters, - **kwargs - ) + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) def build_template_spec_versions_delete_request( - subscription_id: str, - resource_group_name: str, - template_spec_name: str, - template_spec_version: str, - **kwargs: Any + resource_group_name: str, template_spec_name: str, template_spec_version: str, subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2021-03-01-preview") # type: 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-03-01-preview")) # type: str + accept = _headers.pop("Accept", "application/json") - accept = "application/json" # Construct URL - _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Resources/templateSpecs/{templateSpecName}/versions/{templateSpecVersion}") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Resources/templateSpecs/{templateSpecName}/versions/{templateSpecVersion}", + ) # pylint: disable=line-too-long path_format_arguments = { - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._\(\)]+$'), - "templateSpecName": _SERIALIZER.url("template_spec_name", template_spec_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._\(\)]+$'), - "templateSpecVersion": _SERIALIZER.url("template_spec_version", template_spec_version, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._\(\)]+$'), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url( + "resource_group_name", resource_group_name, "str", max_length=90, min_length=1, pattern=r"^[-\w\._\(\)]+$" + ), + "templateSpecName": _SERIALIZER.url( + "template_spec_name", template_spec_name, "str", max_length=90, min_length=1, pattern=r"^[-\w\._\(\)]+$" + ), + "templateSpecVersion": _SERIALIZER.url( + "template_spec_version", + template_spec_version, + "str", + max_length=90, + min_length=1, + pattern=r"^[-\w\._\(\)]+$", + ), } _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - return HttpRequest( - method="DELETE", - url=_url, - params=_query_parameters, - headers=_header_parameters, - **kwargs - ) + return HttpRequest(method="DELETE", url=_url, params=_params, headers=_headers, **kwargs) def build_template_spec_versions_list_request( - subscription_id: str, - resource_group_name: str, - template_spec_name: str, - **kwargs: Any + resource_group_name: str, template_spec_name: str, subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2021-03-01-preview") # type: 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-03-01-preview")) # type: str + accept = _headers.pop("Accept", "application/json") - accept = "application/json" # Construct URL - _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Resources/templateSpecs/{templateSpecName}/versions") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Resources/templateSpecs/{templateSpecName}/versions", + ) # pylint: disable=line-too-long path_format_arguments = { - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._\(\)]+$'), - "templateSpecName": _SERIALIZER.url("template_spec_name", template_spec_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._\(\)]+$'), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url( + "resource_group_name", resource_group_name, "str", max_length=90, min_length=1, pattern=r"^[-\w\._\(\)]+$" + ), + "templateSpecName": _SERIALIZER.url( + "template_spec_name", template_spec_name, "str", max_length=90, min_length=1, pattern=r"^[-\w\._\(\)]+$" + ), } _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') - - return HttpRequest( - method="GET", - url=_url, - params=_query_parameters, - headers=_header_parameters, - **kwargs - ) - -class TemplateSpecsOperations(object): - """TemplateSpecsOperations operations. - - You should not instantiate this class directly. Instead, you should create a Client instance that - instantiates it for you and attaches it as an attribute. - - :ivar models: Alias to model classes used in this operation group. - :type models: ~azure.mgmt.resource.templatespecs.v2021_03_01_preview.models - :param client: Client for service requests. - :param config: Configuration of service client. - :param serializer: An object model serializer. - :param deserializer: An object model deserializer. + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) + + +class TemplateSpecsOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. + + Instead, you should access the following operations through + :class:`~azure.mgmt.resource.templatespecs.v2021_03_01_preview.TemplateSpecsClient`'s + :attr:`template_specs` attribute. """ models = _models - def __init__(self, client, config, serializer, deserializer): - self._client = client - self._serialize = serializer - self._deserialize = deserializer - self._config = config + def __init__(self, *args, **kwargs): + input_args = list(args) + self._client = input_args.pop(0) if input_args else kwargs.pop("client") + self._config = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") + + @overload + def create_or_update( + self, + resource_group_name: str, + template_spec_name: str, + template_spec: _models.TemplateSpec, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.TemplateSpec: + """Creates or updates a Template Spec. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param template_spec_name: Name of the Template Spec. Required. + :type template_spec_name: str + :param template_spec: Template Spec supplied to the operation. Required. + :type template_spec: ~azure.mgmt.resource.templatespecs.v2021_03_01_preview.models.TemplateSpec + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: TemplateSpec or the result of cls(response) + :rtype: ~azure.mgmt.resource.templatespecs.v2021_03_01_preview.models.TemplateSpec + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + def create_or_update( + self, + resource_group_name: str, + template_spec_name: str, + template_spec: IO, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.TemplateSpec: + """Creates or updates a Template Spec. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param template_spec_name: Name of the Template Spec. Required. + :type template_spec_name: str + :param template_spec: Template Spec supplied to the operation. Required. + :type template_spec: IO + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: TemplateSpec or the result of cls(response) + :rtype: ~azure.mgmt.resource.templatespecs.v2021_03_01_preview.models.TemplateSpec + :raises ~azure.core.exceptions.HttpResponseError: + """ @distributed_trace def create_or_update( self, resource_group_name: str, template_spec_name: str, - template_spec: "_models.TemplateSpec", + template_spec: Union[_models.TemplateSpec, IO], **kwargs: Any - ) -> "_models.TemplateSpec": + ) -> _models.TemplateSpec: """Creates or updates a Template Spec. :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. :type resource_group_name: str - :param template_spec_name: Name of the Template Spec. + :param template_spec_name: Name of the Template Spec. Required. :type template_spec_name: str - :param template_spec: Template Spec supplied to the operation. + :param template_spec: Template Spec supplied to the operation. Is either a model type or a IO + type. Required. :type template_spec: ~azure.mgmt.resource.templatespecs.v2021_03_01_preview.models.TemplateSpec + or IO + :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. + Default value is None. + :paramtype content_type: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: TemplateSpec, or the result of cls(response) + :return: TemplateSpec or the result of cls(response) :rtype: ~azure.mgmt.resource.templatespecs.v2021_03_01_preview.models.TemplateSpec - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.TemplateSpec"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) - api_version = kwargs.pop('api_version', "2021-03-01-preview") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - _json = self._serialize.body(template_spec, 'TemplateSpec') + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-03-01-preview")) # type: str + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.TemplateSpec] + + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(template_spec, (IO, bytes)): + _content = template_spec + else: + _json = self._serialize.body(template_spec, "TemplateSpec") request = build_template_specs_create_or_update_request( - subscription_id=self._config.subscription_id, resource_group_name=resource_group_name, template_spec_name=template_spec_name, + subscription_id=self._config.subscription_id, api_version=api_version, content_type=content_type, json=_json, - template_url=self.create_or_update.metadata['url'], + content=_content, + template_url=self.create_or_update.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200, 201]: @@ -547,73 +620,149 @@ def create_or_update( raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) if response.status_code == 200: - deserialized = self._deserialize('TemplateSpec', pipeline_response) + deserialized = self._deserialize("TemplateSpec", pipeline_response) if response.status_code == 201: - deserialized = self._deserialize('TemplateSpec', pipeline_response) + deserialized = self._deserialize("TemplateSpec", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - create_or_update.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Resources/templateSpecs/{templateSpecName}"} # type: ignore + create_or_update.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Resources/templateSpecs/{templateSpecName}"} # type: ignore - - @distributed_trace + @overload def update( self, resource_group_name: str, template_spec_name: str, - template_spec: Optional["_models.TemplateSpecUpdateModel"] = None, + template_spec: Optional[_models.TemplateSpecUpdateModel] = None, + *, + content_type: str = "application/json", **kwargs: Any - ) -> "_models.TemplateSpec": + ) -> _models.TemplateSpec: """Updates Template Spec tags with specified values. :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. :type resource_group_name: str - :param template_spec_name: Name of the Template Spec. + :param template_spec_name: Name of the Template Spec. Required. :type template_spec_name: str :param template_spec: Template Spec resource with the tags to be updated. Default value is None. :type template_spec: ~azure.mgmt.resource.templatespecs.v2021_03_01_preview.models.TemplateSpecUpdateModel + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: TemplateSpec, or the result of cls(response) + :return: TemplateSpec or the result of cls(response) :rtype: ~azure.mgmt.resource.templatespecs.v2021_03_01_preview.models.TemplateSpec - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + def update( + self, + resource_group_name: str, + template_spec_name: str, + template_spec: Optional[IO] = None, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.TemplateSpec: + """Updates Template Spec tags with specified values. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param template_spec_name: Name of the Template Spec. Required. + :type template_spec_name: str + :param template_spec: Template Spec resource with the tags to be updated. Default value is + None. + :type template_spec: IO + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: TemplateSpec or the result of cls(response) + :rtype: ~azure.mgmt.resource.templatespecs.v2021_03_01_preview.models.TemplateSpec + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace + def update( + self, + resource_group_name: str, + template_spec_name: str, + template_spec: Optional[Union[_models.TemplateSpecUpdateModel, IO]] = None, + **kwargs: Any + ) -> _models.TemplateSpec: + """Updates Template Spec tags with specified values. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param template_spec_name: Name of the Template Spec. Required. + :type template_spec_name: str + :param template_spec: Template Spec resource with the tags to be updated. Is either a model + type or a IO type. Default value is None. + :type template_spec: + ~azure.mgmt.resource.templatespecs.v2021_03_01_preview.models.TemplateSpecUpdateModel or IO + :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. + Default value is None. + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: TemplateSpec or the result of cls(response) + :rtype: ~azure.mgmt.resource.templatespecs.v2021_03_01_preview.models.TemplateSpec + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.TemplateSpec"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', "2021-03-01-preview") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-03-01-preview")) # type: str + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.TemplateSpec] - if template_spec is not None: - _json = self._serialize.body(template_spec, 'TemplateSpecUpdateModel') + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(template_spec, (IO, bytes)): + _content = template_spec else: - _json = None + if template_spec is not None: + _json = self._serialize.body(template_spec, "TemplateSpecUpdateModel") + else: + _json = None request = build_template_specs_update_request( - subscription_id=self._config.subscription_id, resource_group_name=resource_group_name, template_spec_name=template_spec_name, + subscription_id=self._config.subscription_id, api_version=api_version, content_type=content_type, json=_json, - template_url=self.update.metadata['url'], + content=_content, + template_url=self.update.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200]: @@ -621,15 +770,14 @@ def update( error = self._deserialize.failsafe_deserialize(_models.TemplateSpecsError, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - deserialized = self._deserialize('TemplateSpec', pipeline_response) + deserialized = self._deserialize("TemplateSpec", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - update.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Resources/templateSpecs/{templateSpecName}"} # type: ignore - + update.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Resources/templateSpecs/{templateSpecName}"} # type: ignore @distributed_trace def get( @@ -638,47 +786,54 @@ def get( template_spec_name: str, expand: Optional[Union[str, "_models.TemplateSpecExpandKind"]] = None, **kwargs: Any - ) -> "_models.TemplateSpec": + ) -> _models.TemplateSpec: """Gets a Template Spec with a given name. :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. :type resource_group_name: str - :param template_spec_name: Name of the Template Spec. + :param template_spec_name: Name of the Template Spec. Required. :type template_spec_name: str :param expand: Allows for expansion of additional Template Spec details in the response. - Optional. Default value is None. + Optional. "versions" Default value is None. :type expand: str or ~azure.mgmt.resource.templatespecs.v2021_03_01_preview.models.TemplateSpecExpandKind :keyword callable cls: A custom type or function that will be passed the direct response - :return: TemplateSpec, or the result of cls(response) + :return: TemplateSpec or the result of cls(response) :rtype: ~azure.mgmt.resource.templatespecs.v2021_03_01_preview.models.TemplateSpec - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.TemplateSpec"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) - api_version = kwargs.pop('api_version', "2021-03-01-preview") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-03-01-preview")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[_models.TemplateSpec] - request = build_template_specs_get_request( - subscription_id=self._config.subscription_id, resource_group_name=resource_group_name, template_spec_name=template_spec_name, - api_version=api_version, + subscription_id=self._config.subscription_id, expand=expand, - template_url=self.get.metadata['url'], + api_version=api_version, + template_url=self.get.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200]: @@ -686,59 +841,62 @@ def get( error = self._deserialize.failsafe_deserialize(_models.TemplateSpecsError, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - deserialized = self._deserialize('TemplateSpec', pipeline_response) + deserialized = self._deserialize("TemplateSpec", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - get.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Resources/templateSpecs/{templateSpecName}"} # type: ignore - + get.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Resources/templateSpecs/{templateSpecName}"} # type: ignore @distributed_trace def delete( # pylint: disable=inconsistent-return-statements - self, - resource_group_name: str, - template_spec_name: str, - **kwargs: Any + self, resource_group_name: str, template_spec_name: str, **kwargs: Any ) -> None: """Deletes a Template Spec by name. When operation completes, status code 200 returned without content. :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. :type resource_group_name: str - :param template_spec_name: Name of the Template Spec. + :param template_spec_name: Name of the Template Spec. Required. :type template_spec_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: None, or the result of cls(response) + :return: None or the result of cls(response) :rtype: None - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType[None] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) - api_version = kwargs.pop('api_version', "2021-03-01-preview") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-03-01-preview")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[None] - request = build_template_specs_delete_request( - subscription_id=self._config.subscription_id, resource_group_name=resource_group_name, template_spec_name=template_spec_name, + subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.delete.metadata['url'], + template_url=self.delete.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200, 204]: @@ -749,55 +907,60 @@ def delete( # pylint: disable=inconsistent-return-statements if cls: return cls(pipeline_response, None, {}) - delete.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Resources/templateSpecs/{templateSpecName}"} # type: ignore - + delete.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Resources/templateSpecs/{templateSpecName}"} # type: ignore @distributed_trace def list_by_subscription( - self, - expand: Optional[Union[str, "_models.TemplateSpecExpandKind"]] = None, - **kwargs: Any - ) -> Iterable["_models.TemplateSpecsListResult"]: + self, expand: Optional[Union[str, "_models.TemplateSpecExpandKind"]] = None, **kwargs: Any + ) -> Iterable["_models.TemplateSpec"]: """Lists all the Template Specs within the specified subscriptions. :param expand: Allows for expansion of additional Template Spec details in the response. - Optional. Default value is None. + Optional. "versions" Default value is None. :type expand: str or ~azure.mgmt.resource.templatespecs.v2021_03_01_preview.models.TemplateSpecExpandKind :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either TemplateSpecsListResult or the result of - cls(response) + :return: An iterator like instance of either TemplateSpec or the result of cls(response) :rtype: - ~azure.core.paging.ItemPaged[~azure.mgmt.resource.templatespecs.v2021_03_01_preview.models.TemplateSpecsListResult] - :raises: ~azure.core.exceptions.HttpResponseError + ~azure.core.paging.ItemPaged[~azure.mgmt.resource.templatespecs.v2021_03_01_preview.models.TemplateSpec] + :raises ~azure.core.exceptions.HttpResponseError: """ - api_version = kwargs.pop('api_version', "2021-03-01-preview") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-03-01-preview")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[_models.TemplateSpecsListResult] - cls = kwargs.pop('cls', None) # type: ClsType["_models.TemplateSpecsListResult"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) + def prepare_request(next_link=None): if not next_link: - + request = build_template_specs_list_by_subscription_request( subscription_id=self._config.subscription_id, - api_version=api_version, expand=expand, - template_url=self.list_by_subscription.metadata['url'], + api_version=api_version, + template_url=self.list_by_subscription.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore else: - - request = build_template_specs_list_by_subscription_request( - subscription_id=self._config.subscription_id, - template_url=next_link, - ) + # make call to next link with the client's api-version + _parsed_next_link = urlparse(next_link) + _next_request_params = case_insensitive_dict(parse_qs(_parsed_next_link.query)) + _next_request_params["api-version"] = self._config.api_version + request = HttpRequest("GET", urljoin(next_link, _parsed_next_link.path), params=_next_request_params) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore request.method = "GET" return request @@ -811,10 +974,8 @@ def extract_data(pipeline_response): def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) response = pipeline_response.http_response @@ -825,11 +986,9 @@ def get_next(next_link=None): return pipeline_response + return ItemPaged(get_next, extract_data) - return ItemPaged( - get_next, extract_data - ) - list_by_subscription.metadata = {'url': "/subscriptions/{subscriptionId}/providers/Microsoft.Resources/templateSpecs/"} # type: ignore + list_by_subscription.metadata = {"url": "/subscriptions/{subscriptionId}/providers/Microsoft.Resources/templateSpecs/"} # type: ignore @distributed_trace def list_by_resource_group( @@ -837,51 +996,59 @@ def list_by_resource_group( resource_group_name: str, expand: Optional[Union[str, "_models.TemplateSpecExpandKind"]] = None, **kwargs: Any - ) -> Iterable["_models.TemplateSpecsListResult"]: + ) -> Iterable["_models.TemplateSpec"]: """Lists all the Template Specs within the specified resource group. :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. :type resource_group_name: str :param expand: Allows for expansion of additional Template Spec details in the response. - Optional. Default value is None. + Optional. "versions" Default value is None. :type expand: str or ~azure.mgmt.resource.templatespecs.v2021_03_01_preview.models.TemplateSpecExpandKind :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either TemplateSpecsListResult or the result of - cls(response) + :return: An iterator like instance of either TemplateSpec or the result of cls(response) :rtype: - ~azure.core.paging.ItemPaged[~azure.mgmt.resource.templatespecs.v2021_03_01_preview.models.TemplateSpecsListResult] - :raises: ~azure.core.exceptions.HttpResponseError + ~azure.core.paging.ItemPaged[~azure.mgmt.resource.templatespecs.v2021_03_01_preview.models.TemplateSpec] + :raises ~azure.core.exceptions.HttpResponseError: """ - api_version = kwargs.pop('api_version', "2021-03-01-preview") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-03-01-preview")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[_models.TemplateSpecsListResult] - cls = kwargs.pop('cls', None) # type: ClsType["_models.TemplateSpecsListResult"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) + def prepare_request(next_link=None): if not next_link: - + request = build_template_specs_list_by_resource_group_request( - subscription_id=self._config.subscription_id, resource_group_name=resource_group_name, - api_version=api_version, + subscription_id=self._config.subscription_id, expand=expand, - template_url=self.list_by_resource_group.metadata['url'], + 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.url = self._client.format_url(request.url) # type: ignore else: - - request = build_template_specs_list_by_resource_group_request( - subscription_id=self._config.subscription_id, - resource_group_name=resource_group_name, - template_url=next_link, - ) + # make call to next link with the client's api-version + _parsed_next_link = urlparse(next_link) + _next_request_params = case_insensitive_dict(parse_qs(_parsed_next_link.query)) + _next_request_params["api-version"] = self._config.api_version + request = HttpRequest("GET", urljoin(next_link, _parsed_next_link.path), params=_next_request_params) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore request.method = "GET" return request @@ -895,10 +1062,8 @@ def extract_data(pipeline_response): def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) response = pipeline_response.http_response @@ -909,87 +1074,166 @@ def get_next(next_link=None): return pipeline_response + return ItemPaged(get_next, extract_data) - return ItemPaged( - get_next, extract_data - ) - list_by_resource_group.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Resources/templateSpecs/"} # type: ignore -class TemplateSpecVersionsOperations(object): - """TemplateSpecVersionsOperations operations. - - You should not instantiate this class directly. Instead, you should create a Client instance that - instantiates it for you and attaches it as an attribute. - - :ivar models: Alias to model classes used in this operation group. - :type models: ~azure.mgmt.resource.templatespecs.v2021_03_01_preview.models - :param client: Client for service requests. - :param config: Configuration of service client. - :param serializer: An object model serializer. - :param deserializer: An object model deserializer. + list_by_resource_group.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Resources/templateSpecs/"} # type: ignore + + +class TemplateSpecVersionsOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. + + Instead, you should access the following operations through + :class:`~azure.mgmt.resource.templatespecs.v2021_03_01_preview.TemplateSpecsClient`'s + :attr:`template_spec_versions` attribute. """ models = _models - def __init__(self, client, config, serializer, deserializer): - self._client = client - self._serialize = serializer - self._deserialize = deserializer - self._config = config + def __init__(self, *args, **kwargs): + input_args = list(args) + self._client = input_args.pop(0) if input_args else kwargs.pop("client") + self._config = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") - @distributed_trace + @overload def create_or_update( self, resource_group_name: str, template_spec_name: str, template_spec_version: str, - template_spec_version_model: "_models.TemplateSpecVersion", + template_spec_version_model: _models.TemplateSpecVersion, + *, + content_type: str = "application/json", **kwargs: Any - ) -> "_models.TemplateSpecVersion": + ) -> _models.TemplateSpecVersion: """Creates or updates a Template Spec version. :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. :type resource_group_name: str - :param template_spec_name: Name of the Template Spec. + :param template_spec_name: Name of the Template Spec. Required. :type template_spec_name: str - :param template_spec_version: The version of the Template Spec. + :param template_spec_version: The version of the Template Spec. Required. :type template_spec_version: str - :param template_spec_version_model: Template Spec Version supplied to the operation. + :param template_spec_version_model: Template Spec Version supplied to the operation. Required. :type template_spec_version_model: ~azure.mgmt.resource.templatespecs.v2021_03_01_preview.models.TemplateSpecVersion + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: TemplateSpecVersion or the result of cls(response) + :rtype: ~azure.mgmt.resource.templatespecs.v2021_03_01_preview.models.TemplateSpecVersion + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + def create_or_update( + self, + resource_group_name: str, + template_spec_name: str, + template_spec_version: str, + template_spec_version_model: IO, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.TemplateSpecVersion: + """Creates or updates a Template Spec version. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param template_spec_name: Name of the Template Spec. Required. + :type template_spec_name: str + :param template_spec_version: The version of the Template Spec. Required. + :type template_spec_version: str + :param template_spec_version_model: Template Spec Version supplied to the operation. Required. + :type template_spec_version_model: IO + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: TemplateSpecVersion or the result of cls(response) + :rtype: ~azure.mgmt.resource.templatespecs.v2021_03_01_preview.models.TemplateSpecVersion + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace + def create_or_update( + self, + resource_group_name: str, + template_spec_name: str, + template_spec_version: str, + template_spec_version_model: Union[_models.TemplateSpecVersion, IO], + **kwargs: Any + ) -> _models.TemplateSpecVersion: + """Creates or updates a Template Spec version. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param template_spec_name: Name of the Template Spec. Required. + :type template_spec_name: str + :param template_spec_version: The version of the Template Spec. Required. + :type template_spec_version: str + :param template_spec_version_model: Template Spec Version supplied to the operation. Is either + a model type or a IO type. Required. + :type template_spec_version_model: + ~azure.mgmt.resource.templatespecs.v2021_03_01_preview.models.TemplateSpecVersion or IO + :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. + Default value is None. + :paramtype content_type: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: TemplateSpecVersion, or the result of cls(response) + :return: TemplateSpecVersion or the result of cls(response) :rtype: ~azure.mgmt.resource.templatespecs.v2021_03_01_preview.models.TemplateSpecVersion - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.TemplateSpecVersion"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) - api_version = kwargs.pop('api_version', "2021-03-01-preview") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - _json = self._serialize.body(template_spec_version_model, 'TemplateSpecVersion') + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-03-01-preview")) # type: str + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.TemplateSpecVersion] + + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(template_spec_version_model, (IO, bytes)): + _content = template_spec_version_model + else: + _json = self._serialize.body(template_spec_version_model, "TemplateSpecVersion") request = build_template_spec_versions_create_or_update_request( - subscription_id=self._config.subscription_id, resource_group_name=resource_group_name, template_spec_name=template_spec_name, template_spec_version=template_spec_version, + subscription_id=self._config.subscription_id, api_version=api_version, content_type=content_type, json=_json, - template_url=self.create_or_update.metadata['url'], + content=_content, + template_url=self.create_or_update.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200, 201]: @@ -998,77 +1242,160 @@ def create_or_update( raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) if response.status_code == 200: - deserialized = self._deserialize('TemplateSpecVersion', pipeline_response) + deserialized = self._deserialize("TemplateSpecVersion", pipeline_response) if response.status_code == 201: - deserialized = self._deserialize('TemplateSpecVersion', pipeline_response) + deserialized = self._deserialize("TemplateSpecVersion", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - create_or_update.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Resources/templateSpecs/{templateSpecName}/versions/{templateSpecVersion}"} # type: ignore - + create_or_update.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Resources/templateSpecs/{templateSpecName}/versions/{templateSpecVersion}"} # type: ignore - @distributed_trace + @overload def update( self, resource_group_name: str, template_spec_name: str, template_spec_version: str, - template_spec_version_update_model: Optional["_models.TemplateSpecVersionUpdateModel"] = None, + template_spec_version_update_model: Optional[_models.TemplateSpecVersionUpdateModel] = None, + *, + content_type: str = "application/json", **kwargs: Any - ) -> "_models.TemplateSpecVersion": + ) -> _models.TemplateSpecVersion: """Updates Template Spec Version tags with specified values. :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. :type resource_group_name: str - :param template_spec_name: Name of the Template Spec. + :param template_spec_name: Name of the Template Spec. Required. :type template_spec_name: str - :param template_spec_version: The version of the Template Spec. + :param template_spec_version: The version of the Template Spec. Required. :type template_spec_version: str :param template_spec_version_update_model: Template Spec Version resource with the tags to be updated. Default value is None. :type template_spec_version_update_model: ~azure.mgmt.resource.templatespecs.v2021_03_01_preview.models.TemplateSpecVersionUpdateModel + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: TemplateSpecVersion, or the result of cls(response) + :return: TemplateSpecVersion or the result of cls(response) :rtype: ~azure.mgmt.resource.templatespecs.v2021_03_01_preview.models.TemplateSpecVersion - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + def update( + self, + resource_group_name: str, + template_spec_name: str, + template_spec_version: str, + template_spec_version_update_model: Optional[IO] = None, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.TemplateSpecVersion: + """Updates Template Spec Version tags with specified values. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param template_spec_name: Name of the Template Spec. Required. + :type template_spec_name: str + :param template_spec_version: The version of the Template Spec. Required. + :type template_spec_version: str + :param template_spec_version_update_model: Template Spec Version resource with the tags to be + updated. Default value is None. + :type template_spec_version_update_model: IO + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: TemplateSpecVersion or the result of cls(response) + :rtype: ~azure.mgmt.resource.templatespecs.v2021_03_01_preview.models.TemplateSpecVersion + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace + def update( + self, + resource_group_name: str, + template_spec_name: str, + template_spec_version: str, + template_spec_version_update_model: Optional[Union[_models.TemplateSpecVersionUpdateModel, IO]] = None, + **kwargs: Any + ) -> _models.TemplateSpecVersion: + """Updates Template Spec Version tags with specified values. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param template_spec_name: Name of the Template Spec. Required. + :type template_spec_name: str + :param template_spec_version: The version of the Template Spec. Required. + :type template_spec_version: str + :param template_spec_version_update_model: Template Spec Version resource with the tags to be + updated. Is either a model type or a IO type. Default value is None. + :type template_spec_version_update_model: + ~azure.mgmt.resource.templatespecs.v2021_03_01_preview.models.TemplateSpecVersionUpdateModel or + IO + :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. + Default value is None. + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: TemplateSpecVersion or the result of cls(response) + :rtype: ~azure.mgmt.resource.templatespecs.v2021_03_01_preview.models.TemplateSpecVersion + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.TemplateSpecVersion"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) - api_version = kwargs.pop('api_version', "2021-03-01-preview") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - if template_spec_version_update_model is not None: - _json = self._serialize.body(template_spec_version_update_model, 'TemplateSpecVersionUpdateModel') + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-03-01-preview")) # type: str + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.TemplateSpecVersion] + + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(template_spec_version_update_model, (IO, bytes)): + _content = template_spec_version_update_model else: - _json = None + if template_spec_version_update_model is not None: + _json = self._serialize.body(template_spec_version_update_model, "TemplateSpecVersionUpdateModel") + else: + _json = None request = build_template_spec_versions_update_request( - subscription_id=self._config.subscription_id, resource_group_name=resource_group_name, template_spec_name=template_spec_name, template_spec_version=template_spec_version, + subscription_id=self._config.subscription_id, api_version=api_version, content_type=content_type, json=_json, - template_url=self.update.metadata['url'], + content=_content, + template_url=self.update.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200]: @@ -1076,62 +1403,64 @@ def update( error = self._deserialize.failsafe_deserialize(_models.TemplateSpecsError, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - deserialized = self._deserialize('TemplateSpecVersion', pipeline_response) + deserialized = self._deserialize("TemplateSpecVersion", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - update.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Resources/templateSpecs/{templateSpecName}/versions/{templateSpecVersion}"} # type: ignore - + update.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Resources/templateSpecs/{templateSpecName}/versions/{templateSpecVersion}"} # type: ignore @distributed_trace def get( - self, - resource_group_name: str, - template_spec_name: str, - template_spec_version: str, - **kwargs: Any - ) -> "_models.TemplateSpecVersion": + self, resource_group_name: str, template_spec_name: str, template_spec_version: str, **kwargs: Any + ) -> _models.TemplateSpecVersion: """Gets a Template Spec version from a specific Template Spec. :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. :type resource_group_name: str - :param template_spec_name: Name of the Template Spec. + :param template_spec_name: Name of the Template Spec. Required. :type template_spec_name: str - :param template_spec_version: The version of the Template Spec. + :param template_spec_version: The version of the Template Spec. Required. :type template_spec_version: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: TemplateSpecVersion, or the result of cls(response) + :return: TemplateSpecVersion or the result of cls(response) :rtype: ~azure.mgmt.resource.templatespecs.v2021_03_01_preview.models.TemplateSpecVersion - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.TemplateSpecVersion"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + 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', "2021-03-01-preview") # type: str + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-03-01-preview")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[_models.TemplateSpecVersion] - request = build_template_spec_versions_get_request( - subscription_id=self._config.subscription_id, resource_group_name=resource_group_name, template_spec_name=template_spec_name, template_spec_version=template_spec_version, + subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.get.metadata['url'], + template_url=self.get.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200]: @@ -1139,63 +1468,65 @@ def get( error = self._deserialize.failsafe_deserialize(_models.TemplateSpecsError, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - deserialized = self._deserialize('TemplateSpecVersion', pipeline_response) + deserialized = self._deserialize("TemplateSpecVersion", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - get.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Resources/templateSpecs/{templateSpecName}/versions/{templateSpecVersion}"} # type: ignore - + get.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Resources/templateSpecs/{templateSpecName}/versions/{templateSpecVersion}"} # type: ignore @distributed_trace def delete( # pylint: disable=inconsistent-return-statements - self, - resource_group_name: str, - template_spec_name: str, - template_spec_version: str, - **kwargs: Any + self, resource_group_name: str, template_spec_name: str, template_spec_version: str, **kwargs: Any ) -> None: """Deletes a specific version from a Template Spec. When operation completes, status code 200 returned without content. :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. :type resource_group_name: str - :param template_spec_name: Name of the Template Spec. + :param template_spec_name: Name of the Template Spec. Required. :type template_spec_name: str - :param template_spec_version: The version of the Template Spec. + :param template_spec_version: The version of the Template Spec. Required. :type template_spec_version: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: None, or the result of cls(response) + :return: None or the result of cls(response) :rtype: None - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType[None] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) - api_version = kwargs.pop('api_version', "2021-03-01-preview") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-03-01-preview")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[None] - request = build_template_spec_versions_delete_request( - subscription_id=self._config.subscription_id, resource_group_name=resource_group_name, template_spec_name=template_spec_name, template_spec_version=template_spec_version, + subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.delete.metadata['url'], + template_url=self.delete.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200, 204]: @@ -1206,59 +1537,62 @@ def delete( # pylint: disable=inconsistent-return-statements if cls: return cls(pipeline_response, None, {}) - delete.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Resources/templateSpecs/{templateSpecName}/versions/{templateSpecVersion}"} # type: ignore - + delete.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Resources/templateSpecs/{templateSpecName}/versions/{templateSpecVersion}"} # type: ignore @distributed_trace def list( - self, - resource_group_name: str, - template_spec_name: str, - **kwargs: Any - ) -> Iterable["_models.TemplateSpecVersionsListResult"]: + self, resource_group_name: str, template_spec_name: str, **kwargs: Any + ) -> Iterable["_models.TemplateSpecVersion"]: """Lists all the Template Spec versions in the specified Template Spec. :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. :type resource_group_name: str - :param template_spec_name: Name of the Template Spec. + :param template_spec_name: Name of the Template Spec. Required. :type template_spec_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either TemplateSpecVersionsListResult or the result of - cls(response) + :return: An iterator like instance of either TemplateSpecVersion or the result of cls(response) :rtype: - ~azure.core.paging.ItemPaged[~azure.mgmt.resource.templatespecs.v2021_03_01_preview.models.TemplateSpecVersionsListResult] - :raises: ~azure.core.exceptions.HttpResponseError + ~azure.core.paging.ItemPaged[~azure.mgmt.resource.templatespecs.v2021_03_01_preview.models.TemplateSpecVersion] + :raises ~azure.core.exceptions.HttpResponseError: """ - api_version = kwargs.pop('api_version', "2021-03-01-preview") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-03-01-preview")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[_models.TemplateSpecVersionsListResult] - cls = kwargs.pop('cls', None) # type: ClsType["_models.TemplateSpecVersionsListResult"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) + def prepare_request(next_link=None): if not next_link: - + request = build_template_spec_versions_list_request( - subscription_id=self._config.subscription_id, resource_group_name=resource_group_name, template_spec_name=template_spec_name, + subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.list.metadata['url'], + template_url=self.list.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore else: - - request = build_template_spec_versions_list_request( - subscription_id=self._config.subscription_id, - resource_group_name=resource_group_name, - template_spec_name=template_spec_name, - template_url=next_link, - ) + # make call to next link with the client's api-version + _parsed_next_link = urlparse(next_link) + _next_request_params = case_insensitive_dict(parse_qs(_parsed_next_link.query)) + _next_request_params["api-version"] = self._config.api_version + request = HttpRequest("GET", urljoin(next_link, _parsed_next_link.path), params=_next_request_params) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore request.method = "GET" return request @@ -1272,10 +1606,8 @@ def extract_data(pipeline_response): def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) response = pipeline_response.http_response @@ -1286,8 +1618,6 @@ def get_next(next_link=None): return pipeline_response + return ItemPaged(get_next, extract_data) - return ItemPaged( - get_next, extract_data - ) - list.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Resources/templateSpecs/{templateSpecName}/versions"} # type: ignore + list.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Resources/templateSpecs/{templateSpecName}/versions"} # type: ignore diff --git a/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/templatespecs/v2021_03_01_preview/operations/_patch.py b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/templatespecs/v2021_03_01_preview/operations/_patch.py new file mode 100644 index 0000000000000..f7dd32510333d --- /dev/null +++ b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/templatespecs/v2021_03_01_preview/operations/_patch.py @@ -0,0 +1,20 @@ +# ------------------------------------ +# Copyright (c) Microsoft Corporation. +# Licensed under the MIT License. +# ------------------------------------ +"""Customize generated code here. + +Follow our quickstart for examples: https://aka.ms/azsdk/python/dpcodegen/python/customize +""" +from typing import List + +__all__: List[str] = [] # Add all objects you want publicly available to users at this package level + + +def patch_sdk(): + """Do not remove from this file. + + `patch_sdk` is a last resort escape hatch that allows you to do customizations + you can't accomplish using the techniques described in + https://aka.ms/azsdk/python/dpcodegen/python/customize + """ diff --git a/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/templatespecs/v2021_05_01/__init__.py b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/templatespecs/v2021_05_01/__init__.py index 4005d4a7201ea..1d05585f5c592 100644 --- a/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/templatespecs/v2021_05_01/__init__.py +++ b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/templatespecs/v2021_05_01/__init__.py @@ -10,9 +10,15 @@ from ._version import VERSION __version__ = VERSION -__all__ = ['TemplateSpecsClient'] -# `._patch.py` is used for handwritten extensions to the generated code -# Example: https://github.com/Azure/azure-sdk-for-python/blob/main/doc/dev/customize_code/how-to-patch-sdk-code.md -from ._patch import patch_sdk -patch_sdk() +try: + from ._patch import __all__ as _patch_all + from ._patch import * # type: ignore # pylint: disable=unused-wildcard-import +except ImportError: + _patch_all = [] +from ._patch import patch_sdk as _patch_sdk + +__all__ = ["TemplateSpecsClient"] +__all__.extend([p for p in _patch_all if p not in __all__]) + +_patch_sdk() diff --git a/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/templatespecs/v2021_05_01/_configuration.py b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/templatespecs/v2021_05_01/_configuration.py index 40318b2d0c069..76cc63ca5be89 100644 --- a/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/templatespecs/v2021_05_01/_configuration.py +++ b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/templatespecs/v2021_05_01/_configuration.py @@ -25,23 +25,19 @@ class TemplateSpecsClientConfiguration(Configuration): # pylint: disable=too-ma Note that all parameters used to create this instance are saved as instance attributes. - :param credential: Credential needed for the client to connect to Azure. + :param credential: Credential needed for the client to connect to Azure. Required. :type credential: ~azure.core.credentials.TokenCredential :param subscription_id: Subscription Id which forms part of the URI for every service call. + Required. :type subscription_id: str :keyword api_version: Api Version. Default value is "2021-05-01". Note that overriding this default value may result in unsupported behavior. :paramtype api_version: str """ - def __init__( - self, - credential: "TokenCredential", - subscription_id: str, - **kwargs: Any - ) -> None: + def __init__(self, credential: "TokenCredential", subscription_id: str, **kwargs: Any) -> None: super(TemplateSpecsClientConfiguration, self).__init__(**kwargs) - api_version = kwargs.pop('api_version', "2021-05-01") # type: str + api_version = kwargs.pop("api_version", "2021-05-01") # type: str if credential is None: raise ValueError("Parameter 'credential' must not be None.") @@ -51,23 +47,24 @@ def __init__( self.credential = credential self.subscription_id = subscription_id self.api_version = api_version - self.credential_scopes = kwargs.pop('credential_scopes', ['https://management.azure.com/.default']) - kwargs.setdefault('sdk_moniker', 'mgmt-resource/{}'.format(VERSION)) + self.credential_scopes = kwargs.pop("credential_scopes", ["https://management.azure.com/.default"]) + kwargs.setdefault("sdk_moniker", "mgmt-resource/{}".format(VERSION)) self._configure(**kwargs) def _configure( - self, - **kwargs # type: Any + self, **kwargs # type: Any ): # type: (...) -> 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) - self.logging_policy = kwargs.get('logging_policy') or policies.NetworkTraceLoggingPolicy(**kwargs) - self.http_logging_policy = kwargs.get('http_logging_policy') or ARMHttpLoggingPolicy(**kwargs) - self.retry_policy = kwargs.get('retry_policy') or policies.RetryPolicy(**kwargs) - self.custom_hook_policy = kwargs.get('custom_hook_policy') or policies.CustomHookPolicy(**kwargs) - self.redirect_policy = kwargs.get('redirect_policy') or policies.RedirectPolicy(**kwargs) - self.authentication_policy = kwargs.get('authentication_policy') + 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) + self.logging_policy = kwargs.get("logging_policy") or policies.NetworkTraceLoggingPolicy(**kwargs) + self.http_logging_policy = kwargs.get("http_logging_policy") or ARMHttpLoggingPolicy(**kwargs) + self.retry_policy = kwargs.get("retry_policy") or policies.RetryPolicy(**kwargs) + self.custom_hook_policy = kwargs.get("custom_hook_policy") or policies.CustomHookPolicy(**kwargs) + self.redirect_policy = kwargs.get("redirect_policy") or policies.RedirectPolicy(**kwargs) + self.authentication_policy = kwargs.get("authentication_policy") if self.credential and not self.authentication_policy: - self.authentication_policy = ARMChallengeAuthenticationPolicy(self.credential, *self.credential_scopes, **kwargs) + self.authentication_policy = ARMChallengeAuthenticationPolicy( + self.credential, *self.credential_scopes, **kwargs + ) diff --git a/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/templatespecs/v2021_05_01/_metadata.json b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/templatespecs/v2021_05_01/_metadata.json index 1bc272c7edf05..4eeccab1bdd6b 100644 --- a/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/templatespecs/v2021_05_01/_metadata.json +++ b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/templatespecs/v2021_05_01/_metadata.json @@ -10,20 +10,20 @@ "azure_arm": true, "has_lro_operations": false, "client_side_validation": false, - "sync_imports": "{\"typing\": {\"azurecore\": {\"azure.core.credentials\": [\"TokenCredential\"]}}, \"regular\": {\"azurecore\": {\"azure.profiles\": [\"KnownProfiles\", \"ProfileDefinition\"], \"azure.profiles.multiapiclient\": [\"MultiApiClientMixin\"], \"azure.mgmt.core\": [\"ARMPipelineClient\"]}, \"local\": {\"._configuration\": [\"TemplateSpecsClientConfiguration\"]}, \"thirdparty\": {\"msrest\": [\"Deserializer\", \"Serializer\"]}}, \"conditional\": {\"stdlib\": {\"typing\": [\"Any\", \"Optional\"]}}}", - "async_imports": "{\"typing\": {\"azurecore\": {\"azure.core.credentials_async\": [\"AsyncTokenCredential\"], \"azure.core.credentials\": [\"TokenCredential\"]}}, \"regular\": {\"azurecore\": {\"azure.profiles\": [\"KnownProfiles\", \"ProfileDefinition\"], \"azure.profiles.multiapiclient\": [\"MultiApiClientMixin\"], \"azure.mgmt.core\": [\"AsyncARMPipelineClient\"]}, \"local\": {\"._configuration\": [\"TemplateSpecsClientConfiguration\"]}, \"thirdparty\": {\"msrest\": [\"Deserializer\", \"Serializer\"]}}, \"conditional\": {\"stdlib\": {\"typing\": [\"Any\", \"Optional\"]}}}" + "sync_imports": "{\"conditional\": {\"stdlib\": {\"typing\": [\"Any\", \"Optional\"]}}, \"regular\": {\"azurecore\": {\"azure.mgmt.core\": [\"ARMPipelineClient\"], \"azure.profiles\": [\"KnownProfiles\", \"ProfileDefinition\"], \"azure.profiles.multiapiclient\": [\"MultiApiClientMixin\"]}, \"local\": {\"._configuration\": [\"TemplateSpecsClientConfiguration\"], \".._serialization\": [\"Deserializer\", \"Serializer\"]}}, \"typing\": {\"azurecore\": {\"azure.core.credentials\": [\"TokenCredential\"]}}}", + "async_imports": "{\"conditional\": {\"stdlib\": {\"typing\": [\"Any\", \"Optional\"]}}, \"regular\": {\"azurecore\": {\"azure.mgmt.core\": [\"AsyncARMPipelineClient\"], \"azure.profiles\": [\"KnownProfiles\", \"ProfileDefinition\"], \"azure.profiles.multiapiclient\": [\"MultiApiClientMixin\"]}, \"local\": {\"._configuration\": [\"TemplateSpecsClientConfiguration\"], \"..._serialization\": [\"Deserializer\", \"Serializer\"]}}, \"typing\": {\"azurecore\": {\"azure.core.credentials_async\": [\"AsyncTokenCredential\"]}}}" }, "global_parameters": { "sync": { "credential": { - "signature": "credential, # type: \"TokenCredential\"", - "description": "Credential needed for the client to connect to Azure.", + "signature": "credential: \"TokenCredential\",", + "description": "Credential needed for the client to connect to Azure. Required.", "docstring_type": "~azure.core.credentials.TokenCredential", "required": true }, "subscription_id": { - "signature": "subscription_id, # type: str", - "description": "Subscription Id which forms part of the URI for every service call.", + "signature": "subscription_id: str,", + "description": "Subscription Id which forms part of the URI for every service call. Required.", "docstring_type": "str", "required": true } @@ -31,13 +31,13 @@ "async": { "credential": { "signature": "credential: \"AsyncTokenCredential\",", - "description": "Credential needed for the client to connect to Azure.", + "description": "Credential needed for the client to connect to Azure. Required.", "docstring_type": "~azure.core.credentials_async.AsyncTokenCredential", "required": true }, "subscription_id": { "signature": "subscription_id: str,", - "description": "Subscription Id which forms part of the URI for every service call.", + "description": "Subscription Id which forms part of the URI for every service call. Required.", "docstring_type": "str", "required": true } @@ -54,7 +54,7 @@ "required": false }, "base_url": { - "signature": "base_url=\"https://management.azure.com\", # type: str", + "signature": "base_url: str = \"https://management.azure.com\",", "description": "Service URL", "docstring_type": "str", "required": false diff --git a/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/templatespecs/v2021_05_01/_patch.py b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/templatespecs/v2021_05_01/_patch.py index 74e48ecd07cf3..f99e77fef9861 100644 --- a/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/templatespecs/v2021_05_01/_patch.py +++ b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/templatespecs/v2021_05_01/_patch.py @@ -28,4 +28,4 @@ # This file is used for handwritten extensions to the generated code. Example: # https://github.com/Azure/azure-sdk-for-python/blob/main/doc/dev/customize_code/how-to-patch-sdk-code.md def patch_sdk(): - pass \ No newline at end of file + pass diff --git a/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/templatespecs/v2021_05_01/_template_specs_client.py b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/templatespecs/v2021_05_01/_template_specs_client.py index 9b4e82184b294..311f0c8997428 100644 --- a/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/templatespecs/v2021_05_01/_template_specs_client.py +++ b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/templatespecs/v2021_05_01/_template_specs_client.py @@ -9,12 +9,11 @@ from copy import deepcopy from typing import Any, TYPE_CHECKING -from msrest import Deserializer, Serializer - from azure.core.rest import HttpRequest, HttpResponse from azure.mgmt.core import ARMPipelineClient from . import models +from .._serialization import Deserializer, Serializer from ._configuration import TemplateSpecsClientConfiguration from .operations import TemplateSpecVersionsOperations, TemplateSpecsOperations @@ -22,7 +21,8 @@ # pylint: disable=unused-import,ungrouped-imports from azure.core.credentials import TokenCredential -class TemplateSpecsClient: + +class TemplateSpecsClient: # pylint: disable=client-accepts-api-version-keyword """The APIs listed in this specification can be used to manage Template Spec resources through the Azure Resource Manager. @@ -32,9 +32,10 @@ class TemplateSpecsClient: :ivar template_spec_versions: TemplateSpecVersionsOperations operations :vartype template_spec_versions: azure.mgmt.resource.templatespecs.v2021_05_01.operations.TemplateSpecVersionsOperations - :param credential: Credential needed for the client to connect to Azure. + :param credential: Credential needed for the client to connect to Azure. Required. :type credential: ~azure.core.credentials.TokenCredential :param subscription_id: Subscription Id which forms part of the URI for every service call. + Required. :type subscription_id: str :param base_url: Service URL. Default value is "https://management.azure.com". :type base_url: str @@ -50,7 +51,9 @@ def __init__( base_url: str = "https://management.azure.com", **kwargs: Any ) -> None: - self._config = TemplateSpecsClientConfiguration(credential=credential, subscription_id=subscription_id, **kwargs) + self._config = TemplateSpecsClientConfiguration( + credential=credential, subscription_id=subscription_id, **kwargs + ) self._client = ARMPipelineClient(base_url=base_url, config=self._config, **kwargs) client_models = {k: v for k, v in models.__dict__.items() if isinstance(v, type)} @@ -58,14 +61,11 @@ def __init__( self._deserialize = Deserializer(client_models) self._serialize.client_side_validation = False self.template_specs = TemplateSpecsOperations(self._client, self._config, self._serialize, self._deserialize) - self.template_spec_versions = TemplateSpecVersionsOperations(self._client, self._config, self._serialize, self._deserialize) - + self.template_spec_versions = TemplateSpecVersionsOperations( + self._client, self._config, self._serialize, self._deserialize + ) - def _send_request( - self, - request: HttpRequest, - **kwargs: Any - ) -> HttpResponse: + def _send_request(self, request: HttpRequest, **kwargs: Any) -> HttpResponse: """Runs the network request through the client's chained policies. >>> from azure.core.rest import HttpRequest @@ -74,7 +74,7 @@ def _send_request( >>> response = client._send_request(request) - For more information on this code flow, see https://aka.ms/azsdk/python/protocol/quickstart + For more information on this code flow, see https://aka.ms/azsdk/dpcodegen/python/send_request :param request: The network request you want to make. Required. :type request: ~azure.core.rest.HttpRequest diff --git a/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/templatespecs/v2021_05_01/_vendor.py b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/templatespecs/v2021_05_01/_vendor.py index 138f663c53a4e..9aad73fc743e7 100644 --- a/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/templatespecs/v2021_05_01/_vendor.py +++ b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/templatespecs/v2021_05_01/_vendor.py @@ -7,6 +7,7 @@ from azure.core.pipeline.transport import HttpRequest + def _convert_request(request, files=None): data = request.content if not files else None request = HttpRequest(method=request.method, url=request.url, headers=request.headers, data=data) @@ -14,6 +15,7 @@ def _convert_request(request, files=None): request.set_formdata_body(files) return request + def _format_url_section(template, **kwargs): components = template.split("/") while components: @@ -21,7 +23,5 @@ def _format_url_section(template, **kwargs): 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 - ] + components = [c for c in formatted_components if "{}".format(key.args[0]) not in c] template = "/".join(components) diff --git a/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/templatespecs/v2021_05_01/_version.py b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/templatespecs/v2021_05_01/_version.py index a012ac01c480c..e5754a47ce68f 100644 --- a/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/templatespecs/v2021_05_01/_version.py +++ b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/templatespecs/v2021_05_01/_version.py @@ -6,4 +6,4 @@ # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -VERSION = "21.1.0" +VERSION = "1.0.0b1" diff --git a/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/templatespecs/v2021_05_01/aio/__init__.py b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/templatespecs/v2021_05_01/aio/__init__.py index 9c8e93c3f82aa..c5e1e112f0111 100644 --- a/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/templatespecs/v2021_05_01/aio/__init__.py +++ b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/templatespecs/v2021_05_01/aio/__init__.py @@ -7,9 +7,15 @@ # -------------------------------------------------------------------------- from ._template_specs_client import TemplateSpecsClient -__all__ = ['TemplateSpecsClient'] -# `._patch.py` is used for handwritten extensions to the generated code -# Example: https://github.com/Azure/azure-sdk-for-python/blob/main/doc/dev/customize_code/how-to-patch-sdk-code.md -from ._patch import patch_sdk -patch_sdk() +try: + from ._patch import __all__ as _patch_all + from ._patch import * # type: ignore # pylint: disable=unused-wildcard-import +except ImportError: + _patch_all = [] +from ._patch import patch_sdk as _patch_sdk + +__all__ = ["TemplateSpecsClient"] +__all__.extend([p for p in _patch_all if p not in __all__]) + +_patch_sdk() diff --git a/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/templatespecs/v2021_05_01/aio/_configuration.py b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/templatespecs/v2021_05_01/aio/_configuration.py index 550ac8a0cab53..cbcda2bb9aa62 100644 --- a/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/templatespecs/v2021_05_01/aio/_configuration.py +++ b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/templatespecs/v2021_05_01/aio/_configuration.py @@ -25,23 +25,19 @@ class TemplateSpecsClientConfiguration(Configuration): # pylint: disable=too-ma Note that all parameters used to create this instance are saved as instance attributes. - :param credential: Credential needed for the client to connect to Azure. + :param credential: Credential needed for the client to connect to Azure. Required. :type credential: ~azure.core.credentials_async.AsyncTokenCredential :param subscription_id: Subscription Id which forms part of the URI for every service call. + Required. :type subscription_id: str :keyword api_version: Api Version. Default value is "2021-05-01". Note that overriding this default value may result in unsupported behavior. :paramtype api_version: str """ - def __init__( - self, - credential: "AsyncTokenCredential", - subscription_id: str, - **kwargs: Any - ) -> None: + def __init__(self, credential: "AsyncTokenCredential", subscription_id: str, **kwargs: Any) -> None: super(TemplateSpecsClientConfiguration, self).__init__(**kwargs) - api_version = kwargs.pop('api_version', "2021-05-01") # type: str + api_version = kwargs.pop("api_version", "2021-05-01") # type: str if credential is None: raise ValueError("Parameter 'credential' must not be None.") @@ -51,22 +47,21 @@ def __init__( self.credential = credential self.subscription_id = subscription_id self.api_version = api_version - self.credential_scopes = kwargs.pop('credential_scopes', ['https://management.azure.com/.default']) - kwargs.setdefault('sdk_moniker', 'mgmt-resource/{}'.format(VERSION)) + self.credential_scopes = kwargs.pop("credential_scopes", ["https://management.azure.com/.default"]) + kwargs.setdefault("sdk_moniker", "mgmt-resource/{}".format(VERSION)) self._configure(**kwargs) - 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) - self.logging_policy = kwargs.get('logging_policy') or policies.NetworkTraceLoggingPolicy(**kwargs) - self.http_logging_policy = kwargs.get('http_logging_policy') or ARMHttpLoggingPolicy(**kwargs) - self.retry_policy = kwargs.get('retry_policy') or policies.AsyncRetryPolicy(**kwargs) - self.custom_hook_policy = kwargs.get('custom_hook_policy') or policies.CustomHookPolicy(**kwargs) - self.redirect_policy = kwargs.get('redirect_policy') or policies.AsyncRedirectPolicy(**kwargs) - self.authentication_policy = kwargs.get('authentication_policy') + 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) + self.logging_policy = kwargs.get("logging_policy") or policies.NetworkTraceLoggingPolicy(**kwargs) + self.http_logging_policy = kwargs.get("http_logging_policy") or ARMHttpLoggingPolicy(**kwargs) + self.retry_policy = kwargs.get("retry_policy") or policies.AsyncRetryPolicy(**kwargs) + self.custom_hook_policy = kwargs.get("custom_hook_policy") or policies.CustomHookPolicy(**kwargs) + self.redirect_policy = kwargs.get("redirect_policy") or policies.AsyncRedirectPolicy(**kwargs) + self.authentication_policy = kwargs.get("authentication_policy") if self.credential and not self.authentication_policy: - self.authentication_policy = AsyncARMChallengeAuthenticationPolicy(self.credential, *self.credential_scopes, **kwargs) + self.authentication_policy = AsyncARMChallengeAuthenticationPolicy( + self.credential, *self.credential_scopes, **kwargs + ) diff --git a/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/templatespecs/v2021_05_01/aio/_patch.py b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/templatespecs/v2021_05_01/aio/_patch.py index 74e48ecd07cf3..f99e77fef9861 100644 --- a/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/templatespecs/v2021_05_01/aio/_patch.py +++ b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/templatespecs/v2021_05_01/aio/_patch.py @@ -28,4 +28,4 @@ # This file is used for handwritten extensions to the generated code. Example: # https://github.com/Azure/azure-sdk-for-python/blob/main/doc/dev/customize_code/how-to-patch-sdk-code.md def patch_sdk(): - pass \ No newline at end of file + pass diff --git a/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/templatespecs/v2021_05_01/aio/_template_specs_client.py b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/templatespecs/v2021_05_01/aio/_template_specs_client.py index a47cc87f2fa96..ce199bad24e06 100644 --- a/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/templatespecs/v2021_05_01/aio/_template_specs_client.py +++ b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/templatespecs/v2021_05_01/aio/_template_specs_client.py @@ -9,12 +9,11 @@ from copy import deepcopy from typing import Any, Awaitable, TYPE_CHECKING -from msrest import Deserializer, Serializer - from azure.core.rest import AsyncHttpResponse, HttpRequest from azure.mgmt.core import AsyncARMPipelineClient from .. import models +from ..._serialization import Deserializer, Serializer from ._configuration import TemplateSpecsClientConfiguration from .operations import TemplateSpecVersionsOperations, TemplateSpecsOperations @@ -22,7 +21,8 @@ # pylint: disable=unused-import,ungrouped-imports from azure.core.credentials_async import AsyncTokenCredential -class TemplateSpecsClient: + +class TemplateSpecsClient: # pylint: disable=client-accepts-api-version-keyword """The APIs listed in this specification can be used to manage Template Spec resources through the Azure Resource Manager. @@ -32,9 +32,10 @@ class TemplateSpecsClient: :ivar template_spec_versions: TemplateSpecVersionsOperations operations :vartype template_spec_versions: azure.mgmt.resource.templatespecs.v2021_05_01.aio.operations.TemplateSpecVersionsOperations - :param credential: Credential needed for the client to connect to Azure. + :param credential: Credential needed for the client to connect to Azure. Required. :type credential: ~azure.core.credentials_async.AsyncTokenCredential :param subscription_id: Subscription Id which forms part of the URI for every service call. + Required. :type subscription_id: str :param base_url: Service URL. Default value is "https://management.azure.com". :type base_url: str @@ -50,7 +51,9 @@ def __init__( base_url: str = "https://management.azure.com", **kwargs: Any ) -> None: - self._config = TemplateSpecsClientConfiguration(credential=credential, subscription_id=subscription_id, **kwargs) + self._config = TemplateSpecsClientConfiguration( + credential=credential, subscription_id=subscription_id, **kwargs + ) self._client = AsyncARMPipelineClient(base_url=base_url, config=self._config, **kwargs) client_models = {k: v for k, v in models.__dict__.items() if isinstance(v, type)} @@ -58,14 +61,11 @@ def __init__( self._deserialize = Deserializer(client_models) self._serialize.client_side_validation = False self.template_specs = TemplateSpecsOperations(self._client, self._config, self._serialize, self._deserialize) - self.template_spec_versions = TemplateSpecVersionsOperations(self._client, self._config, self._serialize, self._deserialize) - + self.template_spec_versions = TemplateSpecVersionsOperations( + self._client, self._config, self._serialize, self._deserialize + ) - def _send_request( - self, - request: HttpRequest, - **kwargs: Any - ) -> Awaitable[AsyncHttpResponse]: + def _send_request(self, request: HttpRequest, **kwargs: Any) -> Awaitable[AsyncHttpResponse]: """Runs the network request through the client's chained policies. >>> from azure.core.rest import HttpRequest @@ -74,7 +74,7 @@ def _send_request( >>> response = await client._send_request(request) - For more information on this code flow, see https://aka.ms/azsdk/python/protocol/quickstart + For more information on this code flow, see https://aka.ms/azsdk/dpcodegen/python/send_request :param request: The network request you want to make. Required. :type request: ~azure.core.rest.HttpRequest diff --git a/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/templatespecs/v2021_05_01/aio/operations/__init__.py b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/templatespecs/v2021_05_01/aio/operations/__init__.py index cb4936f69ad57..1f6058ba55acd 100644 --- a/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/templatespecs/v2021_05_01/aio/operations/__init__.py +++ b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/templatespecs/v2021_05_01/aio/operations/__init__.py @@ -9,7 +9,13 @@ from ._operations import TemplateSpecsOperations from ._operations import TemplateSpecVersionsOperations +from ._patch import __all__ as _patch_all +from ._patch import * # type: ignore # pylint: disable=unused-wildcard-import +from ._patch import patch_sdk as _patch_sdk + __all__ = [ - 'TemplateSpecsOperations', - 'TemplateSpecVersionsOperations', + "TemplateSpecsOperations", + "TemplateSpecVersionsOperations", ] +__all__.extend([p for p in _patch_all if p not in __all__]) +_patch_sdk() diff --git a/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/templatespecs/v2021_05_01/aio/operations/_operations.py b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/templatespecs/v2021_05_01/aio/operations/_operations.py index 7dc7b6120f379..5e3fa350e4c7c 100644 --- a/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/templatespecs/v2021_05_01/aio/operations/_operations.py +++ b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/templatespecs/v2021_05_01/aio/operations/_operations.py @@ -6,94 +6,189 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -from typing import Any, AsyncIterable, Callable, Dict, Optional, TypeVar, Union +from typing import Any, AsyncIterable, Callable, Dict, IO, Optional, TypeVar, Union, overload +from urllib.parse import parse_qs, urljoin, urlparse from azure.core.async_paging import AsyncItemPaged, AsyncList -from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error +from azure.core.exceptions import ( + ClientAuthenticationError, + HttpResponseError, + ResourceExistsError, + ResourceNotFoundError, + ResourceNotModifiedError, + map_error, +) from azure.core.pipeline import PipelineResponse from azure.core.pipeline.transport import AsyncHttpResponse from azure.core.rest import HttpRequest from azure.core.tracing.decorator import distributed_trace from azure.core.tracing.decorator_async import distributed_trace_async +from azure.core.utils import case_insensitive_dict from azure.mgmt.core.exceptions import ARMErrorFormat from ... import models as _models from ..._vendor import _convert_request -from ...operations._operations import build_template_spec_versions_create_or_update_request, build_template_spec_versions_delete_request, build_template_spec_versions_get_request, build_template_spec_versions_list_request, build_template_spec_versions_update_request, build_template_specs_create_or_update_request, build_template_specs_delete_request, build_template_specs_get_request, build_template_specs_list_by_resource_group_request, build_template_specs_list_by_subscription_request, build_template_specs_update_request -T = TypeVar('T') +from ...operations._operations import ( + build_template_spec_versions_create_or_update_request, + build_template_spec_versions_delete_request, + build_template_spec_versions_get_request, + build_template_spec_versions_list_request, + build_template_spec_versions_update_request, + build_template_specs_create_or_update_request, + build_template_specs_delete_request, + build_template_specs_get_request, + build_template_specs_list_by_resource_group_request, + build_template_specs_list_by_subscription_request, + build_template_specs_update_request, +) + +T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] -class TemplateSpecsOperations: - """TemplateSpecsOperations async operations. - You should not instantiate this class directly. Instead, you should create a Client instance that - instantiates it for you and attaches it as an attribute. +class TemplateSpecsOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. - :ivar models: Alias to model classes used in this operation group. - :type models: ~azure.mgmt.resource.templatespecs.v2021_05_01.models - :param client: Client for service requests. - :param config: Configuration of service client. - :param serializer: An object model serializer. - :param deserializer: An object model deserializer. + Instead, you should access the following operations through + :class:`~azure.mgmt.resource.templatespecs.v2021_05_01.aio.TemplateSpecsClient`'s + :attr:`template_specs` attribute. """ models = _models - def __init__(self, client, config, serializer, deserializer) -> None: - self._client = client - self._serialize = serializer - self._deserialize = deserializer - self._config = config + def __init__(self, *args, **kwargs) -> None: + input_args = list(args) + self._client = input_args.pop(0) if input_args else kwargs.pop("client") + self._config = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") - @distributed_trace_async + @overload async def create_or_update( self, resource_group_name: str, template_spec_name: str, - template_spec: "_models.TemplateSpec", + template_spec: _models.TemplateSpec, + *, + content_type: str = "application/json", **kwargs: Any - ) -> "_models.TemplateSpec": + ) -> _models.TemplateSpec: """Creates or updates a Template Spec. :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. :type resource_group_name: str - :param template_spec_name: Name of the Template Spec. + :param template_spec_name: Name of the Template Spec. Required. :type template_spec_name: str - :param template_spec: Template Spec supplied to the operation. + :param template_spec: Template Spec supplied to the operation. Required. :type template_spec: ~azure.mgmt.resource.templatespecs.v2021_05_01.models.TemplateSpec + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: TemplateSpec, or the result of cls(response) + :return: TemplateSpec or the result of cls(response) :rtype: ~azure.mgmt.resource.templatespecs.v2021_05_01.models.TemplateSpec - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + async def create_or_update( + self, + resource_group_name: str, + template_spec_name: str, + template_spec: IO, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.TemplateSpec: + """Creates or updates a Template Spec. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param template_spec_name: Name of the Template Spec. Required. + :type template_spec_name: str + :param template_spec: Template Spec supplied to the operation. Required. + :type template_spec: IO + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: TemplateSpec or the result of cls(response) + :rtype: ~azure.mgmt.resource.templatespecs.v2021_05_01.models.TemplateSpec + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace_async + async def create_or_update( + self, + resource_group_name: str, + template_spec_name: str, + template_spec: Union[_models.TemplateSpec, IO], + **kwargs: Any + ) -> _models.TemplateSpec: + """Creates or updates a Template Spec. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param template_spec_name: Name of the Template Spec. Required. + :type template_spec_name: str + :param template_spec: Template Spec supplied to the operation. Is either a model type or a IO + type. Required. + :type template_spec: ~azure.mgmt.resource.templatespecs.v2021_05_01.models.TemplateSpec or IO + :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. + Default value is None. + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: TemplateSpec or the result of cls(response) + :rtype: ~azure.mgmt.resource.templatespecs.v2021_05_01.models.TemplateSpec + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.TemplateSpec"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) - api_version = kwargs.pop('api_version', "2021-05-01") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - _json = self._serialize.body(template_spec, 'TemplateSpec') + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-05-01")) # type: str + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.TemplateSpec] + + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(template_spec, (IO, bytes)): + _content = template_spec + else: + _json = self._serialize.body(template_spec, "TemplateSpec") request = build_template_specs_create_or_update_request( - subscription_id=self._config.subscription_id, resource_group_name=resource_group_name, template_spec_name=template_spec_name, + subscription_id=self._config.subscription_id, api_version=api_version, content_type=content_type, json=_json, - template_url=self.create_or_update.metadata['url'], + content=_content, + template_url=self.create_or_update.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200, 201]: @@ -102,73 +197,149 @@ async def create_or_update( raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) if response.status_code == 200: - deserialized = self._deserialize('TemplateSpec', pipeline_response) + deserialized = self._deserialize("TemplateSpec", pipeline_response) if response.status_code == 201: - deserialized = self._deserialize('TemplateSpec', pipeline_response) + deserialized = self._deserialize("TemplateSpec", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - create_or_update.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Resources/templateSpecs/{templateSpecName}"} # type: ignore - + create_or_update.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Resources/templateSpecs/{templateSpecName}"} # type: ignore - @distributed_trace_async + @overload async def update( self, resource_group_name: str, template_spec_name: str, - template_spec: Optional["_models.TemplateSpecUpdateModel"] = None, + template_spec: Optional[_models.TemplateSpecUpdateModel] = None, + *, + content_type: str = "application/json", **kwargs: Any - ) -> "_models.TemplateSpec": + ) -> _models.TemplateSpec: """Updates Template Spec tags with specified values. :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. :type resource_group_name: str - :param template_spec_name: Name of the Template Spec. + :param template_spec_name: Name of the Template Spec. Required. :type template_spec_name: str :param template_spec: Template Spec resource with the tags to be updated. Default value is None. :type template_spec: ~azure.mgmt.resource.templatespecs.v2021_05_01.models.TemplateSpecUpdateModel + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: TemplateSpec or the result of cls(response) + :rtype: ~azure.mgmt.resource.templatespecs.v2021_05_01.models.TemplateSpec + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + async def update( + self, + resource_group_name: str, + template_spec_name: str, + template_spec: Optional[IO] = None, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.TemplateSpec: + """Updates Template Spec tags with specified values. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param template_spec_name: Name of the Template Spec. Required. + :type template_spec_name: str + :param template_spec: Template Spec resource with the tags to be updated. Default value is + None. + :type template_spec: IO + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: TemplateSpec, or the result of cls(response) + :return: TemplateSpec or the result of cls(response) :rtype: ~azure.mgmt.resource.templatespecs.v2021_05_01.models.TemplateSpec - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace_async + async def update( + self, + resource_group_name: str, + template_spec_name: str, + template_spec: Optional[Union[_models.TemplateSpecUpdateModel, IO]] = None, + **kwargs: Any + ) -> _models.TemplateSpec: + """Updates Template Spec tags with specified values. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param template_spec_name: Name of the Template Spec. Required. + :type template_spec_name: str + :param template_spec: Template Spec resource with the tags to be updated. Is either a model + type or a IO type. Default value is None. + :type template_spec: + ~azure.mgmt.resource.templatespecs.v2021_05_01.models.TemplateSpecUpdateModel or IO + :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. + Default value is None. + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: TemplateSpec or the result of cls(response) + :rtype: ~azure.mgmt.resource.templatespecs.v2021_05_01.models.TemplateSpec + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.TemplateSpec"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', "2021-05-01") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-05-01")) # type: str + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.TemplateSpec] - if template_spec is not None: - _json = self._serialize.body(template_spec, 'TemplateSpecUpdateModel') + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(template_spec, (IO, bytes)): + _content = template_spec else: - _json = None + if template_spec is not None: + _json = self._serialize.body(template_spec, "TemplateSpecUpdateModel") + else: + _json = None request = build_template_specs_update_request( - subscription_id=self._config.subscription_id, resource_group_name=resource_group_name, template_spec_name=template_spec_name, + subscription_id=self._config.subscription_id, api_version=api_version, content_type=content_type, json=_json, - template_url=self.update.metadata['url'], + content=_content, + template_url=self.update.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200]: @@ -176,15 +347,14 @@ async def update( error = self._deserialize.failsafe_deserialize(_models.TemplateSpecsError, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - deserialized = self._deserialize('TemplateSpec', pipeline_response) + deserialized = self._deserialize("TemplateSpec", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - update.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Resources/templateSpecs/{templateSpecName}"} # type: ignore - + update.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Resources/templateSpecs/{templateSpecName}"} # type: ignore @distributed_trace_async async def get( @@ -193,47 +363,54 @@ async def get( template_spec_name: str, expand: Optional[Union[str, "_models.TemplateSpecExpandKind"]] = None, **kwargs: Any - ) -> "_models.TemplateSpec": + ) -> _models.TemplateSpec: """Gets a Template Spec with a given name. :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. :type resource_group_name: str - :param template_spec_name: Name of the Template Spec. + :param template_spec_name: Name of the Template Spec. Required. :type template_spec_name: str :param expand: Allows for expansion of additional Template Spec details in the response. - Optional. Default value is None. + Optional. "versions" Default value is None. :type expand: str or ~azure.mgmt.resource.templatespecs.v2021_05_01.models.TemplateSpecExpandKind :keyword callable cls: A custom type or function that will be passed the direct response - :return: TemplateSpec, or the result of cls(response) + :return: TemplateSpec or the result of cls(response) :rtype: ~azure.mgmt.resource.templatespecs.v2021_05_01.models.TemplateSpec - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.TemplateSpec"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) - api_version = kwargs.pop('api_version', "2021-05-01") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-05-01")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[_models.TemplateSpec] - request = build_template_specs_get_request( - subscription_id=self._config.subscription_id, resource_group_name=resource_group_name, template_spec_name=template_spec_name, - api_version=api_version, + subscription_id=self._config.subscription_id, expand=expand, - template_url=self.get.metadata['url'], + api_version=api_version, + template_url=self.get.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200]: @@ -241,59 +418,62 @@ async def get( error = self._deserialize.failsafe_deserialize(_models.TemplateSpecsError, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - deserialized = self._deserialize('TemplateSpec', pipeline_response) + deserialized = self._deserialize("TemplateSpec", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - get.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Resources/templateSpecs/{templateSpecName}"} # type: ignore - + get.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Resources/templateSpecs/{templateSpecName}"} # type: ignore @distributed_trace_async async def delete( # pylint: disable=inconsistent-return-statements - self, - resource_group_name: str, - template_spec_name: str, - **kwargs: Any + self, resource_group_name: str, template_spec_name: str, **kwargs: Any ) -> None: """Deletes a Template Spec by name. When operation completes, status code 200 returned without content. :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. :type resource_group_name: str - :param template_spec_name: Name of the Template Spec. + :param template_spec_name: Name of the Template Spec. Required. :type template_spec_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: None, or the result of cls(response) + :return: None or the result of cls(response) :rtype: None - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType[None] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + 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', "2021-05-01") # type: str + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-05-01")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[None] - request = build_template_specs_delete_request( - subscription_id=self._config.subscription_id, resource_group_name=resource_group_name, template_spec_name=template_spec_name, + subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.delete.metadata['url'], + template_url=self.delete.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200, 204]: @@ -304,55 +484,60 @@ async def delete( # pylint: disable=inconsistent-return-statements if cls: return cls(pipeline_response, None, {}) - delete.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Resources/templateSpecs/{templateSpecName}"} # type: ignore - + delete.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Resources/templateSpecs/{templateSpecName}"} # type: ignore @distributed_trace def list_by_subscription( - self, - expand: Optional[Union[str, "_models.TemplateSpecExpandKind"]] = None, - **kwargs: Any - ) -> AsyncIterable["_models.TemplateSpecsListResult"]: + self, expand: Optional[Union[str, "_models.TemplateSpecExpandKind"]] = None, **kwargs: Any + ) -> AsyncIterable["_models.TemplateSpec"]: """Lists all the Template Specs within the specified subscriptions. :param expand: Allows for expansion of additional Template Spec details in the response. - Optional. Default value is None. + Optional. "versions" Default value is None. :type expand: str or ~azure.mgmt.resource.templatespecs.v2021_05_01.models.TemplateSpecExpandKind :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either TemplateSpecsListResult or the result of - cls(response) + :return: An iterator like instance of either TemplateSpec or the result of cls(response) :rtype: - ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.resource.templatespecs.v2021_05_01.models.TemplateSpecsListResult] - :raises: ~azure.core.exceptions.HttpResponseError + ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.resource.templatespecs.v2021_05_01.models.TemplateSpec] + :raises ~azure.core.exceptions.HttpResponseError: """ - api_version = kwargs.pop('api_version', "2021-05-01") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-05-01")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[_models.TemplateSpecsListResult] - cls = kwargs.pop('cls', None) # type: ClsType["_models.TemplateSpecsListResult"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) + def prepare_request(next_link=None): if not next_link: - + request = build_template_specs_list_by_subscription_request( subscription_id=self._config.subscription_id, - api_version=api_version, expand=expand, - template_url=self.list_by_subscription.metadata['url'], + api_version=api_version, + template_url=self.list_by_subscription.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore else: - - request = build_template_specs_list_by_subscription_request( - subscription_id=self._config.subscription_id, - template_url=next_link, - ) + # make call to next link with the client's api-version + _parsed_next_link = urlparse(next_link) + _next_request_params = case_insensitive_dict(parse_qs(_parsed_next_link.query)) + _next_request_params["api-version"] = self._config.api_version + request = HttpRequest("GET", urljoin(next_link, _parsed_next_link.path), params=_next_request_params) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore request.method = "GET" return request @@ -366,10 +551,8 @@ async def extract_data(pipeline_response): async def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) response = pipeline_response.http_response @@ -380,11 +563,9 @@ async def get_next(next_link=None): return pipeline_response + return AsyncItemPaged(get_next, extract_data) - return AsyncItemPaged( - get_next, extract_data - ) - list_by_subscription.metadata = {'url': "/subscriptions/{subscriptionId}/providers/Microsoft.Resources/templateSpecs/"} # type: ignore + list_by_subscription.metadata = {"url": "/subscriptions/{subscriptionId}/providers/Microsoft.Resources/templateSpecs/"} # type: ignore @distributed_trace def list_by_resource_group( @@ -392,51 +573,59 @@ def list_by_resource_group( resource_group_name: str, expand: Optional[Union[str, "_models.TemplateSpecExpandKind"]] = None, **kwargs: Any - ) -> AsyncIterable["_models.TemplateSpecsListResult"]: + ) -> AsyncIterable["_models.TemplateSpec"]: """Lists all the Template Specs within the specified resource group. :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. :type resource_group_name: str :param expand: Allows for expansion of additional Template Spec details in the response. - Optional. Default value is None. + Optional. "versions" Default value is None. :type expand: str or ~azure.mgmt.resource.templatespecs.v2021_05_01.models.TemplateSpecExpandKind :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either TemplateSpecsListResult or the result of - cls(response) + :return: An iterator like instance of either TemplateSpec or the result of cls(response) :rtype: - ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.resource.templatespecs.v2021_05_01.models.TemplateSpecsListResult] - :raises: ~azure.core.exceptions.HttpResponseError + ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.resource.templatespecs.v2021_05_01.models.TemplateSpec] + :raises ~azure.core.exceptions.HttpResponseError: """ - api_version = kwargs.pop('api_version', "2021-05-01") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-05-01")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[_models.TemplateSpecsListResult] - cls = kwargs.pop('cls', None) # type: ClsType["_models.TemplateSpecsListResult"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) + def prepare_request(next_link=None): if not next_link: - + request = build_template_specs_list_by_resource_group_request( - subscription_id=self._config.subscription_id, resource_group_name=resource_group_name, - api_version=api_version, + subscription_id=self._config.subscription_id, expand=expand, - template_url=self.list_by_resource_group.metadata['url'], + 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.url = self._client.format_url(request.url) # type: ignore else: - - request = build_template_specs_list_by_resource_group_request( - subscription_id=self._config.subscription_id, - resource_group_name=resource_group_name, - template_url=next_link, - ) + # make call to next link with the client's api-version + _parsed_next_link = urlparse(next_link) + _next_request_params = case_insensitive_dict(parse_qs(_parsed_next_link.query)) + _next_request_params["api-version"] = self._config.api_version + request = HttpRequest("GET", urljoin(next_link, _parsed_next_link.path), params=_next_request_params) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore request.method = "GET" return request @@ -450,10 +639,8 @@ async def extract_data(pipeline_response): async def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) response = pipeline_response.http_response @@ -464,87 +651,166 @@ async def get_next(next_link=None): return pipeline_response + return AsyncItemPaged(get_next, extract_data) + + list_by_resource_group.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Resources/templateSpecs/"} # type: ignore - return AsyncItemPaged( - get_next, extract_data - ) - list_by_resource_group.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Resources/templateSpecs/"} # type: ignore -class TemplateSpecVersionsOperations: - """TemplateSpecVersionsOperations async operations. - You should not instantiate this class directly. Instead, you should create a Client instance that - instantiates it for you and attaches it as an attribute. +class TemplateSpecVersionsOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. - :ivar models: Alias to model classes used in this operation group. - :type models: ~azure.mgmt.resource.templatespecs.v2021_05_01.models - :param client: Client for service requests. - :param config: Configuration of service client. - :param serializer: An object model serializer. - :param deserializer: An object model deserializer. + Instead, you should access the following operations through + :class:`~azure.mgmt.resource.templatespecs.v2021_05_01.aio.TemplateSpecsClient`'s + :attr:`template_spec_versions` attribute. """ models = _models - def __init__(self, client, config, serializer, deserializer) -> None: - self._client = client - self._serialize = serializer - self._deserialize = deserializer - self._config = config + def __init__(self, *args, **kwargs) -> None: + input_args = list(args) + self._client = input_args.pop(0) if input_args else kwargs.pop("client") + self._config = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") - @distributed_trace_async + @overload async def create_or_update( self, resource_group_name: str, template_spec_name: str, template_spec_version: str, - template_spec_version_model: "_models.TemplateSpecVersion", + template_spec_version_model: _models.TemplateSpecVersion, + *, + content_type: str = "application/json", **kwargs: Any - ) -> "_models.TemplateSpecVersion": + ) -> _models.TemplateSpecVersion: """Creates or updates a Template Spec version. :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. :type resource_group_name: str - :param template_spec_name: Name of the Template Spec. + :param template_spec_name: Name of the Template Spec. Required. :type template_spec_name: str - :param template_spec_version: The version of the Template Spec. + :param template_spec_version: The version of the Template Spec. Required. :type template_spec_version: str - :param template_spec_version_model: Template Spec Version supplied to the operation. + :param template_spec_version_model: Template Spec Version supplied to the operation. Required. :type template_spec_version_model: ~azure.mgmt.resource.templatespecs.v2021_05_01.models.TemplateSpecVersion + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: TemplateSpecVersion, or the result of cls(response) + :return: TemplateSpecVersion or the result of cls(response) :rtype: ~azure.mgmt.resource.templatespecs.v2021_05_01.models.TemplateSpecVersion - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + async def create_or_update( + self, + resource_group_name: str, + template_spec_name: str, + template_spec_version: str, + template_spec_version_model: IO, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.TemplateSpecVersion: + """Creates or updates a Template Spec version. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param template_spec_name: Name of the Template Spec. Required. + :type template_spec_name: str + :param template_spec_version: The version of the Template Spec. Required. + :type template_spec_version: str + :param template_spec_version_model: Template Spec Version supplied to the operation. Required. + :type template_spec_version_model: IO + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: TemplateSpecVersion or the result of cls(response) + :rtype: ~azure.mgmt.resource.templatespecs.v2021_05_01.models.TemplateSpecVersion + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace_async + async def create_or_update( + self, + resource_group_name: str, + template_spec_name: str, + template_spec_version: str, + template_spec_version_model: Union[_models.TemplateSpecVersion, IO], + **kwargs: Any + ) -> _models.TemplateSpecVersion: + """Creates or updates a Template Spec version. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param template_spec_name: Name of the Template Spec. Required. + :type template_spec_name: str + :param template_spec_version: The version of the Template Spec. Required. + :type template_spec_version: str + :param template_spec_version_model: Template Spec Version supplied to the operation. Is either + a model type or a IO type. Required. + :type template_spec_version_model: + ~azure.mgmt.resource.templatespecs.v2021_05_01.models.TemplateSpecVersion or IO + :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. + Default value is None. + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: TemplateSpecVersion or the result of cls(response) + :rtype: ~azure.mgmt.resource.templatespecs.v2021_05_01.models.TemplateSpecVersion + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.TemplateSpecVersion"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', "2021-05-01") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-05-01")) # type: str + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.TemplateSpecVersion] - _json = self._serialize.body(template_spec_version_model, 'TemplateSpecVersion') + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(template_spec_version_model, (IO, bytes)): + _content = template_spec_version_model + else: + _json = self._serialize.body(template_spec_version_model, "TemplateSpecVersion") request = build_template_spec_versions_create_or_update_request( - subscription_id=self._config.subscription_id, resource_group_name=resource_group_name, template_spec_name=template_spec_name, template_spec_version=template_spec_version, + subscription_id=self._config.subscription_id, api_version=api_version, content_type=content_type, json=_json, - template_url=self.create_or_update.metadata['url'], + content=_content, + template_url=self.create_or_update.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200, 201]: @@ -553,77 +819,159 @@ async def create_or_update( raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) if response.status_code == 200: - deserialized = self._deserialize('TemplateSpecVersion', pipeline_response) + deserialized = self._deserialize("TemplateSpecVersion", pipeline_response) if response.status_code == 201: - deserialized = self._deserialize('TemplateSpecVersion', pipeline_response) + deserialized = self._deserialize("TemplateSpecVersion", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - create_or_update.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Resources/templateSpecs/{templateSpecName}/versions/{templateSpecVersion}"} # type: ignore + create_or_update.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Resources/templateSpecs/{templateSpecName}/versions/{templateSpecVersion}"} # type: ignore - - @distributed_trace_async + @overload async def update( self, resource_group_name: str, template_spec_name: str, template_spec_version: str, - template_spec_version_update_model: Optional["_models.TemplateSpecVersionUpdateModel"] = None, + template_spec_version_update_model: Optional[_models.TemplateSpecVersionUpdateModel] = None, + *, + content_type: str = "application/json", **kwargs: Any - ) -> "_models.TemplateSpecVersion": + ) -> _models.TemplateSpecVersion: """Updates Template Spec Version tags with specified values. :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. :type resource_group_name: str - :param template_spec_name: Name of the Template Spec. + :param template_spec_name: Name of the Template Spec. Required. :type template_spec_name: str - :param template_spec_version: The version of the Template Spec. + :param template_spec_version: The version of the Template Spec. Required. :type template_spec_version: str :param template_spec_version_update_model: Template Spec Version resource with the tags to be updated. Default value is None. :type template_spec_version_update_model: ~azure.mgmt.resource.templatespecs.v2021_05_01.models.TemplateSpecVersionUpdateModel + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: TemplateSpecVersion or the result of cls(response) + :rtype: ~azure.mgmt.resource.templatespecs.v2021_05_01.models.TemplateSpecVersion + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + async def update( + self, + resource_group_name: str, + template_spec_name: str, + template_spec_version: str, + template_spec_version_update_model: Optional[IO] = None, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.TemplateSpecVersion: + """Updates Template Spec Version tags with specified values. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param template_spec_name: Name of the Template Spec. Required. + :type template_spec_name: str + :param template_spec_version: The version of the Template Spec. Required. + :type template_spec_version: str + :param template_spec_version_update_model: Template Spec Version resource with the tags to be + updated. Default value is None. + :type template_spec_version_update_model: IO + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: TemplateSpecVersion, or the result of cls(response) + :return: TemplateSpecVersion or the result of cls(response) :rtype: ~azure.mgmt.resource.templatespecs.v2021_05_01.models.TemplateSpecVersion - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace_async + async def update( + self, + resource_group_name: str, + template_spec_name: str, + template_spec_version: str, + template_spec_version_update_model: Optional[Union[_models.TemplateSpecVersionUpdateModel, IO]] = None, + **kwargs: Any + ) -> _models.TemplateSpecVersion: + """Updates Template Spec Version tags with specified values. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param template_spec_name: Name of the Template Spec. Required. + :type template_spec_name: str + :param template_spec_version: The version of the Template Spec. Required. + :type template_spec_version: str + :param template_spec_version_update_model: Template Spec Version resource with the tags to be + updated. Is either a model type or a IO type. Default value is None. + :type template_spec_version_update_model: + ~azure.mgmt.resource.templatespecs.v2021_05_01.models.TemplateSpecVersionUpdateModel or IO + :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. + Default value is None. + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: TemplateSpecVersion or the result of cls(response) + :rtype: ~azure.mgmt.resource.templatespecs.v2021_05_01.models.TemplateSpecVersion + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.TemplateSpecVersion"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) - api_version = kwargs.pop('api_version', "2021-05-01") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - if template_spec_version_update_model is not None: - _json = self._serialize.body(template_spec_version_update_model, 'TemplateSpecVersionUpdateModel') + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-05-01")) # type: str + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.TemplateSpecVersion] + + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(template_spec_version_update_model, (IO, bytes)): + _content = template_spec_version_update_model else: - _json = None + if template_spec_version_update_model is not None: + _json = self._serialize.body(template_spec_version_update_model, "TemplateSpecVersionUpdateModel") + else: + _json = None request = build_template_spec_versions_update_request( - subscription_id=self._config.subscription_id, resource_group_name=resource_group_name, template_spec_name=template_spec_name, template_spec_version=template_spec_version, + subscription_id=self._config.subscription_id, api_version=api_version, content_type=content_type, json=_json, - template_url=self.update.metadata['url'], + content=_content, + template_url=self.update.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200]: @@ -631,62 +979,64 @@ async def update( error = self._deserialize.failsafe_deserialize(_models.TemplateSpecsError, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - deserialized = self._deserialize('TemplateSpecVersion', pipeline_response) + deserialized = self._deserialize("TemplateSpecVersion", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - update.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Resources/templateSpecs/{templateSpecName}/versions/{templateSpecVersion}"} # type: ignore - + update.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Resources/templateSpecs/{templateSpecName}/versions/{templateSpecVersion}"} # type: ignore @distributed_trace_async async def get( - self, - resource_group_name: str, - template_spec_name: str, - template_spec_version: str, - **kwargs: Any - ) -> "_models.TemplateSpecVersion": + self, resource_group_name: str, template_spec_name: str, template_spec_version: str, **kwargs: Any + ) -> _models.TemplateSpecVersion: """Gets a Template Spec version from a specific Template Spec. :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. :type resource_group_name: str - :param template_spec_name: Name of the Template Spec. + :param template_spec_name: Name of the Template Spec. Required. :type template_spec_name: str - :param template_spec_version: The version of the Template Spec. + :param template_spec_version: The version of the Template Spec. Required. :type template_spec_version: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: TemplateSpecVersion, or the result of cls(response) + :return: TemplateSpecVersion or the result of cls(response) :rtype: ~azure.mgmt.resource.templatespecs.v2021_05_01.models.TemplateSpecVersion - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.TemplateSpecVersion"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) - api_version = kwargs.pop('api_version', "2021-05-01") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-05-01")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[_models.TemplateSpecVersion] - request = build_template_spec_versions_get_request( - subscription_id=self._config.subscription_id, resource_group_name=resource_group_name, template_spec_name=template_spec_name, template_spec_version=template_spec_version, + subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.get.metadata['url'], + template_url=self.get.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200]: @@ -694,63 +1044,65 @@ async def get( error = self._deserialize.failsafe_deserialize(_models.TemplateSpecsError, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - deserialized = self._deserialize('TemplateSpecVersion', pipeline_response) + deserialized = self._deserialize("TemplateSpecVersion", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - get.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Resources/templateSpecs/{templateSpecName}/versions/{templateSpecVersion}"} # type: ignore - + get.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Resources/templateSpecs/{templateSpecName}/versions/{templateSpecVersion}"} # type: ignore @distributed_trace_async async def delete( # pylint: disable=inconsistent-return-statements - self, - resource_group_name: str, - template_spec_name: str, - template_spec_version: str, - **kwargs: Any + self, resource_group_name: str, template_spec_name: str, template_spec_version: str, **kwargs: Any ) -> None: """Deletes a specific version from a Template Spec. When operation completes, status code 200 returned without content. :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. :type resource_group_name: str - :param template_spec_name: Name of the Template Spec. + :param template_spec_name: Name of the Template Spec. Required. :type template_spec_name: str - :param template_spec_version: The version of the Template Spec. + :param template_spec_version: The version of the Template Spec. Required. :type template_spec_version: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: None, or the result of cls(response) + :return: None or the result of cls(response) :rtype: None - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType[None] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) - api_version = kwargs.pop('api_version', "2021-05-01") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-05-01")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[None] - request = build_template_spec_versions_delete_request( - subscription_id=self._config.subscription_id, resource_group_name=resource_group_name, template_spec_name=template_spec_name, template_spec_version=template_spec_version, + subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.delete.metadata['url'], + template_url=self.delete.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200, 204]: @@ -761,59 +1113,62 @@ async def delete( # pylint: disable=inconsistent-return-statements if cls: return cls(pipeline_response, None, {}) - delete.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Resources/templateSpecs/{templateSpecName}/versions/{templateSpecVersion}"} # type: ignore - + delete.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Resources/templateSpecs/{templateSpecName}/versions/{templateSpecVersion}"} # type: ignore @distributed_trace def list( - self, - resource_group_name: str, - template_spec_name: str, - **kwargs: Any - ) -> AsyncIterable["_models.TemplateSpecVersionsListResult"]: + self, resource_group_name: str, template_spec_name: str, **kwargs: Any + ) -> AsyncIterable["_models.TemplateSpecVersion"]: """Lists all the Template Spec versions in the specified Template Spec. :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. :type resource_group_name: str - :param template_spec_name: Name of the Template Spec. + :param template_spec_name: Name of the Template Spec. Required. :type template_spec_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either TemplateSpecVersionsListResult or the result of - cls(response) + :return: An iterator like instance of either TemplateSpecVersion or the result of cls(response) :rtype: - ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.resource.templatespecs.v2021_05_01.models.TemplateSpecVersionsListResult] - :raises: ~azure.core.exceptions.HttpResponseError + ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.resource.templatespecs.v2021_05_01.models.TemplateSpecVersion] + :raises ~azure.core.exceptions.HttpResponseError: """ - api_version = kwargs.pop('api_version', "2021-05-01") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-05-01")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[_models.TemplateSpecVersionsListResult] - cls = kwargs.pop('cls', None) # type: ClsType["_models.TemplateSpecVersionsListResult"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) + def prepare_request(next_link=None): if not next_link: - + request = build_template_spec_versions_list_request( - subscription_id=self._config.subscription_id, resource_group_name=resource_group_name, template_spec_name=template_spec_name, + subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.list.metadata['url'], + template_url=self.list.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore else: - - request = build_template_spec_versions_list_request( - subscription_id=self._config.subscription_id, - resource_group_name=resource_group_name, - template_spec_name=template_spec_name, - template_url=next_link, - ) + # make call to next link with the client's api-version + _parsed_next_link = urlparse(next_link) + _next_request_params = case_insensitive_dict(parse_qs(_parsed_next_link.query)) + _next_request_params["api-version"] = self._config.api_version + request = HttpRequest("GET", urljoin(next_link, _parsed_next_link.path), params=_next_request_params) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore request.method = "GET" return request @@ -827,10 +1182,8 @@ async def extract_data(pipeline_response): async def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) response = pipeline_response.http_response @@ -841,8 +1194,6 @@ async def get_next(next_link=None): return pipeline_response + return AsyncItemPaged(get_next, extract_data) - return AsyncItemPaged( - get_next, extract_data - ) - list.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Resources/templateSpecs/{templateSpecName}/versions"} # type: ignore + list.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Resources/templateSpecs/{templateSpecName}/versions"} # type: ignore diff --git a/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/templatespecs/v2021_05_01/aio/operations/_patch.py b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/templatespecs/v2021_05_01/aio/operations/_patch.py new file mode 100644 index 0000000000000..f7dd32510333d --- /dev/null +++ b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/templatespecs/v2021_05_01/aio/operations/_patch.py @@ -0,0 +1,20 @@ +# ------------------------------------ +# Copyright (c) Microsoft Corporation. +# Licensed under the MIT License. +# ------------------------------------ +"""Customize generated code here. + +Follow our quickstart for examples: https://aka.ms/azsdk/python/dpcodegen/python/customize +""" +from typing import List + +__all__: List[str] = [] # Add all objects you want publicly available to users at this package level + + +def patch_sdk(): + """Do not remove from this file. + + `patch_sdk` is a last resort escape hatch that allows you to do customizations + you can't accomplish using the techniques described in + https://aka.ms/azsdk/python/dpcodegen/python/customize + """ diff --git a/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/templatespecs/v2021_05_01/models/__init__.py b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/templatespecs/v2021_05_01/models/__init__.py index 2b966fa1d8bbf..641cfe9fca945 100644 --- a/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/templatespecs/v2021_05_01/models/__init__.py +++ b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/templatespecs/v2021_05_01/models/__init__.py @@ -20,26 +20,28 @@ from ._models_py3 import TemplateSpecsError from ._models_py3 import TemplateSpecsListResult - -from ._template_specs_client_enums import ( - CreatedByType, - TemplateSpecExpandKind, -) +from ._template_specs_client_enums import CreatedByType +from ._template_specs_client_enums import TemplateSpecExpandKind +from ._patch import __all__ as _patch_all +from ._patch import * # type: ignore # pylint: disable=unused-wildcard-import +from ._patch import patch_sdk as _patch_sdk __all__ = [ - 'AzureResourceBase', - 'ErrorAdditionalInfo', - 'ErrorResponse', - 'LinkedTemplateArtifact', - 'SystemData', - 'TemplateSpec', - 'TemplateSpecUpdateModel', - 'TemplateSpecVersion', - 'TemplateSpecVersionInfo', - 'TemplateSpecVersionUpdateModel', - 'TemplateSpecVersionsListResult', - 'TemplateSpecsError', - 'TemplateSpecsListResult', - 'CreatedByType', - 'TemplateSpecExpandKind', + "AzureResourceBase", + "ErrorAdditionalInfo", + "ErrorResponse", + "LinkedTemplateArtifact", + "SystemData", + "TemplateSpec", + "TemplateSpecUpdateModel", + "TemplateSpecVersion", + "TemplateSpecVersionInfo", + "TemplateSpecVersionUpdateModel", + "TemplateSpecVersionsListResult", + "TemplateSpecsError", + "TemplateSpecsListResult", + "CreatedByType", + "TemplateSpecExpandKind", ] +__all__.extend([p for p in _patch_all if p not in __all__]) +_patch_sdk() diff --git a/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/templatespecs/v2021_05_01/models/_models_py3.py b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/templatespecs/v2021_05_01/models/_models_py3.py index e016fc30ebaa1..db3f01e159730 100644 --- a/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/templatespecs/v2021_05_01/models/_models_py3.py +++ b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/templatespecs/v2021_05_01/models/_models_py3.py @@ -1,4 +1,5 @@ # coding=utf-8 +# pylint: disable=too-many-lines # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. # Licensed under the MIT License. See License.txt in the project root for license information. @@ -7,15 +8,22 @@ # -------------------------------------------------------------------------- import datetime -from typing import Any, Dict, List, Optional, Union +import sys +from typing import Any, Dict, List, Optional, TYPE_CHECKING, Union -from azure.core.exceptions import HttpResponseError -import msrest.serialization +from ... import _serialization -from ._template_specs_client_enums import * +if TYPE_CHECKING: + # pylint: disable=unused-import,ungrouped-imports + from .. import models as _models +if sys.version_info >= (3, 9): + from collections.abc import MutableMapping +else: + from typing import MutableMapping # type: ignore # pylint: disable=ungrouped-imports +JSON = MutableMapping[str, Any] # pylint: disable=unsubscriptable-object -class AzureResourceBase(msrest.serialization.Model): +class AzureResourceBase(_serialization.Model): """Common properties for all Azure resources. Variables are only populated by the server, and will be ignored when sending a request. @@ -32,33 +40,29 @@ class AzureResourceBase(msrest.serialization.Model): """ _validation = { - 'id': {'readonly': True}, - 'name': {'readonly': True}, - 'type': {'readonly': True}, - 'system_data': {'readonly': True}, + "id": {"readonly": True}, + "name": {"readonly": True}, + "type": {"readonly": True}, + "system_data": {"readonly": True}, } _attribute_map = { - 'id': {'key': 'id', 'type': 'str'}, - 'name': {'key': 'name', 'type': 'str'}, - 'type': {'key': 'type', 'type': 'str'}, - 'system_data': {'key': 'systemData', 'type': 'SystemData'}, + "id": {"key": "id", "type": "str"}, + "name": {"key": "name", "type": "str"}, + "type": {"key": "type", "type": "str"}, + "system_data": {"key": "systemData", "type": "SystemData"}, } - def __init__( - self, - **kwargs - ): - """ - """ - super(AzureResourceBase, self).__init__(**kwargs) + def __init__(self, **kwargs): + """ """ + super().__init__(**kwargs) self.id = None self.name = None self.type = None self.system_data = None -class ErrorAdditionalInfo(msrest.serialization.Model): +class ErrorAdditionalInfo(_serialization.Model): """The resource management error additional info. Variables are only populated by the server, and will be ignored when sending a request. @@ -66,31 +70,27 @@ class ErrorAdditionalInfo(msrest.serialization.Model): :ivar type: The additional info type. :vartype type: str :ivar info: The additional info. - :vartype info: any + :vartype info: JSON """ _validation = { - 'type': {'readonly': True}, - 'info': {'readonly': True}, + "type": {"readonly": True}, + "info": {"readonly": True}, } _attribute_map = { - 'type': {'key': 'type', 'type': 'str'}, - 'info': {'key': 'info', 'type': 'object'}, + "type": {"key": "type", "type": "str"}, + "info": {"key": "info", "type": "object"}, } - def __init__( - self, - **kwargs - ): - """ - """ - super(ErrorAdditionalInfo, self).__init__(**kwargs) + def __init__(self, **kwargs): + """ """ + super().__init__(**kwargs) self.type = None self.info = None -class ErrorResponse(msrest.serialization.Model): +class ErrorResponse(_serialization.Model): """Common error response for all Azure Resource Manager APIs to return error details for failed operations. (This also follows the OData error response format.). Variables are only populated by the server, and will be ignored when sending a request. @@ -109,28 +109,24 @@ class ErrorResponse(msrest.serialization.Model): """ _validation = { - 'code': {'readonly': True}, - 'message': {'readonly': True}, - 'target': {'readonly': True}, - 'details': {'readonly': True}, - 'additional_info': {'readonly': True}, + "code": {"readonly": True}, + "message": {"readonly": True}, + "target": {"readonly": True}, + "details": {"readonly": True}, + "additional_info": {"readonly": True}, } _attribute_map = { - 'code': {'key': 'code', 'type': 'str'}, - 'message': {'key': 'message', 'type': 'str'}, - 'target': {'key': 'target', 'type': 'str'}, - 'details': {'key': 'details', 'type': '[ErrorResponse]'}, - 'additional_info': {'key': 'additionalInfo', 'type': '[ErrorAdditionalInfo]'}, + "code": {"key": "code", "type": "str"}, + "message": {"key": "message", "type": "str"}, + "target": {"key": "target", "type": "str"}, + "details": {"key": "details", "type": "[ErrorResponse]"}, + "additional_info": {"key": "additionalInfo", "type": "[ErrorAdditionalInfo]"}, } - def __init__( - self, - **kwargs - ): - """ - """ - super(ErrorResponse, self).__init__(**kwargs) + def __init__(self, **kwargs): + """ """ + super().__init__(**kwargs) self.code = None self.message = None self.target = None @@ -138,60 +134,54 @@ def __init__( self.additional_info = None -class LinkedTemplateArtifact(msrest.serialization.Model): +class LinkedTemplateArtifact(_serialization.Model): """Represents a Template Spec artifact containing an embedded Azure Resource Manager template for use as a linked template. All required parameters must be populated in order to send to Azure. - :ivar path: Required. A filesystem safe relative path of the artifact. + :ivar path: A filesystem safe relative path of the artifact. Required. :vartype path: str - :ivar template: Required. The Azure Resource Manager template. - :vartype template: any + :ivar template: The Azure Resource Manager template. Required. + :vartype template: JSON """ _validation = { - 'path': {'required': True}, - 'template': {'required': True}, + "path": {"required": True}, + "template": {"required": True}, } _attribute_map = { - 'path': {'key': 'path', 'type': 'str'}, - 'template': {'key': 'template', 'type': 'object'}, + "path": {"key": "path", "type": "str"}, + "template": {"key": "template", "type": "object"}, } - def __init__( - self, - *, - path: str, - template: Any, - **kwargs - ): + def __init__(self, *, path: str, template: JSON, **kwargs): """ - :keyword path: Required. A filesystem safe relative path of the artifact. + :keyword path: A filesystem safe relative path of the artifact. Required. :paramtype path: str - :keyword template: Required. The Azure Resource Manager template. - :paramtype template: any + :keyword template: The Azure Resource Manager template. Required. + :paramtype template: JSON """ - super(LinkedTemplateArtifact, self).__init__(**kwargs) + super().__init__(**kwargs) self.path = path self.template = template -class SystemData(msrest.serialization.Model): +class SystemData(_serialization.Model): """Metadata pertaining to creation and last modification of the resource. :ivar created_by: The identity that created the resource. :vartype created_by: str - :ivar created_by_type: The type of identity that created the resource. Possible values include: - "User", "Application", "ManagedIdentity", "Key". + :ivar created_by_type: The type of identity that created the resource. Known values are: + "User", "Application", "ManagedIdentity", and "Key". :vartype created_by_type: str or ~azure.mgmt.resource.templatespecs.v2021_05_01.models.CreatedByType :ivar created_at: The timestamp of resource creation (UTC). :vartype created_at: ~datetime.datetime :ivar last_modified_by: The identity that last modified the resource. :vartype last_modified_by: str - :ivar last_modified_by_type: The type of identity that last modified the resource. Possible - values include: "User", "Application", "ManagedIdentity", "Key". + :ivar last_modified_by_type: The type of identity that last modified the resource. Known values + are: "User", "Application", "ManagedIdentity", and "Key". :vartype last_modified_by_type: str or ~azure.mgmt.resource.templatespecs.v2021_05_01.models.CreatedByType :ivar last_modified_at: The timestamp of resource last modification (UTC). @@ -199,44 +189,44 @@ class SystemData(msrest.serialization.Model): """ _attribute_map = { - 'created_by': {'key': 'createdBy', 'type': 'str'}, - 'created_by_type': {'key': 'createdByType', 'type': 'str'}, - 'created_at': {'key': 'createdAt', 'type': 'iso-8601'}, - 'last_modified_by': {'key': 'lastModifiedBy', 'type': 'str'}, - 'last_modified_by_type': {'key': 'lastModifiedByType', 'type': 'str'}, - 'last_modified_at': {'key': 'lastModifiedAt', 'type': 'iso-8601'}, + "created_by": {"key": "createdBy", "type": "str"}, + "created_by_type": {"key": "createdByType", "type": "str"}, + "created_at": {"key": "createdAt", "type": "iso-8601"}, + "last_modified_by": {"key": "lastModifiedBy", "type": "str"}, + "last_modified_by_type": {"key": "lastModifiedByType", "type": "str"}, + "last_modified_at": {"key": "lastModifiedAt", "type": "iso-8601"}, } def __init__( self, *, created_by: Optional[str] = None, - created_by_type: Optional[Union[str, "CreatedByType"]] = None, + created_by_type: Optional[Union[str, "_models.CreatedByType"]] = None, created_at: Optional[datetime.datetime] = None, last_modified_by: Optional[str] = None, - last_modified_by_type: Optional[Union[str, "CreatedByType"]] = None, + last_modified_by_type: Optional[Union[str, "_models.CreatedByType"]] = None, last_modified_at: Optional[datetime.datetime] = None, **kwargs ): """ :keyword created_by: The identity that created the resource. :paramtype created_by: str - :keyword created_by_type: The type of identity that created the resource. Possible values - include: "User", "Application", "ManagedIdentity", "Key". + :keyword created_by_type: The type of identity that created the resource. Known values are: + "User", "Application", "ManagedIdentity", and "Key". :paramtype created_by_type: str or ~azure.mgmt.resource.templatespecs.v2021_05_01.models.CreatedByType :keyword created_at: The timestamp of resource creation (UTC). :paramtype created_at: ~datetime.datetime :keyword last_modified_by: The identity that last modified the resource. :paramtype last_modified_by: str - :keyword last_modified_by_type: The type of identity that last modified the resource. Possible - values include: "User", "Application", "ManagedIdentity", "Key". + :keyword last_modified_by_type: The type of identity that last modified the resource. Known + values are: "User", "Application", "ManagedIdentity", and "Key". :paramtype last_modified_by_type: str or ~azure.mgmt.resource.templatespecs.v2021_05_01.models.CreatedByType :keyword last_modified_at: The timestamp of resource last modification (UTC). :paramtype last_modified_at: ~datetime.datetime """ - super(SystemData, self).__init__(**kwargs) + super().__init__(**kwargs) self.created_by = created_by self.created_by_type = created_by_type self.created_at = created_at @@ -261,10 +251,10 @@ class TemplateSpec(AzureResourceBase): :ivar system_data: Azure Resource Manager metadata containing createdBy and modifiedBy information. :vartype system_data: ~azure.mgmt.resource.templatespecs.v2021_05_01.models.SystemData - :ivar location: Required. The location of the Template Spec. It cannot be changed after - Template Spec creation. It must be one of the supported Azure locations. + :ivar location: The location of the Template Spec. It cannot be changed after Template Spec + creation. It must be one of the supported Azure locations. Required. :vartype location: str - :ivar tags: A set of tags. Resource tags. + :ivar tags: Resource tags. :vartype tags: dict[str, str] :ivar description: Template Spec description. :vartype description: str @@ -272,7 +262,7 @@ class TemplateSpec(AzureResourceBase): :vartype display_name: str :ivar metadata: The Template Spec metadata. Metadata is an open-ended object and is typically a collection of key-value pairs. - :vartype metadata: any + :vartype metadata: JSON :ivar versions: High-level information about the versions within this Template Spec. The keys are the version names. Only populated if the $expand query parameter is set to 'versions'. :vartype versions: dict[str, @@ -280,27 +270,27 @@ class TemplateSpec(AzureResourceBase): """ _validation = { - 'id': {'readonly': True}, - 'name': {'readonly': True}, - 'type': {'readonly': True}, - 'system_data': {'readonly': True}, - 'location': {'required': True}, - 'description': {'max_length': 4096, 'min_length': 0}, - 'display_name': {'max_length': 64, 'min_length': 0}, - 'versions': {'readonly': True}, + "id": {"readonly": True}, + "name": {"readonly": True}, + "type": {"readonly": True}, + "system_data": {"readonly": True}, + "location": {"required": True}, + "description": {"max_length": 4096}, + "display_name": {"max_length": 64}, + "versions": {"readonly": True}, } _attribute_map = { - 'id': {'key': 'id', 'type': 'str'}, - 'name': {'key': 'name', 'type': 'str'}, - 'type': {'key': 'type', 'type': 'str'}, - 'system_data': {'key': 'systemData', 'type': 'SystemData'}, - 'location': {'key': 'location', 'type': 'str'}, - 'tags': {'key': 'tags', 'type': '{str}'}, - 'description': {'key': 'properties.description', 'type': 'str'}, - 'display_name': {'key': 'properties.displayName', 'type': 'str'}, - 'metadata': {'key': 'properties.metadata', 'type': 'object'}, - 'versions': {'key': 'properties.versions', 'type': '{TemplateSpecVersionInfo}'}, + "id": {"key": "id", "type": "str"}, + "name": {"key": "name", "type": "str"}, + "type": {"key": "type", "type": "str"}, + "system_data": {"key": "systemData", "type": "SystemData"}, + "location": {"key": "location", "type": "str"}, + "tags": {"key": "tags", "type": "{str}"}, + "description": {"key": "properties.description", "type": "str"}, + "display_name": {"key": "properties.displayName", "type": "str"}, + "metadata": {"key": "properties.metadata", "type": "object"}, + "versions": {"key": "properties.versions", "type": "{TemplateSpecVersionInfo}"}, } def __init__( @@ -310,14 +300,14 @@ def __init__( tags: Optional[Dict[str, str]] = None, description: Optional[str] = None, display_name: Optional[str] = None, - metadata: Optional[Any] = None, + metadata: Optional[JSON] = None, **kwargs ): """ - :keyword location: Required. The location of the Template Spec. It cannot be changed after - Template Spec creation. It must be one of the supported Azure locations. + :keyword location: The location of the Template Spec. It cannot be changed after Template Spec + creation. It must be one of the supported Azure locations. Required. :paramtype location: str - :keyword tags: A set of tags. Resource tags. + :keyword tags: Resource tags. :paramtype tags: dict[str, str] :keyword description: Template Spec description. :paramtype description: str @@ -325,9 +315,9 @@ def __init__( :paramtype display_name: str :keyword metadata: The Template Spec metadata. Metadata is an open-ended object and is typically a collection of key-value pairs. - :paramtype metadata: any + :paramtype metadata: JSON """ - super(TemplateSpec, self).__init__(**kwargs) + super().__init__(**kwargs) self.location = location self.tags = tags self.description = description @@ -336,7 +326,7 @@ def __init__( self.versions = None -class TemplateSpecsError(msrest.serialization.Model): +class TemplateSpecsError(_serialization.Model): """Template Specs error response. :ivar error: Common error response for all Azure Resource Manager APIs to return error details @@ -345,25 +335,20 @@ class TemplateSpecsError(msrest.serialization.Model): """ _attribute_map = { - 'error': {'key': 'error', 'type': 'ErrorResponse'}, + "error": {"key": "error", "type": "ErrorResponse"}, } - def __init__( - self, - *, - error: Optional["ErrorResponse"] = None, - **kwargs - ): + def __init__(self, *, error: Optional["_models.ErrorResponse"] = None, **kwargs): """ :keyword error: Common error response for all Azure Resource Manager APIs to return error details for failed operations. (This also follows the OData error response format.). :paramtype error: ~azure.mgmt.resource.templatespecs.v2021_05_01.models.ErrorResponse """ - super(TemplateSpecsError, self).__init__(**kwargs) + super().__init__(**kwargs) self.error = error -class TemplateSpecsListResult(msrest.serialization.Model): +class TemplateSpecsListResult(_serialization.Model): """List of Template Specs. Variables are only populated by the server, and will be ignored when sending a request. @@ -375,25 +360,20 @@ class TemplateSpecsListResult(msrest.serialization.Model): """ _validation = { - 'next_link': {'readonly': True}, + "next_link": {"readonly": True}, } _attribute_map = { - 'value': {'key': 'value', 'type': '[TemplateSpec]'}, - 'next_link': {'key': 'nextLink', 'type': 'str'}, + "value": {"key": "value", "type": "[TemplateSpec]"}, + "next_link": {"key": "nextLink", "type": "str"}, } - def __init__( - self, - *, - value: Optional[List["TemplateSpec"]] = None, - **kwargs - ): + def __init__(self, *, value: Optional[List["_models.TemplateSpec"]] = None, **kwargs): """ :keyword value: An array of Template Specs. :paramtype value: list[~azure.mgmt.resource.templatespecs.v2021_05_01.models.TemplateSpec] """ - super(TemplateSpecsListResult, self).__init__(**kwargs) + super().__init__(**kwargs) self.value = value self.next_link = None @@ -412,40 +392,35 @@ class TemplateSpecUpdateModel(AzureResourceBase): :ivar system_data: Azure Resource Manager metadata containing createdBy and modifiedBy information. :vartype system_data: ~azure.mgmt.resource.templatespecs.v2021_05_01.models.SystemData - :ivar tags: A set of tags. Resource tags. + :ivar tags: Resource tags. :vartype tags: dict[str, str] """ _validation = { - 'id': {'readonly': True}, - 'name': {'readonly': True}, - 'type': {'readonly': True}, - 'system_data': {'readonly': True}, + "id": {"readonly": True}, + "name": {"readonly": True}, + "type": {"readonly": True}, + "system_data": {"readonly": True}, } _attribute_map = { - 'id': {'key': 'id', 'type': 'str'}, - 'name': {'key': 'name', 'type': 'str'}, - 'type': {'key': 'type', 'type': 'str'}, - 'system_data': {'key': 'systemData', 'type': 'SystemData'}, - 'tags': {'key': 'tags', 'type': '{str}'}, + "id": {"key": "id", "type": "str"}, + "name": {"key": "name", "type": "str"}, + "type": {"key": "type", "type": "str"}, + "system_data": {"key": "systemData", "type": "SystemData"}, + "tags": {"key": "tags", "type": "{str}"}, } - def __init__( - self, - *, - tags: Optional[Dict[str, str]] = None, - **kwargs - ): + def __init__(self, *, tags: Optional[Dict[str, str]] = None, **kwargs): """ - :keyword tags: A set of tags. Resource tags. + :keyword tags: Resource tags. :paramtype tags: dict[str, str] """ - super(TemplateSpecUpdateModel, self).__init__(**kwargs) + super().__init__(**kwargs) self.tags = tags -class TemplateSpecVersion(AzureResourceBase): +class TemplateSpecVersion(AzureResourceBase): # pylint: disable=too-many-instance-attributes """Template Spec Version object. Variables are only populated by the server, and will be ignored when sending a request. @@ -461,10 +436,10 @@ class TemplateSpecVersion(AzureResourceBase): :ivar system_data: Azure Resource Manager metadata containing createdBy and modifiedBy information. :vartype system_data: ~azure.mgmt.resource.templatespecs.v2021_05_01.models.SystemData - :ivar location: Required. The location of the Template Spec Version. It must match the location - of the parent Template Spec. + :ivar location: The location of the Template Spec Version. It must match the location of the + parent Template Spec. Required. :vartype location: str - :ivar tags: A set of tags. Resource tags. + :ivar tags: Resource tags. :vartype tags: dict[str, str] :ivar description: Template Spec version description. :vartype description: str @@ -473,34 +448,34 @@ class TemplateSpecVersion(AzureResourceBase): list[~azure.mgmt.resource.templatespecs.v2021_05_01.models.LinkedTemplateArtifact] :ivar metadata: The version metadata. Metadata is an open-ended object and is typically a collection of key-value pairs. - :vartype metadata: any + :vartype metadata: JSON :ivar main_template: The main Azure Resource Manager template content. - :vartype main_template: any + :vartype main_template: JSON :ivar ui_form_definition: The Azure Resource Manager template UI definition content. - :vartype ui_form_definition: any + :vartype ui_form_definition: JSON """ _validation = { - 'id': {'readonly': True}, - 'name': {'readonly': True}, - 'type': {'readonly': True}, - 'system_data': {'readonly': True}, - 'location': {'required': True}, - 'description': {'max_length': 4096, 'min_length': 0}, + "id": {"readonly": True}, + "name": {"readonly": True}, + "type": {"readonly": True}, + "system_data": {"readonly": True}, + "location": {"required": True}, + "description": {"max_length": 4096}, } _attribute_map = { - 'id': {'key': 'id', 'type': 'str'}, - 'name': {'key': 'name', 'type': 'str'}, - 'type': {'key': 'type', 'type': 'str'}, - 'system_data': {'key': 'systemData', 'type': 'SystemData'}, - 'location': {'key': 'location', 'type': 'str'}, - 'tags': {'key': 'tags', 'type': '{str}'}, - 'description': {'key': 'properties.description', 'type': 'str'}, - 'linked_templates': {'key': 'properties.linkedTemplates', 'type': '[LinkedTemplateArtifact]'}, - 'metadata': {'key': 'properties.metadata', 'type': 'object'}, - 'main_template': {'key': 'properties.mainTemplate', 'type': 'object'}, - 'ui_form_definition': {'key': 'properties.uiFormDefinition', 'type': 'object'}, + "id": {"key": "id", "type": "str"}, + "name": {"key": "name", "type": "str"}, + "type": {"key": "type", "type": "str"}, + "system_data": {"key": "systemData", "type": "SystemData"}, + "location": {"key": "location", "type": "str"}, + "tags": {"key": "tags", "type": "{str}"}, + "description": {"key": "properties.description", "type": "str"}, + "linked_templates": {"key": "properties.linkedTemplates", "type": "[LinkedTemplateArtifact]"}, + "metadata": {"key": "properties.metadata", "type": "object"}, + "main_template": {"key": "properties.mainTemplate", "type": "object"}, + "ui_form_definition": {"key": "properties.uiFormDefinition", "type": "object"}, } def __init__( @@ -509,17 +484,17 @@ def __init__( location: str, tags: Optional[Dict[str, str]] = None, description: Optional[str] = None, - linked_templates: Optional[List["LinkedTemplateArtifact"]] = None, - metadata: Optional[Any] = None, - main_template: Optional[Any] = None, - ui_form_definition: Optional[Any] = None, + linked_templates: Optional[List["_models.LinkedTemplateArtifact"]] = None, + metadata: Optional[JSON] = None, + main_template: Optional[JSON] = None, + ui_form_definition: Optional[JSON] = None, **kwargs ): """ - :keyword location: Required. The location of the Template Spec Version. It must match the - location of the parent Template Spec. + :keyword location: The location of the Template Spec Version. It must match the location of the + parent Template Spec. Required. :paramtype location: str - :keyword tags: A set of tags. Resource tags. + :keyword tags: Resource tags. :paramtype tags: dict[str, str] :keyword description: Template Spec version description. :paramtype description: str @@ -528,13 +503,13 @@ def __init__( list[~azure.mgmt.resource.templatespecs.v2021_05_01.models.LinkedTemplateArtifact] :keyword metadata: The version metadata. Metadata is an open-ended object and is typically a collection of key-value pairs. - :paramtype metadata: any + :paramtype metadata: JSON :keyword main_template: The main Azure Resource Manager template content. - :paramtype main_template: any + :paramtype main_template: JSON :keyword ui_form_definition: The Azure Resource Manager template UI definition content. - :paramtype ui_form_definition: any + :paramtype ui_form_definition: JSON """ - super(TemplateSpecVersion, self).__init__(**kwargs) + super().__init__(**kwargs) self.location = location self.tags = tags self.description = description @@ -544,7 +519,7 @@ def __init__( self.ui_form_definition = ui_form_definition -class TemplateSpecVersionInfo(msrest.serialization.Model): +class TemplateSpecVersionInfo(_serialization.Model): """High-level information about a Template Spec version. Variables are only populated by the server, and will be ignored when sending a request. @@ -558,30 +533,26 @@ class TemplateSpecVersionInfo(msrest.serialization.Model): """ _validation = { - 'description': {'readonly': True}, - 'time_created': {'readonly': True}, - 'time_modified': {'readonly': True}, + "description": {"readonly": True}, + "time_created": {"readonly": True}, + "time_modified": {"readonly": True}, } _attribute_map = { - 'description': {'key': 'description', 'type': 'str'}, - 'time_created': {'key': 'timeCreated', 'type': 'iso-8601'}, - 'time_modified': {'key': 'timeModified', 'type': 'iso-8601'}, + "description": {"key": "description", "type": "str"}, + "time_created": {"key": "timeCreated", "type": "iso-8601"}, + "time_modified": {"key": "timeModified", "type": "iso-8601"}, } - def __init__( - self, - **kwargs - ): - """ - """ - super(TemplateSpecVersionInfo, self).__init__(**kwargs) + def __init__(self, **kwargs): + """ """ + super().__init__(**kwargs) self.description = None self.time_created = None self.time_modified = None -class TemplateSpecVersionsListResult(msrest.serialization.Model): +class TemplateSpecVersionsListResult(_serialization.Model): """List of Template Specs versions. Variables are only populated by the server, and will be ignored when sending a request. @@ -593,26 +564,21 @@ class TemplateSpecVersionsListResult(msrest.serialization.Model): """ _validation = { - 'next_link': {'readonly': True}, + "next_link": {"readonly": True}, } _attribute_map = { - 'value': {'key': 'value', 'type': '[TemplateSpecVersion]'}, - 'next_link': {'key': 'nextLink', 'type': 'str'}, + "value": {"key": "value", "type": "[TemplateSpecVersion]"}, + "next_link": {"key": "nextLink", "type": "str"}, } - def __init__( - self, - *, - value: Optional[List["TemplateSpecVersion"]] = None, - **kwargs - ): + def __init__(self, *, value: Optional[List["_models.TemplateSpecVersion"]] = None, **kwargs): """ :keyword value: An array of Template Spec versions. :paramtype value: list[~azure.mgmt.resource.templatespecs.v2021_05_01.models.TemplateSpecVersion] """ - super(TemplateSpecVersionsListResult, self).__init__(**kwargs) + super().__init__(**kwargs) self.value = value self.next_link = None @@ -631,34 +597,29 @@ class TemplateSpecVersionUpdateModel(AzureResourceBase): :ivar system_data: Azure Resource Manager metadata containing createdBy and modifiedBy information. :vartype system_data: ~azure.mgmt.resource.templatespecs.v2021_05_01.models.SystemData - :ivar tags: A set of tags. Resource tags. + :ivar tags: Resource tags. :vartype tags: dict[str, str] """ _validation = { - 'id': {'readonly': True}, - 'name': {'readonly': True}, - 'type': {'readonly': True}, - 'system_data': {'readonly': True}, + "id": {"readonly": True}, + "name": {"readonly": True}, + "type": {"readonly": True}, + "system_data": {"readonly": True}, } _attribute_map = { - 'id': {'key': 'id', 'type': 'str'}, - 'name': {'key': 'name', 'type': 'str'}, - 'type': {'key': 'type', 'type': 'str'}, - 'system_data': {'key': 'systemData', 'type': 'SystemData'}, - 'tags': {'key': 'tags', 'type': '{str}'}, + "id": {"key": "id", "type": "str"}, + "name": {"key": "name", "type": "str"}, + "type": {"key": "type", "type": "str"}, + "system_data": {"key": "systemData", "type": "SystemData"}, + "tags": {"key": "tags", "type": "{str}"}, } - def __init__( - self, - *, - tags: Optional[Dict[str, str]] = None, - **kwargs - ): + def __init__(self, *, tags: Optional[Dict[str, str]] = None, **kwargs): """ - :keyword tags: A set of tags. Resource tags. + :keyword tags: Resource tags. :paramtype tags: dict[str, str] """ - super(TemplateSpecVersionUpdateModel, self).__init__(**kwargs) + super().__init__(**kwargs) self.tags = tags diff --git a/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/templatespecs/v2021_05_01/models/_patch.py b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/templatespecs/v2021_05_01/models/_patch.py new file mode 100644 index 0000000000000..f7dd32510333d --- /dev/null +++ b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/templatespecs/v2021_05_01/models/_patch.py @@ -0,0 +1,20 @@ +# ------------------------------------ +# Copyright (c) Microsoft Corporation. +# Licensed under the MIT License. +# ------------------------------------ +"""Customize generated code here. + +Follow our quickstart for examples: https://aka.ms/azsdk/python/dpcodegen/python/customize +""" +from typing import List + +__all__: List[str] = [] # Add all objects you want publicly available to users at this package level + + +def patch_sdk(): + """Do not remove from this file. + + `patch_sdk` is a last resort escape hatch that allows you to do customizations + you can't accomplish using the techniques described in + https://aka.ms/azsdk/python/dpcodegen/python/customize + """ diff --git a/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/templatespecs/v2021_05_01/models/_template_specs_client_enums.py b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/templatespecs/v2021_05_01/models/_template_specs_client_enums.py index ef8823668c7ee..ec0f6b2bc39a4 100644 --- a/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/templatespecs/v2021_05_01/models/_template_specs_client_enums.py +++ b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/templatespecs/v2021_05_01/models/_template_specs_client_enums.py @@ -7,20 +7,20 @@ # -------------------------------------------------------------------------- from enum import Enum -from six import with_metaclass from azure.core import CaseInsensitiveEnumMeta -class CreatedByType(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): - """The type of identity that created the resource. - """ +class CreatedByType(str, Enum, metaclass=CaseInsensitiveEnumMeta): + """The type of identity that created the resource.""" USER = "User" APPLICATION = "Application" MANAGED_IDENTITY = "ManagedIdentity" KEY = "Key" -class TemplateSpecExpandKind(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): + +class TemplateSpecExpandKind(str, Enum, metaclass=CaseInsensitiveEnumMeta): + """TemplateSpecExpandKind.""" #: Includes version information with the Template Spec. VERSIONS = "versions" diff --git a/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/templatespecs/v2021_05_01/operations/__init__.py b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/templatespecs/v2021_05_01/operations/__init__.py index cb4936f69ad57..1f6058ba55acd 100644 --- a/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/templatespecs/v2021_05_01/operations/__init__.py +++ b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/templatespecs/v2021_05_01/operations/__init__.py @@ -9,7 +9,13 @@ from ._operations import TemplateSpecsOperations from ._operations import TemplateSpecVersionsOperations +from ._patch import __all__ as _patch_all +from ._patch import * # type: ignore # pylint: disable=unused-wildcard-import +from ._patch import patch_sdk as _patch_sdk + __all__ = [ - 'TemplateSpecsOperations', - 'TemplateSpecVersionsOperations', + "TemplateSpecsOperations", + "TemplateSpecVersionsOperations", ] +__all__.extend([p for p in _patch_all if p not in __all__]) +_patch_sdk() diff --git a/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/templatespecs/v2021_05_01/operations/_operations.py b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/templatespecs/v2021_05_01/operations/_operations.py index af1c0f1abbb92..adbabacb00aa7 100644 --- a/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/templatespecs/v2021_05_01/operations/_operations.py +++ b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/templatespecs/v2021_05_01/operations/_operations.py @@ -6,539 +6,611 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -from typing import Any, Callable, Dict, Iterable, Optional, TypeVar, Union - -from msrest import Serializer - -from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error +from typing import Any, Callable, Dict, IO, Iterable, Optional, TypeVar, Union, overload +from urllib.parse import parse_qs, urljoin, urlparse + +from azure.core.exceptions import ( + ClientAuthenticationError, + HttpResponseError, + ResourceExistsError, + ResourceNotFoundError, + ResourceNotModifiedError, + map_error, +) from azure.core.paging import ItemPaged from azure.core.pipeline import PipelineResponse from azure.core.pipeline.transport import HttpResponse from azure.core.rest import HttpRequest from azure.core.tracing.decorator import distributed_trace +from azure.core.utils import case_insensitive_dict from azure.mgmt.core.exceptions import ARMErrorFormat from .. import models as _models +from ..._serialization import Serializer from .._vendor import _convert_request, _format_url_section -T = TypeVar('T') -JSONType = Any + +T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] _SERIALIZER = Serializer() _SERIALIZER.client_side_validation = False + def build_template_specs_create_or_update_request( - subscription_id: str, - resource_group_name: str, - template_spec_name: str, - *, - json: JSONType = None, - content: Any = None, - **kwargs: Any + resource_group_name: str, template_spec_name: str, subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2021-05-01") # type: str - content_type = kwargs.pop('content_type', None) # type: Optional[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-05-01")) # type: str + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + accept = _headers.pop("Accept", "application/json") - accept = "application/json" # Construct URL - _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Resources/templateSpecs/{templateSpecName}") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Resources/templateSpecs/{templateSpecName}", + ) # pylint: disable=line-too-long path_format_arguments = { - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._\(\)]+$'), - "templateSpecName": _SERIALIZER.url("template_spec_name", template_spec_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._\(\)]+$'), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url( + "resource_group_name", resource_group_name, "str", max_length=90, min_length=1, pattern=r"^[-\w\._\(\)]+$" + ), + "templateSpecName": _SERIALIZER.url( + "template_spec_name", template_spec_name, "str", max_length=90, min_length=1, pattern=r"^[-\w\._\(\)]+$" + ), } _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] if content_type is not None: - _header_parameters['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') - _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers["Content-Type"] = _SERIALIZER.header("content_type", content_type, "str") + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - return HttpRequest( - method="PUT", - url=_url, - params=_query_parameters, - headers=_header_parameters, - json=json, - content=content, - **kwargs - ) + return HttpRequest(method="PUT", url=_url, params=_params, headers=_headers, **kwargs) def build_template_specs_update_request( - subscription_id: str, - resource_group_name: str, - template_spec_name: str, - *, - json: JSONType = None, - content: Any = None, - **kwargs: Any + resource_group_name: str, template_spec_name: str, subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2021-05-01") # type: str - content_type = kwargs.pop('content_type', None) # type: Optional[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-05-01")) # type: str + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + accept = _headers.pop("Accept", "application/json") - accept = "application/json" # Construct URL - _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Resources/templateSpecs/{templateSpecName}") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Resources/templateSpecs/{templateSpecName}", + ) # pylint: disable=line-too-long path_format_arguments = { - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._\(\)]+$'), - "templateSpecName": _SERIALIZER.url("template_spec_name", template_spec_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._\(\)]+$'), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url( + "resource_group_name", resource_group_name, "str", max_length=90, min_length=1, pattern=r"^[-\w\._\(\)]+$" + ), + "templateSpecName": _SERIALIZER.url( + "template_spec_name", template_spec_name, "str", max_length=90, min_length=1, pattern=r"^[-\w\._\(\)]+$" + ), } _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] if content_type is not None: - _header_parameters['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') - _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers["Content-Type"] = _SERIALIZER.header("content_type", content_type, "str") + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - return HttpRequest( - method="PATCH", - url=_url, - params=_query_parameters, - headers=_header_parameters, - json=json, - content=content, - **kwargs - ) + return HttpRequest(method="PATCH", url=_url, params=_params, headers=_headers, **kwargs) def build_template_specs_get_request( - subscription_id: str, resource_group_name: str, template_spec_name: str, + subscription_id: str, *, expand: Optional[Union[str, "_models.TemplateSpecExpandKind"]] = None, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2021-05-01") # type: 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-05-01")) # type: str + accept = _headers.pop("Accept", "application/json") - accept = "application/json" # Construct URL - _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Resources/templateSpecs/{templateSpecName}") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Resources/templateSpecs/{templateSpecName}", + ) # pylint: disable=line-too-long path_format_arguments = { - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._\(\)]+$'), - "templateSpecName": _SERIALIZER.url("template_spec_name", template_spec_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._\(\)]+$'), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url( + "resource_group_name", resource_group_name, "str", max_length=90, min_length=1, pattern=r"^[-\w\._\(\)]+$" + ), + "templateSpecName": _SERIALIZER.url( + "template_spec_name", template_spec_name, "str", max_length=90, min_length=1, pattern=r"^[-\w\._\(\)]+$" + ), } _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] if expand is not None: - _query_parameters['$expand'] = _SERIALIZER.query("expand", expand, 'str') - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["$expand"] = _SERIALIZER.query("expand", expand, "str") + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - return HttpRequest( - method="GET", - url=_url, - params=_query_parameters, - headers=_header_parameters, - **kwargs - ) + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) def build_template_specs_delete_request( - subscription_id: str, - resource_group_name: str, - template_spec_name: str, - **kwargs: Any + resource_group_name: str, template_spec_name: str, subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2021-05-01") # type: 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-05-01")) # type: str + accept = _headers.pop("Accept", "application/json") - accept = "application/json" # Construct URL - _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Resources/templateSpecs/{templateSpecName}") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Resources/templateSpecs/{templateSpecName}", + ) # pylint: disable=line-too-long path_format_arguments = { - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._\(\)]+$'), - "templateSpecName": _SERIALIZER.url("template_spec_name", template_spec_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._\(\)]+$'), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url( + "resource_group_name", resource_group_name, "str", max_length=90, min_length=1, pattern=r"^[-\w\._\(\)]+$" + ), + "templateSpecName": _SERIALIZER.url( + "template_spec_name", template_spec_name, "str", max_length=90, min_length=1, pattern=r"^[-\w\._\(\)]+$" + ), } _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - return HttpRequest( - method="DELETE", - url=_url, - params=_query_parameters, - headers=_header_parameters, - **kwargs - ) + return HttpRequest(method="DELETE", url=_url, params=_params, headers=_headers, **kwargs) def build_template_specs_list_by_subscription_request( - subscription_id: str, - *, - expand: Optional[Union[str, "_models.TemplateSpecExpandKind"]] = None, - **kwargs: Any + subscription_id: str, *, expand: Optional[Union[str, "_models.TemplateSpecExpandKind"]] = None, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2021-05-01") # type: 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-05-01")) # type: str + accept = _headers.pop("Accept", "application/json") - accept = "application/json" # Construct URL _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/providers/Microsoft.Resources/templateSpecs/") path_format_arguments = { - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), } _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] if expand is not None: - _query_parameters['$expand'] = _SERIALIZER.query("expand", expand, 'str') - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["$expand"] = _SERIALIZER.query("expand", expand, "str") + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - return HttpRequest( - method="GET", - url=_url, - params=_query_parameters, - headers=_header_parameters, - **kwargs - ) + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) def build_template_specs_list_by_resource_group_request( - subscription_id: str, resource_group_name: str, + subscription_id: str, *, expand: Optional[Union[str, "_models.TemplateSpecExpandKind"]] = None, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2021-05-01") # type: 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-05-01")) # type: str + accept = _headers.pop("Accept", "application/json") - accept = "application/json" # Construct URL - _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Resources/templateSpecs/") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Resources/templateSpecs/", + ) # pylint: disable=line-too-long path_format_arguments = { - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._\(\)]+$'), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url( + "resource_group_name", resource_group_name, "str", max_length=90, min_length=1, pattern=r"^[-\w\._\(\)]+$" + ), } _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] if expand is not None: - _query_parameters['$expand'] = _SERIALIZER.query("expand", expand, 'str') - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["$expand"] = _SERIALIZER.query("expand", expand, "str") + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - return HttpRequest( - method="GET", - url=_url, - params=_query_parameters, - headers=_header_parameters, - **kwargs - ) + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) def build_template_spec_versions_create_or_update_request( - subscription_id: str, - resource_group_name: str, - template_spec_name: str, - template_spec_version: str, - *, - json: JSONType = None, - content: Any = None, - **kwargs: Any + resource_group_name: str, template_spec_name: str, template_spec_version: str, subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2021-05-01") # type: str - content_type = kwargs.pop('content_type', None) # type: Optional[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-05-01")) # type: str + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + accept = _headers.pop("Accept", "application/json") - accept = "application/json" # Construct URL - _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Resources/templateSpecs/{templateSpecName}/versions/{templateSpecVersion}") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Resources/templateSpecs/{templateSpecName}/versions/{templateSpecVersion}", + ) # pylint: disable=line-too-long path_format_arguments = { - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._\(\)]+$'), - "templateSpecName": _SERIALIZER.url("template_spec_name", template_spec_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._\(\)]+$'), - "templateSpecVersion": _SERIALIZER.url("template_spec_version", template_spec_version, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._\(\)]+$'), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url( + "resource_group_name", resource_group_name, "str", max_length=90, min_length=1, pattern=r"^[-\w\._\(\)]+$" + ), + "templateSpecName": _SERIALIZER.url( + "template_spec_name", template_spec_name, "str", max_length=90, min_length=1, pattern=r"^[-\w\._\(\)]+$" + ), + "templateSpecVersion": _SERIALIZER.url( + "template_spec_version", + template_spec_version, + "str", + max_length=90, + min_length=1, + pattern=r"^[-\w\._\(\)]+$", + ), } _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] if content_type is not None: - _header_parameters['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') - _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers["Content-Type"] = _SERIALIZER.header("content_type", content_type, "str") + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - return HttpRequest( - method="PUT", - url=_url, - params=_query_parameters, - headers=_header_parameters, - json=json, - content=content, - **kwargs - ) + return HttpRequest(method="PUT", url=_url, params=_params, headers=_headers, **kwargs) def build_template_spec_versions_update_request( - subscription_id: str, - resource_group_name: str, - template_spec_name: str, - template_spec_version: str, - *, - json: JSONType = None, - content: Any = None, - **kwargs: Any + resource_group_name: str, template_spec_name: str, template_spec_version: str, subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2021-05-01") # type: str - content_type = kwargs.pop('content_type', None) # type: Optional[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-05-01")) # type: str + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + accept = _headers.pop("Accept", "application/json") - accept = "application/json" # Construct URL - _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Resources/templateSpecs/{templateSpecName}/versions/{templateSpecVersion}") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Resources/templateSpecs/{templateSpecName}/versions/{templateSpecVersion}", + ) # pylint: disable=line-too-long path_format_arguments = { - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._\(\)]+$'), - "templateSpecName": _SERIALIZER.url("template_spec_name", template_spec_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._\(\)]+$'), - "templateSpecVersion": _SERIALIZER.url("template_spec_version", template_spec_version, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._\(\)]+$'), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url( + "resource_group_name", resource_group_name, "str", max_length=90, min_length=1, pattern=r"^[-\w\._\(\)]+$" + ), + "templateSpecName": _SERIALIZER.url( + "template_spec_name", template_spec_name, "str", max_length=90, min_length=1, pattern=r"^[-\w\._\(\)]+$" + ), + "templateSpecVersion": _SERIALIZER.url( + "template_spec_version", + template_spec_version, + "str", + max_length=90, + min_length=1, + pattern=r"^[-\w\._\(\)]+$", + ), } _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] if content_type is not None: - _header_parameters['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') - _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers["Content-Type"] = _SERIALIZER.header("content_type", content_type, "str") + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - return HttpRequest( - method="PATCH", - url=_url, - params=_query_parameters, - headers=_header_parameters, - json=json, - content=content, - **kwargs - ) + return HttpRequest(method="PATCH", url=_url, params=_params, headers=_headers, **kwargs) def build_template_spec_versions_get_request( - subscription_id: str, - resource_group_name: str, - template_spec_name: str, - template_spec_version: str, - **kwargs: Any + resource_group_name: str, template_spec_name: str, template_spec_version: str, subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2021-05-01") # type: 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-05-01")) # type: str + accept = _headers.pop("Accept", "application/json") - accept = "application/json" # Construct URL - _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Resources/templateSpecs/{templateSpecName}/versions/{templateSpecVersion}") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Resources/templateSpecs/{templateSpecName}/versions/{templateSpecVersion}", + ) # pylint: disable=line-too-long path_format_arguments = { - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._\(\)]+$'), - "templateSpecName": _SERIALIZER.url("template_spec_name", template_spec_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._\(\)]+$'), - "templateSpecVersion": _SERIALIZER.url("template_spec_version", template_spec_version, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._\(\)]+$'), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url( + "resource_group_name", resource_group_name, "str", max_length=90, min_length=1, pattern=r"^[-\w\._\(\)]+$" + ), + "templateSpecName": _SERIALIZER.url( + "template_spec_name", template_spec_name, "str", max_length=90, min_length=1, pattern=r"^[-\w\._\(\)]+$" + ), + "templateSpecVersion": _SERIALIZER.url( + "template_spec_version", + template_spec_version, + "str", + max_length=90, + min_length=1, + pattern=r"^[-\w\._\(\)]+$", + ), } _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - return HttpRequest( - method="GET", - url=_url, - params=_query_parameters, - headers=_header_parameters, - **kwargs - ) + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) def build_template_spec_versions_delete_request( - subscription_id: str, - resource_group_name: str, - template_spec_name: str, - template_spec_version: str, - **kwargs: Any + resource_group_name: str, template_spec_name: str, template_spec_version: str, subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2021-05-01") # type: 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-05-01")) # type: str + accept = _headers.pop("Accept", "application/json") - accept = "application/json" # Construct URL - _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Resources/templateSpecs/{templateSpecName}/versions/{templateSpecVersion}") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Resources/templateSpecs/{templateSpecName}/versions/{templateSpecVersion}", + ) # pylint: disable=line-too-long path_format_arguments = { - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._\(\)]+$'), - "templateSpecName": _SERIALIZER.url("template_spec_name", template_spec_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._\(\)]+$'), - "templateSpecVersion": _SERIALIZER.url("template_spec_version", template_spec_version, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._\(\)]+$'), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url( + "resource_group_name", resource_group_name, "str", max_length=90, min_length=1, pattern=r"^[-\w\._\(\)]+$" + ), + "templateSpecName": _SERIALIZER.url( + "template_spec_name", template_spec_name, "str", max_length=90, min_length=1, pattern=r"^[-\w\._\(\)]+$" + ), + "templateSpecVersion": _SERIALIZER.url( + "template_spec_version", + template_spec_version, + "str", + max_length=90, + min_length=1, + pattern=r"^[-\w\._\(\)]+$", + ), } _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - return HttpRequest( - method="DELETE", - url=_url, - params=_query_parameters, - headers=_header_parameters, - **kwargs - ) + return HttpRequest(method="DELETE", url=_url, params=_params, headers=_headers, **kwargs) def build_template_spec_versions_list_request( - subscription_id: str, - resource_group_name: str, - template_spec_name: str, - **kwargs: Any + resource_group_name: str, template_spec_name: str, subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2021-05-01") # type: 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-05-01")) # type: str + accept = _headers.pop("Accept", "application/json") - accept = "application/json" # Construct URL - _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Resources/templateSpecs/{templateSpecName}/versions") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Resources/templateSpecs/{templateSpecName}/versions", + ) # pylint: disable=line-too-long path_format_arguments = { - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._\(\)]+$'), - "templateSpecName": _SERIALIZER.url("template_spec_name", template_spec_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._\(\)]+$'), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url( + "resource_group_name", resource_group_name, "str", max_length=90, min_length=1, pattern=r"^[-\w\._\(\)]+$" + ), + "templateSpecName": _SERIALIZER.url( + "template_spec_name", template_spec_name, "str", max_length=90, min_length=1, pattern=r"^[-\w\._\(\)]+$" + ), } _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') - - return HttpRequest( - method="GET", - url=_url, - params=_query_parameters, - headers=_header_parameters, - **kwargs - ) - -class TemplateSpecsOperations(object): - """TemplateSpecsOperations operations. - - You should not instantiate this class directly. Instead, you should create a Client instance that - instantiates it for you and attaches it as an attribute. - - :ivar models: Alias to model classes used in this operation group. - :type models: ~azure.mgmt.resource.templatespecs.v2021_05_01.models - :param client: Client for service requests. - :param config: Configuration of service client. - :param serializer: An object model serializer. - :param deserializer: An object model deserializer. + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) + + +class TemplateSpecsOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. + + Instead, you should access the following operations through + :class:`~azure.mgmt.resource.templatespecs.v2021_05_01.TemplateSpecsClient`'s + :attr:`template_specs` attribute. """ models = _models - def __init__(self, client, config, serializer, deserializer): - self._client = client - self._serialize = serializer - self._deserialize = deserializer - self._config = config + def __init__(self, *args, **kwargs): + input_args = list(args) + self._client = input_args.pop(0) if input_args else kwargs.pop("client") + self._config = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") - @distributed_trace + @overload def create_or_update( self, resource_group_name: str, template_spec_name: str, - template_spec: "_models.TemplateSpec", + template_spec: _models.TemplateSpec, + *, + content_type: str = "application/json", **kwargs: Any - ) -> "_models.TemplateSpec": + ) -> _models.TemplateSpec: """Creates or updates a Template Spec. :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. :type resource_group_name: str - :param template_spec_name: Name of the Template Spec. + :param template_spec_name: Name of the Template Spec. Required. :type template_spec_name: str - :param template_spec: Template Spec supplied to the operation. + :param template_spec: Template Spec supplied to the operation. Required. :type template_spec: ~azure.mgmt.resource.templatespecs.v2021_05_01.models.TemplateSpec + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: TemplateSpec or the result of cls(response) + :rtype: ~azure.mgmt.resource.templatespecs.v2021_05_01.models.TemplateSpec + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + def create_or_update( + self, + resource_group_name: str, + template_spec_name: str, + template_spec: IO, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.TemplateSpec: + """Creates or updates a Template Spec. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param template_spec_name: Name of the Template Spec. Required. + :type template_spec_name: str + :param template_spec: Template Spec supplied to the operation. Required. + :type template_spec: IO + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: TemplateSpec, or the result of cls(response) + :return: TemplateSpec or the result of cls(response) :rtype: ~azure.mgmt.resource.templatespecs.v2021_05_01.models.TemplateSpec - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace + def create_or_update( + self, + resource_group_name: str, + template_spec_name: str, + template_spec: Union[_models.TemplateSpec, IO], + **kwargs: Any + ) -> _models.TemplateSpec: + """Creates or updates a Template Spec. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param template_spec_name: Name of the Template Spec. Required. + :type template_spec_name: str + :param template_spec: Template Spec supplied to the operation. Is either a model type or a IO + type. Required. + :type template_spec: ~azure.mgmt.resource.templatespecs.v2021_05_01.models.TemplateSpec or IO + :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. + Default value is None. + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: TemplateSpec or the result of cls(response) + :rtype: ~azure.mgmt.resource.templatespecs.v2021_05_01.models.TemplateSpec + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.TemplateSpec"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', "2021-05-01") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-05-01")) # type: str + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.TemplateSpec] - _json = self._serialize.body(template_spec, 'TemplateSpec') + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(template_spec, (IO, bytes)): + _content = template_spec + else: + _json = self._serialize.body(template_spec, "TemplateSpec") request = build_template_specs_create_or_update_request( - subscription_id=self._config.subscription_id, resource_group_name=resource_group_name, template_spec_name=template_spec_name, + subscription_id=self._config.subscription_id, api_version=api_version, content_type=content_type, json=_json, - template_url=self.create_or_update.metadata['url'], + content=_content, + template_url=self.create_or_update.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200, 201]: @@ -547,73 +619,149 @@ def create_or_update( raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) if response.status_code == 200: - deserialized = self._deserialize('TemplateSpec', pipeline_response) + deserialized = self._deserialize("TemplateSpec", pipeline_response) if response.status_code == 201: - deserialized = self._deserialize('TemplateSpec', pipeline_response) + deserialized = self._deserialize("TemplateSpec", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - create_or_update.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Resources/templateSpecs/{templateSpecName}"} # type: ignore - + create_or_update.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Resources/templateSpecs/{templateSpecName}"} # type: ignore - @distributed_trace + @overload def update( self, resource_group_name: str, template_spec_name: str, - template_spec: Optional["_models.TemplateSpecUpdateModel"] = None, + template_spec: Optional[_models.TemplateSpecUpdateModel] = None, + *, + content_type: str = "application/json", **kwargs: Any - ) -> "_models.TemplateSpec": + ) -> _models.TemplateSpec: """Updates Template Spec tags with specified values. :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. :type resource_group_name: str - :param template_spec_name: Name of the Template Spec. + :param template_spec_name: Name of the Template Spec. Required. :type template_spec_name: str :param template_spec: Template Spec resource with the tags to be updated. Default value is None. :type template_spec: ~azure.mgmt.resource.templatespecs.v2021_05_01.models.TemplateSpecUpdateModel + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: TemplateSpec or the result of cls(response) + :rtype: ~azure.mgmt.resource.templatespecs.v2021_05_01.models.TemplateSpec + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + def update( + self, + resource_group_name: str, + template_spec_name: str, + template_spec: Optional[IO] = None, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.TemplateSpec: + """Updates Template Spec tags with specified values. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param template_spec_name: Name of the Template Spec. Required. + :type template_spec_name: str + :param template_spec: Template Spec resource with the tags to be updated. Default value is + None. + :type template_spec: IO + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: TemplateSpec or the result of cls(response) + :rtype: ~azure.mgmt.resource.templatespecs.v2021_05_01.models.TemplateSpec + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace + def update( + self, + resource_group_name: str, + template_spec_name: str, + template_spec: Optional[Union[_models.TemplateSpecUpdateModel, IO]] = None, + **kwargs: Any + ) -> _models.TemplateSpec: + """Updates Template Spec tags with specified values. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param template_spec_name: Name of the Template Spec. Required. + :type template_spec_name: str + :param template_spec: Template Spec resource with the tags to be updated. Is either a model + type or a IO type. Default value is None. + :type template_spec: + ~azure.mgmt.resource.templatespecs.v2021_05_01.models.TemplateSpecUpdateModel or IO + :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. + Default value is None. + :paramtype content_type: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: TemplateSpec, or the result of cls(response) + :return: TemplateSpec or the result of cls(response) :rtype: ~azure.mgmt.resource.templatespecs.v2021_05_01.models.TemplateSpec - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.TemplateSpec"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) - api_version = kwargs.pop('api_version', "2021-05-01") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - if template_spec is not None: - _json = self._serialize.body(template_spec, 'TemplateSpecUpdateModel') + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-05-01")) # type: str + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.TemplateSpec] + + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(template_spec, (IO, bytes)): + _content = template_spec else: - _json = None + if template_spec is not None: + _json = self._serialize.body(template_spec, "TemplateSpecUpdateModel") + else: + _json = None request = build_template_specs_update_request( - subscription_id=self._config.subscription_id, resource_group_name=resource_group_name, template_spec_name=template_spec_name, + subscription_id=self._config.subscription_id, api_version=api_version, content_type=content_type, json=_json, - template_url=self.update.metadata['url'], + content=_content, + template_url=self.update.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200]: @@ -621,15 +769,14 @@ def update( error = self._deserialize.failsafe_deserialize(_models.TemplateSpecsError, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - deserialized = self._deserialize('TemplateSpec', pipeline_response) + deserialized = self._deserialize("TemplateSpec", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - update.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Resources/templateSpecs/{templateSpecName}"} # type: ignore - + update.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Resources/templateSpecs/{templateSpecName}"} # type: ignore @distributed_trace def get( @@ -638,47 +785,54 @@ def get( template_spec_name: str, expand: Optional[Union[str, "_models.TemplateSpecExpandKind"]] = None, **kwargs: Any - ) -> "_models.TemplateSpec": + ) -> _models.TemplateSpec: """Gets a Template Spec with a given name. :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. :type resource_group_name: str - :param template_spec_name: Name of the Template Spec. + :param template_spec_name: Name of the Template Spec. Required. :type template_spec_name: str :param expand: Allows for expansion of additional Template Spec details in the response. - Optional. Default value is None. + Optional. "versions" Default value is None. :type expand: str or ~azure.mgmt.resource.templatespecs.v2021_05_01.models.TemplateSpecExpandKind :keyword callable cls: A custom type or function that will be passed the direct response - :return: TemplateSpec, or the result of cls(response) + :return: TemplateSpec or the result of cls(response) :rtype: ~azure.mgmt.resource.templatespecs.v2021_05_01.models.TemplateSpec - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.TemplateSpec"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + 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', "2021-05-01") # type: str + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-05-01")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[_models.TemplateSpec] - request = build_template_specs_get_request( - subscription_id=self._config.subscription_id, resource_group_name=resource_group_name, template_spec_name=template_spec_name, - api_version=api_version, + subscription_id=self._config.subscription_id, expand=expand, - template_url=self.get.metadata['url'], + api_version=api_version, + template_url=self.get.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200]: @@ -686,59 +840,62 @@ def get( error = self._deserialize.failsafe_deserialize(_models.TemplateSpecsError, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - deserialized = self._deserialize('TemplateSpec', pipeline_response) + deserialized = self._deserialize("TemplateSpec", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - get.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Resources/templateSpecs/{templateSpecName}"} # type: ignore - + get.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Resources/templateSpecs/{templateSpecName}"} # type: ignore @distributed_trace def delete( # pylint: disable=inconsistent-return-statements - self, - resource_group_name: str, - template_spec_name: str, - **kwargs: Any + self, resource_group_name: str, template_spec_name: str, **kwargs: Any ) -> None: """Deletes a Template Spec by name. When operation completes, status code 200 returned without content. :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. :type resource_group_name: str - :param template_spec_name: Name of the Template Spec. + :param template_spec_name: Name of the Template Spec. Required. :type template_spec_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: None, or the result of cls(response) + :return: None or the result of cls(response) :rtype: None - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType[None] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) - api_version = kwargs.pop('api_version', "2021-05-01") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-05-01")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[None] - request = build_template_specs_delete_request( - subscription_id=self._config.subscription_id, resource_group_name=resource_group_name, template_spec_name=template_spec_name, + subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.delete.metadata['url'], + template_url=self.delete.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200, 204]: @@ -749,55 +906,60 @@ def delete( # pylint: disable=inconsistent-return-statements if cls: return cls(pipeline_response, None, {}) - delete.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Resources/templateSpecs/{templateSpecName}"} # type: ignore - + delete.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Resources/templateSpecs/{templateSpecName}"} # type: ignore @distributed_trace def list_by_subscription( - self, - expand: Optional[Union[str, "_models.TemplateSpecExpandKind"]] = None, - **kwargs: Any - ) -> Iterable["_models.TemplateSpecsListResult"]: + self, expand: Optional[Union[str, "_models.TemplateSpecExpandKind"]] = None, **kwargs: Any + ) -> Iterable["_models.TemplateSpec"]: """Lists all the Template Specs within the specified subscriptions. :param expand: Allows for expansion of additional Template Spec details in the response. - Optional. Default value is None. + Optional. "versions" Default value is None. :type expand: str or ~azure.mgmt.resource.templatespecs.v2021_05_01.models.TemplateSpecExpandKind :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either TemplateSpecsListResult or the result of - cls(response) + :return: An iterator like instance of either TemplateSpec or the result of cls(response) :rtype: - ~azure.core.paging.ItemPaged[~azure.mgmt.resource.templatespecs.v2021_05_01.models.TemplateSpecsListResult] - :raises: ~azure.core.exceptions.HttpResponseError + ~azure.core.paging.ItemPaged[~azure.mgmt.resource.templatespecs.v2021_05_01.models.TemplateSpec] + :raises ~azure.core.exceptions.HttpResponseError: """ - api_version = kwargs.pop('api_version', "2021-05-01") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-05-01")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[_models.TemplateSpecsListResult] - cls = kwargs.pop('cls', None) # type: ClsType["_models.TemplateSpecsListResult"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) + def prepare_request(next_link=None): if not next_link: - + request = build_template_specs_list_by_subscription_request( subscription_id=self._config.subscription_id, - api_version=api_version, expand=expand, - template_url=self.list_by_subscription.metadata['url'], + api_version=api_version, + template_url=self.list_by_subscription.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore else: - - request = build_template_specs_list_by_subscription_request( - subscription_id=self._config.subscription_id, - template_url=next_link, - ) + # make call to next link with the client's api-version + _parsed_next_link = urlparse(next_link) + _next_request_params = case_insensitive_dict(parse_qs(_parsed_next_link.query)) + _next_request_params["api-version"] = self._config.api_version + request = HttpRequest("GET", urljoin(next_link, _parsed_next_link.path), params=_next_request_params) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore request.method = "GET" return request @@ -811,10 +973,8 @@ def extract_data(pipeline_response): def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) response = pipeline_response.http_response @@ -825,11 +985,9 @@ def get_next(next_link=None): return pipeline_response + return ItemPaged(get_next, extract_data) - return ItemPaged( - get_next, extract_data - ) - list_by_subscription.metadata = {'url': "/subscriptions/{subscriptionId}/providers/Microsoft.Resources/templateSpecs/"} # type: ignore + list_by_subscription.metadata = {"url": "/subscriptions/{subscriptionId}/providers/Microsoft.Resources/templateSpecs/"} # type: ignore @distributed_trace def list_by_resource_group( @@ -837,51 +995,59 @@ def list_by_resource_group( resource_group_name: str, expand: Optional[Union[str, "_models.TemplateSpecExpandKind"]] = None, **kwargs: Any - ) -> Iterable["_models.TemplateSpecsListResult"]: + ) -> Iterable["_models.TemplateSpec"]: """Lists all the Template Specs within the specified resource group. :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. :type resource_group_name: str :param expand: Allows for expansion of additional Template Spec details in the response. - Optional. Default value is None. + Optional. "versions" Default value is None. :type expand: str or ~azure.mgmt.resource.templatespecs.v2021_05_01.models.TemplateSpecExpandKind :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either TemplateSpecsListResult or the result of - cls(response) + :return: An iterator like instance of either TemplateSpec or the result of cls(response) :rtype: - ~azure.core.paging.ItemPaged[~azure.mgmt.resource.templatespecs.v2021_05_01.models.TemplateSpecsListResult] - :raises: ~azure.core.exceptions.HttpResponseError + ~azure.core.paging.ItemPaged[~azure.mgmt.resource.templatespecs.v2021_05_01.models.TemplateSpec] + :raises ~azure.core.exceptions.HttpResponseError: """ - api_version = kwargs.pop('api_version', "2021-05-01") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-05-01")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[_models.TemplateSpecsListResult] - cls = kwargs.pop('cls', None) # type: ClsType["_models.TemplateSpecsListResult"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) + def prepare_request(next_link=None): if not next_link: - + request = build_template_specs_list_by_resource_group_request( - subscription_id=self._config.subscription_id, resource_group_name=resource_group_name, - api_version=api_version, + subscription_id=self._config.subscription_id, expand=expand, - template_url=self.list_by_resource_group.metadata['url'], + 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.url = self._client.format_url(request.url) # type: ignore else: - - request = build_template_specs_list_by_resource_group_request( - subscription_id=self._config.subscription_id, - resource_group_name=resource_group_name, - template_url=next_link, - ) + # make call to next link with the client's api-version + _parsed_next_link = urlparse(next_link) + _next_request_params = case_insensitive_dict(parse_qs(_parsed_next_link.query)) + _next_request_params["api-version"] = self._config.api_version + request = HttpRequest("GET", urljoin(next_link, _parsed_next_link.path), params=_next_request_params) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore request.method = "GET" return request @@ -895,10 +1061,8 @@ def extract_data(pipeline_response): def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) response = pipeline_response.http_response @@ -909,87 +1073,166 @@ def get_next(next_link=None): return pipeline_response + return ItemPaged(get_next, extract_data) - return ItemPaged( - get_next, extract_data - ) - list_by_resource_group.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Resources/templateSpecs/"} # type: ignore -class TemplateSpecVersionsOperations(object): - """TemplateSpecVersionsOperations operations. - - You should not instantiate this class directly. Instead, you should create a Client instance that - instantiates it for you and attaches it as an attribute. - - :ivar models: Alias to model classes used in this operation group. - :type models: ~azure.mgmt.resource.templatespecs.v2021_05_01.models - :param client: Client for service requests. - :param config: Configuration of service client. - :param serializer: An object model serializer. - :param deserializer: An object model deserializer. + list_by_resource_group.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Resources/templateSpecs/"} # type: ignore + + +class TemplateSpecVersionsOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. + + Instead, you should access the following operations through + :class:`~azure.mgmt.resource.templatespecs.v2021_05_01.TemplateSpecsClient`'s + :attr:`template_spec_versions` attribute. """ models = _models - def __init__(self, client, config, serializer, deserializer): - self._client = client - self._serialize = serializer - self._deserialize = deserializer - self._config = config + def __init__(self, *args, **kwargs): + input_args = list(args) + self._client = input_args.pop(0) if input_args else kwargs.pop("client") + self._config = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") - @distributed_trace + @overload def create_or_update( self, resource_group_name: str, template_spec_name: str, template_spec_version: str, - template_spec_version_model: "_models.TemplateSpecVersion", + template_spec_version_model: _models.TemplateSpecVersion, + *, + content_type: str = "application/json", **kwargs: Any - ) -> "_models.TemplateSpecVersion": + ) -> _models.TemplateSpecVersion: """Creates or updates a Template Spec version. :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. :type resource_group_name: str - :param template_spec_name: Name of the Template Spec. + :param template_spec_name: Name of the Template Spec. Required. :type template_spec_name: str - :param template_spec_version: The version of the Template Spec. + :param template_spec_version: The version of the Template Spec. Required. :type template_spec_version: str - :param template_spec_version_model: Template Spec Version supplied to the operation. + :param template_spec_version_model: Template Spec Version supplied to the operation. Required. :type template_spec_version_model: ~azure.mgmt.resource.templatespecs.v2021_05_01.models.TemplateSpecVersion + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: TemplateSpecVersion or the result of cls(response) + :rtype: ~azure.mgmt.resource.templatespecs.v2021_05_01.models.TemplateSpecVersion + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + def create_or_update( + self, + resource_group_name: str, + template_spec_name: str, + template_spec_version: str, + template_spec_version_model: IO, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.TemplateSpecVersion: + """Creates or updates a Template Spec version. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param template_spec_name: Name of the Template Spec. Required. + :type template_spec_name: str + :param template_spec_version: The version of the Template Spec. Required. + :type template_spec_version: str + :param template_spec_version_model: Template Spec Version supplied to the operation. Required. + :type template_spec_version_model: IO + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: TemplateSpecVersion or the result of cls(response) + :rtype: ~azure.mgmt.resource.templatespecs.v2021_05_01.models.TemplateSpecVersion + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace + def create_or_update( + self, + resource_group_name: str, + template_spec_name: str, + template_spec_version: str, + template_spec_version_model: Union[_models.TemplateSpecVersion, IO], + **kwargs: Any + ) -> _models.TemplateSpecVersion: + """Creates or updates a Template Spec version. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param template_spec_name: Name of the Template Spec. Required. + :type template_spec_name: str + :param template_spec_version: The version of the Template Spec. Required. + :type template_spec_version: str + :param template_spec_version_model: Template Spec Version supplied to the operation. Is either + a model type or a IO type. Required. + :type template_spec_version_model: + ~azure.mgmt.resource.templatespecs.v2021_05_01.models.TemplateSpecVersion or IO + :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. + Default value is None. + :paramtype content_type: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: TemplateSpecVersion, or the result of cls(response) + :return: TemplateSpecVersion or the result of cls(response) :rtype: ~azure.mgmt.resource.templatespecs.v2021_05_01.models.TemplateSpecVersion - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.TemplateSpecVersion"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) - api_version = kwargs.pop('api_version', "2021-05-01") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - _json = self._serialize.body(template_spec_version_model, 'TemplateSpecVersion') + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-05-01")) # type: str + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.TemplateSpecVersion] + + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(template_spec_version_model, (IO, bytes)): + _content = template_spec_version_model + else: + _json = self._serialize.body(template_spec_version_model, "TemplateSpecVersion") request = build_template_spec_versions_create_or_update_request( - subscription_id=self._config.subscription_id, resource_group_name=resource_group_name, template_spec_name=template_spec_name, template_spec_version=template_spec_version, + subscription_id=self._config.subscription_id, api_version=api_version, content_type=content_type, json=_json, - template_url=self.create_or_update.metadata['url'], + content=_content, + template_url=self.create_or_update.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200, 201]: @@ -998,77 +1241,159 @@ def create_or_update( raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) if response.status_code == 200: - deserialized = self._deserialize('TemplateSpecVersion', pipeline_response) + deserialized = self._deserialize("TemplateSpecVersion", pipeline_response) if response.status_code == 201: - deserialized = self._deserialize('TemplateSpecVersion', pipeline_response) + deserialized = self._deserialize("TemplateSpecVersion", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - create_or_update.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Resources/templateSpecs/{templateSpecName}/versions/{templateSpecVersion}"} # type: ignore - + create_or_update.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Resources/templateSpecs/{templateSpecName}/versions/{templateSpecVersion}"} # type: ignore - @distributed_trace + @overload def update( self, resource_group_name: str, template_spec_name: str, template_spec_version: str, - template_spec_version_update_model: Optional["_models.TemplateSpecVersionUpdateModel"] = None, + template_spec_version_update_model: Optional[_models.TemplateSpecVersionUpdateModel] = None, + *, + content_type: str = "application/json", **kwargs: Any - ) -> "_models.TemplateSpecVersion": + ) -> _models.TemplateSpecVersion: """Updates Template Spec Version tags with specified values. :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. :type resource_group_name: str - :param template_spec_name: Name of the Template Spec. + :param template_spec_name: Name of the Template Spec. Required. :type template_spec_name: str - :param template_spec_version: The version of the Template Spec. + :param template_spec_version: The version of the Template Spec. Required. :type template_spec_version: str :param template_spec_version_update_model: Template Spec Version resource with the tags to be updated. Default value is None. :type template_spec_version_update_model: ~azure.mgmt.resource.templatespecs.v2021_05_01.models.TemplateSpecVersionUpdateModel + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: TemplateSpecVersion, or the result of cls(response) + :return: TemplateSpecVersion or the result of cls(response) :rtype: ~azure.mgmt.resource.templatespecs.v2021_05_01.models.TemplateSpecVersion - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + def update( + self, + resource_group_name: str, + template_spec_name: str, + template_spec_version: str, + template_spec_version_update_model: Optional[IO] = None, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.TemplateSpecVersion: + """Updates Template Spec Version tags with specified values. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param template_spec_name: Name of the Template Spec. Required. + :type template_spec_name: str + :param template_spec_version: The version of the Template Spec. Required. + :type template_spec_version: str + :param template_spec_version_update_model: Template Spec Version resource with the tags to be + updated. Default value is None. + :type template_spec_version_update_model: IO + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: TemplateSpecVersion or the result of cls(response) + :rtype: ~azure.mgmt.resource.templatespecs.v2021_05_01.models.TemplateSpecVersion + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace + def update( + self, + resource_group_name: str, + template_spec_name: str, + template_spec_version: str, + template_spec_version_update_model: Optional[Union[_models.TemplateSpecVersionUpdateModel, IO]] = None, + **kwargs: Any + ) -> _models.TemplateSpecVersion: + """Updates Template Spec Version tags with specified values. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param template_spec_name: Name of the Template Spec. Required. + :type template_spec_name: str + :param template_spec_version: The version of the Template Spec. Required. + :type template_spec_version: str + :param template_spec_version_update_model: Template Spec Version resource with the tags to be + updated. Is either a model type or a IO type. Default value is None. + :type template_spec_version_update_model: + ~azure.mgmt.resource.templatespecs.v2021_05_01.models.TemplateSpecVersionUpdateModel or IO + :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. + Default value is None. + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: TemplateSpecVersion or the result of cls(response) + :rtype: ~azure.mgmt.resource.templatespecs.v2021_05_01.models.TemplateSpecVersion + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.TemplateSpecVersion"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) - api_version = kwargs.pop('api_version', "2021-05-01") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - if template_spec_version_update_model is not None: - _json = self._serialize.body(template_spec_version_update_model, 'TemplateSpecVersionUpdateModel') + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-05-01")) # type: str + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.TemplateSpecVersion] + + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(template_spec_version_update_model, (IO, bytes)): + _content = template_spec_version_update_model else: - _json = None + if template_spec_version_update_model is not None: + _json = self._serialize.body(template_spec_version_update_model, "TemplateSpecVersionUpdateModel") + else: + _json = None request = build_template_spec_versions_update_request( - subscription_id=self._config.subscription_id, resource_group_name=resource_group_name, template_spec_name=template_spec_name, template_spec_version=template_spec_version, + subscription_id=self._config.subscription_id, api_version=api_version, content_type=content_type, json=_json, - template_url=self.update.metadata['url'], + content=_content, + template_url=self.update.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200]: @@ -1076,62 +1401,64 @@ def update( error = self._deserialize.failsafe_deserialize(_models.TemplateSpecsError, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - deserialized = self._deserialize('TemplateSpecVersion', pipeline_response) + deserialized = self._deserialize("TemplateSpecVersion", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - update.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Resources/templateSpecs/{templateSpecName}/versions/{templateSpecVersion}"} # type: ignore - + update.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Resources/templateSpecs/{templateSpecName}/versions/{templateSpecVersion}"} # type: ignore @distributed_trace def get( - self, - resource_group_name: str, - template_spec_name: str, - template_spec_version: str, - **kwargs: Any - ) -> "_models.TemplateSpecVersion": + self, resource_group_name: str, template_spec_name: str, template_spec_version: str, **kwargs: Any + ) -> _models.TemplateSpecVersion: """Gets a Template Spec version from a specific Template Spec. :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. :type resource_group_name: str - :param template_spec_name: Name of the Template Spec. + :param template_spec_name: Name of the Template Spec. Required. :type template_spec_name: str - :param template_spec_version: The version of the Template Spec. + :param template_spec_version: The version of the Template Spec. Required. :type template_spec_version: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: TemplateSpecVersion, or the result of cls(response) + :return: TemplateSpecVersion or the result of cls(response) :rtype: ~azure.mgmt.resource.templatespecs.v2021_05_01.models.TemplateSpecVersion - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.TemplateSpecVersion"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + 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', "2021-05-01") # type: str + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-05-01")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[_models.TemplateSpecVersion] - request = build_template_spec_versions_get_request( - subscription_id=self._config.subscription_id, resource_group_name=resource_group_name, template_spec_name=template_spec_name, template_spec_version=template_spec_version, + subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.get.metadata['url'], + template_url=self.get.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200]: @@ -1139,63 +1466,65 @@ def get( error = self._deserialize.failsafe_deserialize(_models.TemplateSpecsError, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - deserialized = self._deserialize('TemplateSpecVersion', pipeline_response) + deserialized = self._deserialize("TemplateSpecVersion", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - get.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Resources/templateSpecs/{templateSpecName}/versions/{templateSpecVersion}"} # type: ignore - + get.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Resources/templateSpecs/{templateSpecName}/versions/{templateSpecVersion}"} # type: ignore @distributed_trace def delete( # pylint: disable=inconsistent-return-statements - self, - resource_group_name: str, - template_spec_name: str, - template_spec_version: str, - **kwargs: Any + self, resource_group_name: str, template_spec_name: str, template_spec_version: str, **kwargs: Any ) -> None: """Deletes a specific version from a Template Spec. When operation completes, status code 200 returned without content. :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. :type resource_group_name: str - :param template_spec_name: Name of the Template Spec. + :param template_spec_name: Name of the Template Spec. Required. :type template_spec_name: str - :param template_spec_version: The version of the Template Spec. + :param template_spec_version: The version of the Template Spec. Required. :type template_spec_version: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: None, or the result of cls(response) + :return: None or the result of cls(response) :rtype: None - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType[None] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) - api_version = kwargs.pop('api_version', "2021-05-01") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-05-01")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[None] - request = build_template_spec_versions_delete_request( - subscription_id=self._config.subscription_id, resource_group_name=resource_group_name, template_spec_name=template_spec_name, template_spec_version=template_spec_version, + subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.delete.metadata['url'], + template_url=self.delete.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200, 204]: @@ -1206,59 +1535,62 @@ def delete( # pylint: disable=inconsistent-return-statements if cls: return cls(pipeline_response, None, {}) - delete.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Resources/templateSpecs/{templateSpecName}/versions/{templateSpecVersion}"} # type: ignore - + delete.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Resources/templateSpecs/{templateSpecName}/versions/{templateSpecVersion}"} # type: ignore @distributed_trace def list( - self, - resource_group_name: str, - template_spec_name: str, - **kwargs: Any - ) -> Iterable["_models.TemplateSpecVersionsListResult"]: + self, resource_group_name: str, template_spec_name: str, **kwargs: Any + ) -> Iterable["_models.TemplateSpecVersion"]: """Lists all the Template Spec versions in the specified Template Spec. :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. :type resource_group_name: str - :param template_spec_name: Name of the Template Spec. + :param template_spec_name: Name of the Template Spec. Required. :type template_spec_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either TemplateSpecVersionsListResult or the result of - cls(response) + :return: An iterator like instance of either TemplateSpecVersion or the result of cls(response) :rtype: - ~azure.core.paging.ItemPaged[~azure.mgmt.resource.templatespecs.v2021_05_01.models.TemplateSpecVersionsListResult] - :raises: ~azure.core.exceptions.HttpResponseError + ~azure.core.paging.ItemPaged[~azure.mgmt.resource.templatespecs.v2021_05_01.models.TemplateSpecVersion] + :raises ~azure.core.exceptions.HttpResponseError: """ - api_version = kwargs.pop('api_version', "2021-05-01") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-05-01")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[_models.TemplateSpecVersionsListResult] - cls = kwargs.pop('cls', None) # type: ClsType["_models.TemplateSpecVersionsListResult"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) + def prepare_request(next_link=None): if not next_link: - + request = build_template_spec_versions_list_request( - subscription_id=self._config.subscription_id, resource_group_name=resource_group_name, template_spec_name=template_spec_name, + subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.list.metadata['url'], + template_url=self.list.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore else: - - request = build_template_spec_versions_list_request( - subscription_id=self._config.subscription_id, - resource_group_name=resource_group_name, - template_spec_name=template_spec_name, - template_url=next_link, - ) + # make call to next link with the client's api-version + _parsed_next_link = urlparse(next_link) + _next_request_params = case_insensitive_dict(parse_qs(_parsed_next_link.query)) + _next_request_params["api-version"] = self._config.api_version + request = HttpRequest("GET", urljoin(next_link, _parsed_next_link.path), params=_next_request_params) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore request.method = "GET" return request @@ -1272,10 +1604,8 @@ def extract_data(pipeline_response): def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) response = pipeline_response.http_response @@ -1286,8 +1616,6 @@ def get_next(next_link=None): return pipeline_response + return ItemPaged(get_next, extract_data) - return ItemPaged( - get_next, extract_data - ) - list.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Resources/templateSpecs/{templateSpecName}/versions"} # type: ignore + list.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Resources/templateSpecs/{templateSpecName}/versions"} # type: ignore diff --git a/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/templatespecs/v2021_05_01/operations/_patch.py b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/templatespecs/v2021_05_01/operations/_patch.py new file mode 100644 index 0000000000000..f7dd32510333d --- /dev/null +++ b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/templatespecs/v2021_05_01/operations/_patch.py @@ -0,0 +1,20 @@ +# ------------------------------------ +# Copyright (c) Microsoft Corporation. +# Licensed under the MIT License. +# ------------------------------------ +"""Customize generated code here. + +Follow our quickstart for examples: https://aka.ms/azsdk/python/dpcodegen/python/customize +""" +from typing import List + +__all__: List[str] = [] # Add all objects you want publicly available to users at this package level + + +def patch_sdk(): + """Do not remove from this file. + + `patch_sdk` is a last resort escape hatch that allows you to do customizations + you can't accomplish using the techniques described in + https://aka.ms/azsdk/python/dpcodegen/python/customize + """ diff --git a/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/templatespecs/v2022_02_01/__init__.py b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/templatespecs/v2022_02_01/__init__.py index 4005d4a7201ea..1d05585f5c592 100644 --- a/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/templatespecs/v2022_02_01/__init__.py +++ b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/templatespecs/v2022_02_01/__init__.py @@ -10,9 +10,15 @@ from ._version import VERSION __version__ = VERSION -__all__ = ['TemplateSpecsClient'] -# `._patch.py` is used for handwritten extensions to the generated code -# Example: https://github.com/Azure/azure-sdk-for-python/blob/main/doc/dev/customize_code/how-to-patch-sdk-code.md -from ._patch import patch_sdk -patch_sdk() +try: + from ._patch import __all__ as _patch_all + from ._patch import * # type: ignore # pylint: disable=unused-wildcard-import +except ImportError: + _patch_all = [] +from ._patch import patch_sdk as _patch_sdk + +__all__ = ["TemplateSpecsClient"] +__all__.extend([p for p in _patch_all if p not in __all__]) + +_patch_sdk() diff --git a/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/templatespecs/v2022_02_01/_configuration.py b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/templatespecs/v2022_02_01/_configuration.py index 1aaff68b1960d..201e6695ccd3a 100644 --- a/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/templatespecs/v2022_02_01/_configuration.py +++ b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/templatespecs/v2022_02_01/_configuration.py @@ -25,23 +25,19 @@ class TemplateSpecsClientConfiguration(Configuration): # pylint: disable=too-ma Note that all parameters used to create this instance are saved as instance attributes. - :param credential: Credential needed for the client to connect to Azure. + :param credential: Credential needed for the client to connect to Azure. Required. :type credential: ~azure.core.credentials.TokenCredential :param subscription_id: Subscription Id which forms part of the URI for every service call. + Required. :type subscription_id: str :keyword api_version: Api Version. Default value is "2022-02-01". Note that overriding this default value may result in unsupported behavior. :paramtype api_version: str """ - def __init__( - self, - credential: "TokenCredential", - subscription_id: str, - **kwargs: Any - ) -> None: + def __init__(self, credential: "TokenCredential", subscription_id: str, **kwargs: Any) -> None: super(TemplateSpecsClientConfiguration, self).__init__(**kwargs) - api_version = kwargs.pop('api_version', "2022-02-01") # type: str + api_version = kwargs.pop("api_version", "2022-02-01") # type: str if credential is None: raise ValueError("Parameter 'credential' must not be None.") @@ -51,23 +47,24 @@ def __init__( self.credential = credential self.subscription_id = subscription_id self.api_version = api_version - self.credential_scopes = kwargs.pop('credential_scopes', ['https://management.azure.com/.default']) - kwargs.setdefault('sdk_moniker', 'mgmt-resource/{}'.format(VERSION)) + self.credential_scopes = kwargs.pop("credential_scopes", ["https://management.azure.com/.default"]) + kwargs.setdefault("sdk_moniker", "mgmt-resource/{}".format(VERSION)) self._configure(**kwargs) def _configure( - self, - **kwargs # type: Any + self, **kwargs # type: Any ): # type: (...) -> 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) - self.logging_policy = kwargs.get('logging_policy') or policies.NetworkTraceLoggingPolicy(**kwargs) - self.http_logging_policy = kwargs.get('http_logging_policy') or ARMHttpLoggingPolicy(**kwargs) - self.retry_policy = kwargs.get('retry_policy') or policies.RetryPolicy(**kwargs) - self.custom_hook_policy = kwargs.get('custom_hook_policy') or policies.CustomHookPolicy(**kwargs) - self.redirect_policy = kwargs.get('redirect_policy') or policies.RedirectPolicy(**kwargs) - self.authentication_policy = kwargs.get('authentication_policy') + 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) + self.logging_policy = kwargs.get("logging_policy") or policies.NetworkTraceLoggingPolicy(**kwargs) + self.http_logging_policy = kwargs.get("http_logging_policy") or ARMHttpLoggingPolicy(**kwargs) + self.retry_policy = kwargs.get("retry_policy") or policies.RetryPolicy(**kwargs) + self.custom_hook_policy = kwargs.get("custom_hook_policy") or policies.CustomHookPolicy(**kwargs) + self.redirect_policy = kwargs.get("redirect_policy") or policies.RedirectPolicy(**kwargs) + self.authentication_policy = kwargs.get("authentication_policy") if self.credential and not self.authentication_policy: - self.authentication_policy = ARMChallengeAuthenticationPolicy(self.credential, *self.credential_scopes, **kwargs) + self.authentication_policy = ARMChallengeAuthenticationPolicy( + self.credential, *self.credential_scopes, **kwargs + ) diff --git a/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/templatespecs/v2022_02_01/_metadata.json b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/templatespecs/v2022_02_01/_metadata.json index 268c0c939f4b5..04625b1ec7e11 100644 --- a/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/templatespecs/v2022_02_01/_metadata.json +++ b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/templatespecs/v2022_02_01/_metadata.json @@ -10,20 +10,20 @@ "azure_arm": true, "has_lro_operations": false, "client_side_validation": false, - "sync_imports": "{\"typing\": {\"azurecore\": {\"azure.core.credentials\": [\"TokenCredential\"]}}, \"regular\": {\"azurecore\": {\"azure.profiles\": [\"KnownProfiles\", \"ProfileDefinition\"], \"azure.profiles.multiapiclient\": [\"MultiApiClientMixin\"], \"azure.mgmt.core\": [\"ARMPipelineClient\"]}, \"local\": {\"._configuration\": [\"TemplateSpecsClientConfiguration\"]}, \"thirdparty\": {\"msrest\": [\"Deserializer\", \"Serializer\"]}}, \"conditional\": {\"stdlib\": {\"typing\": [\"Any\", \"Optional\"]}}}", - "async_imports": "{\"typing\": {\"azurecore\": {\"azure.core.credentials_async\": [\"AsyncTokenCredential\"], \"azure.core.credentials\": [\"TokenCredential\"]}}, \"regular\": {\"azurecore\": {\"azure.profiles\": [\"KnownProfiles\", \"ProfileDefinition\"], \"azure.profiles.multiapiclient\": [\"MultiApiClientMixin\"], \"azure.mgmt.core\": [\"AsyncARMPipelineClient\"]}, \"local\": {\"._configuration\": [\"TemplateSpecsClientConfiguration\"]}, \"thirdparty\": {\"msrest\": [\"Deserializer\", \"Serializer\"]}}, \"conditional\": {\"stdlib\": {\"typing\": [\"Any\", \"Optional\"]}}}" + "sync_imports": "{\"conditional\": {\"stdlib\": {\"typing\": [\"Any\", \"Optional\"]}}, \"regular\": {\"azurecore\": {\"azure.mgmt.core\": [\"ARMPipelineClient\"], \"azure.profiles\": [\"KnownProfiles\", \"ProfileDefinition\"], \"azure.profiles.multiapiclient\": [\"MultiApiClientMixin\"]}, \"local\": {\"._configuration\": [\"TemplateSpecsClientConfiguration\"], \".._serialization\": [\"Deserializer\", \"Serializer\"]}}, \"typing\": {\"azurecore\": {\"azure.core.credentials\": [\"TokenCredential\"]}}}", + "async_imports": "{\"conditional\": {\"stdlib\": {\"typing\": [\"Any\", \"Optional\"]}}, \"regular\": {\"azurecore\": {\"azure.mgmt.core\": [\"AsyncARMPipelineClient\"], \"azure.profiles\": [\"KnownProfiles\", \"ProfileDefinition\"], \"azure.profiles.multiapiclient\": [\"MultiApiClientMixin\"]}, \"local\": {\"._configuration\": [\"TemplateSpecsClientConfiguration\"], \"..._serialization\": [\"Deserializer\", \"Serializer\"]}}, \"typing\": {\"azurecore\": {\"azure.core.credentials_async\": [\"AsyncTokenCredential\"]}}}" }, "global_parameters": { "sync": { "credential": { - "signature": "credential, # type: \"TokenCredential\"", - "description": "Credential needed for the client to connect to Azure.", + "signature": "credential: \"TokenCredential\",", + "description": "Credential needed for the client to connect to Azure. Required.", "docstring_type": "~azure.core.credentials.TokenCredential", "required": true }, "subscription_id": { - "signature": "subscription_id, # type: str", - "description": "Subscription Id which forms part of the URI for every service call.", + "signature": "subscription_id: str,", + "description": "Subscription Id which forms part of the URI for every service call. Required.", "docstring_type": "str", "required": true } @@ -31,13 +31,13 @@ "async": { "credential": { "signature": "credential: \"AsyncTokenCredential\",", - "description": "Credential needed for the client to connect to Azure.", + "description": "Credential needed for the client to connect to Azure. Required.", "docstring_type": "~azure.core.credentials_async.AsyncTokenCredential", "required": true }, "subscription_id": { "signature": "subscription_id: str,", - "description": "Subscription Id which forms part of the URI for every service call.", + "description": "Subscription Id which forms part of the URI for every service call. Required.", "docstring_type": "str", "required": true } @@ -54,7 +54,7 @@ "required": false }, "base_url": { - "signature": "base_url=\"https://management.azure.com\", # type: str", + "signature": "base_url: str = \"https://management.azure.com\",", "description": "Service URL", "docstring_type": "str", "required": false diff --git a/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/templatespecs/v2022_02_01/_patch.py b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/templatespecs/v2022_02_01/_patch.py index 74e48ecd07cf3..f99e77fef9861 100644 --- a/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/templatespecs/v2022_02_01/_patch.py +++ b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/templatespecs/v2022_02_01/_patch.py @@ -28,4 +28,4 @@ # This file is used for handwritten extensions to the generated code. Example: # https://github.com/Azure/azure-sdk-for-python/blob/main/doc/dev/customize_code/how-to-patch-sdk-code.md def patch_sdk(): - pass \ No newline at end of file + pass diff --git a/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/templatespecs/v2022_02_01/_template_specs_client.py b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/templatespecs/v2022_02_01/_template_specs_client.py index a8ad7f1016f1d..3f7e3117824f0 100644 --- a/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/templatespecs/v2022_02_01/_template_specs_client.py +++ b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/templatespecs/v2022_02_01/_template_specs_client.py @@ -9,12 +9,11 @@ from copy import deepcopy from typing import Any, TYPE_CHECKING -from msrest import Deserializer, Serializer - from azure.core.rest import HttpRequest, HttpResponse from azure.mgmt.core import ARMPipelineClient from . import models +from .._serialization import Deserializer, Serializer from ._configuration import TemplateSpecsClientConfiguration from .operations import TemplateSpecVersionsOperations, TemplateSpecsOperations @@ -22,7 +21,8 @@ # pylint: disable=unused-import,ungrouped-imports from azure.core.credentials import TokenCredential -class TemplateSpecsClient: + +class TemplateSpecsClient: # pylint: disable=client-accepts-api-version-keyword """The APIs listed in this specification can be used to manage Template Spec resources through the Azure Resource Manager. @@ -32,9 +32,10 @@ class TemplateSpecsClient: :ivar template_spec_versions: TemplateSpecVersionsOperations operations :vartype template_spec_versions: azure.mgmt.resource.templatespecs.v2022_02_01.operations.TemplateSpecVersionsOperations - :param credential: Credential needed for the client to connect to Azure. + :param credential: Credential needed for the client to connect to Azure. Required. :type credential: ~azure.core.credentials.TokenCredential :param subscription_id: Subscription Id which forms part of the URI for every service call. + Required. :type subscription_id: str :param base_url: Service URL. Default value is "https://management.azure.com". :type base_url: str @@ -50,7 +51,9 @@ def __init__( base_url: str = "https://management.azure.com", **kwargs: Any ) -> None: - self._config = TemplateSpecsClientConfiguration(credential=credential, subscription_id=subscription_id, **kwargs) + self._config = TemplateSpecsClientConfiguration( + credential=credential, subscription_id=subscription_id, **kwargs + ) self._client = ARMPipelineClient(base_url=base_url, config=self._config, **kwargs) client_models = {k: v for k, v in models.__dict__.items() if isinstance(v, type)} @@ -58,14 +61,11 @@ def __init__( self._deserialize = Deserializer(client_models) self._serialize.client_side_validation = False self.template_specs = TemplateSpecsOperations(self._client, self._config, self._serialize, self._deserialize) - self.template_spec_versions = TemplateSpecVersionsOperations(self._client, self._config, self._serialize, self._deserialize) - + self.template_spec_versions = TemplateSpecVersionsOperations( + self._client, self._config, self._serialize, self._deserialize + ) - def _send_request( - self, - request: HttpRequest, - **kwargs: Any - ) -> HttpResponse: + def _send_request(self, request: HttpRequest, **kwargs: Any) -> HttpResponse: """Runs the network request through the client's chained policies. >>> from azure.core.rest import HttpRequest @@ -74,7 +74,7 @@ def _send_request( >>> response = client._send_request(request) - For more information on this code flow, see https://aka.ms/azsdk/python/protocol/quickstart + For more information on this code flow, see https://aka.ms/azsdk/dpcodegen/python/send_request :param request: The network request you want to make. Required. :type request: ~azure.core.rest.HttpRequest diff --git a/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/templatespecs/v2022_02_01/_vendor.py b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/templatespecs/v2022_02_01/_vendor.py index 138f663c53a4e..9aad73fc743e7 100644 --- a/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/templatespecs/v2022_02_01/_vendor.py +++ b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/templatespecs/v2022_02_01/_vendor.py @@ -7,6 +7,7 @@ from azure.core.pipeline.transport import HttpRequest + def _convert_request(request, files=None): data = request.content if not files else None request = HttpRequest(method=request.method, url=request.url, headers=request.headers, data=data) @@ -14,6 +15,7 @@ def _convert_request(request, files=None): request.set_formdata_body(files) return request + def _format_url_section(template, **kwargs): components = template.split("/") while components: @@ -21,7 +23,5 @@ def _format_url_section(template, **kwargs): 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 - ] + components = [c for c in formatted_components if "{}".format(key.args[0]) not in c] template = "/".join(components) diff --git a/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/templatespecs/v2022_02_01/_version.py b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/templatespecs/v2022_02_01/_version.py index a012ac01c480c..e5754a47ce68f 100644 --- a/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/templatespecs/v2022_02_01/_version.py +++ b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/templatespecs/v2022_02_01/_version.py @@ -6,4 +6,4 @@ # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -VERSION = "21.1.0" +VERSION = "1.0.0b1" diff --git a/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/templatespecs/v2022_02_01/aio/__init__.py b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/templatespecs/v2022_02_01/aio/__init__.py index 9c8e93c3f82aa..c5e1e112f0111 100644 --- a/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/templatespecs/v2022_02_01/aio/__init__.py +++ b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/templatespecs/v2022_02_01/aio/__init__.py @@ -7,9 +7,15 @@ # -------------------------------------------------------------------------- from ._template_specs_client import TemplateSpecsClient -__all__ = ['TemplateSpecsClient'] -# `._patch.py` is used for handwritten extensions to the generated code -# Example: https://github.com/Azure/azure-sdk-for-python/blob/main/doc/dev/customize_code/how-to-patch-sdk-code.md -from ._patch import patch_sdk -patch_sdk() +try: + from ._patch import __all__ as _patch_all + from ._patch import * # type: ignore # pylint: disable=unused-wildcard-import +except ImportError: + _patch_all = [] +from ._patch import patch_sdk as _patch_sdk + +__all__ = ["TemplateSpecsClient"] +__all__.extend([p for p in _patch_all if p not in __all__]) + +_patch_sdk() diff --git a/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/templatespecs/v2022_02_01/aio/_configuration.py b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/templatespecs/v2022_02_01/aio/_configuration.py index 9b8aa0ac5db83..29a2f48d778ad 100644 --- a/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/templatespecs/v2022_02_01/aio/_configuration.py +++ b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/templatespecs/v2022_02_01/aio/_configuration.py @@ -25,23 +25,19 @@ class TemplateSpecsClientConfiguration(Configuration): # pylint: disable=too-ma Note that all parameters used to create this instance are saved as instance attributes. - :param credential: Credential needed for the client to connect to Azure. + :param credential: Credential needed for the client to connect to Azure. Required. :type credential: ~azure.core.credentials_async.AsyncTokenCredential :param subscription_id: Subscription Id which forms part of the URI for every service call. + Required. :type subscription_id: str :keyword api_version: Api Version. Default value is "2022-02-01". Note that overriding this default value may result in unsupported behavior. :paramtype api_version: str """ - def __init__( - self, - credential: "AsyncTokenCredential", - subscription_id: str, - **kwargs: Any - ) -> None: + def __init__(self, credential: "AsyncTokenCredential", subscription_id: str, **kwargs: Any) -> None: super(TemplateSpecsClientConfiguration, self).__init__(**kwargs) - api_version = kwargs.pop('api_version', "2022-02-01") # type: str + api_version = kwargs.pop("api_version", "2022-02-01") # type: str if credential is None: raise ValueError("Parameter 'credential' must not be None.") @@ -51,22 +47,21 @@ def __init__( self.credential = credential self.subscription_id = subscription_id self.api_version = api_version - self.credential_scopes = kwargs.pop('credential_scopes', ['https://management.azure.com/.default']) - kwargs.setdefault('sdk_moniker', 'mgmt-resource/{}'.format(VERSION)) + self.credential_scopes = kwargs.pop("credential_scopes", ["https://management.azure.com/.default"]) + kwargs.setdefault("sdk_moniker", "mgmt-resource/{}".format(VERSION)) self._configure(**kwargs) - 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) - self.logging_policy = kwargs.get('logging_policy') or policies.NetworkTraceLoggingPolicy(**kwargs) - self.http_logging_policy = kwargs.get('http_logging_policy') or ARMHttpLoggingPolicy(**kwargs) - self.retry_policy = kwargs.get('retry_policy') or policies.AsyncRetryPolicy(**kwargs) - self.custom_hook_policy = kwargs.get('custom_hook_policy') or policies.CustomHookPolicy(**kwargs) - self.redirect_policy = kwargs.get('redirect_policy') or policies.AsyncRedirectPolicy(**kwargs) - self.authentication_policy = kwargs.get('authentication_policy') + 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) + self.logging_policy = kwargs.get("logging_policy") or policies.NetworkTraceLoggingPolicy(**kwargs) + self.http_logging_policy = kwargs.get("http_logging_policy") or ARMHttpLoggingPolicy(**kwargs) + self.retry_policy = kwargs.get("retry_policy") or policies.AsyncRetryPolicy(**kwargs) + self.custom_hook_policy = kwargs.get("custom_hook_policy") or policies.CustomHookPolicy(**kwargs) + self.redirect_policy = kwargs.get("redirect_policy") or policies.AsyncRedirectPolicy(**kwargs) + self.authentication_policy = kwargs.get("authentication_policy") if self.credential and not self.authentication_policy: - self.authentication_policy = AsyncARMChallengeAuthenticationPolicy(self.credential, *self.credential_scopes, **kwargs) + self.authentication_policy = AsyncARMChallengeAuthenticationPolicy( + self.credential, *self.credential_scopes, **kwargs + ) diff --git a/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/templatespecs/v2022_02_01/aio/_patch.py b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/templatespecs/v2022_02_01/aio/_patch.py index 74e48ecd07cf3..f99e77fef9861 100644 --- a/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/templatespecs/v2022_02_01/aio/_patch.py +++ b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/templatespecs/v2022_02_01/aio/_patch.py @@ -28,4 +28,4 @@ # This file is used for handwritten extensions to the generated code. Example: # https://github.com/Azure/azure-sdk-for-python/blob/main/doc/dev/customize_code/how-to-patch-sdk-code.md def patch_sdk(): - pass \ No newline at end of file + pass diff --git a/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/templatespecs/v2022_02_01/aio/_template_specs_client.py b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/templatespecs/v2022_02_01/aio/_template_specs_client.py index 7880cce4c3aa4..c0d948280c190 100644 --- a/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/templatespecs/v2022_02_01/aio/_template_specs_client.py +++ b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/templatespecs/v2022_02_01/aio/_template_specs_client.py @@ -9,12 +9,11 @@ from copy import deepcopy from typing import Any, Awaitable, TYPE_CHECKING -from msrest import Deserializer, Serializer - from azure.core.rest import AsyncHttpResponse, HttpRequest from azure.mgmt.core import AsyncARMPipelineClient from .. import models +from ..._serialization import Deserializer, Serializer from ._configuration import TemplateSpecsClientConfiguration from .operations import TemplateSpecVersionsOperations, TemplateSpecsOperations @@ -22,7 +21,8 @@ # pylint: disable=unused-import,ungrouped-imports from azure.core.credentials_async import AsyncTokenCredential -class TemplateSpecsClient: + +class TemplateSpecsClient: # pylint: disable=client-accepts-api-version-keyword """The APIs listed in this specification can be used to manage Template Spec resources through the Azure Resource Manager. @@ -32,9 +32,10 @@ class TemplateSpecsClient: :ivar template_spec_versions: TemplateSpecVersionsOperations operations :vartype template_spec_versions: azure.mgmt.resource.templatespecs.v2022_02_01.aio.operations.TemplateSpecVersionsOperations - :param credential: Credential needed for the client to connect to Azure. + :param credential: Credential needed for the client to connect to Azure. Required. :type credential: ~azure.core.credentials_async.AsyncTokenCredential :param subscription_id: Subscription Id which forms part of the URI for every service call. + Required. :type subscription_id: str :param base_url: Service URL. Default value is "https://management.azure.com". :type base_url: str @@ -50,7 +51,9 @@ def __init__( base_url: str = "https://management.azure.com", **kwargs: Any ) -> None: - self._config = TemplateSpecsClientConfiguration(credential=credential, subscription_id=subscription_id, **kwargs) + self._config = TemplateSpecsClientConfiguration( + credential=credential, subscription_id=subscription_id, **kwargs + ) self._client = AsyncARMPipelineClient(base_url=base_url, config=self._config, **kwargs) client_models = {k: v for k, v in models.__dict__.items() if isinstance(v, type)} @@ -58,14 +61,11 @@ def __init__( self._deserialize = Deserializer(client_models) self._serialize.client_side_validation = False self.template_specs = TemplateSpecsOperations(self._client, self._config, self._serialize, self._deserialize) - self.template_spec_versions = TemplateSpecVersionsOperations(self._client, self._config, self._serialize, self._deserialize) - + self.template_spec_versions = TemplateSpecVersionsOperations( + self._client, self._config, self._serialize, self._deserialize + ) - def _send_request( - self, - request: HttpRequest, - **kwargs: Any - ) -> Awaitable[AsyncHttpResponse]: + def _send_request(self, request: HttpRequest, **kwargs: Any) -> Awaitable[AsyncHttpResponse]: """Runs the network request through the client's chained policies. >>> from azure.core.rest import HttpRequest @@ -74,7 +74,7 @@ def _send_request( >>> response = await client._send_request(request) - For more information on this code flow, see https://aka.ms/azsdk/python/protocol/quickstart + For more information on this code flow, see https://aka.ms/azsdk/dpcodegen/python/send_request :param request: The network request you want to make. Required. :type request: ~azure.core.rest.HttpRequest diff --git a/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/templatespecs/v2022_02_01/aio/operations/__init__.py b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/templatespecs/v2022_02_01/aio/operations/__init__.py index cb4936f69ad57..1f6058ba55acd 100644 --- a/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/templatespecs/v2022_02_01/aio/operations/__init__.py +++ b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/templatespecs/v2022_02_01/aio/operations/__init__.py @@ -9,7 +9,13 @@ from ._operations import TemplateSpecsOperations from ._operations import TemplateSpecVersionsOperations +from ._patch import __all__ as _patch_all +from ._patch import * # type: ignore # pylint: disable=unused-wildcard-import +from ._patch import patch_sdk as _patch_sdk + __all__ = [ - 'TemplateSpecsOperations', - 'TemplateSpecVersionsOperations', + "TemplateSpecsOperations", + "TemplateSpecVersionsOperations", ] +__all__.extend([p for p in _patch_all if p not in __all__]) +_patch_sdk() diff --git a/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/templatespecs/v2022_02_01/aio/operations/_operations.py b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/templatespecs/v2022_02_01/aio/operations/_operations.py index d792778e33ae2..88daad6515d32 100644 --- a/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/templatespecs/v2022_02_01/aio/operations/_operations.py +++ b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/templatespecs/v2022_02_01/aio/operations/_operations.py @@ -6,94 +6,193 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -from typing import Any, AsyncIterable, Callable, Dict, Optional, TypeVar, Union +from typing import Any, AsyncIterable, Callable, Dict, IO, Optional, TypeVar, Union, overload +from urllib.parse import parse_qs, urljoin, urlparse from azure.core.async_paging import AsyncItemPaged, AsyncList -from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error +from azure.core.exceptions import ( + ClientAuthenticationError, + HttpResponseError, + ResourceExistsError, + ResourceNotFoundError, + ResourceNotModifiedError, + map_error, +) from azure.core.pipeline import PipelineResponse from azure.core.pipeline.transport import AsyncHttpResponse from azure.core.rest import HttpRequest from azure.core.tracing.decorator import distributed_trace from azure.core.tracing.decorator_async import distributed_trace_async +from azure.core.utils import case_insensitive_dict from azure.mgmt.core.exceptions import ARMErrorFormat from ... import models as _models from ..._vendor import _convert_request -from ...operations._operations import build_template_spec_versions_create_or_update_request, build_template_spec_versions_delete_request, build_template_spec_versions_get_built_in_request, build_template_spec_versions_get_request, build_template_spec_versions_list_built_ins_request, build_template_spec_versions_list_request, build_template_spec_versions_update_request, build_template_specs_create_or_update_request, build_template_specs_delete_request, build_template_specs_get_built_in_request, build_template_specs_get_request, build_template_specs_list_built_ins_request, build_template_specs_list_by_resource_group_request, build_template_specs_list_by_subscription_request, build_template_specs_update_request -T = TypeVar('T') +from ...operations._operations import ( + build_template_spec_versions_create_or_update_request, + build_template_spec_versions_delete_request, + build_template_spec_versions_get_built_in_request, + build_template_spec_versions_get_request, + build_template_spec_versions_list_built_ins_request, + build_template_spec_versions_list_request, + build_template_spec_versions_update_request, + build_template_specs_create_or_update_request, + build_template_specs_delete_request, + build_template_specs_get_built_in_request, + build_template_specs_get_request, + build_template_specs_list_built_ins_request, + build_template_specs_list_by_resource_group_request, + build_template_specs_list_by_subscription_request, + build_template_specs_update_request, +) + +T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] -class TemplateSpecsOperations: - """TemplateSpecsOperations async operations. - You should not instantiate this class directly. Instead, you should create a Client instance that - instantiates it for you and attaches it as an attribute. +class TemplateSpecsOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. - :ivar models: Alias to model classes used in this operation group. - :type models: ~azure.mgmt.resource.templatespecs.v2022_02_01.models - :param client: Client for service requests. - :param config: Configuration of service client. - :param serializer: An object model serializer. - :param deserializer: An object model deserializer. + Instead, you should access the following operations through + :class:`~azure.mgmt.resource.templatespecs.v2022_02_01.aio.TemplateSpecsClient`'s + :attr:`template_specs` attribute. """ models = _models - def __init__(self, client, config, serializer, deserializer) -> None: - self._client = client - self._serialize = serializer - self._deserialize = deserializer - self._config = config + def __init__(self, *args, **kwargs) -> None: + input_args = list(args) + self._client = input_args.pop(0) if input_args else kwargs.pop("client") + self._config = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") - @distributed_trace_async + @overload async def create_or_update( self, resource_group_name: str, template_spec_name: str, - template_spec: "_models.TemplateSpec", + template_spec: _models.TemplateSpec, + *, + content_type: str = "application/json", **kwargs: Any - ) -> "_models.TemplateSpec": + ) -> _models.TemplateSpec: """Creates or updates a Template Spec. :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. :type resource_group_name: str - :param template_spec_name: Name of the Template Spec. + :param template_spec_name: Name of the Template Spec. Required. :type template_spec_name: str - :param template_spec: Template Spec supplied to the operation. + :param template_spec: Template Spec supplied to the operation. Required. :type template_spec: ~azure.mgmt.resource.templatespecs.v2022_02_01.models.TemplateSpec + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: TemplateSpec or the result of cls(response) + :rtype: ~azure.mgmt.resource.templatespecs.v2022_02_01.models.TemplateSpec + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + async def create_or_update( + self, + resource_group_name: str, + template_spec_name: str, + template_spec: IO, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.TemplateSpec: + """Creates or updates a Template Spec. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param template_spec_name: Name of the Template Spec. Required. + :type template_spec_name: str + :param template_spec: Template Spec supplied to the operation. Required. + :type template_spec: IO + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: TemplateSpec, or the result of cls(response) + :return: TemplateSpec or the result of cls(response) :rtype: ~azure.mgmt.resource.templatespecs.v2022_02_01.models.TemplateSpec - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace_async + async def create_or_update( + self, + resource_group_name: str, + template_spec_name: str, + template_spec: Union[_models.TemplateSpec, IO], + **kwargs: Any + ) -> _models.TemplateSpec: + """Creates or updates a Template Spec. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param template_spec_name: Name of the Template Spec. Required. + :type template_spec_name: str + :param template_spec: Template Spec supplied to the operation. Is either a model type or a IO + type. Required. + :type template_spec: ~azure.mgmt.resource.templatespecs.v2022_02_01.models.TemplateSpec or IO + :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. + Default value is None. + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: TemplateSpec or the result of cls(response) + :rtype: ~azure.mgmt.resource.templatespecs.v2022_02_01.models.TemplateSpec + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.TemplateSpec"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) - api_version = kwargs.pop('api_version', "2022-02-01") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - _json = self._serialize.body(template_spec, 'TemplateSpec') + api_version = kwargs.pop("api_version", _params.pop("api-version", "2022-02-01")) # type: str + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.TemplateSpec] + + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(template_spec, (IO, bytes)): + _content = template_spec + else: + _json = self._serialize.body(template_spec, "TemplateSpec") request = build_template_specs_create_or_update_request( - subscription_id=self._config.subscription_id, resource_group_name=resource_group_name, template_spec_name=template_spec_name, + subscription_id=self._config.subscription_id, api_version=api_version, content_type=content_type, json=_json, - template_url=self.create_or_update.metadata['url'], + content=_content, + template_url=self.create_or_update.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200, 201]: @@ -102,73 +201,149 @@ async def create_or_update( raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) if response.status_code == 200: - deserialized = self._deserialize('TemplateSpec', pipeline_response) + deserialized = self._deserialize("TemplateSpec", pipeline_response) if response.status_code == 201: - deserialized = self._deserialize('TemplateSpec', pipeline_response) + deserialized = self._deserialize("TemplateSpec", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - create_or_update.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Resources/templateSpecs/{templateSpecName}"} # type: ignore + create_or_update.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Resources/templateSpecs/{templateSpecName}"} # type: ignore - - @distributed_trace_async + @overload async def update( self, resource_group_name: str, template_spec_name: str, - template_spec: Optional["_models.TemplateSpecUpdateModel"] = None, + template_spec: Optional[_models.TemplateSpecUpdateModel] = None, + *, + content_type: str = "application/json", **kwargs: Any - ) -> "_models.TemplateSpec": + ) -> _models.TemplateSpec: """Updates Template Spec tags with specified values. :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. :type resource_group_name: str - :param template_spec_name: Name of the Template Spec. + :param template_spec_name: Name of the Template Spec. Required. :type template_spec_name: str :param template_spec: Template Spec resource with the tags to be updated. Default value is None. :type template_spec: ~azure.mgmt.resource.templatespecs.v2022_02_01.models.TemplateSpecUpdateModel + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: TemplateSpec or the result of cls(response) + :rtype: ~azure.mgmt.resource.templatespecs.v2022_02_01.models.TemplateSpec + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + async def update( + self, + resource_group_name: str, + template_spec_name: str, + template_spec: Optional[IO] = None, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.TemplateSpec: + """Updates Template Spec tags with specified values. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param template_spec_name: Name of the Template Spec. Required. + :type template_spec_name: str + :param template_spec: Template Spec resource with the tags to be updated. Default value is + None. + :type template_spec: IO + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: TemplateSpec or the result of cls(response) + :rtype: ~azure.mgmt.resource.templatespecs.v2022_02_01.models.TemplateSpec + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace_async + async def update( + self, + resource_group_name: str, + template_spec_name: str, + template_spec: Optional[Union[_models.TemplateSpecUpdateModel, IO]] = None, + **kwargs: Any + ) -> _models.TemplateSpec: + """Updates Template Spec tags with specified values. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param template_spec_name: Name of the Template Spec. Required. + :type template_spec_name: str + :param template_spec: Template Spec resource with the tags to be updated. Is either a model + type or a IO type. Default value is None. + :type template_spec: + ~azure.mgmt.resource.templatespecs.v2022_02_01.models.TemplateSpecUpdateModel or IO + :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. + Default value is None. + :paramtype content_type: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: TemplateSpec, or the result of cls(response) + :return: TemplateSpec or the result of cls(response) :rtype: ~azure.mgmt.resource.templatespecs.v2022_02_01.models.TemplateSpec - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.TemplateSpec"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) - api_version = kwargs.pop('api_version', "2022-02-01") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - if template_spec is not None: - _json = self._serialize.body(template_spec, 'TemplateSpecUpdateModel') + api_version = kwargs.pop("api_version", _params.pop("api-version", "2022-02-01")) # type: str + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.TemplateSpec] + + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(template_spec, (IO, bytes)): + _content = template_spec else: - _json = None + if template_spec is not None: + _json = self._serialize.body(template_spec, "TemplateSpecUpdateModel") + else: + _json = None request = build_template_specs_update_request( - subscription_id=self._config.subscription_id, resource_group_name=resource_group_name, template_spec_name=template_spec_name, + subscription_id=self._config.subscription_id, api_version=api_version, content_type=content_type, json=_json, - template_url=self.update.metadata['url'], + content=_content, + template_url=self.update.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200]: @@ -176,15 +351,14 @@ async def update( error = self._deserialize.failsafe_deserialize(_models.TemplateSpecsError, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - deserialized = self._deserialize('TemplateSpec', pipeline_response) + deserialized = self._deserialize("TemplateSpec", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - update.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Resources/templateSpecs/{templateSpecName}"} # type: ignore - + update.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Resources/templateSpecs/{templateSpecName}"} # type: ignore @distributed_trace_async async def get( @@ -193,47 +367,54 @@ async def get( template_spec_name: str, expand: Optional[Union[str, "_models.TemplateSpecExpandKind"]] = None, **kwargs: Any - ) -> "_models.TemplateSpec": + ) -> _models.TemplateSpec: """Gets a Template Spec with a given name. :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. :type resource_group_name: str - :param template_spec_name: Name of the Template Spec. + :param template_spec_name: Name of the Template Spec. Required. :type template_spec_name: str :param expand: Allows for expansion of additional Template Spec details in the response. - Optional. Default value is None. + Optional. "versions" Default value is None. :type expand: str or ~azure.mgmt.resource.templatespecs.v2022_02_01.models.TemplateSpecExpandKind :keyword callable cls: A custom type or function that will be passed the direct response - :return: TemplateSpec, or the result of cls(response) + :return: TemplateSpec or the result of cls(response) :rtype: ~azure.mgmt.resource.templatespecs.v2022_02_01.models.TemplateSpec - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.TemplateSpec"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) - api_version = kwargs.pop('api_version', "2022-02-01") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2022-02-01")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[_models.TemplateSpec] - request = build_template_specs_get_request( - subscription_id=self._config.subscription_id, resource_group_name=resource_group_name, template_spec_name=template_spec_name, - api_version=api_version, + subscription_id=self._config.subscription_id, expand=expand, - template_url=self.get.metadata['url'], + api_version=api_version, + template_url=self.get.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200]: @@ -241,59 +422,62 @@ async def get( error = self._deserialize.failsafe_deserialize(_models.TemplateSpecsError, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - deserialized = self._deserialize('TemplateSpec', pipeline_response) + deserialized = self._deserialize("TemplateSpec", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - get.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Resources/templateSpecs/{templateSpecName}"} # type: ignore - + get.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Resources/templateSpecs/{templateSpecName}"} # type: ignore @distributed_trace_async async def delete( # pylint: disable=inconsistent-return-statements - self, - resource_group_name: str, - template_spec_name: str, - **kwargs: Any + self, resource_group_name: str, template_spec_name: str, **kwargs: Any ) -> None: """Deletes a Template Spec by name. When operation completes, status code 200 returned without content. :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. :type resource_group_name: str - :param template_spec_name: Name of the Template Spec. + :param template_spec_name: Name of the Template Spec. Required. :type template_spec_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: None, or the result of cls(response) + :return: None or the result of cls(response) :rtype: None - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType[None] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + 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', "2022-02-01") # type: str + api_version = kwargs.pop("api_version", _params.pop("api-version", "2022-02-01")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[None] - request = build_template_specs_delete_request( - subscription_id=self._config.subscription_id, resource_group_name=resource_group_name, template_spec_name=template_spec_name, + subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.delete.metadata['url'], + template_url=self.delete.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200, 204]: @@ -304,55 +488,60 @@ async def delete( # pylint: disable=inconsistent-return-statements if cls: return cls(pipeline_response, None, {}) - delete.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Resources/templateSpecs/{templateSpecName}"} # type: ignore - + delete.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Resources/templateSpecs/{templateSpecName}"} # type: ignore @distributed_trace def list_by_subscription( - self, - expand: Optional[Union[str, "_models.TemplateSpecExpandKind"]] = None, - **kwargs: Any - ) -> AsyncIterable["_models.TemplateSpecsListResult"]: + self, expand: Optional[Union[str, "_models.TemplateSpecExpandKind"]] = None, **kwargs: Any + ) -> AsyncIterable["_models.TemplateSpec"]: """Lists all the Template Specs within the specified subscriptions. :param expand: Allows for expansion of additional Template Spec details in the response. - Optional. Default value is None. + Optional. "versions" Default value is None. :type expand: str or ~azure.mgmt.resource.templatespecs.v2022_02_01.models.TemplateSpecExpandKind :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either TemplateSpecsListResult or the result of - cls(response) + :return: An iterator like instance of either TemplateSpec or the result of cls(response) :rtype: - ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.resource.templatespecs.v2022_02_01.models.TemplateSpecsListResult] - :raises: ~azure.core.exceptions.HttpResponseError + ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.resource.templatespecs.v2022_02_01.models.TemplateSpec] + :raises ~azure.core.exceptions.HttpResponseError: """ - api_version = kwargs.pop('api_version', "2022-02-01") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2022-02-01")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[_models.TemplateSpecsListResult] - cls = kwargs.pop('cls', None) # type: ClsType["_models.TemplateSpecsListResult"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) + def prepare_request(next_link=None): if not next_link: - + request = build_template_specs_list_by_subscription_request( subscription_id=self._config.subscription_id, - api_version=api_version, expand=expand, - template_url=self.list_by_subscription.metadata['url'], + api_version=api_version, + template_url=self.list_by_subscription.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore else: - - request = build_template_specs_list_by_subscription_request( - subscription_id=self._config.subscription_id, - template_url=next_link, - ) + # make call to next link with the client's api-version + _parsed_next_link = urlparse(next_link) + _next_request_params = case_insensitive_dict(parse_qs(_parsed_next_link.query)) + _next_request_params["api-version"] = self._config.api_version + request = HttpRequest("GET", urljoin(next_link, _parsed_next_link.path), params=_next_request_params) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore request.method = "GET" return request @@ -366,10 +555,8 @@ async def extract_data(pipeline_response): async def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) response = pipeline_response.http_response @@ -380,11 +567,9 @@ async def get_next(next_link=None): return pipeline_response + return AsyncItemPaged(get_next, extract_data) - return AsyncItemPaged( - get_next, extract_data - ) - list_by_subscription.metadata = {'url': "/subscriptions/{subscriptionId}/providers/Microsoft.Resources/templateSpecs/"} # type: ignore + list_by_subscription.metadata = {"url": "/subscriptions/{subscriptionId}/providers/Microsoft.Resources/templateSpecs/"} # type: ignore @distributed_trace def list_by_resource_group( @@ -392,51 +577,59 @@ def list_by_resource_group( resource_group_name: str, expand: Optional[Union[str, "_models.TemplateSpecExpandKind"]] = None, **kwargs: Any - ) -> AsyncIterable["_models.TemplateSpecsListResult"]: + ) -> AsyncIterable["_models.TemplateSpec"]: """Lists all the Template Specs within the specified resource group. :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. :type resource_group_name: str :param expand: Allows for expansion of additional Template Spec details in the response. - Optional. Default value is None. + Optional. "versions" Default value is None. :type expand: str or ~azure.mgmt.resource.templatespecs.v2022_02_01.models.TemplateSpecExpandKind :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either TemplateSpecsListResult or the result of - cls(response) + :return: An iterator like instance of either TemplateSpec or the result of cls(response) :rtype: - ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.resource.templatespecs.v2022_02_01.models.TemplateSpecsListResult] - :raises: ~azure.core.exceptions.HttpResponseError + ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.resource.templatespecs.v2022_02_01.models.TemplateSpec] + :raises ~azure.core.exceptions.HttpResponseError: """ - api_version = kwargs.pop('api_version', "2022-02-01") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2022-02-01")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[_models.TemplateSpecsListResult] - cls = kwargs.pop('cls', None) # type: ClsType["_models.TemplateSpecsListResult"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) + def prepare_request(next_link=None): if not next_link: - + request = build_template_specs_list_by_resource_group_request( - subscription_id=self._config.subscription_id, resource_group_name=resource_group_name, - api_version=api_version, + subscription_id=self._config.subscription_id, expand=expand, - template_url=self.list_by_resource_group.metadata['url'], + 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.url = self._client.format_url(request.url) # type: ignore else: - - request = build_template_specs_list_by_resource_group_request( - subscription_id=self._config.subscription_id, - resource_group_name=resource_group_name, - template_url=next_link, - ) + # make call to next link with the client's api-version + _parsed_next_link = urlparse(next_link) + _next_request_params = case_insensitive_dict(parse_qs(_parsed_next_link.query)) + _next_request_params["api-version"] = self._config.api_version + request = HttpRequest("GET", urljoin(next_link, _parsed_next_link.path), params=_next_request_params) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore request.method = "GET" return request @@ -450,10 +643,8 @@ async def extract_data(pipeline_response): async def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) response = pipeline_response.http_response @@ -464,11 +655,9 @@ async def get_next(next_link=None): return pipeline_response + return AsyncItemPaged(get_next, extract_data) - return AsyncItemPaged( - get_next, extract_data - ) - list_by_resource_group.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Resources/templateSpecs/"} # type: ignore + list_by_resource_group.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Resources/templateSpecs/"} # type: ignore @distributed_trace_async async def get_built_in( @@ -476,43 +665,49 @@ async def get_built_in( template_spec_name: str, expand: Optional[Union[str, "_models.TemplateSpecExpandKind"]] = None, **kwargs: Any - ) -> "_models.TemplateSpec": + ) -> _models.TemplateSpec: """Gets a built-in Template Spec with a given name. - :param template_spec_name: Name of the Template Spec. + :param template_spec_name: Name of the Template Spec. Required. :type template_spec_name: str :param expand: Allows for expansion of additional Template Spec details in the response. - Optional. Default value is None. + Optional. "versions" Default value is None. :type expand: str or ~azure.mgmt.resource.templatespecs.v2022_02_01.models.TemplateSpecExpandKind :keyword callable cls: A custom type or function that will be passed the direct response - :return: TemplateSpec, or the result of cls(response) + :return: TemplateSpec or the result of cls(response) :rtype: ~azure.mgmt.resource.templatespecs.v2022_02_01.models.TemplateSpec - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.TemplateSpec"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + 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', "2022-02-01") # type: str + api_version = kwargs.pop("api_version", _params.pop("api-version", "2022-02-01")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[_models.TemplateSpec] - request = build_template_specs_get_built_in_request( template_spec_name=template_spec_name, - api_version=api_version, expand=expand, - template_url=self.get_built_in.metadata['url'], + api_version=api_version, + template_url=self.get_built_in.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200]: @@ -520,60 +715,66 @@ async def get_built_in( error = self._deserialize.failsafe_deserialize(_models.TemplateSpecsError, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - deserialized = self._deserialize('TemplateSpec', pipeline_response) + deserialized = self._deserialize("TemplateSpec", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - get_built_in.metadata = {'url': "/providers/Microsoft.Resources/builtInTemplateSpecs/{templateSpecName}"} # type: ignore - + get_built_in.metadata = {"url": "/providers/Microsoft.Resources/builtInTemplateSpecs/{templateSpecName}"} # type: ignore @distributed_trace def list_built_ins( - self, - expand: Optional[Union[str, "_models.TemplateSpecExpandKind"]] = None, - **kwargs: Any - ) -> AsyncIterable["_models.TemplateSpecsListResult"]: + self, expand: Optional[Union[str, "_models.TemplateSpecExpandKind"]] = None, **kwargs: Any + ) -> AsyncIterable["_models.TemplateSpec"]: """Lists built-in Template Specs. :param expand: Allows for expansion of additional Template Spec details in the response. - Optional. Default value is None. + Optional. "versions" Default value is None. :type expand: str or ~azure.mgmt.resource.templatespecs.v2022_02_01.models.TemplateSpecExpandKind :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either TemplateSpecsListResult or the result of - cls(response) + :return: An iterator like instance of either TemplateSpec or the result of cls(response) :rtype: - ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.resource.templatespecs.v2022_02_01.models.TemplateSpecsListResult] - :raises: ~azure.core.exceptions.HttpResponseError + ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.resource.templatespecs.v2022_02_01.models.TemplateSpec] + :raises ~azure.core.exceptions.HttpResponseError: """ - api_version = kwargs.pop('api_version', "2022-02-01") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2022-02-01")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[_models.TemplateSpecsListResult] - cls = kwargs.pop('cls', None) # type: ClsType["_models.TemplateSpecsListResult"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) + def prepare_request(next_link=None): if not next_link: - + request = build_template_specs_list_built_ins_request( - api_version=api_version, expand=expand, - template_url=self.list_built_ins.metadata['url'], + api_version=api_version, + template_url=self.list_built_ins.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore else: - - request = build_template_specs_list_built_ins_request( - template_url=next_link, - ) + # make call to next link with the client's api-version + _parsed_next_link = urlparse(next_link) + _next_request_params = case_insensitive_dict(parse_qs(_parsed_next_link.query)) + _next_request_params["api-version"] = self._config.api_version + request = HttpRequest("GET", urljoin(next_link, _parsed_next_link.path), params=_next_request_params) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore request.method = "GET" return request @@ -587,10 +788,8 @@ async def extract_data(pipeline_response): async def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) response = pipeline_response.http_response @@ -601,87 +800,166 @@ async def get_next(next_link=None): return pipeline_response + return AsyncItemPaged(get_next, extract_data) + + list_built_ins.metadata = {"url": "/providers/Microsoft.Resources/builtInTemplateSpecs/"} # type: ignore - return AsyncItemPaged( - get_next, extract_data - ) - list_built_ins.metadata = {'url': "/providers/Microsoft.Resources/builtInTemplateSpecs/"} # type: ignore -class TemplateSpecVersionsOperations: - """TemplateSpecVersionsOperations async operations. - You should not instantiate this class directly. Instead, you should create a Client instance that - instantiates it for you and attaches it as an attribute. +class TemplateSpecVersionsOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. - :ivar models: Alias to model classes used in this operation group. - :type models: ~azure.mgmt.resource.templatespecs.v2022_02_01.models - :param client: Client for service requests. - :param config: Configuration of service client. - :param serializer: An object model serializer. - :param deserializer: An object model deserializer. + Instead, you should access the following operations through + :class:`~azure.mgmt.resource.templatespecs.v2022_02_01.aio.TemplateSpecsClient`'s + :attr:`template_spec_versions` attribute. """ models = _models - def __init__(self, client, config, serializer, deserializer) -> None: - self._client = client - self._serialize = serializer - self._deserialize = deserializer - self._config = config + def __init__(self, *args, **kwargs) -> None: + input_args = list(args) + self._client = input_args.pop(0) if input_args else kwargs.pop("client") + self._config = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") - @distributed_trace_async + @overload async def create_or_update( self, resource_group_name: str, template_spec_name: str, template_spec_version: str, - template_spec_version_model: "_models.TemplateSpecVersion", + template_spec_version_model: _models.TemplateSpecVersion, + *, + content_type: str = "application/json", **kwargs: Any - ) -> "_models.TemplateSpecVersion": + ) -> _models.TemplateSpecVersion: """Creates or updates a Template Spec version. :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. :type resource_group_name: str - :param template_spec_name: Name of the Template Spec. + :param template_spec_name: Name of the Template Spec. Required. :type template_spec_name: str - :param template_spec_version: The version of the Template Spec. + :param template_spec_version: The version of the Template Spec. Required. :type template_spec_version: str - :param template_spec_version_model: Template Spec Version supplied to the operation. + :param template_spec_version_model: Template Spec Version supplied to the operation. Required. :type template_spec_version_model: ~azure.mgmt.resource.templatespecs.v2022_02_01.models.TemplateSpecVersion + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: TemplateSpecVersion or the result of cls(response) + :rtype: ~azure.mgmt.resource.templatespecs.v2022_02_01.models.TemplateSpecVersion + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + async def create_or_update( + self, + resource_group_name: str, + template_spec_name: str, + template_spec_version: str, + template_spec_version_model: IO, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.TemplateSpecVersion: + """Creates or updates a Template Spec version. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param template_spec_name: Name of the Template Spec. Required. + :type template_spec_name: str + :param template_spec_version: The version of the Template Spec. Required. + :type template_spec_version: str + :param template_spec_version_model: Template Spec Version supplied to the operation. Required. + :type template_spec_version_model: IO + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: TemplateSpecVersion or the result of cls(response) + :rtype: ~azure.mgmt.resource.templatespecs.v2022_02_01.models.TemplateSpecVersion + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace_async + async def create_or_update( + self, + resource_group_name: str, + template_spec_name: str, + template_spec_version: str, + template_spec_version_model: Union[_models.TemplateSpecVersion, IO], + **kwargs: Any + ) -> _models.TemplateSpecVersion: + """Creates or updates a Template Spec version. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param template_spec_name: Name of the Template Spec. Required. + :type template_spec_name: str + :param template_spec_version: The version of the Template Spec. Required. + :type template_spec_version: str + :param template_spec_version_model: Template Spec Version supplied to the operation. Is either + a model type or a IO type. Required. + :type template_spec_version_model: + ~azure.mgmt.resource.templatespecs.v2022_02_01.models.TemplateSpecVersion or IO + :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. + Default value is None. + :paramtype content_type: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: TemplateSpecVersion, or the result of cls(response) + :return: TemplateSpecVersion or the result of cls(response) :rtype: ~azure.mgmt.resource.templatespecs.v2022_02_01.models.TemplateSpecVersion - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.TemplateSpecVersion"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) - api_version = kwargs.pop('api_version', "2022-02-01") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - _json = self._serialize.body(template_spec_version_model, 'TemplateSpecVersion') + api_version = kwargs.pop("api_version", _params.pop("api-version", "2022-02-01")) # type: str + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.TemplateSpecVersion] + + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(template_spec_version_model, (IO, bytes)): + _content = template_spec_version_model + else: + _json = self._serialize.body(template_spec_version_model, "TemplateSpecVersion") request = build_template_spec_versions_create_or_update_request( - subscription_id=self._config.subscription_id, resource_group_name=resource_group_name, template_spec_name=template_spec_name, template_spec_version=template_spec_version, + subscription_id=self._config.subscription_id, api_version=api_version, content_type=content_type, json=_json, - template_url=self.create_or_update.metadata['url'], + content=_content, + template_url=self.create_or_update.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200, 201]: @@ -690,77 +968,159 @@ async def create_or_update( raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) if response.status_code == 200: - deserialized = self._deserialize('TemplateSpecVersion', pipeline_response) + deserialized = self._deserialize("TemplateSpecVersion", pipeline_response) if response.status_code == 201: - deserialized = self._deserialize('TemplateSpecVersion', pipeline_response) + deserialized = self._deserialize("TemplateSpecVersion", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - create_or_update.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Resources/templateSpecs/{templateSpecName}/versions/{templateSpecVersion}"} # type: ignore + create_or_update.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Resources/templateSpecs/{templateSpecName}/versions/{templateSpecVersion}"} # type: ignore - - @distributed_trace_async + @overload async def update( self, resource_group_name: str, template_spec_name: str, template_spec_version: str, - template_spec_version_update_model: Optional["_models.TemplateSpecVersionUpdateModel"] = None, + template_spec_version_update_model: Optional[_models.TemplateSpecVersionUpdateModel] = None, + *, + content_type: str = "application/json", **kwargs: Any - ) -> "_models.TemplateSpecVersion": + ) -> _models.TemplateSpecVersion: """Updates Template Spec Version tags with specified values. :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. :type resource_group_name: str - :param template_spec_name: Name of the Template Spec. + :param template_spec_name: Name of the Template Spec. Required. :type template_spec_name: str - :param template_spec_version: The version of the Template Spec. + :param template_spec_version: The version of the Template Spec. Required. :type template_spec_version: str :param template_spec_version_update_model: Template Spec Version resource with the tags to be updated. Default value is None. :type template_spec_version_update_model: ~azure.mgmt.resource.templatespecs.v2022_02_01.models.TemplateSpecVersionUpdateModel + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: TemplateSpecVersion or the result of cls(response) + :rtype: ~azure.mgmt.resource.templatespecs.v2022_02_01.models.TemplateSpecVersion + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + async def update( + self, + resource_group_name: str, + template_spec_name: str, + template_spec_version: str, + template_spec_version_update_model: Optional[IO] = None, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.TemplateSpecVersion: + """Updates Template Spec Version tags with specified values. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param template_spec_name: Name of the Template Spec. Required. + :type template_spec_name: str + :param template_spec_version: The version of the Template Spec. Required. + :type template_spec_version: str + :param template_spec_version_update_model: Template Spec Version resource with the tags to be + updated. Default value is None. + :type template_spec_version_update_model: IO + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: TemplateSpecVersion or the result of cls(response) + :rtype: ~azure.mgmt.resource.templatespecs.v2022_02_01.models.TemplateSpecVersion + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace_async + async def update( + self, + resource_group_name: str, + template_spec_name: str, + template_spec_version: str, + template_spec_version_update_model: Optional[Union[_models.TemplateSpecVersionUpdateModel, IO]] = None, + **kwargs: Any + ) -> _models.TemplateSpecVersion: + """Updates Template Spec Version tags with specified values. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param template_spec_name: Name of the Template Spec. Required. + :type template_spec_name: str + :param template_spec_version: The version of the Template Spec. Required. + :type template_spec_version: str + :param template_spec_version_update_model: Template Spec Version resource with the tags to be + updated. Is either a model type or a IO type. Default value is None. + :type template_spec_version_update_model: + ~azure.mgmt.resource.templatespecs.v2022_02_01.models.TemplateSpecVersionUpdateModel or IO + :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. + Default value is None. + :paramtype content_type: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: TemplateSpecVersion, or the result of cls(response) + :return: TemplateSpecVersion or the result of cls(response) :rtype: ~azure.mgmt.resource.templatespecs.v2022_02_01.models.TemplateSpecVersion - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.TemplateSpecVersion"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', "2022-02-01") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + api_version = kwargs.pop("api_version", _params.pop("api-version", "2022-02-01")) # type: str + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.TemplateSpecVersion] - if template_spec_version_update_model is not None: - _json = self._serialize.body(template_spec_version_update_model, 'TemplateSpecVersionUpdateModel') + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(template_spec_version_update_model, (IO, bytes)): + _content = template_spec_version_update_model else: - _json = None + if template_spec_version_update_model is not None: + _json = self._serialize.body(template_spec_version_update_model, "TemplateSpecVersionUpdateModel") + else: + _json = None request = build_template_spec_versions_update_request( - subscription_id=self._config.subscription_id, resource_group_name=resource_group_name, template_spec_name=template_spec_name, template_spec_version=template_spec_version, + subscription_id=self._config.subscription_id, api_version=api_version, content_type=content_type, json=_json, - template_url=self.update.metadata['url'], + content=_content, + template_url=self.update.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200]: @@ -768,62 +1128,64 @@ async def update( error = self._deserialize.failsafe_deserialize(_models.TemplateSpecsError, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - deserialized = self._deserialize('TemplateSpecVersion', pipeline_response) + deserialized = self._deserialize("TemplateSpecVersion", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - update.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Resources/templateSpecs/{templateSpecName}/versions/{templateSpecVersion}"} # type: ignore - + update.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Resources/templateSpecs/{templateSpecName}/versions/{templateSpecVersion}"} # type: ignore @distributed_trace_async async def get( - self, - resource_group_name: str, - template_spec_name: str, - template_spec_version: str, - **kwargs: Any - ) -> "_models.TemplateSpecVersion": + self, resource_group_name: str, template_spec_name: str, template_spec_version: str, **kwargs: Any + ) -> _models.TemplateSpecVersion: """Gets a Template Spec version from a specific Template Spec. :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. :type resource_group_name: str - :param template_spec_name: Name of the Template Spec. + :param template_spec_name: Name of the Template Spec. Required. :type template_spec_name: str - :param template_spec_version: The version of the Template Spec. + :param template_spec_version: The version of the Template Spec. Required. :type template_spec_version: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: TemplateSpecVersion, or the result of cls(response) + :return: TemplateSpecVersion or the result of cls(response) :rtype: ~azure.mgmt.resource.templatespecs.v2022_02_01.models.TemplateSpecVersion - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.TemplateSpecVersion"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) - api_version = kwargs.pop('api_version', "2022-02-01") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2022-02-01")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[_models.TemplateSpecVersion] - request = build_template_spec_versions_get_request( - subscription_id=self._config.subscription_id, resource_group_name=resource_group_name, template_spec_name=template_spec_name, template_spec_version=template_spec_version, + subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.get.metadata['url'], + template_url=self.get.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200]: @@ -831,63 +1193,65 @@ async def get( error = self._deserialize.failsafe_deserialize(_models.TemplateSpecsError, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - deserialized = self._deserialize('TemplateSpecVersion', pipeline_response) + deserialized = self._deserialize("TemplateSpecVersion", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - get.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Resources/templateSpecs/{templateSpecName}/versions/{templateSpecVersion}"} # type: ignore - + get.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Resources/templateSpecs/{templateSpecName}/versions/{templateSpecVersion}"} # type: ignore @distributed_trace_async async def delete( # pylint: disable=inconsistent-return-statements - self, - resource_group_name: str, - template_spec_name: str, - template_spec_version: str, - **kwargs: Any + self, resource_group_name: str, template_spec_name: str, template_spec_version: str, **kwargs: Any ) -> None: """Deletes a specific version from a Template Spec. When operation completes, status code 200 returned without content. :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. :type resource_group_name: str - :param template_spec_name: Name of the Template Spec. + :param template_spec_name: Name of the Template Spec. Required. :type template_spec_name: str - :param template_spec_version: The version of the Template Spec. + :param template_spec_version: The version of the Template Spec. Required. :type template_spec_version: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: None, or the result of cls(response) + :return: None or the result of cls(response) :rtype: None - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType[None] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) - api_version = kwargs.pop('api_version', "2022-02-01") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2022-02-01")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[None] - request = build_template_spec_versions_delete_request( - subscription_id=self._config.subscription_id, resource_group_name=resource_group_name, template_spec_name=template_spec_name, template_spec_version=template_spec_version, + subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.delete.metadata['url'], + template_url=self.delete.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200, 204]: @@ -898,59 +1262,62 @@ async def delete( # pylint: disable=inconsistent-return-statements if cls: return cls(pipeline_response, None, {}) - delete.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Resources/templateSpecs/{templateSpecName}/versions/{templateSpecVersion}"} # type: ignore - + delete.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Resources/templateSpecs/{templateSpecName}/versions/{templateSpecVersion}"} # type: ignore @distributed_trace def list( - self, - resource_group_name: str, - template_spec_name: str, - **kwargs: Any - ) -> AsyncIterable["_models.TemplateSpecVersionsListResult"]: + self, resource_group_name: str, template_spec_name: str, **kwargs: Any + ) -> AsyncIterable["_models.TemplateSpecVersion"]: """Lists all the Template Spec versions in the specified Template Spec. :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. :type resource_group_name: str - :param template_spec_name: Name of the Template Spec. + :param template_spec_name: Name of the Template Spec. Required. :type template_spec_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either TemplateSpecVersionsListResult or the result of - cls(response) + :return: An iterator like instance of either TemplateSpecVersion or the result of cls(response) :rtype: - ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.resource.templatespecs.v2022_02_01.models.TemplateSpecVersionsListResult] - :raises: ~azure.core.exceptions.HttpResponseError + ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.resource.templatespecs.v2022_02_01.models.TemplateSpecVersion] + :raises ~azure.core.exceptions.HttpResponseError: """ - api_version = kwargs.pop('api_version', "2022-02-01") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2022-02-01")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[_models.TemplateSpecVersionsListResult] - cls = kwargs.pop('cls', None) # type: ClsType["_models.TemplateSpecVersionsListResult"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) + def prepare_request(next_link=None): if not next_link: - + request = build_template_spec_versions_list_request( - subscription_id=self._config.subscription_id, resource_group_name=resource_group_name, template_spec_name=template_spec_name, + subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.list.metadata['url'], + template_url=self.list.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore else: - - request = build_template_spec_versions_list_request( - subscription_id=self._config.subscription_id, - resource_group_name=resource_group_name, - template_spec_name=template_spec_name, - template_url=next_link, - ) + # make call to next link with the client's api-version + _parsed_next_link = urlparse(next_link) + _next_request_params = case_insensitive_dict(parse_qs(_parsed_next_link.query)) + _next_request_params["api-version"] = self._config.api_version + request = HttpRequest("GET", urljoin(next_link, _parsed_next_link.path), params=_next_request_params) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore request.method = "GET" return request @@ -964,10 +1331,8 @@ async def extract_data(pipeline_response): async def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) response = pipeline_response.http_response @@ -978,55 +1343,57 @@ async def get_next(next_link=None): return pipeline_response + return AsyncItemPaged(get_next, extract_data) - return AsyncItemPaged( - get_next, extract_data - ) - list.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Resources/templateSpecs/{templateSpecName}/versions"} # type: ignore + list.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Resources/templateSpecs/{templateSpecName}/versions"} # type: ignore @distributed_trace - def list_built_ins( - self, - template_spec_name: str, - **kwargs: Any - ) -> AsyncIterable["_models.TemplateSpecVersionsListResult"]: + def list_built_ins(self, template_spec_name: str, **kwargs: Any) -> AsyncIterable["_models.TemplateSpecVersion"]: """Lists all the Template Spec versions in the specified built-in Template Spec. - :param template_spec_name: Name of the Template Spec. + :param template_spec_name: Name of the Template Spec. Required. :type template_spec_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either TemplateSpecVersionsListResult or the result of - cls(response) + :return: An iterator like instance of either TemplateSpecVersion or the result of cls(response) :rtype: - ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.resource.templatespecs.v2022_02_01.models.TemplateSpecVersionsListResult] - :raises: ~azure.core.exceptions.HttpResponseError + ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.resource.templatespecs.v2022_02_01.models.TemplateSpecVersion] + :raises ~azure.core.exceptions.HttpResponseError: """ - api_version = kwargs.pop('api_version', "2022-02-01") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2022-02-01")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[_models.TemplateSpecVersionsListResult] - cls = kwargs.pop('cls', None) # type: ClsType["_models.TemplateSpecVersionsListResult"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) + def prepare_request(next_link=None): if not next_link: - + request = build_template_spec_versions_list_built_ins_request( template_spec_name=template_spec_name, api_version=api_version, - template_url=self.list_built_ins.metadata['url'], + template_url=self.list_built_ins.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore else: - - request = build_template_spec_versions_list_built_ins_request( - template_spec_name=template_spec_name, - template_url=next_link, - ) + # make call to next link with the client's api-version + _parsed_next_link = urlparse(next_link) + _next_request_params = case_insensitive_dict(parse_qs(_parsed_next_link.query)) + _next_request_params["api-version"] = self._config.api_version + request = HttpRequest("GET", urljoin(next_link, _parsed_next_link.path), params=_next_request_params) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore request.method = "GET" return request @@ -1040,10 +1407,8 @@ async def extract_data(pipeline_response): async def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) response = pipeline_response.http_response @@ -1054,53 +1419,54 @@ async def get_next(next_link=None): return pipeline_response + return AsyncItemPaged(get_next, extract_data) - return AsyncItemPaged( - get_next, extract_data - ) - list_built_ins.metadata = {'url': "/providers/Microsoft.Resources/builtInTemplateSpecs/{templateSpecName}/versions"} # type: ignore + list_built_ins.metadata = {"url": "/providers/Microsoft.Resources/builtInTemplateSpecs/{templateSpecName}/versions"} # type: ignore @distributed_trace_async async def get_built_in( - self, - template_spec_name: str, - template_spec_version: str, - **kwargs: Any - ) -> "_models.TemplateSpecVersion": + self, template_spec_name: str, template_spec_version: str, **kwargs: Any + ) -> _models.TemplateSpecVersion: """Gets a Template Spec version from a specific built-in Template Spec. - :param template_spec_name: Name of the Template Spec. + :param template_spec_name: Name of the Template Spec. Required. :type template_spec_name: str - :param template_spec_version: The version of the Template Spec. + :param template_spec_version: The version of the Template Spec. Required. :type template_spec_version: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: TemplateSpecVersion, or the result of cls(response) + :return: TemplateSpecVersion or the result of cls(response) :rtype: ~azure.mgmt.resource.templatespecs.v2022_02_01.models.TemplateSpecVersion - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.TemplateSpecVersion"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + 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', "2022-02-01") # type: str + api_version = kwargs.pop("api_version", _params.pop("api-version", "2022-02-01")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[_models.TemplateSpecVersion] - request = build_template_spec_versions_get_built_in_request( template_spec_name=template_spec_name, template_spec_version=template_spec_version, api_version=api_version, - template_url=self.get_built_in.metadata['url'], + template_url=self.get_built_in.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200]: @@ -1108,12 +1474,11 @@ async def get_built_in( error = self._deserialize.failsafe_deserialize(_models.TemplateSpecsError, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - deserialized = self._deserialize('TemplateSpecVersion', pipeline_response) + deserialized = self._deserialize("TemplateSpecVersion", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - get_built_in.metadata = {'url': "/providers/Microsoft.Resources/builtInTemplateSpecs/{templateSpecName}/versions/{templateSpecVersion}"} # type: ignore - + get_built_in.metadata = {"url": "/providers/Microsoft.Resources/builtInTemplateSpecs/{templateSpecName}/versions/{templateSpecVersion}"} # type: ignore diff --git a/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/templatespecs/v2022_02_01/aio/operations/_patch.py b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/templatespecs/v2022_02_01/aio/operations/_patch.py new file mode 100644 index 0000000000000..f7dd32510333d --- /dev/null +++ b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/templatespecs/v2022_02_01/aio/operations/_patch.py @@ -0,0 +1,20 @@ +# ------------------------------------ +# Copyright (c) Microsoft Corporation. +# Licensed under the MIT License. +# ------------------------------------ +"""Customize generated code here. + +Follow our quickstart for examples: https://aka.ms/azsdk/python/dpcodegen/python/customize +""" +from typing import List + +__all__: List[str] = [] # Add all objects you want publicly available to users at this package level + + +def patch_sdk(): + """Do not remove from this file. + + `patch_sdk` is a last resort escape hatch that allows you to do customizations + you can't accomplish using the techniques described in + https://aka.ms/azsdk/python/dpcodegen/python/customize + """ diff --git a/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/templatespecs/v2022_02_01/models/__init__.py b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/templatespecs/v2022_02_01/models/__init__.py index 2b966fa1d8bbf..641cfe9fca945 100644 --- a/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/templatespecs/v2022_02_01/models/__init__.py +++ b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/templatespecs/v2022_02_01/models/__init__.py @@ -20,26 +20,28 @@ from ._models_py3 import TemplateSpecsError from ._models_py3 import TemplateSpecsListResult - -from ._template_specs_client_enums import ( - CreatedByType, - TemplateSpecExpandKind, -) +from ._template_specs_client_enums import CreatedByType +from ._template_specs_client_enums import TemplateSpecExpandKind +from ._patch import __all__ as _patch_all +from ._patch import * # type: ignore # pylint: disable=unused-wildcard-import +from ._patch import patch_sdk as _patch_sdk __all__ = [ - 'AzureResourceBase', - 'ErrorAdditionalInfo', - 'ErrorResponse', - 'LinkedTemplateArtifact', - 'SystemData', - 'TemplateSpec', - 'TemplateSpecUpdateModel', - 'TemplateSpecVersion', - 'TemplateSpecVersionInfo', - 'TemplateSpecVersionUpdateModel', - 'TemplateSpecVersionsListResult', - 'TemplateSpecsError', - 'TemplateSpecsListResult', - 'CreatedByType', - 'TemplateSpecExpandKind', + "AzureResourceBase", + "ErrorAdditionalInfo", + "ErrorResponse", + "LinkedTemplateArtifact", + "SystemData", + "TemplateSpec", + "TemplateSpecUpdateModel", + "TemplateSpecVersion", + "TemplateSpecVersionInfo", + "TemplateSpecVersionUpdateModel", + "TemplateSpecVersionsListResult", + "TemplateSpecsError", + "TemplateSpecsListResult", + "CreatedByType", + "TemplateSpecExpandKind", ] +__all__.extend([p for p in _patch_all if p not in __all__]) +_patch_sdk() diff --git a/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/templatespecs/v2022_02_01/models/_models_py3.py b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/templatespecs/v2022_02_01/models/_models_py3.py index 746f7c48990e3..f4e940d2db2f3 100644 --- a/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/templatespecs/v2022_02_01/models/_models_py3.py +++ b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/templatespecs/v2022_02_01/models/_models_py3.py @@ -1,4 +1,5 @@ # coding=utf-8 +# pylint: disable=too-many-lines # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. # Licensed under the MIT License. See License.txt in the project root for license information. @@ -7,15 +8,22 @@ # -------------------------------------------------------------------------- import datetime -from typing import Any, Dict, List, Optional, Union +import sys +from typing import Any, Dict, List, Optional, TYPE_CHECKING, Union -from azure.core.exceptions import HttpResponseError -import msrest.serialization +from ... import _serialization -from ._template_specs_client_enums import * +if TYPE_CHECKING: + # pylint: disable=unused-import,ungrouped-imports + from .. import models as _models +if sys.version_info >= (3, 9): + from collections.abc import MutableMapping +else: + from typing import MutableMapping # type: ignore # pylint: disable=ungrouped-imports +JSON = MutableMapping[str, Any] # pylint: disable=unsubscriptable-object -class AzureResourceBase(msrest.serialization.Model): +class AzureResourceBase(_serialization.Model): """Common properties for all Azure resources. Variables are only populated by the server, and will be ignored when sending a request. @@ -32,33 +40,29 @@ class AzureResourceBase(msrest.serialization.Model): """ _validation = { - 'id': {'readonly': True}, - 'name': {'readonly': True}, - 'type': {'readonly': True}, - 'system_data': {'readonly': True}, + "id": {"readonly": True}, + "name": {"readonly": True}, + "type": {"readonly": True}, + "system_data": {"readonly": True}, } _attribute_map = { - 'id': {'key': 'id', 'type': 'str'}, - 'name': {'key': 'name', 'type': 'str'}, - 'type': {'key': 'type', 'type': 'str'}, - 'system_data': {'key': 'systemData', 'type': 'SystemData'}, + "id": {"key": "id", "type": "str"}, + "name": {"key": "name", "type": "str"}, + "type": {"key": "type", "type": "str"}, + "system_data": {"key": "systemData", "type": "SystemData"}, } - def __init__( - self, - **kwargs - ): - """ - """ - super(AzureResourceBase, self).__init__(**kwargs) + def __init__(self, **kwargs): + """ """ + super().__init__(**kwargs) self.id = None self.name = None self.type = None self.system_data = None -class ErrorAdditionalInfo(msrest.serialization.Model): +class ErrorAdditionalInfo(_serialization.Model): """The resource management error additional info. Variables are only populated by the server, and will be ignored when sending a request. @@ -66,31 +70,27 @@ class ErrorAdditionalInfo(msrest.serialization.Model): :ivar type: The additional info type. :vartype type: str :ivar info: The additional info. - :vartype info: any + :vartype info: JSON """ _validation = { - 'type': {'readonly': True}, - 'info': {'readonly': True}, + "type": {"readonly": True}, + "info": {"readonly": True}, } _attribute_map = { - 'type': {'key': 'type', 'type': 'str'}, - 'info': {'key': 'info', 'type': 'object'}, + "type": {"key": "type", "type": "str"}, + "info": {"key": "info", "type": "object"}, } - def __init__( - self, - **kwargs - ): - """ - """ - super(ErrorAdditionalInfo, self).__init__(**kwargs) + def __init__(self, **kwargs): + """ """ + super().__init__(**kwargs) self.type = None self.info = None -class ErrorResponse(msrest.serialization.Model): +class ErrorResponse(_serialization.Model): """Common error response for all Azure Resource Manager APIs to return error details for failed operations. (This also follows the OData error response format.). Variables are only populated by the server, and will be ignored when sending a request. @@ -109,28 +109,24 @@ class ErrorResponse(msrest.serialization.Model): """ _validation = { - 'code': {'readonly': True}, - 'message': {'readonly': True}, - 'target': {'readonly': True}, - 'details': {'readonly': True}, - 'additional_info': {'readonly': True}, + "code": {"readonly": True}, + "message": {"readonly": True}, + "target": {"readonly": True}, + "details": {"readonly": True}, + "additional_info": {"readonly": True}, } _attribute_map = { - 'code': {'key': 'code', 'type': 'str'}, - 'message': {'key': 'message', 'type': 'str'}, - 'target': {'key': 'target', 'type': 'str'}, - 'details': {'key': 'details', 'type': '[ErrorResponse]'}, - 'additional_info': {'key': 'additionalInfo', 'type': '[ErrorAdditionalInfo]'}, + "code": {"key": "code", "type": "str"}, + "message": {"key": "message", "type": "str"}, + "target": {"key": "target", "type": "str"}, + "details": {"key": "details", "type": "[ErrorResponse]"}, + "additional_info": {"key": "additionalInfo", "type": "[ErrorAdditionalInfo]"}, } - def __init__( - self, - **kwargs - ): - """ - """ - super(ErrorResponse, self).__init__(**kwargs) + def __init__(self, **kwargs): + """ """ + super().__init__(**kwargs) self.code = None self.message = None self.target = None @@ -138,60 +134,54 @@ def __init__( self.additional_info = None -class LinkedTemplateArtifact(msrest.serialization.Model): +class LinkedTemplateArtifact(_serialization.Model): """Represents a Template Spec artifact containing an embedded Azure Resource Manager template for use as a linked template. All required parameters must be populated in order to send to Azure. - :ivar path: Required. A filesystem safe relative path of the artifact. + :ivar path: A filesystem safe relative path of the artifact. Required. :vartype path: str - :ivar template: Required. The Azure Resource Manager template. - :vartype template: any + :ivar template: The Azure Resource Manager template. Required. + :vartype template: JSON """ _validation = { - 'path': {'required': True}, - 'template': {'required': True}, + "path": {"required": True}, + "template": {"required": True}, } _attribute_map = { - 'path': {'key': 'path', 'type': 'str'}, - 'template': {'key': 'template', 'type': 'object'}, + "path": {"key": "path", "type": "str"}, + "template": {"key": "template", "type": "object"}, } - def __init__( - self, - *, - path: str, - template: Any, - **kwargs - ): + def __init__(self, *, path: str, template: JSON, **kwargs): """ - :keyword path: Required. A filesystem safe relative path of the artifact. + :keyword path: A filesystem safe relative path of the artifact. Required. :paramtype path: str - :keyword template: Required. The Azure Resource Manager template. - :paramtype template: any + :keyword template: The Azure Resource Manager template. Required. + :paramtype template: JSON """ - super(LinkedTemplateArtifact, self).__init__(**kwargs) + super().__init__(**kwargs) self.path = path self.template = template -class SystemData(msrest.serialization.Model): +class SystemData(_serialization.Model): """Metadata pertaining to creation and last modification of the resource. :ivar created_by: The identity that created the resource. :vartype created_by: str - :ivar created_by_type: The type of identity that created the resource. Possible values include: - "User", "Application", "ManagedIdentity", "Key". + :ivar created_by_type: The type of identity that created the resource. Known values are: + "User", "Application", "ManagedIdentity", and "Key". :vartype created_by_type: str or ~azure.mgmt.resource.templatespecs.v2022_02_01.models.CreatedByType :ivar created_at: The timestamp of resource creation (UTC). :vartype created_at: ~datetime.datetime :ivar last_modified_by: The identity that last modified the resource. :vartype last_modified_by: str - :ivar last_modified_by_type: The type of identity that last modified the resource. Possible - values include: "User", "Application", "ManagedIdentity", "Key". + :ivar last_modified_by_type: The type of identity that last modified the resource. Known values + are: "User", "Application", "ManagedIdentity", and "Key". :vartype last_modified_by_type: str or ~azure.mgmt.resource.templatespecs.v2022_02_01.models.CreatedByType :ivar last_modified_at: The timestamp of resource last modification (UTC). @@ -199,44 +189,44 @@ class SystemData(msrest.serialization.Model): """ _attribute_map = { - 'created_by': {'key': 'createdBy', 'type': 'str'}, - 'created_by_type': {'key': 'createdByType', 'type': 'str'}, - 'created_at': {'key': 'createdAt', 'type': 'iso-8601'}, - 'last_modified_by': {'key': 'lastModifiedBy', 'type': 'str'}, - 'last_modified_by_type': {'key': 'lastModifiedByType', 'type': 'str'}, - 'last_modified_at': {'key': 'lastModifiedAt', 'type': 'iso-8601'}, + "created_by": {"key": "createdBy", "type": "str"}, + "created_by_type": {"key": "createdByType", "type": "str"}, + "created_at": {"key": "createdAt", "type": "iso-8601"}, + "last_modified_by": {"key": "lastModifiedBy", "type": "str"}, + "last_modified_by_type": {"key": "lastModifiedByType", "type": "str"}, + "last_modified_at": {"key": "lastModifiedAt", "type": "iso-8601"}, } def __init__( self, *, created_by: Optional[str] = None, - created_by_type: Optional[Union[str, "CreatedByType"]] = None, + created_by_type: Optional[Union[str, "_models.CreatedByType"]] = None, created_at: Optional[datetime.datetime] = None, last_modified_by: Optional[str] = None, - last_modified_by_type: Optional[Union[str, "CreatedByType"]] = None, + last_modified_by_type: Optional[Union[str, "_models.CreatedByType"]] = None, last_modified_at: Optional[datetime.datetime] = None, **kwargs ): """ :keyword created_by: The identity that created the resource. :paramtype created_by: str - :keyword created_by_type: The type of identity that created the resource. Possible values - include: "User", "Application", "ManagedIdentity", "Key". + :keyword created_by_type: The type of identity that created the resource. Known values are: + "User", "Application", "ManagedIdentity", and "Key". :paramtype created_by_type: str or ~azure.mgmt.resource.templatespecs.v2022_02_01.models.CreatedByType :keyword created_at: The timestamp of resource creation (UTC). :paramtype created_at: ~datetime.datetime :keyword last_modified_by: The identity that last modified the resource. :paramtype last_modified_by: str - :keyword last_modified_by_type: The type of identity that last modified the resource. Possible - values include: "User", "Application", "ManagedIdentity", "Key". + :keyword last_modified_by_type: The type of identity that last modified the resource. Known + values are: "User", "Application", "ManagedIdentity", and "Key". :paramtype last_modified_by_type: str or ~azure.mgmt.resource.templatespecs.v2022_02_01.models.CreatedByType :keyword last_modified_at: The timestamp of resource last modification (UTC). :paramtype last_modified_at: ~datetime.datetime """ - super(SystemData, self).__init__(**kwargs) + super().__init__(**kwargs) self.created_by = created_by self.created_by_type = created_by_type self.created_at = created_at @@ -261,10 +251,10 @@ class TemplateSpec(AzureResourceBase): :ivar system_data: Azure Resource Manager metadata containing createdBy and modifiedBy information. :vartype system_data: ~azure.mgmt.resource.templatespecs.v2022_02_01.models.SystemData - :ivar location: Required. The location of the Template Spec. It cannot be changed after - Template Spec creation. It must be one of the supported Azure locations. + :ivar location: The location of the Template Spec. It cannot be changed after Template Spec + creation. It must be one of the supported Azure locations. Required. :vartype location: str - :ivar tags: A set of tags. Resource tags. + :ivar tags: Resource tags. :vartype tags: dict[str, str] :ivar description: Template Spec description. :vartype description: str @@ -272,7 +262,7 @@ class TemplateSpec(AzureResourceBase): :vartype display_name: str :ivar metadata: The Template Spec metadata. Metadata is an open-ended object and is typically a collection of key-value pairs. - :vartype metadata: any + :vartype metadata: JSON :ivar versions: High-level information about the versions within this Template Spec. The keys are the version names. Only populated if the $expand query parameter is set to 'versions'. :vartype versions: dict[str, @@ -280,27 +270,27 @@ class TemplateSpec(AzureResourceBase): """ _validation = { - 'id': {'readonly': True}, - 'name': {'readonly': True}, - 'type': {'readonly': True}, - 'system_data': {'readonly': True}, - 'location': {'required': True}, - 'description': {'max_length': 4096, 'min_length': 0}, - 'display_name': {'max_length': 64, 'min_length': 0}, - 'versions': {'readonly': True}, + "id": {"readonly": True}, + "name": {"readonly": True}, + "type": {"readonly": True}, + "system_data": {"readonly": True}, + "location": {"required": True}, + "description": {"max_length": 4096}, + "display_name": {"max_length": 64}, + "versions": {"readonly": True}, } _attribute_map = { - 'id': {'key': 'id', 'type': 'str'}, - 'name': {'key': 'name', 'type': 'str'}, - 'type': {'key': 'type', 'type': 'str'}, - 'system_data': {'key': 'systemData', 'type': 'SystemData'}, - 'location': {'key': 'location', 'type': 'str'}, - 'tags': {'key': 'tags', 'type': '{str}'}, - 'description': {'key': 'properties.description', 'type': 'str'}, - 'display_name': {'key': 'properties.displayName', 'type': 'str'}, - 'metadata': {'key': 'properties.metadata', 'type': 'object'}, - 'versions': {'key': 'properties.versions', 'type': '{TemplateSpecVersionInfo}'}, + "id": {"key": "id", "type": "str"}, + "name": {"key": "name", "type": "str"}, + "type": {"key": "type", "type": "str"}, + "system_data": {"key": "systemData", "type": "SystemData"}, + "location": {"key": "location", "type": "str"}, + "tags": {"key": "tags", "type": "{str}"}, + "description": {"key": "properties.description", "type": "str"}, + "display_name": {"key": "properties.displayName", "type": "str"}, + "metadata": {"key": "properties.metadata", "type": "object"}, + "versions": {"key": "properties.versions", "type": "{TemplateSpecVersionInfo}"}, } def __init__( @@ -310,14 +300,14 @@ def __init__( tags: Optional[Dict[str, str]] = None, description: Optional[str] = None, display_name: Optional[str] = None, - metadata: Optional[Any] = None, + metadata: Optional[JSON] = None, **kwargs ): """ - :keyword location: Required. The location of the Template Spec. It cannot be changed after - Template Spec creation. It must be one of the supported Azure locations. + :keyword location: The location of the Template Spec. It cannot be changed after Template Spec + creation. It must be one of the supported Azure locations. Required. :paramtype location: str - :keyword tags: A set of tags. Resource tags. + :keyword tags: Resource tags. :paramtype tags: dict[str, str] :keyword description: Template Spec description. :paramtype description: str @@ -325,9 +315,9 @@ def __init__( :paramtype display_name: str :keyword metadata: The Template Spec metadata. Metadata is an open-ended object and is typically a collection of key-value pairs. - :paramtype metadata: any + :paramtype metadata: JSON """ - super(TemplateSpec, self).__init__(**kwargs) + super().__init__(**kwargs) self.location = location self.tags = tags self.description = description @@ -336,7 +326,7 @@ def __init__( self.versions = None -class TemplateSpecsError(msrest.serialization.Model): +class TemplateSpecsError(_serialization.Model): """Template Specs error response. :ivar error: Common error response for all Azure Resource Manager APIs to return error details @@ -345,25 +335,20 @@ class TemplateSpecsError(msrest.serialization.Model): """ _attribute_map = { - 'error': {'key': 'error', 'type': 'ErrorResponse'}, + "error": {"key": "error", "type": "ErrorResponse"}, } - def __init__( - self, - *, - error: Optional["ErrorResponse"] = None, - **kwargs - ): + def __init__(self, *, error: Optional["_models.ErrorResponse"] = None, **kwargs): """ :keyword error: Common error response for all Azure Resource Manager APIs to return error details for failed operations. (This also follows the OData error response format.). :paramtype error: ~azure.mgmt.resource.templatespecs.v2022_02_01.models.ErrorResponse """ - super(TemplateSpecsError, self).__init__(**kwargs) + super().__init__(**kwargs) self.error = error -class TemplateSpecsListResult(msrest.serialization.Model): +class TemplateSpecsListResult(_serialization.Model): """List of Template Specs. Variables are only populated by the server, and will be ignored when sending a request. @@ -375,25 +360,20 @@ class TemplateSpecsListResult(msrest.serialization.Model): """ _validation = { - 'next_link': {'readonly': True}, + "next_link": {"readonly": True}, } _attribute_map = { - 'value': {'key': 'value', 'type': '[TemplateSpec]'}, - 'next_link': {'key': 'nextLink', 'type': 'str'}, + "value": {"key": "value", "type": "[TemplateSpec]"}, + "next_link": {"key": "nextLink", "type": "str"}, } - def __init__( - self, - *, - value: Optional[List["TemplateSpec"]] = None, - **kwargs - ): + def __init__(self, *, value: Optional[List["_models.TemplateSpec"]] = None, **kwargs): """ :keyword value: An array of Template Specs. :paramtype value: list[~azure.mgmt.resource.templatespecs.v2022_02_01.models.TemplateSpec] """ - super(TemplateSpecsListResult, self).__init__(**kwargs) + super().__init__(**kwargs) self.value = value self.next_link = None @@ -412,40 +392,35 @@ class TemplateSpecUpdateModel(AzureResourceBase): :ivar system_data: Azure Resource Manager metadata containing createdBy and modifiedBy information. :vartype system_data: ~azure.mgmt.resource.templatespecs.v2022_02_01.models.SystemData - :ivar tags: A set of tags. Resource tags. + :ivar tags: Resource tags. :vartype tags: dict[str, str] """ _validation = { - 'id': {'readonly': True}, - 'name': {'readonly': True}, - 'type': {'readonly': True}, - 'system_data': {'readonly': True}, + "id": {"readonly": True}, + "name": {"readonly": True}, + "type": {"readonly": True}, + "system_data": {"readonly": True}, } _attribute_map = { - 'id': {'key': 'id', 'type': 'str'}, - 'name': {'key': 'name', 'type': 'str'}, - 'type': {'key': 'type', 'type': 'str'}, - 'system_data': {'key': 'systemData', 'type': 'SystemData'}, - 'tags': {'key': 'tags', 'type': '{str}'}, + "id": {"key": "id", "type": "str"}, + "name": {"key": "name", "type": "str"}, + "type": {"key": "type", "type": "str"}, + "system_data": {"key": "systemData", "type": "SystemData"}, + "tags": {"key": "tags", "type": "{str}"}, } - def __init__( - self, - *, - tags: Optional[Dict[str, str]] = None, - **kwargs - ): + def __init__(self, *, tags: Optional[Dict[str, str]] = None, **kwargs): """ - :keyword tags: A set of tags. Resource tags. + :keyword tags: Resource tags. :paramtype tags: dict[str, str] """ - super(TemplateSpecUpdateModel, self).__init__(**kwargs) + super().__init__(**kwargs) self.tags = tags -class TemplateSpecVersion(AzureResourceBase): +class TemplateSpecVersion(AzureResourceBase): # pylint: disable=too-many-instance-attributes """Template Spec Version object. Variables are only populated by the server, and will be ignored when sending a request. @@ -461,10 +436,10 @@ class TemplateSpecVersion(AzureResourceBase): :ivar system_data: Azure Resource Manager metadata containing createdBy and modifiedBy information. :vartype system_data: ~azure.mgmt.resource.templatespecs.v2022_02_01.models.SystemData - :ivar location: Required. The location of the Template Spec Version. It must match the location - of the parent Template Spec. + :ivar location: The location of the Template Spec Version. It must match the location of the + parent Template Spec. Required. :vartype location: str - :ivar tags: A set of tags. Resource tags. + :ivar tags: Resource tags. :vartype tags: dict[str, str] :ivar description: Template Spec version description. :vartype description: str @@ -473,34 +448,34 @@ class TemplateSpecVersion(AzureResourceBase): list[~azure.mgmt.resource.templatespecs.v2022_02_01.models.LinkedTemplateArtifact] :ivar metadata: The version metadata. Metadata is an open-ended object and is typically a collection of key-value pairs. - :vartype metadata: any + :vartype metadata: JSON :ivar main_template: The main Azure Resource Manager template content. - :vartype main_template: any + :vartype main_template: JSON :ivar ui_form_definition: The Azure Resource Manager template UI definition content. - :vartype ui_form_definition: any + :vartype ui_form_definition: JSON """ _validation = { - 'id': {'readonly': True}, - 'name': {'readonly': True}, - 'type': {'readonly': True}, - 'system_data': {'readonly': True}, - 'location': {'required': True}, - 'description': {'max_length': 4096, 'min_length': 0}, + "id": {"readonly": True}, + "name": {"readonly": True}, + "type": {"readonly": True}, + "system_data": {"readonly": True}, + "location": {"required": True}, + "description": {"max_length": 4096}, } _attribute_map = { - 'id': {'key': 'id', 'type': 'str'}, - 'name': {'key': 'name', 'type': 'str'}, - 'type': {'key': 'type', 'type': 'str'}, - 'system_data': {'key': 'systemData', 'type': 'SystemData'}, - 'location': {'key': 'location', 'type': 'str'}, - 'tags': {'key': 'tags', 'type': '{str}'}, - 'description': {'key': 'properties.description', 'type': 'str'}, - 'linked_templates': {'key': 'properties.linkedTemplates', 'type': '[LinkedTemplateArtifact]'}, - 'metadata': {'key': 'properties.metadata', 'type': 'object'}, - 'main_template': {'key': 'properties.mainTemplate', 'type': 'object'}, - 'ui_form_definition': {'key': 'properties.uiFormDefinition', 'type': 'object'}, + "id": {"key": "id", "type": "str"}, + "name": {"key": "name", "type": "str"}, + "type": {"key": "type", "type": "str"}, + "system_data": {"key": "systemData", "type": "SystemData"}, + "location": {"key": "location", "type": "str"}, + "tags": {"key": "tags", "type": "{str}"}, + "description": {"key": "properties.description", "type": "str"}, + "linked_templates": {"key": "properties.linkedTemplates", "type": "[LinkedTemplateArtifact]"}, + "metadata": {"key": "properties.metadata", "type": "object"}, + "main_template": {"key": "properties.mainTemplate", "type": "object"}, + "ui_form_definition": {"key": "properties.uiFormDefinition", "type": "object"}, } def __init__( @@ -509,17 +484,17 @@ def __init__( location: str, tags: Optional[Dict[str, str]] = None, description: Optional[str] = None, - linked_templates: Optional[List["LinkedTemplateArtifact"]] = None, - metadata: Optional[Any] = None, - main_template: Optional[Any] = None, - ui_form_definition: Optional[Any] = None, + linked_templates: Optional[List["_models.LinkedTemplateArtifact"]] = None, + metadata: Optional[JSON] = None, + main_template: Optional[JSON] = None, + ui_form_definition: Optional[JSON] = None, **kwargs ): """ - :keyword location: Required. The location of the Template Spec Version. It must match the - location of the parent Template Spec. + :keyword location: The location of the Template Spec Version. It must match the location of the + parent Template Spec. Required. :paramtype location: str - :keyword tags: A set of tags. Resource tags. + :keyword tags: Resource tags. :paramtype tags: dict[str, str] :keyword description: Template Spec version description. :paramtype description: str @@ -528,13 +503,13 @@ def __init__( list[~azure.mgmt.resource.templatespecs.v2022_02_01.models.LinkedTemplateArtifact] :keyword metadata: The version metadata. Metadata is an open-ended object and is typically a collection of key-value pairs. - :paramtype metadata: any + :paramtype metadata: JSON :keyword main_template: The main Azure Resource Manager template content. - :paramtype main_template: any + :paramtype main_template: JSON :keyword ui_form_definition: The Azure Resource Manager template UI definition content. - :paramtype ui_form_definition: any + :paramtype ui_form_definition: JSON """ - super(TemplateSpecVersion, self).__init__(**kwargs) + super().__init__(**kwargs) self.location = location self.tags = tags self.description = description @@ -544,7 +519,7 @@ def __init__( self.ui_form_definition = ui_form_definition -class TemplateSpecVersionInfo(msrest.serialization.Model): +class TemplateSpecVersionInfo(_serialization.Model): """High-level information about a Template Spec version. Variables are only populated by the server, and will be ignored when sending a request. @@ -558,30 +533,26 @@ class TemplateSpecVersionInfo(msrest.serialization.Model): """ _validation = { - 'description': {'readonly': True}, - 'time_created': {'readonly': True}, - 'time_modified': {'readonly': True}, + "description": {"readonly": True}, + "time_created": {"readonly": True}, + "time_modified": {"readonly": True}, } _attribute_map = { - 'description': {'key': 'description', 'type': 'str'}, - 'time_created': {'key': 'timeCreated', 'type': 'iso-8601'}, - 'time_modified': {'key': 'timeModified', 'type': 'iso-8601'}, + "description": {"key": "description", "type": "str"}, + "time_created": {"key": "timeCreated", "type": "iso-8601"}, + "time_modified": {"key": "timeModified", "type": "iso-8601"}, } - def __init__( - self, - **kwargs - ): - """ - """ - super(TemplateSpecVersionInfo, self).__init__(**kwargs) + def __init__(self, **kwargs): + """ """ + super().__init__(**kwargs) self.description = None self.time_created = None self.time_modified = None -class TemplateSpecVersionsListResult(msrest.serialization.Model): +class TemplateSpecVersionsListResult(_serialization.Model): """List of Template Specs versions. Variables are only populated by the server, and will be ignored when sending a request. @@ -593,26 +564,21 @@ class TemplateSpecVersionsListResult(msrest.serialization.Model): """ _validation = { - 'next_link': {'readonly': True}, + "next_link": {"readonly": True}, } _attribute_map = { - 'value': {'key': 'value', 'type': '[TemplateSpecVersion]'}, - 'next_link': {'key': 'nextLink', 'type': 'str'}, + "value": {"key": "value", "type": "[TemplateSpecVersion]"}, + "next_link": {"key": "nextLink", "type": "str"}, } - def __init__( - self, - *, - value: Optional[List["TemplateSpecVersion"]] = None, - **kwargs - ): + def __init__(self, *, value: Optional[List["_models.TemplateSpecVersion"]] = None, **kwargs): """ :keyword value: An array of Template Spec versions. :paramtype value: list[~azure.mgmt.resource.templatespecs.v2022_02_01.models.TemplateSpecVersion] """ - super(TemplateSpecVersionsListResult, self).__init__(**kwargs) + super().__init__(**kwargs) self.value = value self.next_link = None @@ -631,34 +597,29 @@ class TemplateSpecVersionUpdateModel(AzureResourceBase): :ivar system_data: Azure Resource Manager metadata containing createdBy and modifiedBy information. :vartype system_data: ~azure.mgmt.resource.templatespecs.v2022_02_01.models.SystemData - :ivar tags: A set of tags. Resource tags. + :ivar tags: Resource tags. :vartype tags: dict[str, str] """ _validation = { - 'id': {'readonly': True}, - 'name': {'readonly': True}, - 'type': {'readonly': True}, - 'system_data': {'readonly': True}, + "id": {"readonly": True}, + "name": {"readonly": True}, + "type": {"readonly": True}, + "system_data": {"readonly": True}, } _attribute_map = { - 'id': {'key': 'id', 'type': 'str'}, - 'name': {'key': 'name', 'type': 'str'}, - 'type': {'key': 'type', 'type': 'str'}, - 'system_data': {'key': 'systemData', 'type': 'SystemData'}, - 'tags': {'key': 'tags', 'type': '{str}'}, + "id": {"key": "id", "type": "str"}, + "name": {"key": "name", "type": "str"}, + "type": {"key": "type", "type": "str"}, + "system_data": {"key": "systemData", "type": "SystemData"}, + "tags": {"key": "tags", "type": "{str}"}, } - def __init__( - self, - *, - tags: Optional[Dict[str, str]] = None, - **kwargs - ): + def __init__(self, *, tags: Optional[Dict[str, str]] = None, **kwargs): """ - :keyword tags: A set of tags. Resource tags. + :keyword tags: Resource tags. :paramtype tags: dict[str, str] """ - super(TemplateSpecVersionUpdateModel, self).__init__(**kwargs) + super().__init__(**kwargs) self.tags = tags diff --git a/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/templatespecs/v2022_02_01/models/_patch.py b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/templatespecs/v2022_02_01/models/_patch.py new file mode 100644 index 0000000000000..f7dd32510333d --- /dev/null +++ b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/templatespecs/v2022_02_01/models/_patch.py @@ -0,0 +1,20 @@ +# ------------------------------------ +# Copyright (c) Microsoft Corporation. +# Licensed under the MIT License. +# ------------------------------------ +"""Customize generated code here. + +Follow our quickstart for examples: https://aka.ms/azsdk/python/dpcodegen/python/customize +""" +from typing import List + +__all__: List[str] = [] # Add all objects you want publicly available to users at this package level + + +def patch_sdk(): + """Do not remove from this file. + + `patch_sdk` is a last resort escape hatch that allows you to do customizations + you can't accomplish using the techniques described in + https://aka.ms/azsdk/python/dpcodegen/python/customize + """ diff --git a/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/templatespecs/v2022_02_01/models/_template_specs_client_enums.py b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/templatespecs/v2022_02_01/models/_template_specs_client_enums.py index ef8823668c7ee..ec0f6b2bc39a4 100644 --- a/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/templatespecs/v2022_02_01/models/_template_specs_client_enums.py +++ b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/templatespecs/v2022_02_01/models/_template_specs_client_enums.py @@ -7,20 +7,20 @@ # -------------------------------------------------------------------------- from enum import Enum -from six import with_metaclass from azure.core import CaseInsensitiveEnumMeta -class CreatedByType(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): - """The type of identity that created the resource. - """ +class CreatedByType(str, Enum, metaclass=CaseInsensitiveEnumMeta): + """The type of identity that created the resource.""" USER = "User" APPLICATION = "Application" MANAGED_IDENTITY = "ManagedIdentity" KEY = "Key" -class TemplateSpecExpandKind(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): + +class TemplateSpecExpandKind(str, Enum, metaclass=CaseInsensitiveEnumMeta): + """TemplateSpecExpandKind.""" #: Includes version information with the Template Spec. VERSIONS = "versions" diff --git a/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/templatespecs/v2022_02_01/operations/__init__.py b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/templatespecs/v2022_02_01/operations/__init__.py index cb4936f69ad57..1f6058ba55acd 100644 --- a/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/templatespecs/v2022_02_01/operations/__init__.py +++ b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/templatespecs/v2022_02_01/operations/__init__.py @@ -9,7 +9,13 @@ from ._operations import TemplateSpecsOperations from ._operations import TemplateSpecVersionsOperations +from ._patch import __all__ as _patch_all +from ._patch import * # type: ignore # pylint: disable=unused-wildcard-import +from ._patch import patch_sdk as _patch_sdk + __all__ = [ - 'TemplateSpecsOperations', - 'TemplateSpecVersionsOperations', + "TemplateSpecsOperations", + "TemplateSpecVersionsOperations", ] +__all__.extend([p for p in _patch_all if p not in __all__]) +_patch_sdk() diff --git a/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/templatespecs/v2022_02_01/operations/_operations.py b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/templatespecs/v2022_02_01/operations/_operations.py index c7d3112be1230..e51743b22eb7d 100644 --- a/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/templatespecs/v2022_02_01/operations/_operations.py +++ b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/templatespecs/v2022_02_01/operations/_operations.py @@ -6,671 +6,729 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -from typing import Any, Callable, Dict, Iterable, Optional, TypeVar, Union - -from msrest import Serializer - -from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error +from typing import Any, Callable, Dict, IO, Iterable, Optional, TypeVar, Union, overload +from urllib.parse import parse_qs, urljoin, urlparse + +from azure.core.exceptions import ( + ClientAuthenticationError, + HttpResponseError, + ResourceExistsError, + ResourceNotFoundError, + ResourceNotModifiedError, + map_error, +) from azure.core.paging import ItemPaged from azure.core.pipeline import PipelineResponse from azure.core.pipeline.transport import HttpResponse from azure.core.rest import HttpRequest from azure.core.tracing.decorator import distributed_trace +from azure.core.utils import case_insensitive_dict from azure.mgmt.core.exceptions import ARMErrorFormat from .. import models as _models +from ..._serialization import Serializer from .._vendor import _convert_request, _format_url_section -T = TypeVar('T') -JSONType = Any + +T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] _SERIALIZER = Serializer() _SERIALIZER.client_side_validation = False + def build_template_specs_create_or_update_request( - subscription_id: str, - resource_group_name: str, - template_spec_name: str, - *, - json: JSONType = None, - content: Any = None, - **kwargs: Any + resource_group_name: str, template_spec_name: str, subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2022-02-01") # type: str - content_type = kwargs.pop('content_type', None) # type: Optional[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", "2022-02-01")) # type: str + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + accept = _headers.pop("Accept", "application/json") - accept = "application/json" # Construct URL - _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Resources/templateSpecs/{templateSpecName}") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Resources/templateSpecs/{templateSpecName}", + ) # pylint: disable=line-too-long path_format_arguments = { - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._\(\)]+$'), - "templateSpecName": _SERIALIZER.url("template_spec_name", template_spec_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._\(\)]+$'), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url( + "resource_group_name", resource_group_name, "str", max_length=90, min_length=1, pattern=r"^[-\w\._\(\)]+$" + ), + "templateSpecName": _SERIALIZER.url( + "template_spec_name", template_spec_name, "str", max_length=90, min_length=1, pattern=r"^[-\w\._\(\)]+$" + ), } _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] if content_type is not None: - _header_parameters['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') - _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers["Content-Type"] = _SERIALIZER.header("content_type", content_type, "str") + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - return HttpRequest( - method="PUT", - url=_url, - params=_query_parameters, - headers=_header_parameters, - json=json, - content=content, - **kwargs - ) + return HttpRequest(method="PUT", url=_url, params=_params, headers=_headers, **kwargs) def build_template_specs_update_request( - subscription_id: str, - resource_group_name: str, - template_spec_name: str, - *, - json: JSONType = None, - content: Any = None, - **kwargs: Any + resource_group_name: str, template_spec_name: str, subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2022-02-01") # type: str - content_type = kwargs.pop('content_type', None) # type: Optional[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", "2022-02-01")) # type: str + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + accept = _headers.pop("Accept", "application/json") - accept = "application/json" # Construct URL - _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Resources/templateSpecs/{templateSpecName}") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Resources/templateSpecs/{templateSpecName}", + ) # pylint: disable=line-too-long path_format_arguments = { - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._\(\)]+$'), - "templateSpecName": _SERIALIZER.url("template_spec_name", template_spec_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._\(\)]+$'), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url( + "resource_group_name", resource_group_name, "str", max_length=90, min_length=1, pattern=r"^[-\w\._\(\)]+$" + ), + "templateSpecName": _SERIALIZER.url( + "template_spec_name", template_spec_name, "str", max_length=90, min_length=1, pattern=r"^[-\w\._\(\)]+$" + ), } _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] if content_type is not None: - _header_parameters['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') - _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers["Content-Type"] = _SERIALIZER.header("content_type", content_type, "str") + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - return HttpRequest( - method="PATCH", - url=_url, - params=_query_parameters, - headers=_header_parameters, - json=json, - content=content, - **kwargs - ) + return HttpRequest(method="PATCH", url=_url, params=_params, headers=_headers, **kwargs) def build_template_specs_get_request( - subscription_id: str, resource_group_name: str, template_spec_name: str, + subscription_id: str, *, expand: Optional[Union[str, "_models.TemplateSpecExpandKind"]] = None, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2022-02-01") # type: 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", "2022-02-01")) # type: str + accept = _headers.pop("Accept", "application/json") - accept = "application/json" # Construct URL - _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Resources/templateSpecs/{templateSpecName}") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Resources/templateSpecs/{templateSpecName}", + ) # pylint: disable=line-too-long path_format_arguments = { - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._\(\)]+$'), - "templateSpecName": _SERIALIZER.url("template_spec_name", template_spec_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._\(\)]+$'), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url( + "resource_group_name", resource_group_name, "str", max_length=90, min_length=1, pattern=r"^[-\w\._\(\)]+$" + ), + "templateSpecName": _SERIALIZER.url( + "template_spec_name", template_spec_name, "str", max_length=90, min_length=1, pattern=r"^[-\w\._\(\)]+$" + ), } _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] if expand is not None: - _query_parameters['$expand'] = _SERIALIZER.query("expand", expand, 'str') - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["$expand"] = _SERIALIZER.query("expand", expand, "str") + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - return HttpRequest( - method="GET", - url=_url, - params=_query_parameters, - headers=_header_parameters, - **kwargs - ) + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) def build_template_specs_delete_request( - subscription_id: str, - resource_group_name: str, - template_spec_name: str, - **kwargs: Any + resource_group_name: str, template_spec_name: str, subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2022-02-01") # type: 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", "2022-02-01")) # type: str + accept = _headers.pop("Accept", "application/json") - accept = "application/json" # Construct URL - _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Resources/templateSpecs/{templateSpecName}") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Resources/templateSpecs/{templateSpecName}", + ) # pylint: disable=line-too-long path_format_arguments = { - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._\(\)]+$'), - "templateSpecName": _SERIALIZER.url("template_spec_name", template_spec_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._\(\)]+$'), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url( + "resource_group_name", resource_group_name, "str", max_length=90, min_length=1, pattern=r"^[-\w\._\(\)]+$" + ), + "templateSpecName": _SERIALIZER.url( + "template_spec_name", template_spec_name, "str", max_length=90, min_length=1, pattern=r"^[-\w\._\(\)]+$" + ), } _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - return HttpRequest( - method="DELETE", - url=_url, - params=_query_parameters, - headers=_header_parameters, - **kwargs - ) + return HttpRequest(method="DELETE", url=_url, params=_params, headers=_headers, **kwargs) def build_template_specs_list_by_subscription_request( - subscription_id: str, - *, - expand: Optional[Union[str, "_models.TemplateSpecExpandKind"]] = None, - **kwargs: Any + subscription_id: str, *, expand: Optional[Union[str, "_models.TemplateSpecExpandKind"]] = None, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2022-02-01") # type: 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", "2022-02-01")) # type: str + accept = _headers.pop("Accept", "application/json") - accept = "application/json" # Construct URL _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/providers/Microsoft.Resources/templateSpecs/") path_format_arguments = { - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), } _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] if expand is not None: - _query_parameters['$expand'] = _SERIALIZER.query("expand", expand, 'str') - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["$expand"] = _SERIALIZER.query("expand", expand, "str") + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - return HttpRequest( - method="GET", - url=_url, - params=_query_parameters, - headers=_header_parameters, - **kwargs - ) + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) def build_template_specs_list_by_resource_group_request( - subscription_id: str, resource_group_name: str, + subscription_id: str, *, expand: Optional[Union[str, "_models.TemplateSpecExpandKind"]] = None, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2022-02-01") # type: 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", "2022-02-01")) # type: str + accept = _headers.pop("Accept", "application/json") - accept = "application/json" # Construct URL - _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Resources/templateSpecs/") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Resources/templateSpecs/", + ) # pylint: disable=line-too-long path_format_arguments = { - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._\(\)]+$'), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url( + "resource_group_name", resource_group_name, "str", max_length=90, min_length=1, pattern=r"^[-\w\._\(\)]+$" + ), } _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] if expand is not None: - _query_parameters['$expand'] = _SERIALIZER.query("expand", expand, 'str') - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["$expand"] = _SERIALIZER.query("expand", expand, "str") + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - return HttpRequest( - method="GET", - url=_url, - params=_query_parameters, - headers=_header_parameters, - **kwargs - ) + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) def build_template_specs_get_built_in_request( - template_spec_name: str, - *, - expand: Optional[Union[str, "_models.TemplateSpecExpandKind"]] = None, - **kwargs: Any + template_spec_name: str, *, expand: Optional[Union[str, "_models.TemplateSpecExpandKind"]] = None, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2022-02-01") # type: 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", "2022-02-01")) # type: str + accept = _headers.pop("Accept", "application/json") - accept = "application/json" # Construct URL _url = kwargs.pop("template_url", "/providers/Microsoft.Resources/builtInTemplateSpecs/{templateSpecName}") path_format_arguments = { - "templateSpecName": _SERIALIZER.url("template_spec_name", template_spec_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._\(\)]+$'), + "templateSpecName": _SERIALIZER.url( + "template_spec_name", template_spec_name, "str", max_length=90, min_length=1, pattern=r"^[-\w\._\(\)]+$" + ), } _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] if expand is not None: - _query_parameters['$expand'] = _SERIALIZER.query("expand", expand, 'str') - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["$expand"] = _SERIALIZER.query("expand", expand, "str") + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - return HttpRequest( - method="GET", - url=_url, - params=_query_parameters, - headers=_header_parameters, - **kwargs - ) + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) def build_template_specs_list_built_ins_request( - *, - expand: Optional[Union[str, "_models.TemplateSpecExpandKind"]] = None, - **kwargs: Any + *, expand: Optional[Union[str, "_models.TemplateSpecExpandKind"]] = None, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2022-02-01") # type: 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", "2022-02-01")) # type: str + accept = _headers.pop("Accept", "application/json") - accept = "application/json" # Construct URL _url = kwargs.pop("template_url", "/providers/Microsoft.Resources/builtInTemplateSpecs/") # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] if expand is not None: - _query_parameters['$expand'] = _SERIALIZER.query("expand", expand, 'str') - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["$expand"] = _SERIALIZER.query("expand", expand, "str") + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - return HttpRequest( - method="GET", - url=_url, - params=_query_parameters, - headers=_header_parameters, - **kwargs - ) + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) def build_template_spec_versions_create_or_update_request( - subscription_id: str, - resource_group_name: str, - template_spec_name: str, - template_spec_version: str, - *, - json: JSONType = None, - content: Any = None, - **kwargs: Any + resource_group_name: str, template_spec_name: str, template_spec_version: str, subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2022-02-01") # type: str - content_type = kwargs.pop('content_type', None) # type: Optional[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", "2022-02-01")) # type: str + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + accept = _headers.pop("Accept", "application/json") - accept = "application/json" # Construct URL - _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Resources/templateSpecs/{templateSpecName}/versions/{templateSpecVersion}") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Resources/templateSpecs/{templateSpecName}/versions/{templateSpecVersion}", + ) # pylint: disable=line-too-long path_format_arguments = { - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._\(\)]+$'), - "templateSpecName": _SERIALIZER.url("template_spec_name", template_spec_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._\(\)]+$'), - "templateSpecVersion": _SERIALIZER.url("template_spec_version", template_spec_version, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._\(\)]+$'), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url( + "resource_group_name", resource_group_name, "str", max_length=90, min_length=1, pattern=r"^[-\w\._\(\)]+$" + ), + "templateSpecName": _SERIALIZER.url( + "template_spec_name", template_spec_name, "str", max_length=90, min_length=1, pattern=r"^[-\w\._\(\)]+$" + ), + "templateSpecVersion": _SERIALIZER.url( + "template_spec_version", + template_spec_version, + "str", + max_length=90, + min_length=1, + pattern=r"^[-\w\._\(\)]+$", + ), } _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] if content_type is not None: - _header_parameters['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') - _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers["Content-Type"] = _SERIALIZER.header("content_type", content_type, "str") + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - return HttpRequest( - method="PUT", - url=_url, - params=_query_parameters, - headers=_header_parameters, - json=json, - content=content, - **kwargs - ) + return HttpRequest(method="PUT", url=_url, params=_params, headers=_headers, **kwargs) def build_template_spec_versions_update_request( - subscription_id: str, - resource_group_name: str, - template_spec_name: str, - template_spec_version: str, - *, - json: JSONType = None, - content: Any = None, - **kwargs: Any + resource_group_name: str, template_spec_name: str, template_spec_version: str, subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2022-02-01") # type: str - content_type = kwargs.pop('content_type', None) # type: Optional[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", "2022-02-01")) # type: str + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + accept = _headers.pop("Accept", "application/json") - accept = "application/json" # Construct URL - _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Resources/templateSpecs/{templateSpecName}/versions/{templateSpecVersion}") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Resources/templateSpecs/{templateSpecName}/versions/{templateSpecVersion}", + ) # pylint: disable=line-too-long path_format_arguments = { - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._\(\)]+$'), - "templateSpecName": _SERIALIZER.url("template_spec_name", template_spec_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._\(\)]+$'), - "templateSpecVersion": _SERIALIZER.url("template_spec_version", template_spec_version, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._\(\)]+$'), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url( + "resource_group_name", resource_group_name, "str", max_length=90, min_length=1, pattern=r"^[-\w\._\(\)]+$" + ), + "templateSpecName": _SERIALIZER.url( + "template_spec_name", template_spec_name, "str", max_length=90, min_length=1, pattern=r"^[-\w\._\(\)]+$" + ), + "templateSpecVersion": _SERIALIZER.url( + "template_spec_version", + template_spec_version, + "str", + max_length=90, + min_length=1, + pattern=r"^[-\w\._\(\)]+$", + ), } _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] if content_type is not None: - _header_parameters['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') - _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers["Content-Type"] = _SERIALIZER.header("content_type", content_type, "str") + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - return HttpRequest( - method="PATCH", - url=_url, - params=_query_parameters, - headers=_header_parameters, - json=json, - content=content, - **kwargs - ) + return HttpRequest(method="PATCH", url=_url, params=_params, headers=_headers, **kwargs) def build_template_spec_versions_get_request( - subscription_id: str, - resource_group_name: str, - template_spec_name: str, - template_spec_version: str, - **kwargs: Any + resource_group_name: str, template_spec_name: str, template_spec_version: str, subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2022-02-01") # type: 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", "2022-02-01")) # type: str + accept = _headers.pop("Accept", "application/json") - accept = "application/json" # Construct URL - _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Resources/templateSpecs/{templateSpecName}/versions/{templateSpecVersion}") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Resources/templateSpecs/{templateSpecName}/versions/{templateSpecVersion}", + ) # pylint: disable=line-too-long path_format_arguments = { - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._\(\)]+$'), - "templateSpecName": _SERIALIZER.url("template_spec_name", template_spec_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._\(\)]+$'), - "templateSpecVersion": _SERIALIZER.url("template_spec_version", template_spec_version, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._\(\)]+$'), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url( + "resource_group_name", resource_group_name, "str", max_length=90, min_length=1, pattern=r"^[-\w\._\(\)]+$" + ), + "templateSpecName": _SERIALIZER.url( + "template_spec_name", template_spec_name, "str", max_length=90, min_length=1, pattern=r"^[-\w\._\(\)]+$" + ), + "templateSpecVersion": _SERIALIZER.url( + "template_spec_version", + template_spec_version, + "str", + max_length=90, + min_length=1, + pattern=r"^[-\w\._\(\)]+$", + ), } _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - return HttpRequest( - method="GET", - url=_url, - params=_query_parameters, - headers=_header_parameters, - **kwargs - ) + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) def build_template_spec_versions_delete_request( - subscription_id: str, - resource_group_name: str, - template_spec_name: str, - template_spec_version: str, - **kwargs: Any + resource_group_name: str, template_spec_name: str, template_spec_version: str, subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2022-02-01") # type: 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", "2022-02-01")) # type: str + accept = _headers.pop("Accept", "application/json") - accept = "application/json" # Construct URL - _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Resources/templateSpecs/{templateSpecName}/versions/{templateSpecVersion}") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Resources/templateSpecs/{templateSpecName}/versions/{templateSpecVersion}", + ) # pylint: disable=line-too-long path_format_arguments = { - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._\(\)]+$'), - "templateSpecName": _SERIALIZER.url("template_spec_name", template_spec_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._\(\)]+$'), - "templateSpecVersion": _SERIALIZER.url("template_spec_version", template_spec_version, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._\(\)]+$'), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url( + "resource_group_name", resource_group_name, "str", max_length=90, min_length=1, pattern=r"^[-\w\._\(\)]+$" + ), + "templateSpecName": _SERIALIZER.url( + "template_spec_name", template_spec_name, "str", max_length=90, min_length=1, pattern=r"^[-\w\._\(\)]+$" + ), + "templateSpecVersion": _SERIALIZER.url( + "template_spec_version", + template_spec_version, + "str", + max_length=90, + min_length=1, + pattern=r"^[-\w\._\(\)]+$", + ), } _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - return HttpRequest( - method="DELETE", - url=_url, - params=_query_parameters, - headers=_header_parameters, - **kwargs - ) + return HttpRequest(method="DELETE", url=_url, params=_params, headers=_headers, **kwargs) def build_template_spec_versions_list_request( - subscription_id: str, - resource_group_name: str, - template_spec_name: str, - **kwargs: Any + resource_group_name: str, template_spec_name: str, subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2022-02-01") # type: 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", "2022-02-01")) # type: str + accept = _headers.pop("Accept", "application/json") - accept = "application/json" # Construct URL - _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Resources/templateSpecs/{templateSpecName}/versions") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Resources/templateSpecs/{templateSpecName}/versions", + ) # pylint: disable=line-too-long path_format_arguments = { - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._\(\)]+$'), - "templateSpecName": _SERIALIZER.url("template_spec_name", template_spec_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._\(\)]+$'), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url( + "resource_group_name", resource_group_name, "str", max_length=90, min_length=1, pattern=r"^[-\w\._\(\)]+$" + ), + "templateSpecName": _SERIALIZER.url( + "template_spec_name", template_spec_name, "str", max_length=90, min_length=1, pattern=r"^[-\w\._\(\)]+$" + ), } _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - return HttpRequest( - method="GET", - url=_url, - params=_query_parameters, - headers=_header_parameters, - **kwargs - ) + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) -def build_template_spec_versions_list_built_ins_request( - template_spec_name: str, - **kwargs: Any -) -> HttpRequest: - api_version = kwargs.pop('api_version', "2022-02-01") # type: str +def build_template_spec_versions_list_built_ins_request(template_spec_name: str, **kwargs: Any) -> HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2022-02-01")) # type: str + accept = _headers.pop("Accept", "application/json") - accept = "application/json" # Construct URL _url = kwargs.pop("template_url", "/providers/Microsoft.Resources/builtInTemplateSpecs/{templateSpecName}/versions") path_format_arguments = { - "templateSpecName": _SERIALIZER.url("template_spec_name", template_spec_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._\(\)]+$'), + "templateSpecName": _SERIALIZER.url( + "template_spec_name", template_spec_name, "str", max_length=90, min_length=1, pattern=r"^[-\w\._\(\)]+$" + ), } _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - return HttpRequest( - method="GET", - url=_url, - params=_query_parameters, - headers=_header_parameters, - **kwargs - ) + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) def build_template_spec_versions_get_built_in_request( - template_spec_name: str, - template_spec_version: str, - **kwargs: Any + template_spec_name: str, template_spec_version: str, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2022-02-01") # type: 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", "2022-02-01")) # type: str + accept = _headers.pop("Accept", "application/json") - accept = "application/json" # Construct URL - _url = kwargs.pop("template_url", "/providers/Microsoft.Resources/builtInTemplateSpecs/{templateSpecName}/versions/{templateSpecVersion}") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", + "/providers/Microsoft.Resources/builtInTemplateSpecs/{templateSpecName}/versions/{templateSpecVersion}", + ) # pylint: disable=line-too-long path_format_arguments = { - "templateSpecName": _SERIALIZER.url("template_spec_name", template_spec_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._\(\)]+$'), - "templateSpecVersion": _SERIALIZER.url("template_spec_version", template_spec_version, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._\(\)]+$'), + "templateSpecName": _SERIALIZER.url( + "template_spec_name", template_spec_name, "str", max_length=90, min_length=1, pattern=r"^[-\w\._\(\)]+$" + ), + "templateSpecVersion": _SERIALIZER.url( + "template_spec_version", + template_spec_version, + "str", + max_length=90, + min_length=1, + pattern=r"^[-\w\._\(\)]+$", + ), } _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') - - return HttpRequest( - method="GET", - url=_url, - params=_query_parameters, - headers=_header_parameters, - **kwargs - ) - -class TemplateSpecsOperations(object): - """TemplateSpecsOperations operations. - - You should not instantiate this class directly. Instead, you should create a Client instance that - instantiates it for you and attaches it as an attribute. - - :ivar models: Alias to model classes used in this operation group. - :type models: ~azure.mgmt.resource.templatespecs.v2022_02_01.models - :param client: Client for service requests. - :param config: Configuration of service client. - :param serializer: An object model serializer. - :param deserializer: An object model deserializer. + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) + + +class TemplateSpecsOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. + + Instead, you should access the following operations through + :class:`~azure.mgmt.resource.templatespecs.v2022_02_01.TemplateSpecsClient`'s + :attr:`template_specs` attribute. """ models = _models - def __init__(self, client, config, serializer, deserializer): - self._client = client - self._serialize = serializer - self._deserialize = deserializer - self._config = config + def __init__(self, *args, **kwargs): + input_args = list(args) + self._client = input_args.pop(0) if input_args else kwargs.pop("client") + self._config = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") - @distributed_trace + @overload def create_or_update( self, resource_group_name: str, template_spec_name: str, - template_spec: "_models.TemplateSpec", + template_spec: _models.TemplateSpec, + *, + content_type: str = "application/json", **kwargs: Any - ) -> "_models.TemplateSpec": + ) -> _models.TemplateSpec: """Creates or updates a Template Spec. :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. :type resource_group_name: str - :param template_spec_name: Name of the Template Spec. + :param template_spec_name: Name of the Template Spec. Required. :type template_spec_name: str - :param template_spec: Template Spec supplied to the operation. + :param template_spec: Template Spec supplied to the operation. Required. :type template_spec: ~azure.mgmt.resource.templatespecs.v2022_02_01.models.TemplateSpec + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: TemplateSpec, or the result of cls(response) + :return: TemplateSpec or the result of cls(response) :rtype: ~azure.mgmt.resource.templatespecs.v2022_02_01.models.TemplateSpec - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + def create_or_update( + self, + resource_group_name: str, + template_spec_name: str, + template_spec: IO, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.TemplateSpec: + """Creates or updates a Template Spec. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param template_spec_name: Name of the Template Spec. Required. + :type template_spec_name: str + :param template_spec: Template Spec supplied to the operation. Required. + :type template_spec: IO + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: TemplateSpec or the result of cls(response) + :rtype: ~azure.mgmt.resource.templatespecs.v2022_02_01.models.TemplateSpec + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace + def create_or_update( + self, + resource_group_name: str, + template_spec_name: str, + template_spec: Union[_models.TemplateSpec, IO], + **kwargs: Any + ) -> _models.TemplateSpec: + """Creates or updates a Template Spec. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param template_spec_name: Name of the Template Spec. Required. + :type template_spec_name: str + :param template_spec: Template Spec supplied to the operation. Is either a model type or a IO + type. Required. + :type template_spec: ~azure.mgmt.resource.templatespecs.v2022_02_01.models.TemplateSpec or IO + :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. + Default value is None. + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: TemplateSpec or the result of cls(response) + :rtype: ~azure.mgmt.resource.templatespecs.v2022_02_01.models.TemplateSpec + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.TemplateSpec"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', "2022-02-01") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + api_version = kwargs.pop("api_version", _params.pop("api-version", "2022-02-01")) # type: str + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.TemplateSpec] - _json = self._serialize.body(template_spec, 'TemplateSpec') + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(template_spec, (IO, bytes)): + _content = template_spec + else: + _json = self._serialize.body(template_spec, "TemplateSpec") request = build_template_specs_create_or_update_request( - subscription_id=self._config.subscription_id, resource_group_name=resource_group_name, template_spec_name=template_spec_name, + subscription_id=self._config.subscription_id, api_version=api_version, content_type=content_type, json=_json, - template_url=self.create_or_update.metadata['url'], + content=_content, + template_url=self.create_or_update.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200, 201]: @@ -679,73 +737,149 @@ def create_or_update( raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) if response.status_code == 200: - deserialized = self._deserialize('TemplateSpec', pipeline_response) + deserialized = self._deserialize("TemplateSpec", pipeline_response) if response.status_code == 201: - deserialized = self._deserialize('TemplateSpec', pipeline_response) + deserialized = self._deserialize("TemplateSpec", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - create_or_update.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Resources/templateSpecs/{templateSpecName}"} # type: ignore - + create_or_update.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Resources/templateSpecs/{templateSpecName}"} # type: ignore - @distributed_trace + @overload def update( self, resource_group_name: str, template_spec_name: str, - template_spec: Optional["_models.TemplateSpecUpdateModel"] = None, + template_spec: Optional[_models.TemplateSpecUpdateModel] = None, + *, + content_type: str = "application/json", **kwargs: Any - ) -> "_models.TemplateSpec": + ) -> _models.TemplateSpec: """Updates Template Spec tags with specified values. :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. :type resource_group_name: str - :param template_spec_name: Name of the Template Spec. + :param template_spec_name: Name of the Template Spec. Required. :type template_spec_name: str :param template_spec: Template Spec resource with the tags to be updated. Default value is None. :type template_spec: ~azure.mgmt.resource.templatespecs.v2022_02_01.models.TemplateSpecUpdateModel + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: TemplateSpec or the result of cls(response) + :rtype: ~azure.mgmt.resource.templatespecs.v2022_02_01.models.TemplateSpec + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + def update( + self, + resource_group_name: str, + template_spec_name: str, + template_spec: Optional[IO] = None, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.TemplateSpec: + """Updates Template Spec tags with specified values. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param template_spec_name: Name of the Template Spec. Required. + :type template_spec_name: str + :param template_spec: Template Spec resource with the tags to be updated. Default value is + None. + :type template_spec: IO + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: TemplateSpec, or the result of cls(response) + :return: TemplateSpec or the result of cls(response) :rtype: ~azure.mgmt.resource.templatespecs.v2022_02_01.models.TemplateSpec - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace + def update( + self, + resource_group_name: str, + template_spec_name: str, + template_spec: Optional[Union[_models.TemplateSpecUpdateModel, IO]] = None, + **kwargs: Any + ) -> _models.TemplateSpec: + """Updates Template Spec tags with specified values. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param template_spec_name: Name of the Template Spec. Required. + :type template_spec_name: str + :param template_spec: Template Spec resource with the tags to be updated. Is either a model + type or a IO type. Default value is None. + :type template_spec: + ~azure.mgmt.resource.templatespecs.v2022_02_01.models.TemplateSpecUpdateModel or IO + :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. + Default value is None. + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: TemplateSpec or the result of cls(response) + :rtype: ~azure.mgmt.resource.templatespecs.v2022_02_01.models.TemplateSpec + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.TemplateSpec"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', "2022-02-01") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + api_version = kwargs.pop("api_version", _params.pop("api-version", "2022-02-01")) # type: str + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.TemplateSpec] - if template_spec is not None: - _json = self._serialize.body(template_spec, 'TemplateSpecUpdateModel') + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(template_spec, (IO, bytes)): + _content = template_spec else: - _json = None + if template_spec is not None: + _json = self._serialize.body(template_spec, "TemplateSpecUpdateModel") + else: + _json = None request = build_template_specs_update_request( - subscription_id=self._config.subscription_id, resource_group_name=resource_group_name, template_spec_name=template_spec_name, + subscription_id=self._config.subscription_id, api_version=api_version, content_type=content_type, json=_json, - template_url=self.update.metadata['url'], + content=_content, + template_url=self.update.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200]: @@ -753,15 +887,14 @@ def update( error = self._deserialize.failsafe_deserialize(_models.TemplateSpecsError, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - deserialized = self._deserialize('TemplateSpec', pipeline_response) + deserialized = self._deserialize("TemplateSpec", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - update.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Resources/templateSpecs/{templateSpecName}"} # type: ignore - + update.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Resources/templateSpecs/{templateSpecName}"} # type: ignore @distributed_trace def get( @@ -770,47 +903,54 @@ def get( template_spec_name: str, expand: Optional[Union[str, "_models.TemplateSpecExpandKind"]] = None, **kwargs: Any - ) -> "_models.TemplateSpec": + ) -> _models.TemplateSpec: """Gets a Template Spec with a given name. :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. :type resource_group_name: str - :param template_spec_name: Name of the Template Spec. + :param template_spec_name: Name of the Template Spec. Required. :type template_spec_name: str :param expand: Allows for expansion of additional Template Spec details in the response. - Optional. Default value is None. + Optional. "versions" Default value is None. :type expand: str or ~azure.mgmt.resource.templatespecs.v2022_02_01.models.TemplateSpecExpandKind :keyword callable cls: A custom type or function that will be passed the direct response - :return: TemplateSpec, or the result of cls(response) + :return: TemplateSpec or the result of cls(response) :rtype: ~azure.mgmt.resource.templatespecs.v2022_02_01.models.TemplateSpec - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.TemplateSpec"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) - api_version = kwargs.pop('api_version', "2022-02-01") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2022-02-01")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[_models.TemplateSpec] - request = build_template_specs_get_request( - subscription_id=self._config.subscription_id, resource_group_name=resource_group_name, template_spec_name=template_spec_name, - api_version=api_version, + subscription_id=self._config.subscription_id, expand=expand, - template_url=self.get.metadata['url'], + api_version=api_version, + template_url=self.get.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200]: @@ -818,59 +958,62 @@ def get( error = self._deserialize.failsafe_deserialize(_models.TemplateSpecsError, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - deserialized = self._deserialize('TemplateSpec', pipeline_response) + deserialized = self._deserialize("TemplateSpec", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - get.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Resources/templateSpecs/{templateSpecName}"} # type: ignore - + get.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Resources/templateSpecs/{templateSpecName}"} # type: ignore @distributed_trace def delete( # pylint: disable=inconsistent-return-statements - self, - resource_group_name: str, - template_spec_name: str, - **kwargs: Any + self, resource_group_name: str, template_spec_name: str, **kwargs: Any ) -> None: """Deletes a Template Spec by name. When operation completes, status code 200 returned without content. :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. :type resource_group_name: str - :param template_spec_name: Name of the Template Spec. + :param template_spec_name: Name of the Template Spec. Required. :type template_spec_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: None, or the result of cls(response) + :return: None or the result of cls(response) :rtype: None - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType[None] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) - api_version = kwargs.pop('api_version', "2022-02-01") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2022-02-01")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[None] - request = build_template_specs_delete_request( - subscription_id=self._config.subscription_id, resource_group_name=resource_group_name, template_spec_name=template_spec_name, + subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.delete.metadata['url'], + template_url=self.delete.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200, 204]: @@ -881,55 +1024,60 @@ def delete( # pylint: disable=inconsistent-return-statements if cls: return cls(pipeline_response, None, {}) - delete.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Resources/templateSpecs/{templateSpecName}"} # type: ignore - + delete.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Resources/templateSpecs/{templateSpecName}"} # type: ignore @distributed_trace def list_by_subscription( - self, - expand: Optional[Union[str, "_models.TemplateSpecExpandKind"]] = None, - **kwargs: Any - ) -> Iterable["_models.TemplateSpecsListResult"]: + self, expand: Optional[Union[str, "_models.TemplateSpecExpandKind"]] = None, **kwargs: Any + ) -> Iterable["_models.TemplateSpec"]: """Lists all the Template Specs within the specified subscriptions. :param expand: Allows for expansion of additional Template Spec details in the response. - Optional. Default value is None. + Optional. "versions" Default value is None. :type expand: str or ~azure.mgmt.resource.templatespecs.v2022_02_01.models.TemplateSpecExpandKind :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either TemplateSpecsListResult or the result of - cls(response) + :return: An iterator like instance of either TemplateSpec or the result of cls(response) :rtype: - ~azure.core.paging.ItemPaged[~azure.mgmt.resource.templatespecs.v2022_02_01.models.TemplateSpecsListResult] - :raises: ~azure.core.exceptions.HttpResponseError + ~azure.core.paging.ItemPaged[~azure.mgmt.resource.templatespecs.v2022_02_01.models.TemplateSpec] + :raises ~azure.core.exceptions.HttpResponseError: """ - api_version = kwargs.pop('api_version', "2022-02-01") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2022-02-01")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[_models.TemplateSpecsListResult] - cls = kwargs.pop('cls', None) # type: ClsType["_models.TemplateSpecsListResult"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) + def prepare_request(next_link=None): if not next_link: - + request = build_template_specs_list_by_subscription_request( subscription_id=self._config.subscription_id, - api_version=api_version, expand=expand, - template_url=self.list_by_subscription.metadata['url'], + api_version=api_version, + template_url=self.list_by_subscription.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore else: - - request = build_template_specs_list_by_subscription_request( - subscription_id=self._config.subscription_id, - template_url=next_link, - ) + # make call to next link with the client's api-version + _parsed_next_link = urlparse(next_link) + _next_request_params = case_insensitive_dict(parse_qs(_parsed_next_link.query)) + _next_request_params["api-version"] = self._config.api_version + request = HttpRequest("GET", urljoin(next_link, _parsed_next_link.path), params=_next_request_params) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore request.method = "GET" return request @@ -943,10 +1091,8 @@ def extract_data(pipeline_response): def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) response = pipeline_response.http_response @@ -957,11 +1103,9 @@ def get_next(next_link=None): return pipeline_response + return ItemPaged(get_next, extract_data) - return ItemPaged( - get_next, extract_data - ) - list_by_subscription.metadata = {'url': "/subscriptions/{subscriptionId}/providers/Microsoft.Resources/templateSpecs/"} # type: ignore + list_by_subscription.metadata = {"url": "/subscriptions/{subscriptionId}/providers/Microsoft.Resources/templateSpecs/"} # type: ignore @distributed_trace def list_by_resource_group( @@ -969,51 +1113,59 @@ def list_by_resource_group( resource_group_name: str, expand: Optional[Union[str, "_models.TemplateSpecExpandKind"]] = None, **kwargs: Any - ) -> Iterable["_models.TemplateSpecsListResult"]: + ) -> Iterable["_models.TemplateSpec"]: """Lists all the Template Specs within the specified resource group. :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. :type resource_group_name: str :param expand: Allows for expansion of additional Template Spec details in the response. - Optional. Default value is None. + Optional. "versions" Default value is None. :type expand: str or ~azure.mgmt.resource.templatespecs.v2022_02_01.models.TemplateSpecExpandKind :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either TemplateSpecsListResult or the result of - cls(response) + :return: An iterator like instance of either TemplateSpec or the result of cls(response) :rtype: - ~azure.core.paging.ItemPaged[~azure.mgmt.resource.templatespecs.v2022_02_01.models.TemplateSpecsListResult] - :raises: ~azure.core.exceptions.HttpResponseError + ~azure.core.paging.ItemPaged[~azure.mgmt.resource.templatespecs.v2022_02_01.models.TemplateSpec] + :raises ~azure.core.exceptions.HttpResponseError: """ - api_version = kwargs.pop('api_version', "2022-02-01") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2022-02-01")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[_models.TemplateSpecsListResult] - cls = kwargs.pop('cls', None) # type: ClsType["_models.TemplateSpecsListResult"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) + def prepare_request(next_link=None): if not next_link: - + request = build_template_specs_list_by_resource_group_request( - subscription_id=self._config.subscription_id, resource_group_name=resource_group_name, - api_version=api_version, + subscription_id=self._config.subscription_id, expand=expand, - template_url=self.list_by_resource_group.metadata['url'], + 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.url = self._client.format_url(request.url) # type: ignore else: - - request = build_template_specs_list_by_resource_group_request( - subscription_id=self._config.subscription_id, - resource_group_name=resource_group_name, - template_url=next_link, - ) + # make call to next link with the client's api-version + _parsed_next_link = urlparse(next_link) + _next_request_params = case_insensitive_dict(parse_qs(_parsed_next_link.query)) + _next_request_params["api-version"] = self._config.api_version + request = HttpRequest("GET", urljoin(next_link, _parsed_next_link.path), params=_next_request_params) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore request.method = "GET" return request @@ -1027,10 +1179,8 @@ def extract_data(pipeline_response): def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) response = pipeline_response.http_response @@ -1041,11 +1191,9 @@ def get_next(next_link=None): return pipeline_response + return ItemPaged(get_next, extract_data) - return ItemPaged( - get_next, extract_data - ) - list_by_resource_group.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Resources/templateSpecs/"} # type: ignore + list_by_resource_group.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Resources/templateSpecs/"} # type: ignore @distributed_trace def get_built_in( @@ -1053,43 +1201,49 @@ def get_built_in( template_spec_name: str, expand: Optional[Union[str, "_models.TemplateSpecExpandKind"]] = None, **kwargs: Any - ) -> "_models.TemplateSpec": + ) -> _models.TemplateSpec: """Gets a built-in Template Spec with a given name. - :param template_spec_name: Name of the Template Spec. + :param template_spec_name: Name of the Template Spec. Required. :type template_spec_name: str :param expand: Allows for expansion of additional Template Spec details in the response. - Optional. Default value is None. + Optional. "versions" Default value is None. :type expand: str or ~azure.mgmt.resource.templatespecs.v2022_02_01.models.TemplateSpecExpandKind :keyword callable cls: A custom type or function that will be passed the direct response - :return: TemplateSpec, or the result of cls(response) + :return: TemplateSpec or the result of cls(response) :rtype: ~azure.mgmt.resource.templatespecs.v2022_02_01.models.TemplateSpec - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.TemplateSpec"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + 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', "2022-02-01") # type: str + api_version = kwargs.pop("api_version", _params.pop("api-version", "2022-02-01")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[_models.TemplateSpec] - request = build_template_specs_get_built_in_request( template_spec_name=template_spec_name, - api_version=api_version, expand=expand, - template_url=self.get_built_in.metadata['url'], + api_version=api_version, + template_url=self.get_built_in.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200]: @@ -1097,60 +1251,66 @@ def get_built_in( error = self._deserialize.failsafe_deserialize(_models.TemplateSpecsError, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - deserialized = self._deserialize('TemplateSpec', pipeline_response) + deserialized = self._deserialize("TemplateSpec", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - get_built_in.metadata = {'url': "/providers/Microsoft.Resources/builtInTemplateSpecs/{templateSpecName}"} # type: ignore - + get_built_in.metadata = {"url": "/providers/Microsoft.Resources/builtInTemplateSpecs/{templateSpecName}"} # type: ignore @distributed_trace def list_built_ins( - self, - expand: Optional[Union[str, "_models.TemplateSpecExpandKind"]] = None, - **kwargs: Any - ) -> Iterable["_models.TemplateSpecsListResult"]: + self, expand: Optional[Union[str, "_models.TemplateSpecExpandKind"]] = None, **kwargs: Any + ) -> Iterable["_models.TemplateSpec"]: """Lists built-in Template Specs. :param expand: Allows for expansion of additional Template Spec details in the response. - Optional. Default value is None. + Optional. "versions" Default value is None. :type expand: str or ~azure.mgmt.resource.templatespecs.v2022_02_01.models.TemplateSpecExpandKind :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either TemplateSpecsListResult or the result of - cls(response) + :return: An iterator like instance of either TemplateSpec or the result of cls(response) :rtype: - ~azure.core.paging.ItemPaged[~azure.mgmt.resource.templatespecs.v2022_02_01.models.TemplateSpecsListResult] - :raises: ~azure.core.exceptions.HttpResponseError + ~azure.core.paging.ItemPaged[~azure.mgmt.resource.templatespecs.v2022_02_01.models.TemplateSpec] + :raises ~azure.core.exceptions.HttpResponseError: """ - api_version = kwargs.pop('api_version', "2022-02-01") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2022-02-01")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[_models.TemplateSpecsListResult] - cls = kwargs.pop('cls', None) # type: ClsType["_models.TemplateSpecsListResult"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) + def prepare_request(next_link=None): if not next_link: - + request = build_template_specs_list_built_ins_request( - api_version=api_version, expand=expand, - template_url=self.list_built_ins.metadata['url'], + api_version=api_version, + template_url=self.list_built_ins.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore else: - - request = build_template_specs_list_built_ins_request( - template_url=next_link, - ) + # make call to next link with the client's api-version + _parsed_next_link = urlparse(next_link) + _next_request_params = case_insensitive_dict(parse_qs(_parsed_next_link.query)) + _next_request_params["api-version"] = self._config.api_version + request = HttpRequest("GET", urljoin(next_link, _parsed_next_link.path), params=_next_request_params) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore request.method = "GET" return request @@ -1164,10 +1324,8 @@ def extract_data(pipeline_response): def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) response = pipeline_response.http_response @@ -1178,87 +1336,166 @@ def get_next(next_link=None): return pipeline_response + return ItemPaged(get_next, extract_data) - return ItemPaged( - get_next, extract_data - ) - list_built_ins.metadata = {'url': "/providers/Microsoft.Resources/builtInTemplateSpecs/"} # type: ignore -class TemplateSpecVersionsOperations(object): - """TemplateSpecVersionsOperations operations. - - You should not instantiate this class directly. Instead, you should create a Client instance that - instantiates it for you and attaches it as an attribute. - - :ivar models: Alias to model classes used in this operation group. - :type models: ~azure.mgmt.resource.templatespecs.v2022_02_01.models - :param client: Client for service requests. - :param config: Configuration of service client. - :param serializer: An object model serializer. - :param deserializer: An object model deserializer. + list_built_ins.metadata = {"url": "/providers/Microsoft.Resources/builtInTemplateSpecs/"} # type: ignore + + +class TemplateSpecVersionsOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. + + Instead, you should access the following operations through + :class:`~azure.mgmt.resource.templatespecs.v2022_02_01.TemplateSpecsClient`'s + :attr:`template_spec_versions` attribute. """ models = _models - def __init__(self, client, config, serializer, deserializer): - self._client = client - self._serialize = serializer - self._deserialize = deserializer - self._config = config + def __init__(self, *args, **kwargs): + input_args = list(args) + self._client = input_args.pop(0) if input_args else kwargs.pop("client") + self._config = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") - @distributed_trace + @overload def create_or_update( self, resource_group_name: str, template_spec_name: str, template_spec_version: str, - template_spec_version_model: "_models.TemplateSpecVersion", + template_spec_version_model: _models.TemplateSpecVersion, + *, + content_type: str = "application/json", **kwargs: Any - ) -> "_models.TemplateSpecVersion": + ) -> _models.TemplateSpecVersion: """Creates or updates a Template Spec version. :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. :type resource_group_name: str - :param template_spec_name: Name of the Template Spec. + :param template_spec_name: Name of the Template Spec. Required. :type template_spec_name: str - :param template_spec_version: The version of the Template Spec. + :param template_spec_version: The version of the Template Spec. Required. :type template_spec_version: str - :param template_spec_version_model: Template Spec Version supplied to the operation. + :param template_spec_version_model: Template Spec Version supplied to the operation. Required. :type template_spec_version_model: ~azure.mgmt.resource.templatespecs.v2022_02_01.models.TemplateSpecVersion + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: TemplateSpecVersion or the result of cls(response) + :rtype: ~azure.mgmt.resource.templatespecs.v2022_02_01.models.TemplateSpecVersion + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + def create_or_update( + self, + resource_group_name: str, + template_spec_name: str, + template_spec_version: str, + template_spec_version_model: IO, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.TemplateSpecVersion: + """Creates or updates a Template Spec version. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param template_spec_name: Name of the Template Spec. Required. + :type template_spec_name: str + :param template_spec_version: The version of the Template Spec. Required. + :type template_spec_version: str + :param template_spec_version_model: Template Spec Version supplied to the operation. Required. + :type template_spec_version_model: IO + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: TemplateSpecVersion or the result of cls(response) + :rtype: ~azure.mgmt.resource.templatespecs.v2022_02_01.models.TemplateSpecVersion + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace + def create_or_update( + self, + resource_group_name: str, + template_spec_name: str, + template_spec_version: str, + template_spec_version_model: Union[_models.TemplateSpecVersion, IO], + **kwargs: Any + ) -> _models.TemplateSpecVersion: + """Creates or updates a Template Spec version. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param template_spec_name: Name of the Template Spec. Required. + :type template_spec_name: str + :param template_spec_version: The version of the Template Spec. Required. + :type template_spec_version: str + :param template_spec_version_model: Template Spec Version supplied to the operation. Is either + a model type or a IO type. Required. + :type template_spec_version_model: + ~azure.mgmt.resource.templatespecs.v2022_02_01.models.TemplateSpecVersion or IO + :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. + Default value is None. + :paramtype content_type: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: TemplateSpecVersion, or the result of cls(response) + :return: TemplateSpecVersion or the result of cls(response) :rtype: ~azure.mgmt.resource.templatespecs.v2022_02_01.models.TemplateSpecVersion - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.TemplateSpecVersion"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', "2022-02-01") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + api_version = kwargs.pop("api_version", _params.pop("api-version", "2022-02-01")) # type: str + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.TemplateSpecVersion] - _json = self._serialize.body(template_spec_version_model, 'TemplateSpecVersion') + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(template_spec_version_model, (IO, bytes)): + _content = template_spec_version_model + else: + _json = self._serialize.body(template_spec_version_model, "TemplateSpecVersion") request = build_template_spec_versions_create_or_update_request( - subscription_id=self._config.subscription_id, resource_group_name=resource_group_name, template_spec_name=template_spec_name, template_spec_version=template_spec_version, + subscription_id=self._config.subscription_id, api_version=api_version, content_type=content_type, json=_json, - template_url=self.create_or_update.metadata['url'], + content=_content, + template_url=self.create_or_update.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200, 201]: @@ -1267,77 +1504,159 @@ def create_or_update( raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) if response.status_code == 200: - deserialized = self._deserialize('TemplateSpecVersion', pipeline_response) + deserialized = self._deserialize("TemplateSpecVersion", pipeline_response) if response.status_code == 201: - deserialized = self._deserialize('TemplateSpecVersion', pipeline_response) + deserialized = self._deserialize("TemplateSpecVersion", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - create_or_update.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Resources/templateSpecs/{templateSpecName}/versions/{templateSpecVersion}"} # type: ignore - + create_or_update.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Resources/templateSpecs/{templateSpecName}/versions/{templateSpecVersion}"} # type: ignore - @distributed_trace + @overload def update( self, resource_group_name: str, template_spec_name: str, template_spec_version: str, - template_spec_version_update_model: Optional["_models.TemplateSpecVersionUpdateModel"] = None, + template_spec_version_update_model: Optional[_models.TemplateSpecVersionUpdateModel] = None, + *, + content_type: str = "application/json", **kwargs: Any - ) -> "_models.TemplateSpecVersion": + ) -> _models.TemplateSpecVersion: """Updates Template Spec Version tags with specified values. :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. :type resource_group_name: str - :param template_spec_name: Name of the Template Spec. + :param template_spec_name: Name of the Template Spec. Required. :type template_spec_name: str - :param template_spec_version: The version of the Template Spec. + :param template_spec_version: The version of the Template Spec. Required. :type template_spec_version: str :param template_spec_version_update_model: Template Spec Version resource with the tags to be updated. Default value is None. :type template_spec_version_update_model: ~azure.mgmt.resource.templatespecs.v2022_02_01.models.TemplateSpecVersionUpdateModel + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: TemplateSpecVersion or the result of cls(response) + :rtype: ~azure.mgmt.resource.templatespecs.v2022_02_01.models.TemplateSpecVersion + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + def update( + self, + resource_group_name: str, + template_spec_name: str, + template_spec_version: str, + template_spec_version_update_model: Optional[IO] = None, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.TemplateSpecVersion: + """Updates Template Spec Version tags with specified values. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param template_spec_name: Name of the Template Spec. Required. + :type template_spec_name: str + :param template_spec_version: The version of the Template Spec. Required. + :type template_spec_version: str + :param template_spec_version_update_model: Template Spec Version resource with the tags to be + updated. Default value is None. + :type template_spec_version_update_model: IO + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: TemplateSpecVersion or the result of cls(response) + :rtype: ~azure.mgmt.resource.templatespecs.v2022_02_01.models.TemplateSpecVersion + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace + def update( + self, + resource_group_name: str, + template_spec_name: str, + template_spec_version: str, + template_spec_version_update_model: Optional[Union[_models.TemplateSpecVersionUpdateModel, IO]] = None, + **kwargs: Any + ) -> _models.TemplateSpecVersion: + """Updates Template Spec Version tags with specified values. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param template_spec_name: Name of the Template Spec. Required. + :type template_spec_name: str + :param template_spec_version: The version of the Template Spec. Required. + :type template_spec_version: str + :param template_spec_version_update_model: Template Spec Version resource with the tags to be + updated. Is either a model type or a IO type. Default value is None. + :type template_spec_version_update_model: + ~azure.mgmt.resource.templatespecs.v2022_02_01.models.TemplateSpecVersionUpdateModel or IO + :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. + Default value is None. + :paramtype content_type: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: TemplateSpecVersion, or the result of cls(response) + :return: TemplateSpecVersion or the result of cls(response) :rtype: ~azure.mgmt.resource.templatespecs.v2022_02_01.models.TemplateSpecVersion - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.TemplateSpecVersion"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', "2022-02-01") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + api_version = kwargs.pop("api_version", _params.pop("api-version", "2022-02-01")) # type: str + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.TemplateSpecVersion] - if template_spec_version_update_model is not None: - _json = self._serialize.body(template_spec_version_update_model, 'TemplateSpecVersionUpdateModel') + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(template_spec_version_update_model, (IO, bytes)): + _content = template_spec_version_update_model else: - _json = None + if template_spec_version_update_model is not None: + _json = self._serialize.body(template_spec_version_update_model, "TemplateSpecVersionUpdateModel") + else: + _json = None request = build_template_spec_versions_update_request( - subscription_id=self._config.subscription_id, resource_group_name=resource_group_name, template_spec_name=template_spec_name, template_spec_version=template_spec_version, + subscription_id=self._config.subscription_id, api_version=api_version, content_type=content_type, json=_json, - template_url=self.update.metadata['url'], + content=_content, + template_url=self.update.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200]: @@ -1345,62 +1664,64 @@ def update( error = self._deserialize.failsafe_deserialize(_models.TemplateSpecsError, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - deserialized = self._deserialize('TemplateSpecVersion', pipeline_response) + deserialized = self._deserialize("TemplateSpecVersion", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - update.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Resources/templateSpecs/{templateSpecName}/versions/{templateSpecVersion}"} # type: ignore - + update.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Resources/templateSpecs/{templateSpecName}/versions/{templateSpecVersion}"} # type: ignore @distributed_trace def get( - self, - resource_group_name: str, - template_spec_name: str, - template_spec_version: str, - **kwargs: Any - ) -> "_models.TemplateSpecVersion": + self, resource_group_name: str, template_spec_name: str, template_spec_version: str, **kwargs: Any + ) -> _models.TemplateSpecVersion: """Gets a Template Spec version from a specific Template Spec. :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. :type resource_group_name: str - :param template_spec_name: Name of the Template Spec. + :param template_spec_name: Name of the Template Spec. Required. :type template_spec_name: str - :param template_spec_version: The version of the Template Spec. + :param template_spec_version: The version of the Template Spec. Required. :type template_spec_version: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: TemplateSpecVersion, or the result of cls(response) + :return: TemplateSpecVersion or the result of cls(response) :rtype: ~azure.mgmt.resource.templatespecs.v2022_02_01.models.TemplateSpecVersion - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.TemplateSpecVersion"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + 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', "2022-02-01") # type: str + api_version = kwargs.pop("api_version", _params.pop("api-version", "2022-02-01")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[_models.TemplateSpecVersion] - request = build_template_spec_versions_get_request( - subscription_id=self._config.subscription_id, resource_group_name=resource_group_name, template_spec_name=template_spec_name, template_spec_version=template_spec_version, + subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.get.metadata['url'], + template_url=self.get.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200]: @@ -1408,63 +1729,65 @@ def get( error = self._deserialize.failsafe_deserialize(_models.TemplateSpecsError, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - deserialized = self._deserialize('TemplateSpecVersion', pipeline_response) + deserialized = self._deserialize("TemplateSpecVersion", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - get.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Resources/templateSpecs/{templateSpecName}/versions/{templateSpecVersion}"} # type: ignore - + get.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Resources/templateSpecs/{templateSpecName}/versions/{templateSpecVersion}"} # type: ignore @distributed_trace def delete( # pylint: disable=inconsistent-return-statements - self, - resource_group_name: str, - template_spec_name: str, - template_spec_version: str, - **kwargs: Any + self, resource_group_name: str, template_spec_name: str, template_spec_version: str, **kwargs: Any ) -> None: """Deletes a specific version from a Template Spec. When operation completes, status code 200 returned without content. :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. :type resource_group_name: str - :param template_spec_name: Name of the Template Spec. + :param template_spec_name: Name of the Template Spec. Required. :type template_spec_name: str - :param template_spec_version: The version of the Template Spec. + :param template_spec_version: The version of the Template Spec. Required. :type template_spec_version: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: None, or the result of cls(response) + :return: None or the result of cls(response) :rtype: None - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType[None] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) - api_version = kwargs.pop('api_version', "2022-02-01") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2022-02-01")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[None] - request = build_template_spec_versions_delete_request( - subscription_id=self._config.subscription_id, resource_group_name=resource_group_name, template_spec_name=template_spec_name, template_spec_version=template_spec_version, + subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.delete.metadata['url'], + template_url=self.delete.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200, 204]: @@ -1475,59 +1798,62 @@ def delete( # pylint: disable=inconsistent-return-statements if cls: return cls(pipeline_response, None, {}) - delete.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Resources/templateSpecs/{templateSpecName}/versions/{templateSpecVersion}"} # type: ignore - + delete.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Resources/templateSpecs/{templateSpecName}/versions/{templateSpecVersion}"} # type: ignore @distributed_trace def list( - self, - resource_group_name: str, - template_spec_name: str, - **kwargs: Any - ) -> Iterable["_models.TemplateSpecVersionsListResult"]: + self, resource_group_name: str, template_spec_name: str, **kwargs: Any + ) -> Iterable["_models.TemplateSpecVersion"]: """Lists all the Template Spec versions in the specified Template Spec. :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. :type resource_group_name: str - :param template_spec_name: Name of the Template Spec. + :param template_spec_name: Name of the Template Spec. Required. :type template_spec_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either TemplateSpecVersionsListResult or the result of - cls(response) + :return: An iterator like instance of either TemplateSpecVersion or the result of cls(response) :rtype: - ~azure.core.paging.ItemPaged[~azure.mgmt.resource.templatespecs.v2022_02_01.models.TemplateSpecVersionsListResult] - :raises: ~azure.core.exceptions.HttpResponseError + ~azure.core.paging.ItemPaged[~azure.mgmt.resource.templatespecs.v2022_02_01.models.TemplateSpecVersion] + :raises ~azure.core.exceptions.HttpResponseError: """ - api_version = kwargs.pop('api_version', "2022-02-01") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2022-02-01")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[_models.TemplateSpecVersionsListResult] - cls = kwargs.pop('cls', None) # type: ClsType["_models.TemplateSpecVersionsListResult"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) + def prepare_request(next_link=None): if not next_link: - + request = build_template_spec_versions_list_request( - subscription_id=self._config.subscription_id, resource_group_name=resource_group_name, template_spec_name=template_spec_name, + subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.list.metadata['url'], + template_url=self.list.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore else: - - request = build_template_spec_versions_list_request( - subscription_id=self._config.subscription_id, - resource_group_name=resource_group_name, - template_spec_name=template_spec_name, - template_url=next_link, - ) + # make call to next link with the client's api-version + _parsed_next_link = urlparse(next_link) + _next_request_params = case_insensitive_dict(parse_qs(_parsed_next_link.query)) + _next_request_params["api-version"] = self._config.api_version + request = HttpRequest("GET", urljoin(next_link, _parsed_next_link.path), params=_next_request_params) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore request.method = "GET" return request @@ -1541,10 +1867,8 @@ def extract_data(pipeline_response): def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) response = pipeline_response.http_response @@ -1555,55 +1879,57 @@ def get_next(next_link=None): return pipeline_response + return ItemPaged(get_next, extract_data) - return ItemPaged( - get_next, extract_data - ) - list.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Resources/templateSpecs/{templateSpecName}/versions"} # type: ignore + list.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Resources/templateSpecs/{templateSpecName}/versions"} # type: ignore @distributed_trace - def list_built_ins( - self, - template_spec_name: str, - **kwargs: Any - ) -> Iterable["_models.TemplateSpecVersionsListResult"]: + def list_built_ins(self, template_spec_name: str, **kwargs: Any) -> Iterable["_models.TemplateSpecVersion"]: """Lists all the Template Spec versions in the specified built-in Template Spec. - :param template_spec_name: Name of the Template Spec. + :param template_spec_name: Name of the Template Spec. Required. :type template_spec_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either TemplateSpecVersionsListResult or the result of - cls(response) + :return: An iterator like instance of either TemplateSpecVersion or the result of cls(response) :rtype: - ~azure.core.paging.ItemPaged[~azure.mgmt.resource.templatespecs.v2022_02_01.models.TemplateSpecVersionsListResult] - :raises: ~azure.core.exceptions.HttpResponseError + ~azure.core.paging.ItemPaged[~azure.mgmt.resource.templatespecs.v2022_02_01.models.TemplateSpecVersion] + :raises ~azure.core.exceptions.HttpResponseError: """ - api_version = kwargs.pop('api_version', "2022-02-01") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2022-02-01")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[_models.TemplateSpecVersionsListResult] - cls = kwargs.pop('cls', None) # type: ClsType["_models.TemplateSpecVersionsListResult"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) + def prepare_request(next_link=None): if not next_link: - + request = build_template_spec_versions_list_built_ins_request( template_spec_name=template_spec_name, api_version=api_version, - template_url=self.list_built_ins.metadata['url'], + template_url=self.list_built_ins.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore else: - - request = build_template_spec_versions_list_built_ins_request( - template_spec_name=template_spec_name, - template_url=next_link, - ) + # make call to next link with the client's api-version + _parsed_next_link = urlparse(next_link) + _next_request_params = case_insensitive_dict(parse_qs(_parsed_next_link.query)) + _next_request_params["api-version"] = self._config.api_version + request = HttpRequest("GET", urljoin(next_link, _parsed_next_link.path), params=_next_request_params) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore request.method = "GET" return request @@ -1617,10 +1943,8 @@ def extract_data(pipeline_response): def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) response = pipeline_response.http_response @@ -1631,53 +1955,54 @@ def get_next(next_link=None): return pipeline_response + return ItemPaged(get_next, extract_data) - return ItemPaged( - get_next, extract_data - ) - list_built_ins.metadata = {'url': "/providers/Microsoft.Resources/builtInTemplateSpecs/{templateSpecName}/versions"} # type: ignore + list_built_ins.metadata = {"url": "/providers/Microsoft.Resources/builtInTemplateSpecs/{templateSpecName}/versions"} # type: ignore @distributed_trace def get_built_in( - self, - template_spec_name: str, - template_spec_version: str, - **kwargs: Any - ) -> "_models.TemplateSpecVersion": + self, template_spec_name: str, template_spec_version: str, **kwargs: Any + ) -> _models.TemplateSpecVersion: """Gets a Template Spec version from a specific built-in Template Spec. - :param template_spec_name: Name of the Template Spec. + :param template_spec_name: Name of the Template Spec. Required. :type template_spec_name: str - :param template_spec_version: The version of the Template Spec. + :param template_spec_version: The version of the Template Spec. Required. :type template_spec_version: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: TemplateSpecVersion, or the result of cls(response) + :return: TemplateSpecVersion or the result of cls(response) :rtype: ~azure.mgmt.resource.templatespecs.v2022_02_01.models.TemplateSpecVersion - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.TemplateSpecVersion"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + 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', "2022-02-01") # type: str + api_version = kwargs.pop("api_version", _params.pop("api-version", "2022-02-01")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[_models.TemplateSpecVersion] - request = build_template_spec_versions_get_built_in_request( template_spec_name=template_spec_name, template_spec_version=template_spec_version, api_version=api_version, - template_url=self.get_built_in.metadata['url'], + template_url=self.get_built_in.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200]: @@ -1685,12 +2010,11 @@ def get_built_in( error = self._deserialize.failsafe_deserialize(_models.TemplateSpecsError, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - deserialized = self._deserialize('TemplateSpecVersion', pipeline_response) + deserialized = self._deserialize("TemplateSpecVersion", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - get_built_in.metadata = {'url': "/providers/Microsoft.Resources/builtInTemplateSpecs/{templateSpecName}/versions/{templateSpecVersion}"} # type: ignore - + get_built_in.metadata = {"url": "/providers/Microsoft.Resources/builtInTemplateSpecs/{templateSpecName}/versions/{templateSpecVersion}"} # type: ignore diff --git a/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/templatespecs/v2022_02_01/operations/_patch.py b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/templatespecs/v2022_02_01/operations/_patch.py new file mode 100644 index 0000000000000..f7dd32510333d --- /dev/null +++ b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/templatespecs/v2022_02_01/operations/_patch.py @@ -0,0 +1,20 @@ +# ------------------------------------ +# Copyright (c) Microsoft Corporation. +# Licensed under the MIT License. +# ------------------------------------ +"""Customize generated code here. + +Follow our quickstart for examples: https://aka.ms/azsdk/python/dpcodegen/python/customize +""" +from typing import List + +__all__: List[str] = [] # Add all objects you want publicly available to users at this package level + + +def patch_sdk(): + """Do not remove from this file. + + `patch_sdk` is a last resort escape hatch that allows you to do customizations + you can't accomplish using the techniques described in + https://aka.ms/azsdk/python/dpcodegen/python/customize + """